diff --git a/BassFalling/README.md b/BassFalling/README.md index a9b569c..d3d24e8 100644 --- a/BassFalling/README.md +++ b/BassFalling/README.md @@ -1,14 +1,6 @@ # 模拟球弹跳 -* 定义两个变量,一个speed,一个accelerate。 -* 设置 ball 与 ground 为BoxCollider。检测下落碰撞,设置speed为defaultSpeed -* 在update中设置代码 -~~~ - /** - * 球运动计算 - */ - drop() { - this.node.y += this.speed; - this.speed += this.accelerate; - } -~~~ + + +### 参考 +* http://gaozhongwuli.com/top/481764.html diff --git a/BassFalling/assets/Scene/Sphere.fire b/BassFalling/assets/Scene/Sphere.fire new file mode 100644 index 0000000..e558b0d --- /dev/null +++ b/BassFalling/assets/Scene/Sphere.fire @@ -0,0 +1,407 @@ +[ + { + "__type__": "cc.SceneAsset", + "_name": "", + "_objFlags": 0, + "_rawFiles": null, + "scene": { + "__id__": 1 + } + }, + { + "__type__": "cc.Scene", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + } + ], + "_tag": -1, + "_active": true, + "_components": [], + "_prefab": null, + "_id": "c55dacfa-c727-4c84-858a-44fbdc7ec7d9", + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_cascadeOpacityEnabled": true, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_localZOrder": 0, + "_globalZOrder": 0, + "_opacityModifyRGB": false, + "groupIndex": 0, + "autoReleaseAssets": false + }, + { + "__type__": "cc.Node", + "_name": "Canvas", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 3 + }, + { + "__id__": 6 + } + ], + "_tag": -1, + "_active": true, + "_components": [ + { + "__id__": 11 + } + ], + "_prefab": null, + "_id": "d4cUSAIHNEPpB8HhNrgn4i", + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_cascadeOpacityEnabled": true, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 960, + "height": 640 + }, + "_rotationX": 0, + "_rotationY": 0, + "_scaleX": 1, + "_scaleY": 1, + "_position": { + "__type__": "cc.Vec2", + "x": 480, + "y": 320 + }, + "_skewX": 0, + "_skewY": 0, + "_localZOrder": 0, + "_globalZOrder": 0, + "_opacityModifyRGB": false, + "groupIndex": 0 + }, + { + "__type__": "cc.Node", + "_name": "background", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_tag": -1, + "_active": true, + "_components": [ + { + "__id__": 4 + }, + { + "__id__": 5 + } + ], + "_prefab": null, + "_id": "d2Z0KoB+lEXrW9qf3paETF", + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 27, + "g": 38, + "b": 46, + "a": 255 + }, + "_cascadeOpacityEnabled": true, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 960, + "height": 640 + }, + "_rotationX": 0, + "_rotationY": 0, + "_scaleX": 1, + "_scaleY": 1, + "_position": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_localZOrder": 0, + "_globalZOrder": 0, + "_opacityModifyRGB": false, + "groupIndex": 0 + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 3 + }, + "_enabled": true, + "isAlignOnce": true, + "_target": null, + "_alignFlags": 45, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 200, + "_originalHeight": 150 + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 3 + }, + "_enabled": true, + "_spriteFrame": { + "__uuid__": "410fb916-8721-4663-bab8-34397391ace7" + }, + "_type": 1, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_atlas": null + }, + { + "__type__": "cc.Node", + "_name": "ground", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [ + { + "__id__": 7 + } + ], + "_tag": -1, + "_active": true, + "_components": [ + { + "__id__": 10 + } + ], + "_prefab": null, + "_id": "2c3YyW0hpAz79/x9nJ6Rtx", + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_cascadeOpacityEnabled": true, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 1 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 400, + "height": 10 + }, + "_rotationX": 0, + "_rotationY": 0, + "_scaleX": 1, + "_scaleY": 1, + "_position": { + "__type__": "cc.Vec2", + "x": 0, + "y": -150 + }, + "_skewX": 0, + "_skewY": 0, + "_localZOrder": 0, + "_globalZOrder": 0, + "_opacityModifyRGB": false, + "groupIndex": 2 + }, + { + "__type__": "cc.Node", + "_name": "sphere", + "_objFlags": 0, + "_parent": { + "__id__": 6 + }, + "_children": [], + "_tag": -1, + "_active": true, + "_components": [ + { + "__id__": 8 + }, + { + "__id__": 9 + } + ], + "_prefab": null, + "_id": "2aymuN3yNC+pxa9iNjvBDH", + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_cascadeOpacityEnabled": true, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 100 + }, + "_rotationX": 0, + "_rotationY": 0, + "_scaleX": 1, + "_scaleY": 1, + "_position": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_localZOrder": 0, + "_globalZOrder": 0, + "_opacityModifyRGB": false, + "groupIndex": 0 + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 7 + }, + "_enabled": true, + "_spriteFrame": { + "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_atlas": null + }, + { + "__type__": "d7ad8rXjqJDiK+ZGh6avzpG", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 7 + }, + "_enabled": true, + "accelerate": 500, + "hight": 340, + "direction": 1 + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 6 + }, + "_enabled": true, + "_spriteFrame": { + "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_atlas": null + }, + { + "__type__": "cc.Canvas", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "_designResolution": { + "__type__": "cc.Size", + "width": 960, + "height": 640 + }, + "_fitWidth": false, + "_fitHeight": true + } +] \ No newline at end of file diff --git a/BassFalling/assets/Scene/Sphere.fire.meta b/BassFalling/assets/Scene/Sphere.fire.meta new file mode 100644 index 0000000..5f3da11 --- /dev/null +++ b/BassFalling/assets/Scene/Sphere.fire.meta @@ -0,0 +1,7 @@ +{ + "ver": "1.0.0", + "uuid": "c55dacfa-c727-4c84-858a-44fbdc7ec7d9", + "asyncLoadAssets": false, + "autoReleaseAssets": false, + "subMetas": {} +} \ No newline at end of file diff --git a/BassFalling/assets/Script/SpheroFalling.ts b/BassFalling/assets/Script/SpheroFalling.ts new file mode 100644 index 0000000..db61adb --- /dev/null +++ b/BassFalling/assets/Script/SpheroFalling.ts @@ -0,0 +1,91 @@ + +const { ccclass, property } = cc._decorator; + +export enum Direction { + up = 1, + down = 2 +}; + +@ccclass +export default class SpheroFalling extends cc.Component { + + @property + accelerate: number = 10; + + @property + hight: number = 0; + + @property({ type: cc.Enum(Direction) }) + direction: Direction = Direction.down; + + speed = 0; + curTime = 0; + startSpeed = 0; + finallySpeed = 0; + finishTime = 0; + + onLoad() { + + } + + start() { + this.finishTime = this.computeTime(this.hight, this.accelerate); + this.finallySpeed = this.computeFinallySpeed(this.finishTime, this.accelerate); + } + + computeTime(h: number, g: number) { + let result = (h * 2) / g; + return Math.sqrt(result); + } + + computeFinallySpeed(time, g) { + return time * g; + } + + computeDistance(t, a) { + if (this.direction == Direction.down) { + return -(t * t * a) / 2; + } else { + let temp1 = this.finallySpeed * t; + let temp2 = (t * t * a) / 2; + return temp1 - temp2; + } + } + + onMoveY(time) { + let p = this.computeDistance(time, this.accelerate); + if (this.direction == Direction.down) { + this.node.y = this.hight + p; + } else { + this.node.y = 0 + p; + } + } + + judgeDirection(y) { + if (y <= 0.01) { + if (this.direction == Direction.up) return; + this.direction = Direction.up; + this.curTime = 0; + } else if (Math.abs(y - this.hight) < 0.01) { + if (this.direction == Direction.down) return; + this.direction = Direction.down; + this.curTime = 0; + } + } + + checkBorder(time) { + if (time > this.finishTime) { + return this.finishTime; + } + return time; + } + + update(dt) { + console.log('update', dt); + this.curTime += dt; + this.curTime = this.checkBorder(this.curTime); + console.log('y', this.node.y); + this.onMoveY(this.curTime); + this.judgeDirection(this.node.y); + } +} diff --git a/BassFalling/assets/Script/SpheroFalling.ts.meta b/BassFalling/assets/Script/SpheroFalling.ts.meta new file mode 100644 index 0000000..a9cdf80 --- /dev/null +++ b/BassFalling/assets/Script/SpheroFalling.ts.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.5", + "uuid": "d7ad8ad7-8ea2-4388-af99-1a1e9abf3a46", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/BassFalling/assets/Texture/HelloWorld.png.meta b/BassFalling/assets/Texture/HelloWorld.png.meta index efdbc77..9c52a59 100644 --- a/BassFalling/assets/Texture/HelloWorld.png.meta +++ b/BassFalling/assets/Texture/HelloWorld.png.meta @@ -1,10 +1,9 @@ { - "ver": "2.2.0", + "ver": "1.0.0", "uuid": "6aa0aa6a-ebee-4155-a088-a687a6aadec4", "type": "sprite", "wrapMode": "clamp", "filterMode": "bilinear", - "premultiplyAlpha": false, "subMetas": { "HelloWorld": { "ver": "1.0.3", diff --git a/BassFalling/assets/Texture/singleColor.png.meta b/BassFalling/assets/Texture/singleColor.png.meta index e3a0a2b..89cdf74 100644 --- a/BassFalling/assets/Texture/singleColor.png.meta +++ b/BassFalling/assets/Texture/singleColor.png.meta @@ -1,10 +1,9 @@ { - "ver": "2.2.0", + "ver": "1.0.0", "uuid": "a8027877-d8d6-4645-97a0-52d4a0123dba", "type": "sprite", "wrapMode": "clamp", "filterMode": "bilinear", - "premultiplyAlpha": false, "subMetas": { "singleColor": { "ver": "1.0.3", diff --git a/BassFalling/settings/project.json b/BassFalling/settings/project.json index 785a546..d3fba09 100644 --- a/BassFalling/settings/project.json +++ b/BassFalling/settings/project.json @@ -24,16 +24,6 @@ "design-resolution-height": 640, "design-resolution-width": 960, "excluded-modules": [], - "facebook": { - "appID": "", - "audience": { - "enable": false - }, - "enable": false, - "live": { - "enable": false - } - }, "fit-height": true, "fit-width": false, "group-list": [ @@ -41,12 +31,12 @@ "ball", "ground" ], - "last-module-event-record-time": 0, "simulator-orientation": false, "simulator-resolution": { "height": 640, "width": 960 }, "use-customize-simulator": false, - "use-project-simulator-setting": false + "use-project-simulator-setting": false, + "start-scene": "current" } \ No newline at end of file diff --git a/BezierPathsDemo/.gitignore b/BezierPathsDemo/.gitignore new file mode 100644 index 0000000..a231b3f --- /dev/null +++ b/BezierPathsDemo/.gitignore @@ -0,0 +1,24 @@ + +#/////////////////////////// +# Cocos Creator 3D Project +#/////////////////////////// +library/ +temp/ +local/ +build/ +profiles/ +native +#////////////////////////// +# NPM +#////////////////////////// +node_modules/ + +#////////////////////////// +# VSCode +#////////////////////////// +.vscode/ + +#////////////////////////// +# WebStorm +#////////////////////////// +.idea/ \ No newline at end of file diff --git a/BezierPathsDemo/README.md b/BezierPathsDemo/README.md new file mode 100644 index 0000000..647c6a7 --- /dev/null +++ b/BezierPathsDemo/README.md @@ -0,0 +1,6 @@ +# 生成匀速Bezier曲线 +> 实现2d与3d的三阶匀速曲线 + +## 参考 +* https://blog.csdn.net/iSunwish/article/details/78935257 +* https://blog.csdn.net/iSunwish/article/details/112127363 \ No newline at end of file diff --git a/BezierPathsDemo/assets/material.meta b/BezierPathsDemo/assets/material.meta new file mode 100644 index 0000000..e1d7660 --- /dev/null +++ b/BezierPathsDemo/assets/material.meta @@ -0,0 +1,12 @@ +{ + "ver": "1.1.0", + "importer": "directory", + "imported": true, + "uuid": "bcb14f34-8131-435f-a8f5-29612c45af59", + "files": [], + "subMetas": {}, + "userData": { + "compressionType": {}, + "isRemoteBundle": {} + } +} diff --git a/BezierPathsDemo/assets/material/hdcSky.mtl b/BezierPathsDemo/assets/material/hdcSky.mtl new file mode 100644 index 0000000..8ea9e0e --- /dev/null +++ b/BezierPathsDemo/assets/material/hdcSky.mtl @@ -0,0 +1,34 @@ +{ + "__type__": "cc.Material", + "_name": "", + "_objFlags": 0, + "_native": "", + "_effectAsset": { + "__uuid__": "a3cd009f-0ab0-420d-9278-b9fdab939bbc" + }, + "_techIdx": 0, + "_defines": [ + { + "USE_TEXTURE": true + } + ], + "_states": [ + { + "blendState": { + "targets": [ + {} + ] + }, + "depthStencilState": {}, + "rasterizerState": {} + } + ], + "_props": [ + { + "mainTexture": { + "__uuid__": "dc4a96c7-321a-48af-81e5-1127ad3ae432@6c48a" + }, + "alphaThreshold": 0 + } + ] +} \ No newline at end of file diff --git a/BezierPathsDemo/assets/material/hdcSky.mtl.meta b/BezierPathsDemo/assets/material/hdcSky.mtl.meta new file mode 100644 index 0000000..3667465 --- /dev/null +++ b/BezierPathsDemo/assets/material/hdcSky.mtl.meta @@ -0,0 +1,11 @@ +{ + "ver": "1.0.9", + "importer": "material", + "imported": true, + "uuid": "482a5162-dad9-446c-b548-8486c7598ee1", + "files": [ + ".json" + ], + "subMetas": {}, + "userData": {} +} diff --git a/BezierPathsDemo/assets/material/plane.mtl b/BezierPathsDemo/assets/material/plane.mtl new file mode 100644 index 0000000..ab9171c --- /dev/null +++ b/BezierPathsDemo/assets/material/plane.mtl @@ -0,0 +1,34 @@ +{ + "__type__": "cc.Material", + "_name": "", + "_objFlags": 0, + "_native": "", + "_effectAsset": { + "__uuid__": "a3cd009f-0ab0-420d-9278-b9fdab939bbc" + }, + "_techIdx": 0, + "_defines": [ + { + "USE_TEXTURE": true + } + ], + "_states": [ + { + "blendState": { + "targets": [ + {} + ] + }, + "depthStencilState": {}, + "rasterizerState": {} + } + ], + "_props": [ + { + "mainTexture": { + "__uuid__": "4f4c4a34-2d08-4a4d-9169-834d7ce82cee@6c48a" + }, + "alphaThreshold": 0 + } + ] +} \ No newline at end of file diff --git a/BezierPathsDemo/assets/material/plane.mtl.meta b/BezierPathsDemo/assets/material/plane.mtl.meta new file mode 100644 index 0000000..4b1c531 --- /dev/null +++ b/BezierPathsDemo/assets/material/plane.mtl.meta @@ -0,0 +1,11 @@ +{ + "ver": "1.0.9", + "importer": "material", + "imported": true, + "uuid": "23e988d0-7168-4fe2-9d46-f29c114e9e33", + "files": [ + ".json" + ], + "subMetas": {}, + "userData": {} +} diff --git a/BezierPathsDemo/assets/material/seafloor.mtl b/BezierPathsDemo/assets/material/seafloor.mtl new file mode 100644 index 0000000..7c7f64b --- /dev/null +++ b/BezierPathsDemo/assets/material/seafloor.mtl @@ -0,0 +1,42 @@ +{ + "__type__": "cc.Material", + "_name": "seafloor", + "_objFlags": 0, + "_native": "", + "_effectAsset": { + "__uuid__": "1baf0fc9-befa-459c-8bdd-af1a450a0319" + }, + "_techIdx": 0, + "_defines": [ + { + "USE_ALBEDO_MAP": true + } + ], + "_states": [ + { + "rasterizerState": {}, + "blendState": { + "targets": [ + {} + ] + }, + "depthStencilState": {} + } + ], + "_props": [ + { + "mainTexture": { + "__uuid__": "0ab3142a-6968-4073-95af-026bc3b23623@2df3a" + }, + "albedoScale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "metallic": 0.400000005960464, + "roughness": 0.70710676908493, + "alphaThreshold": 0 + } + ] +} diff --git a/BezierPathsDemo/assets/material/seafloor.mtl.meta b/BezierPathsDemo/assets/material/seafloor.mtl.meta new file mode 100644 index 0000000..eb9a99a --- /dev/null +++ b/BezierPathsDemo/assets/material/seafloor.mtl.meta @@ -0,0 +1,11 @@ +{ + "ver": "1.0.9", + "importer": "material", + "imported": true, + "uuid": "70d33758-1c1e-424d-b0ab-eac7410559bf", + "files": [ + ".json" + ], + "subMetas": {}, + "userData": {} +} diff --git a/BezierPathsDemo/assets/material/shield.mtl b/BezierPathsDemo/assets/material/shield.mtl new file mode 100644 index 0000000..6e09726 --- /dev/null +++ b/BezierPathsDemo/assets/material/shield.mtl @@ -0,0 +1,62 @@ +{ + "__type__": "cc.Material", + "_name": "", + "_objFlags": 0, + "_native": "", + "_effectAsset": { + "__uuid__": "1baf0fc9-befa-459c-8bdd-af1a450a0319" + }, + "_techIdx": 0, + "_defines": [ + { + "USE_ALBEDO_MAP": true + }, + { + "USE_ALBEDO_MAP": true + }, + { + "USE_ALBEDO_MAP": true + } + ], + "_states": [ + { + "blendState": { + "targets": [ + {} + ] + }, + "depthStencilState": {}, + "rasterizerState": {} + }, + { + "blendState": { + "targets": [ + {} + ] + }, + "depthStencilState": {}, + "rasterizerState": {} + }, + { + "blendState": { + "targets": [ + {} + ] + }, + "depthStencilState": {}, + "rasterizerState": {} + } + ], + "_props": [ + { + "alphaThreshold": 0, + "roughness": 0.70710676908493, + "metallic": 0.400000005960464, + "mainTexture": { + "__uuid__": "95e5b02a-e338-423c-bdbb-17486db1d9eb@6c48a" + } + }, + {}, + {} + ] +} diff --git a/BezierPathsDemo/assets/material/shield.mtl.meta b/BezierPathsDemo/assets/material/shield.mtl.meta new file mode 100644 index 0000000..1d18383 --- /dev/null +++ b/BezierPathsDemo/assets/material/shield.mtl.meta @@ -0,0 +1,11 @@ +{ + "ver": "1.0.9", + "importer": "material", + "imported": true, + "uuid": "8e047178-f61c-4322-a2f6-d1adb28b6ae2", + "files": [ + ".json" + ], + "subMetas": {}, + "userData": {} +} diff --git a/BezierPathsDemo/assets/material/soldier.mtl b/BezierPathsDemo/assets/material/soldier.mtl new file mode 100644 index 0000000..c405305 --- /dev/null +++ b/BezierPathsDemo/assets/material/soldier.mtl @@ -0,0 +1,83 @@ +{ + "__type__": "cc.Material", + "_name": "", + "_objFlags": 0, + "_native": "", + "_effectAsset": { + "__uuid__": "a7612b54-35e3-4238-a1a9-4a7b54635839" + }, + "_techIdx": 0, + "_defines": [ + { + "USE_OUTLINE_PASS": true + }, + { + "USE_BASE_COLOR_MAP": true, + "BASE_COLOR_MAP_AS_SHADE_MAP_1": true, + "BASE_COLOR_MAP_AS_SHADE_MAP_2": true + }, + { + "USE_BASE_COLOR_MAP": true, + "BASE_COLOR_MAP_AS_SHADE_MAP_1": true, + "BASE_COLOR_MAP_AS_SHADE_MAP_2": true + }, + { + "USE_BASE_COLOR_MAP": true + } + ], + "_states": [ + { + "blendState": { + "targets": [ + {} + ] + }, + "depthStencilState": {}, + "rasterizerState": {} + }, + { + "blendState": { + "targets": [ + {} + ] + }, + "depthStencilState": {}, + "rasterizerState": {} + }, + { + "blendState": { + "targets": [ + {} + ] + }, + "depthStencilState": {}, + "rasterizerState": {} + }, + { + "blendState": { + "targets": [ + {} + ] + }, + "depthStencilState": {}, + "rasterizerState": {} + } + ], + "_props": [ + {}, + { + "specular": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 0 + }, + "mainTexture": { + "__uuid__": "6f891a7b-5a08-48e6-9841-ddb364ac86b1@6c48a" + } + }, + {}, + {} + ] +} \ No newline at end of file diff --git a/BezierPathsDemo/assets/material/soldier.mtl.meta b/BezierPathsDemo/assets/material/soldier.mtl.meta new file mode 100644 index 0000000..0289264 --- /dev/null +++ b/BezierPathsDemo/assets/material/soldier.mtl.meta @@ -0,0 +1,11 @@ +{ + "ver": "1.0.9", + "importer": "material", + "imported": true, + "uuid": "8a58ddec-f437-40b9-8ec0-1fc87de97fb5", + "files": [ + ".json" + ], + "subMetas": {}, + "userData": {} +} diff --git a/BezierPathsDemo/assets/material/stone.mtl b/BezierPathsDemo/assets/material/stone.mtl new file mode 100644 index 0000000..69da94f --- /dev/null +++ b/BezierPathsDemo/assets/material/stone.mtl @@ -0,0 +1,83 @@ +{ + "__type__": "cc.Material", + "_name": "", + "_objFlags": 0, + "_native": "", + "_effectAsset": { + "__uuid__": "a7612b54-35e3-4238-a1a9-4a7b54635839" + }, + "_techIdx": 0, + "_defines": [ + { + "USE_OUTLINE_PASS": true + }, + { + "USE_BASE_COLOR_MAP": true, + "BASE_COLOR_MAP_AS_SHADE_MAP_1": true, + "BASE_COLOR_MAP_AS_SHADE_MAP_2": true + }, + { + "USE_BASE_COLOR_MAP": true, + "BASE_COLOR_MAP_AS_SHADE_MAP_1": true, + "BASE_COLOR_MAP_AS_SHADE_MAP_2": true + }, + { + "USE_BASE_COLOR_MAP": true + } + ], + "_states": [ + { + "blendState": { + "targets": [ + {} + ] + }, + "depthStencilState": {}, + "rasterizerState": {} + }, + { + "blendState": { + "targets": [ + {} + ] + }, + "depthStencilState": {}, + "rasterizerState": {} + }, + { + "blendState": { + "targets": [ + {} + ] + }, + "depthStencilState": {}, + "rasterizerState": {} + }, + { + "blendState": { + "targets": [ + {} + ] + }, + "depthStencilState": {}, + "rasterizerState": {} + } + ], + "_props": [ + {}, + { + "specular": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 0 + }, + "mainTexture": { + "__uuid__": "0718d996-39bf-4ab4-bb63-496666fef467@6c48a" + } + }, + {}, + {} + ] +} \ No newline at end of file diff --git a/BezierPathsDemo/assets/material/stone.mtl.meta b/BezierPathsDemo/assets/material/stone.mtl.meta new file mode 100644 index 0000000..eeaf407 --- /dev/null +++ b/BezierPathsDemo/assets/material/stone.mtl.meta @@ -0,0 +1,11 @@ +{ + "ver": "1.0.9", + "importer": "material", + "imported": true, + "uuid": "a155f93b-7769-4ca4-b75f-b13e52193859", + "files": [ + ".json" + ], + "subMetas": {}, + "userData": {} +} diff --git a/BezierPathsDemo/assets/material/tree.mtl b/BezierPathsDemo/assets/material/tree.mtl new file mode 100644 index 0000000..120ce3e --- /dev/null +++ b/BezierPathsDemo/assets/material/tree.mtl @@ -0,0 +1,83 @@ +{ + "__type__": "cc.Material", + "_name": "", + "_objFlags": 0, + "_native": "", + "_effectAsset": { + "__uuid__": "a7612b54-35e3-4238-a1a9-4a7b54635839" + }, + "_techIdx": 0, + "_defines": [ + { + "USE_OUTLINE_PASS": true + }, + { + "USE_BASE_COLOR_MAP": true, + "BASE_COLOR_MAP_AS_SHADE_MAP_1": true, + "BASE_COLOR_MAP_AS_SHADE_MAP_2": true + }, + { + "USE_BASE_COLOR_MAP": true, + "BASE_COLOR_MAP_AS_SHADE_MAP_1": true, + "BASE_COLOR_MAP_AS_SHADE_MAP_2": true + }, + { + "USE_BASE_COLOR_MAP": true + } + ], + "_states": [ + { + "blendState": { + "targets": [ + {} + ] + }, + "depthStencilState": {}, + "rasterizerState": {} + }, + { + "blendState": { + "targets": [ + {} + ] + }, + "depthStencilState": {}, + "rasterizerState": {} + }, + { + "blendState": { + "targets": [ + {} + ] + }, + "depthStencilState": {}, + "rasterizerState": {} + }, + { + "blendState": { + "targets": [ + {} + ] + }, + "depthStencilState": {}, + "rasterizerState": {} + } + ], + "_props": [ + {}, + { + "specular": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 0 + }, + "mainTexture": { + "__uuid__": "c5083e75-ad2e-4ea9-8b33-dee748995b00@6c48a" + } + }, + {}, + {} + ] +} \ No newline at end of file diff --git a/BezierPathsDemo/assets/material/tree.mtl.meta b/BezierPathsDemo/assets/material/tree.mtl.meta new file mode 100644 index 0000000..4078086 --- /dev/null +++ b/BezierPathsDemo/assets/material/tree.mtl.meta @@ -0,0 +1,11 @@ +{ + "ver": "1.0.9", + "importer": "material", + "imported": true, + "uuid": "7bf9df40-4bc9-4e25-8cb0-9a500f949102", + "files": [ + ".json" + ], + "subMetas": {}, + "userData": {} +} diff --git a/BezierPathsDemo/assets/model.meta b/BezierPathsDemo/assets/model.meta new file mode 100644 index 0000000..2408a58 --- /dev/null +++ b/BezierPathsDemo/assets/model.meta @@ -0,0 +1,12 @@ +{ + "ver": "1.1.0", + "importer": "directory", + "imported": true, + "uuid": "1ddc11ba-ecbd-4472-841c-f3777cb248da", + "files": [], + "subMetas": {}, + "userData": { + "compressionType": {}, + "isRemoteBundle": {} + } +} diff --git a/BezierPathsDemo/assets/model/helloWorld.meta b/BezierPathsDemo/assets/model/helloWorld.meta new file mode 100644 index 0000000..9e85fa7 --- /dev/null +++ b/BezierPathsDemo/assets/model/helloWorld.meta @@ -0,0 +1,12 @@ +{ + "ver": "1.1.0", + "importer": "directory", + "imported": true, + "uuid": "11a1d348-a622-41b2-89f3-ed24657e5f84", + "files": [], + "subMetas": {}, + "userData": { + "compressionType": {}, + "isRemoteBundle": {} + } +} diff --git a/BezierPathsDemo/assets/model/helloWorld/grass.meta b/BezierPathsDemo/assets/model/helloWorld/grass.meta new file mode 100644 index 0000000..c5088c9 --- /dev/null +++ b/BezierPathsDemo/assets/model/helloWorld/grass.meta @@ -0,0 +1,12 @@ +{ + "ver": "1.1.0", + "importer": "directory", + "imported": true, + "uuid": "e00862a8-c500-427c-b76f-bbe5203f19cc", + "files": [], + "subMetas": {}, + "userData": { + "compressionType": {}, + "isRemoteBundle": {} + } +} diff --git a/BezierPathsDemo/assets/model/helloWorld/grass/grass.FBX b/BezierPathsDemo/assets/model/helloWorld/grass/grass.FBX new file mode 100644 index 0000000..b4b7ead Binary files /dev/null and b/BezierPathsDemo/assets/model/helloWorld/grass/grass.FBX differ diff --git a/BezierPathsDemo/assets/model/helloWorld/grass/grass.FBX.meta b/BezierPathsDemo/assets/model/helloWorld/grass/grass.FBX.meta new file mode 100644 index 0000000..3c45426 --- /dev/null +++ b/BezierPathsDemo/assets/model/helloWorld/grass/grass.FBX.meta @@ -0,0 +1,170 @@ +{ + "ver": "2.0.14", + "importer": "fbx", + "imported": true, + "uuid": "aade09ee-8f9d-413c-a9e8-8c686ea5e160", + "files": [], + "subMetas": { + "ef5e1": { + "importer": "gltf-mesh", + "uuid": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@ef5e1", + "displayName": "", + "id": "ef5e1", + "name": "grass.mesh", + "ver": "1.1.0", + "imported": true, + "files": [ + ".bin", + ".json" + ], + "subMetas": {}, + "userData": { + "gltfIndex": 0 + } + }, + "73b7f": { + "importer": "gltf-animation", + "uuid": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@73b7f", + "displayName": "", + "id": "73b7f", + "name": "Take 001.animation", + "ver": "1.0.14", + "imported": true, + "files": [ + ".bin", + ".json" + ], + "subMetas": {}, + "userData": { + "events": [], + "gltfIndex": 0, + "sample": 30, + "span": { + "from": 0, + "to": 3.3333332538604736 + }, + "wrapMode": 2, + "speed": 1 + } + }, + "438fe": { + "importer": "gltf-skeleton", + "uuid": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@438fe", + "displayName": "", + "id": "438fe", + "name": "UnnamedSkeleton.skeleton", + "ver": "1.0.1", + "imported": true, + "files": [ + ".json" + ], + "subMetas": {}, + "userData": { + "gltfIndex": 0, + "jointsLength": 6 + } + }, + "80e0c": { + "importer": "gltf-embeded-image", + "uuid": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@80e0c", + "displayName": "", + "id": "80e0c", + "name": "grass.png.image", + "ver": "1.0.3", + "imported": true, + "files": [ + ".png", + ".json" + ], + "subMetas": {}, + "userData": { + "gltfIndex": 0 + } + }, + "9787f": { + "importer": "texture", + "uuid": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@9787f", + "displayName": "", + "id": "9787f", + "name": "grass.texture", + "ver": "1.0.21", + "imported": true, + "files": [ + ".json" + ], + "subMetas": {}, + "userData": { + "wrapModeS": "repeat", + "wrapModeT": "repeat", + "minfilter": "linear", + "magfilter": "linear", + "mipfilter": "none", + "premultiplyAlpha": false, + "anisotropy": 0, + "isUuid": true, + "imageUuidOrDatabaseUri": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@80e0c" + } + }, + "3022b": { + "importer": "gltf-scene", + "uuid": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@3022b", + "displayName": "", + "id": "3022b", + "name": "grass.prefab", + "ver": "1.0.12", + "imported": true, + "files": [ + ".json" + ], + "subMetas": {}, + "userData": { + "gltfIndex": 0 + } + } + }, + "userData": { + "imageMetas": [ + { + "name": "grass.png", + "uri": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@80e0c" + } + ], + "animationImportSettings": [ + { + "name": "Take 001", + "duration": 3.3333332538604736, + "fps": 30, + "splits": [ + { + "name": "Take 001", + "from": 0, + "to": 3.3333332538604736, + "wrapMode": 2 + } + ] + } + ], + "redirect": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@3022b", + "assetFinder": { + "meshes": [ + "aade09ee-8f9d-413c-a9e8-8c686ea5e160@ef5e1" + ], + "skeletons": [ + "aade09ee-8f9d-413c-a9e8-8c686ea5e160@438fe" + ], + "textures": [ + "aade09ee-8f9d-413c-a9e8-8c686ea5e160@9787f" + ], + "materials": [ + "b698e55a-b00b-4987-a8b4-af83cddc59f7" + ], + "scenes": [ + "aade09ee-8f9d-413c-a9e8-8c686ea5e160@3022b" + ] + }, + "useVertexColors": true, + "dumpMaterials": true, + "materialDumpDir": "db://assets/model/helloWorld/grass", + "legacyFbxImporter": true + } +} diff --git a/BezierPathsDemo/assets/model/helloWorld/grass/grass.mtl b/BezierPathsDemo/assets/model/helloWorld/grass/grass.mtl new file mode 100644 index 0000000..5233edb --- /dev/null +++ b/BezierPathsDemo/assets/model/helloWorld/grass/grass.mtl @@ -0,0 +1,34 @@ +{ + "__type__": "cc.Material", + "_name": "", + "_objFlags": 0, + "_native": "", + "_effectAsset": { + "__uuid__": "a3cd009f-0ab0-420d-9278-b9fdab939bbc" + }, + "_techIdx": 0, + "_defines": [ + { + "USE_TEXTURE": true + } + ], + "_states": [ + { + "blendState": { + "targets": [ + {} + ] + }, + "depthStencilState": {}, + "rasterizerState": {} + } + ], + "_props": [ + { + "mainTexture": { + "__uuid__": "ae18deea-c6e0-4a3d-bf70-ee5533f9ba87@6c48a" + }, + "alphaThreshold": 0 + } + ] +} \ No newline at end of file diff --git a/BezierPathsDemo/assets/model/helloWorld/grass/grass.mtl.meta b/BezierPathsDemo/assets/model/helloWorld/grass/grass.mtl.meta new file mode 100644 index 0000000..9b34538 --- /dev/null +++ b/BezierPathsDemo/assets/model/helloWorld/grass/grass.mtl.meta @@ -0,0 +1,11 @@ +{ + "ver": "1.0.9", + "importer": "material", + "imported": true, + "uuid": "b698e55a-b00b-4987-a8b4-af83cddc59f7", + "files": [ + ".json" + ], + "subMetas": {}, + "userData": {} +} diff --git a/BezierPathsDemo/assets/model/helloWorld/grass/grass.png b/BezierPathsDemo/assets/model/helloWorld/grass/grass.png new file mode 100644 index 0000000..78406d7 Binary files /dev/null and b/BezierPathsDemo/assets/model/helloWorld/grass/grass.png differ diff --git a/BezierPathsDemo/assets/model/helloWorld/grass/grass.png.meta b/BezierPathsDemo/assets/model/helloWorld/grass/grass.png.meta new file mode 100644 index 0000000..2317a65 --- /dev/null +++ b/BezierPathsDemo/assets/model/helloWorld/grass/grass.png.meta @@ -0,0 +1,41 @@ +{ + "ver": "1.0.21", + "importer": "image", + "imported": true, + "uuid": "ae18deea-c6e0-4a3d-bf70-ee5533f9ba87", + "files": [ + ".png", + ".json" + ], + "subMetas": { + "6c48a": { + "importer": "texture", + "uuid": "ae18deea-c6e0-4a3d-bf70-ee5533f9ba87@6c48a", + "displayName": "grass", + "id": "6c48a", + "name": "texture", + "ver": "1.0.21", + "imported": true, + "files": [ + ".json" + ], + "subMetas": {}, + "userData": { + "wrapModeS": "repeat", + "wrapModeT": "repeat", + "minfilter": "linear", + "magfilter": "linear", + "mipfilter": "linear", + "premultiplyAlpha": false, + "anisotropy": 0, + "isUuid": true, + "imageUuidOrDatabaseUri": "ae18deea-c6e0-4a3d-bf70-ee5533f9ba87" + } + } + }, + "userData": { + "type": "texture", + "redirect": "ae18deea-c6e0-4a3d-bf70-ee5533f9ba87@6c48a", + "hasAlpha": false + } +} diff --git a/BezierPathsDemo/assets/model/helloWorld/grass/grass.prefab b/BezierPathsDemo/assets/model/helloWorld/grass/grass.prefab new file mode 100644 index 0000000..d062f56 --- /dev/null +++ b/BezierPathsDemo/assets/model/helloWorld/grass/grass.prefab @@ -0,0 +1,589 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "asyncLoadAssets": false + }, + { + "__type__": "cc.Node", + "_name": "grass", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + } + ], + "_active": true, + "_components": [ + { + "__id__": 20 + } + ], + "_prefab": { + "__id__": 21 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "RootNode", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 3 + }, + { + "__id__": 7 + }, + { + "__id__": 13 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 19 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "grass", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 4 + } + ], + "_prefab": { + "__id__": 6 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.37992816729770207, + "y": 0.5963678291908521, + "z": 0.5963678291908521, + "w": -0.37992816729770207 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 0.614784121513367, + "y": 0.614784121513367, + "z": 0.614784121513367 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -90, + "y": -115.0000056286655, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.SkinnedMeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 3 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "b698e55a-b00b-4987-a8b4-af83cddc59f7" + } + ], + "_visFlags": 0, + "lightmapSettings": { + "__id__": 5 + }, + "_mesh": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@ef5e1" + }, + "_shadowCastingMode": 0, + "_enableMorph": true, + "_skeleton": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@438fe" + }, + "_skinningRoot": { + "__id__": 1 + }, + "_id": "", + "__prefab": { + "__id__": 22 + } + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "3aIX8gjK5JFK8ATDBKdax8" + }, + { + "__type__": "cc.Node", + "_name": "Bone001", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [ + { + "__id__": 8 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 12 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": -0.0461842827498913, + "y": 0.0000118009265861474, + "z": -0.0284814611077309 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.0000017283479103639154, + "y": -0.000001696768662714476, + "z": 0.7049074170330618, + "w": 0.7092993256770451 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -0.0005507418826256091, + "y": 0.00027320859410338513, + "z": 89.64412979694991 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone002", + "_objFlags": 0, + "_parent": { + "__id__": 7 + }, + "_children": [ + { + "__id__": 9 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 11 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0404664427042007, + "y": -3.57627860658738e-9, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.000002421418716486127, + "y": 1.5182564735607207e-8, + "z": 0.006269989150778519, + "w": 0.9999803434219023 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0.000277479600078167, + "y": -3.18993241527229e-13, + "z": 0.7184925395739944 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone003", + "_objFlags": 0, + "_parent": { + "__id__": 8 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 10 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0397140197455883, + "y": -1.19209286886246e-9, + "z": 7.15255721317476e-9 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 1.4018830392883508e-10, + "y": -1.4662893682703937e-13, + "z": -0.0010459420626472054, + "w": 0.9999994530024512 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 1.606440509162768e-8, + "y": -1.4726229276075984e-18, + "z": -0.11985615346346049 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "1628kgL41EG4kfuuNtniX1" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "d1mgL13wtIwojR/2FqCufO" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "f5o8/2y99IcawmyX5Tnjyv" + }, + { + "__type__": "cc.Node", + "_name": "Bone004", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [ + { + "__id__": 14 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 18 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0710692703723907, + "y": 0.0000118009265861474, + "z": 0.0136896027252078 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.0000017283479103639154, + "y": -0.000001696768662714476, + "z": 0.7049074170330618, + "w": 0.7092993256770451 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -0.0005507418826256091, + "y": 0.00027320859410338513, + "z": 89.64412979694991 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone005", + "_objFlags": 0, + "_parent": { + "__id__": 13 + }, + "_children": [ + { + "__id__": 15 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 17 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0404664427042007, + "y": -4.76837147544984e-9, + "z": 5.9604643443123e-10 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.000002421418716486127, + "y": 1.5182564735607207e-8, + "z": 0.006269989150778519, + "w": 0.9999803434219023 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0.000277479600078167, + "y": -3.18993241527229e-13, + "z": 0.7184925395739944 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone006", + "_objFlags": 0, + "_parent": { + "__id__": 14 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 16 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.039714016020298, + "y": 0, + "z": 7.74860353658369e-9 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 1.4018830392883508e-10, + "y": -1.4662893682703937e-13, + "z": -0.0010459420626472054, + "w": 0.9999994530024512 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 1.606440509162768e-8, + "y": -1.4726229276075984e-18, + "z": -0.11985615346346049 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "a2tndvTm9M84i3qPpLv8DA" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "c5xVHa1qBClrp5YbutRSaI" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "3fxCLd4O9NUqkwJjBsDQgb" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "b7w6U8zppFX54UJURtAWiT" + }, + { + "__type__": "cc.SkeletalAnimation", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "playOnLoad": false, + "_clips": [ + { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@73b7f" + } + ], + "_defaultClip": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@73b7f" + }, + "_useBakedAnimation": true, + "_sockets": [], + "_id": "", + "__prefab": { + "__id__": 23 + } + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "fdSk3ayLBOH7saksB95r+y" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "4a0+R4fHVFrZlL6GO9T0pE" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "cbKownib1EnadGCwOGazFg" + } +] diff --git a/BezierPathsDemo/assets/model/helloWorld/grass/grass.prefab.meta b/BezierPathsDemo/assets/model/helloWorld/grass/grass.prefab.meta new file mode 100644 index 0000000..cc5d279 --- /dev/null +++ b/BezierPathsDemo/assets/model/helloWorld/grass/grass.prefab.meta @@ -0,0 +1,13 @@ +{ + "ver": "1.1.27", + "importer": "prefab", + "imported": true, + "uuid": "ebe68402-4803-40d3-b0a2-ca696e3f7c60", + "files": [ + ".json" + ], + "subMetas": {}, + "userData": { + "syncNodeName": "grass" + } +} diff --git a/BezierPathsDemo/assets/model/helloWorld/grass/grassGoup.prefab b/BezierPathsDemo/assets/model/helloWorld/grass/grassGoup.prefab new file mode 100644 index 0000000..5ba20dc --- /dev/null +++ b/BezierPathsDemo/assets/model/helloWorld/grass/grassGoup.prefab @@ -0,0 +1,7035 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "asyncLoadAssets": false + }, + { + "__type__": "cc.Node", + "_name": "grassGoup", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + }, + { + "__id__": 23 + }, + { + "__id__": 44 + }, + { + "__id__": 65 + }, + { + "__id__": 86 + }, + { + "__id__": 107 + }, + { + "__id__": 128 + }, + { + "__id__": 149 + }, + { + "__id__": 170 + }, + { + "__id__": 191 + }, + { + "__id__": 212 + }, + { + "__id__": 233 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 254 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "grass", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 3 + } + ], + "_active": true, + "_components": [ + { + "__id__": 21 + } + ], + "_prefab": { + "__id__": 22 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": -0.852, + "y": 0.892, + "z": -1.49 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1.8, + "y": 1.8, + "z": 1.8 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "RootNode", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [ + { + "__id__": 4 + }, + { + "__id__": 8 + }, + { + "__id__": 14 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 20 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "grass", + "_objFlags": 0, + "_parent": { + "__id__": 3 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 5 + } + ], + "_prefab": { + "__id__": 7 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.37992816729770207, + "y": 0.5963678291908521, + "z": 0.5963678291908521, + "w": -0.37992816729770207 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 0.614784121513367, + "y": 0.614784121513367, + "z": 0.614784121513367 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -90, + "y": -115.0000056286655, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.SkinnedMeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 4 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "b698e55a-b00b-4987-a8b4-af83cddc59f7" + } + ], + "_visFlags": 0, + "lightmapSettings": { + "__id__": 6 + }, + "_mesh": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@ef5e1" + }, + "_shadowCastingMode": 0, + "_enableMorph": true, + "_skeleton": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@438fe" + }, + "_skinningRoot": { + "__id__": 2 + }, + "_id": "", + "__prefab": { + "__id__": 255 + } + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "5fs1r6h0xEiJFeWVPk8SNl" + }, + { + "__type__": "cc.Node", + "_name": "Bone001", + "_objFlags": 0, + "_parent": { + "__id__": 3 + }, + "_children": [ + { + "__id__": 9 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 13 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": -0.0461842827498913, + "y": 0.0000118009265861474, + "z": -0.0284814611077309 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.0000017283479103639154, + "y": -0.000001696768662714476, + "z": 0.7049074170330618, + "w": 0.7092993256770451 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -0.0005507418826256091, + "y": 0.00027320859410338513, + "z": 89.64412979694991 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone002", + "_objFlags": 0, + "_parent": { + "__id__": 8 + }, + "_children": [ + { + "__id__": 10 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 12 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0404664427042007, + "y": -3.57627860658738e-9, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.000002421418716486127, + "y": 1.5182564735607207e-8, + "z": 0.006269989150778519, + "w": 0.9999803434219023 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0.000277479600078167, + "y": -3.18993241527229e-13, + "z": 0.7184925395739944 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone003", + "_objFlags": 0, + "_parent": { + "__id__": 9 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 11 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0397140197455883, + "y": -1.19209286886246e-9, + "z": 7.15255721317476e-9 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 1.4018830392883508e-10, + "y": -1.4662893682703937e-13, + "z": -0.0010459420626472054, + "w": 0.9999994530024512 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 1.606440509162768e-8, + "y": -1.4726229276075984e-18, + "z": -0.11985615346346049 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "8e/dPEvbdIMo48q55vpZZ3" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "beKna0bXZNtrHWMkpFZoVU" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "daWdShf/9NHLgm8BB+DJZm" + }, + { + "__type__": "cc.Node", + "_name": "Bone004", + "_objFlags": 0, + "_parent": { + "__id__": 3 + }, + "_children": [ + { + "__id__": 15 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 19 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0710692703723907, + "y": 0.0000118009265861474, + "z": 0.0136896027252078 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.0000017283479103639154, + "y": -0.000001696768662714476, + "z": 0.7049074170330618, + "w": 0.7092993256770451 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -0.0005507418826256091, + "y": 0.00027320859410338513, + "z": 89.64412979694991 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone005", + "_objFlags": 0, + "_parent": { + "__id__": 14 + }, + "_children": [ + { + "__id__": 16 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 18 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0404664427042007, + "y": -4.76837147544984e-9, + "z": 5.9604643443123e-10 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.000002421418716486127, + "y": 1.5182564735607207e-8, + "z": 0.006269989150778519, + "w": 0.9999803434219023 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0.000277479600078167, + "y": -3.18993241527229e-13, + "z": 0.7184925395739944 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone006", + "_objFlags": 0, + "_parent": { + "__id__": 15 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 17 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.039714016020298, + "y": 0, + "z": 7.74860353658369e-9 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 1.4018830392883508e-10, + "y": -1.4662893682703937e-13, + "z": -0.0010459420626472054, + "w": 0.9999994530024512 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 1.606440509162768e-8, + "y": -1.4726229276075984e-18, + "z": -0.11985615346346049 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "96ATlvvpZKqpZWVYxnyW6U" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "8fu8biB4BPFKtDBKsYv4K/" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "94aP4+w7dE/qUrh7Cfcv3Y" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "54SHCY049LyqH1HRGY3ZVR" + }, + { + "__type__": "cc.SkeletalAnimation", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "playOnLoad": true, + "_clips": [ + { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@73b7f" + } + ], + "_defaultClip": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@73b7f" + }, + "_useBakedAnimation": true, + "_sockets": [], + "_id": "", + "__prefab": { + "__id__": 256 + } + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "87M1Av0v5LhZ3LsJOTzwr3" + }, + { + "__type__": "cc.Node", + "_name": "grass", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 24 + } + ], + "_active": true, + "_components": [ + { + "__id__": 42 + } + ], + "_prefab": { + "__id__": 43 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 1.271, + "y": 0.836, + "z": -2.68 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": -0.09886819763876702, + "z": 0, + "w": 0.9951005373808527 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1.4, + "y": 1.4, + "z": 1.4 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": -11.348, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "RootNode", + "_objFlags": 0, + "_parent": { + "__id__": 23 + }, + "_children": [ + { + "__id__": 25 + }, + { + "__id__": 29 + }, + { + "__id__": 35 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 41 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "grass", + "_objFlags": 0, + "_parent": { + "__id__": 24 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 26 + } + ], + "_prefab": { + "__id__": 28 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.37992816729770207, + "y": 0.5963678291908521, + "z": 0.5963678291908521, + "w": -0.37992816729770207 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 0.614784121513367, + "y": 0.614784121513367, + "z": 0.614784121513367 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -90, + "y": -115.0000056286655, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.SkinnedMeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 25 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "b698e55a-b00b-4987-a8b4-af83cddc59f7" + } + ], + "_visFlags": 0, + "lightmapSettings": { + "__id__": 27 + }, + "_mesh": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@ef5e1" + }, + "_shadowCastingMode": 0, + "_enableMorph": true, + "_skeleton": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@438fe" + }, + "_skinningRoot": { + "__id__": 23 + }, + "_id": "", + "__prefab": { + "__id__": 257 + } + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "74Q+wg/aVBj5Bkvd+Cqz4L" + }, + { + "__type__": "cc.Node", + "_name": "Bone001", + "_objFlags": 0, + "_parent": { + "__id__": 24 + }, + "_children": [ + { + "__id__": 30 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 34 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": -0.0461842827498913, + "y": 0.0000118009265861474, + "z": -0.0284814611077309 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.0000017283479103639154, + "y": -0.000001696768662714476, + "z": 0.7049074170330618, + "w": 0.7092993256770451 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -0.0005507418826256091, + "y": 0.00027320859410338513, + "z": 89.64412979694991 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone002", + "_objFlags": 0, + "_parent": { + "__id__": 29 + }, + "_children": [ + { + "__id__": 31 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 33 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0404664427042007, + "y": -3.57627860658738e-9, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.000002421418716486127, + "y": 1.5182564735607207e-8, + "z": 0.006269989150778519, + "w": 0.9999803434219023 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0.000277479600078167, + "y": -3.18993241527229e-13, + "z": 0.7184925395739944 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone003", + "_objFlags": 0, + "_parent": { + "__id__": 30 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 32 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0397140197455883, + "y": -1.19209286886246e-9, + "z": 7.15255721317476e-9 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 1.4018830392883508e-10, + "y": -1.4662893682703937e-13, + "z": -0.0010459420626472054, + "w": 0.9999994530024512 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 1.606440509162768e-8, + "y": -1.4726229276075984e-18, + "z": -0.11985615346346049 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "af9wSIs/ZHx5FXOjfa1Jum" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "25LOOT8GBDpr0h1KIC5gCx" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "4fGc2baulLjbJeePpPYcqt" + }, + { + "__type__": "cc.Node", + "_name": "Bone004", + "_objFlags": 0, + "_parent": { + "__id__": 24 + }, + "_children": [ + { + "__id__": 36 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 40 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0710692703723907, + "y": 0.0000118009265861474, + "z": 0.0136896027252078 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.0000017283479103639154, + "y": -0.000001696768662714476, + "z": 0.7049074170330618, + "w": 0.7092993256770451 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -0.0005507418826256091, + "y": 0.00027320859410338513, + "z": 89.64412979694991 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone005", + "_objFlags": 0, + "_parent": { + "__id__": 35 + }, + "_children": [ + { + "__id__": 37 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 39 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0404664427042007, + "y": -4.76837147544984e-9, + "z": 5.9604643443123e-10 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.000002421418716486127, + "y": 1.5182564735607207e-8, + "z": 0.006269989150778519, + "w": 0.9999803434219023 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0.000277479600078167, + "y": -3.18993241527229e-13, + "z": 0.7184925395739944 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone006", + "_objFlags": 0, + "_parent": { + "__id__": 36 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 38 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.039714016020298, + "y": 0, + "z": 7.74860353658369e-9 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 1.4018830392883508e-10, + "y": -1.4662893682703937e-13, + "z": -0.0010459420626472054, + "w": 0.9999994530024512 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 1.606440509162768e-8, + "y": -1.4726229276075984e-18, + "z": -0.11985615346346049 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "65QAhjUVBAtLwEci9t05Ey" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "e75gT5ogJMOoh/2sggS7OQ" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "b8DSzxi5tJyKiMnjvG0NLg" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "bdiB2XMldLgpbPP0u9vyiH" + }, + { + "__type__": "cc.SkeletalAnimation", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 23 + }, + "_enabled": true, + "playOnLoad": true, + "_clips": [ + { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@73b7f" + } + ], + "_defaultClip": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@73b7f" + }, + "_useBakedAnimation": true, + "_sockets": [], + "_id": "", + "__prefab": { + "__id__": 258 + } + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "8avX4W7ZtLOLCZ8n5QtiPm" + }, + { + "__type__": "cc.Node", + "_name": "grass", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 45 + } + ], + "_active": true, + "_components": [ + { + "__id__": 63 + } + ], + "_prefab": { + "__id__": 64 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.816, + "y": 0.874, + "z": -2.029 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.009594606467145706, + "y": -0.09840154486124139, + "z": -0.09656895017241425, + "w": 0.9904037143297977 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1.8, + "y": 1.8, + "z": 1.8 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": -11.348, + "z": -11.138 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "RootNode", + "_objFlags": 0, + "_parent": { + "__id__": 44 + }, + "_children": [ + { + "__id__": 46 + }, + { + "__id__": 50 + }, + { + "__id__": 56 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 62 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "grass", + "_objFlags": 0, + "_parent": { + "__id__": 45 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 47 + } + ], + "_prefab": { + "__id__": 49 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.37992816729770207, + "y": 0.5963678291908521, + "z": 0.5963678291908521, + "w": -0.37992816729770207 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 0.614784121513367, + "y": 0.614784121513367, + "z": 0.614784121513367 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -90, + "y": -115.0000056286655, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.SkinnedMeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 46 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "b698e55a-b00b-4987-a8b4-af83cddc59f7" + } + ], + "_visFlags": 0, + "lightmapSettings": { + "__id__": 48 + }, + "_mesh": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@ef5e1" + }, + "_shadowCastingMode": 0, + "_enableMorph": true, + "_skeleton": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@438fe" + }, + "_skinningRoot": { + "__id__": 44 + }, + "_id": "", + "__prefab": { + "__id__": 259 + } + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "60njdFxDhJWowG9HZr9kRy" + }, + { + "__type__": "cc.Node", + "_name": "Bone001", + "_objFlags": 0, + "_parent": { + "__id__": 45 + }, + "_children": [ + { + "__id__": 51 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 55 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": -0.0461842827498913, + "y": 0.0000118009265861474, + "z": -0.0284814611077309 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.0000017283479103639154, + "y": -0.000001696768662714476, + "z": 0.7049074170330618, + "w": 0.7092993256770451 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -0.0005507418826256091, + "y": 0.00027320859410338513, + "z": 89.64412979694991 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone002", + "_objFlags": 0, + "_parent": { + "__id__": 50 + }, + "_children": [ + { + "__id__": 52 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 54 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0404664427042007, + "y": -3.57627860658738e-9, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.000002421418716486127, + "y": 1.5182564735607207e-8, + "z": 0.006269989150778519, + "w": 0.9999803434219023 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0.000277479600078167, + "y": -3.18993241527229e-13, + "z": 0.7184925395739944 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone003", + "_objFlags": 0, + "_parent": { + "__id__": 51 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 53 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0397140197455883, + "y": -1.19209286886246e-9, + "z": 7.15255721317476e-9 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 1.4018830392883508e-10, + "y": -1.4662893682703937e-13, + "z": -0.0010459420626472054, + "w": 0.9999994530024512 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 1.606440509162768e-8, + "y": -1.4726229276075984e-18, + "z": -0.11985615346346049 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "91jR835RZHKbRhzSn1x2pJ" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "3bw6IJ5hBJ0aqjcninjsA3" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "dfSzBMugdCkL5lyChYPcpt" + }, + { + "__type__": "cc.Node", + "_name": "Bone004", + "_objFlags": 0, + "_parent": { + "__id__": 45 + }, + "_children": [ + { + "__id__": 57 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 61 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0710692703723907, + "y": 0.0000118009265861474, + "z": 0.0136896027252078 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.0000017283479103639154, + "y": -0.000001696768662714476, + "z": 0.7049074170330618, + "w": 0.7092993256770451 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -0.0005507418826256091, + "y": 0.00027320859410338513, + "z": 89.64412979694991 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone005", + "_objFlags": 0, + "_parent": { + "__id__": 56 + }, + "_children": [ + { + "__id__": 58 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 60 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0404664427042007, + "y": -4.76837147544984e-9, + "z": 5.9604643443123e-10 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.000002421418716486127, + "y": 1.5182564735607207e-8, + "z": 0.006269989150778519, + "w": 0.9999803434219023 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0.000277479600078167, + "y": -3.18993241527229e-13, + "z": 0.7184925395739944 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone006", + "_objFlags": 0, + "_parent": { + "__id__": 57 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 59 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.039714016020298, + "y": 0, + "z": 7.74860353658369e-9 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 1.4018830392883508e-10, + "y": -1.4662893682703937e-13, + "z": -0.0010459420626472054, + "w": 0.9999994530024512 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 1.606440509162768e-8, + "y": -1.4726229276075984e-18, + "z": -0.11985615346346049 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "977HJ5Wy5HiapZRnYB3I8X" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "3da6ppQblGu7DGQDIjczFt" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "36km6+kJtJZ4iiy8pwU3RO" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "0cYonIu91LHamoapMUydbc" + }, + { + "__type__": "cc.SkeletalAnimation", + "_name": "grass", + "_objFlags": 0, + "node": { + "__id__": 44 + }, + "_enabled": true, + "playOnLoad": true, + "_clips": [ + { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@73b7f" + } + ], + "_defaultClip": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@73b7f" + }, + "_useBakedAnimation": true, + "_sockets": [], + "_id": "", + "__prefab": { + "__id__": 260 + } + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "5fAmHUz0xO9YFym/gsZawP" + }, + { + "__type__": "cc.Node", + "_name": "grass", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 66 + } + ], + "_active": true, + "_components": [ + { + "__id__": 84 + } + ], + "_prefab": { + "__id__": 85 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 1.505, + "y": 0.835, + "z": -2.352 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.009051343059323664, + "y": 0.011005731118140823, + "z": -0.042668681053864996, + "w": 0.9989876529409666 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1.8, + "y": 1.8, + "z": 1.8 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 1.094, + "y": 1.309, + "z": -4.879 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "RootNode", + "_objFlags": 0, + "_parent": { + "__id__": 65 + }, + "_children": [ + { + "__id__": 67 + }, + { + "__id__": 71 + }, + { + "__id__": 77 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 83 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "grass", + "_objFlags": 0, + "_parent": { + "__id__": 66 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 68 + } + ], + "_prefab": { + "__id__": 70 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.37992816729770207, + "y": 0.5963678291908521, + "z": 0.5963678291908521, + "w": -0.37992816729770207 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 0.614784121513367, + "y": 0.614784121513367, + "z": 0.614784121513367 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -90, + "y": -115.0000056286655, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.SkinnedMeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 67 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "b698e55a-b00b-4987-a8b4-af83cddc59f7" + } + ], + "_visFlags": 0, + "lightmapSettings": { + "__id__": 69 + }, + "_mesh": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@ef5e1" + }, + "_shadowCastingMode": 0, + "_enableMorph": true, + "_skeleton": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@438fe" + }, + "_skinningRoot": { + "__id__": 65 + }, + "_id": "", + "__prefab": { + "__id__": 261 + } + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "f2zxp5nX1CJq18JC2EndYO" + }, + { + "__type__": "cc.Node", + "_name": "Bone001", + "_objFlags": 0, + "_parent": { + "__id__": 66 + }, + "_children": [ + { + "__id__": 72 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 76 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": -0.0461842827498913, + "y": 0.0000118009265861474, + "z": -0.0284814611077309 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.0000017283479103639154, + "y": -0.000001696768662714476, + "z": 0.7049074170330618, + "w": 0.7092993256770451 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -0.0005507418826256091, + "y": 0.00027320859410338513, + "z": 89.64412979694991 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone002", + "_objFlags": 0, + "_parent": { + "__id__": 71 + }, + "_children": [ + { + "__id__": 73 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 75 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0404664427042007, + "y": -3.57627860658738e-9, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.000002421418716486127, + "y": 1.5182564735607207e-8, + "z": 0.006269989150778519, + "w": 0.9999803434219023 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0.000277479600078167, + "y": -3.18993241527229e-13, + "z": 0.7184925395739944 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone003", + "_objFlags": 0, + "_parent": { + "__id__": 72 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 74 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0397140197455883, + "y": -1.19209286886246e-9, + "z": 7.15255721317476e-9 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 1.4018830392883508e-10, + "y": -1.4662893682703937e-13, + "z": -0.0010459420626472054, + "w": 0.9999994530024512 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 1.606440509162768e-8, + "y": -1.4726229276075984e-18, + "z": -0.11985615346346049 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "baL59AVvRKlKmpQqSjNAYI" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "89NJAVd1tBZ6C0iX/YbeY2" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "3c+BtM6atJC4XerbYlNlM0" + }, + { + "__type__": "cc.Node", + "_name": "Bone004", + "_objFlags": 0, + "_parent": { + "__id__": 66 + }, + "_children": [ + { + "__id__": 78 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 82 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0710692703723907, + "y": 0.0000118009265861474, + "z": 0.0136896027252078 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.0000017283479103639154, + "y": -0.000001696768662714476, + "z": 0.7049074170330618, + "w": 0.7092993256770451 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -0.0005507418826256091, + "y": 0.00027320859410338513, + "z": 89.64412979694991 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone005", + "_objFlags": 0, + "_parent": { + "__id__": 77 + }, + "_children": [ + { + "__id__": 79 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 81 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0404664427042007, + "y": -4.76837147544984e-9, + "z": 5.9604643443123e-10 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.000002421418716486127, + "y": 1.5182564735607207e-8, + "z": 0.006269989150778519, + "w": 0.9999803434219023 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0.000277479600078167, + "y": -3.18993241527229e-13, + "z": 0.7184925395739944 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone006", + "_objFlags": 0, + "_parent": { + "__id__": 78 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 80 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.039714016020298, + "y": 0, + "z": 7.74860353658369e-9 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 1.4018830392883508e-10, + "y": -1.4662893682703937e-13, + "z": -0.0010459420626472054, + "w": 0.9999994530024512 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 1.606440509162768e-8, + "y": -1.4726229276075984e-18, + "z": -0.11985615346346049 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "6fAgsRfRRHeoZrCvNeGhDK" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "8exO45eF5F2KzRxFbNE1M/" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "9byDe6eNtGPIztX4VSZKlQ" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "2at9CGY1VK9qtNpM8kC/KU" + }, + { + "__type__": "cc.SkeletalAnimation", + "_name": "grass", + "_objFlags": 0, + "node": { + "__id__": 65 + }, + "_enabled": true, + "playOnLoad": true, + "_clips": [ + { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@73b7f" + } + ], + "_defaultClip": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@73b7f" + }, + "_useBakedAnimation": true, + "_sockets": [], + "_id": "", + "__prefab": { + "__id__": 262 + } + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "9bIVhdYYpFl7JZmL4oubNS" + }, + { + "__type__": "cc.Node", + "_name": "grass", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 87 + } + ], + "_active": true, + "_components": [ + { + "__id__": 105 + } + ], + "_prefab": { + "__id__": 106 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 2.591, + "y": 0.697, + "z": -3.192 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.009569056200142995, + "y": -0.27238145223532967, + "z": -0.02174826425431747, + "w": 0.961895935454317 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1.4, + "y": 1.4, + "z": 1.4 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -1.735, + "y": -31.653, + "z": -2.099 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "RootNode", + "_objFlags": 0, + "_parent": { + "__id__": 86 + }, + "_children": [ + { + "__id__": 88 + }, + { + "__id__": 92 + }, + { + "__id__": 98 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 104 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "grass", + "_objFlags": 0, + "_parent": { + "__id__": 87 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 89 + } + ], + "_prefab": { + "__id__": 91 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.37992816729770207, + "y": 0.5963678291908521, + "z": 0.5963678291908521, + "w": -0.37992816729770207 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 0.614784121513367, + "y": 0.614784121513367, + "z": 0.614784121513367 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -90, + "y": -115.0000056286655, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.SkinnedMeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 88 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "b698e55a-b00b-4987-a8b4-af83cddc59f7" + } + ], + "_visFlags": 0, + "lightmapSettings": { + "__id__": 90 + }, + "_mesh": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@ef5e1" + }, + "_shadowCastingMode": 0, + "_enableMorph": true, + "_skeleton": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@438fe" + }, + "_skinningRoot": { + "__id__": 86 + }, + "_id": "", + "__prefab": { + "__id__": 263 + } + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "a2WxB7prNBKZLuuRtE7RC2" + }, + { + "__type__": "cc.Node", + "_name": "Bone001", + "_objFlags": 0, + "_parent": { + "__id__": 87 + }, + "_children": [ + { + "__id__": 93 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 97 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": -0.0461842827498913, + "y": 0.0000118009265861474, + "z": -0.0284814611077309 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.0000017283479103639154, + "y": -0.000001696768662714476, + "z": 0.7049074170330618, + "w": 0.7092993256770451 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -0.0005507418826256091, + "y": 0.00027320859410338513, + "z": 89.64412979694991 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone002", + "_objFlags": 0, + "_parent": { + "__id__": 92 + }, + "_children": [ + { + "__id__": 94 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 96 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0404664427042007, + "y": -3.57627860658738e-9, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.000002421418716486127, + "y": 1.5182564735607207e-8, + "z": 0.006269989150778519, + "w": 0.9999803434219023 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0.000277479600078167, + "y": -3.18993241527229e-13, + "z": 0.7184925395739944 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone003", + "_objFlags": 0, + "_parent": { + "__id__": 93 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 95 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0397140197455883, + "y": -1.19209286886246e-9, + "z": 7.15255721317476e-9 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 1.4018830392883508e-10, + "y": -1.4662893682703937e-13, + "z": -0.0010459420626472054, + "w": 0.9999994530024512 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 1.606440509162768e-8, + "y": -1.4726229276075984e-18, + "z": -0.11985615346346049 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "65JgfqDUlBhq62ZblXl99a" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "613BOOO+hIlqnTjr1LZ7yD" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "d9cSWZZzxJ0JJz3NZ3KYKr" + }, + { + "__type__": "cc.Node", + "_name": "Bone004", + "_objFlags": 0, + "_parent": { + "__id__": 87 + }, + "_children": [ + { + "__id__": 99 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 103 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0710692703723907, + "y": 0.0000118009265861474, + "z": 0.0136896027252078 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.0000017283479103639154, + "y": -0.000001696768662714476, + "z": 0.7049074170330618, + "w": 0.7092993256770451 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -0.0005507418826256091, + "y": 0.00027320859410338513, + "z": 89.64412979694991 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone005", + "_objFlags": 0, + "_parent": { + "__id__": 98 + }, + "_children": [ + { + "__id__": 100 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 102 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0404664427042007, + "y": -4.76837147544984e-9, + "z": 5.9604643443123e-10 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.000002421418716486127, + "y": 1.5182564735607207e-8, + "z": 0.006269989150778519, + "w": 0.9999803434219023 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0.000277479600078167, + "y": -3.18993241527229e-13, + "z": 0.7184925395739944 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone006", + "_objFlags": 0, + "_parent": { + "__id__": 99 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 101 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.039714016020298, + "y": 0, + "z": 7.74860353658369e-9 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 1.4018830392883508e-10, + "y": -1.4662893682703937e-13, + "z": -0.0010459420626472054, + "w": 0.9999994530024512 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 1.606440509162768e-8, + "y": -1.4726229276075984e-18, + "z": -0.11985615346346049 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "4bzVNkn1hF04sTb5BrBwWZ" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "aea82LsKdAiqVuBFPi2Vfz" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "daMGy+QoZIMbYWUh1/PBDR" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "75DE0pyqBGsIOI2RSOFxap" + }, + { + "__type__": "cc.SkeletalAnimation", + "_name": "grass", + "_objFlags": 0, + "node": { + "__id__": 86 + }, + "_enabled": true, + "playOnLoad": true, + "_clips": [ + { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@73b7f" + } + ], + "_defaultClip": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@73b7f" + }, + "_useBakedAnimation": true, + "_sockets": [], + "_id": "", + "__prefab": { + "__id__": 264 + } + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "2d66RAsipF1brG2RGpHJY1" + }, + { + "__type__": "cc.Node", + "_name": "grass", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 108 + } + ], + "_active": true, + "_components": [ + { + "__id__": 126 + } + ], + "_prefab": { + "__id__": 127 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": -2.85, + "y": 0.766, + "z": -2.616 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.007707220961668685, + "y": -0.0985673335815995, + "z": 0.07757256533280044, + "w": 0.9920723646001587 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1.8, + "y": 1.8, + "z": 1.8 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": -11.348, + "z": 8.942 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "RootNode", + "_objFlags": 0, + "_parent": { + "__id__": 107 + }, + "_children": [ + { + "__id__": 109 + }, + { + "__id__": 113 + }, + { + "__id__": 119 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 125 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "grass", + "_objFlags": 0, + "_parent": { + "__id__": 108 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 110 + } + ], + "_prefab": { + "__id__": 112 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.37992816729770207, + "y": 0.5963678291908521, + "z": 0.5963678291908521, + "w": -0.37992816729770207 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 0.614784121513367, + "y": 0.614784121513367, + "z": 0.614784121513367 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -90, + "y": -115.0000056286655, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.SkinnedMeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 109 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "b698e55a-b00b-4987-a8b4-af83cddc59f7" + } + ], + "_visFlags": 0, + "lightmapSettings": { + "__id__": 111 + }, + "_mesh": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@ef5e1" + }, + "_shadowCastingMode": 0, + "_enableMorph": true, + "_skeleton": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@438fe" + }, + "_skinningRoot": { + "__id__": 107 + }, + "_id": "", + "__prefab": { + "__id__": 265 + } + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "32O+zfC79Ly5/JDvR+zPy3" + }, + { + "__type__": "cc.Node", + "_name": "Bone001", + "_objFlags": 0, + "_parent": { + "__id__": 108 + }, + "_children": [ + { + "__id__": 114 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 118 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": -0.0461842827498913, + "y": 0.0000118009265861474, + "z": -0.0284814611077309 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.0000017283479103639154, + "y": -0.000001696768662714476, + "z": 0.7049074170330618, + "w": 0.7092993256770451 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -0.0005507418826256091, + "y": 0.00027320859410338513, + "z": 89.64412979694991 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone002", + "_objFlags": 0, + "_parent": { + "__id__": 113 + }, + "_children": [ + { + "__id__": 115 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 117 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0404664427042007, + "y": -3.57627860658738e-9, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.000002421418716486127, + "y": 1.5182564735607207e-8, + "z": 0.006269989150778519, + "w": 0.9999803434219023 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0.000277479600078167, + "y": -3.18993241527229e-13, + "z": 0.7184925395739944 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone003", + "_objFlags": 0, + "_parent": { + "__id__": 114 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 116 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0397140197455883, + "y": -1.19209286886246e-9, + "z": 7.15255721317476e-9 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 1.4018830392883508e-10, + "y": -1.4662893682703937e-13, + "z": -0.0010459420626472054, + "w": 0.9999994530024512 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 1.606440509162768e-8, + "y": -1.4726229276075984e-18, + "z": -0.11985615346346049 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "f31n3srf1OQ6ztTn+Z0+bi" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "39pnXuaeZGe5VqFTUXoXAo" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "2csxgVNAlDEIWU7lnXQfKS" + }, + { + "__type__": "cc.Node", + "_name": "Bone004", + "_objFlags": 0, + "_parent": { + "__id__": 108 + }, + "_children": [ + { + "__id__": 120 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 124 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0710692703723907, + "y": 0.0000118009265861474, + "z": 0.0136896027252078 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.0000017283479103639154, + "y": -0.000001696768662714476, + "z": 0.7049074170330618, + "w": 0.7092993256770451 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -0.0005507418826256091, + "y": 0.00027320859410338513, + "z": 89.64412979694991 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone005", + "_objFlags": 0, + "_parent": { + "__id__": 119 + }, + "_children": [ + { + "__id__": 121 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 123 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0404664427042007, + "y": -4.76837147544984e-9, + "z": 5.9604643443123e-10 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.000002421418716486127, + "y": 1.5182564735607207e-8, + "z": 0.006269989150778519, + "w": 0.9999803434219023 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0.000277479600078167, + "y": -3.18993241527229e-13, + "z": 0.7184925395739944 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone006", + "_objFlags": 0, + "_parent": { + "__id__": 120 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 122 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.039714016020298, + "y": 0, + "z": 7.74860353658369e-9 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 1.4018830392883508e-10, + "y": -1.4662893682703937e-13, + "z": -0.0010459420626472054, + "w": 0.9999994530024512 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 1.606440509162768e-8, + "y": -1.4726229276075984e-18, + "z": -0.11985615346346049 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "c8HIUzEBxJx72ffmHr7Yzh" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "82tqRzYDNKi6iXruWWHldm" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "e1Z+TO4odC37Bc8FKLNniF" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "12tzV7tYdKJJxbVmqiEpry" + }, + { + "__type__": "cc.SkeletalAnimation", + "_name": "grass", + "_objFlags": 0, + "node": { + "__id__": 107 + }, + "_enabled": true, + "playOnLoad": true, + "_clips": [ + { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@73b7f" + } + ], + "_defaultClip": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@73b7f" + }, + "_useBakedAnimation": true, + "_sockets": [], + "_id": "", + "__prefab": { + "__id__": 266 + } + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "ffwse8PqZBf4sIEkNdsA+i" + }, + { + "__type__": "cc.Node", + "_name": "grass", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 129 + } + ], + "_active": true, + "_components": [ + { + "__id__": 147 + } + ], + "_prefab": { + "__id__": 148 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": -3.252, + "y": 0.663, + "z": -3.355 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.005303598000440666, + "y": -0.09872584440048117, + "z": 0.053380291603709065, + "w": 0.9936677633716235 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1.6, + "y": 1.6, + "z": 1.6 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 9.996766443584073e-17, + "y": -11.348, + "z": 6.150000000000002 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "RootNode", + "_objFlags": 0, + "_parent": { + "__id__": 128 + }, + "_children": [ + { + "__id__": 130 + }, + { + "__id__": 134 + }, + { + "__id__": 140 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 146 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "grass", + "_objFlags": 0, + "_parent": { + "__id__": 129 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 131 + } + ], + "_prefab": { + "__id__": 133 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.37992816729770207, + "y": 0.5963678291908521, + "z": 0.5963678291908521, + "w": -0.37992816729770207 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 0.614784121513367, + "y": 0.614784121513367, + "z": 0.614784121513367 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -90, + "y": -115.0000056286655, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.SkinnedMeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 130 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "b698e55a-b00b-4987-a8b4-af83cddc59f7" + } + ], + "_visFlags": 0, + "lightmapSettings": { + "__id__": 132 + }, + "_mesh": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@ef5e1" + }, + "_shadowCastingMode": 0, + "_enableMorph": true, + "_skeleton": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@438fe" + }, + "_skinningRoot": { + "__id__": 128 + }, + "_id": "", + "__prefab": { + "__id__": 267 + } + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "3c/GljN9JNKpGUQDJiCaAz" + }, + { + "__type__": "cc.Node", + "_name": "Bone001", + "_objFlags": 0, + "_parent": { + "__id__": 129 + }, + "_children": [ + { + "__id__": 135 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 139 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": -0.0461842827498913, + "y": 0.0000118009265861474, + "z": -0.0284814611077309 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.0000017283479103639154, + "y": -0.000001696768662714476, + "z": 0.7049074170330618, + "w": 0.7092993256770451 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -0.0005507418826256091, + "y": 0.00027320859410338513, + "z": 89.64412979694991 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone002", + "_objFlags": 0, + "_parent": { + "__id__": 134 + }, + "_children": [ + { + "__id__": 136 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 138 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0404664427042007, + "y": -3.57627860658738e-9, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.000002421418716486127, + "y": 1.5182564735607207e-8, + "z": 0.006269989150778519, + "w": 0.9999803434219023 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0.000277479600078167, + "y": -3.18993241527229e-13, + "z": 0.7184925395739944 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone003", + "_objFlags": 0, + "_parent": { + "__id__": 135 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 137 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0397140197455883, + "y": -1.19209286886246e-9, + "z": 7.15255721317476e-9 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 1.4018830392883508e-10, + "y": -1.4662893682703937e-13, + "z": -0.0010459420626472054, + "w": 0.9999994530024512 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 1.606440509162768e-8, + "y": -1.4726229276075984e-18, + "z": -0.11985615346346049 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "9fnTS8hnVIWqrzTdhgEpre" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "77DlSvZMVCFLNlyGWiwIha" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "17tlC2EGZMWoKAixVNAp0A" + }, + { + "__type__": "cc.Node", + "_name": "Bone004", + "_objFlags": 0, + "_parent": { + "__id__": 129 + }, + "_children": [ + { + "__id__": 141 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 145 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0710692703723907, + "y": 0.0000118009265861474, + "z": 0.0136896027252078 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.0000017283479103639154, + "y": -0.000001696768662714476, + "z": 0.7049074170330618, + "w": 0.7092993256770451 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -0.0005507418826256091, + "y": 0.00027320859410338513, + "z": 89.64412979694991 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone005", + "_objFlags": 0, + "_parent": { + "__id__": 140 + }, + "_children": [ + { + "__id__": 142 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 144 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0404664427042007, + "y": -4.76837147544984e-9, + "z": 5.9604643443123e-10 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.000002421418716486127, + "y": 1.5182564735607207e-8, + "z": 0.006269989150778519, + "w": 0.9999803434219023 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0.000277479600078167, + "y": -3.18993241527229e-13, + "z": 0.7184925395739944 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone006", + "_objFlags": 0, + "_parent": { + "__id__": 141 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 143 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.039714016020298, + "y": 0, + "z": 7.74860353658369e-9 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 1.4018830392883508e-10, + "y": -1.4662893682703937e-13, + "z": -0.0010459420626472054, + "w": 0.9999994530024512 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 1.606440509162768e-8, + "y": -1.4726229276075984e-18, + "z": -0.11985615346346049 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "8cUixi2TpMHINjSklAPeYi" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "b7XmnH2bBCVpvgTAKnVXA2" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "d1EnMgh6RE7o+kI5cUNlG0" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "0eVA3+ezRBf4EQOOoMIo4S" + }, + { + "__type__": "cc.SkeletalAnimation", + "_name": "grass", + "_objFlags": 0, + "node": { + "__id__": 128 + }, + "_enabled": true, + "playOnLoad": true, + "_clips": [ + { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@73b7f" + } + ], + "_defaultClip": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@73b7f" + }, + "_useBakedAnimation": true, + "_sockets": [], + "_id": "", + "__prefab": { + "__id__": 268 + } + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "adNP+ELEhC4awfcKkY8jYJ" + }, + { + "__type__": "cc.Node", + "_name": "grass", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 150 + } + ], + "_active": true, + "_components": [ + { + "__id__": 168 + } + ], + "_prefab": { + "__id__": 169 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": -4.716, + "y": 0.534, + "z": -2.539 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.011417842217574529, + "y": 0.10201162854238845, + "z": 0.09441482697624534, + "w": 0.9902267926936081 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1.2999999999999998, + "y": 1.3, + "z": 1.3 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -2.442, + "y": 11.991, + "z": 10.641 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "RootNode", + "_objFlags": 0, + "_parent": { + "__id__": 149 + }, + "_children": [ + { + "__id__": 151 + }, + { + "__id__": 155 + }, + { + "__id__": 161 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 167 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "grass", + "_objFlags": 0, + "_parent": { + "__id__": 150 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 152 + } + ], + "_prefab": { + "__id__": 154 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.37992816729770207, + "y": 0.5963678291908521, + "z": 0.5963678291908521, + "w": -0.37992816729770207 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 0.614784121513367, + "y": 0.614784121513367, + "z": 0.614784121513367 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -90, + "y": -115.0000056286655, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.SkinnedMeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 151 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "b698e55a-b00b-4987-a8b4-af83cddc59f7" + } + ], + "_visFlags": 0, + "lightmapSettings": { + "__id__": 153 + }, + "_mesh": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@ef5e1" + }, + "_shadowCastingMode": 0, + "_enableMorph": true, + "_skeleton": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@438fe" + }, + "_skinningRoot": { + "__id__": 149 + }, + "_id": "", + "__prefab": { + "__id__": 269 + } + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "43yCcO1I5D6qP+LJIIGKjX" + }, + { + "__type__": "cc.Node", + "_name": "Bone001", + "_objFlags": 0, + "_parent": { + "__id__": 150 + }, + "_children": [ + { + "__id__": 156 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 160 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": -0.0461842827498913, + "y": 0.0000118009265861474, + "z": -0.0284814611077309 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.0000017283479103639154, + "y": -0.000001696768662714476, + "z": 0.7049074170330618, + "w": 0.7092993256770451 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -0.0005507418826256091, + "y": 0.00027320859410338513, + "z": 89.64412979694991 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone002", + "_objFlags": 0, + "_parent": { + "__id__": 155 + }, + "_children": [ + { + "__id__": 157 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 159 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0404664427042007, + "y": -3.57627860658738e-9, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.000002421418716486127, + "y": 1.5182564735607207e-8, + "z": 0.006269989150778519, + "w": 0.9999803434219023 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0.000277479600078167, + "y": -3.18993241527229e-13, + "z": 0.7184925395739944 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone003", + "_objFlags": 0, + "_parent": { + "__id__": 156 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 158 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0397140197455883, + "y": -1.19209286886246e-9, + "z": 7.15255721317476e-9 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 1.4018830392883508e-10, + "y": -1.4662893682703937e-13, + "z": -0.0010459420626472054, + "w": 0.9999994530024512 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 1.606440509162768e-8, + "y": -1.4726229276075984e-18, + "z": -0.11985615346346049 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "d5T2sohQVAEa4ljoSzlMKU" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "93hV+qqgFP44pIvuByy6RE" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "0aJTcuk/5M56nEkb+D7tN9" + }, + { + "__type__": "cc.Node", + "_name": "Bone004", + "_objFlags": 0, + "_parent": { + "__id__": 150 + }, + "_children": [ + { + "__id__": 162 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 166 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0710692703723907, + "y": 0.0000118009265861474, + "z": 0.0136896027252078 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.0000017283479103639154, + "y": -0.000001696768662714476, + "z": 0.7049074170330618, + "w": 0.7092993256770451 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -0.0005507418826256091, + "y": 0.00027320859410338513, + "z": 89.64412979694991 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone005", + "_objFlags": 0, + "_parent": { + "__id__": 161 + }, + "_children": [ + { + "__id__": 163 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 165 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0404664427042007, + "y": -4.76837147544984e-9, + "z": 5.9604643443123e-10 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.000002421418716486127, + "y": 1.5182564735607207e-8, + "z": 0.006269989150778519, + "w": 0.9999803434219023 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0.000277479600078167, + "y": -3.18993241527229e-13, + "z": 0.7184925395739944 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone006", + "_objFlags": 0, + "_parent": { + "__id__": 162 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 164 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.039714016020298, + "y": 0, + "z": 7.74860353658369e-9 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 1.4018830392883508e-10, + "y": -1.4662893682703937e-13, + "z": -0.0010459420626472054, + "w": 0.9999994530024512 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 1.606440509162768e-8, + "y": -1.4726229276075984e-18, + "z": -0.11985615346346049 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "6c2sTe+khLGYrsZVSADL4H" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "ecsSU+lvpNf7DhOOeFG7w2" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "6etpava3ZGlovr3HG7SpRo" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "53OGGCuwFNs4KQ0nQRdow5" + }, + { + "__type__": "cc.SkeletalAnimation", + "_name": "grass", + "_objFlags": 0, + "node": { + "__id__": 149 + }, + "_enabled": true, + "playOnLoad": true, + "_clips": [ + { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@73b7f" + } + ], + "_defaultClip": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@73b7f" + }, + "_useBakedAnimation": true, + "_sockets": [], + "_id": "", + "__prefab": { + "__id__": 270 + } + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "33gYFxG8dO2r8iKjzjEx4z" + }, + { + "__type__": "cc.Node", + "_name": "grass", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 171 + } + ], + "_active": true, + "_components": [ + { + "__id__": 189 + } + ], + "_prefab": { + "__id__": 190 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": -3.151, + "y": 0.706, + "z": -2.905 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.01606605470413201, + "y": 0.10576273729137807, + "z": 0.0511818299419083, + "w": 0.9929433748057723 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1.6, + "y": 1.6, + "z": 1.6 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -2.461, + "y": 12.281, + "z": 5.638 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "RootNode", + "_objFlags": 0, + "_parent": { + "__id__": 170 + }, + "_children": [ + { + "__id__": 172 + }, + { + "__id__": 176 + }, + { + "__id__": 182 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 188 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "grass", + "_objFlags": 0, + "_parent": { + "__id__": 171 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 173 + } + ], + "_prefab": { + "__id__": 175 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.37992816729770207, + "y": 0.5963678291908521, + "z": 0.5963678291908521, + "w": -0.37992816729770207 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 0.614784121513367, + "y": 0.614784121513367, + "z": 0.614784121513367 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -90, + "y": -115.0000056286655, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.SkinnedMeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 172 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "b698e55a-b00b-4987-a8b4-af83cddc59f7" + } + ], + "_visFlags": 0, + "lightmapSettings": { + "__id__": 174 + }, + "_mesh": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@ef5e1" + }, + "_shadowCastingMode": 0, + "_enableMorph": true, + "_skeleton": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@438fe" + }, + "_skinningRoot": { + "__id__": 170 + }, + "_id": "", + "__prefab": { + "__id__": 271 + } + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "87cW2HzEtNk4+RMW95NbLB" + }, + { + "__type__": "cc.Node", + "_name": "Bone001", + "_objFlags": 0, + "_parent": { + "__id__": 171 + }, + "_children": [ + { + "__id__": 177 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 181 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": -0.0461842827498913, + "y": 0.0000118009265861474, + "z": -0.0284814611077309 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.0000017283479103639154, + "y": -0.000001696768662714476, + "z": 0.7049074170330618, + "w": 0.7092993256770451 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -0.0005507418826256091, + "y": 0.00027320859410338513, + "z": 89.64412979694991 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone002", + "_objFlags": 0, + "_parent": { + "__id__": 176 + }, + "_children": [ + { + "__id__": 178 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 180 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0404664427042007, + "y": -3.57627860658738e-9, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.000002421418716486127, + "y": 1.5182564735607207e-8, + "z": 0.006269989150778519, + "w": 0.9999803434219023 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0.000277479600078167, + "y": -3.18993241527229e-13, + "z": 0.7184925395739944 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone003", + "_objFlags": 0, + "_parent": { + "__id__": 177 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 179 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0397140197455883, + "y": -1.19209286886246e-9, + "z": 7.15255721317476e-9 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 1.4018830392883508e-10, + "y": -1.4662893682703937e-13, + "z": -0.0010459420626472054, + "w": 0.9999994530024512 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 1.606440509162768e-8, + "y": -1.4726229276075984e-18, + "z": -0.11985615346346049 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "5bcVkwfGRPza49BU4T6rqn" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "fcqb+cLDVJ3KNvBTyJYBwm" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "16ssZzbLdO76GQg4Dvdp/y" + }, + { + "__type__": "cc.Node", + "_name": "Bone004", + "_objFlags": 0, + "_parent": { + "__id__": 171 + }, + "_children": [ + { + "__id__": 183 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 187 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0710692703723907, + "y": 0.0000118009265861474, + "z": 0.0136896027252078 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.0000017283479103639154, + "y": -0.000001696768662714476, + "z": 0.7049074170330618, + "w": 0.7092993256770451 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -0.0005507418826256091, + "y": 0.00027320859410338513, + "z": 89.64412979694991 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone005", + "_objFlags": 0, + "_parent": { + "__id__": 182 + }, + "_children": [ + { + "__id__": 184 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 186 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0404664427042007, + "y": -4.76837147544984e-9, + "z": 5.9604643443123e-10 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.000002421418716486127, + "y": 1.5182564735607207e-8, + "z": 0.006269989150778519, + "w": 0.9999803434219023 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0.000277479600078167, + "y": -3.18993241527229e-13, + "z": 0.7184925395739944 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone006", + "_objFlags": 0, + "_parent": { + "__id__": 183 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 185 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.039714016020298, + "y": 0, + "z": 7.74860353658369e-9 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 1.4018830392883508e-10, + "y": -1.4662893682703937e-13, + "z": -0.0010459420626472054, + "w": 0.9999994530024512 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 1.606440509162768e-8, + "y": -1.4726229276075984e-18, + "z": -0.11985615346346049 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "0b/yPLcR1FiZPqyfaG8HBZ" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "0fPapM97RGmYmlB69FuuSF" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "0eRKfLOh9OdLsOOjTosv1c" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "560/1xR41BPKG+lcc5935I" + }, + { + "__type__": "cc.SkeletalAnimation", + "_name": "grass", + "_objFlags": 0, + "node": { + "__id__": 170 + }, + "_enabled": true, + "playOnLoad": true, + "_clips": [ + { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@73b7f" + } + ], + "_defaultClip": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@73b7f" + }, + "_useBakedAnimation": true, + "_sockets": [], + "_id": "", + "__prefab": { + "__id__": 272 + } + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "27mCip0lFNkL+6Dj/Bpwj4" + }, + { + "__type__": "cc.Node", + "_name": "grass", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 192 + } + ], + "_active": true, + "_components": [ + { + "__id__": 210 + } + ], + "_prefab": { + "__id__": 211 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 2.179, + "y": 0.714, + "z": -3.159 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.0002046174412504865, + "y": -0.2725489284000769, + "z": -0.05622568582446521, + "w": 0.9604976376926917 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1.4, + "y": 1.4, + "z": 1.4 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -1.744, + "y": -31.778, + "z": -6.207 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "RootNode", + "_objFlags": 0, + "_parent": { + "__id__": 191 + }, + "_children": [ + { + "__id__": 193 + }, + { + "__id__": 197 + }, + { + "__id__": 203 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 209 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "grass", + "_objFlags": 0, + "_parent": { + "__id__": 192 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 194 + } + ], + "_prefab": { + "__id__": 196 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.37992816729770207, + "y": 0.5963678291908521, + "z": 0.5963678291908521, + "w": -0.37992816729770207 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 0.614784121513367, + "y": 0.614784121513367, + "z": 0.614784121513367 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -90, + "y": -115.0000056286655, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.SkinnedMeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 193 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "b698e55a-b00b-4987-a8b4-af83cddc59f7" + } + ], + "_visFlags": 0, + "lightmapSettings": { + "__id__": 195 + }, + "_mesh": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@ef5e1" + }, + "_shadowCastingMode": 0, + "_enableMorph": true, + "_skeleton": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@438fe" + }, + "_skinningRoot": { + "__id__": 191 + }, + "_id": "", + "__prefab": { + "__id__": 273 + } + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "08LJZ1ezRCiqnszI5cXQTx" + }, + { + "__type__": "cc.Node", + "_name": "Bone001", + "_objFlags": 0, + "_parent": { + "__id__": 192 + }, + "_children": [ + { + "__id__": 198 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 202 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": -0.0461842827498913, + "y": 0.0000118009265861474, + "z": -0.0284814611077309 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.0000017283479103639154, + "y": -0.000001696768662714476, + "z": 0.7049074170330618, + "w": 0.7092993256770451 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -0.0005507418826256091, + "y": 0.00027320859410338513, + "z": 89.64412979694991 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone002", + "_objFlags": 0, + "_parent": { + "__id__": 197 + }, + "_children": [ + { + "__id__": 199 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 201 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0404664427042007, + "y": -3.57627860658738e-9, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.000002421418716486127, + "y": 1.5182564735607207e-8, + "z": 0.006269989150778519, + "w": 0.9999803434219023 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0.000277479600078167, + "y": -3.18993241527229e-13, + "z": 0.7184925395739944 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone003", + "_objFlags": 0, + "_parent": { + "__id__": 198 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 200 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0397140197455883, + "y": -1.19209286886246e-9, + "z": 7.15255721317476e-9 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 1.4018830392883508e-10, + "y": -1.4662893682703937e-13, + "z": -0.0010459420626472054, + "w": 0.9999994530024512 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 1.606440509162768e-8, + "y": -1.4726229276075984e-18, + "z": -0.11985615346346049 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "d8OdalQsZKwLFf2mFuR1VJ" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "ecFy8CTgxCib8Fky/YcoUL" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "c9g0zchT9L8IQmY+99TABR" + }, + { + "__type__": "cc.Node", + "_name": "Bone004", + "_objFlags": 0, + "_parent": { + "__id__": 192 + }, + "_children": [ + { + "__id__": 204 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 208 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0710692703723907, + "y": 0.0000118009265861474, + "z": 0.0136896027252078 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.0000017283479103639154, + "y": -0.000001696768662714476, + "z": 0.7049074170330618, + "w": 0.7092993256770451 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -0.0005507418826256091, + "y": 0.00027320859410338513, + "z": 89.64412979694991 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone005", + "_objFlags": 0, + "_parent": { + "__id__": 203 + }, + "_children": [ + { + "__id__": 205 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 207 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0404664427042007, + "y": -4.76837147544984e-9, + "z": 5.9604643443123e-10 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.000002421418716486127, + "y": 1.5182564735607207e-8, + "z": 0.006269989150778519, + "w": 0.9999803434219023 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0.000277479600078167, + "y": -3.18993241527229e-13, + "z": 0.7184925395739944 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone006", + "_objFlags": 0, + "_parent": { + "__id__": 204 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 206 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.039714016020298, + "y": 0, + "z": 7.74860353658369e-9 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 1.4018830392883508e-10, + "y": -1.4662893682703937e-13, + "z": -0.0010459420626472054, + "w": 0.9999994530024512 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 1.606440509162768e-8, + "y": -1.4726229276075984e-18, + "z": -0.11985615346346049 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "66R8TA3S1NT4HLywjDiP1Q" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "963dgjTmdES7q6KBvCTllJ" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "91+xPZxDtGRp/x7cNrBUhM" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "25mf8t9bhJIo3E0lcGCo1H" + }, + { + "__type__": "cc.SkeletalAnimation", + "_name": "grass", + "_objFlags": 0, + "node": { + "__id__": 191 + }, + "_enabled": true, + "playOnLoad": true, + "_clips": [ + { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@73b7f" + } + ], + "_defaultClip": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@73b7f" + }, + "_useBakedAnimation": true, + "_sockets": [], + "_id": "", + "__prefab": { + "__id__": 274 + } + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "50aim7sdtB2rmsHB4KRkd5" + }, + { + "__type__": "cc.Node", + "_name": "grass", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 213 + } + ], + "_active": true, + "_components": [ + { + "__id__": 231 + } + ], + "_prefab": { + "__id__": 232 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 5.041, + "y": 0.406, + "z": -3.58 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.026333680128465056, + "y": -0.27127042474669716, + "z": -0.14805365417229147, + "w": 0.9506834433368816 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1.4, + "y": 1.4, + "z": 1.4 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -1.815, + "y": -32.126, + "z": -17.205 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "RootNode", + "_objFlags": 0, + "_parent": { + "__id__": 212 + }, + "_children": [ + { + "__id__": 214 + }, + { + "__id__": 218 + }, + { + "__id__": 224 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 230 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "grass", + "_objFlags": 0, + "_parent": { + "__id__": 213 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 215 + } + ], + "_prefab": { + "__id__": 217 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.37992816729770207, + "y": 0.5963678291908521, + "z": 0.5963678291908521, + "w": -0.37992816729770207 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 0.614784121513367, + "y": 0.614784121513367, + "z": 0.614784121513367 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -90, + "y": -115.0000056286655, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.SkinnedMeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 214 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "b698e55a-b00b-4987-a8b4-af83cddc59f7" + } + ], + "_visFlags": 0, + "lightmapSettings": { + "__id__": 216 + }, + "_mesh": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@ef5e1" + }, + "_shadowCastingMode": 0, + "_enableMorph": true, + "_skeleton": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@438fe" + }, + "_skinningRoot": { + "__id__": 212 + }, + "_id": "", + "__prefab": { + "__id__": 275 + } + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "203+J3Vb1LP7KUgkjLvNtX" + }, + { + "__type__": "cc.Node", + "_name": "Bone001", + "_objFlags": 0, + "_parent": { + "__id__": 213 + }, + "_children": [ + { + "__id__": 219 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 223 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": -0.0461842827498913, + "y": 0.0000118009265861474, + "z": -0.0284814611077309 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.0000017283479103639154, + "y": -0.000001696768662714476, + "z": 0.7049074170330618, + "w": 0.7092993256770451 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -0.0005507418826256091, + "y": 0.00027320859410338513, + "z": 89.64412979694991 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone002", + "_objFlags": 0, + "_parent": { + "__id__": 218 + }, + "_children": [ + { + "__id__": 220 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 222 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0404664427042007, + "y": -3.57627860658738e-9, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.000002421418716486127, + "y": 1.5182564735607207e-8, + "z": 0.006269989150778519, + "w": 0.9999803434219023 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0.000277479600078167, + "y": -3.18993241527229e-13, + "z": 0.7184925395739944 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone003", + "_objFlags": 0, + "_parent": { + "__id__": 219 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 221 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0397140197455883, + "y": -1.19209286886246e-9, + "z": 7.15255721317476e-9 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 1.4018830392883508e-10, + "y": -1.4662893682703937e-13, + "z": -0.0010459420626472054, + "w": 0.9999994530024512 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 1.606440509162768e-8, + "y": -1.4726229276075984e-18, + "z": -0.11985615346346049 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "3aJII/zG9KaYapX0uizphW" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "48r+NZR1BD7Y5qEv/ruQsO" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "9eOEdVVahA+rbDiF4AJNNX" + }, + { + "__type__": "cc.Node", + "_name": "Bone004", + "_objFlags": 0, + "_parent": { + "__id__": 213 + }, + "_children": [ + { + "__id__": 225 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 229 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0710692703723907, + "y": 0.0000118009265861474, + "z": 0.0136896027252078 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.0000017283479103639154, + "y": -0.000001696768662714476, + "z": 0.7049074170330618, + "w": 0.7092993256770451 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -0.0005507418826256091, + "y": 0.00027320859410338513, + "z": 89.64412979694991 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone005", + "_objFlags": 0, + "_parent": { + "__id__": 224 + }, + "_children": [ + { + "__id__": 226 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 228 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0404664427042007, + "y": -4.76837147544984e-9, + "z": 5.9604643443123e-10 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.000002421418716486127, + "y": 1.5182564735607207e-8, + "z": 0.006269989150778519, + "w": 0.9999803434219023 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0.000277479600078167, + "y": -3.18993241527229e-13, + "z": 0.7184925395739944 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone006", + "_objFlags": 0, + "_parent": { + "__id__": 225 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 227 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.039714016020298, + "y": 0, + "z": 7.74860353658369e-9 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 1.4018830392883508e-10, + "y": -1.4662893682703937e-13, + "z": -0.0010459420626472054, + "w": 0.9999994530024512 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 1.606440509162768e-8, + "y": -1.4726229276075984e-18, + "z": -0.11985615346346049 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "1fFpy0ihVOYbzhBLRLkL1Y" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "d9iCqzyppAILXebiHSqtDk" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "469eCD0ttKHZacZ3xtfeuD" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "9dXaYb8ytBBb2yYH4yN6Vh" + }, + { + "__type__": "cc.SkeletalAnimation", + "_name": "grass", + "_objFlags": 0, + "node": { + "__id__": 212 + }, + "_enabled": true, + "playOnLoad": true, + "_clips": [ + { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@73b7f" + } + ], + "_defaultClip": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@73b7f" + }, + "_useBakedAnimation": true, + "_sockets": [], + "_id": "", + "__prefab": { + "__id__": 276 + } + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "70DWXrCRRL4pWATtzgi7DN" + }, + { + "__type__": "cc.Node", + "_name": "grass", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 234 + } + ], + "_active": true, + "_components": [ + { + "__id__": 252 + } + ], + "_prefab": { + "__id__": 253 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 4.153, + "y": 0.548, + "z": -3.566 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.01263456693718553, + "y": -0.27225485806840527, + "z": -0.09997674733537244, + "w": 0.9569338064718487 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1.4, + "y": 1.4, + "z": 1.4 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -1.769, + "y": -31.94, + "z": -11.433 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "RootNode", + "_objFlags": 0, + "_parent": { + "__id__": 233 + }, + "_children": [ + { + "__id__": 235 + }, + { + "__id__": 239 + }, + { + "__id__": 245 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 251 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "grass", + "_objFlags": 0, + "_parent": { + "__id__": 234 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 236 + } + ], + "_prefab": { + "__id__": 238 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.37992816729770207, + "y": 0.5963678291908521, + "z": 0.5963678291908521, + "w": -0.37992816729770207 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 0.614784121513367, + "y": 0.614784121513367, + "z": 0.614784121513367 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -90, + "y": -115.0000056286655, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.SkinnedMeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 235 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "b698e55a-b00b-4987-a8b4-af83cddc59f7" + } + ], + "_visFlags": 0, + "lightmapSettings": { + "__id__": 237 + }, + "_mesh": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@ef5e1" + }, + "_shadowCastingMode": 0, + "_enableMorph": true, + "_skeleton": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@438fe" + }, + "_skinningRoot": { + "__id__": 233 + }, + "_id": "", + "__prefab": { + "__id__": 277 + } + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "80TsYKkUVBAIbPGc2Ao+X4" + }, + { + "__type__": "cc.Node", + "_name": "Bone001", + "_objFlags": 0, + "_parent": { + "__id__": 234 + }, + "_children": [ + { + "__id__": 240 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 244 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": -0.0461842827498913, + "y": 0.0000118009265861474, + "z": -0.0284814611077309 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.0000017283479103639154, + "y": -0.000001696768662714476, + "z": 0.7049074170330618, + "w": 0.7092993256770451 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -0.0005507418826256091, + "y": 0.00027320859410338513, + "z": 89.64412979694991 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone002", + "_objFlags": 0, + "_parent": { + "__id__": 239 + }, + "_children": [ + { + "__id__": 241 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 243 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0404664427042007, + "y": -3.57627860658738e-9, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.000002421418716486127, + "y": 1.5182564735607207e-8, + "z": 0.006269989150778519, + "w": 0.9999803434219023 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0.000277479600078167, + "y": -3.18993241527229e-13, + "z": 0.7184925395739944 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone003", + "_objFlags": 0, + "_parent": { + "__id__": 240 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 242 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0397140197455883, + "y": -1.19209286886246e-9, + "z": 7.15255721317476e-9 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 1.4018830392883508e-10, + "y": -1.4662893682703937e-13, + "z": -0.0010459420626472054, + "w": 0.9999994530024512 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 1.606440509162768e-8, + "y": -1.4726229276075984e-18, + "z": -0.11985615346346049 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "6aDs2ciZhDh6tahiNmO4QO" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "1er+9JvftCj5j548DE5PNk" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "54j/6cneBCF4PpXQIO+ZrT" + }, + { + "__type__": "cc.Node", + "_name": "Bone004", + "_objFlags": 0, + "_parent": { + "__id__": 234 + }, + "_children": [ + { + "__id__": 246 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 250 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0710692703723907, + "y": 0.0000118009265861474, + "z": 0.0136896027252078 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.0000017283479103639154, + "y": -0.000001696768662714476, + "z": 0.7049074170330618, + "w": 0.7092993256770451 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -0.0005507418826256091, + "y": 0.00027320859410338513, + "z": 89.64412979694991 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone005", + "_objFlags": 0, + "_parent": { + "__id__": 245 + }, + "_children": [ + { + "__id__": 247 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 249 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0404664427042007, + "y": -4.76837147544984e-9, + "z": 5.9604643443123e-10 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.000002421418716486127, + "y": 1.5182564735607207e-8, + "z": 0.006269989150778519, + "w": 0.9999803434219023 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0.000277479600078167, + "y": -3.18993241527229e-13, + "z": 0.7184925395739944 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone006", + "_objFlags": 0, + "_parent": { + "__id__": 246 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 248 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.039714016020298, + "y": 0, + "z": 7.74860353658369e-9 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 1.4018830392883508e-10, + "y": -1.4662893682703937e-13, + "z": -0.0010459420626472054, + "w": 0.9999994530024512 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 1.606440509162768e-8, + "y": -1.4726229276075984e-18, + "z": -0.11985615346346049 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "1eZ45FwjhMoY5AmDd/ApaW" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "7fkJUsKFZMHbutZKiHcKAf" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "c8ON8aNTZH1YV9KZsolNGO" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "fa4L3FVuFMwYhNq67HoU7c" + }, + { + "__type__": "cc.SkeletalAnimation", + "_name": "grass", + "_objFlags": 0, + "node": { + "__id__": 233 + }, + "_enabled": true, + "playOnLoad": true, + "_clips": [ + { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@73b7f" + } + ], + "_defaultClip": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@73b7f" + }, + "_useBakedAnimation": true, + "_sockets": [], + "_id": "", + "__prefab": { + "__id__": 278 + } + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "7aOtJ3fThN27Zj4fmkg0ut" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "e5Peksu5tL9peMeABb8/JC" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "47zIzNBCBNWpHG32eDyrxp" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "7bKAX+g0hOqZeDhmkHG0IO" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "40X4tSMKxI+6zwgQ3Rwf/A" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "30kRInnuRN6qPrWxAcm+CI" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "c3TlGKm2VDyqqklAluBrr7" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "94vToBjvVOSp7Oc32RikBR" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "10+VGsdAVN6LIgVeFtQ5bK" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "a0QNySDClKpaFLLhtz8g/R" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "e9xwES3AdHxJi5coUOv36/" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "afdfCOgCJNuKPmVT+dOTcZ" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "93I8/O8TJPmL3J+cSBnn74" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "f5E2ZKrANAhqLVdak99Arg" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "58r+OjAt5IA4RiLwdN8c3y" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "1bP72q34xD1rNdA/oy7MmS" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "a5NJSBP+9JrKy6+h3VfngD" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "03ik2XrVtDJb1vo0EtpvYI" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "e2ISYx6glGKryX0KFY7620" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "3ci0uo8OJIWZiblaEzXfOe" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "e6mW8ZFDhHUJHvdOH+WypT" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "2cG8FI7JZHkZSXmRvjunfO" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "840DRWYY5A/oRcjeJH91ox" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "a9k81Zta1ETIz9cTVaaI0c" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "7aD+wdrbJHeqrEmpgGnsZv" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "38NdVKbuRLrrLIaNrkMsRY" + } +] diff --git a/BezierPathsDemo/assets/model/helloWorld/grass/grassGoup.prefab.meta b/BezierPathsDemo/assets/model/helloWorld/grass/grassGoup.prefab.meta new file mode 100644 index 0000000..cd77321 --- /dev/null +++ b/BezierPathsDemo/assets/model/helloWorld/grass/grassGoup.prefab.meta @@ -0,0 +1,13 @@ +{ + "ver": "1.1.27", + "importer": "prefab", + "imported": true, + "uuid": "5e4d48c4-0e34-45af-a268-89485197e8bc", + "files": [ + ".json" + ], + "subMetas": {}, + "userData": { + "syncNodeName": "grassGoup" + } +} diff --git a/BezierPathsDemo/assets/model/helloWorld/hdcSky.FBX b/BezierPathsDemo/assets/model/helloWorld/hdcSky.FBX new file mode 100644 index 0000000..e8c5d98 Binary files /dev/null and b/BezierPathsDemo/assets/model/helloWorld/hdcSky.FBX differ diff --git a/BezierPathsDemo/assets/model/helloWorld/hdcSky.FBX.meta b/BezierPathsDemo/assets/model/helloWorld/hdcSky.FBX.meta new file mode 100644 index 0000000..8092784 --- /dev/null +++ b/BezierPathsDemo/assets/model/helloWorld/hdcSky.FBX.meta @@ -0,0 +1,110 @@ +{ + "ver": "2.0.14", + "importer": "fbx", + "imported": true, + "uuid": "929e58ce-66a4-4e04-9036-4244456a1220", + "files": [], + "subMetas": { + "f6832": { + "importer": "gltf-mesh", + "uuid": "929e58ce-66a4-4e04-9036-4244456a1220@f6832", + "displayName": "", + "id": "f6832", + "name": "hdcSky.mesh", + "ver": "1.1.0", + "imported": true, + "files": [ + ".bin", + ".json" + ], + "subMetas": {}, + "userData": { + "gltfIndex": 0 + } + }, + "7f40d": { + "importer": "gltf-embeded-image", + "uuid": "929e58ce-66a4-4e04-9036-4244456a1220@7f40d", + "displayName": "", + "id": "7f40d", + "name": "hdcSky.image", + "ver": "1.0.3", + "imported": true, + "files": [ + ".png", + ".json" + ], + "subMetas": {}, + "userData": { + "gltfIndex": 0 + } + }, + "d6067": { + "importer": "texture", + "uuid": "929e58ce-66a4-4e04-9036-4244456a1220@d6067", + "displayName": "", + "id": "d6067", + "name": "hdcSky.texture", + "ver": "1.0.21", + "imported": true, + "files": [ + ".json" + ], + "subMetas": {}, + "userData": { + "wrapModeS": "repeat", + "wrapModeT": "repeat", + "minfilter": "linear", + "magfilter": "linear", + "mipfilter": "none", + "premultiplyAlpha": false, + "anisotropy": 0, + "isUuid": true, + "imageUuidOrDatabaseUri": "929e58ce-66a4-4e04-9036-4244456a1220@7f40d" + } + }, + "bfc57": { + "importer": "gltf-scene", + "uuid": "929e58ce-66a4-4e04-9036-4244456a1220@bfc57", + "displayName": "", + "id": "bfc57", + "name": "hdcSky.prefab", + "ver": "1.0.12", + "imported": true, + "files": [ + ".json" + ], + "subMetas": {}, + "userData": { + "gltfIndex": 0 + } + } + }, + "userData": { + "imageMetas": [ + { + "name": "hdcSky", + "uri": "929e58ce-66a4-4e04-9036-4244456a1220@7f40d" + } + ], + "redirect": "929e58ce-66a4-4e04-9036-4244456a1220@bfc57", + "assetFinder": { + "meshes": [ + "929e58ce-66a4-4e04-9036-4244456a1220@f6832" + ], + "skeletons": [], + "textures": [ + "929e58ce-66a4-4e04-9036-4244456a1220@d6067" + ], + "materials": [ + "482a5162-dad9-446c-b548-8486c7598ee1" + ], + "scenes": [ + "929e58ce-66a4-4e04-9036-4244456a1220@bfc57" + ] + }, + "dumpMaterials": true, + "materialDumpDir": "db://assets/material", + "legacyFbxImporter": true + } +} diff --git a/BezierPathsDemo/assets/model/helloWorld/hdcSky.prefab b/BezierPathsDemo/assets/model/helloWorld/hdcSky.prefab new file mode 100644 index 0000000..5bc5c27 --- /dev/null +++ b/BezierPathsDemo/assets/model/helloWorld/hdcSky.prefab @@ -0,0 +1,223 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "asyncLoadAssets": false + }, + { + "__type__": "cc.Node", + "_name": "hdcSky", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 8 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "RootNode", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 3 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 7 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "hdcSky", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 4 + } + ], + "_prefab": { + "__id__": 6 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0.00000556361783310422 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.7071067811865476, + "y": 0, + "z": 0, + "w": 0.7071067811865476 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.57702493667603, + "y": 2.57702493667603, + "z": 2.57702493667603 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -90.00000000000003, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.MeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 3 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "482a5162-dad9-446c-b548-8486c7598ee1" + } + ], + "_visFlags": 0, + "lightmapSettings": { + "__id__": 5 + }, + "_mesh": { + "__uuid__": "929e58ce-66a4-4e04-9036-4244456a1220@f6832" + }, + "_shadowCastingMode": 0, + "_enableMorph": true, + "_id": "", + "__prefab": { + "__id__": 9 + } + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "537wfATPdERIxNoHyImaal" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "68pBvn4L5LzqzYlxlqIh1Z" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "a0C8RfybZDJbzD2rhAA/j8" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "b5IvvQucVPBaLUcNTcK1KI" + } +] diff --git a/BezierPathsDemo/assets/model/helloWorld/hdcSky.prefab.meta b/BezierPathsDemo/assets/model/helloWorld/hdcSky.prefab.meta new file mode 100644 index 0000000..18a55d3 --- /dev/null +++ b/BezierPathsDemo/assets/model/helloWorld/hdcSky.prefab.meta @@ -0,0 +1,13 @@ +{ + "ver": "1.1.27", + "importer": "prefab", + "imported": true, + "uuid": "f0512d7a-e4f6-4209-8dc0-ed1de7149c85", + "files": [ + ".json" + ], + "subMetas": {}, + "userData": { + "syncNodeName": "hdcSky" + } +} diff --git a/BezierPathsDemo/assets/model/helloWorld/islands.FBX b/BezierPathsDemo/assets/model/helloWorld/islands.FBX new file mode 100644 index 0000000..fb0021b Binary files /dev/null and b/BezierPathsDemo/assets/model/helloWorld/islands.FBX differ diff --git a/BezierPathsDemo/assets/model/helloWorld/islands.FBX.meta b/BezierPathsDemo/assets/model/helloWorld/islands.FBX.meta new file mode 100644 index 0000000..f9986fc --- /dev/null +++ b/BezierPathsDemo/assets/model/helloWorld/islands.FBX.meta @@ -0,0 +1,366 @@ +{ + "ver": "2.0.14", + "importer": "fbx", + "imported": true, + "uuid": "0ab3142a-6968-4073-95af-026bc3b23623", + "files": [], + "subMetas": { + "71919": { + "importer": "gltf-mesh", + "uuid": "0ab3142a-6968-4073-95af-026bc3b23623@71919", + "displayName": "", + "id": "71919", + "name": "tree1-6.mesh", + "ver": "1.1.0", + "imported": true, + "files": [ + ".bin", + ".json" + ], + "subMetas": {}, + "userData": { + "gltfIndex": 6 + } + }, + "2b0a8": { + "importer": "gltf-mesh", + "uuid": "0ab3142a-6968-4073-95af-026bc3b23623@2b0a8", + "displayName": "", + "id": "2b0a8", + "name": "plane01-0.mesh", + "ver": "1.1.0", + "imported": true, + "files": [ + ".bin", + ".json" + ], + "subMetas": {}, + "userData": { + "gltfIndex": 0 + } + }, + "4a7d8": { + "importer": "gltf-mesh", + "uuid": "0ab3142a-6968-4073-95af-026bc3b23623@4a7d8", + "displayName": "", + "id": "4a7d8", + "name": "stone1-1.mesh", + "ver": "1.1.0", + "imported": true, + "files": [ + ".bin", + ".json" + ], + "subMetas": {}, + "userData": { + "gltfIndex": 1 + } + }, + "0e750": { + "importer": "gltf-mesh", + "uuid": "0ab3142a-6968-4073-95af-026bc3b23623@0e750", + "displayName": "", + "id": "0e750", + "name": "tree1-2.mesh", + "ver": "1.1.0", + "imported": true, + "files": [ + ".bin", + ".json" + ], + "subMetas": {}, + "userData": { + "gltfIndex": 2 + } + }, + "ef86b": { + "importer": "gltf-mesh", + "uuid": "0ab3142a-6968-4073-95af-026bc3b23623@ef86b", + "displayName": "", + "id": "ef86b", + "name": "tree1-3.mesh", + "ver": "1.1.0", + "imported": true, + "files": [ + ".bin", + ".json" + ], + "subMetas": {}, + "userData": { + "gltfIndex": 3 + } + }, + "426f2": { + "importer": "gltf-mesh", + "uuid": "0ab3142a-6968-4073-95af-026bc3b23623@426f2", + "displayName": "", + "id": "426f2", + "name": "tree1-4.mesh", + "ver": "1.1.0", + "imported": true, + "files": [ + ".bin", + ".json" + ], + "subMetas": {}, + "userData": { + "gltfIndex": 4 + } + }, + "754a2": { + "importer": "gltf-mesh", + "uuid": "0ab3142a-6968-4073-95af-026bc3b23623@754a2", + "displayName": "", + "id": "754a2", + "name": "tree1-5.mesh", + "ver": "1.1.0", + "imported": true, + "files": [ + ".bin", + ".json" + ], + "subMetas": {}, + "userData": { + "gltfIndex": 5 + } + }, + "1332c": { + "importer": "gltf-mesh", + "uuid": "0ab3142a-6968-4073-95af-026bc3b23623@1332c", + "displayName": "", + "id": "1332c", + "name": "tree1-7.mesh", + "ver": "1.1.0", + "imported": true, + "files": [ + ".bin", + ".json" + ], + "subMetas": {}, + "userData": { + "gltfIndex": 7 + } + }, + "4d16f": { + "importer": "gltf-mesh", + "uuid": "0ab3142a-6968-4073-95af-026bc3b23623@4d16f", + "displayName": "", + "id": "4d16f", + "name": "tree1-8.mesh", + "ver": "1.1.0", + "imported": true, + "files": [ + ".bin", + ".json" + ], + "subMetas": {}, + "userData": { + "gltfIndex": 8 + } + }, + "efe84": { + "importer": "gltf-mesh", + "uuid": "0ab3142a-6968-4073-95af-026bc3b23623@efe84", + "displayName": "", + "id": "efe84", + "name": "tree1-9.mesh", + "ver": "1.1.0", + "imported": true, + "files": [ + ".bin", + ".json" + ], + "subMetas": {}, + "userData": { + "gltfIndex": 9 + } + }, + "baeab": { + "importer": "gltf-embeded-image", + "uuid": "0ab3142a-6968-4073-95af-026bc3b23623@baeab", + "displayName": "", + "id": "baeab", + "name": "seafloor.jpg.image", + "ver": "1.0.3", + "imported": true, + "files": [ + ".jpg", + ".json" + ], + "subMetas": {}, + "userData": { + "gltfIndex": 0 + } + }, + "eeccb": { + "importer": "gltf-embeded-image", + "uuid": "0ab3142a-6968-4073-95af-026bc3b23623@eeccb", + "displayName": "", + "id": "eeccb", + "name": "stone.jpg.image", + "userData": { + "gltfIndex": 1 + }, + "ver": "1.0.3", + "imported": true, + "files": [ + ".jpg", + ".json" + ], + "subMetas": {} + }, + "3b6f8": { + "importer": "gltf-embeded-image", + "uuid": "0ab3142a-6968-4073-95af-026bc3b23623@3b6f8", + "displayName": "", + "id": "3b6f8", + "name": "tree.png.image", + "userData": { + "gltfIndex": 2 + }, + "ver": "1.0.3", + "imported": true, + "files": [ + ".png", + ".json" + ], + "subMetas": {} + }, + "2df3a": { + "importer": "texture", + "uuid": "0ab3142a-6968-4073-95af-026bc3b23623@2df3a", + "displayName": "", + "id": "2df3a", + "name": "seafloor.texture", + "userData": { + "wrapModeS": "repeat", + "wrapModeT": "repeat", + "minfilter": "linear", + "magfilter": "linear", + "mipfilter": "none", + "premultiplyAlpha": false, + "anisotropy": 0, + "isUuid": true, + "imageUuidOrDatabaseUri": "0ab3142a-6968-4073-95af-026bc3b23623@baeab" + }, + "ver": "1.0.21", + "imported": true, + "files": [ + ".json" + ], + "subMetas": {} + }, + "91a84": { + "importer": "texture", + "uuid": "0ab3142a-6968-4073-95af-026bc3b23623@91a84", + "displayName": "", + "id": "91a84", + "name": "stone.texture", + "userData": { + "wrapModeS": "repeat", + "wrapModeT": "repeat", + "minfilter": "linear", + "magfilter": "linear", + "mipfilter": "none", + "premultiplyAlpha": false, + "anisotropy": 0, + "isUuid": true, + "imageUuidOrDatabaseUri": "0ab3142a-6968-4073-95af-026bc3b23623@eeccb" + }, + "ver": "1.0.21", + "imported": true, + "files": [ + ".json" + ], + "subMetas": {} + }, + "0595c": { + "importer": "texture", + "uuid": "0ab3142a-6968-4073-95af-026bc3b23623@0595c", + "displayName": "", + "id": "0595c", + "name": "tree.texture", + "userData": { + "wrapModeS": "repeat", + "wrapModeT": "repeat", + "minfilter": "linear", + "magfilter": "linear", + "mipfilter": "none", + "premultiplyAlpha": false, + "anisotropy": 0, + "isUuid": true, + "imageUuidOrDatabaseUri": "0ab3142a-6968-4073-95af-026bc3b23623@3b6f8" + }, + "ver": "1.0.21", + "imported": true, + "files": [ + ".json" + ], + "subMetas": {} + }, + "cc8e5": { + "importer": "gltf-scene", + "uuid": "0ab3142a-6968-4073-95af-026bc3b23623@cc8e5", + "displayName": "", + "id": "cc8e5", + "name": "islands.prefab", + "ver": "1.0.12", + "imported": true, + "files": [ + ".json" + ], + "subMetas": {}, + "userData": { + "gltfIndex": 0 + } + } + }, + "userData": { + "imageMetas": [ + { + "name": "seafloor.jpg", + "uri": "0ab3142a-6968-4073-95af-026bc3b23623@baeab" + }, + { + "name": "stone.jpg", + "uri": "0ab3142a-6968-4073-95af-026bc3b23623@eeccb" + }, + { + "name": "tree.png", + "uri": "0ab3142a-6968-4073-95af-026bc3b23623@3b6f8" + } + ], + "redirect": "0ab3142a-6968-4073-95af-026bc3b23623@cc8e5", + "assetFinder": { + "meshes": [ + "0ab3142a-6968-4073-95af-026bc3b23623@2b0a8", + "0ab3142a-6968-4073-95af-026bc3b23623@4a7d8", + "0ab3142a-6968-4073-95af-026bc3b23623@0e750", + "0ab3142a-6968-4073-95af-026bc3b23623@ef86b", + "0ab3142a-6968-4073-95af-026bc3b23623@426f2", + "0ab3142a-6968-4073-95af-026bc3b23623@754a2", + "0ab3142a-6968-4073-95af-026bc3b23623@71919", + "0ab3142a-6968-4073-95af-026bc3b23623@1332c", + "0ab3142a-6968-4073-95af-026bc3b23623@4d16f", + "0ab3142a-6968-4073-95af-026bc3b23623@efe84" + ], + "skeletons": [], + "textures": [ + "0ab3142a-6968-4073-95af-026bc3b23623@2df3a", + "0ab3142a-6968-4073-95af-026bc3b23623@91a84", + "0ab3142a-6968-4073-95af-026bc3b23623@0595c" + ], + "materials": [ + "70d33758-1c1e-424d-b0ab-eac7410559bf", + "a155f93b-7769-4ca4-b75f-b13e52193859", + "7bf9df40-4bc9-4e25-8cb0-9a500f949102" + ], + "scenes": [ + "0ab3142a-6968-4073-95af-026bc3b23623@cc8e5" + ] + }, + "dumpMaterials": true, + "materialDumpDir": "db://assets/material", + "legacyFbxImporter": true + } +} diff --git a/BezierPathsDemo/assets/model/helloWorld/islands.prefab b/BezierPathsDemo/assets/model/helloWorld/islands.prefab new file mode 100644 index 0000000..dad2933 --- /dev/null +++ b/BezierPathsDemo/assets/model/helloWorld/islands.prefab @@ -0,0 +1,1178 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "asyncLoadAssets": false + }, + { + "__type__": "cc.Node", + "_name": "islands", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 44 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "RootNode", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 3 + }, + { + "__id__": 7 + }, + { + "__id__": 11 + }, + { + "__id__": 15 + }, + { + "__id__": 19 + }, + { + "__id__": 23 + }, + { + "__id__": 27 + }, + { + "__id__": 31 + }, + { + "__id__": 35 + }, + { + "__id__": 39 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 43 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "plane01", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 4 + } + ], + "_prefab": { + "__id__": 6 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": -2.35098645956703e-40, + "z": 2.1031643981928e-8 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.7071067811865476, + "y": 0, + "z": 0, + "w": 0.7071067811865476 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 4.25968408584595, + "y": 4.25968408584595, + "z": 2.35247683525085 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -90.00000000000003, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.MeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 3 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "70d33758-1c1e-424d-b0ab-eac7410559bf" + } + ], + "_visFlags": 0, + "lightmapSettings": { + "__id__": 5 + }, + "_mesh": { + "__uuid__": "0ab3142a-6968-4073-95af-026bc3b23623@2b0a8" + }, + "_shadowCastingMode": 0, + "_shadowReceivingMode": 1, + "_enableMorph": true, + "_id": "", + "__prefab": { + "__id__": 45 + } + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "70dgNwYARPfbvgVcNs+gIQ" + }, + { + "__type__": "cc.Node", + "_name": "stone1", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 8 + } + ], + "_prefab": { + "__id__": 10 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": -1.68451106548309, + "y": 0.804959058761597, + "z": -2.55509376525879 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 8.146034247147303e-8, + "y": 0, + "z": 0, + "w": 0.9999999999999967 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 0.111417099833488, + "y": 0.111417099833488, + "z": 0.111417099833488 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0.000009334667642611398, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.MeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 7 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "a155f93b-7769-4ca4-b75f-b13e52193859" + } + ], + "_visFlags": 0, + "lightmapSettings": { + "__id__": 9 + }, + "_mesh": { + "__uuid__": "0ab3142a-6968-4073-95af-026bc3b23623@4a7d8" + }, + "_shadowCastingMode": 1, + "_shadowReceivingMode": 1, + "_enableMorph": true, + "_id": "", + "__prefab": { + "__id__": 46 + } + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "fd517lz3tOuqVWGd5300X6" + }, + { + "__type__": "cc.Node", + "_name": "tree1", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 12 + } + ], + "_prefab": { + "__id__": 14 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 2.69967889785767, + "y": 0.392187118530273, + "z": -3.67192149162292 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.7071067811865476, + "y": 0, + "z": 0, + "w": 0.7071067811865476 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -90.00000000000003, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.MeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 11 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "7bf9df40-4bc9-4e25-8cb0-9a500f949102" + } + ], + "_visFlags": 0, + "lightmapSettings": { + "__id__": 13 + }, + "_mesh": { + "__uuid__": "0ab3142a-6968-4073-95af-026bc3b23623@0e750" + }, + "_shadowCastingMode": 0, + "_shadowReceivingMode": 1, + "_enableMorph": true, + "_id": "", + "__prefab": { + "__id__": 47 + } + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "1evO3wfhhGVomhJPkvbiM/" + }, + { + "__type__": "cc.Node", + "_name": "tree1(__autogen 3)", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 16 + } + ], + "_prefab": { + "__id__": 18 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 4.34285020828247, + "y": 0.273025780916214, + "z": -4.5796275138855 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.7071067811865476, + "y": 0, + "z": 0, + "w": 0.7071067811865476 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -90.00000000000003, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.MeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 15 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "7bf9df40-4bc9-4e25-8cb0-9a500f949102" + } + ], + "_visFlags": 0, + "lightmapSettings": { + "__id__": 17 + }, + "_mesh": { + "__uuid__": "0ab3142a-6968-4073-95af-026bc3b23623@ef86b" + }, + "_shadowCastingMode": 1, + "_shadowReceivingMode": 1, + "_enableMorph": true, + "_id": "", + "__prefab": { + "__id__": 48 + } + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "91DpAWXZ9CFJ+Wk1gnOU27" + }, + { + "__type__": "cc.Node", + "_name": "tree1(__autogen 4)", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 20 + } + ], + "_prefab": { + "__id__": 22 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": -2.78155946731567, + "y": 0.366120487451553, + "z": -5.44366216659546 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.7071067811865476, + "y": 0, + "z": 0, + "w": 0.7071067811865476 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -90.00000000000003, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.MeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 19 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "7bf9df40-4bc9-4e25-8cb0-9a500f949102" + } + ], + "_visFlags": 0, + "lightmapSettings": { + "__id__": 21 + }, + "_mesh": { + "__uuid__": "0ab3142a-6968-4073-95af-026bc3b23623@426f2" + }, + "_shadowCastingMode": 1, + "_shadowReceivingMode": 1, + "_enableMorph": true, + "_id": "", + "__prefab": { + "__id__": 49 + } + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "03YnQPZo5Nc7TYZfZ1EVIK" + }, + { + "__type__": "cc.Node", + "_name": "tree1(__autogen 5)", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 24 + } + ], + "_prefab": { + "__id__": 26 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": -3.78196001052856, + "y": 0.328564822673798, + "z": -3.62895131111145 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.7071067811865447, + "y": -6.18172403853676e-8, + "z": -6.18172403853676e-8, + "w": 0.7071067811865447 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -89.99999999999999, + "y": -0.000010017912624975451, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.MeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 23 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "7bf9df40-4bc9-4e25-8cb0-9a500f949102" + } + ], + "_visFlags": 0, + "lightmapSettings": { + "__id__": 25 + }, + "_mesh": { + "__uuid__": "0ab3142a-6968-4073-95af-026bc3b23623@754a2" + }, + "_shadowCastingMode": 1, + "_shadowReceivingMode": 1, + "_enableMorph": true, + "_id": "", + "__prefab": { + "__id__": 50 + } + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "aehmnp6BdEt5duOREy07Ic" + }, + { + "__type__": "cc.Node", + "_name": "tree1(__autogen 6)", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 28 + } + ], + "_prefab": { + "__id__": 30 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": -6.02857780456543, + "y": 0.0573978498578072, + "z": -3.32550001144409 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.7071067811865476, + "y": 0, + "z": 0, + "w": 0.7071067811865476 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -90.00000000000003, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.MeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 27 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "7bf9df40-4bc9-4e25-8cb0-9a500f949102" + } + ], + "_visFlags": 0, + "lightmapSettings": { + "__id__": 29 + }, + "_mesh": { + "__uuid__": "0ab3142a-6968-4073-95af-026bc3b23623@71919" + }, + "_shadowCastingMode": 1, + "_shadowReceivingMode": 1, + "_enableMorph": true, + "_id": "", + "__prefab": { + "__id__": 51 + } + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "1dXVprqA1AkpKbrdcroE4U" + }, + { + "__type__": "cc.Node", + "_name": "tree1(__autogen 7)", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 32 + } + ], + "_prefab": { + "__id__": 34 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": -0.547172009944916, + "y": 0.595235526561737, + "z": -3.40697646141052 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.7071067811865476, + "y": 0, + "z": 0, + "w": 0.7071067811865476 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -90.00000000000003, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.MeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 31 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "7bf9df40-4bc9-4e25-8cb0-9a500f949102" + } + ], + "_visFlags": 0, + "lightmapSettings": { + "__id__": 33 + }, + "_mesh": { + "__uuid__": "0ab3142a-6968-4073-95af-026bc3b23623@1332c" + }, + "_shadowCastingMode": 1, + "_shadowReceivingMode": 1, + "_enableMorph": true, + "_id": "", + "__prefab": { + "__id__": 52 + } + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "c2n9MRvPxJRbv1PP2mhkZO" + }, + { + "__type__": "cc.Node", + "_name": "tree1(__autogen 8)", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 36 + } + ], + "_prefab": { + "__id__": 38 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": -6.58904409408569, + "y": 0.117208734154701, + "z": -1.02060234546661 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.7071067811865476, + "y": 0, + "z": 0, + "w": 0.7071067811865476 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -90.00000000000003, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.MeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 35 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "7bf9df40-4bc9-4e25-8cb0-9a500f949102" + } + ], + "_visFlags": 0, + "lightmapSettings": { + "__id__": 37 + }, + "_mesh": { + "__uuid__": "0ab3142a-6968-4073-95af-026bc3b23623@4d16f" + }, + "_shadowCastingMode": 1, + "_shadowReceivingMode": 1, + "_enableMorph": true, + "_id": "", + "__prefab": { + "__id__": 53 + } + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "e7VpTFkQ1Ev40vpNxYe7EG" + }, + { + "__type__": "cc.Node", + "_name": "tree1(__autogen 9)", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 40 + } + ], + "_prefab": { + "__id__": 42 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 5.92053079605103, + "y": 0.1805190294981, + "z": -2.71322011947632 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.7071067811865447, + "y": -6.18172403853676e-8, + "z": -6.18172403853676e-8, + "w": 0.7071067811865447 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -89.99999999999999, + "y": -0.000010017912624975451, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.MeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 39 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "7bf9df40-4bc9-4e25-8cb0-9a500f949102" + } + ], + "_visFlags": 0, + "lightmapSettings": { + "__id__": 41 + }, + "_mesh": { + "__uuid__": "0ab3142a-6968-4073-95af-026bc3b23623@efe84" + }, + "_shadowCastingMode": 1, + "_shadowReceivingMode": 1, + "_enableMorph": true, + "_id": "", + "__prefab": { + "__id__": 54 + } + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "a1wQefYUNInYWhsOmPzInv" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "068WXOAs1HrIDx+RBQ6XoV" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "26LvC5hbxAuJZ9Jl2SB/IV" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "51hCg8iAtNH7Y8tFmjcReC" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "a5lPGPNiRFyYOdWQjG/b0f" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "0e0TrsaGNPuqA9aTE8D4Nk" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "b2V95T98pKHKMT45BvbluE" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "a5saPwk+JMQL5Lq58uy7AY" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "daTMPC3tREPZkWvwlBJcHc" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "b0U+7Hov5N2ohB9ah1W4qG" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "c7PVqB27VLuId2A9s2UjiG" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "2aF+lIZypORYarUrk8nKFL" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "a49LqePSVFgIALN9RlzTbZ" + } +] diff --git a/BezierPathsDemo/assets/model/helloWorld/islands.prefab.meta b/BezierPathsDemo/assets/model/helloWorld/islands.prefab.meta new file mode 100644 index 0000000..f64a322 --- /dev/null +++ b/BezierPathsDemo/assets/model/helloWorld/islands.prefab.meta @@ -0,0 +1,13 @@ +{ + "ver": "1.1.27", + "importer": "prefab", + "imported": true, + "uuid": "ccc3a755-7d3d-4304-aa3b-ca4792d79d9f", + "files": [ + ".json" + ], + "subMetas": {}, + "userData": { + "syncNodeName": "islands" + } +} diff --git a/BezierPathsDemo/assets/model/helloWorld/seafloor.jpg b/BezierPathsDemo/assets/model/helloWorld/seafloor.jpg new file mode 100644 index 0000000..137b9b4 Binary files /dev/null and b/BezierPathsDemo/assets/model/helloWorld/seafloor.jpg differ diff --git a/BezierPathsDemo/assets/model/helloWorld/seafloor.jpg.meta b/BezierPathsDemo/assets/model/helloWorld/seafloor.jpg.meta new file mode 100644 index 0000000..7a47889 --- /dev/null +++ b/BezierPathsDemo/assets/model/helloWorld/seafloor.jpg.meta @@ -0,0 +1,41 @@ +{ + "ver": "1.0.21", + "importer": "image", + "imported": true, + "uuid": "4f4c4a34-2d08-4a4d-9169-834d7ce82cee", + "files": [ + ".jpg", + ".json" + ], + "subMetas": { + "6c48a": { + "importer": "texture", + "uuid": "4f4c4a34-2d08-4a4d-9169-834d7ce82cee@6c48a", + "displayName": "seafloor", + "id": "6c48a", + "name": "texture", + "ver": "1.0.21", + "imported": true, + "files": [ + ".json" + ], + "subMetas": {}, + "userData": { + "wrapModeS": "repeat", + "wrapModeT": "repeat", + "minfilter": "linear", + "magfilter": "linear", + "mipfilter": "none", + "premultiplyAlpha": false, + "anisotropy": 0, + "isUuid": true, + "imageUuidOrDatabaseUri": "4f4c4a34-2d08-4a4d-9169-834d7ce82cee" + } + } + }, + "userData": { + "type": "texture", + "redirect": "4f4c4a34-2d08-4a4d-9169-834d7ce82cee@6c48a", + "hasAlpha": false + } +} diff --git a/BezierPathsDemo/assets/model/helloWorld/shield.jpg b/BezierPathsDemo/assets/model/helloWorld/shield.jpg new file mode 100644 index 0000000..3fa717c Binary files /dev/null and b/BezierPathsDemo/assets/model/helloWorld/shield.jpg differ diff --git a/BezierPathsDemo/assets/model/helloWorld/shield.jpg.meta b/BezierPathsDemo/assets/model/helloWorld/shield.jpg.meta new file mode 100644 index 0000000..d3d4b7e --- /dev/null +++ b/BezierPathsDemo/assets/model/helloWorld/shield.jpg.meta @@ -0,0 +1,41 @@ +{ + "ver": "1.0.21", + "importer": "image", + "imported": true, + "uuid": "95e5b02a-e338-423c-bdbb-17486db1d9eb", + "files": [ + ".jpg", + ".json" + ], + "subMetas": { + "6c48a": { + "importer": "texture", + "uuid": "95e5b02a-e338-423c-bdbb-17486db1d9eb@6c48a", + "displayName": "shield", + "id": "6c48a", + "name": "texture", + "ver": "1.0.21", + "imported": true, + "files": [ + ".json" + ], + "subMetas": {}, + "userData": { + "wrapModeS": "repeat", + "wrapModeT": "repeat", + "minfilter": "linear", + "magfilter": "linear", + "mipfilter": "none", + "premultiplyAlpha": false, + "anisotropy": 0, + "isUuid": true, + "imageUuidOrDatabaseUri": "95e5b02a-e338-423c-bdbb-17486db1d9eb" + } + } + }, + "userData": { + "type": "texture", + "redirect": "95e5b02a-e338-423c-bdbb-17486db1d9eb@6c48a", + "hasAlpha": false + } +} diff --git a/BezierPathsDemo/assets/model/helloWorld/sky.png b/BezierPathsDemo/assets/model/helloWorld/sky.png new file mode 100644 index 0000000..4699ff7 Binary files /dev/null and b/BezierPathsDemo/assets/model/helloWorld/sky.png differ diff --git a/BezierPathsDemo/assets/model/helloWorld/sky.png.meta b/BezierPathsDemo/assets/model/helloWorld/sky.png.meta new file mode 100644 index 0000000..c2a3ba7 --- /dev/null +++ b/BezierPathsDemo/assets/model/helloWorld/sky.png.meta @@ -0,0 +1,41 @@ +{ + "ver": "1.0.21", + "importer": "image", + "imported": true, + "uuid": "dc4a96c7-321a-48af-81e5-1127ad3ae432", + "files": [ + ".png", + ".json" + ], + "subMetas": { + "6c48a": { + "importer": "texture", + "uuid": "dc4a96c7-321a-48af-81e5-1127ad3ae432@6c48a", + "displayName": "sky", + "id": "6c48a", + "name": "texture", + "ver": "1.0.21", + "imported": true, + "files": [ + ".json" + ], + "subMetas": {}, + "userData": { + "wrapModeS": "repeat", + "wrapModeT": "repeat", + "minfilter": "linear", + "magfilter": "linear", + "mipfilter": "none", + "premultiplyAlpha": false, + "anisotropy": 0, + "isUuid": true, + "imageUuidOrDatabaseUri": "dc4a96c7-321a-48af-81e5-1127ad3ae432" + } + } + }, + "userData": { + "type": "texture", + "redirect": "dc4a96c7-321a-48af-81e5-1127ad3ae432@6c48a", + "hasAlpha": false + } +} diff --git a/BezierPathsDemo/assets/model/helloWorld/soldier.FBX b/BezierPathsDemo/assets/model/helloWorld/soldier.FBX new file mode 100644 index 0000000..d6f52fd Binary files /dev/null and b/BezierPathsDemo/assets/model/helloWorld/soldier.FBX differ diff --git a/BezierPathsDemo/assets/model/helloWorld/soldier.FBX.meta b/BezierPathsDemo/assets/model/helloWorld/soldier.FBX.meta new file mode 100644 index 0000000..3778fd3 --- /dev/null +++ b/BezierPathsDemo/assets/model/helloWorld/soldier.FBX.meta @@ -0,0 +1,307 @@ +{ + "ver": "2.0.14", + "importer": "fbx", + "imported": true, + "uuid": "e3553cad-2f15-4293-859a-8f43c780f289", + "files": [], + "subMetas": { + "18751": { + "importer": "gltf-mesh", + "uuid": "e3553cad-2f15-4293-859a-8f43c780f289@18751", + "displayName": "", + "id": "18751", + "name": "soldier.mesh", + "ver": "1.1.0", + "imported": true, + "files": [ + ".bin", + ".json" + ], + "subMetas": {}, + "userData": { + "gltfIndex": 0 + } + }, + "30732": { + "importer": "gltf-skeleton", + "uuid": "e3553cad-2f15-4293-859a-8f43c780f289@30732", + "displayName": "", + "id": "30732", + "name": "UnnamedSkeleton-0.skeleton", + "ver": "1.0.1", + "imported": true, + "files": [ + ".json" + ], + "subMetas": {}, + "userData": { + "gltfIndex": 0, + "jointsLength": 22 + } + }, + "da6f3": { + "importer": "gltf-mesh", + "uuid": "e3553cad-2f15-4293-859a-8f43c780f289@da6f3", + "displayName": "", + "id": "da6f3", + "name": "shield.mesh", + "ver": "1.1.0", + "imported": true, + "files": [ + ".bin", + ".json" + ], + "subMetas": {}, + "userData": { + "gltfIndex": 1 + } + }, + "4b929": { + "importer": "gltf-mesh", + "uuid": "e3553cad-2f15-4293-859a-8f43c780f289@4b929", + "displayName": "", + "id": "4b929", + "name": "sword.mesh", + "ver": "1.1.0", + "imported": true, + "files": [ + ".bin", + ".json" + ], + "subMetas": {}, + "userData": { + "gltfIndex": 2 + } + }, + "39f7b": { + "importer": "gltf-mesh", + "uuid": "e3553cad-2f15-4293-859a-8f43c780f289@39f7b", + "displayName": "", + "id": "39f7b", + "name": "shield01.mesh", + "userData": { + "gltfIndex": 3 + }, + "ver": "1.1.0", + "imported": true, + "files": [ + ".bin", + ".json" + ], + "subMetas": {} + }, + "73b7f": { + "importer": "gltf-animation", + "uuid": "e3553cad-2f15-4293-859a-8f43c780f289@73b7f", + "displayName": "", + "id": "73b7f", + "name": "Take 001.animation", + "ver": "1.0.14", + "imported": true, + "files": [ + ".bin", + ".json" + ], + "subMetas": {}, + "userData": { + "events": [], + "gltfIndex": 0, + "sample": 30, + "span": { + "from": 0.03333333333333333, + "to": 1.3333333730697632 + }, + "wrapMode": 2, + "speed": 1 + } + }, + "f1394": { + "importer": "gltf-skeleton", + "uuid": "e3553cad-2f15-4293-859a-8f43c780f289@f1394", + "displayName": "", + "id": "f1394", + "name": "UnnamedSkeleton-1.skeleton", + "ver": "1.0.1", + "imported": true, + "files": [ + ".json" + ], + "subMetas": {}, + "userData": { + "gltfIndex": 1, + "jointsLength": 1 + } + }, + "75ee4": { + "importer": "gltf-skeleton", + "uuid": "e3553cad-2f15-4293-859a-8f43c780f289@75ee4", + "displayName": "", + "id": "75ee4", + "name": "UnnamedSkeleton-2.skeleton", + "ver": "1.0.1", + "imported": true, + "files": [ + ".json" + ], + "subMetas": {}, + "userData": { + "gltfIndex": 2, + "jointsLength": 1 + } + }, + "a72ab": { + "importer": "gltf-skeleton", + "uuid": "e3553cad-2f15-4293-859a-8f43c780f289@a72ab", + "displayName": "", + "id": "a72ab", + "name": "UnnamedSkeleton-3.skeleton", + "ver": "1.0.1", + "imported": true, + "files": [ + ".json" + ], + "subMetas": {}, + "userData": { + "gltfIndex": 3, + "jointsLength": 1 + } + }, + "e94f1": { + "importer": "gltf-embeded-image", + "uuid": "e3553cad-2f15-4293-859a-8f43c780f289@e94f1", + "displayName": "", + "id": "e94f1", + "name": "shield.jpg.image", + "userData": { + "gltfIndex": 1 + }, + "ver": "1.0.3", + "imported": true, + "files": [ + ".jpg", + ".json" + ], + "subMetas": {} + }, + "f3caa": { + "importer": "texture", + "uuid": "e3553cad-2f15-4293-859a-8f43c780f289@f3caa", + "displayName": "", + "id": "f3caa", + "name": "soldier.texture", + "userData": { + "wrapModeS": "repeat", + "wrapModeT": "repeat", + "minfilter": "linear", + "magfilter": "linear", + "mipfilter": "none", + "premultiplyAlpha": false, + "anisotropy": 0, + "isUuid": false, + "imageUuidOrDatabaseUri": "db://assets/model/helloWorld/soldier.png" + }, + "ver": "1.0.21", + "imported": true, + "files": [ + ".json" + ], + "subMetas": {} + }, + "a2be1": { + "importer": "texture", + "uuid": "e3553cad-2f15-4293-859a-8f43c780f289@a2be1", + "displayName": "", + "id": "a2be1", + "name": "shield.texture", + "userData": { + "wrapModeS": "repeat", + "wrapModeT": "repeat", + "minfilter": "linear", + "magfilter": "linear", + "mipfilter": "none", + "premultiplyAlpha": false, + "anisotropy": 0, + "isUuid": true, + "imageUuidOrDatabaseUri": "e3553cad-2f15-4293-859a-8f43c780f289@e94f1" + }, + "ver": "1.0.21", + "imported": true, + "files": [ + ".json" + ], + "subMetas": {} + }, + "d252c": { + "importer": "gltf-scene", + "uuid": "e3553cad-2f15-4293-859a-8f43c780f289@d252c", + "displayName": "", + "id": "d252c", + "name": "soldier.prefab", + "ver": "1.0.12", + "imported": true, + "files": [ + ".json" + ], + "subMetas": {}, + "userData": { + "gltfIndex": 0 + } + } + }, + "userData": { + "imageMetas": [ + { + "name": "soldier", + "uri": "db://assets/model/helloWorld/soldier.png" + }, + { + "name": "shield.jpg", + "uri": "e3553cad-2f15-4293-859a-8f43c780f289@e94f1" + } + ], + "redirect": "e3553cad-2f15-4293-859a-8f43c780f289@d252c", + "assetFinder": { + "meshes": [ + "e3553cad-2f15-4293-859a-8f43c780f289@18751", + "e3553cad-2f15-4293-859a-8f43c780f289@da6f3", + "e3553cad-2f15-4293-859a-8f43c780f289@4b929", + "e3553cad-2f15-4293-859a-8f43c780f289@39f7b" + ], + "skeletons": [ + "e3553cad-2f15-4293-859a-8f43c780f289@30732", + "e3553cad-2f15-4293-859a-8f43c780f289@f1394", + "e3553cad-2f15-4293-859a-8f43c780f289@75ee4", + "e3553cad-2f15-4293-859a-8f43c780f289@a72ab" + ], + "textures": [ + "e3553cad-2f15-4293-859a-8f43c780f289@f3caa", + "e3553cad-2f15-4293-859a-8f43c780f289@a2be1" + ], + "materials": [ + "8a58ddec-f437-40b9-8ec0-1fc87de97fb5", + "8e047178-f61c-4322-a2f6-d1adb28b6ae2" + ], + "scenes": [ + "e3553cad-2f15-4293-859a-8f43c780f289@d252c" + ] + }, + "dumpMaterials": true, + "materialDumpDir": "db://assets/material", + "animationImportSettings": [ + { + "name": "Take 001", + "duration": 1.3333333730697632, + "fps": 30, + "splits": [ + { + "name": "Take 001", + "from": 0.03333333333333333, + "to": 1.3333333730697632, + "wrapMode": 2 + } + ] + } + ], + "legacyFbxImporter": true + } +} diff --git a/BezierPathsDemo/assets/model/helloWorld/soldier.png b/BezierPathsDemo/assets/model/helloWorld/soldier.png new file mode 100644 index 0000000..00ce191 Binary files /dev/null and b/BezierPathsDemo/assets/model/helloWorld/soldier.png differ diff --git a/BezierPathsDemo/assets/model/helloWorld/soldier.png.meta b/BezierPathsDemo/assets/model/helloWorld/soldier.png.meta new file mode 100644 index 0000000..4d1f8de --- /dev/null +++ b/BezierPathsDemo/assets/model/helloWorld/soldier.png.meta @@ -0,0 +1,41 @@ +{ + "ver": "1.0.21", + "importer": "image", + "imported": true, + "uuid": "6f891a7b-5a08-48e6-9841-ddb364ac86b1", + "files": [ + ".png", + ".json" + ], + "subMetas": { + "6c48a": { + "importer": "texture", + "uuid": "6f891a7b-5a08-48e6-9841-ddb364ac86b1@6c48a", + "displayName": "soldier", + "id": "6c48a", + "name": "texture", + "ver": "1.0.21", + "imported": true, + "files": [ + ".json" + ], + "subMetas": {}, + "userData": { + "wrapModeS": "repeat", + "wrapModeT": "repeat", + "minfilter": "linear", + "magfilter": "linear", + "mipfilter": "none", + "premultiplyAlpha": false, + "anisotropy": 0, + "isUuid": true, + "imageUuidOrDatabaseUri": "6f891a7b-5a08-48e6-9841-ddb364ac86b1" + } + } + }, + "userData": { + "type": "texture", + "redirect": "6f891a7b-5a08-48e6-9841-ddb364ac86b1@6c48a", + "hasAlpha": true + } +} diff --git a/BezierPathsDemo/assets/model/helloWorld/soldier.prefab b/BezierPathsDemo/assets/model/helloWorld/soldier.prefab new file mode 100644 index 0000000..fbf5309 --- /dev/null +++ b/BezierPathsDemo/assets/model/helloWorld/soldier.prefab @@ -0,0 +1,2132 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "asyncLoadAssets": false + }, + { + "__type__": "cc.Node", + "_name": "soldier", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + } + ], + "_active": true, + "_components": [ + { + "__id__": 76 + } + ], + "_prefab": { + "__id__": 77 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0.956, + "z": 1.402 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "RootNode", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 3 + }, + { + "__id__": 7 + }, + { + "__id__": 63 + }, + { + "__id__": 67 + }, + { + "__id__": 71 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 75 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "soldier", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 4 + } + ], + "_prefab": { + "__id__": 6 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.9999999999999953, + "y": 0, + "z": 0, + "w": -9.735359185469814e-8 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 87.7489852905273, + "y": 87.7489852905273, + "z": 87.7489852905273 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -179.99998884410013, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.SkinnedMeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 3 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "8a58ddec-f437-40b9-8ec0-1fc87de97fb5" + } + ], + "_visFlags": 0, + "lightmapSettings": { + "__id__": 5 + }, + "_mesh": { + "__uuid__": "e3553cad-2f15-4293-859a-8f43c780f289@18751" + }, + "_shadowCastingMode": 1, + "_shadowReceivingMode": 1, + "_enableMorph": true, + "_skeleton": { + "__uuid__": "e3553cad-2f15-4293-859a-8f43c780f289@30732" + }, + "_skinningRoot": { + "__id__": 1 + }, + "_id": "", + "__prefab": { + "__id__": 78 + } + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "824q3ldSpHoYl9xi6zWeg4" + }, + { + "__type__": "cc.Node", + "_name": "Bip001", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [ + { + "__id__": 8 + }, + { + "__id__": 10 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 62 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0.738336980342865, + "z": -3.74271143591121e-12 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.5000003576277411, + "y": -0.4999996423720031, + "z": -0.4999996423720031, + "w": 0.5000003576277411 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -90, + "y": -89.99991803772988, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 Footsteps", + "_objFlags": 0, + "_parent": { + "__id__": 7 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 9 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": -5.16987871290063e-28, + "y": 0, + "z": -0.734457075595856 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -6.921034890422563e-34, + "y": 6.921044533149828e-34, + "z": 0.7071063043492202, + "w": 0.7071072580235535 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": -1.1216009582263186e-31, + "z": 90 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "24sP2WouNOyq9Pp+iqRgiX" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 Pelvis", + "_objFlags": 0, + "_parent": { + "__id__": 7 + }, + "_children": [ + { + "__id__": 11 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 61 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.4999999925491744, + "y": -0.4999999925491744, + "z": -0.4999993070957696, + "w": 0.5000007078049007 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -89.9999197452773, + "y": -89.9999197452773, + "z": -0.0000017074910412130916 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 Spine", + "_objFlags": 0, + "_parent": { + "__id__": 10 + }, + "_children": [ + { + "__id__": 12 + }, + { + "__id__": 22 + }, + { + "__id__": 32 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 60 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0765029862523079, + "y": -0.000119566058856435, + "z": 1.06260117149759e-7 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.000002080475910607327, + "y": -6.936759723456761e-7, + "z": 0.0003981589901667568, + "w": 0.9999999207323014 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -0.00023837338537102568, + "y": -0.00007939450691674313, + "z": 0.045625660794268635 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 L Thigh", + "_objFlags": 0, + "_parent": { + "__id__": 11 + }, + "_children": [ + { + "__id__": 13 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 21 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": -0.0765029117465019, + "y": 0.000180334449396469, + "z": 0.0665242150425911 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.015412850192755845, + "y": 0.9969698713847834, + "z": 0.002043751751963479, + "w": -0.07621904406852757 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -0.098918034361683, + "y": -171.25793904676914, + "z": -1.7789668366715101 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 L Calf", + "_objFlags": 0, + "_parent": { + "__id__": 12 + }, + "_children": [ + { + "__id__": 14 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 20 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.368020862340927, + "y": -2.38418573772492e-9, + "z": 1.90734859017994e-8 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -3.77253945323161e-21, + "y": -4.658679694134547e-18, + "z": -0.0008097870399876981, + "w": 0.999999672122421 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -8.646032309262241e-19, + "y": -5.338462443351186e-16, + "z": -0.09279476953314847 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 L Foot", + "_objFlags": 0, + "_parent": { + "__id__": 13 + }, + "_children": [ + { + "__id__": 15 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 19 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.29802131652832, + "y": -2.38418573772492e-9, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.0020737143220202685, + "y": -0.07621822672483194, + "z": 0.016616994877612996, + "w": 0.9969505289155877 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0.3822464844159605, + "y": -8.749946017824339, + "z": 1.8805865416881686 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 L Toe0", + "_objFlags": 0, + "_parent": { + "__id__": 14 + }, + "_children": [ + { + "__id__": 16 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 18 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0765028968453407, + "y": 0.0984558463096619, + "z": 1.90734859017994e-8 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -1.5454308319985125e-8, + "y": -1.5454308319985125e-8, + "z": 0.7071067811865472, + "w": 0.7071067811865472 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": -0.0000025044778683729224, + "z": 90 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 L Toe0Nub", + "_objFlags": 0, + "_parent": { + "__id__": 15 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 17 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.00997863244265318, + "y": -2.98023217215615e-10, + "z": 3.55271359939116e-17 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 9.55341250274695e-16, + "y": -2.4399608215727e-23, + "z": 1, + "w": 1.83758927467374e-15 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": -1, + "y": -1, + "z": -1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 180, + "y": -179.9999999999999, + "z": 2.1057221983462293e-13 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "b7ARhVJWFJP4yiboWbM1Xs" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "b7IX4wc+BII5SOxaDKm4bu" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "71/rP0sWxM1bfHuNwls2lv" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "71+6ovA8dDUowhlyNGBIbM" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "4aENadJ59Io4SS6BMn9Aw4" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 R Thigh", + "_objFlags": 0, + "_parent": { + "__id__": 11 + }, + "_children": [ + { + "__id__": 23 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 31 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": -0.0765029117465019, + "y": 0.000180703471414745, + "z": -0.0665242150425911 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.0154126518850906, + "y": 0.9969698755273314, + "z": -0.0020409899233692465, + "w": 0.07621910398987286 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0.09860398393799301, + "y": 171.25792731952373, + "z": -1.7789200579558455 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 R Calf", + "_objFlags": 0, + "_parent": { + "__id__": 22 + }, + "_children": [ + { + "__id__": 24 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 30 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.36802089214325, + "y": 0, + "z": -3.55271359939116e-17 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 2.226103102352033e-19, + "y": 7.125063520427799e-18, + "z": -0.0008097898921612967, + "w": 0.9999996721201113 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 2.6170459347986135e-17, + "y": 8.164935972515574e-16, + "z": -0.09279509636827488 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 R Foot", + "_objFlags": 0, + "_parent": { + "__id__": 23 + }, + "_children": [ + { + "__id__": 25 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 29 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.29802131652832, + "y": 0, + "z": -3.81469718035987e-8 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.002073778117879438, + "y": 0.07621821928385913, + "z": 0.016617013506159614, + "w": 0.9969505290412618 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -0.38225392566993516, + "y": 8.749945293799216, + "z": 1.8805881155171484 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 R Toe0", + "_objFlags": 0, + "_parent": { + "__id__": 24 + }, + "_children": [ + { + "__id__": 26 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 28 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0765028968453407, + "y": 0.0984558537602425, + "z": 1.90734859017994e-8 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -1.5454308319985125e-8, + "y": -1.5454308319985125e-8, + "z": 0.7071067811865472, + "w": 0.7071067811865472 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": -0.0000025044778683729224, + "z": 90 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 R Toe0Nub", + "_objFlags": 0, + "_parent": { + "__id__": 25 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 27 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.00997863244265318, + "y": -2.98023217215615e-10, + "z": 7.10542719878232e-17 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -2.35364776340013e-23, + "y": 9.55341356153813e-16, + "z": -1.77635726291672e-15, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -2.6970814715996306e-21, + "y": 1.0947405540383584e-13, + "z": -2.0355554814507762e-13 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "77BI3YwgNJqKMpf0rJhZ9s" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "26R5ll6SNGP5ArlFhrFOzH" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "cdWn1utjJOUaNdTLXxb/CR" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "8a4oYAyD9MkZi9aL5G15gW" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "baRkxlpMJMup2UzoK3llZt" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 Spine1", + "_objFlags": 0, + "_parent": { + "__id__": 11 + }, + "_children": [ + { + "__id__": 33 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 59 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.150201484560966, + "y": -0.000119601711048745, + "z": -3.31727090241429e-10 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -3.01176726787145e-14, + "y": -1.39586728368323e-23, + "z": -1.0842021724855e-19, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -3.451231066493619e-12, + "y": -1.599546082682973e-21, + "z": -1.2424041724466812e-17 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 Neck", + "_objFlags": 0, + "_parent": { + "__id__": 32 + }, + "_children": [ + { + "__id__": 34 + }, + { + "__id__": 44 + }, + { + "__id__": 54 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 58 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.15020164847374, + "y": -0.0000435724105045665, + "z": -1.20852522433879e-10 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -3.01176726787145e-14, + "y": -9.0989867380833e-23, + "z": -2.74040313253867e-36, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -3.451231066493619e-12, + "y": -1.0426670758753618e-20, + "z": -1.0276926252606202e-41 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 L Clavicle", + "_objFlags": 0, + "_parent": { + "__id__": 33 + }, + "_children": [ + { + "__id__": 35 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 43 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0.0000435078145528678, + "z": 0.0232834853231907 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.6087613827170933, + "y": -0.0002434881366867595, + "z": 0.7933532758994495, + "w": 0.0003150325566206266 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 179.9558877717535, + "y": -104.99999523006848, + "z": 0.01165464185401893 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 L UpperArm", + "_objFlags": 0, + "_parent": { + "__id__": 34 + }, + "_children": [ + { + "__id__": 36 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 42 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.272405058145523, + "y": 4.54747340722069e-15, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.004462069723208538, + "y": 0.4381802273458216, + "z": -0.0019434620153348766, + "w": 0.8988739629404916 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0.5572016837940187, + "y": 51.97620557313351, + "z": 0.02386521946895269 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 L Forearm", + "_objFlags": 0, + "_parent": { + "__id__": 35 + }, + "_children": [ + { + "__id__": 37 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 41 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.263291478157043, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -2.7197715504795845e-20, + "y": -3.0893820368327117e-17, + "z": -0.0008803606294924629, + "w": 0.9999996124825059 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -6.233264281423144e-18, + "y": -3.5401778996822195e-15, + "z": -0.10088191006996569 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 L Hand", + "_objFlags": 0, + "_parent": { + "__id__": 36 + }, + "_children": [ + { + "__id__": 38 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 40 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.199572831392288, + "y": -5.9604643443123e-10, + "z": 1.42108543975646e-16 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.7068252124052271, + "y": 1.0458620867947887e-8, + "z": 1.0614867442646885e-8, + "w": 0.7073882378922519 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -89.95437890588059, + "y": 0.0000017075473071153707, + "z": 1.3340228971442967e-8 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "sword01", + "_objFlags": 0, + "_parent": { + "__id__": 37 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 39 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0919111594557762, + "y": 0.0340489186346531, + "z": -0.14926840364933 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.6409670678902519, + "y": -0.3070256396863465, + "z": -0.5278458569202463, + "w": -0.4650540030872693 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -112.37885078724646, + "y": 75.2002383569922, + "z": 5.587571211625747 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "98Mxm4C+NAIp1/ms1CXDWg" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "7cWlWOkFtKX6ILXuZfhYqO" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "503RTkgyFOwZRj7QxbXFGT" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "66qUHYCHZNMoAvIMM8jTZn" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "c67UVUfoFCNLAcx8dX7SW1" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 R Clavicle", + "_objFlags": 0, + "_parent": { + "__id__": 33 + }, + "_children": [ + { + "__id__": 45 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 53 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0.0000436370064562652, + "z": -0.0232834853231907 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.6087613827171046, + "y": 0.00024128768333211222, + "z": 0.793353275899464, + "w": 0.0003167210153793466 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -179.95597003338875, + "y": 104.99999512047448, + "z": 0.011961643569376679 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 R UpperArm", + "_objFlags": 0, + "_parent": { + "__id__": 44 + }, + "_children": [ + { + "__id__": 46 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 52 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.272405058145523, + "y": 6.82120985672115e-14, + "z": -1.42108543975646e-16 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.030114175418424236, + "y": -0.43755956999841955, + "z": 0.05059855375302801, + "w": 0.897259463867486 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -0.5631334715243025, + "y": -51.96038786477057, + "z": 6.727854372934277 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 R Forearm", + "_objFlags": 0, + "_parent": { + "__id__": 45 + }, + "_children": [ + { + "__id__": 47 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 51 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.263291418552399, + "y": 0, + "z": -7.62939436071974e-8 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -8.302567498559346e-18, + "y": -5.588016764292516e-17, + "z": -0.13176086831298384, + "w": 0.9912815309393233 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -1.8510999406615195e-15, + "y": -6.705762043264369e-15, + "z": -15.14271605062808 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 R Hand", + "_objFlags": 0, + "_parent": { + "__id__": 46 + }, + "_children": [ + { + "__id__": 48 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 50 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.199572905898094, + "y": 8.88178399847791e-18, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.7068252124052272, + "y": -1.9327187937127104e-17, + "z": 1.9311804031753923e-17, + "w": 0.707388237892252 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 89.95437890588059, + "y": -3.1308585900006548e-15, + "z": -7.956237644289779e-23 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "shield01", + "_objFlags": 0, + "_parent": { + "__id__": 47 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 49 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.124533005058765, + "y": -0.00692871073260903, + "z": 0.0576667860150337 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.5417342069004817, + "y": -0.1379658103002438, + "z": 0.11668003843623054, + "w": 0.8208990515846776 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 67.2841187503732, + "y": -20.685866498064005, + "z": 2.411917394086867 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "4f4kzbhYBIMIVjz0nZTcvw" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "19JEI2tAtAo5mcAZ7XSRWH" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "5eAc4VAlRExZ6nABKN5Ihq" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "a72KzY4dJDrb/Ifgjl7CSF" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "9fRB6KFOpAz6pb5W8NAqZg" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 Head", + "_objFlags": 0, + "_parent": { + "__id__": 33 + }, + "_children": [ + { + "__id__": 55 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 57 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0547203049063683, + "y": -1.38777874976217e-19, + "z": 2.71050537062924e-22 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -7.265599787883251e-14, + "y": 1.1042733174299354e-9, + "z": -0.0003988305609355657, + "w": 0.9999999204670887 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 4.214242912539149e-11, + "y": 1.2654042790710837e-7, + "z": -0.04570261697650697 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 HeadNub", + "_objFlags": 0, + "_parent": { + "__id__": 54 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 56 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.475234657526016, + "y": -1.45519149031062e-13, + "z": 2.99510855318999e-20 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -4.09752188234268e-20, + "y": 3.5879314498657e-21, + "z": 1.47015827086174e-40, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -4.6954142064147255e-18, + "y": 4.1114665851911787e-19, + "z": -5.14740158672216e-44 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "ebvw49UjBMKoIvQOBhsyUF" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "4ckJuubwNG3KpsMgkuxo12" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "de+U9IqPVD+qUUY0y7H/86" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "78+5xpqyNL2aHMIBr4YHvg" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "deedfocu1E0amfQjzHnnD8" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "9brOPlFAxPnLhkrpP6KbLQ" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "15XJ/3651AFKLyr6XRj3d7" + }, + { + "__type__": "cc.Node", + "_name": "shield", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 64 + } + ], + "_prefab": { + "__id__": 66 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.9999999999999878, + "y": 0, + "z": 0, + "w": -1.569582366300871e-7 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 87.7489852905273, + "y": 87.7489852905273, + "z": 87.7489852905273 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -179.99998201391097, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.SkinnedMeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 63 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "8a58ddec-f437-40b9-8ec0-1fc87de97fb5" + } + ], + "_visFlags": 0, + "lightmapSettings": { + "__id__": 65 + }, + "_mesh": { + "__uuid__": "e3553cad-2f15-4293-859a-8f43c780f289@da6f3" + }, + "_shadowCastingMode": 0, + "_shadowReceivingMode": 1, + "_enableMorph": true, + "_skeleton": { + "__uuid__": "e3553cad-2f15-4293-859a-8f43c780f289@f1394" + }, + "_skinningRoot": { + "__id__": 1 + }, + "_id": "", + "__prefab": { + "__id__": 79 + } + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "2fgzyRcBxNmZKzBdJpnT0Q" + }, + { + "__type__": "cc.Node", + "_name": "sword", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 68 + } + ], + "_prefab": { + "__id__": 70 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.9999999999999878, + "y": 0, + "z": 0, + "w": -1.569582366300871e-7 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 87.7489852905273, + "y": 87.7489852905273, + "z": 87.7489852905273 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -179.99998201391097, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.SkinnedMeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 67 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "8a58ddec-f437-40b9-8ec0-1fc87de97fb5" + } + ], + "_visFlags": 0, + "lightmapSettings": { + "__id__": 69 + }, + "_mesh": { + "__uuid__": "e3553cad-2f15-4293-859a-8f43c780f289@4b929" + }, + "_shadowCastingMode": 0, + "_shadowReceivingMode": 1, + "_enableMorph": true, + "_skeleton": { + "__uuid__": "e3553cad-2f15-4293-859a-8f43c780f289@75ee4" + }, + "_skinningRoot": { + "__id__": 1 + }, + "_id": "", + "__prefab": { + "__id__": 80 + } + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "d0xEUY/HZBVZJ0EMEz3doQ" + }, + { + "__type__": "cc.Node", + "_name": "shield01", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 72 + } + ], + "_prefab": { + "__id__": 74 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": -0.00499999988824129, + "y": 0, + "z": 0.00499999988824129 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.9999999999999878, + "y": 0, + "z": 0, + "w": -1.569582366300871e-7 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 87.7489852905273, + "y": 87.7489852905273, + "z": 87.7489852905273 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -179.99998201391097, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.SkinnedMeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 71 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "8e047178-f61c-4322-a2f6-d1adb28b6ae2" + } + ], + "_visFlags": 0, + "lightmapSettings": { + "__id__": 73 + }, + "_mesh": { + "__uuid__": "e3553cad-2f15-4293-859a-8f43c780f289@39f7b" + }, + "_shadowCastingMode": 0, + "_shadowReceivingMode": 1, + "_enableMorph": true, + "_skeleton": { + "__uuid__": "e3553cad-2f15-4293-859a-8f43c780f289@a72ab" + }, + "_skinningRoot": { + "__id__": 1 + }, + "_id": "", + "__prefab": { + "__id__": 81 + } + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "464KPea2NOibwROP5moUvA" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "a5uiqiY3JH2IVaNOBBe7fQ" + }, + { + "__type__": "cc.SkeletalAnimation", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "playOnLoad": true, + "_clips": [ + { + "__uuid__": "e3553cad-2f15-4293-859a-8f43c780f289@73b7f" + } + ], + "_defaultClip": { + "__uuid__": "e3553cad-2f15-4293-859a-8f43c780f289@73b7f" + }, + "_useBakedAnimation": true, + "_sockets": [], + "_id": "", + "__prefab": { + "__id__": 82 + } + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "6dMvPN2t1B66O9Zc3HG8dr" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "c03WV1aUFF3JS1Hk5O1YEO" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "5auuAdA+hPK4gDJgo5P8pp" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "ac7EcndpZAX7PoGP3lLRVN" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "42qo1iuetEs5z+QMA5Syeb" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "c0fPRx3VFAj6Wp6rajxsJP" + } +] diff --git a/BezierPathsDemo/assets/model/helloWorld/soldier.prefab.meta b/BezierPathsDemo/assets/model/helloWorld/soldier.prefab.meta new file mode 100644 index 0000000..4242fd6 --- /dev/null +++ b/BezierPathsDemo/assets/model/helloWorld/soldier.prefab.meta @@ -0,0 +1,13 @@ +{ + "ver": "1.1.27", + "importer": "prefab", + "imported": true, + "uuid": "cfc53c4e-7956-482b-aebc-3fb1dcd36eef", + "files": [ + ".json" + ], + "subMetas": {}, + "userData": { + "syncNodeName": "soldier" + } +} diff --git a/BezierPathsDemo/assets/model/helloWorld/stone.jpg b/BezierPathsDemo/assets/model/helloWorld/stone.jpg new file mode 100644 index 0000000..61dd429 Binary files /dev/null and b/BezierPathsDemo/assets/model/helloWorld/stone.jpg differ diff --git a/BezierPathsDemo/assets/model/helloWorld/stone.jpg.meta b/BezierPathsDemo/assets/model/helloWorld/stone.jpg.meta new file mode 100644 index 0000000..ac9c294 --- /dev/null +++ b/BezierPathsDemo/assets/model/helloWorld/stone.jpg.meta @@ -0,0 +1,41 @@ +{ + "ver": "1.0.21", + "importer": "image", + "imported": true, + "uuid": "0718d996-39bf-4ab4-bb63-496666fef467", + "files": [ + ".jpg", + ".json" + ], + "subMetas": { + "6c48a": { + "importer": "texture", + "uuid": "0718d996-39bf-4ab4-bb63-496666fef467@6c48a", + "displayName": "stone", + "id": "6c48a", + "name": "texture", + "ver": "1.0.21", + "imported": true, + "files": [ + ".json" + ], + "subMetas": {}, + "userData": { + "wrapModeS": "repeat", + "wrapModeT": "repeat", + "minfilter": "linear", + "magfilter": "linear", + "mipfilter": "none", + "premultiplyAlpha": false, + "anisotropy": 0, + "isUuid": true, + "imageUuidOrDatabaseUri": "0718d996-39bf-4ab4-bb63-496666fef467" + } + } + }, + "userData": { + "type": "texture", + "redirect": "0718d996-39bf-4ab4-bb63-496666fef467@6c48a", + "hasAlpha": false + } +} diff --git a/BezierPathsDemo/assets/model/helloWorld/tree.png b/BezierPathsDemo/assets/model/helloWorld/tree.png new file mode 100644 index 0000000..3692d92 Binary files /dev/null and b/BezierPathsDemo/assets/model/helloWorld/tree.png differ diff --git a/BezierPathsDemo/assets/model/helloWorld/tree.png.meta b/BezierPathsDemo/assets/model/helloWorld/tree.png.meta new file mode 100644 index 0000000..336e808 --- /dev/null +++ b/BezierPathsDemo/assets/model/helloWorld/tree.png.meta @@ -0,0 +1,41 @@ +{ + "ver": "1.0.21", + "importer": "image", + "imported": true, + "uuid": "c5083e75-ad2e-4ea9-8b33-dee748995b00", + "files": [ + ".png", + ".json" + ], + "subMetas": { + "6c48a": { + "importer": "texture", + "uuid": "c5083e75-ad2e-4ea9-8b33-dee748995b00@6c48a", + "displayName": "tree", + "id": "6c48a", + "name": "texture", + "ver": "1.0.21", + "imported": true, + "files": [ + ".json" + ], + "subMetas": {}, + "userData": { + "wrapModeS": "repeat", + "wrapModeT": "repeat", + "minfilter": "linear", + "magfilter": "linear", + "mipfilter": "none", + "premultiplyAlpha": false, + "anisotropy": 0, + "isUuid": true, + "imageUuidOrDatabaseUri": "c5083e75-ad2e-4ea9-8b33-dee748995b00" + } + } + }, + "userData": { + "type": "texture", + "redirect": "c5083e75-ad2e-4ea9-8b33-dee748995b00@6c48a", + "hasAlpha": false + } +} diff --git a/BezierPathsDemo/assets/scene.meta b/BezierPathsDemo/assets/scene.meta new file mode 100644 index 0000000..822e98f --- /dev/null +++ b/BezierPathsDemo/assets/scene.meta @@ -0,0 +1,12 @@ +{ + "ver": "1.1.0", + "importer": "directory", + "imported": true, + "uuid": "b0a4abb1-db32-49c3-9e09-a45b922a2094", + "files": [], + "subMetas": {}, + "userData": { + "compressionType": {}, + "isRemoteBundle": {} + } +} diff --git a/BezierPathsDemo/assets/scene/Bezier.scene b/BezierPathsDemo/assets/scene/Bezier.scene new file mode 100644 index 0000000..3c66bc3 --- /dev/null +++ b/BezierPathsDemo/assets/scene/Bezier.scene @@ -0,0 +1,692 @@ +[ + { + "__type__": "cc.SceneAsset", + "_name": "", + "_objFlags": 0, + "_native": "", + "scene": { + "__id__": 1 + }, + "asyncLoadAssets": false + }, + { + "__type__": "cc.Scene", + "_name": "", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + }, + { + "__id__": 5 + }, + { + "__id__": 7 + } + ], + "_active": true, + "_components": [], + "_prefab": null, + "autoReleaseAssets": false, + "_globals": { + "__id__": 24 + }, + "_id": "f2d7ea36-b11b-44a5-8f58-31b75049daf6" + }, + { + "__type__": "cc.Node", + "_name": "Main Light", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 3 + } + ], + "_prefab": null, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.24999999999999997, + "y": -0.24999999999999997, + "z": -0.06698729810778066, + "w": 0.9330127018922194 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -30, + "y": -30, + "z": 0 + }, + "_id": "c0y6F5f+pAvI805TdmxIjx" + }, + { + "__type__": "cc.DirectionalLight", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "__prefab": null, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_useColorTemperature": false, + "_colorTemperature": 6550, + "_staticSettings": { + "__id__": 4 + }, + "_illuminance": 65000, + "_id": "597uMYCbhEtJQc0ffJlcgA" + }, + { + "__type__": "cc.StaticLightSettings", + "_baked": false, + "_editorOnly": false, + "_bakeable": false, + "_castShadow": false + }, + { + "__type__": "cc.Node", + "_name": "Main Camera", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 6 + } + ], + "_prefab": null, + "_lpos": { + "__type__": "cc.Vec3", + "x": -10, + "y": 10, + "z": 10 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.27781593346944056, + "y": -0.36497167621709875, + "z": -0.11507512748638377, + "w": 0.8811195706053617 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -35, + "y": -45, + "z": 0 + }, + "_id": "c9DMICJLFO5IeO07EPon7U" + }, + { + "__type__": "cc.Camera", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 5 + }, + "_enabled": true, + "__prefab": null, + "_projection": 1, + "_priority": 0, + "_fov": 45, + "_fovAxis": 0, + "_orthoHeight": 10, + "_near": 1, + "_far": 1000, + "_color": { + "__type__": "cc.Color", + "r": 51, + "g": 51, + "b": 51, + "a": 255 + }, + "_depth": 1, + "_stencil": 0, + "_clearFlags": 7, + "_rect": { + "__type__": "cc.Rect", + "x": 0, + "y": 0, + "width": 1, + "height": 1 + }, + "_aperture": 19, + "_shutter": 7, + "_iso": 0, + "_screenScale": 1, + "_visibility": 1822425087, + "_targetTexture": null, + "_id": "7dWQTpwS5LrIHnc1zAPUtf" + }, + { + "__type__": "cc.Node", + "_name": "Canvas", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 8 + }, + { + "__id__": 10 + } + ], + "_active": true, + "_components": [ + { + "__id__": 17 + }, + { + "__id__": 19 + }, + { + "__id__": 21 + }, + { + "__id__": 23 + } + ], + "_prefab": null, + "_lpos": { + "__type__": "cc.Vec3", + "x": 360, + "y": 640, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 33554432, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "c6oLY91+xJnayalEdSv2oW" + }, + { + "__type__": "cc.Node", + "_name": "Camera", + "_objFlags": 0, + "_parent": { + "__id__": 7 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 9 + } + ], + "_prefab": null, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 1000 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 33554432, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "7dkfYwF9NMZo0OB/FiDGx+" + }, + { + "__type__": "cc.Camera", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 8 + }, + "_enabled": true, + "__prefab": null, + "_projection": 0, + "_priority": 1073741824, + "_fov": 45, + "_fovAxis": 0, + "_orthoHeight": 640, + "_near": 1, + "_far": 2000, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_depth": 1, + "_stencil": 0, + "_clearFlags": 6, + "_rect": { + "__type__": "cc.Rect", + "x": 0, + "y": 0, + "width": 1, + "height": 1 + }, + "_aperture": 19, + "_shutter": 7, + "_iso": 0, + "_screenScale": 1, + "_visibility": 41943040, + "_targetTexture": null, + "_id": "76KkRpK+dMFIWWD4s16j/2" + }, + { + "__type__": "cc.Node", + "_name": "Graphics", + "_objFlags": 0, + "_parent": { + "__id__": 7 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 11 + }, + { + "__id__": 13 + }, + { + "__id__": 15 + }, + { + "__id__": 16 + } + ], + "_prefab": null, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 33554432, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "f0DlcIbe9OwIYn9F4zxVs9" + }, + { + "__type__": "cc.UITransform", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 10 + }, + "_enabled": true, + "__prefab": { + "__id__": 12 + }, + "_priority": 0, + "_contentSize": { + "__type__": "cc.Size", + "width": 720, + "height": 1280 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_id": "0bJ5hyVnRKlbM8Ec1vwkOH" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "c3dMMH5KBHA7aaNq/gxfrr" + }, + { + "__type__": "cc.Graphics", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 10 + }, + "_enabled": true, + "__prefab": { + "__id__": 14 + }, + "_visFlags": 0, + "_customMaterial": null, + "_srcBlendFactor": 2, + "_dstBlendFactor": 4, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_lineWidth": 2.5, + "_strokeColor": { + "__type__": "cc.Color", + "r": 226, + "g": 42, + "b": 42, + "a": 255 + }, + "_lineJoin": 2, + "_lineCap": 0, + "_fillColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_miterLimit": 10, + "_id": "97mg/qdIdF2YVtTodqhGd6" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "b72j61fNtG9IH3vOo7HXe7" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 10 + }, + "_enabled": true, + "__prefab": null, + "_alignFlags": 45, + "_target": null, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_horizontalCenter": 0, + "_verticalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 100, + "_originalHeight": 100, + "_alignMode": 2, + "_lockFlags": 0, + "_id": "ccHSEU7wlMxZIbUskZCbua" + }, + { + "__type__": "8d86dNsntVPNLlI0KI0hg+q", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 10 + }, + "_enabled": true, + "__prefab": null, + "_id": "7dIu5De95IzZ88X1UvIMHF" + }, + { + "__type__": "cc.UITransform", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 7 + }, + "_enabled": true, + "__prefab": { + "__id__": 18 + }, + "_priority": 0, + "_contentSize": { + "__type__": "cc.Size", + "width": 720, + "height": 1280 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_id": "b6PfJ3r4JCYYekID2bV7RT" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "0dngp/9gNO34wUQjZfN/CX" + }, + { + "__type__": "cc.Canvas", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 7 + }, + "_enabled": true, + "__prefab": { + "__id__": 20 + }, + "_cameraComponent": { + "__id__": 9 + }, + "_alignCanvasWithScreen": true, + "_id": "bd5rq1mYZMjKhBy0lJFHTu" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "3f2oTdCepERZdpmIfLsrhd" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 7 + }, + "_enabled": true, + "__prefab": { + "__id__": 22 + }, + "_alignFlags": 45, + "_target": null, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_horizontalCenter": 0, + "_verticalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 0, + "_originalHeight": 0, + "_alignMode": 2, + "_lockFlags": 0, + "_id": "1bhS2RJr1Er4Q0DX0CY9HS" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "e8a+bU/8dPDbbJguUzLdoF" + }, + { + "__type__": "35bc63DayhOaYheI69j11Zr", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 7 + }, + "_enabled": true, + "__prefab": null, + "graphicsHelper": { + "__id__": 16 + }, + "_id": "1d2smm9X9CG6B/mpPWNFbP" + }, + { + "__type__": "cc.SceneGlobals", + "ambient": { + "__id__": 25 + }, + "shadows": { + "__id__": 26 + }, + "_skybox": { + "__id__": 27 + }, + "fog": { + "__id__": 28 + } + }, + { + "__type__": "cc.AmbientInfo", + "_skyColor": { + "__type__": "cc.Color", + "r": 51, + "g": 128, + "b": 204, + "a": 1 + }, + "_skyIllum": 20000, + "_groundAlbedo": { + "__type__": "cc.Color", + "r": 51, + "g": 51, + "b": 51, + "a": 255 + } + }, + { + "__type__": "cc.ShadowsInfo", + "_type": 0, + "_enabled": false, + "_normal": { + "__type__": "cc.Vec3", + "x": 0, + "y": 1, + "z": 0 + }, + "_distance": 0, + "_shadowColor": { + "__type__": "cc.Color", + "r": 76, + "g": 76, + "b": 76, + "a": 255 + }, + "_autoAdapt": true, + "_pcf": 0, + "_bias": 0.00001, + "_near": 1, + "_far": 30, + "_aspect": 1, + "_orthoSize": 5, + "_maxReceived": 4, + "_size": { + "__type__": "cc.Vec2", + "x": 512, + "y": 512 + } + }, + { + "__type__": "cc.SkyboxInfo", + "_envmap": null, + "_isRGBE": false, + "_enabled": false, + "_useIBL": false + }, + { + "__type__": "cc.FogInfo", + "_type": 0, + "_fogColor": { + "__type__": "cc.Color", + "r": 200, + "g": 200, + "b": 200, + "a": 255 + }, + "_enabled": false, + "_fogDensity": 0.3, + "_fogStart": 0.5, + "_fogEnd": 300, + "_fogAtten": 5, + "_fogTop": 1.5, + "_fogRange": 1.2 + } +] \ No newline at end of file diff --git a/BezierPathsDemo/assets/scene/Bezier.scene.meta b/BezierPathsDemo/assets/scene/Bezier.scene.meta new file mode 100644 index 0000000..1158724 --- /dev/null +++ b/BezierPathsDemo/assets/scene/Bezier.scene.meta @@ -0,0 +1,11 @@ +{ + "ver": "1.1.27", + "importer": "scene", + "imported": true, + "uuid": "f2d7ea36-b11b-44a5-8f58-31b75049daf6", + "files": [ + ".json" + ], + "subMetas": {}, + "userData": {} +} diff --git a/BezierPathsDemo/assets/scripts.meta b/BezierPathsDemo/assets/scripts.meta new file mode 100644 index 0000000..6b348f5 --- /dev/null +++ b/BezierPathsDemo/assets/scripts.meta @@ -0,0 +1,12 @@ +{ + "ver": "1.1.0", + "importer": "directory", + "imported": true, + "uuid": "5cbca12f-0036-4e32-952b-6b3da0042b50", + "files": [], + "subMetas": {}, + "userData": { + "compressionType": {}, + "isRemoteBundle": {} + } +} diff --git a/BezierPathsDemo/assets/scripts/BezierCurvesKit.ts b/BezierPathsDemo/assets/scripts/BezierCurvesKit.ts new file mode 100644 index 0000000..f512972 --- /dev/null +++ b/BezierPathsDemo/assets/scripts/BezierCurvesKit.ts @@ -0,0 +1,205 @@ +import { v2, Vec2, Vec3 } from "cc"; + +export class BezierCurvesKit { + + private static _instance: BezierCurvesKit; + public static get Instacne() { + if (this._instance == null) { + this._instance = new BezierCurvesKit(); + } + return this._instance; + } + /** + * 计算三阶曲线 三维坐标 + * @param t + * @param p0 + * @param p1 + * @param p2 + * @param p3 + */ + private calculateBezierPoint3(t: number, p0: Vec3, p1: Vec3, p2: Vec3, p3: Vec3) { + let u = 1 - t; + let tt = t * t; + let uu = u * u; + let uuu = uu * u; + let ttt = tt * t; + let point = new Vec3(); + let x = uuu * p0.x + 3 * uu * t * p1.x + 3 * u * tt * p2.x + ttt * p3.x; + let y = uuu * p0.y + 3 * uu * t * p1.y + 3 * u * tt * p2.y + ttt * p3.y; + let z = uuu * p0.z + 3 * uu * t * p1.z + 3 * u * tt * p2.z + ttt * p3.z; + Vec3.set(point, x, y, z); + return point; + } + + /** + * 计算三阶曲线 二维坐标 + * @param t + * @param p0 + * @param p1 + * @param p2 + * @param p3 + */ + private calculateBezierPoint2(t: number, p0: Vec2, p1: Vec2, p2: Vec2, p3: Vec2) { + let u = 1 - t; + let tt = t * t; + let uu = u * u; + let uuu = uu * u; + let ttt = tt * t; + let point = new Vec2(); + let x = uuu * p0.x + 3 * uu * t * p1.x + 3 * u * tt * p2.x + ttt * p3.x; + let y = uuu * p0.y + 3 * uu * t * p1.y + 3 * u * tt * p2.y + ttt * p3.y; + Vec2.set(point, x, y); + return point; + } + + public calculateBezierPoint(t: number, p0: Vec2 | Vec3, p1: Vec2 | Vec3, p2: Vec2 | Vec3, p3: Vec2 | Vec3) { + if (p0 instanceof Vec2) { + return this.calculateBezierPoint2(t, p0, p1, p2, p3); + } else { + return this.calculateBezierPoint3(t, p0, p1, p2, p3); + } + } + + // + private speedX(points: Vec3[] | Vec2[], t: number) { + let a = -3 * points[0].x * Math.pow(1 - t, 2) + 3 * points[1].x * Math.pow(1 - t, 2) - 6 * points[1].x * (1 - t) * t + 6 * points[2].x * (1 - t) * t - 3 * points[2].x * Math.pow(t, 2) + 3 * points[3].x * Math.pow(t, 2); + return a; + } + + private speedY(points: Vec3[] | Vec2[], t: number) { + let a = -3 * points[0].y * Math.pow(1 - t, 2) + 3 * points[1].y * Math.pow(1 - t, 2) - 6 * points[1].y * (1 - t) * t + 6 * points[2].y * (1 - t) * t - 3 * points[2].y * Math.pow(t, 2) + 3 * points[3].y * Math.pow(t, 2); + return a; + } + + private speedZ(points: Vec3[], t: number) { + let a = -3 * points[0].z * Math.pow(1 - t, 2) + 3 * points[1].z * Math.pow(1 - t, 2) - 6 * points[1].z * (1 - t) * t + 6 * points[2].z * (1 - t) * t - 3 * points[2].z * Math.pow(t, 2) + 3 * points[3].z * Math.pow(t, 2); + return a; + } + + private speedMerge2(points: Vec2[], t: number) { + let v_x = this.speedX(points, t); + let v_y = this.speedY(points, t); + return Math.sqrt(Math.pow(v_x, 2) + Math.pow(v_y, 2)); + } + + private speedMerge3(points: Vec3[], t: number) { + let v_x = this.speedX(points, t); + let v_y = this.speedY(points, t); + let v_z = this.speedZ(points, t); + + return Math.sqrt(Math.pow(v_x, 2) + Math.pow(v_y, 2) + Math.pow(v_z, 2)); + } + + private speedMerge(points: Vec2[] | Vec3[], t: number) { + if (points[0] instanceof Vec2) { + return this.speedMerge2(points, t); + } else { + return this.speedMerge3(points, t); + } + } + + /** + * 求 0~t 段的三阶贝塞尔曲线长度 + * t为realTime + * @param points + */ + private pathLength(points: Vec2[] | Vec3[], t: number) { + let total_step = 100000; + let step_counts = total_step; + let half_counts; + let i = 0; + let sum_1 = 0, sum_2 = 0, t_step; + + if (step_counts == 0) { + return 0; + } + if (step_counts % 2 == 0) { + step_counts++; + } + + half_counts = step_counts / 2; + t_step = t / step_counts; + + while (i < half_counts) { + sum_1 += this.speedMerge(points, (2 * i + 1) * t_step); + i++; + } + i = 1; + while (i < half_counts) { + sum_2 += this.speedMerge(points, (2 * i * t_step)); + i++; + } + + return (this.speedMerge(points, 0) + this.speedMerge(points, 1) + 2 * sum_2 + 4 * sum_1) * t_step / 3; + } + + /** + * 通过对应的弧长来取得rt + * @param points + * @param length + */ + private realTimeByLength(points: Vec2[] | Vec3[], length: number) { + let real_time = 0; + let rt_length = 0; + let delta_length = 0; + let delta_time = 0; + let low = 0, high = 1; + do { + if (delta_length > 0) { + real_time -= (real_time - low) / 2; + delta_time = real_time - low; + } else { + real_time += (high - real_time) / 2; + delta_time = high - real_time; + } + rt_length = this.pathLength(points, real_time); + delta_length = rt_length - length; + if (delta_length > 0) { + high = real_time; + } else { + low = real_time; + } + + // 0.01 的误差已经很小了,可视为此时的 rt 就是真实的 rt + // 或者 rt 的更新量足够小时也应跳出,防止梯度消失造成死循环 + } while (Math.abs(delta_length) > 0.01 && delta_time > 0.000000001) + + return real_time; + } + + /** + * 取得匀速点数组 + * @param points + * @param step + */ + public getUniformPoints(points: Vec2[] | Vec3[],step:number=100) { + let lengthTotal = this.pathLength(points, 1); + let deltaStep = lengthTotal / step; + let drawingPoints: Vec2[] | Vec3[] = []; + + for (let i = 0; i < points.length - 3; i += 3) { + let p0: Vec2 | Vec3 = points[i]; + let p1: Vec2 | Vec3 = points[i + 1]; + let p2: Vec2 | Vec3 = points[i + 2]; + let p3: Vec2 | Vec3 = points[i + 3]; + + if (i == 0) { + drawingPoints.push(p0); + } + + for (let j = 1; j <= step; j++) { + let length = deltaStep * j; + let t = this.realTimeByLength([p0, p1, p2, p3], length); + drawingPoints.push(this.calculateBezierPoint(t, p0, p1, p2, p3)); + } + } + + return drawingPoints; + } +} + +/** + * 参考文章 + * https://blog.csdn.net/iSunwish/article/details/78935257 + * https://blog.csdn.net/iSunwish/article/details/112127363 + */ \ No newline at end of file diff --git a/BezierPathsDemo/assets/scripts/BezierCurvesKit.ts.meta b/BezierPathsDemo/assets/scripts/BezierCurvesKit.ts.meta new file mode 100644 index 0000000..0687a38 --- /dev/null +++ b/BezierPathsDemo/assets/scripts/BezierCurvesKit.ts.meta @@ -0,0 +1,11 @@ +{ + "ver": "4.0.22", + "importer": "typescript", + "imported": true, + "uuid": "25e55cbe-4b98-4aa0-85f3-1f379798a490", + "files": [], + "subMetas": {}, + "userData": { + "simulateGlobals": [] + } +} diff --git a/BezierPathsDemo/assets/scripts/GraphicsHelper.ts b/BezierPathsDemo/assets/scripts/GraphicsHelper.ts new file mode 100644 index 0000000..e7326db --- /dev/null +++ b/BezierPathsDemo/assets/scripts/GraphicsHelper.ts @@ -0,0 +1,52 @@ + +import { _decorator, Component, Node, Vec2, Graphics, v2 } from 'cc'; +const { ccclass, property } = _decorator; + +@ccclass('GraphicsHelper') +export class GraphicsHelper extends Component { + + private graphics: Graphics = null!; + + onLoad() { + this.graphics = this.node.getComponent(Graphics); + console.log('graphics=', this.graphics); + } + start() { + // [3] + // this.drawPoints([v2(10, 10), v2(-10, 10), v2(10, -10), v2(-10, -10)], 5); + // this.drawFill(); + } + + drawPoints(points: Vec2[], radius: number) { + for (let i = 0; i < points.length; i++) { + let point = points[i]; + this.graphics.circle(point.x, point.y, radius); + } + } + + drawPointsLine(points: Vec2[], isClose: boolean = false) { + let length = points.length; + if (length < 2) { + console.warn('point num less than one') + return; + } + this.graphics.moveTo(points[0].x, points[0].y); + for (let i = 1; i < length; i++) { + let point = points[i]; + this.graphics.lineTo(point.x, point.y); + } + if (isClose) { + this.graphics.close(); + } + + } + + drawFill() { + this.graphics.fill(); + } + + drawStroke() { + this.graphics.stroke(); + } +} + diff --git a/BezierPathsDemo/assets/scripts/GraphicsHelper.ts.meta b/BezierPathsDemo/assets/scripts/GraphicsHelper.ts.meta new file mode 100644 index 0000000..eab31e0 --- /dev/null +++ b/BezierPathsDemo/assets/scripts/GraphicsHelper.ts.meta @@ -0,0 +1,11 @@ +{ + "ver": "4.0.22", + "importer": "typescript", + "imported": true, + "uuid": "8d86d36c-9ed5-4f34-b948-d0a234860faa", + "files": [], + "subMetas": {}, + "userData": { + "simulateGlobals": [] + } +} diff --git a/BezierPathsDemo/assets/scripts/Main.ts b/BezierPathsDemo/assets/scripts/Main.ts new file mode 100644 index 0000000..e550e0d --- /dev/null +++ b/BezierPathsDemo/assets/scripts/Main.ts @@ -0,0 +1,41 @@ + +import { _decorator, Component, Node, v2, Vec2 } from 'cc'; +import { BezierCurvesKit } from './BezierCurvesKit'; +import { GraphicsHelper } from './GraphicsHelper'; +const { ccclass, property } = _decorator; + +@ccclass('Main') +export class Main extends Component { + @property(GraphicsHelper) + graphicsHelper: GraphicsHelper = null! + + start() { + // [3] + let points = [v2(-300, -100), v2(-150, 700), v2(50, 600), v2(300, -200)]; + this.graphicsHelper.drawPoints(points, 10); + this.graphicsHelper.drawFill(); + + // let paths: Vec2[] = BezierCurves.getDrawingPoints2(points, 100); + let paths:Vec2[]=BezierCurvesKit.Instacne.getUniformPoints(points,20); + + // this.graphicsHelper.drawPointsLine(paths); + // this.graphicsHelper.drawStroke(); + this.graphicsHelper.drawPoints(paths, 3); + this.graphicsHelper.drawFill(); + } + + // update (deltaTime: number) { + // // [4] + // } +} + +/** + * [1] Class member could be defined like this. + * [2] Use `property` decorator if your want the member to be serializable. + * [3] Your initialization goes here. + * [4] Your update function goes here. + * + * Learn more about scripting: https://docs.cocos.com/creator/3.0/manual/en/scripting/ + * Learn more about CCClass: https://docs.cocos.com/creator/3.0/manual/en/scripting/ccclass.html + * Learn more about life-cycle callbacks: https://docs.cocos.com/creator/3.0/manual/en/scripting/life-cycle-callbacks.html + */ diff --git a/BezierPathsDemo/assets/scripts/Main.ts.meta b/BezierPathsDemo/assets/scripts/Main.ts.meta new file mode 100644 index 0000000..0ad5ed0 --- /dev/null +++ b/BezierPathsDemo/assets/scripts/Main.ts.meta @@ -0,0 +1,11 @@ +{ + "ver": "4.0.22", + "importer": "typescript", + "imported": true, + "uuid": "35bc6dc3-6b28-4e69-885e-23af63d7566b", + "files": [], + "subMetas": {}, + "userData": { + "simulateGlobals": [] + } +} diff --git a/BezierPathsDemo/assets/scripts/migrate-canvas.ts b/BezierPathsDemo/assets/scripts/migrate-canvas.ts new file mode 100644 index 0000000..0ced648 --- /dev/null +++ b/BezierPathsDemo/assets/scripts/migrate-canvas.ts @@ -0,0 +1,85 @@ +/** + * UI 的渲染在 v3.0 变为使用 node.layer 来判断可见性,为了保证老版本项目升级后表现一致, + * Creator 会在运行时动态分配一个未使用的 layer 给常驻节点的 UI,避免常驻节点的 UI 与场景中 + * 的其他 UI 的 layer 发生冲突,当你确定不会发生冲突时,你可以移除此脚本. + * + * UI rendering has changed in v3.0 to use node.layer to determine visibility. + * To ensure consistent performance after upgrading old projects. + * Creator will dynamically assign an unused layer to the UI node in the persist node at + * runtime to avoid conflicts between the layer of UI in the persist node and the + * layer of other UI in the scene. You can remove this script when you + * are sure there is no conflict + */ + +import { _decorator, Node, director, Director, game, BaseNode, Canvas, Camera } from 'cc'; + +const customLayerMask = 0x000fffff; +const builtinLayerMask = 0xfff00000; + +director.on(Director.EVENT_AFTER_SCENE_LAUNCH, () => { + const roots = director.getScene()?.children as BaseNode[]; + let allCanvases = director.getScene()?.getComponentsInChildren(Canvas) as Canvas[]; + if (allCanvases.length <= 1) return; + allCanvases = allCanvases.filter(x => !!x.cameraComponent); + + let allCameras = director.getScene()?.getComponentsInChildren(Camera) as Camera[]; + let usedLayer = 0; + allCameras.forEach(x => usedLayer |= (x.visibility & customLayerMask)); + + const persistCanvas: Canvas[] = []; + for (let i = 0, l = roots.length; i < l; i++) { + const root = roots[i]; + if (!game.isPersistRootNode(root)) continue; + const canvases = root.getComponentsInChildren(Canvas); + if (canvases.length === 0) continue; + persistCanvas.push(...canvases.filter(x => !!x.cameraComponent)); + } + + persistCanvas.forEach((val) => { + const isLayerCollided = allCanvases.find(x => x !== val && (x.cameraComponent!.visibility & val.cameraComponent!.visibility & customLayerMask)); + if (isLayerCollided) { + const availableLayers = ~usedLayer; + const lastAvailableLayer = availableLayers & ~(availableLayers - 1); + val.cameraComponent!.visibility = lastAvailableLayer | (val.cameraComponent!.visibility & builtinLayerMask); + setChildrenLayer(val.node, lastAvailableLayer); + usedLayer |= availableLayers; + } + }); +}); + +function setChildrenLayer (node: Node, layer: number) { + for (let i = 0, l = node.children.length; i < l; i++) { + node.children[i].layer = layer; + setChildrenLayer(node.children[i], layer); + } +} + +let setParentEngine = cc.Node.prototype.setParent; + +cc.Node.prototype.setParent = function(value, keepWorldTransform) { + setParentEngine.call(this, value, keepWorldTransform); + if (!value) return; + // find canvas + let layer = getCanvasCameraLayer(this); + if (layer) { + this.layer = layer; + setChildrenLayer(this, layer); + } +} + +function getCanvasCameraLayer (node: Node) { + let layer = null; + let canvas = node.getComponent(Canvas); + if (canvas && canvas.cameraComponent) { + if (canvas.cameraComponent.visibility & canvas.node.layer) { + layer = canvas.node.layer; + } else { + layer = canvas.cameraComponent.visibility & ~(canvas.cameraComponent.visibility - 1); + } + return layer; + } + if (node.parent) { + layer = getCanvasCameraLayer(node.parent); + } + return layer; +} \ No newline at end of file diff --git a/BezierPathsDemo/assets/scripts/migrate-canvas.ts.meta b/BezierPathsDemo/assets/scripts/migrate-canvas.ts.meta new file mode 100644 index 0000000..d1eb03b --- /dev/null +++ b/BezierPathsDemo/assets/scripts/migrate-canvas.ts.meta @@ -0,0 +1,11 @@ +{ + "ver": "4.0.22", + "importer": "typescript", + "imported": true, + "uuid": "0281b04b-007d-48fc-b494-a5f3aa2cab6b", + "files": [], + "subMetas": {}, + "userData": { + "simulateGlobals": [] + } +} diff --git a/BezierPathsDemo/assets/skybox.meta b/BezierPathsDemo/assets/skybox.meta new file mode 100644 index 0000000..46fb35c --- /dev/null +++ b/BezierPathsDemo/assets/skybox.meta @@ -0,0 +1,12 @@ +{ + "ver": "1.1.0", + "importer": "directory", + "imported": true, + "uuid": "9e344b1f-8681-4ddf-bcc6-bb014c332bb8", + "files": [], + "subMetas": {}, + "userData": { + "compressionType": {}, + "isRemoteBundle": {} + } +} diff --git a/BezierPathsDemo/assets/skybox/sunnySkyBox.jpg b/BezierPathsDemo/assets/skybox/sunnySkyBox.jpg new file mode 100644 index 0000000..633a4b7 Binary files /dev/null and b/BezierPathsDemo/assets/skybox/sunnySkyBox.jpg differ diff --git a/BezierPathsDemo/assets/skybox/sunnySkyBox.jpg.meta b/BezierPathsDemo/assets/skybox/sunnySkyBox.jpg.meta new file mode 100644 index 0000000..6743647 --- /dev/null +++ b/BezierPathsDemo/assets/skybox/sunnySkyBox.jpg.meta @@ -0,0 +1,131 @@ +{ + "ver": "1.0.21", + "importer": "image", + "imported": true, + "uuid": "5af201b5-5951-4e2c-a81f-ac4aad9132cb", + "files": [ + ".jpg", + ".json" + ], + "subMetas": { + "b47c0": { + "importer": "erp-texture-cube", + "uuid": "5af201b5-5951-4e2c-a81f-ac4aad9132cb@b47c0", + "displayName": "sunnySkyBox", + "id": "b47c0", + "name": "textureCube", + "userData": { + "wrapModeS": "repeat", + "wrapModeT": "repeat", + "minfilter": "linear", + "magfilter": "linear", + "mipfilter": "linear", + "anisotropy": 1, + "isRGBE": false, + "imageDatabaseUri": "db://assets/skybox/sunnySkyBox.jpg" + }, + "ver": "1.0.10", + "imported": true, + "files": [ + ".json" + ], + "subMetas": { + "e9a6d": { + "importer": "texture-cube-face", + "uuid": "5af201b5-5951-4e2c-a81f-ac4aad9132cb@b47c0@e9a6d", + "displayName": "", + "id": "e9a6d", + "name": "front", + "userData": {}, + "ver": "1.0.0", + "imported": true, + "files": [ + ".png", + ".json" + ], + "subMetas": {} + }, + "40c10": { + "importer": "texture-cube-face", + "uuid": "5af201b5-5951-4e2c-a81f-ac4aad9132cb@b47c0@40c10", + "displayName": "", + "id": "40c10", + "name": "back", + "userData": {}, + "ver": "1.0.0", + "imported": true, + "files": [ + ".png", + ".json" + ], + "subMetas": {} + }, + "bb97f": { + "importer": "texture-cube-face", + "uuid": "5af201b5-5951-4e2c-a81f-ac4aad9132cb@b47c0@bb97f", + "displayName": "", + "id": "bb97f", + "name": "top", + "userData": {}, + "ver": "1.0.0", + "imported": true, + "files": [ + ".png", + ".json" + ], + "subMetas": {} + }, + "7d38f": { + "importer": "texture-cube-face", + "uuid": "5af201b5-5951-4e2c-a81f-ac4aad9132cb@b47c0@7d38f", + "displayName": "", + "id": "7d38f", + "name": "bottom", + "userData": {}, + "ver": "1.0.0", + "imported": true, + "files": [ + ".png", + ".json" + ], + "subMetas": {} + }, + "74afd": { + "importer": "texture-cube-face", + "uuid": "5af201b5-5951-4e2c-a81f-ac4aad9132cb@b47c0@74afd", + "displayName": "", + "id": "74afd", + "name": "right", + "userData": {}, + "ver": "1.0.0", + "imported": true, + "files": [ + ".png", + ".json" + ], + "subMetas": {} + }, + "8fd34": { + "importer": "texture-cube-face", + "uuid": "5af201b5-5951-4e2c-a81f-ac4aad9132cb@b47c0@8fd34", + "displayName": "", + "id": "8fd34", + "name": "left", + "userData": {}, + "ver": "1.0.0", + "imported": true, + "files": [ + ".png", + ".json" + ], + "subMetas": {} + } + } + } + }, + "userData": { + "hasAlpha": false, + "type": "texture cube", + "redirect": "5af201b5-5951-4e2c-a81f-ac4aad9132cb@b47c0" + } +} diff --git a/BezierPathsDemo/package.json b/BezierPathsDemo/package.json new file mode 100644 index 0000000..a42b0b5 --- /dev/null +++ b/BezierPathsDemo/package.json @@ -0,0 +1,9 @@ +{ + "name": "BezierDemo", + "type": "3d", + "uuid": "c30b28da-749e-479b-bcb6-cecd8d7be9e3", + "version": "3.1.0", + "creator": { + "version": "3.1.0" + } +} diff --git a/BezierPathsDemo/settings/1.2.0/packages/builder.json b/BezierPathsDemo/settings/1.2.0/packages/builder.json new file mode 100644 index 0000000..ad47cd6 --- /dev/null +++ b/BezierPathsDemo/settings/1.2.0/packages/builder.json @@ -0,0 +1,3 @@ +{ + "__version__": "1.2.4" +} diff --git a/BezierPathsDemo/settings/1.2.0/packages/engine.json b/BezierPathsDemo/settings/1.2.0/packages/engine.json new file mode 100644 index 0000000..88d6913 --- /dev/null +++ b/BezierPathsDemo/settings/1.2.0/packages/engine.json @@ -0,0 +1,18 @@ +{ + "modules": { + "cache": {}, + "includeModules": [ + "base", + "gfx-webgl", + "gfx-webgl2", + "ui", + "particle", + "physics-cannon", + "physics-framework", + "audio", + "tween", + "terrain" + ] + }, + "__version__": "1.0.1" +} diff --git a/BezierPathsDemo/settings/1.2.0/packages/project.json b/BezierPathsDemo/settings/1.2.0/packages/project.json new file mode 100644 index 0000000..4e78796 --- /dev/null +++ b/BezierPathsDemo/settings/1.2.0/packages/project.json @@ -0,0 +1,7 @@ +{ + "__version__": "1.0.1", + "script": { + "useDefineForClassFields": false, + "allowDeclareFields": false + } +} diff --git a/BezierPathsDemo/settings/v2/packages/builder.json b/BezierPathsDemo/settings/v2/packages/builder.json new file mode 100644 index 0000000..af081f3 --- /dev/null +++ b/BezierPathsDemo/settings/v2/packages/builder.json @@ -0,0 +1,3 @@ +{ + "__version__": "1.2.8" +} diff --git a/BezierPathsDemo/settings/v2/packages/device.json b/BezierPathsDemo/settings/v2/packages/device.json new file mode 100644 index 0000000..70e599e --- /dev/null +++ b/BezierPathsDemo/settings/v2/packages/device.json @@ -0,0 +1,3 @@ +{ + "__version__": "1.0.1" +} diff --git a/BezierPathsDemo/settings/v2/packages/engine.json b/BezierPathsDemo/settings/v2/packages/engine.json new file mode 100644 index 0000000..47a0b66 --- /dev/null +++ b/BezierPathsDemo/settings/v2/packages/engine.json @@ -0,0 +1,28 @@ +{ + "modules": { + "cache": {}, + "includeModules": [ + "base", + "gfx-webgl", + "3d", + "2d", + "ui", + "particle", + "physics-ammo", + "physics-2d-box2d", + "intersection-2d", + "primitive", + "profiler", + "particle-2d", + "audio", + "video", + "webview", + "tween", + "terrain", + "tiled-map", + "spine", + "dragon-bones" + ] + }, + "__version__": "1.0.5" +} diff --git a/BezierPathsDemo/settings/v2/packages/program.json b/BezierPathsDemo/settings/v2/packages/program.json new file mode 100644 index 0000000..4d87e97 --- /dev/null +++ b/BezierPathsDemo/settings/v2/packages/program.json @@ -0,0 +1,3 @@ +{ + "__version__": "1.0.0" +} diff --git a/BezierPathsDemo/settings/v2/packages/project.json b/BezierPathsDemo/settings/v2/packages/project.json new file mode 100644 index 0000000..f7ca559 --- /dev/null +++ b/BezierPathsDemo/settings/v2/packages/project.json @@ -0,0 +1,13 @@ +{ + "__version__": "1.0.1", + "script": { + "useDefineForClassFields": false, + "allowDeclareFields": false + }, + "general": { + "designResolution": { + "width": 720, + "height": 1280 + } + } +} diff --git a/BezierPathsDemo/tsconfig.json b/BezierPathsDemo/tsconfig.json new file mode 100644 index 0000000..faff299 --- /dev/null +++ b/BezierPathsDemo/tsconfig.json @@ -0,0 +1,6 @@ +{ + /* Base configuration. Do not edit this field. */ + "extends": "./temp/tsconfig.cocos.json" + + /* Add your custom configuration here. */ +} diff --git a/BigNumber64Demo/.gitignore b/BigNumber64Demo/.gitignore new file mode 100644 index 0000000..640d65b --- /dev/null +++ b/BigNumber64Demo/.gitignore @@ -0,0 +1,67 @@ +#///////////////////////////////////////////////////////////////////////////// +# Fireball Projects +#///////////////////////////////////////////////////////////////////////////// + +library/ +temp/ +local/ +build/ + +#///////////////////////////////////////////////////////////////////////////// +# Logs and databases +#///////////////////////////////////////////////////////////////////////////// + +*.log +*.sql +*.sqlite + +#///////////////////////////////////////////////////////////////////////////// +# files for debugger +#///////////////////////////////////////////////////////////////////////////// + +*.sln +*.csproj +*.pidb +*.unityproj +*.suo + +#///////////////////////////////////////////////////////////////////////////// +# OS generated files +#///////////////////////////////////////////////////////////////////////////// + +.DS_Store +ehthumbs.db +Thumbs.db + +#///////////////////////////////////////////////////////////////////////////// +# exvim files +#///////////////////////////////////////////////////////////////////////////// + +*UnityVS.meta +*.err +*.err.meta +*.exvim +*.exvim.meta +*.vimentry +*.vimentry.meta +*.vimproject +*.vimproject.meta +.vimfiles.*/ +.exvim.*/ +quick_gen_project_*_autogen.bat +quick_gen_project_*_autogen.bat.meta +quick_gen_project_*_autogen.sh +quick_gen_project_*_autogen.sh.meta +.exvim.app + +#///////////////////////////////////////////////////////////////////////////// +# webstorm files +#///////////////////////////////////////////////////////////////////////////// + +.idea/ + +#////////////////////////// +# VS Code +#////////////////////////// + +.vscode/ \ No newline at end of file diff --git a/BigNumber64Demo/README.md b/BigNumber64Demo/README.md new file mode 100644 index 0000000..640e805 --- /dev/null +++ b/BigNumber64Demo/README.md @@ -0,0 +1,37 @@ +# BigNumber64Demo +> 介绍如何在 javascript 处理64位大数。 +### 方案1 +[long.js](https://github.com/dcodeIO/long.js) 库 +##### 介绍 +A Long class for representing a 64 bit two's-complement integer value derived from the Closure Library for stand-alone use and extended with unsigned support. + +##### 简单使用 +~~~ +var Long = require("long"); + +var longVal = new Long(0xFFFFFFFF, 0x7FFFFFFF); + +console.log(longVal.toString()); +~~~ + +##### 优势 +* 可以把服务器发过来的高位、底位数据合成一个大数。显示,+、-、*、/、。 + +### 方案2 +[bignumber.js](https://github.com/alexbardas/bignumber.js) 库 +##### 介绍 +BigNumber.js is a light javascript library for node.js and the browser. It supports arithmetic operations on Big Integers. + +It is build with performance in mind, uses the fastest algorithms and supports all basic arithmetic operations (+, -, *, /, %, ^, abs). Works with both positive and negative big integers. + +##### 简单介绍 +~~~ +var BigNumber = require('big-number'); + +BigNumber(5).plus(97).minus(53).plus(434).multiply(5435423).add(321453).multiply(21).div(2).pow(2); +// 760056543044267246001 +~~~ + +##### 优势 +* 支持add/plus, minus/subtract, multiply/mult, divide/div, power/pow, mod, equals, lt, lte, gt, gte, isZero, abs + diff --git a/BigNumber64Demo/assets/Scene.meta b/BigNumber64Demo/assets/Scene.meta new file mode 100644 index 0000000..7da30b0 --- /dev/null +++ b/BigNumber64Demo/assets/Scene.meta @@ -0,0 +1,6 @@ +{ + "ver": "1.0.1", + "uuid": "29f52784-2fca-467b-92e7-8fd9ef8c57b7", + "isGroup": false, + "subMetas": {} +} \ No newline at end of file diff --git a/BigNumber64Demo/assets/Scene/helloworld.fire b/BigNumber64Demo/assets/Scene/helloworld.fire new file mode 100644 index 0000000..3bcd5ed --- /dev/null +++ b/BigNumber64Demo/assets/Scene/helloworld.fire @@ -0,0 +1,368 @@ +[ + { + "__type__": "cc.SceneAsset", + "_name": "", + "_objFlags": 0, + "_rawFiles": null, + "scene": { + "__id__": 1 + } + }, + { + "__type__": "cc.Scene", + "_name": "", + "_objFlags": 0, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_cascadeOpacityEnabled": true, + "_parent": null, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_children": [ + { + "__id__": 2 + } + ], + "_localZOrder": 0, + "_globalZOrder": 0, + "_ignoreAnchorPointForPosition": false, + "_tag": -1, + "_opacityModifyRGB": false, + "_id": "2d2f792f-a40c-49bb-a189-ed176a246e49" + }, + { + "__type__": "cc.Node", + "_name": "Canvas", + "_objFlags": 0, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 252, + "g": 252, + "b": 252, + "a": 255 + }, + "_cascadeOpacityEnabled": true, + "_parent": { + "__id__": 1 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 960, + "height": 640 + }, + "_children": [ + { + "__id__": 3 + }, + { + "__id__": 6 + }, + { + "__id__": 8 + } + ], + "_rotationX": 0, + "_rotationY": 0, + "_scaleX": 1, + "_scaleY": 1, + "_position": { + "__type__": "cc.Vec2", + "x": 480, + "y": 320 + }, + "_skewX": 0, + "_skewY": 0, + "_localZOrder": 0, + "_globalZOrder": 0, + "_ignoreAnchorPointForPosition": false, + "_tag": -1, + "_opacityModifyRGB": false, + "_id": "a286bbGknJLZpRpxROV6M94", + "_active": true, + "_components": [ + { + "__id__": 10 + }, + { + "__id__": 11 + } + ], + "_prefab": null + }, + { + "__type__": "cc.Node", + "_name": "background", + "_objFlags": 0, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 27, + "g": 38, + "b": 46, + "a": 255 + }, + "_cascadeOpacityEnabled": true, + "_parent": { + "__id__": 2 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 960, + "height": 640 + }, + "_children": [], + "_rotationX": 0, + "_rotationY": 0, + "_scaleX": 1, + "_scaleY": 1, + "_position": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_localZOrder": 0, + "_globalZOrder": 0, + "_ignoreAnchorPointForPosition": false, + "_tag": -1, + "_opacityModifyRGB": false, + "_id": "e2e0crkOLxGrpMxpbC4iQg1", + "_active": true, + "_components": [ + { + "__id__": 4 + }, + { + "__id__": 5 + } + ], + "_prefab": null + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 3 + }, + "_enabled": true, + "_alignFlags": 45, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_originalWidth": 200, + "_originalHeight": 150 + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 3 + }, + "_enabled": true, + "_spriteFrame": { + "__uuid__": "410fb916-8721-4663-bab8-34397391ace7" + }, + "_type": 1, + "_useOriginalSize": false, + "_atlas": null + }, + { + "__type__": "cc.Node", + "_name": "cocos", + "_objFlags": 0, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_cascadeOpacityEnabled": true, + "_parent": { + "__id__": 2 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 195, + "height": 270 + }, + "_children": [], + "_rotationX": 0, + "_rotationY": 0, + "_scaleX": 1, + "_scaleY": 1, + "_position": { + "__type__": "cc.Vec2", + "x": 0, + "y": 50 + }, + "_skewX": 0, + "_skewY": 0, + "_localZOrder": 0, + "_globalZOrder": 0, + "_ignoreAnchorPointForPosition": false, + "_tag": -1, + "_opacityModifyRGB": false, + "_id": "c4f30YOS65G64U2TwufdJ+2", + "_active": true, + "_components": [ + { + "__id__": 7 + } + ], + "_prefab": null + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 6 + }, + "_enabled": true, + "_spriteFrame": { + "__uuid__": "31bc895a-c003-4566-a9f3-2e54ae1c17dc" + }, + "_type": 0, + "_useOriginalSize": true, + "_atlas": null + }, + { + "__type__": "cc.Node", + "_name": "label", + "_objFlags": 0, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_cascadeOpacityEnabled": true, + "_parent": { + "__id__": 2 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 492, + "height": 112 + }, + "_children": [], + "_rotationX": 0, + "_rotationY": 0, + "_scaleX": 1, + "_scaleY": 1, + "_position": { + "__type__": "cc.Vec2", + "x": 0, + "y": -180 + }, + "_skewX": 0, + "_skewY": 0, + "_localZOrder": 0, + "_globalZOrder": 0, + "_ignoreAnchorPointForPosition": false, + "_tag": -1, + "_opacityModifyRGB": false, + "_id": "31f1bH7V69Ajr1iXhluMpTB", + "_active": true, + "_components": [ + { + "__id__": 9 + } + ], + "_prefab": null + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 8 + }, + "_enabled": true, + "_useOriginalSize": false, + "_fontSize": 60, + "_lineHeight": 60, + "_enableWrapText": true, + "_isSystemFontUsed": true, + "_N$string": "Label", + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$overflow": 0 + }, + { + "__type__": "cc.Canvas", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "_designResolution": { + "__type__": "cc.Size", + "width": 960, + "height": 640 + }, + "_fitWidth": false, + "_fitHeight": true + }, + { + "__type__": "280c3rsZJJKnZ9RqbALVwtK", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "label": { + "__id__": 9 + }, + "text": "Hello, World!" + } +] \ No newline at end of file diff --git a/BigNumber64Demo/assets/Scene/helloworld.fire.meta b/BigNumber64Demo/assets/Scene/helloworld.fire.meta new file mode 100644 index 0000000..2bff939 --- /dev/null +++ b/BigNumber64Demo/assets/Scene/helloworld.fire.meta @@ -0,0 +1,7 @@ +{ + "ver": "1.0.0", + "uuid": "2d2f792f-a40c-49bb-a189-ed176a246e49", + "asyncLoadAssets": false, + "autoReleaseAssets": false, + "subMetas": {} +} \ No newline at end of file diff --git a/BigNumber64Demo/assets/Script.meta b/BigNumber64Demo/assets/Script.meta new file mode 100644 index 0000000..7259168 --- /dev/null +++ b/BigNumber64Demo/assets/Script.meta @@ -0,0 +1,6 @@ +{ + "ver": "1.0.1", + "uuid": "4734c20c-0db8-4eb2-92ea-e692f4d70934", + "isGroup": false, + "subMetas": {} +} \ No newline at end of file diff --git a/BigNumber64Demo/assets/Script/HelloWorld.js b/BigNumber64Demo/assets/Script/HelloWorld.js new file mode 100644 index 0000000..b8d80cc --- /dev/null +++ b/BigNumber64Demo/assets/Script/HelloWorld.js @@ -0,0 +1,22 @@ +cc.Class({ + extends: cc.Component, + + properties: { + label: { + default: null, + type: cc.Label + }, + // defaults, set visually when attaching this script to the Canvas + text: 'Hello, World!' + }, + + // use this for initialization + onLoad: function () { + this.label.string = this.text; + }, + + // called every frame + update: function (dt) { + + }, +}); diff --git a/BigNumber64Demo/assets/Script/HelloWorld.js.meta b/BigNumber64Demo/assets/Script/HelloWorld.js.meta new file mode 100644 index 0000000..bdd969e --- /dev/null +++ b/BigNumber64Demo/assets/Script/HelloWorld.js.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.5", + "uuid": "280c3aec-6492-4a9d-9f51-a9b00b570b4a", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/BigNumber64Demo/assets/Script/libs.meta b/BigNumber64Demo/assets/Script/libs.meta new file mode 100644 index 0000000..cf3f26a --- /dev/null +++ b/BigNumber64Demo/assets/Script/libs.meta @@ -0,0 +1,5 @@ +{ + "ver": "1.0.1", + "uuid": "94d574ff-9875-4cb1-a36d-07c01b4e4092", + "subMetas": {} +} \ No newline at end of file diff --git a/BigNumber64Demo/assets/Script/libs/bignumber.js b/BigNumber64Demo/assets/Script/libs/bignumber.js new file mode 100644 index 0000000..0512278 --- /dev/null +++ b/BigNumber64Demo/assets/Script/libs/bignumber.js @@ -0,0 +1,432 @@ +/** + * big-number.js -> Arithmetic operations on big integers + * Pure javascript implementation, no external libraries needed + * Copyright(c) 2012-2018 Alex Bardas + * MIT Licensed + * It supports the following operations: + * addition, subtraction, multiplication, division, power, absolute value + * It works with both positive and negative integers + */ + +!(function() { + 'use strict'; + + // Helper function which tests if a given character is a digit + var testDigit = function(digit) { + return (/^\d$/.test(digit)); + }; + + // Helper function which returns the absolute value of a given number + var abs = function(number) { + var bigNumber; + if (typeof number === 'undefined') { + return; + } + bigNumber = BigNumber(number); + bigNumber.sign = 1; + return bigNumber; + }; + + // Check if argument is valid array + var isArray = function(arg) { + return Object.prototype.toString.call(arg) === '[object Array]'; + }; + + var isValidType = function(number) { + return [ + typeof number === 'number', + typeof number === 'string' && number.length > 0, + isArray(number) && number.length > 0, + number instanceof BigNumber + ].some(function(bool) { + return bool === true; + }); + }; + + var errors = { + 'invalid': 'Invalid Number', + 'division by zero': 'Invalid Number - Division By Zero' + }; + + // Constructor function which creates a new BigNumber object + // from an integer, a string, an array or other BigNumber object + function BigNumber(initialNumber) { + var index; + + if (!(this instanceof BigNumber)) { + return new BigNumber(initialNumber); + } + + this.number = []; + this.sign = 1; + this.rest = 0; + + // The initial number can be an array, string, number of another big number + // e.g. array : [3,2,1], ['+',3,2,1], ['-',3,2,1] + // number : 312 + // string : '321', '+321', -321' + // BigNumber : BigNumber(321) + // Every character except the first must be a digit + + if (!isValidType(initialNumber)) { + this.number = errors['invalid']; + return; + } + + if (isArray(initialNumber)) { + if (initialNumber.length && initialNumber[0] === '-' || initialNumber[0] === '+') { + this.sign = initialNumber[0] === '+' ? 1 : -1; + initialNumber.shift(0); + } + for (index = initialNumber.length - 1; index >= 0; index--) { + if (!this.addDigit(initialNumber[index])) + return; + } + } else { + initialNumber = initialNumber.toString(); + if (initialNumber.charAt(0) === '-' || initialNumber.charAt(0) === '+') { + this.sign = initialNumber.charAt(0) === '+' ? 1 : -1; + initialNumber = initialNumber.substring(1); + } + + for (index = initialNumber.length - 1; index >= 0; index--) { + if (!this.addDigit(parseInt(initialNumber.charAt(index), 10))) { + return; + } + } + } + } + + BigNumber.prototype.addDigit = function(digit) { + if (testDigit(digit)) { + this.number.push(digit); + } else { + this.number = errors['invalid']; + return false; + } + + return this; + }; + + BigNumber.prototype.isEven = function() { + return this.number[0] % 2 === 0; + }; + + // returns: + // null if this.number is not a number + // 0 if this.number === number + // -1 if this.number < number + // 1 if this.number > number + BigNumber.prototype._compare = function(number) { + var bigNumber; + var index; + + if (!isValidType(number)) { + return null; + } + + bigNumber = BigNumber(number); + + // If the numbers have different signs, then the positive + // number is greater + if (this.sign !== bigNumber.sign) { + return this.sign; + } + + // Else, check the length + if (this.number.length > bigNumber.number.length) { + return this.sign; + } else if (this.number.length < bigNumber.number.length) { + return this.sign * (-1); + } + + // If they have similar length, compare the numbers + // digit by digit + for (index = this.number.length - 1; index >= 0; index--) { + if (this.number[index] > bigNumber.number[index]) { + return this.sign; + } else if (this.number[index] < bigNumber.number[index]) { + return this.sign * (-1); + } + } + + return 0; + }; + + // Greater than + BigNumber.prototype.gt = function(number) { + return this._compare(number) > 0; + }; + + // Greater than or equal + BigNumber.prototype.gte = function(number) { + return this._compare(number) >= 0; + }; + + // this.number equals n + BigNumber.prototype.equals = function(number) { + return this._compare(number) === 0; + }; + + // Less than or equal + BigNumber.prototype.lte = function(number) { + return this._compare(number) <= 0; + }; + + // Less than + BigNumber.prototype.lt = function(number) { + return this._compare(number) < 0; + }; + + // Addition + BigNumber.prototype.add = function(number) { + var bigNumber; + if (typeof number === 'undefined') { + return this; + } + bigNumber = BigNumber(number); + + if (this.sign !== bigNumber.sign) { + if (this.sign > 0) { + bigNumber.sign = 1; + return this.minus(bigNumber); + } + else { + this.sign = 1; + return bigNumber.minus(this); + } + } + + this.number = BigNumber._add(this, bigNumber); + return this; + }; + + // Subtraction + BigNumber.prototype.subtract = function(number) { + var bigNumber; + if (typeof number === 'undefined') { + return this; + } + bigNumber = BigNumber(number); + + if (this.sign !== bigNumber.sign) { + this.number = BigNumber._add(this, bigNumber); + return this; + } + + // If current number is lesser than the given bigNumber, the result will be negative + this.sign = (this.lt(bigNumber)) ? -1 : 1; + this.number = (abs(this).lt(abs(bigNumber))) + ? BigNumber._subtract(bigNumber, this) + : BigNumber._subtract(this, bigNumber); + + return this; + }; + + // adds two positive BigNumbers + BigNumber._add = function(a, b) { + var index; + var remainder = 0; + var length = Math.max(a.number.length, b.number.length); + + for (index = 0; index < length || remainder > 0; index++) { + a.number[index] = (remainder += (a.number[index] || 0) + (b.number[index] || 0)) % 10; + remainder = Math.floor(remainder / 10); + } + + return a.number; + }; + + // a - b + // a and b are 2 positive BigNumbers and a > b + BigNumber._subtract = function(a, b) { + var index; + var remainder = 0; + var length = a.number.length; + + for (index = 0; index < length; index++) { + a.number[index] -= (b.number[index] || 0) + remainder; + a.number[index] += (remainder = (a.number[index] < 0) ? 1 : 0) * 10; + } + // Count the zeroes which will be removed + index = 0; + length = a.number.length - 1; + while (a.number[length - index] === 0 && length - index > 0) { + index++; + } + if (index > 0) { + a.number.splice(-index); + } + return a.number; + }; + + // this.number * number + BigNumber.prototype.multiply = function(number) { + if (typeof number === 'undefined') { + return this; + } + var bigNumber = BigNumber(number); + var index; + var givenNumberIndex; + var remainder = 0; + var result = []; + + if (this.isZero() || bigNumber.isZero()) { + return BigNumber(0); + } + + this.sign *= bigNumber.sign; + + // multiply the numbers + for (index = 0; index < this.number.length; index++) { + for (remainder = 0, givenNumberIndex = 0; givenNumberIndex < bigNumber.number.length || remainder > 0; givenNumberIndex++) { + result[index + givenNumberIndex] = (remainder += (result[index + givenNumberIndex] || 0) + this.number[index] * (bigNumber.number[givenNumberIndex] || 0)) % 10; + remainder = Math.floor(remainder / 10); + } + } + + this.number = result; + return this; + }; + + // this.number / number + BigNumber.prototype.divide = function(number) { + if (typeof number === 'undefined') { + return this; + } + + var bigNumber = BigNumber(number); + var index; + var length; + var result = []; + var rest = BigNumber(0); + + // test if one of the numbers is zero + if (bigNumber.isZero()) { + this.number = errors['division by zero']; + return this; + } else if (this.isZero()) { + this.rest = BigNumber(0); + return this; + } + + this.sign *= bigNumber.sign; + bigNumber.sign = 1; + + // Skip division by 1 + if (bigNumber.number.length === 1 && bigNumber.number[0] === 1) { + this.rest = BigNumber(0); + return this; + } + + for (index = this.number.length - 1; index >= 0; index--) { + rest.multiply(10); + rest.number[0] = this.number[index]; + result[index] = 0; + while (bigNumber.lte(rest)) { + result[index]++; + rest.subtract(bigNumber); + } + } + + index = 0; + length = result.length - 1; + while (result[length - index] === 0 && length - index > 0) { + index++; + } + if (index > 0) { + result.splice(-index); + } + + this.rest = rest; + this.number = result; + return this; + }; + + // this.number % number + BigNumber.prototype.mod = function(number) { + return this.divide(number).rest; + }; + + BigNumber.prototype.power = function(number) { + if (typeof number === 'undefined') + return; + var bigNumber; + var bigNumberPower; + // Convert the argument to a big number + if (!isValidType(number)) { + this.number = errors['invalid']; + return; + } + bigNumberPower = BigNumber(number); + if (bigNumberPower.isZero()) { + return BigNumber(1); + } + if (bigNumberPower.val() === '1') { + return this; + } + + bigNumber = BigNumber(this); + + this.number = [1]; + while (bigNumberPower.gt(0)) { + if (!bigNumberPower.isEven()) { + this.multiply(bigNumber); + bigNumberPower.subtract(1); + continue; + } + bigNumber.multiply(bigNumber); + bigNumberPower.div(2); + } + + return this; + }; + + // |this.number| + BigNumber.prototype.abs = function() { + this.sign = 1; + return this; + }; + + // Check if this.number is equal to 0 + BigNumber.prototype.isZero = function() { + var index; + for (index = 0; index < this.number.length; index++) { + if (this.number[index] !== 0) { + return false; + } + } + + return true; + }; + + // this.number.toString() + BigNumber.prototype.toString = function() { + var index; + var str = ''; + if (typeof this.number === 'string') { + return this.number; + } + + for (index = this.number.length - 1; index >= 0; index--) { + str += this.number[index]; + } + + return (this.sign > 0) ? str : ('-' + str); + }; + + // Use shorcuts for functions names + BigNumber.prototype.plus = BigNumber.prototype.add; + BigNumber.prototype.minus = BigNumber.prototype.subtract; + BigNumber.prototype.div = BigNumber.prototype.divide; + BigNumber.prototype.mult = BigNumber.prototype.multiply; + BigNumber.prototype.pow = BigNumber.prototype.power; + BigNumber.prototype.val = BigNumber.prototype.toString; + + // CommonJS + if (typeof exports === 'object' && typeof module !== 'undefined') { + module.exports = BigNumber; + } else if (typeof window !== 'undefined') { + window.BigNumber = BigNumber; + } +})(); diff --git a/BigNumber64Demo/assets/Script/libs/bignumber.js.meta b/BigNumber64Demo/assets/Script/libs/bignumber.js.meta new file mode 100644 index 0000000..5285711 --- /dev/null +++ b/BigNumber64Demo/assets/Script/libs/bignumber.js.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.5", + "uuid": "c8022bc5-283a-4bdc-ad83-0cd80ee9e648", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/BigNumber64Demo/assets/Script/libs/long.js b/BigNumber64Demo/assets/Script/libs/long.js new file mode 100644 index 0000000..e1dfd57 --- /dev/null +++ b/BigNumber64Demo/assets/Script/libs/long.js @@ -0,0 +1,1405 @@ +module.exports = Long; + +/** + * wasm optimizations, to do native i64 multiplication and divide + */ +var wasm = null; + +try { + wasm = new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([ + 0, 97, 115, 109, 1, 0, 0, 0, 1, 13, 2, 96, 0, 1, 127, 96, 4, 127, 127, 127, 127, 1, 127, 3, 7, 6, 0, 1, 1, 1, 1, 1, 6, 6, 1, 127, 1, 65, 0, 11, 7, 50, 6, 3, 109, 117, 108, 0, 1, 5, 100, 105, 118, 95, 115, 0, 2, 5, 100, 105, 118, 95, 117, 0, 3, 5, 114, 101, 109, 95, 115, 0, 4, 5, 114, 101, 109, 95, 117, 0, 5, 8, 103, 101, 116, 95, 104, 105, 103, 104, 0, 0, 10, 191, 1, 6, 4, 0, 35, 0, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 126, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 127, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 128, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 129, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 130, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11 + ])), {}).exports; +} catch (e) { + // no wasm support :( +} + +/** + * Constructs a 64 bit two's-complement integer, given its low and high 32 bit values as *signed* integers. + * See the from* functions below for more convenient ways of constructing Longs. + * @exports Long + * @class A Long class for representing a 64 bit two's-complement integer value. + * @param {number} low The low (signed) 32 bits of the long + * @param {number} high The high (signed) 32 bits of the long + * @param {boolean=} unsigned Whether unsigned or not, defaults to signed + * @constructor + */ +function Long(low, high, unsigned) { + + /** + * The low 32 bits as a signed value. + * @type {number} + */ + this.low = low | 0; + + /** + * The high 32 bits as a signed value. + * @type {number} + */ + this.high = high | 0; + + /** + * Whether unsigned or not. + * @type {boolean} + */ + this.unsigned = !!unsigned; +} + +// The internal representation of a long is the two given signed, 32-bit values. +// We use 32-bit pieces because these are the size of integers on which +// Javascript performs bit-operations. For operations like addition and +// multiplication, we split each number into 16 bit pieces, which can easily be +// multiplied within Javascript's floating-point representation without overflow +// or change in sign. +// +// In the algorithms below, we frequently reduce the negative case to the +// positive case by negating the input(s) and then post-processing the result. +// Note that we must ALWAYS check specially whether those values are MIN_VALUE +// (-2^63) because -MIN_VALUE == MIN_VALUE (since 2^63 cannot be represented as +// a positive number, it overflows back into a negative). Not handling this +// case would often result in infinite recursion. +// +// Common constant values ZERO, ONE, NEG_ONE, etc. are defined below the from* +// methods on which they depend. + +/** + * An indicator used to reliably determine if an object is a Long or not. + * @type {boolean} + * @const + * @private + */ +Long.prototype.__isLong__; + +Object.defineProperty(Long.prototype, "__isLong__", { value: true }); + +/** + * @function + * @param {*} obj Object + * @returns {boolean} + * @inner + */ +function isLong(obj) { + return (obj && obj["__isLong__"]) === true; +} + +/** + * Tests if the specified object is a Long. + * @function + * @param {*} obj Object + * @returns {boolean} + */ +Long.isLong = isLong; + +/** + * A cache of the Long representations of small integer values. + * @type {!Object} + * @inner + */ +var INT_CACHE = {}; + +/** + * A cache of the Long representations of small unsigned integer values. + * @type {!Object} + * @inner + */ +var UINT_CACHE = {}; + +/** + * @param {number} value + * @param {boolean=} unsigned + * @returns {!Long} + * @inner + */ +function fromInt(value, unsigned) { + var obj, cachedObj, cache; + if (unsigned) { + value >>>= 0; + if (cache = (0 <= value && value < 256)) { + cachedObj = UINT_CACHE[value]; + if (cachedObj) + return cachedObj; + } + obj = fromBits(value, (value | 0) < 0 ? -1 : 0, true); + if (cache) + UINT_CACHE[value] = obj; + return obj; + } else { + value |= 0; + if (cache = (-128 <= value && value < 128)) { + cachedObj = INT_CACHE[value]; + if (cachedObj) + return cachedObj; + } + obj = fromBits(value, value < 0 ? -1 : 0, false); + if (cache) + INT_CACHE[value] = obj; + return obj; + } +} + +/** + * Returns a Long representing the given 32 bit integer value. + * @function + * @param {number} value The 32 bit integer in question + * @param {boolean=} unsigned Whether unsigned or not, defaults to signed + * @returns {!Long} The corresponding Long value + */ +Long.fromInt = fromInt; + +/** + * @param {number} value + * @param {boolean=} unsigned + * @returns {!Long} + * @inner + */ +function fromNumber(value, unsigned) { + if (isNaN(value)) + return unsigned ? UZERO : ZERO; + if (unsigned) { + if (value < 0) + return UZERO; + if (value >= TWO_PWR_64_DBL) + return MAX_UNSIGNED_VALUE; + } else { + if (value <= -TWO_PWR_63_DBL) + return MIN_VALUE; + if (value + 1 >= TWO_PWR_63_DBL) + return MAX_VALUE; + } + if (value < 0) + return fromNumber(-value, unsigned).neg(); + return fromBits((value % TWO_PWR_32_DBL) | 0, (value / TWO_PWR_32_DBL) | 0, unsigned); +} + +/** + * Returns a Long representing the given value, provided that it is a finite number. Otherwise, zero is returned. + * @function + * @param {number} value The number in question + * @param {boolean=} unsigned Whether unsigned or not, defaults to signed + * @returns {!Long} The corresponding Long value + */ +Long.fromNumber = fromNumber; + +/** + * @param {number} lowBits + * @param {number} highBits + * @param {boolean=} unsigned + * @returns {!Long} + * @inner + */ +function fromBits(lowBits, highBits, unsigned) { + return new Long(lowBits, highBits, unsigned); +} + +/** + * Returns a Long representing the 64 bit integer that comes by concatenating the given low and high bits. Each is + * assumed to use 32 bits. + * @function + * @param {number} lowBits The low 32 bits + * @param {number} highBits The high 32 bits + * @param {boolean=} unsigned Whether unsigned or not, defaults to signed + * @returns {!Long} The corresponding Long value + */ +Long.fromBits = fromBits; + +/** + * @function + * @param {number} base + * @param {number} exponent + * @returns {number} + * @inner + */ +var pow_dbl = Math.pow; // Used 4 times (4*8 to 15+4) + +/** + * @param {string} str + * @param {(boolean|number)=} unsigned + * @param {number=} radix + * @returns {!Long} + * @inner + */ +function fromString(str, unsigned, radix) { + if (str.length === 0) + throw Error('empty string'); + if (str === "NaN" || str === "Infinity" || str === "+Infinity" || str === "-Infinity") + return ZERO; + if (typeof unsigned === 'number') { + // For goog.math.long compatibility + radix = unsigned, + unsigned = false; + } else { + unsigned = !! unsigned; + } + radix = radix || 10; + if (radix < 2 || 36 < radix) + throw RangeError('radix'); + + var p; + if ((p = str.indexOf('-')) > 0) + throw Error('interior hyphen'); + else if (p === 0) { + return fromString(str.substring(1), unsigned, radix).neg(); + } + + // Do several (8) digits each time through the loop, so as to + // minimize the calls to the very expensive emulated div. + var radixToPower = fromNumber(pow_dbl(radix, 8)); + + var result = ZERO; + for (var i = 0; i < str.length; i += 8) { + var size = Math.min(8, str.length - i), + value = parseInt(str.substring(i, i + size), radix); + if (size < 8) { + var power = fromNumber(pow_dbl(radix, size)); + result = result.mul(power).add(fromNumber(value)); + } else { + result = result.mul(radixToPower); + result = result.add(fromNumber(value)); + } + } + result.unsigned = unsigned; + return result; +} + +/** + * Returns a Long representation of the given string, written using the specified radix. + * @function + * @param {string} str The textual representation of the Long + * @param {(boolean|number)=} unsigned Whether unsigned or not, defaults to signed + * @param {number=} radix The radix in which the text is written (2-36), defaults to 10 + * @returns {!Long} The corresponding Long value + */ +Long.fromString = fromString; + +/** + * @function + * @param {!Long|number|string|!{low: number, high: number, unsigned: boolean}} val + * @param {boolean=} unsigned + * @returns {!Long} + * @inner + */ +function fromValue(val, unsigned) { + if (typeof val === 'number') + return fromNumber(val, unsigned); + if (typeof val === 'string') + return fromString(val, unsigned); + // Throws for non-objects, converts non-instanceof Long: + return fromBits(val.low, val.high, typeof unsigned === 'boolean' ? unsigned : val.unsigned); +} + +/** + * Converts the specified value to a Long using the appropriate from* function for its type. + * @function + * @param {!Long|number|string|!{low: number, high: number, unsigned: boolean}} val Value + * @param {boolean=} unsigned Whether unsigned or not, defaults to signed + * @returns {!Long} + */ +Long.fromValue = fromValue; + +// NOTE: the compiler should inline these constant values below and then remove these variables, so there should be +// no runtime penalty for these. + +/** + * @type {number} + * @const + * @inner + */ +var TWO_PWR_16_DBL = 1 << 16; + +/** + * @type {number} + * @const + * @inner + */ +var TWO_PWR_24_DBL = 1 << 24; + +/** + * @type {number} + * @const + * @inner + */ +var TWO_PWR_32_DBL = TWO_PWR_16_DBL * TWO_PWR_16_DBL; + +/** + * @type {number} + * @const + * @inner + */ +var TWO_PWR_64_DBL = TWO_PWR_32_DBL * TWO_PWR_32_DBL; + +/** + * @type {number} + * @const + * @inner + */ +var TWO_PWR_63_DBL = TWO_PWR_64_DBL / 2; + +/** + * @type {!Long} + * @const + * @inner + */ +var TWO_PWR_24 = fromInt(TWO_PWR_24_DBL); + +/** + * @type {!Long} + * @inner + */ +var ZERO = fromInt(0); + +/** + * Signed zero. + * @type {!Long} + */ +Long.ZERO = ZERO; + +/** + * @type {!Long} + * @inner + */ +var UZERO = fromInt(0, true); + +/** + * Unsigned zero. + * @type {!Long} + */ +Long.UZERO = UZERO; + +/** + * @type {!Long} + * @inner + */ +var ONE = fromInt(1); + +/** + * Signed one. + * @type {!Long} + */ +Long.ONE = ONE; + +/** + * @type {!Long} + * @inner + */ +var UONE = fromInt(1, true); + +/** + * Unsigned one. + * @type {!Long} + */ +Long.UONE = UONE; + +/** + * @type {!Long} + * @inner + */ +var NEG_ONE = fromInt(-1); + +/** + * Signed negative one. + * @type {!Long} + */ +Long.NEG_ONE = NEG_ONE; + +/** + * @type {!Long} + * @inner + */ +var MAX_VALUE = fromBits(0xFFFFFFFF|0, 0x7FFFFFFF|0, false); + +/** + * Maximum signed value. + * @type {!Long} + */ +Long.MAX_VALUE = MAX_VALUE; + +/** + * @type {!Long} + * @inner + */ +var MAX_UNSIGNED_VALUE = fromBits(0xFFFFFFFF|0, 0xFFFFFFFF|0, true); + +/** + * Maximum unsigned value. + * @type {!Long} + */ +Long.MAX_UNSIGNED_VALUE = MAX_UNSIGNED_VALUE; + +/** + * @type {!Long} + * @inner + */ +var MIN_VALUE = fromBits(0, 0x80000000|0, false); + +/** + * Minimum signed value. + * @type {!Long} + */ +Long.MIN_VALUE = MIN_VALUE; + +/** + * @alias Long.prototype + * @inner + */ +var LongPrototype = Long.prototype; + +/** + * Converts the Long to a 32 bit integer, assuming it is a 32 bit integer. + * @this {!Long} + * @returns {number} + */ +LongPrototype.toInt = function toInt() { + return this.unsigned ? this.low >>> 0 : this.low; +}; + +/** + * Converts the Long to a the nearest floating-point representation of this value (double, 53 bit mantissa). + * @this {!Long} + * @returns {number} + */ +LongPrototype.toNumber = function toNumber() { + if (this.unsigned) + return ((this.high >>> 0) * TWO_PWR_32_DBL) + (this.low >>> 0); + return this.high * TWO_PWR_32_DBL + (this.low >>> 0); +}; + +/** + * Converts the Long to a string written in the specified radix. + * @this {!Long} + * @param {number=} radix Radix (2-36), defaults to 10 + * @returns {string} + * @override + * @throws {RangeError} If `radix` is out of range + */ +LongPrototype.toString = function toString(radix) { + radix = radix || 10; + if (radix < 2 || 36 < radix) + throw RangeError('radix'); + if (this.isZero()) + return '0'; + if (this.isNegative()) { // Unsigned Longs are never negative + if (this.eq(MIN_VALUE)) { + // We need to change the Long value before it can be negated, so we remove + // the bottom-most digit in this base and then recurse to do the rest. + var radixLong = fromNumber(radix), + div = this.div(radixLong), + rem1 = div.mul(radixLong).sub(this); + return div.toString(radix) + rem1.toInt().toString(radix); + } else + return '-' + this.neg().toString(radix); + } + + // Do several (6) digits each time through the loop, so as to + // minimize the calls to the very expensive emulated div. + var radixToPower = fromNumber(pow_dbl(radix, 6), this.unsigned), + rem = this; + var result = ''; + while (true) { + var remDiv = rem.div(radixToPower), + intval = rem.sub(remDiv.mul(radixToPower)).toInt() >>> 0, + digits = intval.toString(radix); + rem = remDiv; + if (rem.isZero()) + return digits + result; + else { + while (digits.length < 6) + digits = '0' + digits; + result = '' + digits + result; + } + } +}; + +/** + * Gets the high 32 bits as a signed integer. + * @this {!Long} + * @returns {number} Signed high bits + */ +LongPrototype.getHighBits = function getHighBits() { + return this.high; +}; + +/** + * Gets the high 32 bits as an unsigned integer. + * @this {!Long} + * @returns {number} Unsigned high bits + */ +LongPrototype.getHighBitsUnsigned = function getHighBitsUnsigned() { + return this.high >>> 0; +}; + +/** + * Gets the low 32 bits as a signed integer. + * @this {!Long} + * @returns {number} Signed low bits + */ +LongPrototype.getLowBits = function getLowBits() { + return this.low; +}; + +/** + * Gets the low 32 bits as an unsigned integer. + * @this {!Long} + * @returns {number} Unsigned low bits + */ +LongPrototype.getLowBitsUnsigned = function getLowBitsUnsigned() { + return this.low >>> 0; +}; + +/** + * Gets the number of bits needed to represent the absolute value of this Long. + * @this {!Long} + * @returns {number} + */ +LongPrototype.getNumBitsAbs = function getNumBitsAbs() { + if (this.isNegative()) // Unsigned Longs are never negative + return this.eq(MIN_VALUE) ? 64 : this.neg().getNumBitsAbs(); + var val = this.high != 0 ? this.high : this.low; + for (var bit = 31; bit > 0; bit--) + if ((val & (1 << bit)) != 0) + break; + return this.high != 0 ? bit + 33 : bit + 1; +}; + +/** + * Tests if this Long's value equals zero. + * @this {!Long} + * @returns {boolean} + */ +LongPrototype.isZero = function isZero() { + return this.high === 0 && this.low === 0; +}; + +/** + * Tests if this Long's value equals zero. This is an alias of {@link Long#isZero}. + * @returns {boolean} + */ +LongPrototype.eqz = LongPrototype.isZero; + +/** + * Tests if this Long's value is negative. + * @this {!Long} + * @returns {boolean} + */ +LongPrototype.isNegative = function isNegative() { + return !this.unsigned && this.high < 0; +}; + +/** + * Tests if this Long's value is positive. + * @this {!Long} + * @returns {boolean} + */ +LongPrototype.isPositive = function isPositive() { + return this.unsigned || this.high >= 0; +}; + +/** + * Tests if this Long's value is odd. + * @this {!Long} + * @returns {boolean} + */ +LongPrototype.isOdd = function isOdd() { + return (this.low & 1) === 1; +}; + +/** + * Tests if this Long's value is even. + * @this {!Long} + * @returns {boolean} + */ +LongPrototype.isEven = function isEven() { + return (this.low & 1) === 0; +}; + +/** + * Tests if this Long's value equals the specified's. + * @this {!Long} + * @param {!Long|number|string} other Other value + * @returns {boolean} + */ +LongPrototype.equals = function equals(other) { + if (!isLong(other)) + other = fromValue(other); + if (this.unsigned !== other.unsigned && (this.high >>> 31) === 1 && (other.high >>> 31) === 1) + return false; + return this.high === other.high && this.low === other.low; +}; + +/** + * Tests if this Long's value equals the specified's. This is an alias of {@link Long#equals}. + * @function + * @param {!Long|number|string} other Other value + * @returns {boolean} + */ +LongPrototype.eq = LongPrototype.equals; + +/** + * Tests if this Long's value differs from the specified's. + * @this {!Long} + * @param {!Long|number|string} other Other value + * @returns {boolean} + */ +LongPrototype.notEquals = function notEquals(other) { + return !this.eq(/* validates */ other); +}; + +/** + * Tests if this Long's value differs from the specified's. This is an alias of {@link Long#notEquals}. + * @function + * @param {!Long|number|string} other Other value + * @returns {boolean} + */ +LongPrototype.neq = LongPrototype.notEquals; + +/** + * Tests if this Long's value differs from the specified's. This is an alias of {@link Long#notEquals}. + * @function + * @param {!Long|number|string} other Other value + * @returns {boolean} + */ +LongPrototype.ne = LongPrototype.notEquals; + +/** + * Tests if this Long's value is less than the specified's. + * @this {!Long} + * @param {!Long|number|string} other Other value + * @returns {boolean} + */ +LongPrototype.lessThan = function lessThan(other) { + return this.comp(/* validates */ other) < 0; +}; + +/** + * Tests if this Long's value is less than the specified's. This is an alias of {@link Long#lessThan}. + * @function + * @param {!Long|number|string} other Other value + * @returns {boolean} + */ +LongPrototype.lt = LongPrototype.lessThan; + +/** + * Tests if this Long's value is less than or equal the specified's. + * @this {!Long} + * @param {!Long|number|string} other Other value + * @returns {boolean} + */ +LongPrototype.lessThanOrEqual = function lessThanOrEqual(other) { + return this.comp(/* validates */ other) <= 0; +}; + +/** + * Tests if this Long's value is less than or equal the specified's. This is an alias of {@link Long#lessThanOrEqual}. + * @function + * @param {!Long|number|string} other Other value + * @returns {boolean} + */ +LongPrototype.lte = LongPrototype.lessThanOrEqual; + +/** + * Tests if this Long's value is less than or equal the specified's. This is an alias of {@link Long#lessThanOrEqual}. + * @function + * @param {!Long|number|string} other Other value + * @returns {boolean} + */ +LongPrototype.le = LongPrototype.lessThanOrEqual; + +/** + * Tests if this Long's value is greater than the specified's. + * @this {!Long} + * @param {!Long|number|string} other Other value + * @returns {boolean} + */ +LongPrototype.greaterThan = function greaterThan(other) { + return this.comp(/* validates */ other) > 0; +}; + +/** + * Tests if this Long's value is greater than the specified's. This is an alias of {@link Long#greaterThan}. + * @function + * @param {!Long|number|string} other Other value + * @returns {boolean} + */ +LongPrototype.gt = LongPrototype.greaterThan; + +/** + * Tests if this Long's value is greater than or equal the specified's. + * @this {!Long} + * @param {!Long|number|string} other Other value + * @returns {boolean} + */ +LongPrototype.greaterThanOrEqual = function greaterThanOrEqual(other) { + return this.comp(/* validates */ other) >= 0; +}; + +/** + * Tests if this Long's value is greater than or equal the specified's. This is an alias of {@link Long#greaterThanOrEqual}. + * @function + * @param {!Long|number|string} other Other value + * @returns {boolean} + */ +LongPrototype.gte = LongPrototype.greaterThanOrEqual; + +/** + * Tests if this Long's value is greater than or equal the specified's. This is an alias of {@link Long#greaterThanOrEqual}. + * @function + * @param {!Long|number|string} other Other value + * @returns {boolean} + */ +LongPrototype.ge = LongPrototype.greaterThanOrEqual; + +/** + * Compares this Long's value with the specified's. + * @this {!Long} + * @param {!Long|number|string} other Other value + * @returns {number} 0 if they are the same, 1 if the this is greater and -1 + * if the given one is greater + */ +LongPrototype.compare = function compare(other) { + if (!isLong(other)) + other = fromValue(other); + if (this.eq(other)) + return 0; + var thisNeg = this.isNegative(), + otherNeg = other.isNegative(); + if (thisNeg && !otherNeg) + return -1; + if (!thisNeg && otherNeg) + return 1; + // At this point the sign bits are the same + if (!this.unsigned) + return this.sub(other).isNegative() ? -1 : 1; + // Both are positive if at least one is unsigned + return (other.high >>> 0) > (this.high >>> 0) || (other.high === this.high && (other.low >>> 0) > (this.low >>> 0)) ? -1 : 1; +}; + +/** + * Compares this Long's value with the specified's. This is an alias of {@link Long#compare}. + * @function + * @param {!Long|number|string} other Other value + * @returns {number} 0 if they are the same, 1 if the this is greater and -1 + * if the given one is greater + */ +LongPrototype.comp = LongPrototype.compare; + +/** + * Negates this Long's value. + * @this {!Long} + * @returns {!Long} Negated Long + */ +LongPrototype.negate = function negate() { + if (!this.unsigned && this.eq(MIN_VALUE)) + return MIN_VALUE; + return this.not().add(ONE); +}; + +/** + * Negates this Long's value. This is an alias of {@link Long#negate}. + * @function + * @returns {!Long} Negated Long + */ +LongPrototype.neg = LongPrototype.negate; + +/** + * Returns the sum of this and the specified Long. + * @this {!Long} + * @param {!Long|number|string} addend Addend + * @returns {!Long} Sum + */ +LongPrototype.add = function add(addend) { + if (!isLong(addend)) + addend = fromValue(addend); + + // Divide each number into 4 chunks of 16 bits, and then sum the chunks. + + var a48 = this.high >>> 16; + var a32 = this.high & 0xFFFF; + var a16 = this.low >>> 16; + var a00 = this.low & 0xFFFF; + + var b48 = addend.high >>> 16; + var b32 = addend.high & 0xFFFF; + var b16 = addend.low >>> 16; + var b00 = addend.low & 0xFFFF; + + var c48 = 0, c32 = 0, c16 = 0, c00 = 0; + c00 += a00 + b00; + c16 += c00 >>> 16; + c00 &= 0xFFFF; + c16 += a16 + b16; + c32 += c16 >>> 16; + c16 &= 0xFFFF; + c32 += a32 + b32; + c48 += c32 >>> 16; + c32 &= 0xFFFF; + c48 += a48 + b48; + c48 &= 0xFFFF; + return fromBits((c16 << 16) | c00, (c48 << 16) | c32, this.unsigned); +}; + +/** + * Returns the difference of this and the specified Long. + * @this {!Long} + * @param {!Long|number|string} subtrahend Subtrahend + * @returns {!Long} Difference + */ +LongPrototype.subtract = function subtract(subtrahend) { + if (!isLong(subtrahend)) + subtrahend = fromValue(subtrahend); + return this.add(subtrahend.neg()); +}; + +/** + * Returns the difference of this and the specified Long. This is an alias of {@link Long#subtract}. + * @function + * @param {!Long|number|string} subtrahend Subtrahend + * @returns {!Long} Difference + */ +LongPrototype.sub = LongPrototype.subtract; + +/** + * Returns the product of this and the specified Long. + * @this {!Long} + * @param {!Long|number|string} multiplier Multiplier + * @returns {!Long} Product + */ +LongPrototype.multiply = function multiply(multiplier) { + if (this.isZero()) + return ZERO; + if (!isLong(multiplier)) + multiplier = fromValue(multiplier); + + // use wasm support if present + if (wasm) { + var low = wasm["mul"](this.low, + this.high, + multiplier.low, + multiplier.high); + return fromBits(low, wasm["get_high"](), this.unsigned); + } + + if (multiplier.isZero()) + return ZERO; + if (this.eq(MIN_VALUE)) + return multiplier.isOdd() ? MIN_VALUE : ZERO; + if (multiplier.eq(MIN_VALUE)) + return this.isOdd() ? MIN_VALUE : ZERO; + + if (this.isNegative()) { + if (multiplier.isNegative()) + return this.neg().mul(multiplier.neg()); + else + return this.neg().mul(multiplier).neg(); + } else if (multiplier.isNegative()) + return this.mul(multiplier.neg()).neg(); + + // If both longs are small, use float multiplication + if (this.lt(TWO_PWR_24) && multiplier.lt(TWO_PWR_24)) + return fromNumber(this.toNumber() * multiplier.toNumber(), this.unsigned); + + // Divide each long into 4 chunks of 16 bits, and then add up 4x4 products. + // We can skip products that would overflow. + + var a48 = this.high >>> 16; + var a32 = this.high & 0xFFFF; + var a16 = this.low >>> 16; + var a00 = this.low & 0xFFFF; + + var b48 = multiplier.high >>> 16; + var b32 = multiplier.high & 0xFFFF; + var b16 = multiplier.low >>> 16; + var b00 = multiplier.low & 0xFFFF; + + var c48 = 0, c32 = 0, c16 = 0, c00 = 0; + c00 += a00 * b00; + c16 += c00 >>> 16; + c00 &= 0xFFFF; + c16 += a16 * b00; + c32 += c16 >>> 16; + c16 &= 0xFFFF; + c16 += a00 * b16; + c32 += c16 >>> 16; + c16 &= 0xFFFF; + c32 += a32 * b00; + c48 += c32 >>> 16; + c32 &= 0xFFFF; + c32 += a16 * b16; + c48 += c32 >>> 16; + c32 &= 0xFFFF; + c32 += a00 * b32; + c48 += c32 >>> 16; + c32 &= 0xFFFF; + c48 += a48 * b00 + a32 * b16 + a16 * b32 + a00 * b48; + c48 &= 0xFFFF; + return fromBits((c16 << 16) | c00, (c48 << 16) | c32, this.unsigned); +}; + +/** + * Returns the product of this and the specified Long. This is an alias of {@link Long#multiply}. + * @function + * @param {!Long|number|string} multiplier Multiplier + * @returns {!Long} Product + */ +LongPrototype.mul = LongPrototype.multiply; + +/** + * Returns this Long divided by the specified. The result is signed if this Long is signed or + * unsigned if this Long is unsigned. + * @this {!Long} + * @param {!Long|number|string} divisor Divisor + * @returns {!Long} Quotient + */ +LongPrototype.divide = function divide(divisor) { + if (!isLong(divisor)) + divisor = fromValue(divisor); + if (divisor.isZero()) + throw Error('division by zero'); + + // use wasm support if present + if (wasm) { + // guard against signed division overflow: the largest + // negative number / -1 would be 1 larger than the largest + // positive number, due to two's complement. + if (!this.unsigned && + this.high === -0x80000000 && + divisor.low === -1 && divisor.high === -1) { + // be consistent with non-wasm code path + return this; + } + var low = (this.unsigned ? wasm["div_u"] : wasm["div_s"])( + this.low, + this.high, + divisor.low, + divisor.high + ); + return fromBits(low, wasm["get_high"](), this.unsigned); + } + + if (this.isZero()) + return this.unsigned ? UZERO : ZERO; + var approx, rem, res; + if (!this.unsigned) { + // This section is only relevant for signed longs and is derived from the + // closure library as a whole. + if (this.eq(MIN_VALUE)) { + if (divisor.eq(ONE) || divisor.eq(NEG_ONE)) + return MIN_VALUE; // recall that -MIN_VALUE == MIN_VALUE + else if (divisor.eq(MIN_VALUE)) + return ONE; + else { + // At this point, we have |other| >= 2, so |this/other| < |MIN_VALUE|. + var halfThis = this.shr(1); + approx = halfThis.div(divisor).shl(1); + if (approx.eq(ZERO)) { + return divisor.isNegative() ? ONE : NEG_ONE; + } else { + rem = this.sub(divisor.mul(approx)); + res = approx.add(rem.div(divisor)); + return res; + } + } + } else if (divisor.eq(MIN_VALUE)) + return this.unsigned ? UZERO : ZERO; + if (this.isNegative()) { + if (divisor.isNegative()) + return this.neg().div(divisor.neg()); + return this.neg().div(divisor).neg(); + } else if (divisor.isNegative()) + return this.div(divisor.neg()).neg(); + res = ZERO; + } else { + // The algorithm below has not been made for unsigned longs. It's therefore + // required to take special care of the MSB prior to running it. + if (!divisor.unsigned) + divisor = divisor.toUnsigned(); + if (divisor.gt(this)) + return UZERO; + if (divisor.gt(this.shru(1))) // 15 >>> 1 = 7 ; with divisor = 8 ; true + return UONE; + res = UZERO; + } + + // Repeat the following until the remainder is less than other: find a + // floating-point that approximates remainder / other *from below*, add this + // into the result, and subtract it from the remainder. It is critical that + // the approximate value is less than or equal to the real value so that the + // remainder never becomes negative. + rem = this; + while (rem.gte(divisor)) { + // Approximate the result of division. This may be a little greater or + // smaller than the actual value. + approx = Math.max(1, Math.floor(rem.toNumber() / divisor.toNumber())); + + // We will tweak the approximate result by changing it in the 48-th digit or + // the smallest non-fractional digit, whichever is larger. + var log2 = Math.ceil(Math.log(approx) / Math.LN2), + delta = (log2 <= 48) ? 1 : pow_dbl(2, log2 - 48), + + // Decrease the approximation until it is smaller than the remainder. Note + // that if it is too large, the product overflows and is negative. + approxRes = fromNumber(approx), + approxRem = approxRes.mul(divisor); + while (approxRem.isNegative() || approxRem.gt(rem)) { + approx -= delta; + approxRes = fromNumber(approx, this.unsigned); + approxRem = approxRes.mul(divisor); + } + + // We know the answer can't be zero... and actually, zero would cause + // infinite recursion since we would make no progress. + if (approxRes.isZero()) + approxRes = ONE; + + res = res.add(approxRes); + rem = rem.sub(approxRem); + } + return res; +}; + +/** + * Returns this Long divided by the specified. This is an alias of {@link Long#divide}. + * @function + * @param {!Long|number|string} divisor Divisor + * @returns {!Long} Quotient + */ +LongPrototype.div = LongPrototype.divide; + +/** + * Returns this Long modulo the specified. + * @this {!Long} + * @param {!Long|number|string} divisor Divisor + * @returns {!Long} Remainder + */ +LongPrototype.modulo = function modulo(divisor) { + if (!isLong(divisor)) + divisor = fromValue(divisor); + + // use wasm support if present + if (wasm) { + var low = (this.unsigned ? wasm["rem_u"] : wasm["rem_s"])( + this.low, + this.high, + divisor.low, + divisor.high + ); + return fromBits(low, wasm["get_high"](), this.unsigned); + } + + return this.sub(this.div(divisor).mul(divisor)); +}; + +/** + * Returns this Long modulo the specified. This is an alias of {@link Long#modulo}. + * @function + * @param {!Long|number|string} divisor Divisor + * @returns {!Long} Remainder + */ +LongPrototype.mod = LongPrototype.modulo; + +/** + * Returns this Long modulo the specified. This is an alias of {@link Long#modulo}. + * @function + * @param {!Long|number|string} divisor Divisor + * @returns {!Long} Remainder + */ +LongPrototype.rem = LongPrototype.modulo; + +/** + * Returns the bitwise NOT of this Long. + * @this {!Long} + * @returns {!Long} + */ +LongPrototype.not = function not() { + return fromBits(~this.low, ~this.high, this.unsigned); +}; + +/** + * Returns the bitwise AND of this Long and the specified. + * @this {!Long} + * @param {!Long|number|string} other Other Long + * @returns {!Long} + */ +LongPrototype.and = function and(other) { + if (!isLong(other)) + other = fromValue(other); + return fromBits(this.low & other.low, this.high & other.high, this.unsigned); +}; + +/** + * Returns the bitwise OR of this Long and the specified. + * @this {!Long} + * @param {!Long|number|string} other Other Long + * @returns {!Long} + */ +LongPrototype.or = function or(other) { + if (!isLong(other)) + other = fromValue(other); + return fromBits(this.low | other.low, this.high | other.high, this.unsigned); +}; + +/** + * Returns the bitwise XOR of this Long and the given one. + * @this {!Long} + * @param {!Long|number|string} other Other Long + * @returns {!Long} + */ +LongPrototype.xor = function xor(other) { + if (!isLong(other)) + other = fromValue(other); + return fromBits(this.low ^ other.low, this.high ^ other.high, this.unsigned); +}; + +/** + * Returns this Long with bits shifted to the left by the given amount. + * @this {!Long} + * @param {number|!Long} numBits Number of bits + * @returns {!Long} Shifted Long + */ +LongPrototype.shiftLeft = function shiftLeft(numBits) { + if (isLong(numBits)) + numBits = numBits.toInt(); + if ((numBits &= 63) === 0) + return this; + else if (numBits < 32) + return fromBits(this.low << numBits, (this.high << numBits) | (this.low >>> (32 - numBits)), this.unsigned); + else + return fromBits(0, this.low << (numBits - 32), this.unsigned); +}; + +/** + * Returns this Long with bits shifted to the left by the given amount. This is an alias of {@link Long#shiftLeft}. + * @function + * @param {number|!Long} numBits Number of bits + * @returns {!Long} Shifted Long + */ +LongPrototype.shl = LongPrototype.shiftLeft; + +/** + * Returns this Long with bits arithmetically shifted to the right by the given amount. + * @this {!Long} + * @param {number|!Long} numBits Number of bits + * @returns {!Long} Shifted Long + */ +LongPrototype.shiftRight = function shiftRight(numBits) { + if (isLong(numBits)) + numBits = numBits.toInt(); + if ((numBits &= 63) === 0) + return this; + else if (numBits < 32) + return fromBits((this.low >>> numBits) | (this.high << (32 - numBits)), this.high >> numBits, this.unsigned); + else + return fromBits(this.high >> (numBits - 32), this.high >= 0 ? 0 : -1, this.unsigned); +}; + +/** + * Returns this Long with bits arithmetically shifted to the right by the given amount. This is an alias of {@link Long#shiftRight}. + * @function + * @param {number|!Long} numBits Number of bits + * @returns {!Long} Shifted Long + */ +LongPrototype.shr = LongPrototype.shiftRight; + +/** + * Returns this Long with bits logically shifted to the right by the given amount. + * @this {!Long} + * @param {number|!Long} numBits Number of bits + * @returns {!Long} Shifted Long + */ +LongPrototype.shiftRightUnsigned = function shiftRightUnsigned(numBits) { + if (isLong(numBits)) numBits = numBits.toInt(); + if ((numBits &= 63) === 0) return this; + if (numBits < 32) return fromBits((this.low >>> numBits) | (this.high << (32 - numBits)), this.high >>> numBits, this.unsigned); + if (numBits === 32) return fromBits(this.high, 0, this.unsigned); + return fromBits(this.high >>> (numBits - 32), 0, this.unsigned); +}; + +/** + * Returns this Long with bits logically shifted to the right by the given amount. This is an alias of {@link Long#shiftRightUnsigned}. + * @function + * @param {number|!Long} numBits Number of bits + * @returns {!Long} Shifted Long + */ +LongPrototype.shru = LongPrototype.shiftRightUnsigned; + +/** + * Returns this Long with bits logically shifted to the right by the given amount. This is an alias of {@link Long#shiftRightUnsigned}. + * @function + * @param {number|!Long} numBits Number of bits + * @returns {!Long} Shifted Long + */ +LongPrototype.shr_u = LongPrototype.shiftRightUnsigned; + +/** + * Returns this Long with bits rotated to the left by the given amount. + * @this {!Long} + * @param {number|!Long} numBits Number of bits + * @returns {!Long} Rotated Long + */ +LongPrototype.rotateLeft = function rotateLeft(numBits) { + var b; + if (isLong(numBits)) numBits = numBits.toInt(); + if ((numBits &= 63) === 0) return this; + if (numBits === 32) return fromBits(this.high, this.low, this.unsigned); + if (numBits < 32) { + b = (32 - numBits); + return fromBits(((this.low << numBits) | (this.high >>> b)), ((this.high << numBits) | (this.low >>> b)), this.unsigned); + } + numBits -= 32; + b = (32 - numBits); + return fromBits(((this.high << numBits) | (this.low >>> b)), ((this.low << numBits) | (this.high >>> b)), this.unsigned); +} +/** + * Returns this Long with bits rotated to the left by the given amount. This is an alias of {@link Long#rotateLeft}. + * @function + * @param {number|!Long} numBits Number of bits + * @returns {!Long} Rotated Long + */ +LongPrototype.rotl = LongPrototype.rotateLeft; + +/** + * Returns this Long with bits rotated to the right by the given amount. + * @this {!Long} + * @param {number|!Long} numBits Number of bits + * @returns {!Long} Rotated Long + */ +LongPrototype.rotateRight = function rotateRight(numBits) { + var b; + if (isLong(numBits)) numBits = numBits.toInt(); + if ((numBits &= 63) === 0) return this; + if (numBits === 32) return fromBits(this.high, this.low, this.unsigned); + if (numBits < 32) { + b = (32 - numBits); + return fromBits(((this.high << b) | (this.low >>> numBits)), ((this.low << b) | (this.high >>> numBits)), this.unsigned); + } + numBits -= 32; + b = (32 - numBits); + return fromBits(((this.low << b) | (this.high >>> numBits)), ((this.high << b) | (this.low >>> numBits)), this.unsigned); +} +/** + * Returns this Long with bits rotated to the right by the given amount. This is an alias of {@link Long#rotateRight}. + * @function + * @param {number|!Long} numBits Number of bits + * @returns {!Long} Rotated Long + */ +LongPrototype.rotr = LongPrototype.rotateRight; + +/** + * Converts this Long to signed. + * @this {!Long} + * @returns {!Long} Signed long + */ +LongPrototype.toSigned = function toSigned() { + if (!this.unsigned) + return this; + return fromBits(this.low, this.high, false); +}; + +/** + * Converts this Long to unsigned. + * @this {!Long} + * @returns {!Long} Unsigned long + */ +LongPrototype.toUnsigned = function toUnsigned() { + if (this.unsigned) + return this; + return fromBits(this.low, this.high, true); +}; + +/** + * Converts this Long to its byte representation. + * @param {boolean=} le Whether little or big endian, defaults to big endian + * @this {!Long} + * @returns {!Array.} Byte representation + */ +LongPrototype.toBytes = function toBytes(le) { + return le ? this.toBytesLE() : this.toBytesBE(); +}; + +/** + * Converts this Long to its little endian byte representation. + * @this {!Long} + * @returns {!Array.} Little endian byte representation + */ +LongPrototype.toBytesLE = function toBytesLE() { + var hi = this.high, + lo = this.low; + return [ + lo & 0xff, + lo >>> 8 & 0xff, + lo >>> 16 & 0xff, + lo >>> 24 , + hi & 0xff, + hi >>> 8 & 0xff, + hi >>> 16 & 0xff, + hi >>> 24 + ]; +}; + +/** + * Converts this Long to its big endian byte representation. + * @this {!Long} + * @returns {!Array.} Big endian byte representation + */ +LongPrototype.toBytesBE = function toBytesBE() { + var hi = this.high, + lo = this.low; + return [ + hi >>> 24 , + hi >>> 16 & 0xff, + hi >>> 8 & 0xff, + hi & 0xff, + lo >>> 24 , + lo >>> 16 & 0xff, + lo >>> 8 & 0xff, + lo & 0xff + ]; +}; + +/** + * Creates a Long from its byte representation. + * @param {!Array.} bytes Byte representation + * @param {boolean=} unsigned Whether unsigned or not, defaults to signed + * @param {boolean=} le Whether little or big endian, defaults to big endian + * @returns {Long} The corresponding Long value + */ +Long.fromBytes = function fromBytes(bytes, unsigned, le) { + return le ? Long.fromBytesLE(bytes, unsigned) : Long.fromBytesBE(bytes, unsigned); +}; + +/** + * Creates a Long from its little endian byte representation. + * @param {!Array.} bytes Little endian byte representation + * @param {boolean=} unsigned Whether unsigned or not, defaults to signed + * @returns {Long} The corresponding Long value + */ +Long.fromBytesLE = function fromBytesLE(bytes, unsigned) { + return new Long( + bytes[0] | + bytes[1] << 8 | + bytes[2] << 16 | + bytes[3] << 24, + bytes[4] | + bytes[5] << 8 | + bytes[6] << 16 | + bytes[7] << 24, + unsigned + ); +}; + +/** + * Creates a Long from its big endian byte representation. + * @param {!Array.} bytes Big endian byte representation + * @param {boolean=} unsigned Whether unsigned or not, defaults to signed + * @returns {Long} The corresponding Long value + */ +Long.fromBytesBE = function fromBytesBE(bytes, unsigned) { + return new Long( + bytes[4] << 24 | + bytes[5] << 16 | + bytes[6] << 8 | + bytes[7], + bytes[0] << 24 | + bytes[1] << 16 | + bytes[2] << 8 | + bytes[3], + unsigned + ); +}; diff --git a/BigNumber64Demo/assets/Script/libs/long.js.meta b/BigNumber64Demo/assets/Script/libs/long.js.meta new file mode 100644 index 0000000..b97379c --- /dev/null +++ b/BigNumber64Demo/assets/Script/libs/long.js.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.5", + "uuid": "d495a67e-8f57-4dfb-9d2f-4e2565cee8d0", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/BigNumber64Demo/assets/Texture.meta b/BigNumber64Demo/assets/Texture.meta new file mode 100644 index 0000000..f483d19 --- /dev/null +++ b/BigNumber64Demo/assets/Texture.meta @@ -0,0 +1,6 @@ +{ + "ver": "1.0.1", + "uuid": "7b81d4e8-ec84-4716-968d-500ac1d78a54", + "isGroup": false, + "subMetas": {} +} \ No newline at end of file diff --git a/BigNumber64Demo/assets/Texture/HelloWorld.png b/BigNumber64Demo/assets/Texture/HelloWorld.png new file mode 100644 index 0000000..21d4326 Binary files /dev/null and b/BigNumber64Demo/assets/Texture/HelloWorld.png differ diff --git a/BigNumber64Demo/assets/Texture/HelloWorld.png.meta b/BigNumber64Demo/assets/Texture/HelloWorld.png.meta new file mode 100644 index 0000000..9c52a59 --- /dev/null +++ b/BigNumber64Demo/assets/Texture/HelloWorld.png.meta @@ -0,0 +1,30 @@ +{ + "ver": "1.0.0", + "uuid": "6aa0aa6a-ebee-4155-a088-a687a6aadec4", + "type": "sprite", + "wrapMode": "clamp", + "filterMode": "bilinear", + "subMetas": { + "HelloWorld": { + "ver": "1.0.3", + "uuid": "31bc895a-c003-4566-a9f3-2e54ae1c17dc", + "rawTextureUuid": "6aa0aa6a-ebee-4155-a088-a687a6aadec4", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 0, + "trimY": 0, + "width": 195, + "height": 270, + "rawWidth": 195, + "rawHeight": 270, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "subMetas": {} + } + } +} \ No newline at end of file diff --git a/BigNumber64Demo/assets/Texture/singleColor.png b/BigNumber64Demo/assets/Texture/singleColor.png new file mode 100644 index 0000000..ea5bd0b Binary files /dev/null and b/BigNumber64Demo/assets/Texture/singleColor.png differ diff --git a/BigNumber64Demo/assets/Texture/singleColor.png.meta b/BigNumber64Demo/assets/Texture/singleColor.png.meta new file mode 100644 index 0000000..89cdf74 --- /dev/null +++ b/BigNumber64Demo/assets/Texture/singleColor.png.meta @@ -0,0 +1,30 @@ +{ + "ver": "1.0.0", + "uuid": "a8027877-d8d6-4645-97a0-52d4a0123dba", + "type": "sprite", + "wrapMode": "clamp", + "filterMode": "bilinear", + "subMetas": { + "singleColor": { + "ver": "1.0.3", + "uuid": "410fb916-8721-4663-bab8-34397391ace7", + "rawTextureUuid": "a8027877-d8d6-4645-97a0-52d4a0123dba", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 0, + "trimY": 0, + "width": 2, + "height": 2, + "rawWidth": 2, + "rawHeight": 2, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "subMetas": {} + } + } +} \ No newline at end of file diff --git a/BigNumber64Demo/creator.d.ts b/BigNumber64Demo/creator.d.ts new file mode 100644 index 0000000..9714d9c --- /dev/null +++ b/BigNumber64Demo/creator.d.ts @@ -0,0 +1,20635 @@ + +/** !#en +The main namespace of Cocos2d-JS, all engine core classes, functions, properties and constants are defined in this namespace. +!#zh +Cocos 引擎的主要命名空间,引擎代码中所有的类,函数,属性和常量都在这个命名空间中定义。 */ +declare module cc { + /** The current version of Cocos2d being used.
+ Please DO NOT remove this String, it is an important flag for bug tracking.
+ If you post a bug to forum, please attach this flag. */ + export var ENGINE_VERSION: string; + /** The element contains the game canvas */ + export var container: HTMLDivElement; + /** + !#en Init Debug setting. + !#zh 设置调试模式。 + @param mode mode + */ + export function _initDebugSetting(mode: DebugMode): void; + /** + !#en + Outputs an error message to the Cocos Creator Console (editor) or Web Console (runtime).
+ - In Cocos Creator, error is red.
+ - In Chrome, error have a red icon along with red message text.
+ !#zh + 输出错误消息到 Cocos Creator 编辑器的 Console 或运行时页面端的 Console 中。
+ - 在 Cocos Creator 中,错误信息显示是红色的。
+ - 在 Chrome 中,错误信息有红色的图标以及红色的消息文本。
+ @param msg A JavaScript string containing zero or more substitution strings. + @param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output. + */ + export function error(msg: any, ...subst: any[]): void; + /** + !#en + Outputs a warning message to the Cocos Creator Console (editor) or Web Console (runtime). + - In Cocos Creator, warning is yellow. + - In Chrome, warning have a yellow warning icon with the message text. + !#zh + 输出警告消息到 Cocos Creator 编辑器的 Console 或运行时 Web 端的 Console 中。
+ - 在 Cocos Creator 中,警告信息显示是黄色的。
+ - 在 Chrome 中,警告信息有着黄色的图标以及黄色的消息文本。
+ @param msg A JavaScript string containing zero or more substitution strings. + @param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output. + */ + export function warn(msg: any, ...subst: any[]): void; + /** + !#en Outputs a message to the Cocos Creator Console (editor) or Web Console (runtime). + !#zh 输出一条消息到 Cocos Creator 编辑器的 Console 或运行时 Web 端的 Console 中。 + @param msg A JavaScript string containing zero or more substitution strings. + @param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output. + */ + export function log(msg: string|any, ...subst: any[]): void; + /** + !#en + Outputs an informational message to the Cocos Creator Console (editor) or Web Console (runtime). + - In Cocos Creator, info is blue. + - In Firefox and Chrome, a small "i" icon is displayed next to these items in the Web Console's log. + !#zh + 输出一条信息消息到 Cocos Creator 编辑器的 Console 或运行时 Web 端的 Console 中。 + - 在 Cocos Creator 中,Info 信息显示是蓝色的。
+ - 在 Firefox 和 Chrome 中,Info 信息有着小 “i” 图标。 + @param msg A JavaScript string containing zero or more substitution strings. + @param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output. + */ + export function info(msg: any, ...subst: any[]): void; + /** + !#en + Creates the speed action which changes the speed of an action, making it take longer (speed > 1) + or less (speed < 1) time.
+ Useful to simulate 'slow motion' or 'fast forward' effect. + !#zh 修改目标动作的速率。 + @param action action + @param speed speed + + @example + ```js + // change the target action speed; + var action = cc.scaleTo(0.2, 1, 0.6); + var newAction = cc.speed(action, 0.5); + ``` + */ + export function speed(action: ActionInterval, speed: number): Action; + /** + !#en Create a follow action which makes its target follows another node. + !#zh 追踪目标节点的位置。 + @param followedNode followedNode + @param rect rect + + @example + ```js + // example + // creates the action with a set boundary + var followAction = cc.follow(targetNode, cc.rect(0, 0, screenWidth * 2 - 100, screenHeight)); + node.runAction(followAction); + + // creates the action with no boundary set + var followAction = cc.follow(targetNode); + node.runAction(followAction); + ``` + */ + export function follow(followedNode: Node, rect: Rect): Action; + /** + Points setter + @param points points + */ + export function setPoints(points: any[]): void; + /** + !#en Creates an action with a Cardinal Spline array of points and tension. + !#zh 按基数样条曲线轨迹移动到目标位置。 + @param duration duration + @param points array of control points + @param tension tension + + @example + ```js + //create a cc.CardinalSplineTo + var action1 = cc.cardinalSplineTo(3, array, 0); + ``` + */ + export function cardinalSplineTo(duration: number, points: any[], tension: number): ActionInterval; + /** + update position of target + @param newPos newPos + */ + export function updatePosition(newPos: Vec2): void; + /** + !#en Creates an action with a Cardinal Spline array of points and tension. + !#zh 按基数样条曲线轨迹移动指定的距离。 + @param duration duration + @param points points + @param tension tension + */ + export function cardinalSplineBy(duration: number, points: any[], tension: number): ActionInterval; + /** + !#en Creates an action with a Cardinal Spline array of points and tension. + !#zh 按 Catmull Rom 样条曲线轨迹移动到目标位置。 + @param dt dt + @param points points + + @example + ```js + var action1 = cc.catmullRomTo(3, array); + ``` + */ + export function catmullRomTo(dt: number, points: any[]): ActionInterval; + /** + !#en Creates an action with a Cardinal Spline array of points and tension. + !#zh 按 Catmull Rom 样条曲线轨迹移动指定的距离。 + @param dt dt + @param points points + + @example + ```js + var action1 = cc.catmullRomBy(3, array); + ``` + */ + export function catmullRomBy(dt: number, points: any[]): ActionInterval; + /** + !#en + Creates the action easing object with the rate parameter.
+ From slow to fast. + !#zh 创建 easeIn 缓动对象,由慢到快。 + @param rate rate + + @example + ```js + action.easing(cc.easeIn(3.0)); + ``` + */ + export function easeIn(rate: number): any; + /** + !#en + Creates the action easing object with the rate parameter.
+ From fast to slow. + !#zh 创建 easeOut 缓动对象,由快到慢。 + @param rate rate + + @example + ```js + action.easing(cc.easeOut(3.0)); + ``` + */ + export function easeOut(rate: number): any; + /** + !#en + Creates the action easing object with the rate parameter.
+ Slow to fast then to slow. + !#zh 创建 easeInOut 缓动对象,慢到快,然后慢。 + @param rate rate + + @example + ```js + action.easing(cc.easeInOut(3.0)); + ``` + */ + export function easeInOut(rate: number): any; + /** + !#en + Creates the action easing object with the rate parameter.
+ Reference easeInExpo:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeExponentialIn 缓动对象。
+ EaseExponentialIn 是按指数函数缓动进入的动作。
+ 参考 easeInExpo:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + action.easing(cc.easeExponentialIn()); + ``` + */ + export function easeExponentialIn(): any; + /** + !#en + Creates the action easing object.
+ Reference easeOutExpo:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeExponentialOut 缓动对象。
+ EaseExponentialOut 是按指数函数缓动退出的动作。
+ 参考 easeOutExpo:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + action.easing(cc.easeExponentialOut()); + ``` + */ + export function easeExponentialOut(): any; + /** + !#en + Creates an EaseExponentialInOut action easing object.
+ Reference easeInOutExpo:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeExponentialInOut 缓动对象。
+ EaseExponentialInOut 是按指数函数缓动进入并退出的动作。
+ 参考 easeInOutExpo:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + action.easing(cc.easeExponentialInOut()); + ``` + */ + export function easeExponentialInOut(): any; + /** + !#en + Creates an EaseSineIn action.
+ Reference easeInSine:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 EaseSineIn 缓动对象。
+ EaseSineIn 是按正弦函数缓动进入的动作。
+ 参考 easeInSine:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + action.easing(cc.easeSineIn()); + ``` + */ + export function easeSineIn(): any; + /** + !#en + Creates an EaseSineOut action easing object.
+ Reference easeOutSine:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 EaseSineOut 缓动对象。
+ EaseSineIn 是按正弦函数缓动退出的动作。
+ 参考 easeOutSine:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + action.easing(cc.easeSineOut()); + ``` + */ + export function easeSineOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInOutSine:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeSineInOut 缓动对象。
+ EaseSineIn 是按正弦函数缓动进入并退出的动作。
+ 参考 easeInOutSine:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + action.easing(cc.easeSineInOut()); + ``` + */ + export function easeSineInOut(): any; + /** + !#en + Creates the action easing obejct with the period in radians (default is 0.3).
+ Reference easeInElastic:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeElasticIn 缓动对象。
+ EaseElasticIn 是按弹性曲线缓动进入的动作。
+ 参数 easeInElastic:http://www.zhihu.com/question/21981571/answer/19925418 + @param period period + + @example + ```js + // example + action.easing(cc.easeElasticIn(3.0)); + ``` + */ + export function easeElasticIn(period: number): any; + /** + !#en + Creates the action easing object with the period in radians (default is 0.3).
+ Reference easeOutElastic:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeElasticOut 缓动对象。
+ EaseElasticOut 是按弹性曲线缓动退出的动作。
+ 参考 easeOutElastic:http://www.zhihu.com/question/21981571/answer/19925418 + @param period period + + @example + ```js + // example + action.easing(cc.easeElasticOut(3.0)); + ``` + */ + export function easeElasticOut(period: number): any; + /** + !#en + Creates the action easing object with the period in radians (default is 0.3).
+ Reference easeInOutElastic:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeElasticInOut 缓动对象。
+ EaseElasticInOut 是按弹性曲线缓动进入并退出的动作。
+ 参考 easeInOutElastic:http://www.zhihu.com/question/21981571/answer/19925418 + @param period period + + @example + ```js + // example + action.easing(cc.easeElasticInOut(3.0)); + ``` + */ + export function easeElasticInOut(period: number): any; + /** + !#en + Creates the action easing object.
+ Eased bounce effect at the beginning. + !#zh + 创建 easeBounceIn 缓动对象。
+ EaseBounceIn 是按弹跳动作缓动进入的动作。 + + @example + ```js + // example + action.easing(cc.easeBounceIn()); + ``` + */ + export function easeBounceIn(): any; + /** + !#en + Creates the action easing object.
+ Eased bounce effect at the ending. + !#zh + 创建 easeBounceOut 缓动对象。
+ EaseBounceOut 是按弹跳动作缓动退出的动作。 + + @example + ```js + // example + action.easing(cc.easeBounceOut()); + ``` + */ + export function easeBounceOut(): any; + /** + !#en + Creates the action easing object.
+ Eased bounce effect at the begining and ending. + !#zh + 创建 easeBounceInOut 缓动对象。
+ EaseBounceInOut 是按弹跳动作缓动进入并退出的动作。 + + @example + ```js + // example + action.easing(cc.easeBounceInOut()); + ``` + */ + export function easeBounceInOut(): any; + /** + !#en + Creates the action easing object.
+ In the opposite direction to move slowly, and then accelerated to the right direction. + !#zh + 创建 easeBackIn 缓动对象。
+ easeBackIn 是在相反的方向缓慢移动,然后加速到正确的方向。
+ + @example + ```js + // example + action.easing(cc.easeBackIn()); + ``` + */ + export function easeBackIn(): any; + /** + !#en + Creates the action easing object.
+ Fast moving more than the finish, and then slowly back to the finish. + !#zh + 创建 easeBackOut 缓动对象。
+ easeBackOut 快速移动超出目标,然后慢慢回到目标点。 + + @example + ```js + // example + action.easing(cc.easeBackOut()); + ``` + */ + export function easeBackOut(): any; + /** + !#en + Creates the action easing object.
+ Begining of cc.EaseBackIn. Ending of cc.EaseBackOut. + !#zh + 创建 easeBackInOut 缓动对象。
+ + @example + ```js + // example + action.easing(cc.easeBackInOut()); + ``` + */ + export function easeBackInOut(): any; + /** + !#en + Creates the action easing object.
+ Into the 4 reference point.
+ To calculate the motion curve. + !#zh + 创建 easeBezierAction 缓动对象。
+ EaseBezierAction 是按贝塞尔曲线缓动的动作。 + @param p0 The first bezier parameter + @param p1 The second bezier parameter + @param p2 The third bezier parameter + @param p3 The fourth bezier parameter + + @example + ```js + // example + action.easing(cc.easeBezierAction(0.5, 0.5, 1.0, 1.0)); + ``` + */ + export function easeBezierAction(p0: number, p1: number, p2: number, p3: number): any; + /** + !#en + Creates the action easing object.
+ Reference easeInQuad:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuadraticActionIn 缓动对象。
+ EaseQuadraticIn是按二次函数缓动进入的动作。
+ 参考 easeInQuad:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeQuadraticActionIn()); + ``` + */ + export function easeQuadraticActionIn(): any; + /** + !#en + Creates the action easing object.
+ Reference easeOutQuad:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuadraticActionOut 缓动对象。
+ EaseQuadraticOut 是按二次函数缓动退出的动作。
+ 参考 easeOutQuad:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeQuadraticActionOut()); + ``` + */ + export function easeQuadraticActionOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInOutQuad:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuadraticActionInOut 缓动对象。
+ EaseQuadraticInOut 是按二次函数缓动进入并退出的动作。
+ 参考 easeInOutQuad:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeQuadraticActionInOut()); + ``` + */ + export function easeQuadraticActionInOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeIntQuart:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuarticActionIn 缓动对象。
+ EaseQuarticIn 是按四次函数缓动进入的动作。
+ 参考 easeIntQuart:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeQuarticActionIn()); + ``` + */ + export function easeQuarticActionIn(): any; + /** + !#en + Creates the action easing object.
+ Reference easeOutQuart:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuarticActionOut 缓动对象。
+ EaseQuarticOut 是按四次函数缓动退出的动作。
+ 参考 easeOutQuart:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.QuarticActionOut()); + ``` + */ + export function easeQuarticActionOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInOutQuart:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuarticActionInOut 缓动对象。
+ EaseQuarticInOut 是按四次函数缓动进入并退出的动作。
+ 参考 easeInOutQuart:http://www.zhihu.com/question/21981571/answer/19925418 + */ + export function easeQuarticActionInOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInQuint:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuinticActionIn 缓动对象。
+ EaseQuinticIn 是按五次函数缓动进的动作。
+ 参考 easeInQuint:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeQuinticActionIn()); + ``` + */ + export function easeQuinticActionIn(): any; + /** + !#en + Creates the action easing object.
+ Reference easeOutQuint:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuinticActionOut 缓动对象。
+ EaseQuinticOut 是按五次函数缓动退出的动作 + 参考 easeOutQuint:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeQuadraticActionOut()); + ``` + */ + export function easeQuinticActionOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInOutQuint:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuinticActionInOut 缓动对象。
+ EaseQuinticInOut是按五次函数缓动进入并退出的动作。
+ 参考 easeInOutQuint:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeQuinticActionInOut()); + ``` + */ + export function easeQuinticActionInOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInCirc:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeCircleActionIn 缓动对象。
+ EaseCircleIn是按圆形曲线缓动进入的动作。
+ 参考 easeInCirc:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeCircleActionIn()); + ``` + */ + export function easeCircleActionIn(): any; + /** + !#en + Creates the action easing object.
+ Reference easeOutCirc:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeCircleActionOut 缓动对象。
+ EaseCircleOut是按圆形曲线缓动退出的动作。
+ 参考 easeOutCirc:http://www.zhihu.com/question/21981571/answer/19925418 + */ + export function easeCircleActionOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInOutCirc:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeCircleActionInOut 缓动对象。
+ EaseCircleInOut 是按圆形曲线缓动进入并退出的动作。
+ 参考 easeInOutCirc:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeCircleActionInOut()); + ``` + */ + export function easeCircleActionInOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInCubic:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeCubicActionIn 缓动对象。
+ EaseCubicIn 是按三次函数缓动进入的动作。
+ 参考 easeInCubic:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeCubicActionIn()); + ``` + */ + export function easeCubicActionIn(): any; + /** + !#en + Creates the action easing object.
+ Reference easeOutCubic:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeCubicActionOut 缓动对象。
+ EaseCubicOut 是按三次函数缓动退出的动作。
+ 参考 easeOutCubic:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeCubicActionOut()); + ``` + */ + export function easeCubicActionOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInOutCubic:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeCubicActionInOut 缓动对象。
+ EaseCubicInOut是按三次函数缓动进入并退出的动作。
+ 参考 easeInOutCubic:http://www.zhihu.com/question/21981571/answer/19925418 + */ + export function easeCubicActionInOut(): any; + /** + !#en Show the Node. + !#zh 立即显示。 + + @example + ```js + // example + var showAction = cc.show(); + ``` + */ + export function show(): ActionInstant; + /** + !#en Hide the node. + !#zh 立即隐藏。 + + @example + ```js + // example + var hideAction = cc.hide(); + ``` + */ + export function hide(): ActionInstant; + /** + !#en Toggles the visibility of a node. + !#zh 显隐状态切换。 + + @example + ```js + // example + var toggleVisibilityAction = cc.toggleVisibility(); + ``` + */ + export function toggleVisibility(): ActionInstant; + /** + !#en Create a RemoveSelf object with a flag indicate whether the target should be cleaned up while removing. + !#zh 从父节点移除自身。 + @param isNeedCleanUp isNeedCleanUp + + @example + ```js + // example + var removeSelfAction = cc.removeSelf(); + ``` + */ + export function removeSelf(isNeedCleanUp ?: boolean): ActionInstant; + /** + !#en Create a FlipX action to flip or unflip the target. + !#zh X轴翻转。 + @param flip Indicate whether the target should be flipped or not + + @example + ```js + var flipXAction = cc.flipX(true); + ``` + */ + export function flipX(flip: boolean): ActionInstant; + /** + !#en Create a FlipY action to flip or unflip the target. + !#zh Y轴翻转。 + @param flip flip + + @example + ```js + var flipYAction = cc.flipY(true); + ``` + */ + export function flipY(flip: boolean): ActionInstant; + /** + !#en Creates a Place action with a position. + !#zh 放置在目标位置。 + @param pos pos + @param y y + + @example + ```js + // example + var placeAction = cc.place(cc.p(200, 200)); + var placeAction = cc.place(200, 200); + ``` + */ + export function place(pos: Vec2|number, y?: number): ActionInstant; + /** + !#en Creates the action with the callback. + !#zh 执行回调函数。 + @param selector selector + @param selectorTarget selectorTarget + @param data data for function, it accepts all data types. + + @example + ```js + // example + // CallFunc without data + var finish = cc.callFunc(this.removeSprite, this); + + // CallFunc with data + var finish = cc.callFunc(this.removeFromParentAndCleanup, this._grossini, true); + ``` + */ + export function callFunc(selector: Function, selectorTarget?: any, data?: any): ActionInstant; + /** + !#en + Helper constructor to create an array of sequenceable actions + The created action will run actions sequentially, one after another. + !#zh 顺序执行动作,创建的动作将按顺序依次运行。 + @param actionOrActionArray actionOrActionArray + @param tempArray tempArray + + @example + ```js + // example + // create sequence with actions + var seq = cc.sequence(act1, act2); + + // create sequence with array + var seq = cc.sequence(actArray); + ``` + */ + export function sequence(actionOrActionArray: FiniteTimeAction|FiniteTimeAction[], ...tempArray: FiniteTimeAction[]): ActionInterval; + /** + !#en Creates a Repeat action. Times is an unsigned integer between 1 and pow(2,30) + !#zh 重复动作,可以按一定次数重复一个动,如果想永远重复一个动作请使用 repeatForever 动作来完成。 + @param action action + @param times times + + @example + ```js + // example + var rep = cc.repeat(cc.sequence(jump2, jump1), 5); + ``` + */ + export function repeat(action: FiniteTimeAction, times: number): ActionInterval; + /** + !#en Create a acton which repeat forever, as it runs forever, it can't be added into cc.sequence and cc.spawn. + !#zh 永远地重复一个动作,有限次数内重复一个动作请使用 repeat 动作,由于这个动作不会停止,所以不能被添加到 cc.sequence 或 cc.spawn 中。 + @param action action + + @example + ```js + // example + var repeat = cc.repeatForever(cc.rotateBy(1.0, 360)); + ``` + */ + export function repeatForever(action: FiniteTimeAction): ActionInterval; + /** + !#en Create a spawn action which runs several actions in parallel. + !#zh 同步执行动作,同步执行一组动作。 + @param actionOrActionArray actionOrActionArray + @param tempArray tempArray + + @example + ```js + // example + var action = cc.spawn(cc.jumpBy(2, cc.p(300, 0), 50, 4), cc.rotateBy(2, 720)); + todo:It should be the direct use new + ``` + */ + export function spawn(actionOrActionArray: FiniteTimeAction|FiniteTimeAction[], ...tempArray: FiniteTimeAction[]): FiniteTimeAction; + /** + !#en + Rotates a Node object to a certain angle by modifying its rotation property.
+ The direction will be decided by the shortest angle. + !#zh 旋转到目标角度,通过逐帧修改它的 rotation 属性,旋转方向将由最短的角度决定。 + @param duration duration in seconds + @param deltaAngleX deltaAngleX in degrees. + @param deltaAngleY deltaAngleY in degrees. + + @example + ```js + // example + var rotateTo = cc.rotateTo(2, 61.0); + ``` + */ + export function rotateTo(duration: number, deltaAngleX: number, deltaAngleY?: number): ActionInterval; + /** + !#en + Rotates a Node object clockwise a number of degrees by modifying its rotation property. + Relative to its properties to modify. + !#zh 旋转指定的角度。 + @param duration duration in seconds + @param deltaAngleX deltaAngleX in degrees + @param deltaAngleY deltaAngleY in degrees + + @example + ```js + // example + var actionBy = cc.rotateBy(2, 360); + ``` + */ + export function rotateBy(duration: number, deltaAngleX: number, deltaAngleY?: number): ActionInterval; + /** + !#en + Moves a Node object x,y pixels by modifying its position property.
+ x and y are relative to the position of the object.
+ Several MoveBy actions can be concurrently called, and the resulting
+ movement will be the sum of individual movements. + !#zh 移动指定的距离。 + @param duration duration in seconds + @param deltaPos deltaPos + @param deltaY deltaY + + @example + ```js + // example + var actionTo = cc.moveBy(2, cc.p(windowSize.width - 40, windowSize.height - 40)); + ``` + */ + export function moveBy(duration: number, deltaPos: Vec2|number, deltaY?: number): ActionInterval; + /** + !#en + Moves a Node object to the position x,y. x and y are absolute coordinates by modifying its position property.
+ Several MoveTo actions can be concurrently called, and the resulting
+ movement will be the sum of individual movements. + !#zh 移动到目标位置。 + @param duration duration in seconds + @param position position + @param y y + + @example + ```js + // example + var actionBy = cc.moveTo(2, cc.p(80, 80)); + ``` + */ + export function moveTo(duration: number, position: Vec2|number, y?: number): ActionInterval; + /** + !#en + Create a action which skews a Node object to given angles by modifying its skewX and skewY properties. + Changes to the specified value. + !#zh 偏斜到目标角度。 + @param t time in seconds + @param sx sx + @param sy sy + + @example + ```js + // example + var actionTo = cc.skewTo(2, 37.2, -37.2); + ``` + */ + export function skewTo(t: number, sx: number, sy: number): ActionInterval; + /** + !#en + Skews a Node object by skewX and skewY degrees.
+ Relative to its property modification. + !#zh 偏斜指定的角度。 + @param t time in seconds + @param sx sx skew in degrees for X axis + @param sy sy skew in degrees for Y axis + + @example + ```js + // example + var actionBy = cc.skewBy(2, 0, -90); + ``` + */ + export function skewBy(t: number, sx: number, sy: number): ActionInterval; + /** + !#en + Moves a Node object simulating a parabolic jump movement by modifying it's position property. + Relative to its movement. + !#zh 用跳跃的方式移动指定的距离。 + @param duration duration + @param position position + @param y y + @param height height + @param jumps jumps + + @example + ```js + // example + var actionBy = cc.jumpBy(2, cc.p(300, 0), 50, 4); + var actionBy = cc.jumpBy(2, 300, 0, 50, 4); + ``` + */ + export function jumpBy(duration: number, position: Vec2|number, y?: number, height?: number, jumps?: number): ActionInterval; + /** + !#en + Moves a Node object to a parabolic position simulating a jump movement by modifying its position property.
+ Jump to the specified location. + !#zh 用跳跃的方式移动到目标位置。 + @param duration duration + @param position position + @param y y + @param height height + @param jumps jumps + + @example + ```js + // example + var actionTo = cc.jumpTo(2, cc.p(300, 300), 50, 4); + var actionTo = cc.jumpTo(2, 300, 300, 50, 4); + ``` + */ + export function jumpTo(duration: number, position: Vec2|number, y?: number, height?: number, jumps?: number): ActionInterval; + /** + !#en + An action that moves the target with a cubic Bezier curve by a certain distance. + Relative to its movement. + !#zh 按贝赛尔曲线轨迹移动指定的距离。 + @param t time in seconds + @param c Array of points + + @example + ```js + // example + var bezier = [cc.p(0, windowSize.height / 2), cc.p(300, -windowSize.height / 2), cc.p(300, 100)]; + var bezierForward = cc.bezierBy(3, bezier); + ``` + */ + export function bezierBy(t: number, c: Vec2[]): ActionInterval; + /** + !#en An action that moves the target with a cubic Bezier curve to a destination point. + !#zh 按贝赛尔曲线轨迹移动到目标位置。 + @param t t + @param c Array of points + + @example + ```js + // example + var bezier = [cc.p(0, windowSize.height / 2), cc.p(300, -windowSize.height / 2), cc.p(300, 100)]; + var bezierTo = cc.bezierTo(2, bezier); + ``` + */ + export function bezierTo(t: number, c: Vec2[]): ActionInterval; + /** + !#en Scales a Node object to a zoom factor by modifying it's scale property. + !#zh 将节点大小缩放到指定的倍数。 + @param duration duration + @param sx scale parameter in X + @param sy scale parameter in Y, if Null equal to sx + + @example + ```js + // example + // It scales to 0.5 in both X and Y. + var actionTo = cc.scaleTo(2, 0.5); + + // It scales to 0.5 in x and 2 in Y + var actionTo = cc.scaleTo(2, 0.5, 2); + ``` + */ + export function scaleTo(duration: number, sx: number, sy?: number): ActionInterval; + /** + !#en + Scales a Node object a zoom factor by modifying it's scale property. + Relative to its changes. + !#zh 按指定的倍数缩放节点大小。 + @param duration duration in seconds + @param sx sx scale parameter in X + @param sy sy scale parameter in Y, if Null equal to sx + + @example + ```js + // example without sy, it scales by 2 both in X and Y + var actionBy = cc.scaleBy(2, 2); + + //example with sy, it scales by 0.25 in X and 4.5 in Y + var actionBy2 = cc.scaleBy(2, 0.25, 4.5); + ``` + */ + export function scaleBy(duration: number, sx: number, sy?: number|void): ActionInterval; + /** + !#en Blinks a Node object by modifying it's visible property. + !#zh 闪烁(基于透明度)。 + @param duration duration in seconds + @param blinks blinks in times + + @example + ```js + // example + var action = cc.blink(2, 10); + ``` + */ + export function blink(duration: number, blinks: number): ActionInterval; + /** + !#en + Fades an object that implements the cc.RGBAProtocol protocol. + It modifies the opacity from the current value to a custom one. + !#zh 修改透明度到指定值。 + @param duration duration + @param opacity 0-255, 0 is transparent + + @example + ```js + // example + var action = cc.fadeTo(1.0, 0); + ``` + */ + export function fadeTo(duration: number, opacity: number): ActionInterval; + /** + !#en Fades In an object that implements the cc.RGBAProtocol protocol. It modifies the opacity from 0 to 255. + !#zh 渐显效果。 + @param duration duration in seconds + + @example + ```js + //example + var action = cc.fadeIn(1.0); + ``` + */ + export function fadeIn(duration: number): ActionInterval; + /** + !#en Fades Out an object that implements the cc.RGBAProtocol protocol. It modifies the opacity from 255 to 0. + !#zh 渐隐效果。 + @param d duration in seconds + + @example + ```js + // example + var action = cc.fadeOut(1.0); + ``` + */ + export function fadeOut(d: number): ActionInterval; + /** + !#en Tints a Node that implements the cc.NodeRGB protocol from current tint to a custom one. + !#zh 修改颜色到指定值。 + @param duration duration + @param red 0-255 + @param green 0-255 + @param blue 0-255 + + @example + ```js + // example + var action = cc.tintTo(2, 255, 0, 255); + ``` + */ + export function tintTo(duration: number, red: number, green: number, blue: number): ActionInterval; + /** + !#en + Tints a Node that implements the cc.NodeRGB protocol from current tint to a custom one. + Relative to their own color change. + !#zh 按照指定的增量修改颜色。 + @param duration duration in seconds + @param deltaRed deltaRed + @param deltaGreen deltaGreen + @param deltaBlue deltaBlue + + @example + ```js + // example + var action = cc.tintBy(2, -127, -255, -127); + ``` + */ + export function tintBy(duration: number, deltaRed: number, deltaGreen: number, deltaBlue: number): ActionInterval; + /** + !#en Delays the action a certain amount of seconds. + !#en 延迟指定的时间量。 + @param d duration in seconds + + @example + ```js + // example + var delay = cc.delayTime(1); + ``` + */ + export function delayTime(d: number): ActionInterval; + /** + !#en Executes an action in reverse order, from time=duration to time=0. + !#zh 反转目标动作的时间轴。 + @param action action + + @example + ```js + // example + var reverse = cc.reverseTime(this); + ``` + */ + export function reverseTime(action: FiniteTimeAction): ActionInterval; + /** + !#en Create an action with the specified action and forced target. + !#zh 用已有动作和一个新的目标节点创建动作。 + @param target target + @param action action + */ + export function targetedAction(target: Node, action: FiniteTimeAction): ActionInterval; + /** !#en cc.view is the shared view object. + !#zh cc.view 是全局的视图对象。 */ + export var view: View; + /** !#en Director + !#zh 导演类。 */ + export var director: Director; + /** !#en cc.winSize is the alias object for the size of the current game window. + !#zh cc.winSize 为当前的游戏窗口的大小。 */ + export var winSize: Size; + export var game: Game; + /** !#en The System event singleton for global usage + !#zh 系统事件单例,方便全局使用 */ + export var systemEvent: SystemEvent; + /** + + @param touches touches + */ + export function handleTouchesBegin(touches: any[]): void; + /** + + @param touches touches + */ + export function handleTouchesMove(touches: any[]): void; + /** + + @param touches touches + */ + export function handleTouchesEnd(touches: any[]): void; + /** + + @param touches touches + */ + export function handleTouchesCancel(touches: any[]): void; + /** + + @param touches touches + */ + export function getSetOfTouchesEndOrCancel(touches: any[]): any[]; + /** + + @param element element + */ + export function getHTMLElementPosition(element: HTMLElement): any; + /** + + @param touch touch + */ + export function getPreTouch(touch: Touch): Touch; + /** + + @param touch touch + */ + export function setPreTouch(touch: Touch): void; + /** + + @param tx tx + @param ty ty + @param pos pos + */ + export function getTouchByXY(tx: number, ty: number, pos: Vec2): Touch; + /** + + @param event event + @param pos pos + */ + export function getPointByEvent(event: Touch, pos: Vec2): Vec2; + /** + + @param event event + @param pos pos + */ + export function getTouchesByEvent(event: Touch, pos: Vec2): any[]; + /** + + @param element element + */ + export function registerSystemEvent(element: HTMLElement): void; + /** + !#en Defines a CCClass using the given specification, please see [Class](/docs/editors_and_tools/creator-chapters/scripting/class.html) for details. + !#zh 定义一个 CCClass,传入参数必须是一个包含类型参数的字面量对象,具体用法请查阅[类型定义](/docs/creator/scripting/class.html)。 + @param options options + + @example + ```js + // define base class + var Node = cc.Class(); + + // define sub class + var Sprite = cc.Class({ + name: 'Sprite', + extends: Node, + ctor: function () { + this.url = ""; + this.id = 0; + }, + + statics: { + // define static members + count: 0, + getBounds: function (spriteList) { + // compute bounds... + } + }, + + properties { + width: { + default: 128, + type: 'Integer', + tooltip: 'The width of sprite' + }, + height: 128, + size: { + get: function () { + return cc.v2(this.width, this.height); + } + } + }, + + load: function () { + // load this.url... + }; + }); + + // instantiate + + var obj = new Sprite(); + obj.url = 'sprite.png'; + obj.load(); + ``` + */ + export function Class(options?: {name?: string; extends?: Function; ctor?: Function; __ctor__?: Function; properties?: any; statics?: any; mixins?: Function[]; editor?: {executeInEditMode?: boolean; requireComponent?: Function; menu?: string; executionOrder?: number; disallowMultiple?: boolean; playOnFocus?: boolean; inspector?: string; icon?: string; help?: string; }; update?: Function; lateUpdate?: Function; onLoad?: Function; start?: Function; onEnable?: Function; onDisable?: Function; onDestroy?: Function; onFocusInEditor?: Function; onLostFocusInEditor?: Function; resetInEditor?: Function; onRestore?: Function; _getLocalBounds?: Function; }): Function; + /** + Checks whether subclass is child of superclass or equals to superclass + @param subclass subclass + @param superclass superclass + */ + export function isChildClassOf(subclass: Function, superclass: Function): boolean; + /** + Return all super classes + @param constructor constructor + */ + export function getInheritanceChain(constructor: Function): Function[]; + /** + !#en + Define an enum type.
+ If a enum item has a value of -1, it will be given an Integer number according to it's order in the list.
+ Otherwise it will use the value specified by user who writes the enum definition. + + !#zh + 定义一个枚举类型。
+ 用户可以把枚举值设为任意的整数,如果设为 -1,系统将会分配为上一个枚举值 + 1。 + @param obj a JavaScript literal object containing enum names and values, or a TypeScript enum type + + @example + ```js + // JavaScript: + + var WrapMode = cc.Enum({ + Repeat: -1, + Clamp: -1 + }); + + // Texture.WrapMode.Repeat == 0 + // Texture.WrapMode.Clamp == 1 + // Texture.WrapMode[0] == "Repeat" + // Texture.WrapMode[1] == "Clamp" + + var FlagType = cc.Enum({ + Flag1: 1, + Flag2: 2, + Flag3: 4, + Flag4: 8, + }); + + var AtlasSizeList = cc.Enum({ + 128: 128, + 256: 256, + 512: 512, + 1024: 1024, + }); + + // TypeScript: + + // If used in TypeScript, just define a TypeScript enum: + enum Direction { + Up, + Down, + Left, + Right + } + + // If you need to inspect the enum in Properties panel, you can call cc.Enum: + const {ccclass, property} = cc._decorator; + + @ccclass + class NewScript extends cc.Component { + @property({ + default: Direction.Up, + type: cc.Enum(Direction) // call cc.Enum + }) + direction: Direction = Direction.Up; + } + + ``` + */ + export function Enum(obj: T): T; + /** + whether enable accelerometer event + @param isEnable isEnable + */ + export function setAccelerometerEnabled(isEnable: boolean): void; + /** + set accelerometer interval value + @param interval interval + */ + export function setAccelerometerInterval(interval: number): void; + /** + + @param touches touches + */ + export function handleTouchesBegin(touches: any[]): void; + /** + + @param touches touches + */ + export function handleTouchesMove(touches: any[]): void; + /** + + @param touches touches + */ + export function handleTouchesEnd(touches: any[]): void; + /** + + @param touches touches + */ + export function handleTouchesCancel(touches: any[]): void; + /** + + @param touches touches + */ + export function getSetOfTouchesEndOrCancel(touches: any[]): any[]; + /** + + @param element element + */ + export function getHTMLElementPosition(element: HTMLElement): any; + /** + + @param touch touch + */ + export function getPreTouch(touch: Touch): Touch; + /** + + @param touch touch + */ + export function setPreTouch(touch: Touch): void; + /** + + @param tx tx + @param ty ty + @param pos pos + */ + export function getTouchByXY(tx: number, ty: number, pos: Vec2): Touch; + /** + + @param location location + @param pos pos + @param eventType eventType + */ + export function getTouchByXY(location: Vec2, pos: Vec2, eventType: number): Event.EventMouse; + /** + + @param event event + @param pos pos + */ + export function getPointByEvent(event: Touch, pos: Vec2): Vec2; + /** + + @param event event + @param pos pos + */ + export function getTouchesByEvent(event: Touch, pos: Vec2): any[]; + /** + + @param element element + */ + export function registerSystemEvent(element: HTMLElement): void; + /** + + @param dt dt + */ + export function update(dt: number): void; + /** +

+ Linear interpolation between 2 numbers, the ratio sets how much it is biased to each end +

+ @param a number A + @param b number B + @param r ratio between 0 and 1 + + @example + ```js + ---- + lerp + cc.lerp(2,10,0.5)//returns 6 + cc.lerp(2,10,0.2)//returns 3.6 + + ``` + */ + export function lerp(a: number, b: number, r: number): void; + /** + get a random number from 0 to 0xffffff + */ + export function rand(): number; + /** + returns a random float between -1 and 1 + */ + export function randomMinus1To1(): number; + /** + returns a random float between 0 and 1, use Math.random directly + */ + export function random0To1(): number; + /** + converts degrees to radians + @param angle angle + */ + export function degreesToRadians(angle: number): number; + /** + converts radians to degrees + @param angle angle + */ + export function radiansToDegrees(angle: number): number; + /** + Helpful macro that setups the GL server state, the correct GL program and sets the Model View Projection matrix + @param node setup node + */ + export function nodeDrawSetup(node: Node): void; + /** +

+ Increments the GL Draws counts by one.
+ The number of calls per frame are displayed on the screen when the CCDirector's stats are enabled.
+

+ @param addNumber addNumber + */ + export function incrementGLDraws(addNumber: number): void; + /** + Check webgl error.Error will be shown in console if exists. + */ + export function checkGLErrorDebug(): void; + /** + !#en + Checks whether the object is non-nil and not yet destroyed.
+ When an object's `destroy` is called, it is actually destroyed after the end of this frame. + So `isValid` will return false from the next frame, while `isValid` in the current frame will still be true. + If you want to determine whether the current frame has called `destroy`, use `cc.isValid(obj, true)`, + but this is often caused by a particular logical requirements, which is not normally required. + + !#zh + 检查该对象是否不为 null 并且尚未销毁。
+ 当一个对象的 `destroy` 调用以后,会在这一帧结束后才真正销毁。因此从下一帧开始 `isValid` 就会返回 false,而当前帧内 `isValid` 仍然会是 true。如果希望判断当前帧是否调用过 `destroy`,请使用 `cc.isValid(obj, true)`,不过这往往是特殊的业务需求引起的,通常情况下不需要这样。 + @param value value + @param strictMode If true, Object called destroy() in this frame will also treated as invalid. + + @example + ```js + var node = new cc.Node(); + cc.log(cc.isValid(node)); // true + node.destroy(); + cc.log(cc.isValid(node)); // true, still valid in this frame + // after a frame... + cc.log(cc.isValid(node)); // false, destroyed in the end of last frame + ``` + */ + export function isValid(value: any, strictMode?: boolean): boolean; + /** Specify that the input value must be integer in Inspector. + Also used to indicates that the elements in array should be type integer. */ + export var Integer: string; + /** Indicates that the elements in array should be type double. */ + export var Float: string; + /** Indicates that the elements in array should be type boolean. */ + export var Boolean: string; + /** Indicates that the elements in array should be type string. */ + export var String: string; + /** + !#en Deserialize json to cc.Asset + !#zh 将 JSON 反序列化为对象实例。 + + 当指定了 target 选项时,如果 target 引用的其它 asset 的 uuid 不变,则不会改变 target 对 asset 的引用, + 也不会将 uuid 保存到 result 对象中。 + @param data the serialized cc.Asset json string or json object. + @param details additional loading result + @param options options + */ + export function deserialize(data: string|any, details?: Details, options?: any): any; + /** + !#en Clones the object `original` and returns the clone, or instantiate a node from the Prefab. + !#zh 克隆指定的任意类型的对象,或者从 Prefab 实例化出新节点。 + + (Instantiate 时,function 和 dom 等非可序列化对象会直接保留原有引用,Asset 会直接进行浅拷贝,可序列化类型会进行深拷贝。) + @param original An existing object that you want to make a copy of. + + @example + ```js + // instantiate node from prefab + var scene = cc.director.getScene(); + var node = cc.instantiate(prefabAsset); + node.parent = scene; + // clone node + var scene = cc.director.getScene(); + var node = cc.instantiate(targetNode); + node.parent = scene; + ``` + */ + export function instantiate(original: Prefab): Node; + export function instantiate(original: T): T; + /** + Finds a node by hierarchy path, the path is case-sensitive. + It will traverse the hierarchy by splitting the path using '/' character. + This function will still returns the node even if it is inactive. + It is recommended to not use this function every frame instead cache the result at startup. + @param path path + @param referenceNode referenceNode + */ + export function find(path: string, referenceNode?: Node): Node; + /** + !#en + The convenience method to create a new {{#crossLink "Color/Color:method"}}cc.Color{{/crossLink}} + Alpha channel is optional. Default value is 255. + + !#zh + 通过该方法来创建一个新的 {{#crossLink "Color/Color:method"}}cc.Color{{/crossLink}} 对象。 + Alpha 通道是可选的。默认值是 255。 + @param r r + @param g g + @param b b + @param a a + + @example + ```js + ----------------------- + // 1. All channels seperately as parameters + var color1 = new cc.Color(255, 255, 255, 255); + // 2. Convert a hex string to a color + var color2 = new cc.Color("#000000"); + // 3. An color object as parameter + var color3 = new cc.Color({r: 255, g: 255, b: 255, a: 255}); + + ``` + */ + export function color(r?: number, g?: number, b?: number, a?: number): Color; + /** + !#en returns true if both ccColor3B are equal. Otherwise it returns false. + !#zh 判断两个颜色对象的 RGB 部分是否相等,不比较透明度。 + @param color1 color1 + @param color2 color2 + + @example + ```js + cc.log(cc.colorEqual(cc.Color.RED, new cc.Color(255, 0, 0))); // true + ``` + */ + export function colorEqual(color1: Color, color2: Color): boolean; + /** + !#en + convert a string of color for style to Color. + e.g. "#ff06ff" to : cc.color(255,6,255)。 + !#zh 16 进制转换为 Color + @param hex hex + + @example + ```js + cc.hexToColor("#FFFF33"); // Color {r: 255, g: 255, b: 51, a: 255}; + ``` + */ + export function hexToColor(hex: string): Color; + /** + !#en + convert Color to a string of color for style. + e.g. cc.color(255,6,255) to : "#ff06ff" + !#zh Color 转换为 16进制。 + @param color color + + @example + ```js + var color = new cc.Color(255, 6, 255) + cc.colorToHex(color); // #ff06ff; + ``` + */ + export function colorToHex(color: Color): string; + /** + !#en Returns opposite of Vec2. + !#zh 返回相反的向量。 + @param point point + + @example + ```js + cc.pNeg(cc.v2(10, 10));// Vec2 {x: -10, y: -10}; + ``` + */ + export function pNeg(point: Vec2): Vec2; + /** + !#en Calculates sum of two points. + !#zh 返回两个向量的和。 + @param v1 v1 + @param v2 v2 + + @example + ```js + cc.pAdd(cc.v2(1, 1), cc.v2(2, 2));// Vec2 {x: 3, y: 3}; + ``` + */ + export function pAdd(v1: Vec2, v2: Vec2): Vec2; + /** + !#en Calculates difference of two points. + !#zh 返回两个向量的差。 + @param v1 v1 + @param v2 v2 + + @example + ```js + cc.pSub(cc.v2(20, 20), cc.v2(5, 5)); // Vec2 {x: 15, y: 15}; + ``` + */ + export function pSub(v1: Vec2, v2: Vec2): Vec2; + /** + !#en Returns point multiplied by given factor. + !#zh 向量缩放。 + @param point point + @param floatVar floatVar + + @example + ```js + cc.pMult(cc.v2(5, 5), 4); // Vec2 {x: 20, y: 20}; + ``` + */ + export function pMult(point: Vec2, floatVar: number): Vec2; + /** + !#en Calculates midpoint between two points. + !#zh 两个向量之间的中心点。 + @param v1 v1 + @param v2 v2 + + @example + ```js + cc.pMidpoint(cc.v2(10, 10), cc.v2(5, 5)); // Vec2 {x: 7.5, y: 7.5}; + ``` + */ + export function pMidpoint(v1: Vec2, v2: Vec2): Vec2; + /** + !#en Calculates dot product of two points. + !#zh 两个向量之间进行点乘。 + @param v1 v1 + @param v2 v2 + + @example + ```js + cc.pDot(cc.v2(20, 20), cc.v2(5, 5)); // 200; + ``` + */ + export function pDot(v1: Vec2, v2: Vec2): number; + /** + !#en Calculates cross product of two points. + !#zh 两个向量之间进行叉乘。 + @param v1 v1 + @param v2 v2 + + @example + ```js + cc.pCross(cc.v2(20, 20), cc.v2(5, 5)); // 0; + ``` + */ + export function pCross(v1: Vec2, v2: Vec2): number; + /** + !#en Calculates perpendicular of v, rotated 90 degrees counter-clockwise -- cross(v, perp(v)) greater than 0. + !#zh 返回逆时针旋转 90 度后的新向量。 + @param point point + + @example + ```js + cc.pPerp(cc.v2(20, 20)); // Vec2 {x: -20, y: 20}; + ``` + */ + export function pPerp(point: Vec2): Vec2; + /** + !#en Calculates perpendicular of v, rotated 90 degrees clockwise -- cross(v, rperp(v)) smaller than 0. + !#zh 将指定向量顺时针旋转 90 度并返回。 + @param point point + + @example + ```js + cc.pRPerp(cc.v2(20, 20)); // Vec2 {x: 20, y: -20}; + ``` + */ + export function pRPerp(point: Vec2): Vec2; + /** + !#en Calculates the projection of v1 over v2. + !#zh 返回 v1 在 v2 上的投影向量。 + @param v1 v1 + @param v2 v2 + + @example + ```js + var v1 = cc.v2(20, 20); + var v2 = cc.v2(5, 5); + cc.pProject(v1, v2); // Vec2 {x: 20, y: 20}; + ``` + */ + export function pProject(v1: Vec2, v2: Vec2): Vec2; + /** + !#en Calculates the square length of a cc.Vec2 (not calling sqrt() ). + !#zh 返回指定向量长度的平方。 + @param v v + + @example + ```js + cc.pLengthSQ(cc.v2(20, 20)); // 800; + ``` + */ + export function pLengthSQ(v: Vec2): number; + /** + !#en Calculates the square distance between two points (not calling sqrt() ). + !#zh 返回两个点之间距离的平方。 + @param point1 point1 + @param point2 point2 + + @example + ```js + var point1 = cc.v2(20, 20); + var point2 = cc.v2(5, 5); + cc.pDistanceSQ(point1, point2); // 450; + ``` + */ + export function pDistanceSQ(point1: Vec2, point2: Vec2): number; + /** + !#en Calculates distance between point an origin. + !#zh 返回指定向量的长度. + @param v v + + @example + ```js + cc.pLength(cc.v2(20, 20)); // 28.284271247461902; + ``` + */ + export function pLength(v: Vec2): number; + /** + !#en Calculates the distance between two points. + !#zh 返回指定 2 个向量之间的距离。 + @param v1 v1 + @param v2 v2 + + @example + ```js + var v1 = cc.v2(20, 20); + var v2 = cc.v2(5, 5); + cc.pDistance(v1, v2); // 21.213203435596427; + ``` + */ + export function pDistance(v1: Vec2, v2: Vec2): number; + /** + !#en Returns this vector with a magnitude of 1. + !#zh 返回一个长度为 1 的标准化过后的向量。 + @param v v + + @example + ```js + cc.pNormalize(cc.v2(20, 20)); // Vec2 {x: 0.7071067811865475, y: 0.7071067811865475}; + ``` + */ + export function pNormalize(v: Vec2): Vec2; + /** + !#en Converts radians to a normalized vector. + !#zh 将弧度转换为一个标准化后的向量,返回坐标 x = cos(a) , y = sin(a)。 + @param a a + + @example + ```js + cc.pForAngle(20); // Vec2 {x: 0.40808206181339196, y: 0.9129452507276277}; + ``` + */ + export function pForAngle(a: number): Vec2; + /** + !#en Converts a vector to radians. + !#zh 返回指定向量的弧度。 + @param v v + + @example + ```js + cc.pToAngle(cc.v2(20, 20)); // 0.7853981633974483; + ``` + */ + export function pToAngle(v: Vec2): number; + /** + !#en Clamp a value between from and to. + !#zh + 限定浮点数的最大最小值。
+ 数值大于 max_inclusive 则返回 max_inclusive。
+ 数值小于 min_inclusive 则返回 min_inclusive。
+ 否则返回自身。 + @param value value + @param min_inclusive min_inclusive + @param max_inclusive max_inclusive + + @example + ```js + var v1 = cc.clampf(20, 0, 20); // 20; + var v2 = cc.clampf(-1, 0, 20); // 0; + var v3 = cc.clampf(10, 0, 20); // 10; + ``` + */ + export function clampf(value: number, min_inclusive: number, max_inclusive: number): number; + /** + !#en Clamp a value between 0 and 1. + !#zh 限定浮点数的取值范围为 0 ~ 1 之间。 + @param value value + + @example + ```js + var v1 = cc.clampf(20); // 1; + var v2 = cc.clampf(-1); // 0; + var v3 = cc.clampf(0.5); // 0.5; + ``` + */ + export function clamp01(value: number): number; + /** + !#en Clamp a point between from and to. + !#zh + 返回指定限制区域后的向量。
+ 向量大于 max_inclusive 则返回 max_inclusive。
+ 向量小于 min_inclusive 则返回 min_inclusive。
+ 否则返回自身。 + @param p p + @param min_inclusive min_inclusive + @param max_inclusive max_inclusive + + @example + ```js + var min_inclusive = cc.v2(0, 0); + var max_inclusive = cc.v2(20, 20); + var v1 = cc.pClamp(cc.v2(20, 20), min_inclusive, max_inclusive); // Vec2 {x: 20, y: 20}; + var v2 = cc.pClamp(cc.v2(0, 0), min_inclusive, max_inclusive); // Vec2 {x: 0, y: 0}; + var v3 = cc.pClamp(cc.v2(10, 10), min_inclusive, max_inclusive); // Vec2 {x: 10, y: 10}; + ``` + */ + export function pClamp(p: Vec2, min_inclusive: Vec2, max_inclusive: Vec2): Vec2; + /** + !#en Quickly convert cc.Size to a cc.Vec2. + !#zh 快速转换 cc.Size 为 cc.Vec2。 + @param s s + + @example + ```js + cc.pFromSize(new cc.size(20, 20)); // Vec2 {x: 20, y: 20}; + ``` + */ + export function pFromSize(s: Size): Vec2; + /** + !#en + Run a math operation function on each point component
+ Math.abs, Math.fllor, Math.ceil, Math.round. + !#zh 通过运行指定的数学运算函数来计算指定的向量。 + @param p p + @param opFunc opFunc + + @example + ```js + cc.pCompOp(cc.p(-10, -10), Math.abs); // Vec2 {x: 10, y: 10}; + ``` + */ + export function pCompOp(p: Vec2, opFunc: Function): Vec2; + /** + !#en + Linear Interpolation between two points a and b.
+ alpha == 0 ? a
+ alpha == 1 ? b
+ otherwise a value between a..b. + !#zh + 两个点 A 和 B 之间的线性插值。
+ alpha == 0 ? a
+ alpha == 1 ? b
+ 否则这个数值在 a ~ b 之间。 + @param a a + @param b b + @param alpha alpha + + @example + ```js + cc.pLerp(cc.v2(20, 20), cc.v2(5, 5), 0.5); // Vec2 {x: 12.5, y: 12.5}; + ``` + */ + export function pLerp(a: Vec2, b: Vec2, alpha: number): Vec2; + /** + !#en TODO + !#zh + 近似判断两个点是否相等。
+ 判断 2 个向量是否在指定数值的范围之内,如果在则返回 true,反之则返回 false。 + @param a a + @param b b + @param variance variance + + @example + ```js + var a = cc.v2(20, 20); + var b = cc.v2(5, 5); + var b1 = cc.pFuzzyEqual(a, b, 10); // false; + var b2 = cc.pFuzzyEqual(a, b, 18); // true; + ``` + */ + export function pFuzzyEqual(a: Vec2, b: Vec2, variance: number): boolean; + /** + !#en Multiplies a nd b components, a.x*b.x, a.y*b.y. + !#zh 计算两个向量的每个分量的乘积, a.x * b.x, a.y * b.y。 + @param a a + @param b b + + @example + ```js + cc.pCompMult(acc.v2(20, 20), cc.v2(5, 5)); // Vec2 {x: 100, y: 100}; + ``` + */ + export function pCompMult(a: Vec2, b: Vec2): Vec2; + /** + !#en TODO + !#zh 返回两个向量之间带正负号的弧度。 + @param a a + @param b b + */ + export function pAngleSigned(a: Vec2, b: Vec2): number; + /** + !#en TODO + !#zh 获取当前向量与指定向量之间的弧度角。 + @param a a + @param b b + */ + export function pAngle(a: Vec2, b: Vec2): number; + /** + !#en Rotates a point counter clockwise by the angle around a pivot. + !#zh 返回给定向量围绕指定轴心顺时针旋转一定弧度后的结果。 + @param v v is the point to rotate + @param pivot pivot is the pivot, naturally + @param angle angle is the angle of rotation cw in radians + */ + export function pRotateByAngle(v: Vec2, pivot: Vec2, angle: number): Vec2; + /** + !#en + A general line-line intersection test + indicating successful intersection of a line
+ note that to truly test intersection for segments we have to make
+ sure that s & t lie within [0..1] and for rays, make sure s & t > 0
+ the hit point is p3 + t * (p4 - p3);
+ the hit point also is p1 + s * (p2 - p1); + !#zh + 返回 A 为起点 B 为终点线段 1 所在直线和 C 为起点 D 为终点线段 2 所在的直线是否相交,
+ 如果相交返回 true,反之则为 false,参数 retP 是返回交点在线段 1、线段 2 上的比例。 + @param A A is the startpoint for the first line P1 = (p1 - p2). + @param B B is the endpoint for the first line P1 = (p1 - p2). + @param C C is the startpoint for the second line P2 = (p3 - p4). + @param D D is the endpoint for the second line P2 = (p3 - p4). + @param retP retP.x is the range for a hitpoint in P1 (pa = p1 + s*(p2 - p1)),
+ retP.y is the range for a hitpoint in P3 (pa = p2 + t*(p4 - p3)). + */ + export function pLineIntersect(A: Vec2, B: Vec2, C: Vec2, D: Vec2, retP: Vec2): boolean; + /** + !#en ccpSegmentIntersect return YES if Segment A-B intersects with segment C-D. + !#zh 返回线段 A - B 和线段 C - D 是否相交。 + @param A A + @param B B + @param C C + @param D D + */ + export function pSegmentIntersect(A: Vec2, B: Vec2, C: Vec2, D: Vec2): boolean; + /** + !#en ccpIntersectPoint return the intersection point of line A-B, C-D. + !#zh 返回线段 A - B 和线段 C - D 的交点。 + @param A A + @param B B + @param C C + @param D D + */ + export function pIntersectPoint(A: Vec2, B: Vec2, C: Vec2, D: Vec2): Vec2; + /** + !#en check to see if both points are equal. + !#zh 检查指定的 2 个向量是否相等。 + @param A A ccp a + @param B B ccp b to be compared + */ + export function pSameAs(A: Vec2, B: Vec2): boolean; + /** + !#en sets the position of the point to 0. + !#zh 设置指定向量归 0。 + @param v v + */ + export function pZeroIn(v: Vec2): void; + /** + !#en copies the position of one point to another. + !#zh 令 v1 向量等同于 v2。 + @param v1 v1 + @param v2 v2 + */ + export function pIn(v1: Vec2, v2: Vec2): void; + /** + !#en multiplies the point with the given factor (inplace). + !#zh 向量缩放,结果保存到第一个向量。 + @param point point + @param floatVar floatVar + */ + export function pMultIn(point: Vec2, floatVar: number): void; + /** + !#en subtracts one point from another (inplace). + !#zh 向量减法,结果保存到第一个向量。 + @param v1 v1 + @param v2 v2 + */ + export function pSubIn(v1: Vec2, v2: Vec2): void; + /** + !#en adds one point to another (inplace). + !#zh 向量加法,结果保存到第一个向量。 + @param v1 v1 + @param v2 v2 + */ + export function pAddIn(v1: Vec2, v2: Vec2): void; + /** + !#en normalizes the point (inplace). + !#zh 规范化 v 向量,设置 v 向量长度为 1。 + @param v v + */ + export function pNormalizeIn(v: Vec2): void; + /** + !#en + The convenience method to create a new Rect. + see {{#crossLink "Rect/Rect:method"}}cc.Rect{{/crossLink}} + !#zh + 该方法用来快速创建一个新的矩形。{{#crossLink "Rect/Rect:method"}}cc.Rect{{/crossLink}} + @param x x + @param y y + @param w w + @param h h + + @example + ```js + var a = new cc.Rect(0 , 0, 10, 0); + ``` + */ + export function rect(x?: number, y?: number, w?: number, h?: number): Rect; + /** + !#en Check whether a rect's value equals to another. + !#zh 判断两个矩形是否相等。 + @param rect1 rect1 + @param rect2 rect2 + + @example + ```js + var a = new cc.Rect(0, 0, 10, 10); + var b = new cc.Rect(0, 0, 5, 5); + cc.rectEqualToRect(a, b); // false; + var c = new cc.Rect(0, 0, 5, 5); + cc.rectEqualToRect(b, c); // true; + ``` + */ + export function rectEqualToRect(rect1: Rect, rect2: Rect): boolean; + /** + !#en Check whether the rect1 contains rect2. + !#zh + 检查 rect1 矩形是否包含 rect2 矩形。
+ 注意:如果要允许 rect1 和 rect2 的边界重合,应该用 cc.rectOverlapsRect + @param rect1 rect1 + @param rect2 rect2 + + @example + ```js + var a = new cc.Rect(0, 0, 20, 20); + var b = new cc.Rect(10, 10, 20, 20); + cc.rectContainsRect(a, b); // true; + ``` + */ + export function rectContainsRect(rect1: Rect, rect2: Rect): boolean; + /** + !#en Returns the rightmost x-value of a rect. + !#zh 返回矩形在 x 轴上的最大值 + @param rect rect + + @example + ```js + var a = new cc.Rect(10, 0, 20, 20); + cc.rectGetMaxX(a); // 30; + ``` + */ + export function rectGetMaxX(rect: Rect): number; + /** + !#en Return the midpoint x-value of a rect. + !#zh 返回矩形在 x 轴上的中点。 + @param rect rect + + @example + ```js + var a = new cc.Rect(10, 0, 20, 20); + cc.rectGetMidX(a); // 20; + ``` + */ + export function rectGetMidX(rect: Rect): number; + /** + !#en Returns the leftmost x-value of a rect. + !#zh 返回矩形在 x 轴上的最小值。 + @param rect rect + + @example + ```js + var a = new cc.Rect(10, 0, 20, 20); + cc.rectGetMinX(a); // 10; + ``` + */ + export function rectGetMinX(rect: Rect): number; + /** + !#en Return the topmost y-value of a rect. + !#zh 返回矩形在 y 轴上的最大值。 + @param rect rect + + @example + ```js + var a = new cc.Rect(0, 10, 20, 20); + cc.rectGetMaxY(a); // 30; + ``` + */ + export function rectGetMaxY(rect: Rect): number; + /** + !#en Return the midpoint y-value of `rect'. + !#zh 返回矩形在 y 轴上的中点。 + @param rect rect + + @example + ```js + var a = new cc.Rect(0, 10, 20, 20); + cc.rectGetMidY(a); // 20; + ``` + */ + export function rectGetMidY(rect: Rect): number; + /** + !#en Return the bottommost y-value of a rect. + !#zh 返回矩形在 y 轴上的最小值。 + @param rect rect + + @example + ```js + var a = new cc.Rect(0, 10, 20, 20); + cc.rectGetMinY(a); // 10; + ``` + */ + export function rectGetMinY(rect: Rect): number; + /** + !#en Check whether a rect contains a point. + !#zh 检查一个矩形是否包含某个坐标点。 + @param rect rect + @param point point + + @example + ```js + var a = new cc.Rect(0, 10, 20, 20); + var b = new cc.Vec2(0, 10, 10, 10); + cc.rectContainsPoint(a, b); // true; + ``` + */ + export function rectContainsPoint(rect: Rect, point: Vec2): boolean; + /** + !#en Check whether a rect intersect with another. + !#zh 检查一个矩形是否与另一个相交。 + @param rectA rectA + @param rectB rectB + + @example + ```js + var a = new cc.Rect(0, 10, 20, 20); + var b = new cc.Rect(0, 10, 10, 10); + cc.rectIntersectsRect(a, b); // true; + ``` + */ + export function rectIntersectsRect(rectA: Rect, rectB: Rect): boolean; + /** + !#en Check whether a rect overlaps another. + !#zh 检查一个矩形是否重叠另一个。 + @param rectA rectA + @param rectB rectB + + @example + ```js + var a = new cc.Rect(0, 10, 20, 20); + var b = new cc.Rect(0, 10, 10, 10); + cc.rectOverlapsRect(a, b); // true; + ``` + */ + export function rectOverlapsRect(rectA: Rect, rectB: Rect): boolean; + /** + !#en Returns the smallest rectangle that contains the two source rectangles. + !#zh 返回一个包含两个指定矩形的最小矩形。 + @param rectA rectA + @param rectB rectB + + @example + ```js + var a = new cc.Rect(0, 10, 20, 20); + var b = new cc.Rect(0, 10, 10, 10); + cc.rectUnion(a, b); // Rect {x: 0, y: 10, width: 20, height: 20}; + ``` + */ + export function rectUnion(rectA: Rect, rectB: Rect): Rect; + /** + !#en Returns the overlapping portion of 2 rectangles. + !#zh 返回 2 个矩形重叠的部分。 + @param rectA rectA + @param rectB rectB + + @example + ```js + var a = new cc.Rect(0, 10, 20, 20); + var b = new cc.Rect(0, 10, 10, 10); + cc.rectIntersection(a, b); // Rect {x: 0, y: 10, width: 10, height: 10}; + ``` + */ + export function rectIntersection(rectA: Rect, rectB: Rect): Rect; + /** + !#en + Helper function that creates a cc.Size.
+ Please use cc.p or cc.v2 instead, it will soon replace cc.Size. + !#zh + 创建一个 cc.Size 对象的帮助函数。
+ 注意:可以使用 cc.p 或者是 cc.v2 代替,它们将很快取代 cc.Size。 + @param w width or a size object + @param h height + + @example + ```js + var size1 = cc.size(); + var size2 = cc.size(100,100); + var size3 = cc.size(size2); + var size4 = cc.size({width: 100, height: 100}); + + ``` + */ + export function size(w: number|Size, h?: number): Size; + /** + !#en Check whether a point's value equals to another. + !#zh 检查 Size 对象是否等于另一个。 + @param size1 size1 + @param size2 size2 + + @example + ```js + var a = new cc.size(10, 10); + var b = new cc.size(10, 10); + cc.sizeEqualToSize(a, b);// return true; + var b = new cc.size(5, 10); + cc.sizeEqualToSize(a, b);// return false; + ``` + */ + export function sizeEqualToSize(size1: Size, size2: Size): boolean; + export function V3F_C4B_T2F_QuadZero(): V3F_C4B_T2F_Quad; + /** + + @param sourceQuad sourceQuad + */ + export function V3F_C4B_T2F_QuadCopy(sourceQuad: V3F_C4B_T2F_Quad): V3F_C4B_T2F_Quad; + /** + + @param sourceQuads sourceQuads + */ + export function V3F_C4B_T2F_QuadsCopy(sourceQuads: any[]): any[]; + /** + !#en The convenience method to create a new {{#crossLink "Vec2"}}cc.Vec2{{/crossLink}}. + !#zh 通过该简便的函数进行创建 {{#crossLink "Vec2"}}cc.Vec2{{/crossLink}} 对象。 + @param x x + @param y y + + @example + ```js + var v1 = cc.v2(); + var v2 = cc.v2(0, 0); + var v3 = cc.v2(v2); + var v4 = cc.v2({x: 100, y: 100}); + ``` + */ + export function v2(x?: number|any, y?: number): Vec2; + /** + !#en The convenience method to creates a new {{#crossLink "Vec2"}}cc.Vec2{{/crossLink}}. + !#zh 通过该简便的函数进行创建 {{#crossLink "Vec2"}}cc.Vec2{{/crossLink}} 对象。 + @param x a Number or a size object + @param y y + + @example + ```js + var point1 = cc.p(); + var point2 = cc.p(100, 100); + var point3 = cc.p(point2); + var point4 = cc.p({x: 100, y: 100}); + ``` + */ + export function p(x?: number|any, y?: number): Vec2; + /** + !#en Check whether a point's value equals to another. + !#zh 判断两个向量是否相等。 + @param point1 point1 + @param point2 point2 + */ + export function pointEqualToPoint(point1: Vec2, point2: Vec2): boolean; + /** !#en Enum for debug modes. + !#zh 调试模式 */ + export enum DebugMode { + NONE = 0, + INFO = 0, + WARN = 0, + ERROR = 0, + INFO_FOR_WEB_PAGE = 0, + WARN_FOR_WEB_PAGE = 0, + ERROR_FOR_WEB_PAGE = 0, + } + /** !#en Base class cc.Action for action classes. + !#zh Action 类是所有动作类型的基类。 */ + export class Action { + /** + !#en + to copy object with deep copy. + returns a clone of action. + !#zh 返回一个克隆的动作。 + */ + clone(): Action; + /** + !#en + return true if the action has finished. + !#zh 如果动作已完成就返回 true。 + */ + isDone(): boolean; + /** + !#en get the target. + !#zh 获取当前目标节点。 + */ + getTarget(): Node; + /** + !#en The action will modify the target properties. + !#zh 设置目标节点。 + @param target target + */ + setTarget(target: Node): void; + /** + !#en get the original target. + !#zh 获取原始目标节点。 + */ + getOriginalTarget(): Node; + /** + !#en get tag number. + !#zh 获取用于识别动作的标签。 + */ + getTag(): number; + /** + !#en set tag number. + !#zh 设置标签,用于识别动作。 + @param tag tag + */ + setTag(tag: number): void; + /** !#en Default Action tag. + !#zh 默认动作标签。 */ + static TAG_INVALID: number; + } + /** !#en + Base class actions that do have a finite time duration.
+ Possible actions:
+ - An action with a duration of 0 seconds.
+ - An action with a duration of 35.5 seconds. + + Infinite time actions are valid + !#zh 有限时间动作,这种动作拥有时长 duration 属性。 */ + export class FiniteTimeAction extends Action { + /** + !#en get duration of the action. (seconds). + !#zh 获取动作以秒为单位的持续时间。 + */ + getDuration(): number; + /** + !#en set duration of the action. (seconds). + !#zh 设置动作以秒为单位的持续时间。 + @param duration duration + */ + setDuration(duration: number): void; + /** + !#en + Returns a reversed action.
+ For example:
+ - The action will be x coordinates of 0 move to 100.
+ - The reversed action will be x of 100 move to 0. + - Will be rewritten + !#zh 返回一个新的动作,执行与原动作完全相反的动作。 + */ + reverse(): void; + /** + !#en + to copy object with deep copy. + returns a clone of action. + !#zh 返回一个克隆的动作。 + */ + clone(): FiniteTimeAction; + } + /** !#en Base class for Easing actions. + !#zh 所有缓动动作基类,用于修饰 ActionInterval。 */ + export class ActionEase extends ActionInterval { + } + /** !#en Base class for Easing actions with rate parameters + !#zh 拥有速率属性的缓动动作基类。 */ + export class EaseRateAction extends ActionEase { + } + /** !#en Ease Elastic abstract class. + !#zh 弹性缓动动作基类。 */ + export class EaseElastic extends ActionEase { + } + /** !#en cc.EaseBounce abstract class. + !#zh 反弹缓动动作基类。 */ + export class EaseBounce extends ActionEase { + } + /** !#en Instant actions are immediate actions. They don't have a duration like the ActionInterval actions. + !#zh 即时动作,这种动作立即就会执行,继承自 FiniteTimeAction。 */ + export class ActionInstant extends FiniteTimeAction { + } + /** !#en +

An interval action is an action that takes place within a certain period of time.
+ It has an start time, and a finish time. The finish time is the parameter
+ duration plus the start time.

+ +

These CCActionInterval actions have some interesting properties, like:
+ - They can run normally (default)
+ - They can run reversed with the reverse method
+ - They can run with the time altered with the Accelerate, AccelDeccel and Speed actions.

+ +

For example, you can simulate a Ping Pong effect running the action normally and
+ then running it again in Reverse mode.

+ !#zh 时间间隔动作,这种动作在已定时间内完成,继承 FiniteTimeAction。 */ + export class ActionInterval extends FiniteTimeAction { + /** + !#en Implementation of ease motion. + !#zh 缓动运动。 + @param easeObj easeObj + + @example + ```js + action.easing(cc.easeIn(3.0)); + ``` + */ + easing(easeObj: any): ActionInterval; + /** + !#en + Repeats an action a number of times. + To repeat an action forever use the CCRepeatForever action. + !#zh 重复动作可以按一定次数重复一个动作,使用 RepeatForever 动作来永远重复一个动作。 + @param times times + */ + repeat(times: number): ActionInterval; + /** + !#en + Repeats an action for ever.
+ To repeat the an action for a limited number of times use the Repeat action.
+ !#zh 永远地重复一个动作,有限次数内重复一个动作请使用 Repeat 动作。 + */ + repeatForever(): ActionInterval; + } + /** !#en + cc.ActionManager is a class that can manage actions.
+ Normally you won't need to use this class directly. 99% of the cases you will use the CCNode interface, + which uses this class's singleton object. + But there are some cases where you might need to use this class.
+ Examples:
+ - When you want to run an action where the target is different from a CCNode.
+ - When you want to pause / resume the actions
+ !#zh + cc.ActionManager 是可以管理动作的单例类。
+ 通常你并不需要直接使用这个类,99%的情况您将使用 CCNode 的接口。
+ 但也有一些情况下,您可能需要使用这个类。
+ 例如: + - 当你想要运行一个动作,但目标不是 CCNode 类型时。
+ - 当你想要暂停/恢复动作时。
*/ + export class ActionManager { + /** + !#en + Adds an action with a target.
+ If the target is already present, then the action will be added to the existing target. + If the target is not present, a new instance of this target will be created either paused or not, and the action will be added to the newly created target. + When the target is paused, the queued actions won't be 'ticked'. + !#zh + 增加一个动作,同时还需要提供动作的目标对象,目标对象是否暂停作为参数。
+ 如果目标已存在,动作将会被直接添加到现有的节点中。
+ 如果目标不存在,将为这一目标创建一个新的实例,并将动作添加进去。
+ 当目标状态的 paused 为 true,动作将不会被执行 + @param action action + @param target target + @param paused paused + */ + addAction(action: Action, target: Node, paused: boolean): void; + /** + !#en Removes all actions from all the targets. + !#zh 移除所有对象的所有动作。 + */ + removeAllActions(): void; + /** + !#en + Removes all actions from a certain target.
+ All the actions that belongs to the target will be removed. + !#zh + 移除指定对象上的所有动作。
+ 属于该目标的所有的动作将被删除。 + @param target target + @param forceDelete forceDelete + */ + removeAllActionsFromTarget(target: Node, forceDelete: boolean): void; + /** + !#en Removes an action given an action reference. + !#zh 移除指定的动作。 + @param action action + */ + removeAction(action: Action): void; + /** + !#en Removes an action given its tag and the target. + !#zh 删除指定对象下特定标签的一个动作,将删除首个匹配到的动作。 + @param tag tag + @param target target + */ + removeActionByTag(tag: number, target: Node): void; + /** + !#en Gets an action given its tag an a target. + !#zh 通过目标对象和标签获取一个动作。 + @param tag tag + @param target target + */ + getActionByTag(tag: number, target: Node): Action; + /** + !#en + Returns the numbers of actions that are running in a certain target.
+ Composable actions are counted as 1 action.
+ Example:
+ - If you are running 1 Sequence of 7 actions, it will return 1.
+ - If you are running 7 Sequences of 2 actions, it will return 7. + !#zh + 返回指定对象下所有正在运行的动作数量。
+ 组合动作被算作一个动作。
+ 例如:
+ - 如果您正在运行 7 个动作组成的序列动作(Sequence),这个函数将返回 1。
+ - 如果你正在运行 2 个序列动作(Sequence)和 5 个普通动作,这个函数将返回 7。
+ @param target target + */ + getNumberOfRunningActionsInTarget(target: Node): number; + /** + !#en Pauses the target: all running actions and newly added actions will be paused. + !#zh 暂停指定对象:所有正在运行的动作和新添加的动作都将会暂停。 + @param target target + */ + pauseTarget(target: Node): void; + /** + !#en Resumes the target. All queued actions will be resumed. + !#zh 让指定目标恢复运行。在执行序列中所有被暂停的动作将重新恢复运行。 + @param target target + */ + resumeTarget(target: Node): void; + /** + !#en Pauses all running actions, returning a list of targets whose actions were paused. + !#zh 暂停所有正在运行的动作,返回一个包含了那些动作被暂停了的目标对象的列表。 + */ + pauseAllRunningActions(): any[]; + /** + !#en Resume a set of targets (convenience function to reverse a pauseAllRunningActions or pauseTargets call). + !#zh 让一组指定对象恢复运行(用来逆转 pauseAllRunningActions 效果的便捷函数)。 + @param targetsToResume targetsToResume + */ + resumeTargets(targetsToResume: any[]): void; + /** + !#en Pause a set of targets. + !#zh 暂停一组指定对象。 + @param targetsToPause targetsToPause + */ + pauseTargets(targetsToPause: any[]): void; + /** + !#en + purges the shared action manager. It releases the retained instance.
+ because it uses this, so it can not be static. + !#zh + 清除共用的动作管理器。它释放了持有的实例。
+ 因为它使用 this,因此它不能是静态的。 + */ + purgeSharedManager(): void; + /** + !#en The ActionManager update。 + !#zh ActionManager 主循环。 + @param dt delta time in seconds + */ + update(dt: number): void; + } + /** !#en Class for animation data handling. + !#zh 动画剪辑,用于存储动画数据。 */ + export class AnimationClip extends Asset { + /** !#en Duration of this animation. + !#zh 动画的持续时间。 */ + duration: number; + /** !#en FrameRate of this animation. + !#zh 动画的帧速率。 */ + sample: number; + /** !#en Speed of this animation. + !#zh 动画的播放速度。 */ + speed: number; + /** !#en WrapMode of this animation. + !#zh 动画的循环模式。 */ + wrapMode: WrapMode; + /** !#en Curve data. + !#zh 曲线数据。 */ + curveData: any; + /** !#en Event data. + !#zh 事件数据。 */ + events: {frame: number, func: string, params: string[]}[]; + /** + !#en Crate clip with a set of sprite frames + !#zh 使用一组序列帧图片来创建动画剪辑 + @param spriteFrames spriteFrames + @param sample sample + + @example + ```js + var clip = cc.AnimationClip.createWithSpriteFrames(spriteFrames, 10); + ``` + */ + static createWithSpriteFrames(spriteFrames: [SpriteFrame], sample: number): AnimationClip; + } + /** !#en + The AnimationState gives full control over animation playback process. + In most cases the Animation Component is sufficient and easier to use. Use the AnimationState if you need full control. + !#zh + AnimationState 完全控制动画播放过程。
+ 大多数情况下 动画组件 是足够和易于使用的。如果您需要更多的动画控制接口,请使用 AnimationState。 */ + export class AnimationState extends Playable { + /** + + @param clip clip + @param name name + */ + constructor(clip: AnimationClip, name?: string); + animator: AnimationAnimator; + /** !#en The curves list. + !#zh 曲线列表。 */ + curves: any[]; + /** !#en The start delay which represents the number of seconds from an animation's start time to the start of + the active interval. + !#zh 延迟多少秒播放。 */ + delay: number; + /** !#en The animation's iteration count property. + + A real number greater than or equal to zero (including positive infinity) representing the number of times + to repeat the animation node. + + Values less than zero and NaN values are treated as the value 1.0 for the purpose of timing model + calculations. + + !#zh 迭代次数,指动画播放多少次后结束, normalize time。 如 2.5(2次半) */ + repeatCount: number; + /** !#en The iteration duration of this animation in seconds. (length) + !#zh 单次动画的持续时间,秒。 */ + duration: number; + /** !#en The animation's playback speed. 1 is normal playback speed. + !#zh 播放速率。 */ + speed: number; + /** !#en + Wrapping mode of the playing animation. + Notice : dynamic change wrapMode will reset time and repeatCount property + !#zh + 动画循环方式。 + 需要注意的是,动态修改 wrapMode 时,会重置 time 以及 repeatCount */ + wrapMode: WrapMode; + /** !#en The current time of this animation in seconds. + !#zh 动画当前的时间,秒。 */ + time: number; + /** !#en The clip that is being played by this animation state. + !#zh 此动画状态正在播放的剪辑。 */ + clip: AnimationClip; + /** !#en The name of the playing animation. + !#zh 动画的名字 */ + name: string; + } + /** undefined */ + export class Playable { + /** !#en Is playing or paused in play mode? + !#zh 当前是否正在播放。 */ + isPlaying: boolean; + /** !#en Is currently paused? This can be true even if in edit mode(isPlaying == false). + !#zh 当前是否正在暂停 */ + isPaused: boolean; + /** + !#en Play this animation. + !#zh 播放动画。 + */ + play(): void; + /** + !#en Stop this animation. + !#zh 停止动画播放。 + */ + stop(): void; + /** + !#en Pause this animation. + !#zh 暂停动画。 + */ + pause(): void; + /** + !#en Resume this animation. + !#zh 重新播放动画。 + */ + resume(): void; + /** + !#en Perform a single frame step. + !#zh 执行一帧动画。 + */ + step(): void; + } + /** !#en Specifies how time is treated when it is outside of the keyframe range of an Animation. + !#zh 动画使用的循环模式。 */ + export enum WrapMode { + Default = 0, + Normal = 0, + Reverse = 0, + Loop = 0, + LoopReverse = 0, + PingPong = 0, + PingPongReverse = 0, + } + /** !#en cc.audioEngine is the singleton object, it provide simple audio APIs. + !#zh + cc.audioengine是单例对象。
+ 主要用来播放音频,播放的时候会返回一个 audioID,之后都可以通过这个 audioID 来操作这个音频对象。
+ 不使用的时候,请使用 cc.audioEngine.uncache(filePath); 进行资源释放
+ 注意:
+ 在 Android 系统浏览器上,不同浏览器,不同版本的效果不尽相同。
+ 比如说:大多数浏览器都需要用户物理交互才可以开始播放音效,有一些不支持 WebAudio,
+ 有一些不支持多音轨播放。总之如果对音乐依赖比较强,请做尽可能多的测试。 */ + export class audioEngine { + /** + !#en Play audio. + !#zh 播放音频 + @param filePath The path of the audio file without filename extension. + @param loop Whether the music loop or not. + @param volume Volume size. + + @example + ```js + var audioID = cc.audioEngine.play(path, false, 0.5); + ``` + */ + static play(filePath: string, loop: boolean, volume: number): number; + /** + !#en Set audio loop. + !#zh 设置音频是否循环。 + @param audioID audio id. + @param loop Whether cycle. + + @example + ```js + cc.audioEngine.setLoop(id, true); + ``` + */ + static setLoop(audioID: number, loop: boolean): void; + /** + !#en Get audio cycle state. + !#zh 获取音频的循环状态。 + @param audioID audio id. + + @example + ```js + cc.audioEngine.isLoop(id); + ``` + */ + static isLoop(audioID: number): boolean; + /** + !#en Set the volume of audio. + !#zh 设置音量(0.0 ~ 1.0)。 + @param audioID audio id. + @param volume Volume must be in 0.0~1.0 . + + @example + ```js + cc.audioEngine.setVolume(id, 0.5); + ``` + */ + static setVolume(audioID: number, volume: number): void; + /** + !#en The volume of the music max value is 1.0,the min value is 0.0 . + !#zh 获取音量(0.0 ~ 1.0)。 + @param audioID audio id. + + @example + ```js + var volume = cc.audioEngine.getVolume(id); + ``` + */ + static getVolume(audioID: number): number; + /** + !#en Set current time + !#zh 设置当前的音频时间。 + @param audioID audio id. + @param sec current time. + + @example + ```js + cc.audioEngine.setCurrentTime(id, 2); + ``` + */ + static setCurrentTime(audioID: number, sec: number): boolean; + /** + !#en Get current time + !#zh 获取当前的音频播放时间。 + @param audioID audio id. + + @example + ```js + var time = cc.audioEngine.getCurrentTime(id); + ``` + */ + static getCurrentTime(audioID: number): number; + /** + !#en Get audio duration + !#zh 获取音频总时长。 + @param audioID audio id. + + @example + ```js + var time = cc.audioEngine.getDuration(id); + ``` + */ + static getDuration(audioID: number): number; + /** + !#en Get audio state + !#zh 获取音频状态。 + @param audioID audio id. + + @example + ```js + var state = cc.audioEngine.getState(id); + ``` + */ + static getState(audioID: number): audioEngine.AudioState; + /** + !#en Set Audio finish callback + !#zh 设置一个音频结束后的回调 + @param audioID audio id. + @param callback loaded callback. + + @example + ```js + cc.audioEngine.setFinishCallback(id, function () {}); + ``` + */ + static setFinishCallback(audioID: number, callback: Function): void; + /** + !#en Pause playing audio. + !#zh 暂停正在播放音频。 + @param audioID The return value of function play. + + @example + ```js + cc.audioEngine.pause(audioID); + ``` + */ + static pause(audioID: number): void; + /** + !#en Pause all playing audio + !#zh 暂停现在正在播放的所有音频。 + + @example + ```js + cc.audioEngine.pauseAll(); + ``` + */ + static pauseAll(): void; + /** + !#en Resume playing audio. + !#zh 恢复播放指定的音频。 + @param audioID The return value of function play. + + @example + ```js + cc.audioEngine.resume(audioID); + ``` + */ + static resume(audioID: number): void; + /** + !#en Resume all playing audio. + !#zh 恢复播放所有之前暂停的所有音频。 + + @example + ```js + cc.audioEngine.resumeAll(); + ``` + */ + static resumeAll(): void; + /** + !#en Stop playing audio. + !#zh 停止播放指定音频。 + @param audioID The return value of function play. + + @example + ```js + cc.audioEngine.stop(audioID); + ``` + */ + static stop(audioID: number): void; + /** + !#en Stop all playing audio. + !#zh 停止正在播放的所有音频。 + + @example + ```js + cc.audioEngine.stopAll(); + ``` + */ + static stopAll(): void; + /** + !#en Set up an audio can generate a few examples. + !#zh 设置一个音频可以设置几个实例 + @param num a number of instances to be created from within an audio + + @example + ```js + cc.audioEngine.setMaxAudioInstance(20); + ``` + */ + static setMaxAudioInstance(num: number): void; + /** + !#en Getting audio can produce several examples. + !#zh 获取一个音频可以设置几个实例 + + @example + ```js + cc.audioEngine.getMaxAudioInstance(); + ``` + */ + static getMaxAudioInstance(): number; + /** + !#en Unload the preloaded audio from internal buffer. + !#zh 卸载预加载的音频。 + @param filePath filePath + + @example + ```js + cc.audioEngine.uncache(filePath); + ``` + */ + static uncache(filePath: string): void; + /** + !#en Unload all audio from internal buffer. + !#zh 卸载所有音频。 + + @example + ```js + cc.audioEngine.uncacheAll(); + ``` + */ + static uncacheAll(): void; + /** + !#en Preload audio file. + !#zh 预加载一个音频 + @param filePath The file path of an audio. + @param callback The callback of an audio. + + @example + ```js + cc.audioEngine.preload(path); + ``` + */ + static preload(filePath: string, callback?: Function): void; + /** + !#en Set a size, the unit is KB. Over this size is directly resolved into DOM nodes. + !#zh 设置一个以 KB 为单位的尺寸,大于这个尺寸的音频在加载的时候会强制使用 dom 方式加载 + @param kb The file path of an audio. + + @example + ```js + cc.audioEngine.setMaxWebAudioSize(300); + ``` + */ + static setMaxWebAudioSize(kb: number): void; + } + /** !#en +

+ ATTENTION: USE cc.director INSTEAD OF cc.Director.
+ cc.director is a singleton object which manage your game's logic flow.
+ Since the cc.director is a singleton, you don't need to call any constructor or create functions,
+ the standard way to use it is by calling:
+ - cc.director.methodName();
+ + It creates and handle the main Window and manages how and when to execute the Scenes.
+
+ The cc.director is also responsible for:
+ - initializing the OpenGL context
+ - setting the OpenGL pixel format (default on is RGB565)
+ - setting the OpenGL buffer depth (default on is 0-bit)
+ - setting the color for clear screen (default one is BLACK)
+ - setting the projection (default one is 3D)
+ - setting the orientation (default one is Portrait)
+
+
+ The cc.director also sets the default OpenGL context:
+ - GL_TEXTURE_2D is enabled
+ - GL_VERTEX_ARRAY is enabled
+ - GL_COLOR_ARRAY is enabled
+ - GL_TEXTURE_COORD_ARRAY is enabled
+

+

+ cc.director also synchronizes timers with the refresh rate of the display.
+ Features and Limitations:
+ - Scheduled timers & drawing are synchronizes with the refresh rate of the display
+ - Only supports animation intervals of 1/60 1/30 & 1/15
+

+ + !#zh +

+ 注意:用 cc.director 代替 cc.Director。
+ cc.director 一个管理你的游戏的逻辑流程的单例对象。
+ 由于 cc.director 是一个单例,你不需要调用任何构造函数或创建函数,
+ 使用它的标准方法是通过调用:
+ - cc.director.methodName(); +
+ 它创建和处理主窗口并且管理什么时候执行场景。
+
+ cc.director 还负责:
+ - 初始化 OpenGL 环境。
+ - 设置OpenGL像素格式。(默认是 RGB565)
+ - 设置OpenGL缓冲区深度 (默认是 0-bit)
+ - 设置空白场景的颜色 (默认是 黑色)
+ - 设置投影 (默认是 3D)
+ - 设置方向 (默认是 Portrait)
+
+ cc.director 设置了 OpenGL 默认环境
+ - GL_TEXTURE_2D 启用。
+ - GL_VERTEX_ARRAY 启用。
+ - GL_COLOR_ARRAY 启用。
+ - GL_TEXTURE_COORD_ARRAY 启用。
+

+

+ cc.director 也同步定时器与显示器的刷新速率。 +
+ 特点和局限性:
+ - 将计时器 & 渲染与显示器的刷新频率同步。
+ - 只支持动画的间隔 1/60 1/30 & 1/15。
+

*/ + export class Director extends EventTarget { + /** + !#en + Converts an OpenGL coordinate to a view coordinate
+ Useful to convert node points to window points for calls such as glScissor
+ Implementation can be found in CCDirectorWebGL. + !#zh 将触摸点的 WebGL View 坐标转换为屏幕坐标。 + @param glPoint glPoint + */ + convertToUI(glPoint: Vec2): Vec2; + /** + !#en + Returns the size of the WebGL view in points.
+ It takes into account any possible rotation (device orientation) of the window. + !#zh 获取视图的大小,以点为单位。 + */ + getWinSize(): Size; + /** + !#en + Returns the size of the OpenGL view in pixels.
+ It takes into account any possible rotation (device orientation) of the window.
+ On Mac winSize and winSizeInPixels return the same value. + (The pixel here refers to the resource resolution. If you want to get the physics resolution of device, you need to use cc.view.getFrameSize()) + !#zh + 获取视图大小,以像素为单位(这里的像素指的是资源分辨率。 + 如果要获取屏幕物理分辨率,需要用 cc.view.getFrameSize()) + */ + getWinSizeInPixels(): Size; + /** + !#en Returns the visible size of the running scene. + !#zh 获取运行场景的可见大小。 + */ + getVisibleSize(): Size; + /** + !#en Returns the visible origin of the running scene. + !#zh 获取视图在游戏内容中的坐标原点。 + */ + getVisibleOrigin(): Vec2; + /** + !#en Pause the director's ticker, only involve the game logic execution. + It won't pause the rendering process nor the event manager. + If you want to pause the entier game including rendering, audio and event, + please use {{#crossLink "Game.pause"}}cc.game.pause{{/crossLink}} + !#zh 暂停正在运行的场景,该暂停只会停止游戏逻辑执行,但是不会停止渲染和 UI 响应。 + 如果想要更彻底得暂停游戏,包含渲染,音频和事件,请使用 {{#crossLink "Game.pause"}}cc.game.pause{{/crossLink}}。 + */ + pause(): void; + /** + !#en + Run a scene. Replaces the running scene with a new one or enter the first scene.
+ The new scene will be launched immediately. + !#zh 立刻切换指定场景。 + @param scene The need run scene. + @param onBeforeLoadScene The function invoked at the scene before loading. + @param onLaunched The function invoked at the scene after launch. + */ + runSceneImmediate(scene: Scene, onBeforeLoadScene?: Function, onLaunched?: Function): void; + /** + !#en Loads the scene by its name. + !#zh 通过场景名称进行加载场景。 + @param sceneName The name of the scene to load. + @param onLaunched callback, will be called after scene launched. + */ + loadScene(sceneName: string, onLaunched?: Function): boolean; + /** + !#en + Preloads the scene to reduces loading time. You can call this method at any time you want. + After calling this method, you still need to launch the scene by `cc.director.loadScene`. + It will be totally fine to call `cc.director.loadScene` at any time even if the preloading is not + yet finished, the scene will be launched after loaded automatically. + !#zh 预加载场景,你可以在任何时候调用这个方法。 + 调用完后,你仍然需要通过 `cc.director.loadScene` 来启动场景,因为这个方法不会执行场景加载操作。 + 就算预加载还没完成,你也可以直接调用 `cc.director.loadScene`,加载完成后场景就会启动。 + @param sceneName The name of the scene to preload. + @param onLoaded callback, will be called after scene loaded. + */ + preloadScene(sceneName: string, onLoaded?: (error: Error) => void): void; + /** + !#en Resume game logic execution after pause, if the current scene is not paused, nothing will happen. + !#zh 恢复暂停场景的游戏逻辑,如果当前场景没有暂停将没任何事情发生。 + */ + resume(): void; + /** + !#en + Enables or disables WebGL depth test.
+ Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js + !#zh 启用/禁用深度测试(在 Canvas 渲染模式下不会生效)。 + @param on on + */ + setDepthTest(on: boolean): void; + /** + !#en + Set color for clear screen.
+ (Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js) + !#zh + 设置场景的默认擦除颜色。
+ 支持全透明,但不支持透明度为中间值。要支持全透明需手工开启 cc.macro.ENABLE_TRANSPARENT_CANVAS。 + @param clearColor clearColor + */ + setClearColor(clearColor: Color): void; + /** + !#en + Sets an OpenGL projection.
+ Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js. + !#zh 设置 OpenGL 投影。 + @param projection projection + */ + setProjection(projection: number): void; + /** + !#en + Update the view port.
+ Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js. + !#zh 设置视窗(请不要主动调用这个接口,除非你知道你在做什么)。 + */ + setViewport(): void; + /** + !#en + Sets an OpenGL projection.
+ Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js. + !#zh 获取 OpenGL 投影。 + */ + getProjection(): number; + /** + !#en + Enables/disables OpenGL alpha blending.
+ Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js. + !#zh 启用/禁用 透明度融合。 + @param on on + */ + setAlphaBlending(on: boolean): void; + /** + !#en + Returns whether or not the replaced scene will receive the cleanup message.
+ If the new scene is pushed, then the old scene won't receive the "cleanup" message.
+ If the new scene replaces the old one, the it will receive the "cleanup" message. + !#zh + 更换场景时是否接收清理消息。
+ 如果新场景是采用 push 方式进入的,那么旧的场景将不会接收到 “cleanup” 消息。
+ 如果新场景取代旧的场景,它将会接收到 “cleanup” 消息。
+ */ + isSendCleanupToScene(): boolean; + /** + !#en Returns current logic Scene. + !#zh 获取当前逻辑场景。 + + @example + ```js + // This will help you to get the Canvas node in scene + cc.director.getScene().getChildByName('Canvas'); + ``` + */ + getScene(): Scene; + /** + !#en Returns the FPS value. + !#zh 获取单位帧执行时间。 + */ + getAnimationInterval(): number; + /** + !#en Returns whether or not to display the FPS informations. + !#zh 获取是否显示 FPS 信息。 + */ + isDisplayStats(): boolean; + /** + !#en Sets whether display the FPS on the bottom-left corner. + !#zh 设置是否在左下角显示 FPS。 + @param displayStats displayStats + */ + setDisplayStats(displayStats: boolean): void; + /** + !#en Returns whether next delta time equals to zero. + !#zh 返回下一个 “delta time” 是否等于零。 + */ + isNextDeltaTimeZero(): boolean; + /** + !#en Returns whether or not the Director is paused. + !#zh 是否处于暂停状态。 + */ + isPaused(): boolean; + /** + !#en Returns how many frames were called since the director started. + !#zh 获取 director 启动以来游戏运行的总帧数。 + */ + getTotalFrames(): number; + /** + !#en Returns the cc.Scheduler associated with this director. + !#zh 获取和 director 相关联的 cc.Scheduler。 + */ + getScheduler(): Scheduler; + /** + !#en Sets the cc.Scheduler associated with this director. + !#zh 设置和 director 相关联的 cc.Scheduler。 + @param scheduler scheduler + */ + setScheduler(scheduler: Scheduler): void; + /** + !#en Returns the cc.ActionManager associated with this director. + !#zh 获取和 director 相关联的 cc.ActionManager(动作管理器)。 + */ + getActionManager(): ActionManager; + /** + !#en Sets the cc.ActionManager associated with this director. + !#zh 设置和 director 相关联的 cc.ActionManager(动作管理器)。 + @param actionManager actionManager + */ + setActionManager(actionManager: ActionManager): void; + /** + Returns the cc.CollisionManager associated with this director. + */ + getCollisionManager(): CollisionManager; + /** + Returns the cc.PhysicsManager associated with this director. + */ + getPhysicsManager(): PhysicsManager; + /** + !#en Returns the delta time since last frame. + !#zh 获取上一帧的 “delta time”。 + */ + getDeltaTime(): number; + /** !#en The event projection changed of cc.Director. + !#zh cc.Director 投影变化的事件。 */ + static EVENT_PROJECTION_CHANGED: string; + /** !#en The event which will be triggered before loading a new scene. + !#zh 加载新场景之前所触发的事件。 */ + static EVENT_BEFORE_SCENE_LOADING: string; + /** !#en The event which will be triggered before launching a new scene. + !#zh 运行新场景之前所触发的事件。 */ + static EVENT_BEFORE_SCENE_LAUNCH: string; + /** !#en The event which will be triggered after launching a new scene. + !#zh 运行新场景之后所触发的事件。 */ + static EVENT_AFTER_SCENE_LAUNCH: string; + /** !#en The event which will be triggered at the beginning of every frame. + !#zh 每个帧的开始时所触发的事件。 */ + static EVENT_BEFORE_UPDATE: string; + /** !#en The event which will be triggered after engine and components update logic. + !#zh 将在引擎和组件 “update” 逻辑之后所触发的事件。 */ + static EVENT_AFTER_UPDATE: string; + /** !#en The event which will be triggered before visiting the rendering scene graph. + !#zh 访问渲染场景树之前所触发的事件。 */ + static EVENT_BEFORE_VISIT: string; + /** !#en + The event which will be triggered after visiting the rendering scene graph, + the render queue is ready but not rendered at this point. + !#zh + 访问渲染场景图之后所触发的事件,渲染队列已准备就绪,但在这一时刻还没有呈现在画布上。 */ + static EVENT_AFTER_VISIT: string; + /** !#en The event which will be triggered after the rendering process. + !#zh 渲染过程之后所触发的事件。 */ + static EVENT_AFTER_DRAW: string; + /** Constant for 2D projection (orthogonal projection) */ + static PROJECTION_2D: number; + /** Constant for 3D projection with a fovy=60, znear=0.5f and zfar=1500. */ + static PROJECTION_3D: number; + /** Constant for custom projection, if cc.Director's projection set to it, it calls "updateProjection" on the projection delegate. */ + static PROJECTION_CUSTOM: number; + /** Constant for default projection of cc.Director, default projection is 2D projection */ + static PROJECTION_DEFAULT: number; + } + /** !#en cc.game is the singleton object for game related functions. + !#zh cc.game 是 Game 的实例,用来驱动整个游戏。 */ + export class Game extends EventTarget { + /** !#en Event triggered when game hide to background. + Please note that this event is not 100% guaranteed to be fired on Web platform, + on native platforms, it corresponds to enter background event, os status bar or notification center may not trigger this event. + !#zh 游戏进入后台时触发的事件。 + 请注意,在 WEB 平台,这个事件不一定会 100% 触发,这完全取决于浏览器的回调行为。 + 在原生平台,它对应的是应用被切换到后台事件,下拉菜单和上拉状态栏等不一定会触发这个事件,这取决于系统行为。 */ + EVENT_HIDE: string; + /** Event triggered when game back to foreground + Please note that this event is not 100% guaranteed to be fired on Web platform, + on native platforms, it corresponds to enter foreground event. + !#zh 游戏进入前台运行时触发的事件。 + 请注意,在 WEB 平台,这个事件不一定会 100% 触发,这完全取决于浏览器的回调行为。 + 在原生平台,它对应的是应用被切换到前台事件。 */ + EVENT_SHOW: string; + /** Event triggered after game inited, at this point all engine objects and game scripts are loaded */ + EVENT_GAME_INITED: string; + /** Event triggered after renderer inited, at this point you will be able to use the render context */ + EVENT_RENDERER_INITED: string; + /** Key of config */ + CONFIG_KEY: any; + /** !#en The outer frame of the game canvas, parent of cc.container. + !#zh 游戏画布的外框,cc.container 的父类。 */ + frame: any; + /** !#en The container of game canvas, equals to cc.container. + !#zh 游戏画布的容器。 */ + container: HTMLDivElement; + /** !#en The canvas of the game, equals to cc._canvas. + !#zh 游戏的画布。 */ + canvas: HTMLCanvasElement; + /** !#en + The current game configuration, including:
+ 1. debugMode
+ "debugMode" possible values :
+ 0 - No message will be printed.
+ 1 - cc.error, cc.assert, cc.warn, cc.log will print in console.
+ 2 - cc.error, cc.assert, cc.warn will print in console.
+ 3 - cc.error, cc.assert will print in console.
+ 4 - cc.error, cc.assert, cc.warn, cc.log will print on canvas, available only on web.
+ 5 - cc.error, cc.assert, cc.warn will print on canvas, available only on web.
+ 6 - cc.error, cc.assert will print on canvas, available only on web.
+ 2. showFPS
+ Left bottom corner fps information will show when "showFPS" equals true, otherwise it will be hide.
+ 3. exposeClassName
+ Expose class name to chrome debug tools, the class intantiate performance is a little bit slower when exposed.
+ 4. frameRate
+ "frameRate" set the wanted frame rate for your game, but the real fps depends on your game implementation and the running environment.
+ 5. id
+ "gameCanvas" sets the id of your canvas element on the web page, it's useful only on web.
+ 6. renderMode
+ "renderMode" sets the renderer type, only useful on web :
+ 0 - Automatically chosen by engine
+ 1 - Forced to use canvas renderer
+ 2 - Forced to use WebGL renderer, but this will be ignored on mobile browsers
+ 7. scenes
+ "scenes" include available scenes in the current bundle.
+
+ Please DO NOT modify this object directly, it won't have any effect.
+ !#zh + 当前的游戏配置,包括:
+ 1. debugMode(debug 模式,但是在浏览器中这个选项会被忽略)
+ "debugMode" 各种设置选项的意义。
+ 0 - 没有消息被打印出来。
+ 1 - cc.error,cc.assert,cc.warn,cc.log 将打印在 console 中。
+ 2 - cc.error,cc.assert,cc.warn 将打印在 console 中。
+ 3 - cc.error,cc.assert 将打印在 console 中。
+ 4 - cc.error,cc.assert,cc.warn,cc.log 将打印在 canvas 中(仅适用于 web 端)。
+ 5 - cc.error,cc.assert,cc.warn 将打印在 canvas 中(仅适用于 web 端)。
+ 6 - cc.error,cc.assert 将打印在 canvas 中(仅适用于 web 端)。
+ 2. showFPS(显示 FPS)
+ 当 showFPS 为 true 的时候界面的左下角将显示 fps 的信息,否则被隐藏。
+ 3. exposeClassName
+ 暴露类名让 Chrome DevTools 可以识别,如果开启会稍稍降低类的创建过程的性能,但对对象构造没有影响。
+ 4. frameRate (帧率)
+ “frameRate” 设置想要的帧率你的游戏,但真正的FPS取决于你的游戏实现和运行环境。
+ 5. id
+ "gameCanvas" Web 页面上的 Canvas Element ID,仅适用于 web 端。
+ 6. renderMode(渲染模式)
+ “renderMode” 设置渲染器类型,仅适用于 web 端:
+ 0 - 通过引擎自动选择。
+ 1 - 强制使用 canvas 渲染。 + 2 - 强制使用 WebGL 渲染,但是在部分 Android 浏览器中这个选项会被忽略。
+ 7. scenes
+ “scenes” 当前包中可用场景。
+
+ 注意:请不要直接修改这个对象,它不会有任何效果。 */ + config: any; + /** + !#en Callback when the scripts of engine have been load. + !#zh 当引擎完成启动后的回调函数。 + */ + onStart(): void; + /** + !#en Set frameRate of game. + !#zh 设置游戏帧率。 + @param frameRate frameRate + */ + setFrameRate(frameRate: number): void; + /** + !#en Run the game frame by frame. + !#zh 执行一帧游戏循环。 + */ + step(): void; + /** + !#en Pause the game main loop. This will pause: + game logic execution, rendering process, event manager, background music and all audio effects. + This is different with cc.director.pause which only pause the game logic execution. + !#zh 暂停游戏主循环。包含:游戏逻辑,渲染,事件处理,背景音乐和所有音效。这点和只暂停游戏逻辑的 cc.director.pause 不同。 + */ + pause(): void; + /** + !#en Resume the game from pause. This will resume: + game logic execution, rendering process, event manager, background music and all audio effects. + !#zh 恢复游戏主循环。包含:游戏逻辑,渲染,事件处理,背景音乐和所有音效。 + */ + resume(): void; + /** + !#en Check whether the game is paused. + !#zh 判断游戏是否暂停。 + */ + isPaused(): boolean; + /** + !#en Restart game. + !#zh 重新开始游戏 + */ + restart(): void; + /** + !#en End game, it will close the game window + !#zh 退出游戏 + */ + end(): void; + /** + !#en Prepare game. + !#zh 准备引擎,请不要直接调用这个函数。 + @param cb cb + */ + prepare(cb: Function): void; + /** + !#en Run game with configuration object and onStart function. + !#zh 运行游戏,并且指定引擎配置和 onStart 的回调。 + @param config Pass configuration object or onStart function + @param onStart function to be executed after game initialized + */ + run(config?: any|Function, onStart?: Function): void; + /** + !#en + Add a persistent root node to the game, the persistent node won't be destroyed during scene transition.
+ The target node must be placed in the root level of hierarchy, otherwise this API won't have any effect. + !#zh + 声明常驻根节点,该节点不会被在场景切换中被销毁。
+ 目标节点必须位于为层级的根节点,否则无效。 + @param node The node to be made persistent + */ + addPersistRootNode(node: Node): void; + /** + !#en Remove a persistent root node. + !#zh 取消常驻根节点。 + @param node The node to be removed from persistent node list + */ + removePersistRootNode(node: Node): void; + /** + !#en Check whether the node is a persistent root node. + !#zh 检查节点是否是常驻根节点。 + @param node The node to be checked + */ + isPersistRootNode(node: Node): boolean; + } + /** !#en + Class of all entities in Cocos Creator scenes.
+ Node also inherits from {{#crossLink "EventTarget"}}Event Target{{/crossLink}}, it permits Node to dispatch events. + For events supported by Node, please refer to {{#crossLink "Node.EventType"}}{{/crossLink}} + !#zh + Cocos Creator 场景中的所有节点类。节点也继承了 {{#crossLink "EventTarget"}}EventTarget{{/crossLink}},它允许节点发送事件。
+ 支持的节点事件,请参阅 {{#crossLink "Node.EventType"}}{{/crossLink}}。 */ + export class Node extends _BaseNode { + /** !#en + Group index of node.
+ Which Group this node belongs to will resolve that this node's collision components can collide with which other collision componentns.
+ !#zh + 节点的分组索引。
+ 节点的分组将关系到节点的碰撞组件可以与哪些碰撞组件相碰撞。
*/ + groupIndex: number; + /** !#en + Group of node.
+ Which Group this node belongs to will resolve that this node's collision components can collide with which other collision componentns.
+ !#zh + 节点的分组。
+ 节点的分组将关系到节点的碰撞组件可以与哪些碰撞组件相碰撞。
*/ + group: string; + /** !#en The position (x, y) of the node in its parent's coordinates. + !#zh 节点在父节点坐标系中的位置(x, y)。 */ + position: Vec2; + /** !#en x axis position of node. + !#zh 节点 X 轴坐标。 */ + x: number; + /** !#en y axis position of node. + !#zh 节点 Y 轴坐标。 */ + y: number; + /** !#en Rotation of node. + !#zh 该节点旋转角度。 */ + rotation: number; + /** !#en Rotation on x axis. + !#zh 该节点 X 轴旋转角度。 */ + rotationX: number; + /** !#en Rotation on y axis. + !#zh 该节点 Y 轴旋转角度。 */ + rotationY: number; + /** !#en Scale on x axis. + !#zh 节点 X 轴缩放。 */ + scaleX: number; + /** !#en Scale on y axis. + !#zh 节点 Y 轴缩放。 */ + scaleY: number; + /** !#en Skew x + !#zh 该节点 Y 轴倾斜角度。 */ + skewX: number; + /** !#en Skew y + !#zh 该节点 X 轴倾斜角度。 */ + skewY: number; + /** !#en Opacity of node, default value is 255. + !#zh 节点透明度,默认值为 255。 */ + opacity: number; + /** !#en Indicate whether node's opacity value affect its child nodes, default value is true. + !#zh 节点的不透明度值是否影响其子节点,默认值为 true。 */ + cascadeOpacity: boolean; + /** !#en Color of node, default value is white: (255, 255, 255). + !#zh 节点颜色。默认为白色,数值为:(255,255,255)。 */ + color: Color; + /** !#en Anchor point's position on x axis. + !#zh 节点 X 轴锚点位置。 */ + anchorX: number; + /** !#en Anchor point's position on y axis. + !#zh 节点 Y 轴锚点位置。 */ + anchorY: number; + /** !#en Width of node. + !#zh 节点宽度。 */ + width: number; + /** !#en Height of node. + !#zh 节点高度。 */ + height: number; + /** !#en Z order in depth which stands for the drawing order. + !#zh 该节点渲染排序的 Z 轴深度。 */ + zIndex: number; + /** + + @param name name + */ + constructor(name?: string); + /** + !#en + Register a callback of a specific event type on Node.
+ Use this method to register touch or mouse event permit propagation based on scene graph, + you can propagate the event to the parents or swallow it by calling stopPropagation on the event.
+ It's the recommended way to register touch/mouse event for Node, + please do not use cc.eventManager directly for Node. + !#zh + 在节点上注册指定类型的回调函数,也可以设置 target 用于绑定响应函数的 this 对象。
+ 同时您可以将事件派发到父节点或者通过调用 stopPropagation 拦截它。
+ 推荐使用这种方式来监听节点上的触摸或鼠标事件,请不要在节点上直接使用 cc.eventManager。 + @param type A string representing the event type to listen for.
+ See {{#crossLink "Node/position-changed:event"}}Node Events{{/crossLink}} for all builtin events. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + @param useCapture When set to true, the capture argument prevents callback + from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. + When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE. + Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET. + + @example + ```js + this.node.on(cc.Node.EventType.TOUCH_START, this.memberFunction, this); // if "this" is component and the "memberFunction" declared in CCClass. + node.on(cc.Node.EventType.TOUCH_START, callback, this.node); + node.on(cc.Node.EventType.TOUCH_MOVE, callback, this.node); + node.on(cc.Node.EventType.TOUCH_END, callback, this.node); + node.on(cc.Node.EventType.TOUCH_CANCEL, callback, this.node); + node.on("anchor-changed", callback, this); + ``` + */ + on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void; + on(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void; + /** + !#en + Removes the callback previously registered with the same type, callback, target and or useCapture. + This method is merely an alias to removeEventListener. + !#zh 删除之前与同类型,回调,目标或 useCapture 注册的回调。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not. + If not specified, useCapture defaults to false. If a callback was registered twice, + one with capture and one without, each must be removed separately. Removal of a capturing callback + does not affect a non-capturing version of the same listener, and vice versa. + + @example + ```js + this.node.off(cc.Node.EventType.TOUCH_START, this.memberFunction, this); + node.off(cc.Node.EventType.TOUCH_START, callback, this.node); + node.off("anchor-changed", callback, this); + ``` + */ + off(type: string, callback: Function, target?: any, useCapture?: boolean): void; + /** + !#en Removes all callbacks previously registered with the same target. + !#zh 移除目标上的所有注册事件。 + @param target The target to be searched for all related callbacks + + @example + ```js + node.targetOff(target); + ``` + */ + targetOff(target: any): void; + /** + !#en Pause node related system events registered with the current Node. Node system events includes touch and mouse events. + If recursive is set to true, then this API will pause the node system events for the node and all nodes in its sub node tree. + Reference: http://cocos2d-x.org/docs/editors_and_tools/creator-chapters/scripting/internal-events/ + !#zh 暂停当前节点上注册的所有节点系统事件,节点系统事件包含触摸和鼠标事件。 + 如果传递 recursive 为 true,那么这个 API 将暂停本节点和它的子树上所有节点的节点系统事件。 + 参考:http://cocos.com/docs/creator/scripting/internal-events.html + @param recursive Whether to pause node system events on the sub node tree. + + @example + ```js + node.pauseSystemEvents(true); + ``` + */ + pauseSystemEvents(recursive: boolean): void; + /** + !#en Resume node related system events registered with the current Node. Node system events includes touch and mouse events. + If recursive is set to true, then this API will resume the node system events for the node and all nodes in its sub node tree. + Reference: http://cocos2d-x.org/docs/editors_and_tools/creator-chapters/scripting/internal-events/ + !#zh 恢复当前节点上注册的所有节点系统事件,节点系统事件包含触摸和鼠标事件。 + 如果传递 recursive 为 true,那么这个 API 将恢复本节点和它的子树上所有节点的节点系统事件。 + 参考:http://cocos.com/docs/creator/scripting/internal-events.html + @param recursive Whether to resume node system events on the sub node tree. + + @example + ```js + node.resumeSystemEvents(true); + ``` + */ + resumeSystemEvents(recursive: boolean): void; + /** + !#en + Executes an action, and returns the action that is executed.
+ The node becomes the action's target. Refer to cc.Action's getTarget()
+ Calling runAction while the node is not active won't have any effect.
+ Note:You shouldn't modify the action after runAction, that won't take any effect.
+ if you want to modify, when you define action plus. + !#zh + 执行并返回该执行的动作。该节点将会变成动作的目标。
+ 调用 runAction 时,节点自身处于不激活状态将不会有任何效果。
+ 注意:你不应该修改 runAction 后的动作,将无法发挥作用,如果想进行修改,请在定义 action 时加入。 + @param action action + + @example + ```js + var action = cc.scaleTo(0.2, 1, 0.6); + node.runAction(action); + node.runAction(action).repeatForever(); // fail + node.runAction(action.repeatForever()); // right + ``` + */ + runAction(action: Action): Action; + /** + !#en Pause all actions running on the current node. Equals to `cc.director.getActionManager().pauseTarget(node)`. + !#zh 暂停本节点上所有正在运行的动作。和 `cc.director.getActionManager().pauseTarget(node);` 等价。 + + @example + ```js + node.pauseAllActions(); + ``` + */ + pauseAllActions(): void; + /** + !#en Resume all paused actions on the current node. Equals to `cc.director.getActionManager().resumeTarget(node)`. + !#zh 恢复运行本节点上所有暂停的动作。和 `cc.director.getActionManager().resumeTarget(node);` 等价。 + + @example + ```js + node.resumeAllActions(); + ``` + */ + resumeAllActions(): void; + /** + !#en Stops and removes all actions from the running action list . + !#zh 停止并且移除所有正在运行的动作列表。 + + @example + ```js + node.stopAllActions(); + ``` + */ + stopAllActions(): void; + /** + !#en Stops and removes an action from the running action list. + !#zh 停止并移除指定的动作。 + @param action An action object to be removed. + + @example + ```js + var action = cc.scaleTo(0.2, 1, 0.6); + node.stopAction(action); + ``` + */ + stopAction(action: Action): void; + /** + !#en Removes an action from the running action list by its tag. + !#zh 停止并且移除指定标签的动作。 + @param tag A tag that indicates the action to be removed. + + @example + ```js + node.stopAction(1); + ``` + */ + stopActionByTag(tag: number): void; + /** + !#en Returns an action from the running action list by its tag. + !#zh 通过标签获取指定动作。 + @param tag tag + + @example + ```js + var action = node.getActionByTag(1); + ``` + */ + getActionByTag(tag: number): Action; + /** + !#en + Returns the numbers of actions that are running plus the ones that are schedule to run (actions in actionsToAdd and actions arrays).
+ Composable actions are counted as 1 action. Example:
+ If you are running 1 Sequence of 7 actions, it will return 1.
+ If you are running 7 Sequences of 2 actions, it will return 7.

+ !#zh + 获取运行着的动作加上正在调度运行的动作的总数。
+ 例如:
+ - 如果你正在运行 7 个动作中的 1 个 Sequence,它将返回 1。
+ - 如果你正在运行 2 个动作中的 7 个 Sequence,它将返回 7。
+ + @example + ```js + var count = node.getNumberOfRunningActions(); + cc.log("Running Action Count: " + count); + ``` + */ + getNumberOfRunningActions(): number; + /** + !#en Returns a copy of the position (x, y) of the node in its parent's coordinates. + !#zh 获取节点在父节点坐标系中的位置(x, y)。 + + @example + ```js + cc.log("Node Position: " + node.getPosition()); + ``` + */ + getPosition(): Vec2; + /** + !#en + Sets the position (x, y) of the node in its parent's coordinates.
+ Usually we use cc.v2(x, y) to compose cc.Vec2 object.
+ and Passing two numbers (x, y) is more efficient than passing cc.Vec2 object. + !#zh + 设置节点在父节点坐标系中的位置。
+ 可以通过两种方式设置坐标点:
+ 1. 传入 2 个数值 x 和 y。
+ 2. 传入 cc.v2(x, y) 类型为 cc.Vec2 的对象。 + @param newPosOrX X coordinate for position or the position (x, y) of the node in coordinates + @param y Y coordinate for position + + @example + ```js + node.setPosition(cc.v2(0, 0)); + node.setPosition(0, 0); + + ``` + */ + setPosition(newPosOrX: Vec2|number, y?: number): void; + /** + !#en + Returns the scale factor of the node. + Assertion will fail when _scaleX != _scaleY. + !#zh 获取节点的缩放。当 X 轴和 Y 轴有相同的缩放数值时。 + + @example + ```js + cc.log("Node Scale: " + node.getScale()); + ``` + */ + getScale(): number; + /** + !#en Sets the scale factor of the node. 1.0 is the default scale factor. This function can modify the X and Y scale at the same time. + !#zh 设置节点的缩放比例,默认值为 1.0。这个函数可以在同一时间修改 X 和 Y 缩放。 + @param scaleX scaleX or scale + @param scaleY scaleY + + @example + ```js + node.setScale(cc.v2(1, 1)); + node.setScale(1, 1); + ``` + */ + setScale(scaleX: number|Vec2, scaleY?: number): void; + /** + !#en + Returns a copy the untransformed size of the node.
+ The contentSize remains the same no matter the node is scaled or rotated.
+ All nodes has a size. Layer and Scene has the same size of the screen by default.
+ !#zh 获取节点自身大小,不受该节点是否被缩放或者旋转的影响。 + @param ignoreSizeProvider true if you need to get the original size of the node + + @example + ```js + cc.log("Content Size: " + node.getContentSize()); + ``` + */ + getContentSize(ignoreSizeProvider?: boolean): Size; + /** + !#en + Sets the untransformed size of the node.
+ The contentSize remains the same no matter the node is scaled or rotated.
+ All nodes has a size. Layer and Scene has the same size of the screen. + !#zh 设置节点原始大小,不受该节点是否被缩放或者旋转的影响。 + @param size The untransformed size of the node or The untransformed size's width of the node. + @param height The untransformed size's height of the node. + + @example + ```js + node.setContentSize(cc.size(100, 100)); + node.setContentSize(100, 100); + ``` + */ + setContentSize(size: Size|number, height?: number): void; + /** + !#en + Set whether color should be changed with the opacity value, + useless in ccsg.Node, but this function is override in some class to have such behavior. + !#zh 设置更改透明度时是否修改RGB值, + @param opacityValue opacityValue + + @example + ```js + node.setOpacityModifyRGB(true); + ``` + */ + setOpacityModifyRGB(opacityValue: boolean): void; + /** + !#en Get whether color should be changed with the opacity value. + !#zh 更改透明度时是否修改RGB值。 + + @example + ```js + var hasChange = node.isOpacityModifyRGB(); + ``` + */ + isOpacityModifyRGB(): boolean; + /** + !#en + Returns a copy of the anchor point.
+ Anchor point is the point around which all transformations and positioning manipulations take place.
+ It's like a pin in the node where it is "attached" to its parent.
+ The anchorPoint is normalized, like a percentage. (0,0) means the bottom-left corner and (1,1) means the top-right corner.
+ But you can use values higher than (1,1) and lower than (0,0) too.
+ The default anchor point is (0.5,0.5), so it starts at the center of the node. + !#zh + 获取节点锚点,用百分比表示。
+ 锚点应用于所有变换和坐标点的操作,它就像在节点上连接其父节点的大头针。
+ 锚点是标准化的,就像百分比一样。(0,0) 表示左下角,(1,1) 表示右上角。
+ 但是你可以使用比(1,1)更高的值或者比(0,0)更低的值。
+ 默认的锚点是(0.5,0.5),因此它开始于节点的中心位置。
+ 注意:Creator 中的锚点仅用于定位所在的节点,子节点的定位不受影响。 + + @example + ```js + cc.log("Node AnchorPoint: " + node.getAnchorPoint()); + ``` + */ + getAnchorPoint(): Vec2; + /** + !#en + Sets the anchor point in percent.
+ anchor point is the point around which all transformations and positioning manipulations take place.
+ It's like a pin in the node where it is "attached" to its parent.
+ The anchorPoint is normalized, like a percentage. (0,0) means the bottom-left corner and (1,1) means the top-right corner.
+ But you can use values higher than (1,1) and lower than (0,0) too.
+ The default anchor point is (0.5,0.5), so it starts at the center of the node. + !#zh + 设置锚点的百分比。
+ 锚点应用于所有变换和坐标点的操作,它就像在节点上连接其父节点的大头针。
+ 锚点是标准化的,就像百分比一样。(0,0) 表示左下角,(1,1) 表示右上角。
+ 但是你可以使用比(1,1)更高的值或者比(0,0)更低的值。
+ 默认的锚点是(0.5,0.5),因此它开始于节点的中心位置。
+ 注意:Creator 中的锚点仅用于定位所在的节点,子节点的定位不受影响。 + @param point The anchor point of node or The x axis anchor of node. + @param y The y axis anchor of node. + + @example + ```js + node.setAnchorPoint(cc.v2(1, 1)); + node.setAnchorPoint(1, 1); + ``` + */ + setAnchorPoint(point: Vec2|number, y?: number): void; + /** + !#en + Returns a copy of the anchor point in absolute pixels.
+ you can only read it. If you wish to modify it, use setAnchorPoint. + !#zh + 返回锚点的绝对像素位置。
+ 你只能读它。如果您要修改它,使用 setAnchorPoint。 + + @example + ```js + cc.log("AnchorPointInPoints: " + node.getAnchorPointInPoints()); + ``` + */ + getAnchorPointInPoints(): Vec2; + /** + !#en + Returns the displayed opacity of Node, + the difference between displayed opacity and opacity is that displayed opacity is calculated based on opacity and parent node's opacity when cascade opacity enabled. + !#zh + 获取节点显示透明度, + 显示透明度和透明度之间的不同之处在于当启用级连透明度时, + 显示透明度是基于自身透明度和父节点透明度计算的。 + + @example + ```js + var displayOpacity = node.getDisplayedOpacity(); + ``` + */ + getDisplayedOpacity(): number; + /** + !#en + Returns the displayed color of Node, + the difference between displayed color and color is that displayed color is calculated based on color and parent node's color when cascade color enabled. + !#zh + 获取节点的显示颜色, + 显示颜色和颜色之间的不同之处在于当启用级连颜色时, + 显示颜色是基于自身颜色和父节点颜色计算的。 + + @example + ```js + var displayColor = node.getDisplayedColor(); + ``` + */ + getDisplayedColor(): Color; + /** + !#en + Returns the matrix that transform the node's (local) space coordinates into the parent's space coordinates.
+ The matrix is in Pixels.
+ This method is AR (Anchor Relative). + !#zh + 返回这个将节点(局部)的空间坐标系转换成父节点的空间坐标系的矩阵。
+ 这个矩阵以像素为单位。
+ 该方法基于节点坐标。 + + @example + ```js + var affineTransform = node.getNodeToParentTransformAR(); + ``` + */ + getNodeToParentTransformAR(): AffineTransform; + /** + !#en + Returns a "local" axis aligned bounding box of the node.
+ The returned box is relative only to its parent. + !#zh 返回父节坐标系下的轴向对齐的包围盒。 + + @example + ```js + var boundingBox = node.getBoundingBox(); + ``` + */ + getBoundingBox(): Rect; + /** + !#en + Returns a "world" axis aligned bounding box of the node.
+ The bounding box contains self and active children's world bounding box. + !#zh + 返回节点在世界坐标系下的对齐轴向的包围盒(AABB)。
+ 该边框包含自身和已激活的子节点的世界边框。 + + @example + ```js + var newRect = node.getBoundingBoxToWorld(); + ``` + */ + getBoundingBoxToWorld(): Rect; + /** + !#en + Returns the matrix that transform the node's (local) space coordinates into the parent's space coordinates.
+ The matrix is in Pixels. + !#zh 返回这个将节点(局部)的空间坐标系转换成父节点的空间坐标系的矩阵。这个矩阵以像素为单位。 + + @example + ```js + var affineTransform = node.getNodeToParentTransform(); + ``` + */ + getNodeToParentTransform(): AffineTransform; + /** + !#en Returns the world affine transform matrix. The matrix is in Pixels. + !#zh 返回节点到世界坐标系的仿射变换矩阵。矩阵单位是像素。 + + @example + ```js + var affineTransform = node.getNodeToWorldTransform(); + ``` + */ + getNodeToWorldTransform(): AffineTransform; + /** + !#en + Returns the world affine transform matrix. The matrix is in Pixels.
+ This method is AR (Anchor Relative). + !#zh + 返回节点到世界坐标仿射变换矩阵。矩阵单位是像素。
+ 该方法基于节点坐标。 + + @example + ```js + var mat = node.getNodeToWorldTransformAR(); + ``` + */ + getNodeToWorldTransformAR(): AffineTransform; + /** + !#en + Returns the matrix that transform parent's space coordinates to the node's (local) space coordinates.
+ The matrix is in Pixels. The returned transform is readonly and cannot be changed. + !#zh + 返回将父节点的坐标系转换成节点(局部)的空间坐标系的矩阵。
+ 该矩阵以像素为单位。返回的矩阵是只读的,不能更改。 + + @example + ```js + var affineTransform = node.getParentToNodeTransform(); + ``` + */ + getParentToNodeTransform(): AffineTransform; + /** + !#en Returns the inverse world affine transform matrix. The matrix is in Pixels. + !#en 返回世界坐标系到节点坐标系的逆矩阵。 + + @example + ```js + var affineTransform = node.getWorldToNodeTransform(); + ``` + */ + getWorldToNodeTransform(): AffineTransform; + /** + !#en Converts a Point to node (local) space coordinates. The result is in Vec2. + !#zh 将一个点转换到节点 (局部) 坐标系。结果以 Vec2 为单位。 + @param worldPoint worldPoint + + @example + ```js + var newVec2 = node.convertToNodeSpace(cc.v2(100, 100)); + ``` + */ + convertToNodeSpace(worldPoint: Vec2): Vec2; + /** + !#en Converts a Point to world space coordinates. The result is in Points. + !#zh 将一个点转换到世界空间坐标系。结果以 Vec2 为单位。 + @param nodePoint nodePoint + + @example + ```js + var newVec2 = node.convertToWorldSpace(cc.v2(100, 100)); + ``` + */ + convertToWorldSpace(nodePoint: Vec2): Vec2; + /** + !#en + Converts a Point to node (local) space coordinates. The result is in Points.
+ treating the returned/received node point as anchor relative. + !#zh + 将一个点转换到节点 (局部) 空间坐标系。结果以 Vec2 为单位。
+ 返回值将基于节点坐标。 + @param worldPoint worldPoint + + @example + ```js + var newVec2 = node.convertToNodeSpaceAR(cc.v2(100, 100)); + ``` + */ + convertToNodeSpaceAR(worldPoint: Vec2): Vec2; + /** + !#en + Converts a local Point to world space coordinates.The result is in Points.
+ treating the returned/received node point as anchor relative. + !#zh + 将一个点转换到世界空间坐标系。结果以 Vec2 为单位。
+ 返回值将基于世界坐标。 + @param nodePoint nodePoint + + @example + ```js + var newVec2 = node.convertToWorldSpaceAR(cc.v2(100, 100)); + ``` + */ + convertToWorldSpaceAR(nodePoint: Vec2): Vec2; + /** + !#en convenience methods which take a cc.Touch instead of cc.Vec2. + !#zh 将触摸点转换成本地坐标系中位置。 + @param touch The touch object + + @example + ```js + var newVec2 = node.convertTouchToNodeSpace(touch); + ``` + */ + convertTouchToNodeSpace(touch: Touch): Vec2; + /** + !#en converts a cc.Touch (world coordinates) into a local coordinate. This method is AR (Anchor Relative). + !#zh 转换一个 cc.Touch(世界坐标)到一个局部坐标,该方法基于节点坐标。 + @param touch The touch object + + @example + ```js + var newVec2 = node.convertTouchToNodeSpaceAR(touch); + ``` + */ + convertTouchToNodeSpaceAR(touch: Touch): Vec2; + /** + !#en + Adds a child to the node with z order and tag. + !#zh + 添加子节点,并且可以修改该节点的 局部 Z 顺序和标签。 + @param child A child node + @param localZOrder Z order for drawing priority. Please refer to setZOrder(int) + @param tag An integer or a name to identify the node easily. Please refer to setTag(int) and setName(string) + + @example + ```js + node.addChild(newNode, 1, 1001); + ``` + */ + addChild(child: Node, localZOrder?: number, tag?: number|string): void; + /** + !#en Stops all running actions and schedulers. + !#zh 停止所有正在播放的动作和计时器。 + + @example + ```js + node.cleanup(); + ``` + */ + cleanup(): void; + /** + !#en Sorts the children array depends on children's zIndex and arrivalOrder, + normally you won't need to invoke this function. + !#zh 根据子节点的 zIndex 和 arrivalOrder 进行排序,正常情况下开发者不需要手动调用这个函数。 + */ + sortAllChildren(): void; + /** !#en The local scale relative to the parent. + !#zh 节点相对父节点的缩放。 */ + scale: number; + /** + !#en Returns the x axis position of the node in cocos2d coordinates. + !#zh 获取节点 X 轴坐标。 + + @example + ```js + var posX = node.getPositionX(); + ``` + */ + getPositionX(): number; + /** + !#en Sets the x axis position of the node in cocos2d coordinates. + !#zh 设置节点 X 轴坐标。 + @param x x + + @example + ```js + node.setPositionX(1); + ``` + */ + setPositionX(x: number): void; + /** + !#en Returns the y axis position of the node in cocos2d coordinates. + !#zh 获取节点 Y 轴坐标。 + + @example + ```js + var posY = node.getPositionY(); + ``` + */ + getPositionY(): number; + /** + !#en Sets the y axis position of the node in cocos2d coordinates. + !#zh 设置节点 Y 轴坐标。 + @param y The new position in y axis + + @example + ```js + node.setPositionY(100); + ``` + */ + setPositionY(y: number): void; + /** + !#en Returns the local Z order of this node. + !#zh 获取节点局部 Z 轴顺序。 + + @example + ```js + var localZorder = node.getLocalZOrder(); + ``` + */ + getLocalZOrder(): number; + /** + !#en + LocalZOrder is the 'key' used to sort the node relative to its siblings.
+
+ The Node's parent will sort all its children based ont the LocalZOrder value.
+ If two nodes have the same LocalZOrder, then the node that was added first to the children's array
+ will be in front of the other node in the array.
+ Also, the Scene Graph is traversed using the "In-Order" tree traversal algorithm ( http://en.wikipedia.org/wiki/Tree_traversal#In-order )
+ And Nodes that have LocalZOder values smaller than 0 are the "left" subtree
+ While Nodes with LocalZOder greater than 0 are the "right" subtree. + !#zh + LocalZOrder 是 “key” (关键)来分辨节点和它兄弟节点的相关性。 + 父节点将会通过 LocalZOrder 的值来分辨所有的子节点。 + 如果两个节点有同样的 LocalZOrder,那么先加入子节点数组的节点将会显示在后加入的节点的前面。 + 同样的,场景图使用 “In-Order(按顺序)” 遍历数算法来遍历 + ( http://en.wikipedia.org/wiki/Tree_traversal#In-order ) 并且拥有小于 0 的 LocalZOrder 的值的节点是 “ left ” 子树(左子树) + 所以拥有大于 0 的 LocalZOrder 的值得节点是 “ right ”子树(右子树)。 + @param localZOrder localZOrder + + @example + ```js + node.setLocalZOrder(1); + ``` + */ + setLocalZOrder(localZOrder: number): void; + /** + !#en Returns whether node's opacity value affect its child nodes. + !#zh 返回节点的不透明度值是否影响其子节点。 + + @example + ```js + cc.log(node.isCascadeOpacityEnabled()); + ``` + */ + isCascadeOpacityEnabled(): boolean; + /** + !#en Enable or disable cascade opacity, if cascade enabled, child nodes' opacity will be the multiplication of parent opacity and its own opacity. + !#zh 启用或禁用级连不透明度,如果级连启用,子节点的不透明度将是父不透明度乘上它自己的不透明度。 + @param cascadeOpacityEnabled cascadeOpacityEnabled + + @example + ```js + node.setCascadeOpacityEnabled(true); + ``` + */ + setCascadeOpacityEnabled(cascadeOpacityEnabled: boolean): void; + } + /** !#en + cc.Scene is a subclass of cc.Node that is used only as an abstract concept.
+ cc.Scene and cc.Node are almost identical with the difference that users can not modify cc.Scene manually. + !#zh + cc.Scene 是 cc.Node 的子类,仅作为一个抽象的概念。
+ cc.Scene 和 cc.Node 有点不同,用户不应直接修改 cc.Scene。 */ + export class Scene extends Node { + /** !#en Indicates whether all (directly or indirectly) static referenced assets of this scene are releasable by default after scene unloading. + !#zh 指示该场景中直接或间接静态引用到的所有资源是否默认在场景切换后自动释放。 */ + autoReleaseAssets: boolean; + } + /** !#en + Scheduler is responsible of triggering the scheduled callbacks.
+ You should not use NSTimer. Instead use this class.
+
+ There are 2 different types of callbacks (selectors):
+ - update callback: the 'update' callback will be called every frame. You can customize the priority.
+ - custom callback: A custom callback will be called every frame, or with a custom interval of time
+
+ The 'custom selectors' should be avoided when possible. It is faster, + and consumes less memory to use the 'update callback'. * + !#zh + Scheduler 是负责触发回调函数的类。
+ 通常情况下,建议使用 cc.director.getScheduler() 来获取系统定时器。
+ 有两种不同类型的定时器:
+ - update 定时器:每一帧都会触发。您可以自定义优先级。
+ - 自定义定时器:自定义定时器可以每一帧或者自定义的时间间隔触发。
+ 如果希望每帧都触发,应该使用 update 定时器,使用 update 定时器更快,而且消耗更少的内存。 */ + export class Scheduler { + /** + !#en + Modifies the time of all scheduled callbacks.
+ You can use this property to create a 'slow motion' or 'fast forward' effect.
+ Default is 1.0. To create a 'slow motion' effect, use values below 1.0.
+ To create a 'fast forward' effect, use values higher than 1.0.
+ Note:It will affect EVERY scheduled selector / action. + !#zh + 设置时间间隔的缩放比例。
+ 您可以使用这个方法来创建一个 “slow motion(慢动作)” 或 “fast forward(快进)” 的效果。
+ 默认是 1.0。要创建一个 “slow motion(慢动作)” 效果,使用值低于 1.0。
+ 要使用 “fast forward(快进)” 效果,使用值大于 1.0。
+ 注意:它影响该 Scheduler 下管理的所有定时器。 + @param timeScale timeScale + */ + setTimeScale(timeScale: number): void; + /** + !#en Returns time scale of scheduler. + !#zh 获取时间间隔的缩放比例。 + */ + getTimeScale(): number; + /** + !#en 'update' the scheduler. (You should NEVER call this method, unless you know what you are doing.) + !#zh update 调度函数。(不应该直接调用这个方法,除非完全了解这么做的结果) + @param dt delta time + */ + update(dt: number): void; + /** + !#en +

+ The scheduled method will be called every 'interval' seconds.
+ If paused is YES, then it won't be called until it is resumed.
+ If 'interval' is 0, it will be called every frame, but if so, it recommended to use 'scheduleUpdateForTarget:' instead.
+ If the callback function is already scheduled, then only the interval parameter will be updated without re-scheduling it again.
+ repeat let the action be repeated repeat + 1 times, use cc.macro.REPEAT_FOREVER to let the action run continuously
+ delay is the amount of time the action will wait before it'll start
+

+ !#zh + 指定回调函数,调用对象等信息来添加一个新的定时器。
+ 当时间间隔达到指定值时,设置的回调函数将会被调用。
+ 如果 paused 值为 true,那么直到 resume 被调用才开始计时。
+ 如果 interval 值为 0,那么回调函数每一帧都会被调用,但如果是这样, + 建议使用 scheduleUpdateForTarget 代替。
+ 如果回调函数已经被定时器使用,那么只会更新之前定时器的时间间隔参数,不会设置新的定时器。
+ repeat 值可以让定时器触发 repeat + 1 次,使用 cc.macro.REPEAT_FOREVER + 可以让定时器一直循环触发。
+ delay 值指定延迟时间,定时器会在延迟指定的时间之后开始计时。 + @param target target + @param callback_fn callback_fn + @param interval interval + @param repeat repeat + @param delay delay + @param paused paused + + @example + ```js + //register a schedule to scheduler + var scheduler = cc.director.getScheduler(); + scheduler.scheduleCallbackForTarget(this, function, interval, repeat, delay, !this._isRunning); + + ``` + */ + scheduleCallbackForTarget(target: any, callback: Function, interval: number, repeat: number, delay: number, paused?: boolean): void; + scheduleCallbackForTarget(target: any, callback: Function, interval: number, paused?: boolean): void; + /** + !#en The schedule + !#zh 定时器 + @param callback callback + @param target target + @param interval interval + @param repeat repeat + @param delay delay + @param paused paused + + @example + ```js + //register a schedule to scheduler + cc.director.getScheduler().schedule(callback, this, interval, !this._isRunning); + + ``` + */ + schedule(callback: Function, target: any, interval: number, repeat: number, delay: number, paused?: boolean): void; + schedule(callback: Function, target: any, interval: number, paused?: boolean): void; + /** + !#en + Schedules the update callback for a given target, + the callback will be invoked every frame after schedule started. + !#zh + 使用指定的优先级为指定的对象设置 update 定时器。 + update 定时器每一帧都会被触发。优先级的值越低,定时器被触发的越早。 + @param target target + @param priority priority + @param paused paused + @param updateFunc updateFunc + */ + scheduleUpdate(target: any, priority: number, paused: boolean, updateFunc: Function): void; + /** + !#en + Unschedules a callback for a callback and a given target. + If you want to unschedule the "update", use `unscheduleUpdate()` + !#zh + 根据指定的回调函数和调用对象。 + 如果需要取消 update 定时器,请使用 unscheduleUpdate()。 + @param callback The callback to be unscheduled + @param target The target bound to the callback. + */ + unschedule(callback: Function, target: any): void; + /** + !#en Unschedules the update callback for a given target. + !#zh 取消指定对象的 update 定时器。 + @param target The target to be unscheduled. + */ + unscheduleUpdate(target: any): void; + /** + !#en + Unschedules all scheduled callbacks for a given target. + This also includes the "update" callback. + !#zh 取消指定对象的所有定时器,包括 update 定时器。 + @param target The target to be unscheduled. + */ + unscheduleAllForTarget(target: any): void; + /** + !#en + Unschedules all scheduled callbacks from all targets including the system callbacks.
+ You should NEVER call this method, unless you know what you are doing. + !#zh + 取消所有对象的所有定时器,包括系统定时器。
+ 不用调用此函数,除非你确定你在做什么。 + */ + unscheduleAll(): void; + /** + !#en + Unschedules all callbacks from all targets with a minimum priority.
+ You should only call this with `PRIORITY_NON_SYSTEM_MIN` or higher. + !#zh + 取消所有优先级的值大于指定优先级的定时器。
+ 你应该只取消优先级的值大于 PRIORITY_NON_SYSTEM_MIN 的定时器。 + @param minPriority The minimum priority of selector to be unscheduled. Which means, all selectors which + priority is higher than minPriority will be unscheduled. + */ + unscheduleAllWithMinPriority(minPriority: number): void; + /** + !#en Checks whether a callback for a given target is scheduled. + !#zh 检查指定的回调函数和回调对象组合是否存在定时器。 + @param callback The callback to check. + @param target The target of the callback. + */ + isScheduled(callback: Function, target: any): boolean; + /** + !#en + Pause all selectors from all targets.
+ You should NEVER call this method, unless you know what you are doing. + !#zh + 暂停所有对象的所有定时器。
+ 不要调用这个方法,除非你知道你正在做什么。 + */ + pauseAllTargets(): void; + /** + !#en + Pause all selectors from all targets with a minimum priority.
+ You should only call this with kCCPriorityNonSystemMin or higher. + !#zh + 暂停所有优先级的值大于指定优先级的定时器。
+ 你应该只暂停优先级的值大于 PRIORITY_NON_SYSTEM_MIN 的定时器。 + @param minPriority minPriority + */ + pauseAllTargetsWithMinPriority(minPriority: number): void; + /** + !#en + Resume selectors on a set of targets.
+ This can be useful for undoing a call to pauseAllCallbacks. + !#zh + 恢复指定数组中所有对象的定时器。
+ 这个函数是 pauseAllCallbacks 的逆操作。 + @param targetsToResume targetsToResume + */ + resumeTargets(targetsToResume: any[]): void; + /** + !#en + Pauses the target.
+ All scheduled selectors/update for a given target won't be 'ticked' until the target is resumed.
+ If the target is not present, nothing happens. + !#zh + 暂停指定对象的定时器。
+ 指定对象的所有定时器都会被暂停。
+ 如果指定的对象没有定时器,什么也不会发生。 + @param target target + */ + pauseTarget(target: any): void; + /** + !#en + Resumes the target.
+ The 'target' will be unpaused, so all schedule selectors/update will be 'ticked' again.
+ If the target is not present, nothing happens. + !#zh + 恢复指定对象的所有定时器。
+ 指定对象的所有定时器将继续工作。
+ 如果指定的对象没有定时器,什么也不会发生。 + @param target target + */ + resumeTarget(target: any): void; + /** + !#en Returns whether or not the target is paused. + !#zh 返回指定对象的定时器是否暂停了。 + @param target target + */ + isTargetPaused(target: any): boolean; + /** + !#en + Schedules the 'update' callback_fn for a given target with a given priority.
+ The 'update' callback_fn will be called every frame.
+ The lower the priority, the earlier it is called. + !#zh + 为指定对象设置 update 定时器。
+ update 定时器每一帧都会被调用。
+ 优先级的值越低,越早被调用。 + @param target target + @param priority priority + @param paused paused + + @example + ```js + //register this object to scheduler + var scheduler = cc.director.getScheduler(); + scheduler.scheduleUpdateForTarget(this, priority, !this._isRunning ); + + ``` + */ + scheduleUpdateForTarget(target: any, priority: number, paused: boolean): void; + /** + !#en + Unschedule a callback function for a given target.
+ If you want to unschedule the "update", use unscheduleUpdateForTarget. + !#zh + 根据指定的回调函数和调用对象对象取消相应的定时器。
+ 如果需要取消 update 定时器,请使用 unscheduleUpdateForTarget()。 + @param target target + @param callback callback[Function] or key[String] + + @example + ```js + //unschedule a callback of target + var scheduler = cc.director.getScheduler(); + scheduler.unscheduleCallbackForTarget(this, callback); + + ``` + */ + unscheduleCallbackForTarget(target: any, callback: Function): void; + /** + !#en Unschedules the update callback function for a given target. + !#zh 取消指定对象的所有定时器。 + @param target target + + @example + ```js + //unschedules the "update" method. + var scheduler = cc.director.getScheduler(); + scheduler.unscheduleUpdateForTarget(this); + + ``` + */ + unscheduleUpdateForTarget(target: any): void; + /** + !#en + Unschedules all function callbacks for a given target.
+ This also includes the "update" callback function. + !#zh 取消指定对象的所有定时器,包括 update 定时器。 + @param target target + */ + unscheduleAllCallbacksForTarget(target: any): void; + /** + !#en + Unschedules all function callbacks from all targets.
+ You should NEVER call this method, unless you know what you are doing. + !#zh + 取消所有对象的所有定时器。
+ 不要调用这个方法,除非你知道你正在做什么。 + */ + unscheduleAllCallbacks(): void; + /** + !#en + Unschedules all function callbacks from all targets with a minimum priority.
+ You should only call this with kCCPriorityNonSystemMin or higher. + !#zh + 取消所有优先级的值大于指定优先级的所有对象的所有定时器。
+ 你应该只暂停优先级的值大于 PRIORITY_NON_SYSTEM_MIN 的定时器。 + @param minPriority minPriority + */ + unscheduleAllCallbacksWithMinPriority(minPriority: number): void; + /** !#en Priority level reserved for system services. + !#zh 系统服务的优先级。 */ + static PRIORITY_SYSTEM: number; + /** !#en Minimum priority level for user scheduling. + !#zh 用户调度最低优先级。 */ + static PRIORITY_NON_SYSTEM: number; + } + /** !#en + cc.MotionStreak manages a Ribbon based on it's motion in absolute space.
+ You construct it with a fadeTime, minimum segment size, texture path, texture
+ length and color. The fadeTime controls how long it takes each vertex in
+ the streak to fade out, the minimum segment size it how many pixels the
+ streak will move before adding a new ribbon segment, and the texture
+ length is the how many pixels the texture is stretched across. The texture
+ is vertically aligned along the streak segment. + !#zh 运动轨迹,用于游戏对象的运动轨迹上实现拖尾渐隐效果。 */ + export class MotionStreak extends Component { + /** !#en + !#zh 在编辑器模式下预览拖尾效果。 */ + preview: boolean; + /** !#en The fade time to fade. + !#zh 拖尾的渐隐时间,以秒为单位。 */ + fadeTime: number; + /** !#en The minimum segment size. + !#zh 拖尾之间最小距离。 */ + minSeg: number; + /** !#en The stroke's width. + !#zh 拖尾的宽度。 */ + stroke: number; + /** !#en The texture of the MotionStreak. + !#zh 拖尾的贴图。 */ + texture: Texture2D; + /** !#en The color of the MotionStreak. + !#zh 拖尾的颜色 */ + color: Color; + /** !#en The fast Mode. + !#zh 是否启用了快速模式。当启用快速模式,新的点会被更快地添加,但精度较低。 */ + fastMode: boolean; + /** + !#en Remove all living segments of the ribbon. + !#zh 删除当前所有的拖尾片段。 + + @example + ```js + // stop particle system. + myParticleSystem.stopSystem(); + ``` + */ + reset(): void; + } + /** Particle System base class.
+ Attributes of a Particle System:
+ - emmision rate of the particles
+ - Gravity Mode (Mode A):
+ - gravity
+ - direction
+ - speed +- variance
+ - tangential acceleration +- variance
+ - radial acceleration +- variance
+ - Radius Mode (Mode B):
+ - startRadius +- variance
+ - endRadius +- variance
+ - rotate +- variance
+ - Properties common to all modes:
+ - life +- life variance
+ - start spin +- variance
+ - end spin +- variance
+ - start size +- variance
+ - end size +- variance
+ - start color +- variance
+ - end color +- variance
+ - life +- variance
+ - blending function
+ - texture
+
+ cocos2d also supports particles generated by Particle Designer (http://particledesigner.71squared.com/).
+ 'Radius Mode' in Particle Designer uses a fixed emit rate of 30 hz. Since that can't be guarateed in cocos2d,
+ cocos2d uses a another approach, but the results are almost identical.
+ cocos2d supports all the variables used by Particle Designer plus a bit more:
+ - spinning particles (supported when using ParticleSystem)
+ - tangential acceleration (Gravity mode)
+ - radial acceleration (Gravity mode)
+ - radius direction (Radius mode) (Particle Designer supports outwards to inwards direction only)
+ It is possible to customize any of the above mentioned properties in runtime. Example:
*/ + export class ParticleSystem extends _RendererUnderSG { + /** !#en Play particle in edit mode. + !#zh 在编辑器模式下预览粒子,启用后选中粒子时,粒子将自动播放。 */ + preview: boolean; + /** !#en + If set custom to true, then use custom properties insteadof read particle file. + !#zh 是否自定义粒子属性。 */ + custom: boolean; + /** !#en The plist file. + !#zh plist 格式的粒子配置文件。 */ + file: string; + /** . */ + texture: Texture2D; + /** !#en Current quantity of particles that are being simulated. + !#zh 当前播放的粒子数量。 */ + particleCount: number; + /** !#en Specify the source Blend Factor. + !#zh 指定原图混合模式。 */ + srcBlendFactor: BlendFactor; + /** !#en Specify the destination Blend Factor. + !#zh 指定目标的混合模式。 */ + dstBlendFactor: BlendFactor; + /** !#en If set to true, the particle system will automatically start playing on onLoad. + !#zh 如果设置为 true 运行时会自动发射粒子。 */ + playOnLoad: boolean; + /** !#en Indicate whether the owner node will be auto-removed when it has no particles left. + !#zh 粒子播放完毕后自动销毁所在的节点。 */ + autoRemoveOnFinish: boolean; + /** !#en Indicate whether the particle system is activated. + !#zh 是否激活粒子。 */ + active: boolean; + /** !#en Maximum particles of the system. + !#zh 粒子最大数量。 */ + totalParticles: number; + /** !#en How many seconds the emitter wil run. -1 means 'forever'. + !#zh 发射器生存时间,单位秒,-1表示持续发射。 */ + duration: number; + /** !#en Emission rate of the particles. + !#zh 每秒发射的粒子数目。 */ + emissionRate: number; + /** !#en Life of each particle setter. + !#zh 粒子的运行时间。 */ + life: number; + /** !#en Variation of life. + !#zh 粒子的运行时间变化范围。 */ + lifeVar: number; + /** !#en Start color of each particle. + !#zh 粒子初始颜色。 */ + startColor: Color; + /** !#en Variation of the start color. + !#zh 粒子初始颜色变化范围。 */ + startColorVar: Color; + /** !#en Ending color of each particle. + !#zh 粒子结束颜色。 */ + endColor: Color; + /** !#en Variation of the end color. + !#zh 粒子结束颜色变化范围。 */ + endColorVar: Color; + /** !#en Angle of each particle setter. + !#zh 粒子角度。 */ + angle: number; + /** !#en Variation of angle of each particle setter. + !#zh 粒子角度变化范围。 */ + angleVar: number; + /** !#en Start size in pixels of each particle. + !#zh 粒子的初始大小。 */ + startSize: number; + /** !#en Variation of start size in pixels. + !#zh 粒子初始大小的变化范围。 */ + startSizeVar: number; + /** !#en End size in pixels of each particle. + !#zh 粒子结束时的大小。 */ + endSize: number; + /** !#en Variation of end size in pixels. + !#zh 粒子结束大小的变化范围。 */ + endSizeVar: number; + /** !#en Start angle of each particle. + !#zh 粒子开始自旋角度。 */ + startSpin: number; + /** !#en Variation of start angle. + !#zh 粒子开始自旋角度变化范围。 */ + startSpinVar: number; + /** !#en End angle of each particle. + !#zh 粒子结束自旋角度。 */ + endSpin: number; + /** !#en Variation of end angle. + !#zh 粒子结束自旋角度变化范围。 */ + endSpinVar: number; + /** !#en Source position of the emitter. + !#zh 发射器位置。 */ + sourcePos: Vec2; + /** !#en Variation of source position. + !#zh 发射器位置的变化范围。(横向和纵向) */ + posVar: Vec2; + /** !#en Particles movement type. + !#zh 粒子位置类型。 */ + positionType: ParticleSystem.PositionType; + /** !#en Particles emitter modes. + !#zh 发射器类型。 */ + emitterMode: ParticleSystem.EmitterMode; + /** !#en Gravity of the emitter. + !#zh 重力。 */ + gravity: Vec2; + /** !#en Speed of the emitter. + !#zh 速度。 */ + speed: number; + /** !#en Variation of the speed. + !#zh 速度变化范围。 */ + speedVar: number; + /** !#en Tangential acceleration of each particle. Only available in 'Gravity' mode. + !#zh 每个粒子的切向加速度,即垂直于重力方向的加速度,只有在重力模式下可用。 */ + tangentialAccel: number; + /** !#en Variation of the tangential acceleration. + !#zh 每个粒子的切向加速度变化范围。 */ + tangentialAccelVar: number; + /** !#en Acceleration of each particle. Only available in 'Gravity' mode. + !#zh 粒子径向加速度,即平行于重力方向的加速度,只有在重力模式下可用。 */ + radialAccel: number; + /** !#en Variation of the radial acceleration. + !#zh 粒子径向加速度变化范围。 */ + radialAccelVar: number; + /** !#en Indicate whether the rotation of each particle equals to its direction. Only available in 'Gravity' mode. + !#zh 每个粒子的旋转是否等于其方向,只有在重力模式下可用。 */ + rotationIsDir: boolean; + /** !#en Starting radius of the particles. Only available in 'Radius' mode. + !#zh 初始半径,表示粒子出生时相对发射器的距离,只有在半径模式下可用。 */ + startRadius: number; + /** !#en Variation of the starting radius. + !#zh 初始半径变化范围。 */ + startRadiusVar: number; + /** !#en Ending radius of the particles. Only available in 'Radius' mode. + !#zh 结束半径,只有在半径模式下可用。 */ + endRadius: number; + /** !#en Variation of the ending radius. + !#zh 结束半径变化范围。 */ + endRadiusVar: number; + /** !#en Number of degress to rotate a particle around the source pos per second. Only available in 'Radius' mode. + !#zh 粒子每秒围绕起始点的旋转角度,只有在半径模式下可用。 */ + rotatePerS: number; + /** !#en Variation of the degress to rotate a particle around the source pos per second. + !#zh 粒子每秒围绕起始点的旋转角度变化范围。 */ + rotatePerSVar: number; + /** !#en The Particle emitter lives forever. + !#zh 表示发射器永久存在 */ + static DURATION_INFINITY: number; + /** !#en The starting size of the particle is equal to the ending size. + !#zh 表示粒子的起始大小等于结束大小。 */ + static START_SIZE_EQUAL_TO_END_SIZE: number; + /** !#en The starting radius of the particle is equal to the ending radius. + !#zh 表示粒子的起始半径等于结束半径。 */ + static START_RADIUS_EQUAL_TO_END_RADIUS: number; + /** + !#en Add a particle to the emitter. + !#zh 添加一个粒子到发射器中。 + */ + addParticle(): boolean; + /** + !#en Stop emitting particles. Running particles will continue to run until they die. + !#zh 停止发射器发射粒子,发射出去的粒子将继续运行,直至粒子生命结束。 + + @example + ```js + // stop particle system. + myParticleSystem.stopSystem(); + ``` + */ + stopSystem(): void; + /** + !#en Kill all living particles. + !#zh 杀死所有存在的粒子,然后重新启动粒子发射器。 + + @example + ```js + // play particle system. + myParticleSystem.resetSystem(); + ``` + */ + resetSystem(): void; + /** + !#en Whether or not the system is full. + !#zh 发射器中粒子是否大于等于设置的总粒子数量。 + */ + isFull(): boolean; + /** + !#en +

Sets a new CCSpriteFrame as particle.
+ WARNING: this method is experimental. Use setTextureWithRect instead. +

+ !#zh +

设置一个新的精灵帧为粒子。
+ 警告:这个函数只是试验,请使用 setTextureWithRect 实现。 +

+ @param spriteFrame spriteFrame + */ + setDisplayFrame(spriteFrame: SpriteFrame): void; + /** + !#en Sets a new texture with a rect. The rect is in texture position and size. + !#zh 设置一张新贴图和关联的矩形。 + @param texture texture + @param rect rect + */ + setTextureWithRect(texture: Texture2D, rect: Rect): void; + } + /** !#en Renders the TMX object. + !#zh 渲染 tmx object。 */ + export class TMXObject { + /** + !#en Get the name of object + !#zh 获取对象的名称 + */ + getObjectName(): string; + /** + !#en Get the property of object + !#zh 获取对象的属性 + @param propertyName propertyName + */ + getProperty(propertyName: string): any; + /** + !#en Get the properties of object + !#zh 获取对象的属性 + */ + getProperties(): any; + /** + !#en Set the object name + !#zh 设置对象名称 + @param name name + */ + setObjectName(name: string): void; + /** + !#en Set the properties of the object + !#zh 设置对象的属性 + @param props props + */ + setProperties(props: any): void; + } + /** !#en Render the TMX layer. + !#zh 渲染 TMX layer。 */ + export class TiledLayer extends _SGComponent { + /** + !#en Gets the layer name. + !#zh 获取层的名称。 + + @example + ```js + var layerName = tiledLayer.getLayerName(); + cc.log(layerName); + ``` + */ + getLayerName(): string; + /** + !#en Set the layer name. + !#zh 设置层的名称 + @param layerName layerName + + @example + ```js + tiledLayer.setLayerName("New Layer"); + ``` + */ + SetLayerName(layerName: string): void; + /** + !#en Return the value for the specific property name. + !#zh 获取指定属性名的值。 + @param propertyName propertyName + + @example + ```js + var property = tiledLayer.getProperty("info"); + cc.log(property); + ``` + */ + getProperty(propertyName: string): any; + /** + !#en Returns the position in pixels of a given tile coordinate. + !#zh 获取指定 tile 的像素坐标。 + @param pos position or x + @param y y + + @example + ```js + var pos = tiledLayer.getPositionAt(cc.v2(0, 0)); + cc.log("Pos: " + pos); + var pos = tiledLayer.getPositionAt(0, 0); + cc.log("Pos: " + pos); + ``` + */ + getPositionAt(pos: Vec2|number, y?: number): Vec2; + /** + !#en Removes a tile at given tile coordinate. + !#zh 删除指定坐标上的 tile。 + @param pos position or x + @param y y + + @example + ```js + tiledLayer.removeTileAt(cc.v2(0, 0)); + tiledLayer.removeTileAt(0, 0); + ``` + */ + removeTileAt(pos: Vec2|number, y?: number): void; + /** + !#en + Sets the tile gid (gid = tile global id) at a given tile coordinate.
+ The Tile GID can be obtained by using the method "tileGIDAt" or by using the TMX editor . Tileset Mgr +1.
+ If a tile is already placed at that position, then it will be removed. + !#zh + 设置给定坐标的 tile 的 gid (gid = tile 全局 id), + tile 的 GID 可以使用方法 “tileGIDAt” 来获得。
+ 如果一个 tile 已经放在那个位置,那么它将被删除。 + @param gid gid + @param posOrX position or x + @param flagsOrY flags or y + @param flags flags + + @example + ```js + tiledLayer.setTileGID(1001, 10, 10, 1) + ``` + */ + setTileGID(gid: number, posOrX: Vec2|number, flagsOrY: number, flags?: number): void; + /** + !#en + Returns the tile gid at a given tile coordinate.
+ if it returns 0, it means that the tile is empty.
+ This method requires the the tile map has not been previously released (eg. don't call layer.releaseMap())
+ !#zh + 通过给定的 tile 坐标、flags(可选)返回 tile 的 GID.
+ 如果它返回 0,则表示该 tile 为空。
+ 该方法要求 tile 地图之前没有被释放过(如:没有调用过layer.releaseMap()). + @param pos or x + @param y y + + @example + ```js + var tileGid = tiledLayer.getTileGIDAt(0, 0); + ``` + */ + getTileGIDAt(pos: Vec2|number, y?: number): number; + /** + !#en + Returns the tile (_ccsg.Sprite) at a given a tile coordinate.
+ The returned _ccsg.Sprite will be already added to the _ccsg.TMXLayer. Don't add it again.
+ The _ccsg.Sprite can be treated like any other _ccsg.Sprite: rotated, scaled, translated, opacity, color, etc.
+ You can remove either by calling:
+ - layer.removeChild(sprite, cleanup);
+ - or layer.removeTileAt(ccp(x,y)); + !#zh + 通过指定的 tile 坐标获取对应的 tile(Sprite)。 返回的 tile(Sprite) 应是已经添加到 TMXLayer,请不要重复添加。
+ 这个 tile(Sprite) 如同其他的 Sprite 一样,可以旋转、缩放、翻转、透明化、设置颜色等。
+ 你可以通过调用以下方法来对它进行删除:
+ 1. layer.removeChild(sprite, cleanup);
+ 2. 或 layer.removeTileAt(cc.v2(x,y)); + @param pos or x + @param y y + + @example + ```js + var title = tiledLayer.getTileAt(100, 100); + cc.log(title); + ``` + */ + getTileAt(pos: Vec2|number, y?: number): _ccsg.Sprite; + /** + !#en + Dealloc the map that contains the tile position from memory.
+ Unless you want to know at runtime the tiles positions, you can safely call this method.
+ If you are going to call layer.getTileGIDAt() then, don't release the map. + !#zh + 从内存中释放包含 tile 位置信息的地图。
+ 除了在运行时想要知道 tiles 的位置信息外,你都可安全的调用此方法。
+ 如果你之后还要调用 layer.tileGIDAt(), 请不要释放地图. + + @example + ```js + tiledLayer.releaseMap(); + ``` + */ + releaseMap(): void; + /** + !#en Sets the untransformed size of the _ccsg.TMXLayer. + !#zh 设置未转换的 layer 大小。 + @param size The untransformed size of the _ccsg.TMXLayer or The untransformed size's width of the TMXLayer. + @param height The untransformed size's height of the _ccsg.TMXLayer. + + @example + ```js + tiledLayer.setContentSize(100, 100); + ``` + */ + setContentSize(size: Size|number, height?: number): void; + /** + !#en Return texture of cc.SpriteBatchNode. + !#zh 获取纹理。 + + @example + ```js + var texture = tiledLayer.getTexture(); + cc.log("Texture: " + texture); + ``` + */ + getTexture(): Texture2D; + /** + !#en Set the texture of cc.SpriteBatchNode. + !#zh 设置纹理。 + @param texture texture + + @example + ```js + tiledLayer.setTexture(texture); + ``` + */ + setTexture(texture: Texture2D): void; + /** + !#en Set the opacity of all tiles + !#zh 设置所有 Tile 的透明度 + @param opacity opacity + + @example + ```js + tiledLayer.setTileOpacity(128); + ``` + */ + setTileOpacity(opacity: number): void; + /** + !#en Gets layer size. + !#zh 获得层大小。 + + @example + ```js + var size = tiledLayer.getLayerSize(); + cc.log("layer size: " + size); + ``` + */ + getLayerSize(): Size; + /** + !#en Set layer size. + !#zh 设置层大小。 + @param layerSize layerSize + + @example + ```js + tiledLayer.setLayerSize(new cc.size(5, 5)); + ``` + */ + setLayerSize(layerSize: Size): void; + /** + !#en Size of the map's tile (could be different from the tile's size). + !#zh 获取 tile 的大小( tile 的大小可能会有所不同)。 + + @example + ```js + var mapTileSize = tiledLayer.getMapTileSize(); + cc.log("MapTile size: " + mapTileSize); + ``` + */ + getMapTileSize(): Size; + /** + !#en Set the map tile size. + !#zh 设置 tile 的大小。 + @param tileSize tileSize + + @example + ```js + tiledLayer.setMapTileSize(new cc.size(10, 10)); + ``` + */ + setMapTileSize(tileSize: Size): void; + /** + !#en Pointer to the map of tiles. + !#zh 获取地图 tiles。 + + @example + ```js + var tiles = tiledLayer.getTiles(); + ``` + */ + getTiles(): any[]; + /** + !#en Pointer to the map of tiles. + !#zh 设置地图 tiles + @param tiles tiles + + @example + ```js + tiledLayer.setTiles(tiles); + ``` + */ + setTiles(tiles: any[]): void; + /** + !#en Tile set information for the layer. + !#zh 获取 layer 的 Tileset 信息。 + + @example + ```js + var tileset = tiledLayer.getTileSet(); + ``` + */ + getTileSet(): TMXTilesetInfo; + /** + !#en Tile set information for the layer. + !#zh 设置 layer 的 Tileset 信息。 + @param tileset tileset + + @example + ```js + tiledLayer.setTileSet(tileset); + ``` + */ + setTileSet(tileset: TMXTilesetInfo): void; + /** + !#en Layer orientation, which is the same as the map orientation. + !#zh 获取 Layer 方向(同地图方向)。 + + @example + ```js + var orientation = tiledLayer.getLayerOrientation(); + cc.log("Layer Orientation: " + orientation); + ``` + */ + getLayerOrientation(): number; + /** + !#en Layer orientation, which is the same as the map orientation. + !#zh 设置 Layer 方向(同地图方向)。 + @param orientation orientation + + @example + ```js + tiledLayer.setLayerOrientation(TiledMap.Orientation.ORTHO); + ``` + */ + setLayerOrientation(orientation: TiledMap.Orientation): void; + /** + !#en properties from the layer. They can be added using Tiled. + !#zh 获取 layer 的属性,可以使用 Tiled 编辑器添加属性。 + + @example + ```js + var properties = tiledLayer.getProperties(); + cc.log("Properties: " + properties); + ``` + */ + getProperties(): any[]; + /** + !#en properties from the layer. They can be added using Tiled. + !#zh 设置层属性。 + @param properties properties + + @example + ```js + tiledLayer.setLayerOrientation(properties); + ``` + */ + setProperties(properties: any[]): void; + } + /** !#en Renders a TMX Tile Map in the scene. + !#zh 在场景中渲染一个 tmx 格式的 Tile Map。 */ + export class TiledMap extends Component { + /** !#en The TiledMap Asset. + !#zh TiledMap 资源。 */ + tmxAsset: TiledMapAsset; + /** + !#en Gets the map size. + !#zh 获取地图大小。 + + @example + ```js + var mapSize = tiledMap.getMapSize(); + cc.log("Map Size: " + mapSize); + ``` + */ + getMapSize(): Size; + /** + !#en Set the map size. + !#zh 设置地图大小。 + @param mapSize mapSize + + @example + ```js + tiledMap.setMapSize(new cc.size(960, 640)); + ``` + */ + setMapSize(mapSize: Size): void; + /** + !#en Gets the tile size. + !#zh 获取地图背景中 tile 元素的大小。 + + @example + ```js + var tileSize = tiledMap.getTileSize(); + cc.log("Tile Size: " + tileSize); + ``` + */ + getTileSize(): Size; + /** + !#en Set the tile size. + !#zh 设置地图背景中 tile 元素的大小。 + @param tileSize tileSize + + @example + ```js + tiledMap.setTileSize(new cc.size(10, 10)); + ``` + */ + setTileSize(tileSize: Size): void; + /** + !#en map orientation. + !#zh 获取地图方向。 + + @example + ```js + var mapOrientation = tiledMap.getMapOrientation(); + cc.log("Map Orientation: " + mapOrientation); + ``` + */ + getMapOrientation(): number; + /** + !#en map orientation. + !#zh 设置地图方向。 + @param orientation orientation + + @example + ```js + tiledMap.setMapOrientation(TiledMap.Orientation.ORTHO); + ``` + */ + setMapOrientation(orientation: TiledMap.Orientation): void; + /** + !#en object groups. + !#zh 获取所有的对象层。 + + @example + ```js + var objGroups = titledMap.getObjectGroups(); + for (var i = 0; i < objGroups.length; ++i) { + cc.log("obj: " + objGroups[i]); + } + ``` + */ + getObjectGroups(): TiledObjectGroup[]; + /** + !#en Gets the map properties. + !#zh 获取地图的属性。 + + @example + ```js + var properties = titledMap.getProperties(); + for (var i = 0; i < properties.length; ++i) { + cc.log("Properties: " + properties[i]); + } + ``` + */ + getProperties(): any[]; + /** + !#en Set the map properties. + !#zh 设置地图的属性。 + @param properties properties + + @example + ```js + titledMap.setProperties(properties); + ``` + */ + setProperties(properties: any[]): void; + /** + !#en Return All layers array. + !#zh 返回包含所有 layer 的数组。 + + @example + ```js + var layers = titledMap.allLayers(); + for (var i = 0; i < layers.length; ++i) { + cc.log("Layers: " + layers[i]); + } + ``` + */ + allLayers(): TiledLayer[]; + /** + !#en return the cc.TiledLayer for the specific layer. + !#zh 获取指定名称的 layer。 + @param layerName layerName + + @example + ```js + var layer = titledMap.getLayer("Player"); + cc.log(layer); + ``` + */ + getLayer(layerName: string): TiledLayer; + /** + !#en Return the TMXObjectGroup for the specific group. + !#zh 获取指定的 TMXObjectGroup。 + @param groupName groupName + + @example + ```js + var group = titledMap.getObjectGroup("Players"); + cc.log("ObjectGroup: " + group); + ``` + */ + getObjectGroup(groupName: string): TiledObjectGroup; + /** + !#en Return the value for the specific property name. + !#zh 通过属性名称,获取指定的属性。 + @param propertyName propertyName + + @example + ```js + var property = titledMap.getProperty("info"); + cc.log("Property: " + property); + ``` + */ + getProperty(propertyName: string): string; + /** + !#en Return properties dictionary for tile GID. + !#zh 通过 GID ,获取指定的属性。 + @param GID GID + + @example + ```js + var properties = titledMap.getPropertiesForGID(GID); + cc.log("Properties: " + properties); + ``` + */ + getPropertiesForGID(GID: number): any; + } + /** Class for tiled map asset handling. */ + export class TiledMapAsset extends Asset { + } + /** !#en Renders the TMX object group. + !#zh 渲染 tmx object group。 */ + export class TiledObjectGroup extends _SGComponent { + /** + !#en Offset position of child objects. + !#zh 获取子对象的偏移位置。 + + @example + ```js + var offset = tMXObjectGroup.getPositionOffset(); + ``` + */ + getPositionOffset(): Vec2; + /** + !#en Offset position of child objects. + !#zh 设置子对象的偏移位置。 + @param offset offset + + @example + ```js + tMXObjectGroup.setPositionOffset(cc.v2(5, 5)); + ``` + */ + setPositionOffset(offset: Vec2): void; + /** + !#en List of properties stored in a dictionary. + !#zh 以映射的形式获取属性列表。 + + @example + ```js + var offset = tMXObjectGroup.getProperties(); + ``` + */ + getProperties(): any; + /** + !#en Set the properties of the object group. + !#zh 设置属性列表。 + @param Var Var + + @example + ```js + tMXObjectGroup.setProperties(obj); + ``` + */ + setProperties(Var: any): void; + /** + !#en Gets the Group name. + !#zh 获取组名称。 + + @example + ```js + var groupName = tMXObjectGroup.getGroupName; + ``` + */ + getGroupName(): string; + /** + !#en Set the Group name. + !#zh 设置组名称。 + @param groupName groupName + + @example + ```js + tMXObjectGroup.setGroupName("New Group"); + ``` + */ + setGroupName(groupName: string): void; + /** + !#en + Return the object for the specific object name.
+ It will return the 1st object found on the array for the given name. + !#zh 获取指定的对象。 + @param objectName objectName + + @example + ```js + var object = tMXObjectGroup.getObject("Group"); + ``` + */ + getObject(objectName: string): any; + /** + !#en Gets the objects. + !#zh 获取对象数组。 + + @example + ```js + var objects = tMXObjectGroup.getObjects(); + ``` + */ + getObjects(): any[]; + } + /** !#en + cc.NodePool is the cache pool designed for node type.
+ It can helps you to improve your game performance for objects which need frequent release and recreate operations
+ + It's recommended to create cc.NodePool instances by node type, the type corresponds to node type in game design, not the class, + for example, a prefab is a specific node type.
+ When you create a node pool, you can pass a Component which contains `unuse`, `reuse` functions to control the content of node.
+ + Some common use case is :
+ 1. Bullets in game (die very soon, massive creation and recreation, no side effect on other objects)
+ 2. Blocks in candy crash (massive creation and recreation)
+ etc... + !#zh + cc.NodePool 是用于管理节点对象的对象缓存池。
+ 它可以帮助您提高游戏性能,适用于优化对象的反复创建和销毁
+ 以前 cocos2d-x 中的 cc.pool 和新的节点事件注册系统不兼容,因此请使用 cc.NodePool 来代替。 + + 新的 NodePool 需要实例化之后才能使用,每种不同的节点对象池需要一个不同的对象池实例,这里的种类对应于游戏中的节点设计,一个 prefab 相当于一个种类的节点。
+ 在创建缓冲池时,可以传入一个包含 unuse, reuse 函数的组件类型用于节点的回收和复用逻辑。
+ + 一些常见的用例是:
+ 1.在游戏中的子弹(死亡很快,频繁创建,对其他对象无副作用)
+ 2.糖果粉碎传奇中的木块(频繁创建)。 + 等等.... */ + export class NodePool { + /** + !#en + Constructor for creating a pool for a specific node template (usually a prefab). You can pass a component (type or name) argument for handling event for reusing and recycling node. + !#zh + 使用构造函数来创建一个节点专用的对象池,您可以传递一个组件类型或名称,用于处理节点回收和复用时的事件逻辑。 + @param poolHandlerComp !#en The constructor or the class name of the component to control the unuse/reuse logic. !#zh 处理节点回收和复用事件逻辑的组件类型或名称。 + + @example + ```js + properties: { + template: cc.Prefab + }, + onLoad () { + // MyTemplateHandler is a component with 'unuse' and 'reuse' to handle events when node is reused or recycled. + this.myPool = new cc.NodePool('MyTemplateHandler'); + } + ``` + */ + constructor(poolHandlerComp?: {prototype: Component}|string); + /** !#en The pool handler component, it could be the class name or the constructor. + !#zh 缓冲池处理组件,用于节点的回收和复用逻辑,这个属性可以是组件类名或组件的构造函数。 */ + poolHandlerComp: Function|string; + /** + !#en The current available size in the pool + !#zh 获取当前缓冲池的可用对象数量 + */ + size(): number; + /** + !#en Destroy all cached nodes in the pool + !#zh 销毁对象池中缓存的所有节点 + */ + clear(): void; + /** + !#en Put a new Node into the pool. + It will automatically remove the node from its parent without cleanup. + It will also invoke unuse method of the poolHandlerComp if exist. + !#zh 向缓冲池中存入一个不再需要的节点对象。 + 这个函数会自动将目标节点从父节点上移除,但是不会进行 cleanup 操作。 + 这个函数会调用 poolHandlerComp 的 unuse 函数,如果组件和函数都存在的话。 + @param obj obj + + @example + ```js + let myNode = cc.instantiate(this.template); + this.myPool.put(myNode); + ``` + */ + put(obj: Node): void; + /** + !#en Get a obj from pool, if no available object in pool, null will be returned. + This function will invoke the reuse function of poolHandlerComp if exist. + !#zh 获取对象池中的对象,如果对象池没有可用对象,则返回空。 + 这个函数会调用 poolHandlerComp 的 reuse 函数,如果组件和函数都存在的话。 + @param params !#en Params to pass to 'reuse' method in poolHandlerComp !#zh 向 poolHandlerComp 中的 'reuse' 函数传递的参数 + + @example + ```js + let newNode = this.myPool.get(); + ``` + */ + get(...params: any[]): Node; + } + /** !#en + Attention: In creator, it's strongly not recommended to use cc.pool to manager cc.Node. + We provided {{#crossLink "NodePool"}}cc.NodePool{{/crossLink}} instead. + + cc.pool is a singleton object serves as an object cache pool.
+ It can helps you to improve your game performance for objects which need frequent release and recreate operations
+ !#zh + 首先请注意,在 Creator 中我们强烈不建议使用 cc.pool 来管理 cc.Node 节点对象,请使用 {{#crossLink "NodePool"}}cc.NodePool{{/crossLink}} 代替 + 因为 cc.pool 是面向类来设计的,而 cc.Node 中使用 Component 来进行组合,它的类永远都一样,实际却千差万别。 + + cc.pool 是一个单例对象,用作为对象缓存池。
+ 它可以帮助您提高游戏性能,适用于优化对象的反复创建和销毁
*/ + export class pool { + /** + !#en Put the obj in pool. + !#zh 加入对象到对象池中。 + @param obj The need put in pool object. + + @example + ```js + --------------------------------- + var sp = new _ccsg.Sprite("a.png"); + this.addChild(sp); + cc.pool.putInPool(sp); + cc.pool.getFromPool(_ccsg.Sprite, "a.png"); + + ``` + */ + putInPool(obj: any): void; + /** + !#en Check if this kind of obj has already in pool. + !#zh 检查对象池中是否有指定对象的存在。 + @param objClass The check object class. + */ + hasObject(objClass: any): boolean; + /** + !#en Remove the obj if you want to delete it. + !#zh 移除在对象池中指定的对象。 + */ + removeObject(): void; + /** + !#en Get the obj from pool. + !#zh 获取对象池中的指定对象。 + */ + getFromPool(): any; + /** + !#en Remove all objs in pool and reset the pool. + !#zh 移除对象池中的所有对象,并且重置对象池。 + */ + drainAllPools(): void; + } + /** !#en Box Collider. + !#zh 包围盒碰撞组件 */ + export class BoxCollider extends Collider implements Collider.Box { + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Box size + !#zh 包围盒大小 */ + size: Size; + } + /** !#en Circle Collider. + !#zh 圆形碰撞组件 */ + export class CircleCollider extends Collider implements Collider.Circle { + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Circle radius + !#zh 圆形半径 */ + radius: number; + } + /** !#en Collider component base class. + !#zh 碰撞组件基类 */ + export class Collider extends Component { + /** !#en Tag. If a node has several collider components, you can judge which type of collider is collided according to the tag. + !#zh 标签。当一个节点上有多个碰撞组件时,在发生碰撞后,可以使用此标签来判断是节点上的哪个碰撞组件被碰撞了。 */ + tag: number; + } + /** !#en + A simple collision manager class. + It will calculate whether the collider collides other colliders, if collides then call the callbacks. + !#zh + 一个简单的碰撞组件管理类,用于处理节点之间的碰撞组件是否产生了碰撞,并调用相应回调函数。 */ + export class CollisionManager implements EventTarget { + /** !#en + !#zh + 是否开启碰撞管理,默认为不开启 */ + enabled: boolean; + /** !#en + !#zh + 是否绘制碰撞组件的包围盒,默认为不绘制 */ + enabledDrawBoundingBox: boolean; + /** !#en + !#zh + 是否绘制碰撞组件的形状,默认为不绘制 */ + enabledDebugDraw: boolean; + /** + !#en + Register an callback of a specific event type on the EventTarget. + !#zh + 注册事件目标的特定事件类型回调。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + @param useCapture When set to true, the capture argument prevents callback + from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. + When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE. + Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET. + + @example + ```js + node.on(cc.Node.EventType.TOUCH_END, function (event) { + cc.log("this is callback"); + }, node); + ``` + */ + on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void; + on(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void; + /** + !#en + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. + !#zh + 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not. + If not specified, useCapture defaults to false. If a callback was registered twice, + one with capture and one without, each must be removed separately. Removal of a capturing callback + does not affect a non-capturing version of the same listener, and vice versa. + + @example + ```js + // register touchEnd eventListener + var touchEnd = node.on(cc.Node.EventType.TOUCH_END, function (event) { + cc.log("this is callback"); + }, node); + // remove touch end event listener + node.off(cc.Node.EventType.TOUCH_END, touchEnd, node); + // remove all touch end event listeners + node.off(cc.Node.EventType.TOUCH_END); + ``` + */ + off(type: string, callback?: Function, target?: any, useCapture?: boolean): void; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + @param useCapture When set to true, the capture argument prevents callback + from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. + When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE. + Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET. + + @example + ```js + node.once(cc.Node.EventType.TOUCH_END, function (event) { + cc.log("this is callback"); + }, node); + ``` + */ + once(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void; + once(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void; + /** + !#en + Dispatches an event into the event flow. + The event target is the EventTarget object upon which the dispatchEvent() method is called. + !#zh 分发事件到事件流中。 + @param event The Event object that is dispatched into the event flow + */ + dispatchEvent(event: Event): void; + /** + !#en + Send an event to this object directly, this method will not propagate the event to any other objects. + The event will be created from the supplied message, you can get the "detail" argument from event.detail. + !#zh + 该对象直接发送事件, 这种方法不会对事件传播到任何其他对象。 + @param message the message to send + @param detail whatever argument the message needs + */ + emit(message: string, detail?: any): void; + } + /** !#en Intersection helper class + !#zh 辅助类,用于测试形状与形状是否相交 */ + export class Intersection { + /** + !#en Test line and line + !#zh 测试线段与线段是否相交 + @param a1 The start point of the first line + @param a2 The end point of the first line + @param b1 The start point of the second line + @param b2 The end point of the second line + */ + static lineLine(a1: Vec2, a2: Vec2, b1: Vec2, b2: Vec2): boolean; + /** + !#en Test line and rect + !#zh 测试线段与矩形是否相交 + @param a1 The start point of the line + @param a2 The end point of the line + @param b The rect + */ + static lineRect(a1: Vec2, a2: Vec2, b: Rect): boolean; + /** + !#en Test line and polygon + !#zh 测试线段与多边形是否相交 + @param a1 The start point of the line + @param a2 The end point of the line + @param b The polygon, a set of points + */ + static linePolygon(a1: Vec2, a2: Vec2, b: Vec2[]): boolean; + /** + !#en Test rect and rect + !#zh 测试矩形与矩形是否相交 + @param a The first rect + @param b The second rect + */ + static rectRect(a: Rect, b: Rect): boolean; + /** + !#en Test rect and polygon + !#zh 测试矩形与多边形是否相交 + @param a The rect + @param b The polygon, a set of points + */ + static rectPolygon(a: Rect, b: Vec2[]): boolean; + /** + !#en Test polygon and polygon + !#zh 测试多边形与多边形是否相交 + @param a The first polygon, a set of points + @param b The second polygon, a set of points + */ + static polygonPolygon(a: Vec2[], b: Vec2[]): boolean; + /** + !#en Test circle and circle + !#zh 测试圆形与圆形是否相交 + @param a Object contains position and radius + @param b Object contains position and radius + */ + static circleCircle(a: {position: Vec2, radius: number}, b: {position: Vec2, radius: number}): boolean; + /** + !#en Test polygon and circle + !#zh 测试矩形与圆形是否相交 + @param polygon The Polygon, a set of points + @param circle Object contains position and radius + */ + static polygonCircle(polygon: Vec2[], circle: {position: Vec2, radius: number}): boolean; + /** + !#en Test whether the point is in the polygon + !#zh 测试一个点是否在一个多边形中 + @param point The point + @param polygon The polygon, a set of points + */ + static pointInPolygon(point: Vec2, polygon: Vec2[]): boolean; + /** + !#en Calculate the distance of point to line. + !#zh 计算点到直线的距离。如果这是一条线段并且垂足不在线段内,则会计算点到线段端点的距离。 + @param point The point + @param start The start point of line + @param end The end point of line + @param isSegment whether this line is a segment + */ + static pointLineDistance(point: Vec2, start: Vec2, end: Vec2, isSegment: boolean): boolean; + } + /** !#en Polygon Collider. + !#zh 多边形碰撞组件 */ + export class PolygonCollider extends Collider implements Collider.Polygon { + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Polygon points + !#zh 多边形顶点数组 */ + points: [Vec2]; + } + /** !#en + Base class for handling assets used in Fireball. This class can be instantiate. + + You may want to override:
+ - createNode
+ - cc.Object._serialize
+ - cc.Object._deserialize
+ !#zh + 资源基类,该类可以被实例化。
+ + 您可能需要重写:
+ - createNode
+ - cc.Object._serialize
+ - cc.Object._deserialize
*/ + export class Asset extends RawAsset { + /** !#en + Returns the url of this asset's first raw file, if none of rawFile exists, + it will returns an empty string. + !#zh 返回该资源的原始文件的 URL,如果不支持 RAW 文件,它将返回一个空字符串。 */ + rawUrl: string; + /** !#en + Returns the url of this asset's raw files, if none of rawFile exists, + it will returns an empty array. + !#zh 返回该资源的原文件的 URL 数组,如果不支持 RAW 文件,它将返回一个空数组。 */ + rawUrls: string[]; + /** !#en Indicates whether its dependent raw assets can support deferred load if the owner scene (or prefab) is marked as `asyncLoadAssets`. + !#zh 当场景或 Prefab 被标记为 `asyncLoadAssets`,禁止延迟加载该资源所依赖的其它 RawAsset。 */ + static preventDeferredLoadDependents: boolean; + /** + !#en + Create a new node using this asset in the scene.
+ If this type of asset dont have its corresponding node type, this method should be null. + !#zh + 使用该资源在场景中创建一个新节点。
+ 如果这类资源没有相应的节点类型,该方法应该是空的。 + @param callback callback + */ + createNode(callback: (error: string, node: any) => void): void; + } + /** !#en Class for audio data handling. + !#zh 音频资源类。 */ + export class AudioClip extends RawAsset { + } + /** !#en Class for BitmapFont handling. + !#zh 位图字体资源类。 */ + export class BitmapFont extends RawAsset { + } + /** !#en Class for Font handling. + !#zh 字体资源类。 */ + export class Font extends RawAsset { + } + /** !#en Class for LabelAtlas handling. + !#zh 艺术数字字体资源类。 */ + export class LabelAtlas extends BitmapFont { + } + /** !#en Class for prefab handling. + !#zh 预制资源类。 */ + export class Prefab extends Asset { + /** the main cc.Node in the prefab */ + data: Node; + /** !#en Indicates the raw assets of this prefab can be load after prefab loaded. + !#zh 指示该 Prefab 依赖的资源可否在 Prefab 加载后再延迟加载。 */ + asyncLoadAssets: boolean; + /** + Dynamically translation prefab data into minimized code.
+ This method will be called automatically before the first time the prefab being instantiated, + but you can re-call to refresh the create function once you modified the original prefab data in script. + */ + compileCreateFunction(): void; + } + /** !#en + The base class for registering asset types. + + You may want to override: + - createNode (static) + !#zh + 注册用的资源基类。
+ 你可能要重写:
+ - createNode (static) */ + export class RawAsset extends Object { + /** + !#en + Create a new node in the scene.
+ If this type of asset dont have its corresponding node type, this method should be null. + !#zh + 在场景中创建一个新节点。
+ 如果这类资源没有相应的节点类型,该方法应该是空的。 + @param Info Info + @param callback callback + */ + static createNodeByInfo(Info: any, callback: (error: string, node: any) => void): void; + } + /** !#en Class for scene handling. + !#zh 场景资源类。 */ + export class SceneAsset extends Asset { + scene: Scene; + /** !#en Indicates the raw assets of this scene can be load after scene launched. + !#zh 指示该场景依赖的资源可否在场景切换后再延迟加载。 */ + asyncLoadAssets: boolean; + } + /** !#en Class for script handling. + !#zh Script 资源类。 */ + export class _Script extends Asset { + } + /** !#en Class for JavaScript handling. + !#zh JavaScript 资源类。 */ + export class _JavaScript extends Asset { + } + /** !#en Class for coffeescript handling. + !#zh CoffeeScript 资源类。 */ + export class CoffeeScript extends Asset { + } + /** !#en Class for TypeScript handling. + !#zh TypeScript 资源类。 */ + export class TypeScript extends Asset { + } + /** !#en Class for sprite atlas handling. + !#zh 精灵图集资源类。 */ + export class SpriteAtlas extends RawAsset { + /** + Returns the texture of the sprite atlas + */ + getTexture(): Texture2D; + /** + Returns the sprite frame correspond to the given key in sprite atlas. + @param key key + */ + getSpriteFrame(key: string): SpriteFrame; + /** + Returns the sprite frames in sprite atlas. + */ + getSpriteFrames(): [SpriteFrame]; + } + /** !#en Class for TTFFont handling. + !#zh TTF 字体资源类。 */ + export class TTFFont extends Asset { + } + /** !#en Class for text file. + !#zh 文本资源类。 */ + export class TextAsset extends Asset { + } + /** !#en + Camera is usefull when making reel game or other games which need scroll screen. + Using camera will be more efficient than moving node to scroll screen. + Camera + !#zh + 摄像机在制作卷轴或是其他需要移动屏幕的游戏时比较有用,使用摄像机将会比移动节点来移动屏幕更加高效。 */ + export class Camera extends _RendererUnderSG { + /** !#en + The camera zoom ratio. + !#zh + 摄像机缩放比率 */ + zoomRatio: number; + /** !#en + Current active camera, the scene should only have one active camera at the same time. + !#zh + 当前激活的摄像机,场景中在同一时间内只能有一个激活的摄像机。 */ + static main: Camera; + /** + !#en + Add the specified target to camera. + !#zh + 将指定的节点添加到摄像机中。 + @param target target + */ + addTarget(target: Node): void; + /** + !#en + Remove the specified target from camera. + !#zh + 将指定的节点从摄像机中移除。 + @param target target + */ + removeTarget(target: Node): void; + /** + !#en + Get all camera targets. + !#zh + 获取所有摄像机目标节点。 + */ + getTargets(): [Node]; + /** + !#en + Returns the matrix that transform the node's (local) space coordinates into the camera's space coordinates. + !#zh + 返回一个将节点坐标系转换到摄像机坐标系下的矩阵 + @param node the node which should transform + */ + getNodeToCameraTransform(node: Node): AffineTransform; + /** + !#en + Conver a camera coordinates point to world coordinates. + !#zh + 将一个摄像机坐标系下的点转换到世界坐标系下。 + @param point the point which should transform + */ + getCameraToWorldPoint(point: Node): Vec2; + /** + !#en + Check whether the node is in the camera. + !#zh + 检测节点是否被此摄像机影响 + @param node the node which need to check + */ + containsNode(node: Node): boolean; + } + /** !#en The animation component is used to play back animations. + + Animation provide several events to register: + - play : Emit when begin playing animation + - stop : Emit when stop playing animation + - pause : Emit when pause animation + - resume : Emit when resume animation + - lastframe : If animation repeat count is larger than 1, emit when animation play to the last frame + - finished : Emit when finish playing animation + + !#zh Animation 组件用于播放动画。 + + Animation 提供了一系列可注册的事件: + - play : 开始播放时 + - stop : 停止播放时 + - pause : 暂停播放时 + - resume : 恢复播放时 + - lastframe : 假如动画循环次数大于 1,当动画播放到最后一帧时 + - finished : 动画播放完成时 */ + export class Animation extends Component implements EventTarget { + /** !#en Animation will play the default clip when start game. + !#zh 在勾选自动播放或调用 play() 时默认播放的动画剪辑。 */ + defaultClip: AnimationClip; + /** !#en Current played clip. + !#zh 当前播放的动画剪辑。 */ + currentClip: AnimationClip; + /** !#en Whether the animation should auto play the default clip when start game. + !#zh 是否在运行游戏后自动播放默认动画剪辑。 */ + playOnLoad: boolean; + /** + !#en Get all the clips used in this animation. + !#zh 获取动画组件上的所有动画剪辑。 + */ + getClips(): AnimationClip[]; + /** + !#en Plays an animation and stop other animations. + !#zh 播放指定的动画,并且停止当前正在播放动画。如果没有指定动画,则播放默认动画。 + @param name The name of animation to play. If no name is supplied then the default animation will be played. + @param startTime play an animation from startTime + + @example + ```js + var animCtrl = this.node.getComponent(cc.Animation); + animCtrl.play("linear"); + ``` + */ + play(name?: string, startTime?: number): AnimationState; + /** + !#en + Plays an additive animation, it will not stop other animations. + If there are other animations playing, then will play several animations at the same time. + !#zh 播放指定的动画(将不会停止当前播放的动画)。如果没有指定动画,则播放默认动画。 + @param name The name of animation to play. If no name is supplied then the default animation will be played. + @param startTime play an animation from startTime + + @example + ```js + // linear_1 and linear_2 at the same time playing. + var animCtrl = this.node.getComponent(cc.Animation); + animCtrl.playAdditive("linear_1"); + animCtrl.playAdditive("linear_2"); + ``` + */ + playAdditive(name?: string, startTime?: number): AnimationState; + /** + !#en Stops an animation named name. If no name is supplied then stops all playing animations that were started with this Animation.
+ Stopping an animation also Rewinds it to the Start. + !#zh 停止指定的动画。如果没有指定名字,则停止当前正在播放的动画。 + @param name The animation to stop, if not supplied then stops all playing animations. + */ + stop(name?: string): void; + /** + !#en Pauses an animation named name. If no name is supplied then pauses all playing animations that were started with this Animation. + !#zh 暂停当前或者指定的动画。如果没有指定名字,则暂停当前正在播放的动画。 + @param name The animation to pauses, if not supplied then pauses all playing animations. + */ + pause(name?: string): void; + /** + !#en Resumes an animation named name. If no name is supplied then resumes all paused animations that were started with this Animation. + !#zh 重新播放指定的动画,如果没有指定名字,则重新播放当前正在播放的动画。 + @param name The animation to resumes, if not supplied then resumes all paused animations. + */ + resume(name?: string): void; + /** + !#en Make an animation named name go to the specified time. If no name is supplied then make all animations go to the specified time. + !#zh 设置指定动画的播放时间。如果没有指定名字,则设置当前播放动画的播放时间。 + @param time The time to go to + @param name Specified animation name, if not supplied then make all animations go to the time. + */ + setCurrentTime(time?: number, name?: string): void; + /** + !#en Returns the animation state named name. If no animation with the specified name, the function will return null. + !#zh 获取当前或者指定的动画状态,如果未找到指定动画剪辑则返回 null。 + @param name name + */ + getAnimationState(name: string): AnimationState; + /** + !#en Adds a clip to the animation with name newName. If a clip with that name already exists it will be replaced with the new clip. + !#zh 添加动画剪辑,并且可以重新设置该动画剪辑的名称。 + @param clip the clip to add + @param newName newName + */ + addClip(clip: AnimationClip, newName?: string): AnimationState; + /** + !#en + Remove clip from the animation list. This will remove the clip and any animation states based on it. + If there are animation states depand on the clip are playing or clip is defaultClip, it will not delete the clip. + But if force is true, then will always remove the clip and any animation states based on it. If clip is defaultClip, defaultClip will be reset to null + !#zh + 从动画列表中移除指定的动画剪辑,
+ 如果依赖于 clip 的 AnimationState 正在播放或者 clip 是 defaultClip 的话,默认是不会删除 clip 的。 + 但是如果 force 参数为 true,则会强制停止该动画,然后移除该动画剪辑和相关的动画。这时候如果 clip 是 defaultClip,defaultClip 将会被重置为 null。 + @param clip clip + @param force If force is true, then will always remove the clip and any animation states based on it. + */ + removeClip(clip: AnimationClip, force?: boolean): void; + /** + !#en + Samples animations at the current state.
+ This is useful when you explicitly want to set up some animation state, and sample it once. + !#zh 对指定或当前动画进行采样。你可以手动将动画设置到某一个状态,然后采样一次。 + @param name name + */ + sample(name: string): void; + /** + !#en + Register animation event callback. + The event arguments will provide the AnimationState which emit the event. + When play an animation, will auto register the event callback to the AnimationState, and unregister the event callback from the AnimationState when animation stopped. + !#zh + 注册动画事件回调。 + 回调的事件里将会附上发送事件的 AnimationState。 + 当播放一个动画时,会自动将事件注册到对应的 AnimationState 上,停止播放时会将事件从这个 AnimationState 上取消注册。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + @param useCapture When set to true, the capture argument prevents callback + from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. + When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE. + Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET. + + @example + ```js + onPlay: function (event) { + var state = event.detail; // state instanceof cc.AnimationState + var type = event.type; // type === 'play'; + } + + // register event to all animation + animation.on('play', this.onPlay, this); + ``` + */ + on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void; + on(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void; + /** + !#en + Unregister animation event callback. + !#zh + 取消注册动画事件回调。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not. + If not specified, useCapture defaults to false. If a callback was registered twice, + one with capture and one without, each must be removed separately. Removal of a capturing callback + does not affect a non-capturing version of the same listener, and vice versa. + + @example + ```js + // unregister event to all animation + animation.off('play', this.onPlay, this); + ``` + */ + off(type: string, callback: Function, target?: any, useCapture?: boolean): void; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + @param useCapture When set to true, the capture argument prevents callback + from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. + When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE. + Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET. + + @example + ```js + node.once(cc.Node.EventType.TOUCH_END, function (event) { + cc.log("this is callback"); + }, node); + ``` + */ + once(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void; + once(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void; + /** + !#en + Dispatches an event into the event flow. + The event target is the EventTarget object upon which the dispatchEvent() method is called. + !#zh 分发事件到事件流中。 + @param event The Event object that is dispatched into the event flow + */ + dispatchEvent(event: Event): void; + /** + !#en + Send an event to this object directly, this method will not propagate the event to any other objects. + The event will be created from the supplied message, you can get the "detail" argument from event.detail. + !#zh + 该对象直接发送事件, 这种方法不会对事件传播到任何其他对象。 + @param message the message to send + @param detail whatever argument the message needs + */ + emit(message: string, detail?: any): void; + } + /** !#en Audio Source. + !#zh 音频源组件,能对音频剪辑。 */ + export class AudioSource extends Component { + /** !#en + Is the audio source playing (Read Only).
+ Note: isPlaying is not supported for Native platforms. + !#zh + 该音频剪辑是否正播放(只读)。
+ 注意:Native 平台暂时不支持 isPlaying。 */ + isPlaying: boolean; + /** !#en The clip of the audio source. + !#zh 默认要播放的音频剪辑。 */ + clip: AudioClip; + /** !#en The volume of the audio source. + !#zh 音频源的音量(0.0 ~ 1.0)。 */ + volume: number; + /** !#en Is the audio source mute? + !#zh 是否静音音频源。Mute 是设置音量为 0,取消静音是恢复原来的音量。 */ + mute: boolean; + /** !#en Is the audio source looping? + !#zh 音频源是否循环播放? */ + loop: boolean; + /** !#en If set to true, the audio source will automatically start playing on onLoad. + !#zh 如果设置为true,音频源将在 onLoad 时自动播放。 */ + playOnLoad: boolean; + /** + !#en Plays the clip. + !#zh 播放音频剪辑。 + */ + play(): void; + /** + !#en Stops the clip. + !#zh 停止当前音频剪辑。 + */ + stop(): void; + /** + !#en Pause the clip. + !#zh 暂停当前音频剪辑。 + */ + pause(): void; + /** + !#en Resume the clip. + !#zh 恢复播放。 + */ + resume(): void; + /** + !#en Rewind playing music. + !#zh 从头开始播放。 + */ + rewind(): void; + /** + !#en Get current time + !#zh 获取当前的播放时间 + */ + getCurrentTime(): void; + /** + !#en Set current time + !#zh 设置当前的播放时间 + @param time time + */ + setCurrentTime(time: number): void; + /** + !#en Get audio duration + !#zh 获取当前音频的长度 + */ + getDuration(): void; + } + /** !#en + This component will block all input events (mouse and touch) within the bounding box of the node, preventing the input from penetrating into the underlying node, typically for the background of the top UI.
+ This component does not have any API interface and can be added directly to the scene to take effect. + !#zh + 该组件将拦截所属节点 bounding box 内的所有输入事件(鼠标和触摸),防止输入穿透到下层节点,一般用于上层 UI 的背景。
+ 该组件没有任何 API 接口,直接添加到场景即可生效。 */ + export class BlockInputEvents extends Component { + } + /** !#en + Button has 4 Transition types + When Button state changed: + If Transition type is Button.Transition.NONE, Button will do nothing + If Transition type is Button.Transition.COLOR, Button will change target's color + If Transition type is Button.Transition.SPRITE, Button will change target Sprite's sprite + If Transition type is Button.Transition.SCALE, Button will change target node's scale + + Button will trigger 5 events: + Button.EVENT_TOUCH_DOWN + Button.EVENT_TOUCH_UP + Button.EVENT_HOVER_IN + Button.EVENT_HOVER_MOVE + Button.EVENT_HOVER_OUT + + !#zh + 按钮组件。可以被按下,或者点击。
+ + 按钮可以通过修改 Transition 来设置按钮状态过渡的方式:
+ -Button.Transition.NONE // 不做任何过渡
+ -Button.Transition.COLOR // 进行颜色之间过渡
+ -Button.Transition.SPRITE // 进行精灵之间过渡
+ -Button.Transition.SCALE // 进行缩放过渡
+ + 按钮可以绑定事件(但是必须要在按钮的 Node 上才能绑定事件):
+ // 以下事件可以在全平台上都触发
+ -cc.Node.EventType.TOUCH_START // 按下时事件
+ -cc.Node.EventType.TOUCH_Move // 按住移动后事件
+ -cc.Node.EventType.TOUCH_END // 按下后松开后事件
+ -cc.Node.EventType.TOUCH_CANCEL // 按下取消事件
+ // 以下事件只在 PC 平台上触发
+ -cc.Node.EventType.MOUSE_DOWN // 鼠标按下时事件
+ -cc.Node.EventType.MOUSE_MOVE // 鼠标按住移动后事件
+ -cc.Node.EventType.MOUSE_ENTER // 鼠标进入目标事件
+ -cc.Node.EventType.MOUSE_LEAVE // 鼠标离开目标事件
+ -cc.Node.EventType.MOUSE_UP // 鼠标松开事件
+ -cc.Node.EventType.MOUSE_WHEEL // 鼠标滚轮事件
*/ + export class Button extends Component { + /** !#en + Whether the Button is disabled. + If true, the Button will trigger event and do transition. + !#zh + 按钮事件是否被响应,如果为 false,则按钮将被禁用。 */ + interactable: boolean; + /** !#en When this flag is true, Button target sprite will turn gray when interactable is false. + !#zh 如果这个标记为 true,当 button 的 interactable 属性为 false 的时候,会使用内置 shader 让 button 的 target 节点的 sprite 组件变灰 */ + enableAutoGrayEffect: boolean; + /** !#en Transition type + !#zh 按钮状态改变时过渡方式。 */ + transition: Button.Transition; + /** !#en Normal state color. + !#zh 普通状态下按钮所显示的颜色。 */ + normalColor: Color; + /** !#en Pressed state color + !#zh 按下状态时按钮所显示的颜色。 */ + pressedColor: Color; + /** !#en Hover state color + !#zh 悬停状态下按钮所显示的颜色。 */ + hoverColor: Color; + /** !#en Disabled state color + !#zh 禁用状态下按钮所显示的颜色。 */ + disabledColor: Color; + /** !#en Color and Scale transition duration + !#zh 颜色过渡和缩放过渡时所需时间 */ + duration: number; + /** !#en When user press the button, the button will zoom to a scale. + The final scale of the button equals (button original scale * zoomScale) + !#zh 当用户点击按钮后,按钮会缩放到一个值,这个值等于 Button 原始 scale * zoomScale */ + zoomScale: number; + /** !#en Normal state sprite + !#zh 普通状态下按钮所显示的 Sprite 。 */ + normalSprite: SpriteFrame; + /** !#en Pressed state sprite + !#zh 按下状态时按钮所显示的 Sprite 。 */ + pressedSprite: SpriteFrame; + /** !#en Hover state sprite + !#zh 悬停状态下按钮所显示的 Sprite 。 */ + hoverSprite: SpriteFrame; + /** !#en Disabled state sprite + !#zh 禁用状态下按钮所显示的 Sprite 。 */ + disabledSprite: SpriteFrame; + /** !#en + Transition target. + When Button state changed: + If Transition type is Button.Transition.NONE, Button will do nothing + If Transition type is Button.Transition.COLOR, Button will change target's color + If Transition type is Button.Transition.SPRITE, Button will change target Sprite's sprite + !#zh + 需要过渡的目标。 + 当前按钮状态改变规则: + -如果 Transition type 选择 Button.Transition.NONE,按钮不做任何过渡。 + -如果 Transition type 选择 Button.Transition.COLOR,按钮会对目标颜色进行颜色之间的过渡。 + -如果 Transition type 选择 Button.Transition.Sprite,按钮会对目标 Sprite 进行 Sprite 之间的过渡。 */ + target: Node; + /** !#en If Button is clicked, it will trigger event's handler + !#zh 按钮的点击事件列表。 */ + clickEvents: Component.EventHandler[]; + } + /** !#zh: 作为 UI 根节点,为所有子节点提供视窗四边的位置信息以供对齐,另外提供屏幕适配策略接口,方便从编辑器设置。 + 注:由于本节点的尺寸会跟随屏幕拉伸,所以 anchorPoint 只支持 (0.5, 0.5),否则适配不同屏幕时坐标会有偏差。 */ + export class Canvas extends Component { + /** !#en Current active canvas, the scene should only have one active canvas at the same time. + !#zh 当前激活的画布组件,场景同一时间只能有一个激活的画布。 */ + static instance: Canvas; + /** !#en The desigin resolution for current scene. + !#zh 当前场景设计分辨率。 */ + designResolution: Size; + /** !#en TODO + !#zh: 是否优先将设计分辨率高度撑满视图高度。 */ + fitHeight: boolean; + /** !#en TODO + !#zh: 是否优先将设计分辨率宽度撑满视图宽度。 */ + fitWidth: boolean; + } + /** !#en + Base class for everything attached to Node(Entity).
+
+ NOTE: Not allowed to use construction parameters for Component's subclasses, + because Component is created by the engine. + !#zh + 所有附加到节点的基类。
+
+ 注意:不允许使用组件的子类构造参数,因为组件是由引擎创建的。 */ + export class Component extends Object { + /** !#en The node this component is attached to. A component is always attached to a node. + !#zh 该组件被附加到的节点。组件总会附加到一个节点。 */ + node: Node; + /** !#en The uuid for editor. + !#zh 组件的 uuid,用于编辑器。 */ + uuid: string; + /** !#en indicates whether this component is enabled or not. + !#zh 表示该组件自身是否启用。 */ + enabled: boolean; + /** !#en indicates whether this component is enabled and its node is also active in the hierarchy. + !#zh 表示该组件是否被启用并且所在的节点也处于激活状态。 */ + enabledInHierarchy: boolean; + /** !#en Returns a value which used to indicate the onLoad get called or not. + !#zh 返回一个值用来判断 onLoad 是否被调用过,不等于 0 时调用过,等于 0 时未调用。 */ + _isOnLoadCalled: number; + /** + !#en Update is called every frame, if the Component is enabled. + !#zh 如果该组件启用,则每帧调用 update。 + @param dt the delta time in seconds it took to complete the last frame + */ + protected update(dt: number): void; + /** + !#en LateUpdate is called every frame, if the Component is enabled. + !#zh 如果该组件启用,则每帧调用 LateUpdate。 + */ + protected lateUpdate(): void; + /** + !#en + When attaching to an active node or its node first activated. + onLoad is always called before any start functions, this allows you to order initialization of scripts. + !#zh + 当附加到一个激活的节点上或者其节点第一次激活时候调用。onLoad 总是会在任何 start 方法调用前执行,这能用于安排脚本的初始化顺序。 + */ + protected onLoad(): void; + /** + !#en + Called before all scripts' update if the Component is enabled the first time. + Usually used to initialize some logic which need to be called after all components' `onload` methods called. + !#zh + 如果该组件第一次启用,则在所有组件的 update 之前调用。通常用于需要在所有组件的 onLoad 初始化完毕后执行的逻辑。 + */ + protected start(): void; + /** + !#en Called when this component becomes enabled and its node is active. + !#zh 当该组件被启用,并且它的节点也激活时。 + */ + protected onEnable(): void; + /** + !#en Called when this component becomes disabled or its node becomes inactive. + !#zh 当该组件被禁用或节点变为无效时调用。 + */ + protected onDisable(): void; + /** + !#en Called when this component will be destroyed. + !#zh 当该组件被销毁时调用 + */ + protected onDestroy(): void; + protected onFocusInEditor(): void; + protected onLostFocusInEditor(): void; + /** + !#en Called to initialize the component or node’s properties when adding the component the first time or when the Reset command is used. This function is only called in editor. + !#zh 用来初始化组件或节点的一些属性,当该组件被第一次添加到节点上或用户点击了它的 Reset 菜单时调用。这个回调只会在编辑器下调用。 + */ + protected resetInEditor(): void; + /** + !#en Adds a component class to the node. You can also add component to node by passing in the name of the script. + !#zh 向节点添加一个组件类,你还可以通过传入脚本的名称来添加组件。 + @param typeOrClassName the constructor or the class name of the component to add + + @example + ```js + var sprite = node.addComponent(cc.Sprite); + var test = node.addComponent("Test"); + ``` + */ + addComponent(type: {new(): T}): T; + addComponent(className: string): any; + /** + !#en + Returns the component of supplied type if the node has one attached, null if it doesn't.
+ You can also get component in the node by passing in the name of the script. + !#zh + 获取节点上指定类型的组件,如果节点有附加指定类型的组件,则返回,如果没有则为空。
+ 传入参数也可以是脚本的名称。 + @param typeOrClassName typeOrClassName + + @example + ```js + // get sprite component. + var sprite = node.getComponent(cc.Sprite); + // get custom test calss. + var test = node.getComponent("Test"); + ``` + */ + getComponent(type: {prototype: T}): T; + getComponent(className: string): any; + /** + !#en Returns all components of supplied Type in the node. + !#zh 返回节点上指定类型的所有组件。 + @param typeOrClassName typeOrClassName + + @example + ```js + var sprites = node.getComponents(cc.Sprite); + var tests = node.getComponents("Test"); + ``` + */ + getComponents(type: {prototype: T}): T[]; + getComponents(className: string): any[]; + /** + !#en Returns the component of supplied type in any of its children using depth first search. + !#zh 递归查找所有子节点中第一个匹配指定类型的组件。 + @param typeOrClassName typeOrClassName + + @example + ```js + var sprite = node.getComponentInChildren(cc.Sprite); + var Test = node.getComponentInChildren("Test"); + ``` + */ + getComponentInChildren(type: {prototype: T}): T; + getComponentInChildren(className: string): any; + /** + !#en Returns the components of supplied type in self or any of its children using depth first search. + !#zh 递归查找自身或所有子节点中指定类型的组件 + @param typeOrClassName typeOrClassName + + @example + ```js + var sprites = node.getComponentsInChildren(cc.Sprite); + var tests = node.getComponentsInChildren("Test"); + ``` + */ + getComponentsInChildren(type: {prototype: T}): T[]; + getComponentsInChildren(className: string): any[]; + /** + !#en + If the component's bounding box is different from the node's, you can implement this method to supply + a custom axis aligned bounding box (AABB), so the editor's scene view can perform hit test properly. + !#zh + 如果组件的包围盒与节点不同,您可以实现该方法以提供自定义的轴向对齐的包围盒(AABB), + 以便编辑器的场景视图可以正确地执行点选测试。 + @param out_rect the Rect to receive the bounding box + */ + _getLocalBounds(out_rect: Rect): void; + /** + !#en + onRestore is called after the user clicks the Reset item in the Inspector's context menu or performs + an undo operation on this component.
+
+ If the component contains the "internal state", short for "temporary member variables which not included
+ in its CCClass properties", then you may need to implement this function.
+
+ The editor will call the getset accessors of your component to record/restore the component's state
+ for undo/redo operation. However, in extreme cases, it may not works well. Then you should implement
+ this function to manually synchronize your component's "internal states" with its public properties.
+ Once you implement this function, all the getset accessors of your component will not be called when
+ the user performs an undo/redo operation. Which means that only the properties with default value
+ will be recorded or restored by editor.
+
+ Similarly, the editor may failed to reset your component correctly in extreme cases. Then if you need
+ to support the reset menu, you should manually synchronize your component's "internal states" with its
+ properties in this function. Once you implement this function, all the getset accessors of your component
+ will not be called during reset operation. Which means that only the properties with default value
+ will be reset by editor. + + This function is only called in editor mode. + !#zh + onRestore 是用户在检查器菜单点击 Reset 时,对此组件执行撤消操作后调用的。
+
+ 如果组件包含了“内部状态”(不在 CCClass 属性中定义的临时成员变量),那么你可能需要实现该方法。
+
+ 编辑器执行撤销/重做操作时,将调用组件的 get set 来录制和还原组件的状态。 + 然而,在极端的情况下,它可能无法良好运作。
+ 那么你就应该实现这个方法,手动根据组件的属性同步“内部状态”。 + 一旦你实现这个方法,当用户撤销或重做时,组件的所有 get set 都不会再被调用。 + 这意味着仅仅指定了默认值的属性将被编辑器记录和还原。
+
+ 同样的,编辑可能无法在极端情况下正确地重置您的组件。
+ 于是如果你需要支持组件重置菜单,你需要在该方法中手工同步组件属性到“内部状态”。
+ 一旦你实现这个方法,组件的所有 get set 都不会在重置操作时被调用。 + 这意味着仅仅指定了默认值的属性将被编辑器重置。 +
+ 此方法仅在编辑器下会被调用。 + */ + onRestore(): void; + /** + !#en + Schedules a custom selector.
+ If the selector is already scheduled, then the interval parameter will be updated without scheduling it again. + !#zh + 调度一个自定义的回调函数。
+ 如果回调函数已调度,那么将不会重复调度它,只会更新时间间隔参数。 + @param callback The callback function + @param interval Tick interval in seconds. 0 means tick every frame. + @param repeat The selector will be executed (repeat + 1) times, you can use cc.macro.REPEAT_FOREVER for tick infinitely. + @param delay The amount of time that the first tick will wait before execution. + + @example + ```js + var timeCallback = function (dt) { + cc.log("time: " + dt); + } + this.schedule(timeCallback, 1); + ``` + */ + schedule(callback: Function, interval?: number, repeat?: number, delay?: number): void; + /** + !#en Schedules a callback function that runs only once, with a delay of 0 or larger. + !#zh 调度一个只运行一次的回调函数,可以指定 0 让回调函数在下一帧立即执行或者在一定的延时之后执行。 + @param callback A function wrapped as a selector + @param delay The amount of time that the first tick will wait before execution. + + @example + ```js + var timeCallback = function (dt) { + cc.log("time: " + dt); + } + this.scheduleOnce(timeCallback, 2); + ``` + */ + scheduleOnce(callback: Function, delay?: number): void; + /** + !#en Unschedules a custom callback function. + !#zh 取消调度一个自定义的回调函数。 + @param callback_fn A function wrapped as a selector + + @example + ```js + this.unschedule(_callback); + ``` + */ + unschedule(callback_fn: Function): void; + /** + !#en + unschedule all scheduled callback functions: custom callback functions, and the 'update' callback function.
+ Actions are not affected by this method. + !#zh 取消调度所有已调度的回调函数:定制的回调函数以及 'update' 回调函数。动作不受此方法影响。 + + @example + ```js + this.unscheduleAllCallbacks(); + ``` + */ + unscheduleAllCallbacks(): void; + } + /** !#en cc.EditBox is a component for inputing text, you can use it to gather small amounts of text from users. + !#zh EditBox 组件,用于获取用户的输入文本。 */ + export class EditBox extends _RendererUnderSG { + /** !#en Input string of EditBox. + !#zh 输入框的初始输入内容,如果为空则会显示占位符的文本。 */ + string: string; + /** !#en The background image of EditBox. + !#zh 输入框的背景图片 */ + backgroundImage: SpriteFrame; + /** !#en + The return key type of EditBox. + Note: it is meaningless for web platforms and desktop platforms. + !#zh + 指定移动设备上面回车按钮的样式。 + 注意:这个选项对 web 平台与 desktop 平台无效。 */ + returnType: EditBox.KeyboardReturnType; + /** !#en Set the input flags that are to be applied to the EditBox. + !#zh 指定输入标志位,可以指定输入方式为密码或者单词首字母大写。 */ + inputFlag: EditBox.InputFlag; + /** !#en + Set the input mode of the edit box. + If you pass ANY, it will create a multiline EditBox. + !#zh + 指定输入模式: ANY表示多行输入,其它都是单行输入,移动平台上还可以指定键盘样式。 */ + inputMode: EditBox.InputMode; + /** !#en Font size of the input text. + !#zh 输入框文本的字体大小 */ + fontSize: number; + /** !#en Change the lineHeight of displayed text. + !#zh 输入框文本的行高。 */ + lineHeight: number; + /** !#en Font color of the input text. + !#zh 输入框文本的颜色。 */ + fontColor: Color; + /** !#en The display text of placeholder. + !#zh 输入框占位符的文本内容。 */ + placeholder: string; + /** !#en The font size of placeholder. + !#zh 输入框占位符的字体大小。 */ + placeholderFontSize: number; + /** !#en The font color of placeholder. + !#zh 输入框最大允许输入的字符个数。 */ + placeholderFontColor: Color; + /** !#en The maximize input length of EditBox. + - If pass a value less than 0, it won't limit the input number of characters. + - If pass 0, it doesn't allow input any characters. + !#zh 输入框最大允许输入的字符个数。 + - 如果值为小于 0 的值,则不会限制输入字符个数。 + - 如果值为 0,则不允许用户进行任何输入。 */ + maxLength: number; + /** !#en The input is always visible and be on top of the game view. + !zh 输入框总是可见,并且永远在游戏视图的上面 + Note: only available on Web at the moment. */ + stayOnTop: boolean; + /** !#en Set the tabIndex of the DOM input element, only useful on Web. + !#zh 修改 DOM 输入元素的 tabIndex,这个属性只有在 Web 上面修改有意义。 */ + tabIndex: number; + /** !#en The event handler to be called when EditBox began to edit text. + !#zh 开始编辑文本输入框触发的事件回调。 */ + editingDidBegan: Component.EventHandler[]; + /** !#en The event handler to be called when EditBox text changes. + !#zh 编辑文本输入框时触发的事件回调。 */ + textChanged: Component.EventHandler[]; + /** !#en The event handler to be called when EditBox edit ends. + !#zh 结束编辑文本输入框时触发的事件回调。 */ + editingDidEnded: Component.EventHandler[]; + /** !#en The event handler to be called when return key is pressed. Windows is not supported. + !#zh 当用户按下回车按键时的事件回调,目前不支持 windows 平台 */ + editingReturn: Component.EventHandler[]; + /** + !#en Let the EditBox get focus, only valid when stayOnTop is true. + !#zh 让当前 EditBox 获得焦点,只有在 stayOnTop 为 true 的时候设置有效 + Note: only available on Web at the moment. + */ + setFocus(): void; + /** + !#en Determine whether EditBox is getting focus or not. + !#zh 判断 EditBox 是否获得了焦点 + Note: only available on Web at the moment. + */ + isFocused(): void; + /** + !#en if you don't need the EditBox and it isn't in any running Scene, you should + call the destroy method on this component or the associated node explicitly. + Otherwise, the created DOM element won't be removed from web page. + !#zh + 如果你不再使用 EditBox,并且组件未添加到场景中,那么你必须手动对组件或所在节点调用 destroy。 + 这样才能移除网页上的 DOM 节点,避免 Web 平台内存泄露。 + + @example + ```js + editbox.node.parent = null; // or editbox.node.removeFromParent(false); + // when you don't need editbox anymore + editbox.node.destroy(); + ``` + */ + destroy(): boolean; + } + /** !#en The Label Component. + !#zh 文字标签组件 */ + export class Label extends _RendererUnderSG { + /** !#en Content string of label. + !#zh 标签显示的文本内容。 */ + string: string; + /** !#en Horizontal Alignment of label. + !#zh 文本内容的水平对齐方式。 */ + horizontalAlign: Label.HorizontalAlign; + /** !#en Vertical Alignment of label. + !#zh 文本内容的垂直对齐方式。 */ + verticalAlign: Label.VerticalAlign; + /** !#en The actual rendering font size in shrink mode + !#zh SHRINK 模式下面文本实际渲染的字体大小 */ + actualFontSize: number; + /** !#en Font size of label. + !#zh 文本字体大小。 */ + fontSize: number; + /** !#en Font family of label, only take effect when useSystemFont property is true. + !#zh 文本字体名称, 只在 useSystemFont 属性为 true 的时候生效。 */ + fontFamily: string; + /** !#en Line Height of label. + !#zh 文本行高。 */ + lineHeight: number; + /** !#en Overflow of label. + !#zh 文字显示超出范围时的处理方式。 */ + overflow: Label.Overflow; + /** !#en Whether auto wrap label when string width is large than label width. + !#zh 是否自动换行。 */ + enableWrapText: boolean; + /** !#en The font of label. + !#zh 文本字体。 */ + font: Font; + /** !#en Whether use system font name or not. + !#zh 是否使用系统字体。 */ + isSystemFontUsed: boolean; + } + /** !#en Outline effect used to change the display, only used for TTF font + !#zh 描边效果组件,用于字体描边,只能用于系统字体 */ + export class LabelOutline extends Component { + /** !#en Change the outline color + !#zh 改变描边的颜色 */ + color: Color; + /** !#en Change the outline width + !#zh 改变描边的宽度 */ + width: number; + } + /** !#en + The Layout is a container component, use it to arrange child elements easily.
+ Note:
+ 1.Scaling and rotation of child nodes are not considered.
+ 2.After setting the Layout, the results need to be updated until the next frame, + unless you manually call {{#crossLink "Layout/updateLayout:method"}}{{/crossLink}}。 + !#zh + Layout 组件相当于一个容器,能自动对它的所有子节点进行统一排版。
+ 注意:
+ 1.不会考虑子节点的缩放和旋转。
+ 2.对 Layout 设置后结果需要到下一帧才会更新,除非你设置完以后手动调用 {{#crossLink "Layout/updateLayout:method"}}{{/crossLink}}。 */ + export class Layout extends Component { + /** !#en The layout type. + !#zh 布局类型 */ + type: Layout.Type; + /** !#en + The are three resize modes for Layout. + None, resize Container and resize children. + !#zh 缩放模式 */ + resizeMode: Layout.ResizeMode; + /** !#en The cell size for grid layout. + !#zh 每个格子的大小,只有布局类型为 GRID 的时候才有效。 */ + cellSize: Size; + /** !#en + The start axis for grid layout. If you choose horizontal, then children will layout horizontally at first, + and then break line on demand. Choose vertical if you want to layout vertically at first . + !#zh 起始轴方向类型,可进行水平和垂直布局排列,只有布局类型为 GRID 的时候才有效。 */ + startAxis: Layout.AxisDirection; + /** !#en The left padding of layout, it only effect the layout in one direction. + !#zh 容器内左边距,只会在一个布局方向上生效。 */ + paddingLeft: number; + /** !#en The right padding of layout, it only effect the layout in one direction. + !#zh 容器内右边距,只会在一个布局方向上生效。 */ + paddingRight: number; + /** !#en The top padding of layout, it only effect the layout in one direction. + !#zh 容器内上边距,只会在一个布局方向上生效。 */ + paddingTop: number; + /** !#en The bottom padding of layout, it only effect the layout in one direction. + !#zh 容器内下边距,只会在一个布局方向上生效。 */ + paddingBottom: number; + /** !#en The distance in x-axis between each element in layout. + !#zh 子节点之间的水平间距。 */ + spacingX: number; + /** !#en The distance in y-axis between each element in layout. + !#zh 子节点之间的垂直间距。 */ + spacingY: number; + /** !#en + Only take effect in Vertical layout mode. + This option changes the start element's positioning. + !#zh 垂直排列子节点的方向。 */ + verticalDirection: Layout.VerticalDirection; + /** !#en + Only take effect in Horizontal layout mode. + This option changes the start element's positioning. + !#zh 水平排列子节点的方向。 */ + horizontalDirection: Layout.HorizontalDirection; + /** + !#en Perform the layout update + !#zh 立即执行更新布局 + + @example + ```js + layout.type = cc.Layout.HORIZONTAL; + layout.node.addChild(childNode); + cc.log(childNode.x); // not yet changed + layout.updateLayout(); + cc.log(childNode.x); // changed + ``` + */ + updateLayout(): void; + /** !#en The padding of layout, it effects the layout in four direction. + !#zh 容器内边距,该属性会在四个布局方向上生效。 */ + padding: number; + } + /** !#en The Mask Component + !#zh 遮罩组件 */ + export class Mask extends _RendererInSG { + /** !#en The mask type. + !#zh 遮罩类型 */ + type: Mask.Type; + /** !#en The mask image + !#zh 遮罩所需要的贴图 */ + spriteFrame: SpriteFrame; + /** !#en + The alpha threshold.(Not supported Canvas Mode)
+ The content is drawn only where the stencil have pixel with alpha greater than the alphaThreshold.
+ Should be a float between 0 and 1.
+ This default to 1 (so alpha test is disabled). + !#zh + Alpha 阈值(不支持 Canvas 模式)
+ 只有当模板的像素的 alpha 大于 alphaThreshold 时,才会绘制内容。
+ 该数值 0 ~ 1 之间的浮点数,默认值为 1(因此禁用 alpha) */ + alphaThreshold: number; + /** !#en Reverse mask (Not supported Canvas Mode) + !#zh 反向遮罩(不支持 Canvas 模式) */ + inverted: boolean; + /** !#en The segements for ellipse mask. + !#zh 椭圆遮罩的曲线细分数 */ + segements: number; + } + /** !#en The PageView control + !#zh 页面视图组件 */ + export class PageView extends ScrollView { + /** !#en Specify the size type of each page in PageView. + !#zh 页面视图中每个页面大小类型 */ + sizeMode: PageView.SizeMode; + /** !#en The page view direction + !#zh 页面视图滚动类型 */ + direction: PageView.Direction; + /** !#en + The scroll threshold value, when drag exceeds this value, + release the next page will automatically scroll, less than the restore + !#zh 滚动临界值,默认单位百分比,当拖拽超出该数值时,松开会自动滚动下一页,小于时则还原。 */ + scrollThreshold: number; + /** !#en + Auto page turning velocity threshold. When users swipe the PageView quickly, + it will calculate a velocity based on the scroll distance and time, + if the calculated velocity is larger than the threshold, then it will trigger page turning. + !#zh + 快速滑动翻页临界值。 + 当用户快速滑动时,会根据滑动开始和结束的距离与时间计算出一个速度值, + 该值与此临界值相比较,如果大于临界值,则进行自动翻页。 */ + autoPageTurningThreshold: number; + /** !#en Change the PageTurning event timing of PageView. + !#zh 设置 PageView PageTurning 事件的发送时机。 */ + pageTurningEventTiming: number; + /** !#en The Page View Indicator + !#zh 页面视图指示器组件 */ + indicator: PageViewIndicator; + /** !#en The time required to turn over a page. unit: second + !#zh 每个页面翻页时所需时间。单位:秒 */ + pageTurningSpeed: number; + /** !#en PageView events callback + !#zh 滚动视图的事件回调函数 */ + pageEvents: Component.EventHandler[]; + /** + !#en Returns current page index + !#zh 返回当前页面索引 + */ + getCurrentPageIndex(): number; + /** + !#en Set current page index + !#zh 设置当前页面索引 + @param index index + */ + setCurrentPageIndex(index: number): void; + /** + !#en Returns all pages of pageview + !#zh 返回视图中的所有页面 + */ + getPages(): Node[]; + /** + !#en At the end of the current page view to insert a new view + !#zh 在当前页面视图的尾部插入一个新视图 + @param page page + */ + addPage(page: Node): void; + /** + !#en Inserts a page in the specified location + !#zh 将页面插入指定位置中 + @param page page + @param index index + */ + insertPage(page: Node, index: number): void; + /** + !#en Removes a page from PageView. + !#zh 移除指定页面 + @param page page + */ + removePage(page: Node): void; + /** + !#en Removes a page at index of PageView. + !#zh 移除指定下标的页面 + @param index index + */ + removePageAtIndex(index: number): void; + /** + !#en Removes all pages from PageView + !#zh 移除所有页面 + */ + removeAllPages(): void; + /** + !#en Scroll PageView to index. + !#zh 滚动到指定页面 + @param idx index of page. + @param timeInSecond scrolling time + */ + scrollToPage(idx: number, timeInSecond: number): void; + } + /** !#en The Page View Indicator Component + !#zh 页面视图每页标记组件 */ + export class PageViewIndicator extends Component { + /** !#en The spriteFrame for each element. + !#zh 每个页面标记显示的图片 */ + spriteFrame: SpriteFrame; + /** !#en The location direction of PageViewIndicator. + !#zh 页面标记摆放方向 */ + direction: PageViewIndicator.Direction; + /** !#en The cellSize for each element. + !#zh 每个页面标记的大小 */ + cellSize: Size; + /** !#en The distance between each element. + !#zh 每个页面标记之间的边距 */ + spacing: number; + /** + !#en Set Page View + !#zh 设置页面视图 + @param target target + */ + setPageView(target: PageView): void; + } + /** !#en + Visual indicator of progress in some operation. + Displays a bar to the user representing how far the operation has progressed. + !#zh + 进度条组件,可用于显示加载资源时的进度。 */ + export class ProgressBar extends Component { + /** !#en The targeted Sprite which will be changed progressively. + !#zh 用来显示进度条比例的 Sprite 对象。 */ + barSprite: Sprite; + /** !#en The progress mode, there are two modes supported now: horizontal and vertical. + !#zh 进度条的模式 */ + mode: ProgressBar.Mode; + /** !#en The total width or height of the bar sprite. + !#zh 进度条实际的总长度 */ + totalLength: number; + /** !#en The current progress of the bar sprite. The valid value is between 0-1. + !#zh 当前进度值,该数值的区间是 0-1 之间。 */ + progress: number; + /** !#en Whether reverse the progress direction of the bar sprite. + !#zh 进度条是否进行反方向变化。 */ + reverse: boolean; + } + /** Rendering component in scene graph. + Maintains a node which will be the scene graph of component's Node. */ + export class _RendererInSG extends _SGComponent { + } + /** The base rendering component which will attach a leaf node to the cocos2d scene graph. */ + export class _RendererUnderSG extends _SGComponent { + } + /** !#en The RichText Component. + !#zh 富文本组件 */ + export class RichText extends Component { + /** !#en Content string of RichText. + !#zh 富文本显示的文本内容。 */ + string: string; + /** !#en Horizontal Alignment of each line in RichText. + !#zh 文本内容的水平对齐方式。 */ + horizontalAlign: TextAlignment; + /** !#en Font size of RichText. + !#zh 富文本字体大小。 */ + fontSize: number; + /** !#en Custom TTF font of RichText + !#zh 富文本定制字体 */ + font: cc.TTFFont; + /** !#en The maximize width of the RichText + !#zh 富文本的最大宽度 */ + maxWidth: number; + /** !#en Line Height of RichText. + !#zh 富文本行高。 */ + lineHeight: number; + /** !#en The image atlas for the img tag. For each src value in the img tag, there should be a valid spriteFrame in the image atlas. + !#zh 对于 img 标签里面的 src 属性名称,都需要在 imageAtlas 里面找到一个有效的 spriteFrame,否则 img tag 会判定为无效。 */ + imageAtlas: SpriteAtlas; + /** !#en + Once checked, the RichText will block all input events (mouse and touch) within + the bounding box of the node, preventing the input from penetrating into the underlying node. + !#zh + 选中此选项后,RichText 将阻止节点边界框中的所有输入事件(鼠标和触摸),从而防止输入事件穿透到底层节点。 */ + handleTouchEvent: boolean; + } + /** The base class for all rendering component in scene graph. + + You should override: + - _createSgNode + - _initSgNode */ + export class _SGComponent extends Component { + } + /** !#en + The Scrollbar control allows the user to scroll an image or other view that is too large to see completely + !#zh 滚动条组件 */ + export class Scrollbar extends Component { + /** !#en The "handle" part of the scrollbar. + !#zh 作为当前滚动区域位置显示的滑块 Sprite。 */ + handle: Sprite; + /** !#en The direction of scrollbar. + !#zh ScrollBar 的滚动方向。 */ + direction: Scrollbar.Direction; + /** !#en Whether enable auto hide or not. + !#zh 是否在没有滚动动作时自动隐藏 ScrollBar。 */ + enableAutoHide: boolean; + /** !#en + The time to hide scrollbar when scroll finished. + Note: This value is only useful when enableAutoHide is true. + !#zh + 没有滚动动作后经过多久会自动隐藏。 + 注意:只要当 “enableAutoHide” 为 true 时,才有效。 */ + autoHideTime: number; + } + /** !#en + Layout container for a view hierarchy that can be scrolled by the user, + allowing it to be larger than the physical display. + + !#zh + 滚动视图组件 */ + export class ScrollView extends Component { + /** !#en This is a reference to the UI element to be scrolled. + !#zh 可滚动展示内容的节点。 */ + content: Node; + /** !#en Enable horizontal scroll. + !#zh 是否开启水平滚动。 */ + horizontal: boolean; + /** !#en Enable vertical scroll. + !#zh 是否开启垂直滚动。 */ + vertical: boolean; + /** !#en When inertia is set, the content will continue to move when touch ended. + !#zh 是否开启滚动惯性。 */ + inertia: boolean; + /** !#en + It determines how quickly the content stop moving. A value of 1 will stop the movement immediately. + A value of 0 will never stop the movement until it reaches to the boundary of scrollview. + !#zh + 开启惯性后,在用户停止触摸后滚动多快停止,0表示永不停止,1表示立刻停止。 */ + brake: number; + /** !#en When elastic is set, the content will be bounce back when move out of boundary. + !#zh 是否允许滚动内容超过边界,并在停止触摸后回弹。 */ + elastic: boolean; + /** !#en The elapse time of bouncing back. A value of 0 will bounce back immediately. + !#zh 回弹持续的时间,0 表示将立即反弹。 */ + bounceDuration: number; + /** !#en The horizontal scrollbar reference. + !#zh 水平滚动的 ScrollBar。 */ + horizontalScrollBar: Scrollbar; + /** !#en The vertical scrollbar reference. + !#zh 垂直滚动的 ScrollBar。 */ + verticalScrollBar: Scrollbar; + /** !#en Scrollview events callback + !#zh 滚动视图的事件回调函数 */ + scrollEvents: Component.EventHandler[]; + /** !#en If cancelInnerEvents is set to true, the scroll behavior will cancel touch events on inner content nodes + It's set to true by default. + !#zh 如果这个属性被设置为 true,那么滚动行为会取消子节点上注册的触摸事件,默认被设置为 true。 + 注意,子节点上的 touchstart 事件仍然会触发,触点移动距离非常短的情况下 touchmove 和 touchend 也不会受影响。 */ + cancelInnerEvents: boolean; + /** + !#en Scroll the content to the bottom boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图底部。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the bottom boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the bottom of the view. + scrollView.scrollToBottom(0.1); + ``` + */ + scrollToBottom(timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the top boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图顶部。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the top boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the top of the view. + scrollView.scrollToTop(0.1); + ``` + */ + scrollToTop(timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the left boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图左边。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the left boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the left of the view. + scrollView.scrollToLeft(0.1); + ``` + */ + scrollToLeft(timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the right boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图右边。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the right boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the right of the view. + scrollView.scrollToRight(0.1); + ``` + */ + scrollToRight(timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the top left boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图左上角。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the top left boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the upper left corner of the view. + scrollView.scrollToTopLeft(0.1); + ``` + */ + scrollToTopLeft(timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the top right boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图右上角。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the top right boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the top right corner of the view. + scrollView.scrollToTopRight(0.1); + ``` + */ + scrollToTopRight(timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the bottom left boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图左下角。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the bottom left boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the lower left corner of the view. + scrollView.scrollToBottomLeft(0.1); + ``` + */ + scrollToBottomLeft(timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the bottom right boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图右下角。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the bottom right boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the lower right corner of the view. + scrollView.scrollToBottomRight(0.1); + ``` + */ + scrollToBottomRight(timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll with an offset related to the ScrollView's top left origin, if timeInSecond is omitted, then it will jump to the + specific offset immediately. + !#zh 视图内容在规定时间内将滚动到 ScrollView 相对左上角原点的偏移位置, 如果 timeInSecond参数不传,则立即滚动到指定偏移位置。 + @param offset A Vec2, the value of which each axis between 0 and maxScrollOffset + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the specific offset of ScrollView immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to middle position in 0.1 second in x-axis + var maxScrollOffset = this.getMaxScrollOffset(); + scrollView.scrollToOffset(cc.p(maxScrollOffset.x / 2, 0), 0.1); + ``` + */ + scrollToOffset(offset: Vec2, timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Get the positive offset value corresponds to the content's top left boundary. + !#zh 获取滚动视图相对于左上角原点的当前滚动偏移 + */ + getScrollOffset(): Vec2; + /** + !#en Get the maximize available scroll offset + !#zh 获取滚动视图最大可以滚动的偏移量 + */ + getMaxScrollOffset(): Vec2; + /** + !#en Scroll the content to the horizontal percent position of ScrollView. + !#zh 视图内容在规定时间内将滚动到 ScrollView 水平方向的百分比位置上。 + @param percent A value between 0 and 1. + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the horizontal percent position of ScrollView immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to middle position. + scrollView.scrollToBottomRight(0.5, 0.1); + ``` + */ + scrollToPercentHorizontal(percent: number, timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the percent position of ScrollView in any direction. + !#zh 视图内容在规定时间内进行垂直方向和水平方向的滚动,并且滚动到指定百分比位置上。 + @param anchor A point which will be clamp between cc.p(0,0) and cc.p(1,1). + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the percent position of ScrollView immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Vertical scroll to the bottom of the view. + scrollView.scrollTo(cc.p(0, 1), 0.1); + + // Horizontal scroll to view right. + scrollView.scrollTo(cc.p(1, 0), 0.1); + ``` + */ + scrollTo(anchor: Vec2, timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the vertical percent position of ScrollView. + !#zh 视图内容在规定时间内滚动到 ScrollView 垂直方向的百分比位置上。 + @param percent A value between 0 and 1. + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the vertical percent position of ScrollView immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + // Scroll to middle position. + scrollView.scrollToPercentVertical(0.5, 0.1); + */ + scrollToPercentVertical(percent: number, timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Stop auto scroll immediately + !#zh 停止自动滚动, 调用此 API 可以让 Scrollview 立即停止滚动 + */ + stopAutoScroll(): void; + /** + !#en Modify the content position. + !#zh 设置当前视图内容的坐标点。 + @param position The position in content's parent space. + */ + setContentPosition(position: Vec2): void; + /** + !#en Query the content's position in its parent space. + !#zh 获取当前视图内容的坐标点。 + */ + getContentPosition(): Position; + /** + !#en Query whether the user is currently dragging the ScrollView to scroll it + !#zh 用户是否在拖拽当前滚动视图 + */ + isScrolling(): boolean; + /** + !#en Query whether the ScrollView is currently scrolling because of a bounceback or inertia slowdown. + !#zh 当前滚动视图是否在惯性滚动 + */ + isAutoScrolling(): boolean; + } + /** !#en The Slider Control + !#zh 滑动器组件 */ + export class Slider extends Component { + /** !#en The "handle" part of the slider + !#zh 滑动器滑块按钮部件 */ + handle: Button; + /** !#en The slider direction + !#zh 滑动器方向 */ + direction: Slider.Direction; + /** !#en The current progress of the slider. The valid value is between 0-1 + !#zh 当前进度值,该数值的区间是 0-1 之间 */ + progress: number; + /** !#en The slider events callback + !#zh 滑动器组件事件回调函数 */ + slideEvents: Component.EventHandler[]; + } + /** !#en Renders a sprite in the scene. + !#zh 该组件用于在场景中渲染精灵。 */ + export class Sprite extends _RendererUnderSG { + /** !#en The sprite frame of the sprite. + !#zh 精灵的精灵帧 */ + spriteFrame: SpriteFrame; + /** !#en The sprite render type. + !#zh 精灵渲染类型 */ + type: Sprite.SpriteType; + /** !#en + The fill type, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”. + !#zh + 精灵填充类型,仅渲染类型设置为 cc.Sprite.SpriteType.FILLED 时有效。 */ + fillType: Sprite.FillType; + /** !#en + The fill Center, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”. + !#zh + 填充中心点,仅渲染类型设置为 cc.Sprite.SpriteType.FILLED 时有效。 */ + fillCenter: Vec2; + /** !#en + The fill Start, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”. + !#zh + 填充起始点,仅渲染类型设置为 cc.Sprite.SpriteType.FILLED 时有效。 */ + fillStart: number; + /** !#en + The fill Range, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”. + !#zh + 填充范围,仅渲染类型设置为 cc.Sprite.SpriteType.FILLED 时有效。 */ + fillRange: number; + /** !#en specify the frame is trimmed or not. + !#zh 是否使用裁剪模式 */ + trim: boolean; + /** !#en specify the source Blend Factor. + !#zh 指定原图的混合模式 */ + srcBlendFactor: BlendFactor; + /** !#en specify the destination Blend Factor. + !#zh 指定目标的混合模式 */ + dstBlendFactor: BlendFactor; + /** !#en specify the size tracing mode. + !#zh 精灵尺寸调整模式 */ + sizeMode: Sprite.SizeMode; + /** + !#en Change the left sprite's cap inset. + !#zh 设置精灵左边框-用于九宫格。 + @param insetLeft The values to use for the cap inset. + + @example + ```js + sprite.setInsetLeft(5); + ``` + */ + setInsetLeft(insetLeft: number): void; + /** + !#en Query the left sprite's cap inset. + !#zh 获取精灵左边框 + + @example + ```js + var insetLeft = sprite.getInsetLeft(); + cc.log("Inset Left:" + insetLeft); + ``` + */ + getInsetLeft(): number; + /** + !#en Change the top sprite's cap inset. + !#zh 设置精灵上边框-用于九宫格。 + @param insetTop The values to use for the cap inset. + + @example + ```js + sprite.setInsetTop(5); + ``` + */ + setInsetTop(insetTop: number): void; + /** + !#en Query the top sprite's cap inset. + !#zh 获取精灵上边框。 + + @example + ```js + var insetTop = sprite.getInsetTop(); + cc.log("Inset Top:" + insetTop); + ``` + */ + getInsetTop(): number; + /** + !#en Change the right sprite's cap inset. + !#zh 设置精灵右边框-用于九宫格。 + @param insetRight The values to use for the cap inset. + + @example + ```js + sprite.setInsetRight(5); + ``` + */ + setInsetRight(insetRight: number): void; + /** + !#en Query the right sprite's cap inset. + !#zh 获取精灵右边框。 + + @example + ```js + var insetRight = sprite.getInsetRight(); + cc.log("Inset Right:" + insetRight); + ``` + */ + getInsetRight(): number; + /** + !#en Change the bottom sprite's cap inset. + !#zh 设置精灵下边框-用于九宫格。 + @param bottomInset The values to use for the cap inset. + + @example + ```js + sprite.setInsetBottom(5); + ``` + */ + setInsetBottom(bottomInset: number): void; + /** + !#en Query the bottom sprite's cap inset. + !#zh 获取精灵下边框。 + + @example + ```js + var insetBottom = sprite.getInsetBottom(); + cc.log("Inset Bottom:" + insetBottom); + ``` + */ + getInsetBottom(): number; + } + /** !#en A distortion used to change the rendering of simple sprite.If will take effect after sprite component is added. + !#zh 扭曲效果组件,用于改变SIMPLE类型sprite的渲染,只有当sprite组件已经添加后,才能起作用. */ + export class SpriteDistortion extends Component { + /** !#en Change the UV offset for distortion rendering. + !#zh 在渲染时改变UV的整体偏移. */ + offset: Vec2; + /** !#en Change the UV scale for distortion rendering. + !#zh 在渲染时改变UV的寻址系数 */ + tiling: Vec2; + } + /** !#en The toggle component is a CheckBox, when it used together with a ToggleGroup, it + could be treated as a RadioButton. + !#zh Toggle 是一个 CheckBox,当它和 ToggleGroup 一起使用的时候,可以变成 RadioButton。 */ + export class Toggle extends Button { + /** !#en When this value is true, the check mark component will be enabled, otherwise + the check mark component will be disabled. + !#zh 如果这个设置为 true,则 check mark 组件会处于 enabled 状态,否则处于 disabled 状态。 */ + isChecked: boolean; + /** !#en The toggle group which the toggle belongs to, when it is null, the toggle is a CheckBox. + Otherwise, the toggle is a RadioButton. + !#zh Toggle 所属的 ToggleGroup,这个属性是可选的。如果这个属性为 null,则 Toggle 是一个 CheckBox, + 否则,Toggle 是一个 RadioButton。 */ + toggleGroup: ToggleGroup; + /** !#en The image used for the checkmark. + !#zh Toggle 处于选中状态时显示的图片 */ + checkMark: Sprite; + /** !#en If Toggle is clicked, it will trigger event's handler + !#zh Toggle 按钮的点击事件列表。 */ + checkEvents: Component.EventHandler[]; + /** + !#en Make the toggle button checked. + !#zh 使 toggle 按钮处于选中状态 + */ + check(): void; + /** + !#en Make the toggle button unchecked. + !#zh 使 toggle 按钮处于未选中状态 + */ + uncheck(): void; + } + /** !#en ToggleContainer is not a visiable UI component but a way to modify the behavior of a set of Toggles.
+ Toggles that belong to the same group could only have one of them to be switched on at a time.
+ Note: All the first layer child node containing the toggle component will auto be added to the container + !#zh ToggleContainer 不是一个可见的 UI 组件,它可以用来修改一组 Toggle 组件的行为。
+ 当一组 Toggle 属于同一个 ToggleContainer 的时候,任何时候只能有一个 Toggle 处于选中状态。
+ 注意:所有包含 Toggle 组件的一级子节点都会自动被添加到该容器中 */ + export class ToggleContainer extends Component { + /** !#en If this setting is true, a toggle could be switched off and on when pressed. + If it is false, it will make sure there is always only one toggle could be switched on + and the already switched on toggle can't be switched off. + !#zh 如果这个设置为 true, 那么 toggle 按钮在被点击的时候可以反复地被选中和未选中。 */ + allowSwitchOff: boolean; + /** !#en Read only property, return the toggle items array reference managed by ToggleContainer. + !#zh 只读属性,返回 ToggleContainer 管理的 toggle 数组引用 */ + toggleItems: Toggle[]; + } + /** !#en ToggleGroup is not a visiable UI component but a way to modify the behavior of a set of Toggles. + Toggles that belong to the same group could only have one of them to be switched on at a time. + !#zh ToggleGroup 不是一个可见的 UI 组件,它可以用来修改一组 Toggle 组件的行为。当一组 Toggle 属于同一个 ToggleGroup 的时候, + 任何时候只能有一个 Toggle 处于选中状态。 */ + export class ToggleGroup extends Component { + /** !#en If this setting is true, a toggle could be switched off and on when pressed. + If it is false, it will make sure there is always only one toggle could be switched on + and the already switched on toggle can't be switched off. + !#zh 如果这个设置为 true, 那么 toggle 按钮在被点击的时候可以反复地被选中和未选中。 */ + allowSwitchOff: boolean; + /** !#en Read only property, return the toggle items array reference managed by toggleGroup. + !#zh 只读属性,返回 toggleGroup 管理的 toggle 数组引用 */ + toggleItems: any[]; + } + /** !#en cc.VideoPlayer is a component for playing videos, you can use it for showing videos in your game. + !#zh Video 组件,用于在游戏中播放视频 */ + export class VideoPlayer extends _RendererUnderSG { + /** !#en The resource type of videoplayer, REMOTE for remote url and LOCAL for local file path. + !#zh 视频来源:REMOTE 表示远程视频 URL,LOCAL 表示本地视频地址。 */ + resourceType: VideoPlayer.ResourceType; + /** !#en The remote URL of video. + !#zh 远程视频的 URL */ + remoteURL: string; + /** !#en The local video full path. + !#zh 本地视频的 URL */ + clip: string; + /** !#en The current playback time of the now playing item in seconds, you could also change the start playback time. + !#zh 指定视频从什么时间点开始播放,单位是秒,也可以用来获取当前视频播放的时间进度。 */ + currentTime: number; + /** !#en Whether keep the aspect ration of the original video. + !#zh 是否保持视频原来的宽高比 */ + keepAspectRatio: boolean; + /** !#en Whether play video in fullscreen mode. + !#zh 是否全屏播放视频 */ + isFullscreen: boolean; + /** !#en the video player's callback, it will be triggered when certain event occurs, like: playing, paused, stopped and completed. + !#zh 视频播放回调函数,该回调函数会在特定情况被触发,比如播放中,暂时,停止和完成播放。 */ + videoPlayerEvent: Component.EventHandler[]; + /** + !#en If a video is paused, call this method could resume playing. If a video is stopped, call this method to play from scratch. + !#zh 如果视频被暂停播放了,调用这个接口可以继续播放。如果视频被停止播放了,调用这个接口可以从头开始播放。 + */ + play(): void; + /** + !#en If a video is paused, call this method to resume playing. + !#zh 如果一个视频播放被暂停播放了,调用这个接口可以继续播放。 + */ + resume(): void; + /** + !#en If a video is playing, call this method to pause playing. + !#zh 如果一个视频正在播放,调用这个接口可以暂停播放。 + */ + pause(): void; + /** + !#en If a video is playing, call this method to stop playing immediately. + !#zh 如果一个视频正在播放,调用这个接口可以立马停止播放。 + */ + stop(): void; + /** + !#en Gets the duration of the video + !#zh 获取视频文件的播放总时长 + */ + getDuration(): number; + /** + !#en Determine whether video is playing or not. + !#zh 判断当前视频是否处于播放状态 + */ + isPlaying(): boolean; + /** + !#en if you don't need the VideoPlayer and it isn't in any running Scene, you should + call the destroy method on this component or the associated node explicitly. + Otherwise, the created DOM element won't be removed from web page. + !#zh + 如果你不再使用 VideoPlayer,并且组件未添加到场景中,那么你必须手动对组件或所在节点调用 destroy。 + 这样才能移除网页上的 DOM 节点,避免 Web 平台内存泄露。 + + @example + ```js + videoplayer.node.parent = null; // or videoplayer.node.removeFromParent(false); + // when you don't need videoplayer anymore + videoplayer.node.destroy(); + ``` + */ + destroy(): boolean; + } + /** !#en + Handling touch events in a ViewGroup takes special care, + because it's common for a ViewGroup to have children that are targets for different touch events than the ViewGroup itself. + To make sure that each view correctly receives the touch events intended for it, + ViewGroup should register capture phase event and handle the event propagation properly. + Please refer to Scrollview for more information. + + !#zh + ViewGroup的事件处理比较特殊,因为 ViewGroup 里面的子节点关心的事件跟 ViewGroup 本身可能不一样。 + 为了让子节点能够正确地处理事件,ViewGroup 需要注册 capture 阶段的事件,并且合理地处理 ViewGroup 之间的事件传递。 + 请参考 ScrollView 的实现来获取更多信息。 */ + export class ViewGroup extends Component { + } + /** !#en cc.WebView is a component for display web pages in the game + !#zh WebView 组件,用于在游戏中显示网页 */ + export class WebView extends _RendererUnderSG { + /** !#en A given URL to be loaded by the WebView, it should have a http or https prefix. + !#zh 指定 WebView 加载的网址,它应该是一个 http 或者 https 开头的字符串 */ + url: string; + /** !#en The webview's event callback , it will be triggered when certain webview event occurs. + !#zh WebView 的回调事件,当网页加载过程中,加载完成后或者加载出错时都会回调此函数 */ + webviewLoadedEvents: Component.EventHandler[]; + /** + !#en + Set javascript interface scheme (see also setOnJSCallback).
+ Note: Supports only on the Android and iOS. For HTML5, please refer to the official documentation.
+ Please refer to the official documentation for more details. + !#zh + 设置 JavaScript 接口方案(与 'setOnJSCallback' 配套使用)。
+ 注意:只支持 Android 和 iOS ,Web 端用法请前往官方文档查看。
+ 详情请参阅官方文档 + @param scheme scheme + */ + setJavascriptInterfaceScheme(scheme: string): void; + /** + !#en + This callback called when load URL that start with javascript + interface scheme (see also setJavascriptInterfaceScheme).
+ Note: Supports only on the Android and iOS. For HTML5, please refer to the official documentation.
+ Please refer to the official documentation for more details. + !#zh + 当加载 URL 以 JavaScript 接口方案开始时调用这个回调函数。
+ 注意:只支持 Android 和 iOS,Web 端用法请前往官方文档查看。 + 详情请参阅官方文档 + @param callback callback + */ + setOnJSCallback(callback: Function): void; + /** + !#en + Evaluates JavaScript in the context of the currently displayed page.
+ Please refer to the official document for more details
+ Note: Cross domain issues need to be resolved by yourself
+ !#zh + 执行 WebView 内部页面脚本(详情请参阅官方文档)
+ 注意:需要自行解决跨域问题 + @param str str + */ + evaluateJS(str: string): void; + /** + !#en if you don't need the WebView and it isn't in any running Scene, you should + call the destroy method on this component or the associated node explicitly. + Otherwise, the created DOM element won't be removed from web page. + !#zh + 如果你不再使用 WebView,并且组件未添加到场景中,那么你必须手动对组件或所在节点调用 destroy。 + 这样才能移除网页上的 DOM 节点,避免 Web 平台内存泄露。 + + @example + ```js + webview.node.parent = null; // or webview.node.removeFromParent(false); + // when you don't need webview anymore + webview.node.destroy(); + ``` + */ + destroy(): void; + } + /** !#en + Stores and manipulate the anchoring based on its parent. + Widget are used for GUI but can also be used for other things. + Widget will adjust current node's position and size automatically, but the results after adjustment can not be obtained until the next frame unless you call {{#crossLink "Widget/updateAlignment:method"}}{{/crossLink}} manually. + !#zh + Widget 组件,用于设置和适配其相对于父节点的边距,Widget 通常被用于 UI 界面,也可以用于其他地方。 + Widget 会自动调整当前节点的坐标和宽高,不过目前调整后的结果要到下一帧才能在脚本里获取到,除非你先手动调用 {{#crossLink "Widget/updateAlignment:method"}}{{/crossLink}}。 */ + export class Widget extends Component { + /** !#en Specifies an alignment target that can only be one of the parent nodes of the current node. + The default value is null, and when null, indicates the current parent. + !#zh 指定一个对齐目标,只能是当前节点的其中一个父节点,默认为空,为空时表示当前父节点。 */ + target: Node; + /** !#en Whether to align the top. + !#zh 是否对齐上边。 */ + isAlignTop: boolean; + /** !#en + Vertically aligns the midpoint, This will open the other vertical alignment options cancel. + !#zh + 是否垂直方向对齐中点,开启此项会将垂直方向其他对齐选项取消。 */ + isAlignVerticalCenter: boolean; + /** !#en Whether to align the bottom. + !#zh 是否对齐下边。 */ + isAlignBottom: boolean; + /** !#en Whether to align the left. + !#zh 是否对齐左边 */ + isAlignLeft: boolean; + /** !#en + Horizontal aligns the midpoint. This will open the other horizontal alignment options canceled. + !#zh + 是否水平方向对齐中点,开启此选项会将水平方向其他对齐选项取消。 */ + isAlignHorizontalCenter: boolean; + /** !#en Whether to align the right. + !#zh 是否对齐右边。 */ + isAlignRight: boolean; + /** !#en + Whether the stretched horizontally, when enable the left and right alignment will be stretched horizontally, + the width setting is invalid (read only). + !#zh + 当前是否水平拉伸。当同时启用左右对齐时,节点将会被水平拉伸,此时节点的宽度只读。 */ + isStretchWidth: boolean; + /** !#en + Whether the stretched vertically, when enable the left and right alignment will be stretched vertically, + then height setting is invalid (read only) + !#zh + 当前是否垂直拉伸。当同时启用上下对齐时,节点将会被垂直拉伸,此时节点的高度只读。 */ + isStretchHeight: boolean; + /** !#en + The margins between the top of this node and the top of parent node, + the value can be negative, Only available in 'isAlignTop' open. + !#zh + 本节点顶边和父节点顶边的距离,可填写负值,只有在 isAlignTop 开启时才有作用。 */ + top: number; + /** !#en + The margins between the bottom of this node and the bottom of parent node, + the value can be negative, Only available in 'isAlignBottom' open. + !#zh + 本节点底边和父节点底边的距离,可填写负值,只有在 isAlignBottom 开启时才有作用。 */ + bottom: number; + /** !#en + The margins between the left of this node and the left of parent node, + the value can be negative, Only available in 'isAlignLeft' open. + !#zh + 本节点左边和父节点左边的距离,可填写负值,只有在 isAlignLeft 开启时才有作用。 */ + left: number; + /** !#en + The margins between the right of this node and the right of parent node, + the value can be negative, Only available in 'isAlignRight' open. + !#zh + 本节点右边和父节点右边的距离,可填写负值,只有在 isAlignRight 开启时才有作用。 */ + right: number; + /** !#en + Horizontal aligns the midpoint offset value, + the value can be negative, Only available in 'isAlignHorizontalCenter' open. + !#zh 水平居中的偏移值,可填写负值,只有在 isAlignHorizontalCenter 开启时才有作用。 */ + horizontalCenter: number; + /** !#en + Vertical aligns the midpoint offset value, + the value can be negative, Only available in 'isAlignVerticalCenter' open. + !#zh 垂直居中的偏移值,可填写负值,只有在 isAlignVerticalCenter 开启时才有作用。 */ + verticalCenter: number; + /** !#en If true, horizontalCenter is pixel margin, otherwise is percentage (0 - 1) margin. + !#zh 如果为 true,"horizontalCenter" 将会以像素作为偏移值,反之为百分比(0 到 1)。 */ + isAbsoluteHorizontalCenter: boolean; + /** !#en If true, verticalCenter is pixel margin, otherwise is percentage (0 - 1) margin. + !#zh 如果为 true,"verticalCenter" 将会以像素作为偏移值,反之为百分比(0 到 1)。 */ + isAbsoluteVerticalCenter: boolean; + /** !#en + If true, top is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's height. + !#zh + 如果为 true,"top" 将会以像素作为边距,否则将会以相对父物体高度的百分比(0 到 1)作为边距。 */ + isAbsoluteTop: boolean; + /** !#en + If true, bottom is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's height. + !#zh + 如果为 true,"bottom" 将会以像素作为边距,否则将会以相对父物体高度的百分比(0 到 1)作为边距。 */ + isAbsoluteBottom: boolean; + /** !#en + If true, left is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's width. + !#zh + 如果为 true,"left" 将会以像素作为边距,否则将会以相对父物体宽度的百分比(0 到 1)作为边距。 */ + isAbsoluteLeft: boolean; + /** !#en + If true, right is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's width. + !#zh + 如果为 true,"right" 将会以像素作为边距,否则将会以相对父物体宽度的百分比(0 到 1)作为边距。 */ + isAbsoluteRight: boolean; + /** !#en TODO + !#zh + 开启后仅会在 onEnable 的当帧结束时对齐一次,然后立刻禁用当前组件。 + 这样便于脚本或动画继续控制当前节点。 + 注意:onEnable 时所在的那一帧仍然会进行对齐。 */ + isAlignOnce: boolean; + /** + !#en + Immediately perform the widget alignment. You need to manually call this method only if + you need to get the latest results after the alignment before the end of current frame. + !#zh + 立刻执行 widget 对齐操作。这个接口一般不需要手工调用。 + 只有当你需要在当前帧结束前获得 widget 对齐后的最新结果时才需要手动调用这个方法。 + + @example + ```js + widget.top = 10; // change top margin + cc.log(widget.node.y); // not yet changed + widget.updateAlignment(); + cc.log(widget.node.y); // changed + ``` + */ + updateAlignment(): void; + } + /** !#en + EventTarget is an object to which an event is dispatched when something has occurred. + Entity are the most common event targets, but other objects can be event targets too. + + Event targets are an important part of the Fireball event model. + The event target serves as the focal point for how events flow through the scene graph. + When an event such as a mouse click or a keypress occurs, Fireball dispatches an event object + into the event flow from the root of the hierarchy. The event object then makes its way through + the scene graph until it reaches the event target, at which point it begins its return trip through + the scene graph. This round-trip journey to the event target is conceptually divided into three phases: + - The capture phase comprises the journey from the root to the last node before the event target's node + - The target phase comprises only the event target node + - The bubbling phase comprises any subsequent nodes encountered on the return trip to the root of the tree + See also: http://www.w3.org/TR/DOM-Level-3-Events/#event-flow + + Event targets can implement the following methods: + - _getCapturingTargets + - _getBubblingTargets + + !#zh + 事件目标是事件触发时,分派的事件对象,Node 是最常见的事件目标, + 但是其他对象也可以是事件目标。
*/ + export class EventTarget { + /** + !#en + Register an callback of a specific event type on the EventTarget. + !#zh + 注册事件目标的特定事件类型回调。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + @param useCapture When set to true, the capture argument prevents callback + from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. + When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE. + Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET. + + @example + ```js + node.on(cc.Node.EventType.TOUCH_END, function (event) { + cc.log("this is callback"); + }, node); + ``` + */ + on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void; + on(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void; + /** + !#en + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. + !#zh + 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not. + If not specified, useCapture defaults to false. If a callback was registered twice, + one with capture and one without, each must be removed separately. Removal of a capturing callback + does not affect a non-capturing version of the same listener, and vice versa. + + @example + ```js + // register touchEnd eventListener + var touchEnd = node.on(cc.Node.EventType.TOUCH_END, function (event) { + cc.log("this is callback"); + }, node); + // remove touch end event listener + node.off(cc.Node.EventType.TOUCH_END, touchEnd, node); + // remove all touch end event listeners + node.off(cc.Node.EventType.TOUCH_END); + ``` + */ + off(type: string, callback?: Function, target?: any, useCapture?: boolean): void; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + @param useCapture When set to true, the capture argument prevents callback + from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. + When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE. + Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET. + + @example + ```js + node.once(cc.Node.EventType.TOUCH_END, function (event) { + cc.log("this is callback"); + }, node); + ``` + */ + once(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void; + once(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void; + /** + !#en + Dispatches an event into the event flow. + The event target is the EventTarget object upon which the dispatchEvent() method is called. + !#zh 分发事件到事件流中。 + @param event The Event object that is dispatched into the event flow + */ + dispatchEvent(event: Event): void; + /** + !#en + Send an event to this object directly, this method will not propagate the event to any other objects. + The event will be created from the supplied message, you can get the "detail" argument from event.detail. + !#zh + 该对象直接发送事件, 这种方法不会对事件传播到任何其他对象。 + @param message the message to send + @param detail whatever argument the message needs + */ + emit(message: string, detail?: any): void; + } + /** !#en Base class of all kinds of events. + !#zh 包含事件相关信息的对象。 */ + export class Event { + /** + + @param type The name of the event (case-sensitive), e.g. "click", "fire", or "submit" + @param bubbles A boolean indicating whether the event bubbles up through the tree or not + */ + constructor(type: string, bubbles: boolean); + /** !#en The name of the event (case-sensitive), e.g. "click", "fire", or "submit". + !#zh 事件类型。 */ + type: string; + /** !#en Indicate whether the event bubbles up through the tree or not. + !#zh 表示该事件是否进行冒泡。 */ + bubbles: boolean; + /** !#en A reference to the target to which the event was originally dispatched. + !#zh 最初事件触发的目标 */ + target: any; + /** !#en A reference to the currently registered target for the event. + !#zh 当前目标 */ + currentTarget: any; + /** !#en + Indicates which phase of the event flow is currently being evaluated. + Returns an integer value represented by 4 constants: + - Event.NONE = 0 + - Event.CAPTURING_PHASE = 1 + - Event.AT_TARGET = 2 + - Event.BUBBLING_PHASE = 3 + The phases are explained in the [section 3.1, Event dispatch and DOM event flow] + (http://www.w3.org/TR/DOM-Level-3-Events/#event-flow), of the DOM Level 3 Events specification. + !#zh 事件阶段 */ + eventPhase: number; + /** + !#en Reset the event for being stored in the object pool. + !#zh 重置对象池中存储的事件。 + */ + unuse(): string; + /** + !#en Reuse the event for being used again by the object pool. + !#zh 用于对象池再次使用的事件。 + */ + reuse(): string; + /** + !#en Stops propagation for current event. + !#zh 停止传递当前事件。 + */ + stopPropagation(): void; + /** + !#en Stops propagation for current event immediately, + the event won't even be dispatched to the listeners attached in the current target. + !#zh 立即停止当前事件的传递,事件甚至不会被分派到所连接的当前目标。 + */ + stopPropagationImmediate(): void; + /** + !#en Checks whether the event has been stopped. + !#zh 检查该事件是否已经停止传递. + */ + isStopped(): boolean; + /** + !#en +

+ Gets current target of the event
+ note: It only be available when the event listener is associated with node.
+ It returns 0 when the listener is associated with fixed priority. +

+ !#zh 获取当前目标节点 + */ + getCurrentTarget(): Node; + /** + !#en Gets the event type. + !#zh 获取事件类型 + */ + getType(): string; + /** !#en Code for event without type. + !#zh 没有类型的事件 */ + static NO_TYPE: string; + /** !#en The type code of Touch event. + !#zh 触摸事件类型 */ + static TOUCH: string; + /** !#en The type code of Mouse event. + !#zh 鼠标事件类型 */ + static MOUSE: string; + /** !#en The type code of Keyboard event. + !#zh 键盘事件类型 */ + static KEYBOARD: string; + /** !#en The type code of Acceleration event. + !#zh 加速器事件类型 */ + static ACCELERATION: string; + /** !#en Events not currently dispatched are in this phase + !#zh 尚未派发事件阶段 */ + static NONE: number; + /** !#en + The capturing phase comprises the journey from the root to the last node before the event target's node + see http://www.w3.org/TR/DOM-Level-3-Events/#event-flow + !#zh 捕获阶段,包括事件目标节点之前从根节点到最后一个节点的过程。 */ + static CAPTURING_PHASE: number; + /** !#en + The target phase comprises only the event target node + see http://www.w3.org/TR/DOM-Level-3-Events/#event-flow + !#zh 目标阶段仅包括事件目标节点。 */ + static AT_TARGET: number; + /** !#en + The bubbling phase comprises any subsequent nodes encountered on the return trip to the root of the hierarchy + see http://www.w3.org/TR/DOM-Level-3-Events/#event-flow + !#zh 冒泡阶段, 包括回程遇到到层次根节点的任何后续节点。 */ + static BUBBLING_PHASE: number; + } + /** !#en The System event, it currently supports the key events and accelerometer events + !#zh 系统事件,它目前支持按键事件和重力感应事件 */ + export class SystemEvent extends EventTarget { + /** + !#en whether enable accelerometer event + !#zh 是否启用加速度计事件 + @param isEnable isEnable + */ + setAccelerometerEnabled(isEnable: boolean): void; + /** + !#en set accelerometer interval value + !#zh 设置加速度计间隔值 + @param interval interval + */ + setAccelerometerInterval(interval: number): void; + } + /** !#en +

+ The base class of event listener.
+ If you need custom listener which with different callback, you need to inherit this class.
+ For instance, you could refer to EventListenerAcceleration, EventListenerKeyboard,
+ EventListenerTouchOneByOne, EventListenerCustom. +

+ + !#zh + 封装用户的事件处理逻辑。 + 注意:这是一个抽象类,开发者不应该直接实例化这个类,请参考 {{#crossLink "EventListener/create:method"}}cc.EventListener.create{{/crossLink}}。 */ + export class EventListener { + /** + Constructor + @param type type + @param listenerID listenerID + @param callback callback + */ + constructor(type: number, listenerID: number, callback: number); + /** + !#en Checks whether the listener is available. + !#zh 检测监听器是否有效 + */ + checkAvailable(): boolean; + /** + !#en Clones the listener, its subclasses have to override this method. + !#zh 克隆监听器,它的子类必须重写此方法。 + */ + clone(): EventListener; + /** + !#en Enables or disables the listener + !#zh 启用或禁用监听器。 + @param enabled enabled + */ + setEnabled(enabled: boolean): void; + /** + !#en Checks whether the listener is enabled + !#zh 检查监听器是否可用。 + */ + isEnabled(): boolean; + /** !#en The type code of unknown event listener. + !#zh 未知的事件监听器类型 */ + static UNKNOWN: number; + /** !#en The type code of keyboard event listener. + !#zh 键盘事件监听器类型 */ + static KEYBOARD: number; + /** !#en The type code of acceleration event listener. + !#zh 加速器事件监听器类型 */ + static ACCELERATION: number; + /** + !#en + Create a EventListener object with configuration including the event type, handlers and other parameters. + In handlers, this refer to the event listener object itself. + You can also pass custom parameters in the configuration object, + all custom parameters will be polyfilled into the event listener object and can be accessed in handlers. + !#zh 通过指定不同的 Event 对象来设置想要创建的事件监听器。 + @param argObj a json object + + @example + ```js + // Create KEYBOARD EventListener. + cc.EventListener.create({ + event: cc.EventListener.KEYBOARD, + onKeyPressed: function (keyCode, event) { + cc.log('pressed key: ' + keyCode); + }, + onKeyReleased: function (keyCode, event) { + cc.log('released key: ' + keyCode); + } + }); + + // Create ACCELERATION EventListener. + cc.EventListener.create({ + event: cc.EventListener.ACCELERATION, + callback: function (acc, event) { + cc.log('acc: ' + keyCode); + } + }); + ``` + */ + static create(argObj: any): EventListener; + } + /** !#en + This class has been deprecated, please use cc.systemEvent or cc.EventTarget instead. See [Listen to and launch events](../../../manual/en/scripting/events.md) for details.
+
+ cc.eventManager is a singleton object which manages event listener subscriptions and event dispatching. + The EventListener list is managed in such way so that event listeners can be added and removed + while events are being dispatched. + + !#zh + 该类已废弃,请使用 cc.systemEvent 或 cc.EventTarget 代替,详见 [监听和发射事件](../../../manual/zh/scripting/events.md)。
+
+ 事件管理器,它主要管理事件监听器注册和派发系统事件。 */ + export class eventManager { + /** + !#en Pauses all listeners which are associated the specified target. + !#zh 暂停传入的 node 相关的所有监听器的事件响应。 + @param node node + @param recursive recursive + */ + static pauseTarget(node: Node, recursive?: boolean): void; + /** + !#en Resumes all listeners which are associated the specified target. + !#zh 恢复传入的 node 相关的所有监听器的事件响应。 + @param node node + @param recursive recursive + */ + static resumeTarget(node: Node, recursive?: boolean): void; + /** + !#en Query whether the specified event listener id has been added. + !#zh 查询指定的事件 ID 是否存在 + @param listenerID The listener id. + */ + static hasEventListener(listenerID: string|number): boolean; + /** + !#en +

+ Adds a event listener for a specified event.
+ if the parameter "nodeOrPriority" is a node, + it means to add a event listener for a specified event with the priority of scene graph.
+ if the parameter "nodeOrPriority" is a Number, + it means to add a event listener for a specified event with the fixed priority.
+

+ !#zh + 将事件监听器添加到事件管理器中。
+ 如果参数 “nodeOrPriority” 是节点,优先级由 node 的渲染顺序决定,显示在上层的节点将优先收到事件。
+ 如果参数 “nodeOrPriority” 是数字,优先级则固定为该参数的数值,数字越小,优先级越高。
+ @param listener The listener of a specified event or a object of some event parameters. + @param nodeOrPriority The priority of the listener is based on the draw order of this node or fixedPriority The fixed priority of the listener. + */ + static addListener(listener: EventListener|any, nodeOrPriority: Node|number): EventListener; + /** + !#en Remove a listener. + !#zh 移除一个已添加的监听器。 + @param listener an event listener or a registered node target + + @example + ```js + + // 1. remove eventManager add Listener; + var mouseListener1 = cc.eventManager.addListener({ + event: cc.EventListener.MOUSE, + onMouseDown: function(keyCode, event){ }, + onMouseUp: function(keyCode, event){ }, + onMouseMove: function () { }, + onMouseScroll: function () { } + }, node); + + cc.eventManager.removeListener(mouseListener1); + + // 2. remove eventListener create Listener; + var mouseListener2 = cc.EventListener.create({ + event: cc.EventListener.MOUSE, + onMouseDown: function(keyCode, event){ }, + onMouseUp: function(keyCode, event){ }, + onMouseMove: function () { }, + onMouseScroll: function () { } + }); + + cc.eventManager.removeListener(mouseListener2); + + ``` + */ + static removeListener(listener: EventListener): void; + /** + !#en Removes all listeners with the same event listener type or removes all listeners of a node. + !#zh + 移除注册到 eventManager 中指定类型的所有事件监听器。
+ 1. 如果传入的第一个参数类型是 Node,那么事件管理器将移除与该对象相关的所有事件监听器。 + (如果第二参数 recursive 是 true 的话,就会连同该对象的子控件上所有的事件监听器也一并移除)
+ 2. 如果传入的第一个参数类型是 Number(该类型 EventListener 中定义的事件类型), + 那么事件管理器将移除该类型的所有事件监听器。
+ + 下列是目前存在监听器类型:
+ cc.EventListener.UNKNOWN
+ cc.EventListener.KEYBOARD
+ cc.EventListener.ACCELERATION,
+ @param listenerType listenerType or a node + @param recursive recursive + */ + static removeListeners(listenerType: number|Node, recursive?: boolean): void; + /** + !#en Removes all listeners + !#zh 移除所有事件监听器。 + */ + static removeAllListeners(): void; + /** + !#en Sets listener's priority with fixed value. + !#zh 设置 FixedPriority 类型监听器的优先级。 + @param listener listener + @param fixedPriority fixedPriority + */ + static setPriority(listener: EventListener, fixedPriority: number): void; + /** + !#en Whether to enable dispatching events + !#zh 启用或禁用事件管理器,禁用后不会分发任何事件。 + @param enabled enabled + */ + static setEnabled(enabled: boolean): void; + /** + !#en Checks whether dispatching events is enabled + !#zh 检测事件管理器是否启用。 + */ + static isEnabled(): boolean; + } + /** !#en The touch event class + !#zh 封装了触摸相关的信息。 */ + export class Touch { + /** + !#en Returns the current touch location in OpenGL coordinates.、 + !#zh 获取当前触点位置。 + */ + getLocation(): Vec2; + /** + !#en Returns X axis location value. + !#zh 获取当前触点 X 轴位置。 + */ + getLocationX(): number; + /** + !#en Returns Y axis location value. + !#zh 获取当前触点 Y 轴位置。 + */ + getLocationY(): number; + /** + !#en Returns the previous touch location in OpenGL coordinates. + !#zh 获取触点在上一次事件时的位置对象,对象包含 x 和 y 属性。 + */ + getPreviousLocation(): Vec2; + /** + !#en Returns the start touch location in OpenGL coordinates. + !#zh 获获取触点落下时的位置对象,对象包含 x 和 y 属性。 + */ + getStartLocation(): Vec2; + /** + !#en Returns the delta distance from the previous touche to the current one in screen coordinates. + !#zh 获取触点距离上一次事件移动的距离对象,对象包含 x 和 y 属性。 + */ + getDelta(): Vec2; + /** + !#en Returns the current touch location in screen coordinates. + !#zh 获取当前事件在游戏窗口内的坐标位置对象,对象包含 x 和 y 属性。 + */ + getLocationInView(): Vec2; + /** + !#en Returns the previous touch location in screen coordinates. + !#zh 获取触点在上一次事件时在游戏窗口中的位置对象,对象包含 x 和 y 属性。 + */ + getPreviousLocationInView(): Vec2; + /** + !#en Returns the start touch location in screen coordinates. + !#zh 获取触点落下时在游戏窗口中的位置对象,对象包含 x 和 y 属性。 + */ + getStartLocationInView(): Vec2; + /** + !#en Returns the id of cc.Touch. + !#zh 触点的标识 ID,可以用来在多点触摸中跟踪触点。 + */ + getID(): number; + /** + !#en Sets information to touch. + !#zh 设置触摸相关的信息。用于监控触摸事件。 + @param id id + @param x x + @param y y + */ + setTouchInfo(id: number, x: number, y: number): void; + } + /** undefined */ + export class Graphics extends _RendererUnderSG { + /** !#en + Current line width. + !#zh + 当前线条宽度 */ + lineWidth: number; + /** !#en + lineJoin determines how two connecting segments (of lines, arcs or curves) with non-zero lengths in a shape are joined together. + !#zh + lineJoin 用来设置2个长度不为0的相连部分(线段,圆弧,曲线)如何连接在一起的属性。 */ + lineJoin: Graphics.LineJoin; + /** !#en + lineCap determines how the end points of every line are drawn. + !#zh + lineCap 指定如何绘制每一条线段末端。 */ + lineCap: Graphics.LineCap; + /** !#en + stroke color + !#zh + 线段颜色 */ + strokeColor: Color; + /** !#en + fill color + !#zh + 填充颜色 */ + fillColor: Color; + /** !#en + Sets the miter limit ratio + !#zh + 设置斜接面限制比例 */ + miterLimit: number; + /** + !#en Move path start point to (x,y). + !#zh 移动路径起点到坐标(x, y) + @param x The x axis of the coordinate for the end point. + @param y The y axis of the coordinate for the end point. + */ + moveTo(x?: number, y?: number): void; + /** + !#en Adds a straight line to the path + !#zh 绘制直线路径 + @param x The x axis of the coordinate for the end point. + @param y The y axis of the coordinate for the end point. + */ + lineTo(x?: number, y?: number): void; + /** + !#en Adds a cubic Bézier curve to the path + !#zh 绘制三次贝赛尔曲线路径 + @param c1x The x axis of the coordinate for the first control point. + @param c1y The y axis of the coordinate for first control point. + @param c2x The x axis of the coordinate for the second control point. + @param c2y The y axis of the coordinate for the second control point. + @param x The x axis of the coordinate for the end point. + @param y The y axis of the coordinate for the end point. + */ + bezierCurveTo(c1x?: number, c1y?: number, c2x?: number, c2y?: number, x?: number, y?: number): void; + /** + !#en Adds a quadratic Bézier curve to the path + !#zh 绘制二次贝赛尔曲线路径 + @param cx The x axis of the coordinate for the control point. + @param cy The y axis of the coordinate for the control point. + @param x The x axis of the coordinate for the end point. + @param y The y axis of the coordinate for the end point. + */ + quadraticCurveTo(cx?: number, cy?: number, x?: number, y?: number): void; + /** + !#en Adds an arc to the path which is centered at (cx, cy) position with radius r starting at startAngle and ending at endAngle going in the given direction by counterclockwise (defaulting to false). + !#zh 绘制圆弧路径。圆弧路径的圆心在 (cx, cy) 位置,半径为 r ,根据 counterclockwise (默认为false)指定的方向从 startAngle 开始绘制,到 endAngle 结束。 + @param cx The x axis of the coordinate for the center point. + @param cy The y axis of the coordinate for the center point. + @param r The arc's radius. + @param startAngle The angle at which the arc starts, measured clockwise from the positive x axis and expressed in radians. + @param endAngle The angle at which the arc ends, measured clockwise from the positive x axis and expressed in radians. + @param counterclockwise An optional Boolean which, if true, causes the arc to be drawn counter-clockwise between the two angles. By default it is drawn clockwise. + */ + arc(cx?: number, cy?: number, r?: number, startAngle?: number, endAngle?: number, counterclockwise?: number): void; + /** + !#en Adds an ellipse to the path. + !#zh 绘制椭圆路径。 + @param cx The x axis of the coordinate for the center point. + @param cy The y axis of the coordinate for the center point. + @param rx The ellipse's x-axis radius. + @param ry The ellipse's y-axis radius. + */ + ellipse(cx?: number, cy?: number, rx?: number, ry?: number): void; + /** + !#en Adds an circle to the path. + !#zh 绘制圆形路径。 + @param cx The x axis of the coordinate for the center point. + @param cy The y axis of the coordinate for the center point. + @param r The circle's radius. + */ + circle(cx?: number, cy?: number, r?: number): void; + /** + !#en Adds an rectangle to the path. + !#zh 绘制矩形路径。 + @param x The x axis of the coordinate for the rectangle starting point. + @param y The y axis of the coordinate for the rectangle starting point. + @param w The rectangle's width. + @param h The rectangle's height. + */ + rect(x?: number, y?: number, w?: number, h?: number): void; + /** + !#en Adds an round corner rectangle to the path. + !#zh 绘制圆角矩形路径。 + @param x The x axis of the coordinate for the rectangle starting point. + @param y The y axis of the coordinate for the rectangle starting point. + @param w The rectangles width. + @param h The rectangle's height. + @param r The radius of the rectangle. + */ + roundRect(x?: number, y?: number, w?: number, h?: number, r?: number): void; + /** + !#en Draws a filled rectangle. + !#zh 绘制填充矩形。 + @param x The x axis of the coordinate for the rectangle starting point. + @param y The y axis of the coordinate for the rectangle starting point. + @param w The rectangle's width. + @param h The rectangle's height. + */ + fillRect(x?: number, y?: number, w?: number, h?: number): void; + /** + !#en Erasing any previously drawn content. + !#zh 擦除之前绘制的所有内容的方法。 + @param clean Whether to clean the graphics inner cache. + */ + clear(clean?: boolean): void; + /** + !#en Causes the point of the pen to move back to the start of the current path. It tries to add a straight line from the current point to the start. + !#zh 将笔点返回到当前路径起始点的。它尝试从当前点到起始点绘制一条直线。 + */ + close(): void; + /** + !#en Strokes the current or given path with the current stroke style. + !#zh 根据当前的画线样式,绘制当前或已经存在的路径。 + */ + stroke(): void; + /** + !#en Fills the current or given path with the current fill style. + !#zh 根据当前的画线样式,填充当前或已经存在的路径。 + */ + fill(): void; + } + /** undefined */ + export class WorldManifold { + /** !#en + world contact point (point of intersection) + !#zh + 碰撞点集合 */ + points: [Vec2]; + /** !#en + world vector pointing from A to B + !#zh + 世界坐标系下由 A 指向 B 的向量 */ + normal: Vec2; + } + /** !#en + A manifold point is a contact point belonging to a contact manifold. + It holds details related to the geometry and dynamics of the contact points. + Note: the impulses are used for internal caching and may not + provide reliable contact forces, especially for high speed collisions. + !#zh + ManifoldPoint 是接触信息中的接触点信息。它拥有关于几何和接触点的详细信息。 + 注意:信息中的冲量用于系统内部缓存,提供的接触力可能不是很准确,特别是高速移动中的碰撞信息。 */ + export class ManifoldPoint { + /** !#en + The local point usage depends on the manifold type: + -e_circles: the local center of circleB + -e_faceA: the local center of circleB or the clip point of polygonB + -e_faceB: the clip point of polygonA + !#zh + 本地坐标点的用途取决于 manifold 的类型 + - e_circles: circleB 的本地中心点 + - e_faceA: circleB 的本地中心点 或者是 polygonB 的截取点 + - e_faceB: polygonB 的截取点 */ + localPoint: Vec2; + /** !#en + Normal impulse. + !#zh + 法线冲量。 */ + normalImpulse: number; + /** !#en + Tangent impulse. + !#zh + 切线冲量。 */ + tangentImpulse: number; + } + /** undefined */ + export class Manifold { + /** !#en + Manifold type : 0: e_circles, 1: e_faceA, 2: e_faceB + !#zh + Manifold 类型 : 0: e_circles, 1: e_faceA, 2: e_faceB */ + type: number; + /** !#en + The local point usage depends on the manifold type: + -e_circles: the local center of circleA + -e_faceA: the center of faceA + -e_faceB: the center of faceB + !#zh + 用途取决于 manifold 类型 + -e_circles: circleA 的本地中心点 + -e_faceA: faceA 的本地中心点 + -e_faceB: faceB 的本地中心点 */ + localPoint: Vec2; + /** !#en + -e_circles: not used + -e_faceA: the normal on polygonA + -e_faceB: the normal on polygonB + !#zh + -e_circles: 没被使用到 + -e_faceA: polygonA 的法向量 + -e_faceB: polygonB 的法向量 */ + localNormal: Vec2; + /** !#en + the points of contact. + !#zh + 接触点信息。 */ + points: [ManifoldPoint]; + } + /** !#en + Contact impulses for reporting. + !#zh + 用于返回给回调的接触冲量。 */ + export class PhysicsImpulse { + /** !#en + Normal impulses. + !#zh + 法线方向的冲量 */ + normalImpulses: void; + /** !#en + Tangent impulses + !#zh + 切线方向的冲量 */ + tangentImpulses: void; + } + /** !#en + PhysicsContact will be generated during begin and end collision as a parameter of the collision callback. + Note that contacts will be reused for speed up cpu time, so do not cache anything in the contact. + !#zh + 物理接触会在开始和结束碰撞之间生成,并作为参数传入到碰撞回调函数中。 + 注意:传入的物理接触会被系统进行重用,所以不要在使用中缓存里面的任何信息。 */ + export class PhysicsContact { + /** + !#en + Get the world manifold. + !#zh + 获取世界坐标系下的碰撞信息。 + */ + getWorldManifold(): WorldManifold; + /** + !#en + Get the manifold. + !#zh + 获取世界坐标系下的碰撞信息。 + */ + getManifold(): Manifold; + /** + !#en + Get the impulses. + Note: PhysicsImpulse can only used in onPostSolve callback. + !#zh + 获取冲量信息 + 注意:这个信息只有在 onPostSolve 回调中才能获取到 + */ + getImpulse(): PhysicsImpulse; + colliderA: Collider; + colliderB: Collider; + /** !#en + If set disabled to true, the contact will be ignored until contact end. + If you just want to disabled contact for current time step or sub-step, please use disabledOnce. + !#zh + 如果 disabled 被设置为 true,那么直到接触结束此接触都将被忽略。 + 如果只是希望在当前时间步或子步中忽略此接触,请使用 disabledOnce 。 */ + disabled: boolean; + /** !#en + Disabled contact for current time step or sub-step. + !#zh + 在当前时间步或子步中忽略此接触。 */ + disabledOnce: boolean; + /** + !#en + Is this contact touching? + !#zh + 返回碰撞体是否已经接触到。 + */ + isTouching(): boolean; + /** + !#en + Set the desired tangent speed for a conveyor belt behavior. + !#zh + 为传送带设置期望的切线速度 + @param tangentSpeed tangentSpeed + */ + setTangentSpeed(tangentSpeed: number): void; + /** + !#en + Get the desired tangent speed. + !#zh + 获取切线速度 + */ + getTangentSpeed(): number; + /** + !#en + Override the default friction mixture. You can call this in onPreSolve callback. + !#zh + 覆盖默认的摩擦力系数。你可以在 onPreSolve 回调中调用此函数。 + @param friction friction + */ + setFriction(friction: number): void; + /** + !#en + Get the friction. + !#zh + 获取当前摩擦力系数 + */ + getFriction(): number; + /** + !#en + Reset the friction mixture to the default value. + !#zh + 重置摩擦力系数到默认值 + */ + resetFriction(): void; + /** + !#en + Override the default restitution mixture. You can call this in onPreSolve callback. + !#zh + 覆盖默认的恢复系数。你可以在 onPreSolve 回调中调用此函数。 + @param restitution restitution + */ + setRestitution(restitution: number): void; + /** + !#en + Get the restitution. + !#zh + 获取当前恢复系数 + */ + getRestitution(): number; + /** + !#en + Reset the restitution mixture to the default value. + !#zh + 重置恢复系数到默认值 + */ + resetRestitution(): void; + } + /** !#en + Physics manager uses box2d as the inner physics system, and hide most box2d implement details(creating rigidbody, synchronize rigidbody info to node). + You can visit some common box2d function through physics manager(hit testing, raycast, debug info). + Physics manager distributes the collision information to each collision callback when collision is produced. + Note: You need first enable the collision listener in the rigidbody. + !#zh + 物理系统将 box2d 作为内部物理系统,并且隐藏了大部分 box2d 实现细节(比如创建刚体,同步刚体信息到节点中等)。 + 你可以通过物理系统访问一些 box2d 常用的功能,比如点击测试,射线测试,设置测试信息等。 + 物理系统还管理碰撞信息的分发,她会在产生碰撞时,将碰撞信息分发到各个碰撞回调中。 + 注意:你需要先在刚体中开启碰撞接听才会产生相应的碰撞回调。 */ + export class PhysicsManager implements EventTarget { + /** !#en + The draw bits for drawing physics debug information. + !#zh + 指定物理系统需要绘制哪些调试信息。 */ + static DrawBits: DrawBits; + /** !#en + The ratio transform between physics unit and pixel unit, generally is 32. + !#zh + 物理单位与像素单位互相转换的比率,一般是 32。 */ + static PTM_RATIO: number; + /** !#en + The velocity iterations for the velocity constraint solver. + !#zh + 速度更新迭代数 */ + static VELOCITY_ITERATIONS: number; + /** !#en + The position Iterations for the position constraint solver. + !#zh + 位置迭代更新数 */ + static POSITION_ITERATIONS: number; + /** !#en + Specify the fixed time step. + Need enabledAccumulator to make it work. + !#zh + 指定固定的物理更新间隔时间,需要开启 enabledAccumulator 才有效。 */ + static FIXED_TIME_STEP: number; + /** !#en + Specify the max accumulator time. + Need enabledAccumulator to make it work. + !#zh + 每次可用于更新物理系统的最大时间,需要开启 enabledAccumulator 才有效。 */ + static MAX_ACCUMULATOR: number; + /** !#en + If enabled accumulator, then will call step function with the fixed time step FIXED_TIME_STEP. + And if the update dt is bigger than the time step, then will call step function several times. + If disabled accumulator, then will call step function with a time step calculated with the frame rate. + !#zh + 如果开启此选项,那么将会以固定的间隔时间 FIXED_TIME_STEP 来更新物理引擎,如果一个 update 的间隔时间大于 FIXED_TIME_STEP,则会对物理引擎进行多次更新。 + 如果关闭此选项,那么将会根据设定的 frame rate 计算出一个间隔时间来更新物理引擎。 */ + enabledAccumulator: boolean; + /** + !#en + Test which collider contains the given world point + !#zh + 获取包含给定世界坐标系点的碰撞体 + @param point the world point + */ + testPoint(point: Vec2): PhysicsCollider; + /** + !#en + Test which colliders intersect the given world rect + !#zh + 获取与给定世界坐标系矩形相交的碰撞体 + @param rect the world rect + */ + testAABB(rect: Rect): [PhysicsCollider]; + /** + !#en + Raycast the world for all colliders in the path of the ray. + The raycast ignores colliders that contain the starting point. + !#zh + 检测哪些碰撞体在给定射线的路径上,射线检测将忽略包含起始点的碰撞体。 + @param p1 start point of the raycast + @param p2 end point of the raycast + @param type optional, default is RayCastType.Closest + */ + rayCast(p1: Vec2, p2: Vec2, type: RayCastType): [PhysicsRayCastResult]; + /** + !#en + Attach physics debug draw to camera + !#zh + 将物理的调试绘制信息附加到指定摄像机上 + @param camera camera + */ + attachDebugDrawToCamera(camera: Camera): void; + /** + !#en + Detach physics debug draw to camera + !#zh + 将物理的调试绘制信息从指定摄像机上移除 + @param camera camera + */ + detachDebugDrawFromCamera(camera: Camera): void; + /** !#en + Enabled the physics manager? + !#zh + 指定是否启用物理系统? */ + enabled: boolean; + /** !#en + Debug draw flags. + !#zh + 设置调试绘制标志 */ + debugDrawFlags: number; + /** !#en + The physics world gravity. + !#zh + 物理世界重力值 */ + gravity: Vec2; + /** + !#en + Register an callback of a specific event type on the EventTarget. + !#zh + 注册事件目标的特定事件类型回调。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + @param useCapture When set to true, the capture argument prevents callback + from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. + When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE. + Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET. + + @example + ```js + node.on(cc.Node.EventType.TOUCH_END, function (event) { + cc.log("this is callback"); + }, node); + ``` + */ + on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void; + on(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void; + /** + !#en + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. + !#zh + 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not. + If not specified, useCapture defaults to false. If a callback was registered twice, + one with capture and one without, each must be removed separately. Removal of a capturing callback + does not affect a non-capturing version of the same listener, and vice versa. + + @example + ```js + // register touchEnd eventListener + var touchEnd = node.on(cc.Node.EventType.TOUCH_END, function (event) { + cc.log("this is callback"); + }, node); + // remove touch end event listener + node.off(cc.Node.EventType.TOUCH_END, touchEnd, node); + // remove all touch end event listeners + node.off(cc.Node.EventType.TOUCH_END); + ``` + */ + off(type: string, callback?: Function, target?: any, useCapture?: boolean): void; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + @param useCapture When set to true, the capture argument prevents callback + from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. + When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE. + Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET. + + @example + ```js + node.once(cc.Node.EventType.TOUCH_END, function (event) { + cc.log("this is callback"); + }, node); + ``` + */ + once(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void; + once(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void; + /** + !#en + Dispatches an event into the event flow. + The event target is the EventTarget object upon which the dispatchEvent() method is called. + !#zh 分发事件到事件流中。 + @param event The Event object that is dispatched into the event flow + */ + dispatchEvent(event: Event): void; + /** + !#en + Send an event to this object directly, this method will not propagate the event to any other objects. + The event will be created from the supplied message, you can get the "detail" argument from event.detail. + !#zh + 该对象直接发送事件, 这种方法不会对事件传播到任何其他对象。 + @param message the message to send + @param detail whatever argument the message needs + */ + emit(message: string, detail?: any): void; + } + /** undefined */ + export enum DrawBits { + e_aabbBit = 0, + e_pairBit = 0, + e_centerOfMassBit = 0, + e_jointBit = 0, + e_shapeBit = 0, + } + /** undefined */ + export class PhysicsRayCastResult { + /** !#en + The PhysicsCollider which intersects with the raycast + !#zh + 与射线相交的碰撞体 */ + collider: PhysicsCollider; + /** !#en + The intersection point + !#zh + 射线与碰撞体相交的点 */ + point: Vec2; + /** !#en + The normal vector at the point of intersection + !#zh + 射线与碰撞体相交的点的法向量 */ + normal: Vec2; + /** !#en + The fraction of the raycast path at the point of intersection + !#zh + 射线与碰撞体相交的点占射线长度的分数 */ + fraction: number; + } + /** !#en Enum for RigidBodyType. + !#zh 刚体类型 */ + export enum RigidBodyType { + Static = 0, + Kinematic = 0, + Dynamic = 0, + Animated = 0, + } + /** !#en Enum for RayCastType. + !#zh 射线检测类型 */ + export enum RayCastType { + Closest = 0, + Any = 0, + AllClosest = 0, + All = 0, + } + /** undefined */ + export class RigidBody extends Component { + /** !#en + Should enabled contact listener? + When a collision is trigger, the collision callback will only be called when enabled contact listener. + !#zh + 是否启用接触接听器。 + 当 collider 产生碰撞时,只有开启了接触接听器才会调用相应的回调函数 */ + enabledContactListener: boolean; + /** + !#en + Collision callback. + Called when two collider begin to touch. + !#zh + 碰撞回调。 + 如果你的脚本中实现了这个函数,那么它将会在两个碰撞体开始接触时被调用。 + @param contact contact information + @param selfCollider the collider belong to this rigidbody + @param otherCollider the collider belong to another rigidbody + */ + onBeginContact(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void; + /** + !#en + Collision callback. + Called when two collider cease to touch. + !#zh + 碰撞回调。 + 如果你的脚本中实现了这个函数,那么它将会在两个碰撞体停止接触时被调用。 + @param contact contact information + @param selfCollider the collider belong to this rigidbody + @param otherCollider the collider belong to another rigidbody + */ + onEndContact(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void; + /** + !#en + Collision callback. + This is called when a contact is updated. + This allows you to inspect a contact before it goes to the solver(e.g. disable contact). + Note: this is called only for awake bodies. + Note: this is called even when the number of contact points is zero. + Note: this is not called for sensors. + !#zh + 碰撞回调。 + 如果你的脚本中实现了这个函数,那么它将会在接触更新时被调用。 + 你可以在接触被处理前根据他包含的信息作出相应的处理,比如将这个接触禁用掉。 + 注意:回调只会为醒着的刚体调用。 + 注意:接触点为零的时候也有可能被调用。 + 注意:感知体(sensor)的回调不会被调用。 + @param contact contact information + @param selfCollider the collider belong to this rigidbody + @param otherCollider the collider belong to another rigidbody + */ + onPreSolve(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void; + /** + !#en + Collision callback. + This is called after a contact is updated. + You can get the impulses from the contact in this callback. + !#zh + 碰撞回调。 + 如果你的脚本中实现了这个函数,那么它将会在接触更新完后被调用。 + 你可以在这个回调中从接触信息中获取到冲量信息。 + @param contact contact information + @param selfCollider the collider belong to this rigidbody + @param otherCollider the collider belong to another rigidbody + */ + onPostSolve(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void; + /** !#en + Is this a fast moving body that should be prevented from tunneling through + other moving bodies? + Note : + - All bodies are prevented from tunneling through kinematic and static bodies. This setting is only considered on dynamic bodies. + - You should use this flag sparingly since it increases processing time. + !#zh + 这个刚体是否是一个快速移动的刚体,并且需要禁止穿过其他快速移动的刚体? + 需要注意的是 : + - 所有刚体都被禁止从 运动刚体 和 静态刚体 中穿过。此选项只关注于 动态刚体。 + - 应该尽量少的使用此选项,因为它会增加程序处理时间。 */ + bullet: boolean; + /** !#en + Rigidbody type : Static, Kinematic, Dynamic or Animated. + !#zh + 刚体类型: Static, Kinematic, Dynamic or Animated. */ + type: RigidBodyType; + /** !#en + Set this flag to false if this body should never fall asleep. + Note that this increases CPU usage. + !#zh + 如果此刚体永远都不应该进入睡眠,那么设置这个属性为 false。 + 需要注意这将使 CPU 占用率提高。 */ + allowSleep: boolean; + /** !#en + Scale the gravity applied to this body. + !#zh + 缩放应用在此刚体上的重力值 */ + gravityScale: number; + /** !#en + Linear damping is use to reduce the linear velocity. + The damping parameter can be larger than 1, but the damping effect becomes sensitive to the + time step when the damping parameter is large. + !#zh + Linear damping 用于衰减刚体的线性速度。衰减系数可以大于 1,但是当衰减系数比较大的时候,衰减的效果会变得比较敏感。 */ + linearDamping: number; + /** !#en + Angular damping is use to reduce the angular velocity. The damping parameter + can be larger than 1 but the damping effect becomes sensitive to the + time step when the damping parameter is large. + !#zh + Angular damping 用于衰减刚体的角速度。衰减系数可以大于 1,但是当衰减系数比较大的时候,衰减的效果会变得比较敏感。 */ + angularDamping: number; + /** !#en + The linear velocity of the body's origin in world co-ordinates. + !#zh + 刚体在世界坐标下的线性速度 */ + linearVelocity: Vec2; + /** !#en + The angular velocity of the body. + !#zh + 刚体的角速度 */ + angularVelocity: number; + /** !#en + Should this body be prevented from rotating? + !#zh + 是否禁止此刚体进行旋转 */ + fixedRotation: boolean; + /** !#en + Is this body initially awake or sleeping? + !#zh + 是否立刻唤醒此刚体 */ + awake: boolean; + /** !#en + Set the active state of the body. An inactive body is not + simulated and cannot be collided with or woken up. + If body is active, all fixtures will be added to the + broad-phase. + If body is inactive, all fixtures will be removed from + the broad-phase and all contacts will be destroyed. + Fixtures on an inactive body are implicitly inactive and will + not participate in collisions, ray-casts, or queries. + Joints connected to an inactive body are implicitly inactive. + !#zh + 设置刚体的激活状态。一个非激活状态下的刚体是不会被模拟和碰撞的,不管它是否处于睡眠状态下。 + 如果刚体处于激活状态下,所有夹具会被添加到 粗测阶段(broad-phase)。 + 如果刚体处于非激活状态下,所有夹具会被从 粗测阶段(broad-phase)中移除。 + 在非激活状态下的夹具不会参与到碰撞,射线,或者查找中 + 链接到非激活状态下刚体的关节也是非激活的。 */ + active: boolean; + /** + !#en + Gets a local point relative to the body's origin given a world point. + !#zh + 将一个给定的世界坐标系下的点转换为刚体本地坐标系下的点 + @param worldPoint a point in world coordinates. + @param out optional, the receiving point + */ + getLocalPoint(worldPoint: Vec2, out: Vec2): Vec2; + /** + !#en + Get the world coordinates of a point given the local coordinates. + !#zh + 将一个给定的刚体本地坐标系下的点转换为世界坐标系下的点 + @param localPoint a point in local coordinates. + @param out optional, the receiving point + */ + getWorldPoint(localPoint: Vec2, out: Vec2): Vec2; + /** + !#en + Get the world coordinates of a vector given the local coordinates. + !#zh + 将一个给定的世界坐标系下的向量转换为刚体本地坐标系下的向量 + @param localVector a vector in world coordinates. + @param out optional, the receiving vector + */ + getWorldVector(localVector: Vec2, out: Vec2): Vec2; + /** + !#en + Gets a local vector relative to the body's origin given a world vector. + !#zh + 将一个给定的世界坐标系下的点转换为刚体本地坐标系下的点 + @param worldVector a vector in world coordinates. + @param out optional, the receiving vector + */ + getLocalVector(worldVector: Vec2, out: Vec2): Vec2; + /** + !#en + Get the world body origin position. + !#zh + 获取刚体世界坐标系下的原点值 + @param out optional, the receiving point + */ + getWorldPosition(out: Vec2): Vec2; + /** + !#en + Get the world body rotation angle. + !#zh + 获取刚体世界坐标系下的旋转值。 + */ + getWorldRotation(): number; + /** + !#en + Get the local position of the center of mass. + !#zh + 获取刚体本地坐标系下的质心 + */ + getLocalCenter(): Vec2; + /** + !#en + Get the world position of the center of mass. + !#zh + 获取刚体世界坐标系下的质心 + */ + getWorldCenter(): Vec2; + /** + !#en + Get the world linear velocity of a world point attached to this body. + !#zh + 获取刚体上指定点的线性速度 + @param worldPoint a point in world coordinates. + @param out optional, the receiving point + */ + getLinearVelocityFromWorldPoint(worldPoint: Vec2, out: Vec2): Vec2; + /** + !#en + Get total mass of the body. + !#zh + 获取刚体的质量。 + */ + getMass(): number; + /** + !#en + Get the rotational inertia of the body about the local origin. + !#zh + 获取刚体本地坐标系下原点的旋转惯性 + */ + getInertia(): number; + /** + !#en + Get all the joints connect to the rigidbody. + !#zh + 获取链接到此刚体的所有关节 + */ + getJointList(): [Joint]; + /** + !#en + Apply a force at a world point. If the force is not + applied at the center of mass, it will generate a torque and + affect the angular velocity. + !#zh + 施加一个力到刚体上的一个点。如果力没有施加到刚体的质心上,还会产生一个扭矩并且影响到角速度。 + @param force the world force vector. + @param point the world position. + @param wake also wake up the body. + */ + applyForce(force: Vec2, point: Vec2, wake: boolean): void; + /** + !#en + Apply a force to the center of mass. + !#zh + 施加一个力到刚体上的质心上。 + @param force the world force vector. + @param wake also wake up the body. + */ + applyForceToCenter(force: Vec2, wake: boolean): void; + /** + !#en + Apply a torque. This affects the angular velocity. + !#zh + 施加一个扭矩力,将影响刚体的角速度 + @param torque about the z-axis (out of the screen), usually in N-m. + @param wake also wake up the body + */ + applyTorque(torque: number, wake: boolean): void; + /** + !#en + Apply a impulse at a world point, This immediately modifies the velocity. + If the impulse is not applied at the center of mass, it will generate a torque and + affect the angular velocity. + !#zh + 施加冲量到刚体上的一个点,将立即改变刚体的线性速度。 + 如果冲量施加到的点不是刚体的质心,那么将产生一个扭矩并影响刚体的角速度。 + @param impulse the world impulse vector, usually in N-seconds or kg-m/s. + @param point the world position + @param wake alse wake up the body + */ + applyLinearImpulse(impulse: Vec2, point: Vec2, wake: boolean): void; + /** + !#en + Apply an angular impulse. + !#zh + 施加一个角速度冲量。 + @param impulse the angular impulse in units of kg*m*m/s + @param wake also wake up the body + */ + applyAngularImpulse(impulse: number, wake: boolean): void; + /** + !#en + Synchronize node's world position to box2d rigidbody's position. + If enableAnimated is true and rigidbody's type is Animated type, + will set linear velocity instead of directly set rigidbody's position. + !#zh + 同步节点的世界坐标到 box2d 刚体的坐标上。 + 如果 enableAnimated 是 true,并且刚体的类型是 Animated ,那么将设置刚体的线性速度来代替直接设置刚体的位置。 + @param enableAnimated enableAnimated + */ + syncPosition(enableAnimated: boolean): void; + /** + !#en + Synchronize node's world angle to box2d rigidbody's angle. + If enableAnimated is true and rigidbody's type is Animated type, + will set angular velocity instead of directly set rigidbody's angle. + !#zh + 同步节点的世界旋转角度值到 box2d 刚体的旋转值上。 + 如果 enableAnimated 是 true,并且刚体的类型是 Animated ,那么将设置刚体的角速度来代替直接设置刚体的角度。 + @param enableAnimated enableAnimated + */ + syncRotation(enableAnimated: boolean): void; + } + /** Loader for resource loading process. It's a singleton object. */ + export class loader extends Pipeline { + /** The asset loader in cc.loader's pipeline, it's by default the first pipe. + It's used to identify an asset's type, and determine how to download it. */ + static assetLoader: any; + /** The downloader in cc.loader's pipeline, it's by default the second pipe. + It's used to download files with several handlers: pure text, image, script, audio, font, uuid. + You can add your own download function with addDownloadHandlers */ + static downloader: any; + /** The downloader in cc.loader's pipeline, it's by default the third pipe. + It's used to parse downloaded content with several handlers: JSON, image, plist, fnt, uuid. + You can add your own download function with addLoadHandlers */ + static loader: any; + /** + Gets a new XMLHttpRequest instance. + */ + static getXMLHttpRequest(): XMLHttpRequest; + /** + Add custom supported types handler or modify existing type handler for download process. + @param extMap Custom supported types with corresponded handler + + @example + ```js + cc.loader.addDownloadHandlers({ + // This will match all url with `.scene` extension or all url with `scene` type + 'scene' : function (url, callback) {} + }); + ``` + */ + static addDownloadHandlers(extMap: any): void; + /** + Add custom supported types handler or modify existing type handler for load process. + @param extMap Custom supported types with corresponded handler + + @example + ```js + cc.loader.addLoadHandlers({ + // This will match all url with `.scene` extension or all url with `scene` type + 'scene' : function (url, callback) {} + }); + ``` + */ + static addLoadHandlers(extMap: any): void; + /** + Load resources with a progression callback and a complete callback. + The progression callback is the same as Pipeline's {{#crossLink "LoadingItems/onProgress:method"}}onProgress{{/crossLink}} + The complete callback is almost the same as Pipeline's {{#crossLink "LoadingItems/onComplete:method"}}onComplete{{/crossLink}} + The only difference is when user pass a single url as resources, the complete callback will set its result directly as the second parameter. + @param resources Url list in an array + @param progressCallback Callback invoked when progression change + @param completeCallback Callback invoked when all resources loaded + + @example + ```js + cc.loader.load('a.png', function (err, tex) { + cc.log('Result should be a texture: ' + (tex instanceof cc.Texture2D)); + }); + + cc.loader.load('http://example.com/a.png', function (err, tex) { + cc.log('Should load a texture from external url: ' + (tex instanceof cc.Texture2D)); + }); + + cc.loader.load({url: 'http://example.com/getImageREST?file=a.png', type: 'png'}, function (err, tex) { + cc.log('Should load a texture from RESTful API by specify the type: ' + (tex instanceof cc.Texture2D)); + }); + + cc.loader.load(['a.png', 'b.json'], function (errors, results) { + if (errors) { + for (var i = 0; i < errors.length; i++) { + cc.log('Error url [' + errors[i] + ']: ' + results.getError(errors[i])); + } + } + var aTex = results.getContent('a.png'); + var bJsonObj = results.getContent('b.json'); + }); + ``` + */ + static load(resources: string|string[]|{uuid?: string, url?: string, type?: string}, completeCallback?: Function): void; + static load(resources: string|string[]|{uuid?: string, url?: string, type?: string}, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: Function|null): void; + /** + Load resources from the "resources" folder inside the "assets" folder of your project.
+
+ Note: All asset URLs in Creator use forward slashes, URLs using backslashes will not work. + @param url Url of the target resource. + The url is relative to the "resources" folder, extensions must be omitted. + @param type Only asset of type will be loaded if this argument is supplied. + @param progressCallback Callback invoked when progression change. + @param completeCallback Callback invoked when the resource loaded. + + @example + ```js + // load the prefab (project/assets/resources/misc/character/cocos) from resources folder + cc.loader.loadRes('misc/character/cocos', function (err, prefab) { + if (err) { + cc.error(err.message || err); + return; + } + cc.log('Result should be a prefab: ' + (prefab instanceof cc.Prefab)); + }); + + // load the sprite frame of (project/assets/resources/imgs/cocos.png) from resources folder + cc.loader.loadRes('imgs/cocos', cc.SpriteFrame, function (err, spriteFrame) { + if (err) { + cc.error(err.message || err); + return; + } + cc.log('Result should be a sprite frame: ' + (spriteFrame instanceof cc.SpriteFrame)); + }); + ``` + */ + static loadRes(url: string, type: typeof cc.Asset, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any) => void)|null): void; + static loadRes(url: string, type: typeof cc.Asset, completeCallback: (error: Error, resource: any) => void): void; + static loadRes(url: string, type: typeof cc.Asset): void; + static loadRes(url: string, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any) => void)|null): void; + static loadRes(url: string, completeCallback: (error: Error, resource: any) => void): void; + static loadRes(url: string): void; + /** + This method is like {{#crossLink "loader/loadRes:method"}}{{/crossLink}} except that it accepts array of url. + @param urls Array of URLs of the target resource. + The url is relative to the "resources" folder, extensions must be omitted. + @param type Only asset of type will be loaded if this argument is supplied. + @param progressCallback Callback invoked when progression change. + @param completeCallback A callback which is called when all assets have been loaded, or an error occurs. + + @example + ```js + // load the SpriteFrames from resources folder + var spriteFrames; + var urls = ['misc/characters/character_01', 'misc/weapons/weapons_01']; + cc.loader.loadResArray(urls, cc.SpriteFrame, function (err, assets) { + if (err) { + cc.error(err); + return; + } + spriteFrames = assets; + // ... + }); + ``` + */ + static loadResArray(url: string[], type: typeof cc.Asset, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any[]) => void)|null): void; + static loadResArray(url: string[], type: typeof cc.Asset, completeCallback: (error: Error, resource: any[]) => void): void; + static loadResArray(url: string[], type: typeof cc.Asset): void; + static loadResArray(url: string[], progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any[]) => void)|null): void; + static loadResArray(url: string[], completeCallback: (error: Error, resource: any[]) => void): void; + static loadResArray(url: string[]): void; + /** + Load all assets in a folder inside the "assets/resources" folder of your project.
+
+ Note: All asset URLs in Creator use forward slashes, URLs using backslashes will not work. + @param url Url of the target folder. + The url is relative to the "resources" folder, extensions must be omitted. + @param type Only asset of type will be loaded if this argument is supplied. + @param progressCallback Callback invoked when progression change. + @param completeCallback A callback which is called when all assets have been loaded, or an error occurs. + + @example + ```js + // load the texture (resources/imgs/cocos.png) and the corresponding sprite frame + cc.loader.loadResDir('imgs/cocos', function (err, assets) { + if (err) { + cc.error(err); + return; + } + var texture = assets[0]; + var spriteFrame = assets[1]; + }); + + // load all textures in "resources/imgs/" + cc.loader.loadResDir('imgs', cc.Texture2D, function (err, textures) { + var texture1 = textures[0]; + var texture2 = textures[1]; + }); + + // load all JSONs in "resources/data/" + cc.loader.loadResDir('data', function (err, objects, urls) { + var data = objects[0]; + var url = urls[0]; + }); + ``` + */ + static loadResDir(url: string, type: typeof cc.Asset, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any[], urls: string[]) => void)|null): void; + static loadResDir(url: string, type: typeof cc.Asset, completeCallback: (error: Error, resource: any[], urls: string[]) => void): void; + static loadResDir(url: string, type: typeof cc.Asset): void; + static loadResDir(url: string, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any[], urls: string[]) => void)|null): void; + static loadResDir(url: string, completeCallback: (error: Error, resource: any[], urls: string[]) => void): void; + static loadResDir(url: string): void; + /** + Get resource data by id.
+ When you load resources with {{#crossLink "loader/load:method"}}{{/crossLink}} or {{#crossLink "loader/loadRes:method"}}{{/crossLink}}, + the url will be the unique identity of the resource. + After loaded, you can acquire them by passing the url to this API. + @param url url + @param type Only asset of type will be returned if this argument is supplied. + */ + static getRes(url: string, type?: Function): any; + /** + !#en Get all resource dependencies of the requested asset in an array, including itself. + The owner parameter accept the following types: 1. The asset itself; 2. The resource url; 3. The asset's uuid.
+ The returned array stores the dependencies with their uuids, after retrieve dependencies, + you can release them, access dependent assets by passing the uuid to {{#crossLink "loader/getRes:method"}}{{/crossLink}}, or other stuffs you want.
+ For release all dependencies of an asset, please refer to {{#crossLink "loader/release:method"}}{{/crossLink}} + Here is some examples: + !#zh 获取一个指定资源的所有依赖资源,包含它自身,并保存在数组中返回。owner 参数接收以下几种类型:1. 资源 asset 对象;2. 资源目录下的 url;3. 资源的 uuid。
+ 返回的数组将仅保存依赖资源的 uuid,获取这些 uuid 后,你可以从 loader 释放这些资源;通过 {{#crossLink "loader/getRes:method"}}{{/crossLink}} 获取某个资源或者进行其他你需要的操作。
+ 想要释放一个资源及其依赖资源,可以参考 {{#crossLink "loader/release:method"}}{{/crossLink}}。下面是一些示例代码: + @param owner The owner asset or the resource url or the asset's uuid + + @example + ```js + // Release all dependencies of a loaded prefab + var deps = cc.loader.getDependsRecursively(prefab); + cc.loader.release(deps); + // Retrieve all dependent textures + var deps = cc.loader.getDependsRecursively('prefabs/sample'); + var textures = []; + for (var i = 0; i < deps.length; ++i) { + var item = cc.loader.getRes(deps[i]); + if (item instanceof cc.Texture2D) { + textures.push(item); + } + } + ``` + */ + static getDependsRecursively(owner: Asset|RawAsset|string): any[]; + /** + !#en + Release the content of an asset or an array of assets by uuid. + Start from v1.3, this method will not only remove the cache of the asset in loader, but also clean up its content. + For example, if you release a texture, the texture asset and its gl texture data will be freed up. + In complexe project, you can use this function with {{#crossLink "loader/getDependsRecursively:method"}}{{/crossLink}} to free up memory in critical circumstances. + Notice, this method may cause the texture to be unusable, if there are still other nodes use the same texture, they may turn to black and report gl errors. + If you only want to remove the cache of an asset, please use {{#crossLink "pipeline/removeItem:method"}}{{/crossLink}} + !#zh + 通过 id(通常是资源 url)来释放一个资源或者一个资源数组。 + 从 v1.3 开始,这个方法不仅会从 loader 中删除资源的缓存引用,还会清理它的资源内容。 + 比如说,当你释放一个 texture 资源,这个 texture 和它的 gl 贴图数据都会被释放。 + 在复杂项目中,我们建议你结合 {{#crossLink "loader/getDependsRecursively:method"}}{{/crossLink}} 来使用,便于在设备内存告急的情况下更快地释放不再需要的资源的内存。 + 注意,这个函数可能会导致资源贴图或资源所依赖的贴图不可用,如果场景中存在节点仍然依赖同样的贴图,它们可能会变黑并报 GL 错误。 + 如果你只想删除一个资源的缓存引用,请使用 {{#crossLink "pipeline/removeItem:method"}}{{/crossLink}} + @param asset asset + + @example + ```js + // Release a texture which is no longer need + cc.loader.release(texture); + // Release all dependencies of a loaded prefab + var deps = cc.loader.getDependsRecursively('prefabs/sample'); + cc.loader.release(deps); + // If there is no instance of this prefab in the scene, the prefab and its dependencies like textures, sprite frames, etc, will be freed up. + // If you have some other nodes share a texture in this prefab, you can skip it in two ways: + // 1. Forbid auto release a texture before release + cc.loader.setAutoRelease(texture2d, false); + // 2. Remove it from the dependencies array + var deps = cc.loader.getDependsRecursively('prefabs/sample'); + var index = deps.indexOf(texture2d._uuid); + if (index !== -1) + deps.splice(index, 1); + cc.loader.release(deps); + ``` + */ + static release(asset: Asset|RawAsset|string|any[]): void; + /** + !#en Release the asset by its object. Refer to {{#crossLink "loader/release:method"}}{{/crossLink}} for detailed informations. + !#zh 通过资源对象自身来释放资源。详细信息请参考 {{#crossLink "loader/release:method"}}{{/crossLink}} + @param asset asset + */ + static releaseAsset(asset: Asset): void; + /** + !#en Release the asset loaded by {{#crossLink "loader/loadRes:method"}}{{/crossLink}}. Refer to {{#crossLink "loader/release:method"}}{{/crossLink}} for detailed informations. + !#zh 释放通过 {{#crossLink "loader/loadRes:method"}}{{/crossLink}} 加载的资源。详细信息请参考 {{#crossLink "loader/release:method"}}{{/crossLink}} + @param url url + @param type Only asset of type will be released if this argument is supplied. + */ + static releaseRes(url: string, type?: Function): void; + /** + !#en Release the all assets loaded by {{#crossLink "loader/loadResDir:method"}}{{/crossLink}}. Refer to {{#crossLink "loader/release:method"}}{{/crossLink}} for detailed informations. + !#zh 释放通过 {{#crossLink "loader/loadResDir:method"}}{{/crossLink}} 加载的资源。详细信息请参考 {{#crossLink "loader/release:method"}}{{/crossLink}} + @param url url + @param type Only asset of type will be released if this argument is supplied. + */ + static releaseResDir(url: string, type?: Function): void; + /** + !#en Resource all assets. Refer to {{#crossLink "loader/release:method"}}{{/crossLink}} for detailed informations. + !#zh 释放所有资源。详细信息请参考 {{#crossLink "loader/release:method"}}{{/crossLink}} + */ + static releaseAll(): void; + /** + !#en + Indicates whether to release the asset when loading a new scene.
+ By default, when loading a new scene, all assets in the previous scene will be released or preserved + according to whether the previous scene checked the "Auto Release Assets" option. + On the other hand, assets dynamically loaded by using `cc.loader.loadRes` or `cc.loader.loadResDir` + will not be affected by that option, remain not released by default.
+ Use this API to change the default behavior on a single asset, to force preserve or release specified asset when scene switching.
+
+ See: {{#crossLink "loader/setAutoReleaseRecursively:method"}}cc.loader.setAutoReleaseRecursively{{/crossLink}}, {{#crossLink "loader/isAutoRelease:method"}}cc.loader.isAutoRelease{{/crossLink}} + !#zh + 设置当场景切换时是否自动释放资源。
+ 默认情况下,当加载新场景时,旧场景的资源根据旧场景是否勾选“Auto Release Assets”,将会被释放或者保留。 + 而使用 `cc.loader.loadRes` 或 `cc.loader.loadResDir` 动态加载的资源,则不受场景设置的影响,默认不自动释放。
+ 使用这个 API 可以在单个资源上改变这个默认行为,强制在切换场景时保留或者释放指定资源。
+
+ 参考:{{#crossLink "loader/setAutoReleaseRecursively:method"}}cc.loader.setAutoReleaseRecursively{{/crossLink}},{{#crossLink "loader/isAutoRelease:method"}}cc.loader.isAutoRelease{{/crossLink}} + @param assetOrUrlOrUuid asset object or the raw asset's url or uuid + @param autoRelease indicates whether should release automatically + + @example + ```js + // auto release the texture event if "Auto Release Assets" disabled in current scene + cc.loader.setAutoRelease(texture2d, true); + // don't release the texture even if "Auto Release Assets" enabled in current scene + cc.loader.setAutoRelease(texture2d, false); + // first parameter can be url + cc.loader.setAutoRelease(audioUrl, false); + ``` + */ + static setAutoRelease(assetOrUrlOrUuid: Asset|string, autoRelease: boolean): void; + /** + !#en + Indicates whether to release the asset and its referenced other assets when loading a new scene.
+ By default, when loading a new scene, all assets in the previous scene will be released or preserved + according to whether the previous scene checked the "Auto Release Assets" option. + On the other hand, assets dynamically loaded by using `cc.loader.loadRes` or `cc.loader.loadResDir` + will not be affected by that option, remain not released by default.
+ Use this API to change the default behavior on the specified asset and its recursively referenced assets, to force preserve or release specified asset when scene switching.
+
+ See: {{#crossLink "loader/setAutoRelease:method"}}cc.loader.setAutoRelease{{/crossLink}}, {{#crossLink "loader/isAutoRelease:method"}}cc.loader.isAutoRelease{{/crossLink}} + !#zh + 设置当场景切换时是否自动释放资源及资源引用的其它资源。
+ 默认情况下,当加载新场景时,旧场景的资源根据旧场景是否勾选“Auto Release Assets”,将会被释放或者保留。 + 而使用 `cc.loader.loadRes` 或 `cc.loader.loadResDir` 动态加载的资源,则不受场景设置的影响,默认不自动释放。
+ 使用这个 API 可以在指定资源及资源递归引用到的所有资源上改变这个默认行为,强制在切换场景时保留或者释放指定资源。
+
+ 参考:{{#crossLink "loader/setAutoRelease:method"}}cc.loader.setAutoRelease{{/crossLink}},{{#crossLink "loader/isAutoRelease:method"}}cc.loader.isAutoRelease{{/crossLink}} + @param assetOrUrlOrUuid asset object or the raw asset's url or uuid + @param autoRelease indicates whether should release automatically + + @example + ```js + // auto release the SpriteFrame and its Texture event if "Auto Release Assets" disabled in current scene + cc.loader.setAutoReleaseRecursively(spriteFrame, true); + // don't release the SpriteFrame and its Texture even if "Auto Release Assets" enabled in current scene + cc.loader.setAutoReleaseRecursively(spriteFrame, false); + // don't release the Prefab and all the referenced assets + cc.loader.setAutoReleaseRecursively(prefab, false); + ``` + */ + static setAutoReleaseRecursively(assetOrUrlOrUuid: Asset|string, autoRelease: boolean): void; + /** + !#en + Returns whether the asset is configured as auto released, despite how "Auto Release Assets" property is set on scene asset.
+
+ See: {{#crossLink "loader/setAutoRelease:method"}}cc.loader.setAutoRelease{{/crossLink}}, {{#crossLink "loader/setAutoReleaseRecursively:method"}}cc.loader.setAutoReleaseRecursively{{/crossLink}} + + !#zh + 返回指定的资源是否有被设置为自动释放,不论场景的“Auto Release Assets”如何设置。
+
+ 参考:{{#crossLink "loader/setAutoRelease:method"}}cc.loader.setAutoRelease{{/crossLink}},{{#crossLink "loader/setAutoReleaseRecursively:method"}}cc.loader.setAutoReleaseRecursively{{/crossLink}} + @param assetOrUrl asset object or the raw asset's url + */ + static isAutoRelease(assetOrUrl: Asset|string): boolean; + } + /** !#en + LoadingItems is the queue of items which can flow them into the loading pipeline.
+ Please don't construct it directly, use {{#crossLink "LoadingItems.create"}}LoadingItems.create{{/crossLink}} instead, because we use an internal pool to recycle the queues.
+ It hold a map of items, each entry in the map is a url to object key value pair.
+ Each item always contains the following property:
+ - id: The identification of the item, usually it's identical to url
+ - url: The url
+ - type: The type, it's the extension name of the url by default, could be specified manually too.
+ - error: The error happened in pipeline will be stored in this property.
+ - content: The content processed by the pipeline, the final result will also be stored in this property.
+ - complete: The flag indicate whether the item is completed by the pipeline.
+ - states: An object stores the states of each pipe the item go through, the state can be: Pipeline.ItemState.WORKING | Pipeline.ItemState.ERROR | Pipeline.ItemState.COMPLETE
+
+ Item can hold other custom properties.
+ Each LoadingItems object will be destroyed for recycle after onComplete callback
+ So please don't hold its reference for later usage, you can copy properties in it though. + !#zh + LoadingItems 是一个加载对象队列,可以用来输送加载对象到加载管线中。
+ 请不要直接使用 new 构造这个类的对象,你可以使用 {{#crossLink "LoadingItems.create"}}LoadingItems.create{{/crossLink}} 来创建一个新的加载队列,这样可以允许我们的内部对象池回收并重利用加载队列。 + 它有一个 map 属性用来存放加载项,在 map 对象中已 url 为 key 值。
+ 每个对象都会包含下列属性:
+ - id:该对象的标识,通常与 url 相同。
+ - url:路径
+ - type: 类型,它这是默认的 URL 的扩展名,可以手动指定赋值。
+ - error:pipeline 中发生的错误将被保存在这个属性中。
+ - content: pipeline 中处理的临时结果,最终的结果也将被存储在这个属性中。
+ - complete:该标志表明该对象是否通过 pipeline 完成。
+ - states:该对象存储每个管道中对象经历的状态,状态可以是 Pipeline.ItemState.WORKING | Pipeline.ItemState.ERROR | Pipeline.ItemState.COMPLETE
+
+ 对象可容纳其他自定义属性。
+ 每个 LoadingItems 对象都会在 onComplete 回调之后被销毁,所以请不要持有它的引用并在结束回调之后依赖它的内容执行任何逻辑,有这种需求的话你可以提前复制它的内容。 */ + export class LoadingItems extends CallbacksInvoker { + /** + !#en This is a callback which will be invoked while an item flow out the pipeline. + You can pass the callback function in LoadingItems.create or set it later. + !#zh 这个回调函数将在 item 加载结束后被调用。你可以在构造时传递这个回调函数或者是在构造之后直接设置。 + @param completedCount The number of the items that are already completed. + @param totalCount The total number of the items. + @param item The latest item which flow out the pipeline. + + @example + ```js + loadingItems.onProgress = function (completedCount, totalCount, item) { + var progress = (100 * completedCount / totalCount).toFixed(2); + cc.log(progress + '%'); + } + ``` + */ + onProgress(completedCount: number, totalCount: number, item: any): void; + /** + !#en This is a callback which will be invoked while all items is completed, + You can pass the callback function in LoadingItems.create or set it later. + !#zh 该函数将在加载队列全部完成时被调用。你可以在构造时传递这个回调函数或者是在构造之后直接设置。 + @param errors All errored urls will be stored in this array, if no error happened, then it will be null + @param items All items. + + @example + ```js + loadingItems.onComplete = function (errors, items) { + if (error) + cc.log('Completed with ' + errors.length + ' errors'); + else + cc.log('Completed ' + items.totalCount + ' items'); + } + ``` + */ + onComplete(errors: any[], items: LoadingItems): void; + /** !#en The map of all items. + !#zh 存储所有加载项的对象。 */ + map: any; + /** !#en The map of completed items. + !#zh 存储已经完成的加载项。 */ + completed: any; + /** !#en Total count of all items. + !#zh 所有加载项的总数。 */ + totalCount: number; + /** !#en Total count of completed items. + !#zh 所有完成加载项的总数。 */ + completedCount: number; + /** !#en Activated or not. + !#zh 是否启用。 */ + active: boolean; + /** + !#en The constructor function of LoadingItems, this will use recycled LoadingItems in the internal pool if possible. + You can pass onProgress and onComplete callbacks to visualize the loading process. + !#zh LoadingItems 的构造函数,这种构造方式会重用内部对象缓冲池中的 LoadingItems 队列,以尽量避免对象创建。 + 你可以传递 onProgress 和 onComplete 回调函数来获知加载进度信息。 + @param pipeline The pipeline to process the queue. + @param urlList The items array. + @param onProgress The progression callback, refer to {{#crossLink "LoadingItems.onProgress"}}{{/crossLink}} + @param onComplete The completion callback, refer to {{#crossLink "LoadingItems.onComplete"}}{{/crossLink}} + + @example + ```js + LoadingItems.create(cc.loader, ['a.png', 'b.plist'], function (completedCount, totalCount, item) { + var progress = (100 * completedCount / totalCount).toFixed(2); + cc.log(progress + '%'); + }, function (errors, items) { + if (errors) { + for (var i = 0; i < errors.length; ++i) { + cc.log('Error url: ' + errors[i] + ', error: ' + items.getError(errors[i])); + } + } + else { + var result_a = items.getContent('a.png'); + // ... + } + }) + ``` + */ + static create(pipeline: Pipeline, urlList: any[], onProgress: Function, onComplete: Function): LoadingItems; + /** + !#en Retrieve the LoadingItems queue object for an item. + !#zh 通过 item 对象获取它的 LoadingItems 队列。 + @param item The item to query + */ + static getQueue(item: any): LoadingItems; + /** + !#en Complete an item in the LoadingItems queue, please do not call this method unless you know what's happening. + !#zh 通知 LoadingItems 队列一个 item 对象已完成,请不要调用这个函数,除非你知道自己在做什么。 + @param item The item which has completed + */ + static itemComplete(item: any): void; + /** + !#en Add urls to the LoadingItems queue. + !#zh 向一个 LoadingItems 队列添加加载项。 + @param urlList The url list to be appended, the url can be object or string + */ + append(urlList: any[]): any[]; + /** + !#en Complete a LoadingItems queue, please do not call this method unless you know what's happening. + !#zh 完成一个 LoadingItems 队列,请不要调用这个函数,除非你知道自己在做什么。 + */ + allComplete(): void; + /** + !#en Check whether all items are completed. + !#zh 检查是否所有加载项都已经完成。 + */ + isCompleted(): boolean; + /** + !#en Check whether an item is completed. + !#zh 通过 id 检查指定加载项是否已经加载完成。 + @param id The item's id. + */ + isItemCompleted(id: string): boolean; + /** + !#en Check whether an item exists. + !#zh 通过 id 检查加载项是否存在。 + @param id The item's id. + */ + exists(id: string): boolean; + /** + !#en Returns the content of an internal item. + !#zh 通过 id 获取指定对象的内容。 + @param id The item's id. + */ + getContent(id: string): any; + /** + !#en Returns the error of an internal item. + !#zh 通过 id 获取指定对象的错误信息。 + @param id The item's id. + */ + getError(id: string): any; + /** + !#en Add a listener for an item, the callback will be invoked when the item is completed. + !#zh 监听加载项(通过 key 指定)的完成事件。 + @param key key + @param callback can be null + @param target can be null + */ + addListener(key: string, callback: Function, target: any): boolean; + /** + !#en + Check if the specified key has any registered callback.
+ If a callback is also specified, it will only return true if the callback is registered. + !#zh + 检查指定的加载项是否有完成事件监听器。
+ 如果同时还指定了一个回调方法,并且回调有注册,它只会返回 true。 + @param key key + @param callback callback + @param target target + */ + hasListener(key: string, callback?: Function, target?: any): boolean; + /** + !#en + Removes a listener.
+ It will only remove when key, callback, target all match correctly. + !#zh + 移除指定加载项已经注册的完成事件监听器。
+ 只会删除 key, callback, target 均匹配的监听器。 + @param key key + @param callback callback + @param target target + */ + remove(key: string, callback: Function, target: any): boolean; + /** + !#en + Removes all callbacks registered in a certain event + type or all callbacks registered with a certain target. + !#zh 删除指定目标的所有完成事件监听器。 + @param key The event key to be removed or the target to be removed + */ + removeAllListeners(key: string|any): void; + /** + !#en Complete an item in the LoadingItems queue, please do not call this method unless you know what's happening. + !#zh 通知 LoadingItems 队列一个 item 对象已完成,请不要调用这个函数,除非你知道自己在做什么。 + @param id The item url + */ + itemComplete(id: string): void; + /** + !#en Destroy the LoadingItems queue, the queue object won't be garbage collected, it will be recycled, so every after destroy is not reliable. + !#zh 销毁一个 LoadingItems 队列,这个队列对象会被内部缓冲池回收,所以销毁后的所有内部信息都是不可依赖的。 + */ + destroy(): void; + } + /** !#en + A pipeline describes a sequence of manipulations, each manipulation is called a pipe.
+ It's designed for loading process. so items should be urls, and the url will be the identity of each item during the process.
+ A list of items can flow in the pipeline and it will output the results of all pipes.
+ They flow in the pipeline like water in tubes, they go through pipe by pipe separately.
+ Finally all items will flow out the pipeline and the process is finished. + + !#zh + pipeline 描述了一系列的操作,每个操作都被称为 pipe。
+ 它被设计来做加载过程的流程管理。所以 item 应该是 url,并且该 url 将是在处理中的每个 item 的身份标识。
+ 一个 item 列表可以在 pipeline 中流动,它将输出加载项经过所有 pipe 之后的结果。
+ 它们穿过 pipeline 就像水在管子里流动,将会按顺序流过每个 pipe。
+ 最后当所有加载项都流出 pipeline 时,整个加载流程就结束了。 */ + export class Pipeline { + /** + !#en + Constructor, pass an array of pipes to construct a new Pipeline, + the pipes will be chained in the given order.
+ A pipe is an object which must contain an `id` in string and a `handle` function, + the id must be unique in the pipeline.
+ It can also include `async` property to identify whether it's an asynchronous process. + !#zh + 构造函数,通过一系列的 pipe 来构造一个新的 pipeline,pipes 将会在给定的顺序中被锁定。
+ 一个 pipe 就是一个对象,它包含了字符串类型的 ‘id’ 和 ‘handle’ 函数,在 pipeline 中 id 必须是唯一的。
+ 它还可以包括 ‘async’ 属性以确定它是否是一个异步过程。 + @param pipes pipes + + @example + ```js + var pipeline = new Pipeline([ + { + id: 'Downloader', + handle: function (item, callback) {}, + async: true + }, + {id: 'Parser', handle: function (item) {}, async: false} + ]); + ``` + */ + constructor(pipes: any[]); + /** + !#en + Insert a new pipe at the given index of the pipeline.
+ A pipe must contain an `id` in string and a `handle` function, the id must be unique in the pipeline. + !#zh + 在给定的索引位置插入一个新的 pipe。
+ 一个 pipe 必须包含一个字符串类型的 ‘id’ 和 ‘handle’ 函数,该 id 在 pipeline 必须是唯一标识。 + @param pipe The pipe to be inserted + @param index The index to insert + */ + insertPipe(pipe: any, index: number): void; + /** + !en + Insert a pipe to the end of an existing pipe. The existing pipe must be a valid pipe in the pipeline. + !zh + 在当前 pipeline 的一个已知 pipe 后面插入一个新的 pipe。 + @param refPipe An existing pipe in the pipeline. + @param newPipe The pipe to be inserted. + */ + insertPipeAfter(refPipe: any, newPipe: any): void; + /** + !#en + Add a new pipe at the end of the pipeline.
+ A pipe must contain an `id` in string and a `handle` function, the id must be unique in the pipeline. + !#zh + 添加一个新的 pipe 到 pipeline 尾部。
+ 该 pipe 必须包含一个字符串类型 ‘id’ 和 ‘handle’ 函数,该 id 在 pipeline 必须是唯一标识。 + @param pipe The pipe to be appended + */ + appendPipe(pipe: any): void; + /** + !#en + Let new items flow into the pipeline.
+ Each item can be a simple url string or an object, + if it's an object, it must contain `id` property.
+ You can specify its type by `type` property, by default, the type is the extension name in url.
+ By adding a `skips` property including pipe ids, you can skip these pipe.
+ The object can contain any supplementary property as you want.
+ !#zh + 让新的 item 流入 pipeline 中。
+ 这里的每个 item 可以是一个简单字符串类型的 url 或者是一个对象, + 如果它是一个对象的话,他必须要包含 ‘id’ 属性。
+ 你也可以指定它的 ‘type’ 属性类型,默认情况下,该类型是 ‘url’ 的后缀名。
+ 也通过添加一个 包含 ‘skips’ 属性的 item 对象,你就可以跳过 skips 中包含的 pipe。
+ 该对象可以包含任何附加属性。 + @param items items + + @example + ```js + pipeline.flowIn([ + 'res/Background.png', + { + id: 'res/scene.json', + type: 'scene', + name: 'scene', + skips: ['Downloader'] + } + ]); + ``` + */ + flowIn(items: any[]): void; + /** + !#en + Let new items flow into the pipeline and give a callback when the list of items are all completed.
+ This is for loading dependencies for an existing item in flow, usually used in a pipe logic.
+ For example, we have a loader for scene configuration file in JSON, the scene will only be fully loaded
+ after all its dependencies are loaded, then you will need to use function to flow in all dependencies
+ found in the configuration file, and finish the loader pipe only after all dependencies are loaded (in the callback). + !#zh + 让新 items 流入 pipeline 并且当 item 列表完成时进行回调函数。
+ 这个 API 的使用通常是为了加载依赖项。
+ 例如:
+ 我们需要加载一个场景配置的 JSON 文件,该场景会将所有的依赖项全部都加载完毕以后,进行回调表示加载完毕。 + @param urlList urlList + @param callback callback + */ + flowInDeps(urlList: any[], callback: Function): any[]; + /** + !#en + Copy the item states from one source item to all destination items.
+ It's quite useful when a pipe generate new items from one source item,
+ then you should flowIn these generated items into pipeline,
+ but you probably want them to skip all pipes the source item already go through,
+ you can achieve it with this API.
+
+ For example, an unzip pipe will generate more items, but you won't want them to pass unzip or download pipe again. + !#zh + 从一个源 item 向所有目标 item 复制它的 pipe 状态,用于避免重复通过部分 pipe。
+ 当一个源 item 生成了一系列新的 items 时很有用,
+ 你希望让这些新的依赖项进入 pipeline,但是又不希望它们通过源 item 已经经过的 pipe,
+ 但是你可能希望他们源 item 已经通过并跳过所有 pipes,
+ 这个时候就可以使用这个 API。 + @param srcItem The source item + @param dstItems A single destination item or an array of destination items + */ + copyItemStates(srcItem: any, dstItems: any[]|any): void; + /** + !#en Returns whether the pipeline is flowing (contains item) currently. + !#zh 获取 pipeline 当前是否正在处理中。 + */ + isFlowing(): boolean; + /** + !#en Returns all items in pipeline. Returns null, please use API of Loader or LoadingItems. + !#zh 获取 pipeline 中的所有 items。返回 null,请使用 Loader / LoadingItems API。 + */ + getItems(): LoadingItems; + /** + !#en Returns an item in pipeline. + !#zh 根据 id 获取一个 item + @param id The id of the item + */ + getItem(id: any): any; + /** + !#en Removes an completed item in pipeline. + It will only remove the cache in the pipeline or loader, its dependencies won't be released. + cc.loader provided another method to completely cleanup the resource and its dependencies, + please refer to {{#crossLink "loader/release:method"}}cc.loader.release{{/crossLink}} + !#zh 移除指定的已完成 item。 + 这将仅仅从 pipeline 或者 loader 中删除其缓存,并不会释放它所依赖的资源。 + cc.loader 中提供了另一种删除资源及其依赖的清理方法,请参考 {{#crossLink "loader/release:method"}}cc.loader.release{{/crossLink}} + @param id The id of the item + */ + removeItem(id: any): boolean; + /** + !#en Clear the current pipeline, this function will clean up the items. + !#zh 清空当前 pipeline,该函数将清理 items。 + */ + clear(): void; + } + /** !#en Key map for keyboard event + !#zh 键盘事件的按键值 */ + export enum KEY { + none = 0, + back = 0, + menu = 0, + backspace = 0, + tab = 0, + enter = 0, + shift = 0, + ctrl = 0, + alt = 0, + pause = 0, + capslock = 0, + escape = 0, + space = 0, + pageup = 0, + pagedown = 0, + end = 0, + home = 0, + left = 0, + up = 0, + right = 0, + down = 0, + select = 0, + insert = 0, + Delete = 0, + a = 0, + b = 0, + c = 0, + d = 0, + e = 0, + f = 0, + g = 0, + h = 0, + i = 0, + j = 0, + k = 0, + l = 0, + m = 0, + n = 0, + o = 0, + p = 0, + q = 0, + r = 0, + s = 0, + t = 0, + u = 0, + v = 0, + w = 0, + x = 0, + y = 0, + z = 0, + num0 = 0, + num1 = 0, + num2 = 0, + num3 = 0, + num4 = 0, + num5 = 0, + num6 = 0, + num7 = 0, + num8 = 0, + num9 = 0, + '*' = 0, + '+' = 0, + '-' = 0, + numdel = 0, + '/' = 0, + f1 = 0, + f2 = 0, + f3 = 0, + f4 = 0, + f5 = 0, + f6 = 0, + f7 = 0, + f8 = 0, + f9 = 0, + f10 = 0, + f11 = 0, + f12 = 0, + numlock = 0, + scrolllock = 0, + ';' = 0, + semicolon = 0, + equal = 0, + '=' = 0, + ',' = 0, + comma = 0, + dash = 0, + '.' = 0, + period = 0, + forwardslash = 0, + grave = 0, + '[' = 0, + openbracket = 0, + backslash = 0, + ']' = 0, + closebracket = 0, + quote = 0, + dpadLeft = 0, + dpadRight = 0, + dpadUp = 0, + dpadDown = 0, + dpadCenter = 0, + } + /** Image formats */ + export enum ImageFormat { + JPG = 0, + PNG = 0, + TIFF = 0, + WEBP = 0, + PVR = 0, + ETC = 0, + S3TC = 0, + ATITC = 0, + TGA = 0, + RAWDATA = 0, + UNKNOWN = 0, + getImageFormatByData = 0, + } + /** Predefined constants */ + export enum macro { + INVALID_INDEX = 0, + NODE_TAG_INVALID = 0, + PI = 0, + PI2 = 0, + FLT_MAX = 0, + FLT_MIN = 0, + RAD = 0, + DEG = 0, + UINT_MAX = 0, + REPEAT_FOREVER = 0, + FLT_EPSILON = 0, + ONE = 0, + ZERO = 0, + SRC_ALPHA = 0, + SRC_ALPHA_SATURATE = 0, + SRC_COLOR = 0, + DST_ALPHA = 0, + DST_COLOR = 0, + ONE_MINUS_SRC_ALPHA = 0, + ONE_MINUS_SRC_COLOR = 0, + ONE_MINUS_DST_ALPHA = 0, + ONE_MINUS_DST_COLOR = 0, + ONE_MINUS_CONSTANT_ALPHA = 0, + ONE_MINUS_CONSTANT_COLOR = 0, + LINEAR = 0, + BLEND_DST = 0, + WEB_ORIENTATION_PORTRAIT = 0, + WEB_ORIENTATION_LANDSCAPE_LEFT = 0, + WEB_ORIENTATION_PORTRAIT_UPSIDE_DOWN = 0, + WEB_ORIENTATION_LANDSCAPE_RIGHT = 0, + ORIENTATION_PORTRAIT = 0, + ORIENTATION_LANDSCAPE = 0, + ORIENTATION_AUTO = 0, + VERTEX_ATTRIB_FLAG_NONE = 0, + VERTEX_ATTRIB_FLAG_POSITION = 0, + VERTEX_ATTRIB_FLAG_COLOR = 0, + VERTEX_ATTRIB_FLAG_TEX_COORDS = 0, + VERTEX_ATTRIB_FLAG_POS_COLOR_TEX = 0, + GL_ALL = 0, + VERTEX_ATTRIB_POSITION = 0, + VERTEX_ATTRIB_COLOR = 0, + VERTEX_ATTRIB_TEX_COORDS = 0, + VERTEX_ATTRIB_MAX = 0, + UNIFORM_PMATRIX = 0, + UNIFORM_MVMATRIX = 0, + UNIFORM_MVPMATRIX = 0, + UNIFORM_TIME = 0, + UNIFORM_SINTIME = 0, + UNIFORM_COSTIME = 0, + UNIFORM_RANDOM01 = 0, + UNIFORM_SAMPLER = 0, + UNIFORM_MAX = 0, + SHADER_POSITION_TEXTURECOLOR = 0, + SHADER_SPRITE_POSITION_TEXTURECOLOR = 0, + SHADER_POSITION_TEXTURECOLORALPHATEST = 0, + SHADER_SPRITE_POSITION_TEXTURECOLORALPHATEST = 0, + SHADER_POSITION_COLOR = 0, + SHADER_SPRITE_POSITION_COLOR = 0, + SHADER_POSITION_TEXTURE = 0, + SHADER_POSITION_TEXTURE_UCOLOR = 0, + SHADER_POSITION_TEXTUREA8COLOR = 0, + SHADER_POSITION_UCOLOR = 0, + SHADER_POSITION_LENGTHTEXTURECOLOR = 0, + UNIFORM_PMATRIX_S = 0, + UNIFORM_MVMATRIX_S = 0, + UNIFORM_MVPMATRIX_S = 0, + UNIFORM_TIME_S = 0, + UNIFORM_SINTIME_S = 0, + UNIFORM_COSTIME_S = 0, + UNIFORM_RANDOM01_S = 0, + UNIFORM_SAMPLER_S = 0, + UNIFORM_ALPHA_TEST_VALUE_S = 0, + ATTRIBUTE_NAME_COLOR = 0, + ATTRIBUTE_NAME_POSITION = 0, + ATTRIBUTE_NAME_TEX_COORD = 0, + ITEM_SIZE = 0, + CURRENT_ITEM = 0, + ZOOM_ACTION_TAG = 0, + NORMAL_TAG = 0, + SELECTED_TAG = 0, + DISABLE_TAG = 0, + FIX_ARTIFACTS_BY_STRECHING_TEXEL = 0, + FIX_ARTIFACTS_BY_STRECHING_TEXEL_TMX = 0, + DIRECTOR_STATS_POSITION = 0, + DIRECTOR_FPS_INTERVAL = 0, + COCOSNODE_RENDER_SUBPIXEL = 0, + SPRITEBATCHNODE_RENDER_SUBPIXEL = 0, + AUTO_PREMULTIPLIED_ALPHA_FOR_PNG = 0, + OPTIMIZE_BLEND_FUNC_FOR_PREMULTIPLIED_ALPHA = 0, + TEXTURE_NPOT_SUPPORT = 0, + USE_LA88_LABELS = 0, + SPRITE_DEBUG_DRAW = 0, + LABELBMFONT_DEBUG_DRAW = 0, + LABELATLAS_DEBUG_DRAW = 0, + ENABLE_STACKABLE_ACTIONS = 0, + ENABLE_GL_STATE_CACHE = 0, + TOUCH_TIMEOUT = 0, + BATCH_VERTEX_COUNT = 0, + ENABLE_GC_FOR_NATIVE_OBJECTS = 0, + ENABLE_TILEDMAP_CULLING = 0, + DOWNLOAD_MAX_CONCURRENT = 0, + ENABLE_TRANSPARENT_CANVAS = 0, + ENABLE_WEBGL_ANTIALIAS = 0, + ENABLE_CULLING = 0, + BLEND_SRC = 0, + } + /** The base class of most of all the objects in Fireball. */ + export class Object { + /** !#en The name of the object. + !#zh 该对象的名称。 */ + name: string; + /** !#en + Indicates whether the object is not yet destroyed. (It will not be available after being destroyed)
+ When an object's `destroy` is called, it is actually destroyed after the end of this frame. + So `isValid` will return false from the next frame, while `isValid` in the current frame will still be true. + If you want to determine whether the current frame has called `destroy`, use `cc.isValid(obj, true)`, + but this is often caused by a particular logical requirements, which is not normally required. + + !#zh + 表示该对象是否可用(被 destroy 后将不可用)。
+ 当一个对象的 `destroy` 调用以后,会在这一帧结束后才真正销毁。因此从下一帧开始 `isValid` 就会返回 false,而当前帧内 `isValid` 仍然会是 true。如果希望判断当前帧是否调用过 `destroy`,请使用 `cc.isValid(obj, true)`,不过这往往是特殊的业务需求引起的,通常情况下不需要这样。 */ + isValid: boolean; + /** + !#en + Destroy this Object, and release all its own references to other objects.
+ Actual object destruction will delayed until before rendering. + From the next frame, this CCObject is not usable any more. + You can use cc.isValid(obj) to check whether the object is destroyed before accessing it. + !#zh + 销毁该对象,并释放所有它对其它对象的引用。
+ 实际销毁操作会延迟到当前帧渲染前执行。从下一帧开始,CCObject 将不再可用。 + 您可以在访问对象之前使用 cc.isValid(obj) 来检查对象是否已被销毁。 + + @example + ```js + obj.destroy(); + ``` + */ + destroy(): boolean; + } + /** Bit mask that controls object states. */ + export enum Flags { + DontSave = 0, + EditorOnly = 0, + } + /** The fullscreen API provides an easy way for web content to be presented using the user's entire screen. + It's invalid on safari, QQbrowser and android browser */ + export class screen { + /** + initialize + */ + init(): void; + /** + return true if it's full now. + */ + fullScreen(): boolean; + /** + change the screen to full mode. + @param element element + @param onFullScreenChange onFullScreenChange + */ + requestFullScreen(element: Element, onFullScreenChange: Function): void; + /** + exit the full mode. + */ + exitFullScreen(): boolean; + /** + Automatically request full screen with a touch/click event + @param element element + @param onFullScreenChange onFullScreenChange + */ + autoFullScreen(element: Element, onFullScreenChange: Function): void; + } + /** System variables */ + export class sys { + /** English language code */ + static LANGUAGE_ENGLISH: string; + /** Chinese language code */ + static LANGUAGE_CHINESE: string; + /** French language code */ + static LANGUAGE_FRENCH: string; + /** Italian language code */ + static LANGUAGE_ITALIAN: string; + /** German language code */ + static LANGUAGE_GERMAN: string; + /** Spanish language code */ + static LANGUAGE_SPANISH: string; + /** Spanish language code */ + static LANGUAGE_DUTCH: string; + /** Russian language code */ + static LANGUAGE_RUSSIAN: string; + /** Korean language code */ + static LANGUAGE_KOREAN: string; + /** Japanese language code */ + static LANGUAGE_JAPANESE: string; + /** Hungarian language code */ + static LANGUAGE_HUNGARIAN: string; + /** Portuguese language code */ + static LANGUAGE_PORTUGUESE: string; + /** Arabic language code */ + static LANGUAGE_ARABIC: string; + /** Norwegian language code */ + static LANGUAGE_NORWEGIAN: string; + /** Polish language code */ + static LANGUAGE_POLISH: string; + /** Turkish language code */ + static LANGUAGE_TURKISH: string; + /** Ukrainian language code */ + static LANGUAGE_UKRAINIAN: string; + /** Romanian language code */ + static LANGUAGE_ROMANIAN: string; + /** Bulgarian language code */ + static LANGUAGE_BULGARIAN: string; + /** Unknown language code */ + static LANGUAGE_UNKNOWN: string; + static OS_IOS: string; + static OS_ANDROID: string; + static OS_WINDOWS: string; + static OS_MARMALADE: string; + static OS_LINUX: string; + static OS_BADA: string; + static OS_BLACKBERRY: string; + static OS_OSX: string; + static OS_WP8: string; + static OS_WINRT: string; + static OS_UNKNOWN: string; + static UNKNOWN: number; + static WIN32: number; + static LINUX: number; + static MACOS: number; + static ANDROID: number; + static IPHONE: number; + static IPAD: number; + static BLACKBERRY: number; + static NACL: number; + static EMSCRIPTEN: number; + static TIZEN: number; + static WINRT: number; + static WP8: number; + static MOBILE_BROWSER: number; + static DESKTOP_BROWSER: number; + /** Indicates whether executes in editor's window process (Electron's renderer context) */ + static EDITOR_PAGE: number; + /** Indicates whether executes in editor's main process (Electron's browser context) */ + static EDITOR_CORE: number; + static WECHAT_GAME: number; + static QQ_PLAY: number; + /** BROWSER_TYPE_WECHAT */ + static BROWSER_TYPE_WECHAT: string; + /** BROWSER_TYPE_WECHAT_GAME */ + static BROWSER_TYPE_WECHAT_GAME: string; + /** BROWSER_TYPE_QQ_PLAY */ + static BROWSER_TYPE_QQ_PLAY: string; + static BROWSER_TYPE_ANDROID: string; + static BROWSER_TYPE_IE: string; + static BROWSER_TYPE_QQ: string; + static BROWSER_TYPE_MOBILE_QQ: string; + static BROWSER_TYPE_UC: string; + static BROWSER_TYPE_360: string; + static BROWSER_TYPE_BAIDU_APP: string; + static BROWSER_TYPE_BAIDU: string; + static BROWSER_TYPE_MAXTHON: string; + static BROWSER_TYPE_OPERA: string; + static BROWSER_TYPE_OUPENG: string; + static BROWSER_TYPE_MIUI: string; + static BROWSER_TYPE_FIREFOX: string; + static BROWSER_TYPE_SAFARI: string; + static BROWSER_TYPE_CHROME: string; + static BROWSER_TYPE_LIEBAO: string; + static BROWSER_TYPE_QZONE: string; + static BROWSER_TYPE_SOUGOU: string; + static BROWSER_TYPE_UNKNOWN: string; + /** Is native ? This is set to be true in jsb auto. */ + static isNative: boolean; + /** Is web browser ? */ + static isBrowser: boolean; + /** Indicate whether system is mobile system */ + static isMobile: boolean; + /** Indicate the running platform */ + static platform: number; + /** Indicate the current language of the running system */ + static language: string; + /** Indicate the running os name */ + static os: string; + /** Indicate the running os version */ + static osVersion: string; + /** Indicate the running os main version */ + static osMainVersion: number; + /** Indicate the running browser type */ + static browserType: string; + /** Indicate the running browser version */ + static browserVersion: string; + /** Indicate the real pixel resolution of the whole game window */ + static windowPixelResolution: Size; + /** cc.sys.localStorage is a local storage component. */ + static localStorage: any; + /** The capabilities of the current platform */ + static capabilities: any; + /** + Forces the garbage collection, only available in JSB + */ + static garbageCollect(): void; + /** + Dumps rooted objects, only available in JSB + */ + static dumpRoot(): void; + /** + Restart the JS VM, only available in JSB + */ + static restartVM(): void; + /** + Clean a script in the JS VM, only available in JSB + @param jsfile jsfile + */ + static cleanScript(jsfile: string): void; + /** + Check whether an object is valid, + In web engine, it will return true if the object exist + In native engine, it will return true if the JS object and the correspond native object are both valid + @param obj obj + */ + static isObjectValid(obj: any): boolean; + /** + Dump system informations + */ + static dump(): void; + /** + Open a url in browser + @param url url + */ + static openURL(url: string): void; + /** + Get the number of milliseconds elapsed since 1 January 1970 00:00:00 UTC. + */ + static now(): number; + } + /** cc.view is the singleton object which represents the game window.
+ It's main task include:
+ - Apply the design resolution policy
+ - Provide interaction with the window, like resize event on web, retina display support, etc...
+ - Manage the game view port which can be different with the window
+ - Manage the content scale and translation
+
+ Since the cc.view is a singleton, you don't need to call any constructor or create functions,
+ the standard way to use it is by calling:
+ - cc.view.methodName();
*/ + export class View { + /** +

+ Sets view's target-densitydpi for android mobile browser. it can be set to:
+ 1. cc.macro.DENSITYDPI_DEVICE, value is "device-dpi"
+ 2. cc.macro.DENSITYDPI_HIGH, value is "high-dpi" (default value)
+ 3. cc.macro.DENSITYDPI_MEDIUM, value is "medium-dpi" (browser's default value)
+ 4. cc.macro.DENSITYDPI_LOW, value is "low-dpi"
+ 5. Custom value, e.g: "480"
+

+ @param densityDPI densityDPI + */ + setTargetDensityDPI(densityDPI: string): void; + /** + Returns the current target-densitydpi value of cc.view. + */ + getTargetDensityDPI(): string; + /** + Sets whether resize canvas automatically when browser's size changed.
+ Useful only on web. + @param enabled Whether enable automatic resize with browser's resize event + */ + resizeWithBrowserSize(enabled: boolean): void; + /** + Sets the callback function for cc.view's resize action,
+ this callback will be invoked before applying resolution policy,
+ so you can do any additional modifications within the callback.
+ Useful only on web. + @param callback The callback function + */ + setResizeCallback(callback: Function|void): void; + /** + Sets the orientation of the game, it can be landscape, portrait or auto. + When set it to landscape or portrait, and screen w/h ratio doesn't fit, + cc.view will automatically rotate the game canvas using CSS. + Note that this function doesn't have any effect in native, + in native, you need to set the application orientation in native project settings + @param orientation Possible values: cc.macro.ORIENTATION_LANDSCAPE | cc.macro.ORIENTATION_PORTRAIT | cc.macro.ORIENTATION_AUTO + */ + setOrientation(orientation: number): void; + /** + Sets whether the engine modify the "viewport" meta in your web page.
+ It's enabled by default, we strongly suggest you not to disable it.
+ And even when it's enabled, you can still set your own "viewport" meta, it won't be overridden
+ Only useful on web + @param enabled Enable automatic modification to "viewport" meta + */ + adjustViewPort(enabled: boolean): void; + /** + Retina support is enabled by default for Apple device but disabled for other devices,
+ it takes effect only when you called setDesignResolutionPolicy
+ Only useful on web + @param enabled Enable or disable retina display + */ + enableRetina(enabled: boolean): void; + /** + Check whether retina display is enabled.
+ Only useful on web + */ + isRetinaEnabled(): boolean; + /** + !#en Whether to Enable on anti-alias + !#zh 控制抗锯齿是否开启 + @param enabled Enable or not anti-alias + */ + enableAntiAlias(enabled: boolean): void; + /** + !#en Returns whether the current enable on anti-alias + !#zh 返回当前是否抗锯齿 + */ + isAntiAliasEnabled(): boolean; + /** + If enabled, the application will try automatically to enter full screen mode on mobile devices
+ You can pass true as parameter to enable it and disable it by passing false.
+ Only useful on web + @param enabled Enable or disable auto full screen on mobile devices + */ + enableAutoFullScreen(enabled: boolean): void; + /** + Check whether auto full screen is enabled.
+ Only useful on web + */ + isAutoFullScreenEnabled(): boolean; + /** + Get whether render system is ready(no matter opengl or canvas),
+ this name is for the compatibility with cocos2d-x, subclass must implement this method. + */ + isViewReady(): boolean; + /** + Sets the resolution translate on View. + @param offsetLeft offsetLeft + @param offsetTop offsetTop + */ + setContentTranslateLeftTop(offsetLeft: number, offsetTop: number): void; + /** + Returns the resolution translate on View + */ + getContentTranslateLeftTop(): Size; + /** + Returns the frame size of the view.
+ On native platforms, it returns the screen size since the view is a fullscreen view.
+ On web, it returns the size of the canvas's outer DOM element. + */ + getFrameSize(): Size; + /** + On native, it sets the frame size of view.
+ On web, it sets the size of the canvas's outer DOM element. + @param width width + @param height height + */ + setFrameSize(width: number, height: number): void; + /** + Returns the visible area size of the view port. + */ + getVisibleSize(): Size; + /** + Returns the visible area size of the view port. + */ + getVisibleSizeInPixel(): Size; + /** + Returns the visible origin of the view port. + */ + getVisibleOrigin(): Vec2; + /** + Returns the visible origin of the view port. + */ + getVisibleOriginInPixel(): Vec2; + /** + Returns whether developer can set content's scale factor. + */ + canSetContentScaleFactor(): boolean; + /** + Returns the current resolution policy + */ + getResolutionPolicy(): ResolutionPolicy; + /** + Sets the current resolution policy + @param resolutionPolicy resolutionPolicy + */ + setResolutionPolicy(resolutionPolicy: ResolutionPolicy|number): void; + /** + Sets the resolution policy with designed view size in points.
+ The resolution policy include:
+ [1] ResolutionExactFit Fill screen by stretch-to-fit: if the design resolution ratio of width to height is different from the screen resolution ratio, your game view will be stretched.
+ [2] ResolutionNoBorder Full screen without black border: if the design resolution ratio of width to height is different from the screen resolution ratio, two areas of your game view will be cut.
+ [3] ResolutionShowAll Full screen with black border: if the design resolution ratio of width to height is different from the screen resolution ratio, two black borders will be shown.
+ [4] ResolutionFixedHeight Scale the content's height to screen's height and proportionally scale its width
+ [5] ResolutionFixedWidth Scale the content's width to screen's width and proportionally scale its height
+ [cc.ResolutionPolicy] [Web only feature] Custom resolution policy, constructed by cc.ResolutionPolicy
+ @param width Design resolution width. + @param height Design resolution height. + @param resolutionPolicy The resolution policy desired + */ + setDesignResolutionSize(width: number, height: number, resolutionPolicy: ResolutionPolicy|number): void; + /** + Returns the designed size for the view. + Default resolution size is the same as 'getFrameSize'. + */ + getDesignResolutionSize(): Size; + /** + Sets the container to desired pixel resolution and fit the game content to it. + This function is very useful for adaptation in mobile browsers. + In some HD android devices, the resolution is very high, but its browser performance may not be very good. + In this case, enabling retina display is very costy and not suggested, and if retina is disabled, the image may be blurry. + But this API can be helpful to set a desired pixel resolution which is in between. + This API will do the following: + 1. Set viewport's width to the desired width in pixel + 2. Set body width to the exact pixel resolution + 3. The resolution policy will be reset with designed view size in points. + @param width Design resolution width. + @param height Design resolution height. + @param resolutionPolicy The resolution policy desired + */ + setRealPixelResolution(width: number, height: number, resolutionPolicy: ResolutionPolicy|number): void; + /** + Sets view port rectangle with points. + @param x x + @param y y + @param w width + @param h height + */ + setViewPortInPoints(x: number, y: number, w: number, h: number): void; + /** + Sets Scissor rectangle with points. + @param x x + @param y y + @param w w + @param h h + */ + setScissorInPoints(x: number, y: number, w: number, h: number): void; + /** + Returns whether GL_SCISSOR_TEST is enable + */ + isScissorEnabled(): boolean; + /** + Returns the current scissor rectangle + */ + getScissorRect(): Rect; + /** + Sets the name of the view + @param viewName viewName + */ + setViewName(viewName: string): void; + /** + Returns the name of the view + */ + getViewName(): string; + /** + Returns the view port rectangle. + */ + getViewPortRect(): Rect; + /** + Returns scale factor of the horizontal direction (X axis). + */ + getScaleX(): number; + /** + Returns scale factor of the vertical direction (Y axis). + */ + getScaleY(): number; + /** + Returns device pixel ratio for retina display. + */ + getDevicePixelRatio(): number; + /** + Returns the real location in view for a translation based on a related position + @param tx The X axis translation + @param ty The Y axis translation + @param relatedPos The related position object including "left", "top", "width", "height" informations + */ + convertToLocationInView(tx: number, ty: number, relatedPos: any): Vec2; + } + /**

cc.ContainerStrategy class is the root strategy class of container's scale strategy, + it controls the behavior of how to scale the cc.container and cc.game.canvas object

*/ + export class ContainerStrategy { + /** + Manipulation before appling the strategy + @param view The target view + */ + preApply(view: View): void; + /** + Function to apply this strategy + @param view view + @param designedResolution designedResolution + */ + apply(view: View, designedResolution: Size): void; + /** + Manipulation after applying the strategy + @param view The target view + */ + postApply(view: View): void; + } + /**

cc.ContentStrategy class is the root strategy class of content's scale strategy, + it controls the behavior of how to scale the scene and setup the viewport for the game

*/ + export class ContentStrategy { + /** + Manipulation before applying the strategy + @param view The target view + */ + preApply(view: View): void; + /** + Function to apply this strategy + The return value is {scale: [scaleX, scaleY], viewport: {cc.Rect}}, + The target view can then apply these value to itself, it's preferred not to modify directly its private variables + @param view view + @param designedResolution designedResolution + */ + apply(view: View, designedResolution: Size): any; + /** + Manipulation after applying the strategy + @param view The target view + */ + postApply(view: View): void; + } + /** undefined */ + export class EqualToFrame extends ContainerStrategy { + } + /** undefined */ + export class ProportionalToFrame extends ContainerStrategy { + } + /** undefined */ + export class EqualToWindow extends EqualToFrame { + } + /** undefined */ + export class ProportionalToWindow extends ProportionalToFrame { + } + /** undefined */ + export class OriginalContainer extends ContainerStrategy { + } + /**

cc.ResolutionPolicy class is the root strategy class of scale strategy, + its main task is to maintain the compatibility with Cocos2d-x

*/ + export class ResolutionPolicy { + /** + + @param containerStg The container strategy + @param contentStg The content strategy + */ + constructor(containerStg: ContainerStrategy, contentStg: ContentStrategy); + /** + Manipulation before applying the resolution policy + @param view The target view + */ + preApply(view: View): void; + /** + Function to apply this resolution policy + The return value is {scale: [scaleX, scaleY], viewport: {cc.Rect}}, + The target view can then apply these value to itself, it's preferred not to modify directly its private variables + @param view The target view + @param designedResolution The user defined design resolution + */ + apply(view: View, designedResolution: Size): any; + /** + Manipulation after appyling the strategy + @param view The target view + */ + postApply(view: View): void; + /** + Setup the container's scale strategy + @param containerStg containerStg + */ + setContainerStrategy(containerStg: ContainerStrategy): void; + /** + Setup the content's scale strategy + @param contentStg contentStg + */ + setContentStrategy(contentStg: ContentStrategy): void; + /** The entire application is visible in the specified area without trying to preserve the original aspect ratio.
+ Distortion can occur, and the application may appear stretched or compressed. */ + static EXACT_FIT: number; + /** The entire application fills the specified area, without distortion but possibly with some cropping,
+ while maintaining the original aspect ratio of the application. */ + static NO_BORDER: number; + /** The entire application is visible in the specified area without distortion while maintaining the original
+ aspect ratio of the application. Borders can appear on two sides of the application. */ + static SHOW_ALL: number; + /** The application takes the height of the design resolution size and modifies the width of the internal
+ canvas so that it fits the aspect ratio of the device
+ no distortion will occur however you must make sure your application works on different
+ aspect ratios */ + static FIXED_HEIGHT: number; + /** The application takes the width of the design resolution size and modifies the height of the internal
+ canvas so that it fits the aspect ratio of the device
+ no distortion will occur however you must make sure your application works on different
+ aspect ratios */ + static FIXED_WIDTH: number; + /** Unknow policy */ + static UNKNOWN: number; + } + /** cc.visibleRect is a singleton object which defines the actual visible rect of the current view, + it should represent the same rect as cc.view.getViewportRect() */ + export class visibleRect { + /** + initialize + @param visibleRect visibleRect + */ + init(visibleRect: Rect): void; + /** Top left coordinate of the screen related to the game scene. */ + topLeft: Vec2; + /** Top right coordinate of the screen related to the game scene. */ + topRight: Vec2; + /** Top center coordinate of the screen related to the game scene. */ + top: Vec2; + /** Bottom left coordinate of the screen related to the game scene. */ + bottomLeft: Vec2; + /** Bottom right coordinate of the screen related to the game scene. */ + bottomRight: Vec2; + /** Bottom center coordinate of the screen related to the game scene. */ + bottom: Vec2; + /** Center coordinate of the screen related to the game scene. */ + center: Vec2; + /** Left center coordinate of the screen related to the game scene. */ + left: Vec2; + /** Right center coordinate of the screen related to the game scene. */ + right: Vec2; + /** Width of the screen. */ + width: number; + /** Height of the screen. */ + height: number; + } + /** The CallbacksHandler is an abstract class that can register and unregister callbacks by key. + Subclasses should implement their own methods about how to invoke the callbacks. */ + export class _CallbacksHandler { + /** + + @param key key + @param callback callback + @param target can be null + */ + add(key: string, callback: Function, target?: any): void; + /** + Check if the specified key has any registered callback. If a callback is also specified, + it will only return true if the callback is registered. + @param key key + @param callback callback + @param target target + */ + has(key: string, callback?: Function, target?: any): boolean; + /** + Removes all callbacks registered in a certain event type or all callbacks registered with a certain target + @param keyOrTarget The event key to be removed or the target to be removed + */ + removeAll(keyOrTarget: string|any): void; + /** + + @param key key + @param callback callback + @param target target + */ + remove(key: string, callback: Function, target?: any): void; + } + /** !#en The callbacks invoker to handle and invoke callbacks by key. + !#zh CallbacksInvoker 用来根据 Key 管理并调用回调方法。 */ + export class CallbacksInvoker extends _CallbacksHandler { + /** + + @param key key + @param p1 p1 + @param p2 p2 + @param p3 p3 + @param p4 p4 + @param p5 p5 + */ + invoke(key: string, p1?: any, p2?: any, p3?: any, p4?: any, p5?: any): void; + } + /** !#en Contains information collected during deserialization + !#zh 包含反序列化时的一些信息 */ + export class Details { + /** list of the depends assets' uuid */ + uuidList: string[]; + /** the obj list whose field needs to load asset by uuid */ + uuidObjList: any[]; + /** the corresponding field name which referenced to the asset */ + uuidPropList: string[]; + /** the corresponding field name which referenced to the raw object */ + rawProp: string; + reset(): void; + /** + + @param obj obj + @param propName propName + */ + getUuidOf(obj: any, propName: string): string; + /** + + @param obj obj + @param propName propName + @param uuid uuid + */ + push(obj: any, propName: string, uuid: string): void; + } + /** undefined */ + export class url { + /** + Returns the url of raw assets, you will only need this if the raw asset is inside the "resources" folder. + @param url url + + @example + ```js + --- + var url = cc.url.raw("textures/myTexture.png"); + console.log(url); // "resources/raw/textures/myTexture.png" + + ``` + */ + static raw(url: string): string; + /** + Returns the url of builtin raw assets. This method can only used in editor. + @param url url + + @example + ```js + --- + var url = cc.url.builtinRaw("textures/myTexture.png"); + console.log(url); // "resources/default-raw/textures/myTexture.png" + + ``` + */ + static builtinRaw(url: string): string; + } + /** !#en + A cc.SpriteFrame has:
+ - texture: A cc.Texture2D that will be used by the _ccsg.Sprite
+ - rectangle: A rectangle of the texture + + !#zh + 一个 SpriteFrame 包含:
+ - 纹理:会被 Sprite 使用的 Texture2D 对象。
+ - 矩形:在纹理中的矩形区域。 */ + export class SpriteFrame extends Asset implements EventTarget { + /** + !#en + Constructor of SpriteFrame class. + !#zh + SpriteFrame 类的构造函数。 + @param filename filename + @param rect rect + @param rotated Whether the frame is rotated in the texture + @param offset The offset of the frame in the texture + @param originalSize The size of the frame in the texture + */ + constructor(filename?: string|Texture2D, rect?: Rect, rotated?: boolean, offset?: Vec2, originalSize?: Size); + /** !#en Top border of the sprite + !#zh sprite 的顶部边框 */ + insetTop: number; + /** !#en Bottom border of the sprite + !#zh sprite 的底部边框 */ + insetBottom: number; + /** !#en Left border of the sprite + !#zh sprite 的左边边框 */ + insetLeft: number; + /** !#en Right border of the sprite + !#zh sprite 的左边边框 */ + insetRight: number; + /** + !#en Returns whether the texture have been loaded + !#zh 返回是否已加载纹理 + */ + textureLoaded(): boolean; + /** + Add a event listener for texture loaded event. + @param callback callback + @param target target + */ + addLoadedEventListener(callback: Function, target: any): void; + /** + !#en Returns whether the sprite frame is rotated in the texture. + !#zh 获取 SpriteFrame 是否旋转 + */ + isRotated(): boolean; + /** + !#en Set whether the sprite frame is rotated in the texture. + !#zh 设置 SpriteFrame 是否旋转 + @param bRotated bRotated + */ + setRotated(bRotated: boolean): void; + /** + !#en Returns the rect of the sprite frame in the texture. + !#zh 获取 SpriteFrame 的纹理矩形区域 + */ + getRect(): Rect; + /** + !#en Sets the rect of the sprite frame in the texture. + !#zh 设置 SpriteFrame 的纹理矩形区域 + @param rect rect + */ + setRect(rect: Rect): void; + /** + !#en Returns the original size of the trimmed image. + !#zh 获取修剪前的原始大小 + */ + getOriginalSize(): Size; + /** + !#en Sets the original size of the trimmed image. + !#zh 设置修剪前的原始大小 + @param size size + */ + setOriginalSize(size: Size): void; + /** + !#en Returns the texture of the frame. + !#zh 获取使用的纹理实例 + */ + getTexture(): Texture2D; + /** + !#en Returns the offset of the frame in the texture. + !#zh 获取偏移量 + */ + getOffset(): Vec2; + /** + !#en Sets the offset of the frame in the texture. + !#zh 设置偏移量 + @param offsets offsets + */ + setOffset(offsets: Vec2): void; + /** + !#en Clone the sprite frame. + !#zh 克隆 SpriteFrame + */ + clone(): SpriteFrame; + /** + !#en Set SpriteFrame with Texture, rect, rotated, offset and originalSize.
+ !#zh 通过 Texture,rect,rotated,offset 和 originalSize 设置 SpriteFrame + @param textureOrTextureFile textureOrTextureFile + @param rect rect + @param rotated rotated + @param offset offset + @param originalSize originalSize + */ + setTexture(textureOrTextureFile: string|Texture2D, rect?: Rect, rotated?: boolean, offset?: Vec2, originalSize?: Size): boolean; + /** + !#en If a loading scene (or prefab) is marked as `asyncLoadAssets`, all the textures of the SpriteFrame which + associated by user's custom Components in the scene, will not preload automatically. + These textures will be load when Sprite component is going to render the SpriteFrames. + You can call this method if you want to load the texture early. + !#zh 当加载中的场景或 Prefab 被标记为 `asyncLoadAssets` 时,用户在场景中由自定义组件关联到的所有 SpriteFrame 的贴图都不会被提前加载。 + 只有当 Sprite 组件要渲染这些 SpriteFrame 时,才会检查贴图是否加载。如果你希望加载过程提前,你可以手工调用这个方法。 + + @example + ```js + if (spriteFrame.textureLoaded()) { + this._onSpriteFrameLoaded(); + } + else { + spriteFrame.once('load', this._onSpriteFrameLoaded, this); + spriteFrame.ensureLoadTexture(); + } + ``` + */ + ensureLoadTexture(): void; + /** + !#en + If you do not need to use the SpriteFrame temporarily, you can call this method so that its texture could be garbage collected. Then when you need to render the SpriteFrame, you should call `ensureLoadTexture` manually to reload texture. + !#zh + 当你暂时不再使用这个 SpriteFrame 时,可以调用这个方法来保证引用的贴图对象能被 GC。然后当你要渲染 SpriteFrame 时,你需要手动调用 `ensureLoadTexture` 来重新加载贴图。 + + @example + ```js + spriteFrame.clearTexture(); + // when you need the SpriteFrame again... + spriteFrame.once('load', onSpriteFrameLoaded); + spriteFrame.ensureLoadTexture(); + ``` + */ + clearTexture(): void; + /** + !#en + Register an callback of a specific event type on the EventTarget. + !#zh + 注册事件目标的特定事件类型回调。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + @param useCapture When set to true, the capture argument prevents callback + from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. + When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE. + Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET. + + @example + ```js + node.on(cc.Node.EventType.TOUCH_END, function (event) { + cc.log("this is callback"); + }, node); + ``` + */ + on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void; + on(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void; + /** + !#en + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. + !#zh + 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not. + If not specified, useCapture defaults to false. If a callback was registered twice, + one with capture and one without, each must be removed separately. Removal of a capturing callback + does not affect a non-capturing version of the same listener, and vice versa. + + @example + ```js + // register touchEnd eventListener + var touchEnd = node.on(cc.Node.EventType.TOUCH_END, function (event) { + cc.log("this is callback"); + }, node); + // remove touch end event listener + node.off(cc.Node.EventType.TOUCH_END, touchEnd, node); + // remove all touch end event listeners + node.off(cc.Node.EventType.TOUCH_END); + ``` + */ + off(type: string, callback?: Function, target?: any, useCapture?: boolean): void; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + @param useCapture When set to true, the capture argument prevents callback + from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. + When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE. + Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET. + + @example + ```js + node.once(cc.Node.EventType.TOUCH_END, function (event) { + cc.log("this is callback"); + }, node); + ``` + */ + once(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void; + once(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void; + /** + !#en + Dispatches an event into the event flow. + The event target is the EventTarget object upon which the dispatchEvent() method is called. + !#zh 分发事件到事件流中。 + @param event The Event object that is dispatched into the event flow + */ + dispatchEvent(event: Event): void; + /** + !#en + Send an event to this object directly, this method will not propagate the event to any other objects. + The event will be created from the supplied message, you can get the "detail" argument from event.detail. + !#zh + 该对象直接发送事件, 这种方法不会对事件传播到任何其他对象。 + @param message the message to send + @param detail whatever argument the message needs + */ + emit(message: string, detail?: any): void; + } + /**

+ This class allows to easily create OpenGL or Canvas 2D textures from images, text or raw data.
+ The created cc.Texture2D object will always have power-of-two dimensions.
+ Depending on how you create the cc.Texture2D object, the actual image area of the texture might be smaller than the texture dimensions
+ i.e. "contentSize" != (pixelsWide, pixelsHigh) and (maxS, maxT) != (1.0, 1.0).
+ Be aware that the content of the generated textures will be upside-down!

*/ + export class Texture2D extends RawAsset implements EventTarget { + /** !#en + The url of the texture, this coule be empty if the texture wasn't created via a file. + !#zh + 贴图文件的 url,当贴图不是由文件创建时值可能为空 */ + url: string; + /** !#en + Whether the texture is loaded or not + !#zh + 贴图是否已经成功加载 */ + loaded: boolean; + /** !#en + Texture width in pixel + !#zh + 贴图像素宽度 */ + width: number; + /** !#en + Texture height in pixel + !#zh + 贴图像素高度 */ + height: number; + /** + Update texture options, not available in Canvas render mode. + image, format, premultiplyAlpha can not be updated in native. + @param options options + */ + update(options: {image: DOMImageElement; mipmap: boolean; format: PixelFormat; minFilter: Filter; magFilter: Filter; wrapS: WrapMode; wrapT: WrapMode; premultiplyAlpha: boolean; }): void; + /** + Get width in pixels. + */ + getPixelWidth(): number; + /** + Get height of in pixels. + */ + getPixelHeight(): number; + /** + Get content size. + */ + getContentSize(): Size; + /** + Get content size in pixels. + */ + getContentSizeInPixels(): Size; + /** + Init with HTML element. + @param element element + + @example + ```js + var img = new Image(); + img.src = dataURL; + texture.initWithElement(img); + texture.handleLoadedTexture(); + ``` + */ + initWithElement(element: HTMLImageElement|HTMLCanvasElement): void; + /** + Intializes with a texture2d with data. + @param data data + @param pixelFormat pixelFormat + @param pixelsWidth pixelsWidth + @param pixelsHeight pixelsHeight + @param contentSize contentSize is deprecated and ignored + */ + initWithData(data: TypedArray, pixelFormat: number, pixelsWidth: number, pixelsHeight: number, contentSize: Size): boolean; + /** + Initializes a texture from a UIImage object. + Extensions to make it easy to create a CCTexture2D object from an image file. + Note that RGBA type textures will have their alpha premultiplied - use the blending mode (gl.ONE, gl.ONE_MINUS_SRC_ALPHA). + @param uiImage uiImage + */ + initWithImage(uiImage: HTMLImageElement): boolean; + /** + HTMLElement Object getter, available only on web. + In most case, it will return null, because we are recycling the dom image element for better loading performance and lower image cache memory usage. + */ + getHtmlElementObj(): HTMLImageElement; + /** + Check whether texture is loaded. + */ + isLoaded(): boolean; + /** + Handler of texture loaded event. + @param premultiplied premultiplied + */ + handleLoadedTexture(premultiplied?: boolean): void; + /** + Description of cc.Texture2D. + */ + description(): string; + /** + Release texture. + */ + releaseTexture(): void; + /** + Pixel format of the texture. + */ + getPixelFormat(): number; + /** + Whether or not the texture has their Alpha premultiplied, + support only in WebGl rendering mode. + */ + hasPremultipliedAlpha(): boolean; + /** + Whether or not use mipmap, support only in WebGl rendering mode. + */ + hasMipmaps(): boolean; + /** + Sets the min filter, mag filter, wrap s and wrap t texture parameters.
+ If the texture size is NPOT (non power of 2), then in can only use gl.CLAMP_TO_EDGE in gl.TEXTURE_WRAP_{S,T}. + @param texParams texParams object or minFilter + @param magFilter magFilter + @param wrapS wrapS + @param wrapT wrapT + */ + setTexParameters(texParams: any|number, magFilter?: number, wrapS?: Texture2D.WrapMode, wrapT?: Texture2D.WrapMode): void; + /** + sets antialias texture parameters:
+ - GL_TEXTURE_MIN_FILTER = GL_NEAREST
+ - GL_TEXTURE_MAG_FILTER = GL_NEAREST
+ supported only in native or WebGl rendering mode + */ + setAntiAliasTexParameters(): void; + /** + Sets alias texture parameters:
+ GL_TEXTURE_MIN_FILTER = GL_NEAREST
+ GL_TEXTURE_MAG_FILTER = GL_NEAREST
+ supported only in native or WebGl rendering mode + */ + setAliasTexParameters(): void; + /** Pixel format of the texture. */ + pixelFormat: number; + /** Width in pixels. */ + pixelWidth: number; + /** Height in pixels. */ + pixelHeight: number; + /** + !#en + Register an callback of a specific event type on the EventTarget. + !#zh + 注册事件目标的特定事件类型回调。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + @param useCapture When set to true, the capture argument prevents callback + from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. + When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE. + Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET. + + @example + ```js + node.on(cc.Node.EventType.TOUCH_END, function (event) { + cc.log("this is callback"); + }, node); + ``` + */ + on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void; + on(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void; + /** + !#en + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. + !#zh + 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not. + If not specified, useCapture defaults to false. If a callback was registered twice, + one with capture and one without, each must be removed separately. Removal of a capturing callback + does not affect a non-capturing version of the same listener, and vice versa. + + @example + ```js + // register touchEnd eventListener + var touchEnd = node.on(cc.Node.EventType.TOUCH_END, function (event) { + cc.log("this is callback"); + }, node); + // remove touch end event listener + node.off(cc.Node.EventType.TOUCH_END, touchEnd, node); + // remove all touch end event listeners + node.off(cc.Node.EventType.TOUCH_END); + ``` + */ + off(type: string, callback?: Function, target?: any, useCapture?: boolean): void; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + @param useCapture When set to true, the capture argument prevents callback + from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. + When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE. + Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET. + + @example + ```js + node.once(cc.Node.EventType.TOUCH_END, function (event) { + cc.log("this is callback"); + }, node); + ``` + */ + once(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void; + once(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void; + /** + !#en + Dispatches an event into the event flow. + The event target is the EventTarget object upon which the dispatchEvent() method is called. + !#zh 分发事件到事件流中。 + @param event The Event object that is dispatched into the event flow + */ + dispatchEvent(event: Event): void; + /** + !#en + Send an event to this object directly, this method will not propagate the event to any other objects. + The event will be created from the supplied message, you can get the "detail" argument from event.detail. + !#zh + 该对象直接发送事件, 这种方法不会对事件传播到任何其他对象。 + @param message the message to send + @param detail whatever argument the message needs + */ + emit(message: string, detail?: any): void; + } + /** cc.textureCache is a singleton object, it's the global cache for cc.Texture2D */ + export class textureCache { + /** + Description + */ + static description(): string; + /** + Returns an already created texture. Returns null if the texture doesn't exist. + @param textureKeyName textureKeyName + + @example + ```js + ------------------ + var key = cc.textureCache.textureForKey("hello.png"); + + ``` + */ + static textureForKey(textureKeyName: string): Texture2D; + /** + Returns an already created texture. Returns null if the texture doesn't exist. + @param textureKeyName textureKeyName + + @example + ```js + ------------------ + var key = cc.textureCache.getTextureForKey("hello.png"); + + ``` + */ + static getTextureForKey(textureKeyName: string): Texture2D; + /** + + @param texture texture + + @example + ```js + --------------- + var cacheTextureForColor = cc.textureCache.getTextureColors(texture); + + ``` + */ + static getTextureColors(texture: HTMLImageElement): any[]; + /** + !#en get all textures + !#zh 获取所有贴图 + */ + static getAllTextures(): Texture2D[]; + /** +

Purges the dictionary of loaded textures.
+ Call this method if you receive the "Memory Warning"
+ In the short term: it will free some resources preventing your app from being killed
+ In the medium term: it will allocate more resources
+ In the long term: it will be the same

+ + @example + ```js + -------- + cc.textureCache.removeAllTextures(); + + ``` + */ + static removeAllTextures(): void; + /** + Deletes a texture from the cache given a texture. + @param texture texture + + @example + ```js + ----- + cc.textureCache.removeTexture(texture); + + ``` + */ + static removeTexture(texture: HTMLImageElement): void; + /** + Deletes a texture from the cache given a its key name. + @param textureKeyName textureKeyName + + @example + ```js + ------ + cc.textureCache.removeTexture("hello.png"); + + ``` + */ + static removeTextureForKey(textureKeyName: string): void; + /** +

Returns a Texture2D object given an file image
+ If the file image was not previously loaded, it will create a new Texture2D
+ object and it will return it. It will use the filename as a key.
+ Otherwise it will return a reference of a previously loaded image.
+ Supported image extensions: .png, .jpg, .gif

+ @param url url + @param cb cb + @param target target + + @example + ```js + ---- + cc.textureCache.addImage("hello.png"); + + ``` + */ + static addImage(url: string, cb: Function, target: any): Texture2D; + /** + Cache the image data. + @param path path + @param texture texture + */ + static cacheImage(path: string, texture: HTMLImageElement|HTMLCanvasElement): void; + } + /** A base node for CCNode, it will: + - maintain scene hierarchy and active logic + - notifications if some properties changed + - define some interfaces shares between CCNode + - define machanisms for Enity Component Systems + - define prefab and serialize functions */ + export class _BaseNode extends Object implements EventTarget { + /** !#en Name of node. + !#zh 该节点名称。 */ + name: string; + /** !#en The uuid for editor, will be stripped before building project. + !#zh 主要用于编辑器的 uuid,在编辑器下可用于持久化存储,在项目构建之后将变成自增的 id。 */ + uuid: string; + /** !#en All children nodes. + !#zh 节点的所有子节点。 */ + children: Node[]; + /** !#en All children nodes. + !#zh 节点的子节点数量。 */ + childrenCount: number; + /** !#en + The local active state of this node.
+ Note that a Node may be inactive because a parent is not active, even if this returns true.
+ Use {{#crossLink "Node/activeInHierarchy:property"}}{{/crossLink}} if you want to check if the Node is actually treated as active in the scene. + !#zh + 当前节点的自身激活状态。
+ 值得注意的是,一个节点的父节点如果不被激活,那么即使它自身设为激活,它仍然无法激活。
+ 如果你想检查节点在场景中实际的激活状态可以使用 {{#crossLink "Node/activeInHierarchy:property"}}{{/crossLink}}。 */ + active: boolean; + /** !#en Indicates whether this node is active in the scene. + !#zh 表示此节点是否在场景中激活。 */ + activeInHierarchy: boolean; + /** !#en Tag of node. + !#zh 节点标签。 */ + tag: number; + /** + + @param name name + */ + constructor(name?: string); + /** !#en The parent of the node. + !#zh 该节点的父节点。 */ + parent: Node; + /** + !#en + Properties configuration function
+ All properties in attrs will be set to the node,
+ when the setter of the node is available,
+ the property will be set via setter function.
+ !#zh 属性配置函数。在 attrs 的所有属性将被设置为节点属性。 + @param attrs Properties to be set to node + + @example + ```js + var attrs = { key: 0, num: 100 }; + node.attr(attrs); + ``` + */ + attr(attrs: any): void; + /** + !#en Returns a child from the container given its tag. + !#zh 通过标签获取节点的子节点。 + @param aTag An identifier to find the child node. + + @example + ```js + var child = node.getChildByTag(1001); + ``` + */ + getChildByTag(aTag: number): Node; + /** + !#en Returns a child from the container given its uuid. + !#zh 通过 uuid 获取节点的子节点。 + @param uuid The uuid to find the child node. + + @example + ```js + var child = node.getChildByUuid(uuid); + ``` + */ + getChildByUuid(uuid: string): Node; + /** + !#en Returns a child from the container given its name. + !#zh 通过名称获取节点的子节点。 + @param name A name to find the child node. + + @example + ```js + var child = node.getChildByName("Test Node"); + ``` + */ + getChildByName(name: string): Node; + /** + !#en + Inserts a child to the node at a specified index. + !#zh + 插入子节点到指定位置 + @param child the child node to be inserted + @param siblingIndex the sibling index to place the child in + + @example + ```js + node.insertChild(child, 2); + ``` + */ + insertChild(child: Node, siblingIndex: number): void; + /** + !#en Get the sibling index. + !#zh 获取同级索引。 + + @example + ```js + var index = node.getSiblingIndex(); + ``` + */ + getSiblingIndex(): number; + /** + !#en Set the sibling index of this node. + !#zh 设置节点同级索引。 + @param index index + + @example + ```js + node.setSiblingIndex(1); + ``` + */ + setSiblingIndex(index: number): void; + /** + !#en + Remove itself from its parent node. If cleanup is `true`, then also remove all events and actions.
+ If the cleanup parameter is not passed, it will force a cleanup, so it is recommended that you always pass in the `false` parameter when calling this API.
+ If the node orphan, then nothing happens. + !#zh + 从父节点中删除该节点。如果不传入 cleanup 参数或者传入 `true`,那么这个节点上所有绑定的事件、action 都会被删除。
+ 因此建议调用这个 API 时总是传入 `false` 参数。
+ 如果这个节点是一个孤节点,那么什么都不会发生。 + @param cleanup true if all actions and callbacks on this node should be removed, false otherwise. + + @example + ```js + node.removeFromParent(); + node.removeFromParent(false); + ``` + */ + removeFromParent(cleanup?: boolean): void; + /** + !#en + Removes a child from the container. It will also cleanup all running actions depending on the cleanup parameter.

+ If the cleanup parameter is not passed, it will force a cleanup.
+ "remove" logic MUST only be on this method
+ If a class wants to extend the 'removeChild' behavior it only needs
+ to override this method. + !#zh + 移除节点中指定的子节点,是否需要清理所有正在运行的行为取决于 cleanup 参数。
+ 如果 cleanup 参数不传入,默认为 true 表示清理。
+ @param child The child node which will be removed. + @param cleanup true if all running actions and callbacks on the child node will be cleanup, false otherwise. + + @example + ```js + node.removeChild(newNode); + node.removeChild(newNode, false); + ``` + */ + removeChild(child: Node, cleanup?: boolean): void; + /** + !#en + Removes a child from the container by tag value. It will also cleanup all running actions depending on the cleanup parameter. + If the cleanup parameter is not passed, it will force a cleanup.
+ !#zh + 通过标签移除节点中指定的子节点,是否需要清理所有正在运行的行为取决于 cleanup 参数。
+ 如果 cleanup 参数不传入,默认为 true 表示清理。 + @param tag An integer number that identifies a child node + @param cleanup true if all running actions and callbacks on the child node will be cleanup, false otherwise. + + @example + ```js + node.removeChildByTag(1001); + node.removeChildByTag(1001, false); + ``` + */ + removeChildByTag(tag: number, cleanup?: boolean): void; + /** + !#en + Removes all children from the container and do a cleanup all running actions depending on the cleanup parameter.
+ If the cleanup parameter is not passed, it will force a cleanup. + !#zh + 移除节点所有的子节点,是否需要清理所有正在运行的行为取决于 cleanup 参数。
+ 如果 cleanup 参数不传入,默认为 true 表示清理。 + @param cleanup true if all running actions on all children nodes should be cleanup, false otherwise. + + @example + ```js + node.removeAllChildren(); + node.removeAllChildren(false); + ``` + */ + removeAllChildren(cleanup?: boolean): void; + /** + !#en Is this node a child of the given node? + !#zh 是否是指定节点的子节点? + @param parent parent + + @example + ```js + node.isChildOf(newNode); + ``` + */ + isChildOf(parent: Node): boolean; + /** + !#en + Returns the component of supplied type if the node has one attached, null if it doesn't.
+ You can also get component in the node by passing in the name of the script. + !#zh + 获取节点上指定类型的组件,如果节点有附加指定类型的组件,则返回,如果没有则为空。
+ 传入参数也可以是脚本的名称。 + @param typeOrClassName typeOrClassName + + @example + ```js + // get sprite component. + var sprite = node.getComponent(cc.Sprite); + // get custom test calss. + var test = node.getComponent("Test"); + ``` + */ + getComponent(type: {prototype: T}): T; + getComponent(className: string): any; + /** + !#en Returns all components of supplied type in the node. + !#zh 返回节点上指定类型的所有组件。 + @param typeOrClassName typeOrClassName + + @example + ```js + var sprites = node.getComponents(cc.Sprite); + var tests = node.getComponents("Test"); + ``` + */ + getComponents(type: {prototype: T}): T[]; + getComponents(className: string): any[]; + /** + !#en Returns the component of supplied type in any of its children using depth first search. + !#zh 递归查找所有子节点中第一个匹配指定类型的组件。 + @param typeOrClassName typeOrClassName + + @example + ```js + var sprite = node.getComponentInChildren(cc.Sprite); + var Test = node.getComponentInChildren("Test"); + ``` + */ + getComponentInChildren(type: {prototype: T}): T; + getComponentInChildren(className: string): any; + /** + !#en Returns all components of supplied type in self or any of its children. + !#zh 递归查找自身或所有子节点中指定类型的组件 + @param typeOrClassName typeOrClassName + + @example + ```js + var sprites = node.getComponentsInChildren(cc.Sprite); + var tests = node.getComponentsInChildren("Test"); + ``` + */ + getComponentsInChildren(type: {prototype: T}): T[]; + getComponentsInChildren(className: string): any[]; + /** + !#en Adds a component class to the node. You can also add component to node by passing in the name of the script. + !#zh 向节点添加一个指定类型的组件类,你还可以通过传入脚本的名称来添加组件。 + @param typeOrClassName The constructor or the class name of the component to add + + @example + ```js + var sprite = node.addComponent(cc.Sprite); + var test = node.addComponent("Test"); + ``` + */ + addComponent(type: {new(): T}): T; + addComponent(className: string): any; + /** + !#en + Removes a component identified by the given name or removes the component object given. + You can also use component.destroy() if you already have the reference. + !#zh + 删除节点上的指定组件,传入参数可以是一个组件构造函数或组件名,也可以是已经获得的组件引用。 + 如果你已经获得组件引用,你也可以直接调用 component.destroy() + @param component The need remove component. + + @example + ```js + node.removeComponent(cc.Sprite); + var Test = require("Test"); + node.removeComponent(Test); + ``` + */ + removeComponent(component: string|Function|Component): void; + /** + !#en + Destroy all children from the node, and release all their own references to other objects.
+ Actual destruct operation will delayed until before rendering. + !#zh + 销毁所有子节点,并释放所有它们对其它对象的引用。
+ 实际销毁操作会延迟到当前帧渲染前执行。 + + @example + ```js + node.destroyAllChildren(); + ``` + */ + destroyAllChildren(): void; + /** + !#en + Register an callback of a specific event type on the EventTarget. + !#zh + 注册事件目标的特定事件类型回调。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + @param useCapture When set to true, the capture argument prevents callback + from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. + When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE. + Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET. + + @example + ```js + node.on(cc.Node.EventType.TOUCH_END, function (event) { + cc.log("this is callback"); + }, node); + ``` + */ + on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void; + on(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void; + /** + !#en + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. + !#zh + 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not. + If not specified, useCapture defaults to false. If a callback was registered twice, + one with capture and one without, each must be removed separately. Removal of a capturing callback + does not affect a non-capturing version of the same listener, and vice versa. + + @example + ```js + // register touchEnd eventListener + var touchEnd = node.on(cc.Node.EventType.TOUCH_END, function (event) { + cc.log("this is callback"); + }, node); + // remove touch end event listener + node.off(cc.Node.EventType.TOUCH_END, touchEnd, node); + // remove all touch end event listeners + node.off(cc.Node.EventType.TOUCH_END); + ``` + */ + off(type: string, callback?: Function, target?: any, useCapture?: boolean): void; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + @param useCapture When set to true, the capture argument prevents callback + from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. + When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE. + Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET. + + @example + ```js + node.once(cc.Node.EventType.TOUCH_END, function (event) { + cc.log("this is callback"); + }, node); + ``` + */ + once(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void; + once(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void; + /** + !#en + Dispatches an event into the event flow. + The event target is the EventTarget object upon which the dispatchEvent() method is called. + !#zh 分发事件到事件流中。 + @param event The Event object that is dispatched into the event flow + */ + dispatchEvent(event: Event): void; + /** + !#en + Send an event to this object directly, this method will not propagate the event to any other objects. + The event will be created from the supplied message, you can get the "detail" argument from event.detail. + !#zh + 该对象直接发送事件, 这种方法不会对事件传播到任何其他对象。 + @param message the message to send + @param detail whatever argument the message needs + */ + emit(message: string, detail?: any): void; + } + /** !#en + cc.AffineTransform class represent an affine transform matrix. It's composed basically by translation, rotation, scale transformations.
+ Please do not use its constructor directly, use cc.affineTransformMake alias function instead. + !#zh + cc.AffineTransform 类代表一个仿射变换矩阵。它基本上是由平移旋转,缩放转变所组成。
+ 请不要直接使用它的构造,请使用 cc.affineTransformMake 函数代替。 */ + export class AffineTransform { + /** + !#en Create a cc.AffineTransform object with all contents in the matrix. + !#zh 用在矩阵中的所有内容创建一个 cc.AffineTransform 对象。 + @param a a + @param b b + @param c c + @param d d + @param tx tx + @param ty ty + */ + affineTransformMake(a: number, b: number, c: number, d: number, tx: number, ty: number): AffineTransform; + /** + !#en Clone a cc.AffineTransform object from the specified transform. + !#zh 克隆指定的 cc.AffineTransform 对象。 + @param t t + */ + affineTransformClone(t: AffineTransform): AffineTransform; + /** + !#en Apply the affine transformation on a point. + !#zh 对一个点应用矩阵变换。 + @param point or x. + @param transOrY transform matrix or y. + @param t transform matrix or y. + */ + pointApplyAffineTransform(point: Vec2|number, transOrY: AffineTransform|number, t: AffineTransform): Vec2; + /** + !#en Apply the affine transformation on a size. + !#zh 应用 Size 到仿射变换矩阵上。 + @param size size + @param t t + */ + sizeApplyAffineTransform(size: Size, t: AffineTransform): Size; + /** + !#en + Create a identity transformation matrix:
+ [ 1, 0, 0,
+ 0, 1, 0 ] + !#zh + 单位矩阵:
+ [ 1, 0, 0,
+ 0, 1, 0 ] + */ + affineTransformMakeIdentity(): AffineTransform; + /** + !#en Apply the affine transformation on a rect. + !#zh 应用 Rect 到仿射变换矩阵上。 + @param rect rect + @param anAffineTransform anAffineTransform + */ + rectApplyAffineTransform(rect: Rect, anAffineTransform: AffineTransform): Rect; + /** + !#en Apply the affine transformation on a rect, and truns to an Oriented Bounding Box. + !#zh 应用 Rect 到仿射变换矩阵上, 并转换为有向包围盒 + @param rect rect + @param anAffineTransform anAffineTransform + @param out_bl out_bl + @param out_tl out_tl + @param out_tr out_tr + @param out_br out_br + */ + obbApplyAffineTransform(rect: Rect, anAffineTransform: AffineTransform, out_bl: Vec2, out_tl: Vec2, out_tr: Vec2, out_br: Vec2): void; + /** + !#en Create a new affine transformation with a base transformation matrix and a translation based on it. + !#zh 基于一个基础矩阵加上一个平移操作来创建一个新的矩阵。 + @param t The base affine transform object. + @param tx The translation on x axis. + @param ty The translation on y axis. + */ + affineTransformTranslate(t: AffineTransform, tx: number, ty: number): AffineTransform; + /** + !#en Create a new affine transformation with a base transformation matrix and a scale based on it. + !#zh 创建一个基础变换矩阵,并在此基础上进行了 Scale 仿射变换。 + @param t The base affine transform object. + @param sx The scale on x axis. + @param sy The scale on y axis. + */ + affineTransformScale(t: AffineTransform, sx: number, sy: number): AffineTransform; + /** + !#en Create a new affine transformation with a base transformation matrix and a rotation based on it. + !#zh 创建一个基础变换矩阵,并在此基础上进行了 Rotation 仿射变换。 + @param aTransform The base affine transform object. + @param anAngle The angle to rotate. + */ + affineTransformRotate(aTransform: AffineTransform, anAngle: number): AffineTransform; + /** + !#en + Concatenate a transform matrix to another and return the result:
+ t' = t1 * t2 + !#zh 拼接两个矩阵,并返回结果:
+ t' = t1 * t2 + @param t1 The first transform object. + @param t2 The transform object to concatenate. + */ + affineTransformConcat(t1: AffineTransform, t2: AffineTransform): AffineTransform; + /** + !#en + Concatenate a transform matrix to another
+ The results are reflected in the first matrix.
+ t' = t1 * t2 + !#zh + 拼接两个矩阵,将结果保存到第一个矩阵。
+ t' = t1 * t2 + @param t1 The first transform object. + @param t2 The transform object to concatenate. + */ + affineTransformConcatIn(t1: AffineTransform, t2: AffineTransform): AffineTransform; + /** + !#en Return true if an affine transform equals to another, false otherwise. + !#zh 判断两个矩阵是否相等。 + @param t1 t1 + @param t2 t2 + */ + affineTransformEqualToTransform(t1: AffineTransform, t2: AffineTransform): boolean; + /** + !#en Get the invert transform of an AffineTransform object. + !#zh 求逆矩阵。 + @param t t + */ + affineTransformInvert(t: AffineTransform): AffineTransform; + /** + !#en Put the invert transform of an AffineTransform object into the out AffineTransform object. + !#zh 求逆矩阵并存入用户传入的矩阵对象参数。 + @param t t + @param out out + */ + affineTransformInvert(t: AffineTransform, out: AffineTransform): void; + } + /** !#en + Representation of RGBA colors. + + Each color component is a floating point value with a range from 0 to 255. + + You can also use the convenience method {{#crossLink "cc/color:method"}}cc.color{{/crossLink}} to create a new Color. + + !#zh + cc.Color 用于表示颜色。 + + 它包含 RGBA 四个以浮点数保存的颜色分量,每个的值都在 0 到 255 之间。 + + 您也可以通过使用 {{#crossLink "cc/color:method"}}cc.color{{/crossLink}} 的便捷方法来创建一个新的 Color。 */ + export class Color extends ValueType { + /** + + @param r red component of the color, default value is 0. + @param g green component of the color, defualt value is 0. + @param b blue component of the color, default value is 0. + @param a alpha component of the color, default value is 255. + */ + constructor(r?: number, g?: number, b?: number, a?: number); + /** !#en Solid white, RGBA is [255, 255, 255, 255]. + !#zh 纯白色,RGBA 是 [255, 255, 255, 255]。 */ + static WHITE: Color; + /** !#en Solid black, RGBA is [0, 0, 0, 255]. + !#zh 纯黑色,RGBA 是 [0, 0, 0, 255]。 */ + static BLACK: Color; + /** !#en Transparent, RGBA is [0, 0, 0, 0]. + !#zh 透明,RGBA 是 [0, 0, 0, 0]。 */ + static TRANSPARENT: Color; + /** !#en Grey, RGBA is [127.5, 127.5, 127.5]. + !#zh 灰色,RGBA 是 [127.5, 127.5, 127.5]。 */ + static GRAY: Color; + /** !#en Solid red, RGBA is [255, 0, 0]. + !#zh 纯红色,RGBA 是 [255, 0, 0]。 */ + static RED: Color; + /** !#en Solid green, RGBA is [0, 255, 0]. + !#zh 纯绿色,RGBA 是 [0, 255, 0]。 */ + static GREEN: Color; + /** !#en Solid blue, RGBA is [0, 0, 255]. + !#zh 纯蓝色,RGBA 是 [0, 0, 255]。 */ + static BLUE: Color; + /** !#en Yellow, RGBA is [255, 235, 4]. + !#zh 黄色,RGBA 是 [255, 235, 4]。 */ + static YELLOW: Color; + /** !#en Orange, RGBA is [255, 127, 0]. + !#zh 橙色,RGBA 是 [255, 127, 0]。 */ + static ORANGE: Color; + /** !#en Cyan, RGBA is [0, 255, 255]. + !#zh 青色,RGBA 是 [0, 255, 255]。 */ + static CYAN: Color; + /** !#en Magenta, RGBA is [255, 0, 255]. + !#zh 洋红色(品红色),RGBA 是 [255, 0, 255]。 */ + static MAGENTA: Color; + /** + !#en Clone a new color from the current color. + !#zh 克隆当前颜色。 + + @example + ```js + var color = new cc.Color(); + var newColor = color.clone();// Color {r: 0, g: 0, b: 0, a: 255} + ``` + */ + clone(): Color; + /** + !#en TODO + !#zh 判断两个颜色是否相等。 + @param other other + + @example + ```js + var color1 = cc.Color.WHITE; + var color2 = new cc.Color(255, 255, 255); + cc.log(color1.equals(color2)); // true; + color2 = cc.Color.RED; + cc.log(color2.equals(color1)); // false; + ``` + */ + equals(other: Color): boolean; + /** + !#en TODO + !#zh 线性插值 + @param to to + @param ratio the interpolation coefficient. + @param out optional, the receiving vector. + + @example + ```js + // Converts a white color to a black one trough time. + update: function (dt) { + var color = this.node.color; + if (color.equals(cc.Color.BLACK)) { + return; + } + this.ratio += dt * 0.1; + this.node.color = cc.Color.WHITE.lerp(cc.Color.BLACK, ratio); + } + + ``` + */ + lerp(to: Color, ratio: number, out?: Color): Color; + /** + !#en TODO + !#zh 转换为方便阅读的字符串。 + + @example + ```js + var color = cc.Color.WHITE; + color.toString(); // "rgba(255, 255, 255, 255)" + ``` + */ + toString(): string; + /** + !#en Gets red channel value + !#zh 获取当前颜色的红色值。 + */ + getR(): number; + /** + !#en Sets red value and return the current color object + !#zh 设置当前的红色值,并返回当前对象。 + @param red the new Red component. + + @example + ```js + var color = new cc.Color(); + color.setR(255); // Color {r: 255, g: 0, b: 0, a: 255} + ``` + */ + setR(red: number): Color; + /** + !#en Gets green channel value + !#zh 获取当前颜色的绿色值。 + */ + getG(): number; + /** + !#en Sets green value and return the current color object + !#zh 设置当前的绿色值,并返回当前对象。 + @param green the new Green component. + + @example + ```js + var color = new cc.Color(); + color.setG(255); // Color {r: 0, g: 255, b: 0, a: 255} + ``` + */ + setG(green: number): Color; + /** + !#en Gets blue channel value + !#zh 获取当前颜色的蓝色值。 + */ + getB(): number; + /** + !#en Sets blue value and return the current color object + !#zh 设置当前的蓝色值,并返回当前对象。 + @param blue the new Blue component. + + @example + ```js + var color = new cc.Color(); + color.setB(255); // Color {r: 0, g: 0, b: 255, a: 255} + ``` + */ + setB(blue: number): Color; + /** + !#en Gets alpha channel value + !#zh 获取当前颜色的透明度值。 + */ + getA(): number; + /** + !#en Sets alpha value and return the current color object + !#zh 设置当前的透明度,并返回当前对象。 + @param alpha the new Alpha component. + + @example + ```js + var color = new cc.Color(); + color.setA(0); // Color {r: 0, g: 0, b: 0, a: 0} + ``` + */ + setA(alpha: number): Color; + /** + !#en Convert color to css format. + !#zh 转换为 CSS 格式。 + @param opt "rgba", "rgb", "#rgb" or "#rrggbb". + + @example + ```js + var color = cc.Color.BLACK; + color.toCSS(); // "#000"; + color.toCSS("rgba"); // "rgba(0,0,0,1.00)"; + color.toCSS("rgb"); // "rgba(0,0,0)"; + color.toCSS("#rgb"); // "#000"; + color.toCSS("#rrggbb"); // "#000000"; + ``` + */ + toCSS(opt: string): string; + /** + !#en Clamp this color to make all components between 0 to 255。 + !#zh 限制颜色数值,在 0 到 255 之间。 + + @example + ```js + var color = new cc.Color(1000, 0, 0, 255); + color.clamp(); + cc.log(color); // (255, 0, 0, 255) + ``` + */ + clamp(): void; + /** + !#en Read hex string and store color data into the current color object, the hex string must be formated as rgba or rgb. + !#zh 读取 16 进制颜色。 + @param hexString hexString + + @example + ```js + var color = cc.Color.BLACK; + color.fromHEX("#FFFF33"); // Color {r: 255, g: 255, b: 51, a: 255}; + ``` + */ + fromHEX(hexString: string): Color; + /** + !#en TODO + !#zh 转换为 16 进制。 + @param fmt "#rgb" or "#rrggbb". + + @example + ```js + var color = cc.Color.BLACK; + color.toHEX("#rgb"); // "000"; + color.toHEX("#rrggbb"); // "000000"; + ``` + */ + toHEX(fmt: string): string; + /** + !#en Convert to 24bit rgb value. + !#zh 转换为 24bit 的 RGB 值。 + + @example + ```js + var color = cc.Color.YELLOW; + color.toRGBValue(); // 16771844; + ``` + */ + toRGBValue(): number; + /** + !#en TODO + !#zh 读取 HSV(色彩模型)格式。 + @param h h + @param s s + @param v v + + @example + ```js + var color = cc.Color.YELLOW; + color.fromHSV(0, 0, 1); // Color {r: 255, g: 255, b: 255, a: 255}; + ``` + */ + fromHSV(h: number, s: number, v: number): Color; + /** + !#en TODO + !#zh 转换为 HSV(色彩模型)格式。 + + @example + ```js + var color = cc.Color.YELLOW; + color.toHSV(); // Object {h: 0.1533864541832669, s: 0.9843137254901961, v: 1}; + ``` + */ + toHSV(): any; + /** + !#en TODO + !#zh RGB 转换为 HSV。 + @param r red, must be [0, 255]. + @param g red, must be [0, 255]. + @param b red, must be [0, 255]. + + @example + ```js + cc.Color.rgb2hsv(255, 255, 255); // Object {h: 0, s: 0, v: 1}; + ``` + */ + static rgb2hsv(r: number, g: number, b: number): any; + /** + !#en TODO + !#zh HSV 转换为 RGB。 + @param h h + @param s s + @param v v + + @example + ```js + cc.Color.hsv2rgb(0, 0, 1); // Object {r: 255, g: 255, b: 255}; + ``` + */ + static hsv2rgb(h: number, s: number, v: number): any; + } + /** !#en A 2D rectangle defined by x, y position and width, height. + !#zh 通过位置和宽高定义的 2D 矩形。 */ + export class Rect extends ValueType { + /** + !#en + Constructor of cc.Rect class. + see {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} for convenience method. + !#zh + cc.Rect类的构造函数。可以通过 {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} 简便方法进行创建。 + @param x x + @param y y + @param w w + @param h h + */ + constructor(x?: number, y?: number, w?: number, h?: number); + x: number; + y: number; + width: number; + height: number; + /** + !#en Creates a rectangle from two coordinate values. + !#zh 根据指定 2 个坐标创建出一个矩形区域。 + @param v1 v1 + @param v2 v2 + + @example + ```js + cc.Rect.fromMinMax(cc.v2(10, 10), cc.v2(20, 20)); // Rect {x: 10, y: 10, width: 10, height: 10}; + ``` + */ + static fromMinMax(v1: Vec2, v2: Vec2): Rect; + /** + !#en Checks if rect contains. + !#zh + 判断 2 个矩形是否有包含。
+ 返回 1 为 a 包含 b,如果 -1 为 b 包含 a, + 0 这则都不包含。 + @param a Rect a + @param b Rect b + + @example + ```js + var a = new cc.Rect(0, 0, 10, 10); + var b = new cc.Rect(5, 5, 5, 5); + var c = new cc.Rect(20, 20, 10, 10); + cc.Rect.contain(a, b); // 1; + cc.Rect.contain(b, a); // -1; + cc.Rect.contain(a, c); // 0; + ``` + */ + static contain(a: Rect, b: Rect): number; + /** + !#en TODO + !#zh 克隆一个新的 Rect。 + + @example + ```js + var a = new cc.Rect(0, 0, 10, 10); + a.clone();// Rect {x: 0, y: 0, width: 10, height: 10} + ``` + */ + clone(): Rect; + /** + !#en TODO + !#zh 是否等于指定的矩形。 + @param other other + + @example + ```js + var a = new cc.Rect(0, 0, 10, 10); + var b = new cc.Rect(0, 0, 10, 10); + a.equals(b);// true; + ``` + */ + equals(other: Rect): boolean; + /** + !#en TODO + !#zh 线性插值 + @param to to + @param ratio the interpolation coefficient. + @param out optional, the receiving vector. + + @example + ```js + var a = new cc.Rect(0, 0, 10, 10); + var b = new cc.Rect(50, 50, 100, 100); + update (dt) { + // method 1; + var c = a.lerp(b, dt * 0.1); + // method 2; + a.lerp(b, dt * 0.1, c); + } + ``` + */ + lerp(to: Rect, ratio: number, out?: Rect): Rect; + /** + !#en TODO + !#zh 转换为方便阅读的字符串 + + @example + ```js + var a = new cc.Rect(0, 0, 10, 10); + a.toString();// "(0.00, 0.00, 10.00, 10.00)"; + ``` + */ + toString(): string; + /** !#en TODO + !#zh 矩形 x 轴上的最小值。 */ + xMin: number; + /** !#en TODO + !#zh 矩形 y 轴上的最小值。 */ + yMin: number; + /** !#en TODO + !#zh 矩形 x 轴上的最大值。 */ + xMax: number; + /** !#en TODO + !#zh 矩形 y 轴上的最大值。 */ + yMax: number; + /** !#en The position of the center of the rectangle. + !#zh 矩形的中心点。 */ + center: Vec2; + /** !#en The X and Y position of the rectangle. + !#zh 矩形的 x 和 y 坐标。 */ + origin: Vec2; + /** !#en Width and height of the rectangle. + !#zh 矩形的大小。 */ + size: Size; + /** + !#en TODO + !#zh 当前矩形与指定矩形是否相交。 + @param rect rect + + @example + ```js + var a = new cc.Rect(0, 0, 10, 10); + var b = new cc.Rect(0, 0, 20, 20); + a.intersects(b);// true + ``` + */ + intersects(rect: Rect): void; + /** + !#en TODO + !#zh 当前矩形是否包含指定坐标点。 + Returns true if the point inside this rectangle. + @param point point + + @example + ```js + var a = new cc.Rect(0, 0, 10, 10); + var b = new cc.Vec2(0, 5); + a.contains(b);// true + ``` + */ + contains(point: Vec2): void; + /** + !#en Returns true if the other rect totally inside this rectangle. + !#zh 当前矩形是否包含指定矩形。 + @param rect rect + + @example + ```js + var a = new cc.Rect(0, 0, 20, 20); + var b = new cc.Rect(0, 0, 10, 10); + a.containsRect(b);// true + ``` + */ + containsRect(rect: Rect): void; + } + /** !#en + cc.Size is the class for size object,
+ please do not use its constructor to create sizes,
+ use {{#crossLink "cc/size:method"}}{{/crossLink}} alias function instead.
+ It will be deprecated soon, please use cc.Vec2 instead. + + !#zh + cc.Size 是 size 对象的类。
+ 请不要使用它的构造函数创建的 size,
+ 使用 {{#crossLink "cc/size:method"}}{{/crossLink}} 别名函数。
+ 它不久将被取消,请使用cc.Vec2代替。 */ + export class Size { + /** + + @param width width + @param height height + */ + constructor(width: number|Size, height?: number); + width: number; + height: number; + /** !#en return a Size object with width = 0 and height = 0. + !#zh 返回一个宽度为 0 和高度为 0 的 Size 对象。 */ + static ZERO: Size; + /** + !#en TODO + !#zh 克隆 size 对象。 + + @example + ```js + var a = new cc.size(10, 10); + a.clone();// return Size {width: 0, height: 0}; + ``` + */ + clone(): Size; + /** + !#en TODO + !#zh 当前 Size 对象是否等于指定 Size 对象。 + @param other other + + @example + ```js + var a = new cc.size(10, 10); + a.equals(new cc.size(10, 10));// return true; + ``` + */ + equals(other: Size): boolean; + /** + !#en TODO + !#zh 线性插值。 + @param to to + @param ratio the interpolation coefficient. + @param out optional, the receiving vector. + + @example + ```js + var a = new cc.size(10, 10); + var b = new cc.rect(50, 50, 100, 100); + update (dt) { + // method 1; + var c = a.lerp(b, dt * 0.1); + // method 2; + a.lerp(b, dt * 0.1, c); + } + ``` + */ + lerp(to: Rect, ratio: number, out?: Size): Size; + /** + !#en TODO + !#zh 转换为方便阅读的字符串。 + + @example + ```js + var a = new cc.size(10, 10); + a.toString();// return "(10.00, 10.00)"; + ``` + */ + toString(): string; + } + /** !#en the device accelerometer reports values for each axis in units of g-force. + !#zh 设备重力传感器传递的各个轴的数据。 */ + export class Acceleration { + /** + + @param x x + @param y y + @param z z + @param timestamp timestamp + */ + constructor(x: number, y: number, z: number, timestamp: number); + } + /** !#en Blend Function used for textures. + !#zh 图像的混合方式。 */ + export class BlendFunc { + /** + + @param src1 source blend function + @param dst1 destination blend function + */ + constructor(src1: number, dst1: number); + } + /** !#en + Enum for blend factor + Refer to: http://www.andersriggelsen.dk/glblendfunc.php + !#zh + 混合因子 + 可参考: http://www.andersriggelsen.dk/glblendfunc.php */ + export enum BlendFactor { + ONE = 0, + ZERO = 0, + SRC_ALPHA = 0, + SRC_COLOR = 0, + DST_ALPHA = 0, + DST_COLOR = 0, + ONE_MINUS_SRC_ALPHA = 0, + ONE_MINUS_SRC_COLOR = 0, + ONE_MINUS_DST_ALPHA = 0, + ONE_MINUS_DST_COLOR = 0, + blendFuncDisable = 0, + } + /** undefined */ + export enum TextAlignment { + LEFT = 0, + CENTER = 0, + RIGHT = 0, + } + /** undefined */ + export class WebGLColor { + /** + + @param r r + @param g g + @param b b + @param a a + @param arrayBuffer arrayBuffer + @param offset offset + */ + constructor(r: number, g: number, b: number, a: number, arrayBuffer: any[], offset: number); + BYTES_PER_ELEMENT: number; + } + /** undefined */ + export class Vertex2F { + /** + + @param x x + @param y y + @param arrayBuffer arrayBuffer + @param offset offset + */ + constructor(x: number, y: number, arrayBuffer: any[], offset: number); + BYTES_PER_ELEMENT: number; + } + /** undefined */ + export class Vertex3F { + /** + + @param x x + @param y y + @param z z + @param arrayBuffer arrayBuffer + @param offset offset + */ + constructor(x: number, y: number, z: number, arrayBuffer: any[], offset: number); + BYTES_PER_ELEMENT: number; + } + /** undefined */ + export class Tex2F { + /** + + @param u u + @param v v + @param arrayBuffer arrayBuffer + @param offset offset + */ + constructor(u: number, v: number, arrayBuffer: any[], offset: number); + BYTES_PER_ELEMENT: number; + } + /** undefined */ + export class Quad2 { + /** + + @param tl tl + @param tr tr + @param bl bl + @param br br + @param arrayBuffer arrayBuffer + @param offset offset + */ + constructor(tl: Vertex2F, tr: Vertex2F, bl: Vertex2F, br: Vertex2F, arrayBuffer: any[], offset: number); + BYTES_PER_ELEMENT: number; + } + /** A 3D Quad. 4 * 3 floats */ + export class Quad3 { + /** + + @param bl1 bl1 + @param br1 br1 + @param tl1 tl1 + @param tr1 tr1 + @param arrayBuffer arrayBuffer + @param offset offset + */ + constructor(bl1: Vertex3F, br1: Vertex3F, tl1: Vertex3F, tr1: Vertex3F, arrayBuffer: any[], offset: number); + } + /** undefined */ + export class V3F_C4B_T2F { + /** + + @param vertices vertices + @param colors colors + @param texCoords texCoords + @param arrayBuffer arrayBuffer + @param offset offset + */ + constructor(vertices: Vertex3F, colors: Color, texCoords: Tex2F, arrayBuffer: any[], offset: number); + BYTES_PER_ELEMENT(): void; + } + /** undefined */ + export class V3F_C4B_T2F_Quad { + /** + + @param tl tl + @param bl bl + @param tr tr + @param br br + @param arrayBuffer arrayBuffer + @param offset offset + */ + constructor(tl: V3F_C4B_T2F, bl: V3F_C4B_T2F, tr: V3F_C4B_T2F, br: V3F_C4B_T2F, arrayBuffer: any[], offset: number); + BYTES_PER_ELEMENT: number; + } + /** undefined */ + export class V2F_C4B_T2F { + /** + + @param vertices vertices + @param colors colors + @param texCoords texCoords + @param arrayBuffer arrayBuffer + @param offset offset + */ + constructor(vertices: Vertex2F, colors: Color, texCoords: Tex2F, arrayBuffer: any[], offset: number); + BYTES_PER_ELEMENT: number; + } + /** undefined */ + export class V2F_C4B_T2F_Triangle { + /** + + @param a a + @param b b + @param c c + @param arrayBuffer arrayBuffer + @param offset offset + */ + constructor(a: V2F_C4B_T2F, b: V2F_C4B_T2F, c: V2F_C4B_T2F, arrayBuffer: any[], offset: number); + } + /** !#en The base class of all value types. + !#zh 所有值类型的基类。 */ + export class ValueType { + /** + !#en This method returns an exact copy of current value. + !#zh 克隆当前值,该方法返回一个新对象,新对象的值和原对象相等。 + */ + clone(): ValueType; + /** + !#en Compares this object with the other one. + !#zh 当前对象是否等于指定对象。 + @param other other + */ + equals(other: ValueType): boolean; + /** + !#en + Linearly interpolates between this value to to value by ratio which is in the range [0, 1]. + When ratio = 0 returns this. When ratio = 1 return to. When ratio = 0.5 returns the average of this and to. + !#zh + 线性插值。
+ 当 ratio = 0 时返回自身,ratio = 1 时返回目标,ratio = 0.5 返回自身和目标的平均值。。 + @param to the to value + @param ratio the interpolation coefficient + */ + lerp(to: ValueType, ratio: number): ValueType; + /** + !#en TODO + !#zh 转换为方便阅读的字符串。 + */ + toString(): string; + } + /** !#en Representation of 2D vectors and points. + !#zh 表示 2D 向量和坐标 */ + export class Vec2 extends ValueType { + /** + !#en + Constructor + see {{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} or {{#crossLink "cc/p:method"}}cc.p{{/crossLink}} + !#zh + 构造函数,可查看 {{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} 或者 {{#crossLink "cc/p:method"}}cc.p{{/crossLink}} + @param x x + @param y y + */ + constructor(x?: number, y?: number); + x: number; + y: number; + /** + !#en clone a Vec2 value + !#zh 克隆一个 Vec2 值 + */ + clone(): Vec2; + /** + !#en TODO + !#zh 设置向量值。 + @param newValue !#en new value to set. !#zh 要设置的新值 + */ + set(newValue: Vec2): Vec2; + /** + !#en TODO + !#zh 当前的向量是否与指定的向量相等。 + @param other other + */ + equals(other: Vec2): boolean; + /** + !#en TODO + !#zh 转换为方便阅读的字符串。 + */ + toString(): string; + /** + !#en TODO + !#zh 线性插值。 + @param to to + @param ratio the interpolation coefficient + @param out optional, the receiving vector + */ + lerp(to: Vec2, ratio: number, out?: Vec2): Vec2; + /** + !#en Adds this vector. If you want to save result to another vector, use add() instead. + !#zh 向量加法。如果你想保存结果到另一个向量,使用 add() 代替。 + @param vector vector + + @example + ```js + var v = cc.v2(10, 10); + v.addSelf(cc.v2(5, 5));// return Vec2 {x: 15, y: 15}; + ``` + */ + addSelf(vector: Vec2): Vec2; + /** + !#en Adds two vectors, and returns the new result. + !#zh 向量加法,并返回新结果。 + @param vector vector + @param out optional, the receiving vector + + @example + ```js + var v = cc.v2(10, 10); + v.add(cc.v2(5, 5)); // return Vec2 {x: 15, y: 15}; + var v1; + v.add(cc.v2(5, 5), v1); // return Vec2 {x: 15, y: 15}; + ``` + */ + add(vector: Vec2, out?: Vec2): Vec2; + /** + !#en Subtracts one vector from this. If you want to save result to another vector, use sub() instead. + !#zh 向量减法。如果你想保存结果到另一个向量,可使用 sub() 代替。 + @param vector vector + + @example + ```js + var v = cc.v2(10, 10); + v.subSelf(cc.v2(5, 5));// return Vec2 {x: 5, y: 5}; + ``` + */ + subSelf(vector: Vec2): Vec2; + /** + !#en Subtracts one vector from this, and returns the new result. + !#zh 向量减法,并返回新结果。 + @param vector vector + @param out optional, the receiving vector + + @example + ```js + var v = cc.v2(10, 10); + v.sub(cc.v2(5, 5)); // return Vec2 {x: 5, y: 5}; + var v1; + v.sub(cc.v2(5, 5), v1); // return Vec2 {x: 5, y: 5}; + ``` + */ + sub(vector: Vec2, out?: Vec2): Vec2; + /** + !#en Multiplies this by a number. If you want to save result to another vector, use mul() instead. + !#zh 缩放当前向量。如果你想结果保存到另一个向量,可使用 mul() 代替。 + @param num num + + @example + ```js + var v = cc.v2(10, 10); + v.mulSelf(5);// return Vec2 {x: 50, y: 50}; + ``` + */ + mulSelf(num: number): Vec2; + /** + !#en Multiplies by a number, and returns the new result. + !#zh 缩放向量,并返回新结果。 + @param num num + @param out optional, the receiving vector + + @example + ```js + var v = cc.v2(10, 10); + v.mul(5); // return Vec2 {x: 50, y: 50}; + var v1; + v.mul(5, v1); // return Vec2 {x: 50, y: 50}; + ``` + */ + mul(num: number, out?: Vec2): Vec2; + /** + !#en Multiplies two vectors. + !#zh 分量相乘。 + @param vector vector + + @example + ```js + var v = cc.v2(10, 10); + v.scaleSelf(cc.v2(5, 5));// return Vec2 {x: 50, y: 50}; + ``` + */ + scaleSelf(vector: Vec2): Vec2; + /** + !#en Multiplies two vectors, and returns the new result. + !#zh 分量相乘,并返回新的结果。 + @param vector vector + @param out optional, the receiving vector + + @example + ```js + var v = cc.v2(10, 10); + v.scale(cc.v2(5, 5)); // return Vec2 {x: 50, y: 50}; + var v1; + v.scale(cc.v2(5, 5), v1); // return Vec2 {x: 50, y: 50}; + ``` + */ + scale(vector: Vec2, out?: Vec2): Vec2; + /** + !#en Divides by a number. If you want to save result to another vector, use div() instead. + !#zh 向量除法。如果你想结果保存到另一个向量,可使用 div() 代替。 + @param vector vector + + @example + ```js + var v = cc.v2(10, 10); + v.divSelf(5); // return Vec2 {x: 2, y: 2}; + ``` + */ + divSelf(vector: Vec2): Vec2; + /** + !#en Divides by a number, and returns the new result. + !#zh 向量除法,并返回新的结果。 + @param vector vector + @param out optional, the receiving vector + + @example + ```js + var v = cc.v2(10, 10); + v.div(5); // return Vec2 {x: 2, y: 2}; + var v1; + v.div(5, v1); // return Vec2 {x: 2, y: 2}; + ``` + */ + div(vector: Vec2, out?: Vec2): Vec2; + /** + !#en Negates the components. If you want to save result to another vector, use neg() instead. + !#zh 向量取反。如果你想结果保存到另一个向量,可使用 neg() 代替。 + + @example + ```js + var v = cc.v2(10, 10); + v.negSelf(); // return Vec2 {x: -10, y: -10}; + ``` + */ + negSelf(): Vec2; + /** + !#en Negates the components, and returns the new result. + !#zh 返回取反后的新向量。 + @param out optional, the receiving vector + + @example + ```js + var v = cc.v2(10, 10); + var v1; + v.neg(v1); // return Vec2 {x: -10, y: -10}; + ``` + */ + neg(out?: Vec2): Vec2; + /** + !#en Dot product + !#zh 当前向量与指定向量进行点乘。 + @param vector vector + + @example + ```js + var v = cc.v2(10, 10); + v.dot(cc.v2(5, 5)); // return 100; + ``` + */ + dot(vector?: Vec2): number; + /** + !#en Cross product + !#zh 当前向量与指定向量进行叉乘。 + @param vector vector + + @example + ```js + var v = cc.v2(10, 10); + v.cross(cc.v2(5, 5)); // return 0; + ``` + */ + cross(vector?: Vec2): number; + /** + !#en Returns the length of this vector. + !#zh 返回该向量的长度。 + + @example + ```js + var v = cc.v2(10, 10); + v.mag(); // return 14.142135623730951; + ``` + */ + mag(): number; + /** + !#en Returns the squared length of this vector. + !#zh 返回该向量的长度平方。 + + @example + ```js + var v = cc.v2(10, 10); + v.magSqr(); // return 200; + ``` + */ + magSqr(): number; + /** + !#en Make the length of this vector to 1. + !#zh 向量归一化,让这个向量的长度为 1。 + + @example + ```js + var v = cc.v2(10, 10); + v.normalizeSelf(); // return Vec2 {x: 0.7071067811865475, y: 0.7071067811865475}; + ``` + */ + normalizeSelf(): Vec2; + /** + !#en + Returns this vector with a magnitude of 1.
+
+ Note that the current vector is unchanged and a new normalized vector is returned. If you want to normalize the current vector, use normalizeSelf function. + !#zh + 返回归一化后的向量。
+
+ 注意,当前向量不变,并返回一个新的归一化向量。如果你想来归一化当前向量,可使用 normalizeSelf 函数。 + @param out optional, the receiving vector + */ + normalize(out?: Vec2): Vec2; + /** + !#en Get angle in radian between this and vector. + !#zh 夹角的弧度。 + @param vector vector + */ + angle(vector: Vec2): number; + /** + !#en Get angle in radian between this and vector with direction. + !#zh 带方向的夹角的弧度。 + @param vector vector + */ + signAngle(vector: Vec2): number; + /** + !#en rotate + !#zh 返回旋转给定弧度后的新向量。 + @param radians radians + @param out optional, the receiving vector + */ + rotate(radians: number, out?: Vec2): Vec2; + /** + !#en rotate self + !#zh 按指定弧度旋转向量。 + @param radians radians + */ + rotateSelf(radians: number): Vec2; + /** !#en return a Vec2 object with x = 1 and y = 1. + !#zh 新 Vec2 对象。 */ + static ONE: Vec2; + /** !#en return a Vec2 object with x = 0 and y = 0. + !#zh 返回 x = 0 和 y = 0 的 Vec2 对象。 */ + static ZERO: Vec2; + /** !#en return a Vec2 object with x = 0 and y = 1. + !#zh 返回 x = 0 和 y = 1 的 Vec2 对象。 */ + static UP: Vec2; + /** !#en return a Vec2 object with x = 1 and y = 0. + !#zh 返回 x = 1 和 y = 0 的 Vec2 对象。 */ + static RIGHT: Vec2; + } + /** undefined */ + export class PhysicsBoxCollider extends PhysicsCollider implements Collider.Box { + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Box size + !#zh 包围盒大小 */ + size: Size; + } + /** undefined */ + export class PhysicsChainCollider extends PolygonCollider { + /** !#en Whether the chain is loop + !#zh 链条是否首尾相连 */ + loop: boolean; + /** !#en Chain points + !#zh 链条顶点数组 */ + points: [Vec2]; + } + /** undefined */ + export class PhysicsCircleCollider extends PhysicsCollider implements Collider.Circle { + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Circle radius + !#zh 圆形半径 */ + radius: number; + } + /** undefined */ + export class PhysicsCollider { + /** !#en + The density. + !#zh + 密度 */ + density: number; + /** !#en + A sensor collider collects contact information but never generates a collision response + !#zh + 一个传感器类型的碰撞体会产生碰撞回调,但是不会发生物理碰撞效果。 */ + sensor: boolean; + /** !#en + The friction coefficient, usually in the range [0,1]. + !#zh + 摩擦系数,取值一般在 [0, 1] 之间 */ + friction: number; + /** !#en + The restitution (elasticity) usually in the range [0,1]. + !#zh + 弹性系数,取值一般在 [0, 1]之间 */ + restitution: number; + /** !#en + Physics collider will find the rigidbody component on the node and set to this property. + !#zh + 碰撞体会在初始化时查找节点上是否存在刚体,如果查找成功则赋值到这个属性上。 */ + body: RigidBody; + /** + !#en + Apply current changes to collider, this will regenerate inner box2d fixtures. + !#zh + 应用当前 collider 中的修改,调用此函数会重新生成内部 box2d 的夹具。 + */ + apply(): void; + /** + !#en + Get the world aabb of the collider + !#zh + 获取碰撞体的世界坐标系下的包围盒 + */ + getAABB(): void; + } + /** undefined */ + export class PhysicsPolygonCollider extends PhysicsCollider implements Collider.Polygon { + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Polygon points + !#zh 多边形顶点数组 */ + points: [Vec2]; + } + /** !#en + A distance joint constrains two points on two bodies + to remain at a fixed distance from each other. You can view + this as a massless, rigid rod. + !#zh + 距离关节通过一个固定的长度来约束关节链接的两个刚体。你可以将它想象成一个无质量,坚固的木棍。 */ + export class DistanceJoint extends Joint { + /** !#en + The distance separating the two ends of the joint. + !#zh + 关节两端的距离 */ + distance: number; + /** !#en + The spring frequency. + !#zh + 弹性系数。 */ + frequency: number; + /** !#en + The damping ratio. + !#zh + 阻尼,表示关节变形后,恢复到初始状态受到的阻力。 */ + 0: number; + } + /** !#en + Base class for joints to connect rigidbody. + !#zh + 关节类的基类 */ + export class Joint extends Component { + /** !#en + The anchor of the rigidbody. + !#zh + 刚体的锚点。 */ + anchor: Vec2; + /** !#en + The anchor of the connected rigidbody. + !#zh + 关节另一端刚体的锚点。 */ + connectedAnchor: Vec2; + /** !#en + The rigidbody to which the other end of the joint is attached. + !#zh + 关节另一端链接的刚体 */ + connectedBody: RigidBody; + /** !#en + Should the two rigid bodies connected with this joint collide with each other? + !#zh + 链接到关节上的两个刚体是否应该相互碰撞? */ + collideConnected: boolean; + /** + !#en + Apply current changes to joint, this will regenerate inner box2d joint. + !#zh + 应用当前关节中的修改,调用此函数会重新生成内部 box2d 的关节。 + */ + apply(): void; + /** + !#en + Get the anchor point on rigidbody in world coordinates. + !#zh + 获取刚体世界坐标系下的锚点。 + */ + getWorldAnchor(): Vec2; + /** + !#en + Get the anchor point on connected rigidbody in world coordinates. + !#zh + 获取链接刚体世界坐标系下的锚点。 + */ + getWorldConnectedAnchor(): Vec2; + /** + !#en + Gets the reaction force of the joint. + !#zh + 获取关节的反作用力。 + @param timeStep The time to calculate the reaction force for. + */ + getReactionForce(timeStep: number): number; + /** + !#en + Gets the reaction torque of the joint. + !#zh + 获取关节的反扭矩。 + @param timeStep The time to calculate the reaction torque for. + */ + getReactionTorque(timeStep: number): number; + } + /** !#en + A motor joint is used to control the relative motion + between two bodies. A typical usage is to control the movement + of a dynamic body with respect to the ground. + !#zh + 马达关节被用来控制两个刚体间的相对运动。 + 一个典型的例子是用来控制一个动态刚体相对于地面的运动。 */ + export class MotorJoint extends Joint { + /** !#en + The anchor of the rigidbody. + !#zh + 刚体的锚点。 */ + anchor: Vec2; + /** !#en + The anchor of the connected rigidbody. + !#zh + 关节另一端刚体的锚点。 */ + connectedAnchor: Vec2; + /** !#en + The linear offset from connected rigidbody to rigidbody. + !#zh + 关节另一端的刚体相对于起始端刚体的位置偏移量 */ + linearOffset: Vec2; + /** !#en + The angular offset from connected rigidbody to rigidbody. + !#zh + 关节另一端的刚体相对于起始端刚体的角度偏移量 */ + angularOffset: number; + /** !#en + The maximum force can be applied to rigidbody. + !#zh + 可以应用于刚体的最大的力值 */ + maxForce: number; + /** !#en + The maximum torque can be applied to rigidbody. + !#zh + 可以应用于刚体的最大扭矩值 */ + maxTorque: number; + /** !#en + The position correction factor in the range [0,1]. + !#zh + 位置矫正系数,范围为 [0, 1] */ + correctionFactor: number; + } + /** !#en + A mouse joint is used to make a point on a body track a + specified world point. This a soft constraint with a maximum + force. This allows the constraint to stretch and without + applying huge forces. + Mouse Joint will auto register the touch event with the mouse region node, + and move the choosed rigidbody in touch move event. + Note : generally mouse joint only used in test bed. + !#zh + 鼠标关节用于使刚体上的一个点追踪一个指定的世界坐标系下的位置。 + 鼠标关节可以指定一个最大的里来施加一个柔和的约束。 + 鼠标关节会自动使用 mouse region 节点来注册鼠标事件,并且在触摸移动事件中移动选中的刚体。 + 注意:一般鼠标关节只在测试环境中使用。 */ + export class MouseJoint extends Joint { + /** !#en + The anchor of the rigidbody. + !#zh + 刚体的锚点。 */ + anchor: Vec2; + /** !#en + The anchor of the connected rigidbody. + !#zh + 关节另一端刚体的锚点。 */ + connectedAnchor: Vec2; + /** !#en + The node used to register touch evnet. + If this is null, it will be the joint's node. + !#zh + 用于注册触摸事件的节点。 + 如果没有设置这个值,那么将会使用关节的节点来注册事件。 */ + mouseRegion: Node; + /** !#en + The target point. + The mouse joint will move choosed rigidbody to target point. + !#zh + 目标点,鼠标关节将会移动选中的刚体到指定的目标点 */ + target: Vec2; + /** !#en + The spring frequency. + !#zh + 弹簧系数。 */ + frequency: number; + /** !#en + The damping ratio. + !#zh + 阻尼,表示关节变形后,恢复到初始状态受到的阻力。 */ + 0: number; + /** !#en + The maximum force + !#zh + 最大阻力值 */ + maxForce: number; + } + /** !#en + A prismatic joint. This joint provides one degree of freedom: translation + along an axis fixed in rigidbody. Relative rotation is prevented. You can + use a joint limit to restrict the range of motion and a joint motor to + drive the motion or to model joint friction. + !#zh + 移动关节指定了只能在一个方向上移动刚体。 + 你可以开启关节限制来设置刚体运行移动的间距,也可以开启马达来使用关节马达驱动刚体的运行。 */ + export class PrismaticJoint extends Joint { + /** !#en + The local joint axis relative to rigidbody. + !#zh + 指定刚体可以移动的方向。 */ + localAxisA: Vec2; + /** !#en + The reference angle. + !#zh + 相对角度 */ + referenceAngle: number; + /** !#en + Enable joint distance limit? + !#zh + 是否开启关节的距离限制? */ + enableLimit: boolean; + /** !#en + Enable joint motor? + !#zh + 是否开启关节马达? */ + enableMotor: boolean; + /** !#en + The lower joint limit. + !#zh + 刚体能够移动的最小值 */ + lowerLimit: number; + /** !#en + The upper joint limit. + !#zh + 刚体能够移动的最大值 */ + upperLimit: number; + /** !#en + The maxium force can be applied to rigidbody to rearch the target motor speed. + !#zh + 可以施加到刚体的最大力。 */ + maxMotorForce: number; + /** !#en + The expected motor speed. + !#zh + 期望的马达速度。 */ + motorSpeed: number; + } + /** !#en + A revolute joint constrains two bodies to share a common point while they + are free to rotate about the point. The relative rotation about the shared + point is the joint angle. You can limit the relative rotation with + a joint limit that specifies a lower and upper angle. You can use a motor + to drive the relative rotation about the shared point. A maximum motor torque + is provided so that infinite forces are not generated. + !#zh + 旋转关节可以约束两个刚体围绕一个点来进行旋转。 + 你可以通过开启关节限制来限制旋转的最大角度和最小角度。 + 你可以通过开启马达来施加一个扭矩力来驱动这两个刚体在这一点上的相对速度。 */ + export class RevoluteJoint extends Joint { + /** !#en + The reference angle. + An angle between bodies considered to be zero for the joint angle. + !#zh + 相对角度。 + 两个物体之间角度为零时可以看作相等于关节角度 */ + referenceAngle: number; + /** !#en + The lower angle. + !#zh + 角度的最低限制。 */ + lowerAngle: number; + /** !#en + The upper angle. + !#zh + 角度的最高限制。 */ + upperAngle: number; + /** !#en + The maxium torque can be applied to rigidbody to rearch the target motor speed. + !#zh + 可以施加到刚体的最大扭矩。 */ + maxMotorTorque: number; + /** !#en + The expected motor speed. + !#zh + 期望的马达速度。 */ + motorSpeed: number; + /** !#en + Enable joint limit? + !#zh + 是否开启关节的限制? */ + enableLimit: boolean; + /** !#en + Enable joint motor? + !#zh + 是否开启关节马达? */ + enableMotor: boolean; + /** + !#en + Get the joint angle. + !#zh + 获取关节角度。 + */ + getJointAngle(): number; + } + /** !#en + A rope joint enforces a maximum distance between two points + on two bodies. It has no other effect. + Warning: if you attempt to change the maximum length during + the simulation you will get some non-physical behavior. + !#zh + 绳子关节只指定两个刚体间的最大距离,没有其他的效果。 + 注意:如果你试图动态修改关节的长度,这有可能会得到一些意外的效果。 */ + export class RopeJoint extends Joint { + /** !#en + The max length. + !#zh + 最大长度。 */ + maxLength: number; + } + /** !#en + A weld joint essentially glues two bodies together. A weld joint may + distort somewhat because the island constraint solver is approximate. + !#zh + 熔接关节相当于将两个刚体粘在了一起。 + 熔接关节可能会使某些东西失真,因为约束求解器算出的都是近似值。 */ + export class WeldJoint extends Joint { + /** !#en + The reference angle. + !#zh + 相对角度。 */ + referenceAngle: number; + /** !#en + The frequency. + !#zh + 弹性系数。 */ + frequency: number; + /** !#en + The damping ratio. + !#zh + 阻尼,表示关节变形后,恢复到初始状态受到的阻力。 */ + 0: number; + } + /** !#en + A wheel joint. This joint provides two degrees of freedom: translation + along an axis fixed in bodyA and rotation in the plane. You can use a joint motor to drive + the rotation or to model rotational friction. + This joint is designed for vehicle suspensions. + !#zh + 轮子关节提供两个维度的自由度:旋转和沿着指定方向上位置的移动。 + 你可以通过开启关节马达来使用马达驱动刚体的旋转。 + 轮组关节是专门为机动车类型设计的。 */ + export class WheelJoint extends Joint { + /** !#en + The local joint axis relative to rigidbody. + !#zh + 指定刚体可以移动的方向。 */ + localAxisA: Vec2; + /** !#en + The maxium torque can be applied to rigidbody to rearch the target motor speed. + !#zh + 可以施加到刚体的最大扭矩。 */ + maxMotorTorque: number; + /** !#en + The expected motor speed. + !#zh + 期望的马达速度。 */ + motorSpeed: number; + /** !#en + Enable joint motor? + !#zh + 是否开启关节马达? */ + enableMotor: boolean; + /** !#en + The spring frequency. + !#zh + 弹性系数。 */ + frequency: number; + /** !#en + The damping ratio. + !#zh + 阻尼,表示关节变形后,恢复到初始状态受到的阻力。 */ + dampingRatio: number; + } + /**************************************************** + * audioEngine + *****************************************************/ + + export module audioEngine { + /** !#en Audio state. + !#zh 声音播放状态 */ + export enum AudioState { + ERROR = 0, + INITIALZING = 0, + PLAYING = 0, + PAUSED = 0, + } + } + + /**************************************************** + * Node + *****************************************************/ + + export module Node { + /** !#en The event type supported by Node + !#zh Node 支持的事件类型 */ + export class EventType { + /** !#en The event type for touch start event, you can use its value directly: 'touchstart' + !#zh 当手指触摸到屏幕时。 */ + static TOUCH_START: string; + /** !#en The event type for touch move event, you can use its value directly: 'touchmove' + !#zh 当手指在屏幕上目标节点区域内移动时。 */ + static TOUCH_MOVE: string; + /** !#en The event type for touch end event, you can use its value directly: 'touchend' + !#zh 当手指在目标节点区域内离开屏幕时。 */ + static TOUCH_END: string; + /** !#en The event type for touch end event, you can use its value directly: 'touchcancel' + !#zh 当手指在目标节点区域外离开屏幕时。 */ + static TOUCH_CANCEL: string; + /** !#en The event type for mouse down events, you can use its value directly: 'mousedown' + !#zh 当鼠标按下时触发一次。 */ + static MOUSE_DOWN: string; + /** !#en The event type for mouse move events, you can use its value directly: 'mousemove' + !#zh 当鼠标在目标节点在目标节点区域中移动时,不论是否按下。 */ + static MOUSE_MOVE: string; + /** !#en The event type for mouse enter target events, you can use its value directly: 'mouseenter' + !#zh 当鼠标移入目标节点区域时,不论是否按下。 */ + static MOUSE_ENTER: string; + /** !#en The event type for mouse leave target events, you can use its value directly: 'mouseleave' + !#zh 当鼠标移出目标节点区域时,不论是否按下。 */ + static MOUSE_LEAVE: string; + /** !#en The event type for mouse up events, you can use its value directly: 'mouseup' + !#zh 当鼠标从按下状态松开时触发一次。 */ + static MOUSE_UP: string; + /** !#en The event type for mouse wheel events, you can use its value directly: 'mousewheel' + !#zh 当鼠标滚轮滚动时。 */ + static MOUSE_WHEEL: string; + } + } + + /**************************************************** + * ParticleSystem + *****************************************************/ + + export module ParticleSystem { + /** !#en Enum for emitter modes + !#zh 发射模式 */ + export enum EmitterMode { + GRAVITY = 0, + RADIUS = 0, + } + } + + /**************************************************** + * ParticleSystem + *****************************************************/ + + export module ParticleSystem { + /** !#en Enum for particles movement type. + !#zh 粒子位置类型 */ + export enum PositionType { + FREE = 0, + RELATIVE = 0, + GROUPED = 0, + } + } + + /**************************************************** + * TiledMap + *****************************************************/ + + export module TiledMap { + /** !#en The orientation of tiled map. + !#zh Tiled Map 地图方向。 */ + export enum Orientation { + ORTHO = 0, + HEX = 0, + ISO = 0, + NONE = 0, + MAP = 0, + LAYER = 0, + OBJECTGROUP = 0, + OBJECT = 0, + TILE = 0, + HORIZONTAL = 0, + VERTICAL = 0, + DIAGONAL = 0, + FLIPPED_ALL = 0, + FLIPPED_MASK = 0, + STAGGERAXIS_X = 0, + STAGGERAXIS_Y = 0, + STAGGERINDEX_ODD = 0, + STAGGERINDEX_EVEN = 0, + } + } + + /**************************************************** + * Collider + *****************************************************/ + + export module Collider { + /** !#en Defines a Box Collider . + !#zh 用来定义包围盒碰撞体 */ + export class Box { + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Box size + !#zh 包围盒大小 */ + size: Size; + } + } + + /**************************************************** + * Collider + *****************************************************/ + + export module Collider { + /** !#en Defines a Circle Collider . + !#zh 用来定义圆形碰撞体 */ + export class Circle { + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Circle radius + !#zh 圆形半径 */ + radius: number; + } + } + + /**************************************************** + * Collider + *****************************************************/ + + export module Collider { + /** !#en Defines a Polygon Collider . + !#zh 用来定义多边形碰撞体 */ + export class Polygon { + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Polygon points + !#zh 多边形顶点数组 */ + points: [Vec2]; + } + } + + /**************************************************** + * Button + *****************************************************/ + + export module Button { + /** !#en Enum for transition type. + !#zh 过渡类型 */ + export enum Transition { + NONE = 0, + COLOR = 0, + SPRITE = 0, + SCALE = 0, + } + } + + /**************************************************** + * Component + *****************************************************/ + + export module Component { + /** !#en + Component will register a event to target component's handler. + And it will trigger the handler when a certain event occurs. + + !@zh + “EventHandler” 类用来设置场景中的事件回调, + 该类允许用户设置回调目标节点,目标组件名,组件方法名, + 并可通过 emit 方法调用目标函数。 */ + export class EventHandler { + /** !#en Event target + !#zh 目标节点 */ + target: Node; + /** !#en Component name + !#zh 目标组件名 */ + component: string; + /** !#en Event handler + !#zh 响应事件函数名 */ + handler: string; + /** !#en Custom Event Data + !#zh 自定义事件数据 */ + customEventData: string; + /** + + @param events events + @param params params + */ + static emitEvents(events: Component.EventHandler[], ...params: any[]): void; + /** + !#en Emit event with params + !#zh 触发目标组件上的指定 handler 函数,该参数是回调函数的参数值(可不填)。 + @param params params + + @example + ```js + // Call Function + var eventHandler = new cc.Component.EventHandler(); + eventHandler.target = newTarget; + eventHandler.component = "MainMenu"; + eventHandler.handler = "OnClick" + eventHandler.emit(["param1", "param2", ....]); + ``` + */ + emit(params: any[]): void; + } + } + + /**************************************************** + * EditBox + *****************************************************/ + + export module EditBox { + /** !#en Enum for keyboard return types + !#zh 键盘的返回键类型 */ + export enum KeyboardReturnType { + DEFAULT = 0, + DONE = 0, + SEND = 0, + SEARCH = 0, + GO = 0, + } + } + + /**************************************************** + * EditBox + *****************************************************/ + + export module EditBox { + /** !#en The EditBox's InputMode defines the type of text that the user is allowed to enter. + !#zh 输入模式 */ + export enum InputMode { + ANY = 0, + EMAIL_ADDR = 0, + NUMERIC = 0, + PHONE_NUMBER = 0, + URL = 0, + DECIMAL = 0, + SINGLE_LINE = 0, + } + } + + /**************************************************** + * EditBox + *****************************************************/ + + export module EditBox { + /** !#en Enum for the EditBox's input flags + !#zh 定义了一些用于设置文本显示和文本格式化的标志位。 */ + export enum InputFlag { + PASSWORD = 0, + SENSITIVE = 0, + INITIAL_CAPS_WORD = 0, + INITIAL_CAPS_SENTENCE = 0, + INITIAL_CAPS_ALL_CHARACTERS = 0, + } + } + + /**************************************************** + * Label + *****************************************************/ + + export module Label { + /** !#en Enum for text alignment. + !#zh 文本横向对齐类型 */ + export enum HorizontalAlign { + LEFT = 0, + CENTER = 0, + RIGHT = 0, + } + } + + /**************************************************** + * Label + *****************************************************/ + + export module Label { + /** !#en Enum for vertical text alignment. + !#zh 文本垂直对齐类型 */ + export enum VerticalAlign { + TOP = 0, + CENTER = 0, + BOTTOM = 0, + } + } + + /**************************************************** + * Label + *****************************************************/ + + export module Label { + /** !#en Enum for Overflow. + !#zh Overflow 类型 */ + export enum Overflow { + NONE = 0, + CLAMP = 0, + SHRINK = 0, + RESIZE_HEIGHT = 0, + } + } + + /**************************************************** + * Label + *****************************************************/ + + export module Label { + /** !#en Enum for font type. + !#zh Type 类型 */ + export enum Type { + TTF = 0, + BMFont = 0, + SystemFont = 0, + } + } + + /**************************************************** + * Layout + *****************************************************/ + + export module Layout { + /** !#en Enum for Layout type + !#zh 布局类型 */ + export enum Type { + NONE = 0, + HORIZONTAL = 0, + VERTICAL = 0, + GRID = 0, + } + } + + /**************************************************** + * Layout + *****************************************************/ + + export module Layout { + /** !#en Enum for Layout Resize Mode + !#zh 缩放模式 */ + export enum ResizeMode { + NONE = 0, + CONTAINER = 0, + CHILDREN = 0, + } + } + + /**************************************************** + * Layout + *****************************************************/ + + export module Layout { + /** !#en Enum for Grid Layout start axis direction. + The items in grid layout will be arranged in each axis at first.; + !#zh 布局轴向,只用于 GRID 布局。 */ + export enum AxisDirection { + HORIZONTAL = 0, + VERTICAL = 0, + } + } + + /**************************************************** + * Layout + *****************************************************/ + + export module Layout { + /** !#en Enum for vertical layout direction. + Used in Grid Layout together with AxisDirection is VERTICAL + !#zh 垂直方向布局方式 */ + export enum VerticalDirection { + BOTTOM_TO_TOP = 0, + TOP_TO_BOTTOM = 0, + } + } + + /**************************************************** + * Layout + *****************************************************/ + + export module Layout { + /** !#en Enum for horizontal layout direction. + Used in Grid Layout together with AxisDirection is HORIZONTAL + !#zh 水平方向布局方式 */ + export enum HorizontalDirection { + LEFT_TO_RIGHT = 0, + RIGHT_TO_LEFT = 0, + } + } + + /**************************************************** + * Mask + *****************************************************/ + + export module Mask { + /** !#en the type for mask. + !#zh 遮罩组件类型 */ + export enum Type { + RECT = 0, + ELLIPSE = 0, + IMAGE_STENCIL = 0, + } + } + + /**************************************************** + * PageView + *****************************************************/ + + export module PageView { + /** !#en The Page View Size Mode + !#zh 页面视图每个页面统一的大小类型 */ + export enum SizeMode { + Unified = 0, + Free = 0, + } + } + + /**************************************************** + * PageView + *****************************************************/ + + export module PageView { + /** !#en The Page View Direction + !#zh 页面视图滚动类型 */ + export enum Direction { + Horizontal = 0, + Vertical = 0, + } + } + + /**************************************************** + * PageView + *****************************************************/ + + export module PageView { + /** !#en Enum for ScrollView event type. + !#zh 滚动视图事件类型 */ + export enum EventType { + PAGE_TURNING = 0, + } + } + + /**************************************************** + * PageViewIndicator + *****************************************************/ + + export module PageViewIndicator { + /** !#en Enum for PageView Indicator direction + !#zh 页面视图指示器的摆放方向 */ + export enum Direction { + HORIZONTAL = 0, + VERTICAL = 0, + } + } + + /**************************************************** + * ProgressBar + *****************************************************/ + + export module ProgressBar { + /** !#en Enum for ProgressBar mode + !#zh 进度条模式 */ + export enum Mode { + HORIZONTAL = 0, + VERTICAL = 0, + FILLED = 0, + } + } + + /**************************************************** + * Scrollbar + *****************************************************/ + + export module Scrollbar { + /** Enum for Scrollbar direction */ + export enum Direction { + HORIZONTAL = 0, + VERTICAL = 0, + } + } + + /**************************************************** + * ScrollView + *****************************************************/ + + export module ScrollView { + /** !#en Enum for ScrollView event type. + !#zh 滚动视图事件类型 */ + export enum EventType { + SCROLL_TO_TOP = 0, + SCROLL_TO_BOTTOM = 0, + SCROLL_TO_LEFT = 0, + SCROLL_TO_RIGHT = 0, + SCROLLING = 0, + BOUNCE_TOP = 0, + BOUNCE_BOTTOM = 0, + BOUNCE_LEFT = 0, + BOUNCE_RIGHT = 0, + SCROLL_ENDED = 0, + TOUCH_UP = 0, + AUTOSCROLL_ENDED_WITH_THRESHOLD = 0, + SCROLL_BEGAN = 0, + } + } + + /**************************************************** + * Slider + *****************************************************/ + + export module Slider { + /** !#en The Slider Direction + !#zh 滑动器方向 */ + export enum Direction { + Horizontal = 0, + Vertical = 0, + } + } + + /**************************************************** + * Sprite + *****************************************************/ + + export module Sprite { + /** !#en Enum for sprite type. + !#zh Sprite 类型 */ + export enum Type { + SIMPLE = 0, + SLICED = 0, + TILED = 0, + FILLED = 0, + } + } + + /**************************************************** + * Sprite + *****************************************************/ + + export module Sprite { + /** !#en Enum for fill type. + !#zh 填充类型 */ + export enum FillType { + HORIZONTAL = 0, + VERTICAL = 0, + RADIAL = 0, + } + } + + /**************************************************** + * Sprite + *****************************************************/ + + export module Sprite { + /** !#en Sprite Size can track trimmed size, raw size or none. + !#zh 精灵尺寸调整模式 */ + export enum SizeMode { + CUSTOM = 0, + TRIMMED = 0, + RAW = 0, + } + } + + /**************************************************** + * VideoPlayer + *****************************************************/ + + export module VideoPlayer { + /** !#en Video event type + !#zh 视频事件类型 */ + export enum EventType { + PLAYING = 0, + PAUSED = 0, + STOPPED = 0, + COMPLETED = 0, + META_LOADED = 0, + CLICKED = 0, + READY_TO_PLAY = 0, + } + } + + /**************************************************** + * VideoPlayer + *****************************************************/ + + export module VideoPlayer { + /** !#en Enum for video resouce type type. + !#zh 视频来源 */ + export enum ResourceType { + REMOTE = 0, + LOCAL = 0, + } + } + + /**************************************************** + * WebView + *****************************************************/ + + export module WebView { + /** !#en WebView event type + !#zh 网页视图事件类型 */ + export enum EventType { + LOADED = 0, + LOADING = 0, + ERROR = 0, + } + } + + /**************************************************** + * Event + *****************************************************/ + + export module Event { + /** !#en The Custom event + !#zh 自定义事件 */ + export class EventCustom extends Event { + /** + + @param type The name of the event (case-sensitive), e.g. "click", "fire", or "submit" + @param bubbles A boolean indicating whether the event bubbles up through the tree or not + */ + constructor(type: string, bubbles: boolean); + /** !#en A reference to the detailed data of the event + !#zh 事件的详细数据 */ + detail: any; + /** + !#en Sets user data + !#zh 设置用户数据 + @param data data + */ + setUserData(data: any): void; + /** + !#en Gets user data + !#zh 获取用户数据 + */ + getUserData(): any; + /** + !#en Gets event name + !#zh 获取事件名称 + */ + getEventName(): string; + /** !#en + The keyCode read-only property represents a system and implementation dependent numerical code identifying the unmodified value of the pressed key.
+ This is usually the decimal ASCII (RFC 20) or Windows 1252 code corresponding to the key.
+ If the key can't be identified, this value is 0.
+ + !#zh + keyCode 是只读属性它表示一个系统和依赖于实现的数字代码,可以识别按键的未修改值。
+ 这通常是十进制 ASCII (RFC20) 或者 Windows 1252 代码,所对应的密钥。
+ 如果无法识别该键,则该值为 0。 */ + keyCode: number; + } + } + + /**************************************************** + * SystemEvent + *****************************************************/ + + export module SystemEvent { + /** !#en The event type supported by SystemEvent + !#zh SystemEvent 支持的事件类型 */ + export class EventType { + /** !#en The event type for press the key down event, you can use its value directly: 'keydown' + !#zh 当按下按键时触发的事件 */ + static KEY_DOWN: string; + /** !#en The event type for press the key up event, you can use its value directly: 'keyup' + !#zh 当松开按键时触发的事件 */ + static KEY_UP: string; + /** !#en The event type for press the devicemotion event, you can use its value directly: 'devicemotion' + !#zh 重力感应 */ + static DEVICEMOTION: string; + } + } + + /**************************************************** + * Event + *****************************************************/ + + export module Event { + /** !#en The mouse event + !#zh 鼠标事件类型 */ + export class EventMouse extends Event { + /** + !#en Sets scroll data. + !#zh 设置鼠标的滚动数据。 + @param scrollX scrollX + @param scrollY scrollY + */ + setScrollData(scrollX: number, scrollY: number): void; + /** + !#en Returns the x axis scroll value. + !#zh 获取鼠标滚动的X轴距离,只有滚动时才有效。 + */ + getScrollX(): number; + /** + !#en Returns the y axis scroll value. + !#zh 获取滚轮滚动的 Y 轴距离,只有滚动时才有效。 + */ + getScrollY(): number; + /** + !#en Sets cursor location. + !#zh 设置当前鼠标位置。 + @param x x + @param y y + */ + setLocation(x: number, y: number): void; + /** + !#en Returns cursor location. + !#zh 获取鼠标位置对象,对象包含 x 和 y 属性。 + */ + getLocation(): Vec2; + /** + !#en Returns the current cursor location in screen coordinates. + !#zh 获取当前事件在游戏窗口内的坐标位置对象,对象包含 x 和 y 属性。 + */ + getLocationInView(): Vec2; + /** + !#en Returns the previous touch location. + !#zh 获取鼠标点击在上一次事件时的位置对象,对象包含 x 和 y 属性。 + */ + getPreviousLocation(): Vec2; + /** + !#en Returns the delta distance from the previous location to current location. + !#zh 获取鼠标距离上一次事件移动的距离对象,对象包含 x 和 y 属性。 + */ + getDelta(): Vec2; + /** + !#en Returns the X axis delta distance from the previous location to current location. + !#zh 获取鼠标距离上一次事件移动的 X 轴距离。 + */ + getDeltaX(): number; + /** + !#en Returns the Y axis delta distance from the previous location to current location. + !#zh 获取鼠标距离上一次事件移动的 Y 轴距离。 + */ + getDeltaY(): number; + /** + !#en Sets mouse button. + !#zh 设置鼠标按键。 + @param button button + */ + setButton(button: number): void; + /** + !#en Returns mouse button. + !#zh 获取鼠标按键。 + */ + getButton(): number; + /** + !#en Returns location X axis data. + !#zh 获取鼠标当前位置 X 轴。 + */ + getLocationX(): number; + /** + !#en Returns location Y axis data. + !#zh 获取鼠标当前位置 Y 轴。 + */ + getLocationY(): number; + /** !#en The none event code of mouse event. + !#zh 无。 */ + static NONE: number; + /** !#en The event type code of mouse down event. + !#zh 鼠标按下事件。 */ + static DOWN: number; + /** !#en The event type code of mouse up event. + !#zh 鼠标按下后释放事件。 */ + static UP: number; + /** !#en The event type code of mouse move event. + !#zh 鼠标移动事件。 */ + static MOVE: number; + /** !#en The event type code of mouse scroll event. + !#zh 鼠标滚轮事件。 */ + static SCROLL: number; + /** !#en The tag of Mouse left button. + !#zh 鼠标左键的标签。 */ + static BUTTON_LEFT: number; + /** !#en The tag of Mouse right button (The right button number is 2 on browser). + !#zh 鼠标右键的标签。 */ + static BUTTON_RIGHT: number; + /** !#en The tag of Mouse middle button (The right button number is 1 on browser). + !#zh 鼠标中键的标签。 */ + static BUTTON_MIDDLE: number; + /** !#en The tag of Mouse button 4. + !#zh 鼠标按键 4 的标签。 */ + static BUTTON_4: number; + /** !#en The tag of Mouse button 5. + !#zh 鼠标按键 5 的标签。 */ + static BUTTON_5: number; + /** !#en The tag of Mouse button 6. + !#zh 鼠标按键 6 的标签。 */ + static BUTTON_6: number; + /** !#en The tag of Mouse button 7. + !#zh 鼠标按键 7 的标签。 */ + static BUTTON_7: number; + /** !#en The tag of Mouse button 8. + !#zh 鼠标按键 8 的标签。 */ + static BUTTON_8: number; + } + } + + /**************************************************** + * Event + *****************************************************/ + + export module Event { + /** !#en The touch event + !#zh 触摸事件 */ + export class EventTouch extends Event { + /** + + @param touchArr The array of the touches + @param bubbles A boolean indicating whether the event bubbles up through the tree or not + */ + constructor(touchArr: any[], bubbles: boolean); + /** !#en The current touch object + !#zh 当前触点对象 */ + touch: Touch; + /** + !#en Returns event code. + !#zh 获取事件类型。 + */ + getEventCode(): number; + /** + !#en Returns touches of event. + !#zh 获取触摸点的列表。 + */ + getTouches(): any[]; + /** + !#en Sets touch location. + !#zh 设置当前触点位置 + @param x x + @param y y + */ + setLocation(x: number, y: number): void; + /** + !#en Returns touch location. + !#zh 获取触点位置。 + */ + getLocation(): Vec2; + /** + !#en Returns the current touch location in screen coordinates. + !#zh 获取当前触点在游戏窗口中的位置。 + */ + getLocationInView(): Vec2; + /** + !#en Returns the previous touch location. + !#zh 获取触点在上一次事件时的位置对象,对象包含 x 和 y 属性。 + */ + getPreviousLocation(): Vec2; + /** + !#en Returns the start touch location. + !#zh 获获取触点落下时的位置对象,对象包含 x 和 y 属性。 + */ + getStartLocation(): Vec2; + /** + !#en Returns the id of cc.Touch. + !#zh 触点的标识 ID,可以用来在多点触摸中跟踪触点。 + */ + getID(): number; + /** + !#en Returns the delta distance from the previous location to current location. + !#zh 获取触点距离上一次事件移动的距离对象,对象包含 x 和 y 属性。 + */ + getDelta(): Vec2; + /** + !#en Returns the X axis delta distance from the previous location to current location. + !#zh 获取触点距离上一次事件移动的 x 轴距离。 + */ + getDeltaX(): number; + /** + !#en Returns the Y axis delta distance from the previous location to current location. + !#zh 获取触点距离上一次事件移动的 y 轴距离。 + */ + getDeltaY(): number; + /** + !#en Returns location X axis data. + !#zh 获取当前触点 X 轴位置。 + */ + getLocationX(): number; + /** + !#en Returns location Y axis data. + !#zh 获取当前触点 Y 轴位置。 + */ + getLocationY(): number; + } + } + + /**************************************************** + * Event + *****************************************************/ + + export module Event { + /** !#en The acceleration event + !#zh 加速度事件 */ + export class EventAcceleration extends Event { + } + } + + /**************************************************** + * Event + *****************************************************/ + + export module Event { + /** !#en The keyboard event + !#zh 键盘事件 */ + export class EventKeyboard extends Event { + } + } + + /**************************************************** + * Graphics + *****************************************************/ + + export module Graphics { + /** !#en Enum for LineCap. + !#zh 线段末端属性 */ + export enum LineCap { + BUTT = 0, + ROUND = 0, + SQUARE = 0, + } + } + + /**************************************************** + * Graphics + *****************************************************/ + + export module Graphics { + /** !#en Enum for LineJoin. + !#zh 线段拐角属性 */ + export enum LineJoin { + BEVEL = 0, + ROUND = 0, + MITER = 0, + } + } + + /**************************************************** + * Pipeline + *****************************************************/ + + export module Pipeline { + /** The downloader pipe, it can download several types of files: + 1. Text + 2. Image + 3. Script + 4. Audio + 5. Assets + All unknown type will be downloaded as plain text. + You can pass custom supported types in the constructor. */ + export class Downloader { + /** + Constructor of Downloader, you can pass custom supported types. + @param extMap Custom supported types with corresponded handler + + @example + ```js + var downloader = new Downloader({ + // This will match all url with `.scene` extension or all url with `scene` type + 'scene' : function (url, callback) {} + }); + ``` + */ + constructor(extMap: any); + /** + Add custom supported types handler or modify existing type handler. + @param extMap Custom supported types with corresponded handler + */ + addHandlers(extMap: any): void; + } + } + + /**************************************************** + * Pipeline + *****************************************************/ + + export module Pipeline { + /** The loader pipe, it can load several types of files: + 1. Images + 2. JSON + 3. Plist + 4. Audio + 5. Font + 6. Cocos Creator scene + It will not interfere with items of unknown type. + You can pass custom supported types in the constructor. */ + export class Loader { + /** + Constructor of Loader, you can pass custom supported types. + @param extMap Custom supported types with corresponded handler + + @example + ```js + var loader = new Loader({ + // This will match all url with `.scene` extension or all url with `scene` type + 'scene' : function (url, callback) {} + }); + ``` + */ + constructor(extMap: any); + /** + Add custom supported types handler or modify existing type handler. + @param extMap Custom supported types with corresponded handler + */ + addHandlers(extMap: any): void; + } + } + + /**************************************************** + * LoadingItems + *****************************************************/ + + export module LoadingItems { + /** !#en The item states of the LoadingItems, its value could be LoadingItems.ItemState.WORKING | LoadingItems.ItemState.COMPLETET | LoadingItems.ItemState.ERROR + !#zh LoadingItems 队列中的加载项状态,状态的值可能是 LoadingItems.ItemState.WORKING | LoadingItems.ItemState.COMPLETET | LoadingItems.ItemState.ERROR */ + export enum ItemState { + WORKING = 0, + COMPLETET = 0, + ERROR = 0, + } + } + + /**************************************************** + * Texture2D + *****************************************************/ + + export module Texture2D { + /** The texture pixel format, default value is RGBA8888 */ + export enum PixelFormat { + RGB565 = 0, + RGB5A1 = 0, + RGBA4444 = 0, + RGB888 = 0, + RGBA8888 = 0, + A8 = 0, + I8 = 0, + AI88 = 0, + } + } + + /**************************************************** + * Texture2D + *****************************************************/ + + export module Texture2D { + /** The texture wrap mode */ + export enum WrapMode { + REPEAT = 0, + CLAMP_TO_EDGE = 0, + MIRRORED_REPEAT = 0, + } + } + + /**************************************************** + * Texture2D + *****************************************************/ + + export module Texture2D { + /** The texture filter mode */ + export enum Filter { + LINEAR = 0, + NEAREST = 0, + } + } + +} + +/** !#en +AnySDK is a third party solution that offers game developers SDK integration without making changes to the SDK's features or parameters.It can do all of this while remaining invisible to your end user.Our goal is to handle all the tedious SDK integration work for you so that you can use your time to focus on the game itself.No matter if it’s the channel SDK, user system, payment system, ad system, statistics system, sharing system or any other type of SDK: we’ll take care of it for you. +!#zh +AnySDK 为 CP 提供一套第三方 SDK 接入解决方案,整个接入过程,不改变任何 SDK 的功能、特性、参数等,对于最终玩家而言是完全透明无感知的。 +目的是让 CP 商能有更多时间更专注于游戏本身的品质,所有 SDK 的接入工作统统交给我们吧。第三方 SDK 包括了渠道SDK、用户系统、支付系统、广告系统、统计系统、分享系统等等。 */ +declare module anysdk { + /** !#en + agent manager of plugin + !#zh + 插件管理对象 */ + export var agentManager: anysdk.AgentManager; + /** !#en + agent manager of plugin + !#zh + 插件管理类 */ + export class AgentManager { + /** + !#en + AppKey appSecret and privateKey are the only three parameters generated + after the packing tool client finishes creating the game. + The oauthLoginServer parameter is the API address provided by the game service + to login verification + !#zh + appKey、appSecret、privateKey是通过 AnySDK 客户端工具创建游戏后生成的。 + oauthLoginServer参数是游戏服务提供的用来做登陆验证转发的接口地址。 + @param appKey appKey + @param appSecret appSecret + @param privateKey privateKey + @param oauthLoginServer oauthLoginServer + */ + init(appKey: string, appSecret: string, privateKey: string, oauthLoginServer: string): void; + /** + !#en + load all plugins, the operation includes SDK`s initialization + !#zh + 加载所有插件,该操作包含了 SDKs 初始化 + @param callback callback + @param target The object to bind to. + */ + loadAllPlugins(callback: Function, target: any): void; + /** + !#en + unload all plugins + !#zh + 卸载插件 + */ + unloadAllPlugins(): void; + /** + !#en + get user system plugin + !#zh + 获取用户系统插件 + */ + getUserPlugin(): anysdk.ProtocolUser; + /** + !#en + get IAP system plugins + !#zh + 获取支付系统插件 + */ + getIAPPlugins(): anysdk.ProtocolIAP[]; + /** + !#en + get IAP system plugin + !#zh + 获取支付系统插件 + */ + getIAPPlugin(): anysdk.ProtocolIAP; + /** + !#en + get social system plugin + !#zh + 获取社交系统插件 + */ + getSocialPlugin(): anysdk.ProtocolSocial; + /** + !#en + get share system plugin + !#zh + 获取分享系统插件 + */ + getSharePlugin(): anysdk.ProtocolShare; + /** + !#en + get analytics system plugin + !#zh + 获取统计系统插件 + */ + getAnalyticsPlugin(): anysdk.ProtocolAnalytics; + /** + !#en + get ads system plugin + !#zh + 获取广告系统插件 + */ + getAdsPlugin(): anysdk.ProtocolAds; + /** + !#en + get push system plugin + !#zh + 获取推送系统插件 + */ + getPushPlugin(): anysdk.ProtocolPush; + /** + !#en + get REC system plugin + !#zh + 获取录屏系统插件 + */ + getRECPlugin(): anysdk.ProtocolREC; + /** + !#en + get crash system plugin + !#zh + 获取崩溃分析系统插件 + */ + getCrashPlugin(): anysdk.ProtocolCrash; + /** + !#en + get ad track system plugin + !#zh + 获取广告追踪系统插件 + */ + getAdTrackingPlugin(): anysdk.ProtocolAdTracking; + /** + !#en + get custom system plugin + !#zh + 获取自定义系统插件 + */ + getCustomPlugin(): anysdk.ProtocolCustom; + /** + !#en + get custom parameter + !#zh + 获取自定义参数 + */ + getCustomParam(): string; + /** + !#en + get channel id + !#zh + 获取渠道唯一表示符 + */ + getChannelId(): string; + /** + !#en + get status of analytics + !#zh + 获取统计状态 + */ + isAnaylticsEnabled(): boolean; + /** + !#en + set whether to analytics + !#zh + 设置是否统计 + @param enabled enabled + */ + setIsAnaylticsEnabled(enabled: boolean): void; + /** + !#en + destory instance + !#zh + 销毁单例 + */ + static end(): void; + /** + !#en + get instance + !#zh + 获取单例 + */ + static getInstance(): anysdk.AgentManager; + } + /** !#en + plugin protocol + !#zh + 插件协议 */ + export class PluginProtocol { + /** + !#en + Check whether the function is supported + !#zh + 判断函数是否支持 + @param functionName functionName + */ + isFunctionSupported(functionName: string): boolean; + /** + !#en + get plugin name + !#zh + 获取插件名称 + */ + getPluginName(): string; + /** + !#en + get plugin version + !#zh + 获取插件版本 + */ + getPluginVersion(): string; + /** + !#en + get SDK version + !#zh + 获取 SDK 版本 + */ + getSDKVersion(): string; + /** + !#en + void methods for reflections with parameter + !#zh + 反射调用带参数的void方法 + @param funName funName + @param args optional arguments + */ + callFuncWithParam(funName: string, ...args: any|anysdk.PluginParam[]): void; + /** + !#en + String methods for reflections with parameter + !#zh + 反射调用带参数的 String 方法 + @param funName funName + @param args optional arguments + */ + callStringFuncWithParam(funName: string, ...args: any|anysdk.PluginParam[]): string; + /** + !#en + int methods for reflections with parameter + !#zh + 反射调用带参数的 Int 方法 + @param funName funName + @param args optional arguments + */ + callIntFuncWithParam(funName: string, ...args: any|anysdk.PluginParam[]): number; + /** + !#en + boolean methods for reflections with parameter + !#zh + 反射调用带参数的 boolean 方法 + @param funName funName + @param args optional arguments + */ + callBoolFuncWithParam(funName: string, ...args: any|anysdk.PluginParam[]): boolean; + /** + !#en + float methods for reflections with parameter + !#zh + 反射调用带参数的 float 方法 + @param funName funName + @param args optional arguments + */ + callFloatFuncWithParam(funName: string, ...args: any|anysdk.PluginParam[]): number; + } + /** !#en + user protocol + !#zh + 用户系统协议接口 */ + export class ProtocolUser extends PluginProtocol { + /** + !#en + login interface + !#zh + 登录接口 + @param args optional arguments + */ + login(...args: string|any[]): void; + /** + !#en + get status of login + !#zh + 获取登录状态 + */ + isLogined(): boolean; + /** + !#en + get user ID + !#zh + 获取用户唯一标示符 + */ + getUserID(): string; + /** + !#en + get plugin ID + !#zh + 获取插件ID + */ + getPluginId(): string; + /** + !#en + set listener + !#zh + 设置用户系统的监听 + @param listener listener + @param target target + */ + setListener(listener: Function, target: any): void; + /** + !#en + get listener + !#zh + 获取用户系统的监听 + */ + getListener(): Function; + /** + !#en + logout + Before to invoke, you need to verdict whether this properties existed + !#zh + 登出,调用前需要判断属性是否存在 + */ + logout(): void; + /** + !#en + show toolbar + Before to invoke, you need to verdict whether this properties existed + !#zh + 显示悬浮窗,调用前需要判断属性是否存在 + @param place place + */ + showToolBar(place: anysdk.ToolBarPlace): void; + /** + !#en + hide toolbar + Before to invoke, you need to verdict whether this properties existed + !#zh + 隐藏悬浮窗,调用前需要判断属性是否存在 + */ + hideToolBar(): void; + /** + !#en + enter platform + Before to invoke, you need to verdict whether this properties existed + !#zh + 显示平台中心,调用前需要判断属性是否存在 + */ + enterPlatform(): void; + /** + !#en + show exit page + Before to invoke, you need to verdict whether this properties existed + !#zh + 显示退出界面,调用前需要判断属性是否存在 + */ + exit(): void; + /** + !#en + show pause page + Before to invoke, you need to verdict whether this properties existed + !#zh + 显示暂停界面,调用前需要判断属性是否存在 + */ + pause(): void; + /** + !#en + Real-name registration + Before to invoke, you need to verdict whether this properties existed + !#zh + 实名注册,调用前需要判断属性是否存在 + */ + realNameRegister(): void; + /** + !#en + Anti-addiction query + Before to invoke, you need to verdict whether this properties existed + !#zh + 防沉迷查询,调用前需要判断属性是否存在 + */ + antiAddictionQuery(): void; + /** + !#en + submit game role information + Before to invoke, you need to verdict whether this properties existed + !#zh + 提交角色信息,调用前需要判断属性是否存在 + @param data data + */ + submitLoginGameRole(data: any): void; + /** + !#en + get user information + Before to invoke, you need to verdict whether this properties existed + !#zh + 获取用户信息,调用前需要判断属性是否存在 + @param info info + */ + getUserInfo(info: any): void; + /** + !#en + set login type + Before to invoke, you need to verdict whether this properties existed + !#zh + 设置登录类型,调用前需要判断属性是否存在 + @param info info + */ + getAvailableLoginType(info: any): void; + /** + !#en + set login type + Before to invoke, you need to verdict whether this properties existed + !#zh + 设置登录类型,调用前需要判断属性是否存在 + @param loginType loginType + */ + setLoginType(loginType: string): void; + /** + !#en + send to desktop + Before to invoke, you need to verdict whether this properties existed + !#zh + 发送到桌面,调用前需要判断属性是否存在 + */ + sendToDesktop(): void; + /** + !#en + open bbs + Before to invoke, you need to verdict whether this properties existed + !#zh + 打开论坛,调用前需要判断属性是否存在 + */ + openBBS(): void; + } + /** !#en + IAP protocol + !#zh + 支付系统协议接口 */ + export class ProtocolIAP extends PluginProtocol { + /** + !#en + pay interface + !#zh + 支付接口 + @param info Type:map + */ + payForProduct(info: any): void; + /** + !#en + get order ID + !#zh + 获取订单ID + */ + getOrderId(): string; + /** + !#en + reset the pay status + !#zh + 重置支付状态 + */ + static resetPayState(): void; + /** + !#en + get plugin ID + !#zh + 获取插件ID + */ + getPluginId(): string; + /** + !#en + set listener + !#zh + 设置支付系统的监听 + @param listener listener + @param target target + */ + setListener(listener: Function, target: any): void; + /** + !#en + get listener + !#zh + 获取支付系统的监听 + */ + getListener(): Function; + } + /** !#en + analytics protocol + !#zh + 统计系统协议接口 */ + export class ProtocolAnalytics extends PluginProtocol { + /** + !#en + Start a new session. + !#zh + 启动会话 + */ + startSession(): void; + /** + !#en + Stop a session. + !#zh + 关闭会话 + */ + stopSession(): void; + /** + !#en + Set the timeout for expiring a session. + !#zh + 设置会话超时时间 + @param millis Type: long + */ + setSessionContinueMillis(millis: number): void; + /** + !#en + log an error + !#zh + 捕捉异常 + @param errorId errorId + @param message message + */ + logError(errorId: string, message: string): void; + /** + !#en + log an event. + !#zh + 捕捉事件 + @param errorId errorId + @param args optional arguments Type: map + */ + logEvent(errorId: string, ...args: any[]): void; + /** + !#en + Track an event begin. + !#zh + 统计事件开始 + @param eventId eventId + */ + logTimedEventBegin(eventId: string): void; + /** + !#en + Track an event end. + !#zh + 统计事件结束 + @param eventId eventId + */ + logTimedEventEnd(eventId: string): void; + /** + !#en + set Whether to catch uncaught exceptions to server. + !#zh + 设置是否开启自动异常捕捉 + @param enabled enabled + */ + setCaptureUncaughtException(enabled: boolean): void; + /** + !#en + analytics account information + !#zh + 统计玩家帐户信息 + @param paramMap Type: map + */ + setAccount(paramMap: any): void; + /** + !#en + track user to request payment + !#zh + 跟踪用户支付请求 + @param paramMap Type: map + */ + onChargeRequest(paramMap: any): void; + /** + !#en + track Successful payment + !#zh + 追踪用户支付成功 + @param orderID orderID + */ + onChargeSuccess(orderID: string): void; + /** + !#en + track failed payment + !#zh + 追踪用户支付失败 + @param paramMap Type: map + */ + onChargeFail(paramMap: any): void; + /** + !#en + track Successful payment + !#zh + 统计玩家支付成功 + @param paramMap Type: map + */ + onChargeOnlySuccess(paramMap: any): void; + /** + !#en + track user purchase + !#zh + 统计玩家消费 + @param paramMap Type: map + */ + onPurchase(paramMap: any): void; + /** + !#en + track user to use goods + !#zh + 统计玩家使用道具 + @param paramMap Type: map + */ + onUse(paramMap: any): void; + /** + !#en + track user to reward goods + !#zh + 统计玩家获取奖励 + @param paramMap Type: map + */ + onReward(paramMap: any): void; + /** + !#en + start level + !#zh + 开始关卡 + @param paramMap Type: map + */ + startLevel(paramMap: any): void; + /** + !#en + finish level + !#zh + 结束关卡 + @param levelID levelID + */ + finishLevel(levelID: string): void; + /** + !#en + failed level + !#zh + 关卡失败 + @param paramMap Type: map + */ + failLevel(paramMap: any): void; + /** + !#en + start task + !#zh + 开始任务 + @param paramMap Type: map + */ + startTask(paramMap: any): void; + /** + !#en + finish task + !#zh + 完成任务 + @param taskID taskID + */ + finishTask(taskID: string): void; + /** + !#en + failed task + !#zh + 任务失败 + @param paramMap Type: map + */ + failTask(paramMap: any): void; + } + /** !#en + share protocol + !#zh + 分享系统协议接口 */ + export class ProtocolShare extends PluginProtocol { + /** + !#en + share interface + !#zh + 分享 + @param info Type: map + */ + share(info: any): void; + /** + !#en + set listener + !#zh + 设置分享系统的监听 + @param listener listener + @param target target + */ + setListener(listener: Function, target: any): void; + /** + !#en + get listener + !#zh + 获取分享系统的监听 + */ + getListener(): Function; + } + /** !#en + ads protocol + !#zh + 广告系统协议接口 */ + export class ProtocolAds extends PluginProtocol { + /** + !#en + hide ads view + !#zh + 隐藏广告 + @param adstype adstype + @param idx idx + */ + hideAds(adstype: anysdk.AdsType, idx: number): void; + /** + !#en + preload ads view + !#zh + 预加载广告 + @param adstype adstype + @param idx idx + */ + preloadAds(adstype: anysdk.AdsType, idx: number): void; + /** + !#en + query points + !#zh + 查询分数 + */ + queryPoints(): number; + /** + !#en + get whether the ads type is supported + !#zh + 获取广告类型是否支持 + @param arg0 arg0 + */ + isAdTypeSupported(arg0: anysdk.AdsType): boolean; + /** + !#en + spend point + !#zh + 消费分数 + @param points points + */ + spendPoints(points: number): void; + /** + !#en + set listener + !#zh + 设置广告系统的监听 + @param listener listener + @param target target + */ + setListener(listener: Function, target: any): void; + /** + !#en + get listener + !#zh + 获取广告系统的监听 + */ + getListener(): Function; + } + /** !#en + social protocol + !#zh + 社交系统协议接口 */ + export class ProtocolSocial extends PluginProtocol { + /** + !#en + sign in + !#zh + 登录 + */ + signIn(): void; + /** + !#en + sign out + !#zh + 登出 + */ + signOut(): void; + /** + !#en + submit score + !#zh + 提交分数 + @param leadboardID leadboardID + @param score Type: long + */ + submitScore(leadboardID: string, score: number): void; + /** + !#en + show the id of Leaderboard page + !#zh + 根据唯一标识符显示排行榜 + @param leaderboardID leaderboardID + */ + showLeaderboard(leaderboardID: string): void; + /** + !#en + show the page of achievements + !#zh + 显示成就榜 + */ + showAchievements(): void; + /** + !#en + unlock achievement + !#zh + 解锁成就 + @param info Type: map + */ + share(info: any): void; + /** + !#en + set listener + !#zh + 设置社交系统的监听 + @param listener listener + @param target target + */ + setListener(listener: Function, target: any): void; + /** + !#en + get listener + !#zh + 获取社交系统的监听 + */ + getListener(): Function; + /** + !#en + get friends info + Before to invoke, you need to verdict whether this properties existed + !#zh + 获取好友信息,调用前需要判断属性是否存在 + */ + pauseRecording(): void; + /** + !#en + interact + Before to invoke, you need to verdict whether this properties existed + !#zh + 订阅,调用前需要判断属性是否存在 + */ + interact(): void; + /** + !#en + subscribe + Before to invoke, you need to verdict whether this properties existed + !#zh + 关注,调用前需要判断属性是否存在 + */ + subscribe(): void; + } + /** !#en + push protocol + !#zh + 推送系统协议接口 */ + export class ProtocolPush extends PluginProtocol { + /** + !#en + start Push services + !#zh + 启动推送服务 + */ + startPush(): void; + /** + !#en + close Push services + !#zh + 暂停推送服务 + */ + closePush(): void; + /** + !#en + delete alias + !#zh + 删除别名 + @param alias alias + */ + delAlias(alias: string): void; + /** + !#en + set alias + !#zh + 设置别名 + @param alias alias + */ + setAlias(alias: string): void; + /** + !#en + delete tags + !#zh + 删除标签 + @param tags Type: list + */ + delTags(tags: any): void; + /** + !#en + set tags + !#zh + 设置标签 + @param tags Type: list + */ + setTags(tags: any): void; + /** + !#en + set listener + !#zh + 设置推送系统的监听 + @param listener listener + @param target target + */ + setListener(listener: Function, target: any): void; + /** + !#en + get listener + !#zh + 获取推送系统的监听 + */ + getListener(): Function; + } + /** !#en + crash protocol + !#zh + 崩溃分析系统协议接口 */ + export class ProtocolCrash extends PluginProtocol { + /** + !#en + set user identifier + !#zh + 统计用户唯一标识符 + @param identifier identifier + */ + setUserIdentifier(identifier: string): void; + /** + !#en + The uploader captured in exception information + !#zh + 上报异常信息 + @param message message + @param exception exception + */ + reportException(message: string, exception: string): void; + /** + !#en + customize logging + !#zh + 自定义日志记录 + @param breadcrumb breadcrumb + */ + leaveBreadcrumb(breadcrumb: string): void; + } + /** !#en + REC protocol + !#zh + 录屏系统协议接口 */ + export class ProtocolREC extends PluginProtocol { + /** + !#en + share video + !#zh + 分享视频 + @param info Type: map + */ + share(info: any): void; + /** + !#en + Start to record video + !#zh + 开始录制视频 + */ + startRecording(): void; + /** + !#en + Start to record video + !#zh + 结束录制视频 + */ + stopRecording(): void; + /** + !#en + set listener + !#zh + 设置录屏系统的监听 + @param listener listener + @param target target + */ + setListener(listener: Function, target: any): void; + /** + !#en + get listener + !#zh + 获取录屏系统的监听 + */ + getListener(): Function; + /** + !#en + pause to record video + Before to invoke, you need to verdict whether this properties existed + !#zh + 暂停录制视频,调用前需要判断属性是否存在 + */ + pauseRecording(): void; + /** + !#en + resume to record video + Before to invoke, you need to verdict whether this properties existed + !#zh + 恢复录制视频,调用前需要判断属性是否存在 + */ + resumeRecording(): void; + /** + !#en + get whether the device is isAvailable + Before to invoke, you need to verdict whether this properties existed + !#zh + 获取设备是否可用,调用前需要判断属性是否存在 + */ + isAvailable(): boolean; + /** + !#en + get status of recording + Before to invoke, you need to verdict whether this properties existed + !#zh + 获取录制状态,调用前需要判断属性是否存在 + */ + isRecording(): boolean; + /** + !#en + show toolbar + Before to invoke, you need to verdict whether this properties existed + !#zh + 显示悬浮窗,调用前需要判断属性是否存在 + */ + showToolBar(): void; + /** + !#en + hide toolbar + Before to invoke, you need to verdict whether this properties existed + !#zh + 隐藏悬浮窗,调用前需要判断属性是否存在 + */ + hideToolBar(): void; + /** + !#en + show video center + Before to invoke, you need to verdict whether this properties existed + !#zh + 显示视频中心,调用前需要判断属性是否存在 + */ + showVideoCenter(): void; + /** + !#en + enter platform + Before to invoke, you need to verdict whether this properties existed + !#zh + 显示平台中心,调用前需要判断属性是否存在 + */ + enterPlatform(): void; + /** + !#en + Set the video data, it is recommended to check whether are recorded firstly + Before to invoke, you need to verdict whether this properties existed + !#zh + 设置视频相关数据,建议先检查是否是正在录制,调用前需要判断属性是否存在 + @param info Type: map + */ + setMetaData(info: any): void; + } + /** !#en + ad tracking protocol + !#zh + 广告追踪系统协议接口 */ + export class ProtocolAdTracking extends PluginProtocol { + /** + !#en + Call this method if you want to track register events as happening during a section. + !#zh + 统计用户注册信息 + @param productInfo Type: map + */ + onPay(productInfo: any): void; + /** + !#en + Call this method if you want to track register events as happening during a section. + !#zh + 统计用户注册信息 + @param userInfo Type: map + */ + onLogin(userInfo: any): void; + /** + !#en + Call this method if you want to track register events as happening during a section. + !#zh + 统计用户注册信息 + @param userId userId + */ + onRegister(userId: string): void; + /** + !#en + Call this method if you want to track custom events with parameters as happening during a section. + !#zh + 统计自定义事件 + @param eventId eventId + @param paramMap Type: map + */ + trackEvent(eventId: string, paramMap: any): void; + /** + !#en + Call this method with parameters if you want to create role as happening during a section. + !#zh + 统计创建角色事件,调用前需要判断属性是否存在 + @param userInfo Type: map + */ + onCreateRole(userInfo: any): void; + /** + !#en + Call this method if you want to track levelup events with parameters as happening during a section. + Before to invoke, you need to verdict whether this properties existed + !#zh + 统计角色升级事件,调用前需要判断属性是否存在 + @param info Type: map + */ + onLevelUp(info: any): void; + /** + !#en + Invoke this method with parameters if you want to start to pay as happening during a section. + Before to invoke, you need to verdict whether this properties existed + !#zh + 统计开始充值事件,调用前需要判断属性是否存在 + @param info Type: map + */ + onStartToPay(info: any): void; + } + /** !#en + custom protocol + !#zh + 自定义系统协议接口 */ + export class ProtocolCustom extends PluginProtocol { + /** + !#en + set listener + !#zh + 设置自定义系统的监听 + @param listener listener + @param target target + */ + setListener(listener: Function, target: any): void; + /** + !#en + get listener + !#zh + 获取自定义系统的监听 + */ + getListener(): Function; + } + /** !#en + Data structure class + !#zh + 数据结构类 */ + export class PluginParam { + /** + !#en + create plugin parameters + !#zh + 创建对象 + @param parameters parameters + */ + static create(parameters: number|string|any): anysdk.PluginParam; + } + /** !#en The callback of user system + !#zh 用户系统回调 */ + export enum UserActionResultCode { + kInitSuccess = 0, + kInitFail = 0, + kLoginSuccess = 0, + kLoginNetworkError = 0, + kLoginNoNeed = 0, + kLoginFail = 0, + kLoginCancel = 0, + kLogoutSuccess = 0, + kLogoutFail = 0, + kPlatformEnter = 0, + kPlatformBack = 0, + kPausePage = 0, + kExitPage = 0, + kAntiAddictionQuery = 0, + kRealNameRegister = 0, + kAccountSwitchSuccess = 0, + kAccountSwitchFail = 0, + kOpenShop = 0, + kAccountSwitchCancel = 0, + kUserExtension = 0, + kSendToDesktopSuccess = 0, + kSendToDesktopFail = 0, + kGetAvailableLoginTypeSuccess = 0, + kGetAvailableLoginTypeFail = 0, + kGetUserInfoSuccess = 0, + kGetUserInfoFail = 0, + kOpenBBSSuccess = 0, + kOpenBBSFail = 0, + } + /** !#en The toolbar position of user type + !#zh 用户系统悬浮窗位置 */ + export enum ToolBarPlace { + kToolBarTopLeft = 0, + kToolBarTopRight = 0, + kToolBarMidLeft = 0, + kToolBarMidRight = 0, + kToolBarBottomLeft = 0, + kToolBarBottomRight = 0, + } + /** !#en The callback of requesting reStringge + !#zh 支付系统支付请求回调 */ + export enum PayResultCode { + kPaySuccess = 0, + kPayFail = 0, + kPayCancel = 0, + kPayNetworkError = 0, + kPayProductionInforIncomplete = 0, + kPayInitSuccess = 0, + kPayInitFail = 0, + kPayNowPaying = 0, + kPayReStringgeSuccess = 0, + kPayExtension = 0, + kPayNeedLoginAgain = 0, + kRequestSuccess = 0, + kRequestFail = 0, + } + /** !#en The enum of account type + !#zh 统计系统的账号类型 */ + export enum AccountType { + ANONYMOUS = 0, + REGISTED = 0, + SINA_WEIBO = 0, + TENCENT_WEIBO = 0, + QQ = 0, + ND91 = 0, + } + /** !#en The enum of account operation + !#zh 统计系统的账号操作 */ + export enum AccountOperate { + LOGIN = 0, + LOGOUT = 0, + REGISTER = 0, + } + /** !#en The enum of gender + !#zh 统计系统的账号性别 */ + export enum AccountGender { + MALE = 0, + FEMALE = 0, + UNKNOWN = 0, + } + /** !#en The enum of task type + !#zh 统计系统的任务类型 */ + export enum TaskType { + GUIDE_LINE = 0, + MAIN_LINE = 0, + BRANCH_LINE = 0, + DAILY = 0, + ACTIVITY = 0, + OTHER = 0, + } + /** !#en The callback of share system + !#zh 分享系统回调 */ + export enum ShareResultCode { + kShareSuccess = 0, + kShareFail = 0, + kShareCancel = 0, + kShareNetworkError = 0, + kShareExtension = 0, + } + /** !#en The callback of social system + !#zh 社交系统回调 */ + export enum SocialRetCode { + kScoreSubmitSucceed = 0, + kScoreSubmitfail = 0, + kAchUnlockSucceed = 0, + kAchUnlockFail = 0, + kSocialSignInSucceed = 0, + kSocialSignInFail = 0, + kSocialSignOutSucceed = 0, + kSocialSignOutFail = 0, + kSocialGetGameFriends = 0, + kSocialExtensionCode = 0, + kSocialGetFriendsInfoSuccess = 0, + kSocialGetFriendsInfoFail = 0, + kSocialAlreadySubscription = 0, + kSocialNoSubscription = 0, + kSocialSubscriptionFail = 0, + } + /** !#en The callback of ads system + !#zh 广告系统回调 */ + export enum AdsResultCode { + kAdsReceived = 0, + kAdsShown = 0, + kAdsDismissed = 0, + kPointsSpendSucceed = 0, + kPointsSpendFailed = 0, + kNetworkError = 0, + kUnknownError = 0, + kOfferWallOnPointsChanged = 0, + kRewardedVideoWithReward = 0, + kInAppPurchaseFinished = 0, + kAdsClicked = 0, + kAdsExtension = 0, + } + /** !#en The enum of ads position + !#zh 广告位置 */ + export enum AdsPos { + kPosCenter = 0, + kPosTop = 0, + kPosTopLeft = 0, + kPosTopRight = 0, + kPosBottom = 0, + kPosBottomLeft = 0, + kPosBottomRight = 0, + } + /** !#en The enum of ads type + !#zh 广告类型 */ + export enum AdsType { + AD_TYPE_BANNER = 0, + AD_TYPE_FULLSCREEN = 0, + AD_TYPE_MOREAPP = 0, + AD_TYPE_OFFERWALL = 0, + AD_TYPE_REWARDEDVIDEO = 0, + AD_TYPE_NATIVEEXPRESS = 0, + AD_TYPE_NATIVEADVANCED = 0, + } + /** !#en The callback of push system + !#zh 推送系统回调 */ + export enum PushActionResultCode { + kPushReceiveMessage = 0, + kPushExtensionCode = 0, + } + /** !#en The callback of custom system + !#zh 自定义系统回调 */ + export enum CustomResultCode { + kCustomExtension = 0, + } + /** !#en The callback of REC system + !#zh 录屏系统回调 */ + export enum RECResultCode { + kRECInitSuccess = 0, + kRECInitFail = 0, + kRECStartRecording = 0, + kRECStopRecording = 0, + kRECPauseRecording = 0, + kRECResumeRecording = 0, + kRECEnterSDKPage = 0, + kRECQuitSDKPage = 0, + kRECShareSuccess = 0, + kRECShareFail = 0, + kRECExtension = 0, + } +} + +/** !#en +The global main namespace of DragonBones, all classes, functions, +properties and constants of DragonBones are defined in this namespace +!#zh +DragonBones 的全局的命名空间, +与 DragonBones 相关的所有的类,函数,属性,常量都在这个命名空间中定义。 */ +declare module dragonBones { + /** !#en + The Armature Display of DragonBones
+
+ (Armature Display has a reference to a DragonBonesAsset and stores the state for ArmatureDisplay instance, + which consists of the current pose's bone SRT, slot colors, and which slot attachments are visible.
+ Multiple Armature Display can use the same DragonBonesAsset which includes all animations, skins, and attachments.)
+ !#zh + DragonBones 骨骼动画
+
+ (Armature Display 具有对骨骼数据的引用并且存储了骨骼实例的状态, + 它由当前的骨骼动作,slot 颜色,和可见的 slot attachments 组成。
+ 多个 Armature Display 可以使用相同的骨骼数据,其中包括所有的动画,皮肤和 attachments。)
*/ + export class ArmatureDisplay extends cc._RendererUnderSG { + /** !#en + The DragonBones data contains the armatures information (bind pose bones, slots, draw order, + attachments, skins, etc) and animations but does not hold any state.
+ Multiple ArmatureDisplay can share the same DragonBones data. + !#zh + 骨骼数据包含了骨骼信息(绑定骨骼动作,slots,渲染顺序, + attachments,皮肤等等)和动画但不持有任何状态。
+ 多个 ArmatureDisplay 可以共用相同的骨骼数据。 */ + dragonAsset: DragonBonesAsset; + /** !#en + The atlas asset for the DragonBones. + !#zh + 骨骼数据所需的 Atlas Texture 数据。 */ + dragonAtlasAsset: DragonBonesAtlasAsset; + /** !#en The name of current armature. + !#zh 当前的 Armature 名称。 */ + armatureName: string; + /** !#en The name of current playing animation. + !#zh 当前播放的动画名称。 */ + animationName: string; + _defaultArmatureIndex: number; + /** !#en The time scale of this armature. + !#zh 当前骨骼中所有动画的时间缩放率。 */ + timeScale: number; + /** !#en The play times of the default animation. + -1 means using the value of config file; + 0 means repeat for ever + >0 means repeat times + !#zh 播放默认动画的循环次数 + -1 表示使用配置文件中的默认值; + 0 表示无限循环 + >0 表示循环次数 */ + playTimes: number; + /** !#en Indicates whether open debug bones. + !#zh 是否显示 bone 的 debug 信息。 */ + debugBones: boolean; + /** + !#en + Play the specified animation. + Parameter animName specify the animation name. + Parameter playTimes specify the repeat times of the animation. + -1 means use the value of the config file. + 0 means play the animation for ever. + >0 means repeat times. + !#zh + 播放指定的动画. + animName 指定播放动画的名称。 + playTimes 指定播放动画的次数。 + -1 为使用配置文件中的次数。 + 0 为无限循环播放。 + >0 为动画的重复次数。 + @param animName animName + @param playTimes playTimes + */ + playAnimation(animName: string, playTimes: number): dragonBones.AnimationState; + /** + !#en + Get the all armature names in the DragonBones Data. + !#zh + 获取 DragonBones 数据中所有的 armature 名称 + */ + getArmatureNames(): any[]; + /** + !#en + Get the all animation names of specified armature. + !#zh + 获取指定的 armature 的所有动画名称。 + @param armatureName armatureName + */ + getAnimationNames(armatureName: string): any[]; + /** + !#en + Add event listener for the DragonBones Event. + !#zh + 添加 DragonBones 事件监听器。 + @param eventType eventType + @param listener listener + @param target target + */ + addEventListener(eventType: dragonBones.EventObject, listener: Function, target: any): void; + /** + !#en + Remove the event listener for the DragonBones Event. + !#zh + 移除 DragonBones 事件监听器。 + @param eventType eventType + @param listener listener + @param target target + */ + removeEventListener(eventType: dragonBones.EventObject, listener: Function, target: any): void; + /** + !#en + Build the armature for specified name. + !#zh + 构建指定名称的 armature 对象 + @param armatureName armatureName + */ + buildArmature(armatureName: string): dragonBones.Armature; + /** + !#en + Get the current armature object of the ArmatureDisplay. + !#zh + 获取 ArmatureDisplay 当前使用的 Armature 对象 + */ + armature(): any; + } + /** !#en The skeleton data of dragonBones. + !#zh dragonBones 的 骨骼数据。 */ + export class DragonBonesAsset extends cc.Asset { + /** !#en See http://developer.egret.com/cn/github/egret-docs/DB/dbLibs/dataFormat/index.html + !#zh 可查看 DragonBones 官方文档 http://developer.egret.com/cn/github/egret-docs/DB/dbLibs/dataFormat/index.html */ + dragonBonesJson: string; + } + /** !#en The skeleton atlas data of dragonBones. + !#zh dragonBones 的骨骼纹理数据。 */ + export class DragonBonesAtlasAsset extends cc.Asset { + atlasJson: string; + texture: cc.Texture2D; + } +} + +/** !#en +The global main namespace of Spine, all classes, functions, +properties and constants of Spine are defined in this namespace +!#zh +Spine 的全局的命名空间, +与 Spine 相关的所有的类,函数,属性,常量都在这个命名空间中定义。 */ +declare module sp { + /** !#en + The skeleton of Spine
+
+ (Skeleton has a reference to a SkeletonData and stores the state for skeleton instance, + which consists of the current pose's bone SRT, slot colors, and which slot attachments are visible.
+ Multiple skeletons can use the same SkeletonData which includes all animations, skins, and attachments.)
+ !#zh + Spine 骨骼动画
+
+ (Skeleton 具有对骨骼数据的引用并且存储了骨骼实例的状态, + 它由当前的骨骼动作,slot 颜色,和可见的 slot attachments 组成。
+ 多个 Skeleton 可以使用相同的骨骼数据,其中包括所有的动画,皮肤和 attachments。 */ + export class Skeleton extends cc._RendererUnderSG { + /** !#en The skeletal animation is paused? + !#zh 该骨骼动画是否暂停。 */ + paused: boolean; + /** !#en + The skeleton data contains the skeleton information (bind pose bones, slots, draw order, + attachments, skins, etc) and animations but does not hold any state.
+ Multiple skeletons can share the same skeleton data. + !#zh + 骨骼数据包含了骨骼信息(绑定骨骼动作,slots,渲染顺序, + attachments,皮肤等等)和动画但不持有任何状态。
+ 多个 Skeleton 可以共用相同的骨骼数据。 */ + skeletonData: SkeletonData; + /** !#en The name of default skin. + !#zh 默认的皮肤名称。 */ + defaultSkin: string; + /** !#en The name of default animation. + !#zh 默认的动画名称。 */ + defaultAnimation: string; + /** !#en The name of current playing animation. + !#zh 当前播放的动画名称。 */ + animation: string; + _defaultSkinIndex: number; + /** !#en TODO + !#zh 是否循环播放当前骨骼动画。 */ + loop: boolean; + /** !#en Indicates whether to enable premultiplied alpha. + You should disable this option when image's transparent area appears to have opaque pixels, + or enable this option when image's half transparent area appears to be darken. + !#zh 是否启用贴图预乘。 + 当图片的透明区域出现色块时需要关闭该选项,当图片的半透明区域颜色变黑时需要启用该选项。 */ + premultipliedAlpha: boolean; + /** !#en The time scale of this skeleton. + !#zh 当前骨骼中所有动画的时间缩放率。 */ + timeScale: number; + /** !#en Indicates whether open debug slots. + !#zh 是否显示 slot 的 debug 信息。 */ + debugSlots: boolean; + /** !#en Indicates whether open debug bones. + !#zh 是否显示 bone 的 debug 信息。 */ + debugBones: boolean; + /** + !#en Computes the world SRT from the local SRT for each bone. + !#zh 重新更新所有骨骼的世界 Transform, + 当获取 bone 的数值未更新时,即可使用该函数进行更新数值。 + + @example + ```js + var bone = spine.findBone('head'); + cc.log(bone.worldX); // return 0; + spine.updateWorldTransform(); + bone = spine.findBone('head'); + cc.log(bone.worldX); // return -23.12; + ``` + */ + updateWorldTransform(): void; + /** + !#en Sets the bones and slots to the setup pose. + !#zh 还原到起始动作 + */ + setToSetupPose(): void; + /** + !#en + Sets the bones to the setup pose, + using the values from the `BoneData` list in the `SkeletonData`. + !#zh + 设置 bone 到起始动作 + 使用 SkeletonData 中的 BoneData 列表中的值。 + */ + setBonesToSetupPose(): void; + /** + !#en + Sets the slots to the setup pose, + using the values from the `SlotData` list in the `SkeletonData`. + !#zh + 设置 slot 到起始动作。 + 使用 SkeletonData 中的 SlotData 列表中的值。 + */ + setSlotsToSetupPose(): void; + /** + !#en + Finds a bone by name. + This does a string comparison for every bone.
+ Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Bone object. + !#zh + 通过名称查找 bone。 + 这里对每个 bone 的名称进行了对比。
+ 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Bone 对象。 + @param boneName boneName + */ + findBone(boneName: string): sp.spine.Bone; + /** + !#en + Finds a slot by name. This does a string comparison for every slot.
+ Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Slot object. + !#zh + 通过名称查找 slot。这里对每个 slot 的名称进行了比较。
+ 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Slot 对象。 + @param slotName slotName + */ + findSlot(slotName: string): sp.spine.Slot; + /** + !#en + Finds a skin by name and makes it the active skin. + This does a string comparison for every skin.
+ Note that setting the skin does not change which attachments are visible.
+ Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Skin object. + !#zh + 按名称查找皮肤,激活该皮肤。这里对每个皮肤的名称进行了比较。
+ 注意:设置皮肤不会改变 attachment 的可见性。
+ 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Skin 对象。 + @param skinName skinName + */ + setSkin(skinName: string): sp.spine.Skin; + /** + !#en + Returns the attachment for the slot and attachment name. + The skeleton looks first in its skin, then in the skeleton data’s default skin.
+ Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Attachment object. + !#zh + 通过 slot 和 attachment 的名称获取 attachment。Skeleton 优先查找它的皮肤,然后才是 Skeleton Data 中默认的皮肤。
+ 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Attachment 对象。 + @param slotName slotName + @param attachmentName attachmentName + */ + getAttachment(slotName: string, attachmentName: string): sp.spine.Attachment; + /** + !#en + Sets the attachment for the slot and attachment name. + The skeleton looks first in its skin, then in the skeleton data’s default skin. + !#zh + 通过 slot 和 attachment 的名字来设置 attachment。 + Skeleton 优先查找它的皮肤,然后才是 Skeleton Data 中默认的皮肤。 + @param slotName slotName + @param attachmentName attachmentName + */ + setAttachment(slotName: string, attachmentName: string): void; + /** + !#en + Sets runtime skeleton data to sp.Skeleton.
+ This method is different from the `skeletonData` property. This method is passed in the raw data provided by the Spine runtime, and the skeletonData type is the asset type provided by Creator. + !#zh + 设置底层运行时用到的 SkeletonData。
+ 这个接口有别于 `skeletonData` 属性,这个接口传入的是 Spine runtime 提供的原始数据,而 skeletonData 的类型是 Creator 提供的资源类型。 + @param skeletonData skeletonData + @param ownsSkeletonData ownsSkeletonData + */ + setSkeletonData(skeletonData: sp.spine.SkeletonData, ownsSkeletonData: sp.spine.SkeletonData): void; + /** + !#en Sets animation state data.
+ The parameter type is {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.AnimationStateData. + !#zh 设置动画状态数据。
+ 参数是 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.AnimationStateData。 + @param stateData stateData + */ + setAnimationStateData(stateData: sp.spine.AnimationStateData): void; + /** + !#en + Mix applies all keyframe values, + interpolated for the specified time and mixed with the current values. + !#zh 为所有关键帧设定混合及混合时间(从当前值开始差值)。 + @param fromAnimation fromAnimation + @param toAnimation toAnimation + @param duration duration + */ + setMix(fromAnimation: string, toAnimation: string, duration: number): void; + /** + !#en Sets event listener. + !#zh 设置动画事件监听器。 + @param target target + @param callback callback + */ + setAnimationListener(target: any, callback: Function): void; + /** + !#en Set the current animation. Any queued animations are cleared.
+ Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry object. + !#zh 设置当前动画。队列中的任何的动画将被清除。
+ 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry 对象。 + @param trackIndex trackIndex + @param name name + @param loop loop + */ + setAnimation(trackIndex: number, name: string, loop: boolean): sp.spine.TrackEntry; + /** + !#en Adds an animation to be played delay seconds after the current or last queued animation.
+ Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry object. + !#zh 添加一个动画到动画队列尾部,还可以延迟指定的秒数。
+ 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry 对象。 + @param trackIndex trackIndex + @param name name + @param loop loop + @param delay delay + */ + addAnimation(trackIndex: number, name: string, loop: boolean, delay?: number): sp.spine.TrackEntry; + /** + !#en Find animation with specified name. + !#zh 查找指定名称的动画 + @param name name + */ + findAnimation(name: string): sp.spine.Animation; + /** + !#en Returns track entry by trackIndex.
+ Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry object. + !#zh 通过 track 索引获取 TrackEntry。
+ 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry 对象。 + @param trackIndex trackIndex + */ + getCurrent(trackIndex: void): sp.spine.TrackEntry; + /** + !#en Clears all tracks of animation state. + !#zh 清除所有 track 的动画状态。 + */ + clearTracks(): void; + /** + !#en Clears track of animation state by trackIndex. + !#zh 清除出指定 track 的动画状态。 + @param trackIndex trackIndex + */ + clearTrack(trackIndex: number): void; + /** + !#en Set the start event listener. + !#zh 用来设置开始播放动画的事件监听。 + @param listener listener + */ + setStartListener(listener: Function): void; + /** + !#en Set the interrupt event listener. + !#zh 用来设置动画被打断的事件监听。 + @param listener listener + */ + setInterruptListener(listener: Function): void; + /** + !#en Set the end event listener. + !#zh 用来设置动画播放完后的事件监听。 + @param listener listener + */ + setEndListener(listener: Function): void; + /** + !#en Set the dispose event listener. + !#zh 用来设置动画将被销毁的事件监听。 + @param listener listener + */ + setDisposeListener(listener: Function): void; + /** + !#en Set the complete event listener. + !#zh 用来设置动画播放一次循环结束后的事件监听。 + @param listener listener + */ + setCompleteListener(listener: Function): void; + /** + !#en Set the animation event listener. + !#zh 用来设置动画播放过程中帧事件的监听。 + @param listener listener + */ + setEventListener(listener: Function): void; + /** + !#en Set the start event listener for specified TrackEntry (only supported on Web). + !#zh 用来为指定的 TrackEntry 设置动画开始播放的事件监听。(只支持 Web 平台) + @param entry entry + @param listener listener + */ + setTrackStartListener(entry: sp.spine.TrackEntry, listener: Function): void; + /** + !#en Set the interrupt event listener for specified TrackEntry (only supported on Web). + !#zh 用来为指定的 TrackEntry 设置动画被打断的事件监听。(只支持 Web 平台) + @param entry entry + @param listener listener + */ + setTrackInterruptListener(entry: sp.spine.TrackEntry, listener: Function): void; + /** + !#en Set the end event listener for specified TrackEntry (only supported on Web). + !#zh 用来为指定的 TrackEntry 设置动画播放结束的事件监听。(只支持 Web 平台) + @param entry entry + @param listener listener + */ + setTrackEndListener(entry: sp.spine.TrackEntry, listener: Function): void; + /** + !#en Set the dispose event listener for specified TrackEntry (only supported on Web). + !#zh 用来为指定的 TrackEntry 设置动画即将被销毁的事件监听。(只支持 Web 平台) + @param entry entry + @param listener listener + */ + setTrackDisposeListener(entry: sp.spine.TrackEntry, listener: Function): void; + /** + !#en Set the complete event listener for specified TrackEntry (only supported on Web). + !#zh 用来为指定的 TrackEntry 设置动画一次循环播放结束的事件监听。(只支持 Web 平台) + @param entry entry + @param listener listener + */ + setTrackCompleteListener(entry: sp.spine.TrackEntry, listener: Function): void; + /** + !#en Set the event listener for specified TrackEntry (only supported on Web). + !#zh 用来为指定的 TrackEntry 设置动画帧事件的监听。(只支持 Web 平台) + @param entry entry + @param listener listener + */ + setTrackEventListener(entry: sp.spine.TrackEntry, listener: Function): void; + } + /** !#en The skeleton data of spine. + !#zh Spine 的 骨骼数据。 */ + export class SkeletonData extends cc.Asset { + /** !#en See http://en.esotericsoftware.com/spine-json-format + !#zh 可查看 Spine 官方文档 http://zh.esotericsoftware.com/spine-json-format */ + skeletonJson: any; + atlasText: string; + textures: cc.Texture2D[]; + /** !#en + A scale can be specified on the JSON or binary loader which will scale the bone positions, + image sizes, and animation translations. + This can be useful when using different sized images than were used when designing the skeleton + in Spine. For example, if using images that are half the size than were used in Spine, + a scale of 0.5 can be used. This is commonly used for games that can run with either low or high + resolution texture atlases. + see http://en.esotericsoftware.com/spine-using-runtimes#Scaling + !#zh 可查看 Spine 官方文档: http://zh.esotericsoftware.com/spine-using-runtimes#Scaling */ + scale: number; + /** + !#en Get the included SkeletonData used in spine runtime.
+ Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.SkeletonData object. + !#zh 获取 Spine Runtime 使用的 SkeletonData。
+ 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.SkeletonData 对象。 + @param quiet quiet + */ + getRuntimeData(quiet?: boolean): sp.spine.SkeletonData; + } + /** !#en The event type of spine skeleton animation. + !#zh 骨骼动画事件类型。 */ + export enum AnimationEventType { + START = 0, + END = 0, + COMPLETE = 0, + EVENT = 0, + } +} + +/** !#en +`sp.spine` is the namespace for official Spine Runtime, which officially implemented and maintained by Spine.
+Please refer to the official documentation for its detailed usage: [http://en.esotericsoftware.com/spine-using-runtimes](http://en.esotericsoftware.com/spine-using-runtimes) +!#zh +sp.spine 模块是 Spine 官方运行库的 API 入口,由 Spine 官方统一实现和维护,具体用法请参考:[http://zh.esotericsoftware.com/spine-using-runtimes](http://zh.esotericsoftware.com/spine-using-runtimes) */ +declare module sp.spine { +} + +/** !#en Some JavaScript decorators which can be accessed with "cc._decorator". +!#zh 一些 JavaScript 装饰器,目前可以通过 "cc._decorator" 来访问。 +(这些 API 仍不完全稳定,有可能随着 JavaScript 装饰器的标准实现而调整) */ +declare module cc._decorator { + /** + !#en + Declare the standard [ES6 Class](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes) + as CCClass, please see [Class](/docs/editors_and_tools/creator-chapters/scripting/class/) for details. + !#zh + 将标准写法的 [ES6 Class](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes) 声明为 CCClass,具体用法请参阅[类型定义](/docs/creator/scripting/class/)。 + @param name The class name used for serialization. + + @example + ```js + const {ccclass} = cc._decorator; + + // define a CCClass, omit the name + @ccclass + class NewScript extends cc.Component { + // ... + } + + // define a CCClass with a name + @ccclass('LoginData') + class LoginData { + // ... + } + ``` + */ + export function ccclass(name?: string): Function; + export function ccclass(_class?: Function): void; + /** + !#en + Declare property for [CCClass](/docs/editors_and_tools/creator-chapters/scripting/class/). + !#zh + 定义 [CCClass](/docs/creator/scripting/class/) 所用的属性。 + @param options an object with some property attributes + + @example + ```js + const {ccclass, property} = cc._decorator; + + @ccclass + class NewScript extends cc.Component { + @property({ + type: cc.Node + }) + targetNode1 = null; + + @property(cc.Node) + targetNode2 = null; + + @property(cc.Button) + targetButton = null; + + @property + _width = 100; + + @property + get width () { + return this._width; + } + + @property + set width (value) { + this._width = value; + } + + @property + offset = new cc.Vec2(100, 100); + + @property(cc.Vec2) + offsets = []; + + @property(cc.Texture2D) + texture = ""; + } + + // above is equivalent to (上面的代码相当于): + + var NewScript = cc.Class({ + properties: { + targetNode1: { + default: null, + type: cc.Node + }, + + targetNode2: { + default: null, + type: cc.Node + }, + + targetButton: { + default: null, + type: cc.Button + }, + + _width: 100, + + width: { + get () { + return this._width; + }, + set (value) { + this._width = value; + } + }, + + offset: new cc.Vec2(100, 100) + + offsets: { + default: [], + type: cc.Vec2 + } + + texture: { + default: "", + url: cc.Texture2D + }, + } + }); + ``` + */ + export function property(options?: {type?: any; url?: typeof cc.RawAsset; visible?: boolean|(() => boolean); displayName?: string; tooltip?: string; multiline?: boolean; readonly?: boolean; min?: number; max?: number; step?: number; range?: number[]; slide?: boolean; serializable?: boolean; formerlySerializedAs?: string; editorOnly?: boolean; override?: boolean; animatable?: boolean} | any[]|Function|cc.ValueType|number|string|boolean): Function; + export function property(_target: Object, _key: any, _desc?: any): void; + /** + !#en + Makes a CCClass that inherit from component execute in edit mode.
+ By default, all components are only executed in play mode, + which means they will not have their callback functions executed while the Editor is in edit mode. + !#zh + 允许继承自 Component 的 CCClass 在编辑器里执行。
+ 默认情况下,所有 Component 都只会在运行时才会执行,也就是说它们的生命周期回调不会在编辑器里触发。 + + @example + ```js + const {ccclass, executeInEditMode} = cc._decorator; + + @ccclass + @executeInEditMode + class NewScript extends cc.Component { + // ... + } + ``` + */ + export function executeInEditMode(): Function; + export function executeInEditMode(_class: Function): void; + /** + !#en + Automatically add required component as a dependency for the CCClass that inherit from component. + !#zh + 为声明为 CCClass 的组件添加依赖的其它组件。当组件添加到节点上时,如果依赖的组件不存在,引擎将会自动将依赖组件添加到同一个节点,防止脚本出错。该设置在运行时同样有效。 + @param requiredComponent requiredComponent + + @example + ```js + const {ccclass, requireComponent} = cc._decorator; + + @ccclass + @requireComponent(cc.Sprite) + class SpriteCtrl extends cc.Component { + // ... + } + ``` + */ + export function requireComponent(requiredComponent: typeof cc.Component): Function; + /** + !#en + The menu path to register a component to the editors "Component" menu. Eg. "Rendering/CameraCtrl". + !#zh + 将当前组件添加到组件菜单中,方便用户查找。例如 "Rendering/CameraCtrl"。 + @param path The path is the menu represented like a pathname. + For example the menu could be "Rendering/CameraCtrl". + + @example + ```js + const {ccclass, menu} = cc._decorator; + + @ccclass + @menu("Rendering/CameraCtrl") + class NewScript extends cc.Component { + // ... + } + ``` + */ + export function menu(path: string): Function; + /** + !#en + The execution order of lifecycle methods for Component. + Those less than 0 will execute before while those greater than 0 will execute after. + The order will only affect onLoad, onEnable, start, update and lateUpdate while onDisable and onDestroy will not be affected. + !#zh + 设置脚本生命周期方法调用的优先级。优先级小于 0 的组件将会优先执行,优先级大于 0 的组件将会延后执行。优先级仅会影响 onLoad, onEnable, start, update 和 lateUpdate,而 onDisable 和 onDestroy 不受影响。 + @param order The execution order of lifecycle methods for Component. Those less than 0 will execute before while those greater than 0 will execute after. + + @example + ```js + const {ccclass, executionOrder} = cc._decorator; + + @ccclass + @executionOrder(1) + class CameraCtrl extends cc.Component { + // ... + } + ``` + */ + export function executionOrder(order: number): Function; + /** + !#en + Prevents Component of the same type (or subtype) to be added more than once to a Node. + !#zh + 防止多个相同类型(或子类型)的组件被添加到同一个节点。 + + @example + ```js + const {ccclass, disallowMultiple} = cc._decorator; + + @ccclass + @disallowMultiple + class CameraCtrl extends cc.Component { + // ... + } + ``` + */ + export function disallowMultiple(): Function; + export function disallowMultiple(_class: Function): void; + /** + !#en + If specified, the editor's scene view will keep updating this node in 60 fps when it is selected, otherwise, it will update only if necessary.
+ This property is only available if executeInEditMode is true. + !#zh + 当指定了 "executeInEditMode" 以后,playOnFocus 可以在选中当前组件所在的节点时,提高编辑器的场景刷新频率到 60 FPS,否则场景就只会在必要的时候进行重绘。 + + @example + ```js + const {ccclass, playOnFocus, executeInEditMode} = cc._decorator; + + @ccclass + @executeInEditMode + @playOnFocus + class CameraCtrl extends cc.Component { + // ... + } + ``` + */ + export function playOnFocus(): Function; + export function playOnFocus(_class: Function): void; + /** + !#en + Specifying the url of the custom html to draw the component in **Properties**. + !#zh + 自定义当前组件在 **属性检查器** 中渲染时所用的网页 url。 + @param url url + + @example + ```js + const {ccclass, inspector} = cc._decorator; + + @ccclass + @inspector("packages://inspector/inspectors/comps/camera-ctrl.js") + class NewScript extends cc.Component { + // ... + } + ``` + */ + export function inspector(path: string): Function; + /** + !#en + The custom documentation URL. + !#zh + 指定当前组件的帮助文档的 url,设置过后,在 **属性检查器** 中就会出现一个帮助图标,用户点击将打开指定的网页。 + @param url url + + @example + ```js + const {ccclass, help} = cc._decorator; + + @ccclass + @help("app://docs/html/components/spine.html") + class NewScript extends cc.Component { + // ... + } + ``` + */ + export function help(path: string): Function; + /** + NOTE:
+ The old mixins implemented in cc.Class(ES5) behaves exact the same as multiple inheritance. + But since ES6, class constructor can't be function-called and class methods become non-enumerable, + so we can not mix in ES6 Classes.
+ See:
+ [https://esdiscuss.org/topic/traits-are-now-impossible-in-es6-until-es7-since-rev32](https://esdiscuss.org/topic/traits-are-now-impossible-in-es6-until-es7-since-rev32)
+ One possible solution (but IDE unfriendly):
+ [http://justinfagnani.com/2015/12/21/real-mixins-with-javascript-classes](http://justinfagnani.com/2015/12/21/real-mixins-with-javascript-classes/)
+
+ NOTE:
+ You must manually call mixins constructor, this is different from cc.Class(ES5). + @param ctor constructors to mix, only support ES5 constructors or classes defined by using `cc.Class`, + not support ES6 Classes. + + @example + ```js + const {ccclass, mixins} = cc._decorator; + + class Animal { ... } + + const Fly = cc.Class({ + constructor () { ... } + }); + + @ccclass + @mixins(cc.EventTarget, Fly) + class Bird extends Animal { + constructor () { + super(); + + // You must manually call mixins constructor, this is different from cc.Class(ES5) + cc.EventTarget.call(this); + Fly.call(this); + } + // ... + } + ``` + */ + export function mixins(ctor: Function, ...rest: Function[]): Function; +} + +/** This module provides some JavaScript utilities. +All members can be accessed with "cc.js". */ +declare module cc.js { + /** + Check the obj whether is number or not + If a number is created by using 'new Number(10086)', the typeof it will be "object"... + Then you can use this function if you care about this case. + @param obj obj + */ + export function isNumber(obj: any): boolean; + /** + Check the obj whether is string or not. + If a string is created by using 'new String("blabla")', the typeof it will be "object"... + Then you can use this function if you care about this case. + @param obj obj + */ + export function isString(obj: any): boolean; + /** + This method is deprecated, use cc.js.mixin please.
+ Copy all properties not defined in obj from arguments[1...n] + @param obj object to extend its properties + @param sourceObj source object to copy properties from + */ + export function addon(obj: any, ...sourceObj: any[]): any; + /** + copy all properties from arguments[1...n] to obj + @param obj obj + @param sourceObj sourceObj + */ + export function mixin(obj: any, ...sourceObj: any[]): any; + /** + Derive the class from the supplied base class. + Both classes are just native javascript constructors, not created by cc.Class, so + usually you will want to inherit using {{#crossLink "cc/Class:method"}}cc.Class {{/crossLink}} instead. + @param cls cls + @param base the baseclass to inherit + */ + export function extend(cls: Function, base: Function): Function; + /** + Get super class + @param ctor the constructor of subclass + */ + export function getSuper(ctor: Function): Function; + /** + Removes all enumerable properties from object + @param obj obj + */ + export function clear(obj: any): void; + /** + Get property descriptor in object and all its ancestors + @param obj obj + @param name name + */ + export function getPropertyDescriptor(obj: any, name: string): any; + /** + Define value, just help to call Object.defineProperty.
+ The configurable will be true. + @param obj obj + @param prop prop + @param value value + @param writable writable + @param enumerable enumerable + */ + export function value(obj: any, prop: string, value: any, writable?: boolean, enumerable?: boolean): void; + /** + Define get set accessor, just help to call Object.defineProperty(...) + @param obj obj + @param prop prop + @param getter getter + @param setter setter + @param enumerable enumerable + */ + export function getset(obj: any, prop: string, getter: Function, setter: Function, enumerable?: boolean): void; + /** + Define get accessor, just help to call Object.defineProperty(...) + @param obj obj + @param prop prop + @param getter getter + @param enumerable enumerable + @param configurable configurable + */ + export function get(obj: any, prop: string, getter: Function, enumerable?: boolean, configurable?: boolean): void; + /** + Define set accessor, just help to call Object.defineProperty(...) + @param obj obj + @param prop prop + @param setter setter + @param enumerable enumerable + @param configurable configurable + */ + export function set(obj: any, prop: string, setter: Function, enumerable?: boolean, configurable?: boolean): void; + /** + Get class name of the object, if object is just a {} (and which class named 'Object'), it will return "". + (modified from the code from this stackoverflow post) + @param objOrCtor instance or constructor + */ + export function getClassName(objOrCtor: any|Function): string; + /** + Register the class by specified name manually + @param className className + @param constructor constructor + */ + export function setClassName(className: string, constructor: Function): void; + /** + Unregister a class from fireball. + + If you dont need a registered class anymore, you should unregister the class so that Fireball will not keep its reference anymore. + Please note that its still your responsibility to free other references to the class. + @param constructor the class you will want to unregister, any number of classes can be added + */ + export function unregisterClass(...constructor: Function[]): void; + /** + Get the registered class by name + @param classname classname + */ + export function getClassByName(classname: string): Function; + /** + Defines a polyfill field for obsoleted codes. + @param obj YourObject or YourClass.prototype + @param obsoleted "OldParam" or "YourClass.OldParam" + @param newPropName "NewParam" + @param writable writable + */ + export function obsolete(obj: any, obsoleted: string, newPropName: string, writable?: boolean): void; + /** + Defines all polyfill fields for obsoleted codes corresponding to the enumerable properties of props. + @param obj YourObject or YourClass.prototype + @param objName "YourObject" or "YourClass" + @param props props + @param writable writable + */ + export function obsoletes(obj: any, objName: any, props: any, writable?: boolean): void; + /** + A string tool to construct a string with format string. + @param msg A JavaScript string containing zero or more substitution strings (%s). + @param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output. + + @example + ```js + cc.js.formatStr("a: %s, b: %s", a, b); + cc.js.formatStr(a, b, c); + ``` + */ + export function formatStr(msg: string|any, ...subst: any[]): string; + /** + !#en + A simple wrapper of `Object.create(null)` which ensures the return object have no prototype (and thus no inherited members). So we can skip `hasOwnProperty` calls on property lookups. It is a worthwhile optimization than the `{}` literal when `hasOwnProperty` calls are necessary. + !#zh + 该方法是对 `Object.create(null)` 的简单封装。`Object.create(null)` 用于创建无 prototype (也就无继承)的空对象。这样我们在该对象上查找属性时,就不用进行 `hasOwnProperty` 判断。在需要频繁判断 `hasOwnProperty` 时,使用这个方法性能会比 `{}` 更高。 + @param forceDictMode Apply the delete operator to newly created map object. This causes V8 to put the object in "dictionary mode" and disables creation of hidden classes which are very expensive for objects that are constantly changing shape. + */ + export function createMap(forceDictMode?: boolean): any; + /** undefined */ + export class array { + /** + Removes the array item at the specified index. + @param array array + @param index index + */ + static removeAt(array: any[], index: number): void; + /** + Removes the array item at the specified index. + It's faster but the order of the array will be changed. + @param array array + @param index index + */ + static fastRemoveAt(array: any[], index: number): void; + /** + Removes the first occurrence of a specific object from the array. + @param array array + @param value value + */ + static remove(array: any[], value: any): boolean; + /** + Removes the first occurrence of a specific object from the array. + It's faster but the order of the array will be changed. + @param array array + @param value value + */ + static fastRemove(array: any[], value: number): void; + /** + Verify array's Type + @param array array + @param type type + */ + static verifyType(array: any[], type: Function): boolean; + /** + Removes from array all values in minusArr. For each Value in minusArr, the first matching instance in array will be removed. + @param array Source Array + @param minusArr minus Array + */ + static removeArray(array: any[], minusArr: any[]): void; + /** + Inserts some objects at index + @param array array + @param addObjs addObjs + @param index index + */ + static appendObjectsAt(array: any[], addObjs: any[], index: number): any[]; + /** + Exact same function as Array.prototype.indexOf.
+ HACK: ugliy hack for Baidu mobile browser compatibility, stupid Baidu guys modify Array.prototype.indexOf for all pages loaded, their version changes strict comparison to non-strict comparison, it also ignores the second parameter of the original API, and this will cause event handler enter infinite loop.
+ Baidu developers, if you ever see this documentation, here is the standard: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf, Seriously! + @param searchElement Element to locate in the array. + @param fromIndex The index to start the search at + */ + static indexOf(searchElement: any, fromIndex?: number): number; + /** + Determines whether the array contains a specific value. + @param array array + @param value value + */ + static contains(array: any[], value: any): boolean; + /** + Copy an array's item to a new array (its performance is better than Array.slice) + @param array array + */ + static copy(array: any[]): any[]; + } + /** !#en + A fixed-length object pool designed for general type.
+ The implementation of this object pool is very simple, + it can helps you to improve your game performance for objects which need frequent release and recreate operations
+ !#zh + 长度固定的对象缓存池,可以用来缓存各种对象类型。
+ 这个对象池的实现非常精简,它可以帮助您提高游戏性能,适用于优化对象的反复创建和销毁。 */ + export class Pool { + /** + !#en + Constructor for creating an object pool for the specific object type. + You can pass a callback argument for process the cleanup logic when the object is recycled. + !#zh + 使用构造函数来创建一个指定对象类型的对象池,您可以传递一个回调函数,用于处理对象回收时的清理逻辑。 + @param cleanupFunc the callback method used to process the cleanup logic when the object is recycled. + @param size initializes the length of the array + */ + constructor(cleanupFunc: (obj: any) => void, size: number); + constructor(size: number); + /** + !#en + Get and initialize an object from pool. This method defaults to null and requires the user to implement it. + !#zh + 获取并初始化对象池中的对象。这个方法默认为空,需要用户自己实现。 + @param params parameters to used to initialize the object + */ + get(...params: any[]): any; + /** !#en + The current number of available objects, the default is 0, it will gradually increase with the recycle of the object, + the maximum will not exceed the size specified when the constructor is called. + !#zh + 当前可用对象数量,一开始默认是 0,随着对象的回收会逐渐增大,最大不会超过调用构造函数时指定的 size。 */ + count: number; + /** + !#en + Get an object from pool, if no available object in the pool, null will be returned. + !#zh + 获取对象池中的对象,如果对象池没有可用对象,则返回空。 + */ + _get(): any; + /** + !#en Put an object into the pool. + !#zh 向对象池返还一个不再需要的对象。 + */ + put(): void; + /** + !#en Resize the pool. + !#zh 设置对象池容量。 + */ + resize(): void; + } +} +declare namespace dragonBones { + /** + * @private + */ + const enum ArmatureType { + Armature = 0, + MovieClip = 1, + Stage = 2, + } + /** + * @private + */ + const enum DisplayType { + Image = 0, + Armature = 1, + Mesh = 2, + } + /** + * @private + */ + const enum ExtensionType { + FFD = 0, + AdjustColor = 10, + BevelFilter = 11, + BlurFilter = 12, + DropShadowFilter = 13, + GlowFilter = 14, + GradientBevelFilter = 15, + GradientGlowFilter = 16, + } + /** + * @private + */ + const enum EventType { + Frame = 10, + Sound = 11, + } + /** + * @private + */ + const enum ActionType { + Play = 0, + Stop = 1, + GotoAndPlay = 2, + GotoAndStop = 3, + FadeIn = 4, + FadeOut = 5, + } + /** + * @private + */ + const enum BlendMode { + Normal = 0, + Add = 1, + Alpha = 2, + Darken = 3, + Difference = 4, + Erase = 5, + HardLight = 6, + Invert = 7, + Layer = 8, + Lighten = 9, + Multiply = 10, + Overlay = 11, + Screen = 12, + Subtract = 13, + } + /** + * @private + */ + interface Map { + [key: string]: T; + } + /** + * DragonBones + */ + class DragonBones { + /** + * @private + */ + static PI_D: number; + /** + * @private + */ + static PI_H: number; + /** + * @private + */ + static PI_Q: number; + /** + * @private + */ + static ANGLE_TO_RADIAN: number; + /** + * @private + */ + static RADIAN_TO_ANGLE: number; + /** + * @private + */ + static SECOND_TO_MILLISECOND: number; + static VERSION: string; + /** + * @private + */ + static debug: boolean; + /** + * @private + */ + static debugDraw: boolean; + } +} +declare namespace dragonBones { + /** + * @language zh_CN + * 基础对象。 + * @version DragonBones 4.5 + */ + abstract class BaseObject { + private static _hashCode; + private static _defaultMaxCount; + private static _maxCountMap; + private static _poolsMap; + private static _returnObject(object); + /** + * @language zh_CN + * 设置每种对象池的最大缓存数量。 + * @param objectConstructor 对象类。 + * @param maxCount 最大缓存数量。 (设置为 0 则不缓存) + * @version DragonBones 4.5 + */ + static setMaxCount(objectConstructor: typeof BaseObject, maxCount: number): void; + /** + * @language zh_CN + * 清除对象池缓存的对象。 + * @param objectConstructor 对象类。 (不设置则清除所有缓存) + * @version DragonBones 4.5 + */ + static clearPool(objectConstructor?: typeof BaseObject): void; + /** + * @language zh_CN + * 从对象池中创建指定对象。 + * @param objectConstructor 对象类。 + * @version DragonBones 4.5 + */ + static borrowObject(objectConstructor: { + new (): T; + }): T; + /** + * @language zh_CN + * 对象的唯一标识。 + * @version DragonBones 4.5 + */ + hashCode: number; + /** + * @private + */ + protected abstract _onClear(): void; + /** + * @language zh_CN + * 清除数据并返还对象池。 + * @version DragonBones 4.5 + */ + returnToPool(): void; + } +} +declare namespace dragonBones { +} +declare namespace dragonBones { + /** + * @language zh_CN + * 动画混合时,使用的淡出方式。 + * @see dragonBones.Animation#fadeIn() + * @version DragonBones 4.5 + */ + const enum AnimationFadeOutMode { + /** + * @language zh_CN + * 不淡出动画。 + * @version DragonBones 4.5 + */ + None = 0, + /** + * @language zh_CN + * 淡出同层的动画。 + * @version DragonBones 4.5 + */ + SameLayer = 1, + /** + * @language zh_CN + * 淡出同组的动画。 + * @version DragonBones 4.5 + */ + SameGroup = 2, + /** + * @language zh_CN + * 淡出同层并且同组的动画。 + * @version DragonBones 4.5 + */ + SameLayerAndGroup = 3, + /** + * @language zh_CN + * 淡出所有动画。 + * @version DragonBones 4.5 + */ + All = 4, + } + /** + * @language zh_CN + * 播放动画组件接口。 (Armature 和 WordClock 都实现了该接口) + * 任何实现了此接口的实例都可以加到 WorldClock 时钟中,由时钟统一控制动画的播放。 + * @see dragonBones.WorldClock + * @see dragonBones.Armature + * @version DragonBones 3.0 + */ + interface IAnimateble { + /** + * @language zh_CN + * 更新一个指定的时间。 + * @param passedTime 前进的时间。 (以秒为单位) + * @version DragonBones 3.0 + */ + advanceTime(passedTime: number): void; + } + /** + * @language zh_CN + * 动画控制器,用来播放动画数据,管理动画状态。 + * @see dragonBones.AnimationData + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + */ + class Animation extends BaseObject { + /** + * @private + */ + private static _sortAnimationState(a, b); + /** + * @private + */ + static toString(): string; + /** + * @language zh_CN + * 动画的播放速度。 [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1 + * @version DragonBones 3.0 + */ + timeScale: number; + /** + * @private + */ + _armature: Armature; + private _isPlaying; + private _time; + private _duration; + private _lastAnimationState; + private _animations; + private _animationNames; + private _animationStates; + /** + * @inheritDoc + */ + protected _onClear(): void; + private _fadeOut(fadeOutTime, layer, group, fadeOutMode, pauseFadeOut); + /** + * @language zh_CN + * 清除所有正在播放的动画状态。 + * @version DragonBones 4.5 + */ + reset(): void; + /** + * @language zh_CN + * 暂停播放动画。 + * @param animationName 动画状态的名称,如果未设置,则暂停所有动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + */ + stop(animationName?: string): void; + /** + * @language zh_CN + * 播放动画。 + * @param animationName 动画数据的名称,如果未设置,则播放默认动画,或将暂停状态切换为播放状态,或重新播放上一个正在播放的动画。 + * @param playTimes 动画需要播放的次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @returns 返回控制这个动画数据的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + */ + play(animationName?: string, playTimes?: number): AnimationState; + /** + * @language zh_CN + * 淡入播放指定名称的动画。 + * @param animationName 动画数据的名称。 + * @param playTimes 循环播放的次数。 [-1: 使用数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @param fadeInTime 淡入的时间。 [-1: 使用数据默认值, [0~N]: N 秒淡入完毕] (以秒为单位) + * @param layer 混合的图层,图层高会优先获取混合权重。 + * @param group 混合的组,用于给动画状态编组,方便混合淡出控制。 + * @param fadeOutMode 淡出的模式。 + * @param additiveBlending 以叠加的形式混合。 + * @param displayControl 是否对显示对象属性可控。 + * @param pauseFadeOut 暂停需要淡出的动画。 + * @param pauseFadeIn 暂停需要淡入的动画,直到淡入结束才开始播放。 + * @returns 返回控制这个动画数据的动画状态。 + * @see dragonBones.AnimationFadeOutMode + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + */ + fadeIn(animationName: string, fadeInTime?: number, playTimes?: number, layer?: number, group?: string, fadeOutMode?: AnimationFadeOutMode, additiveBlending?: boolean, displayControl?: boolean, pauseFadeOut?: boolean, pauseFadeIn?: boolean): AnimationState; + /** + * @language zh_CN + * 指定名称的动画从指定时间开始播放。 + * @param animationName 动画数据的名称。 + * @param time 时间。 (以秒为单位) + * @param playTimes 动画循环播放的次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @param toTime 播放到指定的时间,如果未设置则播放整个动画。 + * @returns 返回控制这个动画数据的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + */ + gotoAndPlayByTime(animationName: string, time?: number, playTimes?: number, toTime?: number): AnimationState; + /** + * @language zh_CN + * 指定名称的动画从指定帧开始播放。 + * @param animationName 动画数据的名称。 + * @param frame 帧。 + * @param playTimes 动画循环播放的次数。[-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @param toFrame 播放到指定的帧,如果未设置则播放整个动画。 + * @returns 返回控制这个动画数据的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + */ + gotoAndPlayByFrame(animationName: string, frame?: number, playTimes?: number, toFrame?: number): AnimationState; + /** + * @language zh_CN + * 指定名称的动画从指定进度开始播放。 + * @param animationName 动画数据的名称。 + * @param progress 进度。 [0~1] + * @param playTimes 动画循环播放的次数。[-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @param toProgress 播放到指定的进度,如果未设置则播放整个动画。 + * @returns 返回控制这个动画数据的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + */ + gotoAndPlayByProgress(animationName: string, progress?: number, playTimes?: number, toProgress?: number): AnimationState; + /** + * @language zh_CN + * 播放指定名称的动画到指定的时间并停止。 + * @param animationName 动画数据的名称。 + * @param time 时间。 (以秒为单位) + * @returns 返回控制这个动画数据的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + */ + gotoAndStopByTime(animationName: string, time?: number): AnimationState; + /** + * @language zh_CN + * 播放指定名称的动画到指定的帧并停止。 + * @param animationName 动画数据的名称。 + * @param frame 帧。 + * @returns 返回控制这个动画数据的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + */ + gotoAndStopByFrame(animationName: string, frame?: number): AnimationState; + /** + * @language zh_CN + * 播放指定名称的动画到指定的进度并停止。 + * @param animationName 动画数据的名称。 + * @param progress 进度。 [0~1] + * @returns 返回控制这个动画数据的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + */ + gotoAndStopByProgress(animationName: string, progress?: number): AnimationState; + /** + * @language zh_CN + * 获取指定名称的动画状态。 + * @param animationName 动画状态的名称。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + */ + getState(animationName: string): AnimationState; + /** + * @language zh_CN + * 是否包含指定名称的动画数据。 + * @param animationName 动画数据的名称。 + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + */ + hasAnimation(animationName: string): boolean; + /** + * @language zh_CN + * 动画是否处于播放状态。 + * @version DragonBones 3.0 + */ + isPlaying: boolean; + /** + * @language zh_CN + * 所有动画状态是否均已播放完毕。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + */ + isCompleted: boolean; + /** + * @language zh_CN + * 上一个正在播放的动画状态的名称。 + * @see #lastAnimationState + * @version DragonBones 3.0 + */ + lastAnimationName: string; + /** + * @language zh_CN + * 上一个正在播放的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + */ + lastAnimationState: AnimationState; + /** + * @language zh_CN + * 所有动画数据名称。 + * @see #animations + * @version DragonBones 4.5 + */ + animationNames: Array; + /** + * @language zh_CN + * 所有的动画数据。 + * @see dragonBones.AnimationData + * @version DragonBones 4.5 + */ + animations: Map; + /** + * @deprecated + * @see #play() + * @see #fadeIn() + * @see #gotoAndPlayByTime() + * @see #gotoAndPlayByFrame() + * @see #gotoAndPlayByProgress() + */ + gotoAndPlay(animationName: string, fadeInTime?: number, duration?: number, playTimes?: number, layer?: number, group?: string, fadeOutMode?: AnimationFadeOutMode, pauseFadeOut?: boolean, pauseFadeIn?: boolean): AnimationState; + /** + * @deprecated + * @see #gotoAndStopByTime() + * @see #gotoAndStopByFrame() + * @see #gotoAndStopByProgress() + */ + gotoAndStop(animationName: string, time?: number): AnimationState; + /** + * @deprecated + * @see #animationNames + * @see #animations + */ + animationList: Array; + /** + * @language zh_CN + * @deprecated + * @see #animationNames + * @see #animations + */ + animationDataList: Array; + } +} +declare namespace dragonBones { + /** + * @language zh_CN + * 动画状态,播放动画时产生,可以对单个动画的播放进行更细致的控制和调节。 + * @see dragonBones.Animation + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + */ + class AnimationState extends BaseObject { + /** + * @private + */ + static stateActionEnabled: boolean; + /** + * @private + */ + static toString(): string; + /** + * @language zh_CN + * 是否对插槽的颜色,显示序列索引,深度排序,行为等拥有控制的权限。 + * @see dragonBones.Slot#displayController + * @version DragonBones 3.0 + */ + displayControl: boolean; + /** + * @language zh_CN + * 是否以叠加的方式混合动画。 + * @version DragonBones 3.0 + */ + additiveBlending: boolean; + /** + * @private + */ + actionEnabled: boolean; + /** + * @language zh_CN + * 需要播放的次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次] + * @version DragonBones 3.0 + */ + playTimes: number; + /** + * @language zh_CN + * 播放速度。 [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1 + * @version DragonBones 3.0 + */ + timeScale: number; + /** + * @language zh_CN + * 进行动画混合时的权重。 + * @default 1 + * @version DragonBones 3.0 + */ + weight: number; + /** + * @language zh_CN + * 自动淡出时需要的时间,当设置一个大于等于 0 的值,动画状态将会在播放完成后自动淡出。 (以秒为单位) + * @default -1 + * @version DragonBones 3.0 + */ + autoFadeOutTime: number; + /** + * @private + */ + fadeTotalTime: number; + /** + * @private + */ + private _isPlaying; + /** + * @private + */ + private _isPausePlayhead; + /** + * @private + */ + private _fadeTime; + /** + * @private + */ + private _time; + /** + * @private + */ + private _name; + /** + * @private + */ + private _armature; + /** + * @private + */ + private _animationData; + /** + * @private + */ + private _zOrderTimeline; + /** + * @private + */ + private _boneMask; + /** + * @private + */ + private _boneTimelines; + /** + * @private + */ + private _slotTimelines; + /** + * @private + */ + private _ffdTimelines; + /** + * @inheritDoc + */ + protected _onClear(): void; + private _updateTimelineStates(); + private _advanceFadeTime(passedTime); + /** + * @language zh_CN + * 继续播放。 + * @version DragonBones 3.0 + */ + play(): void; + /** + * @language zh_CN + * 暂停播放。 + * @version DragonBones 3.0 + */ + stop(): void; + /** + * @language zh_CN + * 淡出动画。 + * @param fadeOutTime 淡出时间。 (以秒为单位) + * @param pausePlayhead 淡出时是否暂停动画。 [true: 暂停, false: 不暂停] + * @version DragonBones 3.0 + */ + fadeOut(fadeOutTime: number, pausePlayhead?: boolean): void; + /** + * @language zh_CN + * 是否包含指定的骨骼遮罩。 + * @param name 指定的骨骼名称。 + * @version DragonBones 3.0 + */ + containsBoneMask(name: string): boolean; + /** + * @language zh_CN + * 添加指定的骨骼遮罩。 + * @param boneName 指定的骨骼名称。 + * @param recursive 是否为该骨骼的子骨骼添加遮罩。 + * @version DragonBones 3.0 + */ + addBoneMask(name: string, recursive?: boolean): void; + /** + * @language zh_CN + * 删除指定的骨骼遮罩。 + * @param boneName 指定的骨骼名称。 + * @param recursive 是否删除该骨骼的子骨骼遮罩。 + * @version DragonBones 3.0 + */ + removeBoneMask(name: string, recursive?: boolean): void; + /** + * @language zh_CN + * 删除所有骨骼遮罩。 + * @version DragonBones 3.0 + */ + removeAllBoneMask(): void; + /** + * @language zh_CN + * 动画图层。 + * @see dragonBones.Animation#fadeIn() + * @version DragonBones 3.0 + */ + layer: number; + /** + * @language zh_CN + * 动画组。 + * @see dragonBones.Animation#fadeIn() + * @version DragonBones 3.0 + */ + group: string; + /** + * @language zh_CN + * 动画名称。 + * @see dragonBones.AnimationData#name + * @version DragonBones 3.0 + */ + name: string; + /** + * @language zh_CN + * 动画数据。 + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + */ + animationData: AnimationData; + /** + * @language zh_CN + * 是否播放完毕。 + * @version DragonBones 3.0 + */ + isCompleted: boolean; + /** + * @language zh_CN + * 是否正在播放。 + * @version DragonBones 3.0 + */ + isPlaying: boolean; + /** + * @language zh_CN + * 当前动画的播放次数。 + * @version DragonBones 3.0 + */ + currentPlayTimes: number; + /** + * @language zh_CN + * 当前动画的总时间。 (以秒为单位) + * @version DragonBones 3.0 + */ + totalTime: number; + /** + * @language zh_CN + * 当前动画的播放时间。 (以秒为单位) + * @version DragonBones 3.0 + */ + currentTime: number; + /** + * @deprecated + */ + autoTween: boolean; + /** + * @deprecated + * @see #animationData + */ + clip: AnimationData; + } +} +declare namespace dragonBones { +} +declare namespace dragonBones { + /** + * @language zh_CN + * WorldClock 提供时钟的支持,为每个加入到时钟的 IAnimatable 对象更新时间。 + * @see dragonBones.IAnimatable + * @see dragonBones.Armature + * @version DragonBones 3.0 + */ + class WorldClock implements IAnimateble { + private static _clock; + /** + * @language zh_CN + * 一个可以直接使用的全局 WorldClock 实例. + * @version DragonBones 3.0 + */ + static clock: WorldClock; + /** + * @language zh_CN + * 当前的时间。 (以秒为单位) + * @version DragonBones 3.0 + */ + time: number; + /** + * @language zh_CN + * 时间流逝的速度,用于实现动画的变速播放。 [0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1 + * @version DragonBones 3.0 + */ + timeScale: number; + private _animatebles; + /** + * @language zh_CN + * 创建一个新的 WorldClock 实例。 + * 通常并不需要单独创建 WorldClock 的实例,可以直接使用 WorldClock.clock 静态实例。 + * (创建更多独立的 WorldClock 可以更灵活的为需要更新的 IAnimateble 实例分组,实现不同组不同速度的动画播放) + * @version DragonBones 3.0 + */ + constructor(); + /** + * @language zh_CN + * 为所有的 IAnimatable 实例向前播放一个指定的时间。 (通常这个方法需要在 ENTER_FRAME 事件的响应函数中被调用) + * @param passedTime 前进的时间。 (以秒为单位,当设置为 -1 时将自动计算当前帧与上一帧的时间差) + * @version DragonBones 3.0 + */ + advanceTime(passedTime: number): void; + /** + * 是否包含指定的 IAnimatable 实例 + * @param value 指定的 IAnimatable 实例。 + * @returns [true: 包含,false: 不包含]。 + * @version DragonBones 3.0 + */ + contains(value: IAnimateble): boolean; + /** + * @language zh_CN + * 添加指定的 IAnimatable 实例。 + * @param value IAnimatable 实例。 + * @version DragonBones 3.0 + */ + add(value: IAnimateble): void; + /** + * @language zh_CN + * 移除指定的 IAnimatable 实例。 + * @param value IAnimatable 实例。 + * @version DragonBones 3.0 + */ + remove(value: IAnimateble): void; + /** + * @language zh_CN + * 清除所有的 IAnimatable 实例。 + * @version DragonBones 3.0 + */ + clear(): void; + } +} +declare namespace dragonBones { + /** + * @language zh_CN + * 基础变换对象。 + * @version DragonBones 4.5 + */ + abstract class TransformObject extends BaseObject { + /** + * @language zh_CN + * 可以用于存储临时数据。 + * @version DragonBones 3.0 + */ + userData: any; + /** + * @language zh_CN + * 对象的名称。 + * @version DragonBones 3.0 + */ + name: string; + /** + * @language zh_CN + * 相对于骨架坐标系的矩阵。 + * @version DragonBones 3.0 + */ + globalTransformMatrix: Matrix; + /** + * @language zh_CN + * 相对于骨架坐标系的变换。 + * @see dragonBones.Transform + * @version DragonBones 3.0 + */ + global: Transform; + /** + * @language zh_CN + * 相对于骨架或父骨骼坐标系的绑定变换。 + * @see dragonBones.Transform + * @version DragonBones 3.0 + */ + origin: Transform; + /** + * @language zh_CN + * 相对于骨架或父骨骼坐标系的偏移变换。 + * @see dragonBones.Transform + * @version DragonBones 3.0 + */ + offset: Transform; + /** + * @private + */ + _armature: Armature; + /** + * @private + */ + _parent: Bone; + /** + * @private + */ + protected _globalTransformMatrix: Matrix; + /** + * @inheritDoc + */ + protected _onClear(): void; + /** + * @language zh_CN + * 所属的骨架。 + * @see dragonBones.Armature + * @version DragonBones 3.0 + */ + armature: Armature; + /** + * @language zh_CN + * 所属的父骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + */ + parent: Bone; + } +} +declare namespace dragonBones { + /** + * @language zh_CN + * 骨架,是骨骼动画系统的核心,由显示容器、骨骼、插槽、动画、事件系统构成。 + * @see dragonBones.ArmatureData + * @see dragonBones.Bone + * @see dragonBones.Slot + * @see dragonBones.Animation + * @see dragonBones.IArmatureDisplay + * @version DragonBones 3.0 + */ + class Armature extends BaseObject implements IAnimateble { + /** + * @private + */ + static toString(): string; + private static _onSortSlots(a, b); + /** + * @language zh_CN + * 可以用于存储临时数据。 + * @version DragonBones 3.0 + */ + userData: any; + /** + * @private + */ + _cacheFrameIndex: number; + /** + * @private + */ + _armatureData: ArmatureData; + /** + * @private + */ + _skinData: SkinData; + /** + * @private + */ + _animation: Animation; + /** + * @private + */ + _display: IArmatureDisplay; + /** + * @private + */ + _eventManager: IEventDispatcher; + private _delayDispose; + private _lockDispose; + private _slotsDirty; + private _replacedTexture; + private _bones; + private _slots; + private _actions; + private _events; + /** + * @inheritDoc + */ + protected _onClear(): void; + private _sortBones(); + private _sortSlots(); + private _doAction(value); + /** + * @private + */ + _sortZOrder(slotIndices: Array): void; + /** + * @private + */ + _bufferAction(value: ActionData): void; + /** + * @language zh_CN + * 释放骨架。 (会回收到内存池) + * @version DragonBones 3.0 + */ + dispose(): void; + /** + * @language zh_CN + * 更新骨架和动画。 (可以使用时钟实例或显示容器来更新) + * @param passedTime 两帧之前的时间间隔。 (以秒为单位) + * @see dragonBones.IAnimateble + * @see dragonBones.WorldClock + * @see dragonBones.IArmatureDisplay + * @version DragonBones 3.0 + */ + advanceTime(passedTime: number): void; + /** + * @language zh_CN + * 更新骨骼和插槽的变换。 (当骨骼没有动画状态或动画状态播放完成时,骨骼将不在更新) + * @param boneName 指定的骨骼名称,如果未设置,将更新所有骨骼。 + * @param updateSlotDisplay 是否更新插槽的显示对象。 + * @see dragonBones.Bone + * @see dragonBones.Slot + * @version DragonBones 3.0 + */ + invalidUpdate(boneName?: string, updateSlotDisplay?: boolean): void; + /** + * @language zh_CN + * 获取指定名称的骨骼。 + * @param name 骨骼的名称。 + * @returns 骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + */ + getBone(name: string): Bone; + /** + * @language zh_CN + * 通过显示对象获取骨骼。 + * @param display 显示对象。 + * @returns 包含这个显示对象的骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + */ + getBoneByDisplay(display: any): Bone; + /** + * @language zh_CN + * 获取指定名称的插槽。 + * @param name 插槽的名称。 + * @returns 插槽。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + */ + getSlot(name: string): Slot; + /** + * @language zh_CN + * 通过显示对象获取插槽。 + * @param display 显示对象。 + * @returns 包含这个显示对象的插槽。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + */ + getSlotByDisplay(display: any): Slot; + /** + * @language zh_CN + * 替换骨架的主贴图,根据渲染引擎的不同,提供不同的贴图数据。 + * @param texture 贴图。 + * @version DragonBones 4.5 + */ + replaceTexture(texture: any): void; + /** + * @language zh_CN + * 获取所有骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + */ + getBones(): Array; + /** + * @language zh_CN + * 获取所有插槽。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + */ + getSlots(): Array; + /** + * @language zh_CN + * 骨架名称。 + * @see dragonBones.ArmatureData#name + * @version DragonBones 3.0 + */ + name: string; + /** + * @language zh_CN + * 获取骨架数据。 + * @see dragonBones.ArmatureData + * @version DragonBones 4.5 + */ + armatureData: ArmatureData; + /** + * @language zh_CN + * 获得动画控制器。 + * @see dragonBones.Animation + * @version DragonBones 3.0 + */ + animation: Animation; + /** + * @language zh_CN + * 获取显示容器,插槽的显示对象都会以此显示容器为父级,根据渲染平台的不同,类型会不同,通常是 DisplayObjectContainer 类型。 + * @version DragonBones 3.0 + */ + display: IArmatureDisplay | any; + /** + * @language zh_CN + * 获取父插槽。 (当此骨架是某个骨架的子骨架时,可以通过此属性向上查找从属关系) + * @see dragonBones.Slot + * @version DragonBones 4.5 + */ + parent: Slot; + /** + * @language zh_CN + * 动画缓存的帧率,当设置一个大于 0 的帧率时,将会开启动画缓存。 + * 通过将动画数据缓存在内存中来提高运行性能,会有一定的内存开销。 + * 帧率不宜设置的过高,通常跟动画的帧率相当且低于程序运行的帧率。 + * 开启动画缓存后,某些功能将会失效,比如 Bone 和 Slot 的 offset 属性等。 + * @see dragonBones.DragonBonesData#frameRate + * @see dragonBones.ArmatureData#frameRate + * @version DragonBones 4.5 + */ + cacheFrameRate: number; + /** + * @language zh_CN + * 替换骨架的主贴图,根据渲染引擎的不同,提供不同的贴图数据。 + * @version DragonBones 4.5 + */ + replacedTexture: any; + /** + * @language zh_CN + * 开启动画缓存。 + * @param frameRate 动画缓存的帧率 + * @see #cacheFrameRate + * @version DragonBones 4.5 + */ + enableAnimationCache(frameRate: number): void; + /** + * @language zh_CN + * 是否包含指定类型的事件。 + * @param type 事件类型。 + * @returns [true: 包含, false: 不包含] + * @version DragonBones 3.0 + */ + hasEventListener(type: EventStringType): void; + /** + * @language zh_CN + * 添加事件。 + * @param type 事件类型。 + * @param listener 事件回调。 + * @version DragonBones 3.0 + */ + addEventListener(type: EventStringType, listener: Function, target: any): void; + /** + * @language zh_CN + * 移除事件。 + * @param type 事件类型。 + * @param listener 事件回调。 + * @version DragonBones 3.0 + */ + removeEventListener(type: EventStringType, listener: Function, target: any): void; + /** + * @deprecated + */ + addBone(value: Bone, parentName?: string): void; + /** + * @deprecated + */ + addSlot(value: Slot, parentName: string): void; + /** + * @deprecated + */ + removeBone(value: Bone): void; + /** + * @deprecated + */ + removeSlot(value: Slot): void; + /** + * @deprecated + * @see #display + */ + getDisplay(): any; + /** + * @deprecated + * @see #cacheFrameRate + */ + enableCache: boolean; + } +} +declare namespace dragonBones { + /** + * @language zh_CN + * 骨骼,一个骨架中可以包含多个骨骼,骨骼以树状结构组成骨架。 + * 骨骼在骨骼动画体系中是最重要的逻辑单元之一,负责动画中的平移旋转缩放的实现。 + * @see dragonBones.BoneData + * @see dragonBones.Armature + * @see dragonBones.Slot + * @version DragonBones 3.0 + */ + class Bone extends TransformObject { + /** + * @private + */ + static toString(): string; + /** + * @language zh_CN + * 是否继承父骨骼的平移。 [true: 继承, false: 不继承] + * @version DragonBones 3.0 + */ + inheritTranslation: boolean; + /** + * @language zh_CN + * 是否继承父骨骼的旋转。 [true: 继承, false: 不继承] + * @version DragonBones 3.0 + */ + inheritRotation: boolean; + /** + * @language zh_CN + * 是否继承父骨骼的缩放。 [true: 继承, false: 不继承] + * @version DragonBones 4.5 + */ + inheritScale: boolean; + /** + * @language zh_CN + * IK 约束时骨骼方向是否为顺时针方向。 [true: 顺时针, false: 逆时针] + * @version DragonBones 4.5 + */ + ikBendPositive: boolean; + /** + * @language zh_CN + * IK 约束的权重。 + * @version DragonBones 4.5 + */ + ikWeight: number; + /** + * @language zh_CN + * 骨骼长度。 + * @version DragonBones 4.5 + */ + length: number; + /** + * @private + */ + private _visible; + /** + * @private + */ + private _ikChain; + /** + * @private + */ + private _ikChainIndex; + /** + * @private + */ + private _ik; + /** + * @private + */ + private _bones; + /** + * @private + */ + private _slots; + /** + * @inheritDoc + */ + protected _onClear(): void; + /** + * @private + */ + private _updateGlobalTransformMatrix(); + /** + * @private + */ + private _computeIKA(); + /** + * @private + */ + private _computeIKB(); + /** + * @inheritDoc + */ + _setArmature(value: Armature): void; + /** + * @language zh_CN + * 下一帧更新变换。 (当骨骼没有动画状态或动画状态播放完成时,骨骼将不在更新) + * @version DragonBones 3.0 + */ + invalidUpdate(): void; + /** + * @language zh_CN + * 是否包含某个指定的骨骼或插槽。 + * @returns [true: 包含,false: 不包含] + * @see dragonBones.TransformObject + * @version DragonBones 3.0 + */ + contains(child: TransformObject): boolean; + /** + * @language zh_CN + * 所有的子骨骼。 + * @version DragonBones 3.0 + */ + getBones(): Array; + /** + * @language zh_CN + * 所有的插槽。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + */ + getSlots(): Array; + /** + * @private + */ + ikChain: number; + /** + * @private + */ + ikChainIndex: number; + /** + * @language zh_CN + * 当前的 IK 约束目标。 + * @version DragonBones 4.5 + */ + ik: Bone; + /** + * @language zh_CN + * 控制此骨骼所有插槽的显示。 + * @default true + * @see dragonBones.Slot + * @version DragonBones 3.0 + */ + visible: boolean; + /** + * @deprecated + * @see dragonBones.Armature#getSlot() + */ + slot: Slot; + } +} +declare namespace dragonBones { + /** + * @language zh_CN + * 骨架显示容器和事件的接口。 + * @see dragonBones.Armature#display + * @version DragonBones 4.5 + */ + interface IArmatureDisplay extends IEventDispatcher { + /** + * @language zh_CN + * 释放显示对象和骨架。 + * @version DragonBones 4.5 + */ + dispose(): void; + /** + * @language zh_CN + * 获取使用这个显示容器的骨架。 + * @readOnly + * @see dragonBones.Armature + * @version DragonBones 4.5 + */ + armature: Armature; + /** + * @language zh_CN + * 获取使用骨架的动画控制器。 + * @readOnly + * @see dragonBones.Animation + * @version DragonBones 4.5 + */ + animation: Animation; + /** + * @language zh_CN + * 由显示容器来更新骨架和动画。 + * @param on 开启或关闭显示容器对骨架与动画的更新。 + * @version DragonBones 4.5 + */ + advanceTimeBySelf(on: boolean): void; + } +} +declare namespace dragonBones { + /** + * @language zh_CN + * 插槽,附着在骨骼上,控制显示对象的显示状态和属性。 + * 一个骨骼上可以包含多个插槽。 + * 一个插槽中可以包含多个显示对象,同一时间只能显示其中的一个显示对象,但可以在动画播放的过程中切换显示对象实现帧动画。 + * 显示对象可以是普通的图片纹理,也可以是子骨架的显示容器,网格显示对象,还可以是自定义的其他显示对象。 + * @see dragonBones.Armature + * @see dragonBones.Bone + * @see dragonBones.SlotData + * @version DragonBones 3.0 + */ + abstract class Slot extends TransformObject { + private static _helpPoint; + private static _helpMatrix; + /** + * @language zh_CN + * 子骨架是否继承父骨架的动画。 [true: 继承, false: 不继承] + * @default true + * @version DragonBones 4.5 + */ + inheritAnimation: boolean; + /** + * @language zh_CN + * 显示对象受到控制的对象,应设置为动画状态的名称或组名称,设置为 null 则表示受所有的动画状态控制。 + * @default null + * @see dragonBones.AnimationState#displayControl + * @see dragonBones.AnimationState#name + * @see dragonBones.AnimationState#group + * @version DragonBones 4.5 + */ + displayController: string; + /** + * @private + */ + _zOrder: number; + /** + * @private + */ + _pivotX: number; + /** + * @private + */ + _pivotY: number; + /** + * @private + */ + _displayDataSet: SlotDisplayDataSet; + /** + * @private + */ + _meshData: MeshData; + /** + * @private + */ + _childArmature: Armature; + /** + * @private + */ + _rawDisplay: any; + /** + * @private + */ + _meshDisplay: any; + /** + * @private + */ + _cacheFrames: Array; + /** + * @private + */ + _colorTransform: ColorTransform; + /** + * @private + */ + _ffdVertices: Array; + /** + * @private + */ + _replacedDisplayDataSet: Array; + /** + * @private + */ + protected _displayDirty: boolean; + /** + * @private + */ + protected _blendModeDirty: boolean; + /** + * @private + */ + protected _originDirty: boolean; + /** + * @private + */ + protected _transformDirty: boolean; + /** + * @private + */ + protected _displayIndex: number; + /** + * @private + */ + protected _blendMode: BlendMode; + /** + * @private + */ + protected _display: any; + /** + * @private + */ + protected _localMatrix: Matrix; + /** + * @private + */ + protected _displayList: Array; + /** + * @private + */ + protected _meshBones: Array; + /** + * @inheritDoc + */ + protected _onClear(): void; + /** + * @private + */ + protected abstract _initDisplay(value: any): void; + /** + * @private + */ + protected abstract _disposeDisplay(value: any): void; + /** + * @private + */ + protected abstract _onUpdateDisplay(): void; + /** + * @private + */ + protected abstract _addDisplay(): void; + /** + * @private + */ + protected abstract _replaceDisplay(value: any): void; + /** + * @private + */ + protected abstract _removeDisplay(): void; + /** + * @private + */ + protected abstract _updateZOrder(): void; + /** + * @private + */ + protected abstract _updateBlendMode(): void; + /** + * @private + */ + protected abstract _updateColor(): void; + /** + * @private + */ + protected abstract _updateFilters(): void; + /** + * @private + */ + protected abstract _updateFrame(): void; + /** + * @private + */ + protected abstract _updateMesh(): void; + /** + * @private + */ + protected abstract _updateTransform(): void; + private _isMeshBonesUpdate(); + /** + * @private + */ + protected _updatePivot(rawDisplayData: DisplayData, currentDisplayData: DisplayData, currentTextureData: TextureData): void; + /** + * @private + */ + protected _updateDisplay(): void; + /** + * @private + */ + protected _updateLocalTransformMatrix(): void; + /** + * @private + */ + protected _updateGlobalTransformMatrix(): void; + /** + * @private Factory + */ + _setDisplayList(value: Array): boolean; + /** + * @language zh_CN + * 在下一帧更新显示对象的状态。 + * @version DragonBones 4.5 + */ + invalidUpdate(): void; + /** + * @private + */ + rawDisplay: any; + /** + * @private + */ + MeshDisplay: any; + /** + * @language zh_CN + * 此时显示的显示对象在显示列表中的索引。 + * @version DragonBones 4.5 + */ + displayIndex: number; + /** + * @language zh_CN + * 包含显示对象或子骨架的显示列表。 + * @version DragonBones 3.0 + */ + displayList: Array; + /** + * @language zh_CN + * 此时显示的显示对象。 + * @version DragonBones 3.0 + */ + display: any; + /** + * @language zh_CN + * 此时显示的子骨架。 + * @see dragonBones.Armature + * @version DragonBones 3.0 + */ + childArmature: Armature; + /** + * @deprecated + * @see #display + */ + getDisplay(): any; + /** + * @deprecated + * @see #display + */ + setDisplay(value: any): void; + } +} +declare namespace dragonBones { + /** + * @private + */ + type EventStringType = string | "start" | "loopComplete" | "complete" | "fadeIn" | "fadeInComplete" | "fadeOut" | "fadeOutComplete" | "frameEvent" | "soundEvent"; + /** + * @language zh_CN + * 事件接口。 + * @version DragonBones 4.5 + */ + interface IEventDispatcher { + /** + * @language zh_CN + * 是否包含指定类型的事件。 + * @param type 事件类型。 + * @returns [true: 包含, false: 不包含] + * @version DragonBones 4.5 + */ + hasEvent(type: EventStringType): boolean; + /** + * @language zh_CN + * 添加事件。 + * @param type 事件类型。 + * @param listener 事件回调。 + * @version DragonBones 4.5 + */ + addEvent(type: EventStringType, listener: Function, target: any): void; + /** + * @language zh_CN + * 移除事件。 + * @param type 事件类型。 + * @param listener 事件回调。 + * @version DragonBones 4.5 + */ + removeEvent(type: EventStringType, listener: Function, target: any): void; + } + /** + * @language zh_CN + * 事件数据。 + * @version DragonBones 4.5 + */ + class EventObject extends BaseObject { + /** + * @language zh_CN + * 动画开始。 + * @version DragonBones 4.5 + */ + static START: string; + /** + * @language zh_CN + * 动画循环播放一次完成。 + * @version DragonBones 4.5 + */ + static LOOP_COMPLETE: string; + /** + * @language zh_CN + * 动画播放完成。 + * @version DragonBones 4.5 + */ + static COMPLETE: string; + /** + * @language zh_CN + * 动画淡入开始。 + * @version DragonBones 4.5 + */ + static FADE_IN: string; + /** + * @language zh_CN + * 动画淡入完成。 + * @version DragonBones 4.5 + */ + static FADE_IN_COMPLETE: string; + /** + * @language zh_CN + * 动画淡出开始。 + * @version DragonBones 4.5 + */ + static FADE_OUT: string; + /** + * @language zh_CN + * 动画淡出完成。 + * @version DragonBones 4.5 + */ + static FADE_OUT_COMPLETE: string; + /** + * @language zh_CN + * 动画帧事件。 + * @version DragonBones 4.5 + */ + static FRAME_EVENT: string; + /** + * @language zh_CN + * 动画声音事件。 + * @version DragonBones 4.5 + */ + static SOUND_EVENT: string; + /** + * @private + */ + static toString(): string; + /** + * @language zh_CN + * 事件类型。 + * @version DragonBones 4.5 + */ + type: EventStringType; + /** + * @language zh_CN + * 事件名称。 (帧标签的名称或声音的名称) + * @version DragonBones 4.5 + */ + name: string; + /** + * @language zh_CN + * 扩展的数据。 + * @version DragonBones 4.5 + */ + data: any; + /** + * @language zh_CN + * 发出事件的骨架。 + * @version DragonBones 4.5 + */ + armature: Armature; + /** + * @language zh_CN + * 发出事件的骨骼。 + * @version DragonBones 4.5 + */ + bone: Bone; + /** + * @language zh_CN + * 发出事件的插槽。 + * @version DragonBones 4.5 + */ + slot: Slot; + /** + * @language zh_CN + * 发出事件的动画状态。 + * @version DragonBones 4.5 + */ + animationState: AnimationState; + /** + * @private + */ + frame: AnimationFrameData; + /** + * @language zh_CN + * 用户数据。 + * @version DragonBones 4.5 + */ + userData: any; + /** + * @inheritDoc + */ + protected _onClear(): void; + } +} +declare namespace dragonBones { + /** + * @private + */ + class ColorTransform { + alphaMultiplier: number; + redMultiplier: number; + greenMultiplier: number; + blueMultiplier: number; + alphaOffset: number; + redOffset: number; + greenOffset: number; + blueOffset: number; + constructor(alphaMultiplier?: number, redMultiplier?: number, greenMultiplier?: number, blueMultiplier?: number, alphaOffset?: number, redOffset?: number, greenOffset?: number, blueOffset?: number); + copyFrom(value: ColorTransform): void; + identity(): void; + } +} +declare namespace dragonBones { + /** + * @language zh_CN + * 2D 矩阵。 + * @version DragonBones 3.0 + */ + class Matrix { + a: number; + b: number; + c: number; + d: number; + tx: number; + ty: number; + constructor(a?: number, b?: number, c?: number, d?: number, tx?: number, ty?: number); + /** + * @private + */ + toString(): string; + /** + * @language zh_CN + * 复制矩阵。 + * @param value 需要复制的矩阵。 + * @version DragonBones 3.0 + */ + copyFrom(value: Matrix): void; + /** + * @language zh_CN + * 转换为恒等矩阵。 + * @version DragonBones 3.0 + */ + identity(): void; + /** + * @language zh_CN + * 将当前矩阵与另一个矩阵相乘。 + * @param value 需要相乘的矩阵。 + * @version DragonBones 3.0 + */ + concat(value: Matrix): void; + /** + * @language zh_CN + * 转换为逆矩阵。 + * @version DragonBones 3.0 + */ + invert(): void; + /** + * @language zh_CN + * 将矩阵转换应用于指定点。 + * @param x 横坐标。 + * @param y 纵坐标。 + * @param result 应用转换之后的坐标。 + * @params delta 是否忽略 tx,ty 对坐标的转换。 + * @version DragonBones 3.0 + */ + transformPoint(x: number, y: number, result: { + x: number; + y: number; + }, delta?: boolean): void; + } +} +declare namespace dragonBones { + /** + * @private + */ + class Point { + x: number; + y: number; + constructor(x?: number, y?: number); + copyFrom(value: Point): void; + clear(): void; + } +} +declare namespace dragonBones { + /** + * @private + */ + class Rectangle { + x: number; + y: number; + width: number; + height: number; + constructor(x?: number, y?: number, width?: number, height?: number); + copyFrom(value: Rectangle): void; + clear(): void; + } +} +declare namespace dragonBones { + /** + * @language zh_CN + * 2D 变换。 + * @version DragonBones 3.0 + */ + class Transform { + /** + * @language zh_CN + * 水平位移。 + * @version DragonBones 3.0 + */ + x: number; + /** + * @language zh_CN + * 垂直位移。 + * @version DragonBones 3.0 + */ + y: number; + /** + * @language zh_CN + * 水平倾斜。 (以弧度为单位) + * @version DragonBones 3.0 + */ + skewX: number; + /** + * @language zh_CN + * 垂直倾斜。 (以弧度为单位) + * @version DragonBones 3.0 + */ + skewY: number; + /** + * @language zh_CN + * 水平缩放。 + * @version DragonBones 3.0 + */ + scaleX: number; + /** + * @language zh_CN + * 垂直缩放。 + * @version DragonBones 3.0 + */ + scaleY: number; + /** + * @private + */ + static normalizeRadian(value: number): number; + /** + * @private + */ + constructor( + /** + * @language zh_CN + * 水平位移。 + * @version DragonBones 3.0 + */ + x?: number, + /** + * @language zh_CN + * 垂直位移。 + * @version DragonBones 3.0 + */ + y?: number, + /** + * @language zh_CN + * 水平倾斜。 (以弧度为单位) + * @version DragonBones 3.0 + */ + skewX?: number, + /** + * @language zh_CN + * 垂直倾斜。 (以弧度为单位) + * @version DragonBones 3.0 + */ + skewY?: number, + /** + * @language zh_CN + * 水平缩放。 + * @version DragonBones 3.0 + */ + scaleX?: number, + /** + * @language zh_CN + * 垂直缩放。 + * @version DragonBones 3.0 + */ + scaleY?: number); + /** + * @private + */ + toString(): string; + /** + * @private + */ + copyFrom(value: Transform): Transform; + /** + * @private + */ + identity(): Transform; + /** + * @private + */ + add(value: Transform): Transform; + /** + * @private + */ + minus(value: Transform): Transform; + /** + * @private + */ + fromMatrix(matrix: Matrix): Transform; + /** + * @language zh_CN + * 转换为矩阵。 + * @param 矩阵。 + * @version DragonBones 3.0 + */ + toMatrix(matrix: Matrix): Transform; + /** + * @language zh_CN + * 旋转。 (以弧度为单位) + * @version DragonBones 3.0 + */ + rotation: number; + } +} +declare namespace dragonBones { + /** + * @private + */ + abstract class TimelineData> extends BaseObject { + /** + * @private + */ + static toString(): string; + scale: number; + /** + * @private + */ + offset: number; + /** + * @private + */ + frames: Array; + constructor(); + /** + * @inheritDoc + */ + protected _onClear(): void; + } + /** + * @private + */ + class ZOrderTimelineData extends TimelineData { + static toString(): string; + } + /** + * @private + */ + class BoneTimelineData extends TimelineData { + static cacheFrame(cacheFrames: Array, cacheFrameIndex: number, globalTransformMatrix: Matrix): Matrix; + static toString(): string; + bone: BoneData; + originalTransform: Transform; + cachedFrames: Array; + constructor(); + /** + * @inheritDoc + */ + protected _onClear(): void; + cacheFrames(cacheFrameCount: number): void; + } + /** + * @private + */ + class SlotTimelineData extends TimelineData { + static cacheFrame(cacheFrames: Array, cacheFrameIndex: number, globalTransformMatrix: Matrix): Matrix; + static toString(): string; + slot: SlotData; + cachedFrames: Array; + constructor(); + /** + * @inheritDoc + */ + protected _onClear(): void; + cacheFrames(cacheFrameCount: number): void; + } + /** + * @private + */ + class FFDTimelineData extends TimelineData { + static toString(): string; + displayIndex: number; + skin: SkinData; + slot: SlotDisplayDataSet; + constructor(); + /** + * @inheritDoc + */ + protected _onClear(): void; + } +} +declare namespace dragonBones { + /** + * @language zh_CN + * 动画数据。 + * @version DragonBones 3.0 + */ + class AnimationData extends TimelineData { + /** + * @private + */ + static toString(): string; + /** + * @private + */ + hasAsynchronyTimeline: boolean; + /** + * @language zh_CN + * 持续的帧数。 + * @version DragonBones 3.0 + */ + frameCount: number; + /** + * @language zh_CN + * 循环播放的次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次] + * @version DragonBones 3.0 + */ + playTimes: number; + /** + * @language zh_CN + * 开始的时间。 (以秒为单位) + * @version DragonBones 3.0 + */ + position: number; + /** + * @language zh_CN + * 持续的时间。 (以秒为单位) + * @version DragonBones 3.0 + */ + duration: number; + /** + * @language zh_CN + * 淡入混合的时间。 (以秒为单位) + * @version DragonBones 3.0 + */ + fadeInTime: number; + /** + * @private + */ + cacheTimeToFrameScale: number; + /** + * @language zh_CN + * 数据名称。 + * @version DragonBones 3.0 + */ + name: string; + /** + * @private + */ + animation: AnimationData; + /** + * @private + */ + zOrderTimeline: TimelineData; + /** + * @private + */ + boneTimelines: Map; + /** + * @private + */ + slotTimelines: Map; + /** + * @private + */ + ffdTimelines: Map>>; + /** + * @private + */ + cachedFrames: Array; + /** + * @private + */ + constructor(); + /** + * @inheritDoc + */ + protected _onClear(): void; + /** + * @private + */ + cacheFrames(value: number): void; + /** + * @private + */ + addBoneTimeline(value: BoneTimelineData): void; + /** + * @private + */ + addSlotTimeline(value: SlotTimelineData): void; + /** + * @private + */ + addFFDTimeline(value: FFDTimelineData): void; + /** + * @private + */ + getBoneTimeline(name: string): BoneTimelineData; + /** + * @private + */ + getSlotTimeline(name: string): SlotTimelineData; + /** + * @private + */ + getFFDTimeline(skinName: string, slotName: string, displayIndex: number): FFDTimelineData; + } +} +declare namespace dragonBones { + /** + * @language zh_CN + * 骨架数据。 + * @see dragonBones.Armature + * @version DragonBones 3.0 + */ + class ArmatureData extends BaseObject { + private static _onSortSlots(a, b); + /** + * @private + */ + static toString(): string; + /** + * @language zh_CN + * 动画帧率。 + * @version DragonBones 3.0 + */ + frameRate: number; + /** + * @language zh_CN + * 骨架类型。 + * @see dragonBones.ArmatureType + * @version DragonBones 3.0 + */ + type: ArmatureType; + /** + * @language zh_CN + * 数据名称。 + * @version DragonBones 3.0 + */ + name: string; + /** + * @private + */ + parent: DragonBonesData; + /** + * @private + */ + userData: any; + /** + * @private + */ + aabb: Rectangle; + /** + * @language zh_CN + * 所有的骨骼数据。 + * @see dragonBones.BoneData + * @version DragonBones 3.0 + */ + bones: Map; + /** + * @language zh_CN + * 所有的插槽数据。 + * @see dragonBones.SlotData + * @version DragonBones 3.0 + */ + slots: Map; + /** + * @language zh_CN + * 所有的皮肤数据。 + * @see dragonBones.SkinData + * @version DragonBones 3.0 + */ + skins: Map; + /** + * @language zh_CN + * 所有的动画数据。 + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + */ + animations: Map; + /** + * @private + */ + actions: Array; + /** + * @private + */ + cacheFrameRate: number; + /** + * @private + */ + scale: number; + private _boneDirty; + private _slotDirty; + private _defaultSkin; + private _defaultAnimation; + private _sortedBones; + private _sortedSlots; + private _bonesChildren; + /** + * @private + */ + constructor(); + /** + * @inheritDoc + */ + protected _onClear(): void; + private _sortBones(); + private _sortSlots(); + /** + * @private + */ + cacheFrames(value: number): void; + /** + * @private + */ + addBone(value: BoneData, parentName: string): void; + /** + * @private + */ + addSlot(value: SlotData): void; + /** + * @private + */ + addSkin(value: SkinData): void; + /** + * @private + */ + addAnimation(value: AnimationData): void; + /** + * @language zh_CN + * 获取指定名称的骨骼数据。 + * @param name 骨骼数据名称。 + * @see dragonBones.BoneData + * @version DragonBones 3.0 + */ + getBone(name: string): BoneData; + /** + * @language zh_CN + * 获取指定名称的插槽数据。 + * @param name 插槽数据名称。 + * @see dragonBones.SlotData + * @version DragonBones 3.0 + */ + getSlot(name: string): SlotData; + /** + * @language zh_CN + * 获取指定名称的皮肤数据。 + * @param name 皮肤数据名称。 + * @see dragonBones.SkinData + * @version DragonBones 3.0 + */ + getSkin(name: string): SkinData; + /** + * @language zh_CN + * 获取指定名称的动画数据。 + * @param name 动画数据名称。 + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + */ + getAnimation(name: string): AnimationData; + /** + * @private + */ + sortedBones: Array; + /** + * @private + */ + sortedSlots: Array; + /** + * @language zh_CN + * 获取默认的皮肤数据。 + * @see dragonBones.SkinData + * @version DragonBones 4.5 + */ + defaultSkin: SkinData; + /** + * @language zh_CN + * 获取默认的动画数据。 + * @see dragonBones.AnimationData + * @version DragonBones 4.5 + */ + defaultAnimation: AnimationData; + } + /** + * @language zh_CN + * 骨骼数据。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + */ + class BoneData extends BaseObject { + /** + * @private + */ + static toString(): string; + /** + * @private + */ + inheritTranslation: boolean; + /** + * @private + */ + inheritRotation: boolean; + /** + * @private + */ + inheritScale: boolean; + /** + * @private + */ + bendPositive: boolean; + /** + * @private + */ + chain: number; + /** + * @private + */ + chainIndex: number; + /** + * @private + */ + weight: number; + /** + * @private + */ + length: number; + /** + * @language zh_CN + * 数据名称。 + * @version DragonBones 3.0 + */ + name: string; + /** + * @language zh_CN + * 所属的父骨骼数据。 + * @version DragonBones 3.0 + */ + parent: BoneData; + /** + * @private + */ + ik: BoneData; + /** + * @private + */ + transform: Transform; + /** + * @private + */ + constructor(); + /** + * @inheritDoc + */ + protected _onClear(): void; + } + /** + * @language zh_CN + * 插槽数据。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + */ + class SlotData extends BaseObject { + /** + * @private + */ + static DEFAULT_COLOR: ColorTransform; + /** + * @private + */ + static generateColor(): ColorTransform; + /** + * @private + */ + static toString(): string; + /** + * @private + */ + displayIndex: number; + /** + * @private + */ + zOrder: number; + /** + * @private + */ + blendMode: BlendMode; + /** + * @language zh_CN + * 数据名称。 + * @version DragonBones 3.0 + */ + name: string; + /** + * @language zh_CN + * 所属的父骨骼数据。 + * @see dragonBones.BoneData + * @version DragonBones 3.0 + */ + parent: BoneData; + /** + * @private + */ + color: ColorTransform; + /** + * @private + */ + actions: Array; + /** + * @private + */ + constructor(); + /** + * @inheritDoc + */ + protected _onClear(): void; + } + /** + * @language zh_CN + * 皮肤数据。 + * @version DragonBones 3.0 + */ + class SkinData extends BaseObject { + /** + * @private + */ + static toString(): string; + /** + * @language zh_CN + * 数据名称。 + * @version DragonBones 3.0 + */ + name: string; + /** + * @private + */ + slots: Map; + /** + * @private + */ + constructor(); + /** + * @inheritDoc + */ + protected _onClear(): void; + /** + * @private + */ + addSlot(value: SlotDisplayDataSet): void; + /** + * @private + */ + getSlot(name: string): SlotDisplayDataSet; + } + /** + * @private + */ + class SlotDisplayDataSet extends BaseObject { + static toString(): string; + slot: SlotData; + displays: Array; + constructor(); + /** + * @inheritDoc + */ + protected _onClear(): void; + } + /** + * @private + */ + class DisplayData extends BaseObject { + static toString(): string; + isRelativePivot: boolean; + type: DisplayType; + name: string; + texture: TextureData; + armature: ArmatureData; + mesh: MeshData; + pivot: Point; + transform: Transform; + constructor(); + /** + * @inheritDoc + */ + protected _onClear(): void; + } + /** + * @private + */ + class MeshData extends BaseObject { + static toString(): string; + skinned: boolean; + slotPose: Matrix; + uvs: Array; + vertices: Array; + vertexIndices: Array; + boneIndices: Array>; + weights: Array>; + boneVertices: Array>; + bones: Array; + inverseBindPose: Array; + constructor(); + /** + * @inheritDoc + */ + protected _onClear(): void; + } +} +declare namespace dragonBones { + /** + * @language zh_CN + * 龙骨数据,包含多个骨架数据。 + * @see dragonBones.ArmatureData + * @version DragonBones 3.0 + */ + class DragonBonesData extends BaseObject { + /** + * @private + */ + static toString(): string; + /** + * @language zh_CN + * 是否开启共享搜索。 [true: 开启, false: 不开启] + * @default false + * @see dragonBones.ArmatureData + * @version DragonBones 4.5 + */ + autoSearch: boolean; + /** + * @language zh_CN + * 动画帧频。 + * @version DragonBones 3.0 + */ + frameRate: number; + /** + * @language zh_CN + * 数据名称。 + * @version DragonBones 3.0 + */ + name: string; + /** + * @language zh_CN + * 所有的骨架数据。 + * @see dragonBones.ArmatureData + * @version DragonBones 3.0 + */ + armatures: Map; + private _armatureNames; + /** + * @inheritDoc + */ + protected _onClear(): void; + /** + * @language zh_CN + * 获取指定名称的骨架。 + * @param name 骨架数据骨架名称。 + * @see dragonBones.ArmatureData + * @version DragonBones 3.0 + */ + getArmature(name: string): ArmatureData; + /** + * @language zh_CN + * 所有的骨架数据名称。 + * @see #armatures + * @version DragonBones 3.0 + */ + armatureNames: Array; + /** + * @deprecated + * @see dragonBones.BaseFactory#removeDragonBonesData() + */ + dispose(): void; + } +} +declare namespace dragonBones { + /** + * @private + */ + class ActionData extends BaseObject { + static toString(): string; + type: ActionType; + bone: BoneData; + slot: SlotData; + data: Array; + constructor(); + protected _onClear(): void; + } + /** + * @private + */ + class EventData extends BaseObject { + static toString(): string; + type: EventType; + name: string; + data: any; + bone: BoneData; + slot: SlotData; + constructor(); + protected _onClear(): void; + } + /** + * @private + */ + abstract class FrameData extends BaseObject { + position: number; + duration: number; + prev: T; + next: T; + constructor(); + /** + * @inheritDoc + */ + protected _onClear(): void; + } + /** + * @private + */ + abstract class TweenFrameData extends FrameData { + static samplingCurve(curve: Array, frameCount: number): Array; + tweenEasing: number; + curve: Array; + constructor(); + /** + * @inheritDoc + */ + protected _onClear(): void; + } + /** + * @private + */ + class AnimationFrameData extends FrameData { + static toString(): string; + actions: Array; + events: Array; + constructor(); + /** + * @inheritDoc + */ + protected _onClear(): void; + } + /** + * @private + */ + class ZOrderFrameData extends FrameData { + zOrder: Array; + constructor(); + /** + * @inheritDoc + */ + protected _onClear(): void; + } + /** + * @private + */ + class BoneFrameData extends TweenFrameData { + static toString(): string; + tweenScale: boolean; + tweenRotate: number; + guideCurve: Array; + transform: Transform; + constructor(); + /** + * @inheritDoc + */ + protected _onClear(): void; + } + /** + * @private + */ + class SlotFrameData extends TweenFrameData { + static DEFAULT_COLOR: ColorTransform; + static generateColor(): ColorTransform; + static toString(): string; + displayIndex: number; + color: ColorTransform; + constructor(); + /** + * @inheritDoc + */ + protected _onClear(): void; + } + /** + * @private + */ + class ExtensionFrameData extends TweenFrameData { + static toString(): string; + type: ExtensionType; + tweens: Array; + keys: Array; + constructor(); + /** + * @inheritDoc + */ + protected _onClear(): void; + } +} +declare namespace dragonBones { + /** + * @private + */ + abstract class DataParser { + protected static DATA_VERSION_2_3: string; + protected static DATA_VERSION_3_0: string; + protected static DATA_VERSION_4_0: string; + protected static DATA_VERSION: string; + protected static TEXTURE_ATLAS: string; + protected static SUB_TEXTURE: string; + protected static FORMAT: string; + protected static IMAGE_PATH: string; + protected static WIDTH: string; + protected static HEIGHT: string; + protected static ROTATED: string; + protected static FRAME_X: string; + protected static FRAME_Y: string; + protected static FRAME_WIDTH: string; + protected static FRAME_HEIGHT: string; + protected static DRADON_BONES: string; + protected static ARMATURE: string; + protected static BONE: string; + protected static IK: string; + protected static SLOT: string; + protected static SKIN: string; + protected static DISPLAY: string; + protected static ANIMATION: string; + protected static Z_ORDER: string; + protected static FFD: string; + protected static FRAME: string; + protected static PIVOT: string; + protected static TRANSFORM: string; + protected static AABB: string; + protected static COLOR: string; + protected static FILTER: string; + protected static VERSION: string; + protected static IS_GLOBAL: string; + protected static FRAME_RATE: string; + protected static TYPE: string; + protected static NAME: string; + protected static PARENT: string; + protected static LENGTH: string; + protected static DATA: string; + protected static DISPLAY_INDEX: string; + protected static BLEND_MODE: string; + protected static INHERIT_TRANSLATION: string; + protected static INHERIT_ROTATION: string; + protected static INHERIT_SCALE: string; + protected static TARGET: string; + protected static BEND_POSITIVE: string; + protected static CHAIN: string; + protected static WEIGHT: string; + protected static FADE_IN_TIME: string; + protected static PLAY_TIMES: string; + protected static SCALE: string; + protected static OFFSET: string; + protected static POSITION: string; + protected static DURATION: string; + protected static TWEEN_EASING: string; + protected static TWEEN_ROTATE: string; + protected static TWEEN_SCALE: string; + protected static CURVE: string; + protected static GUIDE_CURVE: string; + protected static EVENT: string; + protected static SOUND: string; + protected static ACTION: string; + protected static ACTIONS: string; + protected static DEFAULT_ACTIONS: string; + protected static X: string; + protected static Y: string; + protected static SKEW_X: string; + protected static SKEW_Y: string; + protected static SCALE_X: string; + protected static SCALE_Y: string; + protected static ALPHA_OFFSET: string; + protected static RED_OFFSET: string; + protected static GREEN_OFFSET: string; + protected static BLUE_OFFSET: string; + protected static ALPHA_MULTIPLIER: string; + protected static RED_MULTIPLIER: string; + protected static GREEN_MULTIPLIER: string; + protected static BLUE_MULTIPLIER: string; + protected static UVS: string; + protected static VERTICES: string; + protected static TRIANGLES: string; + protected static WEIGHTS: string; + protected static SLOT_POSE: string; + protected static BONE_POSE: string; + protected static TWEEN: string; + protected static KEY: string; + protected static COLOR_TRANSFORM: string; + protected static TIMELINE: string; + protected static PIVOT_X: string; + protected static PIVOT_Y: string; + protected static Z: string; + protected static LOOP: string; + protected static AUTO_TWEEN: string; + protected static HIDE: string; + protected static _getArmatureType(value: string): ArmatureType; + protected static _getDisplayType(value: string): DisplayType; + protected static _getBlendMode(value: string): BlendMode; + protected static _getActionType(value: string): ActionType; + protected _data: DragonBonesData; + protected _armature: ArmatureData; + protected _skin: SkinData; + protected _slotDisplayDataSet: SlotDisplayDataSet; + protected _mesh: MeshData; + protected _animation: AnimationData; + protected _timeline: any; + protected _isOldData: boolean; + protected _isGlobalTransform: boolean; + protected _isAutoTween: boolean; + protected _animationTweenEasing: number; + protected _timelinePivot: Point; + protected _helpPoint: Point; + protected _helpTransformA: Transform; + protected _helpTransformB: Transform; + protected _helpMatrix: Matrix; + protected _rawBones: Array; + constructor(); + /** + * @private + */ + abstract parseDragonBonesData(rawData: any, scale: number): DragonBonesData; + /** + * @private + */ + abstract parseTextureAtlasData(rawData: any, textureAtlasData: TextureAtlasData, scale: number): void; + private _getTimelineFrameMatrix(animation, timeline, position, transform); + protected _globalToLocal(armature: ArmatureData): void; + protected _mergeFrameToAnimationTimeline(framePostion: number, actions: Array, events: Array): void; + /** + * @deprecated + * @see dragonBones.BaseFactory#parseDragonBonesData() + */ + static parseDragonBonesData(rawData: any): DragonBonesData; + /** + * @deprecated + * @see dragonBones.BaseFactory#parsetTextureAtlasData() + */ + static parseTextureAtlasData(rawData: any, scale?: number): any; + } +} +declare namespace dragonBones { + /** + * @private + */ + class ObjectDataParser extends DataParser { + /** + * @private + */ + protected static _getBoolean(rawData: any, key: string, defaultValue: boolean): boolean; + /** + * @private + */ + protected static _getNumber(rawData: any, key: string, defaultValue: number): number; + /** + * @private + */ + protected static _getString(rawData: any, key: string, defaultValue: string): string; + /** + * @private + */ + protected static _getParameter(rawData: Array, index: number, defaultValue: any): any; + /** + * @private + */ + constructor(); + /** + * @private + */ + protected _parseArmature(rawData: any, scale: number): ArmatureData; + /** + * @private + */ + protected _parseBone(rawData: any): BoneData; + /** + * @private + */ + protected _parseIK(rawData: any): void; + /** + * @private + */ + protected _parseSlot(rawData: any, zOrder: number): SlotData; + /** + * @private + */ + protected _parseSkin(rawData: any): SkinData; + /** + * @private + */ + protected _parseSlotDisplaySet(rawData: any): SlotDisplayDataSet; + /** + * @private + */ + protected _parseDisplay(rawData: any): DisplayData; + /** + * @private + */ + protected _parseMesh(rawData: any): MeshData; + /** + * @private + */ + protected _parseAnimation(rawData: any): AnimationData; + /** + * @private + */ + protected _parseBoneTimeline(rawData: any): BoneTimelineData; + /** + * @private + */ + protected _parseSlotTimeline(rawData: any): SlotTimelineData; + /** + * @private + */ + protected _parseFFDTimeline(rawData: any): FFDTimelineData; + /** + * @private + */ + protected _parseAnimationFrame(rawData: any, frameStart: number, frameCount: number): AnimationFrameData; + /** + * @private + */ + protected _parseZOrderFrame(rawData: any, frameStart: number, frameCount: number): ZOrderFrameData; + /** + * @private + */ + protected _parseBoneFrame(rawData: Object, frameStart: number, frameCount: number): BoneFrameData; + /** + * @private + */ + protected _parseSlotFrame(rawData: any, frameStart: number, frameCount: number): SlotFrameData; + /** + * @private + */ + protected _parseFFDFrame(rawData: any, frameStart: number, frameCount: number): ExtensionFrameData; + /** + * @private + */ + protected _parseTweenFrame>(rawData: any, frame: T, frameStart: number, frameCount: number): void; + /** + * @private + */ + protected _parseFrame>(rawData: any, frame: T, frameStart: number, frameCount: number): void; + /** + * @private + */ + protected _parseTimeline>(rawData: Object, timeline: TimelineData, frameParser: (rawData: any, frameStart: number, frameCount: number) => T): void; + /** + * @private + */ + protected _parseActionData(rawData: any, actions: Array, bone: BoneData, slot: SlotData): void; + /** + * @private + */ + protected _parseEventData(rawData: any, events: Array, bone: BoneData, slot: SlotData): void; + /** + * @private + */ + protected _parseTransform(rawData: Object, transform: Transform): void; + /** + * @private + */ + protected _parseColorTransform(rawData: Object, color: ColorTransform): void; + /** + * @inheritDoc + */ + parseDragonBonesData(rawData: any, scale?: number): DragonBonesData; + /** + * @inheritDoc + */ + parseTextureAtlasData(rawData: any, textureAtlasData: TextureAtlasData, scale?: number): void; + /** + * @private + */ + private static _instance; + /** + * @deprecated + * @see dragonBones.BaseFactory#parseDragonBonesData() + */ + static getInstance(): ObjectDataParser; + } +} +declare namespace dragonBones { + /** + * @language zh_CN + * 贴图集数据。 + * @version DragonBones 3.0 + */ + abstract class TextureAtlasData extends BaseObject { + /** + * @language zh_CN + * 是否开启共享搜索。 [true: 开启, false: 不开启] + * @default false + * @version DragonBones 4.5 + */ + autoSearch: boolean; + /** + * @language zh_CN + * 贴图集缩放系数。 + * @version DragonBones 3.0 + */ + scale: number; + /** + * @language zh_CN + * 贴图集名称。 + * @version DragonBones 3.0 + */ + name: string; + /** + * @language zh_CN + * 贴图集图片路径。 + * @version DragonBones 3.0 + */ + imagePath: string; + /** + * @inheritDoc + */ + protected _onClear(): void; + /** + * @private + */ + getTexture(name: string): TextureData; + } + /** + * @private + */ + abstract class TextureData extends BaseObject { + static generateRectangle(): Rectangle; + rotated: boolean; + name: string; + frame: Rectangle; + parent: TextureAtlasData; + region: Rectangle; + constructor(); + /** + * @inheritDoc + */ + protected _onClear(): void; + } +} +declare namespace dragonBones { + /** + * @private + */ + type BuildArmaturePackage = { + dataName?: string; + textureAtlasName?: string; + data?: DragonBonesData; + armature?: ArmatureData; + skin?: SkinData; + }; + /** + * @language zh_CN + * 创建骨架的基础工厂。 (通常只需要一个全局工厂实例) + * @see dragonBones.DragonBonesData + * @see dragonBones.TextureAtlasData + * @see dragonBones.ArmatureData + * @see dragonBones.Armature + * @version DragonBones 3.0 + */ + abstract class BaseFactory { + protected static _defaultParser: ObjectDataParser; + /** + * @language zh_CN + * 是否开启共享搜索。 [true: 开启, false: 不开启] + * 如果开启,创建一个骨架时,可以从多个龙骨数据中寻找骨架数据,或贴图集数据中寻找贴图数据。 (通常在有共享导出的数据时开启) + * @see dragonBones.DragonBonesData#autoSearch + * @see dragonBones.TextureAtlasData#autoSearch + * @version DragonBones 4.5 + */ + autoSearch: boolean; + /** + * @private + */ + protected _dataParser: DataParser; + /** + * @private + */ + protected _dragonBonesDataMap: Map; + /** + * @private + */ + protected _textureAtlasDataMap: Map>; + /** + * @private + */ + constructor(dataParser?: DataParser); + /** + * @private + */ + protected _getTextureData(textureAtlasName: string, textureName: string): TextureData; + /** + * @private + */ + protected _fillBuildArmaturePackage(dataPackage: BuildArmaturePackage, dragonBonesName: string, armatureName: string, skinName: string, textureAtlasName: string): boolean; + /** + * @private + */ + protected _buildBones(dataPackage: BuildArmaturePackage, armature: Armature): void; + /** + * @private + */ + protected _buildSlots(dataPackage: BuildArmaturePackage, armature: Armature): void; + /** + * @private + */ + protected _replaceSlotDisplay(dataPackage: BuildArmaturePackage, displayData: DisplayData, slot: Slot, displayIndex: number): void; + /** + * @private + */ + protected abstract _generateTextureAtlasData(textureAtlasData: TextureAtlasData, textureAtlas: any): TextureAtlasData; + /** + * @private + */ + protected abstract _generateArmature(dataPackage: BuildArmaturePackage): Armature; + /** + * @private + */ + protected abstract _generateSlot(dataPackage: BuildArmaturePackage, slotDisplayDataSet: SlotDisplayDataSet, armature: Armature): Slot; + /** + * @language zh_CN + * 解析并添加龙骨数据。 + * @param rawData 需要解析的原始数据。 (JSON) + * @param name 为数据提供一个名称,以便可以通过这个名称获取数据,如果未设置,则使用数据中的名称。 + * @returns DragonBonesData + * @see #getDragonBonesData() + * @see #addDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 4.5 + */ + parseDragonBonesData(rawData: any, name?: string, scale?: number): DragonBonesData; + /** + * @language zh_CN + * 解析并添加贴图集数据。 + * @param rawData 需要解析的原始数据。 (JSON) + * @param textureAtlas 贴图集数据。 (JSON) + * @param name 为数据指定一个名称,以便可以通过这个名称获取数据,如果未设置,则使用数据中的名称。 + * @param scale 为贴图集设置一个缩放值。 + * @returns 贴图集数据 + * @see #getTextureAtlasData() + * @see #addTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 4.5 + */ + parseTextureAtlasData(rawData: any, textureAtlas: Object, name?: string, scale?: number): TextureAtlasData; + /** + * @language zh_CN + * 获取指定名称的龙骨数据。 + * @param name 数据名称。 + * @returns DragonBonesData + * @see #parseDragonBonesData() + * @see #addDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + */ + getDragonBonesData(name: string): DragonBonesData; + /** + * @language zh_CN + * 添加龙骨数据。 + * @param data 龙骨数据。 + * @param name 为数据指定一个名称,以便可以通过这个名称获取数据,如果未设置,则使用数据中的名称。 + * @see #parseDragonBonesData() + * @see #getDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + */ + addDragonBonesData(data: DragonBonesData, name?: string): void; + /** + * @language zh_CN + * 移除龙骨数据。 + * @param name 数据名称。 + * @param disposeData 是否释放数据。 [false: 不释放, true: 释放] + * @see #parseDragonBonesData() + * @see #getDragonBonesData() + * @see #addDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + */ + removeDragonBonesData(name: string, disposeData?: boolean): void; + /** + * @language zh_CN + * 获取指定名称的贴图集数据列表。 + * @param name 数据名称。 + * @returns 贴图集数据列表。 + * @see #parseTextureAtlasData() + * @see #addTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.textures.TextureAtlasData + * @version DragonBones 3.0 + */ + getTextureAtlasData(name: string): Array; + /** + * @language zh_CN + * 添加贴图集数据。 + * @param data 贴图集数据。 + * @param name 为数据指定一个名称,以便可以通过这个名称获取数据,如果未设置,则使用数据中的名称。 + * @see #parseTextureAtlasData() + * @see #getTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.textures.TextureAtlasData + * @version DragonBones 3.0 + */ + addTextureAtlasData(data: TextureAtlasData, name?: string): void; + /** + * @language zh_CN + * 移除贴图集数据。 + * @param name 数据名称。 + * @param disposeData 是否释放数据。 [false: 不释放, true: 释放] + * @see #parseTextureAtlasData() + * @see #getTextureAtlasData() + * @see #addTextureAtlasData() + * @see dragonBones.textures.TextureAtlasData + * @version DragonBones 3.0 + */ + removeTextureAtlasData(name: string, disposeData?: boolean): void; + /** + * @language zh_CN + * 清除所有的数据。 + * @param disposeData 是否释放数据。 [false: 不释放, true: 释放] + * @version DragonBones 4.5 + */ + clear(disposeData?: boolean): void; + /** + * @language zh_CN + * 创建一个指定名称的骨架。 + * @param armatureName 骨架数据名称。 + * @param dragonBonesName 龙骨数据名称,如果未设置,将检索所有的龙骨数据,当多个龙骨数据中包含同名的骨架数据时,可能无法创建出准确的骨架。 + * @param skinName 皮肤名称,如果未设置,则使用默认皮肤。 + * @param textureAtlasName 贴图集数据名称,如果未设置,则使用龙骨数据。 + * @returns 骨架 + * @see dragonBones.Armature + * @version DragonBones 3.0 + */ + buildArmature(armatureName: string, dragonBonesName?: string, skinName?: string, textureAtlasName?: string): Armature; + /** + * @language zh_CN + * 将指定骨架的动画替换成其他骨架的动画。 (通常这些骨架应该具有相同的骨架结构) + * @param toArmature 指定的骨架。 + * @param fromArmatreName 其他骨架的名称。 + * @param fromSkinName 其他骨架的皮肤名称,如果未设置,则使用默认皮肤。 + * @param fromDragonBonesDataName 其他骨架属于的龙骨数据名称,如果未设置,则检索所有的龙骨数据。 + * @param ifRemoveOriginalAnimationList 是否移除原有的动画。 [true: 移除, false: 不移除] + * @returns 是否替换成功。 [true: 成功, false: 不成功] + * @see dragonBones.Armature + * @version DragonBones 4.5 + */ + copyAnimationsToArmature(toArmature: Armature, fromArmatreName: string, fromSkinName?: string, fromDragonBonesDataName?: string, ifRemoveOriginalAnimationList?: boolean): boolean; + /** + * @language zh_CN + * 将指定插槽的显示对象替换为指定资源创造出的显示对象。 + * @param dragonBonesName 指定的龙骨数据名称。 + * @param armatureName 指定的骨架名称。 + * @param slotName 指定的插槽名称。 + * @param displayName 指定的显示对象名称。 + * @param slot 指定的插槽实例。 + * @param displayIndex 要替换的显示对象的索引,如果未设置,则替换当前正在显示的显示对象。 + * @version DragonBones 4.5 + */ + replaceSlotDisplay(dragonBonesName: string, armatureName: string, slotName: string, displayName: string, slot: Slot, displayIndex?: number): void; + /** + * @language zh_CN + * 将指定插槽的显示对象列表替换为指定资源创造出的显示对象列表。 + * @param dragonBonesName 指定的 DragonBonesData 名称。 + * @param armatureName 指定的骨架名称。 + * @param slotName 指定的插槽名称。 + * @param slot 指定的插槽实例。 + * @version DragonBones 4.5 + */ + replaceSlotDisplayList(dragonBonesName: string, armatureName: string, slotName: string, slot: Slot): void; + /** + * @private + */ + getAllDragonBonesData(): Map; + /** + * @private + */ + getAllTextureAtlasData(): Map>; + } +} + +declare let jsb: any; +/** Running in the editor. */ +declare let CC_EDITOR: boolean; +/** Preview in browser or simulator. */ +declare let CC_PREVIEW: boolean; +/** Running in the editor or preview. */ +declare let CC_DEV: boolean; +/** Running in the editor or preview, or build in debug mode. */ +declare let CC_DEBUG: boolean; +/** Running in published project. */ +declare let CC_BUILD: boolean; +/** Running in native platform (mobile app, desktop app, or simulator). */ +declare let CC_JSB: boolean; +/** Running in the engine's unit test. */ +declare let CC_TEST: boolean; diff --git a/BigNumber64Demo/jsconfig.json b/BigNumber64Demo/jsconfig.json new file mode 100644 index 0000000..80c2563 --- /dev/null +++ b/BigNumber64Demo/jsconfig.json @@ -0,0 +1,15 @@ +{ + "compilerOptions": { + "target": "es6", + "module": "commonjs", + "experimentalDecorators": true + }, + "exclude": [ + "node_modules", + ".vscode", + "library", + "local", + "settings", + "temp" + ] +} \ No newline at end of file diff --git a/BigNumber64Demo/project.json b/BigNumber64Demo/project.json new file mode 100644 index 0000000..4257d04 --- /dev/null +++ b/BigNumber64Demo/project.json @@ -0,0 +1,4 @@ +{ + "engine": "cocos2d-html5", + "packages": "packages" +} \ No newline at end of file diff --git a/BigNumber64Demo/settings/builder.json b/BigNumber64Demo/settings/builder.json new file mode 100644 index 0000000..09f915c --- /dev/null +++ b/BigNumber64Demo/settings/builder.json @@ -0,0 +1,13 @@ +{ + "excludeScenes": [], + "orientation": { + "landscapeLeft": true, + "landscapeRight": true, + "portrait": false, + "upsideDown": false + }, + "packageName": "org.cocos2d.helloworld", + "startScene": "2d2f792f-a40c-49bb-a189-ed176a246e49", + "title": "hello_world", + "webOrientation": "auto" +} \ No newline at end of file diff --git a/BigNumber64Demo/settings/builder.panel.json b/BigNumber64Demo/settings/builder.panel.json new file mode 100644 index 0000000..6a7c356 --- /dev/null +++ b/BigNumber64Demo/settings/builder.panel.json @@ -0,0 +1,7 @@ +{ + "excludeScenes": [], + "packageName": "org.cocos2d.helloworld", + "platform": "web-mobile", + "startScene": "2d2f792f-a40c-49bb-a189-ed176a246e49", + "title": "HelloWorld" +} \ No newline at end of file diff --git a/BigNumber64Demo/settings/project.json b/BigNumber64Demo/settings/project.json new file mode 100644 index 0000000..ac399c6 --- /dev/null +++ b/BigNumber64Demo/settings/project.json @@ -0,0 +1,28 @@ +{ + "collision-matrix": [ + [ + true + ] + ], + "excluded-modules": [], + "group-list": [ + "default" + ], + "start-scene": "current", + "design-resolution-width": 960, + "design-resolution-height": 640, + "fit-width": false, + "fit-height": true, + "use-project-simulator-setting": false, + "simulator-orientation": false, + "use-customize-simulator": false, + "simulator-resolution": { + "width": 960, + "height": 640 + }, + "cocos-analytics": { + "enable": false, + "appID": "13798", + "appSecret": "959b3ac0037d0f3c2fdce94f8421a9b2" + } +} \ No newline at end of file diff --git a/BigNumber64Demo/template-banner.png b/BigNumber64Demo/template-banner.png new file mode 100644 index 0000000..d24a435 Binary files /dev/null and b/BigNumber64Demo/template-banner.png differ diff --git a/BigNumber64Demo/template.json b/BigNumber64Demo/template.json new file mode 100644 index 0000000..3bcc784 --- /dev/null +++ b/BigNumber64Demo/template.json @@ -0,0 +1,5 @@ +{ + "name": "TEMPLATES.helloworld.name", + "desc": "TEMPLATES.helloworld.desc", + "banner": "template-banner.png" +} \ No newline at end of file diff --git a/ButtonDemo/.gitignore b/ButtonDemo/.gitignore new file mode 100644 index 0000000..a231b3f --- /dev/null +++ b/ButtonDemo/.gitignore @@ -0,0 +1,24 @@ + +#/////////////////////////// +# Cocos Creator 3D Project +#/////////////////////////// +library/ +temp/ +local/ +build/ +profiles/ +native +#////////////////////////// +# NPM +#////////////////////////// +node_modules/ + +#////////////////////////// +# VSCode +#////////////////////////// +.vscode/ + +#////////////////////////// +# WebStorm +#////////////////////////// +.idea/ \ No newline at end of file diff --git a/ButtonDemo/assets/scenes.meta b/ButtonDemo/assets/scenes.meta new file mode 100644 index 0000000..be7b8ed --- /dev/null +++ b/ButtonDemo/assets/scenes.meta @@ -0,0 +1,12 @@ +{ + "ver": "1.1.0", + "importer": "directory", + "imported": true, + "uuid": "3b99d03a-13c2-4098-bcbb-07ba558cc36d", + "files": [], + "subMetas": {}, + "userData": { + "compressionType": {}, + "isRemoteBundle": {} + } +} diff --git a/ButtonDemo/assets/scenes/scene.scene b/ButtonDemo/assets/scenes/scene.scene new file mode 100644 index 0000000..d57ac36 --- /dev/null +++ b/ButtonDemo/assets/scenes/scene.scene @@ -0,0 +1,1057 @@ +[ + { + "__type__": "cc.SceneAsset", + "_name": "", + "_objFlags": 0, + "_native": "", + "scene": { + "__id__": 1 + } + }, + { + "__type__": "cc.Scene", + "_name": "", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + } + ], + "_active": true, + "_components": [], + "_prefab": null, + "autoReleaseAssets": false, + "_globals": { + "__id__": 40 + }, + "_id": "f46876e4-e81b-4931-b493-6d367be385e7" + }, + { + "__type__": "cc.Node", + "_name": "Canvas", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 3 + }, + { + "__id__": 5 + }, + { + "__id__": 18 + }, + { + "__id__": 28 + } + ], + "_active": true, + "_components": [ + { + "__id__": 33 + }, + { + "__id__": 35 + }, + { + "__id__": 37 + }, + { + "__id__": 39 + } + ], + "_prefab": null, + "_lpos": { + "__type__": "cc.Vec3", + "x": 480, + "y": 320, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 33554432, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "3fYAmXJJ1JOZ0YqrPb9xoo" + }, + { + "__type__": "cc.Node", + "_name": "Camera", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 4 + } + ], + "_prefab": null, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 1000 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "6bpxy4/gFKkZ7gYASTyH/4" + }, + { + "__type__": "cc.Camera", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 3 + }, + "_enabled": true, + "__prefab": null, + "_projection": 0, + "_priority": 1073741824, + "_fov": 45, + "_fovAxis": 0, + "_orthoHeight": 320, + "_near": 1, + "_far": 2000, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_depth": 1, + "_stencil": 0, + "_clearFlags": 6, + "_rect": { + "__type__": "cc.Rect", + "x": 0, + "y": 0, + "width": 1, + "height": 1 + }, + "_aperture": 19, + "_shutter": 7, + "_iso": 0, + "_screenScale": 1, + "_visibility": 41943040, + "_targetTexture": null, + "_id": "67bLDNuKtASoWrrj8dWP+c" + }, + { + "__type__": "cc.Node", + "_name": "Button-1", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [ + { + "__id__": 6 + } + ], + "_active": true, + "_components": [ + { + "__id__": 11 + }, + { + "__id__": 13 + }, + { + "__id__": 15 + } + ], + "_prefab": null, + "_lpos": { + "__type__": "cc.Vec3", + "x": -200, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 33554432, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "69pZ1+mNBPcoh3cn7p/jBD" + }, + { + "__type__": "cc.Node", + "_name": "Label", + "_objFlags": 512, + "_parent": { + "__id__": 5 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 7 + }, + { + "__id__": 9 + } + ], + "_prefab": null, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 33554432, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "f8lvpKnVZBqKN6PW+FYgw8" + }, + { + "__type__": "cc.UITransform", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 6 + }, + "_enabled": true, + "__prefab": { + "__id__": 8 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_id": "aa7nsqjS1NebE2UYkFSwY4" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "07QMd0h1dLcYd/vjigaip6" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 6 + }, + "_enabled": true, + "__prefab": { + "__id__": 10 + }, + "_visFlags": 0, + "_customMaterial": null, + "_srcBlendFactor": 2, + "_dstBlendFactor": 4, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_string": "button 1", + "_horizontalAlign": 1, + "_verticalAlign": 1, + "_actualFontSize": 20, + "_fontSize": 20, + "_fontFamily": "Arial", + "_lineHeight": 40, + "_overflow": 1, + "_enableWrapText": false, + "_font": null, + "_isSystemFontUsed": true, + "_isItalic": false, + "_isBold": false, + "_isUnderline": false, + "_underlineHeight": 2, + "_cacheMode": 0, + "_id": "04yXdWFzhI9qlKy1d5tKNF" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "ee3IZdy2dLIaAWpjI7P0FL" + }, + { + "__type__": "cc.UITransform", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 5 + }, + "_enabled": true, + "__prefab": { + "__id__": 12 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_id": "63x6vfP25CiJTnLNXYwiEW" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "98TYGMtwRBTYZZn4EZmhzJ" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 5 + }, + "_enabled": true, + "__prefab": { + "__id__": 14 + }, + "_visFlags": 0, + "_customMaterial": null, + "_srcBlendFactor": 2, + "_dstBlendFactor": 4, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_spriteFrame": { + "__uuid__": "20835ba4-6145-4fbc-a58a-051ce700aa3e@f9941", + "__expectedType__": "cc.SpriteFrame" + }, + "_type": 1, + "_fillType": 0, + "_sizeMode": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_useGrayscale": false, + "_atlas": null, + "_id": "0eavQU8kNOZqWV1jpNt+AE" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "77BcV1zfNHo4LI4KRqZupe" + }, + { + "__type__": "cc.Button", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 5 + }, + "_enabled": true, + "__prefab": { + "__id__": 16 + }, + "clickEvents": [ + { + "__id__": 17 + } + ], + "_interactable": true, + "_transition": 2, + "_normalColor": { + "__type__": "cc.Color", + "r": 214, + "g": 214, + "b": 214, + "a": 255 + }, + "_hoverColor": { + "__type__": "cc.Color", + "r": 211, + "g": 211, + "b": 211, + "a": 255 + }, + "_pressedColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_disabledColor": { + "__type__": "cc.Color", + "r": 124, + "g": 124, + "b": 124, + "a": 255 + }, + "_normalSprite": { + "__uuid__": "20835ba4-6145-4fbc-a58a-051ce700aa3e@f9941", + "__expectedType__": "cc.SpriteFrame" + }, + "_hoverSprite": { + "__uuid__": "20835ba4-6145-4fbc-a58a-051ce700aa3e@f9941", + "__expectedType__": "cc.SpriteFrame" + }, + "_pressedSprite": { + "__uuid__": "544e49d6-3f05-4fa8-9a9e-091f98fc2ce8@f9941", + "__expectedType__": "cc.SpriteFrame" + }, + "_disabledSprite": { + "__uuid__": "951249e0-9f16-456d-8b85-a6ca954da16b@f9941", + "__expectedType__": "cc.SpriteFrame" + }, + "_duration": 0.1, + "_zoomScale": 1.2, + "_target": { + "__id__": 5 + }, + "_id": "63dw3DaUlCHp763mCBMrfo" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "2fOwBXUwBNvaJ4NyyrOq4C" + }, + { + "__type__": "cc.ClickEvent", + "target": { + "__id__": 2 + }, + "component": "", + "_componentId": "a59f98tBdxJlJIv2bTQ9DcL", + "handler": "onClick_1", + "customEventData": "" + }, + { + "__type__": "cc.Node", + "_name": "Button-2", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [ + { + "__id__": 19 + } + ], + "_active": true, + "_components": [ + { + "__id__": 24 + }, + { + "__id__": 26 + } + ], + "_prefab": null, + "_lpos": { + "__type__": "cc.Vec3", + "x": 200, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 33554432, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "1cXoTNxW5EU6FmgkYcao4J" + }, + { + "__type__": "cc.Node", + "_name": "Label", + "_objFlags": 512, + "_parent": { + "__id__": 18 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 20 + }, + { + "__id__": 22 + } + ], + "_prefab": null, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 33554432, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "b6Y/GtDfpNoIGRHpZRlyb8" + }, + { + "__type__": "cc.UITransform", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 19 + }, + "_enabled": true, + "__prefab": { + "__id__": 21 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_id": "34pPtRqpBHRoSL4su/I150" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "07QMd0h1dLcYd/vjigaip6" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 19 + }, + "_enabled": true, + "__prefab": { + "__id__": 23 + }, + "_visFlags": 0, + "_customMaterial": null, + "_srcBlendFactor": 2, + "_dstBlendFactor": 4, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_string": "button 1", + "_horizontalAlign": 1, + "_verticalAlign": 1, + "_actualFontSize": 20, + "_fontSize": 20, + "_fontFamily": "Arial", + "_lineHeight": 40, + "_overflow": 1, + "_enableWrapText": false, + "_font": null, + "_isSystemFontUsed": true, + "_isItalic": false, + "_isBold": false, + "_isUnderline": false, + "_underlineHeight": 2, + "_cacheMode": 0, + "_id": "84j1OrUPJH9Ycq3E/3O6eW" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "ee3IZdy2dLIaAWpjI7P0FL" + }, + { + "__type__": "cc.UITransform", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 18 + }, + "_enabled": true, + "__prefab": { + "__id__": 25 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_id": "dd0Itq25VG3Yu2Rv0blQzz" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "98TYGMtwRBTYZZn4EZmhzJ" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 18 + }, + "_enabled": true, + "__prefab": { + "__id__": 27 + }, + "_visFlags": 0, + "_customMaterial": null, + "_srcBlendFactor": 2, + "_dstBlendFactor": 4, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_spriteFrame": { + "__uuid__": "20835ba4-6145-4fbc-a58a-051ce700aa3e@f9941", + "__expectedType__": "cc.SpriteFrame" + }, + "_type": 1, + "_fillType": 0, + "_sizeMode": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_useGrayscale": false, + "_atlas": null, + "_id": "bdRzwiL01FupLjFv5B8ltF" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "77BcV1zfNHo4LI4KRqZupe" + }, + { + "__type__": "cc.Node", + "_name": "Label", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 29 + }, + { + "__id__": 31 + } + ], + "_prefab": null, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": -121.196, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 33554432, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "f59VnDjdtPHKety6DubIZe" + }, + { + "__type__": "cc.UITransform", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 28 + }, + "_enabled": true, + "__prefab": { + "__id__": 30 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 42.26, + "height": 50.4 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_id": "f4cP2lCsFCYqZul2V8MjJV" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "c68UOAlNhN171Umca6yVvF" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 28 + }, + "_enabled": true, + "__prefab": { + "__id__": 32 + }, + "_visFlags": 0, + "_customMaterial": null, + "_srcBlendFactor": 2, + "_dstBlendFactor": 4, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_string": "label", + "_horizontalAlign": 1, + "_verticalAlign": 1, + "_actualFontSize": 20, + "_fontSize": 20, + "_fontFamily": "Arial", + "_lineHeight": 40, + "_overflow": 0, + "_enableWrapText": true, + "_font": null, + "_isSystemFontUsed": true, + "_isItalic": false, + "_isBold": false, + "_isUnderline": false, + "_underlineHeight": 2, + "_cacheMode": 0, + "_id": "2fH47jBTRJk5JYcT4RAhO6" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "2frm37uaJHQr0AEEaYyM82" + }, + { + "__type__": "cc.UITransform", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "__prefab": { + "__id__": 34 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 960, + "height": 640 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_id": "780zTXIOlGQJLJP167JTH5" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "0dngp/9gNO34wUQjZfN/CX" + }, + { + "__type__": "cc.Canvas", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "__prefab": { + "__id__": 36 + }, + "_cameraComponent": { + "__id__": 4 + }, + "_alignCanvasWithScreen": true, + "_id": "09DFLstpdDx61zuX8Yl/0X" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "3f2oTdCepERZdpmIfLsrhd" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "__prefab": { + "__id__": 38 + }, + "_alignFlags": 45, + "_target": null, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_horizontalCenter": 0, + "_verticalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 0, + "_originalHeight": 0, + "_alignMode": 2, + "_lockFlags": 0, + "_id": "b2OfkEKEhHzam4w1rEZlp0" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "e8a+bU/8dPDbbJguUzLdoF" + }, + { + "__type__": "a59f98tBdxJlJIv2bTQ9DcL", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "__prefab": null, + "txt": { + "__id__": 31 + }, + "btn2": { + "__id__": 18 + }, + "btn1": { + "__id__": 15 + }, + "_id": "37XDSn2WRL57OVwK0/QrkW" + }, + { + "__type__": "cc.SceneGlobals", + "ambient": { + "__id__": 41 + }, + "shadows": { + "__id__": 42 + }, + "_skybox": { + "__id__": 43 + }, + "fog": { + "__id__": 44 + } + }, + { + "__type__": "cc.AmbientInfo", + "_skyColor": { + "__type__": "cc.Color", + "r": 51, + "g": 128, + "b": 204, + "a": 1 + }, + "_skyIllum": 20000, + "_groundAlbedo": { + "__type__": "cc.Color", + "r": 51, + "g": 51, + "b": 51, + "a": 255 + } + }, + { + "__type__": "cc.ShadowsInfo", + "_type": 0, + "_enabled": false, + "_normal": { + "__type__": "cc.Vec3", + "x": 0, + "y": 1, + "z": 0 + }, + "_distance": 0, + "_shadowColor": { + "__type__": "cc.Color", + "r": 76, + "g": 76, + "b": 76, + "a": 255 + }, + "_autoAdapt": true, + "_pcf": 0, + "_bias": 0.00001, + "_packing": false, + "_linear": true, + "_selfShadow": false, + "_normalBias": 0, + "_near": 1, + "_far": 30, + "_aspect": 1, + "_orthoSize": 5, + "_maxReceived": 4, + "_size": { + "__type__": "cc.Vec2", + "x": 512, + "y": 512 + } + }, + { + "__type__": "cc.SkyboxInfo", + "_envmap": null, + "_isRGBE": false, + "_enabled": false, + "_useIBL": false + }, + { + "__type__": "cc.FogInfo", + "_type": 0, + "_fogColor": { + "__type__": "cc.Color", + "r": 200, + "g": 200, + "b": 200, + "a": 255 + }, + "_enabled": false, + "_fogDensity": 0.3, + "_fogStart": 0.5, + "_fogEnd": 300, + "_fogAtten": 5, + "_fogTop": 1.5, + "_fogRange": 1.2 + } +] \ No newline at end of file diff --git a/ButtonDemo/assets/scenes/scene.scene.meta b/ButtonDemo/assets/scenes/scene.scene.meta new file mode 100644 index 0000000..d61edb9 --- /dev/null +++ b/ButtonDemo/assets/scenes/scene.scene.meta @@ -0,0 +1,11 @@ +{ + "ver": "1.1.27", + "importer": "scene", + "imported": true, + "uuid": "a7cfb650-4de4-4ab2-aa56-6f7cdc46e809", + "files": [ + ".json" + ], + "subMetas": {}, + "userData": {} +} diff --git a/ButtonDemo/assets/scripts.meta b/ButtonDemo/assets/scripts.meta new file mode 100644 index 0000000..ce1869a --- /dev/null +++ b/ButtonDemo/assets/scripts.meta @@ -0,0 +1,12 @@ +{ + "ver": "1.1.0", + "importer": "directory", + "imported": true, + "uuid": "abf4fb75-3db7-4a2d-b08b-6ddfda0d8680", + "files": [], + "subMetas": {}, + "userData": { + "compressionType": {}, + "isRemoteBundle": {} + } +} diff --git a/ButtonDemo/assets/scripts/ButtonUtil.ts b/ButtonDemo/assets/scripts/ButtonUtil.ts new file mode 100644 index 0000000..4e882cf --- /dev/null +++ b/ButtonDemo/assets/scripts/ButtonUtil.ts @@ -0,0 +1,59 @@ +import { Button, Component, EventHandler, Node } from "cc"; + +/** + * 对button操作的简单封装 + * 版本为ccc 3.1.x + */ +export default class ButtonUtil { + + /** + * + * @param button 组件 + * @param node 事件所在脚本的节点 + * @param component 事件所在脚本 + * @param callback 事件名字 + * @param customData 数据 + */ + public static AddClick(button: Button, node: Node, component: string, callback: string, customData?: any) { + let clickEventHandler = new EventHandler(); + clickEventHandler.target = node; + clickEventHandler.component = component; + clickEventHandler.handler = callback; + clickEventHandler.customEventData = customData || null; + + button.clickEvents.push(clickEventHandler); + + } + + /** + * + * @param node 添加组件的节点 + * @param zoomScale 绽放因子 默认0.95 + * @returns + */ + public static AddScaleButton(node: Node, zoomScale: number = 0.95): Button { + let button = node.addComponent(Button); + button.target = node; + button.transition = Button.Transition.COLOR; + button.duration = 0.1; + button.zoomScale = zoomScale; + return button; + } + + /** + * + * @param button 组件 + * @param state 是否禁用状态 默认为false + */ + public static Interactable(button: Button | Node, state: boolean) { + if (button instanceof Button) { + button.interactable = state; + } else if (button instanceof Node) { + button = button.getComponent(Button)!; + button && (button.interactable = state); + } + } + + + +} \ No newline at end of file diff --git a/ButtonDemo/assets/scripts/ButtonUtil.ts.meta b/ButtonDemo/assets/scripts/ButtonUtil.ts.meta new file mode 100644 index 0000000..f2733fa --- /dev/null +++ b/ButtonDemo/assets/scripts/ButtonUtil.ts.meta @@ -0,0 +1,9 @@ +{ + "ver": "4.0.22", + "importer": "typescript", + "imported": true, + "uuid": "1cdee820-8f9e-41d0-8f2e-6b2496c4ec1d", + "files": [], + "subMetas": {}, + "userData": {} +} diff --git a/ButtonDemo/assets/scripts/Scene.ts b/ButtonDemo/assets/scripts/Scene.ts new file mode 100644 index 0000000..e6afc2e --- /dev/null +++ b/ButtonDemo/assets/scripts/Scene.ts @@ -0,0 +1,53 @@ + +import { _decorator, Component, Node, Label, Button, EventTouch } from 'cc'; +import ButtonUtil from './ButtonUtil'; +const { ccclass, property } = _decorator; + +@ccclass('Scene') +export class Scene extends Component { + + @property(Label) + txt: Label = null!; + + @property(Node) + btn2: Node = null!; + + @property(Button) + btn1: Button = null!; + + onLoad() { + //手动添加button组件跟事件 + let btn = ButtonUtil.AddScaleButton(this.btn2); + ButtonUtil.AddClick(btn, this.node, 'Scene', 'onClick_2'); + console.log('this.btn1',this.btn1); + } + + start() { + // [3] + } + + onClick_1(event: EventTouch) { + console.log('event 1', event); + this.txt.string = 'button 1' + } + + onClick_2(event: EventTouch) { + console.log('event 2', event); + this.txt.string = 'button 2'; + } + + // update (deltaTime: number) { + // // [4] + // } +} + +/** + * [1] Class member could be defined like this. + * [2] Use `property` decorator if your want the member to be serializable. + * [3] Your initialization goes here. + * [4] Your update function goes here. + * + * Learn more about scripting: https://docs.cocos.com/creator/3.0/manual/en/scripting/ + * Learn more about CCClass: https://docs.cocos.com/creator/3.0/manual/en/scripting/ccclass.html + * Learn more about life-cycle callbacks: https://docs.cocos.com/creator/3.0/manual/en/scripting/life-cycle-callbacks.html + */ diff --git a/ButtonDemo/assets/scripts/Scene.ts.meta b/ButtonDemo/assets/scripts/Scene.ts.meta new file mode 100644 index 0000000..f59f53b --- /dev/null +++ b/ButtonDemo/assets/scripts/Scene.ts.meta @@ -0,0 +1,9 @@ +{ + "ver": "4.0.22", + "importer": "typescript", + "imported": true, + "uuid": "a59f9f2d-05dc-4994-922f-d9b4d0f4370b", + "files": [], + "subMetas": {}, + "userData": {} +} diff --git a/ButtonDemo/package.json b/ButtonDemo/package.json new file mode 100644 index 0000000..30679c7 --- /dev/null +++ b/ButtonDemo/package.json @@ -0,0 +1,6 @@ +{ + "name": "ButtonDemo", + "type": "3d", + "uuid": "3d032722-33df-4bb3-bdfb-b61a9bfc4301", + "version": "3.1.1" +} diff --git a/ButtonDemo/settings/v2/packages/builder.json b/ButtonDemo/settings/v2/packages/builder.json new file mode 100644 index 0000000..af081f3 --- /dev/null +++ b/ButtonDemo/settings/v2/packages/builder.json @@ -0,0 +1,3 @@ +{ + "__version__": "1.2.8" +} diff --git a/ButtonDemo/settings/v2/packages/device.json b/ButtonDemo/settings/v2/packages/device.json new file mode 100644 index 0000000..70e599e --- /dev/null +++ b/ButtonDemo/settings/v2/packages/device.json @@ -0,0 +1,3 @@ +{ + "__version__": "1.0.1" +} diff --git a/ButtonDemo/settings/v2/packages/engine.json b/ButtonDemo/settings/v2/packages/engine.json new file mode 100644 index 0000000..2e889fa --- /dev/null +++ b/ButtonDemo/settings/v2/packages/engine.json @@ -0,0 +1,3 @@ +{ + "__version__": "1.0.5" +} diff --git a/ButtonDemo/settings/v2/packages/program.json b/ButtonDemo/settings/v2/packages/program.json new file mode 100644 index 0000000..4d87e97 --- /dev/null +++ b/ButtonDemo/settings/v2/packages/program.json @@ -0,0 +1,3 @@ +{ + "__version__": "1.0.0" +} diff --git a/ButtonDemo/settings/v2/packages/project.json b/ButtonDemo/settings/v2/packages/project.json new file mode 100644 index 0000000..70e599e --- /dev/null +++ b/ButtonDemo/settings/v2/packages/project.json @@ -0,0 +1,3 @@ +{ + "__version__": "1.0.1" +} diff --git a/ButtonDemo/tsconfig.json b/ButtonDemo/tsconfig.json new file mode 100644 index 0000000..faff299 --- /dev/null +++ b/ButtonDemo/tsconfig.json @@ -0,0 +1,6 @@ +{ + /* Base configuration. Do not edit this field. */ + "extends": "./temp/tsconfig.cocos.json" + + /* Add your custom configuration here. */ +} diff --git a/CameraDemo/.gitignore b/CameraDemo/.gitignore new file mode 100644 index 0000000..c072d29 --- /dev/null +++ b/CameraDemo/.gitignore @@ -0,0 +1,53 @@ +#///////////////////////////////////////////////////////////////////////////// +# Fireball Projects +#///////////////////////////////////////////////////////////////////////////// + +/library/ +/temp/ +/local/ +/build/ + +#///////////////////////////////////////////////////////////////////////////// +# npm files +#///////////////////////////////////////////////////////////////////////////// + +npm-debug.log +node_modules/ + +#///////////////////////////////////////////////////////////////////////////// +# Logs and databases +#///////////////////////////////////////////////////////////////////////////// + +*.log +*.sql +*.sqlite + +#///////////////////////////////////////////////////////////////////////////// +# files for debugger +#///////////////////////////////////////////////////////////////////////////// + +*.sln +*.csproj +*.pidb +*.unityproj +*.suo + +#///////////////////////////////////////////////////////////////////////////// +# OS generated files +#///////////////////////////////////////////////////////////////////////////// + +.DS_Store +ehthumbs.db +Thumbs.db + +#///////////////////////////////////////////////////////////////////////////// +# WebStorm files +#///////////////////////////////////////////////////////////////////////////// + +.idea/ + +#////////////////////////// +# VS Code files +#////////////////////////// + +.vscode/ diff --git a/CameraDemo/README.md b/CameraDemo/README.md new file mode 100644 index 0000000..edc6186 --- /dev/null +++ b/CameraDemo/README.md @@ -0,0 +1,31 @@ +### Camera参数分析 + +### Depth +用于使用多个Camera时,通过设置Depth来决定摄像机的渲染顺序,值越大则摄像机越晚被渲染,渲染在前 + +### cullingMask +将决定这个摄像机用来渲染场景的哪些部分。在 属性检查器 中的摄像机组件中的 cullingMask 会列出当前可以选择的 mask 选项。 +通过选择需要渲染组。如:这个摄像机只用来渲染游戏中的 UI 部分,一般游戏中的 UI 部分都是不需要移动的,而游戏节点可能会往屏幕外移动,这时需要另外的一个摄像机去跟随这个游戏节点 +用户可以通过编辑器菜单栏中的 项目 -> 项目设置 -> 分组管理 来添加或者更改分组,这些分组即是对应的 mask。 + +### clearFlags +指定渲染摄像机时需要做的清除操作 +说明下 +COLOR :如果有多个Camera时。如果都勾选该字段,会出现把其他Camera渲染的画面都清除掉。只留下其中一个。所以一般只选择一个Camera勾选该字段,其他Camera不勾选。 + +### rect +决定摄像机绘制在屏幕上的哪个区域,便于实现类似小地图那样的 Viewport,值为 0~1 + +### zoomRatio +指定摄像机的缩放比例,值越大显示的图像越大。 + +### alignWithScreen +当 alignWithScreen 为 true 的时候,摄像机会自动将视窗大小调整为整个屏幕的大小。如果想要完全自由地控制摄像机,则需要将 alignWithScreen 设置为 false +如果是2d游戏的话,主Camera一般是要调整为整个屏幕的大小。 + +### orthoSize +摄像机在正交投影模式下的视窗大小。该属性在 alignWithScreen 设置为 false 时生效 +如果是2d游戏的话,是使用正交投影模式,3d一般使用透视模式 + +### 官方文档 +https://docs.cocos.com/creator/manual/zh/render/camera.html?h=camer diff --git a/CameraDemo/assets/Scenes.meta b/CameraDemo/assets/Scenes.meta new file mode 100644 index 0000000..ce4611f --- /dev/null +++ b/CameraDemo/assets/Scenes.meta @@ -0,0 +1,12 @@ +{ + "ver": "1.1.2", + "uuid": "a529f388-70d1-4a1b-9cdf-ccad2c8d9e16", + "isBundle": false, + "bundleName": "", + "priority": 1, + "compressionType": {}, + "optimizeHotUpdate": {}, + "inlineSpriteFrames": {}, + "isRemoteBundle": {}, + "subMetas": {} +} \ No newline at end of file diff --git a/CameraDemo/assets/Scenes/Game.fire b/CameraDemo/assets/Scenes/Game.fire new file mode 100644 index 0000000..afed342 --- /dev/null +++ b/CameraDemo/assets/Scenes/Game.fire @@ -0,0 +1,3371 @@ +[ + { + "__type__": "cc.SceneAsset", + "_name": "", + "_objFlags": 0, + "_native": "", + "scene": { + "__id__": 1 + } + }, + { + "__type__": "cc.Scene", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + }, + { + "__id__": 13 + } + ], + "_active": true, + "_components": [], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_is3DNode": true, + "_groupIndex": 0, + "groupIndex": 0, + "autoReleaseAssets": true, + "_id": "b8Beo8tjxBr7LjUYsKpJYx" + }, + { + "__type__": "cc.Node", + "_name": "Canvas", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 3 + }, + { + "__id__": 5 + }, + { + "__id__": 7 + }, + { + "__id__": 9 + } + ], + "_active": true, + "_components": [ + { + "__id__": 11 + }, + { + "__id__": 12 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 960, + "height": 640 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 480, + 320, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "98hcyx82FGPKT1NW36bfgu" + }, + { + "__type__": "cc.Node", + "_name": "Main Camera", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 4 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 273.2743320215784, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "1aU+UWIKxEgZ4t4mixCNOO" + }, + { + "__type__": "cc.Camera", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 3 + }, + "_enabled": true, + "_cullingMask": -7, + "_clearFlags": 6, + "_backgroundColor": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_depth": 1, + "_zoomRatio": 1, + "_targetTexture": null, + "_fov": 60, + "_orthoSize": 10, + "_nearClip": 0.1, + "_farClip": 4096, + "_ortho": true, + "_rect": { + "__type__": "cc.Rect", + "x": 0, + "y": 0, + "width": 1, + "height": 1 + }, + "_renderStages": 1, + "_alignWithScreen": true, + "_id": "95Y0/V/OhKUoickxQO+QnS" + }, + { + "__type__": "cc.Node", + "_name": "Second Camera", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 6 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 273.2743320215784, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "4eH8WLRQ1GJ5gD/JVVTIbG" + }, + { + "__type__": "cc.Camera", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 5 + }, + "_enabled": true, + "_cullingMask": -4, + "_clearFlags": 6, + "_backgroundColor": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_depth": 2, + "_zoomRatio": 1, + "_targetTexture": null, + "_fov": 60, + "_orthoSize": 10, + "_nearClip": 0.1, + "_farClip": 4096, + "_ortho": true, + "_rect": { + "__type__": "cc.Rect", + "x": 0, + "y": 0, + "width": 1, + "height": 1 + }, + "_renderStages": 1, + "_alignWithScreen": true, + "_id": "43dM2jj0dIXa0ME+d3Ntrk" + }, + { + "__type__": "cc.Node", + "_name": "New Sprite(Splash)", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 8 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 100 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -300.848, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 2, + "groupIndex": 2, + "_id": "eeUZYPMslFkKPm711+zP8h" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 7 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "a7S1zq+mZF06QCtncQSqTK" + }, + { + "__type__": "cc.Node", + "_name": "New Label", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 10 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 218, + "g": 66, + "b": 66, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 97.87, + "height": 50.4 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -352.537, + 43.528, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "fb2j14dQ1LyY9BV/Cd7WcO" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 9 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_useOriginalSize": false, + "_string": "Label", + "_N$string": "Label", + "_fontSize": 40, + "_lineHeight": 40, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_styleFlags": 0, + "_underlineHeight": 0, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 0, + "_id": "6dtu1Sg1FD3apGJ1goCiKC" + }, + { + "__type__": "cc.Canvas", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "_designResolution": { + "__type__": "cc.Size", + "width": 960, + "height": 640 + }, + "_fitWidth": false, + "_fitHeight": true, + "_id": "006E3CEXdGBohH2SIm155m" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "alignMode": 1, + "_target": null, + "_alignFlags": 45, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 0, + "_originalHeight": 0, + "_id": "62fb3dwk5Mzrql8WfISlp0" + }, + { + "__type__": "cc.Node", + "_name": "Root", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 14 + }, + { + "__id__": 16 + }, + { + "__id__": 18 + }, + { + "__id__": 84 + } + ], + "_active": true, + "_components": [], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 480, + 320, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 1, + "groupIndex": 1, + "_id": "d0TESWB0JDyIu/B0kK41R/" + }, + { + "__type__": "cc.Node", + "_name": "New Directional Light", + "_objFlags": 0, + "_parent": { + "__id__": 13 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 15 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 1.273, + -0.25881904510252074, + 0, + 0, + 0.9659258262890683, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": -30, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "_groupIndex": 1, + "groupIndex": 1, + "_id": "2dIZ9jh5FBt5S2C2ELqFtq" + }, + { + "__type__": "cc.Light", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 14 + }, + "_enabled": true, + "_type": 0, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_intensity": 1.5, + "_range": 1000, + "_spotAngle": 60, + "_spotExp": 1, + "_shadowType": 0, + "_shadowResolution": 1024, + "_shadowDarkness": 0.5, + "_shadowMinDepth": 1, + "_shadowMaxDepth": 1000, + "_shadowFrustumSize": 50, + "_shadowBias": 0.0005, + "_id": "f8CNzIMPFODZ23MfAklq3J" + }, + { + "__type__": "cc.Node", + "_name": "New 3D Camera", + "_objFlags": 0, + "_parent": { + "__id__": 13 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 17 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 156.696, + 310.855, + -0.08715574274765817, + 0, + 0, + 0.9961946980917455, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": -10, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "_groupIndex": 1, + "groupIndex": 1, + "_id": "d0yi3PeIFOerzU+Z5cPIPS" + }, + { + "__type__": "cc.Camera", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 16 + }, + "_enabled": true, + "_cullingMask": 2, + "_clearFlags": 7, + "_backgroundColor": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_depth": 0, + "_zoomRatio": 1, + "_targetTexture": null, + "_fov": 60, + "_orthoSize": 10, + "_nearClip": 1, + "_farClip": 1024, + "_ortho": false, + "_rect": { + "__type__": "cc.Rect", + "x": 0, + "y": 0, + "width": 1, + "height": 1 + }, + "_renderStages": 1, + "_alignWithScreen": false, + "_id": "f9CtbibpBNc7DjtwYTFU0f" + }, + { + "__type__": "cc.Node", + "_name": "RootNode", + "_objFlags": 0, + "_parent": { + "__id__": 13 + }, + "_children": [ + { + "__id__": 19 + }, + { + "__id__": 79 + } + ], + "_active": true, + "_components": [ + { + "__id__": 82 + } + ], + "_prefab": { + "__id__": 83 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 100, + 100, + 100 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "_groupIndex": 1, + "groupIndex": 1, + "_id": "ba83Lj6rJDlaTyeMZhxGon" + }, + { + "__type__": "cc.Node", + "_name": "Bip001", + "_objFlags": 0, + "_parent": { + "__id__": 18 + }, + "_children": [ + { + "__id__": 20 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 78 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0.445094257593155, + 0, + -0.4777145100774618, + -0.4777143014612054, + -0.5213333952384507, + 0.5213342344888091, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": -89.99996113498794, + "y": -89.99993820758385, + "z": -5.000002492307637 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "_groupIndex": 1, + "groupIndex": 1, + "_id": "2ctUI/BrtH2YKS4XoY20sg" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 Pelvis", + "_objFlags": 0, + "_parent": { + "__id__": 19 + }, + "_children": [ + { + "__id__": 21 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 77 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + -0.5213338166255229, + -0.47771445187796674, + -0.5213330959276368, + 0.4777151423182068, + 1, + 1.00000011920929, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": -94.99991647643981, + "y": -89.99991914907307, + "z": -0.0000017946816826815862 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "_groupIndex": 1, + "groupIndex": 1, + "_id": "2ffXok/wVGwoGNCLRN0NJq" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 Spine", + "_objFlags": 0, + "_parent": { + "__id__": 20 + }, + "_children": [ + { + "__id__": 22 + }, + { + "__id__": 60 + }, + { + "__id__": 68 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 76 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0.110900685191154, + -0.0000882315580383874, + 0.0000079423189163208, + -0.043582268073973175, + -0.005676872100140931, + 0.04364357890150403, + 0.9980799552407389, + 1.00000011920929, + 0.99999988079071, + 0.999999940395355 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": -4.981586646561181, + "y": -0.4329787153885274, + "z": 5.026379146169573 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "_groupIndex": 1, + "groupIndex": 1, + "_id": "d4q7Um6+pC57HMZcH50LKm" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 Spine1", + "_objFlags": 0, + "_parent": { + "__id__": 21 + }, + "_children": [ + { + "__id__": 23 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 59 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0.111723437905312, + -0.000102720259747002, + 0.0000170135499502067, + -0.08482445774483811, + 0.037586793301864846, + 0.16904041165739359, + 0.9812325838272372, + 1.00000011920929, + 1.00000011920929, + 1.00000011920929 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": -10.922558908649066, + "y": 6.219329535991704, + "z": 18.987348186751618 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "_groupIndex": 1, + "groupIndex": 1, + "_id": "510tTxsp1CLqbBKxU96KuI" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 Neck", + "_objFlags": 0, + "_parent": { + "__id__": 22 + }, + "_children": [ + { + "__id__": 24 + }, + { + "__id__": 40 + }, + { + "__id__": 56 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 58 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0.169107705354691, + -0.0000594329831073992, + 7.15255721317476e-9, + 1.3969839507410607e-8, + -9.313226634333202e-9, + -1.4901161193847703e-8, + 0.9999999999999998, + 0.999999940395355, + 0.999999940395355, + 0.999999940395355 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0.000001600825672596715, + "y": -0.0000010672171357380805, + "z": -0.0000017075473074120455 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "_groupIndex": 1, + "groupIndex": 1, + "_id": "2fIBtb0j9KCYHOrV+l0TXY" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 L Clavicle", + "_objFlags": 0, + "_parent": { + "__id__": 23 + }, + "_children": [ + { + "__id__": 25 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 39 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -0.0302013382315636, + 0.0000593185395700857, + 0.0287195052951574, + 0.7071076944760551, + -0.00028153004279250375, + 0.7071057558060123, + 0.0002815308173350889, + 1, + 0.999999940395355, + 0.99999988079071 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 179.95437603965198, + "y": -89.99984291252305, + "z": 2.1653907979926632e-10 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "_groupIndex": 1, + "groupIndex": 1, + "_id": "e2k1CuLuhCa6CiPxQAgpLC" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 L UpperArm", + "_objFlags": 0, + "_parent": { + "__id__": 24 + }, + "_children": [ + { + "__id__": 26 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 38 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0.0769595131278038, + -5.72204577053981e-8, + -7.62939436071974e-8, + -0.011265276624011094, + 0.5725933963291635, + -0.04749572379668194, + 0.8183850268937276, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 2.0689081693117792, + "y": 70.05205481460784, + "z": -5.200451297133968 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "_groupIndex": 1, + "groupIndex": 1, + "_id": "52R9+GyMhPfoiCXCFR8/jc" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 L Forearm", + "_objFlags": 0, + "_parent": { + "__id__": 25 + }, + "_children": [ + { + "__id__": 27 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 37 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0.17928458750248, + 0, + 0, + 2.4787882765288216e-17, + -1.4285688373419676e-17, + -0.2742840608050094, + 0.96164871652195, + 1, + 1.00000011920929, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 2.6868035361408916e-15, + "y": -9.35967471832619e-16, + "z": -31.83870682831776 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "_groupIndex": 1, + "groupIndex": 1, + "_id": "6ai76U2OFFKZYqb1210Dlv" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 L Hand", + "_objFlags": 0, + "_parent": { + "__id__": 26 + }, + "_children": [ + { + "__id__": 28 + }, + { + "__id__": 32 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 36 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0.187908545136452, + 4.76837147544984e-9, + 0, + -0.7736767538918475, + -0.13894343386031113, + -0.1617789706360022, + 0.5966125772512967, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": -104.4512677837114, + "y": -24.596193905127684, + "z": 1.258079923988921 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "_groupIndex": 1, + "groupIndex": 1, + "_id": "b1UEtMCR9F26vm0DmQV+aY" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 L Finger0", + "_objFlags": 0, + "_parent": { + "__id__": 27 + }, + "_children": [ + { + "__id__": 29 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 31 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0.0170081704854965, + 0.00760417943820357, + -0.0307398606091738, + 0.4852738980135882, + 0.3591655198256656, + -0.12196993918310998, + 0.7878024544330422, + 0.999999940395355, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 59.63633765526131, + "y": 43.85277044614094, + "z": 8.998631183153556 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "_groupIndex": 1, + "groupIndex": 1, + "_id": "ebiKuKu1pMyaTmardGHPfV" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 L Finger01", + "_objFlags": 0, + "_parent": { + "__id__": 28 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 30 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0.0195534136146307, + 7.10542719878232e-17, + -3.55271359939116e-17, + 3.72529074255112e-9, + 3.46944695195361e-18, + -1.2924698611885e-26, + 1, + 1, + 0.99999988079071, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 4.268868740146714e-7, + "y": 3.975693351829391e-16, + "z": -1.9731698772535437e-39 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "_groupIndex": 1, + "groupIndex": 1, + "_id": "d9/g6cb+ZDLJyTa4Y2Fi7c" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 18 + }, + "asset": { + "__uuid__": "8c9c3331-f5ac-4c3d-87e5-5aae0064e329" + }, + "fileId": "Bip001/Bip001 Pelvis/Bip001 Spine/Bip001 Spine1/Bip001 Neck/Bip001 L Clavicle/Bip001 L UpperArm/Bip001 L Forearm/Bip001 L Hand/Bip001 L Finger0/Bip001 L Finger01", + "sync": false + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 18 + }, + "asset": { + "__uuid__": "8c9c3331-f5ac-4c3d-87e5-5aae0064e329" + }, + "fileId": "Bip001/Bip001 Pelvis/Bip001 Spine/Bip001 Spine1/Bip001 Neck/Bip001 L Clavicle/Bip001 L UpperArm/Bip001 L Forearm/Bip001 L Hand/Bip001 L Finger0", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "Bip001 L Finger1", + "_objFlags": 0, + "_parent": { + "__id__": 27 + }, + "_children": [ + { + "__id__": 33 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 35 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0.078213594853878, + 0, + -9.53674295089968e-9, + -0.0003977828192779912, + 0.00001737030522296762, + 0.04361935948088976, + 0.99904814345735, + 1, + 1.00000011920929, + 0.999999940395355 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": -0.045800277714890175, + "y": 0.0039920684808117295, + "z": 4.999995608727753 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "_groupIndex": 1, + "groupIndex": 1, + "_id": "87HSLfuiNE5Yyt8wlsYJTy" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 L Finger11", + "_objFlags": 0, + "_parent": { + "__id__": 32 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 34 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0.0197317507117987, + 0, + 1.77635679969558e-17, + -8.680013231006746e-9, + 5.075353419028115e-9, + 0.3007057382523997, + 0.9537169700608662, + 1, + 1.00000011920929, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": -0.0000013715508626515564, + "y": 0.000001042265060604007, + "z": 34.999992640429014 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "_groupIndex": 1, + "groupIndex": 1, + "_id": "4ahwtiNOJIcoMZhCpdERj9" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 18 + }, + "asset": { + "__uuid__": "8c9c3331-f5ac-4c3d-87e5-5aae0064e329" + }, + "fileId": "Bip001/Bip001 Pelvis/Bip001 Spine/Bip001 Spine1/Bip001 Neck/Bip001 L Clavicle/Bip001 L UpperArm/Bip001 L Forearm/Bip001 L Hand/Bip001 L Finger1/Bip001 L Finger11", + "sync": false + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 18 + }, + "asset": { + "__uuid__": "8c9c3331-f5ac-4c3d-87e5-5aae0064e329" + }, + "fileId": "Bip001/Bip001 Pelvis/Bip001 Spine/Bip001 Spine1/Bip001 Neck/Bip001 L Clavicle/Bip001 L UpperArm/Bip001 L Forearm/Bip001 L Hand/Bip001 L Finger1", + "sync": false + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 18 + }, + "asset": { + "__uuid__": "8c9c3331-f5ac-4c3d-87e5-5aae0064e329" + }, + "fileId": "Bip001/Bip001 Pelvis/Bip001 Spine/Bip001 Spine1/Bip001 Neck/Bip001 L Clavicle/Bip001 L UpperArm/Bip001 L Forearm/Bip001 L Hand", + "sync": false + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 18 + }, + "asset": { + "__uuid__": "8c9c3331-f5ac-4c3d-87e5-5aae0064e329" + }, + "fileId": "Bip001/Bip001 Pelvis/Bip001 Spine/Bip001 Spine1/Bip001 Neck/Bip001 L Clavicle/Bip001 L UpperArm/Bip001 L Forearm", + "sync": false + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 18 + }, + "asset": { + "__uuid__": "8c9c3331-f5ac-4c3d-87e5-5aae0064e329" + }, + "fileId": "Bip001/Bip001 Pelvis/Bip001 Spine/Bip001 Spine1/Bip001 Neck/Bip001 L Clavicle/Bip001 L UpperArm", + "sync": false + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 18 + }, + "asset": { + "__uuid__": "8c9c3331-f5ac-4c3d-87e5-5aae0064e329" + }, + "fileId": "Bip001/Bip001 Pelvis/Bip001 Spine/Bip001 Spine1/Bip001 Neck/Bip001 L Clavicle", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "Bip001 R Clavicle", + "_objFlags": 0, + "_parent": { + "__id__": 23 + }, + "_children": [ + { + "__id__": 41 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 55 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -0.0302014146000147, + 0.0000595283490838483, + -0.0287195146083832, + -0.7071076944676654, + 0.0002815405783752107, + 0.7071057558060122, + 0.0002815413529140341, + 1, + 0.999999940395355, + 0.99999988079071 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": -179.95437433228787, + "y": 89.99984291320284, + "z": 2.141643981602186e-10 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "_groupIndex": 1, + "groupIndex": 1, + "_id": "70jZ+SddZIPY+61F0pM0Sq" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 R UpperArm", + "_objFlags": 0, + "_parent": { + "__id__": 40 + }, + "_children": [ + { + "__id__": 42 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 54 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0.0769595429301262, + 3.81469718035987e-8, + -7.62939436071974e-8, + -0.12077409781063089, + -0.5797749758983785, + -0.00982602227974852, + 0.8057158580456393, + 1.00000011920929, + 1, + 1.00000011920929 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": -11.982960853071107, + "y": -70.7260633198872, + "z": 7.135115521837888 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "_groupIndex": 1, + "groupIndex": 1, + "_id": "d7oXNod7pNkLeR/m6qDwd7" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 R Forearm", + "_objFlags": 0, + "_parent": { + "__id__": 41 + }, + "_children": [ + { + "__id__": 43 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 53 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0.179284542798996, + -3.81469718035987e-8, + -3.55271359939116e-17, + -6.2375672851358655e-18, + 1.0562009638917813e-17, + -0.24928714598048776, + 0.9684296148140571, + 0.999999940395355, + 0.999999940395355, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": -4.459119879348145e-16, + "y": 1.1349890661421565e-15, + "z": -28.87066635543818 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "_groupIndex": 1, + "groupIndex": 1, + "_id": "e2NcWfwDNDhIIOXXdPO6Fn" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 R Hand", + "_objFlags": 0, + "_parent": { + "__id__": 42 + }, + "_children": [ + { + "__id__": 44 + }, + { + "__id__": 48 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 52 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0.187908515334129, + 1.90734859017994e-8, + -1.90734859017994e-8, + 0.7251593473126848, + 0.1282718629938548, + -0.23150484227932877, + 0.6356852665984559, + 1.00000011920929, + 1, + 1.00000011920929 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 99.19767733379169, + "y": 30.118356601599345, + "z": -6.216944232352193 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "_groupIndex": 1, + "groupIndex": 1, + "_id": "5aIbev8odPdLzn/3aPqYzB" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 R Finger0", + "_objFlags": 0, + "_parent": { + "__id__": 43 + }, + "_children": [ + { + "__id__": 45 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 47 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0.0170081704854965, + 0.0076042553409934, + 0.0307398736476898, + -0.5150285329626191, + -0.2688684143088339, + -0.13821174859928642, + 0.8020928241609903, + 0.999999940395355, + 0.999999821186066, + 0.99999988079071 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": -64.40890356982322, + "y": -35.06867689973144, + "z": 3.166200721713856 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "_groupIndex": 1, + "groupIndex": 1, + "_id": "10nxgQLy9HA6fkuJKC0jF+" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 R Finger01", + "_objFlags": 0, + "_parent": { + "__id__": 44 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 46 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0.0195534322410822, + 7.10542719878232e-17, + 0, + 7.450581485102254e-9, + 7.450580596923835e-9, + -2.980232594040902e-8, + 0.9999999999999996, + 0.999999940395355, + 0.999999940395355, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 8.537737734737861e-7, + "y": 8.537736716960392e-7, + "z": -0.0000034150949857562675 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "_groupIndex": 1, + "groupIndex": 1, + "_id": "08Vv7eX4hEGJrBxV1uMkEh" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 18 + }, + "asset": { + "__uuid__": "8c9c3331-f5ac-4c3d-87e5-5aae0064e329" + }, + "fileId": "Bip001/Bip001 Pelvis/Bip001 Spine/Bip001 Spine1/Bip001 Neck/Bip001 R Clavicle/Bip001 R UpperArm/Bip001 R Forearm/Bip001 R Hand/Bip001 R Finger0/Bip001 R Finger01", + "sync": false + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 18 + }, + "asset": { + "__uuid__": "8c9c3331-f5ac-4c3d-87e5-5aae0064e329" + }, + "fileId": "Bip001/Bip001 Pelvis/Bip001 Spine/Bip001 Spine1/Bip001 Neck/Bip001 R Clavicle/Bip001 R UpperArm/Bip001 R Forearm/Bip001 R Hand/Bip001 R Finger0", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "Bip001 R Finger1", + "_objFlags": 0, + "_parent": { + "__id__": 43 + }, + "_children": [ + { + "__id__": 49 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 51 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0.0782136172056198, + 0, + 9.53674295089968e-9, + 0.0003977797076788419, + -0.00001736596500306028, + 0.04361950504463571, + 0.999048137103207, + 0.999999821186066, + 0.99999988079071, + 0.99999988079071 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0.045799899521087865, + "y": -0.0039915608407312154, + "z": 5.000012305205561 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "_groupIndex": 1, + "groupIndex": 1, + "_id": "dbGH9Bq+NP45Ze2DW1njDa" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 R Finger11", + "_objFlags": 0, + "_parent": { + "__id__": 48 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 50 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0.0197317693382502, + 0, + 0, + -3.7789922965120535e-9, + -1.9767534864924596e-9, + 0.25881892838243825, + 0.9659258575641125, + 1, + 1, + 1.00000011920929 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": -4.152968333290957e-7, + "y": -1.2323159332839386e-7, + "z": 29.999986153040282 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "_groupIndex": 1, + "groupIndex": 1, + "_id": "b0bloIc/5IvpRBMUAAexOw" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 18 + }, + "asset": { + "__uuid__": "8c9c3331-f5ac-4c3d-87e5-5aae0064e329" + }, + "fileId": "Bip001/Bip001 Pelvis/Bip001 Spine/Bip001 Spine1/Bip001 Neck/Bip001 R Clavicle/Bip001 R UpperArm/Bip001 R Forearm/Bip001 R Hand/Bip001 R Finger1/Bip001 R Finger11", + "sync": false + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 18 + }, + "asset": { + "__uuid__": "8c9c3331-f5ac-4c3d-87e5-5aae0064e329" + }, + "fileId": "Bip001/Bip001 Pelvis/Bip001 Spine/Bip001 Spine1/Bip001 Neck/Bip001 R Clavicle/Bip001 R UpperArm/Bip001 R Forearm/Bip001 R Hand/Bip001 R Finger1", + "sync": false + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 18 + }, + "asset": { + "__uuid__": "8c9c3331-f5ac-4c3d-87e5-5aae0064e329" + }, + "fileId": "Bip001/Bip001 Pelvis/Bip001 Spine/Bip001 Spine1/Bip001 Neck/Bip001 R Clavicle/Bip001 R UpperArm/Bip001 R Forearm/Bip001 R Hand", + "sync": false + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 18 + }, + "asset": { + "__uuid__": "8c9c3331-f5ac-4c3d-87e5-5aae0064e329" + }, + "fileId": "Bip001/Bip001 Pelvis/Bip001 Spine/Bip001 Spine1/Bip001 Neck/Bip001 R Clavicle/Bip001 R UpperArm/Bip001 R Forearm", + "sync": false + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 18 + }, + "asset": { + "__uuid__": "8c9c3331-f5ac-4c3d-87e5-5aae0064e329" + }, + "fileId": "Bip001/Bip001 Pelvis/Bip001 Spine/Bip001 Spine1/Bip001 Neck/Bip001 R Clavicle/Bip001 R UpperArm", + "sync": false + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 18 + }, + "asset": { + "__uuid__": "8c9c3331-f5ac-4c3d-87e5-5aae0064e329" + }, + "fileId": "Bip001/Bip001 Pelvis/Bip001 Spine/Bip001 Spine1/Bip001 Neck/Bip001 R Clavicle", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "Bip001 Head", + "_objFlags": 0, + "_parent": { + "__id__": 23 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 57 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0.0443997941911221, + -1.90734859017994e-8, + -4.76837147544984e-9, + 0.17214491786307975, + -0.044710470980498414, + -0.20766889842597502, + 0.9618943443357787, + 0.999999940395355, + 0.999999940395355, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 20.09440572685176, + "y": -0.9140866061199048, + "z": -24.513298664932453 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "_groupIndex": 1, + "groupIndex": 1, + "_id": "bfQbSTtZ1Lj5nYMD6e5H0X" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 18 + }, + "asset": { + "__uuid__": "8c9c3331-f5ac-4c3d-87e5-5aae0064e329" + }, + "fileId": "Bip001/Bip001 Pelvis/Bip001 Spine/Bip001 Spine1/Bip001 Neck/Bip001 Head", + "sync": false + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 18 + }, + "asset": { + "__uuid__": "8c9c3331-f5ac-4c3d-87e5-5aae0064e329" + }, + "fileId": "Bip001/Bip001 Pelvis/Bip001 Spine/Bip001 Spine1/Bip001 Neck", + "sync": false + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 18 + }, + "asset": { + "__uuid__": "8c9c3331-f5ac-4c3d-87e5-5aae0064e329" + }, + "fileId": "Bip001/Bip001 Pelvis/Bip001 Spine/Bip001 Spine1", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "Bip001 L Thigh", + "_objFlags": 0, + "_parent": { + "__id__": 21 + }, + "_children": [ + { + "__id__": 61 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 67 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -0.109737619757652, + 0.00125834462232888, + 0.0977345854043961, + -0.3916955368971178, + -0.9057390470792186, + -0.1202259651255862, + 0.10843017237157235, + 1, + 1.00000011920929, + 1.00000023841858 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": -24.501287639643245, + "y": -156.5405074977875, + "z": 43.115842518171796 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "_groupIndex": 1, + "groupIndex": 1, + "_id": "5dVgp5bd9DmZXD+YOK494h" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 L Calf", + "_objFlags": 0, + "_parent": { + "__id__": 60 + }, + "_children": [ + { + "__id__": 62 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 66 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0.213316544890404, + -1.90734859017994e-8, + -1.90734859017994e-8, + 9.263872807768317e-18, + 4.823538657255263e-18, + -0.35610604723379286, + 0.9344455485064519, + 1, + 1.00000011920929, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 1.5927668101493827e-15, + "y": 1.1984975576964766e-15, + "z": -41.72249338174621 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "_groupIndex": 1, + "groupIndex": 1, + "_id": "90MQMXwedCMJ8Qo8odem80" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 L Foot", + "_objFlags": 0, + "_parent": { + "__id__": 61 + }, + "_children": [ + { + "__id__": 63 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 65 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0.194084659218788, + 0, + 0, + -0.2002906519899819, + -0.06802260206250402, + 0.022043580143487923, + 0.9771236671519792, + 1, + 1, + 0.999999940395355 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": -22.916092751207238, + "y": -7.146730730788997, + "z": 4.032780160581905 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "_groupIndex": 1, + "groupIndex": 1, + "_id": "45iO7ysSJDW788NCC8lT1V" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 L Toe0", + "_objFlags": 0, + "_parent": { + "__id__": 62 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 64 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0.076642207801342, + 0.155043706297874, + -4.76837147544984e-9, + 0.25268429538628456, + 0.0560201070474476, + -0.209063366350112, + 0.9430296407440691, + 1.00000011920929, + 1.00000011920929, + 0.999999940395355 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 32.498615550966655, + "y": 13.12438813569228, + "z": -21.468835689403612 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "_groupIndex": 1, + "groupIndex": 1, + "_id": "13w8ZtY+5AxZ6rmliv9Kjb" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 18 + }, + "asset": { + "__uuid__": "8c9c3331-f5ac-4c3d-87e5-5aae0064e329" + }, + "fileId": "Bip001/Bip001 Pelvis/Bip001 Spine/Bip001 L Thigh/Bip001 L Calf/Bip001 L Foot/Bip001 L Toe0", + "sync": false + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 18 + }, + "asset": { + "__uuid__": "8c9c3331-f5ac-4c3d-87e5-5aae0064e329" + }, + "fileId": "Bip001/Bip001 Pelvis/Bip001 Spine/Bip001 L Thigh/Bip001 L Calf/Bip001 L Foot", + "sync": false + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 18 + }, + "asset": { + "__uuid__": "8c9c3331-f5ac-4c3d-87e5-5aae0064e329" + }, + "fileId": "Bip001/Bip001 Pelvis/Bip001 Spine/Bip001 L Thigh/Bip001 L Calf", + "sync": false + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 18 + }, + "asset": { + "__uuid__": "8c9c3331-f5ac-4c3d-87e5-5aae0064e329" + }, + "fileId": "Bip001/Bip001 Pelvis/Bip001 Spine/Bip001 L Thigh", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "Bip001 R Thigh", + "_objFlags": 0, + "_parent": { + "__id__": 21 + }, + "_children": [ + { + "__id__": 69 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 75 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -0.111189156770706, + 0.0181316807866096, + -0.0943779274821281, + 0.09901793131776596, + 0.9943849617242725, + -0.024297106481647446, + 0.028348682346573516, + 1, + 1.00000011920929, + 1.00000023841858 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 3.1526958182078615, + "y": 176.4226900958726, + "z": 11.276638781783863 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "_groupIndex": 1, + "groupIndex": 1, + "_id": "dfw268bb5N0qsVnJg4BL/W" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 R Calf", + "_objFlags": 0, + "_parent": { + "__id__": 68 + }, + "_children": [ + { + "__id__": 70 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 74 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0.213316529989243, + 4.44089199923895e-18, + -9.53674295089968e-9, + 2.5651858546827006e-17, + -1.0599709211943675e-17, + -0.38189485814894936, + 0.9242057765018534, + 1.00000011920929, + 1.00000023841858, + 1.00000011920929 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 3.1805541169849224e-15, + "y": 6.440166337472359e-23, + "z": -44.90220803887089 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "_groupIndex": 1, + "groupIndex": 1, + "_id": "a7Uh7QsYlC277ojhPtNd0W" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 R Foot", + "_objFlags": 0, + "_parent": { + "__id__": 69 + }, + "_children": [ + { + "__id__": 71 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 73 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0.194084525108337, + -2.8610228852699e-8, + 0, + 0.08537962721962013, + 0.0820936008367121, + 0.3615101096692318, + 0.9248142519254563, + 0.999999821186066, + 0.99999988079071, + 0.99999988079071 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 7.752139119983778, + "y": 7.083678537549837, + "z": 43.05323970457493 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "_groupIndex": 1, + "groupIndex": 1, + "_id": "f1I1jFZNZCg72d6zcTZny+" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 R Toe0", + "_objFlags": 0, + "_parent": { + "__id__": 70 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 72 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0.0766422152519226, + 0.155043691396713, + -9.53674295089968e-9, + -0.12414516601262598, + 0.17729775533320677, + 0.7997349422717762, + 0.5599799155497119, + 1, + 1, + 0.999999940395355 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": -126.25865570455785, + "y": 130.7358726762891, + "z": 58.39155492610611 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "_groupIndex": 1, + "groupIndex": 1, + "_id": "f2eKlkh3pPJbRotsVfaFM9" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 18 + }, + "asset": { + "__uuid__": "8c9c3331-f5ac-4c3d-87e5-5aae0064e329" + }, + "fileId": "Bip001/Bip001 Pelvis/Bip001 Spine/Bip001 R Thigh/Bip001 R Calf/Bip001 R Foot/Bip001 R Toe0", + "sync": false + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 18 + }, + "asset": { + "__uuid__": "8c9c3331-f5ac-4c3d-87e5-5aae0064e329" + }, + "fileId": "Bip001/Bip001 Pelvis/Bip001 Spine/Bip001 R Thigh/Bip001 R Calf/Bip001 R Foot", + "sync": false + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 18 + }, + "asset": { + "__uuid__": "8c9c3331-f5ac-4c3d-87e5-5aae0064e329" + }, + "fileId": "Bip001/Bip001 Pelvis/Bip001 Spine/Bip001 R Thigh/Bip001 R Calf", + "sync": false + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 18 + }, + "asset": { + "__uuid__": "8c9c3331-f5ac-4c3d-87e5-5aae0064e329" + }, + "fileId": "Bip001/Bip001 Pelvis/Bip001 Spine/Bip001 R Thigh", + "sync": false + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 18 + }, + "asset": { + "__uuid__": "8c9c3331-f5ac-4c3d-87e5-5aae0064e329" + }, + "fileId": "Bip001/Bip001 Pelvis/Bip001 Spine", + "sync": false + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 18 + }, + "asset": { + "__uuid__": "8c9c3331-f5ac-4c3d-87e5-5aae0064e329" + }, + "fileId": "Bip001/Bip001 Pelvis", + "sync": false + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 18 + }, + "asset": { + "__uuid__": "8c9c3331-f5ac-4c3d-87e5-5aae0064e329" + }, + "fileId": "Bip001", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "Box002", + "_objFlags": 0, + "_parent": { + "__id__": 18 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 80 + } + ], + "_prefab": { + "__id__": 81 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0.710542798042297, + 0.649085521697998, + 0, + 8.146034247147357e-8, + 0, + 0, + 0.9999999999999967, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0.000009334667642611461, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "_groupIndex": 1, + "groupIndex": 1, + "_id": "65gIWTyydKPYw4Lu7FsYGV" + }, + { + "__type__": "cc.SkinnedMeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 79 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "546f85cd-bd34-42bd-9471-ad503d002d6b" + } + ], + "_mesh": { + "__uuid__": "2a6e7251-7cb4-4aaf-a6b8-d4139097ab9c" + }, + "_receiveShadows": false, + "_shadowCastingMode": 0, + "_enableAutoBatch": false, + "textures": [], + "_skeleton": { + "__uuid__": "4fa9a064-3c69-4c6f-b9a4-f6038b38adbe" + }, + "_rootBone": { + "__id__": 18 + }, + "_id": "60LAZbthBOmovVxLA4ez1U" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 18 + }, + "asset": { + "__uuid__": "8c9c3331-f5ac-4c3d-87e5-5aae0064e329" + }, + "fileId": "Box002", + "sync": false + }, + { + "__type__": "cc.SkeletonAnimation", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 18 + }, + "_enabled": true, + "_defaultClip": { + "__uuid__": "7ac516c8-693e-440c-a670-d611ef4ff9a6" + }, + "_clips": [ + { + "__uuid__": "7ac516c8-693e-440c-a670-d611ef4ff9a6" + }, + { + "__uuid__": "7953fefc-ce2a-47d3-9be5-b73b81d8e10d" + }, + { + "__uuid__": "71581864-8bfc-4750-b680-8b8fe0a4c05c" + } + ], + "playOnLoad": false, + "_model": { + "__uuid__": "dc2073f0-957d-42c4-bde1-e912ae7a2b5f" + }, + "_id": "21ky2OGn1M0JcFXQ2dxnZb" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 18 + }, + "asset": { + "__uuid__": "8c9c3331-f5ac-4c3d-87e5-5aae0064e329" + }, + "fileId": "dc2073f0-957d-42c4-bde1-e912ae7a2b5f", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "New Box", + "_objFlags": 0, + "_parent": { + "__id__": 13 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 85 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 100, + 1, + 100 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "_groupIndex": 1, + "groupIndex": 1, + "_id": "59mZaSdABA4p3NtR/hFfWv" + }, + { + "__type__": "cc.MeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 84 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "a5849239-3ad3-41d1-8ab4-ae9fea11f97f" + } + ], + "_mesh": { + "__uuid__": "a1ef2fc9-9c57-418a-8f69-6bed9a7a0e7f" + }, + "_receiveShadows": false, + "_shadowCastingMode": 0, + "_enableAutoBatch": false, + "textures": [], + "_id": "28HXKOusNE35Ktw9gvNuWQ" + } +] \ No newline at end of file diff --git a/CameraDemo/assets/Scenes/Game.fire.meta b/CameraDemo/assets/Scenes/Game.fire.meta new file mode 100644 index 0000000..3cbfb55 --- /dev/null +++ b/CameraDemo/assets/Scenes/Game.fire.meta @@ -0,0 +1,7 @@ +{ + "ver": "1.2.7", + "uuid": "77266bc1-4497-473b-b59c-045f432b9150", + "asyncLoadAssets": false, + "autoReleaseAssets": true, + "subMetas": {} +} \ No newline at end of file diff --git a/CameraDemo/assets/people001.fbx b/CameraDemo/assets/people001.fbx new file mode 100644 index 0000000..3066509 Binary files /dev/null and b/CameraDemo/assets/people001.fbx differ diff --git a/CameraDemo/assets/people001.fbx.meta b/CameraDemo/assets/people001.fbx.meta new file mode 100644 index 0000000..d67d26e --- /dev/null +++ b/CameraDemo/assets/people001.fbx.meta @@ -0,0 +1,235 @@ +{ + "ver": "1.1.0", + "uuid": "dc2073f0-957d-42c4-bde1-e912ae7a2b5f", + "scaleFactor": 1, + "boneCount": 30, + "precomputeJointMatrix": false, + "animationFrameRate": 30, + "subMetas": { + "buffer.bin": { + "ver": "1.0.0", + "uuid": "ee6408c2-35ef-4f05-bdc3-9048e4a8e0b9", + "name": "buffer.bin", + "subMetas": {} + }, + "Box002.mesh": { + "ver": "1.0.1", + "uuid": "2a6e7251-7cb4-4aaf-a6b8-d4139097ab9c", + "verts": 1832, + "tris": 2814, + "submeshes": 1, + "attributes": [ + [ + "a_joints", + "a_normal", + "a_position", + "a_uv0", + "a_weights" + ] + ], + "minPos": { + "x": -0.598444759845734, + "y": -0.649927198886871, + "z": -0.196961551904678 + }, + "maxPos": { + "x": 0.598444759845734, + "y": 0.649927198886871, + "z": 0.196961551904678 + }, + "name": "Box002.mesh", + "subMetas": {} + }, + "people001-0.skeleton": { + "ver": "1.0.1", + "uuid": "4fa9a064-3c69-4c6f-b9a4-f6038b38adbe", + "name": "people001-0.skeleton", + "subMetas": {} + }, + "idle.sac": { + "ver": "1.0.1", + "uuid": "71581864-8bfc-4750-b680-8b8fe0a4c05c", + "modelUuid": "dc2073f0-957d-42c4-bde1-e912ae7a2b5f", + "animationID": 0, + "name": "idle.sac", + "maxFrameCount": 51, + "totalFrameCount": 533, + "duration": 2.0833332538604736, + "animationFrameRate": 30, + "subMetas": {} + }, + "run.sac": { + "ver": "1.0.1", + "uuid": "11afb3d2-c478-43c9-a20b-abaa6568e3bd", + "modelUuid": "dc2073f0-957d-42c4-bde1-e912ae7a2b5f", + "animationID": 1, + "name": "run.sac", + "maxFrameCount": 21, + "totalFrameCount": 489, + "duration": 0.8333333134651184, + "animationFrameRate": 30, + "subMetas": {} + }, + "dance.sac": { + "ver": "1.0.1", + "uuid": "7ac516c8-693e-440c-a670-d611ef4ff9a6", + "modelUuid": "dc2073f0-957d-42c4-bde1-e912ae7a2b5f", + "animationID": 2, + "name": "dance.sac", + "maxFrameCount": 118, + "totalFrameCount": 2995, + "duration": 4.875, + "animationFrameRate": 30, + "subMetas": {} + }, + "attack.sac": { + "ver": "1.0.1", + "uuid": "85a27df1-661f-44c9-8d19-19b751bfc47c", + "modelUuid": "dc2073f0-957d-42c4-bde1-e912ae7a2b5f", + "animationID": 3, + "name": "attack.sac", + "maxFrameCount": 19, + "totalFrameCount": 252, + "duration": 0.75, + "animationFrameRate": 30, + "subMetas": {} + }, + "die.sac": { + "ver": "1.0.1", + "uuid": "7953fefc-ce2a-47d3-9be5-b73b81d8e10d", + "modelUuid": "dc2073f0-957d-42c4-bde1-e912ae7a2b5f", + "animationID": 4, + "name": "die.sac", + "maxFrameCount": 43, + "totalFrameCount": 983, + "duration": 1.7916666269302368, + "animationFrameRate": 30, + "subMetas": {} + }, + "people001.prefab": { + "ver": "1.2.7", + "uuid": "8c9c3331-f5ac-4c3d-87e5-5aae0064e329", + "optimizationPolicy": "AUTO", + "asyncLoadAssets": false, + "readonly": true, + "content": [ + { + "__type__": "cc.Prefab", + "_name": "", + "_objFlags": 0, + "data": { + "__id__": 1 + } + }, + { + "__type__": "cc.Node", + "_name": "Sprite", + "_objFlags": 0, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_cascadeOpacityEnabled": true, + "_parent": null, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 40, + "height": 36 + }, + "_children": [], + "_skewX": 0, + "_skewY": 0, + "_localZOrder": 0, + "_globalZOrder": 0, + "_tag": -1, + "_opacityModifyRGB": false, + "_reorderChildDirty": false, + "_id": "", + "_active": true, + "_components": [ + { + "__id__": 2 + } + ], + "_prefab": { + "__id__": 3 + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "_spriteFrame": { + "__uuid__": "8cdb44ac-a3f6-449f-b354-7cd48cf84061" + }, + "_type": 0, + "_sizeMode": 1, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_atlas": null + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": null, + "fileId": "d7118yAG5lKybkFOAh8koPL" + } + ], + "name": "people001.prefab", + "subMetas": {} + }, + "03 - Default.mtl": { + "ver": "1.0.3", + "uuid": "546f85cd-bd34-42bd-9471-ad503d002d6b", + "dataAsSubAsset": null, + "name": "03 - Default.mtl", + "subMetas": {} + } + } +} \ No newline at end of file diff --git a/CameraDemo/creator.d.ts b/CameraDemo/creator.d.ts new file mode 100644 index 0000000..baca55f --- /dev/null +++ b/CameraDemo/creator.d.ts @@ -0,0 +1,32244 @@ + +/** !#en +The main namespace of Cocos2d-JS, all engine core classes, functions, properties and constants are defined in this namespace. +!#zh +Cocos 引擎的主要命名空间,引擎代码中所有的类,函数,属性和常量都在这个命名空间中定义。 */ +declare namespace cc { + /** The current version of Cocos2d being used.
+ Please DO NOT remove this String, it is an important flag for bug tracking.
+ If you post a bug to forum, please attach this flag. */ + export var ENGINE_VERSION: string; + /** + !#en + Creates the speed action which changes the speed of an action, making it take longer (speed > 1) + or less (speed < 1) time.
+ Useful to simulate 'slow motion' or 'fast forward' effect. + !#zh 修改目标动作的速率。 + @param action action + @param speed speed + + @example + ```js + // change the target action speed; + var action = cc.scaleTo(0.2, 1, 0.6); + var newAction = cc.speed(action, 0.5); + ``` + */ + export function speed(action: ActionInterval, speed: number): Action; + /** + !#en Create a follow action which makes its target follows another node. + !#zh 追踪目标节点的位置。 + @param followedNode followedNode + @param rect rect + + @example + ```js + // example + // creates the action with a set boundary + var followAction = cc.follow(targetNode, cc.rect(0, 0, screenWidth * 2 - 100, screenHeight)); + node.runAction(followAction); + + // creates the action with no boundary set + var followAction = cc.follow(targetNode); + node.runAction(followAction); + ``` + */ + export function follow(followedNode: Node, rect: Rect): Action; + /** + Points setter + @param points points + */ + export function setPoints(points: any[]): void; + /** + !#en Creates an action with a Cardinal Spline array of points and tension. + !#zh 按基数样条曲线轨迹移动到目标位置。 + @param duration duration + @param points array of control points + @param tension tension + + @example + ```js + //create a cc.CardinalSplineTo + var action1 = cc.cardinalSplineTo(3, array, 0); + ``` + */ + export function cardinalSplineTo(duration: number, points: any[], tension: number): ActionInterval; + /** + update position of target + @param newPos newPos + */ + export function updatePosition(newPos: Vec2): void; + /** + !#en Creates an action with a Cardinal Spline array of points and tension. + !#zh 按基数样条曲线轨迹移动指定的距离。 + @param duration duration + @param points points + @param tension tension + */ + export function cardinalSplineBy(duration: number, points: any[], tension: number): ActionInterval; + /** + !#en Creates an action with a Cardinal Spline array of points and tension. + !#zh 按 Catmull Rom 样条曲线轨迹移动到目标位置。 + @param dt dt + @param points points + + @example + ```js + var action1 = cc.catmullRomTo(3, array); + ``` + */ + export function catmullRomTo(dt: number, points: any[]): ActionInterval; + /** + !#en Creates an action with a Cardinal Spline array of points and tension. + !#zh 按 Catmull Rom 样条曲线轨迹移动指定的距离。 + @param dt dt + @param points points + + @example + ```js + var action1 = cc.catmullRomBy(3, array); + ``` + */ + export function catmullRomBy(dt: number, points: any[]): ActionInterval; + /** + !#en Show the Node. + !#zh 立即显示。 + + @example + ```js + // example + var showAction = cc.show(); + ``` + */ + export function show(): ActionInstant; + /** + !#en Hide the node. + !#zh 立即隐藏。 + + @example + ```js + // example + var hideAction = cc.hide(); + ``` + */ + export function hide(): ActionInstant; + /** + !#en Toggles the visibility of a node. + !#zh 显隐状态切换。 + + @example + ```js + // example + var toggleVisibilityAction = cc.toggleVisibility(); + ``` + */ + export function toggleVisibility(): ActionInstant; + /** + !#en Create a RemoveSelf object with a flag indicate whether the target should be cleaned up while removing. + !#zh 从父节点移除自身。 + @param isNeedCleanUp isNeedCleanUp + + @example + ```js + // example + var removeSelfAction = cc.removeSelf(); + ``` + */ + export function removeSelf(isNeedCleanUp ?: boolean): ActionInstant; + /** + !#en Destroy self + !#zh 创建一个销毁自身的动作。 + + @example + ```js + var destroySelfAction = cc.destroySelf(); + ``` + */ + export function destroySelf(): ActionInstant; + /** + !#en Create a FlipX action to flip or unflip the target. + !#zh X轴翻转。 + @param flip Indicate whether the target should be flipped or not + + @example + ```js + var flipXAction = cc.flipX(true); + ``` + */ + export function flipX(flip: boolean): ActionInstant; + /** + !#en Create a FlipY action to flip or unflip the target. + !#zh Y轴翻转。 + @param flip flip + + @example + ```js + var flipYAction = cc.flipY(true); + ``` + */ + export function flipY(flip: boolean): ActionInstant; + /** + !#en Creates a Place action with a position. + !#zh 放置在目标位置。 + @param pos pos + @param y y + + @example + ```js + // example + var placeAction = cc.place(cc.v2(200, 200)); + var placeAction = cc.place(200, 200); + ``` + */ + export function place(pos: Vec2|number, y?: number): ActionInstant; + /** + !#en Creates the action with the callback. + !#zh 执行回调函数。 + @param selector selector + @param selectorTarget selectorTarget + @param data data for function, it accepts all data types. + + @example + ```js + // example + // CallFunc without data + var finish = cc.callFunc(this.removeSprite, this); + + // CallFunc with data + var finish = cc.callFunc(this.removeFromParentAndCleanup, this._grossini, true); + ``` + */ + export function callFunc(selector: Function, selectorTarget?: any, data?: any): ActionInstant; + /** + !#en + Creates the action easing object with the rate parameter.
+ From slow to fast. + !#zh 创建 easeIn 缓动对象,由慢到快。 + @param rate rate + + @example + ```js + action.easing(cc.easeIn(3.0)); + ``` + */ + export function easeIn(rate: number): any; + /** + !#en + Creates the action easing object with the rate parameter.
+ From fast to slow. + !#zh 创建 easeOut 缓动对象,由快到慢。 + @param rate rate + + @example + ```js + action.easing(cc.easeOut(3.0)); + ``` + */ + export function easeOut(rate: number): any; + /** + !#en + Creates the action easing object with the rate parameter.
+ Slow to fast then to slow. + !#zh 创建 easeInOut 缓动对象,慢到快,然后慢。 + @param rate rate + + @example + ```js + action.easing(cc.easeInOut(3.0)); + ``` + */ + export function easeInOut(rate: number): any; + /** + !#en + Creates the action easing object with the rate parameter.
+ Reference easeInExpo:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeExponentialIn 缓动对象。
+ EaseExponentialIn 是按指数函数缓动进入的动作。
+ 参考 easeInExpo:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + action.easing(cc.easeExponentialIn()); + ``` + */ + export function easeExponentialIn(): any; + /** + !#en + Creates the action easing object.
+ Reference easeOutExpo:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeExponentialOut 缓动对象。
+ EaseExponentialOut 是按指数函数缓动退出的动作。
+ 参考 easeOutExpo:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + action.easing(cc.easeExponentialOut()); + ``` + */ + export function easeExponentialOut(): any; + /** + !#en + Creates an EaseExponentialInOut action easing object.
+ Reference easeInOutExpo:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeExponentialInOut 缓动对象。
+ EaseExponentialInOut 是按指数函数缓动进入并退出的动作。
+ 参考 easeInOutExpo:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + action.easing(cc.easeExponentialInOut()); + ``` + */ + export function easeExponentialInOut(): any; + /** + !#en + Creates an EaseSineIn action.
+ Reference easeInSine:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 EaseSineIn 缓动对象。
+ EaseSineIn 是按正弦函数缓动进入的动作。
+ 参考 easeInSine:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + action.easing(cc.easeSineIn()); + ``` + */ + export function easeSineIn(): any; + /** + !#en + Creates an EaseSineOut action easing object.
+ Reference easeOutSine:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 EaseSineOut 缓动对象。
+ EaseSineIn 是按正弦函数缓动退出的动作。
+ 参考 easeOutSine:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + action.easing(cc.easeSineOut()); + ``` + */ + export function easeSineOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInOutSine:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeSineInOut 缓动对象。
+ EaseSineIn 是按正弦函数缓动进入并退出的动作。
+ 参考 easeInOutSine:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + action.easing(cc.easeSineInOut()); + ``` + */ + export function easeSineInOut(): any; + /** + !#en + Creates the action easing object with the period in radians (default is 0.3).
+ Reference easeInElastic:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeElasticIn 缓动对象。
+ EaseElasticIn 是按弹性曲线缓动进入的动作。
+ 参数 easeInElastic:http://www.zhihu.com/question/21981571/answer/19925418 + @param period period + + @example + ```js + // example + action.easing(cc.easeElasticIn(3.0)); + ``` + */ + export function easeElasticIn(period: number): any; + /** + !#en + Creates the action easing object with the period in radians (default is 0.3).
+ Reference easeOutElastic:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeElasticOut 缓动对象。
+ EaseElasticOut 是按弹性曲线缓动退出的动作。
+ 参考 easeOutElastic:http://www.zhihu.com/question/21981571/answer/19925418 + @param period period + + @example + ```js + // example + action.easing(cc.easeElasticOut(3.0)); + ``` + */ + export function easeElasticOut(period: number): any; + /** + !#en + Creates the action easing object with the period in radians (default is 0.3).
+ Reference easeInOutElastic:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeElasticInOut 缓动对象。
+ EaseElasticInOut 是按弹性曲线缓动进入并退出的动作。
+ 参考 easeInOutElastic:http://www.zhihu.com/question/21981571/answer/19925418 + @param period period + + @example + ```js + // example + action.easing(cc.easeElasticInOut(3.0)); + ``` + */ + export function easeElasticInOut(period: number): any; + /** + !#en + Creates the action easing object.
+ Eased bounce effect at the beginning. + !#zh + 创建 easeBounceIn 缓动对象。
+ EaseBounceIn 是按弹跳动作缓动进入的动作。 + + @example + ```js + // example + action.easing(cc.easeBounceIn()); + ``` + */ + export function easeBounceIn(): any; + /** + !#en + Creates the action easing object.
+ Eased bounce effect at the ending. + !#zh + 创建 easeBounceOut 缓动对象。
+ EaseBounceOut 是按弹跳动作缓动退出的动作。 + + @example + ```js + // example + action.easing(cc.easeBounceOut()); + ``` + */ + export function easeBounceOut(): any; + /** + !#en + Creates the action easing object.
+ Eased bounce effect at the begining and ending. + !#zh + 创建 easeBounceInOut 缓动对象。
+ EaseBounceInOut 是按弹跳动作缓动进入并退出的动作。 + + @example + ```js + // example + action.easing(cc.easeBounceInOut()); + ``` + */ + export function easeBounceInOut(): any; + /** + !#en + Creates the action easing object.
+ In the opposite direction to move slowly, and then accelerated to the right direction. + !#zh + 创建 easeBackIn 缓动对象。
+ easeBackIn 是在相反的方向缓慢移动,然后加速到正确的方向。
+ + @example + ```js + // example + action.easing(cc.easeBackIn()); + ``` + */ + export function easeBackIn(): any; + /** + !#en + Creates the action easing object.
+ Fast moving more than the finish, and then slowly back to the finish. + !#zh + 创建 easeBackOut 缓动对象。
+ easeBackOut 快速移动超出目标,然后慢慢回到目标点。 + + @example + ```js + // example + action.easing(cc.easeBackOut()); + ``` + */ + export function easeBackOut(): any; + /** + !#en + Creates the action easing object.
+ Begining of cc.EaseBackIn. Ending of cc.EaseBackOut. + !#zh + 创建 easeBackInOut 缓动对象。
+ + @example + ```js + // example + action.easing(cc.easeBackInOut()); + ``` + */ + export function easeBackInOut(): any; + /** + !#en + Creates the action easing object.
+ Into the 4 reference point.
+ To calculate the motion curve. + !#zh + 创建 easeBezierAction 缓动对象。
+ EaseBezierAction 是按贝塞尔曲线缓动的动作。 + @param p0 The first bezier parameter + @param p1 The second bezier parameter + @param p2 The third bezier parameter + @param p3 The fourth bezier parameter + + @example + ```js + // example + action.easing(cc.easeBezierAction(0.5, 0.5, 1.0, 1.0)); + ``` + */ + export function easeBezierAction(p0: number, p1: number, p2: number, p3: number): any; + /** + !#en + Creates the action easing object.
+ Reference easeInQuad:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuadraticActionIn 缓动对象。
+ EaseQuadraticIn是按二次函数缓动进入的动作。
+ 参考 easeInQuad:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeQuadraticActionIn()); + ``` + */ + export function easeQuadraticActionIn(): any; + /** + !#en + Creates the action easing object.
+ Reference easeOutQuad:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuadraticActionOut 缓动对象。
+ EaseQuadraticOut 是按二次函数缓动退出的动作。
+ 参考 easeOutQuad:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeQuadraticActionOut()); + ``` + */ + export function easeQuadraticActionOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInOutQuad:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuadraticActionInOut 缓动对象。
+ EaseQuadraticInOut 是按二次函数缓动进入并退出的动作。
+ 参考 easeInOutQuad:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeQuadraticActionInOut()); + ``` + */ + export function easeQuadraticActionInOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeIntQuart:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuarticActionIn 缓动对象。
+ EaseQuarticIn 是按四次函数缓动进入的动作。
+ 参考 easeIntQuart:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeQuarticActionIn()); + ``` + */ + export function easeQuarticActionIn(): any; + /** + !#en + Creates the action easing object.
+ Reference easeOutQuart:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuarticActionOut 缓动对象。
+ EaseQuarticOut 是按四次函数缓动退出的动作。
+ 参考 easeOutQuart:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.QuarticActionOut()); + ``` + */ + export function easeQuarticActionOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInOutQuart:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuarticActionInOut 缓动对象。
+ EaseQuarticInOut 是按四次函数缓动进入并退出的动作。
+ 参考 easeInOutQuart:http://www.zhihu.com/question/21981571/answer/19925418 + */ + export function easeQuarticActionInOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInQuint:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuinticActionIn 缓动对象。
+ EaseQuinticIn 是按五次函数缓动进的动作。
+ 参考 easeInQuint:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeQuinticActionIn()); + ``` + */ + export function easeQuinticActionIn(): any; + /** + !#en + Creates the action easing object.
+ Reference easeOutQuint:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuinticActionOut 缓动对象。
+ EaseQuinticOut 是按五次函数缓动退出的动作 + 参考 easeOutQuint:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeQuadraticActionOut()); + ``` + */ + export function easeQuinticActionOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInOutQuint:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuinticActionInOut 缓动对象。
+ EaseQuinticInOut是按五次函数缓动进入并退出的动作。
+ 参考 easeInOutQuint:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeQuinticActionInOut()); + ``` + */ + export function easeQuinticActionInOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInCirc:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeCircleActionIn 缓动对象。
+ EaseCircleIn是按圆形曲线缓动进入的动作。
+ 参考 easeInCirc:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeCircleActionIn()); + ``` + */ + export function easeCircleActionIn(): any; + /** + !#en + Creates the action easing object.
+ Reference easeOutCirc:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeCircleActionOut 缓动对象。
+ EaseCircleOut是按圆形曲线缓动退出的动作。
+ 参考 easeOutCirc:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + actioneasing(cc.easeCircleActionOut()); + ``` + */ + export function easeCircleActionOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInOutCirc:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeCircleActionInOut 缓动对象。
+ EaseCircleInOut 是按圆形曲线缓动进入并退出的动作。
+ 参考 easeInOutCirc:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeCircleActionInOut()); + ``` + */ + export function easeCircleActionInOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInCubic:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeCubicActionIn 缓动对象。
+ EaseCubicIn 是按三次函数缓动进入的动作。
+ 参考 easeInCubic:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeCubicActionIn()); + ``` + */ + export function easeCubicActionIn(): any; + /** + !#en + Creates the action easing object.
+ Reference easeOutCubic:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeCubicActionOut 缓动对象。
+ EaseCubicOut 是按三次函数缓动退出的动作。
+ 参考 easeOutCubic:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeCubicActionOut()); + ``` + */ + export function easeCubicActionOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInOutCubic:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeCubicActionInOut 缓动对象。
+ EaseCubicInOut是按三次函数缓动进入并退出的动作。
+ 参考 easeInOutCubic:http://www.zhihu.com/question/21981571/answer/19925418 + */ + export function easeCubicActionInOut(): any; + /** + !#en + Helper constructor to create an array of sequenceable actions + The created action will run actions sequentially, one after another. + !#zh 顺序执行动作,创建的动作将按顺序依次运行。 + @param actionOrActionArray actionOrActionArray + @param tempArray tempArray + + @example + ```js + // example + // create sequence with actions + var seq = cc.sequence(act1, act2); + + // create sequence with array + var seq = cc.sequence(actArray); + ``` + */ + export function sequence(actionOrActionArray: FiniteTimeAction|FiniteTimeAction[], ...tempArray: FiniteTimeAction[]): ActionInterval; + /** + !#en Creates a Repeat action. Times is an unsigned integer between 1 and pow(2,30) + !#zh 重复动作,可以按一定次数重复一个动,如果想永远重复一个动作请使用 repeatForever 动作来完成。 + @param action action + @param times times + + @example + ```js + // example + var rep = cc.repeat(cc.sequence(jump2, jump1), 5); + ``` + */ + export function repeat(action: FiniteTimeAction, times: number): ActionInterval; + /** + !#en Create a acton which repeat forever, as it runs forever, it can't be added into cc.sequence and cc.spawn. + !#zh 永远地重复一个动作,有限次数内重复一个动作请使用 repeat 动作,由于这个动作不会停止,所以不能被添加到 cc.sequence 或 cc.spawn 中。 + @param action action + + @example + ```js + // example + var repeat = cc.repeatForever(cc.rotateBy(1.0, 360)); + ``` + */ + export function repeatForever(action: FiniteTimeAction): ActionInterval; + /** + !#en Create a spawn action which runs several actions in parallel. + !#zh 同步执行动作,同步执行一组动作。 + @param actionOrActionArray actionOrActionArray + @param tempArray tempArray + + @example + ```js + // example + var action = cc.spawn(cc.jumpBy(2, cc.v2(300, 0), 50, 4), cc.rotateBy(2, 720)); + todo:It should be the direct use new + ``` + */ + export function spawn(actionOrActionArray: FiniteTimeAction|FiniteTimeAction[], ...tempArray: FiniteTimeAction[]): FiniteTimeAction; + /** + !#en + Rotates a Node object to a certain angle by modifying its angle property.
+ The direction will be decided by the shortest angle. + !#zh 旋转到目标角度,通过逐帧修改它的 angle 属性,旋转方向将由最短的角度决定。 + @param duration duration in seconds + @param dstAngle dstAngle in degrees. + + @example + ```js + // example + var rotateTo = cc.rotateTo(2, 61.0); + ``` + */ + export function rotateTo(duration: number, dstAngle: number): ActionInterval; + /** + !#en + Rotates a Node object clockwise a number of degrees by modifying its angle property. + Relative to its properties to modify. + !#zh 旋转指定的角度。 + @param duration duration in seconds + @param deltaAngle deltaAngle in degrees + + @example + ```js + // example + var actionBy = cc.rotateBy(2, 360); + ``` + */ + export function rotateBy(duration: number, deltaAngle: number): ActionInterval; + /** + !#en + Moves a Node object x,y pixels by modifying its position property.
+ x and y are relative to the position of the object.
+ Several MoveBy actions can be concurrently called, and the resulting
+ movement will be the sum of individual movements. + !#zh 移动指定的距离。 + @param duration duration in seconds + @param deltaPos deltaPos + @param deltaY deltaY + + @example + ```js + // example + var actionTo = cc.moveBy(2, cc.v2(windowSize.width - 40, windowSize.height - 40)); + ``` + */ + export function moveBy(duration: number, deltaPos: Vec2|number, deltaY?: number): ActionInterval; + /** + !#en + Moves a Node object to the position x,y. x and y are absolute coordinates by modifying its position property.
+ Several MoveTo actions can be concurrently called, and the resulting
+ movement will be the sum of individual movements. + !#zh 移动到目标位置。 + @param duration duration in seconds + @param position position + @param y y + + @example + ```js + // example + var actionBy = cc.moveTo(2, cc.v2(80, 80)); + ``` + */ + export function moveTo(duration: number, position: Vec2|number, y?: number): ActionInterval; + /** + !#en + Create a action which skews a Node object to given angles by modifying its skewX and skewY properties. + Changes to the specified value. + !#zh 偏斜到目标角度。 + @param t time in seconds + @param sx sx + @param sy sy + + @example + ```js + // example + var actionTo = cc.skewTo(2, 37.2, -37.2); + ``` + */ + export function skewTo(t: number, sx: number, sy: number): ActionInterval; + /** + !#en + Skews a Node object by skewX and skewY degrees.
+ Relative to its property modification. + !#zh 偏斜指定的角度。 + @param t time in seconds + @param sx sx skew in degrees for X axis + @param sy sy skew in degrees for Y axis + + @example + ```js + // example + var actionBy = cc.skewBy(2, 0, -90); + ``` + */ + export function skewBy(t: number, sx: number, sy: number): ActionInterval; + /** + !#en + Moves a Node object simulating a parabolic jump movement by modifying it's position property. + Relative to its movement. + !#zh 用跳跃的方式移动指定的距离。 + @param duration duration + @param position position + @param y y + @param height height + @param jumps jumps + + @example + ```js + // example + var actionBy = cc.jumpBy(2, cc.v2(300, 0), 50, 4); + var actionBy = cc.jumpBy(2, 300, 0, 50, 4); + ``` + */ + export function jumpBy(duration: number, position: Vec2|number, y?: number, height?: number, jumps?: number): ActionInterval; + /** + !#en + Moves a Node object to a parabolic position simulating a jump movement by modifying its position property.
+ Jump to the specified location. + !#zh 用跳跃的方式移动到目标位置。 + @param duration duration + @param position position + @param y y + @param height height + @param jumps jumps + + @example + ```js + // example + var actionTo = cc.jumpTo(2, cc.v2(300, 300), 50, 4); + var actionTo = cc.jumpTo(2, 300, 300, 50, 4); + ``` + */ + export function jumpTo(duration: number, position: Vec2|number, y?: number, height?: number, jumps?: number): ActionInterval; + /** + !#en + An action that moves the target with a cubic Bezier curve by a certain distance. + Relative to its movement. + !#zh 按贝赛尔曲线轨迹移动指定的距离。 + @param t time in seconds + @param c Array of points + + @example + ```js + // example + var bezier = [cc.v2(0, windowSize.height / 2), cc.v2(300, -windowSize.height / 2), cc.v2(300, 100)]; + var bezierForward = cc.bezierBy(3, bezier); + ``` + */ + export function bezierBy(t: number, c: Vec2[]): ActionInterval; + /** + !#en An action that moves the target with a cubic Bezier curve to a destination point. + !#zh 按贝赛尔曲线轨迹移动到目标位置。 + @param t t + @param c Array of points + + @example + ```js + // example + var bezier = [cc.v2(0, windowSize.height / 2), cc.v2(300, -windowSize.height / 2), cc.v2(300, 100)]; + var bezierTo = cc.bezierTo(2, bezier); + ``` + */ + export function bezierTo(t: number, c: Vec2[]): ActionInterval; + /** + !#en Scales a Node object to a zoom factor by modifying it's scale property. + !#zh 将节点大小缩放到指定的倍数。 + @param duration duration + @param sx scale parameter in X + @param sy scale parameter in Y, if Null equal to sx + + @example + ```js + // example + // It scales to 0.5 in both X and Y. + var actionTo = cc.scaleTo(2, 0.5); + + // It scales to 0.5 in x and 2 in Y + var actionTo = cc.scaleTo(2, 0.5, 2); + ``` + */ + export function scaleTo(duration: number, sx: number, sy?: number): ActionInterval; + /** + !#en + Scales a Node object a zoom factor by modifying it's scale property. + Relative to its changes. + !#zh 按指定的倍数缩放节点大小。 + @param duration duration in seconds + @param sx sx scale parameter in X + @param sy sy scale parameter in Y, if Null equal to sx + + @example + ```js + // example without sy, it scales by 2 both in X and Y + var actionBy = cc.scaleBy(2, 2); + + //example with sy, it scales by 0.25 in X and 4.5 in Y + var actionBy2 = cc.scaleBy(2, 0.25, 4.5); + ``` + */ + export function scaleBy(duration: number, sx: number, sy?: number|void): ActionInterval; + /** + !#en Blinks a Node object by modifying it's visible property. + !#zh 闪烁(基于透明度)。 + @param duration duration in seconds + @param blinks blinks in times + + @example + ```js + // example + var action = cc.blink(2, 10); + ``` + */ + export function blink(duration: number, blinks: number): ActionInterval; + /** + !#en + Fades an object that implements the cc.RGBAProtocol protocol. + It modifies the opacity from the current value to a custom one. + !#zh 修改透明度到指定值。 + @param duration duration + @param opacity 0-255, 0 is transparent + + @example + ```js + // example + var action = cc.fadeTo(1.0, 0); + ``` + */ + export function fadeTo(duration: number, opacity: number): ActionInterval; + /** + !#en Fades In an object that implements the cc.RGBAProtocol protocol. It modifies the opacity from 0 to 255. + !#zh 渐显效果。 + @param duration duration in seconds + + @example + ```js + //example + var action = cc.fadeIn(1.0); + ``` + */ + export function fadeIn(duration: number): ActionInterval; + /** + !#en Fades Out an object that implements the cc.RGBAProtocol protocol. It modifies the opacity from 255 to 0. + !#zh 渐隐效果。 + @param d duration in seconds + + @example + ```js + // example + var action = cc.fadeOut(1.0); + ``` + */ + export function fadeOut(d: number): ActionInterval; + /** + !#en Tints a Node that implements the cc.NodeRGB protocol from current tint to a custom one. + !#zh 修改颜色到指定值。 + @param duration duration + @param red 0-255 + @param green 0-255 + @param blue 0-255 + + @example + ```js + // example + var action = cc.tintTo(2, 255, 0, 255); + ``` + */ + export function tintTo(duration: number, red: number, green: number, blue: number): ActionInterval; + /** + !#en + Tints a Node that implements the cc.NodeRGB protocol from current tint to a custom one. + Relative to their own color change. + !#zh 按照指定的增量修改颜色。 + @param duration duration in seconds + @param deltaRed deltaRed + @param deltaGreen deltaGreen + @param deltaBlue deltaBlue + + @example + ```js + // example + var action = cc.tintBy(2, -127, -255, -127); + ``` + */ + export function tintBy(duration: number, deltaRed: number, deltaGreen: number, deltaBlue: number): ActionInterval; + /** + !#en Delays the action a certain amount of seconds. + !#zh 延迟指定的时间量。 + @param d duration in seconds + + @example + ```js + // example + var delay = cc.delayTime(1); + ``` + */ + export function delayTime(d: number): ActionInterval; + /** + !#en Executes an action in reverse order, from time=duration to time=0. + !#zh 反转目标动作的时间轴。 + @param action action + + @example + ```js + // example + var reverse = cc.reverseTime(this); + ``` + */ + export function reverseTime(action: FiniteTimeAction): ActionInterval; + /** + !#en Create an action with the specified action and forced target. + !#zh 用已有动作和一个新的目标节点创建动作。 + @param target target + @param action action + */ + export function targetedAction(target: Node, action: FiniteTimeAction): ActionInterval; + /** + + @param target the target to animate + */ + export function tween (target?: T) : Tween; + /** !#en This is a Easing instance. + !#zh 这是一个 Easing 类实例。 */ + export var easing: Easing; + /** + !#en + Outputs an error message to the Cocos Creator Console (editor) or Web Console (runtime).
+ - In Cocos Creator, error is red.
+ - In Chrome, error have a red icon along with red message text.
+ !#zh + 输出错误消息到 Cocos Creator 编辑器的 Console 或运行时页面端的 Console 中。
+ - 在 Cocos Creator 中,错误信息显示是红色的。
+ - 在 Chrome 中,错误信息有红色的图标以及红色的消息文本。
+ @param msg A JavaScript string containing zero or more substitution strings. + @param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output. + */ + export function error(msg: any, ...subst: any[]): void; + /** + !#en + Outputs a warning message to the Cocos Creator Console (editor) or Web Console (runtime). + - In Cocos Creator, warning is yellow. + - In Chrome, warning have a yellow warning icon with the message text. + !#zh + 输出警告消息到 Cocos Creator 编辑器的 Console 或运行时 Web 端的 Console 中。
+ - 在 Cocos Creator 中,警告信息显示是黄色的。
+ - 在 Chrome 中,警告信息有着黄色的图标以及黄色的消息文本。
+ @param msg A JavaScript string containing zero or more substitution strings. + @param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output. + */ + export function warn(msg: any, ...subst: any[]): void; + /** + !#en Outputs a message to the Cocos Creator Console (editor) or Web Console (runtime). + !#zh 输出一条消息到 Cocos Creator 编辑器的 Console 或运行时 Web 端的 Console 中。 + @param msg A JavaScript string containing zero or more substitution strings. + @param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output. + */ + export function log(msg: string|any, ...subst: any[]): void; + /** !#en Director + !#zh 导演类。 */ + export var director: Director; + /** !#en This is a Game instance. + !#zh 这是一个 Game 类的实例,包含游戏主体信息并负责驱动游戏的游戏对象。。 */ + export var game: Game; + /** + !#en + Rotates a Node object to a certain angle by modifying its quternion property.
+ The direction will be decided by the shortest angle. + !#zh 旋转到目标角度,通过逐帧修改它的 quternion 属性,旋转方向将由最短的角度决定。 + @param duration duration in seconds + @param dstAngleX dstAngleX in degrees. + @param dstAngleY dstAngleY in degrees. + @param dstAngleZ dstAngleZ in degrees. + + @example + ```js + // example + var rotate3DTo = cc.rotate3DTo(2, cc.v3(0, 180, 0)); + ``` + */ + export function rotate3DTo(duration: number, dstAngleX: number|Vec3|Quat, dstAngleY?: number, dstAngleZ?: number): ActionInterval; + /** + !#en + Rotates a Node object counter clockwise a number of degrees by modifying its quaternion property. + Relative to its properties to modify. + !#zh 旋转指定的 3D 角度。 + @param duration duration in seconds + @param deltaAngleX deltaAngleX in degrees + @param deltaAngleY deltaAngleY in degrees + @param deltaAngleZ deltaAngleZ in degrees + + @example + ```js + // example + var actionBy = cc.rotate3DBy(2, cc.v3(0, 360, 0)); + ``` + */ + export function rotate3DBy(duration: number, deltaAngleX: number|Vec3, deltaAngleY?: number, deltaAngleZ?: number): ActionInterval; + export var assetManager: AssetManager; + /** !#en + cc.resources is a bundle and controls all asset under assets/resources + + !#zh + cc.resources 是一个 bundle,用于管理所有在 assets/resources 下的资源 */ + export var resources: AssetManager.Bundle; + /** !#en The System event singleton for global usage + !#zh 系统事件单例,方便全局使用 */ + export var systemEvent: SystemEvent; + /** + !#en Defines a CCClass using the given specification, please see [Class](/docs/editors_and_tools/creator-chapters/scripting/class.html) for details. + !#zh 定义一个 CCClass,传入参数必须是一个包含类型参数的字面量对象,具体用法请查阅[类型定义](/docs/creator/scripting/class.html)。 + @param options options + + @example + ```js + // define base class + var Node = cc.Class(); + + // define sub class + var Sprite = cc.Class({ + name: 'Sprite', + extends: Node, + + ctor: function () { + this.url = ""; + this.id = 0; + }, + + statics: { + // define static members + count: 0, + getBounds: function (spriteList) { + // compute bounds... + } + }, + + properties { + width: { + default: 128, + type: cc.Integer, + tooltip: 'The width of sprite' + }, + height: 128, + size: { + get: function () { + return cc.v2(this.width, this.height); + } + } + }, + + load: function () { + // load this.url... + }; + }); + + // instantiate + + var obj = new Sprite(); + obj.url = 'sprite.png'; + obj.load(); + ``` + */ + export function Class(options?: {name?: string; extends?: Function; ctor?: Function; __ctor__?: Function; properties?: any; statics?: any; mixins?: Function[]; editor?: {executeInEditMode?: boolean; requireComponent?: Function; menu?: string; executionOrder?: number; disallowMultiple?: boolean; playOnFocus?: boolean; inspector?: string; icon?: string; help?: string; }; update?: Function; lateUpdate?: Function; onLoad?: Function; start?: Function; onEnable?: Function; onDisable?: Function; onDestroy?: Function; onFocusInEditor?: Function; onLostFocusInEditor?: Function; resetInEditor?: Function; onRestore?: Function; _getLocalBounds?: Function; }): Function; + /** + !#en + Define an enum type.
+ If a enum item has a value of -1, it will be given an Integer number according to it's order in the list.
+ Otherwise it will use the value specified by user who writes the enum definition. + + !#zh + 定义一个枚举类型。
+ 用户可以把枚举值设为任意的整数,如果设为 -1,系统将会分配为上一个枚举值 + 1。 + @param obj a JavaScript literal object containing enum names and values, or a TypeScript enum type + + @example + ```js + // JavaScript: + + var WrapMode = cc.Enum({ + Repeat: -1, + Clamp: -1 + }); + + // Texture.WrapMode.Repeat == 0 + // Texture.WrapMode.Clamp == 1 + // Texture.WrapMode[0] == "Repeat" + // Texture.WrapMode[1] == "Clamp" + + var FlagType = cc.Enum({ + Flag1: 1, + Flag2: 2, + Flag3: 4, + Flag4: 8, + }); + + var AtlasSizeList = cc.Enum({ + 128: 128, + 256: 256, + 512: 512, + 1024: 1024, + }); + + // TypeScript: + + // If used in TypeScript, just define a TypeScript enum: + enum Direction { + Up, + Down, + Left, + Right + } + + // If you need to inspect the enum in Properties panel, you can call cc.Enum: + const {ccclass, property} = cc._decorator; + + @ccclass + class NewScript extends cc.Component { + @property({ + type: cc.Enum(Direction) // call cc.Enum + }) + direction: Direction = Direction.Up; + } + + ``` + */ + export function Enum(obj: T): T; + /** + + @param touches touches + */ + export function handleTouchesBegin(touches: any[]): void; + /** + + @param touches touches + */ + export function handleTouchesMove(touches: any[]): void; + /** + + @param touches touches + */ + export function handleTouchesEnd(touches: any[]): void; + /** + + @param touches touches + */ + export function handleTouchesCancel(touches: any[]): void; + /** + + @param touches touches + */ + export function getSetOfTouchesEndOrCancel(touches: any[]): any[]; + /** + + @param touch touch + */ + export function getPreTouch(touch: Touch): Touch; + /** + + @param touch touch + */ + export function setPreTouch(touch: Touch): void; + /** + + @param tx tx + @param ty ty + @param pos pos + */ + export function getTouchByXY(tx: number, ty: number, pos: Vec2): Touch; + /** + + @param location location + @param pos pos + @param eventType eventType + */ + export function getMouseEvent(location: Vec2, pos: Vec2, eventType: number): Event.EventMouse; + /** + + @param event event + @param pos pos + */ + export function getPointByEvent(event: Touch, pos: Vec2): Vec2; + /** + + @param event event + @param pos pos + */ + export function getTouchesByEvent(event: Touch, pos: Vec2): any[]; + /** + + @param element element + */ + export function registerSystemEvent(element: HTMLElement): void; + /** + + @param dt dt + */ + export function update(dt: number): void; + /** + !#en + Checks whether the object is non-nil and not yet destroyed.
+ When an object's `destroy` is called, it is actually destroyed after the end of this frame. + So `isValid` will return false from the next frame, while `isValid` in the current frame will still be true. + If you want to determine whether the current frame has called `destroy`, use `cc.isValid(obj, true)`, + but this is often caused by a particular logical requirements, which is not normally required. + + !#zh + 检查该对象是否不为 null 并且尚未销毁。
+ 当一个对象的 `destroy` 调用以后,会在这一帧结束后才真正销毁。因此从下一帧开始 `isValid` 就会返回 false,而当前帧内 `isValid` 仍然会是 true。如果希望判断当前帧是否调用过 `destroy`,请使用 `cc.isValid(obj, true)`,不过这往往是特殊的业务需求引起的,通常情况下不需要这样。 + @param value value + @param strictMode If true, Object called destroy() in this frame will also treated as invalid. + + @example + ```js + var node = new cc.Node(); + cc.log(cc.isValid(node)); // true + node.destroy(); + cc.log(cc.isValid(node)); // true, still valid in this frame + // after a frame... + cc.log(cc.isValid(node)); // false, destroyed in the end of last frame + ``` + */ + export function isValid(value: any, strictMode?: boolean): boolean; + /** !#en cc.view is the shared view object. + !#zh cc.view 是全局的视图对象。 */ + export var view: View; + /** !#en cc.winSize is the alias object for the size of the current game window. + !#zh cc.winSize 为当前的游戏窗口的大小。 */ + export var winSize: Size; + /** Specify that the input value must be integer in Inspector. + Also used to indicates that the elements in array should be type integer. */ + export var Integer: string; + /** Indicates that the elements in array should be type double. */ + export var Float: string; + /** Indicates that the elements in array should be type boolean. */ + export var Boolean: string; + /** Indicates that the elements in array should be type string. */ + export var String: string; + /** + !#en Deserialize json to cc.Asset + !#zh 将 JSON 反序列化为对象实例。 + @param data the serialized cc.Asset json string or json object. + @param details additional loading result + @param options options + */ + export function deserialize(data: string|any, details?: Details, options?: any): any; + /** + !#en Clones the object `original` and returns the clone, or instantiate a node from the Prefab. + !#zh 克隆指定的任意类型的对象,或者从 Prefab 实例化出新节点。 + + (Instantiate 时,function 和 dom 等非可序列化对象会直接保留原有引用,Asset 会直接进行浅拷贝,可序列化类型会进行深拷贝。) + @param original An existing object that you want to make a copy of. + + @example + ```js + // instantiate node from prefab + var scene = cc.director.getScene(); + var node = cc.instantiate(prefabAsset); + node.parent = scene; + // clone node + var scene = cc.director.getScene(); + var node = cc.instantiate(targetNode); + node.parent = scene; + ``` + */ + export function instantiate(original: Prefab): Node; + export function instantiate(original: T): T; + /** + Finds a node by hierarchy path, the path is case-sensitive. + It will traverse the hierarchy by splitting the path using '/' character. + This function will still returns the node even if it is inactive. + It is recommended to not use this function every frame instead cache the result at startup. + @param path path + @param referenceNode referenceNode + */ + export function find(path: string, referenceNode?: Node): Node; + /** + !#en + The convenience method to create a new {{#crossLink "Color/Color:method"}}cc.Color{{/crossLink}} + Alpha channel is optional. Default value is 255. + + !#zh + 通过该方法来创建一个新的 {{#crossLink "Color/Color:method"}}cc.Color{{/crossLink}} 对象。 + Alpha 通道是可选的。默认值是 255。 + @param r r + @param g g + @param b b + @param a a + + @example + ```js + ----------------------- + // 1. All channels seperately as parameters + var color1 = new cc.Color(255, 255, 255, 255); + // 2. Convert a hex string to a color + var color2 = new cc.Color("#000000"); + // 3. An color object as parameter + var color3 = new cc.Color({r: 255, g: 255, b: 255, a: 255}); + + ``` + */ + export function color(r?: number, g?: number, b?: number, a?: number): Color; + /** + !#en The convenience method to create a new {{#crossLink "Mat4"}}cc.Mat4{{/crossLink}}. + !#zh 通过该简便的函数进行创建 {{#crossLink "Mat4"}}cc.Mat4{{/crossLink}} 对象。 + @param m00 Component in column 0, row 0 position (index 0) + @param m01 Component in column 0, row 1 position (index 1) + @param m02 Component in column 0, row 2 position (index 2) + @param m03 Component in column 0, row 3 position (index 3) + @param m10 Component in column 1, row 0 position (index 4) + @param m11 Component in column 1, row 1 position (index 5) + @param m12 Component in column 1, row 2 position (index 6) + @param m13 Component in column 1, row 3 position (index 7) + @param m20 Component in column 2, row 0 position (index 8) + @param m21 Component in column 2, row 1 position (index 9) + @param m22 Component in column 2, row 2 position (index 10) + @param m23 Component in column 2, row 3 position (index 11) + @param m30 Component in column 3, row 0 position (index 12) + @param m31 Component in column 3, row 1 position (index 13) + @param m32 Component in column 3, row 2 position (index 14) + @param m33 Component in column 3, row 3 position (index 15) + */ + export function mat4(m00?: number, m01?: number, m02?: number, m03?: number, m10?: number, m11?: number, m12?: number, m13?: number, m20?: number, m21?: number, m22?: number, m23?: number, m30?: number, m31?: number, m32?: number, m33?: number): Mat4; + /** + !#en The convenience method to create a new {{#crossLink "Quat"}}cc.Quat{{/crossLink}}. + !#zh 通过该简便的函数进行创建 {{#crossLink "Quat"}}cc.Quat{{/crossLink}} 对象。 + @param x x + @param y y + @param z z + @param w w + */ + export function quat(x?: number|any, y?: number, z?: number, w?: number): Quat; + /** + !#en + The convenience method to create a new Rect. + see {{#crossLink "Rect/Rect:method"}}cc.Rect{{/crossLink}} + !#zh + 该方法用来快速创建一个新的矩形。{{#crossLink "Rect/Rect:method"}}cc.Rect{{/crossLink}} + @param x x + @param y y + @param w w + @param h h + + @example + ```js + var a = new cc.Rect(0 , 0, 10, 0); + ``` + */ + export function rect(x?: number, y?: number, w?: number, h?: number): Rect; + /** + !#en + Helper function that creates a cc.Size.
+ Please use cc.p or cc.v2 instead, it will soon replace cc.Size. + !#zh + 创建一个 cc.Size 对象的帮助函数。
+ 注意:可以使用 cc.p 或者是 cc.v2 代替,它们将很快取代 cc.Size。 + @param w width or a size object + @param h height + + @example + ```js + var size1 = cc.size(); + var size2 = cc.size(100,100); + var size3 = cc.size(size2); + var size4 = cc.size({width: 100, height: 100}); + + ``` + */ + export function size(w: number|Size, h?: number): Size; + export var EPSILON: number; + /** + Clamps a value between a minimum float and maximum float value. + @param val val + @param min min + @param max max + */ + export function clamp(val: number, min: number, max: number): number; + /** + Clamps a value between 0 and 1. + @param val val + */ + export function clamp01(val: number): number; + /** + + @param from from + @param to to + @param ratio the interpolation coefficient + */ + export function lerp(from: number, to: number, ratio: number): number; + export function random(): void; + /** + Returns a floating-point random number between min (inclusive) and max (exclusive). + @param min min + @param max max + */ + export function randomRange(min: number, max: number): number; + /** + Returns a random integer between min (inclusive) and max (exclusive). + @param min min + @param max max + */ + export function randomRangeInt(min: number, max: number): number; + /** + Linear congruential generator using Hull-Dobell Theorem. + @param seed the random seed + */ + export function pseudoRandom(seed: number): number; + /** + Returns a floating-point pseudo-random number between min (inclusive) and max (exclusive). + @param seed seed + @param min min + @param max max + */ + export function pseudoRandomRange(seed: number, min: number, max: number): number; + /** + Returns a pseudo-random integer between min (inclusive) and max (exclusive). + @param seed seed + @param min min + @param max max + */ + export function pseudoRandomRangeInt(seed: number, min: number, max: number): number; + /** + Returns the next power of two for the value + @param val val + */ + export function nextPow2(val: number): number; + /** + Returns float remainder for t / length + @param t time start at 0 + @param length time of one cycle + */ + export function repeat(t: number, length: number): number; + /** + Returns time wrapped in ping-pong mode + @param t time start at 0 + @param length time of one cycle + */ + export function repeat(t: number, length: number): number; + /** + Returns ratio of a value within a given range + @param from start value + @param to end value + @param value given value + */ + export function repeat(from: number, to: number, value: number): number; + /** + Returns -1, 0, +1 depending on sign of x. + @param v v + */ + export function sign(v: number): void; + /** + !#en The convenience method to create a new {{#crossLink "Vec2"}}cc.Vec2{{/crossLink}}. + !#zh 通过该简便的函数进行创建 {{#crossLink "Vec2"}}cc.Vec2{{/crossLink}} 对象。 + @param x x + @param y y + + @example + ```js + var v1 = cc.v2(); + var v2 = cc.v2(0, 0); + var v3 = cc.v2(v2); + var v4 = cc.v2({x: 100, y: 100}); + ``` + */ + export function v2(x?: number|any, y?: number): Vec2; + /** + !#en The convenience method to create a new {{#crossLink "Vec3"}}cc.Vec3{{/crossLink}}. + !#zh 通过该简便的函数进行创建 {{#crossLink "Vec3"}}cc.Vec3{{/crossLink}} 对象。 + @param x x + @param y y + @param z z + + @example + ```js + var v1 = cc.v3(); + var v2 = cc.v3(0, 0, 0); + var v3 = cc.v3(v2); + var v4 = cc.v3({x: 100, y: 100, z: 0}); + ``` + */ + export function v3(x?: number|any, y?: number, z?: number): Vec3; + export var dynamicAtlasManager: DynamicAtlasManager; + /** !#en The matrix storage */ + export var matrix: any[]; + /** + !#en Get an element + @param i i + @param j j + */ + export function get(i: number, j: number): number; + /** + !#en Set an element + @param i i + @param j j + @param value value + */ + export function set(i: number, j: number, value: boolean): void; + /** + !#en Sets all elements to zero + */ + export function reset(): void; + /** !#en Base class cc.Action for action classes. + !#zh Action 类是所有动作类型的基类。 */ + export class Action { + /** + !#en + to copy object with deep copy. + returns a clone of action. + !#zh 返回一个克隆的动作。 + */ + clone(): Action; + /** + !#en + return true if the action has finished. + !#zh 如果动作已完成就返回 true。 + */ + isDone(): boolean; + /** + !#en get the target. + !#zh 获取当前目标节点。 + */ + getTarget(): Node; + /** + !#en The action will modify the target properties. + !#zh 设置目标节点。 + @param target target + */ + setTarget(target: Node): void; + /** + !#en get the original target. + !#zh 获取原始目标节点。 + */ + getOriginalTarget(): Node; + /** + !#en get tag number. + !#zh 获取用于识别动作的标签。 + */ + getTag(): number; + /** + !#en set tag number. + !#zh 设置标签,用于识别动作。 + @param tag tag + */ + setTag(tag: number): void; + /** !#en Default Action tag. + !#zh 默认动作标签。 */ + static TAG_INVALID: number; + } + /** !#en + Base class actions that do have a finite time duration.
+ Possible actions:
+ - An action with a duration of 0 seconds.
+ - An action with a duration of 35.5 seconds. + + Infinite time actions are valid + !#zh 有限时间动作,这种动作拥有时长 duration 属性。 */ + export class FiniteTimeAction extends Action { + /** + !#en get duration of the action. (seconds). + !#zh 获取动作以秒为单位的持续时间。 + */ + getDuration(): number; + /** + !#en set duration of the action. (seconds). + !#zh 设置动作以秒为单位的持续时间。 + @param duration duration + */ + setDuration(duration: number): void; + /** + !#en + Returns a reversed action.
+ For example:
+ - The action will be x coordinates of 0 move to 100.
+ - The reversed action will be x of 100 move to 0. + - Will be rewritten + !#zh 返回一个新的动作,执行与原动作完全相反的动作。 + */ + reverse(): void; + /** + !#en + to copy object with deep copy. + returns a clone of action. + !#zh 返回一个克隆的动作。 + */ + clone(): FiniteTimeAction; + } + /** !#en Instant actions are immediate actions. They don't have a duration like the ActionInterval actions. + !#zh 即时动作,这种动作立即就会执行,继承自 FiniteTimeAction。 */ + export class ActionInstant extends FiniteTimeAction { + } + /** !#en +

An interval action is an action that takes place within a certain period of time.
+ It has an start time, and a finish time. The finish time is the parameter
+ duration plus the start time.

+ +

These CCActionInterval actions have some interesting properties, like:
+ - They can run normally (default)
+ - They can run reversed with the reverse method
+ - They can run with the time altered with the Accelerate, AccelDeccel and Speed actions.

+ +

For example, you can simulate a Ping Pong effect running the action normally and
+ then running it again in Reverse mode.

+ !#zh 时间间隔动作,这种动作在已定时间内完成,继承 FiniteTimeAction。 */ + export class ActionInterval extends FiniteTimeAction { + /** + !#en Implementation of ease motion. + !#zh 缓动运动。 + @param easeObj easeObj + + @example + ```js + action.easing(cc.easeIn(3.0)); + ``` + */ + easing(easeObj: any): ActionInterval; + /** + !#en + Repeats an action a number of times. + To repeat an action forever use the CCRepeatForever action. + !#zh 重复动作可以按一定次数重复一个动作,使用 RepeatForever 动作来永远重复一个动作。 + @param times times + */ + repeat(times: number): ActionInterval; + /** + !#en + Repeats an action for ever.
+ To repeat the an action for a limited number of times use the Repeat action.
+ !#zh 永远地重复一个动作,有限次数内重复一个动作请使用 Repeat 动作。 + */ + repeatForever(): ActionInterval; + } + /** !#en + cc.ActionManager is a class that can manage actions.
+ Normally you won't need to use this class directly. 99% of the cases you will use the CCNode interface, + which uses this class's singleton object. + But there are some cases where you might need to use this class.
+ Examples:
+ - When you want to run an action where the target is different from a CCNode.
+ - When you want to pause / resume the actions
+ !#zh + cc.ActionManager 是可以管理动作的单例类。
+ 通常你并不需要直接使用这个类,99%的情况您将使用 CCNode 的接口。
+ 但也有一些情况下,您可能需要使用这个类。
+ 例如: + - 当你想要运行一个动作,但目标不是 CCNode 类型时。
+ - 当你想要暂停/恢复动作时。
*/ + export class ActionManager { + /** + !#en + Adds an action with a target.
+ If the target is already present, then the action will be added to the existing target. + If the target is not present, a new instance of this target will be created either paused or not, and the action will be added to the newly created target. + When the target is paused, the queued actions won't be 'ticked'. + !#zh + 增加一个动作,同时还需要提供动作的目标对象,目标对象是否暂停作为参数。
+ 如果目标已存在,动作将会被直接添加到现有的节点中。
+ 如果目标不存在,将为这一目标创建一个新的实例,并将动作添加进去。
+ 当目标状态的 paused 为 true,动作将不会被执行 + @param action action + @param target target + @param paused paused + */ + addAction(action: Action, target: Node, paused: boolean): void; + /** + !#en Removes all actions from all the targets. + !#zh 移除所有对象的所有动作。 + */ + removeAllActions(): void; + /** + !#en + Removes all actions from a certain target.
+ All the actions that belongs to the target will be removed. + !#zh + 移除指定对象上的所有动作。
+ 属于该目标的所有的动作将被删除。 + @param target target + @param forceDelete forceDelete + */ + removeAllActionsFromTarget(target: Node, forceDelete: boolean): void; + /** + !#en Removes an action given an action reference. + !#zh 移除指定的动作。 + @param action action + */ + removeAction(action: Action): void; + /** + !#en Removes an action given its tag and the target. + !#zh 删除指定对象下特定标签的一个动作,将删除首个匹配到的动作。 + @param tag tag + @param target target + */ + removeActionByTag(tag: number, target?: Node): void; + /** + !#en Gets an action given its tag an a target. + !#zh 通过目标对象和标签获取一个动作。 + @param tag tag + @param target target + */ + getActionByTag(tag: number, target: Node): Action; + /** + !#en + Returns the numbers of actions that are running in a certain target.
+ Composable actions are counted as 1 action.
+ Example:
+ - If you are running 1 Sequence of 7 actions, it will return 1.
+ - If you are running 7 Sequences of 2 actions, it will return 7. + !#zh + 返回指定对象下所有正在运行的动作数量。
+ 组合动作被算作一个动作。
+ 例如:
+ - 如果您正在运行 7 个动作组成的序列动作(Sequence),这个函数将返回 1。
+ - 如果你正在运行 2 个序列动作(Sequence)和 5 个普通动作,这个函数将返回 7。
+ @param target target + */ + getNumberOfRunningActionsInTarget(target: Node): number; + /** + !#en Pauses the target: all running actions and newly added actions will be paused. + !#zh 暂停指定对象:所有正在运行的动作和新添加的动作都将会暂停。 + @param target target + */ + pauseTarget(target: Node): void; + /** + !#en Resumes the target. All queued actions will be resumed. + !#zh 让指定目标恢复运行。在执行序列中所有被暂停的动作将重新恢复运行。 + @param target target + */ + resumeTarget(target: Node): void; + /** + !#en Pauses all running actions, returning a list of targets whose actions were paused. + !#zh 暂停所有正在运行的动作,返回一个包含了那些动作被暂停了的目标对象的列表。 + */ + pauseAllRunningActions(): any[]; + /** + !#en Resume a set of targets (convenience function to reverse a pauseAllRunningActions or pauseTargets call). + !#zh 让一组指定对象恢复运行(用来逆转 pauseAllRunningActions 效果的便捷函数)。 + @param targetsToResume targetsToResume + */ + resumeTargets(targetsToResume: any[]): void; + /** + !#en Pause a set of targets. + !#zh 暂停一组指定对象。 + @param targetsToPause targetsToPause + */ + pauseTargets(targetsToPause: any[]): void; + /** + !#en + purges the shared action manager. It releases the retained instance.
+ because it uses this, so it can not be static. + !#zh + 清除共用的动作管理器。它释放了持有的实例。
+ 因为它使用 this,因此它不能是静态的。 + */ + purgeSharedManager(): void; + /** + !#en The ActionManager update。 + !#zh ActionManager 主循环。 + @param dt delta time in seconds + */ + update(dt: number): void; + } + /** !#en + Tween provide a simple and flexible way to create action. + Tween's api is more flexible than cc.Action: + - Support creating an action sequence in chained api, + - Support animate any objects' any properties, not limited to node's properties. + By contrast, cc.Action needs to create a new action class to support new node property. + - Support working with cc.Action, + - Support easing and progress function. + !#zh + Tween 提供了一个简单灵活的方法来创建 action。 + 相对于 Cocos 传统的 cc.Action,cc.Tween 在创建动画上要灵活非常多: + - 支持以链式结构的方式创建一个动画序列。 + - 支持对任意对象的任意属性进行缓动,不再局限于节点上的属性,而 cc.Action 添加一个属性的支持时还需要添加一个新的 action 类型。 + - 支持与 cc.Action 混用 + - 支持设置 {{#crossLink "Easing"}}{{/crossLink}} 或者 progress 函数 */ + export class Tween { + /** + + @param target target + */ + constructor(target?: any); + /** + !#en Stop all tweens + !#zh 停止所有缓动 + */ + static stopAll(): void; + /** + !#en Stop all tweens by tag + !#zh 停止所有指定标签的缓动 + @param tag tag + */ + static stopAllByTag(tag: number): void; + /** + !#en Stop all tweens by target + !#zh 停止所有指定对象的缓动 + @param target target + */ + static stopAllByTarget(target: any): void; + /** + !#en + Insert an action or tween to this sequence + !#zh + 插入一个 action 或者 tween 到队列中 + @param other other + */ + then(other: Action|Tween): Tween; + /** + !#en + Set tween target + !#zh + 设置 tween 的 target + @param target target + */ + target(target: any): Tween; + /** + !#en + Start this tween + !#zh + 运行当前 tween + */ + start(): Tween; + /** + !#en + Stop this tween + !#zh + 停止当前 tween + */ + stop(): Tween; + /** + !#en Sets tween tag + !#zh 设置缓动的标签 + @param tag tag + */ + tag(tag: number): Tween; + /** + !#en + Clone a tween + !#zh + 克隆当前 tween + @param target target + */ + clone(target?: any): Tween; + /** + !#en + Integrate all previous actions to an action. + !#zh + 将之前所有的 action 整合为一个 action。 + */ + union(): Tween; + /** + !#en Sets target's position property according to the bezier curve. + !#zh 按照贝塞尔路径设置目标的 position 属性。 + @param duration duration + @param c1 c1 + @param c2 c2 + @param to to + */ + bezierTo(duration: number, c1: Vec2, c2: Vec2, to: Vec2): Tween; + /** + !#en Sets target's position property according to the bezier curve. + !#zh 按照贝塞尔路径设置目标的 position 属性。 + @param duration duration + @param c1 c1 + @param c2 c2 + @param to to + */ + bezierBy(duration: number, c1: Vec2, c2: Vec2, to: Vec2): Tween; + /** + !#en Flips target's scaleX + !#zh 翻转目标的 scaleX 属性 + */ + flipX(): Tween; + /** + !#en Flips target's scaleY + !#zh 翻转目标的 scaleY 属性 + */ + flipY(): Tween; + /** + !#en Blinks target by set target's opacity property + !#zh 通过设置目标的 opacity 属性达到闪烁效果 + @param duration duration + @param times times + @param opts opts + */ + blink(duration: number, times: number, opts?: {progress?: Function; easing?: Function|string; }): Tween; + /** + !#en + Add an action which calculate with absolute value + !#zh + 添加一个对属性进行绝对值计算的 action + @param duration duration + @param props {scale: 2, position: cc.v3(100, 100, 100)} + @param opts opts + */ + to > (duration: number, props: ConstructorType, opts?: OPTS) : Tween; + /** + !#en + Add an action which calculate with relative value + !#zh + 添加一个对属性进行相对值计算的 action + @param duration duration + @param props {scale: 2, position: cc.v3(100, 100, 100)} + @param opts opts + */ + by > (duration: number, props: ConstructorType, opts?: OPTS) : Tween; + /** + !#en + Directly set target properties + !#zh + 直接设置 target 的属性 + @param props props + */ + set (props: ConstructorType) : Tween; + /** + !#en + Add an delay action + !#zh + 添加一个延时 action + @param duration duration + */ + delay(duration: number): Tween; + /** + !#en + Add an callback action + !#zh + 添加一个回调 action + @param callback callback + */ + call(callback: Function): Tween; + /** + !#en + Add an hide action + !#zh + 添加一个隐藏 action + */ + hide(): Tween; + /** + !#en + Add an show action + !#zh + 添加一个显示 action + */ + show(): Tween; + /** + !#en + Add an removeSelf action + !#zh + 添加一个移除自己 action + */ + removeSelf(): Tween; + /** + !#en + Add an sequence action + !#zh + 添加一个队列 action + @param action action + @param actions actions + */ + sequence(action: Action|Tween, ...actions: (Action|Tween)[]): Tween; + /** + !#en + Add an parallel action + !#zh + 添加一个并行 action + @param action action + @param actions actions + */ + parallel(action: Action|Tween, ...actions: (Action|Tween)[]): Tween; + /** + !#en + Add an repeat action. + This action will integrate before actions to a sequence action as their parameters. + !#zh + 添加一个重复 action,这个 action 会将前一个动作作为他的参数。 + @param repeatTimes repeatTimes + @param action action + */ + repeat(repeatTimes: number, action?: Action|Tween): Tween; + /** + !#en + Add an repeat forever action + This action will integrate before actions to a sequence action as their parameters. + !#zh + 添加一个永久重复 action,这个 action 会将前一个动作作为他的参数。 + @param action action + */ + repeatForever(action?: Action|Tween): Tween; + /** + !#en + Add an reverse time action. + This action will integrate before actions to a sequence action as their parameters. + !#zh + 添加一个倒置时间 action,这个 action 会将前一个动作作为他的参数。 + @param action action + */ + reverseTime(action?: Action|Tween): Tween; + } + /** cc.TMXLayerInfo contains the information about the layers like: + - Layer name + - Layer size + - Layer opacity at creation time (it can be modified at runtime) + - Whether the layer is visible (if it's not visible, then the CocosNode won't be created) + This information is obtained from the TMX file. */ + export class TMXLayerInfo { + /** Properties of the layer info. */ + properties: any; + } + /** cc.TMXImageLayerInfo contains the information about the image layers. + This information is obtained from the TMX file. */ + export class TMXImageLayerInfo { + } + /**

cc.TMXObjectGroupInfo contains the information about the object group like: + - group name + - group size + - group opacity at creation time (it can be modified at runtime) + - Whether the group is visible + + This information is obtained from the TMX file.

*/ + export class TMXObjectGroupInfo { + /** Properties of the ObjectGroup info. */ + properties: any[]; + } + /**

cc.TMXTilesetInfo contains the information about the tilesets like:
+ - Tileset name
+ - Tileset spacing
+ - Tileset margin
+ - size of the tiles
+ - Image used for the tiles
+ - Image size
+ + This information is obtained from the TMX file.

*/ + export class TMXTilesetInfo { + /** Tileset name */ + name: string; + /** First grid */ + firstGid: number; + /** Spacing */ + spacing: number; + /** Margin */ + margin: number; + /** Texture containing the tiles (should be sprite sheet / texture atlas) */ + sourceImage: any; + /** Size in pixels of the image */ + imageSize: Size; + } + /**

cc.TMXMapInfo contains the information about the map like:
+ - Map orientation (hexagonal, isometric or orthogonal)
+ - Tile size
+ - Map size

+ +

And it also contains:
+ - Layers (an array of TMXLayerInfo objects)
+ - Tilesets (an array of TMXTilesetInfo objects)
+ - ObjectGroups (an array of TMXObjectGroupInfo objects)

+ +

This information is obtained from the TMX file.

*/ + export class TMXMapInfo { + /** Properties of the map info. */ + properties: any[]; + /** Map orientation. */ + orientation: number; + /** Parent element. */ + parentElement: any; + /** Parent GID. */ + parentGID: number; + /** Layer attributes. */ + layerAttrs: any; + /** Is reading storing characters stream. */ + storingCharacters: boolean; + /** Current string stored from characters stream. */ + currentString: string; + /** Width of the map */ + mapWidth: number; + /** Height of the map */ + mapHeight: number; + /** Width of a tile */ + tileWidth: number; + /** Height of a tile */ + tileHeight: number; + static ATTRIB_NONE: number; + static ATTRIB_BASE64: number; + static ATTRIB_GZIP: number; + static ATTRIB_ZLIB: number; + } + /** !#en Render the TMX layer. + !#zh 渲染 TMX layer。 */ + export class TiledLayer extends Component { + /** + !#en enable or disable culling + !#zh 开启或关闭裁剪。 + @param value value + */ + enableCulling(value: any): void; + /** + !#en Adds user's node into layer. + !#zh 添加用户节点。 + @param node node + */ + addUserNode(node: Node): boolean; + /** + !#en Removes user's node. + !#zh 移除用户节点。 + @param node node + */ + removeUserNode(node: Node): boolean; + /** + !#en Destroy user's node. + !#zh 销毁用户节点。 + @param node node + */ + destroyUserNode(node: Node): void; + /** + !#en Gets the layer name. + !#zh 获取层的名称。 + + @example + ```js + let layerName = tiledLayer.getLayerName(); + cc.log(layerName); + ``` + */ + getLayerName(): string; + /** + !#en Set the layer name. + !#zh 设置层的名称 + @param layerName layerName + + @example + ```js + tiledLayer.setLayerName("New Layer"); + ``` + */ + SetLayerName(layerName: string): void; + /** + !#en Return the value for the specific property name. + !#zh 获取指定属性名的值。 + @param propertyName propertyName + + @example + ```js + let property = tiledLayer.getProperty("info"); + cc.log(property); + ``` + */ + getProperty(propertyName: string): any; + /** + !#en Returns the position in pixels of a given tile coordinate. + !#zh 获取指定 tile 的像素坐标。 + @param pos position or x + @param y y + + @example + ```js + let pos = tiledLayer.getPositionAt(cc.v2(0, 0)); + cc.log("Pos: " + pos); + let pos = tiledLayer.getPositionAt(0, 0); + cc.log("Pos: " + pos); + ``` + */ + getPositionAt(pos: Vec2|number, y?: number): Vec2; + /** + !#en + Sets the tiles gid (gid = tile global id) at a given tiles rect. + !#zh + 设置给定区域的 tile 的 gid (gid = tile 全局 id), + @param gids an array contains gid + @param beginCol begin col number + @param beginRow begin row number + @param totalCols count of column + + @example + ```js + tiledLayer.setTilesGIDAt([1, 1, 1, 1], 10, 10, 2) + ``` + */ + setTilesGIDAt(gids: any[], beginCol: number, beginRow: number, totalCols: number): void; + /** + !#en + Sets the tile gid (gid = tile global id) at a given tile coordinate.
+ The Tile GID can be obtained by using the method "tileGIDAt" or by using the TMX editor . Tileset Mgr +1.
+ If a tile is already placed at that position, then it will be removed. + !#zh + 设置给定坐标的 tile 的 gid (gid = tile 全局 id), + tile 的 GID 可以使用方法 “tileGIDAt” 来获得。
+ 如果一个 tile 已经放在那个位置,那么它将被删除。 + @param gid gid + @param posOrX position or x + @param flagsOrY flags or y + @param flags flags + + @example + ```js + tiledLayer.setTileGIDAt(1001, 10, 10, 1) + ``` + */ + setTileGIDAt(gid: number, posOrX: Vec2|number, flagsOrY: number, flags?: number): void; + /** + !#en + Returns the tile gid at a given tile coordinate.
+ if it returns 0, it means that the tile is empty.
+ !#zh + 通过给定的 tile 坐标、flags(可选)返回 tile 的 GID.
+ 如果它返回 0,则表示该 tile 为空。
+ @param pos or x + @param y y + + @example + ```js + let tileGid = tiledLayer.getTileGIDAt(0, 0); + ``` + */ + getTileGIDAt(pos: Vec2|number, y?: number): number; + /** + !#en Layer orientation, which is the same as the map orientation. + !#zh 获取 Layer 方向(同地图方向)。 + + @example + ```js + let orientation = tiledLayer.getLayerOrientation(); + cc.log("Layer Orientation: " + orientation); + ``` + */ + getLayerOrientation(): number; + /** + !#en properties from the layer. They can be added using Tiled. + !#zh 获取 layer 的属性,可以使用 Tiled 编辑器添加属性。 + + @example + ```js + let properties = tiledLayer.getProperties(); + cc.log("Properties: " + properties); + ``` + */ + getProperties(): any; + /** + !#en + Get the TiledTile with the tile coordinate.
+ If there is no tile in the specified coordinate and forceCreate parameter is true,
+ then will create a new TiledTile at the coordinate. + The renderer will render the tile with the rotation, scale, position and color property of the TiledTile. + !#zh + 通过指定的 tile 坐标获取对应的 TiledTile。
+ 如果指定的坐标没有 tile,并且设置了 forceCreate 那么将会在指定的坐标创建一个新的 TiledTile 。
+ 在渲染这个 tile 的时候,将会使用 TiledTile 的节点的旋转、缩放、位移、颜色属性。
+ @param x x + @param y y + @param forceCreate forceCreate + + @example + ```js + let tile = tiledLayer.getTiledTileAt(100, 100, true); + cc.log(tile); + ``` + */ + getTiledTileAt(x: number, y: number, forceCreate: boolean): TiledTile; + /** + !#en + Change tile to TiledTile at the specified coordinate. + !#zh + 将指定的 tile 坐标替换为指定的 TiledTile。 + @param x x + @param y y + @param tiledTile tiledTile + */ + setTiledTileAt(x: number, y: number, tiledTile: TiledTile): TiledTile; + /** + !#en Return texture. + !#zh 获取纹理。 + @param index The index of textures + */ + getTexture(index: any): Texture2D; + /** + !#en Return texture. + !#zh 获取纹理。 + */ + getTextures(): Texture2D; + /** + !#en Set the texture. + !#zh 设置纹理。 + @param texture texture + */ + setTexture(texture: Texture2D): void; + /** + !#en Set the texture. + !#zh 设置纹理。 + @param textures textures + */ + setTexture(textures: Texture2D): void; + /** + !#en Gets layer size. + !#zh 获得层大小。 + + @example + ```js + let size = tiledLayer.getLayerSize(); + cc.log("layer size: " + size); + ``` + */ + getLayerSize(): Size; + /** + !#en Size of the map's tile (could be different from the tile's size). + !#zh 获取 tile 的大小( tile 的大小可能会有所不同)。 + + @example + ```js + let mapTileSize = tiledLayer.getMapTileSize(); + cc.log("MapTile size: " + mapTileSize); + ``` + */ + getMapTileSize(): Size; + /** + !#en Gets Tile set first information for the layer. + !#zh 获取 layer 索引位置为0的 Tileset 信息。 + @param index The index of tilesets + */ + getTileSet(index: any): TMXTilesetInfo; + /** + !#en Gets tile set all information for the layer. + !#zh 获取 layer 所有的 Tileset 信息。 + */ + getTileSet(): TMXTilesetInfo; + /** + !#en Sets tile set information for the layer. + !#zh 设置 layer 的 tileset 信息。 + @param tileset tileset + */ + setTileSet(tileset: TMXTilesetInfo): void; + /** + !#en Sets Tile set information for the layer. + !#zh 设置 layer 的 Tileset 信息。 + @param tilesets tilesets + */ + setTileSets(tilesets: TMXTilesetInfo): void; + } + /** Class for tiled map asset handling. */ + export class TiledMapAsset extends Asset { + textures: Texture2D[]; + textureNames: string[]; + textureSizes: Size[]; + imageLayerTextures: Texture2D[]; + imageLayerTextureNames: string[]; + } + /** !#en Renders the TMX object group. + !#zh 渲染 tmx object group。 */ + export class TiledObjectGroup extends Component { + /** + !#en Offset position of child objects. + !#zh 获取子对象的偏移位置。 + + @example + ```js + let offset = tMXObjectGroup.getPositionOffset(); + ``` + */ + getPositionOffset(): Vec2; + /** + !#en List of properties stored in a dictionary. + !#zh 以映射的形式获取属性列表。 + + @example + ```js + let offset = tMXObjectGroup.getProperties(); + ``` + */ + getProperties(): any; + /** + !#en Gets the Group name. + !#zh 获取组名称。 + + @example + ```js + let groupName = tMXObjectGroup.getGroupName; + ``` + */ + getGroupName(): string; + /** + !#en + Return the object for the specific object name.
+ It will return the 1st object found on the array for the given name. + !#zh 获取指定的对象。 + @param objectName objectName + + @example + ```js + let object = tMXObjectGroup.getObject("Group"); + ``` + */ + getObject(objectName: string): any; + /** + !#en Gets the objects. + !#zh 获取对象数组。 + + @example + ```js + let objects = tMXObjectGroup.getObjects(); + ``` + */ + getObjects(): any[]; + } + /** !#en Renders a TMX Tile Map in the scene. + !#zh 在场景中渲染一个 tmx 格式的 Tile Map。 */ + export class TiledMap extends Component { + /** !#en The TiledMap Asset. + !#zh TiledMap 资源。 */ + tmxAsset: TiledMapAsset; + /** + !#en Gets the map size. + !#zh 获取地图大小。 + + @example + ```js + let mapSize = tiledMap.getMapSize(); + cc.log("Map Size: " + mapSize); + ``` + */ + getMapSize(): Size; + /** + !#en Gets the tile size. + !#zh 获取地图背景中 tile 元素的大小。 + + @example + ```js + let tileSize = tiledMap.getTileSize(); + cc.log("Tile Size: " + tileSize); + ``` + */ + getTileSize(): Size; + /** + !#en map orientation. + !#zh 获取地图方向。 + + @example + ```js + let mapOrientation = tiledMap.getMapOrientation(); + cc.log("Map Orientation: " + mapOrientation); + ``` + */ + getMapOrientation(): number; + /** + !#en object groups. + !#zh 获取所有的对象层。 + + @example + ```js + let objGroups = titledMap.getObjectGroups(); + for (let i = 0; i < objGroups.length; ++i) { + cc.log("obj: " + objGroups[i]); + } + ``` + */ + getObjectGroups(): TiledObjectGroup[]; + /** + !#en Return the TMXObjectGroup for the specific group. + !#zh 获取指定的 TMXObjectGroup。 + @param groupName groupName + + @example + ```js + let group = titledMap.getObjectGroup("Players"); + cc.log("ObjectGroup: " + group); + ``` + */ + getObjectGroup(groupName: string): TiledObjectGroup; + /** + !#en enable or disable culling + !#zh 开启或关闭裁剪。 + @param value value + */ + enableCulling(value: any): void; + /** + !#en Gets the map properties. + !#zh 获取地图的属性。 + + @example + ```js + let properties = titledMap.getProperties(); + for (let i = 0; i < properties.length; ++i) { + cc.log("Properties: " + properties[i]); + } + ``` + */ + getProperties(): any[]; + /** + !#en Return All layers array. + !#zh 返回包含所有 layer 的数组。 + + @example + ```js + let layers = titledMap.getLayers(); + for (let i = 0; i < layers.length; ++i) { + cc.log("Layers: " + layers[i]); + } + ``` + */ + getLayers(): TiledLayer[]; + /** + !#en return the cc.TiledLayer for the specific layer. + !#zh 获取指定名称的 layer。 + @param layerName layerName + + @example + ```js + let layer = titledMap.getLayer("Player"); + cc.log(layer); + ``` + */ + getLayer(layerName: string): TiledLayer; + /** + !#en Return the value for the specific property name. + !#zh 通过属性名称,获取指定的属性。 + @param propertyName propertyName + + @example + ```js + let property = titledMap.getProperty("info"); + cc.log("Property: " + property); + ``` + */ + getProperty(propertyName: string): string; + /** + !#en Return properties dictionary for tile GID. + !#zh 通过 GID ,获取指定的属性。 + @param GID GID + + @example + ```js + let properties = titledMap.getPropertiesForGID(GID); + cc.log("Properties: " + properties); + ``` + */ + getPropertiesForGID(GID: number): any; + } + /** !#en TiledTile can control the specified map tile. + It will apply the node rotation, scale, translate to the map tile. + You can change the TiledTile's gid to change the map tile's style. + !#zh TiledTile 可以单独对某一个地图块进行操作。 + 他会将节点的旋转,缩放,平移操作应用在这个地图块上,并可以通过更换当前地图块的 gid 来更换地图块的显示样式。 */ + export class TiledTile extends Component { + /** !#en Specify the TiledTile horizontal coordinate,use map tile as the unit. + !#zh 指定 TiledTile 的横向坐标,以地图块为单位 */ + x: number; + /** !#en Specify the TiledTile vertical coordinate,use map tile as the unit. + !#zh 指定 TiledTile 的纵向坐标,以地图块为单位 */ + y: number; + /** !#en Specify the TiledTile gid. + !#zh 指定 TiledTile 的 gid 值 */ + gid: number; + } + /** !#en Class for animation data handling. + !#zh 动画剪辑,用于存储动画数据。 */ + export class AnimationClip extends Asset { + /** !#en Duration of this animation. + !#zh 动画的持续时间。 */ + duration: number; + /** !#en FrameRate of this animation. + !#zh 动画的帧速率。 */ + sample: number; + /** !#en Speed of this animation. + !#zh 动画的播放速度。 */ + speed: number; + /** !#en WrapMode of this animation. + !#zh 动画的循环模式。 */ + wrapMode: WrapMode; + /** !#en Curve data. + !#zh 曲线数据。 */ + curveData: any; + /** !#en Event data. + !#zh 事件数据。 */ + events: {frame: number, func: string, params: string[]}[]; + /** + !#en Crate clip with a set of sprite frames + !#zh 使用一组序列帧图片来创建动画剪辑 + @param spriteFrames spriteFrames + @param sample sample + + @example + ```js + var clip = cc.AnimationClip.createWithSpriteFrames(spriteFrames, 10); + ``` + */ + static createWithSpriteFrames(spriteFrames: SpriteFrame[], sample: number): AnimationClip; + } + /** !#en + The AnimationState gives full control over animation playback process. + In most cases the Animation Component is sufficient and easier to use. Use the AnimationState if you need full control. + !#zh + AnimationState 完全控制动画播放过程。
+ 大多数情况下 动画组件 是足够和易于使用的。如果您需要更多的动画控制接口,请使用 AnimationState。 */ + export class AnimationState extends Playable { + /** + + @param clip clip + @param name name + */ + constructor(clip: AnimationClip, name?: string); + /** !#en The curves list. + !#zh 曲线列表。 */ + curves: any[]; + /** !#en The start delay which represents the number of seconds from an animation's start time to the start of + the active interval. + !#zh 延迟多少秒播放。 */ + delay: number; + /** !#en The animation's iteration count property. + + A real number greater than or equal to zero (including positive infinity) representing the number of times + to repeat the animation node. + + Values less than zero and NaN values are treated as the value 1.0 for the purpose of timing model + calculations. + + !#zh 迭代次数,指动画播放多少次后结束, normalize time。 如 2.5(2次半) */ + repeatCount: number; + /** !#en The iteration duration of this animation in seconds. (length) + !#zh 单次动画的持续时间,秒。 */ + duration: number; + /** !#en The animation's playback speed. 1 is normal playback speed. + !#zh 播放速率。 */ + speed: number; + /** !#en + Wrapping mode of the playing animation. + Notice : dynamic change wrapMode will reset time and repeatCount property + !#zh + 动画循环方式。 + 需要注意的是,动态修改 wrapMode 时,会重置 time 以及 repeatCount */ + wrapMode: WrapMode; + /** !#en The current time of this animation in seconds. + !#zh 动画当前的时间,秒。 */ + time: number; + /** !#en The clip that is being played by this animation state. + !#zh 此动画状态正在播放的剪辑。 */ + clip: AnimationClip; + /** !#en The name of the playing animation. + !#zh 动画的名字 */ + name: string; + } + /** !#en + This class provide easing methods for {{#crossLink "tween"}}{{/crossLink}} class.
+ Demonstratio: https://easings.net/ + !#zh + 缓动函数类,为 {{#crossLink "Tween"}}{{/crossLink}} 提供缓动效果函数。
+ 函数效果演示: https://easings.net/ */ + export class Easing { + /** + !#en Easing in with quadratic formula. From slow to fast. + !#zh 平方曲线缓入函数。运动由慢到快。 + @param t The current time as a percentage of the total time. + */ + quadIn(t: number): number; + /** + !#en Easing out with quadratic formula. From fast to slow. + !#zh 平方曲线缓出函数。运动由快到慢。 + @param t The current time as a percentage of the total time. + */ + quadOut(t: number): number; + /** + !#en Easing in and out with quadratic formula. From slow to fast, then back to slow. + !#zh 平方曲线缓入缓出函数。运动由慢到快再到慢。 + @param t The current time as a percentage of the total time. + */ + quadInOut(t: number): number; + /** + !#en Easing in with cubic formula. From slow to fast. + !#zh 立方曲线缓入函数。运动由慢到快。 + @param t The current time as a percentage of the total time. + */ + cubicIn(t: number): number; + /** + !#en Easing out with cubic formula. From slow to fast. + !#zh 立方曲线缓出函数。运动由快到慢。 + @param t The current time as a percentage of the total time. + */ + cubicOut(t: number): number; + /** + !#en Easing in and out with cubic formula. From slow to fast, then back to slow. + !#zh 立方曲线缓入缓出函数。运动由慢到快再到慢。 + @param t The current time as a percentage of the total time. + */ + cubicInOut(t: number): number; + /** + !#en Easing in with quartic formula. From slow to fast. + !#zh 四次方曲线缓入函数。运动由慢到快。 + @param t The current time as a percentage of the total time. + */ + quartIn(t: number): number; + /** + !#en Easing out with quartic formula. From fast to slow. + !#zh 四次方曲线缓出函数。运动由快到慢。 + @param t The current time as a percentage of the total time. + */ + quartOut(t: number): number; + /** + !#en Easing in and out with quartic formula. From slow to fast, then back to slow. + !#zh 四次方曲线缓入缓出函数。运动由慢到快再到慢。 + @param t The current time as a percentage of the total time. + */ + quartInOut(t: number): number; + /** + !#en Easing in with quintic formula. From slow to fast. + !#zh 五次方曲线缓入函数。运动由慢到快。 + @param t The current time as a percentage of the total time. + */ + quintIn(t: number): number; + /** + !#en Easing out with quintic formula. From fast to slow. + !#zh 五次方曲线缓出函数。运动由快到慢。 + @param t The current time as a percentage of the total time. + */ + quintOut(t: number): number; + /** + !#en Easing in and out with quintic formula. From slow to fast, then back to slow. + !#zh 五次方曲线缓入缓出函数。运动由慢到快再到慢。 + @param t The current time as a percentage of the total time. + */ + quintInOut(t: number): number; + /** + !#en Easing in and out with sine formula. From slow to fast. + !#zh 正弦曲线缓入函数。运动由慢到快。 + @param t The current time as a percentage of the total time. + */ + sineIn(t: number): number; + /** + !#en Easing in and out with sine formula. From fast to slow. + !#zh 正弦曲线缓出函数。运动由快到慢。 + @param t The current time as a percentage of the total time. + */ + sineOut(t: number): number; + /** + !#en Easing in and out with sine formula. From slow to fast, then back to slow. + !#zh 正弦曲线缓入缓出函数。运动由慢到快再到慢。 + @param t The current time as a percentage of the total time. + */ + sineInOut(t: number): number; + /** + !#en Easing in and out with exponential formula. From slow to fast. + !#zh 指数曲线缓入函数。运动由慢到快。 + @param t The current time as a percentage of the total time. + */ + expoIn(t: number): number; + /** + !#en Easing in and out with exponential formula. From fast to slow. + !#zh 指数曲线缓出函数。运动由快到慢。 + @param t The current time as a percentage of the total time. + */ + expoOut(t: number): number; + /** + !#en Easing in and out with exponential formula. From slow to fast. + !#zh 指数曲线缓入和缓出函数。运动由慢到很快再到慢。 + @param t The current time as a percentage of the total time, then back to slow. + */ + expoInOut(t: number): number; + /** + !#en Easing in and out with circular formula. From slow to fast. + !#zh 循环公式缓入函数。运动由慢到快。 + @param t The current time as a percentage of the total time. + */ + circIn(t: number): number; + /** + !#en Easing in and out with circular formula. From fast to slow. + !#zh 循环公式缓出函数。运动由快到慢。 + @param t The current time as a percentage of the total time. + */ + circOut(t: number): number; + /** + !#en Easing in and out with circular formula. From slow to fast. + !#zh 指数曲线缓入缓出函数。运动由慢到很快再到慢。 + @param t The current time as a percentage of the total time, then back to slow. + */ + circInOut(t: number): number; + /** + !#en Easing in action with a spring oscillating effect. + !#zh 弹簧回震效果的缓入函数。 + @param t The current time as a percentage of the total time. + */ + elasticIn(t: number): number; + /** + !#en Easing out action with a spring oscillating effect. + !#zh 弹簧回震效果的缓出函数。 + @param t The current time as a percentage of the total time. + */ + elasticOut(t: number): number; + /** + !#en Easing in and out action with a spring oscillating effect. + !#zh 弹簧回震效果的缓入缓出函数。 + @param t The current time as a percentage of the total time. + */ + elasticInOut(t: number): number; + /** + !#en Easing in action with "back up" behavior. + !#zh 回退效果的缓入函数。 + @param t The current time as a percentage of the total time. + */ + backIn(t: number): number; + /** + !#en Easing out action with "back up" behavior. + !#zh 回退效果的缓出函数。 + @param t The current time as a percentage of the total time. + */ + backOut(t: number): number; + /** + !#en Easing in and out action with "back up" behavior. + !#zh 回退效果的缓入缓出函数。 + @param t The current time as a percentage of the total time. + */ + backInOut(t: number): number; + /** + !#en Easing in action with bouncing effect. + !#zh 弹跳效果的缓入函数。 + @param t The current time as a percentage of the total time. + */ + bounceIn(t: number): number; + /** + !#en Easing out action with bouncing effect. + !#zh 弹跳效果的缓出函数。 + @param t The current time as a percentage of the total time. + */ + bounceOut(t: number): number; + /** + !#en Easing in and out action with bouncing effect. + !#zh 弹跳效果的缓入缓出函数。 + @param t The current time as a percentage of the total time. + */ + bounceInOut(t: number): number; + /** + !#en Target will run action with smooth effect. + !#zh 平滑效果函数。 + @param t The current time as a percentage of the total time. + */ + smooth(t: number): number; + /** + !#en Target will run action with fade effect. + !#zh 渐褪效果函数。 + @param t The current time as a percentage of the total time. + */ + fade(t: number): number; + } + /** undefined */ + export class Playable { + /** !#en Is playing or paused in play mode? + !#zh 当前是否正在播放。 */ + isPlaying: boolean; + /** !#en Is currently paused? This can be true even if in edit mode(isPlaying == false). + !#zh 当前是否正在暂停 */ + isPaused: boolean; + /** + !#en Play this animation. + !#zh 播放动画。 + */ + play(): void; + /** + !#en Stop this animation. + !#zh 停止动画播放。 + */ + stop(): void; + /** + !#en Pause this animation. + !#zh 暂停动画。 + */ + pause(): void; + /** + !#en Resume this animation. + !#zh 重新播放动画。 + */ + resume(): void; + /** + !#en Perform a single frame step. + !#zh 执行一帧动画。 + */ + step(): void; + } + /** !#en Specifies how time is treated when it is outside of the keyframe range of an Animation. + !#zh 动画使用的循环模式。 */ + export enum WrapMode { + Default = 0, + Normal = 0, + Reverse = 0, + Loop = 0, + LoopReverse = 0, + PingPong = 0, + PingPongReverse = 0, + } + /** Class for particle asset handling. */ + export class ParticleAsset extends Asset { + } + /** Particle System base class.
+ Attributes of a Particle System:
+ - emmision rate of the particles
+ - Gravity Mode (Mode A):
+ - gravity
+ - direction
+ - speed +- variance
+ - tangential acceleration +- variance
+ - radial acceleration +- variance
+ - Radius Mode (Mode B):
+ - startRadius +- variance
+ - endRadius +- variance
+ - rotate +- variance
+ - Properties common to all modes:
+ - life +- life variance
+ - start spin +- variance
+ - end spin +- variance
+ - start size +- variance
+ - end size +- variance
+ - start color +- variance
+ - end color +- variance
+ - life +- variance
+ - blending function
+ - texture
+
+ cocos2d also supports particles generated by Particle Designer (http://particledesigner.71squared.com/).
+ 'Radius Mode' in Particle Designer uses a fixed emit rate of 30 hz. Since that can't be guarateed in cocos2d,
+ cocos2d uses a another approach, but the results are almost identical.
+ cocos2d supports all the variables used by Particle Designer plus a bit more:
+ - spinning particles (supported when using ParticleSystem)
+ - tangential acceleration (Gravity mode)
+ - radial acceleration (Gravity mode)
+ - radius direction (Radius mode) (Particle Designer supports outwards to inwards direction only)
+ It is possible to customize any of the above mentioned properties in runtime. Example:
*/ + export class ParticleSystem extends RenderComponent implements BlendFunc { + /** !#en Play particle in edit mode. + !#zh 在编辑器模式下预览粒子,启用后选中粒子时,粒子将自动播放。 */ + preview: boolean; + /** !#en + If set custom to true, then use custom properties insteadof read particle file. + !#zh 是否自定义粒子属性。 */ + custom: boolean; + /** !#en The plist file. + !#zh plist 格式的粒子配置文件。 */ + file: ParticleAsset; + /** !#en SpriteFrame used for particles display + !#zh 用于粒子呈现的 SpriteFrame */ + spriteFrame: SpriteFrame; + /** !#en Texture of Particle System, readonly, please use spriteFrame to setup new texture。 + !#zh 粒子贴图,只读属性,请使用 spriteFrame 属性来替换贴图。 */ + texture: string; + /** !#en Current quantity of particles that are being simulated. + !#zh 当前播放的粒子数量。 */ + particleCount: number; + /** !#en Indicate whether the system simulation have stopped. + !#zh 指示粒子播放是否完毕。 */ + stopped: boolean; + /** !#en If set to true, the particle system will automatically start playing on onLoad. + !#zh 如果设置为 true 运行时会自动发射粒子。 */ + playOnLoad: boolean; + /** !#en Indicate whether the owner node will be auto-removed when it has no particles left. + !#zh 粒子播放完毕后自动销毁所在的节点。 */ + autoRemoveOnFinish: boolean; + /** !#en Indicate whether the particle system is activated. + !#zh 是否激活粒子。 */ + active: boolean; + /** !#en Maximum particles of the system. + !#zh 粒子最大数量。 */ + totalParticles: number; + /** !#en How many seconds the emitter wil run. -1 means 'forever'. + !#zh 发射器生存时间,单位秒,-1表示持续发射。 */ + duration: number; + /** !#en Emission rate of the particles. + !#zh 每秒发射的粒子数目。 */ + emissionRate: number; + /** !#en Life of each particle setter. + !#zh 粒子的运行时间。 */ + life: number; + /** !#en Variation of life. + !#zh 粒子的运行时间变化范围。 */ + lifeVar: number; + /** !#en Start color of each particle. + !#zh 粒子初始颜色。 */ + startColor: Color; + /** !#en Variation of the start color. + !#zh 粒子初始颜色变化范围。 */ + startColorVar: Color; + /** !#en Ending color of each particle. + !#zh 粒子结束颜色。 */ + endColor: Color; + /** !#en Variation of the end color. + !#zh 粒子结束颜色变化范围。 */ + endColorVar: Color; + /** !#en Angle of each particle setter. + !#zh 粒子角度。 */ + angle: number; + /** !#en Variation of angle of each particle setter. + !#zh 粒子角度变化范围。 */ + angleVar: number; + /** !#en Start size in pixels of each particle. + !#zh 粒子的初始大小。 */ + startSize: number; + /** !#en Variation of start size in pixels. + !#zh 粒子初始大小的变化范围。 */ + startSizeVar: number; + /** !#en End size in pixels of each particle. + !#zh 粒子结束时的大小。 */ + endSize: number; + /** !#en Variation of end size in pixels. + !#zh 粒子结束大小的变化范围。 */ + endSizeVar: number; + /** !#en Start angle of each particle. + !#zh 粒子开始自旋角度。 */ + startSpin: number; + /** !#en Variation of start angle. + !#zh 粒子开始自旋角度变化范围。 */ + startSpinVar: number; + /** !#en End angle of each particle. + !#zh 粒子结束自旋角度。 */ + endSpin: number; + /** !#en Variation of end angle. + !#zh 粒子结束自旋角度变化范围。 */ + endSpinVar: number; + /** !#en Source position of the emitter. + !#zh 发射器位置。 */ + sourcePos: Vec2; + /** !#en Variation of source position. + !#zh 发射器位置的变化范围。(横向和纵向) */ + posVar: Vec2; + /** !#en Particles movement type. + !#zh 粒子位置类型。 */ + positionType: ParticleSystem.PositionType; + /** !#en Particles emitter modes. + !#zh 发射器类型。 */ + emitterMode: ParticleSystem.EmitterMode; + /** !#en Gravity of the emitter. + !#zh 重力。 */ + gravity: Vec2; + /** !#en Speed of the emitter. + !#zh 速度。 */ + speed: number; + /** !#en Variation of the speed. + !#zh 速度变化范围。 */ + speedVar: number; + /** !#en Tangential acceleration of each particle. Only available in 'Gravity' mode. + !#zh 每个粒子的切向加速度,即垂直于重力方向的加速度,只有在重力模式下可用。 */ + tangentialAccel: number; + /** !#en Variation of the tangential acceleration. + !#zh 每个粒子的切向加速度变化范围。 */ + tangentialAccelVar: number; + /** !#en Acceleration of each particle. Only available in 'Gravity' mode. + !#zh 粒子径向加速度,即平行于重力方向的加速度,只有在重力模式下可用。 */ + radialAccel: number; + /** !#en Variation of the radial acceleration. + !#zh 粒子径向加速度变化范围。 */ + radialAccelVar: number; + /** !#en Indicate whether the rotation of each particle equals to its direction. Only available in 'Gravity' mode. + !#zh 每个粒子的旋转是否等于其方向,只有在重力模式下可用。 */ + rotationIsDir: boolean; + /** !#en Starting radius of the particles. Only available in 'Radius' mode. + !#zh 初始半径,表示粒子出生时相对发射器的距离,只有在半径模式下可用。 */ + startRadius: number; + /** !#en Variation of the starting radius. + !#zh 初始半径变化范围。 */ + startRadiusVar: number; + /** !#en Ending radius of the particles. Only available in 'Radius' mode. + !#zh 结束半径,只有在半径模式下可用。 */ + endRadius: number; + /** !#en Variation of the ending radius. + !#zh 结束半径变化范围。 */ + endRadiusVar: number; + /** !#en Number of degress to rotate a particle around the source pos per second. Only available in 'Radius' mode. + !#zh 粒子每秒围绕起始点的旋转角度,只有在半径模式下可用。 */ + rotatePerS: number; + /** !#en Variation of the degress to rotate a particle around the source pos per second. + !#zh 粒子每秒围绕起始点的旋转角度变化范围。 */ + rotatePerSVar: number; + /** !#en The Particle emitter lives forever. + !#zh 表示发射器永久存在 */ + static DURATION_INFINITY: number; + /** !#en The starting size of the particle is equal to the ending size. + !#zh 表示粒子的起始大小等于结束大小。 */ + static START_SIZE_EQUAL_TO_END_SIZE: number; + /** !#en The starting radius of the particle is equal to the ending radius. + !#zh 表示粒子的起始半径等于结束半径。 */ + static START_RADIUS_EQUAL_TO_END_RADIUS: number; + /** + !#en Stop emitting particles. Running particles will continue to run until they die. + !#zh 停止发射器发射粒子,发射出去的粒子将继续运行,直至粒子生命结束。 + + @example + ```js + // stop particle system. + myParticleSystem.stopSystem(); + ``` + */ + stopSystem(): void; + /** + !#en Kill all living particles. + !#zh 杀死所有存在的粒子,然后重新启动粒子发射器。 + + @example + ```js + // play particle system. + myParticleSystem.resetSystem(); + ``` + */ + resetSystem(): void; + /** + !#en Whether or not the system is full. + !#zh 发射器中粒子是否大于等于设置的总粒子数量。 + */ + isFull(): boolean; + /** + !#en Sets a new texture with a rect. The rect is in texture position and size. + Please use spriteFrame property instead, this function is deprecated since v1.9 + !#zh 设置一张新贴图和关联的矩形。 + 请直接设置 spriteFrame 属性,这个函数从 v1.9 版本开始已经被废弃 + @param texture texture + @param rect rect + */ + setTextureWithRect(texture: Texture2D, rect: Rect): void; + /** !#en specify the source Blend Factor, this will generate a custom material object, please pay attention to the memory cost. + !#zh 指定原图的混合模式,这会克隆一个新的材质对象,注意这带来的开销 */ + srcBlendFactor: macro.BlendFactor; + /** !#en specify the destination Blend Factor. + !#zh 指定目标的混合模式 */ + dstBlendFactor: macro.BlendFactor; + } + /** !#en cc.audioEngine is the singleton object, it provide simple audio APIs. + !#zh + cc.audioengine是单例对象。
+ 主要用来播放音频,播放的时候会返回一个 audioID,之后都可以通过这个 audioID 来操作这个音频对象。
+ 不使用的时候,请使用 cc.audioEngine.uncache(filePath); 进行资源释放
+ 注意:
+ 在 Android 系统浏览器上,不同浏览器,不同版本的效果不尽相同。
+ 比如说:大多数浏览器都需要用户物理交互才可以开始播放音效,有一些不支持 WebAudio,
+ 有一些不支持多音轨播放。总之如果对音乐依赖比较强,请做尽可能多的测试。 */ + export class audioEngine { + /** + !#en Play audio. + !#zh 播放音频 + @param clip The audio clip to play. + @param loop Whether the music loop or not. + @param volume Volume size. + + @example + ```js + cc.resources.load(path, cc.AudioClip, null, function (err, clip) { + var audioID = cc.audioEngine.play(clip, false, 0.5); + }); + ``` + */ + static play(clip: AudioClip, loop: boolean, volume: number): number; + /** + !#en Set audio loop. + !#zh 设置音频是否循环。 + @param audioID audio id. + @param loop Whether cycle. + + @example + ```js + cc.audioEngine.setLoop(id, true); + ``` + */ + static setLoop(audioID: number, loop: boolean): void; + /** + !#en Get audio cycle state. + !#zh 获取音频的循环状态。 + @param audioID audio id. + + @example + ```js + cc.audioEngine.isLoop(id); + ``` + */ + static isLoop(audioID: number): boolean; + /** + !#en Set the volume of audio. + !#zh 设置音量(0.0 ~ 1.0)。 + @param audioID audio id. + @param volume Volume must be in 0.0~1.0 . + + @example + ```js + cc.audioEngine.setVolume(id, 0.5); + ``` + */ + static setVolume(audioID: number, volume: number): void; + /** + !#en The volume of the music max value is 1.0,the min value is 0.0 . + !#zh 获取音量(0.0 ~ 1.0)。 + @param audioID audio id. + + @example + ```js + var volume = cc.audioEngine.getVolume(id); + ``` + */ + static getVolume(audioID: number): number; + /** + !#en Set current time + !#zh 设置当前的音频时间。 + @param audioID audio id. + @param sec current time. + + @example + ```js + cc.audioEngine.setCurrentTime(id, 2); + ``` + */ + static setCurrentTime(audioID: number, sec: number): boolean; + /** + !#en Get current time + !#zh 获取当前的音频播放时间。 + @param audioID audio id. + + @example + ```js + var time = cc.audioEngine.getCurrentTime(id); + ``` + */ + static getCurrentTime(audioID: number): number; + /** + !#en Get audio duration + !#zh 获取音频总时长。 + @param audioID audio id. + + @example + ```js + var time = cc.audioEngine.getDuration(id); + ``` + */ + static getDuration(audioID: number): number; + /** + !#en Get audio state + !#zh 获取音频状态。 + @param audioID audio id. + + @example + ```js + var state = cc.audioEngine.getState(id); + ``` + */ + static getState(audioID: number): audioEngine.AudioState; + /** + !#en Set Audio finish callback + !#zh 设置一个音频结束后的回调 + @param audioID audio id. + @param callback loaded callback. + + @example + ```js + cc.audioEngine.setFinishCallback(id, function () {}); + ``` + */ + static setFinishCallback(audioID: number, callback: Function): void; + /** + !#en Pause playing audio. + !#zh 暂停正在播放音频。 + @param audioID The return value of function play. + + @example + ```js + cc.audioEngine.pause(audioID); + ``` + */ + static pause(audioID: number): void; + /** + !#en Pause all playing audio + !#zh 暂停现在正在播放的所有音频。 + + @example + ```js + cc.audioEngine.pauseAll(); + ``` + */ + static pauseAll(): void; + /** + !#en Resume playing audio. + !#zh 恢复播放指定的音频。 + @param audioID The return value of function play. + + @example + ```js + cc.audioEngine.resume(audioID); + ``` + */ + static resume(audioID: number): void; + /** + !#en Resume all playing audio. + !#zh 恢复播放所有之前暂停的所有音频。 + + @example + ```js + cc.audioEngine.resumeAll(); + ``` + */ + static resumeAll(): void; + /** + !#en Stop playing audio. + !#zh 停止播放指定音频。 + @param audioID The return value of function play. + + @example + ```js + cc.audioEngine.stop(audioID); + ``` + */ + static stop(audioID: number): void; + /** + !#en Stop all playing audio. + !#zh 停止正在播放的所有音频。 + + @example + ```js + cc.audioEngine.stopAll(); + ``` + */ + static stopAll(): void; + /** + !#en Set up an audio can generate a few examples. + !#zh 设置一个音频可以设置几个实例 + @param num a number of instances to be created from within an audio + + @example + ```js + cc.audioEngine.setMaxAudioInstance(20); + ``` + */ + static setMaxAudioInstance(num: number): void; + /** + !#en Getting audio can produce several examples. + !#zh 获取一个音频可以设置几个实例 + + @example + ```js + cc.audioEngine.getMaxAudioInstance(); + ``` + */ + static getMaxAudioInstance(): number; + /** + !#en Unload the preloaded audio from internal buffer. + !#zh 卸载预加载的音频。 + @param clip clip + + @example + ```js + cc.audioEngine.uncache(filePath); + ``` + */ + static uncache(clip: AudioClip): void; + /** + !#en Unload all audio from internal buffer. + !#zh 卸载所有音频。 + + @example + ```js + cc.audioEngine.uncacheAll(); + ``` + */ + static uncacheAll(): void; + /** + !#en Play background music + !#zh 播放背景音乐 + @param clip The audio clip to play. + @param loop Whether the music loop or not. + + @example + ```js + cc.resources.load(path, cc.AudioClip, null, function (err, clip) { + var audioID = cc.audioEngine.playMusic(clip, false); + }); + ``` + */ + static playMusic(clip: AudioClip, loop: boolean): number; + /** + !#en Stop background music. + !#zh 停止播放背景音乐。 + + @example + ```js + cc.audioEngine.stopMusic(); + ``` + */ + static stopMusic(): void; + /** + !#en Pause the background music. + !#zh 暂停播放背景音乐。 + + @example + ```js + cc.audioEngine.pauseMusic(); + ``` + */ + static pauseMusic(): void; + /** + !#en Resume playing background music. + !#zh 恢复播放背景音乐。 + + @example + ```js + cc.audioEngine.resumeMusic(); + ``` + */ + static resumeMusic(): void; + /** + !#en Get the volume(0.0 ~ 1.0). + !#zh 获取音量(0.0 ~ 1.0)。 + + @example + ```js + var volume = cc.audioEngine.getMusicVolume(); + ``` + */ + static getMusicVolume(): number; + /** + !#en Set the background music volume. + !#zh 设置背景音乐音量(0.0 ~ 1.0)。 + @param volume Volume must be in 0.0~1.0. + + @example + ```js + cc.audioEngine.setMusicVolume(0.5); + ``` + */ + static setMusicVolume(volume: number): void; + /** + !#en Background music playing state + !#zh 背景音乐是否正在播放 + + @example + ```js + cc.audioEngine.isMusicPlaying(); + ``` + */ + static isMusicPlaying(): boolean; + /** + !#en Play effect audio. + !#zh 播放音效 + @param clip The audio clip to play. + @param loop Whether the music loop or not. + + @example + ```js + cc.resources.load(path, cc.AudioClip, null, function (err, clip) { + var audioID = cc.audioEngine.playEffect(clip, false); + }); + ``` + */ + static playEffect(clip: AudioClip, loop: boolean): number; + /** + !#en Set the volume of effect audio. + !#zh 设置音效音量(0.0 ~ 1.0)。 + @param volume Volume must be in 0.0~1.0. + + @example + ```js + cc.audioEngine.setEffectsVolume(0.5); + ``` + */ + static setEffectsVolume(volume: number): void; + /** + !#en The volume of the effect audio max value is 1.0,the min value is 0.0 . + !#zh 获取音效音量(0.0 ~ 1.0)。 + + @example + ```js + var volume = cc.audioEngine.getEffectsVolume(); + ``` + */ + static getEffectsVolume(): number; + /** + !#en Pause effect audio. + !#zh 暂停播放音效。 + @param audioID audio id. + + @example + ```js + cc.audioEngine.pauseEffect(audioID); + ``` + */ + static pauseEffect(audioID: number): void; + /** + !#en Stop playing all the sound effects. + !#zh 暂停播放所有音效。 + + @example + ```js + cc.audioEngine.pauseAllEffects(); + ``` + */ + static pauseAllEffects(): void; + /** + !#en Resume effect audio. + !#zh 恢复播放音效音频。 + @param audioID The return value of function play. + + @example + ```js + cc.audioEngine.resumeEffect(audioID); + ``` + */ + static resumeEffect(audioID: number): void; + /** + !#en Resume all effect audio. + !#zh 恢复播放所有之前暂停的音效。 + + @example + ```js + cc.audioEngine.resumeAllEffects(); + ``` + */ + static resumeAllEffects(): void; + /** + !#en Stop playing the effect audio. + !#zh 停止播放音效。 + @param audioID audio id. + + @example + ```js + cc.audioEngine.stopEffect(id); + ``` + */ + static stopEffect(audioID: number): void; + /** + !#en Stop playing all the effects. + !#zh 停止播放所有音效。 + + @example + ```js + cc.audioEngine.stopAllEffects(); + ``` + */ + static stopAllEffects(): void; + } + /** !#en cc.WebView is a component for display web pages in the game. Because different platforms have different authorization, API and control methods for WebView component. And have not yet formed a unified standard, only Web, iOS, and Android platforms are currently supported. + !#zh WebView 组件,用于在游戏中显示网页。由于不同平台对于 WebView 组件的授权、API、控制方式都不同,还没有形成统一的标准,所以目前只支持 Web、iOS 和 Android 平台。 */ + export class WebView extends Component { + /** !#en A given URL to be loaded by the WebView, it should have a http or https prefix. + !#zh 指定 WebView 加载的网址,它应该是一个 http 或者 https 开头的字符串 */ + url: string; + /** !#en The webview's event callback , it will be triggered when certain webview event occurs. + !#zh WebView 的回调事件,当网页加载过程中,加载完成后或者加载出错时都会回调此函数 */ + webviewLoadedEvents: Component.EventHandler[]; + /** + !#en + Set javascript interface scheme (see also setOnJSCallback).
+ Note: Supports only on the Android and iOS. For HTML5, please refer to the official documentation.
+ Please refer to the official documentation for more details. + !#zh + 设置 JavaScript 接口方案(与 'setOnJSCallback' 配套使用)。
+ 注意:只支持 Android 和 iOS ,Web 端用法请前往官方文档查看。
+ 详情请参阅官方文档 + @param scheme scheme + */ + setJavascriptInterfaceScheme(scheme: string): void; + /** + !#en + This callback called when load URL that start with javascript + interface scheme (see also setJavascriptInterfaceScheme).
+ Note: Supports only on the Android and iOS. For HTML5, please refer to the official documentation.
+ Please refer to the official documentation for more details. + !#zh + 当加载 URL 以 JavaScript 接口方案开始时调用这个回调函数。
+ 注意:只支持 Android 和 iOS,Web 端用法请前往官方文档查看。 + 详情请参阅官方文档 + @param callback callback + */ + setOnJSCallback(callback: Function): void; + /** + !#en + Evaluates JavaScript in the context of the currently displayed page.
+ Please refer to the official document for more details
+ Note: Cross domain issues need to be resolved by yourself
+ !#zh + 执行 WebView 内部页面脚本(详情请参阅官方文档)
+ 注意:需要自行解决跨域问题 + @param str str + */ + evaluateJS(str: string): void; + /** + !#en if you don't need the WebView and it isn't in any running Scene, you should + call the destroy method on this component or the associated node explicitly. + Otherwise, the created DOM element won't be removed from web page. + !#zh + 如果你不再使用 WebView,并且组件未添加到场景中,那么你必须手动对组件或所在节点调用 destroy。 + 这样才能移除网页上的 DOM 节点,避免 Web 平台内存泄露。 + + @example + ```js + webview.node.parent = null; // or webview.node.removeFromParent(false); + // when you don't need webview anymore + webview.node.destroy(); + ``` + */ + destroy(): boolean; + } + /** !#en cc.VideoPlayer is a component for playing videos, you can use it for showing videos in your game. Because different platforms have different authorization, API and control methods for VideoPlayer component. And have not yet formed a unified standard, only Web, iOS, and Android platforms are currently supported. + !#zh Video 组件,用于在游戏中播放视频。由于不同平台对于 VideoPlayer 组件的授权、API、控制方式都不同,还没有形成统一的标准,所以目前只支持 Web、iOS 和 Android 平台。 */ + export class VideoPlayer extends Component { + /** !#en The resource type of videoplayer, REMOTE for remote url and LOCAL for local file path. + !#zh 视频来源:REMOTE 表示远程视频 URL,LOCAL 表示本地视频地址。 */ + resourceType: VideoPlayer.ResourceType; + /** !#en The remote URL of video. + !#zh 远程视频的 URL */ + remoteURL: string; + /** !#en The local video full path. + !#zh 本地视频的 URL */ + clip: string; + /** !#en The current playback time of the now playing item in seconds, you could also change the start playback time. + !#zh 指定视频从什么时间点开始播放,单位是秒,也可以用来获取当前视频播放的时间进度。 */ + currentTime: number; + /** !#en The volume of the video. + !#zh 视频的音量(0.0 ~ 1.0) */ + volume: number; + /** !#en Mutes the VideoPlayer. Mute sets the volume=0, Un-Mute restore the original volume. + !#zh 是否静音视频。静音时设置音量为 0,取消静音是恢复原来的音量。 */ + mute: boolean; + /** !#en Whether keep the aspect ration of the original video. + !#zh 是否保持视频原来的宽高比 */ + keepAspectRatio: boolean; + /** !#en Whether play video in fullscreen mode. + !#zh 是否全屏播放视频 */ + isFullscreen: boolean; + /** !#en Always below the game view (only useful on Web. Note: The specific effects are not guaranteed to be consistent, depending on whether each browser supports or restricts). + !#zh 永远在游戏视图最底层(这个属性只有在 Web 平台上有效果。注意:具体效果无法保证一致,跟各个浏览器是否支持与限制有关) */ + stayOnBottom: boolean; + /** !#en the video player's callback, it will be triggered when certain event occurs, like: playing, paused, stopped and completed. + !#zh 视频播放回调函数,该回调函数会在特定情况被触发,比如播放中,暂时,停止和完成播放。 */ + videoPlayerEvent: Component.EventHandler[]; + /** + !#en If a video is paused, call this method could resume playing. If a video is stopped, call this method to play from scratch. + !#zh 如果视频被暂停播放了,调用这个接口可以继续播放。如果视频被停止播放了,调用这个接口可以从头开始播放。 + */ + play(): void; + /** + !#en If a video is paused, call this method to resume playing. + !#zh 如果一个视频播放被暂停播放了,调用这个接口可以继续播放。 + */ + resume(): void; + /** + !#en If a video is playing, call this method to pause playing. + !#zh 如果一个视频正在播放,调用这个接口可以暂停播放。 + */ + pause(): void; + /** + !#en If a video is playing, call this method to stop playing immediately. + !#zh 如果一个视频正在播放,调用这个接口可以立马停止播放。 + */ + stop(): void; + /** + !#en Gets the duration of the video + !#zh 获取视频文件的播放总时长 + */ + getDuration(): number; + /** + !#en Determine whether video is playing or not. + !#zh 判断当前视频是否处于播放状态 + */ + isPlaying(): boolean; + /** + !#en if you don't need the VideoPlayer and it isn't in any running Scene, you should + call the destroy method on this component or the associated node explicitly. + Otherwise, the created DOM element won't be removed from web page. + !#zh + 如果你不再使用 VideoPlayer,并且组件未添加到场景中,那么你必须手动对组件或所在节点调用 destroy。 + 这样才能移除网页上的 DOM 节点,避免 Web 平台内存泄露。 + + @example + ```js + videoplayer.node.parent = null; // or videoplayer.node.removeFromParent(false); + // when you don't need videoplayer anymore + videoplayer.node.destroy(); + ``` + */ + destroy(): boolean; + } + /** !#en + cc.NodePool is the cache pool designed for node type.
+ It can helps you to improve your game performance for objects which need frequent release and recreate operations
+ + It's recommended to create cc.NodePool instances by node type, the type corresponds to node type in game design, not the class, + for example, a prefab is a specific node type.
+ When you create a node pool, you can pass a Component which contains `unuse`, `reuse` functions to control the content of node.
+ + Some common use case is :
+ 1. Bullets in game (die very soon, massive creation and recreation, no side effect on other objects)
+ 2. Blocks in candy crash (massive creation and recreation)
+ etc... + !#zh + cc.NodePool 是用于管理节点对象的对象缓存池。
+ 它可以帮助您提高游戏性能,适用于优化对象的反复创建和销毁
+ 以前 cocos2d-x 中的 cc.pool 和新的节点事件注册系统不兼容,因此请使用 cc.NodePool 来代替。 + + 新的 NodePool 需要实例化之后才能使用,每种不同的节点对象池需要一个不同的对象池实例,这里的种类对应于游戏中的节点设计,一个 prefab 相当于一个种类的节点。
+ 在创建缓冲池时,可以传入一个包含 unuse, reuse 函数的组件类型用于节点的回收和复用逻辑。
+ + 一些常见的用例是:
+ 1.在游戏中的子弹(死亡很快,频繁创建,对其他对象无副作用)
+ 2.糖果粉碎传奇中的木块(频繁创建)。 + 等等.... */ + export class NodePool { + /** + !#en + Constructor for creating a pool for a specific node template (usually a prefab). You can pass a component (type or name) argument for handling event for reusing and recycling node. + !#zh + 使用构造函数来创建一个节点专用的对象池,您可以传递一个组件类型或名称,用于处理节点回收和复用时的事件逻辑。 + @param poolHandlerComp !#en The constructor or the class name of the component to control the unuse/reuse logic. !#zh 处理节点回收和复用事件逻辑的组件类型或名称。 + + @example + ```js + properties: { + template: cc.Prefab + }, + onLoad () { + // MyTemplateHandler is a component with 'unuse' and 'reuse' to handle events when node is reused or recycled. + this.myPool = new cc.NodePool('MyTemplateHandler'); + } + ``` + */ + constructor(poolHandlerComp?: {prototype: Component}|string); + /** !#en The pool handler component, it could be the class name or the constructor. + !#zh 缓冲池处理组件,用于节点的回收和复用逻辑,这个属性可以是组件类名或组件的构造函数。 */ + poolHandlerComp: Function|string; + /** + !#en The current available size in the pool + !#zh 获取当前缓冲池的可用对象数量 + */ + size(): number; + /** + !#en Destroy all cached nodes in the pool + !#zh 销毁对象池中缓存的所有节点 + */ + clear(): void; + /** + !#en Put a new Node into the pool. + It will automatically remove the node from its parent without cleanup. + It will also invoke unuse method of the poolHandlerComp if exist. + !#zh 向缓冲池中存入一个不再需要的节点对象。 + 这个函数会自动将目标节点从父节点上移除,但是不会进行 cleanup 操作。 + 这个函数会调用 poolHandlerComp 的 unuse 函数,如果组件和函数都存在的话。 + @param obj obj + + @example + ```js + let myNode = cc.instantiate(this.template); + this.myPool.put(myNode); + ``` + */ + put(obj: Node): void; + /** + !#en Get a obj from pool, if no available object in pool, null will be returned. + This function will invoke the reuse function of poolHandlerComp if exist. + !#zh 获取对象池中的对象,如果对象池没有可用对象,则返回空。 + 这个函数会调用 poolHandlerComp 的 reuse 函数,如果组件和函数都存在的话。 + @param params !#en Params to pass to 'reuse' method in poolHandlerComp !#zh 向 poolHandlerComp 中的 'reuse' 函数传递的参数 + + @example + ```js + let newNode = this.myPool.get(); + ``` + */ + get(...params: any[]): Node; + } + /** !#en An object to boot the game. + !#zh 包含游戏主体信息并负责驱动游戏的游戏对象。 */ + export class debug { + /** + !#en Gets error message with the error id and possible parameters. + !#zh 通过 error id 和必要的参数来获取错误信息。 + @param errorId errorId + @param param param + */ + static getError(errorId: string, param?: any): string; + /** + !#en Returns whether or not to display the FPS informations. + !#zh 是否显示 FPS 信息。 + */ + static isDisplayStats(): boolean; + /** + !#en Sets whether display the FPS on the bottom-left corner. + !#zh 设置是否在左下角显示 FPS。 + @param displayStats displayStats + */ + static setDisplayStats(displayStats: boolean): void; + } + /** !#en +

+ ATTENTION: USE cc.director INSTEAD OF cc.Director.
+ cc.director is a singleton object which manage your game's logic flow.
+ Since the cc.director is a singleton, you don't need to call any constructor or create functions,
+ the standard way to use it is by calling:
+ - cc.director.methodName();
+ + It creates and handle the main Window and manages how and when to execute the Scenes.
+
+ The cc.director is also responsible for:
+ - initializing the OpenGL context
+ - setting the OpenGL pixel format (default on is RGB565)
+ - setting the OpenGL buffer depth (default on is 0-bit)
+ - setting the color for clear screen (default one is BLACK)
+ - setting the projection (default one is 3D)
+ - setting the orientation (default one is Portrait)
+
+
+ The cc.director also sets the default OpenGL context:
+ - GL_TEXTURE_2D is enabled
+ - GL_VERTEX_ARRAY is enabled
+ - GL_COLOR_ARRAY is enabled
+ - GL_TEXTURE_COORD_ARRAY is enabled
+

+

+ cc.director also synchronizes timers with the refresh rate of the display.
+ Features and Limitations:
+ - Scheduled timers & drawing are synchronizes with the refresh rate of the display
+ - Only supports animation intervals of 1/60 1/30 & 1/15
+

+ + !#zh +

+ 注意:用 cc.director 代替 cc.Director。
+ cc.director 一个管理你的游戏的逻辑流程的单例对象。
+ 由于 cc.director 是一个单例,你不需要调用任何构造函数或创建函数,
+ 使用它的标准方法是通过调用:
+ - cc.director.methodName(); +
+ 它创建和处理主窗口并且管理什么时候执行场景。
+
+ cc.director 还负责:
+ - 初始化 OpenGL 环境。
+ - 设置OpenGL像素格式。(默认是 RGB565)
+ - 设置OpenGL缓冲区深度 (默认是 0-bit)
+ - 设置空白场景的颜色 (默认是 黑色)
+ - 设置投影 (默认是 3D)
+ - 设置方向 (默认是 Portrait)
+
+ cc.director 设置了 OpenGL 默认环境
+ - GL_TEXTURE_2D 启用。
+ - GL_VERTEX_ARRAY 启用。
+ - GL_COLOR_ARRAY 启用。
+ - GL_TEXTURE_COORD_ARRAY 启用。
+

+

+ cc.director 也同步定时器与显示器的刷新速率。 +
+ 特点和局限性:
+ - 将计时器 & 渲染与显示器的刷新频率同步。
+ - 只支持动画的间隔 1/60 1/30 & 1/15。
+

*/ + export class Director extends EventTarget { + /** + !#en + Converts a view coordinate to an WebGL coordinate
+ Useful to convert (multi) touches coordinates to the current layout (portrait or landscape)
+ Implementation can be found in CCDirectorWebGL. + !#zh 将触摸点的屏幕坐标转换为 WebGL View 下的坐标。 + @param uiPoint uiPoint + */ + convertToGL(uiPoint: Vec2): Vec2; + /** + !#en + Converts an OpenGL coordinate to a view coordinate
+ Useful to convert node points to window points for calls such as glScissor
+ Implementation can be found in CCDirectorWebGL. + !#zh 将触摸点的 WebGL View 坐标转换为屏幕坐标。 + @param glPoint glPoint + */ + convertToUI(glPoint: Vec2): Vec2; + /** + End the life of director in the next frame + */ + end(): void; + /** + !#en + Returns the size of the WebGL view in points.
+ It takes into account any possible rotation (device orientation) of the window. + !#zh 获取视图的大小,以点为单位。 + */ + getWinSize(): Size; + /** + !#en + Returns the size of the OpenGL view in pixels.
+ It takes into account any possible rotation (device orientation) of the window.
+ On Mac winSize and winSizeInPixels return the same value. + (The pixel here refers to the resource resolution. If you want to get the physics resolution of device, you need to use cc.view.getFrameSize()) + !#zh + 获取视图大小,以像素为单位(这里的像素指的是资源分辨率。 + 如果要获取屏幕物理分辨率,需要用 cc.view.getFrameSize()) + */ + getWinSizeInPixels(): Size; + /** + !#en Pause the director's ticker, only involve the game logic execution. + It won't pause the rendering process nor the event manager. + If you want to pause the entier game including rendering, audio and event, + please use {{#crossLink "Game.pause"}}cc.game.pause{{/crossLink}} + !#zh 暂停正在运行的场景,该暂停只会停止游戏逻辑执行,但是不会停止渲染和 UI 响应。 + 如果想要更彻底得暂停游戏,包含渲染,音频和事件,请使用 {{#crossLink "Game.pause"}}cc.game.pause{{/crossLink}}。 + */ + pause(): void; + /** + !#en + Run a scene. Replaces the running scene with a new one or enter the first scene.
+ The new scene will be launched immediately. + !#zh 立刻切换指定场景。 + @param scene The need run scene. + @param onBeforeLoadScene The function invoked at the scene before loading. + @param onLaunched The function invoked at the scene after launch. + */ + runSceneImmediate(scene: Scene|SceneAsset, onBeforeLoadScene?: Function, onLaunched?: Function): void; + /** + !#en + Run a scene. Replaces the running scene with a new one or enter the first scene. + The new scene will be launched at the end of the current frame. + !#zh 运行指定场景。 + @param scene The need run scene. + @param onBeforeLoadScene The function invoked at the scene before loading. + @param onLaunched The function invoked at the scene after launch. + */ + runScene(scene: Scene|SceneAsset, onBeforeLoadScene?: Function, onLaunched?: Function): void; + /** + !#en Loads the scene by its name. + !#zh 通过场景名称进行加载场景。 + @param sceneName The name of the scene to load. + @param onLaunched callback, will be called after scene launched. + */ + loadScene(sceneName: string, onLaunched?: Function): boolean; + /** + !#en + Preloads the scene to reduces loading time. You can call this method at any time you want. + After calling this method, you still need to launch the scene by `cc.director.loadScene`. + It will be totally fine to call `cc.director.loadScene` at any time even if the preloading is not + yet finished, the scene will be launched after loaded automatically. + !#zh 预加载场景,你可以在任何时候调用这个方法。 + 调用完后,你仍然需要通过 `cc.director.loadScene` 来启动场景,因为这个方法不会执行场景加载操作。 + 就算预加载还没完成,你也可以直接调用 `cc.director.loadScene`,加载完成后场景就会启动。 + @param sceneName The name of the scene to preload. + @param onProgress callback, will be called when the load progression change. + @param onLoaded callback, will be called after scene loaded. + */ + preloadScene(sceneName: string, onProgress?: (completedCount: number, totalCount: number, item: any) => void, onLoaded?: (error: Error) => void): void; + /** + !#en Resume game logic execution after pause, if the current scene is not paused, nothing will happen. + !#zh 恢复暂停场景的游戏逻辑,如果当前场景没有暂停将没任何事情发生。 + */ + resume(): void; + /** + !#en + Enables or disables WebGL depth test.
+ Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js + !#zh 启用/禁用深度测试(在 Canvas 渲染模式下不会生效)。 + @param on on + */ + setDepthTest(on: boolean): void; + /** + !#en + Set color for clear screen.
+ (Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js) + !#zh + 设置场景的默认擦除颜色。
+ 支持全透明,但不支持透明度为中间值。要支持全透明需手工开启 cc.macro.ENABLE_TRANSPARENT_CANVAS。 + @param clearColor clearColor + */ + setClearColor(clearColor: Color): void; + /** + !#en Returns current logic Scene. + !#zh 获取当前逻辑场景。 + + @example + ```js + // This will help you to get the Canvas node in scene + cc.director.getScene().getChildByName('Canvas'); + ``` + */ + getScene(): Scene; + /** + !#en Returns the FPS value. Please use {{#crossLink "Game.setFrameRate"}}cc.game.setFrameRate{{/crossLink}} to control animation interval. + !#zh 获取单位帧执行时间。请使用 {{#crossLink "Game.setFrameRate"}}cc.game.setFrameRate{{/crossLink}} 来控制游戏帧率。 + */ + getAnimationInterval(): number; + /** + Sets animation interval, this doesn't control the main loop. + To control the game's frame rate overall, please use {{#crossLink "Game.setFrameRate"}}cc.game.setFrameRate{{/crossLink}} + @param value The animation interval desired. + */ + setAnimationInterval(value: number): void; + /** + !#en Returns the delta time since last frame. + !#zh 获取上一帧的增量时间。 + */ + getDeltaTime(): number; + /** + !#en Returns the total passed time since game start, unit: ms + !#zh 获取从游戏开始到现在总共经过的时间,单位为 ms + */ + getTotalTime(): number; + /** + !#en Returns how many frames were called since the director started. + !#zh 获取 director 启动以来游戏运行的总帧数。 + */ + getTotalFrames(): number; + /** + !#en Returns whether or not the Director is paused. + !#zh 是否处于暂停状态。 + */ + isPaused(): boolean; + /** + !#en Returns the cc.Scheduler associated with this director. + !#zh 获取和 director 相关联的 cc.Scheduler。 + */ + getScheduler(): Scheduler; + /** + !#en Sets the cc.Scheduler associated with this director. + !#zh 设置和 director 相关联的 cc.Scheduler。 + @param scheduler scheduler + */ + setScheduler(scheduler: Scheduler): void; + /** + !#en Returns the cc.ActionManager associated with this director. + !#zh 获取和 director 相关联的 cc.ActionManager(动作管理器)。 + */ + getActionManager(): ActionManager; + /** + !#en Sets the cc.ActionManager associated with this director. + !#zh 设置和 director 相关联的 cc.ActionManager(动作管理器)。 + @param actionManager actionManager + */ + setActionManager(actionManager: ActionManager): void; + /** + !#en Returns the cc.CollisionManager associated with this director. + !#zh 获取和 director 相关联的 cc.CollisionManager (碰撞管理器)。 + */ + getCollisionManager(): CollisionManager; + /** + !#en Returns the cc.PhysicsManager associated with this director. + !#zh 返回与 director 相关联的 cc.PhysicsManager (物理管理器)。 + */ + getPhysicsManager(): PhysicsManager; + /** + !#en Returns the cc.Physics3DManager associated with this director. + !#zh 返回与 director 相关联的 cc.Physics3DManager (物理管理器)。 + */ + getPhysics3DManager(): Physics3DManager; + /** !#en The event projection changed of cc.Director. This event will not get triggered since v2.0 + !#zh cc.Director 投影变化的事件。从 v2.0 开始这个事件不会再被触发 */ + static EVENT_PROJECTION_CHANGED: string; + /** !#en The event which will be triggered before loading a new scene. + !#zh 加载新场景之前所触发的事件。 */ + static EVENT_BEFORE_SCENE_LOADING: string; + /** !#en The event which will be triggered before launching a new scene. + !#zh 运行新场景之前所触发的事件。 */ + static EVENT_BEFORE_SCENE_LAUNCH: string; + /** !#en The event which will be triggered after launching a new scene. + !#zh 运行新场景之后所触发的事件。 */ + static EVENT_AFTER_SCENE_LAUNCH: string; + /** !#en The event which will be triggered at the beginning of every frame. + !#zh 每个帧的开始时所触发的事件。 */ + static EVENT_BEFORE_UPDATE: string; + /** !#en The event which will be triggered after engine and components update logic. + !#zh 将在引擎和组件 “update” 逻辑之后所触发的事件。 */ + static EVENT_AFTER_UPDATE: string; + /** !#en The event is deprecated since v2.0, please use cc.Director.EVENT_BEFORE_DRAW instead + !#zh 这个事件从 v2.0 开始被废弃,请直接使用 cc.Director.EVENT_BEFORE_DRAW */ + static EVENT_BEFORE_VISIT: string; + /** !#en The event is deprecated since v2.0, please use cc.Director.EVENT_BEFORE_DRAW instead + !#zh 这个事件从 v2.0 开始被废弃,请直接使用 cc.Director.EVENT_BEFORE_DRAW */ + static EVENT_AFTER_VISIT: string; + /** !#en The event which will be triggered before the rendering process. + !#zh 渲染过程之前所触发的事件。 */ + static EVENT_BEFORE_DRAW: string; + /** !#en The event which will be triggered after the rendering process. + !#zh 渲染过程之后所触发的事件。 */ + static EVENT_AFTER_DRAW: string; + /** Constant for 2D projection (orthogonal projection) */ + static PROJECTION_2D: number; + /** Constant for 3D projection with a fovy=60, znear=0.5f and zfar=1500. */ + static PROJECTION_3D: number; + /** Constant for custom projection, if cc.Director's projection set to it, it calls "updateProjection" on the projection delegate. */ + static PROJECTION_CUSTOM: number; + /** Constant for default projection of cc.Director, default projection is 2D projection */ + static PROJECTION_DEFAULT: number; + } + /** !#en An object to boot the game. + !#zh 包含游戏主体信息并负责驱动游戏的游戏对象。 */ + export class Game extends EventTarget { + /** !#en Event triggered when game hide to background. + Please note that this event is not 100% guaranteed to be fired on Web platform, + on native platforms, it corresponds to enter background event, os status bar or notification center may not trigger this event. + !#zh 游戏进入后台时触发的事件。 + 请注意,在 WEB 平台,这个事件不一定会 100% 触发,这完全取决于浏览器的回调行为。 + 在原生平台,它对应的是应用被切换到后台事件,下拉菜单和上拉状态栏等不一定会触发这个事件,这取决于系统行为。 */ + EVENT_HIDE: string; + /** !#en Event triggered when game back to foreground + Please note that this event is not 100% guaranteed to be fired on Web platform, + on native platforms, it corresponds to enter foreground event. + !#zh 游戏进入前台运行时触发的事件。 + 请注意,在 WEB 平台,这个事件不一定会 100% 触发,这完全取决于浏览器的回调行为。 + 在原生平台,它对应的是应用被切换到前台事件。 */ + EVENT_SHOW: string; + /** !#en Event triggered when game restart + !#zh 调用restart后,触发事件。 */ + EVENT_RESTART: string; + /** Event triggered after game inited, at this point all engine objects and game scripts are loaded */ + EVENT_GAME_INITED: string; + /** Event triggered after engine inited, at this point you will be able to use all engine classes. + It was defined as EVENT_RENDERER_INITED in cocos creator v1.x and renamed in v2.0 */ + EVENT_ENGINE_INITED: string; + /** Web Canvas 2d API as renderer backend */ + RENDER_TYPE_CANVAS: number; + /** WebGL API as renderer backend */ + RENDER_TYPE_WEBGL: number; + /** OpenGL API as renderer backend */ + RENDER_TYPE_OPENGL: number; + /** !#en The outer frame of the game canvas, parent of game container. + !#zh 游戏画布的外框,container 的父容器。 */ + frame: any; + /** !#en The container of game canvas. + !#zh 游戏画布的容器。 */ + container: HTMLDivElement; + /** !#en The canvas of the game. + !#zh 游戏的画布。 */ + canvas: HTMLCanvasElement; + /** !#en The renderer backend of the game. + !#zh 游戏的渲染器类型。 */ + renderType: number; + /** !#en + The current game configuration, including:
+ 1. debugMode
+ "debugMode" possible values :
+ 0 - No message will be printed.
+ 1 - cc.error, cc.assert, cc.warn, cc.log will print in console.
+ 2 - cc.error, cc.assert, cc.warn will print in console.
+ 3 - cc.error, cc.assert will print in console.
+ 4 - cc.error, cc.assert, cc.warn, cc.log will print on canvas, available only on web.
+ 5 - cc.error, cc.assert, cc.warn will print on canvas, available only on web.
+ 6 - cc.error, cc.assert will print on canvas, available only on web.
+ 2. showFPS
+ Left bottom corner fps information will show when "showFPS" equals true, otherwise it will be hide.
+ 3. exposeClassName
+ Expose class name to chrome debug tools, the class intantiate performance is a little bit slower when exposed.
+ 4. frameRate
+ "frameRate" set the wanted frame rate for your game, but the real fps depends on your game implementation and the running environment.
+ 5. id
+ "gameCanvas" sets the id of your canvas element on the web page, it's useful only on web.
+ 6. renderMode
+ "renderMode" sets the renderer type, only useful on web :
+ 0 - Automatically chosen by engine
+ 1 - Forced to use canvas renderer
+ 2 - Forced to use WebGL renderer, but this will be ignored on mobile browsers
+
+ Please DO NOT modify this object directly, it won't have any effect.
+ !#zh + 当前的游戏配置,包括:
+ 1. debugMode(debug 模式,但是在浏览器中这个选项会被忽略)
+ "debugMode" 各种设置选项的意义。
+ 0 - 没有消息被打印出来。
+ 1 - cc.error,cc.assert,cc.warn,cc.log 将打印在 console 中。
+ 2 - cc.error,cc.assert,cc.warn 将打印在 console 中。
+ 3 - cc.error,cc.assert 将打印在 console 中。
+ 4 - cc.error,cc.assert,cc.warn,cc.log 将打印在 canvas 中(仅适用于 web 端)。
+ 5 - cc.error,cc.assert,cc.warn 将打印在 canvas 中(仅适用于 web 端)。
+ 6 - cc.error,cc.assert 将打印在 canvas 中(仅适用于 web 端)。
+ 2. showFPS(显示 FPS)
+ 当 showFPS 为 true 的时候界面的左下角将显示 fps 的信息,否则被隐藏。
+ 3. exposeClassName
+ 暴露类名让 Chrome DevTools 可以识别,如果开启会稍稍降低类的创建过程的性能,但对对象构造没有影响。
+ 4. frameRate (帧率)
+ “frameRate” 设置想要的帧率你的游戏,但真正的FPS取决于你的游戏实现和运行环境。
+ 5. id
+ "gameCanvas" Web 页面上的 Canvas Element ID,仅适用于 web 端。
+ 6. renderMode(渲染模式)
+ “renderMode” 设置渲染器类型,仅适用于 web 端:
+ 0 - 通过引擎自动选择。
+ 1 - 强制使用 canvas 渲染。 + 2 - 强制使用 WebGL 渲染,但是在部分 Android 浏览器中这个选项会被忽略。
+
+ 注意:请不要直接修改这个对象,它不会有任何效果。 */ + config: any; + /** + !#en Callback when the scripts of engine have been load. + !#zh 当引擎完成启动后的回调函数。 + */ + onStart(): void; + /** + !#en Set frame rate of game. + !#zh 设置游戏帧率。 + @param frameRate frameRate + */ + setFrameRate(frameRate: number): void; + /** + !#en Get frame rate set for the game, it doesn't represent the real frame rate. + !#zh 获取设置的游戏帧率(不等同于实际帧率)。 + */ + getFrameRate(): number; + /** + !#en Run the game frame by frame. + !#zh 执行一帧游戏循环。 + */ + step(): void; + /** + !#en Pause the game main loop. This will pause: + game logic execution, rendering process, event manager, background music and all audio effects. + This is different with cc.director.pause which only pause the game logic execution. + !#zh 暂停游戏主循环。包含:游戏逻辑,渲染,事件处理,背景音乐和所有音效。这点和只暂停游戏逻辑的 cc.director.pause 不同。 + */ + pause(): void; + /** + !#en Resume the game from pause. This will resume: + game logic execution, rendering process, event manager, background music and all audio effects. + !#zh 恢复游戏主循环。包含:游戏逻辑,渲染,事件处理,背景音乐和所有音效。 + */ + resume(): void; + /** + !#en Check whether the game is paused. + !#zh 判断游戏是否暂停。 + */ + isPaused(): boolean; + /** + !#en Restart game. + !#zh 重新开始游戏 + */ + restart(): void; + /** + !#en End game, it will close the game window + !#zh 退出游戏 + */ + end(): void; + /** + !#en + Register an callback of a specific event type on the game object. + This type of event should be triggered via `emit`. + !#zh + 注册 game 的特定事件类型回调。这种类型的事件应该被 `emit` 触发。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + */ + on(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Register an callback of a specific event type on the game object, + the callback will remove itself after the first time it is triggered. + !#zh + 注册 game 的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + */ + once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; + /** + !#en Prepare game. + !#zh 准备引擎,请不要直接调用这个函数。 + @param cb cb + */ + prepare(cb: Function): void; + /** + !#en Run game with configuration object and onStart function. + !#zh 运行游戏,并且指定引擎配置和 onStart 的回调。 + @param config Pass configuration object or onStart function + @param onStart function to be executed after game initialized + */ + run(config: any, onStart: Function): void; + /** + !#en + Add a persistent root node to the game, the persistent node won't be destroyed during scene transition.
+ The target node must be placed in the root level of hierarchy, otherwise this API won't have any effect. + !#zh + 声明常驻根节点,该节点不会被在场景切换中被销毁。
+ 目标节点必须位于为层级的根节点,否则无效。 + @param node The node to be made persistent + */ + addPersistRootNode(node: Node): void; + /** + !#en Remove a persistent root node. + !#zh 取消常驻根节点。 + @param node The node to be removed from persistent node list + */ + removePersistRootNode(node: Node): void; + /** + !#en Check whether the node is a persistent root node. + !#zh 检查节点是否是常驻根节点。 + @param node The node to be checked + */ + isPersistRootNode(node: Node): boolean; + } + /** !#en + Class of all entities in Cocos Creator scenes.
+ For events supported by Node, please refer to {{#crossLink "Node.EventType"}}{{/crossLink}} + !#zh + Cocos Creator 场景中的所有节点类。
+ 支持的节点事件,请参阅 {{#crossLink "Node.EventType"}}{{/crossLink}}。 */ + export class Node extends _BaseNode { + /** !#en + Group index of node.
+ Which Group this node belongs to will resolve that this node's collision components can collide with which other collision componentns.
+ !#zh + 节点的分组索引。
+ 节点的分组将关系到节点的碰撞组件可以与哪些碰撞组件相碰撞。
*/ + groupIndex: number; + /** !#en + Group of node.
+ Which Group this node belongs to will resolve that this node's collision components can collide with which other collision componentns.
+ !#zh + 节点的分组。
+ 节点的分组将关系到节点的碰撞组件可以与哪些碰撞组件相碰撞。
*/ + group: string; + /** !#en The position (x, y) of the node in its parent's coordinates. + !#zh 节点在父节点坐标系中的位置(x, y)。 */ + position: Vec3; + /** !#en x axis position of node. + !#zh 节点 X 轴坐标。 */ + x: number; + /** !#en y axis position of node. + !#zh 节点 Y 轴坐标。 */ + y: number; + /** !#en z axis position of node. + !#zh 节点 Z 轴坐标。 */ + z: number; + /** !#en Rotation of node. + !#zh 该节点旋转角度。 */ + rotation: number; + /** !#en + Angle of node, the positive value is anti-clockwise direction. + !#zh + 该节点的旋转角度,正值为逆时针方向。 */ + angle: number; + /** !#en The rotation as Euler angles in degrees, used in 3D node. + !#zh 该节点的欧拉角度,用于 3D 节点。 */ + eulerAngles: Vec3; + /** !#en Rotation on x axis. + !#zh 该节点 X 轴旋转角度。 */ + rotationX: number; + /** !#en Rotation on y axis. + !#zh 该节点 Y 轴旋转角度。 */ + rotationY: number; + /** !#en The local scale relative to the parent. + !#zh 节点相对父节点的缩放。 */ + scale: number; + /** !#en Scale on x axis. + !#zh 节点 X 轴缩放。 */ + scaleX: number; + /** !#en Scale on y axis. + !#zh 节点 Y 轴缩放。 */ + scaleY: number; + /** !#en Scale on z axis. + !#zh 节点 Z 轴缩放。 */ + scaleZ: number; + /** !#en Skew x + !#zh 该节点 X 轴倾斜角度。 */ + skewX: number; + /** !#en Skew y + !#zh 该节点 Y 轴倾斜角度。 */ + skewY: number; + /** !#en Opacity of node, default value is 255. + !#zh 节点透明度,默认值为 255。 */ + opacity: number; + /** !#en Color of node, default value is white: (255, 255, 255). + !#zh 节点颜色。默认为白色,数值为:(255,255,255)。 */ + color: Color; + /** !#en Anchor point's position on x axis. + !#zh 节点 X 轴锚点位置。 */ + anchorX: number; + /** !#en Anchor point's position on y axis. + !#zh 节点 Y 轴锚点位置。 */ + anchorY: number; + /** !#en Width of node. + !#zh 节点宽度。 */ + width: number; + /** !#en Height of node. + !#zh 节点高度。 */ + height: number; + /** !#en zIndex is the 'key' used to sort the node relative to its siblings.
+ The value of zIndex should be in the range between cc.macro.MIN_ZINDEX and cc.macro.MAX_ZINDEX.
+ The Node's parent will sort all its children based on the zIndex value and the arrival order.
+ Nodes with greater zIndex will be sorted after nodes with smaller zIndex.
+ If two nodes have the same zIndex, then the node that was added first to the children's array will be in front of the other node in the array.
+ Node's order in children list will affect its rendering order. Parent is always rendering before all children. + !#zh zIndex 是用来对节点进行排序的关键属性,它决定一个节点在兄弟节点之间的位置。
+ zIndex 的取值应该介于 cc.macro.MIN_ZINDEX 和 cc.macro.MAX_ZINDEX 之间 + 父节点主要根据节点的 zIndex 和添加次序来排序,拥有更高 zIndex 的节点将被排在后面,如果两个节点的 zIndex 一致,先添加的节点会稳定排在另一个节点之前。
+ 节点在 children 中的顺序决定了其渲染顺序。父节点永远在所有子节点之前被渲染 */ + zIndex: number; + /** !#en + Switch 2D/3D node. The 2D nodes will run faster. + !#zh + 切换 2D/3D 节点,2D 节点会有更高的运行效率 */ + is3DNode: boolean; + /** !#en Returns a normalized vector representing the up direction (Y axis) of the node in world space. + !#zh 获取节点正上方(y 轴)面对的方向,返回值为世界坐标系下的归一化向量 */ + up: Vec3; + /** !#en Returns a normalized vector representing the right direction (X axis) of the node in world space. + !#zh 获取节点正右方(x 轴)面对的方向,返回值为世界坐标系下的归一化向量 */ + right: Vec3; + /** !#en Returns a normalized vector representing the forward direction (Z axis) of the node in world space. + !#zh 获取节点正前方(z 轴)面对的方向,返回值为世界坐标系下的归一化向量 */ + forward: Vec3; + /** + + @param name name + */ + constructor(name?: string); + /** + !#en + Register a callback of a specific event type on Node.
+ Use this method to register touch or mouse event permit propagation based on scene graph,
+ These kinds of event are triggered with dispatchEvent, the dispatch process has three steps:
+ 1. Capturing phase: dispatch in capture targets (`_getCapturingTargets`), e.g. parents in node tree, from root to the real target
+ 2. At target phase: dispatch to the listeners of the real target
+ 3. Bubbling phase: dispatch in bubble targets (`_getBubblingTargets`), e.g. parents in node tree, from the real target to root
+ In any moment of the dispatching process, it can be stopped via `event.stopPropagation()` or `event.stopPropagationImmidiate()`.
+ It's the recommended way to register touch/mouse event for Node,
+ please do not use cc.eventManager directly for Node.
+ You can also register custom event and use `emit` to trigger custom event on Node.
+ For such events, there won't be capturing and bubbling phase, your event will be dispatched directly to its listeners registered on the same node.
+ You can also pass event callback parameters with `emit` by passing parameters after `type`. + !#zh + 在节点上注册指定类型的回调函数,也可以设置 target 用于绑定响应函数的 this 对象。
+ 鼠标或触摸事件会被系统调用 dispatchEvent 方法触发,触发的过程包含三个阶段:
+ 1. 捕获阶段:派发事件给捕获目标(通过 `_getCapturingTargets` 获取),比如,节点树中注册了捕获阶段的父节点,从根节点开始派发直到目标节点。
+ 2. 目标阶段:派发给目标节点的监听器。
+ 3. 冒泡阶段:派发事件给冒泡目标(通过 `_getBubblingTargets` 获取),比如,节点树中注册了冒泡阶段的父节点,从目标节点开始派发直到根节点。
+ 同时您可以将事件派发到父节点或者通过调用 stopPropagation 拦截它。
+ 推荐使用这种方式来监听节点上的触摸或鼠标事件,请不要在节点上直接使用 cc.eventManager。
+ 你也可以注册自定义事件到节点上,并通过 emit 方法触发此类事件,对于这类事件,不会发生捕获冒泡阶段,只会直接派发给注册在该节点上的监听器
+ 你可以通过在 emit 方法调用时在 type 之后传递额外的参数作为事件回调的参数列表 + @param type A string representing the event type to listen for.
See {{#crossLink "Node/EventTyupe/POSITION_CHANGED"}}Node Events{{/crossLink}} for all builtin events. + @param callback The callback that will be invoked when the event is dispatched. The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + @param useCapture When set to true, the listener will be triggered at capturing phase which is ahead of the final target emit, otherwise it will be triggered during bubbling phase. + + @example + ```js + this.node.on(cc.Node.EventType.TOUCH_START, this.memberFunction, this); // if "this" is component and the "memberFunction" declared in CCClass. + node.on(cc.Node.EventType.TOUCH_START, callback, this); + node.on(cc.Node.EventType.TOUCH_MOVE, callback, this); + node.on(cc.Node.EventType.TOUCH_END, callback, this); + node.on(cc.Node.EventType.TOUCH_CANCEL, callback, this); + node.on(cc.Node.EventType.ANCHOR_CHANGED, callback); + node.on(cc.Node.EventType.COLOR_CHANGED, callback); + ``` + */ + on(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Register an callback of a specific event type on the Node, + the callback will remove itself after the first time it is triggered. + !#zh + 注册节点的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + node.once(cc.Node.EventType.ANCHOR_CHANGED, callback); + ``` + */ + once(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Removes the callback previously registered with the same type, callback, target and or useCapture. + This method is merely an alias to removeEventListener. + !#zh 删除之前与同类型,回调,目标或 useCapture 注册的回调。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + @param useCapture When set to true, the listener will be triggered at capturing phase which is ahead of the final target emit, otherwise it will be triggered during bubbling phase. + + @example + ```js + this.node.off(cc.Node.EventType.TOUCH_START, this.memberFunction, this); + node.off(cc.Node.EventType.TOUCH_START, callback, this.node); + node.off(cc.Node.EventType.ANCHOR_CHANGED, callback, this); + ``` + */ + off(type: string, callback?: Function, target?: any, useCapture?: boolean): void; + /** + !#en Removes all callbacks previously registered with the same target. + !#zh 移除目标上的所有注册事件。 + @param target The target to be searched for all related callbacks + + @example + ```js + node.targetOff(target); + ``` + */ + targetOff(target: any): void; + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en + Trigger an event directly with the event name and necessary arguments. + !#zh + 通过事件名发送自定义事件 + @param type event type + @param arg1 First argument in callback + @param arg2 Second argument in callback + @param arg3 Third argument in callback + @param arg4 Fourth argument in callback + @param arg5 Fifth argument in callback + + @example + ```js + eventTarget.emit('fire', event); + eventTarget.emit('fire', message, emitter); + ``` + */ + emit(type: string, arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any): void; + /** + !#en + Dispatches an event into the event flow. + The event target is the EventTarget object upon which the dispatchEvent() method is called. + !#zh 分发事件到事件流中。 + @param event The Event object that is dispatched into the event flow + */ + dispatchEvent(event: Event): void; + /** + !#en Pause node related system events registered with the current Node. Node system events includes touch and mouse events. + If recursive is set to true, then this API will pause the node system events for the node and all nodes in its sub node tree. + Reference: http://docs.cocos2d-x.org/editors_and_tools/creator-chapters/scripting/internal-events/ + !#zh 暂停当前节点上注册的所有节点系统事件,节点系统事件包含触摸和鼠标事件。 + 如果传递 recursive 为 true,那么这个 API 将暂停本节点和它的子树上所有节点的节点系统事件。 + 参考:https://www.cocos.com/docs/creator/scripting/internal-events.html + @param recursive Whether to pause node system events on the sub node tree. + + @example + ```js + node.pauseSystemEvents(true); + ``` + */ + pauseSystemEvents(recursive: boolean): void; + /** + !#en Resume node related system events registered with the current Node. Node system events includes touch and mouse events. + If recursive is set to true, then this API will resume the node system events for the node and all nodes in its sub node tree. + Reference: http://docs.cocos2d-x.org/editors_and_tools/creator-chapters/scripting/internal-events/ + !#zh 恢复当前节点上注册的所有节点系统事件,节点系统事件包含触摸和鼠标事件。 + 如果传递 recursive 为 true,那么这个 API 将恢复本节点和它的子树上所有节点的节点系统事件。 + 参考:https://www.cocos.com/docs/creator/scripting/internal-events.html + @param recursive Whether to resume node system events on the sub node tree. + + @example + ```js + node.resumeSystemEvents(true); + ``` + */ + resumeSystemEvents(recursive: boolean): void; + /** + !#en + Executes an action, and returns the action that is executed.
+ The node becomes the action's target. Refer to cc.Action's getTarget()
+ Calling runAction while the node is not active won't have any effect.
+ Note:You shouldn't modify the action after runAction, that won't take any effect.
+ if you want to modify, when you define action plus. + !#zh + 执行并返回该执行的动作。该节点将会变成动作的目标。
+ 调用 runAction 时,节点自身处于不激活状态将不会有任何效果。
+ 注意:你不应该修改 runAction 后的动作,将无法发挥作用,如果想进行修改,请在定义 action 时加入。 + @param action action + + @example + ```js + var action = cc.scaleTo(0.2, 1, 0.6); + node.runAction(action); + node.runAction(action).repeatForever(); // fail + node.runAction(action.repeatForever()); // right + ``` + */ + runAction(action: Action): Action; + /** + !#en Pause all actions running on the current node. Equals to `cc.director.getActionManager().pauseTarget(node)`. + !#zh 暂停本节点上所有正在运行的动作。和 `cc.director.getActionManager().pauseTarget(node);` 等价。 + + @example + ```js + node.pauseAllActions(); + ``` + */ + pauseAllActions(): void; + /** + !#en Resume all paused actions on the current node. Equals to `cc.director.getActionManager().resumeTarget(node)`. + !#zh 恢复运行本节点上所有暂停的动作。和 `cc.director.getActionManager().resumeTarget(node);` 等价。 + + @example + ```js + node.resumeAllActions(); + ``` + */ + resumeAllActions(): void; + /** + !#en Stops and removes all actions from the running action list . + !#zh 停止并且移除所有正在运行的动作列表。 + + @example + ```js + node.stopAllActions(); + ``` + */ + stopAllActions(): void; + /** + !#en Stops and removes an action from the running action list. + !#zh 停止并移除指定的动作。 + @param action An action object to be removed. + + @example + ```js + var action = cc.scaleTo(0.2, 1, 0.6); + node.stopAction(action); + ``` + */ + stopAction(action: Action): void; + /** + !#en Removes an action from the running action list by its tag. + !#zh 停止并且移除指定标签的动作。 + @param tag A tag that indicates the action to be removed. + + @example + ```js + node.stopActionByTag(1); + ``` + */ + stopActionByTag(tag: number): void; + /** + !#en Returns an action from the running action list by its tag. + !#zh 通过标签获取指定动作。 + @param tag tag + + @example + ```js + var action = node.getActionByTag(1); + ``` + */ + getActionByTag(tag: number): Action; + /** + !#en + Returns the numbers of actions that are running plus the ones that are schedule to run (actions in actionsToAdd and actions arrays).
+ Composable actions are counted as 1 action. Example:
+ If you are running 1 Sequence of 7 actions, it will return 1.
+ If you are running 7 Sequences of 2 actions, it will return 7.

+ !#zh + 获取运行着的动作加上正在调度运行的动作的总数。
+ 例如:
+ - 如果你正在运行 7 个动作中的 1 个 Sequence,它将返回 1。
+ - 如果你正在运行 2 个动作中的 7 个 Sequence,它将返回 7。
+ + @example + ```js + var count = node.getNumberOfRunningActions(); + cc.log("Running Action Count: " + count); + ``` + */ + getNumberOfRunningActions(): number; + /** + !#en + Returns a copy of the position (x, y, z) of the node in its parent's coordinates. + You can pass a cc.Vec2 or cc.Vec3 as the argument to receive the return values. + !#zh + 获取节点在父节点坐标系中的位置(x, y, z)。 + 你可以传一个 cc.Vec2 或者 cc.Vec3 作为参数来接收返回值。 + @param out The return value to receive position + + @example + ```js + cc.log("Node Position: " + node.getPosition()); + ``` + */ + getPosition(out?: Vec2|Vec3): Vec2; + /** + !#en + Sets the position (x, y, z) of the node in its parent's coordinates.
+ Usually we use cc.v2(x, y) to compose cc.Vec2 object,
+ and passing two numbers (x, y) is more efficient than passing cc.Vec2 object. + For 3D node we can use cc.v3(x, y, z) to compose cc.Vec3 object,
+ and passing three numbers (x, y, z) is more efficient than passing cc.Vec3 object. + !#zh + 设置节点在父节点坐标系中的位置。
+ 可以通过下面的方式设置坐标点:
+ 1. 传入 2 个数值 x, y。
+ 2. 传入 cc.v2(x, y) 类型为 cc.Vec2 的对象。 + 3. 对于 3D 节点可以传入 3 个数值 x, y, z。
+ 4. 对于 3D 节点可以传入 cc.v3(x, y, z) 类型为 cc.Vec3 的对象。 + @param newPosOrX X coordinate for position or the position (x, y, z) of the node in coordinates + @param y Y coordinate for position + @param z Z coordinate for position + */ + setPosition(newPosOrX: Vec2|Vec3|number, y?: number, z?: number): void; + /** + !#en + Returns the scale factor of the node. + Need pass a cc.Vec2 or cc.Vec3 as the argument to receive the return values. + !#zh 获取节点的缩放,需要传一个 cc.Vec2 或者 cc.Vec3 作为参数来接收返回值。 + @param out out + + @example + ```js + cc.log("Node Scale: " + node.getScale(cc.v3())); + ``` + */ + getScale(out: Vec2|Vec3): Vec2; + /** + !#en + Sets the scale of axis in local coordinates of the node. + You can operate 2 axis in 2D node, and 3 axis in 3D node. + !#zh + 设置节点在本地坐标系中坐标轴上的缩放比例。 + 2D 节点可以操作两个坐标轴,而 3D 节点可以操作三个坐标轴。 + @param x scaleX or scale object + @param y y + @param z z + + @example + ```js + node.setScale(cc.v2(2, 2)); + node.setScale(cc.v3(2, 2, 2)); // for 3D node + node.setScale(2); + ``` + */ + setScale(x: number|Vec2|Vec3, y?: number, z?: number): void; + /** + !#en + Get rotation of node (in quaternion). + Need pass a cc.Quat as the argument to receive the return values. + !#zh + 获取该节点的 quaternion 旋转角度,需要传一个 cc.Quat 作为参数来接收返回值。 + @param out out + */ + getRotation(out: Quat): Quat; + /** + !#en Set rotation of node (in quaternion). + !#zh 设置该节点的 quaternion 旋转角度。 + @param quat Quaternion object represents the rotation or the x value of quaternion + @param y y value of quternion + @param z z value of quternion + @param w w value of quternion + */ + setRotation(quat: Quat|number, y?: number, z?: number, w?: number): void; + /** + !#en + Returns a copy the untransformed size of the node.
+ The contentSize remains the same no matter the node is scaled or rotated.
+ All nodes has a size. Layer and Scene has the same size of the screen by default.
+ !#zh 获取节点自身大小,不受该节点是否被缩放或者旋转的影响。 + + @example + ```js + cc.log("Content Size: " + node.getContentSize()); + ``` + */ + getContentSize(): Size; + /** + !#en + Sets the untransformed size of the node.
+ The contentSize remains the same no matter the node is scaled or rotated.
+ All nodes has a size. Layer and Scene has the same size of the screen. + !#zh 设置节点原始大小,不受该节点是否被缩放或者旋转的影响。 + @param size The untransformed size of the node or The untransformed size's width of the node. + @param height The untransformed size's height of the node. + + @example + ```js + node.setContentSize(cc.size(100, 100)); + node.setContentSize(100, 100); + ``` + */ + setContentSize(size: Size|number, height?: number): void; + /** + !#en + Returns a copy of the anchor point.
+ Anchor point is the point around which all transformations and positioning manipulations take place.
+ It's like a pin in the node where it is "attached" to its parent.
+ The anchorPoint is normalized, like a percentage. (0,0) means the bottom-left corner and (1,1) means the top-right corner.
+ But you can use values higher than (1,1) and lower than (0,0) too.
+ The default anchor point is (0.5,0.5), so it starts at the center of the node. + !#zh + 获取节点锚点,用百分比表示。
+ 锚点应用于所有变换和坐标点的操作,它就像在节点上连接其父节点的大头针。
+ 锚点是标准化的,就像百分比一样。(0,0) 表示左下角,(1,1) 表示右上角。
+ 但是你可以使用比(1,1)更高的值或者比(0,0)更低的值。
+ 默认的锚点是(0.5,0.5),因此它开始于节点的中心位置。
+ 注意:Creator 中的锚点仅用于定位所在的节点,子节点的定位不受影响。 + + @example + ```js + cc.log("Node AnchorPoint: " + node.getAnchorPoint()); + ``` + */ + getAnchorPoint(): Vec2; + /** + !#en + Sets the anchor point in percent.
+ anchor point is the point around which all transformations and positioning manipulations take place.
+ It's like a pin in the node where it is "attached" to its parent.
+ The anchorPoint is normalized, like a percentage. (0,0) means the bottom-left corner and (1,1) means the top-right corner.
+ But you can use values higher than (1,1) and lower than (0,0) too.
+ The default anchor point is (0.5,0.5), so it starts at the center of the node. + !#zh + 设置锚点的百分比。
+ 锚点应用于所有变换和坐标点的操作,它就像在节点上连接其父节点的大头针。
+ 锚点是标准化的,就像百分比一样。(0,0) 表示左下角,(1,1) 表示右上角。
+ 但是你可以使用比(1,1)更高的值或者比(0,0)更低的值。
+ 默认的锚点是(0.5,0.5),因此它开始于节点的中心位置。
+ 注意:Creator 中的锚点仅用于定位所在的节点,子节点的定位不受影响。 + @param point The anchor point of node or The x axis anchor of node. + @param y The y axis anchor of node. + + @example + ```js + node.setAnchorPoint(cc.v2(1, 1)); + node.setAnchorPoint(1, 1); + ``` + */ + setAnchorPoint(point: Vec2|number, y?: number): void; + /** + !#en Set rotation by lookAt target point, normally used by Camera Node + !#zh 通过观察目标来设置 rotation,一般用于 Camera Node 上 + @param pos pos + @param up default is (0,1,0) + */ + lookAt(pos: Vec3, up?: Vec3): void; + /** + !#en + Get the local transform matrix (4x4), based on parent node coordinates + !#zh 返回局部空间坐标系的矩阵,基于父节点坐标系。 + @param out The matrix object to be filled with data + + @example + ```js + let mat4 = cc.mat4(); + node.getLocalMatrix(mat4); + ``` + */ + getLocalMatrix(out: Mat4): Mat4; + /** + !#en + Get the world transform matrix (4x4) + !#zh 返回世界空间坐标系的矩阵。 + @param out The matrix object to be filled with data + + @example + ```js + let mat4 = cc.mat4(); + node.getWorldMatrix(mat4); + ``` + */ + getWorldMatrix(out: Mat4): Mat4; + /** + !#en + Converts a Point to node (local) space coordinates. + !#zh + 将一个点转换到节点 (局部) 空间坐标系。 + @param worldPoint worldPoint + @param out out + + @example + ```js + var newVec2 = node.convertToNodeSpaceAR(cc.v2(100, 100)); + var newVec3 = node.convertToNodeSpaceAR(cc.v3(100, 100, 100)); + ``` + */ + convertToNodeSpaceAR(worldPoint: T, out?: T): T; + /** + !#en + Converts a Point in node coordinates to world space coordinates. + !#zh + 将节点坐标系下的一个点转换到世界空间坐标系。 + @param nodePoint nodePoint + @param out out + + @example + ```js + var newVec2 = node.convertToWorldSpaceAR(cc.v2(100, 100)); + var newVec3 = node.convertToWorldSpaceAR(cc.v3(100, 100, 100)); + ``` + */ + convertToWorldSpaceAR(nodePoint: T, out?: T): T; + /** + !#en Converts a Point to node (local) space coordinates then add the anchor point position. + So the return position will be related to the left bottom corner of the node's bounding box. + This equals to the API behavior of cocos2d-x, you probably want to use convertToNodeSpaceAR instead + !#zh 将一个点转换到节点 (局部) 坐标系,并加上锚点的坐标。
+ 也就是说返回的坐标是相对于节点包围盒左下角的坐标。
+ 这个 API 的设计是为了和 cocos2d-x 中行为一致,更多情况下你可能需要使用 convertToNodeSpaceAR。 + @param worldPoint worldPoint + + @example + ```js + var newVec2 = node.convertToNodeSpace(cc.v2(100, 100)); + ``` + */ + convertToNodeSpace(worldPoint: Vec2): Vec2; + /** + !#en Converts a Point related to the left bottom corner of the node's bounding box to world space coordinates. + This equals to the API behavior of cocos2d-x, you probably want to use convertToWorldSpaceAR instead + !#zh 将一个相对于节点左下角的坐标位置转换到世界空间坐标系。 + 这个 API 的设计是为了和 cocos2d-x 中行为一致,更多情况下你可能需要使用 convertToWorldSpaceAR + @param nodePoint nodePoint + + @example + ```js + var newVec2 = node.convertToWorldSpace(cc.v2(100, 100)); + ``` + */ + convertToWorldSpace(nodePoint: Vec2): Vec2; + /** + !#en + Returns the matrix that transform the node's (local) space coordinates into the parent's space coordinates.
+ The matrix is in Pixels. + !#zh 返回这个将节点(局部)的空间坐标系转换成父节点的空间坐标系的矩阵。这个矩阵以像素为单位。 + @param out The affine transform object to be filled with data + + @example + ```js + let affineTransform = cc.AffineTransform.create(); + node.getNodeToParentTransform(affineTransform); + ``` + */ + getNodeToParentTransform(out?: AffineTransform): AffineTransform; + /** + !#en + Returns the matrix that transform the node's (local) space coordinates into the parent's space coordinates.
+ The matrix is in Pixels.
+ This method is AR (Anchor Relative). + !#zh + 返回这个将节点(局部)的空间坐标系转换成父节点的空间坐标系的矩阵。
+ 这个矩阵以像素为单位。
+ 该方法基于节点坐标。 + @param out The affine transform object to be filled with data + + @example + ```js + let affineTransform = cc.AffineTransform.create(); + node.getNodeToParentTransformAR(affineTransform); + ``` + */ + getNodeToParentTransformAR(out?: AffineTransform): AffineTransform; + /** + !#en Returns the world affine transform matrix. The matrix is in Pixels. + !#zh 返回节点到世界坐标系的仿射变换矩阵。矩阵单位是像素。 + @param out The affine transform object to be filled with data + + @example + ```js + let affineTransform = cc.AffineTransform.create(); + node.getNodeToWorldTransform(affineTransform); + ``` + */ + getNodeToWorldTransform(out?: AffineTransform): AffineTransform; + /** + !#en + Returns the world affine transform matrix. The matrix is in Pixels.
+ This method is AR (Anchor Relative). + !#zh + 返回节点到世界坐标仿射变换矩阵。矩阵单位是像素。
+ 该方法基于节点坐标。 + @param out The affine transform object to be filled with data + + @example + ```js + let affineTransform = cc.AffineTransform.create(); + node.getNodeToWorldTransformAR(affineTransform); + ``` + */ + getNodeToWorldTransformAR(out?: AffineTransform): AffineTransform; + /** + !#en + Returns the matrix that transform parent's space coordinates to the node's (local) space coordinates.
+ The matrix is in Pixels. The returned transform is readonly and cannot be changed. + !#zh + 返回将父节点的坐标系转换成节点(局部)的空间坐标系的矩阵。
+ 该矩阵以像素为单位。返回的矩阵是只读的,不能更改。 + @param out The affine transform object to be filled with data + + @example + ```js + let affineTransform = cc.AffineTransform.create(); + node.getParentToNodeTransform(affineTransform); + ``` + */ + getParentToNodeTransform(out?: AffineTransform): AffineTransform; + /** + !#en Returns the inverse world affine transform matrix. The matrix is in Pixels. + !#en 返回世界坐标系到节点坐标系的逆矩阵。 + @param out The affine transform object to be filled with data + + @example + ```js + let affineTransform = cc.AffineTransform.create(); + node.getWorldToNodeTransform(affineTransform); + ``` + */ + getWorldToNodeTransform(out?: AffineTransform): AffineTransform; + /** + !#en convenience methods which take a cc.Touch instead of cc.Vec2. + !#zh 将触摸点转换成本地坐标系中位置。 + @param touch The touch object + + @example + ```js + var newVec2 = node.convertTouchToNodeSpace(touch); + ``` + */ + convertTouchToNodeSpace(touch: Touch): Vec2; + /** + !#en converts a cc.Touch (world coordinates) into a local coordinate. This method is AR (Anchor Relative). + !#zh 转换一个 cc.Touch(世界坐标)到一个局部坐标,该方法基于节点坐标。 + @param touch The touch object + + @example + ```js + var newVec2 = node.convertTouchToNodeSpaceAR(touch); + ``` + */ + convertTouchToNodeSpaceAR(touch: Touch): Vec2; + /** + !#en + Returns a "local" axis aligned bounding box of the node.
+ The returned box is relative only to its parent. + !#zh 返回父节坐标系下的轴向对齐的包围盒。 + + @example + ```js + var boundingBox = node.getBoundingBox(); + ``` + */ + getBoundingBox(): Rect; + /** + !#en + Returns a "world" axis aligned bounding box of the node.
+ The bounding box contains self and active children's world bounding box. + !#zh + 返回节点在世界坐标系下的对齐轴向的包围盒(AABB)。
+ 该边框包含自身和已激活的子节点的世界边框。 + + @example + ```js + var newRect = node.getBoundingBoxToWorld(); + ``` + */ + getBoundingBoxToWorld(): Rect; + /** + !#en + Adds a child to the node with z order and name. + !#zh + 添加子节点,并且可以修改该节点的 局部 Z 顺序和名字。 + @param child A child node + @param zIndex Z order for drawing priority. Please refer to zIndex property + @param name A name to identify the node easily. Please refer to name property + + @example + ```js + node.addChild(newNode, 1, "node"); + ``` + */ + addChild(child: Node, zIndex?: number, name?: string): void; + /** + !#en Stops all running actions and schedulers. + !#zh 停止所有正在播放的动作和计时器。 + + @example + ```js + node.cleanup(); + ``` + */ + cleanup(): void; + /** + !#en Sorts the children array depends on children's zIndex and arrivalOrder, + normally you won't need to invoke this function. + !#zh 根据子节点的 zIndex 和 arrivalOrder 进行排序,正常情况下开发者不需要手动调用这个函数。 + */ + sortAllChildren(): void; + /** + !#en + Returns the displayed opacity of Node, + the difference between displayed opacity and opacity is that displayed opacity is calculated based on opacity and parent node's opacity when cascade opacity enabled. + !#zh + 获取节点显示透明度, + 显示透明度和透明度之间的不同之处在于当启用级连透明度时, + 显示透明度是基于自身透明度和父节点透明度计算的。 + */ + getDisplayedOpacity(): number; + /** + !#en + Returns the displayed color of Node, + the difference between displayed color and color is that displayed color is calculated based on color and parent node's color when cascade color enabled. + !#zh + 获取节点的显示颜色, + 显示颜色和颜色之间的不同之处在于当启用级连颜色时, + 显示颜色是基于自身颜色和父节点颜色计算的。 + */ + getDisplayedColor(): Color; + /** !#en Cascade opacity is removed from v2.0 + Indicate whether node's opacity value affect its child nodes, default value is true. + !#zh 透明度级联功能从 v2.0 开始已移除 + 节点的不透明度值是否影响其子节点,默认值为 true。 */ + cascadeOpacity: boolean; + /** + !#en Cascade opacity is removed from v2.0 + Returns whether node's opacity value affect its child nodes. + !#zh 透明度级联功能从 v2.0 开始已移除 + 返回节点的不透明度值是否影响其子节点。 + */ + isCascadeOpacityEnabled(): boolean; + /** + !#en Cascade opacity is removed from v2.0 + Enable or disable cascade opacity, if cascade enabled, child nodes' opacity will be the multiplication of parent opacity and its own opacity. + !#zh 透明度级联功能从 v2.0 开始已移除 + 启用或禁用级连不透明度,如果级连启用,子节点的不透明度将是父不透明度乘上它自己的不透明度。 + @param cascadeOpacityEnabled cascadeOpacityEnabled + */ + setCascadeOpacityEnabled(cascadeOpacityEnabled: boolean): void; + /** + !#en Opacity modify RGB have been removed since v2.0 + Set whether color should be changed with the opacity value, + useless in ccsg.Node, but this function is override in some class to have such behavior. + !#zh 透明度影响颜色配置已经被废弃 + 设置更改透明度时是否修改RGB值, + @param opacityValue opacityValue + */ + setOpacityModifyRGB(opacityValue: boolean): void; + /** + !#en Opacity modify RGB have been removed since v2.0 + Get whether color should be changed with the opacity value. + !#zh 透明度影响颜色配置已经被废弃 + 获取更改透明度时是否修改RGB值。 + */ + isOpacityModifyRGB(): boolean; + } + /** !#en + cc.Scene is a subclass of cc.Node that is used only as an abstract concept.
+ cc.Scene and cc.Node are almost identical with the difference that users can not modify cc.Scene manually. + !#zh + cc.Scene 是 cc.Node 的子类,仅作为一个抽象的概念。
+ cc.Scene 和 cc.Node 有点不同,用户不应直接修改 cc.Scene。 */ + export class Scene extends Node { + /** !#en Indicates whether all (directly or indirectly) static referenced assets of this scene are releasable by default after scene unloading. + !#zh 指示该场景中直接或间接静态引用到的所有资源是否默认在场景切换后自动释放。 */ + autoReleaseAssets: boolean; + } + /** !#en + Class of private entities in Cocos Creator scenes.
+ The PrivateNode is hidden in editor, and completely transparent to users.
+ It's normally used as Node's private content created by components in parent node.
+ So in theory private nodes are not children, they are part of the parent node.
+ Private node have two important characteristics:
+ 1. It has the minimum z index and cannot be modified, because they can't be displayed over real children.
+ 2. The positioning of private nodes is also special, they will consider the left bottom corner of the parent node's bounding box as the origin of local coordinates.
+ In this way, they can be easily kept inside the bounding box.
+ Currently, it's used by RichText component and TileMap component. + !#zh + Cocos Creator 场景中的私有节点类。
+ 私有节点在编辑器中不可见,对用户透明。
+ 通常私有节点是被一些特殊的组件创建出来作为父节点的一部分而存在的,理论上来说,它们不是子节点,而是父节点的组成部分。
+ 私有节点有两个非常重要的特性:
+ 1. 它有着最小的渲染排序的 Z 轴深度,并且无法被更改,因为它们不能被显示在其他正常子节点之上。
+ 2. 它的定位也是特殊的,对于私有节点来说,父节点包围盒的左下角是它的局部坐标系原点,这个原点相当于父节点的位置减去它锚点的偏移。这样私有节点可以比较容易被控制在包围盒之中。
+ 目前在引擎中,RichText 和 TileMap 都有可能生成私有节点。 */ + export class PrivateNode extends Node { + /** + + @param name name + */ + constructor(name?: string); + } + /** !#en + Scheduler is responsible of triggering the scheduled callbacks.
+ You should not use NSTimer. Instead use this class.
+
+ There are 2 different types of callbacks (selectors):
+ - update callback: the 'update' callback will be called every frame. You can customize the priority.
+ - custom callback: A custom callback will be called every frame, or with a custom interval of time
+
+ The 'custom selectors' should be avoided when possible. It is faster, + and consumes less memory to use the 'update callback'. * + !#zh + Scheduler 是负责触发回调函数的类。
+ 通常情况下,建议使用 cc.director.getScheduler() 来获取系统定时器。
+ 有两种不同类型的定时器:
+ - update 定时器:每一帧都会触发。您可以自定义优先级。
+ - 自定义定时器:自定义定时器可以每一帧或者自定义的时间间隔触发。
+ 如果希望每帧都触发,应该使用 update 定时器,使用 update 定时器更快,而且消耗更少的内存。 */ + export class Scheduler { + /** + !#en This method should be called for any target which needs to schedule tasks, and this method should be called before any scheduler API usage. + This method will add a `_id` property if it doesn't exist. + !#zh 任何需要用 Scheduler 管理任务的对象主体都应该调用这个方法,并且应该在调用任何 Scheduler API 之前调用这个方法。 + 这个方法会给对象添加一个 `_id` 属性,如果这个属性不存在的话。 + @param target target + */ + enableForTarget(target: any): void; + /** + !#en + Modifies the time of all scheduled callbacks.
+ You can use this property to create a 'slow motion' or 'fast forward' effect.
+ Default is 1.0. To create a 'slow motion' effect, use values below 1.0.
+ To create a 'fast forward' effect, use values higher than 1.0.
+ Note:It will affect EVERY scheduled selector / action. + !#zh + 设置时间间隔的缩放比例。
+ 您可以使用这个方法来创建一个 “slow motion(慢动作)” 或 “fast forward(快进)” 的效果。
+ 默认是 1.0。要创建一个 “slow motion(慢动作)” 效果,使用值低于 1.0。
+ 要使用 “fast forward(快进)” 效果,使用值大于 1.0。
+ 注意:它影响该 Scheduler 下管理的所有定时器。 + @param timeScale timeScale + */ + setTimeScale(timeScale: number): void; + /** + !#en Returns time scale of scheduler. + !#zh 获取时间间隔的缩放比例。 + */ + getTimeScale(): number; + /** + !#en 'update' the scheduler. (You should NEVER call this method, unless you know what you are doing.) + !#zh update 调度函数。(不应该直接调用这个方法,除非完全了解这么做的结果) + @param dt delta time + */ + update(dt: number): void; + /** + !#en +

+ The scheduled method will be called every 'interval' seconds.
+ If paused is YES, then it won't be called until it is resumed.
+ If 'interval' is 0, it will be called every frame, but if so, it recommended to use 'scheduleUpdateForTarget:' instead.
+ If the callback function is already scheduled, then only the interval parameter will be updated without re-scheduling it again.
+ repeat let the action be repeated repeat + 1 times, use cc.macro.REPEAT_FOREVER to let the action run continuously
+ delay is the amount of time the action will wait before it'll start
+

+ !#zh + 指定回调函数,调用对象等信息来添加一个新的定时器。
+ 如果 paused 值为 true,那么直到 resume 被调用才开始计时。
+ 当时间间隔达到指定值时,设置的回调函数将会被调用。
+ 如果 interval 值为 0,那么回调函数每一帧都会被调用,但如果是这样, + 建议使用 scheduleUpdateForTarget 代替。
+ 如果回调函数已经被定时器使用,那么只会更新之前定时器的时间间隔参数,不会设置新的定时器。
+ repeat 值可以让定时器触发 repeat + 1 次,使用 cc.macro.REPEAT_FOREVER + 可以让定时器一直循环触发。
+ delay 值指定延迟时间,定时器会在延迟指定的时间之后开始计时。 + @param callback callback + @param target target + @param interval interval + @param repeat repeat + @param delay delay + @param paused paused + + @example + ```js + //register a schedule to scheduler + cc.director.getScheduler().schedule(callback, this, interval, !this._isRunning); + + ``` + */ + schedule(callback: Function, target: any, interval: number, repeat: number, delay: number, paused?: boolean): void; + schedule(callback: Function, target: any, interval: number, paused?: boolean): void; + /** + !#en + Schedules the update callback for a given target, + During every frame after schedule started, the "update" function of target will be invoked. + !#zh + 使用指定的优先级为指定的对象设置 update 定时器。 + update 定时器每一帧都会被触发,触发时自动调用指定对象的 "update" 函数。 + 优先级的值越低,定时器被触发的越早。 + @param target target + @param priority priority + @param paused paused + */ + scheduleUpdate(target: any, priority: number, paused: boolean): void; + /** + !#en + Unschedules a callback for a callback and a given target. + If you want to unschedule the "update", use `unscheduleUpdate()` + !#zh + 取消指定对象定时器。 + 如果需要取消 update 定时器,请使用 unscheduleUpdate()。 + @param callback The callback to be unscheduled + @param target The target bound to the callback. + */ + unschedule(callback: Function, target: any): void; + /** + !#en Unschedules the update callback for a given target. + !#zh 取消指定对象的 update 定时器。 + @param target The target to be unscheduled. + */ + unscheduleUpdate(target: any): void; + /** + !#en + Unschedules all scheduled callbacks for a given target. + This also includes the "update" callback. + !#zh 取消指定对象的所有定时器,包括 update 定时器。 + @param target The target to be unscheduled. + */ + unscheduleAllForTarget(target: any): void; + /** + !#en + Unschedules all scheduled callbacks from all targets including the system callbacks.
+ You should NEVER call this method, unless you know what you are doing. + !#zh + 取消所有对象的所有定时器,包括系统定时器。
+ 不要调用此函数,除非你确定你在做什么。 + */ + unscheduleAll(): void; + /** + !#en + Unschedules all callbacks from all targets with a minimum priority.
+ You should only call this with `PRIORITY_NON_SYSTEM_MIN` or higher. + !#zh + 取消所有优先级的值大于指定优先级的定时器。
+ 你应该只取消优先级的值大于 PRIORITY_NON_SYSTEM_MIN 的定时器。 + @param minPriority The minimum priority of selector to be unscheduled. Which means, all selectors which + priority is higher than minPriority will be unscheduled. + */ + unscheduleAllWithMinPriority(minPriority: number): void; + /** + !#en Checks whether a callback for a given target is scheduled. + !#zh 检查指定的回调函数和回调对象组合是否存在定时器。 + @param callback The callback to check. + @param target The target of the callback. + */ + isScheduled(callback: Function, target: any): boolean; + /** + !#en + Pause all selectors from all targets.
+ You should NEVER call this method, unless you know what you are doing. + !#zh + 暂停所有对象的所有定时器。
+ 不要调用这个方法,除非你知道你正在做什么。 + */ + pauseAllTargets(): void; + /** + !#en + Pause all selectors from all targets with a minimum priority.
+ You should only call this with kCCPriorityNonSystemMin or higher. + !#zh + 暂停所有优先级的值大于指定优先级的定时器。
+ 你应该只暂停优先级的值大于 PRIORITY_NON_SYSTEM_MIN 的定时器。 + @param minPriority minPriority + */ + pauseAllTargetsWithMinPriority(minPriority: number): void; + /** + !#en + Resume selectors on a set of targets.
+ This can be useful for undoing a call to pauseAllCallbacks. + !#zh + 恢复指定数组中所有对象的定时器。
+ 这个函数是 pauseAllCallbacks 的逆操作。 + @param targetsToResume targetsToResume + */ + resumeTargets(targetsToResume: any[]): void; + /** + !#en + Pauses the target.
+ All scheduled selectors/update for a given target won't be 'ticked' until the target is resumed.
+ If the target is not present, nothing happens. + !#zh + 暂停指定对象的定时器。
+ 指定对象的所有定时器都会被暂停。
+ 如果指定的对象没有定时器,什么也不会发生。 + @param target target + */ + pauseTarget(target: any): void; + /** + !#en + Resumes the target.
+ The 'target' will be unpaused, so all schedule selectors/update will be 'ticked' again.
+ If the target is not present, nothing happens. + !#zh + 恢复指定对象的所有定时器。
+ 指定对象的所有定时器将继续工作。
+ 如果指定的对象没有定时器,什么也不会发生。 + @param target target + */ + resumeTarget(target: any): void; + /** + !#en Returns whether or not the target is paused. + !#zh 返回指定对象的定时器是否暂停了。 + @param target target + */ + isTargetPaused(target: any): boolean; + /** !#en Priority level reserved for system services. + !#zh 系统服务的优先级。 */ + static PRIORITY_SYSTEM: number; + /** !#en Minimum priority level for user scheduling. + !#zh 用户调度最低优先级。 */ + static PRIORITY_NON_SYSTEM: number; + } + /** !#en The Light Component + + !#zh 光源组件 */ + export class Light extends Component { + } + /** !#en + This module controls asset's behaviors and information, include loading, releasing etc. it is a singleton + All member can be accessed with `cc.assetManager`. + + !#zh + 此模块管理资源的行为和信息,包括加载,释放等,这是一个单例,所有成员能够通过 `cc.assetManager` 调用 */ + export class AssetManager { + /** !#en + Normal loading pipeline + + !#zh + 正常加载管线 */ + pipeline: cc.AssetManager.Pipeline; + /** !#en + Fetching pipeline + + !#zh + 下载管线 */ + fetchPipeline: cc.AssetManager.Pipeline; + /** !#en + Url transformer + + !#zh + Url 转换器 */ + transformPipeline: cc.AssetManager.Pipeline; + /** !#en + The collection of bundle which is already loaded, you can remove cache with {{#crossLink "AssetManager/removeBundle:method"}}{{/crossLink}} + + !#zh + 已加载 bundle 的集合, 你能通过 {{#crossLink "AssetManager/removeBundle:method"}}{{/crossLink}} 来移除缓存 */ + bundles: AssetManager.Cache; + /** !#en + The collection of asset which is already loaded, you can remove cache with {{#crossLink "AssetManager/releaseAsset:method"}}{{/crossLink}} + + !#zh + 已加载资源的集合, 你能通过 {{#crossLink "AssetManager/releaseAsset:method"}}{{/crossLink}} 来移除缓存 */ + assets: AssetManager.Cache; + /** !#en + Manage relationship between asset and its dependencies + + !#zh + 管理资源依赖关系 */ + dependUtil: cc.AssetManager.DependUtil; + /** !#en + Whether or not cache the loaded asset + + !#zh + 是否缓存已加载的资源 */ + cacheAsset: boolean; + /** !#en + Whether or not load asset forcely, if it is true, asset will be loaded regardless of error + + !#zh + 是否强制加载资源, 如果为 true ,加载资源将会忽略报错 */ + force: boolean; + /** !#en + Some useful function + + !#zh + 一些有用的方法 */ + utils: cc.AssetManager.Helper; + /** !#en + Manage all downloading task + + !#zh + 管理所有下载任务 */ + downloader: cc.AssetManager.Downloader; + /** !#en + Manage all parsing task + + !#zh + 管理所有解析任务 */ + parser: cc.AssetManager.Parser; + /** !#en + Manage internal asset + + !#zh + 管理内置资源 */ + builtins: cc.AssetManager.Builtins; + /** !#en + Manage all packed asset + + !#zh + 管理所有合并后的资源 */ + packManager: cc.AssetManager.PackManager; + /** !#en + Cache manager is a module which controls all caches downloaded from server in non-web platform. + + !#zh + 缓存管理器是一个模块,在非 WEB 平台上,用于管理所有从服务器上下载下来的缓存 */ + cacheManager: cc.AssetManager.CacheManager|null; + /** !#en + The preset of options + + !#zh + 可选参数的预设集 */ + presets: Record>; + /** !#en + The builtin 'main' bundle + + !#zh + 内置 main 包 */ + main: cc.AssetManager.Bundle; + /** !#en + The builtin 'resources' bundle + + !#zh + 内置 resources 包 */ + resources: cc.AssetManager.Bundle; + /** !#en + The builtin 'internal' bundle + + !#zh + 内置 internal 包 */ + internal: cc.AssetManager.Bundle; + /** + !#en + Initialize assetManager with options + + !#zh + 初始化资源管理器 + @param options options + */ + init(options: Record): void; + /** + !#en + Get the bundle which has been loaded + + !#zh + 获取已加载的分包 + @param name The name of bundle + + @example + ```js + // ${project}/assets/test1 + cc.assetManager.getBundle('test1'); + + cc.assetManager.getBundle('resources'); + ``` + */ + getBundle (name: string): cc.AssetManager.Bundle; + /** + !#en + Remove this bundle. NOTE: The asset whthin this bundle will not be released automatically, you can call {{#crossLink "Bundle/releaseAll:method"}}{{/crossLink}} manually before remove it if you need + + !#zh + 移除此包, 注意:这个包内的资源不会自动释放, 如果需要的话你可以在摧毁之前手动调用 {{#crossLink "Bundle/releaseAll:method"}}{{/crossLink}} 进行释放 + @param bundle The bundle to be removed + */ + removeBundle(bundle: cc.AssetManager.Bundle): void; + /** + !#en + General interface used to load assets with a progression callback and a complete callback. You can achieve almost all effect you want with combination of `requests` and `options`. + It is highly recommended that you use more simple API, such as `load`, `loadDir` etc. Every custom parameter in `options` will be distribute to each of `requests`. + if request already has same one, the parameter in request will be given priority. Besides, if request has dependencies, `options` will distribute to dependencies too. + Every custom parameter in `requests` will be tranfered to handler of `downloader` and `parser` as `options`. + You can register you own handler downloader or parser to collect these custom parameters for some effect. + + Reserved Keyword: `uuid`, `url`, `path`, `dir`, `scene`, `type`, `priority`, `preset`, `audioLoadMode`, `ext`, `bundle`, `onFileProgress`, `maxConcurrency`, `maxRequestsPerFrame` + `maxRetryCount`, `version`, `responseType`, `withCredentials`, `mimeType`, `timeout`, `header`, `reload`, `cacheAsset`, `cacheEnabled`, + Please DO NOT use these words as custom options! + + !#zh + 通用加载资源接口,可传入进度回调以及完成回调,通过组合 `request` 和 `options` 参数,几乎可以实现和扩展所有想要的加载效果。非常建议你使用更简单的API,例如 `load`、`loadDir` 等。 + `options` 中的自定义参数将会分发到 `requests` 的每一项中,如果request中已存在同名的参数则以 `requests` 中为准,同时如果有其他 + 依赖资源,则 `options` 中的参数会继续向依赖项中分发。request中的自定义参数都会以 `options` 形式传入加载流程中的 `downloader`, `parser` 的方法中, 你可以 + 扩展 `downloader`, `parser` 收集参数完成想实现的效果。 + + 保留关键字: `uuid`, `url`, `path`, `dir`, `scene`, `type`, `priority`, `preset`, `audioLoadMode`, `ext`, `bundle`, `onFileProgress`, `maxConcurrency`, `maxRequestsPerFrame` + `maxRetryCount`, `version`, `responseType`, `withCredentials`, `mimeType`, `timeout`, `header`, `reload`, `cacheAsset`, `cacheEnabled`, + 请不要使用这些字段为自定义参数! + @param requests The request you want to load + @param options Optional parameters + @param onProgress Callback invoked when progression change + @param onComplete Callback invoked when finish loading + + @example + ```js + cc.assetManager.loadAny({url: 'http://example.com/a.png'}, (err, img) => cc.log(img)); + cc.assetManager.loadAny(['60sVXiTH1D/6Aft4MRt9VC'], (err, assets) => cc.log(assets)); + cc.assetManager.loadAny([{ uuid: '0cbZa5Y71CTZAccaIFluuZ'}, {url: 'http://example.com/a.png'}], (err, assets) => cc.log(assets)); + cc.assetManager.downloader.register('.asset', (url, options, onComplete) => { + url += '?userName=' + options.userName + "&password=" + options.password; + cc.assetManager.downloader.downloadFile(url, null, onComplete); + }); + cc.assetManager.parser.register('.asset', (file, options, onComplete) => { + var json = JSON.parse(file); + var skin = json[options.skin]; + var model = json[options.model]; + onComplete(null, {skin, model}); + }); + cc.assetManager.loadAny({ url: 'http://example.com/my.asset', skin: 'xxx', model: 'xxx', userName: 'xxx', password: 'xxx' }); + ``` + */ + loadAny(requests: string | string[] | Record | Record[], options: Record, onProgress: (finished: number, total: number, item: cc.AssetManager.RequestItem) => void, onComplete: (err: Error, data: any) => void): void; + loadAny(requests: string | string[] | Record | Record[], options: Record, onComplete: (err: Error, data: any) => void): void; + loadAny(requests: string | string[] | Record | Record[], options: Record): void; + loadAny(requests: string | string[] | Record | Record[], onProgress: (finished: number, total: number, item: cc.AssetManager.RequestItem) => void, onComplete: (err: Error, data: any) => void): void; + loadAny(requests: string | string[] | Record | Record[], onComplete: (err: Error, data: any) => void): void; + loadAny(requests: string | string[] | Record | Record[]): void; + /** + !#en + General interface used to preload assets with a progression callback and a complete callback.It is highly recommended that you use more simple API, such as `preloadRes`, `preloadResDir` etc. + Everything about preload is just likes `cc.assetManager.loadAny`, the difference is `cc.assetManager.preloadAny` will only download asset but not parse asset. You need to invoke `cc.assetManager.loadAny(preloadTask)` + to finish loading asset + + !#zh + 通用预加载资源接口,可传入进度回调以及完成回调,非常建议你使用更简单的 API ,例如 `preloadRes`, `preloadResDir` 等。`preloadAny` 和 `loadAny` 几乎一样,区别在于 `preloadAny` 只会下载资源,不会去解析资源,你需要调用 `cc.assetManager.loadAny(preloadTask)` + 来完成资源加载。 + @param requests The request you want to preload + @param options Optional parameters + @param onProgress Callback invoked when progression change + @param onComplete Callback invoked when finish preloading + + @example + ```js + cc.assetManager.preloadAny('0cbZa5Y71CTZAccaIFluuZ', (err) => cc.assetManager.loadAny('0cbZa5Y71CTZAccaIFluuZ')); + ``` + */ + preloadAny(requests: string | string[] | Record | Record[], options: Record, onProgress: (finished: number, total: number, item: cc.AssetManager.RequestItem) => void, onComplete: (err: Error, items: cc.AssetManager.RequestItem[]) => void): void; + preloadAny(requests: string | string[] | Record | Record[], options: Record, onComplete: (err: Error, items: cc.AssetManager.RequestItem[]) => void): void; + preloadAny(requests: string | string[] | Record | Record[], onProgress: (finished: number, total: number, item: cc.AssetManager.RequestItem) => void, onComplete: (err: Error, items: cc.AssetManager.RequestItem[]) => void): void; + preloadAny(requests: string | string[] | Record | Record[], onComplete: (err: Error, items: cc.AssetManager.RequestItem[]) => void): void; + preloadAny(requests: string | string[] | Record | Record[], options: Record): void; + preloadAny(requests: string | string[] | Record | Record[]): void; + /** + !#en + Load native file of asset, if you check the option 'Async Load Assets', you may need to load native file with this before you use the asset + + !#zh + 加载资源的原生文件,如果你勾选了'延迟加载资源'选项,你可能需要在使用资源之前调用此方法来加载原生文件 + @param asset The asset + @param options Some optional parameters + @param onComplete Callback invoked when finish loading + + @example + ```js + cc.assetManager.postLoadNative(texture, (err) => console.log(err)); + ``` + */ + postLoadNative(asset: cc.Asset, options: Record, onComplete: (err: Error) => void): void; + postLoadNative(asset: cc.Asset, options: Record): void; + postLoadNative(asset: cc.Asset, onComplete: (err: Error) => void): void; + postLoadNative(asset: cc.Asset): void; + /** + !#en + Load remote asset with url, such as audio, image, text and so on. + + !#zh + 使用 url 加载远程资源,例如音频,图片,文本等等。 + @param url The url of asset + @param options Some optional parameters + @param onComplete Callback invoked when finish loading + + @example + ```js + cc.assetManager.loadRemote('http://www.cloud.com/test1.jpg', (err, texture) => console.log(err)); + cc.assetManager.loadRemote('http://www.cloud.com/test2.mp3', (err, audioClip) => console.log(err)); + ``` + */ + loadRemote(url: string, options: Record, onComplete: (err: Error, asset: T) => void): void; + loadRemote(url: string, options: Record): void; + loadRemote(url: string, onComplete: (err: Error, asset: T) => void): void; + loadRemote(url: string): void; + /** + !#en + Load script + + !#zh + 加载脚本 + @param url Url of the script + @param options Some optional paramters + @param onComplete Callback when script loaded or failed + + @example + ```js + loadScript('http://localhost:8080/index.js', null, (err) => console.log(err)); + ``` + */ + loadScript(url: string|string[], options: Record, onComplete: (err: Error) => void): void;; + loadScript(url: string|string[], options: Record): void;; + loadScript(url: string|string[], onComplete: (err: Error) => void): void;; + loadScript(url: string|string[]): void;; + /** + !#en + load bundle + + !#zh + 加载资源包 + @param nameOrUrl The name or root path of bundle + @param options Some optional paramter, same like downloader.downloadFile + @param onComplete Callback when bundle loaded or failed + + @example + ```js + loadBundle('http://localhost:8080/test', null, (err, bundle) => console.log(err)); + ``` + */ + loadBundle(nameOrUrl: string, options: Record, onComplete: (err: Error, bundle: cc.AssetManager.Bundle) => void): void; + loadBundle(nameOrUrl: string, options: Record): void; + loadBundle(nameOrUrl: string, onComplete: (err: Error, bundle: cc.AssetManager.Bundle) => void): void; + loadBundle(nameOrUrl: string): void; + /** + !#en + Release asset and it's dependencies. + This method will not only remove the cache of the asset in assetManager, but also clean up its content. + For example, if you release a texture, the texture asset and its gl texture data will be freed up. + Notice, this method may cause the texture to be unusable, if there are still other nodes use the same texture, they may turn to black and report gl errors. + + !#zh + 释放资源以及其依赖资源, 这个方法不仅会从 assetManager 中删除资源的缓存引用,还会清理它的资源内容。 + 比如说,当你释放一个 texture 资源,这个 texture 和它的 gl 贴图数据都会被释放。 + 注意,这个函数可能会导致资源贴图或资源所依赖的贴图不可用,如果场景中存在节点仍然依赖同样的贴图,它们可能会变黑并报 GL 错误。 + @param asset The asset to be released + + @example + ```js + // release a texture which is no longer need + cc.assetManager.releaseAsset(texture); + ``` + */ + releaseAsset(asset: cc.Asset): void; + /** + !#en + Release all assets. Refer to {{#crossLink "AssetManager/releaseAsset:method"}}{{/crossLink}} for detailed informations. + + !#zh + 释放所有资源。详细信息请参考 {{#crossLink "AssetManager/releaseAsset:method"}}{{/crossLink}} + */ + releaseAll(): void; + } + /** `cc.loader` is deprecated, please backup your project and upgrade to {{#crossLink "AssetManager"}}{{/crossLink}} */ + export class loader { + /** `cc.loader.onProgress` is deprecated, please transfer onProgress to API as a parameter */ + static onProgress: any; + /** + `cc.loader.load` is deprecated, please use {{#crossLink "AssetManager/loadAny:method"}}{{/crossLink}} instead + @param resources Url list in an array + @param progressCallback Callback invoked when progression change + @param completeCallback Callback invoked when all resources loaded + */ + static load(resources: string|string[]|{uuid?: string, url?: string, type?: string}, completeCallback?: Function): void; + static load(resources: string|string[]|{uuid?: string, url?: string, type?: string}, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: Function|null): void; + /** + `cc.loader.getXMLHttpRequest` is deprecated, please use `XMLHttpRequest` directly + */ + static getXMLHttpRequest(): XMLHttpRequest; + /** + `cc.loader.getItem` is deprecated, please use `cc.assetManager.asset.get` instead + @param id The id of the item + */ + static getItem(id: any): any; + /** + `cc.loader.loadRes` is deprecated, please use {{#crossLink "Bundle/load:method"}}{{/crossLink}} instead + @param url Url of the target resource. + The url is relative to the "resources" folder, extensions must be omitted. + @param type Only asset of type will be loaded if this argument is supplied. + @param progressCallback Callback invoked when progression change. + @param completeCallback Callback invoked when the resource loaded. + */ + static loadRes(url: string, type: typeof cc.Asset, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any) => void)|null): void; + static loadRes(url: string, type: typeof cc.Asset, completeCallback: (error: Error, resource: any) => void): void; + static loadRes(url: string, type: typeof cc.Asset): void; + static loadRes(url: string, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any) => void)|null): void; + static loadRes(url: string, completeCallback: (error: Error, resource: any) => void): void; + static loadRes(url: string): void; + /** + `cc.loader.loadResArray` is deprecated, please use {{#crossLink "Bundle/load:method"}}{{/crossLink}} instead + @param urls Array of URLs of the target resource. + The url is relative to the "resources" folder, extensions must be omitted. + @param type Only asset of type will be loaded if this argument is supplied. + @param progressCallback Callback invoked when progression change. + @param completeCallback A callback which is called when all assets have been loaded, or an error occurs. + */ + static loadResArray(url: string[], type: typeof cc.Asset, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any[]) => void)|null): void; + static loadResArray(url: string[], type: typeof cc.Asset, completeCallback: (error: Error, resource: any[]) => void): void; + static loadResArray(url: string[], type: typeof cc.Asset): void; + static loadResArray(url: string[], progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any[]) => void)|null): void; + static loadResArray(url: string[], completeCallback: (error: Error, resource: any[]) => void): void; + static loadResArray(url: string[]): void; + static loadResArray(url: string[], type: typeof cc.Asset[]): void; + /** + `cc.loader.loadResDir` is deprecated, please use {{#crossLink "Bundle/loadDir:method"}}{{/crossLink}} instead + @param url Url of the target folder. + The url is relative to the "resources" folder, extensions must be omitted. + @param type Only asset of type will be loaded if this argument is supplied. + @param progressCallback Callback invoked when progression change. + @param completeCallback A callback which is called when all assets have been loaded, or an error occurs. + */ + static loadResDir(url: string, type: typeof cc.Asset, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any[], urls: string[]) => void)|null): void; + static loadResDir(url: string, type: typeof cc.Asset, completeCallback: (error: Error, resource: any[], urls: string[]) => void): void; + static loadResDir(url: string, type: typeof cc.Asset): void; + static loadResDir(url: string, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any[], urls: string[]) => void)|null): void; + static loadResDir(url: string, completeCallback: (error: Error, resource: any[], urls: string[]) => void): void; + static loadResDir(url: string): void; + /** + `cc.loader.getRes` is deprecated, please use {{#crossLink "Bundle/get:method"}}{{/crossLink}} instead + @param url url + @param type Only asset of type will be returned if this argument is supplied. + */ + static getRes(url: string, type?: Function): any; + /** + `cc.loader.getDependsRecursively` is deprecated, please use use {{#crossLink "DependUtil/getDepsRecursively:method"}}{{/crossLink}} instead + @param owner The owner asset or the resource url or the asset's uuid + */ + static getDependsRecursively(owner: Asset|string): any[]; + /** `cc.loader.assetLoader` was removed, assetLoader and md5Pipe were merged into {{#crossLink "AssetManager/transformPipeline:property"}}{{/crossLink}} */ + static assetLoader: any; + /** `cc.loader.md5Pipe` is deprecated, assetLoader and md5Pipe were merged into {{#crossLink "AssetManager/transformPipeline:property"}}{{/crossLink}} */ + static md5Pipe: any; + /** `cc.loader.downloader` is deprecated, please use {{#crossLink "AssetManager/downloader:property"}}{{/crossLink}} instead */ + static downloader: any; + /** `cc.loader.loader` is deprecated, please use {{#crossLink "AssetManager/parser:property"}}{{/crossLink}} instead */ + static loader: any; + /** + `cc.loader.addDownloadHandlers` is deprecated, please use `cc.assetManager.downloader.register` instead + @param extMap Custom supported types with corresponded handler + */ + static addDownloadHandlers(extMap: any): void; + /** + `cc.loader.addLoadHandlers` is deprecated, please use `cc.assetManager.parser.register` instead + @param extMap Custom supported types with corresponded handler + */ + static addLoadHandlers(extMap: any): void; + /** + `cc.loader.release` is deprecated, please use {{#crossLink "AssetManager/releaseAsset:method"}}{{/crossLink}} instead + @param asset asset + */ + static release(asset: Asset|string|any[]): void; + /** + `cc.loader.releaseAsset` is deprecated, please use {{#crossLink "AssetManager/releaseAsset:method"}}{{/crossLink}} instead + @param asset asset + */ + static releaseAsset(asset: Asset): void; + /** + `cc.loader.releaseRes` is deprecated, please use {{#crossLink "AssetManager/releaseRes:method"}}{{/crossLink}} instead + @param url url + @param type Only asset of type will be released if this argument is supplied. + */ + static releaseRes(url: string, type?: Function): void; + /** + `cc.loader.releaseResDir` was removed, please use {{#crossLink "AssetManager/releaseRes:method"}}{{/crossLink}} instead + */ + static releaseResDir(): void; + /** + `cc.loader.releaseAll` is deprecated, please use {{#crossLink "AssetManager/releaseAll:method"}}{{/crossLink}} instead + */ + static releaseAll(): void; + /** + `cc.loader.removeItem` is deprecated, please use `cc.assetManager.assets.remove` instead + @param id The id of the item + */ + static removeItem(id: any): boolean; + /** + `cc.loader.setAutoRelease` is deprecated, if you want to prevent some asset from auto releasing, please use {{#crossLink "Asset/addRef:method"}}{{/crossLink}} instead + @param assetOrUrlOrUuid asset object or the raw asset's url or uuid + @param autoRelease indicates whether should release automatically + */ + static setAutoRelease(assetOrUrlOrUuid: Asset|string, autoRelease: boolean): void; + /** + `cc.loader.setAutoReleaseRecursively` is deprecated, if you want to prevent some asset from auto releasing, please use {{#crossLink "Asset/addRef:method"}}{{/crossLink}} instead + @param assetOrUrlOrUuid asset object or the raw asset's url or uuid + @param autoRelease indicates whether should release automatically + */ + static setAutoReleaseRecursively(assetOrUrlOrUuid: Asset|string, autoRelease: boolean): void; + /** + `cc.loader.isAutoRelease` is deprecated + @param assetOrUrl asset object or the raw asset's url + */ + static isAutoRelease(assetOrUrl: Asset|string): boolean; + } + /** `cc.url` is deprecated */ + export class url { + /** + `cc.url.raw` is deprecated, please use `cc.resources.load` directly, or use `Asset.nativeUrl` instead. + @param url url + */ + static raw(url: string): string; + } + /** `cc.LoadingItems` was removed, please use {{#crossLink "Task"}}{{/crossLink}} instead */ + export class LoadingItems { + } + /** !#en + Base class for handling assets used in Creator.
+ + You may want to override:
+ - createNode
+ - getset functions of _nativeAsset
+ - cc.Object._serialize
+ - cc.Object._deserialize
+ !#zh + Creator 中的资源基类。
+ + 您可能需要重写:
+ - createNode
+ - _nativeAsset 的 getset 方法
+ - cc.Object._serialize
+ - cc.Object._deserialize
*/ + export class Asset extends Object { + /** `cc.Asset.url` is deprecated, please use {{#crossLink "Asset/nativeUrl:property"}}{{/crossLink}} instead */ + url: string; + /** !#en + Whether the asset is loaded or not. + !#zh + 该资源是否已经成功加载。 */ + loaded: boolean; + /** !#en + Returns the url of this asset's native object, if none it will returns an empty string. + !#zh + 返回该资源对应的目标平台资源的 URL,如果没有将返回一个空字符串。 */ + nativeUrl: string; + /** !#en + The number of reference + + !#zh + 引用的数量 */ + refCount: number; + /** !#en Indicates whether its dependent raw assets can support deferred load if the owner scene (or prefab) is marked as `asyncLoadAssets`. + !#zh 当场景或 Prefab 被标记为 `asyncLoadAssets`,禁止延迟加载该资源所依赖的其它原始资源。 */ + static preventDeferredLoadDependents: boolean; + /** !#en Indicates whether its native object should be preloaded from native url. + !#zh 禁止预加载原生对象。 */ + static preventPreloadNativeObject: boolean; + /** + !#en + Returns the asset's url. + + The `Asset` object overrides the `toString()` method of the `Object` object. + For `Asset` objects, the `toString()` method returns a string representation of the object. + JavaScript calls the `toString()` method automatically when an asset is to be represented as a text value or when a texture is referred to in a string concatenation. + !#zh + 返回资源的 URL。 + + Asset 对象将会重写 Object 对象的 `toString()` 方法。 + 对于 Asset 对象,`toString()` 方法返回该对象的字符串表示形式。 + 当资源要表示为文本值时或在字符串连接时引用时,JavaScript 会自动调用 `toString()` 方法。 + */ + toString(): string; + /** + !#en + Create a new node using this asset in the scene.
+ If this type of asset dont have its corresponding node type, this method should be null. + !#zh + 使用该资源在场景中创建一个新节点。
+ 如果这类资源没有相应的节点类型,该方法应该是空的。 + @param callback callback + */ + createNode(callback: (error: string, node: any) => void): void; + /** + !#en + Add references of asset + + !#zh + 增加资源的引用 + */ + addRef(): cc.Asset; + /** + !#en + Reduce references of asset and it will be auto released when refCount equals 0. + + !#zh + 减少资源的引用并尝试进行自动释放。 + */ + decRef(): cc.Asset; + } + /** Predefined constants */ + export class macro { + /** `cc.macro.DOWNLOAD_MAX_CONCURRENT` is deprecated now, please use {{#crossLink "Downloader/maxConcurrency:property"}}{{/crossLink}} instead */ + static DOWNLOAD_MAX_CONCURRENT: number; + /** PI / 180 */ + static RAD: number; + /** One degree */ + static DEG: number; + static REPEAT_FOREVER: number; + static FLT_EPSILON: number; + /** Minimum z index value for node */ + static MIN_ZINDEX: number; + /** Maximum z index value for node */ + static MAX_ZINDEX: number; + static ONE: number; + static ZERO: number; + static SRC_ALPHA: number; + static SRC_ALPHA_SATURATE: number; + static SRC_COLOR: number; + static DST_ALPHA: number; + static DST_COLOR: number; + static ONE_MINUS_SRC_ALPHA: number; + static ONE_MINUS_SRC_COLOR: number; + static ONE_MINUS_DST_ALPHA: number; + static ONE_MINUS_DST_COLOR: number; + static ONE_MINUS_CONSTANT_ALPHA: number; + static ONE_MINUS_CONSTANT_COLOR: number; + /** Oriented vertically */ + static ORIENTATION_PORTRAIT: number; + /** Oriented horizontally */ + static ORIENTATION_LANDSCAPE: number; + /** Oriented automatically */ + static ORIENTATION_AUTO: number; + /**

+ If enabled, the texture coordinates will be calculated by using this formula:
+ - texCoord.left = (rect.x*2+1) / (texture.wide*2);
+ - texCoord.right = texCoord.left + (rect.width*2-2)/(texture.wide*2);
+
+ The same for bottom and top.
+
+ This formula prevents artifacts by using 99% of the texture.
+ The "correct" way to prevent artifacts is by expand the texture's border with the same color by 1 pixel
+
+ Affected component:
+ - cc.TMXLayer
+
+ Enabled by default. To disabled set it to 0.
+ To modify it, in Web engine please refer to CCMacro.js, in JSB please refer to CCConfig.h +

*/ + static FIX_ARTIFACTS_BY_STRECHING_TEXEL_TMX: number; + /** Position of the FPS (Default: 0,0 (bottom-left corner))
+ To modify it, in Web engine please refer to CCMacro.js, in JSB please refer to CCConfig.h */ + static DIRECTOR_STATS_POSITION: Vec2; + /**

+ If enabled, actions that alter the position property (eg: CCMoveBy, CCJumpBy, CCBezierBy, etc..) will be stacked.
+ If you run 2 or more 'position' actions at the same time on a node, then end position will be the sum of all the positions.
+ If disabled, only the last run action will take effect. +

*/ + static ENABLE_STACKABLE_ACTIONS: number; + /** !#en + The timeout to determine whether a touch is no longer active and should be removed. + The reason to add this timeout is due to an issue in X5 browser core, + when X5 is presented in wechat on Android, if a touch is glissed from the bottom up, and leave the page area, + no touch cancel event is triggered, and the touch will be considered active forever. + After multiple times of this action, our maximum touches number will be reached and all new touches will be ignored. + So this new mechanism can remove the touch that should be inactive if it's not updated during the last 5000 milliseconds. + Though it might remove a real touch if it's just not moving for the last 5 seconds which is not easy with the sensibility of mobile touch screen. + You can modify this value to have a better behavior if you find it's not enough. + !#zh + 用于甄别一个触点对象是否已经失效并且可以被移除的延时时长 + 添加这个时长的原因是 X5 内核在微信浏览器中出现的一个 bug。 + 在这个环境下,如果用户将一个触点从底向上移出页面区域,将不会触发任何 touch cancel 或 touch end 事件,而这个触点会被永远当作停留在页面上的有效触点。 + 重复这样操作几次之后,屏幕上的触点数量将达到我们的事件系统所支持的最高触点数量,之后所有的触摸事件都将被忽略。 + 所以这个新的机制可以在触点在一定时间内没有任何更新的情况下视为失效触点并从事件系统中移除。 + 当然,这也可能移除一个真实的触点,如果用户的触点真的在一定时间段内完全没有移动(这在当前手机屏幕的灵敏度下会很难)。 + 你可以修改这个值来获得你需要的效果,默认值是 5000 毫秒。 */ + static TOUCH_TIMEOUT: number; + /** !#en + The maximum vertex count for a single batched draw call. + !#zh + 最大可以被单次批处理渲染的顶点数量。 */ + static BATCH_VERTEX_COUNT: number; + /** !#en + Whether or not enabled tiled map auto culling. If you set the TiledMap skew or rotation, then need to manually disable this, otherwise, the rendering will be wrong. + !#zh + 是否开启瓦片地图的自动裁减功能。瓦片地图如果设置了 skew, rotation 或者采用了摄像机的话,需要手动关闭,否则渲染会出错。 */ + static ENABLE_TILEDMAP_CULLING: boolean; + /** !#en + Boolean that indicates if the canvas contains an alpha channel, default sets to false for better performance. + Though if you want to make your canvas background transparent and show other dom elements at the background, + you can set it to true before `cc.game.run`. + Web only. + !#zh + 用于设置 Canvas 背景是否支持 alpha 通道,默认为 false,这样可以有更高的性能表现。 + 如果你希望 Canvas 背景是透明的,并显示背后的其他 DOM 元素,你可以在 `cc.game.run` 之前将这个值设为 true。 + 仅支持 Web */ + static ENABLE_TRANSPARENT_CANVAS: boolean; + /** !#en + Boolean that indicates if the WebGL context is created with `antialias` option turned on, default value is false. + Set it to true could make your game graphics slightly smoother, like texture hard edges when rotated. + Whether to use this really depend on your game design and targeted platform, + device with retina display usually have good detail on graphics with or without this option, + you probably don't want antialias if your game style is pixel art based. + Also, it could have great performance impact with some browser / device using software MSAA. + You can set it to true before `cc.game.run`. + Web only. + !#zh + 用于设置在创建 WebGL Context 时是否开启抗锯齿选项,默认值是 false。 + 将这个选项设置为 true 会让你的游戏画面稍稍平滑一些,比如旋转硬边贴图时的锯齿。是否开启这个选项很大程度上取决于你的游戏和面向的平台。 + 在大多数拥有 retina 级别屏幕的设备上用户往往无法区分这个选项带来的变化;如果你的游戏选择像素艺术风格,你也多半不会想开启这个选项。 + 同时,在少部分使用软件级别抗锯齿算法的设备或浏览器上,这个选项会对性能产生比较大的影响。 + 你可以在 `cc.game.run` 之前设置这个值,否则它不会生效。 + 仅支持 Web */ + static ENABLE_WEBGL_ANTIALIAS: boolean; + /** !#en + Whether or not enable auto culling. + This feature have been removed in v2.0 new renderer due to overall performance consumption. + We have no plan currently to re-enable auto culling. + If your game have more dynamic objects, we suggest to disable auto culling. + If your game have more static objects, we suggest to enable auto culling. + !#zh + 是否开启自动裁减功能,开启裁减功能将会把在屏幕外的物体从渲染队列中去除掉。 + 这个功能在 v2.0 的新渲染器中被移除了,因为它在大多数游戏中所带来的损耗要高于性能的提升,目前我们没有计划重新支持自动裁剪。 + 如果游戏中的动态物体比较多的话,建议将此选项关闭。 + 如果游戏中的静态物体比较多的话,建议将此选项打开。 */ + static ENABLE_CULLING: boolean; + /** !#en + Whether to clear the original image cache after uploaded a texture to GPU. If cleared, [Dynamic Atlas](https://docs.cocos.com/creator/manual/en/advanced-topics/dynamic-atlas.html) will not be supported. + Normally you don't need to enable this option on the web platform, because Image object doesn't consume too much memory. + But on WeChat Game platform, the current version cache decoded data in Image object, which has high memory usage. + So we enabled this option by default on WeChat, so that we can release Image cache immediately after uploaded to GPU. + !#zh + 是否在将贴图上传至 GPU 之后删除原始图片缓存,删除之后图片将无法进行 [动态合图](https://docs.cocos.com/creator/manual/zh/advanced-topics/dynamic-atlas.html)。 + 在 Web 平台,你通常不需要开启这个选项,因为在 Web 平台 Image 对象所占用的内存很小。 + 但是在微信小游戏平台的当前版本,Image 对象会缓存解码后的图片数据,它所占用的内存空间很大。 + 所以我们在微信平台默认开启了这个选项,这样我们就可以在上传 GL 贴图之后立即释放 Image 对象的内存,避免过高的内存占用。 */ + static CLEANUP_IMAGE_CACHE: boolean; + /** !#en + Whether or not show mesh wire frame. + !#zh + 是否显示网格的线框。 */ + static SHOW_MESH_WIREFRAME: boolean; + /** !#en + Whether or not show mesh normal. + !#zh + 是否显示网格的法线。 */ + static SHOW_MESH_NORMAL: boolean; + /** !#en + Whether to enable multi-touch. + !#zh + 是否开启多点触摸 */ + static ENABLE_MULTI_TOUCH: boolean; + /** References: + https://developer.mozilla.org/en-US/docs/Web/API/ImageBitmap + https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/createImageBitmap + + !#en + Whether to use image bitmap first. + + !#zh + 是否优先使用 image bitmap */ + static ALLOW_IMAGE_BITMAP: boolean; + /** !#en + The image format supported by the engine defaults, and the supported formats may differ in different build platforms and device types. + Currently all platform and device support ['.webp', '.jpg', '.jpeg', '.bmp', '.png'], The iOS mobile platform also supports the PVR format。 + !#zh + 引擎默认支持的图片格式,支持的格式可能在不同的构建平台和设备类型上有所差别。 + 目前所有平台和设备支持的格式有 ['.webp', '.jpg', '.jpeg', '.bmp', '.png']. 另外 Ios 手机平台还额外支持了 PVR 格式。 */ + static SUPPORT_TEXTURE_FORMATS: string[]; + } + /** !#en Box Collider. + !#zh 包围盒碰撞组件 */ + export class BoxCollider extends Collider implements Collider.Box { + /** !#en + Collider info in world coordinate. + !#zh + 碰撞体的世界坐标系下的信息。 */ + world: ColliderInfo; + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Box size + !#zh 包围盒大小 */ + size: Size; + } + /** !#en Circle Collider. + !#zh 圆形碰撞组件 */ + export class CircleCollider extends Collider implements Collider.Circle { + /** !#en + Collider info in world coordinate. + !#zh + 碰撞体的世界坐标系下的信息。 */ + world: ColliderInfo; + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Circle radius + !#zh 圆形半径 */ + radius: number; + } + /** !#en Collider component base class. + !#zh 碰撞组件基类 */ + export class Collider extends Component { + /** !#en Tag. If a node has several collider components, you can judge which type of collider is collided according to the tag. + !#zh 标签。当一个节点上有多个碰撞组件时,在发生碰撞后,可以使用此标签来判断是节点上的哪个碰撞组件被碰撞了。 */ + tag: number; + } + /** !#en + Collider Info. + !#zh + 碰撞体信息。 */ + export class ColliderInfo { + /** !#en + Collider aabb information of last frame + !#zh + 碰撞体上一帧的 aabb 信息 */ + preAabb: Rect; + /** !#en + Collider aabb information of current frame + !#zh + 碰撞体当前帧的 aabb 信息 */ + aabb: Rect; + /** !#en + Collider matrix + !#zh + 碰撞体的矩阵信息 */ + matrix: Mat4; + /** !#en + Collider radius (for CircleCollider) + !#zh + 碰撞体的半径(只对 CircleCollider 有效) */ + radius: number; + /** !#en + Collider position (for CircleCollider) + !#zh + 碰撞体的位置(只对 CircleCollider 有效) */ + position: Vec2; + /** !#en + Collider points (for BoxCollider and PolygonCollider) + !#zh + 碰撞体的顶点信息(只对 BoxCollider 和 PolygonCollider 有效) */ + points: Vec2[]; + } + /** !#en + A simple collision manager class. + It will calculate whether the collider collides other colliders, if collides then call the callbacks. + !#zh + 一个简单的碰撞组件管理类,用于处理节点之间的碰撞组件是否产生了碰撞,并调用相应回调函数。 */ + export class CollisionManager implements EventTarget { + /** !#en + !#zh + 是否开启碰撞管理,默认为不开启 */ + enabled: boolean; + /** !#en + !#zh + 是否绘制碰撞组件的包围盒,默认为不绘制 */ + enabledDrawBoundingBox: boolean; + /** !#en + !#zh + 是否绘制碰撞组件的形状,默认为不绘制 */ + enabledDebugDraw: boolean; + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en + Register an callback of a specific event type on the EventTarget. + This type of event should be triggered via `emit`. + !#zh + 注册事件目标的特定事件类型回调。这种类型的事件应该被 `emit` 触发。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, node); + ``` + */ + on(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. + !#zh + 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + + @example + ```js + // register fire eventListener + var callback = eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, target); + // remove fire event listener + eventTarget.off('fire', callback, target); + // remove all fire event listeners + eventTarget.off('fire'); + ``` + */ + off(type: string, callback?: Function, target?: any): void; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.once('fire', function () { + cc.log("this is the callback and will be invoked only once"); + }, node); + ``` + */ + once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; + /** + !#en + Send an event with the event object. + !#zh + 通过事件对象派发事件 + @param event event + */ + dispatchEvent(event: Event): void; + } + /** !#en Intersection helper class + !#zh 辅助类,用于测试形状与形状是否相交 */ + export class Intersection { + /** + !#en Test line and line + !#zh 测试线段与线段是否相交 + @param a1 The start point of the first line + @param a2 The end point of the first line + @param b1 The start point of the second line + @param b2 The end point of the second line + */ + static lineLine(a1: Vec2, a2: Vec2, b1: Vec2, b2: Vec2): boolean; + /** + !#en Test line and rect + !#zh 测试线段与矩形是否相交 + @param a1 The start point of the line + @param a2 The end point of the line + @param b The rect + */ + static lineRect(a1: Vec2, a2: Vec2, b: Rect): boolean; + /** + !#en Test line and polygon + !#zh 测试线段与多边形是否相交 + @param a1 The start point of the line + @param a2 The end point of the line + @param b The polygon, a set of points + */ + static linePolygon(a1: Vec2, a2: Vec2, b: Vec2[]): boolean; + /** + !#en Test rect and rect + !#zh 测试矩形与矩形是否相交 + @param a The first rect + @param b The second rect + */ + static rectRect(a: Rect, b: Rect): boolean; + /** + !#en Test rect and polygon + !#zh 测试矩形与多边形是否相交 + @param a The rect + @param b The polygon, a set of points + */ + static rectPolygon(a: Rect, b: Vec2[]): boolean; + /** + !#en Test polygon and polygon + !#zh 测试多边形与多边形是否相交 + @param a The first polygon, a set of points + @param b The second polygon, a set of points + */ + static polygonPolygon(a: Vec2[], b: Vec2[]): boolean; + /** + !#en Test circle and circle + !#zh 测试圆形与圆形是否相交 + @param a Object contains position and radius + @param b Object contains position and radius + */ + static circleCircle(a: {position: Vec2, radius: number}, b: {position: Vec2, radius: number}): boolean; + /** + !#en Test polygon and circle + !#zh 测试矩形与圆形是否相交 + @param polygon The Polygon, a set of points + @param circle Object contains position and radius + */ + static polygonCircle(polygon: Vec2[], circle: {position: Vec2, radius: number}): boolean; + /** + !#en Test whether the point is in the polygon + !#zh 测试一个点是否在一个多边形中 + @param point The point + @param polygon The polygon, a set of points + */ + static pointInPolygon(point: Vec2, polygon: Vec2[]): boolean; + /** + !#en Calculate the distance of point to line. + !#zh 计算点到直线的距离。如果这是一条线段并且垂足不在线段内,则会计算点到线段端点的距离。 + @param point The point + @param start The start point of line + @param end The end point of line + @param isSegment whether this line is a segment + */ + static pointLineDistance(point: Vec2, start: Vec2, end: Vec2, isSegment: boolean): number; + } + /** !#en Polygon Collider. + !#zh 多边形碰撞组件 */ + export class PolygonCollider extends Collider implements Collider.Polygon { + /** !#en + Collider info in world coordinate. + !#zh + 碰撞体的世界坐标系下的信息。 */ + world: ColliderInfo; + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Polygon points + !#zh 多边形顶点数组 */ + points: Vec2[]; + } + /** !#en Class for audio data handling. + !#zh 音频资源类。 */ + export class AudioClip extends Asset implements EventTarget { + /** !#en Get the audio clip duration + !#zh 获取音频剪辑的长度 */ + duration: number; + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en + Register an callback of a specific event type on the EventTarget. + This type of event should be triggered via `emit`. + !#zh + 注册事件目标的特定事件类型回调。这种类型的事件应该被 `emit` 触发。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, node); + ``` + */ + on(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. + !#zh + 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + + @example + ```js + // register fire eventListener + var callback = eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, target); + // remove fire event listener + eventTarget.off('fire', callback, target); + // remove all fire event listeners + eventTarget.off('fire'); + ``` + */ + off(type: string, callback?: Function, target?: any): void; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.once('fire', function () { + cc.log("this is the callback and will be invoked only once"); + }, node); + ``` + */ + once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; + /** + !#en + Send an event with the event object. + !#zh + 通过事件对象派发事件 + @param event event + */ + dispatchEvent(event: Event): void; + } + /** !#en Class for BitmapFont handling. + !#zh 位图字体资源类。 */ + export class BitmapFont extends Font { + } + /** undefined */ + export class BufferAsset extends Asset { + } + /** !#en Class for Font handling. + !#zh 字体资源类。 */ + export class Font extends Asset { + } + /** !#en + Class for JSON file. When the JSON file is loaded, this object is returned. + The parsed JSON object can be accessed through the `json` attribute in it.
+ If you want to get the original JSON text, you should modify the extname to `.txt` + so that it is loaded as a `TextAsset` instead of a `JsonAsset`. + + !#zh + JSON 资源类。JSON 文件加载后,将会返回该对象。可以通过其中的 `json` 属性访问解析后的 JSON 对象。
+ 如果你想要获得 JSON 的原始文本,那么应该修改源文件的后缀为 `.txt`,这样就会加载为一个 `TextAsset` 而不是 `JsonAsset`。 */ + export class JsonAsset extends Asset { + /** The loaded JSON object. */ + json: any; + } + /** !#en Class for LabelAtlas handling. + !#zh 艺术数字字体资源类。 */ + export class LabelAtlas extends BitmapFont { + } + /** !#en Class for prefab handling. + !#zh 预制资源类。 */ + export class Prefab extends Asset { + /** the main cc.Node in the prefab */ + data: Node; + /** !#zh + 设置实例化这个 prefab 时所用的优化策略。根据使用情况设置为合适的值,能优化该 prefab 实例化所用的时间。 + !#en + Indicates the optimization policy for instantiating this prefab. + Set to a suitable value based on usage, can optimize the time it takes to instantiate this prefab. */ + optimizationPolicy: Prefab.OptimizationPolicy; + /** !#en Indicates the raw assets of this prefab can be load after prefab loaded. + !#zh 指示该 Prefab 依赖的资源可否在 Prefab 加载后再延迟加载。 */ + asyncLoadAssets: boolean; + readonly: boolean; + /** + Dynamically translation prefab data into minimized code.
+ This method will be called automatically before the first time the prefab being instantiated, + but you can re-call to refresh the create function once you modified the original prefab data in script. + */ + compileCreateFunction(): void; + } + /** Render textures are textures that can be rendered to. */ + export class RenderTexture extends Texture2D { + /** + !#en + Init the render texture with size. + !#zh + 初始化 render texture + @param width width + @param height height + @param depthStencilFormat depthStencilFormat + */ + initWithSize(width?: number, height?: number, depthStencilFormat?: number): void; + /** + !#en + Get pixels from render texture, the pixels data stores in a RGBA Uint8Array. + It will return a new (width * height * 4) length Uint8Array by default。 + You can specify a data to store the pixels to reuse the data, + you and can specify other params to specify the texture region to read. + !#zh + 从 render texture 读取像素数据,数据类型为 RGBA 格式的 Uint8Array 数组。 + 默认每次调用此函数会生成一个大小为 (长 x 高 x 4) 的 Uint8Array。 + 你可以通过传入 data 来接收像素数据,也可以通过传参来指定需要读取的区域的像素。 + @param data data + @param x x + @param y y + @param w w + @param h h + */ + readPixels(data?: Uint8Array, x?: number, y?: number, w?: number, h?: number): Uint8Array; + } + /** !#en Class for scene handling. + !#zh 场景资源类。 */ + export class SceneAsset extends Asset { + scene: Scene; + /** !#en Indicates the raw assets of this scene can be load after scene launched. + !#zh 指示该场景依赖的资源可否在场景切换后再延迟加载。 */ + asyncLoadAssets: boolean; + } + /** !#en Class for script handling. + !#zh Script 资源类。 */ + export class _Script extends Asset { + } + /** !#en Class for JavaScript handling. + !#zh JavaScript 资源类。 */ + export class _JavaScript extends Asset { + } + /** !#en Class for TypeScript handling. + !#zh TypeScript 资源类。 */ + export class TypeScript extends Asset { + } + /** !#en Class for sprite atlas handling. + !#zh 精灵图集资源类。 */ + export class SpriteAtlas extends Asset { + /** + Returns the texture of the sprite atlas + */ + getTexture(): Texture2D; + /** + Returns the sprite frame correspond to the given key in sprite atlas. + @param key key + */ + getSpriteFrame(key: string): SpriteFrame; + /** + Returns the sprite frames in sprite atlas. + */ + getSpriteFrames(): SpriteFrame[]; + } + /** !#en + A cc.SpriteFrame has:
+ - texture: A cc.Texture2D that will be used by render components
+ - rectangle: A rectangle of the texture + + !#zh + 一个 SpriteFrame 包含:
+ - 纹理:会被渲染组件使用的 Texture2D 对象。
+ - 矩形:在纹理中的矩形区域。 */ + export class SpriteFrame extends Asset implements EventTarget { + /** !#en Top border of the sprite + !#zh sprite 的顶部边框 */ + insetTop: number; + /** !#en Bottom border of the sprite + !#zh sprite 的底部边框 */ + insetBottom: number; + /** !#en Left border of the sprite + !#zh sprite 的左边边框 */ + insetLeft: number; + /** !#en Right border of the sprite + !#zh sprite 的左边边框 */ + insetRight: number; + /** + !#en + Constructor of SpriteFrame class. + !#zh + SpriteFrame 类的构造函数。 + @param filename filename + @param rect rect + @param rotated Whether the frame is rotated in the texture + @param offset The offset of the frame in the texture + @param originalSize The size of the frame in the texture + */ + constructor(filename?: string|Texture2D, rect?: Rect, rotated?: boolean, offset?: Vec2, originalSize?: Size); + /** + !#en Returns whether the texture have been loaded + !#zh 返回是否已加载纹理 + */ + textureLoaded(): boolean; + /** + !#en Returns whether the sprite frame is rotated in the texture. + !#zh 获取 SpriteFrame 是否旋转 + */ + isRotated(): boolean; + /** + !#en Set whether the sprite frame is rotated in the texture. + !#zh 设置 SpriteFrame 是否旋转 + @param bRotated bRotated + */ + setRotated(bRotated: boolean): void; + /** + !#en Returns whether the sprite frame is flip x axis in the texture. + !#zh 获取 SpriteFrame 是否反转 x 轴 + */ + isFlipX(): boolean; + /** + !#en Returns whether the sprite frame is flip y axis in the texture. + !#zh 获取 SpriteFrame 是否反转 y 轴 + */ + isFlipY(): boolean; + /** + !#en Set whether the sprite frame is flip x axis in the texture. + !#zh 设置 SpriteFrame 是否翻转 x 轴 + @param flipX flipX + */ + setFlipX(flipX: boolean): void; + /** + !#en Set whether the sprite frame is flip y axis in the texture. + !#zh 设置 SpriteFrame 是否翻转 y 轴 + @param flipY flipY + */ + setFlipY(flipY: boolean): void; + /** + !#en Returns the rect of the sprite frame in the texture. + !#zh 获取 SpriteFrame 的纹理矩形区域 + */ + getRect(): Rect; + /** + !#en Sets the rect of the sprite frame in the texture. + !#zh 设置 SpriteFrame 的纹理矩形区域 + @param rect rect + */ + setRect(rect: Rect): void; + /** + !#en Returns the original size of the trimmed image. + !#zh 获取修剪前的原始大小 + */ + getOriginalSize(): Size; + /** + !#en Sets the original size of the trimmed image. + !#zh 设置修剪前的原始大小 + @param size size + */ + setOriginalSize(size: Size): void; + /** + !#en Returns the texture of the frame. + !#zh 获取使用的纹理实例 + */ + getTexture(): Texture2D; + /** + !#en Returns the offset of the frame in the texture. + !#zh 获取偏移量 + */ + getOffset(): Vec2; + /** + !#en Sets the offset of the frame in the texture. + !#zh 设置偏移量 + @param offsets offsets + */ + setOffset(offsets: Vec2): void; + /** + !#en Clone the sprite frame. + !#zh 克隆 SpriteFrame + */ + clone(): SpriteFrame; + /** + !#en Set SpriteFrame with Texture, rect, rotated, offset and originalSize.
+ !#zh 通过 Texture,rect,rotated,offset 和 originalSize 设置 SpriteFrame。 + @param texture texture + @param rect rect + @param rotated rotated + @param offset offset + @param originalSize originalSize + */ + setTexture(texture: Texture2D, rect?: Rect, rotated?: boolean, offset?: Vec2, originalSize?: Size): boolean; + /** + !#en If a loading scene (or prefab) is marked as `asyncLoadAssets`, all the textures of the SpriteFrame which + associated by user's custom Components in the scene, will not preload automatically. + These textures will be load when Sprite component is going to render the SpriteFrames. + You can call this method if you want to load the texture early. + !#zh 当加载中的场景或 Prefab 被标记为 `asyncLoadAssets` 时,用户在场景中由自定义组件关联到的所有 SpriteFrame 的贴图都不会被提前加载。 + 只有当 Sprite 组件要渲染这些 SpriteFrame 时,才会检查贴图是否加载。如果你希望加载过程提前,你可以手工调用这个方法。 + + @example + ```js + if (spriteFrame.textureLoaded()) { + this._onSpriteFrameLoaded(); + } + else { + spriteFrame.once('load', this._onSpriteFrameLoaded, this); + spriteFrame.ensureLoadTexture(); + } + ``` + */ + ensureLoadTexture(): void; + /** + !#en + If you do not need to use the SpriteFrame temporarily, you can call this method so that its texture could be garbage collected. Then when you need to render the SpriteFrame, you should call `ensureLoadTexture` manually to reload texture. + !#zh + 当你暂时不再使用这个 SpriteFrame 时,可以调用这个方法来保证引用的贴图对象能被 GC。然后当你要渲染 SpriteFrame 时,你需要手动调用 `ensureLoadTexture` 来重新加载贴图。 + */ + clearTexture(): void; + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en + Register an callback of a specific event type on the EventTarget. + This type of event should be triggered via `emit`. + !#zh + 注册事件目标的特定事件类型回调。这种类型的事件应该被 `emit` 触发。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, node); + ``` + */ + on(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. + !#zh + 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + + @example + ```js + // register fire eventListener + var callback = eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, target); + // remove fire event listener + eventTarget.off('fire', callback, target); + // remove all fire event listeners + eventTarget.off('fire'); + ``` + */ + off(type: string, callback?: Function, target?: any): void; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.once('fire', function () { + cc.log("this is the callback and will be invoked only once"); + }, node); + ``` + */ + once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; + /** + !#en + Send an event with the event object. + !#zh + 通过事件对象派发事件 + @param event event + */ + dispatchEvent(event: Event): void; + } + /** !#en Class for TTFFont handling. + !#zh TTF 字体资源类。 */ + export class TTFFont extends Font { + } + /** !#en Class for text file. + !#zh 文本资源类。 */ + export class TextAsset extends Asset { + /** The text contents of the resource. */ + text: string; + } + /** This class allows to easily create OpenGL or Canvas 2D textures from images or raw data. */ + export class Texture2D extends Asset implements EventTarget { + /** !#en Sets whether generate mipmaps for the texture + !#zh 是否为纹理设置生成 mipmaps。 */ + genMipmaps: boolean; + /** !#en + Sets whether texture can be packed into texture atlas. + If need use texture uv in custom Effect, please sets packable to false. + !#zh + 设置纹理是否允许参与合图。 + 如果需要在自定义 Effect 中使用纹理 UV,需要禁止该选项。 */ + packable: boolean; + /** !#en + Whether the texture is loaded or not + !#zh + 贴图是否已经成功加载 */ + loaded: boolean; + /** !#en + Texture width in pixel + !#zh + 贴图像素宽度 */ + width: number; + /** !#en + Texture height in pixel + !#zh + 贴图像素高度 */ + height: number; + /** + !#en + Get renderer texture implementation object + extended from render.Texture2D + !#zh 返回渲染器内部贴图对象 + */ + getImpl(): void; + /** + Update texture options, not available in Canvas render mode. + image, format, premultiplyAlpha can not be updated in native. + @param options options + */ + update(options: {image: DOMImageElement; genMipmaps: boolean; format: Texture2D.PixelFormat; minFilter: Texture2D.Filter; magFilter: Texture2D.Filter; wrapS: WrapMode; wrapT: WrapMode; premultiplyAlpha: boolean; }): void; + /** + !#en + Init with HTML element. + !#zh 用 HTML Image 或 Canvas 对象初始化贴图。 + @param element element + + @example + ```js + var img = new Image(); + img.src = dataURL; + texture.initWithElement(img); + ``` + */ + initWithElement(element: HTMLImageElement|HTMLCanvasElement): void; + /** + !#en + Intializes with texture data in ArrayBufferView. + !#zh 使用一个存储在 ArrayBufferView 中的图像数据(raw data)初始化数据。 + @param data data + @param pixelFormat pixelFormat + @param pixelsWidth pixelsWidth + @param pixelsHeight pixelsHeight + */ + initWithData(data: ArrayBufferView, pixelFormat: number, pixelsWidth: number, pixelsHeight: number): boolean; + /** + !#en + HTMLElement Object getter, available only on web.
+ Note: texture is packed into texture atlas by default
+ you should set texture.packable as false before getting Html element object. + !#zh 获取当前贴图对应的 HTML Image 或 Canvas 对象,只在 Web 平台下有效。
+ 注意:
+ texture 默认参与动态合图,如果需要获取到正确的 Html 元素对象,需要先设置 texture.packable 为 false + */ + getHtmlElementObj(): HTMLImageElement; + /** + !#en + Destory this texture and immediately release its video memory. (Inherit from cc.Object.destroy)
+ After destroy, this object is not usable anymore. + You can use cc.isValid(obj) to check whether the object is destroyed before accessing it. + !#zh + 销毁该贴图,并立即释放它对应的显存。(继承自 cc.Object.destroy)
+ 销毁后,该对象不再可用。您可以在访问对象之前使用 cc.isValid(obj) 来检查对象是否已被销毁。 + */ + destroy(): boolean; + /** + !#en + Pixel format of the texture. + !#zh 获取纹理的像素格式。 + */ + getPixelFormat(): number; + /** + !#en + Whether or not the texture has their Alpha premultiplied. + !#zh 检查纹理在上传 GPU 时预乘选项是否开启。 + */ + hasPremultipliedAlpha(): boolean; + /** + !#en + Handler of texture loaded event. + Since v2.0, you don't need to invoke this function, it will be invoked automatically after texture loaded. + !#zh 贴图加载事件处理器。v2.0 之后你将不在需要手动执行这个函数,它会在贴图加载成功之后自动执行。 + @param premultiplied premultiplied + */ + handleLoadedTexture(premultiplied?: boolean): void; + /** + !#en + Description of cc.Texture2D. + !#zh cc.Texture2D 描述。 + */ + description(): string; + /** + !#en + Release texture, please use destroy instead. + !#zh 释放纹理,请使用 destroy 替代。 + */ + releaseTexture(): void; + /** + !#en Sets the wrap s and wrap t options.
+ If the texture size is NPOT (non power of 2), then in can only use gl.CLAMP_TO_EDGE in gl.TEXTURE_WRAP_{S,T}. + !#zh 设置纹理包装模式。 + 若纹理贴图尺寸是 NPOT(non power of 2),则只能使用 Texture2D.WrapMode.CLAMP_TO_EDGE。 + @param wrapS wrapS + @param wrapT wrapT + */ + setTexParameters(wrapS: Texture2D.WrapMode, wrapT: Texture2D.WrapMode): void; + /** + !#en Sets the minFilter and magFilter options + !#zh 设置纹理贴图缩小和放大过滤器算法选项。 + @param minFilter minFilter + @param magFilter magFilter + */ + setFilters(minFilter: Texture2D.Filter, magFilter: Texture2D.Filter): void; + /** + !#en + Sets the flipY options + !#zh 设置贴图的纵向翻转选项。 + @param flipY flipY + */ + setFlipY(flipY: boolean): void; + /** + !#en + Sets the premultiply alpha options + !#zh 设置贴图的预乘选项。 + @param premultiply premultiply + */ + setPremultiplyAlpha(premultiply: boolean): void; + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en + Register an callback of a specific event type on the EventTarget. + This type of event should be triggered via `emit`. + !#zh + 注册事件目标的特定事件类型回调。这种类型的事件应该被 `emit` 触发。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, node); + ``` + */ + on(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. + !#zh + 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + + @example + ```js + // register fire eventListener + var callback = eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, target); + // remove fire event listener + eventTarget.off('fire', callback, target); + // remove all fire event listeners + eventTarget.off('fire'); + ``` + */ + off(type: string, callback?: Function, target?: any): void; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.once('fire', function () { + cc.log("this is the callback and will be invoked only once"); + }, node); + ``` + */ + once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; + /** + !#en + Send an event with the event object. + !#zh + 通过事件对象派发事件 + @param event event + */ + dispatchEvent(event: Event): void; + } + /** !#en + Camera is usefull when making reel game or other games which need scroll screen. + Using camera will be more efficient than moving node to scroll screen. + Camera + !#zh + 摄像机在制作卷轴或是其他需要移动屏幕的游戏时比较有用,使用摄像机将会比移动节点来移动屏幕更加高效。 */ + export class Camera extends Component { + /** !#en + The camera zoom ratio, only support 2D camera. + !#zh + 摄像机缩放比率, 只支持 2D camera。 */ + zoomRatio: number; + /** !#en + Field of view. The width of the Camera’s view angle, measured in degrees along the local Y axis. + !#zh + 决定摄像机视角的宽度,当摄像机处于透视投影模式下这个属性才会生效。 */ + fov: number; + /** !#en + The viewport size of the Camera when set to orthographic projection. + !#zh + 摄像机在正交投影模式下的视窗大小。 */ + orthoSize: number; + /** !#en + The near clipping plane. + !#zh + 摄像机的近剪裁面。 */ + nearClip: number; + /** !#en + The far clipping plane. + !#zh + 摄像机的远剪裁面。 */ + farClip: number; + /** !#en + Is the camera orthographic (true) or perspective (false)? + !#zh + 设置摄像机的投影模式是正交还是透视模式。 */ + ortho: boolean; + /** !#en + Four values (0 ~ 1) that indicate where on the screen this camera view will be drawn. + !#zh + 决定摄像机绘制在屏幕上哪个位置,值为(0 ~ 1)。 */ + rect: Rect; + /** !#en + This is used to render parts of the scene selectively. + !#zh + 决定摄像机会渲染场景的哪一部分。 */ + cullingMask: number; + /** !#en + Determining what to clear when camera rendering. + !#zh + 决定摄像机渲染时会清除哪些状态。 */ + clearFlags: Camera.ClearFlags; + /** !#en + The color with which the screen will be cleared. + !#zh + 摄像机用于清除屏幕的背景色。 */ + backgroundColor: Color; + /** !#en + Camera's depth in the camera rendering order. Cameras with higher depth are rendered after cameras with lower depth. + !#zh + 摄像机深度。用于决定摄像机的渲染顺序,值越大渲染在越上层。 */ + depth: number; + /** !#en + Destination render texture. + Usually cameras render directly to screen, but for some effects it is useful to make a camera render into a texture. + !#zh + 摄像机渲染的目标 RenderTexture。 + 一般摄像机会直接渲染到屏幕上,但是有一些效果可以使用摄像机渲染到 RenderTexture 上再对 RenderTexture 进行处理来实现。 */ + targetTexture: RenderTexture; + /** !#en + Sets the camera's render stages. + !#zh + 设置摄像机渲染的阶段 */ + renderStages: number; + /** !#en Whether auto align camera viewport to screen + !#zh 是否自动将摄像机的视口对准屏幕 */ + alignWithScreen: boolean; + /** !#en + The primary camera in the scene. Returns the rear most rendered camera, which is the camera with the lowest depth. + !#zh + 当前场景中激活的主摄像机。将会返回渲染在屏幕最底层,也就是 depth 最小的摄像机。 */ + static main: Camera; + /** !#en + All enabled cameras. + !#zh + 当前激活的所有摄像机。 */ + static cameras: Camera[]; + /** + !#en + Get the first camera which the node belong to. + !#zh + 获取节点所在的第一个摄像机。 + @param node node + */ + static findCamera(node: Node): Camera; + /** + !#en + Get the screen to world matrix, only support 2D camera which alignWithScreen is true. + !#zh + 获取屏幕坐标系到世界坐标系的矩阵,只适用于 alignWithScreen 为 true 的 2D 摄像机。 + @param out the matrix to receive the result + */ + getScreenToWorldMatrix2D(out: Mat4): Mat4; + /** + !#en + Get the world to camera matrix, only support 2D camera which alignWithScreen is true. + !#zh + 获取世界坐标系到摄像机坐标系的矩阵,只适用于 alignWithScreen 为 true 的 2D 摄像机。 + @param out the matrix to receive the result + */ + getWorldToScreenMatrix2D(out: Mat4): Mat4; + /** + !#en + Convert point from screen to world. + !#zh + 将坐标从屏幕坐标系转换到世界坐标系。 + @param screenPosition screenPosition + @param out out + */ + getScreenToWorldPoint(screenPosition: Vec3|Vec2, out?: Vec3|Vec2): Vec3; + /** + !#en + Convert point from world to screen. + !#zh + 将坐标从世界坐标系转化到屏幕坐标系。 + @param worldPosition worldPosition + @param out out + */ + getWorldToScreenPoint(worldPosition: Vec3|Vec2, out?: Vec3|Vec2): Vec3; + /** + !#en + Get a ray from screen position + !#zh + 从屏幕坐标获取一条射线 + @param screenPos screenPos + */ + getRay(screenPos: Vec2): geomUtils.Ray; + /** + !#en + Check whether the node is in the camera. + !#zh + 检测节点是否被此摄像机影响 + @param node the node which need to check + */ + containsNode(node: Node): boolean; + /** + !#en + Render the camera manually. + !#zh + 手动渲染摄像机。 + @param rootNode rootNode + */ + render(rootNode?: Node): void; + /** + !#en + Returns the matrix that transform the node's (local) space coordinates into the camera's space coordinates. + !#zh + 返回一个将节点坐标系转换到摄像机坐标系下的矩阵 + @param node the node which should transform + */ + getNodeToCameraTransform(node: Node): AffineTransform; + /** + !#en + Conver a camera coordinates point to world coordinates. + !#zh + 将一个摄像机坐标系下的点转换到世界坐标系下。 + @param point the point which should transform + @param out the point to receive the result + */ + getCameraToWorldPoint(point: Vec2, out?: Vec2): Vec2; + /** + !#en + Conver a world coordinates point to camera coordinates. + !#zh + 将一个世界坐标系下的点转换到摄像机坐标系下。 + @param point point + @param out the point to receive the result + */ + getWorldToCameraPoint(point: Vec2, out?: Vec2): Vec2; + /** + !#en + Get the camera to world matrix + !#zh + 获取摄像机坐标系到世界坐标系的矩阵 + @param out the matrix to receive the result + */ + getCameraToWorldMatrix(out: Mat4): Mat4; + /** + !#en + Get the world to camera matrix + !#zh + 获取世界坐标系到摄像机坐标系的矩阵 + @param out the matrix to receive the result + */ + getWorldToCameraMatrix(out: Mat4): Mat4; + } + /** !#en The touch event class + !#zh 封装了触摸相关的信息。 */ + export class Touch { + /** + !#en Returns the current touch location in OpenGL coordinates.、 + !#zh 获取当前触点位置。 + */ + getLocation(): Vec2; + /** + !#en Returns X axis location value. + !#zh 获取当前触点 X 轴位置。 + */ + getLocationX(): number; + /** + !#en Returns Y axis location value. + !#zh 获取当前触点 Y 轴位置。 + */ + getLocationY(): number; + /** + !#en Returns the previous touch location in OpenGL coordinates. + !#zh 获取触点在上一次事件时的位置对象,对象包含 x 和 y 属性。 + */ + getPreviousLocation(): Vec2; + /** + !#en Returns the start touch location in OpenGL coordinates. + !#zh 获取触点落下时的位置对象,对象包含 x 和 y 属性。 + */ + getStartLocation(): Vec2; + /** + !#en Returns the delta distance from the previous touche to the current one in screen coordinates. + !#zh 获取触点距离上一次事件移动的距离对象,对象包含 x 和 y 属性。 + */ + getDelta(): Vec2; + /** + !#en Returns the current touch location in screen coordinates. + !#zh 获取当前事件在游戏窗口内的坐标位置对象,对象包含 x 和 y 属性。 + */ + getLocationInView(): Vec2; + /** + !#en Returns the previous touch location in screen coordinates. + !#zh 获取触点在上一次事件时在游戏窗口中的位置对象,对象包含 x 和 y 属性。 + */ + getPreviousLocationInView(): Vec2; + /** + !#en Returns the start touch location in screen coordinates. + !#zh 获取触点落下时在游戏窗口中的位置对象,对象包含 x 和 y 属性。 + */ + getStartLocationInView(): Vec2; + /** + !#en Returns the id of cc.Touch. + !#zh 触点的标识 ID,可以用来在多点触摸中跟踪触点。 + */ + getID(): number; + /** + !#en Sets information to touch. + !#zh 设置触摸相关的信息。用于监控触摸事件。 + @param id id + @param x x + @param y y + */ + setTouchInfo(id: number, x: number, y: number): void; + } + /** !#en Mesh Asset. + !#zh 网格资源。 */ + export class Mesh extends Asset implements EventTarget { + /** !#en Get ir set the sub meshes. + !#zh 设置或者获取子网格。 */ + subMeshes: InputAssembler[]; + /** + !#en + Init vertex buffer according to the vertex format. + !#zh + 根据顶点格式初始化顶点内存。 + @param vertexFormat vertex format + @param vertexCount how much vertex should be create in this buffer. + @param dynamic whether or not to use dynamic buffer. + @param index index + */ + init(vertexFormat: gfx.VertexFormat, vertexCount: number, dynamic?: boolean, index?: boolean): void; + /** + !#en + Set the vertex values. + !#zh + 设置顶点数据 + @param name the attribute name, e.g. gfx.ATTR_POSITION + @param values the vertex values + */ + setVertices(name: string, values: Vec2[]|Vec3[]|Color[]|number[]|Uint8Array|Float32Array): void; + /** + !#en + Set the sub mesh indices. + !#zh + 设置子网格索引。 + @param indices the sub mesh indices. + @param index sub mesh index. + @param dynamic whether or not to use dynamic buffer. + */ + setIndices(indices: number[]|Uint16Array|Uint8Array, index?: number, dynamic?: boolean): void; + /** + !#en + Set the sub mesh primitive type. + !#zh + 设置子网格绘制线条的方式。 + @param type type + @param index index + */ + setPrimitiveType(type: number, index: number): void; + /** + !#en + Clear the buffer data. + !#zh + 清除网格创建的内存数据。 + */ + clear(): void; + /** + !#en Set mesh bounding box + !#zh 设置网格的包围盒 + @param min min + @param max max + */ + setBoundingBox(min: Vec3, max: Vec3): void; + /** + !#en Read the specified attributes of the subgrid into the target buffer. + !#zh 读取子网格的指定属性到目标缓冲区中。 + @param primitiveIndex The subgrid index. + @param attributeName attribute name. + @param buffer The target buffer. + @param stride The byte interval between adjacent attributes in the target buffer. + @param offset The offset of the first attribute in the target buffer. + */ + copyAttribute(primitiveIndex: number, attributeName: string, buffer: ArrayBuffer, stride: number, offset: number): boolean; + /** + !#en Read the index data of the subgrid into the target array. + !#zh 读取子网格的索引数据到目标数组中。 + @param primitiveIndex The subgrid index. + @param outputArray The target array. + */ + copyIndices(primitiveIndex: number, outputArray: DataView): boolean; + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en + Register an callback of a specific event type on the EventTarget. + This type of event should be triggered via `emit`. + !#zh + 注册事件目标的特定事件类型回调。这种类型的事件应该被 `emit` 触发。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, node); + ``` + */ + on(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. + !#zh + 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + + @example + ```js + // register fire eventListener + var callback = eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, target); + // remove fire event listener + eventTarget.off('fire', callback, target); + // remove all fire event listeners + eventTarget.off('fire'); + ``` + */ + off(type: string, callback?: Function, target?: any): void; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.once('fire', function () { + cc.log("this is the callback and will be invoked only once"); + }, node); + ``` + */ + once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; + /** + !#en + Send an event with the event object. + !#zh + 通过事件对象派发事件 + @param event event + */ + dispatchEvent(event: Event): void; + } + /** !#en + Mesh Renderer Component + !#zh + 网格渲染组件 */ + export class MeshRenderer extends RenderComponent { + /** !#en + The mesh which the renderer uses. + !#zh + 设置使用的网格 */ + mesh: Mesh; + /** !#en + Whether the mesh should receive shadows. + !#zh + 网格是否接受光源投射的阴影 */ + receiveShadows: boolean; + /** !#en + Shadow Casting Mode + !#zh + 网格投射阴影的模式 */ + shadowCastingMode: MeshRenderer.ShadowCastingMode; + /** !#en + Enable auto merge mesh, only support when mesh's VertexFormat, PrimitiveType, materials are all the same + !#zh + 开启自动合并 mesh 功能,只有在网格的 顶点格式,PrimitiveType, 使用的材质 都一致的情况下才会有效 */ + enableAutoBatch: boolean; + } + /** The class BufferRange denotes a range of the buffer. */ + export class BufferRange { + /** The offset of the range. */ + offset: number; + /** The length of the range. */ + length: number; + } + /** undefined */ + export class VertexFormat { + /** The data range of this bundle. + This range of data is essentially mapped to a GPU vertex buffer. */ + data: BufferRange; + /** The attribute formats. */ + formats: VertexFormat; + /** The vertex bundle that the primitive use. */ + vertexBundleIndices: number[]; + /** The data range of the primitive. + This range of data is essentially mapped to a GPU indices buffer. */ + data: BufferRange; + /** The type of this primitive's indices. */ + indexUnit: number; + /** The primitive's topology. */ + topology: number; + } + /** !#en The animation component is used to play back animations. + + Animation provide several events to register: + - play : Emit when begin playing animation + - stop : Emit when stop playing animation + - pause : Emit when pause animation + - resume : Emit when resume animation + - lastframe : If animation repeat count is larger than 1, emit when animation play to the last frame + - finished : Emit when finish playing animation + + !#zh Animation 组件用于播放动画。 + + Animation 提供了一系列可注册的事件: + - play : 开始播放时 + - stop : 停止播放时 + - pause : 暂停播放时 + - resume : 恢复播放时 + - lastframe : 假如动画循环次数大于 1,当动画播放到最后一帧时 + - finished : 动画播放完成时 */ + export class Animation extends Component implements EventTarget { + /** !#en Animation will play the default clip when start game. + !#zh 在勾选自动播放或调用 play() 时默认播放的动画剪辑。 */ + defaultClip: AnimationClip; + /** !#en Current played clip. + !#zh 当前播放的动画剪辑。 */ + currentClip: AnimationClip; + /** !#en Whether the animation should auto play the default clip when start game. + !#zh 是否在运行游戏后自动播放默认动画剪辑。 */ + playOnLoad: boolean; + /** + !#en Get all the clips used in this animation. + !#zh 获取动画组件上的所有动画剪辑。 + */ + getClips(): AnimationClip[]; + /** + !#en Plays an animation and stop other animations. + !#zh 播放指定的动画,并且停止当前正在播放动画。如果没有指定动画,则播放默认动画。 + @param name The name of animation to play. If no name is supplied then the default animation will be played. + @param startTime play an animation from startTime + + @example + ```js + var animCtrl = this.node.getComponent(cc.Animation); + animCtrl.play("linear"); + ``` + */ + play(name?: string, startTime?: number): AnimationState; + /** + !#en + Plays an additive animation, it will not stop other animations. + If there are other animations playing, then will play several animations at the same time. + !#zh 播放指定的动画(将不会停止当前播放的动画)。如果没有指定动画,则播放默认动画。 + @param name The name of animation to play. If no name is supplied then the default animation will be played. + @param startTime play an animation from startTime + + @example + ```js + // linear_1 and linear_2 at the same time playing. + var animCtrl = this.node.getComponent(cc.Animation); + animCtrl.playAdditive("linear_1"); + animCtrl.playAdditive("linear_2"); + ``` + */ + playAdditive(name?: string, startTime?: number): AnimationState; + /** + !#en Stops an animation named name. If no name is supplied then stops all playing animations that were started with this Animation.
+ Stopping an animation also Rewinds it to the Start. + !#zh 停止指定的动画。如果没有指定名字,则停止当前正在播放的动画。 + @param name The animation to stop, if not supplied then stops all playing animations. + */ + stop(name?: string): void; + /** + !#en Pauses an animation named name. If no name is supplied then pauses all playing animations that were started with this Animation. + !#zh 暂停当前或者指定的动画。如果没有指定名字,则暂停当前正在播放的动画。 + @param name The animation to pauses, if not supplied then pauses all playing animations. + */ + pause(name?: string): void; + /** + !#en Resumes an animation named name. If no name is supplied then resumes all paused animations that were started with this Animation. + !#zh 重新播放指定的动画,如果没有指定名字,则重新播放当前正在播放的动画。 + @param name The animation to resumes, if not supplied then resumes all paused animations. + */ + resume(name?: string): void; + /** + !#en Make an animation named name go to the specified time. If no name is supplied then make all animations go to the specified time. + !#zh 设置指定动画的播放时间。如果没有指定名字,则设置当前播放动画的播放时间。 + @param time The time to go to + @param name Specified animation name, if not supplied then make all animations go to the time. + */ + setCurrentTime(time?: number, name?: string): void; + /** + !#en Returns the animation state named name. If no animation with the specified name, the function will return null. + !#zh 获取当前或者指定的动画状态,如果未找到指定动画剪辑则返回 null。 + @param name name + */ + getAnimationState(name: string): AnimationState; + /** + !#en Adds a clip to the animation with name newName. If a clip with that name already exists it will be replaced with the new clip. + !#zh 添加动画剪辑,并且可以重新设置该动画剪辑的名称。 + @param clip the clip to add + @param newName newName + */ + addClip(clip: AnimationClip, newName?: string): AnimationState; + /** + !#en + Remove clip from the animation list. This will remove the clip and any animation states based on it. + If there are animation states depand on the clip are playing or clip is defaultClip, it will not delete the clip. + But if force is true, then will always remove the clip and any animation states based on it. If clip is defaultClip, defaultClip will be reset to null + !#zh + 从动画列表中移除指定的动画剪辑,
+ 如果依赖于 clip 的 AnimationState 正在播放或者 clip 是 defaultClip 的话,默认是不会删除 clip 的。 + 但是如果 force 参数为 true,则会强制停止该动画,然后移除该动画剪辑和相关的动画。这时候如果 clip 是 defaultClip,defaultClip 将会被重置为 null。 + @param clip clip + @param force If force is true, then will always remove the clip and any animation states based on it. + */ + removeClip(clip: AnimationClip, force?: boolean): void; + /** + !#en + Samples animations at the current state.
+ This is useful when you explicitly want to set up some animation state, and sample it once. + !#zh 对指定或当前动画进行采样。你可以手动将动画设置到某一个状态,然后采样一次。 + @param name name + */ + sample(name: string): void; + /** + !#en + Register animation event callback. + The event arguments will provide the AnimationState which emit the event. + When play an animation, will auto register the event callback to the AnimationState, and unregister the event callback from the AnimationState when animation stopped. + !#zh + 注册动画事件回调。 + 回调的事件里将会附上发送事件的 AnimationState。 + 当播放一个动画时,会自动将事件注册到对应的 AnimationState 上,停止播放时会将事件从这个 AnimationState 上取消注册。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param state state + @param target The target (this object) to invoke the callback, can be null + @param useCapture When set to true, the capture argument prevents callback + from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. + When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE. + Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET. + + @example + ```js + onPlay: function (type, state) { + // callback + } + + // register event to all animation + animation.on('play', this.onPlay, this); + ``` + */ + on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void; + on(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void; + on(type: string, callback: (type: string, state: cc.AnimationState) => void, target?: any, useCapture?: boolean): (type: string, state: cc.AnimationState) => void; + /** + !#en + Unregister animation event callback. + !#zh + 取消注册动画事件回调。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not. + If not specified, useCapture defaults to false. If a callback was registered twice, + one with capture and one without, each must be removed separately. Removal of a capturing callback + does not affect a non-capturing version of the same listener, and vice versa. + + @example + ```js + // unregister event to all animation + animation.off('play', this.onPlay, this); + ``` + */ + off(type: string, callback?: Function, target?: any, useCapture?: boolean): void; + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.once('fire', function () { + cc.log("this is the callback and will be invoked only once"); + }, node); + ``` + */ + once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; + /** + !#en + Send an event with the event object. + !#zh + 通过事件对象派发事件 + @param event event + */ + dispatchEvent(event: Event): void; + } + /** !#en Audio Source. + !#zh 音频源组件,能对音频剪辑。 */ + export class AudioSource extends Component { + /** !#en + Is the audio source playing (Read Only).
+ Note: isPlaying is not supported for Native platforms. + !#zh + 该音频剪辑是否正播放(只读)。
+ 注意:Native 平台暂时不支持 isPlaying。 */ + isPlaying: boolean; + /** !#en The clip of the audio source to play. + !#zh 要播放的音频剪辑。 */ + clip: AudioClip; + /** !#en The volume of the audio source. + !#zh 音频源的音量(0.0 ~ 1.0)。 */ + volume: number; + /** !#en Is the audio source mute? + !#zh 是否静音音频源。Mute 是设置音量为 0,取消静音是恢复原来的音量。 */ + mute: boolean; + /** !#en Is the audio source looping? + !#zh 音频源是否循环播放? */ + loop: boolean; + /** !#en If set to true, the audio source will automatically start playing on onEnable. + !#zh 如果设置为 true,音频源将在 onEnable 时自动播放。 */ + playOnLoad: boolean; + /** + !#en Plays the clip. + !#zh 播放音频剪辑。 + */ + play(): void; + /** + !#en Stops the clip. + !#zh 停止当前音频剪辑。 + */ + stop(): void; + /** + !#en Pause the clip. + !#zh 暂停当前音频剪辑。 + */ + pause(): void; + /** + !#en Resume the clip. + !#zh 恢复播放。 + */ + resume(): void; + /** + !#en Rewind playing music. + !#zh 从头开始播放。 + */ + rewind(): void; + /** + !#en Get current time + !#zh 获取当前的播放时间 + */ + getCurrentTime(): number; + /** + !#en Set current time + !#zh 设置当前的播放时间 + @param time time + */ + setCurrentTime(time: number): number; + /** + !#en Get audio duration + !#zh 获取当前音频的长度 + */ + getDuration(): number; + } + /** !#en + This component will block all input events (mouse and touch) within the bounding box of the node, preventing the input from penetrating into the underlying node, typically for the background of the top UI.
+ This component does not have any API interface and can be added directly to the scene to take effect. + !#zh + 该组件将拦截所属节点 bounding box 内的所有输入事件(鼠标和触摸),防止输入穿透到下层节点,一般用于上层 UI 的背景。
+ 该组件没有任何 API 接口,直接添加到场景即可生效。 */ + export class BlockInputEvents extends Component { + } + /** !#en + Button has 4 Transition types
+ When Button state changed:
+ If Transition type is Button.Transition.NONE, Button will do nothing
+ If Transition type is Button.Transition.COLOR, Button will change target's color
+ If Transition type is Button.Transition.SPRITE, Button will change target Sprite's sprite
+ If Transition type is Button.Transition.SCALE, Button will change target node's scale
+ + Button will trigger 5 events:
+ Button.EVENT_TOUCH_DOWN
+ Button.EVENT_TOUCH_UP
+ Button.EVENT_HOVER_IN
+ Button.EVENT_HOVER_MOVE
+ Button.EVENT_HOVER_OUT
+ User can get the current clicked node with 'event.target' from event object which is passed as parameter in the callback function of click event. + + !#zh + 按钮组件。可以被按下,或者点击。 + + 按钮可以通过修改 Transition 来设置按钮状态过渡的方式: + + - Button.Transition.NONE // 不做任何过渡 + - Button.Transition.COLOR // 进行颜色之间过渡 + - Button.Transition.SPRITE // 进行精灵之间过渡 + - Button.Transition.SCALE // 进行缩放过渡 + + 按钮可以绑定事件(但是必须要在按钮的 Node 上才能绑定事件):
+ 以下事件可以在全平台上都触发: + + - cc.Node.EventType.TOUCH_START // 按下时事件 + - cc.Node.EventType.TOUCH_Move // 按住移动后事件 + - cc.Node.EventType.TOUCH_END // 按下后松开后事件 + - cc.Node.EventType.TOUCH_CANCEL // 按下取消事件 + + 以下事件只在 PC 平台上触发: + + - cc.Node.EventType.MOUSE_DOWN // 鼠标按下时事件 + - cc.Node.EventType.MOUSE_MOVE // 鼠标按住移动后事件 + - cc.Node.EventType.MOUSE_ENTER // 鼠标进入目标事件 + - cc.Node.EventType.MOUSE_LEAVE // 鼠标离开目标事件 + - cc.Node.EventType.MOUSE_UP // 鼠标松开事件 + - cc.Node.EventType.MOUSE_WHEEL // 鼠标滚轮事件 + + 用户可以通过获取 __点击事件__ 回调函数的参数 event 的 target 属性获取当前点击对象。 */ + export class Button extends Component implements GraySpriteState { + /** !#en + Whether the Button is disabled. + If true, the Button will trigger event and do transition. + !#zh + 按钮事件是否被响应,如果为 false,则按钮将被禁用。 */ + interactable: boolean; + /** !#en When this flag is true, Button target sprite will turn gray when interactable is false. + !#zh 如果这个标记为 true,当 button 的 interactable 属性为 false 的时候,会使用内置 shader 让 button 的 target 节点的 sprite 组件变灰 */ + enableAutoGrayEffect: boolean; + /** !#en Transition type + !#zh 按钮状态改变时过渡方式。 */ + transition: Button.Transition; + /** !#en Normal state color. + !#zh 普通状态下按钮所显示的颜色。 */ + normalColor: Color; + /** !#en Pressed state color + !#zh 按下状态时按钮所显示的颜色。 */ + pressedColor: Color; + /** !#en Hover state color + !#zh 悬停状态下按钮所显示的颜色。 */ + hoverColor: Color; + /** !#en Disabled state color + !#zh 禁用状态下按钮所显示的颜色。 */ + disabledColor: Color; + /** !#en Color and Scale transition duration + !#zh 颜色过渡和缩放过渡时所需时间 */ + duration: number; + /** !#en When user press the button, the button will zoom to a scale. + The final scale of the button equals (button original scale * zoomScale) + !#zh 当用户点击按钮后,按钮会缩放到一个值,这个值等于 Button 原始 scale * zoomScale */ + zoomScale: number; + /** !#en Normal state sprite + !#zh 普通状态下按钮所显示的 Sprite 。 */ + normalSprite: SpriteFrame; + /** !#en Pressed state sprite + !#zh 按下状态时按钮所显示的 Sprite 。 */ + pressedSprite: SpriteFrame; + /** !#en Hover state sprite + !#zh 悬停状态下按钮所显示的 Sprite 。 */ + hoverSprite: SpriteFrame; + /** !#en Disabled state sprite + !#zh 禁用状态下按钮所显示的 Sprite 。 */ + disabledSprite: SpriteFrame; + /** !#en + Transition target. + When Button state changed: + If Transition type is Button.Transition.NONE, Button will do nothing + If Transition type is Button.Transition.COLOR, Button will change target's color + If Transition type is Button.Transition.SPRITE, Button will change target Sprite's sprite + !#zh + 需要过渡的目标。 + 当前按钮状态改变规则: + -如果 Transition type 选择 Button.Transition.NONE,按钮不做任何过渡。 + -如果 Transition type 选择 Button.Transition.COLOR,按钮会对目标颜色进行颜色之间的过渡。 + -如果 Transition type 选择 Button.Transition.Sprite,按钮会对目标 Sprite 进行 Sprite 之间的过渡。 */ + target: Node; + /** !#en If Button is clicked, it will trigger event's handler + !#zh 按钮的点击事件列表。 */ + clickEvents: Component.EventHandler[]; + /** !#en The normal material. + !#zh 正常状态的材质。 */ + normalMaterial: Material; + /** !#en The gray material. + !#zh 置灰状态的材质。 */ + grayMaterial: Material; + } + /** !#zh: 作为 UI 根节点,为所有子节点提供视窗四边的位置信息以供对齐,另外提供屏幕适配策略接口,方便从编辑器设置。 + 注:由于本节点的尺寸会跟随屏幕拉伸,所以 anchorPoint 只支持 (0.5, 0.5),否则适配不同屏幕时坐标会有偏差。 */ + export class Canvas extends Component { + /** !#en Current active canvas, the scene should only have one active canvas at the same time. + !#zh 当前激活的画布组件,场景同一时间只能有一个激活的画布。 */ + static instance: Canvas; + /** !#en The desigin resolution for current scene. + !#zh 当前场景设计分辨率。 */ + designResolution: Size; + /** !#en TODO + !#zh: 是否优先将设计分辨率高度撑满视图高度。 */ + fitHeight: boolean; + /** !#en TODO + !#zh: 是否优先将设计分辨率宽度撑满视图宽度。 */ + fitWidth: boolean; + } + /** !#en + Base class for everything attached to Node(Entity).
+
+ NOTE: Not allowed to use construction parameters for Component's subclasses, + because Component is created by the engine. + !#zh + 所有附加到节点的基类。
+
+ 注意:不允许使用组件的子类构造参数,因为组件是由引擎创建的。 */ + export class Component extends Object { + /** !#en The node this component is attached to. A component is always attached to a node. + !#zh 该组件被附加到的节点。组件总会附加到一个节点。 */ + node: Node; + /** !#en The uuid for editor. + !#zh 组件的 uuid,用于编辑器。 */ + uuid: string; + /** !#en indicates whether this component is enabled or not. + !#zh 表示该组件自身是否启用。 */ + enabled: boolean; + /** !#en indicates whether this component is enabled and its node is also active in the hierarchy. + !#zh 表示该组件是否被启用并且所在的节点也处于激活状态。 */ + enabledInHierarchy: boolean; + /** !#en Returns a value which used to indicate the onLoad get called or not. + !#zh 返回一个值用来判断 onLoad 是否被调用过,不等于 0 时调用过,等于 0 时未调用。 */ + _isOnLoadCalled: number; + /** + !#en Update is called every frame, if the Component is enabled.
+ This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere. + !#zh 如果该组件启用,则每帧调用 update。
+ 该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。 + @param dt the delta time in seconds it took to complete the last frame + */ + protected update(dt: number): void; + /** + !#en LateUpdate is called every frame, if the Component is enabled.
+ This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere. + !#zh 如果该组件启用,则每帧调用 LateUpdate。
+ 该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。 + @param dt the delta time in seconds it took to complete the last frame + */ + protected lateUpdate(dt: number): void; + /** + !#en + When attaching to an active node or its node first activated. + onLoad is always called before any start functions, this allows you to order initialization of scripts.
+ This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere. + !#zh + 当附加到一个激活的节点上或者其节点第一次激活时候调用。onLoad 总是会在任何 start 方法调用前执行,这能用于安排脚本的初始化顺序。
+ 该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。 + */ + protected onLoad(): void; + /** + !#en + Called before all scripts' update if the Component is enabled the first time. + Usually used to initialize some logic which need to be called after all components' `onload` methods called.
+ This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere. + !#zh + 如果该组件第一次启用,则在所有组件的 update 之前调用。通常用于需要在所有组件的 onLoad 初始化完毕后执行的逻辑。
+ 该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。 + */ + protected start(): void; + /** + !#en Called when this component becomes enabled and its node is active.
+ This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere. + !#zh 当该组件被启用,并且它的节点也激活时。
+ 该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。 + */ + protected onEnable(): void; + /** + !#en Called when this component becomes disabled or its node becomes inactive.
+ This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere. + !#zh 当该组件被禁用或节点变为无效时调用。
+ 该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。 + */ + protected onDisable(): void; + /** + !#en Called when this component will be destroyed.
+ This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere. + !#zh 当该组件被销毁时调用
+ 该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。 + */ + protected onDestroy(): void; + protected onFocusInEditor(): void; + protected onLostFocusInEditor(): void; + /** + !#en Called to initialize the component or node’s properties when adding the component the first time or when the Reset command is used. This function is only called in editor. + !#zh 用来初始化组件或节点的一些属性,当该组件被第一次添加到节点上或用户点击了它的 Reset 菜单时调用。这个回调只会在编辑器下调用。 + */ + protected resetInEditor(): void; + /** + !#en Adds a component class to the node. You can also add component to node by passing in the name of the script. + !#zh 向节点添加一个组件类,你还可以通过传入脚本的名称来添加组件。 + @param typeOrClassName the constructor or the class name of the component to add + + @example + ```js + var sprite = node.addComponent(cc.Sprite); + var test = node.addComponent("Test"); + ``` + */ + addComponent(type: {new(): T}): T; + addComponent(className: string): any; + /** + !#en + Returns the component of supplied type if the node has one attached, null if it doesn't.
+ You can also get component in the node by passing in the name of the script. + !#zh + 获取节点上指定类型的组件,如果节点有附加指定类型的组件,则返回,如果没有则为空。
+ 传入参数也可以是脚本的名称。 + @param typeOrClassName typeOrClassName + + @example + ```js + // get sprite component. + var sprite = node.getComponent(cc.Sprite); + // get custom test calss. + var test = node.getComponent("Test"); + ``` + */ + getComponent(type: {prototype: T}): T; + getComponent(className: string): any; + /** + !#en Returns all components of supplied Type in the node. + !#zh 返回节点上指定类型的所有组件。 + @param typeOrClassName typeOrClassName + + @example + ```js + var sprites = node.getComponents(cc.Sprite); + var tests = node.getComponents("Test"); + ``` + */ + getComponents(type: {prototype: T}): T[]; + getComponents(className: string): any[]; + /** + !#en Returns the component of supplied type in any of its children using depth first search. + !#zh 递归查找所有子节点中第一个匹配指定类型的组件。 + @param typeOrClassName typeOrClassName + + @example + ```js + var sprite = node.getComponentInChildren(cc.Sprite); + var Test = node.getComponentInChildren("Test"); + ``` + */ + getComponentInChildren(type: {prototype: T}): T; + getComponentInChildren(className: string): any; + /** + !#en Returns the components of supplied type in self or any of its children using depth first search. + !#zh 递归查找自身或所有子节点中指定类型的组件 + @param typeOrClassName typeOrClassName + + @example + ```js + var sprites = node.getComponentsInChildren(cc.Sprite); + var tests = node.getComponentsInChildren("Test"); + ``` + */ + getComponentsInChildren(type: {prototype: T}): T[]; + getComponentsInChildren(className: string): any[]; + /** + !#en + If the component's bounding box is different from the node's, you can implement this method to supply + a custom axis aligned bounding box (AABB), so the editor's scene view can perform hit test properly. + !#zh + 如果组件的包围盒与节点不同,您可以实现该方法以提供自定义的轴向对齐的包围盒(AABB), + 以便编辑器的场景视图可以正确地执行点选测试。 + @param out_rect the Rect to receive the bounding box + */ + _getLocalBounds(out_rect: Rect): void; + /** + !#en + onRestore is called after the user clicks the Reset item in the Inspector's context menu or performs + an undo operation on this component.
+
+ If the component contains the "internal state", short for "temporary member variables which not included
+ in its CCClass properties", then you may need to implement this function.
+
+ The editor will call the getset accessors of your component to record/restore the component's state
+ for undo/redo operation. However, in extreme cases, it may not works well. Then you should implement
+ this function to manually synchronize your component's "internal states" with its public properties.
+ Once you implement this function, all the getset accessors of your component will not be called when
+ the user performs an undo/redo operation. Which means that only the properties with default value
+ will be recorded or restored by editor.
+
+ Similarly, the editor may failed to reset your component correctly in extreme cases. Then if you need
+ to support the reset menu, you should manually synchronize your component's "internal states" with its
+ properties in this function. Once you implement this function, all the getset accessors of your component
+ will not be called during reset operation. Which means that only the properties with default value
+ will be reset by editor. + + This function is only called in editor mode. + !#zh + onRestore 是用户在检查器菜单点击 Reset 时,对此组件执行撤消操作后调用的。
+
+ 如果组件包含了“内部状态”(不在 CCClass 属性中定义的临时成员变量),那么你可能需要实现该方法。
+
+ 编辑器执行撤销/重做操作时,将调用组件的 get set 来录制和还原组件的状态。然而,在极端的情况下,它可能无法良好运作。
+ 那么你就应该实现这个方法,手动根据组件的属性同步“内部状态”。一旦你实现这个方法,当用户撤销或重做时,组件的所有 get set 都不会再被调用。这意味着仅仅指定了默认值的属性将被编辑器记录和还原。
+
+ 同样的,编辑可能无法在极端情况下正确地重置您的组件。如果你需要支持组件重置菜单,则需要在该方法中手工同步组件属性到“内部状态”。一旦你实现这个方法,组件的所有 get set 都不会在重置操作时被调用。这意味着仅仅指定了默认值的属性将被编辑器重置。 +
+ 此方法仅在编辑器下会被调用。 + */ + onRestore(): void; + /** + !#en + Schedules a custom selector.
+ If the selector is already scheduled, then the interval parameter will be updated without scheduling it again. + !#zh + 调度一个自定义的回调函数。
+ 如果回调函数已调度,那么将不会重复调度它,只会更新时间间隔参数。 + @param callback The callback function + @param interval Tick interval in seconds. 0 means tick every frame. + @param repeat The selector will be executed (repeat + 1) times, you can use cc.macro.REPEAT_FOREVER for tick infinitely. + @param delay The amount of time that the first tick will wait before execution. Unit: s + + @example + ```js + var timeCallback = function (dt) { + cc.log("time: " + dt); + } + this.schedule(timeCallback, 1); + ``` + */ + schedule(callback: Function, interval?: number, repeat?: number, delay?: number): void; + /** + !#en Schedules a callback function that runs only once, with a delay of 0 or larger. + !#zh 调度一个只运行一次的回调函数,可以指定 0 让回调函数在下一帧立即执行或者在一定的延时之后执行。 + @param callback A function wrapped as a selector + @param delay The amount of time that the first tick will wait before execution. Unit: s + + @example + ```js + var timeCallback = function (dt) { + cc.log("time: " + dt); + } + this.scheduleOnce(timeCallback, 2); + ``` + */ + scheduleOnce(callback: Function, delay?: number): void; + /** + !#en Unschedules a custom callback function. + !#zh 取消调度一个自定义的回调函数。 + @param callback_fn A function wrapped as a selector + + @example + ```js + this.unschedule(_callback); + ``` + */ + unschedule(callback_fn: Function): void; + /** + !#en + unschedule all scheduled callback functions: custom callback functions, and the 'update' callback function.
+ Actions are not affected by this method. + !#zh 取消调度所有已调度的回调函数:定制的回调函数以及 `update` 回调函数。动作不受此方法影响。 + + @example + ```js + this.unscheduleAllCallbacks(); + ``` + */ + unscheduleAllCallbacks(): void; + } + /** !#en The Label Component. + !#zh 文字标签组件 */ + export class Label extends RenderComponent { + /** !#en Content string of label. + !#zh 标签显示的文本内容。 */ + string: string; + /** !#en Horizontal Alignment of label. + !#zh 文本内容的水平对齐方式。 */ + horizontalAlign: Label.HorizontalAlign; + /** !#en Vertical Alignment of label. + !#zh 文本内容的垂直对齐方式。 */ + verticalAlign: Label.VerticalAlign; + /** !#en The actual rendering font size in shrink mode + !#zh SHRINK 模式下面文本实际渲染的字体大小 */ + actualFontSize: number; + /** !#en Font size of label. + !#zh 文本字体大小。 */ + fontSize: number; + /** !#en Font family of label, only take effect when useSystemFont property is true. + !#zh 文本字体名称, 只在 useSystemFont 属性为 true 的时候生效。 */ + fontFamily: string; + /** !#en Line Height of label. + !#zh 文本行高。 */ + lineHeight: number; + /** !#en Overflow of label. + !#zh 文字显示超出范围时的处理方式。 */ + overflow: Label.Overflow; + /** !#en Whether auto wrap label when string width is large than label width. + !#zh 是否自动换行。 */ + enableWrapText: boolean; + /** !#en The font of label. + !#zh 文本字体。 */ + font: Font; + /** !#en Whether use system font name or not. + !#zh 是否使用系统字体。 */ + useSystemFont: boolean; + /** !#en The spacing of the x axis between characters, only take Effect when using bitmap fonts. + !#zh 文字之间 x 轴的间距,仅在使用位图字体时生效。 */ + spacingX: number; + /** !#en The cache mode of label. This mode only supports system fonts. + !#zh 文本缓存模式, 该模式只支持系统字体。 */ + cacheMode: Label.CacheMode; + /** !#en Whether enable bold. + !#zh 是否启用黑体。 */ + enableBold: boolean; + /** !#en Whether enable italic. + !#zh 是否启用黑体。 */ + enableItalic: boolean; + /** !#en Whether enable underline. + !#zh 是否启用下划线。 */ + enableUnderline: boolean; + /** !#en The height of underline. + !#zh 下划线高度。 */ + underlineHeight: number; + /** + !#zh 需要保证当前场景中没有使用CHAR缓存的Label才可以清除,否则已渲染的文字没有重新绘制会不显示 + !#en It can be cleared that need to ensure there is not use the CHAR cache in the current scene. Otherwise, the rendered text will not be displayed without repainting. + */ + static clearCharCache(): void; + } + /** !#en Outline effect used to change the display, only for system fonts or TTF fonts + !#zh 描边效果组件,用于字体描边,只能用于系统字体 */ + export class LabelOutline extends Component { + /** !#en outline color + !#zh 改变描边的颜色 */ + color: Color; + /** !#en Change the outline width + !#zh 改变描边的宽度 */ + width: number; + } + /** !#en + The Layout is a container component, use it to arrange child elements easily.
+ Note:
+ 1.Scaling and rotation of child nodes are not considered.
+ 2.After setting the Layout, the results need to be updated until the next frame, + unless you manually call {{#crossLink "Layout/updateLayout:method"}}{{/crossLink}}。 + !#zh + Layout 组件相当于一个容器,能自动对它的所有子节点进行统一排版。
+ 注意:
+ 1.不会考虑子节点的缩放和旋转。
+ 2.对 Layout 设置后结果需要到下一帧才会更新,除非你设置完以后手动调用 {{#crossLink "Layout/updateLayout:method"}}{{/crossLink}}。 */ + export class Layout extends Component { + /** !#en The layout type. + !#zh 布局类型 */ + type: Layout.Type; + /** !#en + The are three resize modes for Layout. + None, resize Container and resize children. + !#zh 缩放模式 */ + resizeMode: Layout.ResizeMode; + /** !#en The cell size for grid layout. + !#zh 每个格子的大小,只有布局类型为 GRID 的时候才有效。 */ + cellSize: Size; + /** !#en + The start axis for grid layout. If you choose horizontal, then children will layout horizontally at first, + and then break line on demand. Choose vertical if you want to layout vertically at first . + !#zh 起始轴方向类型,可进行水平和垂直布局排列,只有布局类型为 GRID 的时候才有效。 */ + startAxis: Layout.AxisDirection; + /** !#en The left padding of layout, it only effect the layout in one direction. + !#zh 容器内左边距,只会在一个布局方向上生效。 */ + paddingLeft: number; + /** !#en The right padding of layout, it only effect the layout in one direction. + !#zh 容器内右边距,只会在一个布局方向上生效。 */ + paddingRight: number; + /** !#en The top padding of layout, it only effect the layout in one direction. + !#zh 容器内上边距,只会在一个布局方向上生效。 */ + paddingTop: number; + /** !#en The bottom padding of layout, it only effect the layout in one direction. + !#zh 容器内下边距,只会在一个布局方向上生效。 */ + paddingBottom: number; + /** !#en The distance in x-axis between each element in layout. + !#zh 子节点之间的水平间距。 */ + spacingX: number; + /** !#en The distance in y-axis between each element in layout. + !#zh 子节点之间的垂直间距。 */ + spacingY: number; + /** !#en + Only take effect in Vertical layout mode. + This option changes the start element's positioning. + !#zh 垂直排列子节点的方向。 */ + verticalDirection: Layout.VerticalDirection; + /** !#en + Only take effect in Horizontal layout mode. + This option changes the start element's positioning. + !#zh 水平排列子节点的方向。 */ + horizontalDirection: Layout.HorizontalDirection; + /** !#en Adjust the layout if the children scaled. + !#zh 子节点缩放比例是否影响布局。 */ + affectedByScale: boolean; + /** + !#en Perform the layout update + !#zh 立即执行更新布局 + + @example + ```js + layout.type = cc.Layout.HORIZONTAL; + layout.node.addChild(childNode); + cc.log(childNode.x); // not yet changed + layout.updateLayout(); + cc.log(childNode.x); // changed + ``` + */ + updateLayout(): void; + } + /** !#en Shadow effect for Label component, only for system fonts or TTF fonts + !#zh 用于给 Label 组件添加阴影效果,只能用于系统字体或 ttf 字体 */ + export class LabelShadow extends Component { + /** !#en The shadow color + !#zh 阴影的颜色 */ + color: Color; + /** !#en Offset between font and shadow + !#zh 字体与阴影的偏移 */ + offset: Vec2; + /** !#en A non-negative float specifying the level of shadow blur + !#zh 阴影的模糊程度 */ + blur: number; + } + /** !#en The Mask Component + !#zh 遮罩组件 */ + export class Mask extends RenderComponent { + /** !#en The mask type. + !#zh 遮罩类型 */ + type: Mask.Type; + /** !#en The mask image + !#zh 遮罩所需要的贴图 */ + spriteFrame: SpriteFrame; + /** !#en + The alpha threshold.(Not supported Canvas Mode)
+ The content is drawn only where the stencil have pixel with alpha greater than the alphaThreshold.
+ Should be a float between 0 and 1.
+ This default to 0.1. + When it's set to 1, the stencil will discard all pixels, nothing will be shown. + !#zh + Alpha 阈值(不支持 Canvas 模式)
+ 只有当模板的像素的 alpha 大于等于 alphaThreshold 时,才会绘制内容。
+ 该数值 0 ~ 1 之间的浮点数,默认值为 0.1 + 当被设置为 1 时,会丢弃所有蒙版像素,所以不会显示任何内容 */ + alphaThreshold: number; + /** !#en Reverse mask (Not supported Canvas Mode) + !#zh 反向遮罩(不支持 Canvas 模式) */ + inverted: boolean; + /** TODO: remove segments, not supported by graphics + !#en The segements for ellipse mask. + !#zh 椭圆遮罩的曲线细分数 */ + segements: number; + } + /** !#en + cc.MotionStreak manages a Ribbon based on it's motion in absolute space.
+ You construct it with a fadeTime, minimum segment size, texture path, texture
+ length and color. The fadeTime controls how long it takes each vertex in
+ the streak to fade out, the minimum segment size it how many pixels the
+ streak will move before adding a new ribbon segment, and the texture
+ length is the how many pixels the texture is stretched across. The texture
+ is vertically aligned along the streak segment. + !#zh 运动轨迹,用于游戏对象的运动轨迹上实现拖尾渐隐效果。 */ + export class MotionStreak extends Component implements BlendFunc { + /** !#en + !#zh 在编辑器模式下预览拖尾效果。 */ + preview: boolean; + /** !#en The fade time to fade. + !#zh 拖尾的渐隐时间,以秒为单位。 */ + fadeTime: number; + /** !#en The minimum segment size. + !#zh 拖尾之间最小距离。 */ + minSeg: number; + /** !#en The stroke's width. + !#zh 拖尾的宽度。 */ + stroke: number; + /** !#en The texture of the MotionStreak. + !#zh 拖尾的贴图。 */ + texture: Texture2D; + /** !#en The color of the MotionStreak. + !#zh 拖尾的颜色 */ + color: Color; + /** !#en The fast Mode. + !#zh 是否启用了快速模式。当启用快速模式,新的点会被更快地添加,但精度较低。 */ + fastMode: boolean; + /** + !#en Remove all living segments of the ribbon. + !#zh 删除当前所有的拖尾片段。 + + @example + ```js + // Remove all living segments of the ribbon. + myMotionStreak.reset(); + ``` + */ + reset(): void; + /** !#en specify the source Blend Factor, this will generate a custom material object, please pay attention to the memory cost. + !#zh 指定原图的混合模式,这会克隆一个新的材质对象,注意这带来的开销 */ + srcBlendFactor: macro.BlendFactor; + /** !#en specify the destination Blend Factor. + !#zh 指定目标的混合模式 */ + dstBlendFactor: macro.BlendFactor; + } + /** !#en The PageView control + !#zh 页面视图组件 */ + export class PageView extends ScrollView { + /** !#en Specify the size type of each page in PageView. + !#zh 页面视图中每个页面大小类型 */ + sizeMode: PageView.SizeMode; + /** !#en The page view direction + !#zh 页面视图滚动类型 */ + direction: PageView.Direction; + /** !#en + The scroll threshold value, when drag exceeds this value, + release the next page will automatically scroll, less than the restore + !#zh 滚动临界值,默认单位百分比,当拖拽超出该数值时,松开会自动滚动下一页,小于时则还原。 */ + scrollThreshold: number; + /** !#en + Auto page turning velocity threshold. When users swipe the PageView quickly, + it will calculate a velocity based on the scroll distance and time, + if the calculated velocity is larger than the threshold, then it will trigger page turning. + !#zh + 快速滑动翻页临界值。 + 当用户快速滑动时,会根据滑动开始和结束的距离与时间计算出一个速度值, + 该值与此临界值相比较,如果大于临界值,则进行自动翻页。 */ + autoPageTurningThreshold: number; + /** !#en Change the PageTurning event timing of PageView. + !#zh 设置 PageView PageTurning 事件的发送时机。 */ + pageTurningEventTiming: number; + /** !#en The Page View Indicator + !#zh 页面视图指示器组件 */ + indicator: PageViewIndicator; + /** !#en The time required to turn over a page. unit: second + !#zh 每个页面翻页时所需时间。单位:秒 */ + pageTurningSpeed: number; + /** !#en PageView events callback + !#zh 滚动视图的事件回调函数 */ + pageEvents: Component.EventHandler[]; + /** + !#en Returns current page index + !#zh 返回当前页面索引 + */ + getCurrentPageIndex(): number; + /** + !#en Set current page index + !#zh 设置当前页面索引 + @param index index + */ + setCurrentPageIndex(index: number): void; + /** + !#en Returns all pages of pageview + !#zh 返回视图中的所有页面 + */ + getPages(): Node[]; + /** + !#en At the end of the current page view to insert a new view + !#zh 在当前页面视图的尾部插入一个新视图 + @param page page + */ + addPage(page: Node): void; + /** + !#en Inserts a page in the specified location + !#zh 将页面插入指定位置中 + @param page page + @param index index + */ + insertPage(page: Node, index: number): void; + /** + !#en Removes a page from PageView. + !#zh 移除指定页面 + @param page page + */ + removePage(page: Node): void; + /** + !#en Removes a page at index of PageView. + !#zh 移除指定下标的页面 + @param index index + */ + removePageAtIndex(index: number): void; + /** + !#en Removes all pages from PageView + !#zh 移除所有页面 + */ + removeAllPages(): void; + /** + !#en Scroll PageView to index. + !#zh 滚动到指定页面 + @param idx index of page. + @param timeInSecond scrolling time + */ + scrollToPage(idx: number, timeInSecond: number): void; + } + /** !#en The Page View Indicator Component + !#zh 页面视图每页标记组件 */ + export class PageViewIndicator extends Component { + /** !#en The spriteFrame for each element. + !#zh 每个页面标记显示的图片 */ + spriteFrame: SpriteFrame; + /** !#en The location direction of PageViewIndicator. + !#zh 页面标记摆放方向 */ + direction: PageViewIndicator.Direction; + /** !#en The cellSize for each element. + !#zh 每个页面标记的大小 */ + cellSize: Size; + /** !#en The distance between each element. + !#zh 每个页面标记之间的边距 */ + spacing: number; + /** + !#en Set Page View + !#zh 设置页面视图 + @param target target + */ + setPageView(target: PageView): void; + } + /** !#en + Visual indicator of progress in some operation. + Displays a bar to the user representing how far the operation has progressed. + !#zh + 进度条组件,可用于显示加载资源时的进度。 */ + export class ProgressBar extends Component { + /** !#en The targeted Sprite which will be changed progressively. + !#zh 用来显示进度条比例的 Sprite 对象。 */ + barSprite: Sprite; + /** !#en The progress mode, there are two modes supported now: horizontal and vertical. + !#zh 进度条的模式 */ + mode: ProgressBar.Mode; + /** !#en The total width or height of the bar sprite. + !#zh 进度条实际的总长度 */ + totalLength: number; + /** !#en The current progress of the bar sprite. The valid value is between 0-1. + !#zh 当前进度值,该数值的区间是 0-1 之间。 */ + progress: number; + /** !#en Whether reverse the progress direction of the bar sprite. + !#zh 进度条是否进行反方向变化。 */ + reverse: boolean; + } + /** !#en + Base class for components which supports rendering features. + !#zh + 所有支持渲染的组件的基类 */ + export class RenderComponent extends Component { + /** !#en The materials used by this render component. + !#zh 渲染组件使用的材质。 */ + sharedMaterials: Material[]; + /** + !#en Get the material by index. + !#zh 根据指定索引获取材质 + @param index index + */ + getMaterial(index: number): MaterialVariant; + /** + !#en Gets all the materials. + !#zh 获取所有材质。 + */ + getMaterials(): MaterialVariant[]; + /** + !#en Set the material by index. + !#zh 根据指定索引设置材质 + @param index index + @param material material + */ + setMaterial(index: number, material: Material): Material; + } + /** !#en The RichText Component. + !#zh 富文本组件 */ + export class RichText extends Component { + /** !#en Content string of RichText. + !#zh 富文本显示的文本内容。 */ + string: string; + /** !#en Horizontal Alignment of each line in RichText. + !#zh 文本内容的水平对齐方式。 */ + horizontalAlign: macro.TextAlignment; + /** !#en Font size of RichText. + !#zh 富文本字体大小。 */ + fontSize: number; + /** !#en Custom System font of RichText + !#zh 富文本定制系统字体 */ + fontFamily: string; + /** !#en Custom TTF font of RichText + !#zh 富文本定制字体 */ + font: TTFFont; + /** !#en Whether use system font name or not. + !#zh 是否使用系统字体。 */ + useSystemFont: boolean; + /** !#en The cache mode of label. This mode only supports system fonts. + !#zh 文本缓存模式, 该模式只支持系统字体。 */ + cacheMode: Label.CacheMode; + /** !#en The maximize width of the RichText + !#zh 富文本的最大宽度 */ + maxWidth: number; + /** !#en Line Height of RichText. + !#zh 富文本行高。 */ + lineHeight: number; + /** !#en The image atlas for the img tag. For each src value in the img tag, there should be a valid spriteFrame in the image atlas. + !#zh 对于 img 标签里面的 src 属性名称,都需要在 imageAtlas 里面找到一个有效的 spriteFrame,否则 img tag 会判定为无效。 */ + imageAtlas: SpriteAtlas; + /** !#en + Once checked, the RichText will block all input events (mouse and touch) within + the bounding box of the node, preventing the input from penetrating into the underlying node. + !#zh + 选中此选项后,RichText 将阻止节点边界框中的所有输入事件(鼠标和触摸),从而防止输入事件穿透到底层节点。 */ + handleTouchEvent: boolean; + } + /** !#en + This component is used to adjust the layout of current node to respect the safe area of a notched mobile device such as the iPhone X. + It is typically used for the top node of the UI interaction area. For specific usage, refer to the official [example-cases/02_ui/16_safeArea/SafeArea.fire](https://github.com/cocos-creator/example-cases). + + The concept of safe area is to give you a fixed inner rectangle in which you can safely display content that will be drawn on screen. + You are strongly discouraged from providing controls outside of this area. But your screen background could embellish edges. + + This component internally uses the API `cc.sys.getSafeAreaRect();` to obtain the safe area of the current iOS or Android device, + and implements the adaptation by using the Widget component and set anchor. + + !#zh + 该组件会将所在节点的布局适配到 iPhone X 等异形屏手机的安全区域内,通常用于 UI 交互区域的顶层节点,具体用法可参考官方范例 [example-cases/02_ui/16_safeArea/SafeArea.fire](https://github.com/cocos-creator/example-cases)。 + + 该组件内部通过 API `cc.sys.getSafeAreaRect();` 获取到当前 iOS 或 Android 设备的安全区域,并通过 Widget 组件实现适配。 */ + export class SafeArea extends Component { + /** + !#en Adapt to safe area + !#zh 立即适配安全区域 + + @example + ```js + let safeArea = this.node.addComponent(cc.SafeArea); + safeArea.updateArea(); + ``` + */ + updateArea(): void; + } + /** !#en + The Scrollbar control allows the user to scroll an image or other view that is too large to see completely + !#zh 滚动条组件 */ + export class Scrollbar extends Component { + /** !#en The "handle" part of the scrollbar. + !#zh 作为当前滚动区域位置显示的滑块 Sprite。 */ + handle: Sprite; + /** !#en The direction of scrollbar. + !#zh ScrollBar 的滚动方向。 */ + direction: Scrollbar.Direction; + /** !#en Whether enable auto hide or not. + !#zh 是否在没有滚动动作时自动隐藏 ScrollBar。 */ + enableAutoHide: boolean; + /** !#en + The time to hide scrollbar when scroll finished. + Note: This value is only useful when enableAutoHide is true. + !#zh + 没有滚动动作后经过多久会自动隐藏。 + 注意:只要当 “enableAutoHide” 为 true 时,才有效。 */ + autoHideTime: number; + } + /** !#en + Layout container for a view hierarchy that can be scrolled by the user, + allowing it to be larger than the physical display. + + !#zh + 滚动视图组件 */ + export class ScrollView extends Component { + /** !#en This is a reference to the UI element to be scrolled. + !#zh 可滚动展示内容的节点。 */ + content: Node; + /** !#en Enable horizontal scroll. + !#zh 是否开启水平滚动。 */ + horizontal: boolean; + /** !#en Enable vertical scroll. + !#zh 是否开启垂直滚动。 */ + vertical: boolean; + /** !#en When inertia is set, the content will continue to move when touch ended. + !#zh 是否开启滚动惯性。 */ + inertia: boolean; + /** !#en + It determines how quickly the content stop moving. A value of 1 will stop the movement immediately. + A value of 0 will never stop the movement until it reaches to the boundary of scrollview. + !#zh + 开启惯性后,在用户停止触摸后滚动多快停止,0表示永不停止,1表示立刻停止。 */ + brake: number; + /** !#en When elastic is set, the content will be bounce back when move out of boundary. + !#zh 是否允许滚动内容超过边界,并在停止触摸后回弹。 */ + elastic: boolean; + /** !#en The elapse time of bouncing back. A value of 0 will bounce back immediately. + !#zh 回弹持续的时间,0 表示将立即反弹。 */ + bounceDuration: number; + /** !#en The horizontal scrollbar reference. + !#zh 水平滚动的 ScrollBar。 */ + horizontalScrollBar: Scrollbar; + /** !#en The vertical scrollbar reference. + !#zh 垂直滚动的 ScrollBar。 */ + verticalScrollBar: Scrollbar; + /** !#en Scrollview events callback + !#zh 滚动视图的事件回调函数 */ + scrollEvents: Component.EventHandler[]; + /** !#en If cancelInnerEvents is set to true, the scroll behavior will cancel touch events on inner content nodes + It's set to true by default. + !#zh 如果这个属性被设置为 true,那么滚动行为会取消子节点上注册的触摸事件,默认被设置为 true。 + 注意,子节点上的 touchstart 事件仍然会触发,触点移动距离非常短的情况下 touchmove 和 touchend 也不会受影响。 */ + cancelInnerEvents: boolean; + /** + !#en Scroll the content to the bottom boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图底部。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the bottom boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the bottom of the view. + scrollView.scrollToBottom(0.1); + ``` + */ + scrollToBottom(timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the top boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图顶部。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the top boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the top of the view. + scrollView.scrollToTop(0.1); + ``` + */ + scrollToTop(timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the left boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图左边。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the left boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the left of the view. + scrollView.scrollToLeft(0.1); + ``` + */ + scrollToLeft(timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the right boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图右边。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the right boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the right of the view. + scrollView.scrollToRight(0.1); + ``` + */ + scrollToRight(timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the top left boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图左上角。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the top left boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the upper left corner of the view. + scrollView.scrollToTopLeft(0.1); + ``` + */ + scrollToTopLeft(timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the top right boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图右上角。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the top right boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the top right corner of the view. + scrollView.scrollToTopRight(0.1); + ``` + */ + scrollToTopRight(timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the bottom left boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图左下角。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the bottom left boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the lower left corner of the view. + scrollView.scrollToBottomLeft(0.1); + ``` + */ + scrollToBottomLeft(timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the bottom right boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图右下角。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the bottom right boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the lower right corner of the view. + scrollView.scrollToBottomRight(0.1); + ``` + */ + scrollToBottomRight(timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll with an offset related to the ScrollView's top left origin, if timeInSecond is omitted, then it will jump to the + specific offset immediately. + !#zh 视图内容在规定时间内将滚动到 ScrollView 相对左上角原点的偏移位置, 如果 timeInSecond参数不传,则立即滚动到指定偏移位置。 + @param offset A Vec2, the value of which each axis between 0 and maxScrollOffset + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the specific offset of ScrollView immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to middle position in 0.1 second in x-axis + let maxScrollOffset = this.getMaxScrollOffset(); + scrollView.scrollToOffset(cc.v2(maxScrollOffset.x / 2, 0), 0.1); + ``` + */ + scrollToOffset(offset: Vec2, timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Get the positive offset value corresponds to the content's top left boundary. + !#zh 获取滚动视图相对于左上角原点的当前滚动偏移 + */ + getScrollOffset(): Vec2; + /** + !#en Get the maximize available scroll offset + !#zh 获取滚动视图最大可以滚动的偏移量 + */ + getMaxScrollOffset(): Vec2; + /** + !#en Scroll the content to the horizontal percent position of ScrollView. + !#zh 视图内容在规定时间内将滚动到 ScrollView 水平方向的百分比位置上。 + @param percent A value between 0 and 1. + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the horizontal percent position of ScrollView immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to middle position. + scrollView.scrollToBottomRight(0.5, 0.1); + ``` + */ + scrollToPercentHorizontal(percent: number, timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the percent position of ScrollView in any direction. + !#zh 视图内容在规定时间内进行垂直方向和水平方向的滚动,并且滚动到指定百分比位置上。 + @param anchor A point which will be clamp between cc.v2(0,0) and cc.v2(1,1). + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the percent position of ScrollView immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Vertical scroll to the bottom of the view. + scrollView.scrollTo(cc.v2(0, 1), 0.1); + + // Horizontal scroll to view right. + scrollView.scrollTo(cc.v2(1, 0), 0.1); + ``` + */ + scrollTo(anchor: Vec2, timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the vertical percent position of ScrollView. + !#zh 视图内容在规定时间内滚动到 ScrollView 垂直方向的百分比位置上。 + @param percent A value between 0 and 1. + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the vertical percent position of ScrollView immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + // Scroll to middle position. + scrollView.scrollToPercentVertical(0.5, 0.1); + */ + scrollToPercentVertical(percent: number, timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Stop auto scroll immediately + !#zh 停止自动滚动, 调用此 API 可以让 Scrollview 立即停止滚动 + */ + stopAutoScroll(): void; + /** + !#en Modify the content position. + !#zh 设置当前视图内容的坐标点。 + @param position The position in content's parent space. + */ + setContentPosition(position: Vec2): void; + /** + !#en Query the content's position in its parent space. + !#zh 获取当前视图内容的坐标点。 + */ + getContentPosition(): Vec2; + /** + !#en Query whether the user is currently dragging the ScrollView to scroll it + !#zh 用户是否在拖拽当前滚动视图 + */ + isScrolling(): boolean; + /** + !#en Query whether the ScrollView is currently scrolling because of a bounceback or inertia slowdown. + !#zh 当前滚动视图是否在惯性滚动 + */ + isAutoScrolling(): boolean; + } + /** !#en The Slider Control + !#zh 滑动器组件 */ + export class Slider extends Component { + /** !#en The "handle" part of the slider + !#zh 滑动器滑块按钮部件 */ + handle: Button; + /** !#en The slider direction + !#zh 滑动器方向 */ + direction: Slider.Direction; + /** !#en The current progress of the slider. The valid value is between 0-1 + !#zh 当前进度值,该数值的区间是 0-1 之间 */ + progress: number; + /** !#en The slider slide events' callback array + !#zh 滑动器组件滑动事件回调函数数组 */ + slideEvents: Component.EventHandler[]; + } + /** !#en Renders a sprite in the scene. + !#zh 该组件用于在场景中渲染精灵。 */ + export class Sprite extends RenderComponent implements BlendFunc { + /** !#en The sprite frame of the sprite. + !#zh 精灵的精灵帧 */ + spriteFrame: SpriteFrame; + /** !#en The sprite render type. + !#zh 精灵渲染类型 */ + type: Sprite.Type; + /** !#en + The fill type, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”. + !#zh + 精灵填充类型,仅渲染类型设置为 cc.Sprite.Type.FILLED 时有效。 */ + fillType: Sprite.FillType; + /** !#en + The fill Center, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”. + !#zh + 填充中心点,仅渲染类型设置为 cc.Sprite.Type.FILLED 时有效。 */ + fillCenter: Vec2; + /** !#en + The fill Start, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”. + !#zh + 填充起始点,仅渲染类型设置为 cc.Sprite.Type.FILLED 时有效。 */ + fillStart: number; + /** !#en + The fill Range, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”. + !#zh + 填充范围,仅渲染类型设置为 cc.Sprite.Type.FILLED 时有效。 */ + fillRange: number; + /** !#en specify the frame is trimmed or not. + !#zh 是否使用裁剪模式 */ + trim: boolean; + /** !#en specify the size tracing mode. + !#zh 精灵尺寸调整模式 */ + sizeMode: Sprite.SizeMode; + /** + Change the state of sprite. + @param state NORMAL or GRAY State. + */ + setState(state: Sprite.State): void; + /** + Gets the current state. + */ + getState(): Sprite.State; + /** !#en specify the source Blend Factor, this will generate a custom material object, please pay attention to the memory cost. + !#zh 指定原图的混合模式,这会克隆一个新的材质对象,注意这带来的开销 */ + srcBlendFactor: macro.BlendFactor; + /** !#en specify the destination Blend Factor. + !#zh 指定目标的混合模式 */ + dstBlendFactor: macro.BlendFactor; + } + /** !#en The toggle component is a CheckBox, when it used together with a ToggleGroup, it + could be treated as a RadioButton. + !#zh Toggle 是一个 CheckBox,当它和 ToggleGroup 一起使用的时候,可以变成 RadioButton。 */ + export class Toggle extends Button implements GraySpriteState { + /** !#en When this value is true, the check mark component will be enabled, otherwise + the check mark component will be disabled. + !#zh 如果这个设置为 true,则 check mark 组件会处于 enabled 状态,否则处于 disabled 状态。 */ + isChecked: boolean; + /** !#en The toggle group which the toggle belongs to, when it is null, the toggle is a CheckBox. + Otherwise, the toggle is a RadioButton. + !#zh Toggle 所属的 ToggleGroup,这个属性是可选的。如果这个属性为 null,则 Toggle 是一个 CheckBox, + 否则,Toggle 是一个 RadioButton。 */ + toggleGroup: ToggleGroup; + /** !#en The image used for the checkmark. + !#zh Toggle 处于选中状态时显示的图片 */ + checkMark: Sprite; + /** !#en If Toggle is clicked, it will trigger event's handler + !#zh Toggle 按钮的点击事件列表。 */ + checkEvents: Component.EventHandler[]; + /** + !#en Make the toggle button checked. + !#zh 使 toggle 按钮处于选中状态 + */ + check(): void; + /** + !#en Make the toggle button unchecked. + !#zh 使 toggle 按钮处于未选中状态 + */ + uncheck(): void; + /** !#en The normal material. + !#zh 正常状态的材质。 */ + normalMaterial: Material; + /** !#en The gray material. + !#zh 置灰状态的材质。 */ + grayMaterial: Material; + } + /** !#en ToggleContainer is not a visiable UI component but a way to modify the behavior of a set of Toggles.
+ Toggles that belong to the same group could only have one of them to be switched on at a time.
+ Note: All the first layer child node containing the toggle component will auto be added to the container + !#zh ToggleContainer 不是一个可见的 UI 组件,它可以用来修改一组 Toggle 组件的行为。
+ 当一组 Toggle 属于同一个 ToggleContainer 的时候,任何时候只能有一个 Toggle 处于选中状态。
+ 注意:所有包含 Toggle 组件的一级子节点都会自动被添加到该容器中 */ + export class ToggleContainer extends Component { + /** !#en If this setting is true, a toggle could be switched off and on when pressed. + If it is false, it will make sure there is always only one toggle could be switched on + and the already switched on toggle can't be switched off. + !#zh 如果这个设置为 true, 那么 toggle 按钮在被点击的时候可以反复地被选中和未选中。 */ + allowSwitchOff: boolean; + /** !#en If Toggle is clicked, it will trigger event's handler + !#zh Toggle 按钮的点击事件列表。 */ + checkEvents: Component.EventHandler[]; + /** !#en Read only property, return the toggle items array reference managed by ToggleContainer. + !#zh 只读属性,返回 ToggleContainer 管理的 toggle 数组引用 */ + toggleItems: Toggle[]; + } + /** !#en ToggleGroup is not a visiable UI component but a way to modify the behavior of a set of Toggles. + Toggles that belong to the same group could only have one of them to be switched on at a time. + !#zh ToggleGroup 不是一个可见的 UI 组件,它可以用来修改一组 Toggle 组件的行为。当一组 Toggle 属于同一个 ToggleGroup 的时候, + 任何时候只能有一个 Toggle 处于选中状态。 */ + export class ToggleGroup extends Component { + /** !#en If this setting is true, a toggle could be switched off and on when pressed. + If it is false, it will make sure there is always only one toggle could be switched on + and the already switched on toggle can't be switched off. + !#zh 如果这个设置为 true, 那么 toggle 按钮在被点击的时候可以反复地被选中和未选中。 */ + allowSwitchOff: boolean; + /** !#en Read only property, return the toggle items array reference managed by toggleGroup. + !#zh 只读属性,返回 toggleGroup 管理的 toggle 数组引用 */ + toggleItems: any[]; + } + /** !#en + Handling touch events in a ViewGroup takes special care, + because it's common for a ViewGroup to have children that are targets for different touch events than the ViewGroup itself. + To make sure that each view correctly receives the touch events intended for it, + ViewGroup should register capture phase event and handle the event propagation properly. + Please refer to Scrollview for more information. + + !#zh + ViewGroup的事件处理比较特殊,因为 ViewGroup 里面的子节点关心的事件跟 ViewGroup 本身可能不一样。 + 为了让子节点能够正确地处理事件,ViewGroup 需要注册 capture 阶段的事件,并且合理地处理 ViewGroup 之间的事件传递。 + 请参考 ScrollView 的实现来获取更多信息。 */ + export class ViewGroup extends Component { + } + /** !#en + Stores and manipulate the anchoring based on its parent. + Widget are used for GUI but can also be used for other things. + Widget will adjust current node's position and size automatically, but the results after adjustment can not be obtained until the next frame unless you call {{#crossLink "Widget/updateAlignment:method"}}{{/crossLink}} manually. + !#zh + Widget 组件,用于设置和适配其相对于父节点的边距,Widget 通常被用于 UI 界面,也可以用于其他地方。 + Widget 会自动调整当前节点的坐标和宽高,不过目前调整后的结果要到下一帧才能在脚本里获取到,除非你先手动调用 {{#crossLink "Widget/updateAlignment:method"}}{{/crossLink}}。 */ + export class Widget extends Component { + /** !#en Specifies an alignment target that can only be one of the parent nodes of the current node. + The default value is null, and when null, indicates the current parent. + !#zh 指定一个对齐目标,只能是当前节点的其中一个父节点,默认为空,为空时表示当前父节点。 */ + target: Node; + /** !#en Whether to align the top. + !#zh 是否对齐上边。 */ + isAlignTop: boolean; + /** !#en + Vertically aligns the midpoint, This will open the other vertical alignment options cancel. + !#zh + 是否垂直方向对齐中点,开启此项会将垂直方向其他对齐选项取消。 */ + isAlignVerticalCenter: boolean; + /** !#en Whether to align the bottom. + !#zh 是否对齐下边。 */ + isAlignBottom: boolean; + /** !#en Whether to align the left. + !#zh 是否对齐左边 */ + isAlignLeft: boolean; + /** !#en + Horizontal aligns the midpoint. This will open the other horizontal alignment options canceled. + !#zh + 是否水平方向对齐中点,开启此选项会将水平方向其他对齐选项取消。 */ + isAlignHorizontalCenter: boolean; + /** !#en Whether to align the right. + !#zh 是否对齐右边。 */ + isAlignRight: boolean; + /** !#en + Whether the stretched horizontally, when enable the left and right alignment will be stretched horizontally, + the width setting is invalid (read only). + !#zh + 当前是否水平拉伸。当同时启用左右对齐时,节点将会被水平拉伸,此时节点的宽度只读。 */ + isStretchWidth: boolean; + /** !#en + Whether the stretched vertically, when enable the left and right alignment will be stretched vertically, + then height setting is invalid (read only) + !#zh + 当前是否垂直拉伸。当同时启用上下对齐时,节点将会被垂直拉伸,此时节点的高度只读。 */ + isStretchHeight: boolean; + /** !#en + The margins between the top of this node and the top of parent node, + the value can be negative, Only available in 'isAlignTop' open. + !#zh + 本节点顶边和父节点顶边的距离,可填写负值,只有在 isAlignTop 开启时才有作用。 */ + top: number; + /** !#en + The margins between the bottom of this node and the bottom of parent node, + the value can be negative, Only available in 'isAlignBottom' open. + !#zh + 本节点底边和父节点底边的距离,可填写负值,只有在 isAlignBottom 开启时才有作用。 */ + bottom: number; + /** !#en + The margins between the left of this node and the left of parent node, + the value can be negative, Only available in 'isAlignLeft' open. + !#zh + 本节点左边和父节点左边的距离,可填写负值,只有在 isAlignLeft 开启时才有作用。 */ + left: number; + /** !#en + The margins between the right of this node and the right of parent node, + the value can be negative, Only available in 'isAlignRight' open. + !#zh + 本节点右边和父节点右边的距离,可填写负值,只有在 isAlignRight 开启时才有作用。 */ + right: number; + /** !#en + Horizontal aligns the midpoint offset value, + the value can be negative, Only available in 'isAlignHorizontalCenter' open. + !#zh 水平居中的偏移值,可填写负值,只有在 isAlignHorizontalCenter 开启时才有作用。 */ + horizontalCenter: number; + /** !#en + Vertical aligns the midpoint offset value, + the value can be negative, Only available in 'isAlignVerticalCenter' open. + !#zh 垂直居中的偏移值,可填写负值,只有在 isAlignVerticalCenter 开启时才有作用。 */ + verticalCenter: number; + /** !#en If true, horizontalCenter is pixel margin, otherwise is percentage (0 - 1) margin. + !#zh 如果为 true,"horizontalCenter" 将会以像素作为偏移值,反之为百分比(0 到 1)。 */ + isAbsoluteHorizontalCenter: boolean; + /** !#en If true, verticalCenter is pixel margin, otherwise is percentage (0 - 1) margin. + !#zh 如果为 true,"verticalCenter" 将会以像素作为偏移值,反之为百分比(0 到 1)。 */ + isAbsoluteVerticalCenter: boolean; + /** !#en + If true, top is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's height. + !#zh + 如果为 true,"top" 将会以像素作为边距,否则将会以相对父物体高度的百分比(0 到 1)作为边距。 */ + isAbsoluteTop: boolean; + /** !#en + If true, bottom is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's height. + !#zh + 如果为 true,"bottom" 将会以像素作为边距,否则将会以相对父物体高度的百分比(0 到 1)作为边距。 */ + isAbsoluteBottom: boolean; + /** !#en + If true, left is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's width. + !#zh + 如果为 true,"left" 将会以像素作为边距,否则将会以相对父物体宽度的百分比(0 到 1)作为边距。 */ + isAbsoluteLeft: boolean; + /** !#en + If true, right is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's width. + !#zh + 如果为 true,"right" 将会以像素作为边距,否则将会以相对父物体宽度的百分比(0 到 1)作为边距。 */ + isAbsoluteRight: boolean; + /** !#en Specifies the alignment mode of the Widget, which determines when the widget should refresh. + !#zh 指定 Widget 的对齐模式,用于决定 Widget 应该何时刷新。 */ + alignMode: Widget.AlignMode; + /** + !#en + Immediately perform the widget alignment. You need to manually call this method only if + you need to get the latest results after the alignment before the end of current frame. + !#zh + 立刻执行 widget 对齐操作。这个接口一般不需要手工调用。 + 只有当你需要在当前帧结束前获得 widget 对齐后的最新结果时才需要手动调用这个方法。 + + @example + ```js + widget.top = 10; // change top margin + cc.log(widget.node.y); // not yet changed + widget.updateAlignment(); + cc.log(widget.node.y); // changed + ``` + */ + updateAlignment(): void; + /** !#en + When turned on, it will only be aligned once at the end of the onEnable frame, + then immediately disables the current component. + This will allow the script or animation to continue controlling the current node. + Note: It will still be aligned at the frame when onEnable is called. + !#zh + 开启后仅会在 onEnable 的当帧结束时对齐一次,然后立刻禁用当前组件。 + 这样便于脚本或动画继续控制当前节点。 + 注意:onEnable 时所在的那一帧仍然会进行对齐。 */ + isAlignOnce: boolean; + } + /** !#en SwanSubContextView is a view component which controls open data context viewport in WeChat game platform.
+ The component's node size decide the viewport of the sub context content in main context, + the entire sub context texture will be scaled to the node's bounding box area.
+ This component provides multiple important features:
+ 1. Sub context could use its own resolution size and policy.
+ 2. Sub context could be minized to smallest size it needed.
+ 3. Resolution of sub context content could be increased.
+ 4. User touch input is transformed to the correct viewport.
+ 5. Texture update is handled by this component. User don't need to worry.
+ One important thing to be noted, whenever the node's bounding box change, + you need to manually reset the viewport of sub context using updateSubContextViewport. + !#zh SwanSubContextView 可以用来控制百度小游戏平台开放数据域在主域中的视窗的位置。
+ 这个组件的节点尺寸决定了开放数据域内容在主域中的尺寸,整个开放数据域会被缩放到节点的包围盒范围内。
+ 在这个组件的控制下,用户可以更自由得控制开放数据域:
+ 1. 子域中可以使用独立的设计分辨率和适配模式
+ 2. 子域区域尺寸可以缩小到只容纳内容即可
+ 3. 子域的分辨率也可以被放大,以便获得更清晰的显示效果
+ 4. 用户输入坐标会被自动转换到正确的子域视窗中
+ 5. 子域内容贴图的更新由组件负责,用户不需要处理
+ 唯一需要注意的是,当子域节点的包围盒发生改变时,开发者需要使用 `updateSubContextViewport` 来手动更新子域视窗。 */ + export class SwanSubContextView extends Component { + /** + !#en Update the sub context viewport manually, it should be called whenever the node's bounding box changes. + !#zh 更新开放数据域相对于主域的 viewport,这个函数应该在节点包围盒改变时手动调用。 + */ + updateSubContextViewport(): void; + } + /** !#en WXSubContextView is a view component which controls open data context viewport in WeChat game platform.
+ The component's node size decide the viewport of the sub context content in main context, + the entire sub context texture will be scaled to the node's bounding box area.
+ This component provides multiple important features:
+ 1. Sub context could use its own resolution size and policy.
+ 2. Sub context could be minized to smallest size it needed.
+ 3. Resolution of sub context content could be increased.
+ 4. User touch input is transformed to the correct viewport.
+ 5. Texture update is handled by this component. User don't need to worry.
+ One important thing to be noted, whenever the node's bounding box change, + you need to manually reset the viewport of sub context using updateSubContextViewport. + !#zh WXSubContextView 可以用来控制微信小游戏平台开放数据域在主域中的视窗的位置。
+ 这个组件的节点尺寸决定了开放数据域内容在主域中的尺寸,整个开放数据域会被缩放到节点的包围盒范围内。
+ 在这个组件的控制下,用户可以更自由得控制开放数据域:
+ 1. 子域中可以使用独立的设计分辨率和适配模式
+ 2. 子域区域尺寸可以缩小到只容纳内容即可
+ 3. 子域的分辨率也可以被放大,以便获得更清晰的显示效果
+ 4. 用户输入坐标会被自动转换到正确的子域视窗中
+ 5. 子域内容贴图的更新由组件负责,用户不需要处理
+ 唯一需要注意的是,当子域节点的包围盒发生改变时,开发者需要使用 `updateSubContextViewport` 来手动更新子域视窗。 */ + export class WXSubContextView extends Component { + /** + !#en Reset open data context size and viewport + !#zh 重置开放数据域的尺寸和视窗 + */ + reset(): void; + /** + !#en Update the sub context viewport manually, it should be called whenever the node's bounding box changes. + !#zh 更新开放数据域相对于主域的 viewport,这个函数应该在节点包围盒改变时手动调用。 + */ + updateSubContextViewport(): void; + } + /** !#en The renderer object which provide access to render system APIs, + detailed APIs will be available progressively. + !#zh 提供基础渲染接口的渲染器对象,渲染层的基础接口将逐步开放给用户 */ + export class renderer { + /** !#en The render engine is available only after cc.game.EVENT_ENGINE_INITED event.
+ Normally it will be inited as the webgl render engine, but in wechat open context domain, + it will be inited as the canvas render engine. Canvas render engine is no longer available for other use case since v2.0. + !#zh 基础渲染引擎对象只在 cc.game.EVENT_ENGINE_INITED 事件触发后才可获取。
+ 大多数情况下,它都会是 WebGL 渲染引擎实例,但是在微信开放数据域当中,它会是 Canvas 渲染引擎实例。请注意,从 2.0 开始,我们在其他平台和环境下都废弃了 Canvas 渲染器。 */ + static renderEngine: any; + /** !#en The total draw call count in last rendered frame. + !#zh 上一次渲染帧所提交的渲染批次总数。 */ + static drawCalls: number; + } + /** !#en + EventTarget is an object to which an event is dispatched when something has occurred. + Entity are the most common event targets, but other objects can be event targets too. + + Event targets are an important part of the Fireball event model. + The event target serves as the focal point for how events flow through the scene graph. + When an event such as a mouse click or a keypress occurs, Fireball dispatches an event object + into the event flow from the root of the hierarchy. The event object then makes its way through + the scene graph until it reaches the event target, at which point it begins its return trip through + the scene graph. This round-trip journey to the event target is conceptually divided into three phases: + - The capture phase comprises the journey from the root to the last node before the event target's node + - The target phase comprises only the event target node + - The bubbling phase comprises any subsequent nodes encountered on the return trip to the root of the tree + See also: http://www.w3.org/TR/DOM-Level-3-Events/#event-flow + + Event targets can implement the following methods: + - _getCapturingTargets + - _getBubblingTargets + + !#zh + 事件目标是事件触发时,分派的事件对象,Node 是最常见的事件目标, + 但是其他对象也可以是事件目标。
*/ + export class EventTarget extends CallbacksInvoker { + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en + Register an callback of a specific event type on the EventTarget. + This type of event should be triggered via `emit`. + !#zh + 注册事件目标的特定事件类型回调。这种类型的事件应该被 `emit` 触发。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, node); + ``` + */ + on(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. + !#zh + 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + + @example + ```js + // register fire eventListener + var callback = eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, target); + // remove fire event listener + eventTarget.off('fire', callback, target); + // remove all fire event listeners + eventTarget.off('fire'); + ``` + */ + off(type: string, callback?: Function, target?: any): void; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.once('fire', function () { + cc.log("this is the callback and will be invoked only once"); + }, node); + ``` + */ + once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; + /** + !#en + Send an event with the event object. + !#zh + 通过事件对象派发事件 + @param event event + */ + dispatchEvent(event: Event): void; + } + /** !#en Base class of all kinds of events. + !#zh 包含事件相关信息的对象。 */ + export class Event { + /** + + @param type The name of the event (case-sensitive), e.g. "click", "fire", or "submit" + @param bubbles A boolean indicating whether the event bubbles up through the tree or not + */ + constructor(type: string, bubbles: boolean); + /** !#en The name of the event (case-sensitive), e.g. "click", "fire", or "submit". + !#zh 事件类型。 */ + type: string; + /** !#en Indicate whether the event bubbles up through the tree or not. + !#zh 表示该事件是否进行冒泡。 */ + bubbles: boolean; + /** !#en A reference to the target to which the event was originally dispatched. + !#zh 最初事件触发的目标 */ + target: any; + /** !#en A reference to the currently registered target for the event. + !#zh 当前目标 */ + currentTarget: any; + /** !#en + Indicates which phase of the event flow is currently being evaluated. + Returns an integer value represented by 4 constants: + - Event.NONE = 0 + - Event.CAPTURING_PHASE = 1 + - Event.AT_TARGET = 2 + - Event.BUBBLING_PHASE = 3 + The phases are explained in the [section 3.1, Event dispatch and DOM event flow] + (http://www.w3.org/TR/DOM-Level-3-Events/#event-flow), of the DOM Level 3 Events specification. + !#zh 事件阶段 */ + eventPhase: number; + /** + !#en Reset the event for being stored in the object pool. + !#zh 重置对象池中存储的事件。 + */ + unuse(): string; + /** + !#en Reuse the event for being used again by the object pool. + !#zh 用于对象池再次使用的事件。 + */ + reuse(): string; + /** + !#en Stops propagation for current event. + !#zh 停止传递当前事件。 + */ + stopPropagation(): void; + /** + !#en Stops propagation for current event immediately, + the event won't even be dispatched to the listeners attached in the current target. + !#zh 立即停止当前事件的传递,事件甚至不会被分派到所连接的当前目标。 + */ + stopPropagationImmediate(): void; + /** + !#en Checks whether the event has been stopped. + !#zh 检查该事件是否已经停止传递. + */ + isStopped(): boolean; + /** + !#en +

+ Gets current target of the event
+ note: It only be available when the event listener is associated with node.
+ It returns 0 when the listener is associated with fixed priority. +

+ !#zh 获取当前目标节点 + */ + getCurrentTarget(): Node; + /** + !#en Gets the event type. + !#zh 获取事件类型 + */ + getType(): string; + /** !#en Code for event without type. + !#zh 没有类型的事件 */ + static NO_TYPE: string; + /** !#en The type code of Touch event. + !#zh 触摸事件类型 */ + static TOUCH: string; + /** !#en The type code of Mouse event. + !#zh 鼠标事件类型 */ + static MOUSE: string; + /** !#en The type code of Keyboard event. + !#zh 键盘事件类型 */ + static KEYBOARD: string; + /** !#en The type code of Acceleration event. + !#zh 加速器事件类型 */ + static ACCELERATION: string; + /** !#en Events not currently dispatched are in this phase + !#zh 尚未派发事件阶段 */ + static NONE: number; + /** !#en + The capturing phase comprises the journey from the root to the last node before the event target's node + see http://www.w3.org/TR/DOM-Level-3-Events/#event-flow + !#zh 捕获阶段,包括事件目标节点之前从根节点到最后一个节点的过程。 */ + static CAPTURING_PHASE: number; + /** !#en + The target phase comprises only the event target node + see http://www.w3.org/TR/DOM-Level-3-Events/#event-flow + !#zh 目标阶段仅包括事件目标节点。 */ + static AT_TARGET: number; + /** !#en + The bubbling phase comprises any subsequent nodes encountered on the return trip to the root of the hierarchy + see http://www.w3.org/TR/DOM-Level-3-Events/#event-flow + !#zh 冒泡阶段, 包括回程遇到到层次根节点的任何后续节点。 */ + static BUBBLING_PHASE: number; + } + /** !#en + The System event, it currently supports keyboard events and accelerometer events.
+ You can get the SystemEvent instance with cc.systemEvent.
+ !#zh + 系统事件,它目前支持按键事件和重力感应事件。
+ 你可以通过 cc.systemEvent 获取到 SystemEvent 的实例。
*/ + export class SystemEvent extends EventTarget { + /** + !#en whether enable accelerometer event + !#zh 是否启用加速度计事件 + @param isEnable isEnable + */ + setAccelerometerEnabled(isEnable: boolean): void; + /** + !#en set accelerometer interval value + !#zh 设置加速度计间隔值 + @param interval interval + */ + setAccelerometerInterval(interval: number): void; + } + /** undefined */ + export class WorldManifold { + /** !#en + world contact point (point of intersection) + !#zh + 碰撞点集合 */ + points: Vec2[]; + /** !#en + world vector pointing from A to B + !#zh + 世界坐标系下由 A 指向 B 的向量 */ + normal: Vec2; + } + /** !#en + A manifold point is a contact point belonging to a contact manifold. + It holds details related to the geometry and dynamics of the contact points. + Note: the impulses are used for internal caching and may not + provide reliable contact forces, especially for high speed collisions. + !#zh + ManifoldPoint 是接触信息中的接触点信息。它拥有关于几何和接触点的详细信息。 + 注意:信息中的冲量用于系统内部缓存,提供的接触力可能不是很准确,特别是高速移动中的碰撞信息。 */ + export class ManifoldPoint { + /** !#en + The local point usage depends on the manifold type: + -e_circles: the local center of circleB + -e_faceA: the local center of circleB or the clip point of polygonB + -e_faceB: the clip point of polygonA + !#zh + 本地坐标点的用途取决于 manifold 的类型 + - e_circles: circleB 的本地中心点 + - e_faceA: circleB 的本地中心点 或者是 polygonB 的截取点 + - e_faceB: polygonB 的截取点 */ + localPoint: Vec2; + /** !#en + Normal impulse. + !#zh + 法线冲量。 */ + normalImpulse: number; + /** !#en + Tangent impulse. + !#zh + 切线冲量。 */ + tangentImpulse: number; + } + /** undefined */ + export class Manifold { + /** !#en + Manifold type : 0: e_circles, 1: e_faceA, 2: e_faceB + !#zh + Manifold 类型 : 0: e_circles, 1: e_faceA, 2: e_faceB */ + type: number; + /** !#en + The local point usage depends on the manifold type: + -e_circles: the local center of circleA + -e_faceA: the center of faceA + -e_faceB: the center of faceB + !#zh + 用途取决于 manifold 类型 + -e_circles: circleA 的本地中心点 + -e_faceA: faceA 的本地中心点 + -e_faceB: faceB 的本地中心点 */ + localPoint: Vec2; + /** !#en + -e_circles: not used + -e_faceA: the normal on polygonA + -e_faceB: the normal on polygonB + !#zh + -e_circles: 没被使用到 + -e_faceA: polygonA 的法向量 + -e_faceB: polygonB 的法向量 */ + localNormal: Vec2; + /** !#en + the points of contact. + !#zh + 接触点信息。 */ + points: ManifoldPoint[]; + } + /** !#en + Contact impulses for reporting. + !#zh + 用于返回给回调的接触冲量。 */ + export class PhysicsImpulse { + /** !#en + Normal impulses. + !#zh + 法线方向的冲量 */ + normalImpulses: any; + /** !#en + Tangent impulses + !#zh + 切线方向的冲量 */ + tangentImpulses: any; + } + /** !#en + PhysicsContact will be generated during begin and end collision as a parameter of the collision callback. + Note that contacts will be reused for speed up cpu time, so do not cache anything in the contact. + !#zh + 物理接触会在开始和结束碰撞之间生成,并作为参数传入到碰撞回调函数中。 + 注意:传入的物理接触会被系统进行重用,所以不要在使用中缓存里面的任何信息。 */ + export class PhysicsContact { + /** + !#en + Get the world manifold. + !#zh + 获取世界坐标系下的碰撞信息。 + */ + getWorldManifold(): WorldManifold; + /** + !#en + Get the manifold. + !#zh + 获取本地(局部)坐标系下的碰撞信息。 + */ + getManifold(): Manifold; + /** + !#en + Get the impulses. + Note: PhysicsImpulse can only used in onPostSolve callback. + !#zh + 获取冲量信息 + 注意:这个信息只有在 onPostSolve 回调中才能获取到 + */ + getImpulse(): PhysicsImpulse; + /** !#en + One of the collider that collided + !#zh + 发生碰撞的碰撞体之一 */ + colliderA: Collider; + /** !#en + One of the collider that collided + !#zh + 发生碰撞的碰撞体之一 */ + colliderB: Collider; + /** !#en + If set disabled to true, the contact will be ignored until contact end. + If you just want to disabled contact for current time step or sub-step, please use disabledOnce. + !#zh + 如果 disabled 被设置为 true,那么直到接触结束此接触都将被忽略。 + 如果只是希望在当前时间步或子步中忽略此接触,请使用 disabledOnce 。 */ + disabled: boolean; + /** !#en + Disabled contact for current time step or sub-step. + !#zh + 在当前时间步或子步中忽略此接触。 */ + disabledOnce: boolean; + /** + !#en + Is this contact touching? + !#zh + 返回碰撞体是否已经接触到。 + */ + isTouching(): boolean; + /** + !#en + Set the desired tangent speed for a conveyor belt behavior. + !#zh + 为传送带设置期望的切线速度 + @param tangentSpeed tangentSpeed + */ + setTangentSpeed(tangentSpeed: number): void; + /** + !#en + Get the desired tangent speed. + !#zh + 获取切线速度 + */ + getTangentSpeed(): number; + /** + !#en + Override the default friction mixture. You can call this in onPreSolve callback. + !#zh + 覆盖默认的摩擦力系数。你可以在 onPreSolve 回调中调用此函数。 + @param friction friction + */ + setFriction(friction: number): void; + /** + !#en + Get the friction. + !#zh + 获取当前摩擦力系数 + */ + getFriction(): number; + /** + !#en + Reset the friction mixture to the default value. + !#zh + 重置摩擦力系数到默认值 + */ + resetFriction(): void; + /** + !#en + Override the default restitution mixture. You can call this in onPreSolve callback. + !#zh + 覆盖默认的恢复系数。你可以在 onPreSolve 回调中调用此函数。 + @param restitution restitution + */ + setRestitution(restitution: number): void; + /** + !#en + Get the restitution. + !#zh + 获取当前恢复系数 + */ + getRestitution(): number; + /** + !#en + Reset the restitution mixture to the default value. + !#zh + 重置恢复系数到默认值 + */ + resetRestitution(): void; + } + /** !#en + Physics manager uses box2d as the inner physics system, and hide most box2d implement details(creating rigidbody, synchronize rigidbody info to node). + You can visit some common box2d function through physics manager(hit testing, raycast, debug info). + Physics manager distributes the collision information to each collision callback when collision is produced. + Note: You need first enable the collision listener in the rigidbody. + !#zh + 物理系统将 box2d 作为内部物理系统,并且隐藏了大部分 box2d 实现细节(比如创建刚体,同步刚体信息到节点中等)。 + 你可以通过物理系统访问一些 box2d 常用的功能,比如点击测试,射线测试,设置测试信息等。 + 物理系统还管理碰撞信息的分发,她会在产生碰撞时,将碰撞信息分发到各个碰撞回调中。 + 注意:你需要先在刚体中开启碰撞接听才会产生相应的碰撞回调。
+ 支持的物理系统指定绘制信息事件,请参阅 {{#crossLink "PhysicsManager.DrawBits"}}{{/crossLink}} */ + export class PhysicsManager implements EventTarget { + /** !#en + The ratio transform between physics unit and pixel unit, generally is 32. + !#zh + 物理单位与像素单位互相转换的比率,一般是 32。 */ + static PTM_RATIO: number; + /** !#en + The velocity iterations for the velocity constraint solver. + !#zh + 速度更新迭代数 */ + static VELOCITY_ITERATIONS: number; + /** !#en + The position Iterations for the position constraint solver. + !#zh + 位置迭代更新数 */ + static POSITION_ITERATIONS: number; + /** !#en + Specify the fixed time step. + Need enabledAccumulator to make it work. + !#zh + 指定固定的物理更新间隔时间,需要开启 enabledAccumulator 才有效。 */ + static FIXED_TIME_STEP: number; + /** !#en + Specify the max accumulator time. + Need enabledAccumulator to make it work. + !#zh + 每次可用于更新物理系统的最大时间,需要开启 enabledAccumulator 才有效。 */ + static MAX_ACCUMULATOR: number; + /** !#en + If enabled accumulator, then will call step function with the fixed time step FIXED_TIME_STEP. + And if the update dt is bigger than the time step, then will call step function several times. + If disabled accumulator, then will call step function with a time step calculated with the frame rate. + !#zh + 如果开启此选项,那么将会以固定的间隔时间 FIXED_TIME_STEP 来更新物理引擎,如果一个 update 的间隔时间大于 FIXED_TIME_STEP,则会对物理引擎进行多次更新。 + 如果关闭此选项,那么将会根据设定的 frame rate 计算出一个间隔时间来更新物理引擎。 */ + enabledAccumulator: boolean; + /** + !#en + Test which collider contains the given world point + !#zh + 获取包含给定世界坐标系点的碰撞体 + @param point the world point + */ + testPoint(point: Vec2): PhysicsCollider; + /** + !#en + Test which colliders intersect the given world rect + !#zh + 获取与给定世界坐标系矩形相交的碰撞体 + @param rect the world rect + */ + testAABB(rect: Rect): PhysicsCollider[]; + /** + !#en + Raycast the world for all colliders in the path of the ray. + The raycast ignores colliders that contain the starting point. + !#zh + 检测哪些碰撞体在给定射线的路径上,射线检测将忽略包含起始点的碰撞体。 + @param p1 start point of the raycast + @param p2 end point of the raycast + @param type optional, default is RayCastType.Closest + */ + rayCast(p1: Vec2, p2: Vec2, type: RayCastType): PhysicsRayCastResult[]; + /** !#en + Enabled the physics manager? + !#zh + 指定是否启用物理系统? */ + enabled: boolean; + /** !#en + Debug draw flags. + !#zh + 设置调试绘制标志 */ + debugDrawFlags: number; + /** !#en + The physics world gravity. + !#zh + 物理世界重力值 */ + gravity: Vec2; + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en + Register an callback of a specific event type on the EventTarget. + This type of event should be triggered via `emit`. + !#zh + 注册事件目标的特定事件类型回调。这种类型的事件应该被 `emit` 触发。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, node); + ``` + */ + on(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. + !#zh + 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + + @example + ```js + // register fire eventListener + var callback = eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, target); + // remove fire event listener + eventTarget.off('fire', callback, target); + // remove all fire event listeners + eventTarget.off('fire'); + ``` + */ + off(type: string, callback?: Function, target?: any): void; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.once('fire', function () { + cc.log("this is the callback and will be invoked only once"); + }, node); + ``` + */ + once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; + /** + !#en + Send an event with the event object. + !#zh + 通过事件对象派发事件 + @param event event + */ + dispatchEvent(event: Event): void; + } + /** undefined */ + export class PhysicsRayCastResult { + /** !#en + The PhysicsCollider which intersects with the raycast + !#zh + 与射线相交的碰撞体 */ + collider: PhysicsCollider; + /** !#en + The intersection point + !#zh + 射线与碰撞体相交的点 */ + point: Vec2; + /** !#en + The normal vector at the point of intersection + !#zh + 射线与碰撞体相交的点的法向量 */ + normal: Vec2; + /** !#en + The fraction of the raycast path at the point of intersection + !#zh + 射线与碰撞体相交的点占射线长度的分数 */ + fraction: number; + } + /** !#en Enum for RigidBodyType. + !#zh 刚体类型 */ + export enum RigidBodyType { + Static = 0, + Kinematic = 0, + Dynamic = 0, + Animated = 0, + } + /** !#en Enum for RayCastType. + !#zh 射线检测类型 */ + export enum RayCastType { + Closest = 0, + Any = 0, + AllClosest = 0, + All = 0, + } + /** undefined */ + export class RigidBody extends Component { + /** !#en + Should enabled contact listener? + When a collision is trigger, the collision callback will only be called when enabled contact listener. + !#zh + 是否启用接触接听器。 + 当 collider 产生碰撞时,只有开启了接触接听器才会调用相应的回调函数 */ + enabledContactListener: boolean; + /** + !#en + Collision callback. + Called when two collider begin to touch. + !#zh + 碰撞回调。 + 如果你的脚本中实现了这个函数,那么它将会在两个碰撞体开始接触时被调用。 + @param contact contact information + @param selfCollider the collider belong to this rigidbody + @param otherCollider the collider belong to another rigidbody + */ + onBeginContact(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void; + /** + !#en + Collision callback. + Called when two collider cease to touch. + !#zh + 碰撞回调。 + 如果你的脚本中实现了这个函数,那么它将会在两个碰撞体停止接触时被调用。 + @param contact contact information + @param selfCollider the collider belong to this rigidbody + @param otherCollider the collider belong to another rigidbody + */ + onEndContact(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void; + /** + !#en + Collision callback. + This is called when a contact is updated. + This allows you to inspect a contact before it goes to the solver(e.g. disable contact). + Note: this is called only for awake bodies. + Note: this is called even when the number of contact points is zero. + Note: this is not called for sensors. + !#zh + 碰撞回调。 + 如果你的脚本中实现了这个函数,那么它将会在接触更新时被调用。 + 你可以在接触被处理前根据他包含的信息作出相应的处理,比如将这个接触禁用掉。 + 注意:回调只会为醒着的刚体调用。 + 注意:接触点为零的时候也有可能被调用。 + 注意:感知体(sensor)的回调不会被调用。 + @param contact contact information + @param selfCollider the collider belong to this rigidbody + @param otherCollider the collider belong to another rigidbody + */ + onPreSolve(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void; + /** + !#en + Collision callback. + This is called after a contact is updated. + You can get the impulses from the contact in this callback. + !#zh + 碰撞回调。 + 如果你的脚本中实现了这个函数,那么它将会在接触更新完后被调用。 + 你可以在这个回调中从接触信息中获取到冲量信息。 + @param contact contact information + @param selfCollider the collider belong to this rigidbody + @param otherCollider the collider belong to another rigidbody + */ + onPostSolve(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void; + /** !#en + Is this a fast moving body that should be prevented from tunneling through + other moving bodies? + Note : + - All bodies are prevented from tunneling through kinematic and static bodies. This setting is only considered on dynamic bodies. + - You should use this flag sparingly since it increases processing time. + !#zh + 这个刚体是否是一个快速移动的刚体,并且需要禁止穿过其他快速移动的刚体? + 需要注意的是 : + - 所有刚体都被禁止从 运动刚体 和 静态刚体 中穿过。此选项只关注于 动态刚体。 + - 应该尽量少的使用此选项,因为它会增加程序处理时间。 */ + bullet: boolean; + /** !#en + Rigidbody type : Static, Kinematic, Dynamic or Animated. + !#zh + 刚体类型: Static, Kinematic, Dynamic or Animated. */ + type: RigidBodyType; + /** !#en + Set this flag to false if this body should never fall asleep. + Note that this increases CPU usage. + !#zh + 如果此刚体永远都不应该进入睡眠,那么设置这个属性为 false。 + 需要注意这将使 CPU 占用率提高。 */ + allowSleep: boolean; + /** !#en + Scale the gravity applied to this body. + !#zh + 缩放应用在此刚体上的重力值 */ + gravityScale: number; + /** !#en + Linear damping is use to reduce the linear velocity. + The damping parameter can be larger than 1, but the damping effect becomes sensitive to the + time step when the damping parameter is large. + !#zh + Linear damping 用于衰减刚体的线性速度。衰减系数可以大于 1,但是当衰减系数比较大的时候,衰减的效果会变得比较敏感。 */ + linearDamping: number; + /** !#en + Angular damping is use to reduce the angular velocity. The damping parameter + can be larger than 1 but the damping effect becomes sensitive to the + time step when the damping parameter is large. + !#zh + Angular damping 用于衰减刚体的角速度。衰减系数可以大于 1,但是当衰减系数比较大的时候,衰减的效果会变得比较敏感。 */ + angularDamping: number; + /** !#en + The linear velocity of the body's origin in world co-ordinates. + !#zh + 刚体在世界坐标下的线性速度 */ + linearVelocity: Vec2; + /** !#en + The angular velocity of the body. + !#zh + 刚体的角速度 */ + angularVelocity: number; + /** !#en + Should this body be prevented from rotating? + !#zh + 是否禁止此刚体进行旋转 */ + fixedRotation: boolean; + /** !#en + Set the sleep state of the body. A sleeping body has very low CPU cost.(When the rigid body is hit, if the rigid body is in sleep state, it will be immediately awakened.) + !#zh + 设置刚体的睡眠状态。 睡眠的刚体具有非常低的 CPU 成本。(当刚体被碰撞到时,如果刚体处于睡眠状态,它会立即被唤醒) */ + awake: boolean; + /** !#en + Whether to wake up this rigid body during initialization + !#zh + 是否在初始化时唤醒此刚体 */ + awakeOnLoad: boolean; + /** !#en + Set the active state of the body. An inactive body is not + simulated and cannot be collided with or woken up. + If body is active, all fixtures will be added to the + broad-phase. + If body is inactive, all fixtures will be removed from + the broad-phase and all contacts will be destroyed. + Fixtures on an inactive body are implicitly inactive and will + not participate in collisions, ray-casts, or queries. + Joints connected to an inactive body are implicitly inactive. + !#zh + 设置刚体的激活状态。一个非激活状态下的刚体是不会被模拟和碰撞的,不管它是否处于睡眠状态下。 + 如果刚体处于激活状态下,所有夹具会被添加到 粗测阶段(broad-phase)。 + 如果刚体处于非激活状态下,所有夹具会被从 粗测阶段(broad-phase)中移除。 + 在非激活状态下的夹具不会参与到碰撞,射线,或者查找中 + 链接到非激活状态下刚体的关节也是非激活的。 */ + active: boolean; + /** + !#en + Gets a local point relative to the body's origin given a world point. + !#zh + 将一个给定的世界坐标系下的点转换为刚体本地坐标系下的点 + @param worldPoint a point in world coordinates. + @param out optional, the receiving point + */ + getLocalPoint(worldPoint: Vec2, out: Vec2): Vec2; + /** + !#en + Get the world coordinates of a point given the local coordinates. + !#zh + 将一个给定的刚体本地坐标系下的点转换为世界坐标系下的点 + @param localPoint a point in local coordinates. + @param out optional, the receiving point + */ + getWorldPoint(localPoint: Vec2, out: Vec2): Vec2; + /** + !#en + Get the world coordinates of a vector given the local coordinates. + !#zh + 将一个给定的世界坐标系下的向量转换为刚体本地坐标系下的向量 + @param localVector a vector in world coordinates. + @param out optional, the receiving vector + */ + getWorldVector(localVector: Vec2, out: Vec2): Vec2; + /** + !#en + Gets a local vector relative to the body's origin given a world vector. + !#zh + 将一个给定的世界坐标系下的点转换为刚体本地坐标系下的点 + @param worldVector a vector in world coordinates. + @param out optional, the receiving vector + */ + getLocalVector(worldVector: Vec2, out: Vec2): Vec2; + /** + !#en + Get the world body origin position. + !#zh + 获取刚体世界坐标系下的原点值 + @param out optional, the receiving point + */ + getWorldPosition(out: Vec2): Vec2; + /** + !#en + Get the world body rotation angle. + !#zh + 获取刚体世界坐标系下的旋转值。 + */ + getWorldRotation(): number; + /** + !#en + Get the local position of the center of mass. + !#zh + 获取刚体本地坐标系下的质心 + */ + getLocalCenter(): Vec2; + /** + !#en + Get the world position of the center of mass. + !#zh + 获取刚体世界坐标系下的质心 + */ + getWorldCenter(): Vec2; + /** + !#en + Get the world linear velocity of a world point attached to this body. + !#zh + 获取刚体上指定点的线性速度 + @param worldPoint a point in world coordinates. + @param out optional, the receiving point + */ + getLinearVelocityFromWorldPoint(worldPoint: Vec2, out: Vec2): Vec2; + /** + !#en + Get total mass of the body. + !#zh + 获取刚体的质量。 + */ + getMass(): number; + /** + !#en + Get the rotational inertia of the body about the local origin. + !#zh + 获取刚体本地坐标系下原点的旋转惯性 + */ + getInertia(): number; + /** + !#en + Get all the joints connect to the rigidbody. + !#zh + 获取链接到此刚体的所有关节 + */ + getJointList(): Joint[]; + /** + !#en + Apply a force at a world point. If the force is not + applied at the center of mass, it will generate a torque and + affect the angular velocity. + !#zh + 施加一个力到刚体上的一个点。如果力没有施加到刚体的质心上,还会产生一个扭矩并且影响到角速度。 + @param force the world force vector. + @param point the world position. + @param wake also wake up the body. + */ + applyForce(force: Vec2, point: Vec2, wake: boolean): void; + /** + !#en + Apply a force to the center of mass. + !#zh + 施加一个力到刚体上的质心上。 + @param force the world force vector. + @param wake also wake up the body. + */ + applyForceToCenter(force: Vec2, wake: boolean): void; + /** + !#en + Apply a torque. This affects the angular velocity. + !#zh + 施加一个扭矩力,将影响刚体的角速度 + @param torque about the z-axis (out of the screen), usually in N-m. + @param wake also wake up the body + */ + applyTorque(torque: number, wake: boolean): void; + /** + !#en + Apply a impulse at a world point, This immediately modifies the velocity. + If the impulse is not applied at the center of mass, it will generate a torque and + affect the angular velocity. + !#zh + 施加冲量到刚体上的一个点,将立即改变刚体的线性速度。 + 如果冲量施加到的点不是刚体的质心,那么将产生一个扭矩并影响刚体的角速度。 + @param impulse the world impulse vector, usually in N-seconds or kg-m/s. + @param point the world position + @param wake alse wake up the body + */ + applyLinearImpulse(impulse: Vec2, point: Vec2, wake: boolean): void; + /** + !#en + Apply an angular impulse. + !#zh + 施加一个角速度冲量。 + @param impulse the angular impulse in units of kg*m*m/s + @param wake also wake up the body + */ + applyAngularImpulse(impulse: number, wake: boolean): void; + /** + !#en + Synchronize node's world position to box2d rigidbody's position. + If enableAnimated is true and rigidbody's type is Animated type, + will set linear velocity instead of directly set rigidbody's position. + !#zh + 同步节点的世界坐标到 box2d 刚体的坐标上。 + 如果 enableAnimated 是 true,并且刚体的类型是 Animated ,那么将设置刚体的线性速度来代替直接设置刚体的位置。 + @param enableAnimated enableAnimated + */ + syncPosition(enableAnimated: boolean): void; + /** + !#en + Synchronize node's world angle to box2d rigidbody's angle. + If enableAnimated is true and rigidbody's type is Animated type, + will set angular velocity instead of directly set rigidbody's angle. + !#zh + 同步节点的世界旋转角度值到 box2d 刚体的旋转值上。 + 如果 enableAnimated 是 true,并且刚体的类型是 Animated ,那么将设置刚体的角速度来代替直接设置刚体的角度。 + @param enableAnimated enableAnimated + */ + syncRotation(enableAnimated: boolean): void; + } + /** undefined */ + export class Graphics extends RenderComponent { + /** !#en + Current line width. + !#zh + 当前线条宽度 */ + lineWidth: number; + /** !#en + lineJoin determines how two connecting segments (of lines, arcs or curves) with non-zero lengths in a shape are joined together. + !#zh + lineJoin 用来设置2个长度不为0的相连部分(线段,圆弧,曲线)如何连接在一起的属性。 */ + lineJoin: Graphics.LineJoin; + /** !#en + lineCap determines how the end points of every line are drawn. + !#zh + lineCap 指定如何绘制每一条线段末端。 */ + lineCap: Graphics.LineCap; + /** !#en + stroke color + !#zh + 线段颜色 */ + strokeColor: Color; + /** !#en + fill color + !#zh + 填充颜色 */ + fillColor: Color; + /** !#en + Sets the miter limit ratio + !#zh + 设置斜接面限制比例 */ + miterLimit: number; + /** + !#en Move path start point to (x,y). + !#zh 移动路径起点到坐标(x, y) + @param x The x axis of the coordinate for the end point. + @param y The y axis of the coordinate for the end point. + */ + moveTo(x?: number, y?: number): void; + /** + !#en Adds a straight line to the path + !#zh 绘制直线路径 + @param x The x axis of the coordinate for the end point. + @param y The y axis of the coordinate for the end point. + */ + lineTo(x?: number, y?: number): void; + /** + !#en Adds a cubic Bézier curve to the path + !#zh 绘制三次贝赛尔曲线路径 + @param c1x The x axis of the coordinate for the first control point. + @param c1y The y axis of the coordinate for first control point. + @param c2x The x axis of the coordinate for the second control point. + @param c2y The y axis of the coordinate for the second control point. + @param x The x axis of the coordinate for the end point. + @param y The y axis of the coordinate for the end point. + */ + bezierCurveTo(c1x?: number, c1y?: number, c2x?: number, c2y?: number, x?: number, y?: number): void; + /** + !#en Adds a quadratic Bézier curve to the path + !#zh 绘制二次贝赛尔曲线路径 + @param cx The x axis of the coordinate for the control point. + @param cy The y axis of the coordinate for the control point. + @param x The x axis of the coordinate for the end point. + @param y The y axis of the coordinate for the end point. + */ + quadraticCurveTo(cx?: number, cy?: number, x?: number, y?: number): void; + /** + !#en Adds an arc to the path which is centered at (cx, cy) position with radius r starting at startAngle and ending at endAngle going in the given direction by counterclockwise (defaulting to false). + !#zh 绘制圆弧路径。圆弧路径的圆心在 (cx, cy) 位置,半径为 r ,根据 counterclockwise (默认为false)指定的方向从 startAngle 开始绘制,到 endAngle 结束。 + @param cx The x axis of the coordinate for the center point. + @param cy The y axis of the coordinate for the center point. + @param r The arc's radius. + @param startAngle The angle at which the arc starts, measured clockwise from the positive x axis and expressed in radians. + @param endAngle The angle at which the arc ends, measured clockwise from the positive x axis and expressed in radians. + @param counterclockwise An optional Boolean which, if true, causes the arc to be drawn counter-clockwise between the two angles. By default it is drawn clockwise. + */ + arc(cx?: number, cy?: number, r?: number, startAngle?: number, endAngle?: number, counterclockwise?: boolean): void; + /** + !#en Adds an ellipse to the path. + !#zh 绘制椭圆路径。 + @param cx The x axis of the coordinate for the center point. + @param cy The y axis of the coordinate for the center point. + @param rx The ellipse's x-axis radius. + @param ry The ellipse's y-axis radius. + */ + ellipse(cx?: number, cy?: number, rx?: number, ry?: number): void; + /** + !#en Adds an circle to the path. + !#zh 绘制圆形路径。 + @param cx The x axis of the coordinate for the center point. + @param cy The y axis of the coordinate for the center point. + @param r The circle's radius. + */ + circle(cx?: number, cy?: number, r?: number): void; + /** + !#en Adds an rectangle to the path. + !#zh 绘制矩形路径。 + @param x The x axis of the coordinate for the rectangle starting point. + @param y The y axis of the coordinate for the rectangle starting point. + @param w The rectangle's width. + @param h The rectangle's height. + */ + rect(x?: number, y?: number, w?: number, h?: number): void; + /** + !#en Adds an round corner rectangle to the path. + !#zh 绘制圆角矩形路径。 + @param x The x axis of the coordinate for the rectangle starting point. + @param y The y axis of the coordinate for the rectangle starting point. + @param w The rectangles width. + @param h The rectangle's height. + @param r The radius of the rectangle. + */ + roundRect(x?: number, y?: number, w?: number, h?: number, r?: number): void; + /** + !#en Draws a filled rectangle. + !#zh 绘制填充矩形。 + @param x The x axis of the coordinate for the rectangle starting point. + @param y The y axis of the coordinate for the rectangle starting point. + @param w The rectangle's width. + @param h The rectangle's height. + */ + fillRect(x?: number, y?: number, w?: number, h?: number): void; + /** + !#en Erasing any previously drawn content. + !#zh 擦除之前绘制的所有内容的方法。 + @param clean Whether to clean the graphics inner cache. + */ + clear(clean?: boolean): void; + /** + !#en Causes the point of the pen to move back to the start of the current path. It tries to add a straight line from the current point to the start. + !#zh 将笔点返回到当前路径起始点的。它尝试从当前点到起始点绘制一条直线。 + */ + close(): void; + /** + !#en Strokes the current or given path with the current stroke style. + !#zh 根据当前的画线样式,绘制当前或已经存在的路径。 + */ + stroke(): void; + /** + !#en Fills the current or given path with the current fill style. + !#zh 根据当前的画线样式,填充当前或已经存在的路径。 + */ + fill(): void; + } + /** !#en the device accelerometer reports values for each axis in units of g-force. + !#zh 设备重力传感器传递的各个轴的数据。 */ + export class constructor { + /** + whether enable accelerometer event + @param isEnable isEnable + */ + setAccelerometerEnabled(isEnable: boolean): void; + /** + set accelerometer interval value + @param interval interval + */ + setAccelerometerInterval(interval: number): void; + } + /** undefined */ + export enum VerticalTextAlignment { + TOP = 0, + CENTER = 0, + BOTTOM = 0, + } + /** The base class of most of all the objects in Fireball. */ + export class Object { + /** !#en The name of the object. + !#zh 该对象的名称。 */ + name: string; + /** !#en + Indicates whether the object is not yet destroyed. (It will not be available after being destroyed)
+ When an object's `destroy` is called, it is actually destroyed after the end of this frame. + So `isValid` will return false from the next frame, while `isValid` in the current frame will still be true. + If you want to determine whether the current frame has called `destroy`, use `cc.isValid(obj, true)`, + but this is often caused by a particular logical requirements, which is not normally required. + + !#zh + 表示该对象是否可用(被 destroy 后将不可用)。
+ 当一个对象的 `destroy` 调用以后,会在这一帧结束后才真正销毁。因此从下一帧开始 `isValid` 就会返回 false,而当前帧内 `isValid` 仍然会是 true。如果希望判断当前帧是否调用过 `destroy`,请使用 `cc.isValid(obj, true)`,不过这往往是特殊的业务需求引起的,通常情况下不需要这样。 */ + isValid: boolean; + /** + !#en + Destroy this Object, and release all its own references to other objects.
+ Actual object destruction will delayed until before rendering. + From the next frame, this object is not usable anymore. + You can use `cc.isValid(obj)` to check whether the object is destroyed before accessing it. + !#zh + 销毁该对象,并释放所有它对其它对象的引用。
+ 实际销毁操作会延迟到当前帧渲染前执行。从下一帧开始,该对象将不再可用。 + 您可以在访问对象之前使用 `cc.isValid(obj)` 来检查对象是否已被销毁。 + + @example + ```js + obj.destroy(); + ``` + */ + destroy(): boolean; + } + /** Bit mask that controls object states. */ + export enum Flags { + DontSave = 0, + EditorOnly = 0, + HideInHierarchy = 0, + } + /** The fullscreen API provides an easy way for web content to be presented using the user's entire screen. + It's invalid on safari, QQbrowser and android browser */ + export class screen { + /** + initialize + */ + init(): void; + /** + return true if it's full now. + */ + fullScreen(): boolean; + /** + change the screen to full mode. + @param element element + @param onFullScreenChange onFullScreenChange + @param onFullScreenError onFullScreenError + */ + requestFullScreen(element: Element, onFullScreenChange: Function, onFullScreenError: Function): void; + /** + exit the full mode. + */ + exitFullScreen(): boolean; + /** + Automatically request full screen with a touch/click event + @param element element + @param onFullScreenChange onFullScreenChange + */ + autoFullScreen(element: Element, onFullScreenChange: Function): void; + } + /** System variables */ + export class sys { + /** English language code */ + static LANGUAGE_ENGLISH: string; + /** Chinese language code */ + static LANGUAGE_CHINESE: string; + /** French language code */ + static LANGUAGE_FRENCH: string; + /** Italian language code */ + static LANGUAGE_ITALIAN: string; + /** German language code */ + static LANGUAGE_GERMAN: string; + /** Spanish language code */ + static LANGUAGE_SPANISH: string; + /** Spanish language code */ + static LANGUAGE_DUTCH: string; + /** Russian language code */ + static LANGUAGE_RUSSIAN: string; + /** Korean language code */ + static LANGUAGE_KOREAN: string; + /** Japanese language code */ + static LANGUAGE_JAPANESE: string; + /** Hungarian language code */ + static LANGUAGE_HUNGARIAN: string; + /** Portuguese language code */ + static LANGUAGE_PORTUGUESE: string; + /** Arabic language code */ + static LANGUAGE_ARABIC: string; + /** Norwegian language code */ + static LANGUAGE_NORWEGIAN: string; + /** Polish language code */ + static LANGUAGE_POLISH: string; + /** Turkish language code */ + static LANGUAGE_TURKISH: string; + /** Ukrainian language code */ + static LANGUAGE_UKRAINIAN: string; + /** Romanian language code */ + static LANGUAGE_ROMANIAN: string; + /** Bulgarian language code */ + static LANGUAGE_BULGARIAN: string; + /** Unknown language code */ + static LANGUAGE_UNKNOWN: string; + static OS_IOS: string; + static OS_ANDROID: string; + static OS_WINDOWS: string; + static OS_MARMALADE: string; + static OS_LINUX: string; + static OS_BADA: string; + static OS_BLACKBERRY: string; + static OS_OSX: string; + static OS_WP8: string; + static OS_WINRT: string; + static OS_UNKNOWN: string; + static UNKNOWN: number; + static WIN32: number; + static LINUX: number; + static MACOS: number; + static ANDROID: number; + static IPHONE: number; + static IPAD: number; + static BLACKBERRY: number; + static NACL: number; + static EMSCRIPTEN: number; + static TIZEN: number; + static WINRT: number; + static WP8: number; + static MOBILE_BROWSER: number; + static DESKTOP_BROWSER: number; + /** Indicates whether executes in editor's window process (Electron's renderer context) */ + static EDITOR_PAGE: number; + /** Indicates whether executes in editor's main process (Electron's browser context) */ + static EDITOR_CORE: number; + static WECHAT_GAME: number; + static QQ_PLAY: number; + static FB_PLAYABLE_ADS: number; + static BAIDU_GAME: number; + static VIVO_GAME: number; + static OPPO_GAME: number; + static HUAWEI_GAME: number; + static XIAOMI_GAME: number; + static JKW_GAME: number; + static ALIPAY_GAME: number; + static WECHAT_GAME_SUB: number; + static BAIDU_GAME_SUB: number; + static QTT_GAME: number; + /** BROWSER_TYPE_WECHAT */ + static BROWSER_TYPE_WECHAT: string; + /** BROWSER_TYPE_WECHAT_GAME */ + static BROWSER_TYPE_WECHAT_GAME: string; + /** BROWSER_TYPE_WECHAT_GAME_SUB */ + static BROWSER_TYPE_WECHAT_GAME_SUB: string; + /** BROWSER_TYPE_BAIDU_GAME */ + static BROWSER_TYPE_BAIDU_GAME: string; + /** BROWSER_TYPE_BAIDU_GAME_SUB */ + static BROWSER_TYPE_BAIDU_GAME_SUB: string; + /** BROWSER_TYPE_XIAOMI_GAME */ + static BROWSER_TYPE_XIAOMI_GAME: string; + /** BROWSER_TYPE_ALIPAY_GAME */ + static BROWSER_TYPE_ALIPAY_GAME: string; + /** BROWSER_TYPE_QQ_PLAY */ + static BROWSER_TYPE_QQ_PLAY: string; + static BROWSER_TYPE_ANDROID: string; + static BROWSER_TYPE_IE: string; + static BROWSER_TYPE_EDGE: string; + static BROWSER_TYPE_QQ: string; + static BROWSER_TYPE_MOBILE_QQ: string; + static BROWSER_TYPE_UC: string; + /** uc third party integration. */ + static BROWSER_TYPE_UCBS: string; + static BROWSER_TYPE_360: string; + static BROWSER_TYPE_BAIDU_APP: string; + static BROWSER_TYPE_BAIDU: string; + static BROWSER_TYPE_MAXTHON: string; + static BROWSER_TYPE_OPERA: string; + static BROWSER_TYPE_OUPENG: string; + static BROWSER_TYPE_MIUI: string; + static BROWSER_TYPE_FIREFOX: string; + static BROWSER_TYPE_SAFARI: string; + static BROWSER_TYPE_CHROME: string; + static BROWSER_TYPE_LIEBAO: string; + static BROWSER_TYPE_QZONE: string; + static BROWSER_TYPE_SOUGOU: string; + static BROWSER_TYPE_UNKNOWN: string; + /** Is native ? This is set to be true in jsb auto. */ + static isNative: boolean; + /** Is web browser ? */ + static isBrowser: boolean; + /** + Is webgl extension support? + @param name name + */ + static glExtension(name: any): void; + /** + Get max joint matrix size for skinned mesh renderer. + */ + static getMaxJointMatrixSize(): void; + /** + !#en + Returns the safe area of the screen. If the screen is not notched, the design resolution will be returned by default. + Only supported on Android, iOS and WeChat Mini Game platform. + !#zh + 返回手机屏幕安全区域,如果不是异形屏将默认返回设计分辨率尺寸。目前只支持安卓、iOS 原生平台和微信小游戏平台。 + */ + static getSafeAreaRect(): Rect; + /** Indicate whether system is mobile system */ + static isMobile: boolean; + /** Indicate the running platform */ + static platform: number; + /** Get current language iso 639-1 code. + Examples of valid language codes include "zh-tw", "en", "en-us", "fr", "fr-fr", "es-es", etc. + The actual value totally depends on results provided by destination platform. */ + static languageCode: string; + /** Indicate the current language of the running system */ + static language: string; + /** Indicate the running os name */ + static os: string; + /** Indicate the running os version */ + static osVersion: string; + /** Indicate the running os main version */ + static osMainVersion: number; + /** Indicate the running browser type */ + static browserType: string; + /** Indicate the running browser version */ + static browserVersion: string; + /** Indicate the real pixel resolution of the whole game window */ + static windowPixelResolution: Size; + /** cc.sys.localStorage is a local storage component. */ + static localStorage: any; + /** The capabilities of the current platform */ + static capabilities: any; + /** + !#en + Get the network type of current device, return cc.sys.NetworkType.LAN if failure. + !#zh + 获取当前设备的网络类型, 如果网络类型无法获取,默认将返回 cc.sys.NetworkType.LAN + */ + static getNetworkType(): sys.NetworkType; + /** + !#en + Get the battery level of current device, return 1.0 if failure. + !#zh + 获取当前设备的电池电量,如果电量无法获取,默认将返回 1 + */ + static getBatteryLevel(): number; + /** + Forces the garbage collection, only available in JSB + */ + static garbageCollect(): void; + /** + Restart the JS VM, only available in JSB + */ + static restartVM(): void; + /** + Check whether an object is valid, + In web engine, it will return true if the object exist + In native engine, it will return true if the JS object and the correspond native object are both valid + @param obj obj + */ + static isObjectValid(obj: any): boolean; + /** + Dump system informations + */ + static dump(): void; + /** + Open a url in browser + @param url url + */ + static openURL(url: string): void; + /** + Get the number of milliseconds elapsed since 1 January 1970 00:00:00 UTC. + */ + static now(): number; + } + /** cc.view is the singleton object which represents the game window.
+ It's main task include:
+ - Apply the design resolution policy
+ - Provide interaction with the window, like resize event on web, retina display support, etc...
+ - Manage the game view port which can be different with the window
+ - Manage the content scale and translation
+
+ Since the cc.view is a singleton, you don't need to call any constructor or create functions,
+ the standard way to use it is by calling:
+ - cc.view.methodName();
*/ + export class View extends EventTarget { + /** + !#en + Sets view's target-densitydpi for android mobile browser. it can be set to:
+ 1. cc.macro.DENSITYDPI_DEVICE, value is "device-dpi"
+ 2. cc.macro.DENSITYDPI_HIGH, value is "high-dpi" (default value)
+ 3. cc.macro.DENSITYDPI_MEDIUM, value is "medium-dpi" (browser's default value)
+ 4. cc.macro.DENSITYDPI_LOW, value is "low-dpi"
+ 5. Custom value, e.g: "480"
+ !#zh 设置目标内容的每英寸像素点密度。 + @param densityDPI densityDPI + */ + setTargetDensityDPI(densityDPI: string): void; + /** + !#en + Returns the current target-densitydpi value of cc.view. + !#zh 获取目标内容的每英寸像素点密度。 + */ + getTargetDensityDPI(): string; + /** + !#en + Sets whether resize canvas automatically when browser's size changed.
+ Useful only on web. + !#zh 设置当发现浏览器的尺寸改变时,是否自动调整 canvas 尺寸大小。 + 仅在 Web 模式下有效。 + @param enabled Whether enable automatic resize with browser's resize event + */ + resizeWithBrowserSize(enabled: boolean): void; + /** + !#en + Sets the callback function for cc.view's resize action,
+ this callback will be invoked before applying resolution policy,
+ so you can do any additional modifications within the callback.
+ Useful only on web. + !#zh 设置 cc.view 调整视窗尺寸行为的回调函数, + 这个回调函数会在应用适配模式之前被调用, + 因此你可以在这个回调函数内添加任意附加改变, + 仅在 Web 平台下有效。 + @param callback The callback function + */ + setResizeCallback(callback: Function|void): void; + /** + !#en + Sets the orientation of the game, it can be landscape, portrait or auto. + When set it to landscape or portrait, and screen w/h ratio doesn't fit, + cc.view will automatically rotate the game canvas using CSS. + Note that this function doesn't have any effect in native, + in native, you need to set the application orientation in native project settings + !#zh 设置游戏屏幕朝向,它能够是横版,竖版或自动。 + 当设置为横版或竖版,并且屏幕的宽高比例不匹配时, + cc.view 会自动用 CSS 旋转游戏场景的 canvas, + 这个方法不会对 native 部分产生任何影响,对于 native 而言,你需要在应用设置中的设置排版。 + @param orientation Possible values: cc.macro.ORIENTATION_LANDSCAPE | cc.macro.ORIENTATION_PORTRAIT | cc.macro.ORIENTATION_AUTO + */ + setOrientation(orientation: number): void; + /** + !#en + Sets whether the engine modify the "viewport" meta in your web page.
+ It's enabled by default, we strongly suggest you not to disable it.
+ And even when it's enabled, you can still set your own "viewport" meta, it won't be overridden
+ Only useful on web + !#zh 设置引擎是否调整 viewport meta 来配合屏幕适配。 + 默认设置为启动,我们强烈建议你不要将它设置为关闭。 + 即使当它启动时,你仍然能够设置你的 viewport meta,它不会被覆盖。 + 仅在 Web 模式下有效 + @param enabled Enable automatic modification to "viewport" meta + */ + adjustViewportMeta(enabled: boolean): void; + /** + !#en + Retina support is enabled by default for Apple device but disabled for other devices,
+ it takes effect only when you called setDesignResolutionPolicy
+ Only useful on web + !#zh 对于 Apple 这种支持 Retina 显示的设备上默认进行优化而其他类型设备默认不进行优化, + 它仅会在你调用 setDesignResolutionPolicy 方法时有影响。 + 仅在 Web 模式下有效。 + @param enabled Enable or disable retina display + */ + enableRetina(enabled: boolean): void; + /** + !#en + Check whether retina display is enabled.
+ Only useful on web + !#zh 检查是否对 Retina 显示设备进行优化。 + 仅在 Web 模式下有效。 + */ + isRetinaEnabled(): boolean; + /** + !#en Whether to Enable on anti-alias + !#zh 控制抗锯齿是否开启 + @param enabled Enable or not anti-alias + */ + enableAntiAlias(enabled: boolean): void; + /** + !#en Returns whether the current enable on anti-alias + !#zh 返回当前是否抗锯齿 + */ + isAntiAliasEnabled(): boolean; + /** + !#en + If enabled, the application will try automatically to enter full screen mode on mobile devices
+ You can pass true as parameter to enable it and disable it by passing false.
+ Only useful on web + !#zh 启动时,移动端游戏会在移动端自动尝试进入全屏模式。 + 你能够传入 true 为参数去启动它,用 false 参数来关闭它。 + @param enabled Enable or disable auto full screen on mobile devices + */ + enableAutoFullScreen(enabled: boolean): void; + /** + !#en + Check whether auto full screen is enabled.
+ Only useful on web + !#zh 检查自动进入全屏模式是否启动。 + 仅在 Web 模式下有效。 + */ + isAutoFullScreenEnabled(): boolean; + /** + !#en + Returns the canvas size of the view.
+ On native platforms, it returns the screen size since the view is a fullscreen view.
+ On web, it returns the size of the canvas element. + !#zh 返回视图中 canvas 的尺寸。 + 在 native 平台下,它返回全屏视图下屏幕的尺寸。 + 在 Web 平台下,它返回 canvas 元素尺寸。 + */ + getCanvasSize(): Size; + /** + !#en + Returns the frame size of the view.
+ On native platforms, it returns the screen size since the view is a fullscreen view.
+ On web, it returns the size of the canvas's outer DOM element. + !#zh 返回视图中边框尺寸。 + 在 native 平台下,它返回全屏视图下屏幕的尺寸。 + 在 web 平台下,它返回 canvas 元素的外层 DOM 元素尺寸。 + */ + getFrameSize(): Size; + /** + !#en + On native, it sets the frame size of view.
+ On web, it sets the size of the canvas's outer DOM element. + !#zh 在 native 平台下,设置视图框架尺寸。 + 在 web 平台下,设置 canvas 外层 DOM 元素尺寸。 + @param width width + @param height height + */ + setFrameSize(width: number, height: number): void; + /** + !#en + Returns the visible area size of the view port. + !#zh 返回视图窗口可见区域尺寸。 + */ + getVisibleSize(): Size; + /** + !#en + Returns the visible area size of the view port. + !#zh 返回视图窗口可见区域像素尺寸。 + */ + getVisibleSizeInPixel(): Size; + /** + !#en + Returns the visible origin of the view port. + !#zh 返回视图窗口可见区域原点。 + */ + getVisibleOrigin(): Vec2; + /** + !#en + Returns the visible origin of the view port. + !#zh 返回视图窗口可见区域像素原点。 + */ + getVisibleOriginInPixel(): Vec2; + /** + !#en + Returns the current resolution policy + !#zh 返回当前分辨率方案 + */ + getResolutionPolicy(): ResolutionPolicy; + /** + !#en + Sets the current resolution policy + !#zh 设置当前分辨率模式 + @param resolutionPolicy resolutionPolicy + */ + setResolutionPolicy(resolutionPolicy: ResolutionPolicy|number): void; + /** + !#en + Sets the resolution policy with designed view size in points.
+ The resolution policy include:
+ [1] ResolutionExactFit Fill screen by stretch-to-fit: if the design resolution ratio of width to height is different from the screen resolution ratio, your game view will be stretched.
+ [2] ResolutionNoBorder Full screen without black border: if the design resolution ratio of width to height is different from the screen resolution ratio, two areas of your game view will be cut.
+ [3] ResolutionShowAll Full screen with black border: if the design resolution ratio of width to height is different from the screen resolution ratio, two black borders will be shown.
+ [4] ResolutionFixedHeight Scale the content's height to screen's height and proportionally scale its width
+ [5] ResolutionFixedWidth Scale the content's width to screen's width and proportionally scale its height
+ [cc.ResolutionPolicy] [Web only feature] Custom resolution policy, constructed by cc.ResolutionPolicy
+ !#zh 通过设置设计分辨率和匹配模式来进行游戏画面的屏幕适配。 + @param width Design resolution width. + @param height Design resolution height. + @param resolutionPolicy The resolution policy desired + */ + setDesignResolutionSize(width: number, height: number, resolutionPolicy: ResolutionPolicy|number): void; + /** + !#en + Returns the designed size for the view. + Default resolution size is the same as 'getFrameSize'. + !#zh 返回视图的设计分辨率。 + 默认下分辨率尺寸同 `getFrameSize` 方法相同 + */ + getDesignResolutionSize(): Size; + /** + !#en + Sets the container to desired pixel resolution and fit the game content to it. + This function is very useful for adaptation in mobile browsers. + In some HD android devices, the resolution is very high, but its browser performance may not be very good. + In this case, enabling retina display is very costy and not suggested, and if retina is disabled, the image may be blurry. + But this API can be helpful to set a desired pixel resolution which is in between. + This API will do the following: + 1. Set viewport's width to the desired width in pixel + 2. Set body width to the exact pixel resolution + 3. The resolution policy will be reset with designed view size in points. + !#zh 设置容器(container)需要的像素分辨率并且适配相应分辨率的游戏内容。 + @param width Design resolution width. + @param height Design resolution height. + @param resolutionPolicy The resolution policy desired + */ + setRealPixelResolution(width: number, height: number, resolutionPolicy: ResolutionPolicy|number): void; + /** + !#en + Sets view port rectangle with points. + !#zh 用设计分辨率下的点尺寸来设置视窗。 + @param x x + @param y y + @param w width + @param h height + */ + setViewportInPoints(x: number, y: number, w: number, h: number): void; + /** + !#en + Sets Scissor rectangle with points. + !#zh 用设计分辨率下的点的尺寸来设置 scissor 剪裁区域。 + @param x x + @param y y + @param w w + @param h h + */ + setScissorInPoints(x: number, y: number, w: number, h: number): void; + /** + !#en + Returns whether GL_SCISSOR_TEST is enable + !#zh 检查 scissor 是否生效。 + */ + isScissorEnabled(): boolean; + /** + !#en + Returns the current scissor rectangle + !#zh 返回当前的 scissor 剪裁区域。 + */ + getScissorRect(): Rect; + /** + !#en + Returns the view port rectangle. + !#zh 返回视窗剪裁区域。 + */ + getViewportRect(): Rect; + /** + !#en + Returns scale factor of the horizontal direction (X axis). + !#zh 返回横轴的缩放比,这个缩放比是将画布像素分辨率放到设计分辨率的比例。 + */ + getScaleX(): number; + /** + !#en + Returns scale factor of the vertical direction (Y axis). + !#zh 返回纵轴的缩放比,这个缩放比是将画布像素分辨率缩放到设计分辨率的比例。 + */ + getScaleY(): number; + /** + !#en + Returns device pixel ratio for retina display. + !#zh 返回设备或浏览器像素比例。 + */ + getDevicePixelRatio(): number; + /** + !#en + Returns the real location in view for a translation based on a related position + !#zh 将屏幕坐标转换为游戏视图下的坐标。 + @param tx The X axis translation + @param ty The Y axis translation + @param relatedPos The related position object including "left", "top", "width", "height" informations + */ + convertToLocationInView(tx: number, ty: number, relatedPos: any): Vec2; + } + /**

cc.game.containerStrategy class is the root strategy class of container's scale strategy, + it controls the behavior of how to scale the cc.game.container and cc.game.canvas object

*/ + export class ContainerStrategy { + /** + !#en + Manipulation before appling the strategy + !#zh 在应用策略之前的操作 + @param view The target view + */ + preApply(view: View): void; + /** + !#en + Function to apply this strategy + !#zh 策略应用方法 + @param view view + @param designedResolution designedResolution + */ + apply(view: View, designedResolution: Size): void; + /** + !#en + Manipulation after applying the strategy + !#zh 策略调用之后的操作 + @param view The target view + */ + postApply(view: View): void; + } + /**

cc.ContentStrategy class is the root strategy class of content's scale strategy, + it controls the behavior of how to scale the scene and setup the viewport for the game

*/ + export class ContentStrategy { + /** + !#en + Manipulation before applying the strategy + !#zh 策略应用前的操作 + @param view The target view + */ + preApply(view: View): void; + /** + !#en Function to apply this strategy + The return value is {scale: [scaleX, scaleY], viewport: {cc.Rect}}, + The target view can then apply these value to itself, it's preferred not to modify directly its private variables + !#zh 调用策略方法 + @param view view + @param designedResolution designedResolution + */ + apply(view: View, designedResolution: Size): any; + /** + !#en + Manipulation after applying the strategy + !#zh 策略调用之后的操作 + @param view The target view + */ + postApply(view: View): void; + } + /** undefined */ + export class EqualToFrame extends ContainerStrategy { + } + /** undefined */ + export class ProportionalToFrame extends ContainerStrategy { + } + /** undefined */ + export class EqualToWindow extends EqualToFrame { + } + /** undefined */ + export class ProportionalToWindow extends ProportionalToFrame { + } + /** undefined */ + export class OriginalContainer extends ContainerStrategy { + } + /**

cc.ResolutionPolicy class is the root strategy class of scale strategy, + its main task is to maintain the compatibility with Cocos2d-x

*/ + export class ResolutionPolicy { + /** + + @param containerStg The container strategy + @param contentStg The content strategy + */ + constructor(containerStg: ContainerStrategy, contentStg: ContentStrategy); + /** + !#en Manipulation before applying the resolution policy + !#zh 策略应用前的操作 + @param view The target view + */ + preApply(view: View): void; + /** + !#en Function to apply this resolution policy + The return value is {scale: [scaleX, scaleY], viewport: {cc.Rect}}, + The target view can then apply these value to itself, it's preferred not to modify directly its private variables + !#zh 调用策略方法 + @param view The target view + @param designedResolution The user defined design resolution + */ + apply(view: View, designedResolution: Size): any; + /** + !#en Manipulation after appyling the strategy + !#zh 策略应用之后的操作 + @param view The target view + */ + postApply(view: View): void; + /** + !#en + Setup the container's scale strategy + !#zh 设置容器的适配策略 + @param containerStg containerStg + */ + setContainerStrategy(containerStg: ContainerStrategy): void; + /** + !#en + Setup the content's scale strategy + !#zh 设置内容的适配策略 + @param contentStg contentStg + */ + setContentStrategy(contentStg: ContentStrategy): void; + /** The entire application is visible in the specified area without trying to preserve the original aspect ratio.
+ Distortion can occur, and the application may appear stretched or compressed. */ + static EXACT_FIT: number; + /** The entire application fills the specified area, without distortion but possibly with some cropping,
+ while maintaining the original aspect ratio of the application. */ + static NO_BORDER: number; + /** The entire application is visible in the specified area without distortion while maintaining the original
+ aspect ratio of the application. Borders can appear on two sides of the application. */ + static SHOW_ALL: number; + /** The application takes the height of the design resolution size and modifies the width of the internal
+ canvas so that it fits the aspect ratio of the device
+ no distortion will occur however you must make sure your application works on different
+ aspect ratios */ + static FIXED_HEIGHT: number; + /** The application takes the width of the design resolution size and modifies the height of the internal
+ canvas so that it fits the aspect ratio of the device
+ no distortion will occur however you must make sure your application works on different
+ aspect ratios */ + static FIXED_WIDTH: number; + /** Unknow policy */ + static UNKNOWN: number; + } + /** cc.visibleRect is a singleton object which defines the actual visible rect of the current view, + it should represent the same rect as cc.view.getViewportRect() */ + export class visibleRect { + /** + initialize + @param visibleRect visibleRect + */ + static init(visibleRect: Rect): void; + /** Top left coordinate of the screen related to the game scene. */ + static topLeft: Vec2; + /** Top right coordinate of the screen related to the game scene. */ + static topRight: Vec2; + /** Top center coordinate of the screen related to the game scene. */ + static top: Vec2; + /** Bottom left coordinate of the screen related to the game scene. */ + static bottomLeft: Vec2; + /** Bottom right coordinate of the screen related to the game scene. */ + static bottomRight: Vec2; + /** Bottom center coordinate of the screen related to the game scene. */ + static bottom: Vec2; + /** Center coordinate of the screen related to the game scene. */ + static center: Vec2; + /** Left center coordinate of the screen related to the game scene. */ + static left: Vec2; + /** Right center coordinate of the screen related to the game scene. */ + static right: Vec2; + /** Width of the screen. */ + static width: number; + /** Height of the screen. */ + static height: number; + } + /** !#en The callbacks invoker to handle and invoke callbacks by key. + !#zh CallbacksInvoker 用来根据 Key 管理并调用回调方法。 */ + export class CallbacksInvoker { + /** + !#zh + 检查指定事件是否已注册回调。 + !#en + Check if the specified key has any registered callback. If a callback is also specified, + it will only return true if the callback is registered. + @param key key + @param callback callback + @param target target + */ + hasEventListener(key: string, callback?: Function, target?: any): boolean; + /** + !#zh + 移除在特定事件类型中注册的所有回调或在某个目标中注册的所有回调。 + + !#en + Removes all callbacks registered in a certain event type or all callbacks registered with a certain target + @param keyOrTarget The event key to be removed or the target to be removed + */ + removeAll(keyOrTarget: string|any): void; + /** + !#zh + 删除之前与同类型,回调,目标注册的回调。 + @param key key + @param callback callback + @param target target + */ + off(key: string, callback: Function, target?: any): void; + /** + !#en + Trigger an event directly with the event name and necessary arguments. + !#zh + 通过事件名发送自定义事件 + @param key event type + @param arg1 First argument + @param arg2 Second argument + @param arg3 Third argument + @param arg4 Fourth argument + @param arg5 Fifth argument + + @example + ```js + eventTarget.emit('fire', event); + eventTarget.emit('fire', message, emitter); + ``` + */ + emit(key: string, arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any): void; + } + /** !#en Contains information collected during deserialization + !#zh 包含反序列化时的一些信息 */ + export class Details { + /** list of the depends assets' uuid */ + uuidList: string[]; + /** the obj list whose field needs to load asset by uuid */ + uuidObjList: any[]; + /** the corresponding field name which referenced to the asset */ + uuidPropList: string[]; + reset(): void; + /** + + @param obj obj + @param propName propName + @param uuid uuid + */ + push(obj: any, propName: string, uuid: string): void; + } + /** !#en The module provides utilities for working with file and directory paths + !#zh 用于处理文件与目录的路径的模块 */ + export class path { + /** + !#en Join strings to be a path. + !#zh 拼接字符串为 Path + + @example + ```js + ------------------------------ + cc.path.join("a", "b.png"); //-->"a/b.png" + cc.path.join("a", "b", "c.png"); //-->"a/b/c.png" + cc.path.join("a", "b"); //-->"a/b" + cc.path.join("a", "b", "/"); //-->"a/b/" + cc.path.join("a", "b/", "/"); //-->"a/b/" + + ``` + */ + static join(): string; + /** + !#en Get the ext name of a path including '.', like '.png'. + !#zh 返回 Path 的扩展名,包括 '.',例如 '.png'。 + @param pathStr pathStr + + @example + ```js + --------------------------- + cc.path.extname("a/b.png"); //-->".png" + cc.path.extname("a/b.png?a=1&b=2"); //-->".png" + cc.path.extname("a/b"); //-->null + cc.path.extname("a/b?a=1&b=2"); //-->null + + ``` + */ + static extname(pathStr: string): any; + /** + !#en Get the main name of a file name + !#zh 获取文件名的主名称 + @param fileName fileName + */ + static mainFileName(fileName: string): string; + /** + !#en Get the file name of a file path. + !#zh 获取文件路径的文件名。 + @param pathStr pathStr + @param extname extname + + @example + ```js + --------------------------------- + cc.path.basename("a/b.png"); //-->"b.png" + cc.path.basename("a/b.png?a=1&b=2"); //-->"b.png" + cc.path.basename("a/b.png", ".png"); //-->"b" + cc.path.basename("a/b.png?a=1&b=2", ".png"); //-->"b" + cc.path.basename("a/b.png", ".txt"); //-->"b.png" + + ``` + */ + static basename(pathStr: string, extname?: string): any; + /** + !#en Get dirname of a file path. + !#zh 获取文件路径的目录名。 + @param pathStr pathStr + + @example + ```js + --------------------------------- + * unix + cc.path.driname("a/b/c.png"); //-->"a/b" + cc.path.driname("a/b/c.png?a=1&b=2"); //-->"a/b" + cc.path.dirname("a/b/"); //-->"a/b" + cc.path.dirname("c.png"); //-->"" + * windows + cc.path.driname("a\\b\\c.png"); //-->"a\b" + cc.path.driname("a\\b\\c.png?a=1&b=2"); //-->"a\b" + + ``` + */ + static dirname(pathStr: string): any; + /** + !#en Change extname of a file path. + !#zh 更改文件路径的扩展名。 + @param pathStr pathStr + @param extname extname + + @example + ```js + --------------------------------- + cc.path.changeExtname("a/b.png", ".plist"); //-->"a/b.plist" + cc.path.changeExtname("a/b.png?a=1&b=2", ".plist"); //-->"a/b.plist?a=1&b=2" + + ``` + */ + static changeExtname(pathStr: string, extname?: string): string; + } + /** !#en + AffineTransform class represent an affine transform matrix. It's composed basically by translation, rotation, scale transformations.
+ !#zh + AffineTransform 类代表一个仿射变换矩阵。它基本上是由平移旋转,缩放转变所组成。
*/ + export class AffineTransform { + /** + !#en Create a AffineTransform object with all contents in the matrix. + !#zh 用在矩阵中的所有内容创建一个 AffineTransform 对象。 + @param a a + @param b b + @param c c + @param d d + @param tx tx + @param ty ty + */ + static create(a: number, b: number, c: number, d: number, tx: number, ty: number): AffineTransform; + /** + !#en + Create a identity transformation matrix:
+ [ 1, 0, 0,
+ 0, 1, 0 ] + !#zh + 单位矩阵:
+ [ 1, 0, 0,
+ 0, 1, 0 ] + */ + static identity(): AffineTransform; + /** + !#en Clone a AffineTransform object from the specified transform. + !#zh 克隆指定的 AffineTransform 对象。 + @param t t + */ + static clone(t: AffineTransform): AffineTransform; + /** + !#en + Concatenate a transform matrix to another + The results are reflected in the out affine transform + out = t1 * t2 + This function is memory free, you should create the output affine transform by yourself and manage its memory. + !#zh + 拼接两个矩阵,将结果保存到 out 矩阵。这个函数不创建任何内存,你需要先创建 AffineTransform 对象用来存储结果,并作为第一个参数传入函数。 + out = t1 * t2 + @param out Out object to store the concat result + @param t1 The first transform object. + @param t2 The transform object to concatenate. + */ + static concat(out: AffineTransform, t1: AffineTransform, t2: AffineTransform): AffineTransform; + /** + !#en Get the invert transform of an AffineTransform object. + This function is memory free, you should create the output affine transform by yourself and manage its memory. + !#zh 求逆矩阵。这个函数不创建任何内存,你需要先创建 AffineTransform 对象用来存储结果,并作为第一个参数传入函数。 + @param out out + @param t t + */ + static invert(out: AffineTransform, t: AffineTransform): AffineTransform; + /** + !#en Get an AffineTransform object from a given matrix 4x4. + This function is memory free, you should create the output affine transform by yourself and manage its memory. + !#zh 从一个 4x4 Matrix 获取 AffineTransform 对象。这个函数不创建任何内存,你需要先创建 AffineTransform 对象用来存储结果,并作为第一个参数传入函数。 + @param out out + @param mat mat + */ + static invert(out: AffineTransform, mat: Mat4): AffineTransform; + /** + !#en Apply the affine transformation on a point. + This function is memory free, you should create the output Vec2 by yourself and manage its memory. + !#zh 对一个点应用矩阵变换。这个函数不创建任何内存,你需要先创建一个 Vec2 对象用来存储结果,并作为第一个参数传入函数。 + @param out The output point to store the result + @param point Point to apply transform or x. + @param transOrY transform matrix or y. + @param t transform matrix. + */ + static transformVec2(out: Vec2, point: Vec2|number, transOrY: AffineTransform|number, t?: AffineTransform): Vec2; + /** + !#en Apply the affine transformation on a size. + This function is memory free, you should create the output Size by yourself and manage its memory. + !#zh 应用仿射变换矩阵到 Size 上。这个函数不创建任何内存,你需要先创建一个 Size 对象用来存储结果,并作为第一个参数传入函数。 + @param out The output point to store the result + @param size size + @param t t + */ + static transformSize(out: Size, size: Size, t: AffineTransform): Size; + /** + !#en Apply the affine transformation on a rect. + This function is memory free, you should create the output Rect by yourself and manage its memory. + !#zh 应用仿射变换矩阵到 Rect 上。这个函数不创建任何内存,你需要先创建一个 Rect 对象用来存储结果,并作为第一个参数传入函数。 + @param out out + @param rect rect + @param anAffineTransform anAffineTransform + */ + static transformRect(out: Rect, rect: Rect, anAffineTransform: AffineTransform): Rect; + /** + !#en Apply the affine transformation on a rect, and truns to an Oriented Bounding Box. + This function is memory free, you should create the output vectors by yourself and manage their memory. + !#zh 应用仿射变换矩阵到 Rect 上, 并转换为有向包围盒。这个函数不创建任何内存,你需要先创建包围盒的四个 Vector 对象用来存储结果,并作为前四个参数传入函数。 + @param out_bl out_bl + @param out_tl out_tl + @param out_tr out_tr + @param out_br out_br + @param rect rect + @param anAffineTransform anAffineTransform + */ + static transformObb(out_bl: Vec2, out_tl: Vec2, out_tr: Vec2, out_br: Vec2, rect: Rect, anAffineTransform: AffineTransform): void; + } + /** A base node for CCNode, it will: + - maintain scene hierarchy and active logic + - notifications if some properties changed + - define some interfaces shares between CCNode + - define machanisms for Enity Component Systems + - define prefab and serialize functions */ + export class _BaseNode extends Object implements EventTarget { + /** !#en Name of node. + !#zh 该节点名称。 */ + name: string; + /** !#en The uuid for editor, will be stripped before building project. + !#zh 主要用于编辑器的 uuid,在编辑器下可用于持久化存储,在项目构建之后将变成自增的 id。 */ + uuid: string; + /** !#en All children nodes. + !#zh 节点的所有子节点。 */ + children: Node[]; + /** !#en All children nodes. + !#zh 节点的子节点数量。 */ + childrenCount: number; + /** !#en + The local active state of this node.
+ Note that a Node may be inactive because a parent is not active, even if this returns true.
+ Use {{#crossLink "Node/activeInHierarchy:property"}}{{/crossLink}} if you want to check if the Node is actually treated as active in the scene. + !#zh + 当前节点的自身激活状态。
+ 值得注意的是,一个节点的父节点如果不被激活,那么即使它自身设为激活,它仍然无法激活。
+ 如果你想检查节点在场景中实际的激活状态可以使用 {{#crossLink "Node/activeInHierarchy:property"}}{{/crossLink}}。 */ + active: boolean; + /** !#en Indicates whether this node is active in the scene. + !#zh 表示此节点是否在场景中激活。 */ + activeInHierarchy: boolean; + /** + + @param name name + */ + constructor(name?: string); + /** !#en The parent of the node. + !#zh 该节点的父节点。 */ + parent: Node; + /** + !#en Get parent of the node. + !#zh 获取该节点的父节点。 + + @example + ```js + var parent = this.node.getParent(); + ``` + */ + getParent(): Node; + /** + !#en Set parent of the node. + !#zh 设置该节点的父节点。 + @param value value + + @example + ```js + node.setParent(newNode); + ``` + */ + setParent(value: Node): void; + /** + !#en + Properties configuration function
+ All properties in attrs will be set to the node,
+ when the setter of the node is available,
+ the property will be set via setter function.
+ !#zh 属性配置函数。在 attrs 的所有属性将被设置为节点属性。 + @param attrs Properties to be set to node + + @example + ```js + var attrs = { key: 0, num: 100 }; + node.attr(attrs); + ``` + */ + attr(attrs: any): void; + /** + !#en Returns a child from the container given its uuid. + !#zh 通过 uuid 获取节点的子节点。 + @param uuid The uuid to find the child node. + + @example + ```js + var child = node.getChildByUuid(uuid); + ``` + */ + getChildByUuid(uuid: string): Node; + /** + !#en Returns a child from the container given its name. + !#zh 通过名称获取节点的子节点。 + @param name A name to find the child node. + + @example + ```js + var child = node.getChildByName("Test Node"); + ``` + */ + getChildByName(name: string): Node; + /** + !#en + Inserts a child to the node at a specified index. + !#zh + 插入子节点到指定位置 + @param child the child node to be inserted + @param siblingIndex the sibling index to place the child in + + @example + ```js + node.insertChild(child, 2); + ``` + */ + insertChild(child: Node, siblingIndex: number): void; + /** + !#en Get the sibling index. + !#zh 获取同级索引。 + + @example + ```js + var index = node.getSiblingIndex(); + ``` + */ + getSiblingIndex(): number; + /** + !#en Set the sibling index of this node. + !#zh 设置节点同级索引。 + @param index index + + @example + ```js + node.setSiblingIndex(1); + ``` + */ + setSiblingIndex(index: number): void; + /** + !#en Walk though the sub children tree of the current node. + Each node, including the current node, in the sub tree will be visited two times, before all children and after all children. + This function call is not recursive, it's based on stack. + Please don't walk any other node inside the walk process. + !#zh 遍历该节点的子树里的所有节点并按规则执行回调函数。 + 对子树中的所有节点,包含当前节点,会执行两次回调,prefunc 会在访问它的子节点之前调用,postfunc 会在访问所有子节点之后调用。 + 这个函数的实现不是基于递归的,而是基于栈展开递归的方式。 + 请不要在 walk 过程中对任何其他的节点嵌套执行 walk。 + @param prefunc The callback to process node when reach the node for the first time + @param postfunc The callback to process node when re-visit the node after walked all children in its sub tree + + @example + ```js + node.walk(function (target) { + console.log('Walked through node ' + target.name + ' for the first time'); + }, function (target) { + console.log('Walked through node ' + target.name + ' after walked all children in its sub tree'); + }); + ``` + */ + walk(prefunc: (target: _BaseNode) => void, postfunc: (target: _BaseNode) => void): void; + /** + !#en + Remove itself from its parent node. If cleanup is `true`, then also remove all events and actions.
+ If the cleanup parameter is not passed, it will force a cleanup, so it is recommended that you always pass in the `false` parameter when calling this API.
+ If the node orphan, then nothing happens. + !#zh + 从父节点中删除该节点。如果不传入 cleanup 参数或者传入 `true`,那么这个节点上所有绑定的事件、action 都会被删除。
+ 因此建议调用这个 API 时总是传入 `false` 参数。
+ 如果这个节点是一个孤节点,那么什么都不会发生。 + @param cleanup true if all actions and callbacks on this node should be removed, false otherwise. + + @example + ```js + node.removeFromParent(); + node.removeFromParent(false); + ``` + */ + removeFromParent(cleanup?: boolean): void; + /** + !#en + Removes a child from the container. It will also cleanup all running actions depending on the cleanup parameter.

+ If the cleanup parameter is not passed, it will force a cleanup.
+ "remove" logic MUST only be on this method
+ If a class wants to extend the 'removeChild' behavior it only needs
+ to override this method. + !#zh + 移除节点中指定的子节点,是否需要清理所有正在运行的行为取决于 cleanup 参数。
+ 如果 cleanup 参数不传入,默认为 true 表示清理。
+ @param child The child node which will be removed. + @param cleanup true if all running actions and callbacks on the child node will be cleanup, false otherwise. + + @example + ```js + node.removeChild(newNode); + node.removeChild(newNode, false); + ``` + */ + removeChild(child: Node, cleanup?: boolean): void; + /** + !#en + Removes all children from the container and do a cleanup all running actions depending on the cleanup parameter.
+ If the cleanup parameter is not passed, it will force a cleanup. + !#zh + 移除节点所有的子节点,是否需要清理所有正在运行的行为取决于 cleanup 参数。
+ 如果 cleanup 参数不传入,默认为 true 表示清理。 + @param cleanup true if all running actions on all children nodes should be cleanup, false otherwise. + + @example + ```js + node.removeAllChildren(); + node.removeAllChildren(false); + ``` + */ + removeAllChildren(cleanup?: boolean): void; + /** + !#en Is this node a child of the given node? + !#zh 是否是指定节点的子节点? + @param parent parent + + @example + ```js + node.isChildOf(newNode); + ``` + */ + isChildOf(parent: Node): boolean; + /** + !#en + Returns the component of supplied type if the node has one attached, null if it doesn't.
+ You can also get component in the node by passing in the name of the script. + !#zh + 获取节点上指定类型的组件,如果节点有附加指定类型的组件,则返回,如果没有则为空。
+ 传入参数也可以是脚本的名称。 + @param typeOrClassName typeOrClassName + + @example + ```js + // get sprite component + var sprite = node.getComponent(cc.Sprite); + // get custom test class + var test = node.getComponent("Test"); + ``` + */ + getComponent(type: {prototype: T}): T; + getComponent(className: string): any; + /** + !#en Returns all components of supplied type in the node. + !#zh 返回节点上指定类型的所有组件。 + @param typeOrClassName typeOrClassName + + @example + ```js + var sprites = node.getComponents(cc.Sprite); + var tests = node.getComponents("Test"); + ``` + */ + getComponents(type: {prototype: T}): T[]; + getComponents(className: string): any[]; + /** + !#en Returns the component of supplied type in any of its children using depth first search. + !#zh 递归查找所有子节点中第一个匹配指定类型的组件。 + @param typeOrClassName typeOrClassName + + @example + ```js + var sprite = node.getComponentInChildren(cc.Sprite); + var Test = node.getComponentInChildren("Test"); + ``` + */ + getComponentInChildren(type: {prototype: T}): T; + getComponentInChildren(className: string): any; + /** + !#en Returns all components of supplied type in self or any of its children. + !#zh 递归查找自身或所有子节点中指定类型的组件 + @param typeOrClassName typeOrClassName + + @example + ```js + var sprites = node.getComponentsInChildren(cc.Sprite); + var tests = node.getComponentsInChildren("Test"); + ``` + */ + getComponentsInChildren(type: {prototype: T}): T[]; + getComponentsInChildren(className: string): any[]; + /** + !#en Adds a component class to the node. You can also add component to node by passing in the name of the script. + !#zh 向节点添加一个指定类型的组件类,你还可以通过传入脚本的名称来添加组件。 + @param typeOrClassName The constructor or the class name of the component to add + + @example + ```js + var sprite = node.addComponent(cc.Sprite); + var test = node.addComponent("Test"); + ``` + */ + addComponent(type: {new(): T}): T; + addComponent(className: string): any; + /** + !#en + Removes a component identified by the given name or removes the component object given. + You can also use component.destroy() if you already have the reference. + !#zh + 删除节点上的指定组件,传入参数可以是一个组件构造函数或组件名,也可以是已经获得的组件引用。 + 如果你已经获得组件引用,你也可以直接调用 component.destroy() + @param component The need remove component. + + @example + ```js + node.removeComponent(cc.Sprite); + var Test = require("Test"); + node.removeComponent(Test); + ``` + */ + removeComponent(component: string|Function|Component): void; + /** + !#en + Destroy all children from the node, and release all their own references to other objects.
+ Actual destruct operation will delayed until before rendering. + !#zh + 销毁所有子节点,并释放所有它们对其它对象的引用。
+ 实际销毁操作会延迟到当前帧渲染前执行。 + + @example + ```js + node.destroyAllChildren(); + ``` + */ + destroyAllChildren(): void; + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en + Register an callback of a specific event type on the EventTarget. + This type of event should be triggered via `emit`. + !#zh + 注册事件目标的特定事件类型回调。这种类型的事件应该被 `emit` 触发。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, node); + ``` + */ + on(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. + !#zh + 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + + @example + ```js + // register fire eventListener + var callback = eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, target); + // remove fire event listener + eventTarget.off('fire', callback, target); + // remove all fire event listeners + eventTarget.off('fire'); + ``` + */ + off(type: string, callback?: Function, target?: any): void; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.once('fire', function () { + cc.log("this is the callback and will be invoked only once"); + }, node); + ``` + */ + once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; + /** + !#en + Send an event with the event object. + !#zh + 通过事件对象派发事件 + @param event event + */ + dispatchEvent(event: Event): void; + } + /** !#en + Helper class for setting material blend function. + !#zh + 设置材质混合模式的辅助类。 */ + export class BlendFunc { + /** !#en specify the source Blend Factor, this will generate a custom material object, please pay attention to the memory cost. + !#zh 指定原图的混合模式,这会克隆一个新的材质对象,注意这带来的开销 */ + srcBlendFactor: macro.BlendFactor; + /** !#en specify the destination Blend Factor. + !#zh 指定目标的混合模式 */ + dstBlendFactor: macro.BlendFactor; + } + /** An internal helper class for switching render component's material between normal sprite material and gray sprite material. */ + export class GraySpriteState { + /** !#en The normal material. + !#zh 正常状态的材质。 */ + normalMaterial: Material; + /** !#en The gray material. + !#zh 置灰状态的材质。 */ + grayMaterial: Material; + } + /** misc utilities */ + export class misc { + /** + !#en Clamp a value between from and to. + !#zh + 限定浮点数的最大最小值。
+ 数值大于 max_inclusive 则返回 max_inclusive。
+ 数值小于 min_inclusive 则返回 min_inclusive。
+ 否则返回自身。 + @param value value + @param min_inclusive min_inclusive + @param max_inclusive max_inclusive + + @example + ```js + var v1 = cc.misc.clampf(20, 0, 20); // 20; + var v2 = cc.misc.clampf(-1, 0, 20); // 0; + var v3 = cc.misc.clampf(10, 0, 20); // 10; + ``` + */ + static clampf(value: number, min_inclusive: number, max_inclusive: number): number; + /** + !#en Clamp a value between 0 and 1. + !#zh 限定浮点数的取值范围为 0 ~ 1 之间。 + @param value value + + @example + ```js + var v1 = cc.misc.clamp01(20); // 1; + var v2 = cc.misc.clamp01(-1); // 0; + var v3 = cc.misc.clamp01(0.5); // 0.5; + ``` + */ + static clamp01(value: number): number; + /** + Linear interpolation between 2 numbers, the ratio sets how much it is biased to each end + @param a number A + @param b number B + @param r ratio between 0 and 1 + + @example + ```js + ---- + lerp + cc.misc.lerp(2,10,0.5)//returns 6 + cc.misc.lerp(2,10,0.2)//returns 3.6 + + ``` + */ + static lerp(a: number, b: number, r: number): number; + /** + converts degrees to radians + @param angle angle + */ + static degreesToRadians(angle: number): number; + /** + converts radians to degrees + @param angle angle + */ + static radiansToDegrees(angle: number): number; + } + /** !#en + Representation of RGBA colors. + + Each color component is a floating point value with a range from 0 to 255. + + You can also use the convenience method {{#crossLink "cc/color:method"}}cc.color{{/crossLink}} to create a new Color. + + !#zh + cc.Color 用于表示颜色。 + + 它包含 RGBA 四个以浮点数保存的颜色分量,每个的值都在 0 到 255 之间。 + + 您也可以通过使用 {{#crossLink "cc/color:method"}}cc.color{{/crossLink}} 的便捷方法来创建一个新的 Color。 */ + export class Color extends ValueType { + /** !#en Solid white, RGBA is [255, 255, 255, 255]. + !#zh 纯白色,RGBA 是 [255, 255, 255, 255]。 */ + static WHITE: Color; + /** !#en Solid black, RGBA is [0, 0, 0, 255]. + !#zh 纯黑色,RGBA 是 [0, 0, 0, 255]。 */ + static BLACK: Color; + /** !#en Transparent, RGBA is [0, 0, 0, 0]. + !#zh 透明,RGBA 是 [0, 0, 0, 0]。 */ + static TRANSPARENT: Color; + /** !#en Grey, RGBA is [127.5, 127.5, 127.5]. + !#zh 灰色,RGBA 是 [127.5, 127.5, 127.5]。 */ + static GRAY: Color; + /** !#en Solid red, RGBA is [255, 0, 0]. + !#zh 纯红色,RGBA 是 [255, 0, 0]。 */ + static RED: Color; + /** !#en Solid green, RGBA is [0, 255, 0]. + !#zh 纯绿色,RGBA 是 [0, 255, 0]。 */ + static GREEN: Color; + /** !#en Solid blue, RGBA is [0, 0, 255]. + !#zh 纯蓝色,RGBA 是 [0, 0, 255]。 */ + static BLUE: Color; + /** !#en Yellow, RGBA is [255, 235, 4]. + !#zh 黄色,RGBA 是 [255, 235, 4]。 */ + static YELLOW: Color; + /** !#en Orange, RGBA is [255, 127, 0]. + !#zh 橙色,RGBA 是 [255, 127, 0]。 */ + static ORANGE: Color; + /** !#en Cyan, RGBA is [0, 255, 255]. + !#zh 青色,RGBA 是 [0, 255, 255]。 */ + static CYAN: Color; + /** !#en Magenta, RGBA is [255, 0, 255]. + !#zh 洋红色(品红色),RGBA 是 [255, 0, 255]。 */ + static MAGENTA: Color; + /** + Copy content of a color into another. + */ + static copy (out: Color, a: Color): Color; + /** + Clone a new color. + */ + static clone (a: Color): Color; + /** + Set the components of a color to the given values. + */ + static set (out: Color, r?: number, g?: number, b?: number, a?: number): Color; + /** + Converts the hexadecimal formal color into rgb formal. + */ + static fromHex (out: Color, hex: number): Color; + /** + Converts the hexadecimal formal color into rgb formal. + */ + static fromHEX (out: Color, hex: string): Color; + /** + Add components of two colors, respectively. + */ + static add (out: Color, a: Color, b: Color): Color; + /** + Subtract components of color b from components of color a, respectively. + */ + static subtract (out: Color, a: Color, b: Color): Color; + /** + Multiply components of two colors, respectively. + */ + static multiply (out: Color, a: Color, b: Color): Color; + /** + Divide components of color a by components of color b, respectively. + */ + static divide (out: Color, a: Color, b: Color): Color; + /** + Scales a color by a number. + */ + static scale (out: Color, a: Color, b: number): Color; + /** + Performs a linear interpolation between two colors. + */ + static lerp (out: Color, a: Color, b: Color, t: number): Color; + /** + !#zh 颜色转数组 + !#en Turn an array of colors + @param ofs 数组起始偏移量 + */ + static toArray > (out: Out, a: IColorLike, ofs?: number): Out; + /** + !#zh 数组转颜色 + !#en An array of colors turn + @param ofs 数组起始偏移量 + */ + static fromArray (arr: IWritableArrayLike, out: Out, ofs?: number): Out; + /** + !#zh 颜色 RGB 预乘 Alpha 通道 + !#en RGB premultiply alpha channel + @param out 返回颜色 + @param color 预乘处理的目标颜色 + */ + static premultiplyAlpha (out: Out, a: IColorLike); + /** + + @param r red component of the color, default value is 0. + @param g green component of the color, defualt value is 0. + @param b blue component of the color, default value is 0. + @param a alpha component of the color, default value is 255. + */ + constructor(r?: number, g?: number, b?: number, a?: number); + /** + !#en Clone a new color from the current color. + !#zh 克隆当前颜色。 + + @example + ```js + var color = new cc.Color(); + var newColor = color.clone();// Color {r: 0, g: 0, b: 0, a: 255} + ``` + */ + clone(): Color; + /** + !#en TODO + !#zh 判断两个颜色是否相等。 + @param other other + + @example + ```js + var color1 = cc.Color.WHITE; + var color2 = new cc.Color(255, 255, 255); + cc.log(color1.equals(color2)); // true; + color2 = cc.Color.RED; + cc.log(color2.equals(color1)); // false; + ``` + */ + equals(other: Color): boolean; + /** + !#en TODO + !#zh 线性插值 + @param to to + @param ratio the interpolation coefficient. + @param out optional, the receiving vector. + + @example + ```js + // Converts a white color to a black one trough time. + update: function (dt) { + var color = this.node.color; + if (color.equals(cc.Color.BLACK)) { + return; + } + this.ratio += dt * 0.1; + this.node.color = cc.Color.WHITE.lerp(cc.Color.BLACK, ratio); + } + + ``` + */ + lerp(to: Color, ratio: number, out?: Color): Color; + /** + !#en TODO + !#zh 转换为方便阅读的字符串。 + + @example + ```js + var color = cc.Color.WHITE; + color.toString(); // "rgba(255, 255, 255, 255)" + ``` + */ + toString(): string; + /** !#en Get or set red channel value + !#zh 获取或者设置红色通道 */ + r: number; + /** !#en Get or set green channel value + !#zh 获取或者设置绿色通道 */ + g: number; + /** !#en Get or set blue channel value + !#zh 获取或者设置蓝色通道 */ + b: number; + /** !#en Get or set alpha channel value + !#zh 获取或者设置透明通道 */ + a: number; + /** + !#en Gets red channel value + !#zh 获取当前颜色的红色值。 + */ + getR(): number; + /** + !#en Sets red value and return the current color object + !#zh 设置当前的红色值,并返回当前对象。 + @param red the new Red component. + + @example + ```js + var color = new cc.Color(); + color.setR(255); // Color {r: 255, g: 0, b: 0, a: 255} + ``` + */ + setR(red: number): Color; + /** + !#en Gets green channel value + !#zh 获取当前颜色的绿色值。 + */ + getG(): number; + /** + !#en Sets green value and return the current color object + !#zh 设置当前的绿色值,并返回当前对象。 + @param green the new Green component. + + @example + ```js + var color = new cc.Color(); + color.setG(255); // Color {r: 0, g: 255, b: 0, a: 255} + ``` + */ + setG(green: number): Color; + /** + !#en Gets blue channel value + !#zh 获取当前颜色的蓝色值。 + */ + getB(): number; + /** + !#en Sets blue value and return the current color object + !#zh 设置当前的蓝色值,并返回当前对象。 + @param blue the new Blue component. + + @example + ```js + var color = new cc.Color(); + color.setB(255); // Color {r: 0, g: 0, b: 255, a: 255} + ``` + */ + setB(blue: number): Color; + /** + !#en Gets alpha channel value + !#zh 获取当前颜色的透明度值。 + */ + getA(): number; + /** + !#en Sets alpha value and return the current color object + !#zh 设置当前的透明度,并返回当前对象。 + @param alpha the new Alpha component. + + @example + ```js + var color = new cc.Color(); + color.setA(0); // Color {r: 0, g: 0, b: 0, a: 0} + ``` + */ + setA(alpha: number): Color; + /** + !#en Convert color to css format. + !#zh 转换为 CSS 格式。 + @param opt "rgba", "rgb", "#rgb" or "#rrggbb". + + @example + ```js + var color = cc.Color.BLACK; + color.toCSS(); // "rgba(0,0,0,1.00)"; + color.toCSS("rgba"); // "rgba(0,0,0,1.00)"; + color.toCSS("rgb"); // "rgba(0,0,0)"; + color.toCSS("#rgb"); // "#000"; + color.toCSS("#rrggbb"); // "#000000"; + ``` + */ + toCSS(opt?: string): string; + /** + !#en Read hex string and store color data into the current color object, the hex string must be formated as rgba or rgb. + !#zh 读取 16 进制颜色。 + @param hexString hexString + + @example + ```js + var color = cc.Color.BLACK; + color.fromHEX("#FFFF33"); // Color {r: 255, g: 255, b: 51, a: 255}; + ``` + */ + fromHEX(hexString: string): Color; + /** + !#en convert Color to HEX color string. + !#zh 转换为 16 进制。 + @param fmt "#rgb", "#rrggbb" or "#rrggbbaa". + + @example + ```js + var color = cc.Color.BLACK; + color.toHEX("#rgb"); // "000"; + color.toHEX("#rrggbb"); // "000000"; + ``` + */ + toHEX(fmt?: string): string; + /** + !#en Convert to 24bit rgb value. + !#zh 转换为 24bit 的 RGB 值。 + + @example + ```js + var color = cc.Color.YELLOW; + color.toRGBValue(); // 16771844; + ``` + */ + toRGBValue(): number; + /** + !#en Read HSV model color and convert to RGB color + !#zh 读取 HSV(色彩模型)格式。 + @param h h + @param s s + @param v v + + @example + ```js + var color = cc.Color.YELLOW; + color.fromHSV(0, 0, 1); // Color {r: 255, g: 255, b: 255, a: 255}; + ``` + */ + fromHSV(h: number, s: number, v: number): Color; + /** + !#en Transform to HSV model color + !#zh 转换为 HSV(色彩模型)格式。 + + @example + ```js + var color = cc.Color.YELLOW; + color.toHSV(); // Object {h: 0.1533864541832669, s: 0.9843137254901961, v: 1}; + ``` + */ + toHSV(): any; + /** + !#en Set the color + !#zh 设置颜色 + @param color color + */ + set (color: Color): Color; + /** + !#en Multiplies the current color by the specified color + !#zh 将当前颜色乘以与指定颜色 + @param other other + */ + multiply(other: Color): Color; + } + /** Mathematical 3x3 matrix. + + NOTE: we use column-major matrix for all matrix calculation. + + This may lead to some confusion when referencing OpenGL documentation, + however, which represents out all matricies in column-major format. + This means that while in code a matrix may be typed out as: + + [1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 1, 0, + x, y, z, 0] + + The same matrix in the [OpenGL documentation](https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glTranslate.xml) + is written as: + + 1 0 0 x + 0 1 0 y + 0 0 1 z + 0 0 0 0 + + Please rest assured, however, that they are the same thing! + This is not unique to glMatrix, either, as OpenGL developers have long been confused by the + apparent lack of consistency between the memory layout and the documentation. */ + export class Mat3 extends ValueType { + /** Identity of Mat3 */ + static IDENTITY: Mat3; + /** + !#zh 矩阵转数组 + !#en Matrix transpose array + @param ofs 数组内的起始偏移量 + */ + static toArray > (out: Out, mat: IMat3Like, ofs?: number): Out; + /** + !#zh 数组转矩阵 + !#en Transfer matrix array + @param ofs 数组起始偏移量 + */ + static fromArray (out: Out, arr: IWritableArrayLike, ofs?: number): Out; + /** !#en Matrix Data + !#zh 矩阵数据 */ + m: Float64Array|Float32Array; + constructor (m00?: number | Float32Array, m01?: number, m02?: number, m03?: number, m04?: number, m05?: number, m06?: number, m07?: number, m08?: number); + } + /** !#en Representation of 4*4 matrix. + !#zh 表示 4*4 矩阵 */ + export class Mat4 extends ValueType { + /** + !#en Multiply the current matrix with another one + !#zh 将当前矩阵与指定矩阵相乘 + @param other the second operand + @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created + */ + mul(other: Mat4, out?: Mat4): Mat4; + /** + !#en Multiply each element of the matrix by a scalar. + !#zh 将矩阵的每一个元素都乘以指定的缩放值。 + @param number amount to scale the matrix's elements by + @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created + */ + mulScalar(number: number, out?: Mat4): Mat4; + /** + !#en Subtracts the current matrix with another one + !#zh 将当前矩阵与指定的矩阵相减 + @param other the second operand + @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created + */ + sub(other: Mat4, out?: Mat4): Mat4; + /** Identity of Mat4 */ + static IDENTITY: Mat4; + /** + !#zh 获得指定矩阵的拷贝 + !#en Copy of the specified matrix to obtain + */ + static clone (a: Out): Mat4; + /** + !#zh 复制目标矩阵 + !#en Copy the target matrix + */ + static copy (out: Out, a: Out): Out; + /** + !#zh 将目标赋值为单位矩阵 + !#en The target of an assignment is the identity matrix + */ + static identity (out: Out): Out; + /** + !#zh 转置矩阵 + !#en Transposed matrix + */ + static transpose (out: Out, a: Out): Out; + /** + !#zh 矩阵求逆 + !#en Matrix inversion + */ + static invert (out: Out, a: Out): Out; + /** + !#zh 矩阵行列式 + !#en Matrix determinant + */ + static determinant (a: Out): number; + /** + !#zh 矩阵乘法 + !#en Matrix Multiplication + */ + static multiply (out: Out, a: Out, b: Out): Out; + /** + !#zh 在给定矩阵变换基础上加入变换 + !#en Was added in a given transformation matrix transformation on the basis of + */ + static transform (out: Out, a: Out, v: VecLike): Out; + /** + !#zh 在给定矩阵变换基础上加入新位移变换 + !#en Add new displacement transducer in a matrix transformation on the basis of a given + */ + static translate (out: Out, a: Out, v: VecLike): Out; + /** + !#zh 在给定矩阵变换基础上加入新缩放变换 + !#en Add new scaling transformation in a given matrix transformation on the basis of + */ + static scale (out: Out, a: Out, v: VecLike): Out; + /** + !#zh 在给定矩阵变换基础上加入新旋转变换 + !#en Add a new rotational transform matrix transformation on the basis of a given + @param rad 旋转角度 + @param axis 旋转轴 + */ + static rotate (out: Out, a: Out, rad: number, axis: VecLike): Out; + /** + !#zh 在给定矩阵变换基础上加入绕 X 轴的旋转变换 + !#en Add rotational transformation around the X axis at a given matrix transformation on the basis of + @param rad 旋转角度 + */ + static rotateX (out: Out, a: Out, rad: number): Out; + /** + !#zh 在给定矩阵变换基础上加入绕 Y 轴的旋转变换 + !#en Add about the Y axis rotation transformation in a given matrix transformation on the basis of + @param rad 旋转角度 + */ + static rotateY (out: Out, a: Out, rad: number): Out; + /** + !#zh 在给定矩阵变换基础上加入绕 Z 轴的旋转变换 + !#en Added about the Z axis at a given rotational transformation matrix transformation on the basis of + @param rad 旋转角度 + */ + static rotateZ (out: Out, a: Out, rad: number): Out; + /** + !#zh 计算位移矩阵 + !#en Displacement matrix calculation + */ + static fromTranslation (out: Out, v: VecLike): Out; + /** + !#zh 计算缩放矩阵 + !#en Scaling matrix calculation + */ + static fromScaling (out: Out, v: VecLike): Out; + /** + !#zh 计算旋转矩阵 + !#en Calculates the rotation matrix + */ + static fromRotation (out: Out, rad: number, axis: VecLike): Out; + /** + !#zh 计算绕 X 轴的旋转矩阵 + !#en Calculating rotation matrix about the X axis + */ + static fromXRotation (out: Out, rad: number): Out; + /** + !#zh 计算绕 Y 轴的旋转矩阵 + !#en Calculating rotation matrix about the Y axis + */ + static fromYRotation (out: Out, rad: number): Out; + /** + !#zh 计算绕 Z 轴的旋转矩阵 + !#en Calculating rotation matrix about the Z axis + */ + static fromZRotation (out: Out, rad: number): Out; + /** + !#zh 根据旋转和位移信息计算矩阵 + !#en The rotation and displacement information calculating matrix + */ + static fromRT (out: Out, q: Quat, v: VecLike): Out; + /** + !#zh 提取矩阵的位移信息, 默认矩阵中的变换以 S->R->T 的顺序应用 + !#en Extracting displacement information of the matrix, the matrix transform to the default sequential application S-> R-> T is + */ + static getTranslation (out: VecLike, mat: Out): VecLike; + /** + !#zh 提取矩阵的缩放信息, 默认矩阵中的变换以 S->R->T 的顺序应用 + !#en Scaling information extraction matrix, the matrix transform to the default sequential application S-> R-> T is + */ + static getScaling (out: VecLike, mat: Out): VecLike; + /** + !#zh 提取矩阵的旋转信息, 默认输入矩阵不含有缩放信息,如考虑缩放应使用 `toRTS` 函数。 + !#en Rotation information extraction matrix, the matrix containing no default input scaling information, such as the use of `toRTS` should consider the scaling function. + */ + static getRotation (out: Quat, mat: Out): Quat; + /** + !#zh 提取旋转、位移、缩放信息, 默认矩阵中的变换以 S->R->T 的顺序应用 + !#en Extracting rotational displacement, zoom information, the default matrix transformation in order S-> R-> T applications + */ + static toRTS (mat: Out, q: Quat, v: VecLike, s: VecLike): void; + /** + !#zh 根据旋转、位移、缩放信息计算矩阵,以 S->R->T 的顺序应用 + !#en The rotary displacement, the scaling matrix calculation information, the order S-> R-> T applications + */ + static fromRTS (out: Out, q: Quat, v: VecLike, s: VecLike): Out; + /** + !#zh 根据指定的旋转、位移、缩放及变换中心信息计算矩阵,以 S->R->T 的顺序应用 + !#en According to the specified rotation, displacement, and scale conversion matrix calculation information center, order S-> R-> T applications + @param q 旋转值 + @param v 位移值 + @param s 缩放值 + @param o 指定变换中心 + */ + static fromRTSOrigin (out: Out, q: Quat, v: VecLike, s: VecLike, o: VecLike): Out; + /** + !#zh 根据指定的旋转信息计算矩阵 + !#en The rotation matrix calculation information specified + */ + static fromQuat (out: Out, q: Quat): Out; + /** + !#zh 根据指定的视锥体信息计算矩阵 + !#en The matrix calculation information specified frustum + @param left 左平面距离 + @param right 右平面距离 + @param bottom 下平面距离 + @param top 上平面距离 + @param near 近平面距离 + @param far 远平面距离 + */ + static frustum (out: Out, left: number, right: number, bottom: number, top: number, near: number, far: number): Out; + /** + !#zh 计算透视投影矩阵 + !#en Perspective projection matrix calculation + @param fovy 纵向视角高度 + @param aspect 长宽比 + @param near 近平面距离 + @param far 远平面距离 + */ + static perspective (out: Out, fovy: number, aspect: number, near: number, far: number): Out; + /** + !#zh 计算正交投影矩阵 + !#en Computing orthogonal projection matrix + @param left 左平面距离 + @param right 右平面距离 + @param bottom 下平面距离 + @param top 上平面距离 + @param near 近平面距离 + @param far 远平面距离 + */ + static ortho (out: Out, left: number, right: number, bottom: number, top: number, near: number, far: number): Out; + /** + !#zh 根据视点计算矩阵,注意 `eye - center` 不能为零向量或与 `up` 向量平行 + !#en `Up` parallel vector or vector center` not be zero - the matrix calculation according to the viewpoint, note` eye + @param eye 当前位置 + @param center 目标视点 + @param up 视口上方向 + */ + static lookAt (out: Out, eye: VecLike, center: VecLike, up: VecLike): Out; + /** + !#zh 计算逆转置矩阵 + !#en Reversal matrix calculation + */ + static inverseTranspose (out: Out, a: Out): Out; + /** + !#zh 逐元素矩阵加法 + !#en Element by element matrix addition + */ + static add (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素矩阵减法 + !#en Matrix element by element subtraction + */ + static subtract (out: Out, a: Out, b: Out): Out; + /** + !#zh 矩阵标量乘法 + !#en Matrix scalar multiplication + */ + static multiplyScalar (out: Out, a: Out, b: number): Out; + /** + !#zh 逐元素矩阵标量乘加: A + B * scale + !#en Elements of the matrix by the scalar multiplication and addition: A + B * scale + */ + static multiplyScalarAndAdd (out: Out, a: Out, b: Out, scale: number): Out; + /** + !#zh 矩阵等价判断 + !#en Analyzing the equivalent matrix + */ + static strictEquals (a: Out, b: Out): boolean; + /** + !#zh 排除浮点数误差的矩阵近似等价判断 + !#en Negative floating point error is approximately equivalent to determining a matrix + */ + static equals (a: Out, b: Out, epsilon?: number): boolean; + /** + !#zh 矩阵转数组 + !#en Matrix transpose array + @param ofs 数组内的起始偏移量 + */ + static toArray > (out: Out, mat: IMat4Like, ofs?: number): Out; + /** + !#zh 数组转矩阵 + !#en Transfer matrix array + @param ofs 数组起始偏移量 + */ + static fromArray (out: Out, arr: IWritableArrayLike, ofs?: number): Out; + /** !#en Matrix Data + !#zh 矩阵数据 */ + m: Float64Array|Float32Array; + /** + !#en + Constructor + see {{#crossLink "cc/mat4:method"}}cc.mat4{{/crossLink}} + !#zh + 构造函数,可查看 {{#crossLink "cc/mat4:method"}}cc.mat4{{/crossLink}} + */ + constructor ( m00?: number, m01?: number, m02?: number, m03?: number, m10?: number, m11?: number, m12?: number, m13?: number, m20?: number, m21?: number, m22?: number, m23?: number, m30?: number, m31?: number, m32?: number, m33?: number); + /** + !#en clone a Mat4 object + !#zh 克隆一个 Mat4 对象 + */ + clone(): Mat4; + /** + !#en Sets the matrix with another one's value + !#zh 用另一个矩阵设置这个矩阵的值。 + @param srcObj srcObj + */ + set(srcObj: Mat4): Mat4; + /** + !#en Check whether two matrix equal + !#zh 当前的矩阵是否与指定的矩阵相等。 + @param other other + */ + equals(other: Mat4): boolean; + /** + !#en Check whether two matrix equal with default degree of variance. + !#zh + 近似判断两个矩阵是否相等。
+ 判断 2 个矩阵是否在默认误差范围之内,如果在则返回 true,反之则返回 false。 + @param other other + */ + fuzzyEquals(other: Mat4): boolean; + /** + !#en Transform to string with matrix informations + !#zh 转换为方便阅读的字符串。 + */ + toString(): string; + /** + Set the matrix to the identity matrix + */ + identity(): Mat4; + /** + Transpose the values of a mat4 + @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created. + */ + transpose(out?: Mat4): Mat4; + /** + Inverts a mat4 + @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created. + */ + invert(out?: Mat4): Mat4; + /** + Calculates the adjugate of a mat4 + @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created. + */ + adjoint(out?: Mat4): Mat4; + /** + Calculates the determinant of a mat4 + */ + determinant(): number; + /** + Adds two Mat4 + @param other the second operand + @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created. + */ + add(other: Mat4, out?: Mat4): Mat4; + /** + Subtracts the current matrix with another one + @param other the second operand + */ + subtract(other: Mat4): Mat4; + /** + Subtracts the current matrix with another one + @param other the second operand + */ + multiply(other: Mat4): Mat4; + /** + Multiply each element of the matrix by a scalar. + @param number amount to scale the matrix's elements by + */ + multiplyScalar(number: number): Mat4; + /** + Translate a mat4 by the given vector + @param v vector to translate by + @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created + */ + translate(v: Vec3, out?: Mat4): Mat4; + /** + Scales the mat4 by the dimensions in the given vec3 + @param v vector to scale by + @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created + */ + scale(v: Vec3, out?: Mat4): Mat4; + /** + Rotates a mat4 by the given angle around the given axis + @param rad the angle to rotate the matrix by + @param axis the axis to rotate around + @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created + */ + rotate(rad: number, axis: Vec3, out?: Mat4): Mat4; + /** + Returns the translation vector component of a transformation matrix. + @param out Vector to receive translation component, if not provided, a new vec3 will be created + */ + getTranslation(out: Vec3): Vec3; + /** + Returns the scale factor component of a transformation matrix + @param out Vector to receive scale component, if not provided, a new vec3 will be created + */ + getScale(out: Vec3): Vec3; + /** + Returns the rotation factor component of a transformation matrix + @param out Vector to receive rotation component, if not provided, a new quaternion object will be created + */ + getRotation(out: Quat): Quat; + /** + Restore the matrix values from a quaternion rotation, vector translation and vector scale + @param q Rotation quaternion + @param v Translation vector + @param s Scaling vector + */ + fromRTS(q: Quat, v: Vec3, s: Vec3): Mat4; + /** + Restore the matrix values from a quaternion rotation + @param q Rotation quaternion + */ + fromQuat(q: Quat): Mat4; + } + /** !#en Representation of 2D vectors and points. + !#zh 表示 2D 向量和坐标 */ + export class Quat extends ValueType { + /** + !#en + Constructor + see {{#crossLink "cc/quat:method"}}cc.quat{{/crossLink}} + !#zh + 构造函数,可查看 {{#crossLink "cc/quat:method"}}cc.quat{{/crossLink}} + @param x x + @param y y + @param z z + @param w w + */ + constructor(x?: number, y?: number, z?: number, w?: number); + /** + !#en Calculate the multiply result between this quaternion and another one + !#zh 计算四元数乘积的结果 + @param other other + @param out out + */ + mul(other: Quat, out?: Quat): Quat; + /** + !#zh 获得指定四元数的拷贝 + !#en Obtaining copy specified quaternion + */ + static clone (a: Out): Quat; + /** + !#zh 复制目标四元数 + !#en Copy quaternion target + */ + static copy (out: Out, a: QuatLike): Out; + /** + !#zh 设置四元数值 + !#en Provided Quaternion Value + */ + static set (out: Out, x: number, y: number, z: number, w: number): Out; + /** + !#zh 将目标赋值为单位四元数 + !#en The target of an assignment as a unit quaternion + */ + static identity (out: Out): Out; + /** + !#zh 设置四元数为两向量间的最短路径旋转,默认两向量都已归一化 + !#en Set quaternion rotation is the shortest path between two vectors, the default two vectors are normalized + */ + static rotationTo (out: Out, a: VecLike, b: VecLike): Out; + /** + !#zh 获取四元数的旋转轴和旋转弧度 + !#en Get the rotary shaft and the arc of rotation quaternion + @param outAxis 旋转轴输出 + @param q 源四元数 + */ + static getAxisAngle (outAxis: VecLike, q: Out): number; + /** + !#zh 四元数乘法 + !#en Quaternion multiplication + */ + static multiply (out: Out, a: QuatLike_1, b: QuatLike_2): Out; + /** + !#zh 四元数标量乘法 + !#en Quaternion scalar multiplication + */ + static multiplyScalar (out: Out, a: Out, b: number): Out; + /** + !#zh 四元数乘加:A + B * scale + !#en Quaternion multiplication and addition: A + B * scale + */ + static scaleAndAdd (out: Out, a: Out, b: Out, scale: number): Out; + /** + !#zh 绕 X 轴旋转指定四元数 + !#en About the X axis specified quaternion + @param rad 旋转弧度 + */ + static rotateX (out: Out, a: Out, rad: number): Out; + /** + !#zh 绕 Y 轴旋转指定四元数 + !#en Rotation about the Y axis designated quaternion + @param rad 旋转弧度 + */ + static rotateY (out: Out, a: Out, rad: number): Out; + /** + !#zh 绕 Z 轴旋转指定四元数 + !#en Around the Z axis specified quaternion + @param rad 旋转弧度 + */ + static rotateZ (out: Out, a: Out, rad: number): Out; + /** + !#zh 绕世界空间下指定轴旋转四元数 + !#en Space around the world at a given axis of rotation quaternion + @param axis 旋转轴,默认已归一化 + @param rad 旋转弧度 + */ + static rotateAround (out: Out, rot: Out, axis: VecLike, rad: number): Out; + /** + !#zh 绕本地空间下指定轴旋转四元数 + !#en Local space around the specified axis rotation quaternion + @param axis 旋转轴 + @param rad 旋转弧度 + */ + static rotateAroundLocal (out: Out, rot: Out, axis: VecLike, rad: number): Out; + /** + !#zh 根据 xyz 分量计算 w 分量,默认已归一化 + !#en The component w xyz components calculated, normalized by default + */ + static calculateW (out: Out, a: Out): Out; + /** + !#zh 四元数点积(数量积) + !#en Quaternion dot product (scalar product) + */ + static dot (a: Out, b: Out): number; + /** + !#zh 逐元素线性插值: A + t * (B - A) + !#en Element by element linear interpolation: A + t * (B - A) + */ + static lerp (out: Out, a: Out, b: Out, t: number): Out; + /** + !#zh 带两个控制点的四元数球面插值 + !#en Quaternion with two spherical interpolation control points + */ + static sqlerp (out: Out, a: Out, b: Out, c: Out, d: Out, t: number): Out; + /** + !#zh 四元数求逆 + !#en Quaternion inverse + */ + static invert (out: Out, a: QuatLike): Out; + /** + !#zh 求共轭四元数,对单位四元数与求逆等价,但更高效 + !#en Conjugating a quaternion, and the unit quaternion equivalent to inversion, but more efficient + */ + static conjugate (out: Out, a: Out): Out; + /** + !#zh 求四元数长度 + !#en Seek length quaternion + */ + static len (a: Out): number; + /** + !#zh 求四元数长度平方 + !#en Seeking quaternion square of the length + */ + static lengthSqr (a: Out): number; + /** + !#zh 归一化四元数 + !#en Normalized quaternions + */ + static normalize (out: Out, a: Out): Out; + /** + !#zh 根据本地坐标轴朝向计算四元数,默认三向量都已归一化且相互垂直 + !#en Calculated according to the local orientation quaternion coordinate axis, the default three vectors are normalized and mutually perpendicular + */ + static fromAxes (out: Out, xAxis: VecLike, yAxis: VecLike, zAxis: VecLike): Out; + /** + !#zh 根据视口的前方向和上方向计算四元数 + !#en The forward direction and the direction of the viewport computing quaternion + @param view 视口面向的前方向,必须归一化 + @param up 视口的上方向,必须归一化,默认为 (0, 1, 0) + */ + static fromViewUp (out: Out, view: Vec3, up?: Vec3): Out; + /** + !#zh 根据旋转轴和旋转弧度计算四元数 + !#en The quaternion calculated and the arc of rotation of the rotary shaft + */ + static fromAxisAngle (out: Out, axis: VecLike, rad: number): Out; + /** + !#zh 根据三维矩阵信息计算四元数,默认输入矩阵不含有缩放信息 + !#en Calculating the three-dimensional quaternion matrix information, default zoom information input matrix does not contain + */ + static fromMat3 (out: Out, mat: Mat3): Out; + /** + !#zh 根据欧拉角信息计算四元数,旋转顺序为 YZX + !#en The quaternion calculated Euler angle information, rotation order YZX + */ + static fromEuler (out: Out, x: number, y: number, z: number): Out; + /** + !#zh 返回定义此四元数的坐标系 X 轴向量 + !#en This returns the result of the quaternion coordinate system X-axis vector + */ + static toAxisX (out: VecLike, q: Out): VecLike; + /** + !#zh 返回定义此四元数的坐标系 Y 轴向量 + !#en This returns the result of the quaternion coordinate system Y axis vector + */ + static toAxisY (out: VecLike, q: Out): VecLike; + /** + !#zh 返回定义此四元数的坐标系 Z 轴向量 + !#en This returns the result of the quaternion coordinate system the Z-axis vector + */ + static toAxisZ (out: VecLike, q: Out): VecLike; + /** + !#zh 根据四元数计算欧拉角,返回角度 x, y 在 [-180, 180] 区间内, z 默认在 [-90, 90] 区间内,旋转顺序为 YZX + !#en The quaternion calculated Euler angles, return angle x, y in the [-180, 180] interval, z default the range [-90, 90] interval, the rotation order YZX + @param outerZ z 取值范围区间改为 [-180, -90] U [90, 180] + */ + static toEuler (out: Out, q: IQuatLike, outerZ?: boolean): Out; + /** + !#zh 四元数等价判断 + !#en Analyzing quaternion equivalent + */ + static strictEquals (a: Out, b: Out): boolean; + /** + !#zh 排除浮点数误差的四元数近似等价判断 + !#en Negative floating point error quaternion approximately equivalent Analyzing + */ + static equals (a: Out, b: Out, epsilon?: number): boolean; + /** + !#zh 四元数转数组 + !#en Quaternion rotation array + @param ofs 数组内的起始偏移量 + */ + static toArray > (out: Out, q: IQuatLike, ofs?: number): Out; + /** + !#zh 数组转四元数 + !#en Array to a quaternion + @param ofs 数组起始偏移量 + */ + static fromArray (out: Out, arr: IWritableArrayLike, ofs?: number): Out; + x: number; + y: number; + z: number; + w: number; + /** + !#en clone a Quat object and return the new object + !#zh 克隆一个四元数并返回 + */ + clone(): Quat; + /** + !#en Set values with another quaternion + !#zh 用另一个四元数的值设置到当前对象上。 + @param newValue !#en new value to set. !#zh 要设置的新值 + */ + set(newValue: Quat): Quat; + /** + !#en Check whether current quaternion equals another + !#zh 当前的四元数是否与指定的四元数相等。 + @param other other + */ + equals(other: Quat): boolean; + /** + !#en Convert quaternion to euler + !#zh 转换四元数到欧拉角 + @param out out + */ + toEuler(out: Vec3): Vec3; + /** + !#en Convert euler to quaternion + !#zh 转换欧拉角到四元数 + @param euler euler + */ + fromEuler(euler: Vec3): Quat; + /** + !#en Calculate the interpolation result between this quaternion and another one with given ratio + !#zh 计算四元数的插值结果 + @param to to + @param ratio ratio + @param out out + */ + lerp(to: Quat, ratio: number, out?: Quat): Quat; + /** + !#en Calculate the multiply result between this quaternion and another one + !#zh 计算四元数乘积的结果 + @param other other + */ + multiply(other: Quat): Quat; + /** + !#en Rotates a quaternion by the given angle (in radians) about a world space axis. + !#zh 围绕世界空间轴按给定弧度旋转四元数 + @param rot Quaternion to rotate + @param axis The axis around which to rotate in world space + @param rad Angle (in radians) to rotate + @param out Quaternion to store result + */ + rotateAround(rot: Quat, axis: Vec3, rad: number, out?: Quat): Quat; + } + /** !#en A 2D rectangle defined by x, y position and width, height. + !#zh 通过位置和宽高定义的 2D 矩形。 */ + export class Rect extends ValueType { + /** + !#en + Constructor of Rect class. + see {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} for convenience method. + !#zh + Rect类的构造函数。可以通过 {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} 简便方法进行创建。 + @param x x + @param y y + @param w w + @param h h + */ + constructor(x?: number, y?: number, w?: number, h?: number); + /** + !#en Creates a rectangle from two coordinate values. + !#zh 根据指定 2 个坐标创建出一个矩形区域。 + @param v1 v1 + @param v2 v2 + + @example + ```js + cc.Rect.fromMinMax(cc.v2(10, 10), cc.v2(20, 20)); // Rect {x: 10, y: 10, width: 10, height: 10}; + ``` + */ + static fromMinMax(v1: Vec2, v2: Vec2): Rect; + x: number; + y: number; + width: number; + height: number; + /** + !#en TODO + !#zh 克隆一个新的 Rect。 + + @example + ```js + var a = new cc.Rect(0, 0, 10, 10); + a.clone();// Rect {x: 0, y: 0, width: 10, height: 10} + ``` + */ + clone(): Rect; + /** + !#en TODO + !#zh 是否等于指定的矩形。 + @param other other + + @example + ```js + var a = new cc.Rect(0, 0, 10, 10); + var b = new cc.Rect(0, 0, 10, 10); + a.equals(b);// true; + ``` + */ + equals(other: Rect): boolean; + /** + !#en TODO + !#zh 线性插值 + @param to to + @param ratio the interpolation coefficient. + @param out optional, the receiving vector. + + @example + ```js + var a = new cc.Rect(0, 0, 10, 10); + var b = new cc.Rect(50, 50, 100, 100); + update (dt) { + // method 1; + var c = a.lerp(b, dt * 0.1); + // method 2; + a.lerp(b, dt * 0.1, c); + } + ``` + */ + lerp(to: Rect, ratio: number, out?: Rect): Rect; + /** + !#en Check whether the current rectangle intersects with the given one + !#zh 当前矩形与指定矩形是否相交。 + @param rect rect + + @example + ```js + var a = new cc.Rect(0, 0, 10, 10); + var b = new cc.Rect(0, 0, 20, 20); + a.intersects(b);// true + ``` + */ + intersects(rect: Rect): boolean; + /** + !#en Returns the overlapping portion of 2 rectangles. + !#zh 返回 2 个矩形重叠的部分。 + @param out Stores the result + @param rectB rectB + + @example + ```js + var a = new cc.Rect(0, 10, 20, 20); + var b = new cc.Rect(0, 10, 10, 10); + var intersection = new cc.Rect(); + a.intersection(intersection, b); // intersection {x: 0, y: 10, width: 10, height: 10}; + ``` + */ + intersection(out: Rect, rectB: Rect): Rect; + /** + !#en Check whether the current rect contains the given point + !#zh 当前矩形是否包含指定坐标点。 + Returns true if the point inside this rectangle. + @param point point + + @example + ```js + var a = new cc.Rect(0, 0, 10, 10); + var b = new cc.Vec2(0, 5); + a.contains(b);// true + ``` + */ + contains(point: Vec2): boolean; + /** + !#en Returns true if the other rect totally inside this rectangle. + !#zh 当前矩形是否包含指定矩形。 + @param rect rect + + @example + ```js + var a = new cc.Rect(0, 0, 20, 20); + var b = new cc.Rect(0, 0, 10, 10); + a.containsRect(b);// true + ``` + */ + containsRect(rect: Rect): boolean; + /** + !#en Returns the smallest rectangle that contains the current rect and the given rect. + !#zh 返回一个包含当前矩形和指定矩形的最小矩形。 + @param out Stores the result + @param rectB rectB + + @example + ```js + var a = new cc.Rect(0, 10, 20, 20); + var b = new cc.Rect(0, 10, 10, 10); + var union = new cc.Rect(); + a.union(union, b); // union {x: 0, y: 10, width: 20, height: 20}; + ``` + */ + union(out: Rect, rectB: Rect): Rect; + /** + !#en Apply matrix4 to the rect. + !#zh 使用 mat4 对矩形进行矩阵转换。 + @param out The output rect + @param mat The matrix4 + */ + transformMat4(out: Rect, mat: Mat4): void; + /** + !#en Output rect informations to string + !#zh 转换为方便阅读的字符串 + + @example + ```js + var a = new cc.Rect(0, 0, 10, 10); + a.toString();// "(0.00, 0.00, 10.00, 10.00)"; + ``` + */ + toString(): string; + /** !#en The minimum x value, equals to rect.x + !#zh 矩形 x 轴上的最小值,等价于 rect.x。 */ + xMin: number; + /** !#en The minimum y value, equals to rect.y + !#zh 矩形 y 轴上的最小值。 */ + yMin: number; + /** !#en The maximum x value. + !#zh 矩形 x 轴上的最大值。 */ + xMax: number; + /** !#en The maximum y value. + !#zh 矩形 y 轴上的最大值。 */ + yMax: number; + /** !#en The position of the center of the rectangle. + !#zh 矩形的中心点。 */ + center: Vec2; + /** !#en The X and Y position of the rectangle. + !#zh 矩形的 x 和 y 坐标。 */ + origin: Vec2; + /** !#en Width and height of the rectangle. + !#zh 矩形的大小。 */ + size: Size; + } + /** !#en + cc.Size is the class for size object,
+ please do not use its constructor to create sizes,
+ use {{#crossLink "cc/size:method"}}{{/crossLink}} alias function instead.
+ It will be deprecated soon, please use cc.Vec2 instead. + + !#zh + cc.Size 是 size 对象的类。
+ 请不要使用它的构造函数创建的 size,
+ 使用 {{#crossLink "cc/size:method"}}{{/crossLink}} 别名函数。
+ 它不久将被取消,请使用cc.Vec2代替。 */ + export class Size { + /** + + @param width width + @param height height + */ + constructor(width: number|Size, height?: number); + /** !#en return a Size object with width = 0 and height = 0. + !#zh 返回一个宽度为 0 和高度为 0 的 Size 对象。 */ + static ZERO: Size; + width: number; + height: number; + /** + !#en TODO + !#zh 克隆 size 对象。 + + @example + ```js + var a = new cc.size(10, 10); + a.clone();// return Size {width: 0, height: 0}; + ``` + */ + clone(): Size; + /** + !#en TODO + !#zh 当前 Size 对象是否等于指定 Size 对象。 + @param other other + + @example + ```js + var a = new cc.size(10, 10); + a.equals(new cc.size(10, 10));// return true; + ``` + */ + equals(other: Size): boolean; + /** + !#en TODO + !#zh 线性插值。 + @param to to + @param ratio the interpolation coefficient. + @param out optional, the receiving vector. + + @example + ```js + var a = new cc.size(10, 10); + var b = new cc.rect(50, 50, 100, 100); + update (dt) { + // method 1; + var c = a.lerp(b, dt * 0.1); + // method 2; + a.lerp(b, dt * 0.1, c); + } + ``` + */ + lerp(to: Rect, ratio: number, out?: Size): Size; + /** + !#en TODO + !#zh 转换为方便阅读的字符串。 + + @example + ```js + var a = new cc.size(10, 10); + a.toString();// return "(10.00, 10.00)"; + ``` + */ + toString(): string; + } + /** !#en The base class of all value types. + !#zh 所有值类型的基类。 */ + export class ValueType { + /** + !#en This method returns an exact copy of current value. + !#zh 克隆当前值,该方法返回一个新对象,新对象的值和原对象相等。 + */ + clone(): ValueType; + /** + !#en Compares this object with the other one. + !#zh 当前对象是否等于指定对象。 + @param other other + */ + equals(other: ValueType): boolean; + /** + !#en + Linearly interpolates between this value to to value by ratio which is in the range [0, 1]. + When ratio = 0 returns this. When ratio = 1 return to. When ratio = 0.5 returns the average of this and to. + !#zh + 线性插值。
+ 当 ratio = 0 时返回自身,ratio = 1 时返回目标,ratio = 0.5 返回自身和目标的平均值。。 + @param to the to value + @param ratio the interpolation coefficient + */ + lerp(to: ValueType, ratio: number): ValueType; + /** + !#en + Copys all the properties from another given object to this value. + !#zh + 从其它对象把所有属性复制到当前对象。 + @param source the source to copy + */ + set(source: ValueType): void; + /** + !#en Convert to a readable string. + !#zh 转换为方便阅读的字符串。 + */ + toString(): string; + } + /** !#en Representation of 2D vectors and points. + !#zh 表示 2D 向量和坐标 */ + export class Vec2 extends ValueType { + /** + !#en Returns the length of this vector. + !#zh 返回该向量的长度。 + + @example + ```js + var v = cc.v2(10, 10); + v.mag(); // return 14.142135623730951; + ``` + */ + mag(): number; + /** + !#en Returns the squared length of this vector. + !#zh 返回该向量的长度平方。 + + @example + ```js + var v = cc.v2(10, 10); + v.magSqr(); // return 200; + ``` + */ + magSqr(): number; + /** + !#en Subtracts one vector from this. If you want to save result to another vector, use sub() instead. + !#zh 向量减法。如果你想保存结果到另一个向量,可使用 sub() 代替。 + @param vector vector + + @example + ```js + var v = cc.v2(10, 10); + v.subSelf(cc.v2(5, 5));// return Vec2 {x: 5, y: 5}; + ``` + */ + subSelf(vector: Vec2): Vec2; + /** + !#en Subtracts one vector from this, and returns the new result. + !#zh 向量减法,并返回新结果。 + @param vector vector + @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created + + @example + ```js + var v = cc.v2(10, 10); + v.sub(cc.v2(5, 5)); // return Vec2 {x: 5, y: 5}; + var v1; + v.sub(cc.v2(5, 5), v1); // return Vec2 {x: 5, y: 5}; + ``` + */ + sub(vector: Vec2, out?: Vec2): Vec2; + /** + !#en Multiplies this by a number. If you want to save result to another vector, use mul() instead. + !#zh 缩放当前向量。如果你想结果保存到另一个向量,可使用 mul() 代替。 + @param num num + + @example + ```js + var v = cc.v2(10, 10); + v.mulSelf(5);// return Vec2 {x: 50, y: 50}; + ``` + */ + mulSelf(num: number): Vec2; + /** + !#en Multiplies by a number, and returns the new result. + !#zh 缩放向量,并返回新结果。 + @param num num + @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created + + @example + ```js + var v = cc.v2(10, 10); + v.mul(5); // return Vec2 {x: 50, y: 50}; + var v1; + v.mul(5, v1); // return Vec2 {x: 50, y: 50}; + ``` + */ + mul(num: number, out?: Vec2): Vec2; + /** + !#en Divides by a number. If you want to save result to another vector, use div() instead. + !#zh 向量除法。如果你想结果保存到另一个向量,可使用 div() 代替。 + @param num num + + @example + ```js + var v = cc.v2(10, 10); + v.divSelf(5); // return Vec2 {x: 2, y: 2}; + ``` + */ + divSelf(num: number): Vec2; + /** + !#en Divides by a number, and returns the new result. + !#zh 向量除法,并返回新的结果。 + @param num num + @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created + + @example + ```js + var v = cc.v2(10, 10); + v.div(5); // return Vec2 {x: 2, y: 2}; + var v1; + v.div(5, v1); // return Vec2 {x: 2, y: 2}; + ``` + */ + div(num: number, out?: Vec2): Vec2; + /** + !#en Multiplies two vectors. + !#zh 分量相乘。 + @param vector vector + + @example + ```js + var v = cc.v2(10, 10); + v.scaleSelf(cc.v2(5, 5));// return Vec2 {x: 50, y: 50}; + ``` + */ + scaleSelf(vector: Vec2): Vec2; + /** + !#en Multiplies two vectors, and returns the new result. + !#zh 分量相乘,并返回新的结果。 + @param vector vector + @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created + + @example + ```js + var v = cc.v2(10, 10); + v.scale(cc.v2(5, 5)); // return Vec2 {x: 50, y: 50}; + var v1; + v.scale(cc.v2(5, 5), v1); // return Vec2 {x: 50, y: 50}; + ``` + */ + scale(vector: Vec2, out?: Vec2): Vec2; + /** + !#en Negates the components. If you want to save result to another vector, use neg() instead. + !#zh 向量取反。如果你想结果保存到另一个向量,可使用 neg() 代替。 + + @example + ```js + var v = cc.v2(10, 10); + v.negSelf(); // return Vec2 {x: -10, y: -10}; + ``` + */ + negSelf(): Vec2; + /** + !#en Negates the components, and returns the new result. + !#zh 返回取反后的新向量。 + @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created + + @example + ```js + var v = cc.v2(10, 10); + var v1; + v.neg(v1); // return Vec2 {x: -10, y: -10}; + ``` + */ + neg(out?: Vec2): Vec2; + /** !#en return a Vec2 object with x = 1 and y = 1. + !#zh 新 Vec2 对象。 */ + static ONE: Vec2; + /** !#en return a Vec2 object with x = 0 and y = 0. + !#zh 返回 x = 0 和 y = 0 的 Vec2 对象。 */ + static ZERO: Vec2; + /** !#en return a readonly Vec2 object with x = 0 and y = 0. + !#zh 返回一个 x = 0 和 y = 0 的 Vec2 只读对象。 */ + static ZERO_R: Vec2; + /** !#en return a Vec2 object with x = 0 and y = 1. + !#zh 返回 x = 0 和 y = 1 的 Vec2 对象。 */ + static UP: Vec2; + /** !#en return a readonly Vec2 object with x = 0 and y = 1. + !#zh 返回 x = 0 和 y = 1 的 Vec2 只读对象。 */ + static UP_R: Vec2; + /** !#en return a readonly Vec2 object with x = 1 and y = 0. + !#zh 返回 x = 1 和 y = 0 的 Vec2 只读对象。 */ + static RIGHT: Vec2; + /** !#en return a Vec2 object with x = 1 and y = 0. + !#zh 返回 x = 1 和 y = 0 的 Vec2 对象。 */ + static RIGHT_R: Vec2; + /** + !#zh 获得指定向量的拷贝 + */ + static clone (a: Out): Vec2; + /** + !#zh 复制指定向量的值 + */ + static copy (out: Out, a: Out): Out; + /** + !#zh 设置向量值 + */ + static set (out: Out, x: number, y: number): Out; + /** + !#zh 逐元素向量加法 + */ + static add (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量减法 + */ + static subtract (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量乘法 + */ + static multiply (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量除法 + */ + static divide (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量向上取整 + */ + static ceil (out: Out, a: Out): Out; + /** + !#zh 逐元素向量向下取整 + */ + static floor (out: Out, a: Out): Out; + /** + !#zh 逐元素向量最小值 + */ + static min (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量最大值 + */ + static max (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量四舍五入取整 + */ + static round (out: Out, a: Out): Out; + /** + !#zh 向量标量乘法 + */ + static multiplyScalar (out: Out, a: Out, b: number): Out; + /** + !#zh 逐元素向量乘加: A + B * scale + */ + static scaleAndAdd (out: Out, a: Out, b: Out, scale: number): Out; + /** + !#zh 求两向量的欧氏距离 + */ + static distance (a: Out, b: Out): number; + /** + !#zh 求两向量的欧氏距离平方 + */ + static squaredDistance (a: Out, b: Out): number; + /** + !#zh 求向量长度 + */ + static len (a: Out): number; + /** + !#zh 求向量长度平方 + */ + static lengthSqr (a: Out): number; + /** + !#zh 逐元素向量取负 + */ + static negate (out: Out, a: Out): Out; + /** + !#zh 逐元素向量取倒数,接近 0 时返回 Infinity + */ + static inverse (out: Out, a: Out): Out; + /** + !#zh 逐元素向量取倒数,接近 0 时返回 0 + */ + static inverseSafe (out: Out, a: Out): Out; + /** + !#zh 归一化向量 + */ + static normalize (out: Out, a: Vec2Like): Out; + /** + !#zh 向量点积(数量积) + */ + static dot (a: Out, b: Out): number; + /** + !#zh 向量叉积(向量积),注意二维向量的叉积为与 Z 轴平行的三维向量 + */ + static cross (out: Vec2, a: Out, b: Out): Vec2; + /** + !#zh 逐元素向量线性插值: A + t * (B - A) + */ + static lerp (out: Out, a: Out, b: Out, t: number): Out; + /** + !#zh 生成一个在单位圆上均匀分布的随机向量 + */ + static random (out: Out, scale?: number): Out; + /** + !#zh 向量与三维矩阵乘法,默认向量第三位为 1。 + */ + static transformMat3 (out: Out, a: Out, mat: IMat3Like): Out; + /** + !#zh 向量与四维矩阵乘法,默认向量第三位为 0,第四位为 1。 + */ + static transformMat4 (out: Out, a: Out, mat: MatLike): Out; + /** + !#zh 向量等价判断 + */ + static strictEquals (a: Out, b: Out): boolean; + /** + !#zh 排除浮点数误差的向量近似等价判断 + */ + static equals (a: Out, b: Out, epsilon?: number): boolean; + /** + !#zh 排除浮点数误差的向量近似等价判断 + */ + static angle (a: Out, b: Out): number; + /** + !#zh 向量转数组 + */ + static toArray > (out: Out, v: IVec2Like, ofs?: number): Out; + /** + !#zh 数组转向量 + */ + static fromArray (out: Out, arr: IWritableArrayLike, ofs?: number): Out; + x: number; + y: number; + /** + !#en + Constructor + see {{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} or {{#crossLink "cc/p:method"}}cc.p{{/crossLink}} + !#zh + 构造函数,可查看 {{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} 或者 {{#crossLink "cc/p:method"}}cc.p{{/crossLink}} + @param x x + @param y y + */ + constructor(x?: number, y?: number); + /** + !#en clone a Vec2 object + !#zh 克隆一个 Vec2 对象 + */ + clone(): Vec2; + /** + !#en Sets vector with another's value + !#zh 设置向量值。 + @param newValue !#en new value to set. !#zh 要设置的新值 + */ + set(newValue: Vec2): Vec2; + /** + !#en Check whether two vector equal + !#zh 当前的向量是否与指定的向量相等。 + @param other other + */ + equals(other: Vec2): boolean; + /** + !#en Check whether two vector equal with some degree of variance. + !#zh + 近似判断两个点是否相等。
+ 判断 2 个向量是否在指定数值的范围之内,如果在则返回 true,反之则返回 false。 + @param other other + @param variance variance + */ + fuzzyEquals(other: Vec2, variance: number): boolean; + /** + !#en Transform to string with vector informations + !#zh 转换为方便阅读的字符串。 + */ + toString(): string; + /** + !#en Calculate linear interpolation result between this vector and another one with given ratio + !#zh 线性插值。 + @param to to + @param ratio the interpolation coefficient + @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created + */ + lerp(to: Vec2, ratio: number, out?: Vec2): Vec2; + /** + !#en Clamp the vector between from float and to float. + !#zh + 返回指定限制区域后的向量。
+ 向量大于 max_inclusive 则返回 max_inclusive。
+ 向量小于 min_inclusive 则返回 min_inclusive。
+ 否则返回自身。 + @param min_inclusive min_inclusive + @param max_inclusive max_inclusive + + @example + ```js + var min_inclusive = cc.v2(0, 0); + var max_inclusive = cc.v2(20, 20); + var v1 = cc.v2(20, 20).clampf(min_inclusive, max_inclusive); // Vec2 {x: 20, y: 20}; + var v2 = cc.v2(0, 0).clampf(min_inclusive, max_inclusive); // Vec2 {x: 0, y: 0}; + var v3 = cc.v2(10, 10).clampf(min_inclusive, max_inclusive); // Vec2 {x: 10, y: 10}; + ``` + */ + clampf(min_inclusive: Vec2, max_inclusive: Vec2): Vec2; + /** + !#en Adds this vector. + !#zh 向量加法。 + @param vector vector + @param out out + + @example + ```js + var v = cc.v2(10, 10); + v.add(cc.v2(5, 5));// return Vec2 {x: 15, y: 15}; + ``` + */ + add(vector: Vec2, out?: Vec2): Vec2; + /** + !#en Adds this vector. If you want to save result to another vector, use add() instead. + !#zh 向量加法。如果你想保存结果到另一个向量,使用 add() 代替。 + @param vector vector + */ + addSelf(vector: Vec2): Vec2; + /** + !#en Subtracts one vector from this. + !#zh 向量减法。 + @param vector vector + + @example + ```js + var v = cc.v2(10, 10); + v.subSelf(cc.v2(5, 5));// return Vec2 {x: 5, y: 5}; + ``` + */ + subtract(vector: Vec2): Vec2; + /** + !#en Multiplies this by a number. + !#zh 缩放当前向量。 + @param num num + + @example + ```js + var v = cc.v2(10, 10); + v.multiply(5);// return Vec2 {x: 50, y: 50}; + ``` + */ + multiplyScalar(num: number): Vec2; + /** + !#en Multiplies two vectors. + !#zh 分量相乘。 + @param vector vector + + @example + ```js + var v = cc.v2(10, 10); + v.multiply(cc.v2(5, 5));// return Vec2 {x: 50, y: 50}; + ``` + */ + multiply(vector: Vec2): Vec2; + /** + !#en Divides by a number. + !#zh 向量除法。 + @param num num + + @example + ```js + var v = cc.v2(10, 10); + v.divide(5); // return Vec2 {x: 2, y: 2}; + ``` + */ + divide(num: number): Vec2; + /** + !#en Negates the components. + !#zh 向量取反。 + + @example + ```js + var v = cc.v2(10, 10); + v.negate(); // return Vec2 {x: -10, y: -10}; + ``` + */ + negate(): Vec2; + /** + !#en Dot product + !#zh 当前向量与指定向量进行点乘。 + @param vector vector + + @example + ```js + var v = cc.v2(10, 10); + v.dot(cc.v2(5, 5)); // return 100; + ``` + */ + dot(vector?: Vec2): number; + /** + !#en Cross product + !#zh 当前向量与指定向量进行叉乘。 + @param vector vector + + @example + ```js + var v = cc.v2(10, 10); + v.cross(cc.v2(5, 5)); // return 0; + ``` + */ + cross(vector?: Vec2): number; + /** + !#en Returns the length of this vector. + !#zh 返回该向量的长度。 + + @example + ```js + var v = cc.v2(10, 10); + v.len(); // return 14.142135623730951; + ``` + */ + len(): number; + /** + !#en Returns the squared length of this vector. + !#zh 返回该向量的长度平方。 + + @example + ```js + var v = cc.v2(10, 10); + v.lengthSqr(); // return 200; + ``` + */ + lengthSqr(): number; + /** + !#en Make the length of this vector to 1. + !#zh 向量归一化,让这个向量的长度为 1。 + + @example + ```js + var v = cc.v2(10, 10); + v.normalizeSelf(); // return Vec2 {x: 0.7071067811865475, y: 0.7071067811865475}; + ``` + */ + normalizeSelf(): Vec2; + /** + !#en + Returns this vector with a magnitude of 1.
+
+ Note that the current vector is unchanged and a new normalized vector is returned. If you want to normalize the current vector, use normalizeSelf function. + !#zh + 返回归一化后的向量。
+
+ 注意,当前向量不变,并返回一个新的归一化向量。如果你想来归一化当前向量,可使用 normalizeSelf 函数。 + @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created + */ + normalize(out?: Vec2): Vec2; + /** + !#en Get angle in radian between this and vector. + !#zh 夹角的弧度。 + @param vector vector + */ + angle(vector: Vec2): number; + /** + !#en Get angle in radian between this and vector with direction. + !#zh 带方向的夹角的弧度。 + @param vector vector + */ + signAngle(vector: Vec2): number; + /** + !#en rotate + !#zh 返回旋转给定弧度后的新向量。 + @param radians radians + @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created + */ + rotate(radians: number, out?: Vec2): Vec2; + /** + !#en rotate self + !#zh 按指定弧度旋转向量。 + @param radians radians + */ + rotateSelf(radians: number): Vec2; + /** + !#en Calculates the projection of the current vector over the given vector. + !#zh 返回当前向量在指定 vector 向量上的投影向量。 + @param vector vector + + @example + ```js + var v1 = cc.v2(20, 20); + var v2 = cc.v2(5, 5); + v1.project(v2); // Vec2 {x: 20, y: 20}; + ``` + */ + project(vector: Vec2): Vec2; + /** + Transforms the vec2 with a mat4. 3rd vector component is implicitly '0', 4th vector component is implicitly '1' + @param m matrix to transform with + @param out the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created + */ + transformMat4(m: Mat4, out?: Vec2): Vec2; + /** + Returns the maximum value in x, y. + */ + maxAxis(): number; + } + /** !#en Representation of 3D vectors and points. + !#zh 表示 3D 向量和坐标 */ + export class Vec3 extends ValueType { + /** + !#en Returns the length of this vector. + !#zh 返回该向量的长度。 + + @example + ```js + var v = cc.v3(10, 10, 10); + v.mag(); // return 17.320508075688775; + ``` + */ + mag(): number; + /** + !#en Returns the squared length of this vector. + !#zh 返回该向量的长度平方。 + */ + magSqr(): number; + /** + !#en Subtracts one vector from this. If you want to save result to another vector, use sub() instead. + !#zh 向量减法。如果你想保存结果到另一个向量,可使用 sub() 代替。 + @param vector vector + */ + subSelf(vector: Vec3): Vec3; + /** + !#en Subtracts one vector from this, and returns the new result. + !#zh 向量减法,并返回新结果。 + @param vector vector + @param out optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created + */ + sub(vector: Vec3, out?: Vec3): Vec3; + /** + !#en Multiplies this by a number. If you want to save result to another vector, use mul() instead. + !#zh 缩放当前向量。如果你想结果保存到另一个向量,可使用 mul() 代替。 + @param num num + */ + mulSelf(num: number): Vec3; + /** + !#en Multiplies by a number, and returns the new result. + !#zh 缩放向量,并返回新结果。 + @param num num + @param out optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created + */ + mul(num: number, out?: Vec3): Vec3; + /** + !#en Divides by a number. If you want to save result to another vector, use div() instead. + !#zh 向量除法。如果你想结果保存到另一个向量,可使用 div() 代替。 + @param num num + */ + divSelf(num: number): Vec3; + /** + !#en Divides by a number, and returns the new result. + !#zh 向量除法,并返回新的结果。 + @param num num + @param out optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created + */ + div(num: number, out?: Vec3): Vec3; + /** + !#en Multiplies two vectors. + !#zh 分量相乘。 + @param vector vector + */ + scaleSelf(vector: Vec3): Vec3; + /** + !#en Multiplies two vectors, and returns the new result. + !#zh 分量相乘,并返回新的结果。 + @param vector vector + @param out optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created + */ + scale(vector: Vec3, out?: Vec3): Vec3; + /** + !#en Negates the components. If you want to save result to another vector, use neg() instead. + !#zh 向量取反。如果你想结果保存到另一个向量,可使用 neg() 代替。 + */ + negSelf(): Vec3; + /** + !#en Negates the components, and returns the new result. + !#zh 返回取反后的新向量。 + @param out optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created + */ + neg(out?: Vec3): Vec3; + /** !#en return a Vec3 object with x = 1, y = 1, z = 1. + !#zh 新 Vec3 对象。 */ + static ONE: Vec3; + /** !#en return a Vec3 object with x = 0, y = 0, z = 0. + !#zh 返回 x = 0,y = 0,z = 0 的 Vec3 对象。 */ + static ZERO: Vec3; + /** !#en return a Vec3 object with x = 0, y = 1, z = 0. + !#zh 返回 x = 0, y = 1, z = 0 的 Vec3 对象。 */ + static UP: Vec3; + /** !#en return a Vec3 object with x = 1, y = 0, z = 0. + !#zh 返回 x = 1,y = 0,z = 0 的 Vec3 对象。 */ + static RIGHT: Vec3; + /** !#en return a Vec3 object with x = 0, y = 0, z = 1. + !#zh 返回 x = 0,y = 0,z = 1 的 Vec3 对象。 */ + static FORWARD: Vec3; + /** + !#zh 将目标赋值为零向量 + !#en The target of an assignment zero vector + */ + static zero (out: Out): Out; + /** + !#zh 获得指定向量的拷贝 + !#en Obtaining copy vectors designated + */ + static clone (a: Out): Vec3; + /** + !#zh 复制目标向量 + !#en Copy the target vector + */ + static copy (out: Out, a: Vec3Like): Out; + /** + !#zh 设置向量值 + !#en Set to value + */ + static set (out: Out, x: number, y: number, z: number): Out; + /** + !#zh 逐元素向量加法 + !#en Element-wise vector addition + */ + static add (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量减法 + !#en Element-wise vector subtraction + */ + static subtract (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量乘法 (分量积) + !#en Element-wise vector multiplication (product component) + */ + static multiply (out: Out, a: Vec3Like_1, b: Vec3Like_2): Out; + /** + !#zh 逐元素向量除法 + !#en Element-wise vector division + */ + static divide (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量向上取整 + !#en Rounding up by elements of the vector + */ + static ceil (out: Out, a: Out): Out; + /** + !#zh 逐元素向量向下取整 + !#en Element vector by rounding down + */ + static floor (out: Out, a: Out): Out; + /** + !#zh 逐元素向量最小值 + !#en The minimum by-element vector + */ + static min (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量最大值 + !#en The maximum value of the element-wise vector + */ + static max (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量四舍五入取整 + !#en Element-wise vector of rounding to whole + */ + static round (out: Out, a: Out): Out; + /** + !#zh 向量标量乘法 + !#en Vector scalar multiplication + */ + static multiplyScalar (out: Out, a: Vec3Like, b: number): Out; + /** + !#zh 逐元素向量乘加: A + B * scale + !#en Element-wise vector multiply add: A + B * scale + */ + static scaleAndAdd (out: Out, a: Out, b: Out, scale: number): Out; + /** + !#zh 求两向量的欧氏距离 + !#en Seeking two vectors Euclidean distance + */ + static distance (a: Out, b: Out): number; + /** + !#zh 求两向量的欧氏距离平方 + !#en Euclidean distance squared seeking two vectors + */ + static squaredDistance (a: Out, b: Out): number; + /** + !#zh 求向量长度 + !#en Seeking vector length + */ + static len (a: Out): number; + /** + !#zh 求向量长度平方 + !#en Seeking squared vector length + */ + static lengthSqr (a: Out): number; + /** + !#zh 逐元素向量取负 + !#en By taking the negative elements of the vector + */ + static negate (out: Out, a: Out): Out; + /** + !#zh 逐元素向量取倒数,接近 0 时返回 Infinity + !#en Element vector by taking the inverse, return near 0 Infinity + */ + static inverse (out: Out, a: Out): Out; + /** + !#zh 逐元素向量取倒数,接近 0 时返回 0 + !#en Element vector by taking the inverse, return near 0 0 + */ + static inverseSafe (out: Out, a: Out): Out; + /** + !#zh 归一化向量 + !#en Normalized vector + */ + static normalize (out: Out, a: Vec3Like): Out; + /** + !#zh 向量点积(数量积) + !#en Vector dot product (scalar product) + */ + static dot (a: Out, b: Out): number; + /** + !#zh 向量叉积(向量积) + !#en Vector cross product (vector product) + */ + static cross (out: Out, a: Vec3Like_1, b: Vec3Like_2): Out; + /** + !#zh 逐元素向量线性插值: A + t * (B - A) + !#en Vector element by element linear interpolation: A + t * (B - A) + */ + static lerp (out: Out, a: Out, b: Out, t: number): Out; + /** + !#zh 生成一个在单位球体上均匀分布的随机向量 + !#en Generates a uniformly distributed random vectors on the unit sphere + @param scale 生成的向量长度 + */ + static random (out: Out, scale?: number): Out; + /** + !#zh 向量与四维矩阵乘法,默认向量第四位为 1。 + !#en Four-dimensional vector and matrix multiplication, the default vectors fourth one. + */ + static transformMat4 (out: Out, a: Vec3Like, mat: MatLike): Out; + /** + !#zh 向量与四维矩阵乘法,默认向量第四位为 0。 + !#en Four-dimensional vector and matrix multiplication, vector fourth default is 0. + */ + static transformMat4Normal (out: Out, a: Out, mat: MatLike): Out; + /** + !#zh 向量与三维矩阵乘法 + !#en Dimensional vector matrix multiplication + */ + static transformMat3 (out: Out, a: Out, mat: MatLike): Out; + /** + !#zh 向量仿射变换 + !#en Affine transformation vector + */ + static transformAffine(out: Out, v: VecLike, mat: MatLike): Out; + /** + !#zh 向量四元数乘法 + !#en Vector quaternion multiplication + */ + static transformQuat (out: Out, a: VecLike, q: QuatLike): Out; + /** + !#zh 以缩放 -> 旋转 -> 平移顺序变换向量 + !#en To scale -> rotation -> transformation vector sequence translation + */ + static transformRTS(out: Out, a: VecLike, r: QuatLike, t: VecLike, s: VecLike): Out; + /** + !#zh 以平移 -> 旋转 -> 缩放顺序逆变换向量 + !#en Translational -> rotation -> Zoom inverse transformation vector sequence + */ + static transformInverseRTS(out: Out, a: VecLike, r: QuatLike, t: VecLike, s: VecLike): Out; + /** + !#zh 绕 X 轴旋转向量指定弧度 + !#en Rotation vector specified angle about the X axis + @param v 待旋转向量 + @param o 旋转中心 + @param a 旋转弧度 + */ + static rotateX (out: Out, v: Out, o: Out, a: number): Out; + /** + !#zh 绕 Y 轴旋转向量指定弧度 + !#en Rotation vector specified angle around the Y axis + @param v 待旋转向量 + @param o 旋转中心 + @param a 旋转弧度 + */ + static rotateY (out: Out, v: Out, o: Out, a: number): Out; + /** + !#zh 绕 Z 轴旋转向量指定弧度 + !#en Around the Z axis specified angle vector + @param v 待旋转向量 + @param o 旋转中心 + @param a 旋转弧度 + */ + static rotateZ (out: Out, v: Out, o: Out, a: number): Out; + /** + !#zh 向量等价判断 + !#en Equivalent vectors Analyzing + */ + static strictEquals (a: Out, b: Out): boolean; + /** + !#zh 排除浮点数误差的向量近似等价判断 + !#en Negative error vector floating point approximately equivalent Analyzing + */ + static equals (a: Out, b: Out, epsilon?: number): boolean; + /** + !#zh 求两向量夹角弧度 + !#en Radian angle between two vectors seek + */ + static angle (a: Out, b: Out): number; + /** + !#zh 计算向量在指定平面上的投影 + !#en Calculating a projection vector in the specified plane + @param a 待投影向量 + @param n 指定平面的法线 + */ + static projectOnPlane (out: Out, a: Out, n: Out): Out; + /** + !#zh 计算向量在指定向量上的投影 + !#en Projection vector calculated in the vector designated + @param a 待投影向量 + @param n 目标向量 + */ + static project (out: Out, a: Out, b: Out): Out; + /** + !#zh 向量转数组 + !#en Vector transfer array + @param ofs 数组起始偏移量 + */ + static toArray > (out: Out, v: IVec3Like, ofs?: number): Out; + /** + !#zh 数组转向量 + !#en Array steering amount + @param ofs 数组起始偏移量 + */ + static fromArray (out: Out, arr: IWritableArrayLike, ofs?: number): Out; + x: number; + y: number; + z: number; + /** + !#en + Constructor + see {{#crossLink "cc/vec3:method"}}cc.v3{{/crossLink}} + !#zh + 构造函数,可查看 {{#crossLink "cc/vec3:method"}}cc.v3{{/crossLink}} + @param x x + @param y y + @param z z + */ + constructor(x?: Vec3|number, y?: number, z?: number); + /** + !#en clone a Vec3 value + !#zh 克隆一个 Vec3 值 + */ + clone(): Vec3; + /** + !#en Set the current vector value with the given vector. + !#zh 用另一个向量设置当前的向量对象值。 + @param newValue !#en new value to set. !#zh 要设置的新值 + */ + set(newValue: Vec3): Vec3; + /** + !#en Check whether the vector equals another one + !#zh 当前的向量是否与指定的向量相等。 + @param other other + */ + equals(other: Vec3): boolean; + /** + !#en Check whether two vector equal with some degree of variance. + !#zh + 近似判断两个点是否相等。
+ 判断 2 个向量是否在指定数值的范围之内,如果在则返回 true,反之则返回 false。 + @param other other + @param variance variance + */ + fuzzyEquals(other: Vec3, variance: number): boolean; + /** + !#en Transform to string with vector informations + !#zh 转换为方便阅读的字符串。 + */ + toString(): string; + /** + !#en Calculate linear interpolation result between this vector and another one with given ratio + !#zh 线性插值。 + @param to to + @param ratio the interpolation coefficient + @param out optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created + */ + lerp(to: Vec3, ratio: number, out?: Vec3): Vec3; + /** + !#en Clamp the vector between from float and to float. + !#zh + 返回指定限制区域后的向量。
+ 向量大于 max_inclusive 则返回 max_inclusive。
+ 向量小于 min_inclusive 则返回 min_inclusive。
+ 否则返回自身。 + @param min_inclusive min_inclusive + @param max_inclusive max_inclusive + */ + clampf(min_inclusive: Vec3, max_inclusive: Vec3): Vec3; + /** + !#en Adds this vector. If you want to save result to another vector, use add() instead. + !#zh 向量加法。如果你想保存结果到另一个向量,使用 add() 代替。 + @param vector vector + */ + addSelf(vector: Vec3): Vec3; + /** + !#en Adds two vectors, and returns the new result. + !#zh 向量加法,并返回新结果。 + @param vector vector + @param out optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created + */ + add(vector: Vec3, out?: Vec3): Vec3; + /** + !#en Subtracts one vector from this. + !#zh 向量减法。 + @param vector vector + */ + subtract(vector: Vec3): Vec3; + /** + !#en Multiplies this by a number. + !#zh 缩放当前向量。 + @param num num + */ + multiplyScalar(num: number): Vec3; + /** + !#en Multiplies two vectors. + !#zh 分量相乘。 + @param vector vector + */ + multiply(vector: Vec3): Vec3; + /** + !#en Divides by a number. + !#zh 向量除法。 + @param num num + */ + divide(num: number): Vec3; + /** + !#en Negates the components. + !#zh 向量取反。 + */ + negate(): Vec3; + /** + !#en Dot product + !#zh 当前向量与指定向量进行点乘。 + @param vector vector + */ + dot(vector?: Vec3): number; + /** + !#en Cross product + !#zh 当前向量与指定向量进行叉乘。 + @param vector vector + @param out out + */ + cross(vector: Vec3, out?: Vec3): Vec3; + /** + !#en Returns the length of this vector. + !#zh 返回该向量的长度。 + + @example + ```js + var v = cc.v3(10, 10, 10); + v.len(); // return 17.320508075688775; + ``` + */ + len(): number; + /** + !#en Returns the squared length of this vector. + !#zh 返回该向量的长度平方。 + */ + lengthSqr(): number; + /** + !#en Make the length of this vector to 1. + !#zh 向量归一化,让这个向量的长度为 1。 + */ + normalizeSelf(): Vec3; + /** + !#en + Returns this vector with a magnitude of 1.
+
+ Note that the current vector is unchanged and a new normalized vector is returned. If you want to normalize the current vector, use normalizeSelf function. + !#zh + 返回归一化后的向量。
+
+ 注意,当前向量不变,并返回一个新的归一化向量。如果你想来归一化当前向量,可使用 normalizeSelf 函数。 + @param out optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created + */ + normalize(out?: Vec3): Vec3; + /** + Transforms the vec3 with a mat4. 4th vector component is implicitly '1' + @param m matrix to transform with + @param out the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created + */ + transformMat4(m: Mat4, out?: Vec3): Vec3; + /** + Returns the maximum value in x, y, and z + */ + maxAxis(): number; + /** + !#en Get angle in radian between this and vector. + !#zh 夹角的弧度。 + @param vector vector + */ + angle(vector: Vec3): number; + /** + !#en Calculates the projection of the current vector over the given vector. + !#zh 返回当前向量在指定 vector 向量上的投影向量。 + @param vector vector + + @example + ```js + var v1 = cc.v3(20, 20, 20); + var v2 = cc.v3(5, 5, 5); + v1.project(v2); // Vec3 {x: 20, y: 20, z: 20}; + ``` + */ + project(vector: Vec3): Vec3; + /** + !#en Get angle in radian between this and vector with direction.
+ In order to compatible with the vec2 API. + !#zh 带方向的夹角的弧度。该方法仅用做兼容 2D 计算。 + @param vector vector + */ + signAngle(vector: Vec3|Vec2): number; + /** + !#en rotate. In order to compatible with the vec2 API. + !#zh 返回旋转给定弧度后的新向量。该方法仅用做兼容 2D 计算。 + @param radians radians + @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created + */ + rotate(radians: number, out?: Vec3): Vec2; + /** + !#en rotate self. In order to compatible with the vec2 API. + !#zh 按指定弧度旋转向量。该方法仅用做兼容 2D 计算。 + @param radians radians + */ + rotateSelf(radians: number): Vec3; + } + /** !#en Representation of 3D vectors and points. + !#zh 表示 3D 向量和坐标 */ + export class Vec4 extends ValueType { + /** + !#en Subtracts one vector from this. If you want to save result to another vector, use sub() instead. + !#zh 向量减法。如果你想保存结果到另一个向量,可使用 sub() 代替。 + @param vector vector + */ + subSelf(vector: Vec4): Vec4; + /** + !#en Subtracts one vector from this, and returns the new result. + !#zh 向量减法,并返回新结果。 + @param vector vector + @param out optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created + */ + sub(vector: Vec4, out?: Vec4): Vec4; + /** + !#en Multiplies this by a number. If you want to save result to another vector, use mul() instead. + !#zh 缩放当前向量。如果你想结果保存到另一个向量,可使用 mul() 代替。 + @param num num + */ + mulSelf(num: number): Vec4; + /** + !#en Multiplies by a number, and returns the new result. + !#zh 缩放向量,并返回新结果。 + @param num num + @param out optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created + */ + mul(num: number, out?: Vec4): Vec4; + /** + !#en Divides by a number. If you want to save result to another vector, use div() instead. + !#zh 向量除法。如果你想结果保存到另一个向量,可使用 div() 代替。 + @param num num + */ + divSelf(num: number): Vec4; + /** + !#en Divides by a number, and returns the new result. + !#zh 向量除法,并返回新的结果。 + @param num num + @param out optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created + */ + div(num: number, out?: Vec4): Vec4; + /** + !#en Multiplies two vectors. + !#zh 分量相乘。 + @param vector vector + */ + scaleSelf(vector: Vec4): Vec4; + /** + !#en Multiplies two vectors, and returns the new result. + !#zh 分量相乘,并返回新的结果。 + @param vector vector + @param out optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created + */ + scale(vector: Vec4, out?: Vec4): Vec4; + /** + !#en Negates the components. If you want to save result to another vector, use neg() instead. + !#zh 向量取反。如果你想结果保存到另一个向量,可使用 neg() 代替。 + */ + negSelf(): Vec4; + /** + !#en Negates the components, and returns the new result. + !#zh 返回取反后的新向量。 + @param out optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created + */ + neg(out?: Vec4): Vec4; + /** + !#zh 获得指定向量的拷贝 + !#en Obtaining copy vectors designated + */ + static clone (a: Out): Vec4; + /** + !#zh 复制目标向量 + !#en Copy the target vector + */ + static copy (out: Out, a: Out): Out; + /** + !#zh 设置向量值 + !#en Set to value + */ + static set (out: Out, x: number, y: number, z: number, w: number): Out; + /** + !#zh 逐元素向量加法 + !#en Element-wise vector addition + */ + static add (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量减法 + !#en Element-wise vector subtraction + */ + static subtract (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量乘法 + !#en Element-wise vector multiplication + */ + static multiply (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量除法 + !#en Element-wise vector division + */ + static divide (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量向上取整 + !#en Rounding up by elements of the vector + */ + static ceil (out: Out, a: Out): Out; + /** + !#zh 逐元素向量向下取整 + !#en Element vector by rounding down + */ + static floor (out: Out, a: Out): Out; + /** + !#zh 逐元素向量最小值 + !#en The minimum by-element vector + */ + static min (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量最大值 + !#en The maximum value of the element-wise vector + */ + static max (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量四舍五入取整 + !#en Element-wise vector of rounding to whole + */ + static round (out: Out, a: Out): Out; + /** + !#zh 向量标量乘法 + !#en Vector scalar multiplication + */ + static multiplyScalar (out: Out, a: Out, b: number): Out; + /** + !#zh 逐元素向量乘加: A + B * scale + !#en Element-wise vector multiply add: A + B * scale + */ + static scaleAndAdd (out: Out, a: Out, b: Out, scale: number): Out; + /** + !#zh 求两向量的欧氏距离 + !#en Seeking two vectors Euclidean distance + */ + static distance (a: Out, b: Out): number; + /** + !#zh 求两向量的欧氏距离平方 + !#en Euclidean distance squared seeking two vectors + */ + static squaredDistance (a: Out, b: Out): number; + /** + !#zh 求向量长度 + !#en Seeking vector length + */ + static len (a: Out): number; + /** + !#zh 求向量长度平方 + !#en Seeking squared vector length + */ + static lengthSqr (a: Out): number; + /** + !#zh 逐元素向量取负 + !#en By taking the negative elements of the vector + */ + static negate (out: Out, a: Out): Out; + /** + !#zh 逐元素向量取倒数,接近 0 时返回 Infinity + !#en Element vector by taking the inverse, return near 0 Infinity + */ + static inverse (out: Out, a: Out): Out; + /** + !#zh 逐元素向量取倒数,接近 0 时返回 0 + !#en Element vector by taking the inverse, return near 0 0 + */ + static inverseSafe (out: Out, a: Out): Out; + /** + !#zh 归一化向量 + !#en Normalized vector + */ + static normalize (out: Out, a: Out): Out; + /** + !#zh 向量点积(数量积) + !#en Vector dot product (scalar product) + */ + static dot (a: Out, b: Out): number; + /** + !#zh 逐元素向量线性插值: A + t * (B - A) + !#en Vector element by element linear interpolation: A + t * (B - A) + */ + static lerp (out: Out, a: Out, b: Out, t: number): Out; + /** + !#zh 生成一个在单位球体上均匀分布的随机向量 + !#en Generates a uniformly distributed random vectors on the unit sphere + @param scale 生成的向量长度 + */ + static random (out: Out, scale?: number): Out; + /** + !#zh 向量矩阵乘法 + !#en Vector matrix multiplication + */ + static transformMat4 (out: Out, a: Out, mat: MatLike): Out; + /** + !#zh 向量仿射变换 + !#en Affine transformation vector + */ + static transformAffine(out: Out, v: VecLike, mat: MatLike): Out; + /** + !#zh 向量四元数乘法 + !#en Vector quaternion multiplication + */ + static transformQuat (out: Out, a: Out, q: QuatLike): Out; + /** + !#zh 向量等价判断 + !#en Equivalent vectors Analyzing + */ + static strictEquals (a: Out, b: Out): boolean; + /** + !#zh 排除浮点数误差的向量近似等价判断 + !#en Negative error vector floating point approximately equivalent Analyzing + */ + static equals (a: Out, b: Out, epsilon?: number): boolean; + /** + !#zh 向量转数组 + !#en Vector transfer array + @param ofs 数组起始偏移量 + */ + static toArray > (out: Out, v: IVec4Like, ofs?: number): Out; + /** + !#zh 数组转向量 + !#en Array steering amount + @param ofs 数组起始偏移量 + */ + static fromArray (out: Out, arr: IWritableArrayLike, ofs?: number): Out; + x: number; + y: number; + z: number; + w: number; + /** + !#en + Constructor + see {{#crossLink "cc/vec4:method"}}cc.v4{{/crossLink}} + !#zh + 构造函数,可查看 {{#crossLink "cc/vec4:method"}}cc.v4{{/crossLink}} + @param x x + @param y y + @param z z + @param w w + */ + constructor(x?: number, y?: number, z?: number, w?: number); + /** + !#en clone a Vec4 value + !#zh 克隆一个 Vec4 值 + */ + clone(): Vec4; + /** + !#en Set the current vector value with the given vector. + !#zh 用另一个向量设置当前的向量对象值。 + @param newValue !#en new value to set. !#zh 要设置的新值 + */ + set(newValue: Vec4): Vec4; + /** + !#en Check whether the vector equals another one + !#zh 当前的向量是否与指定的向量相等。 + @param other other + @param epsilon epsilon + */ + equals(other: Vec4, epsilon?: number): boolean; + /** + !#en Check whether the vector equals another one + !#zh 判断当前向量是否在误差范围内与指定分量的向量相等。 + @param x 相比较的向量的 x 分量。 + @param y 相比较的向量的 y 分量。 + @param z 相比较的向量的 z 分量。 + @param w 相比较的向量的 w 分量。 + @param epsilon 允许的误差,应为非负数。 + */ + equals4f(x: number, y: number, z: number, w: number, epsilon?: number): boolean; + /** + !#en Check whether strict equals other Vec4 + !#zh 判断当前向量是否与指定向量相等。两向量的各分量都分别相等时返回 `true`;否则返回 `false`。 + @param other 相比较的向量。 + */ + strictEquals(other: Vec4): boolean; + /** + !#en Check whether strict equals other Vec4 + !#zh 判断当前向量是否与指定分量的向量相等。两向量的各分量都分别相等时返回 `true`;否则返回 `false`。 + @param x 指定向量的 x 分量。 + @param y 指定向量的 y 分量。 + @param z 指定向量的 z 分量。 + @param w 指定向量的 w 分量。 + */ + strictEquals4f(x: number, y: number, z: number, w: number): boolean; + /** + !#en Calculate linear interpolation result between this vector and another one with given ratio + !#zh 根据指定的插值比率,从当前向量到目标向量之间做插值。 + @param to 目标向量。 + @param ratio 插值比率,范围为 [0,1]。 + */ + lerp(to: Vec4, ratio: number): Vec4; + /** + !#en Transform to string with vector informations + !#zh 返回当前向量的字符串表示。 + */ + toString(): string; + /** + !#en Clamp the vector between minInclusive and maxInclusive. + !#zh 设置当前向量的值,使其各个分量都处于指定的范围内。 + @param minInclusive 每个分量都代表了对应分量允许的最小值。 + @param maxInclusive 每个分量都代表了对应分量允许的最大值。 + */ + clampf(minInclusive: Vec4, maxInclusive: Vec4): Vec4; + /** + !#en Adds this vector. If you want to save result to another vector, use add() instead. + !#zh 向量加法。如果你想保存结果到另一个向量,使用 add() 代替。 + @param vector vector + */ + addSelf(vector: Vec4): Vec4; + /** + !#en Adds two vectors, and returns the new result. + !#zh 向量加法,并返回新结果。 + @param vector vector + @param out optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created + */ + add(vector: Vec4, out?: Vec4): Vec4; + /** + !#en Subtracts one vector from this, and returns the new result. + !#zh 向量减法,并返回新结果。 + @param vector vector + @param out optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created + */ + subtract(vector: Vec4, out?: Vec4): Vec4; + /** + !#en Multiplies this by a number. + !#zh 缩放当前向量。 + @param num num + */ + multiplyScalar(num: number): Vec4; + /** + !#en Multiplies two vectors. + !#zh 分量相乘。 + @param vector vector + */ + multiply(vector: Vec4): Vec4; + /** + !#en Divides by a number. + !#zh 向量除法。 + @param num num + */ + divide(num: number): Vec4; + /** + !#en Negates the components. + !#zh 向量取反 + */ + negate(): Vec4; + /** + !#en Dot product + !#zh 当前向量与指定向量进行点乘。 + @param vector vector + */ + dot(vector?: Vec4): number; + /** + !#en Cross product + !#zh 当前向量与指定向量进行叉乘。 + @param vector vector + @param out out + */ + cross(vector: Vec4, out?: Vec4): Vec4; + /** + !#en Returns the length of this vector. + !#zh 返回该向量的长度。 + + @example + ```js + var v = cc.v4(10, 10); + v.len(); // return 14.142135623730951; + ``` + */ + len(): number; + /** + !#en Returns the squared length of this vector. + !#zh 返回该向量的长度平方。 + */ + lengthSqr(): number; + /** + !#en Make the length of this vector to 1. + !#zh 向量归一化,让这个向量的长度为 1。 + */ + normalizeSelf(): Vec4; + /** + !#en + Returns this vector with a magnitude of 1.
+
+ Note that the current vector is unchanged and a new normalized vector is returned. If you want to normalize the current vector, use normalizeSelf function. + !#zh + 返回归一化后的向量。
+
+ 注意,当前向量不变,并返回一个新的归一化向量。如果你想来归一化当前向量,可使用 normalizeSelf 函数。 + @param out optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created + */ + normalize(out?: Vec4): Vec4; + /** + Transforms the vec4 with a mat4. 4th vector component is implicitly '1' + @param m matrix to transform with + @param out the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created + */ + transformMat4(m: Mat4, out?: Vec4): Vec4; + /** + Returns the maximum value in x, y, z, w. + */ + maxAxis(): number; + } + /** !#en The animation curve of 3d particle. + !#zh 3D 粒子动画曲线 */ + export class AnimationCurve { + } + /** !#en The burst of 3d particle. + !#zh 3D 粒子发射时的爆发个数 */ + export class Burst { + /** !#en Time between the start of the particle system and the trigger of this Brust + !#zh 粒子系统开始运行到触发此次 Brust 的时间 */ + time: number; + /** !#en Minimum number of emitted particles + !#zh 发射粒子的最小数量 */ + minCount: number; + /** !#en Maximum number of emitted particles + !#zh 发射粒子的最大数量 */ + maxCount: number; + /** !#en The number of times Burst was triggered. + !#zh Burst 的触发次数 */ + repeatCount: number; + /** !#en Interval of each trigger + !#zh 每次触发的间隔时间 */ + repeatInterval: number; + /** !#en Number of particles emitted + !#zh 发射的粒子的数量 */ + count: CurveRange; + } + /** !#en The ParticleSystem3D Component. + !#zh 3D 粒子组件 */ + export class ParticleSystem3D extends RenderComponent { + /** !#en The run time of particle. + !#zh 粒子系统运行时间 */ + duration: number; + /** !#en The maximum number of particles that a particle system can generate. + !#zh 粒子系统能生成的最大粒子数量 */ + capacity: number; + /** !#en Whether the particle system loops. + !#zh 粒子系统是否循环播放 */ + loop: boolean; + /** !#en Whether the particles start playing automatically after loaded. + !#zh 粒子系统加载后是否自动开始播放 */ + playOnAwake: boolean; + /** !#en When selected, the particle system will start playing after one round has been played (only effective when loop is enabled). + !#zh 选中之后,粒子系统会以已播放完一轮之后的状态开始播放(仅当循环播放启用时有效) */ + prewarm: boolean; + /** !#en The coordinate system in which the particle system is located.
+ World coordinates (does not change when the position of other objects changes)
+ Local coordinates (moving as the position of the parent node changes)
+ Custom coordinates (moving with the position of a custom node) + !#zh 选择粒子系统所在的坐标系
+ 世界坐标(不随其他物体位置改变而变换)
+ 局部坐标(跟随父节点位置改变而移动)
+ 自定坐标(跟随自定义节点的位置改变而移动) */ + simulationSpace: ParticleSystem3DAssembler.Space; + /** !#en Controlling the update speed of the entire particle system. + !#zh 控制整个粒子系统的更新速度。 */ + simulationSpeed: number; + /** !#en Delay particle emission time after particle system starts running. + !#zh 粒子系统开始运行后,延迟粒子发射的时间。 */ + startDelay: CurveRange; + /** !#en Particle life cycle。 + !#zh 粒子生命周期。 */ + startLifetime: CurveRange; + /** !#en Particle initial color + !#zh 粒子初始颜色 */ + startColor: GradientRange; + /** !#en Particle scale space + !#zh 缩放空间 */ + scaleSpace: ParticleSystem3DAssembler.Space; + /** !#en Initial particle size + !#zh 粒子初始大小 */ + startSize: CurveRange; + /** !#en Initial particle speed + !#zh 粒子初始速度 */ + startSpeed: CurveRange; + /** !#en Particle initial rotation angle + !#zh 粒子初始旋转角度 */ + startRotation: CurveRange; + /** !#en Gravity coefficient of particles affected by gravity + !#zh 粒子受重力影响的重力系数 */ + gravityModifier: CurveRange; + /** !#en Particles emitted per second + !#zh 每秒发射的粒子数 */ + rateOverTime: CurveRange; + /** !#en Number of particles emitted per unit distance moved + !#zh 每移动单位距离发射的粒子数 */ + rateOverDistance: CurveRange; + /** !#en The number of Brusts that emit a specified number of particles at a specified time + !#zh 设定在指定时间发射指定数量的粒子的 Brust 的数量 */ + bursts: Burst[]; + /** !#en Particle emitter module + !#zh 粒子发射器模块 */ + shapeModule: ShapeModule; + /** !#en Color control module + !#zh 颜色控制模块 */ + colorOverLifetimeModule: ColorOverLifetimeModule; + /** !#en Particle size module + !#zh 粒子大小模块 */ + sizeOvertimeModule: SizeOvertimeModule; + /** !#en Particle speed module + !#zh 粒子速度模块 */ + velocityOvertimeModule: VelocityOvertimeModule; + /** !#en Particle acceleration module + !#zh 粒子加速度模块 */ + forceOvertimeModule: ForceOvertimeModule; + /** !#en Particle limit speed module (only CPU particles are supported) + !#zh 粒子限制速度模块(只支持 CPU 粒子) */ + limitVelocityOvertimeModule: LimitVelocityOvertimeModule; + /** !#en Particle rotation module + !#zh 粒子旋转模块 */ + rotationOvertimeModule: RotationOvertimeModule; + /** !#en Texture Animation Module + !#zh 贴图动画模块 */ + textureAnimationModule: TextureAnimationModule; + /** !#en Particle Trajectory Module + !#zh 粒子轨迹模块 */ + trailModule: TrailModule; + /** !#en Particle generation mode + !#zh 设定粒子生成模式 */ + renderMode: ParticleSystem3DAssembler.RenderMode; + /** !#en When the particle generation mode is StrecthedBillboard, in the direction of movement of the particles is stretched by velocity magnitude + !#zh 在粒子生成方式为 StrecthedBillboard 时,对粒子在运动方向上按速度大小进行拉伸 */ + velocityScale: number; + /** !#en When the particle generation method is StrecthedBillboard, the particles are stretched according to the particle size in the direction of motion + !#zh 在粒子生成方式为 StrecthedBillboard 时,对粒子在运动方向上按粒子大小进行拉伸 */ + lengthScale: number; + /** !#en Particle model + !#zh 粒子模型 */ + mesh: Mesh; + /** !#en Particle material + !#zh 粒子材质 */ + particleMaterial: Material; + /** !#en Particle trail material + !#zh 粒子轨迹材质 */ + trailMaterial: Material; + /** + !#en Playing particle effects + !#zh 播放粒子效果 + */ + play(): void; + /** + !#en Pause particle effect + !#zh 暂停播放粒子效果 + */ + pause(): void; + /** + !#en Stop particle effect + !#zh 停止播放粒子效果 + */ + stop(): void; + /** + !#en Remove all particle effect + !#zh 将所有粒子从粒子系统中清除 + */ + clear(): void; + } + /** !#en + Helper class for ES5 Map. + !#zh + ES5 Map 辅助类。 */ + export class MapUtils { + } + /** !#en Effect Asset. + !#zh Effect 资源类型。 */ + export class EffectAsset extends Asset { + } + /** !#en Material Asset. + !#zh 材质资源类。 */ + export class Material extends Asset { + /** + !#en Get built-in materials + !#zh 获取内置材质 + @param name name + */ + static getBuiltinMaterial(name: string): Material; + /** + !#en Creates a Material with builtin Effect. + !#zh 使用内建 Effect 创建一个材质。 + @param effectName effectName + @param techniqueIndex techniqueIndex + */ + static createWithBuiltin(effectName: string, techniqueIndex?: number): Material; + /** + !#en Creates a Material. + !#zh 创建一个材质。 + @param effectAsset effectAsset + @param techniqueIndex techniqueIndex + */ + static create(effectAsset: EffectAsset, techniqueIndex?: number): Material; + /** + !#en Sets the Material property + !#zh 设置材质的属性 + @param name name + @param val val + @param passIdx passIdx + @param directly directly + */ + setProperty(name: string, val: any, passIdx?: number, directly?: boolean): void; + /** + !#en Gets the Material property. + !#zh 获取材质的属性。 + @param name name + @param passIdx passIdx + */ + getProperty(name: string, passIdx: number): any; + /** + !#en Sets the Material define. + !#zh 设置材质的宏定义。 + @param name name + @param val val + @param passIdx passIdx + @param force force + */ + define(name: string, val: boolean|number, passIdx?: number, force?: boolean): void; + /** + !#en Gets the Material define. + !#zh 获取材质的宏定义。 + @param name name + @param passIdx passIdx + */ + getDefine(name: string, passIdx?: number): boolean; + /** + !#en Sets the Material cull mode. + !#zh 设置材质的裁减模式。 + @param cullMode cullMode + @param passIdx passIdx + */ + setCullMode(cullMode: number, passIdx: number): void; + /** + !#en Sets the Material depth states. + !#zh 设置材质的深度渲染状态。 + @param depthTest depthTest + @param depthWrite depthWrite + @param depthFunc depthFunc + @param passIdx passIdx + */ + setDepth(depthTest: boolean, depthWrite: boolean, depthFunc: number, passIdx: number): void; + /** + !#en Sets the Material blend states. + !#zh 设置材质的混合渲染状态。 + @param enabled enabled + @param blendEq blendEq + @param blendSrc blendSrc + @param blendDst blendDst + @param blendAlphaEq blendAlphaEq + @param blendSrcAlpha blendSrcAlpha + @param blendDstAlpha blendDstAlpha + @param blendColor blendColor + @param passIdx passIdx + */ + setBlend(enabled: boolean, blendEq: number, blendSrc: number, blendDst: number, blendAlphaEq: number, blendSrcAlpha: number, blendDstAlpha: number, blendColor: number, passIdx: number): void; + /** + !#en Sets whether enable the stencil test. + !#zh 设置是否开启模板测试。 + @param stencilTest stencilTest + @param passIdx passIdx + */ + setStencilEnabled(stencilTest: number, passIdx: number): void; + /** + !#en Sets the Material stencil render states. + !#zh 设置材质的模板测试渲染参数。 + @param stencilTest stencilTest + @param stencilFunc stencilFunc + @param stencilRef stencilRef + @param stencilMask stencilMask + @param stencilFailOp stencilFailOp + @param stencilZFailOp stencilZFailOp + @param stencilZPassOp stencilZPassOp + @param stencilWriteMask stencilWriteMask + @param passIdx passIdx + */ + setStencil(stencilTest: number, stencilFunc: number, stencilRef: number, stencilMask: number, stencilFailOp: number, stencilZFailOp: number, stencilZPassOp: number, stencilWriteMask: number, passIdx: number): void; + } + /** !#en + Material Variant is an extension of the Material Asset. + Changes to Material Variant do not affect other Material Variant or Material Asset, + and changes to Material Asset are synchronized to the Material Variant. + However, when a Material Variant had already modifies a state, the Material Asset state is not synchronized to the Material Variant. + !#zh + 材质变体是材质资源的一个延伸。 + 材质变体的修改不会影响到其他的材质变体或者材质资源,而材质资源的修改会同步体现到材质变体上, + 但是当材质变体对一个状态修改后,材质资源再对这个状态修改是不会同步到材质变体上的。 */ + export class MaterialVariant extends Material { + /** + + @param materialName materialName + @param owner owner + */ + static createWithBuiltin (materialName: string, owner: cc.RenderComponent): MaterialVariant | null; + /** + + @param material material + @param owner owner + */ + static create (material: Material, owner: cc.RenderComponent): MaterialVariant | null; + } + /** !#en SkeletonAnimationClip Asset. + !#zh 骨骼动画剪辑。 */ + export class SkeletonAnimationClip extends AnimationClip { + } + /** !#en . + !#zh 。 */ + export class SkeletonAnimation extends Animation { + } + /** !#en + Skinned Mesh Renderer + !#zh + 蒙皮渲染组件 */ + export class SkinnedMeshRenderer { + /** !#en + Skeleton Asset + !#zh + 骨骼资源 */ + skeleton: sp.Skeleton; + /** !#en + Root Bone + !#zh + 骨骼根节点 */ + rootBone: Node; + } + /** !#en cc.EditBox is a component for inputing text, you can use it to gather small amounts of text from users. + !#zh EditBox 组件,用于获取用户的输入文本。 */ + export class EditBox extends Component { + /** !#en Input string of EditBox. + !#zh 输入框的初始输入内容,如果为空则会显示占位符的文本。 */ + string: string; + /** !#en The Label component attached to the node for EditBox's input text label + !#zh 输入框输入文本节点上挂载的 Label 组件对象 */ + textLabel: Label; + /** !#en The Label component attached to the node for EditBox's placeholder text label + !#zh 输入框占位符节点上挂载的 Label 组件对象 */ + placeholderLabel: Label; + /** !#en The Sprite component attached to the node for EditBox's background + !#zh 输入框背景节点上挂载的 Sprite 组件对象 */ + background: Sprite; + /** !#en The background image of EditBox. This property will be removed in the future, use editBox.background instead please. + !#zh 输入框的背景图片。 该属性会在将来的版本中移除,请用 editBox.background */ + backgroundImage: SpriteFrame; + /** !#en + The return key type of EditBox. + Note: it is meaningless for web platforms and desktop platforms. + !#zh + 指定移动设备上面回车按钮的样式。 + 注意:这个选项对 web 平台与 desktop 平台无效。 */ + returnType: EditBox.KeyboardReturnType; + /** !#en Set the input flags that are to be applied to the EditBox. + !#zh 指定输入标志位,可以指定输入方式为密码或者单词首字母大写。 */ + inputFlag: EditBox.InputFlag; + /** !#en + Set the input mode of the edit box. + If you pass ANY, it will create a multiline EditBox. + !#zh + 指定输入模式: ANY表示多行输入,其它都是单行输入,移动平台上还可以指定键盘样式。 */ + inputMode: EditBox.InputMode; + /** !#en Font size of the input text. This property will be removed in the future, use editBox.textLabel.fontSize instead please. + !#zh 输入框文本的字体大小。 该属性会在将来的版本中移除,请使用 editBox.textLabel.fontSize。 */ + fontSize: number; + /** !#en Change the lineHeight of displayed text. This property will be removed in the future, use editBox.textLabel.lineHeight instead. + !#zh 输入框文本的行高。该属性会在将来的版本中移除,请使用 editBox.textLabel.lineHeight */ + lineHeight: number; + /** !#en Font color of the input text. This property will be removed in the future, use editBox.textLabel.node.color instead. + !#zh 输入框文本的颜色。该属性会在将来的版本中移除,请使用 editBox.textLabel.node.color */ + fontColor: Color; + /** !#en The display text of placeholder. + !#zh 输入框占位符的文本内容。 */ + placeholder: string; + /** !#en The font size of placeholder. This property will be removed in the future, use editBox.placeholderLabel.fontSize instead. + !#zh 输入框占位符的字体大小。该属性会在将来的版本中移除,请使用 editBox.placeholderLabel.fontSize */ + placeholderFontSize: number; + /** !#en The font color of placeholder. This property will be removed in the future, use editBox.placeholderLabel.node.color instead. + !#zh 输入框占位符的字体颜色。该属性会在将来的版本中移除,请使用 editBox.placeholderLabel.node.color */ + placeholderFontColor: Color; + /** !#en The maximize input length of EditBox. + - If pass a value less than 0, it won't limit the input number of characters. + - If pass 0, it doesn't allow input any characters. + !#zh 输入框最大允许输入的字符个数。 + - 如果值为小于 0 的值,则不会限制输入字符个数。 + - 如果值为 0,则不允许用户进行任何输入。 */ + maxLength: number; + /** !#en The input is always visible and be on top of the game view (only useful on Web), this property will be removed on v2.1 + !zh 输入框总是可见,并且永远在游戏视图的上面(这个属性只有在 Web 上面修改有意义),该属性会在 v2.1 中移除 + Note: only available on Web at the moment. */ + stayOnTop: boolean; + /** !#en Set the tabIndex of the DOM input element (only useful on Web). + !#zh 修改 DOM 输入元素的 tabIndex(这个属性只有在 Web 上面修改有意义)。 */ + tabIndex: number; + /** !#en The event handler to be called when EditBox began to edit text. + !#zh 开始编辑文本输入框触发的事件回调。 */ + editingDidBegan: Component.EventHandler[]; + /** !#en The event handler to be called when EditBox text changes. + !#zh 编辑文本输入框时触发的事件回调。 */ + textChanged: Component.EventHandler[]; + /** !#en The event handler to be called when EditBox edit ends. + !#zh 结束编辑文本输入框时触发的事件回调。 */ + editingDidEnded: Component.EventHandler[]; + /** !#en The event handler to be called when return key is pressed. Windows is not supported. + !#zh 当用户按下回车按键时的事件回调,目前不支持 windows 平台 */ + editingReturn: Component.EventHandler[]; + /** + !#en Let the EditBox get focus, this method will be removed on v2.1 + !#zh 让当前 EditBox 获得焦点, 这个方法会在 v2.1 中移除 + */ + setFocus(): void; + /** + !#en Let the EditBox get focus + !#zh 让当前 EditBox 获得焦点 + */ + focus(): void; + /** + !#en Let the EditBox lose focus + !#zh 让当前 EditBox 失去焦点 + */ + blur(): void; + /** + !#en Determine whether EditBox is getting focus or not. + !#zh 判断 EditBox 是否获得了焦点 + */ + isFocused(): void; + /** + !#en if you don't need the EditBox and it isn't in any running Scene, you should + call the destroy method on this component or the associated node explicitly. + Otherwise, the created DOM element won't be removed from web page. + !#zh + 如果你不再使用 EditBox,并且组件未添加到场景中,那么你必须手动对组件或所在节点调用 destroy。 + 这样才能移除网页上的 DOM 节点,避免 Web 平台内存泄露。 + + @example + ```js + editbox.node.parent = null; // or editbox.node.removeFromParent(false); + // when you don't need editbox anymore + editbox.node.destroy(); + ``` + */ + destroy(): boolean; + } + /** undefined */ + export class PhysicsBoxCollider extends PhysicsCollider implements Collider.Box { + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Box size + !#zh 包围盒大小 */ + size: Size; + } + /** undefined */ + export class PhysicsChainCollider extends PolygonCollider { + /** !#en Whether the chain is loop + !#zh 链条是否首尾相连 */ + loop: boolean; + /** !#en Chain points + !#zh 链条顶点数组 */ + points: Vec2[]; + } + /** undefined */ + export class PhysicsCircleCollider extends PhysicsCollider implements Collider.Circle { + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Circle radius + !#zh 圆形半径 */ + radius: number; + } + /** undefined */ + export class PhysicsCollider extends Collider { + /** !#en + The density. + !#zh + 密度 */ + density: number; + /** !#en + A sensor collider collects contact information but never generates a collision response + !#zh + 一个传感器类型的碰撞体会产生碰撞回调,但是不会发生物理碰撞效果。 */ + sensor: boolean; + /** !#en + The friction coefficient, usually in the range [0,1]. + !#zh + 摩擦系数,取值一般在 [0, 1] 之间 */ + friction: number; + /** !#en + The restitution (elasticity) usually in the range [0,1]. + !#zh + 弹性系数,取值一般在 [0, 1]之间 */ + restitution: number; + /** !#en + Physics collider will find the rigidbody component on the node and set to this property. + !#zh + 碰撞体会在初始化时查找节点上是否存在刚体,如果查找成功则赋值到这个属性上。 */ + body: RigidBody; + /** + !#en + Apply current changes to collider, this will regenerate inner box2d fixtures. + !#zh + 应用当前 collider 中的修改,调用此函数会重新生成内部 box2d 的夹具。 + */ + apply(): void; + /** + !#en + Get the world aabb of the collider + !#zh + 获取碰撞体的世界坐标系下的包围盒 + */ + getAABB(): void; + } + /** undefined */ + export class PhysicsPolygonCollider extends PhysicsCollider implements Collider.Polygon { + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Polygon points + !#zh 多边形顶点数组 */ + points: Vec2[]; + } + /** !#en + A distance joint constrains two points on two bodies + to remain at a fixed distance from each other. You can view + this as a massless, rigid rod. + !#zh + 距离关节通过一个固定的长度来约束关节链接的两个刚体。你可以将它想象成一个无质量,坚固的木棍。 */ + export class DistanceJoint extends Joint { + /** !#en + The distance separating the two ends of the joint. + !#zh + 关节两端的距离 */ + distance: number; + /** !#en + The spring frequency. + !#zh + 弹性系数。 */ + frequency: number; + /** !#en + The damping ratio. + !#zh + 阻尼,表示关节变形后,恢复到初始状态受到的阻力。 */ + dampingRatio: number; + } + /** !#en + Base class for joints to connect rigidbody. + !#zh + 关节类的基类 */ + export class Joint extends Component { + /** !#en + The anchor of the rigidbody. + !#zh + 刚体的锚点。 */ + anchor: Vec2; + /** !#en + The anchor of the connected rigidbody. + !#zh + 关节另一端刚体的锚点。 */ + connectedAnchor: Vec2; + /** !#en + The rigidbody to which the other end of the joint is attached. + !#zh + 关节另一端链接的刚体 */ + connectedBody: RigidBody; + /** !#en + Should the two rigid bodies connected with this joint collide with each other? + !#zh + 链接到关节上的两个刚体是否应该相互碰撞? */ + collideConnected: boolean; + /** + !#en + Apply current changes to joint, this will regenerate inner box2d joint. + !#zh + 应用当前关节中的修改,调用此函数会重新生成内部 box2d 的关节。 + */ + apply(): void; + /** + !#en + Get the anchor point on rigidbody in world coordinates. + !#zh + 获取刚体世界坐标系下的锚点。 + */ + getWorldAnchor(): Vec2; + /** + !#en + Get the anchor point on connected rigidbody in world coordinates. + !#zh + 获取链接刚体世界坐标系下的锚点。 + */ + getWorldConnectedAnchor(): Vec2; + /** + !#en + Gets the reaction force of the joint. + !#zh + 获取关节的反作用力。 + @param timeStep The time to calculate the reaction force for. + */ + getReactionForce(timeStep: number): Vec2; + /** + !#en + Gets the reaction torque of the joint. + !#zh + 获取关节的反扭矩。 + @param timeStep The time to calculate the reaction torque for. + */ + getReactionTorque(timeStep: number): number; + } + /** !#en + A motor joint is used to control the relative motion + between two bodies. A typical usage is to control the movement + of a dynamic body with respect to the ground. + !#zh + 马达关节被用来控制两个刚体间的相对运动。 + 一个典型的例子是用来控制一个动态刚体相对于地面的运动。 */ + export class MotorJoint extends Joint { + /** !#en + The anchor of the rigidbody. + !#zh + 刚体的锚点。 */ + anchor: Vec2; + /** !#en + The anchor of the connected rigidbody. + !#zh + 关节另一端刚体的锚点。 */ + connectedAnchor: Vec2; + /** !#en + The linear offset from connected rigidbody to rigidbody. + !#zh + 关节另一端的刚体相对于起始端刚体的位置偏移量 */ + linearOffset: Vec2; + /** !#en + The angular offset from connected rigidbody to rigidbody. + !#zh + 关节另一端的刚体相对于起始端刚体的角度偏移量 */ + angularOffset: number; + /** !#en + The maximum force can be applied to rigidbody. + !#zh + 可以应用于刚体的最大的力值 */ + maxForce: number; + /** !#en + The maximum torque can be applied to rigidbody. + !#zh + 可以应用于刚体的最大扭矩值 */ + maxTorque: number; + /** !#en + The position correction factor in the range [0,1]. + !#zh + 位置矫正系数,范围为 [0, 1] */ + correctionFactor: number; + } + /** !#en + A mouse joint is used to make a point on a body track a + specified world point. This a soft constraint with a maximum + force. This allows the constraint to stretch and without + applying huge forces. + Mouse Joint will auto register the touch event with the mouse region node, + and move the choosed rigidbody in touch move event. + Note : generally mouse joint only used in test bed. + !#zh + 鼠标关节用于使刚体上的一个点追踪一个指定的世界坐标系下的位置。 + 鼠标关节可以指定一个最大的里来施加一个柔和的约束。 + 鼠标关节会自动使用 mouse region 节点来注册鼠标事件,并且在触摸移动事件中移动选中的刚体。 + 注意:一般鼠标关节只在测试环境中使用。 */ + export class MouseJoint extends Joint { + /** !#en + The anchor of the rigidbody. + !#zh + 刚体的锚点。 */ + anchor: Vec2; + /** !#en + The anchor of the connected rigidbody. + !#zh + 关节另一端刚体的锚点。 */ + connectedAnchor: Vec2; + /** !#en + The node used to register touch evnet. + If this is null, it will be the joint's node. + !#zh + 用于注册触摸事件的节点。 + 如果没有设置这个值,那么将会使用关节的节点来注册事件。 */ + mouseRegion: Node; + /** !#en + The target point. + The mouse joint will move choosed rigidbody to target point. + !#zh + 目标点,鼠标关节将会移动选中的刚体到指定的目标点 */ + target: Vec2; + /** !#en + The spring frequency. + !#zh + 弹簧系数。 */ + frequency: number; + /** !#en + The damping ratio. + !#zh + 阻尼,表示关节变形后,恢复到初始状态受到的阻力。 */ + 0: number; + /** !#en + The maximum force + !#zh + 最大阻力值 */ + maxForce: number; + } + /** !#en + A prismatic joint. This joint provides one degree of freedom: translation + along an axis fixed in rigidbody. Relative rotation is prevented. You can + use a joint limit to restrict the range of motion and a joint motor to + drive the motion or to model joint friction. + !#zh + 移动关节指定了只能在一个方向上移动刚体。 + 你可以开启关节限制来设置刚体运行移动的间距,也可以开启马达来使用关节马达驱动刚体的运行。 */ + export class PrismaticJoint extends Joint { + /** !#en + The local joint axis relative to rigidbody. + !#zh + 指定刚体可以移动的方向。 */ + localAxisA: Vec2; + /** !#en + The reference angle. + !#zh + 相对角度 */ + referenceAngle: number; + /** !#en + Enable joint distance limit? + !#zh + 是否开启关节的距离限制? */ + enableLimit: boolean; + /** !#en + Enable joint motor? + !#zh + 是否开启关节马达? */ + enableMotor: boolean; + /** !#en + The lower joint limit. + !#zh + 刚体能够移动的最小值 */ + lowerLimit: number; + /** !#en + The upper joint limit. + !#zh + 刚体能够移动的最大值 */ + upperLimit: number; + /** !#en + The maxium force can be applied to rigidbody to rearch the target motor speed. + !#zh + 可以施加到刚体的最大力。 */ + maxMotorForce: number; + /** !#en + The expected motor speed. + !#zh + 期望的马达速度。 */ + motorSpeed: number; + } + /** !#en + A revolute joint constrains two bodies to share a common point while they + are free to rotate about the point. The relative rotation about the shared + point is the joint angle. You can limit the relative rotation with + a joint limit that specifies a lower and upper angle. You can use a motor + to drive the relative rotation about the shared point. A maximum motor torque + is provided so that infinite forces are not generated. + !#zh + 旋转关节可以约束两个刚体围绕一个点来进行旋转。 + 你可以通过开启关节限制来限制旋转的最大角度和最小角度。 + 你可以通过开启马达来施加一个扭矩力来驱动这两个刚体在这一点上的相对速度。 */ + export class RevoluteJoint extends Joint { + /** !#en + The reference angle. + An angle between bodies considered to be zero for the joint angle. + !#zh + 相对角度。 + 两个物体之间角度为零时可以看作相等于关节角度 */ + referenceAngle: number; + /** !#en + The lower angle. + !#zh + 角度的最低限制。 */ + lowerAngle: number; + /** !#en + The upper angle. + !#zh + 角度的最高限制。 */ + upperAngle: number; + /** !#en + The maxium torque can be applied to rigidbody to rearch the target motor speed. + !#zh + 可以施加到刚体的最大扭矩。 */ + maxMotorTorque: number; + /** !#en + The expected motor speed. + !#zh + 期望的马达速度。 */ + motorSpeed: number; + /** !#en + Enable joint limit? + !#zh + 是否开启关节的限制? */ + enableLimit: boolean; + /** !#en + Enable joint motor? + !#zh + 是否开启关节马达? */ + enableMotor: boolean; + /** + !#en + Get the joint angle. + !#zh + 获取关节角度。 + */ + getJointAngle(): number; + } + /** !#en + A rope joint enforces a maximum distance between two points + on two bodies. It has no other effect. + Warning: if you attempt to change the maximum length during + the simulation you will get some non-physical behavior. + !#zh + 绳子关节只指定两个刚体间的最大距离,没有其他的效果。 + 注意:如果你试图动态修改关节的长度,这有可能会得到一些意外的效果。 */ + export class RopeJoint extends Joint { + /** !#en + The max length. + !#zh + 最大长度。 */ + maxLength: number; + } + /** !#en + A weld joint essentially glues two bodies together. A weld joint may + distort somewhat because the island constraint solver is approximate. + !#zh + 熔接关节相当于将两个刚体粘在了一起。 + 熔接关节可能会使某些东西失真,因为约束求解器算出的都是近似值。 */ + export class WeldJoint extends Joint { + /** !#en + The reference angle. + !#zh + 相对角度。 */ + referenceAngle: number; + /** !#en + The frequency. + !#zh + 弹性系数。 */ + frequency: number; + /** !#en + The damping ratio. + !#zh + 阻尼,表示关节变形后,恢复到初始状态受到的阻力。 */ + 0: number; + } + /** !#en + A wheel joint. This joint provides two degrees of freedom: translation + along an axis fixed in bodyA and rotation in the plane. You can use a joint motor to drive + the rotation or to model rotational friction. + This joint is designed for vehicle suspensions. + !#zh + 轮子关节提供两个维度的自由度:旋转和沿着指定方向上位置的移动。 + 你可以通过开启关节马达来使用马达驱动刚体的旋转。 + 轮组关节是专门为机动车类型设计的。 */ + export class WheelJoint extends Joint { + /** !#en + The local joint axis relative to rigidbody. + !#zh + 指定刚体可以移动的方向。 */ + localAxisA: Vec2; + /** !#en + The maxium torque can be applied to rigidbody to rearch the target motor speed. + !#zh + 可以施加到刚体的最大扭矩。 */ + maxMotorTorque: number; + /** !#en + The expected motor speed. + !#zh + 期望的马达速度。 */ + motorSpeed: number; + /** !#en + Enable joint motor? + !#zh + 是否开启关节马达? */ + enableMotor: boolean; + /** !#en + The spring frequency. + !#zh + 弹性系数。 */ + frequency: number; + /** !#en + The damping ratio. + !#zh + 阻尼,表示关节变形后,恢复到初始状态受到的阻力。 */ + dampingRatio: number; + } + /** !#en The rigid body type + !#zh 刚体类型 */ + export enum ERigidBodyType { + DYNAMIC = 0, + STATIC = 0, + KINEMATIC = 0, + } + /** !#en + Trigger event + !#zh + 触发事件。 */ + export class ITriggerEvent { + /** !#en + The type of event fired + !#zh + 触发的事件类型 */ + type: string; + /** !#en + Triggers its own collider in the event + !#zh + 触发事件中的自己的碰撞器 */ + selfCollider: Collider3D; + /** !#en + Triggers another collider in the event + !#zh + 触发事件中的另一个碰撞器 */ + otherCollider: Collider3D; + } + /** !#en + Collision information for collision events. + !#zh + 碰撞事件的碰撞信息。 */ + export class IContactEquation { + /** !#en + The collision point A in the collision information. + !#zh + 碰撞信息中的碰撞点 A。 */ + contactA: Vec3; + /** !#en + Collision point B in collision information. + !#zh + 碰撞信息中的碰撞点 B。 */ + contactB: Vec3; + /** !#en + Normals in collision information. + !#zh + 碰撞信息中的法线。 */ + normal: Vec3; + } + /** !#en + Collision events. + !#zh + 碰撞事件。 */ + export class ICollisionEvent { + /** !#en + Event type of collision. + !#zh + 碰撞的事件类型。 */ + type: string; + /** !#en + Collider of its own in collision. + !#zh + 碰撞中的自己的碰撞器。 */ + selfCollider: Collider3D; + /** !#en + Another collider in the collision. + !#zh + 碰撞中的另一个碰撞器。 */ + otherCollider: Collider3D; + /** !#en + Information about all the points of impact in the collision. + !#zh + 碰撞中的所有碰撞点的信息。 */ + contacts: IContactEquation[]; + } + /** !#en + Physical systems manager. + !#zh + 物理系统管理器。 */ + export class Physics3DManager { + /** !#en + Whether to enable the physics system, default is false. + !#zh + 是否启用物理系统,默认不启用。 */ + enabled: boolean; + /** !#en + Whether to allow the physics system to automatically hibernate, default is true. + !#zh + 物理系统是否允许自动休眠,默认为 true。 */ + allowSleep: boolean; + /** !#en + The maximum number of sub-steps a full step is permitted to be broken into, default is 2. + !#zh + 物理每帧模拟的最大子步数,默认为 2。 */ + maxSubStep: number; + /** !#en + Time spent in each simulation of physics, default is 1/60s. + !#zh + 物理每步模拟消耗的固定时间,默认为 1/60 秒。 */ + deltaTime: number; + /** !#en + Whether to use a fixed time step. + !#zh + 是否使用固定的时间步长。 */ + useFixedTime: boolean; + /** !#en + Gravity value of the physics simulation, default is (0, -10, 0). + !#zh + 物理世界的重力数值,默认为 (0, -10, 0)。 */ + gravity: Vec3; + /** !#en + Gets the global default physical material. Note that builtin is null. + !#zh + 获取全局的默认物理材质,注意:builtin 时为 null。 */ + defaultMaterial: PhysicsMaterial|void; + /** + !#en + A physical system simulation is performed once and will now be performed automatically once per frame. + !#zh + 执行一次物理系统的模拟,目前将在每帧自动执行一次。 + @param deltaTime The time difference from the last execution is currently elapsed per frame + */ + update(deltaTime: number): void; + /** + !#en Detect all collision boxes and return all detected results, or null if none is detected. Note that the return value is taken from the object pool, so do not save the result reference or modify the result. + !#zh 检测所有的碰撞盒,并返回所有被检测到的结果,若没有检测到,则返回空值。注意返回值是从对象池中取的,所以请不要保存结果引用或者修改结果。 + @param worldRay A ray in world space + @param groupIndexOrName Collision group index or group name + @param maxDistance Maximum detection distance + @param queryTrigger Detect trigger or not + */ + raycast(worldRay: geomUtils.Ray, groupIndexOrName: number|string, maxDistance: number, queryTrigger: boolean): PhysicsRayResult[]; + /** + !#en Detect all collision boxes and return the detection result with the shortest ray distance. If not, return null value. Note that the return value is taken from the object pool, so do not save the result reference or modify the result. + !#zh 检测所有的碰撞盒,并返回射线距离最短的检测结果,若没有,则返回空值。注意返回值是从对象池中取的,所以请不要保存结果引用或者修改结果。 + @param worldRay A ray in world space + @param groupIndexOrName Collision group index or group name + @param maxDistance Maximum detection distance + @param queryTrigger Detect trigger or not + */ + raycastClosest(worldRay: geomUtils.Ray, groupIndexOrName: number|string, maxDistance: number, queryTrigger: boolean): PhysicsRayResult; + } + /** !#en + Used to store physical ray detection results + !#zh + 用于保存物理射线检测结果 */ + export class PhysicsRayResult { + /** !#en + Hit the point + !#zh + 击中点 */ + hitPoint: Vec3; + /** !#en + Distance + !#zh + 距离 */ + distance: number; + /** !#en + Hit the collision box + !#zh + 击中的碰撞盒 */ + collider: Collider3D; + /** + !#en + Set up ray. This method is used internally by the engine. Do not call it from an external script + !#zh + 设置射线,此方法由引擎内部使用,请勿在外部脚本调用 + @param hitPoint hitPoint + @param distance distance + @param collider collider + */ + _assign(hitPoint: Vec3, distance: number, collider: Collider3D): void; + /** + !#en + Clone + !#zh + 克隆 + */ + clone(): void; + } + /** Rigid body interface */ + export class IRigidBody { + rigidBody: RigidBody3D; + mass: number; + linearDamping: number; + angularDamping: number; + isKinematic: boolean; + useGravity: boolean; + fixedRotation: boolean; + linearFactor: IVec3Like; + angularFactor: IVec3Like; + allowSleep: boolean; + isAwake: boolean; + isSleepy: boolean; + isSleeping: boolean; + wakeUp(): void; + sleep(): void; + /** + + @param out out + */ + getLinearVelocity(out: IVec3Like): void; + /** + + @param out out + */ + setLinearVelocity(out: IVec3Like): void; + /** + + @param out out + */ + getAngularVelocity(out: IVec3Like): void; + /** + + @param out out + */ + setAngularVelocity(out: IVec3Like): void; + /** + + @param force force + @param relativePoint relativePoint + */ + applyForce(force: IVec3Like, relativePoint: IVec3Like): void; + /** + + @param force force + @param relativePoint relativePoint + */ + applyLocalForce(force: IVec3Like, relativePoint: IVec3Like): void; + /** + + @param force force + @param relativePoint relativePoint + */ + applyImpulse(force: IVec3Like, relativePoint: IVec3Like): void; + /** + + @param force force + @param relativePoint relativePoint + */ + applyLocalImpulse(force: IVec3Like, relativePoint: IVec3Like): void; + /** + + @param torque torque + */ + applyTorque(torque: IVec3Like): void; + /** + + @param torque torque + */ + applyLocalTorque(torque: IVec3Like): void; + } + /** Class has x y z properties */ + export class IVec3Like { + x: number; + y: number; + z: number; + } + /** Class has x y z w properties */ + export class IQuatLike { + x: number; + y: number; + z: number; + w: number; + } + /** !#en Base shape interface. */ + export class IBaseShape { + collider: Collider3D; + attachedRigidBody: RigidBody3D|void; + material: any; + isTrigger: boolean; + center: IVec3Like; + } + /** !#en box shape interface */ + export class IBoxShape { + size: IVec3Like; + } + /** !#en Sphere shape interface */ + export class ISphereShape { + radius: number; + } + /** Ray cast options */ + export class IRaycastOptions { + groupIndex: number; + queryTrigger: boolean; + maxDistance: number; + } + /** Collision detect */ + export class ICollisionDetect { + /** + Ray cast, and return information of the closest hit. + @param worldRay worldRay + @param options options + @param out out + */ + raycastClosest(worldRay: geomUtils.Ray, options: IRaycastOptions, out: PhysicsRayResult): boolean; + /** + Ray cast against all bodies. The provided callback will be executed for each hit with a RaycastResult as single argument. + @param worldRay worldRay + @param options options + @param pool pool + @param resultes resultes + */ + raycast(worldRay: geomUtils.Ray, options: IRaycastOptions, pool: RecyclePool, resultes: PhysicsRayResult[]): boolean; + } + /** Physics world interface */ + export class IPhysicsWorld { + } + /** !#en The color over time module of 3d particle. + !#zh 3D 粒子颜色变化模块 */ + export class ColorOvertimeModule { + /** !#en The enable of ColorOvertimeModule. + !#zh 是否启用 */ + enable: boolean; + } + /** !#en The curve range of target value. + !#zh 目标值的曲线范围 */ + export class CurveRange { + /** !#en Curve type. + !#zh 曲线类型。 */ + mode: ParticleSystem.EmitterMode; + /** !#en The curve to use when mode is Curve. + !#zh 当 mode 为 Curve 时,使用的曲线。 */ + curve: AnimationCurve; + /** !#en The lower limit of the curve to use when mode is TwoCurves + !#zh 当 mode 为 TwoCurves 时,使用的曲线下限。 */ + curveMin: AnimationCurve; + /** !#en The upper limit of the curve to use when mode is TwoCurves + !#zh 当 mode 为 TwoCurves 时,使用的曲线上限。 */ + curveMax: AnimationCurve; + /** !#en When mode is Constant, the value of the curve. + !#zh 当 mode 为 Constant 时,曲线的值。 */ + constant: number; + /** !#en The lower limit of the curve to use when mode is TwoConstants + !#zh 当 mode 为 TwoConstants 时,曲线的下限。 */ + constantMin: number; + /** !#en The upper limit of the curve to use when mode is TwoConstants + !#zh 当 mode 为 TwoConstants 时,曲线的上限。 */ + constantMax: number; + /** !#en Coefficients applied to curve interpolation. + !#zh 应用于曲线插值的系数。 */ + multiplier: number; + } + /** !#en The force over time module of 3d particle. + !#zh 3D 粒子的加速度模块 */ + export class ForceOvertimeModule { + /** !#en The enable of ColorOvertimeModule. + !#zh 是否启用 */ + enable: boolean; + /** !#en Coordinate system used in acceleration calculation. + !#zh 加速度计算时采用的坐标系。 */ + space: ParticleSystem3DAssembler.Space; + /** !#en X-axis acceleration component. + !#zh X 轴方向上的加速度分量。 */ + x: CurveRange; + /** !#en Y-axis acceleration component. + !#zh Y 轴方向上的加速度分量。 */ + y: CurveRange; + /** !#en Z-axis acceleration component. + !#zh Z 轴方向上的加速度分量。 */ + z: CurveRange; + } + /** !#en The gradient range of color. + !#zh 颜色值的渐变范围 */ + export class GradientRange { + /** !#en Gradient type. + !#zh 渐变色类型。 */ + mode: ParticleSystem.EmitterMode; + /** !#en The color when mode is Color. + !#zh 当 mode 为 Color 时的颜色。 */ + color: Color; + /** !#en Lower color limit when mode is TwoColors. + !#zh 当 mode 为 TwoColors 时的颜色下限。 */ + colorMin: Color; + /** !#en Upper color limit when mode is TwoColors. + !#zh 当 mode 为 TwoColors 时的颜色上限。 */ + colorMax: Color; + /** !#en Color gradient when mode is Gradient + !#zh 当 mode 为 Gradient 时的颜色渐变。 */ + gradient: Gradient; + /** !#en Lower color gradient limit when mode is TwoGradients. + !#zh 当 mode 为 TwoGradients 时的颜色渐变下限。 */ + gradientMin: Gradient; + /** !#en Upper color gradient limit when mode is TwoGradients. + !#zh 当 mode 为 TwoGradients 时的颜色渐变上限。 */ + gradientMax: Gradient; + } + /** !#en The color key of gradient. + !#zh color 关键帧 */ + export class ColorKey { + } + /** !#en The alpha key of gradient. + !#zh alpha 关键帧 */ + export class AlphaKey { + } + /** !#en The gradient data of color. + !#zh 颜色渐变数据 */ + export class Gradient { + } + /** !#en The limit velocity module of 3d particle. + !#zh 3D 粒子的限速模块 */ + export class LimitVelocityOvertimeModule { + /** !#en The enable of LimitVelocityOvertimeModule. + !#zh 是否启用 */ + enable: boolean; + /** !#en The coordinate system used when calculating the lower speed limit. + !#zh 计算速度下限时采用的坐标系。 */ + space: ParticleSystem3DAssembler.Space; + /** !#en Whether to limit the three axes separately. + !#zh 是否三个轴分开限制。 */ + separateAxes: boolean; + /** !#en Lower speed limit + !#zh 速度下限。 */ + limit: CurveRange; + /** !#en Lower speed limit in X direction. + !#zh X 轴方向上的速度下限。 */ + limitX: CurveRange; + /** !#en Lower speed limit in Y direction. + !#zh Y 轴方向上的速度下限。 */ + limitY: CurveRange; + /** !#en Lower speed limit in Z direction. + !#zh Z 轴方向上的速度下限。 */ + limitZ: CurveRange; + /** !#en Interpolation of current speed and lower speed limit. + !#zh 当前速度与速度下限的插值。 */ + dampen: number; + } + /** !#en The optimized curve. + !#zh 优化曲线 */ + export class OptimizedCurve { + } + /** !#en The rotation module of 3d particle. + !#zh 3D 粒子的旋转模块 */ + export class RotationOvertimeModule { + /** !#en The enable of RotationOvertimeModule. + !#zh 是否启用 */ + enable: boolean; + /** !#en Whether to set the rotation of three axes separately (not currently supported) + !#zh 是否三个轴分开设定旋转(暂不支持)。 */ + separateAxes: boolean; + /** !#en Set rotation around X axis. + !#zh 绕 X 轴设定旋转。 */ + x: CurveRange; + /** !#en Set rotation around Y axis. + !#zh 绕 Y 轴设定旋转。 */ + y: CurveRange; + /** !#en Set rotation around Z axis. + !#zh 绕 Z 轴设定旋转。 */ + z: CurveRange; + } + /** !#en The size module of 3d particle. + !#zh 3D 粒子的大小模块 */ + export class SizeOvertimeModule { + /** !#en The enable of SizeOvertimeModule. + !#zh 是否启用 */ + enable: boolean; + /** !#en Decide whether to control particle size independently on each axis. + !#zh 决定是否在每个轴上独立控制粒子大小。 */ + separateAxes: boolean; + /** !#en Define a curve to determine the size change of particles during their life cycle. + !#zh 定义一条曲线来决定粒子在其生命周期中的大小变化。 */ + size: CurveRange; + /** !#en Defines a curve to determine the size change of particles in the X-axis direction during their life cycle. + !#zh 定义一条曲线来决定粒子在其生命周期中 X 轴方向上的大小变化。 */ + x: CurveRange; + /** !#en Defines a curve to determine the size change of particles in the Y-axis direction during their life cycle. + !#zh 定义一条曲线来决定粒子在其生命周期中 Y 轴方向上的大小变化。 */ + y: CurveRange; + /** !#en Defines a curve to determine the size change of particles in the Z-axis direction during their life cycle. + !#zh 定义一条曲线来决定粒子在其生命周期中 Z 轴方向上的大小变化。 */ + z: CurveRange; + } + /** !#en The texture animation module of 3d particle. + !#zh 3D 粒子的贴图动画模块 */ + export class TextureAnimationModule { + /** !#en The enable of TextureAnimationModule. + !#zh 是否启用 */ + enable: boolean; + /** !#en Set the type of particle map animation (only supports Grid mode for the time being) + !#zh 设定粒子贴图动画的类型(暂只支持 Grid 模式。 */ + mode: ParticleSystem.EmitterMode; + /** !#en Animation frames in X direction. + !#zh X 方向动画帧数。 */ + numTilesX: number; + /** !#en Animation frames in Y direction. + !#zh Y 方向动画帧数。 */ + numTilesY: number; + /** !#en The way of the animation plays. + !#zh 动画播放方式。 */ + animation: Animation; + /** !#en Randomly select a line from the animated map to generate the animation.
+ This option only takes effect when the animation playback mode is SingleRow. + !#zh 随机从动画贴图中选择一行以生成动画。
+ 此选项仅在动画播放方式为 SingleRow 时生效。 */ + randomRow: boolean; + /** !#en Select specific lines from the animation map to generate the animation.
+ This option is only available when the animation playback mode is SingleRow and randomRow is disabled. + !#zh 从动画贴图中选择特定行以生成动画。
+ 此选项仅在动画播放方式为 SingleRow 时且禁用 randomRow 时可用。 */ + rowIndex: number; + /** !#en Frame and time curve of animation playback in one cycle. + !#zh 一个周期内动画播放的帧与时间变化曲线。 */ + frameOverTime: CurveRange; + /** !#en Play from which frames, the time is the life cycle of the entire particle system. + !#zh 从第几帧开始播放,时间为整个粒子系统的生命周期。 */ + startFrame: CurveRange; + /** !#en Number of playback loops in a life cycle. + !#zh 一个生命周期内播放循环的次数。 */ + cycleCount: number; + } + /** !#en The velocity module of 3d particle. + !#zh 3D 粒子的速度模块 */ + export class VelocityOvertimeModule { + /** !#en The enable of VelocityOvertimeModule. + !#zh 是否启用 */ + enable: boolean; + /** !#en Coordinate system used in speed calculation. + !#zh 速度计算时采用的坐标系。 */ + space: ParticleSystem3DAssembler.Space; + /** !#en Velocity component in X axis direction + !#zh X 轴方向上的速度分量。 */ + x: CurveRange; + /** !#en Velocity component in Y axis direction + !#zh Y 轴方向上的速度分量。 */ + y: CurveRange; + /** !#en Velocity component in Z axis direction + !#zh Z 轴方向上的速度分量。 */ + z: CurveRange; + /** !#en Speed correction factor (only supports CPU particles). + !#zh 速度修正系数(只支持 CPU 粒子)。 */ + speedModifier: CurveRange; + } + /** !#en The shape module of 3d particle. + !#zh 3D 粒子的发射形状模块 */ + export class ShapeModule { + /** !#en The enable of shapeModule. + !#zh 是否启用 */ + enable: boolean; + /** !#en Particle emitter type. + !#zh 粒子发射器类型。 */ + shapeType: shapeModule.ShapeType; + /** !#en The emission site of the particle. + !#zh 粒子从发射器哪个部位发射。 */ + emitFrom: shapeModule.EmitLocation; + /** !#en Particle emitter radius. + !#zh 粒子发射器半径。 */ + radius: number; + /** !#en Particle emitter emission position (not valid for Box type emitters): + - 0 means emitted from the surface; + - 1 means launch from the center; + - 0 ~ 1 indicates emission from the center to the surface. + !#zh 粒子发射器发射位置(对 Box 类型的发射器无效): + - 0 表示从表面发射; + - 1 表示从中心发射; + - 0 ~ 1 之间表示在中心到表面之间发射。 */ + radiusThickness: number; + /** !#en The angle between the axis of the cone and the generatrix + Determines the opening and closing of the cone launcher + !#zh 圆锥的轴与母线的夹角。 + 决定圆锥发射器的开合程度。 */ + angle: number; + /** !#en Particle emitters emit in a fan-shaped range. + !#zh 粒子发射器在一个扇形范围内发射。 */ + arc: number; + /** !#en How particles are emitted in the sector range. + !#zh 粒子在扇形范围内的发射方式。 */ + arcMode: shapeModule.ArcMode; + /** !#en Controls the discrete intervals around the arcs where particles might be generated. + !#zh 控制可能产生粒子的弧周围的离散间隔。 */ + arcSpread: number; + /** !#en The speed at which particles are emitted around the circumference. + !#zh 粒子沿圆周发射的速度。 */ + arcSpeed: CurveRange; + /** !#en Axis length from top of cone to bottom of cone . + Determines the height of the cone emitter. + !#zh 圆锥顶部截面距离底部的轴长。 + 决定圆锥发射器的高度。 */ + length: number; + /** !#en Particle emitter emission location (for box-type particle emitters). + !#zh 粒子发射器发射位置(针对 Box 类型的粒子发射器。 */ + boxThickness: Vec3; + /** !#en Particle Emitter Position + !#zh 粒子发射器位置。 */ + position: Vec3; + /** !#en Particle emitter rotation angle. + !#zh 粒子发射器旋转角度。 */ + rotation: Vec3; + /** !#en Particle emitter scaling + !#zh 粒子发射器缩放比例。 */ + scale: Vec3; + /** !#en The direction of particle movement is determined based on the initial direction of the particles. + !#zh 根据粒子的初始方向决定粒子的移动方向。 */ + alignToDirection: boolean; + /** !#en Set particle generation direction randomly. + !#zh 粒子生成方向随机设定。 */ + randomDirectionAmount: number; + /** !#en Interpolation between the current emission direction and the direction from the current position to the center of the node. + !#zh 表示当前发射方向与当前位置到结点中心连线方向的插值。 */ + sphericalDirectionAmount: number; + } + /** !#en The trail module of 3d particle. + !#zh 3D 粒子拖尾模块 */ + export class TrailModule { + /** !#en The enable of trailModule. + !#zh 是否启用 */ + enable: boolean; + /** !#en Sets how particles generate trajectories. + !#zh 设定粒子生成轨迹的方式。 */ + mode: trailModule.TrailMode; + /** !#en Life cycle of trajectory. + !#zh 轨迹存在的生命周期。 */ + lifeTime: CurveRange; + /** !#en Minimum spacing between each track particle + !#zh 每个轨迹粒子之间的最小间距。 */ + minParticleDistance: number; + /** !#en The coordinate system of trajectories. + !#zh 轨迹设定时的坐标系。 */ + space: ParticleSystem3DAssembler.Space; + /** !#en Whether the particle itself exists. + !#zh 粒子本身是否存在。 */ + existWithParticles: boolean; + /** !#en Set the texture fill method + !#zh 设定纹理填充方式。 */ + textureMode: trailModule.TextureMode; + /** !#en Whether to use particle width + !#zh 是否使用粒子的宽度。 */ + widthFromParticle: boolean; + /** !#en Curves that control track length + !#zh 控制轨迹长度的曲线。 */ + widthRatio: CurveRange; + /** !#en Whether to use particle color + !#zh 是否使用粒子的颜色。 */ + colorFromParticle: boolean; + /** !#en The color of trajectories. + !#zh 轨迹的颜色。 */ + colorOverTrail: GradientRange; + /** !#en Trajectories color over time. + !#zh 轨迹随时间变化的颜色。 */ + colorOvertime: GradientRange; + } + /** !#en Manage Dynamic Atlas Manager. Dynamic Atlas Manager is used for merging textures at runtime, see [Dynamic Atlas](https://docs.cocos.com/creator/manual/en/advanced-topics/dynamic-atlas.html) for details. + !#zh 管理动态图集。动态图集用于在运行时对贴图进行合并,详见 [动态合图](https://docs.cocos.com/creator/manual/zh/advanced-topics/dynamic-atlas.html)。 */ + export class DynamicAtlasManager { + /** !#en Enable or disable the dynamic atlas, see [Dynamic Atlas](https://docs.cocos.com/creator/manual/en/advanced-topics/dynamic-atlas.html) for details. + !#zh 开启或者关闭动态图集,详见 [动态合图](https://docs.cocos.com/creator/manual/zh/advanced-topics/dynamic-atlas.html)。 */ + enabled: boolean; + /** !#en The maximum number of atlas that can be created. + !#zh 可以创建的最大图集数量。 */ + maxAtlasCount: number; + /** !#en Is enable textureBleeding. + !#zh 是否开启 textureBleeding */ + textureBleeding: boolean; + /** !#en The size of the atlas that was created + !#zh 创建的图集的宽高 */ + textureSize: number; + /** !#en The maximum size of the picture that can be added to the atlas. + !#zh 可以添加进图集的图片的最大尺寸。 */ + maxFrameSize: number; + /** !#en The minimum size of the picture that can be added to the atlas. + !#zh 可以添加进图集的图片的最小尺寸。 */ + minFrameSize: number; + /** + !#en Append a sprite frame into the dynamic atlas. + !#zh 添加碎图进入动态图集。 + @param spriteFrame spriteFrame + */ + insertSpriteFrame(spriteFrame: SpriteFrame): void; + /** + !#en Resets all dynamic atlas, and the existing ones will be destroyed. + !#zh 重置所有动态图集,已有的动态图集会被销毁。 + */ + reset(): void; + /** + !#en Displays all the dynamic atlas in the current scene, which you can use to view the current atlas state. + !#zh 在当前场景中显示所有动态图集,可以用来查看当前的合图状态。 + @param show show + */ + showDebug(show: boolean): Node; + } + /** !#en + Physics material. + !#zh + 物理材质。 */ + export class PhysicsMaterial extends Asset { + /** !#en + Friction for this material. + !#zh + 物理材质的摩擦力。 */ + friction: number; + /** !#en + Restitution for this material. + !#zh + 物理材质的弹力。 */ + restitution: number; + } + /** !#en + Each frame applies a constant force to a rigid body, depending on the RigidBody3D + !#zh + 在每帧对一个刚体施加持续的力,依赖 RigidBody3D 组件 */ + export class ConstantForce extends Component { + /** !#en + Set the force used in the world coordinate system, use `this.force = otherVec3`. + !#zh + 设置世界坐标系中使用的力,设置时请用 `this.force = otherVec3` 的方式。 */ + force: Vec3; + /** !#en + Set the force used in the local coordinate system, using `this.localforce = otherVec3`. + !#zh + 获取和设置本地坐标系中使用的力,设置时请用 `this.localForce = otherVec3` 的方式。 */ + localForce: Vec3; + /** !#en + Torque applied to the world orientation + !#zh + 对世界朝向施加的扭矩 */ + torque: Vec3; + /** !#en + Torque applied to local orientation, using `this.localtorque = otherVec3`. + !#zh + 对本地朝向施加的扭矩,设置时请用 `this.localTorque = otherVec3` 的方式。 */ + localTorque: Vec3; + } + /** !#en + RigidBody is the basic object that make up the physical world, and it can make a node physically affected and react. + !#zh + 刚体是组成物理世界的基本对象,可以让一个节点受到物理影响并产生反应。该组件在使用 Builtin 物理引擎时无效。 */ + export class RigidBody3D extends Component { + /** !#en + Whether sleep is allowed. + !#zh + 是否允许休眠。 */ + allowSleep: boolean; + /** !#en + The mass of the rigidbody. + !#zh + 刚体的质量。 */ + mass: number; + /** !#en + Used to reduce the linear rate of rigidbody. The larger the value, the slower the rigidbody moves. + !#zh + 线性阻尼,用于减小刚体的线性速率,值越大物体移动越慢。 */ + linearDamping: number; + /** !#en + Used to reduce the rotation rate of rigidbody. The larger the value, the slower the rigidbody rotates. + !#zh + 角阻尼,用于减小刚体的旋转速率,值越大刚体旋转越慢。 */ + angularDamping: number; + /** !#en + If enabled, the developer controls the displacement and rotation of the rigidbody, not the physics engine. + !#zh + 是否由开发者来控制刚体的位移和旋转,而不是受物理引擎的影响。 */ + isKinematic: boolean; + /** !#en + If enabled, the rigidbody is affected by gravity. + !#zh + 如果开启,刚体会受到重力影响。 */ + useGravity: boolean; + /** !#en + If enabled, the rigidbody will be fixed without rotation during a collision. + !#zh + 如果开启,发生碰撞时会固定刚体不产生旋转。 */ + fixedRotation: boolean; + /** !#en + It can affect the linear velocity change of the rigidbody in each axis. The larger the value, the faster the rigidbody moves. + !#zh + 线性因子,可影响刚体在每个轴向的线性速度变化,值越大刚体移动越快。 */ + linearFactor: Vec3; + /** !#en + It can affect the rotation speed change of the rigidbody in each axis. The larger the value, the faster the rigidbody rotates. + !#zh + 旋转因子,可影响刚体在每个轴向的旋转速度变化,值越大刚体旋转越快。 */ + angularFactor: Vec3; + /** !#en + The rigidbody is awake. + !#zh + 刚体是否为唤醒的状态。 */ + isAwake: boolean; + /** !#en + The rigidbody can enter hibernation. + !#zh + 刚体是否为可进入休眠的状态。 */ + isSleepy: boolean; + /** !#en + The rigidbody is sleeping. + !#zh + 刚体是否为正在休眠的状态。 */ + isSleeping: boolean; + /** !#en + Get the rigidbody object inside the physics engine. + !#zh + 获得物理引擎内部刚体对象。 */ + rigidBody: IRigidBody; + /** + !#en + A force is applied to a rigid body at a point in world space. + !#zh + 在世界空间中的某点上对刚体施加一个作用力。 + @param force force + @param relativePoint The point of action, relative to the center of the rigid body. + */ + applyForce(force: Vec3, relativePoint: Vec3): void; + /** + !#en + Apply a force on the rigid body at a point in local space. + !#zh + 在本地空间中的某点上对刚体施加一个作用力。 + @param force force + @param localPoint Point of application + */ + applyLocalForce(force: Vec3, localPoint: Vec3): void; + /** + !#en + Apply an impulse to a rigid body at a point in world space. + !#zh + 在世界空间的某点上对刚体施加一个冲量。 + @param impulse impulse + @param relativePoint The point of action, relative to the center of the rigid body. + */ + applyImpulse(impulse: Vec3, relativePoint: Vec3): void; + /** + !#en + Apply an impulse to the rigid body at a point in local space. + !#zh + 在本地空间的某点上对刚体施加一个冲量。 + @param impulse impulse + @param localPoint Point of application + */ + applyLocalImpulse(impulse: Vec3, localPoint: Vec3): void; + /** + !#en + Apply a torque to the rigid body. + !#zh + 对刚体施加扭转力。 + @param torque torque + */ + applyTorque(torque: Vec3): void; + /** + !#en + Apply a local torque to the rigid body. + !#zh + 对刚体施加本地扭转力。 + @param torque torque + */ + applyLocalTorque(torque: Vec3): void; + /** + !#en + Awaken the rigid body. + !#zh + 唤醒刚体。 + */ + wakeUp(): void; + /** + !#en + Dormant rigid body. + !#zh + 休眠刚体。 + */ + sleep(): void; + /** + !#en + Get linear velocity. + !#zh + 获取线性速度。 + @param out out + */ + getLinearVelocity(out: Vec3): void; + /** + !#en + Set linear speed. + !#zh + 设置线性速度。 + @param value value + */ + setLinearVelocity(value: Vec3): void; + /** + !#en + Gets the rotation speed. + !#zh + 获取旋转速度。 + @param out out + */ + getAngularVelocity(out: Vec3): void; + /** + !#en + Set rotation speed. + !#zh + 设置旋转速度。 + @param value value + */ + setAngularVelocity(value: Vec3): void; + } + /** !#en + Physics box collider + !#zh + 物理盒子碰撞器 */ + export class BoxCollider3D extends Collider3D { + /** !#en + Get or set the size of the box, in local space. + !#zh + 获取或设置盒的大小。 */ + size: Vec3; + boxShape: IBoxShape; + } + /** !#en + The base class of the collider. + !#zh + 碰撞器的基类。 */ + export class Collider3D extends Component implements EventTarget { + sharedMaterial: PhysicsMaterial; + /** !#en + get or set the collider is trigger, this will be always trigger if using builtin. + !#zh + 获取或设置碰撞器是否为触发器。 */ + isTrigger: boolean; + /** !#en + get or set the center of the collider, in local space. + !#zh + 获取或设置碰撞器的中心点。 */ + center: Vec3; + /** !#en + get the collider attached rigidbody, this may be null. + !#zh + 获取碰撞器所绑定的刚体组件,可能为 null。 */ + attachedRigidbody: RigidBody3D|void; + /** !#en + get collider shape. + !#zh + 获取碰撞器形状。 */ + shape: IBaseShape; + /** + !#en + Register an callback of a specific event type on the EventTarget. + This type of event should be triggered via `emit`. + !#zh + 注册事件目标的特定事件类型回调。这种类型的事件应该被 `emit` 触发。 + @param type The type of collider event can be `trigger-enter`, `trigger-stay`, `trigger-exit` or `collision-enter`, `collision-stay`, `collision-exit`. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null. + + @example + ```js + eventTarget.on('fire', function (event) { + // event is ITriggerEvent or ICollisionEvent + }, node); + ``` + */ + on(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. + !#zh + 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。 + @param type The type of collider event can be `trigger-enter`, `trigger-stay`, `trigger-exit` or `collision-enter`, `collision-stay`, `collision-exit`. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed. + + @example + ```js + // register fire eventListener + var callback = eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, target); + // remove fire event listener + eventTarget.off('fire', callback, target); + // remove all fire event listeners + eventTarget.off('fire'); + ``` + */ + off(type: string, callback?: Function, target?: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type The type of collider event can be `trigger-enter`, `trigger-stay`, `trigger-exit` or `collision-enter`, `collision-stay`, `collision-exit`. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null. + + @example + ```js + eventTarget.once('fire', function (event) { + // event is ITriggerEvent or ICollisionEvent + }, node); + ``` + */ + once(type: string, callback: (event: ITriggerEvent|ICollisionEvent) => void, target?: any): void; + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Send an event with the event object. + !#zh + 通过事件对象派发事件 + @param event event + */ + dispatchEvent(event: Event): void; + } + /** !#en + Physics sphere collider + !#zh + 物理球碰撞器 */ + export class SphereCollider3D extends Collider3D { + /** !#en + Get or set the radius of the sphere. + !#zh + 获取或设置球的半径。 */ + radius: number; + sphereShape: ISphereShape; + } + /**************************************************** + * TiledMap + *****************************************************/ + + export namespace TiledMap { + /** !#en The orientation of tiled map. + !#zh Tiled Map 地图方向。 */ + export enum Orientation { + ORTHO = 0, + HEX = 0, + ISO = 0, + } + } + + /**************************************************** + * TiledMap + *****************************************************/ + + export namespace TiledMap { + /** The property type of tiled map. */ + export enum Property { + NONE = 0, + MAP = 0, + LAYER = 0, + OBJECTGROUP = 0, + OBJECT = 0, + TILE = 0, + } + } + + /**************************************************** + * TiledMap + *****************************************************/ + + export namespace TiledMap { + /** The tile flags of tiled map. */ + export enum TileFlag { + HORIZONTAL = 0, + VERTICAL = 0, + DIAGONAL = 0, + FLIPPED_ALL = 0, + FLIPPED_MASK = 0, + } + } + + /**************************************************** + * TiledMap + *****************************************************/ + + export namespace TiledMap { + /** !#en The stagger axis of Hex tiled map. + !#zh 六边形地图的 stagger axis 值 */ + export enum StaggerAxis { + STAGGERAXIS_X = 0, + STAGGERAXIS_Y = 0, + } + } + + /**************************************************** + * TiledMap + *****************************************************/ + + export namespace TiledMap { + /** !#en The render order of tiled map. + !#zh 地图的渲染顺序 */ + export enum RenderOrder { + STAGGERINDEX_ODD = 0, + STAGGERINDEX_EVEN = 0, + RightDown = 0, + RightUp = 0, + LeftDown = 0, + LeftUp = 0, + } + } + + /**************************************************** + * TiledMap + *****************************************************/ + + export namespace TiledMap { + /** !#en TiledMap Object Type + !#zh 地图物体类型 */ + export enum TMXObjectType { + RECT = 0, + ELLIPSE = 0, + POLYGON = 0, + POLYLINE = 0, + IMAGE = 0, + TEXT = 0, + } + } + + /**************************************************** + * ParticleSystem + *****************************************************/ + + export namespace ParticleSystem { + /** !#en Enum for emitter modes + !#zh 发射模式 */ + export enum EmitterMode { + GRAVITY = 0, + RADIUS = 0, + } + } + + /**************************************************** + * ParticleSystem + *****************************************************/ + + export namespace ParticleSystem { + /** !#en Enum for particles movement type. + !#zh 粒子位置类型 */ + export enum PositionType { + FREE = 0, + RELATIVE = 0, + GROUPED = 0, + } + } + + /**************************************************** + * audioEngine + *****************************************************/ + + export namespace audioEngine { + /** !#en Audio state. + !#zh 声音播放状态 */ + export enum AudioState { + ERROR = 0, + INITIALZING = 0, + PLAYING = 0, + PAUSED = 0, + STOPPED = 0, + } + } + + /**************************************************** + * WebView + *****************************************************/ + + export namespace WebView { + /** !#en WebView event type + !#zh 网页视图事件类型 */ + export enum EventType { + LOADED = 0, + LOADING = 0, + ERROR = 0, + } + } + + /**************************************************** + * VideoPlayer + *****************************************************/ + + export namespace VideoPlayer { + /** !#en Video event type + !#zh 视频事件类型 */ + export enum EventType { + PLAYING = 0, + PAUSED = 0, + STOPPED = 0, + COMPLETED = 0, + META_LOADED = 0, + CLICKED = 0, + READY_TO_PLAY = 0, + } + } + + /**************************************************** + * VideoPlayer + *****************************************************/ + + export namespace VideoPlayer { + /** !#en Enum for video resouce type type. + !#zh 视频来源 */ + export enum ResourceType { + REMOTE = 0, + LOCAL = 0, + } + } + + /**************************************************** + * debug + *****************************************************/ + + export namespace debug { + /** !#en Enum for debug modes. + !#zh 调试模式 */ + export enum DebugMode { + NONE = 0, + INFO = 0, + WARN = 0, + ERROR = 0, + INFO_FOR_WEB_PAGE = 0, + WARN_FOR_WEB_PAGE = 0, + ERROR_FOR_WEB_PAGE = 0, + } + } + + /**************************************************** + * Node + *****************************************************/ + + export namespace Node { + /** !#en Node's local dirty properties flag + !#zh Node 的本地属性 dirty 状态位 */ + export enum _LocalDirtyFlag { + POSITION = 0, + SCALE = 0, + ROTATION = 0, + SKEW = 0, + TRS = 0, + RS = 0, + TRS = 0, + PHYSICS_POSITION = 0, + PHYSICS_SCALE = 0, + PHYSICS_ROTATION = 0, + PHYSICS_TRS = 0, + PHYSICS_RS = 0, + ALL_POSITION = 0, + ALL_SCALE = 0, + ALL_ROTATION = 0, + ALL_TRS = 0, + ALL = 0, + } + } + + /**************************************************** + * Node + *****************************************************/ + + export namespace Node { + /** !#en The event type supported by Node + !#zh Node 支持的事件类型 */ + export class EventType { + /** !#en The event type for touch start event, you can use its value directly: 'touchstart' + !#zh 当手指触摸到屏幕时。 */ + static TOUCH_START: string; + /** !#en The event type for touch move event, you can use its value directly: 'touchmove' + !#zh 当手指在屏幕上移动时。 */ + static TOUCH_MOVE: string; + /** !#en The event type for touch end event, you can use its value directly: 'touchend' + !#zh 当手指在目标节点区域内离开屏幕时。 */ + static TOUCH_END: string; + /** !#en The event type for touch end event, you can use its value directly: 'touchcancel' + !#zh 当手指在目标节点区域外离开屏幕时。 */ + static TOUCH_CANCEL: string; + /** !#en The event type for mouse down events, you can use its value directly: 'mousedown' + !#zh 当鼠标按下时触发一次。 */ + static MOUSE_DOWN: string; + /** !#en The event type for mouse move events, you can use its value directly: 'mousemove' + !#zh 当鼠标在目标节点在目标节点区域中移动时,不论是否按下。 */ + static MOUSE_MOVE: string; + /** !#en The event type for mouse enter target events, you can use its value directly: 'mouseenter' + !#zh 当鼠标移入目标节点区域时,不论是否按下。 */ + static MOUSE_ENTER: string; + /** !#en The event type for mouse leave target events, you can use its value directly: 'mouseleave' + !#zh 当鼠标移出目标节点区域时,不论是否按下。 */ + static MOUSE_LEAVE: string; + /** !#en The event type for mouse up events, you can use its value directly: 'mouseup' + !#zh 当鼠标从按下状态松开时触发一次。 */ + static MOUSE_UP: string; + /** !#en The event type for mouse wheel events, you can use its value directly: 'mousewheel' + !#zh 当鼠标滚轮滚动时。 */ + static MOUSE_WHEEL: string; + /** !#en The event type for position change events. + Performance note, this event will be triggered every time corresponding properties being changed, + if the event callback have heavy logic it may have great performance impact, try to avoid such scenario. + !#zh 当节点位置改变时触发的事件。 + 性能警告:这个事件会在每次对应的属性被修改时触发,如果事件回调损耗较高,有可能对性能有很大的负面影响,请尽量避免这种情况。 */ + static POSITION_CHANGED: string; + /** !#en The event type for rotation change events. + Performance note, this event will be triggered every time corresponding properties being changed, + if the event callback have heavy logic it may have great performance impact, try to avoid such scenario. + !#zh 当节点旋转改变时触发的事件。 + 性能警告:这个事件会在每次对应的属性被修改时触发,如果事件回调损耗较高,有可能对性能有很大的负面影响,请尽量避免这种情况。 */ + static ROTATION_CHANGED: string; + /** !#en The event type for scale change events. + Performance note, this event will be triggered every time corresponding properties being changed, + if the event callback have heavy logic it may have great performance impact, try to avoid such scenario. + !#zh 当节点缩放改变时触发的事件。 + 性能警告:这个事件会在每次对应的属性被修改时触发,如果事件回调损耗较高,有可能对性能有很大的负面影响,请尽量避免这种情况。 */ + static SCALE_CHANGED: string; + /** !#en The event type for size change events. + Performance note, this event will be triggered every time corresponding properties being changed, + if the event callback have heavy logic it may have great performance impact, try to avoid such scenario. + !#zh 当节点尺寸改变时触发的事件。 + 性能警告:这个事件会在每次对应的属性被修改时触发,如果事件回调损耗较高,有可能对性能有很大的负面影响,请尽量避免这种情况。 */ + static SIZE_CHANGED: string; + /** !#en The event type for anchor point change events. + Performance note, this event will be triggered every time corresponding properties being changed, + if the event callback have heavy logic it may have great performance impact, try to avoid such scenario. + !#zh 当节点锚点改变时触发的事件。 + 性能警告:这个事件会在每次对应的属性被修改时触发,如果事件回调损耗较高,有可能对性能有很大的负面影响,请尽量避免这种情况。 */ + static ANCHOR_CHANGED: string; + /** !#en The event type for color change events. + Performance note, this event will be triggered every time corresponding properties being changed, + if the event callback have heavy logic it may have great performance impact, try to avoid such scenario. + !#zh 当节点颜色改变时触发的事件。 + 性能警告:这个事件会在每次对应的属性被修改时触发,如果事件回调损耗较高,有可能对性能有很大的负面影响,请尽量避免这种情况。 */ + static COLOR_CHANGED: string; + /** !#en The event type for new child added events. + !#zh 当新的子节点被添加时触发的事件。 */ + static CHILD_ADDED: string; + /** !#en The event type for child removed events. + !#zh 当子节点被移除时触发的事件。 */ + static CHILD_REMOVED: string; + /** !#en The event type for children reorder events. + !#zh 当子节点顺序改变时触发的事件。 */ + static CHILD_REORDER: string; + /** !#en The event type for node group changed events. + !#zh 当节点归属群组发生变化时触发的事件。 */ + static GROUP_CHANGED: string; + /** !#en The event type for node's sibling order changed. + !#zh 当节点在兄弟节点中的顺序发生变化时触发的事件。 */ + static SIBLING_ORDER_CHANGED: string; + } + } + + /**************************************************** + * Light + *****************************************************/ + + export namespace Light { + /** !#en The light source type + + !#zh 光源类型 */ + export enum Type { + DIRECTIONAL = 0, + POINT = 0, + SPOT = 0, + AMBIENT = 0, + } + } + + /**************************************************** + * Light + *****************************************************/ + + export namespace Light { + /** !#en The shadow type + + !#zh 阴影类型 */ + export enum ShadowType { + NONE = 0, + HARD = 0, + SOFT_PCF3X3 = 0, + SOFT_PCF5X5 = 0, + } + } + + /**************************************************** + * Collider + *****************************************************/ + + export namespace Collider { + /** !#en Defines a Box Collider . + !#zh 用来定义包围盒碰撞体 */ + export class Box { + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Box size + !#zh 包围盒大小 */ + size: Size; + } + } + + /**************************************************** + * Collider + *****************************************************/ + + export namespace Collider { + /** !#en Defines a Circle Collider . + !#zh 用来定义圆形碰撞体 */ + export class Circle { + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Circle radius + !#zh 圆形半径 */ + radius: number; + } + } + + /**************************************************** + * Collider + *****************************************************/ + + export namespace Collider { + /** !#en Defines a Polygon Collider . + !#zh 用来定义多边形碰撞体 */ + export class Polygon { + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Polygon points + !#zh 多边形顶点数组 */ + points: Vec2[]; + } + } + + /**************************************************** + * Prefab + *****************************************************/ + + export namespace Prefab { + /** !#zh + Prefab 创建实例所用的优化策略,配合 {{#crossLink "Prefab.optimizationPolicy"}}cc.Prefab#optimizationPolicy{{/crossLink}} 使用。 + !#en + An enumeration used with the {{#crossLink "Prefab.optimizationPolicy"}}cc.Prefab#optimizationPolicy{{/crossLink}} + to specify how to optimize the instantiate operation. */ + export enum OptimizationPolicy { + AUTO = 0, + SINGLE_INSTANCE = 0, + MULTI_INSTANCE = 0, + } + } + + /**************************************************** + * RenderTexture + *****************************************************/ + + export namespace RenderTexture { + /** !#en The depth buffer and stencil buffer format for RenderTexture. + !#zh RenderTexture 的深度缓冲以及模板缓冲格式。 */ + export enum DepthStencilFormat { + RB_FMT_D24S8 = 0, + RB_FMT_S8 = 0, + RB_FMT_D16 = 0, + } + } + + /**************************************************** + * Texture2D + *****************************************************/ + + export namespace Texture2D { + /** The texture pixel format, default value is RGBA8888, + you should note that textures loaded by normal image files (png, jpg) can only support RGBA8888 format, + other formats are supported by compressed file types or raw data. */ + export enum PixelFormat { + RGB565 = 0, + RGB5A1 = 0, + RGBA4444 = 0, + RGB888 = 0, + RGBA8888 = 0, + RGBA32F = 0, + A8 = 0, + I8 = 0, + AI88 = 0, + RGB_PVRTC_2BPPV1 = 0, + RGBA_PVRTC_2BPPV1 = 0, + RGB_A_PVRTC_2BPPV1 = 0, + RGB_PVRTC_4BPPV1 = 0, + RGBA_PVRTC_4BPPV1 = 0, + RGB_A_PVRTC_4BPPV1 = 0, + RGB_ETC1 = 0, + RGBA_ETC1 = 0, + RGB_ETC2 = 0, + RGBA_ETC2 = 0, + } + } + + /**************************************************** + * Texture2D + *****************************************************/ + + export namespace Texture2D { + /** The texture wrap mode */ + export enum WrapMode { + REPEAT = 0, + CLAMP_TO_EDGE = 0, + MIRRORED_REPEAT = 0, + } + } + + /**************************************************** + * Texture2D + *****************************************************/ + + export namespace Texture2D { + /** The texture filter mode */ + export enum Filter { + LINEAR = 0, + NEAREST = 0, + } + } + + /**************************************************** + * Camera + *****************************************************/ + + export namespace Camera { + /** !#en Values for Camera.clearFlags, determining what to clear when rendering a Camera. + !#zh 摄像机清除标记位,决定摄像机渲染时会清除哪些状态 */ + export enum ClearFlags { + COLOR = 0, + DEPTH = 0, + STENCIL = 0, + } + } + + /**************************************************** + * Event + *****************************************************/ + + export namespace Event { + /** !#en The mouse event + !#zh 鼠标事件类型 */ + export class EventMouse extends Event { + /** + !#en Sets scroll data. + !#zh 设置鼠标的滚动数据。 + @param scrollX scrollX + @param scrollY scrollY + */ + setScrollData(scrollX: number, scrollY: number): void; + /** + !#en Returns the x axis scroll value. + !#zh 获取鼠标滚动的X轴距离,只有滚动时才有效。 + */ + getScrollX(): number; + /** + !#en Returns the y axis scroll value. + !#zh 获取滚轮滚动的 Y 轴距离,只有滚动时才有效。 + */ + getScrollY(): number; + /** + !#en Sets cursor location. + !#zh 设置当前鼠标位置。 + @param x x + @param y y + */ + setLocation(x: number, y: number): void; + /** + !#en Returns cursor location. + !#zh 获取鼠标位置对象,对象包含 x 和 y 属性。 + */ + getLocation(): Vec2; + /** + !#en Returns the current cursor location in screen coordinates. + !#zh 获取当前事件在游戏窗口内的坐标位置对象,对象包含 x 和 y 属性。 + */ + getLocationInView(): Vec2; + /** + !#en Returns the previous touch location. + !#zh 获取鼠标点击在上一次事件时的位置对象,对象包含 x 和 y 属性。 + */ + getPreviousLocation(): Vec2; + /** + !#en Returns the delta distance from the previous location to current location. + !#zh 获取鼠标距离上一次事件移动的距离对象,对象包含 x 和 y 属性。 + */ + getDelta(): Vec2; + /** + !#en Returns the X axis delta distance from the previous location to current location. + !#zh 获取鼠标距离上一次事件移动的 X 轴距离。 + */ + getDeltaX(): number; + /** + !#en Returns the Y axis delta distance from the previous location to current location. + !#zh 获取鼠标距离上一次事件移动的 Y 轴距离。 + */ + getDeltaY(): number; + /** + !#en Sets mouse button. + !#zh 设置鼠标按键。 + @param button button + */ + setButton(button: number): void; + /** + !#en Returns mouse button. + !#zh 获取鼠标按键。 + */ + getButton(): number; + /** + !#en Returns location X axis data. + !#zh 获取鼠标当前位置 X 轴。 + */ + getLocationX(): number; + /** + !#en Returns location Y axis data. + !#zh 获取鼠标当前位置 Y 轴。 + */ + getLocationY(): number; + /** !#en The none event code of mouse event. + !#zh 无。 */ + static NONE: number; + /** !#en The event type code of mouse down event. + !#zh 鼠标按下事件。 */ + static DOWN: number; + /** !#en The event type code of mouse up event. + !#zh 鼠标按下后释放事件。 */ + static UP: number; + /** !#en The event type code of mouse move event. + !#zh 鼠标移动事件。 */ + static MOVE: number; + /** !#en The event type code of mouse scroll event. + !#zh 鼠标滚轮事件。 */ + static SCROLL: number; + /** !#en The tag of Mouse left button. + !#zh 鼠标左键的标签。 */ + static BUTTON_LEFT: number; + /** !#en The tag of Mouse right button (The right button number is 2 on browser). + !#zh 鼠标右键的标签。 */ + static BUTTON_RIGHT: number; + /** !#en The tag of Mouse middle button (The right button number is 1 on browser). + !#zh 鼠标中键的标签。 */ + static BUTTON_MIDDLE: number; + /** !#en The tag of Mouse button 4. + !#zh 鼠标按键 4 的标签。 */ + static BUTTON_4: number; + /** !#en The tag of Mouse button 5. + !#zh 鼠标按键 5 的标签。 */ + static BUTTON_5: number; + /** !#en The tag of Mouse button 6. + !#zh 鼠标按键 6 的标签。 */ + static BUTTON_6: number; + /** !#en The tag of Mouse button 7. + !#zh 鼠标按键 7 的标签。 */ + static BUTTON_7: number; + /** !#en The tag of Mouse button 8. + !#zh 鼠标按键 8 的标签。 */ + static BUTTON_8: number; + } + } + + /**************************************************** + * Event + *****************************************************/ + + export namespace Event { + /** !#en The touch event + !#zh 触摸事件 */ + export class EventTouch extends Event { + /** + + @param touchArr The array of the touches + @param bubbles A boolean indicating whether the event bubbles up through the tree or not + */ + constructor(touchArr: any[], bubbles: boolean); + /** !#en The current touch object + !#zh 当前触点对象 */ + touch: Touch; + /** + !#en Returns event code. + !#zh 获取事件类型。 + */ + getEventCode(): number; + /** + !#en Returns touches of event. + !#zh 获取触摸点的列表。 + */ + getTouches(): any[]; + /** + !#en Sets touch location. + !#zh 设置当前触点位置 + @param x x + @param y y + */ + setLocation(x: number, y: number): void; + /** + !#en Returns touch location. + !#zh 获取触点位置。 + */ + getLocation(): Vec2; + /** + !#en Returns the current touch location in screen coordinates. + !#zh 获取当前触点在游戏窗口中的位置。 + */ + getLocationInView(): Vec2; + /** + !#en Returns the previous touch location. + !#zh 获取触点在上一次事件时的位置对象,对象包含 x 和 y 属性。 + */ + getPreviousLocation(): Vec2; + /** + !#en Returns the start touch location. + !#zh 获取触点落下时的位置对象,对象包含 x 和 y 属性。 + */ + getStartLocation(): Vec2; + /** + !#en Returns the id of cc.Touch. + !#zh 触点的标识 ID,可以用来在多点触摸中跟踪触点。 + */ + getID(): number; + /** + !#en Returns the delta distance from the previous location to current location. + !#zh 获取触点距离上一次事件移动的距离对象,对象包含 x 和 y 属性。 + */ + getDelta(): Vec2; + /** + !#en Returns the X axis delta distance from the previous location to current location. + !#zh 获取触点距离上一次事件移动的 x 轴距离。 + */ + getDeltaX(): number; + /** + !#en Returns the Y axis delta distance from the previous location to current location. + !#zh 获取触点距离上一次事件移动的 y 轴距离。 + */ + getDeltaY(): number; + /** + !#en Returns location X axis data. + !#zh 获取当前触点 X 轴位置。 + */ + getLocationX(): number; + /** + !#en Returns location Y axis data. + !#zh 获取当前触点 Y 轴位置。 + */ + getLocationY(): number; + } + } + + /**************************************************** + * Event + *****************************************************/ + + export namespace Event { + /** !#en The acceleration event + !#zh 加速度事件 */ + export class EventAcceleration extends Event { + } + } + + /**************************************************** + * Event + *****************************************************/ + + export namespace Event { + /** !#en The keyboard event + !#zh 键盘事件 */ + export class EventKeyboard extends Event { + /** !#en + The keyCode read-only property represents a system and implementation dependent numerical code identifying the unmodified value of the pressed key. + This is usually the decimal ASCII (RFC 20) or Windows 1252 code corresponding to the key. + If the key can't be identified, this value is 0. + + !#zh + keyCode 是只读属性它表示一个系统和依赖于实现的数字代码,可以识别按键的未修改值。 + 这通常是十进制 ASCII (RFC20) 或者 Windows 1252 代码,所对应的密钥。 + 如果无法识别该键,则该值为 0。 */ + keyCode: number; + } + } + + /**************************************************** + * geomUtils + *****************************************************/ + + export namespace geomUtils { + /** Aabb */ + export class Aabb { + /** + create a new aabb + @param px X coordinates for aabb's original point + @param py Y coordinates for aabb's original point + @param pz Z coordinates for aabb's original point + @param w the half of aabb width + @param h the half of aabb height + @param l the half of aabb length + */ + create(px: number, py: number, pz: number, w: number, h: number, l: number): Aabb; + /** + clone a new aabb + @param a the source aabb + */ + clone(a: Aabb): Aabb; + /** + copy the values from one aabb to another + @param out the receiving aabb + @param a the source aabb + */ + copy(out: Aabb, a: Aabb): Aabb; + /** + create a new aabb from two corner points + @param out the receiving aabb + @param minPos lower corner position of the aabb + @param maxPos upper corner position of the aabb + */ + fromPoints(out: Aabb, minPos: Vec3, maxPos: Vec3): Aabb; + /** + Set the components of a aabb to the given values + @param out the receiving aabb + @param px X coordinates for aabb's original point + @param py Y coordinates for aabb's original point + @param pz Z coordinates for aabb's original point + @param w the half of aabb width + @param h the half of aabb height + @param l the half of aabb length + */ + set(out: Aabb, px: number, py: number, pz: number, w: number, h: number, l: number): Aabb; + center: Vec3; + halfExtents: Vec3; + _type: number; + /** + Get the bounding points of this shape + @param minPos minPos + @param maxPos maxPos + */ + getBoundary(minPos: Vec3, maxPos: Vec3): void; + /** + Transform this shape + @param m the transform matrix + @param pos the position part of the transform + @param rot the rotation part of the transform + @param scale the scale part of the transform + @param out the target shape + */ + transform(m: Mat4, pos: Vec3, rot: Quat, scale: Vec3, out?: Aabb): void; + } + } + + /**************************************************** + * geomUtils + *****************************************************/ + + export namespace geomUtils { + /** !#en Shape type. */ + export enum enums { + SHAPE_RAY = 0, + SHAPE_LINE = 0, + SHAPE_SPHERE = 0, + SHAPE_AABB = 0, + SHAPE_OBB = 0, + SHAPE_PLANE = 0, + SHAPE_TRIANGLE = 0, + SHAPE_FRUSTUM = 0, + SHAPE_FRUSTUM_ACCURATE = 0, + } + } + + /**************************************************** + * geomUtils + *****************************************************/ + + export namespace geomUtils { + /** !#en frustum + !#zh 平截头体 */ + export class Frustum { + /** Set whether to use accurate intersection testing function on this frustum */ + accurate: boolean; + /** + create a new frustum + */ + static create(): Frustum; + /** + Clone a frustum + @param f f + */ + static clone(f: Frustum): Frustum; + /** + Copy the values from one frustum to another + @param out out + @param f f + */ + copy(out: Frustum, f: Frustum): Frustum; + planes: geomUtils.Plane[]; + planes: Vec3[]; + /** + !#en Update the frustum information according to the given transform matrix. + Note that the resulting planes are not normalized under normal mode. + @param m the view-projection matrix + @param inv the inverse view-projection matrix + */ + update(m: Mat4, inv: Mat4): void; + /** + !#en transform by matrix + @param mat mat + */ + transform(mat: Mat4): void; + } + } + + /**************************************************** + * geomUtils + *****************************************************/ + + export namespace geomUtils { + /** undefined */ + export class intersect { + /** + !#en + Check whether ray intersect with nodes + !#zh + 检测射线是否与物体有交集 + @param root If root is null, then traversal nodes from scene node + @param worldRay worldRay + @param handler handler + @param filter filter + */ + static ray_cast(root: Node, worldRay: geomUtils.Ray, handler: Function, filter: Function): any[]; + /** + !#en ray-plane intersect
+ !#zh 射线与平面的相交性检测。 + @param ray ray + @param plane plane + */ + static ray_plane(ray: geomUtils.Ray, plane: geomUtils.Plane): number; + /** + !#en line-plane intersect
+ !#zh 线段与平面的相交性检测。 + @param line line + @param plane plane + */ + static line_plane(line: geomUtils.Line, plane: geomUtils.Plane): number; + /** + !#en ray-triangle intersect
+ !#zh 射线与三角形的相交性检测。 + @param ray ray + @param triangle triangle + @param doubleSided doubleSided + */ + static ray_triangle(ray: geomUtils.Ray, triangle: geomUtils.Triangle, doubleSided: boolean): number; + /** + !#en line-triangle intersect
+ !#zh 线段与三角形的相交性检测。 + @param line line + @param triangle triangle + @param outPt optional, The intersection point + */ + static line_triangle(line: geomUtils.Line, triangle: geomUtils.Triangle, outPt: Vec3): number; + /** + !#en line-quad intersect
+ !#zh 线段与四边形的相交性检测。 + @param p A point on a line segment + @param q Another point on the line segment + @param a Quadrilateral point a + @param b Quadrilateral point b + @param c Quadrilateral point c + @param d Quadrilateral point d + @param outPt optional, The intersection point + */ + static line_quad(p: Vec3, q: Vec3, a: Vec3, b: Vec3, c: Vec3, d: Vec3, outPt: Vec3): number; + /** + !#en ray-sphere intersect
+ !#zh 射线和球的相交性检测。 + @param ray ray + @param sphere sphere + */ + static ray_sphere(ray: geomUtils.Ray, sphere: geomUtils.Sphere): number; + /** + !#en ray-aabb intersect
+ !#zh 射线和轴对齐包围盒的相交性检测。 + @param ray ray + @param aabb Align the axis around the box + */ + static ray_aabb(ray: geomUtils.Ray, aabb: Aabb): number; + /** + !#en ray-obb intersect
+ !#zh 射线和方向包围盒的相交性检测。 + @param ray ray + @param obb Direction box + */ + static ray_obb(ray: geomUtils.Ray, obb: geomUtils.Obb): number; + /** + !#en aabb-aabb intersect
+ !#zh 轴对齐包围盒和轴对齐包围盒的相交性检测。 + @param aabb1 Axis alignment surrounds box 1 + @param aabb2 Axis alignment surrounds box 2 + */ + static aabb_aabb(aabb1: Aabb, aabb2: Aabb): number; + /** + !#en aabb-obb intersect
+ !#zh 轴对齐包围盒和方向包围盒的相交性检测。 + @param aabb Align the axis around the box + @param obb Direction box + */ + static aabb_obb(aabb: Aabb, obb: geomUtils.Obb): number; + /** + !#en aabb-plane intersect
+ !#zh 轴对齐包围盒和平面的相交性检测。 + @param aabb Align the axis around the box + @param plane plane + */ + static aabb_plane(aabb: Aabb, plane: geomUtils.Plane): number; + /** + !#en aabb-frustum intersect, faster but has false positive corner cases
+ !#zh 轴对齐包围盒和锥台相交性检测,速度快,但有错误情况。 + @param aabb Align the axis around the box + @param frustum frustum + */ + static aabb_frustum(aabb: Aabb, frustum: Frustum): number; + /** + !#en aabb-frustum intersect, handles most of the false positives correctly
+ !#zh 轴对齐包围盒和锥台相交性检测,正确处理大多数错误情况。 + @param aabb Align the axis around the box + @param frustum frustum + */ + static aabb_frustum_accurate(aabb: Aabb, frustum: Frustum): number; + /** + !#en obb-point intersect
+ !#zh 方向包围盒和点的相交性检测。 + @param obb Direction box + @param point point + */ + static obb_point(obb: geomUtils.Obb, point: geomUtils.Vec3): boolean; + /** + !#en obb-plane intersect
+ !#zh 方向包围盒和平面的相交性检测。 + @param obb Direction box + @param plane plane + */ + static obb_plane(obb: geomUtils.Obb, plane: geomUtils.Plane): number; + /** + !#en obb-frustum intersect, faster but has false positive corner cases
+ !#zh 方向包围盒和锥台相交性检测,速度快,但有错误情况。 + @param obb Direction box + @param frustum frustum + */ + static obb_frustum(obb: geomUtils.Obb, frustum: Frustum): number; + /** + !#en obb-frustum intersect, handles most of the false positives correctly
+ !#zh 方向包围盒和锥台相交性检测,正确处理大多数错误情况。 + @param obb Direction box + @param frustum frustum + */ + static obb_frustum_accurate(obb: geomUtils.Obb, frustum: Frustum): number; + /** + !#en obb-obb intersect
+ !#zh 方向包围盒和方向包围盒的相交性检测。 + @param obb1 Direction box1 + @param obb2 Direction box2 + */ + static obb_obb(obb1: geomUtils.Obb, obb2: geomUtils.Obb): number; + /** + !#en phere-plane intersect, not necessarily faster than obb-plane
+ due to the length calculation of the plane normal to factor out
+ the unnomalized plane distance
+ !#zh 球与平面的相交性检测。 + @param sphere sphere + @param plane plane + */ + static sphere_plane(sphere: geomUtils.Sphere, plane: geomUtils.Plane): number; + /** + !#en sphere-frustum intersect, faster but has false positive corner cases
+ !#zh 球和锥台的相交性检测,速度快,但有错误情况。 + @param sphere sphere + @param frustum frustum + */ + static sphere_frustum(sphere: geomUtils.Sphere, frustum: Frustum): number; + /** + !#en sphere-frustum intersect, handles the false positives correctly
+ !#zh 球和锥台的相交性检测,正确处理大多数错误情况。 + @param sphere sphere + @param frustum frustum + */ + static sphere_frustum_accurate(sphere: geomUtils.Sphere, frustum: Frustum): number; + /** + !#en sphere-sphere intersect
+ !#zh 球和球的相交性检测。 + @param sphere0 sphere0 + @param sphere1 sphere1 + */ + static sphere_sphere(sphere0: geomUtils.Sphere, sphere1: geomUtils.Sphere): boolean; + /** + !#en sphere-aabb intersect
+ !#zh 球和轴对齐包围盒的相交性检测。 + @param sphere sphere + @param aabb aabb + */ + static sphere_aabb(sphere: geomUtils.Sphere, aabb: Aabb): boolean; + /** + !#en sphere-obb intersect
+ !#zh 球和方向包围盒的相交性检测。 + @param sphere sphere + @param obb obb + */ + static sphere_obb(sphere: geomUtils.Sphere, obb: geomUtils.Obb): boolean; + /** + !#en + The intersection detection of g1 and g2 can fill in the shape in the basic geometry. + !#zh + g1 和 g2 的相交性检测,可填入基础几何中的形状。 + @param g1 Geometry 1 + @param g2 Geometry 2 + @param outPt optional, Intersection point. (note: only partial shape detection with this return value) + */ + static resolve(g1: any, g2: any, outPt: any): void; + } + } + + /**************************************************** + * geomUtils + *****************************************************/ + + export namespace geomUtils { + /** !#en + line + !#zh + 直线 */ + export class Line { + /** + !#en + create a new line + !#zh + 创建一个新的 line。 + @param sx The x part of the starting point. + @param sy The y part of the starting point. + @param sz The z part of the starting point. + @param ex The x part of the end point. + @param ey The y part of the end point. + @param ez The z part of the end point. + */ + create(sx: number, sy: number, sz: number, ex: number, ey: number, ez: number): Line; + /** + !#en + Creates a new line initialized with values from an existing line + !#zh + 克隆一个新的 line。 + @param a The source of cloning. + */ + clone(a: Line): Line; + /** + !#en + Copy the values from one line to another + !#zh + 复制一个线的值到另一个。 + @param out The object that accepts the action. + @param a The source of the copy. + */ + copy(out: Line, a: Line): Line; + /** + !#en + create a line from two points + !#zh + 用两个点创建一个线。 + @param out The object that accepts the action. + @param start The starting point. + @param end At the end. + */ + fromPoints(out: Line, start: Vec3, end: Vec3): Line; + /** + !#en + Set the components of a Vec3 to the given values + !#zh + 将给定线的属性设置为给定值。 + @param out The object that accepts the action. + @param sx The x part of the starting point. + @param sy The y part of the starting point. + @param sz The z part of the starting point. + @param ex The x part of the end point. + @param ey The y part of the end point. + @param ez The z part of the end point. + */ + set(out: Line, sx: number, sy: number, sz: number, ex: number, ey: number, ez: number): Line; + /** + !#en + Calculate the length of the line. + !#zh + 计算线的长度。 + @param a The line to calculate. + */ + len(a: Line): number; + /** !#en + Start points. + !#zh + 起点。 */ + s: Vec3; + /** !#en + End points. + !#zh + 终点。 */ + e: Vec3; + /** + !#en + Calculate the length of the line. + !#zh + 计算线的长度。 + */ + length(): number; + } + } + + /**************************************************** + * geomUtils + *****************************************************/ + + export namespace geomUtils { + /** !#en obb + !#zh + 基础几何 方向包围盒。 */ + export class Obb { + /** !#zh + 获取形状的类型。 */ + type: number; + /** + !#en + create a new obb + !#zh + 创建一个新的 obb 实例。 + @param cx X coordinates of the shape relative to the origin. + @param cy Y coordinates of the shape relative to the origin. + @param cz Z coordinates of the shape relative to the origin. + @param hw Obb is half the width. + @param hh Obb is half the height. + @param hl Obb is half the Length. + @param ox_1 Direction matrix parameter. + @param ox_2 Direction matrix parameter. + @param ox_3 Direction matrix parameter. + @param oy_1 Direction matrix parameter. + @param oy_2 Direction matrix parameter. + @param oy_3 Direction matrix parameter. + @param oz_1 Direction matrix parameter. + @param oz_2 Direction matrix parameter. + @param oz_3 Direction matrix parameter. + */ + create(cx: number, cy: number, cz: number, hw: number, hh: number, hl: number, ox_1: number, ox_2: number, ox_3: number, oy_1: number, oy_2: number, oy_3: number, oz_1: number, oz_2: number, oz_3: number): Obb; + /** + !#en + clone a new obb + !#zh + 克隆一个 obb。 + @param a The target of cloning. + */ + clone(a: Obb): Obb; + /** + !#en + copy the values from one obb to another + !#zh + 将从一个 obb 的值复制到另一个 obb。 + @param out Obb that accepts the operation. + @param a Obb being copied. + */ + copy(out: Obb, a: Obb): Obb; + /** + !#en + create a new obb from two corner points + !#zh + 用两个点创建一个新的 obb。 + @param out Obb that accepts the operation. + @param minPos The smallest point of obb. + @param maxPos Obb's maximum point. + */ + fromPoints(out: Obb, minPos: Vec3, maxPos: Vec3): Obb; + /** + !#en + Set the components of a obb to the given values + !#zh + 将给定 obb 的属性设置为给定的值。 + @param cx X coordinates of the shape relative to the origin. + @param cy Y coordinates of the shape relative to the origin. + @param cz Z coordinates of the shape relative to the origin. + @param hw Obb is half the width. + @param hh Obb is half the height. + @param hl Obb is half the Length. + @param ox_1 Direction matrix parameter. + @param ox_2 Direction matrix parameter. + @param ox_3 Direction matrix parameter. + @param oy_1 Direction matrix parameter. + @param oy_2 Direction matrix parameter. + @param oy_3 Direction matrix parameter. + @param oz_1 Direction matrix parameter. + @param oz_2 Direction matrix parameter. + @param oz_3 Direction matrix parameter. + */ + set(cx: number, cy: number, cz: number, hw: number, hh: number, hl: number, ox_1: number, ox_2: number, ox_3: number, oy_1: number, oy_2: number, oy_3: number, oz_1: number, oz_2: number, oz_3: number): Obb; + /** !#en + The center of the local coordinate. + !#zh + 本地坐标的中心点。 */ + center: Vec3; + /** !#en + Half the length, width, and height. + !#zh + 长宽高的一半。 */ + halfExtents: Vec3; + /** !#en + Direction matrix. + !#zh + 方向矩阵。 */ + orientation: Mat3; + /** + !#en + Get the bounding points of this shape + !#zh + 获取 obb 的最小点和最大点。 + @param minPos minPos + @param maxPos maxPos + */ + getBoundary(minPos: Vec3, maxPos: Vec3): void; + /** + !#en Transform this shape + !#zh + 将 out 根据这个 obb 的数据进行变换。 + @param m The transformation matrix. + @param pos The position part of the transformation. + @param rot The rotating part of the transformation. + @param scale The scaling part of the transformation. + @param out Target of transformation. + */ + transform(m: Mat4, pos: Vec3, rot: Quat, scale: Vec3, out: Obb): void; + /** + !#en + Transform out based on this obb data. + !#zh + 将 out 根据这个 obb 的数据进行变换。 + @param m The transformation matrix. + @param rot The rotating part of the transformation. + @param out Target of transformation. + */ + translateAndRotate(m: Mat4, rot: Quat, out: Obb): void; + /** + !#en + Scale out based on this obb data. + !#zh + 将 out 根据这个 obb 的数据进行缩放。 + @param scale Scale value. + @param out Scaled target. + */ + setScale(scale: Vec3, out: Obb): void; + } + } + + /**************************************************** + * geomUtils + *****************************************************/ + + export namespace geomUtils { + /** !#en + plane。 + !#zh + 平面。 */ + export class Plane { + /** + !#en + create a new plane + !#zh + 创建一个新的 plane。 + @param nx The x part of the normal component. + @param ny The y part of the normal component. + @param nz The z part of the normal component. + @param d Distance from the origin. + */ + create(nx: number, ny: number, nz: number, d: number): Plane; + /** + !#en + clone a new plane + !#zh + 克隆一个新的 plane。 + @param p The source of cloning. + */ + clone(p: Plane): Plane; + /** + !#en + copy the values from one plane to another + !#zh + 复制一个平面的值到另一个。 + @param out The object that accepts the action. + @param p The source of the copy. + */ + copy(out: Plane, p: Plane): Plane; + /** + !#en + create a plane from three points + !#zh + 用三个点创建一个平面。 + @param out The object that accepts the action. + @param a Point a。 + @param b Point b。 + @param c Point c。 + */ + fromPoints(out: Plane, a: Vec3, b: Vec3, c: Vec3): Plane; + /** + !#en + Set the components of a plane to the given values + !#zh + 将给定平面的属性设置为给定值。 + @param out The object that accepts the action. + @param nx The x part of the normal component. + @param ny The y part of the normal component. + @param nz The z part of the normal component. + @param d Distance from the origin. + */ + set(out: Plane, nx: number, ny: number, nz: number, d: number): Plane; + /** + !#en + create plane from normal and point + !#zh + 用一条法线和一个点创建平面。 + @param out The object that accepts the action. + @param normal The normal of a plane. + @param point A point on the plane. + */ + fromNormalAndPoint(out: Plane, normal: Vec3, point: Vec3): Plane; + /** + !#en + normalize a plane + !#zh + 归一化一个平面。 + @param out The object that accepts the action. + @param a Source data for operations. + */ + normalize(out: Plane, a: Plane): Plane; + /** !#en + A normal vector. + !#zh + 法线向量。 */ + n: Vec3; + /** !#en + The distance from the origin to the plane. + !#zh + 原点到平面的距离。 */ + d: number; + /** + !#en + Transform a plane. + !#zh + 变换一个平面。 + @param mat mat + */ + transform(mat: Mat4): void; + } + } + + /**************************************************** + * geomUtils + *****************************************************/ + + export namespace geomUtils { + /** !#en + ray + !#zh + 射线。 */ + export class Ray { + /** + !#en + create a new ray + !#zh + 创建一条射线。 + @param ox The x part of the starting point. + @param oy The y part of the starting point. + @param oz The z part of the starting point. + @param dx X in the direction. + @param dy Y in the direction. + @param dz Z in the direction. + */ + create(ox: number, oy: number, oz: number, dx: number, dy: number, dz: number): Ray; + /** + !#en + Creates a new ray initialized with values from an existing ray + !#zh + 从一条射线克隆出一条新的射线。 + @param a Clone target + */ + clone(a: Ray): Ray; + /** + !#en + Copy the values from one ray to another + !#zh + 将从一个 ray 的值复制到另一个 ray。 + @param out Accept the ray of the operation. + @param a Copied ray. + */ + copy(out: Ray, a: Ray): Ray; + /** + !#en + create a ray from two points + !#zh + 用两个点创建一条射线。 + @param out Receive the operating ray. + @param origin Origin of ray + @param target A point on a ray. + */ + fromPoints(out: Ray, origin: Vec3, target: Vec3): Ray; + /** + !#en + Set the components of a ray to the given values + !#zh + 将给定射线的属性设置为给定的值。 + @param out Receive the operating ray. + @param ox The x part of the starting point. + @param oy The y part of the starting point. + @param oz The z part of the starting point. + @param dx X in the direction. + @param dy Y in the direction. + @param dz Z in the direction. + */ + set(out: Ray, ox: number, oy: number, oz: number, dx: number, dy: number, dz: number): Ray; + /** !#en + Start point. + !#zh + 起点。 */ + o: Vec3; + /** !#e + Direction + !#zh + 方向。 */ + d: Vec3; + /** + !#en Compute hit. + @param out out + @param distance distance + */ + computeHit(out: IVec3Like, distance: number): void; + } + } + + /**************************************************** + * geomUtils + *****************************************************/ + + export namespace geomUtils { + /** !#en + Sphere. + !#zh + 轴对齐球。 */ + export class Sphere { + /** + !#en + create a new sphere + !#zh + 创建一个新的 sphere 实例。 + @param cx X coordinates of the shape relative to the origin. + @param cy Y coordinates of the shape relative to the origin. + @param cz Z coordinates of the shape relative to the origin. + @param r Radius of sphere + */ + create(cx: any, cy: any, cz: any, r: any): Sphere; + /** + !#en + clone a new sphere + !#zh + 克隆一个新的 sphere 实例。 + @param p The target of cloning. + */ + clone(p: Sphere): Sphere; + /** + !#en + copy the values from one sphere to another + !#zh + 将从一个 sphere 的值复制到另一个 sphere。 + @param out Accept the sphere of operations. + @param a Sphere being copied. + */ + copy(out: Sphere, a: Sphere): Sphere; + /** + !#en + create a new bounding sphere from two corner points + !#zh + 从两个点创建一个新的 sphere。 + @param out Accept the sphere of operations. + @param minPos The smallest point of sphere. + @param maxPos The maximum point of sphere. + */ + fromPoints(out: any, minPos: any, maxPos: any): Sphere; + /** + !#en Set the components of a sphere to the given values + !#zh 将球体的属性设置为给定的值。 + @param out Accept the sphere of operations. + @param cx X coordinates of the shape relative to the origin. + @param cy Y coordinates of the shape relative to the origin. + @param cz Z coordinates of the shape relative to the origin. + @param r Radius. + */ + set(out: Sphere, cx: any, cy: any, cz: any, r: number): Sphere; + /** !#en + The center of the local coordinate. + !#zh + 本地坐标的中心点。 */ + center: Vec3; + /** !#zh + 半径。 */ + radius: number; + /** + !#en + Clone. + !#zh + 获得克隆。 + */ + clone(): void; + /** + !#en + Copy sphere + !#zh + 拷贝对象。 + @param a Copy target. + */ + copy(a: any): void; + /** + !#en + Get the bounding points of this shape + !#zh + 获取此形状的边界点。 + @param minPos minPos + @param maxPos maxPos + */ + getBoundary(minPos: Vec3, maxPos: Vec3): void; + /** + !#en + Transform this shape + !#zh + 将 out 根据这个 sphere 的数据进行变换。 + @param m The transformation matrix. + @param pos The position part of the transformation. + @param rot The rotating part of the transformation. + @param scale The scaling part of the transformation. + @param out The target of the transformation. + */ + transform(m: any, pos: any, rot: any, scale: any, out: any): void; + /** + !#en + Scale out based on the sphere data. + !#zh + 将 out 根据这个 sphere 的数据进行缩放。 + @param scale Scale value + @param out Scale target + */ + setScale(scale: any, out: any): void; + } + } + + /**************************************************** + * geomUtils + *****************************************************/ + + export namespace geomUtils { + /** Triangle */ + export class Triangle { + /** + create a new triangle + @param ax ax + @param ay ay + @param az az + @param bx bx + @param by by + @param bz bz + @param cx cx + @param cy cy + @param cz cz + */ + create(ax: number, ay: number, az: number, bx: number, by: number, bz: number, cx: number, cy: number, cz: number): Triangle; + /** + clone a new triangle + @param t the source plane + */ + clone(t: Triangle): Triangle; + /** + copy the values from one triangle to another + @param out the receiving triangle + @param t the source triangle + */ + copy(out: Triangle, t: Triangle): Triangle; + /** + Create a triangle from three points + @param out the receiving triangle + @param a a + @param b b + @param c c + */ + fromPoints(out: Triangle, a: Vec3, b: Vec3, c: Vec3): Triangle; + /** + Set the components of a triangle to the given values + @param out the receiving plane + @param ax X component of a + @param ay Y component of a + @param az Z component of a + @param bx X component of b + @param by Y component of b + @param bz Z component of b + @param cx X component of c + @param cy Y component of c + @param cz Z component of c + */ + set(out: Triangle, ax: number, ay: number, az: number, bx: number, by: number, bz: number, cx: number, cy: number, cz: number): Plane; + a: Vec3; + b: Vec3; + c: Vec3; + } + } + + /**************************************************** + * MeshRenderer + *****************************************************/ + + export namespace MeshRenderer { + /** !#en Shadow projection mode + + !#ch 阴影投射方式 */ + export enum ShadowCastingMode { + OFF = 0, + ON = 0, + } + } + + /**************************************************** + * Animation + *****************************************************/ + + export namespace Animation { + /** !#en The event type supported by Animation + !#zh Animation 支持的事件类型 */ + export class EventType { + /** !#en Emit when begin playing animation + !#zh 开始播放时触发 */ + static PLAY: string; + /** !#en Emit when stop playing animation + !#zh 停止播放时触发 */ + static STOP: string; + /** !#en Emit when pause animation + !#zh 暂停播放时触发 */ + static PAUSE: string; + /** !#en Emit when resume animation + !#zh 恢复播放时触发 */ + static RESUME: string; + /** !#en If animation repeat count is larger than 1, emit when animation play to the last frame + !#zh 假如动画循环次数大于 1,当动画播放到最后一帧时触发 */ + static LASTFRAME: string; + /** !#en Emit when finish playing animation + !#zh 动画播放完成时触发 */ + static FINISHED: string; + } + } + + /**************************************************** + * Button + *****************************************************/ + + export namespace Button { + /** !#en Enum for transition type. + !#zh 过渡类型 */ + export enum Transition { + NONE = 0, + COLOR = 0, + SPRITE = 0, + SCALE = 0, + } + } + + /**************************************************** + * Component + *****************************************************/ + + export namespace Component { + /** !#en + Component will register a event to target component's handler. + And it will trigger the handler when a certain event occurs. + + !@zh + “EventHandler” 类用来设置场景中的事件回调, + 该类允许用户设置回调目标节点,目标组件名,组件方法名, + 并可通过 emit 方法调用目标函数。 */ + export class EventHandler { + /** !#en the node that contains target callback, such as the node example script belongs to + !#zh 事件响应函数所在节点 ,比如例子中脚本归属的节点本身 */ + target: Node; + /** !#en name of the component(script) that contains target callback, such as the name 'MainMenu' of script in example + !#zh 事件响应函数所在组件名(脚本名), 比如例子中的脚本名 'MainMenu' */ + component: string; + /** !#en Event handler, such as function's name 'onClick' in example + !#zh 响应事件函数名,比如例子中的 'onClick' */ + handler: string; + /** !#en Custom Event Data, such as 'eventType' in example + !#zh 自定义事件数据,比如例子中的 eventType */ + customEventData: string; + /** + + @param events events + @param params params + */ + static emitEvents(events: EventHandler[], ...params: any[]): void; + /** + !#en Emit event with params + !#zh 触发目标组件上的指定 handler 函数,该参数是回调函数的参数值(可不填)。 + @param params params + + @example + ```js + // Call Function + var eventHandler = new cc.Component.EventHandler(); + eventHandler.target = newTarget; + eventHandler.component = "MainMenu"; + eventHandler.handler = "OnClick" + eventHandler.emit(["param1", "param2", ....]); + ``` + */ + emit(params: any[]): void; + } + } + + /**************************************************** + * Label + *****************************************************/ + + export namespace Label { + /** !#en Enum for text alignment. + !#zh 文本横向对齐类型 */ + export enum HorizontalAlign { + LEFT = 0, + CENTER = 0, + RIGHT = 0, + } + } + + /**************************************************** + * Label + *****************************************************/ + + export namespace Label { + /** !#en Enum for vertical text alignment. + !#zh 文本垂直对齐类型 */ + export enum VerticalAlign { + TOP = 0, + CENTER = 0, + BOTTOM = 0, + } + } + + /**************************************************** + * Label + *****************************************************/ + + export namespace Label { + /** !#en Enum for Overflow. + !#zh Overflow 类型 */ + export enum Overflow { + NONE = 0, + CLAMP = 0, + SHRINK = 0, + RESIZE_HEIGHT = 0, + } + } + + /**************************************************** + * Label + *****************************************************/ + + export namespace Label { + /** !#en Enum for font type. + !#zh Type 类型 */ + export enum Type { + TTF = 0, + BMFont = 0, + SystemFont = 0, + } + } + + /**************************************************** + * Label + *****************************************************/ + + export namespace Label { + /** !#en Enum for cache mode. + !#zh CacheMode 类型 */ + export enum CacheMode { + NONE = 0, + BITMAP = 0, + CHAR = 0, + } + } + + /**************************************************** + * Layout + *****************************************************/ + + export namespace Layout { + /** !#en Enum for Layout type + !#zh 布局类型 */ + export enum Type { + NONE = 0, + HORIZONTAL = 0, + VERTICAL = 0, + GRID = 0, + } + } + + /**************************************************** + * Layout + *****************************************************/ + + export namespace Layout { + /** !#en Enum for Layout Resize Mode + !#zh 缩放模式 */ + export enum ResizeMode { + NONE = 0, + CONTAINER = 0, + CHILDREN = 0, + } + } + + /**************************************************** + * Layout + *****************************************************/ + + export namespace Layout { + /** !#en Enum for Grid Layout start axis direction. + The items in grid layout will be arranged in each axis at first.; + !#zh 布局轴向,只用于 GRID 布局。 */ + export enum AxisDirection { + HORIZONTAL = 0, + VERTICAL = 0, + } + } + + /**************************************************** + * Layout + *****************************************************/ + + export namespace Layout { + /** !#en Enum for vertical layout direction. + Used in Grid Layout together with AxisDirection is VERTICAL + !#zh 垂直方向布局方式 */ + export enum VerticalDirection { + BOTTOM_TO_TOP = 0, + TOP_TO_BOTTOM = 0, + } + } + + /**************************************************** + * Layout + *****************************************************/ + + export namespace Layout { + /** !#en Enum for horizontal layout direction. + Used in Grid Layout together with AxisDirection is HORIZONTAL + !#zh 水平方向布局方式 */ + export enum HorizontalDirection { + LEFT_TO_RIGHT = 0, + RIGHT_TO_LEFT = 0, + } + } + + /**************************************************** + * Mask + *****************************************************/ + + export namespace Mask { + /** !#en the type for mask. + !#zh 遮罩组件类型 */ + export enum Type { + RECT = 0, + ELLIPSE = 0, + IMAGE_STENCIL = 0, + } + } + + /**************************************************** + * PageView + *****************************************************/ + + export namespace PageView { + /** !#en The Page View Size Mode + !#zh 页面视图每个页面统一的大小类型 */ + export enum SizeMode { + Unified = 0, + Free = 0, + } + } + + /**************************************************** + * PageView + *****************************************************/ + + export namespace PageView { + /** !#en The Page View Direction + !#zh 页面视图滚动类型 */ + export enum Direction { + Horizontal = 0, + Vertical = 0, + } + } + + /**************************************************** + * PageView + *****************************************************/ + + export namespace PageView { + /** !#en Enum for ScrollView event type. + !#zh 滚动视图事件类型 */ + export enum EventType { + PAGE_TURNING = 0, + } + } + + /**************************************************** + * PageViewIndicator + *****************************************************/ + + export namespace PageViewIndicator { + /** !#en Enum for PageView Indicator direction + !#zh 页面视图指示器的摆放方向 */ + export enum Direction { + HORIZONTAL = 0, + VERTICAL = 0, + } + } + + /**************************************************** + * ProgressBar + *****************************************************/ + + export namespace ProgressBar { + /** !#en Enum for ProgressBar mode + !#zh 进度条模式 */ + export enum Mode { + HORIZONTAL = 0, + VERTICAL = 0, + FILLED = 0, + } + } + + /**************************************************** + * Scrollbar + *****************************************************/ + + export namespace Scrollbar { + /** Enum for Scrollbar direction */ + export enum Direction { + HORIZONTAL = 0, + VERTICAL = 0, + } + } + + /**************************************************** + * ScrollView + *****************************************************/ + + export namespace ScrollView { + /** !#en Enum for ScrollView event type. + !#zh 滚动视图事件类型 */ + export enum EventType { + SCROLL_TO_TOP = 0, + SCROLL_TO_BOTTOM = 0, + SCROLL_TO_LEFT = 0, + SCROLL_TO_RIGHT = 0, + SCROLLING = 0, + BOUNCE_TOP = 0, + BOUNCE_BOTTOM = 0, + BOUNCE_LEFT = 0, + BOUNCE_RIGHT = 0, + SCROLL_ENDED = 0, + TOUCH_UP = 0, + AUTOSCROLL_ENDED_WITH_THRESHOLD = 0, + SCROLL_BEGAN = 0, + } + } + + /**************************************************** + * Slider + *****************************************************/ + + export namespace Slider { + /** !#en The Slider Direction + !#zh 滑动器方向 */ + export enum Direction { + Horizontal = 0, + Vertical = 0, + } + } + + /**************************************************** + * Sprite + *****************************************************/ + + export namespace Sprite { + /** !#en Enum for sprite type. + !#zh Sprite 类型 */ + export enum Type { + SIMPLE = 0, + SLICED = 0, + TILED = 0, + FILLED = 0, + MESH = 0, + } + } + + /**************************************************** + * Sprite + *****************************************************/ + + export namespace Sprite { + /** !#en Enum for fill type. + !#zh 填充类型 */ + export enum FillType { + HORIZONTAL = 0, + VERTICAL = 0, + RADIAL = 0, + } + } + + /**************************************************** + * Sprite + *****************************************************/ + + export namespace Sprite { + /** !#en Sprite Size can track trimmed size, raw size or none. + !#zh 精灵尺寸调整模式 */ + export enum SizeMode { + CUSTOM = 0, + TRIMMED = 0, + RAW = 0, + } + } + + /**************************************************** + * Sprite + *****************************************************/ + + export namespace Sprite { + /** !#en Sprite state can choice the normal or grayscale. + !#zh 精灵颜色通道模式。 */ + export enum State { + NORMAL = 0, + GRAY = 0, + } + } + + /**************************************************** + * Widget + *****************************************************/ + + export namespace Widget { + /** !#en Enum for Widget's alignment mode, indicating when the widget should refresh. + !#zh Widget 的对齐模式,表示 Widget 应该何时刷新。 */ + export enum AlignMode { + ONCE = 0, + ON_WINDOW_RESIZE = 0, + ALWAYS = 0, + } + } + + /**************************************************** + * Event + *****************************************************/ + + export namespace Event { + /** !#en The Custom event + !#zh 自定义事件 */ + export class EventCustom extends Event { + /** + + @param type The name of the event (case-sensitive), e.g. "click", "fire", or "submit" + @param bubbles A boolean indicating whether the event bubbles up through the tree or not + */ + constructor(type: string, bubbles: boolean); + /** !#en A reference to the detailed data of the event + !#zh 事件的详细数据 */ + detail: any; + /** + !#en Sets user data + !#zh 设置用户数据 + @param data data + */ + setUserData(data: any): void; + /** + !#en Gets user data + !#zh 获取用户数据 + */ + getUserData(): any; + /** + !#en Gets event name + !#zh 获取事件名称 + */ + getEventName(): string; + } + } + + /**************************************************** + * SystemEvent + *****************************************************/ + + export namespace SystemEvent { + /** !#en The event type supported by SystemEvent + !#zh SystemEvent 支持的事件类型 */ + export class EventType { + /** !#en The event type for press the key down event, you can use its value directly: 'keydown' + !#zh 当按下按键时触发的事件 */ + static KEY_DOWN: string; + /** !#en The event type for press the key up event, you can use its value directly: 'keyup' + !#zh 当松开按键时触发的事件 */ + static KEY_UP: string; + /** !#en The event type for press the devicemotion event, you can use its value directly: 'devicemotion' + !#zh 重力感应 */ + static DEVICEMOTION: string; + } + } + + /**************************************************** + * PhysicsManager + *****************************************************/ + + export namespace PhysicsManager { + /** !#en + The draw bits for drawing physics debug information.
+ example:
+ ```js + cc.director.getPhysicsManager().debugDrawFlags = + // cc.PhysicsManager.DrawBits.e_aabbBit | + // cc.PhysicsManager.DrawBits.e_pairBit | + // cc.PhysicsManager.DrawBits.e_centerOfMassBit | + cc.PhysicsManager.DrawBits.e_jointBit | + cc.PhysicsManager.DrawBits.e_shapeBit; + ``` + !#zh + 指定物理系统需要绘制哪些调试信息。
+ example:
+ ```js + cc.director.getPhysicsManager().debugDrawFlags = + // cc.PhysicsManager.DrawBits.e_aabbBit | + // cc.PhysicsManager.DrawBits.e_pairBit | + // cc.PhysicsManager.DrawBits.e_centerOfMassBit | + cc.PhysicsManager.DrawBits.e_jointBit | + cc.PhysicsManager.DrawBits.e_shapeBit; + ``` */ + export enum DrawBits { + e_aabbBit = 0, + e_jointBit = 0, + e_shapeBit = 0, + } + } + + /**************************************************** + * Graphics + *****************************************************/ + + export namespace Graphics { + /** !#en Enum for LineCap. + !#zh 线段末端属性 */ + export enum LineCap { + BUTT = 0, + ROUND = 0, + SQUARE = 0, + } + } + + /**************************************************** + * Graphics + *****************************************************/ + + export namespace Graphics { + /** !#en Enum for LineJoin. + !#zh 线段拐角属性 */ + export enum LineJoin { + BEVEL = 0, + ROUND = 0, + MITER = 0, + } + } + + /**************************************************** + * macro + *****************************************************/ + + export namespace macro { + /** !#en Key map for keyboard event + !#zh 键盘事件的按键值 */ + export enum KEY { + none = 0, + back = 0, + menu = 0, + backspace = 0, + tab = 0, + enter = 0, + shift = 0, + ctrl = 0, + alt = 0, + pause = 0, + capslock = 0, + escape = 0, + space = 0, + pageup = 0, + pagedown = 0, + end = 0, + home = 0, + left = 0, + up = 0, + right = 0, + down = 0, + select = 0, + insert = 0, + Delete = 0, + a = 0, + b = 0, + c = 0, + d = 0, + e = 0, + f = 0, + g = 0, + h = 0, + i = 0, + j = 0, + k = 0, + l = 0, + m = 0, + n = 0, + o = 0, + p = 0, + q = 0, + r = 0, + s = 0, + t = 0, + u = 0, + v = 0, + w = 0, + x = 0, + y = 0, + z = 0, + num0 = 0, + num1 = 0, + num2 = 0, + num3 = 0, + num4 = 0, + num5 = 0, + num6 = 0, + num7 = 0, + num8 = 0, + num9 = 0, + '*' = 0, + '+' = 0, + '-' = 0, + numdel = 0, + '/' = 0, + f1 = 0, + f2 = 0, + f3 = 0, + f4 = 0, + f5 = 0, + f6 = 0, + f7 = 0, + f8 = 0, + f9 = 0, + f10 = 0, + f11 = 0, + f12 = 0, + numlock = 0, + scrolllock = 0, + ';' = 0, + semicolon = 0, + equal = 0, + '=' = 0, + ',' = 0, + comma = 0, + dash = 0, + '.' = 0, + period = 0, + forwardslash = 0, + grave = 0, + '[' = 0, + openbracket = 0, + backslash = 0, + ']' = 0, + closebracket = 0, + quote = 0, + dpadLeft = 0, + dpadRight = 0, + dpadUp = 0, + dpadDown = 0, + dpadCenter = 0, + } + } + + /**************************************************** + * macro + *****************************************************/ + + export namespace macro { + /** Image formats */ + export enum ImageFormat { + JPG = 0, + PNG = 0, + TIFF = 0, + WEBP = 0, + PVR = 0, + ETC = 0, + S3TC = 0, + ATITC = 0, + TGA = 0, + RAWDATA = 0, + UNKNOWN = 0, + } + } + + /**************************************************** + * macro + *****************************************************/ + + export namespace macro { + /** !#en + Enum for blend factor + Refer to: http://www.andersriggelsen.dk/glblendfunc.php + !#zh + 混合因子 + 可参考: http://www.andersriggelsen.dk/glblendfunc.php */ + export enum BlendFactor { + ONE = 0, + ZERO = 0, + SRC_ALPHA = 0, + SRC_COLOR = 0, + DST_ALPHA = 0, + DST_COLOR = 0, + ONE_MINUS_SRC_ALPHA = 0, + ONE_MINUS_SRC_COLOR = 0, + ONE_MINUS_DST_ALPHA = 0, + ONE_MINUS_DST_COLOR = 0, + } + } + + /**************************************************** + * macro + *****************************************************/ + + export namespace macro { + /** undefined */ + export enum TextAlignment { + LEFT = 0, + CENTER = 0, + RIGHT = 0, + } + } + + /**************************************************** + * sys + *****************************************************/ + + export namespace sys { + /** !#en + Network type enumeration + !#zh + 网络类型枚举 */ + export enum NetworkType { + NONE = 0, + LAN = 0, + WWAN = 0, + } + } + + /**************************************************** + * ParticleSystem3DAssembler + *****************************************************/ + + export namespace ParticleSystem3DAssembler { + /** undefined */ + export enum Space { + } + } + + /**************************************************** + * ParticleSystem3DAssembler + *****************************************************/ + + export namespace ParticleSystem3DAssembler { + /** 粒子的生成模式 */ + export enum RenderMode { + } + } + + /**************************************************** + * shapeModule + *****************************************************/ + + export namespace shapeModule { + /** 粒子发射器类型 */ + export enum ShapeType { + Box = 0, + Circle = 0, + Cone = 0, + Sphere = 0, + Hemisphere = 0, + } + } + + /**************************************************** + * shapeModule + *****************************************************/ + + export namespace shapeModule { + /** 粒子从发射器的哪个部位发射 */ + export enum EmitLocation { + Base = 0, + Edge = 0, + Shell = 0, + Volume = 0, + } + } + + /**************************************************** + * shapeModule + *****************************************************/ + + export namespace shapeModule { + /** 粒子在扇形区域的发射方式 */ + export enum ArcMode { + Random = 0, + Loop = 0, + PingPong = 0, + } + } + + /**************************************************** + * trailModule + *****************************************************/ + + export namespace trailModule { + /** 选择如何为粒子系统生成轨迹 */ + export enum TrailMode { + } + } + + /**************************************************** + * trailModule + *****************************************************/ + + export namespace trailModule { + /** 纹理填充模式 */ + export enum TextureMode { + } + } + + /**************************************************** + * primitive + *****************************************************/ + + export namespace primitive { + /** undefined */ + export enum PolyhedronType { + Tetrahedron = 0, + Octahedron = 0, + Dodecahedron = 0, + Icosahedron = 0, + Rhombicuboctahedron = 0, + TriangularPrism = 0, + PentagonalPrism = 0, + HexagonalPrism = 0, + SquarePyramid = 0, + PentagonalPyramid = 0, + TriangularDipyramid = 0, + PentagonalDipyramid = 0, + ElongatedSquareDipyramid = 0, + ElongatedPentagonalDipyramid = 0, + ElongatedPentagonalCupola = 0, + } + } + + /**************************************************** + * primitive + *****************************************************/ + + export namespace primitive { + /** undefined */ + export class VertexData { + positions: number[]; + normals: number[]; + uvs: number[]; + indices: number[]; + minPos: Vec3; + maxPos: Vec3; + boundingRadius: number; + } + } + + /**************************************************** + * Material + *****************************************************/ + + export namespace Material { + /** !#en Material builtin name + !#zh 内置材质名字 */ + export enum BUILTIN_NAME { + SPRITE = 0, + GRAY_SPRITE = 0, + UNLIT = 0, + } + } + + /**************************************************** + * EditBox + *****************************************************/ + + export namespace EditBox { + /** !#en Enum for keyboard return types + !#zh 键盘的返回键类型 */ + export enum KeyboardReturnType { + DEFAULT = 0, + DONE = 0, + SEND = 0, + SEARCH = 0, + GO = 0, + NEXT = 0, + } + } + + /**************************************************** + * EditBox + *****************************************************/ + + export namespace EditBox { + /** !#en The EditBox's InputMode defines the type of text that the user is allowed to enter. + !#zh 输入模式 */ + export enum InputMode { + ANY = 0, + EMAIL_ADDR = 0, + NUMERIC = 0, + PHONE_NUMBER = 0, + URL = 0, + DECIMAL = 0, + SINGLE_LINE = 0, + } + } + + /**************************************************** + * EditBox + *****************************************************/ + + export namespace EditBox { + /** !#en Enum for the EditBox's input flags + !#zh 定义了一些用于设置文本显示和文本格式化的标志位。 */ + export enum InputFlag { + PASSWORD = 0, + SENSITIVE = 0, + INITIAL_CAPS_WORD = 0, + INITIAL_CAPS_SENTENCE = 0, + INITIAL_CAPS_ALL_CHARACTERS = 0, + DEFAULT = 0, + } + } + + /**************************************************** + * textureAnimationModule + *****************************************************/ + + export namespace textureAnimationModule { + /** 粒子贴图动画类型 */ + export enum Mode { + } + } + + /**************************************************** + * textureAnimationModule + *****************************************************/ + + export namespace textureAnimationModule { + /** 贴图动画的播放方式 */ + export enum Animation { + } + } + +} + +/** !#en +The global main namespace of Spine, all classes, functions, +properties and constants of Spine are defined in this namespace +!#zh +Spine 的全局的命名空间, +与 Spine 相关的所有的类,函数,属性,常量都在这个命名空间中定义。 */ +declare namespace sp { + /** !#en The event type of spine skeleton animation. + !#zh 骨骼动画事件类型。 */ + export enum AnimationEventType { + START = 0, + END = 0, + COMPLETE = 0, + EVENT = 0, + } + /** !#en + The skeleton of Spine
+
+ (Skeleton has a reference to a SkeletonData and stores the state for skeleton instance, + which consists of the current pose's bone SRT, slot colors, and which slot attachments are visible.
+ Multiple skeletons can use the same SkeletonData which includes all animations, skins, and attachments.)
+ !#zh + Spine 骨骼动画
+
+ (Skeleton 具有对骨骼数据的引用并且存储了骨骼实例的状态, + 它由当前的骨骼动作,slot 颜色,和可见的 slot attachments 组成。
+ 多个 Skeleton 可以使用相同的骨骼数据,其中包括所有的动画,皮肤和 attachments。 */ + export class Skeleton extends cc.RenderComponent { + /** !#en The skeletal animation is paused? + !#zh 该骨骼动画是否暂停。 */ + paused: boolean; + /** !#en + The skeleton data contains the skeleton information (bind pose bones, slots, draw order, + attachments, skins, etc) and animations but does not hold any state.
+ Multiple skeletons can share the same skeleton data. + !#zh + 骨骼数据包含了骨骼信息(绑定骨骼动作,slots,渲染顺序, + attachments,皮肤等等)和动画但不持有任何状态。
+ 多个 Skeleton 可以共用相同的骨骼数据。 */ + skeletonData: SkeletonData; + /** !#en The name of default skin. + !#zh 默认的皮肤名称。 */ + defaultSkin: string; + /** !#en The name of default animation. + !#zh 默认的动画名称。 */ + defaultAnimation: string; + /** !#en The name of current playing animation. + !#zh 当前播放的动画名称。 */ + animation: string; + _defaultSkinIndex: number; + /** !#en TODO + !#zh 是否循环播放当前骨骼动画。 */ + loop: boolean; + /** !#en Indicates whether to enable premultiplied alpha. + You should disable this option when image's transparent area appears to have opaque pixels, + or enable this option when image's half transparent area appears to be darken. + !#zh 是否启用贴图预乘。 + 当图片的透明区域出现色块时需要关闭该选项,当图片的半透明区域颜色变黑时需要启用该选项。 */ + premultipliedAlpha: boolean; + /** !#en The time scale of this skeleton. + !#zh 当前骨骼中所有动画的时间缩放率。 */ + timeScale: number; + /** !#en Indicates whether open debug slots. + !#zh 是否显示 slot 的 debug 信息。 */ + debugSlots: boolean; + /** !#en Indicates whether open debug bones. + !#zh 是否显示 bone 的 debug 信息。 */ + debugBones: boolean; + /** !#en Indicates whether open debug mesh. + !#zh 是否显示 mesh 的 debug 信息。 */ + debugMesh: boolean; + /** !#en Enabled two color tint. + !#zh 是否启用染色效果。 */ + useTint: boolean; + /** !#en Enabled batch model, if skeleton is complex, do not enable batch, or will lower performance. + !#zh 开启合批,如果渲染大量相同纹理,且结构简单的骨骼动画,开启合批可以降低drawcall,否则请不要开启,cpu消耗会上升。 */ + enableBatch: boolean; + /** + !#en + Sets runtime skeleton data to sp.Skeleton.
+ This method is different from the `skeletonData` property. This method is passed in the raw data provided by the Spine runtime, and the skeletonData type is the asset type provided by Creator. + !#zh + 设置底层运行时用到的 SkeletonData。
+ 这个接口有别于 `skeletonData` 属性,这个接口传入的是 Spine runtime 提供的原始数据,而 skeletonData 的类型是 Creator 提供的资源类型。 + @param skeletonData skeletonData + */ + setSkeletonData(skeletonData: sp.spine.SkeletonData): void; + /** + !#en Sets slots visible range. + !#zh 设置骨骼插槽可视范围。 + @param startSlotIndex startSlotIndex + @param endSlotIndex endSlotIndex + */ + setSlotsRange(startSlotIndex: number, endSlotIndex: number): void; + /** + !#en Sets animation state data.
+ The parameter type is {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.AnimationStateData. + !#zh 设置动画状态数据。
+ 参数是 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.AnimationStateData。 + @param stateData stateData + */ + setAnimationStateData(stateData: sp.spine.AnimationStateData): void; + /** + !#en + It's best to set cache mode before set property 'dragonAsset', or will waste some cpu time. + If set the mode in editor, then no need to worry about order problem. + !#zh + 若想切换渲染模式,最好在设置'dragonAsset'之前,先设置好渲染模式,否则有运行时开销。 + 若在编辑中设置渲染模式,则无需担心设置次序的问题。 + @param cacheMode cacheMode + + @example + ```js + skeleton.setAnimationCacheMode(sp.Skeleton.AnimationCacheMode.SHARED_CACHE); + ``` + */ + setAnimationCacheMode(cacheMode: Skeleton.AnimationCacheMode): void; + /** + !#en Whether in cached mode. + !#zh 当前是否处于缓存模式。 + */ + isAnimationCached(): boolean; + /** + !#en Sets vertex effect delegate. + !#zh 设置顶点动画代理 + @param effectDelegate effectDelegate + */ + setVertexEffectDelegate(effectDelegate: VertexEffectDelegate): void; + /** + !#en Computes the world SRT from the local SRT for each bone. + !#zh 重新更新所有骨骼的世界 Transform, + 当获取 bone 的数值未更新时,即可使用该函数进行更新数值。 + + @example + ```js + var bone = spine.findBone('head'); + cc.log(bone.worldX); // return 0; + spine.updateWorldTransform(); + bone = spine.findBone('head'); + cc.log(bone.worldX); // return -23.12; + ``` + */ + updateWorldTransform(): void; + /** + !#en Sets the bones and slots to the setup pose. + !#zh 还原到起始动作 + */ + setToSetupPose(): void; + /** + !#en + Sets the bones to the setup pose, + using the values from the `BoneData` list in the `SkeletonData`. + !#zh + 设置 bone 到起始动作 + 使用 SkeletonData 中的 BoneData 列表中的值。 + */ + setBonesToSetupPose(): void; + /** + !#en + Sets the slots to the setup pose, + using the values from the `SlotData` list in the `SkeletonData`. + !#zh + 设置 slot 到起始动作。 + 使用 SkeletonData 中的 SlotData 列表中的值。 + */ + setSlotsToSetupPose(): void; + /** + !#en + Updating an animation cache to calculate all frame data in the animation is a cost in + performance due to calculating all data in a single frame. + To update the cache, use the invalidAnimationCache method with high performance. + !#zh + 更新某个动画缓存, 预计算动画中所有帧数据,由于在单帧计算所有数据,所以较消耗性能。 + 若想更新缓存,可使用 invalidAnimationCache 方法,具有较高性能。 + @param animName animName + */ + updateAnimationCache(animName: string): void; + /** + !#en + Invalidates the animation cache, which is then recomputed on each frame.. + !#zh + 使动画缓存失效,之后会在每帧重新计算。 + */ + invalidAnimationCache(): void; + /** + !#en + Finds a bone by name. + This does a string comparison for every bone.
+ Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Bone object. + !#zh + 通过名称查找 bone。 + 这里对每个 bone 的名称进行了对比。
+ 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Bone 对象。 + @param boneName boneName + */ + findBone(boneName: string): sp.spine.Bone; + /** + !#en + Finds a slot by name. This does a string comparison for every slot.
+ Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Slot object. + !#zh + 通过名称查找 slot。这里对每个 slot 的名称进行了比较。
+ 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Slot 对象。 + @param slotName slotName + */ + findSlot(slotName: string): sp.spine.Slot; + /** + !#en + Finds a skin by name and makes it the active skin. + This does a string comparison for every skin.
+ Note that setting the skin does not change which attachments are visible.
+ Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Skin object. + !#zh + 按名称查找皮肤,激活该皮肤。这里对每个皮肤的名称进行了比较。
+ 注意:设置皮肤不会改变 attachment 的可见性。
+ 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Skin 对象。 + @param skinName skinName + */ + setSkin(skinName: string): void; + /** + !#en + Returns the attachment for the slot and attachment name. + The skeleton looks first in its skin, then in the skeleton data’s default skin.
+ Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Attachment object. + !#zh + 通过 slot 和 attachment 的名称获取 attachment。Skeleton 优先查找它的皮肤,然后才是 Skeleton Data 中默认的皮肤。
+ 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Attachment 对象。 + @param slotName slotName + @param attachmentName attachmentName + */ + getAttachment(slotName: string, attachmentName: string): sp.spine.Attachment; + /** + !#en + Sets the attachment for the slot and attachment name. + The skeleton looks first in its skin, then in the skeleton data’s default skin. + !#zh + 通过 slot 和 attachment 的名字来设置 attachment。 + Skeleton 优先查找它的皮肤,然后才是 Skeleton Data 中默认的皮肤。 + @param slotName slotName + @param attachmentName attachmentName + */ + setAttachment(slotName: string, attachmentName: string): void; + /** + Return the renderer of attachment. + @param regionAttachment regionAttachment + */ + getTextureAtlas(regionAttachment: sp.spine.RegionAttachment|spine.BoundingBoxAttachment): sp.spine.TextureAtlasRegion; + /** + !#en + Mix applies all keyframe values, + interpolated for the specified time and mixed with the current values. + !#zh 为所有关键帧设定混合及混合时间(从当前值开始差值)。 + @param fromAnimation fromAnimation + @param toAnimation toAnimation + @param duration duration + */ + setMix(fromAnimation: string, toAnimation: string, duration: number): void; + /** + !#en Set the current animation. Any queued animations are cleared.
+ Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry object. + !#zh 设置当前动画。队列中的任何的动画将被清除。
+ 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry 对象。 + @param trackIndex trackIndex + @param name name + @param loop loop + */ + setAnimation(trackIndex: number, name: string, loop: boolean): sp.spine.TrackEntry; + /** + !#en Adds an animation to be played delay seconds after the current or last queued animation.
+ Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry object. + !#zh 添加一个动画到动画队列尾部,还可以延迟指定的秒数。
+ 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry 对象。 + @param trackIndex trackIndex + @param name name + @param loop loop + @param delay delay + */ + addAnimation(trackIndex: number, name: string, loop: boolean, delay?: number): sp.spine.TrackEntry; + /** + !#en Find animation with specified name. + !#zh 查找指定名称的动画 + @param name name + */ + findAnimation(name: string): sp.spine.Animation; + /** + !#en Returns track entry by trackIndex.
+ Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry object. + !#zh 通过 track 索引获取 TrackEntry。
+ 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry 对象。 + @param trackIndex trackIndex + */ + getCurrent(trackIndex: any): sp.spine.TrackEntry; + /** + !#en Clears all tracks of animation state. + !#zh 清除所有 track 的动画状态。 + */ + clearTracks(): void; + /** + !#en Clears track of animation state by trackIndex. + !#zh 清除出指定 track 的动画状态。 + @param trackIndex trackIndex + */ + clearTrack(trackIndex: number): void; + /** + !#en Set the start event listener. + !#zh 用来设置开始播放动画的事件监听。 + @param listener listener + */ + setStartListener(listener: Function): void; + /** + !#en Set the interrupt event listener. + !#zh 用来设置动画被打断的事件监听。 + @param listener listener + */ + setInterruptListener(listener: Function): void; + /** + !#en Set the end event listener. + !#zh 用来设置动画播放完后的事件监听。 + @param listener listener + */ + setEndListener(listener: Function): void; + /** + !#en Set the dispose event listener. + !#zh 用来设置动画将被销毁的事件监听。 + @param listener listener + */ + setDisposeListener(listener: Function): void; + /** + !#en Set the complete event listener. + !#zh 用来设置动画播放一次循环结束后的事件监听。 + @param listener listener + */ + setCompleteListener(listener: Function): void; + /** + !#en Set the animation event listener. + !#zh 用来设置动画播放过程中帧事件的监听。 + @param listener listener + */ + setEventListener(listener: Function): void; + /** + !#en Set the start event listener for specified TrackEntry. + !#zh 用来为指定的 TrackEntry 设置动画开始播放的事件监听。 + @param entry entry + @param listener listener + */ + setTrackStartListener(entry: sp.spine.TrackEntry, listener: Function): void; + /** + !#en Set the interrupt event listener for specified TrackEntry. + !#zh 用来为指定的 TrackEntry 设置动画被打断的事件监听。 + @param entry entry + @param listener listener + */ + setTrackInterruptListener(entry: sp.spine.TrackEntry, listener: Function): void; + /** + !#en Set the end event listener for specified TrackEntry. + !#zh 用来为指定的 TrackEntry 设置动画播放结束的事件监听。 + @param entry entry + @param listener listener + */ + setTrackEndListener(entry: sp.spine.TrackEntry, listener: Function): void; + /** + !#en Set the dispose event listener for specified TrackEntry. + !#zh 用来为指定的 TrackEntry 设置动画即将被销毁的事件监听。 + @param entry entry + @param listener listener + */ + setTrackDisposeListener(entry: sp.spine.TrackEntry, listener: Function): void; + /** + !#en Set the complete event listener for specified TrackEntry. + !#zh 用来为指定的 TrackEntry 设置动画一次循环播放结束的事件监听。 + @param entry entry + @param listener listener + */ + setTrackCompleteListener(entry: sp.spine.TrackEntry, listener: (entry: sp.spine.TrackEntry, loopCount: number) => void): void; + /** + !#en Set the event listener for specified TrackEntry. + !#zh 用来为指定的 TrackEntry 设置动画帧事件的监听。 + @param entry entry + @param listener listener + */ + setTrackEventListener(entry: sp.spine.TrackEntry, listener: Function): void; + /** + !#en Get the animation state object + !#zh 获取动画状态 + */ + getState(): sp.spine.AnimationState; + } + /** !#en The skeleton data of spine. + !#zh Spine 的 骨骼数据。 */ + export class SkeletonData extends cc.Asset { + /** !#en See http://en.esotericsoftware.com/spine-json-format + !#zh 可查看 Spine 官方文档 http://zh.esotericsoftware.com/spine-json-format */ + skeletonJson: any; + atlasText: string; + textures: cc.Texture2D[]; + /** !#en + A scale can be specified on the JSON or binary loader which will scale the bone positions, + image sizes, and animation translations. + This can be useful when using different sized images than were used when designing the skeleton + in Spine. For example, if using images that are half the size than were used in Spine, + a scale of 0.5 can be used. This is commonly used for games that can run with either low or high + resolution texture atlases. + see http://en.esotericsoftware.com/spine-using-runtimes#Scaling + !#zh 可查看 Spine 官方文档: http://zh.esotericsoftware.com/spine-using-runtimes#Scaling */ + scale: number; + /** + !#en Get the included SkeletonData used in spine runtime.
+ Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.SkeletonData object. + !#zh 获取 Spine Runtime 使用的 SkeletonData。
+ 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.SkeletonData 对象。 + @param quiet quiet + */ + getRuntimeData(quiet?: boolean): sp.spine.SkeletonData; + } + /** !#en + The delegate of spine vertex effect + !#zh + Spine 顶点动画代理 */ + export class VertexEffectDelegate { + /** + !#en Clears vertex effect. + !#zh 清空顶点效果 + */ + clear(): void; + /** + !#en Inits delegate with jitter effect + !#zh 设置顶点抖动效果 + @param jitterX jitterX + @param jitterY jitterY + */ + initJitter(jitterX: number, jitterY: number): void; + /** + !#en Inits delegate with swirl effect + !#zh 设置顶点漩涡效果 + @param radius radius + @param power power + */ + initSwirlWithPow(radius: number, power: number): sp.spine.JitterEffect; + /** + !#en Inits delegate with swirl effect + !#zh 设置顶点漩涡效果 + @param radius radius + @param power power + */ + initSwirlWithPowOut(radius: number, power: number): sp.spine.SwirlEffect; + /** + !#en Gets jitter vertex effect + !#zh 获取顶点抖动效果 + */ + getJitterVertexEffect(): sp.spine.JitterEffect; + /** + !#en Gets swirl vertex effect + !#zh 获取顶点漩涡效果 + */ + getSwirlVertexEffect(): sp.spine.SwirlEffect; + /** + !#en Gets vertex effect + !#zh 获取顶点效果 + */ + getVertexEffect(): sp.spine.JitterEffect; + /** + !#en Gets effect type + !#zh 获取效果类型 + */ + getEffectType(): string; + } + /**************************************************** + * sp + *****************************************************/ + + export namespace sp { + /** !#en Attach node tool + !#zh 挂点工具类 */ + export class AttachUtil { + /** + !#en Gets attached root node. + !#zh 获取挂接节点树的根节点 + */ + getAttachedRootNode(): cc.Node; + /** + !#en Gets attached node which you want. + !#zh 获得对应的挂点 + @param boneName boneName + */ + getAttachedNodes(boneName: string): cc.Node[]; + /** + !#en Destroy attached node which you want. + !#zh 销毁对应的挂点 + @param boneName boneName + */ + destroyAttachedNodes(boneName: string): void; + /** + !#en Traverse all bones to generate the minimum node tree containing the given bone names, NOTE that make sure the skeleton has initialized before calling this interface. + !#zh 遍历所有插槽,生成包含所有给定插槽名称的最小节点树,注意,调用该接口前请确保骨骼动画已经初始化好。 + @param boneName boneName + */ + generateAttachedNodes(boneName: string): cc.Node[]; + /** + !#en Destroy all attached node. + !#zh 销毁所有挂点 + */ + destroyAllAttachedNodes(): void; + /** + !#en Traverse all bones to generate a tree containing all bones nodes, NOTE that make sure the skeleton has initialized before calling this interface. + !#zh 遍历所有插槽,生成包含所有插槽的节点树,注意,调用该接口前请确保骨骼动画已经初始化好。 + */ + generateAllAttachedNodes(): cc.Node; + } + } + + /**************************************************** + * Skeleton + *****************************************************/ + + export namespace Skeleton { + /** !#en Enum for animation cache mode type. + !#zh Spine动画缓存类型 */ + export enum AnimationCacheMode { + REALTIME = 0, + SHARED_CACHE = 0, + PRIVATE_CACHE = 0, + } + } + +} + +/** !#en +`sp.spine` is the namespace for official Spine Runtime, which officially implemented and maintained by Spine.
+Please refer to the official documentation for its detailed usage: [http://en.esotericsoftware.com/spine-using-runtimes](http://en.esotericsoftware.com/spine-using-runtimes) +!#zh +sp.spine 模块是 Spine 官方运行库的 API 入口,由 Spine 官方统一实现和维护,具体用法请参考:[http://zh.esotericsoftware.com/spine-using-runtimes](http://zh.esotericsoftware.com/spine-using-runtimes) */ +declare namespace sp.spine { +} + +/** !#en +The global main namespace of DragonBones, all classes, functions, +properties and constants of DragonBones are defined in this namespace +!#zh +DragonBones 的全局的命名空间, +与 DragonBones 相关的所有的类,函数,属性,常量都在这个命名空间中定义。 */ +declare namespace dragonBones { + /** !#en + The Armature Display of DragonBones
+
+ (Armature Display has a reference to a DragonBonesAsset and stores the state for ArmatureDisplay instance, + which consists of the current pose's bone SRT, slot colors, and which slot attachments are visible.
+ Multiple Armature Display can use the same DragonBonesAsset which includes all animations, skins, and attachments.)
+ !#zh + DragonBones 骨骼动画
+
+ (Armature Display 具有对骨骼数据的引用并且存储了骨骼实例的状态, + 它由当前的骨骼动作,slot 颜色,和可见的 slot attachments 组成。
+ 多个 Armature Display 可以使用相同的骨骼数据,其中包括所有的动画,皮肤和 attachments。)
*/ + export class ArmatureDisplay extends cc.RenderComponent { + /** !#en + The DragonBones data contains the armatures information (bind pose bones, slots, draw order, + attachments, skins, etc) and animations but does not hold any state.
+ Multiple ArmatureDisplay can share the same DragonBones data. + !#zh + 骨骼数据包含了骨骼信息(绑定骨骼动作,slots,渲染顺序, + attachments,皮肤等等)和动画但不持有任何状态。
+ 多个 ArmatureDisplay 可以共用相同的骨骼数据。 */ + dragonAsset: DragonBonesAsset; + /** !#en + The atlas asset for the DragonBones. + !#zh + 骨骼数据所需的 Atlas Texture 数据。 */ + dragonAtlasAsset: DragonBonesAtlasAsset; + /** !#en The name of current armature. + !#zh 当前的 Armature 名称。 */ + armatureName: string; + /** !#en The name of current playing animation. + !#zh 当前播放的动画名称。 */ + animationName: string; + _defaultArmatureIndex: number; + /** !#en The time scale of this armature. + !#zh 当前骨骼中所有动画的时间缩放率。 */ + timeScale: number; + /** !#en The play times of the default animation. + -1 means using the value of config file; + 0 means repeat for ever + >0 means repeat times + !#zh 播放默认动画的循环次数 + -1 表示使用配置文件中的默认值; + 0 表示无限循环 + >0 表示循环次数 */ + playTimes: number; + /** !#en Indicates whether to enable premultiplied alpha. + You should disable this option when image's transparent area appears to have opaque pixels, + or enable this option when image's half transparent area appears to be darken. + !#zh 是否启用贴图预乘。 + 当图片的透明区域出现色块时需要关闭该选项,当图片的半透明区域颜色变黑时需要启用该选项。 */ + premultipliedAlpha: boolean; + /** !#en Indicates whether open debug bones. + !#zh 是否显示 bone 的 debug 信息。 */ + debugBones: boolean; + /** !#en Enabled batch model, if skeleton is complex, do not enable batch, or will lower performance. + !#zh 开启合批,如果渲染大量相同纹理,且结构简单的骨骼动画,开启合批可以降低drawcall,否则请不要开启,cpu消耗会上升。 */ + enableBatch: boolean; + /** + !#en + The key of dragonbones cache data, which is regard as 'dragonbonesName', when you want to change dragonbones cloth. + !#zh + 缓存龙骨数据的key值,换装的时会使用到该值,作为dragonbonesName使用 + + @example + ```js + let factory = dragonBones.CCFactory.getInstance(); + let needChangeSlot = needChangeArmature.armature().getSlot("changeSlotName"); + factory.replaceSlotDisplay(toChangeArmature.getArmatureKey(), "armatureName", "slotName", "displayName", needChangeSlot); + ``` + */ + getArmatureKey(): string; + /** + !#en + It's best to set cache mode before set property 'dragonAsset', or will waste some cpu time. + If set the mode in editor, then no need to worry about order problem. + !#zh + 若想切换渲染模式,最好在设置'dragonAsset'之前,先设置好渲染模式,否则有运行时开销。 + 若在编辑中设置渲染模式,则无需担心设置次序的问题。 + @param cacheMode cacheMode + + @example + ```js + armatureDisplay.setAnimationCacheMode(dragonBones.ArmatureDisplay.AnimationCacheMode.SHARED_CACHE); + ``` + */ + setAnimationCacheMode(cacheMode: ArmatureDisplay.AnimationCacheMode): void; + /** + !#en Whether in cached mode. + !#zh 当前是否处于缓存模式。 + */ + isAnimationCached(): boolean; + /** + !#en + Play the specified animation. + Parameter animName specify the animation name. + Parameter playTimes specify the repeat times of the animation. + -1 means use the value of the config file. + 0 means play the animation for ever. + >0 means repeat times. + !#zh + 播放指定的动画. + animName 指定播放动画的名称。 + playTimes 指定播放动画的次数。 + -1 为使用配置文件中的次数。 + 0 为无限循环播放。 + >0 为动画的重复次数。 + @param animName animName + @param playTimes playTimes + */ + playAnimation(animName: string, playTimes: number): dragonBones.AnimationState; + /** + !#en + Updating an animation cache to calculate all frame data in the animation is a cost in + performance due to calculating all data in a single frame. + To update the cache, use the invalidAnimationCache method with high performance. + !#zh + 更新某个动画缓存, 预计算动画中所有帧数据,由于在单帧计算所有数据,所以较消耗性能。 + 若想更新缓存,可使用 invalidAnimationCache 方法,具有较高性能。 + @param animName animName + */ + updateAnimationCache(animName: string): void; + /** + !#en + Invalidates the animation cache, which is then recomputed on each frame.. + !#zh + 使动画缓存失效,之后会在每帧重新计算。 + */ + invalidAnimationCache(): void; + /** + !#en + Get the all armature names in the DragonBones Data. + !#zh + 获取 DragonBones 数据中所有的 armature 名称 + */ + getArmatureNames(): any[]; + /** + !#en + Get the all animation names of specified armature. + !#zh + 获取指定的 armature 的所有动画名称。 + @param armatureName armatureName + */ + getAnimationNames(armatureName: string): any[]; + /** + !#en + Add event listener for the DragonBones Event, the same to addEventListener. + !#zh + 添加 DragonBones 事件监听器,与 addEventListener 作用相同。 + @param type A string representing the event type to listen for. + @param listener The callback that will be invoked when the event is dispatched. + @param target The target (this object) to invoke the callback, can be null + */ + on(type: string, listener: (event: cc.Event) => void, target?: any): void; + /** + !#en + Remove the event listener for the DragonBones Event, the same to removeEventListener. + !#zh + 移除 DragonBones 事件监听器,与 removeEventListener 作用相同。 + @param type A string representing the event type to listen for. + @param listener listener + @param target target + */ + off(type: string, listener?: Function, target?: any): void; + /** + !#en + Add DragonBones one-time event listener, the callback will remove itself after the first time it is triggered. + !#zh + 添加 DragonBones 一次性事件监听器,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param listener The callback that will be invoked when the event is dispatched. + @param target The target (this object) to invoke the callback, can be null + */ + once(type: string, listener: (event: cc.Event) => void, target?: any): void; + /** + !#en + Add event listener for the DragonBones Event. + !#zh + 添加 DragonBones 事件监听器。 + @param type A string representing the event type to listen for. + @param listener The callback that will be invoked when the event is dispatched. + @param target The target (this object) to invoke the callback, can be null + */ + addEventListener(type: string, listener: (event: cc.Event) => void, target?: any): void; + /** + !#en + Remove the event listener for the DragonBones Event. + !#zh + 移除 DragonBones 事件监听器。 + @param type A string representing the event type to listen for. + @param listener listener + @param target target + */ + removeEventListener(type: string, listener?: Function, target?: any): void; + /** + !#en + Build the armature for specified name. + !#zh + 构建指定名称的 armature 对象 + @param armatureName armatureName + @param node node + */ + buildArmature(armatureName: string, node: cc.Node): ArmatureDisplay; + /** + !#en + Get the current armature object of the ArmatureDisplay. + !#zh + 获取 ArmatureDisplay 当前使用的 Armature 对象 + */ + armature(): any; + } + /** DragonBones factory */ + export class CCFactory extends BaseFactory { + /** + + + @example + ```js + let factory = dragonBones.CCFactory.getInstance(); + ``` + */ + static getInstance(): CCFactory; + } + /** !#en The skeleton data of dragonBones. + !#zh dragonBones 的 骨骼数据。 */ + export class DragonBonesAsset extends cc.Asset { + /** !#en See http://developer.egret.com/cn/github/egret-docs/DB/dbLibs/dataFormat/index.html + !#zh 可查看 DragonBones 官方文档 http://developer.egret.com/cn/github/egret-docs/DB/dbLibs/dataFormat/index.html */ + dragonBonesJson: string; + } + /** !#en The skeleton atlas data of dragonBones. + !#zh dragonBones 的骨骼纹理数据。 */ + export class DragonBonesAtlasAsset extends cc.Asset { + atlasJson: string; + texture: cc.Texture2D; + } + /**************************************************** + * ArmatureDisplay + *****************************************************/ + + export namespace ArmatureDisplay { + /** !#en Enum for cache mode type. + !#zh Dragonbones渲染类型 */ + export enum AnimationCacheMode { + REALTIME = 0, + SHARED_CACHE = 0, + PRIVATE_CACHE = 0, + } + } + + /**************************************************** + * dragonBones + *****************************************************/ + + export namespace dragonBones { + /** !#en Attach node tool + !#zh 挂点工具类 */ + export class AttachUtil { + /** + !#en Gets attached root node. + !#zh 获取挂接节点树的根节点 + */ + getAttachedRootNode(): cc.Node; + /** + !#en Gets attached node which you want. + !#zh 获得对应的挂点 + @param boneName boneName + */ + getAttachedNodes(boneName: string): cc.Node[]; + /** + !#en Destroy attached node which you want. + !#zh 销毁对应的挂点 + @param boneName boneName + */ + destroyAttachedNodes(boneName: string): void; + /** + !#en Traverse all bones to generate the minimum node tree containing the given bone names, NOTE that make sure the skeleton has initialized before calling this interface. + !#zh 遍历所有插槽,生成包含所有给定插槽名称的最小节点树,注意,调用该接口前请确保骨骼动画已经初始化好。 + @param boneName boneName + */ + generateAttachedNodes(boneName: string): cc.Node[]; + /** + !#en Destroy all attached node. + !#zh 销毁所有挂点 + */ + destroyAllAttachedNodes(): void; + /** + !#en Traverse all bones to generate a tree containing all bones nodes, NOTE that make sure the skeleton has initialized before calling this interface. + !#zh 遍历所有插槽,生成包含所有插槽的节点树,注意,调用该接口前请确保骨骼动画已经初始化好。 + */ + generateAllAttachedNodes(): cc.Node; + } + } + +} + +/** !#en +This module controls asset's behaviors and information, include loading, releasing etc. +All member can be accessed with `cc.assetManager`. All class or enum can be accessed with `cc.AssetManager` + +!#zh +此模块管理资源的行为和信息,包括加载,释放等,所有成员能够通过 `cc.assetManager` 调用. 所有类型或枚举能通过 `cc.AssetManager` 访问 */ +declare namespace cc.AssetManager { + /** !#en + This module contains the builtin asset, it's a singleton, all member can be accessed with `cc.assetManager.builtins` + + !#zh + 此模块包含内建资源,这是一个单例,所有成员能通过 `cc.assetManager.builtins` 访问 */ + export class Builtins { + /** + !#en + Initialize + + !#zh + 初始化 + @param cb Callback when finish loading built-in assets + */ + init (cb: () => void): void; + /** + !#en + Get the built-in asset using specific type and name. + + !#zh + 通过特定的类型和名称获取内建资源 + @param type The type of asset, such as `effect` + @param name The name of asset, such as `phong` + + @example + ```js + cc.assetManaer.builtins.getBuiltin('effect', 'phone'); + ``` + */ + getBuiltin(type?: string, name?: string): cc.Asset | Cache; + /** + !#en + Clear all builtin assets + + !#zh + 清空所有内置资源 + */ + clear(): void; + } + /** !#en + A bundle contains an amount of assets(includes scene), you can load, preload, release asset which is in this bundle + + !#zh + 一个包含一定数量资源(包括场景)的包,你可以加载,预加载,释放此包内的资源 */ + export class Bundle { + /** + !#en + Create a bundle + + !#zh + 创建一个 bundle + */ + constructor(); + /** !#en + The name of this bundle + + !#zh + 此 bundle 的名称 */ + name: string; + /** !#en + The dependency of this bundle + + !#zh + 此 bundle 的依赖 */ + deps: string[]; + /** !#en + The root path of this bundle, such like 'http://example.com/bundle1' + + !#zh + 此 bundle 的根路径, 例如 'http://example.com/bundle1' */ + base: string; + /** + !#en + Get asset's info using path, only valid when asset is in bundle folder. + + !#zh + 使用 path 获取资源的配置信息 + @param path The relative path of asset, such as 'images/a' + @param type The constructor of asset, such as `cc.Texture2D` + + @example + ```js + var info = bundle.getInfoWithPath('image/a', cc.Texture2D); + ``` + */ + getInfoWithPath (path: string, type?: typeof cc.Asset): Record; + /** + !#en + Get all asset's info within specific folder + + !#zh + 获取在某个指定文件夹下的所有资源信息 + @param path The relative path of folder, such as 'images' + @param type The constructor should be used to filter paths + @param out The output array + + @example + ```js + var infos = []; + bundle.getDirWithPath('images', cc.Texture2D, infos); + ``` + */ + getDirWithPath (path: string, type: typeof cc.Asset, out: Array>): Array>; + getDirWithPath (path: string, type: typeof cc.Asset): Array>; + getDirWithPath (path: string): Array>; + /** + !#en + Get asset's info with uuid + + !#zh + 通过 uuid 获取资源信息 + @param uuid The asset's uuid + + @example + ```js + var info = bundle.getAssetInfo('fcmR3XADNLgJ1ByKhqcC5Z'); + ``` + */ + getAssetInfo (uuid: string): Record; + /** + !#en + Get scene'info with name + + !#zh + 通过场景名获取场景信息 + @param name The name of scene + + @example + ```js + var info = bundle.getSceneInfo('first.fire'); + ``` + */ + getSceneInfo(name: string): Record; + /** + !#en + Initialize this bundle with options + + !#zh + 初始化此 bundle + @param options options + */ + init(options: Record): void; + /** + !#en + Load the asset within this bundle by the path which is relative to bundle's path + + !#zh + 通过相对路径加载分包中的资源。路径是相对分包文件夹路径的相对路径 + @param paths Paths of the target assets.The path is relative to the bundle's folder, extensions must be omitted. + @param type Only asset of type will be loaded if this argument is supplied. + @param onProgress Callback invoked when progression change. + @param onComplete Callback invoked when all assets loaded. + + @example + ```js + // load the texture (${project}/assets/resources/textures/background.jpg) from resources + cc.resources.load('textures/background', cc.Texture2D, (err, texture) => console.log(err)); + + // load the audio (${project}/assets/resources/music/hit.mp3) from resources + cc.resources.load('music/hit', cc.AudioClip, (err, audio) => console.log(err)); + + // load the prefab (${project}/assets/bundle1/misc/character/cocos) from bundle1 folder + bundle1.load('misc/character/cocos', cc.Prefab, (err, prefab) => console.log(err)); + + // load the sprite frame (${project}/assets/some/xxx/bundle2/imgs/cocos.png) from bundle2 folder + bundle2.load('imgs/cocos', cc.SpriteFrame, null, (err, spriteFrame) => console.log(err)); + ``` + */ + load(paths: string|string[], type: typeof cc.Asset, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, assets: T|Array) => void): void; + load(paths: string|string[], onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, assets: T|Array) => void): void; + load(paths: string|string[], type: typeof cc.Asset, onComplete: (error: Error, assets: T|Array) => void): void; + load(paths: string|string[], onComplete: (error: Error, assets: T|Array) => void): void; + load(paths: string|string[], type: typeof cc.Asset): void; + load(paths: string|string[]): void; + /** + !#en + Preload the asset within this bundle by the path which is relative to bundle's path. + After calling this method, you still need to finish loading by calling `Bundle.load`. + It will be totally fine to call `Bundle.load` at any time even if the preloading is not + yet finished + + !#zh + 通过相对路径预加载分包中的资源。路径是相对分包文件夹路径的相对路径。调用完后,你仍然需要通过 `Bundle.load` 来完成加载。 + 就算预加载还没完成,你也可以直接调用 `Bundle.load`。 + @param paths Paths of the target asset.The path is relative to bundle folder, extensions must be omitted. + @param type Only asset of type will be loaded if this argument is supplied. + @param onProgress Callback invoked when progression change. + @param onComplete Callback invoked when the resource loaded. + + @example + ```js + // preload the texture (${project}/assets/resources/textures/background.jpg) from resources + cc.resources.preload('textures/background', cc.Texture2D); + + // preload the audio (${project}/assets/resources/music/hit.mp3) from resources + cc.resources.preload('music/hit', cc.AudioClip); + // wait for while + cc.resources.load('music/hit', cc.AudioClip, (err, audioClip) => {}); + + * // preload the prefab (${project}/assets/bundle1/misc/character/cocos) from bundle1 folder + bundle1.preload('misc/character/cocos', cc.Prefab); + + // load the sprite frame of (${project}/assets/bundle2/imgs/cocos.png) from bundle2 folder + bundle2.preload('imgs/cocos', cc.SpriteFrame); + // wait for while + bundle2.load('imgs/cocos', cc.SpriteFrame, (err, spriteFrame) => {}); + ``` + */ + preload(paths: string|string[], type: typeof cc.Asset, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, items: RequestItem[]) => void): void; + preload(paths: string|string[], onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, items: RequestItem[]) => void): void; + preload(paths: string|string[], type: typeof cc.Asset, onComplete: (error: Error, items: RequestItem[]) => void): void; + preload(paths: string|string[], type: typeof cc.Asset): void; + preload(paths: string|string[], onComplete: (error: Error, items: RequestItem[]) => void): void; + preload(paths: string|string[]): void; + /** + !#en + Load all assets under a folder inside the bundle folder.
+
+ Note: All asset paths in Creator use forward slashes, paths using backslashes will not work. + + !#zh + 加载目标文件夹中的所有资源, 注意:路径中只能使用斜杠,反斜杠将停止工作 + @param dir path of the target folder.The path is relative to the bundle folder, extensions must be omitted. + @param type Only asset of type will be loaded if this argument is supplied. + @param onProgress Callback invoked when progression change. + @param onComplete A callback which is called when all assets have been loaded, or an error occurs. + + @example + ```js + // load all audios (resources/audios/) + cc.resources.loadDir('audios', cc.AudioClip, (err, audios) => {}); + + // load all textures in "resources/imgs/" + cc.resources.loadDir('imgs', cc.Texture2D, null, function (err, textures) { + var texture1 = textures[0]; + var texture2 = textures[1]; + }); + + // load all prefabs (${project}/assets/bundle1/misc/characters/) from bundle1 folder + bundle1.loadDir('misc/characters', cc.Prefab, (err, prefabs) => console.log(err)); + + // load all sprite frame (${project}/assets/some/xxx/bundle2/skills/) from bundle2 folder + bundle2.loadDir('skills', cc.SpriteFrame, null, (err, spriteFrames) => console.log(err)); + ``` + */ + loadDir(dir: string, type: typeof cc.Asset, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, assets: Array) => void): void; + loadDir(dir: string, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, assets: Array) => void): void; + loadDir(dir: string, type: typeof cc.Asset, onComplete: (error: Error, assets: Array) => void): void; + loadDir(dir: string, type: typeof cc.Asset): void; + loadDir(dir: string, onComplete: (error: Error, assets: Array) => void): void; + loadDir(dir: string): void; + /** + !#en + Preload all assets under a folder inside the bundle folder.
After calling this method, you still need to finish loading by calling `Bundle.loadDir`. + It will be totally fine to call `Bundle.loadDir` at any time even if the preloading is not yet finished + + !#zh + 预加载目标文件夹中的所有资源。调用完后,你仍然需要通过 `Bundle.loadDir` 来完成加载。 + 就算预加载还没完成,你也可以直接调用 `Bundle.loadDir`。 + @param dir path of the target folder.The path is relative to the bundle folder, extensions must be omitted. + @param type Only asset of type will be preloaded if this argument is supplied. + @param onProgress Callback invoked when progression change. + @param onComplete A callback which is called when all assets have been loaded, or an error occurs. + + @example + ```js + // preload all audios (resources/audios/) + cc.resources.preloadDir('audios', cc.AudioClip); + + // preload all textures in "resources/imgs/" + cc.resources.preloadDir('imgs', cc.Texture2D); + // wait for while + cc.resources.loadDir('imgs', cc.Texture2D, (err, textures) => {}); + + // preload all prefabs (${project}/assets/bundle1/misc/characters/) from bundle1 folder + bundle1.preloadDir('misc/characters', cc.Prefab); + + // preload all sprite frame (${project}/assets/some/xxx/bundle2/skills/) from bundle2 folder + bundle2.preloadDir('skills', cc.SpriteFrame); + // wait for while + bundle2.loadDir('skills', cc.SpriteFrame, (err, spriteFrames) => {}); + ``` + */ + preloadDir(dir: string, type: typeof cc.Asset, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, items: RequestItem[]) => void): void; + preloadDir(dir: string, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, items: RequestItem[]) => void): void; + preloadDir(dir: string, type: typeof cc.Asset, onComplete: (error: Error, items: RequestItem[]) => void): void; + preloadDir(dir: string, type: typeof cc.Asset): void; + preloadDir(dir: string, onComplete: (error: Error, items: RequestItem[]) => void): void; + preloadDir(dir: string): void; + /** + !#en + Loads the scene within this bundle by its name. + + !#zh + 通过场景名称加载分包中的场景。 + @param sceneName The name of the scene to load. + @param options Some optional parameters + @param onProgress Callback invoked when progression change. + @param onComplete callback, will be called after scene launched. + + @example + ```js + bundle1.loadScene('first', (err, sceneAsset) => cc.director.runScene(sceneAsset)); + ``` + */ + loadScene(sceneName: string, options: Record, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, sceneAsset: cc.SceneAsset) => void): void; + loadScene(sceneName: string, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, sceneAsset: cc.SceneAsset) => void): void; + loadScene(sceneName: string, options: Record, onComplete: (error: Error, sceneAsset: cc.SceneAsset) => void): void; + loadScene(sceneName: string, options: Record): void; + loadScene(sceneName: string, onComplete: (error: Error, sceneAsset: cc.SceneAsset) => void): void; + loadScene(sceneName: string): void; + /** + !#en + Preloads the scene within this bundle by its name. After calling this method, you still need to finish loading by calling `Bundle.loadScene` or `cc.director.loadScene`. + It will be totally fine to call `Bundle.loadDir` at any time even if the preloading is not yet finished + + !#zh + 通过场景名称预加载分包中的场景.调用完后,你仍然需要通过 `Bundle.loadScene` 或 `cc.director.loadScene` 来完成加载。 + 就算预加载还没完成,你也可以直接调用 `Bundle.loadScene` 或 `cc.director.loadScene`。 + @param sceneName The name of the scene to preload. + @param options Some optional parameters + @param onProgress callback, will be called when the load progression change. + @param onComplete callback, will be called after scene loaded. + + @example + ```js + bundle1.preloadScene('first'); + // wait for a while + bundle1.loadScene('first', (err, scene) => cc.director.runScene(scene)); + ``` + */ + preloadScene(sceneName: string, options: Record, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error) => void): void; + preloadScene(sceneName: string, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error) => void): void; + preloadScene(sceneName: string, options: Record, onComplete: (error: Error) => void): void; + preloadScene(sceneName: string, options: Record): void; + preloadScene(sceneName: string, onComplete: (error: Error) => void): void; + preloadScene(sceneName: string): void; + /** + !#en + Get asset within this bundle by path and type.
+ After you load asset with {{#crossLink "Bundle/load:method"}}{{/crossLink}} or {{#crossLink "Bundle/loadDir:method"}}{{/crossLink}}, + you can acquire them by passing the path to this API. + + !#zh + 通过路径与类型获取资源。在你使用 {{#crossLink "Bundle/load:method"}}{{/crossLink}} 或者 {{#crossLink "Bundle/loadDir:method"}}{{/crossLink}} 之后, + 你能通过传路径通过这个 API 获取到这些资源。 + @param path The path of asset + @param type Only asset of type will be returned if this argument is supplied. + + @example + ```js + bundle1.get('music/hit', cc.AudioClip); + ``` + */ + get (path: string, type?: typeof cc.Asset): cc.Asset; + /** + !#en + Release the asset loaded by {{#crossLink "Bundle/load:method"}}{{/crossLink}} or {{#crossLink "Bundle/loadDir:method"}}{{/crossLink}} and it's dependencies. + Refer to {{#crossLink "AssetManager/releaseAsset:method"}}{{/crossLink}} for detailed informations. + + !#zh + 释放通过 {{#crossLink "Bundle/load:method"}}{{/crossLink}} 或者 {{#crossLink "Bundle/loadDir:method"}}{{/crossLink}} 加载的资源。详细信息请参考 {{#crossLink "AssetManager/releaseAsset:method"}}{{/crossLink}} + @param path The path of asset + @param type Only asset of type will be released if this argument is supplied. + + @example + ```js + // release a texture which is no longer need + bundle1.release('misc/character/cocos'); + ``` + */ + release(path: string, type: typeof cc.Asset): void; + release(path: string): void; + /** + !#en + Release all assets within this bundle. Refer to {{#crossLink "AssetManager/releaseAll:method"}}{{/crossLink}} for detailed informations. + + !#zh + 释放此包中的所有资源。详细信息请参考 {{#crossLink "AssetManager/releaseAll:method"}}{{/crossLink}} + + @example + ```js + // release all asset within bundle1 + bundle1.releaseAll(); + ``` + */ + releaseAll(): void; + } + /** !#en + Cache manager is a module which controls all caches downloaded from server in non-web platform, it is a singleton + All member can be accessed with `cc.assetManager.cacheManager`. + + !#zh + 缓存管理器是一个模块,在非 WEB 平台上,用于管理所有从服务器上下载下来的缓存,这是一个单例,所有成员能通过 `cc.assetManager.cacheManager` 访问。 */ + export class CacheManager { + /** !#en + The name of cacheDir + + !#zh + 缓存目录的名称 */ + cacheDir: string; + /** !#en + Whether or not cache asset into user's storage space, this property only works on mini-game platforms + + !#zh + 是否缓存资源到用户存储空间,此属性只在小游戏平台有效 */ + cacheEnabled: boolean; + /** !#en + Whether or not auto clear cache when storage ran out, this property only works on mini-game platforms + + !#zh + 是否在存储空间满了后自动清理缓存,此属性只在小游戏平台有效 */ + autoClear: boolean; + /** !#en + The interval between caching resources, this property only works on mini-game platforms + + !#zh + 缓存资源的间隔时间,此属性只在小游戏平台有效 */ + cacheInterval: number; + /** !#en + The interval between deleting resources, when you use `cleanLRU`, the resources will be deleted as this interval + + !#zh + 清理资源的间隔时间,当你使用 `cleanLRU` 时,资源将以此间隔被删除 */ + deleteInterval: number; + /** + !#en + Get cached path with origin url + + !#zh + 通过原始 url 获取缓存后的路径 + @param originUrl originUrl + */ + getCache(originUrl: string): string; + /** + !#en + Get temporary path with origin url, this method only works on mini-game platforms + + !#zh + 通过原始 url 获取临时文件的路径,此方法只在小游戏平台有效 + @param originUrl originUrl + */ + getTemp(originUrl: string): string; + /** + !#en + Clear all caches, please use with caution, If necessary, we recommend using it before the game is launched + + !#zh + 清空所有缓存,请谨慎使用,如果必要的话,我们建议在游戏启动之前使用 + */ + clearCache(): void; + /** + !#en + Clear part of caches with LRU strategy + + !#zh + 使用 LRU 策略清空部分缓存 + */ + clearLRU(): void; + /** + !#en + Remove cache with origin url + + !#zh + 通过原始 url 移除缓存 + */ + removeCache(): void; + } + /** !#en + use to cache something + + !#zh + 用于缓存某些内容 */ + export class Cache { + /** + !#en + Create a cache + + !#zh + 创建一个 cache + @param map An object used to initialize + */ + constructor(map?: Record); + /** + !#en + Add Key-Value to cache + + !#zh + 增加键值对到缓存中 + @param key The key + @param val The value + + @example + ```js + var cache = new Cache(); + cache.add('test', null); + ``` + */ + add(key: string, val: T): T; + /** + !#en + Get the cached content by key + + !#zh + 通过 key 获取对应的 value + @param key The key + + @example + ```js + var cache = new Cache(); + var test = cache.get('test'); + ``` + */ + get(key: string): T; + /** + !#en + Check whether or not content exists by key + + !#zh + 通过 Key 判断是否存在对应的内容 + @param key The key + + @example + ```js + var cache = new Cache(); + var exist = cache.has('test'); + ``` + */ + has(key: string): boolean; + /** + !#en + Remove the cached content by key + + !#zh + 通过 Key 移除对应的内容 + @param key The key + + @example + ```js + var cache = new Cache(); + var content = cache.remove('test'); + ``` + */ + remove(key: string): T; + /** + !#en + Clear all content + + !#zh + 清除所有内容 + + @example + ```js + var cache = new Cache(); + cache.clear(); + ``` + */ + clear():void; + /** + !#en + Enumerate all content and invoke function + + !#zh + 枚举所有内容并执行方法 + @param func Function to be invoked + + @example + ```js + var cache = new Cache(); + cache.forEach((val, key) => console.log(key)); + ``` + */ + forEach(func: (val: T, key: string) => void): void; + /** + !#en + Enumerate all content to find one element which can fulfill condition + + !#zh + 枚举所有内容,找到一个可以满足条件的元素 + @param predicate The condition + + @example + ```js + var cache = new Cache(); + var val = cache.find((val, key) => key === 'test'); + ``` + */ + find(predicate: (val: T, key: string) => boolean): T; + /** !#en + The count of cached content + + !#zh + 缓存数量 */ + count: number; + /** + !#en + Destroy this cache + + !#zh + 销毁这个 cache + */ + destroy(): void; + } + /** !#en + Control asset's dependency list, it is a singleton. All member can be accessed with `cc.assetManager.dependUtil` + + !#zh + 控制资源的依赖列表,这是一个单例, 所有成员能通过 `cc.assetManager.dependUtil` 访问 */ + export class DependUtil { + /** + !#en + Get asset's native dependency. For example, Texture's native dependency is image. + + !#zh + 获取资源的原生依赖,例如 Texture 的原生依赖是图片 + @param uuid asset's uuid + + @example + ```js + var dep = dependUtil.getNativeDep('fcmR3XADNLgJ1ByKhqcC5Z'); + ``` + */ + getNativeDep(uuid: string): Record; + /** + !#en + Get asset's direct referencing non-native dependency list. For example, Material's non-native dependencies are Texture. + + !#zh + 获取资源直接引用的非原生依赖列表,例如,材质的非原生依赖是 Texture + @param uuid asset's uuid + + @example + ```js + var deps = dependUtil.getDeps('fcmR3XADNLgJ1ByKhqcC5Z'); + ``` + */ + getDeps(uuid: string): string[]; + /** + !#en + Get non-native dependency list of the loaded asset, include indirect reference. + The returned array stores the dependencies with their uuid, after retrieve dependencies, + + !#zh + 获取某个已经加载好的资源的所有非原生依赖资源列表,包括间接引用的资源,并保存在数组中返回。 + 返回的数组将仅保存依赖资源的 uuid。 + @param uuid The asset's uuid + + @example + ```js + var deps = dependUtil.getDepsRecursively('fcmR3XADNLgJ1ByKhqcC5Z'); + ``` + */ + getDepsRecursively(uuid: string): string[]; + } + /** !#en + Control all download process, it is a singleton. All member can be accessed with `cc.assetManager.downloader` , it can download several types of files: + 1. Text + 2. Image + 3. Audio + 4. Assets + 5. Scripts + + !#zh + 管理所有下载过程,downloader 是个单例,所有成员能通过 `cc.assetManager.downloader` 访问,它能下载以下几种类型的文件: + 1. 文本 + 2. 图片 + 3. 音频 + 4. 资源 + 5. 脚本 */ + export class Downloader { + /** !#en + The maximum number of concurrent when downloading + + !#zh + 下载时的最大并发数 */ + maxConcurrency: number; + /** !#en + The maximum number of request can be launched per frame when downloading + + !#zh + 下载时每帧可以启动的最大请求数 */ + maxRequestsPerFrame: number; + /** !#en + The max number of retries when fail + + !#zh + 失败重试次数 */ + maxRetryCount: number; + /** !#en + Wait for while before another retry, unit: ms + + !#zh + 重试的间隔时间 */ + retryInterval: number; + /** + !#en + Use Image element to download image + + !#zh + 使用 Image 元素来下载图片 + @param url Url of the image + @param options Some optional paramters + @param onComplete Callback when image loaded or failed + + @example + ```js + downloadDomImage('http://example.com/test.jpg', null, (err, img) => console.log(err)); + ``` + */ + downloadDomImage(url: string, options?: Record , onComplete?: (err: Error, img: HTMLImageElement) => void): HTMLImageElement; + downloadDomImage(url: string, onComplete?: (err: Error, img: HTMLImageElement) => void): HTMLImageElement; + /** + !#en + Use audio element to download audio + + !#zh + 使用 Audio 元素来下载音频 + @param url Url of the audio + @param options Some optional paramters + @param onComplete Callback invoked when audio loaded or failed + + @example + ```js + downloadDomAudio('http://example.com/test.mp3', null, (err, audio) => console.log(err)); + ``` + */ + downloadDomAudio(url: string, options?: Record, onComplete?: (err: Error, audio: HTMLAudioElement) => void): HTMLAudioElement; + downloadDomAudio(url: string, onComplete?: (err: Error, audio: HTMLAudioElement) => void): HTMLAudioElement; + /** + !#en + Use XMLHttpRequest to download file + + !#zh + 使用 XMLHttpRequest 来下载文件 + @param url Url of the file + @param options Some optional paramters + @param onFileProgress Callback continuously during download is processing + @param onComplete Callback when file loaded or failed + + @example + ```js + downloadFile('http://example.com/test.bin', {responseType: 'arraybuffer'}, null, (err, arrayBuffer) => console.log(err)); + ``` + */ + downloadFile(url: string, options?: Record, onFileProgress?: (loaded: Number, total: Number) => void, onComplete?: (err: Error, response: any) => void): XMLHttpRequest; + downloadFile(url: string, onFileProgress?: (loaded: Number, total: Number) => void, onComplete?: (err: Error, response: any) => void): XMLHttpRequest; + downloadFile(url: string, options?: Record, onComplete?: (err: Error, response: any) => void): XMLHttpRequest; + downloadFile(url: string, onComplete?: (err: Error, response: any) => void): XMLHttpRequest; + /** + !#en + Load script + + !#zh + 加载脚本 + @param url Url of the script + @param options Some optional paramters + @param onComplete Callback when script loaded or failed + + @example + ```js + downloadScript('http://localhost:8080/index.js', null, (err) => console.log(err)); + ``` + */ + downloadScript(url: string, options?: Record, onComplete?: (err: Error) => void): void;; + downloadScript(url: string, onComplete?: (err: Error) => void): void;; + /** + !#en + Register custom handler if you want to change default behavior or extend downloader to download other format file + + !#zh + 当你想修改默认行为或者拓展 downloader 来下载其他格式文件时可以注册自定义的 handler + @param type Extension likes '.jpg' or map likes {'.jpg': jpgHandler, '.png': pngHandler} + @param handler handler + + @example + ```js + downloader.register('.tga', (url, options, onComplete) => onComplete(null, null)); + downloader.register({'.tga': (url, options, onComplete) => onComplete(null, null), '.ext': (url, options, onComplete) => onComplete(null, null)}); + ``` + */ + register(type: string, handler: (url: string, options: Record, onComplete: (err: Error, content: any) => void) => void): void; + register(map: Record, onComplete: (err: Error, content: any) => void) => void>): void; + /** + !#en + Use corresponding handler to download file under limitation + + !#zh + 在限制下使用对应的 handler 来下载文件 + @param url The url should be downloaded + @param type The type indicates that which handler should be used to download, such as '.jpg' + @param options some optional paramters will be transferred to the corresponding handler. + @param onComplete callback when finishing downloading + + @example + ```js + download('http://example.com/test.tga', '.tga', {onFileProgress: (loaded, total) => console.lgo(loaded/total)}, onComplete: (err) => console.log(err)); + ``` + */ + download(id: string, url: string, type: string, options: Record, onComplete: (err: Error, content: any) => void): void; + } + /** !#en + Provide some helpful function, it is a singleton. All member can be accessed with `cc.assetManager.utils` + + !#zh + 提供一些辅助方法,helper 是一个单例, 所有成员能通过 `cc.assetManager.utils` 访问 */ + export class Helper { + /** + !#en + Decode uuid, returns the original uuid + + !#zh + 解码 uuid,返回原始 uuid + @param base64 the encoded uuid + + @example + ```js + var uuid = 'fcmR3XADNLgJ1ByKhqcC5Z'; + var originalUuid = decodeUuid(uuid); // fc991dd7-0033-4b80-9d41-c8a86a702e59 + ``` + */ + decodeUuid(base64: string): string; + /** + !#en + Extract uuid from url + + !#zh + 从 url 中提取 uuid + @param url url + + @example + ```js + var url = 'res/import/fc/fc991dd7-0033-4b80-9d41-c8a86a702e59.json'; + var uuid = getUuidFromURL(url); // fc991dd7-0033-4b80-9d41-c8a86a702e59 + ``` + */ + getUuidFromURL(url: string): string; + /** + !#en + Transform uuid to url + + !#zh + 转换 uuid 为 url + @param uuid The uuid of asset + @param options Some optional parameters + + @example + ```js + var url = getUrlWithUuid('fcmR3XADNLgJ1ByKhqcC5Z', {isNative: false}); + ``` + */ + getUrlWithUuid(uuid: string, options?: Record): string; + /** + !#en + Check if the type of data is cc.Scene or cc.Prefab + + !#zh + 检测数据的类型是否是 Scene 或者 Prefab + @param json serialized data + */ + isSceneObj(json: any): boolean; + /** + !#en + Check if the type of asset is scene + + !#zh + 检查资源类型是否是场景 + @param asset asset + */ + isScene(asset: any): boolean; + /** + !#en + Normalize url, strip './' and '/' + + !#zh + 标准化 url ,去除 './' 和 '/' + @param url url + */ + normalize(url: string): string; + } + /** !#en + Parse the downloaded file, it's a singleton, all member can be accessed with `cc.assetManager.parser` + + !#zh + 解析已下载的文件,parser 是一个单例, 所有成员能通过 `cc.assetManaager.parser` 访问 */ + export class Parser { + /** + !#en + Parse image file + + !#zh + 解析图片文件 + @param file The downloaded file + @param options Some optional paramters + @param onComplete callback when finish parsing. + + @example + ```js + downloader.downloadFile('test.jpg', {responseType: 'blob'}, null, (err, file) => { + parser.parseImage(file, null, (err, img) => console.log(err)); + }); + ``` + */ + parseImage(file: Blob, options: Record, onComplete?: (err: Error, img: ImageBitmap|HTMLImageElement) => void): void; + /** + !#en + Parse audio file + + !#zh + 解析音频文件 + @param file The downloaded file + @param options Some optional paramters + @param onComplete Callback when finish parsing. + + @example + ```js + downloader.downloadFile('test.mp3', {responseType: 'arraybuffer'}, null, (err, file) => { + parser.parseAudio(file, null, (err, audio) => console.log(err)); + }); + ``` + */ + parseAudio(file: ArrayBuffer|HTMLAudioElement, options: Record, onComplete?: (err: Error, audio: AudioBuffer|HTMLAudioElement) => void): void; + /** + !#en + Parse pvr file + + !#zh + 解析压缩纹理格式 pvr 文件 + @param file The downloaded file + @param options Some optional paramters + @param onComplete Callback when finish parsing. + + @example + ```js + downloader.downloadFile('test.pvr', {responseType: 'arraybuffer'}, null, (err, file) => { + parser.parsePVRTex(file, null, (err, pvrAsset) => console.log(err)); + }); + ``` + */ + parsePVRTex(file: ArrayBuffer|ArrayBufferView, options: Record, onComplete: (err: Error, pvrAsset: {_data: Uint8Array, _compressed: boolean, width: number, height: number}) => void): void; + /** + !#en + Parse pkm file + + !#zh + 解析压缩纹理格式 pkm 文件 + @param file The downloaded file + @param options Some optional paramters + @param onComplete Callback when finish parsing. + + @example + ```js + downloader.downloadFile('test.pkm', {responseType: 'arraybuffer'}, null, (err, file) => { + parser.parsePKMTex(file, null, (err, etcAsset) => console.log(err)); + }); + ``` + */ + parsePKMTex(file: ArrayBuffer|ArrayBufferView, options: Record, onComplete: (err: Error, etcAsset: {_data: Uint8Array, _compressed: boolean, width: number, height: number}) => void): void; + /** + !#en + Parse plist file + + !#zh + 解析 plist 文件 + @param file The downloaded file + @param options Some optional paramters + @param onComplete Callback when finish parsing + + @example + ```js + downloader.downloadFile('test.plist', {responseType: 'text'}, null, (err, file) => { + parser.parsePlist(file, null, (err, data) => console.log(err)); + }); + ``` + */ + parsePlist(file: string, options: Record, onComplete?: (err: Error, data: any) => void): void; + /** + !#en + Deserialize asset file + + !#zh + 反序列化资源文件 + @param file The serialized json + @param options Some optional paramters + @param onComplete Callback when finish parsing + + @example + ```js + downloader.downloadFile('test.json', {responseType: 'json'}, null, (err, file) => { + parser.parseImport(file, null, (err, data) => console.log(err)); + }); + ``` + */ + parseImport (file: any, options: Record, onComplete?: (err: Error, asset: cc.Asset) => void): void; + /** + !#en + Register custom handler if you want to change default behavior or extend parser to parse other format file + + !#zh + 当你想修改默认行为或者拓展 parser 来解析其他格式文件时可以注册自定义的handler + @param type Extension likes '.jpg' or map likes {'.jpg': jpgHandler, '.png': pngHandler} + @param handler The corresponding handler + + @example + ```js + parser.register('.tga', (file, options, onComplete) => onComplete(null, null)); + parser.register({'.tga': (file, options, onComplete) => onComplete(null, null), '.ext': (file, options, onComplete) => onComplete(null, null)}); + ``` + */ + register(type: string, handler: (file: any, options: Record, onComplete: (err: Error, data: any) => void) => void): void; + register(map: Record, onComplete: (err: Error, data: any) => void) => void>): void; + /** + !#en + Use corresponding handler to parse file + + !#zh + 使用对应的handler来解析文件 + @param id The id of file + @param file File + @param type The corresponding type of file, likes '.jpg'. + @param options Some optional paramters will be transferred to the corresponding handler. + @param onComplete callback when finishing downloading + + @example + ```js + downloader.downloadFile('test.jpg', {responseType: 'blob'}, null, (err, file) => { + parser.parse('test.jpg', file, '.jpg', null, (err, img) => console.log(err)); + }); + ``` + */ + parse(id: string, file: any, type: string, options: Record, onComplete: (err: Error, content: any) => void): void; + } + /** !#en + The builtin bundles + + !#zh + 内置 bundle */ + export enum BuiltinBundleName { + RESOURCES = 0, + INTERNAL = 0, + MAIN = 0, + START_SCENE = 0, + } + /** !#en + A collection of information about a request + + !#zh + 请求的相关信息集合 */ + export class RequestItem { + /** !#en + The uuid of request + + !#zh + 请求资源的uuid */ + uuid: string; + /** !#en + The final url of request + + !#zh + 请求的最终url */ + url: string; + /** !#en + The extension name of asset + + !#zh + 资源的扩展名 */ + ext: string; + /** !#en + The content of asset + + !#zh + 资源的内容 */ + content: any; + /** !#en + The file of asset + + !#zh + 资源的文件 */ + file: any; + /** !#en + The information of asset + + !#zh + 资源的相关信息 */ + info: any; + /** !#en + Whether or not it is native asset + + !#zh + 资源是否是原生资源 */ + isNative: boolean; + /** !#en + Custom options + + !#zh + 自定义参数 */ + options: any; + /** + !#en + Create a request item + + !#zh + 创建一个 request item + */ + constructor(); + /** !#en + The id of request, combined from uuid and isNative + + !#zh + 请求的 id, 由 uuid 和 isNative 组合而成 */ + id: string; + /** + !#en + Recycle this for reuse + + !#zh + 回收 requestItem 用于复用 + */ + recycle(): void; + /** + !#en + Create a new request item from pool + + !#zh + 从对象池中创建 requestItem + */ + static create(): RequestItem; + } + /** !#en + Task is used to run in the pipeline for some effect + + !#zh + 任务用于在管线中运行以达成某种效果 */ + export class Task { + /** !#en + The id of task + + !#zh + 任务id */ + id: number; + /** !#en + The callback when task is completed + + !#zh + 完成回调 */ + onComplete: Function; + /** !#en + The callback of progression + + !#zh + 进度回调 */ + onProgress: Function; + /** !#en + The callback when something goes wrong + + !#zh + 错误回调 */ + onError: Function; + /** !#en + The source of task + + !#zh + 任务的源 */ + source: any; + /** !#en + The output of task + + !#zh + 任务的输出 */ + output: any; + /** !#en + The input of task + + !#zh + 任务的输入 */ + input: any; + /** !#en + The progression of task + + !#zh + 任务的进度 */ + progress: any; + /** !#en + Custom options + + !#zh + 自定义参数 */ + options: any; + /** + !#en + Create a new Task + + !#zh + 创建一个任务 + @param options Some optional paramters + */ + constructor(options?: {onComplete?: (err: Error, result: any) => void, onError?: () => void, onProgress?: Function, input: any, progress?: any, options?: Record}); + /** + !#en + Set paramters of this task + + !#zh + 设置任务的参数 + @param options Some optional paramters + + @example + ```js + var task = new Task(); + task.set({input: ['test'], onComplete: (err, result) => console.log(err), onProgress: (finish, total) => console.log(finish / total)}); + ``` + */ + set(options?: {onComplete?: (err: Error, result: any) => void, onError?: () => void, onProgress?: Function, input: any, progress?: any, options?: Record}): void; + /** + !#en + Dispatch event + + !#zh + 发布事件 + @param event The event name + @param param1 Parameter 1 + @param param2 Parameter 2 + @param param3 Parameter 3 + @param param4 Parameter 4 + + @example + ```js + var task = Task.create(); + Task.onComplete = (msg) => console.log(msg); + Task.dispatch('complete', 'hello world'); + ``` + */ + dispatch(event: string, param1?: any, param2?: any, param3?: any, param4?: any): void; + /** + !#en + Recycle this for reuse + + !#zh + 回收 task 用于复用 + */ + recycle(): void; + /** !#en + Whether or not this task is completed + + !#zh + 此任务是否已经完成 */ + isFinish: boolean; + /** + !#en + Create a new task from pool + + !#zh + 从对象池中创建 task + @param options Some optional paramters + */ + static create(options?: {onComplete?: (err: Error, result: any) => void, onError?: () => void, onProgress?: Function, input: any, progress?: any, options?: Record}): Task; + } + /** !#en + Handle the packed asset, include unpacking, loading, cache and so on. It is a singleton. All member can be accessed with `cc.assetManager.packManager` + + !#zh + 处理打包资源,包括拆包,加载,缓存等等,这是一个单例, 所有成员能通过 `cc.assetManager.packManager` 访问 */ + export class PackManager { + /** + !#en + Unpack the json, revert to what it was before packing + + !#zh + 拆解 json 包,恢复为打包之前的内容 + @param pack The pack + @param json The content of pack + @param options Some optional parameters + @param onComplete Callback when finish unpacking + + @example + ```js + downloader.downloadFile('pack.json', {responseType: 'json'}, null, (err, file) => { + packManager.unpackJson(['a', 'b'], file, null, (err, data) => console.log(err)); + }); + ``` + */ + unpackJson(pack: string[], json: any, options: Record, onComplete?: (err: Error, content: any) => void): void; + /** + !#en + Register custom handler if you want to change default behavior or extend packManager to unpack other format pack + + !#zh + 当你想修改默认行为或者拓展 packManager 来拆分其他格式的包时可以注册自定义的 handler + @param type Extension likes '.bin' or map likes {'.bin': binHandler, '.ab': abHandler} + @param handler handler + + @example + ```js + packManager.register('.bin', (packUuid, file, options, onComplete) => onComplete(null, null)); + packManager.register({'.bin': (packUuid, file, options, onComplete) => onComplete(null, null), '.ab': (packUuid, file, options, onComplete) => onComplete(null, null)}); + ``` + */ + register(type: string, handler: (packUuid: string, data: any, options: Record, onComplete: (err: Error, content: any) => void) => void): void; + register(map: Record, onComplete: (err: Error, content: any) => void) => void>): void; + /** + !#en + Use corresponding handler to unpack package + + !#zh + 用对应的 handler 来进行解包 + @param pack The uuid of packed assets + @param data The packed data + @param type The type indicates that which handler should be used to download, such as '.jpg' + @param options Some optional parameter + @param onComplete callback when finishing unpacking + + @example + ```js + downloader.downloadFile('pack.json', {responseType: 'json'}, null, (err, file) => { + packManager.unpack(['2fawq123d', '1zsweq23f'], file, '.json', null, (err, data) => console.log(err)); + }); + ``` + */ + unpack(pack: string[], data: any, type: string, options: Record, onComplete?: (err: Error, data: any) => void): void; + /** + !#en + Download request item, If item is not in any package, download as usual. Otherwise, download the corresponding package and unpack it. + And then retrieve the corresponding content form it. + + !#zh + 下载请求对象,如果请求对象不在任何包内,则正常下载,否则下载对应的 package 并进行拆解,并取回包内对应的内容 + @param item Some item you want to download + @param options Some optional parameters + @param onComplete Callback when finished + + @example + ```js + var requestItem = cc.AssetManager.RequestItem.create(); + requestItem.uuid = 'fcmR3XADNLgJ1ByKhqcC5Z'; + requestItem.info = config.getAssetInfo('fcmR3XADNLgJ1ByKhqcC5Z'); + packManager.load(requestItem, null, (err, data) => console.log(err)); + ``` + */ + load(item: RequestItem, options: Record, onComplete: (err: Error, data: any) => void): void; + } + /** !#en + Pipeline can execute the task for some effect. + + !#zh + 管线能执行任务达到某个效果 */ + export class Pipeline { + /** !#en + The id of pipeline + + !#zh + 管线的 id */ + id: number; + /** !#en + The name of pipeline + + !#zh + 管线的名字 */ + name: string; + /** !#en + All pipes of pipeline + + !#zh + 所有的管道 */ + pipes: Function[]; + /** + !#en + Create a new pipeline + + !#zh + 创建一个管线 + @param name The name of pipeline + @param funcs The array of pipe, every pipe must be function which take two parameters, the first is a `Task` flowed in pipeline, the second is complete callback + + @example + ```js + var pipeline = new Pipeline('download', [ + (task, done) => { + var url = task.input; + cc.assetManager.downloader.downloadFile(url, null, null, (err, result) => { + task.output = result; + done(err); + }); + }, + (task, done) => { + var text = task.input; + var json = JSON.stringify(text); + task.output = json; + done(); + } + ]); + ``` + */ + constructor(name: string, funcs: Array<(task: Task, done?: (err: Error) => void) => void>); + /** + !#en + At specific point insert a new pipe to pipeline + + !#zh + 在某个特定的点为管线插入一个新的 pipe + @param func The new pipe + @param index The specific point you want to insert at. + + @example + ```js + var pipeline = new Pipeline('test', []); + pipeline.insert((task, done) => { + // do something + done(); + }, 0); + ``` + */ + insert(func: (task: Task, callback?: (err: Error) => void) => void, index: number): Pipeline; + /** + !#en + Append a new pipe to the pipeline + + !#zh + 添加一个管道到管线中 + @param func The new pipe + + @example + ```js + var pipeline = new Pipeline('test', []); + pipeline.append((task, done) => { + // do something + done(); + }); + ``` + */ + append(func: (task: Task, callback?: (err: Error) => void) => void): Pipeline; + /** + !#en + Remove pipe which at specific point + + !#zh + 移除特定位置的管道 + @param index The specific point + + @example + ```js + var pipeline = new Pipeline('test', (task, done) => { + // do something + done(); + }); + pipeline.remove(0); + ``` + */ + remove(index: number): Pipeline; + /** + !#en + Execute task synchronously + + !#zh + 同步执行任务 + @param task The task will be executed + + @example + ```js + var pipeline = new Pipeline('sync', [(task) => { + let input = task.input; + task.output = doSomething(task.input); + }]); + + var task = new Task({input: 'test'}); + console.log(pipeline.sync(task)); + ``` + */ + sync(task: Task): any; + /** + !#en + Execute task asynchronously + + !#zh + 异步执行任务 + @param task The task will be executed + + @example + ```js + var pipeline = new Pipeline('sync', [(task, done) => { + let input = task.input; + task.output = doSomething(task.input); + done(); + }]); + var task = new Task({input: 'test', onComplete: (err, result) => console.log(result)}); + pipeline.async(task); + ``` + */ + async(task: Task): void; + } +} + +/** Some helpful utilities */ +declare namespace cc.geomUtils { + /** + !#en + the distance between a point and a plane + !#zh + 计算点和平面之间的距离。 + @param point point + @param plane plane + */ + export function point_plane(point: cc.Vec3, plane: cc.Plane): number; + /** + !#en + the closest point on plane to a given point + !#zh + 计算平面上最接近给定点的点。 + @param out Closest point + @param point Given point + @param plane plane + */ + export function pt_point_plane(out: cc.Vec3, point: cc.Vec3, plane: cc.Plane): cc.Vec3; + /** + !#en + the closest point on aabb to a given point + !#zh + 计算 aabb 上最接近给定点的点。 + @param out Closest point. + @param point Given point. + @param aabb Align the axis around the box. + */ + export function pt_point_aabb(out: cc.Vec3, point: cc.Vec3, aabb: cc.Aabb): cc.Vec3; + /** + !#en + the closest point on obb to a given point + !#zh + 计算 obb 上最接近给定点的点。 + @param out Closest point + @param point Given point + @param obb Direction box + */ + export function pt_point_obb(out: cc.Vec3, point: cc.Vec3, obb: cc.Obb): cc.Vec3; +} + +/** !#en Some JavaScript decorators which can be accessed with "cc._decorator". +!#zh 一些 JavaScript 装饰器,目前可以通过 "cc._decorator" 来访问。 +(这些 API 仍不完全稳定,有可能随着 JavaScript 装饰器的标准实现而调整) */ +declare namespace cc._decorator { + /** + !#en + Declare the standard [ES6 Class](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes) + as CCClass, please see [Class](../../../manual/en/scripting/class.html) for details. + !#zh + 将标准写法的 [ES6 Class](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes) 声明为 CCClass,具体用法请参阅[类型定义](../../../manual/zh/scripting/class.html)。 + @param name The class name used for serialization. + + @example + ```js + const {ccclass} = cc._decorator; + + // define a CCClass, omit the name + @ccclass + class NewScript extends cc.Component { + // ... + } + + // define a CCClass with a name + @ccclass('LoginData') + class LoginData { + // ... + } + ``` + */ + export function ccclass(name?: string): Function; + export function ccclass(_class?: Function): void; + /** + !#en + Declare property for [CCClass](../../../manual/en/scripting/reference/attributes.html). + !#zh + 定义 [CCClass](../../../manual/zh/scripting/reference/attributes.html) 所用的属性。 + @param options an object with some property attributes + + @example + ```js + const {ccclass, property} = cc._decorator; + + @ccclass + class NewScript extends cc.Component { + @property({ + type: cc.Node + }) + targetNode1 = null; + + @property(cc.Node) + targetNode2 = null; + + @property(cc.Button) + targetButton = null; + + @property + _width = 100; + + @property + get width () { + return this._width; + } + + @property + set width (value) { + this._width = value; + } + + @property + offset = new cc.Vec2(100, 100); + + @property(cc.Vec2) + offsets = []; + + @property(cc.SpriteFrame) + frame = null; + } + + // above is equivalent to (上面的代码相当于): + + var NewScript = cc.Class({ + properties: { + targetNode1: { + default: null, + type: cc.Node + }, + + targetNode2: { + default: null, + type: cc.Node + }, + + targetButton: { + default: null, + type: cc.Button + }, + + _width: 100, + + width: { + get () { + return this._width; + }, + set (value) { + this._width = value; + } + }, + + offset: new cc.Vec2(100, 100) + + offsets: { + default: [], + type: cc.Vec2 + } + + frame: { + default: null, + type: cc.SpriteFrame + }, + } + }); + ``` + */ + export function property(options?: {type?: any; visible?: boolean|(() => boolean); displayName?: string; tooltip?: string; multiline?: boolean; readonly?: boolean; min?: number; max?: number; step?: number; range?: number[]; slide?: boolean; serializable?: boolean; formerlySerializedAs?: string; editorOnly?: boolean; override?: boolean; animatable?: boolean} | any[]|Function|cc.ValueType|number|string|boolean): Function; + export function property(_target: Object, _key: any, _desc?: any): void; + /** + !#en + Makes a CCClass that inherit from component execute in edit mode.
+ By default, all components are only executed in play mode, + which means they will not have their callback functions executed while the Editor is in edit mode. + !#zh + 允许继承自 Component 的 CCClass 在编辑器里执行。
+ 默认情况下,所有 Component 都只会在运行时才会执行,也就是说它们的生命周期回调不会在编辑器里触发。 + + @example + ```js + const {ccclass, executeInEditMode} = cc._decorator; + + @ccclass + @executeInEditMode + class NewScript extends cc.Component { + // ... + } + ``` + */ + export function executeInEditMode(): Function; + export function executeInEditMode(_class: Function): void; + /** + !#en + Automatically add required component as a dependency for the CCClass that inherit from component. + !#zh + 为声明为 CCClass 的组件添加依赖的其它组件。当组件添加到节点上时,如果依赖的组件不存在,引擎将会自动将依赖组件添加到同一个节点,防止脚本出错。该设置在运行时同样有效。 + @param requiredComponent requiredComponent + + @example + ```js + const {ccclass, requireComponent} = cc._decorator; + + @ccclass + @requireComponent(cc.Sprite) + class SpriteCtrl extends cc.Component { + // ... + } + ``` + */ + export function requireComponent(requiredComponent: typeof cc.Component): Function; + /** + !#en + The menu path to register a component to the editors "Component" menu. Eg. "Rendering/CameraCtrl". + !#zh + 将当前组件添加到组件菜单中,方便用户查找。例如 "Rendering/CameraCtrl"。 + @param path The path is the menu represented like a pathname. + For example the menu could be "Rendering/CameraCtrl". + + @example + ```js + const {ccclass, menu} = cc._decorator; + + @ccclass + @menu("Rendering/CameraCtrl") + class NewScript extends cc.Component { + // ... + } + ``` + */ + export function menu(path: string): Function; + /** + !#en + The execution order of lifecycle methods for Component. + Those less than 0 will execute before while those greater than 0 will execute after. + The order will only affect onLoad, onEnable, start, update and lateUpdate while onDisable and onDestroy will not be affected. + !#zh + 设置脚本生命周期方法调用的优先级。优先级小于 0 的组件将会优先执行,优先级大于 0 的组件将会延后执行。优先级仅会影响 onLoad, onEnable, start, update 和 lateUpdate,而 onDisable 和 onDestroy 不受影响。 + @param order The execution order of lifecycle methods for Component. Those less than 0 will execute before while those greater than 0 will execute after. + + @example + ```js + const {ccclass, executionOrder} = cc._decorator; + + @ccclass + @executionOrder(1) + class CameraCtrl extends cc.Component { + // ... + } + ``` + */ + export function executionOrder(order: number): Function; + /** + !#en + Prevents Component of the same type (or subtype) to be added more than once to a Node. + !#zh + 防止多个相同类型(或子类型)的组件被添加到同一个节点。 + + @example + ```js + const {ccclass, disallowMultiple} = cc._decorator; + + @ccclass + @disallowMultiple + class CameraCtrl extends cc.Component { + // ... + } + ``` + */ + export function disallowMultiple(): Function; + export function disallowMultiple(_class: Function): void; + /** + !#en + If specified, the editor's scene view will keep updating this node in 60 fps when it is selected, otherwise, it will update only if necessary.
+ This property is only available if executeInEditMode is true. + !#zh + 当指定了 "executeInEditMode" 以后,playOnFocus 可以在选中当前组件所在的节点时,提高编辑器的场景刷新频率到 60 FPS,否则场景就只会在必要的时候进行重绘。 + + @example + ```js + const {ccclass, playOnFocus, executeInEditMode} = cc._decorator; + + @ccclass + @executeInEditMode + @playOnFocus + class CameraCtrl extends cc.Component { + // ... + } + ``` + */ + export function playOnFocus(): Function; + export function playOnFocus(_class: Function): void; + /** + !#en + Specifying the url of the custom html to draw the component in **Properties**. + !#zh + 自定义当前组件在 **属性检查器** 中渲染时所用的网页 url。 + @param url url + + @example + ```js + const {ccclass, inspector} = cc._decorator; + + @ccclass + @inspector("packages://inspector/inspectors/comps/camera-ctrl.js") + class NewScript extends cc.Component { + // ... + } + ``` + */ + export function inspector(path: string): Function; + /** + !#en + The custom documentation URL. + !#zh + 指定当前组件的帮助文档的 url,设置过后,在 **属性检查器** 中就会出现一个帮助图标,用户点击将打开指定的网页。 + @param url url + + @example + ```js + const {ccclass, help} = cc._decorator; + + @ccclass + @help("app://docs/html/components/spine.html") + class NewScript extends cc.Component { + // ... + } + ``` + */ + export function help(path: string): Function; + /** + NOTE:
+ The old mixins implemented in cc.Class(ES5) behaves exact the same as multiple inheritance. + But since ES6, class constructor can't be function-called and class methods become non-enumerable, + so we can not mix in ES6 Classes.
+ See:
+ [https://esdiscuss.org/topic/traits-are-now-impossible-in-es6-until-es7-since-rev32](https://esdiscuss.org/topic/traits-are-now-impossible-in-es6-until-es7-since-rev32)
+ One possible solution (but IDE unfriendly):
+ [http://justinfagnani.com/2015/12/21/real-mixins-with-javascript-classes](http://justinfagnani.com/2015/12/21/real-mixins-with-javascript-classes/)
+
+ NOTE:
+ You must manually call mixins constructor, this is different from cc.Class(ES5). + @param ctor constructors to mix, only support ES5 constructors or classes defined by using `cc.Class`, + not support ES6 Classes. + + @example + ```js + const {ccclass, mixins} = cc._decorator; + + class Animal { ... } + + const Fly = cc.Class({ + constructor () { ... } + }); + + @ccclass + @mixins(cc.EventTarget, Fly) + class Bird extends Animal { + constructor () { + super(); + + // You must manually call mixins constructor, this is different from cc.Class(ES5) + cc.EventTarget.call(this); + Fly.call(this); + } + // ... + } + ``` + */ + export function mixins(ctor: Function, ...rest: Function[]): Function; +} + +/** !#en This module provides some JavaScript utilities. All members can be accessed with `cc.js`. +!#zh 这个模块封装了 JavaScript 相关的一些实用函数,你可以通过 `cc.js` 来访问这个模块。 */ +declare namespace cc.js { + /** + Check the obj whether is number or not + If a number is created by using 'new Number(10086)', the typeof it will be "object"... + Then you can use this function if you care about this case. + @param obj obj + */ + export function isNumber(obj: any): boolean; + /** + Check the obj whether is string or not. + If a string is created by using 'new String("blabla")', the typeof it will be "object"... + Then you can use this function if you care about this case. + @param obj obj + */ + export function isString(obj: any): boolean; + /** + Copy all properties not defined in obj from arguments[1...n] + @param obj object to extend its properties + @param sourceObj source object to copy properties from + */ + export function addon(obj: any, ...sourceObj: any[]): any; + /** + copy all properties from arguments[1...n] to obj + @param obj obj + @param sourceObj sourceObj + */ + export function mixin(obj: any, ...sourceObj: any[]): any; + /** + Derive the class from the supplied base class. + Both classes are just native javascript constructors, not created by cc.Class, so + usually you will want to inherit using {{#crossLink "cc/Class:method"}}cc.Class {{/crossLink}} instead. + @param cls cls + @param base the baseclass to inherit + */ + export function extend(cls: Function, base: Function): Function; + /** + Get super class + @param ctor the constructor of subclass + */ + export function getSuper(ctor: Function): Function; + /** + Checks whether subclass is child of superclass or equals to superclass + @param subclass subclass + @param superclass superclass + */ + export function isChildClassOf(subclass: Function, superclass: Function): boolean; + /** + Removes all enumerable properties from object + @param obj obj + */ + export function clear(obj: any): void; + /** + Checks whether obj is an empty object + @param obj obj + */ + export function isEmptyObject(obj: any): boolean; + /** + Get property descriptor in object and all its ancestors + @param obj obj + @param name name + */ + export function getPropertyDescriptor(obj: any, name: string): any; + /** + Define value, just help to call Object.defineProperty.
+ The configurable will be true. + @param obj obj + @param prop prop + @param value value + @param writable writable + @param enumerable enumerable + */ + export function value(obj: any, prop: string, value: any, writable?: boolean, enumerable?: boolean): void; + /** + Define get set accessor, just help to call Object.defineProperty(...) + @param obj obj + @param prop prop + @param getter getter + @param setter setter + @param enumerable enumerable + @param configurable configurable + */ + export function getset(obj: any, prop: string, getter: Function, setter?: Function, enumerable?: boolean, configurable?: boolean): void; + /** + Define get accessor, just help to call Object.defineProperty(...) + @param obj obj + @param prop prop + @param getter getter + @param enumerable enumerable + @param configurable configurable + */ + export function get(obj: any, prop: string, getter: Function, enumerable?: boolean, configurable?: boolean): void; + /** + Define set accessor, just help to call Object.defineProperty(...) + @param obj obj + @param prop prop + @param setter setter + @param enumerable enumerable + @param configurable configurable + */ + export function set(obj: any, prop: string, setter: Function, enumerable?: boolean, configurable?: boolean): void; + /** + Get class name of the object, if object is just a {} (and which class named 'Object'), it will return "". + (modified from the code from this stackoverflow post) + @param objOrCtor instance or constructor + */ + export function getClassName(objOrCtor: any|Function): string; + /** !#en All classes registered in the engine, indexed by ID. + !#zh 引擎中已注册的所有类型,通过 ID 进行索引。 */ + export var _registeredClassIds: any; + /** !#en All classes registered in the engine, indexed by name. + !#zh 引擎中已注册的所有类型,通过名称进行索引。 */ + export var _registeredClassNames: any; + /** + Register the class by specified name manually + @param className className + @param constructor constructor + */ + export function setClassName(className: string, constructor: Function): void; + /** + Unregister a class from fireball. + + If you dont need a registered class anymore, you should unregister the class so that Fireball will not keep its reference anymore. + Please note that its still your responsibility to free other references to the class. + @param constructor the class you will want to unregister, any number of classes can be added + */ + export function unregisterClass(...constructor: Function[]): void; + /** + Get the registered class by name + @param classname classname + */ + export function getClassByName(classname: string): Function; + /** + Defines a polyfill field for deprecated codes. + @param obj YourObject or YourClass.prototype + @param obsoleted "OldParam" or "YourClass.OldParam" + @param newExpr "NewParam" or "YourClass.NewParam" + @param writable writable + */ + export function obsolete(obj: any, obsoleted: string, newExpr: string, writable?: boolean): void; + /** + Defines all polyfill fields for obsoleted codes corresponding to the enumerable properties of props. + @param obj YourObject or YourClass.prototype + @param objName "YourObject" or "YourClass" + @param props props + @param writable writable + */ + export function obsoletes(obj: any, objName: any, props: any, writable?: boolean): void; + /** + A string tool to construct a string with format string. + @param msg A JavaScript string containing zero or more substitution strings (%s). + @param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output. + + @example + ```js + cc.js.formatStr("a: %s, b: %s", a, b); + cc.js.formatStr(a, b, c); + ``` + */ + export function formatStr(msg: string|any, ...subst: any[]): string; + /** + !#en + A simple wrapper of `Object.create(null)` which ensures the return object have no prototype (and thus no inherited members). So we can skip `hasOwnProperty` calls on property lookups. It is a worthwhile optimization than the `{}` literal when `hasOwnProperty` calls are necessary. + !#zh + 该方法是对 `Object.create(null)` 的简单封装。`Object.create(null)` 用于创建无 prototype (也就无继承)的空对象。这样我们在该对象上查找属性时,就不用进行 `hasOwnProperty` 判断。在需要频繁判断 `hasOwnProperty` 时,使用这个方法性能会比 `{}` 更高。 + @param forceDictMode Apply the delete operator to newly created map object. This causes V8 to put the object in "dictionary mode" and disables creation of hidden classes which are very expensive for objects that are constantly changing shape. + */ + export function createMap(forceDictMode?: boolean): any; + /** undefined */ + export class array { + /** + Removes the array item at the specified index. + @param array array + @param index index + */ + static removeAt(array: any[], index: number): void; + /** + Removes the array item at the specified index. + It's faster but the order of the array will be changed. + @param array array + @param index index + */ + static fastRemoveAt(array: any[], index: number): void; + /** + Removes the first occurrence of a specific object from the array. + @param array array + @param value value + */ + static remove(array: any[], value: any): boolean; + /** + Removes the first occurrence of a specific object from the array. + It's faster but the order of the array will be changed. + @param array array + @param value value + */ + static fastRemove(array: any[], value: number): void; + /** + Verify array's Type + @param array array + @param type type + */ + static verifyType(array: any[], type: Function): boolean; + /** + Removes from array all values in minusArr. For each Value in minusArr, the first matching instance in array will be removed. + @param array Source Array + @param minusArr minus Array + */ + static removeArray(array: any[], minusArr: any[]): void; + /** + Inserts some objects at index + @param array array + @param addObjs addObjs + @param index index + */ + static appendObjectsAt(array: any[], addObjs: any[], index: number): any[]; + /** + Determines whether the array contains a specific value. + @param array array + @param value value + */ + static contains(array: any[], value: any): boolean; + /** + Copy an array's item to a new array (its performance is better than Array.slice) + @param array array + */ + static copy(array: any[]): any[]; + } + /** !#en + A fixed-length object pool designed for general type.
+ The implementation of this object pool is very simple, + it can helps you to improve your game performance for objects which need frequent release and recreate operations
+ !#zh + 长度固定的对象缓存池,可以用来缓存各种对象类型。
+ 这个对象池的实现非常精简,它可以帮助您提高游戏性能,适用于优化对象的反复创建和销毁。 */ + export class Pool { + /** + !#en + Constructor for creating an object pool for the specific object type. + You can pass a callback argument for process the cleanup logic when the object is recycled. + !#zh + 使用构造函数来创建一个指定对象类型的对象池,您可以传递一个回调函数,用于处理对象回收时的清理逻辑。 + @param cleanupFunc the callback method used to process the cleanup logic when the object is recycled. + @param size initializes the length of the array + */ + constructor(cleanupFunc: (obj: any) => void, size: number); + constructor(size: number); + /** + !#en + Get and initialize an object from pool. This method defaults to null and requires the user to implement it. + !#zh + 获取并初始化对象池中的对象。这个方法默认为空,需要用户自己实现。 + @param params parameters to used to initialize the object + */ + get(...params: any[]): any; + /** !#en + The current number of available objects, the default is 0, it will gradually increase with the recycle of the object, + the maximum will not exceed the size specified when the constructor is called. + !#zh + 当前可用对象数量,一开始默认是 0,随着对象的回收会逐渐增大,最大不会超过调用构造函数时指定的 size。 */ + count: number; + /** + !#en + Get an object from pool, if no available object in the pool, null will be returned. + !#zh + 获取对象池中的对象,如果对象池没有可用对象,则返回空。 + */ + _get(): any; + /** + !#en Put an object into the pool. + !#zh 向对象池返还一个不再需要的对象。 + */ + put(): void; + /** + !#en Resize the pool. + !#zh 设置对象池容量。 + */ + resize(): void; + } +} + +/** !#en A basic module for creating vertex data for 3D objects. You can access this module by `cc.primitive`. +!#zh 一个创建 3D 物体顶点数据的基础模块,你可以通过 `cc.primitive` 来访问这个模块。 */ +declare namespace cc.primitive { + /** + !#en Create box vertex data + !#zh 创建长方体顶点数据 + @param width width + @param height height + @param length length + @param opts opts + */ + export function box(width: number, height: number, length: number, opts: {widthSegments: number; heightSegments: number; lengthSegments: number; }): cc.VertexData; + /** + !#en Create cone vertex data + !#zh 创建圆锥体顶点数据 + @param radius radius + @param height height + @param opts opts + */ + export function cone(radius: number, height: number, opts: {radialSegments: number; heightSegments: number; capped: boolean; arc: number; }): cc.VertexData; + /** + !#en Create cylinder vertex data + !#zh 创建圆柱体顶点数据 + @param radiusTop radiusTop + @param radiusBottom radiusBottom + @param height height + @param opts opts + */ + export function cylinder(radiusTop: number, radiusBottom: number, height: number, opts: {radialSegments: number; heightSegments: number; capped: boolean; arc: number; }): cc.VertexData; + /** + !#en Create plane vertex data + !#zh 创建平台顶点数据 + @param width width + @param length length + @param opts opts + */ + export function plane(width: number, length: number, opts: {widthSegments: number; lengthSegments: number; }): cc.VertexData; + /** + !#en Create quad vertex data + !#zh 创建面片顶点数据 + */ + export function quad(): cc.VertexData; + /** + !#en Create sphere vertex data + !#zh 创建球体顶点数据 + @param radius radius + @param opts opts + */ + export function sphere(radius: number, opts: {segments: number; }): cc.VertexData; + /** + !#en Create torus vertex data + !#zh 创建圆环顶点数据 + @param radius radius + @param tube tube + @param opts opts + */ + export function torus(radius: number, tube: number, opts: {radialSegments: number; tubularSegments: number; arc: number; }): cc.VertexData; + /** + !#en Create capsule vertex data + !#zh 创建胶囊体顶点数据 + @param radiusTop radiusTop + @param radiusBottom radiusBottom + @param height height + @param opts opts + */ + export function capsule(radiusTop: number, radiusBottom: number, height: number, opts: {sides: number; heightSegments: number; capped: boolean; arc: number; }): cc.VertexData; + /** + !#en Create polyhedron vertex data + !#zh 创建多面体顶点数据 + @param type type + @param Size Size + @param opts opts + */ + export function polyhedron(type: cc.primitive.PolyhedronType, Size: number, opts: {sizeX: number; sizeY: number; sizeZ: number; }): cc.VertexData; +} + +declare let CC_JSB: boolean +declare let CC_NATIVERENDERER: boolean +declare let CC_EDITOR: boolean + +declare let cc: { + // polyfills: { + // destroyObject? (object: any): void; + // }; + [x: string]: any; +} + +// https://medium.com/dailyjs/typescript-create-a-condition-based-subset-types-9d902cea5b8c +type FlagExcludedType = { [Key in keyof Base]: Base[Key] extends Type ? never : Key }; +type AllowedNames = FlagExcludedType[keyof Base]; +type KeyPartial = { [P in K]?: T[P] }; +type OmitType = KeyPartial>; +type ConstructorType = OmitType; + +declare interface IWritableArrayLike { + readonly length: number; + [index: number]: T; +} + +declare let module: { + exports: object +} + + +declare interface Math { + sign(v: number); +} + +declare interface Object { + assign(target: {}, source: {}); +} + +/** + * @module cc.AssetManager + */ + +declare namespace cc.AssetManager { + /** + * !#en + * Cache manager is a module which controls all caches downloaded from server in non-web platform, it is a singleton + * All member can be accessed with `cc.assetManager.cacheManager`. + * + * !#zh + * 缓存管理器是一个模块,在非 WEB 平台上,用于管理所有从服务器上下载下来的缓存,这是一个单例,所有成员能通过 `cc.assetManager.cacheManager` 访问。 + * + * @class CacheManager + */ + class CacheManager { + /** + * !#en + * The name of cacheDir + * + * !#zh + * 缓存目录的名称 + * + * @property cacheDir + * @type {String} + * @default 'gamecaches' + */ + public cacheDir: String; + + /** + * !#en + * Whether or not cache asset into user's storage space, this property only works on mini-game platforms + * + * !#zh + * 是否缓存资源到用户存储空间,此属性只在小游戏平台有效 + * + * @property cacheEnabled + * @type {Boolean} + * @default true + */ + public cacheEnabled: Boolean; + + /** + * !#en + * Whether or not auto clear cache when storage ran out, this property only works on mini-game platforms + * + * !#zh + * 是否在存储空间满了后自动清理缓存,此属性只在小游戏平台有效 + * + * @property autoClear + * @type {Boolean} + * @default true + */ + public autoClear: Boolean; + + /** + * !#en + * The interval between caching resources, this property only works on mini-game platforms + * + * !#zh + * 缓存资源的间隔时间,此属性只在小游戏平台有效 + * + * @property cacheInterval + * @type {Number} + * @default 500 + */ + public cacheInterval: Number; + + /** + * !#en + * The interval between deleting resources, when you use `cleanLRU`, the resources will be deleted as this interval + * + * !#zh + * 清理资源的间隔时间,当你使用 `cleanLRU` 时,资源将以此间隔被删除 + * + * @property deleteInterval + * @type {Number} + * @default 500 + */ + public deleteInterval: Number; + + /** + * !#en + * Get cached path with origin url + * + * !#zh + * 通过原始 url 获取缓存后的路径 + * + * @method getCache + * @param {string} originUrl + * @returns {String} The cached path + */ + public getCache (originUrl: string): string; + + /** + * !#en + * Get temporary path with origin url, this method only works on mini-game platforms + * + * !#zh + * 通过原始 url 获取临时文件的路径,此方法只在小游戏平台有效 + * + * @method getTemp + * @param {string} originUrl + * @returns {String} The temp path + */ + public getTemp (originUrl: string): string; + + /** + * !#en + * Clear all caches, please use with caution, If necessary, we recommend using it before the game is launched + * + * !#zh + * 清空所有缓存,请谨慎使用,如果必要的话,我们建议在游戏启动之前使用 + * + * @method clearCache + */ + public clearCache (): void; + + /** + * !#en + * Clear part of caches with LRU strategy + * + * !#zh + * 使用 LRU 策略清空部分缓存 + * + * @method clearLRU + */ + public clearLRU (): void; + + /** + * !#en + * Remove cache with origin url + * + * !#zh + * 通过原始 url 移除缓存 + * + * @method removeCache + */ + public removeCache (originUrl: string): void; + } +} + +type FloatArray = Float64Array | Float32Array; + +interface IColorLike { + r: number; + g: number; + b: number; + a: number; + _val: number; + +} + +interface IMat3Like { + m: FloatArray +} + +interface IMat4Like { + m: FloatArray +} + +interface IQuatLike { + x: number; + y: number; + z: number; + w: number; +} + +interface IRectLike { + x: number; + y: number; + width: number; + height: number; +} + +interface ISizeLike { + width: number; + height: number; +} + +interface IVec2Like { + x: number; + y: number; +} + +interface IVec3Like { + x: number; + y: number; + z: number; +} + +interface IVec4Like { + x: number; + y: number; + z: number; + w: number; +} +declare namespace dragonBones { + /** + * @internal + * @private + */ + const webAssemblyModule: { + HEAP16: Int16Array; + _malloc(byteSize: number): number; + _free(pointer: number): void; + setDataBinary(data: DragonBonesData, binaryPointer: number, intBytesLength: number, floatBytesLength: number, frameIntBytesLength: number, frameFloatBytesLength: number, frameBytesLength: number, timelineBytesLength: number): void; + }; +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + const enum BinaryOffset { + WeigthBoneCount = 0, + WeigthFloatOffset = 1, + WeigthBoneIndices = 2, + MeshVertexCount = 0, + MeshTriangleCount = 1, + MeshFloatOffset = 2, + MeshWeightOffset = 3, + MeshVertexIndices = 4, + TimelineScale = 0, + TimelineOffset = 1, + TimelineKeyFrameCount = 2, + TimelineFrameValueCount = 3, + TimelineFrameValueOffset = 4, + TimelineFrameOffset = 5, + FramePosition = 0, + FrameTweenType = 1, + FrameTweenEasingOrCurveSampleCount = 2, + FrameCurveSamples = 3, + DeformMeshOffset = 0, + DeformCount = 1, + DeformValueCount = 2, + DeformValueOffset = 3, + DeformFloatOffset = 4, + } + /** + * @internal + * @private + */ + const enum ArmatureType { + Armature = 0, + MovieClip = 1, + Stage = 2, + } + /** + * @internal + * @private + */ + const enum BoneType { + Bone = 0, + Surface = 1, + } + /** + * @private + */ + const enum DisplayType { + Image = 0, + Armature = 1, + Mesh = 2, + BoundingBox = 3, + } + /** + * - Bounding box type. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 边界框类型。 + * @version DragonBones 5.0 + * @language zh_CN + */ + const enum BoundingBoxType { + Rectangle = 0, + Ellipse = 1, + Polygon = 2, + } + /** + * @internal + * @private + */ + const enum ActionType { + Play = 0, + Frame = 10, + Sound = 11, + } + /** + * @internal + * @private + */ + const enum BlendMode { + Normal = 0, + Add = 1, + Alpha = 2, + Darken = 3, + Difference = 4, + Erase = 5, + HardLight = 6, + Invert = 7, + Layer = 8, + Lighten = 9, + Multiply = 10, + Overlay = 11, + Screen = 12, + Subtract = 13, + } + /** + * @internal + * @private + */ + const enum TweenType { + None = 0, + Line = 1, + Curve = 2, + QuadIn = 3, + QuadOut = 4, + QuadInOut = 5, + } + /** + * @internal + * @private + */ + const enum TimelineType { + Action = 0, + ZOrder = 1, + BoneAll = 10, + BoneTranslate = 11, + BoneRotate = 12, + BoneScale = 13, + Surface = 50, + SlotDisplay = 20, + SlotColor = 21, + SlotFFD = 22, + IKConstraint = 30, + AnimationTime = 40, + AnimationWeight = 41, + } + /** + * - Offset mode. + * @version DragonBones 5.5 + * @language en_US + */ + /** + * - 偏移模式。 + * @version DragonBones 5.5 + * @language zh_CN + */ + const enum OffsetMode { + None = 0, + Additive = 1, + Override = 2, + } + /** + * - Animation fade out mode. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画淡出模式。 + * @version DragonBones 4.5 + * @language zh_CN + */ + const enum AnimationFadeOutMode { + /** + * - Do not fade out of any animation states. + * @language en_US + */ + /** + * - 不淡出任何的动画状态。 + * @language zh_CN + */ + None = 0, + /** + * - Fade out the animation states of the same layer. + * @language en_US + */ + /** + * - 淡出同层的动画状态。 + * @language zh_CN + */ + SameLayer = 1, + /** + * - Fade out the animation states of the same group. + * @language en_US + */ + /** + * - 淡出同组的动画状态。 + * @language zh_CN + */ + SameGroup = 2, + /** + * - Fade out the animation states of the same layer and group. + * @language en_US + */ + /** + * - 淡出同层并且同组的动画状态。 + * @language zh_CN + */ + SameLayerAndGroup = 3, + /** + * - Fade out of all animation states. + * @language en_US + */ + /** + * - 淡出所有的动画状态。 + * @language zh_CN + */ + All = 4, + /** + * - Does not replace the animation state with the same name. + * @language en_US + */ + /** + * - 不替换同名的动画状态。 + * @language zh_CN + */ + Single = 5, + } + /** + * @private + */ + interface Map { + [key: string]: T; + } + /** + * @private + */ + class DragonBones { + static readonly VERSION: string; + static yDown: boolean; + static debug: boolean; + static debugDraw: boolean; + static webAssembly: boolean; + private readonly _clock; + private readonly _events; + private readonly _objects; + private _eventManager; + constructor(eventManager: IEventDispatcher); + advanceTime(passedTime: number): void; + bufferEvent(value: EventObject): void; + bufferObject(object: BaseObject): void; + readonly clock: WorldClock; + readonly eventManager: IEventDispatcher; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The BaseObject is the base class for all objects in the DragonBones framework. + * All BaseObject instances are cached to the object pool to reduce the performance consumption of frequent requests for memory or memory recovery. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 基础对象,通常 DragonBones 的对象都继承自该类。 + * 所有基础对象的实例都会缓存到对象池,以减少频繁申请内存或内存回收的性能消耗。 + * @version DragonBones 4.5 + * @language zh_CN + */ + abstract class BaseObject { + private static _hashCode; + private static _defaultMaxCount; + private static readonly _maxCountMap; + private static readonly _poolsMap; + private static _returnObject(object); + static toString(): string; + /** + * - Set the maximum cache count of the specify object pool. + * @param objectConstructor - The specify class. (Set all object pools max cache count if not set) + * @param maxCount - Max count. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 设置特定对象池的最大缓存数量。 + * @param objectConstructor - 特定的类。 (不设置则设置所有对象池的最大缓存数量) + * @param maxCount - 最大缓存数量。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static setMaxCount(objectConstructor: (typeof BaseObject) | null, maxCount: number): void; + /** + * - Clear the cached instances of a specify object pool. + * @param objectConstructor - Specify class. (Clear all cached instances if not set) + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 清除特定对象池的缓存实例。 + * @param objectConstructor - 特定的类。 (不设置则清除所有缓存的实例) + * @version DragonBones 4.5 + * @language zh_CN + */ + static clearPool(objectConstructor?: (typeof BaseObject) | null): void; + /** + * - Get an instance of the specify class from object pool. + * @param objectConstructor - The specify class. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 从对象池中获取特定类的实例。 + * @param objectConstructor - 特定的类。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static borrowObject(objectConstructor: { + new (): T; + }): T; + /** + * - A unique identification number assigned to the object. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 分配给此实例的唯一标识号。 + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly hashCode: number; + private _isInPool; + /** + * @private + */ + protected abstract _onClear(): void; + /** + * - Clear the object and return it back to object pool。 + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 清除该实例的所有数据并将其返还对象池。 + * @version DragonBones 4.5 + * @language zh_CN + */ + returnToPool(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - 2D Transform matrix. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 2D 转换矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class Matrix { + /** + * - The value that affects the positioning of pixels along the x axis when scaling or rotating an image. + * @default 1.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 缩放或旋转图像时影响像素沿 x 轴定位的值。 + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + a: number; + /** + * - The value that affects the positioning of pixels along the y axis when rotating or skewing an image. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 旋转或倾斜图像时影响像素沿 y 轴定位的值。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + b: number; + /** + * - The value that affects the positioning of pixels along the x axis when rotating or skewing an image. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 旋转或倾斜图像时影响像素沿 x 轴定位的值。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + c: number; + /** + * - The value that affects the positioning of pixels along the y axis when scaling or rotating an image. + * @default 1.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 缩放或旋转图像时影响像素沿 y 轴定位的值。 + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + d: number; + /** + * - The distance by which to translate each point along the x axis. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 沿 x 轴平移每个点的距离。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + tx: number; + /** + * - The distance by which to translate each point along the y axis. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 沿 y 轴平移每个点的距离。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + ty: number; + /** + * @private + */ + constructor(a?: number, b?: number, c?: number, d?: number, tx?: number, ty?: number); + toString(): string; + /** + * @private + */ + copyFrom(value: Matrix): Matrix; + /** + * @private + */ + copyFromArray(value: Array, offset?: number): Matrix; + /** + * - Convert to unit matrix. + * The resulting matrix has the following properties: a=1, b=0, c=0, d=1, tx=0, ty=0. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 转换为单位矩阵。 + * 该矩阵具有以下属性:a=1、b=0、c=0、d=1、tx=0、ty=0。 + * @version DragonBones 3.0 + * @language zh_CN + */ + identity(): Matrix; + /** + * - Multiplies the current matrix with another matrix. + * @param value - The matrix that needs to be multiplied. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 将当前矩阵与另一个矩阵相乘。 + * @param value - 需要相乘的矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + concat(value: Matrix): Matrix; + /** + * - Convert to inverse matrix. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 转换为逆矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + invert(): Matrix; + /** + * - Apply a matrix transformation to a specific point. + * @param x - X coordinate. + * @param y - Y coordinate. + * @param result - The point after the transformation is applied. + * @param delta - Whether to ignore tx, ty's conversion to point. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 将矩阵转换应用于特定点。 + * @param x - 横坐标。 + * @param y - 纵坐标。 + * @param result - 应用转换之后的点。 + * @param delta - 是否忽略 tx,ty 对点的转换。 + * @version DragonBones 3.0 + * @language zh_CN + */ + transformPoint(x: number, y: number, result: { + x: number; + y: number; + }, delta?: boolean): void; + /** + * @private + */ + transformRectangle(rectangle: { + x: number; + y: number; + width: number; + height: number; + }, delta?: boolean): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - 2D Transform. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 2D 变换。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class Transform { + /** + * @private + */ + static readonly PI: number; + /** + * @private + */ + static readonly PI_D: number; + /** + * @private + */ + static readonly PI_H: number; + /** + * @private + */ + static readonly PI_Q: number; + /** + * @private + */ + static readonly RAD_DEG: number; + /** + * @private + */ + static readonly DEG_RAD: number; + /** + * @private + */ + static normalizeRadian(value: number): number; + /** + * - Horizontal translate. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 水平位移。 + * @version DragonBones 3.0 + * @language zh_CN + */ + x: number; + /** + * - Vertical translate. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 垂直位移。 + * @version DragonBones 3.0 + * @language zh_CN + */ + y: number; + /** + * - Skew. (In radians) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 倾斜。 (以弧度为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + skew: number; + /** + * - rotation. (In radians) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 旋转。 (以弧度为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + rotation: number; + /** + * - Horizontal Scaling. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 水平缩放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + scaleX: number; + /** + * - Vertical scaling. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 垂直缩放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + scaleY: number; + /** + * @private + */ + constructor(x?: number, y?: number, skew?: number, rotation?: number, scaleX?: number, scaleY?: number); + toString(): string; + /** + * @private + */ + copyFrom(value: Transform): Transform; + /** + * @private + */ + identity(): Transform; + /** + * @private + */ + add(value: Transform): Transform; + /** + * @private + */ + minus(value: Transform): Transform; + /** + * @private + */ + fromMatrix(matrix: Matrix): Transform; + /** + * @private + */ + toMatrix(matrix: Matrix): Transform; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + class ColorTransform { + alphaMultiplier: number; + redMultiplier: number; + greenMultiplier: number; + blueMultiplier: number; + alphaOffset: number; + redOffset: number; + greenOffset: number; + blueOffset: number; + constructor(alphaMultiplier?: number, redMultiplier?: number, greenMultiplier?: number, blueMultiplier?: number, alphaOffset?: number, redOffset?: number, greenOffset?: number, blueOffset?: number); + copyFrom(value: ColorTransform): void; + identity(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The Point object represents a location in a two-dimensional coordinate system. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - Point 对象表示二维坐标系统中的某个位置。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class Point { + /** + * - The horizontal coordinate. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 该点的水平坐标。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + x: number; + /** + * - The vertical coordinate. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 该点的垂直坐标。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + y: number; + /** + * - Creates a new point. If you pass no parameters to this method, a point is created at (0,0). + * @param x - The horizontal coordinate. + * @param y - The vertical coordinate. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 创建一个 egret.Point 对象.若不传入任何参数,将会创建一个位于(0,0)位置的点。 + * @param x - 该对象的x属性值,默认为 0.0。 + * @param y - 该对象的y属性值,默认为 0.0。 + * @version DragonBones 3.0 + * @language zh_CN + */ + constructor(x?: number, y?: number); + /** + * @private + */ + copyFrom(value: Point): void; + /** + * @private + */ + clear(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - A Rectangle object is an area defined by its position, as indicated by its top-left corner point (x, y) and by its + * width and its height.
+ * The x, y, width, and height properties of the Rectangle class are independent of each other; changing the value of + * one property has no effect on the others. However, the right and bottom properties are integrally related to those + * four properties. For example, if you change the value of the right property, the value of the width property changes; + * if you change the bottom property, the value of the height property changes. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - Rectangle 对象是按其位置(由它左上角的点 (x, y) 确定)以及宽度和高度定义的区域。
+ * Rectangle 类的 x、y、width 和 height 属性相互独立;更改一个属性的值不会影响其他属性。 + * 但是,right 和 bottom 属性与这四个属性是整体相关的。例如,如果更改 right 属性的值,则 width + * 属性的值将发生变化;如果更改 bottom 属性,则 height 属性的值将发生变化。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class Rectangle { + /** + * - The x coordinate of the top-left corner of the rectangle. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 矩形左上角的 x 坐标。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + x: number; + /** + * - The y coordinate of the top-left corner of the rectangle. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 矩形左上角的 y 坐标。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + y: number; + /** + * - The width of the rectangle, in pixels. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 矩形的宽度(以像素为单位)。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + width: number; + /** + * - 矩形的高度(以像素为单位)。 + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - The height of the rectangle, in pixels. + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + height: number; + /** + * @private + */ + constructor(x?: number, y?: number, width?: number, height?: number); + /** + * @private + */ + copyFrom(value: Rectangle): void; + /** + * @private + */ + clear(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The user custom data. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 用户自定义数据。 + * @version DragonBones 5.0 + * @language zh_CN + */ + class UserData extends BaseObject { + static toString(): string; + /** + * - The custom int numbers. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 自定义整数。 + * @version DragonBones 5.0 + * @language zh_CN + */ + readonly ints: Array; + /** + * - The custom float numbers. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 自定义浮点数。 + * @version DragonBones 5.0 + * @language zh_CN + */ + readonly floats: Array; + /** + * - The custom strings. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 自定义字符串。 + * @version DragonBones 5.0 + * @language zh_CN + */ + readonly strings: Array; + /** + * @inheritDoc + */ + protected _onClear(): void; + /** + * @internal + * @private + */ + addInt(value: number): void; + /** + * @internal + * @private + */ + addFloat(value: number): void; + /** + * @internal + * @private + */ + addString(value: string): void; + /** + * - Get the custom int number. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 获取自定义整数。 + * @version DragonBones 5.0 + * @language zh_CN + */ + getInt(index?: number): number; + /** + * - Get the custom float number. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 获取自定义浮点数。 + * @version DragonBones 5.0 + * @language zh_CN + */ + getFloat(index?: number): number; + /** + * - Get the custom string. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 获取自定义字符串。 + * @version DragonBones 5.0 + * @language zh_CN + */ + getString(index?: number): string; + } + /** + * @internal + * @private + */ + class ActionData extends BaseObject { + static toString(): string; + type: ActionType; + name: string; + bone: BoneData | null; + slot: SlotData | null; + data: UserData | null; + protected _onClear(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The DragonBones data. + * A DragonBones data contains multiple armature data. + * @see dragonBones.ArmatureData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 龙骨数据。 + * 一个龙骨数据包含多个骨架数据。 + * @see dragonBones.ArmatureData + * @version DragonBones 3.0 + * @language zh_CN + */ + class DragonBonesData extends BaseObject { + static toString(): string; + /** + * @private + */ + autoSearch: boolean; + /** + * - The animation frame rate. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画帧频。 + * @version DragonBones 3.0 + * @language zh_CN + */ + frameRate: number; + /** + * - The data version. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 数据版本。 + * @version DragonBones 3.0 + * @language zh_CN + */ + version: string; + /** + * - The DragonBones data name. + * The name is consistent with the DragonBones project name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 龙骨数据名称。 + * 该名称与龙骨项目名保持一致。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + stage: ArmatureData | null; + /** + * @internal + * @private + */ + readonly frameIndices: Array; + /** + * @internal + * @private + */ + readonly cachedFrames: Array; + /** + * - All armature data names. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 所有的骨架数据名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly armatureNames: Array; + /** + * @private + */ + readonly armatures: Map; + /** + * @internal + * @private + */ + binary: ArrayBuffer; + /** + * @internal + * @private + */ + intArray: Int16Array; + /** + * @internal + * @private + */ + floatArray: Float32Array; + /** + * @internal + * @private + */ + frameIntArray: Int16Array; + /** + * @internal + * @private + */ + frameFloatArray: Float32Array; + /** + * @internal + * @private + */ + frameArray: Int16Array; + /** + * @internal + * @private + */ + timelineArray: Uint16Array; + /** + * @private + */ + userData: UserData | null; + /** + * @inheritDoc + */ + protected _onClear(): void; + /** + * @internal + * @private + */ + addArmature(value: ArmatureData): void; + /** + * - Get a specific armature data. + * @param name - The armature data name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的骨架数据。 + * @param name - 骨架数据名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + getArmature(name: string): ArmatureData | null; + /** + * - Deprecated, please refer to {@link #dragonBones.BaseFactory#removeDragonBonesData()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #dragonBones.BaseFactory#removeDragonBonesData()}。 + * @deprecated + * @language zh_CN + */ + dispose(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The armature data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨架数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class ArmatureData extends BaseObject { + static toString(): string; + /** + * @private + */ + type: ArmatureType; + /** + * - The animation frame rate. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画帧率。 + * @version DragonBones 3.0 + * @language zh_CN + */ + frameRate: number; + /** + * @private + */ + cacheFrameRate: number; + /** + * @private + */ + scale: number; + /** + * - The armature name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨架名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + readonly aabb: Rectangle; + /** + * - The names of all the animation data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 所有的动画数据名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly animationNames: Array; + /** + * @private + */ + readonly sortedBones: Array; + /** + * @private + */ + readonly sortedSlots: Array; + /** + * @private + */ + readonly defaultActions: Array; + /** + * @private + */ + readonly actions: Array; + /** + * @private + */ + readonly bones: Map; + /** + * @private + */ + readonly slots: Map; + /** + * @private + */ + readonly constraints: Map; + /** + * @private + */ + readonly skins: Map; + /** + * @private + */ + readonly animations: Map; + /** + * - The default skin data. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 默认插槽数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + defaultSkin: SkinData | null; + /** + * - The default animation data. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 默认动画数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + defaultAnimation: AnimationData | null; + /** + * @private + */ + canvas: CanvasData | null; + /** + * @private + */ + userData: UserData | null; + /** + * @private + */ + parent: DragonBonesData; + /** + * @inheritDoc + */ + protected _onClear(): void; + /** + * @internal + * @private + */ + sortBones(): void; + /** + * @internal + * @private + */ + cacheFrames(frameRate: number): void; + /** + * @internal + * @private + */ + setCacheFrame(globalTransformMatrix: Matrix, transform: Transform): number; + /** + * @internal + * @private + */ + getCacheFrame(globalTransformMatrix: Matrix, transform: Transform, arrayOffset: number): void; + /** + * @internal + * @private + */ + addBone(value: BoneData): void; + /** + * @internal + * @private + */ + addSlot(value: SlotData): void; + /** + * @internal + * @private + */ + addConstraint(value: ConstraintData): void; + /** + * @internal + * @private + */ + addSkin(value: SkinData): void; + /** + * @internal + * @private + */ + addAnimation(value: AnimationData): void; + /** + * @internal + * @private + */ + addAction(value: ActionData, isDefault: boolean): void; + /** + * - Get a specific done data. + * @param name - The bone name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的骨骼数据。 + * @param name - 骨骼名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + getBone(name: string): BoneData | null; + /** + * - Get a specific slot data. + * @param name - The slot name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的插槽数据。 + * @param name - 插槽名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + getSlot(name: string): SlotData | null; + /** + * @private + */ + getConstraint(name: string): ConstraintData | null; + /** + * - Get a specific skin data. + * @param name - The skin name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定皮肤数据。 + * @param name - 皮肤名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + getSkin(name: string): SkinData | null; + /** + * @internal + * @private + */ + getMesh(skinName: string, slotName: string, meshName: string): MeshDisplayData | null; + /** + * - Get a specific animation data. + * @param name - The animation name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的动画数据。 + * @param name - 动画名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + getAnimation(name: string): AnimationData | null; + } + /** + * - The bone data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨骼数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class BoneData extends BaseObject { + static toString(): string; + /** + * @private + */ + inheritTranslation: boolean; + /** + * @private + */ + inheritRotation: boolean; + /** + * @private + */ + inheritScale: boolean; + /** + * @private + */ + inheritReflection: boolean; + /** + * @private + */ + type: BoneType; + /** + * - The bone length. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨骼长度。 + * @version DragonBones 3.0 + * @language zh_CN + */ + length: number; + /** + * - The bone name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨骼名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + readonly transform: Transform; + /** + * @private + */ + userData: UserData | null; + /** + * - The parent bone data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 父骨骼数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + parent: BoneData | null; + /** + * @inheritDoc + */ + protected _onClear(): void; + } + /** + * @internal + * @private + */ + class SurfaceData extends BoneData { + static toString(): string; + segmentX: number; + segmentY: number; + readonly vertices: Array; + /** + * @inheritDoc + */ + protected _onClear(): void; + } + /** + * - The slot data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 插槽数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class SlotData extends BaseObject { + /** + * @internal + * @private + */ + static readonly DEFAULT_COLOR: ColorTransform; + /** + * @internal + * @private + */ + static createColor(): ColorTransform; + static toString(): string; + /** + * @private + */ + blendMode: BlendMode; + /** + * @private + */ + displayIndex: number; + /** + * @private + */ + zOrder: number; + /** + * - The slot name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 插槽名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + color: ColorTransform; + /** + * @private + */ + userData: UserData | null; + /** + * - The parent bone data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 父骨骼数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + parent: BoneData; + /** + * @inheritDoc + */ + protected _onClear(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + abstract class ConstraintData extends BaseObject { + order: number; + name: string; + target: BoneData; + root: BoneData; + bone: BoneData | null; + protected _onClear(): void; + } + /** + * @internal + * @private + */ + class IKConstraintData extends ConstraintData { + static toString(): string; + scaleEnabled: boolean; + bendPositive: boolean; + weight: number; + protected _onClear(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + class CanvasData extends BaseObject { + static toString(): string; + hasBackground: boolean; + color: number; + x: number; + y: number; + width: number; + height: number; + protected _onClear(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The skin data, typically a armature data instance contains at least one skinData. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 皮肤数据,通常一个骨架数据至少包含一个皮肤数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class SkinData extends BaseObject { + static toString(): string; + /** + * - The skin name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 皮肤名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + readonly displays: Map>; + /** + * @private + */ + parent: ArmatureData; + /** + * @inheritDoc + */ + protected _onClear(): void; + /** + * @internal + * @private + */ + addDisplay(slotName: string, value: DisplayData | null): void; + /** + * @private + */ + getDisplay(slotName: string, displayName: string): DisplayData | null; + /** + * @private + */ + getDisplays(slotName: string): Array | null; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + abstract class DisplayData extends BaseObject { + type: DisplayType; + name: string; + path: string; + parent: SkinData; + readonly transform: Transform; + protected _onClear(): void; + } + /** + * @internal + * @private + */ + class ImageDisplayData extends DisplayData { + static toString(): string; + readonly pivot: Point; + texture: TextureData | null; + protected _onClear(): void; + } + /** + * @internal + * @private + */ + class ArmatureDisplayData extends DisplayData { + static toString(): string; + inheritAnimation: boolean; + readonly actions: Array; + armature: ArmatureData | null; + protected _onClear(): void; + /** + * @private + */ + addAction(value: ActionData): void; + } + /** + * @internal + * @private + */ + class MeshDisplayData extends DisplayData { + static toString(): string; + inheritDeform: boolean; + offset: number; + weight: WeightData | null; + glue: GlueData | null; + texture: TextureData | null; + protected _onClear(): void; + } + /** + * @internal + * @private + */ + class BoundingBoxDisplayData extends DisplayData { + static toString(): string; + boundingBox: BoundingBoxData | null; + protected _onClear(): void; + } + /** + * @internal + * @private + */ + class WeightData extends BaseObject { + static toString(): string; + count: number; + offset: number; + readonly bones: Array; + protected _onClear(): void; + addBone(value: BoneData): void; + } + /** + * @internal + * @private + */ + class GlueData extends BaseObject { + static toString(): string; + readonly weights: Array; + readonly meshes: Array; + protected _onClear(): void; + addMesh(value: MeshDisplayData | null): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The base class of bounding box data. + * @see dragonBones.RectangleData + * @see dragonBones.EllipseData + * @see dragonBones.PolygonData + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 边界框数据基类。 + * @see dragonBones.RectangleData + * @see dragonBones.EllipseData + * @see dragonBones.PolygonData + * @version DragonBones 5.0 + * @language zh_CN + */ + abstract class BoundingBoxData extends BaseObject { + /** + * - The bounding box type. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 边界框类型。 + * @version DragonBones 5.0 + * @language zh_CN + */ + type: BoundingBoxType; + /** + * @private + */ + color: number; + /** + * @private + */ + width: number; + /** + * @private + */ + height: number; + /** + * @private + */ + protected _onClear(): void; + /** + * - Check whether the bounding box contains a specific point. (Local coordinate system) + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 检查边界框是否包含特定点。(本地坐标系) + * @version DragonBones 5.0 + * @language zh_CN + */ + abstract containsPoint(pX: number, pY: number): boolean; + /** + * - Check whether the bounding box intersects a specific segment. (Local coordinate system) + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 检查边界框是否与特定线段相交。(本地坐标系) + * @version DragonBones 5.0 + * @language zh_CN + */ + abstract intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA: { + x: number; + y: number; + } | null, intersectionPointB: { + x: number; + y: number; + } | null, normalRadians: { + x: number; + y: number; + } | null): number; + } + /** + * - The rectangle bounding box data. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 矩形边界框数据。 + * @version DragonBones 5.1 + * @language zh_CN + */ + class RectangleBoundingBoxData extends BoundingBoxData { + static toString(): string; + /** + * - Compute the bit code for a point (x, y) using the clip rectangle + */ + private static _computeOutCode(x, y, xMin, yMin, xMax, yMax); + /** + * @private + */ + static rectangleIntersectsSegment(xA: number, yA: number, xB: number, yB: number, xMin: number, yMin: number, xMax: number, yMax: number, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): number; + /** + * @inheritDoc + * @private + */ + protected _onClear(): void; + /** + * @inheritDoc + */ + containsPoint(pX: number, pY: number): boolean; + /** + * @inheritDoc + */ + intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): number; + } + /** + * - The ellipse bounding box data. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 椭圆边界框数据。 + * @version DragonBones 5.1 + * @language zh_CN + */ + class EllipseBoundingBoxData extends BoundingBoxData { + static toString(): string; + /** + * @private + */ + static ellipseIntersectsSegment(xA: number, yA: number, xB: number, yB: number, xC: number, yC: number, widthH: number, heightH: number, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): number; + /** + * @inheritDoc + * @private + */ + protected _onClear(): void; + /** + * @inheritDoc + */ + containsPoint(pX: number, pY: number): boolean; + /** + * @inheritDoc + */ + intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): number; + } + /** + * - The polygon bounding box data. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 多边形边界框数据。 + * @version DragonBones 5.1 + * @language zh_CN + */ + class PolygonBoundingBoxData extends BoundingBoxData { + static toString(): string; + /** + * @private + */ + static polygonIntersectsSegment(xA: number, yA: number, xB: number, yB: number, vertices: Array, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): number; + /** + * @private + */ + x: number; + /** + * @private + */ + y: number; + /** + * - The polygon vertices. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 多边形顶点。 + * @version DragonBones 5.1 + * @language zh_CN + */ + readonly vertices: Array; + /** + * @private + */ + weight: WeightData | null; + /** + * @inheritDoc + * @private + */ + protected _onClear(): void; + /** + * @inheritDoc + */ + containsPoint(pX: number, pY: number): boolean; + /** + * @inheritDoc + */ + intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): number; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The animation data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class AnimationData extends BaseObject { + static toString(): string; + /** + * - FrameIntArray. + * @internal + * @private + */ + frameIntOffset: number; + /** + * - FrameFloatArray. + * @internal + * @private + */ + frameFloatOffset: number; + /** + * - FrameArray. + * @internal + * @private + */ + frameOffset: number; + /** + * - The frame count of the animation. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画的帧数。 + * @version DragonBones 3.0 + * @language zh_CN + */ + frameCount: number; + /** + * - The play times of the animation. [0: Loop play, [1~N]: Play N times] + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画的播放次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次] + * @version DragonBones 3.0 + * @language zh_CN + */ + playTimes: number; + /** + * - The duration of the animation. (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画的持续时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + duration: number; + /** + * @private + */ + scale: number; + /** + * - The fade in time of the animation. (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画的淡入时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + fadeInTime: number; + /** + * @private + */ + cacheFrameRate: number; + /** + * - The animation name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + readonly cachedFrames: Array; + /** + * @private + */ + readonly boneTimelines: Map>; + /** + * @private + */ + readonly surfaceTimelines: Map>; + /** + * @private + */ + readonly slotTimelines: Map>; + /** + * @private + */ + readonly constraintTimelines: Map>; + /** + * @private + */ + readonly animationTimelines: Map>; + /** + * @private + */ + readonly boneCachedFrameIndices: Map>; + /** + * @private + */ + readonly slotCachedFrameIndices: Map>; + /** + * @private + */ + actionTimeline: TimelineData | null; + /** + * @private + */ + zOrderTimeline: TimelineData | null; + /** + * @private + */ + parent: ArmatureData; + /** + * @inheritDoc + */ + protected _onClear(): void; + /** + * @internal + * @private + */ + cacheFrames(frameRate: number): void; + /** + * @private + */ + addBoneTimeline(bone: BoneData, timeline: TimelineData): void; + /** + * @private + */ + addSurfaceTimeline(surface: SurfaceData, timeline: TimelineData): void; + /** + * @private + */ + addSlotTimeline(slot: SlotData, timeline: TimelineData): void; + /** + * @private + */ + addConstraintTimeline(constraint: ConstraintData, timeline: TimelineData): void; + /** + * @private + */ + addAnimationTimeline(name: string, timeline: TimelineData): void; + /** + * @private + */ + getBoneTimelines(name: string): Array | null; + /** + * @private + */ + getSurfaceTimelines(name: string): Array | null; + /** + * @private + */ + getSlotTimelines(name: string): Array | null; + /** + * @private + */ + getConstraintTimelines(name: string): Array | null; + /** + * @private + */ + getAnimationTimelines(name: string): Array | null; + /** + * @private + */ + getBoneCachedFrameIndices(name: string): Array | null; + /** + * @private + */ + getSlotCachedFrameIndices(name: string): Array | null; + } + /** + * @internal + * @private + */ + class TimelineData extends BaseObject { + static toString(): string; + type: TimelineType; + offset: number; + frameIndicesOffset: number; + protected _onClear(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The animation config is used to describe all the information needed to play an animation state. + * The API is still in the experimental phase and may encounter bugs or stability or compatibility issues when used. + * @see dragonBones.AnimationState + * @beta + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画配置用来描述播放一个动画状态所需要的全部信息。 + * 该 API 仍在实验阶段,使用时可能遭遇 bug 或稳定性或兼容性问题。 + * @see dragonBones.AnimationState + * @beta + * @version DragonBones 5.0 + * @language zh_CN + */ + class AnimationConfig extends BaseObject { + static toString(): string; + /** + * @private + */ + pauseFadeOut: boolean; + /** + * - Fade out the pattern of other animation states when the animation state is fade in. + * This property is typically used to specify the substitution of multiple animation states blend. + * @default dragonBones.AnimationFadeOutMode.All + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 淡入动画状态时淡出其他动画状态的模式。 + * 该属性通常用来指定多个动画状态混合时的相互替换关系。 + * @default dragonBones.AnimationFadeOutMode.All + * @version DragonBones 5.0 + * @language zh_CN + */ + fadeOutMode: AnimationFadeOutMode; + /** + * @private + */ + fadeOutTweenType: TweenType; + /** + * @private + */ + fadeOutTime: number; + /** + * @private + */ + pauseFadeIn: boolean; + /** + * @private + */ + actionEnabled: boolean; + /** + * @private + */ + additiveBlending: boolean; + /** + * - Whether the animation state has control over the display property of the slots. + * Sometimes blend a animation state does not want it to control the display properties of the slots, + * especially if other animation state are controlling the display properties of the slots. + * @default true + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画状态是否对插槽的显示对象属性有控制权。 + * 有时混合一个动画状态并不希望其控制插槽的显示对象属性, + * 尤其是其他动画状态正在控制这些插槽的显示对象属性时。 + * @default true + * @version DragonBones 5.0 + * @language zh_CN + */ + displayControl: boolean; + /** + * - Whether to reset the objects without animation to the armature pose when the animation state is start to play. + * This property should usually be set to false when blend multiple animation states. + * @default true + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 开始播放动画状态时是否将没有动画的对象重置为骨架初始值。 + * 通常在混合多个动画状态时应该将该属性设置为 false。 + * @default true + * @version DragonBones 5.1 + * @language zh_CN + */ + resetToPose: boolean; + /** + * @private + */ + fadeInTweenType: TweenType; + /** + * - The play times. [0: Loop play, [1~N]: Play N times] + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 播放次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次] + * @version DragonBones 3.0 + * @language zh_CN + */ + playTimes: number; + /** + * - The blend layer. + * High layer animation state will get the blend weight first. + * When the blend weight is assigned more than 1, the remaining animation states will no longer get the weight assigned. + * @readonly + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 混合图层。 + * 图层高的动画状态会优先获取混合权重。 + * 当混合权重分配超过 1 时,剩余的动画状态将不再获得权重分配。 + * @readonly + * @version DragonBones 5.0 + * @language zh_CN + */ + layer: number; + /** + * - The start time of play. (In seconds) + * @default 0.0 + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 播放的开始时间。 (以秒为单位) + * @default 0.0 + * @version DragonBones 5.0 + * @language zh_CN + */ + position: number; + /** + * - The duration of play. + * [-1: Use the default value of the animation data, 0: Stop play, (0~N]: The duration] (In seconds) + * @default -1.0 + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 播放的持续时间。 + * [-1: 使用动画数据默认值, 0: 动画停止, (0~N]: 持续时间] (以秒为单位) + * @default -1.0 + * @version DragonBones 5.0 + * @language zh_CN + */ + duration: number; + /** + * - The play speed. + * The value is an overlay relationship with {@link dragonBones.Animation#timeScale}. + * [(-N~0): Reverse play, 0: Stop play, (0~1): Slow play, 1: Normal play, (1~N): Fast play] + * @default 1.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 播放速度。 + * 该值与 {@link dragonBones.Animation#timeScale} 是叠加关系。 + * [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + timeScale: number; + /** + * - The blend weight. + * @default 1.0 + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 混合权重。 + * @default 1.0 + * @version DragonBones 5.0 + * @language zh_CN + */ + weight: number; + /** + * - The fade in time. + * [-1: Use the default value of the animation data, [0~N]: The fade in time] (In seconds) + * @default -1.0 + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 淡入时间。 + * [-1: 使用动画数据默认值, [0~N]: 淡入时间] (以秒为单位) + * @default -1.0 + * @version DragonBones 5.0 + * @language zh_CN + */ + fadeInTime: number; + /** + * - The auto fade out time when the animation state play completed. + * [-1: Do not fade out automatically, [0~N]: The fade out time] (In seconds) + * @default -1.0 + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画状态播放完成后的自动淡出时间。 + * [-1: 不自动淡出, [0~N]: 淡出时间] (以秒为单位) + * @default -1.0 + * @version DragonBones 5.0 + * @language zh_CN + */ + autoFadeOutTime: number; + /** + * - The name of the animation state. (Can be different from the name of the animation data) + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画状态名称。 (可以不同于动画数据) + * @version DragonBones 5.0 + * @language zh_CN + */ + name: string; + /** + * - The animation data name. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画数据名称。 + * @version DragonBones 5.0 + * @language zh_CN + */ + animation: string; + /** + * - The blend group name of the animation state. + * This property is typically used to specify the substitution of multiple animation states blend. + * @readonly + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 混合组名称。 + * 该属性通常用来指定多个动画状态混合时的相互替换关系。 + * @readonly + * @version DragonBones 5.0 + * @language zh_CN + */ + group: string; + /** + * @private + */ + readonly boneMask: Array; + /** + * @private + */ + protected _onClear(): void; + /** + * @private + */ + clear(): void; + /** + * @private + */ + copyFrom(value: AnimationConfig): void; + /** + * @private + */ + containsBoneMask(name: string): boolean; + /** + * @private + */ + addBoneMask(armature: Armature, name: string, recursive?: boolean): void; + /** + * @private + */ + removeBoneMask(armature: Armature, name: string, recursive?: boolean): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The texture atlas data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 贴图集数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + abstract class TextureAtlasData extends BaseObject { + /** + * @private + */ + autoSearch: boolean; + /** + * @private + */ + width: number; + /** + * @private + */ + height: number; + /** + * @private + */ + scale: number; + /** + * - The texture atlas name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 贴图集名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * - The image path of the texture atlas. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 贴图集图片路径。 + * @version DragonBones 3.0 + * @language zh_CN + */ + imagePath: string; + /** + * @private + */ + readonly textures: Map; + /** + * @inheritDoc + */ + protected _onClear(): void; + /** + * @private + */ + copyFrom(value: TextureAtlasData): void; + /** + * @internal + * @private + */ + abstract createTexture(): TextureData; + /** + * @internal + * @private + */ + addTexture(value: TextureData): void; + /** + * @private + */ + getTexture(name: string): TextureData | null; + } + /** + * @internal + * @private + */ + abstract class TextureData extends BaseObject { + static createRectangle(): Rectangle; + rotated: boolean; + name: string; + readonly region: Rectangle; + parent: TextureAtlasData; + frame: Rectangle | null; + protected _onClear(): void; + copyFrom(value: TextureData): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The armature proxy interface, the docking engine needs to implement it concretely. + * @see dragonBones.Armature + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 骨架代理接口,对接的引擎需要对其进行具体实现。 + * @see dragonBones.Armature + * @version DragonBones 5.0 + * @language zh_CN + */ + interface IArmatureProxy extends IEventDispatcher { + /** + * @internal + * @private + */ + dbInit(armature: Armature): void; + /** + * @internal + * @private + */ + dbClear(): void; + /** + * @internal + * @private + */ + dbUpdate(): void; + /** + * - Dispose the instance and the Armature instance. (The Armature instance will return to the object pool) + * @example + *
+         *     removeChild(armatureDisplay);
+         *     armatureDisplay.dispose();
+         * 
+ * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 释放该实例和骨架。 (骨架会回收到对象池) + * @example + *
+         *     removeChild(armatureDisplay);
+         *     armatureDisplay.dispose();
+         * 
+ * @version DragonBones 4.5 + * @language zh_CN + */ + dispose(disposeProxy: boolean): void; + /** + * - The armature. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 骨架。 + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly armature: Armature; + /** + * - The animation player. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画播放器。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly animation: Animation; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - Armature is the core of the skeleton animation system. + * @see dragonBones.ArmatureData + * @see dragonBones.Bone + * @see dragonBones.Slot + * @see dragonBones.Animation + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨架是骨骼动画系统的核心。 + * @see dragonBones.ArmatureData + * @see dragonBones.Bone + * @see dragonBones.Slot + * @see dragonBones.Animation + * @version DragonBones 3.0 + * @language zh_CN + */ + class Armature extends BaseObject implements IAnimatable { + static toString(): string; + private static _onSortSlots(a, b); + /** + * - Whether to inherit the animation control of the parent armature. + * True to try to have the child armature play an animation with the same name when the parent armature play the animation. + * @default true + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 是否继承父骨架的动画控制。 + * 如果该值为 true,当父骨架播放动画时,会尝试让子骨架播放同名动画。 + * @default true + * @version DragonBones 4.5 + * @language zh_CN + */ + inheritAnimation: boolean; + /** + * @private + */ + userData: any; + private _lockUpdate; + private _bonesDirty; + private _slotsDirty; + private _zOrderDirty; + private _flipX; + private _flipY; + /** + * @internal + * @private + */ + _cacheFrameIndex: number; + private readonly _bones; + private readonly _slots; + /** + * @internal + * @private + */ + readonly _glueSlots: Array; + /** + * @internal + * @private + */ + readonly _constraints: Array; + private readonly _actions; + /** + * @internal + * @private + */ + _armatureData: ArmatureData; + private _animation; + private _proxy; + private _display; + /** + * @internal + * @private + */ + _replaceTextureAtlasData: TextureAtlasData | null; + private _replacedTexture; + /** + * @internal + * @private + */ + _dragonBones: DragonBones; + private _clock; + /** + * @internal + * @private + */ + _parent: Slot | null; + /** + * @private + */ + protected _onClear(): void; + private _sortBones(); + private _sortSlots(); + /** + * @internal + * @private + */ + _sortZOrder(slotIndices: Array | Int16Array | null, offset: number): void; + /** + * @internal + * @private + */ + _addBoneToBoneList(value: Bone): void; + /** + * @internal + * @private + */ + _removeBoneFromBoneList(value: Bone): void; + /** + * @internal + * @private + */ + _addSlotToSlotList(value: Slot): void; + /** + * @internal + * @private + */ + _removeSlotFromSlotList(value: Slot): void; + /** + * @internal + * @private + */ + _bufferAction(action: ActionData, append: boolean): void; + /** + * - Dispose the armature. (Return to the object pool) + * @example + *
+         *     removeChild(armature.display);
+         *     armature.dispose();
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 释放骨架。 (回收到对象池) + * @example + *
+         *     removeChild(armature.display);
+         *     armature.dispose();
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + dispose(): void; + /** + * @internal + * @private + */ + init(armatureData: ArmatureData, proxy: IArmatureProxy, display: any, dragonBones: DragonBones): void; + /** + * @inheritDoc + */ + advanceTime(passedTime: number): void; + /** + * - Forces a specific bone or its owning slot to update the transform or display property in the next frame. + * @param boneName - The bone name. (If not set, all bones will be update) + * @param updateSlot - Whether to update the bone's slots. (Default: false) + * @see dragonBones.Bone#invalidUpdate() + * @see dragonBones.Slot#invalidUpdate() + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 强制特定骨骼或其拥有的插槽在下一帧更新变换或显示属性。 + * @param boneName - 骨骼名称。 (如果未设置,将更新所有骨骼) + * @param updateSlot - 是否更新骨骼的插槽。 (默认: false) + * @see dragonBones.Bone#invalidUpdate() + * @see dragonBones.Slot#invalidUpdate() + * @version DragonBones 3.0 + * @language zh_CN + */ + invalidUpdate(boneName?: string | null, updateSlot?: boolean): void; + /** + * - Check whether a specific point is inside a custom bounding box in a slot. + * The coordinate system of the point is the inner coordinate system of the armature. + * Custom bounding boxes need to be customized in Dragonbones Pro. + * @param x - The horizontal coordinate of the point. + * @param y - The vertical coordinate of the point. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 检查特定点是否在某个插槽的自定义边界框内。 + * 点的坐标系为骨架内坐标系。 + * 自定义边界框需要在 DragonBones Pro 中自定义。 + * @param x - 点的水平坐标。 + * @param y - 点的垂直坐标。 + * @version DragonBones 5.0 + * @language zh_CN + */ + containsPoint(x: number, y: number): Slot | null; + /** + * - Check whether a specific segment intersects a custom bounding box for a slot in the armature. + * The coordinate system of the segment and intersection is the inner coordinate system of the armature. + * Custom bounding boxes need to be customized in Dragonbones Pro. + * @param xA - The horizontal coordinate of the beginning of the segment. + * @param yA - The vertical coordinate of the beginning of the segment. + * @param xB - The horizontal coordinate of the end point of the segment. + * @param yB - The vertical coordinate of the end point of the segment. + * @param intersectionPointA - The first intersection at which a line segment intersects the bounding box from the beginning to the end. (If not set, the intersection point will not calculated) + * @param intersectionPointB - The first intersection at which a line segment intersects the bounding box from the end to the beginning. (If not set, the intersection point will not calculated) + * @param normalRadians - The normal radians of the tangent of the intersection boundary box. [x: Normal radian of the first intersection tangent, y: Normal radian of the second intersection tangent] (If not set, the normal will not calculated) + * @returns The slot of the first custom bounding box where the segment intersects from the start point to the end point. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 检查特定线段是否与骨架的某个插槽的自定义边界框相交。 + * 线段和交点的坐标系均为骨架内坐标系。 + * 自定义边界框需要在 DragonBones Pro 中自定义。 + * @param xA - 线段起点的水平坐标。 + * @param yA - 线段起点的垂直坐标。 + * @param xB - 线段终点的水平坐标。 + * @param yB - 线段终点的垂直坐标。 + * @param intersectionPointA - 线段从起点到终点与边界框相交的第一个交点。 (如果未设置,则不计算交点) + * @param intersectionPointB - 线段从终点到起点与边界框相交的第一个交点。 (如果未设置,则不计算交点) + * @param normalRadians - 交点边界框切线的法线弧度。 [x: 第一个交点切线的法线弧度, y: 第二个交点切线的法线弧度] (如果未设置,则不计算法线) + * @returns 线段从起点到终点相交的第一个自定义边界框的插槽。 + * @version DragonBones 5.0 + * @language zh_CN + */ + intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): Slot | null; + /** + * - Get a specific bone. + * @param name - The bone name. + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的骨骼。 + * @param name - 骨骼名称。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + getBone(name: string): Bone | null; + /** + * - Get a specific bone by the display. + * @param display - The display object. + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 通过显示对象获取特定的骨骼。 + * @param display - 显示对象。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + getBoneByDisplay(display: any): Bone | null; + /** + * - Get a specific slot. + * @param name - The slot name. + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的插槽。 + * @param name - 插槽名称。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + getSlot(name: string): Slot | null; + /** + * - Get a specific slot by the display. + * @param display - The display object. + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 通过显示对象获取特定的插槽。 + * @param display - 显示对象。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + getSlotByDisplay(display: any): Slot | null; + /** + * @deprecated + */ + addBone(value: Bone, parentName: string): void; + /** + * @deprecated + */ + addSlot(value: Slot, parentName: string): void; + /** + * @private + */ + addConstraint(value: Constraint): void; + /** + * @deprecated + */ + removeBone(value: Bone): void; + /** + * @deprecated + */ + removeSlot(value: Slot): void; + /** + * - Get all bones. + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取所有的骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + getBones(): Array; + /** + * - Get all slots. + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取所有的插槽。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + getSlots(): Array; + /** + * - Whether to flip the armature horizontally. + * @version DragonBones 5.5 + * @language en_US + */ + /** + * - 是否将骨架水平翻转。 + * @version DragonBones 5.5 + * @language zh_CN + */ + flipX: boolean; + /** + * - Whether to flip the armature vertically. + * @version DragonBones 5.5 + * @language en_US + */ + /** + * - 是否将骨架垂直翻转。 + * @version DragonBones 5.5 + * @language zh_CN + */ + flipY: boolean; + /** + * - The animation cache frame rate, which turns on the animation cache when the set value is greater than 0. + * There is a certain amount of memory overhead to improve performance by caching animation data in memory. + * The frame rate should not be set too high, usually with the frame rate of the animation is similar and lower than the program running frame rate. + * When the animation cache is turned on, some features will fail, such as the offset property of bone. + * @example + *
+         *     armature.cacheFrameRate = 24;
+         * 
+ * @see dragonBones.DragonBonesData#frameRate + * @see dragonBones.ArmatureData#frameRate + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画缓存帧率,当设置的值大于 0 的时,将会开启动画缓存。 + * 通过将动画数据缓存在内存中来提高运行性能,会有一定的内存开销。 + * 帧率不宜设置的过高,通常跟动画的帧率相当且低于程序运行的帧率。 + * 开启动画缓存后,某些功能将会失效,比如骨骼的 offset 属性等。 + * @example + *
+         *     armature.cacheFrameRate = 24;
+         * 
+ * @see dragonBones.DragonBonesData#frameRate + * @see dragonBones.ArmatureData#frameRate + * @version DragonBones 4.5 + * @language zh_CN + */ + cacheFrameRate: number; + /** + * - The armature name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨架名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly name: string; + /** + * - The armature data. + * @see dragonBones.ArmatureData + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 骨架数据。 + * @see dragonBones.ArmatureData + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly armatureData: ArmatureData; + /** + * - The animation player. + * @see dragonBones.Animation + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画播放器。 + * @see dragonBones.Animation + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly animation: Animation; + /** + * @pivate + */ + readonly proxy: IArmatureProxy; + /** + * - The EventDispatcher instance of the armature. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 该骨架的 EventDispatcher 实例。 + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly eventDispatcher: IEventDispatcher; + /** + * - The display container. + * The display of the slot is displayed as the parent. + * Depending on the rendering engine, the type will be different, usually the DisplayObjectContainer type. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 显示容器实例。 + * 插槽的显示对象都会以此显示容器为父级。 + * 根据渲染引擎的不同,类型会不同,通常是 DisplayObjectContainer 类型。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly display: any; + /** + * @private + */ + replacedTexture: any; + /** + * @inheritDoc + */ + clock: WorldClock | null; + /** + * - Get the parent slot which the armature belongs to. + * @see dragonBones.Slot + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 该骨架所属的父插槽。 + * @see dragonBones.Slot + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly parent: Slot | null; + /** + * @deprecated + * @private + */ + replaceTexture(texture: any): void; + /** + * - Deprecated, please refer to {@link #eventDispatcher}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #eventDispatcher}。 + * @deprecated + * @language zh_CN + */ + hasEventListener(type: EventStringType): boolean; + /** + * - Deprecated, please refer to {@link #eventDispatcher}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #eventDispatcher}。 + * @deprecated + * @language zh_CN + */ + addEventListener(type: EventStringType, listener: Function, target: any): void; + /** + * - Deprecated, please refer to {@link #eventDispatcher}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #eventDispatcher}。 + * @deprecated + * @language zh_CN + */ + removeEventListener(type: EventStringType, listener: Function, target: any): void; + /** + * - Deprecated, please refer to {@link #cacheFrameRate}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #cacheFrameRate}。 + * @deprecated + * @language zh_CN + */ + enableAnimationCache(frameRate: number): void; + /** + * - Deprecated, please refer to {@link #display}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #display}。 + * @deprecated + * @language zh_CN + */ + getDisplay(): any; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The base class of the transform object. + * @see dragonBones.Transform + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 变换对象的基类。 + * @see dragonBones.Transform + * @version DragonBones 4.5 + * @language zh_CN + */ + abstract class TransformObject extends BaseObject { + /** + * @private + */ + protected static readonly _helpMatrix: Matrix; + /** + * @private + */ + protected static readonly _helpTransform: Transform; + /** + * @private + */ + protected static readonly _helpPoint: Point; + /** + * - A matrix relative to the armature coordinate system. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 相对于骨架坐标系的矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly globalTransformMatrix: Matrix; + /** + * - A transform relative to the armature coordinate system. + * @see #updateGlobalTransform() + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 相对于骨架坐标系的变换。 + * @see #updateGlobalTransform() + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly global: Transform; + /** + * - The offset transform relative to the armature or the parent bone coordinate system. + * @see #dragonBones.Bone#invalidUpdate() + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 相对于骨架或父骨骼坐标系的偏移变换。 + * @see #dragonBones.Bone#invalidUpdate() + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly offset: Transform; + /** + * @private + */ + origin: Transform | null; + /** + * @private + */ + userData: any; + /** + * @private + */ + protected _globalDirty: boolean; + /** + * @internal + * @private + */ + _armature: Armature; + /** + * @internal + * @private + */ + _parent: Bone; + /** + * @private + */ + protected _onClear(): void; + /** + * @internal + * @private + */ + _setArmature(value: Armature | null): void; + /** + * @internal + * @private + */ + _setParent(value: Bone | null): void; + /** + * - For performance considerations, rotation or scale in the {@link #global} attribute of the bone or slot is not always properly accessible, + * some engines do not rely on these attributes to update rendering, such as Egret. + * The use of this method ensures that the access to the {@link #global} property is correctly rotation or scale. + * @example + *
+         *     bone.updateGlobalTransform();
+         *     let rotation = bone.global.rotation;
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 出于性能的考虑,骨骼或插槽的 {@link #global} 属性中的旋转或缩放并不总是正确可访问的,有些引擎并不依赖这些属性更新渲染,比如 Egret。 + * 使用此方法可以保证访问到 {@link #global} 属性中正确的旋转或缩放。 + * @example + *
+         *     bone.updateGlobalTransform();
+         *     let rotation = bone.global.rotation;
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + updateGlobalTransform(): void; + /** + * - The armature to which it belongs. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 所属的骨架。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly armature: Armature; + /** + * - The parent bone to which it belongs. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 所属的父骨骼。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly parent: Bone; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - Bone is one of the most important logical units in the armature animation system, + * and is responsible for the realization of translate, rotation, scaling in the animations. + * A armature can contain multiple bones. + * @see dragonBones.BoneData + * @see dragonBones.Armature + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨骼在骨骼动画体系中是最重要的逻辑单元之一,负责动画中的平移、旋转、缩放的实现。 + * 一个骨架中可以包含多个骨骼。 + * @see dragonBones.BoneData + * @see dragonBones.Armature + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + class Bone extends TransformObject { + static toString(): string; + /** + * - The offset mode. + * @see #offset + * @version DragonBones 5.5 + * @language en_US + */ + /** + * - 偏移模式。 + * @see #offset + * @version DragonBones 5.5 + * @language zh_CN + */ + offsetMode: OffsetMode; + /** + * @internal + * @private + */ + readonly animationPose: Transform; + /** + * @internal + * @private + */ + _transformDirty: boolean; + /** + * @internal + * @private + */ + _childrenTransformDirty: boolean; + protected _localDirty: boolean; + /** + * @internal + * @private + */ + _hasConstraint: boolean; + private _visible; + protected _cachedFrameIndex: number; + /** + * @internal + * @private + */ + readonly _blendState: BlendState; + /** + * @internal + * @private + */ + _boneData: BoneData; + /** + * @internal + * @private + */ + _cachedFrameIndices: Array | null; + /** + * @inheritDoc + */ + protected _onClear(): void; + /** + * @private + */ + protected _updateGlobalTransformMatrix(isCache: boolean): void; + /** + * @inheritDoc + */ + _setArmature(value: Armature | null): void; + /** + * @internal + * @private + */ + init(boneData: BoneData): void; + /** + * @internal + * @private + */ + update(cacheFrameIndex: number): void; + /** + * @internal + * @private + */ + updateByConstraint(): void; + /** + * - Forces the bone to update the transform in the next frame. + * When the bone is not animated or its animation state is finished, the bone will not continue to update, + * and when the skeleton must be updated for some reason, the method needs to be called explicitly. + * @example + *
+         *     let bone = armature.getBone("arm");
+         *     bone.offset.scaleX = 2.0;
+         *     bone.invalidUpdate();
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 强制骨骼在下一帧更新变换。 + * 当该骨骼没有动画状态或其动画状态播放完成时,骨骼将不在继续更新,而此时由于某些原因必须更新骨骼时,则需要显式调用该方法。 + * @example + *
+         *     let bone = armature.getBone("arm");
+         *     bone.offset.scaleX = 2.0;
+         *     bone.invalidUpdate();
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + invalidUpdate(): void; + /** + * - Check whether the bone contains a specific bone or slot. + * @see dragonBones.Bone + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 检查该骨骼是否包含特定的骨骼或插槽。 + * @see dragonBones.Bone + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + contains(value: TransformObject): boolean; + /** + * - The bone data. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 骨骼数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly boneData: BoneData; + /** + * - The visible of all slots in the bone. + * @default true + * @see dragonBones.Slot#visible + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 此骨骼所有插槽的可见。 + * @default true + * @see dragonBones.Slot#visible + * @version DragonBones 3.0 + * @language zh_CN + */ + visible: boolean; + /** + * - The bone name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨骼名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly name: string; + /** + * - Deprecated, please refer to {@link dragonBones.Armature#getBones()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link dragonBones.Armature#getBones()}。 + * @deprecated + * @language zh_CN + */ + getBones(): Array; + /** + * - Deprecated, please refer to {@link dragonBones.Armature#getSlots()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link dragonBones.Armature#getSlots()}。 + * @deprecated + * @language zh_CN + */ + getSlots(): Array; + /** + * - Deprecated, please refer to {@link dragonBones.Armature#getSlot()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link dragonBones.Armature#getSlot()}。 + * @deprecated + * @language zh_CN + */ + readonly slot: Slot | null; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + class Surface extends Bone { + static toString(): string; + private _dX; + private _dY; + private _k; + private _kX; + private _kY; + /** + * For debug draw. + * @internal + * @private + */ + readonly _vertices: Array; + /** + * For timeline state. + * @internal + * @private + */ + readonly _deformVertices: Array; + /** + * x1, y1, x2, y2, x3, y3, x4, y4, d1X, d1Y, d2X, d2Y + */ + private readonly _hullCache; + /** + * Inside [flag, a, b, c, d, tx, ty], Outside [flag, a, b, c, d, tx, ty] + */ + private readonly _matrixCahce; + /** + * @inheritDoc + */ + protected _onClear(): void; + private _getAffineTransform(x, y, lX, lY, aX, aY, bX, bY, cX, cY, transform, matrix, isDown); + private _updateVertices(); + /** + * @private + */ + protected _updateGlobalTransformMatrix(isCache: boolean): void; + _getGlobalTransformMatrix(x: number, y: number): Matrix; + init(surfaceData: SurfaceData): void; + /** + * @internal + * @private + */ + update(cacheFrameIndex: number): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The slot attached to the armature, controls the display status and properties of the display object. + * A bone can contain multiple slots. + * A slot can contain multiple display objects, displaying only one of the display objects at a time, + * but you can toggle the display object into frame animation while the animation is playing. + * The display object can be a normal texture, or it can be a display of a child armature, a grid display object, + * and a custom other display object. + * @see dragonBones.Armature + * @see dragonBones.Bone + * @see dragonBones.SlotData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 插槽附着在骨骼上,控制显示对象的显示状态和属性。 + * 一个骨骼上可以包含多个插槽。 + * 一个插槽中可以包含多个显示对象,同一时间只能显示其中的一个显示对象,但可以在动画播放的过程中切换显示对象实现帧动画。 + * 显示对象可以是普通的图片纹理,也可以是子骨架的显示容器,网格显示对象,还可以是自定义的其他显示对象。 + * @see dragonBones.Armature + * @see dragonBones.Bone + * @see dragonBones.SlotData + * @version DragonBones 3.0 + * @language zh_CN + */ + abstract class Slot extends TransformObject { + /** + * - Displays the animated state or mixed group name controlled by the object, set to null to be controlled by all animation states. + * @default null + * @see dragonBones.AnimationState#displayControl + * @see dragonBones.AnimationState#name + * @see dragonBones.AnimationState#group + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 显示对象受到控制的动画状态或混合组名称,设置为 null 则表示受所有的动画状态控制。 + * @default null + * @see dragonBones.AnimationState#displayControl + * @see dragonBones.AnimationState#name + * @see dragonBones.AnimationState#group + * @version DragonBones 4.5 + * @language zh_CN + */ + displayController: string | null; + /** + * @private + */ + protected _displayDirty: boolean; + /** + * @private + */ + protected _zOrderDirty: boolean; + /** + * @private + */ + protected _visibleDirty: boolean; + /** + * @private + */ + protected _blendModeDirty: boolean; + /** + * @internal + * @private + */ + _colorDirty: boolean; + /** + * @internal + * @private + */ + _meshDirty: boolean; + /** + * @private + */ + protected _transformDirty: boolean; + /** + * @private + */ + protected _visible: boolean; + /** + * @private + */ + protected _blendMode: BlendMode; + /** + * @private + */ + protected _displayIndex: number; + /** + * @private + */ + protected _animationDisplayIndex: number; + /** + * @internal + * @private + */ + _zOrder: number; + /** + * @private + */ + protected _cachedFrameIndex: number; + /** + * @internal + * @private + */ + _pivotX: number; + /** + * @internal + * @private + */ + _pivotY: number; + /** + * @private + */ + protected readonly _localMatrix: Matrix; + /** + * @internal + * @private + */ + readonly _colorTransform: ColorTransform; + /** + * @internal + * @private + */ + readonly _deformVertices: Array; + /** + * @private + */ + readonly _displayDatas: Array; + /** + * @private + */ + protected readonly _displayList: Array; + /** + * @private + */ + protected readonly _meshBones: Array; + /** + * @private + */ + protected readonly _meshSlots: Array; + /** + * @internal + * @private + */ + _slotData: SlotData; + /** + * @private + */ + protected _rawDisplayDatas: Array | null; + /** + * @private + */ + protected _displayData: DisplayData | null; + /** + * @private + */ + protected _textureData: TextureData | null; + /** + * @internal + * @private + */ + _meshData: MeshDisplayData | null; + /** + * @private + */ + protected _boundingBoxData: BoundingBoxData | null; + /** + * @private + */ + protected _rawDisplay: any; + /** + * @private + */ + protected _meshDisplay: any; + /** + * @private + */ + protected _display: any; + /** + * @private + */ + protected _childArmature: Armature | null; + /** + * @internal + * @private + */ + _cachedFrameIndices: Array | null; + /** + * @inheritDoc + */ + protected _onClear(): void; + /** + * @private + */ + protected abstract _initDisplay(value: any, isRetain: boolean): void; + /** + * @private + */ + protected abstract _disposeDisplay(value: any, isRelease: boolean): void; + /** + * @private + */ + protected abstract _onUpdateDisplay(): void; + /** + * @private + */ + protected abstract _addDisplay(): void; + /** + * @private + */ + protected abstract _replaceDisplay(value: any): void; + /** + * @private + */ + protected abstract _removeDisplay(): void; + /** + * @private + */ + protected abstract _updateZOrder(): void; + /** + * @private + */ + abstract _updateVisible(): void; + /** + * @private + */ + protected abstract _updateBlendMode(): void; + /** + * @private + */ + protected abstract _updateColor(): void; + /** + * @private + */ + protected abstract _updateFrame(): void; + /** + * @private + */ + protected abstract _updateMesh(): void; + /** + * @internal + * @private + */ + abstract _updateGlueMesh(): void; + /** + * @private + */ + protected abstract _updateTransform(): void; + /** + * @private + */ + protected abstract _identityTransform(): void; + /** + * @private + */ + protected _getDefaultRawDisplayData(): DisplayData | null; + /** + * @private + */ + protected _updateDisplayData(): void; + /** + * @private + */ + protected _updateDisplay(): void; + /** + * @private + */ + protected _updateGlobalTransformMatrix(isCache: boolean): void; + /** + * @private + */ + protected _isMeshBonesUpdate(): boolean; + /** + * @inheritDoc + */ + _setArmature(value: Armature | null): void; + /** + * @internal + * @private + */ + _setDisplayIndex(value: number, isAnimation?: boolean): boolean; + /** + * @internal + * @private + */ + _setZorder(value: number): boolean; + /** + * @internal + * @private + */ + _setColor(value: ColorTransform): boolean; + /** + * @internal + * @private + */ + _setDisplayList(value: Array | null): boolean; + /** + * @internal + * @private + */ + init(slotData: SlotData, displayDatas: Array | null, rawDisplay: any, meshDisplay: any): void; + /** + * @internal + * @private + */ + update(cacheFrameIndex: number): void; + /** + * @private + */ + updateTransformAndMatrix(): void; + /** + * @private + */ + replaceDisplayData(value: DisplayData | null, displayIndex?: number): void; + /** + * - Check whether a specific point is inside a custom bounding box in the slot. + * The coordinate system of the point is the inner coordinate system of the armature. + * Custom bounding boxes need to be customized in Dragonbones Pro. + * @param x - The horizontal coordinate of the point. + * @param y - The vertical coordinate of the point. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 检查特定点是否在插槽的自定义边界框内。 + * 点的坐标系为骨架内坐标系。 + * 自定义边界框需要在 DragonBones Pro 中自定义。 + * @param x - 点的水平坐标。 + * @param y - 点的垂直坐标。 + * @version DragonBones 5.0 + * @language zh_CN + */ + containsPoint(x: number, y: number): boolean; + /** + * - Check whether a specific segment intersects a custom bounding box for the slot. + * The coordinate system of the segment and intersection is the inner coordinate system of the armature. + * Custom bounding boxes need to be customized in Dragonbones Pro. + * @param xA - The horizontal coordinate of the beginning of the segment. + * @param yA - The vertical coordinate of the beginning of the segment. + * @param xB - The horizontal coordinate of the end point of the segment. + * @param yB - The vertical coordinate of the end point of the segment. + * @param intersectionPointA - The first intersection at which a line segment intersects the bounding box from the beginning to the end. (If not set, the intersection point will not calculated) + * @param intersectionPointB - The first intersection at which a line segment intersects the bounding box from the end to the beginning. (If not set, the intersection point will not calculated) + * @param normalRadians - The normal radians of the tangent of the intersection boundary box. [x: Normal radian of the first intersection tangent, y: Normal radian of the second intersection tangent] (If not set, the normal will not calculated) + * @returns Intersection situation. [1: Disjoint and segments within the bounding box, 0: Disjoint, 1: Intersecting and having a nodal point and ending in the bounding box, 2: Intersecting and having a nodal point and starting at the bounding box, 3: Intersecting and having two intersections, N: Intersecting and having N intersections] + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 检查特定线段是否与插槽的自定义边界框相交。 + * 线段和交点的坐标系均为骨架内坐标系。 + * 自定义边界框需要在 DragonBones Pro 中自定义。 + * @param xA - 线段起点的水平坐标。 + * @param yA - 线段起点的垂直坐标。 + * @param xB - 线段终点的水平坐标。 + * @param yB - 线段终点的垂直坐标。 + * @param intersectionPointA - 线段从起点到终点与边界框相交的第一个交点。 (如果未设置,则不计算交点) + * @param intersectionPointB - 线段从终点到起点与边界框相交的第一个交点。 (如果未设置,则不计算交点) + * @param normalRadians - 交点边界框切线的法线弧度。 [x: 第一个交点切线的法线弧度, y: 第二个交点切线的法线弧度] (如果未设置,则不计算法线) + * @returns 相交的情况。 [-1: 不相交且线段在包围盒内, 0: 不相交, 1: 相交且有一个交点且终点在包围盒内, 2: 相交且有一个交点且起点在包围盒内, 3: 相交且有两个交点, N: 相交且有 N 个交点] + * @version DragonBones 5.0 + * @language zh_CN + */ + intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): number; + /** + * - Forces the slot to update the state of the display object in the next frame. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 强制插槽在下一帧更新显示对象的状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + invalidUpdate(): void; + /** + * - The visible of slot's display object. + * @default true + * @version DragonBones 5.6 + * @language en_US + */ + /** + * - 插槽的显示对象的可见。 + * @default true + * @version DragonBones 5.6 + * @language zh_CN + */ + visible: boolean; + /** + * - The index of the display object displayed in the display list. + * @example + *
+         *     let slot = armature.getSlot("weapon");
+         *     slot.displayIndex = 3;
+         *     slot.displayController = "none";
+         * 
+ * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 此时显示的显示对象在显示列表中的索引。 + * @example + *
+         *     let slot = armature.getSlot("weapon");
+         *     slot.displayIndex = 3;
+         *     slot.displayController = "none";
+         * 
+ * @version DragonBones 4.5 + * @language zh_CN + */ + displayIndex: number; + /** + * - The slot name. + * @see dragonBones.SlotData#name + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 插槽名称。 + * @see dragonBones.SlotData#name + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly name: string; + /** + * - Contains a display list of display objects or child armatures. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 包含显示对象或子骨架的显示列表。 + * @version DragonBones 3.0 + * @language zh_CN + */ + displayList: Array; + /** + * - The slot data. + * @see dragonBones.SlotData + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 插槽数据。 + * @see dragonBones.SlotData + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly slotData: SlotData; + /** + * @private + */ + rawDisplayDatas: Array | null; + /** + * - The custom bounding box data for the slot at current time. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 插槽此时的自定义包围盒数据。 + * @version DragonBones 5.0 + * @language zh_CN + */ + readonly boundingBoxData: BoundingBoxData | null; + /** + * @private + */ + readonly rawDisplay: any; + /** + * @private + */ + readonly meshDisplay: any; + /** + * - The display object that the slot displays at this time. + * @example + *
+         *     let slot = armature.getSlot("text");
+         *     slot.display = new yourEngine.TextField();
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 插槽此时显示的显示对象。 + * @example + *
+         *     let slot = armature.getSlot("text");
+         *     slot.display = new yourEngine.TextField();
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + display: any; + /** + * - The child armature that the slot displayed at current time. + * @example + *
+         *     let slot = armature.getSlot("weapon");
+         *     slot.childArmature = factory.buildArmature("weapon_blabla", "weapon_blabla_project");
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 插槽此时显示的子骨架。 + * @example + *
+         *     let slot = armature.getSlot("weapon");
+         *     slot.childArmature = factory.buildArmature("weapon_blabla", "weapon_blabla_project");
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + childArmature: Armature | null; + /** + * - Deprecated, please refer to {@link #display}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #display}。 + * @deprecated + * @language zh_CN + */ + getDisplay(): any; + /** + * - Deprecated, please refer to {@link #display}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #display}。 + * @deprecated + * @language zh_CN + */ + setDisplay(value: any): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + abstract class Constraint extends BaseObject { + protected static readonly _helpMatrix: Matrix; + protected static readonly _helpTransform: Transform; + protected static readonly _helpPoint: Point; + /** + * - For timeline state. + * @internal + */ + _constraintData: ConstraintData; + protected _armature: Armature; + /** + * - For sort bones. + * @internal + */ + _target: Bone; + /** + * - For sort bones. + * @internal + */ + _root: Bone; + protected _bone: Bone | null; + protected _onClear(): void; + abstract init(constraintData: ConstraintData, armature: Armature): void; + abstract update(): void; + abstract invalidUpdate(): void; + readonly name: string; + } + /** + * @internal + * @private + */ + class IKConstraint extends Constraint { + static toString(): string; + private _scaleEnabled; + /** + * - For timeline state. + * @internal + */ + _bendPositive: boolean; + /** + * - For timeline state. + * @internal + */ + _weight: number; + protected _onClear(): void; + private _computeA(); + private _computeB(); + init(constraintData: ConstraintData, armature: Armature): void; + update(): void; + invalidUpdate(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - Play animation interface. (Both Armature and Wordclock implement the interface) + * Any instance that implements the interface can be added to the Worldclock instance and advance time by Worldclock instance uniformly. + * @see dragonBones.WorldClock + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 播放动画接口。 (Armature 和 WordClock 都实现了该接口) + * 任何实现了此接口的实例都可以添加到 WorldClock 实例中,由 WorldClock 实例统一更新时间。 + * @see dragonBones.WorldClock + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + interface IAnimatable { + /** + * - Advance time. + * @param passedTime - Passed time. (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 更新时间。 + * @param passedTime - 前进的时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + advanceTime(passedTime: number): void; + /** + * - The Wordclock instance to which the current belongs. + * @example + *
+         *     armature.clock = factory.clock; // Add armature to clock.
+         *     armature.clock = null; // Remove armature from clock.
+         * 
+ * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 当前所属的 WordClock 实例。 + * @example + *
+         *     armature.clock = factory.clock; // 将骨架添加到时钟。
+         *     armature.clock = null; // 将骨架从时钟移除。
+         * 
+ * @version DragonBones 5.0 + * @language zh_CN + */ + clock: WorldClock | null; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - Worldclock provides clock support for animations, advance time for each IAnimatable object added to the instance. + * @see dragonBones.IAnimateble + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - WorldClock 对动画提供时钟支持,为每个加入到该实例的 IAnimatable 对象更新时间。 + * @see dragonBones.IAnimateble + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + class WorldClock implements IAnimatable { + /** + * - Current time. (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 当前的时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + time: number; + /** + * - The play speed, used to control animation speed-shift play. + * [0: Stop play, (0~1): Slow play, 1: Normal play, (1~N): Fast play] + * @default 1.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 播放速度,用于控制动画变速播放。 + * [0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + timeScale: number; + private readonly _animatebles; + private _clock; + /** + * - Creating a Worldclock instance. Typically, you do not need to create Worldclock instance. + * When multiple Worldclock instances are running at different speeds, can achieving some specific animation effects, such as bullet time. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 创建一个 WorldClock 实例。通常并不需要创建 WorldClock 实例。 + * 当多个 WorldClock 实例使用不同的速度运行时,可以实现一些特殊的动画效果,比如子弹时间等。 + * @version DragonBones 3.0 + * @language zh_CN + */ + constructor(time?: number); + /** + * - Advance time for all IAnimatable instances. + * @param passedTime - Passed time. [-1: Automatically calculates the time difference between the current frame and the previous frame, [0~N): Passed time] (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 为所有的 IAnimatable 实例更新时间。 + * @param passedTime - 前进的时间。 [-1: 自动计算当前帧与上一帧的时间差, [0~N): 前进的时间] (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + advanceTime(passedTime: number): void; + /** + * - Check whether contains a specific instance of IAnimatable. + * @param value - The IAnimatable instance. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 检查是否包含特定的 IAnimatable 实例。 + * @param value - IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + contains(value: IAnimatable): boolean; + /** + * - Add IAnimatable instance. + * @param value - The IAnimatable instance. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 添加 IAnimatable 实例。 + * @param value - IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + add(value: IAnimatable): void; + /** + * - Removes a specified IAnimatable instance. + * @param value - The IAnimatable instance. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 移除特定的 IAnimatable 实例。 + * @param value - IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + remove(value: IAnimatable): void; + /** + * - Clear all IAnimatable instances. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 清除所有的 IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + clear(): void; + /** + * @inheritDoc + */ + clock: WorldClock | null; + /** + * - Deprecated, please refer to {@link dragonBones.BaseFactory#clock}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link dragonBones.BaseFactory#clock}。 + * @deprecated + * @language zh_CN + */ + static readonly clock: WorldClock; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The animation player is used to play the animation data and manage the animation states. + * @see dragonBones.AnimationData + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画播放器用来播放动画数据和管理动画状态。 + * @see dragonBones.AnimationData + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + class Animation extends BaseObject { + static toString(): string; + /** + * - The play speed of all animations. [0: Stop, (0~1): Slow, 1: Normal, (1~N): Fast] + * @default 1.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 所有动画的播放速度。 [0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + timeScale: number; + private _lockUpdate; + private _animationDirty; + private _inheritTimeScale; + private readonly _animationNames; + private readonly _animationStates; + private readonly _animations; + private _armature; + private _animationConfig; + private _lastAnimationState; + /** + * @private + */ + protected _onClear(): void; + private _fadeOut(animationConfig); + /** + * @internal + * @private + */ + init(armature: Armature): void; + /** + * @internal + * @private + */ + advanceTime(passedTime: number): void; + /** + * - Clear all animations states. + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 清除所有的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + reset(): void; + /** + * - Pause a specific animation state. + * @param animationName - The name of animation state. (If not set, it will pause all animations) + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 暂停指定动画状态的播放。 + * @param animationName - 动画状态名称。 (如果未设置,则暂停所有动画) + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + stop(animationName?: string | null): void; + /** + * - Play animation with a specific animation config. + * The API is still in the experimental phase and may encounter bugs or stability or compatibility issues when used. + * @param animationConfig - The animation config. + * @returns The playing animation state. + * @see dragonBones.AnimationConfig + * @beta + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 通过指定的动画配置来播放动画。 + * 该 API 仍在实验阶段,使用时可能遭遇 bug 或稳定性或兼容性问题。 + * @param animationConfig - 动画配置。 + * @returns 播放的动画状态。 + * @see dragonBones.AnimationConfig + * @beta + * @version DragonBones 5.0 + * @language zh_CN + */ + playConfig(animationConfig: AnimationConfig): AnimationState | null; + /** + * - Play a specific animation. + * @param animationName - The name of animation data. (If not set, The default animation will be played, or resume the animation playing from pause status, or replay the last playing animation) + * @param playTimes - Playing repeat times. [-1: Use default value of the animation data, 0: No end loop playing, [1~N]: Repeat N times] (default: -1) + * @returns The playing animation state. + * @example + *
+         *     armature.animation.play("walk");
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 播放指定动画。 + * @param animationName - 动画数据名称。 (如果未设置,则播放默认动画,或将暂停状态切换为播放状态,或重新播放之前播放的动画) + * @param playTimes - 循环播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) + * @returns 播放的动画状态。 + * @example + *
+         *     armature.animation.play("walk");
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + play(animationName?: string | null, playTimes?: number): AnimationState | null; + /** + * - Fade in a specific animation. + * @param animationName - The name of animation data. + * @param fadeInTime - The fade in time. [-1: Use the default value of animation data, [0~N]: The fade in time (In seconds)] (Default: -1) + * @param playTimes - playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) + * @param layer - The blending layer, the animation states in high level layer will get the blending weights with high priority, when the total blending weights are more than 1.0, there will be no more weights can be allocated to the other animation states. (Default: 0) + * @param group - The blending group name, it is typically used to specify the substitution of multiple animation states blending. (Default: null) + * @param fadeOutMode - The fade out mode, which is typically used to specify alternate mode of multiple animation states blending. (Default: AnimationFadeOutMode.SameLayerAndGroup) + * @returns The playing animation state. + * @example + *
+         *     armature.animation.fadeIn("walk", 0.3, 0, 0, "normalGroup").resetToPose = false;
+         *     armature.animation.fadeIn("attack", 0.3, 1, 0, "attackGroup").resetToPose = false;
+         * 
+ * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 淡入播放指定的动画。 + * @param animationName - 动画数据名称。 + * @param fadeInTime - 淡入时间。 [-1: 使用动画数据默认值, [0~N]: 淡入时间 (以秒为单位)] (默认: -1) + * @param playTimes - 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) + * @param layer - 混合图层,图层高的动画状态会优先获取混合权重,当混合权重分配总和超过 1.0 时,剩余的动画状态将不能再获得权重分配。 (默认: 0) + * @param group - 混合组名称,该属性通常用来指定多个动画状态混合时的相互替换关系。 (默认: null) + * @param fadeOutMode - 淡出模式,该属性通常用来指定多个动画状态混合时的相互替换模式。 (默认: AnimationFadeOutMode.SameLayerAndGroup) + * @returns 播放的动画状态。 + * @example + *
+         *     armature.animation.fadeIn("walk", 0.3, 0, 0, "normalGroup").resetToPose = false;
+         *     armature.animation.fadeIn("attack", 0.3, 1, 0, "attackGroup").resetToPose = false;
+         * 
+ * @version DragonBones 4.5 + * @language zh_CN + */ + fadeIn(animationName: string, fadeInTime?: number, playTimes?: number, layer?: number, group?: string | null, fadeOutMode?: AnimationFadeOutMode): AnimationState | null; + /** + * - Play a specific animation from the specific time. + * @param animationName - The name of animation data. + * @param time - The start time point of playing. (In seconds) + * @param playTimes - Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) + * @returns The played animation state. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 从指定时间开始播放指定的动画。 + * @param animationName - 动画数据名称。 + * @param time - 播放开始的时间。 (以秒为单位) + * @param playTimes - 循环播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) + * @returns 播放的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndPlayByTime(animationName: string, time?: number, playTimes?: number): AnimationState | null; + /** + * - Play a specific animation from the specific frame. + * @param animationName - The name of animation data. + * @param frame - The start frame of playing. + * @param playTimes - Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) + * @returns The played animation state. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 从指定帧开始播放指定的动画。 + * @param animationName - 动画数据名称。 + * @param frame - 播放开始的帧数。 + * @param playTimes - 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) + * @returns 播放的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndPlayByFrame(animationName: string, frame?: number, playTimes?: number): AnimationState | null; + /** + * - Play a specific animation from the specific progress. + * @param animationName - The name of animation data. + * @param progress - The start progress value of playing. + * @param playTimes - Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) + * @returns The played animation state. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 从指定进度开始播放指定的动画。 + * @param animationName - 动画数据名称。 + * @param progress - 开始播放的进度。 + * @param playTimes - 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) + * @returns 播放的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndPlayByProgress(animationName: string, progress?: number, playTimes?: number): AnimationState | null; + /** + * - Stop a specific animation at the specific time. + * @param animationName - The name of animation data. + * @param time - The stop time. (In seconds) + * @returns The played animation state. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 在指定时间停止指定动画播放 + * @param animationName - 动画数据名称。 + * @param time - 停止的时间。 (以秒为单位) + * @returns 播放的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndStopByTime(animationName: string, time?: number): AnimationState | null; + /** + * - Stop a specific animation at the specific frame. + * @param animationName - The name of animation data. + * @param frame - The stop frame. + * @returns The played animation state. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 在指定帧停止指定动画的播放 + * @param animationName - 动画数据名称。 + * @param frame - 停止的帧数。 + * @returns 播放的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndStopByFrame(animationName: string, frame?: number): AnimationState | null; + /** + * - Stop a specific animation at the specific progress. + * @param animationName - The name of animation data. + * @param progress - The stop progress value. + * @returns The played animation state. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 在指定的进度停止指定的动画播放。 + * @param animationName - 动画数据名称。 + * @param progress - 停止进度。 + * @returns 播放的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndStopByProgress(animationName: string, progress?: number): AnimationState | null; + /** + * - Get a specific animation state. + * @param animationName - The name of animation state. + * @example + *
+         *     armature.animation.play("walk");
+         *     let walkState = armature.animation.getState("walk");
+         *     walkState.timeScale = 0.5;
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取指定的动画状态 + * @param animationName - 动画状态名称。 + * @example + *
+         *     armature.animation.play("walk");
+         *     let walkState = armature.animation.getState("walk");
+         *     walkState.timeScale = 0.5;
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + getState(animationName: string): AnimationState | null; + /** + * - Check whether a specific animation data is included. + * @param animationName - The name of animation data. + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 检查是否包含指定的动画数据 + * @param animationName - 动画数据名称。 + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language zh_CN + */ + hasAnimation(animationName: string): boolean; + /** + * - Get all the animation states. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 获取所有的动画状态 + * @version DragonBones 5.1 + * @language zh_CN + */ + getStates(): Array; + /** + * - Check whether there is an animation state is playing + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 检查是否有动画状态正在播放 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly isPlaying: boolean; + /** + * - Check whether all the animation states' playing were finished. + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 检查是否所有的动画状态均已播放完毕。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly isCompleted: boolean; + /** + * - The name of the last playing animation state. + * @see #lastAnimationState + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 上一个播放的动画状态名称 + * @see #lastAnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly lastAnimationName: string; + /** + * - The name of all animation data + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 所有动画数据的名称 + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly animationNames: Array; + /** + * - All animation data. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 所有的动画数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + animations: Map; + /** + * - An AnimationConfig instance that can be used quickly. + * @see dragonBones.AnimationConfig + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 一个可以快速使用的动画配置实例。 + * @see dragonBones.AnimationConfig + * @version DragonBones 5.0 + * @language zh_CN + */ + readonly animationConfig: AnimationConfig; + /** + * - The last playing animation state + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 上一个播放的动画状态 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly lastAnimationState: AnimationState | null; + /** + * - Deprecated, please refer to {@link #play()} {@link #fadeIn()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #play()} {@link #fadeIn()}。 + * @deprecated + * @language zh_CN + */ + gotoAndPlay(animationName: string, fadeInTime?: number, duration?: number, playTimes?: number, layer?: number, group?: string | null, fadeOutMode?: AnimationFadeOutMode, pauseFadeOut?: boolean, pauseFadeIn?: boolean): AnimationState | null; + /** + * - Deprecated, please refer to {@link #gotoAndStopByTime()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #gotoAndStopByTime()}。 + * @deprecated + * @language zh_CN + */ + gotoAndStop(animationName: string, time?: number): AnimationState | null; + /** + * - Deprecated, please refer to {@link #animationNames}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #animationNames}。 + * @deprecated + * @language zh_CN + */ + readonly animationList: Array; + /** + * - Deprecated, please refer to {@link #animationNames}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #animationNames}。 + * @deprecated + * @language zh_CN + */ + readonly animationDataList: Array; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The animation state is generated when the animation data is played. + * @see dragonBones.Animation + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画状态由播放动画数据时产生。 + * @see dragonBones.Animation + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language zh_CN + */ + class AnimationState extends BaseObject { + static toString(): string; + /** + * @private + */ + actionEnabled: boolean; + /** + * @private + */ + additiveBlending: boolean; + /** + * - Whether the animation state has control over the display object properties of the slots. + * Sometimes blend a animation state does not want it to control the display object properties of the slots, + * especially if other animation state are controlling the display object properties of the slots. + * @default true + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画状态是否对插槽的显示对象属性有控制权。 + * 有时混合一个动画状态并不希望其控制插槽的显示对象属性, + * 尤其是其他动画状态正在控制这些插槽的显示对象属性时。 + * @default true + * @version DragonBones 5.0 + * @language zh_CN + */ + displayControl: boolean; + /** + * - Whether to reset the objects without animation to the armature pose when the animation state is start to play. + * This property should usually be set to false when blend multiple animation states. + * @default true + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 开始播放动画状态时是否将没有动画的对象重置为骨架初始值。 + * 通常在混合多个动画状态时应该将该属性设置为 false。 + * @default true + * @version DragonBones 5.1 + * @language zh_CN + */ + resetToPose: boolean; + /** + * - The play times. [0: Loop play, [1~N]: Play N times] + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 播放次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次] + * @version DragonBones 3.0 + * @language zh_CN + */ + playTimes: number; + /** + * - The blend layer. + * High layer animation state will get the blend weight first. + * When the blend weight is assigned more than 1, the remaining animation states will no longer get the weight assigned. + * @readonly + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 混合图层。 + * 图层高的动画状态会优先获取混合权重。 + * 当混合权重分配超过 1 时,剩余的动画状态将不再获得权重分配。 + * @readonly + * @version DragonBones 5.0 + * @language zh_CN + */ + layer: number; + /** + * - The play speed. + * The value is an overlay relationship with {@link dragonBones.Animation#timeScale}. + * [(-N~0): Reverse play, 0: Stop play, (0~1): Slow play, 1: Normal play, (1~N): Fast play] + * @default 1.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 播放速度。 + * 该值与 {@link dragonBones.Animation#timeScale} 是叠加关系。 + * [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + timeScale: number; + /** + * - The blend weight. + * @default 1.0 + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 混合权重。 + * @default 1.0 + * @version DragonBones 5.0 + * @language zh_CN + */ + weight: number; + /** + * - The auto fade out time when the animation state play completed. + * [-1: Do not fade out automatically, [0~N]: The fade out time] (In seconds) + * @default -1.0 + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画状态播放完成后的自动淡出时间。 + * [-1: 不自动淡出, [0~N]: 淡出时间] (以秒为单位) + * @default -1.0 + * @version DragonBones 5.0 + * @language zh_CN + */ + autoFadeOutTime: number; + /** + * @private + */ + fadeTotalTime: number; + /** + * - The name of the animation state. (Can be different from the name of the animation data) + * @readonly + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画状态名称。 (可以不同于动画数据) + * @readonly + * @version DragonBones 5.0 + * @language zh_CN + */ + name: string; + /** + * - The blend group name of the animation state. + * This property is typically used to specify the substitution of multiple animation states blend. + * @readonly + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 混合组名称。 + * 该属性通常用来指定多个动画状态混合时的相互替换关系。 + * @readonly + * @version DragonBones 5.0 + * @language zh_CN + */ + group: string; + private _timelineDirty; + /** + * - xx: Play Enabled, Fade Play Enabled + * @internal + * @private + */ + _playheadState: number; + /** + * -1: Fade in, 0: Fade complete, 1: Fade out; + * @internal + * @private + */ + _fadeState: number; + /** + * -1: Fade start, 0: Fading, 1: Fade complete; + * @internal + * @private + */ + _subFadeState: number; + /** + * @internal + * @private + */ + _position: number; + /** + * @internal + * @private + */ + _duration: number; + private _fadeTime; + private _time; + /** + * @internal + * @private + */ + _fadeProgress: number; + /** + * @internal + * @private + */ + _weightResult: number; + /** + * @internal + * @private + */ + readonly _blendState: BlendState; + private readonly _boneMask; + private readonly _boneTimelines; + private readonly _surfaceTimelines; + private readonly _slotTimelines; + private readonly _constraintTimelines; + private readonly _animationTimelines; + private readonly _poseTimelines; + private readonly _bonePoses; + /** + * @internal + * @private + */ + _animationData: AnimationData; + private _armature; + /** + * @internal + * @private + */ + _actionTimeline: ActionTimelineState; + private _zOrderTimeline; + /** + * @internal + * @private + */ + _parent: AnimationState; + /** + * @private + */ + protected _onClear(): void; + private _updateTimelines(); + private _updateBoneAndSlotTimelines(); + private _advanceFadeTime(passedTime); + /** + * @internal + * @private + */ + init(armature: Armature, animationData: AnimationData, animationConfig: AnimationConfig): void; + /** + * @internal + * @private + */ + advanceTime(passedTime: number, cacheFrameRate: number): void; + /** + * - Continue play. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 继续播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + play(): void; + /** + * - Stop play. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 暂停播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + stop(): void; + /** + * - Fade out the animation state. + * @param fadeOutTime - The fade out time. (In seconds) + * @param pausePlayhead - Whether to pause the animation playing when fade out. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 淡出动画状态。 + * @param fadeOutTime - 淡出时间。 (以秒为单位) + * @param pausePlayhead - 淡出时是否暂停播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + fadeOut(fadeOutTime: number, pausePlayhead?: boolean): void; + /** + * - Check if a specific bone mask is included. + * @param name - The bone name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 检查是否包含特定骨骼遮罩。 + * @param name - 骨骼名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + containsBoneMask(name: string): boolean; + /** + * - Add a specific bone mask. + * @param name - The bone name. + * @param recursive - Whether or not to add a mask to the bone's sub-bone. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 添加特定的骨骼遮罩。 + * @param name - 骨骼名称。 + * @param recursive - 是否为该骨骼的子骨骼添加遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + addBoneMask(name: string, recursive?: boolean): void; + /** + * - Remove the mask of a specific bone. + * @param name - The bone name. + * @param recursive - Whether to remove the bone's sub-bone mask. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 删除特定骨骼的遮罩。 + * @param name - 骨骼名称。 + * @param recursive - 是否删除该骨骼的子骨骼遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + removeBoneMask(name: string, recursive?: boolean): void; + /** + * - Remove all bone masks. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 删除所有骨骼遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + removeAllBoneMask(): void; + /** + * - Whether the animation state is fading in. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 是否正在淡入。 + * @version DragonBones 5.1 + * @language zh_CN + */ + readonly isFadeIn: boolean; + /** + * - Whether the animation state is fading out. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 是否正在淡出。 + * @version DragonBones 5.1 + * @language zh_CN + */ + readonly isFadeOut: boolean; + /** + * - Whether the animation state is fade completed. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 是否淡入或淡出完毕。 + * @version DragonBones 5.1 + * @language zh_CN + */ + readonly isFadeComplete: boolean; + /** + * - Whether the animation state is playing. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 是否正在播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly isPlaying: boolean; + /** + * - Whether the animation state is play completed. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 是否播放完毕。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly isCompleted: boolean; + /** + * - The times has been played. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 已经循环播放的次数。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly currentPlayTimes: number; + /** + * - The total time. (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 总播放时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly totalTime: number; + /** + * - The time is currently playing. (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 当前播放的时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + currentTime: number; + /** + * - The animation data. + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画数据。 + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly animationData: AnimationData; + } + /** + * @internal + * @private + */ + class BonePose extends BaseObject { + static toString(): string; + readonly current: Transform; + readonly delta: Transform; + readonly result: Transform; + protected _onClear(): void; + } + /** + * @internal + * @private + */ + class BlendState { + dirty: boolean; + layer: number; + leftWeight: number; + layerWeight: number; + blendWeight: number; + update(weight: number, layer: number): number; + clear(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + const enum TweenState { + None = 0, + Once = 1, + Always = 2, + } + /** + * @internal + * @private + */ + abstract class TimelineState extends BaseObject { + playState: number; + currentPlayTimes: number; + currentTime: number; + protected _tweenState: TweenState; + protected _frameRate: number; + protected _frameValueOffset: number; + protected _frameCount: number; + protected _frameOffset: number; + protected _frameIndex: number; + protected _frameRateR: number; + protected _position: number; + protected _duration: number; + protected _timeScale: number; + protected _timeOffset: number; + protected _dragonBonesData: DragonBonesData; + protected _animationData: AnimationData; + protected _timelineData: TimelineData | null; + protected _armature: Armature; + protected _animationState: AnimationState; + protected _actionTimeline: TimelineState; + protected _frameArray: Array | Int16Array; + protected _frameIntArray: Array | Int16Array; + protected _frameFloatArray: Array | Int16Array; + protected _timelineArray: Array | Uint16Array; + protected _frameIndices: Array; + protected _onClear(): void; + protected abstract _onArriveAtFrame(): void; + protected abstract _onUpdateFrame(): void; + protected _setCurrentTime(passedTime: number): boolean; + init(armature: Armature, animationState: AnimationState, timelineData: TimelineData | null): void; + fadeOut(): void; + update(passedTime: number): void; + } + /** + * @internal + * @private + */ + abstract class TweenTimelineState extends TimelineState { + private static _getEasingValue(tweenType, progress, easing); + private static _getEasingCurveValue(progress, samples, count, offset); + protected _tweenType: TweenType; + protected _curveCount: number; + protected _framePosition: number; + protected _frameDurationR: number; + protected _tweenProgress: number; + protected _tweenEasing: number; + protected _onClear(): void; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + } + /** + * @internal + * @private + */ + abstract class BoneTimelineState extends TweenTimelineState { + bone: Bone; + bonePose: BonePose; + protected _onClear(): void; + blend(state: number): void; + } + /** + * @internal + * @private + */ + abstract class SlotTimelineState extends TweenTimelineState { + slot: Slot; + protected _onClear(): void; + } + /** + * @internal + * @private + */ + abstract class ConstraintTimelineState extends TweenTimelineState { + constraint: Constraint; + protected _onClear(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + class ActionTimelineState extends TimelineState { + static toString(): string; + private _onCrossFrame(frameIndex); + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + update(passedTime: number): void; + setCurrentTime(value: number): void; + } + /** + * @internal + * @private + */ + class ZOrderTimelineState extends TimelineState { + static toString(): string; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + } + /** + * @internal + * @private + */ + class BoneAllTimelineState extends BoneTimelineState { + static toString(): string; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + fadeOut(): void; + } + /** + * @internal + * @private + */ + class BoneTranslateTimelineState extends BoneTimelineState { + static toString(): string; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + } + /** + * @internal + * @private + */ + class BoneRotateTimelineState extends BoneTimelineState { + static toString(): string; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + fadeOut(): void; + } + /** + * @internal + * @private + */ + class BoneScaleTimelineState extends BoneTimelineState { + static toString(): string; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + } + /** + * @internal + * @private + */ + class SurfaceTimelineState extends TweenTimelineState { + static toString(): string; + surface: Surface; + private _frameFloatOffset; + private _valueCount; + private _deformCount; + private _valueOffset; + private readonly _current; + private readonly _delta; + private readonly _result; + protected _onClear(): void; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + init(armature: Armature, animationState: AnimationState, timelineData: TimelineData | null): void; + blend(state: number): void; + } + /** + * @internal + * @private + */ + class SlotDislayTimelineState extends SlotTimelineState { + static toString(): string; + protected _onArriveAtFrame(): void; + } + /** + * @internal + * @private + */ + class SlotColorTimelineState extends SlotTimelineState { + static toString(): string; + private _dirty; + private readonly _current; + private readonly _delta; + private readonly _result; + protected _onClear(): void; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + fadeOut(): void; + update(passedTime: number): void; + } + /** + * @internal + * @private + */ + class SlotFFDTimelineState extends SlotTimelineState { + static toString(): string; + meshOffset: number; + private _dirty; + private _frameFloatOffset; + private _valueCount; + private _deformCount; + private _valueOffset; + private readonly _current; + private readonly _delta; + private readonly _result; + protected _onClear(): void; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + init(armature: Armature, animationState: AnimationState, timelineData: TimelineData | null): void; + fadeOut(): void; + update(passedTime: number): void; + } + /** + * @internal + * @private + */ + class IKConstraintTimelineState extends ConstraintTimelineState { + static toString(): string; + private _current; + private _delta; + protected _onClear(): void; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + } + /** + * @internal + * @private + */ + class AnimationTimelineState extends TweenTimelineState { + static toString(): string; + animationState: AnimationState; + private readonly _floats; + protected _onClear(): void; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + blend(state: number): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The properties of the object carry basic information about an event, + * which are passed as parameter or parameter's parameter to event listeners when an event occurs. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 事件对象,包含有关事件的基本信息,当发生事件时,该实例将作为参数或参数的参数传递给事件侦听器。 + * @version DragonBones 4.5 + * @language zh_CN + */ + class EventObject extends BaseObject { + /** + * - Animation start play. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画开始播放。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly START: string; + /** + * - Animation loop play complete once. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画循环播放完成一次。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly LOOP_COMPLETE: string; + /** + * - Animation play complete. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画播放完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly COMPLETE: string; + /** + * - Animation fade in start. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画淡入开始。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly FADE_IN: string; + /** + * - Animation fade in complete. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画淡入完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly FADE_IN_COMPLETE: string; + /** + * - Animation fade out start. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画淡出开始。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly FADE_OUT: string; + /** + * - Animation fade out complete. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画淡出完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly FADE_OUT_COMPLETE: string; + /** + * - Animation frame event. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画帧事件。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly FRAME_EVENT: string; + /** + * - Animation frame sound event. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画帧声音事件。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly SOUND_EVENT: string; + static toString(): string; + /** + * - If is a frame event, the value is used to describe the time that the event was in the animation timeline. (In seconds) + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 如果是帧事件,此值用来描述该事件在动画时间轴中所处的时间。(以秒为单位) + * @version DragonBones 4.5 + * @language zh_CN + */ + time: number; + /** + * - The event type。 + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 事件类型。 + * @version DragonBones 4.5 + * @language zh_CN + */ + type: EventStringType; + /** + * - The event name. (The frame event name or the frame sound name) + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 事件名称。 (帧事件的名称或帧声音的名称) + * @version DragonBones 4.5 + * @language zh_CN + */ + name: string; + /** + * - The armature that dispatch the event. + * @see dragonBones.Armature + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 发出该事件的骨架。 + * @see dragonBones.Armature + * @version DragonBones 4.5 + * @language zh_CN + */ + armature: Armature; + /** + * - The bone that dispatch the event. + * @see dragonBones.Bone + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 发出该事件的骨骼。 + * @see dragonBones.Bone + * @version DragonBones 4.5 + * @language zh_CN + */ + bone: Bone | null; + /** + * - The slot that dispatch the event. + * @see dragonBones.Slot + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 发出该事件的插槽。 + * @see dragonBones.Slot + * @version DragonBones 4.5 + * @language zh_CN + */ + slot: Slot | null; + /** + * - The animation state that dispatch the event. + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 发出该事件的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + animationState: AnimationState; + /** + * - The custom data. + * @see dragonBones.CustomData + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 自定义数据。 + * @see dragonBones.CustomData + * @version DragonBones 5.0 + * @language zh_CN + */ + data: UserData | null; + /** + * @private + */ + protected _onClear(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @private + */ + type EventStringType = string | "start" | "loopComplete" | "complete" | "fadeIn" | "fadeInComplete" | "fadeOut" | "fadeOutComplete" | "frameEvent" | "soundEvent"; + /** + * - The event dispatcher interface. + * Dragonbones event dispatch usually relies on docking engine to implement, which defines the event method to be implemented when docking the engine. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 事件派发接口。 + * DragonBones 的事件派发通常依赖于对接的引擎来实现,该接口定义了对接引擎时需要实现的事件方法。 + * @version DragonBones 4.5 + * @language zh_CN + */ + interface IEventDispatcher { + /** + * - Checks whether the object has any listeners registered for a specific type of event。 + * @param type - Event type. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 检查是否为特定的事件类型注册了任何侦听器。 + * @param type - 事件类型。 + * @version DragonBones 4.5 + * @language zh_CN + */ + hasDBEventListener(type: EventStringType): boolean; + /** + * - Dispatches an event into the event flow. + * @param type - Event type. + * @param eventObject - Event object. + * @see dragonBones.EventObject + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 分派特定的事件到事件流中。 + * @param type - 事件类型。 + * @param eventObject - 事件数据。 + * @see dragonBones.EventObject + * @version DragonBones 4.5 + * @language zh_CN + */ + dispatchDBEvent(type: EventStringType, eventObject: EventObject): void; + /** + * - Add an event listener object so that the listener receives notification of an event. + * @param type - Event type. + * @param listener - Event listener. + * @param thisObject - The listener function's "this". + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 添加特定事件类型的事件侦听器,以使侦听器能够接收事件通知。 + * @param type - 事件类型。 + * @param listener - 事件侦听器。 + * @param thisObject - 侦听函数绑定的 this 对象。 + * @version DragonBones 4.5 + * @language zh_CN + */ + addDBEventListener(type: EventStringType, listener: Function, thisObject: any): void; + /** + * - Removes a listener from the object. + * @param type - Event type. + * @param listener - Event listener. + * @param thisObject - The listener function's "this". + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 删除特定事件类型的侦听器。 + * @param type - 事件类型。 + * @param listener - 事件侦听器。 + * @param thisObject - 侦听函数绑定的 this 对象。 + * @version DragonBones 4.5 + * @language zh_CN + */ + removeDBEventListener(type: EventStringType, listener: Function, thisObject: any): void; + /** + * - Deprecated, please refer to {@link #hasDBEventListener()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #hasDBEventListener()}。 + * @deprecated + * @language zh_CN + */ + hasEvent(type: EventStringType): boolean; + /** + * - Deprecated, please refer to {@link #addDBEventListener()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #addDBEventListener()}。 + * @deprecated + * @language zh_CN + */ + addEvent(type: EventStringType, listener: Function, thisObject: any): void; + /** + * - Deprecated, please refer to {@link #removeDBEventListener()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #removeDBEventListener()}。 + * @deprecated + * @language zh_CN + */ + removeEvent(type: EventStringType, listener: Function, thisObject: any): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + abstract class DataParser { + protected static readonly DATA_VERSION_2_3: string; + protected static readonly DATA_VERSION_3_0: string; + protected static readonly DATA_VERSION_4_0: string; + protected static readonly DATA_VERSION_4_5: string; + protected static readonly DATA_VERSION_5_0: string; + protected static readonly DATA_VERSION_5_5: string; + protected static readonly DATA_VERSION: string; + protected static readonly DATA_VERSIONS: Array; + protected static readonly TEXTURE_ATLAS: string; + protected static readonly SUB_TEXTURE: string; + protected static readonly FORMAT: string; + protected static readonly IMAGE_PATH: string; + protected static readonly WIDTH: string; + protected static readonly HEIGHT: string; + protected static readonly ROTATED: string; + protected static readonly FRAME_X: string; + protected static readonly FRAME_Y: string; + protected static readonly FRAME_WIDTH: string; + protected static readonly FRAME_HEIGHT: string; + protected static readonly DRADON_BONES: string; + protected static readonly USER_DATA: string; + protected static readonly ARMATURE: string; + protected static readonly BONE: string; + protected static readonly SURFACE: string; + protected static readonly SLOT: string; + protected static readonly CONSTRAINT: string; + protected static readonly IK: string; + protected static readonly SKIN: string; + protected static readonly DISPLAY: string; + protected static readonly ANIMATION: string; + protected static readonly Z_ORDER: string; + protected static readonly FFD: string; + protected static readonly FRAME: string; + protected static readonly TRANSLATE_FRAME: string; + protected static readonly ROTATE_FRAME: string; + protected static readonly SCALE_FRAME: string; + protected static readonly DISPLAY_FRAME: string; + protected static readonly COLOR_FRAME: string; + protected static readonly DEFAULT_ACTIONS: string; + protected static readonly ACTIONS: string; + protected static readonly EVENTS: string; + protected static readonly INTS: string; + protected static readonly FLOATS: string; + protected static readonly STRINGS: string; + protected static readonly CANVAS: string; + protected static readonly TRANSFORM: string; + protected static readonly PIVOT: string; + protected static readonly AABB: string; + protected static readonly COLOR: string; + protected static readonly VERSION: string; + protected static readonly COMPATIBLE_VERSION: string; + protected static readonly FRAME_RATE: string; + protected static readonly TYPE: string; + protected static readonly SUB_TYPE: string; + protected static readonly NAME: string; + protected static readonly PARENT: string; + protected static readonly TARGET: string; + protected static readonly STAGE: string; + protected static readonly SHARE: string; + protected static readonly PATH: string; + protected static readonly LENGTH: string; + protected static readonly DISPLAY_INDEX: string; + protected static readonly BLEND_MODE: string; + protected static readonly INHERIT_TRANSLATION: string; + protected static readonly INHERIT_ROTATION: string; + protected static readonly INHERIT_SCALE: string; + protected static readonly INHERIT_REFLECTION: string; + protected static readonly INHERIT_ANIMATION: string; + protected static readonly INHERIT_DEFORM: string; + protected static readonly SEGMENT_X: string; + protected static readonly SEGMENT_Y: string; + protected static readonly BEND_POSITIVE: string; + protected static readonly CHAIN: string; + protected static readonly WEIGHT: string; + protected static readonly FADE_IN_TIME: string; + protected static readonly PLAY_TIMES: string; + protected static readonly SCALE: string; + protected static readonly OFFSET: string; + protected static readonly POSITION: string; + protected static readonly DURATION: string; + protected static readonly TWEEN_EASING: string; + protected static readonly TWEEN_ROTATE: string; + protected static readonly TWEEN_SCALE: string; + protected static readonly CLOCK_WISE: string; + protected static readonly CURVE: string; + protected static readonly SOUND: string; + protected static readonly EVENT: string; + protected static readonly ACTION: string; + protected static readonly X: string; + protected static readonly Y: string; + protected static readonly SKEW_X: string; + protected static readonly SKEW_Y: string; + protected static readonly SCALE_X: string; + protected static readonly SCALE_Y: string; + protected static readonly VALUE: string; + protected static readonly ROTATE: string; + protected static readonly SKEW: string; + protected static readonly ALPHA_OFFSET: string; + protected static readonly RED_OFFSET: string; + protected static readonly GREEN_OFFSET: string; + protected static readonly BLUE_OFFSET: string; + protected static readonly ALPHA_MULTIPLIER: string; + protected static readonly RED_MULTIPLIER: string; + protected static readonly GREEN_MULTIPLIER: string; + protected static readonly BLUE_MULTIPLIER: string; + protected static readonly UVS: string; + protected static readonly VERTICES: string; + protected static readonly TRIANGLES: string; + protected static readonly WEIGHTS: string; + protected static readonly SLOT_POSE: string; + protected static readonly BONE_POSE: string; + protected static readonly GLUE_WEIGHTS: string; + protected static readonly GLUE_MESHES: string; + protected static readonly GOTO_AND_PLAY: string; + protected static readonly DEFAULT_NAME: string; + protected static _getArmatureType(value: string): ArmatureType; + protected static _getBoneType(value: string): BoneType; + protected static _getDisplayType(value: string): DisplayType; + protected static _getBoundingBoxType(value: string): BoundingBoxType; + protected static _getActionType(value: string): ActionType; + protected static _getBlendMode(value: string): BlendMode; + abstract parseDragonBonesData(rawData: any, scale: number): DragonBonesData | null; + abstract parseTextureAtlasData(rawData: any, textureAtlasData: TextureAtlasData, scale: number): boolean; + /** + * - Deprecated, please refer to {@link dragonBones.BaseFactory#parsetTextureAtlasData()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link dragonBones.BaseFactory#parsetTextureAtlasData()}。 + * @deprecated + * @language zh_CN + */ + static parseDragonBonesData(rawData: any): DragonBonesData | null; + /** + * - Deprecated, please refer to {@link dragonBones.BaseFactory#parsetTextureAtlasData()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link dragonBones.BaseFactory#parsetTextureAtlasData()}。 + * @deprecated + * @language zh_CN + */ + static parseTextureAtlasData(rawData: any, scale?: number): any; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + class ObjectDataParser extends DataParser { + protected static _getBoolean(rawData: any, key: string, defaultValue: boolean): boolean; + protected static _getNumber(rawData: any, key: string, defaultValue: number): number; + protected static _getString(rawData: any, key: string, defaultValue: string): string; + protected _rawTextureAtlasIndex: number; + protected readonly _rawBones: Array; + protected _data: DragonBonesData; + protected _armature: ArmatureData; + protected _bone: BoneData; + protected _surface: SurfaceData; + protected _slot: SlotData; + protected _skin: SkinData; + protected _mesh: MeshDisplayData; + protected _animation: AnimationData; + protected _timeline: TimelineData; + protected _rawTextureAtlases: Array | null; + private _defaultColorOffset; + private _prevClockwise; + private _prevRotation; + private readonly _helpMatrixA; + private readonly _helpMatrixB; + private readonly _helpTransform; + private readonly _helpColorTransform; + private readonly _helpPoint; + private readonly _helpArray; + private readonly _intArray; + private readonly _floatArray; + private readonly _frameIntArray; + private readonly _frameFloatArray; + private readonly _frameArray; + private readonly _timelineArray; + private readonly _cacheRawMeshes; + private readonly _cacheMeshes; + private readonly _actionFrames; + private readonly _weightSlotPose; + private readonly _weightBonePoses; + private readonly _cacheBones; + private readonly _slotChildActions; + private _getCurvePoint(x1, y1, x2, y2, x3, y3, x4, y4, t, result); + private _samplingEasingCurve(curve, samples); + private _parseActionDataInFrame(rawData, frameStart, bone, slot); + private _mergeActionFrame(rawData, frameStart, type, bone, slot); + protected _parseArmature(rawData: any, scale: number): ArmatureData; + protected _parseBone(rawData: any): BoneData; + protected _parseIKConstraint(rawData: any): ConstraintData | null; + protected _parseSlot(rawData: any, zOrder: number): SlotData; + protected _parseSkin(rawData: any): SkinData; + protected _parseDisplay(rawData: any): DisplayData | null; + protected _parsePivot(rawData: any, display: ImageDisplayData): void; + protected _parseMesh(rawData: any, mesh: MeshDisplayData): void; + protected _parseMeshGlue(rawData: any, mesh: MeshDisplayData): void; + protected _parseBoundingBox(rawData: any): BoundingBoxData | null; + protected _parsePolygonBoundingBox(rawData: any): PolygonBoundingBoxData; + protected _parseAnimation(rawData: any): AnimationData; + protected _parseTimeline(rawData: any, rawFrames: Array | null, framesKey: string, type: TimelineType, addIntOffset: boolean, addFloatOffset: boolean, frameValueCount: number, frameParser: (rawData: any, frameStart: number, frameCount: number) => number): TimelineData | null; + protected _parseBoneTimeline(rawData: any): void; + protected _parseSlotTimeline(rawData: any): void; + protected _parseFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseTweenFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseActionFrame(frame: ActionFrame, frameStart: number, frameCount: number): number; + protected _parseZOrderFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseBoneAllFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseBoneTranslateFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseBoneRotateFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseBoneScaleFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseSurfaceFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseSlotDisplayFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseSlotColorFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseSlotFFDFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseIKConstraintFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseAnimationFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseActionData(rawData: any, type: ActionType, bone: BoneData | null, slot: SlotData | null): Array; + protected _parseTransform(rawData: any, transform: Transform, scale: number): void; + protected _parseColorTransform(rawData: any, color: ColorTransform): void; + protected _parseArray(rawData: any): void; + protected _modifyArray(): void; + parseDragonBonesData(rawData: any, scale?: number): DragonBonesData | null; + parseTextureAtlasData(rawData: any, textureAtlasData: TextureAtlasData, scale?: number): boolean; + private static _objectDataParserInstance; + /** + * - Deprecated, please refer to {@link dragonBones.BaseFactory#parseDragonBonesData()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link dragonBones.BaseFactory#parseDragonBonesData()}。 + * @deprecated + * @language zh_CN + */ + static getInstance(): ObjectDataParser; + } + /** + * @internal + * @private + */ + class ActionFrame { + frameStart: number; + readonly actions: Array; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + class BinaryDataParser extends ObjectDataParser { + private _binaryOffset; + private _binary; + private _intArrayBuffer; + private _floatArrayBuffer; + private _frameIntArrayBuffer; + private _frameFloatArrayBuffer; + private _frameArrayBuffer; + private _timelineArrayBuffer; + private _inRange(a, min, max); + private _decodeUTF8(data); + private _getUTF16Key(value); + private _parseBinaryTimeline(type, offset, timelineData?); + protected _parseMesh(rawData: any, mesh: MeshDisplayData): void; + protected _parseAnimation(rawData: any): AnimationData; + protected _parseArray(rawData: any): void; + parseDragonBonesData(rawData: any, scale?: number): DragonBonesData | null; + private static _binaryDataParserInstance; + /** + * - Deprecated, please refer to {@link dragonBones.BaseFactory#parseDragonBonesData()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link dragonBones.BaseFactory#parseDragonBonesData()}。 + * @deprecated + * @language zh_CN + */ + static getInstance(): BinaryDataParser; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - Base class for the factory that create the armatures. (Typically only one global factory instance is required) + * The factory instance create armatures by parsed and added DragonBonesData instances and TextureAtlasData instances. + * Once the data has been parsed, it has been cached in the factory instance and does not need to be parsed again until it is cleared by the factory instance. + * @see dragonBones.DragonBonesData + * @see dragonBones.TextureAtlasData + * @see dragonBones.ArmatureData + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 创建骨架的工厂基类。 (通常只需要一个全局工厂实例) + * 工厂通过解析并添加的 DragonBonesData 实例和 TextureAtlasData 实例来创建骨架。 + * 当数据被解析过之后,已经添加到工厂中,在没有被工厂清理之前,不需要再次解析。 + * @see dragonBones.DragonBonesData + * @see dragonBones.TextureAtlasData + * @see dragonBones.ArmatureData + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + abstract class BaseFactory { + /** + * @private + */ + protected static _objectParser: ObjectDataParser; + /** + * @private + */ + protected static _binaryParser: BinaryDataParser; + /** + * @private + */ + autoSearch: boolean; + /** + * @private + */ + protected readonly _dragonBonesDataMap: Map; + /** + * @private + */ + protected readonly _textureAtlasDataMap: Map>; + /** + * @private + */ + protected _dragonBones: DragonBones; + /** + * @private + */ + protected _dataParser: DataParser; + /** + * - Create a factory instance. (typically only one global factory instance is required) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 创建一个工厂实例。 (通常只需要一个全局工厂实例) + * @version DragonBones 3.0 + * @language zh_CN + */ + constructor(dataParser?: DataParser | null); + /** + * @private + */ + protected _isSupportMesh(): boolean; + /** + * @private + */ + protected _getTextureData(textureAtlasName: string, textureName: string): TextureData | null; + /** + * @private + */ + protected _fillBuildArmaturePackage(dataPackage: BuildArmaturePackage, dragonBonesName: string, armatureName: string, skinName: string, textureAtlasName: string): boolean; + /** + * @private + */ + protected _buildBones(dataPackage: BuildArmaturePackage, armature: Armature): void; + /** + * @private + */ + protected _buildSlots(dataPackage: BuildArmaturePackage, armature: Armature): void; + /** + * @private + */ + protected _buildChildArmature(dataPackage: BuildArmaturePackage | null, slot: Slot, displayData: DisplayData): Armature | null; + /** + * @private + */ + protected _getSlotDisplay(dataPackage: BuildArmaturePackage | null, displayData: DisplayData, rawDisplayData: DisplayData | null, slot: Slot): any; + /** + * @private + */ + protected abstract _buildTextureAtlasData(textureAtlasData: TextureAtlasData | null, textureAtlas: any): TextureAtlasData; + /** + * @private + */ + protected abstract _buildArmature(dataPackage: BuildArmaturePackage): Armature; + /** + * @private + */ + protected abstract _buildSlot(dataPackage: BuildArmaturePackage, slotData: SlotData, displays: Array | null, armature: Armature): Slot; + /** + * - Parse the raw data to a DragonBonesData instance and cache it to the factory. + * @param rawData - The raw data. + * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (If not set, use the instance name instead) + * @param scale - Specify a scaling value for all armatures. (Default: 1.0) + * @returns DragonBonesData instance + * @see #getDragonBonesData() + * @see #addDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 将原始数据解析为 DragonBonesData 实例,并缓存到工厂中。 + * @param rawData - 原始数据。 + * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) + * @param scale - 为所有的骨架指定一个缩放值。 (默认: 1.0) + * @returns DragonBonesData 实例 + * @see #getDragonBonesData() + * @see #addDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 4.5 + * @language zh_CN + */ + parseDragonBonesData(rawData: any, name?: string | null, scale?: number): DragonBonesData | null; + /** + * - Parse the raw texture atlas data and the texture atlas object to a TextureAtlasData instance and cache it to the factory. + * @param rawData - The raw texture atlas data. + * @param textureAtlas - The texture atlas object. + * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (If not set, use the instance name instead) + * @param scale - Specify a scaling value for the map set. (Default: 1.0) + * @returns TextureAtlasData instance + * @see #getTextureAtlasData() + * @see #addTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 将原始贴图集数据和贴图集对象解析为 TextureAtlasData 实例,并缓存到工厂中。 + * @param rawData - 原始贴图集数据。 + * @param textureAtlas - 贴图集对象。 + * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) + * @param scale - 为贴图集指定一个缩放值。 (默认: 1.0) + * @returns TextureAtlasData 实例 + * @see #getTextureAtlasData() + * @see #addTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 4.5 + * @language zh_CN + */ + parseTextureAtlasData(rawData: any, textureAtlas: any, name?: string | null, scale?: number): TextureAtlasData; + /** + * @private + */ + updateTextureAtlasData(name: string, textureAtlases: Array): void; + /** + * - Get a specific DragonBonesData instance. + * @param name - The DragonBonesData instance cache name. + * @returns DragonBonesData instance + * @see #parseDragonBonesData() + * @see #addDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的 DragonBonesData 实例。 + * @param name - DragonBonesData 实例的缓存名称。 + * @returns DragonBonesData 实例 + * @see #parseDragonBonesData() + * @see #addDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language zh_CN + */ + getDragonBonesData(name: string): DragonBonesData | null; + /** + * - Cache a DragonBonesData instance to the factory. + * @param data - The DragonBonesData instance. + * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (if not set, use the instance name instead) + * @see #parseDragonBonesData() + * @see #getDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 将 DragonBonesData 实例缓存到工厂中。 + * @param data - DragonBonesData 实例。 + * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) + * @see #parseDragonBonesData() + * @see #getDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language zh_CN + */ + addDragonBonesData(data: DragonBonesData, name?: string | null): void; + /** + * - Remove a DragonBonesData instance. + * @param name - The DragonBonesData instance cache name. + * @param disposeData - Whether to dispose data. (Default: true) + * @see #parseDragonBonesData() + * @see #getDragonBonesData() + * @see #addDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 移除 DragonBonesData 实例。 + * @param name - DragonBonesData 实例缓存名称。 + * @param disposeData - 是否释放数据。 (默认: true) + * @see #parseDragonBonesData() + * @see #getDragonBonesData() + * @see #addDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language zh_CN + */ + removeDragonBonesData(name: string, disposeData?: boolean): void; + /** + * - Get a list of specific TextureAtlasData instances. + * @param name - The TextureAtlasData cahce name. + * @see #parseTextureAtlasData() + * @see #addTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的 TextureAtlasData 实例列表。 + * @param name - TextureAtlasData 实例缓存名称。 + * @see #parseTextureAtlasData() + * @see #addTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language zh_CN + */ + getTextureAtlasData(name: string): Array | null; + /** + * - Cache a TextureAtlasData instance to the factory. + * @param data - The TextureAtlasData instance. + * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (if not set, use the instance name instead) + * @see #parseTextureAtlasData() + * @see #getTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 将 TextureAtlasData 实例缓存到工厂中。 + * @param data - TextureAtlasData 实例。 + * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) + * @see #parseTextureAtlasData() + * @see #getTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language zh_CN + */ + addTextureAtlasData(data: TextureAtlasData, name?: string | null): void; + /** + * - Remove a TextureAtlasData instance. + * @param name - The TextureAtlasData instance cache name. + * @param disposeData - Whether to dispose data. + * @see #parseTextureAtlasData() + * @see #getTextureAtlasData() + * @see #addTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 移除 TextureAtlasData 实例。 + * @param name - TextureAtlasData 实例的缓存名称。 + * @param disposeData - 是否释放数据。 + * @see #parseTextureAtlasData() + * @see #getTextureAtlasData() + * @see #addTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language zh_CN + */ + removeTextureAtlasData(name: string, disposeData?: boolean): void; + /** + * - Get a specific armature data. + * @param name - The armature data name. + * @param dragonBonesName - The cached name for DragonbonesData instance. + * @see dragonBones.ArmatureData + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 获取特定的骨架数据。 + * @param name - 骨架数据名称。 + * @param dragonBonesName - DragonBonesData 实例的缓存名称。 + * @see dragonBones.ArmatureData + * @version DragonBones 5.1 + * @language zh_CN + */ + getArmatureData(name: string, dragonBonesName?: string): ArmatureData | null; + /** + * - Clear all cached DragonBonesData instances and TextureAtlasData instances. + * @param disposeData - Whether to dispose data. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 清除缓存的所有 DragonBonesData 实例和 TextureAtlasData 实例。 + * @param disposeData - 是否释放数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + clear(disposeData?: boolean): void; + /** + * - Create a armature from cached DragonBonesData instances and TextureAtlasData instances. + * @param armatureName - The armature data name. + * @param dragonBonesName - The cached name of the DragonBonesData instance. (If not set, all DragonBonesData instances are retrieved, and when multiple DragonBonesData instances contain a the same name armature data, it may not be possible to accurately create a specific armature) + * @param skinName - The skin name, you can set a different ArmatureData name to share it's skin data. (If not set, use the default skin data) + * @returns The armature. + * @example + *
+         *     let armature = factory.buildArmature("armatureName", "dragonBonesName");
+         *     armature.clock = factory.clock;
+         * 
+ * @see dragonBones.DragonBonesData + * @see dragonBones.ArmatureData + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 通过缓存的 DragonBonesData 实例和 TextureAtlasData 实例创建一个骨架。 + * @param armatureName - 骨架数据名称。 + * @param dragonBonesName - DragonBonesData 实例的缓存名称。 (如果未设置,将检索所有的 DragonBonesData 实例,当多个 DragonBonesData 实例中包含同名的骨架数据时,可能无法准确的创建出特定的骨架) + * @param skinName - 皮肤名称,可以设置一个其他骨架数据名称来共享其皮肤数据(如果未设置,则使用默认的皮肤数据)。 + * @returns 骨架。 + * @example + *
+         *     let armature = factory.buildArmature("armatureName", "dragonBonesName");
+         *     armature.clock = factory.clock;
+         * 
+ * @see dragonBones.DragonBonesData + * @see dragonBones.ArmatureData + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + buildArmature(armatureName: string, dragonBonesName?: string, skinName?: string, textureAtlasName?: string): Armature | null; + /** + * @private + */ + replaceDisplay(slot: Slot, displayData: DisplayData, displayIndex?: number): void; + /** + * - Replaces the current display data for a particular slot with a specific display data. + * Specify display data with "dragonBonesName/armatureName/slotName/displayName". + * @param dragonBonesName - The DragonBonesData instance cache name. + * @param armatureName - The armature data name. + * @param slotName - The slot data name. + * @param displayName - The display data name. + * @param slot - The slot. + * @param displayIndex - The index of the display data that is replaced. (If it is not set, replaces the current display data) + * @example + *
+         *     let slot = armature.getSlot("weapon");
+         *     factory.replaceSlotDisplay("dragonBonesName", "armatureName", "slotName", "displayName", slot);
+         * 
+ * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 用特定的显示对象数据替换特定插槽当前的显示对象数据。 + * 用 "dragonBonesName/armatureName/slotName/displayName" 指定显示对象数据。 + * @param dragonBonesName - DragonBonesData 实例的缓存名称。 + * @param armatureName - 骨架数据名称。 + * @param slotName - 插槽数据名称。 + * @param displayName - 显示对象数据名称。 + * @param slot - 插槽。 + * @param displayIndex - 被替换的显示对象数据的索引。 (如果未设置,则替换当前的显示对象数据) + * @example + *
+         *     let slot = armature.getSlot("weapon");
+         *     factory.replaceSlotDisplay("dragonBonesName", "armatureName", "slotName", "displayName", slot);
+         * 
+ * @version DragonBones 4.5 + * @language zh_CN + */ + replaceSlotDisplay(dragonBonesName: string, armatureName: string, slotName: string, displayName: string, slot: Slot, displayIndex?: number): boolean; + /** + * @private + */ + replaceSlotDisplayList(dragonBonesName: string | null, armatureName: string, slotName: string, slot: Slot): boolean; + /** + * - Share specific skin data with specific armature. + * @param armature - The armature. + * @param skin - The skin data. + * @param isOverride - Whether it completely override the original skin. (Default: false) + * @param exclude - A list of slot names that do not need to be replace. + * @example + *
+         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
+         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
+         *     if (armatureDataB && armatureDataB.defaultSkin) {
+         *     factory.replaceSkin(armatureA, armatureDataB.defaultSkin, false, ["arm_l", "weapon_l"]);
+         *     }
+         * 
+ * @see dragonBones.Armature + * @see dragonBones.SkinData + * @version DragonBones 5.6 + * @language en_US + */ + /** + * - 将特定的皮肤数据共享给特定的骨架使用。 + * @param armature - 骨架。 + * @param skin - 皮肤数据。 + * @param isOverride - 是否完全覆盖原来的皮肤。 (默认: false) + * @param exclude - 不需要被替换的插槽名称列表。 + * @example + *
+         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
+         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
+         *     if (armatureDataB && armatureDataB.defaultSkin) {
+         *     factory.replaceSkin(armatureA, armatureDataB.defaultSkin, false, ["arm_l", "weapon_l"]);
+         *     }
+         * 
+ * @see dragonBones.Armature + * @see dragonBones.SkinData + * @version DragonBones 5.6 + * @language zh_CN + */ + replaceSkin(armature: Armature, skin: SkinData, isOverride?: boolean, exclude?: Array | null): boolean; + /** + * - Replaces the existing animation data for a specific armature with the animation data for the specific armature data. + * This enables you to make a armature template so that other armature without animations can share it's animations. + * @param armature - The armtaure. + * @param armatureData - The armature data. + * @param isOverride - Whether to completely overwrite the original animation. (Default: false) + * @example + *
+         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
+         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
+         *     if (armatureDataB) {
+         *     factory.replaceAnimation(armatureA, armatureDataB);
+         *     }
+         * 
+ * @see dragonBones.Armature + * @see dragonBones.ArmatureData + * @version DragonBones 5.6 + * @language en_US + */ + /** + * - 用特定骨架数据的动画数据替换特定骨架现有的动画数据。 + * 这样就能实现制作一个骨架动画模板,让其他没有制作动画的骨架共享该动画。 + * @param armature - 骨架。 + * @param armatureData - 骨架数据。 + * @param isOverride - 是否完全覆盖原来的动画。(默认: false)。 + * @example + *
+         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
+         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
+         *     if (armatureDataB) {
+         *     factory.replaceAnimation(armatureA, armatureDataB);
+         *     }
+         * 
+ * @see dragonBones.Armature + * @see dragonBones.ArmatureData + * @version DragonBones 5.6 + * @language zh_CN + */ + replaceAnimation(armature: Armature, armatureData: ArmatureData, isOverride?: boolean): boolean; + /** + * @private + */ + getAllDragonBonesData(): Map; + /** + * @private + */ + getAllTextureAtlasData(): Map>; + /** + * - An Worldclock instance updated by engine. + * @version DragonBones 5.7 + * @language en_US + */ + /** + * - 由引擎驱动的 WorldClock 实例。 + * @version DragonBones 5.7 + * @language zh_CN + */ + readonly clock: WorldClock; + /** + * @private + */ + readonly dragonBones: DragonBones; + /** + * - Deprecated, please refer to {@link #replaceSkin}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #replaceSkin}。 + * @deprecated + * @language zh_CN + */ + changeSkin(armature: Armature, skin: SkinData, exclude?: Array | null): boolean; + /** + * - Deprecated, please refer to {@link #replaceAnimation}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #replaceAnimation}。 + * @deprecated + * @language zh_CN + */ + copyAnimationsToArmature(toArmature: Armature, fromArmatreName: string, fromSkinName?: string, fromDragonBonesDataName?: string, replaceOriginalAnimation?: boolean): boolean; + } + /** + * @internal + * @private + */ + class BuildArmaturePackage { + dataName: string; + textureAtlasName: string; + data: DragonBonesData; + armature: ArmatureData; + skin: SkinData | null; + } +} + +declare namespace sp.spine { + class Animation { + name: string; + timelines: Array; + timelineIds: Array; + duration: number; + constructor(name: string, timelines: Array, duration: number); + hasTimeline(id: number): boolean; + apply(skeleton: Skeleton, lastTime: number, time: number, loop: boolean, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + static binarySearch(values: ArrayLike, target: number, step?: number): number; + static linearSearch(values: ArrayLike, target: number, step: number): number; + } + interface Timeline { + apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + getPropertyId(): number; + } + enum MixBlend { + setup = 0, + first = 1, + replace = 2, + add = 3 + } + enum MixDirection { + mixIn = 0, + mixOut = 1 + } + enum TimelineType { + rotate = 0, + translate = 1, + scale = 2, + shear = 3, + attachment = 4, + color = 5, + deform = 6, + event = 7, + drawOrder = 8, + ikConstraint = 9, + transformConstraint = 10, + pathConstraintPosition = 11, + pathConstraintSpacing = 12, + pathConstraintMix = 13, + twoColor = 14 + } + abstract class CurveTimeline implements Timeline { + static LINEAR: number; + static STEPPED: number; + static BEZIER: number; + static BEZIER_SIZE: number; + private curves; + abstract getPropertyId(): number; + constructor(frameCount: number); + getFrameCount(): number; + setLinear(frameIndex: number): void; + setStepped(frameIndex: number): void; + getCurveType(frameIndex: number): number; + setCurve(frameIndex: number, cx1: number, cy1: number, cx2: number, cy2: number): void; + getCurvePercent(frameIndex: number, percent: number): number; + abstract apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class RotateTimeline extends CurveTimeline { + static ENTRIES: number; + static PREV_TIME: number; + static PREV_ROTATION: number; + static ROTATION: number; + boneIndex: number; + frames: ArrayLike; + constructor(frameCount: number); + getPropertyId(): number; + setFrame(frameIndex: number, time: number, degrees: number): void; + apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class TranslateTimeline extends CurveTimeline { + static ENTRIES: number; + static PREV_TIME: number; + static PREV_X: number; + static PREV_Y: number; + static X: number; + static Y: number; + boneIndex: number; + frames: ArrayLike; + constructor(frameCount: number); + getPropertyId(): number; + setFrame(frameIndex: number, time: number, x: number, y: number): void; + apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class ScaleTimeline extends TranslateTimeline { + constructor(frameCount: number); + getPropertyId(): number; + apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class ShearTimeline extends TranslateTimeline { + constructor(frameCount: number); + getPropertyId(): number; + apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class ColorTimeline extends CurveTimeline { + static ENTRIES: number; + static PREV_TIME: number; + static PREV_R: number; + static PREV_G: number; + static PREV_B: number; + static PREV_A: number; + static R: number; + static G: number; + static B: number; + static A: number; + slotIndex: number; + frames: ArrayLike; + constructor(frameCount: number); + getPropertyId(): number; + setFrame(frameIndex: number, time: number, r: number, g: number, b: number, a: number): void; + apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class TwoColorTimeline extends CurveTimeline { + static ENTRIES: number; + static PREV_TIME: number; + static PREV_R: number; + static PREV_G: number; + static PREV_B: number; + static PREV_A: number; + static PREV_R2: number; + static PREV_G2: number; + static PREV_B2: number; + static R: number; + static G: number; + static B: number; + static A: number; + static R2: number; + static G2: number; + static B2: number; + slotIndex: number; + frames: ArrayLike; + constructor(frameCount: number); + getPropertyId(): number; + setFrame(frameIndex: number, time: number, r: number, g: number, b: number, a: number, r2: number, g2: number, b2: number): void; + apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class AttachmentTimeline implements Timeline { + slotIndex: number; + frames: ArrayLike; + attachmentNames: Array; + constructor(frameCount: number); + getPropertyId(): number; + getFrameCount(): number; + setFrame(frameIndex: number, time: number, attachmentName: string): void; + apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class DeformTimeline extends CurveTimeline { + slotIndex: number; + attachment: VertexAttachment; + frames: ArrayLike; + frameVertices: Array>; + constructor(frameCount: number); + getPropertyId(): number; + setFrame(frameIndex: number, time: number, vertices: ArrayLike): void; + apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class EventTimeline implements Timeline { + frames: ArrayLike; + events: Array; + constructor(frameCount: number); + getPropertyId(): number; + getFrameCount(): number; + setFrame(frameIndex: number, event: Event): void; + apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class DrawOrderTimeline implements Timeline { + frames: ArrayLike; + drawOrders: Array>; + constructor(frameCount: number); + getPropertyId(): number; + getFrameCount(): number; + setFrame(frameIndex: number, time: number, drawOrder: Array): void; + apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class IkConstraintTimeline extends CurveTimeline { + static ENTRIES: number; + static PREV_TIME: number; + static PREV_MIX: number; + static PREV_SOFTNESS: number; + static PREV_BEND_DIRECTION: number; + static PREV_COMPRESS: number; + static PREV_STRETCH: number; + static MIX: number; + static SOFTNESS: number; + static BEND_DIRECTION: number; + static COMPRESS: number; + static STRETCH: number; + ikConstraintIndex: number; + frames: ArrayLike; + constructor(frameCount: number); + getPropertyId(): number; + setFrame(frameIndex: number, time: number, mix: number, softness: number, bendDirection: number, compress: boolean, stretch: boolean): void; + apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class TransformConstraintTimeline extends CurveTimeline { + static ENTRIES: number; + static PREV_TIME: number; + static PREV_ROTATE: number; + static PREV_TRANSLATE: number; + static PREV_SCALE: number; + static PREV_SHEAR: number; + static ROTATE: number; + static TRANSLATE: number; + static SCALE: number; + static SHEAR: number; + transformConstraintIndex: number; + frames: ArrayLike; + constructor(frameCount: number); + getPropertyId(): number; + setFrame(frameIndex: number, time: number, rotateMix: number, translateMix: number, scaleMix: number, shearMix: number): void; + apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class PathConstraintPositionTimeline extends CurveTimeline { + static ENTRIES: number; + static PREV_TIME: number; + static PREV_VALUE: number; + static VALUE: number; + pathConstraintIndex: number; + frames: ArrayLike; + constructor(frameCount: number); + getPropertyId(): number; + setFrame(frameIndex: number, time: number, value: number): void; + apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class PathConstraintSpacingTimeline extends PathConstraintPositionTimeline { + constructor(frameCount: number); + getPropertyId(): number; + apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class PathConstraintMixTimeline extends CurveTimeline { + static ENTRIES: number; + static PREV_TIME: number; + static PREV_ROTATE: number; + static PREV_TRANSLATE: number; + static ROTATE: number; + static TRANSLATE: number; + pathConstraintIndex: number; + frames: ArrayLike; + constructor(frameCount: number); + getPropertyId(): number; + setFrame(frameIndex: number, time: number, rotateMix: number, translateMix: number): void; + apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } +} +declare namespace sp.spine { + class AnimationState { + static emptyAnimation: Animation; + static SUBSEQUENT: number; + static FIRST: number; + static HOLD: number; + static HOLD_MIX: number; + static NOT_LAST: number; + data: AnimationStateData; + tracks: TrackEntry[]; + timeScale: number; + events: Event[]; + listeners: AnimationStateListener[]; + queue: EventQueue; + propertyIDs: IntSet; + animationsChanged: boolean; + trackEntryPool: Pool; + constructor(data: AnimationStateData); + update(delta: number): void; + updateMixingFrom(to: TrackEntry, delta: number): boolean; + apply(skeleton: Skeleton): boolean; + applyMixingFrom(to: TrackEntry, skeleton: Skeleton, blend: MixBlend): number; + applyRotateTimeline(timeline: Timeline, skeleton: Skeleton, time: number, alpha: number, blend: MixBlend, timelinesRotation: Array, i: number, firstFrame: boolean): void; + queueEvents(entry: TrackEntry, animationTime: number): void; + clearTracks(): void; + clearTrack(trackIndex: number): void; + setCurrent(index: number, current: TrackEntry, interrupt: boolean): void; + setAnimation(trackIndex: number, animationName: string, loop: boolean): TrackEntry; + setAnimationWith(trackIndex: number, animation: Animation, loop: boolean): TrackEntry; + addAnimation(trackIndex: number, animationName: string, loop: boolean, delay: number): TrackEntry; + addAnimationWith(trackIndex: number, animation: Animation, loop: boolean, delay: number): TrackEntry; + setEmptyAnimation(trackIndex: number, mixDuration: number): TrackEntry; + addEmptyAnimation(trackIndex: number, mixDuration: number, delay: number): TrackEntry; + setEmptyAnimations(mixDuration: number): void; + expandToIndex(index: number): TrackEntry; + trackEntry(trackIndex: number, animation: Animation, loop: boolean, last: TrackEntry): TrackEntry; + disposeNext(entry: TrackEntry): void; + _animationsChanged(): void; + computeHold(entry: TrackEntry): void; + computeNotLast(entry: TrackEntry): void; + getCurrent(trackIndex: number): TrackEntry; + addListener(listener: AnimationStateListener): void; + removeListener(listener: AnimationStateListener): void; + clearListeners(): void; + clearListenerNotifications(): void; + } + class TrackEntry { + animation: Animation; + next: TrackEntry; + mixingFrom: TrackEntry; + mixingTo: TrackEntry; + listener: AnimationStateListener; + trackIndex: number; + loop: boolean; + holdPrevious: boolean; + eventThreshold: number; + attachmentThreshold: number; + drawOrderThreshold: number; + animationStart: number; + animationEnd: number; + animationLast: number; + nextAnimationLast: number; + delay: number; + trackTime: number; + trackLast: number; + nextTrackLast: number; + trackEnd: number; + timeScale: number; + alpha: number; + mixTime: number; + mixDuration: number; + interruptAlpha: number; + totalAlpha: number; + mixBlend: MixBlend; + timelineMode: number[]; + timelineHoldMix: TrackEntry[]; + timelinesRotation: number[]; + reset(): void; + getAnimationTime(): number; + setAnimationLast(animationLast: number): void; + isComplete(): boolean; + resetRotationDirections(): void; + } + class EventQueue { + objects: Array; + drainDisabled: boolean; + animState: AnimationState; + constructor(animState: AnimationState); + start(entry: TrackEntry): void; + interrupt(entry: TrackEntry): void; + end(entry: TrackEntry): void; + dispose(entry: TrackEntry): void; + complete(entry: TrackEntry): void; + event(entry: TrackEntry, event: Event): void; + drain(): void; + clear(): void; + } + enum EventType { + start = 0, + interrupt = 1, + end = 2, + dispose = 3, + complete = 4, + event = 5 + } + interface AnimationStateListener { + start(entry: TrackEntry): void; + interrupt(entry: TrackEntry): void; + end(entry: TrackEntry): void; + dispose(entry: TrackEntry): void; + complete(entry: TrackEntry): void; + event(entry: TrackEntry, event: Event): void; + } + abstract class AnimationStateAdapter implements AnimationStateListener { + start(entry: TrackEntry): void; + interrupt(entry: TrackEntry): void; + end(entry: TrackEntry): void; + dispose(entry: TrackEntry): void; + complete(entry: TrackEntry): void; + event(entry: TrackEntry, event: Event): void; + } +} +declare namespace sp.spine { + class AnimationStateData { + skeletonData: SkeletonData; + animationToMixTime: Map; + defaultMix: number; + constructor(skeletonData: SkeletonData); + setMix(fromName: string, toName: string, duration: number): void; + setMixWith(from: Animation, to: Animation, duration: number): void; + getMix(from: Animation, to: Animation): number; + } +} +declare namespace sp.spine { + class AssetManager implements Disposable { + private pathPrefix; + private textureLoader; + private assets; + private errors; + private toLoad; + private loaded; + constructor(textureLoader: (image: HTMLImageElement) => any, pathPrefix?: string); + private static downloadText; + private static downloadBinary; + loadBinary(path: string, success?: (path: string, binary: Uint8Array) => void, error?: (path: string, error: string) => void): void; + loadText(path: string, success?: (path: string, text: string) => void, error?: (path: string, error: string) => void): void; + loadTexture(path: string, success?: (path: string, image: HTMLImageElement) => void, error?: (path: string, error: string) => void): void; + loadTextureData(path: string, data: string, success?: (path: string, image: HTMLImageElement) => void, error?: (path: string, error: string) => void): void; + loadTextureAtlas(path: string, success?: (path: string, atlas: TextureAtlas) => void, error?: (path: string, error: string) => void): void; + get(path: string): any; + remove(path: string): void; + removeAll(): void; + isLoadingComplete(): boolean; + getToLoad(): number; + getLoaded(): number; + dispose(): void; + hasErrors(): boolean; + getErrors(): Map; + } +} +declare namespace sp.spine { + class AtlasAttachmentLoader implements AttachmentLoader { + atlas: TextureAtlas; + constructor(atlas: TextureAtlas); + newRegionAttachment(skin: Skin, name: string, path: string): RegionAttachment; + newMeshAttachment(skin: Skin, name: string, path: string): MeshAttachment; + newBoundingBoxAttachment(skin: Skin, name: string): BoundingBoxAttachment; + newPathAttachment(skin: Skin, name: string): PathAttachment; + newPointAttachment(skin: Skin, name: string): PointAttachment; + newClippingAttachment(skin: Skin, name: string): ClippingAttachment; + } +} +declare namespace sp.spine { + enum BlendMode { + Normal = 0, + Additive = 1, + Multiply = 2, + Screen = 3 + } +} +declare namespace sp.spine { + class Bone implements Updatable { + data: BoneData; + skeleton: Skeleton; + parent: Bone; + children: Bone[]; + x: number; + y: number; + rotation: number; + scaleX: number; + scaleY: number; + shearX: number; + shearY: number; + ax: number; + ay: number; + arotation: number; + ascaleX: number; + ascaleY: number; + ashearX: number; + ashearY: number; + appliedValid: boolean; + a: number; + b: number; + c: number; + d: number; + worldY: number; + worldX: number; + sorted: boolean; + active: boolean; + constructor(data: BoneData, skeleton: Skeleton, parent: Bone); + isActive(): boolean; + update(): void; + updateWorldTransform(): void; + updateWorldTransformWith(x: number, y: number, rotation: number, scaleX: number, scaleY: number, shearX: number, shearY: number): void; + setToSetupPose(): void; + getWorldRotationX(): number; + getWorldRotationY(): number; + getWorldScaleX(): number; + getWorldScaleY(): number; + updateAppliedTransform(): void; + worldToLocal(world: Vector2): Vector2; + localToWorld(local: Vector2): Vector2; + worldToLocalRotation(worldRotation: number): number; + localToWorldRotation(localRotation: number): number; + rotateWorld(degrees: number): void; + } +} +declare namespace sp.spine { + class BoneData { + index: number; + name: string; + parent: BoneData; + length: number; + x: number; + y: number; + rotation: number; + scaleX: number; + scaleY: number; + shearX: number; + shearY: number; + transformMode: TransformMode; + skinRequired: boolean; + color: Color; + constructor(index: number, name: string, parent: BoneData); + } + enum TransformMode { + Normal = 0, + OnlyTranslation = 1, + NoRotationOrReflection = 2, + NoScale = 3, + NoScaleOrReflection = 4 + } +} +declare namespace sp.spine { + abstract class ConstraintData { + name: string; + order: number; + skinRequired: boolean; + constructor(name: string, order: number, skinRequired: boolean); + } +} +declare namespace sp.spine { + class Event { + data: EventData; + intValue: number; + floatValue: number; + stringValue: string; + time: number; + volume: number; + balance: number; + constructor(time: number, data: EventData); + } +} +declare namespace sp.spine { + class EventData { + name: string; + intValue: number; + floatValue: number; + stringValue: string; + audioPath: string; + volume: number; + balance: number; + constructor(name: string); + } +} +declare namespace sp.spine { + class IkConstraint implements Updatable { + data: IkConstraintData; + bones: Array; + target: Bone; + bendDirection: number; + compress: boolean; + stretch: boolean; + mix: number; + softness: number; + active: boolean; + constructor(data: IkConstraintData, skeleton: Skeleton); + isActive(): boolean; + apply(): void; + update(): void; + apply1(bone: Bone, targetX: number, targetY: number, compress: boolean, stretch: boolean, uniform: boolean, alpha: number): void; + apply2(parent: Bone, child: Bone, targetX: number, targetY: number, bendDir: number, stretch: boolean, softness: number, alpha: number): void; + } +} +declare namespace sp.spine { + class IkConstraintData extends ConstraintData { + bones: BoneData[]; + target: BoneData; + bendDirection: number; + compress: boolean; + stretch: boolean; + uniform: boolean; + mix: number; + softness: number; + constructor(name: string); + } +} +declare namespace sp.spine { + class PathConstraint implements Updatable { + static NONE: number; + static BEFORE: number; + static AFTER: number; + static epsilon: number; + data: PathConstraintData; + bones: Array; + target: Slot; + position: number; + spacing: number; + rotateMix: number; + translateMix: number; + spaces: number[]; + positions: number[]; + world: number[]; + curves: number[]; + lengths: number[]; + segments: number[]; + active: boolean; + constructor(data: PathConstraintData, skeleton: Skeleton); + isActive(): boolean; + apply(): void; + update(): void; + computeWorldPositions(path: PathAttachment, spacesCount: number, tangents: boolean, percentPosition: boolean, percentSpacing: boolean): number[]; + addBeforePosition(p: number, temp: Array, i: number, out: Array, o: number): void; + addAfterPosition(p: number, temp: Array, i: number, out: Array, o: number): void; + addCurvePosition(p: number, x1: number, y1: number, cx1: number, cy1: number, cx2: number, cy2: number, x2: number, y2: number, out: Array, o: number, tangents: boolean): void; + } +} +declare namespace sp.spine { + class PathConstraintData extends ConstraintData { + bones: BoneData[]; + target: SlotData; + positionMode: PositionMode; + spacingMode: SpacingMode; + rotateMode: RotateMode; + offsetRotation: number; + position: number; + spacing: number; + rotateMix: number; + translateMix: number; + constructor(name: string); + } + enum PositionMode { + Fixed = 0, + Percent = 1 + } + enum SpacingMode { + Length = 0, + Fixed = 1, + Percent = 2 + } + enum RotateMode { + Tangent = 0, + Chain = 1, + ChainScale = 2 + } +} +declare namespace sp.spine { + class SharedAssetManager implements Disposable { + private pathPrefix; + private clientAssets; + private queuedAssets; + private rawAssets; + private errors; + constructor(pathPrefix?: string); + private queueAsset; + loadText(clientId: string, path: string): void; + loadJson(clientId: string, path: string): void; + loadTexture(clientId: string, textureLoader: (image: HTMLImageElement) => any, path: string): void; + get(clientId: string, path: string): any; + private updateClientAssets; + isLoadingComplete(clientId: string): boolean; + dispose(): void; + hasErrors(): boolean; + getErrors(): Map; + } +} +declare namespace sp.spine { + class Skeleton { + data: SkeletonData; + bones: Array; + slots: Array; + drawOrder: Array; + ikConstraints: Array; + transformConstraints: Array; + pathConstraints: Array; + _updateCache: Updatable[]; + updateCacheReset: Updatable[]; + skin: Skin; + color: Color; + time: number; + scaleX: number; + scaleY: number; + x: number; + y: number; + constructor(data: SkeletonData); + updateCache(): void; + sortIkConstraint(constraint: IkConstraint): void; + sortPathConstraint(constraint: PathConstraint): void; + sortTransformConstraint(constraint: TransformConstraint): void; + sortPathConstraintAttachment(skin: Skin, slotIndex: number, slotBone: Bone): void; + sortPathConstraintAttachmentWith(attachment: Attachment, slotBone: Bone): void; + sortBone(bone: Bone): void; + sortReset(bones: Array): void; + updateWorldTransform(): void; + setToSetupPose(): void; + setBonesToSetupPose(): void; + setSlotsToSetupPose(): void; + getRootBone(): Bone; + findBone(boneName: string): Bone; + findBoneIndex(boneName: string): number; + findSlot(slotName: string): Slot; + findSlotIndex(slotName: string): number; + setSkinByName(skinName: string): void; + setSkin(newSkin: Skin): void; + getAttachmentByName(slotName: string, attachmentName: string): Attachment; + getAttachment(slotIndex: number, attachmentName: string): Attachment; + setAttachment(slotName: string, attachmentName: string): void; + findIkConstraint(constraintName: string): IkConstraint; + findTransformConstraint(constraintName: string): TransformConstraint; + findPathConstraint(constraintName: string): PathConstraint; + getBounds(offset: Vector2, size: Vector2, temp?: Array): void; + update(delta: number): void; + } +} +declare namespace sp.spine { + class SkeletonBinary { + static AttachmentTypeValues: number[]; + static TransformModeValues: TransformMode[]; + static PositionModeValues: PositionMode[]; + static SpacingModeValues: SpacingMode[]; + static RotateModeValues: RotateMode[]; + static BlendModeValues: BlendMode[]; + static BONE_ROTATE: number; + static BONE_TRANSLATE: number; + static BONE_SCALE: number; + static BONE_SHEAR: number; + static SLOT_ATTACHMENT: number; + static SLOT_COLOR: number; + static SLOT_TWO_COLOR: number; + static PATH_POSITION: number; + static PATH_SPACING: number; + static PATH_MIX: number; + static CURVE_LINEAR: number; + static CURVE_STEPPED: number; + static CURVE_BEZIER: number; + scale: number; + attachmentLoader: AttachmentLoader; + private linkedMeshes; + constructor(attachmentLoader: AttachmentLoader); + readSkeletonData(binary: Uint8Array): SkeletonData; + private readSkin; + private readAttachment; + private readVertices; + private readFloatArray; + private readShortArray; + private readAnimation; + private readCurve; + setCurve(timeline: CurveTimeline, frameIndex: number, cx1: number, cy1: number, cx2: number, cy2: number): void; + } +} +declare namespace sp.spine { + class SkeletonBounds { + minX: number; + minY: number; + maxX: number; + maxY: number; + boundingBoxes: BoundingBoxAttachment[]; + polygons: ArrayLike[]; + private polygonPool; + update(skeleton: Skeleton, updateAabb: boolean): void; + aabbCompute(): void; + aabbContainsPoint(x: number, y: number): boolean; + aabbIntersectsSegment(x1: number, y1: number, x2: number, y2: number): boolean; + aabbIntersectsSkeleton(bounds: SkeletonBounds): boolean; + containsPoint(x: number, y: number): BoundingBoxAttachment; + containsPointPolygon(polygon: ArrayLike, x: number, y: number): boolean; + intersectsSegment(x1: number, y1: number, x2: number, y2: number): BoundingBoxAttachment; + intersectsSegmentPolygon(polygon: ArrayLike, x1: number, y1: number, x2: number, y2: number): boolean; + getPolygon(boundingBox: BoundingBoxAttachment): ArrayLike; + getWidth(): number; + getHeight(): number; + } +} +declare namespace sp.spine { + class SkeletonClipping { + private triangulator; + private clippingPolygon; + private clipOutput; + clippedVertices: number[]; + clippedTriangles: number[]; + private scratch; + private clipAttachment; + private clippingPolygons; + clipStart(slot: Slot, clip: ClippingAttachment): number; + clipEndWithSlot(slot: Slot): void; + clipEnd(): void; + isClipping(): boolean; + clipTriangles(vertices: ArrayLike, verticesLength: number, triangles: ArrayLike, trianglesLength: number, uvs: ArrayLike, light: Color, dark: Color, twoColor: boolean): void; + clip(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, clippingArea: Array, output: Array): boolean; + static makeClockwise(polygon: ArrayLike): void; + } +} +declare namespace sp.spine { + class SkeletonData { + name: string; + bones: BoneData[]; + slots: SlotData[]; + skins: Skin[]; + defaultSkin: Skin; + events: EventData[]; + animations: Animation[]; + ikConstraints: IkConstraintData[]; + transformConstraints: TransformConstraintData[]; + pathConstraints: PathConstraintData[]; + x: number; + y: number; + width: number; + height: number; + version: string; + hash: string; + fps: number; + imagesPath: string; + audioPath: string; + findBone(boneName: string): BoneData; + findBoneIndex(boneName: string): number; + findSlot(slotName: string): SlotData; + findSlotIndex(slotName: string): number; + findSkin(skinName: string): Skin; + findEvent(eventDataName: string): EventData; + findAnimation(animationName: string): Animation; + findIkConstraint(constraintName: string): IkConstraintData; + findTransformConstraint(constraintName: string): TransformConstraintData; + findPathConstraint(constraintName: string): PathConstraintData; + findPathConstraintIndex(pathConstraintName: string): number; + } +} +declare namespace sp.spine { + class SkeletonJson { + attachmentLoader: AttachmentLoader; + scale: number; + private linkedMeshes; + constructor(attachmentLoader: AttachmentLoader); + readSkeletonData(json: string | any): SkeletonData; + readAttachment(map: any, skin: Skin, slotIndex: number, name: string, skeletonData: SkeletonData): Attachment; + readVertices(map: any, attachment: VertexAttachment, verticesLength: number): void; + readAnimation(map: any, name: string, skeletonData: SkeletonData): void; + readCurve(map: any, timeline: CurveTimeline, frameIndex: number): void; + getValue(map: any, prop: string, defaultValue: any): any; + static blendModeFromString(str: string): BlendMode; + static positionModeFromString(str: string): PositionMode; + static spacingModeFromString(str: string): SpacingMode; + static rotateModeFromString(str: string): RotateMode; + static transformModeFromString(str: string): TransformMode; + } +} +declare namespace sp.spine { + class SkinEntry { + slotIndex: number; + name: string; + attachment: Attachment; + constructor(slotIndex: number, name: string, attachment: Attachment); + } + class Skin { + name: string; + attachments: Map[]; + bones: BoneData[]; + constraints: ConstraintData[]; + constructor(name: string); + setAttachment(slotIndex: number, name: string, attachment: Attachment): void; + addSkin(skin: Skin): void; + copySkin(skin: Skin): void; + getAttachment(slotIndex: number, name: string): Attachment; + removeAttachment(slotIndex: number, name: string): void; + getAttachments(): Array; + getAttachmentsForSlot(slotIndex: number, attachments: Array): void; + clear(): void; + attachAll(skeleton: Skeleton, oldSkin: Skin): void; + } +} +declare namespace sp.spine { + class Slot { + data: SlotData; + bone: Bone; + color: Color; + darkColor: Color; + private attachment; + private attachmentTime; + deform: number[]; + constructor(data: SlotData, bone: Bone); + getSkeleton(): Skeleton; + getAttachment(): Attachment; + setAttachment(attachment: Attachment): void; + setAttachmentTime(time: number): void; + getAttachmentTime(): number; + setToSetupPose(): void; + } +} +declare namespace sp.spine { + class SlotData { + index: number; + name: string; + boneData: BoneData; + color: Color; + darkColor: Color; + attachmentName: string; + blendMode: BlendMode; + constructor(index: number, name: string, boneData: BoneData); + } +} +declare namespace sp.spine { + abstract class Texture { + protected _image: HTMLImageElement; + constructor(image: HTMLImageElement); + getImage(): HTMLImageElement; + abstract setFilters(minFilter: TextureFilter, magFilter: TextureFilter): void; + abstract setWraps(uWrap: TextureWrap, vWrap: TextureWrap): void; + abstract dispose(): void; + static filterFromString(text: string): TextureFilter; + static wrapFromString(text: string): TextureWrap; + } + enum TextureFilter { + Nearest = 9728, + Linear = 9729, + MipMap = 9987, + MipMapNearestNearest = 9984, + MipMapLinearNearest = 9985, + MipMapNearestLinear = 9986, + MipMapLinearLinear = 9987 + } + enum TextureWrap { + MirroredRepeat = 33648, + ClampToEdge = 33071, + Repeat = 10497 + } + class TextureRegion { + renderObject: any; + u: number; + v: number; + u2: number; + v2: number; + width: number; + height: number; + rotate: boolean; + offsetX: number; + offsetY: number; + originalWidth: number; + originalHeight: number; + } + class FakeTexture extends Texture { + setFilters(minFilter: TextureFilter, magFilter: TextureFilter): void; + setWraps(uWrap: TextureWrap, vWrap: TextureWrap): void; + dispose(): void; + } +} +declare namespace sp.spine { + class TextureAtlas implements Disposable { + pages: TextureAtlasPage[]; + regions: TextureAtlasRegion[]; + constructor(atlasText: string, textureLoader: (path: string) => any); + private load; + findRegion(name: string): TextureAtlasRegion; + dispose(): void; + } + class TextureAtlasPage { + name: string; + minFilter: TextureFilter; + magFilter: TextureFilter; + uWrap: TextureWrap; + vWrap: TextureWrap; + texture: Texture; + width: number; + height: number; + } + class TextureAtlasRegion extends TextureRegion { + page: TextureAtlasPage; + name: string; + x: number; + y: number; + index: number; + rotate: boolean; + degrees: number; + texture: Texture; + } +} +declare namespace sp.spine { + class TransformConstraint implements Updatable { + data: TransformConstraintData; + bones: Array; + target: Bone; + rotateMix: number; + translateMix: number; + scaleMix: number; + shearMix: number; + temp: Vector2; + active: boolean; + constructor(data: TransformConstraintData, skeleton: Skeleton); + isActive(): boolean; + apply(): void; + update(): void; + applyAbsoluteWorld(): void; + applyRelativeWorld(): void; + applyAbsoluteLocal(): void; + applyRelativeLocal(): void; + } +} +declare namespace sp.spine { + class TransformConstraintData extends ConstraintData { + bones: BoneData[]; + target: BoneData; + rotateMix: number; + translateMix: number; + scaleMix: number; + shearMix: number; + offsetRotation: number; + offsetX: number; + offsetY: number; + offsetScaleX: number; + offsetScaleY: number; + offsetShearY: number; + relative: boolean; + local: boolean; + constructor(name: string); + } +} +declare namespace sp.spine { + class Triangulator { + private convexPolygons; + private convexPolygonsIndices; + private indicesArray; + private isConcaveArray; + private triangles; + private polygonPool; + private polygonIndicesPool; + triangulate(verticesArray: ArrayLike): Array; + decompose(verticesArray: Array, triangles: Array): Array>; + private static isConcave; + private static positiveArea; + private static winding; + } +} +declare namespace sp.spine { + interface Updatable { + update(): void; + isActive(): boolean; + } +} +declare namespace sp.spine { + interface Map { + [key: string]: T; + } + class IntSet { + array: number[]; + add(value: number): boolean; + contains(value: number): boolean; + remove(value: number): void; + clear(): void; + } + interface Disposable { + dispose(): void; + } + interface Restorable { + restore(): void; + } + class Color { + r: number; + g: number; + b: number; + a: number; + static WHITE: Color; + static RED: Color; + static GREEN: Color; + static BLUE: Color; + static MAGENTA: Color; + constructor(r?: number, g?: number, b?: number, a?: number); + set(r: number, g: number, b: number, a: number): this; + setFromColor(c: Color): this; + setFromString(hex: string): this; + add(r: number, g: number, b: number, a: number): this; + clamp(): this; + static rgba8888ToColor(color: Color, value: number): void; + static rgb888ToColor(color: Color, value: number): void; + } + class MathUtils { + static PI: number; + static PI2: number; + static radiansToDegrees: number; + static radDeg: number; + static degreesToRadians: number; + static degRad: number; + static clamp(value: number, min: number, max: number): number; + static cosDeg(degrees: number): number; + static sinDeg(degrees: number): number; + static signum(value: number): number; + static toInt(x: number): number; + static cbrt(x: number): number; + static randomTriangular(min: number, max: number): number; + static randomTriangularWith(min: number, max: number, mode: number): number; + } + abstract class Interpolation { + protected abstract applyInternal(a: number): number; + apply(start: number, end: number, a: number): number; + } + class Pow extends Interpolation { + protected power: number; + constructor(power: number); + applyInternal(a: number): number; + } + class PowOut extends Pow { + constructor(power: number); + applyInternal(a: number): number; + } + class Utils { + static SUPPORTS_TYPED_ARRAYS: boolean; + static arrayCopy(source: ArrayLike, sourceStart: number, dest: ArrayLike, destStart: number, numElements: number): void; + static setArraySize(array: Array, size: number, value?: any): Array; + static ensureArrayCapacity(array: Array, size: number, value?: any): Array; + static newArray(size: number, defaultValue: T): Array; + static newFloatArray(size: number): ArrayLike; + static newShortArray(size: number): ArrayLike; + static toFloatArray(array: Array): number[] | Float32Array; + static toSinglePrecision(value: number): number; + static webkit602BugfixHelper(alpha: number, blend: MixBlend): void; + static contains(array: Array, element: T, identity?: boolean): boolean; + } + class DebugUtils { + static logBones(skeleton: Skeleton): void; + } + class Pool { + private items; + private instantiator; + constructor(instantiator: () => T); + obtain(): T; + free(item: T): void; + freeAll(items: ArrayLike): void; + clear(): void; + } + class Vector2 { + x: number; + y: number; + constructor(x?: number, y?: number); + set(x: number, y: number): Vector2; + length(): number; + normalize(): this; + } + class TimeKeeper { + maxDelta: number; + framesPerSecond: number; + delta: number; + totalTime: number; + private lastTime; + private frameCount; + private frameTime; + update(): void; + } + interface ArrayLike { + length: number; + [n: number]: T; + } + class WindowedMean { + values: Array; + addedValues: number; + lastValue: number; + mean: number; + dirty: boolean; + constructor(windowSize?: number); + hasEnoughData(): boolean; + addValue(value: number): void; + getMean(): number; + } +} +declare namespace sp.spine { + interface VertexEffect { + begin(skeleton: Skeleton): void; + transform(position: Vector2, uv: Vector2, light: Color, dark: Color): void; + end(): void; + } +} +interface Math { + fround(n: number): number; +} +declare namespace sp.spine { + abstract class Attachment { + name: string; + constructor(name: string); + abstract copy(): Attachment; + } + abstract class VertexAttachment extends Attachment { + private static nextID; + id: number; + bones: Array; + vertices: ArrayLike; + worldVerticesLength: number; + deformAttachment: VertexAttachment; + constructor(name: string); + computeWorldVertices(slot: Slot, start: number, count: number, worldVertices: ArrayLike, offset: number, stride: number): void; + copyTo(attachment: VertexAttachment): void; + } +} +declare namespace sp.spine { + interface AttachmentLoader { + newRegionAttachment(skin: Skin, name: string, path: string): RegionAttachment; + newMeshAttachment(skin: Skin, name: string, path: string): MeshAttachment; + newBoundingBoxAttachment(skin: Skin, name: string): BoundingBoxAttachment; + newPathAttachment(skin: Skin, name: string): PathAttachment; + newPointAttachment(skin: Skin, name: string): PointAttachment; + newClippingAttachment(skin: Skin, name: string): ClippingAttachment; + } +} +declare namespace sp.spine { + enum AttachmentType { + Region = 0, + BoundingBox = 1, + Mesh = 2, + LinkedMesh = 3, + Path = 4, + Point = 5, + Clipping = 6 + } +} +declare namespace sp.spine { + class BoundingBoxAttachment extends VertexAttachment { + color: Color; + constructor(name: string); + copy(): Attachment; + } +} +declare namespace sp.spine { + class ClippingAttachment extends VertexAttachment { + endSlot: SlotData; + color: Color; + constructor(name: string); + copy(): Attachment; + } +} +declare namespace sp.spine { + class MeshAttachment extends VertexAttachment { + region: TextureRegion; + path: string; + regionUVs: ArrayLike; + uvs: ArrayLike; + triangles: Array; + color: Color; + width: number; + height: number; + hullLength: number; + edges: Array; + private parentMesh; + tempColor: Color; + constructor(name: string); + updateUVs(): void; + getParentMesh(): MeshAttachment; + setParentMesh(parentMesh: MeshAttachment): void; + copy(): Attachment; + newLinkedMesh(): MeshAttachment; + } +} +declare namespace sp.spine { + class PathAttachment extends VertexAttachment { + lengths: Array; + closed: boolean; + constantSpeed: boolean; + color: Color; + constructor(name: string); + copy(): Attachment; + } +} +declare namespace sp.spine { + class PointAttachment extends VertexAttachment { + x: number; + y: number; + rotation: number; + color: Color; + constructor(name: string); + computeWorldPosition(bone: Bone, point: Vector2): Vector2; + computeWorldRotation(bone: Bone): number; + copy(): Attachment; + } +} +declare namespace sp.spine { + class RegionAttachment extends Attachment { + static OX1: number; + static OY1: number; + static OX2: number; + static OY2: number; + static OX3: number; + static OY3: number; + static OX4: number; + static OY4: number; + static X1: number; + static Y1: number; + static C1R: number; + static C1G: number; + static C1B: number; + static C1A: number; + static U1: number; + static V1: number; + static X2: number; + static Y2: number; + static C2R: number; + static C2G: number; + static C2B: number; + static C2A: number; + static U2: number; + static V2: number; + static X3: number; + static Y3: number; + static C3R: number; + static C3G: number; + static C3B: number; + static C3A: number; + static U3: number; + static V3: number; + static X4: number; + static Y4: number; + static C4R: number; + static C4G: number; + static C4B: number; + static C4A: number; + static U4: number; + static V4: number; + x: number; + y: number; + scaleX: number; + scaleY: number; + rotation: number; + width: number; + height: number; + color: Color; + path: string; + rendererObject: any; + region: TextureRegion; + offset: ArrayLike; + uvs: ArrayLike; + tempColor: Color; + constructor(name: string); + updateOffset(): void; + setRegion(region: TextureRegion): void; + computeWorldVertices(bone: Bone, worldVertices: ArrayLike, offset: number, stride: number): void; + copy(): Attachment; + } +} +declare namespace sp.spine { + class JitterEffect implements VertexEffect { + jitterX: number; + jitterY: number; + constructor(jitterX: number, jitterY: number); + begin(skeleton: Skeleton): void; + transform(position: Vector2, uv: Vector2, light: Color, dark: Color): void; + end(): void; + } +} +declare namespace sp.spine { + class SwirlEffect implements VertexEffect { + static interpolation: PowOut; + centerX: number; + centerY: number; + radius: number; + angle: number; + private worldX; + private worldY; + constructor(radius: number); + begin(skeleton: Skeleton): void; + transform(position: Vector2, uv: Vector2, light: Color, dark: Color): void; + end(): void; + } +} + +/** + * API for jsb module + * Author: haroel + * Homepage: https://github.com/haroel/creatorexDTS + */ +declare namespace jsb{ + export module reflection{ + /** + * https://docs.cocos.com/creator/manual/zh/advanced-topics/java-reflection.html + * call OBJC/Java static methods + * + * @param className + * @param methodName + * @param methodSignature + * @param parameters + */ + export function callStaticMethod (className: string, methodName: string, methodSignature: string, ...parameters:any): any; + } + /** + * 下载任务对象 + */ + export type DownloaderTask = { requestURL: string, storagePath: string, identifier: string }; + + /** + * Http file downloader for jsb! + */ + export class Downloader{ + /** + * create a download task + * @param requestURL + * @param storagePath + * @param identifier + */ + createDownloadFileTask (requestURL:string, storagePath:string, identifier?:string): DownloaderTask; + + setOnFileTaskSuccess (onSucceed: (task: DownloaderTask) => void): void; + + setOnTaskProgress (onProgress: (task: DownloaderTask, bytesReceived: number, totalBytesReceived: number, totalBytesExpected: number) => void): void; + + setOnTaskError (onError: (task: DownloaderTask, errorCode: number, errorCodeInternal: number, errorStr: string) => void): void; + + } + + export interface ManifestAsset { + md5: string; + path: string; + compressed: boolean; + size: number; + downloadState: number; + } + + export class Manifest { + constructor (manifestUrl: string); + constructor (content: string, manifestRoot: string); + parseFile (manifestUrl: string): void; + parseJSONString (content: string, manifestRoot: string): void; + + getManifestRoot (): string; + getManifestFileUrl (): string; + getVersionFileUrl (): string; + getSearchPaths (): [string]; + getVersion (): string; + getPackageUrl (): boolean; + + setUpdating (isUpdating: boolean): void; + isUpdating (): boolean; + isVersionLoaded (): boolean; + isLoaded (): boolean; + } + + export class EventAssetsManager { + // EventCode + static ERROR_NO_LOCAL_MANIFEST: number; + static ERROR_DOWNLOAD_MANIFEST: number; + static ERROR_PARSE_MANIFEST: number; + static NEW_VERSION_FOUND: number; + static ALREADY_UP_TO_DATE: number; + static UPDATE_PROGRESSION: number; + static ASSET_UPDATED: number; + static ERROR_UPDATING: number; + static UPDATE_FINISHED: number; + static UPDATE_FAILED: number; + static ERROR_DECOMPRESS: number; + + constructor (eventName: string, manager: AssetsManager, eventCode: number, + assetId?: string, message?: string, curleCode?: number, curlmCode?: number); + getAssetsManagerEx (): AssetsManager; + isResuming (): boolean; + + getDownloadedFiles (): number; + getDownloadedBytes (): number; + getTotalFiles (): number; + getTotalBytes (): number; + getPercent (): number; + getPercentByFile (): number; + + getEventCode (): number; + getMessage (): string; + getAssetId (): string; + getCURLECode (): number; + getCURLMCode (): number; + } + + export module AssetsManager { + export enum State { + UNINITED, + UNCHECKED, + PREDOWNLOAD_VERSION, + DOWNLOADING_VERSION, + VERSION_LOADED, + PREDOWNLOAD_MANIFEST, + DOWNLOADING_MANIFEST, + MANIFEST_LOADED, + NEED_UPDATE, + READY_TO_UPDATE, + UPDATING, + UNZIPPING, + UP_TO_DATE, + FAIL_TO_UPDATE, + } + } + + export class AssetsManager { + constructor (manifestUrl: string, storagePath: string, versionCompareHandle?: (versionA: string, versionB: string) => number); + static create (manifestUrl: string, storagePath: string): AssetsManager; + + getState (): AssetsManager.State; + getStoragePath (): string + getMaxConcurrentTask (): number; + // setMaxConcurrentTask (max: number): void; // actually not supported + + checkUpdate (): void; + prepareUpdate (): void; + update (): void; + isResuming (): boolean; + + getDownloadedFiles (): number; + getDownloadedBytes (): number; + getTotalFiles (): number; + getTotalBytes (): number; + downloadFailedAssets (): void; + + getLocalManifest (): Manifest; + loadLocalManifest (manifestUrl: string): boolean; + loadLocalManifest (localManifest: Manifest, storagePath: string): boolean; + getRemoteManifest (): Manifest; + loadRemoteManifest (remoteManifest: Manifest): boolean; + + /** + * Setup your own version compare handler, versionA and B is versions in string. + * if the return value greater than 0, versionA is greater than B, + * if the return value equals 0, versionA equals to B, + * if the return value smaller than 0, versionA is smaller than B. + */ + setVersionCompareHandle (versionCompareHandle?: (versionA: string, versionB: string) => number): void; + /** + * Setup the verification callback, Return true if the verification passed, otherwise return false + */ + setVerifyCallback (verifyCallback: (path: string, asset: ManifestAsset) => boolean): void; + setEventCallback (eventCallback: (event: EventAssetsManager) => void): void; + } + + /** + * FileUtils Helper class to handle file operations. + */ + export module fileUtils{ + /** + * Checks whether the path is an absolute path. + * + * @note On Android, if the parameter passed in is relative to "@assets/", this method will treat it as an absolute path. + * Also on Blackberry, path starts with "app/native/Resources/" is treated as an absolute path. + * + * @param path The path that needs to be checked. + * @return True if it's an absolute path, false if not. + */ + export function isAbsolutePath (path:string):boolean; + /** Returns the fullpath for a given filename. + + First it will try to get a new filename from the "filenameLookup" dictionary. + If a new filename can't be found on the dictionary, it will use the original filename. + Then it will try to obtain the full path of the filename using the FileUtils search rules: resolutions, and search paths. + The file search is based on the array element order of search paths and resolution directories. + + For instance: + + We set two elements("/mnt/sdcard/", "internal_dir/") to search paths vector by setSearchPaths, + and set three elements("resources-ipadhd/", "resources-ipad/", "resources-iphonehd") + to resolutions vector by setSearchResolutionsOrder. The "internal_dir" is relative to "Resources/". + + If we have a file named 'sprite.png', the mapping in fileLookup dictionary contains `key: sprite.png -> value: sprite.pvr.gz`. + Firstly, it will replace 'sprite.png' with 'sprite.pvr.gz', then searching the file sprite.pvr.gz as follows: + + /mnt/sdcard/resources-ipadhd/sprite.pvr.gz (if not found, search next) + /mnt/sdcard/resources-ipad/sprite.pvr.gz (if not found, search next) + /mnt/sdcard/resources-iphonehd/sprite.pvr.gz (if not found, search next) + /mnt/sdcard/sprite.pvr.gz (if not found, search next) + internal_dir/resources-ipadhd/sprite.pvr.gz (if not found, search next) + internal_dir/resources-ipad/sprite.pvr.gz (if not found, search next) + internal_dir/resources-iphonehd/sprite.pvr.gz (if not found, search next) + internal_dir/sprite.pvr.gz (if not found, return "sprite.png") + + If the filename contains relative path like "gamescene/uilayer/sprite.png", + and the mapping in fileLookup dictionary contains `key: gamescene/uilayer/sprite.png -> value: gamescene/uilayer/sprite.pvr.gz`. + The file search order will be: + + /mnt/sdcard/gamescene/uilayer/resources-ipadhd/sprite.pvr.gz (if not found, search next) + /mnt/sdcard/gamescene/uilayer/resources-ipad/sprite.pvr.gz (if not found, search next) + /mnt/sdcard/gamescene/uilayer/resources-iphonehd/sprite.pvr.gz (if not found, search next) + /mnt/sdcard/gamescene/uilayer/sprite.pvr.gz (if not found, search next) + internal_dir/gamescene/uilayer/resources-ipadhd/sprite.pvr.gz (if not found, search next) + internal_dir/gamescene/uilayer/resources-ipad/sprite.pvr.gz (if not found, search next) + internal_dir/gamescene/uilayer/resources-iphonehd/sprite.pvr.gz (if not found, search next) + internal_dir/gamescene/uilayer/sprite.pvr.gz (if not found, return "gamescene/uilayer/sprite.png") + + If the new file can't be found on the file system, it will return the parameter filename directly. + + This method was added to simplify multiplatform support. Whether you are using cocos2d-js or any cross-compilation toolchain like StellaSDK or Apportable, + you might need to load different resources for a given file in the different platforms. + + @since v2.1 + */ + export function fullPathForFilename (filename:string):string; + /** + * Gets string from a file. + */ + export function getStringFromFile (filename:string):string; + /** + * Removes a file. + * + * @param filepath The full path of the file, it must be an absolute path. + * @return True if the file have been removed successfully, false if not. + */ + export function removeFile (filepath:string):boolean; + /** + * Checks whether the path is a directory. + * + * @param dirPath The path of the directory, it could be a relative or an absolute path. + * @return True if the directory exists, false if not. + */ + export function isDirectoryExist (dirPath:string):boolean; + /** + * Normalize: remove . and .. + * @param filepath + */ + export function normalizePath (filepath:string):string; + /** + * Get default resource root path. + */ + export function getDefaultResourceRootPath ():string; + /** + * Loads the filenameLookup dictionary from the contents of a filename. + * + * @note The plist file name should follow the format below: + * + * @code + * + * + * + * + * filenames + * + * sounds/click.wav + * sounds/click.caf + * sounds/endgame.wav + * sounds/endgame.caf + * sounds/gem-0.wav + * sounds/gem-0.caf + * + * metadata + * + * version + * 1 + * + * + * + * @endcode + * @param filename The plist file name. + * + @since v2.1 + * @js loadFilenameLookup + * @lua loadFilenameLookup + */ + export function loadFilenameLookup (filepath:string):void; + /** Checks whether to pop up a message box when failed to load an image. + * @return True if pop up a message box when failed to load an image, false if not. + */ + export function isPopupNotify ():boolean; + /** + * Sets whether to pop-up a message box when failed to load an image. + */ + export function setPopupNotify (notify:boolean):void; + + // Converts the contents of a file to a ValueVector. + // This method is used internally. + export function getValueVectorFromFile (filepath:string):Array; + /** + * Gets the array of search paths. + * + * @return The array of search paths which may contain the prefix of default resource root path. + * @note In best practise, getter function should return the value of setter function passes in. + * But since we should not break the compatibility, we keep using the old logic. + * Therefore, If you want to get the original search paths, please call 'getOriginalSearchPaths()' instead. + * @see fullPathForFilename(const char*). + * @lua NA + */ + export function getSearchPaths ():Array; + /** + * + * @param filepath + */ + export function getFileDir (filepath:string):string; + /** + * write a ValueMap into a plist file + * + *@param dict the ValueMap want to save (key,value) + *@param fullPath The full path to the file you want to save a string + *@return bool + */ + export function writeToFile ( valueMap:any ):boolean; + /** + * Gets the original search path array set by 'setSearchPaths' or 'addSearchPath'. + * @return The array of the original search paths + */ + export function getOriginalSearchPaths ():Array; + /** + * List all files in a directory. + * + * @param dirPath The path of the directory, it could be a relative or an absolute path. + * @return File paths in a string vector + */ + export function listFiles (filepath:string):Array; + /** + * Converts the contents of a file to a ValueMap. + * @param filename The filename of the file to gets content. + * @return ValueMap of the file contents. + * @note This method is used internally. + */ + export function getValueMapFromFile (filepath:string):any; + /** + * Retrieve the file size. + * + * @note If a relative path was passed in, it will be inserted a default root path at the beginning. + * @param filepath The path of the file, it could be a relative or absolute path. + * @return The file size. + */ + export function getFileSize (filepath:string):number; + + /** Converts the contents of a file to a ValueMap. + * This method is used internally. + */ + export function getValueMapFromData (filedata:string,filesize:number):any; + /** + * Removes a directory. + * + * @param dirPath The full path of the directory, it must be an absolute path. + * @return True if the directory have been removed successfully, false if not. + */ + export function removeDirectory (dirPath:string):boolean; + /** + * Sets the array of search paths. + * + * You can use this array to modify the search path of the resources. + * If you want to use "themes" or search resources in the "cache", you can do it easily by adding new entries in this array. + * + * @note This method could access relative path and absolute path. + * If the relative path was passed to the vector, FileUtils will add the default resource directory before the relative path. + * For instance: + * On Android, the default resource root path is "@assets/". + * If "/mnt/sdcard/" and "resources-large" were set to the search paths vector, + * "resources-large" will be converted to "@assets/resources-large" since it was a relative path. + * + * @param searchPaths The array contains search paths. + * @see fullPathForFilename(const char*) + * @since v2.1 + * In js:var setSearchPaths(var jsval); + * @lua NA + */ + export function setSearchPaths ( searchPath:Array):void; + /** + * write a string into a file + * + * @param dataStr the string want to save + * @param fullPath The full path to the file you want to save a string + * @return bool True if write success + */ + export function writeStringToFile (dataStr:string,fullPath:string):boolean; + /** + * Sets the array that contains the search order of the resources. + * + * @param searchResolutionsOrder The source array that contains the search order of the resources. + * @see getSearchResolutionsOrder(), fullPathForFilename(const char*). + * @since v2.1 + * In js:var setSearchResolutionsOrder(var jsval) + * @lua NA + */ + export function setSearchResolutionsOrder (searchResolutionsOrder:Array):void; + /** + * Append search order of the resources. + * + * @see setSearchResolutionsOrder(), fullPathForFilename(). + * @since v2.1 + */ + export function addSearchResolutionsOrder (order:string,front:boolean):void; + /** + * Add search path. + * + * @since v2.1 + */ + export function addSearchPath (path:string,front:boolean):void; + /** + * write ValueVector into a plist file + * + *@param vecData the ValueVector want to save + *@param fullPath The full path to the file you want to save a string + *@return bool + */ + export function writeValueVectorToFile (vecData:Array,fullPath:string):boolean; + /** + * Checks whether a file exists. + * + * @note If a relative path was passed in, it will be inserted a default root path at the beginning. + * @param filename The path of the file, it could be a relative or absolute path. + * @return True if the file exists, false if not. + */ + export function isFileExist (filename:string):boolean; + /**©∫ + * Purges full path caches. + */ + export function purgeCachedEntries ():void; + /** + * Gets full path from a file name and the path of the relative file. + * @param filename The file name. + * @param relativeFile The path of the relative file. + * @return The full path. + * e.g. filename: hello.png, pszRelativeFile: /User/path1/path2/hello.plist + * Return: /User/path1/path2/hello.pvr (If there a a key(hello.png)-value(hello.pvr) in FilenameLookup dictionary. ) + * + */ + export function fullPathFromRelativeFile (filename:string,relativeFile:string):string; + /** + * Windows fopen can't support UTF-8 filename + * Need convert all parameters fopen and other 3rd-party libs + * + * @param filenameUtf8 std::string name file for conversion from utf-8 + * @return std::string ansi filename in current locale + */ + export function getSuitableFOpen (filenameUtf8:string):string; + /** + * write ValueMap into a plist file + * + *@param dict the ValueMap want to save + *@param fullPath The full path to the file you want to save a string + *@return bool + */ + export function writeValueMapToFile (dict:any,fullPath:string):string; + /** + * Gets filename extension is a suffix (separated from the base filename by a dot) in lower case. + * Examples of filename extensions are .png, .jpeg, .exe, .dmg and .txt. + * @param filePath The path of the file, it could be a relative or absolute path. + * @return suffix for filename in lower case or empty if a dot not found. + */ + export function getFileExtension (filePath:string):string; + /** + * Sets writable path. + */ + export function setWritablePath (writablePath:string):void; + /** + * Set default resource root path. + */ + export function setDefaultResourceRootPath (filepath:string):void; + + /** + * Gets the array that contains the search order of the resources. + * + * @see setSearchResolutionsOrder(const std::vector&), fullPathForFilename(const char*). + * @since v2.1 + * @lua NA + */ + export function getSearchResolutionsOrder ():Array; + /** + * Creates a directory. + * + * @param dirPath The path of the directory, it must be an absolute path. + * @return True if the directory have been created successfully, false if not. + */ + export function createDirectory (dirPath:string):string; + /** + * List all files recursively in a directory. + * + * @param dirPath The path of the directory, it could be a relative or an absolute path. + * @return File paths in a string vector + */ + export function listFilesRecursively (dirPath:string, files:Array):void; + /** + * Gets the writable path. + * @return The path that can be write/read a file in + */ + export function getWritablePath ():string; + } +} + +/** Running in the editor. */ +declare const CC_EDITOR: boolean; +/** Preview in browser or simulator. */ +declare const CC_PREVIEW: boolean; +/** Running in the editor or preview. */ +declare const CC_DEV: boolean; +/** Running in the editor or preview, or build in debug mode. */ +declare const CC_DEBUG: boolean; +/** Running in published project. */ +declare const CC_BUILD: boolean; +/** Running in native platforms (mobile app, desktop app, or simulator). */ +declare const CC_JSB: boolean; +/** Running in runtime environments. */ +declare const CC_RUNTIME: boolean; +/** Running in the engine's unit test. */ +declare const CC_TEST: boolean; +/** Running in the WeChat Mini Game. */ +declare const CC_WECHATGAME: boolean; diff --git a/CameraDemo/jsconfig.json b/CameraDemo/jsconfig.json new file mode 100644 index 0000000..80c2563 --- /dev/null +++ b/CameraDemo/jsconfig.json @@ -0,0 +1,15 @@ +{ + "compilerOptions": { + "target": "es6", + "module": "commonjs", + "experimentalDecorators": true + }, + "exclude": [ + "node_modules", + ".vscode", + "library", + "local", + "settings", + "temp" + ] +} \ No newline at end of file diff --git a/CameraDemo/project.json b/CameraDemo/project.json new file mode 100644 index 0000000..be37882 --- /dev/null +++ b/CameraDemo/project.json @@ -0,0 +1,8 @@ +{ + "engine": "cocos-creator-js", + "packages": "packages", + "name": "CameraDemo", + "id": "3f30aaba-94b8-402b-af70-7bfce0af6cd5", + "version": "2.4.0", + "isNew": false +} \ No newline at end of file diff --git a/CameraDemo/settings/project.json b/CameraDemo/settings/project.json new file mode 100644 index 0000000..832ce6c --- /dev/null +++ b/CameraDemo/settings/project.json @@ -0,0 +1,46 @@ +{ + "group-list": [ + "default", + "root", + "ui_1" + ], + "collision-matrix": [ + [ + true + ], + [ + false, + false + ], + [ + false, + false, + false + ] + ], + "excluded-modules": [ + "3D Physics/Builtin" + ], + "preview-port": 7456, + "design-resolution-width": 960, + "design-resolution-height": 640, + "fit-width": false, + "fit-height": true, + "use-project-simulator-setting": false, + "simulator-orientation": false, + "use-customize-simulator": true, + "simulator-resolution": { + "height": 640, + "width": 960 + }, + "facebook": { + "appID": "", + "audience": { + "enable": false + }, + "enable": false, + "live": { + "enable": false + } + } +} diff --git a/CameraDemo/settings/services.json b/CameraDemo/settings/services.json new file mode 100644 index 0000000..599b09e --- /dev/null +++ b/CameraDemo/settings/services.json @@ -0,0 +1,6 @@ +{ + "game": { + "name": "未知游戏", + "appid": "UNKNOW" + } +} \ No newline at end of file diff --git a/CameraDemo/tsconfig.json b/CameraDemo/tsconfig.json new file mode 100644 index 0000000..93c0b22 --- /dev/null +++ b/CameraDemo/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ "es2015", "es2017", "dom" ], + "target": "es5", + "experimentalDecorators": true, + "skipLibCheck": true, + "outDir": "temp/vscode-dist", + "forceConsistentCasingInFileNames": true + }, + "exclude": [ + "node_modules", + "library", + "local", + "temp", + "build", + "settings" + ] +} \ No newline at end of file diff --git a/CameraFollowDemo/.gitignore b/CameraFollowDemo/.gitignore new file mode 100644 index 0000000..a231b3f --- /dev/null +++ b/CameraFollowDemo/.gitignore @@ -0,0 +1,24 @@ + +#/////////////////////////// +# Cocos Creator 3D Project +#/////////////////////////// +library/ +temp/ +local/ +build/ +profiles/ +native +#////////////////////////// +# NPM +#////////////////////////// +node_modules/ + +#////////////////////////// +# VSCode +#////////////////////////// +.vscode/ + +#////////////////////////// +# WebStorm +#////////////////////////// +.idea/ \ No newline at end of file diff --git a/CameraFollowDemo/README.md b/CameraFollowDemo/README.md new file mode 100644 index 0000000..50b9de8 --- /dev/null +++ b/CameraFollowDemo/README.md @@ -0,0 +1,35 @@ +# 相机跟随 + +## 计算目标节点的前向量(世界坐标下) +~~~ +节点当前四元数=获取世界坐标系下的旋转() +向向量=向量四元数乘法(节点默认前方向,节点当前四元数) +向向量=向向量.将当前向量归一化() +~~~ + +## 计算摄像机的向前四元数 +~~~ +摄像机前向量=摄像机位置-目标节点位置 +摄像机节点前向量=摄像机前向量*-1 +角度四元数=根据视口的前方向和上方向计算四元数() +摄像机节点角度四元数=角度四元数 +~~~ + +## 计算跟随距离 +~~~ +CameraPos=TargetPos-TargetForward*hDist+targetUp*vDist; +摄像机位置=目标节点位置-目标节点单位前向量*水平距离+目标节点单位上向量*垂直距离 +~~~ + +## 计算弹簧 +~~~ +理想位置=计算理想位置函数() +相对差值=实际位置-理想位置 +加速度=-1*弹性系数*相对差值-阻尼系数*当前速度 +速度=速度+加速度*间隔时间 +实际位置=实际位置+速度*间隔时间 +~~~ + +## 参考 +* https://mp.weixin.qq.com/s?__biz=MzI1Nzk1MzExNw==&mid=2247485617&idx=1&sn=839880f5200bbf0376f1885c997a791d&chksm=ea0ed483dd795d950cbfe2150fb02a5deece940731ce1e240936c2b69cfc44ecdd53d546bb09&cur_album_id=1342270984425996289&scene=190#rd +* github https://gitee.com/lamyoung/cocos-creator-3d-examples/blob/master/springCamera/assets/src/SpringCamera.ts diff --git a/CameraFollowDemo/assets/folder.meta b/CameraFollowDemo/assets/folder.meta new file mode 100644 index 0000000..1f468c1 --- /dev/null +++ b/CameraFollowDemo/assets/folder.meta @@ -0,0 +1,12 @@ +{ + "ver": "1.1.0", + "importer": "directory", + "imported": true, + "uuid": "203d9f6d-0bf0-4206-90e1-08a3b092c7fc", + "files": [], + "subMetas": {}, + "userData": { + "compressionType": {}, + "isRemoteBundle": {} + } +} diff --git a/CameraFollowDemo/assets/material.meta b/CameraFollowDemo/assets/material.meta new file mode 100644 index 0000000..e1d7660 --- /dev/null +++ b/CameraFollowDemo/assets/material.meta @@ -0,0 +1,12 @@ +{ + "ver": "1.1.0", + "importer": "directory", + "imported": true, + "uuid": "bcb14f34-8131-435f-a8f5-29612c45af59", + "files": [], + "subMetas": {}, + "userData": { + "compressionType": {}, + "isRemoteBundle": {} + } +} diff --git a/CameraFollowDemo/assets/material/color001.mtl b/CameraFollowDemo/assets/material/color001.mtl new file mode 100644 index 0000000..1ae5273 --- /dev/null +++ b/CameraFollowDemo/assets/material/color001.mtl @@ -0,0 +1,42 @@ +{ + "__type__": "cc.Material", + "_name": "", + "_objFlags": 0, + "_native": "", + "_effectAsset": { + "__uuid__": "1baf0fc9-befa-459c-8bdd-af1a450a0319", + "__expectedType__": "cc.EffectAsset" + }, + "_techIdx": 0, + "_defines": [ + {}, + {}, + {} + ], + "_states": [ + { + "rasterizerState": {}, + "depthStencilState": {}, + "blendState": { + "targets": [ + {} + ] + } + }, + {}, + {} + ], + "_props": [ + { + "mainColor": { + "__type__": "cc.Color", + "r": 100, + "g": 150, + "b": 255, + "a": 255 + } + }, + {}, + {} + ] +} \ No newline at end of file diff --git a/CameraFollowDemo/assets/material/color001.mtl.meta b/CameraFollowDemo/assets/material/color001.mtl.meta new file mode 100644 index 0000000..c44917a --- /dev/null +++ b/CameraFollowDemo/assets/material/color001.mtl.meta @@ -0,0 +1,11 @@ +{ + "ver": "1.0.11", + "importer": "material", + "imported": true, + "uuid": "a0ddabd7-f1da-421f-ac27-bfd6a96339ef", + "files": [ + ".json" + ], + "subMetas": {}, + "userData": {} +} diff --git a/CameraFollowDemo/assets/material/hdcSky.mtl b/CameraFollowDemo/assets/material/hdcSky.mtl new file mode 100644 index 0000000..8ea9e0e --- /dev/null +++ b/CameraFollowDemo/assets/material/hdcSky.mtl @@ -0,0 +1,34 @@ +{ + "__type__": "cc.Material", + "_name": "", + "_objFlags": 0, + "_native": "", + "_effectAsset": { + "__uuid__": "a3cd009f-0ab0-420d-9278-b9fdab939bbc" + }, + "_techIdx": 0, + "_defines": [ + { + "USE_TEXTURE": true + } + ], + "_states": [ + { + "blendState": { + "targets": [ + {} + ] + }, + "depthStencilState": {}, + "rasterizerState": {} + } + ], + "_props": [ + { + "mainTexture": { + "__uuid__": "dc4a96c7-321a-48af-81e5-1127ad3ae432@6c48a" + }, + "alphaThreshold": 0 + } + ] +} \ No newline at end of file diff --git a/CameraFollowDemo/assets/material/hdcSky.mtl.meta b/CameraFollowDemo/assets/material/hdcSky.mtl.meta new file mode 100644 index 0000000..573057d --- /dev/null +++ b/CameraFollowDemo/assets/material/hdcSky.mtl.meta @@ -0,0 +1,11 @@ +{ + "ver": "1.0.11", + "importer": "material", + "imported": true, + "uuid": "482a5162-dad9-446c-b548-8486c7598ee1", + "files": [ + ".json" + ], + "subMetas": {}, + "userData": {} +} diff --git a/CameraFollowDemo/assets/material/plane.mtl b/CameraFollowDemo/assets/material/plane.mtl new file mode 100644 index 0000000..ab9171c --- /dev/null +++ b/CameraFollowDemo/assets/material/plane.mtl @@ -0,0 +1,34 @@ +{ + "__type__": "cc.Material", + "_name": "", + "_objFlags": 0, + "_native": "", + "_effectAsset": { + "__uuid__": "a3cd009f-0ab0-420d-9278-b9fdab939bbc" + }, + "_techIdx": 0, + "_defines": [ + { + "USE_TEXTURE": true + } + ], + "_states": [ + { + "blendState": { + "targets": [ + {} + ] + }, + "depthStencilState": {}, + "rasterizerState": {} + } + ], + "_props": [ + { + "mainTexture": { + "__uuid__": "4f4c4a34-2d08-4a4d-9169-834d7ce82cee@6c48a" + }, + "alphaThreshold": 0 + } + ] +} \ No newline at end of file diff --git a/CameraFollowDemo/assets/material/plane.mtl.meta b/CameraFollowDemo/assets/material/plane.mtl.meta new file mode 100644 index 0000000..ef37318 --- /dev/null +++ b/CameraFollowDemo/assets/material/plane.mtl.meta @@ -0,0 +1,11 @@ +{ + "ver": "1.0.11", + "importer": "material", + "imported": true, + "uuid": "23e988d0-7168-4fe2-9d46-f29c114e9e33", + "files": [ + ".json" + ], + "subMetas": {}, + "userData": {} +} diff --git a/CameraFollowDemo/assets/material/seafloor.mtl b/CameraFollowDemo/assets/material/seafloor.mtl new file mode 100644 index 0000000..2b04037 --- /dev/null +++ b/CameraFollowDemo/assets/material/seafloor.mtl @@ -0,0 +1,42 @@ +{ + "__type__": "cc.Material", + "_name": "seafloor", + "_objFlags": 0, + "_native": "", + "_effectAsset": { + "__uuid__": "1baf0fc9-befa-459c-8bdd-af1a450a0319" + }, + "_techIdx": 0, + "_defines": [ + { + "USE_ALBEDO_MAP": true + } + ], + "_states": [ + { + "rasterizerState": {}, + "blendState": { + "targets": [ + {} + ] + }, + "depthStencilState": {} + } + ], + "_props": [ + { + "mainTexture": { + "__uuid__": "0ab3142a-6968-4073-95af-026bc3b23623@2df3a" + }, + "albedoScale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "metallic": 0.400000005960464, + "roughness": 0.70710676908493, + "alphaThreshold": 0 + } + ] +} \ No newline at end of file diff --git a/CameraFollowDemo/assets/material/seafloor.mtl.meta b/CameraFollowDemo/assets/material/seafloor.mtl.meta new file mode 100644 index 0000000..0462f2a --- /dev/null +++ b/CameraFollowDemo/assets/material/seafloor.mtl.meta @@ -0,0 +1,11 @@ +{ + "ver": "1.0.11", + "importer": "material", + "imported": true, + "uuid": "70d33758-1c1e-424d-b0ab-eac7410559bf", + "files": [ + ".json" + ], + "subMetas": {}, + "userData": {} +} diff --git a/CameraFollowDemo/assets/material/shield.mtl b/CameraFollowDemo/assets/material/shield.mtl new file mode 100644 index 0000000..21f1a57 --- /dev/null +++ b/CameraFollowDemo/assets/material/shield.mtl @@ -0,0 +1,62 @@ +{ + "__type__": "cc.Material", + "_name": "", + "_objFlags": 0, + "_native": "", + "_effectAsset": { + "__uuid__": "1baf0fc9-befa-459c-8bdd-af1a450a0319" + }, + "_techIdx": 0, + "_defines": [ + { + "USE_ALBEDO_MAP": true + }, + { + "USE_ALBEDO_MAP": true + }, + { + "USE_ALBEDO_MAP": true + } + ], + "_states": [ + { + "blendState": { + "targets": [ + {} + ] + }, + "depthStencilState": {}, + "rasterizerState": {} + }, + { + "blendState": { + "targets": [ + {} + ] + }, + "depthStencilState": {}, + "rasterizerState": {} + }, + { + "blendState": { + "targets": [ + {} + ] + }, + "depthStencilState": {}, + "rasterizerState": {} + } + ], + "_props": [ + { + "alphaThreshold": 0, + "roughness": 0.70710676908493, + "metallic": 0.400000005960464, + "mainTexture": { + "__uuid__": "95e5b02a-e338-423c-bdbb-17486db1d9eb@6c48a" + } + }, + {}, + {} + ] +} \ No newline at end of file diff --git a/CameraFollowDemo/assets/material/shield.mtl.meta b/CameraFollowDemo/assets/material/shield.mtl.meta new file mode 100644 index 0000000..8628d43 --- /dev/null +++ b/CameraFollowDemo/assets/material/shield.mtl.meta @@ -0,0 +1,11 @@ +{ + "ver": "1.0.11", + "importer": "material", + "imported": true, + "uuid": "8e047178-f61c-4322-a2f6-d1adb28b6ae2", + "files": [ + ".json" + ], + "subMetas": {}, + "userData": {} +} diff --git a/CameraFollowDemo/assets/material/soldier.mtl b/CameraFollowDemo/assets/material/soldier.mtl new file mode 100644 index 0000000..c405305 --- /dev/null +++ b/CameraFollowDemo/assets/material/soldier.mtl @@ -0,0 +1,83 @@ +{ + "__type__": "cc.Material", + "_name": "", + "_objFlags": 0, + "_native": "", + "_effectAsset": { + "__uuid__": "a7612b54-35e3-4238-a1a9-4a7b54635839" + }, + "_techIdx": 0, + "_defines": [ + { + "USE_OUTLINE_PASS": true + }, + { + "USE_BASE_COLOR_MAP": true, + "BASE_COLOR_MAP_AS_SHADE_MAP_1": true, + "BASE_COLOR_MAP_AS_SHADE_MAP_2": true + }, + { + "USE_BASE_COLOR_MAP": true, + "BASE_COLOR_MAP_AS_SHADE_MAP_1": true, + "BASE_COLOR_MAP_AS_SHADE_MAP_2": true + }, + { + "USE_BASE_COLOR_MAP": true + } + ], + "_states": [ + { + "blendState": { + "targets": [ + {} + ] + }, + "depthStencilState": {}, + "rasterizerState": {} + }, + { + "blendState": { + "targets": [ + {} + ] + }, + "depthStencilState": {}, + "rasterizerState": {} + }, + { + "blendState": { + "targets": [ + {} + ] + }, + "depthStencilState": {}, + "rasterizerState": {} + }, + { + "blendState": { + "targets": [ + {} + ] + }, + "depthStencilState": {}, + "rasterizerState": {} + } + ], + "_props": [ + {}, + { + "specular": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 0 + }, + "mainTexture": { + "__uuid__": "6f891a7b-5a08-48e6-9841-ddb364ac86b1@6c48a" + } + }, + {}, + {} + ] +} \ No newline at end of file diff --git a/CameraFollowDemo/assets/material/soldier.mtl.meta b/CameraFollowDemo/assets/material/soldier.mtl.meta new file mode 100644 index 0000000..a8b6c5a --- /dev/null +++ b/CameraFollowDemo/assets/material/soldier.mtl.meta @@ -0,0 +1,11 @@ +{ + "ver": "1.0.11", + "importer": "material", + "imported": true, + "uuid": "8a58ddec-f437-40b9-8ec0-1fc87de97fb5", + "files": [ + ".json" + ], + "subMetas": {}, + "userData": {} +} diff --git a/CameraFollowDemo/assets/material/stone.mtl b/CameraFollowDemo/assets/material/stone.mtl new file mode 100644 index 0000000..69da94f --- /dev/null +++ b/CameraFollowDemo/assets/material/stone.mtl @@ -0,0 +1,83 @@ +{ + "__type__": "cc.Material", + "_name": "", + "_objFlags": 0, + "_native": "", + "_effectAsset": { + "__uuid__": "a7612b54-35e3-4238-a1a9-4a7b54635839" + }, + "_techIdx": 0, + "_defines": [ + { + "USE_OUTLINE_PASS": true + }, + { + "USE_BASE_COLOR_MAP": true, + "BASE_COLOR_MAP_AS_SHADE_MAP_1": true, + "BASE_COLOR_MAP_AS_SHADE_MAP_2": true + }, + { + "USE_BASE_COLOR_MAP": true, + "BASE_COLOR_MAP_AS_SHADE_MAP_1": true, + "BASE_COLOR_MAP_AS_SHADE_MAP_2": true + }, + { + "USE_BASE_COLOR_MAP": true + } + ], + "_states": [ + { + "blendState": { + "targets": [ + {} + ] + }, + "depthStencilState": {}, + "rasterizerState": {} + }, + { + "blendState": { + "targets": [ + {} + ] + }, + "depthStencilState": {}, + "rasterizerState": {} + }, + { + "blendState": { + "targets": [ + {} + ] + }, + "depthStencilState": {}, + "rasterizerState": {} + }, + { + "blendState": { + "targets": [ + {} + ] + }, + "depthStencilState": {}, + "rasterizerState": {} + } + ], + "_props": [ + {}, + { + "specular": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 0 + }, + "mainTexture": { + "__uuid__": "0718d996-39bf-4ab4-bb63-496666fef467@6c48a" + } + }, + {}, + {} + ] +} \ No newline at end of file diff --git a/CameraFollowDemo/assets/material/stone.mtl.meta b/CameraFollowDemo/assets/material/stone.mtl.meta new file mode 100644 index 0000000..829b0b5 --- /dev/null +++ b/CameraFollowDemo/assets/material/stone.mtl.meta @@ -0,0 +1,11 @@ +{ + "ver": "1.0.11", + "importer": "material", + "imported": true, + "uuid": "a155f93b-7769-4ca4-b75f-b13e52193859", + "files": [ + ".json" + ], + "subMetas": {}, + "userData": {} +} diff --git a/CameraFollowDemo/assets/material/tree.mtl b/CameraFollowDemo/assets/material/tree.mtl new file mode 100644 index 0000000..120ce3e --- /dev/null +++ b/CameraFollowDemo/assets/material/tree.mtl @@ -0,0 +1,83 @@ +{ + "__type__": "cc.Material", + "_name": "", + "_objFlags": 0, + "_native": "", + "_effectAsset": { + "__uuid__": "a7612b54-35e3-4238-a1a9-4a7b54635839" + }, + "_techIdx": 0, + "_defines": [ + { + "USE_OUTLINE_PASS": true + }, + { + "USE_BASE_COLOR_MAP": true, + "BASE_COLOR_MAP_AS_SHADE_MAP_1": true, + "BASE_COLOR_MAP_AS_SHADE_MAP_2": true + }, + { + "USE_BASE_COLOR_MAP": true, + "BASE_COLOR_MAP_AS_SHADE_MAP_1": true, + "BASE_COLOR_MAP_AS_SHADE_MAP_2": true + }, + { + "USE_BASE_COLOR_MAP": true + } + ], + "_states": [ + { + "blendState": { + "targets": [ + {} + ] + }, + "depthStencilState": {}, + "rasterizerState": {} + }, + { + "blendState": { + "targets": [ + {} + ] + }, + "depthStencilState": {}, + "rasterizerState": {} + }, + { + "blendState": { + "targets": [ + {} + ] + }, + "depthStencilState": {}, + "rasterizerState": {} + }, + { + "blendState": { + "targets": [ + {} + ] + }, + "depthStencilState": {}, + "rasterizerState": {} + } + ], + "_props": [ + {}, + { + "specular": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 0 + }, + "mainTexture": { + "__uuid__": "c5083e75-ad2e-4ea9-8b33-dee748995b00@6c48a" + } + }, + {}, + {} + ] +} \ No newline at end of file diff --git a/CameraFollowDemo/assets/material/tree.mtl.meta b/CameraFollowDemo/assets/material/tree.mtl.meta new file mode 100644 index 0000000..5c7d9db --- /dev/null +++ b/CameraFollowDemo/assets/material/tree.mtl.meta @@ -0,0 +1,11 @@ +{ + "ver": "1.0.11", + "importer": "material", + "imported": true, + "uuid": "7bf9df40-4bc9-4e25-8cb0-9a500f949102", + "files": [ + ".json" + ], + "subMetas": {}, + "userData": {} +} diff --git a/CameraFollowDemo/assets/model.meta b/CameraFollowDemo/assets/model.meta new file mode 100644 index 0000000..2408a58 --- /dev/null +++ b/CameraFollowDemo/assets/model.meta @@ -0,0 +1,12 @@ +{ + "ver": "1.1.0", + "importer": "directory", + "imported": true, + "uuid": "1ddc11ba-ecbd-4472-841c-f3777cb248da", + "files": [], + "subMetas": {}, + "userData": { + "compressionType": {}, + "isRemoteBundle": {} + } +} diff --git a/CameraFollowDemo/assets/model/helloWorld.meta b/CameraFollowDemo/assets/model/helloWorld.meta new file mode 100644 index 0000000..9e85fa7 --- /dev/null +++ b/CameraFollowDemo/assets/model/helloWorld.meta @@ -0,0 +1,12 @@ +{ + "ver": "1.1.0", + "importer": "directory", + "imported": true, + "uuid": "11a1d348-a622-41b2-89f3-ed24657e5f84", + "files": [], + "subMetas": {}, + "userData": { + "compressionType": {}, + "isRemoteBundle": {} + } +} diff --git a/CameraFollowDemo/assets/model/helloWorld/grass.meta b/CameraFollowDemo/assets/model/helloWorld/grass.meta new file mode 100644 index 0000000..c5088c9 --- /dev/null +++ b/CameraFollowDemo/assets/model/helloWorld/grass.meta @@ -0,0 +1,12 @@ +{ + "ver": "1.1.0", + "importer": "directory", + "imported": true, + "uuid": "e00862a8-c500-427c-b76f-bbe5203f19cc", + "files": [], + "subMetas": {}, + "userData": { + "compressionType": {}, + "isRemoteBundle": {} + } +} diff --git a/CameraFollowDemo/assets/model/helloWorld/grass/grass.FBX b/CameraFollowDemo/assets/model/helloWorld/grass/grass.FBX new file mode 100644 index 0000000..b4b7ead Binary files /dev/null and b/CameraFollowDemo/assets/model/helloWorld/grass/grass.FBX differ diff --git a/CameraFollowDemo/assets/model/helloWorld/grass/grass.FBX.meta b/CameraFollowDemo/assets/model/helloWorld/grass/grass.FBX.meta new file mode 100644 index 0000000..f11130a --- /dev/null +++ b/CameraFollowDemo/assets/model/helloWorld/grass/grass.FBX.meta @@ -0,0 +1,171 @@ +{ + "ver": "2.1.10", + "importer": "fbx", + "imported": true, + "uuid": "aade09ee-8f9d-413c-a9e8-8c686ea5e160", + "files": [ + "__original-animation-0.cconb" + ], + "subMetas": { + "ef5e1": { + "importer": "gltf-mesh", + "uuid": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@ef5e1", + "displayName": "", + "id": "ef5e1", + "name": "grass.mesh", + "ver": "1.1.0", + "imported": true, + "files": [ + ".bin", + ".json" + ], + "subMetas": {}, + "userData": { + "gltfIndex": 0 + } + }, + "73b7f": { + "importer": "gltf-animation", + "uuid": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@73b7f", + "displayName": "", + "id": "73b7f", + "name": "Take 001.animation", + "ver": "1.0.16", + "imported": true, + "files": [ + ".cconb" + ], + "subMetas": {}, + "userData": { + "events": [], + "gltfIndex": 0, + "sample": 30, + "span": { + "from": 0, + "to": 3.3333332538604736 + }, + "wrapMode": 2, + "speed": 1 + } + }, + "438fe": { + "importer": "gltf-skeleton", + "uuid": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@438fe", + "displayName": "", + "id": "438fe", + "name": "UnnamedSkeleton.skeleton", + "ver": "1.0.1", + "imported": true, + "files": [ + ".json" + ], + "subMetas": {}, + "userData": { + "gltfIndex": 0, + "jointsLength": 6 + } + }, + "80e0c": { + "importer": "gltf-embeded-image", + "uuid": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@80e0c", + "displayName": "", + "id": "80e0c", + "name": "grass.png.image", + "ver": "1.0.3", + "imported": true, + "files": [ + ".png", + ".json" + ], + "subMetas": {}, + "userData": { + "gltfIndex": 0 + } + }, + "9787f": { + "importer": "texture", + "uuid": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@9787f", + "displayName": "", + "id": "9787f", + "name": "grass.texture", + "ver": "1.0.21", + "imported": true, + "files": [ + ".json" + ], + "subMetas": {}, + "userData": { + "wrapModeS": "repeat", + "wrapModeT": "repeat", + "minfilter": "linear", + "magfilter": "linear", + "mipfilter": "none", + "premultiplyAlpha": false, + "anisotropy": 0, + "isUuid": true, + "imageUuidOrDatabaseUri": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@80e0c" + } + }, + "3022b": { + "importer": "gltf-scene", + "uuid": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@3022b", + "displayName": "", + "id": "3022b", + "name": "grass.prefab", + "ver": "1.0.12", + "imported": true, + "files": [ + ".json" + ], + "subMetas": {}, + "userData": { + "gltfIndex": 0 + } + } + }, + "userData": { + "imageMetas": [ + { + "name": "grass.png", + "uri": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@80e0c" + } + ], + "animationImportSettings": [ + { + "name": "Take 001", + "duration": 3.3333332538604736, + "fps": 30, + "splits": [ + { + "name": "Take 001", + "from": 0, + "to": 3.3333332538604736, + "wrapMode": 2 + } + ] + } + ], + "redirect": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@3022b", + "assetFinder": { + "meshes": [ + "aade09ee-8f9d-413c-a9e8-8c686ea5e160@ef5e1" + ], + "skeletons": [ + "aade09ee-8f9d-413c-a9e8-8c686ea5e160@438fe" + ], + "textures": [ + "aade09ee-8f9d-413c-a9e8-8c686ea5e160@9787f" + ], + "materials": [ + "b698e55a-b00b-4987-a8b4-af83cddc59f7" + ], + "scenes": [ + "aade09ee-8f9d-413c-a9e8-8c686ea5e160@3022b" + ] + }, + "useVertexColors": true, + "dumpMaterials": true, + "materialDumpDir": "db://assets/model/helloWorld/grass", + "legacyFbxImporter": true + } +} diff --git a/CameraFollowDemo/assets/model/helloWorld/grass/grass.mtl b/CameraFollowDemo/assets/model/helloWorld/grass/grass.mtl new file mode 100644 index 0000000..5233edb --- /dev/null +++ b/CameraFollowDemo/assets/model/helloWorld/grass/grass.mtl @@ -0,0 +1,34 @@ +{ + "__type__": "cc.Material", + "_name": "", + "_objFlags": 0, + "_native": "", + "_effectAsset": { + "__uuid__": "a3cd009f-0ab0-420d-9278-b9fdab939bbc" + }, + "_techIdx": 0, + "_defines": [ + { + "USE_TEXTURE": true + } + ], + "_states": [ + { + "blendState": { + "targets": [ + {} + ] + }, + "depthStencilState": {}, + "rasterizerState": {} + } + ], + "_props": [ + { + "mainTexture": { + "__uuid__": "ae18deea-c6e0-4a3d-bf70-ee5533f9ba87@6c48a" + }, + "alphaThreshold": 0 + } + ] +} \ No newline at end of file diff --git a/CameraFollowDemo/assets/model/helloWorld/grass/grass.mtl.meta b/CameraFollowDemo/assets/model/helloWorld/grass/grass.mtl.meta new file mode 100644 index 0000000..235bce1 --- /dev/null +++ b/CameraFollowDemo/assets/model/helloWorld/grass/grass.mtl.meta @@ -0,0 +1,11 @@ +{ + "ver": "1.0.11", + "importer": "material", + "imported": true, + "uuid": "b698e55a-b00b-4987-a8b4-af83cddc59f7", + "files": [ + ".json" + ], + "subMetas": {}, + "userData": {} +} diff --git a/CameraFollowDemo/assets/model/helloWorld/grass/grass.png b/CameraFollowDemo/assets/model/helloWorld/grass/grass.png new file mode 100644 index 0000000..78406d7 Binary files /dev/null and b/CameraFollowDemo/assets/model/helloWorld/grass/grass.png differ diff --git a/CameraFollowDemo/assets/model/helloWorld/grass/grass.png.meta b/CameraFollowDemo/assets/model/helloWorld/grass/grass.png.meta new file mode 100644 index 0000000..6cd11e0 --- /dev/null +++ b/CameraFollowDemo/assets/model/helloWorld/grass/grass.png.meta @@ -0,0 +1,41 @@ +{ + "ver": "1.0.22", + "importer": "image", + "imported": true, + "uuid": "ae18deea-c6e0-4a3d-bf70-ee5533f9ba87", + "files": [ + ".png", + ".json" + ], + "subMetas": { + "6c48a": { + "importer": "texture", + "uuid": "ae18deea-c6e0-4a3d-bf70-ee5533f9ba87@6c48a", + "displayName": "grass", + "id": "6c48a", + "name": "texture", + "ver": "1.0.21", + "imported": true, + "files": [ + ".json" + ], + "subMetas": {}, + "userData": { + "wrapModeS": "repeat", + "wrapModeT": "repeat", + "minfilter": "linear", + "magfilter": "linear", + "mipfilter": "linear", + "premultiplyAlpha": false, + "anisotropy": 0, + "isUuid": true, + "imageUuidOrDatabaseUri": "ae18deea-c6e0-4a3d-bf70-ee5533f9ba87" + } + } + }, + "userData": { + "type": "texture", + "redirect": "ae18deea-c6e0-4a3d-bf70-ee5533f9ba87@6c48a", + "hasAlpha": false + } +} diff --git a/CameraFollowDemo/assets/model/helloWorld/grass/grass.prefab b/CameraFollowDemo/assets/model/helloWorld/grass/grass.prefab new file mode 100644 index 0000000..ddb6022 --- /dev/null +++ b/CameraFollowDemo/assets/model/helloWorld/grass/grass.prefab @@ -0,0 +1,589 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "asyncLoadAssets": false + }, + { + "__type__": "cc.Node", + "_name": "grass", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + } + ], + "_active": true, + "_components": [ + { + "__id__": 21 + } + ], + "_prefab": { + "__id__": 23 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "RootNode", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 3 + }, + { + "__id__": 8 + }, + { + "__id__": 14 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 20 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "grass", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 4 + } + ], + "_prefab": { + "__id__": 7 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.37992816729770207, + "y": 0.5963678291908521, + "z": 0.5963678291908521, + "w": -0.37992816729770207 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 0.614784121513367, + "y": 0.614784121513367, + "z": 0.614784121513367 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -90, + "y": -115.0000056286655, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.SkinnedMeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 3 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "b698e55a-b00b-4987-a8b4-af83cddc59f7" + } + ], + "_visFlags": 0, + "lightmapSettings": { + "__id__": 5 + }, + "_mesh": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@ef5e1" + }, + "_shadowCastingMode": 0, + "_enableMorph": true, + "_skeleton": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@438fe" + }, + "_skinningRoot": { + "__id__": 1 + }, + "_id": "", + "__prefab": { + "__id__": 6 + } + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "cdq4wvfd1AkYLKBGkpcnul" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "3aIX8gjK5JFK8ATDBKdax8" + }, + { + "__type__": "cc.Node", + "_name": "Bone001", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [ + { + "__id__": 9 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 13 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": -0.0461842827498913, + "y": 0.0000118009265861474, + "z": -0.0284814611077309 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.0000017283479103639154, + "y": -0.000001696768662714476, + "z": 0.7049074170330618, + "w": 0.7092993256770451 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -0.0005507418826256091, + "y": 0.00027320859410338513, + "z": 89.64412979694991 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone002", + "_objFlags": 0, + "_parent": { + "__id__": 8 + }, + "_children": [ + { + "__id__": 10 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 12 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0404664427042007, + "y": -3.57627860658738e-9, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.000002421418716486127, + "y": 1.5182564735607207e-8, + "z": 0.006269989150778519, + "w": 0.9999803434219023 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0.000277479600078167, + "y": -3.18993241527229e-13, + "z": 0.7184925395739944 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone003", + "_objFlags": 0, + "_parent": { + "__id__": 9 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 11 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0397140197455883, + "y": -1.19209286886246e-9, + "z": 7.15255721317476e-9 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 1.4018830392883508e-10, + "y": -1.4662893682703937e-13, + "z": -0.0010459420626472054, + "w": 0.9999994530024512 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 1.606440509162768e-8, + "y": -1.4726229276075984e-18, + "z": -0.11985615346346049 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "1628kgL41EG4kfuuNtniX1" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "d1mgL13wtIwojR/2FqCufO" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "f5o8/2y99IcawmyX5Tnjyv" + }, + { + "__type__": "cc.Node", + "_name": "Bone004", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [ + { + "__id__": 15 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 19 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0710692703723907, + "y": 0.0000118009265861474, + "z": 0.0136896027252078 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.0000017283479103639154, + "y": -0.000001696768662714476, + "z": 0.7049074170330618, + "w": 0.7092993256770451 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -0.0005507418826256091, + "y": 0.00027320859410338513, + "z": 89.64412979694991 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone005", + "_objFlags": 0, + "_parent": { + "__id__": 14 + }, + "_children": [ + { + "__id__": 16 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 18 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0404664427042007, + "y": -4.76837147544984e-9, + "z": 5.9604643443123e-10 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.000002421418716486127, + "y": 1.5182564735607207e-8, + "z": 0.006269989150778519, + "w": 0.9999803434219023 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0.000277479600078167, + "y": -3.18993241527229e-13, + "z": 0.7184925395739944 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone006", + "_objFlags": 0, + "_parent": { + "__id__": 15 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 17 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.039714016020298, + "y": 0, + "z": 7.74860353658369e-9 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 1.4018830392883508e-10, + "y": -1.4662893682703937e-13, + "z": -0.0010459420626472054, + "w": 0.9999994530024512 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 1.606440509162768e-8, + "y": -1.4726229276075984e-18, + "z": -0.11985615346346049 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "a2tndvTm9M84i3qPpLv8DA" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "c5xVHa1qBClrp5YbutRSaI" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "3fxCLd4O9NUqkwJjBsDQgb" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "b7w6U8zppFX54UJURtAWiT" + }, + { + "__type__": "cc.SkeletalAnimation", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "playOnLoad": false, + "_clips": [ + { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@73b7f" + } + ], + "_defaultClip": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@73b7f" + }, + "_useBakedAnimation": true, + "_sockets": [], + "_id": "", + "__prefab": { + "__id__": 22 + } + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "deki0q/OJHD4jsTyP928BZ" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "fdSk3ayLBOH7saksB95r+y" + } +] \ No newline at end of file diff --git a/CameraFollowDemo/assets/model/helloWorld/grass/grass.prefab.meta b/CameraFollowDemo/assets/model/helloWorld/grass/grass.prefab.meta new file mode 100644 index 0000000..f2d6ba3 --- /dev/null +++ b/CameraFollowDemo/assets/model/helloWorld/grass/grass.prefab.meta @@ -0,0 +1,13 @@ +{ + "ver": "1.1.35", + "importer": "prefab", + "imported": true, + "uuid": "ebe68402-4803-40d3-b0a2-ca696e3f7c60", + "files": [ + ".json" + ], + "subMetas": {}, + "userData": { + "syncNodeName": "grass" + } +} diff --git a/CameraFollowDemo/assets/model/helloWorld/grass/grassGoup.prefab b/CameraFollowDemo/assets/model/helloWorld/grass/grassGoup.prefab new file mode 100644 index 0000000..d5a79c6 --- /dev/null +++ b/CameraFollowDemo/assets/model/helloWorld/grass/grassGoup.prefab @@ -0,0 +1,7035 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "asyncLoadAssets": false + }, + { + "__type__": "cc.Node", + "_name": "grassGoup", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + }, + { + "__id__": 25 + }, + { + "__id__": 48 + }, + { + "__id__": 71 + }, + { + "__id__": 94 + }, + { + "__id__": 117 + }, + { + "__id__": 140 + }, + { + "__id__": 163 + }, + { + "__id__": 186 + }, + { + "__id__": 209 + }, + { + "__id__": 232 + }, + { + "__id__": 255 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 278 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "grass", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 3 + } + ], + "_active": true, + "_components": [ + { + "__id__": 22 + } + ], + "_prefab": { + "__id__": 24 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": -0.852, + "y": 0.892, + "z": -1.49 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1.8, + "y": 1.8, + "z": 1.8 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "RootNode", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [ + { + "__id__": 4 + }, + { + "__id__": 9 + }, + { + "__id__": 15 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 21 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "grass", + "_objFlags": 0, + "_parent": { + "__id__": 3 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 5 + } + ], + "_prefab": { + "__id__": 8 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.37992816729770207, + "y": 0.5963678291908521, + "z": 0.5963678291908521, + "w": -0.37992816729770207 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 0.614784121513367, + "y": 0.614784121513367, + "z": 0.614784121513367 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -90, + "y": -115.0000056286655, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.SkinnedMeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 4 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "b698e55a-b00b-4987-a8b4-af83cddc59f7" + } + ], + "_visFlags": 0, + "lightmapSettings": { + "__id__": 6 + }, + "_mesh": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@ef5e1" + }, + "_shadowCastingMode": 0, + "_enableMorph": true, + "_skeleton": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@438fe" + }, + "_skinningRoot": { + "__id__": 2 + }, + "_id": "", + "__prefab": { + "__id__": 7 + } + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "a6J1jU/r1BPKNIcVMEREit" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "5fs1r6h0xEiJFeWVPk8SNl" + }, + { + "__type__": "cc.Node", + "_name": "Bone001", + "_objFlags": 0, + "_parent": { + "__id__": 3 + }, + "_children": [ + { + "__id__": 10 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 14 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": -0.0461842827498913, + "y": 0.0000118009265861474, + "z": -0.0284814611077309 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.0000017283479103639154, + "y": -0.000001696768662714476, + "z": 0.7049074170330618, + "w": 0.7092993256770451 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -0.0005507418826256091, + "y": 0.00027320859410338513, + "z": 89.64412979694991 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone002", + "_objFlags": 0, + "_parent": { + "__id__": 9 + }, + "_children": [ + { + "__id__": 11 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 13 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0404664427042007, + "y": -3.57627860658738e-9, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.000002421418716486127, + "y": 1.5182564735607207e-8, + "z": 0.006269989150778519, + "w": 0.9999803434219023 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0.000277479600078167, + "y": -3.18993241527229e-13, + "z": 0.7184925395739944 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone003", + "_objFlags": 0, + "_parent": { + "__id__": 10 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 12 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0397140197455883, + "y": -1.19209286886246e-9, + "z": 7.15255721317476e-9 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 1.4018830392883508e-10, + "y": -1.4662893682703937e-13, + "z": -0.0010459420626472054, + "w": 0.9999994530024512 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 1.606440509162768e-8, + "y": -1.4726229276075984e-18, + "z": -0.11985615346346049 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "8e/dPEvbdIMo48q55vpZZ3" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "beKna0bXZNtrHWMkpFZoVU" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "daWdShf/9NHLgm8BB+DJZm" + }, + { + "__type__": "cc.Node", + "_name": "Bone004", + "_objFlags": 0, + "_parent": { + "__id__": 3 + }, + "_children": [ + { + "__id__": 16 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 20 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0710692703723907, + "y": 0.0000118009265861474, + "z": 0.0136896027252078 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.0000017283479103639154, + "y": -0.000001696768662714476, + "z": 0.7049074170330618, + "w": 0.7092993256770451 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -0.0005507418826256091, + "y": 0.00027320859410338513, + "z": 89.64412979694991 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone005", + "_objFlags": 0, + "_parent": { + "__id__": 15 + }, + "_children": [ + { + "__id__": 17 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 19 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0404664427042007, + "y": -4.76837147544984e-9, + "z": 5.9604643443123e-10 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.000002421418716486127, + "y": 1.5182564735607207e-8, + "z": 0.006269989150778519, + "w": 0.9999803434219023 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0.000277479600078167, + "y": -3.18993241527229e-13, + "z": 0.7184925395739944 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone006", + "_objFlags": 0, + "_parent": { + "__id__": 16 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 18 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.039714016020298, + "y": 0, + "z": 7.74860353658369e-9 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 1.4018830392883508e-10, + "y": -1.4662893682703937e-13, + "z": -0.0010459420626472054, + "w": 0.9999994530024512 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 1.606440509162768e-8, + "y": -1.4726229276075984e-18, + "z": -0.11985615346346049 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "96ATlvvpZKqpZWVYxnyW6U" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "8fu8biB4BPFKtDBKsYv4K/" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "94aP4+w7dE/qUrh7Cfcv3Y" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "54SHCY049LyqH1HRGY3ZVR" + }, + { + "__type__": "cc.SkeletalAnimation", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "playOnLoad": true, + "_clips": [ + { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@73b7f" + } + ], + "_defaultClip": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@73b7f" + }, + "_useBakedAnimation": true, + "_sockets": [], + "_id": "", + "__prefab": { + "__id__": 23 + } + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "11JgtTUn5OJKE3LJ8pTj/2" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "87M1Av0v5LhZ3LsJOTzwr3" + }, + { + "__type__": "cc.Node", + "_name": "grass", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 26 + } + ], + "_active": true, + "_components": [ + { + "__id__": 45 + } + ], + "_prefab": { + "__id__": 47 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 1.271, + "y": 0.836, + "z": -2.68 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": -0.09886819763876702, + "z": 0, + "w": 0.9951005373808527 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1.4, + "y": 1.4, + "z": 1.4 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": -11.348, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "RootNode", + "_objFlags": 0, + "_parent": { + "__id__": 25 + }, + "_children": [ + { + "__id__": 27 + }, + { + "__id__": 32 + }, + { + "__id__": 38 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 44 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "grass", + "_objFlags": 0, + "_parent": { + "__id__": 26 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 28 + } + ], + "_prefab": { + "__id__": 31 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.37992816729770207, + "y": 0.5963678291908521, + "z": 0.5963678291908521, + "w": -0.37992816729770207 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 0.614784121513367, + "y": 0.614784121513367, + "z": 0.614784121513367 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -90, + "y": -115.0000056286655, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.SkinnedMeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 27 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "b698e55a-b00b-4987-a8b4-af83cddc59f7" + } + ], + "_visFlags": 0, + "lightmapSettings": { + "__id__": 29 + }, + "_mesh": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@ef5e1" + }, + "_shadowCastingMode": 0, + "_enableMorph": true, + "_skeleton": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@438fe" + }, + "_skinningRoot": { + "__id__": 25 + }, + "_id": "", + "__prefab": { + "__id__": 30 + } + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "28WH2cvhNDFbN3it+8Q+XK" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "74Q+wg/aVBj5Bkvd+Cqz4L" + }, + { + "__type__": "cc.Node", + "_name": "Bone001", + "_objFlags": 0, + "_parent": { + "__id__": 26 + }, + "_children": [ + { + "__id__": 33 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 37 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": -0.0461842827498913, + "y": 0.0000118009265861474, + "z": -0.0284814611077309 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.0000017283479103639154, + "y": -0.000001696768662714476, + "z": 0.7049074170330618, + "w": 0.7092993256770451 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -0.0005507418826256091, + "y": 0.00027320859410338513, + "z": 89.64412979694991 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone002", + "_objFlags": 0, + "_parent": { + "__id__": 32 + }, + "_children": [ + { + "__id__": 34 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 36 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0404664427042007, + "y": -3.57627860658738e-9, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.000002421418716486127, + "y": 1.5182564735607207e-8, + "z": 0.006269989150778519, + "w": 0.9999803434219023 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0.000277479600078167, + "y": -3.18993241527229e-13, + "z": 0.7184925395739944 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone003", + "_objFlags": 0, + "_parent": { + "__id__": 33 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 35 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0397140197455883, + "y": -1.19209286886246e-9, + "z": 7.15255721317476e-9 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 1.4018830392883508e-10, + "y": -1.4662893682703937e-13, + "z": -0.0010459420626472054, + "w": 0.9999994530024512 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 1.606440509162768e-8, + "y": -1.4726229276075984e-18, + "z": -0.11985615346346049 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "af9wSIs/ZHx5FXOjfa1Jum" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "25LOOT8GBDpr0h1KIC5gCx" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "4fGc2baulLjbJeePpPYcqt" + }, + { + "__type__": "cc.Node", + "_name": "Bone004", + "_objFlags": 0, + "_parent": { + "__id__": 26 + }, + "_children": [ + { + "__id__": 39 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 43 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0710692703723907, + "y": 0.0000118009265861474, + "z": 0.0136896027252078 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.0000017283479103639154, + "y": -0.000001696768662714476, + "z": 0.7049074170330618, + "w": 0.7092993256770451 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -0.0005507418826256091, + "y": 0.00027320859410338513, + "z": 89.64412979694991 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone005", + "_objFlags": 0, + "_parent": { + "__id__": 38 + }, + "_children": [ + { + "__id__": 40 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 42 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0404664427042007, + "y": -4.76837147544984e-9, + "z": 5.9604643443123e-10 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.000002421418716486127, + "y": 1.5182564735607207e-8, + "z": 0.006269989150778519, + "w": 0.9999803434219023 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0.000277479600078167, + "y": -3.18993241527229e-13, + "z": 0.7184925395739944 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone006", + "_objFlags": 0, + "_parent": { + "__id__": 39 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 41 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.039714016020298, + "y": 0, + "z": 7.74860353658369e-9 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 1.4018830392883508e-10, + "y": -1.4662893682703937e-13, + "z": -0.0010459420626472054, + "w": 0.9999994530024512 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 1.606440509162768e-8, + "y": -1.4726229276075984e-18, + "z": -0.11985615346346049 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "65QAhjUVBAtLwEci9t05Ey" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "e75gT5ogJMOoh/2sggS7OQ" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "b8DSzxi5tJyKiMnjvG0NLg" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "bdiB2XMldLgpbPP0u9vyiH" + }, + { + "__type__": "cc.SkeletalAnimation", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 25 + }, + "_enabled": true, + "playOnLoad": true, + "_clips": [ + { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@73b7f" + } + ], + "_defaultClip": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@73b7f" + }, + "_useBakedAnimation": true, + "_sockets": [], + "_id": "", + "__prefab": { + "__id__": 46 + } + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "abXR2STONCQrmlGd7QjDWb" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "8avX4W7ZtLOLCZ8n5QtiPm" + }, + { + "__type__": "cc.Node", + "_name": "grass", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 49 + } + ], + "_active": true, + "_components": [ + { + "__id__": 68 + } + ], + "_prefab": { + "__id__": 70 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.816, + "y": 0.874, + "z": -2.029 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.009594606467145706, + "y": -0.09840154486124139, + "z": -0.09656895017241425, + "w": 0.9904037143297977 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1.8, + "y": 1.8, + "z": 1.8 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": -11.348, + "z": -11.138 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "RootNode", + "_objFlags": 0, + "_parent": { + "__id__": 48 + }, + "_children": [ + { + "__id__": 50 + }, + { + "__id__": 55 + }, + { + "__id__": 61 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 67 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "grass", + "_objFlags": 0, + "_parent": { + "__id__": 49 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 51 + } + ], + "_prefab": { + "__id__": 54 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.37992816729770207, + "y": 0.5963678291908521, + "z": 0.5963678291908521, + "w": -0.37992816729770207 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 0.614784121513367, + "y": 0.614784121513367, + "z": 0.614784121513367 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -90, + "y": -115.0000056286655, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.SkinnedMeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 50 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "b698e55a-b00b-4987-a8b4-af83cddc59f7" + } + ], + "_visFlags": 0, + "lightmapSettings": { + "__id__": 52 + }, + "_mesh": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@ef5e1" + }, + "_shadowCastingMode": 0, + "_enableMorph": true, + "_skeleton": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@438fe" + }, + "_skinningRoot": { + "__id__": 48 + }, + "_id": "", + "__prefab": { + "__id__": 53 + } + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "87exLhmM1P35jx6GLN7j5f" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "60njdFxDhJWowG9HZr9kRy" + }, + { + "__type__": "cc.Node", + "_name": "Bone001", + "_objFlags": 0, + "_parent": { + "__id__": 49 + }, + "_children": [ + { + "__id__": 56 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 60 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": -0.0461842827498913, + "y": 0.0000118009265861474, + "z": -0.0284814611077309 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.0000017283479103639154, + "y": -0.000001696768662714476, + "z": 0.7049074170330618, + "w": 0.7092993256770451 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -0.0005507418826256091, + "y": 0.00027320859410338513, + "z": 89.64412979694991 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone002", + "_objFlags": 0, + "_parent": { + "__id__": 55 + }, + "_children": [ + { + "__id__": 57 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 59 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0404664427042007, + "y": -3.57627860658738e-9, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.000002421418716486127, + "y": 1.5182564735607207e-8, + "z": 0.006269989150778519, + "w": 0.9999803434219023 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0.000277479600078167, + "y": -3.18993241527229e-13, + "z": 0.7184925395739944 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone003", + "_objFlags": 0, + "_parent": { + "__id__": 56 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 58 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0397140197455883, + "y": -1.19209286886246e-9, + "z": 7.15255721317476e-9 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 1.4018830392883508e-10, + "y": -1.4662893682703937e-13, + "z": -0.0010459420626472054, + "w": 0.9999994530024512 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 1.606440509162768e-8, + "y": -1.4726229276075984e-18, + "z": -0.11985615346346049 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "91jR835RZHKbRhzSn1x2pJ" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "3bw6IJ5hBJ0aqjcninjsA3" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "dfSzBMugdCkL5lyChYPcpt" + }, + { + "__type__": "cc.Node", + "_name": "Bone004", + "_objFlags": 0, + "_parent": { + "__id__": 49 + }, + "_children": [ + { + "__id__": 62 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 66 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0710692703723907, + "y": 0.0000118009265861474, + "z": 0.0136896027252078 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.0000017283479103639154, + "y": -0.000001696768662714476, + "z": 0.7049074170330618, + "w": 0.7092993256770451 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -0.0005507418826256091, + "y": 0.00027320859410338513, + "z": 89.64412979694991 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone005", + "_objFlags": 0, + "_parent": { + "__id__": 61 + }, + "_children": [ + { + "__id__": 63 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 65 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0404664427042007, + "y": -4.76837147544984e-9, + "z": 5.9604643443123e-10 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.000002421418716486127, + "y": 1.5182564735607207e-8, + "z": 0.006269989150778519, + "w": 0.9999803434219023 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0.000277479600078167, + "y": -3.18993241527229e-13, + "z": 0.7184925395739944 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone006", + "_objFlags": 0, + "_parent": { + "__id__": 62 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 64 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.039714016020298, + "y": 0, + "z": 7.74860353658369e-9 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 1.4018830392883508e-10, + "y": -1.4662893682703937e-13, + "z": -0.0010459420626472054, + "w": 0.9999994530024512 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 1.606440509162768e-8, + "y": -1.4726229276075984e-18, + "z": -0.11985615346346049 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "977HJ5Wy5HiapZRnYB3I8X" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "3da6ppQblGu7DGQDIjczFt" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "36km6+kJtJZ4iiy8pwU3RO" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "0cYonIu91LHamoapMUydbc" + }, + { + "__type__": "cc.SkeletalAnimation", + "_name": "grass", + "_objFlags": 0, + "node": { + "__id__": 48 + }, + "_enabled": true, + "playOnLoad": true, + "_clips": [ + { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@73b7f" + } + ], + "_defaultClip": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@73b7f" + }, + "_useBakedAnimation": true, + "_sockets": [], + "_id": "", + "__prefab": { + "__id__": 69 + } + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "3eRlu7+XFMf4IKjhzVuyYo" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "5fAmHUz0xO9YFym/gsZawP" + }, + { + "__type__": "cc.Node", + "_name": "grass", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 72 + } + ], + "_active": true, + "_components": [ + { + "__id__": 91 + } + ], + "_prefab": { + "__id__": 93 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 1.505, + "y": 0.835, + "z": -2.352 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.009051343059323664, + "y": 0.011005731118140823, + "z": -0.042668681053864996, + "w": 0.9989876529409666 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1.8, + "y": 1.8, + "z": 1.8 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 1.094, + "y": 1.309, + "z": -4.879 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "RootNode", + "_objFlags": 0, + "_parent": { + "__id__": 71 + }, + "_children": [ + { + "__id__": 73 + }, + { + "__id__": 78 + }, + { + "__id__": 84 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 90 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "grass", + "_objFlags": 0, + "_parent": { + "__id__": 72 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 74 + } + ], + "_prefab": { + "__id__": 77 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.37992816729770207, + "y": 0.5963678291908521, + "z": 0.5963678291908521, + "w": -0.37992816729770207 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 0.614784121513367, + "y": 0.614784121513367, + "z": 0.614784121513367 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -90, + "y": -115.0000056286655, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.SkinnedMeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 73 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "b698e55a-b00b-4987-a8b4-af83cddc59f7" + } + ], + "_visFlags": 0, + "lightmapSettings": { + "__id__": 75 + }, + "_mesh": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@ef5e1" + }, + "_shadowCastingMode": 0, + "_enableMorph": true, + "_skeleton": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@438fe" + }, + "_skinningRoot": { + "__id__": 71 + }, + "_id": "", + "__prefab": { + "__id__": 76 + } + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "dduLonFhNK+q908BUlLM7f" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "f2zxp5nX1CJq18JC2EndYO" + }, + { + "__type__": "cc.Node", + "_name": "Bone001", + "_objFlags": 0, + "_parent": { + "__id__": 72 + }, + "_children": [ + { + "__id__": 79 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 83 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": -0.0461842827498913, + "y": 0.0000118009265861474, + "z": -0.0284814611077309 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.0000017283479103639154, + "y": -0.000001696768662714476, + "z": 0.7049074170330618, + "w": 0.7092993256770451 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -0.0005507418826256091, + "y": 0.00027320859410338513, + "z": 89.64412979694991 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone002", + "_objFlags": 0, + "_parent": { + "__id__": 78 + }, + "_children": [ + { + "__id__": 80 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 82 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0404664427042007, + "y": -3.57627860658738e-9, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.000002421418716486127, + "y": 1.5182564735607207e-8, + "z": 0.006269989150778519, + "w": 0.9999803434219023 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0.000277479600078167, + "y": -3.18993241527229e-13, + "z": 0.7184925395739944 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone003", + "_objFlags": 0, + "_parent": { + "__id__": 79 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 81 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0397140197455883, + "y": -1.19209286886246e-9, + "z": 7.15255721317476e-9 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 1.4018830392883508e-10, + "y": -1.4662893682703937e-13, + "z": -0.0010459420626472054, + "w": 0.9999994530024512 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 1.606440509162768e-8, + "y": -1.4726229276075984e-18, + "z": -0.11985615346346049 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "baL59AVvRKlKmpQqSjNAYI" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "89NJAVd1tBZ6C0iX/YbeY2" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "3c+BtM6atJC4XerbYlNlM0" + }, + { + "__type__": "cc.Node", + "_name": "Bone004", + "_objFlags": 0, + "_parent": { + "__id__": 72 + }, + "_children": [ + { + "__id__": 85 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 89 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0710692703723907, + "y": 0.0000118009265861474, + "z": 0.0136896027252078 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.0000017283479103639154, + "y": -0.000001696768662714476, + "z": 0.7049074170330618, + "w": 0.7092993256770451 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -0.0005507418826256091, + "y": 0.00027320859410338513, + "z": 89.64412979694991 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone005", + "_objFlags": 0, + "_parent": { + "__id__": 84 + }, + "_children": [ + { + "__id__": 86 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 88 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0404664427042007, + "y": -4.76837147544984e-9, + "z": 5.9604643443123e-10 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.000002421418716486127, + "y": 1.5182564735607207e-8, + "z": 0.006269989150778519, + "w": 0.9999803434219023 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0.000277479600078167, + "y": -3.18993241527229e-13, + "z": 0.7184925395739944 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone006", + "_objFlags": 0, + "_parent": { + "__id__": 85 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 87 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.039714016020298, + "y": 0, + "z": 7.74860353658369e-9 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 1.4018830392883508e-10, + "y": -1.4662893682703937e-13, + "z": -0.0010459420626472054, + "w": 0.9999994530024512 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 1.606440509162768e-8, + "y": -1.4726229276075984e-18, + "z": -0.11985615346346049 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "6fAgsRfRRHeoZrCvNeGhDK" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "8exO45eF5F2KzRxFbNE1M/" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "9byDe6eNtGPIztX4VSZKlQ" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "2at9CGY1VK9qtNpM8kC/KU" + }, + { + "__type__": "cc.SkeletalAnimation", + "_name": "grass", + "_objFlags": 0, + "node": { + "__id__": 71 + }, + "_enabled": true, + "playOnLoad": true, + "_clips": [ + { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@73b7f" + } + ], + "_defaultClip": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@73b7f" + }, + "_useBakedAnimation": true, + "_sockets": [], + "_id": "", + "__prefab": { + "__id__": 92 + } + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "22rvun9aNNBbAK//dWXzkX" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "9bIVhdYYpFl7JZmL4oubNS" + }, + { + "__type__": "cc.Node", + "_name": "grass", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 95 + } + ], + "_active": true, + "_components": [ + { + "__id__": 114 + } + ], + "_prefab": { + "__id__": 116 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 2.591, + "y": 0.697, + "z": -3.192 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.009569056200142995, + "y": -0.27238145223532967, + "z": -0.02174826425431747, + "w": 0.961895935454317 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1.4, + "y": 1.4, + "z": 1.4 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -1.735, + "y": -31.653, + "z": -2.099 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "RootNode", + "_objFlags": 0, + "_parent": { + "__id__": 94 + }, + "_children": [ + { + "__id__": 96 + }, + { + "__id__": 101 + }, + { + "__id__": 107 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 113 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "grass", + "_objFlags": 0, + "_parent": { + "__id__": 95 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 97 + } + ], + "_prefab": { + "__id__": 100 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.37992816729770207, + "y": 0.5963678291908521, + "z": 0.5963678291908521, + "w": -0.37992816729770207 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 0.614784121513367, + "y": 0.614784121513367, + "z": 0.614784121513367 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -90, + "y": -115.0000056286655, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.SkinnedMeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 96 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "b698e55a-b00b-4987-a8b4-af83cddc59f7" + } + ], + "_visFlags": 0, + "lightmapSettings": { + "__id__": 98 + }, + "_mesh": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@ef5e1" + }, + "_shadowCastingMode": 0, + "_enableMorph": true, + "_skeleton": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@438fe" + }, + "_skinningRoot": { + "__id__": 94 + }, + "_id": "", + "__prefab": { + "__id__": 99 + } + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "af0f1GeGlKf5MvKMEuH8MJ" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "a2WxB7prNBKZLuuRtE7RC2" + }, + { + "__type__": "cc.Node", + "_name": "Bone001", + "_objFlags": 0, + "_parent": { + "__id__": 95 + }, + "_children": [ + { + "__id__": 102 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 106 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": -0.0461842827498913, + "y": 0.0000118009265861474, + "z": -0.0284814611077309 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.0000017283479103639154, + "y": -0.000001696768662714476, + "z": 0.7049074170330618, + "w": 0.7092993256770451 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -0.0005507418826256091, + "y": 0.00027320859410338513, + "z": 89.64412979694991 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone002", + "_objFlags": 0, + "_parent": { + "__id__": 101 + }, + "_children": [ + { + "__id__": 103 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 105 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0404664427042007, + "y": -3.57627860658738e-9, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.000002421418716486127, + "y": 1.5182564735607207e-8, + "z": 0.006269989150778519, + "w": 0.9999803434219023 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0.000277479600078167, + "y": -3.18993241527229e-13, + "z": 0.7184925395739944 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone003", + "_objFlags": 0, + "_parent": { + "__id__": 102 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 104 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0397140197455883, + "y": -1.19209286886246e-9, + "z": 7.15255721317476e-9 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 1.4018830392883508e-10, + "y": -1.4662893682703937e-13, + "z": -0.0010459420626472054, + "w": 0.9999994530024512 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 1.606440509162768e-8, + "y": -1.4726229276075984e-18, + "z": -0.11985615346346049 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "65JgfqDUlBhq62ZblXl99a" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "613BOOO+hIlqnTjr1LZ7yD" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "d9cSWZZzxJ0JJz3NZ3KYKr" + }, + { + "__type__": "cc.Node", + "_name": "Bone004", + "_objFlags": 0, + "_parent": { + "__id__": 95 + }, + "_children": [ + { + "__id__": 108 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 112 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0710692703723907, + "y": 0.0000118009265861474, + "z": 0.0136896027252078 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.0000017283479103639154, + "y": -0.000001696768662714476, + "z": 0.7049074170330618, + "w": 0.7092993256770451 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -0.0005507418826256091, + "y": 0.00027320859410338513, + "z": 89.64412979694991 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone005", + "_objFlags": 0, + "_parent": { + "__id__": 107 + }, + "_children": [ + { + "__id__": 109 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 111 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0404664427042007, + "y": -4.76837147544984e-9, + "z": 5.9604643443123e-10 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.000002421418716486127, + "y": 1.5182564735607207e-8, + "z": 0.006269989150778519, + "w": 0.9999803434219023 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0.000277479600078167, + "y": -3.18993241527229e-13, + "z": 0.7184925395739944 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone006", + "_objFlags": 0, + "_parent": { + "__id__": 108 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 110 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.039714016020298, + "y": 0, + "z": 7.74860353658369e-9 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 1.4018830392883508e-10, + "y": -1.4662893682703937e-13, + "z": -0.0010459420626472054, + "w": 0.9999994530024512 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 1.606440509162768e-8, + "y": -1.4726229276075984e-18, + "z": -0.11985615346346049 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "4bzVNkn1hF04sTb5BrBwWZ" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "aea82LsKdAiqVuBFPi2Vfz" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "daMGy+QoZIMbYWUh1/PBDR" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "75DE0pyqBGsIOI2RSOFxap" + }, + { + "__type__": "cc.SkeletalAnimation", + "_name": "grass", + "_objFlags": 0, + "node": { + "__id__": 94 + }, + "_enabled": true, + "playOnLoad": true, + "_clips": [ + { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@73b7f" + } + ], + "_defaultClip": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@73b7f" + }, + "_useBakedAnimation": true, + "_sockets": [], + "_id": "", + "__prefab": { + "__id__": 115 + } + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "0f8P8jwTVOzaIGGhmhMYJ6" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "2d66RAsipF1brG2RGpHJY1" + }, + { + "__type__": "cc.Node", + "_name": "grass", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 118 + } + ], + "_active": true, + "_components": [ + { + "__id__": 137 + } + ], + "_prefab": { + "__id__": 139 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": -2.85, + "y": 0.766, + "z": -2.616 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.007707220961668685, + "y": -0.0985673335815995, + "z": 0.07757256533280044, + "w": 0.9920723646001587 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1.8, + "y": 1.8, + "z": 1.8 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": -11.348, + "z": 8.942 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "RootNode", + "_objFlags": 0, + "_parent": { + "__id__": 117 + }, + "_children": [ + { + "__id__": 119 + }, + { + "__id__": 124 + }, + { + "__id__": 130 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 136 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "grass", + "_objFlags": 0, + "_parent": { + "__id__": 118 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 120 + } + ], + "_prefab": { + "__id__": 123 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.37992816729770207, + "y": 0.5963678291908521, + "z": 0.5963678291908521, + "w": -0.37992816729770207 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 0.614784121513367, + "y": 0.614784121513367, + "z": 0.614784121513367 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -90, + "y": -115.0000056286655, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.SkinnedMeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 119 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "b698e55a-b00b-4987-a8b4-af83cddc59f7" + } + ], + "_visFlags": 0, + "lightmapSettings": { + "__id__": 121 + }, + "_mesh": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@ef5e1" + }, + "_shadowCastingMode": 0, + "_enableMorph": true, + "_skeleton": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@438fe" + }, + "_skinningRoot": { + "__id__": 117 + }, + "_id": "", + "__prefab": { + "__id__": 122 + } + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "e9BPt5G81CloUmA5IJNHIQ" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "32O+zfC79Ly5/JDvR+zPy3" + }, + { + "__type__": "cc.Node", + "_name": "Bone001", + "_objFlags": 0, + "_parent": { + "__id__": 118 + }, + "_children": [ + { + "__id__": 125 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 129 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": -0.0461842827498913, + "y": 0.0000118009265861474, + "z": -0.0284814611077309 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.0000017283479103639154, + "y": -0.000001696768662714476, + "z": 0.7049074170330618, + "w": 0.7092993256770451 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -0.0005507418826256091, + "y": 0.00027320859410338513, + "z": 89.64412979694991 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone002", + "_objFlags": 0, + "_parent": { + "__id__": 124 + }, + "_children": [ + { + "__id__": 126 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 128 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0404664427042007, + "y": -3.57627860658738e-9, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.000002421418716486127, + "y": 1.5182564735607207e-8, + "z": 0.006269989150778519, + "w": 0.9999803434219023 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0.000277479600078167, + "y": -3.18993241527229e-13, + "z": 0.7184925395739944 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone003", + "_objFlags": 0, + "_parent": { + "__id__": 125 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 127 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0397140197455883, + "y": -1.19209286886246e-9, + "z": 7.15255721317476e-9 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 1.4018830392883508e-10, + "y": -1.4662893682703937e-13, + "z": -0.0010459420626472054, + "w": 0.9999994530024512 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 1.606440509162768e-8, + "y": -1.4726229276075984e-18, + "z": -0.11985615346346049 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "f31n3srf1OQ6ztTn+Z0+bi" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "39pnXuaeZGe5VqFTUXoXAo" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "2csxgVNAlDEIWU7lnXQfKS" + }, + { + "__type__": "cc.Node", + "_name": "Bone004", + "_objFlags": 0, + "_parent": { + "__id__": 118 + }, + "_children": [ + { + "__id__": 131 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 135 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0710692703723907, + "y": 0.0000118009265861474, + "z": 0.0136896027252078 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.0000017283479103639154, + "y": -0.000001696768662714476, + "z": 0.7049074170330618, + "w": 0.7092993256770451 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -0.0005507418826256091, + "y": 0.00027320859410338513, + "z": 89.64412979694991 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone005", + "_objFlags": 0, + "_parent": { + "__id__": 130 + }, + "_children": [ + { + "__id__": 132 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 134 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0404664427042007, + "y": -4.76837147544984e-9, + "z": 5.9604643443123e-10 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.000002421418716486127, + "y": 1.5182564735607207e-8, + "z": 0.006269989150778519, + "w": 0.9999803434219023 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0.000277479600078167, + "y": -3.18993241527229e-13, + "z": 0.7184925395739944 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone006", + "_objFlags": 0, + "_parent": { + "__id__": 131 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 133 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.039714016020298, + "y": 0, + "z": 7.74860353658369e-9 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 1.4018830392883508e-10, + "y": -1.4662893682703937e-13, + "z": -0.0010459420626472054, + "w": 0.9999994530024512 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 1.606440509162768e-8, + "y": -1.4726229276075984e-18, + "z": -0.11985615346346049 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "c8HIUzEBxJx72ffmHr7Yzh" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "82tqRzYDNKi6iXruWWHldm" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "e1Z+TO4odC37Bc8FKLNniF" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "12tzV7tYdKJJxbVmqiEpry" + }, + { + "__type__": "cc.SkeletalAnimation", + "_name": "grass", + "_objFlags": 0, + "node": { + "__id__": 117 + }, + "_enabled": true, + "playOnLoad": true, + "_clips": [ + { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@73b7f" + } + ], + "_defaultClip": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@73b7f" + }, + "_useBakedAnimation": true, + "_sockets": [], + "_id": "", + "__prefab": { + "__id__": 138 + } + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "b6LjWqcFFEYa267NpDVpBB" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "ffwse8PqZBf4sIEkNdsA+i" + }, + { + "__type__": "cc.Node", + "_name": "grass", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 141 + } + ], + "_active": true, + "_components": [ + { + "__id__": 160 + } + ], + "_prefab": { + "__id__": 162 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": -3.252, + "y": 0.663, + "z": -3.355 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.005303598000440666, + "y": -0.09872584440048117, + "z": 0.053380291603709065, + "w": 0.9936677633716235 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1.6, + "y": 1.6, + "z": 1.6 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 9.996766443584073e-17, + "y": -11.348, + "z": 6.150000000000002 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "RootNode", + "_objFlags": 0, + "_parent": { + "__id__": 140 + }, + "_children": [ + { + "__id__": 142 + }, + { + "__id__": 147 + }, + { + "__id__": 153 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 159 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "grass", + "_objFlags": 0, + "_parent": { + "__id__": 141 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 143 + } + ], + "_prefab": { + "__id__": 146 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.37992816729770207, + "y": 0.5963678291908521, + "z": 0.5963678291908521, + "w": -0.37992816729770207 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 0.614784121513367, + "y": 0.614784121513367, + "z": 0.614784121513367 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -90, + "y": -115.0000056286655, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.SkinnedMeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 142 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "b698e55a-b00b-4987-a8b4-af83cddc59f7" + } + ], + "_visFlags": 0, + "lightmapSettings": { + "__id__": 144 + }, + "_mesh": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@ef5e1" + }, + "_shadowCastingMode": 0, + "_enableMorph": true, + "_skeleton": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@438fe" + }, + "_skinningRoot": { + "__id__": 140 + }, + "_id": "", + "__prefab": { + "__id__": 145 + } + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "7dt8ZZ5EBNDIxOgpt1XbGu" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "3c/GljN9JNKpGUQDJiCaAz" + }, + { + "__type__": "cc.Node", + "_name": "Bone001", + "_objFlags": 0, + "_parent": { + "__id__": 141 + }, + "_children": [ + { + "__id__": 148 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 152 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": -0.0461842827498913, + "y": 0.0000118009265861474, + "z": -0.0284814611077309 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.0000017283479103639154, + "y": -0.000001696768662714476, + "z": 0.7049074170330618, + "w": 0.7092993256770451 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -0.0005507418826256091, + "y": 0.00027320859410338513, + "z": 89.64412979694991 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone002", + "_objFlags": 0, + "_parent": { + "__id__": 147 + }, + "_children": [ + { + "__id__": 149 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 151 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0404664427042007, + "y": -3.57627860658738e-9, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.000002421418716486127, + "y": 1.5182564735607207e-8, + "z": 0.006269989150778519, + "w": 0.9999803434219023 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0.000277479600078167, + "y": -3.18993241527229e-13, + "z": 0.7184925395739944 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone003", + "_objFlags": 0, + "_parent": { + "__id__": 148 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 150 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0397140197455883, + "y": -1.19209286886246e-9, + "z": 7.15255721317476e-9 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 1.4018830392883508e-10, + "y": -1.4662893682703937e-13, + "z": -0.0010459420626472054, + "w": 0.9999994530024512 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 1.606440509162768e-8, + "y": -1.4726229276075984e-18, + "z": -0.11985615346346049 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "9fnTS8hnVIWqrzTdhgEpre" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "77DlSvZMVCFLNlyGWiwIha" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "17tlC2EGZMWoKAixVNAp0A" + }, + { + "__type__": "cc.Node", + "_name": "Bone004", + "_objFlags": 0, + "_parent": { + "__id__": 141 + }, + "_children": [ + { + "__id__": 154 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 158 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0710692703723907, + "y": 0.0000118009265861474, + "z": 0.0136896027252078 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.0000017283479103639154, + "y": -0.000001696768662714476, + "z": 0.7049074170330618, + "w": 0.7092993256770451 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -0.0005507418826256091, + "y": 0.00027320859410338513, + "z": 89.64412979694991 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone005", + "_objFlags": 0, + "_parent": { + "__id__": 153 + }, + "_children": [ + { + "__id__": 155 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 157 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0404664427042007, + "y": -4.76837147544984e-9, + "z": 5.9604643443123e-10 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.000002421418716486127, + "y": 1.5182564735607207e-8, + "z": 0.006269989150778519, + "w": 0.9999803434219023 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0.000277479600078167, + "y": -3.18993241527229e-13, + "z": 0.7184925395739944 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone006", + "_objFlags": 0, + "_parent": { + "__id__": 154 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 156 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.039714016020298, + "y": 0, + "z": 7.74860353658369e-9 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 1.4018830392883508e-10, + "y": -1.4662893682703937e-13, + "z": -0.0010459420626472054, + "w": 0.9999994530024512 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 1.606440509162768e-8, + "y": -1.4726229276075984e-18, + "z": -0.11985615346346049 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "8cUixi2TpMHINjSklAPeYi" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "b7XmnH2bBCVpvgTAKnVXA2" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "d1EnMgh6RE7o+kI5cUNlG0" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "0eVA3+ezRBf4EQOOoMIo4S" + }, + { + "__type__": "cc.SkeletalAnimation", + "_name": "grass", + "_objFlags": 0, + "node": { + "__id__": 140 + }, + "_enabled": true, + "playOnLoad": true, + "_clips": [ + { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@73b7f" + } + ], + "_defaultClip": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@73b7f" + }, + "_useBakedAnimation": true, + "_sockets": [], + "_id": "", + "__prefab": { + "__id__": 161 + } + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "a5eATDuwJGuL6l09vX0n3S" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "adNP+ELEhC4awfcKkY8jYJ" + }, + { + "__type__": "cc.Node", + "_name": "grass", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 164 + } + ], + "_active": true, + "_components": [ + { + "__id__": 183 + } + ], + "_prefab": { + "__id__": 185 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": -4.716, + "y": 0.534, + "z": -2.539 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.011417842217574529, + "y": 0.10201162854238845, + "z": 0.09441482697624534, + "w": 0.9902267926936081 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1.2999999999999998, + "y": 1.3, + "z": 1.3 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -2.442, + "y": 11.991, + "z": 10.641 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "RootNode", + "_objFlags": 0, + "_parent": { + "__id__": 163 + }, + "_children": [ + { + "__id__": 165 + }, + { + "__id__": 170 + }, + { + "__id__": 176 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 182 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "grass", + "_objFlags": 0, + "_parent": { + "__id__": 164 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 166 + } + ], + "_prefab": { + "__id__": 169 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.37992816729770207, + "y": 0.5963678291908521, + "z": 0.5963678291908521, + "w": -0.37992816729770207 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 0.614784121513367, + "y": 0.614784121513367, + "z": 0.614784121513367 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -90, + "y": -115.0000056286655, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.SkinnedMeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 165 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "b698e55a-b00b-4987-a8b4-af83cddc59f7" + } + ], + "_visFlags": 0, + "lightmapSettings": { + "__id__": 167 + }, + "_mesh": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@ef5e1" + }, + "_shadowCastingMode": 0, + "_enableMorph": true, + "_skeleton": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@438fe" + }, + "_skinningRoot": { + "__id__": 163 + }, + "_id": "", + "__prefab": { + "__id__": 168 + } + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "c4Nekl9YtKUKupS0ASX7It" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "43yCcO1I5D6qP+LJIIGKjX" + }, + { + "__type__": "cc.Node", + "_name": "Bone001", + "_objFlags": 0, + "_parent": { + "__id__": 164 + }, + "_children": [ + { + "__id__": 171 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 175 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": -0.0461842827498913, + "y": 0.0000118009265861474, + "z": -0.0284814611077309 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.0000017283479103639154, + "y": -0.000001696768662714476, + "z": 0.7049074170330618, + "w": 0.7092993256770451 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -0.0005507418826256091, + "y": 0.00027320859410338513, + "z": 89.64412979694991 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone002", + "_objFlags": 0, + "_parent": { + "__id__": 170 + }, + "_children": [ + { + "__id__": 172 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 174 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0404664427042007, + "y": -3.57627860658738e-9, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.000002421418716486127, + "y": 1.5182564735607207e-8, + "z": 0.006269989150778519, + "w": 0.9999803434219023 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0.000277479600078167, + "y": -3.18993241527229e-13, + "z": 0.7184925395739944 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone003", + "_objFlags": 0, + "_parent": { + "__id__": 171 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 173 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0397140197455883, + "y": -1.19209286886246e-9, + "z": 7.15255721317476e-9 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 1.4018830392883508e-10, + "y": -1.4662893682703937e-13, + "z": -0.0010459420626472054, + "w": 0.9999994530024512 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 1.606440509162768e-8, + "y": -1.4726229276075984e-18, + "z": -0.11985615346346049 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "d5T2sohQVAEa4ljoSzlMKU" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "93hV+qqgFP44pIvuByy6RE" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "0aJTcuk/5M56nEkb+D7tN9" + }, + { + "__type__": "cc.Node", + "_name": "Bone004", + "_objFlags": 0, + "_parent": { + "__id__": 164 + }, + "_children": [ + { + "__id__": 177 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 181 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0710692703723907, + "y": 0.0000118009265861474, + "z": 0.0136896027252078 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.0000017283479103639154, + "y": -0.000001696768662714476, + "z": 0.7049074170330618, + "w": 0.7092993256770451 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -0.0005507418826256091, + "y": 0.00027320859410338513, + "z": 89.64412979694991 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone005", + "_objFlags": 0, + "_parent": { + "__id__": 176 + }, + "_children": [ + { + "__id__": 178 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 180 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0404664427042007, + "y": -4.76837147544984e-9, + "z": 5.9604643443123e-10 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.000002421418716486127, + "y": 1.5182564735607207e-8, + "z": 0.006269989150778519, + "w": 0.9999803434219023 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0.000277479600078167, + "y": -3.18993241527229e-13, + "z": 0.7184925395739944 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone006", + "_objFlags": 0, + "_parent": { + "__id__": 177 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 179 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.039714016020298, + "y": 0, + "z": 7.74860353658369e-9 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 1.4018830392883508e-10, + "y": -1.4662893682703937e-13, + "z": -0.0010459420626472054, + "w": 0.9999994530024512 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 1.606440509162768e-8, + "y": -1.4726229276075984e-18, + "z": -0.11985615346346049 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "6c2sTe+khLGYrsZVSADL4H" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "ecsSU+lvpNf7DhOOeFG7w2" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "6etpava3ZGlovr3HG7SpRo" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "53OGGCuwFNs4KQ0nQRdow5" + }, + { + "__type__": "cc.SkeletalAnimation", + "_name": "grass", + "_objFlags": 0, + "node": { + "__id__": 163 + }, + "_enabled": true, + "playOnLoad": true, + "_clips": [ + { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@73b7f" + } + ], + "_defaultClip": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@73b7f" + }, + "_useBakedAnimation": true, + "_sockets": [], + "_id": "", + "__prefab": { + "__id__": 184 + } + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "8fKHzMP19M76liKGOWy5fp" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "33gYFxG8dO2r8iKjzjEx4z" + }, + { + "__type__": "cc.Node", + "_name": "grass", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 187 + } + ], + "_active": true, + "_components": [ + { + "__id__": 206 + } + ], + "_prefab": { + "__id__": 208 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": -3.151, + "y": 0.706, + "z": -2.905 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.01606605470413201, + "y": 0.10576273729137807, + "z": 0.0511818299419083, + "w": 0.9929433748057723 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1.6, + "y": 1.6, + "z": 1.6 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -2.461, + "y": 12.281, + "z": 5.638 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "RootNode", + "_objFlags": 0, + "_parent": { + "__id__": 186 + }, + "_children": [ + { + "__id__": 188 + }, + { + "__id__": 193 + }, + { + "__id__": 199 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 205 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "grass", + "_objFlags": 0, + "_parent": { + "__id__": 187 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 189 + } + ], + "_prefab": { + "__id__": 192 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.37992816729770207, + "y": 0.5963678291908521, + "z": 0.5963678291908521, + "w": -0.37992816729770207 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 0.614784121513367, + "y": 0.614784121513367, + "z": 0.614784121513367 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -90, + "y": -115.0000056286655, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.SkinnedMeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 188 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "b698e55a-b00b-4987-a8b4-af83cddc59f7" + } + ], + "_visFlags": 0, + "lightmapSettings": { + "__id__": 190 + }, + "_mesh": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@ef5e1" + }, + "_shadowCastingMode": 0, + "_enableMorph": true, + "_skeleton": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@438fe" + }, + "_skinningRoot": { + "__id__": 186 + }, + "_id": "", + "__prefab": { + "__id__": 191 + } + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "b9cuhcVRxPvZTPHcAyE7eS" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "87cW2HzEtNk4+RMW95NbLB" + }, + { + "__type__": "cc.Node", + "_name": "Bone001", + "_objFlags": 0, + "_parent": { + "__id__": 187 + }, + "_children": [ + { + "__id__": 194 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 198 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": -0.0461842827498913, + "y": 0.0000118009265861474, + "z": -0.0284814611077309 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.0000017283479103639154, + "y": -0.000001696768662714476, + "z": 0.7049074170330618, + "w": 0.7092993256770451 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -0.0005507418826256091, + "y": 0.00027320859410338513, + "z": 89.64412979694991 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone002", + "_objFlags": 0, + "_parent": { + "__id__": 193 + }, + "_children": [ + { + "__id__": 195 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 197 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0404664427042007, + "y": -3.57627860658738e-9, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.000002421418716486127, + "y": 1.5182564735607207e-8, + "z": 0.006269989150778519, + "w": 0.9999803434219023 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0.000277479600078167, + "y": -3.18993241527229e-13, + "z": 0.7184925395739944 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone003", + "_objFlags": 0, + "_parent": { + "__id__": 194 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 196 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0397140197455883, + "y": -1.19209286886246e-9, + "z": 7.15255721317476e-9 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 1.4018830392883508e-10, + "y": -1.4662893682703937e-13, + "z": -0.0010459420626472054, + "w": 0.9999994530024512 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 1.606440509162768e-8, + "y": -1.4726229276075984e-18, + "z": -0.11985615346346049 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "5bcVkwfGRPza49BU4T6rqn" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "fcqb+cLDVJ3KNvBTyJYBwm" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "16ssZzbLdO76GQg4Dvdp/y" + }, + { + "__type__": "cc.Node", + "_name": "Bone004", + "_objFlags": 0, + "_parent": { + "__id__": 187 + }, + "_children": [ + { + "__id__": 200 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 204 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0710692703723907, + "y": 0.0000118009265861474, + "z": 0.0136896027252078 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.0000017283479103639154, + "y": -0.000001696768662714476, + "z": 0.7049074170330618, + "w": 0.7092993256770451 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -0.0005507418826256091, + "y": 0.00027320859410338513, + "z": 89.64412979694991 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone005", + "_objFlags": 0, + "_parent": { + "__id__": 199 + }, + "_children": [ + { + "__id__": 201 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 203 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0404664427042007, + "y": -4.76837147544984e-9, + "z": 5.9604643443123e-10 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.000002421418716486127, + "y": 1.5182564735607207e-8, + "z": 0.006269989150778519, + "w": 0.9999803434219023 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0.000277479600078167, + "y": -3.18993241527229e-13, + "z": 0.7184925395739944 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone006", + "_objFlags": 0, + "_parent": { + "__id__": 200 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 202 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.039714016020298, + "y": 0, + "z": 7.74860353658369e-9 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 1.4018830392883508e-10, + "y": -1.4662893682703937e-13, + "z": -0.0010459420626472054, + "w": 0.9999994530024512 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 1.606440509162768e-8, + "y": -1.4726229276075984e-18, + "z": -0.11985615346346049 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "0b/yPLcR1FiZPqyfaG8HBZ" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "0fPapM97RGmYmlB69FuuSF" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "0eRKfLOh9OdLsOOjTosv1c" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "560/1xR41BPKG+lcc5935I" + }, + { + "__type__": "cc.SkeletalAnimation", + "_name": "grass", + "_objFlags": 0, + "node": { + "__id__": 186 + }, + "_enabled": true, + "playOnLoad": true, + "_clips": [ + { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@73b7f" + } + ], + "_defaultClip": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@73b7f" + }, + "_useBakedAnimation": true, + "_sockets": [], + "_id": "", + "__prefab": { + "__id__": 207 + } + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "63dAWSpBBOqo5RjIXi5sEW" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "27mCip0lFNkL+6Dj/Bpwj4" + }, + { + "__type__": "cc.Node", + "_name": "grass", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 210 + } + ], + "_active": true, + "_components": [ + { + "__id__": 229 + } + ], + "_prefab": { + "__id__": 231 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 2.179, + "y": 0.714, + "z": -3.159 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.0002046174412504865, + "y": -0.2725489284000769, + "z": -0.05622568582446521, + "w": 0.9604976376926917 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1.4, + "y": 1.4, + "z": 1.4 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -1.744, + "y": -31.778, + "z": -6.207 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "RootNode", + "_objFlags": 0, + "_parent": { + "__id__": 209 + }, + "_children": [ + { + "__id__": 211 + }, + { + "__id__": 216 + }, + { + "__id__": 222 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 228 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "grass", + "_objFlags": 0, + "_parent": { + "__id__": 210 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 212 + } + ], + "_prefab": { + "__id__": 215 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.37992816729770207, + "y": 0.5963678291908521, + "z": 0.5963678291908521, + "w": -0.37992816729770207 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 0.614784121513367, + "y": 0.614784121513367, + "z": 0.614784121513367 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -90, + "y": -115.0000056286655, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.SkinnedMeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 211 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "b698e55a-b00b-4987-a8b4-af83cddc59f7" + } + ], + "_visFlags": 0, + "lightmapSettings": { + "__id__": 213 + }, + "_mesh": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@ef5e1" + }, + "_shadowCastingMode": 0, + "_enableMorph": true, + "_skeleton": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@438fe" + }, + "_skinningRoot": { + "__id__": 209 + }, + "_id": "", + "__prefab": { + "__id__": 214 + } + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "f3T3OFBBJBYrGbPSQ+k7GJ" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "08LJZ1ezRCiqnszI5cXQTx" + }, + { + "__type__": "cc.Node", + "_name": "Bone001", + "_objFlags": 0, + "_parent": { + "__id__": 210 + }, + "_children": [ + { + "__id__": 217 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 221 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": -0.0461842827498913, + "y": 0.0000118009265861474, + "z": -0.0284814611077309 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.0000017283479103639154, + "y": -0.000001696768662714476, + "z": 0.7049074170330618, + "w": 0.7092993256770451 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -0.0005507418826256091, + "y": 0.00027320859410338513, + "z": 89.64412979694991 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone002", + "_objFlags": 0, + "_parent": { + "__id__": 216 + }, + "_children": [ + { + "__id__": 218 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 220 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0404664427042007, + "y": -3.57627860658738e-9, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.000002421418716486127, + "y": 1.5182564735607207e-8, + "z": 0.006269989150778519, + "w": 0.9999803434219023 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0.000277479600078167, + "y": -3.18993241527229e-13, + "z": 0.7184925395739944 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone003", + "_objFlags": 0, + "_parent": { + "__id__": 217 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 219 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0397140197455883, + "y": -1.19209286886246e-9, + "z": 7.15255721317476e-9 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 1.4018830392883508e-10, + "y": -1.4662893682703937e-13, + "z": -0.0010459420626472054, + "w": 0.9999994530024512 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 1.606440509162768e-8, + "y": -1.4726229276075984e-18, + "z": -0.11985615346346049 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "d8OdalQsZKwLFf2mFuR1VJ" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "ecFy8CTgxCib8Fky/YcoUL" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "c9g0zchT9L8IQmY+99TABR" + }, + { + "__type__": "cc.Node", + "_name": "Bone004", + "_objFlags": 0, + "_parent": { + "__id__": 210 + }, + "_children": [ + { + "__id__": 223 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 227 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0710692703723907, + "y": 0.0000118009265861474, + "z": 0.0136896027252078 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.0000017283479103639154, + "y": -0.000001696768662714476, + "z": 0.7049074170330618, + "w": 0.7092993256770451 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -0.0005507418826256091, + "y": 0.00027320859410338513, + "z": 89.64412979694991 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone005", + "_objFlags": 0, + "_parent": { + "__id__": 222 + }, + "_children": [ + { + "__id__": 224 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 226 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0404664427042007, + "y": -4.76837147544984e-9, + "z": 5.9604643443123e-10 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.000002421418716486127, + "y": 1.5182564735607207e-8, + "z": 0.006269989150778519, + "w": 0.9999803434219023 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0.000277479600078167, + "y": -3.18993241527229e-13, + "z": 0.7184925395739944 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone006", + "_objFlags": 0, + "_parent": { + "__id__": 223 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 225 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.039714016020298, + "y": 0, + "z": 7.74860353658369e-9 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 1.4018830392883508e-10, + "y": -1.4662893682703937e-13, + "z": -0.0010459420626472054, + "w": 0.9999994530024512 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 1.606440509162768e-8, + "y": -1.4726229276075984e-18, + "z": -0.11985615346346049 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "66R8TA3S1NT4HLywjDiP1Q" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "963dgjTmdES7q6KBvCTllJ" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "91+xPZxDtGRp/x7cNrBUhM" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "25mf8t9bhJIo3E0lcGCo1H" + }, + { + "__type__": "cc.SkeletalAnimation", + "_name": "grass", + "_objFlags": 0, + "node": { + "__id__": 209 + }, + "_enabled": true, + "playOnLoad": true, + "_clips": [ + { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@73b7f" + } + ], + "_defaultClip": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@73b7f" + }, + "_useBakedAnimation": true, + "_sockets": [], + "_id": "", + "__prefab": { + "__id__": 230 + } + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "5c8UINxBNN1bAOwYYO6ZIW" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "50aim7sdtB2rmsHB4KRkd5" + }, + { + "__type__": "cc.Node", + "_name": "grass", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 233 + } + ], + "_active": true, + "_components": [ + { + "__id__": 252 + } + ], + "_prefab": { + "__id__": 254 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 5.041, + "y": 0.406, + "z": -3.58 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.026333680128465056, + "y": -0.27127042474669716, + "z": -0.14805365417229147, + "w": 0.9506834433368816 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1.4, + "y": 1.4, + "z": 1.4 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -1.815, + "y": -32.126, + "z": -17.205 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "RootNode", + "_objFlags": 0, + "_parent": { + "__id__": 232 + }, + "_children": [ + { + "__id__": 234 + }, + { + "__id__": 239 + }, + { + "__id__": 245 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 251 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "grass", + "_objFlags": 0, + "_parent": { + "__id__": 233 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 235 + } + ], + "_prefab": { + "__id__": 238 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.37992816729770207, + "y": 0.5963678291908521, + "z": 0.5963678291908521, + "w": -0.37992816729770207 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 0.614784121513367, + "y": 0.614784121513367, + "z": 0.614784121513367 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -90, + "y": -115.0000056286655, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.SkinnedMeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 234 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "b698e55a-b00b-4987-a8b4-af83cddc59f7" + } + ], + "_visFlags": 0, + "lightmapSettings": { + "__id__": 236 + }, + "_mesh": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@ef5e1" + }, + "_shadowCastingMode": 0, + "_enableMorph": true, + "_skeleton": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@438fe" + }, + "_skinningRoot": { + "__id__": 232 + }, + "_id": "", + "__prefab": { + "__id__": 237 + } + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "d0A5LfhGhAfrDnBGJ3JzOe" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "203+J3Vb1LP7KUgkjLvNtX" + }, + { + "__type__": "cc.Node", + "_name": "Bone001", + "_objFlags": 0, + "_parent": { + "__id__": 233 + }, + "_children": [ + { + "__id__": 240 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 244 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": -0.0461842827498913, + "y": 0.0000118009265861474, + "z": -0.0284814611077309 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.0000017283479103639154, + "y": -0.000001696768662714476, + "z": 0.7049074170330618, + "w": 0.7092993256770451 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -0.0005507418826256091, + "y": 0.00027320859410338513, + "z": 89.64412979694991 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone002", + "_objFlags": 0, + "_parent": { + "__id__": 239 + }, + "_children": [ + { + "__id__": 241 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 243 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0404664427042007, + "y": -3.57627860658738e-9, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.000002421418716486127, + "y": 1.5182564735607207e-8, + "z": 0.006269989150778519, + "w": 0.9999803434219023 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0.000277479600078167, + "y": -3.18993241527229e-13, + "z": 0.7184925395739944 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone003", + "_objFlags": 0, + "_parent": { + "__id__": 240 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 242 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0397140197455883, + "y": -1.19209286886246e-9, + "z": 7.15255721317476e-9 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 1.4018830392883508e-10, + "y": -1.4662893682703937e-13, + "z": -0.0010459420626472054, + "w": 0.9999994530024512 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 1.606440509162768e-8, + "y": -1.4726229276075984e-18, + "z": -0.11985615346346049 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "3aJII/zG9KaYapX0uizphW" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "48r+NZR1BD7Y5qEv/ruQsO" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "9eOEdVVahA+rbDiF4AJNNX" + }, + { + "__type__": "cc.Node", + "_name": "Bone004", + "_objFlags": 0, + "_parent": { + "__id__": 233 + }, + "_children": [ + { + "__id__": 246 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 250 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0710692703723907, + "y": 0.0000118009265861474, + "z": 0.0136896027252078 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.0000017283479103639154, + "y": -0.000001696768662714476, + "z": 0.7049074170330618, + "w": 0.7092993256770451 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -0.0005507418826256091, + "y": 0.00027320859410338513, + "z": 89.64412979694991 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone005", + "_objFlags": 0, + "_parent": { + "__id__": 245 + }, + "_children": [ + { + "__id__": 247 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 249 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0404664427042007, + "y": -4.76837147544984e-9, + "z": 5.9604643443123e-10 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.000002421418716486127, + "y": 1.5182564735607207e-8, + "z": 0.006269989150778519, + "w": 0.9999803434219023 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0.000277479600078167, + "y": -3.18993241527229e-13, + "z": 0.7184925395739944 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone006", + "_objFlags": 0, + "_parent": { + "__id__": 246 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 248 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.039714016020298, + "y": 0, + "z": 7.74860353658369e-9 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 1.4018830392883508e-10, + "y": -1.4662893682703937e-13, + "z": -0.0010459420626472054, + "w": 0.9999994530024512 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 1.606440509162768e-8, + "y": -1.4726229276075984e-18, + "z": -0.11985615346346049 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "1fFpy0ihVOYbzhBLRLkL1Y" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "d9iCqzyppAILXebiHSqtDk" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "469eCD0ttKHZacZ3xtfeuD" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "9dXaYb8ytBBb2yYH4yN6Vh" + }, + { + "__type__": "cc.SkeletalAnimation", + "_name": "grass", + "_objFlags": 0, + "node": { + "__id__": 232 + }, + "_enabled": true, + "playOnLoad": true, + "_clips": [ + { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@73b7f" + } + ], + "_defaultClip": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@73b7f" + }, + "_useBakedAnimation": true, + "_sockets": [], + "_id": "", + "__prefab": { + "__id__": 253 + } + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "2dbXeRDsVAWK67o3tGgUEl" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "70DWXrCRRL4pWATtzgi7DN" + }, + { + "__type__": "cc.Node", + "_name": "grass", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 256 + } + ], + "_active": true, + "_components": [ + { + "__id__": 275 + } + ], + "_prefab": { + "__id__": 277 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 4.153, + "y": 0.548, + "z": -3.566 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.01263456693718553, + "y": -0.27225485806840527, + "z": -0.09997674733537244, + "w": 0.9569338064718487 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1.4, + "y": 1.4, + "z": 1.4 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -1.769, + "y": -31.94, + "z": -11.433 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "RootNode", + "_objFlags": 0, + "_parent": { + "__id__": 255 + }, + "_children": [ + { + "__id__": 257 + }, + { + "__id__": 262 + }, + { + "__id__": 268 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 274 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "grass", + "_objFlags": 0, + "_parent": { + "__id__": 256 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 258 + } + ], + "_prefab": { + "__id__": 261 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.37992816729770207, + "y": 0.5963678291908521, + "z": 0.5963678291908521, + "w": -0.37992816729770207 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 0.614784121513367, + "y": 0.614784121513367, + "z": 0.614784121513367 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -90, + "y": -115.0000056286655, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.SkinnedMeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 257 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "b698e55a-b00b-4987-a8b4-af83cddc59f7" + } + ], + "_visFlags": 0, + "lightmapSettings": { + "__id__": 259 + }, + "_mesh": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@ef5e1" + }, + "_shadowCastingMode": 0, + "_enableMorph": true, + "_skeleton": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@438fe" + }, + "_skinningRoot": { + "__id__": 255 + }, + "_id": "", + "__prefab": { + "__id__": 260 + } + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "161SEdWiFO/abXxUI8RkYk" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "80TsYKkUVBAIbPGc2Ao+X4" + }, + { + "__type__": "cc.Node", + "_name": "Bone001", + "_objFlags": 0, + "_parent": { + "__id__": 256 + }, + "_children": [ + { + "__id__": 263 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 267 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": -0.0461842827498913, + "y": 0.0000118009265861474, + "z": -0.0284814611077309 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.0000017283479103639154, + "y": -0.000001696768662714476, + "z": 0.7049074170330618, + "w": 0.7092993256770451 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -0.0005507418826256091, + "y": 0.00027320859410338513, + "z": 89.64412979694991 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone002", + "_objFlags": 0, + "_parent": { + "__id__": 262 + }, + "_children": [ + { + "__id__": 264 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 266 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0404664427042007, + "y": -3.57627860658738e-9, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.000002421418716486127, + "y": 1.5182564735607207e-8, + "z": 0.006269989150778519, + "w": 0.9999803434219023 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0.000277479600078167, + "y": -3.18993241527229e-13, + "z": 0.7184925395739944 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone003", + "_objFlags": 0, + "_parent": { + "__id__": 263 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 265 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0397140197455883, + "y": -1.19209286886246e-9, + "z": 7.15255721317476e-9 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 1.4018830392883508e-10, + "y": -1.4662893682703937e-13, + "z": -0.0010459420626472054, + "w": 0.9999994530024512 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 1.606440509162768e-8, + "y": -1.4726229276075984e-18, + "z": -0.11985615346346049 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "6aDs2ciZhDh6tahiNmO4QO" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "1er+9JvftCj5j548DE5PNk" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "54j/6cneBCF4PpXQIO+ZrT" + }, + { + "__type__": "cc.Node", + "_name": "Bone004", + "_objFlags": 0, + "_parent": { + "__id__": 256 + }, + "_children": [ + { + "__id__": 269 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 273 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0710692703723907, + "y": 0.0000118009265861474, + "z": 0.0136896027252078 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.0000017283479103639154, + "y": -0.000001696768662714476, + "z": 0.7049074170330618, + "w": 0.7092993256770451 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -0.0005507418826256091, + "y": 0.00027320859410338513, + "z": 89.64412979694991 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone005", + "_objFlags": 0, + "_parent": { + "__id__": 268 + }, + "_children": [ + { + "__id__": 270 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 272 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0404664427042007, + "y": -4.76837147544984e-9, + "z": 5.9604643443123e-10 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.000002421418716486127, + "y": 1.5182564735607207e-8, + "z": 0.006269989150778519, + "w": 0.9999803434219023 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0.000277479600078167, + "y": -3.18993241527229e-13, + "z": 0.7184925395739944 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bone006", + "_objFlags": 0, + "_parent": { + "__id__": 269 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 271 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.039714016020298, + "y": 0, + "z": 7.74860353658369e-9 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 1.4018830392883508e-10, + "y": -1.4662893682703937e-13, + "z": -0.0010459420626472054, + "w": 0.9999994530024512 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 1.606440509162768e-8, + "y": -1.4726229276075984e-18, + "z": -0.11985615346346049 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "1eZ45FwjhMoY5AmDd/ApaW" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "7fkJUsKFZMHbutZKiHcKAf" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "c8ON8aNTZH1YV9KZsolNGO" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "fa4L3FVuFMwYhNq67HoU7c" + }, + { + "__type__": "cc.SkeletalAnimation", + "_name": "grass", + "_objFlags": 0, + "node": { + "__id__": 255 + }, + "_enabled": true, + "playOnLoad": true, + "_clips": [ + { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@73b7f" + } + ], + "_defaultClip": { + "__uuid__": "aade09ee-8f9d-413c-a9e8-8c686ea5e160@73b7f" + }, + "_useBakedAnimation": true, + "_sockets": [], + "_id": "", + "__prefab": { + "__id__": 276 + } + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "42733HPMdIEqobiaBVXbRJ" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "7aOtJ3fThN27Zj4fmkg0ut" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "e5Peksu5tL9peMeABb8/JC" + } +] \ No newline at end of file diff --git a/CameraFollowDemo/assets/model/helloWorld/grass/grassGoup.prefab.meta b/CameraFollowDemo/assets/model/helloWorld/grass/grassGoup.prefab.meta new file mode 100644 index 0000000..0145557 --- /dev/null +++ b/CameraFollowDemo/assets/model/helloWorld/grass/grassGoup.prefab.meta @@ -0,0 +1,13 @@ +{ + "ver": "1.1.35", + "importer": "prefab", + "imported": true, + "uuid": "5e4d48c4-0e34-45af-a268-89485197e8bc", + "files": [ + ".json" + ], + "subMetas": {}, + "userData": { + "syncNodeName": "grassGoup" + } +} diff --git a/CameraFollowDemo/assets/model/helloWorld/hdcSky.FBX b/CameraFollowDemo/assets/model/helloWorld/hdcSky.FBX new file mode 100644 index 0000000..e8c5d98 Binary files /dev/null and b/CameraFollowDemo/assets/model/helloWorld/hdcSky.FBX differ diff --git a/CameraFollowDemo/assets/model/helloWorld/hdcSky.FBX.meta b/CameraFollowDemo/assets/model/helloWorld/hdcSky.FBX.meta new file mode 100644 index 0000000..57ad1fd --- /dev/null +++ b/CameraFollowDemo/assets/model/helloWorld/hdcSky.FBX.meta @@ -0,0 +1,110 @@ +{ + "ver": "2.1.10", + "importer": "fbx", + "imported": true, + "uuid": "929e58ce-66a4-4e04-9036-4244456a1220", + "files": [], + "subMetas": { + "f6832": { + "importer": "gltf-mesh", + "uuid": "929e58ce-66a4-4e04-9036-4244456a1220@f6832", + "displayName": "", + "id": "f6832", + "name": "hdcSky.mesh", + "ver": "1.1.0", + "imported": true, + "files": [ + ".bin", + ".json" + ], + "subMetas": {}, + "userData": { + "gltfIndex": 0 + } + }, + "7f40d": { + "importer": "gltf-embeded-image", + "uuid": "929e58ce-66a4-4e04-9036-4244456a1220@7f40d", + "displayName": "", + "id": "7f40d", + "name": "hdcSky.image", + "ver": "1.0.3", + "imported": true, + "files": [ + ".png", + ".json" + ], + "subMetas": {}, + "userData": { + "gltfIndex": 0 + } + }, + "d6067": { + "importer": "texture", + "uuid": "929e58ce-66a4-4e04-9036-4244456a1220@d6067", + "displayName": "", + "id": "d6067", + "name": "hdcSky.texture", + "ver": "1.0.21", + "imported": true, + "files": [ + ".json" + ], + "subMetas": {}, + "userData": { + "wrapModeS": "repeat", + "wrapModeT": "repeat", + "minfilter": "linear", + "magfilter": "linear", + "mipfilter": "none", + "premultiplyAlpha": false, + "anisotropy": 0, + "isUuid": true, + "imageUuidOrDatabaseUri": "929e58ce-66a4-4e04-9036-4244456a1220@7f40d" + } + }, + "bfc57": { + "importer": "gltf-scene", + "uuid": "929e58ce-66a4-4e04-9036-4244456a1220@bfc57", + "displayName": "", + "id": "bfc57", + "name": "hdcSky.prefab", + "ver": "1.0.12", + "imported": true, + "files": [ + ".json" + ], + "subMetas": {}, + "userData": { + "gltfIndex": 0 + } + } + }, + "userData": { + "imageMetas": [ + { + "name": "hdcSky", + "uri": "929e58ce-66a4-4e04-9036-4244456a1220@7f40d" + } + ], + "redirect": "929e58ce-66a4-4e04-9036-4244456a1220@bfc57", + "assetFinder": { + "meshes": [ + "929e58ce-66a4-4e04-9036-4244456a1220@f6832" + ], + "skeletons": [], + "textures": [ + "929e58ce-66a4-4e04-9036-4244456a1220@d6067" + ], + "materials": [ + "482a5162-dad9-446c-b548-8486c7598ee1" + ], + "scenes": [ + "929e58ce-66a4-4e04-9036-4244456a1220@bfc57" + ] + }, + "dumpMaterials": true, + "materialDumpDir": "db://assets/material", + "legacyFbxImporter": true + } +} diff --git a/CameraFollowDemo/assets/model/helloWorld/hdcSky.prefab b/CameraFollowDemo/assets/model/helloWorld/hdcSky.prefab new file mode 100644 index 0000000..c46cc44 --- /dev/null +++ b/CameraFollowDemo/assets/model/helloWorld/hdcSky.prefab @@ -0,0 +1,223 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "asyncLoadAssets": false + }, + { + "__type__": "cc.Node", + "_name": "hdcSky", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 9 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "RootNode", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 3 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 8 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "hdcSky", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 4 + } + ], + "_prefab": { + "__id__": 7 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0.00000556361783310422 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.7071067811865476, + "y": 0, + "z": 0, + "w": 0.7071067811865476 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.57702493667603, + "y": 2.57702493667603, + "z": 2.57702493667603 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -90.00000000000003, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.MeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 3 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "482a5162-dad9-446c-b548-8486c7598ee1" + } + ], + "_visFlags": 0, + "lightmapSettings": { + "__id__": 5 + }, + "_mesh": { + "__uuid__": "929e58ce-66a4-4e04-9036-4244456a1220@f6832" + }, + "_shadowCastingMode": 0, + "_enableMorph": true, + "_id": "", + "__prefab": { + "__id__": 6 + } + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "faUTUMvuxGGLzyygmsEygr" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "537wfATPdERIxNoHyImaal" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "68pBvn4L5LzqzYlxlqIh1Z" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "a0C8RfybZDJbzD2rhAA/j8" + } +] \ No newline at end of file diff --git a/CameraFollowDemo/assets/model/helloWorld/hdcSky.prefab.meta b/CameraFollowDemo/assets/model/helloWorld/hdcSky.prefab.meta new file mode 100644 index 0000000..52fa87a --- /dev/null +++ b/CameraFollowDemo/assets/model/helloWorld/hdcSky.prefab.meta @@ -0,0 +1,13 @@ +{ + "ver": "1.1.35", + "importer": "prefab", + "imported": true, + "uuid": "f0512d7a-e4f6-4209-8dc0-ed1de7149c85", + "files": [ + ".json" + ], + "subMetas": {}, + "userData": { + "syncNodeName": "hdcSky" + } +} diff --git a/CameraFollowDemo/assets/model/helloWorld/islands.FBX b/CameraFollowDemo/assets/model/helloWorld/islands.FBX new file mode 100644 index 0000000..fb0021b Binary files /dev/null and b/CameraFollowDemo/assets/model/helloWorld/islands.FBX differ diff --git a/CameraFollowDemo/assets/model/helloWorld/islands.FBX.meta b/CameraFollowDemo/assets/model/helloWorld/islands.FBX.meta new file mode 100644 index 0000000..a0cfe43 --- /dev/null +++ b/CameraFollowDemo/assets/model/helloWorld/islands.FBX.meta @@ -0,0 +1,366 @@ +{ + "ver": "2.1.10", + "importer": "fbx", + "imported": true, + "uuid": "0ab3142a-6968-4073-95af-026bc3b23623", + "files": [], + "subMetas": { + "71919": { + "importer": "gltf-mesh", + "uuid": "0ab3142a-6968-4073-95af-026bc3b23623@71919", + "displayName": "", + "id": "71919", + "name": "tree1-6.mesh", + "ver": "1.1.0", + "imported": true, + "files": [ + ".bin", + ".json" + ], + "subMetas": {}, + "userData": { + "gltfIndex": 6 + } + }, + "2b0a8": { + "importer": "gltf-mesh", + "uuid": "0ab3142a-6968-4073-95af-026bc3b23623@2b0a8", + "displayName": "", + "id": "2b0a8", + "name": "plane01-0.mesh", + "ver": "1.1.0", + "imported": true, + "files": [ + ".bin", + ".json" + ], + "subMetas": {}, + "userData": { + "gltfIndex": 0 + } + }, + "4a7d8": { + "importer": "gltf-mesh", + "uuid": "0ab3142a-6968-4073-95af-026bc3b23623@4a7d8", + "displayName": "", + "id": "4a7d8", + "name": "stone1-1.mesh", + "ver": "1.1.0", + "imported": true, + "files": [ + ".bin", + ".json" + ], + "subMetas": {}, + "userData": { + "gltfIndex": 1 + } + }, + "0e750": { + "importer": "gltf-mesh", + "uuid": "0ab3142a-6968-4073-95af-026bc3b23623@0e750", + "displayName": "", + "id": "0e750", + "name": "tree1-2.mesh", + "ver": "1.1.0", + "imported": true, + "files": [ + ".bin", + ".json" + ], + "subMetas": {}, + "userData": { + "gltfIndex": 2 + } + }, + "ef86b": { + "importer": "gltf-mesh", + "uuid": "0ab3142a-6968-4073-95af-026bc3b23623@ef86b", + "displayName": "", + "id": "ef86b", + "name": "tree1-3.mesh", + "ver": "1.1.0", + "imported": true, + "files": [ + ".bin", + ".json" + ], + "subMetas": {}, + "userData": { + "gltfIndex": 3 + } + }, + "426f2": { + "importer": "gltf-mesh", + "uuid": "0ab3142a-6968-4073-95af-026bc3b23623@426f2", + "displayName": "", + "id": "426f2", + "name": "tree1-4.mesh", + "ver": "1.1.0", + "imported": true, + "files": [ + ".bin", + ".json" + ], + "subMetas": {}, + "userData": { + "gltfIndex": 4 + } + }, + "754a2": { + "importer": "gltf-mesh", + "uuid": "0ab3142a-6968-4073-95af-026bc3b23623@754a2", + "displayName": "", + "id": "754a2", + "name": "tree1-5.mesh", + "ver": "1.1.0", + "imported": true, + "files": [ + ".bin", + ".json" + ], + "subMetas": {}, + "userData": { + "gltfIndex": 5 + } + }, + "1332c": { + "importer": "gltf-mesh", + "uuid": "0ab3142a-6968-4073-95af-026bc3b23623@1332c", + "displayName": "", + "id": "1332c", + "name": "tree1-7.mesh", + "ver": "1.1.0", + "imported": true, + "files": [ + ".bin", + ".json" + ], + "subMetas": {}, + "userData": { + "gltfIndex": 7 + } + }, + "4d16f": { + "importer": "gltf-mesh", + "uuid": "0ab3142a-6968-4073-95af-026bc3b23623@4d16f", + "displayName": "", + "id": "4d16f", + "name": "tree1-8.mesh", + "ver": "1.1.0", + "imported": true, + "files": [ + ".bin", + ".json" + ], + "subMetas": {}, + "userData": { + "gltfIndex": 8 + } + }, + "efe84": { + "importer": "gltf-mesh", + "uuid": "0ab3142a-6968-4073-95af-026bc3b23623@efe84", + "displayName": "", + "id": "efe84", + "name": "tree1-9.mesh", + "ver": "1.1.0", + "imported": true, + "files": [ + ".bin", + ".json" + ], + "subMetas": {}, + "userData": { + "gltfIndex": 9 + } + }, + "baeab": { + "importer": "gltf-embeded-image", + "uuid": "0ab3142a-6968-4073-95af-026bc3b23623@baeab", + "displayName": "", + "id": "baeab", + "name": "seafloor.jpg.image", + "ver": "1.0.3", + "imported": true, + "files": [ + ".jpg", + ".json" + ], + "subMetas": {}, + "userData": { + "gltfIndex": 0 + } + }, + "eeccb": { + "importer": "gltf-embeded-image", + "uuid": "0ab3142a-6968-4073-95af-026bc3b23623@eeccb", + "displayName": "", + "id": "eeccb", + "name": "stone.jpg.image", + "userData": { + "gltfIndex": 1 + }, + "ver": "1.0.3", + "imported": true, + "files": [ + ".jpg", + ".json" + ], + "subMetas": {} + }, + "3b6f8": { + "importer": "gltf-embeded-image", + "uuid": "0ab3142a-6968-4073-95af-026bc3b23623@3b6f8", + "displayName": "", + "id": "3b6f8", + "name": "tree.png.image", + "userData": { + "gltfIndex": 2 + }, + "ver": "1.0.3", + "imported": true, + "files": [ + ".png", + ".json" + ], + "subMetas": {} + }, + "2df3a": { + "importer": "texture", + "uuid": "0ab3142a-6968-4073-95af-026bc3b23623@2df3a", + "displayName": "", + "id": "2df3a", + "name": "seafloor.texture", + "userData": { + "wrapModeS": "repeat", + "wrapModeT": "repeat", + "minfilter": "linear", + "magfilter": "linear", + "mipfilter": "none", + "premultiplyAlpha": false, + "anisotropy": 0, + "isUuid": true, + "imageUuidOrDatabaseUri": "0ab3142a-6968-4073-95af-026bc3b23623@baeab" + }, + "ver": "1.0.21", + "imported": true, + "files": [ + ".json" + ], + "subMetas": {} + }, + "91a84": { + "importer": "texture", + "uuid": "0ab3142a-6968-4073-95af-026bc3b23623@91a84", + "displayName": "", + "id": "91a84", + "name": "stone.texture", + "userData": { + "wrapModeS": "repeat", + "wrapModeT": "repeat", + "minfilter": "linear", + "magfilter": "linear", + "mipfilter": "none", + "premultiplyAlpha": false, + "anisotropy": 0, + "isUuid": true, + "imageUuidOrDatabaseUri": "0ab3142a-6968-4073-95af-026bc3b23623@eeccb" + }, + "ver": "1.0.21", + "imported": true, + "files": [ + ".json" + ], + "subMetas": {} + }, + "0595c": { + "importer": "texture", + "uuid": "0ab3142a-6968-4073-95af-026bc3b23623@0595c", + "displayName": "", + "id": "0595c", + "name": "tree.texture", + "userData": { + "wrapModeS": "repeat", + "wrapModeT": "repeat", + "minfilter": "linear", + "magfilter": "linear", + "mipfilter": "none", + "premultiplyAlpha": false, + "anisotropy": 0, + "isUuid": true, + "imageUuidOrDatabaseUri": "0ab3142a-6968-4073-95af-026bc3b23623@3b6f8" + }, + "ver": "1.0.21", + "imported": true, + "files": [ + ".json" + ], + "subMetas": {} + }, + "cc8e5": { + "importer": "gltf-scene", + "uuid": "0ab3142a-6968-4073-95af-026bc3b23623@cc8e5", + "displayName": "", + "id": "cc8e5", + "name": "islands.prefab", + "ver": "1.0.12", + "imported": true, + "files": [ + ".json" + ], + "subMetas": {}, + "userData": { + "gltfIndex": 0 + } + } + }, + "userData": { + "imageMetas": [ + { + "name": "seafloor.jpg", + "uri": "0ab3142a-6968-4073-95af-026bc3b23623@baeab" + }, + { + "name": "stone.jpg", + "uri": "0ab3142a-6968-4073-95af-026bc3b23623@eeccb" + }, + { + "name": "tree.png", + "uri": "0ab3142a-6968-4073-95af-026bc3b23623@3b6f8" + } + ], + "redirect": "0ab3142a-6968-4073-95af-026bc3b23623@cc8e5", + "assetFinder": { + "meshes": [ + "0ab3142a-6968-4073-95af-026bc3b23623@2b0a8", + "0ab3142a-6968-4073-95af-026bc3b23623@4a7d8", + "0ab3142a-6968-4073-95af-026bc3b23623@0e750", + "0ab3142a-6968-4073-95af-026bc3b23623@ef86b", + "0ab3142a-6968-4073-95af-026bc3b23623@426f2", + "0ab3142a-6968-4073-95af-026bc3b23623@754a2", + "0ab3142a-6968-4073-95af-026bc3b23623@71919", + "0ab3142a-6968-4073-95af-026bc3b23623@1332c", + "0ab3142a-6968-4073-95af-026bc3b23623@4d16f", + "0ab3142a-6968-4073-95af-026bc3b23623@efe84" + ], + "skeletons": [], + "textures": [ + "0ab3142a-6968-4073-95af-026bc3b23623@2df3a", + "0ab3142a-6968-4073-95af-026bc3b23623@91a84", + "0ab3142a-6968-4073-95af-026bc3b23623@0595c" + ], + "materials": [ + "70d33758-1c1e-424d-b0ab-eac7410559bf", + "a155f93b-7769-4ca4-b75f-b13e52193859", + "7bf9df40-4bc9-4e25-8cb0-9a500f949102" + ], + "scenes": [ + "0ab3142a-6968-4073-95af-026bc3b23623@cc8e5" + ] + }, + "dumpMaterials": true, + "materialDumpDir": "db://assets/material", + "legacyFbxImporter": true + } +} diff --git a/CameraFollowDemo/assets/model/helloWorld/islands.prefab b/CameraFollowDemo/assets/model/helloWorld/islands.prefab new file mode 100644 index 0000000..c3d13b6 --- /dev/null +++ b/CameraFollowDemo/assets/model/helloWorld/islands.prefab @@ -0,0 +1,1178 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "asyncLoadAssets": false + }, + { + "__type__": "cc.Node", + "_name": "islands", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 54 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "RootNode", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 3 + }, + { + "__id__": 8 + }, + { + "__id__": 13 + }, + { + "__id__": 18 + }, + { + "__id__": 23 + }, + { + "__id__": 28 + }, + { + "__id__": 33 + }, + { + "__id__": 38 + }, + { + "__id__": 43 + }, + { + "__id__": 48 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 53 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "plane01", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 4 + } + ], + "_prefab": { + "__id__": 7 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": -2.35098645956703e-40, + "z": 2.1031643981928e-8 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.7071067811865476, + "y": 0, + "z": 0, + "w": 0.7071067811865476 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 4.25968408584595, + "y": 4.25968408584595, + "z": 2.35247683525085 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -90.00000000000003, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.MeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 3 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "70d33758-1c1e-424d-b0ab-eac7410559bf" + } + ], + "_visFlags": 0, + "lightmapSettings": { + "__id__": 5 + }, + "_mesh": { + "__uuid__": "0ab3142a-6968-4073-95af-026bc3b23623@2b0a8" + }, + "_shadowCastingMode": 0, + "_shadowReceivingMode": 1, + "_enableMorph": true, + "_id": "", + "__prefab": { + "__id__": 6 + } + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "ddvMFij+ZIL5lu+/NQX8Nf" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "70dgNwYARPfbvgVcNs+gIQ" + }, + { + "__type__": "cc.Node", + "_name": "stone1", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 9 + } + ], + "_prefab": { + "__id__": 12 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": -1.68451106548309, + "y": 0.804959058761597, + "z": -2.55509376525879 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 8.146034247147303e-8, + "y": 0, + "z": 0, + "w": 0.9999999999999967 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 0.111417099833488, + "y": 0.111417099833488, + "z": 0.111417099833488 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0.000009334667642611398, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.MeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 8 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "a155f93b-7769-4ca4-b75f-b13e52193859" + } + ], + "_visFlags": 0, + "lightmapSettings": { + "__id__": 10 + }, + "_mesh": { + "__uuid__": "0ab3142a-6968-4073-95af-026bc3b23623@4a7d8" + }, + "_shadowCastingMode": 1, + "_shadowReceivingMode": 1, + "_enableMorph": true, + "_id": "", + "__prefab": { + "__id__": 11 + } + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "e3XMjUJKFLH41z39JaWzyB" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "fd517lz3tOuqVWGd5300X6" + }, + { + "__type__": "cc.Node", + "_name": "tree1", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 14 + } + ], + "_prefab": { + "__id__": 17 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 2.69967889785767, + "y": 0.392187118530273, + "z": -3.67192149162292 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.7071067811865476, + "y": 0, + "z": 0, + "w": 0.7071067811865476 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -90.00000000000003, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.MeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 13 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "7bf9df40-4bc9-4e25-8cb0-9a500f949102" + } + ], + "_visFlags": 0, + "lightmapSettings": { + "__id__": 15 + }, + "_mesh": { + "__uuid__": "0ab3142a-6968-4073-95af-026bc3b23623@0e750" + }, + "_shadowCastingMode": 0, + "_shadowReceivingMode": 1, + "_enableMorph": true, + "_id": "", + "__prefab": { + "__id__": 16 + } + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "a5Viy6l3VLDpf6gY5yZF+v" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "1evO3wfhhGVomhJPkvbiM/" + }, + { + "__type__": "cc.Node", + "_name": "tree1(__autogen 3)", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 19 + } + ], + "_prefab": { + "__id__": 22 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 4.34285020828247, + "y": 0.273025780916214, + "z": -4.5796275138855 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.7071067811865476, + "y": 0, + "z": 0, + "w": 0.7071067811865476 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -90.00000000000003, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.MeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 18 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "7bf9df40-4bc9-4e25-8cb0-9a500f949102" + } + ], + "_visFlags": 0, + "lightmapSettings": { + "__id__": 20 + }, + "_mesh": { + "__uuid__": "0ab3142a-6968-4073-95af-026bc3b23623@ef86b" + }, + "_shadowCastingMode": 1, + "_shadowReceivingMode": 1, + "_enableMorph": true, + "_id": "", + "__prefab": { + "__id__": 21 + } + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "e4If/bQrJCsb9D9JopZa2h" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "91DpAWXZ9CFJ+Wk1gnOU27" + }, + { + "__type__": "cc.Node", + "_name": "tree1(__autogen 4)", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 24 + } + ], + "_prefab": { + "__id__": 27 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": -2.78155946731567, + "y": 0.366120487451553, + "z": -5.44366216659546 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.7071067811865476, + "y": 0, + "z": 0, + "w": 0.7071067811865476 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -90.00000000000003, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.MeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 23 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "7bf9df40-4bc9-4e25-8cb0-9a500f949102" + } + ], + "_visFlags": 0, + "lightmapSettings": { + "__id__": 25 + }, + "_mesh": { + "__uuid__": "0ab3142a-6968-4073-95af-026bc3b23623@426f2" + }, + "_shadowCastingMode": 1, + "_shadowReceivingMode": 1, + "_enableMorph": true, + "_id": "", + "__prefab": { + "__id__": 26 + } + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "d7Vkz0NV5Mn4RUce28JVTp" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "03YnQPZo5Nc7TYZfZ1EVIK" + }, + { + "__type__": "cc.Node", + "_name": "tree1(__autogen 5)", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 29 + } + ], + "_prefab": { + "__id__": 32 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": -3.78196001052856, + "y": 0.328564822673798, + "z": -3.62895131111145 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.7071067811865447, + "y": -6.18172403853676e-8, + "z": -6.18172403853676e-8, + "w": 0.7071067811865447 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -89.99999999999999, + "y": -0.000010017912624975451, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.MeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 28 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "7bf9df40-4bc9-4e25-8cb0-9a500f949102" + } + ], + "_visFlags": 0, + "lightmapSettings": { + "__id__": 30 + }, + "_mesh": { + "__uuid__": "0ab3142a-6968-4073-95af-026bc3b23623@754a2" + }, + "_shadowCastingMode": 1, + "_shadowReceivingMode": 1, + "_enableMorph": true, + "_id": "", + "__prefab": { + "__id__": 31 + } + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "3eVATgLQJKDbqOvE33W2uc" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "aehmnp6BdEt5duOREy07Ic" + }, + { + "__type__": "cc.Node", + "_name": "tree1(__autogen 6)", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 34 + } + ], + "_prefab": { + "__id__": 37 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": -6.02857780456543, + "y": 0.0573978498578072, + "z": -3.32550001144409 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.7071067811865476, + "y": 0, + "z": 0, + "w": 0.7071067811865476 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -90.00000000000003, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.MeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 33 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "7bf9df40-4bc9-4e25-8cb0-9a500f949102" + } + ], + "_visFlags": 0, + "lightmapSettings": { + "__id__": 35 + }, + "_mesh": { + "__uuid__": "0ab3142a-6968-4073-95af-026bc3b23623@71919" + }, + "_shadowCastingMode": 1, + "_shadowReceivingMode": 1, + "_enableMorph": true, + "_id": "", + "__prefab": { + "__id__": 36 + } + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "2akU/MgO5Ovo6QcS0c/I7e" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "1dXVprqA1AkpKbrdcroE4U" + }, + { + "__type__": "cc.Node", + "_name": "tree1(__autogen 7)", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 39 + } + ], + "_prefab": { + "__id__": 42 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": -0.547172009944916, + "y": 0.595235526561737, + "z": -3.40697646141052 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.7071067811865476, + "y": 0, + "z": 0, + "w": 0.7071067811865476 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -90.00000000000003, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.MeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 38 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "7bf9df40-4bc9-4e25-8cb0-9a500f949102" + } + ], + "_visFlags": 0, + "lightmapSettings": { + "__id__": 40 + }, + "_mesh": { + "__uuid__": "0ab3142a-6968-4073-95af-026bc3b23623@1332c" + }, + "_shadowCastingMode": 1, + "_shadowReceivingMode": 1, + "_enableMorph": true, + "_id": "", + "__prefab": { + "__id__": 41 + } + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "54xaKIQbtPLK5r21VY0qmM" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "c2n9MRvPxJRbv1PP2mhkZO" + }, + { + "__type__": "cc.Node", + "_name": "tree1(__autogen 8)", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 44 + } + ], + "_prefab": { + "__id__": 47 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": -6.58904409408569, + "y": 0.117208734154701, + "z": -1.02060234546661 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.7071067811865476, + "y": 0, + "z": 0, + "w": 0.7071067811865476 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -90.00000000000003, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.MeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 43 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "7bf9df40-4bc9-4e25-8cb0-9a500f949102" + } + ], + "_visFlags": 0, + "lightmapSettings": { + "__id__": 45 + }, + "_mesh": { + "__uuid__": "0ab3142a-6968-4073-95af-026bc3b23623@4d16f" + }, + "_shadowCastingMode": 1, + "_shadowReceivingMode": 1, + "_enableMorph": true, + "_id": "", + "__prefab": { + "__id__": 46 + } + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "23UFBqszxJ/6Otof04QwYT" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "e7VpTFkQ1Ev40vpNxYe7EG" + }, + { + "__type__": "cc.Node", + "_name": "tree1(__autogen 9)", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 49 + } + ], + "_prefab": { + "__id__": 52 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 5.92053079605103, + "y": 0.1805190294981, + "z": -2.71322011947632 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.7071067811865447, + "y": -6.18172403853676e-8, + "z": -6.18172403853676e-8, + "w": 0.7071067811865447 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -89.99999999999999, + "y": -0.000010017912624975451, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.MeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 48 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "7bf9df40-4bc9-4e25-8cb0-9a500f949102" + } + ], + "_visFlags": 0, + "lightmapSettings": { + "__id__": 50 + }, + "_mesh": { + "__uuid__": "0ab3142a-6968-4073-95af-026bc3b23623@efe84" + }, + "_shadowCastingMode": 1, + "_shadowReceivingMode": 1, + "_enableMorph": true, + "_id": "", + "__prefab": { + "__id__": 51 + } + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "c7PE6gNTdDw45ytwlOEWR3" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "a1wQefYUNInYWhsOmPzInv" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "068WXOAs1HrIDx+RBQ6XoV" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "26LvC5hbxAuJZ9Jl2SB/IV" + } +] \ No newline at end of file diff --git a/CameraFollowDemo/assets/model/helloWorld/islands.prefab.meta b/CameraFollowDemo/assets/model/helloWorld/islands.prefab.meta new file mode 100644 index 0000000..e12c517 --- /dev/null +++ b/CameraFollowDemo/assets/model/helloWorld/islands.prefab.meta @@ -0,0 +1,13 @@ +{ + "ver": "1.1.35", + "importer": "prefab", + "imported": true, + "uuid": "ccc3a755-7d3d-4304-aa3b-ca4792d79d9f", + "files": [ + ".json" + ], + "subMetas": {}, + "userData": { + "syncNodeName": "islands" + } +} diff --git a/CameraFollowDemo/assets/model/helloWorld/seafloor.jpg b/CameraFollowDemo/assets/model/helloWorld/seafloor.jpg new file mode 100644 index 0000000..137b9b4 Binary files /dev/null and b/CameraFollowDemo/assets/model/helloWorld/seafloor.jpg differ diff --git a/CameraFollowDemo/assets/model/helloWorld/seafloor.jpg.meta b/CameraFollowDemo/assets/model/helloWorld/seafloor.jpg.meta new file mode 100644 index 0000000..c6980e3 --- /dev/null +++ b/CameraFollowDemo/assets/model/helloWorld/seafloor.jpg.meta @@ -0,0 +1,41 @@ +{ + "ver": "1.0.22", + "importer": "image", + "imported": true, + "uuid": "4f4c4a34-2d08-4a4d-9169-834d7ce82cee", + "files": [ + ".jpg", + ".json" + ], + "subMetas": { + "6c48a": { + "importer": "texture", + "uuid": "4f4c4a34-2d08-4a4d-9169-834d7ce82cee@6c48a", + "displayName": "seafloor", + "id": "6c48a", + "name": "texture", + "ver": "1.0.21", + "imported": true, + "files": [ + ".json" + ], + "subMetas": {}, + "userData": { + "wrapModeS": "repeat", + "wrapModeT": "repeat", + "minfilter": "linear", + "magfilter": "linear", + "mipfilter": "none", + "premultiplyAlpha": false, + "anisotropy": 0, + "isUuid": true, + "imageUuidOrDatabaseUri": "4f4c4a34-2d08-4a4d-9169-834d7ce82cee" + } + } + }, + "userData": { + "type": "texture", + "redirect": "4f4c4a34-2d08-4a4d-9169-834d7ce82cee@6c48a", + "hasAlpha": false + } +} diff --git a/CameraFollowDemo/assets/model/helloWorld/shield.jpg b/CameraFollowDemo/assets/model/helloWorld/shield.jpg new file mode 100644 index 0000000..3fa717c Binary files /dev/null and b/CameraFollowDemo/assets/model/helloWorld/shield.jpg differ diff --git a/CameraFollowDemo/assets/model/helloWorld/shield.jpg.meta b/CameraFollowDemo/assets/model/helloWorld/shield.jpg.meta new file mode 100644 index 0000000..058a93f --- /dev/null +++ b/CameraFollowDemo/assets/model/helloWorld/shield.jpg.meta @@ -0,0 +1,41 @@ +{ + "ver": "1.0.22", + "importer": "image", + "imported": true, + "uuid": "95e5b02a-e338-423c-bdbb-17486db1d9eb", + "files": [ + ".jpg", + ".json" + ], + "subMetas": { + "6c48a": { + "importer": "texture", + "uuid": "95e5b02a-e338-423c-bdbb-17486db1d9eb@6c48a", + "displayName": "shield", + "id": "6c48a", + "name": "texture", + "ver": "1.0.21", + "imported": true, + "files": [ + ".json" + ], + "subMetas": {}, + "userData": { + "wrapModeS": "repeat", + "wrapModeT": "repeat", + "minfilter": "linear", + "magfilter": "linear", + "mipfilter": "none", + "premultiplyAlpha": false, + "anisotropy": 0, + "isUuid": true, + "imageUuidOrDatabaseUri": "95e5b02a-e338-423c-bdbb-17486db1d9eb" + } + } + }, + "userData": { + "type": "texture", + "redirect": "95e5b02a-e338-423c-bdbb-17486db1d9eb@6c48a", + "hasAlpha": false + } +} diff --git a/CameraFollowDemo/assets/model/helloWorld/sky.png b/CameraFollowDemo/assets/model/helloWorld/sky.png new file mode 100644 index 0000000..4699ff7 Binary files /dev/null and b/CameraFollowDemo/assets/model/helloWorld/sky.png differ diff --git a/CameraFollowDemo/assets/model/helloWorld/sky.png.meta b/CameraFollowDemo/assets/model/helloWorld/sky.png.meta new file mode 100644 index 0000000..f60e7e4 --- /dev/null +++ b/CameraFollowDemo/assets/model/helloWorld/sky.png.meta @@ -0,0 +1,41 @@ +{ + "ver": "1.0.22", + "importer": "image", + "imported": true, + "uuid": "dc4a96c7-321a-48af-81e5-1127ad3ae432", + "files": [ + ".png", + ".json" + ], + "subMetas": { + "6c48a": { + "importer": "texture", + "uuid": "dc4a96c7-321a-48af-81e5-1127ad3ae432@6c48a", + "displayName": "sky", + "id": "6c48a", + "name": "texture", + "ver": "1.0.21", + "imported": true, + "files": [ + ".json" + ], + "subMetas": {}, + "userData": { + "wrapModeS": "repeat", + "wrapModeT": "repeat", + "minfilter": "linear", + "magfilter": "linear", + "mipfilter": "none", + "premultiplyAlpha": false, + "anisotropy": 0, + "isUuid": true, + "imageUuidOrDatabaseUri": "dc4a96c7-321a-48af-81e5-1127ad3ae432" + } + } + }, + "userData": { + "type": "texture", + "redirect": "dc4a96c7-321a-48af-81e5-1127ad3ae432@6c48a", + "hasAlpha": false + } +} diff --git a/CameraFollowDemo/assets/model/helloWorld/soldier.FBX b/CameraFollowDemo/assets/model/helloWorld/soldier.FBX new file mode 100644 index 0000000..d6f52fd Binary files /dev/null and b/CameraFollowDemo/assets/model/helloWorld/soldier.FBX differ diff --git a/CameraFollowDemo/assets/model/helloWorld/soldier.FBX.meta b/CameraFollowDemo/assets/model/helloWorld/soldier.FBX.meta new file mode 100644 index 0000000..0797579 --- /dev/null +++ b/CameraFollowDemo/assets/model/helloWorld/soldier.FBX.meta @@ -0,0 +1,308 @@ +{ + "ver": "2.1.10", + "importer": "fbx", + "imported": true, + "uuid": "e3553cad-2f15-4293-859a-8f43c780f289", + "files": [ + "__original-animation-0.cconb" + ], + "subMetas": { + "18751": { + "importer": "gltf-mesh", + "uuid": "e3553cad-2f15-4293-859a-8f43c780f289@18751", + "displayName": "", + "id": "18751", + "name": "soldier.mesh", + "ver": "1.1.0", + "imported": true, + "files": [ + ".bin", + ".json" + ], + "subMetas": {}, + "userData": { + "gltfIndex": 0 + } + }, + "30732": { + "importer": "gltf-skeleton", + "uuid": "e3553cad-2f15-4293-859a-8f43c780f289@30732", + "displayName": "", + "id": "30732", + "name": "UnnamedSkeleton-0.skeleton", + "ver": "1.0.1", + "imported": true, + "files": [ + ".json" + ], + "subMetas": {}, + "userData": { + "gltfIndex": 0, + "jointsLength": 22 + } + }, + "da6f3": { + "importer": "gltf-mesh", + "uuid": "e3553cad-2f15-4293-859a-8f43c780f289@da6f3", + "displayName": "", + "id": "da6f3", + "name": "shield.mesh", + "ver": "1.1.0", + "imported": true, + "files": [ + ".bin", + ".json" + ], + "subMetas": {}, + "userData": { + "gltfIndex": 1 + } + }, + "4b929": { + "importer": "gltf-mesh", + "uuid": "e3553cad-2f15-4293-859a-8f43c780f289@4b929", + "displayName": "", + "id": "4b929", + "name": "sword.mesh", + "ver": "1.1.0", + "imported": true, + "files": [ + ".bin", + ".json" + ], + "subMetas": {}, + "userData": { + "gltfIndex": 2 + } + }, + "39f7b": { + "importer": "gltf-mesh", + "uuid": "e3553cad-2f15-4293-859a-8f43c780f289@39f7b", + "displayName": "", + "id": "39f7b", + "name": "shield01.mesh", + "userData": { + "gltfIndex": 3 + }, + "ver": "1.1.0", + "imported": true, + "files": [ + ".bin", + ".json" + ], + "subMetas": {} + }, + "73b7f": { + "importer": "gltf-animation", + "uuid": "e3553cad-2f15-4293-859a-8f43c780f289@73b7f", + "displayName": "", + "id": "73b7f", + "name": "Take 001.animation", + "ver": "1.0.16", + "imported": true, + "files": [ + ".cconb" + ], + "subMetas": {}, + "userData": { + "events": [], + "gltfIndex": 0, + "sample": 30, + "span": { + "from": 0.03333333333333333, + "to": 1.3333333730697632 + }, + "wrapMode": 2, + "speed": 1 + } + }, + "f1394": { + "importer": "gltf-skeleton", + "uuid": "e3553cad-2f15-4293-859a-8f43c780f289@f1394", + "displayName": "", + "id": "f1394", + "name": "UnnamedSkeleton-1.skeleton", + "ver": "1.0.1", + "imported": true, + "files": [ + ".json" + ], + "subMetas": {}, + "userData": { + "gltfIndex": 1, + "jointsLength": 1 + } + }, + "75ee4": { + "importer": "gltf-skeleton", + "uuid": "e3553cad-2f15-4293-859a-8f43c780f289@75ee4", + "displayName": "", + "id": "75ee4", + "name": "UnnamedSkeleton-2.skeleton", + "ver": "1.0.1", + "imported": true, + "files": [ + ".json" + ], + "subMetas": {}, + "userData": { + "gltfIndex": 2, + "jointsLength": 1 + } + }, + "a72ab": { + "importer": "gltf-skeleton", + "uuid": "e3553cad-2f15-4293-859a-8f43c780f289@a72ab", + "displayName": "", + "id": "a72ab", + "name": "UnnamedSkeleton-3.skeleton", + "ver": "1.0.1", + "imported": true, + "files": [ + ".json" + ], + "subMetas": {}, + "userData": { + "gltfIndex": 3, + "jointsLength": 1 + } + }, + "e94f1": { + "importer": "gltf-embeded-image", + "uuid": "e3553cad-2f15-4293-859a-8f43c780f289@e94f1", + "displayName": "", + "id": "e94f1", + "name": "shield.jpg.image", + "userData": { + "gltfIndex": 1 + }, + "ver": "1.0.3", + "imported": true, + "files": [ + ".jpg", + ".json" + ], + "subMetas": {} + }, + "f3caa": { + "importer": "texture", + "uuid": "e3553cad-2f15-4293-859a-8f43c780f289@f3caa", + "displayName": "", + "id": "f3caa", + "name": "soldier.texture", + "userData": { + "wrapModeS": "repeat", + "wrapModeT": "repeat", + "minfilter": "linear", + "magfilter": "linear", + "mipfilter": "none", + "premultiplyAlpha": false, + "anisotropy": 0, + "isUuid": false, + "imageUuidOrDatabaseUri": "db://assets/model/helloWorld/soldier.png" + }, + "ver": "1.0.21", + "imported": true, + "files": [ + ".json" + ], + "subMetas": {} + }, + "a2be1": { + "importer": "texture", + "uuid": "e3553cad-2f15-4293-859a-8f43c780f289@a2be1", + "displayName": "", + "id": "a2be1", + "name": "shield.texture", + "userData": { + "wrapModeS": "repeat", + "wrapModeT": "repeat", + "minfilter": "linear", + "magfilter": "linear", + "mipfilter": "none", + "premultiplyAlpha": false, + "anisotropy": 0, + "isUuid": true, + "imageUuidOrDatabaseUri": "e3553cad-2f15-4293-859a-8f43c780f289@e94f1" + }, + "ver": "1.0.21", + "imported": true, + "files": [ + ".json" + ], + "subMetas": {} + }, + "d252c": { + "importer": "gltf-scene", + "uuid": "e3553cad-2f15-4293-859a-8f43c780f289@d252c", + "displayName": "", + "id": "d252c", + "name": "soldier.prefab", + "ver": "1.0.12", + "imported": true, + "files": [ + ".json" + ], + "subMetas": {}, + "userData": { + "gltfIndex": 0 + } + } + }, + "userData": { + "imageMetas": [ + { + "name": "soldier", + "uri": "db://assets/model/helloWorld/soldier.png" + }, + { + "name": "shield.jpg", + "uri": "e3553cad-2f15-4293-859a-8f43c780f289@e94f1" + } + ], + "redirect": "e3553cad-2f15-4293-859a-8f43c780f289@d252c", + "assetFinder": { + "meshes": [ + "e3553cad-2f15-4293-859a-8f43c780f289@18751", + "e3553cad-2f15-4293-859a-8f43c780f289@da6f3", + "e3553cad-2f15-4293-859a-8f43c780f289@4b929", + "e3553cad-2f15-4293-859a-8f43c780f289@39f7b" + ], + "skeletons": [ + "e3553cad-2f15-4293-859a-8f43c780f289@30732", + "e3553cad-2f15-4293-859a-8f43c780f289@f1394", + "e3553cad-2f15-4293-859a-8f43c780f289@75ee4", + "e3553cad-2f15-4293-859a-8f43c780f289@a72ab" + ], + "textures": [ + "e3553cad-2f15-4293-859a-8f43c780f289@f3caa", + "e3553cad-2f15-4293-859a-8f43c780f289@a2be1" + ], + "materials": [ + "8a58ddec-f437-40b9-8ec0-1fc87de97fb5", + "8e047178-f61c-4322-a2f6-d1adb28b6ae2" + ], + "scenes": [ + "e3553cad-2f15-4293-859a-8f43c780f289@d252c" + ] + }, + "dumpMaterials": true, + "materialDumpDir": "db://assets/material", + "animationImportSettings": [ + { + "name": "Take 001", + "duration": 1.3333333730697632, + "fps": 30, + "splits": [ + { + "name": "Take 001", + "from": 0.03333333333333333, + "to": 1.3333333730697632, + "wrapMode": 2 + } + ] + } + ], + "legacyFbxImporter": true + } +} diff --git a/CameraFollowDemo/assets/model/helloWorld/soldier.png b/CameraFollowDemo/assets/model/helloWorld/soldier.png new file mode 100644 index 0000000..00ce191 Binary files /dev/null and b/CameraFollowDemo/assets/model/helloWorld/soldier.png differ diff --git a/CameraFollowDemo/assets/model/helloWorld/soldier.png.meta b/CameraFollowDemo/assets/model/helloWorld/soldier.png.meta new file mode 100644 index 0000000..40c1de1 --- /dev/null +++ b/CameraFollowDemo/assets/model/helloWorld/soldier.png.meta @@ -0,0 +1,41 @@ +{ + "ver": "1.0.22", + "importer": "image", + "imported": true, + "uuid": "6f891a7b-5a08-48e6-9841-ddb364ac86b1", + "files": [ + ".png", + ".json" + ], + "subMetas": { + "6c48a": { + "importer": "texture", + "uuid": "6f891a7b-5a08-48e6-9841-ddb364ac86b1@6c48a", + "displayName": "soldier", + "id": "6c48a", + "name": "texture", + "ver": "1.0.21", + "imported": true, + "files": [ + ".json" + ], + "subMetas": {}, + "userData": { + "wrapModeS": "repeat", + "wrapModeT": "repeat", + "minfilter": "linear", + "magfilter": "linear", + "mipfilter": "none", + "premultiplyAlpha": false, + "anisotropy": 0, + "isUuid": true, + "imageUuidOrDatabaseUri": "6f891a7b-5a08-48e6-9841-ddb364ac86b1" + } + } + }, + "userData": { + "type": "texture", + "redirect": "6f891a7b-5a08-48e6-9841-ddb364ac86b1@6c48a", + "hasAlpha": true + } +} diff --git a/CameraFollowDemo/assets/model/helloWorld/soldier.prefab b/CameraFollowDemo/assets/model/helloWorld/soldier.prefab new file mode 100644 index 0000000..4355404 --- /dev/null +++ b/CameraFollowDemo/assets/model/helloWorld/soldier.prefab @@ -0,0 +1,2132 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "asyncLoadAssets": false + }, + { + "__type__": "cc.Node", + "_name": "soldier", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + } + ], + "_active": true, + "_components": [ + { + "__id__": 80 + } + ], + "_prefab": { + "__id__": 82 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0.956, + "z": 1.402 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "RootNode", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 3 + }, + { + "__id__": 8 + }, + { + "__id__": 64 + }, + { + "__id__": 69 + }, + { + "__id__": 74 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 79 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "soldier", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 4 + } + ], + "_prefab": { + "__id__": 7 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.9999999999999953, + "y": 0, + "z": 0, + "w": -9.735359185469814e-8 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 87.7489852905273, + "y": 87.7489852905273, + "z": 87.7489852905273 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -179.99998884410013, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.SkinnedMeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 3 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "8a58ddec-f437-40b9-8ec0-1fc87de97fb5" + } + ], + "_visFlags": 0, + "lightmapSettings": { + "__id__": 5 + }, + "_mesh": { + "__uuid__": "e3553cad-2f15-4293-859a-8f43c780f289@18751" + }, + "_shadowCastingMode": 1, + "_shadowReceivingMode": 1, + "_enableMorph": true, + "_skeleton": { + "__uuid__": "e3553cad-2f15-4293-859a-8f43c780f289@30732" + }, + "_skinningRoot": { + "__id__": 1 + }, + "_id": "", + "__prefab": { + "__id__": 6 + } + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "78XZsd31xPjIsSP2888FcN" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "824q3ldSpHoYl9xi6zWeg4" + }, + { + "__type__": "cc.Node", + "_name": "Bip001", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [ + { + "__id__": 9 + }, + { + "__id__": 11 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 63 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0.738336980342865, + "z": -3.74271143591121e-12 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.5000003576277411, + "y": -0.4999996423720031, + "z": -0.4999996423720031, + "w": 0.5000003576277411 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -90, + "y": -89.99991803772988, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 Footsteps", + "_objFlags": 0, + "_parent": { + "__id__": 8 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 10 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": -5.16987871290063e-28, + "y": 0, + "z": -0.734457075595856 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -6.921034890422563e-34, + "y": 6.921044533149828e-34, + "z": 0.7071063043492202, + "w": 0.7071072580235535 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": -1.1216009582263186e-31, + "z": 90 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "24sP2WouNOyq9Pp+iqRgiX" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 Pelvis", + "_objFlags": 0, + "_parent": { + "__id__": 8 + }, + "_children": [ + { + "__id__": 12 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 62 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.4999999925491744, + "y": -0.4999999925491744, + "z": -0.4999993070957696, + "w": 0.5000007078049007 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -89.9999197452773, + "y": -89.9999197452773, + "z": -0.0000017074910412130916 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 Spine", + "_objFlags": 0, + "_parent": { + "__id__": 11 + }, + "_children": [ + { + "__id__": 13 + }, + { + "__id__": 23 + }, + { + "__id__": 33 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 61 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0765029862523079, + "y": -0.000119566058856435, + "z": 1.06260117149759e-7 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.000002080475910607327, + "y": -6.936759723456761e-7, + "z": 0.0003981589901667568, + "w": 0.9999999207323014 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -0.00023837338537102568, + "y": -0.00007939450691674313, + "z": 0.045625660794268635 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 L Thigh", + "_objFlags": 0, + "_parent": { + "__id__": 12 + }, + "_children": [ + { + "__id__": 14 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 22 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": -0.0765029117465019, + "y": 0.000180334449396469, + "z": 0.0665242150425911 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.015412850192755845, + "y": 0.9969698713847834, + "z": 0.002043751751963479, + "w": -0.07621904406852757 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -0.098918034361683, + "y": -171.25793904676914, + "z": -1.7789668366715101 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 L Calf", + "_objFlags": 0, + "_parent": { + "__id__": 13 + }, + "_children": [ + { + "__id__": 15 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 21 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.368020862340927, + "y": -2.38418573772492e-9, + "z": 1.90734859017994e-8 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -3.77253945323161e-21, + "y": -4.658679694134547e-18, + "z": -0.0008097870399876981, + "w": 0.999999672122421 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -8.646032309262241e-19, + "y": -5.338462443351186e-16, + "z": -0.09279476953314847 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 L Foot", + "_objFlags": 0, + "_parent": { + "__id__": 14 + }, + "_children": [ + { + "__id__": 16 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 20 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.29802131652832, + "y": -2.38418573772492e-9, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.0020737143220202685, + "y": -0.07621822672483194, + "z": 0.016616994877612996, + "w": 0.9969505289155877 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0.3822464844159605, + "y": -8.749946017824339, + "z": 1.8805865416881686 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 L Toe0", + "_objFlags": 0, + "_parent": { + "__id__": 15 + }, + "_children": [ + { + "__id__": 17 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 19 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0765028968453407, + "y": 0.0984558463096619, + "z": 1.90734859017994e-8 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -1.5454308319985125e-8, + "y": -1.5454308319985125e-8, + "z": 0.7071067811865472, + "w": 0.7071067811865472 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": -0.0000025044778683729224, + "z": 90 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 L Toe0Nub", + "_objFlags": 0, + "_parent": { + "__id__": 16 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 18 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.00997863244265318, + "y": -2.98023217215615e-10, + "z": 3.55271359939116e-17 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 9.55341250274695e-16, + "y": -2.4399608215727e-23, + "z": 1, + "w": 1.83758927467374e-15 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": -1, + "y": -1, + "z": -1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 180, + "y": -179.9999999999999, + "z": 2.1057221983462293e-13 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "b7ARhVJWFJP4yiboWbM1Xs" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "b7IX4wc+BII5SOxaDKm4bu" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "71/rP0sWxM1bfHuNwls2lv" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "71+6ovA8dDUowhlyNGBIbM" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "4aENadJ59Io4SS6BMn9Aw4" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 R Thigh", + "_objFlags": 0, + "_parent": { + "__id__": 12 + }, + "_children": [ + { + "__id__": 24 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 32 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": -0.0765029117465019, + "y": 0.000180703471414745, + "z": -0.0665242150425911 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.0154126518850906, + "y": 0.9969698755273314, + "z": -0.0020409899233692465, + "w": 0.07621910398987286 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0.09860398393799301, + "y": 171.25792731952373, + "z": -1.7789200579558455 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 R Calf", + "_objFlags": 0, + "_parent": { + "__id__": 23 + }, + "_children": [ + { + "__id__": 25 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 31 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.36802089214325, + "y": 0, + "z": -3.55271359939116e-17 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 2.226103102352033e-19, + "y": 7.125063520427799e-18, + "z": -0.0008097898921612967, + "w": 0.9999996721201113 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 2.6170459347986135e-17, + "y": 8.164935972515574e-16, + "z": -0.09279509636827488 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 R Foot", + "_objFlags": 0, + "_parent": { + "__id__": 24 + }, + "_children": [ + { + "__id__": 26 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 30 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.29802131652832, + "y": 0, + "z": -3.81469718035987e-8 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.002073778117879438, + "y": 0.07621821928385913, + "z": 0.016617013506159614, + "w": 0.9969505290412618 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -0.38225392566993516, + "y": 8.749945293799216, + "z": 1.8805881155171484 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 R Toe0", + "_objFlags": 0, + "_parent": { + "__id__": 25 + }, + "_children": [ + { + "__id__": 27 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 29 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0765028968453407, + "y": 0.0984558537602425, + "z": 1.90734859017994e-8 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -1.5454308319985125e-8, + "y": -1.5454308319985125e-8, + "z": 0.7071067811865472, + "w": 0.7071067811865472 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": -0.0000025044778683729224, + "z": 90 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 R Toe0Nub", + "_objFlags": 0, + "_parent": { + "__id__": 26 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 28 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.00997863244265318, + "y": -2.98023217215615e-10, + "z": 7.10542719878232e-17 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -2.35364776340013e-23, + "y": 9.55341356153813e-16, + "z": -1.77635726291672e-15, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -2.6970814715996306e-21, + "y": 1.0947405540383584e-13, + "z": -2.0355554814507762e-13 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "77BI3YwgNJqKMpf0rJhZ9s" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "26R5ll6SNGP5ArlFhrFOzH" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "cdWn1utjJOUaNdTLXxb/CR" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "8a4oYAyD9MkZi9aL5G15gW" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "baRkxlpMJMup2UzoK3llZt" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 Spine1", + "_objFlags": 0, + "_parent": { + "__id__": 12 + }, + "_children": [ + { + "__id__": 34 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 60 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.150201484560966, + "y": -0.000119601711048745, + "z": -3.31727090241429e-10 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -3.01176726787145e-14, + "y": -1.39586728368323e-23, + "z": -1.0842021724855e-19, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -3.451231066493619e-12, + "y": -1.599546082682973e-21, + "z": -1.2424041724466812e-17 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 Neck", + "_objFlags": 0, + "_parent": { + "__id__": 33 + }, + "_children": [ + { + "__id__": 35 + }, + { + "__id__": 45 + }, + { + "__id__": 55 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 59 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.15020164847374, + "y": -0.0000435724105045665, + "z": -1.20852522433879e-10 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -3.01176726787145e-14, + "y": -9.0989867380833e-23, + "z": -2.74040313253867e-36, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -3.451231066493619e-12, + "y": -1.0426670758753618e-20, + "z": -1.0276926252606202e-41 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 L Clavicle", + "_objFlags": 0, + "_parent": { + "__id__": 34 + }, + "_children": [ + { + "__id__": 36 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 44 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0.0000435078145528678, + "z": 0.0232834853231907 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.6087613827170933, + "y": -0.0002434881366867595, + "z": 0.7933532758994495, + "w": 0.0003150325566206266 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 179.9558877717535, + "y": -104.99999523006848, + "z": 0.01165464185401893 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 L UpperArm", + "_objFlags": 0, + "_parent": { + "__id__": 35 + }, + "_children": [ + { + "__id__": 37 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 43 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.272405058145523, + "y": 4.54747340722069e-15, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.004462069723208538, + "y": 0.4381802273458216, + "z": -0.0019434620153348766, + "w": 0.8988739629404916 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0.5572016837940187, + "y": 51.97620557313351, + "z": 0.02386521946895269 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 L Forearm", + "_objFlags": 0, + "_parent": { + "__id__": 36 + }, + "_children": [ + { + "__id__": 38 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 42 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.263291478157043, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -2.7197715504795845e-20, + "y": -3.0893820368327117e-17, + "z": -0.0008803606294924629, + "w": 0.9999996124825059 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -6.233264281423144e-18, + "y": -3.5401778996822195e-15, + "z": -0.10088191006996569 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 L Hand", + "_objFlags": 0, + "_parent": { + "__id__": 37 + }, + "_children": [ + { + "__id__": 39 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 41 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.199572831392288, + "y": -5.9604643443123e-10, + "z": 1.42108543975646e-16 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.7068252124052271, + "y": 1.0458620867947887e-8, + "z": 1.0614867442646885e-8, + "w": 0.7073882378922519 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -89.95437890588059, + "y": 0.0000017075473071153707, + "z": 1.3340228971442967e-8 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "sword01", + "_objFlags": 0, + "_parent": { + "__id__": 38 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 40 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0919111594557762, + "y": 0.0340489186346531, + "z": -0.14926840364933 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.6409670678902519, + "y": -0.3070256396863465, + "z": -0.5278458569202463, + "w": -0.4650540030872693 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -112.37885078724646, + "y": 75.2002383569922, + "z": 5.587571211625747 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "98Mxm4C+NAIp1/ms1CXDWg" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "7cWlWOkFtKX6ILXuZfhYqO" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "503RTkgyFOwZRj7QxbXFGT" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "66qUHYCHZNMoAvIMM8jTZn" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "c67UVUfoFCNLAcx8dX7SW1" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 R Clavicle", + "_objFlags": 0, + "_parent": { + "__id__": 34 + }, + "_children": [ + { + "__id__": 46 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 54 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0.0000436370064562652, + "z": -0.0232834853231907 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.6087613827171046, + "y": 0.00024128768333211222, + "z": 0.793353275899464, + "w": 0.0003167210153793466 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -179.95597003338875, + "y": 104.99999512047448, + "z": 0.011961643569376679 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 R UpperArm", + "_objFlags": 0, + "_parent": { + "__id__": 45 + }, + "_children": [ + { + "__id__": 47 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 53 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.272405058145523, + "y": 6.82120985672115e-14, + "z": -1.42108543975646e-16 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.030114175418424236, + "y": -0.43755956999841955, + "z": 0.05059855375302801, + "w": 0.897259463867486 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -0.5631334715243025, + "y": -51.96038786477057, + "z": 6.727854372934277 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 R Forearm", + "_objFlags": 0, + "_parent": { + "__id__": 46 + }, + "_children": [ + { + "__id__": 48 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 52 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.263291418552399, + "y": 0, + "z": -7.62939436071974e-8 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -8.302567498559346e-18, + "y": -5.588016764292516e-17, + "z": -0.13176086831298384, + "w": 0.9912815309393233 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -1.8510999406615195e-15, + "y": -6.705762043264369e-15, + "z": -15.14271605062808 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 R Hand", + "_objFlags": 0, + "_parent": { + "__id__": 47 + }, + "_children": [ + { + "__id__": 49 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 51 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.199572905898094, + "y": 8.88178399847791e-18, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.7068252124052272, + "y": -1.9327187937127104e-17, + "z": 1.9311804031753923e-17, + "w": 0.707388237892252 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 89.95437890588059, + "y": -3.1308585900006548e-15, + "z": -7.956237644289779e-23 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "shield01", + "_objFlags": 0, + "_parent": { + "__id__": 48 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 50 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.124533005058765, + "y": -0.00692871073260903, + "z": 0.0576667860150337 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.5417342069004817, + "y": -0.1379658103002438, + "z": 0.11668003843623054, + "w": 0.8208990515846776 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 67.2841187503732, + "y": -20.685866498064005, + "z": 2.411917394086867 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "4f4kzbhYBIMIVjz0nZTcvw" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "19JEI2tAtAo5mcAZ7XSRWH" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "5eAc4VAlRExZ6nABKN5Ihq" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "a72KzY4dJDrb/Ifgjl7CSF" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "9fRB6KFOpAz6pb5W8NAqZg" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 Head", + "_objFlags": 0, + "_parent": { + "__id__": 34 + }, + "_children": [ + { + "__id__": 56 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 58 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.0547203049063683, + "y": -1.38777874976217e-19, + "z": 2.71050537062924e-22 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -7.265599787883251e-14, + "y": 1.1042733174299354e-9, + "z": -0.0003988305609355657, + "w": 0.9999999204670887 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 4.214242912539149e-11, + "y": 1.2654042790710837e-7, + "z": -0.04570261697650697 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bip001 HeadNub", + "_objFlags": 0, + "_parent": { + "__id__": 55 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 57 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.475234657526016, + "y": -1.45519149031062e-13, + "z": 2.99510855318999e-20 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -4.09752188234268e-20, + "y": 3.5879314498657e-21, + "z": 1.47015827086174e-40, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -4.6954142064147255e-18, + "y": 4.1114665851911787e-19, + "z": -5.14740158672216e-44 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "ebvw49UjBMKoIvQOBhsyUF" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "4ckJuubwNG3KpsMgkuxo12" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "de+U9IqPVD+qUUY0y7H/86" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "78+5xpqyNL2aHMIBr4YHvg" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "deedfocu1E0amfQjzHnnD8" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "9brOPlFAxPnLhkrpP6KbLQ" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "15XJ/3651AFKLyr6XRj3d7" + }, + { + "__type__": "cc.Node", + "_name": "shield", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 65 + } + ], + "_prefab": { + "__id__": 68 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.9999999999999878, + "y": 0, + "z": 0, + "w": -1.569582366300871e-7 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 87.7489852905273, + "y": 87.7489852905273, + "z": 87.7489852905273 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -179.99998201391097, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.SkinnedMeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 64 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "8a58ddec-f437-40b9-8ec0-1fc87de97fb5" + } + ], + "_visFlags": 0, + "lightmapSettings": { + "__id__": 66 + }, + "_mesh": { + "__uuid__": "e3553cad-2f15-4293-859a-8f43c780f289@da6f3" + }, + "_shadowCastingMode": 0, + "_shadowReceivingMode": 1, + "_enableMorph": true, + "_skeleton": { + "__uuid__": "e3553cad-2f15-4293-859a-8f43c780f289@f1394" + }, + "_skinningRoot": { + "__id__": 1 + }, + "_id": "", + "__prefab": { + "__id__": 67 + } + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "ffoVYmt2NOmIBz5DHpacF8" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "2fgzyRcBxNmZKzBdJpnT0Q" + }, + { + "__type__": "cc.Node", + "_name": "sword", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 70 + } + ], + "_prefab": { + "__id__": 73 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.9999999999999878, + "y": 0, + "z": 0, + "w": -1.569582366300871e-7 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 87.7489852905273, + "y": 87.7489852905273, + "z": 87.7489852905273 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -179.99998201391097, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.SkinnedMeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 69 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "8a58ddec-f437-40b9-8ec0-1fc87de97fb5" + } + ], + "_visFlags": 0, + "lightmapSettings": { + "__id__": 71 + }, + "_mesh": { + "__uuid__": "e3553cad-2f15-4293-859a-8f43c780f289@4b929" + }, + "_shadowCastingMode": 0, + "_shadowReceivingMode": 1, + "_enableMorph": true, + "_skeleton": { + "__uuid__": "e3553cad-2f15-4293-859a-8f43c780f289@75ee4" + }, + "_skinningRoot": { + "__id__": 1 + }, + "_id": "", + "__prefab": { + "__id__": 72 + } + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "9aCVBuMeZPv6so1VxT6c40" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "d0xEUY/HZBVZJ0EMEz3doQ" + }, + { + "__type__": "cc.Node", + "_name": "shield01", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 75 + } + ], + "_prefab": { + "__id__": 78 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": -0.00499999988824129, + "y": 0, + "z": 0.00499999988824129 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0.9999999999999878, + "y": 0, + "z": 0, + "w": -1.569582366300871e-7 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 87.7489852905273, + "y": 87.7489852905273, + "z": 87.7489852905273 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -179.99998201391097, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.SkinnedMeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 74 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "8e047178-f61c-4322-a2f6-d1adb28b6ae2" + } + ], + "_visFlags": 0, + "lightmapSettings": { + "__id__": 76 + }, + "_mesh": { + "__uuid__": "e3553cad-2f15-4293-859a-8f43c780f289@39f7b" + }, + "_shadowCastingMode": 0, + "_shadowReceivingMode": 1, + "_enableMorph": true, + "_skeleton": { + "__uuid__": "e3553cad-2f15-4293-859a-8f43c780f289@a72ab" + }, + "_skinningRoot": { + "__id__": 1 + }, + "_id": "", + "__prefab": { + "__id__": 77 + } + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "ca1srfPsJJgKKJww9GO/JE" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "464KPea2NOibwROP5moUvA" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "a5uiqiY3JH2IVaNOBBe7fQ" + }, + { + "__type__": "cc.SkeletalAnimation", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "playOnLoad": true, + "_clips": [ + { + "__uuid__": "e3553cad-2f15-4293-859a-8f43c780f289@73b7f" + } + ], + "_defaultClip": { + "__uuid__": "e3553cad-2f15-4293-859a-8f43c780f289@73b7f" + }, + "_useBakedAnimation": true, + "_sockets": [], + "_id": "", + "__prefab": { + "__id__": 81 + } + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "04W3Kzvb9BZbZUGFZzfzi5" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "6dMvPN2t1B66O9Zc3HG8dr" + } +] \ No newline at end of file diff --git a/CameraFollowDemo/assets/model/helloWorld/soldier.prefab.meta b/CameraFollowDemo/assets/model/helloWorld/soldier.prefab.meta new file mode 100644 index 0000000..8465d54 --- /dev/null +++ b/CameraFollowDemo/assets/model/helloWorld/soldier.prefab.meta @@ -0,0 +1,13 @@ +{ + "ver": "1.1.35", + "importer": "prefab", + "imported": true, + "uuid": "cfc53c4e-7956-482b-aebc-3fb1dcd36eef", + "files": [ + ".json" + ], + "subMetas": {}, + "userData": { + "syncNodeName": "soldier" + } +} diff --git a/CameraFollowDemo/assets/model/helloWorld/stone.jpg b/CameraFollowDemo/assets/model/helloWorld/stone.jpg new file mode 100644 index 0000000..61dd429 Binary files /dev/null and b/CameraFollowDemo/assets/model/helloWorld/stone.jpg differ diff --git a/CameraFollowDemo/assets/model/helloWorld/stone.jpg.meta b/CameraFollowDemo/assets/model/helloWorld/stone.jpg.meta new file mode 100644 index 0000000..271d192 --- /dev/null +++ b/CameraFollowDemo/assets/model/helloWorld/stone.jpg.meta @@ -0,0 +1,41 @@ +{ + "ver": "1.0.22", + "importer": "image", + "imported": true, + "uuid": "0718d996-39bf-4ab4-bb63-496666fef467", + "files": [ + ".jpg", + ".json" + ], + "subMetas": { + "6c48a": { + "importer": "texture", + "uuid": "0718d996-39bf-4ab4-bb63-496666fef467@6c48a", + "displayName": "stone", + "id": "6c48a", + "name": "texture", + "ver": "1.0.21", + "imported": true, + "files": [ + ".json" + ], + "subMetas": {}, + "userData": { + "wrapModeS": "repeat", + "wrapModeT": "repeat", + "minfilter": "linear", + "magfilter": "linear", + "mipfilter": "none", + "premultiplyAlpha": false, + "anisotropy": 0, + "isUuid": true, + "imageUuidOrDatabaseUri": "0718d996-39bf-4ab4-bb63-496666fef467" + } + } + }, + "userData": { + "type": "texture", + "redirect": "0718d996-39bf-4ab4-bb63-496666fef467@6c48a", + "hasAlpha": false + } +} diff --git a/CameraFollowDemo/assets/model/helloWorld/tree.png b/CameraFollowDemo/assets/model/helloWorld/tree.png new file mode 100644 index 0000000..3692d92 Binary files /dev/null and b/CameraFollowDemo/assets/model/helloWorld/tree.png differ diff --git a/CameraFollowDemo/assets/model/helloWorld/tree.png.meta b/CameraFollowDemo/assets/model/helloWorld/tree.png.meta new file mode 100644 index 0000000..f64c119 --- /dev/null +++ b/CameraFollowDemo/assets/model/helloWorld/tree.png.meta @@ -0,0 +1,41 @@ +{ + "ver": "1.0.22", + "importer": "image", + "imported": true, + "uuid": "c5083e75-ad2e-4ea9-8b33-dee748995b00", + "files": [ + ".png", + ".json" + ], + "subMetas": { + "6c48a": { + "importer": "texture", + "uuid": "c5083e75-ad2e-4ea9-8b33-dee748995b00@6c48a", + "displayName": "tree", + "id": "6c48a", + "name": "texture", + "ver": "1.0.21", + "imported": true, + "files": [ + ".json" + ], + "subMetas": {}, + "userData": { + "wrapModeS": "repeat", + "wrapModeT": "repeat", + "minfilter": "linear", + "magfilter": "linear", + "mipfilter": "none", + "premultiplyAlpha": false, + "anisotropy": 0, + "isUuid": true, + "imageUuidOrDatabaseUri": "c5083e75-ad2e-4ea9-8b33-dee748995b00" + } + } + }, + "userData": { + "type": "texture", + "redirect": "c5083e75-ad2e-4ea9-8b33-dee748995b00@6c48a", + "hasAlpha": false + } +} diff --git a/CameraFollowDemo/assets/scene.meta b/CameraFollowDemo/assets/scene.meta new file mode 100644 index 0000000..822e98f --- /dev/null +++ b/CameraFollowDemo/assets/scene.meta @@ -0,0 +1,12 @@ +{ + "ver": "1.1.0", + "importer": "directory", + "imported": true, + "uuid": "b0a4abb1-db32-49c3-9e09-a45b922a2094", + "files": [], + "subMetas": {}, + "userData": { + "compressionType": {}, + "isRemoteBundle": {} + } +} diff --git a/CameraFollowDemo/assets/scene/main.scene b/CameraFollowDemo/assets/scene/main.scene new file mode 100644 index 0000000..039bea5 --- /dev/null +++ b/CameraFollowDemo/assets/scene/main.scene @@ -0,0 +1,2726 @@ +[ + { + "__type__": "cc.SceneAsset", + "_name": "", + "_objFlags": 0, + "_native": "", + "scene": { + "__id__": 1 + } + }, + { + "__type__": "cc.Scene", + "_name": "main", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + }, + { + "__id__": 5 + }, + { + "__id__": 7 + }, + { + "__id__": 33 + }, + { + "__id__": 72 + }, + { + "__id__": 10 + }, + { + "__id__": 137 + }, + { + "__id__": 144 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 145 + }, + "autoReleaseAssets": false, + "_globals": { + "__id__": 194 + }, + "_id": "7c3e7fab-7b1e-4865-ba84-3cf81b48b9fb" + }, + { + "__type__": "cc.Node", + "_name": "Main Light", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 3 + } + ], + "_prefab": null, + "_lpos": { + "__type__": "cc.Vec3", + "x": -2.955, + "y": 3.412, + "z": 5.118 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.24999999999999997, + "y": -0.24999999999999997, + "z": -0.06698729810778066, + "w": 0.9330127018922194 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -30, + "y": -30, + "z": 0 + }, + "_id": "c0y6F5f+pAvI805TdmxIjx" + }, + { + "__type__": "cc.DirectionalLight", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "__prefab": null, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_useColorTemperature": false, + "_colorTemperature": 6550, + "_staticSettings": { + "__id__": 4 + }, + "_illuminanceHDR": 125000, + "_illuminance": 125000, + "_illuminanceLDR": 3.2552083333333335, + "_id": "597uMYCbhEtJQc0ffJlcgA" + }, + { + "__type__": "cc.StaticLightSettings", + "_baked": false, + "_editorOnly": false, + "_bakeable": false, + "_castShadow": false + }, + { + "__type__": "cc.Node", + "_name": "InputManager", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 6 + } + ], + "_prefab": null, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "17duPsPONL077KF1engWXG" + }, + { + "__type__": "45733dOgltPZY3wZcanJHXT", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 5 + }, + "_enabled": true, + "__prefab": null, + "_id": "a8F+NCHhxGEaymg3acGhBl" + }, + { + "__type__": "cc.Node", + "_name": "Main Camera", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 8 + }, + { + "__id__": 9 + } + ], + "_prefab": null, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 4, + "z": 6.305 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.13139134126869803, + "y": -1.1396382211944538e-19, + "z": 8.598422133009006e-19, + "w": 0.9913305782833558 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -15.1, + "y": 0, + "z": 9.93923337957349e-17 + }, + "_id": "c9DMICJLFO5IeO07EPon7U" + }, + { + "__type__": "cc.Camera", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 7 + }, + "_enabled": true, + "__prefab": null, + "_projection": 1, + "_priority": 0, + "_fov": 45, + "_fovAxis": 0, + "_orthoHeight": 10, + "_near": 1, + "_far": 1000, + "_color": { + "__type__": "cc.Color", + "r": 51, + "g": 51, + "b": 51, + "a": 255 + }, + "_depth": 1, + "_stencil": 0, + "_clearFlags": 14, + "_rect": { + "__type__": "cc.Rect", + "x": 0, + "y": 0, + "width": 1, + "height": 1 + }, + "_aperture": 19, + "_shutter": 7, + "_iso": 0, + "_screenScale": 1, + "_visibility": 1820327937, + "_targetTexture": null, + "_id": "7dWQTpwS5LrIHnc1zAPUtf" + }, + { + "__type__": "def1bnk1B5GJrn7LmZcDLJU", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 7 + }, + "_enabled": true, + "__prefab": null, + "target": { + "__id__": 10 + }, + "state": 1, + "hDist": 5, + "vDist": 4, + "springConst": 1000, + "_id": "16bYYqLs9E5KvVPnjgDxlQ" + }, + { + "__type__": "cc.Node", + "_name": "Role", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 11 + } + ], + "_active": true, + "_components": [ + { + "__id__": 32 + } + ], + "_prefab": null, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 1, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "b7VOc4YjxDMaPO2edJDo5i" + }, + { + "__type__": "cc.Node", + "_objFlags": 0, + "_parent": { + "__id__": 10 + }, + "_prefab": { + "__id__": 12 + } + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 11 + }, + "asset": { + "__uuid__": "cfc53c4e-7956-482b-aebc-3fb1dcd36eef", + "__expectedType__": "cc.Prefab" + }, + "fileId": "6dMvPN2t1B66O9Zc3HG8dr", + "instance": { + "__id__": 13 + } + }, + { + "__type__": "cc.PrefabInstance", + "fileId": "93xtJEZ71OF5Gk8u497J9k", + "prefabRootNode": null, + "mountedChildren": [], + "mountedComponents": [], + "propertyOverrides": [ + { + "__id__": 14 + }, + { + "__id__": 17 + }, + { + "__id__": 20 + }, + { + "__id__": 23 + }, + { + "__id__": 26 + }, + { + "__id__": 28 + }, + { + "__id__": 30 + }, + { + "__id__": 31 + } + ], + "removedComponents": [] + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 15 + }, + "propertyPath": [ + "lightmapSettings" + ], + "value": { + "__id__": 16 + } + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "78XZsd31xPjIsSP2888FcN" + ] + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 18 + }, + "propertyPath": [ + "lightmapSettings" + ], + "value": { + "__id__": 19 + } + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "ffoVYmt2NOmIBz5DHpacF8" + ] + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 21 + }, + "propertyPath": [ + "lightmapSettings" + ], + "value": { + "__id__": 22 + } + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "9aCVBuMeZPv6so1VxT6c40" + ] + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 24 + }, + "propertyPath": [ + "lightmapSettings" + ], + "value": { + "__id__": 25 + } + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "ca1srfPsJJgKKJww9GO/JE" + ] + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 27 + }, + "propertyPath": [ + "_lpos" + ], + "value": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + } + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "6dMvPN2t1B66O9Zc3HG8dr" + ] + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 29 + }, + "propertyPath": [ + "_lscale" + ], + "value": { + "__type__": "cc.Vec3", + "x": 0.5, + "y": 0.5, + "z": 0.5 + } + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "6dMvPN2t1B66O9Zc3HG8dr" + ] + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 29 + }, + "propertyPath": [ + "_lrot" + ], + "value": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + } + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 29 + }, + "propertyPath": [ + "_euler" + ], + "value": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + } + }, + { + "__type__": "44808qPmbBEG6odeuvB7prG", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 10 + }, + "_enabled": true, + "__prefab": null, + "target": { + "__id__": 10 + }, + "_id": "0dxOBx3zJK/bm/hDo3hmEE" + }, + { + "__type__": "cc.Node", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_prefab": { + "__id__": 34 + } + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 33 + }, + "asset": { + "__uuid__": "ccc3a755-7d3d-4304-aa3b-ca4792d79d9f", + "__expectedType__": "cc.Prefab" + }, + "fileId": "26LvC5hbxAuJZ9Jl2SB/IV", + "instance": { + "__id__": 35 + } + }, + { + "__type__": "cc.PrefabInstance", + "fileId": "cdNOYl3LRPhapW8a8hi/Iy", + "prefabRootNode": null, + "mountedChildren": [], + "mountedComponents": [], + "propertyOverrides": [ + { + "__id__": 36 + }, + { + "__id__": 39 + }, + { + "__id__": 42 + }, + { + "__id__": 44 + }, + { + "__id__": 47 + }, + { + "__id__": 49 + }, + { + "__id__": 52 + }, + { + "__id__": 55 + }, + { + "__id__": 58 + }, + { + "__id__": 61 + }, + { + "__id__": 64 + }, + { + "__id__": 67 + }, + { + "__id__": 70 + } + ], + "removedComponents": [] + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 37 + }, + "propertyPath": [ + "lightmapSettings" + ], + "value": { + "__id__": 38 + } + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "ddvMFij+ZIL5lu+/NQX8Nf" + ] + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 40 + }, + "propertyPath": [ + "lightmapSettings" + ], + "value": { + "__id__": 41 + } + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "e3XMjUJKFLH41z39JaWzyB" + ] + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 43 + }, + "propertyPath": [ + "position" + ], + "value": { + "__type__": "cc.Vec3", + "x": -1.341, + "y": 0.805, + "z": -2.555 + } + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "fd517lz3tOuqVWGd5300X6" + ] + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 45 + }, + "propertyPath": [ + "lightmapSettings" + ], + "value": { + "__id__": 46 + } + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "a5Viy6l3VLDpf6gY5yZF+v" + ] + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 48 + }, + "propertyPath": [ + "_shadowCastingMode" + ], + "value": 1 + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "a5Viy6l3VLDpf6gY5yZF+v" + ] + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 50 + }, + "propertyPath": [ + "lightmapSettings" + ], + "value": { + "__id__": 51 + } + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "e4If/bQrJCsb9D9JopZa2h" + ] + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 53 + }, + "propertyPath": [ + "lightmapSettings" + ], + "value": { + "__id__": 54 + } + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "d7Vkz0NV5Mn4RUce28JVTp" + ] + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 56 + }, + "propertyPath": [ + "lightmapSettings" + ], + "value": { + "__id__": 57 + } + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "3eVATgLQJKDbqOvE33W2uc" + ] + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 59 + }, + "propertyPath": [ + "lightmapSettings" + ], + "value": { + "__id__": 60 + } + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "2akU/MgO5Ovo6QcS0c/I7e" + ] + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 62 + }, + "propertyPath": [ + "lightmapSettings" + ], + "value": { + "__id__": 63 + } + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "54xaKIQbtPLK5r21VY0qmM" + ] + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 65 + }, + "propertyPath": [ + "lightmapSettings" + ], + "value": { + "__id__": 66 + } + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "23UFBqszxJ/6Otof04QwYT" + ] + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 68 + }, + "propertyPath": [ + "lightmapSettings" + ], + "value": { + "__id__": 69 + } + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "c7PE6gNTdDw45ytwlOEWR3" + ] + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 71 + }, + "propertyPath": [ + "_lpos" + ], + "value": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": -1.067 + } + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "26LvC5hbxAuJZ9Jl2SB/IV" + ] + }, + { + "__type__": "cc.Node", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_prefab": { + "__id__": 73 + } + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 72 + }, + "asset": { + "__uuid__": "5e4d48c4-0e34-45af-a268-89485197e8bc", + "__expectedType__": "cc.Prefab" + }, + "fileId": "e5Peksu5tL9peMeABb8/JC", + "instance": { + "__id__": 74 + } + }, + { + "__type__": "cc.PrefabInstance", + "fileId": "7e4SH9jydKyaQjXZtS5AiQ", + "prefabRootNode": null, + "mountedChildren": [], + "mountedComponents": [], + "propertyOverrides": [ + { + "__id__": 75 + }, + { + "__id__": 78 + }, + { + "__id__": 80 + }, + { + "__id__": 83 + }, + { + "__id__": 85 + }, + { + "__id__": 88 + }, + { + "__id__": 90 + }, + { + "__id__": 93 + }, + { + "__id__": 95 + }, + { + "__id__": 97 + }, + { + "__id__": 100 + }, + { + "__id__": 102 + }, + { + "__id__": 105 + }, + { + "__id__": 107 + }, + { + "__id__": 110 + }, + { + "__id__": 112 + }, + { + "__id__": 115 + }, + { + "__id__": 117 + }, + { + "__id__": 120 + }, + { + "__id__": 122 + }, + { + "__id__": 125 + }, + { + "__id__": 127 + }, + { + "__id__": 130 + }, + { + "__id__": 132 + }, + { + "__id__": 135 + } + ], + "removedComponents": [] + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 76 + }, + "propertyPath": [ + "lightmapSettings" + ], + "value": { + "__id__": 77 + } + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "a6J1jU/r1BPKNIcVMEREit" + ] + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 79 + }, + "propertyPath": [ + "_shadowReceivingMode" + ], + "value": 1 + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "a6J1jU/r1BPKNIcVMEREit" + ] + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 81 + }, + "propertyPath": [ + "lightmapSettings" + ], + "value": { + "__id__": 82 + } + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "28WH2cvhNDFbN3it+8Q+XK" + ] + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 84 + }, + "propertyPath": [ + "_shadowReceivingMode" + ], + "value": 1 + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "28WH2cvhNDFbN3it+8Q+XK" + ] + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 86 + }, + "propertyPath": [ + "lightmapSettings" + ], + "value": { + "__id__": 87 + } + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "87exLhmM1P35jx6GLN7j5f" + ] + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 89 + }, + "propertyPath": [ + "_shadowReceivingMode" + ], + "value": 1 + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "87exLhmM1P35jx6GLN7j5f" + ] + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 91 + }, + "propertyPath": [ + "lightmapSettings" + ], + "value": { + "__id__": 92 + } + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "dduLonFhNK+q908BUlLM7f" + ] + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 94 + }, + "propertyPath": [ + "_shadowCastingMode" + ], + "value": 1 + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "dduLonFhNK+q908BUlLM7f" + ] + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 96 + }, + "propertyPath": [ + "_shadowReceivingMode" + ], + "value": 1 + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "dduLonFhNK+q908BUlLM7f" + ] + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 98 + }, + "propertyPath": [ + "lightmapSettings" + ], + "value": { + "__id__": 99 + } + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "af0f1GeGlKf5MvKMEuH8MJ" + ] + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 101 + }, + "propertyPath": [ + "_shadowReceivingMode" + ], + "value": 1 + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "af0f1GeGlKf5MvKMEuH8MJ" + ] + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 103 + }, + "propertyPath": [ + "lightmapSettings" + ], + "value": { + "__id__": 104 + } + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "e9BPt5G81CloUmA5IJNHIQ" + ] + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 106 + }, + "propertyPath": [ + "_shadowReceivingMode" + ], + "value": 1 + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "e9BPt5G81CloUmA5IJNHIQ" + ] + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 108 + }, + "propertyPath": [ + "lightmapSettings" + ], + "value": { + "__id__": 109 + } + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "7dt8ZZ5EBNDIxOgpt1XbGu" + ] + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 111 + }, + "propertyPath": [ + "_shadowReceivingMode" + ], + "value": 1 + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "7dt8ZZ5EBNDIxOgpt1XbGu" + ] + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 113 + }, + "propertyPath": [ + "lightmapSettings" + ], + "value": { + "__id__": 114 + } + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "c4Nekl9YtKUKupS0ASX7It" + ] + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 116 + }, + "propertyPath": [ + "_shadowReceivingMode" + ], + "value": 1 + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "c4Nekl9YtKUKupS0ASX7It" + ] + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 118 + }, + "propertyPath": [ + "lightmapSettings" + ], + "value": { + "__id__": 119 + } + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "b9cuhcVRxPvZTPHcAyE7eS" + ] + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 121 + }, + "propertyPath": [ + "_shadowReceivingMode" + ], + "value": 1 + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "b9cuhcVRxPvZTPHcAyE7eS" + ] + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 123 + }, + "propertyPath": [ + "lightmapSettings" + ], + "value": { + "__id__": 124 + } + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "f3T3OFBBJBYrGbPSQ+k7GJ" + ] + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 126 + }, + "propertyPath": [ + "_shadowReceivingMode" + ], + "value": 1 + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "f3T3OFBBJBYrGbPSQ+k7GJ" + ] + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 128 + }, + "propertyPath": [ + "lightmapSettings" + ], + "value": { + "__id__": 129 + } + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "d0A5LfhGhAfrDnBGJ3JzOe" + ] + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 131 + }, + "propertyPath": [ + "_shadowReceivingMode" + ], + "value": 1 + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "d0A5LfhGhAfrDnBGJ3JzOe" + ] + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 133 + }, + "propertyPath": [ + "lightmapSettings" + ], + "value": { + "__id__": 134 + } + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "161SEdWiFO/abXxUI8RkYk" + ] + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 136 + }, + "propertyPath": [ + "_shadowReceivingMode" + ], + "value": 1 + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "161SEdWiFO/abXxUI8RkYk" + ] + }, + { + "__type__": "cc.Node", + "_name": "Capsule", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 138 + } + ], + "_active": true, + "_components": [ + { + "__id__": 141 + }, + { + "__id__": 143 + } + ], + "_prefab": null, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0.992, + "y": 1.123, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 0.25, + "y": 0.25, + "z": 0.25 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "edlhFJ3pBL8KfJGpDHZd9E" + }, + { + "__type__": "cc.Node", + "_name": "Cube", + "_objFlags": 0, + "_parent": { + "__id__": 137 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 139 + } + ], + "_prefab": null, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0.45, + "z": -0.358 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 0.8, + "y": 0.2, + "z": 0.4 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "6eoy5qWttL/oieY/q4aweu" + }, + { + "__type__": "cc.MeshRenderer", + "_name": "Cube", + "_objFlags": 0, + "node": { + "__id__": 138 + }, + "_enabled": true, + "__prefab": null, + "_materials": [ + { + "__uuid__": "a0ddabd7-f1da-421f-ac27-bfd6a96339ef", + "__expectedType__": "cc.Material" + } + ], + "_visFlags": 0, + "lightmapSettings": { + "__id__": 140 + }, + "_mesh": { + "__uuid__": "1263d74c-8167-4928-91a6-4e2672411f47@a804a", + "__expectedType__": "cc.Mesh" + }, + "_shadowCastingMode": 0, + "_shadowReceivingMode": 1, + "_enableMorph": true, + "_id": "8ex0SOV21IhqGrwLp7BMP/" + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "cc.MeshRenderer", + "_name": "Capsule", + "_objFlags": 0, + "node": { + "__id__": 137 + }, + "_enabled": true, + "__prefab": null, + "_materials": [ + { + "__uuid__": "d3c7820c-2a98-4429-8bc7-b8453bc9ac41", + "__expectedType__": "cc.Material" + } + ], + "_visFlags": 0, + "lightmapSettings": { + "__id__": 142 + }, + "_mesh": { + "__uuid__": "1263d74c-8167-4928-91a6-4e2672411f47@801ec", + "__expectedType__": "cc.Mesh" + }, + "_shadowCastingMode": 0, + "_shadowReceivingMode": 1, + "_enableMorph": true, + "_id": "0c3iP2zUlENr1//8BdtvS8" + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "3d2b1b0r6VC65lmI9lquHvj", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 137 + }, + "_enabled": true, + "__prefab": null, + "target": { + "__id__": 10 + }, + "_id": "4de8QBm6FOYo/fVvbbsTys" + }, + { + "__type__": "cc.Node", + "_name": "Node", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": null, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 1, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "691xstmTRBjoT0EIt7JVyU" + }, + { + "__type__": "cc.PrefabInfo", + "fileId": "", + "targetOverrides": [ + { + "__id__": 146 + }, + { + "__id__": 149 + }, + { + "__id__": 152 + }, + { + "__id__": 155 + }, + { + "__id__": 158 + }, + { + "__id__": 161 + }, + { + "__id__": 164 + }, + { + "__id__": 167 + }, + { + "__id__": 170 + }, + { + "__id__": 173 + }, + { + "__id__": 176 + }, + { + "__id__": 179 + }, + { + "__id__": 182 + }, + { + "__id__": 185 + }, + { + "__id__": 188 + }, + { + "__id__": 191 + } + ], + "nestedPrefabInstanceRoots": [ + { + "__id__": 33 + }, + { + "__id__": 72 + }, + { + "__id__": 11 + } + ] + }, + { + "__type__": "cc.TargetOverrideInfo", + "source": { + "__id__": 11 + }, + "sourceInfo": { + "__id__": 147 + }, + "propertyPath": [ + "_skinningRoot" + ], + "target": { + "__id__": 11 + }, + "targetInfo": { + "__id__": 148 + } + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "04W3Kzvb9BZbZUGFZzfzi5" + ] + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "6dMvPN2t1B66O9Zc3HG8dr" + ] + }, + { + "__type__": "cc.TargetOverrideInfo", + "source": { + "__id__": 11 + }, + "sourceInfo": { + "__id__": 150 + }, + "propertyPath": [ + "_skinningRoot" + ], + "target": { + "__id__": 11 + }, + "targetInfo": { + "__id__": 151 + } + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "04W3Kzvb9BZbZUGFZzfzi5" + ] + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "6dMvPN2t1B66O9Zc3HG8dr" + ] + }, + { + "__type__": "cc.TargetOverrideInfo", + "source": { + "__id__": 11 + }, + "sourceInfo": { + "__id__": 153 + }, + "propertyPath": [ + "_skinningRoot" + ], + "target": { + "__id__": 11 + }, + "targetInfo": { + "__id__": 154 + } + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "04W3Kzvb9BZbZUGFZzfzi5" + ] + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "6dMvPN2t1B66O9Zc3HG8dr" + ] + }, + { + "__type__": "cc.TargetOverrideInfo", + "source": { + "__id__": 11 + }, + "sourceInfo": { + "__id__": 156 + }, + "propertyPath": [ + "_skinningRoot" + ], + "target": { + "__id__": 11 + }, + "targetInfo": { + "__id__": 157 + } + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "04W3Kzvb9BZbZUGFZzfzi5" + ] + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "6dMvPN2t1B66O9Zc3HG8dr" + ] + }, + { + "__type__": "cc.TargetOverrideInfo", + "source": { + "__id__": 72 + }, + "sourceInfo": { + "__id__": 159 + }, + "propertyPath": [ + "_skinningRoot" + ], + "target": { + "__id__": 72 + }, + "targetInfo": { + "__id__": 160 + } + }, + { + "__type__": "cc.TargetInfo", + "localID": [] + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "87M1Av0v5LhZ3LsJOTzwr3" + ] + }, + { + "__type__": "cc.TargetOverrideInfo", + "source": { + "__id__": 72 + }, + "sourceInfo": { + "__id__": 162 + }, + "propertyPath": [ + "_skinningRoot" + ], + "target": { + "__id__": 72 + }, + "targetInfo": { + "__id__": 163 + } + }, + { + "__type__": "cc.TargetInfo", + "localID": [] + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "8avX4W7ZtLOLCZ8n5QtiPm" + ] + }, + { + "__type__": "cc.TargetOverrideInfo", + "source": { + "__id__": 72 + }, + "sourceInfo": { + "__id__": 165 + }, + "propertyPath": [ + "_skinningRoot" + ], + "target": { + "__id__": 72 + }, + "targetInfo": { + "__id__": 166 + } + }, + { + "__type__": "cc.TargetInfo", + "localID": [] + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "5fAmHUz0xO9YFym/gsZawP" + ] + }, + { + "__type__": "cc.TargetOverrideInfo", + "source": { + "__id__": 72 + }, + "sourceInfo": { + "__id__": 168 + }, + "propertyPath": [ + "_skinningRoot" + ], + "target": { + "__id__": 72 + }, + "targetInfo": { + "__id__": 169 + } + }, + { + "__type__": "cc.TargetInfo", + "localID": [] + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "9bIVhdYYpFl7JZmL4oubNS" + ] + }, + { + "__type__": "cc.TargetOverrideInfo", + "source": { + "__id__": 72 + }, + "sourceInfo": { + "__id__": 171 + }, + "propertyPath": [ + "_skinningRoot" + ], + "target": { + "__id__": 72 + }, + "targetInfo": { + "__id__": 172 + } + }, + { + "__type__": "cc.TargetInfo", + "localID": [] + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "2d66RAsipF1brG2RGpHJY1" + ] + }, + { + "__type__": "cc.TargetOverrideInfo", + "source": { + "__id__": 72 + }, + "sourceInfo": { + "__id__": 174 + }, + "propertyPath": [ + "_skinningRoot" + ], + "target": { + "__id__": 72 + }, + "targetInfo": { + "__id__": 175 + } + }, + { + "__type__": "cc.TargetInfo", + "localID": [] + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "ffwse8PqZBf4sIEkNdsA+i" + ] + }, + { + "__type__": "cc.TargetOverrideInfo", + "source": { + "__id__": 72 + }, + "sourceInfo": { + "__id__": 177 + }, + "propertyPath": [ + "_skinningRoot" + ], + "target": { + "__id__": 72 + }, + "targetInfo": { + "__id__": 178 + } + }, + { + "__type__": "cc.TargetInfo", + "localID": [] + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "adNP+ELEhC4awfcKkY8jYJ" + ] + }, + { + "__type__": "cc.TargetOverrideInfo", + "source": { + "__id__": 72 + }, + "sourceInfo": { + "__id__": 180 + }, + "propertyPath": [ + "_skinningRoot" + ], + "target": { + "__id__": 72 + }, + "targetInfo": { + "__id__": 181 + } + }, + { + "__type__": "cc.TargetInfo", + "localID": [] + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "33gYFxG8dO2r8iKjzjEx4z" + ] + }, + { + "__type__": "cc.TargetOverrideInfo", + "source": { + "__id__": 72 + }, + "sourceInfo": { + "__id__": 183 + }, + "propertyPath": [ + "_skinningRoot" + ], + "target": { + "__id__": 72 + }, + "targetInfo": { + "__id__": 184 + } + }, + { + "__type__": "cc.TargetInfo", + "localID": [] + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "27mCip0lFNkL+6Dj/Bpwj4" + ] + }, + { + "__type__": "cc.TargetOverrideInfo", + "source": { + "__id__": 72 + }, + "sourceInfo": { + "__id__": 186 + }, + "propertyPath": [ + "_skinningRoot" + ], + "target": { + "__id__": 72 + }, + "targetInfo": { + "__id__": 187 + } + }, + { + "__type__": "cc.TargetInfo", + "localID": [] + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "50aim7sdtB2rmsHB4KRkd5" + ] + }, + { + "__type__": "cc.TargetOverrideInfo", + "source": { + "__id__": 72 + }, + "sourceInfo": { + "__id__": 189 + }, + "propertyPath": [ + "_skinningRoot" + ], + "target": { + "__id__": 72 + }, + "targetInfo": { + "__id__": 190 + } + }, + { + "__type__": "cc.TargetInfo", + "localID": [] + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "70DWXrCRRL4pWATtzgi7DN" + ] + }, + { + "__type__": "cc.TargetOverrideInfo", + "source": { + "__id__": 72 + }, + "sourceInfo": { + "__id__": 192 + }, + "propertyPath": [ + "_skinningRoot" + ], + "target": { + "__id__": 72 + }, + "targetInfo": { + "__id__": 193 + } + }, + { + "__type__": "cc.TargetInfo", + "localID": [] + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "7aOtJ3fThN27Zj4fmkg0ut" + ] + }, + { + "__type__": "cc.SceneGlobals", + "ambient": { + "__id__": 195 + }, + "shadows": { + "__id__": 196 + }, + "_skybox": { + "__id__": 197 + }, + "fog": { + "__id__": 198 + }, + "octree": { + "__id__": 199 + } + }, + { + "__type__": "cc.AmbientInfo", + "_skyColorHDR": { + "__type__": "cc.Vec4", + "x": 0.2, + "y": 0.5019607843137255, + "z": 0.8, + "w": 0.520833125 + }, + "_skyColor": { + "__type__": "cc.Vec4", + "x": 0.2, + "y": 0.5019607843137255, + "z": 0.8, + "w": 0.520833125 + }, + "_skyIllumHDR": 20000, + "_skyIllum": 20000, + "_groundAlbedoHDR": { + "__type__": "cc.Vec4", + "x": 0.2, + "y": 0.2, + "z": 0.2, + "w": 1 + }, + "_groundAlbedo": { + "__type__": "cc.Vec4", + "x": 0.2, + "y": 0.2, + "z": 0.2, + "w": 1 + }, + "_skyColorLDR": { + "__type__": "cc.Vec4", + "x": 0.2, + "y": 0.5019607843137255, + "z": 0.8, + "w": 0.520833125 + }, + "_skyIllumLDR": 0.78125, + "_groundAlbedoLDR": { + "__type__": "cc.Vec4", + "x": 0.2, + "y": 0.2, + "z": 0.2, + "w": 1 + } + }, + { + "__type__": "cc.ShadowsInfo", + "_type": 1, + "_enabled": true, + "_normal": { + "__type__": "cc.Vec3", + "x": 0, + "y": 1, + "z": 0 + }, + "_distance": 1, + "_shadowColor": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 115 + }, + "_firstSetCSM": false, + "_fixedArea": false, + "_pcf": 2, + "_bias": 0.01, + "_normalBias": 0, + "_near": 0.1, + "_far": 50, + "_shadowDistance": 10, + "_invisibleOcclusionRange": 200, + "_orthoSize": 10, + "_maxReceived": 4, + "_size": { + "__type__": "cc.Vec2", + "x": 512, + "y": 512 + }, + "_saturation": 0.45098039215686275 + }, + { + "__type__": "cc.SkyboxInfo", + "_applyDiffuseMap": false, + "_envmapHDR": { + "__uuid__": "5af201b5-5951-4e2c-a81f-ac4aad9132cb@b47c0", + "__expectedType__": "cc.TextureCube" + }, + "_envmap": { + "__uuid__": "5af201b5-5951-4e2c-a81f-ac4aad9132cb@b47c0", + "__expectedType__": "cc.TextureCube" + }, + "_envmapLDR": { + "__uuid__": "5af201b5-5951-4e2c-a81f-ac4aad9132cb@b47c0", + "__expectedType__": "cc.TextureCube" + }, + "_diffuseMapHDR": null, + "_diffuseMapLDR": null, + "_enabled": true, + "_useIBL": false, + "_useHDR": true + }, + { + "__type__": "cc.FogInfo", + "_type": 0, + "_fogColor": { + "__type__": "cc.Color", + "r": 225, + "g": 225, + "b": 225, + "a": 255 + }, + "_enabled": false, + "_fogDensity": 0.3, + "_fogStart": 0.5, + "_fogEnd": 300, + "_fogAtten": 5, + "_fogTop": 1.5, + "_fogRange": 1.2, + "_accurate": false + }, + { + "__type__": "cc.OctreeInfo", + "_enabled": false, + "_minPos": { + "__type__": "cc.Vec3", + "x": -1024, + "y": -1024, + "z": -1024 + }, + "_maxPos": { + "__type__": "cc.Vec3", + "x": 1024, + "y": 1024, + "z": 1024 + }, + "_depth": 8 + } +] \ No newline at end of file diff --git a/CameraFollowDemo/assets/scene/main.scene.meta b/CameraFollowDemo/assets/scene/main.scene.meta new file mode 100644 index 0000000..3c139b1 --- /dev/null +++ b/CameraFollowDemo/assets/scene/main.scene.meta @@ -0,0 +1,11 @@ +{ + "ver": "1.1.35", + "importer": "scene", + "imported": true, + "uuid": "7c3e7fab-7b1e-4865-ba84-3cf81b48b9fb", + "files": [ + ".json" + ], + "subMetas": {}, + "userData": {} +} diff --git a/CameraFollowDemo/assets/scripts.meta b/CameraFollowDemo/assets/scripts.meta new file mode 100644 index 0000000..3418d0d --- /dev/null +++ b/CameraFollowDemo/assets/scripts.meta @@ -0,0 +1,12 @@ +{ + "ver": "1.1.0", + "importer": "directory", + "imported": true, + "uuid": "fd940988-b5a4-4d7e-a23c-182c215fa8cb", + "files": [], + "subMetas": {}, + "userData": { + "compressionType": {}, + "isRemoteBundle": {} + } +} diff --git a/CameraFollowDemo/assets/scripts/CameraFollow.ts b/CameraFollowDemo/assets/scripts/CameraFollow.ts new file mode 100644 index 0000000..92578fd --- /dev/null +++ b/CameraFollowDemo/assets/scripts/CameraFollow.ts @@ -0,0 +1,91 @@ + +import { _decorator, Component, Node, Vec3, v3, Quat, Enum } from 'cc'; +import { NHelper } from './NHelper'; +const { ccclass, property } = _decorator; + +export enum ECameraState { + /**不跟随 */ + idle, + /**跟随 */ + look, +} + +@ccclass('CameraFollow') +export class CameraFollow extends Component { + @property({ type: Node, displayName: "跟随目标" }) + protected target: Node = null; + @property({ type: Enum(ECameraState), displayName: "跟随状态" }) + protected state: ECameraState = ECameraState.look; + @property({ displayName: "水平跟随距离" }) + protected hDist: number = 5; + @property({ displayName: "垂直跟随距离" }) + protected vDist: number = 4; + + private tempPos: Vec3 = v3(); + + start() { + + } + + /** + * 计算前向量 + * @returns + */ + protected getUp() { + return v3(0, 1, 0); + } + + /** + * 计算跟随距离 + * @returns + */ + protected computeCameraPos(out: Vec3 = null): Vec3 { + let tempPos = out ? out : this.tempPos; + this.target.getWorldPosition(tempPos); + let forward = NHelper.getForward(this.target); + forward.multiplyScalar(-this.hDist); + tempPos.add(forward); + tempPos.add(this.getUp().multiplyScalar(this.vDist)); + return tempPos; + } + + /** + * 跟随 + * @param dt + */ + protected lookAt(dt: number) { + let pos = this.computeCameraPos(); + this.updatePosition(pos); + this.updateRotation(pos); + } + + /** + * 更新跟随位置 + * @param pos + */ + protected updatePosition(pos: Vec3) { + this.node.worldPosition = pos; + } + + /** + * 更新角度四元数 + * @param pos + */ + protected updateRotation(pos: Vec3) { + //camera前方向 + let forward = this.target.position.clone().subtract(pos); + //取反得到camera节点的前方向 + forward.multiplyScalar(-1).normalize(); + //构造四元数 + let quat = new Quat(); + Quat.fromViewUp(quat, forward, this.getUp()); + this.node.setRotation(quat); + } + + update(deltaTime: number) { + if (this.state == ECameraState.look) { + this.lookAt(deltaTime); + } + } +} + diff --git a/CameraFollowDemo/assets/scripts/CameraFollow.ts.meta b/CameraFollowDemo/assets/scripts/CameraFollow.ts.meta new file mode 100644 index 0000000..9e71660 --- /dev/null +++ b/CameraFollowDemo/assets/scripts/CameraFollow.ts.meta @@ -0,0 +1,9 @@ +{ + "ver": "4.0.23", + "importer": "typescript", + "imported": true, + "uuid": "96df90e9-217e-4c3a-a4cd-02ed0ffb48a4", + "files": [], + "subMetas": {}, + "userData": {} +} diff --git a/CameraFollowDemo/assets/scripts/InputManager.ts b/CameraFollowDemo/assets/scripts/InputManager.ts new file mode 100644 index 0000000..4fa6da7 --- /dev/null +++ b/CameraFollowDemo/assets/scripts/InputManager.ts @@ -0,0 +1,79 @@ + +import { _decorator, Component, Node, input, Input, EventKeyboard, KeyCode, game } from 'cc'; +const { ccclass, property } = _decorator; + + +@ccclass('InputManager') +export class InputManager extends Component { + // [1] + // dummy = ''; + + // [2] + // @property + // serializableDummy = 0; + + onLoad() { + + } + + start() { + + } + + onEnable() { + input.on(Input.EventType.KEY_DOWN, this.onKeyDown, this); + input.on(Input.EventType.KEY_UP, this.onKeyUp, this); + + } + + onDisable() { + input.off(Input.EventType.KEY_DOWN, this.onKeyDown, this); + input.off(Input.EventType.KEY_UP, this.onKeyUp, this); + } + + onKeyDown(event: EventKeyboard) { + switch (event.keyCode) { + case KeyCode.KEY_A: { + console.log('key a'); + //left + game.emit("rule_horizontal_push", 1) + } break; + case KeyCode.KEY_D: { + console.log('key d'); + game.emit("rule_horizontal_push", -1) + } break; + case KeyCode.KEY_W: { + game.emit("rule_vertical_push", 1) + } break; + case KeyCode.KEY_S: { + game.emit("rule_vertical_push", -1) + } break; + } + } + + onKeyUp(event: EventKeyboard) { + switch (event.keyCode) { + case KeyCode.KEY_A: { + console.log('key a'); + //left + game.emit("rule_horizontal_push", 0) + } break; + case KeyCode.KEY_D: { + console.log('key d'); + game.emit("rule_horizontal_push", 0) + } break; + case KeyCode.KEY_W: { + game.emit("rule_vertical_push", 0) + } break; + case KeyCode.KEY_S: { + game.emit("rule_vertical_push", 0) + } break; + } + } + + // update(deltaTime: number) { + + // } +} + + diff --git a/CameraFollowDemo/assets/scripts/InputManager.ts.meta b/CameraFollowDemo/assets/scripts/InputManager.ts.meta new file mode 100644 index 0000000..24488a6 --- /dev/null +++ b/CameraFollowDemo/assets/scripts/InputManager.ts.meta @@ -0,0 +1,9 @@ +{ + "ver": "4.0.23", + "importer": "typescript", + "imported": true, + "uuid": "4573374e-825b-4f65-8df0-65c6a72475d3", + "files": [], + "subMetas": {}, + "userData": {} +} diff --git a/CameraFollowDemo/assets/scripts/LookAt.ts b/CameraFollowDemo/assets/scripts/LookAt.ts new file mode 100644 index 0000000..a11c3a1 --- /dev/null +++ b/CameraFollowDemo/assets/scripts/LookAt.ts @@ -0,0 +1,31 @@ + +import { _decorator, Component, Node, v3 } from 'cc'; +const { ccclass, property } = _decorator; + + +@ccclass('LookAt') +export class LookAt extends Component { + + @property(Node) + target: Node = null; + + start() { + // [3] + } + + update(deltaTime: number) { + // [4] + this.node.lookAt(this.target.worldPosition,v3(0,1,0)); + } +} + +/** + * [1] Class member could be defined like this. + * [2] Use `property` decorator if your want the member to be serializable. + * [3] Your initialization goes here. + * [4] Your update function goes here. + * + * Learn more about scripting: https://docs.cocos.com/creator/3.4/manual/zh/scripting/ + * Learn more about CCClass: https://docs.cocos.com/creator/3.4/manual/zh/scripting/ccclass.html + * Learn more about life-cycle callbacks: https://docs.cocos.com/creator/3.4/manual/zh/scripting/life-cycle-callbacks.html + */ diff --git a/CameraFollowDemo/assets/scripts/LookAt.ts.meta b/CameraFollowDemo/assets/scripts/LookAt.ts.meta new file mode 100644 index 0000000..8dbb269 --- /dev/null +++ b/CameraFollowDemo/assets/scripts/LookAt.ts.meta @@ -0,0 +1,9 @@ +{ + "ver": "4.0.23", + "importer": "typescript", + "imported": true, + "uuid": "3d2b16f4-afa5-42eb-9966-23d96ab87be3", + "files": [], + "subMetas": {}, + "userData": {} +} diff --git a/CameraFollowDemo/assets/scripts/NHelper.ts b/CameraFollowDemo/assets/scripts/NHelper.ts new file mode 100644 index 0000000..0996c52 --- /dev/null +++ b/CameraFollowDemo/assets/scripts/NHelper.ts @@ -0,0 +1,16 @@ +import { CCObject, Node, Quat, v3, Vec3 } from "cc"; + +export class NHelper { + private static tempQuat: Quat = new Quat(); + private static tempPos:Vec3=new Vec3(); + /** + * 计算节点世界坐标下的向前向量 + * @param node 目标节点 + * @param defaultForward 默认前方向 + */ + public static getForward(node: Node, defaultForward: Vec3 = v3(0, 0, 1)) { + node.getWorldRotation(this.tempQuat); + Vec3.transformQuat(this.tempPos, defaultForward, this.tempQuat); + return this.tempPos.normalize(); + } +} \ No newline at end of file diff --git a/CameraFollowDemo/assets/scripts/NHelper.ts.meta b/CameraFollowDemo/assets/scripts/NHelper.ts.meta new file mode 100644 index 0000000..bd0319c --- /dev/null +++ b/CameraFollowDemo/assets/scripts/NHelper.ts.meta @@ -0,0 +1,9 @@ +{ + "ver": "4.0.23", + "importer": "typescript", + "imported": true, + "uuid": "8ba48c76-b830-4db2-b387-7aeec8d76a10", + "files": [], + "subMetas": {}, + "userData": {} +} diff --git a/CameraFollowDemo/assets/scripts/Role.ts b/CameraFollowDemo/assets/scripts/Role.ts new file mode 100644 index 0000000..85ce09d --- /dev/null +++ b/CameraFollowDemo/assets/scripts/Role.ts @@ -0,0 +1,71 @@ + +import { _decorator, Component, Node, game, Quat, v3, Vec3 } from 'cc'; +const { ccclass, property } = _decorator; + +@ccclass('Role') +export class Role extends Component { + + @property(Node) + target: Node = null; + + private speed: number = 10; + private angleSpeed: number = 4; + + onEnable() { + game.on("rule_horizontal_push", this.onMoveHorizontal, this); + game.on("rule_vertical_push", this.onMoveVertical, this); + console.log('forward=',this.getForward()); + } + + onDisable() { + game.off("rule_horizontal_push", this.onMoveHorizontal, this); + game.off("rule_vertical_push", this.onMoveVertical, this); + } + + /** + * + * @returns + */ + getForward() { + let rotation = this.target.getWorldRotation(); + let forward=v3(); + //通过角色的角度的四元数,取得前进向量 + Vec3.transformQuat(forward,v3(0,0,1),rotation); + return forward.normalize(); + } + + private hDir: number = 0; + onMoveHorizontal() { + this.hDir = arguments[0]; + } + + private rotation(dt: number) { + let rotation = this.target.worldRotation; + let next = new Quat(); + Quat.rotateAround(next, rotation, v3(0, 1, 0), this.angleSpeed * dt * this.hDir); + this.target.setRotation(next); + } + + private vDir: number = 0; + onMoveVertical() { + this.vDir = arguments[0]; + } + + move(dt: number) { + let forward = this.getForward(); + forward.multiplyScalar(this.speed * dt * this.vDir); + let pos = this.target.getWorldPosition().add(forward); + this.target.setWorldPosition(pos); + } + + update(deltaTime: number) { + if (Math.abs(this.vDir) > 0) { + this.move(deltaTime); + } + + if (Math.abs(this.hDir) > 0) { + this.rotation(deltaTime); + } + } +} + diff --git a/CameraFollowDemo/assets/scripts/Role.ts.meta b/CameraFollowDemo/assets/scripts/Role.ts.meta new file mode 100644 index 0000000..864f11a --- /dev/null +++ b/CameraFollowDemo/assets/scripts/Role.ts.meta @@ -0,0 +1,9 @@ +{ + "ver": "4.0.23", + "importer": "typescript", + "imported": true, + "uuid": "44808a8f-99b0-441b-aa1d-7aebc1ee9ac6", + "files": [], + "subMetas": {}, + "userData": {} +} diff --git a/CameraFollowDemo/assets/scripts/SpringCamera.ts b/CameraFollowDemo/assets/scripts/SpringCamera.ts new file mode 100644 index 0000000..391fbaf --- /dev/null +++ b/CameraFollowDemo/assets/scripts/SpringCamera.ts @@ -0,0 +1,42 @@ + +import { _decorator, Component, Node, Vec3, v3 } from 'cc'; +import { CameraFollow } from './CameraFollow'; +const { ccclass, property } = _decorator; + +@ccclass('SpringCamera') +export class SpringCamera extends CameraFollow { + @property({ displayName: "弹性系数", tooltip: "数值越高表示越僵硬" }) + protected springConst: number = 1000; + /**阻尼系数,数值是由弹性系数决定 */ + protected dampeConst: number = 1; + /**移动速度*/ + protected velocity: Vec3 = v3(); + /**camera真实位置向量*/ + protected actualPos: Vec3 = v3(); + /**理想位置到真实位置的差值 */ + private diff: Vec3 = v3(); + /**弹簧加速度 */ + private springAcc: Vec3 = v3(); + + onLoad() { + this.dampeConst = 2 * Math.sqrt(this.springConst); + //起初,设置位置为理想位置,就是基础跟随摄像机的眼睛位置一样 + this.computeCameraPos(this.actualPos); + this.updatePosition(this.actualPos); + this.updateRotation(this.actualPos); + } + + protected lookAt(dt: number) { + let idealPos = this.computeCameraPos(); + //差值 + Vec3.subtract(this.diff, this.actualPos, idealPos); + //计算加速度 + Vec3.subtract(this.springAcc, this.diff.multiplyScalar(-1 * this.dampeConst), this.velocity.clone().multiplyScalar(this.dampeConst)); + this.velocity.add(this.springAcc.multiplyScalar(dt)); + this.actualPos.add(this.velocity.multiplyScalar(dt)); + //更新位置跟角度 + this.updatePosition(this.actualPos); + this.updateRotation(this.actualPos); + } +} + diff --git a/CameraFollowDemo/assets/scripts/SpringCamera.ts.meta b/CameraFollowDemo/assets/scripts/SpringCamera.ts.meta new file mode 100644 index 0000000..ee1aac7 --- /dev/null +++ b/CameraFollowDemo/assets/scripts/SpringCamera.ts.meta @@ -0,0 +1,9 @@ +{ + "ver": "4.0.23", + "importer": "typescript", + "imported": true, + "uuid": "def1b9e4-d41e-4626-b9fb-2e665c0cb254", + "files": [], + "subMetas": {}, + "userData": {} +} diff --git a/CameraFollowDemo/assets/skybox.meta b/CameraFollowDemo/assets/skybox.meta new file mode 100644 index 0000000..46fb35c --- /dev/null +++ b/CameraFollowDemo/assets/skybox.meta @@ -0,0 +1,12 @@ +{ + "ver": "1.1.0", + "importer": "directory", + "imported": true, + "uuid": "9e344b1f-8681-4ddf-bcc6-bb014c332bb8", + "files": [], + "subMetas": {}, + "userData": { + "compressionType": {}, + "isRemoteBundle": {} + } +} diff --git a/CameraFollowDemo/assets/skybox/sunnySkyBox.jpg b/CameraFollowDemo/assets/skybox/sunnySkyBox.jpg new file mode 100644 index 0000000..633a4b7 Binary files /dev/null and b/CameraFollowDemo/assets/skybox/sunnySkyBox.jpg differ diff --git a/CameraFollowDemo/assets/skybox/sunnySkyBox.jpg.meta b/CameraFollowDemo/assets/skybox/sunnySkyBox.jpg.meta new file mode 100644 index 0000000..f05be57 --- /dev/null +++ b/CameraFollowDemo/assets/skybox/sunnySkyBox.jpg.meta @@ -0,0 +1,131 @@ +{ + "ver": "1.0.22", + "importer": "image", + "imported": true, + "uuid": "5af201b5-5951-4e2c-a81f-ac4aad9132cb", + "files": [ + ".jpg", + ".json" + ], + "subMetas": { + "b47c0": { + "importer": "erp-texture-cube", + "uuid": "5af201b5-5951-4e2c-a81f-ac4aad9132cb@b47c0", + "displayName": "sunnySkyBox", + "id": "b47c0", + "name": "textureCube", + "userData": { + "wrapModeS": "repeat", + "wrapModeT": "repeat", + "minfilter": "linear", + "magfilter": "linear", + "mipfilter": "linear", + "anisotropy": 1, + "isRGBE": false, + "imageDatabaseUri": "db://assets/skybox/sunnySkyBox.jpg" + }, + "ver": "1.0.10", + "imported": true, + "files": [ + ".json" + ], + "subMetas": { + "e9a6d": { + "importer": "texture-cube-face", + "uuid": "5af201b5-5951-4e2c-a81f-ac4aad9132cb@b47c0@e9a6d", + "displayName": "", + "id": "e9a6d", + "name": "front", + "userData": {}, + "ver": "1.0.0", + "imported": true, + "files": [ + ".png", + ".json" + ], + "subMetas": {} + }, + "40c10": { + "importer": "texture-cube-face", + "uuid": "5af201b5-5951-4e2c-a81f-ac4aad9132cb@b47c0@40c10", + "displayName": "", + "id": "40c10", + "name": "back", + "userData": {}, + "ver": "1.0.0", + "imported": true, + "files": [ + ".png", + ".json" + ], + "subMetas": {} + }, + "bb97f": { + "importer": "texture-cube-face", + "uuid": "5af201b5-5951-4e2c-a81f-ac4aad9132cb@b47c0@bb97f", + "displayName": "", + "id": "bb97f", + "name": "top", + "userData": {}, + "ver": "1.0.0", + "imported": true, + "files": [ + ".png", + ".json" + ], + "subMetas": {} + }, + "7d38f": { + "importer": "texture-cube-face", + "uuid": "5af201b5-5951-4e2c-a81f-ac4aad9132cb@b47c0@7d38f", + "displayName": "", + "id": "7d38f", + "name": "bottom", + "userData": {}, + "ver": "1.0.0", + "imported": true, + "files": [ + ".png", + ".json" + ], + "subMetas": {} + }, + "74afd": { + "importer": "texture-cube-face", + "uuid": "5af201b5-5951-4e2c-a81f-ac4aad9132cb@b47c0@74afd", + "displayName": "", + "id": "74afd", + "name": "right", + "userData": {}, + "ver": "1.0.0", + "imported": true, + "files": [ + ".png", + ".json" + ], + "subMetas": {} + }, + "8fd34": { + "importer": "texture-cube-face", + "uuid": "5af201b5-5951-4e2c-a81f-ac4aad9132cb@b47c0@8fd34", + "displayName": "", + "id": "8fd34", + "name": "left", + "userData": {}, + "ver": "1.0.0", + "imported": true, + "files": [ + ".png", + ".json" + ], + "subMetas": {} + } + } + } + }, + "userData": { + "hasAlpha": false, + "type": "texture cube", + "redirect": "5af201b5-5951-4e2c-a81f-ac4aad9132cb@b47c0" + } +} diff --git a/CameraFollowDemo/package.json b/CameraFollowDemo/package.json new file mode 100644 index 0000000..4b87188 --- /dev/null +++ b/CameraFollowDemo/package.json @@ -0,0 +1,9 @@ +{ + "name": "CameraFollowDemo", + "type": "3d", + "uuid": "c30b28da-749e-479b-bcb6-cecd8d7be9e3", + "version": "3.4.0", + "creator": { + "version": "3.4.0" + } +} diff --git a/CameraFollowDemo/settings/1.2.0/packages/builder.json b/CameraFollowDemo/settings/1.2.0/packages/builder.json new file mode 100644 index 0000000..ad47cd6 --- /dev/null +++ b/CameraFollowDemo/settings/1.2.0/packages/builder.json @@ -0,0 +1,3 @@ +{ + "__version__": "1.2.4" +} diff --git a/CameraFollowDemo/settings/1.2.0/packages/engine.json b/CameraFollowDemo/settings/1.2.0/packages/engine.json new file mode 100644 index 0000000..88d6913 --- /dev/null +++ b/CameraFollowDemo/settings/1.2.0/packages/engine.json @@ -0,0 +1,18 @@ +{ + "modules": { + "cache": {}, + "includeModules": [ + "base", + "gfx-webgl", + "gfx-webgl2", + "ui", + "particle", + "physics-cannon", + "physics-framework", + "audio", + "tween", + "terrain" + ] + }, + "__version__": "1.0.1" +} diff --git a/CameraFollowDemo/settings/1.2.0/packages/project.json b/CameraFollowDemo/settings/1.2.0/packages/project.json new file mode 100644 index 0000000..4e78796 --- /dev/null +++ b/CameraFollowDemo/settings/1.2.0/packages/project.json @@ -0,0 +1,7 @@ +{ + "__version__": "1.0.1", + "script": { + "useDefineForClassFields": false, + "allowDeclareFields": false + } +} diff --git a/CameraFollowDemo/settings/v2/packages/builder.json b/CameraFollowDemo/settings/v2/packages/builder.json new file mode 100644 index 0000000..be7f363 --- /dev/null +++ b/CameraFollowDemo/settings/v2/packages/builder.json @@ -0,0 +1,3 @@ +{ + "__version__": "1.3.0" +} diff --git a/CameraFollowDemo/settings/v2/packages/engine.json b/CameraFollowDemo/settings/v2/packages/engine.json new file mode 100644 index 0000000..0834809 --- /dev/null +++ b/CameraFollowDemo/settings/v2/packages/engine.json @@ -0,0 +1,30 @@ +{ + "modules": { + "cache": {}, + "includeModules": [ + "base", + "gfx-webgl", + "gfx-webgl2", + "3d", + "2d", + "ui", + "particle", + "physics-ammo", + "physics-2d-box2d", + "intersection-2d", + "primitive", + "profiler", + "particle-2d", + "audio", + "video", + "webview", + "tween", + "terrain", + "tiled-map", + "spine", + "dragon-bones", + "marionette" + ] + }, + "__version__": "1.0.5" +} diff --git a/CameraFollowDemo/settings/v2/packages/project.json b/CameraFollowDemo/settings/v2/packages/project.json new file mode 100644 index 0000000..4e78796 --- /dev/null +++ b/CameraFollowDemo/settings/v2/packages/project.json @@ -0,0 +1,7 @@ +{ + "__version__": "1.0.1", + "script": { + "useDefineForClassFields": false, + "allowDeclareFields": false + } +} diff --git a/CameraFollowDemo/tsconfig.json b/CameraFollowDemo/tsconfig.json new file mode 100644 index 0000000..7dc649a --- /dev/null +++ b/CameraFollowDemo/tsconfig.json @@ -0,0 +1,9 @@ +{ + /* Base configuration. Do not edit this field. */ + "extends": "./temp/tsconfig.cocos.json", + + /* Add your custom configuration here. */ + "compilerOptions": { + "strict": false + } +} diff --git a/CarTrack/assets/Script/CarTrack.js b/CarTrack/assets/Script/CarTrack.js index 7b49f87..1376328 100644 --- a/CarTrack/assets/Script/CarTrack.js +++ b/CarTrack/assets/Script/CarTrack.js @@ -11,7 +11,7 @@ cc.Class({ onLoad() { this.halfBoxLength = parseInt(this.boxLength / 2); this.perimeter = 0; - this.perimeterMax = 1000 + 500 * Math.PI; + this.perimeterMax = this.boxLength * 2 + this.r * 2 * Math.PI; }, registerEvent() { @@ -21,11 +21,12 @@ cc.Class({ }, /** - * 定义 - * 0到500为右直线 - * 500到500+PI*r为上半圆 - * 500+PI*r到1000+PI*r为左直线 - * 最后1000+2PI*4为下半圆 + * 原理:距离s=时间t*速度v + * 实现 -- 分割为四部分 + * 第一部分 -- 0到500为右直线 + * 第二部分 -- 500到500+PI*r为上半圆 + * 第三部分 -- 500+PI*r到1000+PI*r为左直线 + * 第四部分 -- 最后1000+2PI*4为下半圆 * @param {*} dt * @param {*} speed */ @@ -35,7 +36,7 @@ cc.Class({ let point = cc.v2(0, 0); if (this.perimeter <= this.boxLength) { point.x = this.r; - point.y = -250 + this.perimeter; + point.y = -this.halfBoxLength + this.perimeter; } else if (this.perimeter <= (this.boxLength + Math.PI * this.r)) { let length = this.perimeter - this.boxLength; let radian = length / this.r; @@ -43,7 +44,7 @@ cc.Class({ point.y = this.halfBoxLength + this.r * Math.sin(radian); } else if (this.perimeter <= (2 * this.boxLength + Math.PI * this.r)) { point.x = -this.r; - point.y = 250 - (this.perimeter - this.boxLength - Math.PI * this.r); + point.y = this.halfBoxLength - (this.perimeter - this.boxLength - Math.PI * this.r); } else { let length = this.perimeter - 2 * this.boxLength; let radian = length / this.r; @@ -53,42 +54,6 @@ cc.Class({ return point; }, - getTrackByPoint(point, length) { - console.log('getTrackByPoint'); - // point.x = Math.floor(point.x); - // point.y = Math.floor(point.y); - //效正由于半圆带来偏差 - if (point.x > this.r) { - point.x = this.r; - } else if (point.x < -this.r) { - point.x = -this.r; - } - console.log(Math.abs(point.y) <= this.halfBoxLength, point.x == this.r); - //box的右边轨道 - if (point.x == this.r && Math.abs(point.y) <= this.halfBoxLength) { - point.y += length; - return point; - //box的上半圆 - } else if (Math.abs(point.x) <= this.r && point.y >= this.halfBoxLength) { - //弧度 - let radian = length / this.r; - point.x = this.r * Math.cos(radian); - point.y = this.halfBoxLength + this.r * Math.sin(radian); - return point; - //左边 - } else if (point.x == -this.r && Math.abs(point.y) <= this.halfBoxLength) { - point.y -= length; - return point; - //下半圆 - } else if (Math.abs(point.x) < this.r && point.y <= - this.halfBoxLength) { - //弧度 - let radian = length / this.r; - point.x = this.r * Math.cos(radian); - point.y = -this.halfBoxLength - this.r * Math.sin(radian); - return point; - } - }, - update(dt) { // let point = this.nodeTarget.getPosition(); let movePoint = this.getPointByPerimeter(dt, this.speed); diff --git a/CarTrack/assets/Texture/HelloWorld.png.meta b/CarTrack/assets/Texture/HelloWorld.png.meta index efdbc77..9c52a59 100644 --- a/CarTrack/assets/Texture/HelloWorld.png.meta +++ b/CarTrack/assets/Texture/HelloWorld.png.meta @@ -1,10 +1,9 @@ { - "ver": "2.2.0", + "ver": "1.0.0", "uuid": "6aa0aa6a-ebee-4155-a088-a687a6aadec4", "type": "sprite", "wrapMode": "clamp", "filterMode": "bilinear", - "premultiplyAlpha": false, "subMetas": { "HelloWorld": { "ver": "1.0.3", diff --git a/CarTrack/assets/Texture/singleColor.png.meta b/CarTrack/assets/Texture/singleColor.png.meta index e3a0a2b..89cdf74 100644 --- a/CarTrack/assets/Texture/singleColor.png.meta +++ b/CarTrack/assets/Texture/singleColor.png.meta @@ -1,10 +1,9 @@ { - "ver": "2.2.0", + "ver": "1.0.0", "uuid": "a8027877-d8d6-4645-97a0-52d4a0123dba", "type": "sprite", "wrapMode": "clamp", "filterMode": "bilinear", - "premultiplyAlpha": false, "subMetas": { "singleColor": { "ver": "1.0.3", diff --git a/CreatorUtils/Emitter1.x.js b/CreatorUtils/Emitter1.x.js new file mode 100644 index 0000000..daefe6a --- /dev/null +++ b/CreatorUtils/Emitter1.x.js @@ -0,0 +1,169 @@ +module.exports = Emitter; + +/** + * Initialize a new `Emitter`. + * + * @api public + */ + +function Emitter(obj) { + if (obj) return mixin(obj); +} + +/** +将Emitter.prototype里面的所有属性都整合到obj + */ + +function mixin(obj) { + for (var key in Emitter.prototype) { + obj[key] = Emitter.prototype[key]; + } + return obj; +} + +/** +添加监听事件 + */ +Emitter.prototype.on = + Emitter.prototype.addEventListener = function (event, fn, context) { + this._callbacks = this._callbacks || {}; + this._contexts = this._contexts || {}; + let callBack = fn; + if (arguments.length == 3) { + callBack = function () { + try { + fn.apply(context, arguments); + } catch (error) { + console.error(error); + } + }; + callBack.fn = fn; + callBack.context = context; + callBack.event = event; + (this._contexts[context.__instanceId] = this._contexts[context.__instanceId] || []) + .push(callBack); + } + (this._callbacks[event] = this._callbacks[event] || []) + .push(callBack); + return this; + }; + +/** +添加事件,该事件只被触发一次,触发后会被移除 + */ +Emitter.prototype.once = function (event, fn, context) { + var self = this; + this._callbacks = this._callbacks || {}; + + function on() { + self.off(event, on); + try { + if (arguments.length == 3) { + fn.apply(context, arguments); + } else { + fn.apply(this, arguments); + } + } catch (error) { + console.error(error); + } + } + on.fn = fn; + this.on(event, on); + return this; +}; +/** + * + * @param {*} context + */ +Emitter.prototype.offThis = function (context) { + this._contexts = this._contexts || {}; + var contexts = this._contexts[context.__instanceId] || []; + let len = contexts.length; + for (let i = 0; i < len; i++) { + let callBack = contexts[i]; + this.off(callBack.event, callBack.fn, callBack.context); + } + if (this._contexts[context.__instanceId]) { + //删除 + delete this._contexts[context.__instanceId]; + } +}; + +/** +移除监听事件,当不传参数时,所有事件都会被移除 + */ +Emitter.prototype.off = + Emitter.prototype.removeListener = + Emitter.prototype.removeAllListeners = + Emitter.prototype.removeEventListener = function (event, fn, context) { + this._callbacks = this._callbacks || {}; + + // all + if (0 == arguments.length) { + this._callbacks = {}; + return this; + } + + // specific event + var callbacks = this._callbacks[event]; + if (!callbacks) return this; + + // remove all handlers + if (1 == arguments.length) { + delete this._callbacks[event]; + return this; + } + + // remove specific handler + var cb; + for (var i = 0; i < callbacks.length; i++) { + cb = callbacks[i]; + if (arguments.length == 2) { + if (cb === fn || cb.fn === fn) { + callbacks.splice(i, 1); + break; + } + } else if (arguments.length == 3) { + if (cb === fn || (cb.fn === fn && cb.context === context)) { + callbacks.splice(i, 1); + break; + } + } + } + return this; + }; + +/** +发送事件,当发送该事件时会触发相应的监听的回调函数 + */ +Emitter.prototype.emit = function (event) { + this._callbacks = this._callbacks || {}; + var args = [].slice.call(arguments, 1), + callbacks = this._callbacks[event]; + + if (callbacks) { + callbacks = callbacks.slice(0); + for (var i = 0, len = callbacks.length; i < len; ++i) { + callbacks[i].apply(this, args); + // callbacks[i](args); + + } + } + + return this; +}; + +/** +返回所有监听事件 + */ +Emitter.prototype.listeners = function (event) { + this._callbacks = this._callbacks || {}; + return this._callbacks[event] || []; +}; + +/** +返回监听事件的个数 + */ +Emitter.prototype.hasListeners = function (event) { + return !!this.listeners(event).length; +}; \ No newline at end of file diff --git a/CreatorUtils/Emitter2.x.js b/CreatorUtils/Emitter2.x.js new file mode 100644 index 0000000..3a70fda --- /dev/null +++ b/CreatorUtils/Emitter2.x.js @@ -0,0 +1,169 @@ +module.exports = Emitter; + +/** + * Initialize a new `Emitter`. + * + * @api public + */ + +function Emitter(obj) { + if (obj) return mixin(obj); +} + +/** +将Emitter.prototype里面的所有属性都整合到obj +*/ + +function mixin(obj) { + for (var key in Emitter.prototype) { + obj[key] = Emitter.prototype[key]; + } + return obj; +} + +/** +添加监听事件 + */ +Emitter.prototype.on = + Emitter.prototype.addEventListener = function (event, fn, context) { + this._callbacks = this._callbacks || {}; + this._contexts = this._contexts || {}; + let callBack = fn; + if (arguments.length == 3) { + callBack = function () { + try { + fn.apply(context, arguments); + } catch (error) { + console.error(error); + } + }; + callBack.fn = fn; + callBack.context = context; + callBack.event = event; + (this._contexts[context.uuid] = this._contexts[context.uuid] || []) + .push(callBack); + } + (this._callbacks[event] = this._callbacks[event] || []) + .push(callBack); + return this; + }; + +/** +添加事件,该事件只被触发一次,触发后会被移除 + */ +Emitter.prototype.once = function (event, fn, context) { + var self = this; + this._callbacks = this._callbacks || {}; + + function on() { + self.off(event, on); + try { + if (arguments.length == 3) { + fn.apply(context, arguments); + } else { + fn.apply(this, arguments); + } + } catch (error) { + console.error(error); + } + } + on.fn = fn; + this.on(event, on); + return this; +}; +/** + * + * @param {*} context + */ +Emitter.prototype.offAll = + Emitter.prototype.removeAllListeners = function (context) { + this._contexts = this._contexts || {}; + var contexts = this._contexts[context.uuid] || []; + let len = contexts.length; + for (let i = 0; i < len; i++) { + let callBack = contexts[i]; + this.off(callBack.event, callBack.fn, callBack.context); + } + if (this._contexts[context.uuid]) { + //删除 + delete this._contexts[context.uuid]; + } + }; + +/** +移除监听事件,当不传参数时,所有事件都会被移除 + */ +Emitter.prototype.off = + Emitter.prototype.removeListener = + Emitter.prototype.removeEventListener = function (event, fn, context) { + this._callbacks = this._callbacks || {}; + + // all + if (0 == arguments.length) { + this._callbacks = {}; + return this; + } + + // specific event + var callbacks = this._callbacks[event]; + if (!callbacks) return this; + + // remove all handlers + if (1 == arguments.length) { + delete this._callbacks[event]; + return this; + } + + // remove specific handler + var cb; + for (var i = 0; i < callbacks.length; i++) { + cb = callbacks[i]; + if (arguments.length == 2) { + if (cb === fn || cb.fn === fn) { + callbacks.splice(i, 1); + break; + } + } else if (arguments.length == 3) { + if (cb === fn || (cb.fn === fn && cb.context === context)) { + callbacks.splice(i, 1); + break; + } + } + } + return this; + }; + +/** +发送事件,当发送该事件时会触发相应的监听的回调函数 + */ +Emitter.prototype.emit = function (event) { + this._callbacks = this._callbacks || {}; + var args = [].slice.call(arguments, 1), + callbacks = this._callbacks[event]; + + if (callbacks) { + callbacks = callbacks.slice(0); + for (var i = 0, len = callbacks.length; i < len; ++i) { + callbacks[i].apply(this, args); + // callbacks[i](args); + + } + } + + return this; +}; + +/** +返回所有监听事件 + */ +Emitter.prototype.listeners = function (event) { + this._callbacks = this._callbacks || {}; + return this._callbacks[event] || []; +}; + +/** +返回监听事件的个数 + */ +Emitter.prototype.hasListeners = function (event) { + return !!this.listeners(event).length; +}; \ No newline at end of file diff --git a/CreatorUtils/UI/ButtonUtil.ts b/CreatorUtils/UI/ButtonUtil.ts new file mode 100644 index 0000000..4e882cf --- /dev/null +++ b/CreatorUtils/UI/ButtonUtil.ts @@ -0,0 +1,59 @@ +import { Button, Component, EventHandler, Node } from "cc"; + +/** + * 对button操作的简单封装 + * 版本为ccc 3.1.x + */ +export default class ButtonUtil { + + /** + * + * @param button 组件 + * @param node 事件所在脚本的节点 + * @param component 事件所在脚本 + * @param callback 事件名字 + * @param customData 数据 + */ + public static AddClick(button: Button, node: Node, component: string, callback: string, customData?: any) { + let clickEventHandler = new EventHandler(); + clickEventHandler.target = node; + clickEventHandler.component = component; + clickEventHandler.handler = callback; + clickEventHandler.customEventData = customData || null; + + button.clickEvents.push(clickEventHandler); + + } + + /** + * + * @param node 添加组件的节点 + * @param zoomScale 绽放因子 默认0.95 + * @returns + */ + public static AddScaleButton(node: Node, zoomScale: number = 0.95): Button { + let button = node.addComponent(Button); + button.target = node; + button.transition = Button.Transition.COLOR; + button.duration = 0.1; + button.zoomScale = zoomScale; + return button; + } + + /** + * + * @param button 组件 + * @param state 是否禁用状态 默认为false + */ + public static Interactable(button: Button | Node, state: boolean) { + if (button instanceof Button) { + button.interactable = state; + } else if (button instanceof Node) { + button = button.getComponent(Button)!; + button && (button.interactable = state); + } + } + + + +} \ No newline at end of file diff --git a/DisplayScrollViewDemo/.gitignore b/DisplayScrollViewDemo/.gitignore new file mode 100644 index 0000000..0c09bf3 --- /dev/null +++ b/DisplayScrollViewDemo/.gitignore @@ -0,0 +1,51 @@ +#///////////////////////////////////////////////////////////////////////////// +# Fireball Projects +#///////////////////////////////////////////////////////////////////////////// + +/library/ +/temp/ +/local/ +/build/ + +#///////////////////////////////////////////////////////////////////////////// +# npm files +#///////////////////////////////////////////////////////////////////////////// + +npm-debug.log +node_modules/ + +#///////////////////////////////////////////////////////////////////////////// +# Logs and databases +#///////////////////////////////////////////////////////////////////////////// + +*.log +*.sql +*.sqlite + +#///////////////////////////////////////////////////////////////////////////// +# files for debugger +#///////////////////////////////////////////////////////////////////////////// + +*.sln +*.pidb +*.suo + +#///////////////////////////////////////////////////////////////////////////// +# OS generated files +#///////////////////////////////////////////////////////////////////////////// + +.DS_Store +ehthumbs.db +Thumbs.db + +#///////////////////////////////////////////////////////////////////////////// +# WebStorm files +#///////////////////////////////////////////////////////////////////////////// + +.idea/ + +#////////////////////////// +# VS Code files +#////////////////////////// + +.vscode/ diff --git a/DisplayScrollViewDemo/README.md b/DisplayScrollViewDemo/README.md new file mode 100644 index 0000000..09b0019 --- /dev/null +++ b/DisplayScrollViewDemo/README.md @@ -0,0 +1,2 @@ +# hello-world +Hello world new project template. diff --git a/DisplayScrollViewDemo/assets/Display.meta b/DisplayScrollViewDemo/assets/Display.meta new file mode 100644 index 0000000..1033ff3 --- /dev/null +++ b/DisplayScrollViewDemo/assets/Display.meta @@ -0,0 +1,7 @@ +{ + "ver": "1.0.1", + "uuid": "9e85e619-6523-4291-9caf-cedf05542577", + "isSubpackage": false, + "subpackageName": "", + "subMetas": {} +} \ No newline at end of file diff --git a/DisplayScrollViewDemo/assets/Display/NavigateItem.ts b/DisplayScrollViewDemo/assets/Display/NavigateItem.ts new file mode 100644 index 0000000..e8932df --- /dev/null +++ b/DisplayScrollViewDemo/assets/Display/NavigateItem.ts @@ -0,0 +1,8 @@ + +export class NavigateItem { + public name: string = null; + public icon: string = null; + public appId: string = null; + public path: string = null; + public bgColor: string = null; +} diff --git a/DisplayScrollViewDemo/assets/Display/NavigateItem.ts.meta b/DisplayScrollViewDemo/assets/Display/NavigateItem.ts.meta new file mode 100644 index 0000000..89c5b88 --- /dev/null +++ b/DisplayScrollViewDemo/assets/Display/NavigateItem.ts.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.8", + "uuid": "f4e332f4-4dc0-47a1-aaeb-aa264ec86014", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/DisplayScrollViewDemo/assets/Display/NavigateItemPlusView.ts b/DisplayScrollViewDemo/assets/Display/NavigateItemPlusView.ts new file mode 100644 index 0000000..32ce767 --- /dev/null +++ b/DisplayScrollViewDemo/assets/Display/NavigateItemPlusView.ts @@ -0,0 +1,28 @@ + +import { NavigateItem } from "./NavigateItem"; +import NavigateItemView from "./NavigateItemView"; + +const { ccclass, property } = cc._decorator; + +@ccclass +export default class NavigateItemPlusView extends cc.Component { + + @property([NavigateItemView]) + list: NavigateItemView[] = []; + + // onLoad () {} + + start() { + + } + + init(data: NavigateItem[]) { + console.log('data', data); + for (let i = 0; i < data.length; i++) { + this.list[i].node.active = true; + this.list[i].init(data[i]); + } + } + + // update (dt) {} +} diff --git a/DisplayScrollViewDemo/assets/Display/NavigateItemPlusView.ts.meta b/DisplayScrollViewDemo/assets/Display/NavigateItemPlusView.ts.meta new file mode 100644 index 0000000..e1f78c1 --- /dev/null +++ b/DisplayScrollViewDemo/assets/Display/NavigateItemPlusView.ts.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.8", + "uuid": "f8380bfd-2c7e-4fde-95c3-dfc319499d9d", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/DisplayScrollViewDemo/assets/Display/NavigateItemView.ts b/DisplayScrollViewDemo/assets/Display/NavigateItemView.ts new file mode 100644 index 0000000..07192a1 --- /dev/null +++ b/DisplayScrollViewDemo/assets/Display/NavigateItemView.ts @@ -0,0 +1,64 @@ + +import { NavigateItem } from "./NavigateItem"; + +const { ccclass, property } = cc._decorator; + +@ccclass +export default class NavigateItemView extends cc.Component { + + @property(cc.Sprite) + icon: cc.Sprite = null; + + @property(cc.Node) + bg: cc.Node = null; + + @property(cc.Label) + title: cc.Label = null; + + private info: NavigateItem = null; + + // onLoad () {} + + start() { + + } + + init(data: NavigateItem) { + this.info = data; + this.title.string = this.info.name; + this.bg.color = (new cc.Color()).fromHEX(data.bgColor); + this.loadIcon(data.icon); + + } + + onEventClick(event, custom) { + console.log('info', this.info.name); + this.navigateGame(); + } + + navigateGame() { + if (!window['wx']) { + return; + } + window['wx'].navigateToMiniProgram({ + appId: this.info.appId, + path: this.info.path, + success(res) { + // 打开成功 + console.log('打开成功'); + }, + fail(res) { + console.log('打开失败', res); + } + }) + } + + loadIcon(url) { + cc.loader.load(url, (err, texture) => { + console.log('err', err, texture); + this.icon.spriteFrame = new cc.SpriteFrame(texture); + }) + } + + // update (dt) {} +} diff --git a/DisplayScrollViewDemo/assets/Display/NavigateItemView.ts.meta b/DisplayScrollViewDemo/assets/Display/NavigateItemView.ts.meta new file mode 100644 index 0000000..64d0605 --- /dev/null +++ b/DisplayScrollViewDemo/assets/Display/NavigateItemView.ts.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.8", + "uuid": "02d579a5-1f05-46ec-9204-b53a49636553", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/DisplayScrollViewDemo/assets/Display/NavigateView.ts b/DisplayScrollViewDemo/assets/Display/NavigateView.ts new file mode 100644 index 0000000..acf88f4 --- /dev/null +++ b/DisplayScrollViewDemo/assets/Display/NavigateView.ts @@ -0,0 +1,209 @@ +import NavigateItemView from "./NavigateItemView"; +import { NavigateItem } from "./NavigateItem"; +import NavigateItemPlusView from "./NavigateItemPlusView"; + +const { ccclass, property } = cc._decorator; + +enum Direct { + horizontal = 2, + vertical = 1, + grid = 3 +} + +const BgColorList = ['#edb879', '#1979a9', '#e07b39', '#69bdd2', '#80391e', '#cce7e8', '#b97455', '#44bcd8', '#7f39fb', '9acd32', '#ddbe5b']; + +@ccclass +export default class NavigateView extends cc.Component { + + @property(cc.Node) + content: cc.Node = null; + @property(cc.Node) + ItemPrefab: cc.Node = null; + + @property(cc.Vec2) + speed: cc.Vec2 = new cc.Vec2(-10, 10); + + @property({ type: cc.Enum(Direct) }) + public dir: number = 1; + + private itemSize: cc.Size = null; + private contentSize: cc.Size = null; + private startPos: cc.Vec2 = null; + private intervalSize: cc.Vec2 = null; + + //当前conetent显示最大个数 + private maxItemCount: cc.Vec2 = null; + //当前item个数 + private itemCount: cc.Vec2 = null; + + private direct: cc.Vec2 = new cc.Vec2(1, -1); + + private borderPos: cc.Vec2 = null; + + private itemList: Array = []; + + private isLoop: boolean = false; + + private showIndex: number = 0; + + private gameList: any[] = null; + + private columnCount = 3; + + // LIFE-CYCLE CALLBACKS: + + onLoad() { + this.itemSize = cc.size(this.ItemPrefab.width, this.ItemPrefab.height); + this.contentSize = cc.size(this.content.width, this.content.height); + //当前conetent显示最大个数 + this.maxItemCount = cc.v2(Math.floor(this.contentSize.width / this.itemSize.width), Math.floor(this.contentSize.height / this.itemSize.height)); + this.itemCount = cc.v2(this.maxItemCount.x + 2, this.maxItemCount.y + 2); + + this.borderPos = cc.v2(-1 * Math.abs(this.itemSize.width / 2), Math.abs(this.itemSize.height / 2)); + this.startPos = cc.v2(this.direct.x * this.itemSize.width / 2, this.direct.y * this.itemSize.height / 2); + this.intervalSize = cc.v2(this.direct.x * this.itemSize.width, Math.abs(this.direct.y * this.itemSize.height)); + if (this.dir == Direct.vertical || this.dir == Direct.grid) { + this.startPos.x = 0; + this.intervalSize.x = 0; + } else { + this.startPos.y = 0; + this.intervalSize.y = 0; + } + + this.initItems(); + this.onLoadData(); + } + + onLoadData() { + let data = []; + for (let i = 0; i < 10; i++) { + let item = new NavigateItem(); + item.appId = '' + i; + item.name = 'item_' + i; + data.push(item); + } + this.initList(data); + } + + start() { + + } + + initList(data: NavigateItem[]) { + let list: any[] = []; + //向上取整, + let len = Math.ceil(data.length / this.columnCount) * this.columnCount; + for (let i = 0; i < len; i++) { + let item = new NavigateItem(); + //铺满数据 + let pram = data[i % data.length]; + item.appId = pram.appId; + item.icon = pram.icon; + item.name = pram.name; + item.path = ''; + item.bgColor = BgColorList[i] || BgColorList[0]; + + if (this.dir != Direct.grid) { + list.push(item); + } else { + let row = Math.floor(i / this.columnCount); + if (list[row] == undefined) { + list.push([]); + } + list[row].push(item); + } + } + this.init(list); + } + + initItems() { + this.itemList.push(this.ItemPrefab); + this.ItemPrefab.position = cc.v2(this.startPos.x, this.startPos.y); + this.ItemPrefab.active = false; + let prop = 'x'; + if (this.dir == Direct.vertical || this.dir == Direct.grid) { + prop = 'y'; + } + for (let i = 1; i < this.itemCount[prop]; i++) { + let item = cc.instantiate(this.ItemPrefab); + this.content.addChild(item); + item.position = cc.v2(this.startPos.x + this.direct.x * this.intervalSize.x * i, this.startPos.y + this.direct.y * this.intervalSize.y * i); + item.name = 'item_' + i; + this.itemList.push(item); + } + } + + init(list: any[]) { + this.gameList = list; + let prop = 'x'; + if (this.dir == Direct.vertical || this.dir == Direct.grid) { + prop = 'y'; + } + + let len: number = list.length; + this.isLoop = true; + + len = this.itemCount[prop]; + //把this.itemCount成员设置数据 + for (let i = 0; i < len; i++) { + this.showIndex = i; + //可能出现len>this.gameList的情况。 + this.showIndex = (this.showIndex) % this.gameList.length; + let item = this.itemList[i]; + this.setItemInfo(item, list[this.showIndex]); + } + } + + /** + * + * @param node + * @param info NavigateItem or NavigateItem[] + */ + setItemInfo(node: cc.Node, info: any[]) { + node.active = true; + if (this.dir == Direct.grid) { + let view = node.getComponent(NavigateItemPlusView); + view.init(info); + } else { + let view = node.getComponent(NavigateItemView); + view.init(info); + } + } + + onLoop(dt) { + if (!this.isLoop) return; + let prop = 'x'; + if (this.dir == Direct.vertical || this.dir == Direct.grid) { + prop = 'y'; + } + let speed = this.speed[prop] * dt; + //移动 + this.itemList.forEach((item: cc.Node) => { + item[prop] += speed; + }); + + //是否过界 + this.itemList.forEach((item: cc.Node, i: number) => { + let isBorder = false; + if (this.dir == Direct.vertical || this.dir == Direct.grid) { + isBorder = item[prop] > this.borderPos[prop]; + } else { + isBorder = item[prop] < this.borderPos[prop]; + } + if (isBorder) { + //找到上一个item的位置 + let lastIndex = (i - 1 + this.itemList.length) % this.itemList.length; + //放到上一个item后面 + item[prop] = this.itemList[lastIndex][prop] + this.direct[prop] * this.intervalSize[prop]; + //当前显示的item下标 + this.showIndex = (this.showIndex + 1) % this.gameList.length; + this.setItemInfo(item, this.gameList[this.showIndex]); + } + + }) + } + + update(dt) { + this.onLoop(dt); + } +} diff --git a/DisplayScrollViewDemo/assets/Display/NavigateView.ts.meta b/DisplayScrollViewDemo/assets/Display/NavigateView.ts.meta new file mode 100644 index 0000000..89df13f --- /dev/null +++ b/DisplayScrollViewDemo/assets/Display/NavigateView.ts.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.8", + "uuid": "7e33b492-e399-42e2-959c-8d7dbc4544e2", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/DisplayScrollViewDemo/assets/Display/texture.meta b/DisplayScrollViewDemo/assets/Display/texture.meta new file mode 100644 index 0000000..192dd83 --- /dev/null +++ b/DisplayScrollViewDemo/assets/Display/texture.meta @@ -0,0 +1,7 @@ +{ + "ver": "1.0.1", + "uuid": "ffc3495c-3c1e-4036-83af-f9ded67d5acd", + "isSubpackage": false, + "subpackageName": "", + "subMetas": {} +} \ No newline at end of file diff --git a/DisplayScrollViewDemo/assets/Display/texture/di.png b/DisplayScrollViewDemo/assets/Display/texture/di.png new file mode 100644 index 0000000..750314d Binary files /dev/null and b/DisplayScrollViewDemo/assets/Display/texture/di.png differ diff --git a/DisplayScrollViewDemo/assets/Display/texture/di.png.meta b/DisplayScrollViewDemo/assets/Display/texture/di.png.meta new file mode 100644 index 0000000..17a7b7f --- /dev/null +++ b/DisplayScrollViewDemo/assets/Display/texture/di.png.meta @@ -0,0 +1,36 @@ +{ + "ver": "2.3.4", + "uuid": "6ae4cb63-9339-482d-8295-8de6d9aff9b1", + "type": "sprite", + "wrapMode": "clamp", + "filterMode": "bilinear", + "premultiplyAlpha": false, + "genMipmaps": false, + "packable": true, + "width": 162, + "height": 196, + "platformSettings": {}, + "subMetas": { + "di": { + "ver": "1.0.4", + "uuid": "c74d19dd-9ad1-42d2-9a21-c08de2224512", + "rawTextureUuid": "6ae4cb63-9339-482d-8295-8de6d9aff9b1", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 0, + "trimY": 0, + "width": 162, + "height": 196, + "rawWidth": 162, + "rawHeight": 196, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "subMetas": {} + } + } +} \ No newline at end of file diff --git a/DisplayScrollViewDemo/assets/Display/texture/kuang.png b/DisplayScrollViewDemo/assets/Display/texture/kuang.png new file mode 100644 index 0000000..72b0c7e Binary files /dev/null and b/DisplayScrollViewDemo/assets/Display/texture/kuang.png differ diff --git a/DisplayScrollViewDemo/assets/Display/texture/kuang.png.meta b/DisplayScrollViewDemo/assets/Display/texture/kuang.png.meta new file mode 100644 index 0000000..84e35ba --- /dev/null +++ b/DisplayScrollViewDemo/assets/Display/texture/kuang.png.meta @@ -0,0 +1,36 @@ +{ + "ver": "2.3.4", + "uuid": "49294db5-82ba-4c85-85c7-3fea9b4233a3", + "type": "sprite", + "wrapMode": "clamp", + "filterMode": "bilinear", + "premultiplyAlpha": false, + "genMipmaps": false, + "packable": true, + "width": 152, + "height": 152, + "platformSettings": {}, + "subMetas": { + "kuang": { + "ver": "1.0.4", + "uuid": "1634b135-4a2d-448a-acf5-0751ba3038d6", + "rawTextureUuid": "49294db5-82ba-4c85-85c7-3fea9b4233a3", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 0, + "trimY": 0, + "width": 152, + "height": 152, + "rawWidth": 152, + "rawHeight": 152, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "subMetas": {} + } + } +} \ No newline at end of file diff --git a/DisplayScrollViewDemo/assets/Scene.meta b/DisplayScrollViewDemo/assets/Scene.meta new file mode 100644 index 0000000..7da30b0 --- /dev/null +++ b/DisplayScrollViewDemo/assets/Scene.meta @@ -0,0 +1,6 @@ +{ + "ver": "1.0.1", + "uuid": "29f52784-2fca-467b-92e7-8fd9ef8c57b7", + "isGroup": false, + "subMetas": {} +} \ No newline at end of file diff --git a/DisplayScrollViewDemo/assets/Scene/helloworld.fire b/DisplayScrollViewDemo/assets/Scene/helloworld.fire new file mode 100644 index 0000000..9d3730e --- /dev/null +++ b/DisplayScrollViewDemo/assets/Scene/helloworld.fire @@ -0,0 +1,4072 @@ +[ + { + "__type__": "cc.SceneAsset", + "_name": "", + "_objFlags": 0, + "_native": "", + "scene": { + "__id__": 1 + } + }, + { + "__type__": "cc.Scene", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + } + ], + "_active": true, + "_components": [], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_is3DNode": true, + "_groupIndex": 0, + "groupIndex": 0, + "autoReleaseAssets": false, + "_id": "2d2f792f-a40c-49bb-a189-ed176a246e49" + }, + { + "__type__": "cc.Node", + "_name": "Canvas", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 3 + }, + { + "__id__": 5 + }, + { + "__id__": 8 + }, + { + "__id__": 10 + }, + { + "__id__": 12 + } + ], + "_active": true, + "_components": [ + { + "__id__": 86 + }, + { + "__id__": 87 + }, + { + "__id__": 88 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 252, + "g": 252, + "b": 252, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 960, + "height": 640 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 480, + 320, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "a286bbGknJLZpRpxROV6M94" + }, + { + "__type__": "cc.Node", + "_name": "Main Camera", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 4 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 272.84131931968614, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "bajsC4KotFLZ6XLFLKnycL" + }, + { + "__type__": "cc.Camera", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 3 + }, + "_enabled": true, + "_cullingMask": 4294967295, + "_clearFlags": 7, + "_backgroundColor": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_depth": -1, + "_zoomRatio": 1, + "_targetTexture": null, + "_fov": 60, + "_orthoSize": 10, + "_nearClip": 1, + "_farClip": 4096, + "_ortho": true, + "_rect": { + "__type__": "cc.Rect", + "x": 0, + "y": 0, + "width": 1, + "height": 1 + }, + "_renderStages": 1, + "_alignWithScreen": true, + "_id": "c7r5+B15dD56dUBiNj+0KH" + }, + { + "__type__": "cc.Node", + "_name": "background", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 6 + }, + { + "__id__": 7 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 27, + "g": 38, + "b": 46, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 960, + "height": 640 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "e2e0crkOLxGrpMxpbC4iQg1" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 5 + }, + "_enabled": true, + "alignMode": 1, + "_target": null, + "_alignFlags": 45, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 200, + "_originalHeight": 150, + "_id": "86+yud7pFDSrM+lsxByQvE" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 5 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "410fb916-8721-4663-bab8-34397391ace7" + }, + "_type": 1, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "1bi08CbSBHsZSXfV2t6eKB" + }, + { + "__type__": "cc.Node", + "_name": "cocos", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 9 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 195, + "height": 270 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 50, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "c4f30YOS65G64U2TwufdJ+2" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 8 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "31bc895a-c003-4566-a9f3-2e54ae1c17dc" + }, + "_type": 0, + "_sizeMode": 1, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "42SM+92GZAXYsjLj89MLM+" + }, + { + "__type__": "cc.Node", + "_name": "label", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 11 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 146.81, + "height": 75.6 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + -180, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "31f1bH7V69Ajr1iXhluMpTB" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 10 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_useOriginalSize": false, + "_string": "Label", + "_N$string": "Label", + "_fontSize": 60, + "_lineHeight": 60, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_styleFlags": 0, + "_underlineHeight": 0, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 0, + "_id": "74saCdhnNHjbyDsdd1bTTt" + }, + { + "__type__": "cc.Node", + "_name": "DisplayScrollView", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [ + { + "__id__": 13 + }, + { + "__id__": 28 + }, + { + "__id__": 43 + } + ], + "_active": true, + "_components": [], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "dfwKQU5tZN+YDXDcSNt109" + }, + { + "__type__": "cc.Node", + "_name": "NavigaeViewH", + "_objFlags": 0, + "_parent": { + "__id__": 12 + }, + "_children": [ + { + "__id__": 14 + }, + { + "__id__": 15 + } + ], + "_active": true, + "_components": [ + { + "__id__": 27 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 420, + "height": 120 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -248.876, + -236.733, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "fbWlC34BNLOIBX5LrVXIgk" + }, + { + "__type__": "cc.Node", + "_name": "bg", + "_objFlags": 0, + "_parent": { + "__id__": 13 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "54LOwLKmhHP5LwNzZwIbdD" + }, + { + "__type__": "cc.Node", + "_name": "content", + "_objFlags": 0, + "_parent": { + "__id__": 13 + }, + "_children": [ + { + "__id__": 16 + } + ], + "_active": true, + "_components": [ + { + "__id__": 26 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 400, + "height": 120 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -200, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "a7tun/HalNvKUx5dBgm33Q" + }, + { + "__type__": "cc.Node", + "_name": "Item_0", + "_objFlags": 0, + "_parent": { + "__id__": 15 + }, + "_children": [ + { + "__id__": 17 + }, + { + "__id__": 19 + }, + { + "__id__": 21 + } + ], + "_active": true, + "_components": [ + { + "__id__": 23 + }, + { + "__id__": 24 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 120 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 50, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "90t6Yk1JhBW7F5163VP2nM" + }, + { + "__type__": "cc.Node", + "_name": "bg", + "_objFlags": 0, + "_parent": { + "__id__": 16 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 18 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 74, + "g": 48, + "b": 48, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 120 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "8fwl/5jk9Kjbg/kh7tvXK/" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 17 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "5fjZq06TdOQrqOR2zRLL3f" + }, + { + "__type__": "cc.Node", + "_name": "icon", + "_objFlags": 0, + "_parent": { + "__id__": 16 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 20 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 90, + "height": 90 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 12.5, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "1c1UGhlm1JtKHqLZ7WpMNQ" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 19 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "d4bqDDEnxK7aMzFRqGDZcL" + }, + { + "__type__": "cc.Node", + "_name": "name", + "_objFlags": 0, + "_parent": { + "__id__": 16 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 22 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 90, + "height": 22.68 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + -45.153, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "70FDw3cWVLt4nyahBPbri4" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 21 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_useOriginalSize": false, + "_string": "aaaaaaaaa", + "_N$string": "aaaaaaaaa", + "_fontSize": 16, + "_lineHeight": 18, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_styleFlags": 0, + "_underlineHeight": 0, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 2, + "_N$cacheMode": 0, + "_id": "68SZnIuXVPGLQFpfETVIj3" + }, + { + "__type__": "02d57mlHwVG7JIEtTpJY2VT", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 16 + }, + "_enabled": true, + "icon": { + "__id__": 20 + }, + "bg": { + "__id__": 17 + }, + "title": { + "__id__": 22 + }, + "_id": "acCh85UAVErqRjCapftklW" + }, + { + "__type__": "cc.Button", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 16 + }, + "_enabled": true, + "_normalMaterial": null, + "_grayMaterial": null, + "duration": 0.1, + "zoomScale": 1.2, + "clickEvents": [ + { + "__id__": 25 + } + ], + "_N$interactable": true, + "_N$enableAutoGrayEffect": false, + "_N$transition": 0, + "transition": 0, + "_N$normalColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$pressedColor": { + "__type__": "cc.Color", + "r": 211, + "g": 211, + "b": 211, + "a": 255 + }, + "pressedColor": { + "__type__": "cc.Color", + "r": 211, + "g": 211, + "b": 211, + "a": 255 + }, + "_N$hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$disabledColor": { + "__type__": "cc.Color", + "r": 124, + "g": 124, + "b": 124, + "a": 255 + }, + "_N$normalSprite": null, + "_N$pressedSprite": null, + "pressedSprite": null, + "_N$hoverSprite": null, + "hoverSprite": null, + "_N$disabledSprite": null, + "_N$target": { + "__id__": 16 + }, + "_id": "2cxjLiC2JFPIgs22SRhcdd" + }, + { + "__type__": "cc.ClickEvent", + "target": { + "__id__": 16 + }, + "component": "", + "_componentId": "02d57mlHwVG7JIEtTpJY2VT", + "handler": "onEventClick", + "customEventData": "" + }, + { + "__type__": "cc.Mask", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 15 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_spriteFrame": null, + "_type": 0, + "_segments": 64, + "_N$alphaThreshold": 0.1, + "_N$inverted": false, + "_id": "c5Cc8T19lCwobppQHR0PLd" + }, + { + "__type__": "7e33bSS45lC4pWcjX28RUTi", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 13 + }, + "_enabled": true, + "content": { + "__id__": 15 + }, + "ItemPrefab": { + "__id__": 16 + }, + "speed": { + "__type__": "cc.Vec2", + "x": -10, + "y": 0 + }, + "dir": 2, + "_id": "b2iIJ8OklHZ5aUVxUiHfls" + }, + { + "__type__": "cc.Node", + "_name": "NavigaeViewV", + "_objFlags": 0, + "_parent": { + "__id__": 12 + }, + "_children": [ + { + "__id__": 29 + }, + { + "__id__": 30 + } + ], + "_active": true, + "_components": [ + { + "__id__": 42 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 420 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -377.781, + 93.086, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "9dNk9h4e9HsZYIjEB/+dwL" + }, + { + "__type__": "cc.Node", + "_name": "bg", + "_objFlags": 0, + "_parent": { + "__id__": 28 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "885Ih+ExtEk5Mg8BtSGUeJ" + }, + { + "__type__": "cc.Node", + "_name": "content", + "_objFlags": 0, + "_parent": { + "__id__": 28 + }, + "_children": [ + { + "__id__": 31 + } + ], + "_active": true, + "_components": [ + { + "__id__": 41 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 400 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 1 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 210, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "cdbqqg2R1C+7KuAEOsmiuH" + }, + { + "__type__": "cc.Node", + "_name": "Item_0", + "_objFlags": 0, + "_parent": { + "__id__": 30 + }, + "_children": [ + { + "__id__": 32 + }, + { + "__id__": 34 + }, + { + "__id__": 36 + } + ], + "_active": true, + "_components": [ + { + "__id__": 38 + }, + { + "__id__": 39 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 120 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + -60, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "d1Ktr7UXdIAb2tTsRWn1Ns" + }, + { + "__type__": "cc.Node", + "_name": "bg", + "_objFlags": 0, + "_parent": { + "__id__": 31 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 33 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 74, + "g": 48, + "b": 48, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 120 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "eaW0+QwipFp4NNs1U5xcl6" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 32 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "0bJpbPaylLlZur5JR+OH1u" + }, + { + "__type__": "cc.Node", + "_name": "icon", + "_objFlags": 0, + "_parent": { + "__id__": 31 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 35 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 90, + "height": 90 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 12.5, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "61AGG+iZVMiZNnhY3AItPM" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 34 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "1cD/FKTIZO4qXY2WdYZt/A" + }, + { + "__type__": "cc.Node", + "_name": "name", + "_objFlags": 0, + "_parent": { + "__id__": 31 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 37 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 90, + "height": 22.68 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + -45.153, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "d7irJs+iRJYb+97KtAva9v" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 36 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_useOriginalSize": false, + "_string": "aaaaaaaaa", + "_N$string": "aaaaaaaaa", + "_fontSize": 16, + "_lineHeight": 18, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_styleFlags": 0, + "_underlineHeight": 0, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 2, + "_N$cacheMode": 0, + "_id": "77nr521TFGPayLHBt2XnpR" + }, + { + "__type__": "02d57mlHwVG7JIEtTpJY2VT", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 31 + }, + "_enabled": true, + "icon": { + "__id__": 35 + }, + "bg": { + "__id__": 32 + }, + "title": { + "__id__": 37 + }, + "_id": "c4Et8iyUlFgY7+pwEdKvnI" + }, + { + "__type__": "cc.Button", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 31 + }, + "_enabled": true, + "_normalMaterial": null, + "_grayMaterial": null, + "duration": 0.1, + "zoomScale": 1.2, + "clickEvents": [ + { + "__id__": 40 + } + ], + "_N$interactable": true, + "_N$enableAutoGrayEffect": false, + "_N$transition": 0, + "transition": 0, + "_N$normalColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$pressedColor": { + "__type__": "cc.Color", + "r": 211, + "g": 211, + "b": 211, + "a": 255 + }, + "pressedColor": { + "__type__": "cc.Color", + "r": 211, + "g": 211, + "b": 211, + "a": 255 + }, + "_N$hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$disabledColor": { + "__type__": "cc.Color", + "r": 124, + "g": 124, + "b": 124, + "a": 255 + }, + "_N$normalSprite": null, + "_N$pressedSprite": null, + "pressedSprite": null, + "_N$hoverSprite": null, + "hoverSprite": null, + "_N$disabledSprite": null, + "_N$target": { + "__id__": 31 + }, + "_id": "58dE7QPgRPrZzYv/4w6cvL" + }, + { + "__type__": "cc.ClickEvent", + "target": { + "__id__": 31 + }, + "component": "", + "_componentId": "02d57mlHwVG7JIEtTpJY2VT", + "handler": "onEventClick", + "customEventData": "" + }, + { + "__type__": "cc.Mask", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 30 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_spriteFrame": null, + "_type": 0, + "_segments": 64, + "_N$alphaThreshold": 0.1, + "_N$inverted": false, + "_id": "b0ThClyw1InKk2pN/j9nxY" + }, + { + "__type__": "7e33bSS45lC4pWcjX28RUTi", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 28 + }, + "_enabled": true, + "content": { + "__id__": 30 + }, + "ItemPrefab": { + "__id__": 31 + }, + "speed": { + "__type__": "cc.Vec2", + "x": 0, + "y": 10 + }, + "dir": 1, + "_id": "57AfOGJqZGiLlloGNOEiAA" + }, + { + "__type__": "cc.Node", + "_name": "NavigaeViewG", + "_objFlags": 0, + "_parent": { + "__id__": 12 + }, + "_children": [ + { + "__id__": 44 + }, + { + "__id__": 45 + } + ], + "_active": true, + "_components": [ + { + "__id__": 85 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 492, + "height": 620 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 262.518, + 47.192, + 0, + 0, + 0, + 0, + 1, + 0.8, + 0.8, + 0.8 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "b84x1MIxVFCIX1aeZHg8+e" + }, + { + "__type__": "cc.Node", + "_name": "bg", + "_objFlags": 0, + "_parent": { + "__id__": 43 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "e7TeOiDk9CA6uQsLyMGUtM" + }, + { + "__type__": "cc.Node", + "_name": "content", + "_objFlags": 0, + "_parent": { + "__id__": 43 + }, + "_children": [ + { + "__id__": 46 + } + ], + "_active": true, + "_components": [ + { + "__id__": 84 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 492, + "height": 620 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 1 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 320, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "cfTh1TQG1MFos4+m3wT2th" + }, + { + "__type__": "cc.Node", + "_name": "Item_0", + "_objFlags": 0, + "_parent": { + "__id__": 45 + }, + "_children": [ + { + "__id__": 47 + }, + { + "__id__": 59 + }, + { + "__id__": 71 + } + ], + "_active": true, + "_components": [ + { + "__id__": 83 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 492, + "height": 196 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + -98, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "ffTqghJ8xIZ5s5gqTSbj9/" + }, + { + "__type__": "cc.Node", + "_name": "Item_0", + "_objFlags": 0, + "_parent": { + "__id__": 46 + }, + "_children": [ + { + "__id__": 48 + }, + { + "__id__": 50 + }, + { + "__id__": 52 + }, + { + "__id__": 54 + } + ], + "_active": true, + "_components": [ + { + "__id__": 56 + }, + { + "__id__": 57 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 162, + "height": 196 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -164, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "a7gZfuzV1PIpdH818wz0+y" + }, + { + "__type__": "cc.Node", + "_name": "bg", + "_objFlags": 0, + "_parent": { + "__id__": 47 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 49 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 74, + "g": 48, + "b": 48, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 162, + "height": 192 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "4bpF/w3wxFnqE2mKXInWEt" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 48 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "c74d19dd-9ad1-42d2-9a21-c08de2224512" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "713GplxvRD1pKVVn7OQNvw" + }, + { + "__type__": "cc.Node", + "_name": "icon", + "_objFlags": 0, + "_parent": { + "__id__": 47 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 51 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 146, + "height": 146 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 16.098, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "9ajC+ngZBGfpkkqqlOBEVB" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 50 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "1a7m25OsRBA61oGevrZeI1" + }, + { + "__type__": "cc.Node", + "_name": "kuang", + "_objFlags": 0, + "_parent": { + "__id__": 47 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 53 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 152, + "height": 152 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 14.34, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "837ZTzuFFAwYozQVJXIxC/" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 52 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "1634b135-4a2d-448a-acf5-0751ba3038d6" + }, + "_type": 0, + "_sizeMode": 1, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "faSRwn7fBFY7/0/OTBRPz/" + }, + { + "__type__": "cc.Node", + "_name": "name", + "_objFlags": 0, + "_parent": { + "__id__": 47 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 55 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 90, + "height": 22.68 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + -76.241, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "e82gWgY6NCRKyaiwlu3YgD" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 54 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_useOriginalSize": false, + "_string": "aaaaaaaaa", + "_N$string": "aaaaaaaaa", + "_fontSize": 16, + "_lineHeight": 18, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_styleFlags": 0, + "_underlineHeight": 0, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 2, + "_N$cacheMode": 0, + "_id": "90DCcxYT9JXb0cK8iZ5t5j" + }, + { + "__type__": "02d57mlHwVG7JIEtTpJY2VT", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 47 + }, + "_enabled": true, + "icon": { + "__id__": 51 + }, + "bg": { + "__id__": 48 + }, + "title": { + "__id__": 55 + }, + "_id": "0fu/hGDapHtrs1tk4yRzjk" + }, + { + "__type__": "cc.Button", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 47 + }, + "_enabled": true, + "_normalMaterial": null, + "_grayMaterial": null, + "duration": 0.1, + "zoomScale": 1.2, + "clickEvents": [ + { + "__id__": 58 + } + ], + "_N$interactable": true, + "_N$enableAutoGrayEffect": false, + "_N$transition": 0, + "transition": 0, + "_N$normalColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$pressedColor": { + "__type__": "cc.Color", + "r": 211, + "g": 211, + "b": 211, + "a": 255 + }, + "pressedColor": { + "__type__": "cc.Color", + "r": 211, + "g": 211, + "b": 211, + "a": 255 + }, + "_N$hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$disabledColor": { + "__type__": "cc.Color", + "r": 124, + "g": 124, + "b": 124, + "a": 255 + }, + "_N$normalSprite": null, + "_N$pressedSprite": null, + "pressedSprite": null, + "_N$hoverSprite": null, + "hoverSprite": null, + "_N$disabledSprite": null, + "_N$target": { + "__id__": 47 + }, + "_id": "5fiQxkWKtIUpL6McYpI6c8" + }, + { + "__type__": "cc.ClickEvent", + "target": { + "__id__": 47 + }, + "component": "", + "_componentId": "02d57mlHwVG7JIEtTpJY2VT", + "handler": "onEventClick", + "customEventData": "" + }, + { + "__type__": "cc.Node", + "_name": "Item_1", + "_objFlags": 0, + "_parent": { + "__id__": 46 + }, + "_children": [ + { + "__id__": 60 + }, + { + "__id__": 62 + }, + { + "__id__": 64 + }, + { + "__id__": 66 + } + ], + "_active": true, + "_components": [ + { + "__id__": 68 + }, + { + "__id__": 69 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 162, + "height": 196 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "9dA0dmC8NJcr3cves4dJ99" + }, + { + "__type__": "cc.Node", + "_name": "bg", + "_objFlags": 0, + "_parent": { + "__id__": 59 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 61 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 74, + "g": 48, + "b": 48, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 162, + "height": 192 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "bbx1/6cG5JD6ccr1koT17A" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 60 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "c74d19dd-9ad1-42d2-9a21-c08de2224512" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "2aP5VF1MlJ8rKxm8niwZsb" + }, + { + "__type__": "cc.Node", + "_name": "icon", + "_objFlags": 0, + "_parent": { + "__id__": 59 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 63 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 146, + "height": 146 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 16.098, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "a3g5HHGJtDOKKY+yIHfDdN" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 62 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "951RJllINHS5wECR6FAuQI" + }, + { + "__type__": "cc.Node", + "_name": "kuang", + "_objFlags": 0, + "_parent": { + "__id__": 59 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 65 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 152, + "height": 152 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 14.34, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "51FiyK2kpEk7cHpUXXwgiW" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 64 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "1634b135-4a2d-448a-acf5-0751ba3038d6" + }, + "_type": 0, + "_sizeMode": 1, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "87n8i0RqhIRqOA0167S9RE" + }, + { + "__type__": "cc.Node", + "_name": "name", + "_objFlags": 0, + "_parent": { + "__id__": 59 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 67 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 90, + "height": 22.68 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + -76.241, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "96iSUK21NE4aB0uH7+1Veq" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 66 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_useOriginalSize": false, + "_string": "aaaaaaaaa", + "_N$string": "aaaaaaaaa", + "_fontSize": 16, + "_lineHeight": 18, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_styleFlags": 0, + "_underlineHeight": 0, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 2, + "_N$cacheMode": 0, + "_id": "eaYjPUyGBG8aH+5VpADirJ" + }, + { + "__type__": "02d57mlHwVG7JIEtTpJY2VT", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 59 + }, + "_enabled": true, + "icon": { + "__id__": 63 + }, + "bg": { + "__id__": 60 + }, + "title": { + "__id__": 67 + }, + "_id": "3bPK6pGK5AL7RP1wEg3yxv" + }, + { + "__type__": "cc.Button", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 59 + }, + "_enabled": true, + "_normalMaterial": null, + "_grayMaterial": null, + "duration": 0.1, + "zoomScale": 1.2, + "clickEvents": [ + { + "__id__": 70 + } + ], + "_N$interactable": true, + "_N$enableAutoGrayEffect": false, + "_N$transition": 0, + "transition": 0, + "_N$normalColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$pressedColor": { + "__type__": "cc.Color", + "r": 211, + "g": 211, + "b": 211, + "a": 255 + }, + "pressedColor": { + "__type__": "cc.Color", + "r": 211, + "g": 211, + "b": 211, + "a": 255 + }, + "_N$hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$disabledColor": { + "__type__": "cc.Color", + "r": 124, + "g": 124, + "b": 124, + "a": 255 + }, + "_N$normalSprite": null, + "_N$pressedSprite": null, + "pressedSprite": null, + "_N$hoverSprite": null, + "hoverSprite": null, + "_N$disabledSprite": null, + "_N$target": { + "__id__": 59 + }, + "_id": "aehmZdXgBJx6zUGORbKjd3" + }, + { + "__type__": "cc.ClickEvent", + "target": { + "__id__": 59 + }, + "component": "", + "_componentId": "02d57mlHwVG7JIEtTpJY2VT", + "handler": "onEventClick", + "customEventData": "" + }, + { + "__type__": "cc.Node", + "_name": "Item_2", + "_objFlags": 0, + "_parent": { + "__id__": 46 + }, + "_children": [ + { + "__id__": 72 + }, + { + "__id__": 74 + }, + { + "__id__": 76 + }, + { + "__id__": 78 + } + ], + "_active": true, + "_components": [ + { + "__id__": 80 + }, + { + "__id__": 81 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 162, + "height": 196 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 164, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "beyG9QDCxGPJwutQhPf14V" + }, + { + "__type__": "cc.Node", + "_name": "bg", + "_objFlags": 0, + "_parent": { + "__id__": 71 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 73 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 74, + "g": 48, + "b": 48, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 162, + "height": 192 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "49G13U04tHBqkn11uvtzof" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 72 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "c74d19dd-9ad1-42d2-9a21-c08de2224512" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "84/p+Z/JZNKoA26FfcYPlK" + }, + { + "__type__": "cc.Node", + "_name": "icon", + "_objFlags": 0, + "_parent": { + "__id__": 71 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 75 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 146, + "height": 146 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 16.098, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "1dP+Bh0ZhLpo0keGfiWcgD" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 74 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "9ak1KychBGHaFnz35RgNLV" + }, + { + "__type__": "cc.Node", + "_name": "kuang", + "_objFlags": 0, + "_parent": { + "__id__": 71 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 77 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 152, + "height": 152 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 14.34, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "3d2xVMLFxNxYvNC8l/CuOj" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 76 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "1634b135-4a2d-448a-acf5-0751ba3038d6" + }, + "_type": 0, + "_sizeMode": 1, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "a1QdT4tBVNvpy1kpeWCLy2" + }, + { + "__type__": "cc.Node", + "_name": "name", + "_objFlags": 0, + "_parent": { + "__id__": 71 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 79 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 90, + "height": 22.68 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + -76.241, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "ddjjKtcJFEnKxx5xB5bNS0" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 78 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_useOriginalSize": false, + "_string": "aaaaaaaaa", + "_N$string": "aaaaaaaaa", + "_fontSize": 16, + "_lineHeight": 18, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_styleFlags": 0, + "_underlineHeight": 0, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 2, + "_N$cacheMode": 0, + "_id": "e7COkyq6tJFK/NZUZPrYtQ" + }, + { + "__type__": "02d57mlHwVG7JIEtTpJY2VT", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 71 + }, + "_enabled": true, + "icon": { + "__id__": 75 + }, + "bg": { + "__id__": 72 + }, + "title": { + "__id__": 79 + }, + "_id": "5a7d7p3SVNXafKyzyorZgH" + }, + { + "__type__": "cc.Button", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 71 + }, + "_enabled": true, + "_normalMaterial": null, + "_grayMaterial": null, + "duration": 0.1, + "zoomScale": 1.2, + "clickEvents": [ + { + "__id__": 82 + } + ], + "_N$interactable": true, + "_N$enableAutoGrayEffect": false, + "_N$transition": 0, + "transition": 0, + "_N$normalColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$pressedColor": { + "__type__": "cc.Color", + "r": 211, + "g": 211, + "b": 211, + "a": 255 + }, + "pressedColor": { + "__type__": "cc.Color", + "r": 211, + "g": 211, + "b": 211, + "a": 255 + }, + "_N$hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$disabledColor": { + "__type__": "cc.Color", + "r": 124, + "g": 124, + "b": 124, + "a": 255 + }, + "_N$normalSprite": null, + "_N$pressedSprite": null, + "pressedSprite": null, + "_N$hoverSprite": null, + "hoverSprite": null, + "_N$disabledSprite": null, + "_N$target": { + "__id__": 71 + }, + "_id": "13V9kl7ctC5KnTnBlktrQH" + }, + { + "__type__": "cc.ClickEvent", + "target": { + "__id__": 71 + }, + "component": "", + "_componentId": "02d57mlHwVG7JIEtTpJY2VT", + "handler": "onEventClick", + "customEventData": "" + }, + { + "__type__": "f8380v9LH5P3pXD38MZSZ2d", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 46 + }, + "_enabled": true, + "list": [ + { + "__id__": 56 + }, + { + "__id__": 68 + }, + { + "__id__": 80 + } + ], + "_id": "a5EPVtiz9FCbrClOeXfNj8" + }, + { + "__type__": "cc.Mask", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 45 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_spriteFrame": null, + "_type": 0, + "_segments": 64, + "_N$alphaThreshold": 0.1, + "_N$inverted": false, + "_id": "dcNiRrnx9JCZF/b0tCuIaf" + }, + { + "__type__": "7e33bSS45lC4pWcjX28RUTi", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 43 + }, + "_enabled": true, + "content": { + "__id__": 45 + }, + "ItemPrefab": { + "__id__": 46 + }, + "speed": { + "__type__": "cc.Vec2", + "x": 0, + "y": 10 + }, + "dir": 3, + "_id": "fadbnCOrZH7oL3ycZ5igS7" + }, + { + "__type__": "cc.Canvas", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "_designResolution": { + "__type__": "cc.Size", + "width": 960, + "height": 640 + }, + "_fitWidth": false, + "_fitHeight": true, + "_id": "6f5cteKmlPh6NGUsUqxlFR" + }, + { + "__type__": "280c3rsZJJKnZ9RqbALVwtK", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "label": { + "__id__": 11 + }, + "text": "Hello, World!", + "_id": "dcGJ+cSA5D7qNtScKfLjJJ" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "alignMode": 1, + "_target": null, + "_alignFlags": 45, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 0, + "_originalHeight": 0, + "_id": "7ai1UWo5ZIz7+20mmbj2go" + } +] \ No newline at end of file diff --git a/DisplayScrollViewDemo/assets/Scene/helloworld.fire.meta b/DisplayScrollViewDemo/assets/Scene/helloworld.fire.meta new file mode 100644 index 0000000..bf0b7c0 --- /dev/null +++ b/DisplayScrollViewDemo/assets/Scene/helloworld.fire.meta @@ -0,0 +1,7 @@ +{ + "ver": "1.2.7", + "uuid": "2d2f792f-a40c-49bb-a189-ed176a246e49", + "asyncLoadAssets": false, + "autoReleaseAssets": false, + "subMetas": {} +} \ No newline at end of file diff --git a/DisplayScrollViewDemo/assets/Script.meta b/DisplayScrollViewDemo/assets/Script.meta new file mode 100644 index 0000000..7259168 --- /dev/null +++ b/DisplayScrollViewDemo/assets/Script.meta @@ -0,0 +1,6 @@ +{ + "ver": "1.0.1", + "uuid": "4734c20c-0db8-4eb2-92ea-e692f4d70934", + "isGroup": false, + "subMetas": {} +} \ No newline at end of file diff --git a/DisplayScrollViewDemo/assets/Script/HelloWorld.js b/DisplayScrollViewDemo/assets/Script/HelloWorld.js new file mode 100644 index 0000000..b8d80cc --- /dev/null +++ b/DisplayScrollViewDemo/assets/Script/HelloWorld.js @@ -0,0 +1,22 @@ +cc.Class({ + extends: cc.Component, + + properties: { + label: { + default: null, + type: cc.Label + }, + // defaults, set visually when attaching this script to the Canvas + text: 'Hello, World!' + }, + + // use this for initialization + onLoad: function () { + this.label.string = this.text; + }, + + // called every frame + update: function (dt) { + + }, +}); diff --git a/DisplayScrollViewDemo/assets/Script/HelloWorld.js.meta b/DisplayScrollViewDemo/assets/Script/HelloWorld.js.meta new file mode 100644 index 0000000..e805d60 --- /dev/null +++ b/DisplayScrollViewDemo/assets/Script/HelloWorld.js.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.8", + "uuid": "280c3aec-6492-4a9d-9f51-a9b00b570b4a", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/DisplayScrollViewDemo/assets/Texture.meta b/DisplayScrollViewDemo/assets/Texture.meta new file mode 100644 index 0000000..f483d19 --- /dev/null +++ b/DisplayScrollViewDemo/assets/Texture.meta @@ -0,0 +1,6 @@ +{ + "ver": "1.0.1", + "uuid": "7b81d4e8-ec84-4716-968d-500ac1d78a54", + "isGroup": false, + "subMetas": {} +} \ No newline at end of file diff --git a/DisplayScrollViewDemo/assets/Texture/HelloWorld.png b/DisplayScrollViewDemo/assets/Texture/HelloWorld.png new file mode 100644 index 0000000..21d4326 Binary files /dev/null and b/DisplayScrollViewDemo/assets/Texture/HelloWorld.png differ diff --git a/DisplayScrollViewDemo/assets/Texture/HelloWorld.png.meta b/DisplayScrollViewDemo/assets/Texture/HelloWorld.png.meta new file mode 100644 index 0000000..478c5ff --- /dev/null +++ b/DisplayScrollViewDemo/assets/Texture/HelloWorld.png.meta @@ -0,0 +1,36 @@ +{ + "ver": "2.3.4", + "uuid": "6aa0aa6a-ebee-4155-a088-a687a6aadec4", + "type": "sprite", + "wrapMode": "clamp", + "filterMode": "bilinear", + "premultiplyAlpha": false, + "genMipmaps": false, + "packable": true, + "width": 195, + "height": 270, + "platformSettings": {}, + "subMetas": { + "HelloWorld": { + "ver": "1.0.4", + "uuid": "31bc895a-c003-4566-a9f3-2e54ae1c17dc", + "rawTextureUuid": "6aa0aa6a-ebee-4155-a088-a687a6aadec4", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 0, + "trimY": 0, + "width": 195, + "height": 270, + "rawWidth": 195, + "rawHeight": 270, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "subMetas": {} + } + } +} \ No newline at end of file diff --git a/DisplayScrollViewDemo/assets/Texture/singleColor.png b/DisplayScrollViewDemo/assets/Texture/singleColor.png new file mode 100644 index 0000000..fa6376e Binary files /dev/null and b/DisplayScrollViewDemo/assets/Texture/singleColor.png differ diff --git a/DisplayScrollViewDemo/assets/Texture/singleColor.png.meta b/DisplayScrollViewDemo/assets/Texture/singleColor.png.meta new file mode 100644 index 0000000..906e91a --- /dev/null +++ b/DisplayScrollViewDemo/assets/Texture/singleColor.png.meta @@ -0,0 +1,36 @@ +{ + "ver": "2.3.4", + "uuid": "a8027877-d8d6-4645-97a0-52d4a0123dba", + "type": "sprite", + "wrapMode": "clamp", + "filterMode": "bilinear", + "premultiplyAlpha": false, + "genMipmaps": false, + "packable": true, + "width": 2, + "height": 2, + "platformSettings": {}, + "subMetas": { + "singleColor": { + "ver": "1.0.4", + "uuid": "410fb916-8721-4663-bab8-34397391ace7", + "rawTextureUuid": "a8027877-d8d6-4645-97a0-52d4a0123dba", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 0, + "trimY": 0, + "width": 2, + "height": 2, + "rawWidth": 2, + "rawHeight": 2, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "subMetas": {} + } + } +} \ No newline at end of file diff --git a/DisplayScrollViewDemo/creator.d.ts b/DisplayScrollViewDemo/creator.d.ts new file mode 100644 index 0000000..744e092 --- /dev/null +++ b/DisplayScrollViewDemo/creator.d.ts @@ -0,0 +1,30661 @@ + +/** !#en +The main namespace of Cocos2d-JS, all engine core classes, functions, properties and constants are defined in this namespace. +!#zh +Cocos 引擎的主要命名空间,引擎代码中所有的类,函数,属性和常量都在这个命名空间中定义。 */ +declare namespace cc { + /** The current version of Cocos2d being used.
+ Please DO NOT remove this String, it is an important flag for bug tracking.
+ If you post a bug to forum, please attach this flag. */ + export var ENGINE_VERSION: string; + /** !#en This is a Easing instance. + !#zh 这是一个 Easing 类实例。 */ + export var easing: Easing; + /** + !#en + Creates the speed action which changes the speed of an action, making it take longer (speed > 1) + or less (speed < 1) time.
+ Useful to simulate 'slow motion' or 'fast forward' effect. + !#zh 修改目标动作的速率。 + @param action action + @param speed speed + + @example + ```js + // change the target action speed; + var action = cc.scaleTo(0.2, 1, 0.6); + var newAction = cc.speed(action, 0.5); + ``` + */ + export function speed(action: ActionInterval, speed: number): Action; + /** + !#en Create a follow action which makes its target follows another node. + !#zh 追踪目标节点的位置。 + @param followedNode followedNode + @param rect rect + + @example + ```js + // example + // creates the action with a set boundary + var followAction = cc.follow(targetNode, cc.rect(0, 0, screenWidth * 2 - 100, screenHeight)); + node.runAction(followAction); + + // creates the action with no boundary set + var followAction = cc.follow(targetNode); + node.runAction(followAction); + ``` + */ + export function follow(followedNode: Node, rect: Rect): Action; + /** + Points setter + @param points points + */ + export function setPoints(points: any[]): void; + /** + !#en Creates an action with a Cardinal Spline array of points and tension. + !#zh 按基数样条曲线轨迹移动到目标位置。 + @param duration duration + @param points array of control points + @param tension tension + + @example + ```js + //create a cc.CardinalSplineTo + var action1 = cc.cardinalSplineTo(3, array, 0); + ``` + */ + export function cardinalSplineTo(duration: number, points: any[], tension: number): ActionInterval; + /** + update position of target + @param newPos newPos + */ + export function updatePosition(newPos: Vec2): void; + /** + !#en Creates an action with a Cardinal Spline array of points and tension. + !#zh 按基数样条曲线轨迹移动指定的距离。 + @param duration duration + @param points points + @param tension tension + */ + export function cardinalSplineBy(duration: number, points: any[], tension: number): ActionInterval; + /** + !#en Creates an action with a Cardinal Spline array of points and tension. + !#zh 按 Catmull Rom 样条曲线轨迹移动到目标位置。 + @param dt dt + @param points points + + @example + ```js + var action1 = cc.catmullRomTo(3, array); + ``` + */ + export function catmullRomTo(dt: number, points: any[]): ActionInterval; + /** + !#en Creates an action with a Cardinal Spline array of points and tension. + !#zh 按 Catmull Rom 样条曲线轨迹移动指定的距离。 + @param dt dt + @param points points + + @example + ```js + var action1 = cc.catmullRomBy(3, array); + ``` + */ + export function catmullRomBy(dt: number, points: any[]): ActionInterval; + /** + !#en + Creates the action easing object with the rate parameter.
+ From slow to fast. + !#zh 创建 easeIn 缓动对象,由慢到快。 + @param rate rate + + @example + ```js + action.easing(cc.easeIn(3.0)); + ``` + */ + export function easeIn(rate: number): any; + /** + !#en + Creates the action easing object with the rate parameter.
+ From fast to slow. + !#zh 创建 easeOut 缓动对象,由快到慢。 + @param rate rate + + @example + ```js + action.easing(cc.easeOut(3.0)); + ``` + */ + export function easeOut(rate: number): any; + /** + !#en + Creates the action easing object with the rate parameter.
+ Slow to fast then to slow. + !#zh 创建 easeInOut 缓动对象,慢到快,然后慢。 + @param rate rate + + @example + ```js + action.easing(cc.easeInOut(3.0)); + ``` + */ + export function easeInOut(rate: number): any; + /** + !#en + Creates the action easing object with the rate parameter.
+ Reference easeInExpo:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeExponentialIn 缓动对象。
+ EaseExponentialIn 是按指数函数缓动进入的动作。
+ 参考 easeInExpo:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + action.easing(cc.easeExponentialIn()); + ``` + */ + export function easeExponentialIn(): any; + /** + !#en + Creates the action easing object.
+ Reference easeOutExpo:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeExponentialOut 缓动对象。
+ EaseExponentialOut 是按指数函数缓动退出的动作。
+ 参考 easeOutExpo:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + action.easing(cc.easeExponentialOut()); + ``` + */ + export function easeExponentialOut(): any; + /** + !#en + Creates an EaseExponentialInOut action easing object.
+ Reference easeInOutExpo:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeExponentialInOut 缓动对象。
+ EaseExponentialInOut 是按指数函数缓动进入并退出的动作。
+ 参考 easeInOutExpo:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + action.easing(cc.easeExponentialInOut()); + ``` + */ + export function easeExponentialInOut(): any; + /** + !#en + Creates an EaseSineIn action.
+ Reference easeInSine:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 EaseSineIn 缓动对象。
+ EaseSineIn 是按正弦函数缓动进入的动作。
+ 参考 easeInSine:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + action.easing(cc.easeSineIn()); + ``` + */ + export function easeSineIn(): any; + /** + !#en + Creates an EaseSineOut action easing object.
+ Reference easeOutSine:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 EaseSineOut 缓动对象。
+ EaseSineIn 是按正弦函数缓动退出的动作。
+ 参考 easeOutSine:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + action.easing(cc.easeSineOut()); + ``` + */ + export function easeSineOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInOutSine:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeSineInOut 缓动对象。
+ EaseSineIn 是按正弦函数缓动进入并退出的动作。
+ 参考 easeInOutSine:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + action.easing(cc.easeSineInOut()); + ``` + */ + export function easeSineInOut(): any; + /** + !#en + Creates the action easing object with the period in radians (default is 0.3).
+ Reference easeInElastic:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeElasticIn 缓动对象。
+ EaseElasticIn 是按弹性曲线缓动进入的动作。
+ 参数 easeInElastic:http://www.zhihu.com/question/21981571/answer/19925418 + @param period period + + @example + ```js + // example + action.easing(cc.easeElasticIn(3.0)); + ``` + */ + export function easeElasticIn(period: number): any; + /** + !#en + Creates the action easing object with the period in radians (default is 0.3).
+ Reference easeOutElastic:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeElasticOut 缓动对象。
+ EaseElasticOut 是按弹性曲线缓动退出的动作。
+ 参考 easeOutElastic:http://www.zhihu.com/question/21981571/answer/19925418 + @param period period + + @example + ```js + // example + action.easing(cc.easeElasticOut(3.0)); + ``` + */ + export function easeElasticOut(period: number): any; + /** + !#en + Creates the action easing object with the period in radians (default is 0.3).
+ Reference easeInOutElastic:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeElasticInOut 缓动对象。
+ EaseElasticInOut 是按弹性曲线缓动进入并退出的动作。
+ 参考 easeInOutElastic:http://www.zhihu.com/question/21981571/answer/19925418 + @param period period + + @example + ```js + // example + action.easing(cc.easeElasticInOut(3.0)); + ``` + */ + export function easeElasticInOut(period: number): any; + /** + !#en + Creates the action easing object.
+ Eased bounce effect at the beginning. + !#zh + 创建 easeBounceIn 缓动对象。
+ EaseBounceIn 是按弹跳动作缓动进入的动作。 + + @example + ```js + // example + action.easing(cc.easeBounceIn()); + ``` + */ + export function easeBounceIn(): any; + /** + !#en + Creates the action easing object.
+ Eased bounce effect at the ending. + !#zh + 创建 easeBounceOut 缓动对象。
+ EaseBounceOut 是按弹跳动作缓动退出的动作。 + + @example + ```js + // example + action.easing(cc.easeBounceOut()); + ``` + */ + export function easeBounceOut(): any; + /** + !#en + Creates the action easing object.
+ Eased bounce effect at the begining and ending. + !#zh + 创建 easeBounceInOut 缓动对象。
+ EaseBounceInOut 是按弹跳动作缓动进入并退出的动作。 + + @example + ```js + // example + action.easing(cc.easeBounceInOut()); + ``` + */ + export function easeBounceInOut(): any; + /** + !#en + Creates the action easing object.
+ In the opposite direction to move slowly, and then accelerated to the right direction. + !#zh + 创建 easeBackIn 缓动对象。
+ easeBackIn 是在相反的方向缓慢移动,然后加速到正确的方向。
+ + @example + ```js + // example + action.easing(cc.easeBackIn()); + ``` + */ + export function easeBackIn(): any; + /** + !#en + Creates the action easing object.
+ Fast moving more than the finish, and then slowly back to the finish. + !#zh + 创建 easeBackOut 缓动对象。
+ easeBackOut 快速移动超出目标,然后慢慢回到目标点。 + + @example + ```js + // example + action.easing(cc.easeBackOut()); + ``` + */ + export function easeBackOut(): any; + /** + !#en + Creates the action easing object.
+ Begining of cc.EaseBackIn. Ending of cc.EaseBackOut. + !#zh + 创建 easeBackInOut 缓动对象。
+ + @example + ```js + // example + action.easing(cc.easeBackInOut()); + ``` + */ + export function easeBackInOut(): any; + /** + !#en + Creates the action easing object.
+ Into the 4 reference point.
+ To calculate the motion curve. + !#zh + 创建 easeBezierAction 缓动对象。
+ EaseBezierAction 是按贝塞尔曲线缓动的动作。 + @param p0 The first bezier parameter + @param p1 The second bezier parameter + @param p2 The third bezier parameter + @param p3 The fourth bezier parameter + + @example + ```js + // example + action.easing(cc.easeBezierAction(0.5, 0.5, 1.0, 1.0)); + ``` + */ + export function easeBezierAction(p0: number, p1: number, p2: number, p3: number): any; + /** + !#en + Creates the action easing object.
+ Reference easeInQuad:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuadraticActionIn 缓动对象。
+ EaseQuadraticIn是按二次函数缓动进入的动作。
+ 参考 easeInQuad:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeQuadraticActionIn()); + ``` + */ + export function easeQuadraticActionIn(): any; + /** + !#en + Creates the action easing object.
+ Reference easeOutQuad:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuadraticActionOut 缓动对象。
+ EaseQuadraticOut 是按二次函数缓动退出的动作。
+ 参考 easeOutQuad:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeQuadraticActionOut()); + ``` + */ + export function easeQuadraticActionOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInOutQuad:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuadraticActionInOut 缓动对象。
+ EaseQuadraticInOut 是按二次函数缓动进入并退出的动作。
+ 参考 easeInOutQuad:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeQuadraticActionInOut()); + ``` + */ + export function easeQuadraticActionInOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeIntQuart:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuarticActionIn 缓动对象。
+ EaseQuarticIn 是按四次函数缓动进入的动作。
+ 参考 easeIntQuart:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeQuarticActionIn()); + ``` + */ + export function easeQuarticActionIn(): any; + /** + !#en + Creates the action easing object.
+ Reference easeOutQuart:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuarticActionOut 缓动对象。
+ EaseQuarticOut 是按四次函数缓动退出的动作。
+ 参考 easeOutQuart:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.QuarticActionOut()); + ``` + */ + export function easeQuarticActionOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInOutQuart:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuarticActionInOut 缓动对象。
+ EaseQuarticInOut 是按四次函数缓动进入并退出的动作。
+ 参考 easeInOutQuart:http://www.zhihu.com/question/21981571/answer/19925418 + */ + export function easeQuarticActionInOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInQuint:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuinticActionIn 缓动对象。
+ EaseQuinticIn 是按五次函数缓动进的动作。
+ 参考 easeInQuint:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeQuinticActionIn()); + ``` + */ + export function easeQuinticActionIn(): any; + /** + !#en + Creates the action easing object.
+ Reference easeOutQuint:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuinticActionOut 缓动对象。
+ EaseQuinticOut 是按五次函数缓动退出的动作 + 参考 easeOutQuint:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeQuadraticActionOut()); + ``` + */ + export function easeQuinticActionOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInOutQuint:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuinticActionInOut 缓动对象。
+ EaseQuinticInOut是按五次函数缓动进入并退出的动作。
+ 参考 easeInOutQuint:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeQuinticActionInOut()); + ``` + */ + export function easeQuinticActionInOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInCirc:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeCircleActionIn 缓动对象。
+ EaseCircleIn是按圆形曲线缓动进入的动作。
+ 参考 easeInCirc:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeCircleActionIn()); + ``` + */ + export function easeCircleActionIn(): any; + /** + !#en + Creates the action easing object.
+ Reference easeOutCirc:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeCircleActionOut 缓动对象。
+ EaseCircleOut是按圆形曲线缓动退出的动作。
+ 参考 easeOutCirc:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + actioneasing(cc.easeCircleActionOut()); + ``` + */ + export function easeCircleActionOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInOutCirc:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeCircleActionInOut 缓动对象。
+ EaseCircleInOut 是按圆形曲线缓动进入并退出的动作。
+ 参考 easeInOutCirc:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeCircleActionInOut()); + ``` + */ + export function easeCircleActionInOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInCubic:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeCubicActionIn 缓动对象。
+ EaseCubicIn 是按三次函数缓动进入的动作。
+ 参考 easeInCubic:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeCubicActionIn()); + ``` + */ + export function easeCubicActionIn(): any; + /** + !#en + Creates the action easing object.
+ Reference easeOutCubic:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeCubicActionOut 缓动对象。
+ EaseCubicOut 是按三次函数缓动退出的动作。
+ 参考 easeOutCubic:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeCubicActionOut()); + ``` + */ + export function easeCubicActionOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInOutCubic:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeCubicActionInOut 缓动对象。
+ EaseCubicInOut是按三次函数缓动进入并退出的动作。
+ 参考 easeInOutCubic:http://www.zhihu.com/question/21981571/answer/19925418 + */ + export function easeCubicActionInOut(): any; + /** + !#en Show the Node. + !#zh 立即显示。 + + @example + ```js + // example + var showAction = cc.show(); + ``` + */ + export function show(): ActionInstant; + /** + !#en Hide the node. + !#zh 立即隐藏。 + + @example + ```js + // example + var hideAction = cc.hide(); + ``` + */ + export function hide(): ActionInstant; + /** + !#en Toggles the visibility of a node. + !#zh 显隐状态切换。 + + @example + ```js + // example + var toggleVisibilityAction = cc.toggleVisibility(); + ``` + */ + export function toggleVisibility(): ActionInstant; + /** + !#en Create a RemoveSelf object with a flag indicate whether the target should be cleaned up while removing. + !#zh 从父节点移除自身。 + @param isNeedCleanUp isNeedCleanUp + + @example + ```js + // example + var removeSelfAction = cc.removeSelf(); + ``` + */ + export function removeSelf(isNeedCleanUp ?: boolean): ActionInstant; + /** + !#en Destroy self + !#zh 创建一个销毁自身的动作。 + + @example + ```js + var destroySelfAction = cc.destroySelf(); + ``` + */ + export function destroySelf(): ActionInstant; + /** + !#en Create a FlipX action to flip or unflip the target. + !#zh X轴翻转。 + @param flip Indicate whether the target should be flipped or not + + @example + ```js + var flipXAction = cc.flipX(true); + ``` + */ + export function flipX(flip: boolean): ActionInstant; + /** + !#en Create a FlipY action to flip or unflip the target. + !#zh Y轴翻转。 + @param flip flip + + @example + ```js + var flipYAction = cc.flipY(true); + ``` + */ + export function flipY(flip: boolean): ActionInstant; + /** + !#en Creates a Place action with a position. + !#zh 放置在目标位置。 + @param pos pos + @param y y + + @example + ```js + // example + var placeAction = cc.place(cc.v2(200, 200)); + var placeAction = cc.place(200, 200); + ``` + */ + export function place(pos: Vec2|number, y?: number): ActionInstant; + /** + !#en Creates the action with the callback. + !#zh 执行回调函数。 + @param selector selector + @param selectorTarget selectorTarget + @param data data for function, it accepts all data types. + + @example + ```js + // example + // CallFunc without data + var finish = cc.callFunc(this.removeSprite, this); + + // CallFunc with data + var finish = cc.callFunc(this.removeFromParentAndCleanup, this._grossini, true); + ``` + */ + export function callFunc(selector: Function, selectorTarget?: any, data?: any): ActionInstant; + /** + !#en + Helper constructor to create an array of sequenceable actions + The created action will run actions sequentially, one after another. + !#zh 顺序执行动作,创建的动作将按顺序依次运行。 + @param actionOrActionArray actionOrActionArray + @param tempArray tempArray + + @example + ```js + // example + // create sequence with actions + var seq = cc.sequence(act1, act2); + + // create sequence with array + var seq = cc.sequence(actArray); + ``` + */ + export function sequence(actionOrActionArray: FiniteTimeAction|FiniteTimeAction[], ...tempArray: FiniteTimeAction[]): ActionInterval; + /** + !#en Creates a Repeat action. Times is an unsigned integer between 1 and pow(2,30) + !#zh 重复动作,可以按一定次数重复一个动,如果想永远重复一个动作请使用 repeatForever 动作来完成。 + @param action action + @param times times + + @example + ```js + // example + var rep = cc.repeat(cc.sequence(jump2, jump1), 5); + ``` + */ + export function repeat(action: FiniteTimeAction, times: number): ActionInterval; + /** + !#en Create a acton which repeat forever, as it runs forever, it can't be added into cc.sequence and cc.spawn. + !#zh 永远地重复一个动作,有限次数内重复一个动作请使用 repeat 动作,由于这个动作不会停止,所以不能被添加到 cc.sequence 或 cc.spawn 中。 + @param action action + + @example + ```js + // example + var repeat = cc.repeatForever(cc.rotateBy(1.0, 360)); + ``` + */ + export function repeatForever(action: FiniteTimeAction): ActionInterval; + /** + !#en Create a spawn action which runs several actions in parallel. + !#zh 同步执行动作,同步执行一组动作。 + @param actionOrActionArray actionOrActionArray + @param tempArray tempArray + + @example + ```js + // example + var action = cc.spawn(cc.jumpBy(2, cc.v2(300, 0), 50, 4), cc.rotateBy(2, 720)); + todo:It should be the direct use new + ``` + */ + export function spawn(actionOrActionArray: FiniteTimeAction|FiniteTimeAction[], ...tempArray: FiniteTimeAction[]): FiniteTimeAction; + /** + !#en + Rotates a Node object to a certain angle by modifying its angle property.
+ The direction will be decided by the shortest angle. + !#zh 旋转到目标角度,通过逐帧修改它的 angle 属性,旋转方向将由最短的角度决定。 + @param duration duration in seconds + @param dstAngle dstAngle in degrees. + + @example + ```js + // example + var rotateTo = cc.rotateTo(2, 61.0); + ``` + */ + export function rotateTo(duration: number, dstAngle: number): ActionInterval; + /** + !#en + Rotates a Node object clockwise a number of degrees by modifying its angle property. + Relative to its properties to modify. + !#zh 旋转指定的角度。 + @param duration duration in seconds + @param deltaAngle deltaAngle in degrees + + @example + ```js + // example + var actionBy = cc.rotateBy(2, 360); + ``` + */ + export function rotateBy(duration: number, deltaAngle: number): ActionInterval; + /** + !#en + Moves a Node object x,y pixels by modifying its position property.
+ x and y are relative to the position of the object.
+ Several MoveBy actions can be concurrently called, and the resulting
+ movement will be the sum of individual movements. + !#zh 移动指定的距离。 + @param duration duration in seconds + @param deltaPos deltaPos + @param deltaY deltaY + + @example + ```js + // example + var actionTo = cc.moveBy(2, cc.v2(windowSize.width - 40, windowSize.height - 40)); + ``` + */ + export function moveBy(duration: number, deltaPos: Vec2|number, deltaY?: number): ActionInterval; + /** + !#en + Moves a Node object to the position x,y. x and y are absolute coordinates by modifying its position property.
+ Several MoveTo actions can be concurrently called, and the resulting
+ movement will be the sum of individual movements. + !#zh 移动到目标位置。 + @param duration duration in seconds + @param position position + @param y y + + @example + ```js + // example + var actionBy = cc.moveTo(2, cc.v2(80, 80)); + ``` + */ + export function moveTo(duration: number, position: Vec2|number, y?: number): ActionInterval; + /** + !#en + Create a action which skews a Node object to given angles by modifying its skewX and skewY properties. + Changes to the specified value. + !#zh 偏斜到目标角度。 + @param t time in seconds + @param sx sx + @param sy sy + + @example + ```js + // example + var actionTo = cc.skewTo(2, 37.2, -37.2); + ``` + */ + export function skewTo(t: number, sx: number, sy: number): ActionInterval; + /** + !#en + Skews a Node object by skewX and skewY degrees.
+ Relative to its property modification. + !#zh 偏斜指定的角度。 + @param t time in seconds + @param sx sx skew in degrees for X axis + @param sy sy skew in degrees for Y axis + + @example + ```js + // example + var actionBy = cc.skewBy(2, 0, -90); + ``` + */ + export function skewBy(t: number, sx: number, sy: number): ActionInterval; + /** + !#en + Moves a Node object simulating a parabolic jump movement by modifying it's position property. + Relative to its movement. + !#zh 用跳跃的方式移动指定的距离。 + @param duration duration + @param position position + @param y y + @param height height + @param jumps jumps + + @example + ```js + // example + var actionBy = cc.jumpBy(2, cc.v2(300, 0), 50, 4); + var actionBy = cc.jumpBy(2, 300, 0, 50, 4); + ``` + */ + export function jumpBy(duration: number, position: Vec2|number, y?: number, height?: number, jumps?: number): ActionInterval; + /** + !#en + Moves a Node object to a parabolic position simulating a jump movement by modifying its position property.
+ Jump to the specified location. + !#zh 用跳跃的方式移动到目标位置。 + @param duration duration + @param position position + @param y y + @param height height + @param jumps jumps + + @example + ```js + // example + var actionTo = cc.jumpTo(2, cc.v2(300, 300), 50, 4); + var actionTo = cc.jumpTo(2, 300, 300, 50, 4); + ``` + */ + export function jumpTo(duration: number, position: Vec2|number, y?: number, height?: number, jumps?: number): ActionInterval; + /** + !#en + An action that moves the target with a cubic Bezier curve by a certain distance. + Relative to its movement. + !#zh 按贝赛尔曲线轨迹移动指定的距离。 + @param t time in seconds + @param c Array of points + + @example + ```js + // example + var bezier = [cc.v2(0, windowSize.height / 2), cc.v2(300, -windowSize.height / 2), cc.v2(300, 100)]; + var bezierForward = cc.bezierBy(3, bezier); + ``` + */ + export function bezierBy(t: number, c: Vec2[]): ActionInterval; + /** + !#en An action that moves the target with a cubic Bezier curve to a destination point. + !#zh 按贝赛尔曲线轨迹移动到目标位置。 + @param t t + @param c Array of points + + @example + ```js + // example + var bezier = [cc.v2(0, windowSize.height / 2), cc.v2(300, -windowSize.height / 2), cc.v2(300, 100)]; + var bezierTo = cc.bezierTo(2, bezier); + ``` + */ + export function bezierTo(t: number, c: Vec2[]): ActionInterval; + /** + !#en Scales a Node object to a zoom factor by modifying it's scale property. + !#zh 将节点大小缩放到指定的倍数。 + @param duration duration + @param sx scale parameter in X + @param sy scale parameter in Y, if Null equal to sx + + @example + ```js + // example + // It scales to 0.5 in both X and Y. + var actionTo = cc.scaleTo(2, 0.5); + + // It scales to 0.5 in x and 2 in Y + var actionTo = cc.scaleTo(2, 0.5, 2); + ``` + */ + export function scaleTo(duration: number, sx: number, sy?: number): ActionInterval; + /** + !#en + Scales a Node object a zoom factor by modifying it's scale property. + Relative to its changes. + !#zh 按指定的倍数缩放节点大小。 + @param duration duration in seconds + @param sx sx scale parameter in X + @param sy sy scale parameter in Y, if Null equal to sx + + @example + ```js + // example without sy, it scales by 2 both in X and Y + var actionBy = cc.scaleBy(2, 2); + + //example with sy, it scales by 0.25 in X and 4.5 in Y + var actionBy2 = cc.scaleBy(2, 0.25, 4.5); + ``` + */ + export function scaleBy(duration: number, sx: number, sy?: number|void): ActionInterval; + /** + !#en Blinks a Node object by modifying it's visible property. + !#zh 闪烁(基于透明度)。 + @param duration duration in seconds + @param blinks blinks in times + + @example + ```js + // example + var action = cc.blink(2, 10); + ``` + */ + export function blink(duration: number, blinks: number): ActionInterval; + /** + !#en + Fades an object that implements the cc.RGBAProtocol protocol. + It modifies the opacity from the current value to a custom one. + !#zh 修改透明度到指定值。 + @param duration duration + @param opacity 0-255, 0 is transparent + + @example + ```js + // example + var action = cc.fadeTo(1.0, 0); + ``` + */ + export function fadeTo(duration: number, opacity: number): ActionInterval; + /** + !#en Fades In an object that implements the cc.RGBAProtocol protocol. It modifies the opacity from 0 to 255. + !#zh 渐显效果。 + @param duration duration in seconds + + @example + ```js + //example + var action = cc.fadeIn(1.0); + ``` + */ + export function fadeIn(duration: number): ActionInterval; + /** + !#en Fades Out an object that implements the cc.RGBAProtocol protocol. It modifies the opacity from 255 to 0. + !#zh 渐隐效果。 + @param d duration in seconds + + @example + ```js + // example + var action = cc.fadeOut(1.0); + ``` + */ + export function fadeOut(d: number): ActionInterval; + /** + !#en Tints a Node that implements the cc.NodeRGB protocol from current tint to a custom one. + !#zh 修改颜色到指定值。 + @param duration duration + @param red 0-255 + @param green 0-255 + @param blue 0-255 + + @example + ```js + // example + var action = cc.tintTo(2, 255, 0, 255); + ``` + */ + export function tintTo(duration: number, red: number, green: number, blue: number): ActionInterval; + /** + !#en + Tints a Node that implements the cc.NodeRGB protocol from current tint to a custom one. + Relative to their own color change. + !#zh 按照指定的增量修改颜色。 + @param duration duration in seconds + @param deltaRed deltaRed + @param deltaGreen deltaGreen + @param deltaBlue deltaBlue + + @example + ```js + // example + var action = cc.tintBy(2, -127, -255, -127); + ``` + */ + export function tintBy(duration: number, deltaRed: number, deltaGreen: number, deltaBlue: number): ActionInterval; + /** + !#en Delays the action a certain amount of seconds. + !#zh 延迟指定的时间量。 + @param d duration in seconds + + @example + ```js + // example + var delay = cc.delayTime(1); + ``` + */ + export function delayTime(d: number): ActionInterval; + /** + !#en Executes an action in reverse order, from time=duration to time=0. + !#zh 反转目标动作的时间轴。 + @param action action + + @example + ```js + // example + var reverse = cc.reverseTime(this); + ``` + */ + export function reverseTime(action: FiniteTimeAction): ActionInterval; + /** + !#en Create an action with the specified action and forced target. + !#zh 用已有动作和一个新的目标节点创建动作。 + @param target target + @param action action + */ + export function targetedAction(target: Node, action: FiniteTimeAction): ActionInterval; + /** + + @param target the target to animate + */ + export function tween (target?: Object) : Tween; + /** + !#en + Outputs an error message to the Cocos Creator Console (editor) or Web Console (runtime).
+ - In Cocos Creator, error is red.
+ - In Chrome, error have a red icon along with red message text.
+ !#zh + 输出错误消息到 Cocos Creator 编辑器的 Console 或运行时页面端的 Console 中。
+ - 在 Cocos Creator 中,错误信息显示是红色的。
+ - 在 Chrome 中,错误信息有红色的图标以及红色的消息文本。
+ @param msg A JavaScript string containing zero or more substitution strings. + @param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output. + */ + export function error(msg: any, ...subst: any[]): void; + /** + !#en + Outputs a warning message to the Cocos Creator Console (editor) or Web Console (runtime). + - In Cocos Creator, warning is yellow. + - In Chrome, warning have a yellow warning icon with the message text. + !#zh + 输出警告消息到 Cocos Creator 编辑器的 Console 或运行时 Web 端的 Console 中。
+ - 在 Cocos Creator 中,警告信息显示是黄色的。
+ - 在 Chrome 中,警告信息有着黄色的图标以及黄色的消息文本。
+ @param msg A JavaScript string containing zero or more substitution strings. + @param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output. + */ + export function warn(msg: any, ...subst: any[]): void; + /** + !#en Outputs a message to the Cocos Creator Console (editor) or Web Console (runtime). + !#zh 输出一条消息到 Cocos Creator 编辑器的 Console 或运行时 Web 端的 Console 中。 + @param msg A JavaScript string containing zero or more substitution strings. + @param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output. + */ + export function log(msg: string|any, ...subst: any[]): void; + /** !#en Director + !#zh 导演类。 */ + export var director: Director; + /** !#en This is a Game instance. + !#zh 这是一个 Game 类的实例,包含游戏主体信息并负责驱动游戏的游戏对象。。 */ + export var game: Game; + /** + !#en + Rotates a Node object to a certain angle by modifying its quternion property.
+ The direction will be decided by the shortest angle. + !#zh 旋转到目标角度,通过逐帧修改它的 quternion 属性,旋转方向将由最短的角度决定。 + @param duration duration in seconds + @param dstAngleX dstAngleX in degrees. + @param dstAngleY dstAngleY in degrees. + @param dstAngleZ dstAngleZ in degrees. + + @example + ```js + // example + var rotate3DTo = cc.rotate3DTo(2, cc.v3(0, 180, 0)); + ``` + */ + export function rotate3DTo(duration: number, dstAngleX: number|Vec3|Quat, dstAngleY?: number, dstAngleZ?: number): ActionInterval; + /** + !#en + Rotates a Node object counter clockwise a number of degrees by modifying its quaternion property. + Relative to its properties to modify. + !#zh 旋转指定的 3D 角度。 + @param duration duration in seconds + @param deltaAngleX deltaAngleX in degrees + @param deltaAngleY deltaAngleY in degrees + @param deltaAngleZ deltaAngleZ in degrees + + @example + ```js + // example + var actionBy = cc.rotate3DBy(2, cc.v3(0, 360, 0)); + ``` + */ + export function rotate3DBy(duration: number, deltaAngleX: number|Vec3, deltaAngleY?: number, deltaAngleZ?: number): ActionInterval; + /** !#en The System event singleton for global usage + !#zh 系统事件单例,方便全局使用 */ + export var systemEvent: SystemEvent; + /** The offset of the range. */ + export var offset: number; + /** The length of the range. */ + export var length: number; + /** The data range of this bundle. + This range of data is essentially mapped to a GPU vertex buffer. */ + export var data: BufferRange; + /** The attribute formats. */ + export var formats: VertexFormat; + /** The vertex bundle that the primitive use. */ + export var vertexBundleIndices: number[]; + /** The data range of the primitive. + This range of data is essentially mapped to a GPU indices buffer. */ + export var data: BufferRange; + /** The type of this primitive's indices. */ + export var indexUnit: number; + /** The primitive's topology. */ + export var topology: number; + /** + !#en Defines a CCClass using the given specification, please see [Class](/docs/editors_and_tools/creator-chapters/scripting/class.html) for details. + !#zh 定义一个 CCClass,传入参数必须是一个包含类型参数的字面量对象,具体用法请查阅[类型定义](/docs/creator/scripting/class.html)。 + @param options options + + @example + ```js + // define base class + var Node = cc.Class(); + + // define sub class + var Sprite = cc.Class({ + name: 'Sprite', + extends: Node, + + ctor: function () { + this.url = ""; + this.id = 0; + }, + + statics: { + // define static members + count: 0, + getBounds: function (spriteList) { + // compute bounds... + } + }, + + properties { + width: { + default: 128, + type: cc.Integer, + tooltip: 'The width of sprite' + }, + height: 128, + size: { + get: function () { + return cc.v2(this.width, this.height); + } + } + }, + + load: function () { + // load this.url... + }; + }); + + // instantiate + + var obj = new Sprite(); + obj.url = 'sprite.png'; + obj.load(); + ``` + */ + export function Class(options?: {name?: string; extends?: Function; ctor?: Function; __ctor__?: Function; properties?: any; statics?: any; mixins?: Function[]; editor?: {executeInEditMode?: boolean; requireComponent?: Function; menu?: string; executionOrder?: number; disallowMultiple?: boolean; playOnFocus?: boolean; inspector?: string; icon?: string; help?: string; }; update?: Function; lateUpdate?: Function; onLoad?: Function; start?: Function; onEnable?: Function; onDisable?: Function; onDestroy?: Function; onFocusInEditor?: Function; onLostFocusInEditor?: Function; resetInEditor?: Function; onRestore?: Function; _getLocalBounds?: Function; }): Function; + /** + !#en + Define an enum type.
+ If a enum item has a value of -1, it will be given an Integer number according to it's order in the list.
+ Otherwise it will use the value specified by user who writes the enum definition. + + !#zh + 定义一个枚举类型。
+ 用户可以把枚举值设为任意的整数,如果设为 -1,系统将会分配为上一个枚举值 + 1。 + @param obj a JavaScript literal object containing enum names and values, or a TypeScript enum type + + @example + ```js + // JavaScript: + + var WrapMode = cc.Enum({ + Repeat: -1, + Clamp: -1 + }); + + // Texture.WrapMode.Repeat == 0 + // Texture.WrapMode.Clamp == 1 + // Texture.WrapMode[0] == "Repeat" + // Texture.WrapMode[1] == "Clamp" + + var FlagType = cc.Enum({ + Flag1: 1, + Flag2: 2, + Flag3: 4, + Flag4: 8, + }); + + var AtlasSizeList = cc.Enum({ + 128: 128, + 256: 256, + 512: 512, + 1024: 1024, + }); + + // TypeScript: + + // If used in TypeScript, just define a TypeScript enum: + enum Direction { + Up, + Down, + Left, + Right + } + + // If you need to inspect the enum in Properties panel, you can call cc.Enum: + const {ccclass, property} = cc._decorator; + + @ccclass + class NewScript extends cc.Component { + @property({ + type: cc.Enum(Direction) // call cc.Enum + }) + direction: Direction = Direction.Up; + } + + ``` + */ + export function Enum(obj: T): T; + /** + + @param touches touches + */ + export function handleTouchesBegin(touches: any[]): void; + /** + + @param touches touches + */ + export function handleTouchesMove(touches: any[]): void; + /** + + @param touches touches + */ + export function handleTouchesEnd(touches: any[]): void; + /** + + @param touches touches + */ + export function handleTouchesCancel(touches: any[]): void; + /** + + @param touches touches + */ + export function getSetOfTouchesEndOrCancel(touches: any[]): any[]; + /** + + @param touch touch + */ + export function getPreTouch(touch: Touch): Touch; + /** + + @param touch touch + */ + export function setPreTouch(touch: Touch): void; + /** + + @param tx tx + @param ty ty + @param pos pos + */ + export function getTouchByXY(tx: number, ty: number, pos: Vec2): Touch; + /** + + @param location location + @param pos pos + @param eventType eventType + */ + export function getMouseEvent(location: Vec2, pos: Vec2, eventType: number): Event.EventMouse; + /** + + @param event event + @param pos pos + */ + export function getPointByEvent(event: Touch, pos: Vec2): Vec2; + /** + + @param event event + @param pos pos + */ + export function getTouchesByEvent(event: Touch, pos: Vec2): any[]; + /** + + @param element element + */ + export function registerSystemEvent(element: HTMLElement): void; + /** + + @param dt dt + */ + export function update(dt: number): void; + /** + !#en + Checks whether the object is non-nil and not yet destroyed.
+ When an object's `destroy` is called, it is actually destroyed after the end of this frame. + So `isValid` will return false from the next frame, while `isValid` in the current frame will still be true. + If you want to determine whether the current frame has called `destroy`, use `cc.isValid(obj, true)`, + but this is often caused by a particular logical requirements, which is not normally required. + + !#zh + 检查该对象是否不为 null 并且尚未销毁。
+ 当一个对象的 `destroy` 调用以后,会在这一帧结束后才真正销毁。因此从下一帧开始 `isValid` 就会返回 false,而当前帧内 `isValid` 仍然会是 true。如果希望判断当前帧是否调用过 `destroy`,请使用 `cc.isValid(obj, true)`,不过这往往是特殊的业务需求引起的,通常情况下不需要这样。 + @param value value + @param strictMode If true, Object called destroy() in this frame will also treated as invalid. + + @example + ```js + var node = new cc.Node(); + cc.log(cc.isValid(node)); // true + node.destroy(); + cc.log(cc.isValid(node)); // true, still valid in this frame + // after a frame... + cc.log(cc.isValid(node)); // false, destroyed in the end of last frame + ``` + */ + export function isValid(value: any, strictMode?: boolean): boolean; + /** !#en cc.view is the shared view object. + !#zh cc.view 是全局的视图对象。 */ + export var view: View; + /** !#en cc.winSize is the alias object for the size of the current game window. + !#zh cc.winSize 为当前的游戏窗口的大小。 */ + export var winSize: Size; + /** Specify that the input value must be integer in Inspector. + Also used to indicates that the elements in array should be type integer. */ + export var Integer: string; + /** Indicates that the elements in array should be type double. */ + export var Float: string; + /** Indicates that the elements in array should be type boolean. */ + export var Boolean: string; + /** Indicates that the elements in array should be type string. */ + export var String: string; + /** + !#en Deserialize json to cc.Asset + !#zh 将 JSON 反序列化为对象实例。 + + 当指定了 target 选项时,如果 target 引用的其它 asset 的 uuid 不变,则不会改变 target 对 asset 的引用, + 也不会将 uuid 保存到 result 对象中。 + @param data the serialized cc.Asset json string or json object. + @param details additional loading result + @param options options + */ + export function deserialize(data: string|any, details?: Details, options?: any): any; + /** + !#en Clones the object `original` and returns the clone, or instantiate a node from the Prefab. + !#zh 克隆指定的任意类型的对象,或者从 Prefab 实例化出新节点。 + + (Instantiate 时,function 和 dom 等非可序列化对象会直接保留原有引用,Asset 会直接进行浅拷贝,可序列化类型会进行深拷贝。) + @param original An existing object that you want to make a copy of. + + @example + ```js + // instantiate node from prefab + var scene = cc.director.getScene(); + var node = cc.instantiate(prefabAsset); + node.parent = scene; + // clone node + var scene = cc.director.getScene(); + var node = cc.instantiate(targetNode); + node.parent = scene; + ``` + */ + export function instantiate(original: Prefab): Node; + export function instantiate(original: T): T; + /** + Finds a node by hierarchy path, the path is case-sensitive. + It will traverse the hierarchy by splitting the path using '/' character. + This function will still returns the node even if it is inactive. + It is recommended to not use this function every frame instead cache the result at startup. + @param path path + @param referenceNode referenceNode + */ + export function find(path: string, referenceNode?: Node): Node; + /** + !#en + The convenience method to create a new {{#crossLink "Color/Color:method"}}cc.Color{{/crossLink}} + Alpha channel is optional. Default value is 255. + + !#zh + 通过该方法来创建一个新的 {{#crossLink "Color/Color:method"}}cc.Color{{/crossLink}} 对象。 + Alpha 通道是可选的。默认值是 255。 + @param r r + @param g g + @param b b + @param a a + + @example + ```js + ----------------------- + // 1. All channels seperately as parameters + var color1 = new cc.Color(255, 255, 255, 255); + // 2. Convert a hex string to a color + var color2 = new cc.Color("#000000"); + // 3. An color object as parameter + var color3 = new cc.Color({r: 255, g: 255, b: 255, a: 255}); + + ``` + */ + export function color(r?: number, g?: number, b?: number, a?: number): Color; + /** Identity of Mat3 */ + export var IDENTITY: Mat3; + /** + !#zh 矩阵转数组 + !#en Matrix transpose array + @param ofs 数组内的起始偏移量 + */ + export function toArray > (out: Out, mat: IMat3Like, ofs = 0); + /** + !#zh 数组转矩阵 + !#en Transfer matrix array + @param ofs 数组起始偏移量 + */ + export function fromArray (out: Out, arr: IWritableArrayLike, ofs = 0); + /** !#en Matrix Data + !#zh 矩阵数据 */ + export var m: Float64Array|Float32Array; + export function constructor (m00: number | Float32Array = 1, m01 = 0, m02 = 0, m03 = 0, m04 = 1, m05 = 0, m06 = 0, m07 = 0, m08 = 1); + /** + !#en The convenience method to create a new {{#crossLink "Mat4"}}cc.Mat4{{/crossLink}}. + !#zh 通过该简便的函数进行创建 {{#crossLink "Mat4"}}cc.Mat4{{/crossLink}} 对象。 + @param m00 Component in column 0, row 0 position (index 0) + @param m01 Component in column 0, row 1 position (index 1) + @param m02 Component in column 0, row 2 position (index 2) + @param m03 Component in column 0, row 3 position (index 3) + @param m10 Component in column 1, row 0 position (index 4) + @param m11 Component in column 1, row 1 position (index 5) + @param m12 Component in column 1, row 2 position (index 6) + @param m13 Component in column 1, row 3 position (index 7) + @param m20 Component in column 2, row 0 position (index 8) + @param m21 Component in column 2, row 1 position (index 9) + @param m22 Component in column 2, row 2 position (index 10) + @param m23 Component in column 2, row 3 position (index 11) + @param m30 Component in column 3, row 0 position (index 12) + @param m31 Component in column 3, row 1 position (index 13) + @param m32 Component in column 3, row 2 position (index 14) + @param m33 Component in column 3, row 3 position (index 15) + */ + export function mat4(m00?: number, m01?: number, m02?: number, m03?: number, m10?: number, m11?: number, m12?: number, m13?: number, m20?: number, m21?: number, m22?: number, m23?: number, m30?: number, m31?: number, m32?: number, m33?: number): Mat4; + /** + !#en The convenience method to create a new {{#crossLink "Quat"}}cc.Quat{{/crossLink}}. + !#zh 通过该简便的函数进行创建 {{#crossLink "Quat"}}cc.Quat{{/crossLink}} 对象。 + @param x x + @param y y + @param z z + @param w w + */ + export function quat(x?: number|any, y?: number, z?: number, w?: number): Quat; + /** + !#en + The convenience method to create a new Rect. + see {{#crossLink "Rect/Rect:method"}}cc.Rect{{/crossLink}} + !#zh + 该方法用来快速创建一个新的矩形。{{#crossLink "Rect/Rect:method"}}cc.Rect{{/crossLink}} + @param x x + @param y y + @param w w + @param h h + + @example + ```js + var a = new cc.Rect(0 , 0, 10, 0); + ``` + */ + export function rect(x?: number, y?: number, w?: number, h?: number): Rect; + /** + !#en + Helper function that creates a cc.Size.
+ Please use cc.p or cc.v2 instead, it will soon replace cc.Size. + !#zh + 创建一个 cc.Size 对象的帮助函数。
+ 注意:可以使用 cc.p 或者是 cc.v2 代替,它们将很快取代 cc.Size。 + @param w width or a size object + @param h height + + @example + ```js + var size1 = cc.size(); + var size2 = cc.size(100,100); + var size3 = cc.size(size2); + var size4 = cc.size({width: 100, height: 100}); + + ``` + */ + export function size(w: number|Size, h?: number): Size; + export var EPSILON: number; + /** + Clamps a value between a minimum float and maximum float value. + @param val val + @param min min + @param max max + */ + export function clamp(val: number, min: number, max: number): number; + /** + Clamps a value between 0 and 1. + @param val val + */ + export function clamp01(val: number): number; + /** + + @param from from + @param to to + @param ratio the interpolation coefficient + */ + export function lerp(from: number, to: number, ratio: number): number; + export function random(): void; + /** + Returns a floating-point random number between min (inclusive) and max (exclusive). + @param min min + @param max max + */ + export function randomRange(min: number, max: number): number; + /** + Returns a random integer between min (inclusive) and max (exclusive). + @param min min + @param max max + */ + export function randomRangeInt(min: number, max: number): number; + /** + Linear congruential generator using Hull-Dobell Theorem. + @param seed the random seed + */ + export function pseudoRandom(seed: number): number; + /** + Returns a floating-point pseudo-random number between min (inclusive) and max (exclusive). + @param seed seed + @param min min + @param max max + */ + export function pseudoRandomRange(seed: number, min: number, max: number): number; + /** + Returns a pseudo-random integer between min (inclusive) and max (exclusive). + @param seed seed + @param min min + @param max max + */ + export function pseudoRandomRangeInt(seed: number, min: number, max: number): number; + /** + Returns the next power of two for the value + @param val val + */ + export function nextPow2(val: number): number; + /** + Returns float remainder for t / length + @param t time start at 0 + @param length time of one cycle + */ + export function repeat(t: number, length: number): number; + /** + Returns time wrapped in ping-pong mode + @param t time start at 0 + @param length time of one cycle + */ + export function repeat(t: number, length: number): number; + /** + Returns ratio of a value within a given range + @param from start value + @param to end value + @param value given value + */ + export function repeat(from: number, to: number, value: number): number; + /** + Returns -1, 0, +1 depending on sign of x. + @param v v + */ + export function sign(v: number): void; + /** + !#en The convenience method to create a new {{#crossLink "Vec2"}}cc.Vec2{{/crossLink}}. + !#zh 通过该简便的函数进行创建 {{#crossLink "Vec2"}}cc.Vec2{{/crossLink}} 对象。 + @param x x + @param y y + + @example + ```js + var v1 = cc.v2(); + var v2 = cc.v2(0, 0); + var v3 = cc.v2(v2); + var v4 = cc.v2({x: 100, y: 100}); + ``` + */ + export function v2(x?: number|any, y?: number): Vec2; + /** + !#en The convenience method to create a new {{#crossLink "Vec3"}}cc.Vec3{{/crossLink}}. + !#zh 通过该简便的函数进行创建 {{#crossLink "Vec3"}}cc.Vec3{{/crossLink}} 对象。 + @param x x + @param y y + @param z z + + @example + ```js + var v1 = cc.v3(); + var v2 = cc.v3(0, 0, 0); + var v3 = cc.v3(v2); + var v4 = cc.v3({x: 100, y: 100, z: 0}); + ``` + */ + export function v3(x?: number|any, y?: number, z?: number): Vec3; + export var dynamicAtlasManager: DynamicAtlasManager; + /** !#en The matrix storage */ + export var matrix: any[]; + /** + !#en Get an element + @param i i + @param j j + */ + export function get(i: number, j: number): number; + /** + !#en Set an element + @param i i + @param j j + @param value value + */ + export function set(i: number, j: number, value: boolean): void; + /** + !#en Sets all elements to zero + */ + export function reset(): void; + /** !#en Class for animation data handling. + !#zh 动画剪辑,用于存储动画数据。 */ + export class AnimationClip extends Asset { + /** !#en Duration of this animation. + !#zh 动画的持续时间。 */ + duration: number; + /** !#en FrameRate of this animation. + !#zh 动画的帧速率。 */ + sample: number; + /** !#en Speed of this animation. + !#zh 动画的播放速度。 */ + speed: number; + /** !#en WrapMode of this animation. + !#zh 动画的循环模式。 */ + wrapMode: WrapMode; + /** !#en Curve data. + !#zh 曲线数据。 */ + curveData: any; + /** !#en Event data. + !#zh 事件数据。 */ + events: {frame: number, func: string, params: string[]}[]; + /** + !#en Crate clip with a set of sprite frames + !#zh 使用一组序列帧图片来创建动画剪辑 + @param spriteFrames spriteFrames + @param sample sample + + @example + ```js + var clip = cc.AnimationClip.createWithSpriteFrames(spriteFrames, 10); + ``` + */ + static createWithSpriteFrames(spriteFrames: SpriteFrame[], sample: number): AnimationClip; + } + /** !#en + The AnimationState gives full control over animation playback process. + In most cases the Animation Component is sufficient and easier to use. Use the AnimationState if you need full control. + !#zh + AnimationState 完全控制动画播放过程。
+ 大多数情况下 动画组件 是足够和易于使用的。如果您需要更多的动画控制接口,请使用 AnimationState。 */ + export class AnimationState extends Playable { + /** + + @param clip clip + @param name name + */ + constructor(clip: AnimationClip, name?: string); + /** !#en The curves list. + !#zh 曲线列表。 */ + curves: any[]; + /** !#en The start delay which represents the number of seconds from an animation's start time to the start of + the active interval. + !#zh 延迟多少秒播放。 */ + delay: number; + /** !#en The animation's iteration count property. + + A real number greater than or equal to zero (including positive infinity) representing the number of times + to repeat the animation node. + + Values less than zero and NaN values are treated as the value 1.0 for the purpose of timing model + calculations. + + !#zh 迭代次数,指动画播放多少次后结束, normalize time。 如 2.5(2次半) */ + repeatCount: number; + /** !#en The iteration duration of this animation in seconds. (length) + !#zh 单次动画的持续时间,秒。 */ + duration: number; + /** !#en The animation's playback speed. 1 is normal playback speed. + !#zh 播放速率。 */ + speed: number; + /** !#en + Wrapping mode of the playing animation. + Notice : dynamic change wrapMode will reset time and repeatCount property + !#zh + 动画循环方式。 + 需要注意的是,动态修改 wrapMode 时,会重置 time 以及 repeatCount */ + wrapMode: WrapMode; + /** !#en The current time of this animation in seconds. + !#zh 动画当前的时间,秒。 */ + time: number; + /** !#en The clip that is being played by this animation state. + !#zh 此动画状态正在播放的剪辑。 */ + clip: AnimationClip; + /** !#en The name of the playing animation. + !#zh 动画的名字 */ + name: string; + } + /** !#en + This class provide easing methods for {{#crossLink "tween"}}{{/crossLink}} class.
+ Demonstratio: https://easings.net/ + !#zh + 缓动函数类,为 {{#crossLink "Tween"}}{{/crossLink}} 提供缓动效果函数。
+ 函数效果演示: https://easings.net/ */ + export class Easing { + /** + !#en Easing in with quadratic formula. From slow to fast. + !#zh 平方曲线缓入函数。运动由慢到快。 + @param t The current time as a percentage of the total time. + */ + quadIn(t: number): number; + /** + !#en Easing out with quadratic formula. From fast to slow. + !#zh 平方曲线缓出函数。运动由快到慢。 + @param t The current time as a percentage of the total time. + */ + quadOut(t: number): number; + /** + !#en Easing in and out with quadratic formula. From slow to fast, then back to slow. + !#zh 平方曲线缓入缓出函数。运动由慢到快再到慢。 + @param t The current time as a percentage of the total time. + */ + quadInOut(t: number): number; + /** + !#en Easing in with cubic formula. From slow to fast. + !#zh 立方曲线缓入函数。运动由慢到快。 + @param t The current time as a percentage of the total time. + */ + cubicIn(t: number): number; + /** + !#en Easing out with cubic formula. From slow to fast. + !#zh 立方曲线缓出函数。运动由快到慢。 + @param t The current time as a percentage of the total time. + */ + cubicOut(t: number): number; + /** + !#en Easing in and out with cubic formula. From slow to fast, then back to slow. + !#zh 立方曲线缓入缓出函数。运动由慢到快再到慢。 + @param t The current time as a percentage of the total time. + */ + cubicInOut(t: number): number; + /** + !#en Easing in with quartic formula. From slow to fast. + !#zh 四次方曲线缓入函数。运动由慢到快。 + @param t The current time as a percentage of the total time. + */ + quartIn(t: number): number; + /** + !#en Easing out with quartic formula. From fast to slow. + !#zh 四次方曲线缓出函数。运动由快到慢。 + @param t The current time as a percentage of the total time. + */ + quartOut(t: number): number; + /** + !#en Easing in and out with quartic formula. From slow to fast, then back to slow. + !#zh 四次方曲线缓入缓出函数。运动由慢到快再到慢。 + @param t The current time as a percentage of the total time. + */ + quartInOut(t: number): number; + /** + !#en Easing in with quintic formula. From slow to fast. + !#zh 五次方曲线缓入函数。运动由慢到快。 + @param t The current time as a percentage of the total time. + */ + quintIn(t: number): number; + /** + !#en Easing out with quintic formula. From fast to slow. + !#zh 五次方曲线缓出函数。运动由快到慢。 + @param t The current time as a percentage of the total time. + */ + quintOut(t: number): number; + /** + !#en Easing in and out with quintic formula. From slow to fast, then back to slow. + !#zh 五次方曲线缓入缓出函数。运动由慢到快再到慢。 + @param t The current time as a percentage of the total time. + */ + quintInOut(t: number): number; + /** + !#en Easing in and out with sine formula. From slow to fast. + !#zh 正弦曲线缓入函数。运动由慢到快。 + @param t The current time as a percentage of the total time. + */ + sineIn(t: number): number; + /** + !#en Easing in and out with sine formula. From fast to slow. + !#zh 正弦曲线缓出函数。运动由快到慢。 + @param t The current time as a percentage of the total time. + */ + sineOut(t: number): number; + /** + !#en Easing in and out with sine formula. From slow to fast, then back to slow. + !#zh 正弦曲线缓入缓出函数。运动由慢到快再到慢。 + @param t The current time as a percentage of the total time. + */ + sineInOut(t: number): number; + /** + !#en Easing in and out with exponential formula. From slow to fast. + !#zh 指数曲线缓入函数。运动由慢到快。 + @param t The current time as a percentage of the total time. + */ + expoIn(t: number): number; + /** + !#en Easing in and out with exponential formula. From fast to slow. + !#zh 指数曲线缓出函数。运动由快到慢。 + @param t The current time as a percentage of the total time. + */ + expoOut(t: number): number; + /** + !#en Easing in and out with exponential formula. From slow to fast. + !#zh 指数曲线缓入和缓出函数。运动由慢到很快再到慢。 + @param t The current time as a percentage of the total time, then back to slow. + */ + expoInOut(t: number): number; + /** + !#en Easing in and out with circular formula. From slow to fast. + !#zh 循环公式缓入函数。运动由慢到快。 + @param t The current time as a percentage of the total time. + */ + circIn(t: number): number; + /** + !#en Easing in and out with circular formula. From fast to slow. + !#zh 循环公式缓出函数。运动由快到慢。 + @param t The current time as a percentage of the total time. + */ + circOut(t: number): number; + /** + !#en Easing in and out with circular formula. From slow to fast. + !#zh 指数曲线缓入缓出函数。运动由慢到很快再到慢。 + @param t The current time as a percentage of the total time, then back to slow. + */ + circInOut(t: number): number; + /** + !#en Easing in action with a spring oscillating effect. + !#zh 弹簧回震效果的缓入函数。 + @param t The current time as a percentage of the total time. + */ + elasticIn(t: number): number; + /** + !#en Easing out action with a spring oscillating effect. + !#zh 弹簧回震效果的缓出函数。 + @param t The current time as a percentage of the total time. + */ + elasticOut(t: number): number; + /** + !#en Easing in and out action with a spring oscillating effect. + !#zh 弹簧回震效果的缓入缓出函数。 + @param t The current time as a percentage of the total time. + */ + elasticInOut(t: number): number; + /** + !#en Easing in action with "back up" behavior. + !#zh 回退效果的缓入函数。 + @param t The current time as a percentage of the total time. + */ + backIn(t: number): number; + /** + !#en Easing out action with "back up" behavior. + !#zh 回退效果的缓出函数。 + @param t The current time as a percentage of the total time. + */ + backOut(t: number): number; + /** + !#en Easing in and out action with "back up" behavior. + !#zh 回退效果的缓入缓出函数。 + @param t The current time as a percentage of the total time. + */ + backInOut(t: number): number; + /** + !#en Easing in action with bouncing effect. + !#zh 弹跳效果的缓入函数。 + @param t The current time as a percentage of the total time. + */ + bounceIn(t: number): number; + /** + !#en Easing out action with bouncing effect. + !#zh 弹跳效果的缓出函数。 + @param t The current time as a percentage of the total time. + */ + bounceOut(t: number): number; + /** + !#en Easing in and out action with bouncing effect. + !#zh 弹跳效果的缓入缓出函数。 + @param t The current time as a percentage of the total time. + */ + bounceInOut(t: number): number; + /** + !#en Target will run action with smooth effect. + !#zh 平滑效果函数。 + @param t The current time as a percentage of the total time. + */ + smooth(t: number): number; + /** + !#en Target will run action with fade effect. + !#zh 渐褪效果函数。 + @param t The current time as a percentage of the total time. + */ + fade(t: number): number; + } + /** undefined */ + export class Playable { + /** !#en Is playing or paused in play mode? + !#zh 当前是否正在播放。 */ + isPlaying: boolean; + /** !#en Is currently paused? This can be true even if in edit mode(isPlaying == false). + !#zh 当前是否正在暂停 */ + isPaused: boolean; + /** + !#en Play this animation. + !#zh 播放动画。 + */ + play(): void; + /** + !#en Stop this animation. + !#zh 停止动画播放。 + */ + stop(): void; + /** + !#en Pause this animation. + !#zh 暂停动画。 + */ + pause(): void; + /** + !#en Resume this animation. + !#zh 重新播放动画。 + */ + resume(): void; + /** + !#en Perform a single frame step. + !#zh 执行一帧动画。 + */ + step(): void; + } + /** !#en Specifies how time is treated when it is outside of the keyframe range of an Animation. + !#zh 动画使用的循环模式。 */ + export enum WrapMode { + Default = 0, + Normal = 0, + Reverse = 0, + Loop = 0, + LoopReverse = 0, + PingPong = 0, + PingPongReverse = 0, + } + /** !#en cc.audioEngine is the singleton object, it provide simple audio APIs. + !#zh + cc.audioengine是单例对象。
+ 主要用来播放音频,播放的时候会返回一个 audioID,之后都可以通过这个 audioID 来操作这个音频对象。
+ 不使用的时候,请使用 cc.audioEngine.uncache(filePath); 进行资源释放
+ 注意:
+ 在 Android 系统浏览器上,不同浏览器,不同版本的效果不尽相同。
+ 比如说:大多数浏览器都需要用户物理交互才可以开始播放音效,有一些不支持 WebAudio,
+ 有一些不支持多音轨播放。总之如果对音乐依赖比较强,请做尽可能多的测试。 */ + export class audioEngine { + /** + !#en Play audio. + !#zh 播放音频 + @param clip The audio clip to play. + @param loop Whether the music loop or not. + @param volume Volume size. + + @example + ```js + cc.loader.loadRes(url, cc.AudioClip, function (err, clip) { + var audioID = cc.audioEngine.play(clip, false, 0.5); + }); + ``` + */ + static play(clip: AudioClip, loop: boolean, volume: number): number; + /** + !#en Set audio loop. + !#zh 设置音频是否循环。 + @param audioID audio id. + @param loop Whether cycle. + + @example + ```js + cc.audioEngine.setLoop(id, true); + ``` + */ + static setLoop(audioID: number, loop: boolean): void; + /** + !#en Get audio cycle state. + !#zh 获取音频的循环状态。 + @param audioID audio id. + + @example + ```js + cc.audioEngine.isLoop(id); + ``` + */ + static isLoop(audioID: number): boolean; + /** + !#en Set the volume of audio. + !#zh 设置音量(0.0 ~ 1.0)。 + @param audioID audio id. + @param volume Volume must be in 0.0~1.0 . + + @example + ```js + cc.audioEngine.setVolume(id, 0.5); + ``` + */ + static setVolume(audioID: number, volume: number): void; + /** + !#en The volume of the music max value is 1.0,the min value is 0.0 . + !#zh 获取音量(0.0 ~ 1.0)。 + @param audioID audio id. + + @example + ```js + var volume = cc.audioEngine.getVolume(id); + ``` + */ + static getVolume(audioID: number): number; + /** + !#en Set current time + !#zh 设置当前的音频时间。 + @param audioID audio id. + @param sec current time. + + @example + ```js + cc.audioEngine.setCurrentTime(id, 2); + ``` + */ + static setCurrentTime(audioID: number, sec: number): boolean; + /** + !#en Get current time + !#zh 获取当前的音频播放时间。 + @param audioID audio id. + + @example + ```js + var time = cc.audioEngine.getCurrentTime(id); + ``` + */ + static getCurrentTime(audioID: number): number; + /** + !#en Get audio duration + !#zh 获取音频总时长。 + @param audioID audio id. + + @example + ```js + var time = cc.audioEngine.getDuration(id); + ``` + */ + static getDuration(audioID: number): number; + /** + !#en Get audio state + !#zh 获取音频状态。 + @param audioID audio id. + + @example + ```js + var state = cc.audioEngine.getState(id); + ``` + */ + static getState(audioID: number): audioEngine.AudioState; + /** + !#en Set Audio finish callback + !#zh 设置一个音频结束后的回调 + @param audioID audio id. + @param callback loaded callback. + + @example + ```js + cc.audioEngine.setFinishCallback(id, function () {}); + ``` + */ + static setFinishCallback(audioID: number, callback: Function): void; + /** + !#en Pause playing audio. + !#zh 暂停正在播放音频。 + @param audioID The return value of function play. + + @example + ```js + cc.audioEngine.pause(audioID); + ``` + */ + static pause(audioID: number): void; + /** + !#en Pause all playing audio + !#zh 暂停现在正在播放的所有音频。 + + @example + ```js + cc.audioEngine.pauseAll(); + ``` + */ + static pauseAll(): void; + /** + !#en Resume playing audio. + !#zh 恢复播放指定的音频。 + @param audioID The return value of function play. + + @example + ```js + cc.audioEngine.resume(audioID); + ``` + */ + static resume(audioID: number): void; + /** + !#en Resume all playing audio. + !#zh 恢复播放所有之前暂停的所有音频。 + + @example + ```js + cc.audioEngine.resumeAll(); + ``` + */ + static resumeAll(): void; + /** + !#en Stop playing audio. + !#zh 停止播放指定音频。 + @param audioID The return value of function play. + + @example + ```js + cc.audioEngine.stop(audioID); + ``` + */ + static stop(audioID: number): void; + /** + !#en Stop all playing audio. + !#zh 停止正在播放的所有音频。 + + @example + ```js + cc.audioEngine.stopAll(); + ``` + */ + static stopAll(): void; + /** + !#en Set up an audio can generate a few examples. + !#zh 设置一个音频可以设置几个实例 + @param num a number of instances to be created from within an audio + + @example + ```js + cc.audioEngine.setMaxAudioInstance(20); + ``` + */ + static setMaxAudioInstance(num: number): void; + /** + !#en Getting audio can produce several examples. + !#zh 获取一个音频可以设置几个实例 + + @example + ```js + cc.audioEngine.getMaxAudioInstance(); + ``` + */ + static getMaxAudioInstance(): number; + /** + !#en Unload the preloaded audio from internal buffer. + !#zh 卸载预加载的音频。 + @param clip clip + + @example + ```js + cc.audioEngine.uncache(filePath); + ``` + */ + static uncache(clip: AudioClip): void; + /** + !#en Unload all audio from internal buffer. + !#zh 卸载所有音频。 + + @example + ```js + cc.audioEngine.uncacheAll(); + ``` + */ + static uncacheAll(): void; + /** + !#en Preload audio file. + !#zh 预加载一个音频 + @param filePath The file path of an audio. + @param callback The callback of an audio. + + @example + ```js + cc.audioEngine.preload(path); + ``` + */ + static preload(filePath: string, callback?: Function): void; + /** + !#en Set a size, the unit is KB. Over this size is directly resolved into DOM nodes. + !#zh 设置一个以 KB 为单位的尺寸,大于这个尺寸的音频在加载的时候会强制使用 dom 方式加载 + @param kb The file path of an audio. + + @example + ```js + cc.audioEngine.setMaxWebAudioSize(300); + ``` + */ + static setMaxWebAudioSize(kb: number): void; + /** + !#en Play background music + !#zh 播放背景音乐 + @param clip The audio clip to play. + @param loop Whether the music loop or not. + + @example + ```js + cc.loader.loadRes(url, cc.AudioClip, function (err, clip) { + var audioID = cc.audioEngine.playMusic(clip, false); + }); + ``` + */ + static playMusic(clip: AudioClip, loop: boolean): number; + /** + !#en Stop background music. + !#zh 停止播放背景音乐。 + + @example + ```js + cc.audioEngine.stopMusic(); + ``` + */ + static stopMusic(): void; + /** + !#en Pause the background music. + !#zh 暂停播放背景音乐。 + + @example + ```js + cc.audioEngine.pauseMusic(); + ``` + */ + static pauseMusic(): void; + /** + !#en Resume playing background music. + !#zh 恢复播放背景音乐。 + + @example + ```js + cc.audioEngine.resumeMusic(); + ``` + */ + static resumeMusic(): void; + /** + !#en Get the volume(0.0 ~ 1.0). + !#zh 获取音量(0.0 ~ 1.0)。 + + @example + ```js + var volume = cc.audioEngine.getMusicVolume(); + ``` + */ + static getMusicVolume(): number; + /** + !#en Set the background music volume. + !#zh 设置背景音乐音量(0.0 ~ 1.0)。 + @param volume Volume must be in 0.0~1.0. + + @example + ```js + cc.audioEngine.setMusicVolume(0.5); + ``` + */ + static setMusicVolume(volume: number): void; + /** + !#en Background music playing state + !#zh 背景音乐是否正在播放 + + @example + ```js + cc.audioEngine.isMusicPlaying(); + ``` + */ + static isMusicPlaying(): boolean; + /** + !#en Play effect audio. + !#zh 播放音效 + @param clip The audio clip to play. + @param loop Whether the music loop or not. + + @example + ```js + cc.loader.loadRes(url, cc.AudioClip, function (err, clip) { + var audioID = cc.audioEngine.playEffect(clip, false); + }); + ``` + */ + static playEffect(clip: AudioClip, loop: boolean): number; + /** + !#en Set the volume of effect audio. + !#zh 设置音效音量(0.0 ~ 1.0)。 + @param volume Volume must be in 0.0~1.0. + + @example + ```js + cc.audioEngine.setEffectsVolume(0.5); + ``` + */ + static setEffectsVolume(volume: number): void; + /** + !#en The volume of the effect audio max value is 1.0,the min value is 0.0 . + !#zh 获取音效音量(0.0 ~ 1.0)。 + + @example + ```js + var volume = cc.audioEngine.getEffectsVolume(); + ``` + */ + static getEffectsVolume(): number; + /** + !#en Pause effect audio. + !#zh 暂停播放音效。 + @param audioID audio id. + + @example + ```js + cc.audioEngine.pauseEffect(audioID); + ``` + */ + static pauseEffect(audioID: number): void; + /** + !#en Stop playing all the sound effects. + !#zh 暂停播放所有音效。 + + @example + ```js + cc.audioEngine.pauseAllEffects(); + ``` + */ + static pauseAllEffects(): void; + /** + !#en Resume effect audio. + !#zh 恢复播放音效音频。 + @param audioID The return value of function play. + + @example + ```js + cc.audioEngine.resumeEffect(audioID); + ``` + */ + static resumeEffect(audioID: number): void; + /** + !#en Resume all effect audio. + !#zh 恢复播放所有之前暂停的音效。 + + @example + ```js + cc.audioEngine.resumeAllEffects(); + ``` + */ + static resumeAllEffects(): void; + /** + !#en Stop playing the effect audio. + !#zh 停止播放音效。 + @param audioID audio id. + + @example + ```js + cc.audioEngine.stopEffect(id); + ``` + */ + static stopEffect(audioID: number): void; + /** + !#en Stop playing all the effects. + !#zh 停止播放所有音效。 + + @example + ```js + cc.audioEngine.stopAllEffects(); + ``` + */ + static stopAllEffects(): void; + } + /** !#en Base class cc.Action for action classes. + !#zh Action 类是所有动作类型的基类。 */ + export class Action { + /** + !#en + to copy object with deep copy. + returns a clone of action. + !#zh 返回一个克隆的动作。 + */ + clone(): Action; + /** + !#en + return true if the action has finished. + !#zh 如果动作已完成就返回 true。 + */ + isDone(): boolean; + /** + !#en get the target. + !#zh 获取当前目标节点。 + */ + getTarget(): Node; + /** + !#en The action will modify the target properties. + !#zh 设置目标节点。 + @param target target + */ + setTarget(target: Node): void; + /** + !#en get the original target. + !#zh 获取原始目标节点。 + */ + getOriginalTarget(): Node; + /** + !#en get tag number. + !#zh 获取用于识别动作的标签。 + */ + getTag(): number; + /** + !#en set tag number. + !#zh 设置标签,用于识别动作。 + @param tag tag + */ + setTag(tag: number): void; + /** !#en Default Action tag. + !#zh 默认动作标签。 */ + static TAG_INVALID: number; + } + /** !#en + Base class actions that do have a finite time duration.
+ Possible actions:
+ - An action with a duration of 0 seconds.
+ - An action with a duration of 35.5 seconds. + + Infinite time actions are valid + !#zh 有限时间动作,这种动作拥有时长 duration 属性。 */ + export class FiniteTimeAction extends Action { + /** + !#en get duration of the action. (seconds). + !#zh 获取动作以秒为单位的持续时间。 + */ + getDuration(): number; + /** + !#en set duration of the action. (seconds). + !#zh 设置动作以秒为单位的持续时间。 + @param duration duration + */ + setDuration(duration: number): void; + /** + !#en + Returns a reversed action.
+ For example:
+ - The action will be x coordinates of 0 move to 100.
+ - The reversed action will be x of 100 move to 0. + - Will be rewritten + !#zh 返回一个新的动作,执行与原动作完全相反的动作。 + */ + reverse(): void; + /** + !#en + to copy object with deep copy. + returns a clone of action. + !#zh 返回一个克隆的动作。 + */ + clone(): FiniteTimeAction; + } + /** !#en Instant actions are immediate actions. They don't have a duration like the ActionInterval actions. + !#zh 即时动作,这种动作立即就会执行,继承自 FiniteTimeAction。 */ + export class ActionInstant extends FiniteTimeAction { + } + /** !#en +

An interval action is an action that takes place within a certain period of time.
+ It has an start time, and a finish time. The finish time is the parameter
+ duration plus the start time.

+ +

These CCActionInterval actions have some interesting properties, like:
+ - They can run normally (default)
+ - They can run reversed with the reverse method
+ - They can run with the time altered with the Accelerate, AccelDeccel and Speed actions.

+ +

For example, you can simulate a Ping Pong effect running the action normally and
+ then running it again in Reverse mode.

+ !#zh 时间间隔动作,这种动作在已定时间内完成,继承 FiniteTimeAction。 */ + export class ActionInterval extends FiniteTimeAction { + /** + !#en Implementation of ease motion. + !#zh 缓动运动。 + @param easeObj easeObj + + @example + ```js + action.easing(cc.easeIn(3.0)); + ``` + */ + easing(easeObj: any): ActionInterval; + /** + !#en + Repeats an action a number of times. + To repeat an action forever use the CCRepeatForever action. + !#zh 重复动作可以按一定次数重复一个动作,使用 RepeatForever 动作来永远重复一个动作。 + @param times times + */ + repeat(times: number): ActionInterval; + /** + !#en + Repeats an action for ever.
+ To repeat the an action for a limited number of times use the Repeat action.
+ !#zh 永远地重复一个动作,有限次数内重复一个动作请使用 Repeat 动作。 + */ + repeatForever(): ActionInterval; + } + /** !#en + cc.ActionManager is a class that can manage actions.
+ Normally you won't need to use this class directly. 99% of the cases you will use the CCNode interface, + which uses this class's singleton object. + But there are some cases where you might need to use this class.
+ Examples:
+ - When you want to run an action where the target is different from a CCNode.
+ - When you want to pause / resume the actions
+ !#zh + cc.ActionManager 是可以管理动作的单例类。
+ 通常你并不需要直接使用这个类,99%的情况您将使用 CCNode 的接口。
+ 但也有一些情况下,您可能需要使用这个类。
+ 例如: + - 当你想要运行一个动作,但目标不是 CCNode 类型时。
+ - 当你想要暂停/恢复动作时。
*/ + export class ActionManager { + /** + !#en + Adds an action with a target.
+ If the target is already present, then the action will be added to the existing target. + If the target is not present, a new instance of this target will be created either paused or not, and the action will be added to the newly created target. + When the target is paused, the queued actions won't be 'ticked'. + !#zh + 增加一个动作,同时还需要提供动作的目标对象,目标对象是否暂停作为参数。
+ 如果目标已存在,动作将会被直接添加到现有的节点中。
+ 如果目标不存在,将为这一目标创建一个新的实例,并将动作添加进去。
+ 当目标状态的 paused 为 true,动作将不会被执行 + @param action action + @param target target + @param paused paused + */ + addAction(action: Action, target: Node, paused: boolean): void; + /** + !#en Removes all actions from all the targets. + !#zh 移除所有对象的所有动作。 + */ + removeAllActions(): void; + /** + !#en + Removes all actions from a certain target.
+ All the actions that belongs to the target will be removed. + !#zh + 移除指定对象上的所有动作。
+ 属于该目标的所有的动作将被删除。 + @param target target + @param forceDelete forceDelete + */ + removeAllActionsFromTarget(target: Node, forceDelete: boolean): void; + /** + !#en Removes an action given an action reference. + !#zh 移除指定的动作。 + @param action action + */ + removeAction(action: Action): void; + /** + !#en Removes an action given its tag and the target. + !#zh 删除指定对象下特定标签的一个动作,将删除首个匹配到的动作。 + @param tag tag + @param target target + */ + removeActionByTag(tag: number, target?: Node): void; + /** + !#en Gets an action given its tag an a target. + !#zh 通过目标对象和标签获取一个动作。 + @param tag tag + @param target target + */ + getActionByTag(tag: number, target: Node): Action; + /** + !#en + Returns the numbers of actions that are running in a certain target.
+ Composable actions are counted as 1 action.
+ Example:
+ - If you are running 1 Sequence of 7 actions, it will return 1.
+ - If you are running 7 Sequences of 2 actions, it will return 7. + !#zh + 返回指定对象下所有正在运行的动作数量。
+ 组合动作被算作一个动作。
+ 例如:
+ - 如果您正在运行 7 个动作组成的序列动作(Sequence),这个函数将返回 1。
+ - 如果你正在运行 2 个序列动作(Sequence)和 5 个普通动作,这个函数将返回 7。
+ @param target target + */ + getNumberOfRunningActionsInTarget(target: Node): number; + /** + !#en Pauses the target: all running actions and newly added actions will be paused. + !#zh 暂停指定对象:所有正在运行的动作和新添加的动作都将会暂停。 + @param target target + */ + pauseTarget(target: Node): void; + /** + !#en Resumes the target. All queued actions will be resumed. + !#zh 让指定目标恢复运行。在执行序列中所有被暂停的动作将重新恢复运行。 + @param target target + */ + resumeTarget(target: Node): void; + /** + !#en Pauses all running actions, returning a list of targets whose actions were paused. + !#zh 暂停所有正在运行的动作,返回一个包含了那些动作被暂停了的目标对象的列表。 + */ + pauseAllRunningActions(): any[]; + /** + !#en Resume a set of targets (convenience function to reverse a pauseAllRunningActions or pauseTargets call). + !#zh 让一组指定对象恢复运行(用来逆转 pauseAllRunningActions 效果的便捷函数)。 + @param targetsToResume targetsToResume + */ + resumeTargets(targetsToResume: any[]): void; + /** + !#en Pause a set of targets. + !#zh 暂停一组指定对象。 + @param targetsToPause targetsToPause + */ + pauseTargets(targetsToPause: any[]): void; + /** + !#en + purges the shared action manager. It releases the retained instance.
+ because it uses this, so it can not be static. + !#zh + 清除共用的动作管理器。它释放了持有的实例。
+ 因为它使用 this,因此它不能是静态的。 + */ + purgeSharedManager(): void; + /** + !#en The ActionManager update。 + !#zh ActionManager 主循环。 + @param dt delta time in seconds + */ + update(dt: number): void; + } + /** !#en + Tween provide a simple and flexible way to create action. + Tween's api is more flexible than cc.Action: + - Support creating an action sequence in chained api, + - Support animate any objects' any properties, not limited to node's properties. + By contrast, cc.Action needs to create a new action class to support new node property. + - Support working with cc.Action, + - Support easing and progress function. + !#zh + Tween 提供了一个简单灵活的方法来创建 action。 + 相对于 Cocos 传统的 cc.Action,cc.Tween 在创建动画上要灵活非常多: + - 支持以链式结构的方式创建一个动画序列。 + - 支持对任意对象的任意属性进行缓动,不再局限于节点上的属性,而 cc.Action 添加一个属性的支持时还需要添加一个新的 action 类型。 + - 支持与 cc.Action 混用 + - 支持设置 {{#crossLink "Easing"}}{{/crossLink}} 或者 progress 函数 */ + export class Tween { + /** + + @param target target + */ + constructor(target?: any); + /** + !#en Stop all tweens + !#zh 停止所有缓动 + */ + static stopAll(): void; + /** + !#en Stop all tweens by tag + !#zh 停止所有指定标签的缓动 + @param tag tag + */ + static stopAllByTag(tag: number): void; + /** + !#en Stop all tweens by target + !#zh 停止所有指定对象的缓动 + @param target target + */ + static stopAllByTarget(target: any): void; + /** + !#en + Insert an action or tween to this sequence + !#zh + 插入一个 action 或者 tween 到队列中 + @param other other + */ + then(other: Action|Tween): Tween; + /** + !#en + Set tween target + !#zh + 设置 tween 的 target + @param target target + */ + target(target: any): Tween; + /** + !#en + Start this tween + !#zh + 运行当前 tween + */ + start(): Tween; + /** + !#en + Stop this tween + !#zh + 停止当前 tween + */ + stop(): Tween; + /** + !#en Sets tween tag + !#zh 设置缓动的标签 + @param tag tag + */ + tag(tag: number): Tween; + /** + !#en + Clone a tween + !#zh + 克隆当前 tween + @param target target + */ + clone(target?: any): Tween; + /** + !#en + Integrate all previous actions to an action. + !#zh + 将之前所有的 action 整合为一个 action。 + */ + union(): Tween; + /** + !#en Sets target's position property according to the bezier curve. + !#zh 按照贝塞尔路径设置目标的 position 属性。 + @param duration duration + @param c1 c1 + @param c2 c2 + @param to to + */ + bezierTo(duration: number, c1: Vec2, c2: Vec2, to: Vec2): Tween; + /** + !#en Sets target's position property according to the bezier curve. + !#zh 按照贝塞尔路径设置目标的 position 属性。 + @param duration duration + @param c1 c1 + @param c2 c2 + @param to to + */ + bezierBy(duration: number, c1: Vec2, c2: Vec2, to: Vec2): Tween; + /** + !#en Flips target's scaleX + !#zh 翻转目标的 scaleX 属性 + */ + flipX(): Tween; + /** + !#en Flips target's scaleY + !#zh 翻转目标的 scaleY 属性 + */ + flipY(): Tween; + /** + !#en Blinks target by set target's opacity property + !#zh 通过设置目标的 opacity 属性达到闪烁效果 + @param duration duration + @param times times + @param opts opts + */ + blink(duration: number, times: number, opts?: {progress?: Function; easing?: Function|string; }): Tween; + /** + !#en + Add an action which calculate with absolute value + !#zh + 添加一个对属性进行绝对值计算的 action + @param duration duration + @param props {scale: 2, position: cc.v3(100, 100, 100)} + @param opts opts + */ + to > (duration: number, props: ConstructorType, opts?: OPTS) : Tween; + /** + !#en + Add an action which calculate with relative value + !#zh + 添加一个对属性进行相对值计算的 action + @param duration duration + @param props {scale: 2, position: cc.v3(100, 100, 100)} + @param opts opts + */ + by > (duration: number, props: ConstructorType, opts?: OPTS) : Tween; + /** + !#en + Directly set target properties + !#zh + 直接设置 target 的属性 + @param props props + */ + set (props: ConstructorType) : Tween; + /** + !#en + Add an delay action + !#zh + 添加一个延时 action + @param duration duration + */ + delay(duration: number): Tween; + /** + !#en + Add an callback action + !#zh + 添加一个回调 action + @param callback callback + */ + call(callback: Function): Tween; + /** + !#en + Add an hide action + !#zh + 添加一个隐藏 action + */ + hide(): Tween; + /** + !#en + Add an show action + !#zh + 添加一个显示 action + */ + show(): Tween; + /** + !#en + Add an removeSelf action + !#zh + 添加一个移除自己 action + */ + removeSelf(): Tween; + /** + !#en + Add an sequence action + !#zh + 添加一个队列 action + @param action action + @param actions actions + */ + sequence(action: Action|Tween, ...actions: (Action|Tween)[]): Tween; + /** + !#en + Add an parallel action + !#zh + 添加一个并行 action + @param action action + @param actions actions + */ + parallel(action: Action|Tween, ...actions: (Action|Tween)[]): Tween; + /** + !#en + Add an repeat action. + This action will integrate before actions to a sequence action as their parameters. + !#zh + 添加一个重复 action,这个 action 会将前一个动作作为他的参数。 + @param repeatTimes repeatTimes + @param action action + */ + repeat(repeatTimes: number, action?: Action|Tween): Tween; + /** + !#en + Add an repeat forever action + This action will integrate before actions to a sequence action as their parameters. + !#zh + 添加一个永久重复 action,这个 action 会将前一个动作作为他的参数。 + @param action action + */ + repeatForever(action?: Action|Tween): Tween; + /** + !#en + Add an reverse time action. + This action will integrate before actions to a sequence action as their parameters. + !#zh + 添加一个倒置时间 action,这个 action 会将前一个动作作为他的参数。 + @param action action + */ + reverseTime(action?: Action|Tween): Tween; + } + /** Class for particle asset handling. */ + export class ParticleAsset extends Asset { + } + /** Particle System base class.
+ Attributes of a Particle System:
+ - emmision rate of the particles
+ - Gravity Mode (Mode A):
+ - gravity
+ - direction
+ - speed +- variance
+ - tangential acceleration +- variance
+ - radial acceleration +- variance
+ - Radius Mode (Mode B):
+ - startRadius +- variance
+ - endRadius +- variance
+ - rotate +- variance
+ - Properties common to all modes:
+ - life +- life variance
+ - start spin +- variance
+ - end spin +- variance
+ - start size +- variance
+ - end size +- variance
+ - start color +- variance
+ - end color +- variance
+ - life +- variance
+ - blending function
+ - texture
+
+ cocos2d also supports particles generated by Particle Designer (http://particledesigner.71squared.com/).
+ 'Radius Mode' in Particle Designer uses a fixed emit rate of 30 hz. Since that can't be guarateed in cocos2d,
+ cocos2d uses a another approach, but the results are almost identical.
+ cocos2d supports all the variables used by Particle Designer plus a bit more:
+ - spinning particles (supported when using ParticleSystem)
+ - tangential acceleration (Gravity mode)
+ - radial acceleration (Gravity mode)
+ - radius direction (Radius mode) (Particle Designer supports outwards to inwards direction only)
+ It is possible to customize any of the above mentioned properties in runtime. Example:
*/ + export class ParticleSystem extends RenderComponent implements BlendFunc { + /** !#en Play particle in edit mode. + !#zh 在编辑器模式下预览粒子,启用后选中粒子时,粒子将自动播放。 */ + preview: boolean; + /** !#en + If set custom to true, then use custom properties insteadof read particle file. + !#zh 是否自定义粒子属性。 */ + custom: boolean; + /** !#en The plist file. + !#zh plist 格式的粒子配置文件。 */ + file: ParticleAsset; + /** !#en SpriteFrame used for particles display + !#zh 用于粒子呈现的 SpriteFrame */ + spriteFrame: SpriteFrame; + /** !#en Texture of Particle System, readonly, please use spriteFrame to setup new texture。 + !#zh 粒子贴图,只读属性,请使用 spriteFrame 属性来替换贴图。 */ + texture: string; + /** !#en Current quantity of particles that are being simulated. + !#zh 当前播放的粒子数量。 */ + particleCount: number; + /** !#en Indicate whether the system simulation have stopped. + !#zh 指示粒子播放是否完毕。 */ + stopped: boolean; + /** !#en If set to true, the particle system will automatically start playing on onLoad. + !#zh 如果设置为 true 运行时会自动发射粒子。 */ + playOnLoad: boolean; + /** !#en Indicate whether the owner node will be auto-removed when it has no particles left. + !#zh 粒子播放完毕后自动销毁所在的节点。 */ + autoRemoveOnFinish: boolean; + /** !#en Indicate whether the particle system is activated. + !#zh 是否激活粒子。 */ + active: boolean; + /** !#en Maximum particles of the system. + !#zh 粒子最大数量。 */ + totalParticles: number; + /** !#en How many seconds the emitter wil run. -1 means 'forever'. + !#zh 发射器生存时间,单位秒,-1表示持续发射。 */ + duration: number; + /** !#en Emission rate of the particles. + !#zh 每秒发射的粒子数目。 */ + emissionRate: number; + /** !#en Life of each particle setter. + !#zh 粒子的运行时间。 */ + life: number; + /** !#en Variation of life. + !#zh 粒子的运行时间变化范围。 */ + lifeVar: number; + /** !#en Start color of each particle. + !#zh 粒子初始颜色。 */ + startColor: Color; + /** !#en Variation of the start color. + !#zh 粒子初始颜色变化范围。 */ + startColorVar: Color; + /** !#en Ending color of each particle. + !#zh 粒子结束颜色。 */ + endColor: Color; + /** !#en Variation of the end color. + !#zh 粒子结束颜色变化范围。 */ + endColorVar: Color; + /** !#en Angle of each particle setter. + !#zh 粒子角度。 */ + angle: number; + /** !#en Variation of angle of each particle setter. + !#zh 粒子角度变化范围。 */ + angleVar: number; + /** !#en Start size in pixels of each particle. + !#zh 粒子的初始大小。 */ + startSize: number; + /** !#en Variation of start size in pixels. + !#zh 粒子初始大小的变化范围。 */ + startSizeVar: number; + /** !#en End size in pixels of each particle. + !#zh 粒子结束时的大小。 */ + endSize: number; + /** !#en Variation of end size in pixels. + !#zh 粒子结束大小的变化范围。 */ + endSizeVar: number; + /** !#en Start angle of each particle. + !#zh 粒子开始自旋角度。 */ + startSpin: number; + /** !#en Variation of start angle. + !#zh 粒子开始自旋角度变化范围。 */ + startSpinVar: number; + /** !#en End angle of each particle. + !#zh 粒子结束自旋角度。 */ + endSpin: number; + /** !#en Variation of end angle. + !#zh 粒子结束自旋角度变化范围。 */ + endSpinVar: number; + /** !#en Source position of the emitter. + !#zh 发射器位置。 */ + sourcePos: Vec2; + /** !#en Variation of source position. + !#zh 发射器位置的变化范围。(横向和纵向) */ + posVar: Vec2; + /** !#en Particles movement type. + !#zh 粒子位置类型。 */ + positionType: ParticleSystem.PositionType; + /** !#en Particles emitter modes. + !#zh 发射器类型。 */ + emitterMode: ParticleSystem.EmitterMode; + /** !#en Gravity of the emitter. + !#zh 重力。 */ + gravity: Vec2; + /** !#en Speed of the emitter. + !#zh 速度。 */ + speed: number; + /** !#en Variation of the speed. + !#zh 速度变化范围。 */ + speedVar: number; + /** !#en Tangential acceleration of each particle. Only available in 'Gravity' mode. + !#zh 每个粒子的切向加速度,即垂直于重力方向的加速度,只有在重力模式下可用。 */ + tangentialAccel: number; + /** !#en Variation of the tangential acceleration. + !#zh 每个粒子的切向加速度变化范围。 */ + tangentialAccelVar: number; + /** !#en Acceleration of each particle. Only available in 'Gravity' mode. + !#zh 粒子径向加速度,即平行于重力方向的加速度,只有在重力模式下可用。 */ + radialAccel: number; + /** !#en Variation of the radial acceleration. + !#zh 粒子径向加速度变化范围。 */ + radialAccelVar: number; + /** !#en Indicate whether the rotation of each particle equals to its direction. Only available in 'Gravity' mode. + !#zh 每个粒子的旋转是否等于其方向,只有在重力模式下可用。 */ + rotationIsDir: boolean; + /** !#en Starting radius of the particles. Only available in 'Radius' mode. + !#zh 初始半径,表示粒子出生时相对发射器的距离,只有在半径模式下可用。 */ + startRadius: number; + /** !#en Variation of the starting radius. + !#zh 初始半径变化范围。 */ + startRadiusVar: number; + /** !#en Ending radius of the particles. Only available in 'Radius' mode. + !#zh 结束半径,只有在半径模式下可用。 */ + endRadius: number; + /** !#en Variation of the ending radius. + !#zh 结束半径变化范围。 */ + endRadiusVar: number; + /** !#en Number of degress to rotate a particle around the source pos per second. Only available in 'Radius' mode. + !#zh 粒子每秒围绕起始点的旋转角度,只有在半径模式下可用。 */ + rotatePerS: number; + /** !#en Variation of the degress to rotate a particle around the source pos per second. + !#zh 粒子每秒围绕起始点的旋转角度变化范围。 */ + rotatePerSVar: number; + /** !#en The Particle emitter lives forever. + !#zh 表示发射器永久存在 */ + static DURATION_INFINITY: number; + /** !#en The starting size of the particle is equal to the ending size. + !#zh 表示粒子的起始大小等于结束大小。 */ + static START_SIZE_EQUAL_TO_END_SIZE: number; + /** !#en The starting radius of the particle is equal to the ending radius. + !#zh 表示粒子的起始半径等于结束半径。 */ + static START_RADIUS_EQUAL_TO_END_RADIUS: number; + /** + !#en Stop emitting particles. Running particles will continue to run until they die. + !#zh 停止发射器发射粒子,发射出去的粒子将继续运行,直至粒子生命结束。 + + @example + ```js + // stop particle system. + myParticleSystem.stopSystem(); + ``` + */ + stopSystem(): void; + /** + !#en Kill all living particles. + !#zh 杀死所有存在的粒子,然后重新启动粒子发射器。 + + @example + ```js + // play particle system. + myParticleSystem.resetSystem(); + ``` + */ + resetSystem(): void; + /** + !#en Whether or not the system is full. + !#zh 发射器中粒子是否大于等于设置的总粒子数量。 + */ + isFull(): boolean; + /** + !#en Sets a new texture with a rect. The rect is in texture position and size. + Please use spriteFrame property instead, this function is deprecated since v1.9 + !#zh 设置一张新贴图和关联的矩形。 + 请直接设置 spriteFrame 属性,这个函数从 v1.9 版本开始已经被废弃 + @param texture texture + @param rect rect + */ + setTextureWithRect(texture: Texture2D, rect: Rect): void; + /** !#en specify the source Blend Factor, this will generate a custom material object, please pay attention to the memory cost. + !#zh 指定原图的混合模式,这会克隆一个新的材质对象,注意这带来的开销 */ + srcBlendFactor: macro.BlendFactor; + /** !#en specify the destination Blend Factor. + !#zh 指定目标的混合模式 */ + dstBlendFactor: macro.BlendFactor; + } + /** cc.TMXLayerInfo contains the information about the layers like: + - Layer name + - Layer size + - Layer opacity at creation time (it can be modified at runtime) + - Whether the layer is visible (if it's not visible, then the CocosNode won't be created) + This information is obtained from the TMX file. */ + export class TMXLayerInfo { + /** Properties of the layer info. */ + properties: any; + } + /** cc.TMXImageLayerInfo contains the information about the image layers. + This information is obtained from the TMX file. */ + export class TMXImageLayerInfo { + } + /**

cc.TMXObjectGroupInfo contains the information about the object group like: + - group name + - group size + - group opacity at creation time (it can be modified at runtime) + - Whether the group is visible + + This information is obtained from the TMX file.

*/ + export class TMXObjectGroupInfo { + /** Properties of the ObjectGroup info. */ + properties: any[]; + } + /**

cc.TMXTilesetInfo contains the information about the tilesets like:
+ - Tileset name
+ - Tileset spacing
+ - Tileset margin
+ - size of the tiles
+ - Image used for the tiles
+ - Image size
+ + This information is obtained from the TMX file.

*/ + export class TMXTilesetInfo { + /** Tileset name */ + name: string; + /** First grid */ + firstGid: number; + /** Spacing */ + spacing: number; + /** Margin */ + margin: number; + /** Texture containing the tiles (should be sprite sheet / texture atlas) */ + sourceImage: any; + /** Size in pixels of the image */ + imageSize: Size; + } + /**

cc.TMXMapInfo contains the information about the map like:
+ - Map orientation (hexagonal, isometric or orthogonal)
+ - Tile size
+ - Map size

+ +

And it also contains:
+ - Layers (an array of TMXLayerInfo objects)
+ - Tilesets (an array of TMXTilesetInfo objects)
+ - ObjectGroups (an array of TMXObjectGroupInfo objects)

+ +

This information is obtained from the TMX file.

*/ + export class TMXMapInfo { + /** Properties of the map info. */ + properties: any[]; + /** Map orientation. */ + orientation: number; + /** Parent element. */ + parentElement: any; + /** Parent GID. */ + parentGID: number; + /** Layer attributes. */ + layerAttrs: any; + /** Is reading storing characters stream. */ + storingCharacters: boolean; + /** Current string stored from characters stream. */ + currentString: string; + /** Width of the map */ + mapWidth: number; + /** Height of the map */ + mapHeight: number; + /** Width of a tile */ + tileWidth: number; + /** Height of a tile */ + tileHeight: number; + static ATTRIB_NONE: number; + static ATTRIB_BASE64: number; + static ATTRIB_GZIP: number; + static ATTRIB_ZLIB: number; + } + /** !#en Render the TMX layer. + !#zh 渲染 TMX layer。 */ + export class TiledLayer extends Component { + /** + !#en enable or disable culling + !#zh 开启或关闭裁剪。 + @param value value + */ + enableCulling(value: any): void; + /** + !#en Adds user's node into layer. + !#zh 添加用户节点。 + @param node node + */ + addUserNode(node: Node): boolean; + /** + !#en Removes user's node. + !#zh 移除用户节点。 + @param node node + */ + removeUserNode(node: Node): boolean; + /** + !#en Destroy user's node. + !#zh 销毁用户节点。 + @param node node + */ + destroyUserNode(node: Node): void; + /** + !#en Gets the layer name. + !#zh 获取层的名称。 + + @example + ```js + let layerName = tiledLayer.getLayerName(); + cc.log(layerName); + ``` + */ + getLayerName(): string; + /** + !#en Set the layer name. + !#zh 设置层的名称 + @param layerName layerName + + @example + ```js + tiledLayer.setLayerName("New Layer"); + ``` + */ + SetLayerName(layerName: string): void; + /** + !#en Return the value for the specific property name. + !#zh 获取指定属性名的值。 + @param propertyName propertyName + + @example + ```js + let property = tiledLayer.getProperty("info"); + cc.log(property); + ``` + */ + getProperty(propertyName: string): any; + /** + !#en Returns the position in pixels of a given tile coordinate. + !#zh 获取指定 tile 的像素坐标。 + @param pos position or x + @param y y + + @example + ```js + let pos = tiledLayer.getPositionAt(cc.v2(0, 0)); + cc.log("Pos: " + pos); + let pos = tiledLayer.getPositionAt(0, 0); + cc.log("Pos: " + pos); + ``` + */ + getPositionAt(pos: Vec2|number, y?: number): Vec2; + /** + !#en + Sets the tile gid (gid = tile global id) at a given tile coordinate.
+ The Tile GID can be obtained by using the method "tileGIDAt" or by using the TMX editor . Tileset Mgr +1.
+ If a tile is already placed at that position, then it will be removed. + !#zh + 设置给定坐标的 tile 的 gid (gid = tile 全局 id), + tile 的 GID 可以使用方法 “tileGIDAt” 来获得。
+ 如果一个 tile 已经放在那个位置,那么它将被删除。 + @param gid gid + @param posOrX position or x + @param flagsOrY flags or y + @param flags flags + + @example + ```js + tiledLayer.setTileGIDAt(1001, 10, 10, 1) + ``` + */ + setTileGIDAt(gid: number, posOrX: Vec2|number, flagsOrY: number, flags?: number): void; + /** + !#en + Returns the tile gid at a given tile coordinate.
+ if it returns 0, it means that the tile is empty.
+ !#zh + 通过给定的 tile 坐标、flags(可选)返回 tile 的 GID.
+ 如果它返回 0,则表示该 tile 为空。
+ @param pos or x + @param y y + + @example + ```js + let tileGid = tiledLayer.getTileGIDAt(0, 0); + ``` + */ + getTileGIDAt(pos: Vec2|number, y?: number): number; + /** + !#en Layer orientation, which is the same as the map orientation. + !#zh 获取 Layer 方向(同地图方向)。 + + @example + ```js + let orientation = tiledLayer.getLayerOrientation(); + cc.log("Layer Orientation: " + orientation); + ``` + */ + getLayerOrientation(): number; + /** + !#en properties from the layer. They can be added using Tiled. + !#zh 获取 layer 的属性,可以使用 Tiled 编辑器添加属性。 + + @example + ```js + let properties = tiledLayer.getProperties(); + cc.log("Properties: " + properties); + ``` + */ + getProperties(): any; + /** + !#en + Get the TiledTile with the tile coordinate.
+ If there is no tile in the specified coordinate and forceCreate parameter is true,
+ then will create a new TiledTile at the coordinate. + The renderer will render the tile with the rotation, scale, position and color property of the TiledTile. + !#zh + 通过指定的 tile 坐标获取对应的 TiledTile。
+ 如果指定的坐标没有 tile,并且设置了 forceCreate 那么将会在指定的坐标创建一个新的 TiledTile 。
+ 在渲染这个 tile 的时候,将会使用 TiledTile 的节点的旋转、缩放、位移、颜色属性。
+ @param x x + @param y y + @param forceCreate forceCreate + + @example + ```js + let tile = tiledLayer.getTiledTileAt(100, 100, true); + cc.log(tile); + ``` + */ + getTiledTileAt(x: number, y: number, forceCreate: boolean): TiledTile; + /** + !#en + Change tile to TiledTile at the specified coordinate. + !#zh + 将指定的 tile 坐标替换为指定的 TiledTile。 + @param x x + @param y y + @param tiledTile tiledTile + */ + setTiledTileAt(x: number, y: number, tiledTile: TiledTile): TiledTile; + /** + !#en Return texture. + !#zh 获取纹理。 + @param index The index of textures + */ + getTexture(index: any): Texture2D; + /** + !#en Return texture. + !#zh 获取纹理。 + */ + getTextures(): Texture2D; + /** + !#en Set the texture. + !#zh 设置纹理。 + @param texture texture + */ + setTexture(texture: Texture2D): void; + /** + !#en Set the texture. + !#zh 设置纹理。 + @param textures textures + */ + setTexture(textures: Texture2D): void; + /** + !#en Gets layer size. + !#zh 获得层大小。 + + @example + ```js + let size = tiledLayer.getLayerSize(); + cc.log("layer size: " + size); + ``` + */ + getLayerSize(): Size; + /** + !#en Size of the map's tile (could be different from the tile's size). + !#zh 获取 tile 的大小( tile 的大小可能会有所不同)。 + + @example + ```js + let mapTileSize = tiledLayer.getMapTileSize(); + cc.log("MapTile size: " + mapTileSize); + ``` + */ + getMapTileSize(): Size; + /** + !#en Gets Tile set first information for the layer. + !#zh 获取 layer 索引位置为0的 Tileset 信息。 + @param index The index of tilesets + */ + getTileSet(index: any): TMXTilesetInfo; + /** + !#en Gets tile set all information for the layer. + !#zh 获取 layer 所有的 Tileset 信息。 + */ + getTileSet(): TMXTilesetInfo; + /** + !#en Sets tile set information for the layer. + !#zh 设置 layer 的 tileset 信息。 + @param tileset tileset + */ + setTileSet(tileset: TMXTilesetInfo): void; + /** + !#en Sets Tile set information for the layer. + !#zh 设置 layer 的 Tileset 信息。 + @param tilesets tilesets + */ + setTileSets(tilesets: TMXTilesetInfo): void; + } + /** !#en Renders a TMX Tile Map in the scene. + !#zh 在场景中渲染一个 tmx 格式的 Tile Map。 */ + export class TiledMap extends Component { + /** !#en The TiledMap Asset. + !#zh TiledMap 资源。 */ + tmxAsset: TiledMapAsset; + /** + !#en Gets the map size. + !#zh 获取地图大小。 + + @example + ```js + let mapSize = tiledMap.getMapSize(); + cc.log("Map Size: " + mapSize); + ``` + */ + getMapSize(): Size; + /** + !#en Gets the tile size. + !#zh 获取地图背景中 tile 元素的大小。 + + @example + ```js + let tileSize = tiledMap.getTileSize(); + cc.log("Tile Size: " + tileSize); + ``` + */ + getTileSize(): Size; + /** + !#en map orientation. + !#zh 获取地图方向。 + + @example + ```js + let mapOrientation = tiledMap.getMapOrientation(); + cc.log("Map Orientation: " + mapOrientation); + ``` + */ + getMapOrientation(): number; + /** + !#en object groups. + !#zh 获取所有的对象层。 + + @example + ```js + let objGroups = titledMap.getObjectGroups(); + for (let i = 0; i < objGroups.length; ++i) { + cc.log("obj: " + objGroups[i]); + } + ``` + */ + getObjectGroups(): TiledObjectGroup[]; + /** + !#en Return the TMXObjectGroup for the specific group. + !#zh 获取指定的 TMXObjectGroup。 + @param groupName groupName + + @example + ```js + let group = titledMap.getObjectGroup("Players"); + cc.log("ObjectGroup: " + group); + ``` + */ + getObjectGroup(groupName: string): TiledObjectGroup; + /** + !#en enable or disable culling + !#zh 开启或关闭裁剪。 + @param value value + */ + enableCulling(value: any): void; + /** + !#en Gets the map properties. + !#zh 获取地图的属性。 + + @example + ```js + let properties = titledMap.getProperties(); + for (let i = 0; i < properties.length; ++i) { + cc.log("Properties: " + properties[i]); + } + ``` + */ + getProperties(): any[]; + /** + !#en Return All layers array. + !#zh 返回包含所有 layer 的数组。 + + @example + ```js + let layers = titledMap.getLayers(); + for (let i = 0; i < layers.length; ++i) { + cc.log("Layers: " + layers[i]); + } + ``` + */ + getLayers(): TiledLayer[]; + /** + !#en return the cc.TiledLayer for the specific layer. + !#zh 获取指定名称的 layer。 + @param layerName layerName + + @example + ```js + let layer = titledMap.getLayer("Player"); + cc.log(layer); + ``` + */ + getLayer(layerName: string): TiledLayer; + /** + !#en Return the value for the specific property name. + !#zh 通过属性名称,获取指定的属性。 + @param propertyName propertyName + + @example + ```js + let property = titledMap.getProperty("info"); + cc.log("Property: " + property); + ``` + */ + getProperty(propertyName: string): string; + /** + !#en Return properties dictionary for tile GID. + !#zh 通过 GID ,获取指定的属性。 + @param GID GID + + @example + ```js + let properties = titledMap.getPropertiesForGID(GID); + cc.log("Properties: " + properties); + ``` + */ + getPropertiesForGID(GID: number): any; + } + /** !#en Renders the TMX object group. + !#zh 渲染 tmx object group。 */ + export class TiledObjectGroup extends Component { + /** + !#en Offset position of child objects. + !#zh 获取子对象的偏移位置。 + + @example + ```js + let offset = tMXObjectGroup.getPositionOffset(); + ``` + */ + getPositionOffset(): Vec2; + /** + !#en List of properties stored in a dictionary. + !#zh 以映射的形式获取属性列表。 + + @example + ```js + let offset = tMXObjectGroup.getProperties(); + ``` + */ + getProperties(): any; + /** + !#en Gets the Group name. + !#zh 获取组名称。 + + @example + ```js + let groupName = tMXObjectGroup.getGroupName; + ``` + */ + getGroupName(): string; + /** + !#en + Return the object for the specific object name.
+ It will return the 1st object found on the array for the given name. + !#zh 获取指定的对象。 + @param objectName objectName + + @example + ```js + let object = tMXObjectGroup.getObject("Group"); + ``` + */ + getObject(objectName: string): any; + /** + !#en Gets the objects. + !#zh 获取对象数组。 + + @example + ```js + let objects = tMXObjectGroup.getObjects(); + ``` + */ + getObjects(): any[]; + } + /** Class for tiled map asset handling. */ + export class TiledMapAsset extends Asset { + textures: Texture2D[]; + textureNames: string[]; + textureSizes: Size[]; + imageLayerTextures: Texture2D[]; + imageLayerTextureNames: string[]; + } + /** !#en TiledTile can control the specified map tile. + It will apply the node rotation, scale, translate to the map tile. + You can change the TiledTile's gid to change the map tile's style. + !#zh TiledTile 可以单独对某一个地图块进行操作。 + 他会将节点的旋转,缩放,平移操作应用在这个地图块上,并可以通过更换当前地图块的 gid 来更换地图块的显示样式。 */ + export class TiledTile extends Component { + /** !#en Specify the TiledTile horizontal coordinate,use map tile as the unit. + !#zh 指定 TiledTile 的横向坐标,以地图块为单位 */ + x: number; + /** !#en Specify the TiledTile vertical coordinate,use map tile as the unit. + !#zh 指定 TiledTile 的纵向坐标,以地图块为单位 */ + y: number; + /** !#en Specify the TiledTile gid. + !#zh 指定 TiledTile 的 gid 值 */ + gid: number; + } + /** !#en An object to boot the game. + !#zh 包含游戏主体信息并负责驱动游戏的游戏对象。 */ + export class debug { + /** + !#en Gets error message with the error id and possible parameters. + !#zh 通过 error id 和必要的参数来获取错误信息。 + @param errorId errorId + @param param param + */ + static getError(errorId: string, param?: any): string; + /** + !#en Returns whether or not to display the FPS informations. + !#zh 是否显示 FPS 信息。 + */ + static isDisplayStats(): boolean; + /** + !#en Sets whether display the FPS on the bottom-left corner. + !#zh 设置是否在左下角显示 FPS。 + @param displayStats displayStats + */ + static setDisplayStats(displayStats: boolean): void; + } + /** !#en +

+ ATTENTION: USE cc.director INSTEAD OF cc.Director.
+ cc.director is a singleton object which manage your game's logic flow.
+ Since the cc.director is a singleton, you don't need to call any constructor or create functions,
+ the standard way to use it is by calling:
+ - cc.director.methodName();
+ + It creates and handle the main Window and manages how and when to execute the Scenes.
+
+ The cc.director is also responsible for:
+ - initializing the OpenGL context
+ - setting the OpenGL pixel format (default on is RGB565)
+ - setting the OpenGL buffer depth (default on is 0-bit)
+ - setting the color for clear screen (default one is BLACK)
+ - setting the projection (default one is 3D)
+ - setting the orientation (default one is Portrait)
+
+
+ The cc.director also sets the default OpenGL context:
+ - GL_TEXTURE_2D is enabled
+ - GL_VERTEX_ARRAY is enabled
+ - GL_COLOR_ARRAY is enabled
+ - GL_TEXTURE_COORD_ARRAY is enabled
+

+

+ cc.director also synchronizes timers with the refresh rate of the display.
+ Features and Limitations:
+ - Scheduled timers & drawing are synchronizes with the refresh rate of the display
+ - Only supports animation intervals of 1/60 1/30 & 1/15
+

+ + !#zh +

+ 注意:用 cc.director 代替 cc.Director。
+ cc.director 一个管理你的游戏的逻辑流程的单例对象。
+ 由于 cc.director 是一个单例,你不需要调用任何构造函数或创建函数,
+ 使用它的标准方法是通过调用:
+ - cc.director.methodName(); +
+ 它创建和处理主窗口并且管理什么时候执行场景。
+
+ cc.director 还负责:
+ - 初始化 OpenGL 环境。
+ - 设置OpenGL像素格式。(默认是 RGB565)
+ - 设置OpenGL缓冲区深度 (默认是 0-bit)
+ - 设置空白场景的颜色 (默认是 黑色)
+ - 设置投影 (默认是 3D)
+ - 设置方向 (默认是 Portrait)
+
+ cc.director 设置了 OpenGL 默认环境
+ - GL_TEXTURE_2D 启用。
+ - GL_VERTEX_ARRAY 启用。
+ - GL_COLOR_ARRAY 启用。
+ - GL_TEXTURE_COORD_ARRAY 启用。
+

+

+ cc.director 也同步定时器与显示器的刷新速率。 +
+ 特点和局限性:
+ - 将计时器 & 渲染与显示器的刷新频率同步。
+ - 只支持动画的间隔 1/60 1/30 & 1/15。
+

*/ + export class Director extends EventTarget { + /** + !#en + Converts a view coordinate to an WebGL coordinate
+ Useful to convert (multi) touches coordinates to the current layout (portrait or landscape)
+ Implementation can be found in CCDirectorWebGL. + !#zh 将触摸点的屏幕坐标转换为 WebGL View 下的坐标。 + @param uiPoint uiPoint + */ + convertToGL(uiPoint: Vec2): Vec2; + /** + !#en + Converts an OpenGL coordinate to a view coordinate
+ Useful to convert node points to window points for calls such as glScissor
+ Implementation can be found in CCDirectorWebGL. + !#zh 将触摸点的 WebGL View 坐标转换为屏幕坐标。 + @param glPoint glPoint + */ + convertToUI(glPoint: Vec2): Vec2; + /** + End the life of director in the next frame + */ + end(): void; + /** + !#en + Returns the size of the WebGL view in points.
+ It takes into account any possible rotation (device orientation) of the window. + !#zh 获取视图的大小,以点为单位。 + */ + getWinSize(): Size; + /** + !#en + Returns the size of the OpenGL view in pixels.
+ It takes into account any possible rotation (device orientation) of the window.
+ On Mac winSize and winSizeInPixels return the same value. + (The pixel here refers to the resource resolution. If you want to get the physics resolution of device, you need to use cc.view.getFrameSize()) + !#zh + 获取视图大小,以像素为单位(这里的像素指的是资源分辨率。 + 如果要获取屏幕物理分辨率,需要用 cc.view.getFrameSize()) + */ + getWinSizeInPixels(): Size; + /** + !#en Pause the director's ticker, only involve the game logic execution. + It won't pause the rendering process nor the event manager. + If you want to pause the entier game including rendering, audio and event, + please use {{#crossLink "Game.pause"}}cc.game.pause{{/crossLink}} + !#zh 暂停正在运行的场景,该暂停只会停止游戏逻辑执行,但是不会停止渲染和 UI 响应。 + 如果想要更彻底得暂停游戏,包含渲染,音频和事件,请使用 {{#crossLink "Game.pause"}}cc.game.pause{{/crossLink}}。 + */ + pause(): void; + /** + !#en + Run a scene. Replaces the running scene with a new one or enter the first scene.
+ The new scene will be launched immediately. + !#zh 立刻切换指定场景。 + @param scene The need run scene. + @param onBeforeLoadScene The function invoked at the scene before loading. + @param onLaunched The function invoked at the scene after launch. + */ + runSceneImmediate(scene: Scene, onBeforeLoadScene?: Function, onLaunched?: Function): void; + /** + !#en Loads the scene by its name. + !#zh 通过场景名称进行加载场景。 + @param sceneName The name of the scene to load. + @param onLaunched callback, will be called after scene launched. + */ + loadScene(sceneName: string, onLaunched?: Function): boolean; + /** + !#en + Preloads the scene to reduces loading time. You can call this method at any time you want. + After calling this method, you still need to launch the scene by `cc.director.loadScene`. + It will be totally fine to call `cc.director.loadScene` at any time even if the preloading is not + yet finished, the scene will be launched after loaded automatically. + !#zh 预加载场景,你可以在任何时候调用这个方法。 + 调用完后,你仍然需要通过 `cc.director.loadScene` 来启动场景,因为这个方法不会执行场景加载操作。 + 就算预加载还没完成,你也可以直接调用 `cc.director.loadScene`,加载完成后场景就会启动。 + @param sceneName The name of the scene to preload. + @param onProgress callback, will be called when the load progression change. + @param onLoaded callback, will be called after scene loaded. + */ + preloadScene(sceneName: string, onProgress?: (completedCount: number, totalCount: number, item: any) => void, onLoaded?: (error: Error, asset: SceneAsset) => void): void; + /** + !#en Resume game logic execution after pause, if the current scene is not paused, nothing will happen. + !#zh 恢复暂停场景的游戏逻辑,如果当前场景没有暂停将没任何事情发生。 + */ + resume(): void; + /** + !#en + Enables or disables WebGL depth test.
+ Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js + !#zh 启用/禁用深度测试(在 Canvas 渲染模式下不会生效)。 + @param on on + */ + setDepthTest(on: boolean): void; + /** + !#en + Set color for clear screen.
+ (Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js) + !#zh + 设置场景的默认擦除颜色。
+ 支持全透明,但不支持透明度为中间值。要支持全透明需手工开启 cc.macro.ENABLE_TRANSPARENT_CANVAS。 + @param clearColor clearColor + */ + setClearColor(clearColor: Color): void; + /** + !#en Returns current logic Scene. + !#zh 获取当前逻辑场景。 + + @example + ```js + // This will help you to get the Canvas node in scene + cc.director.getScene().getChildByName('Canvas'); + ``` + */ + getScene(): Scene; + /** + !#en Returns the FPS value. Please use {{#crossLink "Game.setFrameRate"}}cc.game.setFrameRate{{/crossLink}} to control animation interval. + !#zh 获取单位帧执行时间。请使用 {{#crossLink "Game.setFrameRate"}}cc.game.setFrameRate{{/crossLink}} 来控制游戏帧率。 + */ + getAnimationInterval(): number; + /** + Sets animation interval, this doesn't control the main loop. + To control the game's frame rate overall, please use {{#crossLink "Game.setFrameRate"}}cc.game.setFrameRate{{/crossLink}} + @param value The animation interval desired. + */ + setAnimationInterval(value: number): void; + /** + !#en Returns the delta time since last frame. + !#zh 获取上一帧的增量时间。 + */ + getDeltaTime(): number; + /** + !#en Returns the total passed time since game start, unit: ms + !#zh 获取从游戏开始到现在总共经过的时间,单位为 ms + */ + getTotalTime(): number; + /** + !#en Returns how many frames were called since the director started. + !#zh 获取 director 启动以来游戏运行的总帧数。 + */ + getTotalFrames(): number; + /** + !#en Returns whether or not the Director is paused. + !#zh 是否处于暂停状态。 + */ + isPaused(): boolean; + /** + !#en Returns the cc.Scheduler associated with this director. + !#zh 获取和 director 相关联的 cc.Scheduler。 + */ + getScheduler(): Scheduler; + /** + !#en Sets the cc.Scheduler associated with this director. + !#zh 设置和 director 相关联的 cc.Scheduler。 + @param scheduler scheduler + */ + setScheduler(scheduler: Scheduler): void; + /** + !#en Returns the cc.ActionManager associated with this director. + !#zh 获取和 director 相关联的 cc.ActionManager(动作管理器)。 + */ + getActionManager(): ActionManager; + /** + !#en Sets the cc.ActionManager associated with this director. + !#zh 设置和 director 相关联的 cc.ActionManager(动作管理器)。 + @param actionManager actionManager + */ + setActionManager(actionManager: ActionManager): void; + /** + !#en Returns the cc.CollisionManager associated with this director. + !#zh 获取和 director 相关联的 cc.CollisionManager (碰撞管理器)。 + */ + getCollisionManager(): CollisionManager; + /** + !#en Returns the cc.PhysicsManager associated with this director. + !#zh 返回与 director 相关联的 cc.PhysicsManager (物理管理器)。 + */ + getPhysicsManager(): PhysicsManager; + /** + !#en Returns the cc.Physics3DManager associated with this director. + !#zh 返回与 director 相关联的 cc.Physics3DManager (物理管理器)。 + */ + getPhysics3DManager(): Physics3DManager; + /** !#en The event projection changed of cc.Director. This event will not get triggered since v2.0 + !#zh cc.Director 投影变化的事件。从 v2.0 开始这个事件不会再被触发 */ + static EVENT_PROJECTION_CHANGED: string; + /** !#en The event which will be triggered before loading a new scene. + !#zh 加载新场景之前所触发的事件。 */ + static EVENT_BEFORE_SCENE_LOADING: string; + /** !#en The event which will be triggered before launching a new scene. + !#zh 运行新场景之前所触发的事件。 */ + static EVENT_BEFORE_SCENE_LAUNCH: string; + /** !#en The event which will be triggered after launching a new scene. + !#zh 运行新场景之后所触发的事件。 */ + static EVENT_AFTER_SCENE_LAUNCH: string; + /** !#en The event which will be triggered at the beginning of every frame. + !#zh 每个帧的开始时所触发的事件。 */ + static EVENT_BEFORE_UPDATE: string; + /** !#en The event which will be triggered after engine and components update logic. + !#zh 将在引擎和组件 “update” 逻辑之后所触发的事件。 */ + static EVENT_AFTER_UPDATE: string; + /** !#en The event is deprecated since v2.0, please use cc.Director.EVENT_BEFORE_DRAW instead + !#zh 这个事件从 v2.0 开始被废弃,请直接使用 cc.Director.EVENT_BEFORE_DRAW */ + static EVENT_BEFORE_VISIT: string; + /** !#en The event is deprecated since v2.0, please use cc.Director.EVENT_BEFORE_DRAW instead + !#zh 这个事件从 v2.0 开始被废弃,请直接使用 cc.Director.EVENT_BEFORE_DRAW */ + static EVENT_AFTER_VISIT: string; + /** !#en The event which will be triggered before the rendering process. + !#zh 渲染过程之前所触发的事件。 */ + static EVENT_BEFORE_DRAW: string; + /** !#en The event which will be triggered after the rendering process. + !#zh 渲染过程之后所触发的事件。 */ + static EVENT_AFTER_DRAW: string; + /** Constant for 2D projection (orthogonal projection) */ + static PROJECTION_2D: number; + /** Constant for 3D projection with a fovy=60, znear=0.5f and zfar=1500. */ + static PROJECTION_3D: number; + /** Constant for custom projection, if cc.Director's projection set to it, it calls "updateProjection" on the projection delegate. */ + static PROJECTION_CUSTOM: number; + /** Constant for default projection of cc.Director, default projection is 2D projection */ + static PROJECTION_DEFAULT: number; + } + /** !#en An object to boot the game. + !#zh 包含游戏主体信息并负责驱动游戏的游戏对象。 */ + export class Game extends EventTarget { + /** !#en Event triggered when game hide to background. + Please note that this event is not 100% guaranteed to be fired on Web platform, + on native platforms, it corresponds to enter background event, os status bar or notification center may not trigger this event. + !#zh 游戏进入后台时触发的事件。 + 请注意,在 WEB 平台,这个事件不一定会 100% 触发,这完全取决于浏览器的回调行为。 + 在原生平台,它对应的是应用被切换到后台事件,下拉菜单和上拉状态栏等不一定会触发这个事件,这取决于系统行为。 */ + EVENT_HIDE: string; + /** !#en Event triggered when game back to foreground + Please note that this event is not 100% guaranteed to be fired on Web platform, + on native platforms, it corresponds to enter foreground event. + !#zh 游戏进入前台运行时触发的事件。 + 请注意,在 WEB 平台,这个事件不一定会 100% 触发,这完全取决于浏览器的回调行为。 + 在原生平台,它对应的是应用被切换到前台事件。 */ + EVENT_SHOW: string; + /** !#en Event triggered when game restart + !#zh 调用restart后,触发事件。 */ + EVENT_RESTART: string; + /** Event triggered after game inited, at this point all engine objects and game scripts are loaded */ + EVENT_GAME_INITED: string; + /** Event triggered after engine inited, at this point you will be able to use all engine classes. + It was defined as EVENT_RENDERER_INITED in cocos creator v1.x and renamed in v2.0 */ + EVENT_ENGINE_INITED: string; + /** Web Canvas 2d API as renderer backend */ + RENDER_TYPE_CANVAS: number; + /** WebGL API as renderer backend */ + RENDER_TYPE_WEBGL: number; + /** OpenGL API as renderer backend */ + RENDER_TYPE_OPENGL: number; + /** !#en The outer frame of the game canvas, parent of game container. + !#zh 游戏画布的外框,container 的父容器。 */ + frame: any; + /** !#en The container of game canvas. + !#zh 游戏画布的容器。 */ + container: HTMLDivElement; + /** !#en The canvas of the game. + !#zh 游戏的画布。 */ + canvas: HTMLCanvasElement; + /** !#en The renderer backend of the game. + !#zh 游戏的渲染器类型。 */ + renderType: number; + /** !#en + The current game configuration, including:
+ 1. debugMode
+ "debugMode" possible values :
+ 0 - No message will be printed.
+ 1 - cc.error, cc.assert, cc.warn, cc.log will print in console.
+ 2 - cc.error, cc.assert, cc.warn will print in console.
+ 3 - cc.error, cc.assert will print in console.
+ 4 - cc.error, cc.assert, cc.warn, cc.log will print on canvas, available only on web.
+ 5 - cc.error, cc.assert, cc.warn will print on canvas, available only on web.
+ 6 - cc.error, cc.assert will print on canvas, available only on web.
+ 2. showFPS
+ Left bottom corner fps information will show when "showFPS" equals true, otherwise it will be hide.
+ 3. exposeClassName
+ Expose class name to chrome debug tools, the class intantiate performance is a little bit slower when exposed.
+ 4. frameRate
+ "frameRate" set the wanted frame rate for your game, but the real fps depends on your game implementation and the running environment.
+ 5. id
+ "gameCanvas" sets the id of your canvas element on the web page, it's useful only on web.
+ 6. renderMode
+ "renderMode" sets the renderer type, only useful on web :
+ 0 - Automatically chosen by engine
+ 1 - Forced to use canvas renderer
+ 2 - Forced to use WebGL renderer, but this will be ignored on mobile browsers
+ 7. scenes
+ "scenes" include available scenes in the current bundle.
+
+ Please DO NOT modify this object directly, it won't have any effect.
+ !#zh + 当前的游戏配置,包括:
+ 1. debugMode(debug 模式,但是在浏览器中这个选项会被忽略)
+ "debugMode" 各种设置选项的意义。
+ 0 - 没有消息被打印出来。
+ 1 - cc.error,cc.assert,cc.warn,cc.log 将打印在 console 中。
+ 2 - cc.error,cc.assert,cc.warn 将打印在 console 中。
+ 3 - cc.error,cc.assert 将打印在 console 中。
+ 4 - cc.error,cc.assert,cc.warn,cc.log 将打印在 canvas 中(仅适用于 web 端)。
+ 5 - cc.error,cc.assert,cc.warn 将打印在 canvas 中(仅适用于 web 端)。
+ 6 - cc.error,cc.assert 将打印在 canvas 中(仅适用于 web 端)。
+ 2. showFPS(显示 FPS)
+ 当 showFPS 为 true 的时候界面的左下角将显示 fps 的信息,否则被隐藏。
+ 3. exposeClassName
+ 暴露类名让 Chrome DevTools 可以识别,如果开启会稍稍降低类的创建过程的性能,但对对象构造没有影响。
+ 4. frameRate (帧率)
+ “frameRate” 设置想要的帧率你的游戏,但真正的FPS取决于你的游戏实现和运行环境。
+ 5. id
+ "gameCanvas" Web 页面上的 Canvas Element ID,仅适用于 web 端。
+ 6. renderMode(渲染模式)
+ “renderMode” 设置渲染器类型,仅适用于 web 端:
+ 0 - 通过引擎自动选择。
+ 1 - 强制使用 canvas 渲染。 + 2 - 强制使用 WebGL 渲染,但是在部分 Android 浏览器中这个选项会被忽略。
+ 7. scenes
+ “scenes” 当前包中可用场景。
+
+ 注意:请不要直接修改这个对象,它不会有任何效果。 */ + config: any; + /** + !#en Callback when the scripts of engine have been load. + !#zh 当引擎完成启动后的回调函数。 + */ + onStart(): void; + /** + !#en Set frame rate of game. + !#zh 设置游戏帧率。 + @param frameRate frameRate + */ + setFrameRate(frameRate: number): void; + /** + !#en Get frame rate set for the game, it doesn't represent the real frame rate. + !#zh 获取设置的游戏帧率(不等同于实际帧率)。 + */ + getFrameRate(): number; + /** + !#en Run the game frame by frame. + !#zh 执行一帧游戏循环。 + */ + step(): void; + /** + !#en Pause the game main loop. This will pause: + game logic execution, rendering process, event manager, background music and all audio effects. + This is different with cc.director.pause which only pause the game logic execution. + !#zh 暂停游戏主循环。包含:游戏逻辑,渲染,事件处理,背景音乐和所有音效。这点和只暂停游戏逻辑的 cc.director.pause 不同。 + */ + pause(): void; + /** + !#en Resume the game from pause. This will resume: + game logic execution, rendering process, event manager, background music and all audio effects. + !#zh 恢复游戏主循环。包含:游戏逻辑,渲染,事件处理,背景音乐和所有音效。 + */ + resume(): void; + /** + !#en Check whether the game is paused. + !#zh 判断游戏是否暂停。 + */ + isPaused(): boolean; + /** + !#en Restart game. + !#zh 重新开始游戏 + */ + restart(): void; + /** + !#en End game, it will close the game window + !#zh 退出游戏 + */ + end(): void; + /** + !#en + Register an callback of a specific event type on the game object. + This type of event should be triggered via `emit`. + !#zh + 注册 game 的特定事件类型回调。这种类型的事件应该被 `emit` 触发。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + */ + on(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Register an callback of a specific event type on the game object, + the callback will remove itself after the first time it is triggered. + !#zh + 注册 game 的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + */ + once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; + /** + !#en Prepare game. + !#zh 准备引擎,请不要直接调用这个函数。 + @param cb cb + */ + prepare(cb: Function): void; + /** + !#en Run game with configuration object and onStart function. + !#zh 运行游戏,并且指定引擎配置和 onStart 的回调。 + @param config Pass configuration object or onStart function + @param onStart function to be executed after game initialized + */ + run(config: any, onStart: Function): void; + /** + !#en + Add a persistent root node to the game, the persistent node won't be destroyed during scene transition.
+ The target node must be placed in the root level of hierarchy, otherwise this API won't have any effect. + !#zh + 声明常驻根节点,该节点不会被在场景切换中被销毁。
+ 目标节点必须位于为层级的根节点,否则无效。 + @param node The node to be made persistent + */ + addPersistRootNode(node: Node): void; + /** + !#en Remove a persistent root node. + !#zh 取消常驻根节点。 + @param node The node to be removed from persistent node list + */ + removePersistRootNode(node: Node): void; + /** + !#en Check whether the node is a persistent root node. + !#zh 检查节点是否是常驻根节点。 + @param node The node to be checked + */ + isPersistRootNode(node: Node): boolean; + } + /** !#en + Class of all entities in Cocos Creator scenes.
+ For events supported by Node, please refer to {{#crossLink "Node.EventType"}}{{/crossLink}} + !#zh + Cocos Creator 场景中的所有节点类。
+ 支持的节点事件,请参阅 {{#crossLink "Node.EventType"}}{{/crossLink}}。 */ + export class Node extends _BaseNode { + /** !#en + Group index of node.
+ Which Group this node belongs to will resolve that this node's collision components can collide with which other collision componentns.
+ !#zh + 节点的分组索引。
+ 节点的分组将关系到节点的碰撞组件可以与哪些碰撞组件相碰撞。
*/ + groupIndex: number; + /** !#en + Group of node.
+ Which Group this node belongs to will resolve that this node's collision components can collide with which other collision componentns.
+ !#zh + 节点的分组。
+ 节点的分组将关系到节点的碰撞组件可以与哪些碰撞组件相碰撞。
*/ + group: string; + /** !#en The position (x, y) of the node in its parent's coordinates. + !#zh 节点在父节点坐标系中的位置(x, y)。 */ + position: Vec3; + /** !#en x axis position of node. + !#zh 节点 X 轴坐标。 */ + x: number; + /** !#en y axis position of node. + !#zh 节点 Y 轴坐标。 */ + y: number; + /** !#en z axis position of node. + !#zh 节点 Z 轴坐标。 */ + z: number; + /** !#en Rotation of node. + !#zh 该节点旋转角度。 */ + rotation: number; + /** !#en + Angle of node, the positive value is anti-clockwise direction. + !#zh + 该节点的旋转角度,正值为逆时针方向。 */ + angle: number; + /** !#en The rotation as Euler angles in degrees, used in 3D node. + !#zh 该节点的欧拉角度,用于 3D 节点。 */ + eulerAngles: Vec3; + /** !#en Rotation on x axis. + !#zh 该节点 X 轴旋转角度。 */ + rotationX: number; + /** !#en Rotation on y axis. + !#zh 该节点 Y 轴旋转角度。 */ + rotationY: number; + /** !#en The local scale relative to the parent. + !#zh 节点相对父节点的缩放。 */ + scale: number; + /** !#en Scale on x axis. + !#zh 节点 X 轴缩放。 */ + scaleX: number; + /** !#en Scale on y axis. + !#zh 节点 Y 轴缩放。 */ + scaleY: number; + /** !#en Scale on z axis. + !#zh 节点 Z 轴缩放。 */ + scaleZ: number; + /** !#en Skew x + !#zh 该节点 X 轴倾斜角度。 */ + skewX: number; + /** !#en Skew y + !#zh 该节点 Y 轴倾斜角度。 */ + skewY: number; + /** !#en Opacity of node, default value is 255. + !#zh 节点透明度,默认值为 255。 */ + opacity: number; + /** !#en Color of node, default value is white: (255, 255, 255). + !#zh 节点颜色。默认为白色,数值为:(255,255,255)。 */ + color: Color; + /** !#en Anchor point's position on x axis. + !#zh 节点 X 轴锚点位置。 */ + anchorX: number; + /** !#en Anchor point's position on y axis. + !#zh 节点 Y 轴锚点位置。 */ + anchorY: number; + /** !#en Width of node. + !#zh 节点宽度。 */ + width: number; + /** !#en Height of node. + !#zh 节点高度。 */ + height: number; + /** !#en zIndex is the 'key' used to sort the node relative to its siblings.
+ The value of zIndex should be in the range between cc.macro.MIN_ZINDEX and cc.macro.MAX_ZINDEX.
+ The Node's parent will sort all its children based on the zIndex value and the arrival order.
+ Nodes with greater zIndex will be sorted after nodes with smaller zIndex.
+ If two nodes have the same zIndex, then the node that was added first to the children's array will be in front of the other node in the array.
+ Node's order in children list will affect its rendering order. Parent is always rendering before all children. + !#zh zIndex 是用来对节点进行排序的关键属性,它决定一个节点在兄弟节点之间的位置。
+ zIndex 的取值应该介于 cc.macro.MIN_ZINDEX 和 cc.macro.MAX_ZINDEX 之间 + 父节点主要根据节点的 zIndex 和添加次序来排序,拥有更高 zIndex 的节点将被排在后面,如果两个节点的 zIndex 一致,先添加的节点会稳定排在另一个节点之前。
+ 节点在 children 中的顺序决定了其渲染顺序。父节点永远在所有子节点之前被渲染 */ + zIndex: number; + /** !#en + Switch 2D/3D node. The 2D nodes will run faster. + !#zh + 切换 2D/3D 节点,2D 节点会有更高的运行效率 */ + is3DNode: boolean; + /** !#en Returns a normalized vector representing the up direction (Y axis) of the node in world space. + !#zh 获取节点正上方(y 轴)面对的方向,返回值为世界坐标系下的归一化向量 */ + up: Vec3; + /** !#en Returns a normalized vector representing the right direction (X axis) of the node in world space. + !#zh 获取节点正右方(x 轴)面对的方向,返回值为世界坐标系下的归一化向量 */ + right: Vec3; + /** !#en Returns a normalized vector representing the forward direction (Z axis) of the node in world space. + !#zh 获取节点正前方(z 轴)面对的方向,返回值为世界坐标系下的归一化向量 */ + forward: Vec3; + /** + + @param name name + */ + constructor(name?: string); + /** + !#en + Register a callback of a specific event type on Node.
+ Use this method to register touch or mouse event permit propagation based on scene graph,
+ These kinds of event are triggered with dispatchEvent, the dispatch process has three steps:
+ 1. Capturing phase: dispatch in capture targets (`_getCapturingTargets`), e.g. parents in node tree, from root to the real target
+ 2. At target phase: dispatch to the listeners of the real target
+ 3. Bubbling phase: dispatch in bubble targets (`_getBubblingTargets`), e.g. parents in node tree, from the real target to root
+ In any moment of the dispatching process, it can be stopped via `event.stopPropagation()` or `event.stopPropagationImmidiate()`.
+ It's the recommended way to register touch/mouse event for Node,
+ please do not use cc.eventManager directly for Node.
+ You can also register custom event and use `emit` to trigger custom event on Node.
+ For such events, there won't be capturing and bubbling phase, your event will be dispatched directly to its listeners registered on the same node.
+ You can also pass event callback parameters with `emit` by passing parameters after `type`. + !#zh + 在节点上注册指定类型的回调函数,也可以设置 target 用于绑定响应函数的 this 对象。
+ 鼠标或触摸事件会被系统调用 dispatchEvent 方法触发,触发的过程包含三个阶段:
+ 1. 捕获阶段:派发事件给捕获目标(通过 `_getCapturingTargets` 获取),比如,节点树中注册了捕获阶段的父节点,从根节点开始派发直到目标节点。
+ 2. 目标阶段:派发给目标节点的监听器。
+ 3. 冒泡阶段:派发事件给冒泡目标(通过 `_getBubblingTargets` 获取),比如,节点树中注册了冒泡阶段的父节点,从目标节点开始派发直到根节点。
+ 同时您可以将事件派发到父节点或者通过调用 stopPropagation 拦截它。
+ 推荐使用这种方式来监听节点上的触摸或鼠标事件,请不要在节点上直接使用 cc.eventManager。
+ 你也可以注册自定义事件到节点上,并通过 emit 方法触发此类事件,对于这类事件,不会发生捕获冒泡阶段,只会直接派发给注册在该节点上的监听器
+ 你可以通过在 emit 方法调用时在 type 之后传递额外的参数作为事件回调的参数列表 + @param type A string representing the event type to listen for.
See {{#crossLink "Node/EventTyupe/POSITION_CHANGED"}}Node Events{{/crossLink}} for all builtin events. + @param callback The callback that will be invoked when the event is dispatched. The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + @param useCapture When set to true, the listener will be triggered at capturing phase which is ahead of the final target emit, otherwise it will be triggered during bubbling phase. + + @example + ```js + this.node.on(cc.Node.EventType.TOUCH_START, this.memberFunction, this); // if "this" is component and the "memberFunction" declared in CCClass. + node.on(cc.Node.EventType.TOUCH_START, callback, this); + node.on(cc.Node.EventType.TOUCH_MOVE, callback, this); + node.on(cc.Node.EventType.TOUCH_END, callback, this); + node.on(cc.Node.EventType.TOUCH_CANCEL, callback, this); + node.on(cc.Node.EventType.ANCHOR_CHANGED, callback); + node.on(cc.Node.EventType.COLOR_CHANGED, callback); + ``` + */ + on(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Register an callback of a specific event type on the Node, + the callback will remove itself after the first time it is triggered. + !#zh + 注册节点的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + node.once(cc.Node.EventType.ANCHOR_CHANGED, callback); + ``` + */ + once(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Removes the callback previously registered with the same type, callback, target and or useCapture. + This method is merely an alias to removeEventListener. + !#zh 删除之前与同类型,回调,目标或 useCapture 注册的回调。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + @param useCapture When set to true, the listener will be triggered at capturing phase which is ahead of the final target emit, otherwise it will be triggered during bubbling phase. + + @example + ```js + this.node.off(cc.Node.EventType.TOUCH_START, this.memberFunction, this); + node.off(cc.Node.EventType.TOUCH_START, callback, this.node); + node.off(cc.Node.EventType.ANCHOR_CHANGED, callback, this); + ``` + */ + off(type: string, callback?: Function, target?: any, useCapture?: boolean): void; + /** + !#en Removes all callbacks previously registered with the same target. + !#zh 移除目标上的所有注册事件。 + @param target The target to be searched for all related callbacks + + @example + ```js + node.targetOff(target); + ``` + */ + targetOff(target: any): void; + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en + Trigger an event directly with the event name and necessary arguments. + !#zh + 通过事件名发送自定义事件 + @param type event type + @param arg1 First argument in callback + @param arg2 Second argument in callback + @param arg3 Third argument in callback + @param arg4 Fourth argument in callback + @param arg5 Fifth argument in callback + + @example + ```js + eventTarget.emit('fire', event); + eventTarget.emit('fire', message, emitter); + ``` + */ + emit(type: string, arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any): void; + /** + !#en + Dispatches an event into the event flow. + The event target is the EventTarget object upon which the dispatchEvent() method is called. + !#zh 分发事件到事件流中。 + @param event The Event object that is dispatched into the event flow + */ + dispatchEvent(event: Event): void; + /** + !#en Pause node related system events registered with the current Node. Node system events includes touch and mouse events. + If recursive is set to true, then this API will pause the node system events for the node and all nodes in its sub node tree. + Reference: http://docs.cocos2d-x.org/editors_and_tools/creator-chapters/scripting/internal-events/ + !#zh 暂停当前节点上注册的所有节点系统事件,节点系统事件包含触摸和鼠标事件。 + 如果传递 recursive 为 true,那么这个 API 将暂停本节点和它的子树上所有节点的节点系统事件。 + 参考:https://www.cocos.com/docs/creator/scripting/internal-events.html + @param recursive Whether to pause node system events on the sub node tree. + + @example + ```js + node.pauseSystemEvents(true); + ``` + */ + pauseSystemEvents(recursive: boolean): void; + /** + !#en Resume node related system events registered with the current Node. Node system events includes touch and mouse events. + If recursive is set to true, then this API will resume the node system events for the node and all nodes in its sub node tree. + Reference: http://docs.cocos2d-x.org/editors_and_tools/creator-chapters/scripting/internal-events/ + !#zh 恢复当前节点上注册的所有节点系统事件,节点系统事件包含触摸和鼠标事件。 + 如果传递 recursive 为 true,那么这个 API 将恢复本节点和它的子树上所有节点的节点系统事件。 + 参考:https://www.cocos.com/docs/creator/scripting/internal-events.html + @param recursive Whether to resume node system events on the sub node tree. + + @example + ```js + node.resumeSystemEvents(true); + ``` + */ + resumeSystemEvents(recursive: boolean): void; + /** + !#en + Executes an action, and returns the action that is executed.
+ The node becomes the action's target. Refer to cc.Action's getTarget()
+ Calling runAction while the node is not active won't have any effect.
+ Note:You shouldn't modify the action after runAction, that won't take any effect.
+ if you want to modify, when you define action plus. + !#zh + 执行并返回该执行的动作。该节点将会变成动作的目标。
+ 调用 runAction 时,节点自身处于不激活状态将不会有任何效果。
+ 注意:你不应该修改 runAction 后的动作,将无法发挥作用,如果想进行修改,请在定义 action 时加入。 + @param action action + + @example + ```js + var action = cc.scaleTo(0.2, 1, 0.6); + node.runAction(action); + node.runAction(action).repeatForever(); // fail + node.runAction(action.repeatForever()); // right + ``` + */ + runAction(action: Action): Action; + /** + !#en Pause all actions running on the current node. Equals to `cc.director.getActionManager().pauseTarget(node)`. + !#zh 暂停本节点上所有正在运行的动作。和 `cc.director.getActionManager().pauseTarget(node);` 等价。 + + @example + ```js + node.pauseAllActions(); + ``` + */ + pauseAllActions(): void; + /** + !#en Resume all paused actions on the current node. Equals to `cc.director.getActionManager().resumeTarget(node)`. + !#zh 恢复运行本节点上所有暂停的动作。和 `cc.director.getActionManager().resumeTarget(node);` 等价。 + + @example + ```js + node.resumeAllActions(); + ``` + */ + resumeAllActions(): void; + /** + !#en Stops and removes all actions from the running action list . + !#zh 停止并且移除所有正在运行的动作列表。 + + @example + ```js + node.stopAllActions(); + ``` + */ + stopAllActions(): void; + /** + !#en Stops and removes an action from the running action list. + !#zh 停止并移除指定的动作。 + @param action An action object to be removed. + + @example + ```js + var action = cc.scaleTo(0.2, 1, 0.6); + node.stopAction(action); + ``` + */ + stopAction(action: Action): void; + /** + !#en Removes an action from the running action list by its tag. + !#zh 停止并且移除指定标签的动作。 + @param tag A tag that indicates the action to be removed. + + @example + ```js + node.stopActionByTag(1); + ``` + */ + stopActionByTag(tag: number): void; + /** + !#en Returns an action from the running action list by its tag. + !#zh 通过标签获取指定动作。 + @param tag tag + + @example + ```js + var action = node.getActionByTag(1); + ``` + */ + getActionByTag(tag: number): Action; + /** + !#en + Returns the numbers of actions that are running plus the ones that are schedule to run (actions in actionsToAdd and actions arrays).
+ Composable actions are counted as 1 action. Example:
+ If you are running 1 Sequence of 7 actions, it will return 1.
+ If you are running 7 Sequences of 2 actions, it will return 7.

+ !#zh + 获取运行着的动作加上正在调度运行的动作的总数。
+ 例如:
+ - 如果你正在运行 7 个动作中的 1 个 Sequence,它将返回 1。
+ - 如果你正在运行 2 个动作中的 7 个 Sequence,它将返回 7。
+ + @example + ```js + var count = node.getNumberOfRunningActions(); + cc.log("Running Action Count: " + count); + ``` + */ + getNumberOfRunningActions(): number; + /** + !#en + Returns a copy of the position (x, y, z) of the node in its parent's coordinates. + You can pass a cc.Vec2 or cc.Vec3 as the argument to receive the return values. + !#zh + 获取节点在父节点坐标系中的位置(x, y, z)。 + 你可以传一个 cc.Vec2 或者 cc.Vec3 作为参数来接收返回值。 + @param out The return value to receive position + + @example + ```js + cc.log("Node Position: " + node.getPosition()); + ``` + */ + getPosition(out?: Vec2|Vec3): Vec2; + /** + !#en + Sets the position (x, y, z) of the node in its parent's coordinates.
+ Usually we use cc.v2(x, y) to compose cc.Vec2 object,
+ and passing two numbers (x, y) is more efficient than passing cc.Vec2 object. + For 3D node we can use cc.v3(x, y, z) to compose cc.Vec3 object,
+ and passing three numbers (x, y, z) is more efficient than passing cc.Vec3 object. + !#zh + 设置节点在父节点坐标系中的位置。
+ 可以通过下面的方式设置坐标点:
+ 1. 传入 2 个数值 x, y。
+ 2. 传入 cc.v2(x, y) 类型为 cc.Vec2 的对象。 + 3. 对于 3D 节点可以传入 3 个数值 x, y, z。
+ 4. 对于 3D 节点可以传入 cc.v3(x, y, z) 类型为 cc.Vec3 的对象。 + @param newPosOrX X coordinate for position or the position (x, y, z) of the node in coordinates + @param y Y coordinate for position + @param z Z coordinate for position + */ + setPosition(newPosOrX: Vec2|Vec3|number, y?: number, z?: number): void; + /** + !#en + Returns the scale factor of the node. + Need pass a cc.Vec2 or cc.Vec3 as the argument to receive the return values. + !#zh 获取节点的缩放,需要传一个 cc.Vec2 或者 cc.Vec3 作为参数来接收返回值。 + @param out out + + @example + ```js + cc.log("Node Scale: " + node.getScale(cc.v3())); + ``` + */ + getScale(out: Vec2|Vec3): Vec2; + /** + !#en + Sets the scale of axis in local coordinates of the node. + You can operate 2 axis in 2D node, and 3 axis in 3D node. + !#zh + 设置节点在本地坐标系中坐标轴上的缩放比例。 + 2D 节点可以操作两个坐标轴,而 3D 节点可以操作三个坐标轴。 + @param x scaleX or scale object + @param y y + @param z z + + @example + ```js + node.setScale(cc.v2(2, 2)); + node.setScale(cc.v3(2, 2, 2)); // for 3D node + node.setScale(2); + ``` + */ + setScale(x: number|Vec2|Vec3, y?: number, z?: number): void; + /** + !#en + Get rotation of node (in quaternion). + Need pass a cc.Quat as the argument to receive the return values. + !#zh + 获取该节点的 quaternion 旋转角度,需要传一个 cc.Quat 作为参数来接收返回值。 + @param out out + */ + getRotation(out: Quat): Quat; + /** + !#en Set rotation of node (in quaternion). + !#zh 设置该节点的 quaternion 旋转角度。 + @param quat Quaternion object represents the rotation or the x value of quaternion + @param y y value of quternion + @param z z value of quternion + @param w w value of quternion + */ + setRotation(quat: Quat|number, y?: number, z?: number, w?: number): void; + /** + !#en + Returns a copy the untransformed size of the node.
+ The contentSize remains the same no matter the node is scaled or rotated.
+ All nodes has a size. Layer and Scene has the same size of the screen by default.
+ !#zh 获取节点自身大小,不受该节点是否被缩放或者旋转的影响。 + + @example + ```js + cc.log("Content Size: " + node.getContentSize()); + ``` + */ + getContentSize(): Size; + /** + !#en + Sets the untransformed size of the node.
+ The contentSize remains the same no matter the node is scaled or rotated.
+ All nodes has a size. Layer and Scene has the same size of the screen. + !#zh 设置节点原始大小,不受该节点是否被缩放或者旋转的影响。 + @param size The untransformed size of the node or The untransformed size's width of the node. + @param height The untransformed size's height of the node. + + @example + ```js + node.setContentSize(cc.size(100, 100)); + node.setContentSize(100, 100); + ``` + */ + setContentSize(size: Size|number, height?: number): void; + /** + !#en + Returns a copy of the anchor point.
+ Anchor point is the point around which all transformations and positioning manipulations take place.
+ It's like a pin in the node where it is "attached" to its parent.
+ The anchorPoint is normalized, like a percentage. (0,0) means the bottom-left corner and (1,1) means the top-right corner.
+ But you can use values higher than (1,1) and lower than (0,0) too.
+ The default anchor point is (0.5,0.5), so it starts at the center of the node. + !#zh + 获取节点锚点,用百分比表示。
+ 锚点应用于所有变换和坐标点的操作,它就像在节点上连接其父节点的大头针。
+ 锚点是标准化的,就像百分比一样。(0,0) 表示左下角,(1,1) 表示右上角。
+ 但是你可以使用比(1,1)更高的值或者比(0,0)更低的值。
+ 默认的锚点是(0.5,0.5),因此它开始于节点的中心位置。
+ 注意:Creator 中的锚点仅用于定位所在的节点,子节点的定位不受影响。 + + @example + ```js + cc.log("Node AnchorPoint: " + node.getAnchorPoint()); + ``` + */ + getAnchorPoint(): Vec2; + /** + !#en + Sets the anchor point in percent.
+ anchor point is the point around which all transformations and positioning manipulations take place.
+ It's like a pin in the node where it is "attached" to its parent.
+ The anchorPoint is normalized, like a percentage. (0,0) means the bottom-left corner and (1,1) means the top-right corner.
+ But you can use values higher than (1,1) and lower than (0,0) too.
+ The default anchor point is (0.5,0.5), so it starts at the center of the node. + !#zh + 设置锚点的百分比。
+ 锚点应用于所有变换和坐标点的操作,它就像在节点上连接其父节点的大头针。
+ 锚点是标准化的,就像百分比一样。(0,0) 表示左下角,(1,1) 表示右上角。
+ 但是你可以使用比(1,1)更高的值或者比(0,0)更低的值。
+ 默认的锚点是(0.5,0.5),因此它开始于节点的中心位置。
+ 注意:Creator 中的锚点仅用于定位所在的节点,子节点的定位不受影响。 + @param point The anchor point of node or The x axis anchor of node. + @param y The y axis anchor of node. + + @example + ```js + node.setAnchorPoint(cc.v2(1, 1)); + node.setAnchorPoint(1, 1); + ``` + */ + setAnchorPoint(point: Vec2|number, y?: number): void; + /** + !#en Set rotation by lookAt target point, normally used by Camera Node + !#zh 通过观察目标来设置 rotation,一般用于 Camera Node 上 + @param pos pos + @param up default is (0,1,0) + */ + lookAt(pos: Vec3, up?: Vec3): void; + /** + !#en + Get the local transform matrix (4x4), based on parent node coordinates + !#zh 返回局部空间坐标系的矩阵,基于父节点坐标系。 + @param out The matrix object to be filled with data + + @example + ```js + let mat4 = cc.mat4(); + node.getLocalMatrix(mat4); + ``` + */ + getLocalMatrix(out: Mat4): Mat4; + /** + !#en + Get the world transform matrix (4x4) + !#zh 返回世界空间坐标系的矩阵。 + @param out The matrix object to be filled with data + + @example + ```js + let mat4 = cc.mat4(); + node.getWorldMatrix(mat4); + ``` + */ + getWorldMatrix(out: Mat4): Mat4; + /** + !#en + Converts a Point to node (local) space coordinates. + !#zh + 将一个点转换到节点 (局部) 空间坐标系。 + @param worldPoint worldPoint + @param out out + + @example + ```js + var newVec2 = node.convertToNodeSpaceAR(cc.v2(100, 100)); + var newVec3 = node.convertToNodeSpaceAR(cc.v3(100, 100, 100)); + ``` + */ + convertToNodeSpaceAR(worldPoint: T, out?: T): T; + /** + !#en + Converts a Point in node coordinates to world space coordinates. + !#zh + 将节点坐标系下的一个点转换到世界空间坐标系。 + @param nodePoint nodePoint + @param out out + + @example + ```js + var newVec2 = node.convertToWorldSpaceAR(cc.v2(100, 100)); + var newVec3 = node.convertToWorldSpaceAR(cc.v3(100, 100, 100)); + ``` + */ + convertToWorldSpaceAR(nodePoint: T, out?: T): T; + /** + !#en Converts a Point to node (local) space coordinates then add the anchor point position. + So the return position will be related to the left bottom corner of the node's bounding box. + This equals to the API behavior of cocos2d-x, you probably want to use convertToNodeSpaceAR instead + !#zh 将一个点转换到节点 (局部) 坐标系,并加上锚点的坐标。
+ 也就是说返回的坐标是相对于节点包围盒左下角的坐标。
+ 这个 API 的设计是为了和 cocos2d-x 中行为一致,更多情况下你可能需要使用 convertToNodeSpaceAR。 + @param worldPoint worldPoint + + @example + ```js + var newVec2 = node.convertToNodeSpace(cc.v2(100, 100)); + ``` + */ + convertToNodeSpace(worldPoint: Vec2): Vec2; + /** + !#en Converts a Point related to the left bottom corner of the node's bounding box to world space coordinates. + This equals to the API behavior of cocos2d-x, you probably want to use convertToWorldSpaceAR instead + !#zh 将一个相对于节点左下角的坐标位置转换到世界空间坐标系。 + 这个 API 的设计是为了和 cocos2d-x 中行为一致,更多情况下你可能需要使用 convertToWorldSpaceAR + @param nodePoint nodePoint + + @example + ```js + var newVec2 = node.convertToWorldSpace(cc.v2(100, 100)); + ``` + */ + convertToWorldSpace(nodePoint: Vec2): Vec2; + /** + !#en + Returns the matrix that transform the node's (local) space coordinates into the parent's space coordinates.
+ The matrix is in Pixels. + !#zh 返回这个将节点(局部)的空间坐标系转换成父节点的空间坐标系的矩阵。这个矩阵以像素为单位。 + @param out The affine transform object to be filled with data + + @example + ```js + let affineTransform = cc.AffineTransform.create(); + node.getNodeToParentTransform(affineTransform); + ``` + */ + getNodeToParentTransform(out?: AffineTransform): AffineTransform; + /** + !#en + Returns the matrix that transform the node's (local) space coordinates into the parent's space coordinates.
+ The matrix is in Pixels.
+ This method is AR (Anchor Relative). + !#zh + 返回这个将节点(局部)的空间坐标系转换成父节点的空间坐标系的矩阵。
+ 这个矩阵以像素为单位。
+ 该方法基于节点坐标。 + @param out The affine transform object to be filled with data + + @example + ```js + let affineTransform = cc.AffineTransform.create(); + node.getNodeToParentTransformAR(affineTransform); + ``` + */ + getNodeToParentTransformAR(out?: AffineTransform): AffineTransform; + /** + !#en Returns the world affine transform matrix. The matrix is in Pixels. + !#zh 返回节点到世界坐标系的仿射变换矩阵。矩阵单位是像素。 + @param out The affine transform object to be filled with data + + @example + ```js + let affineTransform = cc.AffineTransform.create(); + node.getNodeToWorldTransform(affineTransform); + ``` + */ + getNodeToWorldTransform(out?: AffineTransform): AffineTransform; + /** + !#en + Returns the world affine transform matrix. The matrix is in Pixels.
+ This method is AR (Anchor Relative). + !#zh + 返回节点到世界坐标仿射变换矩阵。矩阵单位是像素。
+ 该方法基于节点坐标。 + @param out The affine transform object to be filled with data + + @example + ```js + let affineTransform = cc.AffineTransform.create(); + node.getNodeToWorldTransformAR(affineTransform); + ``` + */ + getNodeToWorldTransformAR(out?: AffineTransform): AffineTransform; + /** + !#en + Returns the matrix that transform parent's space coordinates to the node's (local) space coordinates.
+ The matrix is in Pixels. The returned transform is readonly and cannot be changed. + !#zh + 返回将父节点的坐标系转换成节点(局部)的空间坐标系的矩阵。
+ 该矩阵以像素为单位。返回的矩阵是只读的,不能更改。 + @param out The affine transform object to be filled with data + + @example + ```js + let affineTransform = cc.AffineTransform.create(); + node.getParentToNodeTransform(affineTransform); + ``` + */ + getParentToNodeTransform(out?: AffineTransform): AffineTransform; + /** + !#en Returns the inverse world affine transform matrix. The matrix is in Pixels. + !#en 返回世界坐标系到节点坐标系的逆矩阵。 + @param out The affine transform object to be filled with data + + @example + ```js + let affineTransform = cc.AffineTransform.create(); + node.getWorldToNodeTransform(affineTransform); + ``` + */ + getWorldToNodeTransform(out?: AffineTransform): AffineTransform; + /** + !#en convenience methods which take a cc.Touch instead of cc.Vec2. + !#zh 将触摸点转换成本地坐标系中位置。 + @param touch The touch object + + @example + ```js + var newVec2 = node.convertTouchToNodeSpace(touch); + ``` + */ + convertTouchToNodeSpace(touch: Touch): Vec2; + /** + !#en converts a cc.Touch (world coordinates) into a local coordinate. This method is AR (Anchor Relative). + !#zh 转换一个 cc.Touch(世界坐标)到一个局部坐标,该方法基于节点坐标。 + @param touch The touch object + + @example + ```js + var newVec2 = node.convertTouchToNodeSpaceAR(touch); + ``` + */ + convertTouchToNodeSpaceAR(touch: Touch): Vec2; + /** + !#en + Returns a "local" axis aligned bounding box of the node.
+ The returned box is relative only to its parent. + !#zh 返回父节坐标系下的轴向对齐的包围盒。 + + @example + ```js + var boundingBox = node.getBoundingBox(); + ``` + */ + getBoundingBox(): Rect; + /** + !#en + Returns a "world" axis aligned bounding box of the node.
+ The bounding box contains self and active children's world bounding box. + !#zh + 返回节点在世界坐标系下的对齐轴向的包围盒(AABB)。
+ 该边框包含自身和已激活的子节点的世界边框。 + + @example + ```js + var newRect = node.getBoundingBoxToWorld(); + ``` + */ + getBoundingBoxToWorld(): Rect; + /** + !#en + Adds a child to the node with z order and name. + !#zh + 添加子节点,并且可以修改该节点的 局部 Z 顺序和名字。 + @param child A child node + @param zIndex Z order for drawing priority. Please refer to zIndex property + @param name A name to identify the node easily. Please refer to name property + + @example + ```js + node.addChild(newNode, 1, "node"); + ``` + */ + addChild(child: Node, zIndex?: number, name?: string): void; + /** + !#en Stops all running actions and schedulers. + !#zh 停止所有正在播放的动作和计时器。 + + @example + ```js + node.cleanup(); + ``` + */ + cleanup(): void; + /** + !#en Sorts the children array depends on children's zIndex and arrivalOrder, + normally you won't need to invoke this function. + !#zh 根据子节点的 zIndex 和 arrivalOrder 进行排序,正常情况下开发者不需要手动调用这个函数。 + */ + sortAllChildren(): void; + /** + !#en + Returns the displayed opacity of Node, + the difference between displayed opacity and opacity is that displayed opacity is calculated based on opacity and parent node's opacity when cascade opacity enabled. + !#zh + 获取节点显示透明度, + 显示透明度和透明度之间的不同之处在于当启用级连透明度时, + 显示透明度是基于自身透明度和父节点透明度计算的。 + */ + getDisplayedOpacity(): number; + /** + !#en + Returns the displayed color of Node, + the difference between displayed color and color is that displayed color is calculated based on color and parent node's color when cascade color enabled. + !#zh + 获取节点的显示颜色, + 显示颜色和颜色之间的不同之处在于当启用级连颜色时, + 显示颜色是基于自身颜色和父节点颜色计算的。 + */ + getDisplayedColor(): Color; + /** !#en Cascade opacity is removed from v2.0 + Indicate whether node's opacity value affect its child nodes, default value is true. + !#zh 透明度级联功能从 v2.0 开始已移除 + 节点的不透明度值是否影响其子节点,默认值为 true。 */ + cascadeOpacity: boolean; + /** + !#en Cascade opacity is removed from v2.0 + Returns whether node's opacity value affect its child nodes. + !#zh 透明度级联功能从 v2.0 开始已移除 + 返回节点的不透明度值是否影响其子节点。 + */ + isCascadeOpacityEnabled(): boolean; + /** + !#en Cascade opacity is removed from v2.0 + Enable or disable cascade opacity, if cascade enabled, child nodes' opacity will be the multiplication of parent opacity and its own opacity. + !#zh 透明度级联功能从 v2.0 开始已移除 + 启用或禁用级连不透明度,如果级连启用,子节点的不透明度将是父不透明度乘上它自己的不透明度。 + @param cascadeOpacityEnabled cascadeOpacityEnabled + */ + setCascadeOpacityEnabled(cascadeOpacityEnabled: boolean): void; + /** + !#en Opacity modify RGB have been removed since v2.0 + Set whether color should be changed with the opacity value, + useless in ccsg.Node, but this function is override in some class to have such behavior. + !#zh 透明度影响颜色配置已经被废弃 + 设置更改透明度时是否修改RGB值, + @param opacityValue opacityValue + */ + setOpacityModifyRGB(opacityValue: boolean): void; + /** + !#en Opacity modify RGB have been removed since v2.0 + Get whether color should be changed with the opacity value. + !#zh 透明度影响颜色配置已经被废弃 + 获取更改透明度时是否修改RGB值。 + */ + isOpacityModifyRGB(): boolean; + } + /** !#en + Class of private entities in Cocos Creator scenes.
+ The PrivateNode is hidden in editor, and completely transparent to users.
+ It's normally used as Node's private content created by components in parent node.
+ So in theory private nodes are not children, they are part of the parent node.
+ Private node have two important characteristics:
+ 1. It has the minimum z index and cannot be modified, because they can't be displayed over real children.
+ 2. The positioning of private nodes is also special, they will consider the left bottom corner of the parent node's bounding box as the origin of local coordinates.
+ In this way, they can be easily kept inside the bounding box.
+ Currently, it's used by RichText component and TileMap component. + !#zh + Cocos Creator 场景中的私有节点类。
+ 私有节点在编辑器中不可见,对用户透明。
+ 通常私有节点是被一些特殊的组件创建出来作为父节点的一部分而存在的,理论上来说,它们不是子节点,而是父节点的组成部分。
+ 私有节点有两个非常重要的特性:
+ 1. 它有着最小的渲染排序的 Z 轴深度,并且无法被更改,因为它们不能被显示在其他正常子节点之上。
+ 2. 它的定位也是特殊的,对于私有节点来说,父节点包围盒的左下角是它的局部坐标系原点,这个原点相当于父节点的位置减去它锚点的偏移。这样私有节点可以比较容易被控制在包围盒之中。
+ 目前在引擎中,RichText 和 TileMap 都有可能生成私有节点。 */ + export class PrivateNode extends Node { + /** + + @param name name + */ + constructor(name?: string); + } + /** !#en + cc.Scene is a subclass of cc.Node that is used only as an abstract concept.
+ cc.Scene and cc.Node are almost identical with the difference that users can not modify cc.Scene manually. + !#zh + cc.Scene 是 cc.Node 的子类,仅作为一个抽象的概念。
+ cc.Scene 和 cc.Node 有点不同,用户不应直接修改 cc.Scene。 */ + export class Scene extends Node { + /** !#en Indicates whether all (directly or indirectly) static referenced assets of this scene are releasable by default after scene unloading. + !#zh 指示该场景中直接或间接静态引用到的所有资源是否默认在场景切换后自动释放。 */ + autoReleaseAssets: boolean; + } + /** !#en + Scheduler is responsible of triggering the scheduled callbacks.
+ You should not use NSTimer. Instead use this class.
+
+ There are 2 different types of callbacks (selectors):
+ - update callback: the 'update' callback will be called every frame. You can customize the priority.
+ - custom callback: A custom callback will be called every frame, or with a custom interval of time
+
+ The 'custom selectors' should be avoided when possible. It is faster, + and consumes less memory to use the 'update callback'. * + !#zh + Scheduler 是负责触发回调函数的类。
+ 通常情况下,建议使用 cc.director.getScheduler() 来获取系统定时器。
+ 有两种不同类型的定时器:
+ - update 定时器:每一帧都会触发。您可以自定义优先级。
+ - 自定义定时器:自定义定时器可以每一帧或者自定义的时间间隔触发。
+ 如果希望每帧都触发,应该使用 update 定时器,使用 update 定时器更快,而且消耗更少的内存。 */ + export class Scheduler { + /** + !#en This method should be called for any target which needs to schedule tasks, and this method should be called before any scheduler API usage. + This method will add a `_id` property if it doesn't exist. + !#zh 任何需要用 Scheduler 管理任务的对象主体都应该调用这个方法,并且应该在调用任何 Scheduler API 之前调用这个方法。 + 这个方法会给对象添加一个 `_id` 属性,如果这个属性不存在的话。 + @param target target + */ + enableForTarget(target: any): void; + /** + !#en + Modifies the time of all scheduled callbacks.
+ You can use this property to create a 'slow motion' or 'fast forward' effect.
+ Default is 1.0. To create a 'slow motion' effect, use values below 1.0.
+ To create a 'fast forward' effect, use values higher than 1.0.
+ Note:It will affect EVERY scheduled selector / action. + !#zh + 设置时间间隔的缩放比例。
+ 您可以使用这个方法来创建一个 “slow motion(慢动作)” 或 “fast forward(快进)” 的效果。
+ 默认是 1.0。要创建一个 “slow motion(慢动作)” 效果,使用值低于 1.0。
+ 要使用 “fast forward(快进)” 效果,使用值大于 1.0。
+ 注意:它影响该 Scheduler 下管理的所有定时器。 + @param timeScale timeScale + */ + setTimeScale(timeScale: number): void; + /** + !#en Returns time scale of scheduler. + !#zh 获取时间间隔的缩放比例。 + */ + getTimeScale(): number; + /** + !#en 'update' the scheduler. (You should NEVER call this method, unless you know what you are doing.) + !#zh update 调度函数。(不应该直接调用这个方法,除非完全了解这么做的结果) + @param dt delta time + */ + update(dt: number): void; + /** + !#en +

+ The scheduled method will be called every 'interval' seconds.
+ If paused is YES, then it won't be called until it is resumed.
+ If 'interval' is 0, it will be called every frame, but if so, it recommended to use 'scheduleUpdateForTarget:' instead.
+ If the callback function is already scheduled, then only the interval parameter will be updated without re-scheduling it again.
+ repeat let the action be repeated repeat + 1 times, use cc.macro.REPEAT_FOREVER to let the action run continuously
+ delay is the amount of time the action will wait before it'll start
+

+ !#zh + 指定回调函数,调用对象等信息来添加一个新的定时器。
+ 如果 paused 值为 true,那么直到 resume 被调用才开始计时。
+ 当时间间隔达到指定值时,设置的回调函数将会被调用。
+ 如果 interval 值为 0,那么回调函数每一帧都会被调用,但如果是这样, + 建议使用 scheduleUpdateForTarget 代替。
+ 如果回调函数已经被定时器使用,那么只会更新之前定时器的时间间隔参数,不会设置新的定时器。
+ repeat 值可以让定时器触发 repeat + 1 次,使用 cc.macro.REPEAT_FOREVER + 可以让定时器一直循环触发。
+ delay 值指定延迟时间,定时器会在延迟指定的时间之后开始计时。 + @param callback callback + @param target target + @param interval interval + @param repeat repeat + @param delay delay + @param paused paused + + @example + ```js + //register a schedule to scheduler + cc.director.getScheduler().schedule(callback, this, interval, !this._isRunning); + + ``` + */ + schedule(callback: Function, target: any, interval: number, repeat: number, delay: number, paused?: boolean): void; + schedule(callback: Function, target: any, interval: number, paused?: boolean): void; + /** + !#en + Schedules the update callback for a given target, + During every frame after schedule started, the "update" function of target will be invoked. + !#zh + 使用指定的优先级为指定的对象设置 update 定时器。 + update 定时器每一帧都会被触发,触发时自动调用指定对象的 "update" 函数。 + 优先级的值越低,定时器被触发的越早。 + @param target target + @param priority priority + @param paused paused + */ + scheduleUpdate(target: any, priority: number, paused: boolean): void; + /** + !#en + Unschedules a callback for a callback and a given target. + If you want to unschedule the "update", use `unscheduleUpdate()` + !#zh + 取消指定对象定时器。 + 如果需要取消 update 定时器,请使用 unscheduleUpdate()。 + @param callback The callback to be unscheduled + @param target The target bound to the callback. + */ + unschedule(callback: Function, target: any): void; + /** + !#en Unschedules the update callback for a given target. + !#zh 取消指定对象的 update 定时器。 + @param target The target to be unscheduled. + */ + unscheduleUpdate(target: any): void; + /** + !#en + Unschedules all scheduled callbacks for a given target. + This also includes the "update" callback. + !#zh 取消指定对象的所有定时器,包括 update 定时器。 + @param target The target to be unscheduled. + */ + unscheduleAllForTarget(target: any): void; + /** + !#en + Unschedules all scheduled callbacks from all targets including the system callbacks.
+ You should NEVER call this method, unless you know what you are doing. + !#zh + 取消所有对象的所有定时器,包括系统定时器。
+ 不用调用此函数,除非你确定你在做什么。 + */ + unscheduleAll(): void; + /** + !#en + Unschedules all callbacks from all targets with a minimum priority.
+ You should only call this with `PRIORITY_NON_SYSTEM_MIN` or higher. + !#zh + 取消所有优先级的值大于指定优先级的定时器。
+ 你应该只取消优先级的值大于 PRIORITY_NON_SYSTEM_MIN 的定时器。 + @param minPriority The minimum priority of selector to be unscheduled. Which means, all selectors which + priority is higher than minPriority will be unscheduled. + */ + unscheduleAllWithMinPriority(minPriority: number): void; + /** + !#en Checks whether a callback for a given target is scheduled. + !#zh 检查指定的回调函数和回调对象组合是否存在定时器。 + @param callback The callback to check. + @param target The target of the callback. + */ + isScheduled(callback: Function, target: any): boolean; + /** + !#en + Pause all selectors from all targets.
+ You should NEVER call this method, unless you know what you are doing. + !#zh + 暂停所有对象的所有定时器。
+ 不要调用这个方法,除非你知道你正在做什么。 + */ + pauseAllTargets(): void; + /** + !#en + Pause all selectors from all targets with a minimum priority.
+ You should only call this with kCCPriorityNonSystemMin or higher. + !#zh + 暂停所有优先级的值大于指定优先级的定时器。
+ 你应该只暂停优先级的值大于 PRIORITY_NON_SYSTEM_MIN 的定时器。 + @param minPriority minPriority + */ + pauseAllTargetsWithMinPriority(minPriority: number): void; + /** + !#en + Resume selectors on a set of targets.
+ This can be useful for undoing a call to pauseAllCallbacks. + !#zh + 恢复指定数组中所有对象的定时器。
+ 这个函数是 pauseAllCallbacks 的逆操作。 + @param targetsToResume targetsToResume + */ + resumeTargets(targetsToResume: any[]): void; + /** + !#en + Pauses the target.
+ All scheduled selectors/update for a given target won't be 'ticked' until the target is resumed.
+ If the target is not present, nothing happens. + !#zh + 暂停指定对象的定时器。
+ 指定对象的所有定时器都会被暂停。
+ 如果指定的对象没有定时器,什么也不会发生。 + @param target target + */ + pauseTarget(target: any): void; + /** + !#en + Resumes the target.
+ The 'target' will be unpaused, so all schedule selectors/update will be 'ticked' again.
+ If the target is not present, nothing happens. + !#zh + 恢复指定对象的所有定时器。
+ 指定对象的所有定时器将继续工作。
+ 如果指定的对象没有定时器,什么也不会发生。 + @param target target + */ + resumeTarget(target: any): void; + /** + !#en Returns whether or not the target is paused. + !#zh 返回指定对象的定时器是否暂停了。 + @param target target + */ + isTargetPaused(target: any): boolean; + /** !#en Priority level reserved for system services. + !#zh 系统服务的优先级。 */ + static PRIORITY_SYSTEM: number; + /** !#en Minimum priority level for user scheduling. + !#zh 用户调度最低优先级。 */ + static PRIORITY_NON_SYSTEM: number; + } + /** !#en + cc.NodePool is the cache pool designed for node type.
+ It can helps you to improve your game performance for objects which need frequent release and recreate operations
+ + It's recommended to create cc.NodePool instances by node type, the type corresponds to node type in game design, not the class, + for example, a prefab is a specific node type.
+ When you create a node pool, you can pass a Component which contains `unuse`, `reuse` functions to control the content of node.
+ + Some common use case is :
+ 1. Bullets in game (die very soon, massive creation and recreation, no side effect on other objects)
+ 2. Blocks in candy crash (massive creation and recreation)
+ etc... + !#zh + cc.NodePool 是用于管理节点对象的对象缓存池。
+ 它可以帮助您提高游戏性能,适用于优化对象的反复创建和销毁
+ 以前 cocos2d-x 中的 cc.pool 和新的节点事件注册系统不兼容,因此请使用 cc.NodePool 来代替。 + + 新的 NodePool 需要实例化之后才能使用,每种不同的节点对象池需要一个不同的对象池实例,这里的种类对应于游戏中的节点设计,一个 prefab 相当于一个种类的节点。
+ 在创建缓冲池时,可以传入一个包含 unuse, reuse 函数的组件类型用于节点的回收和复用逻辑。
+ + 一些常见的用例是:
+ 1.在游戏中的子弹(死亡很快,频繁创建,对其他对象无副作用)
+ 2.糖果粉碎传奇中的木块(频繁创建)。 + 等等.... */ + export class NodePool { + /** + !#en + Constructor for creating a pool for a specific node template (usually a prefab). You can pass a component (type or name) argument for handling event for reusing and recycling node. + !#zh + 使用构造函数来创建一个节点专用的对象池,您可以传递一个组件类型或名称,用于处理节点回收和复用时的事件逻辑。 + @param poolHandlerComp !#en The constructor or the class name of the component to control the unuse/reuse logic. !#zh 处理节点回收和复用事件逻辑的组件类型或名称。 + + @example + ```js + properties: { + template: cc.Prefab + }, + onLoad () { + // MyTemplateHandler is a component with 'unuse' and 'reuse' to handle events when node is reused or recycled. + this.myPool = new cc.NodePool('MyTemplateHandler'); + } + ``` + */ + constructor(poolHandlerComp?: {prototype: Component}|string); + /** !#en The pool handler component, it could be the class name or the constructor. + !#zh 缓冲池处理组件,用于节点的回收和复用逻辑,这个属性可以是组件类名或组件的构造函数。 */ + poolHandlerComp: Function|string; + /** + !#en The current available size in the pool + !#zh 获取当前缓冲池的可用对象数量 + */ + size(): number; + /** + !#en Destroy all cached nodes in the pool + !#zh 销毁对象池中缓存的所有节点 + */ + clear(): void; + /** + !#en Put a new Node into the pool. + It will automatically remove the node from its parent without cleanup. + It will also invoke unuse method of the poolHandlerComp if exist. + !#zh 向缓冲池中存入一个不再需要的节点对象。 + 这个函数会自动将目标节点从父节点上移除,但是不会进行 cleanup 操作。 + 这个函数会调用 poolHandlerComp 的 unuse 函数,如果组件和函数都存在的话。 + @param obj obj + + @example + ```js + let myNode = cc.instantiate(this.template); + this.myPool.put(myNode); + ``` + */ + put(obj: Node): void; + /** + !#en Get a obj from pool, if no available object in pool, null will be returned. + This function will invoke the reuse function of poolHandlerComp if exist. + !#zh 获取对象池中的对象,如果对象池没有可用对象,则返回空。 + 这个函数会调用 poolHandlerComp 的 reuse 函数,如果组件和函数都存在的话。 + @param params !#en Params to pass to 'reuse' method in poolHandlerComp !#zh 向 poolHandlerComp 中的 'reuse' 函数传递的参数 + + @example + ```js + let newNode = this.myPool.get(); + ``` + */ + get(...params: any[]): Node; + } + /** !#en cc.WebView is a component for display web pages in the game. Because different platforms have different authorization, API and control methods for WebView component. And have not yet formed a unified standard, only Web, iOS, and Android platforms are currently supported. + !#zh WebView 组件,用于在游戏中显示网页。由于不同平台对于 WebView 组件的授权、API、控制方式都不同,还没有形成统一的标准,所以目前只支持 Web、iOS 和 Android 平台。 */ + export class WebView extends Component { + /** !#en A given URL to be loaded by the WebView, it should have a http or https prefix. + !#zh 指定 WebView 加载的网址,它应该是一个 http 或者 https 开头的字符串 */ + url: string; + /** !#en The webview's event callback , it will be triggered when certain webview event occurs. + !#zh WebView 的回调事件,当网页加载过程中,加载完成后或者加载出错时都会回调此函数 */ + webviewLoadedEvents: Component.EventHandler[]; + /** + !#en + Set javascript interface scheme (see also setOnJSCallback).
+ Note: Supports only on the Android and iOS. For HTML5, please refer to the official documentation.
+ Please refer to the official documentation for more details. + !#zh + 设置 JavaScript 接口方案(与 'setOnJSCallback' 配套使用)。
+ 注意:只支持 Android 和 iOS ,Web 端用法请前往官方文档查看。
+ 详情请参阅官方文档 + @param scheme scheme + */ + setJavascriptInterfaceScheme(scheme: string): void; + /** + !#en + This callback called when load URL that start with javascript + interface scheme (see also setJavascriptInterfaceScheme).
+ Note: Supports only on the Android and iOS. For HTML5, please refer to the official documentation.
+ Please refer to the official documentation for more details. + !#zh + 当加载 URL 以 JavaScript 接口方案开始时调用这个回调函数。
+ 注意:只支持 Android 和 iOS,Web 端用法请前往官方文档查看。 + 详情请参阅官方文档 + @param callback callback + */ + setOnJSCallback(callback: Function): void; + /** + !#en + Evaluates JavaScript in the context of the currently displayed page.
+ Please refer to the official document for more details
+ Note: Cross domain issues need to be resolved by yourself
+ !#zh + 执行 WebView 内部页面脚本(详情请参阅官方文档)
+ 注意:需要自行解决跨域问题 + @param str str + */ + evaluateJS(str: string): void; + /** + !#en if you don't need the WebView and it isn't in any running Scene, you should + call the destroy method on this component or the associated node explicitly. + Otherwise, the created DOM element won't be removed from web page. + !#zh + 如果你不再使用 WebView,并且组件未添加到场景中,那么你必须手动对组件或所在节点调用 destroy。 + 这样才能移除网页上的 DOM 节点,避免 Web 平台内存泄露。 + + @example + ```js + webview.node.parent = null; // or webview.node.removeFromParent(false); + // when you don't need webview anymore + webview.node.destroy(); + ``` + */ + destroy(): boolean; + } + /** !#en cc.VideoPlayer is a component for playing videos, you can use it for showing videos in your game. Because different platforms have different authorization, API and control methods for VideoPlayer component. And have not yet formed a unified standard, only Web, iOS, and Android platforms are currently supported. + !#zh Video 组件,用于在游戏中播放视频。由于不同平台对于 VideoPlayer 组件的授权、API、控制方式都不同,还没有形成统一的标准,所以目前只支持 Web、iOS 和 Android 平台。 */ + export class VideoPlayer extends Component { + /** !#en The resource type of videoplayer, REMOTE for remote url and LOCAL for local file path. + !#zh 视频来源:REMOTE 表示远程视频 URL,LOCAL 表示本地视频地址。 */ + resourceType: VideoPlayer.ResourceType; + /** !#en The remote URL of video. + !#zh 远程视频的 URL */ + remoteURL: string; + /** !#en The local video full path. + !#zh 本地视频的 URL */ + clip: string; + /** !#en The current playback time of the now playing item in seconds, you could also change the start playback time. + !#zh 指定视频从什么时间点开始播放,单位是秒,也可以用来获取当前视频播放的时间进度。 */ + currentTime: number; + /** !#en The volume of the video. + !#zh 视频的音量(0.0 ~ 1.0) */ + volume: number; + /** !#en Mutes the VideoPlayer. Mute sets the volume=0, Un-Mute restore the original volume. + !#zh 是否静音视频。静音时设置音量为 0,取消静音是恢复原来的音量。 */ + mute: boolean; + /** !#en Whether keep the aspect ration of the original video. + !#zh 是否保持视频原来的宽高比 */ + keepAspectRatio: boolean; + /** !#en Whether play video in fullscreen mode. + !#zh 是否全屏播放视频 */ + isFullscreen: boolean; + /** !#en Always below the game view (only useful on Web. Note: The specific effects are not guaranteed to be consistent, depending on whether each browser supports or restricts). + !#zh 永远在游戏视图最底层(这个属性只有在 Web 平台上有效果。注意:具体效果无法保证一致,跟各个浏览器是否支持与限制有关) */ + stayOnBottom: boolean; + /** !#en the video player's callback, it will be triggered when certain event occurs, like: playing, paused, stopped and completed. + !#zh 视频播放回调函数,该回调函数会在特定情况被触发,比如播放中,暂时,停止和完成播放。 */ + videoPlayerEvent: Component.EventHandler[]; + /** + !#en If a video is paused, call this method could resume playing. If a video is stopped, call this method to play from scratch. + !#zh 如果视频被暂停播放了,调用这个接口可以继续播放。如果视频被停止播放了,调用这个接口可以从头开始播放。 + */ + play(): void; + /** + !#en If a video is paused, call this method to resume playing. + !#zh 如果一个视频播放被暂停播放了,调用这个接口可以继续播放。 + */ + resume(): void; + /** + !#en If a video is playing, call this method to pause playing. + !#zh 如果一个视频正在播放,调用这个接口可以暂停播放。 + */ + pause(): void; + /** + !#en If a video is playing, call this method to stop playing immediately. + !#zh 如果一个视频正在播放,调用这个接口可以立马停止播放。 + */ + stop(): void; + /** + !#en Gets the duration of the video + !#zh 获取视频文件的播放总时长 + */ + getDuration(): number; + /** + !#en Determine whether video is playing or not. + !#zh 判断当前视频是否处于播放状态 + */ + isPlaying(): boolean; + /** + !#en if you don't need the VideoPlayer and it isn't in any running Scene, you should + call the destroy method on this component or the associated node explicitly. + Otherwise, the created DOM element won't be removed from web page. + !#zh + 如果你不再使用 VideoPlayer,并且组件未添加到场景中,那么你必须手动对组件或所在节点调用 destroy。 + 这样才能移除网页上的 DOM 节点,避免 Web 平台内存泄露。 + + @example + ```js + videoplayer.node.parent = null; // or videoplayer.node.removeFromParent(false); + // when you don't need videoplayer anymore + videoplayer.node.destroy(); + ``` + */ + destroy(): boolean; + } + /** !#en + Camera is usefull when making reel game or other games which need scroll screen. + Using camera will be more efficient than moving node to scroll screen. + Camera + !#zh + 摄像机在制作卷轴或是其他需要移动屏幕的游戏时比较有用,使用摄像机将会比移动节点来移动屏幕更加高效。 */ + export class Camera extends Component { + /** !#en + The camera zoom ratio, only support 2D camera. + !#zh + 摄像机缩放比率, 只支持 2D camera。 */ + zoomRatio: number; + /** !#en + Field of view. The width of the Camera’s view angle, measured in degrees along the local Y axis. + !#zh + 决定摄像机视角的宽度,当摄像机处于透视投影模式下这个属性才会生效。 */ + fov: number; + /** !#en + The viewport size of the Camera when set to orthographic projection. + !#zh + 摄像机在正交投影模式下的视窗大小。 */ + orthoSize: number; + /** !#en + The near clipping plane. + !#zh + 摄像机的近剪裁面。 */ + nearClip: number; + /** !#en + The far clipping plane. + !#zh + 摄像机的远剪裁面。 */ + farClip: number; + /** !#en + Is the camera orthographic (true) or perspective (false)? + !#zh + 设置摄像机的投影模式是正交还是透视模式。 */ + ortho: boolean; + /** !#en + Four values (0 ~ 1) that indicate where on the screen this camera view will be drawn. + !#zh + 决定摄像机绘制在屏幕上哪个位置,值为(0 ~ 1)。 */ + rect: Rect; + /** !#en + This is used to render parts of the scene selectively. + !#zh + 决定摄像机会渲染场景的哪一部分。 */ + cullingMask: number; + /** !#en + Determining what to clear when camera rendering. + !#zh + 决定摄像机渲染时会清除哪些状态。 */ + clearFlags: Camera.ClearFlags; + /** !#en + The color with which the screen will be cleared. + !#zh + 摄像机用于清除屏幕的背景色。 */ + backgroundColor: Color; + /** !#en + Camera's depth in the camera rendering order. + !#zh + 摄像机深度,用于决定摄像机的渲染顺序。 */ + depth: number; + /** !#en + Destination render texture. + Usually cameras render directly to screen, but for some effects it is useful to make a camera render into a texture. + !#zh + 摄像机渲染的目标 RenderTexture。 + 一般摄像机会直接渲染到屏幕上,但是有一些效果可以使用摄像机渲染到 RenderTexture 上再对 RenderTexture 进行处理来实现。 */ + targetTexture: RenderTexture; + /** !#en + Sets the camera's render stages. + !#zh + 设置摄像机渲染的阶段 */ + renderStages: number; + /** !#en Whether auto align camera viewport to screen + !#zh 是否自动将摄像机的视口对准屏幕 */ + alignWithScreen: boolean; + /** !#en + The first enabled camera. + !#zh + 第一个被激活的摄像机。 */ + static main: Camera; + /** !#en + All enabled cameras. + !#zh + 激活的所有摄像机。 */ + static cameras: Camera[]; + /** + !#en + Get the first camera which the node belong to. + !#zh + 获取节点所在的第一个摄像机。 + @param node node + */ + static findCamera(node: Node): Camera; + /** + !#en + Get the screen to world matrix, only support 2D camera which alignWithScreen is true. + !#zh + 获取屏幕坐标系到世界坐标系的矩阵,只适用于 alignWithScreen 为 true 的 2D 摄像机。 + @param out the matrix to receive the result + */ + getScreenToWorldMatrix2D(out: Mat4): Mat4; + /** + !#en + Get the world to camera matrix, only support 2D camera which alignWithScreen is true. + !#zh + 获取世界坐标系到摄像机坐标系的矩阵,只适用于 alignWithScreen 为 true 的 2D 摄像机。 + @param out the matrix to receive the result + */ + getWorldToScreenMatrix2D(out: Mat4): Mat4; + /** + !#en + Convert point from screen to world. + !#zh + 将坐标从屏幕坐标系转换到世界坐标系。 + @param screenPosition screenPosition + @param out out + */ + getScreenToWorldPoint(screenPosition: Vec3|Vec2, out?: Vec3|Vec2): Vec3; + /** + !#en + Convert point from world to screen. + !#zh + 将坐标从世界坐标系转化到屏幕坐标系。 + @param worldPosition worldPosition + @param out out + */ + getWorldToScreenPoint(worldPosition: Vec3|Vec2, out?: Vec3|Vec2): Vec3; + /** + !#en + Get a ray from screen position + !#zh + 从屏幕坐标获取一条射线 + @param screenPos screenPos + */ + getRay(screenPos: Vec2): geomUtils.Ray; + /** + !#en + Check whether the node is in the camera. + !#zh + 检测节点是否被此摄像机影响 + @param node the node which need to check + */ + containsNode(node: Node): boolean; + /** + !#en + Render the camera manually. + !#zh + 手动渲染摄像机。 + @param root root + */ + render(root: Node): void; + /** + !#en + Returns the matrix that transform the node's (local) space coordinates into the camera's space coordinates. + !#zh + 返回一个将节点坐标系转换到摄像机坐标系下的矩阵 + @param node the node which should transform + */ + getNodeToCameraTransform(node: Node): AffineTransform; + /** + !#en + Conver a camera coordinates point to world coordinates. + !#zh + 将一个摄像机坐标系下的点转换到世界坐标系下。 + @param point the point which should transform + @param out the point to receive the result + */ + getCameraToWorldPoint(point: Vec2, out?: Vec2): Vec2; + /** + !#en + Conver a world coordinates point to camera coordinates. + !#zh + 将一个世界坐标系下的点转换到摄像机坐标系下。 + @param point point + @param out the point to receive the result + */ + getWorldToCameraPoint(point: Vec2, out?: Vec2): Vec2; + /** + !#en + Get the camera to world matrix + !#zh + 获取摄像机坐标系到世界坐标系的矩阵 + @param out the matrix to receive the result + */ + getCameraToWorldMatrix(out: Mat4): Mat4; + /** + !#en + Get the world to camera matrix + !#zh + 获取世界坐标系到摄像机坐标系的矩阵 + @param out the matrix to receive the result + */ + getWorldToCameraMatrix(out: Mat4): Mat4; + } + /** !#en The Light Component + + !#zh 光源组件 */ + export class Light extends Component { + } + /** !#en Box Collider. + !#zh 包围盒碰撞组件 */ + export class BoxCollider extends Collider implements Collider.Box { + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Box size + !#zh 包围盒大小 */ + size: Size; + } + /** !#en Circle Collider. + !#zh 圆形碰撞组件 */ + export class CircleCollider extends Collider implements Collider.Circle { + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Circle radius + !#zh 圆形半径 */ + radius: number; + } + /** !#en Collider component base class. + !#zh 碰撞组件基类 */ + export class Collider extends Component { + /** !#en Tag. If a node has several collider components, you can judge which type of collider is collided according to the tag. + !#zh 标签。当一个节点上有多个碰撞组件时,在发生碰撞后,可以使用此标签来判断是节点上的哪个碰撞组件被碰撞了。 */ + tag: number; + } + /** !#en + A simple collision manager class. + It will calculate whether the collider collides other colliders, if collides then call the callbacks. + !#zh + 一个简单的碰撞组件管理类,用于处理节点之间的碰撞组件是否产生了碰撞,并调用相应回调函数。 */ + export class CollisionManager implements EventTarget { + /** !#en + !#zh + 是否开启碰撞管理,默认为不开启 */ + enabled: boolean; + /** !#en + !#zh + 是否绘制碰撞组件的包围盒,默认为不绘制 */ + enabledDrawBoundingBox: boolean; + /** !#en + !#zh + 是否绘制碰撞组件的形状,默认为不绘制 */ + enabledDebugDraw: boolean; + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en + Register an callback of a specific event type on the EventTarget. + This type of event should be triggered via `emit`. + !#zh + 注册事件目标的特定事件类型回调。这种类型的事件应该被 `emit` 触发。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, node); + ``` + */ + on(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. + !#zh + 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + + @example + ```js + // register fire eventListener + var callback = eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, target); + // remove fire event listener + eventTarget.off('fire', callback, target); + // remove all fire event listeners + eventTarget.off('fire'); + ``` + */ + off(type: string, callback?: Function, target?: any): void; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.once('fire', function () { + cc.log("this is the callback and will be invoked only once"); + }, node); + ``` + */ + once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; + /** + !#en + Send an event with the event object. + !#zh + 通过事件对象派发事件 + @param event event + */ + dispatchEvent(event: Event): void; + } + /** !#en Intersection helper class + !#zh 辅助类,用于测试形状与形状是否相交 */ + export class Intersection { + /** + !#en Test line and line + !#zh 测试线段与线段是否相交 + @param a1 The start point of the first line + @param a2 The end point of the first line + @param b1 The start point of the second line + @param b2 The end point of the second line + */ + static lineLine(a1: Vec2, a2: Vec2, b1: Vec2, b2: Vec2): boolean; + /** + !#en Test line and rect + !#zh 测试线段与矩形是否相交 + @param a1 The start point of the line + @param a2 The end point of the line + @param b The rect + */ + static lineRect(a1: Vec2, a2: Vec2, b: Rect): boolean; + /** + !#en Test line and polygon + !#zh 测试线段与多边形是否相交 + @param a1 The start point of the line + @param a2 The end point of the line + @param b The polygon, a set of points + */ + static linePolygon(a1: Vec2, a2: Vec2, b: Vec2[]): boolean; + /** + !#en Test rect and rect + !#zh 测试矩形与矩形是否相交 + @param a The first rect + @param b The second rect + */ + static rectRect(a: Rect, b: Rect): boolean; + /** + !#en Test rect and polygon + !#zh 测试矩形与多边形是否相交 + @param a The rect + @param b The polygon, a set of points + */ + static rectPolygon(a: Rect, b: Vec2[]): boolean; + /** + !#en Test polygon and polygon + !#zh 测试多边形与多边形是否相交 + @param a The first polygon, a set of points + @param b The second polygon, a set of points + */ + static polygonPolygon(a: Vec2[], b: Vec2[]): boolean; + /** + !#en Test circle and circle + !#zh 测试圆形与圆形是否相交 + @param a Object contains position and radius + @param b Object contains position and radius + */ + static circleCircle(a: {position: Vec2, radius: number}, b: {position: Vec2, radius: number}): boolean; + /** + !#en Test polygon and circle + !#zh 测试矩形与圆形是否相交 + @param polygon The Polygon, a set of points + @param circle Object contains position and radius + */ + static polygonCircle(polygon: Vec2[], circle: {position: Vec2, radius: number}): boolean; + /** + !#en Test whether the point is in the polygon + !#zh 测试一个点是否在一个多边形中 + @param point The point + @param polygon The polygon, a set of points + */ + static pointInPolygon(point: Vec2, polygon: Vec2[]): boolean; + /** + !#en Calculate the distance of point to line. + !#zh 计算点到直线的距离。如果这是一条线段并且垂足不在线段内,则会计算点到线段端点的距离。 + @param point The point + @param start The start point of line + @param end The end point of line + @param isSegment whether this line is a segment + */ + static pointLineDistance(point: Vec2, start: Vec2, end: Vec2, isSegment: boolean): number; + } + /** !#en Polygon Collider. + !#zh 多边形碰撞组件 */ + export class PolygonCollider extends Collider implements Collider.Polygon { + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Polygon points + !#zh 多边形顶点数组 */ + points: Vec2[]; + } + /** !#en + Base class for handling assets used in Creator.
+ + You may want to override:
+ - createNode
+ - getset functions of _nativeAsset
+ - cc.Object._serialize
+ - cc.Object._deserialize
+ !#zh + Creator 中的资源基类。
+ + 您可能需要重写:
+ - createNode
+ - _nativeAsset 的 getset 方法
+ - cc.Object._serialize
+ - cc.Object._deserialize
*/ + export class Asset extends RawAsset { + /** !#en + Whether the asset is loaded or not + !#zh + 该资源是否已经成功加载 */ + loaded: boolean; + /** !#en + Points to the true url of this asset's native object, only valid when asset is loaded and asyncLoadAsset is not enabled. + The difference between nativeUrl and url is that the latter is final path, there is no needs to transform url by md5 and subpackage. + Besides, url may points to temporary path or cached path on mini game platform which has cache mechanism (WeChat etc). + If you want to make use of the native file on those platforms, you should use url instead of nativeUrl. + + !#zh + 资源的原生文件的真实url,只在资源被加载后以及没有启用延迟加载时才有效。 nativeUrl 与 url 的区别在于,url 是资源最终路径,所以 url 不需要再经过 md5 以及子包的路径转换, + 另外某些带缓存机制的小游戏平台(微信等)上url可能会指向临时文件路径或者缓存路径,如果你需要在这些平台上使用资源的原生文件,请使用url,避免使用nativeUrl */ + url: string; + /** !#en + Returns the url of this asset's native object, if none it will returns an empty string. + !#zh + 返回该资源对应的目标平台资源的 URL,如果没有将返回一个空字符串。 */ + nativeUrl: string; + /** !#en Indicates whether its dependent raw assets can support deferred load if the owner scene (or prefab) is marked as `asyncLoadAssets`. + !#zh 当场景或 Prefab 被标记为 `asyncLoadAssets`,禁止延迟加载该资源所依赖的其它 RawAsset。 */ + static preventDeferredLoadDependents: boolean; + /** !#en Indicates whether its native object should be preloaded from native url. + !#zh 禁止预加载原生对象。 */ + static preventPreloadNativeObject: boolean; + /** + Returns the asset's url. + + The `Asset` object overrides the `toString()` method of the `Object` object. + For `Asset` objects, the toString() method returns a string representation of the object. + JavaScript calls the toString() method automatically when an asset is to be represented as a text value or when a texture is referred to in a string concatenation. + */ + toString(): string; + /** + !#en + Create a new node using this asset in the scene.
+ If this type of asset dont have its corresponding node type, this method should be null. + !#zh + 使用该资源在场景中创建一个新节点。
+ 如果这类资源没有相应的节点类型,该方法应该是空的。 + @param callback callback + */ + createNode(callback: (error: string, node: any) => void): void; + } + /** !#en Class for audio data handling. + !#zh 音频资源类。 */ + export class AudioClip extends Asset implements EventTarget { + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en + Register an callback of a specific event type on the EventTarget. + This type of event should be triggered via `emit`. + !#zh + 注册事件目标的特定事件类型回调。这种类型的事件应该被 `emit` 触发。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, node); + ``` + */ + on(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. + !#zh + 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + + @example + ```js + // register fire eventListener + var callback = eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, target); + // remove fire event listener + eventTarget.off('fire', callback, target); + // remove all fire event listeners + eventTarget.off('fire'); + ``` + */ + off(type: string, callback?: Function, target?: any): void; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.once('fire', function () { + cc.log("this is the callback and will be invoked only once"); + }, node); + ``` + */ + once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; + /** + !#en + Send an event with the event object. + !#zh + 通过事件对象派发事件 + @param event event + */ + dispatchEvent(event: Event): void; + } + /** !#en Class for BitmapFont handling. + !#zh 位图字体资源类。 */ + export class BitmapFont extends Font { + } + /** undefined */ + export class BufferAsset extends Asset { + } + /** !#en Class for Font handling. + !#zh 字体资源类。 */ + export class Font extends Asset { + } + /** !#en + Class for JSON file. When the JSON file is loaded, this object is returned. + The parsed JSON object can be accessed through the `json` attribute in it.
+ If you want to get the original JSON text, you should modify the extname to `.txt` + so that it is loaded as a `TextAsset` instead of a `JsonAsset`. + + !#zh + JSON 资源类。JSON 文件加载后,将会返回该对象。可以通过其中的 `json` 属性访问解析后的 JSON 对象。
+ 如果你想要获得 JSON 的原始文本,那么应该修改源文件的后缀为 `.txt`,这样就会加载为一个 `TextAsset` 而不是 `JsonAsset`。 */ + export class JsonAsset extends Asset { + /** The loaded JSON object. */ + json: any; + } + /** !#en Class for LabelAtlas handling. + !#zh 艺术数字字体资源类。 */ + export class LabelAtlas extends BitmapFont { + } + /** !#en Class for prefab handling. + !#zh 预制资源类。 */ + export class Prefab extends Asset { + /** the main cc.Node in the prefab */ + data: Node; + /** !#zh + 设置实例化这个 prefab 时所用的优化策略。根据使用情况设置为合适的值,能优化该 prefab 实例化所用的时间。 + !#en + Indicates the optimization policy for instantiating this prefab. + Set to a suitable value based on usage, can optimize the time it takes to instantiate this prefab. */ + optimizationPolicy: Prefab.OptimizationPolicy; + /** !#en Indicates the raw assets of this prefab can be load after prefab loaded. + !#zh 指示该 Prefab 依赖的资源可否在 Prefab 加载后再延迟加载。 */ + asyncLoadAssets: boolean; + readonly: boolean; + /** + Dynamically translation prefab data into minimized code.
+ This method will be called automatically before the first time the prefab being instantiated, + but you can re-call to refresh the create function once you modified the original prefab data in script. + */ + compileCreateFunction(): void; + } + /** !#en + The base class for registering asset types. + !#zh + 注册用的资源基类。 */ + export class RawAsset extends Object { + } + /** Render textures are textures that can be rendered to. */ + export class RenderTexture extends Texture2D { + /** + !#en + Init the render texture with size. + !#zh + 初始化 render texture + @param width width + @param height height + @param depthStencilFormat depthStencilFormat + */ + initWithSize(width?: number, height?: number, depthStencilFormat?: number): void; + /** + !#en + Get pixels from render texture, the pixels data stores in a RGBA Uint8Array. + It will return a new (width * height * 4) length Uint8Array by default。 + You can specify a data to store the pixels to reuse the data, + you and can specify other params to specify the texture region to read. + !#zh + 从 render texture 读取像素数据,数据类型为 RGBA 格式的 Uint8Array 数组。 + 默认每次调用此函数会生成一个大小为 (长 x 高 x 4) 的 Uint8Array。 + 你可以通过传入 data 来接收像素数据,也可以通过传参来指定需要读取的区域的像素。 + @param data data + @param x x + @param y y + @param w w + @param h h + */ + readPixels(data?: Uint8Array, x?: number, y?: number, w?: number, h?: number): Uint8Array; + } + /** !#en Class for scene handling. + !#zh 场景资源类。 */ + export class SceneAsset extends Asset { + scene: Scene; + /** !#en Indicates the raw assets of this scene can be load after scene launched. + !#zh 指示该场景依赖的资源可否在场景切换后再延迟加载。 */ + asyncLoadAssets: boolean; + } + /** !#en Class for script handling. + !#zh Script 资源类。 */ + export class _Script extends Asset { + } + /** !#en Class for JavaScript handling. + !#zh JavaScript 资源类。 */ + export class _JavaScript extends Asset { + } + /** !#en Class for coffeescript handling. + !#zh CoffeeScript 资源类。 */ + export class CoffeeScript extends Asset { + } + /** !#en Class for TypeScript handling. + !#zh TypeScript 资源类。 */ + export class TypeScript extends Asset { + } + /** !#en Class for sprite atlas handling. + !#zh 精灵图集资源类。 */ + export class SpriteAtlas extends Asset { + /** + Returns the texture of the sprite atlas + */ + getTexture(): Texture2D; + /** + Returns the sprite frame correspond to the given key in sprite atlas. + @param key key + */ + getSpriteFrame(key: string): SpriteFrame; + /** + Returns the sprite frames in sprite atlas. + */ + getSpriteFrames(): SpriteFrame[]; + } + /** !#en + A cc.SpriteFrame has:
+ - texture: A cc.Texture2D that will be used by render components
+ - rectangle: A rectangle of the texture + + !#zh + 一个 SpriteFrame 包含:
+ - 纹理:会被渲染组件使用的 Texture2D 对象。
+ - 矩形:在纹理中的矩形区域。 */ + export class SpriteFrame extends Asset implements EventTarget { + /** !#en Top border of the sprite + !#zh sprite 的顶部边框 */ + insetTop: number; + /** !#en Bottom border of the sprite + !#zh sprite 的底部边框 */ + insetBottom: number; + /** !#en Left border of the sprite + !#zh sprite 的左边边框 */ + insetLeft: number; + /** !#en Right border of the sprite + !#zh sprite 的左边边框 */ + insetRight: number; + /** + !#en + Constructor of SpriteFrame class. + !#zh + SpriteFrame 类的构造函数。 + @param filename filename + @param rect rect + @param rotated Whether the frame is rotated in the texture + @param offset The offset of the frame in the texture + @param originalSize The size of the frame in the texture + */ + constructor(filename?: string|Texture2D, rect?: Rect, rotated?: boolean, offset?: Vec2, originalSize?: Size); + /** + !#en Returns whether the texture have been loaded + !#zh 返回是否已加载纹理 + */ + textureLoaded(): boolean; + /** + !#en Returns whether the sprite frame is rotated in the texture. + !#zh 获取 SpriteFrame 是否旋转 + */ + isRotated(): boolean; + /** + !#en Set whether the sprite frame is rotated in the texture. + !#zh 设置 SpriteFrame 是否旋转 + @param bRotated bRotated + */ + setRotated(bRotated: boolean): void; + /** + !#en Returns whether the sprite frame is flip x axis in the texture. + !#zh 获取 SpriteFrame 是否反转 x 轴 + */ + isFlipX(): boolean; + /** + !#en Returns whether the sprite frame is flip y axis in the texture. + !#zh 获取 SpriteFrame 是否反转 y 轴 + */ + isFlipY(): boolean; + /** + !#en Set whether the sprite frame is flip x axis in the texture. + !#zh 设置 SpriteFrame 是否翻转 x 轴 + @param flipX flipX + */ + setFlipX(flipX: boolean): void; + /** + !#en Set whether the sprite frame is flip y axis in the texture. + !#zh 设置 SpriteFrame 是否翻转 y 轴 + @param flipY flipY + */ + setFlipY(flipY: boolean): void; + /** + !#en Returns the rect of the sprite frame in the texture. + !#zh 获取 SpriteFrame 的纹理矩形区域 + */ + getRect(): Rect; + /** + !#en Sets the rect of the sprite frame in the texture. + !#zh 设置 SpriteFrame 的纹理矩形区域 + @param rect rect + */ + setRect(rect: Rect): void; + /** + !#en Returns the original size of the trimmed image. + !#zh 获取修剪前的原始大小 + */ + getOriginalSize(): Size; + /** + !#en Sets the original size of the trimmed image. + !#zh 设置修剪前的原始大小 + @param size size + */ + setOriginalSize(size: Size): void; + /** + !#en Returns the texture of the frame. + !#zh 获取使用的纹理实例 + */ + getTexture(): Texture2D; + /** + !#en Returns the offset of the frame in the texture. + !#zh 获取偏移量 + */ + getOffset(): Vec2; + /** + !#en Sets the offset of the frame in the texture. + !#zh 设置偏移量 + @param offsets offsets + */ + setOffset(offsets: Vec2): void; + /** + !#en Clone the sprite frame. + !#zh 克隆 SpriteFrame + */ + clone(): SpriteFrame; + /** + !#en Set SpriteFrame with Texture, rect, rotated, offset and originalSize.
+ !#zh 通过 Texture,rect,rotated,offset 和 originalSize 设置 SpriteFrame。 + @param textureOrTextureFile textureOrTextureFile + @param rect rect + @param rotated rotated + @param offset offset + @param originalSize originalSize + */ + setTexture(textureOrTextureFile: string|Texture2D, rect?: Rect, rotated?: boolean, offset?: Vec2, originalSize?: Size): boolean; + /** + !#en If a loading scene (or prefab) is marked as `asyncLoadAssets`, all the textures of the SpriteFrame which + associated by user's custom Components in the scene, will not preload automatically. + These textures will be load when Sprite component is going to render the SpriteFrames. + You can call this method if you want to load the texture early. + !#zh 当加载中的场景或 Prefab 被标记为 `asyncLoadAssets` 时,用户在场景中由自定义组件关联到的所有 SpriteFrame 的贴图都不会被提前加载。 + 只有当 Sprite 组件要渲染这些 SpriteFrame 时,才会检查贴图是否加载。如果你希望加载过程提前,你可以手工调用这个方法。 + + @example + ```js + if (spriteFrame.textureLoaded()) { + this._onSpriteFrameLoaded(); + } + else { + spriteFrame.once('load', this._onSpriteFrameLoaded, this); + spriteFrame.ensureLoadTexture(); + } + ``` + */ + ensureLoadTexture(): void; + /** + !#en + If you do not need to use the SpriteFrame temporarily, you can call this method so that its texture could be garbage collected. Then when you need to render the SpriteFrame, you should call `ensureLoadTexture` manually to reload texture. + !#zh + 当你暂时不再使用这个 SpriteFrame 时,可以调用这个方法来保证引用的贴图对象能被 GC。然后当你要渲染 SpriteFrame 时,你需要手动调用 `ensureLoadTexture` 来重新加载贴图。 + */ + clearTexture(): void; + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en + Register an callback of a specific event type on the EventTarget. + This type of event should be triggered via `emit`. + !#zh + 注册事件目标的特定事件类型回调。这种类型的事件应该被 `emit` 触发。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, node); + ``` + */ + on(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. + !#zh + 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + + @example + ```js + // register fire eventListener + var callback = eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, target); + // remove fire event listener + eventTarget.off('fire', callback, target); + // remove all fire event listeners + eventTarget.off('fire'); + ``` + */ + off(type: string, callback?: Function, target?: any): void; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.once('fire', function () { + cc.log("this is the callback and will be invoked only once"); + }, node); + ``` + */ + once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; + /** + !#en + Send an event with the event object. + !#zh + 通过事件对象派发事件 + @param event event + */ + dispatchEvent(event: Event): void; + } + /** !#en Class for TTFFont handling. + !#zh TTF 字体资源类。 */ + export class TTFFont extends Font { + } + /** !#en Class for text file. + !#zh 文本资源类。 */ + export class TextAsset extends Asset { + /** The text contents of the resource. */ + text: string; + } + /** This class allows to easily create OpenGL or Canvas 2D textures from images or raw data. */ + export class Texture2D extends Asset implements EventTarget { + /** !#en Sets whether generate mipmaps for the texture + !#zh 是否为纹理设置生成 mipmaps。 */ + genMipmaps: boolean; + /** !#en + Sets whether texture can be packed into texture atlas. + If need use texture uv in custom Effect, please sets packable to false. + !#zh + 设置纹理是否允许参与合图。 + 如果需要在自定义 Effect 中使用纹理 UV,需要禁止该选项。 */ + packable: boolean; + /** !#en + Whether the texture is loaded or not + !#zh + 贴图是否已经成功加载 */ + loaded: boolean; + /** !#en + Texture width in pixel + !#zh + 贴图像素宽度 */ + width: number; + /** !#en + Texture height in pixel + !#zh + 贴图像素高度 */ + height: number; + /** + !#en + Get renderer texture implementation object + extended from render.Texture2D + !#zh 返回渲染器内部贴图对象 + */ + getImpl(): void; + /** + Update texture options, not available in Canvas render mode. + image, format, premultiplyAlpha can not be updated in native. + @param options options + */ + update(options: {image: DOMImageElement; genMipmaps: boolean; format: Texture2D.PixelFormat; minFilter: Texture2D.Filter; magFilter: Texture2D.Filter; wrapS: WrapMode; wrapT: WrapMode; premultiplyAlpha: boolean; }): void; + /** + !#en + Init with HTML element. + !#zh 用 HTML Image 或 Canvas 对象初始化贴图。 + @param element element + + @example + ```js + var img = new Image(); + img.src = dataURL; + texture.initWithElement(img); + ``` + */ + initWithElement(element: HTMLImageElement|HTMLCanvasElement): void; + /** + !#en + Intializes with a texture2d with data in Uint8Array. + !#zh 使用一个存储在 Unit8Array 中的图像数据(raw data)初始化数据。 + @param data data + @param pixelFormat pixelFormat + @param pixelsWidth pixelsWidth + @param pixelsHeight pixelsHeight + */ + initWithData(data: DataView, pixelFormat: number, pixelsWidth: number, pixelsHeight: number): boolean; + /** + !#en + HTMLElement Object getter, available only on web.
+ Note: texture is packed into texture atlas by default
+ you should set texture.packable as false before getting Html element object. + !#zh 获取当前贴图对应的 HTML Image 或 Canvas 对象,只在 Web 平台下有效。
+ 注意:
+ texture 默认参与动态合图,如果需要获取到正确的 Html 元素对象,需要先设置 texture.packable 为 false + */ + getHtmlElementObj(): HTMLImageElement; + /** + !#en + Destory this texture and immediately release its video memory. (Inherit from cc.Object.destroy)
+ After destroy, this object is not usable any more. + You can use cc.isValid(obj) to check whether the object is destroyed before accessing it. + !#zh + 销毁该贴图,并立即释放它对应的显存。(继承自 cc.Object.destroy)
+ 销毁后,该对象不再可用。您可以在访问对象之前使用 cc.isValid(obj) 来检查对象是否已被销毁。 + */ + destroy(): boolean; + /** + !#en + Pixel format of the texture. + !#zh 获取纹理的像素格式。 + */ + getPixelFormat(): number; + /** + !#en + Whether or not the texture has their Alpha premultiplied. + !#zh 检查纹理在上传 GPU 时预乘选项是否开启。 + */ + hasPremultipliedAlpha(): boolean; + /** + !#en + Handler of texture loaded event. + Since v2.0, you don't need to invoke this function, it will be invoked automatically after texture loaded. + !#zh 贴图加载事件处理器。v2.0 之后你将不在需要手动执行这个函数,它会在贴图加载成功之后自动执行。 + @param premultiplied premultiplied + */ + handleLoadedTexture(premultiplied?: boolean): void; + /** + !#en + Description of cc.Texture2D. + !#zh cc.Texture2D 描述。 + */ + description(): string; + /** + !#en + Release texture, please use destroy instead. + !#zh 释放纹理,请使用 destroy 替代。 + */ + releaseTexture(): void; + /** + !#en Sets the wrap s and wrap t options.
+ If the texture size is NPOT (non power of 2), then in can only use gl.CLAMP_TO_EDGE in gl.TEXTURE_WRAP_{S,T}. + !#zh 设置纹理包装模式。 + 若纹理贴图尺寸是 NPOT(non power of 2),则只能使用 Texture2D.WrapMode.CLAMP_TO_EDGE。 + @param wrapS wrapS + @param wrapT wrapT + */ + setTexParameters(wrapS: Texture2D.WrapMode, wrapT: Texture2D.WrapMode): void; + /** + !#en Sets the minFilter and magFilter options + !#zh 设置纹理贴图缩小和放大过滤器算法选项。 + @param minFilter minFilter + @param magFilter magFilter + */ + setFilters(minFilter: Texture2D.Filter, magFilter: Texture2D.Filter): void; + /** + !#en + Sets the flipY options + !#zh 设置贴图的纵向翻转选项。 + @param flipY flipY + */ + setFlipY(flipY: boolean): void; + /** + !#en + Sets the premultiply alpha options + !#zh 设置贴图的预乘选项。 + @param premultiply premultiply + */ + setPremultiplyAlpha(premultiply: boolean): void; + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en + Register an callback of a specific event type on the EventTarget. + This type of event should be triggered via `emit`. + !#zh + 注册事件目标的特定事件类型回调。这种类型的事件应该被 `emit` 触发。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, node); + ``` + */ + on(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. + !#zh + 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + + @example + ```js + // register fire eventListener + var callback = eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, target); + // remove fire event listener + eventTarget.off('fire', callback, target); + // remove all fire event listeners + eventTarget.off('fire'); + ``` + */ + off(type: string, callback?: Function, target?: any): void; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.once('fire', function () { + cc.log("this is the callback and will be invoked only once"); + }, node); + ``` + */ + once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; + /** + !#en + Send an event with the event object. + !#zh + 通过事件对象派发事件 + @param event event + */ + dispatchEvent(event: Event): void; + } + /** !#en The touch event class + !#zh 封装了触摸相关的信息。 */ + export class Touch { + /** + !#en Returns the current touch location in OpenGL coordinates.、 + !#zh 获取当前触点位置。 + */ + getLocation(): Vec2; + /** + !#en Returns X axis location value. + !#zh 获取当前触点 X 轴位置。 + */ + getLocationX(): number; + /** + !#en Returns Y axis location value. + !#zh 获取当前触点 Y 轴位置。 + */ + getLocationY(): number; + /** + !#en Returns the previous touch location in OpenGL coordinates. + !#zh 获取触点在上一次事件时的位置对象,对象包含 x 和 y 属性。 + */ + getPreviousLocation(): Vec2; + /** + !#en Returns the start touch location in OpenGL coordinates. + !#zh 获取触点落下时的位置对象,对象包含 x 和 y 属性。 + */ + getStartLocation(): Vec2; + /** + !#en Returns the delta distance from the previous touche to the current one in screen coordinates. + !#zh 获取触点距离上一次事件移动的距离对象,对象包含 x 和 y 属性。 + */ + getDelta(): Vec2; + /** + !#en Returns the current touch location in screen coordinates. + !#zh 获取当前事件在游戏窗口内的坐标位置对象,对象包含 x 和 y 属性。 + */ + getLocationInView(): Vec2; + /** + !#en Returns the previous touch location in screen coordinates. + !#zh 获取触点在上一次事件时在游戏窗口中的位置对象,对象包含 x 和 y 属性。 + */ + getPreviousLocationInView(): Vec2; + /** + !#en Returns the start touch location in screen coordinates. + !#zh 获取触点落下时在游戏窗口中的位置对象,对象包含 x 和 y 属性。 + */ + getStartLocationInView(): Vec2; + /** + !#en Returns the id of cc.Touch. + !#zh 触点的标识 ID,可以用来在多点触摸中跟踪触点。 + */ + getID(): number; + /** + !#en Sets information to touch. + !#zh 设置触摸相关的信息。用于监控触摸事件。 + @param id id + @param x x + @param y y + */ + setTouchInfo(id: number, x: number, y: number): void; + } + /** !#en Base class of all kinds of events. + !#zh 包含事件相关信息的对象。 */ + export class Event { + /** + + @param type The name of the event (case-sensitive), e.g. "click", "fire", or "submit" + @param bubbles A boolean indicating whether the event bubbles up through the tree or not + */ + constructor(type: string, bubbles: boolean); + /** !#en The name of the event (case-sensitive), e.g. "click", "fire", or "submit". + !#zh 事件类型。 */ + type: string; + /** !#en Indicate whether the event bubbles up through the tree or not. + !#zh 表示该事件是否进行冒泡。 */ + bubbles: boolean; + /** !#en A reference to the target to which the event was originally dispatched. + !#zh 最初事件触发的目标 */ + target: any; + /** !#en A reference to the currently registered target for the event. + !#zh 当前目标 */ + currentTarget: any; + /** !#en + Indicates which phase of the event flow is currently being evaluated. + Returns an integer value represented by 4 constants: + - Event.NONE = 0 + - Event.CAPTURING_PHASE = 1 + - Event.AT_TARGET = 2 + - Event.BUBBLING_PHASE = 3 + The phases are explained in the [section 3.1, Event dispatch and DOM event flow] + (http://www.w3.org/TR/DOM-Level-3-Events/#event-flow), of the DOM Level 3 Events specification. + !#zh 事件阶段 */ + eventPhase: number; + /** + !#en Reset the event for being stored in the object pool. + !#zh 重置对象池中存储的事件。 + */ + unuse(): string; + /** + !#en Reuse the event for being used again by the object pool. + !#zh 用于对象池再次使用的事件。 + */ + reuse(): string; + /** + !#en Stops propagation for current event. + !#zh 停止传递当前事件。 + */ + stopPropagation(): void; + /** + !#en Stops propagation for current event immediately, + the event won't even be dispatched to the listeners attached in the current target. + !#zh 立即停止当前事件的传递,事件甚至不会被分派到所连接的当前目标。 + */ + stopPropagationImmediate(): void; + /** + !#en Checks whether the event has been stopped. + !#zh 检查该事件是否已经停止传递. + */ + isStopped(): boolean; + /** + !#en +

+ Gets current target of the event
+ note: It only be available when the event listener is associated with node.
+ It returns 0 when the listener is associated with fixed priority. +

+ !#zh 获取当前目标节点 + */ + getCurrentTarget(): Node; + /** + !#en Gets the event type. + !#zh 获取事件类型 + */ + getType(): string; + /** !#en Code for event without type. + !#zh 没有类型的事件 */ + static NO_TYPE: string; + /** !#en The type code of Touch event. + !#zh 触摸事件类型 */ + static TOUCH: string; + /** !#en The type code of Mouse event. + !#zh 鼠标事件类型 */ + static MOUSE: string; + /** !#en The type code of Keyboard event. + !#zh 键盘事件类型 */ + static KEYBOARD: string; + /** !#en The type code of Acceleration event. + !#zh 加速器事件类型 */ + static ACCELERATION: string; + /** !#en Events not currently dispatched are in this phase + !#zh 尚未派发事件阶段 */ + static NONE: number; + /** !#en + The capturing phase comprises the journey from the root to the last node before the event target's node + see http://www.w3.org/TR/DOM-Level-3-Events/#event-flow + !#zh 捕获阶段,包括事件目标节点之前从根节点到最后一个节点的过程。 */ + static CAPTURING_PHASE: number; + /** !#en + The target phase comprises only the event target node + see http://www.w3.org/TR/DOM-Level-3-Events/#event-flow + !#zh 目标阶段仅包括事件目标节点。 */ + static AT_TARGET: number; + /** !#en + The bubbling phase comprises any subsequent nodes encountered on the return trip to the root of the hierarchy + see http://www.w3.org/TR/DOM-Level-3-Events/#event-flow + !#zh 冒泡阶段, 包括回程遇到到层次根节点的任何后续节点。 */ + static BUBBLING_PHASE: number; + } + /** !#en + EventTarget is an object to which an event is dispatched when something has occurred. + Entity are the most common event targets, but other objects can be event targets too. + + Event targets are an important part of the Fireball event model. + The event target serves as the focal point for how events flow through the scene graph. + When an event such as a mouse click or a keypress occurs, Fireball dispatches an event object + into the event flow from the root of the hierarchy. The event object then makes its way through + the scene graph until it reaches the event target, at which point it begins its return trip through + the scene graph. This round-trip journey to the event target is conceptually divided into three phases: + - The capture phase comprises the journey from the root to the last node before the event target's node + - The target phase comprises only the event target node + - The bubbling phase comprises any subsequent nodes encountered on the return trip to the root of the tree + See also: http://www.w3.org/TR/DOM-Level-3-Events/#event-flow + + Event targets can implement the following methods: + - _getCapturingTargets + - _getBubblingTargets + + !#zh + 事件目标是事件触发时,分派的事件对象,Node 是最常见的事件目标, + 但是其他对象也可以是事件目标。
*/ + export class EventTarget extends CallbacksInvoker { + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en + Register an callback of a specific event type on the EventTarget. + This type of event should be triggered via `emit`. + !#zh + 注册事件目标的特定事件类型回调。这种类型的事件应该被 `emit` 触发。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, node); + ``` + */ + on(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. + !#zh + 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + + @example + ```js + // register fire eventListener + var callback = eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, target); + // remove fire event listener + eventTarget.off('fire', callback, target); + // remove all fire event listeners + eventTarget.off('fire'); + ``` + */ + off(type: string, callback?: Function, target?: any): void; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.once('fire', function () { + cc.log("this is the callback and will be invoked only once"); + }, node); + ``` + */ + once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; + /** + !#en + Send an event with the event object. + !#zh + 通过事件对象派发事件 + @param event event + */ + dispatchEvent(event: Event): void; + } + /** !#en + The System event, it currently supports keyboard events and accelerometer events.
+ You can get the SystemEvent instance with cc.systemEvent.
+ !#zh + 系统事件,它目前支持按键事件和重力感应事件。
+ 你可以通过 cc.systemEvent 获取到 SystemEvent 的实例。
*/ + export class SystemEvent extends EventTarget { + /** + !#en whether enable accelerometer event + !#zh 是否启用加速度计事件 + @param isEnable isEnable + */ + setAccelerometerEnabled(isEnable: boolean): void; + /** + !#en set accelerometer interval value + !#zh 设置加速度计间隔值 + @param interval interval + */ + setAccelerometerInterval(interval: number): void; + } + /** !#en The animation component is used to play back animations. + + Animation provide several events to register: + - play : Emit when begin playing animation + - stop : Emit when stop playing animation + - pause : Emit when pause animation + - resume : Emit when resume animation + - lastframe : If animation repeat count is larger than 1, emit when animation play to the last frame + - finished : Emit when finish playing animation + + !#zh Animation 组件用于播放动画。 + + Animation 提供了一系列可注册的事件: + - play : 开始播放时 + - stop : 停止播放时 + - pause : 暂停播放时 + - resume : 恢复播放时 + - lastframe : 假如动画循环次数大于 1,当动画播放到最后一帧时 + - finished : 动画播放完成时 */ + export class Animation extends Component implements EventTarget { + /** !#en Animation will play the default clip when start game. + !#zh 在勾选自动播放或调用 play() 时默认播放的动画剪辑。 */ + defaultClip: AnimationClip; + /** !#en Current played clip. + !#zh 当前播放的动画剪辑。 */ + currentClip: AnimationClip; + /** !#en Whether the animation should auto play the default clip when start game. + !#zh 是否在运行游戏后自动播放默认动画剪辑。 */ + playOnLoad: boolean; + /** + !#en Get all the clips used in this animation. + !#zh 获取动画组件上的所有动画剪辑。 + */ + getClips(): AnimationClip[]; + /** + !#en Plays an animation and stop other animations. + !#zh 播放指定的动画,并且停止当前正在播放动画。如果没有指定动画,则播放默认动画。 + @param name The name of animation to play. If no name is supplied then the default animation will be played. + @param startTime play an animation from startTime + + @example + ```js + var animCtrl = this.node.getComponent(cc.Animation); + animCtrl.play("linear"); + ``` + */ + play(name?: string, startTime?: number): AnimationState; + /** + !#en + Plays an additive animation, it will not stop other animations. + If there are other animations playing, then will play several animations at the same time. + !#zh 播放指定的动画(将不会停止当前播放的动画)。如果没有指定动画,则播放默认动画。 + @param name The name of animation to play. If no name is supplied then the default animation will be played. + @param startTime play an animation from startTime + + @example + ```js + // linear_1 and linear_2 at the same time playing. + var animCtrl = this.node.getComponent(cc.Animation); + animCtrl.playAdditive("linear_1"); + animCtrl.playAdditive("linear_2"); + ``` + */ + playAdditive(name?: string, startTime?: number): AnimationState; + /** + !#en Stops an animation named name. If no name is supplied then stops all playing animations that were started with this Animation.
+ Stopping an animation also Rewinds it to the Start. + !#zh 停止指定的动画。如果没有指定名字,则停止当前正在播放的动画。 + @param name The animation to stop, if not supplied then stops all playing animations. + */ + stop(name?: string): void; + /** + !#en Pauses an animation named name. If no name is supplied then pauses all playing animations that were started with this Animation. + !#zh 暂停当前或者指定的动画。如果没有指定名字,则暂停当前正在播放的动画。 + @param name The animation to pauses, if not supplied then pauses all playing animations. + */ + pause(name?: string): void; + /** + !#en Resumes an animation named name. If no name is supplied then resumes all paused animations that were started with this Animation. + !#zh 重新播放指定的动画,如果没有指定名字,则重新播放当前正在播放的动画。 + @param name The animation to resumes, if not supplied then resumes all paused animations. + */ + resume(name?: string): void; + /** + !#en Make an animation named name go to the specified time. If no name is supplied then make all animations go to the specified time. + !#zh 设置指定动画的播放时间。如果没有指定名字,则设置当前播放动画的播放时间。 + @param time The time to go to + @param name Specified animation name, if not supplied then make all animations go to the time. + */ + setCurrentTime(time?: number, name?: string): void; + /** + !#en Returns the animation state named name. If no animation with the specified name, the function will return null. + !#zh 获取当前或者指定的动画状态,如果未找到指定动画剪辑则返回 null。 + @param name name + */ + getAnimationState(name: string): AnimationState; + /** + !#en Adds a clip to the animation with name newName. If a clip with that name already exists it will be replaced with the new clip. + !#zh 添加动画剪辑,并且可以重新设置该动画剪辑的名称。 + @param clip the clip to add + @param newName newName + */ + addClip(clip: AnimationClip, newName?: string): AnimationState; + /** + !#en + Remove clip from the animation list. This will remove the clip and any animation states based on it. + If there are animation states depand on the clip are playing or clip is defaultClip, it will not delete the clip. + But if force is true, then will always remove the clip and any animation states based on it. If clip is defaultClip, defaultClip will be reset to null + !#zh + 从动画列表中移除指定的动画剪辑,
+ 如果依赖于 clip 的 AnimationState 正在播放或者 clip 是 defaultClip 的话,默认是不会删除 clip 的。 + 但是如果 force 参数为 true,则会强制停止该动画,然后移除该动画剪辑和相关的动画。这时候如果 clip 是 defaultClip,defaultClip 将会被重置为 null。 + @param clip clip + @param force If force is true, then will always remove the clip and any animation states based on it. + */ + removeClip(clip: AnimationClip, force?: boolean): void; + /** + !#en + Samples animations at the current state.
+ This is useful when you explicitly want to set up some animation state, and sample it once. + !#zh 对指定或当前动画进行采样。你可以手动将动画设置到某一个状态,然后采样一次。 + @param name name + */ + sample(name: string): void; + /** + !#en + Register animation event callback. + The event arguments will provide the AnimationState which emit the event. + When play an animation, will auto register the event callback to the AnimationState, and unregister the event callback from the AnimationState when animation stopped. + !#zh + 注册动画事件回调。 + 回调的事件里将会附上发送事件的 AnimationState。 + 当播放一个动画时,会自动将事件注册到对应的 AnimationState 上,停止播放时会将事件从这个 AnimationState 上取消注册。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param state state + @param target The target (this object) to invoke the callback, can be null + @param useCapture When set to true, the capture argument prevents callback + from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. + When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE. + Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET. + + @example + ```js + onPlay: function (type, state) { + // callback + } + + // register event to all animation + animation.on('play', this.onPlay, this); + ``` + */ + on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void; + on(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void; + /** + !#en + Unregister animation event callback. + !#zh + 取消注册动画事件回调。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not. + If not specified, useCapture defaults to false. If a callback was registered twice, + one with capture and one without, each must be removed separately. Removal of a capturing callback + does not affect a non-capturing version of the same listener, and vice versa. + + @example + ```js + // unregister event to all animation + animation.off('play', this.onPlay, this); + ``` + */ + off(type: string, callback?: Function, target?: any, useCapture?: boolean): void; + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.once('fire', function () { + cc.log("this is the callback and will be invoked only once"); + }, node); + ``` + */ + once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; + /** + !#en + Send an event with the event object. + !#zh + 通过事件对象派发事件 + @param event event + */ + dispatchEvent(event: Event): void; + } + /** !#en Audio Source. + !#zh 音频源组件,能对音频剪辑。 */ + export class AudioSource extends Component { + /** !#en + Is the audio source playing (Read Only).
+ Note: isPlaying is not supported for Native platforms. + !#zh + 该音频剪辑是否正播放(只读)。
+ 注意:Native 平台暂时不支持 isPlaying。 */ + isPlaying: boolean; + /** !#en The clip of the audio source to play. + !#zh 要播放的音频剪辑。 */ + clip: AudioClip; + /** !#en The volume of the audio source. + !#zh 音频源的音量(0.0 ~ 1.0)。 */ + volume: number; + /** !#en Is the audio source mute? + !#zh 是否静音音频源。Mute 是设置音量为 0,取消静音是恢复原来的音量。 */ + mute: boolean; + /** !#en Is the audio source looping? + !#zh 音频源是否循环播放? */ + loop: boolean; + /** !#en If set to true, the audio source will automatically start playing on onEnable. + !#zh 如果设置为 true,音频源将在 onEnable 时自动播放。 */ + playOnLoad: boolean; + /** + !#en Plays the clip. + !#zh 播放音频剪辑。 + */ + play(): void; + /** + !#en Stops the clip. + !#zh 停止当前音频剪辑。 + */ + stop(): void; + /** + !#en Pause the clip. + !#zh 暂停当前音频剪辑。 + */ + pause(): void; + /** + !#en Resume the clip. + !#zh 恢复播放。 + */ + resume(): void; + /** + !#en Rewind playing music. + !#zh 从头开始播放。 + */ + rewind(): void; + /** + !#en Get current time + !#zh 获取当前的播放时间 + */ + getCurrentTime(): number; + /** + !#en Set current time + !#zh 设置当前的播放时间 + @param time time + */ + setCurrentTime(time: number): number; + /** + !#en Get audio duration + !#zh 获取当前音频的长度 + */ + getDuration(): number; + } + /** !#en + This component will block all input events (mouse and touch) within the bounding box of the node, preventing the input from penetrating into the underlying node, typically for the background of the top UI.
+ This component does not have any API interface and can be added directly to the scene to take effect. + !#zh + 该组件将拦截所属节点 bounding box 内的所有输入事件(鼠标和触摸),防止输入穿透到下层节点,一般用于上层 UI 的背景。
+ 该组件没有任何 API 接口,直接添加到场景即可生效。 */ + export class BlockInputEvents extends Component { + } + /** !#en + Button has 4 Transition types
+ When Button state changed:
+ If Transition type is Button.Transition.NONE, Button will do nothing
+ If Transition type is Button.Transition.COLOR, Button will change target's color
+ If Transition type is Button.Transition.SPRITE, Button will change target Sprite's sprite
+ If Transition type is Button.Transition.SCALE, Button will change target node's scale
+ + Button will trigger 5 events:
+ Button.EVENT_TOUCH_DOWN
+ Button.EVENT_TOUCH_UP
+ Button.EVENT_HOVER_IN
+ Button.EVENT_HOVER_MOVE
+ Button.EVENT_HOVER_OUT
+ User can get the current clicked node with 'event.target' from event object which is passed as parameter in the callback function of click event. + + !#zh + 按钮组件。可以被按下,或者点击。 + + 按钮可以通过修改 Transition 来设置按钮状态过渡的方式: + + - Button.Transition.NONE // 不做任何过渡 + - Button.Transition.COLOR // 进行颜色之间过渡 + - Button.Transition.SPRITE // 进行精灵之间过渡 + - Button.Transition.SCALE // 进行缩放过渡 + + 按钮可以绑定事件(但是必须要在按钮的 Node 上才能绑定事件):
+ 以下事件可以在全平台上都触发: + + - cc.Node.EventType.TOUCH_START // 按下时事件 + - cc.Node.EventType.TOUCH_Move // 按住移动后事件 + - cc.Node.EventType.TOUCH_END // 按下后松开后事件 + - cc.Node.EventType.TOUCH_CANCEL // 按下取消事件 + + 以下事件只在 PC 平台上触发: + + - cc.Node.EventType.MOUSE_DOWN // 鼠标按下时事件 + - cc.Node.EventType.MOUSE_MOVE // 鼠标按住移动后事件 + - cc.Node.EventType.MOUSE_ENTER // 鼠标进入目标事件 + - cc.Node.EventType.MOUSE_LEAVE // 鼠标离开目标事件 + - cc.Node.EventType.MOUSE_UP // 鼠标松开事件 + - cc.Node.EventType.MOUSE_WHEEL // 鼠标滚轮事件 + + 用户可以通过获取 __点击事件__ 回调函数的参数 event 的 target 属性获取当前点击对象。 */ + export class Button extends Component implements GraySpriteState { + /** !#en + Whether the Button is disabled. + If true, the Button will trigger event and do transition. + !#zh + 按钮事件是否被响应,如果为 false,则按钮将被禁用。 */ + interactable: boolean; + /** !#en When this flag is true, Button target sprite will turn gray when interactable is false. + !#zh 如果这个标记为 true,当 button 的 interactable 属性为 false 的时候,会使用内置 shader 让 button 的 target 节点的 sprite 组件变灰 */ + enableAutoGrayEffect: boolean; + /** !#en Transition type + !#zh 按钮状态改变时过渡方式。 */ + transition: Button.Transition; + /** !#en Normal state color. + !#zh 普通状态下按钮所显示的颜色。 */ + normalColor: Color; + /** !#en Pressed state color + !#zh 按下状态时按钮所显示的颜色。 */ + pressedColor: Color; + /** !#en Hover state color + !#zh 悬停状态下按钮所显示的颜色。 */ + hoverColor: Color; + /** !#en Disabled state color + !#zh 禁用状态下按钮所显示的颜色。 */ + disabledColor: Color; + /** !#en Color and Scale transition duration + !#zh 颜色过渡和缩放过渡时所需时间 */ + duration: number; + /** !#en When user press the button, the button will zoom to a scale. + The final scale of the button equals (button original scale * zoomScale) + !#zh 当用户点击按钮后,按钮会缩放到一个值,这个值等于 Button 原始 scale * zoomScale */ + zoomScale: number; + /** !#en Normal state sprite + !#zh 普通状态下按钮所显示的 Sprite 。 */ + normalSprite: SpriteFrame; + /** !#en Pressed state sprite + !#zh 按下状态时按钮所显示的 Sprite 。 */ + pressedSprite: SpriteFrame; + /** !#en Hover state sprite + !#zh 悬停状态下按钮所显示的 Sprite 。 */ + hoverSprite: SpriteFrame; + /** !#en Disabled state sprite + !#zh 禁用状态下按钮所显示的 Sprite 。 */ + disabledSprite: SpriteFrame; + /** !#en + Transition target. + When Button state changed: + If Transition type is Button.Transition.NONE, Button will do nothing + If Transition type is Button.Transition.COLOR, Button will change target's color + If Transition type is Button.Transition.SPRITE, Button will change target Sprite's sprite + !#zh + 需要过渡的目标。 + 当前按钮状态改变规则: + -如果 Transition type 选择 Button.Transition.NONE,按钮不做任何过渡。 + -如果 Transition type 选择 Button.Transition.COLOR,按钮会对目标颜色进行颜色之间的过渡。 + -如果 Transition type 选择 Button.Transition.Sprite,按钮会对目标 Sprite 进行 Sprite 之间的过渡。 */ + target: Node; + /** !#en If Button is clicked, it will trigger event's handler + !#zh 按钮的点击事件列表。 */ + clickEvents: Component.EventHandler[]; + /** !#en The normal material. + !#zh 正常状态的材质。 */ + normalMaterial: Material; + /** !#en The gray material. + !#zh 置灰状态的材质。 */ + grayMaterial: Material; + } + /** !#zh: 作为 UI 根节点,为所有子节点提供视窗四边的位置信息以供对齐,另外提供屏幕适配策略接口,方便从编辑器设置。 + 注:由于本节点的尺寸会跟随屏幕拉伸,所以 anchorPoint 只支持 (0.5, 0.5),否则适配不同屏幕时坐标会有偏差。 */ + export class Canvas extends Component { + /** !#en Current active canvas, the scene should only have one active canvas at the same time. + !#zh 当前激活的画布组件,场景同一时间只能有一个激活的画布。 */ + static instance: Canvas; + /** !#en The desigin resolution for current scene. + !#zh 当前场景设计分辨率。 */ + designResolution: Size; + /** !#en TODO + !#zh: 是否优先将设计分辨率高度撑满视图高度。 */ + fitHeight: boolean; + /** !#en TODO + !#zh: 是否优先将设计分辨率宽度撑满视图宽度。 */ + fitWidth: boolean; + } + /** !#en + Base class for everything attached to Node(Entity).
+
+ NOTE: Not allowed to use construction parameters for Component's subclasses, + because Component is created by the engine. + !#zh + 所有附加到节点的基类。
+
+ 注意:不允许使用组件的子类构造参数,因为组件是由引擎创建的。 */ + export class Component extends Object { + /** !#en The node this component is attached to. A component is always attached to a node. + !#zh 该组件被附加到的节点。组件总会附加到一个节点。 */ + node: Node; + /** !#en The uuid for editor. + !#zh 组件的 uuid,用于编辑器。 */ + uuid: string; + /** !#en indicates whether this component is enabled or not. + !#zh 表示该组件自身是否启用。 */ + enabled: boolean; + /** !#en indicates whether this component is enabled and its node is also active in the hierarchy. + !#zh 表示该组件是否被启用并且所在的节点也处于激活状态。 */ + enabledInHierarchy: boolean; + /** !#en Returns a value which used to indicate the onLoad get called or not. + !#zh 返回一个值用来判断 onLoad 是否被调用过,不等于 0 时调用过,等于 0 时未调用。 */ + _isOnLoadCalled: number; + /** + !#en Update is called every frame, if the Component is enabled.
+ This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere. + !#zh 如果该组件启用,则每帧调用 update。
+ 该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。 + @param dt the delta time in seconds it took to complete the last frame + */ + protected update(dt: number): void; + /** + !#en LateUpdate is called every frame, if the Component is enabled.
+ This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere. + !#zh 如果该组件启用,则每帧调用 LateUpdate。
+ 该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。 + @param dt the delta time in seconds it took to complete the last frame + */ + protected lateUpdate(dt: number): void; + /** + !#en + When attaching to an active node or its node first activated. + onLoad is always called before any start functions, this allows you to order initialization of scripts.
+ This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere. + !#zh + 当附加到一个激活的节点上或者其节点第一次激活时候调用。onLoad 总是会在任何 start 方法调用前执行,这能用于安排脚本的初始化顺序。
+ 该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。 + */ + protected onLoad(): void; + /** + !#en + Called before all scripts' update if the Component is enabled the first time. + Usually used to initialize some logic which need to be called after all components' `onload` methods called.
+ This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere. + !#zh + 如果该组件第一次启用,则在所有组件的 update 之前调用。通常用于需要在所有组件的 onLoad 初始化完毕后执行的逻辑。
+ 该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。 + */ + protected start(): void; + /** + !#en Called when this component becomes enabled and its node is active.
+ This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere. + !#zh 当该组件被启用,并且它的节点也激活时。
+ 该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。 + */ + protected onEnable(): void; + /** + !#en Called when this component becomes disabled or its node becomes inactive.
+ This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere. + !#zh 当该组件被禁用或节点变为无效时调用。
+ 该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。 + */ + protected onDisable(): void; + /** + !#en Called when this component will be destroyed.
+ This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere. + !#zh 当该组件被销毁时调用
+ 该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。 + */ + protected onDestroy(): void; + protected onFocusInEditor(): void; + protected onLostFocusInEditor(): void; + /** + !#en Called to initialize the component or node’s properties when adding the component the first time or when the Reset command is used. This function is only called in editor. + !#zh 用来初始化组件或节点的一些属性,当该组件被第一次添加到节点上或用户点击了它的 Reset 菜单时调用。这个回调只会在编辑器下调用。 + */ + protected resetInEditor(): void; + /** + !#en Adds a component class to the node. You can also add component to node by passing in the name of the script. + !#zh 向节点添加一个组件类,你还可以通过传入脚本的名称来添加组件。 + @param typeOrClassName the constructor or the class name of the component to add + + @example + ```js + var sprite = node.addComponent(cc.Sprite); + var test = node.addComponent("Test"); + ``` + */ + addComponent(type: {new(): T}): T; + addComponent(className: string): any; + /** + !#en + Returns the component of supplied type if the node has one attached, null if it doesn't.
+ You can also get component in the node by passing in the name of the script. + !#zh + 获取节点上指定类型的组件,如果节点有附加指定类型的组件,则返回,如果没有则为空。
+ 传入参数也可以是脚本的名称。 + @param typeOrClassName typeOrClassName + + @example + ```js + // get sprite component. + var sprite = node.getComponent(cc.Sprite); + // get custom test calss. + var test = node.getComponent("Test"); + ``` + */ + getComponent(type: {prototype: T}): T; + getComponent(className: string): any; + /** + !#en Returns all components of supplied Type in the node. + !#zh 返回节点上指定类型的所有组件。 + @param typeOrClassName typeOrClassName + + @example + ```js + var sprites = node.getComponents(cc.Sprite); + var tests = node.getComponents("Test"); + ``` + */ + getComponents(type: {prototype: T}): T[]; + getComponents(className: string): any[]; + /** + !#en Returns the component of supplied type in any of its children using depth first search. + !#zh 递归查找所有子节点中第一个匹配指定类型的组件。 + @param typeOrClassName typeOrClassName + + @example + ```js + var sprite = node.getComponentInChildren(cc.Sprite); + var Test = node.getComponentInChildren("Test"); + ``` + */ + getComponentInChildren(type: {prototype: T}): T; + getComponentInChildren(className: string): any; + /** + !#en Returns the components of supplied type in self or any of its children using depth first search. + !#zh 递归查找自身或所有子节点中指定类型的组件 + @param typeOrClassName typeOrClassName + + @example + ```js + var sprites = node.getComponentsInChildren(cc.Sprite); + var tests = node.getComponentsInChildren("Test"); + ``` + */ + getComponentsInChildren(type: {prototype: T}): T[]; + getComponentsInChildren(className: string): any[]; + /** + !#en + If the component's bounding box is different from the node's, you can implement this method to supply + a custom axis aligned bounding box (AABB), so the editor's scene view can perform hit test properly. + !#zh + 如果组件的包围盒与节点不同,您可以实现该方法以提供自定义的轴向对齐的包围盒(AABB), + 以便编辑器的场景视图可以正确地执行点选测试。 + @param out_rect the Rect to receive the bounding box + */ + _getLocalBounds(out_rect: Rect): void; + /** + !#en + onRestore is called after the user clicks the Reset item in the Inspector's context menu or performs + an undo operation on this component.
+
+ If the component contains the "internal state", short for "temporary member variables which not included
+ in its CCClass properties", then you may need to implement this function.
+
+ The editor will call the getset accessors of your component to record/restore the component's state
+ for undo/redo operation. However, in extreme cases, it may not works well. Then you should implement
+ this function to manually synchronize your component's "internal states" with its public properties.
+ Once you implement this function, all the getset accessors of your component will not be called when
+ the user performs an undo/redo operation. Which means that only the properties with default value
+ will be recorded or restored by editor.
+
+ Similarly, the editor may failed to reset your component correctly in extreme cases. Then if you need
+ to support the reset menu, you should manually synchronize your component's "internal states" with its
+ properties in this function. Once you implement this function, all the getset accessors of your component
+ will not be called during reset operation. Which means that only the properties with default value
+ will be reset by editor. + + This function is only called in editor mode. + !#zh + onRestore 是用户在检查器菜单点击 Reset 时,对此组件执行撤消操作后调用的。
+
+ 如果组件包含了“内部状态”(不在 CCClass 属性中定义的临时成员变量),那么你可能需要实现该方法。
+
+ 编辑器执行撤销/重做操作时,将调用组件的 get set 来录制和还原组件的状态。 + 然而,在极端的情况下,它可能无法良好运作。
+ 那么你就应该实现这个方法,手动根据组件的属性同步“内部状态”。 + 一旦你实现这个方法,当用户撤销或重做时,组件的所有 get set 都不会再被调用。 + 这意味着仅仅指定了默认值的属性将被编辑器记录和还原。
+
+ 同样的,编辑可能无法在极端情况下正确地重置您的组件。
+ 于是如果你需要支持组件重置菜单,你需要在该方法中手工同步组件属性到“内部状态”。
+ 一旦你实现这个方法,组件的所有 get set 都不会在重置操作时被调用。 + 这意味着仅仅指定了默认值的属性将被编辑器重置。 +
+ 此方法仅在编辑器下会被调用。 + */ + onRestore(): void; + /** + !#en + Schedules a custom selector.
+ If the selector is already scheduled, then the interval parameter will be updated without scheduling it again. + !#zh + 调度一个自定义的回调函数。
+ 如果回调函数已调度,那么将不会重复调度它,只会更新时间间隔参数。 + @param callback The callback function + @param interval Tick interval in seconds. 0 means tick every frame. + @param repeat The selector will be executed (repeat + 1) times, you can use cc.macro.REPEAT_FOREVER for tick infinitely. + @param delay The amount of time that the first tick will wait before execution. Unit: s + + @example + ```js + var timeCallback = function (dt) { + cc.log("time: " + dt); + } + this.schedule(timeCallback, 1); + ``` + */ + schedule(callback: Function, interval?: number, repeat?: number, delay?: number): void; + /** + !#en Schedules a callback function that runs only once, with a delay of 0 or larger. + !#zh 调度一个只运行一次的回调函数,可以指定 0 让回调函数在下一帧立即执行或者在一定的延时之后执行。 + @param callback A function wrapped as a selector + @param delay The amount of time that the first tick will wait before execution. Unit: s + + @example + ```js + var timeCallback = function (dt) { + cc.log("time: " + dt); + } + this.scheduleOnce(timeCallback, 2); + ``` + */ + scheduleOnce(callback: Function, delay?: number): void; + /** + !#en Unschedules a custom callback function. + !#zh 取消调度一个自定义的回调函数。 + @param callback_fn A function wrapped as a selector + + @example + ```js + this.unschedule(_callback); + ``` + */ + unschedule(callback_fn: Function): void; + /** + !#en + unschedule all scheduled callback functions: custom callback functions, and the 'update' callback function.
+ Actions are not affected by this method. + !#zh 取消调度所有已调度的回调函数:定制的回调函数以及 'update' 回调函数。动作不受此方法影响。 + + @example + ```js + this.unscheduleAllCallbacks(); + ``` + */ + unscheduleAllCallbacks(): void; + } + /** !#en The Label Component. + !#zh 文字标签组件 */ + export class Label extends RenderComponent { + /** !#en Content string of label. + !#zh 标签显示的文本内容。 */ + string: string; + /** !#en Horizontal Alignment of label. + !#zh 文本内容的水平对齐方式。 */ + horizontalAlign: Label.HorizontalAlign; + /** !#en Vertical Alignment of label. + !#zh 文本内容的垂直对齐方式。 */ + verticalAlign: Label.VerticalAlign; + /** !#en The actual rendering font size in shrink mode + !#zh SHRINK 模式下面文本实际渲染的字体大小 */ + actualFontSize: number; + /** !#en Font size of label. + !#zh 文本字体大小。 */ + fontSize: number; + /** !#en Font family of label, only take effect when useSystemFont property is true. + !#zh 文本字体名称, 只在 useSystemFont 属性为 true 的时候生效。 */ + fontFamily: string; + /** !#en Line Height of label. + !#zh 文本行高。 */ + lineHeight: number; + /** !#en Overflow of label. + !#zh 文字显示超出范围时的处理方式。 */ + overflow: Label.Overflow; + /** !#en Whether auto wrap label when string width is large than label width. + !#zh 是否自动换行。 */ + enableWrapText: boolean; + /** !#en The font of label. + !#zh 文本字体。 */ + font: Font; + /** !#en Whether use system font name or not. + !#zh 是否使用系统字体。 */ + useSystemFont: boolean; + /** !#en The spacing of the x axis between characters, only take Effect when using bitmap fonts. + !#zh 文字之间 x 轴的间距,仅在使用位图字体时生效。 */ + spacingX: number; + /** !#en The cache mode of label. This mode only supports system fonts. + !#zh 文本缓存模式, 该模式只支持系统字体。 */ + cacheMode: Label.CacheMode; + /** !#en Whether enable bold. + !#zh 是否启用黑体。 */ + enableBold: boolean; + /** !#en Whether enable italic. + !#zh 是否启用黑体。 */ + enableItalic: boolean; + /** !#en Whether enable underline. + !#zh 是否启用下划线。 */ + enableUnderline: boolean; + /** !#en The height of underline. + !#zh 下划线高度。 */ + underlineHeight: number; + /** + !#zh 需要保证当前场景中没有使用CHAR缓存的Label才可以清除,否则已渲染的文字没有重新绘制会不显示 + !#en It can be cleared that need to ensure there is not use the CHAR cache in the current scene. Otherwise, the rendered text will not be displayed without repainting. + */ + static clearCharCache(): void; + } + /** !#en Outline effect used to change the display, only for system fonts or TTF fonts + !#zh 描边效果组件,用于字体描边,只能用于系统字体 */ + export class LabelOutline extends Component { + /** !#en outline color + !#zh 改变描边的颜色 */ + color: Color; + /** !#en Change the outline width + !#zh 改变描边的宽度 */ + width: number; + } + /** !#en Shadow effect for Label component, only for system fonts or TTF fonts + !#zh 用于给 Label 组件添加阴影效果,只能用于系统字体或 ttf 字体 */ + export class LabelShadow extends Component { + /** !#en The shadow color + !#zh 阴影的颜色 */ + color: Color; + /** !#en Offset between font and shadow + !#zh 字体与阴影的偏移 */ + offset: Vec2; + /** !#en A non-negative float specifying the level of shadow blur + !#zh 阴影的模糊程度 */ + blur: number; + } + /** !#en + The Layout is a container component, use it to arrange child elements easily.
+ Note:
+ 1.Scaling and rotation of child nodes are not considered.
+ 2.After setting the Layout, the results need to be updated until the next frame, + unless you manually call {{#crossLink "Layout/updateLayout:method"}}{{/crossLink}}。 + !#zh + Layout 组件相当于一个容器,能自动对它的所有子节点进行统一排版。
+ 注意:
+ 1.不会考虑子节点的缩放和旋转。
+ 2.对 Layout 设置后结果需要到下一帧才会更新,除非你设置完以后手动调用 {{#crossLink "Layout/updateLayout:method"}}{{/crossLink}}。 */ + export class Layout extends Component { + /** !#en The layout type. + !#zh 布局类型 */ + type: Layout.Type; + /** !#en + The are three resize modes for Layout. + None, resize Container and resize children. + !#zh 缩放模式 */ + resizeMode: Layout.ResizeMode; + /** !#en The cell size for grid layout. + !#zh 每个格子的大小,只有布局类型为 GRID 的时候才有效。 */ + cellSize: Size; + /** !#en + The start axis for grid layout. If you choose horizontal, then children will layout horizontally at first, + and then break line on demand. Choose vertical if you want to layout vertically at first . + !#zh 起始轴方向类型,可进行水平和垂直布局排列,只有布局类型为 GRID 的时候才有效。 */ + startAxis: Layout.AxisDirection; + /** !#en The left padding of layout, it only effect the layout in one direction. + !#zh 容器内左边距,只会在一个布局方向上生效。 */ + paddingLeft: number; + /** !#en The right padding of layout, it only effect the layout in one direction. + !#zh 容器内右边距,只会在一个布局方向上生效。 */ + paddingRight: number; + /** !#en The top padding of layout, it only effect the layout in one direction. + !#zh 容器内上边距,只会在一个布局方向上生效。 */ + paddingTop: number; + /** !#en The bottom padding of layout, it only effect the layout in one direction. + !#zh 容器内下边距,只会在一个布局方向上生效。 */ + paddingBottom: number; + /** !#en The distance in x-axis between each element in layout. + !#zh 子节点之间的水平间距。 */ + spacingX: number; + /** !#en The distance in y-axis between each element in layout. + !#zh 子节点之间的垂直间距。 */ + spacingY: number; + /** !#en + Only take effect in Vertical layout mode. + This option changes the start element's positioning. + !#zh 垂直排列子节点的方向。 */ + verticalDirection: Layout.VerticalDirection; + /** !#en + Only take effect in Horizontal layout mode. + This option changes the start element's positioning. + !#zh 水平排列子节点的方向。 */ + horizontalDirection: Layout.HorizontalDirection; + /** !#en Adjust the layout if the children scaled. + !#zh 子节点缩放比例是否影响布局。 */ + affectedByScale: boolean; + /** + !#en Perform the layout update + !#zh 立即执行更新布局 + + @example + ```js + layout.type = cc.Layout.HORIZONTAL; + layout.node.addChild(childNode); + cc.log(childNode.x); // not yet changed + layout.updateLayout(); + cc.log(childNode.x); // changed + ``` + */ + updateLayout(): void; + } + /** !#en The Mask Component + !#zh 遮罩组件 */ + export class Mask extends RenderComponent { + /** !#en The mask type. + !#zh 遮罩类型 */ + type: Mask.Type; + /** !#en The mask image + !#zh 遮罩所需要的贴图 */ + spriteFrame: SpriteFrame; + /** !#en + The alpha threshold.(Not supported Canvas Mode)
+ The content is drawn only where the stencil have pixel with alpha greater than the alphaThreshold.
+ Should be a float between 0 and 1.
+ This default to 0.1. + When it's set to 1, the stencil will discard all pixels, nothing will be shown. + !#zh + Alpha 阈值(不支持 Canvas 模式)
+ 只有当模板的像素的 alpha 大于等于 alphaThreshold 时,才会绘制内容。
+ 该数值 0 ~ 1 之间的浮点数,默认值为 0.1 + 当被设置为 1 时,会丢弃所有蒙版像素,所以不会显示任何内容 */ + alphaThreshold: number; + /** !#en Reverse mask (Not supported Canvas Mode) + !#zh 反向遮罩(不支持 Canvas 模式) */ + inverted: boolean; + /** TODO: remove segments, not supported by graphics + !#en The segements for ellipse mask. + !#zh 椭圆遮罩的曲线细分数 */ + segements: number; + } + /** !#en + cc.MotionStreak manages a Ribbon based on it's motion in absolute space.
+ You construct it with a fadeTime, minimum segment size, texture path, texture
+ length and color. The fadeTime controls how long it takes each vertex in
+ the streak to fade out, the minimum segment size it how many pixels the
+ streak will move before adding a new ribbon segment, and the texture
+ length is the how many pixels the texture is stretched across. The texture
+ is vertically aligned along the streak segment. + !#zh 运动轨迹,用于游戏对象的运动轨迹上实现拖尾渐隐效果。 */ + export class MotionStreak extends Component implements BlendFunc { + /** !#en + !#zh 在编辑器模式下预览拖尾效果。 */ + preview: boolean; + /** !#en The fade time to fade. + !#zh 拖尾的渐隐时间,以秒为单位。 */ + fadeTime: number; + /** !#en The minimum segment size. + !#zh 拖尾之间最小距离。 */ + minSeg: number; + /** !#en The stroke's width. + !#zh 拖尾的宽度。 */ + stroke: number; + /** !#en The texture of the MotionStreak. + !#zh 拖尾的贴图。 */ + texture: Texture2D; + /** !#en The color of the MotionStreak. + !#zh 拖尾的颜色 */ + color: Color; + /** !#en The fast Mode. + !#zh 是否启用了快速模式。当启用快速模式,新的点会被更快地添加,但精度较低。 */ + fastMode: boolean; + /** + !#en Remove all living segments of the ribbon. + !#zh 删除当前所有的拖尾片段。 + + @example + ```js + // Remove all living segments of the ribbon. + myMotionStreak.reset(); + ``` + */ + reset(): void; + /** !#en specify the source Blend Factor, this will generate a custom material object, please pay attention to the memory cost. + !#zh 指定原图的混合模式,这会克隆一个新的材质对象,注意这带来的开销 */ + srcBlendFactor: macro.BlendFactor; + /** !#en specify the destination Blend Factor. + !#zh 指定目标的混合模式 */ + dstBlendFactor: macro.BlendFactor; + } + /** !#en The PageView control + !#zh 页面视图组件 */ + export class PageView extends ScrollView { + /** !#en Specify the size type of each page in PageView. + !#zh 页面视图中每个页面大小类型 */ + sizeMode: PageView.SizeMode; + /** !#en The page view direction + !#zh 页面视图滚动类型 */ + direction: PageView.Direction; + /** !#en + The scroll threshold value, when drag exceeds this value, + release the next page will automatically scroll, less than the restore + !#zh 滚动临界值,默认单位百分比,当拖拽超出该数值时,松开会自动滚动下一页,小于时则还原。 */ + scrollThreshold: number; + /** !#en + Auto page turning velocity threshold. When users swipe the PageView quickly, + it will calculate a velocity based on the scroll distance and time, + if the calculated velocity is larger than the threshold, then it will trigger page turning. + !#zh + 快速滑动翻页临界值。 + 当用户快速滑动时,会根据滑动开始和结束的距离与时间计算出一个速度值, + 该值与此临界值相比较,如果大于临界值,则进行自动翻页。 */ + autoPageTurningThreshold: number; + /** !#en Change the PageTurning event timing of PageView. + !#zh 设置 PageView PageTurning 事件的发送时机。 */ + pageTurningEventTiming: number; + /** !#en The Page View Indicator + !#zh 页面视图指示器组件 */ + indicator: PageViewIndicator; + /** !#en The time required to turn over a page. unit: second + !#zh 每个页面翻页时所需时间。单位:秒 */ + pageTurningSpeed: number; + /** !#en PageView events callback + !#zh 滚动视图的事件回调函数 */ + pageEvents: Component.EventHandler[]; + /** + !#en Returns current page index + !#zh 返回当前页面索引 + */ + getCurrentPageIndex(): number; + /** + !#en Set current page index + !#zh 设置当前页面索引 + @param index index + */ + setCurrentPageIndex(index: number): void; + /** + !#en Returns all pages of pageview + !#zh 返回视图中的所有页面 + */ + getPages(): Node[]; + /** + !#en At the end of the current page view to insert a new view + !#zh 在当前页面视图的尾部插入一个新视图 + @param page page + */ + addPage(page: Node): void; + /** + !#en Inserts a page in the specified location + !#zh 将页面插入指定位置中 + @param page page + @param index index + */ + insertPage(page: Node, index: number): void; + /** + !#en Removes a page from PageView. + !#zh 移除指定页面 + @param page page + */ + removePage(page: Node): void; + /** + !#en Removes a page at index of PageView. + !#zh 移除指定下标的页面 + @param index index + */ + removePageAtIndex(index: number): void; + /** + !#en Removes all pages from PageView + !#zh 移除所有页面 + */ + removeAllPages(): void; + /** + !#en Scroll PageView to index. + !#zh 滚动到指定页面 + @param idx index of page. + @param timeInSecond scrolling time + */ + scrollToPage(idx: number, timeInSecond: number): void; + } + /** !#en The Page View Indicator Component + !#zh 页面视图每页标记组件 */ + export class PageViewIndicator extends Component { + /** !#en The spriteFrame for each element. + !#zh 每个页面标记显示的图片 */ + spriteFrame: SpriteFrame; + /** !#en The location direction of PageViewIndicator. + !#zh 页面标记摆放方向 */ + direction: PageViewIndicator.Direction; + /** !#en The cellSize for each element. + !#zh 每个页面标记的大小 */ + cellSize: Size; + /** !#en The distance between each element. + !#zh 每个页面标记之间的边距 */ + spacing: number; + /** + !#en Set Page View + !#zh 设置页面视图 + @param target target + */ + setPageView(target: PageView): void; + } + /** !#en + Visual indicator of progress in some operation. + Displays a bar to the user representing how far the operation has progressed. + !#zh + 进度条组件,可用于显示加载资源时的进度。 */ + export class ProgressBar extends Component { + /** !#en The targeted Sprite which will be changed progressively. + !#zh 用来显示进度条比例的 Sprite 对象。 */ + barSprite: Sprite; + /** !#en The progress mode, there are two modes supported now: horizontal and vertical. + !#zh 进度条的模式 */ + mode: ProgressBar.Mode; + /** !#en The total width or height of the bar sprite. + !#zh 进度条实际的总长度 */ + totalLength: number; + /** !#en The current progress of the bar sprite. The valid value is between 0-1. + !#zh 当前进度值,该数值的区间是 0-1 之间。 */ + progress: number; + /** !#en Whether reverse the progress direction of the bar sprite. + !#zh 进度条是否进行反方向变化。 */ + reverse: boolean; + } + /** !#en + Base class for components which supports rendering features. + !#zh + 所有支持渲染的组件的基类 */ + export class RenderComponent extends Component { + /** !#en The materials used by this render component. + !#zh 渲染组件使用的材质。 */ + sharedMaterials: Material[]; + /** + !#en Get the material by index. + !#zh 根据指定索引获取材质 + @param index index + */ + getMaterial(index: number): MaterialVariant; + /** + !#en Gets all the materials. + !#zh 获取所有材质。 + */ + getMaterials(): MaterialVariant[]; + /** + !#en Set the material by index. + !#zh 根据指定索引设置材质 + @param index index + @param material material + */ + setMaterial(index: number, material: Material): Material; + } + /** !#en The RichText Component. + !#zh 富文本组件 */ + export class RichText extends Component { + /** !#en Content string of RichText. + !#zh 富文本显示的文本内容。 */ + string: string; + /** !#en Horizontal Alignment of each line in RichText. + !#zh 文本内容的水平对齐方式。 */ + horizontalAlign: macro.TextAlignment; + /** !#en Font size of RichText. + !#zh 富文本字体大小。 */ + fontSize: number; + /** !#en Custom System font of RichText + !#zh 富文本定制系统字体 */ + fontFamily: string; + /** !#en Custom TTF font of RichText + !#zh 富文本定制字体 */ + font: TTFFont; + /** !#en Whether use system font name or not. + !#zh 是否使用系统字体。 */ + useSystemFont: boolean; + /** !#en The cache mode of label. This mode only supports system fonts. + !#zh 文本缓存模式, 该模式只支持系统字体。 */ + cacheMode: Label.CacheMode; + /** !#en The maximize width of the RichText + !#zh 富文本的最大宽度 */ + maxWidth: number; + /** !#en Line Height of RichText. + !#zh 富文本行高。 */ + lineHeight: number; + /** !#en The image atlas for the img tag. For each src value in the img tag, there should be a valid spriteFrame in the image atlas. + !#zh 对于 img 标签里面的 src 属性名称,都需要在 imageAtlas 里面找到一个有效的 spriteFrame,否则 img tag 会判定为无效。 */ + imageAtlas: SpriteAtlas; + /** !#en + Once checked, the RichText will block all input events (mouse and touch) within + the bounding box of the node, preventing the input from penetrating into the underlying node. + !#zh + 选中此选项后,RichText 将阻止节点边界框中的所有输入事件(鼠标和触摸),从而防止输入事件穿透到底层节点。 */ + handleTouchEvent: boolean; + } + /** !#en + The Scrollbar control allows the user to scroll an image or other view that is too large to see completely + !#zh 滚动条组件 */ + export class Scrollbar extends Component { + /** !#en The "handle" part of the scrollbar. + !#zh 作为当前滚动区域位置显示的滑块 Sprite。 */ + handle: Sprite; + /** !#en The direction of scrollbar. + !#zh ScrollBar 的滚动方向。 */ + direction: Scrollbar.Direction; + /** !#en Whether enable auto hide or not. + !#zh 是否在没有滚动动作时自动隐藏 ScrollBar。 */ + enableAutoHide: boolean; + /** !#en + The time to hide scrollbar when scroll finished. + Note: This value is only useful when enableAutoHide is true. + !#zh + 没有滚动动作后经过多久会自动隐藏。 + 注意:只要当 “enableAutoHide” 为 true 时,才有效。 */ + autoHideTime: number; + } + /** !#en + Layout container for a view hierarchy that can be scrolled by the user, + allowing it to be larger than the physical display. + + !#zh + 滚动视图组件 */ + export class ScrollView extends Component { + /** !#en This is a reference to the UI element to be scrolled. + !#zh 可滚动展示内容的节点。 */ + content: Node; + /** !#en Enable horizontal scroll. + !#zh 是否开启水平滚动。 */ + horizontal: boolean; + /** !#en Enable vertical scroll. + !#zh 是否开启垂直滚动。 */ + vertical: boolean; + /** !#en When inertia is set, the content will continue to move when touch ended. + !#zh 是否开启滚动惯性。 */ + inertia: boolean; + /** !#en + It determines how quickly the content stop moving. A value of 1 will stop the movement immediately. + A value of 0 will never stop the movement until it reaches to the boundary of scrollview. + !#zh + 开启惯性后,在用户停止触摸后滚动多快停止,0表示永不停止,1表示立刻停止。 */ + brake: number; + /** !#en When elastic is set, the content will be bounce back when move out of boundary. + !#zh 是否允许滚动内容超过边界,并在停止触摸后回弹。 */ + elastic: boolean; + /** !#en The elapse time of bouncing back. A value of 0 will bounce back immediately. + !#zh 回弹持续的时间,0 表示将立即反弹。 */ + bounceDuration: number; + /** !#en The horizontal scrollbar reference. + !#zh 水平滚动的 ScrollBar。 */ + horizontalScrollBar: Scrollbar; + /** !#en The vertical scrollbar reference. + !#zh 垂直滚动的 ScrollBar。 */ + verticalScrollBar: Scrollbar; + /** !#en Scrollview events callback + !#zh 滚动视图的事件回调函数 */ + scrollEvents: Component.EventHandler[]; + /** !#en If cancelInnerEvents is set to true, the scroll behavior will cancel touch events on inner content nodes + It's set to true by default. + !#zh 如果这个属性被设置为 true,那么滚动行为会取消子节点上注册的触摸事件,默认被设置为 true。 + 注意,子节点上的 touchstart 事件仍然会触发,触点移动距离非常短的情况下 touchmove 和 touchend 也不会受影响。 */ + cancelInnerEvents: boolean; + /** + !#en Scroll the content to the bottom boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图底部。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the bottom boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the bottom of the view. + scrollView.scrollToBottom(0.1); + ``` + */ + scrollToBottom(timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the top boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图顶部。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the top boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the top of the view. + scrollView.scrollToTop(0.1); + ``` + */ + scrollToTop(timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the left boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图左边。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the left boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the left of the view. + scrollView.scrollToLeft(0.1); + ``` + */ + scrollToLeft(timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the right boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图右边。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the right boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the right of the view. + scrollView.scrollToRight(0.1); + ``` + */ + scrollToRight(timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the top left boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图左上角。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the top left boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the upper left corner of the view. + scrollView.scrollToTopLeft(0.1); + ``` + */ + scrollToTopLeft(timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the top right boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图右上角。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the top right boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the top right corner of the view. + scrollView.scrollToTopRight(0.1); + ``` + */ + scrollToTopRight(timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the bottom left boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图左下角。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the bottom left boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the lower left corner of the view. + scrollView.scrollToBottomLeft(0.1); + ``` + */ + scrollToBottomLeft(timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the bottom right boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图右下角。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the bottom right boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the lower right corner of the view. + scrollView.scrollToBottomRight(0.1); + ``` + */ + scrollToBottomRight(timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll with an offset related to the ScrollView's top left origin, if timeInSecond is omitted, then it will jump to the + specific offset immediately. + !#zh 视图内容在规定时间内将滚动到 ScrollView 相对左上角原点的偏移位置, 如果 timeInSecond参数不传,则立即滚动到指定偏移位置。 + @param offset A Vec2, the value of which each axis between 0 and maxScrollOffset + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the specific offset of ScrollView immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to middle position in 0.1 second in x-axis + let maxScrollOffset = this.getMaxScrollOffset(); + scrollView.scrollToOffset(cc.v2(maxScrollOffset.x / 2, 0), 0.1); + ``` + */ + scrollToOffset(offset: Vec2, timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Get the positive offset value corresponds to the content's top left boundary. + !#zh 获取滚动视图相对于左上角原点的当前滚动偏移 + */ + getScrollOffset(): Vec2; + /** + !#en Get the maximize available scroll offset + !#zh 获取滚动视图最大可以滚动的偏移量 + */ + getMaxScrollOffset(): Vec2; + /** + !#en Scroll the content to the horizontal percent position of ScrollView. + !#zh 视图内容在规定时间内将滚动到 ScrollView 水平方向的百分比位置上。 + @param percent A value between 0 and 1. + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the horizontal percent position of ScrollView immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to middle position. + scrollView.scrollToBottomRight(0.5, 0.1); + ``` + */ + scrollToPercentHorizontal(percent: number, timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the percent position of ScrollView in any direction. + !#zh 视图内容在规定时间内进行垂直方向和水平方向的滚动,并且滚动到指定百分比位置上。 + @param anchor A point which will be clamp between cc.v2(0,0) and cc.v2(1,1). + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the percent position of ScrollView immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Vertical scroll to the bottom of the view. + scrollView.scrollTo(cc.v2(0, 1), 0.1); + + // Horizontal scroll to view right. + scrollView.scrollTo(cc.v2(1, 0), 0.1); + ``` + */ + scrollTo(anchor: Vec2, timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the vertical percent position of ScrollView. + !#zh 视图内容在规定时间内滚动到 ScrollView 垂直方向的百分比位置上。 + @param percent A value between 0 and 1. + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the vertical percent position of ScrollView immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + // Scroll to middle position. + scrollView.scrollToPercentVertical(0.5, 0.1); + */ + scrollToPercentVertical(percent: number, timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Stop auto scroll immediately + !#zh 停止自动滚动, 调用此 API 可以让 Scrollview 立即停止滚动 + */ + stopAutoScroll(): void; + /** + !#en Modify the content position. + !#zh 设置当前视图内容的坐标点。 + @param position The position in content's parent space. + */ + setContentPosition(position: Vec2): void; + /** + !#en Query the content's position in its parent space. + !#zh 获取当前视图内容的坐标点。 + */ + getContentPosition(): Vec2; + /** + !#en Query whether the user is currently dragging the ScrollView to scroll it + !#zh 用户是否在拖拽当前滚动视图 + */ + isScrolling(): boolean; + /** + !#en Query whether the ScrollView is currently scrolling because of a bounceback or inertia slowdown. + !#zh 当前滚动视图是否在惯性滚动 + */ + isAutoScrolling(): boolean; + } + /** !#en The Slider Control + !#zh 滑动器组件 */ + export class Slider extends Component { + /** !#en The "handle" part of the slider + !#zh 滑动器滑块按钮部件 */ + handle: Button; + /** !#en The slider direction + !#zh 滑动器方向 */ + direction: Slider.Direction; + /** !#en The current progress of the slider. The valid value is between 0-1 + !#zh 当前进度值,该数值的区间是 0-1 之间 */ + progress: number; + /** !#en The slider slide events' callback array + !#zh 滑动器组件滑动事件回调函数数组 */ + slideEvents: Component.EventHandler[]; + } + /** !#en Renders a sprite in the scene. + !#zh 该组件用于在场景中渲染精灵。 */ + export class Sprite extends RenderComponent implements BlendFunc { + /** !#en The sprite frame of the sprite. + !#zh 精灵的精灵帧 */ + spriteFrame: SpriteFrame; + /** !#en The sprite render type. + !#zh 精灵渲染类型 */ + type: Sprite.Type; + /** !#en + The fill type, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”. + !#zh + 精灵填充类型,仅渲染类型设置为 cc.Sprite.Type.FILLED 时有效。 */ + fillType: Sprite.FillType; + /** !#en + The fill Center, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”. + !#zh + 填充中心点,仅渲染类型设置为 cc.Sprite.Type.FILLED 时有效。 */ + fillCenter: Vec2; + /** !#en + The fill Start, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”. + !#zh + 填充起始点,仅渲染类型设置为 cc.Sprite.Type.FILLED 时有效。 */ + fillStart: number; + /** !#en + The fill Range, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”. + !#zh + 填充范围,仅渲染类型设置为 cc.Sprite.Type.FILLED 时有效。 */ + fillRange: number; + /** !#en specify the frame is trimmed or not. + !#zh 是否使用裁剪模式 */ + trim: boolean; + /** !#en specify the size tracing mode. + !#zh 精灵尺寸调整模式 */ + sizeMode: Sprite.SizeMode; + /** + Change the state of sprite. + @param state NORMAL or GRAY State. + */ + setState(state: Sprite.State): void; + /** + Gets the current state. + */ + getState(): Sprite.State; + /** !#en specify the source Blend Factor, this will generate a custom material object, please pay attention to the memory cost. + !#zh 指定原图的混合模式,这会克隆一个新的材质对象,注意这带来的开销 */ + srcBlendFactor: macro.BlendFactor; + /** !#en specify the destination Blend Factor. + !#zh 指定目标的混合模式 */ + dstBlendFactor: macro.BlendFactor; + } + /** !#en The toggle component is a CheckBox, when it used together with a ToggleGroup, it + could be treated as a RadioButton. + !#zh Toggle 是一个 CheckBox,当它和 ToggleGroup 一起使用的时候,可以变成 RadioButton。 */ + export class Toggle extends Button implements GraySpriteState { + /** !#en When this value is true, the check mark component will be enabled, otherwise + the check mark component will be disabled. + !#zh 如果这个设置为 true,则 check mark 组件会处于 enabled 状态,否则处于 disabled 状态。 */ + isChecked: boolean; + /** !#en The toggle group which the toggle belongs to, when it is null, the toggle is a CheckBox. + Otherwise, the toggle is a RadioButton. + !#zh Toggle 所属的 ToggleGroup,这个属性是可选的。如果这个属性为 null,则 Toggle 是一个 CheckBox, + 否则,Toggle 是一个 RadioButton。 */ + toggleGroup: ToggleGroup; + /** !#en The image used for the checkmark. + !#zh Toggle 处于选中状态时显示的图片 */ + checkMark: Sprite; + /** !#en If Toggle is clicked, it will trigger event's handler + !#zh Toggle 按钮的点击事件列表。 */ + checkEvents: Component.EventHandler[]; + /** + !#en Make the toggle button checked. + !#zh 使 toggle 按钮处于选中状态 + */ + check(): void; + /** + !#en Make the toggle button unchecked. + !#zh 使 toggle 按钮处于未选中状态 + */ + uncheck(): void; + /** !#en The normal material. + !#zh 正常状态的材质。 */ + normalMaterial: Material; + /** !#en The gray material. + !#zh 置灰状态的材质。 */ + grayMaterial: Material; + } + /** !#en ToggleContainer is not a visiable UI component but a way to modify the behavior of a set of Toggles.
+ Toggles that belong to the same group could only have one of them to be switched on at a time.
+ Note: All the first layer child node containing the toggle component will auto be added to the container + !#zh ToggleContainer 不是一个可见的 UI 组件,它可以用来修改一组 Toggle 组件的行为。
+ 当一组 Toggle 属于同一个 ToggleContainer 的时候,任何时候只能有一个 Toggle 处于选中状态。
+ 注意:所有包含 Toggle 组件的一级子节点都会自动被添加到该容器中 */ + export class ToggleContainer extends Component { + /** !#en If this setting is true, a toggle could be switched off and on when pressed. + If it is false, it will make sure there is always only one toggle could be switched on + and the already switched on toggle can't be switched off. + !#zh 如果这个设置为 true, 那么 toggle 按钮在被点击的时候可以反复地被选中和未选中。 */ + allowSwitchOff: boolean; + /** !#en If Toggle is clicked, it will trigger event's handler + !#zh Toggle 按钮的点击事件列表。 */ + checkEvents: Component.EventHandler[]; + /** !#en Read only property, return the toggle items array reference managed by ToggleContainer. + !#zh 只读属性,返回 ToggleContainer 管理的 toggle 数组引用 */ + toggleItems: Toggle[]; + } + /** !#en ToggleGroup is not a visiable UI component but a way to modify the behavior of a set of Toggles. + Toggles that belong to the same group could only have one of them to be switched on at a time. + !#zh ToggleGroup 不是一个可见的 UI 组件,它可以用来修改一组 Toggle 组件的行为。当一组 Toggle 属于同一个 ToggleGroup 的时候, + 任何时候只能有一个 Toggle 处于选中状态。 */ + export class ToggleGroup extends Component { + /** !#en If this setting is true, a toggle could be switched off and on when pressed. + If it is false, it will make sure there is always only one toggle could be switched on + and the already switched on toggle can't be switched off. + !#zh 如果这个设置为 true, 那么 toggle 按钮在被点击的时候可以反复地被选中和未选中。 */ + allowSwitchOff: boolean; + /** !#en Read only property, return the toggle items array reference managed by toggleGroup. + !#zh 只读属性,返回 toggleGroup 管理的 toggle 数组引用 */ + toggleItems: any[]; + } + /** !#en + Handling touch events in a ViewGroup takes special care, + because it's common for a ViewGroup to have children that are targets for different touch events than the ViewGroup itself. + To make sure that each view correctly receives the touch events intended for it, + ViewGroup should register capture phase event and handle the event propagation properly. + Please refer to Scrollview for more information. + + !#zh + ViewGroup的事件处理比较特殊,因为 ViewGroup 里面的子节点关心的事件跟 ViewGroup 本身可能不一样。 + 为了让子节点能够正确地处理事件,ViewGroup 需要注册 capture 阶段的事件,并且合理地处理 ViewGroup 之间的事件传递。 + 请参考 ScrollView 的实现来获取更多信息。 */ + export class ViewGroup extends Component { + } + /** !#en + Stores and manipulate the anchoring based on its parent. + Widget are used for GUI but can also be used for other things. + Widget will adjust current node's position and size automatically, but the results after adjustment can not be obtained until the next frame unless you call {{#crossLink "Widget/updateAlignment:method"}}{{/crossLink}} manually. + !#zh + Widget 组件,用于设置和适配其相对于父节点的边距,Widget 通常被用于 UI 界面,也可以用于其他地方。 + Widget 会自动调整当前节点的坐标和宽高,不过目前调整后的结果要到下一帧才能在脚本里获取到,除非你先手动调用 {{#crossLink "Widget/updateAlignment:method"}}{{/crossLink}}。 */ + export class Widget extends Component { + /** !#en Specifies an alignment target that can only be one of the parent nodes of the current node. + The default value is null, and when null, indicates the current parent. + !#zh 指定一个对齐目标,只能是当前节点的其中一个父节点,默认为空,为空时表示当前父节点。 */ + target: Node; + /** !#en Whether to align the top. + !#zh 是否对齐上边。 */ + isAlignTop: boolean; + /** !#en + Vertically aligns the midpoint, This will open the other vertical alignment options cancel. + !#zh + 是否垂直方向对齐中点,开启此项会将垂直方向其他对齐选项取消。 */ + isAlignVerticalCenter: boolean; + /** !#en Whether to align the bottom. + !#zh 是否对齐下边。 */ + isAlignBottom: boolean; + /** !#en Whether to align the left. + !#zh 是否对齐左边 */ + isAlignLeft: boolean; + /** !#en + Horizontal aligns the midpoint. This will open the other horizontal alignment options canceled. + !#zh + 是否水平方向对齐中点,开启此选项会将水平方向其他对齐选项取消。 */ + isAlignHorizontalCenter: boolean; + /** !#en Whether to align the right. + !#zh 是否对齐右边。 */ + isAlignRight: boolean; + /** !#en + Whether the stretched horizontally, when enable the left and right alignment will be stretched horizontally, + the width setting is invalid (read only). + !#zh + 当前是否水平拉伸。当同时启用左右对齐时,节点将会被水平拉伸,此时节点的宽度只读。 */ + isStretchWidth: boolean; + /** !#en + Whether the stretched vertically, when enable the left and right alignment will be stretched vertically, + then height setting is invalid (read only) + !#zh + 当前是否垂直拉伸。当同时启用上下对齐时,节点将会被垂直拉伸,此时节点的高度只读。 */ + isStretchHeight: boolean; + /** !#en + The margins between the top of this node and the top of parent node, + the value can be negative, Only available in 'isAlignTop' open. + !#zh + 本节点顶边和父节点顶边的距离,可填写负值,只有在 isAlignTop 开启时才有作用。 */ + top: number; + /** !#en + The margins between the bottom of this node and the bottom of parent node, + the value can be negative, Only available in 'isAlignBottom' open. + !#zh + 本节点底边和父节点底边的距离,可填写负值,只有在 isAlignBottom 开启时才有作用。 */ + bottom: number; + /** !#en + The margins between the left of this node and the left of parent node, + the value can be negative, Only available in 'isAlignLeft' open. + !#zh + 本节点左边和父节点左边的距离,可填写负值,只有在 isAlignLeft 开启时才有作用。 */ + left: number; + /** !#en + The margins between the right of this node and the right of parent node, + the value can be negative, Only available in 'isAlignRight' open. + !#zh + 本节点右边和父节点右边的距离,可填写负值,只有在 isAlignRight 开启时才有作用。 */ + right: number; + /** !#en + Horizontal aligns the midpoint offset value, + the value can be negative, Only available in 'isAlignHorizontalCenter' open. + !#zh 水平居中的偏移值,可填写负值,只有在 isAlignHorizontalCenter 开启时才有作用。 */ + horizontalCenter: number; + /** !#en + Vertical aligns the midpoint offset value, + the value can be negative, Only available in 'isAlignVerticalCenter' open. + !#zh 垂直居中的偏移值,可填写负值,只有在 isAlignVerticalCenter 开启时才有作用。 */ + verticalCenter: number; + /** !#en If true, horizontalCenter is pixel margin, otherwise is percentage (0 - 1) margin. + !#zh 如果为 true,"horizontalCenter" 将会以像素作为偏移值,反之为百分比(0 到 1)。 */ + isAbsoluteHorizontalCenter: boolean; + /** !#en If true, verticalCenter is pixel margin, otherwise is percentage (0 - 1) margin. + !#zh 如果为 true,"verticalCenter" 将会以像素作为偏移值,反之为百分比(0 到 1)。 */ + isAbsoluteVerticalCenter: boolean; + /** !#en + If true, top is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's height. + !#zh + 如果为 true,"top" 将会以像素作为边距,否则将会以相对父物体高度的百分比(0 到 1)作为边距。 */ + isAbsoluteTop: boolean; + /** !#en + If true, bottom is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's height. + !#zh + 如果为 true,"bottom" 将会以像素作为边距,否则将会以相对父物体高度的百分比(0 到 1)作为边距。 */ + isAbsoluteBottom: boolean; + /** !#en + If true, left is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's width. + !#zh + 如果为 true,"left" 将会以像素作为边距,否则将会以相对父物体宽度的百分比(0 到 1)作为边距。 */ + isAbsoluteLeft: boolean; + /** !#en + If true, right is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's width. + !#zh + 如果为 true,"right" 将会以像素作为边距,否则将会以相对父物体宽度的百分比(0 到 1)作为边距。 */ + isAbsoluteRight: boolean; + /** !#en Specifies the alignment mode of the Widget, which determines when the widget should refresh. + !#zh 指定 Widget 的对齐模式,用于决定 Widget 应该何时刷新。 */ + alignMode: Widget.AlignMode; + /** + !#en + Immediately perform the widget alignment. You need to manually call this method only if + you need to get the latest results after the alignment before the end of current frame. + !#zh + 立刻执行 widget 对齐操作。这个接口一般不需要手工调用。 + 只有当你需要在当前帧结束前获得 widget 对齐后的最新结果时才需要手动调用这个方法。 + + @example + ```js + widget.top = 10; // change top margin + cc.log(widget.node.y); // not yet changed + widget.updateAlignment(); + cc.log(widget.node.y); // changed + ``` + */ + updateAlignment(): void; + /** !#en + When turned on, it will only be aligned once at the end of the onEnable frame, + then immediately disables the current component. + This will allow the script or animation to continue controlling the current node. + Note: It will still be aligned at the frame when onEnable is called. + !#zh + 开启后仅会在 onEnable 的当帧结束时对齐一次,然后立刻禁用当前组件。 + 这样便于脚本或动画继续控制当前节点。 + 注意:onEnable 时所在的那一帧仍然会进行对齐。 */ + isAlignOnce: boolean; + } + /** !#en SwanSubContextView is a view component which controls open data context viewport in WeChat game platform.
+ The component's node size decide the viewport of the sub context content in main context, + the entire sub context texture will be scaled to the node's bounding box area.
+ This component provides multiple important features:
+ 1. Sub context could use its own resolution size and policy.
+ 2. Sub context could be minized to smallest size it needed.
+ 3. Resolution of sub context content could be increased.
+ 4. User touch input is transformed to the correct viewport.
+ 5. Texture update is handled by this component. User don't need to worry.
+ One important thing to be noted, whenever the node's bounding box change, + you need to manually reset the viewport of sub context using updateSubContextViewport. + !#zh SwanSubContextView 可以用来控制百度小游戏平台开放数据域在主域中的视窗的位置。
+ 这个组件的节点尺寸决定了开放数据域内容在主域中的尺寸,整个开放数据域会被缩放到节点的包围盒范围内。
+ 在这个组件的控制下,用户可以更自由得控制开放数据域:
+ 1. 子域中可以使用独立的设计分辨率和适配模式
+ 2. 子域区域尺寸可以缩小到只容纳内容即可
+ 3. 子域的分辨率也可以被放大,以便获得更清晰的显示效果
+ 4. 用户输入坐标会被自动转换到正确的子域视窗中
+ 5. 子域内容贴图的更新由组件负责,用户不需要处理
+ 唯一需要注意的是,当子域节点的包围盒发生改变时,开发者需要使用 `updateSubContextViewport` 来手动更新子域视窗。 */ + export class SwanSubContextView extends Component { + /** + !#en Update the sub context viewport manually, it should be called whenever the node's bounding box changes. + !#zh 更新开放数据域相对于主域的 viewport,这个函数应该在节点包围盒改变时手动调用。 + */ + updateSubContextViewport(): void; + } + /** !#en WXSubContextView is a view component which controls open data context viewport in WeChat game platform.
+ The component's node size decide the viewport of the sub context content in main context, + the entire sub context texture will be scaled to the node's bounding box area.
+ This component provides multiple important features:
+ 1. Sub context could use its own resolution size and policy.
+ 2. Sub context could be minized to smallest size it needed.
+ 3. Resolution of sub context content could be increased.
+ 4. User touch input is transformed to the correct viewport.
+ 5. Texture update is handled by this component. User don't need to worry.
+ One important thing to be noted, whenever the node's bounding box change, + you need to manually reset the viewport of sub context using updateSubContextViewport. + !#zh WXSubContextView 可以用来控制微信小游戏平台开放数据域在主域中的视窗的位置。
+ 这个组件的节点尺寸决定了开放数据域内容在主域中的尺寸,整个开放数据域会被缩放到节点的包围盒范围内。
+ 在这个组件的控制下,用户可以更自由得控制开放数据域:
+ 1. 子域中可以使用独立的设计分辨率和适配模式
+ 2. 子域区域尺寸可以缩小到只容纳内容即可
+ 3. 子域的分辨率也可以被放大,以便获得更清晰的显示效果
+ 4. 用户输入坐标会被自动转换到正确的子域视窗中
+ 5. 子域内容贴图的更新由组件负责,用户不需要处理
+ 唯一需要注意的是,当子域节点的包围盒发生改变时,开发者需要使用 `updateSubContextViewport` 来手动更新子域视窗。 */ + export class WXSubContextView extends Component { + /** + !#en Reset open data context size and viewport + !#zh 重置开放数据域的尺寸和视窗 + */ + reset(): void; + /** + !#en Update the sub context viewport manually, it should be called whenever the node's bounding box changes. + !#zh 更新开放数据域相对于主域的 viewport,这个函数应该在节点包围盒改变时手动调用。 + */ + updateSubContextViewport(): void; + } + /** undefined */ + export class Graphics extends RenderComponent { + /** !#en + Current line width. + !#zh + 当前线条宽度 */ + lineWidth: number; + /** !#en + lineJoin determines how two connecting segments (of lines, arcs or curves) with non-zero lengths in a shape are joined together. + !#zh + lineJoin 用来设置2个长度不为0的相连部分(线段,圆弧,曲线)如何连接在一起的属性。 */ + lineJoin: Graphics.LineJoin; + /** !#en + lineCap determines how the end points of every line are drawn. + !#zh + lineCap 指定如何绘制每一条线段末端。 */ + lineCap: Graphics.LineCap; + /** !#en + stroke color + !#zh + 线段颜色 */ + strokeColor: Color; + /** !#en + fill color + !#zh + 填充颜色 */ + fillColor: Color; + /** !#en + Sets the miter limit ratio + !#zh + 设置斜接面限制比例 */ + miterLimit: number; + /** + !#en Move path start point to (x,y). + !#zh 移动路径起点到坐标(x, y) + @param x The x axis of the coordinate for the end point. + @param y The y axis of the coordinate for the end point. + */ + moveTo(x?: number, y?: number): void; + /** + !#en Adds a straight line to the path + !#zh 绘制直线路径 + @param x The x axis of the coordinate for the end point. + @param y The y axis of the coordinate for the end point. + */ + lineTo(x?: number, y?: number): void; + /** + !#en Adds a cubic Bézier curve to the path + !#zh 绘制三次贝赛尔曲线路径 + @param c1x The x axis of the coordinate for the first control point. + @param c1y The y axis of the coordinate for first control point. + @param c2x The x axis of the coordinate for the second control point. + @param c2y The y axis of the coordinate for the second control point. + @param x The x axis of the coordinate for the end point. + @param y The y axis of the coordinate for the end point. + */ + bezierCurveTo(c1x?: number, c1y?: number, c2x?: number, c2y?: number, x?: number, y?: number): void; + /** + !#en Adds a quadratic Bézier curve to the path + !#zh 绘制二次贝赛尔曲线路径 + @param cx The x axis of the coordinate for the control point. + @param cy The y axis of the coordinate for the control point. + @param x The x axis of the coordinate for the end point. + @param y The y axis of the coordinate for the end point. + */ + quadraticCurveTo(cx?: number, cy?: number, x?: number, y?: number): void; + /** + !#en Adds an arc to the path which is centered at (cx, cy) position with radius r starting at startAngle and ending at endAngle going in the given direction by counterclockwise (defaulting to false). + !#zh 绘制圆弧路径。圆弧路径的圆心在 (cx, cy) 位置,半径为 r ,根据 counterclockwise (默认为false)指定的方向从 startAngle 开始绘制,到 endAngle 结束。 + @param cx The x axis of the coordinate for the center point. + @param cy The y axis of the coordinate for the center point. + @param r The arc's radius. + @param startAngle The angle at which the arc starts, measured clockwise from the positive x axis and expressed in radians. + @param endAngle The angle at which the arc ends, measured clockwise from the positive x axis and expressed in radians. + @param counterclockwise An optional Boolean which, if true, causes the arc to be drawn counter-clockwise between the two angles. By default it is drawn clockwise. + */ + arc(cx?: number, cy?: number, r?: number, startAngle?: number, endAngle?: number, counterclockwise?: boolean): void; + /** + !#en Adds an ellipse to the path. + !#zh 绘制椭圆路径。 + @param cx The x axis of the coordinate for the center point. + @param cy The y axis of the coordinate for the center point. + @param rx The ellipse's x-axis radius. + @param ry The ellipse's y-axis radius. + */ + ellipse(cx?: number, cy?: number, rx?: number, ry?: number): void; + /** + !#en Adds an circle to the path. + !#zh 绘制圆形路径。 + @param cx The x axis of the coordinate for the center point. + @param cy The y axis of the coordinate for the center point. + @param r The circle's radius. + */ + circle(cx?: number, cy?: number, r?: number): void; + /** + !#en Adds an rectangle to the path. + !#zh 绘制矩形路径。 + @param x The x axis of the coordinate for the rectangle starting point. + @param y The y axis of the coordinate for the rectangle starting point. + @param w The rectangle's width. + @param h The rectangle's height. + */ + rect(x?: number, y?: number, w?: number, h?: number): void; + /** + !#en Adds an round corner rectangle to the path. + !#zh 绘制圆角矩形路径。 + @param x The x axis of the coordinate for the rectangle starting point. + @param y The y axis of the coordinate for the rectangle starting point. + @param w The rectangles width. + @param h The rectangle's height. + @param r The radius of the rectangle. + */ + roundRect(x?: number, y?: number, w?: number, h?: number, r?: number): void; + /** + !#en Draws a filled rectangle. + !#zh 绘制填充矩形。 + @param x The x axis of the coordinate for the rectangle starting point. + @param y The y axis of the coordinate for the rectangle starting point. + @param w The rectangle's width. + @param h The rectangle's height. + */ + fillRect(x?: number, y?: number, w?: number, h?: number): void; + /** + !#en Erasing any previously drawn content. + !#zh 擦除之前绘制的所有内容的方法。 + @param clean Whether to clean the graphics inner cache. + */ + clear(clean?: boolean): void; + /** + !#en Causes the point of the pen to move back to the start of the current path. It tries to add a straight line from the current point to the start. + !#zh 将笔点返回到当前路径起始点的。它尝试从当前点到起始点绘制一条直线。 + */ + close(): void; + /** + !#en Strokes the current or given path with the current stroke style. + !#zh 根据当前的画线样式,绘制当前或已经存在的路径。 + */ + stroke(): void; + /** + !#en Fills the current or given path with the current fill style. + !#zh 根据当前的画线样式,填充当前或已经存在的路径。 + */ + fill(): void; + } + /** !#en Mesh Asset. + !#zh 网格资源。 */ + export class Mesh extends Asset implements EventTarget { + /** !#en Get ir set the sub meshes. + !#zh 设置或者获取子网格。 */ + subMeshes: InputAssembler[]; + /** + !#en + Init vertex buffer according to the vertex format. + !#zh + 根据顶点格式初始化顶点内存。 + @param vertexFormat vertex format + @param vertexCount how much vertex should be create in this buffer. + @param dynamic whether or not to use dynamic buffer. + @param index index + */ + init(vertexFormat: gfx.VertexFormat, vertexCount: number, dynamic?: boolean, index?: boolean): void; + /** + !#en + Set the vertex values. + !#zh + 设置顶点数据 + @param name the attribute name, e.g. gfx.ATTR_POSITION + @param values the vertex values + */ + setVertices(name: string, values: Vec2[]|Vec3[]|Color[]|number[]|Uint8Array|Float32Array): void; + /** + !#en + Set the sub mesh indices. + !#zh + 设置子网格索引。 + @param indices the sub mesh indices. + @param index sub mesh index. + @param dynamic whether or not to use dynamic buffer. + */ + setIndices(indices: number[]|Uint16Array|Uint8Array, index?: number, dynamic?: boolean): void; + /** + !#en + Set the sub mesh primitive type. + !#zh + 设置子网格绘制线条的方式。 + @param type type + @param index index + */ + setPrimitiveType(type: number, index: number): void; + /** + !#en + Clear the buffer data. + !#zh + 清除网格创建的内存数据。 + */ + clear(): void; + /** + !#en Set mesh bounding box + !#zh 设置网格的包围盒 + @param min min + @param max max + */ + setBoundingBox(min: Vec3, max: Vec3): void; + /** + !#en Read the specified attributes of the subgrid into the target buffer. + !#zh 读取子网格的指定属性到目标缓冲区中。 + @param primitiveIndex The subgrid index. + @param attributeName attribute name. + @param buffer The target buffer. + @param stride The byte interval between adjacent attributes in the target buffer. + @param offset The offset of the first attribute in the target buffer. + */ + copyAttribute(primitiveIndex: number, attributeName: string, buffer: ArrayBuffer, stride: number, offset: number): boolean; + /** + !#en Read the index data of the subgrid into the target array. + !#zh 读取子网格的索引数据到目标数组中。 + @param primitiveIndex The subgrid index. + @param outputArray The target array. + */ + copyIndices(primitiveIndex: number, outputArray: DataView): boolean; + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en + Register an callback of a specific event type on the EventTarget. + This type of event should be triggered via `emit`. + !#zh + 注册事件目标的特定事件类型回调。这种类型的事件应该被 `emit` 触发。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, node); + ``` + */ + on(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. + !#zh + 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + + @example + ```js + // register fire eventListener + var callback = eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, target); + // remove fire event listener + eventTarget.off('fire', callback, target); + // remove all fire event listeners + eventTarget.off('fire'); + ``` + */ + off(type: string, callback?: Function, target?: any): void; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.once('fire', function () { + cc.log("this is the callback and will be invoked only once"); + }, node); + ``` + */ + once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; + /** + !#en + Send an event with the event object. + !#zh + 通过事件对象派发事件 + @param event event + */ + dispatchEvent(event: Event): void; + } + /** !#en + Mesh Renderer Component + !#zh + 网格渲染组件 */ + export class MeshRenderer extends RenderComponent { + /** !#en + The mesh which the renderer uses. + !#zh + 设置使用的网格 */ + mesh: Mesh; + /** !#en + Whether the mesh should receive shadows. + !#zh + 网格是否接受光源投射的阴影 */ + receiveShadows: boolean; + /** !#en + Shadow Casting Mode + !#zh + 网格投射阴影的模式 */ + shadowCastingMode: MeshRenderer.ShadowCastingMode; + /** !#en + Enable auto merge mesh, only support when mesh's VertexFormat, PrimitiveType, materials are all the same + !#zh + 开启自动合并 mesh 功能,只有在网格的 顶点格式,PrimitiveType, 使用的材质 都一致的情况下才会有效 */ + enableAutoBatch: boolean; + } + /** !#en The renderer object which provide access to render system APIs, + detailed APIs will be available progressively. + !#zh 提供基础渲染接口的渲染器对象,渲染层的基础接口将逐步开放给用户 */ + export class renderer { + /** !#en The render engine is available only after cc.game.EVENT_ENGINE_INITED event.
+ Normally it will be inited as the webgl render engine, but in wechat open context domain, + it will be inited as the canvas render engine. Canvas render engine is no longer available for other use case since v2.0. + !#zh 基础渲染引擎对象只在 cc.game.EVENT_ENGINE_INITED 事件触发后才可获取。
+ 大多数情况下,它都会是 WebGL 渲染引擎实例,但是在微信开放数据域当中,它会是 Canvas 渲染引擎实例。请注意,从 2.0 开始,我们在其他平台和环境下都废弃了 Canvas 渲染器。 */ + static renderEngine: any; + /** !#en The total draw call count in last rendered frame. + !#zh 上一次渲染帧所提交的渲染批次总数。 */ + static drawCalls: number; + } + /** Loader for resource loading process. It's a singleton object. */ + export class loader extends Pipeline { + /** The asset loader in cc.loader's pipeline, it's by default the first pipe. + It's used to identify an asset's type, and determine how to download it. */ + static assetLoader: any; + /** The md5 pipe in cc.loader's pipeline, it could be absent if the project isn't build with md5 option. + It's used to modify the url to the real downloadable url with md5 suffix. */ + static md5Pipe: any; + /** The downloader in cc.loader's pipeline, it's by default the second pipe. + It's used to download files with several handlers: pure text, image, script, audio, font, uuid. + You can add your own download function with addDownloadHandlers */ + static downloader: any; + /** The loader in cc.loader's pipeline, it's by default the third pipe. + It's used to parse downloaded content with several handlers: JSON, image, plist, fnt, uuid. + You can add your own download function with addLoadHandlers */ + static loader: any; + /** + Gets a new XMLHttpRequest instance. + */ + static getXMLHttpRequest(): XMLHttpRequest; + /** + Add custom supported types handler or modify existing type handler for download process. + @param extMap Custom supported types with corresponded handler + + @example + ```js + cc.loader.addDownloadHandlers({ + // This will match all url with `.scene` extension or all url with `scene` type + 'scene' : function (url, callback) {} + }); + ``` + */ + static addDownloadHandlers(extMap: any): void; + /** + Add custom supported types handler or modify existing type handler for load process. + @param extMap Custom supported types with corresponded handler + + @example + ```js + cc.loader.addLoadHandlers({ + // This will match all url with `.scene` extension or all url with `scene` type + 'scene' : function (url, callback) {} + }); + ``` + */ + static addLoadHandlers(extMap: any): void; + /** + Load resources with a progression callback and a complete callback. + The progression callback is the same as Pipeline's {{#crossLink "LoadingItems/onProgress:method"}}onProgress{{/crossLink}} + The complete callback is almost the same as Pipeline's {{#crossLink "LoadingItems/onComplete:method"}}onComplete{{/crossLink}} + The only difference is when user pass a single url as resources, the complete callback will set its result directly as the second parameter. + @param resources Url list in an array + @param progressCallback Callback invoked when progression change + @param completeCallback Callback invoked when all resources loaded + + @example + ```js + cc.loader.load('a.png', function (err, tex) { + cc.log('Result should be a texture: ' + (tex instanceof cc.Texture2D)); + }); + + cc.loader.load('http://example.com/a.png', function (err, tex) { + cc.log('Should load a texture from external url: ' + (tex instanceof cc.Texture2D)); + }); + + cc.loader.load({url: 'http://example.com/getImageREST?file=a.png', type: 'png'}, function (err, tex) { + cc.log('Should load a texture from RESTful API by specify the type: ' + (tex instanceof cc.Texture2D)); + }); + + cc.loader.load(['a.png', 'b.json'], function (errors, results) { + if (errors) { + for (var i = 0; i < errors.length; i++) { + cc.log('Error url [' + errors[i] + ']: ' + results.getError(errors[i])); + } + } + var aTex = results.getContent('a.png'); + var bJsonObj = results.getContent('b.json'); + }); + ``` + */ + static load(resources: string|string[]|{uuid?: string, url?: string, type?: string}, completeCallback?: Function): void; + static load(resources: string|string[]|{uuid?: string, url?: string, type?: string}, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: Function|null): void; + /** + Load resources from the "resources" folder inside the "assets" folder of your project.
+
+ Note: All asset URLs in Creator use forward slashes, URLs using backslashes will not work. + @param url Url of the target resource. + The url is relative to the "resources" folder, extensions must be omitted. + @param type Only asset of type will be loaded if this argument is supplied. + @param progressCallback Callback invoked when progression change. + @param completeCallback Callback invoked when the resource loaded. + + @example + ```js + // load the prefab (project/assets/resources/misc/character/cocos) from resources folder + cc.loader.loadRes('misc/character/cocos', function (err, prefab) { + if (err) { + cc.error(err.message || err); + return; + } + cc.log('Result should be a prefab: ' + (prefab instanceof cc.Prefab)); + }); + + // load the sprite frame of (project/assets/resources/imgs/cocos.png) from resources folder + cc.loader.loadRes('imgs/cocos', cc.SpriteFrame, function (err, spriteFrame) { + if (err) { + cc.error(err.message || err); + return; + } + cc.log('Result should be a sprite frame: ' + (spriteFrame instanceof cc.SpriteFrame)); + }); + ``` + */ + static loadRes(url: string, type: typeof cc.Asset, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any) => void)|null): void; + static loadRes(url: string, type: typeof cc.Asset, completeCallback: (error: Error, resource: any) => void): void; + static loadRes(url: string, type: typeof cc.Asset): void; + static loadRes(url: string, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any) => void)|null): void; + static loadRes(url: string, completeCallback: (error: Error, resource: any) => void): void; + static loadRes(url: string): void; + /** + This method is like {{#crossLink "loader/loadRes:method"}}{{/crossLink}} except that it accepts array of url. + @param urls Array of URLs of the target resource. + The url is relative to the "resources" folder, extensions must be omitted. + @param type Only asset of type will be loaded if this argument is supplied. + @param progressCallback Callback invoked when progression change. + @param completeCallback A callback which is called when all assets have been loaded, or an error occurs. + + @example + ```js + // load the SpriteFrames from resources folder + var spriteFrames; + var urls = ['misc/characters/character_01', 'misc/weapons/weapons_01']; + cc.loader.loadResArray(urls, cc.SpriteFrame, function (err, assets) { + if (err) { + cc.error(err); + return; + } + spriteFrames = assets; + // ... + }); + ``` + */ + static loadResArray(url: string[], type: typeof cc.Asset, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any[]) => void)|null): void; + static loadResArray(url: string[], type: typeof cc.Asset, completeCallback: (error: Error, resource: any[]) => void): void; + static loadResArray(url: string[], type: typeof cc.Asset): void; + static loadResArray(url: string[], progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any[]) => void)|null): void; + static loadResArray(url: string[], completeCallback: (error: Error, resource: any[]) => void): void; + static loadResArray(url: string[]): void; + static loadResArray(url: string[], type: typeof cc.Asset[]): void; + /** + Load all assets in a folder inside the "assets/resources" folder of your project.
+
+ Note: All asset URLs in Creator use forward slashes, URLs using backslashes will not work. + @param url Url of the target folder. + The url is relative to the "resources" folder, extensions must be omitted. + @param type Only asset of type will be loaded if this argument is supplied. + @param progressCallback Callback invoked when progression change. + @param completeCallback A callback which is called when all assets have been loaded, or an error occurs. + + @example + ```js + // load the texture (resources/imgs/cocos.png) and the corresponding sprite frame + cc.loader.loadResDir('imgs/cocos', function (err, assets) { + if (err) { + cc.error(err); + return; + } + var texture = assets[0]; + var spriteFrame = assets[1]; + }); + + // load all textures in "resources/imgs/" + cc.loader.loadResDir('imgs', cc.Texture2D, function (err, textures) { + var texture1 = textures[0]; + var texture2 = textures[1]; + }); + + // load all JSONs in "resources/data/" + cc.loader.loadResDir('data', function (err, objects, urls) { + var data = objects[0]; + var url = urls[0]; + }); + ``` + */ + static loadResDir(url: string, type: typeof cc.Asset, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any[], urls: string[]) => void)|null): void; + static loadResDir(url: string, type: typeof cc.Asset, completeCallback: (error: Error, resource: any[], urls: string[]) => void): void; + static loadResDir(url: string, type: typeof cc.Asset): void; + static loadResDir(url: string, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any[], urls: string[]) => void)|null): void; + static loadResDir(url: string, completeCallback: (error: Error, resource: any[], urls: string[]) => void): void; + static loadResDir(url: string): void; + /** + Get resource data by id.
+ When you load resources with {{#crossLink "loader/load:method"}}{{/crossLink}} or {{#crossLink "loader/loadRes:method"}}{{/crossLink}}, + the url will be the unique identity of the resource. + After loaded, you can acquire them by passing the url to this API. + @param url url + @param type Only asset of type will be returned if this argument is supplied. + */ + static getRes(url: string, type?: Function): any; + /** + !#en + Get all resource dependencies of the loaded asset in an array, including itself. + The owner parameter accept the following types: 1. The asset itself; 2. The resource url; 3. The asset's uuid.
+ The returned array stores the dependencies with their uuids, after retrieve dependencies, + you can release them, access dependent assets by passing the uuid to {{#crossLink "loader/getRes:method"}}{{/crossLink}}, or other stuffs you want.
+ For release all dependencies of an asset, please refer to {{#crossLink "loader/release:method"}}{{/crossLink}} + Here is some examples: + !#zh + 获取某个已经加载好的资源的所有依赖资源,包含它自身,并保存在数组中返回。owner 参数接收以下几种类型:1. 资源 asset 对象;2. 资源目录下的 url;3. 资源的 uuid。
+ 返回的数组将仅保存依赖资源的 uuid,获取这些 uuid 后,你可以从 loader 释放这些资源;通过 {{#crossLink "loader/getRes:method"}}{{/crossLink}} 获取某个资源或者进行其他你需要的操作。
+ 想要释放一个资源及其依赖资源,可以参考 {{#crossLink "loader/release:method"}}{{/crossLink}}。下面是一些示例代码: + @param owner The owner asset or the resource url or the asset's uuid + + @example + ```js + // Release all dependencies of a loaded prefab + var deps = cc.loader.getDependsRecursively(prefab); + cc.loader.release(deps); + // Retrieve all dependent textures + var deps = cc.loader.getDependsRecursively('prefabs/sample'); + var textures = []; + for (var i = 0; i < deps.length; ++i) { + var item = cc.loader.getRes(deps[i]); + if (item instanceof cc.Texture2D) { + textures.push(item); + } + } + ``` + */ + static getDependsRecursively(owner: Asset|RawAsset|string): any[]; + /** + !#en + Release the content of an asset or an array of assets by uuid. + Start from v1.3, this method will not only remove the cache of the asset in loader, but also clean up its content. + For example, if you release a texture, the texture asset and its gl texture data will be freed up. + In complexe project, you can use this function with {{#crossLink "loader/getDependsRecursively:method"}}{{/crossLink}} to free up memory in critical circumstances. + Notice, this method may cause the texture to be unusable, if there are still other nodes use the same texture, they may turn to black and report gl errors. + If you only want to remove the cache of an asset, please use {{#crossLink "pipeline/removeItem:method"}}{{/crossLink}} + !#zh + 通过 id(通常是资源 url)来释放一个资源或者一个资源数组。 + 从 v1.3 开始,这个方法不仅会从 loader 中删除资源的缓存引用,还会清理它的资源内容。 + 比如说,当你释放一个 texture 资源,这个 texture 和它的 gl 贴图数据都会被释放。 + 在复杂项目中,我们建议你结合 {{#crossLink "loader/getDependsRecursively:method"}}{{/crossLink}} 来使用,便于在设备内存告急的情况下更快地释放不再需要的资源的内存。 + 注意,这个函数可能会导致资源贴图或资源所依赖的贴图不可用,如果场景中存在节点仍然依赖同样的贴图,它们可能会变黑并报 GL 错误。 + 如果你只想删除一个资源的缓存引用,请使用 {{#crossLink "pipeline/removeItem:method"}}{{/crossLink}} + @param asset asset + + @example + ```js + // Release a texture which is no longer need + cc.loader.release(texture); + // Release all dependencies of a loaded prefab + var deps = cc.loader.getDependsRecursively('prefabs/sample'); + cc.loader.release(deps); + // If there is no instance of this prefab in the scene, the prefab and its dependencies like textures, sprite frames, etc, will be freed up. + // If you have some other nodes share a texture in this prefab, you can skip it in two ways: + // 1. Forbid auto release a texture before release + cc.loader.setAutoRelease(texture2d, false); + // 2. Remove it from the dependencies array + var deps = cc.loader.getDependsRecursively('prefabs/sample'); + var index = deps.indexOf(texture2d._uuid); + if (index !== -1) + deps.splice(index, 1); + cc.loader.release(deps); + ``` + */ + static release(asset: Asset|RawAsset|string|any[]): void; + /** + !#en Release the asset by its object. Refer to {{#crossLink "loader/release:method"}}{{/crossLink}} for detailed informations. + !#zh 通过资源对象自身来释放资源。详细信息请参考 {{#crossLink "loader/release:method"}}{{/crossLink}} + @param asset asset + */ + static releaseAsset(asset: Asset): void; + /** + !#en Release the asset loaded by {{#crossLink "loader/loadRes:method"}}{{/crossLink}}. Refer to {{#crossLink "loader/release:method"}}{{/crossLink}} for detailed informations. + !#zh 释放通过 {{#crossLink "loader/loadRes:method"}}{{/crossLink}} 加载的资源。详细信息请参考 {{#crossLink "loader/release:method"}}{{/crossLink}} + @param url url + @param type Only asset of type will be released if this argument is supplied. + */ + static releaseRes(url: string, type?: Function): void; + /** + !#en Release the all assets loaded by {{#crossLink "loader/loadResDir:method"}}{{/crossLink}}. Refer to {{#crossLink "loader/release:method"}}{{/crossLink}} for detailed informations. + !#zh 释放通过 {{#crossLink "loader/loadResDir:method"}}{{/crossLink}} 加载的资源。详细信息请参考 {{#crossLink "loader/release:method"}}{{/crossLink}} + @param url url + @param type Only asset of type will be released if this argument is supplied. + */ + static releaseResDir(url: string, type?: Function): void; + /** + !#en Resource all assets. Refer to {{#crossLink "loader/release:method"}}{{/crossLink}} for detailed informations. + !#zh 释放所有资源。详细信息请参考 {{#crossLink "loader/release:method"}}{{/crossLink}} + */ + static releaseAll(): void; + /** + !#en + Indicates whether to release the asset when loading a new scene.
+ By default, when loading a new scene, all assets in the previous scene will be released or preserved + according to whether the previous scene checked the "Auto Release Assets" option. + On the other hand, assets dynamically loaded by using `cc.loader.loadRes` or `cc.loader.loadResDir` + will not be affected by that option, remain not released by default.
+ Use this API to change the default behavior on a single asset, to force preserve or release specified asset when scene switching.
+
+ See: {{#crossLink "loader/setAutoReleaseRecursively:method"}}cc.loader.setAutoReleaseRecursively{{/crossLink}}, {{#crossLink "loader/isAutoRelease:method"}}cc.loader.isAutoRelease{{/crossLink}} + !#zh + 设置当场景切换时是否自动释放资源。
+ 默认情况下,当加载新场景时,旧场景的资源根据旧场景是否勾选“Auto Release Assets”,将会被释放或者保留。 + 而使用 `cc.loader.loadRes` 或 `cc.loader.loadResDir` 动态加载的资源,则不受场景设置的影响,默认不自动释放。
+ 使用这个 API 可以在单个资源上改变这个默认行为,强制在切换场景时保留或者释放指定资源。
+
+ 参考:{{#crossLink "loader/setAutoReleaseRecursively:method"}}cc.loader.setAutoReleaseRecursively{{/crossLink}},{{#crossLink "loader/isAutoRelease:method"}}cc.loader.isAutoRelease{{/crossLink}} + @param assetOrUrlOrUuid asset object or the raw asset's url or uuid + @param autoRelease indicates whether should release automatically + + @example + ```js + // auto release the texture event if "Auto Release Assets" disabled in current scene + cc.loader.setAutoRelease(texture2d, true); + // don't release the texture even if "Auto Release Assets" enabled in current scene + cc.loader.setAutoRelease(texture2d, false); + // first parameter can be url + cc.loader.setAutoRelease(audioUrl, false); + ``` + */ + static setAutoRelease(assetOrUrlOrUuid: Asset|string, autoRelease: boolean): void; + /** + !#en + Indicates whether to release the asset and its referenced other assets when loading a new scene.
+ By default, when loading a new scene, all assets in the previous scene will be released or preserved + according to whether the previous scene checked the "Auto Release Assets" option. + On the other hand, assets dynamically loaded by using `cc.loader.loadRes` or `cc.loader.loadResDir` + will not be affected by that option, remain not released by default.
+ Use this API to change the default behavior on the specified asset and its recursively referenced assets, to force preserve or release specified asset when scene switching.
+
+ See: {{#crossLink "loader/setAutoRelease:method"}}cc.loader.setAutoRelease{{/crossLink}}, {{#crossLink "loader/isAutoRelease:method"}}cc.loader.isAutoRelease{{/crossLink}} + !#zh + 设置当场景切换时是否自动释放资源及资源引用的其它资源。
+ 默认情况下,当加载新场景时,旧场景的资源根据旧场景是否勾选“Auto Release Assets”,将会被释放或者保留。 + 而使用 `cc.loader.loadRes` 或 `cc.loader.loadResDir` 动态加载的资源,则不受场景设置的影响,默认不自动释放。
+ 使用这个 API 可以在指定资源及资源递归引用到的所有资源上改变这个默认行为,强制在切换场景时保留或者释放指定资源。
+
+ 参考:{{#crossLink "loader/setAutoRelease:method"}}cc.loader.setAutoRelease{{/crossLink}},{{#crossLink "loader/isAutoRelease:method"}}cc.loader.isAutoRelease{{/crossLink}} + @param assetOrUrlOrUuid asset object or the raw asset's url or uuid + @param autoRelease indicates whether should release automatically + + @example + ```js + // auto release the SpriteFrame and its Texture event if "Auto Release Assets" disabled in current scene + cc.loader.setAutoReleaseRecursively(spriteFrame, true); + // don't release the SpriteFrame and its Texture even if "Auto Release Assets" enabled in current scene + cc.loader.setAutoReleaseRecursively(spriteFrame, false); + // don't release the Prefab and all the referenced assets + cc.loader.setAutoReleaseRecursively(prefab, false); + ``` + */ + static setAutoReleaseRecursively(assetOrUrlOrUuid: Asset|string, autoRelease: boolean): void; + /** + !#en + Returns whether the asset is configured as auto released, despite how "Auto Release Assets" property is set on scene asset.
+
+ See: {{#crossLink "loader/setAutoRelease:method"}}cc.loader.setAutoRelease{{/crossLink}}, {{#crossLink "loader/setAutoReleaseRecursively:method"}}cc.loader.setAutoReleaseRecursively{{/crossLink}} + + !#zh + 返回指定的资源是否有被设置为自动释放,不论场景的“Auto Release Assets”如何设置。
+
+ 参考:{{#crossLink "loader/setAutoRelease:method"}}cc.loader.setAutoRelease{{/crossLink}},{{#crossLink "loader/setAutoReleaseRecursively:method"}}cc.loader.setAutoReleaseRecursively{{/crossLink}} + @param assetOrUrl asset object or the raw asset's url + */ + static isAutoRelease(assetOrUrl: Asset|string): boolean; + } + /** !#en + LoadingItems is the queue of items which can flow them into the loading pipeline.
+ Please don't construct it directly, use {{#crossLink "LoadingItems.create"}}cc.LoadingItems.create{{/crossLink}} instead, because we use an internal pool to recycle the queues.
+ It hold a map of items, each entry in the map is a url to object key value pair.
+ Each item always contains the following property:
+ - id: The identification of the item, usually it's identical to url
+ - url: The url
+ - type: The type, it's the extension name of the url by default, could be specified manually too.
+ - error: The error happened in pipeline will be stored in this property.
+ - content: The content processed by the pipeline, the final result will also be stored in this property.
+ - complete: The flag indicate whether the item is completed by the pipeline.
+ - states: An object stores the states of each pipe the item go through, the state can be: Pipeline.ItemState.WORKING | Pipeline.ItemState.ERROR | Pipeline.ItemState.COMPLETE
+
+ Item can hold other custom properties.
+ Each LoadingItems object will be destroyed for recycle after onComplete callback
+ So please don't hold its reference for later usage, you can copy properties in it though. + !#zh + LoadingItems 是一个加载对象队列,可以用来输送加载对象到加载管线中。
+ 请不要直接使用 new 构造这个类的对象,你可以使用 {{#crossLink "LoadingItems.create"}}cc.LoadingItems.create{{/crossLink}} 来创建一个新的加载队列,这样可以允许我们的内部对象池回收并重利用加载队列。 + 它有一个 map 属性用来存放加载项,在 map 对象中以 url 为 key 值。
+ 每个对象都会包含下列属性:
+ - id:该对象的标识,通常与 url 相同。
+ - url:路径
+ - type: 类型,它这是默认的 URL 的扩展名,可以手动指定赋值。
+ - error:pipeline 中发生的错误将被保存在这个属性中。
+ - content: pipeline 中处理的临时结果,最终的结果也将被存储在这个属性中。
+ - complete:该标志表明该对象是否通过 pipeline 完成。
+ - states:该对象存储每个管道中对象经历的状态,状态可以是 Pipeline.ItemState.WORKING | Pipeline.ItemState.ERROR | Pipeline.ItemState.COMPLETE
+
+ 对象可容纳其他自定义属性。
+ 每个 LoadingItems 对象都会在 onComplete 回调之后被销毁,所以请不要持有它的引用并在结束回调之后依赖它的内容执行任何逻辑,有这种需求的话你可以提前复制它的内容。 */ + export class LoadingItems extends CallbacksInvoker { + /** + !#en This is a callback which will be invoked while an item flow out the pipeline. + You can pass the callback function in LoadingItems.create or set it later. + !#zh 这个回调函数将在 item 加载结束后被调用。你可以在构造时传递这个回调函数或者是在构造之后直接设置。 + @param completedCount The number of the items that are already completed. + @param totalCount The total number of the items. + @param item The latest item which flow out the pipeline. + + @example + ```js + loadingItems.onProgress = function (completedCount, totalCount, item) { + var progress = (100 * completedCount / totalCount).toFixed(2); + cc.log(progress + '%'); + } + ``` + */ + onProgress(completedCount: number, totalCount: number, item: any): void; + /** + !#en This is a callback which will be invoked while all items is completed, + You can pass the callback function in LoadingItems.create or set it later. + !#zh 该函数将在加载队列全部完成时被调用。你可以在构造时传递这个回调函数或者是在构造之后直接设置。 + @param errors All errored urls will be stored in this array, if no error happened, then it will be null + @param items All items. + + @example + ```js + loadingItems.onComplete = function (errors, items) { + if (error) + cc.log('Completed with ' + errors.length + ' errors'); + else + cc.log('Completed ' + items.totalCount + ' items'); + } + ``` + */ + onComplete(errors: any[], items: LoadingItems): void; + /** !#en The map of all items. + !#zh 存储所有加载项的对象。 */ + map: any; + /** !#en The map of completed items. + !#zh 存储已经完成的加载项。 */ + completed: any; + /** !#en Total count of all items. + !#zh 所有加载项的总数。 */ + totalCount: number; + /** !#en Total count of completed items. + !#zh 所有完成加载项的总数。 */ + completedCount: number; + /** !#en Activated or not. + !#zh 是否启用。 */ + active: boolean; + /** + !#en The constructor function of LoadingItems, this will use recycled LoadingItems in the internal pool if possible. + You can pass onProgress and onComplete callbacks to visualize the loading process. + !#zh LoadingItems 的构造函数,这种构造方式会重用内部对象缓冲池中的 LoadingItems 队列,以尽量避免对象创建。 + 你可以传递 onProgress 和 onComplete 回调函数来获知加载进度信息。 + @param pipeline The pipeline to process the queue. + @param urlList The items array. + @param onProgress The progression callback, refer to {{#crossLink "LoadingItems.onProgress"}}{{/crossLink}} + @param onComplete The completion callback, refer to {{#crossLink "LoadingItems.onComplete"}}{{/crossLink}} + + @example + ```js + cc.LoadingItems.create(cc.loader, ['a.png', 'b.plist'], function (completedCount, totalCount, item) { + var progress = (100 * completedCount / totalCount).toFixed(2); + cc.log(progress + '%'); + }, function (errors, items) { + if (errors) { + for (var i = 0; i < errors.length; ++i) { + cc.log('Error url: ' + errors[i] + ', error: ' + items.getError(errors[i])); + } + } + else { + var result_a = items.getContent('a.png'); + // ... + } + }) + ``` + */ + static create(pipeline: Pipeline, urlList: any[], onProgress: Function, onComplete: Function): LoadingItems; + /** + !#en Retrieve the LoadingItems queue object for an item. + !#zh 通过 item 对象获取它的 LoadingItems 队列。 + @param item The item to query + */ + static getQueue(item: any): LoadingItems; + /** + !#en Complete an item in the LoadingItems queue, please do not call this method unless you know what's happening. + !#zh 通知 LoadingItems 队列一个 item 对象已完成,请不要调用这个函数,除非你知道自己在做什么。 + @param item The item which has completed + */ + static itemComplete(item: any): void; + /** + !#en Add urls to the LoadingItems queue. + !#zh 向一个 LoadingItems 队列添加加载项。 + @param urlList The url list to be appended, the url can be object or string + */ + append(urlList: any[]): any[]; + /** + !#en Complete a LoadingItems queue, please do not call this method unless you know what's happening. + !#zh 完成一个 LoadingItems 队列,请不要调用这个函数,除非你知道自己在做什么。 + */ + allComplete(): void; + /** + !#en Check whether all items are completed. + !#zh 检查是否所有加载项都已经完成。 + */ + isCompleted(): boolean; + /** + !#en Check whether an item is completed. + !#zh 通过 id 检查指定加载项是否已经加载完成。 + @param id The item's id. + */ + isItemCompleted(id: string): boolean; + /** + !#en Check whether an item exists. + !#zh 通过 id 检查加载项是否存在。 + @param id The item's id. + */ + exists(id: string): boolean; + /** + !#en Returns the content of an internal item. + !#zh 通过 id 获取指定对象的内容。 + @param id The item's id. + */ + getContent(id: string): any; + /** + !#en Returns the error of an internal item. + !#zh 通过 id 获取指定对象的错误信息。 + @param id The item's id. + */ + getError(id: string): any; + /** + !#en Add a listener for an item, the callback will be invoked when the item is completed. + !#zh 监听加载项(通过 key 指定)的完成事件。 + @param key key + @param callback can be null + @param target can be null + */ + addListener(key: string, callback: Function, target: any): boolean; + /** + !#en + Check if the specified key has any registered callback. + If a callback is also specified, it will only return true if the callback is registered. + !#zh + 检查指定的加载项是否有完成事件监听器。 + 如果同时还指定了一个回调方法,并且回调有注册,它只会返回 true。 + @param key key + @param callback callback + @param target target + */ + hasListener(key: string, callback?: Function, target?: any): boolean; + /** + !#en + Removes a listener. + It will only remove when key, callback, target all match correctly. + !#zh + 移除指定加载项已经注册的完成事件监听器。 + 只会删除 key, callback, target 均匹配的监听器。 + @param key key + @param callback callback + @param target target + */ + remove(key: string, callback: Function, target: any): boolean; + /** + !#en + Removes all callbacks registered in a certain event + type or all callbacks registered with a certain target. + !#zh 删除指定目标的所有完成事件监听器。 + @param key The event key to be removed or the target to be removed + */ + removeAllListeners(key: string|any): void; + /** + !#en Complete an item in the LoadingItems queue, please do not call this method unless you know what's happening. + !#zh 通知 LoadingItems 队列一个 item 对象已完成,请不要调用这个函数,除非你知道自己在做什么。 + @param id The item url + */ + itemComplete(id: string): void; + /** + !#en Destroy the LoadingItems queue, the queue object won't be garbage collected, it will be recycled, so every after destroy is not reliable. + !#zh 销毁一个 LoadingItems 队列,这个队列对象会被内部缓冲池回收,所以销毁后的所有内部信息都是不可依赖的。 + */ + destroy(): void; + } + /** !#en + A pipeline describes a sequence of manipulations, each manipulation is called a pipe.
+ It's designed for loading process. so items should be urls, and the url will be the identity of each item during the process.
+ A list of items can flow in the pipeline and it will output the results of all pipes.
+ They flow in the pipeline like water in tubes, they go through pipe by pipe separately.
+ Finally all items will flow out the pipeline and the process is finished. + + !#zh + pipeline 描述了一系列的操作,每个操作都被称为 pipe。
+ 它被设计来做加载过程的流程管理。所以 item 应该是 url,并且该 url 将是在处理中的每个 item 的身份标识。
+ 一个 item 列表可以在 pipeline 中流动,它将输出加载项经过所有 pipe 之后的结果。
+ 它们穿过 pipeline 就像水在管子里流动,将会按顺序流过每个 pipe。
+ 最后当所有加载项都流出 pipeline 时,整个加载流程就结束了。 */ + export class Pipeline { + /** + !#en + Constructor, pass an array of pipes to construct a new Pipeline, + the pipes will be chained in the given order.
+ A pipe is an object which must contain an `id` in string and a `handle` function, + the id must be unique in the pipeline.
+ It can also include `async` property to identify whether it's an asynchronous process. + !#zh + 构造函数,通过一系列的 pipe 来构造一个新的 pipeline,pipes 将会在给定的顺序中被锁定。
+ 一个 pipe 就是一个对象,它包含了字符串类型的 ‘id’ 和 ‘handle’ 函数,在 pipeline 中 id 必须是唯一的。
+ 它还可以包括 ‘async’ 属性以确定它是否是一个异步过程。 + @param pipes pipes + + @example + ```js + var pipeline = new Pipeline([ + { + id: 'Downloader', + handle: function (item, callback) {}, + async: true + }, + {id: 'Parser', handle: function (item) {}, async: false} + ]); + ``` + */ + constructor(pipes: any[]); + /** + !#en + Insert a new pipe at the given index of the pipeline.
+ A pipe must contain an `id` in string and a `handle` function, the id must be unique in the pipeline. + !#zh + 在给定的索引位置插入一个新的 pipe。
+ 一个 pipe 必须包含一个字符串类型的 ‘id’ 和 ‘handle’ 函数,该 id 在 pipeline 必须是唯一标识。 + @param pipe The pipe to be inserted + @param index The index to insert + */ + insertPipe(pipe: any, index: number): void; + /** + !#en + Insert a pipe to the end of an existing pipe. The existing pipe must be a valid pipe in the pipeline. + !#zh + 在当前 pipeline 的一个已知 pipe 后面插入一个新的 pipe。 + @param refPipe An existing pipe in the pipeline. + @param newPipe The pipe to be inserted. + */ + insertPipeAfter(refPipe: any, newPipe: any): void; + /** + !#en + Add a new pipe at the end of the pipeline.
+ A pipe must contain an `id` in string and a `handle` function, the id must be unique in the pipeline. + !#zh + 添加一个新的 pipe 到 pipeline 尾部。
+ 该 pipe 必须包含一个字符串类型 ‘id’ 和 ‘handle’ 函数,该 id 在 pipeline 必须是唯一标识。 + @param pipe The pipe to be appended + */ + appendPipe(pipe: any): void; + /** + !#en + Let new items flow into the pipeline.
+ Each item can be a simple url string or an object, + if it's an object, it must contain `id` property.
+ You can specify its type by `type` property, by default, the type is the extension name in url.
+ By adding a `skips` property including pipe ids, you can skip these pipe.
+ The object can contain any supplementary property as you want.
+ !#zh + 让新的 item 流入 pipeline 中。
+ 这里的每个 item 可以是一个简单字符串类型的 url 或者是一个对象, + 如果它是一个对象的话,他必须要包含 ‘id’ 属性。
+ 你也可以指定它的 ‘type’ 属性类型,默认情况下,该类型是 ‘url’ 的后缀名。
+ 也通过添加一个 包含 ‘skips’ 属性的 item 对象,你就可以跳过 skips 中包含的 pipe。
+ 该对象可以包含任何附加属性。 + @param items items + + @example + ```js + pipeline.flowIn([ + 'res/Background.png', + { + id: 'res/scene.json', + type: 'scene', + name: 'scene', + skips: ['Downloader'] + } + ]); + ``` + */ + flowIn(items: any[]): void; + /** + !#en + Copy the item states from one source item to all destination items.
+ It's quite useful when a pipe generate new items from one source item,
+ then you should flowIn these generated items into pipeline,
+ but you probably want them to skip all pipes the source item already go through,
+ you can achieve it with this API.
+
+ For example, an unzip pipe will generate more items, but you won't want them to pass unzip or download pipe again. + !#zh + 从一个源 item 向所有目标 item 复制它的 pipe 状态,用于避免重复通过部分 pipe。
+ 当一个源 item 生成了一系列新的 items 时很有用,
+ 你希望让这些新的依赖项进入 pipeline,但是又不希望它们通过源 item 已经经过的 pipe,
+ 但是你可能希望他们源 item 已经通过并跳过所有 pipes,
+ 这个时候就可以使用这个 API。 + @param srcItem The source item + @param dstItems A single destination item or an array of destination items + */ + copyItemStates(srcItem: any, dstItems: any[]|any): void; + /** + !#en Returns an item in pipeline. + !#zh 根据 id 获取一个 item + @param id The id of the item + */ + getItem(id: any): any; + /** + !#en Removes an completed item in pipeline. + It will only remove the cache in the pipeline or loader, its dependencies won't be released. + cc.loader provided another method to completely cleanup the resource and its dependencies, + please refer to {{#crossLink "loader/release:method"}}cc.loader.release{{/crossLink}} + !#zh 移除指定的已完成 item。 + 这将仅仅从 pipeline 或者 loader 中删除其缓存,并不会释放它所依赖的资源。 + cc.loader 中提供了另一种删除资源及其依赖的清理方法,请参考 {{#crossLink "loader/release:method"}}cc.loader.release{{/crossLink}} + @param id The id of the item + */ + removeItem(id: any): boolean; + /** + !#en Clear the current pipeline, this function will clean up the items. + !#zh 清空当前 pipeline,该函数将清理 items。 + */ + clear(): void; + } + /** undefined */ + export class WorldManifold { + /** !#en + world contact point (point of intersection) + !#zh + 碰撞点集合 */ + points: Vec2[]; + /** !#en + world vector pointing from A to B + !#zh + 世界坐标系下由 A 指向 B 的向量 */ + normal: Vec2; + } + /** !#en + A manifold point is a contact point belonging to a contact manifold. + It holds details related to the geometry and dynamics of the contact points. + Note: the impulses are used for internal caching and may not + provide reliable contact forces, especially for high speed collisions. + !#zh + ManifoldPoint 是接触信息中的接触点信息。它拥有关于几何和接触点的详细信息。 + 注意:信息中的冲量用于系统内部缓存,提供的接触力可能不是很准确,特别是高速移动中的碰撞信息。 */ + export class ManifoldPoint { + /** !#en + The local point usage depends on the manifold type: + -e_circles: the local center of circleB + -e_faceA: the local center of circleB or the clip point of polygonB + -e_faceB: the clip point of polygonA + !#zh + 本地坐标点的用途取决于 manifold 的类型 + - e_circles: circleB 的本地中心点 + - e_faceA: circleB 的本地中心点 或者是 polygonB 的截取点 + - e_faceB: polygonB 的截取点 */ + localPoint: Vec2; + /** !#en + Normal impulse. + !#zh + 法线冲量。 */ + normalImpulse: number; + /** !#en + Tangent impulse. + !#zh + 切线冲量。 */ + tangentImpulse: number; + } + /** undefined */ + export class Manifold { + /** !#en + Manifold type : 0: e_circles, 1: e_faceA, 2: e_faceB + !#zh + Manifold 类型 : 0: e_circles, 1: e_faceA, 2: e_faceB */ + type: number; + /** !#en + The local point usage depends on the manifold type: + -e_circles: the local center of circleA + -e_faceA: the center of faceA + -e_faceB: the center of faceB + !#zh + 用途取决于 manifold 类型 + -e_circles: circleA 的本地中心点 + -e_faceA: faceA 的本地中心点 + -e_faceB: faceB 的本地中心点 */ + localPoint: Vec2; + /** !#en + -e_circles: not used + -e_faceA: the normal on polygonA + -e_faceB: the normal on polygonB + !#zh + -e_circles: 没被使用到 + -e_faceA: polygonA 的法向量 + -e_faceB: polygonB 的法向量 */ + localNormal: Vec2; + /** !#en + the points of contact. + !#zh + 接触点信息。 */ + points: ManifoldPoint[]; + } + /** !#en + Contact impulses for reporting. + !#zh + 用于返回给回调的接触冲量。 */ + export class PhysicsImpulse { + /** !#en + Normal impulses. + !#zh + 法线方向的冲量 */ + normalImpulses: any; + /** !#en + Tangent impulses + !#zh + 切线方向的冲量 */ + tangentImpulses: any; + } + /** !#en + PhysicsContact will be generated during begin and end collision as a parameter of the collision callback. + Note that contacts will be reused for speed up cpu time, so do not cache anything in the contact. + !#zh + 物理接触会在开始和结束碰撞之间生成,并作为参数传入到碰撞回调函数中。 + 注意:传入的物理接触会被系统进行重用,所以不要在使用中缓存里面的任何信息。 */ + export class PhysicsContact { + /** + !#en + Get the world manifold. + !#zh + 获取世界坐标系下的碰撞信息。 + */ + getWorldManifold(): WorldManifold; + /** + !#en + Get the manifold. + !#zh + 获取本地(局部)坐标系下的碰撞信息。 + */ + getManifold(): Manifold; + /** + !#en + Get the impulses. + Note: PhysicsImpulse can only used in onPostSolve callback. + !#zh + 获取冲量信息 + 注意:这个信息只有在 onPostSolve 回调中才能获取到 + */ + getImpulse(): PhysicsImpulse; + colliderA: Collider; + colliderB: Collider; + /** !#en + If set disabled to true, the contact will be ignored until contact end. + If you just want to disabled contact for current time step or sub-step, please use disabledOnce. + !#zh + 如果 disabled 被设置为 true,那么直到接触结束此接触都将被忽略。 + 如果只是希望在当前时间步或子步中忽略此接触,请使用 disabledOnce 。 */ + disabled: boolean; + /** !#en + Disabled contact for current time step or sub-step. + !#zh + 在当前时间步或子步中忽略此接触。 */ + disabledOnce: boolean; + /** + !#en + Is this contact touching? + !#zh + 返回碰撞体是否已经接触到。 + */ + isTouching(): boolean; + /** + !#en + Set the desired tangent speed for a conveyor belt behavior. + !#zh + 为传送带设置期望的切线速度 + @param tangentSpeed tangentSpeed + */ + setTangentSpeed(tangentSpeed: number): void; + /** + !#en + Get the desired tangent speed. + !#zh + 获取切线速度 + */ + getTangentSpeed(): number; + /** + !#en + Override the default friction mixture. You can call this in onPreSolve callback. + !#zh + 覆盖默认的摩擦力系数。你可以在 onPreSolve 回调中调用此函数。 + @param friction friction + */ + setFriction(friction: number): void; + /** + !#en + Get the friction. + !#zh + 获取当前摩擦力系数 + */ + getFriction(): number; + /** + !#en + Reset the friction mixture to the default value. + !#zh + 重置摩擦力系数到默认值 + */ + resetFriction(): void; + /** + !#en + Override the default restitution mixture. You can call this in onPreSolve callback. + !#zh + 覆盖默认的恢复系数。你可以在 onPreSolve 回调中调用此函数。 + @param restitution restitution + */ + setRestitution(restitution: number): void; + /** + !#en + Get the restitution. + !#zh + 获取当前恢复系数 + */ + getRestitution(): number; + /** + !#en + Reset the restitution mixture to the default value. + !#zh + 重置恢复系数到默认值 + */ + resetRestitution(): void; + } + /** !#en + Physics manager uses box2d as the inner physics system, and hide most box2d implement details(creating rigidbody, synchronize rigidbody info to node). + You can visit some common box2d function through physics manager(hit testing, raycast, debug info). + Physics manager distributes the collision information to each collision callback when collision is produced. + Note: You need first enable the collision listener in the rigidbody. + !#zh + 物理系统将 box2d 作为内部物理系统,并且隐藏了大部分 box2d 实现细节(比如创建刚体,同步刚体信息到节点中等)。 + 你可以通过物理系统访问一些 box2d 常用的功能,比如点击测试,射线测试,设置测试信息等。 + 物理系统还管理碰撞信息的分发,她会在产生碰撞时,将碰撞信息分发到各个碰撞回调中。 + 注意:你需要先在刚体中开启碰撞接听才会产生相应的碰撞回调。
+ 支持的物理系统指定绘制信息事件,请参阅 {{#crossLink "PhysicsManager.DrawBits"}}{{/crossLink}} */ + export class PhysicsManager implements EventTarget { + /** !#en + The ratio transform between physics unit and pixel unit, generally is 32. + !#zh + 物理单位与像素单位互相转换的比率,一般是 32。 */ + static PTM_RATIO: number; + /** !#en + The velocity iterations for the velocity constraint solver. + !#zh + 速度更新迭代数 */ + static VELOCITY_ITERATIONS: number; + /** !#en + The position Iterations for the position constraint solver. + !#zh + 位置迭代更新数 */ + static POSITION_ITERATIONS: number; + /** !#en + Specify the fixed time step. + Need enabledAccumulator to make it work. + !#zh + 指定固定的物理更新间隔时间,需要开启 enabledAccumulator 才有效。 */ + static FIXED_TIME_STEP: number; + /** !#en + Specify the max accumulator time. + Need enabledAccumulator to make it work. + !#zh + 每次可用于更新物理系统的最大时间,需要开启 enabledAccumulator 才有效。 */ + static MAX_ACCUMULATOR: number; + /** !#en + If enabled accumulator, then will call step function with the fixed time step FIXED_TIME_STEP. + And if the update dt is bigger than the time step, then will call step function several times. + If disabled accumulator, then will call step function with a time step calculated with the frame rate. + !#zh + 如果开启此选项,那么将会以固定的间隔时间 FIXED_TIME_STEP 来更新物理引擎,如果一个 update 的间隔时间大于 FIXED_TIME_STEP,则会对物理引擎进行多次更新。 + 如果关闭此选项,那么将会根据设定的 frame rate 计算出一个间隔时间来更新物理引擎。 */ + enabledAccumulator: boolean; + /** + !#en + Test which collider contains the given world point + !#zh + 获取包含给定世界坐标系点的碰撞体 + @param point the world point + */ + testPoint(point: Vec2): PhysicsCollider; + /** + !#en + Test which colliders intersect the given world rect + !#zh + 获取与给定世界坐标系矩形相交的碰撞体 + @param rect the world rect + */ + testAABB(rect: Rect): PhysicsCollider[]; + /** + !#en + Raycast the world for all colliders in the path of the ray. + The raycast ignores colliders that contain the starting point. + !#zh + 检测哪些碰撞体在给定射线的路径上,射线检测将忽略包含起始点的碰撞体。 + @param p1 start point of the raycast + @param p2 end point of the raycast + @param type optional, default is RayCastType.Closest + */ + rayCast(p1: Vec2, p2: Vec2, type: RayCastType): PhysicsRayCastResult[]; + /** !#en + Enabled the physics manager? + !#zh + 指定是否启用物理系统? */ + enabled: boolean; + /** !#en + Debug draw flags. + !#zh + 设置调试绘制标志 */ + debugDrawFlags: number; + /** !#en + The physics world gravity. + !#zh + 物理世界重力值 */ + gravity: Vec2; + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en + Register an callback of a specific event type on the EventTarget. + This type of event should be triggered via `emit`. + !#zh + 注册事件目标的特定事件类型回调。这种类型的事件应该被 `emit` 触发。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, node); + ``` + */ + on(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. + !#zh + 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + + @example + ```js + // register fire eventListener + var callback = eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, target); + // remove fire event listener + eventTarget.off('fire', callback, target); + // remove all fire event listeners + eventTarget.off('fire'); + ``` + */ + off(type: string, callback?: Function, target?: any): void; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.once('fire', function () { + cc.log("this is the callback and will be invoked only once"); + }, node); + ``` + */ + once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; + /** + !#en + Send an event with the event object. + !#zh + 通过事件对象派发事件 + @param event event + */ + dispatchEvent(event: Event): void; + } + /** undefined */ + export class PhysicsRayCastResult { + /** !#en + The PhysicsCollider which intersects with the raycast + !#zh + 与射线相交的碰撞体 */ + collider: PhysicsCollider; + /** !#en + The intersection point + !#zh + 射线与碰撞体相交的点 */ + point: Vec2; + /** !#en + The normal vector at the point of intersection + !#zh + 射线与碰撞体相交的点的法向量 */ + normal: Vec2; + /** !#en + The fraction of the raycast path at the point of intersection + !#zh + 射线与碰撞体相交的点占射线长度的分数 */ + fraction: number; + } + /** !#en Enum for RigidBodyType. + !#zh 刚体类型 */ + export enum RigidBodyType { + Static = 0, + Kinematic = 0, + Dynamic = 0, + Animated = 0, + } + /** !#en Enum for RayCastType. + !#zh 射线检测类型 */ + export enum RayCastType { + Closest = 0, + Any = 0, + AllClosest = 0, + All = 0, + } + /** undefined */ + export class RigidBody extends Component { + /** !#en + Should enabled contact listener? + When a collision is trigger, the collision callback will only be called when enabled contact listener. + !#zh + 是否启用接触接听器。 + 当 collider 产生碰撞时,只有开启了接触接听器才会调用相应的回调函数 */ + enabledContactListener: boolean; + /** + !#en + Collision callback. + Called when two collider begin to touch. + !#zh + 碰撞回调。 + 如果你的脚本中实现了这个函数,那么它将会在两个碰撞体开始接触时被调用。 + @param contact contact information + @param selfCollider the collider belong to this rigidbody + @param otherCollider the collider belong to another rigidbody + */ + onBeginContact(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void; + /** + !#en + Collision callback. + Called when two collider cease to touch. + !#zh + 碰撞回调。 + 如果你的脚本中实现了这个函数,那么它将会在两个碰撞体停止接触时被调用。 + @param contact contact information + @param selfCollider the collider belong to this rigidbody + @param otherCollider the collider belong to another rigidbody + */ + onEndContact(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void; + /** + !#en + Collision callback. + This is called when a contact is updated. + This allows you to inspect a contact before it goes to the solver(e.g. disable contact). + Note: this is called only for awake bodies. + Note: this is called even when the number of contact points is zero. + Note: this is not called for sensors. + !#zh + 碰撞回调。 + 如果你的脚本中实现了这个函数,那么它将会在接触更新时被调用。 + 你可以在接触被处理前根据他包含的信息作出相应的处理,比如将这个接触禁用掉。 + 注意:回调只会为醒着的刚体调用。 + 注意:接触点为零的时候也有可能被调用。 + 注意:感知体(sensor)的回调不会被调用。 + @param contact contact information + @param selfCollider the collider belong to this rigidbody + @param otherCollider the collider belong to another rigidbody + */ + onPreSolve(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void; + /** + !#en + Collision callback. + This is called after a contact is updated. + You can get the impulses from the contact in this callback. + !#zh + 碰撞回调。 + 如果你的脚本中实现了这个函数,那么它将会在接触更新完后被调用。 + 你可以在这个回调中从接触信息中获取到冲量信息。 + @param contact contact information + @param selfCollider the collider belong to this rigidbody + @param otherCollider the collider belong to another rigidbody + */ + onPostSolve(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void; + /** !#en + Is this a fast moving body that should be prevented from tunneling through + other moving bodies? + Note : + - All bodies are prevented from tunneling through kinematic and static bodies. This setting is only considered on dynamic bodies. + - You should use this flag sparingly since it increases processing time. + !#zh + 这个刚体是否是一个快速移动的刚体,并且需要禁止穿过其他快速移动的刚体? + 需要注意的是 : + - 所有刚体都被禁止从 运动刚体 和 静态刚体 中穿过。此选项只关注于 动态刚体。 + - 应该尽量少的使用此选项,因为它会增加程序处理时间。 */ + bullet: boolean; + /** !#en + Rigidbody type : Static, Kinematic, Dynamic or Animated. + !#zh + 刚体类型: Static, Kinematic, Dynamic or Animated. */ + type: RigidBodyType; + /** !#en + Set this flag to false if this body should never fall asleep. + Note that this increases CPU usage. + !#zh + 如果此刚体永远都不应该进入睡眠,那么设置这个属性为 false。 + 需要注意这将使 CPU 占用率提高。 */ + allowSleep: boolean; + /** !#en + Scale the gravity applied to this body. + !#zh + 缩放应用在此刚体上的重力值 */ + gravityScale: number; + /** !#en + Linear damping is use to reduce the linear velocity. + The damping parameter can be larger than 1, but the damping effect becomes sensitive to the + time step when the damping parameter is large. + !#zh + Linear damping 用于衰减刚体的线性速度。衰减系数可以大于 1,但是当衰减系数比较大的时候,衰减的效果会变得比较敏感。 */ + linearDamping: number; + /** !#en + Angular damping is use to reduce the angular velocity. The damping parameter + can be larger than 1 but the damping effect becomes sensitive to the + time step when the damping parameter is large. + !#zh + Angular damping 用于衰减刚体的角速度。衰减系数可以大于 1,但是当衰减系数比较大的时候,衰减的效果会变得比较敏感。 */ + angularDamping: number; + /** !#en + The linear velocity of the body's origin in world co-ordinates. + !#zh + 刚体在世界坐标下的线性速度 */ + linearVelocity: Vec2; + /** !#en + The angular velocity of the body. + !#zh + 刚体的角速度 */ + angularVelocity: number; + /** !#en + Should this body be prevented from rotating? + !#zh + 是否禁止此刚体进行旋转 */ + fixedRotation: boolean; + /** !#en + Set the sleep state of the body. A sleeping body has very low CPU cost.(When the rigid body is hit, if the rigid body is in sleep state, it will be immediately awakened.) + !#zh + 设置刚体的睡眠状态。 睡眠的刚体具有非常低的 CPU 成本。(当刚体被碰撞到时,如果刚体处于睡眠状态,它会立即被唤醒) */ + awake: boolean; + /** !#en + Whether to wake up this rigid body during initialization + !#zh + 是否在初始化时唤醒此刚体 */ + awakeOnLoad: boolean; + /** !#en + Set the active state of the body. An inactive body is not + simulated and cannot be collided with or woken up. + If body is active, all fixtures will be added to the + broad-phase. + If body is inactive, all fixtures will be removed from + the broad-phase and all contacts will be destroyed. + Fixtures on an inactive body are implicitly inactive and will + not participate in collisions, ray-casts, or queries. + Joints connected to an inactive body are implicitly inactive. + !#zh + 设置刚体的激活状态。一个非激活状态下的刚体是不会被模拟和碰撞的,不管它是否处于睡眠状态下。 + 如果刚体处于激活状态下,所有夹具会被添加到 粗测阶段(broad-phase)。 + 如果刚体处于非激活状态下,所有夹具会被从 粗测阶段(broad-phase)中移除。 + 在非激活状态下的夹具不会参与到碰撞,射线,或者查找中 + 链接到非激活状态下刚体的关节也是非激活的。 */ + active: boolean; + /** + !#en + Gets a local point relative to the body's origin given a world point. + !#zh + 将一个给定的世界坐标系下的点转换为刚体本地坐标系下的点 + @param worldPoint a point in world coordinates. + @param out optional, the receiving point + */ + getLocalPoint(worldPoint: Vec2, out: Vec2): Vec2; + /** + !#en + Get the world coordinates of a point given the local coordinates. + !#zh + 将一个给定的刚体本地坐标系下的点转换为世界坐标系下的点 + @param localPoint a point in local coordinates. + @param out optional, the receiving point + */ + getWorldPoint(localPoint: Vec2, out: Vec2): Vec2; + /** + !#en + Get the world coordinates of a vector given the local coordinates. + !#zh + 将一个给定的世界坐标系下的向量转换为刚体本地坐标系下的向量 + @param localVector a vector in world coordinates. + @param out optional, the receiving vector + */ + getWorldVector(localVector: Vec2, out: Vec2): Vec2; + /** + !#en + Gets a local vector relative to the body's origin given a world vector. + !#zh + 将一个给定的世界坐标系下的点转换为刚体本地坐标系下的点 + @param worldVector a vector in world coordinates. + @param out optional, the receiving vector + */ + getLocalVector(worldVector: Vec2, out: Vec2): Vec2; + /** + !#en + Get the world body origin position. + !#zh + 获取刚体世界坐标系下的原点值 + @param out optional, the receiving point + */ + getWorldPosition(out: Vec2): Vec2; + /** + !#en + Get the world body rotation angle. + !#zh + 获取刚体世界坐标系下的旋转值。 + */ + getWorldRotation(): number; + /** + !#en + Get the local position of the center of mass. + !#zh + 获取刚体本地坐标系下的质心 + */ + getLocalCenter(): Vec2; + /** + !#en + Get the world position of the center of mass. + !#zh + 获取刚体世界坐标系下的质心 + */ + getWorldCenter(): Vec2; + /** + !#en + Get the world linear velocity of a world point attached to this body. + !#zh + 获取刚体上指定点的线性速度 + @param worldPoint a point in world coordinates. + @param out optional, the receiving point + */ + getLinearVelocityFromWorldPoint(worldPoint: Vec2, out: Vec2): Vec2; + /** + !#en + Get total mass of the body. + !#zh + 获取刚体的质量。 + */ + getMass(): number; + /** + !#en + Get the rotational inertia of the body about the local origin. + !#zh + 获取刚体本地坐标系下原点的旋转惯性 + */ + getInertia(): number; + /** + !#en + Get all the joints connect to the rigidbody. + !#zh + 获取链接到此刚体的所有关节 + */ + getJointList(): Joint[]; + /** + !#en + Apply a force at a world point. If the force is not + applied at the center of mass, it will generate a torque and + affect the angular velocity. + !#zh + 施加一个力到刚体上的一个点。如果力没有施加到刚体的质心上,还会产生一个扭矩并且影响到角速度。 + @param force the world force vector. + @param point the world position. + @param wake also wake up the body. + */ + applyForce(force: Vec2, point: Vec2, wake: boolean): void; + /** + !#en + Apply a force to the center of mass. + !#zh + 施加一个力到刚体上的质心上。 + @param force the world force vector. + @param wake also wake up the body. + */ + applyForceToCenter(force: Vec2, wake: boolean): void; + /** + !#en + Apply a torque. This affects the angular velocity. + !#zh + 施加一个扭矩力,将影响刚体的角速度 + @param torque about the z-axis (out of the screen), usually in N-m. + @param wake also wake up the body + */ + applyTorque(torque: number, wake: boolean): void; + /** + !#en + Apply a impulse at a world point, This immediately modifies the velocity. + If the impulse is not applied at the center of mass, it will generate a torque and + affect the angular velocity. + !#zh + 施加冲量到刚体上的一个点,将立即改变刚体的线性速度。 + 如果冲量施加到的点不是刚体的质心,那么将产生一个扭矩并影响刚体的角速度。 + @param impulse the world impulse vector, usually in N-seconds or kg-m/s. + @param point the world position + @param wake alse wake up the body + */ + applyLinearImpulse(impulse: Vec2, point: Vec2, wake: boolean): void; + /** + !#en + Apply an angular impulse. + !#zh + 施加一个角速度冲量。 + @param impulse the angular impulse in units of kg*m*m/s + @param wake also wake up the body + */ + applyAngularImpulse(impulse: number, wake: boolean): void; + /** + !#en + Synchronize node's world position to box2d rigidbody's position. + If enableAnimated is true and rigidbody's type is Animated type, + will set linear velocity instead of directly set rigidbody's position. + !#zh + 同步节点的世界坐标到 box2d 刚体的坐标上。 + 如果 enableAnimated 是 true,并且刚体的类型是 Animated ,那么将设置刚体的线性速度来代替直接设置刚体的位置。 + @param enableAnimated enableAnimated + */ + syncPosition(enableAnimated: boolean): void; + /** + !#en + Synchronize node's world angle to box2d rigidbody's angle. + If enableAnimated is true and rigidbody's type is Animated type, + will set angular velocity instead of directly set rigidbody's angle. + !#zh + 同步节点的世界旋转角度值到 box2d 刚体的旋转值上。 + 如果 enableAnimated 是 true,并且刚体的类型是 Animated ,那么将设置刚体的角速度来代替直接设置刚体的角度。 + @param enableAnimated enableAnimated + */ + syncRotation(enableAnimated: boolean): void; + } + /** !#en the device accelerometer reports values for each axis in units of g-force. + !#zh 设备重力传感器传递的各个轴的数据。 */ + export class constructor { + /** + whether enable accelerometer event + @param isEnable isEnable + */ + setAccelerometerEnabled(isEnable: boolean): void; + /** + set accelerometer interval value + @param interval interval + */ + setAccelerometerInterval(interval: number): void; + } + /** Predefined constants */ + export class macro { + /** PI / 180 */ + static RAD: number; + /** One degree */ + static DEG: number; + static REPEAT_FOREVER: number; + static FLT_EPSILON: number; + /** Minimum z index value for node */ + static MIN_ZINDEX: number; + /** Maximum z index value for node */ + static MAX_ZINDEX: number; + static ONE: number; + static ZERO: number; + static SRC_ALPHA: number; + static SRC_ALPHA_SATURATE: number; + static SRC_COLOR: number; + static DST_ALPHA: number; + static DST_COLOR: number; + static ONE_MINUS_SRC_ALPHA: number; + static ONE_MINUS_SRC_COLOR: number; + static ONE_MINUS_DST_ALPHA: number; + static ONE_MINUS_DST_COLOR: number; + static ONE_MINUS_CONSTANT_ALPHA: number; + static ONE_MINUS_CONSTANT_COLOR: number; + /** Oriented vertically */ + static ORIENTATION_PORTRAIT: number; + /** Oriented horizontally */ + static ORIENTATION_LANDSCAPE: number; + /** Oriented automatically */ + static ORIENTATION_AUTO: number; + /**

+ If enabled, the texture coordinates will be calculated by using this formula:
+ - texCoord.left = (rect.x*2+1) / (texture.wide*2);
+ - texCoord.right = texCoord.left + (rect.width*2-2)/(texture.wide*2);
+
+ The same for bottom and top.
+
+ This formula prevents artifacts by using 99% of the texture.
+ The "correct" way to prevent artifacts is by expand the texture's border with the same color by 1 pixel
+
+ Affected component:
+ - cc.TMXLayer
+
+ Enabled by default. To disabled set it to 0.
+ To modify it, in Web engine please refer to CCMacro.js, in JSB please refer to CCConfig.h +

*/ + static FIX_ARTIFACTS_BY_STRECHING_TEXEL_TMX: number; + /** Position of the FPS (Default: 0,0 (bottom-left corner))
+ To modify it, in Web engine please refer to CCMacro.js, in JSB please refer to CCConfig.h */ + static DIRECTOR_STATS_POSITION: Vec2; + /**

+ If enabled, actions that alter the position property (eg: CCMoveBy, CCJumpBy, CCBezierBy, etc..) will be stacked.
+ If you run 2 or more 'position' actions at the same time on a node, then end position will be the sum of all the positions.
+ If disabled, only the last run action will take effect. +

*/ + static ENABLE_STACKABLE_ACTIONS: number; + /** !#en + The timeout to determine whether a touch is no longer active and should be removed. + The reason to add this timeout is due to an issue in X5 browser core, + when X5 is presented in wechat on Android, if a touch is glissed from the bottom up, and leave the page area, + no touch cancel event is triggered, and the touch will be considered active forever. + After multiple times of this action, our maximum touches number will be reached and all new touches will be ignored. + So this new mechanism can remove the touch that should be inactive if it's not updated during the last 5000 milliseconds. + Though it might remove a real touch if it's just not moving for the last 5 seconds which is not easy with the sensibility of mobile touch screen. + You can modify this value to have a better behavior if you find it's not enough. + !#zh + 用于甄别一个触点对象是否已经失效并且可以被移除的延时时长 + 添加这个时长的原因是 X5 内核在微信浏览器中出现的一个 bug。 + 在这个环境下,如果用户将一个触点从底向上移出页面区域,将不会触发任何 touch cancel 或 touch end 事件,而这个触点会被永远当作停留在页面上的有效触点。 + 重复这样操作几次之后,屏幕上的触点数量将达到我们的事件系统所支持的最高触点数量,之后所有的触摸事件都将被忽略。 + 所以这个新的机制可以在触点在一定时间内没有任何更新的情况下视为失效触点并从事件系统中移除。 + 当然,这也可能移除一个真实的触点,如果用户的触点真的在一定时间段内完全没有移动(这在当前手机屏幕的灵敏度下会很难)。 + 你可以修改这个值来获得你需要的效果,默认值是 5000 毫秒。 */ + static TOUCH_TIMEOUT: number; + /** !#en + The maximum vertex count for a single batched draw call. + !#zh + 最大可以被单次批处理渲染的顶点数量。 */ + static BATCH_VERTEX_COUNT: number; + /** !#en + Whether or not enabled tiled map auto culling. If you set the TiledMap skew or rotation, then need to manually disable this, otherwise, the rendering will be wrong. + !#zh + 是否开启瓦片地图的自动裁减功能。瓦片地图如果设置了 skew, rotation 或者采用了摄像机的话,需要手动关闭,否则渲染会出错。 */ + static ENABLE_TILEDMAP_CULLING: boolean; + /** !#en + The max concurrent task number for the downloader + !#zh + 下载任务的最大并发数限制,在安卓平台部分机型或版本上可能需要限制在较低的水平 */ + static DOWNLOAD_MAX_CONCURRENT: number; + /** !#en + Boolean that indicates if the canvas contains an alpha channel, default sets to false for better performance. + Though if you want to make your canvas background transparent and show other dom elements at the background, + you can set it to true before `cc.game.run`. + Web only. + !#zh + 用于设置 Canvas 背景是否支持 alpha 通道,默认为 false,这样可以有更高的性能表现。 + 如果你希望 Canvas 背景是透明的,并显示背后的其他 DOM 元素,你可以在 `cc.game.run` 之前将这个值设为 true。 + 仅支持 Web */ + static ENABLE_TRANSPARENT_CANVAS: boolean; + /** !#en + Boolean that indicates if the WebGL context is created with `antialias` option turned on, default value is false. + Set it to true could make your game graphics slightly smoother, like texture hard edges when rotated. + Whether to use this really depend on your game design and targeted platform, + device with retina display usually have good detail on graphics with or without this option, + you probably don't want antialias if your game style is pixel art based. + Also, it could have great performance impact with some browser / device using software MSAA. + You can set it to true before `cc.game.run`. + Web only. + !#zh + 用于设置在创建 WebGL Context 时是否开启抗锯齿选项,默认值是 false。 + 将这个选项设置为 true 会让你的游戏画面稍稍平滑一些,比如旋转硬边贴图时的锯齿。是否开启这个选项很大程度上取决于你的游戏和面向的平台。 + 在大多数拥有 retina 级别屏幕的设备上用户往往无法区分这个选项带来的变化;如果你的游戏选择像素艺术风格,你也多半不会想开启这个选项。 + 同时,在少部分使用软件级别抗锯齿算法的设备或浏览器上,这个选项会对性能产生比较大的影响。 + 你可以在 `cc.game.run` 之前设置这个值,否则它不会生效。 + 仅支持 Web */ + static ENABLE_WEBGL_ANTIALIAS: boolean; + /** !#en + Whether or not enable auto culling. + This feature have been removed in v2.0 new renderer due to overall performance consumption. + We have no plan currently to re-enable auto culling. + If your game have more dynamic objects, we suggest to disable auto culling. + If your game have more static objects, we suggest to enable auto culling. + !#zh + 是否开启自动裁减功能,开启裁减功能将会把在屏幕外的物体从渲染队列中去除掉。 + 这个功能在 v2.0 的新渲染器中被移除了,因为它在大多数游戏中所带来的损耗要高于性能的提升,目前我们没有计划重新支持自动裁剪。 + 如果游戏中的动态物体比较多的话,建议将此选项关闭。 + 如果游戏中的静态物体比较多的话,建议将此选项打开。 */ + static ENABLE_CULLING: boolean; + /** !#en + Whether to clear the original image cache after uploaded a texture to GPU. If cleared, [Dynamic Atlas](https://docs.cocos.com/creator/manual/en/advanced-topics/dynamic-atlas.html) will not be supported. + Normally you don't need to enable this option on the web platform, because Image object doesn't consume too much memory. + But on WeChat Game platform, the current version cache decoded data in Image object, which has high memory usage. + So we enabled this option by default on WeChat, so that we can release Image cache immediately after uploaded to GPU. + !#zh + 是否在将贴图上传至 GPU 之后删除原始图片缓存,删除之后图片将无法进行 [动态合图](https://docs.cocos.com/creator/manual/zh/advanced-topics/dynamic-atlas.html)。 + 在 Web 平台,你通常不需要开启这个选项,因为在 Web 平台 Image 对象所占用的内存很小。 + 但是在微信小游戏平台的当前版本,Image 对象会缓存解码后的图片数据,它所占用的内存空间很大。 + 所以我们在微信平台默认开启了这个选项,这样我们就可以在上传 GL 贴图之后立即释放 Image 对象的内存,避免过高的内存占用。 */ + static CLEANUP_IMAGE_CACHE: boolean; + /** !#en + Whether or not show mesh wire frame. + !#zh + 是否显示网格的线框。 */ + static SHOW_MESH_WIREFRAME: boolean; + /** !#en + Whether or not show mesh normal. + !#zh + 是否显示网格的法线。 */ + static SHOW_MESH_NORMAL: boolean; + /** !#en + Whether to enable multi-touch. + !#zh + 是否开启多点触摸 */ + static ENABLE_MULTI_TOUCH: boolean; + /** !#en + The image format supported by the engine defaults, and the supported formats may differ in different build platforms and device types. + Currently all platform and device support ['.webp', '.jpg', '.jpeg', '.bmp', '.png'], The iOS mobile platform also supports the PVR format。 + !#zh + 引擎默认支持的图片格式,支持的格式可能在不同的构建平台和设备类型上有所差别。 + 目前所有平台和设备支持的格式有 ['.webp', '.jpg', '.jpeg', '.bmp', '.png']. 另外 Ios 手机平台还额外支持了 PVR 格式。 */ + static SUPPORT_TEXTURE_FORMATS: string[]; + } + /** undefined */ + export enum VerticalTextAlignment { + TOP = 0, + CENTER = 0, + BOTTOM = 0, + } + /** The base class of most of all the objects in Fireball. */ + export class Object { + /** !#en The name of the object. + !#zh 该对象的名称。 */ + name: string; + /** !#en + Indicates whether the object is not yet destroyed. (It will not be available after being destroyed)
+ When an object's `destroy` is called, it is actually destroyed after the end of this frame. + So `isValid` will return false from the next frame, while `isValid` in the current frame will still be true. + If you want to determine whether the current frame has called `destroy`, use `cc.isValid(obj, true)`, + but this is often caused by a particular logical requirements, which is not normally required. + + !#zh + 表示该对象是否可用(被 destroy 后将不可用)。
+ 当一个对象的 `destroy` 调用以后,会在这一帧结束后才真正销毁。因此从下一帧开始 `isValid` 就会返回 false,而当前帧内 `isValid` 仍然会是 true。如果希望判断当前帧是否调用过 `destroy`,请使用 `cc.isValid(obj, true)`,不过这往往是特殊的业务需求引起的,通常情况下不需要这样。 */ + isValid: boolean; + /** + !#en + Destroy this Object, and release all its own references to other objects.
+ Actual object destruction will delayed until before rendering. + From the next frame, this object is not usable any more. + You can use cc.isValid(obj) to check whether the object is destroyed before accessing it. + !#zh + 销毁该对象,并释放所有它对其它对象的引用。
+ 实际销毁操作会延迟到当前帧渲染前执行。从下一帧开始,该对象将不再可用。 + 您可以在访问对象之前使用 cc.isValid(obj) 来检查对象是否已被销毁。 + + @example + ```js + obj.destroy(); + ``` + */ + destroy(): boolean; + } + /** Bit mask that controls object states. */ + export enum Flags { + DontSave = 0, + EditorOnly = 0, + HideInHierarchy = 0, + } + /** The fullscreen API provides an easy way for web content to be presented using the user's entire screen. + It's invalid on safari, QQbrowser and android browser */ + export class screen { + /** + initialize + */ + init(): void; + /** + return true if it's full now. + */ + fullScreen(): boolean; + /** + change the screen to full mode. + @param element element + @param onFullScreenChange onFullScreenChange + @param onFullScreenError onFullScreenError + */ + requestFullScreen(element: Element, onFullScreenChange: Function, onFullScreenError: Function): void; + /** + exit the full mode. + */ + exitFullScreen(): boolean; + /** + Automatically request full screen with a touch/click event + @param element element + @param onFullScreenChange onFullScreenChange + */ + autoFullScreen(element: Element, onFullScreenChange: Function): void; + } + /** System variables */ + export class sys { + /** English language code */ + static LANGUAGE_ENGLISH: string; + /** Chinese language code */ + static LANGUAGE_CHINESE: string; + /** French language code */ + static LANGUAGE_FRENCH: string; + /** Italian language code */ + static LANGUAGE_ITALIAN: string; + /** German language code */ + static LANGUAGE_GERMAN: string; + /** Spanish language code */ + static LANGUAGE_SPANISH: string; + /** Spanish language code */ + static LANGUAGE_DUTCH: string; + /** Russian language code */ + static LANGUAGE_RUSSIAN: string; + /** Korean language code */ + static LANGUAGE_KOREAN: string; + /** Japanese language code */ + static LANGUAGE_JAPANESE: string; + /** Hungarian language code */ + static LANGUAGE_HUNGARIAN: string; + /** Portuguese language code */ + static LANGUAGE_PORTUGUESE: string; + /** Arabic language code */ + static LANGUAGE_ARABIC: string; + /** Norwegian language code */ + static LANGUAGE_NORWEGIAN: string; + /** Polish language code */ + static LANGUAGE_POLISH: string; + /** Turkish language code */ + static LANGUAGE_TURKISH: string; + /** Ukrainian language code */ + static LANGUAGE_UKRAINIAN: string; + /** Romanian language code */ + static LANGUAGE_ROMANIAN: string; + /** Bulgarian language code */ + static LANGUAGE_BULGARIAN: string; + /** Unknown language code */ + static LANGUAGE_UNKNOWN: string; + static OS_IOS: string; + static OS_ANDROID: string; + static OS_WINDOWS: string; + static OS_MARMALADE: string; + static OS_LINUX: string; + static OS_BADA: string; + static OS_BLACKBERRY: string; + static OS_OSX: string; + static OS_WP8: string; + static OS_WINRT: string; + static OS_UNKNOWN: string; + static UNKNOWN: number; + static WIN32: number; + static LINUX: number; + static MACOS: number; + static ANDROID: number; + static IPHONE: number; + static IPAD: number; + static BLACKBERRY: number; + static NACL: number; + static EMSCRIPTEN: number; + static TIZEN: number; + static WINRT: number; + static WP8: number; + static MOBILE_BROWSER: number; + static DESKTOP_BROWSER: number; + /** Indicates whether executes in editor's window process (Electron's renderer context) */ + static EDITOR_PAGE: number; + /** Indicates whether executes in editor's main process (Electron's browser context) */ + static EDITOR_CORE: number; + static WECHAT_GAME: number; + static QQ_PLAY: number; + static FB_PLAYABLE_ADS: number; + static BAIDU_GAME: number; + static VIVO_GAME: number; + static OPPO_GAME: number; + static HUAWEI_GAME: number; + static XIAOMI_GAME: number; + static JKW_GAME: number; + static ALIPAY_GAME: number; + static WECHAT_GAME_SUB: number; + static BAIDU_GAME_SUB: number; + static QTT_GAME: number; + /** BROWSER_TYPE_WECHAT */ + static BROWSER_TYPE_WECHAT: string; + /** BROWSER_TYPE_WECHAT_GAME */ + static BROWSER_TYPE_WECHAT_GAME: string; + /** BROWSER_TYPE_WECHAT_GAME_SUB */ + static BROWSER_TYPE_WECHAT_GAME_SUB: string; + /** BROWSER_TYPE_BAIDU_GAME */ + static BROWSER_TYPE_BAIDU_GAME: string; + /** BROWSER_TYPE_BAIDU_GAME_SUB */ + static BROWSER_TYPE_BAIDU_GAME_SUB: string; + /** BROWSER_TYPE_XIAOMI_GAME */ + static BROWSER_TYPE_XIAOMI_GAME: string; + /** BROWSER_TYPE_ALIPAY_GAME */ + static BROWSER_TYPE_ALIPAY_GAME: string; + /** BROWSER_TYPE_QQ_PLAY */ + static BROWSER_TYPE_QQ_PLAY: string; + static BROWSER_TYPE_ANDROID: string; + static BROWSER_TYPE_IE: string; + static BROWSER_TYPE_EDGE: string; + static BROWSER_TYPE_QQ: string; + static BROWSER_TYPE_MOBILE_QQ: string; + static BROWSER_TYPE_UC: string; + /** uc third party integration. */ + static BROWSER_TYPE_UCBS: string; + static BROWSER_TYPE_360: string; + static BROWSER_TYPE_BAIDU_APP: string; + static BROWSER_TYPE_BAIDU: string; + static BROWSER_TYPE_MAXTHON: string; + static BROWSER_TYPE_OPERA: string; + static BROWSER_TYPE_OUPENG: string; + static BROWSER_TYPE_MIUI: string; + static BROWSER_TYPE_FIREFOX: string; + static BROWSER_TYPE_SAFARI: string; + static BROWSER_TYPE_CHROME: string; + static BROWSER_TYPE_LIEBAO: string; + static BROWSER_TYPE_QZONE: string; + static BROWSER_TYPE_SOUGOU: string; + static BROWSER_TYPE_UNKNOWN: string; + /** Is native ? This is set to be true in jsb auto. */ + static isNative: boolean; + /** Is web browser ? */ + static isBrowser: boolean; + /** + Is webgl extension support? + @param name name + */ + static glExtension(name: any): void; + /** + Get max joint matrix size for skinned mesh renderer. + */ + static getMaxJointMatrixSize(): void; + /** Indicate whether system is mobile system */ + static isMobile: boolean; + /** Indicate the running platform */ + static platform: number; + /** Get current language iso 639-1 code. + Examples of valid language codes include "zh-tw", "en", "en-us", "fr", "fr-fr", "es-es", etc. + The actual value totally depends on results provided by destination platform. */ + static languageCode: string; + /** Indicate the current language of the running system */ + static language: string; + /** Indicate the running os name */ + static os: string; + /** Indicate the running os version */ + static osVersion: string; + /** Indicate the running os main version */ + static osMainVersion: number; + /** Indicate the running browser type */ + static browserType: string; + /** Indicate the running browser version */ + static browserVersion: string; + /** Indicate the real pixel resolution of the whole game window */ + static windowPixelResolution: Size; + /** cc.sys.localStorage is a local storage component. */ + static localStorage: any; + /** The capabilities of the current platform */ + static capabilities: any; + /** + !#en + Get the network type of current device, return cc.sys.NetworkType.LAN if failure. + !#zh + 获取当前设备的网络类型, 如果网络类型无法获取,默认将返回 cc.sys.NetworkType.LAN + */ + static getNetworkType(): sys.NetworkType; + /** + !#en + Get the battery level of current device, return 1.0 if failure. + !#zh + 获取当前设备的电池电量,如果电量无法获取,默认将返回 1 + */ + static getBatteryLevel(): number; + /** + Forces the garbage collection, only available in JSB + */ + static garbageCollect(): void; + /** + Restart the JS VM, only available in JSB + */ + static restartVM(): void; + /** + !#en + Return the safe area rect.
+ only available on the iOS native platform, otherwise it will return a rect with design resolution size. + !#zh + 返回手机屏幕安全区域,目前仅在 iOS 原生平台有效。其它平台将默认返回设计分辨率尺寸。 + */ + static getSafeAreaRect(): Rect; + /** + Check whether an object is valid, + In web engine, it will return true if the object exist + In native engine, it will return true if the JS object and the correspond native object are both valid + @param obj obj + */ + static isObjectValid(obj: any): boolean; + /** + Dump system informations + */ + static dump(): void; + /** + Open a url in browser + @param url url + */ + static openURL(url: string): void; + /** + Get the number of milliseconds elapsed since 1 January 1970 00:00:00 UTC. + */ + static now(): number; + } + /** cc.view is the singleton object which represents the game window.
+ It's main task include:
+ - Apply the design resolution policy
+ - Provide interaction with the window, like resize event on web, retina display support, etc...
+ - Manage the game view port which can be different with the window
+ - Manage the content scale and translation
+
+ Since the cc.view is a singleton, you don't need to call any constructor or create functions,
+ the standard way to use it is by calling:
+ - cc.view.methodName();
*/ + export class View extends EventTarget { + /** + !#en + Sets view's target-densitydpi for android mobile browser. it can be set to:
+ 1. cc.macro.DENSITYDPI_DEVICE, value is "device-dpi"
+ 2. cc.macro.DENSITYDPI_HIGH, value is "high-dpi" (default value)
+ 3. cc.macro.DENSITYDPI_MEDIUM, value is "medium-dpi" (browser's default value)
+ 4. cc.macro.DENSITYDPI_LOW, value is "low-dpi"
+ 5. Custom value, e.g: "480"
+ !#zh 设置目标内容的每英寸像素点密度。 + @param densityDPI densityDPI + */ + setTargetDensityDPI(densityDPI: string): void; + /** + !#en + Returns the current target-densitydpi value of cc.view. + !#zh 获取目标内容的每英寸像素点密度。 + */ + getTargetDensityDPI(): string; + /** + !#en + Sets whether resize canvas automatically when browser's size changed.
+ Useful only on web. + !#zh 设置当发现浏览器的尺寸改变时,是否自动调整 canvas 尺寸大小。 + 仅在 Web 模式下有效。 + @param enabled Whether enable automatic resize with browser's resize event + */ + resizeWithBrowserSize(enabled: boolean): void; + /** + !#en + Sets the callback function for cc.view's resize action,
+ this callback will be invoked before applying resolution policy,
+ so you can do any additional modifications within the callback.
+ Useful only on web. + !#zh 设置 cc.view 调整视窗尺寸行为的回调函数, + 这个回调函数会在应用适配模式之前被调用, + 因此你可以在这个回调函数内添加任意附加改变, + 仅在 Web 平台下有效。 + @param callback The callback function + */ + setResizeCallback(callback: Function|void): void; + /** + !#en + Sets the orientation of the game, it can be landscape, portrait or auto. + When set it to landscape or portrait, and screen w/h ratio doesn't fit, + cc.view will automatically rotate the game canvas using CSS. + Note that this function doesn't have any effect in native, + in native, you need to set the application orientation in native project settings + !#zh 设置游戏屏幕朝向,它能够是横版,竖版或自动。 + 当设置为横版或竖版,并且屏幕的宽高比例不匹配时, + cc.view 会自动用 CSS 旋转游戏场景的 canvas, + 这个方法不会对 native 部分产生任何影响,对于 native 而言,你需要在应用设置中的设置排版。 + @param orientation Possible values: cc.macro.ORIENTATION_LANDSCAPE | cc.macro.ORIENTATION_PORTRAIT | cc.macro.ORIENTATION_AUTO + */ + setOrientation(orientation: number): void; + /** + !#en + Sets whether the engine modify the "viewport" meta in your web page.
+ It's enabled by default, we strongly suggest you not to disable it.
+ And even when it's enabled, you can still set your own "viewport" meta, it won't be overridden
+ Only useful on web + !#zh 设置引擎是否调整 viewport meta 来配合屏幕适配。 + 默认设置为启动,我们强烈建议你不要将它设置为关闭。 + 即使当它启动时,你仍然能够设置你的 viewport meta,它不会被覆盖。 + 仅在 Web 模式下有效 + @param enabled Enable automatic modification to "viewport" meta + */ + adjustViewportMeta(enabled: boolean): void; + /** + !#en + Retina support is enabled by default for Apple device but disabled for other devices,
+ it takes effect only when you called setDesignResolutionPolicy
+ Only useful on web + !#zh 对于 Apple 这种支持 Retina 显示的设备上默认进行优化而其他类型设备默认不进行优化, + 它仅会在你调用 setDesignResolutionPolicy 方法时有影响。 + 仅在 Web 模式下有效。 + @param enabled Enable or disable retina display + */ + enableRetina(enabled: boolean): void; + /** + !#en + Check whether retina display is enabled.
+ Only useful on web + !#zh 检查是否对 Retina 显示设备进行优化。 + 仅在 Web 模式下有效。 + */ + isRetinaEnabled(): boolean; + /** + !#en Whether to Enable on anti-alias + !#zh 控制抗锯齿是否开启 + @param enabled Enable or not anti-alias + */ + enableAntiAlias(enabled: boolean): void; + /** + !#en Returns whether the current enable on anti-alias + !#zh 返回当前是否抗锯齿 + */ + isAntiAliasEnabled(): boolean; + /** + !#en + If enabled, the application will try automatically to enter full screen mode on mobile devices
+ You can pass true as parameter to enable it and disable it by passing false.
+ Only useful on web + !#zh 启动时,移动端游戏会在移动端自动尝试进入全屏模式。 + 你能够传入 true 为参数去启动它,用 false 参数来关闭它。 + @param enabled Enable or disable auto full screen on mobile devices + */ + enableAutoFullScreen(enabled: boolean): void; + /** + !#en + Check whether auto full screen is enabled.
+ Only useful on web + !#zh 检查自动进入全屏模式是否启动。 + 仅在 Web 模式下有效。 + */ + isAutoFullScreenEnabled(): boolean; + /** + !#en + Returns the canvas size of the view.
+ On native platforms, it returns the screen size since the view is a fullscreen view.
+ On web, it returns the size of the canvas element. + !#zh 返回视图中 canvas 的尺寸。 + 在 native 平台下,它返回全屏视图下屏幕的尺寸。 + 在 Web 平台下,它返回 canvas 元素尺寸。 + */ + getCanvasSize(): Size; + /** + !#en + Returns the frame size of the view.
+ On native platforms, it returns the screen size since the view is a fullscreen view.
+ On web, it returns the size of the canvas's outer DOM element. + !#zh 返回视图中边框尺寸。 + 在 native 平台下,它返回全屏视图下屏幕的尺寸。 + 在 web 平台下,它返回 canvas 元素的外层 DOM 元素尺寸。 + */ + getFrameSize(): Size; + /** + !#en + On native, it sets the frame size of view.
+ On web, it sets the size of the canvas's outer DOM element. + !#zh 在 native 平台下,设置视图框架尺寸。 + 在 web 平台下,设置 canvas 外层 DOM 元素尺寸。 + @param width width + @param height height + */ + setFrameSize(width: number, height: number): void; + /** + !#en + Returns the visible area size of the view port. + !#zh 返回视图窗口可见区域尺寸。 + */ + getVisibleSize(): Size; + /** + !#en + Returns the visible area size of the view port. + !#zh 返回视图窗口可见区域像素尺寸。 + */ + getVisibleSizeInPixel(): Size; + /** + !#en + Returns the visible origin of the view port. + !#zh 返回视图窗口可见区域原点。 + */ + getVisibleOrigin(): Vec2; + /** + !#en + Returns the visible origin of the view port. + !#zh 返回视图窗口可见区域像素原点。 + */ + getVisibleOriginInPixel(): Vec2; + /** + !#en + Returns the current resolution policy + !#zh 返回当前分辨率方案 + */ + getResolutionPolicy(): ResolutionPolicy; + /** + !#en + Sets the current resolution policy + !#zh 设置当前分辨率模式 + @param resolutionPolicy resolutionPolicy + */ + setResolutionPolicy(resolutionPolicy: ResolutionPolicy|number): void; + /** + !#en + Sets the resolution policy with designed view size in points.
+ The resolution policy include:
+ [1] ResolutionExactFit Fill screen by stretch-to-fit: if the design resolution ratio of width to height is different from the screen resolution ratio, your game view will be stretched.
+ [2] ResolutionNoBorder Full screen without black border: if the design resolution ratio of width to height is different from the screen resolution ratio, two areas of your game view will be cut.
+ [3] ResolutionShowAll Full screen with black border: if the design resolution ratio of width to height is different from the screen resolution ratio, two black borders will be shown.
+ [4] ResolutionFixedHeight Scale the content's height to screen's height and proportionally scale its width
+ [5] ResolutionFixedWidth Scale the content's width to screen's width and proportionally scale its height
+ [cc.ResolutionPolicy] [Web only feature] Custom resolution policy, constructed by cc.ResolutionPolicy
+ !#zh 通过设置设计分辨率和匹配模式来进行游戏画面的屏幕适配。 + @param width Design resolution width. + @param height Design resolution height. + @param resolutionPolicy The resolution policy desired + */ + setDesignResolutionSize(width: number, height: number, resolutionPolicy: ResolutionPolicy|number): void; + /** + !#en + Returns the designed size for the view. + Default resolution size is the same as 'getFrameSize'. + !#zh 返回视图的设计分辨率。 + 默认下分辨率尺寸同 `getFrameSize` 方法相同 + */ + getDesignResolutionSize(): Size; + /** + !#en + Sets the container to desired pixel resolution and fit the game content to it. + This function is very useful for adaptation in mobile browsers. + In some HD android devices, the resolution is very high, but its browser performance may not be very good. + In this case, enabling retina display is very costy and not suggested, and if retina is disabled, the image may be blurry. + But this API can be helpful to set a desired pixel resolution which is in between. + This API will do the following: + 1. Set viewport's width to the desired width in pixel + 2. Set body width to the exact pixel resolution + 3. The resolution policy will be reset with designed view size in points. + !#zh 设置容器(container)需要的像素分辨率并且适配相应分辨率的游戏内容。 + @param width Design resolution width. + @param height Design resolution height. + @param resolutionPolicy The resolution policy desired + */ + setRealPixelResolution(width: number, height: number, resolutionPolicy: ResolutionPolicy|number): void; + /** + !#en + Sets view port rectangle with points. + !#zh 用设计分辨率下的点尺寸来设置视窗。 + @param x x + @param y y + @param w width + @param h height + */ + setViewportInPoints(x: number, y: number, w: number, h: number): void; + /** + !#en + Sets Scissor rectangle with points. + !#zh 用设计分辨率下的点的尺寸来设置 scissor 剪裁区域。 + @param x x + @param y y + @param w w + @param h h + */ + setScissorInPoints(x: number, y: number, w: number, h: number): void; + /** + !#en + Returns whether GL_SCISSOR_TEST is enable + !#zh 检查 scissor 是否生效。 + */ + isScissorEnabled(): boolean; + /** + !#en + Returns the current scissor rectangle + !#zh 返回当前的 scissor 剪裁区域。 + */ + getScissorRect(): Rect; + /** + !#en + Returns the view port rectangle. + !#zh 返回视窗剪裁区域。 + */ + getViewportRect(): Rect; + /** + !#en + Returns scale factor of the horizontal direction (X axis). + !#zh 返回横轴的缩放比,这个缩放比是将画布像素分辨率放到设计分辨率的比例。 + */ + getScaleX(): number; + /** + !#en + Returns scale factor of the vertical direction (Y axis). + !#zh 返回纵轴的缩放比,这个缩放比是将画布像素分辨率缩放到设计分辨率的比例。 + */ + getScaleY(): number; + /** + !#en + Returns device pixel ratio for retina display. + !#zh 返回设备或浏览器像素比例。 + */ + getDevicePixelRatio(): number; + /** + !#en + Returns the real location in view for a translation based on a related position + !#zh 将屏幕坐标转换为游戏视图下的坐标。 + @param tx The X axis translation + @param ty The Y axis translation + @param relatedPos The related position object including "left", "top", "width", "height" informations + */ + convertToLocationInView(tx: number, ty: number, relatedPos: any): Vec2; + } + /**

cc.game.containerStrategy class is the root strategy class of container's scale strategy, + it controls the behavior of how to scale the cc.game.container and cc.game.canvas object

*/ + export class ContainerStrategy { + /** + !#en + Manipulation before appling the strategy + !#zh 在应用策略之前的操作 + @param view The target view + */ + preApply(view: View): void; + /** + !#en + Function to apply this strategy + !#zh 策略应用方法 + @param view view + @param designedResolution designedResolution + */ + apply(view: View, designedResolution: Size): void; + /** + !#en + Manipulation after applying the strategy + !#zh 策略调用之后的操作 + @param view The target view + */ + postApply(view: View): void; + } + /**

cc.ContentStrategy class is the root strategy class of content's scale strategy, + it controls the behavior of how to scale the scene and setup the viewport for the game

*/ + export class ContentStrategy { + /** + !#en + Manipulation before applying the strategy + !#zh 策略应用前的操作 + @param view The target view + */ + preApply(view: View): void; + /** + !#en Function to apply this strategy + The return value is {scale: [scaleX, scaleY], viewport: {cc.Rect}}, + The target view can then apply these value to itself, it's preferred not to modify directly its private variables + !#zh 调用策略方法 + @param view view + @param designedResolution designedResolution + */ + apply(view: View, designedResolution: Size): any; + /** + !#en + Manipulation after applying the strategy + !#zh 策略调用之后的操作 + @param view The target view + */ + postApply(view: View): void; + } + /** undefined */ + export class EqualToFrame extends ContainerStrategy { + } + /** undefined */ + export class ProportionalToFrame extends ContainerStrategy { + } + /** undefined */ + export class EqualToWindow extends EqualToFrame { + } + /** undefined */ + export class ProportionalToWindow extends ProportionalToFrame { + } + /** undefined */ + export class OriginalContainer extends ContainerStrategy { + } + /**

cc.ResolutionPolicy class is the root strategy class of scale strategy, + its main task is to maintain the compatibility with Cocos2d-x

*/ + export class ResolutionPolicy { + /** + + @param containerStg The container strategy + @param contentStg The content strategy + */ + constructor(containerStg: ContainerStrategy, contentStg: ContentStrategy); + /** + !#en Manipulation before applying the resolution policy + !#zh 策略应用前的操作 + @param view The target view + */ + preApply(view: View): void; + /** + !#en Function to apply this resolution policy + The return value is {scale: [scaleX, scaleY], viewport: {cc.Rect}}, + The target view can then apply these value to itself, it's preferred not to modify directly its private variables + !#zh 调用策略方法 + @param view The target view + @param designedResolution The user defined design resolution + */ + apply(view: View, designedResolution: Size): any; + /** + !#en Manipulation after appyling the strategy + !#zh 策略应用之后的操作 + @param view The target view + */ + postApply(view: View): void; + /** + !#en + Setup the container's scale strategy + !#zh 设置容器的适配策略 + @param containerStg containerStg + */ + setContainerStrategy(containerStg: ContainerStrategy): void; + /** + !#en + Setup the content's scale strategy + !#zh 设置内容的适配策略 + @param contentStg contentStg + */ + setContentStrategy(contentStg: ContentStrategy): void; + /** The entire application is visible in the specified area without trying to preserve the original aspect ratio.
+ Distortion can occur, and the application may appear stretched or compressed. */ + static EXACT_FIT: number; + /** The entire application fills the specified area, without distortion but possibly with some cropping,
+ while maintaining the original aspect ratio of the application. */ + static NO_BORDER: number; + /** The entire application is visible in the specified area without distortion while maintaining the original
+ aspect ratio of the application. Borders can appear on two sides of the application. */ + static SHOW_ALL: number; + /** The application takes the height of the design resolution size and modifies the width of the internal
+ canvas so that it fits the aspect ratio of the device
+ no distortion will occur however you must make sure your application works on different
+ aspect ratios */ + static FIXED_HEIGHT: number; + /** The application takes the width of the design resolution size and modifies the height of the internal
+ canvas so that it fits the aspect ratio of the device
+ no distortion will occur however you must make sure your application works on different
+ aspect ratios */ + static FIXED_WIDTH: number; + /** Unknow policy */ + static UNKNOWN: number; + } + /** cc.visibleRect is a singleton object which defines the actual visible rect of the current view, + it should represent the same rect as cc.view.getViewportRect() */ + export class visibleRect { + /** + initialize + @param visibleRect visibleRect + */ + static init(visibleRect: Rect): void; + /** Top left coordinate of the screen related to the game scene. */ + static topLeft: Vec2; + /** Top right coordinate of the screen related to the game scene. */ + static topRight: Vec2; + /** Top center coordinate of the screen related to the game scene. */ + static top: Vec2; + /** Bottom left coordinate of the screen related to the game scene. */ + static bottomLeft: Vec2; + /** Bottom right coordinate of the screen related to the game scene. */ + static bottomRight: Vec2; + /** Bottom center coordinate of the screen related to the game scene. */ + static bottom: Vec2; + /** Center coordinate of the screen related to the game scene. */ + static center: Vec2; + /** Left center coordinate of the screen related to the game scene. */ + static left: Vec2; + /** Right center coordinate of the screen related to the game scene. */ + static right: Vec2; + /** Width of the screen. */ + static width: number; + /** Height of the screen. */ + static height: number; + } + /** !#en The callbacks invoker to handle and invoke callbacks by key. + !#zh CallbacksInvoker 用来根据 Key 管理并调用回调方法。 */ + export class CallbacksInvoker { + /** + !#zh + 检查指定事件是否已注册回调。 + !#en + Check if the specified key has any registered callback. If a callback is also specified, + it will only return true if the callback is registered. + @param key key + @param callback callback + @param target target + */ + hasEventListener(key: string, callback?: Function, target?: any): boolean; + /** + !#zh + 移除在特定事件类型中注册的所有回调或在某个目标中注册的所有回调。 + + !#en + Removes all callbacks registered in a certain event type or all callbacks registered with a certain target + @param keyOrTarget The event key to be removed or the target to be removed + */ + removeAll(keyOrTarget: string|any): void; + /** + !#zh + 删除之前与同类型,回调,目标注册的回调。 + @param key key + @param callback callback + @param target target + */ + off(key: string, callback: Function, target?: any): void; + /** + !#en + Trigger an event directly with the event name and necessary arguments. + !#zh + 通过事件名发送自定义事件 + @param key event type + @param arg1 First argument + @param arg2 Second argument + @param arg3 Third argument + @param arg4 Fourth argument + @param arg5 Fifth argument + + @example + ```js + eventTarget.emit('fire', event); + eventTarget.emit('fire', message, emitter); + ``` + */ + emit(key: string, arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any): void; + } + /** !#en Contains information collected during deserialization + !#zh 包含反序列化时的一些信息 */ + export class Details { + /** list of the depends assets' uuid */ + uuidList: string[]; + /** the obj list whose field needs to load asset by uuid */ + uuidObjList: any[]; + /** the corresponding field name which referenced to the asset */ + uuidPropList: string[]; + reset(): void; + /** + + @param obj obj + @param propName propName + @param uuid uuid + */ + push(obj: any, propName: string, uuid: string): void; + } + /** undefined */ + export class url { + /** + Returns the url of raw assets, you will only need this if the raw asset is inside the "resources" folder. + @param url url + + @example + ```js + --- + var url = cc.url.raw("textures/myTexture.png"); + console.log(url); // "resources/raw/textures/myTexture.png" + + ``` + */ + static raw(url: string): string; + } + /** !#en The module provides utilities for working with file and directory paths + !#zh 用于处理文件与目录的路径的模块 */ + export class path { + /** + !#en Join strings to be a path. + !#zh 拼接字符串为 Path + + @example + ```js + ------------------------------ + cc.path.join("a", "b.png"); //-->"a/b.png" + cc.path.join("a", "b", "c.png"); //-->"a/b/c.png" + cc.path.join("a", "b"); //-->"a/b" + cc.path.join("a", "b", "/"); //-->"a/b/" + cc.path.join("a", "b/", "/"); //-->"a/b/" + + ``` + */ + static join(): string; + /** + !#en Get the ext name of a path including '.', like '.png'. + !#zh 返回 Path 的扩展名,包括 '.',例如 '.png'。 + @param pathStr pathStr + + @example + ```js + --------------------------- + cc.path.extname("a/b.png"); //-->".png" + cc.path.extname("a/b.png?a=1&b=2"); //-->".png" + cc.path.extname("a/b"); //-->null + cc.path.extname("a/b?a=1&b=2"); //-->null + + ``` + */ + static extname(pathStr: string): any; + /** + !#en Get the main name of a file name + !#zh 获取文件名的主名称 + @param fileName fileName + */ + static mainFileName(fileName: string): string; + /** + !#en Get the file name of a file path. + !#zh 获取文件路径的文件名。 + @param pathStr pathStr + @param extname extname + + @example + ```js + --------------------------------- + cc.path.basename("a/b.png"); //-->"b.png" + cc.path.basename("a/b.png?a=1&b=2"); //-->"b.png" + cc.path.basename("a/b.png", ".png"); //-->"b" + cc.path.basename("a/b.png?a=1&b=2", ".png"); //-->"b" + cc.path.basename("a/b.png", ".txt"); //-->"b.png" + + ``` + */ + static basename(pathStr: string, extname?: string): any; + /** + !#en Get dirname of a file path. + !#zh 获取文件路径的目录名。 + @param pathStr pathStr + + @example + ```js + --------------------------------- + * unix + cc.path.driname("a/b/c.png"); //-->"a/b" + cc.path.driname("a/b/c.png?a=1&b=2"); //-->"a/b" + cc.path.dirname("a/b/"); //-->"a/b" + cc.path.dirname("c.png"); //-->"" + * windows + cc.path.driname("a\\b\\c.png"); //-->"a\b" + cc.path.driname("a\\b\\c.png?a=1&b=2"); //-->"a\b" + + ``` + */ + static dirname(pathStr: string): any; + /** + !#en Change extname of a file path. + !#zh 更改文件路径的扩展名。 + @param pathStr pathStr + @param extname extname + + @example + ```js + --------------------------------- + cc.path.changeExtname("a/b.png", ".plist"); //-->"a/b.plist" + cc.path.changeExtname("a/b.png?a=1&b=2", ".plist"); //-->"a/b.plist?a=1&b=2" + + ``` + */ + static changeExtname(pathStr: string, extname?: string): string; + } + /** !#en + AffineTransform class represent an affine transform matrix. It's composed basically by translation, rotation, scale transformations.
+ !#zh + AffineTransform 类代表一个仿射变换矩阵。它基本上是由平移旋转,缩放转变所组成。
*/ + export class AffineTransform { + /** + !#en Create a AffineTransform object with all contents in the matrix. + !#zh 用在矩阵中的所有内容创建一个 AffineTransform 对象。 + @param a a + @param b b + @param c c + @param d d + @param tx tx + @param ty ty + */ + static create(a: number, b: number, c: number, d: number, tx: number, ty: number): AffineTransform; + /** + !#en + Create a identity transformation matrix:
+ [ 1, 0, 0,
+ 0, 1, 0 ] + !#zh + 单位矩阵:
+ [ 1, 0, 0,
+ 0, 1, 0 ] + */ + static identity(): AffineTransform; + /** + !#en Clone a AffineTransform object from the specified transform. + !#zh 克隆指定的 AffineTransform 对象。 + @param t t + */ + static clone(t: AffineTransform): AffineTransform; + /** + !#en + Concatenate a transform matrix to another + The results are reflected in the out affine transform + out = t1 * t2 + This function is memory free, you should create the output affine transform by yourself and manage its memory. + !#zh + 拼接两个矩阵,将结果保存到 out 矩阵。这个函数不创建任何内存,你需要先创建 AffineTransform 对象用来存储结果,并作为第一个参数传入函数。 + out = t1 * t2 + @param out Out object to store the concat result + @param t1 The first transform object. + @param t2 The transform object to concatenate. + */ + static concat(out: AffineTransform, t1: AffineTransform, t2: AffineTransform): AffineTransform; + /** + !#en Get the invert transform of an AffineTransform object. + This function is memory free, you should create the output affine transform by yourself and manage its memory. + !#zh 求逆矩阵。这个函数不创建任何内存,你需要先创建 AffineTransform 对象用来存储结果,并作为第一个参数传入函数。 + @param out out + @param t t + */ + static invert(out: AffineTransform, t: AffineTransform): AffineTransform; + /** + !#en Get an AffineTransform object from a given matrix 4x4. + This function is memory free, you should create the output affine transform by yourself and manage its memory. + !#zh 从一个 4x4 Matrix 获取 AffineTransform 对象。这个函数不创建任何内存,你需要先创建 AffineTransform 对象用来存储结果,并作为第一个参数传入函数。 + @param out out + @param mat mat + */ + static invert(out: AffineTransform, mat: Mat4): AffineTransform; + /** + !#en Apply the affine transformation on a point. + This function is memory free, you should create the output Vec2 by yourself and manage its memory. + !#zh 对一个点应用矩阵变换。这个函数不创建任何内存,你需要先创建一个 Vec2 对象用来存储结果,并作为第一个参数传入函数。 + @param out The output point to store the result + @param point Point to apply transform or x. + @param transOrY transform matrix or y. + @param t transform matrix. + */ + static transformVec2(out: Vec2, point: Vec2|number, transOrY: AffineTransform|number, t?: AffineTransform): Vec2; + /** + !#en Apply the affine transformation on a size. + This function is memory free, you should create the output Size by yourself and manage its memory. + !#zh 应用仿射变换矩阵到 Size 上。这个函数不创建任何内存,你需要先创建一个 Size 对象用来存储结果,并作为第一个参数传入函数。 + @param out The output point to store the result + @param size size + @param t t + */ + static transformSize(out: Size, size: Size, t: AffineTransform): Size; + /** + !#en Apply the affine transformation on a rect. + This function is memory free, you should create the output Rect by yourself and manage its memory. + !#zh 应用仿射变换矩阵到 Rect 上。这个函数不创建任何内存,你需要先创建一个 Rect 对象用来存储结果,并作为第一个参数传入函数。 + @param out out + @param rect rect + @param anAffineTransform anAffineTransform + */ + static transformRect(out: Rect, rect: Rect, anAffineTransform: AffineTransform): Rect; + /** + !#en Apply the affine transformation on a rect, and truns to an Oriented Bounding Box. + This function is memory free, you should create the output vectors by yourself and manage their memory. + !#zh 应用仿射变换矩阵到 Rect 上, 并转换为有向包围盒。这个函数不创建任何内存,你需要先创建包围盒的四个 Vector 对象用来存储结果,并作为前四个参数传入函数。 + @param out_bl out_bl + @param out_tl out_tl + @param out_tr out_tr + @param out_br out_br + @param rect rect + @param anAffineTransform anAffineTransform + */ + static transformObb(out_bl: Vec2, out_tl: Vec2, out_tr: Vec2, out_br: Vec2, rect: Rect, anAffineTransform: AffineTransform): void; + } + /** !#en + Helper class for setting material blend function. + !#zh + 设置材质混合模式的辅助类。 */ + export class BlendFunc { + /** !#en specify the source Blend Factor, this will generate a custom material object, please pay attention to the memory cost. + !#zh 指定原图的混合模式,这会克隆一个新的材质对象,注意这带来的开销 */ + srcBlendFactor: macro.BlendFactor; + /** !#en specify the destination Blend Factor. + !#zh 指定目标的混合模式 */ + dstBlendFactor: macro.BlendFactor; + } + /** A base node for CCNode, it will: + - maintain scene hierarchy and active logic + - notifications if some properties changed + - define some interfaces shares between CCNode + - define machanisms for Enity Component Systems + - define prefab and serialize functions */ + export class _BaseNode extends Object implements EventTarget { + /** !#en Name of node. + !#zh 该节点名称。 */ + name: string; + /** !#en The uuid for editor, will be stripped before building project. + !#zh 主要用于编辑器的 uuid,在编辑器下可用于持久化存储,在项目构建之后将变成自增的 id。 */ + uuid: string; + /** !#en All children nodes. + !#zh 节点的所有子节点。 */ + children: Node[]; + /** !#en All children nodes. + !#zh 节点的子节点数量。 */ + childrenCount: number; + /** !#en + The local active state of this node.
+ Note that a Node may be inactive because a parent is not active, even if this returns true.
+ Use {{#crossLink "Node/activeInHierarchy:property"}}{{/crossLink}} if you want to check if the Node is actually treated as active in the scene. + !#zh + 当前节点的自身激活状态。
+ 值得注意的是,一个节点的父节点如果不被激活,那么即使它自身设为激活,它仍然无法激活。
+ 如果你想检查节点在场景中实际的激活状态可以使用 {{#crossLink "Node/activeInHierarchy:property"}}{{/crossLink}}。 */ + active: boolean; + /** !#en Indicates whether this node is active in the scene. + !#zh 表示此节点是否在场景中激活。 */ + activeInHierarchy: boolean; + /** + + @param name name + */ + constructor(name?: string); + /** !#en The parent of the node. + !#zh 该节点的父节点。 */ + parent: Node; + /** + !#en Get parent of the node. + !#zh 获取该节点的父节点。 + + @example + ```js + var parent = this.node.getParent(); + ``` + */ + getParent(): Node; + /** + !#en Set parent of the node. + !#zh 设置该节点的父节点。 + @param value value + + @example + ```js + node.setParent(newNode); + ``` + */ + setParent(value: Node): void; + /** + !#en + Properties configuration function
+ All properties in attrs will be set to the node,
+ when the setter of the node is available,
+ the property will be set via setter function.
+ !#zh 属性配置函数。在 attrs 的所有属性将被设置为节点属性。 + @param attrs Properties to be set to node + + @example + ```js + var attrs = { key: 0, num: 100 }; + node.attr(attrs); + ``` + */ + attr(attrs: any): void; + /** + !#en Returns a child from the container given its uuid. + !#zh 通过 uuid 获取节点的子节点。 + @param uuid The uuid to find the child node. + + @example + ```js + var child = node.getChildByUuid(uuid); + ``` + */ + getChildByUuid(uuid: string): Node; + /** + !#en Returns a child from the container given its name. + !#zh 通过名称获取节点的子节点。 + @param name A name to find the child node. + + @example + ```js + var child = node.getChildByName("Test Node"); + ``` + */ + getChildByName(name: string): Node; + /** + !#en + Inserts a child to the node at a specified index. + !#zh + 插入子节点到指定位置 + @param child the child node to be inserted + @param siblingIndex the sibling index to place the child in + + @example + ```js + node.insertChild(child, 2); + ``` + */ + insertChild(child: Node, siblingIndex: number): void; + /** + !#en Get the sibling index. + !#zh 获取同级索引。 + + @example + ```js + var index = node.getSiblingIndex(); + ``` + */ + getSiblingIndex(): number; + /** + !#en Set the sibling index of this node. + !#zh 设置节点同级索引。 + @param index index + + @example + ```js + node.setSiblingIndex(1); + ``` + */ + setSiblingIndex(index: number): void; + /** + !#en Walk though the sub children tree of the current node. + Each node, including the current node, in the sub tree will be visited two times, before all children and after all children. + This function call is not recursive, it's based on stack. + Please don't walk any other node inside the walk process. + !#zh 遍历该节点的子树里的所有节点并按规则执行回调函数。 + 对子树中的所有节点,包含当前节点,会执行两次回调,prefunc 会在访问它的子节点之前调用,postfunc 会在访问所有子节点之后调用。 + 这个函数的实现不是基于递归的,而是基于栈展开递归的方式。 + 请不要在 walk 过程中对任何其他的节点嵌套执行 walk。 + @param prefunc The callback to process node when reach the node for the first time + @param postfunc The callback to process node when re-visit the node after walked all children in its sub tree + + @example + ```js + node.walk(function (target) { + console.log('Walked through node ' + target.name + ' for the first time'); + }, function (target) { + console.log('Walked through node ' + target.name + ' after walked all children in its sub tree'); + }); + ``` + */ + walk(prefunc: (target: _BaseNode) => void, postfunc: (target: _BaseNode) => void): void; + /** + !#en + Remove itself from its parent node. If cleanup is `true`, then also remove all events and actions.
+ If the cleanup parameter is not passed, it will force a cleanup, so it is recommended that you always pass in the `false` parameter when calling this API.
+ If the node orphan, then nothing happens. + !#zh + 从父节点中删除该节点。如果不传入 cleanup 参数或者传入 `true`,那么这个节点上所有绑定的事件、action 都会被删除。
+ 因此建议调用这个 API 时总是传入 `false` 参数。
+ 如果这个节点是一个孤节点,那么什么都不会发生。 + @param cleanup true if all actions and callbacks on this node should be removed, false otherwise. + + @example + ```js + node.removeFromParent(); + node.removeFromParent(false); + ``` + */ + removeFromParent(cleanup?: boolean): void; + /** + !#en + Removes a child from the container. It will also cleanup all running actions depending on the cleanup parameter.

+ If the cleanup parameter is not passed, it will force a cleanup.
+ "remove" logic MUST only be on this method
+ If a class wants to extend the 'removeChild' behavior it only needs
+ to override this method. + !#zh + 移除节点中指定的子节点,是否需要清理所有正在运行的行为取决于 cleanup 参数。
+ 如果 cleanup 参数不传入,默认为 true 表示清理。
+ @param child The child node which will be removed. + @param cleanup true if all running actions and callbacks on the child node will be cleanup, false otherwise. + + @example + ```js + node.removeChild(newNode); + node.removeChild(newNode, false); + ``` + */ + removeChild(child: Node, cleanup?: boolean): void; + /** + !#en + Removes all children from the container and do a cleanup all running actions depending on the cleanup parameter.
+ If the cleanup parameter is not passed, it will force a cleanup. + !#zh + 移除节点所有的子节点,是否需要清理所有正在运行的行为取决于 cleanup 参数。
+ 如果 cleanup 参数不传入,默认为 true 表示清理。 + @param cleanup true if all running actions on all children nodes should be cleanup, false otherwise. + + @example + ```js + node.removeAllChildren(); + node.removeAllChildren(false); + ``` + */ + removeAllChildren(cleanup?: boolean): void; + /** + !#en Is this node a child of the given node? + !#zh 是否是指定节点的子节点? + @param parent parent + + @example + ```js + node.isChildOf(newNode); + ``` + */ + isChildOf(parent: Node): boolean; + /** + !#en + Returns the component of supplied type if the node has one attached, null if it doesn't.
+ You can also get component in the node by passing in the name of the script. + !#zh + 获取节点上指定类型的组件,如果节点有附加指定类型的组件,则返回,如果没有则为空。
+ 传入参数也可以是脚本的名称。 + @param typeOrClassName typeOrClassName + + @example + ```js + // get sprite component + var sprite = node.getComponent(cc.Sprite); + // get custom test class + var test = node.getComponent("Test"); + ``` + */ + getComponent(type: {prototype: T}): T; + getComponent(className: string): any; + /** + !#en Returns all components of supplied type in the node. + !#zh 返回节点上指定类型的所有组件。 + @param typeOrClassName typeOrClassName + + @example + ```js + var sprites = node.getComponents(cc.Sprite); + var tests = node.getComponents("Test"); + ``` + */ + getComponents(type: {prototype: T}): T[]; + getComponents(className: string): any[]; + /** + !#en Returns the component of supplied type in any of its children using depth first search. + !#zh 递归查找所有子节点中第一个匹配指定类型的组件。 + @param typeOrClassName typeOrClassName + + @example + ```js + var sprite = node.getComponentInChildren(cc.Sprite); + var Test = node.getComponentInChildren("Test"); + ``` + */ + getComponentInChildren(type: {prototype: T}): T; + getComponentInChildren(className: string): any; + /** + !#en Returns all components of supplied type in self or any of its children. + !#zh 递归查找自身或所有子节点中指定类型的组件 + @param typeOrClassName typeOrClassName + + @example + ```js + var sprites = node.getComponentsInChildren(cc.Sprite); + var tests = node.getComponentsInChildren("Test"); + ``` + */ + getComponentsInChildren(type: {prototype: T}): T[]; + getComponentsInChildren(className: string): any[]; + /** + !#en Adds a component class to the node. You can also add component to node by passing in the name of the script. + !#zh 向节点添加一个指定类型的组件类,你还可以通过传入脚本的名称来添加组件。 + @param typeOrClassName The constructor or the class name of the component to add + + @example + ```js + var sprite = node.addComponent(cc.Sprite); + var test = node.addComponent("Test"); + ``` + */ + addComponent(type: {new(): T}): T; + addComponent(className: string): any; + /** + !#en + Removes a component identified by the given name or removes the component object given. + You can also use component.destroy() if you already have the reference. + !#zh + 删除节点上的指定组件,传入参数可以是一个组件构造函数或组件名,也可以是已经获得的组件引用。 + 如果你已经获得组件引用,你也可以直接调用 component.destroy() + @param component The need remove component. + + @example + ```js + node.removeComponent(cc.Sprite); + var Test = require("Test"); + node.removeComponent(Test); + ``` + */ + removeComponent(component: string|Function|Component): void; + /** + !#en + Destroy all children from the node, and release all their own references to other objects.
+ Actual destruct operation will delayed until before rendering. + !#zh + 销毁所有子节点,并释放所有它们对其它对象的引用。
+ 实际销毁操作会延迟到当前帧渲染前执行。 + + @example + ```js + node.destroyAllChildren(); + ``` + */ + destroyAllChildren(): void; + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en + Register an callback of a specific event type on the EventTarget. + This type of event should be triggered via `emit`. + !#zh + 注册事件目标的特定事件类型回调。这种类型的事件应该被 `emit` 触发。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, node); + ``` + */ + on(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. + !#zh + 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + + @example + ```js + // register fire eventListener + var callback = eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, target); + // remove fire event listener + eventTarget.off('fire', callback, target); + // remove all fire event listeners + eventTarget.off('fire'); + ``` + */ + off(type: string, callback?: Function, target?: any): void; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.once('fire', function () { + cc.log("this is the callback and will be invoked only once"); + }, node); + ``` + */ + once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; + /** + !#en + Send an event with the event object. + !#zh + 通过事件对象派发事件 + @param event event + */ + dispatchEvent(event: Event): void; + } + /** An internal helper class for switching render component's material between normal sprite material and gray sprite material. */ + export class GraySpriteState { + /** !#en The normal material. + !#zh 正常状态的材质。 */ + normalMaterial: Material; + /** !#en The gray material. + !#zh 置灰状态的材质。 */ + grayMaterial: Material; + } + /** misc utilities */ + export class misc { + /** + !#en Clamp a value between from and to. + !#zh + 限定浮点数的最大最小值。
+ 数值大于 max_inclusive 则返回 max_inclusive。
+ 数值小于 min_inclusive 则返回 min_inclusive。
+ 否则返回自身。 + @param value value + @param min_inclusive min_inclusive + @param max_inclusive max_inclusive + + @example + ```js + var v1 = cc.misc.clampf(20, 0, 20); // 20; + var v2 = cc.misc.clampf(-1, 0, 20); // 0; + var v3 = cc.misc.clampf(10, 0, 20); // 10; + ``` + */ + static clampf(value: number, min_inclusive: number, max_inclusive: number): number; + /** + !#en Clamp a value between 0 and 1. + !#zh 限定浮点数的取值范围为 0 ~ 1 之间。 + @param value value + + @example + ```js + var v1 = cc.misc.clamp01(20); // 1; + var v2 = cc.misc.clamp01(-1); // 0; + var v3 = cc.misc.clamp01(0.5); // 0.5; + ``` + */ + static clamp01(value: number): number; + /** + Linear interpolation between 2 numbers, the ratio sets how much it is biased to each end + @param a number A + @param b number B + @param r ratio between 0 and 1 + + @example + ```js + ---- + lerp + cc.misc.lerp(2,10,0.5)//returns 6 + cc.misc.lerp(2,10,0.2)//returns 3.6 + + ``` + */ + static lerp(a: number, b: number, r: number): number; + /** + converts degrees to radians + @param angle angle + */ + static degreesToRadians(angle: number): number; + /** + converts radians to degrees + @param angle angle + */ + static radiansToDegrees(angle: number): number; + } + /** !#en + Representation of RGBA colors. + + Each color component is a floating point value with a range from 0 to 255. + + You can also use the convenience method {{#crossLink "cc/color:method"}}cc.color{{/crossLink}} to create a new Color. + + !#zh + cc.Color 用于表示颜色。 + + 它包含 RGBA 四个以浮点数保存的颜色分量,每个的值都在 0 到 255 之间。 + + 您也可以通过使用 {{#crossLink "cc/color:method"}}cc.color{{/crossLink}} 的便捷方法来创建一个新的 Color。 */ + export class Color extends ValueType { + /** !#en Solid white, RGBA is [255, 255, 255, 255]. + !#zh 纯白色,RGBA 是 [255, 255, 255, 255]。 */ + static WHITE: Color; + /** !#en Solid black, RGBA is [0, 0, 0, 255]. + !#zh 纯黑色,RGBA 是 [0, 0, 0, 255]。 */ + static BLACK: Color; + /** !#en Transparent, RGBA is [0, 0, 0, 0]. + !#zh 透明,RGBA 是 [0, 0, 0, 0]。 */ + static TRANSPARENT: Color; + /** !#en Grey, RGBA is [127.5, 127.5, 127.5]. + !#zh 灰色,RGBA 是 [127.5, 127.5, 127.5]。 */ + static GRAY: Color; + /** !#en Solid red, RGBA is [255, 0, 0]. + !#zh 纯红色,RGBA 是 [255, 0, 0]。 */ + static RED: Color; + /** !#en Solid green, RGBA is [0, 255, 0]. + !#zh 纯绿色,RGBA 是 [0, 255, 0]。 */ + static GREEN: Color; + /** !#en Solid blue, RGBA is [0, 0, 255]. + !#zh 纯蓝色,RGBA 是 [0, 0, 255]。 */ + static BLUE: Color; + /** !#en Yellow, RGBA is [255, 235, 4]. + !#zh 黄色,RGBA 是 [255, 235, 4]。 */ + static YELLOW: Color; + /** !#en Orange, RGBA is [255, 127, 0]. + !#zh 橙色,RGBA 是 [255, 127, 0]。 */ + static ORANGE: Color; + /** !#en Cyan, RGBA is [0, 255, 255]. + !#zh 青色,RGBA 是 [0, 255, 255]。 */ + static CYAN: Color; + /** !#en Magenta, RGBA is [255, 0, 255]. + !#zh 洋红色(品红色),RGBA 是 [255, 0, 255]。 */ + static MAGENTA: Color; + /** + Copy content of a color into another. + */ + static copy (out: Color, a: Color): Color; + /** + Clone a new color. + */ + static clone (a: Color): Color; + /** + Set the components of a color to the given values. + */ + static set (out: Color, r = 255, g = 255, b = 255, a = 255): Color; + /** + Converts the hexadecimal formal color into rgb formal. + */ + static fromHex (out: Color, hex: number): Color; + /** + Add components of two colors, respectively. + */ + static add (out: Color, a: Color, b: Color): Color; + /** + Subtract components of color b from components of color a, respectively. + */ + static subtract (out: Color, a: Color, b: Color): Color; + /** + Multiply components of two colors, respectively. + */ + static multiply (out: Color, a: Color, b: Color): Color; + /** + Divide components of color a by components of color b, respectively. + */ + static divide (out: Color, a: Color, b: Color): Color; + /** + Scales a color by a number. + */ + static scale (out: Color, a: Color, b: number): Color; + /** + Performs a linear interpolation between two colors. + */ + static lerp (out: Color, a: Color, b: Color, t: number): Color; + /** + !#zh 颜色转数组 + !#en Turn an array of colors + @param ofs 数组起始偏移量 + */ + static toArray > (out: Out, a: IColorLike, ofs = 0); + /** + !#zh 数组转颜色 + !#en An array of colors turn + @param ofs 数组起始偏移量 + */ + static fromArray (arr: IWritableArrayLike, out: Out, ofs = 0); + /** + + @param r red component of the color, default value is 0. + @param g green component of the color, defualt value is 0. + @param b blue component of the color, default value is 0. + @param a alpha component of the color, default value is 255. + */ + constructor(r?: number, g?: number, b?: number, a?: number); + /** + !#en Clone a new color from the current color. + !#zh 克隆当前颜色。 + + @example + ```js + var color = new cc.Color(); + var newColor = color.clone();// Color {r: 0, g: 0, b: 0, a: 255} + ``` + */ + clone(): Color; + /** + !#en TODO + !#zh 判断两个颜色是否相等。 + @param other other + + @example + ```js + var color1 = cc.Color.WHITE; + var color2 = new cc.Color(255, 255, 255); + cc.log(color1.equals(color2)); // true; + color2 = cc.Color.RED; + cc.log(color2.equals(color1)); // false; + ``` + */ + equals(other: Color): boolean; + /** + !#en TODO + !#zh 线性插值 + @param to to + @param ratio the interpolation coefficient. + @param out optional, the receiving vector. + + @example + ```js + // Converts a white color to a black one trough time. + update: function (dt) { + var color = this.node.color; + if (color.equals(cc.Color.BLACK)) { + return; + } + this.ratio += dt * 0.1; + this.node.color = cc.Color.WHITE.lerp(cc.Color.BLACK, ratio); + } + + ``` + */ + lerp(to: Color, ratio: number, out?: Color): Color; + /** + !#en TODO + !#zh 转换为方便阅读的字符串。 + + @example + ```js + var color = cc.Color.WHITE; + color.toString(); // "rgba(255, 255, 255, 255)" + ``` + */ + toString(): string; + /** !#en Get or set red channel value + !#zh 获取或者设置红色通道 */ + r: number; + /** !#en Get or set green channel value + !#zh 获取或者设置绿色通道 */ + g: number; + /** !#en Get or set blue channel value + !#zh 获取或者设置蓝色通道 */ + b: number; + /** !#en Get or set alpha channel value + !#zh 获取或者设置透明通道 */ + a: number; + /** + !#en Gets red channel value + !#zh 获取当前颜色的红色值。 + */ + getR(): number; + /** + !#en Sets red value and return the current color object + !#zh 设置当前的红色值,并返回当前对象。 + @param red the new Red component. + + @example + ```js + var color = new cc.Color(); + color.setR(255); // Color {r: 255, g: 0, b: 0, a: 255} + ``` + */ + setR(red: number): Color; + /** + !#en Gets green channel value + !#zh 获取当前颜色的绿色值。 + */ + getG(): number; + /** + !#en Sets green value and return the current color object + !#zh 设置当前的绿色值,并返回当前对象。 + @param green the new Green component. + + @example + ```js + var color = new cc.Color(); + color.setG(255); // Color {r: 0, g: 255, b: 0, a: 255} + ``` + */ + setG(green: number): Color; + /** + !#en Gets blue channel value + !#zh 获取当前颜色的蓝色值。 + */ + getB(): number; + /** + !#en Sets blue value and return the current color object + !#zh 设置当前的蓝色值,并返回当前对象。 + @param blue the new Blue component. + + @example + ```js + var color = new cc.Color(); + color.setB(255); // Color {r: 0, g: 0, b: 255, a: 255} + ``` + */ + setB(blue: number): Color; + /** + !#en Gets alpha channel value + !#zh 获取当前颜色的透明度值。 + */ + getA(): number; + /** + !#en Sets alpha value and return the current color object + !#zh 设置当前的透明度,并返回当前对象。 + @param alpha the new Alpha component. + + @example + ```js + var color = new cc.Color(); + color.setA(0); // Color {r: 0, g: 0, b: 0, a: 0} + ``` + */ + setA(alpha: number): Color; + /** + !#en Convert color to css format. + !#zh 转换为 CSS 格式。 + @param opt "rgba", "rgb", "#rgb" or "#rrggbb". + + @example + ```js + var color = cc.Color.BLACK; + color.toCSS(); // "rgba(0,0,0,1.00)"; + color.toCSS("rgba"); // "rgba(0,0,0,1.00)"; + color.toCSS("rgb"); // "rgba(0,0,0)"; + color.toCSS("#rgb"); // "#000"; + color.toCSS("#rrggbb"); // "#000000"; + ``` + */ + toCSS(opt?: string): string; + /** + !#en Read hex string and store color data into the current color object, the hex string must be formated as rgba or rgb. + !#zh 读取 16 进制颜色。 + @param hexString hexString + + @example + ```js + var color = cc.Color.BLACK; + color.fromHEX("#FFFF33"); // Color {r: 255, g: 255, b: 51, a: 255}; + ``` + */ + fromHEX(hexString: string): Color; + /** + !#en convert Color to HEX color string. + e.g. cc.color(255,6,255) to : "#ff06ff" + !#zh 转换为 16 进制。 + @param fmt "#rgb", "#rrggbb" or "#rrggbbaa". + + @example + ```js + var color = cc.Color.BLACK; + color.toHEX("#rgb"); // "000"; + color.toHEX("#rrggbb"); // "000000"; + ``` + */ + toHEX(fmt: string): string; + /** + !#en Convert to 24bit rgb value. + !#zh 转换为 24bit 的 RGB 值。 + + @example + ```js + var color = cc.Color.YELLOW; + color.toRGBValue(); // 16771844; + ``` + */ + toRGBValue(): number; + /** + !#en Read HSV model color and convert to RGB color + !#zh 读取 HSV(色彩模型)格式。 + @param h h + @param s s + @param v v + + @example + ```js + var color = cc.Color.YELLOW; + color.fromHSV(0, 0, 1); // Color {r: 255, g: 255, b: 255, a: 255}; + ``` + */ + fromHSV(h: number, s: number, v: number): Color; + /** + !#en Transform to HSV model color + !#zh 转换为 HSV(色彩模型)格式。 + + @example + ```js + var color = cc.Color.YELLOW; + color.toHSV(); // Object {h: 0.1533864541832669, s: 0.9843137254901961, v: 1}; + ``` + */ + toHSV(): any; + /** + !#en Set the color + !#zh 设置颜色 + @param color color + */ + set (color: Color): Color; + /** + !#en Multiplies the current color by the specified color + !#zh 将当前颜色乘以与指定颜色 + @param other other + */ + multiply(other: Color): Color; + } + /** !#en Representation of 4*4 matrix. + !#zh 表示 4*4 矩阵 */ + export class Mat4 extends ValueType { + /** + !#en Multiply the current matrix with another one + !#zh 将当前矩阵与指定矩阵相乘 + @param other the second operand + @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created + */ + mul(other: Mat4, out?: Mat4): Mat4; + /** + !#en Multiply each element of the matrix by a scalar. + !#zh 将矩阵的每一个元素都乘以指定的缩放值。 + @param number amount to scale the matrix's elements by + @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created + */ + mulScalar(number: number, out?: Mat4): Mat4; + /** + !#en Subtracts the current matrix with another one + !#zh 将当前矩阵与指定的矩阵相减 + @param other the second operand + @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created + */ + sub(other: Mat4, out?: Mat4): Mat4; + /** Identity of Mat4 */ + static IDENTITY: Mat4; + /** + !#zh 获得指定矩阵的拷贝 + !#en Copy of the specified matrix to obtain + */ + static clone (a: Out); + /** + !#zh 复制目标矩阵 + !#en Copy the target matrix + */ + static copy (out: Out, a: Out); + /** + !#zh 将目标赋值为单位矩阵 + !#en The target of an assignment is the identity matrix + */ + static identity (out: Out); + /** + !#zh 转置矩阵 + !#en Transposed matrix + */ + static transpose (out: Out, a: Out); + /** + !#zh 矩阵求逆 + !#en Matrix inversion + */ + static invert (out: Out, a: Out); + /** + !#zh 矩阵行列式 + !#en Matrix determinant + */ + static determinant (a: Out): number; + /** + !#zh 矩阵乘法 + !#en Matrix Multiplication + */ + static multiply (out: Out, a: Out, b: Out); + /** + !#zh 在给定矩阵变换基础上加入变换 + !#en Was added in a given transformation matrix transformation on the basis of + */ + static transform (out: Out, a: Out, v: VecLike); + /** + !#zh 在给定矩阵变换基础上加入新位移变换 + !#en Add new displacement transducer in a matrix transformation on the basis of a given + */ + static translate (out: Out, a: Out, v: VecLike); + /** + !#zh 在给定矩阵变换基础上加入新缩放变换 + !#en Add new scaling transformation in a given matrix transformation on the basis of + */ + static scale (out: Out, a: Out, v: VecLike); + /** + !#zh 在给定矩阵变换基础上加入新旋转变换 + !#en Add a new rotational transform matrix transformation on the basis of a given + @param rad 旋转角度 + @param axis 旋转轴 + */ + static rotate (out: Out, a: Out, rad: number, axis: VecLike); + /** + !#zh 在给定矩阵变换基础上加入绕 X 轴的旋转变换 + !#en Add rotational transformation around the X axis at a given matrix transformation on the basis of + @param rad 旋转角度 + */ + static rotateX (out: Out, a: Out, rad: number); + /** + !#zh 在给定矩阵变换基础上加入绕 Y 轴的旋转变换 + !#en Add about the Y axis rotation transformation in a given matrix transformation on the basis of + @param rad 旋转角度 + */ + static rotateY (out: Out, a: Out, rad: number); + /** + !#zh 在给定矩阵变换基础上加入绕 Z 轴的旋转变换 + !#en Added about the Z axis at a given rotational transformation matrix transformation on the basis of + @param rad 旋转角度 + */ + static rotateZ (out: Out, a: Out, rad: number); + /** + !#zh 计算位移矩阵 + !#en Displacement matrix calculation + */ + static fromTranslation (out: Out, v: VecLike); + /** + !#zh 计算缩放矩阵 + !#en Scaling matrix calculation + */ + static fromScaling (out: Out, v: VecLike); + /** + !#zh 计算旋转矩阵 + !#en Calculates the rotation matrix + */ + static fromRotation (out: Out, rad: number, axis: VecLike); + /** + !#zh 计算绕 X 轴的旋转矩阵 + !#en Calculating rotation matrix about the X axis + */ + static fromXRotation (out: Out, rad: number); + /** + !#zh 计算绕 Y 轴的旋转矩阵 + !#en Calculating rotation matrix about the Y axis + */ + static fromYRotation (out: Out, rad: number); + /** + !#zh 计算绕 Z 轴的旋转矩阵 + !#en Calculating rotation matrix about the Z axis + */ + static fromZRotation (out: Out, rad: number); + /** + !#zh 根据旋转和位移信息计算矩阵 + !#en The rotation and displacement information calculating matrix + */ + static fromRT (out: Out, q: Quat, v: VecLike); + /** + !#zh 提取矩阵的位移信息, 默认矩阵中的变换以 S->R->T 的顺序应用 + !#en Extracting displacement information of the matrix, the matrix transform to the default sequential application S-> R-> T is + */ + static getTranslation (out: VecLike, mat: Out); + /** + !#zh 提取矩阵的缩放信息, 默认矩阵中的变换以 S->R->T 的顺序应用 + !#en Scaling information extraction matrix, the matrix transform to the default sequential application S-> R-> T is + */ + static getScaling (out: VecLike, mat: Out); + /** + !#zh 提取矩阵的旋转信息, 默认输入矩阵不含有缩放信息,如考虑缩放应使用 `toRTS` 函数。 + !#en Rotation information extraction matrix, the matrix containing no default input scaling information, such as the use of `toRTS` should consider the scaling function. + */ + static getRotation (out: Quat, mat: Out); + /** + !#zh 提取旋转、位移、缩放信息, 默认矩阵中的变换以 S->R->T 的顺序应用 + !#en Extracting rotational displacement, zoom information, the default matrix transformation in order S-> R-> T applications + */ + static toRTS (mat: Out, q: Quat, v: VecLike, s: VecLike); + /** + !#zh 根据旋转、位移、缩放信息计算矩阵,以 S->R->T 的顺序应用 + !#en The rotary displacement, the scaling matrix calculation information, the order S-> R-> T applications + */ + static fromRTS (out: Out, q: Quat, v: VecLike, s: VecLike); + /** + !#zh 根据指定的旋转、位移、缩放及变换中心信息计算矩阵,以 S->R->T 的顺序应用 + !#en According to the specified rotation, displacement, and scale conversion matrix calculation information center, order S-> R-> T applications + @param q 旋转值 + @param v 位移值 + @param s 缩放值 + @param o 指定变换中心 + */ + static fromRTSOrigin (out: Out, q: Quat, v: VecLike, s: VecLike, o: VecLike); + /** + !#zh 根据指定的旋转信息计算矩阵 + !#en The rotation matrix calculation information specified + */ + static fromQuat (out: Out, q: Quat); + /** + !#zh 根据指定的视锥体信息计算矩阵 + !#en The matrix calculation information specified frustum + @param left 左平面距离 + @param right 右平面距离 + @param bottom 下平面距离 + @param top 上平面距离 + @param near 近平面距离 + @param far 远平面距离 + */ + static frustum (out: Out, left: number, right: number, bottom: number, top: number, near: number, far: number); + /** + !#zh 计算透视投影矩阵 + !#en Perspective projection matrix calculation + @param fovy 纵向视角高度 + @param aspect 长宽比 + @param near 近平面距离 + @param far 远平面距离 + */ + static perspective (out: Out, fovy: number, aspect: number, near: number, far: number); + /** + !#zh 计算正交投影矩阵 + !#en Computing orthogonal projection matrix + @param left 左平面距离 + @param right 右平面距离 + @param bottom 下平面距离 + @param top 上平面距离 + @param near 近平面距离 + @param far 远平面距离 + */ + static ortho (out: Out, left: number, right: number, bottom: number, top: number, near: number, far: number); + /** + !#zh 根据视点计算矩阵,注意 `eye - center` 不能为零向量或与 `up` 向量平行 + !#en `Up` parallel vector or vector center` not be zero - the matrix calculation according to the viewpoint, note` eye + @param eye 当前位置 + @param center 目标视点 + @param up 视口上方向 + */ + static lookAt (out: Out, eye: VecLike, center: VecLike, up: VecLike); + /** + !#zh 计算逆转置矩阵 + !#en Reversal matrix calculation + */ + static inverseTranspose (out: Out, a: Out); + /** + !#zh 逐元素矩阵加法 + !#en Element by element matrix addition + */ + static add (out: Out, a: Out, b: Out); + /** + !#zh 逐元素矩阵减法 + !#en Matrix element by element subtraction + */ + static subtract (out: Out, a: Out, b: Out); + /** + !#zh 矩阵标量乘法 + !#en Matrix scalar multiplication + */ + static multiplyScalar (out: Out, a: Out, b: number); + /** + !#zh 逐元素矩阵标量乘加: A + B * scale + !#en Elements of the matrix by the scalar multiplication and addition: A + B * scale + */ + static multiplyScalarAndAdd (out: Out, a: Out, b: Out, scale: number); + /** + !#zh 矩阵等价判断 + !#en Analyzing the equivalent matrix + */ + static strictEquals (a: Out, b: Out); + /** + !#zh 排除浮点数误差的矩阵近似等价判断 + !#en Negative floating point error is approximately equivalent to determining a matrix + */ + static equals (a: Out, b: Out, epsilon = EPSILON); + /** + !#zh 矩阵转数组 + !#en Matrix transpose array + @param ofs 数组内的起始偏移量 + */ + static toArray > (out: Out, mat: IMat4Like, ofs = 0); + /** + !#zh 数组转矩阵 + !#en Transfer matrix array + @param ofs 数组起始偏移量 + */ + static fromArray (out: Out, arr: IWritableArrayLike, ofs = 0); + /** !#en Matrix Data + !#zh 矩阵数据 */ + m: Float64Array|Float32Array; + /** + !#en + Constructor + see {{#crossLink "cc/mat4:method"}}cc.mat4{{/crossLink}} + !#zh + 构造函数,可查看 {{#crossLink "cc/mat4:method"}}cc.mat4{{/crossLink}} + */ + constructor ( m00: number = 1, m01: number = 0, m02: number = 0, m03: number = 0, m10: number = 0, m11: number = 1, m12: number = 0, m13: number = 0, m20: number = 0, m21: number = 0, m22: number = 1, m23: number = 0, m30: number = 0, m31: number = 0, m32: number = 0, m33: number = 1); + /** + !#en clone a Mat4 object + !#zh 克隆一个 Mat4 对象 + */ + clone(): Mat4; + /** + !#en Sets the matrix with another one's value + !#zh 用另一个矩阵设置这个矩阵的值。 + @param srcObj srcObj + */ + set(srcObj: Mat4): Mat4; + /** + !#en Check whether two matrix equal + !#zh 当前的矩阵是否与指定的矩阵相等。 + @param other other + */ + equals(other: Mat4): boolean; + /** + !#en Check whether two matrix equal with default degree of variance. + !#zh + 近似判断两个矩阵是否相等。
+ 判断 2 个矩阵是否在默认误差范围之内,如果在则返回 true,反之则返回 false。 + @param other other + */ + fuzzyEquals(other: Mat4): boolean; + /** + !#en Transform to string with matrix informations + !#zh 转换为方便阅读的字符串。 + */ + toString(): string; + /** + Set the matrix to the identity matrix + */ + identity(): Mat4; + /** + Transpose the values of a mat4 + @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created. + */ + transpose(out?: Mat4): Mat4; + /** + Inverts a mat4 + @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created. + */ + invert(out?: Mat4): Mat4; + /** + Calculates the adjugate of a mat4 + @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created. + */ + adjoint(out?: Mat4): Mat4; + /** + Calculates the determinant of a mat4 + */ + determinant(): number; + /** + Adds two Mat4 + @param other the second operand + @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created. + */ + add(other: Mat4, out?: Mat4): Mat4; + /** + Subtracts the current matrix with another one + @param other the second operand + */ + subtract(other: Mat4): Mat4; + /** + Subtracts the current matrix with another one + @param other the second operand + */ + multiply(other: Mat4): Mat4; + /** + Multiply each element of the matrix by a scalar. + @param number amount to scale the matrix's elements by + */ + multiplyScalar(number: number): Mat4; + /** + Translate a mat4 by the given vector + @param v vector to translate by + @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created + */ + translate(v: Vec3, out?: Mat4): Mat4; + /** + Scales the mat4 by the dimensions in the given vec3 + @param v vector to scale by + @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created + */ + scale(v: Vec3, out?: Mat4): Mat4; + /** + Rotates a mat4 by the given angle around the given axis + @param rad the angle to rotate the matrix by + @param axis the axis to rotate around + @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created + */ + rotate(rad: number, axis: Vec3, out?: Mat4): Mat4; + /** + Returns the translation vector component of a transformation matrix. + @param out Vector to receive translation component, if not provided, a new vec3 will be created + */ + getTranslation(out: Vec3): Vec3; + /** + Returns the scale factor component of a transformation matrix + @param out Vector to receive scale component, if not provided, a new vec3 will be created + */ + getScale(out: Vec3): Vec3; + /** + Returns the rotation factor component of a transformation matrix + @param out Vector to receive rotation component, if not provided, a new quaternion object will be created + */ + getRotation(out: Quat): Quat; + /** + Restore the matrix values from a quaternion rotation, vector translation and vector scale + @param q Rotation quaternion + @param v Translation vector + @param s Scaling vector + */ + fromRTS(q: Quat, v: Vec3, s: Vec3): Mat4; + /** + Restore the matrix values from a quaternion rotation + @param q Rotation quaternion + */ + fromQuat(q: Quat): Mat4; + } + /** !#en Representation of 2D vectors and points. + !#zh 表示 2D 向量和坐标 */ + export class Quat extends ValueType { + /** + !#en + Constructor + see {{#crossLink "cc/quat:method"}}cc.quat{{/crossLink}} + !#zh + 构造函数,可查看 {{#crossLink "cc/quat:method"}}cc.quat{{/crossLink}} + @param x x + @param y y + @param z z + @param w w + */ + constructor(x?: number, y?: number, z?: number, w?: number); + /** + !#en Calculate the multiply result between this quaternion and another one + !#zh 计算四元数乘积的结果 + @param other other + @param out out + */ + mul(other: Quat, out?: Quat): Quat; + /** + !#zh 获得指定四元数的拷贝 + !#en Obtaining copy specified quaternion + */ + static clone (a: Out); + /** + !#zh 复制目标四元数 + !#en Copy quaternion target + */ + static copy (out: Out, a: QuatLike); + /** + !#zh 设置四元数值 + !#en Provided Quaternion Value + */ + static set (out: Out, x: number, y: number, z: number, w: number); + /** + !#zh 将目标赋值为单位四元数 + !#en The target of an assignment as a unit quaternion + */ + static identity (out: Out); + /** + !#zh 设置四元数为两向量间的最短路径旋转,默认两向量都已归一化 + !#en Set quaternion rotation is the shortest path between two vectors, the default two vectors are normalized + */ + static rotationTo (out: Out, a: VecLike, b: VecLike); + /** + !#zh 获取四元数的旋转轴和旋转弧度 + !#en Get the rotary shaft and the arc of rotation quaternion + @param outAxis 旋转轴输出 + @param q 源四元数 + */ + static getAxisAngle (outAxis: VecLike, q: Out); + /** + !#zh 四元数乘法 + !#en Quaternion multiplication + */ + static multiply (out: Out, a: QuatLike_1, b: QuatLike_2); + /** + !#zh 四元数标量乘法 + !#en Quaternion scalar multiplication + */ + static multiplyScalar (out: Out, a: Out, b: number); + /** + !#zh 四元数乘加:A + B * scale + !#en Quaternion multiplication and addition: A + B * scale + */ + static scaleAndAdd (out: Out, a: Out, b: Out, scale: number); + /** + !#zh 绕 X 轴旋转指定四元数 + !#en About the X axis specified quaternion + @param rad 旋转弧度 + */ + static rotateX (out: Out, a: Out, rad: number); + /** + !#zh 绕 Y 轴旋转指定四元数 + !#en Rotation about the Y axis designated quaternion + @param rad 旋转弧度 + */ + static rotateY (out: Out, a: Out, rad: number); + /** + !#zh 绕 Z 轴旋转指定四元数 + !#en Around the Z axis specified quaternion + @param rad 旋转弧度 + */ + static rotateZ (out: Out, a: Out, rad: number); + /** + !#zh 绕世界空间下指定轴旋转四元数 + !#en Space around the world at a given axis of rotation quaternion + @param axis 旋转轴,默认已归一化 + @param rad 旋转弧度 + */ + static rotateAround (out: Out, rot: Out, axis: VecLike, rad: number); + /** + !#zh 绕本地空间下指定轴旋转四元数 + !#en Local space around the specified axis rotation quaternion + @param axis 旋转轴 + @param rad 旋转弧度 + */ + static rotateAroundLocal (out: Out, rot: Out, axis: VecLike, rad: number); + /** + !#zh 根据 xyz 分量计算 w 分量,默认已归一化 + !#en The component w xyz components calculated, normalized by default + */ + static calculateW (out: Out, a: Out); + /** + !#zh 四元数点积(数量积) + !#en Quaternion dot product (scalar product) + */ + static dot (a: Out, b: Out); + /** + !#zh 逐元素线性插值: A + t * (B - A) + !#en Element by element linear interpolation: A + t * (B - A) + */ + static lerp (out: Out, a: Out, b: Out, t: number); + /** + !#zh 带两个控制点的四元数球面插值 + !#en Quaternion with two spherical interpolation control points + */ + static sqlerp (out: Out, a: Out, b: Out, c: Out, d: Out, t: number); + /** + !#zh 四元数求逆 + !#en Quaternion inverse + */ + static invert (out: Out, a: QuatLike); + /** + !#zh 求共轭四元数,对单位四元数与求逆等价,但更高效 + !#en Conjugating a quaternion, and the unit quaternion equivalent to inversion, but more efficient + */ + static conjugate (out: Out, a: Out); + /** + !#zh 求四元数长度 + !#en Seek length quaternion + */ + static len (a: Out); + /** + !#zh 求四元数长度平方 + !#en Seeking quaternion square of the length + */ + static lengthSqr (a: Out); + /** + !#zh 归一化四元数 + !#en Normalized quaternions + */ + static normalize (out: Out, a: Out); + /** + !#zh 根据本地坐标轴朝向计算四元数,默认三向量都已归一化且相互垂直 + !#en Calculated according to the local orientation quaternion coordinate axis, the default three vectors are normalized and mutually perpendicular + */ + static fromAxes (out: Out, xAxis: VecLike, yAxis: VecLike, zAxis: VecLike); + /** + !#zh 根据视口的前方向和上方向计算四元数 + !#en The forward direction and the direction of the viewport computing quaternion + @param view 视口面向的前方向,必须归一化 + @param up 视口的上方向,必须归一化,默认为 (0, 1, 0) + */ + static fromViewUp (out: Out, view: Vec3, up?: Vec3); + /** + !#zh 根据旋转轴和旋转弧度计算四元数 + !#en The quaternion calculated and the arc of rotation of the rotary shaft + */ + static fromAxisAngle (out: Out, axis: VecLike, rad: number); + /** + !#zh 根据三维矩阵信息计算四元数,默认输入矩阵不含有缩放信息 + !#en Calculating the three-dimensional quaternion matrix information, default zoom information input matrix does not contain + */ + static fromMat3 (out: Out, mat: Mat3); + /** + !#zh 根据欧拉角信息计算四元数,旋转顺序为 YZX + !#en The quaternion calculated Euler angle information, rotation order YZX + */ + static fromEuler (out: Out, x: number, y: number, z: number); + /** + !#zh 返回定义此四元数的坐标系 X 轴向量 + !#en This returns the result of the quaternion coordinate system X-axis vector + */ + static toAxisX (out: VecLike, q: Out); + /** + !#zh 返回定义此四元数的坐标系 Y 轴向量 + !#en This returns the result of the quaternion coordinate system Y axis vector + */ + static toAxisY (out: VecLike, q: Out); + /** + !#zh 返回定义此四元数的坐标系 Z 轴向量 + !#en This returns the result of the quaternion coordinate system the Z-axis vector + */ + static toAxisZ (out: VecLike, q: Out); + /** + !#zh 根据四元数计算欧拉角,返回角度 x, y 在 [-180, 180] 区间内, z 默认在 [-90, 90] 区间内,旋转顺序为 YZX + !#en The quaternion calculated Euler angles, return angle x, y in the [-180, 180] interval, z default the range [-90, 90] interval, the rotation order YZX + @param outerZ z 取值范围区间改为 [-180, -90] U [90, 180] + */ + static toEuler (out: Out, q: IQuatLike, outerZ?: boolean); + /** + !#zh 四元数等价判断 + !#en Analyzing quaternion equivalent + */ + static strictEquals (a: Out, b: Out); + /** + !#zh 排除浮点数误差的四元数近似等价判断 + !#en Negative floating point error quaternion approximately equivalent Analyzing + */ + static equals (a: Out, b: Out, epsilon = EPSILON); + /** + !#zh 四元数转数组 + !#en Quaternion rotation array + @param ofs 数组内的起始偏移量 + */ + static toArray > (out: Out, q: IQuatLike, ofs = 0); + /** + !#zh 数组转四元数 + !#en Array to a quaternion + @param ofs 数组起始偏移量 + */ + static fromArray (out: Out, arr: IWritableArrayLike, ofs = 0); + x: number; + y: number; + z: number; + w: number; + /** + !#en clone a Quat object and return the new object + !#zh 克隆一个四元数并返回 + */ + clone(): Quat; + /** + !#en Set values with another quaternion + !#zh 用另一个四元数的值设置到当前对象上。 + @param newValue !#en new value to set. !#zh 要设置的新值 + */ + set(newValue: Quat): Quat; + /** + !#en Check whether current quaternion equals another + !#zh 当前的四元数是否与指定的四元数相等。 + @param other other + */ + equals(other: Quat): boolean; + /** + !#en Convert quaternion to euler + !#zh 转换四元数到欧拉角 + @param out out + */ + toEuler(out: Vec3): Vec3; + /** + !#en Convert euler to quaternion + !#zh 转换欧拉角到四元数 + @param euler euler + */ + fromEuler(euler: Vec3): Quat; + /** + !#en Calculate the interpolation result between this quaternion and another one with given ratio + !#zh 计算四元数的插值结果 + @param to to + @param ratio ratio + @param out out + */ + lerp(to: Quat, ratio: number, out?: Quat): Quat; + /** + !#en Calculate the multiply result between this quaternion and another one + !#zh 计算四元数乘积的结果 + @param other other + */ + multiply(other: Quat): Quat; + /** + !#en Rotates a quaternion by the given angle (in radians) about a world space axis. + !#zh 围绕世界空间轴按给定弧度旋转四元数 + @param rot Quaternion to rotate + @param axis The axis around which to rotate in world space + @param rad Angle (in radians) to rotate + @param out Quaternion to store result + */ + rotateAround(rot: Quat, axis: Vec3, rad: number, out?: Quat): Quat; + } + /** !#en A 2D rectangle defined by x, y position and width, height. + !#zh 通过位置和宽高定义的 2D 矩形。 */ + export class Rect extends ValueType { + /** + !#en + Constructor of Rect class. + see {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} for convenience method. + !#zh + Rect类的构造函数。可以通过 {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} 简便方法进行创建。 + @param x x + @param y y + @param w w + @param h h + */ + constructor(x?: number, y?: number, w?: number, h?: number); + /** + !#en Creates a rectangle from two coordinate values. + !#zh 根据指定 2 个坐标创建出一个矩形区域。 + @param v1 v1 + @param v2 v2 + + @example + ```js + cc.Rect.fromMinMax(cc.v2(10, 10), cc.v2(20, 20)); // Rect {x: 10, y: 10, width: 10, height: 10}; + ``` + */ + static fromMinMax(v1: Vec2, v2: Vec2): Rect; + x: number; + y: number; + width: number; + height: number; + /** + !#en TODO + !#zh 克隆一个新的 Rect。 + + @example + ```js + var a = new cc.Rect(0, 0, 10, 10); + a.clone();// Rect {x: 0, y: 0, width: 10, height: 10} + ``` + */ + clone(): Rect; + /** + !#en TODO + !#zh 是否等于指定的矩形。 + @param other other + + @example + ```js + var a = new cc.Rect(0, 0, 10, 10); + var b = new cc.Rect(0, 0, 10, 10); + a.equals(b);// true; + ``` + */ + equals(other: Rect): boolean; + /** + !#en TODO + !#zh 线性插值 + @param to to + @param ratio the interpolation coefficient. + @param out optional, the receiving vector. + + @example + ```js + var a = new cc.Rect(0, 0, 10, 10); + var b = new cc.Rect(50, 50, 100, 100); + update (dt) { + // method 1; + var c = a.lerp(b, dt * 0.1); + // method 2; + a.lerp(b, dt * 0.1, c); + } + ``` + */ + lerp(to: Rect, ratio: number, out?: Rect): Rect; + /** + !#en Check whether the current rectangle intersects with the given one + !#zh 当前矩形与指定矩形是否相交。 + @param rect rect + + @example + ```js + var a = new cc.Rect(0, 0, 10, 10); + var b = new cc.Rect(0, 0, 20, 20); + a.intersects(b);// true + ``` + */ + intersects(rect: Rect): boolean; + /** + !#en Returns the overlapping portion of 2 rectangles. + !#zh 返回 2 个矩形重叠的部分。 + @param out Stores the result + @param rectB rectB + + @example + ```js + var a = new cc.Rect(0, 10, 20, 20); + var b = new cc.Rect(0, 10, 10, 10); + var intersection = new cc.Rect(); + a.intersection(intersection, b); // intersection {x: 0, y: 10, width: 10, height: 10}; + ``` + */ + intersection(out: Rect, rectB: Rect): Rect; + /** + !#en Check whether the current rect contains the given point + !#zh 当前矩形是否包含指定坐标点。 + Returns true if the point inside this rectangle. + @param point point + + @example + ```js + var a = new cc.Rect(0, 0, 10, 10); + var b = new cc.Vec2(0, 5); + a.contains(b);// true + ``` + */ + contains(point: Vec2): boolean; + /** + !#en Returns true if the other rect totally inside this rectangle. + !#zh 当前矩形是否包含指定矩形。 + @param rect rect + + @example + ```js + var a = new cc.Rect(0, 0, 20, 20); + var b = new cc.Rect(0, 0, 10, 10); + a.containsRect(b);// true + ``` + */ + containsRect(rect: Rect): boolean; + /** + !#en Returns the smallest rectangle that contains the current rect and the given rect. + !#zh 返回一个包含当前矩形和指定矩形的最小矩形。 + @param out Stores the result + @param rectB rectB + + @example + ```js + var a = new cc.Rect(0, 10, 20, 20); + var b = new cc.Rect(0, 10, 10, 10); + var union = new cc.Rect(); + a.union(union, b); // union {x: 0, y: 10, width: 20, height: 20}; + ``` + */ + union(out: Rect, rectB: Rect): Rect; + /** + !#en Apply matrix4 to the rect. + !#zh 使用 mat4 对矩形进行矩阵转换。 + @param out The output rect + @param mat The matrix4 + */ + transformMat4(out: Rect, mat: Mat4): void; + /** + !#en Output rect informations to string + !#zh 转换为方便阅读的字符串 + + @example + ```js + var a = new cc.Rect(0, 0, 10, 10); + a.toString();// "(0.00, 0.00, 10.00, 10.00)"; + ``` + */ + toString(): string; + /** !#en The minimum x value, equals to rect.x + !#zh 矩形 x 轴上的最小值,等价于 rect.x。 */ + xMin: number; + /** !#en The minimum y value, equals to rect.y + !#zh 矩形 y 轴上的最小值。 */ + yMin: number; + /** !#en The maximum x value. + !#zh 矩形 x 轴上的最大值。 */ + xMax: number; + /** !#en The maximum y value. + !#zh 矩形 y 轴上的最大值。 */ + yMax: number; + /** !#en The position of the center of the rectangle. + !#zh 矩形的中心点。 */ + center: Vec2; + /** !#en The X and Y position of the rectangle. + !#zh 矩形的 x 和 y 坐标。 */ + origin: Vec2; + /** !#en Width and height of the rectangle. + !#zh 矩形的大小。 */ + size: Size; + } + /** !#en + cc.Size is the class for size object,
+ please do not use its constructor to create sizes,
+ use {{#crossLink "cc/size:method"}}{{/crossLink}} alias function instead.
+ It will be deprecated soon, please use cc.Vec2 instead. + + !#zh + cc.Size 是 size 对象的类。
+ 请不要使用它的构造函数创建的 size,
+ 使用 {{#crossLink "cc/size:method"}}{{/crossLink}} 别名函数。
+ 它不久将被取消,请使用cc.Vec2代替。 */ + export class Size { + /** + + @param width width + @param height height + */ + constructor(width: number|Size, height?: number); + /** !#en return a Size object with width = 0 and height = 0. + !#zh 返回一个宽度为 0 和高度为 0 的 Size 对象。 */ + static ZERO: Size; + width: number; + height: number; + /** + !#en TODO + !#zh 克隆 size 对象。 + + @example + ```js + var a = new cc.size(10, 10); + a.clone();// return Size {width: 0, height: 0}; + ``` + */ + clone(): Size; + /** + !#en TODO + !#zh 当前 Size 对象是否等于指定 Size 对象。 + @param other other + + @example + ```js + var a = new cc.size(10, 10); + a.equals(new cc.size(10, 10));// return true; + ``` + */ + equals(other: Size): boolean; + /** + !#en TODO + !#zh 线性插值。 + @param to to + @param ratio the interpolation coefficient. + @param out optional, the receiving vector. + + @example + ```js + var a = new cc.size(10, 10); + var b = new cc.rect(50, 50, 100, 100); + update (dt) { + // method 1; + var c = a.lerp(b, dt * 0.1); + // method 2; + a.lerp(b, dt * 0.1, c); + } + ``` + */ + lerp(to: Rect, ratio: number, out?: Size): Size; + /** + !#en TODO + !#zh 转换为方便阅读的字符串。 + + @example + ```js + var a = new cc.size(10, 10); + a.toString();// return "(10.00, 10.00)"; + ``` + */ + toString(): string; + } + /** !#en Representation of 2D vectors and points. + !#zh 表示 2D 向量和坐标 */ + export class Vec2 extends ValueType { + /** + !#en Returns the length of this vector. + !#zh 返回该向量的长度。 + + @example + ```js + var v = cc.v2(10, 10); + v.mag(); // return 14.142135623730951; + ``` + */ + mag(): number; + /** + !#en Returns the squared length of this vector. + !#zh 返回该向量的长度平方。 + + @example + ```js + var v = cc.v2(10, 10); + v.magSqr(); // return 200; + ``` + */ + magSqr(): number; + /** + !#en Subtracts one vector from this. If you want to save result to another vector, use sub() instead. + !#zh 向量减法。如果你想保存结果到另一个向量,可使用 sub() 代替。 + @param vector vector + + @example + ```js + var v = cc.v2(10, 10); + v.subSelf(cc.v2(5, 5));// return Vec2 {x: 5, y: 5}; + ``` + */ + subSelf(vector: Vec2): Vec2; + /** + !#en Subtracts one vector from this, and returns the new result. + !#zh 向量减法,并返回新结果。 + @param vector vector + @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created + + @example + ```js + var v = cc.v2(10, 10); + v.sub(cc.v2(5, 5)); // return Vec2 {x: 5, y: 5}; + var v1; + v.sub(cc.v2(5, 5), v1); // return Vec2 {x: 5, y: 5}; + ``` + */ + sub(vector: Vec2, out?: Vec2): Vec2; + /** + !#en Multiplies this by a number. If you want to save result to another vector, use mul() instead. + !#zh 缩放当前向量。如果你想结果保存到另一个向量,可使用 mul() 代替。 + @param num num + + @example + ```js + var v = cc.v2(10, 10); + v.mulSelf(5);// return Vec2 {x: 50, y: 50}; + ``` + */ + mulSelf(num: number): Vec2; + /** + !#en Multiplies by a number, and returns the new result. + !#zh 缩放向量,并返回新结果。 + @param num num + @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created + + @example + ```js + var v = cc.v2(10, 10); + v.mul(5); // return Vec2 {x: 50, y: 50}; + var v1; + v.mul(5, v1); // return Vec2 {x: 50, y: 50}; + ``` + */ + mul(num: number, out?: Vec2): Vec2; + /** + !#en Divides by a number. If you want to save result to another vector, use div() instead. + !#zh 向量除法。如果你想结果保存到另一个向量,可使用 div() 代替。 + @param num num + + @example + ```js + var v = cc.v2(10, 10); + v.divSelf(5); // return Vec2 {x: 2, y: 2}; + ``` + */ + divSelf(num: number): Vec2; + /** + !#en Divides by a number, and returns the new result. + !#zh 向量除法,并返回新的结果。 + @param num num + @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created + + @example + ```js + var v = cc.v2(10, 10); + v.div(5); // return Vec2 {x: 2, y: 2}; + var v1; + v.div(5, v1); // return Vec2 {x: 2, y: 2}; + ``` + */ + div(num: number, out?: Vec2): Vec2; + /** + !#en Multiplies two vectors. + !#zh 分量相乘。 + @param vector vector + + @example + ```js + var v = cc.v2(10, 10); + v.scaleSelf(cc.v2(5, 5));// return Vec2 {x: 50, y: 50}; + ``` + */ + scaleSelf(vector: Vec2): Vec2; + /** + !#en Multiplies two vectors, and returns the new result. + !#zh 分量相乘,并返回新的结果。 + @param vector vector + @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created + + @example + ```js + var v = cc.v2(10, 10); + v.scale(cc.v2(5, 5)); // return Vec2 {x: 50, y: 50}; + var v1; + v.scale(cc.v2(5, 5), v1); // return Vec2 {x: 50, y: 50}; + ``` + */ + scale(vector: Vec2, out?: Vec2): Vec2; + /** + !#en Negates the components. If you want to save result to another vector, use neg() instead. + !#zh 向量取反。如果你想结果保存到另一个向量,可使用 neg() 代替。 + + @example + ```js + var v = cc.v2(10, 10); + v.negSelf(); // return Vec2 {x: -10, y: -10}; + ``` + */ + negSelf(): Vec2; + /** + !#en Negates the components, and returns the new result. + !#zh 返回取反后的新向量。 + @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created + + @example + ```js + var v = cc.v2(10, 10); + var v1; + v.neg(v1); // return Vec2 {x: -10, y: -10}; + ``` + */ + neg(out?: Vec2): Vec2; + /** !#en return a Vec2 object with x = 1 and y = 1. + !#zh 新 Vec2 对象。 */ + static ONE: Vec2; + /** !#en return a Vec2 object with x = 0 and y = 0. + !#zh 返回 x = 0 和 y = 0 的 Vec2 对象。 */ + static ZERO: Vec2; + /** !#en return a readonly Vec2 object with x = 0 and y = 0. + !#zh 返回一个 x = 0 和 y = 0 的 Vec2 只读对象。 */ + static ZERO_R: Vec2; + /** !#en return a Vec2 object with x = 0 and y = 1. + !#zh 返回 x = 0 和 y = 1 的 Vec2 对象。 */ + static UP: Vec2; + /** !#en return a readonly Vec2 object with x = 0 and y = 1. + !#zh 返回 x = 0 和 y = 1 的 Vec2 只读对象。 */ + static UP_R: Vec2; + /** !#en return a readonly Vec2 object with x = 1 and y = 0. + !#zh 返回 x = 1 和 y = 0 的 Vec2 只读对象。 */ + static RIGHT: Vec2; + /** !#en return a Vec2 object with x = 1 and y = 0. + !#zh 返回 x = 1 和 y = 0 的 Vec2 对象。 */ + static RIGHT_R: Vec2; + /** + !#zh 获得指定向量的拷贝 + */ + static clone (a: Out); + /** + !#zh 复制指定向量的值 + */ + static copy (out: Out, a: Out); + /** + !#zh 设置向量值 + */ + static set (out: Out, x: number, y: number); + /** + !#zh 逐元素向量加法 + */ + static add (out: Out, a: Out, b: Out); + /** + !#zh 逐元素向量减法 + */ + static subtract (out: Out, a: Out, b: Out); + /** + !#zh 逐元素向量乘法 + */ + static multiply (out: Out, a: Out, b: Out); + /** + !#zh 逐元素向量除法 + */ + static divide (out: Out, a: Out, b: Out); + /** + !#zh 逐元素向量向上取整 + */ + static ceil (out: Out, a: Out); + /** + !#zh 逐元素向量向下取整 + */ + static floor (out: Out, a: Out); + /** + !#zh 逐元素向量最小值 + */ + static min (out: Out, a: Out, b: Out); + /** + !#zh 逐元素向量最大值 + */ + static max (out: Out, a: Out, b: Out); + /** + !#zh 逐元素向量四舍五入取整 + */ + static round (out: Out, a: Out); + /** + !#zh 向量标量乘法 + */ + static multiplyScalar (out: Out, a: Out, b: number); + /** + !#zh 逐元素向量乘加: A + B * scale + */ + static scaleAndAdd (out: Out, a: Out, b: Out, scale: number); + /** + !#zh 求两向量的欧氏距离 + */ + static distance (a: Out, b: Out); + /** + !#zh 求两向量的欧氏距离平方 + */ + static squaredDistance (a: Out, b: Out); + /** + !#zh 求向量长度 + */ + static len (a: Out); + /** + !#zh 求向量长度平方 + */ + static lengthSqr (a: Out); + /** + !#zh 逐元素向量取负 + */ + static negate (out: Out, a: Out); + /** + !#zh 逐元素向量取倒数,接近 0 时返回 Infinity + */ + static inverse (out: Out, a: Out); + /** + !#zh 逐元素向量取倒数,接近 0 时返回 0 + */ + static inverseSafe (out: Out, a: Out); + /** + !#zh 归一化向量 + */ + static normalize (out: Out, a: Vec2Like); + /** + !#zh 向量点积(数量积) + */ + static dot (a: Out, b: Out); + /** + !#zh 向量叉积(向量积),注意二维向量的叉积为与 Z 轴平行的三维向量 + */ + static cross (out: Vec2, a: Out, b: Out); + /** + !#zh 逐元素向量线性插值: A + t * (B - A) + */ + static lerp (out: Out, a: Out, b: Out, t: number); + /** + !#zh 生成一个在单位圆上均匀分布的随机向量 + */ + static random (out: Out, scale?: number); + /** + !#zh 向量与三维矩阵乘法,默认向量第三位为 1。 + */ + static transformMat3 (out: Out, a: Out, mat: IMat3Like); + /** + !#zh 向量与四维矩阵乘法,默认向量第三位为 0,第四位为 1。 + */ + static transformMat4 (out: Out, a: Out, mat: MatLike); + /** + !#zh 向量等价判断 + */ + static strictEquals (a: Out, b: Out); + /** + !#zh 排除浮点数误差的向量近似等价判断 + */ + static equals (a: Out, b: Out, epsilon = EPSILON); + /** + !#zh 排除浮点数误差的向量近似等价判断 + */ + static angle (a: Out, b: Out); + /** + !#zh 向量转数组 + */ + static toArray > (out: Out, v: IVec2Like, ofs = 0); + /** + !#zh 数组转向量 + */ + static fromArray (out: Out, arr: IWritableArrayLike, ofs = 0); + x: number; + y: number; + /** + !#en + Constructor + see {{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} or {{#crossLink "cc/p:method"}}cc.p{{/crossLink}} + !#zh + 构造函数,可查看 {{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} 或者 {{#crossLink "cc/p:method"}}cc.p{{/crossLink}} + @param x x + @param y y + */ + constructor(x?: number, y?: number); + /** + !#en clone a Vec2 object + !#zh 克隆一个 Vec2 对象 + */ + clone(): Vec2; + /** + !#en Sets vector with another's value + !#zh 设置向量值。 + @param newValue !#en new value to set. !#zh 要设置的新值 + */ + set(newValue: Vec2): Vec2; + /** + !#en Check whether two vector equal + !#zh 当前的向量是否与指定的向量相等。 + @param other other + */ + equals(other: Vec2): boolean; + /** + !#en Check whether two vector equal with some degree of variance. + !#zh + 近似判断两个点是否相等。
+ 判断 2 个向量是否在指定数值的范围之内,如果在则返回 true,反之则返回 false。 + @param other other + @param variance variance + */ + fuzzyEquals(other: Vec2, variance: number): boolean; + /** + !#en Transform to string with vector informations + !#zh 转换为方便阅读的字符串。 + */ + toString(): string; + /** + !#en Calculate linear interpolation result between this vector and another one with given ratio + !#zh 线性插值。 + @param to to + @param ratio the interpolation coefficient + @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created + */ + lerp(to: Vec2, ratio: number, out?: Vec2): Vec2; + /** + !#en Clamp the vector between from float and to float. + !#zh + 返回指定限制区域后的向量。
+ 向量大于 max_inclusive 则返回 max_inclusive。
+ 向量小于 min_inclusive 则返回 min_inclusive。
+ 否则返回自身。 + @param min_inclusive min_inclusive + @param max_inclusive max_inclusive + + @example + ```js + var min_inclusive = cc.v2(0, 0); + var max_inclusive = cc.v2(20, 20); + var v1 = cc.v2(20, 20).clampf(min_inclusive, max_inclusive); // Vec2 {x: 20, y: 20}; + var v2 = cc.v2(0, 0).clampf(min_inclusive, max_inclusive); // Vec2 {x: 0, y: 0}; + var v3 = cc.v2(10, 10).clampf(min_inclusive, max_inclusive); // Vec2 {x: 10, y: 10}; + ``` + */ + clampf(min_inclusive: Vec2, max_inclusive: Vec2): Vec2; + /** + !#en Adds this vector. + !#zh 向量加法。 + @param vector vector + @param out out + + @example + ```js + var v = cc.v2(10, 10); + v.add(cc.v2(5, 5));// return Vec2 {x: 15, y: 15}; + ``` + */ + add(vector: Vec2, out?: Vec2): Vec2; + /** + !#en Adds this vector. If you want to save result to another vector, use add() instead. + !#zh 向量加法。如果你想保存结果到另一个向量,使用 add() 代替。 + @param vector vector + */ + addSelf(vector: Vec2): Vec2; + /** + !#en Subtracts one vector from this. + !#zh 向量减法。 + @param vector vector + + @example + ```js + var v = cc.v2(10, 10); + v.subSelf(cc.v2(5, 5));// return Vec2 {x: 5, y: 5}; + ``` + */ + subtract(vector: Vec2): Vec2; + /** + !#en Multiplies this by a number. + !#zh 缩放当前向量。 + @param num num + + @example + ```js + var v = cc.v2(10, 10); + v.multiply(5);// return Vec2 {x: 50, y: 50}; + ``` + */ + multiplyScalar(num: number): Vec2; + /** + !#en Multiplies two vectors. + !#zh 分量相乘。 + @param vector vector + + @example + ```js + var v = cc.v2(10, 10); + v.multiply(cc.v2(5, 5));// return Vec2 {x: 50, y: 50}; + ``` + */ + multiply(vector: Vec2): Vec2; + /** + !#en Divides by a number. + !#zh 向量除法。 + @param num num + + @example + ```js + var v = cc.v2(10, 10); + v.divide(5); // return Vec2 {x: 2, y: 2}; + ``` + */ + divide(num: number): Vec2; + /** + !#en Negates the components. + !#zh 向量取反。 + + @example + ```js + var v = cc.v2(10, 10); + v.negate(); // return Vec2 {x: -10, y: -10}; + ``` + */ + negate(): Vec2; + /** + !#en Dot product + !#zh 当前向量与指定向量进行点乘。 + @param vector vector + + @example + ```js + var v = cc.v2(10, 10); + v.dot(cc.v2(5, 5)); // return 100; + ``` + */ + dot(vector?: Vec2): number; + /** + !#en Cross product + !#zh 当前向量与指定向量进行叉乘。 + @param vector vector + + @example + ```js + var v = cc.v2(10, 10); + v.cross(cc.v2(5, 5)); // return 0; + ``` + */ + cross(vector?: Vec2): number; + /** + !#en Returns the length of this vector. + !#zh 返回该向量的长度。 + + @example + ```js + var v = cc.v2(10, 10); + v.len(); // return 14.142135623730951; + ``` + */ + len(): number; + /** + !#en Returns the squared length of this vector. + !#zh 返回该向量的长度平方。 + + @example + ```js + var v = cc.v2(10, 10); + v.lengthSqr(); // return 200; + ``` + */ + lengthSqr(): number; + /** + !#en Make the length of this vector to 1. + !#zh 向量归一化,让这个向量的长度为 1。 + + @example + ```js + var v = cc.v2(10, 10); + v.normalizeSelf(); // return Vec2 {x: 0.7071067811865475, y: 0.7071067811865475}; + ``` + */ + normalizeSelf(): Vec2; + /** + !#en + Returns this vector with a magnitude of 1.
+
+ Note that the current vector is unchanged and a new normalized vector is returned. If you want to normalize the current vector, use normalizeSelf function. + !#zh + 返回归一化后的向量。
+
+ 注意,当前向量不变,并返回一个新的归一化向量。如果你想来归一化当前向量,可使用 normalizeSelf 函数。 + @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created + */ + normalize(out?: Vec2): Vec2; + /** + !#en Get angle in radian between this and vector. + !#zh 夹角的弧度。 + @param vector vector + */ + angle(vector: Vec2): number; + /** + !#en Get angle in radian between this and vector with direction. + !#zh 带方向的夹角的弧度。 + @param vector vector + */ + signAngle(vector: Vec2): number; + /** + !#en rotate + !#zh 返回旋转给定弧度后的新向量。 + @param radians radians + @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created + */ + rotate(radians: number, out?: Vec2): Vec2; + /** + !#en rotate self + !#zh 按指定弧度旋转向量。 + @param radians radians + */ + rotateSelf(radians: number): Vec2; + /** + !#en Calculates the projection of the current vector over the given vector. + !#zh 返回当前向量在指定 vector 向量上的投影向量。 + @param vector vector + + @example + ```js + var v1 = cc.v2(20, 20); + var v2 = cc.v2(5, 5); + v1.project(v2); // Vec2 {x: 20, y: 20}; + ``` + */ + project(vector: Vec2): Vec2; + /** + Transforms the vec2 with a mat4. 3rd vector component is implicitly '0', 4th vector component is implicitly '1' + @param m matrix to transform with + @param out the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created + */ + transformMat4(m: Mat4, out?: Vec2): Vec2; + /** + Returns the maximum value in x, y. + */ + maxAxis(): number; + } + /** !#en The base class of all value types. + !#zh 所有值类型的基类。 */ + export class ValueType { + /** + !#en This method returns an exact copy of current value. + !#zh 克隆当前值,该方法返回一个新对象,新对象的值和原对象相等。 + */ + clone(): ValueType; + /** + !#en Compares this object with the other one. + !#zh 当前对象是否等于指定对象。 + @param other other + */ + equals(other: ValueType): boolean; + /** + !#en + Linearly interpolates between this value to to value by ratio which is in the range [0, 1]. + When ratio = 0 returns this. When ratio = 1 return to. When ratio = 0.5 returns the average of this and to. + !#zh + 线性插值。
+ 当 ratio = 0 时返回自身,ratio = 1 时返回目标,ratio = 0.5 返回自身和目标的平均值。。 + @param to the to value + @param ratio the interpolation coefficient + */ + lerp(to: ValueType, ratio: number): ValueType; + /** + !#en + Copys all the properties from another given object to this value. + !#zh + 从其它对象把所有属性复制到当前对象。 + @param source the source to copy + */ + set(source: ValueType): void; + /** + !#en Convert to a readable string. + !#zh 转换为方便阅读的字符串。 + */ + toString(): string; + } + /** !#en Representation of 3D vectors and points. + !#zh 表示 3D 向量和坐标 */ + export class Vec3 extends ValueType { + /** + !#en Returns the length of this vector. + !#zh 返回该向量的长度。 + + @example + ```js + var v = cc.v3(10, 10, 10); + v.mag(); // return 17.320508075688775; + ``` + */ + mag(): number; + /** + !#en Returns the squared length of this vector. + !#zh 返回该向量的长度平方。 + */ + magSqr(): number; + /** + !#en Subtracts one vector from this. If you want to save result to another vector, use sub() instead. + !#zh 向量减法。如果你想保存结果到另一个向量,可使用 sub() 代替。 + @param vector vector + */ + subSelf(vector: Vec3): Vec3; + /** + !#en Subtracts one vector from this, and returns the new result. + !#zh 向量减法,并返回新结果。 + @param vector vector + @param out optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created + */ + sub(vector: Vec3, out?: Vec3): Vec3; + /** + !#en Multiplies this by a number. If you want to save result to another vector, use mul() instead. + !#zh 缩放当前向量。如果你想结果保存到另一个向量,可使用 mul() 代替。 + @param num num + */ + mulSelf(num: number): Vec3; + /** + !#en Multiplies by a number, and returns the new result. + !#zh 缩放向量,并返回新结果。 + @param num num + @param out optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created + */ + mul(num: number, out?: Vec3): Vec3; + /** + !#en Divides by a number. If you want to save result to another vector, use div() instead. + !#zh 向量除法。如果你想结果保存到另一个向量,可使用 div() 代替。 + @param num num + */ + divSelf(num: number): Vec3; + /** + !#en Divides by a number, and returns the new result. + !#zh 向量除法,并返回新的结果。 + @param num num + @param out optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created + */ + div(num: number, out?: Vec3): Vec3; + /** + !#en Multiplies two vectors. + !#zh 分量相乘。 + @param vector vector + */ + scaleSelf(vector: Vec3): Vec3; + /** + !#en Multiplies two vectors, and returns the new result. + !#zh 分量相乘,并返回新的结果。 + @param vector vector + @param out optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created + */ + scale(vector: Vec3, out?: Vec3): Vec3; + /** + !#en Negates the components. If you want to save result to another vector, use neg() instead. + !#zh 向量取反。如果你想结果保存到另一个向量,可使用 neg() 代替。 + */ + negSelf(): Vec3; + /** + !#en Negates the components, and returns the new result. + !#zh 返回取反后的新向量。 + @param out optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created + */ + neg(out?: Vec3): Vec3; + /** !#en return a Vec3 object with x = 1, y = 1, z = 1. + !#zh 新 Vec3 对象。 */ + static ONE: Vec3; + /** !#en return a Vec3 object with x = 0, y = 0, z = 0. + !#zh 返回 x = 0,y = 0,z = 0 的 Vec3 对象。 */ + static ZERO: Vec3; + /** !#en return a Vec3 object with x = 0, y = 1, z = 0. + !#zh 返回 x = 0, y = 1, z = 0 的 Vec3 对象。 */ + static UP: Vec3; + /** !#en return a Vec3 object with x = 1, y = 0, z = 0. + !#zh 返回 x = 1,y = 0,z = 0 的 Vec3 对象。 */ + static RIGHT: Vec3; + /** !#en return a Vec3 object with x = 0, y = 0, z = 1. + !#zh 返回 x = 0,y = 0,z = 1 的 Vec3 对象。 */ + static FORWARD: Vec3; + /** + !#zh 将目标赋值为零向量 + !#en The target of an assignment zero vector + */ + static zero (out: Out); + /** + !#zh 获得指定向量的拷贝 + !#en Obtaining copy vectors designated + */ + static clone (a: Out); + /** + !#zh 复制目标向量 + !#en Copy the target vector + */ + static copy (out: Out, a: Vec3Like); + /** + !#zh 设置向量值 + !#en Set to value + */ + static set (out: Out, x: number, y: number, z: number); + /** + !#zh 逐元素向量加法 + !#en Element-wise vector addition + */ + static add (out: Out, a: Out, b: Out); + /** + !#zh 逐元素向量减法 + !#en Element-wise vector subtraction + */ + static subtract (out: Out, a: Out, b: Out); + /** + !#zh 逐元素向量乘法 (分量积) + !#en Element-wise vector multiplication (product component) + */ + static multiply (out: Out, a: Vec3Like_1, b: Vec3Like_2); + /** + !#zh 逐元素向量除法 + !#en Element-wise vector division + */ + static divide (out: Out, a: Out, b: Out); + /** + !#zh 逐元素向量向上取整 + !#en Rounding up by elements of the vector + */ + static ceil (out: Out, a: Out); + /** + !#zh 逐元素向量向下取整 + !#en Element vector by rounding down + */ + static floor (out: Out, a: Out); + /** + !#zh 逐元素向量最小值 + !#en The minimum by-element vector + */ + static min (out: Out, a: Out, b: Out); + /** + !#zh 逐元素向量最大值 + !#en The maximum value of the element-wise vector + */ + static max (out: Out, a: Out, b: Out); + /** + !#zh 逐元素向量四舍五入取整 + !#en Element-wise vector of rounding to whole + */ + static round (out: Out, a: Out); + /** + !#zh 向量标量乘法 + !#en Vector scalar multiplication + */ + static multiplyScalar (out: Out, a: Vec3Like, b: number); + /** + !#zh 逐元素向量乘加: A + B * scale + !#en Element-wise vector multiply add: A + B * scale + */ + static scaleAndAdd (out: Out, a: Out, b: Out, scale: number); + /** + !#zh 求两向量的欧氏距离 + !#en Seeking two vectors Euclidean distance + */ + static distance (a: Out, b: Out); + /** + !#zh 求两向量的欧氏距离平方 + !#en Euclidean distance squared seeking two vectors + */ + static squaredDistance (a: Out, b: Out); + /** + !#zh 求向量长度 + !#en Seeking vector length + */ + static len (a: Out); + /** + !#zh 求向量长度平方 + !#en Seeking squared vector length + */ + static lengthSqr (a: Out); + /** + !#zh 逐元素向量取负 + !#en By taking the negative elements of the vector + */ + static negate (out: Out, a: Out); + /** + !#zh 逐元素向量取倒数,接近 0 时返回 Infinity + !#en Element vector by taking the inverse, return near 0 Infinity + */ + static inverse (out: Out, a: Out); + /** + !#zh 逐元素向量取倒数,接近 0 时返回 0 + !#en Element vector by taking the inverse, return near 0 0 + */ + static inverseSafe (out: Out, a: Out); + /** + !#zh 归一化向量 + !#en Normalized vector + */ + static normalize (out: Out, a: Vec3Like); + /** + !#zh 向量点积(数量积) + !#en Vector dot product (scalar product) + */ + static dot (a: Out, b: Out); + /** + !#zh 向量叉积(向量积) + !#en Vector cross product (vector product) + */ + static cross (out: Out, a: Vec3Like_1, b: Vec3Like_2); + /** + !#zh 逐元素向量线性插值: A + t * (B - A) + !#en Vector element by element linear interpolation: A + t * (B - A) + */ + static lerp (out: Out, a: Out, b: Out, t: number); + /** + !#zh 生成一个在单位球体上均匀分布的随机向量 + !#en Generates a uniformly distributed random vectors on the unit sphere + @param scale 生成的向量长度 + */ + static random (out: Out, scale?: number); + /** + !#zh 向量与四维矩阵乘法,默认向量第四位为 1。 + !#en Four-dimensional vector and matrix multiplication, the default vectors fourth one. + */ + static transformMat4 (out: Out, a: Vec3Like, mat: MatLike); + /** + !#zh 向量与四维矩阵乘法,默认向量第四位为 0。 + !#en Four-dimensional vector and matrix multiplication, vector fourth default is 0. + */ + static transformMat4Normal (out: Out, a: Out, mat: MatLike); + /** + !#zh 向量与三维矩阵乘法 + !#en Dimensional vector matrix multiplication + */ + static transformMat3 (out: Out, a: Out, mat: MatLike); + /** + !#zh 向量四元数乘法 + !#en Vector quaternion multiplication + */ + static transformQuat (out: Out, a: VecLike, q: QuatLike); + /** + !#zh 绕 X 轴旋转向量指定弧度 + !#en Rotation vector specified angle about the X axis + @param v 待旋转向量 + @param o 旋转中心 + @param a 旋转弧度 + */ + static rotateX (out: Out, v: Out, o: Out, a: number); + /** + !#zh 绕 Y 轴旋转向量指定弧度 + !#en Rotation vector specified angle around the Y axis + @param v 待旋转向量 + @param o 旋转中心 + @param a 旋转弧度 + */ + static rotateY (out: Out, v: Out, o: Out, a: number); + /** + !#zh 绕 Z 轴旋转向量指定弧度 + !#en Around the Z axis specified angle vector + @param v 待旋转向量 + @param o 旋转中心 + @param a 旋转弧度 + */ + static rotateZ (out: Out, v: Out, o: Out, a: number); + /** + !#zh 向量等价判断 + !#en Equivalent vectors Analyzing + */ + static strictEquals (a: Out, b: Out); + /** + !#zh 排除浮点数误差的向量近似等价判断 + !#en Negative error vector floating point approximately equivalent Analyzing + */ + static equals (a: Out, b: Out, epsilon = EPSILON); + /** + !#zh 求两向量夹角弧度 + !#en Radian angle between two vectors seek + */ + static angle (a: Out, b: Out); + /** + !#zh 计算向量在指定平面上的投影 + !#en Calculating a projection vector in the specified plane + @param a 待投影向量 + @param n 指定平面的法线 + */ + static projectOnPlane (out: Out, a: Out, n: Out); + /** + !#zh 计算向量在指定向量上的投影 + !#en Projection vector calculated in the vector designated + @param a 待投影向量 + @param n 目标向量 + */ + static project (out: Out, a: Out, b: Out); + /** + !#zh 向量转数组 + !#en Vector transfer array + @param ofs 数组起始偏移量 + */ + static toArray > (out: Out, v: IVec3Like, ofs = 0); + /** + !#zh 数组转向量 + !#en Array steering amount + @param ofs 数组起始偏移量 + */ + static fromArray (out: Out, arr: IWritableArrayLike, ofs = 0); + x: number; + y: number; + z: number; + /** + !#en + Constructor + see {{#crossLink "cc/vec3:method"}}cc.v3{{/crossLink}} + !#zh + 构造函数,可查看 {{#crossLink "cc/vec3:method"}}cc.v3{{/crossLink}} + @param x x + @param y y + @param z z + */ + constructor(x?: Vec3|number, y?: number, z?: number); + /** + !#en clone a Vec3 value + !#zh 克隆一个 Vec3 值 + */ + clone(): Vec3; + /** + !#en Set the current vector value with the given vector. + !#zh 用另一个向量设置当前的向量对象值。 + @param newValue !#en new value to set. !#zh 要设置的新值 + */ + set(newValue: Vec3): Vec3; + /** + !#en Check whether the vector equals another one + !#zh 当前的向量是否与指定的向量相等。 + @param other other + */ + equals(other: Vec3): boolean; + /** + !#en Check whether two vector equal with some degree of variance. + !#zh + 近似判断两个点是否相等。
+ 判断 2 个向量是否在指定数值的范围之内,如果在则返回 true,反之则返回 false。 + @param other other + @param variance variance + */ + fuzzyEquals(other: Vec3, variance: number): boolean; + /** + !#en Transform to string with vector informations + !#zh 转换为方便阅读的字符串。 + */ + toString(): string; + /** + !#en Calculate linear interpolation result between this vector and another one with given ratio + !#zh 线性插值。 + @param to to + @param ratio the interpolation coefficient + @param out optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created + */ + lerp(to: Vec3, ratio: number, out?: Vec3): Vec3; + /** + !#en Clamp the vector between from float and to float. + !#zh + 返回指定限制区域后的向量。
+ 向量大于 max_inclusive 则返回 max_inclusive。
+ 向量小于 min_inclusive 则返回 min_inclusive。
+ 否则返回自身。 + @param min_inclusive min_inclusive + @param max_inclusive max_inclusive + */ + clampf(min_inclusive: Vec3, max_inclusive: Vec3): Vec3; + /** + !#en Adds this vector. If you want to save result to another vector, use add() instead. + !#zh 向量加法。如果你想保存结果到另一个向量,使用 add() 代替。 + @param vector vector + */ + addSelf(vector: Vec3): Vec3; + /** + !#en Adds two vectors, and returns the new result. + !#zh 向量加法,并返回新结果。 + @param vector vector + @param out optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created + */ + add(vector: Vec3, out?: Vec3): Vec3; + /** + !#en Subtracts one vector from this. + !#zh 向量减法。 + @param vector vector + */ + subtract(vector: Vec3): Vec3; + /** + !#en Multiplies this by a number. + !#zh 缩放当前向量。 + @param num num + */ + multiplyScalar(num: number): Vec3; + /** + !#en Multiplies two vectors. + !#zh 分量相乘。 + @param vector vector + */ + multiply(vector: Vec3): Vec3; + /** + !#en Divides by a number. + !#zh 向量除法。 + @param num num + */ + divide(num: number): Vec3; + /** + !#en Negates the components. + !#zh 向量取反。 + */ + negate(): Vec3; + /** + !#en Dot product + !#zh 当前向量与指定向量进行点乘。 + @param vector vector + */ + dot(vector?: Vec3): number; + /** + !#en Cross product + !#zh 当前向量与指定向量进行叉乘。 + @param vector vector + @param out out + */ + cross(vector: Vec3, out?: Vec3): Vec3; + /** + !#en Returns the length of this vector. + !#zh 返回该向量的长度。 + + @example + ```js + var v = cc.v3(10, 10, 10); + v.len(); // return 17.320508075688775; + ``` + */ + len(): number; + /** + !#en Returns the squared length of this vector. + !#zh 返回该向量的长度平方。 + */ + lengthSqr(): number; + /** + !#en Make the length of this vector to 1. + !#zh 向量归一化,让这个向量的长度为 1。 + */ + normalizeSelf(): Vec3; + /** + !#en + Returns this vector with a magnitude of 1.
+
+ Note that the current vector is unchanged and a new normalized vector is returned. If you want to normalize the current vector, use normalizeSelf function. + !#zh + 返回归一化后的向量。
+
+ 注意,当前向量不变,并返回一个新的归一化向量。如果你想来归一化当前向量,可使用 normalizeSelf 函数。 + @param out optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created + */ + normalize(out?: Vec3): Vec3; + /** + Transforms the vec3 with a mat4. 4th vector component is implicitly '1' + @param m matrix to transform with + @param out the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created + */ + transformMat4(m: Mat4, out?: Vec3): Vec3; + /** + Returns the maximum value in x, y, and z + */ + maxAxis(): number; + /** + !#en Get angle in radian between this and vector. + !#zh 夹角的弧度。 + @param vector vector + */ + angle(vector: Vec3): number; + /** + !#en Calculates the projection of the current vector over the given vector. + !#zh 返回当前向量在指定 vector 向量上的投影向量。 + @param vector vector + + @example + ```js + var v1 = cc.v3(20, 20, 20); + var v2 = cc.v3(5, 5, 5); + v1.project(v2); // Vec3 {x: 20, y: 20, z: 20}; + ``` + */ + project(vector: Vec3): Vec3; + /** + !#en Get angle in radian between this and vector with direction.
+ In order to compatible with the vec2 API. + !#zh 带方向的夹角的弧度。该方法仅用做兼容 2D 计算。 + @param vector vector + */ + signAngle(vector: Vec3|Vec2): number; + /** + !#en rotate. In order to compatible with the vec2 API. + !#zh 返回旋转给定弧度后的新向量。该方法仅用做兼容 2D 计算。 + @param radians radians + @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created + */ + rotate(radians: number, out?: Vec3): Vec2; + /** + !#en rotate self. In order to compatible with the vec2 API. + !#zh 按指定弧度旋转向量。该方法仅用做兼容 2D 计算。 + @param radians radians + */ + rotateSelf(radians: number): Vec3; + } + /** !#en Representation of 3D vectors and points. + !#zh 表示 3D 向量和坐标 */ + export class Vec4 extends ValueType { + /** + !#en Subtracts one vector from this. If you want to save result to another vector, use sub() instead. + !#zh 向量减法。如果你想保存结果到另一个向量,可使用 sub() 代替。 + @param vector vector + */ + subSelf(vector: Vec4): Vec4; + /** + !#en Subtracts one vector from this, and returns the new result. + !#zh 向量减法,并返回新结果。 + @param vector vector + @param out optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created + */ + sub(vector: Vec4, out?: Vec4): Vec4; + /** + !#en Multiplies this by a number. If you want to save result to another vector, use mul() instead. + !#zh 缩放当前向量。如果你想结果保存到另一个向量,可使用 mul() 代替。 + @param num num + */ + mulSelf(num: number): Vec4; + /** + !#en Multiplies by a number, and returns the new result. + !#zh 缩放向量,并返回新结果。 + @param num num + @param out optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created + */ + mul(num: number, out?: Vec4): Vec4; + /** + !#en Divides by a number. If you want to save result to another vector, use div() instead. + !#zh 向量除法。如果你想结果保存到另一个向量,可使用 div() 代替。 + @param num num + */ + divSelf(num: number): Vec4; + /** + !#en Divides by a number, and returns the new result. + !#zh 向量除法,并返回新的结果。 + @param num num + @param out optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created + */ + div(num: number, out?: Vec4): Vec4; + /** + !#en Multiplies two vectors. + !#zh 分量相乘。 + @param vector vector + */ + scaleSelf(vector: Vec4): Vec4; + /** + !#en Multiplies two vectors, and returns the new result. + !#zh 分量相乘,并返回新的结果。 + @param vector vector + @param out optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created + */ + scale(vector: Vec4, out?: Vec4): Vec4; + /** + !#en Negates the components. If you want to save result to another vector, use neg() instead. + !#zh 向量取反。如果你想结果保存到另一个向量,可使用 neg() 代替。 + */ + negSelf(): Vec4; + /** + !#en Negates the components, and returns the new result. + !#zh 返回取反后的新向量。 + @param out optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created + */ + neg(out?: Vec4): Vec4; + /** + !#zh 获得指定向量的拷贝 + !#en Obtaining copy vectors designated + */ + static clone (a: Out); + /** + !#zh 复制目标向量 + !#en Copy the target vector + */ + static copy (out: Out, a: Out); + /** + !#zh 设置向量值 + !#en Set to value + */ + static set (out: Out, x: number, y: number, z: number, w: number); + /** + !#zh 逐元素向量加法 + !#en Element-wise vector addition + */ + static add (out: Out, a: Out, b: Out); + /** + !#zh 逐元素向量减法 + !#en Element-wise vector subtraction + */ + static subtract (out: Out, a: Out, b: Out); + /** + !#zh 逐元素向量乘法 + !#en Element-wise vector multiplication + */ + static multiply (out: Out, a: Out, b: Out); + /** + !#zh 逐元素向量除法 + !#en Element-wise vector division + */ + static divide (out: Out, a: Out, b: Out); + /** + !#zh 逐元素向量向上取整 + !#en Rounding up by elements of the vector + */ + static ceil (out: Out, a: Out); + /** + !#zh 逐元素向量向下取整 + !#en Element vector by rounding down + */ + static floor (out: Out, a: Out); + /** + !#zh 逐元素向量最小值 + !#en The minimum by-element vector + */ + static min (out: Out, a: Out, b: Out); + /** + !#zh 逐元素向量最大值 + !#en The maximum value of the element-wise vector + */ + static max (out: Out, a: Out, b: Out); + /** + !#zh 逐元素向量四舍五入取整 + !#en Element-wise vector of rounding to whole + */ + static round (out: Out, a: Out); + /** + !#zh 向量标量乘法 + !#en Vector scalar multiplication + */ + static multiplyScalar (out: Out, a: Out, b: number); + /** + !#zh 逐元素向量乘加: A + B * scale + !#en Element-wise vector multiply add: A + B * scale + */ + static scaleAndAdd (out: Out, a: Out, b: Out, scale: number); + /** + !#zh 求两向量的欧氏距离 + !#en Seeking two vectors Euclidean distance + */ + static distance (a: Out, b: Out); + /** + !#zh 求两向量的欧氏距离平方 + !#en Euclidean distance squared seeking two vectors + */ + static squaredDistance (a: Out, b: Out); + /** + !#zh 求向量长度 + !#en Seeking vector length + */ + static len (a: Out); + /** + !#zh 求向量长度平方 + !#en Seeking squared vector length + */ + static lengthSqr (a: Out); + /** + !#zh 逐元素向量取负 + !#en By taking the negative elements of the vector + */ + static negate (out: Out, a: Out); + /** + !#zh 逐元素向量取倒数,接近 0 时返回 Infinity + !#en Element vector by taking the inverse, return near 0 Infinity + */ + static inverse (out: Out, a: Out); + /** + !#zh 逐元素向量取倒数,接近 0 时返回 0 + !#en Element vector by taking the inverse, return near 0 0 + */ + static inverseSafe (out: Out, a: Out); + /** + !#zh 归一化向量 + !#en Normalized vector + */ + static normalize (out: Out, a: Out); + /** + !#zh 向量点积(数量积) + !#en Vector dot product (scalar product) + */ + static dot (a: Out, b: Out); + /** + !#zh 逐元素向量线性插值: A + t * (B - A) + !#en Vector element by element linear interpolation: A + t * (B - A) + */ + static lerp (out: Out, a: Out, b: Out, t: number); + /** + !#zh 生成一个在单位球体上均匀分布的随机向量 + !#en Generates a uniformly distributed random vectors on the unit sphere + @param scale 生成的向量长度 + */ + static random (out: Out, scale?: number); + /** + !#zh 向量矩阵乘法 + !#en Vector matrix multiplication + */ + static transformMat4 (out: Out, a: Out, mat: MatLike); + /** + !#zh 向量四元数乘法 + !#en Vector quaternion multiplication + */ + static transformQuat (out: Out, a: Out, q: QuatLike); + /** + !#zh 向量等价判断 + !#en Equivalent vectors Analyzing + */ + static strictEquals (a: Out, b: Out); + /** + !#zh 排除浮点数误差的向量近似等价判断 + !#en Negative error vector floating point approximately equivalent Analyzing + */ + static equals (a: Out, b: Out, epsilon = EPSILON); + /** + !#zh 向量转数组 + !#en Vector transfer array + @param ofs 数组起始偏移量 + */ + static toArray > (out: Out, v: IVec4Like, ofs = 0); + /** + !#zh 数组转向量 + !#en Array steering amount + @param ofs 数组起始偏移量 + */ + static fromArray (out: Out, arr: IWritableArrayLike, ofs = 0); + x: number; + y: number; + z: number; + w: number; + /** + !#en + Constructor + see {{#crossLink "cc/vec4:method"}}cc.v4{{/crossLink}} + !#zh + 构造函数,可查看 {{#crossLink "cc/vec4:method"}}cc.v4{{/crossLink}} + @param x x + @param y y + @param z z + @param w w + */ + constructor(x?: number, y?: number, z?: number, w?: number); + /** + !#en clone a Vec4 value + !#zh 克隆一个 Vec4 值 + */ + clone(): Vec4; + /** + !#en Set the current vector value with the given vector. + !#zh 用另一个向量设置当前的向量对象值。 + @param newValue !#en new value to set. !#zh 要设置的新值 + */ + set(newValue: Vec4): Vec4; + /** + !#en Check whether the vector equals another one + !#zh 当前的向量是否与指定的向量相等。 + @param other other + @param epsilon epsilon + */ + equals(other: Vec4, epsilon?: number): boolean; + /** + !#en Check whether the vector equals another one + !#zh 判断当前向量是否在误差范围内与指定分量的向量相等。 + @param x 相比较的向量的 x 分量。 + @param y 相比较的向量的 y 分量。 + @param z 相比较的向量的 z 分量。 + @param w 相比较的向量的 w 分量。 + @param epsilon 允许的误差,应为非负数。 + */ + equals4f(x: number, y: number, z: number, w: number, epsilon?: number): boolean; + /** + !#en Check whether strict equals other Vec4 + !#zh 判断当前向量是否与指定向量相等。两向量的各分量都分别相等时返回 `true`;否则返回 `false`。 + @param other 相比较的向量。 + */ + strictEquals(other: Vec4): boolean; + /** + !#en Check whether strict equals other Vec4 + !#zh 判断当前向量是否与指定分量的向量相等。两向量的各分量都分别相等时返回 `true`;否则返回 `false`。 + @param x 指定向量的 x 分量。 + @param y 指定向量的 y 分量。 + @param z 指定向量的 z 分量。 + @param w 指定向量的 w 分量。 + */ + strictEquals4f(x: number, y: number, z: number, w: number): boolean; + /** + !#en Calculate linear interpolation result between this vector and another one with given ratio + !#zh 根据指定的插值比率,从当前向量到目标向量之间做插值。 + @param to 目标向量。 + @param ratio 插值比率,范围为 [0,1]。 + */ + lerp(to: Vec4, ratio: number): Vec4; + /** + !#en Transform to string with vector informations + !#zh 返回当前向量的字符串表示。 + */ + toString(): string; + /** + !#en Clamp the vector between minInclusive and maxInclusive. + !#zh 设置当前向量的值,使其各个分量都处于指定的范围内。 + @param minInclusive 每个分量都代表了对应分量允许的最小值。 + @param maxInclusive 每个分量都代表了对应分量允许的最大值。 + */ + clampf(minInclusive: Vec4, maxInclusive: Vec4): Vec4; + /** + !#en Adds this vector. If you want to save result to another vector, use add() instead. + !#zh 向量加法。如果你想保存结果到另一个向量,使用 add() 代替。 + @param vector vector + */ + addSelf(vector: Vec4): Vec4; + /** + !#en Adds two vectors, and returns the new result. + !#zh 向量加法,并返回新结果。 + @param vector vector + @param out optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created + */ + add(vector: Vec4, out?: Vec4): Vec4; + /** + !#en Subtracts one vector from this, and returns the new result. + !#zh 向量减法,并返回新结果。 + @param vector vector + @param out optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created + */ + subtract(vector: Vec4, out?: Vec4): Vec4; + /** + !#en Multiplies this by a number. + !#zh 缩放当前向量。 + @param num num + */ + multiplyScalar(num: number): Vec4; + /** + !#en Multiplies two vectors. + !#zh 分量相乘。 + @param vector vector + */ + multiply(vector: Vec4): Vec4; + /** + !#en Divides by a number. + !#zh 向量除法。 + @param num num + */ + divide(num: number): Vec4; + /** + !#en Negates the components. + !#zh 向量取反 + */ + negate(): Vec4; + /** + !#en Dot product + !#zh 当前向量与指定向量进行点乘。 + @param vector vector + */ + dot(vector?: Vec4): number; + /** + !#en Cross product + !#zh 当前向量与指定向量进行叉乘。 + @param vector vector + @param out out + */ + cross(vector: Vec4, out?: Vec4): Vec4; + /** + !#en Returns the length of this vector. + !#zh 返回该向量的长度。 + + @example + ```js + var v = cc.v4(10, 10); + v.len(); // return 14.142135623730951; + ``` + */ + len(): number; + /** + !#en Returns the squared length of this vector. + !#zh 返回该向量的长度平方。 + */ + lengthSqr(): number; + /** + !#en Make the length of this vector to 1. + !#zh 向量归一化,让这个向量的长度为 1。 + */ + normalizeSelf(): Vec4; + /** + !#en + Returns this vector with a magnitude of 1.
+
+ Note that the current vector is unchanged and a new normalized vector is returned. If you want to normalize the current vector, use normalizeSelf function. + !#zh + 返回归一化后的向量。
+
+ 注意,当前向量不变,并返回一个新的归一化向量。如果你想来归一化当前向量,可使用 normalizeSelf 函数。 + @param out optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created + */ + normalize(out?: Vec4): Vec4; + /** + Transforms the vec4 with a mat4. 4th vector component is implicitly '1' + @param m matrix to transform with + @param out the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created + */ + transformMat4(m: Mat4, out?: Vec4): Vec4; + /** + Returns the maximum value in x, y, z, w. + */ + maxAxis(): number; + } + /** !#en The burst of 3d particle. + !#zh 3D 粒子发射时的爆发个数 */ + export class Burst { + /** !#en Time between the start of the particle system and the trigger of this Brust + !#zh 粒子系统开始运行到触发此次 Brust 的时间 */ + time: number; + /** !#en Minimum number of emitted particles + !#zh 发射粒子的最小数量 */ + minCount: number; + /** !#en Maximum number of emitted particles + !#zh 发射粒子的最大数量 */ + maxCount: number; + /** !#en The number of times Burst was triggered. + !#zh Burst 的触发次数 */ + repeatCount: number; + /** !#en Interval of each trigger + !#zh 每次触发的间隔时间 */ + repeatInterval: number; + /** !#en Number of particles emitted + !#zh 发射的粒子的数量 */ + count: CurveRange; + } + /** !#en The animation curve of 3d particle. + !#zh 3D 粒子动画曲线 */ + export class AnimationCurve { + } + /** !#en The ParticleSystem3D Component. + !#zh 3D 粒子组件 */ + export class ParticleSystem3D extends RenderComponent { + /** !#en The run time of particle. + !#zh 粒子系统运行时间 */ + duration: number; + /** !#en The maximum number of particles that a particle system can generate. + !#zh 粒子系统能生成的最大粒子数量 */ + capacity: number; + /** !#en Whether the particle system loops. + !#zh 粒子系统是否循环播放 */ + loop: boolean; + /** !#en Whether the particles start playing automatically after loaded. + !#zh 粒子系统加载后是否自动开始播放 */ + playOnAwake: boolean; + /** !#en When selected, the particle system will start playing after one round has been played (only effective when loop is enabled). + !#zh 选中之后,粒子系统会以已播放完一轮之后的状态开始播放(仅当循环播放启用时有效) */ + prewarm: boolean; + /** !#en The coordinate system in which the particle system is located.
+ World coordinates (does not change when the position of other objects changes)
+ Local coordinates (moving as the position of the parent node changes)
+ Custom coordinates (moving with the position of a custom node) + !#zh 选择粒子系统所在的坐标系
+ 世界坐标(不随其他物体位置改变而变换)
+ 局部坐标(跟随父节点位置改变而移动)
+ 自定坐标(跟随自定义节点的位置改变而移动) */ + simulationSpace: Space; + /** !#en Controlling the update speed of the entire particle system. + !#zh 控制整个粒子系统的更新速度。 */ + simulationSpeed: number; + /** !#en Delay particle emission time after particle system starts running. + !#zh 粒子系统开始运行后,延迟粒子发射的时间。 */ + startDelay: CurveRange; + /** !#en Particle life cycle。 + !#zh 粒子生命周期。 */ + startLifetime: CurveRange; + /** !#en Particle initial color + !#zh 粒子初始颜色 */ + startColor: GradientRange; + /** !#en Particle scale space + !#zh 缩放空间 */ + scaleSpace: Space; + /** !#en Initial particle size + !#zh 粒子初始大小 */ + startSize: CurveRange; + /** !#en Initial particle speed + !#zh 粒子初始速度 */ + startSpeed: CurveRange; + /** !#en Particle initial rotation angle + !#zh 粒子初始旋转角度 */ + startRotation: CurveRange; + /** !#en Gravity coefficient of particles affected by gravity + !#zh 粒子受重力影响的重力系数 */ + gravityModifier: CurveRange; + /** !#en Particles emitted per second + !#zh 每秒发射的粒子数 */ + rateOverTime: CurveRange; + /** !#en Number of particles emitted per unit distance moved + !#zh 每移动单位距离发射的粒子数 */ + rateOverDistance: CurveRange; + /** !#en The number of Brusts that emit a specified number of particles at a specified time + !#zh 设定在指定时间发射指定数量的粒子的 Brust 的数量 */ + bursts: Burst[]; + /** !#en Particle emitter module + !#zh 粒子发射器模块 */ + shapeModule: ShapeModule; + /** !#en Color control module + !#zh 颜色控制模块 */ + colorOverLifetimeModule: ColorOverLifetimeModule; + /** !#en Particle size module + !#zh 粒子大小模块 */ + sizeOvertimeModule: SizeOvertimeModule; + /** !#en Particle speed module + !#zh 粒子速度模块 */ + velocityOvertimeModule: VelocityOvertimeModule; + /** !#en Particle acceleration module + !#zh 粒子加速度模块 */ + forceOvertimeModule: ForceOvertimeModule; + /** !#en Particle limit speed module (only CPU particles are supported) + !#zh 粒子限制速度模块(只支持 CPU 粒子) */ + limitVelocityOvertimeModule: LimitVelocityOvertimeModule; + /** !#en Particle rotation module + !#zh 粒子旋转模块 */ + rotationOvertimeModule: RotationOvertimeModule; + /** !#en Texture Animation Module + !#zh 贴图动画模块 */ + textureAnimationModule: TextureAnimationModule; + /** !#en Particle Trajectory Module + !#zh 粒子轨迹模块 */ + trailModule: TrailModule; + /** !#en Particle generation mode + !#zh 设定粒子生成模式 */ + renderMode: ParticleSystem3DAssembler.RenderMode; + /** !#en When the particle generation mode is StrecthedBillboard, in the direction of movement of the particles is stretched by velocity magnitude + !#zh 在粒子生成方式为 StrecthedBillboard 时,对粒子在运动方向上按速度大小进行拉伸 */ + velocityScale: number; + /** !#en When the particle generation method is StrecthedBillboard, the particles are stretched according to the particle size in the direction of motion + !#zh 在粒子生成方式为 StrecthedBillboard 时,对粒子在运动方向上按粒子大小进行拉伸 */ + lengthScale: number; + /** !#en Particle model + !#zh 粒子模型 */ + mesh: Mesh; + /** !#en Particle material + !#zh 粒子材质 */ + particleMaterial: Material; + /** !#en Particle trail material + !#zh 粒子轨迹材质 */ + trailMaterial: Material; + /** + !#en Playing particle effects + !#zh 播放粒子效果 + */ + play(): void; + /** + !#en Pause particle effect + !#zh 暂停播放粒子效果 + */ + pause(): void; + /** + !#en Stop particle effect + !#zh 停止播放粒子效果 + */ + stop(): void; + /** + !#en Remove all particle effect + !#zh 将所有粒子从粒子系统中清除 + */ + clear(): void; + } + /** !#en + Helper class for ES5 Map. + !#zh + ES5 Map 辅助类。 */ + export class MapUtils { + } + /** !#en . + !#zh 。 */ + export class SkeletonAnimation extends Animation { + } + /** !#en + Skinned Mesh Renderer + !#zh + 蒙皮渲染组件 */ + export class SkinnedMeshRenderer { + /** !#en + Skeleton Asset + !#zh + 骨骼资源 */ + skeleton: sp.Skeleton; + /** !#en + Root Bone + !#zh + 骨骼根节点 */ + rootBone: Node; + } + /** !#en SkeletonAnimationClip Asset. + !#zh 骨骼动画剪辑。 */ + export class SkeletonAnimationClip extends AnimationClip { + } + /** !#en Effect Asset. + !#zh Effect 资源类型。 */ + export class EffectAsset extends Asset { + } + /** !#en Material Asset. + !#zh 材质资源类。 */ + export class Material extends Asset { + /** + !#en Creates a Material with builtin Effect. + !#zh 使用内建 Effect 创建一个材质。 + @param effectName effectName + @param techniqueIndex techniqueIndex + */ + static createWithBuiltin(effectName: string, techniqueIndex?: number): Material; + /** + !#en Creates a Material. + !#zh 创建一个材质。 + @param effectAsset effectAsset + @param techniqueIndex techniqueIndex + */ + static create(effectAsset: EffectAsset, techniqueIndex?: number): Material; + /** + !#en Sets the Material property + !#zh 是指材质的属性 + @param name name + @param val val + @param passIdx passIdx + @param directly directly + */ + setProperty(name: string, val: any, passIdx?: number, directly?: boolean): void; + /** + !#en Gets the Material property. + !#zh 获取材质的属性。 + @param name name + @param passIdx passIdx + */ + getProperty(name: string, passIdx: number): void; + /** + !#en Sets the Material define. + !#zh 设置材质的宏定义。 + @param name name + @param val val + @param passIdx passIdx + @param force force + */ + define(name: string, val: boolean|number, passIdx?: number, force?: boolean): void; + /** + !#en Gets the Material define. + !#zh 获取材质的宏定义。 + @param name name + @param passIdx passIdx + */ + getDefine(name: string, passIdx?: number): boolean; + /** + !#en Sets the Material cull mode. + !#zh 设置材质的裁减模式。 + @param cullMode cullMode + @param passIdx passIdx + */ + setCullMode(cullMode: number, passIdx: number): void; + /** + !#en Sets the Material depth states. + !#zh 设置材质的深度渲染状态。 + @param depthTest depthTest + @param depthWrite depthWrite + @param depthFunc depthFunc + @param passIdx passIdx + */ + setDepth(depthTest: boolean, depthWrite: boolean, depthFunc: number, passIdx: number): void; + /** + !#en Sets the Material blend states. + !#zh 设置材质的混合渲染状态。 + @param enabled enabled + @param blendEq blendEq + @param blendSrc blendSrc + @param blendDst blendDst + @param blendAlphaEq blendAlphaEq + @param blendSrcAlpha blendSrcAlpha + @param blendDstAlpha blendDstAlpha + @param blendColor blendColor + @param passIdx passIdx + */ + setBlend(enabled: number, blendEq: number, blendSrc: number, blendDst: number, blendAlphaEq: number, blendSrcAlpha: number, blendDstAlpha: number, blendColor: number, passIdx: number): void; + /** + !#en Sets whether enable the stencil test. + !#zh 设置是否开启模板测试。 + @param stencilTest stencilTest + @param passIdx passIdx + */ + setStencilEnabled(stencilTest: number, passIdx: number): void; + /** + !#en Sets the Material stencil render states. + !#zh 设置材质的模板测试渲染参数。 + @param stencilTest stencilTest + @param stencilFunc stencilFunc + @param stencilRef stencilRef + @param stencilMask stencilMask + @param stencilFailOp stencilFailOp + @param stencilZFailOp stencilZFailOp + @param stencilZPassOp stencilZPassOp + @param stencilWriteMask stencilWriteMask + @param passIdx passIdx + */ + setStencil(stencilTest: number, stencilFunc: number, stencilRef: number, stencilMask: number, stencilFailOp: number, stencilZFailOp: number, stencilZPassOp: number, stencilWriteMask: number, passIdx: number): void; + } + /** !#en + Material Variant is an extension of the Material Asset. + Changes to Material Variant do not affect other Material Variant or Material Asset, + and changes to Material Asset are synchronized to the Material Variant. + However, when a Material Variant had already modifies a state, the Material Asset state is not synchronized to the Material Variant. + !#zh + 材质变体是材质资源的一个延伸。 + 材质变体的修改不会影响到其他的材质变体或者材质资源,而材质资源的修改会同步体现到材质变体上, + 但是当材质变体对一个状态修改后,材质资源再对这个状态修改是不会同步到材质变体上的。 */ + export class MaterialVariant extends Material { + /** + + @param materialName materialName + @param owner owner + */ + static createWithBuiltin (materialName, owner: cc.RenderComponent): MaterialVariant | null; + /** + + @param material material + @param owner owner + */ + static create (material: Material, owner: cc.RenderComponent): MaterialVariant | null; + } + /** !#en cc.EditBox is a component for inputing text, you can use it to gather small amounts of text from users. + !#zh EditBox 组件,用于获取用户的输入文本。 */ + export class EditBox extends Component { + /** !#en Input string of EditBox. + !#zh 输入框的初始输入内容,如果为空则会显示占位符的文本。 */ + string: string; + /** !#en The Label component attached to the node for EditBox's input text label + !#zh 输入框输入文本节点上挂载的 Label 组件对象 */ + textLabel: Label; + /** !#en The Label component attached to the node for EditBox's placeholder text label + !#zh 输入框占位符节点上挂载的 Label 组件对象 */ + placeholderLabel: Label; + /** !#en The Sprite component attached to the node for EditBox's background + !#zh 输入框背景节点上挂载的 Sprite 组件对象 */ + background: Sprite; + /** !#en The background image of EditBox. This property will be removed in the future, use editBox.background instead please. + !#zh 输入框的背景图片。 该属性会在将来的版本中移除,请用 editBox.background */ + backgroundImage: SpriteFrame; + /** !#en + The return key type of EditBox. + Note: it is meaningless for web platforms and desktop platforms. + !#zh + 指定移动设备上面回车按钮的样式。 + 注意:这个选项对 web 平台与 desktop 平台无效。 */ + returnType: EditBox.KeyboardReturnType; + /** !#en Set the input flags that are to be applied to the EditBox. + !#zh 指定输入标志位,可以指定输入方式为密码或者单词首字母大写。 */ + inputFlag: EditBox.InputFlag; + /** !#en + Set the input mode of the edit box. + If you pass ANY, it will create a multiline EditBox. + !#zh + 指定输入模式: ANY表示多行输入,其它都是单行输入,移动平台上还可以指定键盘样式。 */ + inputMode: EditBox.InputMode; + /** !#en Font size of the input text. This property will be removed in the future, use editBox.textLabel.fontSize instead please. + !#zh 输入框文本的字体大小。 该属性会在将来的版本中移除,请使用 editBox.textLabel.fontSize。 */ + fontSize: number; + /** !#en Change the lineHeight of displayed text. This property will be removed in the future, use editBox.textLabel.lineHeight instead. + !#zh 输入框文本的行高。该属性会在将来的版本中移除,请使用 editBox.textLabel.lineHeight */ + lineHeight: number; + /** !#en Font color of the input text. This property will be removed in the future, use editBox.textLabel.node.color instead. + !#zh 输入框文本的颜色。该属性会在将来的版本中移除,请使用 editBox.textLabel.node.color */ + fontColor: Color; + /** !#en The display text of placeholder. + !#zh 输入框占位符的文本内容。 */ + placeholder: string; + /** !#en The font size of placeholder. This property will be removed in the future, use editBox.placeholderLabel.fontSize instead. + !#zh 输入框占位符的字体大小。该属性会在将来的版本中移除,请使用 editBox.placeholderLabel.fontSize */ + placeholderFontSize: number; + /** !#en The font color of placeholder. This property will be removed in the future, use editBox.placeholderLabel.node.color instead. + !#zh 输入框占位符的字体颜色。该属性会在将来的版本中移除,请使用 editBox.placeholderLabel.node.color */ + placeholderFontColor: Color; + /** !#en The maximize input length of EditBox. + - If pass a value less than 0, it won't limit the input number of characters. + - If pass 0, it doesn't allow input any characters. + !#zh 输入框最大允许输入的字符个数。 + - 如果值为小于 0 的值,则不会限制输入字符个数。 + - 如果值为 0,则不允许用户进行任何输入。 */ + maxLength: number; + /** !#en The input is always visible and be on top of the game view (only useful on Web), this property will be removed on v2.1 + !zh 输入框总是可见,并且永远在游戏视图的上面(这个属性只有在 Web 上面修改有意义),该属性会在 v2.1 中移除 + Note: only available on Web at the moment. */ + stayOnTop: boolean; + /** !#en Set the tabIndex of the DOM input element (only useful on Web). + !#zh 修改 DOM 输入元素的 tabIndex(这个属性只有在 Web 上面修改有意义)。 */ + tabIndex: number; + /** !#en The event handler to be called when EditBox began to edit text. + !#zh 开始编辑文本输入框触发的事件回调。 */ + editingDidBegan: Component.EventHandler[]; + /** !#en The event handler to be called when EditBox text changes. + !#zh 编辑文本输入框时触发的事件回调。 */ + textChanged: Component.EventHandler[]; + /** !#en The event handler to be called when EditBox edit ends. + !#zh 结束编辑文本输入框时触发的事件回调。 */ + editingDidEnded: Component.EventHandler[]; + /** !#en The event handler to be called when return key is pressed. Windows is not supported. + !#zh 当用户按下回车按键时的事件回调,目前不支持 windows 平台 */ + editingReturn: Component.EventHandler[]; + /** + !#en Let the EditBox get focus, this method will be removed on v2.1 + !#zh 让当前 EditBox 获得焦点, 这个方法会在 v2.1 中移除 + */ + setFocus(): void; + /** + !#en Let the EditBox get focus + !#zh 让当前 EditBox 获得焦点 + */ + focus(): void; + /** + !#en Let the EditBox lose focus + !#zh 让当前 EditBox 失去焦点 + */ + blur(): void; + /** + !#en Determine whether EditBox is getting focus or not. + !#zh 判断 EditBox 是否获得了焦点 + */ + isFocused(): void; + /** + !#en if you don't need the EditBox and it isn't in any running Scene, you should + call the destroy method on this component or the associated node explicitly. + Otherwise, the created DOM element won't be removed from web page. + !#zh + 如果你不再使用 EditBox,并且组件未添加到场景中,那么你必须手动对组件或所在节点调用 destroy。 + 这样才能移除网页上的 DOM 节点,避免 Web 平台内存泄露。 + + @example + ```js + editbox.node.parent = null; // or editbox.node.removeFromParent(false); + // when you don't need editbox anymore + editbox.node.destroy(); + ``` + */ + destroy(): boolean; + } + /** undefined */ + export class PhysicsBoxCollider extends PhysicsCollider implements Collider.Box { + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Box size + !#zh 包围盒大小 */ + size: Size; + } + /** undefined */ + export class PhysicsChainCollider extends PolygonCollider { + /** !#en Whether the chain is loop + !#zh 链条是否首尾相连 */ + loop: boolean; + /** !#en Chain points + !#zh 链条顶点数组 */ + points: Vec2[]; + } + /** undefined */ + export class PhysicsCircleCollider extends PhysicsCollider implements Collider.Circle { + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Circle radius + !#zh 圆形半径 */ + radius: number; + } + /** undefined */ + export class PhysicsCollider extends Collider { + /** !#en + The density. + !#zh + 密度 */ + density: number; + /** !#en + A sensor collider collects contact information but never generates a collision response + !#zh + 一个传感器类型的碰撞体会产生碰撞回调,但是不会发生物理碰撞效果。 */ + sensor: boolean; + /** !#en + The friction coefficient, usually in the range [0,1]. + !#zh + 摩擦系数,取值一般在 [0, 1] 之间 */ + friction: number; + /** !#en + The restitution (elasticity) usually in the range [0,1]. + !#zh + 弹性系数,取值一般在 [0, 1]之间 */ + restitution: number; + /** !#en + Physics collider will find the rigidbody component on the node and set to this property. + !#zh + 碰撞体会在初始化时查找节点上是否存在刚体,如果查找成功则赋值到这个属性上。 */ + body: RigidBody; + /** + !#en + Apply current changes to collider, this will regenerate inner box2d fixtures. + !#zh + 应用当前 collider 中的修改,调用此函数会重新生成内部 box2d 的夹具。 + */ + apply(): void; + /** + !#en + Get the world aabb of the collider + !#zh + 获取碰撞体的世界坐标系下的包围盒 + */ + getAABB(): void; + } + /** undefined */ + export class PhysicsPolygonCollider extends PhysicsCollider implements Collider.Polygon { + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Polygon points + !#zh 多边形顶点数组 */ + points: Vec2[]; + } + /** !#en + A distance joint constrains two points on two bodies + to remain at a fixed distance from each other. You can view + this as a massless, rigid rod. + !#zh + 距离关节通过一个固定的长度来约束关节链接的两个刚体。你可以将它想象成一个无质量,坚固的木棍。 */ + export class DistanceJoint extends Joint { + /** !#en + The distance separating the two ends of the joint. + !#zh + 关节两端的距离 */ + distance: number; + /** !#en + The spring frequency. + !#zh + 弹性系数。 */ + frequency: number; + /** !#en + The damping ratio. + !#zh + 阻尼,表示关节变形后,恢复到初始状态受到的阻力。 */ + dampingRatio: number; + } + /** !#en + Base class for joints to connect rigidbody. + !#zh + 关节类的基类 */ + export class Joint extends Component { + /** !#en + The anchor of the rigidbody. + !#zh + 刚体的锚点。 */ + anchor: Vec2; + /** !#en + The anchor of the connected rigidbody. + !#zh + 关节另一端刚体的锚点。 */ + connectedAnchor: Vec2; + /** !#en + The rigidbody to which the other end of the joint is attached. + !#zh + 关节另一端链接的刚体 */ + connectedBody: RigidBody; + /** !#en + Should the two rigid bodies connected with this joint collide with each other? + !#zh + 链接到关节上的两个刚体是否应该相互碰撞? */ + collideConnected: boolean; + /** + !#en + Apply current changes to joint, this will regenerate inner box2d joint. + !#zh + 应用当前关节中的修改,调用此函数会重新生成内部 box2d 的关节。 + */ + apply(): void; + /** + !#en + Get the anchor point on rigidbody in world coordinates. + !#zh + 获取刚体世界坐标系下的锚点。 + */ + getWorldAnchor(): Vec2; + /** + !#en + Get the anchor point on connected rigidbody in world coordinates. + !#zh + 获取链接刚体世界坐标系下的锚点。 + */ + getWorldConnectedAnchor(): Vec2; + /** + !#en + Gets the reaction force of the joint. + !#zh + 获取关节的反作用力。 + @param timeStep The time to calculate the reaction force for. + */ + getReactionForce(timeStep: number): Vec2; + /** + !#en + Gets the reaction torque of the joint. + !#zh + 获取关节的反扭矩。 + @param timeStep The time to calculate the reaction torque for. + */ + getReactionTorque(timeStep: number): number; + } + /** !#en + A motor joint is used to control the relative motion + between two bodies. A typical usage is to control the movement + of a dynamic body with respect to the ground. + !#zh + 马达关节被用来控制两个刚体间的相对运动。 + 一个典型的例子是用来控制一个动态刚体相对于地面的运动。 */ + export class MotorJoint extends Joint { + /** !#en + The anchor of the rigidbody. + !#zh + 刚体的锚点。 */ + anchor: Vec2; + /** !#en + The anchor of the connected rigidbody. + !#zh + 关节另一端刚体的锚点。 */ + connectedAnchor: Vec2; + /** !#en + The linear offset from connected rigidbody to rigidbody. + !#zh + 关节另一端的刚体相对于起始端刚体的位置偏移量 */ + linearOffset: Vec2; + /** !#en + The angular offset from connected rigidbody to rigidbody. + !#zh + 关节另一端的刚体相对于起始端刚体的角度偏移量 */ + angularOffset: number; + /** !#en + The maximum force can be applied to rigidbody. + !#zh + 可以应用于刚体的最大的力值 */ + maxForce: number; + /** !#en + The maximum torque can be applied to rigidbody. + !#zh + 可以应用于刚体的最大扭矩值 */ + maxTorque: number; + /** !#en + The position correction factor in the range [0,1]. + !#zh + 位置矫正系数,范围为 [0, 1] */ + correctionFactor: number; + } + /** !#en + A mouse joint is used to make a point on a body track a + specified world point. This a soft constraint with a maximum + force. This allows the constraint to stretch and without + applying huge forces. + Mouse Joint will auto register the touch event with the mouse region node, + and move the choosed rigidbody in touch move event. + Note : generally mouse joint only used in test bed. + !#zh + 鼠标关节用于使刚体上的一个点追踪一个指定的世界坐标系下的位置。 + 鼠标关节可以指定一个最大的里来施加一个柔和的约束。 + 鼠标关节会自动使用 mouse region 节点来注册鼠标事件,并且在触摸移动事件中移动选中的刚体。 + 注意:一般鼠标关节只在测试环境中使用。 */ + export class MouseJoint extends Joint { + /** !#en + The anchor of the rigidbody. + !#zh + 刚体的锚点。 */ + anchor: Vec2; + /** !#en + The anchor of the connected rigidbody. + !#zh + 关节另一端刚体的锚点。 */ + connectedAnchor: Vec2; + /** !#en + The node used to register touch evnet. + If this is null, it will be the joint's node. + !#zh + 用于注册触摸事件的节点。 + 如果没有设置这个值,那么将会使用关节的节点来注册事件。 */ + mouseRegion: Node; + /** !#en + The target point. + The mouse joint will move choosed rigidbody to target point. + !#zh + 目标点,鼠标关节将会移动选中的刚体到指定的目标点 */ + target: Vec2; + /** !#en + The spring frequency. + !#zh + 弹簧系数。 */ + frequency: number; + /** !#en + The damping ratio. + !#zh + 阻尼,表示关节变形后,恢复到初始状态受到的阻力。 */ + 0: number; + /** !#en + The maximum force + !#zh + 最大阻力值 */ + maxForce: number; + } + /** !#en + A prismatic joint. This joint provides one degree of freedom: translation + along an axis fixed in rigidbody. Relative rotation is prevented. You can + use a joint limit to restrict the range of motion and a joint motor to + drive the motion or to model joint friction. + !#zh + 移动关节指定了只能在一个方向上移动刚体。 + 你可以开启关节限制来设置刚体运行移动的间距,也可以开启马达来使用关节马达驱动刚体的运行。 */ + export class PrismaticJoint extends Joint { + /** !#en + The local joint axis relative to rigidbody. + !#zh + 指定刚体可以移动的方向。 */ + localAxisA: Vec2; + /** !#en + The reference angle. + !#zh + 相对角度 */ + referenceAngle: number; + /** !#en + Enable joint distance limit? + !#zh + 是否开启关节的距离限制? */ + enableLimit: boolean; + /** !#en + Enable joint motor? + !#zh + 是否开启关节马达? */ + enableMotor: boolean; + /** !#en + The lower joint limit. + !#zh + 刚体能够移动的最小值 */ + lowerLimit: number; + /** !#en + The upper joint limit. + !#zh + 刚体能够移动的最大值 */ + upperLimit: number; + /** !#en + The maxium force can be applied to rigidbody to rearch the target motor speed. + !#zh + 可以施加到刚体的最大力。 */ + maxMotorForce: number; + /** !#en + The expected motor speed. + !#zh + 期望的马达速度。 */ + motorSpeed: number; + } + /** !#en + A revolute joint constrains two bodies to share a common point while they + are free to rotate about the point. The relative rotation about the shared + point is the joint angle. You can limit the relative rotation with + a joint limit that specifies a lower and upper angle. You can use a motor + to drive the relative rotation about the shared point. A maximum motor torque + is provided so that infinite forces are not generated. + !#zh + 旋转关节可以约束两个刚体围绕一个点来进行旋转。 + 你可以通过开启关节限制来限制旋转的最大角度和最小角度。 + 你可以通过开启马达来施加一个扭矩力来驱动这两个刚体在这一点上的相对速度。 */ + export class RevoluteJoint extends Joint { + /** !#en + The reference angle. + An angle between bodies considered to be zero for the joint angle. + !#zh + 相对角度。 + 两个物体之间角度为零时可以看作相等于关节角度 */ + referenceAngle: number; + /** !#en + The lower angle. + !#zh + 角度的最低限制。 */ + lowerAngle: number; + /** !#en + The upper angle. + !#zh + 角度的最高限制。 */ + upperAngle: number; + /** !#en + The maxium torque can be applied to rigidbody to rearch the target motor speed. + !#zh + 可以施加到刚体的最大扭矩。 */ + maxMotorTorque: number; + /** !#en + The expected motor speed. + !#zh + 期望的马达速度。 */ + motorSpeed: number; + /** !#en + Enable joint limit? + !#zh + 是否开启关节的限制? */ + enableLimit: boolean; + /** !#en + Enable joint motor? + !#zh + 是否开启关节马达? */ + enableMotor: boolean; + /** + !#en + Get the joint angle. + !#zh + 获取关节角度。 + */ + getJointAngle(): number; + } + /** !#en + A rope joint enforces a maximum distance between two points + on two bodies. It has no other effect. + Warning: if you attempt to change the maximum length during + the simulation you will get some non-physical behavior. + !#zh + 绳子关节只指定两个刚体间的最大距离,没有其他的效果。 + 注意:如果你试图动态修改关节的长度,这有可能会得到一些意外的效果。 */ + export class RopeJoint extends Joint { + /** !#en + The max length. + !#zh + 最大长度。 */ + maxLength: number; + } + /** !#en + A wheel joint. This joint provides two degrees of freedom: translation + along an axis fixed in bodyA and rotation in the plane. You can use a joint motor to drive + the rotation or to model rotational friction. + This joint is designed for vehicle suspensions. + !#zh + 轮子关节提供两个维度的自由度:旋转和沿着指定方向上位置的移动。 + 你可以通过开启关节马达来使用马达驱动刚体的旋转。 + 轮组关节是专门为机动车类型设计的。 */ + export class WheelJoint extends Joint { + /** !#en + The local joint axis relative to rigidbody. + !#zh + 指定刚体可以移动的方向。 */ + localAxisA: Vec2; + /** !#en + The maxium torque can be applied to rigidbody to rearch the target motor speed. + !#zh + 可以施加到刚体的最大扭矩。 */ + maxMotorTorque: number; + /** !#en + The expected motor speed. + !#zh + 期望的马达速度。 */ + motorSpeed: number; + /** !#en + Enable joint motor? + !#zh + 是否开启关节马达? */ + enableMotor: boolean; + /** !#en + The spring frequency. + !#zh + 弹性系数。 */ + frequency: number; + /** !#en + The damping ratio. + !#zh + 阻尼,表示关节变形后,恢复到初始状态受到的阻力。 */ + dampingRatio: number; + } + /** !#en + A weld joint essentially glues two bodies together. A weld joint may + distort somewhat because the island constraint solver is approximate. + !#zh + 熔接关节相当于将两个刚体粘在了一起。 + 熔接关节可能会使某些东西失真,因为约束求解器算出的都是近似值。 */ + export class WeldJoint extends Joint { + /** !#en + The reference angle. + !#zh + 相对角度。 */ + referenceAngle: number; + /** !#en + The frequency. + !#zh + 弹性系数。 */ + frequency: number; + /** !#en + The damping ratio. + !#zh + 阻尼,表示关节变形后,恢复到初始状态受到的阻力。 */ + 0: number; + } + /** !#en The color over time module of 3d particle. + !#zh 3D 粒子颜色变化模块 */ + export class ColorOvertimeModule { + /** !#en The enable of ColorOvertimeModule. + !#zh 是否启用 */ + enable: boolean; + } + /** !#en The curve range of target value. + !#zh 目标值的曲线范围 */ + export class CurveRange { + /** !#en Curve type. + !#zh 曲线类型。 */ + mode: ParticleSystem.EmitterMode; + /** !#en The curve to use when mode is Curve. + !#zh 当 mode 为 Curve 时,使用的曲线。 */ + curve: AnimationCurve; + /** !#en The lower limit of the curve to use when mode is TwoCurves + !#zh 当 mode 为 TwoCurves 时,使用的曲线下限。 */ + curveMin: AnimationCurve; + /** !#en The upper limit of the curve to use when mode is TwoCurves + !#zh 当 mode 为 TwoCurves 时,使用的曲线上限。 */ + curveMax: AnimationCurve; + /** !#en When mode is Constant, the value of the curve. + !#zh 当 mode 为 Constant 时,曲线的值。 */ + constant: number; + /** !#en The lower limit of the curve to use when mode is TwoConstants + !#zh 当 mode 为 TwoConstants 时,曲线的下限。 */ + constantMin: number; + /** !#en The upper limit of the curve to use when mode is TwoConstants + !#zh 当 mode 为 TwoConstants 时,曲线的上限。 */ + constantMax: number; + /** !#en Coefficients applied to curve interpolation. + !#zh 应用于曲线插值的系数。 */ + multiplier: number; + } + /** !#en The force over time module of 3d particle. + !#zh 3D 粒子的加速度模块 */ + export class ForceOvertimeModule { + /** !#en The enable of ColorOvertimeModule. + !#zh 是否启用 */ + enable: boolean; + /** !#en Coordinate system used in acceleration calculation. + !#zh 加速度计算时采用的坐标系。 */ + space: Space; + /** !#en X-axis acceleration component. + !#zh X 轴方向上的加速度分量。 */ + x: CurveRange; + /** !#en Y-axis acceleration component. + !#zh Y 轴方向上的加速度分量。 */ + y: CurveRange; + /** !#en Z-axis acceleration component. + !#zh Z 轴方向上的加速度分量。 */ + z: CurveRange; + } + /** !#en The gradient range of color. + !#zh 颜色值的渐变范围 */ + export class GradientRange { + /** !#en Gradient type. + !#zh 渐变色类型。 */ + mode: ParticleSystem.EmitterMode; + /** !#en The color when mode is Color. + !#zh 当 mode 为 Color 时的颜色。 */ + color: Color; + /** !#en Lower color limit when mode is TwoColors. + !#zh 当 mode 为 TwoColors 时的颜色下限。 */ + colorMin: Color; + /** !#en Upper color limit when mode is TwoColors. + !#zh 当 mode 为 TwoColors 时的颜色上限。 */ + colorMax: Color; + /** !#en Color gradient when mode is Gradient + !#zh 当 mode 为 Gradient 时的颜色渐变。 */ + gradient: Gradient; + /** !#en Lower color gradient limit when mode is TwoGradients. + !#zh 当 mode 为 TwoGradients 时的颜色渐变下限。 */ + gradientMin: Gradient; + /** !#en Upper color gradient limit when mode is TwoGradients. + !#zh 当 mode 为 TwoGradients 时的颜色渐变上限。 */ + gradientMax: Gradient; + } + /** !#en The color key of gradient. + !#zh color 关键帧 */ + export class ColorKey { + } + /** !#en The alpha key of gradient. + !#zh alpha 关键帧 */ + export class AlphaKey { + } + /** !#en The gradient data of color. + !#zh 颜色渐变数据 */ + export class Gradient { + } + /** !#en The limit velocity module of 3d particle. + !#zh 3D 粒子的限速模块 */ + export class LimitVelocityOvertimeModule { + /** !#en The enable of LimitVelocityOvertimeModule. + !#zh 是否启用 */ + enable: boolean; + /** !#en The coordinate system used when calculating the lower speed limit. + !#zh 计算速度下限时采用的坐标系。 */ + space: Space; + /** !#en Whether to limit the three axes separately. + !#zh 是否三个轴分开限制。 */ + separateAxes: boolean; + /** !#en Lower speed limit + !#zh 速度下限。 */ + limit: CurveRange; + /** !#en Lower speed limit in X direction. + !#zh X 轴方向上的速度下限。 */ + limitX: CurveRange; + /** !#en Lower speed limit in Y direction. + !#zh Y 轴方向上的速度下限。 */ + limitY: CurveRange; + /** !#en Lower speed limit in Z direction. + !#zh Z 轴方向上的速度下限。 */ + limitZ: CurveRange; + /** !#en Interpolation of current speed and lower speed limit. + !#zh 当前速度与速度下限的插值。 */ + dampen: number; + } + /** !#en The optimized curve. + !#zh 优化曲线 */ + export class OptimizedCurve { + } + /** !#en The rotation module of 3d particle. + !#zh 3D 粒子的旋转模块 */ + export class RotationOvertimeModule { + /** !#en The enable of RotationOvertimeModule. + !#zh 是否启用 */ + enable: boolean; + /** !#en Whether to set the rotation of three axes separately (not currently supported) + !#zh 是否三个轴分开设定旋转(暂不支持)。 */ + separateAxes: boolean; + /** !#en Set rotation around X axis. + !#zh 绕 X 轴设定旋转。 */ + x: CurveRange; + /** !#en Set rotation around Y axis. + !#zh 绕 Y 轴设定旋转。 */ + y: CurveRange; + /** !#en Set rotation around Z axis. + !#zh 绕 Z 轴设定旋转。 */ + z: CurveRange; + } + /** !#en The size module of 3d particle. + !#zh 3D 粒子的大小模块 */ + export class SizeOvertimeModule { + /** !#en The enable of SizeOvertimeModule. + !#zh 是否启用 */ + enable: boolean; + /** !#en Decide whether to control particle size independently on each axis. + !#zh 决定是否在每个轴上独立控制粒子大小。 */ + separateAxes: boolean; + /** !#en Define a curve to determine the size change of particles during their life cycle. + !#zh 定义一条曲线来决定粒子在其生命周期中的大小变化。 */ + size: CurveRange; + /** !#en Defines a curve to determine the size change of particles in the X-axis direction during their life cycle. + !#zh 定义一条曲线来决定粒子在其生命周期中 X 轴方向上的大小变化。 */ + x: CurveRange; + /** !#en Defines a curve to determine the size change of particles in the Y-axis direction during their life cycle. + !#zh 定义一条曲线来决定粒子在其生命周期中 Y 轴方向上的大小变化。 */ + y: CurveRange; + /** !#en Defines a curve to determine the size change of particles in the Z-axis direction during their life cycle. + !#zh 定义一条曲线来决定粒子在其生命周期中 Z 轴方向上的大小变化。 */ + z: CurveRange; + } + /** !#en The texture animation module of 3d particle. + !#zh 3D 粒子的贴图动画模块 */ + export class TextureAnimationModule { + /** !#en The enable of TextureAnimationModule. + !#zh 是否启用 */ + enable: boolean; + /** !#en Set the type of particle map animation (only supports Grid mode for the time being) + !#zh 设定粒子贴图动画的类型(暂只支持 Grid 模式。 */ + mode: ParticleSystem.EmitterMode; + /** !#en Animation frames in X direction. + !#zh X 方向动画帧数。 */ + numTilesX: number; + /** !#en Animation frames in Y direction. + !#zh Y 方向动画帧数。 */ + numTilesY: number; + /** !#en The way of the animation plays. + !#zh 动画播放方式。 */ + animation: Animation; + /** !#en Randomly select a line from the animated map to generate the animation.
+ This option only takes effect when the animation playback mode is SingleRow. + !#zh 随机从动画贴图中选择一行以生成动画。
+ 此选项仅在动画播放方式为 SingleRow 时生效。 */ + randomRow: boolean; + /** !#en Select specific lines from the animation map to generate the animation.
+ This option is only available when the animation playback mode is SingleRow and randomRow is disabled. + !#zh 从动画贴图中选择特定行以生成动画。
+ 此选项仅在动画播放方式为 SingleRow 时且禁用 randomRow 时可用。 */ + rowIndex: number; + /** !#en Frame and time curve of animation playback in one cycle. + !#zh 一个周期内动画播放的帧与时间变化曲线。 */ + frameOverTime: CurveRange; + /** !#en Play from which frames, the time is the life cycle of the entire particle system. + !#zh 从第几帧开始播放,时间为整个粒子系统的生命周期。 */ + startFrame: CurveRange; + /** !#en Number of playback loops in a life cycle. + !#zh 一个生命周期内播放循环的次数。 */ + cycleCount: number; + } + /** !#en The velocity module of 3d particle. + !#zh 3D 粒子的速度模块 */ + export class VelocityOvertimeModule { + /** !#en The enable of VelocityOvertimeModule. + !#zh 是否启用 */ + enable: boolean; + /** !#en Coordinate system used in speed calculation. + !#zh 速度计算时采用的坐标系。 */ + space: Space; + /** !#en Velocity component in X axis direction + !#zh X 轴方向上的速度分量。 */ + x: CurveRange; + /** !#en Velocity component in Y axis direction + !#zh Y 轴方向上的速度分量。 */ + y: CurveRange; + /** !#en Velocity component in Z axis direction + !#zh Z 轴方向上的速度分量。 */ + z: CurveRange; + /** !#en Speed correction factor (only supports CPU particles). + !#zh 速度修正系数(只支持 CPU 粒子)。 */ + speedModifier: CurveRange; + } + /** !#en The shape module of 3d particle. + !#zh 3D 粒子的发射形状模块 */ + export class ShapeModule { + /** !#en The enable of shapeModule. + !#zh 是否启用 */ + enable: boolean; + /** !#en Particle emitter type. + !#zh 粒子发射器类型。 */ + shapeType: shapeModule.ShapeType; + /** !#en The emission site of the particle. + !#zh 粒子从发射器哪个部位发射。 */ + emitFrom: shapeModule.EmitLocation; + /** !#en Particle emitter radius. + !#zh 粒子发射器半径。 */ + radius: number; + /** !#en Particle emitter emission position (not valid for Box type emitters): + - 0 means emitted from the surface; + - 1 means launch from the center; + - 0 ~ 1 indicates emission from the center to the surface. + !#zh 粒子发射器发射位置(对 Box 类型的发射器无效): + - 0 表示从表面发射; + - 1 表示从中心发射; + - 0 ~ 1 之间表示在中心到表面之间发射。 */ + radiusThickness: number; + /** !#en The angle between the axis of the cone and the generatrix + Determines the opening and closing of the cone launcher + !#zh 圆锥的轴与母线的夹角。 + 决定圆锥发射器的开合程度。 */ + angle: number; + /** !#en Particle emitters emit in a fan-shaped range. + !#zh 粒子发射器在一个扇形范围内发射。 */ + arc: number; + /** !#en How particles are emitted in the sector range. + !#zh 粒子在扇形范围内的发射方式。 */ + arcMode: shapeModule.ArcMode; + /** !#en Controls the discrete intervals around the arcs where particles might be generated. + !#zh 控制可能产生粒子的弧周围的离散间隔。 */ + arcSpread: number; + /** !#en The speed at which particles are emitted around the circumference. + !#zh 粒子沿圆周发射的速度。 */ + arcSpeed: CurveRange; + /** !#en Axis length from top of cone to bottom of cone . + Determines the height of the cone emitter. + !#zh 圆锥顶部截面距离底部的轴长。 + 决定圆锥发射器的高度。 */ + length: number; + /** !#en Particle emitter emission location (for box-type particle emitters). + !#zh 粒子发射器发射位置(针对 Box 类型的粒子发射器。 */ + boxThickness: Vec3; + /** !#en Particle Emitter Position + !#zh 粒子发射器位置。 */ + position: Vec3; + /** !#en Particle emitter rotation angle. + !#zh 粒子发射器旋转角度。 */ + rotation: Vec3; + /** !#en Particle emitter scaling + !#zh 粒子发射器缩放比例。 */ + scale: Vec3; + /** !#en The direction of particle movement is determined based on the initial direction of the particles. + !#zh 根据粒子的初始方向决定粒子的移动方向。 */ + alignToDirection: boolean; + /** !#en Set particle generation direction randomly. + !#zh 粒子生成方向随机设定。 */ + randomDirectionAmount: number; + /** !#en Interpolation between the current emission direction and the direction from the current position to the center of the node. + !#zh 表示当前发射方向与当前位置到结点中心连线方向的插值。 */ + sphericalDirectionAmount: number; + } + /** !#en The trail module of 3d particle. + !#zh 3D 粒子拖尾模块 */ + export class TrailModule { + /** !#en The enable of trailModule. + !#zh 是否启用 */ + enable: boolean; + /** !#en Sets how particles generate trajectories. + !#zh 设定粒子生成轨迹的方式。 */ + mode: trailModule.TrailMode; + /** !#en Life cycle of trajectory. + !#zh 轨迹存在的生命周期。 */ + lifeTime: CurveRange; + /** !#en Minimum spacing between each track particle + !#zh 每个轨迹粒子之间的最小间距。 */ + minParticleDistance: number; + /** !#en The coordinate system of trajectories. + !#zh 轨迹设定时的坐标系。 */ + space: Space; + /** !#en Whether the particle itself exists. + !#zh 粒子本身是否存在。 */ + existWithParticles: boolean; + /** !#en Set the texture fill method + !#zh 设定纹理填充方式。 */ + textureMode: trailModule.TextureMode; + /** !#en Whether to use particle width + !#zh 是否使用粒子的宽度。 */ + widthFromParticle: boolean; + /** !#en Curves that control track length + !#zh 控制轨迹长度的曲线。 */ + widthRatio: CurveRange; + /** !#en Whether to use particle color + !#zh 是否使用粒子的颜色。 */ + colorFromParticle: boolean; + /** !#en The color of trajectories. + !#zh 轨迹的颜色。 */ + colorOverTrail: GradientRange; + /** !#en Trajectories color over time. + !#zh 轨迹随时间变化的颜色。 */ + colorOvertime: GradientRange; + } + /** Rigid body interface */ + export class IRigidBody { + rigidBody: RigidBody3D; + mass: number; + linearDamping: number; + angularDamping: number; + isKinematic: boolean; + useGravity: boolean; + fixedRotation: boolean; + linearFactor: IVec3Like; + angularFactor: IVec3Like; + allowSleep: boolean; + isAwake: boolean; + isSleepy: boolean; + isSleeping: boolean; + wakeUp(): void; + sleep(): void; + /** + + @param out out + */ + getLinearVelocity(out: IVec3Like): void; + /** + + @param out out + */ + setLinearVelocity(out: IVec3Like): void; + /** + + @param out out + */ + getAngularVelocity(out: IVec3Like): void; + /** + + @param out out + */ + setAngularVelocity(out: IVec3Like): void; + /** + + @param force force + @param relativePoint relativePoint + */ + applyForce(force: IVec3Like, relativePoint: IVec3Like): void; + /** + + @param force force + @param relativePoint relativePoint + */ + applyLocalForce(force: IVec3Like, relativePoint: IVec3Like): void; + /** + + @param force force + @param relativePoint relativePoint + */ + applyImpulse(force: IVec3Like, relativePoint: IVec3Like): void; + /** + + @param force force + @param relativePoint relativePoint + */ + applyLocalImpulse(force: IVec3Like, relativePoint: IVec3Like): void; + /** + + @param torque torque + */ + applyTorque(torque: IVec3Like): void; + /** + + @param torque torque + */ + applyLocalTorque(torque: IVec3Like): void; + } + /** Class has x y z properties */ + export class IVec3Like { + x: number; + y: number; + z: number; + } + /** Class has x y z w properties */ + export class IQuatLike { + x: number; + y: number; + z: number; + w: number; + } + /** !#en Base shape interface. */ + export class IBaseShape { + collider: Collider3D; + attachedRigidBody: RigidBody3D|void; + material: any; + isTrigger: boolean; + center: IVec3Like; + } + /** !#en box shape interface */ + export class IBoxShape { + size: IVec3Like; + } + /** !#en Sphere shape interface */ + export class ISphereShape { + radius: number; + } + /** Ray cast options */ + export class IRaycastOptions { + groupIndex: number; + queryTrigger: boolean; + maxDistance: number; + } + /** Collision detect */ + export class ICollisionDetect { + /** + Ray cast, and return information of the closest hit. + @param worldRay worldRay + @param options options + @param out out + */ + raycastClosest(worldRay: geomUtils.Ray, options: IRaycastOptions, out: PhysicsRayResult): boolean; + /** + Ray cast against all bodies. The provided callback will be executed for each hit with a RaycastResult as single argument. + @param worldRay worldRay + @param options options + @param pool pool + @param resultes resultes + */ + raycast(worldRay: geomUtils.Ray, options: IRaycastOptions, pool: RecyclePool, resultes: PhysicsRayResult[]): boolean; + } + /** Physics world interface */ + export class IPhysicsWorld { + } + /** !#en The rigid body type + !#zh 刚体类型 */ + export enum ERigidBodyType { + DYNAMIC = 0, + STATIC = 0, + KINEMATIC = 0, + } + /** !#en + Trigger event + !#zh + 触发事件。 */ + export class ITriggerEvent { + /** !#en + The type of event fired + !#zh + 触发的事件类型 */ + type: string; + /** !#en + Triggers its own collider in the event + !#zh + 触发事件中的自己的碰撞器 */ + selfCollider: Collider3D; + /** !#en + Triggers another collider in the event + !#zh + 触发事件中的另一个碰撞器 */ + otherCollider: Collider3D; + } + /** !#en + Collision information for collision events. + !#zh + 碰撞事件的碰撞信息。 */ + export class IContactEquation { + /** !#en + The collision point A in the collision information. + !#zh + 碰撞信息中的碰撞点A。 */ + contactA: Vec3; + /** !#en + Collision point B in collision information. + !#zh + 碰撞信息中的碰撞点B。 */ + contactB: Vec3; + /** !#en + Normals in collision information. + !#zh + 碰撞信息中的法线。 */ + normal: Vec3; + } + /** !#en + Collision events. + !#zh + 碰撞事件。 */ + export class ICollisionEvent { + /** !#en + Event type of collision. + !#zh + 碰撞的事件类型。 */ + type: string; + /** !#en + Collider of its own in collision. + !#zh + 碰撞中的自己的碰撞器。 */ + selfCollider: Collider3D; + /** !#en + Another collider in the collision. + !#zh + 碰撞中的另一个碰撞器。 */ + otherCollider: Collider3D; + /** !#en + Information about all the points of impact in the collision. + !#zh + 碰撞中的所有碰撞点的信息。 */ + contacts: IContactEquation[]; + } + /** !#en + Physical systems manager. + !#zh + 物理系统管理器。 */ + export class Physics3DManager { + /** !#en + Gets or sets whether to enable physical systems, which are not enabled by default. + !#zh + 获取或设置是否启用物理系统,默认不启用。 */ + enabled: boolean; + /** !#en + Gets or sets whether the physical system allows automatic sleep, which defaults to true. + !#zh + 获取或设置物理系统是否允许自动休眠,默认为 true */ + allowSleep: boolean; + /** !#en + Gets or sets the maximum number of child steps per frame simulated. + !#zh + 获取或设置每帧模拟的最大子步数。 */ + maxSubStep: number; + /** !#en + Gets or sets the fixed time consumed by each simulation step. + !#zh + 获取或设置每步模拟消耗的固定时间。 */ + deltaTime: number; + /** !#en + Gets or sets whether to use a fixed time step. + !#zh + 获取或设置是否使用固定的时间步长。 */ + useFixedTime: boolean; + /** !#en + Gets or sets the gravity value of the physical world, by default (0, -10, 0) + !#zh + 获取或设置物理世界的重力数值,默认为 (0, -10, 0) */ + gravity: Vec3; + /** !#en + Gets the global default physical material. Note that builtin is null + !#zh + 获取全局的默认物理材质,注意:builtin 时为 null */ + defaultMaterial: PhysicsMaterial|void; + /** + !#en + A physical system simulation is performed once and will now be performed automatically once per frame. + !#zh + 执行一次物理系统的模拟,目前将在每帧自动执行一次。 + @param deltaTime The time difference from the last execution is currently elapsed per frame + */ + update(deltaTime: number): void; + /** + !#en Detect all collision boxes and return all detected results, or null if none is detected. Note that the return value is taken from the object pool, so do not save the result reference or modify the result. + !#zh 检测所有的碰撞盒,并返回所有被检测到的结果,若没有检测到,则返回空值。注意返回值是从对象池中取的,所以请不要保存结果引用或者修改结果。 + @param worldRay A ray in world space + @param groupIndexOrName Collision group index or group name + @param maxDistance Maximum detection distance + @param queryTrigger Detect trigger or not + */ + raycast(worldRay: geomUtils.Ray, groupIndexOrName: number|string, maxDistance: number, queryTrigger: boolean): PhysicsRayResult[]; + /** + !#en Detect all collision boxes and return the detection result with the shortest ray distance. If not, return null value. Note that the return value is taken from the object pool, so do not save the result reference or modify the result. + !#zh 检测所有的碰撞盒,并返回射线距离最短的检测结果,若没有,则返回空值。注意返回值是从对象池中取的,所以请不要保存结果引用或者修改结果。 + @param worldRay A ray in world space + @param groupIndexOrName Collision group index or group name + @param maxDistance Maximum detection distance + @param queryTrigger Detect trigger or not + */ + raycastClosest(worldRay: geomUtils.Ray, groupIndexOrName: number|string, maxDistance: number, queryTrigger: boolean): PhysicsRayResult; + } + /** !#en + Used to store physical ray detection results + !#zh + 用于保存物理射线检测结果 */ + export class PhysicsRayResult { + /** !#en + Hit the point + !#zh + 击中点 */ + hitPoint: Vec3; + /** !#en + Distance + !#zh + 距离 */ + distance: number; + /** !#en + Hit the collision box + !#zh + 击中的碰撞盒 */ + collider: Collider3D; + /** + !#en + Set up ray. This method is used internally by the engine. Do not call it from an external script + !#zh + 设置射线,此方法由引擎内部使用,请勿在外部脚本调用 + @param hitPoint hitPoint + @param distance distance + @param collider collider + */ + _assign(hitPoint: Vec3, distance: number, collider: Collider3D): void; + /** + !#en + Clone + !#zh + 克隆 + */ + clone(): void; + } + /** !#en Manage Dynamic Atlas Manager. Dynamic Atlas Manager is used for merging textures at runtime, see [Dynamic Atlas](https://docs.cocos.com/creator/manual/en/advanced-topics/dynamic-atlas.html) for details. + !#zh 管理动态图集。动态图集用于在运行时对贴图进行合并,详见 [动态合图](https://docs.cocos.com/creator/manual/zh/advanced-topics/dynamic-atlas.html)。 */ + export class DynamicAtlasManager { + /** !#en Enable or disable the dynamic atlas, see [Dynamic Atlas](https://docs.cocos.com/creator/manual/en/advanced-topics/dynamic-atlas.html) for details. + !#zh 开启或者关闭动态图集,详见 [动态合图](https://docs.cocos.com/creator/manual/zh/advanced-topics/dynamic-atlas.html)。 */ + enabled: boolean; + /** !#en The maximum number of atlas that can be created. + !#zh 可以创建的最大图集数量。 */ + maxAtlasCount: number; + /** !#en Is enable textureBleeding. + !#zh 是否开启 textureBleeding */ + textureBleeding: boolean; + /** !#en The size of the atlas that was created + !#zh 创建的图集的宽高 */ + textureSize: number; + /** !#en The maximum size of the picture that can be added to the atlas. + !#zh 可以添加进图集的图片的最大尺寸。 */ + maxFrameSize: number; + /** !#en The minimum size of the picture that can be added to the atlas. + !#zh 可以添加进图集的图片的最小尺寸。 */ + minFrameSize: number; + /** + !#en Append a sprite frame into the dynamic atlas. + !#zh 添加碎图进入动态图集。 + @param spriteFrame spriteFrame + */ + insertSpriteFrame(spriteFrame: SpriteFrame): void; + /** + !#en Resets all dynamic atlas, and the existing ones will be destroyed. + !#zh 重置所有动态图集,已有的动态图集会被销毁。 + */ + reset(): void; + /** + !#en Displays all the dynamic atlas in the current scene, which you can use to view the current atlas state. + !#zh 在当前场景中显示所有动态图集,可以用来查看当前的合图状态。 + @param show show + */ + showDebug(show: boolean): void; + } + /** Physics material. */ + export class PhysicsMaterial extends Asset { + /** Friction for this material. + If non-negative, it will be used instead of the friction given by ContactMaterials. + If there's no matching ContactMaterial, the value from .defaultContactMaterial in the World will be used. */ + friction: number; + /** Restitution for this material. + If non-negative, it will be used instead of the restitution given by ContactMaterials. + If there's no matching ContactMaterial, the value from .defaultContactMaterial in the World will be used */ + restitution: number; + } + /** !#en + Each frame applies a constant force to a rigid body, depending on the RigidBody3D + !#zh + 在每帧对一个刚体施加持续的力,依赖 RigidBody3D 组件 */ + export class ConstantForce extends Component { + /** !#en + To get and set the force that the world is facing, use this.force = otherVec3 + !#zh + 获取和设置世界朝向的力, 设置时请用 this.force = otherVec3 的方式 */ + force: Vec3; + /** !#en + Get and set the force of the local orientation, using this.localforce = otherVec3 + !#zh + 获取和设置本地朝向的力, 设置时请用 this.localForce = otherVec3 的方式 */ + localForce: Vec3; + /** !#zh + 获取和设置世界朝向的扭转力 */ + torque: Vec3; + /** !#en + Get and set the torque of the local orientation using this.localtorque = otherVec3 + !#zh + 获取和设置本地朝向的扭转力, 设置时请用 this.localTorque = otherVec3 的方式 */ + localTorque: Vec3; + } + /** !#en + Rigid body. + !#zh + 刚体组件。 */ + export class RigidBody3D extends Component { + /** !#en + Gets or sets whether sleep is allowed + !#zh + 获取或设置是否允许休眠 */ + allowSleep: boolean; + /** !#en + Gets or sets the mass of the rigid body. + !#zh + 获取或设置刚体的质量。 */ + mass: number; + /** !#en + Gets or sets linear damping. + !#zh + 获取或设置线性阻尼。 */ + linearDamping: number; + /** !#en + Gets or sets rotational damping. + !#zh + 获取或设置旋转阻尼。 */ + angularDamping: number; + /** !#en + Gets or sets whether the rigid body is controlled by a physical system. + !#zh + 获取或设置刚体是否由物理系统控制运动。 */ + isKinematic: boolean; + /** !#en + Gets or sets whether the rigid body uses gravity. + !#zh + 获取或设置刚体是否使用重力。 */ + useGravity: boolean; + /** !#en + Gets or sets whether the rigid body is fixed for rotation. + !#zh + 获取或设置刚体是否固定旋转。 */ + fixedRotation: boolean; + /** !#en + Gets or sets a factor of linear velocity that can be used to control the scaling of velocity in each axis direction. + !#zh + 获取或设置线性速度的因子,可以用来控制每个轴方向上的速度的缩放。 */ + linearFactor: Vec3; + /** !#en + Gets or sets the rotation speed factor that can be used to control the rotation speed scaling in each axis direction. + !#zh + 获取或设置旋转速度的因子,可以用来控制每个轴方向上的旋转速度的缩放。 */ + angularFactor: Vec3; + /** !#en + Gets whether the state is awakened. + !#zh + 获取是否是唤醒的状态。 */ + isAwake: boolean; + /** !#en + Gets whether or not a dormant state can be entered. + !#zh + 获取是否是可进入休眠的状态。 */ + isSleepy: boolean; + /** !#en + Gets whether the state is dormant. + !#zh + 获取是否是正在休眠的状态。 */ + isSleeping: boolean; + /** !#en + Gets physics engine rigid body object. + !#zh + 获得物理引擎内部刚体对象 */ + rigidBody: IRigidBody; + /** + !#en + A force is applied to a rigid body at a point in world space. + !#zh + 在世界空间中的某点上对刚体施加一个作用力。 + @param force force + @param relativePoint The point of action, relative to the center of the rigid body + */ + applyForce(force: Vec3, relativePoint: Vec3): void; + /** + !#en + Apply a force on the rigid body at a point in local space. + !#zh + 在本地空间中的某点上对刚体施加一个作用力。 + @param force force + @param localPoint Point of application + */ + applyLocalForce(force: Vec3, localPoint: Vec3): void; + /** + !#en + Apply an impulse to a rigid body at a point in world space. + !#zh + 在世界空间的某点上对刚体施加一个冲量。 + @param impulse impulse + @param relativePoint The point of action, relative to the center of the rigid body + */ + applyImpulse(impulse: Vec3, relativePoint: Vec3): void; + /** + !#en + Apply an impulse to the rigid body at a point in local space. + !#zh + 在本地空间的某点上对刚体施加一个冲量。 + @param impulse impulse + @param localPoint Point of application + */ + applyLocalImpulse(impulse: Vec3, localPoint: Vec3): void; + /** + !#en + Apply a torque to the rigid body. + !#zh + 对刚体施加扭转力。 + @param torque torque + */ + applyTorque(torque: Vec3): void; + /** + !#en + Apply a local torque to the rigid body. + !#zh + 对刚体施加本地扭转力。 + @param torque torque + */ + applyLocalTorque(torque: Vec3): void; + /** + !#en + Awaken the rigid body. + !#zh + 唤醒刚体。 + */ + wakeUp(): void; + /** + !#en + Dormant rigid body. + !#zh + 休眠刚体。 + */ + sleep(): void; + /** + !#en + Get linear velocity. + !#zh + 获取线性速度。 + @param out out + */ + getLinearVelocity(out: Vec3): void; + /** + !#en + Set linear speed. + !#zh + 设置线性速度。 + @param value value + */ + setLinearVelocity(value: Vec3): void; + /** + !#en + Gets the rotation speed. + !#zh + 获取旋转速度。 + @param out out + */ + getAngularVelocity(out: Vec3): void; + /** + !#en + Set rotation speed. + !#zh + 设置旋转速度。 + @param value value + */ + setAngularVelocity(value: Vec3): void; + } + /** !#en + Physics box collider + !#zh + 物理盒子碰撞器 */ + export class BoxCollider3D extends Collider3D { + /** !#en + Get or set the size of the box, in local space. + !#zh + 获取或设置盒的大小。 */ + size: Vec3; + boxShape: IBoxShape; + } + /** !#en + The base class of the collider + !#zh + 碰撞器的基类 */ + export class Collider3D extends Component implements EventTarget { + sharedMaterial: PhysicsMaterial; + /** !#en + get or set the collider is trigger, this will be always trigger if using builtin. + !#zh + 获取或设置碰撞器是否为触发器 */ + isTrigger: boolean; + /** !#en + get or set the center of the collider, in local space. + !#zh + 获取或设置碰撞器的中心点。 */ + center: Vec3; + /** !#en + get the collider attached rigidbody, this may be null + !#zh + 获取碰撞器所绑定的刚体组件,可能为 null */ + attachedRigidbody: RigidBody3D|void; + /** !#en + get collider shape + !#zh + 获取碰撞器形状 */ + shape: IBaseShape; + /** + !#en + Register an callback of a specific event type on the EventTarget. + This type of event should be triggered via `emit`. + !#zh + 注册事件目标的特定事件类型回调。这种类型的事件应该被 `emit` 触发。 + @param type The type of collider event can be 'trigger-enter', 'trigger-stay', 'trigger-exit' or 'collision-enter', 'collision-stay', 'collision-exit'. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.on('fire', function (event) { + // event is ITriggerEvent or ICollisionEvent + }, node); + ``` + */ + on(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. + !#zh + 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。 + @param type The type of collider event can be 'trigger-enter', 'trigger-stay', 'trigger-exit' or 'collision-enter', 'collision-stay', 'collision-exit'. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + + @example + ```js + // register fire eventListener + var callback = eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, target); + // remove fire event listener + eventTarget.off('fire', callback, target); + // remove all fire event listeners + eventTarget.off('fire'); + ``` + */ + off(type: string, callback?: Function, target?: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type The type of collider event can be 'trigger-enter', 'trigger-stay', 'trigger-exit' or 'collision-enter', 'collision-stay', 'collision-exit'. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.once('fire', function (event) { + // event is ITriggerEvent or ICollisionEvent + }, node); + ``` + */ + once(type: string, callback: (event: ITriggerEvent|ICollisionEvent) => void, target?: any): void; + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Send an event with the event object. + !#zh + 通过事件对象派发事件 + @param event event + */ + dispatchEvent(event: Event): void; + } + /** !#en + Physics sphere collider + !#zh + 物理球碰撞器 */ + export class SphereCollider3D extends Collider3D { + /** !#en + Get or set the radius of the sphere. + !#zh + 获取或设置球的半径。 */ + radius: number; + sphereShape: ISphereShape; + } + /**************************************************** + * audioEngine + *****************************************************/ + + export namespace audioEngine { + /** !#en Audio state. + !#zh 声音播放状态 */ + export enum AudioState { + ERROR = 0, + INITIALZING = 0, + PLAYING = 0, + PAUSED = 0, + STOPPED = 0, + } + } + + /**************************************************** + * ParticleSystem + *****************************************************/ + + export namespace ParticleSystem { + /** !#en Enum for emitter modes + !#zh 发射模式 */ + export enum EmitterMode { + GRAVITY = 0, + RADIUS = 0, + } + } + + /**************************************************** + * ParticleSystem + *****************************************************/ + + export namespace ParticleSystem { + /** !#en Enum for particles movement type. + !#zh 粒子位置类型 */ + export enum PositionType { + FREE = 0, + RELATIVE = 0, + GROUPED = 0, + } + } + + /**************************************************** + * TiledMap + *****************************************************/ + + export namespace TiledMap { + /** !#en The orientation of tiled map. + !#zh Tiled Map 地图方向。 */ + export enum Orientation { + ORTHO = 0, + HEX = 0, + ISO = 0, + } + } + + /**************************************************** + * TiledMap + *****************************************************/ + + export namespace TiledMap { + /** The property type of tiled map. */ + export enum Property { + NONE = 0, + MAP = 0, + LAYER = 0, + OBJECTGROUP = 0, + OBJECT = 0, + TILE = 0, + } + } + + /**************************************************** + * TiledMap + *****************************************************/ + + export namespace TiledMap { + /** The tile flags of tiled map. */ + export enum TileFlag { + HORIZONTAL = 0, + VERTICAL = 0, + DIAGONAL = 0, + FLIPPED_ALL = 0, + FLIPPED_MASK = 0, + } + } + + /**************************************************** + * TiledMap + *****************************************************/ + + export namespace TiledMap { + /** !#en The stagger axis of Hex tiled map. + !#zh 六边形地图的 stagger axis 值 */ + export enum StaggerAxis { + STAGGERAXIS_X = 0, + STAGGERAXIS_Y = 0, + } + } + + /**************************************************** + * TiledMap + *****************************************************/ + + export namespace TiledMap { + /** !#en The render order of tiled map. + !#zh 地图的渲染顺序 */ + export enum RenderOrder { + STAGGERINDEX_ODD = 0, + STAGGERINDEX_EVEN = 0, + RightDown = 0, + RightUp = 0, + LeftDown = 0, + LeftUp = 0, + } + } + + /**************************************************** + * TiledMap + *****************************************************/ + + export namespace TiledMap { + /** !#en TiledMap Object Type + !#zh 地图物体类型 */ + export enum TMXObjectType { + RECT = 0, + ELLIPSE = 0, + POLYGON = 0, + POLYLINE = 0, + IMAGE = 0, + TEXT = 0, + } + } + + /**************************************************** + * debug + *****************************************************/ + + export namespace debug { + /** !#en Enum for debug modes. + !#zh 调试模式 */ + export enum DebugMode { + NONE = 0, + INFO = 0, + WARN = 0, + ERROR = 0, + INFO_FOR_WEB_PAGE = 0, + WARN_FOR_WEB_PAGE = 0, + ERROR_FOR_WEB_PAGE = 0, + } + } + + /**************************************************** + * Node + *****************************************************/ + + export namespace Node { + /** !#en Node's local dirty properties flag + !#zh Node 的本地属性 dirty 状态位 */ + export enum _LocalDirtyFlag { + POSITION = 0, + SCALE = 0, + ROTATION = 0, + SKEW = 0, + TRS = 0, + RS = 0, + TRS = 0, + PHYSICS_POSITION = 0, + PHYSICS_SCALE = 0, + PHYSICS_ROTATION = 0, + PHYSICS_TRS = 0, + PHYSICS_RS = 0, + ALL_POSITION = 0, + ALL_SCALE = 0, + ALL_ROTATION = 0, + ALL_TRS = 0, + ALL = 0, + } + } + + /**************************************************** + * Node + *****************************************************/ + + export namespace Node { + /** !#en The event type supported by Node + !#zh Node 支持的事件类型 */ + export class EventType { + /** !#en The event type for touch start event, you can use its value directly: 'touchstart' + !#zh 当手指触摸到屏幕时。 */ + static TOUCH_START: string; + /** !#en The event type for touch move event, you can use its value directly: 'touchmove' + !#zh 当手指在屏幕上移动时。 */ + static TOUCH_MOVE: string; + /** !#en The event type for touch end event, you can use its value directly: 'touchend' + !#zh 当手指在目标节点区域内离开屏幕时。 */ + static TOUCH_END: string; + /** !#en The event type for touch end event, you can use its value directly: 'touchcancel' + !#zh 当手指在目标节点区域外离开屏幕时。 */ + static TOUCH_CANCEL: string; + /** !#en The event type for mouse down events, you can use its value directly: 'mousedown' + !#zh 当鼠标按下时触发一次。 */ + static MOUSE_DOWN: string; + /** !#en The event type for mouse move events, you can use its value directly: 'mousemove' + !#zh 当鼠标在目标节点在目标节点区域中移动时,不论是否按下。 */ + static MOUSE_MOVE: string; + /** !#en The event type for mouse enter target events, you can use its value directly: 'mouseenter' + !#zh 当鼠标移入目标节点区域时,不论是否按下。 */ + static MOUSE_ENTER: string; + /** !#en The event type for mouse leave target events, you can use its value directly: 'mouseleave' + !#zh 当鼠标移出目标节点区域时,不论是否按下。 */ + static MOUSE_LEAVE: string; + /** !#en The event type for mouse up events, you can use its value directly: 'mouseup' + !#zh 当鼠标从按下状态松开时触发一次。 */ + static MOUSE_UP: string; + /** !#en The event type for mouse wheel events, you can use its value directly: 'mousewheel' + !#zh 当鼠标滚轮滚动时。 */ + static MOUSE_WHEEL: string; + /** !#en The event type for position change events. + Performance note, this event will be triggered every time corresponding properties being changed, + if the event callback have heavy logic it may have great performance impact, try to avoid such scenario. + !#zh 当节点位置改变时触发的事件。 + 性能警告:这个事件会在每次对应的属性被修改时触发,如果事件回调损耗较高,有可能对性能有很大的负面影响,请尽量避免这种情况。 */ + static POSITION_CHANGED: string; + /** !#en The event type for rotation change events. + Performance note, this event will be triggered every time corresponding properties being changed, + if the event callback have heavy logic it may have great performance impact, try to avoid such scenario. + !#zh 当节点旋转改变时触发的事件。 + 性能警告:这个事件会在每次对应的属性被修改时触发,如果事件回调损耗较高,有可能对性能有很大的负面影响,请尽量避免这种情况。 */ + static ROTATION_CHANGED: string; + /** !#en The event type for scale change events. + Performance note, this event will be triggered every time corresponding properties being changed, + if the event callback have heavy logic it may have great performance impact, try to avoid such scenario. + !#zh 当节点缩放改变时触发的事件。 + 性能警告:这个事件会在每次对应的属性被修改时触发,如果事件回调损耗较高,有可能对性能有很大的负面影响,请尽量避免这种情况。 */ + static SCALE_CHANGED: string; + /** !#en The event type for size change events. + Performance note, this event will be triggered every time corresponding properties being changed, + if the event callback have heavy logic it may have great performance impact, try to avoid such scenario. + !#zh 当节点尺寸改变时触发的事件。 + 性能警告:这个事件会在每次对应的属性被修改时触发,如果事件回调损耗较高,有可能对性能有很大的负面影响,请尽量避免这种情况。 */ + static SIZE_CHANGED: string; + /** !#en The event type for anchor point change events. + Performance note, this event will be triggered every time corresponding properties being changed, + if the event callback have heavy logic it may have great performance impact, try to avoid such scenario. + !#zh 当节点锚点改变时触发的事件。 + 性能警告:这个事件会在每次对应的属性被修改时触发,如果事件回调损耗较高,有可能对性能有很大的负面影响,请尽量避免这种情况。 */ + static ANCHOR_CHANGED: string; + /** !#en The event type for color change events. + Performance note, this event will be triggered every time corresponding properties being changed, + if the event callback have heavy logic it may have great performance impact, try to avoid such scenario. + !#zh 当节点颜色改变时触发的事件。 + 性能警告:这个事件会在每次对应的属性被修改时触发,如果事件回调损耗较高,有可能对性能有很大的负面影响,请尽量避免这种情况。 */ + static COLOR_CHANGED: string; + /** !#en The event type for new child added events. + !#zh 当新的子节点被添加时触发的事件。 */ + static CHILD_ADDED: string; + /** !#en The event type for child removed events. + !#zh 当子节点被移除时触发的事件。 */ + static CHILD_REMOVED: string; + /** !#en The event type for children reorder events. + !#zh 当子节点顺序改变时触发的事件。 */ + static CHILD_REORDER: string; + /** !#en The event type for node group changed events. + !#zh 当节点归属群组发生变化时触发的事件。 */ + static GROUP_CHANGED: string; + /** !#en The event type for node's sibling order changed. + !#zh 当节点在兄弟节点中的顺序发生变化时触发的事件。 */ + static SIBLING_ORDER_CHANGED: string; + } + } + + /**************************************************** + * WebView + *****************************************************/ + + export namespace WebView { + /** !#en WebView event type + !#zh 网页视图事件类型 */ + export enum EventType { + LOADED = 0, + LOADING = 0, + ERROR = 0, + } + } + + /**************************************************** + * VideoPlayer + *****************************************************/ + + export namespace VideoPlayer { + /** !#en Video event type + !#zh 视频事件类型 */ + export enum EventType { + PLAYING = 0, + PAUSED = 0, + STOPPED = 0, + COMPLETED = 0, + META_LOADED = 0, + CLICKED = 0, + READY_TO_PLAY = 0, + } + } + + /**************************************************** + * VideoPlayer + *****************************************************/ + + export namespace VideoPlayer { + /** !#en Enum for video resouce type type. + !#zh 视频来源 */ + export enum ResourceType { + REMOTE = 0, + LOCAL = 0, + } + } + + /**************************************************** + * Camera + *****************************************************/ + + export namespace Camera { + /** !#en Values for Camera.clearFlags, determining what to clear when rendering a Camera. + !#zh 摄像机清除标记位,决定摄像机渲染时会清除哪些状态 */ + export enum ClearFlags { + COLOR = 0, + DEPTH = 0, + STENCIL = 0, + } + } + + /**************************************************** + * Light + *****************************************************/ + + export namespace Light { + /** !#en The light source type + + !#zh 光源类型 */ + export enum Type { + DIRECTIONAL = 0, + POINT = 0, + SPOT = 0, + AMBIENT = 0, + } + } + + /**************************************************** + * Light + *****************************************************/ + + export namespace Light { + /** !#en The shadow type + + !#zh 阴影类型 */ + export enum ShadowType { + NONE = 0, + HARD = 0, + SOFT_PCF3X3 = 0, + SOFT_PCF5X5 = 0, + } + } + + /**************************************************** + * Collider + *****************************************************/ + + export namespace Collider { + /** !#en Defines a Box Collider . + !#zh 用来定义包围盒碰撞体 */ + export class Box { + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Box size + !#zh 包围盒大小 */ + size: Size; + } + } + + /**************************************************** + * Collider + *****************************************************/ + + export namespace Collider { + /** !#en Defines a Circle Collider . + !#zh 用来定义圆形碰撞体 */ + export class Circle { + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Circle radius + !#zh 圆形半径 */ + radius: number; + } + } + + /**************************************************** + * Collider + *****************************************************/ + + export namespace Collider { + /** !#en Defines a Polygon Collider . + !#zh 用来定义多边形碰撞体 */ + export class Polygon { + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Polygon points + !#zh 多边形顶点数组 */ + points: Vec2[]; + } + } + + /**************************************************** + * Prefab + *****************************************************/ + + export namespace Prefab { + /** !#zh + Prefab 创建实例所用的优化策略,配合 {{#crossLink "Prefab.optimizationPolicy"}}cc.Prefab#optimizationPolicy{{/crossLink}} 使用。 + !#en + An enumeration used with the {{#crossLink "Prefab.optimizationPolicy"}}cc.Prefab#optimizationPolicy{{/crossLink}} + to specify how to optimize the instantiate operation. */ + export enum OptimizationPolicy { + AUTO = 0, + SINGLE_INSTANCE = 0, + MULTI_INSTANCE = 0, + } + } + + /**************************************************** + * RenderTexture + *****************************************************/ + + export namespace RenderTexture { + /** !#en The depth buffer and stencil buffer format for RenderTexture. + !#zh RenderTexture 的深度缓冲以及模板缓冲格式。 */ + export enum DepthStencilFormat { + RB_FMT_D24S8 = 0, + RB_FMT_S8 = 0, + RB_FMT_D16 = 0, + } + } + + /**************************************************** + * Texture2D + *****************************************************/ + + export namespace Texture2D { + /** The texture pixel format, default value is RGBA8888, + you should note that textures loaded by normal image files (png, jpg) can only support RGBA8888 format, + other formats are supported by compressed file types or raw data. */ + export enum PixelFormat { + RGB565 = 0, + RGB5A1 = 0, + RGBA4444 = 0, + RGB888 = 0, + RGBA8888 = 0, + RGBA32F = 0, + A8 = 0, + I8 = 0, + AI88 = 0, + RGB_PVRTC_2BPPV1 = 0, + RGBA_PVRTC_2BPPV1 = 0, + RGB_A_PVRTC_2BPPV1 = 0, + RGB_PVRTC_4BPPV1 = 0, + RGBA_PVRTC_4BPPV1 = 0, + RGB_A_PVRTC_4BPPV1 = 0, + RGB_ETC1 = 0, + RGBA_ETC1 = 0, + RGB_ETC2 = 0, + RGBA_ETC2 = 0, + } + } + + /**************************************************** + * Texture2D + *****************************************************/ + + export namespace Texture2D { + /** The texture wrap mode */ + export enum WrapMode { + REPEAT = 0, + CLAMP_TO_EDGE = 0, + MIRRORED_REPEAT = 0, + } + } + + /**************************************************** + * Texture2D + *****************************************************/ + + export namespace Texture2D { + /** The texture filter mode */ + export enum Filter { + LINEAR = 0, + NEAREST = 0, + } + } + + /**************************************************** + * Event + *****************************************************/ + + export namespace Event { + /** !#en The mouse event + !#zh 鼠标事件类型 */ + export class EventMouse extends Event { + /** + !#en Sets scroll data. + !#zh 设置鼠标的滚动数据。 + @param scrollX scrollX + @param scrollY scrollY + */ + setScrollData(scrollX: number, scrollY: number): void; + /** + !#en Returns the x axis scroll value. + !#zh 获取鼠标滚动的X轴距离,只有滚动时才有效。 + */ + getScrollX(): number; + /** + !#en Returns the y axis scroll value. + !#zh 获取滚轮滚动的 Y 轴距离,只有滚动时才有效。 + */ + getScrollY(): number; + /** + !#en Sets cursor location. + !#zh 设置当前鼠标位置。 + @param x x + @param y y + */ + setLocation(x: number, y: number): void; + /** + !#en Returns cursor location. + !#zh 获取鼠标位置对象,对象包含 x 和 y 属性。 + */ + getLocation(): Vec2; + /** + !#en Returns the current cursor location in screen coordinates. + !#zh 获取当前事件在游戏窗口内的坐标位置对象,对象包含 x 和 y 属性。 + */ + getLocationInView(): Vec2; + /** + !#en Returns the previous touch location. + !#zh 获取鼠标点击在上一次事件时的位置对象,对象包含 x 和 y 属性。 + */ + getPreviousLocation(): Vec2; + /** + !#en Returns the delta distance from the previous location to current location. + !#zh 获取鼠标距离上一次事件移动的距离对象,对象包含 x 和 y 属性。 + */ + getDelta(): Vec2; + /** + !#en Returns the X axis delta distance from the previous location to current location. + !#zh 获取鼠标距离上一次事件移动的 X 轴距离。 + */ + getDeltaX(): number; + /** + !#en Returns the Y axis delta distance from the previous location to current location. + !#zh 获取鼠标距离上一次事件移动的 Y 轴距离。 + */ + getDeltaY(): number; + /** + !#en Sets mouse button. + !#zh 设置鼠标按键。 + @param button button + */ + setButton(button: number): void; + /** + !#en Returns mouse button. + !#zh 获取鼠标按键。 + */ + getButton(): number; + /** + !#en Returns location X axis data. + !#zh 获取鼠标当前位置 X 轴。 + */ + getLocationX(): number; + /** + !#en Returns location Y axis data. + !#zh 获取鼠标当前位置 Y 轴。 + */ + getLocationY(): number; + /** !#en The none event code of mouse event. + !#zh 无。 */ + static NONE: number; + /** !#en The event type code of mouse down event. + !#zh 鼠标按下事件。 */ + static DOWN: number; + /** !#en The event type code of mouse up event. + !#zh 鼠标按下后释放事件。 */ + static UP: number; + /** !#en The event type code of mouse move event. + !#zh 鼠标移动事件。 */ + static MOVE: number; + /** !#en The event type code of mouse scroll event. + !#zh 鼠标滚轮事件。 */ + static SCROLL: number; + /** !#en The tag of Mouse left button. + !#zh 鼠标左键的标签。 */ + static BUTTON_LEFT: number; + /** !#en The tag of Mouse right button (The right button number is 2 on browser). + !#zh 鼠标右键的标签。 */ + static BUTTON_RIGHT: number; + /** !#en The tag of Mouse middle button (The right button number is 1 on browser). + !#zh 鼠标中键的标签。 */ + static BUTTON_MIDDLE: number; + /** !#en The tag of Mouse button 4. + !#zh 鼠标按键 4 的标签。 */ + static BUTTON_4: number; + /** !#en The tag of Mouse button 5. + !#zh 鼠标按键 5 的标签。 */ + static BUTTON_5: number; + /** !#en The tag of Mouse button 6. + !#zh 鼠标按键 6 的标签。 */ + static BUTTON_6: number; + /** !#en The tag of Mouse button 7. + !#zh 鼠标按键 7 的标签。 */ + static BUTTON_7: number; + /** !#en The tag of Mouse button 8. + !#zh 鼠标按键 8 的标签。 */ + static BUTTON_8: number; + } + } + + /**************************************************** + * Event + *****************************************************/ + + export namespace Event { + /** !#en The touch event + !#zh 触摸事件 */ + export class EventTouch extends Event { + /** + + @param touchArr The array of the touches + @param bubbles A boolean indicating whether the event bubbles up through the tree or not + */ + constructor(touchArr: any[], bubbles: boolean); + /** !#en The current touch object + !#zh 当前触点对象 */ + touch: Touch; + /** + !#en Returns event code. + !#zh 获取事件类型。 + */ + getEventCode(): number; + /** + !#en Returns touches of event. + !#zh 获取触摸点的列表。 + */ + getTouches(): any[]; + /** + !#en Sets touch location. + !#zh 设置当前触点位置 + @param x x + @param y y + */ + setLocation(x: number, y: number): void; + /** + !#en Returns touch location. + !#zh 获取触点位置。 + */ + getLocation(): Vec2; + /** + !#en Returns the current touch location in screen coordinates. + !#zh 获取当前触点在游戏窗口中的位置。 + */ + getLocationInView(): Vec2; + /** + !#en Returns the previous touch location. + !#zh 获取触点在上一次事件时的位置对象,对象包含 x 和 y 属性。 + */ + getPreviousLocation(): Vec2; + /** + !#en Returns the start touch location. + !#zh 获取触点落下时的位置对象,对象包含 x 和 y 属性。 + */ + getStartLocation(): Vec2; + /** + !#en Returns the id of cc.Touch. + !#zh 触点的标识 ID,可以用来在多点触摸中跟踪触点。 + */ + getID(): number; + /** + !#en Returns the delta distance from the previous location to current location. + !#zh 获取触点距离上一次事件移动的距离对象,对象包含 x 和 y 属性。 + */ + getDelta(): Vec2; + /** + !#en Returns the X axis delta distance from the previous location to current location. + !#zh 获取触点距离上一次事件移动的 x 轴距离。 + */ + getDeltaX(): number; + /** + !#en Returns the Y axis delta distance from the previous location to current location. + !#zh 获取触点距离上一次事件移动的 y 轴距离。 + */ + getDeltaY(): number; + /** + !#en Returns location X axis data. + !#zh 获取当前触点 X 轴位置。 + */ + getLocationX(): number; + /** + !#en Returns location Y axis data. + !#zh 获取当前触点 Y 轴位置。 + */ + getLocationY(): number; + } + } + + /**************************************************** + * Event + *****************************************************/ + + export namespace Event { + /** !#en The acceleration event + !#zh 加速度事件 */ + export class EventAcceleration extends Event { + } + } + + /**************************************************** + * Event + *****************************************************/ + + export namespace Event { + /** !#en The keyboard event + !#zh 键盘事件 */ + export class EventKeyboard extends Event { + /** !#en + The keyCode read-only property represents a system and implementation dependent numerical code identifying the unmodified value of the pressed key. + This is usually the decimal ASCII (RFC 20) or Windows 1252 code corresponding to the key. + If the key can't be identified, this value is 0. + + !#zh + keyCode 是只读属性它表示一个系统和依赖于实现的数字代码,可以识别按键的未修改值。 + 这通常是十进制 ASCII (RFC20) 或者 Windows 1252 代码,所对应的密钥。 + 如果无法识别该键,则该值为 0。 */ + keyCode: number; + } + } + + /**************************************************** + * Event + *****************************************************/ + + export namespace Event { + /** !#en The Custom event + !#zh 自定义事件 */ + export class EventCustom extends Event { + /** + + @param type The name of the event (case-sensitive), e.g. "click", "fire", or "submit" + @param bubbles A boolean indicating whether the event bubbles up through the tree or not + */ + constructor(type: string, bubbles: boolean); + /** !#en A reference to the detailed data of the event + !#zh 事件的详细数据 */ + detail: any; + /** + !#en Sets user data + !#zh 设置用户数据 + @param data data + */ + setUserData(data: any): void; + /** + !#en Gets user data + !#zh 获取用户数据 + */ + getUserData(): any; + /** + !#en Gets event name + !#zh 获取事件名称 + */ + getEventName(): string; + } + } + + /**************************************************** + * SystemEvent + *****************************************************/ + + export namespace SystemEvent { + /** !#en The event type supported by SystemEvent + !#zh SystemEvent 支持的事件类型 */ + export class EventType { + /** !#en The event type for press the key down event, you can use its value directly: 'keydown' + !#zh 当按下按键时触发的事件 */ + static KEY_DOWN: string; + /** !#en The event type for press the key up event, you can use its value directly: 'keyup' + !#zh 当松开按键时触发的事件 */ + static KEY_UP: string; + /** !#en The event type for press the devicemotion event, you can use its value directly: 'devicemotion' + !#zh 重力感应 */ + static DEVICEMOTION: string; + } + } + + /**************************************************** + * geomUtils + *****************************************************/ + + export namespace geomUtils { + /** Aabb */ + export class Aabb { + /** + create a new aabb + @param px X coordinates for aabb's original point + @param py Y coordinates for aabb's original point + @param pz Z coordinates for aabb's original point + @param w the half of aabb width + @param h the half of aabb height + @param l the half of aabb length + */ + create(px: number, py: number, pz: number, w: number, h: number, l: number): Aabb; + /** + clone a new aabb + @param a the source aabb + */ + clone(a: Aabb): Aabb; + /** + copy the values from one aabb to another + @param out the receiving aabb + @param a the source aabb + */ + copy(out: Aabb, a: Aabb): Aabb; + /** + create a new aabb from two corner points + @param out the receiving aabb + @param minPos lower corner position of the aabb + @param maxPos upper corner position of the aabb + */ + fromPoints(out: Aabb, minPos: Vec3, maxPos: Vec3): Aabb; + /** + Set the components of a aabb to the given values + @param out the receiving aabb + @param px X coordinates for aabb's original point + @param py Y coordinates for aabb's original point + @param pz Z coordinates for aabb's original point + @param w the half of aabb width + @param h the half of aabb height + @param l the half of aabb length + */ + set(out: Aabb, px: number, py: number, pz: number, w: number, h: number, l: number): Aabb; + center: Vec3; + halfExtents: Vec3; + _type: number; + /** + Get the bounding points of this shape + @param minPos minPos + @param maxPos maxPos + */ + getBoundary(minPos: Vec3, maxPos: Vec3): void; + /** + Transform this shape + @param m the transform matrix + @param pos the position part of the transform + @param rot the rotation part of the transform + @param scale the scale part of the transform + @param out the target shape + */ + transform(m: Mat4, pos: Vec3, rot: Quat, scale: Vec3, out?: Aabb): void; + } + } + + /**************************************************** + * geomUtils + *****************************************************/ + + export namespace geomUtils { + /** !#en Shape type. */ + export enum enums { + SHAPE_RAY = 0, + SHAPE_LINE = 0, + SHAPE_SPHERE = 0, + SHAPE_AABB = 0, + SHAPE_OBB = 0, + SHAPE_PLANE = 0, + SHAPE_TRIANGLE = 0, + SHAPE_FRUSTUM = 0, + SHAPE_FRUSTUM_ACCURATE = 0, + } + } + + /**************************************************** + * geomUtils + *****************************************************/ + + export namespace geomUtils { + /** !#en frustum + !#zh 平截头体 */ + export class Frustum { + /** Set whether to use accurate intersection testing function on this frustum */ + accurate: boolean; + /** + create a new frustum + */ + static create(): Frustum; + /** + Clone a frustum + @param f f + */ + static clone(f: Frustum): Frustum; + /** + Copy the values from one frustum to another + @param out out + @param f f + */ + copy(out: Frustum, f: Frustum): Frustum; + planes: geomUtils.Plane[]; + planes: Vec3[]; + /** + !#en Update the frustum information according to the given transform matrix. + Note that the resulting planes are not normalized under normal mode. + @param m the view-projection matrix + @param inv the inverse view-projection matrix + */ + update(m: Mat4, inv: Mat4): void; + /** + !#en transform by matrix + @param mat mat + */ + transform(mat: Mat4): void; + } + } + + /**************************************************** + * geomUtils + *****************************************************/ + + export namespace geomUtils { + /** undefined */ + export class intersect { + /** + !#en + Check whether ray intersect with nodes + !#zh + 检测射线是否与物体有交集 + @param root If root is null, then traversal nodes from scene node + @param worldRay worldRay + @param handler handler + @param filter filter + */ + static ray_cast(root: Node, worldRay: geomUtils.Ray, handler: Function, filter: Function): any[]; + /** + !#en ray-plane intersect
+ !#zh 射线与平面的相交性检测。 + @param ray ray + @param plane plane + */ + static ray_plane(ray: geomUtils.Ray, plane: geomUtils.Plane): number; + /** + !#en line-plane intersect
+ !#zh 线段与平面的相交性检测。 + @param line line + @param plane plane + */ + static line_plane(line: geomUtils.Line, plane: geomUtils.Plane): number; + /** + !#en ray-triangle intersect
+ !#zh 射线与三角形的相交性检测。 + @param ray ray + @param triangle triangle + @param doubleSided doubleSided + */ + static ray_triangle(ray: geomUtils.Ray, triangle: geomUtils.Triangle, doubleSided: boolean): number; + /** + !#en line-triangle intersect
+ !#zh 线段与三角形的相交性检测。 + @param line line + @param triangle triangle + @param outPt optional, The intersection point + */ + static line_triangle(line: geomUtils.Line, triangle: geomUtils.Triangle, outPt: Vec3): number; + /** + !#en line-quad intersect
+ !#zh 线段与四边形的相交性检测。 + @param p A point on a line segment + @param q Another point on the line segment + @param a Quadrilateral point a + @param b Quadrilateral point b + @param c Quadrilateral point c + @param d Quadrilateral point d + @param outPt optional, The intersection point + */ + static line_quad(p: Vec3, q: Vec3, a: Vec3, b: Vec3, c: Vec3, d: Vec3, outPt: Vec3): number; + /** + !#en ray-sphere intersect
+ !#zh 射线和球的相交性检测。 + @param ray ray + @param sphere sphere + */ + static ray_sphere(ray: geomUtils.Ray, sphere: geomUtils.Sphere): number; + /** + !#en ray-aabb intersect
+ !#zh 射线和轴对齐包围盒的相交性检测。 + @param ray ray + @param aabb Align the axis around the box + */ + static ray_aabb(ray: geomUtils.Ray, aabb: Aabb): number; + /** + !#en ray-obb intersect
+ !#zh 射线和方向包围盒的相交性检测。 + @param ray ray + @param obb Direction box + */ + static ray_obb(ray: geomUtils.Ray, obb: geomUtils.Obb): number; + /** + !#en aabb-aabb intersect
+ !#zh 轴对齐包围盒和轴对齐包围盒的相交性检测。 + @param aabb1 Axis alignment surrounds box 1 + @param aabb2 Axis alignment surrounds box 2 + */ + static aabb_aabb(aabb1: Aabb, aabb2: Aabb): number; + /** + !#en aabb-obb intersect
+ !#zh 轴对齐包围盒和方向包围盒的相交性检测。 + @param aabb Align the axis around the box + @param obb Direction box + */ + static aabb_obb(aabb: Aabb, obb: geomUtils.Obb): number; + /** + !#en aabb-plane intersect
+ !#zh 轴对齐包围盒和平面的相交性检测。 + @param aabb Align the axis around the box + @param plane plane + */ + static aabb_plane(aabb: Aabb, plane: geomUtils.Plane): number; + /** + !#en aabb-frustum intersect, faster but has false positive corner cases
+ !#zh 轴对齐包围盒和锥台相交性检测,速度快,但有错误情况。 + @param aabb Align the axis around the box + @param frustum frustum + */ + static aabb_frustum(aabb: Aabb, frustum: Frustum): number; + /** + !#en aabb-frustum intersect, handles most of the false positives correctly
+ !#zh 轴对齐包围盒和锥台相交性检测,正确处理大多数错误情况。 + @param aabb Align the axis around the box + @param frustum frustum + */ + static aabb_frustum_accurate(aabb: Aabb, frustum: Frustum): number; + /** + !#en obb-point intersect
+ !#zh 方向包围盒和点的相交性检测。 + @param obb Direction box + @param point point + */ + static obb_point(obb: geomUtils.Obb, point: geomUtils.Vec3): boolean; + /** + !#en obb-plane intersect
+ !#zh 方向包围盒和平面的相交性检测。 + @param obb Direction box + @param plane plane + */ + static obb_plane(obb: geomUtils.Obb, plane: geomUtils.Plane): number; + /** + !#en obb-frustum intersect, faster but has false positive corner cases
+ !#zh 方向包围盒和锥台相交性检测,速度快,但有错误情况。 + @param obb Direction box + @param frustum frustum + */ + static obb_frustum(obb: geomUtils.Obb, frustum: Frustum): number; + /** + !#en obb-frustum intersect, handles most of the false positives correctly
+ !#zh 方向包围盒和锥台相交性检测,正确处理大多数错误情况。 + @param obb Direction box + @param frustum frustum + */ + static obb_frustum_accurate(obb: geomUtils.Obb, frustum: Frustum): number; + /** + !#en obb-obb intersect
+ !#zh 方向包围盒和方向包围盒的相交性检测。 + @param obb1 Direction box1 + @param obb2 Direction box2 + */ + static obb_obb(obb1: geomUtils.Obb, obb2: geomUtils.Obb): number; + /** + !#en phere-plane intersect, not necessarily faster than obb-plane
+ due to the length calculation of the plane normal to factor out
+ the unnomalized plane distance
+ !#zh 球与平面的相交性检测。 + @param sphere sphere + @param plane plane + */ + static sphere_plane(sphere: geomUtils.Sphere, plane: geomUtils.Plane): number; + /** + !#en sphere-frustum intersect, faster but has false positive corner cases
+ !#zh 球和锥台的相交性检测,速度快,但有错误情况。 + @param sphere sphere + @param frustum frustum + */ + static sphere_frustum(sphere: geomUtils.Sphere, frustum: Frustum): number; + /** + !#en sphere-frustum intersect, handles the false positives correctly
+ !#zh 球和锥台的相交性检测,正确处理大多数错误情况。 + @param sphere sphere + @param frustum frustum + */ + static sphere_frustum_accurate(sphere: geomUtils.Sphere, frustum: Frustum): number; + /** + !#en sphere-sphere intersect
+ !#zh 球和球的相交性检测。 + @param sphere0 sphere0 + @param sphere1 sphere1 + */ + static sphere_sphere(sphere0: geomUtils.Sphere, sphere1: geomUtils.Sphere): boolean; + /** + !#en sphere-aabb intersect
+ !#zh 球和轴对齐包围盒的相交性检测。 + @param sphere sphere + @param aabb aabb + */ + static sphere_aabb(sphere: geomUtils.Sphere, aabb: Aabb): boolean; + /** + !#en sphere-obb intersect
+ !#zh 球和方向包围盒的相交性检测。 + @param sphere sphere + @param obb obb + */ + static sphere_obb(sphere: geomUtils.Sphere, obb: geomUtils.Obb): boolean; + /** + !#en + The intersection detection of g1 and g2 can fill in the shape in the basic geometry. + !#zh + g1 和 g2 的相交性检测,可填入基础几何中的形状。 + @param g1 Geometry 1 + @param g2 Geometry 2 + @param outPt optional, Intersection point. (note: only partial shape detection with this return value) + */ + static resolve(g1: any, g2: any, outPt: any): void; + } + } + + /**************************************************** + * geomUtils + *****************************************************/ + + export namespace geomUtils { + /** !#en + line + !#zh + 直线 */ + export class Line { + /** + !#en + create a new line + !#zh + 创建一个新的 line。 + @param sx The x part of the starting point. + @param sy The y part of the starting point. + @param sz The z part of the starting point. + @param ex The x part of the end point. + @param ey The y part of the end point. + @param ez The z part of the end point. + */ + create(sx: number, sy: number, sz: number, ex: number, ey: number, ez: number): Line; + /** + !#en + Creates a new line initialized with values from an existing line + !#zh + 克隆一个新的 line。 + @param a The source of cloning. + */ + clone(a: Line): Line; + /** + !#en + Copy the values from one line to another + !#zh + 复制一个线的值到另一个。 + @param out The object that accepts the action. + @param a The source of the copy. + */ + copy(out: Line, a: Line): Line; + /** + !#en + create a line from two points + !#zh + 用两个点创建一个线。 + @param out The object that accepts the action. + @param start The starting point. + @param end At the end. + */ + fromPoints(out: Line, start: Vec3, end: Vec3): Line; + /** + !#en + Set the components of a Vec3 to the given values + !#zh + 将给定线的属性设置为给定值。 + @param out The object that accepts the action. + @param sx The x part of the starting point. + @param sy The y part of the starting point. + @param sz The z part of the starting point. + @param ex The x part of the end point. + @param ey The y part of the end point. + @param ez The z part of the end point. + */ + set(out: Line, sx: number, sy: number, sz: number, ex: number, ey: number, ez: number): Line; + /** + !#en + Calculate the length of the line. + !#zh + 计算线的长度。 + @param a The line to calculate. + */ + len(a: Line): number; + /** !#en + Start points. + !#zh + 起点。 */ + s: Vec3; + /** !#en + End points. + !#zh + 终点。 */ + e: Vec3; + /** + !#en + Calculate the length of the line. + !#zh + 计算线的长度。 + */ + length(): number; + } + } + + /**************************************************** + * geomUtils + *****************************************************/ + + export namespace geomUtils { + /** !#en obb + !#zh + 基础几何 方向包围盒。 */ + export class Obb { + /** !#zh + 获取形状的类型。 */ + type: number; + /** + !#en + create a new obb + !#zh + 创建一个新的 obb 实例。 + @param cx X coordinates of the shape relative to the origin. + @param cy Y coordinates of the shape relative to the origin. + @param cz Z coordinates of the shape relative to the origin. + @param hw Obb is half the width. + @param hh Obb is half the height. + @param hl Obb is half the Length. + @param ox_1 Direction matrix parameter. + @param ox_2 Direction matrix parameter. + @param ox_3 Direction matrix parameter. + @param oy_1 Direction matrix parameter. + @param oy_2 Direction matrix parameter. + @param oy_3 Direction matrix parameter. + @param oz_1 Direction matrix parameter. + @param oz_2 Direction matrix parameter. + @param oz_3 Direction matrix parameter. + */ + create(cx: number, cy: number, cz: number, hw: number, hh: number, hl: number, ox_1: number, ox_2: number, ox_3: number, oy_1: number, oy_2: number, oy_3: number, oz_1: number, oz_2: number, oz_3: number): Obb; + /** + !#en + clone a new obb + !#zh + 克隆一个 obb。 + @param a The target of cloning. + */ + clone(a: Obb): Obb; + /** + !#en + copy the values from one obb to another + !#zh + 将从一个 obb 的值复制到另一个 obb。 + @param out Obb that accepts the operation. + @param a Obb being copied. + */ + copy(out: Obb, a: Obb): Obb; + /** + !#en + create a new obb from two corner points + !#zh + 用两个点创建一个新的 obb。 + @param out Obb that accepts the operation. + @param minPos The smallest point of obb. + @param maxPos Obb's maximum point. + */ + fromPoints(out: Obb, minPos: Vec3, maxPos: Vec3): Obb; + /** + !#en + Set the components of a obb to the given values + !#zh + 将给定 obb 的属性设置为给定的值。 + @param cx X coordinates of the shape relative to the origin. + @param cy Y coordinates of the shape relative to the origin. + @param cz Z coordinates of the shape relative to the origin. + @param hw Obb is half the width. + @param hh Obb is half the height. + @param hl Obb is half the Length. + @param ox_1 Direction matrix parameter. + @param ox_2 Direction matrix parameter. + @param ox_3 Direction matrix parameter. + @param oy_1 Direction matrix parameter. + @param oy_2 Direction matrix parameter. + @param oy_3 Direction matrix parameter. + @param oz_1 Direction matrix parameter. + @param oz_2 Direction matrix parameter. + @param oz_3 Direction matrix parameter. + */ + set(cx: number, cy: number, cz: number, hw: number, hh: number, hl: number, ox_1: number, ox_2: number, ox_3: number, oy_1: number, oy_2: number, oy_3: number, oz_1: number, oz_2: number, oz_3: number): Obb; + /** !#en + The center of the local coordinate. + !#zh + 本地坐标的中心点。 */ + center: Vec3; + /** !#en + Half the length, width, and height. + !#zh + 长宽高的一半。 */ + halfExtents: Vec3; + /** !#en + Direction matrix. + !#zh + 方向矩阵。 */ + orientation: Mat3; + /** + !#en + Get the bounding points of this shape + !#zh + 获取 obb 的最小点和最大点。 + @param minPos minPos + @param maxPos maxPos + */ + getBoundary(minPos: Vec3, maxPos: Vec3): void; + /** + !#en Transform this shape + !#zh + 将 out 根据这个 obb 的数据进行变换。 + @param m The transformation matrix. + @param pos The position part of the transformation. + @param rot The rotating part of the transformation. + @param scale The scaling part of the transformation. + @param out Target of transformation. + */ + transform(m: Mat4, pos: Vec3, rot: Quat, scale: Vec3, out: Obb): void; + /** + !#en + Transform out based on this obb data. + !#zh + 将 out 根据这个 obb 的数据进行变换。 + @param m The transformation matrix. + @param rot The rotating part of the transformation. + @param out Target of transformation. + */ + translateAndRotate(m: Mat4, rot: Quat, out: Obb): void; + /** + !#en + Scale out based on this obb data. + !#zh + 将 out 根据这个 obb 的数据进行缩放。 + @param scale Scale value. + @param out Scaled target. + */ + setScale(scale: Vec3, out: Obb): void; + } + } + + /**************************************************** + * geomUtils + *****************************************************/ + + export namespace geomUtils { + /** !#en + plane。 + !#zh + 平面。 */ + export class Plane { + /** + !#en + create a new plane + !#zh + 创建一个新的 plane。 + @param nx The x part of the normal component. + @param ny The y part of the normal component. + @param nz The z part of the normal component. + @param d Distance from the origin. + */ + create(nx: number, ny: number, nz: number, d: number): Plane; + /** + !#en + clone a new plane + !#zh + 克隆一个新的 plane。 + @param p The source of cloning. + */ + clone(p: Plane): Plane; + /** + !#en + copy the values from one plane to another + !#zh + 复制一个平面的值到另一个。 + @param out The object that accepts the action. + @param p The source of the copy. + */ + copy(out: Plane, p: Plane): Plane; + /** + !#en + create a plane from three points + !#zh + 用三个点创建一个平面。 + @param out The object that accepts the action. + @param a Point a。 + @param b Point b。 + @param c Point c。 + */ + fromPoints(out: Plane, a: Vec3, b: Vec3, c: Vec3): Plane; + /** + !#en + Set the components of a plane to the given values + !#zh + 将给定平面的属性设置为给定值。 + @param out The object that accepts the action. + @param nx The x part of the normal component. + @param ny The y part of the normal component. + @param nz The z part of the normal component. + @param d Distance from the origin. + */ + set(out: Plane, nx: number, ny: number, nz: number, d: number): Plane; + /** + !#en + create plane from normal and point + !#zh + 用一条法线和一个点创建平面。 + @param out The object that accepts the action. + @param normal The normal of a plane. + @param point A point on the plane. + */ + fromNormalAndPoint(out: Plane, normal: Vec3, point: Vec3): Plane; + /** + !#en + normalize a plane + !#zh + 归一化一个平面。 + @param out The object that accepts the action. + @param a Source data for operations. + */ + normalize(out: Plane, a: Plane): Plane; + /** !#en + A normal vector. + !#zh + 法线向量。 */ + n: Vec3; + /** !#en + The distance from the origin to the plane. + !#zh + 原点到平面的距离。 */ + d: number; + /** + !#en + Transform a plane. + !#zh + 变换一个平面。 + @param mat mat + */ + transform(mat: Mat4): void; + } + } + + /**************************************************** + * geomUtils + *****************************************************/ + + export namespace geomUtils { + /** !#en + ray + !#zh + 射线。 */ + export class Ray { + /** + !#en + create a new ray + !#zh + 创建一条射线。 + @param ox The x part of the starting point. + @param oy The y part of the starting point. + @param oz The z part of the starting point. + @param dx X in the direction. + @param dy Y in the direction. + @param dz Z in the direction. + */ + create(ox: number, oy: number, oz: number, dx: number, dy: number, dz: number): Ray; + /** + !#en + Creates a new ray initialized with values from an existing ray + !#zh + 从一条射线克隆出一条新的射线。 + @param a Clone target + */ + clone(a: Ray): Ray; + /** + !#en + Copy the values from one ray to another + !#zh + 将从一个 ray 的值复制到另一个 ray。 + @param out Accept the ray of the operation. + @param a Copied ray. + */ + copy(out: Ray, a: Ray): Ray; + /** + !#en + create a ray from two points + !#zh + 用两个点创建一条射线。 + @param out Receive the operating ray. + @param origin Origin of ray + @param target A point on a ray. + */ + fromPoints(out: Ray, origin: Vec3, target: Vec3): Ray; + /** + !#en + Set the components of a ray to the given values + !#zh + 将给定射线的属性设置为给定的值。 + @param out Receive the operating ray. + @param ox The x part of the starting point. + @param oy The y part of the starting point. + @param oz The z part of the starting point. + @param dx X in the direction. + @param dy Y in the direction. + @param dz Z in the direction. + */ + set(out: Ray, ox: number, oy: number, oz: number, dx: number, dy: number, dz: number): Ray; + /** !#en + Start point. + !#zh + 起点。 */ + o: Vec3; + /** !#e + Direction + !#zh + 方向。 */ + d: Vec3; + /** + !#en Compute hit. + @param out out + @param distance distance + */ + computeHit(out: IVec3Like, distance: number): void; + } + } + + /**************************************************** + * geomUtils + *****************************************************/ + + export namespace geomUtils { + /** !#en + Sphere. + !#zh + 轴对齐球。 */ + export class Sphere { + /** + !#en + create a new sphere + !#zh + 创建一个新的 sphere 实例。 + @param cx X coordinates of the shape relative to the origin. + @param cy Y coordinates of the shape relative to the origin. + @param cz Z coordinates of the shape relative to the origin. + @param r Radius of sphere + */ + create(cx: any, cy: any, cz: any, r: any): Sphere; + /** + !#en + clone a new sphere + !#zh + 克隆一个新的 sphere 实例。 + @param p The target of cloning. + */ + clone(p: Sphere): Sphere; + /** + !#en + copy the values from one sphere to another + !#zh + 将从一个 sphere 的值复制到另一个 sphere。 + @param out Accept the sphere of operations. + @param a Sphere being copied. + */ + copy(out: Sphere, a: Sphere): Sphere; + /** + !#en + create a new bounding sphere from two corner points + !#zh + 从两个点创建一个新的 sphere。 + @param out Accept the sphere of operations. + @param minPos The smallest point of sphere. + @param maxPos The maximum point of sphere. + */ + fromPoints(out: any, minPos: any, maxPos: any): Sphere; + /** + !#en Set the components of a sphere to the given values + !#zh 将球体的属性设置为给定的值。 + @param out Accept the sphere of operations. + @param cx X coordinates of the shape relative to the origin. + @param cy Y coordinates of the shape relative to the origin. + @param cz Z coordinates of the shape relative to the origin. + @param r Radius. + */ + set(out: Sphere, cx: any, cy: any, cz: any, r: number): Sphere; + /** !#en + The center of the local coordinate. + !#zh + 本地坐标的中心点。 */ + center: Vec3; + /** !#zh + 半径。 */ + radius: number; + /** + !#en + Clone. + !#zh + 获得克隆。 + */ + clone(): void; + /** + !#en + Copy sphere + !#zh + 拷贝对象。 + @param a Copy target. + */ + copy(a: any): void; + /** + !#en + Get the bounding points of this shape + !#zh + 获取此形状的边界点。 + @param minPos minPos + @param maxPos maxPos + */ + getBoundary(minPos: Vec3, maxPos: Vec3): void; + /** + !#en + Transform this shape + !#zh + 将 out 根据这个 sphere 的数据进行变换。 + @param m The transformation matrix. + @param pos The position part of the transformation. + @param rot The rotating part of the transformation. + @param scale The scaling part of the transformation. + @param out The target of the transformation. + */ + transform(m: any, pos: any, rot: any, scale: any, out: any): void; + /** + !#en + Scale out based on the sphere data. + !#zh + 将 out 根据这个 sphere 的数据进行缩放。 + @param scale Scale value + @param out Scale target + */ + setScale(scale: any, out: any): void; + } + } + + /**************************************************** + * geomUtils + *****************************************************/ + + export namespace geomUtils { + /** Triangle */ + export class Triangle { + /** + create a new triangle + @param ax ax + @param ay ay + @param az az + @param bx bx + @param by by + @param bz bz + @param cx cx + @param cy cy + @param cz cz + */ + create(ax: number, ay: number, az: number, bx: number, by: number, bz: number, cx: number, cy: number, cz: number): Triangle; + /** + clone a new triangle + @param t the source plane + */ + clone(t: Triangle): Triangle; + /** + copy the values from one triangle to another + @param out the receiving triangle + @param t the source triangle + */ + copy(out: Triangle, t: Triangle): Triangle; + /** + Create a triangle from three points + @param out the receiving triangle + @param a a + @param b b + @param c c + */ + fromPoints(out: Triangle, a: Vec3, b: Vec3, c: Vec3): Triangle; + /** + Set the components of a triangle to the given values + @param out the receiving plane + @param ax X component of a + @param ay Y component of a + @param az Z component of a + @param bx X component of b + @param by Y component of b + @param bz Z component of b + @param cx X component of c + @param cy Y component of c + @param cz Z component of c + */ + set(out: Triangle, ax: number, ay: number, az: number, bx: number, by: number, bz: number, cx: number, cy: number, cz: number): Plane; + a: Vec3; + b: Vec3; + c: Vec3; + } + } + + /**************************************************** + * Animation + *****************************************************/ + + export namespace Animation { + /** !#en The event type supported by Animation + !#zh Animation 支持的事件类型 */ + export class EventType { + /** !#en Emit when begin playing animation + !#zh 开始播放时触发 */ + static PLAY: string; + /** !#en Emit when stop playing animation + !#zh 停止播放时触发 */ + static STOP: string; + /** !#en Emit when pause animation + !#zh 暂停播放时触发 */ + static PAUSE: string; + /** !#en Emit when resume animation + !#zh 恢复播放时触发 */ + static RESUME: string; + /** !#en If animation repeat count is larger than 1, emit when animation play to the last frame + !#zh 假如动画循环次数大于 1,当动画播放到最后一帧时触发 */ + static LASTFRAME: string; + /** !#en Emit when finish playing animation + !#zh 动画播放完成时触发 */ + static FINISHED: string; + } + } + + /**************************************************** + * Button + *****************************************************/ + + export namespace Button { + /** !#en Enum for transition type. + !#zh 过渡类型 */ + export enum Transition { + NONE = 0, + COLOR = 0, + SPRITE = 0, + SCALE = 0, + } + } + + /**************************************************** + * Component + *****************************************************/ + + export namespace Component { + /** !#en + Component will register a event to target component's handler. + And it will trigger the handler when a certain event occurs. + + !@zh + “EventHandler” 类用来设置场景中的事件回调, + 该类允许用户设置回调目标节点,目标组件名,组件方法名, + 并可通过 emit 方法调用目标函数。 */ + export class EventHandler { + /** !#en the node that contains target callback, such as the node example script belongs to + !#zh 事件响应函数所在节点 ,比如例子中脚本归属的节点本身 */ + target: Node; + /** !#en name of the component(script) that contains target callback, such as the name 'MainMenu' of script in example + !#zh 事件响应函数所在组件名(脚本名), 比如例子中的脚本名 'MainMenu' */ + component: string; + /** !#en Event handler, such as function's name 'onClick' in example + !#zh 响应事件函数名,比如例子中的 'onClick' */ + handler: string; + /** !#en Custom Event Data, such as 'eventType' in example + !#zh 自定义事件数据,比如例子中的 eventType */ + customEventData: string; + /** + + @param events events + @param params params + */ + static emitEvents(events: EventHandler[], ...params: any[]): void; + /** + !#en Emit event with params + !#zh 触发目标组件上的指定 handler 函数,该参数是回调函数的参数值(可不填)。 + @param params params + + @example + ```js + // Call Function + var eventHandler = new cc.Component.EventHandler(); + eventHandler.target = newTarget; + eventHandler.component = "MainMenu"; + eventHandler.handler = "OnClick" + eventHandler.emit(["param1", "param2", ....]); + ``` + */ + emit(params: any[]): void; + } + } + + /**************************************************** + * Label + *****************************************************/ + + export namespace Label { + /** !#en Enum for text alignment. + !#zh 文本横向对齐类型 */ + export enum HorizontalAlign { + LEFT = 0, + CENTER = 0, + RIGHT = 0, + } + } + + /**************************************************** + * Label + *****************************************************/ + + export namespace Label { + /** !#en Enum for vertical text alignment. + !#zh 文本垂直对齐类型 */ + export enum VerticalAlign { + TOP = 0, + CENTER = 0, + BOTTOM = 0, + } + } + + /**************************************************** + * Label + *****************************************************/ + + export namespace Label { + /** !#en Enum for Overflow. + !#zh Overflow 类型 */ + export enum Overflow { + NONE = 0, + CLAMP = 0, + SHRINK = 0, + RESIZE_HEIGHT = 0, + } + } + + /**************************************************** + * Label + *****************************************************/ + + export namespace Label { + /** !#en Enum for font type. + !#zh Type 类型 */ + export enum Type { + TTF = 0, + BMFont = 0, + SystemFont = 0, + } + } + + /**************************************************** + * Label + *****************************************************/ + + export namespace Label { + /** !#en Enum for cache mode. + !#zh CacheMode 类型 */ + export enum CacheMode { + NONE = 0, + BITMAP = 0, + CHAR = 0, + } + } + + /**************************************************** + * Layout + *****************************************************/ + + export namespace Layout { + /** !#en Enum for Layout type + !#zh 布局类型 */ + export enum Type { + NONE = 0, + HORIZONTAL = 0, + VERTICAL = 0, + GRID = 0, + } + } + + /**************************************************** + * Layout + *****************************************************/ + + export namespace Layout { + /** !#en Enum for Layout Resize Mode + !#zh 缩放模式 */ + export enum ResizeMode { + NONE = 0, + CONTAINER = 0, + CHILDREN = 0, + } + } + + /**************************************************** + * Layout + *****************************************************/ + + export namespace Layout { + /** !#en Enum for Grid Layout start axis direction. + The items in grid layout will be arranged in each axis at first.; + !#zh 布局轴向,只用于 GRID 布局。 */ + export enum AxisDirection { + HORIZONTAL = 0, + VERTICAL = 0, + } + } + + /**************************************************** + * Layout + *****************************************************/ + + export namespace Layout { + /** !#en Enum for vertical layout direction. + Used in Grid Layout together with AxisDirection is VERTICAL + !#zh 垂直方向布局方式 */ + export enum VerticalDirection { + BOTTOM_TO_TOP = 0, + TOP_TO_BOTTOM = 0, + } + } + + /**************************************************** + * Layout + *****************************************************/ + + export namespace Layout { + /** !#en Enum for horizontal layout direction. + Used in Grid Layout together with AxisDirection is HORIZONTAL + !#zh 水平方向布局方式 */ + export enum HorizontalDirection { + LEFT_TO_RIGHT = 0, + RIGHT_TO_LEFT = 0, + } + } + + /**************************************************** + * Mask + *****************************************************/ + + export namespace Mask { + /** !#en the type for mask. + !#zh 遮罩组件类型 */ + export enum Type { + RECT = 0, + ELLIPSE = 0, + IMAGE_STENCIL = 0, + } + } + + /**************************************************** + * PageView + *****************************************************/ + + export namespace PageView { + /** !#en The Page View Size Mode + !#zh 页面视图每个页面统一的大小类型 */ + export enum SizeMode { + Unified = 0, + Free = 0, + } + } + + /**************************************************** + * PageView + *****************************************************/ + + export namespace PageView { + /** !#en The Page View Direction + !#zh 页面视图滚动类型 */ + export enum Direction { + Horizontal = 0, + Vertical = 0, + } + } + + /**************************************************** + * PageView + *****************************************************/ + + export namespace PageView { + /** !#en Enum for ScrollView event type. + !#zh 滚动视图事件类型 */ + export enum EventType { + PAGE_TURNING = 0, + } + } + + /**************************************************** + * PageViewIndicator + *****************************************************/ + + export namespace PageViewIndicator { + /** !#en Enum for PageView Indicator direction + !#zh 页面视图指示器的摆放方向 */ + export enum Direction { + HORIZONTAL = 0, + VERTICAL = 0, + } + } + + /**************************************************** + * ProgressBar + *****************************************************/ + + export namespace ProgressBar { + /** !#en Enum for ProgressBar mode + !#zh 进度条模式 */ + export enum Mode { + HORIZONTAL = 0, + VERTICAL = 0, + FILLED = 0, + } + } + + /**************************************************** + * Scrollbar + *****************************************************/ + + export namespace Scrollbar { + /** Enum for Scrollbar direction */ + export enum Direction { + HORIZONTAL = 0, + VERTICAL = 0, + } + } + + /**************************************************** + * ScrollView + *****************************************************/ + + export namespace ScrollView { + /** !#en Enum for ScrollView event type. + !#zh 滚动视图事件类型 */ + export enum EventType { + SCROLL_TO_TOP = 0, + SCROLL_TO_BOTTOM = 0, + SCROLL_TO_LEFT = 0, + SCROLL_TO_RIGHT = 0, + SCROLLING = 0, + BOUNCE_TOP = 0, + BOUNCE_BOTTOM = 0, + BOUNCE_LEFT = 0, + BOUNCE_RIGHT = 0, + SCROLL_ENDED = 0, + TOUCH_UP = 0, + AUTOSCROLL_ENDED_WITH_THRESHOLD = 0, + SCROLL_BEGAN = 0, + } + } + + /**************************************************** + * Slider + *****************************************************/ + + export namespace Slider { + /** !#en The Slider Direction + !#zh 滑动器方向 */ + export enum Direction { + Horizontal = 0, + Vertical = 0, + } + } + + /**************************************************** + * Sprite + *****************************************************/ + + export namespace Sprite { + /** !#en Enum for sprite type. + !#zh Sprite 类型 */ + export enum Type { + SIMPLE = 0, + SLICED = 0, + TILED = 0, + FILLED = 0, + MESH = 0, + } + } + + /**************************************************** + * Sprite + *****************************************************/ + + export namespace Sprite { + /** !#en Enum for fill type. + !#zh 填充类型 */ + export enum FillType { + HORIZONTAL = 0, + VERTICAL = 0, + RADIAL = 0, + } + } + + /**************************************************** + * Sprite + *****************************************************/ + + export namespace Sprite { + /** !#en Sprite Size can track trimmed size, raw size or none. + !#zh 精灵尺寸调整模式 */ + export enum SizeMode { + CUSTOM = 0, + TRIMMED = 0, + RAW = 0, + } + } + + /**************************************************** + * Sprite + *****************************************************/ + + export namespace Sprite { + /** !#en Sprite state can choice the normal or grayscale. + !#zh 精灵颜色通道模式。 */ + export enum State { + NORMAL = 0, + GRAY = 0, + } + } + + /**************************************************** + * Widget + *****************************************************/ + + export namespace Widget { + /** !#en Enum for Widget's alignment mode, indicating when the widget should refresh. + !#zh Widget 的对齐模式,表示 Widget 应该何时刷新。 */ + export enum AlignMode { + ONCE = 0, + ON_WINDOW_RESIZE = 0, + ALWAYS = 0, + } + } + + /**************************************************** + * Graphics + *****************************************************/ + + export namespace Graphics { + /** !#en Enum for LineCap. + !#zh 线段末端属性 */ + export enum LineCap { + BUTT = 0, + ROUND = 0, + SQUARE = 0, + } + } + + /**************************************************** + * Graphics + *****************************************************/ + + export namespace Graphics { + /** !#en Enum for LineJoin. + !#zh 线段拐角属性 */ + export enum LineJoin { + BEVEL = 0, + ROUND = 0, + MITER = 0, + } + } + + /**************************************************** + * MeshRenderer + *****************************************************/ + + export namespace MeshRenderer { + /** !#en Shadow projection mode + + !#ch 阴影投射方式 */ + export enum ShadowCastingMode { + OFF = 0, + ON = 0, + } + } + + /**************************************************** + * Pipeline + *****************************************************/ + + export namespace Pipeline { + /** The downloader pipe, it can download several types of files: + 1. Text + 2. Image + 3. Script + 4. Audio + 5. Assets + All unknown type will be downloaded as plain text. + You can pass custom supported types in the constructor. */ + export class Downloader { + /** + Constructor of Downloader, you can pass custom supported types. + @param extMap Custom supported types with corresponded handler + + @example + ```js + var downloader = new Downloader({ + // This will match all url with `.scene` extension or all url with `scene` type + 'scene' : function (url, callback) {} + }); + ``` + */ + constructor(extMap: any); + /** + Add custom supported types handler or modify existing type handler. + @param extMap Custom supported types with corresponded handler + */ + addHandlers(extMap: any): void; + /** + !#en + Load subpackage with name. + !#zh + 通过子包名加载子包代码。 + @param name Subpackage name + @param progressCallback Callback when progress changed + @param completeCallback Callback invoked when subpackage loaded + */ + loadSubpackage(name: string, progressCallback?: Function, completeCallback?: (error: Error) => void): void; + } + } + + /**************************************************** + * Pipeline + *****************************************************/ + + export namespace Pipeline { + /** The loader pipe, it can load several types of files: + 1. Images + 2. JSON + 3. Plist + 4. Audio + 5. Font + 6. Cocos Creator scene + It will not interfere with items of unknown type. + You can pass custom supported types in the constructor. */ + export class Loader { + /** + Constructor of Loader, you can pass custom supported types. + @param extMap Custom supported types with corresponded handler + + @example + ```js + var loader = new Loader({ + // This will match all url with `.scene` extension or all url with `scene` type + 'scene' : function (url, callback) {} + }); + ``` + */ + constructor(extMap: any); + /** + Add custom supported types handler or modify existing type handler. + @param extMap Custom supported types with corresponded handler + */ + addHandlers(extMap: any): void; + } + } + + /**************************************************** + * LoadingItems + *****************************************************/ + + export namespace LoadingItems { + /** !#en The item states of the LoadingItems, its value could be LoadingItems.ItemState.WORKING | LoadingItems.ItemState.COMPLETET | LoadingItems.ItemState.ERROR + !#zh LoadingItems 队列中的加载项状态,状态的值可能是 LoadingItems.ItemState.WORKING | LoadingItems.ItemState.COMPLETET | LoadingItems.ItemState.ERROR */ + export enum ItemState { + WORKING = 0, + COMPLETET = 0, + ERROR = 0, + } + } + + /**************************************************** + * PhysicsManager + *****************************************************/ + + export namespace PhysicsManager { + /** !#en + The draw bits for drawing physics debug information.
+ example:
+ ```js + cc.director.getPhysicsManager().debugDrawFlags = + // cc.PhysicsManager.DrawBits.e_aabbBit | + // cc.PhysicsManager.DrawBits.e_pairBit | + // cc.PhysicsManager.DrawBits.e_centerOfMassBit | + cc.PhysicsManager.DrawBits.e_jointBit | + cc.PhysicsManager.DrawBits.e_shapeBit; + ``` + !#zh + 指定物理系统需要绘制哪些调试信息。
+ example:
+ ```js + cc.director.getPhysicsManager().debugDrawFlags = + // cc.PhysicsManager.DrawBits.e_aabbBit | + // cc.PhysicsManager.DrawBits.e_pairBit | + // cc.PhysicsManager.DrawBits.e_centerOfMassBit | + cc.PhysicsManager.DrawBits.e_jointBit | + cc.PhysicsManager.DrawBits.e_shapeBit; + ``` */ + export enum DrawBits { + e_aabbBit = 0, + e_jointBit = 0, + e_shapeBit = 0, + } + } + + /**************************************************** + * macro + *****************************************************/ + + export namespace macro { + /** !#en Key map for keyboard event + !#zh 键盘事件的按键值 */ + export enum KEY { + none = 0, + back = 0, + menu = 0, + backspace = 0, + tab = 0, + enter = 0, + shift = 0, + ctrl = 0, + alt = 0, + pause = 0, + capslock = 0, + escape = 0, + space = 0, + pageup = 0, + pagedown = 0, + end = 0, + home = 0, + left = 0, + up = 0, + right = 0, + down = 0, + select = 0, + insert = 0, + Delete = 0, + a = 0, + b = 0, + c = 0, + d = 0, + e = 0, + f = 0, + g = 0, + h = 0, + i = 0, + j = 0, + k = 0, + l = 0, + m = 0, + n = 0, + o = 0, + p = 0, + q = 0, + r = 0, + s = 0, + t = 0, + u = 0, + v = 0, + w = 0, + x = 0, + y = 0, + z = 0, + num0 = 0, + num1 = 0, + num2 = 0, + num3 = 0, + num4 = 0, + num5 = 0, + num6 = 0, + num7 = 0, + num8 = 0, + num9 = 0, + '*' = 0, + '+' = 0, + '-' = 0, + numdel = 0, + '/' = 0, + f1 = 0, + f2 = 0, + f3 = 0, + f4 = 0, + f5 = 0, + f6 = 0, + f7 = 0, + f8 = 0, + f9 = 0, + f10 = 0, + f11 = 0, + f12 = 0, + numlock = 0, + scrolllock = 0, + ';' = 0, + semicolon = 0, + equal = 0, + '=' = 0, + ',' = 0, + comma = 0, + dash = 0, + '.' = 0, + period = 0, + forwardslash = 0, + grave = 0, + '[' = 0, + openbracket = 0, + backslash = 0, + ']' = 0, + closebracket = 0, + quote = 0, + dpadLeft = 0, + dpadRight = 0, + dpadUp = 0, + dpadDown = 0, + dpadCenter = 0, + } + } + + /**************************************************** + * macro + *****************************************************/ + + export namespace macro { + /** Image formats */ + export enum ImageFormat { + JPG = 0, + PNG = 0, + TIFF = 0, + WEBP = 0, + PVR = 0, + ETC = 0, + S3TC = 0, + ATITC = 0, + TGA = 0, + RAWDATA = 0, + UNKNOWN = 0, + } + } + + /**************************************************** + * macro + *****************************************************/ + + export namespace macro { + /** !#en + Enum for blend factor + Refer to: http://www.andersriggelsen.dk/glblendfunc.php + !#zh + 混合因子 + 可参考: http://www.andersriggelsen.dk/glblendfunc.php */ + export enum BlendFactor { + ONE = 0, + ZERO = 0, + SRC_ALPHA = 0, + SRC_COLOR = 0, + DST_ALPHA = 0, + DST_COLOR = 0, + ONE_MINUS_SRC_ALPHA = 0, + ONE_MINUS_SRC_COLOR = 0, + ONE_MINUS_DST_ALPHA = 0, + ONE_MINUS_DST_COLOR = 0, + } + } + + /**************************************************** + * macro + *****************************************************/ + + export namespace macro { + /** undefined */ + export enum TextAlignment { + LEFT = 0, + CENTER = 0, + RIGHT = 0, + } + } + + /**************************************************** + * sys + *****************************************************/ + + export namespace sys { + /** !#en + Network type enumeration + !#zh + 网络类型枚举 */ + export enum NetworkType { + NONE = 0, + LAN = 0, + WWAN = 0, + } + } + + /**************************************************** + * ParticleSystem3DAssembler + *****************************************************/ + + export namespace ParticleSystem3DAssembler { + /** 粒子的生成模式 */ + export enum RenderMode { + } + } + + /**************************************************** + * shapeModule + *****************************************************/ + + export namespace shapeModule { + /** 粒子发射器类型 */ + export enum ShapeType { + Box = 0, + Circle = 0, + Cone = 0, + Sphere = 0, + Hemisphere = 0, + } + } + + /**************************************************** + * shapeModule + *****************************************************/ + + export namespace shapeModule { + /** 粒子从发射器的哪个部位发射 */ + export enum EmitLocation { + Base = 0, + Edge = 0, + Shell = 0, + Volume = 0, + } + } + + /**************************************************** + * shapeModule + *****************************************************/ + + export namespace shapeModule { + /** 粒子在扇形区域的发射方式 */ + export enum ArcMode { + Random = 0, + Loop = 0, + PingPong = 0, + } + } + + /**************************************************** + * trailModule + *****************************************************/ + + export namespace trailModule { + /** 选择如何为粒子系统生成轨迹 */ + export enum TrailMode { + } + } + + /**************************************************** + * trailModule + *****************************************************/ + + export namespace trailModule { + /** 纹理填充模式 */ + export enum TextureMode { + } + } + + /**************************************************** + * primitive + *****************************************************/ + + export namespace primitive { + /** undefined */ + export enum PolyhedronType { + Tetrahedron = 0, + Octahedron = 0, + Dodecahedron = 0, + Icosahedron = 0, + Rhombicuboctahedron = 0, + TriangularPrism = 0, + PentagonalPrism = 0, + HexagonalPrism = 0, + SquarePyramid = 0, + PentagonalPyramid = 0, + TriangularDipyramid = 0, + PentagonalDipyramid = 0, + ElongatedSquareDipyramid = 0, + ElongatedPentagonalDipyramid = 0, + ElongatedPentagonalCupola = 0, + } + } + + /**************************************************** + * primitive + *****************************************************/ + + export namespace primitive { + /** undefined */ + export class VertexData { + positions: number[]; + normals: number[]; + uvs: number[]; + indices: number[]; + minPos: Vec3; + maxPos: Vec3; + boundingRadius: number; + } + } + + /**************************************************** + * Material + *****************************************************/ + + export namespace Material { + /** !#en Material builtin name + !#zh 内置材质名字 */ + export enum BUILTIN_NAME { + SPRITE = 0, + GRAY_SPRITE = 0, + UNLIT = 0, + } + } + + /**************************************************** + * EditBox + *****************************************************/ + + export namespace EditBox { + /** !#en Enum for keyboard return types + !#zh 键盘的返回键类型 */ + export enum KeyboardReturnType { + DEFAULT = 0, + DONE = 0, + SEND = 0, + SEARCH = 0, + GO = 0, + NEXT = 0, + } + } + + /**************************************************** + * EditBox + *****************************************************/ + + export namespace EditBox { + /** !#en The EditBox's InputMode defines the type of text that the user is allowed to enter. + !#zh 输入模式 */ + export enum InputMode { + ANY = 0, + EMAIL_ADDR = 0, + NUMERIC = 0, + PHONE_NUMBER = 0, + URL = 0, + DECIMAL = 0, + SINGLE_LINE = 0, + } + } + + /**************************************************** + * EditBox + *****************************************************/ + + export namespace EditBox { + /** !#en Enum for the EditBox's input flags + !#zh 定义了一些用于设置文本显示和文本格式化的标志位。 */ + export enum InputFlag { + PASSWORD = 0, + SENSITIVE = 0, + INITIAL_CAPS_WORD = 0, + INITIAL_CAPS_SENTENCE = 0, + INITIAL_CAPS_ALL_CHARACTERS = 0, + DEFAULT = 0, + } + } + + /**************************************************** + * textureAnimationModule + *****************************************************/ + + export namespace textureAnimationModule { + /** 粒子贴图动画类型 */ + export enum Mode { + } + } + + /**************************************************** + * textureAnimationModule + *****************************************************/ + + export namespace textureAnimationModule { + /** 贴图动画的播放方式 */ + export enum Animation { + } + } + +} + +/** !#en +The global main namespace of Spine, all classes, functions, +properties and constants of Spine are defined in this namespace +!#zh +Spine 的全局的命名空间, +与 Spine 相关的所有的类,函数,属性,常量都在这个命名空间中定义。 */ +declare namespace sp { + /** !#en + The skeleton of Spine
+
+ (Skeleton has a reference to a SkeletonData and stores the state for skeleton instance, + which consists of the current pose's bone SRT, slot colors, and which slot attachments are visible.
+ Multiple skeletons can use the same SkeletonData which includes all animations, skins, and attachments.)
+ !#zh + Spine 骨骼动画
+
+ (Skeleton 具有对骨骼数据的引用并且存储了骨骼实例的状态, + 它由当前的骨骼动作,slot 颜色,和可见的 slot attachments 组成。
+ 多个 Skeleton 可以使用相同的骨骼数据,其中包括所有的动画,皮肤和 attachments。 */ + export class Skeleton extends cc.RenderComponent { + /** !#en The skeletal animation is paused? + !#zh 该骨骼动画是否暂停。 */ + paused: boolean; + /** !#en + The skeleton data contains the skeleton information (bind pose bones, slots, draw order, + attachments, skins, etc) and animations but does not hold any state.
+ Multiple skeletons can share the same skeleton data. + !#zh + 骨骼数据包含了骨骼信息(绑定骨骼动作,slots,渲染顺序, + attachments,皮肤等等)和动画但不持有任何状态。
+ 多个 Skeleton 可以共用相同的骨骼数据。 */ + skeletonData: SkeletonData; + /** !#en The name of default skin. + !#zh 默认的皮肤名称。 */ + defaultSkin: string; + /** !#en The name of default animation. + !#zh 默认的动画名称。 */ + defaultAnimation: string; + /** !#en The name of current playing animation. + !#zh 当前播放的动画名称。 */ + animation: string; + _defaultSkinIndex: number; + /** !#en TODO + !#zh 是否循环播放当前骨骼动画。 */ + loop: boolean; + /** !#en Indicates whether to enable premultiplied alpha. + You should disable this option when image's transparent area appears to have opaque pixels, + or enable this option when image's half transparent area appears to be darken. + !#zh 是否启用贴图预乘。 + 当图片的透明区域出现色块时需要关闭该选项,当图片的半透明区域颜色变黑时需要启用该选项。 */ + premultipliedAlpha: boolean; + /** !#en The time scale of this skeleton. + !#zh 当前骨骼中所有动画的时间缩放率。 */ + timeScale: number; + /** !#en Indicates whether open debug slots. + !#zh 是否显示 slot 的 debug 信息。 */ + debugSlots: boolean; + /** !#en Indicates whether open debug bones. + !#zh 是否显示 bone 的 debug 信息。 */ + debugBones: boolean; + /** !#en Indicates whether open debug mesh. + !#zh 是否显示 mesh 的 debug 信息。 */ + debugMesh: boolean; + /** !#en Enabled two color tint. + !#zh 是否启用染色效果。 */ + useTint: boolean; + /** !#en Enabled batch model, if skeleton is complex, do not enable batch, or will lower performance. + !#zh 开启合批,如果渲染大量相同纹理,且结构简单的骨骼动画,开启合批可以降低drawcall,否则请不要开启,cpu消耗会上升。 */ + enableBatch: boolean; + /** + !#en + Sets runtime skeleton data to sp.Skeleton.
+ This method is different from the `skeletonData` property. This method is passed in the raw data provided by the Spine runtime, and the skeletonData type is the asset type provided by Creator. + !#zh + 设置底层运行时用到的 SkeletonData。
+ 这个接口有别于 `skeletonData` 属性,这个接口传入的是 Spine runtime 提供的原始数据,而 skeletonData 的类型是 Creator 提供的资源类型。 + @param skeletonData skeletonData + */ + setSkeletonData(skeletonData: sp.spine.SkeletonData): void; + /** + !#en Sets slots visible range. + !#zh 设置骨骼插槽可视范围。 + @param startSlotIndex startSlotIndex + @param endSlotIndex endSlotIndex + */ + setSlotsRange(startSlotIndex: number, endSlotIndex: number): void; + /** + !#en Sets animation state data.
+ The parameter type is {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.AnimationStateData. + !#zh 设置动画状态数据。
+ 参数是 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.AnimationStateData。 + @param stateData stateData + */ + setAnimationStateData(stateData: sp.spine.AnimationStateData): void; + /** + !#en + It's best to set cache mode before set property 'dragonAsset', or will waste some cpu time. + If set the mode in editor, then no need to worry about order problem. + !#zh + 若想切换渲染模式,最好在设置'dragonAsset'之前,先设置好渲染模式,否则有运行时开销。 + 若在编辑中设置渲染模式,则无需担心设置次序的问题。 + @param cacheMode cacheMode + + @example + ```js + skeleton.setAnimationCacheMode(sp.Skeleton.AnimationCacheMode.SHARED_CACHE); + ``` + */ + setAnimationCacheMode(cacheMode: Skeleton.AnimationCacheMode): void; + /** + !#en Whether in cached mode. + !#zh 当前是否处于缓存模式。 + */ + isAnimationCached(): boolean; + /** + !#en Sets vertex effect delegate. + !#zh 设置顶点动画代理 + @param effectDelegate effectDelegate + */ + setVertexEffectDelegate(effectDelegate: VertexEffectDelegate): void; + /** + !#en Computes the world SRT from the local SRT for each bone. + !#zh 重新更新所有骨骼的世界 Transform, + 当获取 bone 的数值未更新时,即可使用该函数进行更新数值。 + + @example + ```js + var bone = spine.findBone('head'); + cc.log(bone.worldX); // return 0; + spine.updateWorldTransform(); + bone = spine.findBone('head'); + cc.log(bone.worldX); // return -23.12; + ``` + */ + updateWorldTransform(): void; + /** + !#en Sets the bones and slots to the setup pose. + !#zh 还原到起始动作 + */ + setToSetupPose(): void; + /** + !#en + Sets the bones to the setup pose, + using the values from the `BoneData` list in the `SkeletonData`. + !#zh + 设置 bone 到起始动作 + 使用 SkeletonData 中的 BoneData 列表中的值。 + */ + setBonesToSetupPose(): void; + /** + !#en + Sets the slots to the setup pose, + using the values from the `SlotData` list in the `SkeletonData`. + !#zh + 设置 slot 到起始动作。 + 使用 SkeletonData 中的 SlotData 列表中的值。 + */ + setSlotsToSetupPose(): void; + /** + !#en + Updating an animation cache to calculate all frame data in the animation is a cost in + performance due to calculating all data in a single frame. + To update the cache, use the invalidAnimationCache method with high performance. + !#zh + 更新某个动画缓存, 预计算动画中所有帧数据,由于在单帧计算所有数据,所以较消耗性能。 + 若想更新缓存,可使用 invalidAnimationCache 方法,具有较高性能。 + @param animName animName + */ + updateAnimationCache(animName: string): void; + /** + !#en + Invalidates the animation cache, which is then recomputed on each frame.. + !#zh + 使动画缓存失效,之后会在每帧重新计算。 + */ + invalidAnimationCache(): void; + /** + !#en + Finds a bone by name. + This does a string comparison for every bone.
+ Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Bone object. + !#zh + 通过名称查找 bone。 + 这里对每个 bone 的名称进行了对比。
+ 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Bone 对象。 + @param boneName boneName + */ + findBone(boneName: string): sp.spine.Bone; + /** + !#en + Finds a slot by name. This does a string comparison for every slot.
+ Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Slot object. + !#zh + 通过名称查找 slot。这里对每个 slot 的名称进行了比较。
+ 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Slot 对象。 + @param slotName slotName + */ + findSlot(slotName: string): sp.spine.Slot; + /** + !#en + Finds a skin by name and makes it the active skin. + This does a string comparison for every skin.
+ Note that setting the skin does not change which attachments are visible.
+ Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Skin object. + !#zh + 按名称查找皮肤,激活该皮肤。这里对每个皮肤的名称进行了比较。
+ 注意:设置皮肤不会改变 attachment 的可见性。
+ 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Skin 对象。 + @param skinName skinName + */ + setSkin(skinName: string): void; + /** + !#en + Returns the attachment for the slot and attachment name. + The skeleton looks first in its skin, then in the skeleton data’s default skin.
+ Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Attachment object. + !#zh + 通过 slot 和 attachment 的名称获取 attachment。Skeleton 优先查找它的皮肤,然后才是 Skeleton Data 中默认的皮肤。
+ 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Attachment 对象。 + @param slotName slotName + @param attachmentName attachmentName + */ + getAttachment(slotName: string, attachmentName: string): sp.spine.Attachment; + /** + !#en + Sets the attachment for the slot and attachment name. + The skeleton looks first in its skin, then in the skeleton data’s default skin. + !#zh + 通过 slot 和 attachment 的名字来设置 attachment。 + Skeleton 优先查找它的皮肤,然后才是 Skeleton Data 中默认的皮肤。 + @param slotName slotName + @param attachmentName attachmentName + */ + setAttachment(slotName: string, attachmentName: string): void; + /** + Return the renderer of attachment. + @param regionAttachment regionAttachment + */ + getTextureAtlas(regionAttachment: sp.spine.RegionAttachment|spine.BoundingBoxAttachment): sp.spine.TextureAtlasRegion; + /** + !#en + Mix applies all keyframe values, + interpolated for the specified time and mixed with the current values. + !#zh 为所有关键帧设定混合及混合时间(从当前值开始差值)。 + @param fromAnimation fromAnimation + @param toAnimation toAnimation + @param duration duration + */ + setMix(fromAnimation: string, toAnimation: string, duration: number): void; + /** + !#en Set the current animation. Any queued animations are cleared.
+ Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry object. + !#zh 设置当前动画。队列中的任何的动画将被清除。
+ 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry 对象。 + @param trackIndex trackIndex + @param name name + @param loop loop + */ + setAnimation(trackIndex: number, name: string, loop: boolean): sp.spine.TrackEntry; + /** + !#en Adds an animation to be played delay seconds after the current or last queued animation.
+ Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry object. + !#zh 添加一个动画到动画队列尾部,还可以延迟指定的秒数。
+ 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry 对象。 + @param trackIndex trackIndex + @param name name + @param loop loop + @param delay delay + */ + addAnimation(trackIndex: number, name: string, loop: boolean, delay?: number): sp.spine.TrackEntry; + /** + !#en Find animation with specified name. + !#zh 查找指定名称的动画 + @param name name + */ + findAnimation(name: string): sp.spine.Animation; + /** + !#en Returns track entry by trackIndex.
+ Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry object. + !#zh 通过 track 索引获取 TrackEntry。
+ 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry 对象。 + @param trackIndex trackIndex + */ + getCurrent(trackIndex: any): sp.spine.TrackEntry; + /** + !#en Clears all tracks of animation state. + !#zh 清除所有 track 的动画状态。 + */ + clearTracks(): void; + /** + !#en Clears track of animation state by trackIndex. + !#zh 清除出指定 track 的动画状态。 + @param trackIndex trackIndex + */ + clearTrack(trackIndex: number): void; + /** + !#en Set the start event listener. + !#zh 用来设置开始播放动画的事件监听。 + @param listener listener + */ + setStartListener(listener: Function): void; + /** + !#en Set the interrupt event listener. + !#zh 用来设置动画被打断的事件监听。 + @param listener listener + */ + setInterruptListener(listener: Function): void; + /** + !#en Set the end event listener. + !#zh 用来设置动画播放完后的事件监听。 + @param listener listener + */ + setEndListener(listener: Function): void; + /** + !#en Set the dispose event listener. + !#zh 用来设置动画将被销毁的事件监听。 + @param listener listener + */ + setDisposeListener(listener: Function): void; + /** + !#en Set the complete event listener. + !#zh 用来设置动画播放一次循环结束后的事件监听。 + @param listener listener + */ + setCompleteListener(listener: Function): void; + /** + !#en Set the animation event listener. + !#zh 用来设置动画播放过程中帧事件的监听。 + @param listener listener + */ + setEventListener(listener: Function): void; + /** + !#en Set the start event listener for specified TrackEntry. + !#zh 用来为指定的 TrackEntry 设置动画开始播放的事件监听。 + @param entry entry + @param listener listener + */ + setTrackStartListener(entry: sp.spine.TrackEntry, listener: Function): void; + /** + !#en Set the interrupt event listener for specified TrackEntry. + !#zh 用来为指定的 TrackEntry 设置动画被打断的事件监听。 + @param entry entry + @param listener listener + */ + setTrackInterruptListener(entry: sp.spine.TrackEntry, listener: Function): void; + /** + !#en Set the end event listener for specified TrackEntry. + !#zh 用来为指定的 TrackEntry 设置动画播放结束的事件监听。 + @param entry entry + @param listener listener + */ + setTrackEndListener(entry: sp.spine.TrackEntry, listener: Function): void; + /** + !#en Set the dispose event listener for specified TrackEntry. + !#zh 用来为指定的 TrackEntry 设置动画即将被销毁的事件监听。 + @param entry entry + @param listener listener + */ + setTrackDisposeListener(entry: sp.spine.TrackEntry, listener: Function): void; + /** + !#en Set the complete event listener for specified TrackEntry. + !#zh 用来为指定的 TrackEntry 设置动画一次循环播放结束的事件监听。 + @param entry entry + @param listener listener + */ + setTrackCompleteListener(entry: sp.spine.TrackEntry, listener: (entry: sp.spine.TrackEntry, loopCount: number) => void): void; + /** + !#en Set the event listener for specified TrackEntry. + !#zh 用来为指定的 TrackEntry 设置动画帧事件的监听。 + @param entry entry + @param listener listener + */ + setTrackEventListener(entry: sp.spine.TrackEntry, listener: Function): void; + /** + !#en Get the animation state object + !#zh 获取动画状态 + */ + getState(): sp.spine.AnimationState; + } + /** !#en The event type of spine skeleton animation. + !#zh 骨骼动画事件类型。 */ + export enum AnimationEventType { + START = 0, + END = 0, + COMPLETE = 0, + EVENT = 0, + } + /** !#en The skeleton data of spine. + !#zh Spine 的 骨骼数据。 */ + export class SkeletonData extends cc.Asset { + /** !#en See http://en.esotericsoftware.com/spine-json-format + !#zh 可查看 Spine 官方文档 http://zh.esotericsoftware.com/spine-json-format */ + skeletonJson: any; + atlasText: string; + textures: cc.Texture2D[]; + /** !#en + A scale can be specified on the JSON or binary loader which will scale the bone positions, + image sizes, and animation translations. + This can be useful when using different sized images than were used when designing the skeleton + in Spine. For example, if using images that are half the size than were used in Spine, + a scale of 0.5 can be used. This is commonly used for games that can run with either low or high + resolution texture atlases. + see http://en.esotericsoftware.com/spine-using-runtimes#Scaling + !#zh 可查看 Spine 官方文档: http://zh.esotericsoftware.com/spine-using-runtimes#Scaling */ + scale: number; + /** + !#en Get the included SkeletonData used in spine runtime.
+ Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.SkeletonData object. + !#zh 获取 Spine Runtime 使用的 SkeletonData。
+ 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.SkeletonData 对象。 + @param quiet quiet + */ + getRuntimeData(quiet?: boolean): sp.spine.SkeletonData; + } + /** !#en + The delegate of spine vertex effect + !#zh + Spine 顶点动画代理 */ + export class VertexEffectDelegate { + /** + !#en Clears vertex effect. + !#zh 清空顶点效果 + */ + clear(): void; + /** + !#en Inits delegate with jitter effect + !#zh 设置顶点抖动效果 + @param jitterX jitterX + @param jitterY jitterY + */ + initJitter(jitterX: number, jitterY: number): void; + /** + !#en Inits delegate with swirl effect + !#zh 设置顶点漩涡效果 + @param radius radius + @param power power + */ + initSwirlWithPow(radius: number, power: number): sp.spine.JitterEffect; + /** + !#en Inits delegate with swirl effect + !#zh 设置顶点漩涡效果 + @param radius radius + @param power power + */ + initSwirlWithPowOut(radius: number, power: number): sp.spine.SwirlEffect; + /** + !#en Gets jitter vertex effect + !#zh 获取顶点抖动效果 + */ + getJitterVertexEffect(): sp.spine.JitterEffect; + /** + !#en Gets swirl vertex effect + !#zh 获取顶点漩涡效果 + */ + getSwirlVertexEffect(): sp.spine.SwirlEffect; + /** + !#en Gets vertex effect + !#zh 获取顶点效果 + */ + getVertexEffect(): sp.spine.JitterEffect; + /** + !#en Gets effect type + !#zh 获取效果类型 + */ + getEffectType(): string; + } + /**************************************************** + * sp + *****************************************************/ + + export namespace sp { + /** !#en Attach node tool + !#zh 挂点工具类 */ + export class AttachUtil { + /** + !#en Gets attached root node. + !#zh 获取挂接节点树的根节点 + */ + getAttachedRootNode(): cc.Node; + /** + !#en Gets attached node which you want. + !#zh 获得对应的挂点 + @param boneName boneName + */ + getAttachedNodes(boneName: string): cc.Node[]; + /** + !#en Destroy attached node which you want. + !#zh 销毁对应的挂点 + @param boneName boneName + */ + destroyAttachedNodes(boneName: string): void; + /** + !#en Traverse all bones to generate the minimum node tree containing the given bone names, NOTE that make sure the skeleton has initialized before calling this interface. + !#zh 遍历所有插槽,生成包含所有给定插槽名称的最小节点树,注意,调用该接口前请确保骨骼动画已经初始化好。 + @param boneName boneName + */ + generateAttachedNodes(boneName: string): cc.Node[]; + /** + !#en Destroy all attached node. + !#zh 销毁所有挂点 + */ + destroyAllAttachedNodes(): void; + /** + !#en Traverse all bones to generate a tree containing all bones nodes, NOTE that make sure the skeleton has initialized before calling this interface. + !#zh 遍历所有插槽,生成包含所有插槽的节点树,注意,调用该接口前请确保骨骼动画已经初始化好。 + */ + generateAllAttachedNodes(): cc.Node; + } + } + + /**************************************************** + * Skeleton + *****************************************************/ + + export namespace Skeleton { + /** !#en Enum for animation cache mode type. + !#zh Spine动画缓存类型 */ + export enum AnimationCacheMode { + REALTIME = 0, + SHARED_CACHE = 0, + PRIVATE_CACHE = 0, + } + } + +} + +/** !#en +`sp.spine` is the namespace for official Spine Runtime, which officially implemented and maintained by Spine.
+Please refer to the official documentation for its detailed usage: [http://en.esotericsoftware.com/spine-using-runtimes](http://en.esotericsoftware.com/spine-using-runtimes) +!#zh +sp.spine 模块是 Spine 官方运行库的 API 入口,由 Spine 官方统一实现和维护,具体用法请参考:[http://zh.esotericsoftware.com/spine-using-runtimes](http://zh.esotericsoftware.com/spine-using-runtimes) */ +declare namespace sp.spine { +} + +/** !#en +The global main namespace of DragonBones, all classes, functions, +properties and constants of DragonBones are defined in this namespace +!#zh +DragonBones 的全局的命名空间, +与 DragonBones 相关的所有的类,函数,属性,常量都在这个命名空间中定义。 */ +declare namespace dragonBones { + /** !#en + The Armature Display of DragonBones
+
+ (Armature Display has a reference to a DragonBonesAsset and stores the state for ArmatureDisplay instance, + which consists of the current pose's bone SRT, slot colors, and which slot attachments are visible.
+ Multiple Armature Display can use the same DragonBonesAsset which includes all animations, skins, and attachments.)
+ !#zh + DragonBones 骨骼动画
+
+ (Armature Display 具有对骨骼数据的引用并且存储了骨骼实例的状态, + 它由当前的骨骼动作,slot 颜色,和可见的 slot attachments 组成。
+ 多个 Armature Display 可以使用相同的骨骼数据,其中包括所有的动画,皮肤和 attachments。)
*/ + export class ArmatureDisplay extends cc.RenderComponent { + /** !#en + The DragonBones data contains the armatures information (bind pose bones, slots, draw order, + attachments, skins, etc) and animations but does not hold any state.
+ Multiple ArmatureDisplay can share the same DragonBones data. + !#zh + 骨骼数据包含了骨骼信息(绑定骨骼动作,slots,渲染顺序, + attachments,皮肤等等)和动画但不持有任何状态。
+ 多个 ArmatureDisplay 可以共用相同的骨骼数据。 */ + dragonAsset: DragonBonesAsset; + /** !#en + The atlas asset for the DragonBones. + !#zh + 骨骼数据所需的 Atlas Texture 数据。 */ + dragonAtlasAsset: DragonBonesAtlasAsset; + /** !#en The name of current armature. + !#zh 当前的 Armature 名称。 */ + armatureName: string; + /** !#en The name of current playing animation. + !#zh 当前播放的动画名称。 */ + animationName: string; + _defaultArmatureIndex: number; + /** !#en The time scale of this armature. + !#zh 当前骨骼中所有动画的时间缩放率。 */ + timeScale: number; + /** !#en The play times of the default animation. + -1 means using the value of config file; + 0 means repeat for ever + >0 means repeat times + !#zh 播放默认动画的循环次数 + -1 表示使用配置文件中的默认值; + 0 表示无限循环 + >0 表示循环次数 */ + playTimes: number; + /** !#en Indicates whether to enable premultiplied alpha. + You should disable this option when image's transparent area appears to have opaque pixels, + or enable this option when image's half transparent area appears to be darken. + !#zh 是否启用贴图预乘。 + 当图片的透明区域出现色块时需要关闭该选项,当图片的半透明区域颜色变黑时需要启用该选项。 */ + premultipliedAlpha: boolean; + /** !#en Indicates whether open debug bones. + !#zh 是否显示 bone 的 debug 信息。 */ + debugBones: boolean; + /** !#en Enabled batch model, if skeleton is complex, do not enable batch, or will lower performance. + !#zh 开启合批,如果渲染大量相同纹理,且结构简单的骨骼动画,开启合批可以降低drawcall,否则请不要开启,cpu消耗会上升。 */ + enableBatch: boolean; + /** + !#en + The key of dragonbones cache data, which is regard as 'dragonbonesName', when you want to change dragonbones cloth. + !#zh + 缓存龙骨数据的key值,换装的时会使用到该值,作为dragonbonesName使用 + + @example + ```js + let factory = dragonBones.CCFactory.getInstance(); + let needChangeSlot = needChangeArmature.armature().getSlot("changeSlotName"); + factory.replaceSlotDisplay(toChangeArmature.getArmatureKey(), "armatureName", "slotName", "displayName", needChangeSlot); + ``` + */ + getArmatureKey(): string; + /** + !#en + It's best to set cache mode before set property 'dragonAsset', or will waste some cpu time. + If set the mode in editor, then no need to worry about order problem. + !#zh + 若想切换渲染模式,最好在设置'dragonAsset'之前,先设置好渲染模式,否则有运行时开销。 + 若在编辑中设置渲染模式,则无需担心设置次序的问题。 + @param cacheMode cacheMode + + @example + ```js + armatureDisplay.setAnimationCacheMode(dragonBones.ArmatureDisplay.AnimationCacheMode.SHARED_CACHE); + ``` + */ + setAnimationCacheMode(cacheMode: ArmatureDisplay.AnimationCacheMode): void; + /** + !#en Whether in cached mode. + !#zh 当前是否处于缓存模式。 + */ + isAnimationCached(): boolean; + /** + !#en + Play the specified animation. + Parameter animName specify the animation name. + Parameter playTimes specify the repeat times of the animation. + -1 means use the value of the config file. + 0 means play the animation for ever. + >0 means repeat times. + !#zh + 播放指定的动画. + animName 指定播放动画的名称。 + playTimes 指定播放动画的次数。 + -1 为使用配置文件中的次数。 + 0 为无限循环播放。 + >0 为动画的重复次数。 + @param animName animName + @param playTimes playTimes + */ + playAnimation(animName: string, playTimes: number): dragonBones.AnimationState; + /** + !#en + Updating an animation cache to calculate all frame data in the animation is a cost in + performance due to calculating all data in a single frame. + To update the cache, use the invalidAnimationCache method with high performance. + !#zh + 更新某个动画缓存, 预计算动画中所有帧数据,由于在单帧计算所有数据,所以较消耗性能。 + 若想更新缓存,可使用 invalidAnimationCache 方法,具有较高性能。 + @param animName animName + */ + updateAnimationCache(animName: string): void; + /** + !#en + Invalidates the animation cache, which is then recomputed on each frame.. + !#zh + 使动画缓存失效,之后会在每帧重新计算。 + */ + invalidAnimationCache(): void; + /** + !#en + Get the all armature names in the DragonBones Data. + !#zh + 获取 DragonBones 数据中所有的 armature 名称 + */ + getArmatureNames(): any[]; + /** + !#en + Get the all animation names of specified armature. + !#zh + 获取指定的 armature 的所有动画名称。 + @param armatureName armatureName + */ + getAnimationNames(armatureName: string): any[]; + /** + !#en + Add event listener for the DragonBones Event, the same to addEventListener. + !#zh + 添加 DragonBones 事件监听器,与 addEventListener 作用相同。 + @param type A string representing the event type to listen for. + @param listener The callback that will be invoked when the event is dispatched. + @param target The target (this object) to invoke the callback, can be null + */ + on(type: string, listener: (event: cc.Event) => void, target?: any): void; + /** + !#en + Remove the event listener for the DragonBones Event, the same to removeEventListener. + !#zh + 移除 DragonBones 事件监听器,与 removeEventListener 作用相同。 + @param type A string representing the event type to listen for. + @param listener listener + @param target target + */ + off(type: string, listener?: Function, target?: any): void; + /** + !#en + Add DragonBones one-time event listener, the callback will remove itself after the first time it is triggered. + !#zh + 添加 DragonBones 一次性事件监听器,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param listener The callback that will be invoked when the event is dispatched. + @param target The target (this object) to invoke the callback, can be null + */ + once(type: string, listener: (event: cc.Event) => void, target?: any): void; + /** + !#en + Add event listener for the DragonBones Event. + !#zh + 添加 DragonBones 事件监听器。 + @param type A string representing the event type to listen for. + @param listener The callback that will be invoked when the event is dispatched. + @param target The target (this object) to invoke the callback, can be null + */ + addEventListener(type: string, listener: (event: cc.Event) => void, target?: any): void; + /** + !#en + Remove the event listener for the DragonBones Event. + !#zh + 移除 DragonBones 事件监听器。 + @param type A string representing the event type to listen for. + @param listener listener + @param target target + */ + removeEventListener(type: string, listener?: Function, target?: any): void; + /** + !#en + Build the armature for specified name. + !#zh + 构建指定名称的 armature 对象 + @param armatureName armatureName + @param node node + */ + buildArmature(armatureName: string, node: cc.Node): ArmatureDisplay; + /** + !#en + Get the current armature object of the ArmatureDisplay. + !#zh + 获取 ArmatureDisplay 当前使用的 Armature 对象 + */ + armature(): any; + } + /** DragonBones factory */ + export class CCFactory extends BaseFactory { + /** + + + @example + ```js + let factory = dragonBones.CCFactory.getInstance(); + ``` + */ + static getInstance(): CCFactory; + } + /** !#en The skeleton data of dragonBones. + !#zh dragonBones 的 骨骼数据。 */ + export class DragonBonesAsset extends cc.Asset { + /** !#en See http://developer.egret.com/cn/github/egret-docs/DB/dbLibs/dataFormat/index.html + !#zh 可查看 DragonBones 官方文档 http://developer.egret.com/cn/github/egret-docs/DB/dbLibs/dataFormat/index.html */ + dragonBonesJson: string; + } + /** !#en The skeleton atlas data of dragonBones. + !#zh dragonBones 的骨骼纹理数据。 */ + export class DragonBonesAtlasAsset extends cc.Asset { + atlasJson: string; + texture: cc.Texture2D; + } + /**************************************************** + * ArmatureDisplay + *****************************************************/ + + export namespace ArmatureDisplay { + /** !#en Enum for cache mode type. + !#zh Dragonbones渲染类型 */ + export enum AnimationCacheMode { + REALTIME = 0, + SHARED_CACHE = 0, + PRIVATE_CACHE = 0, + } + } + + /**************************************************** + * dragonBones + *****************************************************/ + + export namespace dragonBones { + /** !#en Attach node tool + !#zh 挂点工具类 */ + export class AttachUtil { + /** + !#en Gets attached root node. + !#zh 获取挂接节点树的根节点 + */ + getAttachedRootNode(): cc.Node; + /** + !#en Gets attached node which you want. + !#zh 获得对应的挂点 + @param boneName boneName + */ + getAttachedNodes(boneName: string): cc.Node[]; + /** + !#en Destroy attached node which you want. + !#zh 销毁对应的挂点 + @param boneName boneName + */ + destroyAttachedNodes(boneName: string): void; + /** + !#en Traverse all bones to generate the minimum node tree containing the given bone names, NOTE that make sure the skeleton has initialized before calling this interface. + !#zh 遍历所有插槽,生成包含所有给定插槽名称的最小节点树,注意,调用该接口前请确保骨骼动画已经初始化好。 + @param boneName boneName + */ + generateAttachedNodes(boneName: string): cc.Node[]; + /** + !#en Destroy all attached node. + !#zh 销毁所有挂点 + */ + destroyAllAttachedNodes(): void; + /** + !#en Traverse all bones to generate a tree containing all bones nodes, NOTE that make sure the skeleton has initialized before calling this interface. + !#zh 遍历所有插槽,生成包含所有插槽的节点树,注意,调用该接口前请确保骨骼动画已经初始化好。 + */ + generateAllAttachedNodes(): cc.Node; + } + } + +} + +/** Some helpful utilities */ +declare namespace cc.geomUtils { + /** + !#en + the distance between a point and a plane + !#zh + 计算点和平面之间的距离。 + @param point point + @param plane plane + */ + export function point_plane(point: cc.Vec3, plane: cc.Plane): number; + /** + !#en + the closest point on plane to a given point + !#zh + 计算平面上最接近给定点的点。 + @param out Closest point + @param point Given point + @param plane plane + */ + export function pt_point_plane(out: cc.Vec3, point: cc.Vec3, plane: cc.Plane): cc.Vec3; + /** + !#en + the closest point on aabb to a given point + !#zh + 计算 aabb 上最接近给定点的点。 + @param out Closest point. + @param point Given point. + @param aabb Align the axis around the box. + */ + export function pt_point_aabb(out: cc.Vec3, point: cc.Vec3, aabb: cc.Aabb): cc.Vec3; + /** + !#en + the closest point on obb to a given point + !#zh + 计算 obb 上最接近给定点的点。 + @param out Closest point + @param point Given point + @param obb Direction box + */ + export function pt_point_obb(out: cc.Vec3, point: cc.Vec3, obb: cc.Obb): cc.Vec3; +} + +/** !#en Some JavaScript decorators which can be accessed with "cc._decorator". +!#zh 一些 JavaScript 装饰器,目前可以通过 "cc._decorator" 来访问。 +(这些 API 仍不完全稳定,有可能随着 JavaScript 装饰器的标准实现而调整) */ +declare namespace cc._decorator { + /** + !#en + Declare the standard [ES6 Class](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes) + as CCClass, please see [Class](../../../manual/en/scripting/class.html) for details. + !#zh + 将标准写法的 [ES6 Class](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes) 声明为 CCClass,具体用法请参阅[类型定义](../../../manual/zh/scripting/class.html)。 + @param name The class name used for serialization. + + @example + ```js + const {ccclass} = cc._decorator; + + // define a CCClass, omit the name + @ccclass + class NewScript extends cc.Component { + // ... + } + + // define a CCClass with a name + @ccclass('LoginData') + class LoginData { + // ... + } + ``` + */ + export function ccclass(name?: string): Function; + export function ccclass(_class?: Function): void; + /** + !#en + Declare property for [CCClass](../../../manual/en/scripting/reference/attributes.html). + !#zh + 定义 [CCClass](../../../manual/zh/scripting/reference/attributes.html) 所用的属性。 + @param options an object with some property attributes + + @example + ```js + const {ccclass, property} = cc._decorator; + + @ccclass + class NewScript extends cc.Component { + @property({ + type: cc.Node + }) + targetNode1 = null; + + @property(cc.Node) + targetNode2 = null; + + @property(cc.Button) + targetButton = null; + + @property + _width = 100; + + @property + get width () { + return this._width; + } + + @property + set width (value) { + this._width = value; + } + + @property + offset = new cc.Vec2(100, 100); + + @property(cc.Vec2) + offsets = []; + + @property(cc.SpriteFrame) + frame = null; + } + + // above is equivalent to (上面的代码相当于): + + var NewScript = cc.Class({ + properties: { + targetNode1: { + default: null, + type: cc.Node + }, + + targetNode2: { + default: null, + type: cc.Node + }, + + targetButton: { + default: null, + type: cc.Button + }, + + _width: 100, + + width: { + get () { + return this._width; + }, + set (value) { + this._width = value; + } + }, + + offset: new cc.Vec2(100, 100) + + offsets: { + default: [], + type: cc.Vec2 + } + + frame: { + default: null, + type: cc.SpriteFrame + }, + } + }); + ``` + */ + export function property(options?: {type?: any; visible?: boolean|(() => boolean); displayName?: string; tooltip?: string; multiline?: boolean; readonly?: boolean; min?: number; max?: number; step?: number; range?: number[]; slide?: boolean; serializable?: boolean; formerlySerializedAs?: string; editorOnly?: boolean; override?: boolean; animatable?: boolean} | any[]|Function|cc.ValueType|number|string|boolean): Function; + export function property(_target: Object, _key: any, _desc?: any): void; + /** + !#en + Makes a CCClass that inherit from component execute in edit mode.
+ By default, all components are only executed in play mode, + which means they will not have their callback functions executed while the Editor is in edit mode. + !#zh + 允许继承自 Component 的 CCClass 在编辑器里执行。
+ 默认情况下,所有 Component 都只会在运行时才会执行,也就是说它们的生命周期回调不会在编辑器里触发。 + + @example + ```js + const {ccclass, executeInEditMode} = cc._decorator; + + @ccclass + @executeInEditMode + class NewScript extends cc.Component { + // ... + } + ``` + */ + export function executeInEditMode(): Function; + export function executeInEditMode(_class: Function): void; + /** + !#en + Automatically add required component as a dependency for the CCClass that inherit from component. + !#zh + 为声明为 CCClass 的组件添加依赖的其它组件。当组件添加到节点上时,如果依赖的组件不存在,引擎将会自动将依赖组件添加到同一个节点,防止脚本出错。该设置在运行时同样有效。 + @param requiredComponent requiredComponent + + @example + ```js + const {ccclass, requireComponent} = cc._decorator; + + @ccclass + @requireComponent(cc.Sprite) + class SpriteCtrl extends cc.Component { + // ... + } + ``` + */ + export function requireComponent(requiredComponent: typeof cc.Component): Function; + /** + !#en + The menu path to register a component to the editors "Component" menu. Eg. "Rendering/CameraCtrl". + !#zh + 将当前组件添加到组件菜单中,方便用户查找。例如 "Rendering/CameraCtrl"。 + @param path The path is the menu represented like a pathname. + For example the menu could be "Rendering/CameraCtrl". + + @example + ```js + const {ccclass, menu} = cc._decorator; + + @ccclass + @menu("Rendering/CameraCtrl") + class NewScript extends cc.Component { + // ... + } + ``` + */ + export function menu(path: string): Function; + /** + !#en + The execution order of lifecycle methods for Component. + Those less than 0 will execute before while those greater than 0 will execute after. + The order will only affect onLoad, onEnable, start, update and lateUpdate while onDisable and onDestroy will not be affected. + !#zh + 设置脚本生命周期方法调用的优先级。优先级小于 0 的组件将会优先执行,优先级大于 0 的组件将会延后执行。优先级仅会影响 onLoad, onEnable, start, update 和 lateUpdate,而 onDisable 和 onDestroy 不受影响。 + @param order The execution order of lifecycle methods for Component. Those less than 0 will execute before while those greater than 0 will execute after. + + @example + ```js + const {ccclass, executionOrder} = cc._decorator; + + @ccclass + @executionOrder(1) + class CameraCtrl extends cc.Component { + // ... + } + ``` + */ + export function executionOrder(order: number): Function; + /** + !#en + Prevents Component of the same type (or subtype) to be added more than once to a Node. + !#zh + 防止多个相同类型(或子类型)的组件被添加到同一个节点。 + + @example + ```js + const {ccclass, disallowMultiple} = cc._decorator; + + @ccclass + @disallowMultiple + class CameraCtrl extends cc.Component { + // ... + } + ``` + */ + export function disallowMultiple(): Function; + export function disallowMultiple(_class: Function): void; + /** + !#en + If specified, the editor's scene view will keep updating this node in 60 fps when it is selected, otherwise, it will update only if necessary.
+ This property is only available if executeInEditMode is true. + !#zh + 当指定了 "executeInEditMode" 以后,playOnFocus 可以在选中当前组件所在的节点时,提高编辑器的场景刷新频率到 60 FPS,否则场景就只会在必要的时候进行重绘。 + + @example + ```js + const {ccclass, playOnFocus, executeInEditMode} = cc._decorator; + + @ccclass + @executeInEditMode + @playOnFocus + class CameraCtrl extends cc.Component { + // ... + } + ``` + */ + export function playOnFocus(): Function; + export function playOnFocus(_class: Function): void; + /** + !#en + Specifying the url of the custom html to draw the component in **Properties**. + !#zh + 自定义当前组件在 **属性检查器** 中渲染时所用的网页 url。 + @param url url + + @example + ```js + const {ccclass, inspector} = cc._decorator; + + @ccclass + @inspector("packages://inspector/inspectors/comps/camera-ctrl.js") + class NewScript extends cc.Component { + // ... + } + ``` + */ + export function inspector(path: string): Function; + /** + !#en + The custom documentation URL. + !#zh + 指定当前组件的帮助文档的 url,设置过后,在 **属性检查器** 中就会出现一个帮助图标,用户点击将打开指定的网页。 + @param url url + + @example + ```js + const {ccclass, help} = cc._decorator; + + @ccclass + @help("app://docs/html/components/spine.html") + class NewScript extends cc.Component { + // ... + } + ``` + */ + export function help(path: string): Function; + /** + NOTE:
+ The old mixins implemented in cc.Class(ES5) behaves exact the same as multiple inheritance. + But since ES6, class constructor can't be function-called and class methods become non-enumerable, + so we can not mix in ES6 Classes.
+ See:
+ [https://esdiscuss.org/topic/traits-are-now-impossible-in-es6-until-es7-since-rev32](https://esdiscuss.org/topic/traits-are-now-impossible-in-es6-until-es7-since-rev32)
+ One possible solution (but IDE unfriendly):
+ [http://justinfagnani.com/2015/12/21/real-mixins-with-javascript-classes](http://justinfagnani.com/2015/12/21/real-mixins-with-javascript-classes/)
+
+ NOTE:
+ You must manually call mixins constructor, this is different from cc.Class(ES5). + @param ctor constructors to mix, only support ES5 constructors or classes defined by using `cc.Class`, + not support ES6 Classes. + + @example + ```js + const {ccclass, mixins} = cc._decorator; + + class Animal { ... } + + const Fly = cc.Class({ + constructor () { ... } + }); + + @ccclass + @mixins(cc.EventTarget, Fly) + class Bird extends Animal { + constructor () { + super(); + + // You must manually call mixins constructor, this is different from cc.Class(ES5) + cc.EventTarget.call(this); + Fly.call(this); + } + // ... + } + ``` + */ + export function mixins(ctor: Function, ...rest: Function[]): Function; +} + +/** !#en This module provides some JavaScript utilities. All members can be accessed with `cc.js`. +!#zh 这个模块封装了 JavaScript 相关的一些实用函数,你可以通过 `cc.js` 来访问这个模块。 */ +declare namespace cc.js { + /** + Check the obj whether is number or not + If a number is created by using 'new Number(10086)', the typeof it will be "object"... + Then you can use this function if you care about this case. + @param obj obj + */ + export function isNumber(obj: any): boolean; + /** + Check the obj whether is string or not. + If a string is created by using 'new String("blabla")', the typeof it will be "object"... + Then you can use this function if you care about this case. + @param obj obj + */ + export function isString(obj: any): boolean; + /** + Copy all properties not defined in obj from arguments[1...n] + @param obj object to extend its properties + @param sourceObj source object to copy properties from + */ + export function addon(obj: any, ...sourceObj: any[]): any; + /** + copy all properties from arguments[1...n] to obj + @param obj obj + @param sourceObj sourceObj + */ + export function mixin(obj: any, ...sourceObj: any[]): any; + /** + Derive the class from the supplied base class. + Both classes are just native javascript constructors, not created by cc.Class, so + usually you will want to inherit using {{#crossLink "cc/Class:method"}}cc.Class {{/crossLink}} instead. + @param cls cls + @param base the baseclass to inherit + */ + export function extend(cls: Function, base: Function): Function; + /** + Get super class + @param ctor the constructor of subclass + */ + export function getSuper(ctor: Function): Function; + /** + Checks whether subclass is child of superclass or equals to superclass + @param subclass subclass + @param superclass superclass + */ + export function isChildClassOf(subclass: Function, superclass: Function): boolean; + /** + Removes all enumerable properties from object + @param obj obj + */ + export function clear(obj: any): void; + /** + Checks whether obj is an empty object + @param obj obj + */ + export function isEmptyObject(obj: any): boolean; + /** + Get property descriptor in object and all its ancestors + @param obj obj + @param name name + */ + export function getPropertyDescriptor(obj: any, name: string): any; + /** + Define value, just help to call Object.defineProperty.
+ The configurable will be true. + @param obj obj + @param prop prop + @param value value + @param writable writable + @param enumerable enumerable + */ + export function value(obj: any, prop: string, value: any, writable?: boolean, enumerable?: boolean): void; + /** + Define get set accessor, just help to call Object.defineProperty(...) + @param obj obj + @param prop prop + @param getter getter + @param setter setter + @param enumerable enumerable + @param configurable configurable + */ + export function getset(obj: any, prop: string, getter: Function, setter?: Function, enumerable?: boolean, configurable?: boolean): void; + /** + Define get accessor, just help to call Object.defineProperty(...) + @param obj obj + @param prop prop + @param getter getter + @param enumerable enumerable + @param configurable configurable + */ + export function get(obj: any, prop: string, getter: Function, enumerable?: boolean, configurable?: boolean): void; + /** + Define set accessor, just help to call Object.defineProperty(...) + @param obj obj + @param prop prop + @param setter setter + @param enumerable enumerable + @param configurable configurable + */ + export function set(obj: any, prop: string, setter: Function, enumerable?: boolean, configurable?: boolean): void; + /** + Get class name of the object, if object is just a {} (and which class named 'Object'), it will return "". + (modified from the code from this stackoverflow post) + @param objOrCtor instance or constructor + */ + export function getClassName(objOrCtor: any|Function): string; + /** !#en All classes registered in the engine, indexed by ID. + !#zh 引擎中已注册的所有类型,通过 ID 进行索引。 */ + export var _registeredClassIds: any; + /** !#en All classes registered in the engine, indexed by name. + !#zh 引擎中已注册的所有类型,通过名称进行索引。 */ + export var _registeredClassNames: any; + /** + Register the class by specified name manually + @param className className + @param constructor constructor + */ + export function setClassName(className: string, constructor: Function): void; + /** + Unregister a class from fireball. + + If you dont need a registered class anymore, you should unregister the class so that Fireball will not keep its reference anymore. + Please note that its still your responsibility to free other references to the class. + @param constructor the class you will want to unregister, any number of classes can be added + */ + export function unregisterClass(...constructor: Function[]): void; + /** + Get the registered class by name + @param classname classname + */ + export function getClassByName(classname: string): Function; + /** + Defines a polyfill field for deprecated codes. + @param obj YourObject or YourClass.prototype + @param obsoleted "OldParam" or "YourClass.OldParam" + @param newExpr "NewParam" or "YourClass.NewParam" + @param writable writable + */ + export function obsolete(obj: any, obsoleted: string, newExpr: string, writable?: boolean): void; + /** + Defines all polyfill fields for obsoleted codes corresponding to the enumerable properties of props. + @param obj YourObject or YourClass.prototype + @param objName "YourObject" or "YourClass" + @param props props + @param writable writable + */ + export function obsoletes(obj: any, objName: any, props: any, writable?: boolean): void; + /** + A string tool to construct a string with format string. + @param msg A JavaScript string containing zero or more substitution strings (%s). + @param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output. + + @example + ```js + cc.js.formatStr("a: %s, b: %s", a, b); + cc.js.formatStr(a, b, c); + ``` + */ + export function formatStr(msg: string|any, ...subst: any[]): string; + /** + !#en + A simple wrapper of `Object.create(null)` which ensures the return object have no prototype (and thus no inherited members). So we can skip `hasOwnProperty` calls on property lookups. It is a worthwhile optimization than the `{}` literal when `hasOwnProperty` calls are necessary. + !#zh + 该方法是对 `Object.create(null)` 的简单封装。`Object.create(null)` 用于创建无 prototype (也就无继承)的空对象。这样我们在该对象上查找属性时,就不用进行 `hasOwnProperty` 判断。在需要频繁判断 `hasOwnProperty` 时,使用这个方法性能会比 `{}` 更高。 + @param forceDictMode Apply the delete operator to newly created map object. This causes V8 to put the object in "dictionary mode" and disables creation of hidden classes which are very expensive for objects that are constantly changing shape. + */ + export function createMap(forceDictMode?: boolean): any; + /** undefined */ + export class array { + /** + Removes the array item at the specified index. + @param array array + @param index index + */ + static removeAt(array: any[], index: number): void; + /** + Removes the array item at the specified index. + It's faster but the order of the array will be changed. + @param array array + @param index index + */ + static fastRemoveAt(array: any[], index: number): void; + /** + Removes the first occurrence of a specific object from the array. + @param array array + @param value value + */ + static remove(array: any[], value: any): boolean; + /** + Removes the first occurrence of a specific object from the array. + It's faster but the order of the array will be changed. + @param array array + @param value value + */ + static fastRemove(array: any[], value: number): void; + /** + Verify array's Type + @param array array + @param type type + */ + static verifyType(array: any[], type: Function): boolean; + /** + Removes from array all values in minusArr. For each Value in minusArr, the first matching instance in array will be removed. + @param array Source Array + @param minusArr minus Array + */ + static removeArray(array: any[], minusArr: any[]): void; + /** + Inserts some objects at index + @param array array + @param addObjs addObjs + @param index index + */ + static appendObjectsAt(array: any[], addObjs: any[], index: number): any[]; + /** + Exact same function as Array.prototype.indexOf.
+ HACK: ugliy hack for Baidu mobile browser compatibility, stupid Baidu guys modify Array.prototype.indexOf for all pages loaded, their version changes strict comparison to non-strict comparison, it also ignores the second parameter of the original API, and this will cause event handler enter infinite loop.
+ Baidu developers, if you ever see this documentation, here is the standard: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf, Seriously! + @param searchElement Element to locate in the array. + @param fromIndex The index to start the search at + */ + static indexOf(searchElement: any, fromIndex?: number): number; + /** + Determines whether the array contains a specific value. + @param array array + @param value value + */ + static contains(array: any[], value: any): boolean; + /** + Copy an array's item to a new array (its performance is better than Array.slice) + @param array array + */ + static copy(array: any[]): any[]; + } + /** !#en + A fixed-length object pool designed for general type.
+ The implementation of this object pool is very simple, + it can helps you to improve your game performance for objects which need frequent release and recreate operations
+ !#zh + 长度固定的对象缓存池,可以用来缓存各种对象类型。
+ 这个对象池的实现非常精简,它可以帮助您提高游戏性能,适用于优化对象的反复创建和销毁。 */ + export class Pool { + /** + !#en + Constructor for creating an object pool for the specific object type. + You can pass a callback argument for process the cleanup logic when the object is recycled. + !#zh + 使用构造函数来创建一个指定对象类型的对象池,您可以传递一个回调函数,用于处理对象回收时的清理逻辑。 + @param cleanupFunc the callback method used to process the cleanup logic when the object is recycled. + @param size initializes the length of the array + */ + constructor(cleanupFunc: (obj: any) => void, size: number); + constructor(size: number); + /** + !#en + Get and initialize an object from pool. This method defaults to null and requires the user to implement it. + !#zh + 获取并初始化对象池中的对象。这个方法默认为空,需要用户自己实现。 + @param params parameters to used to initialize the object + */ + get(...params: any[]): any; + /** !#en + The current number of available objects, the default is 0, it will gradually increase with the recycle of the object, + the maximum will not exceed the size specified when the constructor is called. + !#zh + 当前可用对象数量,一开始默认是 0,随着对象的回收会逐渐增大,最大不会超过调用构造函数时指定的 size。 */ + count: number; + /** + !#en + Get an object from pool, if no available object in the pool, null will be returned. + !#zh + 获取对象池中的对象,如果对象池没有可用对象,则返回空。 + */ + _get(): any; + /** + !#en Put an object into the pool. + !#zh 向对象池返还一个不再需要的对象。 + */ + put(): void; + /** + !#en Resize the pool. + !#zh 设置对象池容量。 + */ + resize(): void; + } +} + +/** !#en A basic module for creating vertex data for 3D objects. You can access this module by `cc.primitive`. +!#zh 一个创建 3D 物体顶点数据的基础模块,你可以通过 `cc.primitive` 来访问这个模块。 */ +declare namespace cc.primitive { + /** + !#en Create box vertex data + !#zh 创建长方体顶点数据 + @param width width + @param height height + @param length length + @param opts opts + */ + export function box(width: number, height: number, length: number, opts: {widthSegments: number; heightSegments: number; lengthSegments: number; }): cc.VertexData; + /** + !#en Create cone vertex data + !#zh 创建圆锥体顶点数据 + @param radius radius + @param height height + @param opts opts + */ + export function cone(radius: number, height: number, opts: {radialSegments: number; heightSegments: number; capped: boolean; arc: number; }): cc.VertexData; + /** + !#en Create cylinder vertex data + !#zh 创建圆柱体顶点数据 + @param radiusTop radiusTop + @param radiusBottom radiusBottom + @param height height + @param opts opts + */ + export function cylinder(radiusTop: number, radiusBottom: number, height: number, opts: {radialSegments: number; heightSegments: number; capped: boolean; arc: number; }): cc.VertexData; + /** + !#en Create plane vertex data + !#zh 创建平台顶点数据 + @param width width + @param length length + @param opts opts + */ + export function plane(width: number, length: number, opts: {widthSegments: number; lengthSegments: number; }): cc.VertexData; + /** + !#en Create quad vertex data + !#zh 创建面片顶点数据 + */ + export function quad(): cc.VertexData; + /** + !#en Create sphere vertex data + !#zh 创建球体顶点数据 + @param radius radius + @param opts opts + */ + export function sphere(radius: number, opts: {segments: number; }): cc.VertexData; + /** + !#en Create torus vertex data + !#zh 创建圆环顶点数据 + @param radius radius + @param tube tube + @param opts opts + */ + export function torus(radius: number, tube: number, opts: {radialSegments: number; tubularSegments: number; arc: number; }): cc.VertexData; + /** + !#en Create capsule vertex data + !#zh 创建胶囊体顶点数据 + @param radiusTop radiusTop + @param radiusBottom radiusBottom + @param height height + @param opts opts + */ + export function capsule(radiusTop: number, radiusBottom: number, height: number, opts: {sides: number; heightSegments: number; capped: boolean; arc: number; }): cc.VertexData; + /** + !#en Create polyhedron vertex data + !#zh 创建多面体顶点数据 + @param type type + @param Size Size + @param opts opts + */ + export function polyhedron(type: cc.primitive.PolyhedronType, Size: number, opts: {sizeX: number; sizeY: number; sizeZ: number; }): cc.VertexData; +} + +declare let CC_JSB: boolean +declare let CC_NATIVERENDERER: boolean +declare let CC_EDITOR: boolean + +declare let cc: { + // polyfills: { + // destroyObject? (object: any): void; + // }; + [x: string]: any; +} + +// https://medium.com/dailyjs/typescript-create-a-condition-based-subset-types-9d902cea5b8c +type FlagExcludedType = { [Key in keyof Base]: Base[Key] extends Type ? never : Key }; +type AllowedNames = FlagExcludedType[keyof Base]; +type KeyPartial = { [P in K]?: T[P] }; +type OmitType = KeyPartial>; +type ConstructorType = OmitType; + +declare interface IWritableArrayLike { + readonly length: number; + [index: number]: T; +} + +declare let module: { + exports: object +} + + +declare interface Math { + sign(v: number); +} + +declare interface Object { + assign(target: {}, source: {}); +} + + +type FloatArray = Float64Array | Float32Array; + +interface IColorLike { + r: number; + g: number; + b: number; + a: number; + _val: number; + +} + +interface IMat3Like { + m: FloatArray +} + +interface IMat4Like { + m: FloatArray +} + +interface IQuatLike { + x: number; + y: number; + z: number; + w: number; +} + +interface IRectLike { + x: number; + y: number; + width: number; + height: number; +} + +interface ISizeLike { + width: number; + height: number; +} + +interface IVec2Like { + x: number; + y: number; +} + +interface IVec3Like { + x: number; + y: number; + z: number; +} + +interface IVec4Like { + x: number; + y: number; + z: number; + w: number; +} +declare namespace dragonBones { + /** + * @internal + * @private + */ + const webAssemblyModule: { + HEAP16: Int16Array; + _malloc(byteSize: number): number; + _free(pointer: number): void; + setDataBinary(data: DragonBonesData, binaryPointer: number, intBytesLength: number, floatBytesLength: number, frameIntBytesLength: number, frameFloatBytesLength: number, frameBytesLength: number, timelineBytesLength: number): void; + }; +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + const enum BinaryOffset { + WeigthBoneCount = 0, + WeigthFloatOffset = 1, + WeigthBoneIndices = 2, + MeshVertexCount = 0, + MeshTriangleCount = 1, + MeshFloatOffset = 2, + MeshWeightOffset = 3, + MeshVertexIndices = 4, + TimelineScale = 0, + TimelineOffset = 1, + TimelineKeyFrameCount = 2, + TimelineFrameValueCount = 3, + TimelineFrameValueOffset = 4, + TimelineFrameOffset = 5, + FramePosition = 0, + FrameTweenType = 1, + FrameTweenEasingOrCurveSampleCount = 2, + FrameCurveSamples = 3, + DeformMeshOffset = 0, + DeformCount = 1, + DeformValueCount = 2, + DeformValueOffset = 3, + DeformFloatOffset = 4, + } + /** + * @internal + * @private + */ + const enum ArmatureType { + Armature = 0, + MovieClip = 1, + Stage = 2, + } + /** + * @internal + * @private + */ + const enum BoneType { + Bone = 0, + Surface = 1, + } + /** + * @private + */ + const enum DisplayType { + Image = 0, + Armature = 1, + Mesh = 2, + BoundingBox = 3, + } + /** + * - Bounding box type. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 边界框类型。 + * @version DragonBones 5.0 + * @language zh_CN + */ + const enum BoundingBoxType { + Rectangle = 0, + Ellipse = 1, + Polygon = 2, + } + /** + * @internal + * @private + */ + const enum ActionType { + Play = 0, + Frame = 10, + Sound = 11, + } + /** + * @internal + * @private + */ + const enum BlendMode { + Normal = 0, + Add = 1, + Alpha = 2, + Darken = 3, + Difference = 4, + Erase = 5, + HardLight = 6, + Invert = 7, + Layer = 8, + Lighten = 9, + Multiply = 10, + Overlay = 11, + Screen = 12, + Subtract = 13, + } + /** + * @internal + * @private + */ + const enum TweenType { + None = 0, + Line = 1, + Curve = 2, + QuadIn = 3, + QuadOut = 4, + QuadInOut = 5, + } + /** + * @internal + * @private + */ + const enum TimelineType { + Action = 0, + ZOrder = 1, + BoneAll = 10, + BoneTranslate = 11, + BoneRotate = 12, + BoneScale = 13, + Surface = 50, + SlotDisplay = 20, + SlotColor = 21, + SlotFFD = 22, + IKConstraint = 30, + AnimationTime = 40, + AnimationWeight = 41, + } + /** + * - Offset mode. + * @version DragonBones 5.5 + * @language en_US + */ + /** + * - 偏移模式。 + * @version DragonBones 5.5 + * @language zh_CN + */ + const enum OffsetMode { + None = 0, + Additive = 1, + Override = 2, + } + /** + * - Animation fade out mode. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画淡出模式。 + * @version DragonBones 4.5 + * @language zh_CN + */ + const enum AnimationFadeOutMode { + /** + * - Do not fade out of any animation states. + * @language en_US + */ + /** + * - 不淡出任何的动画状态。 + * @language zh_CN + */ + None = 0, + /** + * - Fade out the animation states of the same layer. + * @language en_US + */ + /** + * - 淡出同层的动画状态。 + * @language zh_CN + */ + SameLayer = 1, + /** + * - Fade out the animation states of the same group. + * @language en_US + */ + /** + * - 淡出同组的动画状态。 + * @language zh_CN + */ + SameGroup = 2, + /** + * - Fade out the animation states of the same layer and group. + * @language en_US + */ + /** + * - 淡出同层并且同组的动画状态。 + * @language zh_CN + */ + SameLayerAndGroup = 3, + /** + * - Fade out of all animation states. + * @language en_US + */ + /** + * - 淡出所有的动画状态。 + * @language zh_CN + */ + All = 4, + /** + * - Does not replace the animation state with the same name. + * @language en_US + */ + /** + * - 不替换同名的动画状态。 + * @language zh_CN + */ + Single = 5, + } + /** + * @private + */ + interface Map { + [key: string]: T; + } + /** + * @private + */ + class DragonBones { + static readonly VERSION: string; + static yDown: boolean; + static debug: boolean; + static debugDraw: boolean; + static webAssembly: boolean; + private readonly _clock; + private readonly _events; + private readonly _objects; + private _eventManager; + constructor(eventManager: IEventDispatcher); + advanceTime(passedTime: number): void; + bufferEvent(value: EventObject): void; + bufferObject(object: BaseObject): void; + readonly clock: WorldClock; + readonly eventManager: IEventDispatcher; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The BaseObject is the base class for all objects in the DragonBones framework. + * All BaseObject instances are cached to the object pool to reduce the performance consumption of frequent requests for memory or memory recovery. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 基础对象,通常 DragonBones 的对象都继承自该类。 + * 所有基础对象的实例都会缓存到对象池,以减少频繁申请内存或内存回收的性能消耗。 + * @version DragonBones 4.5 + * @language zh_CN + */ + abstract class BaseObject { + private static _hashCode; + private static _defaultMaxCount; + private static readonly _maxCountMap; + private static readonly _poolsMap; + private static _returnObject(object); + static toString(): string; + /** + * - Set the maximum cache count of the specify object pool. + * @param objectConstructor - The specify class. (Set all object pools max cache count if not set) + * @param maxCount - Max count. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 设置特定对象池的最大缓存数量。 + * @param objectConstructor - 特定的类。 (不设置则设置所有对象池的最大缓存数量) + * @param maxCount - 最大缓存数量。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static setMaxCount(objectConstructor: (typeof BaseObject) | null, maxCount: number): void; + /** + * - Clear the cached instances of a specify object pool. + * @param objectConstructor - Specify class. (Clear all cached instances if not set) + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 清除特定对象池的缓存实例。 + * @param objectConstructor - 特定的类。 (不设置则清除所有缓存的实例) + * @version DragonBones 4.5 + * @language zh_CN + */ + static clearPool(objectConstructor?: (typeof BaseObject) | null): void; + /** + * - Get an instance of the specify class from object pool. + * @param objectConstructor - The specify class. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 从对象池中获取特定类的实例。 + * @param objectConstructor - 特定的类。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static borrowObject(objectConstructor: { + new (): T; + }): T; + /** + * - A unique identification number assigned to the object. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 分配给此实例的唯一标识号。 + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly hashCode: number; + private _isInPool; + /** + * @private + */ + protected abstract _onClear(): void; + /** + * - Clear the object and return it back to object pool。 + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 清除该实例的所有数据并将其返还对象池。 + * @version DragonBones 4.5 + * @language zh_CN + */ + returnToPool(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - 2D Transform matrix. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 2D 转换矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class Matrix { + /** + * - The value that affects the positioning of pixels along the x axis when scaling or rotating an image. + * @default 1.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 缩放或旋转图像时影响像素沿 x 轴定位的值。 + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + a: number; + /** + * - The value that affects the positioning of pixels along the y axis when rotating or skewing an image. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 旋转或倾斜图像时影响像素沿 y 轴定位的值。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + b: number; + /** + * - The value that affects the positioning of pixels along the x axis when rotating or skewing an image. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 旋转或倾斜图像时影响像素沿 x 轴定位的值。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + c: number; + /** + * - The value that affects the positioning of pixels along the y axis when scaling or rotating an image. + * @default 1.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 缩放或旋转图像时影响像素沿 y 轴定位的值。 + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + d: number; + /** + * - The distance by which to translate each point along the x axis. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 沿 x 轴平移每个点的距离。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + tx: number; + /** + * - The distance by which to translate each point along the y axis. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 沿 y 轴平移每个点的距离。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + ty: number; + /** + * @private + */ + constructor(a?: number, b?: number, c?: number, d?: number, tx?: number, ty?: number); + toString(): string; + /** + * @private + */ + copyFrom(value: Matrix): Matrix; + /** + * @private + */ + copyFromArray(value: Array, offset?: number): Matrix; + /** + * - Convert to unit matrix. + * The resulting matrix has the following properties: a=1, b=0, c=0, d=1, tx=0, ty=0. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 转换为单位矩阵。 + * 该矩阵具有以下属性:a=1、b=0、c=0、d=1、tx=0、ty=0。 + * @version DragonBones 3.0 + * @language zh_CN + */ + identity(): Matrix; + /** + * - Multiplies the current matrix with another matrix. + * @param value - The matrix that needs to be multiplied. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 将当前矩阵与另一个矩阵相乘。 + * @param value - 需要相乘的矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + concat(value: Matrix): Matrix; + /** + * - Convert to inverse matrix. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 转换为逆矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + invert(): Matrix; + /** + * - Apply a matrix transformation to a specific point. + * @param x - X coordinate. + * @param y - Y coordinate. + * @param result - The point after the transformation is applied. + * @param delta - Whether to ignore tx, ty's conversion to point. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 将矩阵转换应用于特定点。 + * @param x - 横坐标。 + * @param y - 纵坐标。 + * @param result - 应用转换之后的点。 + * @param delta - 是否忽略 tx,ty 对点的转换。 + * @version DragonBones 3.0 + * @language zh_CN + */ + transformPoint(x: number, y: number, result: { + x: number; + y: number; + }, delta?: boolean): void; + /** + * @private + */ + transformRectangle(rectangle: { + x: number; + y: number; + width: number; + height: number; + }, delta?: boolean): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - 2D Transform. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 2D 变换。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class Transform { + /** + * @private + */ + static readonly PI: number; + /** + * @private + */ + static readonly PI_D: number; + /** + * @private + */ + static readonly PI_H: number; + /** + * @private + */ + static readonly PI_Q: number; + /** + * @private + */ + static readonly RAD_DEG: number; + /** + * @private + */ + static readonly DEG_RAD: number; + /** + * @private + */ + static normalizeRadian(value: number): number; + /** + * - Horizontal translate. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 水平位移。 + * @version DragonBones 3.0 + * @language zh_CN + */ + x: number; + /** + * - Vertical translate. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 垂直位移。 + * @version DragonBones 3.0 + * @language zh_CN + */ + y: number; + /** + * - Skew. (In radians) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 倾斜。 (以弧度为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + skew: number; + /** + * - rotation. (In radians) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 旋转。 (以弧度为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + rotation: number; + /** + * - Horizontal Scaling. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 水平缩放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + scaleX: number; + /** + * - Vertical scaling. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 垂直缩放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + scaleY: number; + /** + * @private + */ + constructor(x?: number, y?: number, skew?: number, rotation?: number, scaleX?: number, scaleY?: number); + toString(): string; + /** + * @private + */ + copyFrom(value: Transform): Transform; + /** + * @private + */ + identity(): Transform; + /** + * @private + */ + add(value: Transform): Transform; + /** + * @private + */ + minus(value: Transform): Transform; + /** + * @private + */ + fromMatrix(matrix: Matrix): Transform; + /** + * @private + */ + toMatrix(matrix: Matrix): Transform; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + class ColorTransform { + alphaMultiplier: number; + redMultiplier: number; + greenMultiplier: number; + blueMultiplier: number; + alphaOffset: number; + redOffset: number; + greenOffset: number; + blueOffset: number; + constructor(alphaMultiplier?: number, redMultiplier?: number, greenMultiplier?: number, blueMultiplier?: number, alphaOffset?: number, redOffset?: number, greenOffset?: number, blueOffset?: number); + copyFrom(value: ColorTransform): void; + identity(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The Point object represents a location in a two-dimensional coordinate system. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - Point 对象表示二维坐标系统中的某个位置。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class Point { + /** + * - The horizontal coordinate. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 该点的水平坐标。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + x: number; + /** + * - The vertical coordinate. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 该点的垂直坐标。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + y: number; + /** + * - Creates a new point. If you pass no parameters to this method, a point is created at (0,0). + * @param x - The horizontal coordinate. + * @param y - The vertical coordinate. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 创建一个 egret.Point 对象.若不传入任何参数,将会创建一个位于(0,0)位置的点。 + * @param x - 该对象的x属性值,默认为 0.0。 + * @param y - 该对象的y属性值,默认为 0.0。 + * @version DragonBones 3.0 + * @language zh_CN + */ + constructor(x?: number, y?: number); + /** + * @private + */ + copyFrom(value: Point): void; + /** + * @private + */ + clear(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - A Rectangle object is an area defined by its position, as indicated by its top-left corner point (x, y) and by its + * width and its height.
+ * The x, y, width, and height properties of the Rectangle class are independent of each other; changing the value of + * one property has no effect on the others. However, the right and bottom properties are integrally related to those + * four properties. For example, if you change the value of the right property, the value of the width property changes; + * if you change the bottom property, the value of the height property changes. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - Rectangle 对象是按其位置(由它左上角的点 (x, y) 确定)以及宽度和高度定义的区域。
+ * Rectangle 类的 x、y、width 和 height 属性相互独立;更改一个属性的值不会影响其他属性。 + * 但是,right 和 bottom 属性与这四个属性是整体相关的。例如,如果更改 right 属性的值,则 width + * 属性的值将发生变化;如果更改 bottom 属性,则 height 属性的值将发生变化。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class Rectangle { + /** + * - The x coordinate of the top-left corner of the rectangle. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 矩形左上角的 x 坐标。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + x: number; + /** + * - The y coordinate of the top-left corner of the rectangle. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 矩形左上角的 y 坐标。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + y: number; + /** + * - The width of the rectangle, in pixels. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 矩形的宽度(以像素为单位)。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + width: number; + /** + * - 矩形的高度(以像素为单位)。 + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - The height of the rectangle, in pixels. + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + height: number; + /** + * @private + */ + constructor(x?: number, y?: number, width?: number, height?: number); + /** + * @private + */ + copyFrom(value: Rectangle): void; + /** + * @private + */ + clear(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The user custom data. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 用户自定义数据。 + * @version DragonBones 5.0 + * @language zh_CN + */ + class UserData extends BaseObject { + static toString(): string; + /** + * - The custom int numbers. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 自定义整数。 + * @version DragonBones 5.0 + * @language zh_CN + */ + readonly ints: Array; + /** + * - The custom float numbers. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 自定义浮点数。 + * @version DragonBones 5.0 + * @language zh_CN + */ + readonly floats: Array; + /** + * - The custom strings. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 自定义字符串。 + * @version DragonBones 5.0 + * @language zh_CN + */ + readonly strings: Array; + /** + * @inheritDoc + */ + protected _onClear(): void; + /** + * @internal + * @private + */ + addInt(value: number): void; + /** + * @internal + * @private + */ + addFloat(value: number): void; + /** + * @internal + * @private + */ + addString(value: string): void; + /** + * - Get the custom int number. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 获取自定义整数。 + * @version DragonBones 5.0 + * @language zh_CN + */ + getInt(index?: number): number; + /** + * - Get the custom float number. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 获取自定义浮点数。 + * @version DragonBones 5.0 + * @language zh_CN + */ + getFloat(index?: number): number; + /** + * - Get the custom string. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 获取自定义字符串。 + * @version DragonBones 5.0 + * @language zh_CN + */ + getString(index?: number): string; + } + /** + * @internal + * @private + */ + class ActionData extends BaseObject { + static toString(): string; + type: ActionType; + name: string; + bone: BoneData | null; + slot: SlotData | null; + data: UserData | null; + protected _onClear(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The DragonBones data. + * A DragonBones data contains multiple armature data. + * @see dragonBones.ArmatureData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 龙骨数据。 + * 一个龙骨数据包含多个骨架数据。 + * @see dragonBones.ArmatureData + * @version DragonBones 3.0 + * @language zh_CN + */ + class DragonBonesData extends BaseObject { + static toString(): string; + /** + * @private + */ + autoSearch: boolean; + /** + * - The animation frame rate. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画帧频。 + * @version DragonBones 3.0 + * @language zh_CN + */ + frameRate: number; + /** + * - The data version. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 数据版本。 + * @version DragonBones 3.0 + * @language zh_CN + */ + version: string; + /** + * - The DragonBones data name. + * The name is consistent with the DragonBones project name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 龙骨数据名称。 + * 该名称与龙骨项目名保持一致。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + stage: ArmatureData | null; + /** + * @internal + * @private + */ + readonly frameIndices: Array; + /** + * @internal + * @private + */ + readonly cachedFrames: Array; + /** + * - All armature data names. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 所有的骨架数据名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly armatureNames: Array; + /** + * @private + */ + readonly armatures: Map; + /** + * @internal + * @private + */ + binary: ArrayBuffer; + /** + * @internal + * @private + */ + intArray: Int16Array; + /** + * @internal + * @private + */ + floatArray: Float32Array; + /** + * @internal + * @private + */ + frameIntArray: Int16Array; + /** + * @internal + * @private + */ + frameFloatArray: Float32Array; + /** + * @internal + * @private + */ + frameArray: Int16Array; + /** + * @internal + * @private + */ + timelineArray: Uint16Array; + /** + * @private + */ + userData: UserData | null; + /** + * @inheritDoc + */ + protected _onClear(): void; + /** + * @internal + * @private + */ + addArmature(value: ArmatureData): void; + /** + * - Get a specific armature data. + * @param name - The armature data name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的骨架数据。 + * @param name - 骨架数据名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + getArmature(name: string): ArmatureData | null; + /** + * - Deprecated, please refer to {@link #dragonBones.BaseFactory#removeDragonBonesData()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #dragonBones.BaseFactory#removeDragonBonesData()}。 + * @deprecated + * @language zh_CN + */ + dispose(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The armature data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨架数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class ArmatureData extends BaseObject { + static toString(): string; + /** + * @private + */ + type: ArmatureType; + /** + * - The animation frame rate. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画帧率。 + * @version DragonBones 3.0 + * @language zh_CN + */ + frameRate: number; + /** + * @private + */ + cacheFrameRate: number; + /** + * @private + */ + scale: number; + /** + * - The armature name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨架名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + readonly aabb: Rectangle; + /** + * - The names of all the animation data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 所有的动画数据名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly animationNames: Array; + /** + * @private + */ + readonly sortedBones: Array; + /** + * @private + */ + readonly sortedSlots: Array; + /** + * @private + */ + readonly defaultActions: Array; + /** + * @private + */ + readonly actions: Array; + /** + * @private + */ + readonly bones: Map; + /** + * @private + */ + readonly slots: Map; + /** + * @private + */ + readonly constraints: Map; + /** + * @private + */ + readonly skins: Map; + /** + * @private + */ + readonly animations: Map; + /** + * - The default skin data. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 默认插槽数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + defaultSkin: SkinData | null; + /** + * - The default animation data. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 默认动画数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + defaultAnimation: AnimationData | null; + /** + * @private + */ + canvas: CanvasData | null; + /** + * @private + */ + userData: UserData | null; + /** + * @private + */ + parent: DragonBonesData; + /** + * @inheritDoc + */ + protected _onClear(): void; + /** + * @internal + * @private + */ + sortBones(): void; + /** + * @internal + * @private + */ + cacheFrames(frameRate: number): void; + /** + * @internal + * @private + */ + setCacheFrame(globalTransformMatrix: Matrix, transform: Transform): number; + /** + * @internal + * @private + */ + getCacheFrame(globalTransformMatrix: Matrix, transform: Transform, arrayOffset: number): void; + /** + * @internal + * @private + */ + addBone(value: BoneData): void; + /** + * @internal + * @private + */ + addSlot(value: SlotData): void; + /** + * @internal + * @private + */ + addConstraint(value: ConstraintData): void; + /** + * @internal + * @private + */ + addSkin(value: SkinData): void; + /** + * @internal + * @private + */ + addAnimation(value: AnimationData): void; + /** + * @internal + * @private + */ + addAction(value: ActionData, isDefault: boolean): void; + /** + * - Get a specific done data. + * @param name - The bone name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的骨骼数据。 + * @param name - 骨骼名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + getBone(name: string): BoneData | null; + /** + * - Get a specific slot data. + * @param name - The slot name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的插槽数据。 + * @param name - 插槽名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + getSlot(name: string): SlotData | null; + /** + * @private + */ + getConstraint(name: string): ConstraintData | null; + /** + * - Get a specific skin data. + * @param name - The skin name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定皮肤数据。 + * @param name - 皮肤名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + getSkin(name: string): SkinData | null; + /** + * @internal + * @private + */ + getMesh(skinName: string, slotName: string, meshName: string): MeshDisplayData | null; + /** + * - Get a specific animation data. + * @param name - The animation name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的动画数据。 + * @param name - 动画名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + getAnimation(name: string): AnimationData | null; + } + /** + * - The bone data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨骼数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class BoneData extends BaseObject { + static toString(): string; + /** + * @private + */ + inheritTranslation: boolean; + /** + * @private + */ + inheritRotation: boolean; + /** + * @private + */ + inheritScale: boolean; + /** + * @private + */ + inheritReflection: boolean; + /** + * @private + */ + type: BoneType; + /** + * - The bone length. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨骼长度。 + * @version DragonBones 3.0 + * @language zh_CN + */ + length: number; + /** + * - The bone name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨骼名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + readonly transform: Transform; + /** + * @private + */ + userData: UserData | null; + /** + * - The parent bone data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 父骨骼数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + parent: BoneData | null; + /** + * @inheritDoc + */ + protected _onClear(): void; + } + /** + * @internal + * @private + */ + class SurfaceData extends BoneData { + static toString(): string; + segmentX: number; + segmentY: number; + readonly vertices: Array; + /** + * @inheritDoc + */ + protected _onClear(): void; + } + /** + * - The slot data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 插槽数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class SlotData extends BaseObject { + /** + * @internal + * @private + */ + static readonly DEFAULT_COLOR: ColorTransform; + /** + * @internal + * @private + */ + static createColor(): ColorTransform; + static toString(): string; + /** + * @private + */ + blendMode: BlendMode; + /** + * @private + */ + displayIndex: number; + /** + * @private + */ + zOrder: number; + /** + * - The slot name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 插槽名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + color: ColorTransform; + /** + * @private + */ + userData: UserData | null; + /** + * - The parent bone data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 父骨骼数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + parent: BoneData; + /** + * @inheritDoc + */ + protected _onClear(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + abstract class ConstraintData extends BaseObject { + order: number; + name: string; + target: BoneData; + root: BoneData; + bone: BoneData | null; + protected _onClear(): void; + } + /** + * @internal + * @private + */ + class IKConstraintData extends ConstraintData { + static toString(): string; + scaleEnabled: boolean; + bendPositive: boolean; + weight: number; + protected _onClear(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + class CanvasData extends BaseObject { + static toString(): string; + hasBackground: boolean; + color: number; + x: number; + y: number; + width: number; + height: number; + protected _onClear(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The skin data, typically a armature data instance contains at least one skinData. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 皮肤数据,通常一个骨架数据至少包含一个皮肤数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class SkinData extends BaseObject { + static toString(): string; + /** + * - The skin name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 皮肤名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + readonly displays: Map>; + /** + * @private + */ + parent: ArmatureData; + /** + * @inheritDoc + */ + protected _onClear(): void; + /** + * @internal + * @private + */ + addDisplay(slotName: string, value: DisplayData | null): void; + /** + * @private + */ + getDisplay(slotName: string, displayName: string): DisplayData | null; + /** + * @private + */ + getDisplays(slotName: string): Array | null; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + abstract class DisplayData extends BaseObject { + type: DisplayType; + name: string; + path: string; + parent: SkinData; + readonly transform: Transform; + protected _onClear(): void; + } + /** + * @internal + * @private + */ + class ImageDisplayData extends DisplayData { + static toString(): string; + readonly pivot: Point; + texture: TextureData | null; + protected _onClear(): void; + } + /** + * @internal + * @private + */ + class ArmatureDisplayData extends DisplayData { + static toString(): string; + inheritAnimation: boolean; + readonly actions: Array; + armature: ArmatureData | null; + protected _onClear(): void; + /** + * @private + */ + addAction(value: ActionData): void; + } + /** + * @internal + * @private + */ + class MeshDisplayData extends DisplayData { + static toString(): string; + inheritDeform: boolean; + offset: number; + weight: WeightData | null; + glue: GlueData | null; + texture: TextureData | null; + protected _onClear(): void; + } + /** + * @internal + * @private + */ + class BoundingBoxDisplayData extends DisplayData { + static toString(): string; + boundingBox: BoundingBoxData | null; + protected _onClear(): void; + } + /** + * @internal + * @private + */ + class WeightData extends BaseObject { + static toString(): string; + count: number; + offset: number; + readonly bones: Array; + protected _onClear(): void; + addBone(value: BoneData): void; + } + /** + * @internal + * @private + */ + class GlueData extends BaseObject { + static toString(): string; + readonly weights: Array; + readonly meshes: Array; + protected _onClear(): void; + addMesh(value: MeshDisplayData | null): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The base class of bounding box data. + * @see dragonBones.RectangleData + * @see dragonBones.EllipseData + * @see dragonBones.PolygonData + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 边界框数据基类。 + * @see dragonBones.RectangleData + * @see dragonBones.EllipseData + * @see dragonBones.PolygonData + * @version DragonBones 5.0 + * @language zh_CN + */ + abstract class BoundingBoxData extends BaseObject { + /** + * - The bounding box type. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 边界框类型。 + * @version DragonBones 5.0 + * @language zh_CN + */ + type: BoundingBoxType; + /** + * @private + */ + color: number; + /** + * @private + */ + width: number; + /** + * @private + */ + height: number; + /** + * @private + */ + protected _onClear(): void; + /** + * - Check whether the bounding box contains a specific point. (Local coordinate system) + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 检查边界框是否包含特定点。(本地坐标系) + * @version DragonBones 5.0 + * @language zh_CN + */ + abstract containsPoint(pX: number, pY: number): boolean; + /** + * - Check whether the bounding box intersects a specific segment. (Local coordinate system) + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 检查边界框是否与特定线段相交。(本地坐标系) + * @version DragonBones 5.0 + * @language zh_CN + */ + abstract intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA: { + x: number; + y: number; + } | null, intersectionPointB: { + x: number; + y: number; + } | null, normalRadians: { + x: number; + y: number; + } | null): number; + } + /** + * - The rectangle bounding box data. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 矩形边界框数据。 + * @version DragonBones 5.1 + * @language zh_CN + */ + class RectangleBoundingBoxData extends BoundingBoxData { + static toString(): string; + /** + * - Compute the bit code for a point (x, y) using the clip rectangle + */ + private static _computeOutCode(x, y, xMin, yMin, xMax, yMax); + /** + * @private + */ + static rectangleIntersectsSegment(xA: number, yA: number, xB: number, yB: number, xMin: number, yMin: number, xMax: number, yMax: number, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): number; + /** + * @inheritDoc + * @private + */ + protected _onClear(): void; + /** + * @inheritDoc + */ + containsPoint(pX: number, pY: number): boolean; + /** + * @inheritDoc + */ + intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): number; + } + /** + * - The ellipse bounding box data. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 椭圆边界框数据。 + * @version DragonBones 5.1 + * @language zh_CN + */ + class EllipseBoundingBoxData extends BoundingBoxData { + static toString(): string; + /** + * @private + */ + static ellipseIntersectsSegment(xA: number, yA: number, xB: number, yB: number, xC: number, yC: number, widthH: number, heightH: number, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): number; + /** + * @inheritDoc + * @private + */ + protected _onClear(): void; + /** + * @inheritDoc + */ + containsPoint(pX: number, pY: number): boolean; + /** + * @inheritDoc + */ + intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): number; + } + /** + * - The polygon bounding box data. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 多边形边界框数据。 + * @version DragonBones 5.1 + * @language zh_CN + */ + class PolygonBoundingBoxData extends BoundingBoxData { + static toString(): string; + /** + * @private + */ + static polygonIntersectsSegment(xA: number, yA: number, xB: number, yB: number, vertices: Array, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): number; + /** + * @private + */ + x: number; + /** + * @private + */ + y: number; + /** + * - The polygon vertices. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 多边形顶点。 + * @version DragonBones 5.1 + * @language zh_CN + */ + readonly vertices: Array; + /** + * @private + */ + weight: WeightData | null; + /** + * @inheritDoc + * @private + */ + protected _onClear(): void; + /** + * @inheritDoc + */ + containsPoint(pX: number, pY: number): boolean; + /** + * @inheritDoc + */ + intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): number; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The animation data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class AnimationData extends BaseObject { + static toString(): string; + /** + * - FrameIntArray. + * @internal + * @private + */ + frameIntOffset: number; + /** + * - FrameFloatArray. + * @internal + * @private + */ + frameFloatOffset: number; + /** + * - FrameArray. + * @internal + * @private + */ + frameOffset: number; + /** + * - The frame count of the animation. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画的帧数。 + * @version DragonBones 3.0 + * @language zh_CN + */ + frameCount: number; + /** + * - The play times of the animation. [0: Loop play, [1~N]: Play N times] + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画的播放次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次] + * @version DragonBones 3.0 + * @language zh_CN + */ + playTimes: number; + /** + * - The duration of the animation. (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画的持续时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + duration: number; + /** + * @private + */ + scale: number; + /** + * - The fade in time of the animation. (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画的淡入时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + fadeInTime: number; + /** + * @private + */ + cacheFrameRate: number; + /** + * - The animation name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + readonly cachedFrames: Array; + /** + * @private + */ + readonly boneTimelines: Map>; + /** + * @private + */ + readonly surfaceTimelines: Map>; + /** + * @private + */ + readonly slotTimelines: Map>; + /** + * @private + */ + readonly constraintTimelines: Map>; + /** + * @private + */ + readonly animationTimelines: Map>; + /** + * @private + */ + readonly boneCachedFrameIndices: Map>; + /** + * @private + */ + readonly slotCachedFrameIndices: Map>; + /** + * @private + */ + actionTimeline: TimelineData | null; + /** + * @private + */ + zOrderTimeline: TimelineData | null; + /** + * @private + */ + parent: ArmatureData; + /** + * @inheritDoc + */ + protected _onClear(): void; + /** + * @internal + * @private + */ + cacheFrames(frameRate: number): void; + /** + * @private + */ + addBoneTimeline(bone: BoneData, timeline: TimelineData): void; + /** + * @private + */ + addSurfaceTimeline(surface: SurfaceData, timeline: TimelineData): void; + /** + * @private + */ + addSlotTimeline(slot: SlotData, timeline: TimelineData): void; + /** + * @private + */ + addConstraintTimeline(constraint: ConstraintData, timeline: TimelineData): void; + /** + * @private + */ + addAnimationTimeline(name: string, timeline: TimelineData): void; + /** + * @private + */ + getBoneTimelines(name: string): Array | null; + /** + * @private + */ + getSurfaceTimelines(name: string): Array | null; + /** + * @private + */ + getSlotTimelines(name: string): Array | null; + /** + * @private + */ + getConstraintTimelines(name: string): Array | null; + /** + * @private + */ + getAnimationTimelines(name: string): Array | null; + /** + * @private + */ + getBoneCachedFrameIndices(name: string): Array | null; + /** + * @private + */ + getSlotCachedFrameIndices(name: string): Array | null; + } + /** + * @internal + * @private + */ + class TimelineData extends BaseObject { + static toString(): string; + type: TimelineType; + offset: number; + frameIndicesOffset: number; + protected _onClear(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The animation config is used to describe all the information needed to play an animation state. + * The API is still in the experimental phase and may encounter bugs or stability or compatibility issues when used. + * @see dragonBones.AnimationState + * @beta + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画配置用来描述播放一个动画状态所需要的全部信息。 + * 该 API 仍在实验阶段,使用时可能遭遇 bug 或稳定性或兼容性问题。 + * @see dragonBones.AnimationState + * @beta + * @version DragonBones 5.0 + * @language zh_CN + */ + class AnimationConfig extends BaseObject { + static toString(): string; + /** + * @private + */ + pauseFadeOut: boolean; + /** + * - Fade out the pattern of other animation states when the animation state is fade in. + * This property is typically used to specify the substitution of multiple animation states blend. + * @default dragonBones.AnimationFadeOutMode.All + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 淡入动画状态时淡出其他动画状态的模式。 + * 该属性通常用来指定多个动画状态混合时的相互替换关系。 + * @default dragonBones.AnimationFadeOutMode.All + * @version DragonBones 5.0 + * @language zh_CN + */ + fadeOutMode: AnimationFadeOutMode; + /** + * @private + */ + fadeOutTweenType: TweenType; + /** + * @private + */ + fadeOutTime: number; + /** + * @private + */ + pauseFadeIn: boolean; + /** + * @private + */ + actionEnabled: boolean; + /** + * @private + */ + additiveBlending: boolean; + /** + * - Whether the animation state has control over the display property of the slots. + * Sometimes blend a animation state does not want it to control the display properties of the slots, + * especially if other animation state are controlling the display properties of the slots. + * @default true + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画状态是否对插槽的显示对象属性有控制权。 + * 有时混合一个动画状态并不希望其控制插槽的显示对象属性, + * 尤其是其他动画状态正在控制这些插槽的显示对象属性时。 + * @default true + * @version DragonBones 5.0 + * @language zh_CN + */ + displayControl: boolean; + /** + * - Whether to reset the objects without animation to the armature pose when the animation state is start to play. + * This property should usually be set to false when blend multiple animation states. + * @default true + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 开始播放动画状态时是否将没有动画的对象重置为骨架初始值。 + * 通常在混合多个动画状态时应该将该属性设置为 false。 + * @default true + * @version DragonBones 5.1 + * @language zh_CN + */ + resetToPose: boolean; + /** + * @private + */ + fadeInTweenType: TweenType; + /** + * - The play times. [0: Loop play, [1~N]: Play N times] + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 播放次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次] + * @version DragonBones 3.0 + * @language zh_CN + */ + playTimes: number; + /** + * - The blend layer. + * High layer animation state will get the blend weight first. + * When the blend weight is assigned more than 1, the remaining animation states will no longer get the weight assigned. + * @readonly + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 混合图层。 + * 图层高的动画状态会优先获取混合权重。 + * 当混合权重分配超过 1 时,剩余的动画状态将不再获得权重分配。 + * @readonly + * @version DragonBones 5.0 + * @language zh_CN + */ + layer: number; + /** + * - The start time of play. (In seconds) + * @default 0.0 + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 播放的开始时间。 (以秒为单位) + * @default 0.0 + * @version DragonBones 5.0 + * @language zh_CN + */ + position: number; + /** + * - The duration of play. + * [-1: Use the default value of the animation data, 0: Stop play, (0~N]: The duration] (In seconds) + * @default -1.0 + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 播放的持续时间。 + * [-1: 使用动画数据默认值, 0: 动画停止, (0~N]: 持续时间] (以秒为单位) + * @default -1.0 + * @version DragonBones 5.0 + * @language zh_CN + */ + duration: number; + /** + * - The play speed. + * The value is an overlay relationship with {@link dragonBones.Animation#timeScale}. + * [(-N~0): Reverse play, 0: Stop play, (0~1): Slow play, 1: Normal play, (1~N): Fast play] + * @default 1.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 播放速度。 + * 该值与 {@link dragonBones.Animation#timeScale} 是叠加关系。 + * [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + timeScale: number; + /** + * - The blend weight. + * @default 1.0 + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 混合权重。 + * @default 1.0 + * @version DragonBones 5.0 + * @language zh_CN + */ + weight: number; + /** + * - The fade in time. + * [-1: Use the default value of the animation data, [0~N]: The fade in time] (In seconds) + * @default -1.0 + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 淡入时间。 + * [-1: 使用动画数据默认值, [0~N]: 淡入时间] (以秒为单位) + * @default -1.0 + * @version DragonBones 5.0 + * @language zh_CN + */ + fadeInTime: number; + /** + * - The auto fade out time when the animation state play completed. + * [-1: Do not fade out automatically, [0~N]: The fade out time] (In seconds) + * @default -1.0 + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画状态播放完成后的自动淡出时间。 + * [-1: 不自动淡出, [0~N]: 淡出时间] (以秒为单位) + * @default -1.0 + * @version DragonBones 5.0 + * @language zh_CN + */ + autoFadeOutTime: number; + /** + * - The name of the animation state. (Can be different from the name of the animation data) + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画状态名称。 (可以不同于动画数据) + * @version DragonBones 5.0 + * @language zh_CN + */ + name: string; + /** + * - The animation data name. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画数据名称。 + * @version DragonBones 5.0 + * @language zh_CN + */ + animation: string; + /** + * - The blend group name of the animation state. + * This property is typically used to specify the substitution of multiple animation states blend. + * @readonly + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 混合组名称。 + * 该属性通常用来指定多个动画状态混合时的相互替换关系。 + * @readonly + * @version DragonBones 5.0 + * @language zh_CN + */ + group: string; + /** + * @private + */ + readonly boneMask: Array; + /** + * @private + */ + protected _onClear(): void; + /** + * @private + */ + clear(): void; + /** + * @private + */ + copyFrom(value: AnimationConfig): void; + /** + * @private + */ + containsBoneMask(name: string): boolean; + /** + * @private + */ + addBoneMask(armature: Armature, name: string, recursive?: boolean): void; + /** + * @private + */ + removeBoneMask(armature: Armature, name: string, recursive?: boolean): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The texture atlas data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 贴图集数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + abstract class TextureAtlasData extends BaseObject { + /** + * @private + */ + autoSearch: boolean; + /** + * @private + */ + width: number; + /** + * @private + */ + height: number; + /** + * @private + */ + scale: number; + /** + * - The texture atlas name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 贴图集名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * - The image path of the texture atlas. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 贴图集图片路径。 + * @version DragonBones 3.0 + * @language zh_CN + */ + imagePath: string; + /** + * @private + */ + readonly textures: Map; + /** + * @inheritDoc + */ + protected _onClear(): void; + /** + * @private + */ + copyFrom(value: TextureAtlasData): void; + /** + * @internal + * @private + */ + abstract createTexture(): TextureData; + /** + * @internal + * @private + */ + addTexture(value: TextureData): void; + /** + * @private + */ + getTexture(name: string): TextureData | null; + } + /** + * @internal + * @private + */ + abstract class TextureData extends BaseObject { + static createRectangle(): Rectangle; + rotated: boolean; + name: string; + readonly region: Rectangle; + parent: TextureAtlasData; + frame: Rectangle | null; + protected _onClear(): void; + copyFrom(value: TextureData): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The armature proxy interface, the docking engine needs to implement it concretely. + * @see dragonBones.Armature + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 骨架代理接口,对接的引擎需要对其进行具体实现。 + * @see dragonBones.Armature + * @version DragonBones 5.0 + * @language zh_CN + */ + interface IArmatureProxy extends IEventDispatcher { + /** + * @internal + * @private + */ + dbInit(armature: Armature): void; + /** + * @internal + * @private + */ + dbClear(): void; + /** + * @internal + * @private + */ + dbUpdate(): void; + /** + * - Dispose the instance and the Armature instance. (The Armature instance will return to the object pool) + * @example + *
+         *     removeChild(armatureDisplay);
+         *     armatureDisplay.dispose();
+         * 
+ * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 释放该实例和骨架。 (骨架会回收到对象池) + * @example + *
+         *     removeChild(armatureDisplay);
+         *     armatureDisplay.dispose();
+         * 
+ * @version DragonBones 4.5 + * @language zh_CN + */ + dispose(disposeProxy: boolean): void; + /** + * - The armature. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 骨架。 + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly armature: Armature; + /** + * - The animation player. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画播放器。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly animation: Animation; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - Armature is the core of the skeleton animation system. + * @see dragonBones.ArmatureData + * @see dragonBones.Bone + * @see dragonBones.Slot + * @see dragonBones.Animation + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨架是骨骼动画系统的核心。 + * @see dragonBones.ArmatureData + * @see dragonBones.Bone + * @see dragonBones.Slot + * @see dragonBones.Animation + * @version DragonBones 3.0 + * @language zh_CN + */ + class Armature extends BaseObject implements IAnimatable { + static toString(): string; + private static _onSortSlots(a, b); + /** + * - Whether to inherit the animation control of the parent armature. + * True to try to have the child armature play an animation with the same name when the parent armature play the animation. + * @default true + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 是否继承父骨架的动画控制。 + * 如果该值为 true,当父骨架播放动画时,会尝试让子骨架播放同名动画。 + * @default true + * @version DragonBones 4.5 + * @language zh_CN + */ + inheritAnimation: boolean; + /** + * @private + */ + userData: any; + private _lockUpdate; + private _bonesDirty; + private _slotsDirty; + private _zOrderDirty; + private _flipX; + private _flipY; + /** + * @internal + * @private + */ + _cacheFrameIndex: number; + private readonly _bones; + private readonly _slots; + /** + * @internal + * @private + */ + readonly _glueSlots: Array; + /** + * @internal + * @private + */ + readonly _constraints: Array; + private readonly _actions; + /** + * @internal + * @private + */ + _armatureData: ArmatureData; + private _animation; + private _proxy; + private _display; + /** + * @internal + * @private + */ + _replaceTextureAtlasData: TextureAtlasData | null; + private _replacedTexture; + /** + * @internal + * @private + */ + _dragonBones: DragonBones; + private _clock; + /** + * @internal + * @private + */ + _parent: Slot | null; + /** + * @private + */ + protected _onClear(): void; + private _sortBones(); + private _sortSlots(); + /** + * @internal + * @private + */ + _sortZOrder(slotIndices: Array | Int16Array | null, offset: number): void; + /** + * @internal + * @private + */ + _addBoneToBoneList(value: Bone): void; + /** + * @internal + * @private + */ + _removeBoneFromBoneList(value: Bone): void; + /** + * @internal + * @private + */ + _addSlotToSlotList(value: Slot): void; + /** + * @internal + * @private + */ + _removeSlotFromSlotList(value: Slot): void; + /** + * @internal + * @private + */ + _bufferAction(action: ActionData, append: boolean): void; + /** + * - Dispose the armature. (Return to the object pool) + * @example + *
+         *     removeChild(armature.display);
+         *     armature.dispose();
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 释放骨架。 (回收到对象池) + * @example + *
+         *     removeChild(armature.display);
+         *     armature.dispose();
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + dispose(): void; + /** + * @internal + * @private + */ + init(armatureData: ArmatureData, proxy: IArmatureProxy, display: any, dragonBones: DragonBones): void; + /** + * @inheritDoc + */ + advanceTime(passedTime: number): void; + /** + * - Forces a specific bone or its owning slot to update the transform or display property in the next frame. + * @param boneName - The bone name. (If not set, all bones will be update) + * @param updateSlot - Whether to update the bone's slots. (Default: false) + * @see dragonBones.Bone#invalidUpdate() + * @see dragonBones.Slot#invalidUpdate() + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 强制特定骨骼或其拥有的插槽在下一帧更新变换或显示属性。 + * @param boneName - 骨骼名称。 (如果未设置,将更新所有骨骼) + * @param updateSlot - 是否更新骨骼的插槽。 (默认: false) + * @see dragonBones.Bone#invalidUpdate() + * @see dragonBones.Slot#invalidUpdate() + * @version DragonBones 3.0 + * @language zh_CN + */ + invalidUpdate(boneName?: string | null, updateSlot?: boolean): void; + /** + * - Check whether a specific point is inside a custom bounding box in a slot. + * The coordinate system of the point is the inner coordinate system of the armature. + * Custom bounding boxes need to be customized in Dragonbones Pro. + * @param x - The horizontal coordinate of the point. + * @param y - The vertical coordinate of the point. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 检查特定点是否在某个插槽的自定义边界框内。 + * 点的坐标系为骨架内坐标系。 + * 自定义边界框需要在 DragonBones Pro 中自定义。 + * @param x - 点的水平坐标。 + * @param y - 点的垂直坐标。 + * @version DragonBones 5.0 + * @language zh_CN + */ + containsPoint(x: number, y: number): Slot | null; + /** + * - Check whether a specific segment intersects a custom bounding box for a slot in the armature. + * The coordinate system of the segment and intersection is the inner coordinate system of the armature. + * Custom bounding boxes need to be customized in Dragonbones Pro. + * @param xA - The horizontal coordinate of the beginning of the segment. + * @param yA - The vertical coordinate of the beginning of the segment. + * @param xB - The horizontal coordinate of the end point of the segment. + * @param yB - The vertical coordinate of the end point of the segment. + * @param intersectionPointA - The first intersection at which a line segment intersects the bounding box from the beginning to the end. (If not set, the intersection point will not calculated) + * @param intersectionPointB - The first intersection at which a line segment intersects the bounding box from the end to the beginning. (If not set, the intersection point will not calculated) + * @param normalRadians - The normal radians of the tangent of the intersection boundary box. [x: Normal radian of the first intersection tangent, y: Normal radian of the second intersection tangent] (If not set, the normal will not calculated) + * @returns The slot of the first custom bounding box where the segment intersects from the start point to the end point. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 检查特定线段是否与骨架的某个插槽的自定义边界框相交。 + * 线段和交点的坐标系均为骨架内坐标系。 + * 自定义边界框需要在 DragonBones Pro 中自定义。 + * @param xA - 线段起点的水平坐标。 + * @param yA - 线段起点的垂直坐标。 + * @param xB - 线段终点的水平坐标。 + * @param yB - 线段终点的垂直坐标。 + * @param intersectionPointA - 线段从起点到终点与边界框相交的第一个交点。 (如果未设置,则不计算交点) + * @param intersectionPointB - 线段从终点到起点与边界框相交的第一个交点。 (如果未设置,则不计算交点) + * @param normalRadians - 交点边界框切线的法线弧度。 [x: 第一个交点切线的法线弧度, y: 第二个交点切线的法线弧度] (如果未设置,则不计算法线) + * @returns 线段从起点到终点相交的第一个自定义边界框的插槽。 + * @version DragonBones 5.0 + * @language zh_CN + */ + intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): Slot | null; + /** + * - Get a specific bone. + * @param name - The bone name. + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的骨骼。 + * @param name - 骨骼名称。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + getBone(name: string): Bone | null; + /** + * - Get a specific bone by the display. + * @param display - The display object. + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 通过显示对象获取特定的骨骼。 + * @param display - 显示对象。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + getBoneByDisplay(display: any): Bone | null; + /** + * - Get a specific slot. + * @param name - The slot name. + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的插槽。 + * @param name - 插槽名称。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + getSlot(name: string): Slot | null; + /** + * - Get a specific slot by the display. + * @param display - The display object. + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 通过显示对象获取特定的插槽。 + * @param display - 显示对象。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + getSlotByDisplay(display: any): Slot | null; + /** + * @deprecated + */ + addBone(value: Bone, parentName: string): void; + /** + * @deprecated + */ + addSlot(value: Slot, parentName: string): void; + /** + * @private + */ + addConstraint(value: Constraint): void; + /** + * @deprecated + */ + removeBone(value: Bone): void; + /** + * @deprecated + */ + removeSlot(value: Slot): void; + /** + * - Get all bones. + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取所有的骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + getBones(): Array; + /** + * - Get all slots. + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取所有的插槽。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + getSlots(): Array; + /** + * - Whether to flip the armature horizontally. + * @version DragonBones 5.5 + * @language en_US + */ + /** + * - 是否将骨架水平翻转。 + * @version DragonBones 5.5 + * @language zh_CN + */ + flipX: boolean; + /** + * - Whether to flip the armature vertically. + * @version DragonBones 5.5 + * @language en_US + */ + /** + * - 是否将骨架垂直翻转。 + * @version DragonBones 5.5 + * @language zh_CN + */ + flipY: boolean; + /** + * - The animation cache frame rate, which turns on the animation cache when the set value is greater than 0. + * There is a certain amount of memory overhead to improve performance by caching animation data in memory. + * The frame rate should not be set too high, usually with the frame rate of the animation is similar and lower than the program running frame rate. + * When the animation cache is turned on, some features will fail, such as the offset property of bone. + * @example + *
+         *     armature.cacheFrameRate = 24;
+         * 
+ * @see dragonBones.DragonBonesData#frameRate + * @see dragonBones.ArmatureData#frameRate + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画缓存帧率,当设置的值大于 0 的时,将会开启动画缓存。 + * 通过将动画数据缓存在内存中来提高运行性能,会有一定的内存开销。 + * 帧率不宜设置的过高,通常跟动画的帧率相当且低于程序运行的帧率。 + * 开启动画缓存后,某些功能将会失效,比如骨骼的 offset 属性等。 + * @example + *
+         *     armature.cacheFrameRate = 24;
+         * 
+ * @see dragonBones.DragonBonesData#frameRate + * @see dragonBones.ArmatureData#frameRate + * @version DragonBones 4.5 + * @language zh_CN + */ + cacheFrameRate: number; + /** + * - The armature name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨架名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly name: string; + /** + * - The armature data. + * @see dragonBones.ArmatureData + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 骨架数据。 + * @see dragonBones.ArmatureData + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly armatureData: ArmatureData; + /** + * - The animation player. + * @see dragonBones.Animation + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画播放器。 + * @see dragonBones.Animation + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly animation: Animation; + /** + * @pivate + */ + readonly proxy: IArmatureProxy; + /** + * - The EventDispatcher instance of the armature. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 该骨架的 EventDispatcher 实例。 + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly eventDispatcher: IEventDispatcher; + /** + * - The display container. + * The display of the slot is displayed as the parent. + * Depending on the rendering engine, the type will be different, usually the DisplayObjectContainer type. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 显示容器实例。 + * 插槽的显示对象都会以此显示容器为父级。 + * 根据渲染引擎的不同,类型会不同,通常是 DisplayObjectContainer 类型。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly display: any; + /** + * @private + */ + replacedTexture: any; + /** + * @inheritDoc + */ + clock: WorldClock | null; + /** + * - Get the parent slot which the armature belongs to. + * @see dragonBones.Slot + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 该骨架所属的父插槽。 + * @see dragonBones.Slot + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly parent: Slot | null; + /** + * @deprecated + * @private + */ + replaceTexture(texture: any): void; + /** + * - Deprecated, please refer to {@link #eventDispatcher}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #eventDispatcher}。 + * @deprecated + * @language zh_CN + */ + hasEventListener(type: EventStringType): boolean; + /** + * - Deprecated, please refer to {@link #eventDispatcher}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #eventDispatcher}。 + * @deprecated + * @language zh_CN + */ + addEventListener(type: EventStringType, listener: Function, target: any): void; + /** + * - Deprecated, please refer to {@link #eventDispatcher}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #eventDispatcher}。 + * @deprecated + * @language zh_CN + */ + removeEventListener(type: EventStringType, listener: Function, target: any): void; + /** + * - Deprecated, please refer to {@link #cacheFrameRate}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #cacheFrameRate}。 + * @deprecated + * @language zh_CN + */ + enableAnimationCache(frameRate: number): void; + /** + * - Deprecated, please refer to {@link #display}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #display}。 + * @deprecated + * @language zh_CN + */ + getDisplay(): any; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The base class of the transform object. + * @see dragonBones.Transform + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 变换对象的基类。 + * @see dragonBones.Transform + * @version DragonBones 4.5 + * @language zh_CN + */ + abstract class TransformObject extends BaseObject { + /** + * @private + */ + protected static readonly _helpMatrix: Matrix; + /** + * @private + */ + protected static readonly _helpTransform: Transform; + /** + * @private + */ + protected static readonly _helpPoint: Point; + /** + * - A matrix relative to the armature coordinate system. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 相对于骨架坐标系的矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly globalTransformMatrix: Matrix; + /** + * - A transform relative to the armature coordinate system. + * @see #updateGlobalTransform() + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 相对于骨架坐标系的变换。 + * @see #updateGlobalTransform() + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly global: Transform; + /** + * - The offset transform relative to the armature or the parent bone coordinate system. + * @see #dragonBones.Bone#invalidUpdate() + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 相对于骨架或父骨骼坐标系的偏移变换。 + * @see #dragonBones.Bone#invalidUpdate() + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly offset: Transform; + /** + * @private + */ + origin: Transform | null; + /** + * @private + */ + userData: any; + /** + * @private + */ + protected _globalDirty: boolean; + /** + * @internal + * @private + */ + _armature: Armature; + /** + * @internal + * @private + */ + _parent: Bone; + /** + * @private + */ + protected _onClear(): void; + /** + * @internal + * @private + */ + _setArmature(value: Armature | null): void; + /** + * @internal + * @private + */ + _setParent(value: Bone | null): void; + /** + * - For performance considerations, rotation or scale in the {@link #global} attribute of the bone or slot is not always properly accessible, + * some engines do not rely on these attributes to update rendering, such as Egret. + * The use of this method ensures that the access to the {@link #global} property is correctly rotation or scale. + * @example + *
+         *     bone.updateGlobalTransform();
+         *     let rotation = bone.global.rotation;
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 出于性能的考虑,骨骼或插槽的 {@link #global} 属性中的旋转或缩放并不总是正确可访问的,有些引擎并不依赖这些属性更新渲染,比如 Egret。 + * 使用此方法可以保证访问到 {@link #global} 属性中正确的旋转或缩放。 + * @example + *
+         *     bone.updateGlobalTransform();
+         *     let rotation = bone.global.rotation;
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + updateGlobalTransform(): void; + /** + * - The armature to which it belongs. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 所属的骨架。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly armature: Armature; + /** + * - The parent bone to which it belongs. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 所属的父骨骼。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly parent: Bone; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - Bone is one of the most important logical units in the armature animation system, + * and is responsible for the realization of translate, rotation, scaling in the animations. + * A armature can contain multiple bones. + * @see dragonBones.BoneData + * @see dragonBones.Armature + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨骼在骨骼动画体系中是最重要的逻辑单元之一,负责动画中的平移、旋转、缩放的实现。 + * 一个骨架中可以包含多个骨骼。 + * @see dragonBones.BoneData + * @see dragonBones.Armature + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + class Bone extends TransformObject { + static toString(): string; + /** + * - The offset mode. + * @see #offset + * @version DragonBones 5.5 + * @language en_US + */ + /** + * - 偏移模式。 + * @see #offset + * @version DragonBones 5.5 + * @language zh_CN + */ + offsetMode: OffsetMode; + /** + * @internal + * @private + */ + readonly animationPose: Transform; + /** + * @internal + * @private + */ + _transformDirty: boolean; + /** + * @internal + * @private + */ + _childrenTransformDirty: boolean; + protected _localDirty: boolean; + /** + * @internal + * @private + */ + _hasConstraint: boolean; + private _visible; + protected _cachedFrameIndex: number; + /** + * @internal + * @private + */ + readonly _blendState: BlendState; + /** + * @internal + * @private + */ + _boneData: BoneData; + /** + * @internal + * @private + */ + _cachedFrameIndices: Array | null; + /** + * @inheritDoc + */ + protected _onClear(): void; + /** + * @private + */ + protected _updateGlobalTransformMatrix(isCache: boolean): void; + /** + * @inheritDoc + */ + _setArmature(value: Armature | null): void; + /** + * @internal + * @private + */ + init(boneData: BoneData): void; + /** + * @internal + * @private + */ + update(cacheFrameIndex: number): void; + /** + * @internal + * @private + */ + updateByConstraint(): void; + /** + * - Forces the bone to update the transform in the next frame. + * When the bone is not animated or its animation state is finished, the bone will not continue to update, + * and when the skeleton must be updated for some reason, the method needs to be called explicitly. + * @example + *
+         *     let bone = armature.getBone("arm");
+         *     bone.offset.scaleX = 2.0;
+         *     bone.invalidUpdate();
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 强制骨骼在下一帧更新变换。 + * 当该骨骼没有动画状态或其动画状态播放完成时,骨骼将不在继续更新,而此时由于某些原因必须更新骨骼时,则需要显式调用该方法。 + * @example + *
+         *     let bone = armature.getBone("arm");
+         *     bone.offset.scaleX = 2.0;
+         *     bone.invalidUpdate();
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + invalidUpdate(): void; + /** + * - Check whether the bone contains a specific bone or slot. + * @see dragonBones.Bone + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 检查该骨骼是否包含特定的骨骼或插槽。 + * @see dragonBones.Bone + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + contains(value: TransformObject): boolean; + /** + * - The bone data. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 骨骼数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly boneData: BoneData; + /** + * - The visible of all slots in the bone. + * @default true + * @see dragonBones.Slot#visible + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 此骨骼所有插槽的可见。 + * @default true + * @see dragonBones.Slot#visible + * @version DragonBones 3.0 + * @language zh_CN + */ + visible: boolean; + /** + * - The bone name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨骼名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly name: string; + /** + * - Deprecated, please refer to {@link dragonBones.Armature#getBones()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link dragonBones.Armature#getBones()}。 + * @deprecated + * @language zh_CN + */ + getBones(): Array; + /** + * - Deprecated, please refer to {@link dragonBones.Armature#getSlots()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link dragonBones.Armature#getSlots()}。 + * @deprecated + * @language zh_CN + */ + getSlots(): Array; + /** + * - Deprecated, please refer to {@link dragonBones.Armature#getSlot()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link dragonBones.Armature#getSlot()}。 + * @deprecated + * @language zh_CN + */ + readonly slot: Slot | null; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + class Surface extends Bone { + static toString(): string; + private _dX; + private _dY; + private _k; + private _kX; + private _kY; + /** + * For debug draw. + * @internal + * @private + */ + readonly _vertices: Array; + /** + * For timeline state. + * @internal + * @private + */ + readonly _deformVertices: Array; + /** + * x1, y1, x2, y2, x3, y3, x4, y4, d1X, d1Y, d2X, d2Y + */ + private readonly _hullCache; + /** + * Inside [flag, a, b, c, d, tx, ty], Outside [flag, a, b, c, d, tx, ty] + */ + private readonly _matrixCahce; + /** + * @inheritDoc + */ + protected _onClear(): void; + private _getAffineTransform(x, y, lX, lY, aX, aY, bX, bY, cX, cY, transform, matrix, isDown); + private _updateVertices(); + /** + * @private + */ + protected _updateGlobalTransformMatrix(isCache: boolean): void; + _getGlobalTransformMatrix(x: number, y: number): Matrix; + init(surfaceData: SurfaceData): void; + /** + * @internal + * @private + */ + update(cacheFrameIndex: number): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The slot attached to the armature, controls the display status and properties of the display object. + * A bone can contain multiple slots. + * A slot can contain multiple display objects, displaying only one of the display objects at a time, + * but you can toggle the display object into frame animation while the animation is playing. + * The display object can be a normal texture, or it can be a display of a child armature, a grid display object, + * and a custom other display object. + * @see dragonBones.Armature + * @see dragonBones.Bone + * @see dragonBones.SlotData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 插槽附着在骨骼上,控制显示对象的显示状态和属性。 + * 一个骨骼上可以包含多个插槽。 + * 一个插槽中可以包含多个显示对象,同一时间只能显示其中的一个显示对象,但可以在动画播放的过程中切换显示对象实现帧动画。 + * 显示对象可以是普通的图片纹理,也可以是子骨架的显示容器,网格显示对象,还可以是自定义的其他显示对象。 + * @see dragonBones.Armature + * @see dragonBones.Bone + * @see dragonBones.SlotData + * @version DragonBones 3.0 + * @language zh_CN + */ + abstract class Slot extends TransformObject { + /** + * - Displays the animated state or mixed group name controlled by the object, set to null to be controlled by all animation states. + * @default null + * @see dragonBones.AnimationState#displayControl + * @see dragonBones.AnimationState#name + * @see dragonBones.AnimationState#group + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 显示对象受到控制的动画状态或混合组名称,设置为 null 则表示受所有的动画状态控制。 + * @default null + * @see dragonBones.AnimationState#displayControl + * @see dragonBones.AnimationState#name + * @see dragonBones.AnimationState#group + * @version DragonBones 4.5 + * @language zh_CN + */ + displayController: string | null; + /** + * @private + */ + protected _displayDirty: boolean; + /** + * @private + */ + protected _zOrderDirty: boolean; + /** + * @private + */ + protected _visibleDirty: boolean; + /** + * @private + */ + protected _blendModeDirty: boolean; + /** + * @internal + * @private + */ + _colorDirty: boolean; + /** + * @internal + * @private + */ + _meshDirty: boolean; + /** + * @private + */ + protected _transformDirty: boolean; + /** + * @private + */ + protected _visible: boolean; + /** + * @private + */ + protected _blendMode: BlendMode; + /** + * @private + */ + protected _displayIndex: number; + /** + * @private + */ + protected _animationDisplayIndex: number; + /** + * @internal + * @private + */ + _zOrder: number; + /** + * @private + */ + protected _cachedFrameIndex: number; + /** + * @internal + * @private + */ + _pivotX: number; + /** + * @internal + * @private + */ + _pivotY: number; + /** + * @private + */ + protected readonly _localMatrix: Matrix; + /** + * @internal + * @private + */ + readonly _colorTransform: ColorTransform; + /** + * @internal + * @private + */ + readonly _deformVertices: Array; + /** + * @private + */ + readonly _displayDatas: Array; + /** + * @private + */ + protected readonly _displayList: Array; + /** + * @private + */ + protected readonly _meshBones: Array; + /** + * @private + */ + protected readonly _meshSlots: Array; + /** + * @internal + * @private + */ + _slotData: SlotData; + /** + * @private + */ + protected _rawDisplayDatas: Array | null; + /** + * @private + */ + protected _displayData: DisplayData | null; + /** + * @private + */ + protected _textureData: TextureData | null; + /** + * @internal + * @private + */ + _meshData: MeshDisplayData | null; + /** + * @private + */ + protected _boundingBoxData: BoundingBoxData | null; + /** + * @private + */ + protected _rawDisplay: any; + /** + * @private + */ + protected _meshDisplay: any; + /** + * @private + */ + protected _display: any; + /** + * @private + */ + protected _childArmature: Armature | null; + /** + * @internal + * @private + */ + _cachedFrameIndices: Array | null; + /** + * @inheritDoc + */ + protected _onClear(): void; + /** + * @private + */ + protected abstract _initDisplay(value: any, isRetain: boolean): void; + /** + * @private + */ + protected abstract _disposeDisplay(value: any, isRelease: boolean): void; + /** + * @private + */ + protected abstract _onUpdateDisplay(): void; + /** + * @private + */ + protected abstract _addDisplay(): void; + /** + * @private + */ + protected abstract _replaceDisplay(value: any): void; + /** + * @private + */ + protected abstract _removeDisplay(): void; + /** + * @private + */ + protected abstract _updateZOrder(): void; + /** + * @private + */ + abstract _updateVisible(): void; + /** + * @private + */ + protected abstract _updateBlendMode(): void; + /** + * @private + */ + protected abstract _updateColor(): void; + /** + * @private + */ + protected abstract _updateFrame(): void; + /** + * @private + */ + protected abstract _updateMesh(): void; + /** + * @internal + * @private + */ + abstract _updateGlueMesh(): void; + /** + * @private + */ + protected abstract _updateTransform(): void; + /** + * @private + */ + protected abstract _identityTransform(): void; + /** + * @private + */ + protected _getDefaultRawDisplayData(): DisplayData | null; + /** + * @private + */ + protected _updateDisplayData(): void; + /** + * @private + */ + protected _updateDisplay(): void; + /** + * @private + */ + protected _updateGlobalTransformMatrix(isCache: boolean): void; + /** + * @private + */ + protected _isMeshBonesUpdate(): boolean; + /** + * @inheritDoc + */ + _setArmature(value: Armature | null): void; + /** + * @internal + * @private + */ + _setDisplayIndex(value: number, isAnimation?: boolean): boolean; + /** + * @internal + * @private + */ + _setZorder(value: number): boolean; + /** + * @internal + * @private + */ + _setColor(value: ColorTransform): boolean; + /** + * @internal + * @private + */ + _setDisplayList(value: Array | null): boolean; + /** + * @internal + * @private + */ + init(slotData: SlotData, displayDatas: Array | null, rawDisplay: any, meshDisplay: any): void; + /** + * @internal + * @private + */ + update(cacheFrameIndex: number): void; + /** + * @private + */ + updateTransformAndMatrix(): void; + /** + * @private + */ + replaceDisplayData(value: DisplayData | null, displayIndex?: number): void; + /** + * - Check whether a specific point is inside a custom bounding box in the slot. + * The coordinate system of the point is the inner coordinate system of the armature. + * Custom bounding boxes need to be customized in Dragonbones Pro. + * @param x - The horizontal coordinate of the point. + * @param y - The vertical coordinate of the point. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 检查特定点是否在插槽的自定义边界框内。 + * 点的坐标系为骨架内坐标系。 + * 自定义边界框需要在 DragonBones Pro 中自定义。 + * @param x - 点的水平坐标。 + * @param y - 点的垂直坐标。 + * @version DragonBones 5.0 + * @language zh_CN + */ + containsPoint(x: number, y: number): boolean; + /** + * - Check whether a specific segment intersects a custom bounding box for the slot. + * The coordinate system of the segment and intersection is the inner coordinate system of the armature. + * Custom bounding boxes need to be customized in Dragonbones Pro. + * @param xA - The horizontal coordinate of the beginning of the segment. + * @param yA - The vertical coordinate of the beginning of the segment. + * @param xB - The horizontal coordinate of the end point of the segment. + * @param yB - The vertical coordinate of the end point of the segment. + * @param intersectionPointA - The first intersection at which a line segment intersects the bounding box from the beginning to the end. (If not set, the intersection point will not calculated) + * @param intersectionPointB - The first intersection at which a line segment intersects the bounding box from the end to the beginning. (If not set, the intersection point will not calculated) + * @param normalRadians - The normal radians of the tangent of the intersection boundary box. [x: Normal radian of the first intersection tangent, y: Normal radian of the second intersection tangent] (If not set, the normal will not calculated) + * @returns Intersection situation. [1: Disjoint and segments within the bounding box, 0: Disjoint, 1: Intersecting and having a nodal point and ending in the bounding box, 2: Intersecting and having a nodal point and starting at the bounding box, 3: Intersecting and having two intersections, N: Intersecting and having N intersections] + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 检查特定线段是否与插槽的自定义边界框相交。 + * 线段和交点的坐标系均为骨架内坐标系。 + * 自定义边界框需要在 DragonBones Pro 中自定义。 + * @param xA - 线段起点的水平坐标。 + * @param yA - 线段起点的垂直坐标。 + * @param xB - 线段终点的水平坐标。 + * @param yB - 线段终点的垂直坐标。 + * @param intersectionPointA - 线段从起点到终点与边界框相交的第一个交点。 (如果未设置,则不计算交点) + * @param intersectionPointB - 线段从终点到起点与边界框相交的第一个交点。 (如果未设置,则不计算交点) + * @param normalRadians - 交点边界框切线的法线弧度。 [x: 第一个交点切线的法线弧度, y: 第二个交点切线的法线弧度] (如果未设置,则不计算法线) + * @returns 相交的情况。 [-1: 不相交且线段在包围盒内, 0: 不相交, 1: 相交且有一个交点且终点在包围盒内, 2: 相交且有一个交点且起点在包围盒内, 3: 相交且有两个交点, N: 相交且有 N 个交点] + * @version DragonBones 5.0 + * @language zh_CN + */ + intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): number; + /** + * - Forces the slot to update the state of the display object in the next frame. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 强制插槽在下一帧更新显示对象的状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + invalidUpdate(): void; + /** + * - The visible of slot's display object. + * @default true + * @version DragonBones 5.6 + * @language en_US + */ + /** + * - 插槽的显示对象的可见。 + * @default true + * @version DragonBones 5.6 + * @language zh_CN + */ + visible: boolean; + /** + * - The index of the display object displayed in the display list. + * @example + *
+         *     let slot = armature.getSlot("weapon");
+         *     slot.displayIndex = 3;
+         *     slot.displayController = "none";
+         * 
+ * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 此时显示的显示对象在显示列表中的索引。 + * @example + *
+         *     let slot = armature.getSlot("weapon");
+         *     slot.displayIndex = 3;
+         *     slot.displayController = "none";
+         * 
+ * @version DragonBones 4.5 + * @language zh_CN + */ + displayIndex: number; + /** + * - The slot name. + * @see dragonBones.SlotData#name + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 插槽名称。 + * @see dragonBones.SlotData#name + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly name: string; + /** + * - Contains a display list of display objects or child armatures. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 包含显示对象或子骨架的显示列表。 + * @version DragonBones 3.0 + * @language zh_CN + */ + displayList: Array; + /** + * - The slot data. + * @see dragonBones.SlotData + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 插槽数据。 + * @see dragonBones.SlotData + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly slotData: SlotData; + /** + * @private + */ + rawDisplayDatas: Array | null; + /** + * - The custom bounding box data for the slot at current time. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 插槽此时的自定义包围盒数据。 + * @version DragonBones 5.0 + * @language zh_CN + */ + readonly boundingBoxData: BoundingBoxData | null; + /** + * @private + */ + readonly rawDisplay: any; + /** + * @private + */ + readonly meshDisplay: any; + /** + * - The display object that the slot displays at this time. + * @example + *
+         *     let slot = armature.getSlot("text");
+         *     slot.display = new yourEngine.TextField();
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 插槽此时显示的显示对象。 + * @example + *
+         *     let slot = armature.getSlot("text");
+         *     slot.display = new yourEngine.TextField();
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + display: any; + /** + * - The child armature that the slot displayed at current time. + * @example + *
+         *     let slot = armature.getSlot("weapon");
+         *     slot.childArmature = factory.buildArmature("weapon_blabla", "weapon_blabla_project");
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 插槽此时显示的子骨架。 + * @example + *
+         *     let slot = armature.getSlot("weapon");
+         *     slot.childArmature = factory.buildArmature("weapon_blabla", "weapon_blabla_project");
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + childArmature: Armature | null; + /** + * - Deprecated, please refer to {@link #display}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #display}。 + * @deprecated + * @language zh_CN + */ + getDisplay(): any; + /** + * - Deprecated, please refer to {@link #display}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #display}。 + * @deprecated + * @language zh_CN + */ + setDisplay(value: any): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + abstract class Constraint extends BaseObject { + protected static readonly _helpMatrix: Matrix; + protected static readonly _helpTransform: Transform; + protected static readonly _helpPoint: Point; + /** + * - For timeline state. + * @internal + */ + _constraintData: ConstraintData; + protected _armature: Armature; + /** + * - For sort bones. + * @internal + */ + _target: Bone; + /** + * - For sort bones. + * @internal + */ + _root: Bone; + protected _bone: Bone | null; + protected _onClear(): void; + abstract init(constraintData: ConstraintData, armature: Armature): void; + abstract update(): void; + abstract invalidUpdate(): void; + readonly name: string; + } + /** + * @internal + * @private + */ + class IKConstraint extends Constraint { + static toString(): string; + private _scaleEnabled; + /** + * - For timeline state. + * @internal + */ + _bendPositive: boolean; + /** + * - For timeline state. + * @internal + */ + _weight: number; + protected _onClear(): void; + private _computeA(); + private _computeB(); + init(constraintData: ConstraintData, armature: Armature): void; + update(): void; + invalidUpdate(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - Play animation interface. (Both Armature and Wordclock implement the interface) + * Any instance that implements the interface can be added to the Worldclock instance and advance time by Worldclock instance uniformly. + * @see dragonBones.WorldClock + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 播放动画接口。 (Armature 和 WordClock 都实现了该接口) + * 任何实现了此接口的实例都可以添加到 WorldClock 实例中,由 WorldClock 实例统一更新时间。 + * @see dragonBones.WorldClock + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + interface IAnimatable { + /** + * - Advance time. + * @param passedTime - Passed time. (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 更新时间。 + * @param passedTime - 前进的时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + advanceTime(passedTime: number): void; + /** + * - The Wordclock instance to which the current belongs. + * @example + *
+         *     armature.clock = factory.clock; // Add armature to clock.
+         *     armature.clock = null; // Remove armature from clock.
+         * 
+ * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 当前所属的 WordClock 实例。 + * @example + *
+         *     armature.clock = factory.clock; // 将骨架添加到时钟。
+         *     armature.clock = null; // 将骨架从时钟移除。
+         * 
+ * @version DragonBones 5.0 + * @language zh_CN + */ + clock: WorldClock | null; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - Worldclock provides clock support for animations, advance time for each IAnimatable object added to the instance. + * @see dragonBones.IAnimateble + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - WorldClock 对动画提供时钟支持,为每个加入到该实例的 IAnimatable 对象更新时间。 + * @see dragonBones.IAnimateble + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + class WorldClock implements IAnimatable { + /** + * - Current time. (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 当前的时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + time: number; + /** + * - The play speed, used to control animation speed-shift play. + * [0: Stop play, (0~1): Slow play, 1: Normal play, (1~N): Fast play] + * @default 1.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 播放速度,用于控制动画变速播放。 + * [0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + timeScale: number; + private readonly _animatebles; + private _clock; + /** + * - Creating a Worldclock instance. Typically, you do not need to create Worldclock instance. + * When multiple Worldclock instances are running at different speeds, can achieving some specific animation effects, such as bullet time. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 创建一个 WorldClock 实例。通常并不需要创建 WorldClock 实例。 + * 当多个 WorldClock 实例使用不同的速度运行时,可以实现一些特殊的动画效果,比如子弹时间等。 + * @version DragonBones 3.0 + * @language zh_CN + */ + constructor(time?: number); + /** + * - Advance time for all IAnimatable instances. + * @param passedTime - Passed time. [-1: Automatically calculates the time difference between the current frame and the previous frame, [0~N): Passed time] (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 为所有的 IAnimatable 实例更新时间。 + * @param passedTime - 前进的时间。 [-1: 自动计算当前帧与上一帧的时间差, [0~N): 前进的时间] (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + advanceTime(passedTime: number): void; + /** + * - Check whether contains a specific instance of IAnimatable. + * @param value - The IAnimatable instance. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 检查是否包含特定的 IAnimatable 实例。 + * @param value - IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + contains(value: IAnimatable): boolean; + /** + * - Add IAnimatable instance. + * @param value - The IAnimatable instance. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 添加 IAnimatable 实例。 + * @param value - IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + add(value: IAnimatable): void; + /** + * - Removes a specified IAnimatable instance. + * @param value - The IAnimatable instance. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 移除特定的 IAnimatable 实例。 + * @param value - IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + remove(value: IAnimatable): void; + /** + * - Clear all IAnimatable instances. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 清除所有的 IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + clear(): void; + /** + * @inheritDoc + */ + clock: WorldClock | null; + /** + * - Deprecated, please refer to {@link dragonBones.BaseFactory#clock}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link dragonBones.BaseFactory#clock}。 + * @deprecated + * @language zh_CN + */ + static readonly clock: WorldClock; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The animation player is used to play the animation data and manage the animation states. + * @see dragonBones.AnimationData + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画播放器用来播放动画数据和管理动画状态。 + * @see dragonBones.AnimationData + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + class Animation extends BaseObject { + static toString(): string; + /** + * - The play speed of all animations. [0: Stop, (0~1): Slow, 1: Normal, (1~N): Fast] + * @default 1.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 所有动画的播放速度。 [0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + timeScale: number; + private _lockUpdate; + private _animationDirty; + private _inheritTimeScale; + private readonly _animationNames; + private readonly _animationStates; + private readonly _animations; + private _armature; + private _animationConfig; + private _lastAnimationState; + /** + * @private + */ + protected _onClear(): void; + private _fadeOut(animationConfig); + /** + * @internal + * @private + */ + init(armature: Armature): void; + /** + * @internal + * @private + */ + advanceTime(passedTime: number): void; + /** + * - Clear all animations states. + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 清除所有的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + reset(): void; + /** + * - Pause a specific animation state. + * @param animationName - The name of animation state. (If not set, it will pause all animations) + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 暂停指定动画状态的播放。 + * @param animationName - 动画状态名称。 (如果未设置,则暂停所有动画) + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + stop(animationName?: string | null): void; + /** + * - Play animation with a specific animation config. + * The API is still in the experimental phase and may encounter bugs or stability or compatibility issues when used. + * @param animationConfig - The animation config. + * @returns The playing animation state. + * @see dragonBones.AnimationConfig + * @beta + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 通过指定的动画配置来播放动画。 + * 该 API 仍在实验阶段,使用时可能遭遇 bug 或稳定性或兼容性问题。 + * @param animationConfig - 动画配置。 + * @returns 播放的动画状态。 + * @see dragonBones.AnimationConfig + * @beta + * @version DragonBones 5.0 + * @language zh_CN + */ + playConfig(animationConfig: AnimationConfig): AnimationState | null; + /** + * - Play a specific animation. + * @param animationName - The name of animation data. (If not set, The default animation will be played, or resume the animation playing from pause status, or replay the last playing animation) + * @param playTimes - Playing repeat times. [-1: Use default value of the animation data, 0: No end loop playing, [1~N]: Repeat N times] (default: -1) + * @returns The playing animation state. + * @example + *
+         *     armature.animation.play("walk");
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 播放指定动画。 + * @param animationName - 动画数据名称。 (如果未设置,则播放默认动画,或将暂停状态切换为播放状态,或重新播放之前播放的动画) + * @param playTimes - 循环播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) + * @returns 播放的动画状态。 + * @example + *
+         *     armature.animation.play("walk");
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + play(animationName?: string | null, playTimes?: number): AnimationState | null; + /** + * - Fade in a specific animation. + * @param animationName - The name of animation data. + * @param fadeInTime - The fade in time. [-1: Use the default value of animation data, [0~N]: The fade in time (In seconds)] (Default: -1) + * @param playTimes - playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) + * @param layer - The blending layer, the animation states in high level layer will get the blending weights with high priority, when the total blending weights are more than 1.0, there will be no more weights can be allocated to the other animation states. (Default: 0) + * @param group - The blending group name, it is typically used to specify the substitution of multiple animation states blending. (Default: null) + * @param fadeOutMode - The fade out mode, which is typically used to specify alternate mode of multiple animation states blending. (Default: AnimationFadeOutMode.SameLayerAndGroup) + * @returns The playing animation state. + * @example + *
+         *     armature.animation.fadeIn("walk", 0.3, 0, 0, "normalGroup").resetToPose = false;
+         *     armature.animation.fadeIn("attack", 0.3, 1, 0, "attackGroup").resetToPose = false;
+         * 
+ * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 淡入播放指定的动画。 + * @param animationName - 动画数据名称。 + * @param fadeInTime - 淡入时间。 [-1: 使用动画数据默认值, [0~N]: 淡入时间 (以秒为单位)] (默认: -1) + * @param playTimes - 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) + * @param layer - 混合图层,图层高的动画状态会优先获取混合权重,当混合权重分配总和超过 1.0 时,剩余的动画状态将不能再获得权重分配。 (默认: 0) + * @param group - 混合组名称,该属性通常用来指定多个动画状态混合时的相互替换关系。 (默认: null) + * @param fadeOutMode - 淡出模式,该属性通常用来指定多个动画状态混合时的相互替换模式。 (默认: AnimationFadeOutMode.SameLayerAndGroup) + * @returns 播放的动画状态。 + * @example + *
+         *     armature.animation.fadeIn("walk", 0.3, 0, 0, "normalGroup").resetToPose = false;
+         *     armature.animation.fadeIn("attack", 0.3, 1, 0, "attackGroup").resetToPose = false;
+         * 
+ * @version DragonBones 4.5 + * @language zh_CN + */ + fadeIn(animationName: string, fadeInTime?: number, playTimes?: number, layer?: number, group?: string | null, fadeOutMode?: AnimationFadeOutMode): AnimationState | null; + /** + * - Play a specific animation from the specific time. + * @param animationName - The name of animation data. + * @param time - The start time point of playing. (In seconds) + * @param playTimes - Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) + * @returns The played animation state. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 从指定时间开始播放指定的动画。 + * @param animationName - 动画数据名称。 + * @param time - 播放开始的时间。 (以秒为单位) + * @param playTimes - 循环播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) + * @returns 播放的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndPlayByTime(animationName: string, time?: number, playTimes?: number): AnimationState | null; + /** + * - Play a specific animation from the specific frame. + * @param animationName - The name of animation data. + * @param frame - The start frame of playing. + * @param playTimes - Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) + * @returns The played animation state. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 从指定帧开始播放指定的动画。 + * @param animationName - 动画数据名称。 + * @param frame - 播放开始的帧数。 + * @param playTimes - 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) + * @returns 播放的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndPlayByFrame(animationName: string, frame?: number, playTimes?: number): AnimationState | null; + /** + * - Play a specific animation from the specific progress. + * @param animationName - The name of animation data. + * @param progress - The start progress value of playing. + * @param playTimes - Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) + * @returns The played animation state. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 从指定进度开始播放指定的动画。 + * @param animationName - 动画数据名称。 + * @param progress - 开始播放的进度。 + * @param playTimes - 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) + * @returns 播放的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndPlayByProgress(animationName: string, progress?: number, playTimes?: number): AnimationState | null; + /** + * - Stop a specific animation at the specific time. + * @param animationName - The name of animation data. + * @param time - The stop time. (In seconds) + * @returns The played animation state. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 在指定时间停止指定动画播放 + * @param animationName - 动画数据名称。 + * @param time - 停止的时间。 (以秒为单位) + * @returns 播放的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndStopByTime(animationName: string, time?: number): AnimationState | null; + /** + * - Stop a specific animation at the specific frame. + * @param animationName - The name of animation data. + * @param frame - The stop frame. + * @returns The played animation state. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 在指定帧停止指定动画的播放 + * @param animationName - 动画数据名称。 + * @param frame - 停止的帧数。 + * @returns 播放的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndStopByFrame(animationName: string, frame?: number): AnimationState | null; + /** + * - Stop a specific animation at the specific progress. + * @param animationName - The name of animation data. + * @param progress - The stop progress value. + * @returns The played animation state. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 在指定的进度停止指定的动画播放。 + * @param animationName - 动画数据名称。 + * @param progress - 停止进度。 + * @returns 播放的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndStopByProgress(animationName: string, progress?: number): AnimationState | null; + /** + * - Get a specific animation state. + * @param animationName - The name of animation state. + * @example + *
+         *     armature.animation.play("walk");
+         *     let walkState = armature.animation.getState("walk");
+         *     walkState.timeScale = 0.5;
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取指定的动画状态 + * @param animationName - 动画状态名称。 + * @example + *
+         *     armature.animation.play("walk");
+         *     let walkState = armature.animation.getState("walk");
+         *     walkState.timeScale = 0.5;
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + getState(animationName: string): AnimationState | null; + /** + * - Check whether a specific animation data is included. + * @param animationName - The name of animation data. + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 检查是否包含指定的动画数据 + * @param animationName - 动画数据名称。 + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language zh_CN + */ + hasAnimation(animationName: string): boolean; + /** + * - Get all the animation states. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 获取所有的动画状态 + * @version DragonBones 5.1 + * @language zh_CN + */ + getStates(): Array; + /** + * - Check whether there is an animation state is playing + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 检查是否有动画状态正在播放 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly isPlaying: boolean; + /** + * - Check whether all the animation states' playing were finished. + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 检查是否所有的动画状态均已播放完毕。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly isCompleted: boolean; + /** + * - The name of the last playing animation state. + * @see #lastAnimationState + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 上一个播放的动画状态名称 + * @see #lastAnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly lastAnimationName: string; + /** + * - The name of all animation data + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 所有动画数据的名称 + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly animationNames: Array; + /** + * - All animation data. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 所有的动画数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + animations: Map; + /** + * - An AnimationConfig instance that can be used quickly. + * @see dragonBones.AnimationConfig + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 一个可以快速使用的动画配置实例。 + * @see dragonBones.AnimationConfig + * @version DragonBones 5.0 + * @language zh_CN + */ + readonly animationConfig: AnimationConfig; + /** + * - The last playing animation state + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 上一个播放的动画状态 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly lastAnimationState: AnimationState | null; + /** + * - Deprecated, please refer to {@link #play()} {@link #fadeIn()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #play()} {@link #fadeIn()}。 + * @deprecated + * @language zh_CN + */ + gotoAndPlay(animationName: string, fadeInTime?: number, duration?: number, playTimes?: number, layer?: number, group?: string | null, fadeOutMode?: AnimationFadeOutMode, pauseFadeOut?: boolean, pauseFadeIn?: boolean): AnimationState | null; + /** + * - Deprecated, please refer to {@link #gotoAndStopByTime()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #gotoAndStopByTime()}。 + * @deprecated + * @language zh_CN + */ + gotoAndStop(animationName: string, time?: number): AnimationState | null; + /** + * - Deprecated, please refer to {@link #animationNames}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #animationNames}。 + * @deprecated + * @language zh_CN + */ + readonly animationList: Array; + /** + * - Deprecated, please refer to {@link #animationNames}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #animationNames}。 + * @deprecated + * @language zh_CN + */ + readonly animationDataList: Array; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The animation state is generated when the animation data is played. + * @see dragonBones.Animation + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画状态由播放动画数据时产生。 + * @see dragonBones.Animation + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language zh_CN + */ + class AnimationState extends BaseObject { + static toString(): string; + /** + * @private + */ + actionEnabled: boolean; + /** + * @private + */ + additiveBlending: boolean; + /** + * - Whether the animation state has control over the display object properties of the slots. + * Sometimes blend a animation state does not want it to control the display object properties of the slots, + * especially if other animation state are controlling the display object properties of the slots. + * @default true + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画状态是否对插槽的显示对象属性有控制权。 + * 有时混合一个动画状态并不希望其控制插槽的显示对象属性, + * 尤其是其他动画状态正在控制这些插槽的显示对象属性时。 + * @default true + * @version DragonBones 5.0 + * @language zh_CN + */ + displayControl: boolean; + /** + * - Whether to reset the objects without animation to the armature pose when the animation state is start to play. + * This property should usually be set to false when blend multiple animation states. + * @default true + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 开始播放动画状态时是否将没有动画的对象重置为骨架初始值。 + * 通常在混合多个动画状态时应该将该属性设置为 false。 + * @default true + * @version DragonBones 5.1 + * @language zh_CN + */ + resetToPose: boolean; + /** + * - The play times. [0: Loop play, [1~N]: Play N times] + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 播放次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次] + * @version DragonBones 3.0 + * @language zh_CN + */ + playTimes: number; + /** + * - The blend layer. + * High layer animation state will get the blend weight first. + * When the blend weight is assigned more than 1, the remaining animation states will no longer get the weight assigned. + * @readonly + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 混合图层。 + * 图层高的动画状态会优先获取混合权重。 + * 当混合权重分配超过 1 时,剩余的动画状态将不再获得权重分配。 + * @readonly + * @version DragonBones 5.0 + * @language zh_CN + */ + layer: number; + /** + * - The play speed. + * The value is an overlay relationship with {@link dragonBones.Animation#timeScale}. + * [(-N~0): Reverse play, 0: Stop play, (0~1): Slow play, 1: Normal play, (1~N): Fast play] + * @default 1.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 播放速度。 + * 该值与 {@link dragonBones.Animation#timeScale} 是叠加关系。 + * [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + timeScale: number; + /** + * - The blend weight. + * @default 1.0 + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 混合权重。 + * @default 1.0 + * @version DragonBones 5.0 + * @language zh_CN + */ + weight: number; + /** + * - The auto fade out time when the animation state play completed. + * [-1: Do not fade out automatically, [0~N]: The fade out time] (In seconds) + * @default -1.0 + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画状态播放完成后的自动淡出时间。 + * [-1: 不自动淡出, [0~N]: 淡出时间] (以秒为单位) + * @default -1.0 + * @version DragonBones 5.0 + * @language zh_CN + */ + autoFadeOutTime: number; + /** + * @private + */ + fadeTotalTime: number; + /** + * - The name of the animation state. (Can be different from the name of the animation data) + * @readonly + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画状态名称。 (可以不同于动画数据) + * @readonly + * @version DragonBones 5.0 + * @language zh_CN + */ + name: string; + /** + * - The blend group name of the animation state. + * This property is typically used to specify the substitution of multiple animation states blend. + * @readonly + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 混合组名称。 + * 该属性通常用来指定多个动画状态混合时的相互替换关系。 + * @readonly + * @version DragonBones 5.0 + * @language zh_CN + */ + group: string; + private _timelineDirty; + /** + * - xx: Play Enabled, Fade Play Enabled + * @internal + * @private + */ + _playheadState: number; + /** + * -1: Fade in, 0: Fade complete, 1: Fade out; + * @internal + * @private + */ + _fadeState: number; + /** + * -1: Fade start, 0: Fading, 1: Fade complete; + * @internal + * @private + */ + _subFadeState: number; + /** + * @internal + * @private + */ + _position: number; + /** + * @internal + * @private + */ + _duration: number; + private _fadeTime; + private _time; + /** + * @internal + * @private + */ + _fadeProgress: number; + /** + * @internal + * @private + */ + _weightResult: number; + /** + * @internal + * @private + */ + readonly _blendState: BlendState; + private readonly _boneMask; + private readonly _boneTimelines; + private readonly _surfaceTimelines; + private readonly _slotTimelines; + private readonly _constraintTimelines; + private readonly _animationTimelines; + private readonly _poseTimelines; + private readonly _bonePoses; + /** + * @internal + * @private + */ + _animationData: AnimationData; + private _armature; + /** + * @internal + * @private + */ + _actionTimeline: ActionTimelineState; + private _zOrderTimeline; + /** + * @internal + * @private + */ + _parent: AnimationState; + /** + * @private + */ + protected _onClear(): void; + private _updateTimelines(); + private _updateBoneAndSlotTimelines(); + private _advanceFadeTime(passedTime); + /** + * @internal + * @private + */ + init(armature: Armature, animationData: AnimationData, animationConfig: AnimationConfig): void; + /** + * @internal + * @private + */ + advanceTime(passedTime: number, cacheFrameRate: number): void; + /** + * - Continue play. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 继续播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + play(): void; + /** + * - Stop play. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 暂停播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + stop(): void; + /** + * - Fade out the animation state. + * @param fadeOutTime - The fade out time. (In seconds) + * @param pausePlayhead - Whether to pause the animation playing when fade out. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 淡出动画状态。 + * @param fadeOutTime - 淡出时间。 (以秒为单位) + * @param pausePlayhead - 淡出时是否暂停播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + fadeOut(fadeOutTime: number, pausePlayhead?: boolean): void; + /** + * - Check if a specific bone mask is included. + * @param name - The bone name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 检查是否包含特定骨骼遮罩。 + * @param name - 骨骼名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + containsBoneMask(name: string): boolean; + /** + * - Add a specific bone mask. + * @param name - The bone name. + * @param recursive - Whether or not to add a mask to the bone's sub-bone. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 添加特定的骨骼遮罩。 + * @param name - 骨骼名称。 + * @param recursive - 是否为该骨骼的子骨骼添加遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + addBoneMask(name: string, recursive?: boolean): void; + /** + * - Remove the mask of a specific bone. + * @param name - The bone name. + * @param recursive - Whether to remove the bone's sub-bone mask. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 删除特定骨骼的遮罩。 + * @param name - 骨骼名称。 + * @param recursive - 是否删除该骨骼的子骨骼遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + removeBoneMask(name: string, recursive?: boolean): void; + /** + * - Remove all bone masks. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 删除所有骨骼遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + removeAllBoneMask(): void; + /** + * - Whether the animation state is fading in. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 是否正在淡入。 + * @version DragonBones 5.1 + * @language zh_CN + */ + readonly isFadeIn: boolean; + /** + * - Whether the animation state is fading out. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 是否正在淡出。 + * @version DragonBones 5.1 + * @language zh_CN + */ + readonly isFadeOut: boolean; + /** + * - Whether the animation state is fade completed. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 是否淡入或淡出完毕。 + * @version DragonBones 5.1 + * @language zh_CN + */ + readonly isFadeComplete: boolean; + /** + * - Whether the animation state is playing. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 是否正在播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly isPlaying: boolean; + /** + * - Whether the animation state is play completed. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 是否播放完毕。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly isCompleted: boolean; + /** + * - The times has been played. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 已经循环播放的次数。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly currentPlayTimes: number; + /** + * - The total time. (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 总播放时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly totalTime: number; + /** + * - The time is currently playing. (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 当前播放的时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + currentTime: number; + /** + * - The animation data. + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画数据。 + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly animationData: AnimationData; + } + /** + * @internal + * @private + */ + class BonePose extends BaseObject { + static toString(): string; + readonly current: Transform; + readonly delta: Transform; + readonly result: Transform; + protected _onClear(): void; + } + /** + * @internal + * @private + */ + class BlendState { + dirty: boolean; + layer: number; + leftWeight: number; + layerWeight: number; + blendWeight: number; + update(weight: number, layer: number): number; + clear(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + const enum TweenState { + None = 0, + Once = 1, + Always = 2, + } + /** + * @internal + * @private + */ + abstract class TimelineState extends BaseObject { + playState: number; + currentPlayTimes: number; + currentTime: number; + protected _tweenState: TweenState; + protected _frameRate: number; + protected _frameValueOffset: number; + protected _frameCount: number; + protected _frameOffset: number; + protected _frameIndex: number; + protected _frameRateR: number; + protected _position: number; + protected _duration: number; + protected _timeScale: number; + protected _timeOffset: number; + protected _dragonBonesData: DragonBonesData; + protected _animationData: AnimationData; + protected _timelineData: TimelineData | null; + protected _armature: Armature; + protected _animationState: AnimationState; + protected _actionTimeline: TimelineState; + protected _frameArray: Array | Int16Array; + protected _frameIntArray: Array | Int16Array; + protected _frameFloatArray: Array | Int16Array; + protected _timelineArray: Array | Uint16Array; + protected _frameIndices: Array; + protected _onClear(): void; + protected abstract _onArriveAtFrame(): void; + protected abstract _onUpdateFrame(): void; + protected _setCurrentTime(passedTime: number): boolean; + init(armature: Armature, animationState: AnimationState, timelineData: TimelineData | null): void; + fadeOut(): void; + update(passedTime: number): void; + } + /** + * @internal + * @private + */ + abstract class TweenTimelineState extends TimelineState { + private static _getEasingValue(tweenType, progress, easing); + private static _getEasingCurveValue(progress, samples, count, offset); + protected _tweenType: TweenType; + protected _curveCount: number; + protected _framePosition: number; + protected _frameDurationR: number; + protected _tweenProgress: number; + protected _tweenEasing: number; + protected _onClear(): void; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + } + /** + * @internal + * @private + */ + abstract class BoneTimelineState extends TweenTimelineState { + bone: Bone; + bonePose: BonePose; + protected _onClear(): void; + blend(state: number): void; + } + /** + * @internal + * @private + */ + abstract class SlotTimelineState extends TweenTimelineState { + slot: Slot; + protected _onClear(): void; + } + /** + * @internal + * @private + */ + abstract class ConstraintTimelineState extends TweenTimelineState { + constraint: Constraint; + protected _onClear(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + class ActionTimelineState extends TimelineState { + static toString(): string; + private _onCrossFrame(frameIndex); + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + update(passedTime: number): void; + setCurrentTime(value: number): void; + } + /** + * @internal + * @private + */ + class ZOrderTimelineState extends TimelineState { + static toString(): string; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + } + /** + * @internal + * @private + */ + class BoneAllTimelineState extends BoneTimelineState { + static toString(): string; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + fadeOut(): void; + } + /** + * @internal + * @private + */ + class BoneTranslateTimelineState extends BoneTimelineState { + static toString(): string; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + } + /** + * @internal + * @private + */ + class BoneRotateTimelineState extends BoneTimelineState { + static toString(): string; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + fadeOut(): void; + } + /** + * @internal + * @private + */ + class BoneScaleTimelineState extends BoneTimelineState { + static toString(): string; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + } + /** + * @internal + * @private + */ + class SurfaceTimelineState extends TweenTimelineState { + static toString(): string; + surface: Surface; + private _frameFloatOffset; + private _valueCount; + private _deformCount; + private _valueOffset; + private readonly _current; + private readonly _delta; + private readonly _result; + protected _onClear(): void; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + init(armature: Armature, animationState: AnimationState, timelineData: TimelineData | null): void; + blend(state: number): void; + } + /** + * @internal + * @private + */ + class SlotDislayTimelineState extends SlotTimelineState { + static toString(): string; + protected _onArriveAtFrame(): void; + } + /** + * @internal + * @private + */ + class SlotColorTimelineState extends SlotTimelineState { + static toString(): string; + private _dirty; + private readonly _current; + private readonly _delta; + private readonly _result; + protected _onClear(): void; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + fadeOut(): void; + update(passedTime: number): void; + } + /** + * @internal + * @private + */ + class SlotFFDTimelineState extends SlotTimelineState { + static toString(): string; + meshOffset: number; + private _dirty; + private _frameFloatOffset; + private _valueCount; + private _deformCount; + private _valueOffset; + private readonly _current; + private readonly _delta; + private readonly _result; + protected _onClear(): void; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + init(armature: Armature, animationState: AnimationState, timelineData: TimelineData | null): void; + fadeOut(): void; + update(passedTime: number): void; + } + /** + * @internal + * @private + */ + class IKConstraintTimelineState extends ConstraintTimelineState { + static toString(): string; + private _current; + private _delta; + protected _onClear(): void; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + } + /** + * @internal + * @private + */ + class AnimationTimelineState extends TweenTimelineState { + static toString(): string; + animationState: AnimationState; + private readonly _floats; + protected _onClear(): void; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + blend(state: number): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The properties of the object carry basic information about an event, + * which are passed as parameter or parameter's parameter to event listeners when an event occurs. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 事件对象,包含有关事件的基本信息,当发生事件时,该实例将作为参数或参数的参数传递给事件侦听器。 + * @version DragonBones 4.5 + * @language zh_CN + */ + class EventObject extends BaseObject { + /** + * - Animation start play. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画开始播放。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly START: string; + /** + * - Animation loop play complete once. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画循环播放完成一次。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly LOOP_COMPLETE: string; + /** + * - Animation play complete. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画播放完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly COMPLETE: string; + /** + * - Animation fade in start. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画淡入开始。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly FADE_IN: string; + /** + * - Animation fade in complete. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画淡入完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly FADE_IN_COMPLETE: string; + /** + * - Animation fade out start. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画淡出开始。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly FADE_OUT: string; + /** + * - Animation fade out complete. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画淡出完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly FADE_OUT_COMPLETE: string; + /** + * - Animation frame event. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画帧事件。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly FRAME_EVENT: string; + /** + * - Animation frame sound event. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画帧声音事件。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly SOUND_EVENT: string; + static toString(): string; + /** + * - If is a frame event, the value is used to describe the time that the event was in the animation timeline. (In seconds) + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 如果是帧事件,此值用来描述该事件在动画时间轴中所处的时间。(以秒为单位) + * @version DragonBones 4.5 + * @language zh_CN + */ + time: number; + /** + * - The event type。 + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 事件类型。 + * @version DragonBones 4.5 + * @language zh_CN + */ + type: EventStringType; + /** + * - The event name. (The frame event name or the frame sound name) + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 事件名称。 (帧事件的名称或帧声音的名称) + * @version DragonBones 4.5 + * @language zh_CN + */ + name: string; + /** + * - The armature that dispatch the event. + * @see dragonBones.Armature + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 发出该事件的骨架。 + * @see dragonBones.Armature + * @version DragonBones 4.5 + * @language zh_CN + */ + armature: Armature; + /** + * - The bone that dispatch the event. + * @see dragonBones.Bone + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 发出该事件的骨骼。 + * @see dragonBones.Bone + * @version DragonBones 4.5 + * @language zh_CN + */ + bone: Bone | null; + /** + * - The slot that dispatch the event. + * @see dragonBones.Slot + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 发出该事件的插槽。 + * @see dragonBones.Slot + * @version DragonBones 4.5 + * @language zh_CN + */ + slot: Slot | null; + /** + * - The animation state that dispatch the event. + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 发出该事件的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + animationState: AnimationState; + /** + * - The custom data. + * @see dragonBones.CustomData + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 自定义数据。 + * @see dragonBones.CustomData + * @version DragonBones 5.0 + * @language zh_CN + */ + data: UserData | null; + /** + * @private + */ + protected _onClear(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @private + */ + type EventStringType = string | "start" | "loopComplete" | "complete" | "fadeIn" | "fadeInComplete" | "fadeOut" | "fadeOutComplete" | "frameEvent" | "soundEvent"; + /** + * - The event dispatcher interface. + * Dragonbones event dispatch usually relies on docking engine to implement, which defines the event method to be implemented when docking the engine. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 事件派发接口。 + * DragonBones 的事件派发通常依赖于对接的引擎来实现,该接口定义了对接引擎时需要实现的事件方法。 + * @version DragonBones 4.5 + * @language zh_CN + */ + interface IEventDispatcher { + /** + * - Checks whether the object has any listeners registered for a specific type of event。 + * @param type - Event type. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 检查是否为特定的事件类型注册了任何侦听器。 + * @param type - 事件类型。 + * @version DragonBones 4.5 + * @language zh_CN + */ + hasDBEventListener(type: EventStringType): boolean; + /** + * - Dispatches an event into the event flow. + * @param type - Event type. + * @param eventObject - Event object. + * @see dragonBones.EventObject + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 分派特定的事件到事件流中。 + * @param type - 事件类型。 + * @param eventObject - 事件数据。 + * @see dragonBones.EventObject + * @version DragonBones 4.5 + * @language zh_CN + */ + dispatchDBEvent(type: EventStringType, eventObject: EventObject): void; + /** + * - Add an event listener object so that the listener receives notification of an event. + * @param type - Event type. + * @param listener - Event listener. + * @param thisObject - The listener function's "this". + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 添加特定事件类型的事件侦听器,以使侦听器能够接收事件通知。 + * @param type - 事件类型。 + * @param listener - 事件侦听器。 + * @param thisObject - 侦听函数绑定的 this 对象。 + * @version DragonBones 4.5 + * @language zh_CN + */ + addDBEventListener(type: EventStringType, listener: Function, thisObject: any): void; + /** + * - Removes a listener from the object. + * @param type - Event type. + * @param listener - Event listener. + * @param thisObject - The listener function's "this". + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 删除特定事件类型的侦听器。 + * @param type - 事件类型。 + * @param listener - 事件侦听器。 + * @param thisObject - 侦听函数绑定的 this 对象。 + * @version DragonBones 4.5 + * @language zh_CN + */ + removeDBEventListener(type: EventStringType, listener: Function, thisObject: any): void; + /** + * - Deprecated, please refer to {@link #hasDBEventListener()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #hasDBEventListener()}。 + * @deprecated + * @language zh_CN + */ + hasEvent(type: EventStringType): boolean; + /** + * - Deprecated, please refer to {@link #addDBEventListener()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #addDBEventListener()}。 + * @deprecated + * @language zh_CN + */ + addEvent(type: EventStringType, listener: Function, thisObject: any): void; + /** + * - Deprecated, please refer to {@link #removeDBEventListener()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #removeDBEventListener()}。 + * @deprecated + * @language zh_CN + */ + removeEvent(type: EventStringType, listener: Function, thisObject: any): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + abstract class DataParser { + protected static readonly DATA_VERSION_2_3: string; + protected static readonly DATA_VERSION_3_0: string; + protected static readonly DATA_VERSION_4_0: string; + protected static readonly DATA_VERSION_4_5: string; + protected static readonly DATA_VERSION_5_0: string; + protected static readonly DATA_VERSION_5_5: string; + protected static readonly DATA_VERSION: string; + protected static readonly DATA_VERSIONS: Array; + protected static readonly TEXTURE_ATLAS: string; + protected static readonly SUB_TEXTURE: string; + protected static readonly FORMAT: string; + protected static readonly IMAGE_PATH: string; + protected static readonly WIDTH: string; + protected static readonly HEIGHT: string; + protected static readonly ROTATED: string; + protected static readonly FRAME_X: string; + protected static readonly FRAME_Y: string; + protected static readonly FRAME_WIDTH: string; + protected static readonly FRAME_HEIGHT: string; + protected static readonly DRADON_BONES: string; + protected static readonly USER_DATA: string; + protected static readonly ARMATURE: string; + protected static readonly BONE: string; + protected static readonly SURFACE: string; + protected static readonly SLOT: string; + protected static readonly CONSTRAINT: string; + protected static readonly IK: string; + protected static readonly SKIN: string; + protected static readonly DISPLAY: string; + protected static readonly ANIMATION: string; + protected static readonly Z_ORDER: string; + protected static readonly FFD: string; + protected static readonly FRAME: string; + protected static readonly TRANSLATE_FRAME: string; + protected static readonly ROTATE_FRAME: string; + protected static readonly SCALE_FRAME: string; + protected static readonly DISPLAY_FRAME: string; + protected static readonly COLOR_FRAME: string; + protected static readonly DEFAULT_ACTIONS: string; + protected static readonly ACTIONS: string; + protected static readonly EVENTS: string; + protected static readonly INTS: string; + protected static readonly FLOATS: string; + protected static readonly STRINGS: string; + protected static readonly CANVAS: string; + protected static readonly TRANSFORM: string; + protected static readonly PIVOT: string; + protected static readonly AABB: string; + protected static readonly COLOR: string; + protected static readonly VERSION: string; + protected static readonly COMPATIBLE_VERSION: string; + protected static readonly FRAME_RATE: string; + protected static readonly TYPE: string; + protected static readonly SUB_TYPE: string; + protected static readonly NAME: string; + protected static readonly PARENT: string; + protected static readonly TARGET: string; + protected static readonly STAGE: string; + protected static readonly SHARE: string; + protected static readonly PATH: string; + protected static readonly LENGTH: string; + protected static readonly DISPLAY_INDEX: string; + protected static readonly BLEND_MODE: string; + protected static readonly INHERIT_TRANSLATION: string; + protected static readonly INHERIT_ROTATION: string; + protected static readonly INHERIT_SCALE: string; + protected static readonly INHERIT_REFLECTION: string; + protected static readonly INHERIT_ANIMATION: string; + protected static readonly INHERIT_DEFORM: string; + protected static readonly SEGMENT_X: string; + protected static readonly SEGMENT_Y: string; + protected static readonly BEND_POSITIVE: string; + protected static readonly CHAIN: string; + protected static readonly WEIGHT: string; + protected static readonly FADE_IN_TIME: string; + protected static readonly PLAY_TIMES: string; + protected static readonly SCALE: string; + protected static readonly OFFSET: string; + protected static readonly POSITION: string; + protected static readonly DURATION: string; + protected static readonly TWEEN_EASING: string; + protected static readonly TWEEN_ROTATE: string; + protected static readonly TWEEN_SCALE: string; + protected static readonly CLOCK_WISE: string; + protected static readonly CURVE: string; + protected static readonly SOUND: string; + protected static readonly EVENT: string; + protected static readonly ACTION: string; + protected static readonly X: string; + protected static readonly Y: string; + protected static readonly SKEW_X: string; + protected static readonly SKEW_Y: string; + protected static readonly SCALE_X: string; + protected static readonly SCALE_Y: string; + protected static readonly VALUE: string; + protected static readonly ROTATE: string; + protected static readonly SKEW: string; + protected static readonly ALPHA_OFFSET: string; + protected static readonly RED_OFFSET: string; + protected static readonly GREEN_OFFSET: string; + protected static readonly BLUE_OFFSET: string; + protected static readonly ALPHA_MULTIPLIER: string; + protected static readonly RED_MULTIPLIER: string; + protected static readonly GREEN_MULTIPLIER: string; + protected static readonly BLUE_MULTIPLIER: string; + protected static readonly UVS: string; + protected static readonly VERTICES: string; + protected static readonly TRIANGLES: string; + protected static readonly WEIGHTS: string; + protected static readonly SLOT_POSE: string; + protected static readonly BONE_POSE: string; + protected static readonly GLUE_WEIGHTS: string; + protected static readonly GLUE_MESHES: string; + protected static readonly GOTO_AND_PLAY: string; + protected static readonly DEFAULT_NAME: string; + protected static _getArmatureType(value: string): ArmatureType; + protected static _getBoneType(value: string): BoneType; + protected static _getDisplayType(value: string): DisplayType; + protected static _getBoundingBoxType(value: string): BoundingBoxType; + protected static _getActionType(value: string): ActionType; + protected static _getBlendMode(value: string): BlendMode; + abstract parseDragonBonesData(rawData: any, scale: number): DragonBonesData | null; + abstract parseTextureAtlasData(rawData: any, textureAtlasData: TextureAtlasData, scale: number): boolean; + /** + * - Deprecated, please refer to {@link dragonBones.BaseFactory#parsetTextureAtlasData()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link dragonBones.BaseFactory#parsetTextureAtlasData()}。 + * @deprecated + * @language zh_CN + */ + static parseDragonBonesData(rawData: any): DragonBonesData | null; + /** + * - Deprecated, please refer to {@link dragonBones.BaseFactory#parsetTextureAtlasData()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link dragonBones.BaseFactory#parsetTextureAtlasData()}。 + * @deprecated + * @language zh_CN + */ + static parseTextureAtlasData(rawData: any, scale?: number): any; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + class ObjectDataParser extends DataParser { + protected static _getBoolean(rawData: any, key: string, defaultValue: boolean): boolean; + protected static _getNumber(rawData: any, key: string, defaultValue: number): number; + protected static _getString(rawData: any, key: string, defaultValue: string): string; + protected _rawTextureAtlasIndex: number; + protected readonly _rawBones: Array; + protected _data: DragonBonesData; + protected _armature: ArmatureData; + protected _bone: BoneData; + protected _surface: SurfaceData; + protected _slot: SlotData; + protected _skin: SkinData; + protected _mesh: MeshDisplayData; + protected _animation: AnimationData; + protected _timeline: TimelineData; + protected _rawTextureAtlases: Array | null; + private _defaultColorOffset; + private _prevClockwise; + private _prevRotation; + private readonly _helpMatrixA; + private readonly _helpMatrixB; + private readonly _helpTransform; + private readonly _helpColorTransform; + private readonly _helpPoint; + private readonly _helpArray; + private readonly _intArray; + private readonly _floatArray; + private readonly _frameIntArray; + private readonly _frameFloatArray; + private readonly _frameArray; + private readonly _timelineArray; + private readonly _cacheRawMeshes; + private readonly _cacheMeshes; + private readonly _actionFrames; + private readonly _weightSlotPose; + private readonly _weightBonePoses; + private readonly _cacheBones; + private readonly _slotChildActions; + private _getCurvePoint(x1, y1, x2, y2, x3, y3, x4, y4, t, result); + private _samplingEasingCurve(curve, samples); + private _parseActionDataInFrame(rawData, frameStart, bone, slot); + private _mergeActionFrame(rawData, frameStart, type, bone, slot); + protected _parseArmature(rawData: any, scale: number): ArmatureData; + protected _parseBone(rawData: any): BoneData; + protected _parseIKConstraint(rawData: any): ConstraintData | null; + protected _parseSlot(rawData: any, zOrder: number): SlotData; + protected _parseSkin(rawData: any): SkinData; + protected _parseDisplay(rawData: any): DisplayData | null; + protected _parsePivot(rawData: any, display: ImageDisplayData): void; + protected _parseMesh(rawData: any, mesh: MeshDisplayData): void; + protected _parseMeshGlue(rawData: any, mesh: MeshDisplayData): void; + protected _parseBoundingBox(rawData: any): BoundingBoxData | null; + protected _parsePolygonBoundingBox(rawData: any): PolygonBoundingBoxData; + protected _parseAnimation(rawData: any): AnimationData; + protected _parseTimeline(rawData: any, rawFrames: Array | null, framesKey: string, type: TimelineType, addIntOffset: boolean, addFloatOffset: boolean, frameValueCount: number, frameParser: (rawData: any, frameStart: number, frameCount: number) => number): TimelineData | null; + protected _parseBoneTimeline(rawData: any): void; + protected _parseSlotTimeline(rawData: any): void; + protected _parseFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseTweenFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseActionFrame(frame: ActionFrame, frameStart: number, frameCount: number): number; + protected _parseZOrderFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseBoneAllFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseBoneTranslateFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseBoneRotateFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseBoneScaleFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseSurfaceFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseSlotDisplayFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseSlotColorFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseSlotFFDFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseIKConstraintFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseAnimationFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseActionData(rawData: any, type: ActionType, bone: BoneData | null, slot: SlotData | null): Array; + protected _parseTransform(rawData: any, transform: Transform, scale: number): void; + protected _parseColorTransform(rawData: any, color: ColorTransform): void; + protected _parseArray(rawData: any): void; + protected _modifyArray(): void; + parseDragonBonesData(rawData: any, scale?: number): DragonBonesData | null; + parseTextureAtlasData(rawData: any, textureAtlasData: TextureAtlasData, scale?: number): boolean; + private static _objectDataParserInstance; + /** + * - Deprecated, please refer to {@link dragonBones.BaseFactory#parseDragonBonesData()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link dragonBones.BaseFactory#parseDragonBonesData()}。 + * @deprecated + * @language zh_CN + */ + static getInstance(): ObjectDataParser; + } + /** + * @internal + * @private + */ + class ActionFrame { + frameStart: number; + readonly actions: Array; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + class BinaryDataParser extends ObjectDataParser { + private _binaryOffset; + private _binary; + private _intArrayBuffer; + private _floatArrayBuffer; + private _frameIntArrayBuffer; + private _frameFloatArrayBuffer; + private _frameArrayBuffer; + private _timelineArrayBuffer; + private _inRange(a, min, max); + private _decodeUTF8(data); + private _getUTF16Key(value); + private _parseBinaryTimeline(type, offset, timelineData?); + protected _parseMesh(rawData: any, mesh: MeshDisplayData): void; + protected _parseAnimation(rawData: any): AnimationData; + protected _parseArray(rawData: any): void; + parseDragonBonesData(rawData: any, scale?: number): DragonBonesData | null; + private static _binaryDataParserInstance; + /** + * - Deprecated, please refer to {@link dragonBones.BaseFactory#parseDragonBonesData()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link dragonBones.BaseFactory#parseDragonBonesData()}。 + * @deprecated + * @language zh_CN + */ + static getInstance(): BinaryDataParser; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - Base class for the factory that create the armatures. (Typically only one global factory instance is required) + * The factory instance create armatures by parsed and added DragonBonesData instances and TextureAtlasData instances. + * Once the data has been parsed, it has been cached in the factory instance and does not need to be parsed again until it is cleared by the factory instance. + * @see dragonBones.DragonBonesData + * @see dragonBones.TextureAtlasData + * @see dragonBones.ArmatureData + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 创建骨架的工厂基类。 (通常只需要一个全局工厂实例) + * 工厂通过解析并添加的 DragonBonesData 实例和 TextureAtlasData 实例来创建骨架。 + * 当数据被解析过之后,已经添加到工厂中,在没有被工厂清理之前,不需要再次解析。 + * @see dragonBones.DragonBonesData + * @see dragonBones.TextureAtlasData + * @see dragonBones.ArmatureData + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + abstract class BaseFactory { + /** + * @private + */ + protected static _objectParser: ObjectDataParser; + /** + * @private + */ + protected static _binaryParser: BinaryDataParser; + /** + * @private + */ + autoSearch: boolean; + /** + * @private + */ + protected readonly _dragonBonesDataMap: Map; + /** + * @private + */ + protected readonly _textureAtlasDataMap: Map>; + /** + * @private + */ + protected _dragonBones: DragonBones; + /** + * @private + */ + protected _dataParser: DataParser; + /** + * - Create a factory instance. (typically only one global factory instance is required) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 创建一个工厂实例。 (通常只需要一个全局工厂实例) + * @version DragonBones 3.0 + * @language zh_CN + */ + constructor(dataParser?: DataParser | null); + /** + * @private + */ + protected _isSupportMesh(): boolean; + /** + * @private + */ + protected _getTextureData(textureAtlasName: string, textureName: string): TextureData | null; + /** + * @private + */ + protected _fillBuildArmaturePackage(dataPackage: BuildArmaturePackage, dragonBonesName: string, armatureName: string, skinName: string, textureAtlasName: string): boolean; + /** + * @private + */ + protected _buildBones(dataPackage: BuildArmaturePackage, armature: Armature): void; + /** + * @private + */ + protected _buildSlots(dataPackage: BuildArmaturePackage, armature: Armature): void; + /** + * @private + */ + protected _buildChildArmature(dataPackage: BuildArmaturePackage | null, slot: Slot, displayData: DisplayData): Armature | null; + /** + * @private + */ + protected _getSlotDisplay(dataPackage: BuildArmaturePackage | null, displayData: DisplayData, rawDisplayData: DisplayData | null, slot: Slot): any; + /** + * @private + */ + protected abstract _buildTextureAtlasData(textureAtlasData: TextureAtlasData | null, textureAtlas: any): TextureAtlasData; + /** + * @private + */ + protected abstract _buildArmature(dataPackage: BuildArmaturePackage): Armature; + /** + * @private + */ + protected abstract _buildSlot(dataPackage: BuildArmaturePackage, slotData: SlotData, displays: Array | null, armature: Armature): Slot; + /** + * - Parse the raw data to a DragonBonesData instance and cache it to the factory. + * @param rawData - The raw data. + * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (If not set, use the instance name instead) + * @param scale - Specify a scaling value for all armatures. (Default: 1.0) + * @returns DragonBonesData instance + * @see #getDragonBonesData() + * @see #addDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 将原始数据解析为 DragonBonesData 实例,并缓存到工厂中。 + * @param rawData - 原始数据。 + * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) + * @param scale - 为所有的骨架指定一个缩放值。 (默认: 1.0) + * @returns DragonBonesData 实例 + * @see #getDragonBonesData() + * @see #addDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 4.5 + * @language zh_CN + */ + parseDragonBonesData(rawData: any, name?: string | null, scale?: number): DragonBonesData | null; + /** + * - Parse the raw texture atlas data and the texture atlas object to a TextureAtlasData instance and cache it to the factory. + * @param rawData - The raw texture atlas data. + * @param textureAtlas - The texture atlas object. + * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (If not set, use the instance name instead) + * @param scale - Specify a scaling value for the map set. (Default: 1.0) + * @returns TextureAtlasData instance + * @see #getTextureAtlasData() + * @see #addTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 将原始贴图集数据和贴图集对象解析为 TextureAtlasData 实例,并缓存到工厂中。 + * @param rawData - 原始贴图集数据。 + * @param textureAtlas - 贴图集对象。 + * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) + * @param scale - 为贴图集指定一个缩放值。 (默认: 1.0) + * @returns TextureAtlasData 实例 + * @see #getTextureAtlasData() + * @see #addTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 4.5 + * @language zh_CN + */ + parseTextureAtlasData(rawData: any, textureAtlas: any, name?: string | null, scale?: number): TextureAtlasData; + /** + * @private + */ + updateTextureAtlasData(name: string, textureAtlases: Array): void; + /** + * - Get a specific DragonBonesData instance. + * @param name - The DragonBonesData instance cache name. + * @returns DragonBonesData instance + * @see #parseDragonBonesData() + * @see #addDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的 DragonBonesData 实例。 + * @param name - DragonBonesData 实例的缓存名称。 + * @returns DragonBonesData 实例 + * @see #parseDragonBonesData() + * @see #addDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language zh_CN + */ + getDragonBonesData(name: string): DragonBonesData | null; + /** + * - Cache a DragonBonesData instance to the factory. + * @param data - The DragonBonesData instance. + * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (if not set, use the instance name instead) + * @see #parseDragonBonesData() + * @see #getDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 将 DragonBonesData 实例缓存到工厂中。 + * @param data - DragonBonesData 实例。 + * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) + * @see #parseDragonBonesData() + * @see #getDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language zh_CN + */ + addDragonBonesData(data: DragonBonesData, name?: string | null): void; + /** + * - Remove a DragonBonesData instance. + * @param name - The DragonBonesData instance cache name. + * @param disposeData - Whether to dispose data. (Default: true) + * @see #parseDragonBonesData() + * @see #getDragonBonesData() + * @see #addDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 移除 DragonBonesData 实例。 + * @param name - DragonBonesData 实例缓存名称。 + * @param disposeData - 是否释放数据。 (默认: true) + * @see #parseDragonBonesData() + * @see #getDragonBonesData() + * @see #addDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language zh_CN + */ + removeDragonBonesData(name: string, disposeData?: boolean): void; + /** + * - Get a list of specific TextureAtlasData instances. + * @param name - The TextureAtlasData cahce name. + * @see #parseTextureAtlasData() + * @see #addTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的 TextureAtlasData 实例列表。 + * @param name - TextureAtlasData 实例缓存名称。 + * @see #parseTextureAtlasData() + * @see #addTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language zh_CN + */ + getTextureAtlasData(name: string): Array | null; + /** + * - Cache a TextureAtlasData instance to the factory. + * @param data - The TextureAtlasData instance. + * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (if not set, use the instance name instead) + * @see #parseTextureAtlasData() + * @see #getTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 将 TextureAtlasData 实例缓存到工厂中。 + * @param data - TextureAtlasData 实例。 + * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) + * @see #parseTextureAtlasData() + * @see #getTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language zh_CN + */ + addTextureAtlasData(data: TextureAtlasData, name?: string | null): void; + /** + * - Remove a TextureAtlasData instance. + * @param name - The TextureAtlasData instance cache name. + * @param disposeData - Whether to dispose data. + * @see #parseTextureAtlasData() + * @see #getTextureAtlasData() + * @see #addTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 移除 TextureAtlasData 实例。 + * @param name - TextureAtlasData 实例的缓存名称。 + * @param disposeData - 是否释放数据。 + * @see #parseTextureAtlasData() + * @see #getTextureAtlasData() + * @see #addTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language zh_CN + */ + removeTextureAtlasData(name: string, disposeData?: boolean): void; + /** + * - Get a specific armature data. + * @param name - The armature data name. + * @param dragonBonesName - The cached name for DragonbonesData instance. + * @see dragonBones.ArmatureData + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 获取特定的骨架数据。 + * @param name - 骨架数据名称。 + * @param dragonBonesName - DragonBonesData 实例的缓存名称。 + * @see dragonBones.ArmatureData + * @version DragonBones 5.1 + * @language zh_CN + */ + getArmatureData(name: string, dragonBonesName?: string): ArmatureData | null; + /** + * - Clear all cached DragonBonesData instances and TextureAtlasData instances. + * @param disposeData - Whether to dispose data. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 清除缓存的所有 DragonBonesData 实例和 TextureAtlasData 实例。 + * @param disposeData - 是否释放数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + clear(disposeData?: boolean): void; + /** + * - Create a armature from cached DragonBonesData instances and TextureAtlasData instances. + * @param armatureName - The armature data name. + * @param dragonBonesName - The cached name of the DragonBonesData instance. (If not set, all DragonBonesData instances are retrieved, and when multiple DragonBonesData instances contain a the same name armature data, it may not be possible to accurately create a specific armature) + * @param skinName - The skin name, you can set a different ArmatureData name to share it's skin data. (If not set, use the default skin data) + * @returns The armature. + * @example + *
+         *     let armature = factory.buildArmature("armatureName", "dragonBonesName");
+         *     armature.clock = factory.clock;
+         * 
+ * @see dragonBones.DragonBonesData + * @see dragonBones.ArmatureData + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 通过缓存的 DragonBonesData 实例和 TextureAtlasData 实例创建一个骨架。 + * @param armatureName - 骨架数据名称。 + * @param dragonBonesName - DragonBonesData 实例的缓存名称。 (如果未设置,将检索所有的 DragonBonesData 实例,当多个 DragonBonesData 实例中包含同名的骨架数据时,可能无法准确的创建出特定的骨架) + * @param skinName - 皮肤名称,可以设置一个其他骨架数据名称来共享其皮肤数据(如果未设置,则使用默认的皮肤数据)。 + * @returns 骨架。 + * @example + *
+         *     let armature = factory.buildArmature("armatureName", "dragonBonesName");
+         *     armature.clock = factory.clock;
+         * 
+ * @see dragonBones.DragonBonesData + * @see dragonBones.ArmatureData + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + buildArmature(armatureName: string, dragonBonesName?: string, skinName?: string, textureAtlasName?: string): Armature | null; + /** + * @private + */ + replaceDisplay(slot: Slot, displayData: DisplayData, displayIndex?: number): void; + /** + * - Replaces the current display data for a particular slot with a specific display data. + * Specify display data with "dragonBonesName/armatureName/slotName/displayName". + * @param dragonBonesName - The DragonBonesData instance cache name. + * @param armatureName - The armature data name. + * @param slotName - The slot data name. + * @param displayName - The display data name. + * @param slot - The slot. + * @param displayIndex - The index of the display data that is replaced. (If it is not set, replaces the current display data) + * @example + *
+         *     let slot = armature.getSlot("weapon");
+         *     factory.replaceSlotDisplay("dragonBonesName", "armatureName", "slotName", "displayName", slot);
+         * 
+ * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 用特定的显示对象数据替换特定插槽当前的显示对象数据。 + * 用 "dragonBonesName/armatureName/slotName/displayName" 指定显示对象数据。 + * @param dragonBonesName - DragonBonesData 实例的缓存名称。 + * @param armatureName - 骨架数据名称。 + * @param slotName - 插槽数据名称。 + * @param displayName - 显示对象数据名称。 + * @param slot - 插槽。 + * @param displayIndex - 被替换的显示对象数据的索引。 (如果未设置,则替换当前的显示对象数据) + * @example + *
+         *     let slot = armature.getSlot("weapon");
+         *     factory.replaceSlotDisplay("dragonBonesName", "armatureName", "slotName", "displayName", slot);
+         * 
+ * @version DragonBones 4.5 + * @language zh_CN + */ + replaceSlotDisplay(dragonBonesName: string, armatureName: string, slotName: string, displayName: string, slot: Slot, displayIndex?: number): boolean; + /** + * @private + */ + replaceSlotDisplayList(dragonBonesName: string | null, armatureName: string, slotName: string, slot: Slot): boolean; + /** + * - Share specific skin data with specific armature. + * @param armature - The armature. + * @param skin - The skin data. + * @param isOverride - Whether it completely override the original skin. (Default: false) + * @param exclude - A list of slot names that do not need to be replace. + * @example + *
+         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
+         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
+         *     if (armatureDataB && armatureDataB.defaultSkin) {
+         *     factory.replaceSkin(armatureA, armatureDataB.defaultSkin, false, ["arm_l", "weapon_l"]);
+         *     }
+         * 
+ * @see dragonBones.Armature + * @see dragonBones.SkinData + * @version DragonBones 5.6 + * @language en_US + */ + /** + * - 将特定的皮肤数据共享给特定的骨架使用。 + * @param armature - 骨架。 + * @param skin - 皮肤数据。 + * @param isOverride - 是否完全覆盖原来的皮肤。 (默认: false) + * @param exclude - 不需要被替换的插槽名称列表。 + * @example + *
+         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
+         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
+         *     if (armatureDataB && armatureDataB.defaultSkin) {
+         *     factory.replaceSkin(armatureA, armatureDataB.defaultSkin, false, ["arm_l", "weapon_l"]);
+         *     }
+         * 
+ * @see dragonBones.Armature + * @see dragonBones.SkinData + * @version DragonBones 5.6 + * @language zh_CN + */ + replaceSkin(armature: Armature, skin: SkinData, isOverride?: boolean, exclude?: Array | null): boolean; + /** + * - Replaces the existing animation data for a specific armature with the animation data for the specific armature data. + * This enables you to make a armature template so that other armature without animations can share it's animations. + * @param armature - The armtaure. + * @param armatureData - The armature data. + * @param isOverride - Whether to completely overwrite the original animation. (Default: false) + * @example + *
+         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
+         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
+         *     if (armatureDataB) {
+         *     factory.replaceAnimation(armatureA, armatureDataB);
+         *     }
+         * 
+ * @see dragonBones.Armature + * @see dragonBones.ArmatureData + * @version DragonBones 5.6 + * @language en_US + */ + /** + * - 用特定骨架数据的动画数据替换特定骨架现有的动画数据。 + * 这样就能实现制作一个骨架动画模板,让其他没有制作动画的骨架共享该动画。 + * @param armature - 骨架。 + * @param armatureData - 骨架数据。 + * @param isOverride - 是否完全覆盖原来的动画。(默认: false)。 + * @example + *
+         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
+         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
+         *     if (armatureDataB) {
+         *     factory.replaceAnimation(armatureA, armatureDataB);
+         *     }
+         * 
+ * @see dragonBones.Armature + * @see dragonBones.ArmatureData + * @version DragonBones 5.6 + * @language zh_CN + */ + replaceAnimation(armature: Armature, armatureData: ArmatureData, isOverride?: boolean): boolean; + /** + * @private + */ + getAllDragonBonesData(): Map; + /** + * @private + */ + getAllTextureAtlasData(): Map>; + /** + * - An Worldclock instance updated by engine. + * @version DragonBones 5.7 + * @language en_US + */ + /** + * - 由引擎驱动的 WorldClock 实例。 + * @version DragonBones 5.7 + * @language zh_CN + */ + readonly clock: WorldClock; + /** + * @private + */ + readonly dragonBones: DragonBones; + /** + * - Deprecated, please refer to {@link #replaceSkin}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #replaceSkin}。 + * @deprecated + * @language zh_CN + */ + changeSkin(armature: Armature, skin: SkinData, exclude?: Array | null): boolean; + /** + * - Deprecated, please refer to {@link #replaceAnimation}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #replaceAnimation}。 + * @deprecated + * @language zh_CN + */ + copyAnimationsToArmature(toArmature: Armature, fromArmatreName: string, fromSkinName?: string, fromDragonBonesDataName?: string, replaceOriginalAnimation?: boolean): boolean; + } + /** + * @internal + * @private + */ + class BuildArmaturePackage { + dataName: string; + textureAtlasName: string; + data: DragonBonesData; + armature: ArmatureData; + skin: SkinData | null; + } +} + +declare namespace sp.spine { + class Animation { + name: string; + timelines: Array; + timelineIds: Array; + duration: number; + constructor(name: string, timelines: Array, duration: number); + hasTimeline(id: number): boolean; + apply(skeleton: Skeleton, lastTime: number, time: number, loop: boolean, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + static binarySearch(values: ArrayLike, target: number, step?: number): number; + static linearSearch(values: ArrayLike, target: number, step: number): number; + } + interface Timeline { + apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + getPropertyId(): number; + } + enum MixBlend { + setup = 0, + first = 1, + replace = 2, + add = 3 + } + enum MixDirection { + mixIn = 0, + mixOut = 1 + } + enum TimelineType { + rotate = 0, + translate = 1, + scale = 2, + shear = 3, + attachment = 4, + color = 5, + deform = 6, + event = 7, + drawOrder = 8, + ikConstraint = 9, + transformConstraint = 10, + pathConstraintPosition = 11, + pathConstraintSpacing = 12, + pathConstraintMix = 13, + twoColor = 14 + } + abstract class CurveTimeline implements Timeline { + static LINEAR: number; + static STEPPED: number; + static BEZIER: number; + static BEZIER_SIZE: number; + private curves; + abstract getPropertyId(): number; + constructor(frameCount: number); + getFrameCount(): number; + setLinear(frameIndex: number): void; + setStepped(frameIndex: number): void; + getCurveType(frameIndex: number): number; + setCurve(frameIndex: number, cx1: number, cy1: number, cx2: number, cy2: number): void; + getCurvePercent(frameIndex: number, percent: number): number; + abstract apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class RotateTimeline extends CurveTimeline { + static ENTRIES: number; + static PREV_TIME: number; + static PREV_ROTATION: number; + static ROTATION: number; + boneIndex: number; + frames: ArrayLike; + constructor(frameCount: number); + getPropertyId(): number; + setFrame(frameIndex: number, time: number, degrees: number): void; + apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class TranslateTimeline extends CurveTimeline { + static ENTRIES: number; + static PREV_TIME: number; + static PREV_X: number; + static PREV_Y: number; + static X: number; + static Y: number; + boneIndex: number; + frames: ArrayLike; + constructor(frameCount: number); + getPropertyId(): number; + setFrame(frameIndex: number, time: number, x: number, y: number): void; + apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class ScaleTimeline extends TranslateTimeline { + constructor(frameCount: number); + getPropertyId(): number; + apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class ShearTimeline extends TranslateTimeline { + constructor(frameCount: number); + getPropertyId(): number; + apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class ColorTimeline extends CurveTimeline { + static ENTRIES: number; + static PREV_TIME: number; + static PREV_R: number; + static PREV_G: number; + static PREV_B: number; + static PREV_A: number; + static R: number; + static G: number; + static B: number; + static A: number; + slotIndex: number; + frames: ArrayLike; + constructor(frameCount: number); + getPropertyId(): number; + setFrame(frameIndex: number, time: number, r: number, g: number, b: number, a: number): void; + apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class TwoColorTimeline extends CurveTimeline { + static ENTRIES: number; + static PREV_TIME: number; + static PREV_R: number; + static PREV_G: number; + static PREV_B: number; + static PREV_A: number; + static PREV_R2: number; + static PREV_G2: number; + static PREV_B2: number; + static R: number; + static G: number; + static B: number; + static A: number; + static R2: number; + static G2: number; + static B2: number; + slotIndex: number; + frames: ArrayLike; + constructor(frameCount: number); + getPropertyId(): number; + setFrame(frameIndex: number, time: number, r: number, g: number, b: number, a: number, r2: number, g2: number, b2: number): void; + apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class AttachmentTimeline implements Timeline { + slotIndex: number; + frames: ArrayLike; + attachmentNames: Array; + constructor(frameCount: number); + getPropertyId(): number; + getFrameCount(): number; + setFrame(frameIndex: number, time: number, attachmentName: string): void; + apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class DeformTimeline extends CurveTimeline { + slotIndex: number; + attachment: VertexAttachment; + frames: ArrayLike; + frameVertices: Array>; + constructor(frameCount: number); + getPropertyId(): number; + setFrame(frameIndex: number, time: number, vertices: ArrayLike): void; + apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class EventTimeline implements Timeline { + frames: ArrayLike; + events: Array; + constructor(frameCount: number); + getPropertyId(): number; + getFrameCount(): number; + setFrame(frameIndex: number, event: Event): void; + apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class DrawOrderTimeline implements Timeline { + frames: ArrayLike; + drawOrders: Array>; + constructor(frameCount: number); + getPropertyId(): number; + getFrameCount(): number; + setFrame(frameIndex: number, time: number, drawOrder: Array): void; + apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class IkConstraintTimeline extends CurveTimeline { + static ENTRIES: number; + static PREV_TIME: number; + static PREV_MIX: number; + static PREV_SOFTNESS: number; + static PREV_BEND_DIRECTION: number; + static PREV_COMPRESS: number; + static PREV_STRETCH: number; + static MIX: number; + static SOFTNESS: number; + static BEND_DIRECTION: number; + static COMPRESS: number; + static STRETCH: number; + ikConstraintIndex: number; + frames: ArrayLike; + constructor(frameCount: number); + getPropertyId(): number; + setFrame(frameIndex: number, time: number, mix: number, softness: number, bendDirection: number, compress: boolean, stretch: boolean): void; + apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class TransformConstraintTimeline extends CurveTimeline { + static ENTRIES: number; + static PREV_TIME: number; + static PREV_ROTATE: number; + static PREV_TRANSLATE: number; + static PREV_SCALE: number; + static PREV_SHEAR: number; + static ROTATE: number; + static TRANSLATE: number; + static SCALE: number; + static SHEAR: number; + transformConstraintIndex: number; + frames: ArrayLike; + constructor(frameCount: number); + getPropertyId(): number; + setFrame(frameIndex: number, time: number, rotateMix: number, translateMix: number, scaleMix: number, shearMix: number): void; + apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class PathConstraintPositionTimeline extends CurveTimeline { + static ENTRIES: number; + static PREV_TIME: number; + static PREV_VALUE: number; + static VALUE: number; + pathConstraintIndex: number; + frames: ArrayLike; + constructor(frameCount: number); + getPropertyId(): number; + setFrame(frameIndex: number, time: number, value: number): void; + apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class PathConstraintSpacingTimeline extends PathConstraintPositionTimeline { + constructor(frameCount: number); + getPropertyId(): number; + apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class PathConstraintMixTimeline extends CurveTimeline { + static ENTRIES: number; + static PREV_TIME: number; + static PREV_ROTATE: number; + static PREV_TRANSLATE: number; + static ROTATE: number; + static TRANSLATE: number; + pathConstraintIndex: number; + frames: ArrayLike; + constructor(frameCount: number); + getPropertyId(): number; + setFrame(frameIndex: number, time: number, rotateMix: number, translateMix: number): void; + apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } +} +declare namespace sp.spine { + class AnimationState { + static emptyAnimation: Animation; + static SUBSEQUENT: number; + static FIRST: number; + static HOLD: number; + static HOLD_MIX: number; + static NOT_LAST: number; + data: AnimationStateData; + tracks: TrackEntry[]; + timeScale: number; + events: Event[]; + listeners: AnimationStateListener[]; + queue: EventQueue; + propertyIDs: IntSet; + animationsChanged: boolean; + trackEntryPool: Pool; + constructor(data: AnimationStateData); + update(delta: number): void; + updateMixingFrom(to: TrackEntry, delta: number): boolean; + apply(skeleton: Skeleton): boolean; + applyMixingFrom(to: TrackEntry, skeleton: Skeleton, blend: MixBlend): number; + applyRotateTimeline(timeline: Timeline, skeleton: Skeleton, time: number, alpha: number, blend: MixBlend, timelinesRotation: Array, i: number, firstFrame: boolean): void; + queueEvents(entry: TrackEntry, animationTime: number): void; + clearTracks(): void; + clearTrack(trackIndex: number): void; + setCurrent(index: number, current: TrackEntry, interrupt: boolean): void; + setAnimation(trackIndex: number, animationName: string, loop: boolean): TrackEntry; + setAnimationWith(trackIndex: number, animation: Animation, loop: boolean): TrackEntry; + addAnimation(trackIndex: number, animationName: string, loop: boolean, delay: number): TrackEntry; + addAnimationWith(trackIndex: number, animation: Animation, loop: boolean, delay: number): TrackEntry; + setEmptyAnimation(trackIndex: number, mixDuration: number): TrackEntry; + addEmptyAnimation(trackIndex: number, mixDuration: number, delay: number): TrackEntry; + setEmptyAnimations(mixDuration: number): void; + expandToIndex(index: number): TrackEntry; + trackEntry(trackIndex: number, animation: Animation, loop: boolean, last: TrackEntry): TrackEntry; + disposeNext(entry: TrackEntry): void; + _animationsChanged(): void; + computeHold(entry: TrackEntry): void; + computeNotLast(entry: TrackEntry): void; + getCurrent(trackIndex: number): TrackEntry; + addListener(listener: AnimationStateListener): void; + removeListener(listener: AnimationStateListener): void; + clearListeners(): void; + clearListenerNotifications(): void; + } + class TrackEntry { + animation: Animation; + next: TrackEntry; + mixingFrom: TrackEntry; + mixingTo: TrackEntry; + listener: AnimationStateListener; + trackIndex: number; + loop: boolean; + holdPrevious: boolean; + eventThreshold: number; + attachmentThreshold: number; + drawOrderThreshold: number; + animationStart: number; + animationEnd: number; + animationLast: number; + nextAnimationLast: number; + delay: number; + trackTime: number; + trackLast: number; + nextTrackLast: number; + trackEnd: number; + timeScale: number; + alpha: number; + mixTime: number; + mixDuration: number; + interruptAlpha: number; + totalAlpha: number; + mixBlend: MixBlend; + timelineMode: number[]; + timelineHoldMix: TrackEntry[]; + timelinesRotation: number[]; + reset(): void; + getAnimationTime(): number; + setAnimationLast(animationLast: number): void; + isComplete(): boolean; + resetRotationDirections(): void; + } + class EventQueue { + objects: Array; + drainDisabled: boolean; + animState: AnimationState; + constructor(animState: AnimationState); + start(entry: TrackEntry): void; + interrupt(entry: TrackEntry): void; + end(entry: TrackEntry): void; + dispose(entry: TrackEntry): void; + complete(entry: TrackEntry): void; + event(entry: TrackEntry, event: Event): void; + drain(): void; + clear(): void; + } + enum EventType { + start = 0, + interrupt = 1, + end = 2, + dispose = 3, + complete = 4, + event = 5 + } + interface AnimationStateListener { + start(entry: TrackEntry): void; + interrupt(entry: TrackEntry): void; + end(entry: TrackEntry): void; + dispose(entry: TrackEntry): void; + complete(entry: TrackEntry): void; + event(entry: TrackEntry, event: Event): void; + } + abstract class AnimationStateAdapter implements AnimationStateListener { + start(entry: TrackEntry): void; + interrupt(entry: TrackEntry): void; + end(entry: TrackEntry): void; + dispose(entry: TrackEntry): void; + complete(entry: TrackEntry): void; + event(entry: TrackEntry, event: Event): void; + } +} +declare namespace sp.spine { + class AnimationStateData { + skeletonData: SkeletonData; + animationToMixTime: Map; + defaultMix: number; + constructor(skeletonData: SkeletonData); + setMix(fromName: string, toName: string, duration: number): void; + setMixWith(from: Animation, to: Animation, duration: number): void; + getMix(from: Animation, to: Animation): number; + } +} +declare namespace sp.spine { + class AssetManager implements Disposable { + private pathPrefix; + private textureLoader; + private assets; + private errors; + private toLoad; + private loaded; + constructor(textureLoader: (image: HTMLImageElement) => any, pathPrefix?: string); + private static downloadText; + private static downloadBinary; + loadBinary(path: string, success?: (path: string, binary: Uint8Array) => void, error?: (path: string, error: string) => void): void; + loadText(path: string, success?: (path: string, text: string) => void, error?: (path: string, error: string) => void): void; + loadTexture(path: string, success?: (path: string, image: HTMLImageElement) => void, error?: (path: string, error: string) => void): void; + loadTextureData(path: string, data: string, success?: (path: string, image: HTMLImageElement) => void, error?: (path: string, error: string) => void): void; + loadTextureAtlas(path: string, success?: (path: string, atlas: TextureAtlas) => void, error?: (path: string, error: string) => void): void; + get(path: string): any; + remove(path: string): void; + removeAll(): void; + isLoadingComplete(): boolean; + getToLoad(): number; + getLoaded(): number; + dispose(): void; + hasErrors(): boolean; + getErrors(): Map; + } +} +declare namespace sp.spine { + class AtlasAttachmentLoader implements AttachmentLoader { + atlas: TextureAtlas; + constructor(atlas: TextureAtlas); + newRegionAttachment(skin: Skin, name: string, path: string): RegionAttachment; + newMeshAttachment(skin: Skin, name: string, path: string): MeshAttachment; + newBoundingBoxAttachment(skin: Skin, name: string): BoundingBoxAttachment; + newPathAttachment(skin: Skin, name: string): PathAttachment; + newPointAttachment(skin: Skin, name: string): PointAttachment; + newClippingAttachment(skin: Skin, name: string): ClippingAttachment; + } +} +declare namespace sp.spine { + enum BlendMode { + Normal = 0, + Additive = 1, + Multiply = 2, + Screen = 3 + } +} +declare namespace sp.spine { + class Bone implements Updatable { + data: BoneData; + skeleton: Skeleton; + parent: Bone; + children: Bone[]; + x: number; + y: number; + rotation: number; + scaleX: number; + scaleY: number; + shearX: number; + shearY: number; + ax: number; + ay: number; + arotation: number; + ascaleX: number; + ascaleY: number; + ashearX: number; + ashearY: number; + appliedValid: boolean; + a: number; + b: number; + c: number; + d: number; + worldY: number; + worldX: number; + sorted: boolean; + active: boolean; + constructor(data: BoneData, skeleton: Skeleton, parent: Bone); + isActive(): boolean; + update(): void; + updateWorldTransform(): void; + updateWorldTransformWith(x: number, y: number, rotation: number, scaleX: number, scaleY: number, shearX: number, shearY: number): void; + setToSetupPose(): void; + getWorldRotationX(): number; + getWorldRotationY(): number; + getWorldScaleX(): number; + getWorldScaleY(): number; + updateAppliedTransform(): void; + worldToLocal(world: Vector2): Vector2; + localToWorld(local: Vector2): Vector2; + worldToLocalRotation(worldRotation: number): number; + localToWorldRotation(localRotation: number): number; + rotateWorld(degrees: number): void; + } +} +declare namespace sp.spine { + class BoneData { + index: number; + name: string; + parent: BoneData; + length: number; + x: number; + y: number; + rotation: number; + scaleX: number; + scaleY: number; + shearX: number; + shearY: number; + transformMode: TransformMode; + skinRequired: boolean; + color: Color; + constructor(index: number, name: string, parent: BoneData); + } + enum TransformMode { + Normal = 0, + OnlyTranslation = 1, + NoRotationOrReflection = 2, + NoScale = 3, + NoScaleOrReflection = 4 + } +} +declare namespace sp.spine { + abstract class ConstraintData { + name: string; + order: number; + skinRequired: boolean; + constructor(name: string, order: number, skinRequired: boolean); + } +} +declare namespace sp.spine { + class Event { + data: EventData; + intValue: number; + floatValue: number; + stringValue: string; + time: number; + volume: number; + balance: number; + constructor(time: number, data: EventData); + } +} +declare namespace sp.spine { + class EventData { + name: string; + intValue: number; + floatValue: number; + stringValue: string; + audioPath: string; + volume: number; + balance: number; + constructor(name: string); + } +} +declare namespace sp.spine { + class IkConstraint implements Updatable { + data: IkConstraintData; + bones: Array; + target: Bone; + bendDirection: number; + compress: boolean; + stretch: boolean; + mix: number; + softness: number; + active: boolean; + constructor(data: IkConstraintData, skeleton: Skeleton); + isActive(): boolean; + apply(): void; + update(): void; + apply1(bone: Bone, targetX: number, targetY: number, compress: boolean, stretch: boolean, uniform: boolean, alpha: number): void; + apply2(parent: Bone, child: Bone, targetX: number, targetY: number, bendDir: number, stretch: boolean, softness: number, alpha: number): void; + } +} +declare namespace sp.spine { + class IkConstraintData extends ConstraintData { + bones: BoneData[]; + target: BoneData; + bendDirection: number; + compress: boolean; + stretch: boolean; + uniform: boolean; + mix: number; + softness: number; + constructor(name: string); + } +} +declare namespace sp.spine { + class PathConstraint implements Updatable { + static NONE: number; + static BEFORE: number; + static AFTER: number; + static epsilon: number; + data: PathConstraintData; + bones: Array; + target: Slot; + position: number; + spacing: number; + rotateMix: number; + translateMix: number; + spaces: number[]; + positions: number[]; + world: number[]; + curves: number[]; + lengths: number[]; + segments: number[]; + active: boolean; + constructor(data: PathConstraintData, skeleton: Skeleton); + isActive(): boolean; + apply(): void; + update(): void; + computeWorldPositions(path: PathAttachment, spacesCount: number, tangents: boolean, percentPosition: boolean, percentSpacing: boolean): number[]; + addBeforePosition(p: number, temp: Array, i: number, out: Array, o: number): void; + addAfterPosition(p: number, temp: Array, i: number, out: Array, o: number): void; + addCurvePosition(p: number, x1: number, y1: number, cx1: number, cy1: number, cx2: number, cy2: number, x2: number, y2: number, out: Array, o: number, tangents: boolean): void; + } +} +declare namespace sp.spine { + class PathConstraintData extends ConstraintData { + bones: BoneData[]; + target: SlotData; + positionMode: PositionMode; + spacingMode: SpacingMode; + rotateMode: RotateMode; + offsetRotation: number; + position: number; + spacing: number; + rotateMix: number; + translateMix: number; + constructor(name: string); + } + enum PositionMode { + Fixed = 0, + Percent = 1 + } + enum SpacingMode { + Length = 0, + Fixed = 1, + Percent = 2 + } + enum RotateMode { + Tangent = 0, + Chain = 1, + ChainScale = 2 + } +} +declare namespace sp.spine { + class SharedAssetManager implements Disposable { + private pathPrefix; + private clientAssets; + private queuedAssets; + private rawAssets; + private errors; + constructor(pathPrefix?: string); + private queueAsset; + loadText(clientId: string, path: string): void; + loadJson(clientId: string, path: string): void; + loadTexture(clientId: string, textureLoader: (image: HTMLImageElement) => any, path: string): void; + get(clientId: string, path: string): any; + private updateClientAssets; + isLoadingComplete(clientId: string): boolean; + dispose(): void; + hasErrors(): boolean; + getErrors(): Map; + } +} +declare namespace sp.spine { + class Skeleton { + data: SkeletonData; + bones: Array; + slots: Array; + drawOrder: Array; + ikConstraints: Array; + transformConstraints: Array; + pathConstraints: Array; + _updateCache: Updatable[]; + updateCacheReset: Updatable[]; + skin: Skin; + color: Color; + time: number; + scaleX: number; + scaleY: number; + x: number; + y: number; + constructor(data: SkeletonData); + updateCache(): void; + sortIkConstraint(constraint: IkConstraint): void; + sortPathConstraint(constraint: PathConstraint): void; + sortTransformConstraint(constraint: TransformConstraint): void; + sortPathConstraintAttachment(skin: Skin, slotIndex: number, slotBone: Bone): void; + sortPathConstraintAttachmentWith(attachment: Attachment, slotBone: Bone): void; + sortBone(bone: Bone): void; + sortReset(bones: Array): void; + updateWorldTransform(): void; + setToSetupPose(): void; + setBonesToSetupPose(): void; + setSlotsToSetupPose(): void; + getRootBone(): Bone; + findBone(boneName: string): Bone; + findBoneIndex(boneName: string): number; + findSlot(slotName: string): Slot; + findSlotIndex(slotName: string): number; + setSkinByName(skinName: string): void; + setSkin(newSkin: Skin): void; + getAttachmentByName(slotName: string, attachmentName: string): Attachment; + getAttachment(slotIndex: number, attachmentName: string): Attachment; + setAttachment(slotName: string, attachmentName: string): void; + findIkConstraint(constraintName: string): IkConstraint; + findTransformConstraint(constraintName: string): TransformConstraint; + findPathConstraint(constraintName: string): PathConstraint; + getBounds(offset: Vector2, size: Vector2, temp?: Array): void; + update(delta: number): void; + } +} +declare namespace sp.spine { + class SkeletonBinary { + static AttachmentTypeValues: number[]; + static TransformModeValues: TransformMode[]; + static PositionModeValues: PositionMode[]; + static SpacingModeValues: SpacingMode[]; + static RotateModeValues: RotateMode[]; + static BlendModeValues: BlendMode[]; + static BONE_ROTATE: number; + static BONE_TRANSLATE: number; + static BONE_SCALE: number; + static BONE_SHEAR: number; + static SLOT_ATTACHMENT: number; + static SLOT_COLOR: number; + static SLOT_TWO_COLOR: number; + static PATH_POSITION: number; + static PATH_SPACING: number; + static PATH_MIX: number; + static CURVE_LINEAR: number; + static CURVE_STEPPED: number; + static CURVE_BEZIER: number; + scale: number; + attachmentLoader: AttachmentLoader; + private linkedMeshes; + constructor(attachmentLoader: AttachmentLoader); + readSkeletonData(binary: Uint8Array): SkeletonData; + private readSkin; + private readAttachment; + private readVertices; + private readFloatArray; + private readShortArray; + private readAnimation; + private readCurve; + setCurve(timeline: CurveTimeline, frameIndex: number, cx1: number, cy1: number, cx2: number, cy2: number): void; + } +} +declare namespace sp.spine { + class SkeletonBounds { + minX: number; + minY: number; + maxX: number; + maxY: number; + boundingBoxes: BoundingBoxAttachment[]; + polygons: ArrayLike[]; + private polygonPool; + update(skeleton: Skeleton, updateAabb: boolean): void; + aabbCompute(): void; + aabbContainsPoint(x: number, y: number): boolean; + aabbIntersectsSegment(x1: number, y1: number, x2: number, y2: number): boolean; + aabbIntersectsSkeleton(bounds: SkeletonBounds): boolean; + containsPoint(x: number, y: number): BoundingBoxAttachment; + containsPointPolygon(polygon: ArrayLike, x: number, y: number): boolean; + intersectsSegment(x1: number, y1: number, x2: number, y2: number): BoundingBoxAttachment; + intersectsSegmentPolygon(polygon: ArrayLike, x1: number, y1: number, x2: number, y2: number): boolean; + getPolygon(boundingBox: BoundingBoxAttachment): ArrayLike; + getWidth(): number; + getHeight(): number; + } +} +declare namespace sp.spine { + class SkeletonClipping { + private triangulator; + private clippingPolygon; + private clipOutput; + clippedVertices: number[]; + clippedTriangles: number[]; + private scratch; + private clipAttachment; + private clippingPolygons; + clipStart(slot: Slot, clip: ClippingAttachment): number; + clipEndWithSlot(slot: Slot): void; + clipEnd(): void; + isClipping(): boolean; + clipTriangles(vertices: ArrayLike, verticesLength: number, triangles: ArrayLike, trianglesLength: number, uvs: ArrayLike, light: Color, dark: Color, twoColor: boolean): void; + clip(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, clippingArea: Array, output: Array): boolean; + static makeClockwise(polygon: ArrayLike): void; + } +} +declare namespace sp.spine { + class SkeletonData { + name: string; + bones: BoneData[]; + slots: SlotData[]; + skins: Skin[]; + defaultSkin: Skin; + events: EventData[]; + animations: Animation[]; + ikConstraints: IkConstraintData[]; + transformConstraints: TransformConstraintData[]; + pathConstraints: PathConstraintData[]; + x: number; + y: number; + width: number; + height: number; + version: string; + hash: string; + fps: number; + imagesPath: string; + audioPath: string; + findBone(boneName: string): BoneData; + findBoneIndex(boneName: string): number; + findSlot(slotName: string): SlotData; + findSlotIndex(slotName: string): number; + findSkin(skinName: string): Skin; + findEvent(eventDataName: string): EventData; + findAnimation(animationName: string): Animation; + findIkConstraint(constraintName: string): IkConstraintData; + findTransformConstraint(constraintName: string): TransformConstraintData; + findPathConstraint(constraintName: string): PathConstraintData; + findPathConstraintIndex(pathConstraintName: string): number; + } +} +declare namespace sp.spine { + class SkeletonJson { + attachmentLoader: AttachmentLoader; + scale: number; + private linkedMeshes; + constructor(attachmentLoader: AttachmentLoader); + readSkeletonData(json: string | any): SkeletonData; + readAttachment(map: any, skin: Skin, slotIndex: number, name: string, skeletonData: SkeletonData): Attachment; + readVertices(map: any, attachment: VertexAttachment, verticesLength: number): void; + readAnimation(map: any, name: string, skeletonData: SkeletonData): void; + readCurve(map: any, timeline: CurveTimeline, frameIndex: number): void; + getValue(map: any, prop: string, defaultValue: any): any; + static blendModeFromString(str: string): BlendMode; + static positionModeFromString(str: string): PositionMode; + static spacingModeFromString(str: string): SpacingMode; + static rotateModeFromString(str: string): RotateMode; + static transformModeFromString(str: string): TransformMode; + } +} +declare namespace sp.spine { + class SkinEntry { + slotIndex: number; + name: string; + attachment: Attachment; + constructor(slotIndex: number, name: string, attachment: Attachment); + } + class Skin { + name: string; + attachments: Map[]; + bones: BoneData[]; + constraints: ConstraintData[]; + constructor(name: string); + setAttachment(slotIndex: number, name: string, attachment: Attachment): void; + addSkin(skin: Skin): void; + copySkin(skin: Skin): void; + getAttachment(slotIndex: number, name: string): Attachment; + removeAttachment(slotIndex: number, name: string): void; + getAttachments(): Array; + getAttachmentsForSlot(slotIndex: number, attachments: Array): void; + clear(): void; + attachAll(skeleton: Skeleton, oldSkin: Skin): void; + } +} +declare namespace sp.spine { + class Slot { + data: SlotData; + bone: Bone; + color: Color; + darkColor: Color; + private attachment; + private attachmentTime; + deform: number[]; + constructor(data: SlotData, bone: Bone); + getSkeleton(): Skeleton; + getAttachment(): Attachment; + setAttachment(attachment: Attachment): void; + setAttachmentTime(time: number): void; + getAttachmentTime(): number; + setToSetupPose(): void; + } +} +declare namespace sp.spine { + class SlotData { + index: number; + name: string; + boneData: BoneData; + color: Color; + darkColor: Color; + attachmentName: string; + blendMode: BlendMode; + constructor(index: number, name: string, boneData: BoneData); + } +} +declare namespace sp.spine { + abstract class Texture { + protected _image: HTMLImageElement; + constructor(image: HTMLImageElement); + getImage(): HTMLImageElement; + abstract setFilters(minFilter: TextureFilter, magFilter: TextureFilter): void; + abstract setWraps(uWrap: TextureWrap, vWrap: TextureWrap): void; + abstract dispose(): void; + static filterFromString(text: string): TextureFilter; + static wrapFromString(text: string): TextureWrap; + } + enum TextureFilter { + Nearest = 9728, + Linear = 9729, + MipMap = 9987, + MipMapNearestNearest = 9984, + MipMapLinearNearest = 9985, + MipMapNearestLinear = 9986, + MipMapLinearLinear = 9987 + } + enum TextureWrap { + MirroredRepeat = 33648, + ClampToEdge = 33071, + Repeat = 10497 + } + class TextureRegion { + renderObject: any; + u: number; + v: number; + u2: number; + v2: number; + width: number; + height: number; + rotate: boolean; + offsetX: number; + offsetY: number; + originalWidth: number; + originalHeight: number; + } + class FakeTexture extends Texture { + setFilters(minFilter: TextureFilter, magFilter: TextureFilter): void; + setWraps(uWrap: TextureWrap, vWrap: TextureWrap): void; + dispose(): void; + } +} +declare namespace sp.spine { + class TextureAtlas implements Disposable { + pages: TextureAtlasPage[]; + regions: TextureAtlasRegion[]; + constructor(atlasText: string, textureLoader: (path: string) => any); + private load; + findRegion(name: string): TextureAtlasRegion; + dispose(): void; + } + class TextureAtlasPage { + name: string; + minFilter: TextureFilter; + magFilter: TextureFilter; + uWrap: TextureWrap; + vWrap: TextureWrap; + texture: Texture; + width: number; + height: number; + } + class TextureAtlasRegion extends TextureRegion { + page: TextureAtlasPage; + name: string; + x: number; + y: number; + index: number; + rotate: boolean; + degrees: number; + texture: Texture; + } +} +declare namespace sp.spine { + class TransformConstraint implements Updatable { + data: TransformConstraintData; + bones: Array; + target: Bone; + rotateMix: number; + translateMix: number; + scaleMix: number; + shearMix: number; + temp: Vector2; + active: boolean; + constructor(data: TransformConstraintData, skeleton: Skeleton); + isActive(): boolean; + apply(): void; + update(): void; + applyAbsoluteWorld(): void; + applyRelativeWorld(): void; + applyAbsoluteLocal(): void; + applyRelativeLocal(): void; + } +} +declare namespace sp.spine { + class TransformConstraintData extends ConstraintData { + bones: BoneData[]; + target: BoneData; + rotateMix: number; + translateMix: number; + scaleMix: number; + shearMix: number; + offsetRotation: number; + offsetX: number; + offsetY: number; + offsetScaleX: number; + offsetScaleY: number; + offsetShearY: number; + relative: boolean; + local: boolean; + constructor(name: string); + } +} +declare namespace sp.spine { + class Triangulator { + private convexPolygons; + private convexPolygonsIndices; + private indicesArray; + private isConcaveArray; + private triangles; + private polygonPool; + private polygonIndicesPool; + triangulate(verticesArray: ArrayLike): Array; + decompose(verticesArray: Array, triangles: Array): Array>; + private static isConcave; + private static positiveArea; + private static winding; + } +} +declare namespace sp.spine { + interface Updatable { + update(): void; + isActive(): boolean; + } +} +declare namespace sp.spine { + interface Map { + [key: string]: T; + } + class IntSet { + array: number[]; + add(value: number): boolean; + contains(value: number): boolean; + remove(value: number): void; + clear(): void; + } + interface Disposable { + dispose(): void; + } + interface Restorable { + restore(): void; + } + class Color { + r: number; + g: number; + b: number; + a: number; + static WHITE: Color; + static RED: Color; + static GREEN: Color; + static BLUE: Color; + static MAGENTA: Color; + constructor(r?: number, g?: number, b?: number, a?: number); + set(r: number, g: number, b: number, a: number): this; + setFromColor(c: Color): this; + setFromString(hex: string): this; + add(r: number, g: number, b: number, a: number): this; + clamp(): this; + static rgba8888ToColor(color: Color, value: number): void; + static rgb888ToColor(color: Color, value: number): void; + } + class MathUtils { + static PI: number; + static PI2: number; + static radiansToDegrees: number; + static radDeg: number; + static degreesToRadians: number; + static degRad: number; + static clamp(value: number, min: number, max: number): number; + static cosDeg(degrees: number): number; + static sinDeg(degrees: number): number; + static signum(value: number): number; + static toInt(x: number): number; + static cbrt(x: number): number; + static randomTriangular(min: number, max: number): number; + static randomTriangularWith(min: number, max: number, mode: number): number; + } + abstract class Interpolation { + protected abstract applyInternal(a: number): number; + apply(start: number, end: number, a: number): number; + } + class Pow extends Interpolation { + protected power: number; + constructor(power: number); + applyInternal(a: number): number; + } + class PowOut extends Pow { + constructor(power: number); + applyInternal(a: number): number; + } + class Utils { + static SUPPORTS_TYPED_ARRAYS: boolean; + static arrayCopy(source: ArrayLike, sourceStart: number, dest: ArrayLike, destStart: number, numElements: number): void; + static setArraySize(array: Array, size: number, value?: any): Array; + static ensureArrayCapacity(array: Array, size: number, value?: any): Array; + static newArray(size: number, defaultValue: T): Array; + static newFloatArray(size: number): ArrayLike; + static newShortArray(size: number): ArrayLike; + static toFloatArray(array: Array): number[] | Float32Array; + static toSinglePrecision(value: number): number; + static webkit602BugfixHelper(alpha: number, blend: MixBlend): void; + static contains(array: Array, element: T, identity?: boolean): boolean; + } + class DebugUtils { + static logBones(skeleton: Skeleton): void; + } + class Pool { + private items; + private instantiator; + constructor(instantiator: () => T); + obtain(): T; + free(item: T): void; + freeAll(items: ArrayLike): void; + clear(): void; + } + class Vector2 { + x: number; + y: number; + constructor(x?: number, y?: number); + set(x: number, y: number): Vector2; + length(): number; + normalize(): this; + } + class TimeKeeper { + maxDelta: number; + framesPerSecond: number; + delta: number; + totalTime: number; + private lastTime; + private frameCount; + private frameTime; + update(): void; + } + interface ArrayLike { + length: number; + [n: number]: T; + } + class WindowedMean { + values: Array; + addedValues: number; + lastValue: number; + mean: number; + dirty: boolean; + constructor(windowSize?: number); + hasEnoughData(): boolean; + addValue(value: number): void; + getMean(): number; + } +} +declare namespace sp.spine { + interface VertexEffect { + begin(skeleton: Skeleton): void; + transform(position: Vector2, uv: Vector2, light: Color, dark: Color): void; + end(): void; + } +} +interface Math { + fround(n: number): number; +} +declare namespace sp.spine { + abstract class Attachment { + name: string; + constructor(name: string); + abstract copy(): Attachment; + } + abstract class VertexAttachment extends Attachment { + private static nextID; + id: number; + bones: Array; + vertices: ArrayLike; + worldVerticesLength: number; + deformAttachment: VertexAttachment; + constructor(name: string); + computeWorldVertices(slot: Slot, start: number, count: number, worldVertices: ArrayLike, offset: number, stride: number): void; + copyTo(attachment: VertexAttachment): void; + } +} +declare namespace sp.spine { + interface AttachmentLoader { + newRegionAttachment(skin: Skin, name: string, path: string): RegionAttachment; + newMeshAttachment(skin: Skin, name: string, path: string): MeshAttachment; + newBoundingBoxAttachment(skin: Skin, name: string): BoundingBoxAttachment; + newPathAttachment(skin: Skin, name: string): PathAttachment; + newPointAttachment(skin: Skin, name: string): PointAttachment; + newClippingAttachment(skin: Skin, name: string): ClippingAttachment; + } +} +declare namespace sp.spine { + enum AttachmentType { + Region = 0, + BoundingBox = 1, + Mesh = 2, + LinkedMesh = 3, + Path = 4, + Point = 5, + Clipping = 6 + } +} +declare namespace sp.spine { + class BoundingBoxAttachment extends VertexAttachment { + color: Color; + constructor(name: string); + copy(): Attachment; + } +} +declare namespace sp.spine { + class ClippingAttachment extends VertexAttachment { + endSlot: SlotData; + color: Color; + constructor(name: string); + copy(): Attachment; + } +} +declare namespace sp.spine { + class MeshAttachment extends VertexAttachment { + region: TextureRegion; + path: string; + regionUVs: ArrayLike; + uvs: ArrayLike; + triangles: Array; + color: Color; + width: number; + height: number; + hullLength: number; + edges: Array; + private parentMesh; + tempColor: Color; + constructor(name: string); + updateUVs(): void; + getParentMesh(): MeshAttachment; + setParentMesh(parentMesh: MeshAttachment): void; + copy(): Attachment; + newLinkedMesh(): MeshAttachment; + } +} +declare namespace sp.spine { + class PathAttachment extends VertexAttachment { + lengths: Array; + closed: boolean; + constantSpeed: boolean; + color: Color; + constructor(name: string); + copy(): Attachment; + } +} +declare namespace sp.spine { + class PointAttachment extends VertexAttachment { + x: number; + y: number; + rotation: number; + color: Color; + constructor(name: string); + computeWorldPosition(bone: Bone, point: Vector2): Vector2; + computeWorldRotation(bone: Bone): number; + copy(): Attachment; + } +} +declare namespace sp.spine { + class RegionAttachment extends Attachment { + static OX1: number; + static OY1: number; + static OX2: number; + static OY2: number; + static OX3: number; + static OY3: number; + static OX4: number; + static OY4: number; + static X1: number; + static Y1: number; + static C1R: number; + static C1G: number; + static C1B: number; + static C1A: number; + static U1: number; + static V1: number; + static X2: number; + static Y2: number; + static C2R: number; + static C2G: number; + static C2B: number; + static C2A: number; + static U2: number; + static V2: number; + static X3: number; + static Y3: number; + static C3R: number; + static C3G: number; + static C3B: number; + static C3A: number; + static U3: number; + static V3: number; + static X4: number; + static Y4: number; + static C4R: number; + static C4G: number; + static C4B: number; + static C4A: number; + static U4: number; + static V4: number; + x: number; + y: number; + scaleX: number; + scaleY: number; + rotation: number; + width: number; + height: number; + color: Color; + path: string; + rendererObject: any; + region: TextureRegion; + offset: ArrayLike; + uvs: ArrayLike; + tempColor: Color; + constructor(name: string); + updateOffset(): void; + setRegion(region: TextureRegion): void; + computeWorldVertices(bone: Bone, worldVertices: ArrayLike, offset: number, stride: number): void; + copy(): Attachment; + } +} +declare namespace sp.spine { + class JitterEffect implements VertexEffect { + jitterX: number; + jitterY: number; + constructor(jitterX: number, jitterY: number); + begin(skeleton: Skeleton): void; + transform(position: Vector2, uv: Vector2, light: Color, dark: Color): void; + end(): void; + } +} +declare namespace sp.spine { + class SwirlEffect implements VertexEffect { + static interpolation: PowOut; + centerX: number; + centerY: number; + radius: number; + angle: number; + private worldX; + private worldY; + constructor(radius: number); + begin(skeleton: Skeleton): void; + transform(position: Vector2, uv: Vector2, light: Color, dark: Color): void; + end(): void; + } +} + +/** + * API for jsb module + * Author: haroel + * Homepage: https://github.com/haroel/creatorexDTS + */ +declare namespace jsb{ + export module reflection{ + /** + * https://docs.cocos.com/creator/manual/zh/advanced-topics/java-reflection.html + * call OBJC/Java static methods + * + * @param className + * @param methodName + * @param methodSignature + * @param parameters + */ + export function callStaticMethod(className: string, methodName: string, methodSignature: string, ...parameters:any): any; + } + /** + * 下载任务对象 + */ + export type DownloaderTask = { requestURL: string, storagePath: string, identifier: string }; + + /** + * Http file downloader for jsb! + */ + export class Downloader{ + /** + * create a download task + * @param requestURL + * @param storagePath + * @param identifier + */ + createDownloadFileTask(requestURL:string, storagePath:string, identifier?:string): DownloaderTask; + + setOnFileTaskSuccess(onSucceed: (task: DownloaderTask) => void): void; + + setOnTaskProgress(onProgress: (task: DownloaderTask, bytesReceived: number, totalBytesReceived: number, totalBytesExpected: number) => void): void; + + setOnTaskError(onError: (task: DownloaderTask, errorCode: number, errorCodeInternal: number, errorStr: string) => void): void; + + } + + /** + * FileUtils Helper class to handle file operations. + */ + export module fileUtils{ + /** + * Checks whether the path is an absolute path. + * + * @note On Android, if the parameter passed in is relative to "@assets/", this method will treat it as an absolute path. + * Also on Blackberry, path starts with "app/native/Resources/" is treated as an absolute path. + * + * @param path The path that needs to be checked. + * @return True if it's an absolute path, false if not. + */ + export function isAbsolutePath(path:string):boolean; + /** Returns the fullpath for a given filename. + + First it will try to get a new filename from the "filenameLookup" dictionary. + If a new filename can't be found on the dictionary, it will use the original filename. + Then it will try to obtain the full path of the filename using the FileUtils search rules: resolutions, and search paths. + The file search is based on the array element order of search paths and resolution directories. + + For instance: + + We set two elements("/mnt/sdcard/", "internal_dir/") to search paths vector by setSearchPaths, + and set three elements("resources-ipadhd/", "resources-ipad/", "resources-iphonehd") + to resolutions vector by setSearchResolutionsOrder. The "internal_dir" is relative to "Resources/". + + If we have a file named 'sprite.png', the mapping in fileLookup dictionary contains `key: sprite.png -> value: sprite.pvr.gz`. + Firstly, it will replace 'sprite.png' with 'sprite.pvr.gz', then searching the file sprite.pvr.gz as follows: + + /mnt/sdcard/resources-ipadhd/sprite.pvr.gz (if not found, search next) + /mnt/sdcard/resources-ipad/sprite.pvr.gz (if not found, search next) + /mnt/sdcard/resources-iphonehd/sprite.pvr.gz (if not found, search next) + /mnt/sdcard/sprite.pvr.gz (if not found, search next) + internal_dir/resources-ipadhd/sprite.pvr.gz (if not found, search next) + internal_dir/resources-ipad/sprite.pvr.gz (if not found, search next) + internal_dir/resources-iphonehd/sprite.pvr.gz (if not found, search next) + internal_dir/sprite.pvr.gz (if not found, return "sprite.png") + + If the filename contains relative path like "gamescene/uilayer/sprite.png", + and the mapping in fileLookup dictionary contains `key: gamescene/uilayer/sprite.png -> value: gamescene/uilayer/sprite.pvr.gz`. + The file search order will be: + + /mnt/sdcard/gamescene/uilayer/resources-ipadhd/sprite.pvr.gz (if not found, search next) + /mnt/sdcard/gamescene/uilayer/resources-ipad/sprite.pvr.gz (if not found, search next) + /mnt/sdcard/gamescene/uilayer/resources-iphonehd/sprite.pvr.gz (if not found, search next) + /mnt/sdcard/gamescene/uilayer/sprite.pvr.gz (if not found, search next) + internal_dir/gamescene/uilayer/resources-ipadhd/sprite.pvr.gz (if not found, search next) + internal_dir/gamescene/uilayer/resources-ipad/sprite.pvr.gz (if not found, search next) + internal_dir/gamescene/uilayer/resources-iphonehd/sprite.pvr.gz (if not found, search next) + internal_dir/gamescene/uilayer/sprite.pvr.gz (if not found, return "gamescene/uilayer/sprite.png") + + If the new file can't be found on the file system, it will return the parameter filename directly. + + This method was added to simplify multiplatform support. Whether you are using cocos2d-js or any cross-compilation toolchain like StellaSDK or Apportable, + you might need to load different resources for a given file in the different platforms. + + @since v2.1 + */ + export function fullPathForFilename(filename:string):string; + /** + * Gets string from a file. + */ + export function getStringFromFile(filename:string):string; + /** + * Removes a file. + * + * @param filepath The full path of the file, it must be an absolute path. + * @return True if the file have been removed successfully, false if not. + */ + export function removeFile(filepath:string):boolean; + /** + * Checks whether the path is a directory. + * + * @param dirPath The path of the directory, it could be a relative or an absolute path. + * @return True if the directory exists, false if not. + */ + export function isDirectoryExist(dirPath:string):boolean; + /** + * Normalize: remove . and .. + * @param filepath + */ + export function normalizePath(filepath:string):string; + /** + * Get default resource root path. + */ + export function getDefaultResourceRootPath():string; + /** + * Loads the filenameLookup dictionary from the contents of a filename. + * + * @note The plist file name should follow the format below: + * + * @code + * + * + * + * + * filenames + * + * sounds/click.wav + * sounds/click.caf + * sounds/endgame.wav + * sounds/endgame.caf + * sounds/gem-0.wav + * sounds/gem-0.caf + * + * metadata + * + * version + * 1 + * + * + * + * @endcode + * @param filename The plist file name. + * + @since v2.1 + * @js loadFilenameLookup + * @lua loadFilenameLookup + */ + export function loadFilenameLookup(filepath:string):void; + /** Checks whether to pop up a message box when failed to load an image. + * @return True if pop up a message box when failed to load an image, false if not. + */ + export function isPopupNotify():boolean; + /** + * Sets whether to pop-up a message box when failed to load an image. + */ + export function setPopupNotify(notify:boolean):void; + + // Converts the contents of a file to a ValueVector. + // This method is used internally. + export function getValueVectorFromFile(filepath:string):Array; + /** + * Gets the array of search paths. + * + * @return The array of search paths which may contain the prefix of default resource root path. + * @note In best practise, getter function should return the value of setter function passes in. + * But since we should not break the compatibility, we keep using the old logic. + * Therefore, If you want to get the original search paths, please call 'getOriginalSearchPaths()' instead. + * @see fullPathForFilename(const char*). + * @lua NA + */ + export function getSearchPaths(filepath:string):Array; + /** + * + * @param filepath + */ + export function getFileDir(filepath:string):string; + /** + * write a ValueMap into a plist file + * + *@param dict the ValueMap want to save (key,value) + *@param fullPath The full path to the file you want to save a string + *@return bool + */ + export function writeToFile( valueMap:any ):boolean; + /** + * Gets the original search path array set by 'setSearchPaths' or 'addSearchPath'. + * @return The array of the original search paths + */ + export function getOriginalSearchPaths():Array; + /** + * List all files in a directory. + * + * @param dirPath The path of the directory, it could be a relative or an absolute path. + * @return File paths in a string vector + */ + export function listFiles(filepath:string):Array; + /** + * Converts the contents of a file to a ValueMap. + * @param filename The filename of the file to gets content. + * @return ValueMap of the file contents. + * @note This method is used internally. + */ + export function getValueMapFromFile(filepath:string):any; + /** + * Retrieve the file size. + * + * @note If a relative path was passed in, it will be inserted a default root path at the beginning. + * @param filepath The path of the file, it could be a relative or absolute path. + * @return The file size. + */ + export function getFileSize(filepath:string):number; + + /** Converts the contents of a file to a ValueMap. + * This method is used internally. + */ + export function getValueMapFromData(filedata:string,filesize:number):any; + /** + * Removes a directory. + * + * @param dirPath The full path of the directory, it must be an absolute path. + * @return True if the directory have been removed successfully, false if not. + */ + export function removeDirectory(dirPath:string):boolean; + /** + * Sets the array of search paths. + * + * You can use this array to modify the search path of the resources. + * If you want to use "themes" or search resources in the "cache", you can do it easily by adding new entries in this array. + * + * @note This method could access relative path and absolute path. + * If the relative path was passed to the vector, FileUtils will add the default resource directory before the relative path. + * For instance: + * On Android, the default resource root path is "@assets/". + * If "/mnt/sdcard/" and "resources-large" were set to the search paths vector, + * "resources-large" will be converted to "@assets/resources-large" since it was a relative path. + * + * @param searchPaths The array contains search paths. + * @see fullPathForFilename(const char*) + * @since v2.1 + * In js:var setSearchPaths(var jsval); + * @lua NA + */ + export function setSearchPaths( searchPath:Array):void; + /** + * write a string into a file + * + * @param dataStr the string want to save + * @param fullPath The full path to the file you want to save a string + * @return bool True if write success + */ + export function writeStringToFile(dataStr:string,fullPath:string):boolean; + /** + * Sets the array that contains the search order of the resources. + * + * @param searchResolutionsOrder The source array that contains the search order of the resources. + * @see getSearchResolutionsOrder(), fullPathForFilename(const char*). + * @since v2.1 + * In js:var setSearchResolutionsOrder(var jsval) + * @lua NA + */ + export function setSearchResolutionsOrder(searchResolutionsOrder:Array):void; + /** + * Append search order of the resources. + * + * @see setSearchResolutionsOrder(), fullPathForFilename(). + * @since v2.1 + */ + export function addSearchResolutionsOrder(order:string,front:boolean):void; + /** + * Add search path. + * + * @since v2.1 + */ + export function addSearchPath(path:string,front:boolean):void; + /** + * write ValueVector into a plist file + * + *@param vecData the ValueVector want to save + *@param fullPath The full path to the file you want to save a string + *@return bool + */ + export function writeValueVectorToFile(vecData:Array,fullPath:string):boolean; + /** + * Checks whether a file exists. + * + * @note If a relative path was passed in, it will be inserted a default root path at the beginning. + * @param filename The path of the file, it could be a relative or absolute path. + * @return True if the file exists, false if not. + */ + export function isFileExist(filename:string):boolean; + /**©∫ + * Purges full path caches. + */ + export function purgeCachedEntries():void; + /** + * Gets full path from a file name and the path of the relative file. + * @param filename The file name. + * @param relativeFile The path of the relative file. + * @return The full path. + * e.g. filename: hello.png, pszRelativeFile: /User/path1/path2/hello.plist + * Return: /User/path1/path2/hello.pvr (If there a a key(hello.png)-value(hello.pvr) in FilenameLookup dictionary. ) + * + */ + export function fullPathFromRelativeFile(filename:string,relativeFile:string):string; + /** + * Windows fopen can't support UTF-8 filename + * Need convert all parameters fopen and other 3rd-party libs + * + * @param filenameUtf8 std::string name file for conversion from utf-8 + * @return std::string ansi filename in current locale + */ + export function getSuitableFOpen(filenameUtf8:string):string; + /** + * write ValueMap into a plist file + * + *@param dict the ValueMap want to save + *@param fullPath The full path to the file you want to save a string + *@return bool + */ + export function writeValueMapToFile(dict:any,fullPath:string):string; + /** + * Gets filename extension is a suffix (separated from the base filename by a dot) in lower case. + * Examples of filename extensions are .png, .jpeg, .exe, .dmg and .txt. + * @param filePath The path of the file, it could be a relative or absolute path. + * @return suffix for filename in lower case or empty if a dot not found. + */ + export function getFileExtension(filePath:string):string; + /** + * Sets writable path. + */ + export function setWritablePath(writablePath:string):void; + /** + * Set default resource root path. + */ + export function setDefaultResourceRootPath(filepath:string):void; + + /** + * Gets the array that contains the search order of the resources. + * + * @see setSearchResolutionsOrder(const std::vector&), fullPathForFilename(const char*). + * @since v2.1 + * @lua NA + */ + export function getSearchResolutionsOrder():Array; + /** + * Creates a directory. + * + * @param dirPath The path of the directory, it must be an absolute path. + * @return True if the directory have been created successfully, false if not. + */ + export function createDirectory(dirPath:string):string; + /** + * List all files recursively in a directory. + * + * @param dirPath The path of the directory, it could be a relative or an absolute path. + * @return File paths in a string vector + */ + export function listFilesRecursively(dirPath:string, files:Array):void; + /** + * Gets the writable path. + * @return The path that can be write/read a file in + */ + export function getWritablePath():string; + } +} + +/** Running in the editor. */ +declare const CC_EDITOR: boolean; +/** Preview in browser or simulator. */ +declare const CC_PREVIEW: boolean; +/** Running in the editor or preview. */ +declare const CC_DEV: boolean; +/** Running in the editor or preview, or build in debug mode. */ +declare const CC_DEBUG: boolean; +/** Running in published project. */ +declare const CC_BUILD: boolean; +/** Running in native platforms (mobile app, desktop app, or simulator). */ +declare const CC_JSB: boolean; +/** Running in runtime environments. */ +declare const CC_RUNTIME: boolean; +/** Running in the engine's unit test. */ +declare const CC_TEST: boolean; +/** Running in the WeChat Mini Game. */ +declare const CC_WECHATGAME: boolean; diff --git a/DisplayScrollViewDemo/jsconfig.json b/DisplayScrollViewDemo/jsconfig.json new file mode 100644 index 0000000..80c2563 --- /dev/null +++ b/DisplayScrollViewDemo/jsconfig.json @@ -0,0 +1,15 @@ +{ + "compilerOptions": { + "target": "es6", + "module": "commonjs", + "experimentalDecorators": true + }, + "exclude": [ + "node_modules", + ".vscode", + "library", + "local", + "settings", + "temp" + ] +} \ No newline at end of file diff --git a/DisplayScrollViewDemo/project.json b/DisplayScrollViewDemo/project.json new file mode 100644 index 0000000..79db58b --- /dev/null +++ b/DisplayScrollViewDemo/project.json @@ -0,0 +1,8 @@ +{ + "engine": "cocos2d-html5", + "packages": "packages", + "version": "2.3.4", + "name": "DisplayDemo", + "id": "406e2846-e6d9-4a03-8987-c92356e9bf92", + "isNew": false +} \ No newline at end of file diff --git a/DisplayScrollViewDemo/settings/builder.json b/DisplayScrollViewDemo/settings/builder.json new file mode 100644 index 0000000..09f915c --- /dev/null +++ b/DisplayScrollViewDemo/settings/builder.json @@ -0,0 +1,13 @@ +{ + "excludeScenes": [], + "orientation": { + "landscapeLeft": true, + "landscapeRight": true, + "portrait": false, + "upsideDown": false + }, + "packageName": "org.cocos2d.helloworld", + "startScene": "2d2f792f-a40c-49bb-a189-ed176a246e49", + "title": "hello_world", + "webOrientation": "auto" +} \ No newline at end of file diff --git a/DisplayScrollViewDemo/settings/builder.panel.json b/DisplayScrollViewDemo/settings/builder.panel.json new file mode 100644 index 0000000..6a7c356 --- /dev/null +++ b/DisplayScrollViewDemo/settings/builder.panel.json @@ -0,0 +1,7 @@ +{ + "excludeScenes": [], + "packageName": "org.cocos2d.helloworld", + "platform": "web-mobile", + "startScene": "2d2f792f-a40c-49bb-a189-ed176a246e49", + "title": "HelloWorld" +} \ No newline at end of file diff --git a/DisplayScrollViewDemo/settings/project.json b/DisplayScrollViewDemo/settings/project.json new file mode 100644 index 0000000..1239abe --- /dev/null +++ b/DisplayScrollViewDemo/settings/project.json @@ -0,0 +1,36 @@ +{ + "collision-matrix": [ + [ + true + ] + ], + "excluded-modules": [], + "group-list": [ + "default" + ], + "start-scene": "2d2f792f-a40c-49bb-a189-ed176a246e49", + "design-resolution-width": 960, + "design-resolution-height": 640, + "fit-width": false, + "fit-height": true, + "use-project-simulator-setting": false, + "simulator-orientation": false, + "use-customize-simulator": false, + "simulator-resolution": { + "width": 960, + "height": 640 + }, + "last-module-event-record-time": 0, + "assets-sort-type": "name", + "facebook": { + "enable": false, + "appID": "", + "live": { + "enable": false + }, + "audience": { + "enable": false + } + }, + "migrate-history": [] +} diff --git a/DisplayScrollViewDemo/settings/services.json b/DisplayScrollViewDemo/settings/services.json new file mode 100644 index 0000000..599b09e --- /dev/null +++ b/DisplayScrollViewDemo/settings/services.json @@ -0,0 +1,6 @@ +{ + "game": { + "name": "未知游戏", + "appid": "UNKNOW" + } +} \ No newline at end of file diff --git a/DisplayScrollViewDemo/template-banner.png b/DisplayScrollViewDemo/template-banner.png new file mode 100644 index 0000000..d24a435 Binary files /dev/null and b/DisplayScrollViewDemo/template-banner.png differ diff --git a/DisplayScrollViewDemo/template.json b/DisplayScrollViewDemo/template.json new file mode 100644 index 0000000..3bcc784 --- /dev/null +++ b/DisplayScrollViewDemo/template.json @@ -0,0 +1,5 @@ +{ + "name": "TEMPLATES.helloworld.name", + "desc": "TEMPLATES.helloworld.desc", + "banner": "template-banner.png" +} \ No newline at end of file diff --git a/DisplayScrollViewDemo/tsconfig.json b/DisplayScrollViewDemo/tsconfig.json new file mode 100644 index 0000000..93c0b22 --- /dev/null +++ b/DisplayScrollViewDemo/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ "es2015", "es2017", "dom" ], + "target": "es5", + "experimentalDecorators": true, + "skipLibCheck": true, + "outDir": "temp/vscode-dist", + "forceConsistentCasingInFileNames": true + }, + "exclude": [ + "node_modules", + "library", + "local", + "temp", + "build", + "settings" + ] +} \ No newline at end of file diff --git a/DncryptDemo/.gitignore b/DncryptDemo/.gitignore new file mode 100644 index 0000000..0c09bf3 --- /dev/null +++ b/DncryptDemo/.gitignore @@ -0,0 +1,51 @@ +#///////////////////////////////////////////////////////////////////////////// +# Fireball Projects +#///////////////////////////////////////////////////////////////////////////// + +/library/ +/temp/ +/local/ +/build/ + +#///////////////////////////////////////////////////////////////////////////// +# npm files +#///////////////////////////////////////////////////////////////////////////// + +npm-debug.log +node_modules/ + +#///////////////////////////////////////////////////////////////////////////// +# Logs and databases +#///////////////////////////////////////////////////////////////////////////// + +*.log +*.sql +*.sqlite + +#///////////////////////////////////////////////////////////////////////////// +# files for debugger +#///////////////////////////////////////////////////////////////////////////// + +*.sln +*.pidb +*.suo + +#///////////////////////////////////////////////////////////////////////////// +# OS generated files +#///////////////////////////////////////////////////////////////////////////// + +.DS_Store +ehthumbs.db +Thumbs.db + +#///////////////////////////////////////////////////////////////////////////// +# WebStorm files +#///////////////////////////////////////////////////////////////////////////// + +.idea/ + +#////////////////////////// +# VS Code files +#////////////////////////// + +.vscode/ diff --git a/DncryptDemo/README.md b/DncryptDemo/README.md new file mode 100644 index 0000000..09b0019 --- /dev/null +++ b/DncryptDemo/README.md @@ -0,0 +1,2 @@ +# hello-world +Hello world new project template. diff --git a/DncryptDemo/assets/Scene.meta b/DncryptDemo/assets/Scene.meta new file mode 100644 index 0000000..7da30b0 --- /dev/null +++ b/DncryptDemo/assets/Scene.meta @@ -0,0 +1,6 @@ +{ + "ver": "1.0.1", + "uuid": "29f52784-2fca-467b-92e7-8fd9ef8c57b7", + "isGroup": false, + "subMetas": {} +} \ No newline at end of file diff --git a/DncryptDemo/assets/Scene/helloworld.fire b/DncryptDemo/assets/Scene/helloworld.fire new file mode 100644 index 0000000..c4782b3 --- /dev/null +++ b/DncryptDemo/assets/Scene/helloworld.fire @@ -0,0 +1,594 @@ +[ + { + "__type__": "cc.SceneAsset", + "_name": "", + "_objFlags": 0, + "_native": "", + "scene": { + "__id__": 1 + } + }, + { + "__type__": "cc.Scene", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + } + ], + "_active": true, + "_level": 0, + "_components": [], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_zIndex": 0, + "groupIndex": 0, + "autoReleaseAssets": false, + "_id": "2d2f792f-a40c-49bb-a189-ed176a246e49", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 0.3296875, + 0.3296875, + 1 + ] + } + }, + { + "__type__": "cc.Node", + "_name": "Canvas", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 3 + }, + { + "__id__": 5 + }, + { + "__id__": 8 + }, + { + "__id__": 10 + } + ], + "_active": true, + "_level": 0, + "_components": [ + { + "__id__": 12 + }, + { + "__id__": 13 + }, + { + "__id__": 14 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 252, + "g": 252, + "b": 252, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 960, + "height": 640 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "_zIndex": 0, + "groupIndex": 0, + "_id": "a286bbGknJLZpRpxROV6M94", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 480, + 320, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Node", + "_name": "Main Camera", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_level": 1, + "_components": [ + { + "__id__": 4 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "_zIndex": 0, + "groupIndex": 0, + "_id": "bajsC4KotFLZ6XLFLKnycL", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Camera", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 3 + }, + "_enabled": true, + "_cullingMask": 4294967295, + "_clearFlags": 7, + "_backgroundColor": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_depth": -1, + "_zoomRatio": 1, + "_targetTexture": null, + "_id": "c7r5+B15dD56dUBiNj+0KH" + }, + { + "__type__": "cc.Node", + "_name": "background", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_level": 0, + "_components": [ + { + "__id__": 6 + }, + { + "__id__": 7 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 27, + "g": 38, + "b": 46, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 960, + "height": 640 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "_zIndex": 0, + "groupIndex": 0, + "_id": "e2e0crkOLxGrpMxpbC4iQg1", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 5 + }, + "_enabled": true, + "alignMode": 1, + "_target": null, + "_alignFlags": 45, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 200, + "_originalHeight": 150, + "_id": "86+yud7pFDSrM+lsxByQvE" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 5 + }, + "_enabled": true, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "410fb916-8721-4663-bab8-34397391ace7" + }, + "_type": 1, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_state": 0, + "_atlas": null, + "_id": "1bi08CbSBHsZSXfV2t6eKB" + }, + { + "__type__": "cc.Node", + "_name": "cocos", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_level": 0, + "_components": [ + { + "__id__": 9 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 195, + "height": 270 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "_zIndex": 0, + "groupIndex": 0, + "_id": "c4f30YOS65G64U2TwufdJ+2", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 50, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 8 + }, + "_enabled": true, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "31bc895a-c003-4566-a9f3-2e54ae1c17dc" + }, + "_type": 0, + "_sizeMode": 1, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_state": 0, + "_atlas": null, + "_id": "42SM+92GZAXYsjLj89MLM+" + }, + { + "__type__": "cc.Node", + "_name": "label", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_level": 0, + "_components": [ + { + "__id__": 11 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 146.81, + "height": 60 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "_zIndex": 0, + "groupIndex": 0, + "_id": "31f1bH7V69Ajr1iXhluMpTB", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + -180, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 10 + }, + "_enabled": true, + "_srcBlendFactor": 1, + "_dstBlendFactor": 771, + "_useOriginalSize": false, + "_string": "Label", + "_N$string": "Label", + "_fontSize": 60, + "_lineHeight": 60, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_id": "74saCdhnNHjbyDsdd1bTTt" + }, + { + "__type__": "cc.Canvas", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "_designResolution": { + "__type__": "cc.Size", + "width": 960, + "height": 640 + }, + "_fitWidth": false, + "_fitHeight": true, + "_id": "6f5cteKmlPh6NGUsUqxlFR" + }, + { + "__type__": "280c3rsZJJKnZ9RqbALVwtK", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "label": { + "__id__": 11 + }, + "text": "Hello, World!", + "_id": "dcGJ+cSA5D7qNtScKfLjJJ" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "alignMode": 1, + "_target": null, + "_alignFlags": 45, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 0, + "_originalHeight": 0 + } +] \ No newline at end of file diff --git a/DncryptDemo/assets/Scene/helloworld.fire.meta b/DncryptDemo/assets/Scene/helloworld.fire.meta new file mode 100644 index 0000000..bf0b7c0 --- /dev/null +++ b/DncryptDemo/assets/Scene/helloworld.fire.meta @@ -0,0 +1,7 @@ +{ + "ver": "1.2.7", + "uuid": "2d2f792f-a40c-49bb-a189-ed176a246e49", + "asyncLoadAssets": false, + "autoReleaseAssets": false, + "subMetas": {} +} \ No newline at end of file diff --git a/DncryptDemo/assets/Script.meta b/DncryptDemo/assets/Script.meta new file mode 100644 index 0000000..7259168 --- /dev/null +++ b/DncryptDemo/assets/Script.meta @@ -0,0 +1,6 @@ +{ + "ver": "1.0.1", + "uuid": "4734c20c-0db8-4eb2-92ea-e692f4d70934", + "isGroup": false, + "subMetas": {} +} \ No newline at end of file diff --git a/DncryptDemo/assets/Script/HelloWorld.js b/DncryptDemo/assets/Script/HelloWorld.js new file mode 100644 index 0000000..8e286e9 --- /dev/null +++ b/DncryptDemo/assets/Script/HelloWorld.js @@ -0,0 +1,32 @@ + +const encrypt = require('encryptjs'); + +cc.Class({ + extends: cc.Component, + + properties: { + label: { + default: null, + type: cc.Label + }, + // defaults, set visually when attaching this script to the Canvas + text: 'Hello, World!' + }, + + // use this for initialization + onLoad: function () { + this.label.string = this.text; + let abc = 'aaaaaaaaaaa'; + let key = 'key'; + let encryStr = encrypt.encrypt(abc, key, 256); + console.log('abc=', encryStr); + + let decryStr = encrypt.decrypt(encryStr, key, 256); + console.log('abc', decryStr); + }, + + // called every frame + update: function (dt) { + + }, +}); diff --git a/DncryptDemo/assets/Script/HelloWorld.js.meta b/DncryptDemo/assets/Script/HelloWorld.js.meta new file mode 100644 index 0000000..e805d60 --- /dev/null +++ b/DncryptDemo/assets/Script/HelloWorld.js.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.8", + "uuid": "280c3aec-6492-4a9d-9f51-a9b00b570b4a", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/DncryptDemo/assets/Script/libs.meta b/DncryptDemo/assets/Script/libs.meta new file mode 100644 index 0000000..40df079 --- /dev/null +++ b/DncryptDemo/assets/Script/libs.meta @@ -0,0 +1,7 @@ +{ + "ver": "1.0.1", + "uuid": "5bba654d-86b6-417e-a001-4908a34e73eb", + "isSubpackage": false, + "subpackageName": "", + "subMetas": {} +} \ No newline at end of file diff --git a/DncryptDemo/assets/Script/libs/algo.js b/DncryptDemo/assets/Script/libs/algo.js new file mode 100644 index 0000000..bbb9176 --- /dev/null +++ b/DncryptDemo/assets/Script/libs/algo.js @@ -0,0 +1,209 @@ + +/* jshint node:true *//* global define */ +'use strict'; + + +/** + * Rijndael cipher encryption routines, + * + * Reference implementation of FIPS-197 http://csrc.nist.gov/publications/fips/fips197/fips-197.pdf. + * + * @namespace + */ +var Algo = {}; + + +/** + * Cipher function: encrypt 'input' state with Rijndael algorithm [§5.1]; + * applies Nr rounds (10/12/14) using key schedule w for 'add round key' stage. + * + * @param {number[]} input - 16-byte (128-bit) input state array. + * @param {number[][]} w - Key schedule as 2D byte-array (Nr+1 x Nb bytes). + * @returns {number[]} Encrypted output state array. + */ +Algo.cipher = function(input, w) { + var Nb = 4; // block size (in words): no of columns in state + var Nr = w.length/Nb - 1; // no of rounds: 10/12/14 for 128/192/256-bit keys + + var state = [[],[],[],[]]; // initialise 4xNb byte-array 'state' with input [§3.4] + for (var i=0; i<4*Nb; i++) state[i%4][Math.floor(i/4)] = input[i]; + + state = Algo.addRoundKey(state, w, 0, Nb); + + for (var round=1; round 6 && i%Nk == 4) { + temp = Algo.subWord(temp); + } + // xor w[i] with w[i-1] and w[i-Nk] + for (var t=0; t<4; t++) w[i][t] = w[i-Nk][t] ^ temp[t]; + } + + return w; +}; + + +/** + * Apply SBox to state S [§5.1.1] + * @private + */ +Algo.subBytes = function(s, Nb) { + for (var r=0; r<4; r++) { + for (var c=0; c + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +(function (name, definition) { + if (typeof exports !== 'undefined' && typeof module !== 'undefined') { + module.exports = definition(); + } else if (typeof define === 'function' && typeof define.amd === 'object') { + define(definition); + } else if (typeof define === 'function' && typeof define.petal === 'object') { + define(name, [], definition); + } else { + this[name] = definition(); + } +})('encryptjs', function (encryptjs) { + + 'use strict'; + + encryptjs = { version: '1.0.0' }; + + //Right before exporting the validator object, pass each of the builtins + //through extend() so that their first argument is coerced to a string + encryptjs.init = function () { + console.log("--------------------Applying Encryption Algorithm------------------ "); + }; + 'use strict'; + if (typeof module!='undefined' && module.exports) var Algo = require('algo'); // CommonJS (Node.js) + + encryptjs.encrypt = function(plaintext, password, nBits) { + var blockSize = 16; // block size fixed at 16 bytes / 128 bits (Nb=4) + if (!(nBits==128 || nBits==192 || nBits==256)) return ''; // standard allows 128/192/256 bit keys + plaintext = String(plaintext).utf8Encode(); + password = String(password).utf8Encode(); + + // use AES itself to encrypt password to get cipher key (using plain password as source for key + // expansion) - gives us well encrypted key (though hashed key might be preferred for prod'n use) + var nBytes = nBits/8; // no bytes in key (16/24/32) + var pwBytes = new Array(nBytes); + for (var i=0; i>> i*8) & 0xff; + for (var i=0; i<2; i++) counterBlock[i+2] = (nonceRnd >>> i*8) & 0xff; + for (var i=0; i<4; i++) counterBlock[i+4] = (nonceSec >>> i*8) & 0xff; + + // and convert it to a string to go on the front of the ciphertext + var ctrTxt = ''; + for (var i=0; i<8; i++) ctrTxt += String.fromCharCode(counterBlock[i]); + + // generate key schedule - an expansion of the key into distinct Key Rounds for each round + var keySchedule = Algo.keyExpansion(key); + + var blockCount = Math.ceil(plaintext.length/blockSize); + var ciphertxt = new Array(blockCount); // ciphertext as array of strings + + for (var b=0; b>> c*8) & 0xff; + for (var c=0; c<4; c++) counterBlock[15-c-4] = (b/0x100000000 >>> c*8); + + var cipherCntr = Algo.cipher(counterBlock, keySchedule); // -- encrypt counter block -- + + // block size is reduced on final block + var blockLength = b>> c*8) & 0xff; + for (var c=0; c<4; c++) counterBlock[15-c-4] = (((b+1)/0x100000000-1) >>> c*8) & 0xff; + + var cipherCntr = Algo.cipher(counterBlock, keySchedule); // encrypt counter block + + var plaintxtByte = new Array(ciphertext[b].length); + for (var i=0; i + Please DO NOT remove this String, it is an important flag for bug tracking.
+ If you post a bug to forum, please attach this flag. */ + export var ENGINE_VERSION: string; + /** + !#en + Creates the speed action which changes the speed of an action, making it take longer (speed > 1) + or less (speed < 1) time.
+ Useful to simulate 'slow motion' or 'fast forward' effect. + !#zh 修改目标动作的速率。 + @param action action + @param speed speed + + @example + ```js + // change the target action speed; + var action = cc.scaleTo(0.2, 1, 0.6); + var newAction = cc.speed(action, 0.5); + ``` + */ + export function speed(action: ActionInterval, speed: number): Action; + /** + !#en Create a follow action which makes its target follows another node. + !#zh 追踪目标节点的位置。 + @param followedNode followedNode + @param rect rect + + @example + ```js + // example + // creates the action with a set boundary + var followAction = cc.follow(targetNode, cc.rect(0, 0, screenWidth * 2 - 100, screenHeight)); + node.runAction(followAction); + + // creates the action with no boundary set + var followAction = cc.follow(targetNode); + node.runAction(followAction); + ``` + */ + export function follow(followedNode: Node, rect: Rect): Action; + /** + Points setter + @param points points + */ + export function setPoints(points: any[]): void; + /** + !#en Creates an action with a Cardinal Spline array of points and tension. + !#zh 按基数样条曲线轨迹移动到目标位置。 + @param duration duration + @param points array of control points + @param tension tension + + @example + ```js + //create a cc.CardinalSplineTo + var action1 = cc.cardinalSplineTo(3, array, 0); + ``` + */ + export function cardinalSplineTo(duration: number, points: any[], tension: number): ActionInterval; + /** + update position of target + @param newPos newPos + */ + export function updatePosition(newPos: Vec2): void; + /** + !#en Creates an action with a Cardinal Spline array of points and tension. + !#zh 按基数样条曲线轨迹移动指定的距离。 + @param duration duration + @param points points + @param tension tension + */ + export function cardinalSplineBy(duration: number, points: any[], tension: number): ActionInterval; + /** + !#en Creates an action with a Cardinal Spline array of points and tension. + !#zh 按 Catmull Rom 样条曲线轨迹移动到目标位置。 + @param dt dt + @param points points + + @example + ```js + var action1 = cc.catmullRomTo(3, array); + ``` + */ + export function catmullRomTo(dt: number, points: any[]): ActionInterval; + /** + !#en Creates an action with a Cardinal Spline array of points and tension. + !#zh 按 Catmull Rom 样条曲线轨迹移动指定的距离。 + @param dt dt + @param points points + + @example + ```js + var action1 = cc.catmullRomBy(3, array); + ``` + */ + export function catmullRomBy(dt: number, points: any[]): ActionInterval; + /** + !#en + Creates the action easing object with the rate parameter.
+ From slow to fast. + !#zh 创建 easeIn 缓动对象,由慢到快。 + @param rate rate + + @example + ```js + action.easing(cc.easeIn(3.0)); + ``` + */ + export function easeIn(rate: number): any; + /** + !#en + Creates the action easing object with the rate parameter.
+ From fast to slow. + !#zh 创建 easeOut 缓动对象,由快到慢。 + @param rate rate + + @example + ```js + action.easing(cc.easeOut(3.0)); + ``` + */ + export function easeOut(rate: number): any; + /** + !#en + Creates the action easing object with the rate parameter.
+ Slow to fast then to slow. + !#zh 创建 easeInOut 缓动对象,慢到快,然后慢。 + @param rate rate + + @example + ```js + action.easing(cc.easeInOut(3.0)); + ``` + */ + export function easeInOut(rate: number): any; + /** + !#en + Creates the action easing object with the rate parameter.
+ Reference easeInExpo:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeExponentialIn 缓动对象。
+ EaseExponentialIn 是按指数函数缓动进入的动作。
+ 参考 easeInExpo:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + action.easing(cc.easeExponentialIn()); + ``` + */ + export function easeExponentialIn(): any; + /** + !#en + Creates the action easing object.
+ Reference easeOutExpo:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeExponentialOut 缓动对象。
+ EaseExponentialOut 是按指数函数缓动退出的动作。
+ 参考 easeOutExpo:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + action.easing(cc.easeExponentialOut()); + ``` + */ + export function easeExponentialOut(): any; + /** + !#en + Creates an EaseExponentialInOut action easing object.
+ Reference easeInOutExpo:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeExponentialInOut 缓动对象。
+ EaseExponentialInOut 是按指数函数缓动进入并退出的动作。
+ 参考 easeInOutExpo:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + action.easing(cc.easeExponentialInOut()); + ``` + */ + export function easeExponentialInOut(): any; + /** + !#en + Creates an EaseSineIn action.
+ Reference easeInSine:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 EaseSineIn 缓动对象。
+ EaseSineIn 是按正弦函数缓动进入的动作。
+ 参考 easeInSine:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + action.easing(cc.easeSineIn()); + ``` + */ + export function easeSineIn(): any; + /** + !#en + Creates an EaseSineOut action easing object.
+ Reference easeOutSine:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 EaseSineOut 缓动对象。
+ EaseSineIn 是按正弦函数缓动退出的动作。
+ 参考 easeOutSine:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + action.easing(cc.easeSineOut()); + ``` + */ + export function easeSineOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInOutSine:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeSineInOut 缓动对象。
+ EaseSineIn 是按正弦函数缓动进入并退出的动作。
+ 参考 easeInOutSine:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + action.easing(cc.easeSineInOut()); + ``` + */ + export function easeSineInOut(): any; + /** + !#en + Creates the action easing object with the period in radians (default is 0.3).
+ Reference easeInElastic:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeElasticIn 缓动对象。
+ EaseElasticIn 是按弹性曲线缓动进入的动作。
+ 参数 easeInElastic:http://www.zhihu.com/question/21981571/answer/19925418 + @param period period + + @example + ```js + // example + action.easing(cc.easeElasticIn(3.0)); + ``` + */ + export function easeElasticIn(period: number): any; + /** + !#en + Creates the action easing object with the period in radians (default is 0.3).
+ Reference easeOutElastic:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeElasticOut 缓动对象。
+ EaseElasticOut 是按弹性曲线缓动退出的动作。
+ 参考 easeOutElastic:http://www.zhihu.com/question/21981571/answer/19925418 + @param period period + + @example + ```js + // example + action.easing(cc.easeElasticOut(3.0)); + ``` + */ + export function easeElasticOut(period: number): any; + /** + !#en + Creates the action easing object with the period in radians (default is 0.3).
+ Reference easeInOutElastic:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeElasticInOut 缓动对象。
+ EaseElasticInOut 是按弹性曲线缓动进入并退出的动作。
+ 参考 easeInOutElastic:http://www.zhihu.com/question/21981571/answer/19925418 + @param period period + + @example + ```js + // example + action.easing(cc.easeElasticInOut(3.0)); + ``` + */ + export function easeElasticInOut(period: number): any; + /** + !#en + Creates the action easing object.
+ Eased bounce effect at the beginning. + !#zh + 创建 easeBounceIn 缓动对象。
+ EaseBounceIn 是按弹跳动作缓动进入的动作。 + + @example + ```js + // example + action.easing(cc.easeBounceIn()); + ``` + */ + export function easeBounceIn(): any; + /** + !#en + Creates the action easing object.
+ Eased bounce effect at the ending. + !#zh + 创建 easeBounceOut 缓动对象。
+ EaseBounceOut 是按弹跳动作缓动退出的动作。 + + @example + ```js + // example + action.easing(cc.easeBounceOut()); + ``` + */ + export function easeBounceOut(): any; + /** + !#en + Creates the action easing object.
+ Eased bounce effect at the begining and ending. + !#zh + 创建 easeBounceInOut 缓动对象。
+ EaseBounceInOut 是按弹跳动作缓动进入并退出的动作。 + + @example + ```js + // example + action.easing(cc.easeBounceInOut()); + ``` + */ + export function easeBounceInOut(): any; + /** + !#en + Creates the action easing object.
+ In the opposite direction to move slowly, and then accelerated to the right direction. + !#zh + 创建 easeBackIn 缓动对象。
+ easeBackIn 是在相反的方向缓慢移动,然后加速到正确的方向。
+ + @example + ```js + // example + action.easing(cc.easeBackIn()); + ``` + */ + export function easeBackIn(): any; + /** + !#en + Creates the action easing object.
+ Fast moving more than the finish, and then slowly back to the finish. + !#zh + 创建 easeBackOut 缓动对象。
+ easeBackOut 快速移动超出目标,然后慢慢回到目标点。 + + @example + ```js + // example + action.easing(cc.easeBackOut()); + ``` + */ + export function easeBackOut(): any; + /** + !#en + Creates the action easing object.
+ Begining of cc.EaseBackIn. Ending of cc.EaseBackOut. + !#zh + 创建 easeBackInOut 缓动对象。
+ + @example + ```js + // example + action.easing(cc.easeBackInOut()); + ``` + */ + export function easeBackInOut(): any; + /** + !#en + Creates the action easing object.
+ Into the 4 reference point.
+ To calculate the motion curve. + !#zh + 创建 easeBezierAction 缓动对象。
+ EaseBezierAction 是按贝塞尔曲线缓动的动作。 + @param p0 The first bezier parameter + @param p1 The second bezier parameter + @param p2 The third bezier parameter + @param p3 The fourth bezier parameter + + @example + ```js + // example + action.easing(cc.easeBezierAction(0.5, 0.5, 1.0, 1.0)); + ``` + */ + export function easeBezierAction(p0: number, p1: number, p2: number, p3: number): any; + /** + !#en + Creates the action easing object.
+ Reference easeInQuad:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuadraticActionIn 缓动对象。
+ EaseQuadraticIn是按二次函数缓动进入的动作。
+ 参考 easeInQuad:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeQuadraticActionIn()); + ``` + */ + export function easeQuadraticActionIn(): any; + /** + !#en + Creates the action easing object.
+ Reference easeOutQuad:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuadraticActionOut 缓动对象。
+ EaseQuadraticOut 是按二次函数缓动退出的动作。
+ 参考 easeOutQuad:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeQuadraticActionOut()); + ``` + */ + export function easeQuadraticActionOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInOutQuad:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuadraticActionInOut 缓动对象。
+ EaseQuadraticInOut 是按二次函数缓动进入并退出的动作。
+ 参考 easeInOutQuad:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeQuadraticActionInOut()); + ``` + */ + export function easeQuadraticActionInOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeIntQuart:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuarticActionIn 缓动对象。
+ EaseQuarticIn 是按四次函数缓动进入的动作。
+ 参考 easeIntQuart:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeQuarticActionIn()); + ``` + */ + export function easeQuarticActionIn(): any; + /** + !#en + Creates the action easing object.
+ Reference easeOutQuart:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuarticActionOut 缓动对象。
+ EaseQuarticOut 是按四次函数缓动退出的动作。
+ 参考 easeOutQuart:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.QuarticActionOut()); + ``` + */ + export function easeQuarticActionOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInOutQuart:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuarticActionInOut 缓动对象。
+ EaseQuarticInOut 是按四次函数缓动进入并退出的动作。
+ 参考 easeInOutQuart:http://www.zhihu.com/question/21981571/answer/19925418 + */ + export function easeQuarticActionInOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInQuint:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuinticActionIn 缓动对象。
+ EaseQuinticIn 是按五次函数缓动进的动作。
+ 参考 easeInQuint:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeQuinticActionIn()); + ``` + */ + export function easeQuinticActionIn(): any; + /** + !#en + Creates the action easing object.
+ Reference easeOutQuint:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuinticActionOut 缓动对象。
+ EaseQuinticOut 是按五次函数缓动退出的动作 + 参考 easeOutQuint:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeQuadraticActionOut()); + ``` + */ + export function easeQuinticActionOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInOutQuint:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuinticActionInOut 缓动对象。
+ EaseQuinticInOut是按五次函数缓动进入并退出的动作。
+ 参考 easeInOutQuint:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeQuinticActionInOut()); + ``` + */ + export function easeQuinticActionInOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInCirc:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeCircleActionIn 缓动对象。
+ EaseCircleIn是按圆形曲线缓动进入的动作。
+ 参考 easeInCirc:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeCircleActionIn()); + ``` + */ + export function easeCircleActionIn(): any; + /** + !#en + Creates the action easing object.
+ Reference easeOutCirc:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeCircleActionOut 缓动对象。
+ EaseCircleOut是按圆形曲线缓动退出的动作。
+ 参考 easeOutCirc:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + actioneasing(cc.easeCircleActionOut()); + ``` + */ + export function easeCircleActionOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInOutCirc:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeCircleActionInOut 缓动对象。
+ EaseCircleInOut 是按圆形曲线缓动进入并退出的动作。
+ 参考 easeInOutCirc:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeCircleActionInOut()); + ``` + */ + export function easeCircleActionInOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInCubic:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeCubicActionIn 缓动对象。
+ EaseCubicIn 是按三次函数缓动进入的动作。
+ 参考 easeInCubic:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeCubicActionIn()); + ``` + */ + export function easeCubicActionIn(): any; + /** + !#en + Creates the action easing object.
+ Reference easeOutCubic:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeCubicActionOut 缓动对象。
+ EaseCubicOut 是按三次函数缓动退出的动作。
+ 参考 easeOutCubic:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeCubicActionOut()); + ``` + */ + export function easeCubicActionOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInOutCubic:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeCubicActionInOut 缓动对象。
+ EaseCubicInOut是按三次函数缓动进入并退出的动作。
+ 参考 easeInOutCubic:http://www.zhihu.com/question/21981571/answer/19925418 + */ + export function easeCubicActionInOut(): any; + /** + !#en Show the Node. + !#zh 立即显示。 + + @example + ```js + // example + var showAction = cc.show(); + ``` + */ + export function show(): ActionInstant; + /** + !#en Hide the node. + !#zh 立即隐藏。 + + @example + ```js + // example + var hideAction = cc.hide(); + ``` + */ + export function hide(): ActionInstant; + /** + !#en Toggles the visibility of a node. + !#zh 显隐状态切换。 + + @example + ```js + // example + var toggleVisibilityAction = cc.toggleVisibility(); + ``` + */ + export function toggleVisibility(): ActionInstant; + /** + !#en Create a RemoveSelf object with a flag indicate whether the target should be cleaned up while removing. + !#zh 从父节点移除自身。 + @param isNeedCleanUp isNeedCleanUp + + @example + ```js + // example + var removeSelfAction = cc.removeSelf(); + ``` + */ + export function removeSelf(isNeedCleanUp ?: boolean): ActionInstant; + /** + !#en Destroy self + !#zh 创建一个销毁自身的动作。 + + @example + ```js + var destroySelfAction = cc.destroySelf(); + ``` + */ + export function destroySelf(): ActionInstant; + /** + !#en Create a FlipX action to flip or unflip the target. + !#zh X轴翻转。 + @param flip Indicate whether the target should be flipped or not + + @example + ```js + var flipXAction = cc.flipX(true); + ``` + */ + export function flipX(flip: boolean): ActionInstant; + /** + !#en Create a FlipY action to flip or unflip the target. + !#zh Y轴翻转。 + @param flip flip + + @example + ```js + var flipYAction = cc.flipY(true); + ``` + */ + export function flipY(flip: boolean): ActionInstant; + /** + !#en Creates a Place action with a position. + !#zh 放置在目标位置。 + @param pos pos + @param y y + + @example + ```js + // example + var placeAction = cc.place(cc.v2(200, 200)); + var placeAction = cc.place(200, 200); + ``` + */ + export function place(pos: Vec2|number, y?: number): ActionInstant; + /** + !#en Creates the action with the callback. + !#zh 执行回调函数。 + @param selector selector + @param selectorTarget selectorTarget + @param data data for function, it accepts all data types. + + @example + ```js + // example + // CallFunc without data + var finish = cc.callFunc(this.removeSprite, this); + + // CallFunc with data + var finish = cc.callFunc(this.removeFromParentAndCleanup, this._grossini, true); + ``` + */ + export function callFunc(selector: Function, selectorTarget?: any, data?: any): ActionInstant; + /** + !#en + Helper constructor to create an array of sequenceable actions + The created action will run actions sequentially, one after another. + !#zh 顺序执行动作,创建的动作将按顺序依次运行。 + @param actionOrActionArray actionOrActionArray + @param tempArray tempArray + + @example + ```js + // example + // create sequence with actions + var seq = cc.sequence(act1, act2); + + // create sequence with array + var seq = cc.sequence(actArray); + ``` + */ + export function sequence(actionOrActionArray: FiniteTimeAction|FiniteTimeAction[], ...tempArray: FiniteTimeAction[]): ActionInterval; + /** + !#en Creates a Repeat action. Times is an unsigned integer between 1 and pow(2,30) + !#zh 重复动作,可以按一定次数重复一个动,如果想永远重复一个动作请使用 repeatForever 动作来完成。 + @param action action + @param times times + + @example + ```js + // example + var rep = cc.repeat(cc.sequence(jump2, jump1), 5); + ``` + */ + export function repeat(action: FiniteTimeAction, times: number): ActionInterval; + /** + !#en Create a acton which repeat forever, as it runs forever, it can't be added into cc.sequence and cc.spawn. + !#zh 永远地重复一个动作,有限次数内重复一个动作请使用 repeat 动作,由于这个动作不会停止,所以不能被添加到 cc.sequence 或 cc.spawn 中。 + @param action action + + @example + ```js + // example + var repeat = cc.repeatForever(cc.rotateBy(1.0, 360)); + ``` + */ + export function repeatForever(action: FiniteTimeAction): ActionInterval; + /** + !#en Create a spawn action which runs several actions in parallel. + !#zh 同步执行动作,同步执行一组动作。 + @param actionOrActionArray actionOrActionArray + @param tempArray tempArray + + @example + ```js + // example + var action = cc.spawn(cc.jumpBy(2, cc.v2(300, 0), 50, 4), cc.rotateBy(2, 720)); + todo:It should be the direct use new + ``` + */ + export function spawn(actionOrActionArray: FiniteTimeAction|FiniteTimeAction[], ...tempArray: FiniteTimeAction[]): FiniteTimeAction; + /** + !#en + Rotates a Node object to a certain angle by modifying its angle property.
+ The direction will be decided by the shortest angle. + !#zh 旋转到目标角度,通过逐帧修改它的 angle 属性,旋转方向将由最短的角度决定。 + @param duration duration in seconds + @param dstAngle dstAngle in degrees. + + @example + ```js + // example + var rotateTo = cc.rotateTo(2, 61.0); + ``` + */ + export function rotateTo(duration: number, dstAngle: number): ActionInterval; + /** + !#en + Rotates a Node object clockwise a number of degrees by modifying its angle property. + Relative to its properties to modify. + !#zh 旋转指定的角度。 + @param duration duration in seconds + @param deltaAngle deltaAngle in degrees + + @example + ```js + // example + var actionBy = cc.rotateBy(2, 360); + ``` + */ + export function rotateBy(duration: number, deltaAngle: number): ActionInterval; + /** + !#en + Moves a Node object x,y pixels by modifying its position property.
+ x and y are relative to the position of the object.
+ Several MoveBy actions can be concurrently called, and the resulting
+ movement will be the sum of individual movements. + !#zh 移动指定的距离。 + @param duration duration in seconds + @param deltaPos deltaPos + @param deltaY deltaY + + @example + ```js + // example + var actionTo = cc.moveBy(2, cc.v2(windowSize.width - 40, windowSize.height - 40)); + ``` + */ + export function moveBy(duration: number, deltaPos: Vec2|number, deltaY?: number): ActionInterval; + /** + !#en + Moves a Node object to the position x,y. x and y are absolute coordinates by modifying its position property.
+ Several MoveTo actions can be concurrently called, and the resulting
+ movement will be the sum of individual movements. + !#zh 移动到目标位置。 + @param duration duration in seconds + @param position position + @param y y + + @example + ```js + // example + var actionBy = cc.moveTo(2, cc.v2(80, 80)); + ``` + */ + export function moveTo(duration: number, position: Vec2|number, y?: number): ActionInterval; + /** + !#en + Create a action which skews a Node object to given angles by modifying its skewX and skewY properties. + Changes to the specified value. + !#zh 偏斜到目标角度。 + @param t time in seconds + @param sx sx + @param sy sy + + @example + ```js + // example + var actionTo = cc.skewTo(2, 37.2, -37.2); + ``` + */ + export function skewTo(t: number, sx: number, sy: number): ActionInterval; + /** + !#en + Skews a Node object by skewX and skewY degrees.
+ Relative to its property modification. + !#zh 偏斜指定的角度。 + @param t time in seconds + @param sx sx skew in degrees for X axis + @param sy sy skew in degrees for Y axis + + @example + ```js + // example + var actionBy = cc.skewBy(2, 0, -90); + ``` + */ + export function skewBy(t: number, sx: number, sy: number): ActionInterval; + /** + !#en + Moves a Node object simulating a parabolic jump movement by modifying it's position property. + Relative to its movement. + !#zh 用跳跃的方式移动指定的距离。 + @param duration duration + @param position position + @param y y + @param height height + @param jumps jumps + + @example + ```js + // example + var actionBy = cc.jumpBy(2, cc.v2(300, 0), 50, 4); + var actionBy = cc.jumpBy(2, 300, 0, 50, 4); + ``` + */ + export function jumpBy(duration: number, position: Vec2|number, y?: number, height?: number, jumps?: number): ActionInterval; + /** + !#en + Moves a Node object to a parabolic position simulating a jump movement by modifying its position property.
+ Jump to the specified location. + !#zh 用跳跃的方式移动到目标位置。 + @param duration duration + @param position position + @param y y + @param height height + @param jumps jumps + + @example + ```js + // example + var actionTo = cc.jumpTo(2, cc.v2(300, 300), 50, 4); + var actionTo = cc.jumpTo(2, 300, 300, 50, 4); + ``` + */ + export function jumpTo(duration: number, position: Vec2|number, y?: number, height?: number, jumps?: number): ActionInterval; + /** + !#en + An action that moves the target with a cubic Bezier curve by a certain distance. + Relative to its movement. + !#zh 按贝赛尔曲线轨迹移动指定的距离。 + @param t time in seconds + @param c Array of points + + @example + ```js + // example + var bezier = [cc.v2(0, windowSize.height / 2), cc.v2(300, -windowSize.height / 2), cc.v2(300, 100)]; + var bezierForward = cc.bezierBy(3, bezier); + ``` + */ + export function bezierBy(t: number, c: Vec2[]): ActionInterval; + /** + !#en An action that moves the target with a cubic Bezier curve to a destination point. + !#zh 按贝赛尔曲线轨迹移动到目标位置。 + @param t t + @param c Array of points + + @example + ```js + // example + var bezier = [cc.v2(0, windowSize.height / 2), cc.v2(300, -windowSize.height / 2), cc.v2(300, 100)]; + var bezierTo = cc.bezierTo(2, bezier); + ``` + */ + export function bezierTo(t: number, c: Vec2[]): ActionInterval; + /** + !#en Scales a Node object to a zoom factor by modifying it's scale property. + !#zh 将节点大小缩放到指定的倍数。 + @param duration duration + @param sx scale parameter in X + @param sy scale parameter in Y, if Null equal to sx + + @example + ```js + // example + // It scales to 0.5 in both X and Y. + var actionTo = cc.scaleTo(2, 0.5); + + // It scales to 0.5 in x and 2 in Y + var actionTo = cc.scaleTo(2, 0.5, 2); + ``` + */ + export function scaleTo(duration: number, sx: number, sy?: number): ActionInterval; + /** + !#en + Scales a Node object a zoom factor by modifying it's scale property. + Relative to its changes. + !#zh 按指定的倍数缩放节点大小。 + @param duration duration in seconds + @param sx sx scale parameter in X + @param sy sy scale parameter in Y, if Null equal to sx + + @example + ```js + // example without sy, it scales by 2 both in X and Y + var actionBy = cc.scaleBy(2, 2); + + //example with sy, it scales by 0.25 in X and 4.5 in Y + var actionBy2 = cc.scaleBy(2, 0.25, 4.5); + ``` + */ + export function scaleBy(duration: number, sx: number, sy?: number|void): ActionInterval; + /** + !#en Blinks a Node object by modifying it's visible property. + !#zh 闪烁(基于透明度)。 + @param duration duration in seconds + @param blinks blinks in times + + @example + ```js + // example + var action = cc.blink(2, 10); + ``` + */ + export function blink(duration: number, blinks: number): ActionInterval; + /** + !#en + Fades an object that implements the cc.RGBAProtocol protocol. + It modifies the opacity from the current value to a custom one. + !#zh 修改透明度到指定值。 + @param duration duration + @param opacity 0-255, 0 is transparent + + @example + ```js + // example + var action = cc.fadeTo(1.0, 0); + ``` + */ + export function fadeTo(duration: number, opacity: number): ActionInterval; + /** + !#en Fades In an object that implements the cc.RGBAProtocol protocol. It modifies the opacity from 0 to 255. + !#zh 渐显效果。 + @param duration duration in seconds + + @example + ```js + //example + var action = cc.fadeIn(1.0); + ``` + */ + export function fadeIn(duration: number): ActionInterval; + /** + !#en Fades Out an object that implements the cc.RGBAProtocol protocol. It modifies the opacity from 255 to 0. + !#zh 渐隐效果。 + @param d duration in seconds + + @example + ```js + // example + var action = cc.fadeOut(1.0); + ``` + */ + export function fadeOut(d: number): ActionInterval; + /** + !#en Tints a Node that implements the cc.NodeRGB protocol from current tint to a custom one. + !#zh 修改颜色到指定值。 + @param duration duration + @param red 0-255 + @param green 0-255 + @param blue 0-255 + + @example + ```js + // example + var action = cc.tintTo(2, 255, 0, 255); + ``` + */ + export function tintTo(duration: number, red: number, green: number, blue: number): ActionInterval; + /** + !#en + Tints a Node that implements the cc.NodeRGB protocol from current tint to a custom one. + Relative to their own color change. + !#zh 按照指定的增量修改颜色。 + @param duration duration in seconds + @param deltaRed deltaRed + @param deltaGreen deltaGreen + @param deltaBlue deltaBlue + + @example + ```js + // example + var action = cc.tintBy(2, -127, -255, -127); + ``` + */ + export function tintBy(duration: number, deltaRed: number, deltaGreen: number, deltaBlue: number): ActionInterval; + /** + !#en Delays the action a certain amount of seconds. + !#zh 延迟指定的时间量。 + @param d duration in seconds + + @example + ```js + // example + var delay = cc.delayTime(1); + ``` + */ + export function delayTime(d: number): ActionInterval; + /** + !#en Executes an action in reverse order, from time=duration to time=0. + !#zh 反转目标动作的时间轴。 + @param action action + + @example + ```js + // example + var reverse = cc.reverseTime(this); + ``` + */ + export function reverseTime(action: FiniteTimeAction): ActionInterval; + /** + !#en Create an action with the specified action and forced target. + !#zh 用已有动作和一个新的目标节点创建动作。 + @param target target + @param action action + */ + export function targetedAction(target: Node, action: FiniteTimeAction): ActionInterval; + /** + + @param target the target to animate + */ + export function tween (target?: Object) : Tween; + /** !#en This is a Easing instance. + !#zh 这是一个 Easing 类实例。 */ + export var easing: Easing; + /** + !#en + Outputs an error message to the Cocos Creator Console (editor) or Web Console (runtime).
+ - In Cocos Creator, error is red.
+ - In Chrome, error have a red icon along with red message text.
+ !#zh + 输出错误消息到 Cocos Creator 编辑器的 Console 或运行时页面端的 Console 中。
+ - 在 Cocos Creator 中,错误信息显示是红色的。
+ - 在 Chrome 中,错误信息有红色的图标以及红色的消息文本。
+ @param msg A JavaScript string containing zero or more substitution strings. + @param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output. + */ + export function error(msg: any, ...subst: any[]): void; + /** + !#en + Outputs a warning message to the Cocos Creator Console (editor) or Web Console (runtime). + - In Cocos Creator, warning is yellow. + - In Chrome, warning have a yellow warning icon with the message text. + !#zh + 输出警告消息到 Cocos Creator 编辑器的 Console 或运行时 Web 端的 Console 中。
+ - 在 Cocos Creator 中,警告信息显示是黄色的。
+ - 在 Chrome 中,警告信息有着黄色的图标以及黄色的消息文本。
+ @param msg A JavaScript string containing zero or more substitution strings. + @param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output. + */ + export function warn(msg: any, ...subst: any[]): void; + /** + !#en Outputs a message to the Cocos Creator Console (editor) or Web Console (runtime). + !#zh 输出一条消息到 Cocos Creator 编辑器的 Console 或运行时 Web 端的 Console 中。 + @param msg A JavaScript string containing zero or more substitution strings. + @param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output. + */ + export function log(msg: string|any, ...subst: any[]): void; + /** !#en This is a Game instance. + !#zh 这是一个 Game 类的实例,包含游戏主体信息并负责驱动游戏的游戏对象。。 */ + export var game: Game; + /** !#en Director + !#zh 导演类。 */ + export var director: Director; + /** + !#en + Rotates a Node object to a certain angle by modifying its quternion property.
+ The direction will be decided by the shortest angle. + !#zh 旋转到目标角度,通过逐帧修改它的 quternion 属性,旋转方向将由最短的角度决定。 + @param duration duration in seconds + @param dstAngleX dstAngleX in degrees. + @param dstAngleY dstAngleY in degrees. + @param dstAngleZ dstAngleZ in degrees. + + @example + ```js + // example + var rotate3DTo = cc.rotate3DTo(2, cc.v3(0, 180, 0)); + ``` + */ + export function rotate3DTo(duration: number, dstAngleX: number|Vec3|Quat, dstAngleY?: number, dstAngleZ?: number): ActionInterval; + /** + !#en + Rotates a Node object counter clockwise a number of degrees by modifying its quaternion property. + Relative to its properties to modify. + !#zh 旋转指定的 3D 角度。 + @param duration duration in seconds + @param deltaAngleX deltaAngleX in degrees + @param deltaAngleY deltaAngleY in degrees + @param deltaAngleZ deltaAngleZ in degrees + + @example + ```js + // example + var actionBy = cc.rotate3DBy(2, cc.v3(0, 360, 0)); + ``` + */ + export function rotate3DBy(duration: number, deltaAngleX: number|Vec3, deltaAngleY?: number, deltaAngleZ?: number): ActionInterval; + /** !#en The System event singleton for global usage + !#zh 系统事件单例,方便全局使用 */ + export var systemEvent: SystemEvent; + /** The offset of the range. */ + export var offset: number; + /** The length of the range. */ + export var length: number; + /** The data range of this bundle. + This range of data is essentially mapped to a GPU vertex buffer. */ + export var data: BufferRange; + /** The attribute formats. */ + export var formats: VertexFormat; + /** The vertex bundle that the primitive use. */ + export var vertexBundleIndices: number[]; + /** The data range of the primitive. + This range of data is essentially mapped to a GPU indices buffer. */ + export var data: BufferRange; + /** The type of this primitive's indices. */ + export var indexUnit: number; + /** The primitive's topology. */ + export var topology: number; + /** + Finds a node by hierarchy path, the path is case-sensitive. + It will traverse the hierarchy by splitting the path using '/' character. + This function will still returns the node even if it is inactive. + It is recommended to not use this function every frame instead cache the result at startup. + @param path path + @param referenceNode referenceNode + */ + export function find(path: string, referenceNode?: Node): Node; + /** + !#en + The convenience method to create a new {{#crossLink "Color/Color:method"}}cc.Color{{/crossLink}} + Alpha channel is optional. Default value is 255. + + !#zh + 通过该方法来创建一个新的 {{#crossLink "Color/Color:method"}}cc.Color{{/crossLink}} 对象。 + Alpha 通道是可选的。默认值是 255。 + @param r r + @param g g + @param b b + @param a a + + @example + ```js + ----------------------- + // 1. All channels seperately as parameters + var color1 = new cc.Color(255, 255, 255, 255); + // 2. Convert a hex string to a color + var color2 = new cc.Color("#000000"); + // 3. An color object as parameter + var color3 = new cc.Color({r: 255, g: 255, b: 255, a: 255}); + + ``` + */ + export function color(r?: number, g?: number, b?: number, a?: number): Color; + /** Identity of Mat3 */ + export var IDENTITY: Mat3; + /** + !#zh 矩阵转数组 + !#en Matrix transpose array + @param ofs 数组内的起始偏移量 + */ + export function toArray > (out: Out, mat: IMat3Like, ofs = 0); + /** + !#zh 数组转矩阵 + !#en Transfer matrix array + @param ofs 数组起始偏移量 + */ + export function fromArray (out: Out, arr: IWritableArrayLike, ofs = 0); + /** !#en Matrix Data + !#zh 矩阵数据 */ + export var m: Float64Array|Float32Array; + export function constructor (m00: number | Float32Array = 1, m01 = 0, m02 = 0, m03 = 0, m04 = 1, m05 = 0, m06 = 0, m07 = 0, m08 = 1); + /** + !#en The convenience method to create a new {{#crossLink "Mat4"}}cc.Mat4{{/crossLink}}. + !#zh 通过该简便的函数进行创建 {{#crossLink "Mat4"}}cc.Mat4{{/crossLink}} 对象。 + @param m00 Component in column 0, row 0 position (index 0) + @param m01 Component in column 0, row 1 position (index 1) + @param m02 Component in column 0, row 2 position (index 2) + @param m03 Component in column 0, row 3 position (index 3) + @param m10 Component in column 1, row 0 position (index 4) + @param m11 Component in column 1, row 1 position (index 5) + @param m12 Component in column 1, row 2 position (index 6) + @param m13 Component in column 1, row 3 position (index 7) + @param m20 Component in column 2, row 0 position (index 8) + @param m21 Component in column 2, row 1 position (index 9) + @param m22 Component in column 2, row 2 position (index 10) + @param m23 Component in column 2, row 3 position (index 11) + @param m30 Component in column 3, row 0 position (index 12) + @param m31 Component in column 3, row 1 position (index 13) + @param m32 Component in column 3, row 2 position (index 14) + @param m33 Component in column 3, row 3 position (index 15) + */ + export function mat4(m00?: number, m01?: number, m02?: number, m03?: number, m10?: number, m11?: number, m12?: number, m13?: number, m20?: number, m21?: number, m22?: number, m23?: number, m30?: number, m31?: number, m32?: number, m33?: number): Mat4; + /** + !#en The convenience method to create a new {{#crossLink "Quat"}}cc.Quat{{/crossLink}}. + !#zh 通过该简便的函数进行创建 {{#crossLink "Quat"}}cc.Quat{{/crossLink}} 对象。 + @param x x + @param y y + @param z z + @param w w + */ + export function quat(x?: number|any, y?: number, z?: number, w?: number): Quat; + /** + !#en + The convenience method to create a new Rect. + see {{#crossLink "Rect/Rect:method"}}cc.Rect{{/crossLink}} + !#zh + 该方法用来快速创建一个新的矩形。{{#crossLink "Rect/Rect:method"}}cc.Rect{{/crossLink}} + @param x x + @param y y + @param w w + @param h h + + @example + ```js + var a = new cc.Rect(0 , 0, 10, 0); + ``` + */ + export function rect(x?: number, y?: number, w?: number, h?: number): Rect; + /** + !#en + Helper function that creates a cc.Size.
+ Please use cc.p or cc.v2 instead, it will soon replace cc.Size. + !#zh + 创建一个 cc.Size 对象的帮助函数。
+ 注意:可以使用 cc.p 或者是 cc.v2 代替,它们将很快取代 cc.Size。 + @param w width or a size object + @param h height + + @example + ```js + var size1 = cc.size(); + var size2 = cc.size(100,100); + var size3 = cc.size(size2); + var size4 = cc.size({width: 100, height: 100}); + + ``` + */ + export function size(w: number|Size, h?: number): Size; + export var EPSILON: number; + /** + Clamps a value between a minimum float and maximum float value. + @param val val + @param min min + @param max max + */ + export function clamp(val: number, min: number, max: number): number; + /** + Clamps a value between 0 and 1. + @param val val + */ + export function clamp01(val: number): number; + /** + + @param from from + @param to to + @param ratio the interpolation coefficient + */ + export function lerp(from: number, to: number, ratio: number): number; + export function random(): void; + /** + Returns a floating-point random number between min (inclusive) and max (exclusive). + @param min min + @param max max + */ + export function randomRange(min: number, max: number): number; + /** + Returns a random integer between min (inclusive) and max (exclusive). + @param min min + @param max max + */ + export function randomRangeInt(min: number, max: number): number; + /** + Linear congruential generator using Hull-Dobell Theorem. + @param seed the random seed + */ + export function pseudoRandom(seed: number): number; + /** + Returns a floating-point pseudo-random number between min (inclusive) and max (exclusive). + @param seed seed + @param min min + @param max max + */ + export function pseudoRandomRange(seed: number, min: number, max: number): number; + /** + Returns a pseudo-random integer between min (inclusive) and max (exclusive). + @param seed seed + @param min min + @param max max + */ + export function pseudoRandomRangeInt(seed: number, min: number, max: number): number; + /** + Returns the next power of two for the value + @param val val + */ + export function nextPow2(val: number): number; + /** + Returns float remainder for t / length + @param t time start at 0 + @param length time of one cycle + */ + export function repeat(t: number, length: number): number; + /** + Returns time wrapped in ping-pong mode + @param t time start at 0 + @param length time of one cycle + */ + export function repeat(t: number, length: number): number; + /** + Returns ratio of a value within a given range + @param from start value + @param to end value + @param value given value + */ + export function repeat(from: number, to: number, value: number): number; + /** + Returns -1, 0, +1 depending on sign of x. + @param v v + */ + export function sign(v: number): void; + /** + !#en The convenience method to create a new {{#crossLink "Vec2"}}cc.Vec2{{/crossLink}}. + !#zh 通过该简便的函数进行创建 {{#crossLink "Vec2"}}cc.Vec2{{/crossLink}} 对象。 + @param x x + @param y y + + @example + ```js + var v1 = cc.v2(); + var v2 = cc.v2(0, 0); + var v3 = cc.v2(v2); + var v4 = cc.v2({x: 100, y: 100}); + ``` + */ + export function v2(x?: number|any, y?: number): Vec2; + /** + !#en The convenience method to create a new {{#crossLink "Vec3"}}cc.Vec3{{/crossLink}}. + !#zh 通过该简便的函数进行创建 {{#crossLink "Vec3"}}cc.Vec3{{/crossLink}} 对象。 + @param x x + @param y y + @param z z + + @example + ```js + var v1 = cc.v3(); + var v2 = cc.v3(0, 0, 0); + var v3 = cc.v3(v2); + var v4 = cc.v3({x: 100, y: 100, z: 0}); + ``` + */ + export function v3(x?: number|any, y?: number, z?: number): Vec3; + /** + !#en Defines a CCClass using the given specification, please see [Class](/docs/editors_and_tools/creator-chapters/scripting/class.html) for details. + !#zh 定义一个 CCClass,传入参数必须是一个包含类型参数的字面量对象,具体用法请查阅[类型定义](/docs/creator/scripting/class.html)。 + @param options options + + @example + ```js + // define base class + var Node = cc.Class(); + + // define sub class + var Sprite = cc.Class({ + name: 'Sprite', + extends: Node, + + ctor: function () { + this.url = ""; + this.id = 0; + }, + + statics: { + // define static members + count: 0, + getBounds: function (spriteList) { + // compute bounds... + } + }, + + properties { + width: { + default: 128, + type: cc.Integer, + tooltip: 'The width of sprite' + }, + height: 128, + size: { + get: function () { + return cc.v2(this.width, this.height); + } + } + }, + + load: function () { + // load this.url... + }; + }); + + // instantiate + + var obj = new Sprite(); + obj.url = 'sprite.png'; + obj.load(); + ``` + */ + export function Class(options?: {name?: string; extends?: Function; ctor?: Function; __ctor__?: Function; properties?: any; statics?: any; mixins?: Function[]; editor?: {executeInEditMode?: boolean; requireComponent?: Function; menu?: string; executionOrder?: number; disallowMultiple?: boolean; playOnFocus?: boolean; inspector?: string; icon?: string; help?: string; }; update?: Function; lateUpdate?: Function; onLoad?: Function; start?: Function; onEnable?: Function; onDisable?: Function; onDestroy?: Function; onFocusInEditor?: Function; onLostFocusInEditor?: Function; resetInEditor?: Function; onRestore?: Function; _getLocalBounds?: Function; }): Function; + /** + !#en + Define an enum type.
+ If a enum item has a value of -1, it will be given an Integer number according to it's order in the list.
+ Otherwise it will use the value specified by user who writes the enum definition. + + !#zh + 定义一个枚举类型。
+ 用户可以把枚举值设为任意的整数,如果设为 -1,系统将会分配为上一个枚举值 + 1。 + @param obj a JavaScript literal object containing enum names and values, or a TypeScript enum type + + @example + ```js + // JavaScript: + + var WrapMode = cc.Enum({ + Repeat: -1, + Clamp: -1 + }); + + // Texture.WrapMode.Repeat == 0 + // Texture.WrapMode.Clamp == 1 + // Texture.WrapMode[0] == "Repeat" + // Texture.WrapMode[1] == "Clamp" + + var FlagType = cc.Enum({ + Flag1: 1, + Flag2: 2, + Flag3: 4, + Flag4: 8, + }); + + var AtlasSizeList = cc.Enum({ + 128: 128, + 256: 256, + 512: 512, + 1024: 1024, + }); + + // TypeScript: + + // If used in TypeScript, just define a TypeScript enum: + enum Direction { + Up, + Down, + Left, + Right + } + + // If you need to inspect the enum in Properties panel, you can call cc.Enum: + const {ccclass, property} = cc._decorator; + + @ccclass + class NewScript extends cc.Component { + @property({ + type: cc.Enum(Direction) // call cc.Enum + }) + direction: Direction = Direction.Up; + } + + ``` + */ + export function Enum(obj: T): T; + /** + + @param touches touches + */ + export function handleTouchesBegin(touches: any[]): void; + /** + + @param touches touches + */ + export function handleTouchesMove(touches: any[]): void; + /** + + @param touches touches + */ + export function handleTouchesEnd(touches: any[]): void; + /** + + @param touches touches + */ + export function handleTouchesCancel(touches: any[]): void; + /** + + @param touches touches + */ + export function getSetOfTouchesEndOrCancel(touches: any[]): any[]; + /** + + @param touch touch + */ + export function getPreTouch(touch: Touch): Touch; + /** + + @param touch touch + */ + export function setPreTouch(touch: Touch): void; + /** + + @param tx tx + @param ty ty + @param pos pos + */ + export function getTouchByXY(tx: number, ty: number, pos: Vec2): Touch; + /** + + @param location location + @param pos pos + @param eventType eventType + */ + export function getMouseEvent(location: Vec2, pos: Vec2, eventType: number): Event.EventMouse; + /** + + @param event event + @param pos pos + */ + export function getPointByEvent(event: Touch, pos: Vec2): Vec2; + /** + + @param event event + @param pos pos + */ + export function getTouchesByEvent(event: Touch, pos: Vec2): any[]; + /** + + @param element element + */ + export function registerSystemEvent(element: HTMLElement): void; + /** + + @param dt dt + */ + export function update(dt: number): void; + /** + !#en + Checks whether the object is non-nil and not yet destroyed.
+ When an object's `destroy` is called, it is actually destroyed after the end of this frame. + So `isValid` will return false from the next frame, while `isValid` in the current frame will still be true. + If you want to determine whether the current frame has called `destroy`, use `cc.isValid(obj, true)`, + but this is often caused by a particular logical requirements, which is not normally required. + + !#zh + 检查该对象是否不为 null 并且尚未销毁。
+ 当一个对象的 `destroy` 调用以后,会在这一帧结束后才真正销毁。因此从下一帧开始 `isValid` 就会返回 false,而当前帧内 `isValid` 仍然会是 true。如果希望判断当前帧是否调用过 `destroy`,请使用 `cc.isValid(obj, true)`,不过这往往是特殊的业务需求引起的,通常情况下不需要这样。 + @param value value + @param strictMode If true, Object called destroy() in this frame will also treated as invalid. + + @example + ```js + var node = new cc.Node(); + cc.log(cc.isValid(node)); // true + node.destroy(); + cc.log(cc.isValid(node)); // true, still valid in this frame + // after a frame... + cc.log(cc.isValid(node)); // false, destroyed in the end of last frame + ``` + */ + export function isValid(value: any, strictMode?: boolean): boolean; + /** !#en cc.view is the shared view object. + !#zh cc.view 是全局的视图对象。 */ + export var view: View; + /** !#en cc.winSize is the alias object for the size of the current game window. + !#zh cc.winSize 为当前的游戏窗口的大小。 */ + export var winSize: Size; + /** Specify that the input value must be integer in Inspector. + Also used to indicates that the elements in array should be type integer. */ + export var Integer: string; + /** Indicates that the elements in array should be type double. */ + export var Float: string; + /** Indicates that the elements in array should be type boolean. */ + export var Boolean: string; + /** Indicates that the elements in array should be type string. */ + export var String: string; + /** + !#en Deserialize json to cc.Asset + !#zh 将 JSON 反序列化为对象实例。 + + 当指定了 target 选项时,如果 target 引用的其它 asset 的 uuid 不变,则不会改变 target 对 asset 的引用, + 也不会将 uuid 保存到 result 对象中。 + @param data the serialized cc.Asset json string or json object. + @param details additional loading result + @param options options + */ + export function deserialize(data: string|any, details?: Details, options?: any): any; + /** + !#en Clones the object `original` and returns the clone, or instantiate a node from the Prefab. + !#zh 克隆指定的任意类型的对象,或者从 Prefab 实例化出新节点。 + + (Instantiate 时,function 和 dom 等非可序列化对象会直接保留原有引用,Asset 会直接进行浅拷贝,可序列化类型会进行深拷贝。) + @param original An existing object that you want to make a copy of. + + @example + ```js + // instantiate node from prefab + var scene = cc.director.getScene(); + var node = cc.instantiate(prefabAsset); + node.parent = scene; + // clone node + var scene = cc.director.getScene(); + var node = cc.instantiate(targetNode); + node.parent = scene; + ``` + */ + export function instantiate(original: Prefab): Node; + export function instantiate(original: T): T; + export var dynamicAtlasManager: DynamicAtlasManager; + /** !#en The matrix storage */ + export var matrix: any[]; + /** + !#en Get an element + @param i i + @param j j + */ + export function get(i: number, j: number): number; + /** + !#en Set an element + @param i i + @param j j + @param value value + */ + export function set(i: number, j: number, value: boolean): void; + /** + !#en Sets all elements to zero + */ + export function reset(): void; + /** !#en cc.audioEngine is the singleton object, it provide simple audio APIs. + !#zh + cc.audioengine是单例对象。
+ 主要用来播放音频,播放的时候会返回一个 audioID,之后都可以通过这个 audioID 来操作这个音频对象。
+ 不使用的时候,请使用 cc.audioEngine.uncache(filePath); 进行资源释放
+ 注意:
+ 在 Android 系统浏览器上,不同浏览器,不同版本的效果不尽相同。
+ 比如说:大多数浏览器都需要用户物理交互才可以开始播放音效,有一些不支持 WebAudio,
+ 有一些不支持多音轨播放。总之如果对音乐依赖比较强,请做尽可能多的测试。 */ + export class audioEngine { + /** + !#en Play audio. + !#zh 播放音频 + @param clip The audio clip to play. + @param loop Whether the music loop or not. + @param volume Volume size. + + @example + ```js + cc.loader.loadRes(url, cc.AudioClip, function (err, clip) { + var audioID = cc.audioEngine.play(clip, false, 0.5); + }); + ``` + */ + static play(clip: AudioClip, loop: boolean, volume: number): number; + /** + !#en Set audio loop. + !#zh 设置音频是否循环。 + @param audioID audio id. + @param loop Whether cycle. + + @example + ```js + cc.audioEngine.setLoop(id, true); + ``` + */ + static setLoop(audioID: number, loop: boolean): void; + /** + !#en Get audio cycle state. + !#zh 获取音频的循环状态。 + @param audioID audio id. + + @example + ```js + cc.audioEngine.isLoop(id); + ``` + */ + static isLoop(audioID: number): boolean; + /** + !#en Set the volume of audio. + !#zh 设置音量(0.0 ~ 1.0)。 + @param audioID audio id. + @param volume Volume must be in 0.0~1.0 . + + @example + ```js + cc.audioEngine.setVolume(id, 0.5); + ``` + */ + static setVolume(audioID: number, volume: number): void; + /** + !#en The volume of the music max value is 1.0,the min value is 0.0 . + !#zh 获取音量(0.0 ~ 1.0)。 + @param audioID audio id. + + @example + ```js + var volume = cc.audioEngine.getVolume(id); + ``` + */ + static getVolume(audioID: number): number; + /** + !#en Set current time + !#zh 设置当前的音频时间。 + @param audioID audio id. + @param sec current time. + + @example + ```js + cc.audioEngine.setCurrentTime(id, 2); + ``` + */ + static setCurrentTime(audioID: number, sec: number): boolean; + /** + !#en Get current time + !#zh 获取当前的音频播放时间。 + @param audioID audio id. + + @example + ```js + var time = cc.audioEngine.getCurrentTime(id); + ``` + */ + static getCurrentTime(audioID: number): number; + /** + !#en Get audio duration + !#zh 获取音频总时长。 + @param audioID audio id. + + @example + ```js + var time = cc.audioEngine.getDuration(id); + ``` + */ + static getDuration(audioID: number): number; + /** + !#en Get audio state + !#zh 获取音频状态。 + @param audioID audio id. + + @example + ```js + var state = cc.audioEngine.getState(id); + ``` + */ + static getState(audioID: number): audioEngine.AudioState; + /** + !#en Set Audio finish callback + !#zh 设置一个音频结束后的回调 + @param audioID audio id. + @param callback loaded callback. + + @example + ```js + cc.audioEngine.setFinishCallback(id, function () {}); + ``` + */ + static setFinishCallback(audioID: number, callback: Function): void; + /** + !#en Pause playing audio. + !#zh 暂停正在播放音频。 + @param audioID The return value of function play. + + @example + ```js + cc.audioEngine.pause(audioID); + ``` + */ + static pause(audioID: number): void; + /** + !#en Pause all playing audio + !#zh 暂停现在正在播放的所有音频。 + + @example + ```js + cc.audioEngine.pauseAll(); + ``` + */ + static pauseAll(): void; + /** + !#en Resume playing audio. + !#zh 恢复播放指定的音频。 + @param audioID The return value of function play. + + @example + ```js + cc.audioEngine.resume(audioID); + ``` + */ + static resume(audioID: number): void; + /** + !#en Resume all playing audio. + !#zh 恢复播放所有之前暂停的所有音频。 + + @example + ```js + cc.audioEngine.resumeAll(); + ``` + */ + static resumeAll(): void; + /** + !#en Stop playing audio. + !#zh 停止播放指定音频。 + @param audioID The return value of function play. + + @example + ```js + cc.audioEngine.stop(audioID); + ``` + */ + static stop(audioID: number): void; + /** + !#en Stop all playing audio. + !#zh 停止正在播放的所有音频。 + + @example + ```js + cc.audioEngine.stopAll(); + ``` + */ + static stopAll(): void; + /** + !#en Set up an audio can generate a few examples. + !#zh 设置一个音频可以设置几个实例 + @param num a number of instances to be created from within an audio + + @example + ```js + cc.audioEngine.setMaxAudioInstance(20); + ``` + */ + static setMaxAudioInstance(num: number): void; + /** + !#en Getting audio can produce several examples. + !#zh 获取一个音频可以设置几个实例 + + @example + ```js + cc.audioEngine.getMaxAudioInstance(); + ``` + */ + static getMaxAudioInstance(): number; + /** + !#en Unload the preloaded audio from internal buffer. + !#zh 卸载预加载的音频。 + @param clip clip + + @example + ```js + cc.audioEngine.uncache(filePath); + ``` + */ + static uncache(clip: AudioClip): void; + /** + !#en Unload all audio from internal buffer. + !#zh 卸载所有音频。 + + @example + ```js + cc.audioEngine.uncacheAll(); + ``` + */ + static uncacheAll(): void; + /** + !#en Preload audio file. + !#zh 预加载一个音频 + @param filePath The file path of an audio. + @param callback The callback of an audio. + + @example + ```js + cc.audioEngine.preload(path); + ``` + */ + static preload(filePath: string, callback?: Function): void; + /** + !#en Set a size, the unit is KB. Over this size is directly resolved into DOM nodes. + !#zh 设置一个以 KB 为单位的尺寸,大于这个尺寸的音频在加载的时候会强制使用 dom 方式加载 + @param kb The file path of an audio. + + @example + ```js + cc.audioEngine.setMaxWebAudioSize(300); + ``` + */ + static setMaxWebAudioSize(kb: number): void; + /** + !#en Play background music + !#zh 播放背景音乐 + @param clip The audio clip to play. + @param loop Whether the music loop or not. + + @example + ```js + cc.loader.loadRes(url, cc.AudioClip, function (err, clip) { + var audioID = cc.audioEngine.playMusic(clip, false); + }); + ``` + */ + static playMusic(clip: AudioClip, loop: boolean): number; + /** + !#en Stop background music. + !#zh 停止播放背景音乐。 + + @example + ```js + cc.audioEngine.stopMusic(); + ``` + */ + static stopMusic(): void; + /** + !#en Pause the background music. + !#zh 暂停播放背景音乐。 + + @example + ```js + cc.audioEngine.pauseMusic(); + ``` + */ + static pauseMusic(): void; + /** + !#en Resume playing background music. + !#zh 恢复播放背景音乐。 + + @example + ```js + cc.audioEngine.resumeMusic(); + ``` + */ + static resumeMusic(): void; + /** + !#en Get the volume(0.0 ~ 1.0). + !#zh 获取音量(0.0 ~ 1.0)。 + + @example + ```js + var volume = cc.audioEngine.getMusicVolume(); + ``` + */ + static getMusicVolume(): number; + /** + !#en Set the background music volume. + !#zh 设置背景音乐音量(0.0 ~ 1.0)。 + @param volume Volume must be in 0.0~1.0. + + @example + ```js + cc.audioEngine.setMusicVolume(0.5); + ``` + */ + static setMusicVolume(volume: number): void; + /** + !#en Background music playing state + !#zh 背景音乐是否正在播放 + + @example + ```js + cc.audioEngine.isMusicPlaying(); + ``` + */ + static isMusicPlaying(): boolean; + /** + !#en Play effect audio. + !#zh 播放音效 + @param clip The audio clip to play. + @param loop Whether the music loop or not. + + @example + ```js + cc.loader.loadRes(url, cc.AudioClip, function (err, clip) { + var audioID = cc.audioEngine.playEffect(clip, false); + }); + ``` + */ + static playEffect(clip: AudioClip, loop: boolean): number; + /** + !#en Set the volume of effect audio. + !#zh 设置音效音量(0.0 ~ 1.0)。 + @param volume Volume must be in 0.0~1.0. + + @example + ```js + cc.audioEngine.setEffectsVolume(0.5); + ``` + */ + static setEffectsVolume(volume: number): void; + /** + !#en The volume of the effect audio max value is 1.0,the min value is 0.0 . + !#zh 获取音效音量(0.0 ~ 1.0)。 + + @example + ```js + var volume = cc.audioEngine.getEffectsVolume(); + ``` + */ + static getEffectsVolume(): number; + /** + !#en Pause effect audio. + !#zh 暂停播放音效。 + @param audioID audio id. + + @example + ```js + cc.audioEngine.pauseEffect(audioID); + ``` + */ + static pauseEffect(audioID: number): void; + /** + !#en Stop playing all the sound effects. + !#zh 暂停播放所有音效。 + + @example + ```js + cc.audioEngine.pauseAllEffects(); + ``` + */ + static pauseAllEffects(): void; + /** + !#en Resume effect audio. + !#zh 恢复播放音效音频。 + @param audioID The return value of function play. + + @example + ```js + cc.audioEngine.resumeEffect(audioID); + ``` + */ + static resumeEffect(audioID: number): void; + /** + !#en Resume all effect audio. + !#zh 恢复播放所有之前暂停的音效。 + + @example + ```js + cc.audioEngine.resumeAllEffects(); + ``` + */ + static resumeAllEffects(): void; + /** + !#en Stop playing the effect audio. + !#zh 停止播放音效。 + @param audioID audio id. + + @example + ```js + cc.audioEngine.stopEffect(id); + ``` + */ + static stopEffect(audioID: number): void; + /** + !#en Stop playing all the effects. + !#zh 停止播放所有音效。 + + @example + ```js + cc.audioEngine.stopAllEffects(); + ``` + */ + static stopAllEffects(): void; + } + /** !#en Base class cc.Action for action classes. + !#zh Action 类是所有动作类型的基类。 */ + export class Action { + /** + !#en + to copy object with deep copy. + returns a clone of action. + !#zh 返回一个克隆的动作。 + */ + clone(): Action; + /** + !#en + return true if the action has finished. + !#zh 如果动作已完成就返回 true。 + */ + isDone(): boolean; + /** + !#en get the target. + !#zh 获取当前目标节点。 + */ + getTarget(): Node; + /** + !#en The action will modify the target properties. + !#zh 设置目标节点。 + @param target target + */ + setTarget(target: Node): void; + /** + !#en get the original target. + !#zh 获取原始目标节点。 + */ + getOriginalTarget(): Node; + /** + !#en get tag number. + !#zh 获取用于识别动作的标签。 + */ + getTag(): number; + /** + !#en set tag number. + !#zh 设置标签,用于识别动作。 + @param tag tag + */ + setTag(tag: number): void; + /** !#en Default Action tag. + !#zh 默认动作标签。 */ + static TAG_INVALID: number; + } + /** !#en + Base class actions that do have a finite time duration.
+ Possible actions:
+ - An action with a duration of 0 seconds.
+ - An action with a duration of 35.5 seconds. + + Infinite time actions are valid + !#zh 有限时间动作,这种动作拥有时长 duration 属性。 */ + export class FiniteTimeAction extends Action { + /** + !#en get duration of the action. (seconds). + !#zh 获取动作以秒为单位的持续时间。 + */ + getDuration(): number; + /** + !#en set duration of the action. (seconds). + !#zh 设置动作以秒为单位的持续时间。 + @param duration duration + */ + setDuration(duration: number): void; + /** + !#en + Returns a reversed action.
+ For example:
+ - The action will be x coordinates of 0 move to 100.
+ - The reversed action will be x of 100 move to 0. + - Will be rewritten + !#zh 返回一个新的动作,执行与原动作完全相反的动作。 + */ + reverse(): void; + /** + !#en + to copy object with deep copy. + returns a clone of action. + !#zh 返回一个克隆的动作。 + */ + clone(): FiniteTimeAction; + } + /** !#en Instant actions are immediate actions. They don't have a duration like the ActionInterval actions. + !#zh 即时动作,这种动作立即就会执行,继承自 FiniteTimeAction。 */ + export class ActionInstant extends FiniteTimeAction { + } + /** !#en +

An interval action is an action that takes place within a certain period of time.
+ It has an start time, and a finish time. The finish time is the parameter
+ duration plus the start time.

+ +

These CCActionInterval actions have some interesting properties, like:
+ - They can run normally (default)
+ - They can run reversed with the reverse method
+ - They can run with the time altered with the Accelerate, AccelDeccel and Speed actions.

+ +

For example, you can simulate a Ping Pong effect running the action normally and
+ then running it again in Reverse mode.

+ !#zh 时间间隔动作,这种动作在已定时间内完成,继承 FiniteTimeAction。 */ + export class ActionInterval extends FiniteTimeAction { + /** + !#en Implementation of ease motion. + !#zh 缓动运动。 + @param easeObj easeObj + + @example + ```js + action.easing(cc.easeIn(3.0)); + ``` + */ + easing(easeObj: any): ActionInterval; + /** + !#en + Repeats an action a number of times. + To repeat an action forever use the CCRepeatForever action. + !#zh 重复动作可以按一定次数重复一个动作,使用 RepeatForever 动作来永远重复一个动作。 + @param times times + */ + repeat(times: number): ActionInterval; + /** + !#en + Repeats an action for ever.
+ To repeat the an action for a limited number of times use the Repeat action.
+ !#zh 永远地重复一个动作,有限次数内重复一个动作请使用 Repeat 动作。 + */ + repeatForever(): ActionInterval; + } + /** !#en + cc.ActionManager is a class that can manage actions.
+ Normally you won't need to use this class directly. 99% of the cases you will use the CCNode interface, + which uses this class's singleton object. + But there are some cases where you might need to use this class.
+ Examples:
+ - When you want to run an action where the target is different from a CCNode.
+ - When you want to pause / resume the actions
+ !#zh + cc.ActionManager 是可以管理动作的单例类。
+ 通常你并不需要直接使用这个类,99%的情况您将使用 CCNode 的接口。
+ 但也有一些情况下,您可能需要使用这个类。
+ 例如: + - 当你想要运行一个动作,但目标不是 CCNode 类型时。
+ - 当你想要暂停/恢复动作时。
*/ + export class ActionManager { + /** + !#en + Adds an action with a target.
+ If the target is already present, then the action will be added to the existing target. + If the target is not present, a new instance of this target will be created either paused or not, and the action will be added to the newly created target. + When the target is paused, the queued actions won't be 'ticked'. + !#zh + 增加一个动作,同时还需要提供动作的目标对象,目标对象是否暂停作为参数。
+ 如果目标已存在,动作将会被直接添加到现有的节点中。
+ 如果目标不存在,将为这一目标创建一个新的实例,并将动作添加进去。
+ 当目标状态的 paused 为 true,动作将不会被执行 + @param action action + @param target target + @param paused paused + */ + addAction(action: Action, target: Node, paused: boolean): void; + /** + !#en Removes all actions from all the targets. + !#zh 移除所有对象的所有动作。 + */ + removeAllActions(): void; + /** + !#en + Removes all actions from a certain target.
+ All the actions that belongs to the target will be removed. + !#zh + 移除指定对象上的所有动作。
+ 属于该目标的所有的动作将被删除。 + @param target target + @param forceDelete forceDelete + */ + removeAllActionsFromTarget(target: Node, forceDelete: boolean): void; + /** + !#en Removes an action given an action reference. + !#zh 移除指定的动作。 + @param action action + */ + removeAction(action: Action): void; + /** + !#en Removes an action given its tag and the target. + !#zh 删除指定对象下特定标签的一个动作,将删除首个匹配到的动作。 + @param tag tag + @param target target + */ + removeActionByTag(tag: number, target?: Node): void; + /** + !#en Gets an action given its tag an a target. + !#zh 通过目标对象和标签获取一个动作。 + @param tag tag + @param target target + */ + getActionByTag(tag: number, target: Node): Action; + /** + !#en + Returns the numbers of actions that are running in a certain target.
+ Composable actions are counted as 1 action.
+ Example:
+ - If you are running 1 Sequence of 7 actions, it will return 1.
+ - If you are running 7 Sequences of 2 actions, it will return 7. + !#zh + 返回指定对象下所有正在运行的动作数量。
+ 组合动作被算作一个动作。
+ 例如:
+ - 如果您正在运行 7 个动作组成的序列动作(Sequence),这个函数将返回 1。
+ - 如果你正在运行 2 个序列动作(Sequence)和 5 个普通动作,这个函数将返回 7。
+ @param target target + */ + getNumberOfRunningActionsInTarget(target: Node): number; + /** + !#en Pauses the target: all running actions and newly added actions will be paused. + !#zh 暂停指定对象:所有正在运行的动作和新添加的动作都将会暂停。 + @param target target + */ + pauseTarget(target: Node): void; + /** + !#en Resumes the target. All queued actions will be resumed. + !#zh 让指定目标恢复运行。在执行序列中所有被暂停的动作将重新恢复运行。 + @param target target + */ + resumeTarget(target: Node): void; + /** + !#en Pauses all running actions, returning a list of targets whose actions were paused. + !#zh 暂停所有正在运行的动作,返回一个包含了那些动作被暂停了的目标对象的列表。 + */ + pauseAllRunningActions(): any[]; + /** + !#en Resume a set of targets (convenience function to reverse a pauseAllRunningActions or pauseTargets call). + !#zh 让一组指定对象恢复运行(用来逆转 pauseAllRunningActions 效果的便捷函数)。 + @param targetsToResume targetsToResume + */ + resumeTargets(targetsToResume: any[]): void; + /** + !#en Pause a set of targets. + !#zh 暂停一组指定对象。 + @param targetsToPause targetsToPause + */ + pauseTargets(targetsToPause: any[]): void; + /** + !#en + purges the shared action manager. It releases the retained instance.
+ because it uses this, so it can not be static. + !#zh + 清除共用的动作管理器。它释放了持有的实例。
+ 因为它使用 this,因此它不能是静态的。 + */ + purgeSharedManager(): void; + /** + !#en The ActionManager update。 + !#zh ActionManager 主循环。 + @param dt delta time in seconds + */ + update(dt: number): void; + } + /** !#en + Tween provide a simple and flexible way to create action. + Tween's api is more flexible than cc.Action: + - Support creating an action sequence in chained api, + - Support animate any objects' any properties, not limited to node's properties. + By contrast, cc.Action needs to create a new action class to support new node property. + - Support working with cc.Action, + - Support easing and progress function. + !#zh + Tween 提供了一个简单灵活的方法来创建 action。 + 相对于 Cocos 传统的 cc.Action,cc.Tween 在创建动画上要灵活非常多: + - 支持以链式结构的方式创建一个动画序列。 + - 支持对任意对象的任意属性进行缓动,不再局限于节点上的属性,而 cc.Action 添加一个属性的支持时还需要添加一个新的 action 类型。 + - 支持与 cc.Action 混用 + - 支持设置 {{#crossLink "Easing"}}{{/crossLink}} 或者 progress 函数 */ + export class Tween { + /** + + @param target target + */ + constructor(target?: any); + /** + !#en Stop all tweens + !#zh 停止所有缓动 + */ + static stopAll(): void; + /** + !#en Stop all tweens by tag + !#zh 停止所有指定标签的缓动 + @param tag tag + */ + static stopAllByTag(tag: number): void; + /** + !#en Stop all tweens by target + !#zh 停止所有指定对象的缓动 + @param target target + */ + static stopAllByTarget(target: any): void; + /** + !#en + Insert an action or tween to this sequence + !#zh + 插入一个 action 或者 tween 到队列中 + @param other other + */ + then(other: Action|Tween): Tween; + /** + !#en + Set tween target + !#zh + 设置 tween 的 target + @param target target + */ + target(target: any): Tween; + /** + !#en + Start this tween + !#zh + 运行当前 tween + */ + start(): Tween; + /** + !#en + Stop this tween + !#zh + 停止当前 tween + */ + stop(): Tween; + /** + !#en Sets tween tag + !#zh 设置缓动的标签 + @param tag tag + */ + tag(tag: number): Tween; + /** + !#en + Clone a tween + !#zh + 克隆当前 tween + @param target target + */ + clone(target?: any): Tween; + /** + !#en + Integrate all previous actions to an action. + !#zh + 将之前所有的 action 整合为一个 action。 + */ + union(): Tween; + /** + !#en Sets target's position property according to the bezier curve. + !#zh 按照贝塞尔路径设置目标的 position 属性。 + @param duration duration + @param c1 c1 + @param c2 c2 + @param to to + */ + bezierTo(duration: number, c1: Vec2, c2: Vec2, to: Vec2): Tween; + /** + !#en Sets target's position property according to the bezier curve. + !#zh 按照贝塞尔路径设置目标的 position 属性。 + @param duration duration + @param c1 c1 + @param c2 c2 + @param to to + */ + bezierBy(duration: number, c1: Vec2, c2: Vec2, to: Vec2): Tween; + /** + !#en Flips target's scaleX + !#zh 翻转目标的 scaleX 属性 + */ + flipX(): Tween; + /** + !#en Flips target's scaleY + !#zh 翻转目标的 scaleY 属性 + */ + flipY(): Tween; + /** + !#en Blinks target by set target's opacity property + !#zh 通过设置目标的 opacity 属性达到闪烁效果 + @param duration duration + @param times times + @param opts opts + */ + blink(duration: number, times: number, opts?: {progress?: Function; easing?: Function|string; }): Tween; + /** + !#en + Add an action which calculate with absolute value + !#zh + 添加一个对属性进行绝对值计算的 action + @param duration duration + @param props {scale: 2, position: cc.v3(100, 100, 100)} + @param opts opts + */ + to > (duration: number, props: ConstructorType, opts?: OPTS) : Tween; + /** + !#en + Add an action which calculate with relative value + !#zh + 添加一个对属性进行相对值计算的 action + @param duration duration + @param props {scale: 2, position: cc.v3(100, 100, 100)} + @param opts opts + */ + by > (duration: number, props: ConstructorType, opts?: OPTS) : Tween; + /** + !#en + Directly set target properties + !#zh + 直接设置 target 的属性 + @param props props + */ + set (props: ConstructorType) : Tween; + /** + !#en + Add an delay action + !#zh + 添加一个延时 action + @param duration duration + */ + delay(duration: number): Tween; + /** + !#en + Add an callback action + !#zh + 添加一个回调 action + @param callback callback + */ + call(callback: Function): Tween; + /** + !#en + Add an hide action + !#zh + 添加一个隐藏 action + */ + hide(): Tween; + /** + !#en + Add an show action + !#zh + 添加一个显示 action + */ + show(): Tween; + /** + !#en + Add an removeSelf action + !#zh + 添加一个移除自己 action + */ + removeSelf(): Tween; + /** + !#en + Add an sequence action + !#zh + 添加一个队列 action + @param action action + @param actions actions + */ + sequence(action: Action|Tween, ...actions: (Action|Tween)[]): Tween; + /** + !#en + Add an parallel action + !#zh + 添加一个并行 action + @param action action + @param actions actions + */ + parallel(action: Action|Tween, ...actions: (Action|Tween)[]): Tween; + /** + !#en + Add an repeat action. + This action will integrate before actions to a sequence action as their parameters. + !#zh + 添加一个重复 action,这个 action 会将前一个动作作为他的参数。 + @param repeatTimes repeatTimes + @param action action + */ + repeat(repeatTimes: number, action?: Action|Tween): Tween; + /** + !#en + Add an repeat forever action + This action will integrate before actions to a sequence action as their parameters. + !#zh + 添加一个永久重复 action,这个 action 会将前一个动作作为他的参数。 + @param action action + */ + repeatForever(action?: Action|Tween): Tween; + /** + !#en + Add an reverse time action. + This action will integrate before actions to a sequence action as their parameters. + !#zh + 添加一个倒置时间 action,这个 action 会将前一个动作作为他的参数。 + @param action action + */ + reverseTime(action?: Action|Tween): Tween; + } + /** !#en Class for animation data handling. + !#zh 动画剪辑,用于存储动画数据。 */ + export class AnimationClip extends Asset { + /** !#en Duration of this animation. + !#zh 动画的持续时间。 */ + duration: number; + /** !#en FrameRate of this animation. + !#zh 动画的帧速率。 */ + sample: number; + /** !#en Speed of this animation. + !#zh 动画的播放速度。 */ + speed: number; + /** !#en WrapMode of this animation. + !#zh 动画的循环模式。 */ + wrapMode: WrapMode; + /** !#en Curve data. + !#zh 曲线数据。 */ + curveData: any; + /** !#en Event data. + !#zh 事件数据。 */ + events: {frame: number, func: string, params: string[]}[]; + /** + !#en Crate clip with a set of sprite frames + !#zh 使用一组序列帧图片来创建动画剪辑 + @param spriteFrames spriteFrames + @param sample sample + + @example + ```js + var clip = cc.AnimationClip.createWithSpriteFrames(spriteFrames, 10); + ``` + */ + static createWithSpriteFrames(spriteFrames: SpriteFrame[], sample: number): AnimationClip; + } + /** !#en + The AnimationState gives full control over animation playback process. + In most cases the Animation Component is sufficient and easier to use. Use the AnimationState if you need full control. + !#zh + AnimationState 完全控制动画播放过程。
+ 大多数情况下 动画组件 是足够和易于使用的。如果您需要更多的动画控制接口,请使用 AnimationState。 */ + export class AnimationState extends Playable { + /** + + @param clip clip + @param name name + */ + constructor(clip: AnimationClip, name?: string); + /** !#en The curves list. + !#zh 曲线列表。 */ + curves: any[]; + /** !#en The start delay which represents the number of seconds from an animation's start time to the start of + the active interval. + !#zh 延迟多少秒播放。 */ + delay: number; + /** !#en The animation's iteration count property. + + A real number greater than or equal to zero (including positive infinity) representing the number of times + to repeat the animation node. + + Values less than zero and NaN values are treated as the value 1.0 for the purpose of timing model + calculations. + + !#zh 迭代次数,指动画播放多少次后结束, normalize time。 如 2.5(2次半) */ + repeatCount: number; + /** !#en The iteration duration of this animation in seconds. (length) + !#zh 单次动画的持续时间,秒。 */ + duration: number; + /** !#en The animation's playback speed. 1 is normal playback speed. + !#zh 播放速率。 */ + speed: number; + /** !#en + Wrapping mode of the playing animation. + Notice : dynamic change wrapMode will reset time and repeatCount property + !#zh + 动画循环方式。 + 需要注意的是,动态修改 wrapMode 时,会重置 time 以及 repeatCount */ + wrapMode: WrapMode; + /** !#en The current time of this animation in seconds. + !#zh 动画当前的时间,秒。 */ + time: number; + /** !#en The clip that is being played by this animation state. + !#zh 此动画状态正在播放的剪辑。 */ + clip: AnimationClip; + /** !#en The name of the playing animation. + !#zh 动画的名字 */ + name: string; + } + /** !#en + This class provide easing methods for {{#crossLink "tween"}}{{/crossLink}} class.
+ Demonstratio: https://easings.net/ + !#zh + 缓动函数类,为 {{#crossLink "Tween"}}{{/crossLink}} 提供缓动效果函数。
+ 函数效果演示: https://easings.net/ */ + export class Easing { + /** + !#en Easing in with quadratic formula. From slow to fast. + !#zh 平方曲线缓入函数。运动由慢到快。 + @param t The current time as a percentage of the total time. + */ + quadIn(t: number): number; + /** + !#en Easing out with quadratic formula. From fast to slow. + !#zh 平方曲线缓出函数。运动由快到慢。 + @param t The current time as a percentage of the total time. + */ + quadOut(t: number): number; + /** + !#en Easing in and out with quadratic formula. From slow to fast, then back to slow. + !#zh 平方曲线缓入缓出函数。运动由慢到快再到慢。 + @param t The current time as a percentage of the total time. + */ + quadInOut(t: number): number; + /** + !#en Easing in with cubic formula. From slow to fast. + !#zh 立方曲线缓入函数。运动由慢到快。 + @param t The current time as a percentage of the total time. + */ + cubicIn(t: number): number; + /** + !#en Easing out with cubic formula. From slow to fast. + !#zh 立方曲线缓出函数。运动由快到慢。 + @param t The current time as a percentage of the total time. + */ + cubicOut(t: number): number; + /** + !#en Easing in and out with cubic formula. From slow to fast, then back to slow. + !#zh 立方曲线缓入缓出函数。运动由慢到快再到慢。 + @param t The current time as a percentage of the total time. + */ + cubicInOut(t: number): number; + /** + !#en Easing in with quartic formula. From slow to fast. + !#zh 四次方曲线缓入函数。运动由慢到快。 + @param t The current time as a percentage of the total time. + */ + quartIn(t: number): number; + /** + !#en Easing out with quartic formula. From fast to slow. + !#zh 四次方曲线缓出函数。运动由快到慢。 + @param t The current time as a percentage of the total time. + */ + quartOut(t: number): number; + /** + !#en Easing in and out with quartic formula. From slow to fast, then back to slow. + !#zh 四次方曲线缓入缓出函数。运动由慢到快再到慢。 + @param t The current time as a percentage of the total time. + */ + quartInOut(t: number): number; + /** + !#en Easing in with quintic formula. From slow to fast. + !#zh 五次方曲线缓入函数。运动由慢到快。 + @param t The current time as a percentage of the total time. + */ + quintIn(t: number): number; + /** + !#en Easing out with quintic formula. From fast to slow. + !#zh 五次方曲线缓出函数。运动由快到慢。 + @param t The current time as a percentage of the total time. + */ + quintOut(t: number): number; + /** + !#en Easing in and out with quintic formula. From slow to fast, then back to slow. + !#zh 五次方曲线缓入缓出函数。运动由慢到快再到慢。 + @param t The current time as a percentage of the total time. + */ + quintInOut(t: number): number; + /** + !#en Easing in and out with sine formula. From slow to fast. + !#zh 正弦曲线缓入函数。运动由慢到快。 + @param t The current time as a percentage of the total time. + */ + sineIn(t: number): number; + /** + !#en Easing in and out with sine formula. From fast to slow. + !#zh 正弦曲线缓出函数。运动由快到慢。 + @param t The current time as a percentage of the total time. + */ + sineOut(t: number): number; + /** + !#en Easing in and out with sine formula. From slow to fast, then back to slow. + !#zh 正弦曲线缓入缓出函数。运动由慢到快再到慢。 + @param t The current time as a percentage of the total time. + */ + sineInOut(t: number): number; + /** + !#en Easing in and out with exponential formula. From slow to fast. + !#zh 指数曲线缓入函数。运动由慢到快。 + @param t The current time as a percentage of the total time. + */ + expoIn(t: number): number; + /** + !#en Easing in and out with exponential formula. From fast to slow. + !#zh 指数曲线缓出函数。运动由快到慢。 + @param t The current time as a percentage of the total time. + */ + expoOut(t: number): number; + /** + !#en Easing in and out with exponential formula. From slow to fast. + !#zh 指数曲线缓入和缓出函数。运动由慢到很快再到慢。 + @param t The current time as a percentage of the total time, then back to slow. + */ + expoInOut(t: number): number; + /** + !#en Easing in and out with circular formula. From slow to fast. + !#zh 循环公式缓入函数。运动由慢到快。 + @param t The current time as a percentage of the total time. + */ + circIn(t: number): number; + /** + !#en Easing in and out with circular formula. From fast to slow. + !#zh 循环公式缓出函数。运动由快到慢。 + @param t The current time as a percentage of the total time. + */ + circOut(t: number): number; + /** + !#en Easing in and out with circular formula. From slow to fast. + !#zh 指数曲线缓入缓出函数。运动由慢到很快再到慢。 + @param t The current time as a percentage of the total time, then back to slow. + */ + circInOut(t: number): number; + /** + !#en Easing in action with a spring oscillating effect. + !#zh 弹簧回震效果的缓入函数。 + @param t The current time as a percentage of the total time. + */ + elasticIn(t: number): number; + /** + !#en Easing out action with a spring oscillating effect. + !#zh 弹簧回震效果的缓出函数。 + @param t The current time as a percentage of the total time. + */ + elasticOut(t: number): number; + /** + !#en Easing in and out action with a spring oscillating effect. + !#zh 弹簧回震效果的缓入缓出函数。 + @param t The current time as a percentage of the total time. + */ + elasticInOut(t: number): number; + /** + !#en Easing in action with "back up" behavior. + !#zh 回退效果的缓入函数。 + @param t The current time as a percentage of the total time. + */ + backIn(t: number): number; + /** + !#en Easing out action with "back up" behavior. + !#zh 回退效果的缓出函数。 + @param t The current time as a percentage of the total time. + */ + backOut(t: number): number; + /** + !#en Easing in and out action with "back up" behavior. + !#zh 回退效果的缓入缓出函数。 + @param t The current time as a percentage of the total time. + */ + backInOut(t: number): number; + /** + !#en Easing in action with bouncing effect. + !#zh 弹跳效果的缓入函数。 + @param t The current time as a percentage of the total time. + */ + bounceIn(t: number): number; + /** + !#en Easing out action with bouncing effect. + !#zh 弹跳效果的缓出函数。 + @param t The current time as a percentage of the total time. + */ + bounceOut(t: number): number; + /** + !#en Easing in and out action with bouncing effect. + !#zh 弹跳效果的缓入缓出函数。 + @param t The current time as a percentage of the total time. + */ + bounceInOut(t: number): number; + /** + !#en Target will run action with smooth effect. + !#zh 平滑效果函数。 + @param t The current time as a percentage of the total time. + */ + smooth(t: number): number; + /** + !#en Target will run action with fade effect. + !#zh 渐褪效果函数。 + @param t The current time as a percentage of the total time. + */ + fade(t: number): number; + } + /** undefined */ + export class Playable { + /** !#en Is playing or paused in play mode? + !#zh 当前是否正在播放。 */ + isPlaying: boolean; + /** !#en Is currently paused? This can be true even if in edit mode(isPlaying == false). + !#zh 当前是否正在暂停 */ + isPaused: boolean; + /** + !#en Play this animation. + !#zh 播放动画。 + */ + play(): void; + /** + !#en Stop this animation. + !#zh 停止动画播放。 + */ + stop(): void; + /** + !#en Pause this animation. + !#zh 暂停动画。 + */ + pause(): void; + /** + !#en Resume this animation. + !#zh 重新播放动画。 + */ + resume(): void; + /** + !#en Perform a single frame step. + !#zh 执行一帧动画。 + */ + step(): void; + } + /** !#en Specifies how time is treated when it is outside of the keyframe range of an Animation. + !#zh 动画使用的循环模式。 */ + export enum WrapMode { + Default = 0, + Normal = 0, + Reverse = 0, + Loop = 0, + LoopReverse = 0, + PingPong = 0, + PingPongReverse = 0, + } + /** Class for particle asset handling. */ + export class ParticleAsset extends Asset { + } + /** Particle System base class.
+ Attributes of a Particle System:
+ - emmision rate of the particles
+ - Gravity Mode (Mode A):
+ - gravity
+ - direction
+ - speed +- variance
+ - tangential acceleration +- variance
+ - radial acceleration +- variance
+ - Radius Mode (Mode B):
+ - startRadius +- variance
+ - endRadius +- variance
+ - rotate +- variance
+ - Properties common to all modes:
+ - life +- life variance
+ - start spin +- variance
+ - end spin +- variance
+ - start size +- variance
+ - end size +- variance
+ - start color +- variance
+ - end color +- variance
+ - life +- variance
+ - blending function
+ - texture
+
+ cocos2d also supports particles generated by Particle Designer (http://particledesigner.71squared.com/).
+ 'Radius Mode' in Particle Designer uses a fixed emit rate of 30 hz. Since that can't be guarateed in cocos2d,
+ cocos2d uses a another approach, but the results are almost identical.
+ cocos2d supports all the variables used by Particle Designer plus a bit more:
+ - spinning particles (supported when using ParticleSystem)
+ - tangential acceleration (Gravity mode)
+ - radial acceleration (Gravity mode)
+ - radius direction (Radius mode) (Particle Designer supports outwards to inwards direction only)
+ It is possible to customize any of the above mentioned properties in runtime. Example:
*/ + export class ParticleSystem extends RenderComponent implements BlendFunc { + /** !#en Play particle in edit mode. + !#zh 在编辑器模式下预览粒子,启用后选中粒子时,粒子将自动播放。 */ + preview: boolean; + /** !#en + If set custom to true, then use custom properties insteadof read particle file. + !#zh 是否自定义粒子属性。 */ + custom: boolean; + /** !#en The plist file. + !#zh plist 格式的粒子配置文件。 */ + file: ParticleAsset; + /** !#en SpriteFrame used for particles display + !#zh 用于粒子呈现的 SpriteFrame */ + spriteFrame: SpriteFrame; + /** !#en Texture of Particle System, readonly, please use spriteFrame to setup new texture。 + !#zh 粒子贴图,只读属性,请使用 spriteFrame 属性来替换贴图。 */ + texture: string; + /** !#en Current quantity of particles that are being simulated. + !#zh 当前播放的粒子数量。 */ + particleCount: number; + /** !#en Indicate whether the system simulation have stopped. + !#zh 指示粒子播放是否完毕。 */ + stopped: boolean; + /** !#en If set to true, the particle system will automatically start playing on onLoad. + !#zh 如果设置为 true 运行时会自动发射粒子。 */ + playOnLoad: boolean; + /** !#en Indicate whether the owner node will be auto-removed when it has no particles left. + !#zh 粒子播放完毕后自动销毁所在的节点。 */ + autoRemoveOnFinish: boolean; + /** !#en Indicate whether the particle system is activated. + !#zh 是否激活粒子。 */ + active: boolean; + /** !#en Maximum particles of the system. + !#zh 粒子最大数量。 */ + totalParticles: number; + /** !#en How many seconds the emitter wil run. -1 means 'forever'. + !#zh 发射器生存时间,单位秒,-1表示持续发射。 */ + duration: number; + /** !#en Emission rate of the particles. + !#zh 每秒发射的粒子数目。 */ + emissionRate: number; + /** !#en Life of each particle setter. + !#zh 粒子的运行时间。 */ + life: number; + /** !#en Variation of life. + !#zh 粒子的运行时间变化范围。 */ + lifeVar: number; + /** !#en Start color of each particle. + !#zh 粒子初始颜色。 */ + startColor: Color; + /** !#en Variation of the start color. + !#zh 粒子初始颜色变化范围。 */ + startColorVar: Color; + /** !#en Ending color of each particle. + !#zh 粒子结束颜色。 */ + endColor: Color; + /** !#en Variation of the end color. + !#zh 粒子结束颜色变化范围。 */ + endColorVar: Color; + /** !#en Angle of each particle setter. + !#zh 粒子角度。 */ + angle: number; + /** !#en Variation of angle of each particle setter. + !#zh 粒子角度变化范围。 */ + angleVar: number; + /** !#en Start size in pixels of each particle. + !#zh 粒子的初始大小。 */ + startSize: number; + /** !#en Variation of start size in pixels. + !#zh 粒子初始大小的变化范围。 */ + startSizeVar: number; + /** !#en End size in pixels of each particle. + !#zh 粒子结束时的大小。 */ + endSize: number; + /** !#en Variation of end size in pixels. + !#zh 粒子结束大小的变化范围。 */ + endSizeVar: number; + /** !#en Start angle of each particle. + !#zh 粒子开始自旋角度。 */ + startSpin: number; + /** !#en Variation of start angle. + !#zh 粒子开始自旋角度变化范围。 */ + startSpinVar: number; + /** !#en End angle of each particle. + !#zh 粒子结束自旋角度。 */ + endSpin: number; + /** !#en Variation of end angle. + !#zh 粒子结束自旋角度变化范围。 */ + endSpinVar: number; + /** !#en Source position of the emitter. + !#zh 发射器位置。 */ + sourcePos: Vec2; + /** !#en Variation of source position. + !#zh 发射器位置的变化范围。(横向和纵向) */ + posVar: Vec2; + /** !#en Particles movement type. + !#zh 粒子位置类型。 */ + positionType: ParticleSystem.PositionType; + /** !#en Particles emitter modes. + !#zh 发射器类型。 */ + emitterMode: ParticleSystem.EmitterMode; + /** !#en Gravity of the emitter. + !#zh 重力。 */ + gravity: Vec2; + /** !#en Speed of the emitter. + !#zh 速度。 */ + speed: number; + /** !#en Variation of the speed. + !#zh 速度变化范围。 */ + speedVar: number; + /** !#en Tangential acceleration of each particle. Only available in 'Gravity' mode. + !#zh 每个粒子的切向加速度,即垂直于重力方向的加速度,只有在重力模式下可用。 */ + tangentialAccel: number; + /** !#en Variation of the tangential acceleration. + !#zh 每个粒子的切向加速度变化范围。 */ + tangentialAccelVar: number; + /** !#en Acceleration of each particle. Only available in 'Gravity' mode. + !#zh 粒子径向加速度,即平行于重力方向的加速度,只有在重力模式下可用。 */ + radialAccel: number; + /** !#en Variation of the radial acceleration. + !#zh 粒子径向加速度变化范围。 */ + radialAccelVar: number; + /** !#en Indicate whether the rotation of each particle equals to its direction. Only available in 'Gravity' mode. + !#zh 每个粒子的旋转是否等于其方向,只有在重力模式下可用。 */ + rotationIsDir: boolean; + /** !#en Starting radius of the particles. Only available in 'Radius' mode. + !#zh 初始半径,表示粒子出生时相对发射器的距离,只有在半径模式下可用。 */ + startRadius: number; + /** !#en Variation of the starting radius. + !#zh 初始半径变化范围。 */ + startRadiusVar: number; + /** !#en Ending radius of the particles. Only available in 'Radius' mode. + !#zh 结束半径,只有在半径模式下可用。 */ + endRadius: number; + /** !#en Variation of the ending radius. + !#zh 结束半径变化范围。 */ + endRadiusVar: number; + /** !#en Number of degress to rotate a particle around the source pos per second. Only available in 'Radius' mode. + !#zh 粒子每秒围绕起始点的旋转角度,只有在半径模式下可用。 */ + rotatePerS: number; + /** !#en Variation of the degress to rotate a particle around the source pos per second. + !#zh 粒子每秒围绕起始点的旋转角度变化范围。 */ + rotatePerSVar: number; + /** !#en The Particle emitter lives forever. + !#zh 表示发射器永久存在 */ + static DURATION_INFINITY: number; + /** !#en The starting size of the particle is equal to the ending size. + !#zh 表示粒子的起始大小等于结束大小。 */ + static START_SIZE_EQUAL_TO_END_SIZE: number; + /** !#en The starting radius of the particle is equal to the ending radius. + !#zh 表示粒子的起始半径等于结束半径。 */ + static START_RADIUS_EQUAL_TO_END_RADIUS: number; + /** + !#en Stop emitting particles. Running particles will continue to run until they die. + !#zh 停止发射器发射粒子,发射出去的粒子将继续运行,直至粒子生命结束。 + + @example + ```js + // stop particle system. + myParticleSystem.stopSystem(); + ``` + */ + stopSystem(): void; + /** + !#en Kill all living particles. + !#zh 杀死所有存在的粒子,然后重新启动粒子发射器。 + + @example + ```js + // play particle system. + myParticleSystem.resetSystem(); + ``` + */ + resetSystem(): void; + /** + !#en Whether or not the system is full. + !#zh 发射器中粒子是否大于等于设置的总粒子数量。 + */ + isFull(): boolean; + /** + !#en Sets a new texture with a rect. The rect is in texture position and size. + Please use spriteFrame property instead, this function is deprecated since v1.9 + !#zh 设置一张新贴图和关联的矩形。 + 请直接设置 spriteFrame 属性,这个函数从 v1.9 版本开始已经被废弃 + @param texture texture + @param rect rect + */ + setTextureWithRect(texture: Texture2D, rect: Rect): void; + /** !#en specify the source Blend Factor, this will generate a custom material object, please pay attention to the memory cost. + !#zh 指定原图的混合模式,这会克隆一个新的材质对象,注意这带来的开销 */ + srcBlendFactor: macro.BlendFactor; + /** !#en specify the destination Blend Factor. + !#zh 指定目标的混合模式 */ + dstBlendFactor: macro.BlendFactor; + } + /** cc.TMXLayerInfo contains the information about the layers like: + - Layer name + - Layer size + - Layer opacity at creation time (it can be modified at runtime) + - Whether the layer is visible (if it's not visible, then the CocosNode won't be created) + This information is obtained from the TMX file. */ + export class TMXLayerInfo { + /** Properties of the layer info. */ + properties: any; + } + /** cc.TMXImageLayerInfo contains the information about the image layers. + This information is obtained from the TMX file. */ + export class TMXImageLayerInfo { + } + /**

cc.TMXObjectGroupInfo contains the information about the object group like: + - group name + - group size + - group opacity at creation time (it can be modified at runtime) + - Whether the group is visible + + This information is obtained from the TMX file.

*/ + export class TMXObjectGroupInfo { + /** Properties of the ObjectGroup info. */ + properties: any[]; + } + /**

cc.TMXTilesetInfo contains the information about the tilesets like:
+ - Tileset name
+ - Tileset spacing
+ - Tileset margin
+ - size of the tiles
+ - Image used for the tiles
+ - Image size
+ + This information is obtained from the TMX file.

*/ + export class TMXTilesetInfo { + /** Tileset name */ + name: string; + /** First grid */ + firstGid: number; + /** Spacing */ + spacing: number; + /** Margin */ + margin: number; + /** Texture containing the tiles (should be sprite sheet / texture atlas) */ + sourceImage: any; + /** Size in pixels of the image */ + imageSize: Size; + } + /**

cc.TMXMapInfo contains the information about the map like:
+ - Map orientation (hexagonal, isometric or orthogonal)
+ - Tile size
+ - Map size

+ +

And it also contains:
+ - Layers (an array of TMXLayerInfo objects)
+ - Tilesets (an array of TMXTilesetInfo objects)
+ - ObjectGroups (an array of TMXObjectGroupInfo objects)

+ +

This information is obtained from the TMX file.

*/ + export class TMXMapInfo { + /** Properties of the map info. */ + properties: any[]; + /** Map orientation. */ + orientation: number; + /** Parent element. */ + parentElement: any; + /** Parent GID. */ + parentGID: number; + /** Layer attributes. */ + layerAttrs: any; + /** Is reading storing characters stream. */ + storingCharacters: boolean; + /** Current string stored from characters stream. */ + currentString: string; + /** Width of the map */ + mapWidth: number; + /** Height of the map */ + mapHeight: number; + /** Width of a tile */ + tileWidth: number; + /** Height of a tile */ + tileHeight: number; + static ATTRIB_NONE: number; + static ATTRIB_BASE64: number; + static ATTRIB_GZIP: number; + static ATTRIB_ZLIB: number; + } + /** !#en Renders a TMX Tile Map in the scene. + !#zh 在场景中渲染一个 tmx 格式的 Tile Map。 */ + export class TiledMap extends Component { + /** !#en The TiledMap Asset. + !#zh TiledMap 资源。 */ + tmxAsset: TiledMapAsset; + /** + !#en Gets the map size. + !#zh 获取地图大小。 + + @example + ```js + let mapSize = tiledMap.getMapSize(); + cc.log("Map Size: " + mapSize); + ``` + */ + getMapSize(): Size; + /** + !#en Gets the tile size. + !#zh 获取地图背景中 tile 元素的大小。 + + @example + ```js + let tileSize = tiledMap.getTileSize(); + cc.log("Tile Size: " + tileSize); + ``` + */ + getTileSize(): Size; + /** + !#en map orientation. + !#zh 获取地图方向。 + + @example + ```js + let mapOrientation = tiledMap.getMapOrientation(); + cc.log("Map Orientation: " + mapOrientation); + ``` + */ + getMapOrientation(): number; + /** + !#en object groups. + !#zh 获取所有的对象层。 + + @example + ```js + let objGroups = titledMap.getObjectGroups(); + for (let i = 0; i < objGroups.length; ++i) { + cc.log("obj: " + objGroups[i]); + } + ``` + */ + getObjectGroups(): TiledObjectGroup[]; + /** + !#en Return the TMXObjectGroup for the specific group. + !#zh 获取指定的 TMXObjectGroup。 + @param groupName groupName + + @example + ```js + let group = titledMap.getObjectGroup("Players"); + cc.log("ObjectGroup: " + group); + ``` + */ + getObjectGroup(groupName: string): TiledObjectGroup; + /** + !#en enable or disable culling + !#zh 开启或关闭裁剪。 + @param value value + */ + enableCulling(value: any): void; + /** + !#en Gets the map properties. + !#zh 获取地图的属性。 + + @example + ```js + let properties = titledMap.getProperties(); + for (let i = 0; i < properties.length; ++i) { + cc.log("Properties: " + properties[i]); + } + ``` + */ + getProperties(): any[]; + /** + !#en Return All layers array. + !#zh 返回包含所有 layer 的数组。 + + @example + ```js + let layers = titledMap.getLayers(); + for (let i = 0; i < layers.length; ++i) { + cc.log("Layers: " + layers[i]); + } + ``` + */ + getLayers(): TiledLayer[]; + /** + !#en return the cc.TiledLayer for the specific layer. + !#zh 获取指定名称的 layer。 + @param layerName layerName + + @example + ```js + let layer = titledMap.getLayer("Player"); + cc.log(layer); + ``` + */ + getLayer(layerName: string): TiledLayer; + /** + !#en Return the value for the specific property name. + !#zh 通过属性名称,获取指定的属性。 + @param propertyName propertyName + + @example + ```js + let property = titledMap.getProperty("info"); + cc.log("Property: " + property); + ``` + */ + getProperty(propertyName: string): string; + /** + !#en Return properties dictionary for tile GID. + !#zh 通过 GID ,获取指定的属性。 + @param GID GID + + @example + ```js + let properties = titledMap.getPropertiesForGID(GID); + cc.log("Properties: " + properties); + ``` + */ + getPropertiesForGID(GID: number): any; + } + /** !#en Render the TMX layer. + !#zh 渲染 TMX layer。 */ + export class TiledLayer extends Component { + /** + !#en enable or disable culling + !#zh 开启或关闭裁剪。 + @param value value + */ + enableCulling(value: any): void; + /** + !#en Adds user's node into layer. + !#zh 添加用户节点。 + @param node node + */ + addUserNode(node: Node): boolean; + /** + !#en Removes user's node. + !#zh 移除用户节点。 + @param node node + */ + removeUserNode(node: Node): boolean; + /** + !#en Destroy user's node. + !#zh 销毁用户节点。 + @param node node + */ + destroyUserNode(node: Node): void; + /** + !#en Gets the layer name. + !#zh 获取层的名称。 + + @example + ```js + let layerName = tiledLayer.getLayerName(); + cc.log(layerName); + ``` + */ + getLayerName(): string; + /** + !#en Set the layer name. + !#zh 设置层的名称 + @param layerName layerName + + @example + ```js + tiledLayer.setLayerName("New Layer"); + ``` + */ + SetLayerName(layerName: string): void; + /** + !#en Return the value for the specific property name. + !#zh 获取指定属性名的值。 + @param propertyName propertyName + + @example + ```js + let property = tiledLayer.getProperty("info"); + cc.log(property); + ``` + */ + getProperty(propertyName: string): any; + /** + !#en Returns the position in pixels of a given tile coordinate. + !#zh 获取指定 tile 的像素坐标。 + @param pos position or x + @param y y + + @example + ```js + let pos = tiledLayer.getPositionAt(cc.v2(0, 0)); + cc.log("Pos: " + pos); + let pos = tiledLayer.getPositionAt(0, 0); + cc.log("Pos: " + pos); + ``` + */ + getPositionAt(pos: Vec2|number, y?: number): Vec2; + /** + !#en + Sets the tile gid (gid = tile global id) at a given tile coordinate.
+ The Tile GID can be obtained by using the method "tileGIDAt" or by using the TMX editor . Tileset Mgr +1.
+ If a tile is already placed at that position, then it will be removed. + !#zh + 设置给定坐标的 tile 的 gid (gid = tile 全局 id), + tile 的 GID 可以使用方法 “tileGIDAt” 来获得。
+ 如果一个 tile 已经放在那个位置,那么它将被删除。 + @param gid gid + @param posOrX position or x + @param flagsOrY flags or y + @param flags flags + + @example + ```js + tiledLayer.setTileGIDAt(1001, 10, 10, 1) + ``` + */ + setTileGIDAt(gid: number, posOrX: Vec2|number, flagsOrY: number, flags?: number): void; + /** + !#en + Returns the tile gid at a given tile coordinate.
+ if it returns 0, it means that the tile is empty.
+ !#zh + 通过给定的 tile 坐标、flags(可选)返回 tile 的 GID.
+ 如果它返回 0,则表示该 tile 为空。
+ @param pos or x + @param y y + + @example + ```js + let tileGid = tiledLayer.getTileGIDAt(0, 0); + ``` + */ + getTileGIDAt(pos: Vec2|number, y?: number): number; + /** + !#en Layer orientation, which is the same as the map orientation. + !#zh 获取 Layer 方向(同地图方向)。 + + @example + ```js + let orientation = tiledLayer.getLayerOrientation(); + cc.log("Layer Orientation: " + orientation); + ``` + */ + getLayerOrientation(): number; + /** + !#en properties from the layer. They can be added using Tiled. + !#zh 获取 layer 的属性,可以使用 Tiled 编辑器添加属性。 + + @example + ```js + let properties = tiledLayer.getProperties(); + cc.log("Properties: " + properties); + ``` + */ + getProperties(): any; + /** + !#en + Get the TiledTile with the tile coordinate.
+ If there is no tile in the specified coordinate and forceCreate parameter is true,
+ then will create a new TiledTile at the coordinate. + The renderer will render the tile with the rotation, scale, position and color property of the TiledTile. + !#zh + 通过指定的 tile 坐标获取对应的 TiledTile。
+ 如果指定的坐标没有 tile,并且设置了 forceCreate 那么将会在指定的坐标创建一个新的 TiledTile 。
+ 在渲染这个 tile 的时候,将会使用 TiledTile 的节点的旋转、缩放、位移、颜色属性。
+ @param x x + @param y y + @param forceCreate forceCreate + + @example + ```js + let tile = tiledLayer.getTiledTileAt(100, 100, true); + cc.log(tile); + ``` + */ + getTiledTileAt(x: number, y: number, forceCreate: boolean): TiledTile; + /** + !#en + Change tile to TiledTile at the specified coordinate. + !#zh + 将指定的 tile 坐标替换为指定的 TiledTile。 + @param x x + @param y y + @param tiledTile tiledTile + */ + setTiledTileAt(x: number, y: number, tiledTile: TiledTile): TiledTile; + /** + !#en Return texture. + !#zh 获取纹理。 + @param index The index of textures + */ + getTexture(index: any): Texture2D; + /** + !#en Return texture. + !#zh 获取纹理。 + */ + getTextures(): Texture2D; + /** + !#en Set the texture. + !#zh 设置纹理。 + @param texture texture + */ + setTexture(texture: Texture2D): void; + /** + !#en Set the texture. + !#zh 设置纹理。 + @param textures textures + */ + setTexture(textures: Texture2D): void; + /** + !#en Gets layer size. + !#zh 获得层大小。 + + @example + ```js + let size = tiledLayer.getLayerSize(); + cc.log("layer size: " + size); + ``` + */ + getLayerSize(): Size; + /** + !#en Size of the map's tile (could be different from the tile's size). + !#zh 获取 tile 的大小( tile 的大小可能会有所不同)。 + + @example + ```js + let mapTileSize = tiledLayer.getMapTileSize(); + cc.log("MapTile size: " + mapTileSize); + ``` + */ + getMapTileSize(): Size; + /** + !#en Gets Tile set first information for the layer. + !#zh 获取 layer 索引位置为0的 Tileset 信息。 + @param index The index of tilesets + */ + getTileSet(index: any): TMXTilesetInfo; + /** + !#en Gets tile set all information for the layer. + !#zh 获取 layer 所有的 Tileset 信息。 + */ + getTileSet(): TMXTilesetInfo; + /** + !#en Sets tile set information for the layer. + !#zh 设置 layer 的 tileset 信息。 + @param tileset tileset + */ + setTileSet(tileset: TMXTilesetInfo): void; + /** + !#en Sets Tile set information for the layer. + !#zh 设置 layer 的 Tileset 信息。 + @param tilesets tilesets + */ + setTileSets(tilesets: TMXTilesetInfo): void; + } + /** !#en Renders the TMX object group. + !#zh 渲染 tmx object group。 */ + export class TiledObjectGroup extends Component { + /** + !#en Offset position of child objects. + !#zh 获取子对象的偏移位置。 + + @example + ```js + let offset = tMXObjectGroup.getPositionOffset(); + ``` + */ + getPositionOffset(): Vec2; + /** + !#en List of properties stored in a dictionary. + !#zh 以映射的形式获取属性列表。 + + @example + ```js + let offset = tMXObjectGroup.getProperties(); + ``` + */ + getProperties(): any; + /** + !#en Gets the Group name. + !#zh 获取组名称。 + + @example + ```js + let groupName = tMXObjectGroup.getGroupName; + ``` + */ + getGroupName(): string; + /** + !#en + Return the object for the specific object name.
+ It will return the 1st object found on the array for the given name. + !#zh 获取指定的对象。 + @param objectName objectName + + @example + ```js + let object = tMXObjectGroup.getObject("Group"); + ``` + */ + getObject(objectName: string): any; + /** + !#en Gets the objects. + !#zh 获取对象数组。 + + @example + ```js + let objects = tMXObjectGroup.getObjects(); + ``` + */ + getObjects(): any[]; + } + /** Class for tiled map asset handling. */ + export class TiledMapAsset extends Asset { + textures: Texture2D[]; + textureNames: string[]; + textureSizes: Size[]; + imageLayerTextures: Texture2D[]; + imageLayerTextureNames: string[]; + } + /** !#en TiledTile can control the specified map tile. + It will apply the node rotation, scale, translate to the map tile. + You can change the TiledTile's gid to change the map tile's style. + !#zh TiledTile 可以单独对某一个地图块进行操作。 + 他会将节点的旋转,缩放,平移操作应用在这个地图块上,并可以通过更换当前地图块的 gid 来更换地图块的显示样式。 */ + export class TiledTile extends Component { + /** !#en Specify the TiledTile horizontal coordinate,use map tile as the unit. + !#zh 指定 TiledTile 的横向坐标,以地图块为单位 */ + x: number; + /** !#en Specify the TiledTile vertical coordinate,use map tile as the unit. + !#zh 指定 TiledTile 的纵向坐标,以地图块为单位 */ + y: number; + /** !#en Specify the TiledTile gid. + !#zh 指定 TiledTile 的 gid 值 */ + gid: number; + } + /** !#en cc.WebView is a component for display web pages in the game. Because different platforms have different authorization, API and control methods for WebView component. And have not yet formed a unified standard, only Web, iOS, and Android platforms are currently supported. + !#zh WebView 组件,用于在游戏中显示网页。由于不同平台对于 WebView 组件的授权、API、控制方式都不同,还没有形成统一的标准,所以目前只支持 Web、iOS 和 Android 平台。 */ + export class WebView extends Component { + /** !#en A given URL to be loaded by the WebView, it should have a http or https prefix. + !#zh 指定 WebView 加载的网址,它应该是一个 http 或者 https 开头的字符串 */ + url: string; + /** !#en The webview's event callback , it will be triggered when certain webview event occurs. + !#zh WebView 的回调事件,当网页加载过程中,加载完成后或者加载出错时都会回调此函数 */ + webviewLoadedEvents: Component.EventHandler[]; + /** + !#en + Set javascript interface scheme (see also setOnJSCallback).
+ Note: Supports only on the Android and iOS. For HTML5, please refer to the official documentation.
+ Please refer to the official documentation for more details. + !#zh + 设置 JavaScript 接口方案(与 'setOnJSCallback' 配套使用)。
+ 注意:只支持 Android 和 iOS ,Web 端用法请前往官方文档查看。
+ 详情请参阅官方文档 + @param scheme scheme + */ + setJavascriptInterfaceScheme(scheme: string): void; + /** + !#en + This callback called when load URL that start with javascript + interface scheme (see also setJavascriptInterfaceScheme).
+ Note: Supports only on the Android and iOS. For HTML5, please refer to the official documentation.
+ Please refer to the official documentation for more details. + !#zh + 当加载 URL 以 JavaScript 接口方案开始时调用这个回调函数。
+ 注意:只支持 Android 和 iOS,Web 端用法请前往官方文档查看。 + 详情请参阅官方文档 + @param callback callback + */ + setOnJSCallback(callback: Function): void; + /** + !#en + Evaluates JavaScript in the context of the currently displayed page.
+ Please refer to the official document for more details
+ Note: Cross domain issues need to be resolved by yourself
+ !#zh + 执行 WebView 内部页面脚本(详情请参阅官方文档)
+ 注意:需要自行解决跨域问题 + @param str str + */ + evaluateJS(str: string): void; + /** + !#en if you don't need the WebView and it isn't in any running Scene, you should + call the destroy method on this component or the associated node explicitly. + Otherwise, the created DOM element won't be removed from web page. + !#zh + 如果你不再使用 WebView,并且组件未添加到场景中,那么你必须手动对组件或所在节点调用 destroy。 + 这样才能移除网页上的 DOM 节点,避免 Web 平台内存泄露。 + + @example + ```js + webview.node.parent = null; // or webview.node.removeFromParent(false); + // when you don't need webview anymore + webview.node.destroy(); + ``` + */ + destroy(): boolean; + } + /** !#en cc.VideoPlayer is a component for playing videos, you can use it for showing videos in your game. Because different platforms have different authorization, API and control methods for VideoPlayer component. And have not yet formed a unified standard, only Web, iOS, and Android platforms are currently supported. + !#zh Video 组件,用于在游戏中播放视频。由于不同平台对于 VideoPlayer 组件的授权、API、控制方式都不同,还没有形成统一的标准,所以目前只支持 Web、iOS 和 Android 平台。 */ + export class VideoPlayer extends Component { + /** !#en The resource type of videoplayer, REMOTE for remote url and LOCAL for local file path. + !#zh 视频来源:REMOTE 表示远程视频 URL,LOCAL 表示本地视频地址。 */ + resourceType: VideoPlayer.ResourceType; + /** !#en The remote URL of video. + !#zh 远程视频的 URL */ + remoteURL: string; + /** !#en The local video full path. + !#zh 本地视频的 URL */ + clip: string; + /** !#en The current playback time of the now playing item in seconds, you could also change the start playback time. + !#zh 指定视频从什么时间点开始播放,单位是秒,也可以用来获取当前视频播放的时间进度。 */ + currentTime: number; + /** !#en The volume of the video. + !#zh 视频的音量(0.0 ~ 1.0) */ + volume: number; + /** !#en Mutes the VideoPlayer. Mute sets the volume=0, Un-Mute restore the original volume. + !#zh 是否静音视频。静音时设置音量为 0,取消静音是恢复原来的音量。 */ + mute: boolean; + /** !#en Whether keep the aspect ration of the original video. + !#zh 是否保持视频原来的宽高比 */ + keepAspectRatio: boolean; + /** !#en Whether play video in fullscreen mode. + !#zh 是否全屏播放视频 */ + isFullscreen: boolean; + /** !#en Always below the game view (only useful on Web. Note: The specific effects are not guaranteed to be consistent, depending on whether each browser supports or restricts). + !#zh 永远在游戏视图最底层(这个属性只有在 Web 平台上有效果。注意:具体效果无法保证一致,跟各个浏览器是否支持与限制有关) */ + stayOnBottom: boolean; + /** !#en the video player's callback, it will be triggered when certain event occurs, like: playing, paused, stopped and completed. + !#zh 视频播放回调函数,该回调函数会在特定情况被触发,比如播放中,暂时,停止和完成播放。 */ + videoPlayerEvent: Component.EventHandler[]; + /** + !#en If a video is paused, call this method could resume playing. If a video is stopped, call this method to play from scratch. + !#zh 如果视频被暂停播放了,调用这个接口可以继续播放。如果视频被停止播放了,调用这个接口可以从头开始播放。 + */ + play(): void; + /** + !#en If a video is paused, call this method to resume playing. + !#zh 如果一个视频播放被暂停播放了,调用这个接口可以继续播放。 + */ + resume(): void; + /** + !#en If a video is playing, call this method to pause playing. + !#zh 如果一个视频正在播放,调用这个接口可以暂停播放。 + */ + pause(): void; + /** + !#en If a video is playing, call this method to stop playing immediately. + !#zh 如果一个视频正在播放,调用这个接口可以立马停止播放。 + */ + stop(): void; + /** + !#en Gets the duration of the video + !#zh 获取视频文件的播放总时长 + */ + getDuration(): number; + /** + !#en Determine whether video is playing or not. + !#zh 判断当前视频是否处于播放状态 + */ + isPlaying(): boolean; + /** + !#en if you don't need the VideoPlayer and it isn't in any running Scene, you should + call the destroy method on this component or the associated node explicitly. + Otherwise, the created DOM element won't be removed from web page. + !#zh + 如果你不再使用 VideoPlayer,并且组件未添加到场景中,那么你必须手动对组件或所在节点调用 destroy。 + 这样才能移除网页上的 DOM 节点,避免 Web 平台内存泄露。 + + @example + ```js + videoplayer.node.parent = null; // or videoplayer.node.removeFromParent(false); + // when you don't need videoplayer anymore + videoplayer.node.destroy(); + ``` + */ + destroy(): boolean; + } + /** !#en An object to boot the game. + !#zh 包含游戏主体信息并负责驱动游戏的游戏对象。 */ + export class debug { + /** + !#en Gets error message with the error id and possible parameters. + !#zh 通过 error id 和必要的参数来获取错误信息。 + @param errorId errorId + @param param param + */ + static getError(errorId: string, param?: any): string; + /** + !#en Returns whether or not to display the FPS informations. + !#zh 是否显示 FPS 信息。 + */ + static isDisplayStats(): boolean; + /** + !#en Sets whether display the FPS on the bottom-left corner. + !#zh 设置是否在左下角显示 FPS。 + @param displayStats displayStats + */ + static setDisplayStats(displayStats: boolean): void; + } + /** !#en An object to boot the game. + !#zh 包含游戏主体信息并负责驱动游戏的游戏对象。 */ + export class Game extends EventTarget { + /** !#en Event triggered when game hide to background. + Please note that this event is not 100% guaranteed to be fired on Web platform, + on native platforms, it corresponds to enter background event, os status bar or notification center may not trigger this event. + !#zh 游戏进入后台时触发的事件。 + 请注意,在 WEB 平台,这个事件不一定会 100% 触发,这完全取决于浏览器的回调行为。 + 在原生平台,它对应的是应用被切换到后台事件,下拉菜单和上拉状态栏等不一定会触发这个事件,这取决于系统行为。 */ + EVENT_HIDE: string; + /** !#en Event triggered when game back to foreground + Please note that this event is not 100% guaranteed to be fired on Web platform, + on native platforms, it corresponds to enter foreground event. + !#zh 游戏进入前台运行时触发的事件。 + 请注意,在 WEB 平台,这个事件不一定会 100% 触发,这完全取决于浏览器的回调行为。 + 在原生平台,它对应的是应用被切换到前台事件。 */ + EVENT_SHOW: string; + /** !#en Event triggered when game restart + !#zh 调用restart后,触发事件。 */ + EVENT_RESTART: string; + /** Event triggered after game inited, at this point all engine objects and game scripts are loaded */ + EVENT_GAME_INITED: string; + /** Event triggered after engine inited, at this point you will be able to use all engine classes. + It was defined as EVENT_RENDERER_INITED in cocos creator v1.x and renamed in v2.0 */ + EVENT_ENGINE_INITED: string; + /** Web Canvas 2d API as renderer backend */ + RENDER_TYPE_CANVAS: number; + /** WebGL API as renderer backend */ + RENDER_TYPE_WEBGL: number; + /** OpenGL API as renderer backend */ + RENDER_TYPE_OPENGL: number; + /** !#en The outer frame of the game canvas, parent of game container. + !#zh 游戏画布的外框,container 的父容器。 */ + frame: any; + /** !#en The container of game canvas. + !#zh 游戏画布的容器。 */ + container: HTMLDivElement; + /** !#en The canvas of the game. + !#zh 游戏的画布。 */ + canvas: HTMLCanvasElement; + /** !#en The renderer backend of the game. + !#zh 游戏的渲染器类型。 */ + renderType: number; + /** !#en + The current game configuration, including:
+ 1. debugMode
+ "debugMode" possible values :
+ 0 - No message will be printed.
+ 1 - cc.error, cc.assert, cc.warn, cc.log will print in console.
+ 2 - cc.error, cc.assert, cc.warn will print in console.
+ 3 - cc.error, cc.assert will print in console.
+ 4 - cc.error, cc.assert, cc.warn, cc.log will print on canvas, available only on web.
+ 5 - cc.error, cc.assert, cc.warn will print on canvas, available only on web.
+ 6 - cc.error, cc.assert will print on canvas, available only on web.
+ 2. showFPS
+ Left bottom corner fps information will show when "showFPS" equals true, otherwise it will be hide.
+ 3. exposeClassName
+ Expose class name to chrome debug tools, the class intantiate performance is a little bit slower when exposed.
+ 4. frameRate
+ "frameRate" set the wanted frame rate for your game, but the real fps depends on your game implementation and the running environment.
+ 5. id
+ "gameCanvas" sets the id of your canvas element on the web page, it's useful only on web.
+ 6. renderMode
+ "renderMode" sets the renderer type, only useful on web :
+ 0 - Automatically chosen by engine
+ 1 - Forced to use canvas renderer
+ 2 - Forced to use WebGL renderer, but this will be ignored on mobile browsers
+ 7. scenes
+ "scenes" include available scenes in the current bundle.
+
+ Please DO NOT modify this object directly, it won't have any effect.
+ !#zh + 当前的游戏配置,包括:
+ 1. debugMode(debug 模式,但是在浏览器中这个选项会被忽略)
+ "debugMode" 各种设置选项的意义。
+ 0 - 没有消息被打印出来。
+ 1 - cc.error,cc.assert,cc.warn,cc.log 将打印在 console 中。
+ 2 - cc.error,cc.assert,cc.warn 将打印在 console 中。
+ 3 - cc.error,cc.assert 将打印在 console 中。
+ 4 - cc.error,cc.assert,cc.warn,cc.log 将打印在 canvas 中(仅适用于 web 端)。
+ 5 - cc.error,cc.assert,cc.warn 将打印在 canvas 中(仅适用于 web 端)。
+ 6 - cc.error,cc.assert 将打印在 canvas 中(仅适用于 web 端)。
+ 2. showFPS(显示 FPS)
+ 当 showFPS 为 true 的时候界面的左下角将显示 fps 的信息,否则被隐藏。
+ 3. exposeClassName
+ 暴露类名让 Chrome DevTools 可以识别,如果开启会稍稍降低类的创建过程的性能,但对对象构造没有影响。
+ 4. frameRate (帧率)
+ “frameRate” 设置想要的帧率你的游戏,但真正的FPS取决于你的游戏实现和运行环境。
+ 5. id
+ "gameCanvas" Web 页面上的 Canvas Element ID,仅适用于 web 端。
+ 6. renderMode(渲染模式)
+ “renderMode” 设置渲染器类型,仅适用于 web 端:
+ 0 - 通过引擎自动选择。
+ 1 - 强制使用 canvas 渲染。 + 2 - 强制使用 WebGL 渲染,但是在部分 Android 浏览器中这个选项会被忽略。
+ 7. scenes
+ “scenes” 当前包中可用场景。
+
+ 注意:请不要直接修改这个对象,它不会有任何效果。 */ + config: any; + /** + !#en Callback when the scripts of engine have been load. + !#zh 当引擎完成启动后的回调函数。 + */ + onStart(): void; + /** + !#en Set frame rate of game. + !#zh 设置游戏帧率。 + @param frameRate frameRate + */ + setFrameRate(frameRate: number): void; + /** + !#en Get frame rate set for the game, it doesn't represent the real frame rate. + !#zh 获取设置的游戏帧率(不等同于实际帧率)。 + */ + getFrameRate(): number; + /** + !#en Run the game frame by frame. + !#zh 执行一帧游戏循环。 + */ + step(): void; + /** + !#en Pause the game main loop. This will pause: + game logic execution, rendering process, event manager, background music and all audio effects. + This is different with cc.director.pause which only pause the game logic execution. + !#zh 暂停游戏主循环。包含:游戏逻辑,渲染,事件处理,背景音乐和所有音效。这点和只暂停游戏逻辑的 cc.director.pause 不同。 + */ + pause(): void; + /** + !#en Resume the game from pause. This will resume: + game logic execution, rendering process, event manager, background music and all audio effects. + !#zh 恢复游戏主循环。包含:游戏逻辑,渲染,事件处理,背景音乐和所有音效。 + */ + resume(): void; + /** + !#en Check whether the game is paused. + !#zh 判断游戏是否暂停。 + */ + isPaused(): boolean; + /** + !#en Restart game. + !#zh 重新开始游戏 + */ + restart(): void; + /** + !#en End game, it will close the game window + !#zh 退出游戏 + */ + end(): void; + /** + !#en + Register an callback of a specific event type on the game object. + This type of event should be triggered via `emit`. + !#zh + 注册 game 的特定事件类型回调。这种类型的事件应该被 `emit` 触发。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + */ + on(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Register an callback of a specific event type on the game object, + the callback will remove itself after the first time it is triggered. + !#zh + 注册 game 的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + */ + once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; + /** + !#en Prepare game. + !#zh 准备引擎,请不要直接调用这个函数。 + @param cb cb + */ + prepare(cb: Function): void; + /** + !#en Run game with configuration object and onStart function. + !#zh 运行游戏,并且指定引擎配置和 onStart 的回调。 + @param config Pass configuration object or onStart function + @param onStart function to be executed after game initialized + */ + run(config: any, onStart: Function): void; + /** + !#en + Add a persistent root node to the game, the persistent node won't be destroyed during scene transition.
+ The target node must be placed in the root level of hierarchy, otherwise this API won't have any effect. + !#zh + 声明常驻根节点,该节点不会被在场景切换中被销毁。
+ 目标节点必须位于为层级的根节点,否则无效。 + @param node The node to be made persistent + */ + addPersistRootNode(node: Node): void; + /** + !#en Remove a persistent root node. + !#zh 取消常驻根节点。 + @param node The node to be removed from persistent node list + */ + removePersistRootNode(node: Node): void; + /** + !#en Check whether the node is a persistent root node. + !#zh 检查节点是否是常驻根节点。 + @param node The node to be checked + */ + isPersistRootNode(node: Node): boolean; + } + /** !#en +

+ ATTENTION: USE cc.director INSTEAD OF cc.Director.
+ cc.director is a singleton object which manage your game's logic flow.
+ Since the cc.director is a singleton, you don't need to call any constructor or create functions,
+ the standard way to use it is by calling:
+ - cc.director.methodName();
+ + It creates and handle the main Window and manages how and when to execute the Scenes.
+
+ The cc.director is also responsible for:
+ - initializing the OpenGL context
+ - setting the OpenGL pixel format (default on is RGB565)
+ - setting the OpenGL buffer depth (default on is 0-bit)
+ - setting the color for clear screen (default one is BLACK)
+ - setting the projection (default one is 3D)
+ - setting the orientation (default one is Portrait)
+
+
+ The cc.director also sets the default OpenGL context:
+ - GL_TEXTURE_2D is enabled
+ - GL_VERTEX_ARRAY is enabled
+ - GL_COLOR_ARRAY is enabled
+ - GL_TEXTURE_COORD_ARRAY is enabled
+

+

+ cc.director also synchronizes timers with the refresh rate of the display.
+ Features and Limitations:
+ - Scheduled timers & drawing are synchronizes with the refresh rate of the display
+ - Only supports animation intervals of 1/60 1/30 & 1/15
+

+ + !#zh +

+ 注意:用 cc.director 代替 cc.Director。
+ cc.director 一个管理你的游戏的逻辑流程的单例对象。
+ 由于 cc.director 是一个单例,你不需要调用任何构造函数或创建函数,
+ 使用它的标准方法是通过调用:
+ - cc.director.methodName(); +
+ 它创建和处理主窗口并且管理什么时候执行场景。
+
+ cc.director 还负责:
+ - 初始化 OpenGL 环境。
+ - 设置OpenGL像素格式。(默认是 RGB565)
+ - 设置OpenGL缓冲区深度 (默认是 0-bit)
+ - 设置空白场景的颜色 (默认是 黑色)
+ - 设置投影 (默认是 3D)
+ - 设置方向 (默认是 Portrait)
+
+ cc.director 设置了 OpenGL 默认环境
+ - GL_TEXTURE_2D 启用。
+ - GL_VERTEX_ARRAY 启用。
+ - GL_COLOR_ARRAY 启用。
+ - GL_TEXTURE_COORD_ARRAY 启用。
+

+

+ cc.director 也同步定时器与显示器的刷新速率。 +
+ 特点和局限性:
+ - 将计时器 & 渲染与显示器的刷新频率同步。
+ - 只支持动画的间隔 1/60 1/30 & 1/15。
+

*/ + export class Director extends EventTarget { + /** + !#en + Converts a view coordinate to an WebGL coordinate
+ Useful to convert (multi) touches coordinates to the current layout (portrait or landscape)
+ Implementation can be found in CCDirectorWebGL. + !#zh 将触摸点的屏幕坐标转换为 WebGL View 下的坐标。 + @param uiPoint uiPoint + */ + convertToGL(uiPoint: Vec2): Vec2; + /** + !#en + Converts an OpenGL coordinate to a view coordinate
+ Useful to convert node points to window points for calls such as glScissor
+ Implementation can be found in CCDirectorWebGL. + !#zh 将触摸点的 WebGL View 坐标转换为屏幕坐标。 + @param glPoint glPoint + */ + convertToUI(glPoint: Vec2): Vec2; + /** + End the life of director in the next frame + */ + end(): void; + /** + !#en + Returns the size of the WebGL view in points.
+ It takes into account any possible rotation (device orientation) of the window. + !#zh 获取视图的大小,以点为单位。 + */ + getWinSize(): Size; + /** + !#en + Returns the size of the OpenGL view in pixels.
+ It takes into account any possible rotation (device orientation) of the window.
+ On Mac winSize and winSizeInPixels return the same value. + (The pixel here refers to the resource resolution. If you want to get the physics resolution of device, you need to use cc.view.getFrameSize()) + !#zh + 获取视图大小,以像素为单位(这里的像素指的是资源分辨率。 + 如果要获取屏幕物理分辨率,需要用 cc.view.getFrameSize()) + */ + getWinSizeInPixels(): Size; + /** + !#en Pause the director's ticker, only involve the game logic execution. + It won't pause the rendering process nor the event manager. + If you want to pause the entier game including rendering, audio and event, + please use {{#crossLink "Game.pause"}}cc.game.pause{{/crossLink}} + !#zh 暂停正在运行的场景,该暂停只会停止游戏逻辑执行,但是不会停止渲染和 UI 响应。 + 如果想要更彻底得暂停游戏,包含渲染,音频和事件,请使用 {{#crossLink "Game.pause"}}cc.game.pause{{/crossLink}}。 + */ + pause(): void; + /** + !#en + Run a scene. Replaces the running scene with a new one or enter the first scene.
+ The new scene will be launched immediately. + !#zh 立刻切换指定场景。 + @param scene The need run scene. + @param onBeforeLoadScene The function invoked at the scene before loading. + @param onLaunched The function invoked at the scene after launch. + */ + runSceneImmediate(scene: Scene, onBeforeLoadScene?: Function, onLaunched?: Function): void; + /** + !#en Loads the scene by its name. + !#zh 通过场景名称进行加载场景。 + @param sceneName The name of the scene to load. + @param onLaunched callback, will be called after scene launched. + */ + loadScene(sceneName: string, onLaunched?: Function): boolean; + /** + !#en + Preloads the scene to reduces loading time. You can call this method at any time you want. + After calling this method, you still need to launch the scene by `cc.director.loadScene`. + It will be totally fine to call `cc.director.loadScene` at any time even if the preloading is not + yet finished, the scene will be launched after loaded automatically. + !#zh 预加载场景,你可以在任何时候调用这个方法。 + 调用完后,你仍然需要通过 `cc.director.loadScene` 来启动场景,因为这个方法不会执行场景加载操作。 + 就算预加载还没完成,你也可以直接调用 `cc.director.loadScene`,加载完成后场景就会启动。 + @param sceneName The name of the scene to preload. + @param onProgress callback, will be called when the load progression change. + @param onLoaded callback, will be called after scene loaded. + */ + preloadScene(sceneName: string, onProgress?: (completedCount: number, totalCount: number, item: any) => void, onLoaded?: (error: Error, asset: SceneAsset) => void): void; + /** + !#en Resume game logic execution after pause, if the current scene is not paused, nothing will happen. + !#zh 恢复暂停场景的游戏逻辑,如果当前场景没有暂停将没任何事情发生。 + */ + resume(): void; + /** + !#en + Enables or disables WebGL depth test.
+ Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js + !#zh 启用/禁用深度测试(在 Canvas 渲染模式下不会生效)。 + @param on on + */ + setDepthTest(on: boolean): void; + /** + !#en + Set color for clear screen.
+ (Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js) + !#zh + 设置场景的默认擦除颜色。
+ 支持全透明,但不支持透明度为中间值。要支持全透明需手工开启 cc.macro.ENABLE_TRANSPARENT_CANVAS。 + @param clearColor clearColor + */ + setClearColor(clearColor: Color): void; + /** + !#en Returns current logic Scene. + !#zh 获取当前逻辑场景。 + + @example + ```js + // This will help you to get the Canvas node in scene + cc.director.getScene().getChildByName('Canvas'); + ``` + */ + getScene(): Scene; + /** + !#en Returns the FPS value. Please use {{#crossLink "Game.setFrameRate"}}cc.game.setFrameRate{{/crossLink}} to control animation interval. + !#zh 获取单位帧执行时间。请使用 {{#crossLink "Game.setFrameRate"}}cc.game.setFrameRate{{/crossLink}} 来控制游戏帧率。 + */ + getAnimationInterval(): number; + /** + Sets animation interval, this doesn't control the main loop. + To control the game's frame rate overall, please use {{#crossLink "Game.setFrameRate"}}cc.game.setFrameRate{{/crossLink}} + @param value The animation interval desired. + */ + setAnimationInterval(value: number): void; + /** + !#en Returns the delta time since last frame. + !#zh 获取上一帧的增量时间。 + */ + getDeltaTime(): number; + /** + !#en Returns the total passed time since game start, unit: ms + !#zh 获取从游戏开始到现在总共经过的时间,单位为 ms + */ + getTotalTime(): number; + /** + !#en Returns how many frames were called since the director started. + !#zh 获取 director 启动以来游戏运行的总帧数。 + */ + getTotalFrames(): number; + /** + !#en Returns whether or not the Director is paused. + !#zh 是否处于暂停状态。 + */ + isPaused(): boolean; + /** + !#en Returns the cc.Scheduler associated with this director. + !#zh 获取和 director 相关联的 cc.Scheduler。 + */ + getScheduler(): Scheduler; + /** + !#en Sets the cc.Scheduler associated with this director. + !#zh 设置和 director 相关联的 cc.Scheduler。 + @param scheduler scheduler + */ + setScheduler(scheduler: Scheduler): void; + /** + !#en Returns the cc.ActionManager associated with this director. + !#zh 获取和 director 相关联的 cc.ActionManager(动作管理器)。 + */ + getActionManager(): ActionManager; + /** + !#en Sets the cc.ActionManager associated with this director. + !#zh 设置和 director 相关联的 cc.ActionManager(动作管理器)。 + @param actionManager actionManager + */ + setActionManager(actionManager: ActionManager): void; + /** + !#en Returns the cc.CollisionManager associated with this director. + !#zh 获取和 director 相关联的 cc.CollisionManager (碰撞管理器)。 + */ + getCollisionManager(): CollisionManager; + /** + !#en Returns the cc.PhysicsManager associated with this director. + !#zh 返回与 director 相关联的 cc.PhysicsManager (物理管理器)。 + */ + getPhysicsManager(): PhysicsManager; + /** + !#en Returns the cc.Physics3DManager associated with this director. + !#zh 返回与 director 相关联的 cc.Physics3DManager (物理管理器)。 + */ + getPhysics3DManager(): Physics3DManager; + /** !#en The event projection changed of cc.Director. This event will not get triggered since v2.0 + !#zh cc.Director 投影变化的事件。从 v2.0 开始这个事件不会再被触发 */ + static EVENT_PROJECTION_CHANGED: string; + /** !#en The event which will be triggered before loading a new scene. + !#zh 加载新场景之前所触发的事件。 */ + static EVENT_BEFORE_SCENE_LOADING: string; + /** !#en The event which will be triggered before launching a new scene. + !#zh 运行新场景之前所触发的事件。 */ + static EVENT_BEFORE_SCENE_LAUNCH: string; + /** !#en The event which will be triggered after launching a new scene. + !#zh 运行新场景之后所触发的事件。 */ + static EVENT_AFTER_SCENE_LAUNCH: string; + /** !#en The event which will be triggered at the beginning of every frame. + !#zh 每个帧的开始时所触发的事件。 */ + static EVENT_BEFORE_UPDATE: string; + /** !#en The event which will be triggered after engine and components update logic. + !#zh 将在引擎和组件 “update” 逻辑之后所触发的事件。 */ + static EVENT_AFTER_UPDATE: string; + /** !#en The event is deprecated since v2.0, please use cc.Director.EVENT_BEFORE_DRAW instead + !#zh 这个事件从 v2.0 开始被废弃,请直接使用 cc.Director.EVENT_BEFORE_DRAW */ + static EVENT_BEFORE_VISIT: string; + /** !#en The event is deprecated since v2.0, please use cc.Director.EVENT_BEFORE_DRAW instead + !#zh 这个事件从 v2.0 开始被废弃,请直接使用 cc.Director.EVENT_BEFORE_DRAW */ + static EVENT_AFTER_VISIT: string; + /** !#en The event which will be triggered before the rendering process. + !#zh 渲染过程之前所触发的事件。 */ + static EVENT_BEFORE_DRAW: string; + /** !#en The event which will be triggered after the rendering process. + !#zh 渲染过程之后所触发的事件。 */ + static EVENT_AFTER_DRAW: string; + /** Constant for 2D projection (orthogonal projection) */ + static PROJECTION_2D: number; + /** Constant for 3D projection with a fovy=60, znear=0.5f and zfar=1500. */ + static PROJECTION_3D: number; + /** Constant for custom projection, if cc.Director's projection set to it, it calls "updateProjection" on the projection delegate. */ + static PROJECTION_CUSTOM: number; + /** Constant for default projection of cc.Director, default projection is 2D projection */ + static PROJECTION_DEFAULT: number; + } + /** !#en + Class of private entities in Cocos Creator scenes.
+ The PrivateNode is hidden in editor, and completely transparent to users.
+ It's normally used as Node's private content created by components in parent node.
+ So in theory private nodes are not children, they are part of the parent node.
+ Private node have two important characteristics:
+ 1. It has the minimum z index and cannot be modified, because they can't be displayed over real children.
+ 2. The positioning of private nodes is also special, they will consider the left bottom corner of the parent node's bounding box as the origin of local coordinates.
+ In this way, they can be easily kept inside the bounding box.
+ Currently, it's used by RichText component and TileMap component. + !#zh + Cocos Creator 场景中的私有节点类。
+ 私有节点在编辑器中不可见,对用户透明。
+ 通常私有节点是被一些特殊的组件创建出来作为父节点的一部分而存在的,理论上来说,它们不是子节点,而是父节点的组成部分。
+ 私有节点有两个非常重要的特性:
+ 1. 它有着最小的渲染排序的 Z 轴深度,并且无法被更改,因为它们不能被显示在其他正常子节点之上。
+ 2. 它的定位也是特殊的,对于私有节点来说,父节点包围盒的左下角是它的局部坐标系原点,这个原点相当于父节点的位置减去它锚点的偏移。这样私有节点可以比较容易被控制在包围盒之中。
+ 目前在引擎中,RichText 和 TileMap 都有可能生成私有节点。 */ + export class PrivateNode extends Node { + /** + + @param name name + */ + constructor(name?: string); + } + /** !#en + cc.Scene is a subclass of cc.Node that is used only as an abstract concept.
+ cc.Scene and cc.Node are almost identical with the difference that users can not modify cc.Scene manually. + !#zh + cc.Scene 是 cc.Node 的子类,仅作为一个抽象的概念。
+ cc.Scene 和 cc.Node 有点不同,用户不应直接修改 cc.Scene。 */ + export class Scene extends Node { + /** !#en Indicates whether all (directly or indirectly) static referenced assets of this scene are releasable by default after scene unloading. + !#zh 指示该场景中直接或间接静态引用到的所有资源是否默认在场景切换后自动释放。 */ + autoReleaseAssets: boolean; + } + /** !#en + Class of all entities in Cocos Creator scenes.
+ For events supported by Node, please refer to {{#crossLink "Node.EventType"}}{{/crossLink}} + !#zh + Cocos Creator 场景中的所有节点类。
+ 支持的节点事件,请参阅 {{#crossLink "Node.EventType"}}{{/crossLink}}。 */ + export class Node extends _BaseNode { + /** !#en + Group index of node.
+ Which Group this node belongs to will resolve that this node's collision components can collide with which other collision componentns.
+ !#zh + 节点的分组索引。
+ 节点的分组将关系到节点的碰撞组件可以与哪些碰撞组件相碰撞。
*/ + groupIndex: number; + /** !#en + Group of node.
+ Which Group this node belongs to will resolve that this node's collision components can collide with which other collision componentns.
+ !#zh + 节点的分组。
+ 节点的分组将关系到节点的碰撞组件可以与哪些碰撞组件相碰撞。
*/ + group: string; + /** !#en The position (x, y) of the node in its parent's coordinates. + !#zh 节点在父节点坐标系中的位置(x, y)。 */ + position: Vec3; + /** !#en x axis position of node. + !#zh 节点 X 轴坐标。 */ + x: number; + /** !#en y axis position of node. + !#zh 节点 Y 轴坐标。 */ + y: number; + /** !#en z axis position of node. + !#zh 节点 Z 轴坐标。 */ + z: number; + /** !#en Rotation of node. + !#zh 该节点旋转角度。 */ + rotation: number; + /** !#en + Angle of node, the positive value is anti-clockwise direction. + !#zh + 该节点的旋转角度,正值为逆时针方向。 */ + angle: number; + /** !#en The rotation as Euler angles in degrees, used in 3D node. + !#zh 该节点的欧拉角度,用于 3D 节点。 */ + eulerAngles: Vec3; + /** !#en Rotation on x axis. + !#zh 该节点 X 轴旋转角度。 */ + rotationX: number; + /** !#en Rotation on y axis. + !#zh 该节点 Y 轴旋转角度。 */ + rotationY: number; + /** !#en The local scale relative to the parent. + !#zh 节点相对父节点的缩放。 */ + scale: number; + /** !#en Scale on x axis. + !#zh 节点 X 轴缩放。 */ + scaleX: number; + /** !#en Scale on y axis. + !#zh 节点 Y 轴缩放。 */ + scaleY: number; + /** !#en Scale on z axis. + !#zh 节点 Z 轴缩放。 */ + scaleZ: number; + /** !#en Skew x + !#zh 该节点 X 轴倾斜角度。 */ + skewX: number; + /** !#en Skew y + !#zh 该节点 Y 轴倾斜角度。 */ + skewY: number; + /** !#en Opacity of node, default value is 255. + !#zh 节点透明度,默认值为 255。 */ + opacity: number; + /** !#en Color of node, default value is white: (255, 255, 255). + !#zh 节点颜色。默认为白色,数值为:(255,255,255)。 */ + color: Color; + /** !#en Anchor point's position on x axis. + !#zh 节点 X 轴锚点位置。 */ + anchorX: number; + /** !#en Anchor point's position on y axis. + !#zh 节点 Y 轴锚点位置。 */ + anchorY: number; + /** !#en Width of node. + !#zh 节点宽度。 */ + width: number; + /** !#en Height of node. + !#zh 节点高度。 */ + height: number; + /** !#en zIndex is the 'key' used to sort the node relative to its siblings.
+ The value of zIndex should be in the range between cc.macro.MIN_ZINDEX and cc.macro.MAX_ZINDEX.
+ The Node's parent will sort all its children based on the zIndex value and the arrival order.
+ Nodes with greater zIndex will be sorted after nodes with smaller zIndex.
+ If two nodes have the same zIndex, then the node that was added first to the children's array will be in front of the other node in the array.
+ Node's order in children list will affect its rendering order. Parent is always rendering before all children. + !#zh zIndex 是用来对节点进行排序的关键属性,它决定一个节点在兄弟节点之间的位置。
+ zIndex 的取值应该介于 cc.macro.MIN_ZINDEX 和 cc.macro.MAX_ZINDEX 之间 + 父节点主要根据节点的 zIndex 和添加次序来排序,拥有更高 zIndex 的节点将被排在后面,如果两个节点的 zIndex 一致,先添加的节点会稳定排在另一个节点之前。
+ 节点在 children 中的顺序决定了其渲染顺序。父节点永远在所有子节点之前被渲染 */ + zIndex: number; + /** !#en + Switch 2D/3D node. The 2D nodes will run faster. + !#zh + 切换 2D/3D 节点,2D 节点会有更高的运行效率 */ + is3DNode: boolean; + /** !#en Returns a normalized vector representing the up direction (Y axis) of the node in world space. + !#zh 获取节点正上方(y 轴)面对的方向,返回值为世界坐标系下的归一化向量 */ + up: Vec3; + /** !#en Returns a normalized vector representing the right direction (X axis) of the node in world space. + !#zh 获取节点正右方(x 轴)面对的方向,返回值为世界坐标系下的归一化向量 */ + right: Vec3; + /** !#en Returns a normalized vector representing the forward direction (Z axis) of the node in world space. + !#zh 获取节点正前方(z 轴)面对的方向,返回值为世界坐标系下的归一化向量 */ + forward: Vec3; + /** + + @param name name + */ + constructor(name?: string); + /** + !#en + Register a callback of a specific event type on Node.
+ Use this method to register touch or mouse event permit propagation based on scene graph,
+ These kinds of event are triggered with dispatchEvent, the dispatch process has three steps:
+ 1. Capturing phase: dispatch in capture targets (`_getCapturingTargets`), e.g. parents in node tree, from root to the real target
+ 2. At target phase: dispatch to the listeners of the real target
+ 3. Bubbling phase: dispatch in bubble targets (`_getBubblingTargets`), e.g. parents in node tree, from the real target to root
+ In any moment of the dispatching process, it can be stopped via `event.stopPropagation()` or `event.stopPropagationImmidiate()`.
+ It's the recommended way to register touch/mouse event for Node,
+ please do not use cc.eventManager directly for Node.
+ You can also register custom event and use `emit` to trigger custom event on Node.
+ For such events, there won't be capturing and bubbling phase, your event will be dispatched directly to its listeners registered on the same node.
+ You can also pass event callback parameters with `emit` by passing parameters after `type`. + !#zh + 在节点上注册指定类型的回调函数,也可以设置 target 用于绑定响应函数的 this 对象。
+ 鼠标或触摸事件会被系统调用 dispatchEvent 方法触发,触发的过程包含三个阶段:
+ 1. 捕获阶段:派发事件给捕获目标(通过 `_getCapturingTargets` 获取),比如,节点树中注册了捕获阶段的父节点,从根节点开始派发直到目标节点。
+ 2. 目标阶段:派发给目标节点的监听器。
+ 3. 冒泡阶段:派发事件给冒泡目标(通过 `_getBubblingTargets` 获取),比如,节点树中注册了冒泡阶段的父节点,从目标节点开始派发直到根节点。
+ 同时您可以将事件派发到父节点或者通过调用 stopPropagation 拦截它。
+ 推荐使用这种方式来监听节点上的触摸或鼠标事件,请不要在节点上直接使用 cc.eventManager。
+ 你也可以注册自定义事件到节点上,并通过 emit 方法触发此类事件,对于这类事件,不会发生捕获冒泡阶段,只会直接派发给注册在该节点上的监听器
+ 你可以通过在 emit 方法调用时在 type 之后传递额外的参数作为事件回调的参数列表 + @param type A string representing the event type to listen for.
See {{#crossLink "Node/EventTyupe/POSITION_CHANGED"}}Node Events{{/crossLink}} for all builtin events. + @param callback The callback that will be invoked when the event is dispatched. The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + @param useCapture When set to true, the listener will be triggered at capturing phase which is ahead of the final target emit, otherwise it will be triggered during bubbling phase. + + @example + ```js + this.node.on(cc.Node.EventType.TOUCH_START, this.memberFunction, this); // if "this" is component and the "memberFunction" declared in CCClass. + node.on(cc.Node.EventType.TOUCH_START, callback, this); + node.on(cc.Node.EventType.TOUCH_MOVE, callback, this); + node.on(cc.Node.EventType.TOUCH_END, callback, this); + node.on(cc.Node.EventType.TOUCH_CANCEL, callback, this); + node.on(cc.Node.EventType.ANCHOR_CHANGED, callback); + node.on(cc.Node.EventType.COLOR_CHANGED, callback); + ``` + */ + on(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Register an callback of a specific event type on the Node, + the callback will remove itself after the first time it is triggered. + !#zh + 注册节点的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + node.once(cc.Node.EventType.ANCHOR_CHANGED, callback); + ``` + */ + once(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Removes the callback previously registered with the same type, callback, target and or useCapture. + This method is merely an alias to removeEventListener. + !#zh 删除之前与同类型,回调,目标或 useCapture 注册的回调。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + @param useCapture When set to true, the listener will be triggered at capturing phase which is ahead of the final target emit, otherwise it will be triggered during bubbling phase. + + @example + ```js + this.node.off(cc.Node.EventType.TOUCH_START, this.memberFunction, this); + node.off(cc.Node.EventType.TOUCH_START, callback, this.node); + node.off(cc.Node.EventType.ANCHOR_CHANGED, callback, this); + ``` + */ + off(type: string, callback?: Function, target?: any, useCapture?: boolean): void; + /** + !#en Removes all callbacks previously registered with the same target. + !#zh 移除目标上的所有注册事件。 + @param target The target to be searched for all related callbacks + + @example + ```js + node.targetOff(target); + ``` + */ + targetOff(target: any): void; + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en + Trigger an event directly with the event name and necessary arguments. + !#zh + 通过事件名发送自定义事件 + @param type event type + @param arg1 First argument in callback + @param arg2 Second argument in callback + @param arg3 Third argument in callback + @param arg4 Fourth argument in callback + @param arg5 Fifth argument in callback + + @example + ```js + eventTarget.emit('fire', event); + eventTarget.emit('fire', message, emitter); + ``` + */ + emit(type: string, arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any): void; + /** + !#en + Dispatches an event into the event flow. + The event target is the EventTarget object upon which the dispatchEvent() method is called. + !#zh 分发事件到事件流中。 + @param event The Event object that is dispatched into the event flow + */ + dispatchEvent(event: Event): void; + /** + !#en Pause node related system events registered with the current Node. Node system events includes touch and mouse events. + If recursive is set to true, then this API will pause the node system events for the node and all nodes in its sub node tree. + Reference: http://docs.cocos2d-x.org/editors_and_tools/creator-chapters/scripting/internal-events/ + !#zh 暂停当前节点上注册的所有节点系统事件,节点系统事件包含触摸和鼠标事件。 + 如果传递 recursive 为 true,那么这个 API 将暂停本节点和它的子树上所有节点的节点系统事件。 + 参考:https://www.cocos.com/docs/creator/scripting/internal-events.html + @param recursive Whether to pause node system events on the sub node tree. + + @example + ```js + node.pauseSystemEvents(true); + ``` + */ + pauseSystemEvents(recursive: boolean): void; + /** + !#en Resume node related system events registered with the current Node. Node system events includes touch and mouse events. + If recursive is set to true, then this API will resume the node system events for the node and all nodes in its sub node tree. + Reference: http://docs.cocos2d-x.org/editors_and_tools/creator-chapters/scripting/internal-events/ + !#zh 恢复当前节点上注册的所有节点系统事件,节点系统事件包含触摸和鼠标事件。 + 如果传递 recursive 为 true,那么这个 API 将恢复本节点和它的子树上所有节点的节点系统事件。 + 参考:https://www.cocos.com/docs/creator/scripting/internal-events.html + @param recursive Whether to resume node system events on the sub node tree. + + @example + ```js + node.resumeSystemEvents(true); + ``` + */ + resumeSystemEvents(recursive: boolean): void; + /** + !#en + Executes an action, and returns the action that is executed.
+ The node becomes the action's target. Refer to cc.Action's getTarget()
+ Calling runAction while the node is not active won't have any effect.
+ Note:You shouldn't modify the action after runAction, that won't take any effect.
+ if you want to modify, when you define action plus. + !#zh + 执行并返回该执行的动作。该节点将会变成动作的目标。
+ 调用 runAction 时,节点自身处于不激活状态将不会有任何效果。
+ 注意:你不应该修改 runAction 后的动作,将无法发挥作用,如果想进行修改,请在定义 action 时加入。 + @param action action + + @example + ```js + var action = cc.scaleTo(0.2, 1, 0.6); + node.runAction(action); + node.runAction(action).repeatForever(); // fail + node.runAction(action.repeatForever()); // right + ``` + */ + runAction(action: Action): Action; + /** + !#en Pause all actions running on the current node. Equals to `cc.director.getActionManager().pauseTarget(node)`. + !#zh 暂停本节点上所有正在运行的动作。和 `cc.director.getActionManager().pauseTarget(node);` 等价。 + + @example + ```js + node.pauseAllActions(); + ``` + */ + pauseAllActions(): void; + /** + !#en Resume all paused actions on the current node. Equals to `cc.director.getActionManager().resumeTarget(node)`. + !#zh 恢复运行本节点上所有暂停的动作。和 `cc.director.getActionManager().resumeTarget(node);` 等价。 + + @example + ```js + node.resumeAllActions(); + ``` + */ + resumeAllActions(): void; + /** + !#en Stops and removes all actions from the running action list . + !#zh 停止并且移除所有正在运行的动作列表。 + + @example + ```js + node.stopAllActions(); + ``` + */ + stopAllActions(): void; + /** + !#en Stops and removes an action from the running action list. + !#zh 停止并移除指定的动作。 + @param action An action object to be removed. + + @example + ```js + var action = cc.scaleTo(0.2, 1, 0.6); + node.stopAction(action); + ``` + */ + stopAction(action: Action): void; + /** + !#en Removes an action from the running action list by its tag. + !#zh 停止并且移除指定标签的动作。 + @param tag A tag that indicates the action to be removed. + + @example + ```js + node.stopActionByTag(1); + ``` + */ + stopActionByTag(tag: number): void; + /** + !#en Returns an action from the running action list by its tag. + !#zh 通过标签获取指定动作。 + @param tag tag + + @example + ```js + var action = node.getActionByTag(1); + ``` + */ + getActionByTag(tag: number): Action; + /** + !#en + Returns the numbers of actions that are running plus the ones that are schedule to run (actions in actionsToAdd and actions arrays).
+ Composable actions are counted as 1 action. Example:
+ If you are running 1 Sequence of 7 actions, it will return 1.
+ If you are running 7 Sequences of 2 actions, it will return 7.

+ !#zh + 获取运行着的动作加上正在调度运行的动作的总数。
+ 例如:
+ - 如果你正在运行 7 个动作中的 1 个 Sequence,它将返回 1。
+ - 如果你正在运行 2 个动作中的 7 个 Sequence,它将返回 7。
+ + @example + ```js + var count = node.getNumberOfRunningActions(); + cc.log("Running Action Count: " + count); + ``` + */ + getNumberOfRunningActions(): number; + /** + !#en + Returns a copy of the position (x, y, z) of the node in its parent's coordinates. + You can pass a cc.Vec2 or cc.Vec3 as the argument to receive the return values. + !#zh + 获取节点在父节点坐标系中的位置(x, y, z)。 + 你可以传一个 cc.Vec2 或者 cc.Vec3 作为参数来接收返回值。 + @param out The return value to receive position + + @example + ```js + cc.log("Node Position: " + node.getPosition()); + ``` + */ + getPosition(out?: Vec2|Vec3): Vec2; + /** + !#en + Sets the position (x, y, z) of the node in its parent's coordinates.
+ Usually we use cc.v2(x, y) to compose cc.Vec2 object,
+ and passing two numbers (x, y) is more efficient than passing cc.Vec2 object. + For 3D node we can use cc.v3(x, y, z) to compose cc.Vec3 object,
+ and passing three numbers (x, y, z) is more efficient than passing cc.Vec3 object. + !#zh + 设置节点在父节点坐标系中的位置。
+ 可以通过下面的方式设置坐标点:
+ 1. 传入 2 个数值 x, y。
+ 2. 传入 cc.v2(x, y) 类型为 cc.Vec2 的对象。 + 3. 对于 3D 节点可以传入 3 个数值 x, y, z。
+ 4. 对于 3D 节点可以传入 cc.v3(x, y, z) 类型为 cc.Vec3 的对象。 + @param newPosOrX X coordinate for position or the position (x, y, z) of the node in coordinates + @param y Y coordinate for position + @param z Z coordinate for position + */ + setPosition(newPosOrX: Vec2|Vec3|number, y?: number, z?: number): void; + /** + !#en + Returns the scale factor of the node. + Need pass a cc.Vec2 or cc.Vec3 as the argument to receive the return values. + !#zh 获取节点的缩放,需要传一个 cc.Vec2 或者 cc.Vec3 作为参数来接收返回值。 + @param out out + + @example + ```js + cc.log("Node Scale: " + node.getScale(cc.v3())); + ``` + */ + getScale(out: Vec2|Vec3): Vec2; + /** + !#en + Sets the scale of axis in local coordinates of the node. + You can operate 2 axis in 2D node, and 3 axis in 3D node. + !#zh + 设置节点在本地坐标系中坐标轴上的缩放比例。 + 2D 节点可以操作两个坐标轴,而 3D 节点可以操作三个坐标轴。 + @param x scaleX or scale object + @param y y + @param z z + + @example + ```js + node.setScale(cc.v2(2, 2)); + node.setScale(cc.v3(2, 2, 2)); // for 3D node + node.setScale(2); + ``` + */ + setScale(x: number|Vec2|Vec3, y?: number, z?: number): void; + /** + !#en + Get rotation of node (in quaternion). + Need pass a cc.Quat as the argument to receive the return values. + !#zh + 获取该节点的 quaternion 旋转角度,需要传一个 cc.Quat 作为参数来接收返回值。 + @param out out + */ + getRotation(out: Quat): Quat; + /** + !#en Set rotation of node (in quaternion). + !#zh 设置该节点的 quaternion 旋转角度。 + @param quat Quaternion object represents the rotation or the x value of quaternion + @param y y value of quternion + @param z z value of quternion + @param w w value of quternion + */ + setRotation(quat: Quat|number, y?: number, z?: number, w?: number): void; + /** + !#en + Returns a copy the untransformed size of the node.
+ The contentSize remains the same no matter the node is scaled or rotated.
+ All nodes has a size. Layer and Scene has the same size of the screen by default.
+ !#zh 获取节点自身大小,不受该节点是否被缩放或者旋转的影响。 + + @example + ```js + cc.log("Content Size: " + node.getContentSize()); + ``` + */ + getContentSize(): Size; + /** + !#en + Sets the untransformed size of the node.
+ The contentSize remains the same no matter the node is scaled or rotated.
+ All nodes has a size. Layer and Scene has the same size of the screen. + !#zh 设置节点原始大小,不受该节点是否被缩放或者旋转的影响。 + @param size The untransformed size of the node or The untransformed size's width of the node. + @param height The untransformed size's height of the node. + + @example + ```js + node.setContentSize(cc.size(100, 100)); + node.setContentSize(100, 100); + ``` + */ + setContentSize(size: Size|number, height?: number): void; + /** + !#en + Returns a copy of the anchor point.
+ Anchor point is the point around which all transformations and positioning manipulations take place.
+ It's like a pin in the node where it is "attached" to its parent.
+ The anchorPoint is normalized, like a percentage. (0,0) means the bottom-left corner and (1,1) means the top-right corner.
+ But you can use values higher than (1,1) and lower than (0,0) too.
+ The default anchor point is (0.5,0.5), so it starts at the center of the node. + !#zh + 获取节点锚点,用百分比表示。
+ 锚点应用于所有变换和坐标点的操作,它就像在节点上连接其父节点的大头针。
+ 锚点是标准化的,就像百分比一样。(0,0) 表示左下角,(1,1) 表示右上角。
+ 但是你可以使用比(1,1)更高的值或者比(0,0)更低的值。
+ 默认的锚点是(0.5,0.5),因此它开始于节点的中心位置。
+ 注意:Creator 中的锚点仅用于定位所在的节点,子节点的定位不受影响。 + + @example + ```js + cc.log("Node AnchorPoint: " + node.getAnchorPoint()); + ``` + */ + getAnchorPoint(): Vec2; + /** + !#en + Sets the anchor point in percent.
+ anchor point is the point around which all transformations and positioning manipulations take place.
+ It's like a pin in the node where it is "attached" to its parent.
+ The anchorPoint is normalized, like a percentage. (0,0) means the bottom-left corner and (1,1) means the top-right corner.
+ But you can use values higher than (1,1) and lower than (0,0) too.
+ The default anchor point is (0.5,0.5), so it starts at the center of the node. + !#zh + 设置锚点的百分比。
+ 锚点应用于所有变换和坐标点的操作,它就像在节点上连接其父节点的大头针。
+ 锚点是标准化的,就像百分比一样。(0,0) 表示左下角,(1,1) 表示右上角。
+ 但是你可以使用比(1,1)更高的值或者比(0,0)更低的值。
+ 默认的锚点是(0.5,0.5),因此它开始于节点的中心位置。
+ 注意:Creator 中的锚点仅用于定位所在的节点,子节点的定位不受影响。 + @param point The anchor point of node or The x axis anchor of node. + @param y The y axis anchor of node. + + @example + ```js + node.setAnchorPoint(cc.v2(1, 1)); + node.setAnchorPoint(1, 1); + ``` + */ + setAnchorPoint(point: Vec2|number, y?: number): void; + /** + !#en Set rotation by lookAt target point, normally used by Camera Node + !#zh 通过观察目标来设置 rotation,一般用于 Camera Node 上 + @param pos pos + @param up default is (0,1,0) + */ + lookAt(pos: Vec3, up?: Vec3): void; + /** + !#en + Get the local transform matrix (4x4), based on parent node coordinates + !#zh 返回局部空间坐标系的矩阵,基于父节点坐标系。 + @param out The matrix object to be filled with data + + @example + ```js + let mat4 = cc.mat4(); + node.getLocalMatrix(mat4); + ``` + */ + getLocalMatrix(out: Mat4): Mat4; + /** + !#en + Get the world transform matrix (4x4) + !#zh 返回世界空间坐标系的矩阵。 + @param out The matrix object to be filled with data + + @example + ```js + let mat4 = cc.mat4(); + node.getWorldMatrix(mat4); + ``` + */ + getWorldMatrix(out: Mat4): Mat4; + /** + !#en + Converts a Point to node (local) space coordinates. + !#zh + 将一个点转换到节点 (局部) 空间坐标系。 + @param worldPoint worldPoint + @param out out + + @example + ```js + var newVec2 = node.convertToNodeSpaceAR(cc.v2(100, 100)); + var newVec3 = node.convertToNodeSpaceAR(cc.v3(100, 100, 100)); + ``` + */ + convertToNodeSpaceAR(worldPoint: T, out?: T): T; + /** + !#en + Converts a Point in node coordinates to world space coordinates. + !#zh + 将节点坐标系下的一个点转换到世界空间坐标系。 + @param nodePoint nodePoint + @param out out + + @example + ```js + var newVec2 = node.convertToWorldSpaceAR(cc.v2(100, 100)); + var newVec3 = node.convertToWorldSpaceAR(cc.v3(100, 100, 100)); + ``` + */ + convertToWorldSpaceAR(nodePoint: T, out?: T): T; + /** + !#en Converts a Point to node (local) space coordinates then add the anchor point position. + So the return position will be related to the left bottom corner of the node's bounding box. + This equals to the API behavior of cocos2d-x, you probably want to use convertToNodeSpaceAR instead + !#zh 将一个点转换到节点 (局部) 坐标系,并加上锚点的坐标。
+ 也就是说返回的坐标是相对于节点包围盒左下角的坐标。
+ 这个 API 的设计是为了和 cocos2d-x 中行为一致,更多情况下你可能需要使用 convertToNodeSpaceAR。 + @param worldPoint worldPoint + + @example + ```js + var newVec2 = node.convertToNodeSpace(cc.v2(100, 100)); + ``` + */ + convertToNodeSpace(worldPoint: Vec2): Vec2; + /** + !#en Converts a Point related to the left bottom corner of the node's bounding box to world space coordinates. + This equals to the API behavior of cocos2d-x, you probably want to use convertToWorldSpaceAR instead + !#zh 将一个相对于节点左下角的坐标位置转换到世界空间坐标系。 + 这个 API 的设计是为了和 cocos2d-x 中行为一致,更多情况下你可能需要使用 convertToWorldSpaceAR + @param nodePoint nodePoint + + @example + ```js + var newVec2 = node.convertToWorldSpace(cc.v2(100, 100)); + ``` + */ + convertToWorldSpace(nodePoint: Vec2): Vec2; + /** + !#en + Returns the matrix that transform the node's (local) space coordinates into the parent's space coordinates.
+ The matrix is in Pixels. + !#zh 返回这个将节点(局部)的空间坐标系转换成父节点的空间坐标系的矩阵。这个矩阵以像素为单位。 + @param out The affine transform object to be filled with data + + @example + ```js + let affineTransform = cc.AffineTransform.create(); + node.getNodeToParentTransform(affineTransform); + ``` + */ + getNodeToParentTransform(out?: AffineTransform): AffineTransform; + /** + !#en + Returns the matrix that transform the node's (local) space coordinates into the parent's space coordinates.
+ The matrix is in Pixels.
+ This method is AR (Anchor Relative). + !#zh + 返回这个将节点(局部)的空间坐标系转换成父节点的空间坐标系的矩阵。
+ 这个矩阵以像素为单位。
+ 该方法基于节点坐标。 + @param out The affine transform object to be filled with data + + @example + ```js + let affineTransform = cc.AffineTransform.create(); + node.getNodeToParentTransformAR(affineTransform); + ``` + */ + getNodeToParentTransformAR(out?: AffineTransform): AffineTransform; + /** + !#en Returns the world affine transform matrix. The matrix is in Pixels. + !#zh 返回节点到世界坐标系的仿射变换矩阵。矩阵单位是像素。 + @param out The affine transform object to be filled with data + + @example + ```js + let affineTransform = cc.AffineTransform.create(); + node.getNodeToWorldTransform(affineTransform); + ``` + */ + getNodeToWorldTransform(out?: AffineTransform): AffineTransform; + /** + !#en + Returns the world affine transform matrix. The matrix is in Pixels.
+ This method is AR (Anchor Relative). + !#zh + 返回节点到世界坐标仿射变换矩阵。矩阵单位是像素。
+ 该方法基于节点坐标。 + @param out The affine transform object to be filled with data + + @example + ```js + let affineTransform = cc.AffineTransform.create(); + node.getNodeToWorldTransformAR(affineTransform); + ``` + */ + getNodeToWorldTransformAR(out?: AffineTransform): AffineTransform; + /** + !#en + Returns the matrix that transform parent's space coordinates to the node's (local) space coordinates.
+ The matrix is in Pixels. The returned transform is readonly and cannot be changed. + !#zh + 返回将父节点的坐标系转换成节点(局部)的空间坐标系的矩阵。
+ 该矩阵以像素为单位。返回的矩阵是只读的,不能更改。 + @param out The affine transform object to be filled with data + + @example + ```js + let affineTransform = cc.AffineTransform.create(); + node.getParentToNodeTransform(affineTransform); + ``` + */ + getParentToNodeTransform(out?: AffineTransform): AffineTransform; + /** + !#en Returns the inverse world affine transform matrix. The matrix is in Pixels. + !#en 返回世界坐标系到节点坐标系的逆矩阵。 + @param out The affine transform object to be filled with data + + @example + ```js + let affineTransform = cc.AffineTransform.create(); + node.getWorldToNodeTransform(affineTransform); + ``` + */ + getWorldToNodeTransform(out?: AffineTransform): AffineTransform; + /** + !#en convenience methods which take a cc.Touch instead of cc.Vec2. + !#zh 将触摸点转换成本地坐标系中位置。 + @param touch The touch object + + @example + ```js + var newVec2 = node.convertTouchToNodeSpace(touch); + ``` + */ + convertTouchToNodeSpace(touch: Touch): Vec2; + /** + !#en converts a cc.Touch (world coordinates) into a local coordinate. This method is AR (Anchor Relative). + !#zh 转换一个 cc.Touch(世界坐标)到一个局部坐标,该方法基于节点坐标。 + @param touch The touch object + + @example + ```js + var newVec2 = node.convertTouchToNodeSpaceAR(touch); + ``` + */ + convertTouchToNodeSpaceAR(touch: Touch): Vec2; + /** + !#en + Returns a "local" axis aligned bounding box of the node.
+ The returned box is relative only to its parent. + !#zh 返回父节坐标系下的轴向对齐的包围盒。 + + @example + ```js + var boundingBox = node.getBoundingBox(); + ``` + */ + getBoundingBox(): Rect; + /** + !#en + Returns a "world" axis aligned bounding box of the node.
+ The bounding box contains self and active children's world bounding box. + !#zh + 返回节点在世界坐标系下的对齐轴向的包围盒(AABB)。
+ 该边框包含自身和已激活的子节点的世界边框。 + + @example + ```js + var newRect = node.getBoundingBoxToWorld(); + ``` + */ + getBoundingBoxToWorld(): Rect; + /** + !#en + Adds a child to the node with z order and name. + !#zh + 添加子节点,并且可以修改该节点的 局部 Z 顺序和名字。 + @param child A child node + @param zIndex Z order for drawing priority. Please refer to zIndex property + @param name A name to identify the node easily. Please refer to name property + + @example + ```js + node.addChild(newNode, 1, "node"); + ``` + */ + addChild(child: Node, zIndex?: number, name?: string): void; + /** + !#en Stops all running actions and schedulers. + !#zh 停止所有正在播放的动作和计时器。 + + @example + ```js + node.cleanup(); + ``` + */ + cleanup(): void; + /** + !#en Sorts the children array depends on children's zIndex and arrivalOrder, + normally you won't need to invoke this function. + !#zh 根据子节点的 zIndex 和 arrivalOrder 进行排序,正常情况下开发者不需要手动调用这个函数。 + */ + sortAllChildren(): void; + /** + !#en + Returns the displayed opacity of Node, + the difference between displayed opacity and opacity is that displayed opacity is calculated based on opacity and parent node's opacity when cascade opacity enabled. + !#zh + 获取节点显示透明度, + 显示透明度和透明度之间的不同之处在于当启用级连透明度时, + 显示透明度是基于自身透明度和父节点透明度计算的。 + */ + getDisplayedOpacity(): number; + /** + !#en + Returns the displayed color of Node, + the difference between displayed color and color is that displayed color is calculated based on color and parent node's color when cascade color enabled. + !#zh + 获取节点的显示颜色, + 显示颜色和颜色之间的不同之处在于当启用级连颜色时, + 显示颜色是基于自身颜色和父节点颜色计算的。 + */ + getDisplayedColor(): Color; + /** !#en Cascade opacity is removed from v2.0 + Indicate whether node's opacity value affect its child nodes, default value is true. + !#zh 透明度级联功能从 v2.0 开始已移除 + 节点的不透明度值是否影响其子节点,默认值为 true。 */ + cascadeOpacity: boolean; + /** + !#en Cascade opacity is removed from v2.0 + Returns whether node's opacity value affect its child nodes. + !#zh 透明度级联功能从 v2.0 开始已移除 + 返回节点的不透明度值是否影响其子节点。 + */ + isCascadeOpacityEnabled(): boolean; + /** + !#en Cascade opacity is removed from v2.0 + Enable or disable cascade opacity, if cascade enabled, child nodes' opacity will be the multiplication of parent opacity and its own opacity. + !#zh 透明度级联功能从 v2.0 开始已移除 + 启用或禁用级连不透明度,如果级连启用,子节点的不透明度将是父不透明度乘上它自己的不透明度。 + @param cascadeOpacityEnabled cascadeOpacityEnabled + */ + setCascadeOpacityEnabled(cascadeOpacityEnabled: boolean): void; + /** + !#en Opacity modify RGB have been removed since v2.0 + Set whether color should be changed with the opacity value, + useless in ccsg.Node, but this function is override in some class to have such behavior. + !#zh 透明度影响颜色配置已经被废弃 + 设置更改透明度时是否修改RGB值, + @param opacityValue opacityValue + */ + setOpacityModifyRGB(opacityValue: boolean): void; + /** + !#en Opacity modify RGB have been removed since v2.0 + Get whether color should be changed with the opacity value. + !#zh 透明度影响颜色配置已经被废弃 + 获取更改透明度时是否修改RGB值。 + */ + isOpacityModifyRGB(): boolean; + } + /** !#en + Scheduler is responsible of triggering the scheduled callbacks.
+ You should not use NSTimer. Instead use this class.
+
+ There are 2 different types of callbacks (selectors):
+ - update callback: the 'update' callback will be called every frame. You can customize the priority.
+ - custom callback: A custom callback will be called every frame, or with a custom interval of time
+
+ The 'custom selectors' should be avoided when possible. It is faster, + and consumes less memory to use the 'update callback'. * + !#zh + Scheduler 是负责触发回调函数的类。
+ 通常情况下,建议使用 cc.director.getScheduler() 来获取系统定时器。
+ 有两种不同类型的定时器:
+ - update 定时器:每一帧都会触发。您可以自定义优先级。
+ - 自定义定时器:自定义定时器可以每一帧或者自定义的时间间隔触发。
+ 如果希望每帧都触发,应该使用 update 定时器,使用 update 定时器更快,而且消耗更少的内存。 */ + export class Scheduler { + /** + !#en This method should be called for any target which needs to schedule tasks, and this method should be called before any scheduler API usage. + This method will add a `_id` property if it doesn't exist. + !#zh 任何需要用 Scheduler 管理任务的对象主体都应该调用这个方法,并且应该在调用任何 Scheduler API 之前调用这个方法。 + 这个方法会给对象添加一个 `_id` 属性,如果这个属性不存在的话。 + @param target target + */ + enableForTarget(target: any): void; + /** + !#en + Modifies the time of all scheduled callbacks.
+ You can use this property to create a 'slow motion' or 'fast forward' effect.
+ Default is 1.0. To create a 'slow motion' effect, use values below 1.0.
+ To create a 'fast forward' effect, use values higher than 1.0.
+ Note:It will affect EVERY scheduled selector / action. + !#zh + 设置时间间隔的缩放比例。
+ 您可以使用这个方法来创建一个 “slow motion(慢动作)” 或 “fast forward(快进)” 的效果。
+ 默认是 1.0。要创建一个 “slow motion(慢动作)” 效果,使用值低于 1.0。
+ 要使用 “fast forward(快进)” 效果,使用值大于 1.0。
+ 注意:它影响该 Scheduler 下管理的所有定时器。 + @param timeScale timeScale + */ + setTimeScale(timeScale: number): void; + /** + !#en Returns time scale of scheduler. + !#zh 获取时间间隔的缩放比例。 + */ + getTimeScale(): number; + /** + !#en 'update' the scheduler. (You should NEVER call this method, unless you know what you are doing.) + !#zh update 调度函数。(不应该直接调用这个方法,除非完全了解这么做的结果) + @param dt delta time + */ + update(dt: number): void; + /** + !#en +

+ The scheduled method will be called every 'interval' seconds.
+ If paused is YES, then it won't be called until it is resumed.
+ If 'interval' is 0, it will be called every frame, but if so, it recommended to use 'scheduleUpdateForTarget:' instead.
+ If the callback function is already scheduled, then only the interval parameter will be updated without re-scheduling it again.
+ repeat let the action be repeated repeat + 1 times, use cc.macro.REPEAT_FOREVER to let the action run continuously
+ delay is the amount of time the action will wait before it'll start
+

+ !#zh + 指定回调函数,调用对象等信息来添加一个新的定时器。
+ 如果 paused 值为 true,那么直到 resume 被调用才开始计时。
+ 当时间间隔达到指定值时,设置的回调函数将会被调用。
+ 如果 interval 值为 0,那么回调函数每一帧都会被调用,但如果是这样, + 建议使用 scheduleUpdateForTarget 代替。
+ 如果回调函数已经被定时器使用,那么只会更新之前定时器的时间间隔参数,不会设置新的定时器。
+ repeat 值可以让定时器触发 repeat + 1 次,使用 cc.macro.REPEAT_FOREVER + 可以让定时器一直循环触发。
+ delay 值指定延迟时间,定时器会在延迟指定的时间之后开始计时。 + @param callback callback + @param target target + @param interval interval + @param repeat repeat + @param delay delay + @param paused paused + + @example + ```js + //register a schedule to scheduler + cc.director.getScheduler().schedule(callback, this, interval, !this._isRunning); + + ``` + */ + schedule(callback: Function, target: any, interval: number, repeat: number, delay: number, paused?: boolean): void; + schedule(callback: Function, target: any, interval: number, paused?: boolean): void; + /** + !#en + Schedules the update callback for a given target, + During every frame after schedule started, the "update" function of target will be invoked. + !#zh + 使用指定的优先级为指定的对象设置 update 定时器。 + update 定时器每一帧都会被触发,触发时自动调用指定对象的 "update" 函数。 + 优先级的值越低,定时器被触发的越早。 + @param target target + @param priority priority + @param paused paused + */ + scheduleUpdate(target: any, priority: number, paused: boolean): void; + /** + !#en + Unschedules a callback for a callback and a given target. + If you want to unschedule the "update", use `unscheduleUpdate()` + !#zh + 取消指定对象定时器。 + 如果需要取消 update 定时器,请使用 unscheduleUpdate()。 + @param callback The callback to be unscheduled + @param target The target bound to the callback. + */ + unschedule(callback: Function, target: any): void; + /** + !#en Unschedules the update callback for a given target. + !#zh 取消指定对象的 update 定时器。 + @param target The target to be unscheduled. + */ + unscheduleUpdate(target: any): void; + /** + !#en + Unschedules all scheduled callbacks for a given target. + This also includes the "update" callback. + !#zh 取消指定对象的所有定时器,包括 update 定时器。 + @param target The target to be unscheduled. + */ + unscheduleAllForTarget(target: any): void; + /** + !#en + Unschedules all scheduled callbacks from all targets including the system callbacks.
+ You should NEVER call this method, unless you know what you are doing. + !#zh + 取消所有对象的所有定时器,包括系统定时器。
+ 不用调用此函数,除非你确定你在做什么。 + */ + unscheduleAll(): void; + /** + !#en + Unschedules all callbacks from all targets with a minimum priority.
+ You should only call this with `PRIORITY_NON_SYSTEM_MIN` or higher. + !#zh + 取消所有优先级的值大于指定优先级的定时器。
+ 你应该只取消优先级的值大于 PRIORITY_NON_SYSTEM_MIN 的定时器。 + @param minPriority The minimum priority of selector to be unscheduled. Which means, all selectors which + priority is higher than minPriority will be unscheduled. + */ + unscheduleAllWithMinPriority(minPriority: number): void; + /** + !#en Checks whether a callback for a given target is scheduled. + !#zh 检查指定的回调函数和回调对象组合是否存在定时器。 + @param callback The callback to check. + @param target The target of the callback. + */ + isScheduled(callback: Function, target: any): boolean; + /** + !#en + Pause all selectors from all targets.
+ You should NEVER call this method, unless you know what you are doing. + !#zh + 暂停所有对象的所有定时器。
+ 不要调用这个方法,除非你知道你正在做什么。 + */ + pauseAllTargets(): void; + /** + !#en + Pause all selectors from all targets with a minimum priority.
+ You should only call this with kCCPriorityNonSystemMin or higher. + !#zh + 暂停所有优先级的值大于指定优先级的定时器。
+ 你应该只暂停优先级的值大于 PRIORITY_NON_SYSTEM_MIN 的定时器。 + @param minPriority minPriority + */ + pauseAllTargetsWithMinPriority(minPriority: number): void; + /** + !#en + Resume selectors on a set of targets.
+ This can be useful for undoing a call to pauseAllCallbacks. + !#zh + 恢复指定数组中所有对象的定时器。
+ 这个函数是 pauseAllCallbacks 的逆操作。 + @param targetsToResume targetsToResume + */ + resumeTargets(targetsToResume: any[]): void; + /** + !#en + Pauses the target.
+ All scheduled selectors/update for a given target won't be 'ticked' until the target is resumed.
+ If the target is not present, nothing happens. + !#zh + 暂停指定对象的定时器。
+ 指定对象的所有定时器都会被暂停。
+ 如果指定的对象没有定时器,什么也不会发生。 + @param target target + */ + pauseTarget(target: any): void; + /** + !#en + Resumes the target.
+ The 'target' will be unpaused, so all schedule selectors/update will be 'ticked' again.
+ If the target is not present, nothing happens. + !#zh + 恢复指定对象的所有定时器。
+ 指定对象的所有定时器将继续工作。
+ 如果指定的对象没有定时器,什么也不会发生。 + @param target target + */ + resumeTarget(target: any): void; + /** + !#en Returns whether or not the target is paused. + !#zh 返回指定对象的定时器是否暂停了。 + @param target target + */ + isTargetPaused(target: any): boolean; + /** !#en Priority level reserved for system services. + !#zh 系统服务的优先级。 */ + static PRIORITY_SYSTEM: number; + /** !#en Minimum priority level for user scheduling. + !#zh 用户调度最低优先级。 */ + static PRIORITY_NON_SYSTEM: number; + } + /** !#en + cc.NodePool is the cache pool designed for node type.
+ It can helps you to improve your game performance for objects which need frequent release and recreate operations
+ + It's recommended to create cc.NodePool instances by node type, the type corresponds to node type in game design, not the class, + for example, a prefab is a specific node type.
+ When you create a node pool, you can pass a Component which contains `unuse`, `reuse` functions to control the content of node.
+ + Some common use case is :
+ 1. Bullets in game (die very soon, massive creation and recreation, no side effect on other objects)
+ 2. Blocks in candy crash (massive creation and recreation)
+ etc... + !#zh + cc.NodePool 是用于管理节点对象的对象缓存池。
+ 它可以帮助您提高游戏性能,适用于优化对象的反复创建和销毁
+ 以前 cocos2d-x 中的 cc.pool 和新的节点事件注册系统不兼容,因此请使用 cc.NodePool 来代替。 + + 新的 NodePool 需要实例化之后才能使用,每种不同的节点对象池需要一个不同的对象池实例,这里的种类对应于游戏中的节点设计,一个 prefab 相当于一个种类的节点。
+ 在创建缓冲池时,可以传入一个包含 unuse, reuse 函数的组件类型用于节点的回收和复用逻辑。
+ + 一些常见的用例是:
+ 1.在游戏中的子弹(死亡很快,频繁创建,对其他对象无副作用)
+ 2.糖果粉碎传奇中的木块(频繁创建)。 + 等等.... */ + export class NodePool { + /** + !#en + Constructor for creating a pool for a specific node template (usually a prefab). You can pass a component (type or name) argument for handling event for reusing and recycling node. + !#zh + 使用构造函数来创建一个节点专用的对象池,您可以传递一个组件类型或名称,用于处理节点回收和复用时的事件逻辑。 + @param poolHandlerComp !#en The constructor or the class name of the component to control the unuse/reuse logic. !#zh 处理节点回收和复用事件逻辑的组件类型或名称。 + + @example + ```js + properties: { + template: cc.Prefab + }, + onLoad () { + // MyTemplateHandler is a component with 'unuse' and 'reuse' to handle events when node is reused or recycled. + this.myPool = new cc.NodePool('MyTemplateHandler'); + } + ``` + */ + constructor(poolHandlerComp?: {prototype: Component}|string); + /** !#en The pool handler component, it could be the class name or the constructor. + !#zh 缓冲池处理组件,用于节点的回收和复用逻辑,这个属性可以是组件类名或组件的构造函数。 */ + poolHandlerComp: Function|string; + /** + !#en The current available size in the pool + !#zh 获取当前缓冲池的可用对象数量 + */ + size(): number; + /** + !#en Destroy all cached nodes in the pool + !#zh 销毁对象池中缓存的所有节点 + */ + clear(): void; + /** + !#en Put a new Node into the pool. + It will automatically remove the node from its parent without cleanup. + It will also invoke unuse method of the poolHandlerComp if exist. + !#zh 向缓冲池中存入一个不再需要的节点对象。 + 这个函数会自动将目标节点从父节点上移除,但是不会进行 cleanup 操作。 + 这个函数会调用 poolHandlerComp 的 unuse 函数,如果组件和函数都存在的话。 + @param obj obj + + @example + ```js + let myNode = cc.instantiate(this.template); + this.myPool.put(myNode); + ``` + */ + put(obj: Node): void; + /** + !#en Get a obj from pool, if no available object in pool, null will be returned. + This function will invoke the reuse function of poolHandlerComp if exist. + !#zh 获取对象池中的对象,如果对象池没有可用对象,则返回空。 + 这个函数会调用 poolHandlerComp 的 reuse 函数,如果组件和函数都存在的话。 + @param params !#en Params to pass to 'reuse' method in poolHandlerComp !#zh 向 poolHandlerComp 中的 'reuse' 函数传递的参数 + + @example + ```js + let newNode = this.myPool.get(); + ``` + */ + get(...params: any[]): Node; + } + /** !#en The Light Component + + !#zh 光源组件 */ + export class Light extends Component { + } + /** !#en + Base class for handling assets used in Creator.
+ + You may want to override:
+ - createNode
+ - getset functions of _nativeAsset
+ - cc.Object._serialize
+ - cc.Object._deserialize
+ !#zh + Creator 中的资源基类。
+ + 您可能需要重写:
+ - createNode
+ - _nativeAsset 的 getset 方法
+ - cc.Object._serialize
+ - cc.Object._deserialize
*/ + export class Asset extends RawAsset { + /** !#en + Whether the asset is loaded or not + !#zh + 该资源是否已经成功加载 */ + loaded: boolean; + /** !#en + Points to the true url of this asset's native object, only valid when asset is loaded and asyncLoadAsset is not enabled. + The difference between nativeUrl and url is that the latter is final path, there is no needs to transform url by md5 and subpackage. + Besides, url may points to temporary path or cached path on mini game platform which has cache mechanism (WeChat etc). + If you want to make use of the native file on those platforms, you should use url instead of nativeUrl. + + !#zh + 资源的原生文件的真实url,只在资源被加载后以及没有启用延迟加载时才有效。 nativeUrl 与 url 的区别在于,url 是资源最终路径,所以 url 不需要再经过 md5 以及子包的路径转换, + 另外某些带缓存机制的小游戏平台(微信等)上url可能会指向临时文件路径或者缓存路径,如果你需要在这些平台上使用资源的原生文件,请使用url,避免使用nativeUrl */ + url: string; + /** !#en + Returns the url of this asset's native object, if none it will returns an empty string. + !#zh + 返回该资源对应的目标平台资源的 URL,如果没有将返回一个空字符串。 */ + nativeUrl: string; + /** !#en Indicates whether its dependent raw assets can support deferred load if the owner scene (or prefab) is marked as `asyncLoadAssets`. + !#zh 当场景或 Prefab 被标记为 `asyncLoadAssets`,禁止延迟加载该资源所依赖的其它 RawAsset。 */ + static preventDeferredLoadDependents: boolean; + /** !#en Indicates whether its native object should be preloaded from native url. + !#zh 禁止预加载原生对象。 */ + static preventPreloadNativeObject: boolean; + /** + Returns the asset's url. + + The `Asset` object overrides the `toString()` method of the `Object` object. + For `Asset` objects, the toString() method returns a string representation of the object. + JavaScript calls the toString() method automatically when an asset is to be represented as a text value or when a texture is referred to in a string concatenation. + */ + toString(): string; + /** + !#en + Create a new node using this asset in the scene.
+ If this type of asset dont have its corresponding node type, this method should be null. + !#zh + 使用该资源在场景中创建一个新节点。
+ 如果这类资源没有相应的节点类型,该方法应该是空的。 + @param callback callback + */ + createNode(callback: (error: string, node: any) => void): void; + } + /** !#en Class for audio data handling. + !#zh 音频资源类。 */ + export class AudioClip extends Asset implements EventTarget { + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en + Register an callback of a specific event type on the EventTarget. + This type of event should be triggered via `emit`. + !#zh + 注册事件目标的特定事件类型回调。这种类型的事件应该被 `emit` 触发。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, node); + ``` + */ + on(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. + !#zh + 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + + @example + ```js + // register fire eventListener + var callback = eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, target); + // remove fire event listener + eventTarget.off('fire', callback, target); + // remove all fire event listeners + eventTarget.off('fire'); + ``` + */ + off(type: string, callback?: Function, target?: any): void; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.once('fire', function () { + cc.log("this is the callback and will be invoked only once"); + }, node); + ``` + */ + once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; + /** + !#en + Send an event with the event object. + !#zh + 通过事件对象派发事件 + @param event event + */ + dispatchEvent(event: Event): void; + } + /** !#en Class for BitmapFont handling. + !#zh 位图字体资源类。 */ + export class BitmapFont extends Font { + } + /** undefined */ + export class BufferAsset extends Asset { + } + /** !#en + Class for JSON file. When the JSON file is loaded, this object is returned. + The parsed JSON object can be accessed through the `json` attribute in it.
+ If you want to get the original JSON text, you should modify the extname to `.txt` + so that it is loaded as a `TextAsset` instead of a `JsonAsset`. + + !#zh + JSON 资源类。JSON 文件加载后,将会返回该对象。可以通过其中的 `json` 属性访问解析后的 JSON 对象。
+ 如果你想要获得 JSON 的原始文本,那么应该修改源文件的后缀为 `.txt`,这样就会加载为一个 `TextAsset` 而不是 `JsonAsset`。 */ + export class JsonAsset extends Asset { + /** The loaded JSON object. */ + json: any; + } + /** !#en Class for Font handling. + !#zh 字体资源类。 */ + export class Font extends Asset { + } + /** !#en Class for LabelAtlas handling. + !#zh 艺术数字字体资源类。 */ + export class LabelAtlas extends BitmapFont { + } + /** !#en Class for prefab handling. + !#zh 预制资源类。 */ + export class Prefab extends Asset { + /** the main cc.Node in the prefab */ + data: Node; + /** !#zh + 设置实例化这个 prefab 时所用的优化策略。根据使用情况设置为合适的值,能优化该 prefab 实例化所用的时间。 + !#en + Indicates the optimization policy for instantiating this prefab. + Set to a suitable value based on usage, can optimize the time it takes to instantiate this prefab. */ + optimizationPolicy: Prefab.OptimizationPolicy; + /** !#en Indicates the raw assets of this prefab can be load after prefab loaded. + !#zh 指示该 Prefab 依赖的资源可否在 Prefab 加载后再延迟加载。 */ + asyncLoadAssets: boolean; + readonly: boolean; + /** + Dynamically translation prefab data into minimized code.
+ This method will be called automatically before the first time the prefab being instantiated, + but you can re-call to refresh the create function once you modified the original prefab data in script. + */ + compileCreateFunction(): void; + } + /** !#en + The base class for registering asset types. + !#zh + 注册用的资源基类。 */ + export class RawAsset extends Object { + } + /** Render textures are textures that can be rendered to. */ + export class RenderTexture extends Texture2D { + /** + !#en + Init the render texture with size. + !#zh + 初始化 render texture + @param width width + @param height height + @param depthStencilFormat depthStencilFormat + */ + initWithSize(width?: number, height?: number, depthStencilFormat?: number): void; + /** + !#en + Get pixels from render texture, the pixels data stores in a RGBA Uint8Array. + It will return a new (width * height * 4) length Uint8Array by default。 + You can specify a data to store the pixels to reuse the data, + you and can specify other params to specify the texture region to read. + !#zh + 从 render texture 读取像素数据,数据类型为 RGBA 格式的 Uint8Array 数组。 + 默认每次调用此函数会生成一个大小为 (长 x 高 x 4) 的 Uint8Array。 + 你可以通过传入 data 来接收像素数据,也可以通过传参来指定需要读取的区域的像素。 + @param data data + @param x x + @param y y + @param w w + @param h h + */ + readPixels(data?: Uint8Array, x?: number, y?: number, w?: number, h?: number): Uint8Array; + } + /** !#en Class for scene handling. + !#zh 场景资源类。 */ + export class SceneAsset extends Asset { + scene: Scene; + /** !#en Indicates the raw assets of this scene can be load after scene launched. + !#zh 指示该场景依赖的资源可否在场景切换后再延迟加载。 */ + asyncLoadAssets: boolean; + } + /** !#en Class for script handling. + !#zh Script 资源类。 */ + export class _Script extends Asset { + } + /** !#en Class for JavaScript handling. + !#zh JavaScript 资源类。 */ + export class _JavaScript extends Asset { + } + /** !#en Class for coffeescript handling. + !#zh CoffeeScript 资源类。 */ + export class CoffeeScript extends Asset { + } + /** !#en Class for TypeScript handling. + !#zh TypeScript 资源类。 */ + export class TypeScript extends Asset { + } + /** !#en Class for sprite atlas handling. + !#zh 精灵图集资源类。 */ + export class SpriteAtlas extends Asset { + /** + Returns the texture of the sprite atlas + */ + getTexture(): Texture2D; + /** + Returns the sprite frame correspond to the given key in sprite atlas. + @param key key + */ + getSpriteFrame(key: string): SpriteFrame; + /** + Returns the sprite frames in sprite atlas. + */ + getSpriteFrames(): SpriteFrame[]; + } + /** !#en + A cc.SpriteFrame has:
+ - texture: A cc.Texture2D that will be used by render components
+ - rectangle: A rectangle of the texture + + !#zh + 一个 SpriteFrame 包含:
+ - 纹理:会被渲染组件使用的 Texture2D 对象。
+ - 矩形:在纹理中的矩形区域。 */ + export class SpriteFrame extends Asset implements EventTarget { + /** !#en Top border of the sprite + !#zh sprite 的顶部边框 */ + insetTop: number; + /** !#en Bottom border of the sprite + !#zh sprite 的底部边框 */ + insetBottom: number; + /** !#en Left border of the sprite + !#zh sprite 的左边边框 */ + insetLeft: number; + /** !#en Right border of the sprite + !#zh sprite 的左边边框 */ + insetRight: number; + /** + !#en + Constructor of SpriteFrame class. + !#zh + SpriteFrame 类的构造函数。 + @param filename filename + @param rect rect + @param rotated Whether the frame is rotated in the texture + @param offset The offset of the frame in the texture + @param originalSize The size of the frame in the texture + */ + constructor(filename?: string|Texture2D, rect?: Rect, rotated?: boolean, offset?: Vec2, originalSize?: Size); + /** + !#en Returns whether the texture have been loaded + !#zh 返回是否已加载纹理 + */ + textureLoaded(): boolean; + /** + !#en Returns whether the sprite frame is rotated in the texture. + !#zh 获取 SpriteFrame 是否旋转 + */ + isRotated(): boolean; + /** + !#en Set whether the sprite frame is rotated in the texture. + !#zh 设置 SpriteFrame 是否旋转 + @param bRotated bRotated + */ + setRotated(bRotated: boolean): void; + /** + !#en Returns whether the sprite frame is flip x axis in the texture. + !#zh 获取 SpriteFrame 是否反转 x 轴 + */ + isFlipX(): boolean; + /** + !#en Returns whether the sprite frame is flip y axis in the texture. + !#zh 获取 SpriteFrame 是否反转 y 轴 + */ + isFlipY(): boolean; + /** + !#en Set whether the sprite frame is flip x axis in the texture. + !#zh 设置 SpriteFrame 是否翻转 x 轴 + @param flipX flipX + */ + setFlipX(flipX: boolean): void; + /** + !#en Set whether the sprite frame is flip y axis in the texture. + !#zh 设置 SpriteFrame 是否翻转 y 轴 + @param flipY flipY + */ + setFlipY(flipY: boolean): void; + /** + !#en Returns the rect of the sprite frame in the texture. + !#zh 获取 SpriteFrame 的纹理矩形区域 + */ + getRect(): Rect; + /** + !#en Sets the rect of the sprite frame in the texture. + !#zh 设置 SpriteFrame 的纹理矩形区域 + @param rect rect + */ + setRect(rect: Rect): void; + /** + !#en Returns the original size of the trimmed image. + !#zh 获取修剪前的原始大小 + */ + getOriginalSize(): Size; + /** + !#en Sets the original size of the trimmed image. + !#zh 设置修剪前的原始大小 + @param size size + */ + setOriginalSize(size: Size): void; + /** + !#en Returns the texture of the frame. + !#zh 获取使用的纹理实例 + */ + getTexture(): Texture2D; + /** + !#en Returns the offset of the frame in the texture. + !#zh 获取偏移量 + */ + getOffset(): Vec2; + /** + !#en Sets the offset of the frame in the texture. + !#zh 设置偏移量 + @param offsets offsets + */ + setOffset(offsets: Vec2): void; + /** + !#en Clone the sprite frame. + !#zh 克隆 SpriteFrame + */ + clone(): SpriteFrame; + /** + !#en Set SpriteFrame with Texture, rect, rotated, offset and originalSize.
+ !#zh 通过 Texture,rect,rotated,offset 和 originalSize 设置 SpriteFrame。 + @param textureOrTextureFile textureOrTextureFile + @param rect rect + @param rotated rotated + @param offset offset + @param originalSize originalSize + */ + setTexture(textureOrTextureFile: string|Texture2D, rect?: Rect, rotated?: boolean, offset?: Vec2, originalSize?: Size): boolean; + /** + !#en If a loading scene (or prefab) is marked as `asyncLoadAssets`, all the textures of the SpriteFrame which + associated by user's custom Components in the scene, will not preload automatically. + These textures will be load when Sprite component is going to render the SpriteFrames. + You can call this method if you want to load the texture early. + !#zh 当加载中的场景或 Prefab 被标记为 `asyncLoadAssets` 时,用户在场景中由自定义组件关联到的所有 SpriteFrame 的贴图都不会被提前加载。 + 只有当 Sprite 组件要渲染这些 SpriteFrame 时,才会检查贴图是否加载。如果你希望加载过程提前,你可以手工调用这个方法。 + + @example + ```js + if (spriteFrame.textureLoaded()) { + this._onSpriteFrameLoaded(); + } + else { + spriteFrame.once('load', this._onSpriteFrameLoaded, this); + spriteFrame.ensureLoadTexture(); + } + ``` + */ + ensureLoadTexture(): void; + /** + !#en + If you do not need to use the SpriteFrame temporarily, you can call this method so that its texture could be garbage collected. Then when you need to render the SpriteFrame, you should call `ensureLoadTexture` manually to reload texture. + !#zh + 当你暂时不再使用这个 SpriteFrame 时,可以调用这个方法来保证引用的贴图对象能被 GC。然后当你要渲染 SpriteFrame 时,你需要手动调用 `ensureLoadTexture` 来重新加载贴图。 + */ + clearTexture(): void; + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en + Register an callback of a specific event type on the EventTarget. + This type of event should be triggered via `emit`. + !#zh + 注册事件目标的特定事件类型回调。这种类型的事件应该被 `emit` 触发。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, node); + ``` + */ + on(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. + !#zh + 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + + @example + ```js + // register fire eventListener + var callback = eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, target); + // remove fire event listener + eventTarget.off('fire', callback, target); + // remove all fire event listeners + eventTarget.off('fire'); + ``` + */ + off(type: string, callback?: Function, target?: any): void; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.once('fire', function () { + cc.log("this is the callback and will be invoked only once"); + }, node); + ``` + */ + once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; + /** + !#en + Send an event with the event object. + !#zh + 通过事件对象派发事件 + @param event event + */ + dispatchEvent(event: Event): void; + } + /** !#en Class for text file. + !#zh 文本资源类。 */ + export class TextAsset extends Asset { + /** The text contents of the resource. */ + text: string; + } + /** !#en Class for TTFFont handling. + !#zh TTF 字体资源类。 */ + export class TTFFont extends Font { + } + /** This class allows to easily create OpenGL or Canvas 2D textures from images or raw data. */ + export class Texture2D extends Asset implements EventTarget { + /** !#en Sets whether generate mipmaps for the texture + !#zh 是否为纹理设置生成 mipmaps。 */ + genMipmaps: boolean; + /** !#en + Sets whether texture can be packed into texture atlas. + If need use texture uv in custom Effect, please sets packable to false. + !#zh + 设置纹理是否允许参与合图。 + 如果需要在自定义 Effect 中使用纹理 UV,需要禁止该选项。 */ + packable: boolean; + /** !#en + Whether the texture is loaded or not + !#zh + 贴图是否已经成功加载 */ + loaded: boolean; + /** !#en + Texture width in pixel + !#zh + 贴图像素宽度 */ + width: number; + /** !#en + Texture height in pixel + !#zh + 贴图像素高度 */ + height: number; + /** + !#en + Get renderer texture implementation object + extended from render.Texture2D + !#zh 返回渲染器内部贴图对象 + */ + getImpl(): void; + /** + Update texture options, not available in Canvas render mode. + image, format, premultiplyAlpha can not be updated in native. + @param options options + */ + update(options: {image: DOMImageElement; genMipmaps: boolean; format: Texture2D.PixelFormat; minFilter: Texture2D.Filter; magFilter: Texture2D.Filter; wrapS: WrapMode; wrapT: WrapMode; premultiplyAlpha: boolean; }): void; + /** + !#en + Init with HTML element. + !#zh 用 HTML Image 或 Canvas 对象初始化贴图。 + @param element element + + @example + ```js + var img = new Image(); + img.src = dataURL; + texture.initWithElement(img); + ``` + */ + initWithElement(element: HTMLImageElement|HTMLCanvasElement): void; + /** + !#en + Intializes with a texture2d with data in Uint8Array. + !#zh 使用一个存储在 Unit8Array 中的图像数据(raw data)初始化数据。 + @param data data + @param pixelFormat pixelFormat + @param pixelsWidth pixelsWidth + @param pixelsHeight pixelsHeight + */ + initWithData(data: DataView, pixelFormat: number, pixelsWidth: number, pixelsHeight: number): boolean; + /** + !#en + HTMLElement Object getter, available only on web.
+ Note: texture is packed into texture atlas by default
+ you should set texture.packable as false before getting Html element object. + !#zh 获取当前贴图对应的 HTML Image 或 Canvas 对象,只在 Web 平台下有效。
+ 注意:
+ texture 默认参与动态合图,如果需要获取到正确的 Html 元素对象,需要先设置 texture.packable 为 false + */ + getHtmlElementObj(): HTMLImageElement; + /** + !#en + Destory this texture and immediately release its video memory. (Inherit from cc.Object.destroy)
+ After destroy, this object is not usable any more. + You can use cc.isValid(obj) to check whether the object is destroyed before accessing it. + !#zh + 销毁该贴图,并立即释放它对应的显存。(继承自 cc.Object.destroy)
+ 销毁后,该对象不再可用。您可以在访问对象之前使用 cc.isValid(obj) 来检查对象是否已被销毁。 + */ + destroy(): boolean; + /** + !#en + Pixel format of the texture. + !#zh 获取纹理的像素格式。 + */ + getPixelFormat(): number; + /** + !#en + Whether or not the texture has their Alpha premultiplied. + !#zh 检查纹理在上传 GPU 时预乘选项是否开启。 + */ + hasPremultipliedAlpha(): boolean; + /** + !#en + Handler of texture loaded event. + Since v2.0, you don't need to invoke this function, it will be invoked automatically after texture loaded. + !#zh 贴图加载事件处理器。v2.0 之后你将不在需要手动执行这个函数,它会在贴图加载成功之后自动执行。 + @param premultiplied premultiplied + */ + handleLoadedTexture(premultiplied?: boolean): void; + /** + !#en + Description of cc.Texture2D. + !#zh cc.Texture2D 描述。 + */ + description(): string; + /** + !#en + Release texture, please use destroy instead. + !#zh 释放纹理,请使用 destroy 替代。 + */ + releaseTexture(): void; + /** + !#en Sets the wrap s and wrap t options.
+ If the texture size is NPOT (non power of 2), then in can only use gl.CLAMP_TO_EDGE in gl.TEXTURE_WRAP_{S,T}. + !#zh 设置纹理包装模式。 + 若纹理贴图尺寸是 NPOT(non power of 2),则只能使用 Texture2D.WrapMode.CLAMP_TO_EDGE。 + @param wrapS wrapS + @param wrapT wrapT + */ + setTexParameters(wrapS: Texture2D.WrapMode, wrapT: Texture2D.WrapMode): void; + /** + !#en Sets the minFilter and magFilter options + !#zh 设置纹理贴图缩小和放大过滤器算法选项。 + @param minFilter minFilter + @param magFilter magFilter + */ + setFilters(minFilter: Texture2D.Filter, magFilter: Texture2D.Filter): void; + /** + !#en + Sets the flipY options + !#zh 设置贴图的纵向翻转选项。 + @param flipY flipY + */ + setFlipY(flipY: boolean): void; + /** + !#en + Sets the premultiply alpha options + !#zh 设置贴图的预乘选项。 + @param premultiply premultiply + */ + setPremultiplyAlpha(premultiply: boolean): void; + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en + Register an callback of a specific event type on the EventTarget. + This type of event should be triggered via `emit`. + !#zh + 注册事件目标的特定事件类型回调。这种类型的事件应该被 `emit` 触发。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, node); + ``` + */ + on(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. + !#zh + 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + + @example + ```js + // register fire eventListener + var callback = eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, target); + // remove fire event listener + eventTarget.off('fire', callback, target); + // remove all fire event listeners + eventTarget.off('fire'); + ``` + */ + off(type: string, callback?: Function, target?: any): void; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.once('fire', function () { + cc.log("this is the callback and will be invoked only once"); + }, node); + ``` + */ + once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; + /** + !#en + Send an event with the event object. + !#zh + 通过事件对象派发事件 + @param event event + */ + dispatchEvent(event: Event): void; + } + /** !#en Box Collider. + !#zh 包围盒碰撞组件 */ + export class BoxCollider extends Collider implements Collider.Box { + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Box size + !#zh 包围盒大小 */ + size: Size; + } + /** !#en Circle Collider. + !#zh 圆形碰撞组件 */ + export class CircleCollider extends Collider implements Collider.Circle { + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Circle radius + !#zh 圆形半径 */ + radius: number; + } + /** !#en Collider component base class. + !#zh 碰撞组件基类 */ + export class Collider extends Component { + /** !#en Tag. If a node has several collider components, you can judge which type of collider is collided according to the tag. + !#zh 标签。当一个节点上有多个碰撞组件时,在发生碰撞后,可以使用此标签来判断是节点上的哪个碰撞组件被碰撞了。 */ + tag: number; + } + /** !#en + A simple collision manager class. + It will calculate whether the collider collides other colliders, if collides then call the callbacks. + !#zh + 一个简单的碰撞组件管理类,用于处理节点之间的碰撞组件是否产生了碰撞,并调用相应回调函数。 */ + export class CollisionManager implements EventTarget { + /** !#en + !#zh + 是否开启碰撞管理,默认为不开启 */ + enabled: boolean; + /** !#en + !#zh + 是否绘制碰撞组件的包围盒,默认为不绘制 */ + enabledDrawBoundingBox: boolean; + /** !#en + !#zh + 是否绘制碰撞组件的形状,默认为不绘制 */ + enabledDebugDraw: boolean; + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en + Register an callback of a specific event type on the EventTarget. + This type of event should be triggered via `emit`. + !#zh + 注册事件目标的特定事件类型回调。这种类型的事件应该被 `emit` 触发。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, node); + ``` + */ + on(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. + !#zh + 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + + @example + ```js + // register fire eventListener + var callback = eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, target); + // remove fire event listener + eventTarget.off('fire', callback, target); + // remove all fire event listeners + eventTarget.off('fire'); + ``` + */ + off(type: string, callback?: Function, target?: any): void; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.once('fire', function () { + cc.log("this is the callback and will be invoked only once"); + }, node); + ``` + */ + once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; + /** + !#en + Send an event with the event object. + !#zh + 通过事件对象派发事件 + @param event event + */ + dispatchEvent(event: Event): void; + } + /** !#en Intersection helper class + !#zh 辅助类,用于测试形状与形状是否相交 */ + export class Intersection { + /** + !#en Test line and line + !#zh 测试线段与线段是否相交 + @param a1 The start point of the first line + @param a2 The end point of the first line + @param b1 The start point of the second line + @param b2 The end point of the second line + */ + static lineLine(a1: Vec2, a2: Vec2, b1: Vec2, b2: Vec2): boolean; + /** + !#en Test line and rect + !#zh 测试线段与矩形是否相交 + @param a1 The start point of the line + @param a2 The end point of the line + @param b The rect + */ + static lineRect(a1: Vec2, a2: Vec2, b: Rect): boolean; + /** + !#en Test line and polygon + !#zh 测试线段与多边形是否相交 + @param a1 The start point of the line + @param a2 The end point of the line + @param b The polygon, a set of points + */ + static linePolygon(a1: Vec2, a2: Vec2, b: Vec2[]): boolean; + /** + !#en Test rect and rect + !#zh 测试矩形与矩形是否相交 + @param a The first rect + @param b The second rect + */ + static rectRect(a: Rect, b: Rect): boolean; + /** + !#en Test rect and polygon + !#zh 测试矩形与多边形是否相交 + @param a The rect + @param b The polygon, a set of points + */ + static rectPolygon(a: Rect, b: Vec2[]): boolean; + /** + !#en Test polygon and polygon + !#zh 测试多边形与多边形是否相交 + @param a The first polygon, a set of points + @param b The second polygon, a set of points + */ + static polygonPolygon(a: Vec2[], b: Vec2[]): boolean; + /** + !#en Test circle and circle + !#zh 测试圆形与圆形是否相交 + @param a Object contains position and radius + @param b Object contains position and radius + */ + static circleCircle(a: {position: Vec2, radius: number}, b: {position: Vec2, radius: number}): boolean; + /** + !#en Test polygon and circle + !#zh 测试矩形与圆形是否相交 + @param polygon The Polygon, a set of points + @param circle Object contains position and radius + */ + static polygonCircle(polygon: Vec2[], circle: {position: Vec2, radius: number}): boolean; + /** + !#en Test whether the point is in the polygon + !#zh 测试一个点是否在一个多边形中 + @param point The point + @param polygon The polygon, a set of points + */ + static pointInPolygon(point: Vec2, polygon: Vec2[]): boolean; + /** + !#en Calculate the distance of point to line. + !#zh 计算点到直线的距离。如果这是一条线段并且垂足不在线段内,则会计算点到线段端点的距离。 + @param point The point + @param start The start point of line + @param end The end point of line + @param isSegment whether this line is a segment + */ + static pointLineDistance(point: Vec2, start: Vec2, end: Vec2, isSegment: boolean): number; + } + /** !#en Polygon Collider. + !#zh 多边形碰撞组件 */ + export class PolygonCollider extends Collider implements Collider.Polygon { + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Polygon points + !#zh 多边形顶点数组 */ + points: Vec2[]; + } + /** !#en + Camera is usefull when making reel game or other games which need scroll screen. + Using camera will be more efficient than moving node to scroll screen. + Camera + !#zh + 摄像机在制作卷轴或是其他需要移动屏幕的游戏时比较有用,使用摄像机将会比移动节点来移动屏幕更加高效。 */ + export class Camera extends Component { + /** !#en + The camera zoom ratio, only support 2D camera. + !#zh + 摄像机缩放比率, 只支持 2D camera。 */ + zoomRatio: number; + /** !#en + Field of view. The width of the Camera’s view angle, measured in degrees along the local Y axis. + !#zh + 决定摄像机视角的宽度,当摄像机处于透视投影模式下这个属性才会生效。 */ + fov: number; + /** !#en + The viewport size of the Camera when set to orthographic projection. + !#zh + 摄像机在正交投影模式下的视窗大小。 */ + orthoSize: number; + /** !#en + The near clipping plane. + !#zh + 摄像机的近剪裁面。 */ + nearClip: number; + /** !#en + The far clipping plane. + !#zh + 摄像机的远剪裁面。 */ + farClip: number; + /** !#en + Is the camera orthographic (true) or perspective (false)? + !#zh + 设置摄像机的投影模式是正交还是透视模式。 */ + ortho: boolean; + /** !#en + Four values (0 ~ 1) that indicate where on the screen this camera view will be drawn. + !#zh + 决定摄像机绘制在屏幕上哪个位置,值为(0 ~ 1)。 */ + rect: Rect; + /** !#en + This is used to render parts of the scene selectively. + !#zh + 决定摄像机会渲染场景的哪一部分。 */ + cullingMask: number; + /** !#en + Determining what to clear when camera rendering. + !#zh + 决定摄像机渲染时会清除哪些状态。 */ + clearFlags: Camera.ClearFlags; + /** !#en + The color with which the screen will be cleared. + !#zh + 摄像机用于清除屏幕的背景色。 */ + backgroundColor: Color; + /** !#en + Camera's depth in the camera rendering order. + !#zh + 摄像机深度,用于决定摄像机的渲染顺序。 */ + depth: number; + /** !#en + Destination render texture. + Usually cameras render directly to screen, but for some effects it is useful to make a camera render into a texture. + !#zh + 摄像机渲染的目标 RenderTexture。 + 一般摄像机会直接渲染到屏幕上,但是有一些效果可以使用摄像机渲染到 RenderTexture 上再对 RenderTexture 进行处理来实现。 */ + targetTexture: RenderTexture; + /** !#en + Sets the camera's render stages. + !#zh + 设置摄像机渲染的阶段 */ + renderStages: number; + /** !#en Whether auto align camera viewport to screen + !#zh 是否自动将摄像机的视口对准屏幕 */ + alignWithScreen: boolean; + /** !#en + The first enabled camera. + !#zh + 第一个被激活的摄像机。 */ + static main: Camera; + /** !#en + All enabled cameras. + !#zh + 激活的所有摄像机。 */ + static cameras: Camera[]; + /** + !#en + Get the first camera which the node belong to. + !#zh + 获取节点所在的第一个摄像机。 + @param node node + */ + static findCamera(node: Node): Camera; + /** + !#en + Get the screen to world matrix, only support 2D camera which alignWithScreen is true. + !#zh + 获取屏幕坐标系到世界坐标系的矩阵,只适用于 alignWithScreen 为 true 的 2D 摄像机。 + @param out the matrix to receive the result + */ + getScreenToWorldMatrix2D(out: Mat4): Mat4; + /** + !#en + Get the world to camera matrix, only support 2D camera which alignWithScreen is true. + !#zh + 获取世界坐标系到摄像机坐标系的矩阵,只适用于 alignWithScreen 为 true 的 2D 摄像机。 + @param out the matrix to receive the result + */ + getWorldToScreenMatrix2D(out: Mat4): Mat4; + /** + !#en + Convert point from screen to world. + !#zh + 将坐标从屏幕坐标系转换到世界坐标系。 + @param screenPosition screenPosition + @param out out + */ + getScreenToWorldPoint(screenPosition: Vec3|Vec2, out?: Vec3|Vec2): Vec3; + /** + !#en + Convert point from world to screen. + !#zh + 将坐标从世界坐标系转化到屏幕坐标系。 + @param worldPosition worldPosition + @param out out + */ + getWorldToScreenPoint(worldPosition: Vec3|Vec2, out?: Vec3|Vec2): Vec3; + /** + !#en + Get a ray from screen position + !#zh + 从屏幕坐标获取一条射线 + @param screenPos screenPos + */ + getRay(screenPos: Vec2): geomUtils.Ray; + /** + !#en + Check whether the node is in the camera. + !#zh + 检测节点是否被此摄像机影响 + @param node the node which need to check + */ + containsNode(node: Node): boolean; + /** + !#en + Render the camera manually. + !#zh + 手动渲染摄像机。 + @param root root + */ + render(root: Node): void; + /** + !#en + Returns the matrix that transform the node's (local) space coordinates into the camera's space coordinates. + !#zh + 返回一个将节点坐标系转换到摄像机坐标系下的矩阵 + @param node the node which should transform + */ + getNodeToCameraTransform(node: Node): AffineTransform; + /** + !#en + Conver a camera coordinates point to world coordinates. + !#zh + 将一个摄像机坐标系下的点转换到世界坐标系下。 + @param point the point which should transform + @param out the point to receive the result + */ + getCameraToWorldPoint(point: Vec2, out?: Vec2): Vec2; + /** + !#en + Conver a world coordinates point to camera coordinates. + !#zh + 将一个世界坐标系下的点转换到摄像机坐标系下。 + @param point point + @param out the point to receive the result + */ + getWorldToCameraPoint(point: Vec2, out?: Vec2): Vec2; + /** + !#en + Get the camera to world matrix + !#zh + 获取摄像机坐标系到世界坐标系的矩阵 + @param out the matrix to receive the result + */ + getCameraToWorldMatrix(out: Mat4): Mat4; + /** + !#en + Get the world to camera matrix + !#zh + 获取世界坐标系到摄像机坐标系的矩阵 + @param out the matrix to receive the result + */ + getWorldToCameraMatrix(out: Mat4): Mat4; + } + /** !#en The animation component is used to play back animations. + + Animation provide several events to register: + - play : Emit when begin playing animation + - stop : Emit when stop playing animation + - pause : Emit when pause animation + - resume : Emit when resume animation + - lastframe : If animation repeat count is larger than 1, emit when animation play to the last frame + - finished : Emit when finish playing animation + + !#zh Animation 组件用于播放动画。 + + Animation 提供了一系列可注册的事件: + - play : 开始播放时 + - stop : 停止播放时 + - pause : 暂停播放时 + - resume : 恢复播放时 + - lastframe : 假如动画循环次数大于 1,当动画播放到最后一帧时 + - finished : 动画播放完成时 */ + export class Animation extends Component implements EventTarget { + /** !#en Animation will play the default clip when start game. + !#zh 在勾选自动播放或调用 play() 时默认播放的动画剪辑。 */ + defaultClip: AnimationClip; + /** !#en Current played clip. + !#zh 当前播放的动画剪辑。 */ + currentClip: AnimationClip; + /** !#en Whether the animation should auto play the default clip when start game. + !#zh 是否在运行游戏后自动播放默认动画剪辑。 */ + playOnLoad: boolean; + /** + !#en Get all the clips used in this animation. + !#zh 获取动画组件上的所有动画剪辑。 + */ + getClips(): AnimationClip[]; + /** + !#en Plays an animation and stop other animations. + !#zh 播放指定的动画,并且停止当前正在播放动画。如果没有指定动画,则播放默认动画。 + @param name The name of animation to play. If no name is supplied then the default animation will be played. + @param startTime play an animation from startTime + + @example + ```js + var animCtrl = this.node.getComponent(cc.Animation); + animCtrl.play("linear"); + ``` + */ + play(name?: string, startTime?: number): AnimationState; + /** + !#en + Plays an additive animation, it will not stop other animations. + If there are other animations playing, then will play several animations at the same time. + !#zh 播放指定的动画(将不会停止当前播放的动画)。如果没有指定动画,则播放默认动画。 + @param name The name of animation to play. If no name is supplied then the default animation will be played. + @param startTime play an animation from startTime + + @example + ```js + // linear_1 and linear_2 at the same time playing. + var animCtrl = this.node.getComponent(cc.Animation); + animCtrl.playAdditive("linear_1"); + animCtrl.playAdditive("linear_2"); + ``` + */ + playAdditive(name?: string, startTime?: number): AnimationState; + /** + !#en Stops an animation named name. If no name is supplied then stops all playing animations that were started with this Animation.
+ Stopping an animation also Rewinds it to the Start. + !#zh 停止指定的动画。如果没有指定名字,则停止当前正在播放的动画。 + @param name The animation to stop, if not supplied then stops all playing animations. + */ + stop(name?: string): void; + /** + !#en Pauses an animation named name. If no name is supplied then pauses all playing animations that were started with this Animation. + !#zh 暂停当前或者指定的动画。如果没有指定名字,则暂停当前正在播放的动画。 + @param name The animation to pauses, if not supplied then pauses all playing animations. + */ + pause(name?: string): void; + /** + !#en Resumes an animation named name. If no name is supplied then resumes all paused animations that were started with this Animation. + !#zh 重新播放指定的动画,如果没有指定名字,则重新播放当前正在播放的动画。 + @param name The animation to resumes, if not supplied then resumes all paused animations. + */ + resume(name?: string): void; + /** + !#en Make an animation named name go to the specified time. If no name is supplied then make all animations go to the specified time. + !#zh 设置指定动画的播放时间。如果没有指定名字,则设置当前播放动画的播放时间。 + @param time The time to go to + @param name Specified animation name, if not supplied then make all animations go to the time. + */ + setCurrentTime(time?: number, name?: string): void; + /** + !#en Returns the animation state named name. If no animation with the specified name, the function will return null. + !#zh 获取当前或者指定的动画状态,如果未找到指定动画剪辑则返回 null。 + @param name name + */ + getAnimationState(name: string): AnimationState; + /** + !#en Adds a clip to the animation with name newName. If a clip with that name already exists it will be replaced with the new clip. + !#zh 添加动画剪辑,并且可以重新设置该动画剪辑的名称。 + @param clip the clip to add + @param newName newName + */ + addClip(clip: AnimationClip, newName?: string): AnimationState; + /** + !#en + Remove clip from the animation list. This will remove the clip and any animation states based on it. + If there are animation states depand on the clip are playing or clip is defaultClip, it will not delete the clip. + But if force is true, then will always remove the clip and any animation states based on it. If clip is defaultClip, defaultClip will be reset to null + !#zh + 从动画列表中移除指定的动画剪辑,
+ 如果依赖于 clip 的 AnimationState 正在播放或者 clip 是 defaultClip 的话,默认是不会删除 clip 的。 + 但是如果 force 参数为 true,则会强制停止该动画,然后移除该动画剪辑和相关的动画。这时候如果 clip 是 defaultClip,defaultClip 将会被重置为 null。 + @param clip clip + @param force If force is true, then will always remove the clip and any animation states based on it. + */ + removeClip(clip: AnimationClip, force?: boolean): void; + /** + !#en + Samples animations at the current state.
+ This is useful when you explicitly want to set up some animation state, and sample it once. + !#zh 对指定或当前动画进行采样。你可以手动将动画设置到某一个状态,然后采样一次。 + @param name name + */ + sample(name: string): void; + /** + !#en + Register animation event callback. + The event arguments will provide the AnimationState which emit the event. + When play an animation, will auto register the event callback to the AnimationState, and unregister the event callback from the AnimationState when animation stopped. + !#zh + 注册动画事件回调。 + 回调的事件里将会附上发送事件的 AnimationState。 + 当播放一个动画时,会自动将事件注册到对应的 AnimationState 上,停止播放时会将事件从这个 AnimationState 上取消注册。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param state state + @param target The target (this object) to invoke the callback, can be null + @param useCapture When set to true, the capture argument prevents callback + from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. + When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE. + Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET. + + @example + ```js + onPlay: function (type, state) { + // callback + } + + // register event to all animation + animation.on('play', this.onPlay, this); + ``` + */ + on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void; + on(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void; + /** + !#en + Unregister animation event callback. + !#zh + 取消注册动画事件回调。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not. + If not specified, useCapture defaults to false. If a callback was registered twice, + one with capture and one without, each must be removed separately. Removal of a capturing callback + does not affect a non-capturing version of the same listener, and vice versa. + + @example + ```js + // unregister event to all animation + animation.off('play', this.onPlay, this); + ``` + */ + off(type: string, callback?: Function, target?: any, useCapture?: boolean): void; + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.once('fire', function () { + cc.log("this is the callback and will be invoked only once"); + }, node); + ``` + */ + once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; + /** + !#en + Send an event with the event object. + !#zh + 通过事件对象派发事件 + @param event event + */ + dispatchEvent(event: Event): void; + } + /** !#en Audio Source. + !#zh 音频源组件,能对音频剪辑。 */ + export class AudioSource extends Component { + /** !#en + Is the audio source playing (Read Only).
+ Note: isPlaying is not supported for Native platforms. + !#zh + 该音频剪辑是否正播放(只读)。
+ 注意:Native 平台暂时不支持 isPlaying。 */ + isPlaying: boolean; + /** !#en The clip of the audio source to play. + !#zh 要播放的音频剪辑。 */ + clip: AudioClip; + /** !#en The volume of the audio source. + !#zh 音频源的音量(0.0 ~ 1.0)。 */ + volume: number; + /** !#en Is the audio source mute? + !#zh 是否静音音频源。Mute 是设置音量为 0,取消静音是恢复原来的音量。 */ + mute: boolean; + /** !#en Is the audio source looping? + !#zh 音频源是否循环播放? */ + loop: boolean; + /** !#en If set to true, the audio source will automatically start playing on onEnable. + !#zh 如果设置为 true,音频源将在 onEnable 时自动播放。 */ + playOnLoad: boolean; + /** + !#en Plays the clip. + !#zh 播放音频剪辑。 + */ + play(): void; + /** + !#en Stops the clip. + !#zh 停止当前音频剪辑。 + */ + stop(): void; + /** + !#en Pause the clip. + !#zh 暂停当前音频剪辑。 + */ + pause(): void; + /** + !#en Resume the clip. + !#zh 恢复播放。 + */ + resume(): void; + /** + !#en Rewind playing music. + !#zh 从头开始播放。 + */ + rewind(): void; + /** + !#en Get current time + !#zh 获取当前的播放时间 + */ + getCurrentTime(): number; + /** + !#en Set current time + !#zh 设置当前的播放时间 + @param time time + */ + setCurrentTime(time: number): number; + /** + !#en Get audio duration + !#zh 获取当前音频的长度 + */ + getDuration(): number; + } + /** !#en + This component will block all input events (mouse and touch) within the bounding box of the node, preventing the input from penetrating into the underlying node, typically for the background of the top UI.
+ This component does not have any API interface and can be added directly to the scene to take effect. + !#zh + 该组件将拦截所属节点 bounding box 内的所有输入事件(鼠标和触摸),防止输入穿透到下层节点,一般用于上层 UI 的背景。
+ 该组件没有任何 API 接口,直接添加到场景即可生效。 */ + export class BlockInputEvents extends Component { + } + /** !#en + Button has 4 Transition types
+ When Button state changed:
+ If Transition type is Button.Transition.NONE, Button will do nothing
+ If Transition type is Button.Transition.COLOR, Button will change target's color
+ If Transition type is Button.Transition.SPRITE, Button will change target Sprite's sprite
+ If Transition type is Button.Transition.SCALE, Button will change target node's scale
+ + Button will trigger 5 events:
+ Button.EVENT_TOUCH_DOWN
+ Button.EVENT_TOUCH_UP
+ Button.EVENT_HOVER_IN
+ Button.EVENT_HOVER_MOVE
+ Button.EVENT_HOVER_OUT
+ User can get the current clicked node with 'event.target' from event object which is passed as parameter in the callback function of click event. + + !#zh + 按钮组件。可以被按下,或者点击。 + + 按钮可以通过修改 Transition 来设置按钮状态过渡的方式: + + - Button.Transition.NONE // 不做任何过渡 + - Button.Transition.COLOR // 进行颜色之间过渡 + - Button.Transition.SPRITE // 进行精灵之间过渡 + - Button.Transition.SCALE // 进行缩放过渡 + + 按钮可以绑定事件(但是必须要在按钮的 Node 上才能绑定事件):
+ 以下事件可以在全平台上都触发: + + - cc.Node.EventType.TOUCH_START // 按下时事件 + - cc.Node.EventType.TOUCH_Move // 按住移动后事件 + - cc.Node.EventType.TOUCH_END // 按下后松开后事件 + - cc.Node.EventType.TOUCH_CANCEL // 按下取消事件 + + 以下事件只在 PC 平台上触发: + + - cc.Node.EventType.MOUSE_DOWN // 鼠标按下时事件 + - cc.Node.EventType.MOUSE_MOVE // 鼠标按住移动后事件 + - cc.Node.EventType.MOUSE_ENTER // 鼠标进入目标事件 + - cc.Node.EventType.MOUSE_LEAVE // 鼠标离开目标事件 + - cc.Node.EventType.MOUSE_UP // 鼠标松开事件 + - cc.Node.EventType.MOUSE_WHEEL // 鼠标滚轮事件 + + 用户可以通过获取 __点击事件__ 回调函数的参数 event 的 target 属性获取当前点击对象。 */ + export class Button extends Component implements GraySpriteState { + /** !#en + Whether the Button is disabled. + If true, the Button will trigger event and do transition. + !#zh + 按钮事件是否被响应,如果为 false,则按钮将被禁用。 */ + interactable: boolean; + /** !#en When this flag is true, Button target sprite will turn gray when interactable is false. + !#zh 如果这个标记为 true,当 button 的 interactable 属性为 false 的时候,会使用内置 shader 让 button 的 target 节点的 sprite 组件变灰 */ + enableAutoGrayEffect: boolean; + /** !#en Transition type + !#zh 按钮状态改变时过渡方式。 */ + transition: Button.Transition; + /** !#en Normal state color. + !#zh 普通状态下按钮所显示的颜色。 */ + normalColor: Color; + /** !#en Pressed state color + !#zh 按下状态时按钮所显示的颜色。 */ + pressedColor: Color; + /** !#en Hover state color + !#zh 悬停状态下按钮所显示的颜色。 */ + hoverColor: Color; + /** !#en Disabled state color + !#zh 禁用状态下按钮所显示的颜色。 */ + disabledColor: Color; + /** !#en Color and Scale transition duration + !#zh 颜色过渡和缩放过渡时所需时间 */ + duration: number; + /** !#en When user press the button, the button will zoom to a scale. + The final scale of the button equals (button original scale * zoomScale) + !#zh 当用户点击按钮后,按钮会缩放到一个值,这个值等于 Button 原始 scale * zoomScale */ + zoomScale: number; + /** !#en Normal state sprite + !#zh 普通状态下按钮所显示的 Sprite 。 */ + normalSprite: SpriteFrame; + /** !#en Pressed state sprite + !#zh 按下状态时按钮所显示的 Sprite 。 */ + pressedSprite: SpriteFrame; + /** !#en Hover state sprite + !#zh 悬停状态下按钮所显示的 Sprite 。 */ + hoverSprite: SpriteFrame; + /** !#en Disabled state sprite + !#zh 禁用状态下按钮所显示的 Sprite 。 */ + disabledSprite: SpriteFrame; + /** !#en + Transition target. + When Button state changed: + If Transition type is Button.Transition.NONE, Button will do nothing + If Transition type is Button.Transition.COLOR, Button will change target's color + If Transition type is Button.Transition.SPRITE, Button will change target Sprite's sprite + !#zh + 需要过渡的目标。 + 当前按钮状态改变规则: + -如果 Transition type 选择 Button.Transition.NONE,按钮不做任何过渡。 + -如果 Transition type 选择 Button.Transition.COLOR,按钮会对目标颜色进行颜色之间的过渡。 + -如果 Transition type 选择 Button.Transition.Sprite,按钮会对目标 Sprite 进行 Sprite 之间的过渡。 */ + target: Node; + /** !#en If Button is clicked, it will trigger event's handler + !#zh 按钮的点击事件列表。 */ + clickEvents: Component.EventHandler[]; + /** !#en The normal material. + !#zh 正常状态的材质。 */ + normalMaterial: Material; + /** !#en The gray material. + !#zh 置灰状态的材质。 */ + grayMaterial: Material; + } + /** !#zh: 作为 UI 根节点,为所有子节点提供视窗四边的位置信息以供对齐,另外提供屏幕适配策略接口,方便从编辑器设置。 + 注:由于本节点的尺寸会跟随屏幕拉伸,所以 anchorPoint 只支持 (0.5, 0.5),否则适配不同屏幕时坐标会有偏差。 */ + export class Canvas extends Component { + /** !#en Current active canvas, the scene should only have one active canvas at the same time. + !#zh 当前激活的画布组件,场景同一时间只能有一个激活的画布。 */ + static instance: Canvas; + /** !#en The desigin resolution for current scene. + !#zh 当前场景设计分辨率。 */ + designResolution: Size; + /** !#en TODO + !#zh: 是否优先将设计分辨率高度撑满视图高度。 */ + fitHeight: boolean; + /** !#en TODO + !#zh: 是否优先将设计分辨率宽度撑满视图宽度。 */ + fitWidth: boolean; + } + /** !#en + Base class for everything attached to Node(Entity).
+
+ NOTE: Not allowed to use construction parameters for Component's subclasses, + because Component is created by the engine. + !#zh + 所有附加到节点的基类。
+
+ 注意:不允许使用组件的子类构造参数,因为组件是由引擎创建的。 */ + export class Component extends Object { + /** !#en The node this component is attached to. A component is always attached to a node. + !#zh 该组件被附加到的节点。组件总会附加到一个节点。 */ + node: Node; + /** !#en The uuid for editor. + !#zh 组件的 uuid,用于编辑器。 */ + uuid: string; + /** !#en indicates whether this component is enabled or not. + !#zh 表示该组件自身是否启用。 */ + enabled: boolean; + /** !#en indicates whether this component is enabled and its node is also active in the hierarchy. + !#zh 表示该组件是否被启用并且所在的节点也处于激活状态。 */ + enabledInHierarchy: boolean; + /** !#en Returns a value which used to indicate the onLoad get called or not. + !#zh 返回一个值用来判断 onLoad 是否被调用过,不等于 0 时调用过,等于 0 时未调用。 */ + _isOnLoadCalled: number; + /** + !#en Update is called every frame, if the Component is enabled.
+ This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere. + !#zh 如果该组件启用,则每帧调用 update。
+ 该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。 + @param dt the delta time in seconds it took to complete the last frame + */ + protected update(dt: number): void; + /** + !#en LateUpdate is called every frame, if the Component is enabled.
+ This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere. + !#zh 如果该组件启用,则每帧调用 LateUpdate。
+ 该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。 + @param dt the delta time in seconds it took to complete the last frame + */ + protected lateUpdate(dt: number): void; + /** + !#en + When attaching to an active node or its node first activated. + onLoad is always called before any start functions, this allows you to order initialization of scripts.
+ This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere. + !#zh + 当附加到一个激活的节点上或者其节点第一次激活时候调用。onLoad 总是会在任何 start 方法调用前执行,这能用于安排脚本的初始化顺序。
+ 该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。 + */ + protected onLoad(): void; + /** + !#en + Called before all scripts' update if the Component is enabled the first time. + Usually used to initialize some logic which need to be called after all components' `onload` methods called.
+ This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere. + !#zh + 如果该组件第一次启用,则在所有组件的 update 之前调用。通常用于需要在所有组件的 onLoad 初始化完毕后执行的逻辑。
+ 该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。 + */ + protected start(): void; + /** + !#en Called when this component becomes enabled and its node is active.
+ This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere. + !#zh 当该组件被启用,并且它的节点也激活时。
+ 该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。 + */ + protected onEnable(): void; + /** + !#en Called when this component becomes disabled or its node becomes inactive.
+ This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere. + !#zh 当该组件被禁用或节点变为无效时调用。
+ 该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。 + */ + protected onDisable(): void; + /** + !#en Called when this component will be destroyed.
+ This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere. + !#zh 当该组件被销毁时调用
+ 该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。 + */ + protected onDestroy(): void; + protected onFocusInEditor(): void; + protected onLostFocusInEditor(): void; + /** + !#en Called to initialize the component or node’s properties when adding the component the first time or when the Reset command is used. This function is only called in editor. + !#zh 用来初始化组件或节点的一些属性,当该组件被第一次添加到节点上或用户点击了它的 Reset 菜单时调用。这个回调只会在编辑器下调用。 + */ + protected resetInEditor(): void; + /** + !#en Adds a component class to the node. You can also add component to node by passing in the name of the script. + !#zh 向节点添加一个组件类,你还可以通过传入脚本的名称来添加组件。 + @param typeOrClassName the constructor or the class name of the component to add + + @example + ```js + var sprite = node.addComponent(cc.Sprite); + var test = node.addComponent("Test"); + ``` + */ + addComponent(type: {new(): T}): T; + addComponent(className: string): any; + /** + !#en + Returns the component of supplied type if the node has one attached, null if it doesn't.
+ You can also get component in the node by passing in the name of the script. + !#zh + 获取节点上指定类型的组件,如果节点有附加指定类型的组件,则返回,如果没有则为空。
+ 传入参数也可以是脚本的名称。 + @param typeOrClassName typeOrClassName + + @example + ```js + // get sprite component. + var sprite = node.getComponent(cc.Sprite); + // get custom test calss. + var test = node.getComponent("Test"); + ``` + */ + getComponent(type: {prototype: T}): T; + getComponent(className: string): any; + /** + !#en Returns all components of supplied Type in the node. + !#zh 返回节点上指定类型的所有组件。 + @param typeOrClassName typeOrClassName + + @example + ```js + var sprites = node.getComponents(cc.Sprite); + var tests = node.getComponents("Test"); + ``` + */ + getComponents(type: {prototype: T}): T[]; + getComponents(className: string): any[]; + /** + !#en Returns the component of supplied type in any of its children using depth first search. + !#zh 递归查找所有子节点中第一个匹配指定类型的组件。 + @param typeOrClassName typeOrClassName + + @example + ```js + var sprite = node.getComponentInChildren(cc.Sprite); + var Test = node.getComponentInChildren("Test"); + ``` + */ + getComponentInChildren(type: {prototype: T}): T; + getComponentInChildren(className: string): any; + /** + !#en Returns the components of supplied type in self or any of its children using depth first search. + !#zh 递归查找自身或所有子节点中指定类型的组件 + @param typeOrClassName typeOrClassName + + @example + ```js + var sprites = node.getComponentsInChildren(cc.Sprite); + var tests = node.getComponentsInChildren("Test"); + ``` + */ + getComponentsInChildren(type: {prototype: T}): T[]; + getComponentsInChildren(className: string): any[]; + /** + !#en + If the component's bounding box is different from the node's, you can implement this method to supply + a custom axis aligned bounding box (AABB), so the editor's scene view can perform hit test properly. + !#zh + 如果组件的包围盒与节点不同,您可以实现该方法以提供自定义的轴向对齐的包围盒(AABB), + 以便编辑器的场景视图可以正确地执行点选测试。 + @param out_rect the Rect to receive the bounding box + */ + _getLocalBounds(out_rect: Rect): void; + /** + !#en + onRestore is called after the user clicks the Reset item in the Inspector's context menu or performs + an undo operation on this component.
+
+ If the component contains the "internal state", short for "temporary member variables which not included
+ in its CCClass properties", then you may need to implement this function.
+
+ The editor will call the getset accessors of your component to record/restore the component's state
+ for undo/redo operation. However, in extreme cases, it may not works well. Then you should implement
+ this function to manually synchronize your component's "internal states" with its public properties.
+ Once you implement this function, all the getset accessors of your component will not be called when
+ the user performs an undo/redo operation. Which means that only the properties with default value
+ will be recorded or restored by editor.
+
+ Similarly, the editor may failed to reset your component correctly in extreme cases. Then if you need
+ to support the reset menu, you should manually synchronize your component's "internal states" with its
+ properties in this function. Once you implement this function, all the getset accessors of your component
+ will not be called during reset operation. Which means that only the properties with default value
+ will be reset by editor. + + This function is only called in editor mode. + !#zh + onRestore 是用户在检查器菜单点击 Reset 时,对此组件执行撤消操作后调用的。
+
+ 如果组件包含了“内部状态”(不在 CCClass 属性中定义的临时成员变量),那么你可能需要实现该方法。
+
+ 编辑器执行撤销/重做操作时,将调用组件的 get set 来录制和还原组件的状态。 + 然而,在极端的情况下,它可能无法良好运作。
+ 那么你就应该实现这个方法,手动根据组件的属性同步“内部状态”。 + 一旦你实现这个方法,当用户撤销或重做时,组件的所有 get set 都不会再被调用。 + 这意味着仅仅指定了默认值的属性将被编辑器记录和还原。
+
+ 同样的,编辑可能无法在极端情况下正确地重置您的组件。
+ 于是如果你需要支持组件重置菜单,你需要在该方法中手工同步组件属性到“内部状态”。
+ 一旦你实现这个方法,组件的所有 get set 都不会在重置操作时被调用。 + 这意味着仅仅指定了默认值的属性将被编辑器重置。 +
+ 此方法仅在编辑器下会被调用。 + */ + onRestore(): void; + /** + !#en + Schedules a custom selector.
+ If the selector is already scheduled, then the interval parameter will be updated without scheduling it again. + !#zh + 调度一个自定义的回调函数。
+ 如果回调函数已调度,那么将不会重复调度它,只会更新时间间隔参数。 + @param callback The callback function + @param interval Tick interval in seconds. 0 means tick every frame. + @param repeat The selector will be executed (repeat + 1) times, you can use cc.macro.REPEAT_FOREVER for tick infinitely. + @param delay The amount of time that the first tick will wait before execution. Unit: s + + @example + ```js + var timeCallback = function (dt) { + cc.log("time: " + dt); + } + this.schedule(timeCallback, 1); + ``` + */ + schedule(callback: Function, interval?: number, repeat?: number, delay?: number): void; + /** + !#en Schedules a callback function that runs only once, with a delay of 0 or larger. + !#zh 调度一个只运行一次的回调函数,可以指定 0 让回调函数在下一帧立即执行或者在一定的延时之后执行。 + @param callback A function wrapped as a selector + @param delay The amount of time that the first tick will wait before execution. Unit: s + + @example + ```js + var timeCallback = function (dt) { + cc.log("time: " + dt); + } + this.scheduleOnce(timeCallback, 2); + ``` + */ + scheduleOnce(callback: Function, delay?: number): void; + /** + !#en Unschedules a custom callback function. + !#zh 取消调度一个自定义的回调函数。 + @param callback_fn A function wrapped as a selector + + @example + ```js + this.unschedule(_callback); + ``` + */ + unschedule(callback_fn: Function): void; + /** + !#en + unschedule all scheduled callback functions: custom callback functions, and the 'update' callback function.
+ Actions are not affected by this method. + !#zh 取消调度所有已调度的回调函数:定制的回调函数以及 'update' 回调函数。动作不受此方法影响。 + + @example + ```js + this.unscheduleAllCallbacks(); + ``` + */ + unscheduleAllCallbacks(): void; + } + /** !#en The Label Component. + !#zh 文字标签组件 */ + export class Label extends RenderComponent { + /** !#en Content string of label. + !#zh 标签显示的文本内容。 */ + string: string; + /** !#en Horizontal Alignment of label. + !#zh 文本内容的水平对齐方式。 */ + horizontalAlign: Label.HorizontalAlign; + /** !#en Vertical Alignment of label. + !#zh 文本内容的垂直对齐方式。 */ + verticalAlign: Label.VerticalAlign; + /** !#en The actual rendering font size in shrink mode + !#zh SHRINK 模式下面文本实际渲染的字体大小 */ + actualFontSize: number; + /** !#en Font size of label. + !#zh 文本字体大小。 */ + fontSize: number; + /** !#en Font family of label, only take effect when useSystemFont property is true. + !#zh 文本字体名称, 只在 useSystemFont 属性为 true 的时候生效。 */ + fontFamily: string; + /** !#en Line Height of label. + !#zh 文本行高。 */ + lineHeight: number; + /** !#en Overflow of label. + !#zh 文字显示超出范围时的处理方式。 */ + overflow: Label.Overflow; + /** !#en Whether auto wrap label when string width is large than label width. + !#zh 是否自动换行。 */ + enableWrapText: boolean; + /** !#en The font of label. + !#zh 文本字体。 */ + font: Font; + /** !#en Whether use system font name or not. + !#zh 是否使用系统字体。 */ + useSystemFont: boolean; + /** !#en The spacing of the x axis between characters, only take Effect when using bitmap fonts. + !#zh 文字之间 x 轴的间距,仅在使用位图字体时生效。 */ + spacingX: number; + /** !#en The cache mode of label. This mode only supports system fonts. + !#zh 文本缓存模式, 该模式只支持系统字体。 */ + cacheMode: Label.CacheMode; + /** !#en Whether enable bold. + !#zh 是否启用黑体。 */ + enableBold: boolean; + /** !#en Whether enable italic. + !#zh 是否启用黑体。 */ + enableItalic: boolean; + /** !#en Whether enable underline. + !#zh 是否启用下划线。 */ + enableUnderline: boolean; + /** !#en The height of underline. + !#zh 下划线高度。 */ + underlineHeight: number; + /** + !#zh 需要保证当前场景中没有使用CHAR缓存的Label才可以清除,否则已渲染的文字没有重新绘制会不显示 + !#en It can be cleared that need to ensure there is not use the CHAR cache in the current scene. Otherwise, the rendered text will not be displayed without repainting. + */ + static clearCharCache(): void; + } + /** !#en Outline effect used to change the display, only for system fonts or TTF fonts + !#zh 描边效果组件,用于字体描边,只能用于系统字体 */ + export class LabelOutline extends Component { + /** !#en outline color + !#zh 改变描边的颜色 */ + color: Color; + /** !#en Change the outline width + !#zh 改变描边的宽度 */ + width: number; + } + /** !#en Shadow effect for Label component, only for system fonts or TTF fonts + !#zh 用于给 Label 组件添加阴影效果,只能用于系统字体或 ttf 字体 */ + export class LabelShadow extends Component { + /** !#en The shadow color + !#zh 阴影的颜色 */ + color: Color; + /** !#en Offset between font and shadow + !#zh 字体与阴影的偏移 */ + offset: Vec2; + /** !#en A non-negative float specifying the level of shadow blur + !#zh 阴影的模糊程度 */ + blur: number; + } + /** !#en + The Layout is a container component, use it to arrange child elements easily.
+ Note:
+ 1.Scaling and rotation of child nodes are not considered.
+ 2.After setting the Layout, the results need to be updated until the next frame, + unless you manually call {{#crossLink "Layout/updateLayout:method"}}{{/crossLink}}。 + !#zh + Layout 组件相当于一个容器,能自动对它的所有子节点进行统一排版。
+ 注意:
+ 1.不会考虑子节点的缩放和旋转。
+ 2.对 Layout 设置后结果需要到下一帧才会更新,除非你设置完以后手动调用 {{#crossLink "Layout/updateLayout:method"}}{{/crossLink}}。 */ + export class Layout extends Component { + /** !#en The layout type. + !#zh 布局类型 */ + type: Layout.Type; + /** !#en + The are three resize modes for Layout. + None, resize Container and resize children. + !#zh 缩放模式 */ + resizeMode: Layout.ResizeMode; + /** !#en The cell size for grid layout. + !#zh 每个格子的大小,只有布局类型为 GRID 的时候才有效。 */ + cellSize: Size; + /** !#en + The start axis for grid layout. If you choose horizontal, then children will layout horizontally at first, + and then break line on demand. Choose vertical if you want to layout vertically at first . + !#zh 起始轴方向类型,可进行水平和垂直布局排列,只有布局类型为 GRID 的时候才有效。 */ + startAxis: Layout.AxisDirection; + /** !#en The left padding of layout, it only effect the layout in one direction. + !#zh 容器内左边距,只会在一个布局方向上生效。 */ + paddingLeft: number; + /** !#en The right padding of layout, it only effect the layout in one direction. + !#zh 容器内右边距,只会在一个布局方向上生效。 */ + paddingRight: number; + /** !#en The top padding of layout, it only effect the layout in one direction. + !#zh 容器内上边距,只会在一个布局方向上生效。 */ + paddingTop: number; + /** !#en The bottom padding of layout, it only effect the layout in one direction. + !#zh 容器内下边距,只会在一个布局方向上生效。 */ + paddingBottom: number; + /** !#en The distance in x-axis between each element in layout. + !#zh 子节点之间的水平间距。 */ + spacingX: number; + /** !#en The distance in y-axis between each element in layout. + !#zh 子节点之间的垂直间距。 */ + spacingY: number; + /** !#en + Only take effect in Vertical layout mode. + This option changes the start element's positioning. + !#zh 垂直排列子节点的方向。 */ + verticalDirection: Layout.VerticalDirection; + /** !#en + Only take effect in Horizontal layout mode. + This option changes the start element's positioning. + !#zh 水平排列子节点的方向。 */ + horizontalDirection: Layout.HorizontalDirection; + /** !#en Adjust the layout if the children scaled. + !#zh 子节点缩放比例是否影响布局。 */ + affectedByScale: boolean; + /** + !#en Perform the layout update + !#zh 立即执行更新布局 + + @example + ```js + layout.type = cc.Layout.HORIZONTAL; + layout.node.addChild(childNode); + cc.log(childNode.x); // not yet changed + layout.updateLayout(); + cc.log(childNode.x); // changed + ``` + */ + updateLayout(): void; + } + /** !#en The Mask Component + !#zh 遮罩组件 */ + export class Mask extends RenderComponent { + /** !#en The mask type. + !#zh 遮罩类型 */ + type: Mask.Type; + /** !#en The mask image + !#zh 遮罩所需要的贴图 */ + spriteFrame: SpriteFrame; + /** !#en + The alpha threshold.(Not supported Canvas Mode)
+ The content is drawn only where the stencil have pixel with alpha greater than the alphaThreshold.
+ Should be a float between 0 and 1.
+ This default to 0.1. + When it's set to 1, the stencil will discard all pixels, nothing will be shown. + !#zh + Alpha 阈值(不支持 Canvas 模式)
+ 只有当模板的像素的 alpha 大于等于 alphaThreshold 时,才会绘制内容。
+ 该数值 0 ~ 1 之间的浮点数,默认值为 0.1 + 当被设置为 1 时,会丢弃所有蒙版像素,所以不会显示任何内容 */ + alphaThreshold: number; + /** !#en Reverse mask (Not supported Canvas Mode) + !#zh 反向遮罩(不支持 Canvas 模式) */ + inverted: boolean; + /** TODO: remove segments, not supported by graphics + !#en The segements for ellipse mask. + !#zh 椭圆遮罩的曲线细分数 */ + segements: number; + } + /** !#en + cc.MotionStreak manages a Ribbon based on it's motion in absolute space.
+ You construct it with a fadeTime, minimum segment size, texture path, texture
+ length and color. The fadeTime controls how long it takes each vertex in
+ the streak to fade out, the minimum segment size it how many pixels the
+ streak will move before adding a new ribbon segment, and the texture
+ length is the how many pixels the texture is stretched across. The texture
+ is vertically aligned along the streak segment. + !#zh 运动轨迹,用于游戏对象的运动轨迹上实现拖尾渐隐效果。 */ + export class MotionStreak extends Component implements BlendFunc { + /** !#en + !#zh 在编辑器模式下预览拖尾效果。 */ + preview: boolean; + /** !#en The fade time to fade. + !#zh 拖尾的渐隐时间,以秒为单位。 */ + fadeTime: number; + /** !#en The minimum segment size. + !#zh 拖尾之间最小距离。 */ + minSeg: number; + /** !#en The stroke's width. + !#zh 拖尾的宽度。 */ + stroke: number; + /** !#en The texture of the MotionStreak. + !#zh 拖尾的贴图。 */ + texture: Texture2D; + /** !#en The color of the MotionStreak. + !#zh 拖尾的颜色 */ + color: Color; + /** !#en The fast Mode. + !#zh 是否启用了快速模式。当启用快速模式,新的点会被更快地添加,但精度较低。 */ + fastMode: boolean; + /** + !#en Remove all living segments of the ribbon. + !#zh 删除当前所有的拖尾片段。 + + @example + ```js + // Remove all living segments of the ribbon. + myMotionStreak.reset(); + ``` + */ + reset(): void; + /** !#en specify the source Blend Factor, this will generate a custom material object, please pay attention to the memory cost. + !#zh 指定原图的混合模式,这会克隆一个新的材质对象,注意这带来的开销 */ + srcBlendFactor: macro.BlendFactor; + /** !#en specify the destination Blend Factor. + !#zh 指定目标的混合模式 */ + dstBlendFactor: macro.BlendFactor; + } + /** !#en The PageView control + !#zh 页面视图组件 */ + export class PageView extends ScrollView { + /** !#en Specify the size type of each page in PageView. + !#zh 页面视图中每个页面大小类型 */ + sizeMode: PageView.SizeMode; + /** !#en The page view direction + !#zh 页面视图滚动类型 */ + direction: PageView.Direction; + /** !#en + The scroll threshold value, when drag exceeds this value, + release the next page will automatically scroll, less than the restore + !#zh 滚动临界值,默认单位百分比,当拖拽超出该数值时,松开会自动滚动下一页,小于时则还原。 */ + scrollThreshold: number; + /** !#en + Auto page turning velocity threshold. When users swipe the PageView quickly, + it will calculate a velocity based on the scroll distance and time, + if the calculated velocity is larger than the threshold, then it will trigger page turning. + !#zh + 快速滑动翻页临界值。 + 当用户快速滑动时,会根据滑动开始和结束的距离与时间计算出一个速度值, + 该值与此临界值相比较,如果大于临界值,则进行自动翻页。 */ + autoPageTurningThreshold: number; + /** !#en Change the PageTurning event timing of PageView. + !#zh 设置 PageView PageTurning 事件的发送时机。 */ + pageTurningEventTiming: number; + /** !#en The Page View Indicator + !#zh 页面视图指示器组件 */ + indicator: PageViewIndicator; + /** !#en The time required to turn over a page. unit: second + !#zh 每个页面翻页时所需时间。单位:秒 */ + pageTurningSpeed: number; + /** !#en PageView events callback + !#zh 滚动视图的事件回调函数 */ + pageEvents: Component.EventHandler[]; + /** + !#en Returns current page index + !#zh 返回当前页面索引 + */ + getCurrentPageIndex(): number; + /** + !#en Set current page index + !#zh 设置当前页面索引 + @param index index + */ + setCurrentPageIndex(index: number): void; + /** + !#en Returns all pages of pageview + !#zh 返回视图中的所有页面 + */ + getPages(): Node[]; + /** + !#en At the end of the current page view to insert a new view + !#zh 在当前页面视图的尾部插入一个新视图 + @param page page + */ + addPage(page: Node): void; + /** + !#en Inserts a page in the specified location + !#zh 将页面插入指定位置中 + @param page page + @param index index + */ + insertPage(page: Node, index: number): void; + /** + !#en Removes a page from PageView. + !#zh 移除指定页面 + @param page page + */ + removePage(page: Node): void; + /** + !#en Removes a page at index of PageView. + !#zh 移除指定下标的页面 + @param index index + */ + removePageAtIndex(index: number): void; + /** + !#en Removes all pages from PageView + !#zh 移除所有页面 + */ + removeAllPages(): void; + /** + !#en Scroll PageView to index. + !#zh 滚动到指定页面 + @param idx index of page. + @param timeInSecond scrolling time + */ + scrollToPage(idx: number, timeInSecond: number): void; + } + /** !#en The Page View Indicator Component + !#zh 页面视图每页标记组件 */ + export class PageViewIndicator extends Component { + /** !#en The spriteFrame for each element. + !#zh 每个页面标记显示的图片 */ + spriteFrame: SpriteFrame; + /** !#en The location direction of PageViewIndicator. + !#zh 页面标记摆放方向 */ + direction: PageViewIndicator.Direction; + /** !#en The cellSize for each element. + !#zh 每个页面标记的大小 */ + cellSize: Size; + /** !#en The distance between each element. + !#zh 每个页面标记之间的边距 */ + spacing: number; + /** + !#en Set Page View + !#zh 设置页面视图 + @param target target + */ + setPageView(target: PageView): void; + } + /** !#en + Visual indicator of progress in some operation. + Displays a bar to the user representing how far the operation has progressed. + !#zh + 进度条组件,可用于显示加载资源时的进度。 */ + export class ProgressBar extends Component { + /** !#en The targeted Sprite which will be changed progressively. + !#zh 用来显示进度条比例的 Sprite 对象。 */ + barSprite: Sprite; + /** !#en The progress mode, there are two modes supported now: horizontal and vertical. + !#zh 进度条的模式 */ + mode: ProgressBar.Mode; + /** !#en The total width or height of the bar sprite. + !#zh 进度条实际的总长度 */ + totalLength: number; + /** !#en The current progress of the bar sprite. The valid value is between 0-1. + !#zh 当前进度值,该数值的区间是 0-1 之间。 */ + progress: number; + /** !#en Whether reverse the progress direction of the bar sprite. + !#zh 进度条是否进行反方向变化。 */ + reverse: boolean; + } + /** !#en + Base class for components which supports rendering features. + !#zh + 所有支持渲染的组件的基类 */ + export class RenderComponent extends Component { + /** !#en The materials used by this render component. + !#zh 渲染组件使用的材质。 */ + sharedMaterials: Material[]; + /** + !#en Get the material by index. + !#zh 根据指定索引获取材质 + @param index index + */ + getMaterial(index: number): MaterialVariant; + /** + !#en Gets all the materials. + !#zh 获取所有材质。 + */ + getMaterials(): MaterialVariant[]; + /** + !#en Set the material by index. + !#zh 根据指定索引设置材质 + @param index index + @param material material + */ + setMaterial(index: number, material: Material): Material; + } + /** !#en The RichText Component. + !#zh 富文本组件 */ + export class RichText extends Component { + /** !#en Content string of RichText. + !#zh 富文本显示的文本内容。 */ + string: string; + /** !#en Horizontal Alignment of each line in RichText. + !#zh 文本内容的水平对齐方式。 */ + horizontalAlign: macro.TextAlignment; + /** !#en Font size of RichText. + !#zh 富文本字体大小。 */ + fontSize: number; + /** !#en Custom System font of RichText + !#zh 富文本定制系统字体 */ + fontFamily: string; + /** !#en Custom TTF font of RichText + !#zh 富文本定制字体 */ + font: TTFFont; + /** !#en Whether use system font name or not. + !#zh 是否使用系统字体。 */ + useSystemFont: boolean; + /** !#en The cache mode of label. This mode only supports system fonts. + !#zh 文本缓存模式, 该模式只支持系统字体。 */ + cacheMode: Label.CacheMode; + /** !#en The maximize width of the RichText + !#zh 富文本的最大宽度 */ + maxWidth: number; + /** !#en Line Height of RichText. + !#zh 富文本行高。 */ + lineHeight: number; + /** !#en The image atlas for the img tag. For each src value in the img tag, there should be a valid spriteFrame in the image atlas. + !#zh 对于 img 标签里面的 src 属性名称,都需要在 imageAtlas 里面找到一个有效的 spriteFrame,否则 img tag 会判定为无效。 */ + imageAtlas: SpriteAtlas; + /** !#en + Once checked, the RichText will block all input events (mouse and touch) within + the bounding box of the node, preventing the input from penetrating into the underlying node. + !#zh + 选中此选项后,RichText 将阻止节点边界框中的所有输入事件(鼠标和触摸),从而防止输入事件穿透到底层节点。 */ + handleTouchEvent: boolean; + } + /** !#en + The Scrollbar control allows the user to scroll an image or other view that is too large to see completely + !#zh 滚动条组件 */ + export class Scrollbar extends Component { + /** !#en The "handle" part of the scrollbar. + !#zh 作为当前滚动区域位置显示的滑块 Sprite。 */ + handle: Sprite; + /** !#en The direction of scrollbar. + !#zh ScrollBar 的滚动方向。 */ + direction: Scrollbar.Direction; + /** !#en Whether enable auto hide or not. + !#zh 是否在没有滚动动作时自动隐藏 ScrollBar。 */ + enableAutoHide: boolean; + /** !#en + The time to hide scrollbar when scroll finished. + Note: This value is only useful when enableAutoHide is true. + !#zh + 没有滚动动作后经过多久会自动隐藏。 + 注意:只要当 “enableAutoHide” 为 true 时,才有效。 */ + autoHideTime: number; + } + /** !#en + Layout container for a view hierarchy that can be scrolled by the user, + allowing it to be larger than the physical display. + + !#zh + 滚动视图组件 */ + export class ScrollView extends Component { + /** !#en This is a reference to the UI element to be scrolled. + !#zh 可滚动展示内容的节点。 */ + content: Node; + /** !#en Enable horizontal scroll. + !#zh 是否开启水平滚动。 */ + horizontal: boolean; + /** !#en Enable vertical scroll. + !#zh 是否开启垂直滚动。 */ + vertical: boolean; + /** !#en When inertia is set, the content will continue to move when touch ended. + !#zh 是否开启滚动惯性。 */ + inertia: boolean; + /** !#en + It determines how quickly the content stop moving. A value of 1 will stop the movement immediately. + A value of 0 will never stop the movement until it reaches to the boundary of scrollview. + !#zh + 开启惯性后,在用户停止触摸后滚动多快停止,0表示永不停止,1表示立刻停止。 */ + brake: number; + /** !#en When elastic is set, the content will be bounce back when move out of boundary. + !#zh 是否允许滚动内容超过边界,并在停止触摸后回弹。 */ + elastic: boolean; + /** !#en The elapse time of bouncing back. A value of 0 will bounce back immediately. + !#zh 回弹持续的时间,0 表示将立即反弹。 */ + bounceDuration: number; + /** !#en The horizontal scrollbar reference. + !#zh 水平滚动的 ScrollBar。 */ + horizontalScrollBar: Scrollbar; + /** !#en The vertical scrollbar reference. + !#zh 垂直滚动的 ScrollBar。 */ + verticalScrollBar: Scrollbar; + /** !#en Scrollview events callback + !#zh 滚动视图的事件回调函数 */ + scrollEvents: Component.EventHandler[]; + /** !#en If cancelInnerEvents is set to true, the scroll behavior will cancel touch events on inner content nodes + It's set to true by default. + !#zh 如果这个属性被设置为 true,那么滚动行为会取消子节点上注册的触摸事件,默认被设置为 true。 + 注意,子节点上的 touchstart 事件仍然会触发,触点移动距离非常短的情况下 touchmove 和 touchend 也不会受影响。 */ + cancelInnerEvents: boolean; + /** + !#en Scroll the content to the bottom boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图底部。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the bottom boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the bottom of the view. + scrollView.scrollToBottom(0.1); + ``` + */ + scrollToBottom(timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the top boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图顶部。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the top boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the top of the view. + scrollView.scrollToTop(0.1); + ``` + */ + scrollToTop(timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the left boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图左边。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the left boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the left of the view. + scrollView.scrollToLeft(0.1); + ``` + */ + scrollToLeft(timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the right boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图右边。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the right boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the right of the view. + scrollView.scrollToRight(0.1); + ``` + */ + scrollToRight(timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the top left boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图左上角。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the top left boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the upper left corner of the view. + scrollView.scrollToTopLeft(0.1); + ``` + */ + scrollToTopLeft(timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the top right boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图右上角。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the top right boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the top right corner of the view. + scrollView.scrollToTopRight(0.1); + ``` + */ + scrollToTopRight(timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the bottom left boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图左下角。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the bottom left boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the lower left corner of the view. + scrollView.scrollToBottomLeft(0.1); + ``` + */ + scrollToBottomLeft(timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the bottom right boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图右下角。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the bottom right boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the lower right corner of the view. + scrollView.scrollToBottomRight(0.1); + ``` + */ + scrollToBottomRight(timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll with an offset related to the ScrollView's top left origin, if timeInSecond is omitted, then it will jump to the + specific offset immediately. + !#zh 视图内容在规定时间内将滚动到 ScrollView 相对左上角原点的偏移位置, 如果 timeInSecond参数不传,则立即滚动到指定偏移位置。 + @param offset A Vec2, the value of which each axis between 0 and maxScrollOffset + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the specific offset of ScrollView immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to middle position in 0.1 second in x-axis + let maxScrollOffset = this.getMaxScrollOffset(); + scrollView.scrollToOffset(cc.v2(maxScrollOffset.x / 2, 0), 0.1); + ``` + */ + scrollToOffset(offset: Vec2, timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Get the positive offset value corresponds to the content's top left boundary. + !#zh 获取滚动视图相对于左上角原点的当前滚动偏移 + */ + getScrollOffset(): Vec2; + /** + !#en Get the maximize available scroll offset + !#zh 获取滚动视图最大可以滚动的偏移量 + */ + getMaxScrollOffset(): Vec2; + /** + !#en Scroll the content to the horizontal percent position of ScrollView. + !#zh 视图内容在规定时间内将滚动到 ScrollView 水平方向的百分比位置上。 + @param percent A value between 0 and 1. + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the horizontal percent position of ScrollView immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to middle position. + scrollView.scrollToBottomRight(0.5, 0.1); + ``` + */ + scrollToPercentHorizontal(percent: number, timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the percent position of ScrollView in any direction. + !#zh 视图内容在规定时间内进行垂直方向和水平方向的滚动,并且滚动到指定百分比位置上。 + @param anchor A point which will be clamp between cc.v2(0,0) and cc.v2(1,1). + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the percent position of ScrollView immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Vertical scroll to the bottom of the view. + scrollView.scrollTo(cc.v2(0, 1), 0.1); + + // Horizontal scroll to view right. + scrollView.scrollTo(cc.v2(1, 0), 0.1); + ``` + */ + scrollTo(anchor: Vec2, timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the vertical percent position of ScrollView. + !#zh 视图内容在规定时间内滚动到 ScrollView 垂直方向的百分比位置上。 + @param percent A value between 0 and 1. + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the vertical percent position of ScrollView immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + // Scroll to middle position. + scrollView.scrollToPercentVertical(0.5, 0.1); + */ + scrollToPercentVertical(percent: number, timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Stop auto scroll immediately + !#zh 停止自动滚动, 调用此 API 可以让 Scrollview 立即停止滚动 + */ + stopAutoScroll(): void; + /** + !#en Modify the content position. + !#zh 设置当前视图内容的坐标点。 + @param position The position in content's parent space. + */ + setContentPosition(position: Vec2): void; + /** + !#en Query the content's position in its parent space. + !#zh 获取当前视图内容的坐标点。 + */ + getContentPosition(): Vec2; + /** + !#en Query whether the user is currently dragging the ScrollView to scroll it + !#zh 用户是否在拖拽当前滚动视图 + */ + isScrolling(): boolean; + /** + !#en Query whether the ScrollView is currently scrolling because of a bounceback or inertia slowdown. + !#zh 当前滚动视图是否在惯性滚动 + */ + isAutoScrolling(): boolean; + } + /** !#en The Slider Control + !#zh 滑动器组件 */ + export class Slider extends Component { + /** !#en The "handle" part of the slider + !#zh 滑动器滑块按钮部件 */ + handle: Button; + /** !#en The slider direction + !#zh 滑动器方向 */ + direction: Slider.Direction; + /** !#en The current progress of the slider. The valid value is between 0-1 + !#zh 当前进度值,该数值的区间是 0-1 之间 */ + progress: number; + /** !#en The slider slide events' callback array + !#zh 滑动器组件滑动事件回调函数数组 */ + slideEvents: Component.EventHandler[]; + } + /** !#en Renders a sprite in the scene. + !#zh 该组件用于在场景中渲染精灵。 */ + export class Sprite extends RenderComponent implements BlendFunc { + /** !#en The sprite frame of the sprite. + !#zh 精灵的精灵帧 */ + spriteFrame: SpriteFrame; + /** !#en The sprite render type. + !#zh 精灵渲染类型 */ + type: Sprite.Type; + /** !#en + The fill type, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”. + !#zh + 精灵填充类型,仅渲染类型设置为 cc.Sprite.Type.FILLED 时有效。 */ + fillType: Sprite.FillType; + /** !#en + The fill Center, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”. + !#zh + 填充中心点,仅渲染类型设置为 cc.Sprite.Type.FILLED 时有效。 */ + fillCenter: Vec2; + /** !#en + The fill Start, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”. + !#zh + 填充起始点,仅渲染类型设置为 cc.Sprite.Type.FILLED 时有效。 */ + fillStart: number; + /** !#en + The fill Range, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”. + !#zh + 填充范围,仅渲染类型设置为 cc.Sprite.Type.FILLED 时有效。 */ + fillRange: number; + /** !#en specify the frame is trimmed or not. + !#zh 是否使用裁剪模式 */ + trim: boolean; + /** !#en specify the size tracing mode. + !#zh 精灵尺寸调整模式 */ + sizeMode: Sprite.SizeMode; + /** + Change the state of sprite. + @param state NORMAL or GRAY State. + */ + setState(state: Sprite.State): void; + /** + Gets the current state. + */ + getState(): Sprite.State; + /** !#en specify the source Blend Factor, this will generate a custom material object, please pay attention to the memory cost. + !#zh 指定原图的混合模式,这会克隆一个新的材质对象,注意这带来的开销 */ + srcBlendFactor: macro.BlendFactor; + /** !#en specify the destination Blend Factor. + !#zh 指定目标的混合模式 */ + dstBlendFactor: macro.BlendFactor; + } + /** !#en The toggle component is a CheckBox, when it used together with a ToggleGroup, it + could be treated as a RadioButton. + !#zh Toggle 是一个 CheckBox,当它和 ToggleGroup 一起使用的时候,可以变成 RadioButton。 */ + export class Toggle extends Button implements GraySpriteState { + /** !#en When this value is true, the check mark component will be enabled, otherwise + the check mark component will be disabled. + !#zh 如果这个设置为 true,则 check mark 组件会处于 enabled 状态,否则处于 disabled 状态。 */ + isChecked: boolean; + /** !#en The toggle group which the toggle belongs to, when it is null, the toggle is a CheckBox. + Otherwise, the toggle is a RadioButton. + !#zh Toggle 所属的 ToggleGroup,这个属性是可选的。如果这个属性为 null,则 Toggle 是一个 CheckBox, + 否则,Toggle 是一个 RadioButton。 */ + toggleGroup: ToggleGroup; + /** !#en The image used for the checkmark. + !#zh Toggle 处于选中状态时显示的图片 */ + checkMark: Sprite; + /** !#en If Toggle is clicked, it will trigger event's handler + !#zh Toggle 按钮的点击事件列表。 */ + checkEvents: Component.EventHandler[]; + /** + !#en Make the toggle button checked. + !#zh 使 toggle 按钮处于选中状态 + */ + check(): void; + /** + !#en Make the toggle button unchecked. + !#zh 使 toggle 按钮处于未选中状态 + */ + uncheck(): void; + /** !#en The normal material. + !#zh 正常状态的材质。 */ + normalMaterial: Material; + /** !#en The gray material. + !#zh 置灰状态的材质。 */ + grayMaterial: Material; + } + /** !#en ToggleContainer is not a visiable UI component but a way to modify the behavior of a set of Toggles.
+ Toggles that belong to the same group could only have one of them to be switched on at a time.
+ Note: All the first layer child node containing the toggle component will auto be added to the container + !#zh ToggleContainer 不是一个可见的 UI 组件,它可以用来修改一组 Toggle 组件的行为。
+ 当一组 Toggle 属于同一个 ToggleContainer 的时候,任何时候只能有一个 Toggle 处于选中状态。
+ 注意:所有包含 Toggle 组件的一级子节点都会自动被添加到该容器中 */ + export class ToggleContainer extends Component { + /** !#en If this setting is true, a toggle could be switched off and on when pressed. + If it is false, it will make sure there is always only one toggle could be switched on + and the already switched on toggle can't be switched off. + !#zh 如果这个设置为 true, 那么 toggle 按钮在被点击的时候可以反复地被选中和未选中。 */ + allowSwitchOff: boolean; + /** !#en If Toggle is clicked, it will trigger event's handler + !#zh Toggle 按钮的点击事件列表。 */ + checkEvents: Component.EventHandler[]; + /** !#en Read only property, return the toggle items array reference managed by ToggleContainer. + !#zh 只读属性,返回 ToggleContainer 管理的 toggle 数组引用 */ + toggleItems: Toggle[]; + } + /** !#en ToggleGroup is not a visiable UI component but a way to modify the behavior of a set of Toggles. + Toggles that belong to the same group could only have one of them to be switched on at a time. + !#zh ToggleGroup 不是一个可见的 UI 组件,它可以用来修改一组 Toggle 组件的行为。当一组 Toggle 属于同一个 ToggleGroup 的时候, + 任何时候只能有一个 Toggle 处于选中状态。 */ + export class ToggleGroup extends Component { + /** !#en If this setting is true, a toggle could be switched off and on when pressed. + If it is false, it will make sure there is always only one toggle could be switched on + and the already switched on toggle can't be switched off. + !#zh 如果这个设置为 true, 那么 toggle 按钮在被点击的时候可以反复地被选中和未选中。 */ + allowSwitchOff: boolean; + /** !#en Read only property, return the toggle items array reference managed by toggleGroup. + !#zh 只读属性,返回 toggleGroup 管理的 toggle 数组引用 */ + toggleItems: any[]; + } + /** !#en + Handling touch events in a ViewGroup takes special care, + because it's common for a ViewGroup to have children that are targets for different touch events than the ViewGroup itself. + To make sure that each view correctly receives the touch events intended for it, + ViewGroup should register capture phase event and handle the event propagation properly. + Please refer to Scrollview for more information. + + !#zh + ViewGroup的事件处理比较特殊,因为 ViewGroup 里面的子节点关心的事件跟 ViewGroup 本身可能不一样。 + 为了让子节点能够正确地处理事件,ViewGroup 需要注册 capture 阶段的事件,并且合理地处理 ViewGroup 之间的事件传递。 + 请参考 ScrollView 的实现来获取更多信息。 */ + export class ViewGroup extends Component { + } + /** !#en + Stores and manipulate the anchoring based on its parent. + Widget are used for GUI but can also be used for other things. + Widget will adjust current node's position and size automatically, but the results after adjustment can not be obtained until the next frame unless you call {{#crossLink "Widget/updateAlignment:method"}}{{/crossLink}} manually. + !#zh + Widget 组件,用于设置和适配其相对于父节点的边距,Widget 通常被用于 UI 界面,也可以用于其他地方。 + Widget 会自动调整当前节点的坐标和宽高,不过目前调整后的结果要到下一帧才能在脚本里获取到,除非你先手动调用 {{#crossLink "Widget/updateAlignment:method"}}{{/crossLink}}。 */ + export class Widget extends Component { + /** !#en Specifies an alignment target that can only be one of the parent nodes of the current node. + The default value is null, and when null, indicates the current parent. + !#zh 指定一个对齐目标,只能是当前节点的其中一个父节点,默认为空,为空时表示当前父节点。 */ + target: Node; + /** !#en Whether to align the top. + !#zh 是否对齐上边。 */ + isAlignTop: boolean; + /** !#en + Vertically aligns the midpoint, This will open the other vertical alignment options cancel. + !#zh + 是否垂直方向对齐中点,开启此项会将垂直方向其他对齐选项取消。 */ + isAlignVerticalCenter: boolean; + /** !#en Whether to align the bottom. + !#zh 是否对齐下边。 */ + isAlignBottom: boolean; + /** !#en Whether to align the left. + !#zh 是否对齐左边 */ + isAlignLeft: boolean; + /** !#en + Horizontal aligns the midpoint. This will open the other horizontal alignment options canceled. + !#zh + 是否水平方向对齐中点,开启此选项会将水平方向其他对齐选项取消。 */ + isAlignHorizontalCenter: boolean; + /** !#en Whether to align the right. + !#zh 是否对齐右边。 */ + isAlignRight: boolean; + /** !#en + Whether the stretched horizontally, when enable the left and right alignment will be stretched horizontally, + the width setting is invalid (read only). + !#zh + 当前是否水平拉伸。当同时启用左右对齐时,节点将会被水平拉伸,此时节点的宽度只读。 */ + isStretchWidth: boolean; + /** !#en + Whether the stretched vertically, when enable the left and right alignment will be stretched vertically, + then height setting is invalid (read only) + !#zh + 当前是否垂直拉伸。当同时启用上下对齐时,节点将会被垂直拉伸,此时节点的高度只读。 */ + isStretchHeight: boolean; + /** !#en + The margins between the top of this node and the top of parent node, + the value can be negative, Only available in 'isAlignTop' open. + !#zh + 本节点顶边和父节点顶边的距离,可填写负值,只有在 isAlignTop 开启时才有作用。 */ + top: number; + /** !#en + The margins between the bottom of this node and the bottom of parent node, + the value can be negative, Only available in 'isAlignBottom' open. + !#zh + 本节点底边和父节点底边的距离,可填写负值,只有在 isAlignBottom 开启时才有作用。 */ + bottom: number; + /** !#en + The margins between the left of this node and the left of parent node, + the value can be negative, Only available in 'isAlignLeft' open. + !#zh + 本节点左边和父节点左边的距离,可填写负值,只有在 isAlignLeft 开启时才有作用。 */ + left: number; + /** !#en + The margins between the right of this node and the right of parent node, + the value can be negative, Only available in 'isAlignRight' open. + !#zh + 本节点右边和父节点右边的距离,可填写负值,只有在 isAlignRight 开启时才有作用。 */ + right: number; + /** !#en + Horizontal aligns the midpoint offset value, + the value can be negative, Only available in 'isAlignHorizontalCenter' open. + !#zh 水平居中的偏移值,可填写负值,只有在 isAlignHorizontalCenter 开启时才有作用。 */ + horizontalCenter: number; + /** !#en + Vertical aligns the midpoint offset value, + the value can be negative, Only available in 'isAlignVerticalCenter' open. + !#zh 垂直居中的偏移值,可填写负值,只有在 isAlignVerticalCenter 开启时才有作用。 */ + verticalCenter: number; + /** !#en If true, horizontalCenter is pixel margin, otherwise is percentage (0 - 1) margin. + !#zh 如果为 true,"horizontalCenter" 将会以像素作为偏移值,反之为百分比(0 到 1)。 */ + isAbsoluteHorizontalCenter: boolean; + /** !#en If true, verticalCenter is pixel margin, otherwise is percentage (0 - 1) margin. + !#zh 如果为 true,"verticalCenter" 将会以像素作为偏移值,反之为百分比(0 到 1)。 */ + isAbsoluteVerticalCenter: boolean; + /** !#en + If true, top is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's height. + !#zh + 如果为 true,"top" 将会以像素作为边距,否则将会以相对父物体高度的百分比(0 到 1)作为边距。 */ + isAbsoluteTop: boolean; + /** !#en + If true, bottom is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's height. + !#zh + 如果为 true,"bottom" 将会以像素作为边距,否则将会以相对父物体高度的百分比(0 到 1)作为边距。 */ + isAbsoluteBottom: boolean; + /** !#en + If true, left is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's width. + !#zh + 如果为 true,"left" 将会以像素作为边距,否则将会以相对父物体宽度的百分比(0 到 1)作为边距。 */ + isAbsoluteLeft: boolean; + /** !#en + If true, right is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's width. + !#zh + 如果为 true,"right" 将会以像素作为边距,否则将会以相对父物体宽度的百分比(0 到 1)作为边距。 */ + isAbsoluteRight: boolean; + /** !#en Specifies the alignment mode of the Widget, which determines when the widget should refresh. + !#zh 指定 Widget 的对齐模式,用于决定 Widget 应该何时刷新。 */ + alignMode: Widget.AlignMode; + /** + !#en + Immediately perform the widget alignment. You need to manually call this method only if + you need to get the latest results after the alignment before the end of current frame. + !#zh + 立刻执行 widget 对齐操作。这个接口一般不需要手工调用。 + 只有当你需要在当前帧结束前获得 widget 对齐后的最新结果时才需要手动调用这个方法。 + + @example + ```js + widget.top = 10; // change top margin + cc.log(widget.node.y); // not yet changed + widget.updateAlignment(); + cc.log(widget.node.y); // changed + ``` + */ + updateAlignment(): void; + /** !#en + When turned on, it will only be aligned once at the end of the onEnable frame, + then immediately disables the current component. + This will allow the script or animation to continue controlling the current node. + Note: It will still be aligned at the frame when onEnable is called. + !#zh + 开启后仅会在 onEnable 的当帧结束时对齐一次,然后立刻禁用当前组件。 + 这样便于脚本或动画继续控制当前节点。 + 注意:onEnable 时所在的那一帧仍然会进行对齐。 */ + isAlignOnce: boolean; + } + /** !#en SwanSubContextView is a view component which controls open data context viewport in WeChat game platform.
+ The component's node size decide the viewport of the sub context content in main context, + the entire sub context texture will be scaled to the node's bounding box area.
+ This component provides multiple important features:
+ 1. Sub context could use its own resolution size and policy.
+ 2. Sub context could be minized to smallest size it needed.
+ 3. Resolution of sub context content could be increased.
+ 4. User touch input is transformed to the correct viewport.
+ 5. Texture update is handled by this component. User don't need to worry.
+ One important thing to be noted, whenever the node's bounding box change, + you need to manually reset the viewport of sub context using updateSubContextViewport. + !#zh SwanSubContextView 可以用来控制百度小游戏平台开放数据域在主域中的视窗的位置。
+ 这个组件的节点尺寸决定了开放数据域内容在主域中的尺寸,整个开放数据域会被缩放到节点的包围盒范围内。
+ 在这个组件的控制下,用户可以更自由得控制开放数据域:
+ 1. 子域中可以使用独立的设计分辨率和适配模式
+ 2. 子域区域尺寸可以缩小到只容纳内容即可
+ 3. 子域的分辨率也可以被放大,以便获得更清晰的显示效果
+ 4. 用户输入坐标会被自动转换到正确的子域视窗中
+ 5. 子域内容贴图的更新由组件负责,用户不需要处理
+ 唯一需要注意的是,当子域节点的包围盒发生改变时,开发者需要使用 `updateSubContextViewport` 来手动更新子域视窗。 */ + export class SwanSubContextView extends Component { + /** + !#en Update the sub context viewport manually, it should be called whenever the node's bounding box changes. + !#zh 更新开放数据域相对于主域的 viewport,这个函数应该在节点包围盒改变时手动调用。 + */ + updateSubContextViewport(): void; + } + /** !#en WXSubContextView is a view component which controls open data context viewport in WeChat game platform.
+ The component's node size decide the viewport of the sub context content in main context, + the entire sub context texture will be scaled to the node's bounding box area.
+ This component provides multiple important features:
+ 1. Sub context could use its own resolution size and policy.
+ 2. Sub context could be minized to smallest size it needed.
+ 3. Resolution of sub context content could be increased.
+ 4. User touch input is transformed to the correct viewport.
+ 5. Texture update is handled by this component. User don't need to worry.
+ One important thing to be noted, whenever the node's bounding box change, + you need to manually reset the viewport of sub context using updateSubContextViewport. + !#zh WXSubContextView 可以用来控制微信小游戏平台开放数据域在主域中的视窗的位置。
+ 这个组件的节点尺寸决定了开放数据域内容在主域中的尺寸,整个开放数据域会被缩放到节点的包围盒范围内。
+ 在这个组件的控制下,用户可以更自由得控制开放数据域:
+ 1. 子域中可以使用独立的设计分辨率和适配模式
+ 2. 子域区域尺寸可以缩小到只容纳内容即可
+ 3. 子域的分辨率也可以被放大,以便获得更清晰的显示效果
+ 4. 用户输入坐标会被自动转换到正确的子域视窗中
+ 5. 子域内容贴图的更新由组件负责,用户不需要处理
+ 唯一需要注意的是,当子域节点的包围盒发生改变时,开发者需要使用 `updateSubContextViewport` 来手动更新子域视窗。 */ + export class WXSubContextView extends Component { + /** + !#en Reset open data context size and viewport + !#zh 重置开放数据域的尺寸和视窗 + */ + reset(): void; + /** + !#en Update the sub context viewport manually, it should be called whenever the node's bounding box changes. + !#zh 更新开放数据域相对于主域的 viewport,这个函数应该在节点包围盒改变时手动调用。 + */ + updateSubContextViewport(): void; + } + /** !#en + EventTarget is an object to which an event is dispatched when something has occurred. + Entity are the most common event targets, but other objects can be event targets too. + + Event targets are an important part of the Fireball event model. + The event target serves as the focal point for how events flow through the scene graph. + When an event such as a mouse click or a keypress occurs, Fireball dispatches an event object + into the event flow from the root of the hierarchy. The event object then makes its way through + the scene graph until it reaches the event target, at which point it begins its return trip through + the scene graph. This round-trip journey to the event target is conceptually divided into three phases: + - The capture phase comprises the journey from the root to the last node before the event target's node + - The target phase comprises only the event target node + - The bubbling phase comprises any subsequent nodes encountered on the return trip to the root of the tree + See also: http://www.w3.org/TR/DOM-Level-3-Events/#event-flow + + Event targets can implement the following methods: + - _getCapturingTargets + - _getBubblingTargets + + !#zh + 事件目标是事件触发时,分派的事件对象,Node 是最常见的事件目标, + 但是其他对象也可以是事件目标。
*/ + export class EventTarget extends CallbacksInvoker { + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en + Register an callback of a specific event type on the EventTarget. + This type of event should be triggered via `emit`. + !#zh + 注册事件目标的特定事件类型回调。这种类型的事件应该被 `emit` 触发。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, node); + ``` + */ + on(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. + !#zh + 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + + @example + ```js + // register fire eventListener + var callback = eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, target); + // remove fire event listener + eventTarget.off('fire', callback, target); + // remove all fire event listeners + eventTarget.off('fire'); + ``` + */ + off(type: string, callback?: Function, target?: any): void; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.once('fire', function () { + cc.log("this is the callback and will be invoked only once"); + }, node); + ``` + */ + once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; + /** + !#en + Send an event with the event object. + !#zh + 通过事件对象派发事件 + @param event event + */ + dispatchEvent(event: Event): void; + } + /** !#en Base class of all kinds of events. + !#zh 包含事件相关信息的对象。 */ + export class Event { + /** + + @param type The name of the event (case-sensitive), e.g. "click", "fire", or "submit" + @param bubbles A boolean indicating whether the event bubbles up through the tree or not + */ + constructor(type: string, bubbles: boolean); + /** !#en The name of the event (case-sensitive), e.g. "click", "fire", or "submit". + !#zh 事件类型。 */ + type: string; + /** !#en Indicate whether the event bubbles up through the tree or not. + !#zh 表示该事件是否进行冒泡。 */ + bubbles: boolean; + /** !#en A reference to the target to which the event was originally dispatched. + !#zh 最初事件触发的目标 */ + target: any; + /** !#en A reference to the currently registered target for the event. + !#zh 当前目标 */ + currentTarget: any; + /** !#en + Indicates which phase of the event flow is currently being evaluated. + Returns an integer value represented by 4 constants: + - Event.NONE = 0 + - Event.CAPTURING_PHASE = 1 + - Event.AT_TARGET = 2 + - Event.BUBBLING_PHASE = 3 + The phases are explained in the [section 3.1, Event dispatch and DOM event flow] + (http://www.w3.org/TR/DOM-Level-3-Events/#event-flow), of the DOM Level 3 Events specification. + !#zh 事件阶段 */ + eventPhase: number; + /** + !#en Reset the event for being stored in the object pool. + !#zh 重置对象池中存储的事件。 + */ + unuse(): string; + /** + !#en Reuse the event for being used again by the object pool. + !#zh 用于对象池再次使用的事件。 + */ + reuse(): string; + /** + !#en Stops propagation for current event. + !#zh 停止传递当前事件。 + */ + stopPropagation(): void; + /** + !#en Stops propagation for current event immediately, + the event won't even be dispatched to the listeners attached in the current target. + !#zh 立即停止当前事件的传递,事件甚至不会被分派到所连接的当前目标。 + */ + stopPropagationImmediate(): void; + /** + !#en Checks whether the event has been stopped. + !#zh 检查该事件是否已经停止传递. + */ + isStopped(): boolean; + /** + !#en +

+ Gets current target of the event
+ note: It only be available when the event listener is associated with node.
+ It returns 0 when the listener is associated with fixed priority. +

+ !#zh 获取当前目标节点 + */ + getCurrentTarget(): Node; + /** + !#en Gets the event type. + !#zh 获取事件类型 + */ + getType(): string; + /** !#en Code for event without type. + !#zh 没有类型的事件 */ + static NO_TYPE: string; + /** !#en The type code of Touch event. + !#zh 触摸事件类型 */ + static TOUCH: string; + /** !#en The type code of Mouse event. + !#zh 鼠标事件类型 */ + static MOUSE: string; + /** !#en The type code of Keyboard event. + !#zh 键盘事件类型 */ + static KEYBOARD: string; + /** !#en The type code of Acceleration event. + !#zh 加速器事件类型 */ + static ACCELERATION: string; + /** !#en Events not currently dispatched are in this phase + !#zh 尚未派发事件阶段 */ + static NONE: number; + /** !#en + The capturing phase comprises the journey from the root to the last node before the event target's node + see http://www.w3.org/TR/DOM-Level-3-Events/#event-flow + !#zh 捕获阶段,包括事件目标节点之前从根节点到最后一个节点的过程。 */ + static CAPTURING_PHASE: number; + /** !#en + The target phase comprises only the event target node + see http://www.w3.org/TR/DOM-Level-3-Events/#event-flow + !#zh 目标阶段仅包括事件目标节点。 */ + static AT_TARGET: number; + /** !#en + The bubbling phase comprises any subsequent nodes encountered on the return trip to the root of the hierarchy + see http://www.w3.org/TR/DOM-Level-3-Events/#event-flow + !#zh 冒泡阶段, 包括回程遇到到层次根节点的任何后续节点。 */ + static BUBBLING_PHASE: number; + } + /** !#en + The System event, it currently supports keyboard events and accelerometer events.
+ You can get the SystemEvent instance with cc.systemEvent.
+ !#zh + 系统事件,它目前支持按键事件和重力感应事件。
+ 你可以通过 cc.systemEvent 获取到 SystemEvent 的实例。
*/ + export class SystemEvent extends EventTarget { + /** + !#en whether enable accelerometer event + !#zh 是否启用加速度计事件 + @param isEnable isEnable + */ + setAccelerometerEnabled(isEnable: boolean): void; + /** + !#en set accelerometer interval value + !#zh 设置加速度计间隔值 + @param interval interval + */ + setAccelerometerInterval(interval: number): void; + } + /** !#en The touch event class + !#zh 封装了触摸相关的信息。 */ + export class Touch { + /** + !#en Returns the current touch location in OpenGL coordinates.、 + !#zh 获取当前触点位置。 + */ + getLocation(): Vec2; + /** + !#en Returns X axis location value. + !#zh 获取当前触点 X 轴位置。 + */ + getLocationX(): number; + /** + !#en Returns Y axis location value. + !#zh 获取当前触点 Y 轴位置。 + */ + getLocationY(): number; + /** + !#en Returns the previous touch location in OpenGL coordinates. + !#zh 获取触点在上一次事件时的位置对象,对象包含 x 和 y 属性。 + */ + getPreviousLocation(): Vec2; + /** + !#en Returns the start touch location in OpenGL coordinates. + !#zh 获取触点落下时的位置对象,对象包含 x 和 y 属性。 + */ + getStartLocation(): Vec2; + /** + !#en Returns the delta distance from the previous touche to the current one in screen coordinates. + !#zh 获取触点距离上一次事件移动的距离对象,对象包含 x 和 y 属性。 + */ + getDelta(): Vec2; + /** + !#en Returns the current touch location in screen coordinates. + !#zh 获取当前事件在游戏窗口内的坐标位置对象,对象包含 x 和 y 属性。 + */ + getLocationInView(): Vec2; + /** + !#en Returns the previous touch location in screen coordinates. + !#zh 获取触点在上一次事件时在游戏窗口中的位置对象,对象包含 x 和 y 属性。 + */ + getPreviousLocationInView(): Vec2; + /** + !#en Returns the start touch location in screen coordinates. + !#zh 获取触点落下时在游戏窗口中的位置对象,对象包含 x 和 y 属性。 + */ + getStartLocationInView(): Vec2; + /** + !#en Returns the id of cc.Touch. + !#zh 触点的标识 ID,可以用来在多点触摸中跟踪触点。 + */ + getID(): number; + /** + !#en Sets information to touch. + !#zh 设置触摸相关的信息。用于监控触摸事件。 + @param id id + @param x x + @param y y + */ + setTouchInfo(id: number, x: number, y: number): void; + } + /** undefined */ + export class Graphics extends RenderComponent { + /** !#en + Current line width. + !#zh + 当前线条宽度 */ + lineWidth: number; + /** !#en + lineJoin determines how two connecting segments (of lines, arcs or curves) with non-zero lengths in a shape are joined together. + !#zh + lineJoin 用来设置2个长度不为0的相连部分(线段,圆弧,曲线)如何连接在一起的属性。 */ + lineJoin: Graphics.LineJoin; + /** !#en + lineCap determines how the end points of every line are drawn. + !#zh + lineCap 指定如何绘制每一条线段末端。 */ + lineCap: Graphics.LineCap; + /** !#en + stroke color + !#zh + 线段颜色 */ + strokeColor: Color; + /** !#en + fill color + !#zh + 填充颜色 */ + fillColor: Color; + /** !#en + Sets the miter limit ratio + !#zh + 设置斜接面限制比例 */ + miterLimit: number; + /** + !#en Move path start point to (x,y). + !#zh 移动路径起点到坐标(x, y) + @param x The x axis of the coordinate for the end point. + @param y The y axis of the coordinate for the end point. + */ + moveTo(x?: number, y?: number): void; + /** + !#en Adds a straight line to the path + !#zh 绘制直线路径 + @param x The x axis of the coordinate for the end point. + @param y The y axis of the coordinate for the end point. + */ + lineTo(x?: number, y?: number): void; + /** + !#en Adds a cubic Bézier curve to the path + !#zh 绘制三次贝赛尔曲线路径 + @param c1x The x axis of the coordinate for the first control point. + @param c1y The y axis of the coordinate for first control point. + @param c2x The x axis of the coordinate for the second control point. + @param c2y The y axis of the coordinate for the second control point. + @param x The x axis of the coordinate for the end point. + @param y The y axis of the coordinate for the end point. + */ + bezierCurveTo(c1x?: number, c1y?: number, c2x?: number, c2y?: number, x?: number, y?: number): void; + /** + !#en Adds a quadratic Bézier curve to the path + !#zh 绘制二次贝赛尔曲线路径 + @param cx The x axis of the coordinate for the control point. + @param cy The y axis of the coordinate for the control point. + @param x The x axis of the coordinate for the end point. + @param y The y axis of the coordinate for the end point. + */ + quadraticCurveTo(cx?: number, cy?: number, x?: number, y?: number): void; + /** + !#en Adds an arc to the path which is centered at (cx, cy) position with radius r starting at startAngle and ending at endAngle going in the given direction by counterclockwise (defaulting to false). + !#zh 绘制圆弧路径。圆弧路径的圆心在 (cx, cy) 位置,半径为 r ,根据 counterclockwise (默认为false)指定的方向从 startAngle 开始绘制,到 endAngle 结束。 + @param cx The x axis of the coordinate for the center point. + @param cy The y axis of the coordinate for the center point. + @param r The arc's radius. + @param startAngle The angle at which the arc starts, measured clockwise from the positive x axis and expressed in radians. + @param endAngle The angle at which the arc ends, measured clockwise from the positive x axis and expressed in radians. + @param counterclockwise An optional Boolean which, if true, causes the arc to be drawn counter-clockwise between the two angles. By default it is drawn clockwise. + */ + arc(cx?: number, cy?: number, r?: number, startAngle?: number, endAngle?: number, counterclockwise?: boolean): void; + /** + !#en Adds an ellipse to the path. + !#zh 绘制椭圆路径。 + @param cx The x axis of the coordinate for the center point. + @param cy The y axis of the coordinate for the center point. + @param rx The ellipse's x-axis radius. + @param ry The ellipse's y-axis radius. + */ + ellipse(cx?: number, cy?: number, rx?: number, ry?: number): void; + /** + !#en Adds an circle to the path. + !#zh 绘制圆形路径。 + @param cx The x axis of the coordinate for the center point. + @param cy The y axis of the coordinate for the center point. + @param r The circle's radius. + */ + circle(cx?: number, cy?: number, r?: number): void; + /** + !#en Adds an rectangle to the path. + !#zh 绘制矩形路径。 + @param x The x axis of the coordinate for the rectangle starting point. + @param y The y axis of the coordinate for the rectangle starting point. + @param w The rectangle's width. + @param h The rectangle's height. + */ + rect(x?: number, y?: number, w?: number, h?: number): void; + /** + !#en Adds an round corner rectangle to the path. + !#zh 绘制圆角矩形路径。 + @param x The x axis of the coordinate for the rectangle starting point. + @param y The y axis of the coordinate for the rectangle starting point. + @param w The rectangles width. + @param h The rectangle's height. + @param r The radius of the rectangle. + */ + roundRect(x?: number, y?: number, w?: number, h?: number, r?: number): void; + /** + !#en Draws a filled rectangle. + !#zh 绘制填充矩形。 + @param x The x axis of the coordinate for the rectangle starting point. + @param y The y axis of the coordinate for the rectangle starting point. + @param w The rectangle's width. + @param h The rectangle's height. + */ + fillRect(x?: number, y?: number, w?: number, h?: number): void; + /** + !#en Erasing any previously drawn content. + !#zh 擦除之前绘制的所有内容的方法。 + @param clean Whether to clean the graphics inner cache. + */ + clear(clean?: boolean): void; + /** + !#en Causes the point of the pen to move back to the start of the current path. It tries to add a straight line from the current point to the start. + !#zh 将笔点返回到当前路径起始点的。它尝试从当前点到起始点绘制一条直线。 + */ + close(): void; + /** + !#en Strokes the current or given path with the current stroke style. + !#zh 根据当前的画线样式,绘制当前或已经存在的路径。 + */ + stroke(): void; + /** + !#en Fills the current or given path with the current fill style. + !#zh 根据当前的画线样式,填充当前或已经存在的路径。 + */ + fill(): void; + } + /** Loader for resource loading process. It's a singleton object. */ + export class loader extends Pipeline { + /** The asset loader in cc.loader's pipeline, it's by default the first pipe. + It's used to identify an asset's type, and determine how to download it. */ + static assetLoader: any; + /** The md5 pipe in cc.loader's pipeline, it could be absent if the project isn't build with md5 option. + It's used to modify the url to the real downloadable url with md5 suffix. */ + static md5Pipe: any; + /** The downloader in cc.loader's pipeline, it's by default the second pipe. + It's used to download files with several handlers: pure text, image, script, audio, font, uuid. + You can add your own download function with addDownloadHandlers */ + static downloader: any; + /** The loader in cc.loader's pipeline, it's by default the third pipe. + It's used to parse downloaded content with several handlers: JSON, image, plist, fnt, uuid. + You can add your own download function with addLoadHandlers */ + static loader: any; + /** + Gets a new XMLHttpRequest instance. + */ + static getXMLHttpRequest(): XMLHttpRequest; + /** + Add custom supported types handler or modify existing type handler for download process. + @param extMap Custom supported types with corresponded handler + + @example + ```js + cc.loader.addDownloadHandlers({ + // This will match all url with `.scene` extension or all url with `scene` type + 'scene' : function (url, callback) {} + }); + ``` + */ + static addDownloadHandlers(extMap: any): void; + /** + Add custom supported types handler or modify existing type handler for load process. + @param extMap Custom supported types with corresponded handler + + @example + ```js + cc.loader.addLoadHandlers({ + // This will match all url with `.scene` extension or all url with `scene` type + 'scene' : function (url, callback) {} + }); + ``` + */ + static addLoadHandlers(extMap: any): void; + /** + Load resources with a progression callback and a complete callback. + The progression callback is the same as Pipeline's {{#crossLink "LoadingItems/onProgress:method"}}onProgress{{/crossLink}} + The complete callback is almost the same as Pipeline's {{#crossLink "LoadingItems/onComplete:method"}}onComplete{{/crossLink}} + The only difference is when user pass a single url as resources, the complete callback will set its result directly as the second parameter. + @param resources Url list in an array + @param progressCallback Callback invoked when progression change + @param completeCallback Callback invoked when all resources loaded + + @example + ```js + cc.loader.load('a.png', function (err, tex) { + cc.log('Result should be a texture: ' + (tex instanceof cc.Texture2D)); + }); + + cc.loader.load('http://example.com/a.png', function (err, tex) { + cc.log('Should load a texture from external url: ' + (tex instanceof cc.Texture2D)); + }); + + cc.loader.load({url: 'http://example.com/getImageREST?file=a.png', type: 'png'}, function (err, tex) { + cc.log('Should load a texture from RESTful API by specify the type: ' + (tex instanceof cc.Texture2D)); + }); + + cc.loader.load(['a.png', 'b.json'], function (errors, results) { + if (errors) { + for (var i = 0; i < errors.length; i++) { + cc.log('Error url [' + errors[i] + ']: ' + results.getError(errors[i])); + } + } + var aTex = results.getContent('a.png'); + var bJsonObj = results.getContent('b.json'); + }); + ``` + */ + static load(resources: string|string[]|{uuid?: string, url?: string, type?: string}, completeCallback?: Function): void; + static load(resources: string|string[]|{uuid?: string, url?: string, type?: string}, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: Function|null): void; + /** + Load resources from the "resources" folder inside the "assets" folder of your project.
+
+ Note: All asset URLs in Creator use forward slashes, URLs using backslashes will not work. + @param url Url of the target resource. + The url is relative to the "resources" folder, extensions must be omitted. + @param type Only asset of type will be loaded if this argument is supplied. + @param progressCallback Callback invoked when progression change. + @param completeCallback Callback invoked when the resource loaded. + + @example + ```js + // load the prefab (project/assets/resources/misc/character/cocos) from resources folder + cc.loader.loadRes('misc/character/cocos', function (err, prefab) { + if (err) { + cc.error(err.message || err); + return; + } + cc.log('Result should be a prefab: ' + (prefab instanceof cc.Prefab)); + }); + + // load the sprite frame of (project/assets/resources/imgs/cocos.png) from resources folder + cc.loader.loadRes('imgs/cocos', cc.SpriteFrame, function (err, spriteFrame) { + if (err) { + cc.error(err.message || err); + return; + } + cc.log('Result should be a sprite frame: ' + (spriteFrame instanceof cc.SpriteFrame)); + }); + ``` + */ + static loadRes(url: string, type: typeof cc.Asset, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any) => void)|null): void; + static loadRes(url: string, type: typeof cc.Asset, completeCallback: (error: Error, resource: any) => void): void; + static loadRes(url: string, type: typeof cc.Asset): void; + static loadRes(url: string, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any) => void)|null): void; + static loadRes(url: string, completeCallback: (error: Error, resource: any) => void): void; + static loadRes(url: string): void; + /** + This method is like {{#crossLink "loader/loadRes:method"}}{{/crossLink}} except that it accepts array of url. + @param urls Array of URLs of the target resource. + The url is relative to the "resources" folder, extensions must be omitted. + @param type Only asset of type will be loaded if this argument is supplied. + @param progressCallback Callback invoked when progression change. + @param completeCallback A callback which is called when all assets have been loaded, or an error occurs. + + @example + ```js + // load the SpriteFrames from resources folder + var spriteFrames; + var urls = ['misc/characters/character_01', 'misc/weapons/weapons_01']; + cc.loader.loadResArray(urls, cc.SpriteFrame, function (err, assets) { + if (err) { + cc.error(err); + return; + } + spriteFrames = assets; + // ... + }); + ``` + */ + static loadResArray(url: string[], type: typeof cc.Asset, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any[]) => void)|null): void; + static loadResArray(url: string[], type: typeof cc.Asset, completeCallback: (error: Error, resource: any[]) => void): void; + static loadResArray(url: string[], type: typeof cc.Asset): void; + static loadResArray(url: string[], progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any[]) => void)|null): void; + static loadResArray(url: string[], completeCallback: (error: Error, resource: any[]) => void): void; + static loadResArray(url: string[]): void; + static loadResArray(url: string[], type: typeof cc.Asset[]): void; + /** + Load all assets in a folder inside the "assets/resources" folder of your project.
+
+ Note: All asset URLs in Creator use forward slashes, URLs using backslashes will not work. + @param url Url of the target folder. + The url is relative to the "resources" folder, extensions must be omitted. + @param type Only asset of type will be loaded if this argument is supplied. + @param progressCallback Callback invoked when progression change. + @param completeCallback A callback which is called when all assets have been loaded, or an error occurs. + + @example + ```js + // load the texture (resources/imgs/cocos.png) and the corresponding sprite frame + cc.loader.loadResDir('imgs/cocos', function (err, assets) { + if (err) { + cc.error(err); + return; + } + var texture = assets[0]; + var spriteFrame = assets[1]; + }); + + // load all textures in "resources/imgs/" + cc.loader.loadResDir('imgs', cc.Texture2D, function (err, textures) { + var texture1 = textures[0]; + var texture2 = textures[1]; + }); + + // load all JSONs in "resources/data/" + cc.loader.loadResDir('data', function (err, objects, urls) { + var data = objects[0]; + var url = urls[0]; + }); + ``` + */ + static loadResDir(url: string, type: typeof cc.Asset, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any[], urls: string[]) => void)|null): void; + static loadResDir(url: string, type: typeof cc.Asset, completeCallback: (error: Error, resource: any[], urls: string[]) => void): void; + static loadResDir(url: string, type: typeof cc.Asset): void; + static loadResDir(url: string, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any[], urls: string[]) => void)|null): void; + static loadResDir(url: string, completeCallback: (error: Error, resource: any[], urls: string[]) => void): void; + static loadResDir(url: string): void; + /** + Get resource data by id.
+ When you load resources with {{#crossLink "loader/load:method"}}{{/crossLink}} or {{#crossLink "loader/loadRes:method"}}{{/crossLink}}, + the url will be the unique identity of the resource. + After loaded, you can acquire them by passing the url to this API. + @param url url + @param type Only asset of type will be returned if this argument is supplied. + */ + static getRes(url: string, type?: Function): any; + /** + !#en + Get all resource dependencies of the loaded asset in an array, including itself. + The owner parameter accept the following types: 1. The asset itself; 2. The resource url; 3. The asset's uuid.
+ The returned array stores the dependencies with their uuids, after retrieve dependencies, + you can release them, access dependent assets by passing the uuid to {{#crossLink "loader/getRes:method"}}{{/crossLink}}, or other stuffs you want.
+ For release all dependencies of an asset, please refer to {{#crossLink "loader/release:method"}}{{/crossLink}} + Here is some examples: + !#zh + 获取某个已经加载好的资源的所有依赖资源,包含它自身,并保存在数组中返回。owner 参数接收以下几种类型:1. 资源 asset 对象;2. 资源目录下的 url;3. 资源的 uuid。
+ 返回的数组将仅保存依赖资源的 uuid,获取这些 uuid 后,你可以从 loader 释放这些资源;通过 {{#crossLink "loader/getRes:method"}}{{/crossLink}} 获取某个资源或者进行其他你需要的操作。
+ 想要释放一个资源及其依赖资源,可以参考 {{#crossLink "loader/release:method"}}{{/crossLink}}。下面是一些示例代码: + @param owner The owner asset or the resource url or the asset's uuid + + @example + ```js + // Release all dependencies of a loaded prefab + var deps = cc.loader.getDependsRecursively(prefab); + cc.loader.release(deps); + // Retrieve all dependent textures + var deps = cc.loader.getDependsRecursively('prefabs/sample'); + var textures = []; + for (var i = 0; i < deps.length; ++i) { + var item = cc.loader.getRes(deps[i]); + if (item instanceof cc.Texture2D) { + textures.push(item); + } + } + ``` + */ + static getDependsRecursively(owner: Asset|RawAsset|string): any[]; + /** + !#en + Release the content of an asset or an array of assets by uuid. + Start from v1.3, this method will not only remove the cache of the asset in loader, but also clean up its content. + For example, if you release a texture, the texture asset and its gl texture data will be freed up. + In complexe project, you can use this function with {{#crossLink "loader/getDependsRecursively:method"}}{{/crossLink}} to free up memory in critical circumstances. + Notice, this method may cause the texture to be unusable, if there are still other nodes use the same texture, they may turn to black and report gl errors. + If you only want to remove the cache of an asset, please use {{#crossLink "pipeline/removeItem:method"}}{{/crossLink}} + !#zh + 通过 id(通常是资源 url)来释放一个资源或者一个资源数组。 + 从 v1.3 开始,这个方法不仅会从 loader 中删除资源的缓存引用,还会清理它的资源内容。 + 比如说,当你释放一个 texture 资源,这个 texture 和它的 gl 贴图数据都会被释放。 + 在复杂项目中,我们建议你结合 {{#crossLink "loader/getDependsRecursively:method"}}{{/crossLink}} 来使用,便于在设备内存告急的情况下更快地释放不再需要的资源的内存。 + 注意,这个函数可能会导致资源贴图或资源所依赖的贴图不可用,如果场景中存在节点仍然依赖同样的贴图,它们可能会变黑并报 GL 错误。 + 如果你只想删除一个资源的缓存引用,请使用 {{#crossLink "pipeline/removeItem:method"}}{{/crossLink}} + @param asset asset + + @example + ```js + // Release a texture which is no longer need + cc.loader.release(texture); + // Release all dependencies of a loaded prefab + var deps = cc.loader.getDependsRecursively('prefabs/sample'); + cc.loader.release(deps); + // If there is no instance of this prefab in the scene, the prefab and its dependencies like textures, sprite frames, etc, will be freed up. + // If you have some other nodes share a texture in this prefab, you can skip it in two ways: + // 1. Forbid auto release a texture before release + cc.loader.setAutoRelease(texture2d, false); + // 2. Remove it from the dependencies array + var deps = cc.loader.getDependsRecursively('prefabs/sample'); + var index = deps.indexOf(texture2d._uuid); + if (index !== -1) + deps.splice(index, 1); + cc.loader.release(deps); + ``` + */ + static release(asset: Asset|RawAsset|string|any[]): void; + /** + !#en Release the asset by its object. Refer to {{#crossLink "loader/release:method"}}{{/crossLink}} for detailed informations. + !#zh 通过资源对象自身来释放资源。详细信息请参考 {{#crossLink "loader/release:method"}}{{/crossLink}} + @param asset asset + */ + static releaseAsset(asset: Asset): void; + /** + !#en Release the asset loaded by {{#crossLink "loader/loadRes:method"}}{{/crossLink}}. Refer to {{#crossLink "loader/release:method"}}{{/crossLink}} for detailed informations. + !#zh 释放通过 {{#crossLink "loader/loadRes:method"}}{{/crossLink}} 加载的资源。详细信息请参考 {{#crossLink "loader/release:method"}}{{/crossLink}} + @param url url + @param type Only asset of type will be released if this argument is supplied. + */ + static releaseRes(url: string, type?: Function): void; + /** + !#en Release the all assets loaded by {{#crossLink "loader/loadResDir:method"}}{{/crossLink}}. Refer to {{#crossLink "loader/release:method"}}{{/crossLink}} for detailed informations. + !#zh 释放通过 {{#crossLink "loader/loadResDir:method"}}{{/crossLink}} 加载的资源。详细信息请参考 {{#crossLink "loader/release:method"}}{{/crossLink}} + @param url url + @param type Only asset of type will be released if this argument is supplied. + */ + static releaseResDir(url: string, type?: Function): void; + /** + !#en Resource all assets. Refer to {{#crossLink "loader/release:method"}}{{/crossLink}} for detailed informations. + !#zh 释放所有资源。详细信息请参考 {{#crossLink "loader/release:method"}}{{/crossLink}} + */ + static releaseAll(): void; + /** + !#en + Indicates whether to release the asset when loading a new scene.
+ By default, when loading a new scene, all assets in the previous scene will be released or preserved + according to whether the previous scene checked the "Auto Release Assets" option. + On the other hand, assets dynamically loaded by using `cc.loader.loadRes` or `cc.loader.loadResDir` + will not be affected by that option, remain not released by default.
+ Use this API to change the default behavior on a single asset, to force preserve or release specified asset when scene switching.
+
+ See: {{#crossLink "loader/setAutoReleaseRecursively:method"}}cc.loader.setAutoReleaseRecursively{{/crossLink}}, {{#crossLink "loader/isAutoRelease:method"}}cc.loader.isAutoRelease{{/crossLink}} + !#zh + 设置当场景切换时是否自动释放资源。
+ 默认情况下,当加载新场景时,旧场景的资源根据旧场景是否勾选“Auto Release Assets”,将会被释放或者保留。 + 而使用 `cc.loader.loadRes` 或 `cc.loader.loadResDir` 动态加载的资源,则不受场景设置的影响,默认不自动释放。
+ 使用这个 API 可以在单个资源上改变这个默认行为,强制在切换场景时保留或者释放指定资源。
+
+ 参考:{{#crossLink "loader/setAutoReleaseRecursively:method"}}cc.loader.setAutoReleaseRecursively{{/crossLink}},{{#crossLink "loader/isAutoRelease:method"}}cc.loader.isAutoRelease{{/crossLink}} + @param assetOrUrlOrUuid asset object or the raw asset's url or uuid + @param autoRelease indicates whether should release automatically + + @example + ```js + // auto release the texture event if "Auto Release Assets" disabled in current scene + cc.loader.setAutoRelease(texture2d, true); + // don't release the texture even if "Auto Release Assets" enabled in current scene + cc.loader.setAutoRelease(texture2d, false); + // first parameter can be url + cc.loader.setAutoRelease(audioUrl, false); + ``` + */ + static setAutoRelease(assetOrUrlOrUuid: Asset|string, autoRelease: boolean): void; + /** + !#en + Indicates whether to release the asset and its referenced other assets when loading a new scene.
+ By default, when loading a new scene, all assets in the previous scene will be released or preserved + according to whether the previous scene checked the "Auto Release Assets" option. + On the other hand, assets dynamically loaded by using `cc.loader.loadRes` or `cc.loader.loadResDir` + will not be affected by that option, remain not released by default.
+ Use this API to change the default behavior on the specified asset and its recursively referenced assets, to force preserve or release specified asset when scene switching.
+
+ See: {{#crossLink "loader/setAutoRelease:method"}}cc.loader.setAutoRelease{{/crossLink}}, {{#crossLink "loader/isAutoRelease:method"}}cc.loader.isAutoRelease{{/crossLink}} + !#zh + 设置当场景切换时是否自动释放资源及资源引用的其它资源。
+ 默认情况下,当加载新场景时,旧场景的资源根据旧场景是否勾选“Auto Release Assets”,将会被释放或者保留。 + 而使用 `cc.loader.loadRes` 或 `cc.loader.loadResDir` 动态加载的资源,则不受场景设置的影响,默认不自动释放。
+ 使用这个 API 可以在指定资源及资源递归引用到的所有资源上改变这个默认行为,强制在切换场景时保留或者释放指定资源。
+
+ 参考:{{#crossLink "loader/setAutoRelease:method"}}cc.loader.setAutoRelease{{/crossLink}},{{#crossLink "loader/isAutoRelease:method"}}cc.loader.isAutoRelease{{/crossLink}} + @param assetOrUrlOrUuid asset object or the raw asset's url or uuid + @param autoRelease indicates whether should release automatically + + @example + ```js + // auto release the SpriteFrame and its Texture event if "Auto Release Assets" disabled in current scene + cc.loader.setAutoReleaseRecursively(spriteFrame, true); + // don't release the SpriteFrame and its Texture even if "Auto Release Assets" enabled in current scene + cc.loader.setAutoReleaseRecursively(spriteFrame, false); + // don't release the Prefab and all the referenced assets + cc.loader.setAutoReleaseRecursively(prefab, false); + ``` + */ + static setAutoReleaseRecursively(assetOrUrlOrUuid: Asset|string, autoRelease: boolean): void; + /** + !#en + Returns whether the asset is configured as auto released, despite how "Auto Release Assets" property is set on scene asset.
+
+ See: {{#crossLink "loader/setAutoRelease:method"}}cc.loader.setAutoRelease{{/crossLink}}, {{#crossLink "loader/setAutoReleaseRecursively:method"}}cc.loader.setAutoReleaseRecursively{{/crossLink}} + + !#zh + 返回指定的资源是否有被设置为自动释放,不论场景的“Auto Release Assets”如何设置。
+
+ 参考:{{#crossLink "loader/setAutoRelease:method"}}cc.loader.setAutoRelease{{/crossLink}},{{#crossLink "loader/setAutoReleaseRecursively:method"}}cc.loader.setAutoReleaseRecursively{{/crossLink}} + @param assetOrUrl asset object or the raw asset's url + */ + static isAutoRelease(assetOrUrl: Asset|string): boolean; + } + /** !#en + LoadingItems is the queue of items which can flow them into the loading pipeline.
+ Please don't construct it directly, use {{#crossLink "LoadingItems.create"}}cc.LoadingItems.create{{/crossLink}} instead, because we use an internal pool to recycle the queues.
+ It hold a map of items, each entry in the map is a url to object key value pair.
+ Each item always contains the following property:
+ - id: The identification of the item, usually it's identical to url
+ - url: The url
+ - type: The type, it's the extension name of the url by default, could be specified manually too.
+ - error: The error happened in pipeline will be stored in this property.
+ - content: The content processed by the pipeline, the final result will also be stored in this property.
+ - complete: The flag indicate whether the item is completed by the pipeline.
+ - states: An object stores the states of each pipe the item go through, the state can be: Pipeline.ItemState.WORKING | Pipeline.ItemState.ERROR | Pipeline.ItemState.COMPLETE
+
+ Item can hold other custom properties.
+ Each LoadingItems object will be destroyed for recycle after onComplete callback
+ So please don't hold its reference for later usage, you can copy properties in it though. + !#zh + LoadingItems 是一个加载对象队列,可以用来输送加载对象到加载管线中。
+ 请不要直接使用 new 构造这个类的对象,你可以使用 {{#crossLink "LoadingItems.create"}}cc.LoadingItems.create{{/crossLink}} 来创建一个新的加载队列,这样可以允许我们的内部对象池回收并重利用加载队列。 + 它有一个 map 属性用来存放加载项,在 map 对象中以 url 为 key 值。
+ 每个对象都会包含下列属性:
+ - id:该对象的标识,通常与 url 相同。
+ - url:路径
+ - type: 类型,它这是默认的 URL 的扩展名,可以手动指定赋值。
+ - error:pipeline 中发生的错误将被保存在这个属性中。
+ - content: pipeline 中处理的临时结果,最终的结果也将被存储在这个属性中。
+ - complete:该标志表明该对象是否通过 pipeline 完成。
+ - states:该对象存储每个管道中对象经历的状态,状态可以是 Pipeline.ItemState.WORKING | Pipeline.ItemState.ERROR | Pipeline.ItemState.COMPLETE
+
+ 对象可容纳其他自定义属性。
+ 每个 LoadingItems 对象都会在 onComplete 回调之后被销毁,所以请不要持有它的引用并在结束回调之后依赖它的内容执行任何逻辑,有这种需求的话你可以提前复制它的内容。 */ + export class LoadingItems extends CallbacksInvoker { + /** + !#en This is a callback which will be invoked while an item flow out the pipeline. + You can pass the callback function in LoadingItems.create or set it later. + !#zh 这个回调函数将在 item 加载结束后被调用。你可以在构造时传递这个回调函数或者是在构造之后直接设置。 + @param completedCount The number of the items that are already completed. + @param totalCount The total number of the items. + @param item The latest item which flow out the pipeline. + + @example + ```js + loadingItems.onProgress = function (completedCount, totalCount, item) { + var progress = (100 * completedCount / totalCount).toFixed(2); + cc.log(progress + '%'); + } + ``` + */ + onProgress(completedCount: number, totalCount: number, item: any): void; + /** + !#en This is a callback which will be invoked while all items is completed, + You can pass the callback function in LoadingItems.create or set it later. + !#zh 该函数将在加载队列全部完成时被调用。你可以在构造时传递这个回调函数或者是在构造之后直接设置。 + @param errors All errored urls will be stored in this array, if no error happened, then it will be null + @param items All items. + + @example + ```js + loadingItems.onComplete = function (errors, items) { + if (error) + cc.log('Completed with ' + errors.length + ' errors'); + else + cc.log('Completed ' + items.totalCount + ' items'); + } + ``` + */ + onComplete(errors: any[], items: LoadingItems): void; + /** !#en The map of all items. + !#zh 存储所有加载项的对象。 */ + map: any; + /** !#en The map of completed items. + !#zh 存储已经完成的加载项。 */ + completed: any; + /** !#en Total count of all items. + !#zh 所有加载项的总数。 */ + totalCount: number; + /** !#en Total count of completed items. + !#zh 所有完成加载项的总数。 */ + completedCount: number; + /** !#en Activated or not. + !#zh 是否启用。 */ + active: boolean; + /** + !#en The constructor function of LoadingItems, this will use recycled LoadingItems in the internal pool if possible. + You can pass onProgress and onComplete callbacks to visualize the loading process. + !#zh LoadingItems 的构造函数,这种构造方式会重用内部对象缓冲池中的 LoadingItems 队列,以尽量避免对象创建。 + 你可以传递 onProgress 和 onComplete 回调函数来获知加载进度信息。 + @param pipeline The pipeline to process the queue. + @param urlList The items array. + @param onProgress The progression callback, refer to {{#crossLink "LoadingItems.onProgress"}}{{/crossLink}} + @param onComplete The completion callback, refer to {{#crossLink "LoadingItems.onComplete"}}{{/crossLink}} + + @example + ```js + cc.LoadingItems.create(cc.loader, ['a.png', 'b.plist'], function (completedCount, totalCount, item) { + var progress = (100 * completedCount / totalCount).toFixed(2); + cc.log(progress + '%'); + }, function (errors, items) { + if (errors) { + for (var i = 0; i < errors.length; ++i) { + cc.log('Error url: ' + errors[i] + ', error: ' + items.getError(errors[i])); + } + } + else { + var result_a = items.getContent('a.png'); + // ... + } + }) + ``` + */ + static create(pipeline: Pipeline, urlList: any[], onProgress: Function, onComplete: Function): LoadingItems; + /** + !#en Retrieve the LoadingItems queue object for an item. + !#zh 通过 item 对象获取它的 LoadingItems 队列。 + @param item The item to query + */ + static getQueue(item: any): LoadingItems; + /** + !#en Complete an item in the LoadingItems queue, please do not call this method unless you know what's happening. + !#zh 通知 LoadingItems 队列一个 item 对象已完成,请不要调用这个函数,除非你知道自己在做什么。 + @param item The item which has completed + */ + static itemComplete(item: any): void; + /** + !#en Add urls to the LoadingItems queue. + !#zh 向一个 LoadingItems 队列添加加载项。 + @param urlList The url list to be appended, the url can be object or string + */ + append(urlList: any[]): any[]; + /** + !#en Complete a LoadingItems queue, please do not call this method unless you know what's happening. + !#zh 完成一个 LoadingItems 队列,请不要调用这个函数,除非你知道自己在做什么。 + */ + allComplete(): void; + /** + !#en Check whether all items are completed. + !#zh 检查是否所有加载项都已经完成。 + */ + isCompleted(): boolean; + /** + !#en Check whether an item is completed. + !#zh 通过 id 检查指定加载项是否已经加载完成。 + @param id The item's id. + */ + isItemCompleted(id: string): boolean; + /** + !#en Check whether an item exists. + !#zh 通过 id 检查加载项是否存在。 + @param id The item's id. + */ + exists(id: string): boolean; + /** + !#en Returns the content of an internal item. + !#zh 通过 id 获取指定对象的内容。 + @param id The item's id. + */ + getContent(id: string): any; + /** + !#en Returns the error of an internal item. + !#zh 通过 id 获取指定对象的错误信息。 + @param id The item's id. + */ + getError(id: string): any; + /** + !#en Add a listener for an item, the callback will be invoked when the item is completed. + !#zh 监听加载项(通过 key 指定)的完成事件。 + @param key key + @param callback can be null + @param target can be null + */ + addListener(key: string, callback: Function, target: any): boolean; + /** + !#en + Check if the specified key has any registered callback. + If a callback is also specified, it will only return true if the callback is registered. + !#zh + 检查指定的加载项是否有完成事件监听器。 + 如果同时还指定了一个回调方法,并且回调有注册,它只会返回 true。 + @param key key + @param callback callback + @param target target + */ + hasListener(key: string, callback?: Function, target?: any): boolean; + /** + !#en + Removes a listener. + It will only remove when key, callback, target all match correctly. + !#zh + 移除指定加载项已经注册的完成事件监听器。 + 只会删除 key, callback, target 均匹配的监听器。 + @param key key + @param callback callback + @param target target + */ + remove(key: string, callback: Function, target: any): boolean; + /** + !#en + Removes all callbacks registered in a certain event + type or all callbacks registered with a certain target. + !#zh 删除指定目标的所有完成事件监听器。 + @param key The event key to be removed or the target to be removed + */ + removeAllListeners(key: string|any): void; + /** + !#en Complete an item in the LoadingItems queue, please do not call this method unless you know what's happening. + !#zh 通知 LoadingItems 队列一个 item 对象已完成,请不要调用这个函数,除非你知道自己在做什么。 + @param id The item url + */ + itemComplete(id: string): void; + /** + !#en Destroy the LoadingItems queue, the queue object won't be garbage collected, it will be recycled, so every after destroy is not reliable. + !#zh 销毁一个 LoadingItems 队列,这个队列对象会被内部缓冲池回收,所以销毁后的所有内部信息都是不可依赖的。 + */ + destroy(): void; + } + /** !#en + A pipeline describes a sequence of manipulations, each manipulation is called a pipe.
+ It's designed for loading process. so items should be urls, and the url will be the identity of each item during the process.
+ A list of items can flow in the pipeline and it will output the results of all pipes.
+ They flow in the pipeline like water in tubes, they go through pipe by pipe separately.
+ Finally all items will flow out the pipeline and the process is finished. + + !#zh + pipeline 描述了一系列的操作,每个操作都被称为 pipe。
+ 它被设计来做加载过程的流程管理。所以 item 应该是 url,并且该 url 将是在处理中的每个 item 的身份标识。
+ 一个 item 列表可以在 pipeline 中流动,它将输出加载项经过所有 pipe 之后的结果。
+ 它们穿过 pipeline 就像水在管子里流动,将会按顺序流过每个 pipe。
+ 最后当所有加载项都流出 pipeline 时,整个加载流程就结束了。 */ + export class Pipeline { + /** + !#en + Constructor, pass an array of pipes to construct a new Pipeline, + the pipes will be chained in the given order.
+ A pipe is an object which must contain an `id` in string and a `handle` function, + the id must be unique in the pipeline.
+ It can also include `async` property to identify whether it's an asynchronous process. + !#zh + 构造函数,通过一系列的 pipe 来构造一个新的 pipeline,pipes 将会在给定的顺序中被锁定。
+ 一个 pipe 就是一个对象,它包含了字符串类型的 ‘id’ 和 ‘handle’ 函数,在 pipeline 中 id 必须是唯一的。
+ 它还可以包括 ‘async’ 属性以确定它是否是一个异步过程。 + @param pipes pipes + + @example + ```js + var pipeline = new Pipeline([ + { + id: 'Downloader', + handle: function (item, callback) {}, + async: true + }, + {id: 'Parser', handle: function (item) {}, async: false} + ]); + ``` + */ + constructor(pipes: any[]); + /** + !#en + Insert a new pipe at the given index of the pipeline.
+ A pipe must contain an `id` in string and a `handle` function, the id must be unique in the pipeline. + !#zh + 在给定的索引位置插入一个新的 pipe。
+ 一个 pipe 必须包含一个字符串类型的 ‘id’ 和 ‘handle’ 函数,该 id 在 pipeline 必须是唯一标识。 + @param pipe The pipe to be inserted + @param index The index to insert + */ + insertPipe(pipe: any, index: number): void; + /** + !#en + Insert a pipe to the end of an existing pipe. The existing pipe must be a valid pipe in the pipeline. + !#zh + 在当前 pipeline 的一个已知 pipe 后面插入一个新的 pipe。 + @param refPipe An existing pipe in the pipeline. + @param newPipe The pipe to be inserted. + */ + insertPipeAfter(refPipe: any, newPipe: any): void; + /** + !#en + Add a new pipe at the end of the pipeline.
+ A pipe must contain an `id` in string and a `handle` function, the id must be unique in the pipeline. + !#zh + 添加一个新的 pipe 到 pipeline 尾部。
+ 该 pipe 必须包含一个字符串类型 ‘id’ 和 ‘handle’ 函数,该 id 在 pipeline 必须是唯一标识。 + @param pipe The pipe to be appended + */ + appendPipe(pipe: any): void; + /** + !#en + Let new items flow into the pipeline.
+ Each item can be a simple url string or an object, + if it's an object, it must contain `id` property.
+ You can specify its type by `type` property, by default, the type is the extension name in url.
+ By adding a `skips` property including pipe ids, you can skip these pipe.
+ The object can contain any supplementary property as you want.
+ !#zh + 让新的 item 流入 pipeline 中。
+ 这里的每个 item 可以是一个简单字符串类型的 url 或者是一个对象, + 如果它是一个对象的话,他必须要包含 ‘id’ 属性。
+ 你也可以指定它的 ‘type’ 属性类型,默认情况下,该类型是 ‘url’ 的后缀名。
+ 也通过添加一个 包含 ‘skips’ 属性的 item 对象,你就可以跳过 skips 中包含的 pipe。
+ 该对象可以包含任何附加属性。 + @param items items + + @example + ```js + pipeline.flowIn([ + 'res/Background.png', + { + id: 'res/scene.json', + type: 'scene', + name: 'scene', + skips: ['Downloader'] + } + ]); + ``` + */ + flowIn(items: any[]): void; + /** + !#en + Copy the item states from one source item to all destination items.
+ It's quite useful when a pipe generate new items from one source item,
+ then you should flowIn these generated items into pipeline,
+ but you probably want them to skip all pipes the source item already go through,
+ you can achieve it with this API.
+
+ For example, an unzip pipe will generate more items, but you won't want them to pass unzip or download pipe again. + !#zh + 从一个源 item 向所有目标 item 复制它的 pipe 状态,用于避免重复通过部分 pipe。
+ 当一个源 item 生成了一系列新的 items 时很有用,
+ 你希望让这些新的依赖项进入 pipeline,但是又不希望它们通过源 item 已经经过的 pipe,
+ 但是你可能希望他们源 item 已经通过并跳过所有 pipes,
+ 这个时候就可以使用这个 API。 + @param srcItem The source item + @param dstItems A single destination item or an array of destination items + */ + copyItemStates(srcItem: any, dstItems: any[]|any): void; + /** + !#en Returns an item in pipeline. + !#zh 根据 id 获取一个 item + @param id The id of the item + */ + getItem(id: any): any; + /** + !#en Removes an completed item in pipeline. + It will only remove the cache in the pipeline or loader, its dependencies won't be released. + cc.loader provided another method to completely cleanup the resource and its dependencies, + please refer to {{#crossLink "loader/release:method"}}cc.loader.release{{/crossLink}} + !#zh 移除指定的已完成 item。 + 这将仅仅从 pipeline 或者 loader 中删除其缓存,并不会释放它所依赖的资源。 + cc.loader 中提供了另一种删除资源及其依赖的清理方法,请参考 {{#crossLink "loader/release:method"}}cc.loader.release{{/crossLink}} + @param id The id of the item + */ + removeItem(id: any): boolean; + /** + !#en Clear the current pipeline, this function will clean up the items. + !#zh 清空当前 pipeline,该函数将清理 items。 + */ + clear(): void; + } + /** undefined */ + export class WorldManifold { + /** !#en + world contact point (point of intersection) + !#zh + 碰撞点集合 */ + points: Vec2[]; + /** !#en + world vector pointing from A to B + !#zh + 世界坐标系下由 A 指向 B 的向量 */ + normal: Vec2; + } + /** !#en + A manifold point is a contact point belonging to a contact manifold. + It holds details related to the geometry and dynamics of the contact points. + Note: the impulses are used for internal caching and may not + provide reliable contact forces, especially for high speed collisions. + !#zh + ManifoldPoint 是接触信息中的接触点信息。它拥有关于几何和接触点的详细信息。 + 注意:信息中的冲量用于系统内部缓存,提供的接触力可能不是很准确,特别是高速移动中的碰撞信息。 */ + export class ManifoldPoint { + /** !#en + The local point usage depends on the manifold type: + -e_circles: the local center of circleB + -e_faceA: the local center of circleB or the clip point of polygonB + -e_faceB: the clip point of polygonA + !#zh + 本地坐标点的用途取决于 manifold 的类型 + - e_circles: circleB 的本地中心点 + - e_faceA: circleB 的本地中心点 或者是 polygonB 的截取点 + - e_faceB: polygonB 的截取点 */ + localPoint: Vec2; + /** !#en + Normal impulse. + !#zh + 法线冲量。 */ + normalImpulse: number; + /** !#en + Tangent impulse. + !#zh + 切线冲量。 */ + tangentImpulse: number; + } + /** undefined */ + export class Manifold { + /** !#en + Manifold type : 0: e_circles, 1: e_faceA, 2: e_faceB + !#zh + Manifold 类型 : 0: e_circles, 1: e_faceA, 2: e_faceB */ + type: number; + /** !#en + The local point usage depends on the manifold type: + -e_circles: the local center of circleA + -e_faceA: the center of faceA + -e_faceB: the center of faceB + !#zh + 用途取决于 manifold 类型 + -e_circles: circleA 的本地中心点 + -e_faceA: faceA 的本地中心点 + -e_faceB: faceB 的本地中心点 */ + localPoint: Vec2; + /** !#en + -e_circles: not used + -e_faceA: the normal on polygonA + -e_faceB: the normal on polygonB + !#zh + -e_circles: 没被使用到 + -e_faceA: polygonA 的法向量 + -e_faceB: polygonB 的法向量 */ + localNormal: Vec2; + /** !#en + the points of contact. + !#zh + 接触点信息。 */ + points: ManifoldPoint[]; + } + /** !#en + Contact impulses for reporting. + !#zh + 用于返回给回调的接触冲量。 */ + export class PhysicsImpulse { + /** !#en + Normal impulses. + !#zh + 法线方向的冲量 */ + normalImpulses: any; + /** !#en + Tangent impulses + !#zh + 切线方向的冲量 */ + tangentImpulses: any; + } + /** !#en + PhysicsContact will be generated during begin and end collision as a parameter of the collision callback. + Note that contacts will be reused for speed up cpu time, so do not cache anything in the contact. + !#zh + 物理接触会在开始和结束碰撞之间生成,并作为参数传入到碰撞回调函数中。 + 注意:传入的物理接触会被系统进行重用,所以不要在使用中缓存里面的任何信息。 */ + export class PhysicsContact { + /** + !#en + Get the world manifold. + !#zh + 获取世界坐标系下的碰撞信息。 + */ + getWorldManifold(): WorldManifold; + /** + !#en + Get the manifold. + !#zh + 获取本地(局部)坐标系下的碰撞信息。 + */ + getManifold(): Manifold; + /** + !#en + Get the impulses. + Note: PhysicsImpulse can only used in onPostSolve callback. + !#zh + 获取冲量信息 + 注意:这个信息只有在 onPostSolve 回调中才能获取到 + */ + getImpulse(): PhysicsImpulse; + colliderA: Collider; + colliderB: Collider; + /** !#en + If set disabled to true, the contact will be ignored until contact end. + If you just want to disabled contact for current time step or sub-step, please use disabledOnce. + !#zh + 如果 disabled 被设置为 true,那么直到接触结束此接触都将被忽略。 + 如果只是希望在当前时间步或子步中忽略此接触,请使用 disabledOnce 。 */ + disabled: boolean; + /** !#en + Disabled contact for current time step or sub-step. + !#zh + 在当前时间步或子步中忽略此接触。 */ + disabledOnce: boolean; + /** + !#en + Is this contact touching? + !#zh + 返回碰撞体是否已经接触到。 + */ + isTouching(): boolean; + /** + !#en + Set the desired tangent speed for a conveyor belt behavior. + !#zh + 为传送带设置期望的切线速度 + @param tangentSpeed tangentSpeed + */ + setTangentSpeed(tangentSpeed: number): void; + /** + !#en + Get the desired tangent speed. + !#zh + 获取切线速度 + */ + getTangentSpeed(): number; + /** + !#en + Override the default friction mixture. You can call this in onPreSolve callback. + !#zh + 覆盖默认的摩擦力系数。你可以在 onPreSolve 回调中调用此函数。 + @param friction friction + */ + setFriction(friction: number): void; + /** + !#en + Get the friction. + !#zh + 获取当前摩擦力系数 + */ + getFriction(): number; + /** + !#en + Reset the friction mixture to the default value. + !#zh + 重置摩擦力系数到默认值 + */ + resetFriction(): void; + /** + !#en + Override the default restitution mixture. You can call this in onPreSolve callback. + !#zh + 覆盖默认的恢复系数。你可以在 onPreSolve 回调中调用此函数。 + @param restitution restitution + */ + setRestitution(restitution: number): void; + /** + !#en + Get the restitution. + !#zh + 获取当前恢复系数 + */ + getRestitution(): number; + /** + !#en + Reset the restitution mixture to the default value. + !#zh + 重置恢复系数到默认值 + */ + resetRestitution(): void; + } + /** !#en + Physics manager uses box2d as the inner physics system, and hide most box2d implement details(creating rigidbody, synchronize rigidbody info to node). + You can visit some common box2d function through physics manager(hit testing, raycast, debug info). + Physics manager distributes the collision information to each collision callback when collision is produced. + Note: You need first enable the collision listener in the rigidbody. + !#zh + 物理系统将 box2d 作为内部物理系统,并且隐藏了大部分 box2d 实现细节(比如创建刚体,同步刚体信息到节点中等)。 + 你可以通过物理系统访问一些 box2d 常用的功能,比如点击测试,射线测试,设置测试信息等。 + 物理系统还管理碰撞信息的分发,她会在产生碰撞时,将碰撞信息分发到各个碰撞回调中。 + 注意:你需要先在刚体中开启碰撞接听才会产生相应的碰撞回调。
+ 支持的物理系统指定绘制信息事件,请参阅 {{#crossLink "PhysicsManager.DrawBits"}}{{/crossLink}} */ + export class PhysicsManager implements EventTarget { + /** !#en + The ratio transform between physics unit and pixel unit, generally is 32. + !#zh + 物理单位与像素单位互相转换的比率,一般是 32。 */ + static PTM_RATIO: number; + /** !#en + The velocity iterations for the velocity constraint solver. + !#zh + 速度更新迭代数 */ + static VELOCITY_ITERATIONS: number; + /** !#en + The position Iterations for the position constraint solver. + !#zh + 位置迭代更新数 */ + static POSITION_ITERATIONS: number; + /** !#en + Specify the fixed time step. + Need enabledAccumulator to make it work. + !#zh + 指定固定的物理更新间隔时间,需要开启 enabledAccumulator 才有效。 */ + static FIXED_TIME_STEP: number; + /** !#en + Specify the max accumulator time. + Need enabledAccumulator to make it work. + !#zh + 每次可用于更新物理系统的最大时间,需要开启 enabledAccumulator 才有效。 */ + static MAX_ACCUMULATOR: number; + /** !#en + If enabled accumulator, then will call step function with the fixed time step FIXED_TIME_STEP. + And if the update dt is bigger than the time step, then will call step function several times. + If disabled accumulator, then will call step function with a time step calculated with the frame rate. + !#zh + 如果开启此选项,那么将会以固定的间隔时间 FIXED_TIME_STEP 来更新物理引擎,如果一个 update 的间隔时间大于 FIXED_TIME_STEP,则会对物理引擎进行多次更新。 + 如果关闭此选项,那么将会根据设定的 frame rate 计算出一个间隔时间来更新物理引擎。 */ + enabledAccumulator: boolean; + /** + !#en + Test which collider contains the given world point + !#zh + 获取包含给定世界坐标系点的碰撞体 + @param point the world point + */ + testPoint(point: Vec2): PhysicsCollider; + /** + !#en + Test which colliders intersect the given world rect + !#zh + 获取与给定世界坐标系矩形相交的碰撞体 + @param rect the world rect + */ + testAABB(rect: Rect): PhysicsCollider[]; + /** + !#en + Raycast the world for all colliders in the path of the ray. + The raycast ignores colliders that contain the starting point. + !#zh + 检测哪些碰撞体在给定射线的路径上,射线检测将忽略包含起始点的碰撞体。 + @param p1 start point of the raycast + @param p2 end point of the raycast + @param type optional, default is RayCastType.Closest + */ + rayCast(p1: Vec2, p2: Vec2, type: RayCastType): PhysicsRayCastResult[]; + /** !#en + Enabled the physics manager? + !#zh + 指定是否启用物理系统? */ + enabled: boolean; + /** !#en + Debug draw flags. + !#zh + 设置调试绘制标志 */ + debugDrawFlags: number; + /** !#en + The physics world gravity. + !#zh + 物理世界重力值 */ + gravity: Vec2; + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en + Register an callback of a specific event type on the EventTarget. + This type of event should be triggered via `emit`. + !#zh + 注册事件目标的特定事件类型回调。这种类型的事件应该被 `emit` 触发。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, node); + ``` + */ + on(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. + !#zh + 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + + @example + ```js + // register fire eventListener + var callback = eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, target); + // remove fire event listener + eventTarget.off('fire', callback, target); + // remove all fire event listeners + eventTarget.off('fire'); + ``` + */ + off(type: string, callback?: Function, target?: any): void; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.once('fire', function () { + cc.log("this is the callback and will be invoked only once"); + }, node); + ``` + */ + once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; + /** + !#en + Send an event with the event object. + !#zh + 通过事件对象派发事件 + @param event event + */ + dispatchEvent(event: Event): void; + } + /** undefined */ + export class PhysicsRayCastResult { + /** !#en + The PhysicsCollider which intersects with the raycast + !#zh + 与射线相交的碰撞体 */ + collider: PhysicsCollider; + /** !#en + The intersection point + !#zh + 射线与碰撞体相交的点 */ + point: Vec2; + /** !#en + The normal vector at the point of intersection + !#zh + 射线与碰撞体相交的点的法向量 */ + normal: Vec2; + /** !#en + The fraction of the raycast path at the point of intersection + !#zh + 射线与碰撞体相交的点占射线长度的分数 */ + fraction: number; + } + /** !#en Enum for RigidBodyType. + !#zh 刚体类型 */ + export enum RigidBodyType { + Static = 0, + Kinematic = 0, + Dynamic = 0, + Animated = 0, + } + /** !#en Enum for RayCastType. + !#zh 射线检测类型 */ + export enum RayCastType { + Closest = 0, + Any = 0, + AllClosest = 0, + All = 0, + } + /** undefined */ + export class RigidBody extends Component { + /** !#en + Should enabled contact listener? + When a collision is trigger, the collision callback will only be called when enabled contact listener. + !#zh + 是否启用接触接听器。 + 当 collider 产生碰撞时,只有开启了接触接听器才会调用相应的回调函数 */ + enabledContactListener: boolean; + /** + !#en + Collision callback. + Called when two collider begin to touch. + !#zh + 碰撞回调。 + 如果你的脚本中实现了这个函数,那么它将会在两个碰撞体开始接触时被调用。 + @param contact contact information + @param selfCollider the collider belong to this rigidbody + @param otherCollider the collider belong to another rigidbody + */ + onBeginContact(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void; + /** + !#en + Collision callback. + Called when two collider cease to touch. + !#zh + 碰撞回调。 + 如果你的脚本中实现了这个函数,那么它将会在两个碰撞体停止接触时被调用。 + @param contact contact information + @param selfCollider the collider belong to this rigidbody + @param otherCollider the collider belong to another rigidbody + */ + onEndContact(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void; + /** + !#en + Collision callback. + This is called when a contact is updated. + This allows you to inspect a contact before it goes to the solver(e.g. disable contact). + Note: this is called only for awake bodies. + Note: this is called even when the number of contact points is zero. + Note: this is not called for sensors. + !#zh + 碰撞回调。 + 如果你的脚本中实现了这个函数,那么它将会在接触更新时被调用。 + 你可以在接触被处理前根据他包含的信息作出相应的处理,比如将这个接触禁用掉。 + 注意:回调只会为醒着的刚体调用。 + 注意:接触点为零的时候也有可能被调用。 + 注意:感知体(sensor)的回调不会被调用。 + @param contact contact information + @param selfCollider the collider belong to this rigidbody + @param otherCollider the collider belong to another rigidbody + */ + onPreSolve(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void; + /** + !#en + Collision callback. + This is called after a contact is updated. + You can get the impulses from the contact in this callback. + !#zh + 碰撞回调。 + 如果你的脚本中实现了这个函数,那么它将会在接触更新完后被调用。 + 你可以在这个回调中从接触信息中获取到冲量信息。 + @param contact contact information + @param selfCollider the collider belong to this rigidbody + @param otherCollider the collider belong to another rigidbody + */ + onPostSolve(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void; + /** !#en + Is this a fast moving body that should be prevented from tunneling through + other moving bodies? + Note : + - All bodies are prevented from tunneling through kinematic and static bodies. This setting is only considered on dynamic bodies. + - You should use this flag sparingly since it increases processing time. + !#zh + 这个刚体是否是一个快速移动的刚体,并且需要禁止穿过其他快速移动的刚体? + 需要注意的是 : + - 所有刚体都被禁止从 运动刚体 和 静态刚体 中穿过。此选项只关注于 动态刚体。 + - 应该尽量少的使用此选项,因为它会增加程序处理时间。 */ + bullet: boolean; + /** !#en + Rigidbody type : Static, Kinematic, Dynamic or Animated. + !#zh + 刚体类型: Static, Kinematic, Dynamic or Animated. */ + type: RigidBodyType; + /** !#en + Set this flag to false if this body should never fall asleep. + Note that this increases CPU usage. + !#zh + 如果此刚体永远都不应该进入睡眠,那么设置这个属性为 false。 + 需要注意这将使 CPU 占用率提高。 */ + allowSleep: boolean; + /** !#en + Scale the gravity applied to this body. + !#zh + 缩放应用在此刚体上的重力值 */ + gravityScale: number; + /** !#en + Linear damping is use to reduce the linear velocity. + The damping parameter can be larger than 1, but the damping effect becomes sensitive to the + time step when the damping parameter is large. + !#zh + Linear damping 用于衰减刚体的线性速度。衰减系数可以大于 1,但是当衰减系数比较大的时候,衰减的效果会变得比较敏感。 */ + linearDamping: number; + /** !#en + Angular damping is use to reduce the angular velocity. The damping parameter + can be larger than 1 but the damping effect becomes sensitive to the + time step when the damping parameter is large. + !#zh + Angular damping 用于衰减刚体的角速度。衰减系数可以大于 1,但是当衰减系数比较大的时候,衰减的效果会变得比较敏感。 */ + angularDamping: number; + /** !#en + The linear velocity of the body's origin in world co-ordinates. + !#zh + 刚体在世界坐标下的线性速度 */ + linearVelocity: Vec2; + /** !#en + The angular velocity of the body. + !#zh + 刚体的角速度 */ + angularVelocity: number; + /** !#en + Should this body be prevented from rotating? + !#zh + 是否禁止此刚体进行旋转 */ + fixedRotation: boolean; + /** !#en + Set the sleep state of the body. A sleeping body has very low CPU cost.(When the rigid body is hit, if the rigid body is in sleep state, it will be immediately awakened.) + !#zh + 设置刚体的睡眠状态。 睡眠的刚体具有非常低的 CPU 成本。(当刚体被碰撞到时,如果刚体处于睡眠状态,它会立即被唤醒) */ + awake: boolean; + /** !#en + Whether to wake up this rigid body during initialization + !#zh + 是否在初始化时唤醒此刚体 */ + awakeOnLoad: boolean; + /** !#en + Set the active state of the body. An inactive body is not + simulated and cannot be collided with or woken up. + If body is active, all fixtures will be added to the + broad-phase. + If body is inactive, all fixtures will be removed from + the broad-phase and all contacts will be destroyed. + Fixtures on an inactive body are implicitly inactive and will + not participate in collisions, ray-casts, or queries. + Joints connected to an inactive body are implicitly inactive. + !#zh + 设置刚体的激活状态。一个非激活状态下的刚体是不会被模拟和碰撞的,不管它是否处于睡眠状态下。 + 如果刚体处于激活状态下,所有夹具会被添加到 粗测阶段(broad-phase)。 + 如果刚体处于非激活状态下,所有夹具会被从 粗测阶段(broad-phase)中移除。 + 在非激活状态下的夹具不会参与到碰撞,射线,或者查找中 + 链接到非激活状态下刚体的关节也是非激活的。 */ + active: boolean; + /** + !#en + Gets a local point relative to the body's origin given a world point. + !#zh + 将一个给定的世界坐标系下的点转换为刚体本地坐标系下的点 + @param worldPoint a point in world coordinates. + @param out optional, the receiving point + */ + getLocalPoint(worldPoint: Vec2, out: Vec2): Vec2; + /** + !#en + Get the world coordinates of a point given the local coordinates. + !#zh + 将一个给定的刚体本地坐标系下的点转换为世界坐标系下的点 + @param localPoint a point in local coordinates. + @param out optional, the receiving point + */ + getWorldPoint(localPoint: Vec2, out: Vec2): Vec2; + /** + !#en + Get the world coordinates of a vector given the local coordinates. + !#zh + 将一个给定的世界坐标系下的向量转换为刚体本地坐标系下的向量 + @param localVector a vector in world coordinates. + @param out optional, the receiving vector + */ + getWorldVector(localVector: Vec2, out: Vec2): Vec2; + /** + !#en + Gets a local vector relative to the body's origin given a world vector. + !#zh + 将一个给定的世界坐标系下的点转换为刚体本地坐标系下的点 + @param worldVector a vector in world coordinates. + @param out optional, the receiving vector + */ + getLocalVector(worldVector: Vec2, out: Vec2): Vec2; + /** + !#en + Get the world body origin position. + !#zh + 获取刚体世界坐标系下的原点值 + @param out optional, the receiving point + */ + getWorldPosition(out: Vec2): Vec2; + /** + !#en + Get the world body rotation angle. + !#zh + 获取刚体世界坐标系下的旋转值。 + */ + getWorldRotation(): number; + /** + !#en + Get the local position of the center of mass. + !#zh + 获取刚体本地坐标系下的质心 + */ + getLocalCenter(): Vec2; + /** + !#en + Get the world position of the center of mass. + !#zh + 获取刚体世界坐标系下的质心 + */ + getWorldCenter(): Vec2; + /** + !#en + Get the world linear velocity of a world point attached to this body. + !#zh + 获取刚体上指定点的线性速度 + @param worldPoint a point in world coordinates. + @param out optional, the receiving point + */ + getLinearVelocityFromWorldPoint(worldPoint: Vec2, out: Vec2): Vec2; + /** + !#en + Get total mass of the body. + !#zh + 获取刚体的质量。 + */ + getMass(): number; + /** + !#en + Get the rotational inertia of the body about the local origin. + !#zh + 获取刚体本地坐标系下原点的旋转惯性 + */ + getInertia(): number; + /** + !#en + Get all the joints connect to the rigidbody. + !#zh + 获取链接到此刚体的所有关节 + */ + getJointList(): Joint[]; + /** + !#en + Apply a force at a world point. If the force is not + applied at the center of mass, it will generate a torque and + affect the angular velocity. + !#zh + 施加一个力到刚体上的一个点。如果力没有施加到刚体的质心上,还会产生一个扭矩并且影响到角速度。 + @param force the world force vector. + @param point the world position. + @param wake also wake up the body. + */ + applyForce(force: Vec2, point: Vec2, wake: boolean): void; + /** + !#en + Apply a force to the center of mass. + !#zh + 施加一个力到刚体上的质心上。 + @param force the world force vector. + @param wake also wake up the body. + */ + applyForceToCenter(force: Vec2, wake: boolean): void; + /** + !#en + Apply a torque. This affects the angular velocity. + !#zh + 施加一个扭矩力,将影响刚体的角速度 + @param torque about the z-axis (out of the screen), usually in N-m. + @param wake also wake up the body + */ + applyTorque(torque: number, wake: boolean): void; + /** + !#en + Apply a impulse at a world point, This immediately modifies the velocity. + If the impulse is not applied at the center of mass, it will generate a torque and + affect the angular velocity. + !#zh + 施加冲量到刚体上的一个点,将立即改变刚体的线性速度。 + 如果冲量施加到的点不是刚体的质心,那么将产生一个扭矩并影响刚体的角速度。 + @param impulse the world impulse vector, usually in N-seconds or kg-m/s. + @param point the world position + @param wake alse wake up the body + */ + applyLinearImpulse(impulse: Vec2, point: Vec2, wake: boolean): void; + /** + !#en + Apply an angular impulse. + !#zh + 施加一个角速度冲量。 + @param impulse the angular impulse in units of kg*m*m/s + @param wake also wake up the body + */ + applyAngularImpulse(impulse: number, wake: boolean): void; + /** + !#en + Synchronize node's world position to box2d rigidbody's position. + If enableAnimated is true and rigidbody's type is Animated type, + will set linear velocity instead of directly set rigidbody's position. + !#zh + 同步节点的世界坐标到 box2d 刚体的坐标上。 + 如果 enableAnimated 是 true,并且刚体的类型是 Animated ,那么将设置刚体的线性速度来代替直接设置刚体的位置。 + @param enableAnimated enableAnimated + */ + syncPosition(enableAnimated: boolean): void; + /** + !#en + Synchronize node's world angle to box2d rigidbody's angle. + If enableAnimated is true and rigidbody's type is Animated type, + will set angular velocity instead of directly set rigidbody's angle. + !#zh + 同步节点的世界旋转角度值到 box2d 刚体的旋转值上。 + 如果 enableAnimated 是 true,并且刚体的类型是 Animated ,那么将设置刚体的角速度来代替直接设置刚体的角度。 + @param enableAnimated enableAnimated + */ + syncRotation(enableAnimated: boolean): void; + } + /** !#en Mesh Asset. + !#zh 网格资源。 */ + export class Mesh extends Asset implements EventTarget { + /** !#en Get ir set the sub meshes. + !#zh 设置或者获取子网格。 */ + subMeshes: InputAssembler[]; + /** + !#en + Init vertex buffer according to the vertex format. + !#zh + 根据顶点格式初始化顶点内存。 + @param vertexFormat vertex format + @param vertexCount how much vertex should be create in this buffer. + @param dynamic whether or not to use dynamic buffer. + @param index index + */ + init(vertexFormat: gfx.VertexFormat, vertexCount: number, dynamic?: boolean, index?: boolean): void; + /** + !#en + Set the vertex values. + !#zh + 设置顶点数据 + @param name the attribute name, e.g. gfx.ATTR_POSITION + @param values the vertex values + */ + setVertices(name: string, values: Vec2[]|Vec3[]|Color[]|number[]|Uint8Array|Float32Array): void; + /** + !#en + Set the sub mesh indices. + !#zh + 设置子网格索引。 + @param indices the sub mesh indices. + @param index sub mesh index. + @param dynamic whether or not to use dynamic buffer. + */ + setIndices(indices: number[]|Uint16Array|Uint8Array, index?: number, dynamic?: boolean): void; + /** + !#en + Set the sub mesh primitive type. + !#zh + 设置子网格绘制线条的方式。 + @param type type + @param index index + */ + setPrimitiveType(type: number, index: number): void; + /** + !#en + Clear the buffer data. + !#zh + 清除网格创建的内存数据。 + */ + clear(): void; + /** + !#en Set mesh bounding box + !#zh 设置网格的包围盒 + @param min min + @param max max + */ + setBoundingBox(min: Vec3, max: Vec3): void; + /** + !#en Read the specified attributes of the subgrid into the target buffer. + !#zh 读取子网格的指定属性到目标缓冲区中。 + @param primitiveIndex The subgrid index. + @param attributeName attribute name. + @param buffer The target buffer. + @param stride The byte interval between adjacent attributes in the target buffer. + @param offset The offset of the first attribute in the target buffer. + */ + copyAttribute(primitiveIndex: number, attributeName: string, buffer: ArrayBuffer, stride: number, offset: number): boolean; + /** + !#en Read the index data of the subgrid into the target array. + !#zh 读取子网格的索引数据到目标数组中。 + @param primitiveIndex The subgrid index. + @param outputArray The target array. + */ + copyIndices(primitiveIndex: number, outputArray: DataView): boolean; + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en + Register an callback of a specific event type on the EventTarget. + This type of event should be triggered via `emit`. + !#zh + 注册事件目标的特定事件类型回调。这种类型的事件应该被 `emit` 触发。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, node); + ``` + */ + on(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. + !#zh + 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + + @example + ```js + // register fire eventListener + var callback = eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, target); + // remove fire event listener + eventTarget.off('fire', callback, target); + // remove all fire event listeners + eventTarget.off('fire'); + ``` + */ + off(type: string, callback?: Function, target?: any): void; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.once('fire', function () { + cc.log("this is the callback and will be invoked only once"); + }, node); + ``` + */ + once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; + /** + !#en + Send an event with the event object. + !#zh + 通过事件对象派发事件 + @param event event + */ + dispatchEvent(event: Event): void; + } + /** !#en + Mesh Renderer Component + !#zh + 网格渲染组件 */ + export class MeshRenderer extends RenderComponent { + /** !#en + The mesh which the renderer uses. + !#zh + 设置使用的网格 */ + mesh: Mesh; + /** !#en + Whether the mesh should receive shadows. + !#zh + 网格是否接受光源投射的阴影 */ + receiveShadows: boolean; + /** !#en + Shadow Casting Mode + !#zh + 网格投射阴影的模式 */ + shadowCastingMode: MeshRenderer.ShadowCastingMode; + /** !#en + Enable auto merge mesh, only support when mesh's VertexFormat, PrimitiveType, materials are all the same + !#zh + 开启自动合并 mesh 功能,只有在网格的 顶点格式,PrimitiveType, 使用的材质 都一致的情况下才会有效 */ + enableAutoBatch: boolean; + } + /** !#en The renderer object which provide access to render system APIs, + detailed APIs will be available progressively. + !#zh 提供基础渲染接口的渲染器对象,渲染层的基础接口将逐步开放给用户 */ + export class renderer { + /** !#en The render engine is available only after cc.game.EVENT_ENGINE_INITED event.
+ Normally it will be inited as the webgl render engine, but in wechat open context domain, + it will be inited as the canvas render engine. Canvas render engine is no longer available for other use case since v2.0. + !#zh 基础渲染引擎对象只在 cc.game.EVENT_ENGINE_INITED 事件触发后才可获取。
+ 大多数情况下,它都会是 WebGL 渲染引擎实例,但是在微信开放数据域当中,它会是 Canvas 渲染引擎实例。请注意,从 2.0 开始,我们在其他平台和环境下都废弃了 Canvas 渲染器。 */ + static renderEngine: any; + /** !#en The total draw call count in last rendered frame. + !#zh 上一次渲染帧所提交的渲染批次总数。 */ + static drawCalls: number; + } + /** !#en The module provides utilities for working with file and directory paths + !#zh 用于处理文件与目录的路径的模块 */ + export class path { + /** + !#en Join strings to be a path. + !#zh 拼接字符串为 Path + + @example + ```js + ------------------------------ + cc.path.join("a", "b.png"); //-->"a/b.png" + cc.path.join("a", "b", "c.png"); //-->"a/b/c.png" + cc.path.join("a", "b"); //-->"a/b" + cc.path.join("a", "b", "/"); //-->"a/b/" + cc.path.join("a", "b/", "/"); //-->"a/b/" + + ``` + */ + static join(): string; + /** + !#en Get the ext name of a path including '.', like '.png'. + !#zh 返回 Path 的扩展名,包括 '.',例如 '.png'。 + @param pathStr pathStr + + @example + ```js + --------------------------- + cc.path.extname("a/b.png"); //-->".png" + cc.path.extname("a/b.png?a=1&b=2"); //-->".png" + cc.path.extname("a/b"); //-->null + cc.path.extname("a/b?a=1&b=2"); //-->null + + ``` + */ + static extname(pathStr: string): any; + /** + !#en Get the main name of a file name + !#zh 获取文件名的主名称 + @param fileName fileName + */ + static mainFileName(fileName: string): string; + /** + !#en Get the file name of a file path. + !#zh 获取文件路径的文件名。 + @param pathStr pathStr + @param extname extname + + @example + ```js + --------------------------------- + cc.path.basename("a/b.png"); //-->"b.png" + cc.path.basename("a/b.png?a=1&b=2"); //-->"b.png" + cc.path.basename("a/b.png", ".png"); //-->"b" + cc.path.basename("a/b.png?a=1&b=2", ".png"); //-->"b" + cc.path.basename("a/b.png", ".txt"); //-->"b.png" + + ``` + */ + static basename(pathStr: string, extname?: string): any; + /** + !#en Get dirname of a file path. + !#zh 获取文件路径的目录名。 + @param pathStr pathStr + + @example + ```js + --------------------------------- + * unix + cc.path.driname("a/b/c.png"); //-->"a/b" + cc.path.driname("a/b/c.png?a=1&b=2"); //-->"a/b" + cc.path.dirname("a/b/"); //-->"a/b" + cc.path.dirname("c.png"); //-->"" + * windows + cc.path.driname("a\\b\\c.png"); //-->"a\b" + cc.path.driname("a\\b\\c.png?a=1&b=2"); //-->"a\b" + + ``` + */ + static dirname(pathStr: string): any; + /** + !#en Change extname of a file path. + !#zh 更改文件路径的扩展名。 + @param pathStr pathStr + @param extname extname + + @example + ```js + --------------------------------- + cc.path.changeExtname("a/b.png", ".plist"); //-->"a/b.plist" + cc.path.changeExtname("a/b.png?a=1&b=2", ".plist"); //-->"a/b.plist?a=1&b=2" + + ``` + */ + static changeExtname(pathStr: string, extname?: string): string; + } + /** !#en + AffineTransform class represent an affine transform matrix. It's composed basically by translation, rotation, scale transformations.
+ !#zh + AffineTransform 类代表一个仿射变换矩阵。它基本上是由平移旋转,缩放转变所组成。
*/ + export class AffineTransform { + /** + !#en Create a AffineTransform object with all contents in the matrix. + !#zh 用在矩阵中的所有内容创建一个 AffineTransform 对象。 + @param a a + @param b b + @param c c + @param d d + @param tx tx + @param ty ty + */ + static create(a: number, b: number, c: number, d: number, tx: number, ty: number): AffineTransform; + /** + !#en + Create a identity transformation matrix:
+ [ 1, 0, 0,
+ 0, 1, 0 ] + !#zh + 单位矩阵:
+ [ 1, 0, 0,
+ 0, 1, 0 ] + */ + static identity(): AffineTransform; + /** + !#en Clone a AffineTransform object from the specified transform. + !#zh 克隆指定的 AffineTransform 对象。 + @param t t + */ + static clone(t: AffineTransform): AffineTransform; + /** + !#en + Concatenate a transform matrix to another + The results are reflected in the out affine transform + out = t1 * t2 + This function is memory free, you should create the output affine transform by yourself and manage its memory. + !#zh + 拼接两个矩阵,将结果保存到 out 矩阵。这个函数不创建任何内存,你需要先创建 AffineTransform 对象用来存储结果,并作为第一个参数传入函数。 + out = t1 * t2 + @param out Out object to store the concat result + @param t1 The first transform object. + @param t2 The transform object to concatenate. + */ + static concat(out: AffineTransform, t1: AffineTransform, t2: AffineTransform): AffineTransform; + /** + !#en Get the invert transform of an AffineTransform object. + This function is memory free, you should create the output affine transform by yourself and manage its memory. + !#zh 求逆矩阵。这个函数不创建任何内存,你需要先创建 AffineTransform 对象用来存储结果,并作为第一个参数传入函数。 + @param out out + @param t t + */ + static invert(out: AffineTransform, t: AffineTransform): AffineTransform; + /** + !#en Get an AffineTransform object from a given matrix 4x4. + This function is memory free, you should create the output affine transform by yourself and manage its memory. + !#zh 从一个 4x4 Matrix 获取 AffineTransform 对象。这个函数不创建任何内存,你需要先创建 AffineTransform 对象用来存储结果,并作为第一个参数传入函数。 + @param out out + @param mat mat + */ + static invert(out: AffineTransform, mat: Mat4): AffineTransform; + /** + !#en Apply the affine transformation on a point. + This function is memory free, you should create the output Vec2 by yourself and manage its memory. + !#zh 对一个点应用矩阵变换。这个函数不创建任何内存,你需要先创建一个 Vec2 对象用来存储结果,并作为第一个参数传入函数。 + @param out The output point to store the result + @param point Point to apply transform or x. + @param transOrY transform matrix or y. + @param t transform matrix. + */ + static transformVec2(out: Vec2, point: Vec2|number, transOrY: AffineTransform|number, t?: AffineTransform): Vec2; + /** + !#en Apply the affine transformation on a size. + This function is memory free, you should create the output Size by yourself and manage its memory. + !#zh 应用仿射变换矩阵到 Size 上。这个函数不创建任何内存,你需要先创建一个 Size 对象用来存储结果,并作为第一个参数传入函数。 + @param out The output point to store the result + @param size size + @param t t + */ + static transformSize(out: Size, size: Size, t: AffineTransform): Size; + /** + !#en Apply the affine transformation on a rect. + This function is memory free, you should create the output Rect by yourself and manage its memory. + !#zh 应用仿射变换矩阵到 Rect 上。这个函数不创建任何内存,你需要先创建一个 Rect 对象用来存储结果,并作为第一个参数传入函数。 + @param out out + @param rect rect + @param anAffineTransform anAffineTransform + */ + static transformRect(out: Rect, rect: Rect, anAffineTransform: AffineTransform): Rect; + /** + !#en Apply the affine transformation on a rect, and truns to an Oriented Bounding Box. + This function is memory free, you should create the output vectors by yourself and manage their memory. + !#zh 应用仿射变换矩阵到 Rect 上, 并转换为有向包围盒。这个函数不创建任何内存,你需要先创建包围盒的四个 Vector 对象用来存储结果,并作为前四个参数传入函数。 + @param out_bl out_bl + @param out_tl out_tl + @param out_tr out_tr + @param out_br out_br + @param rect rect + @param anAffineTransform anAffineTransform + */ + static transformObb(out_bl: Vec2, out_tl: Vec2, out_tr: Vec2, out_br: Vec2, rect: Rect, anAffineTransform: AffineTransform): void; + } + /** A base node for CCNode, it will: + - maintain scene hierarchy and active logic + - notifications if some properties changed + - define some interfaces shares between CCNode + - define machanisms for Enity Component Systems + - define prefab and serialize functions */ + export class _BaseNode extends Object implements EventTarget { + /** !#en Name of node. + !#zh 该节点名称。 */ + name: string; + /** !#en The uuid for editor, will be stripped before building project. + !#zh 主要用于编辑器的 uuid,在编辑器下可用于持久化存储,在项目构建之后将变成自增的 id。 */ + uuid: string; + /** !#en All children nodes. + !#zh 节点的所有子节点。 */ + children: Node[]; + /** !#en All children nodes. + !#zh 节点的子节点数量。 */ + childrenCount: number; + /** !#en + The local active state of this node.
+ Note that a Node may be inactive because a parent is not active, even if this returns true.
+ Use {{#crossLink "Node/activeInHierarchy:property"}}{{/crossLink}} if you want to check if the Node is actually treated as active in the scene. + !#zh + 当前节点的自身激活状态。
+ 值得注意的是,一个节点的父节点如果不被激活,那么即使它自身设为激活,它仍然无法激活。
+ 如果你想检查节点在场景中实际的激活状态可以使用 {{#crossLink "Node/activeInHierarchy:property"}}{{/crossLink}}。 */ + active: boolean; + /** !#en Indicates whether this node is active in the scene. + !#zh 表示此节点是否在场景中激活。 */ + activeInHierarchy: boolean; + /** + + @param name name + */ + constructor(name?: string); + /** !#en The parent of the node. + !#zh 该节点的父节点。 */ + parent: Node; + /** + !#en Get parent of the node. + !#zh 获取该节点的父节点。 + + @example + ```js + var parent = this.node.getParent(); + ``` + */ + getParent(): Node; + /** + !#en Set parent of the node. + !#zh 设置该节点的父节点。 + @param value value + + @example + ```js + node.setParent(newNode); + ``` + */ + setParent(value: Node): void; + /** + !#en + Properties configuration function
+ All properties in attrs will be set to the node,
+ when the setter of the node is available,
+ the property will be set via setter function.
+ !#zh 属性配置函数。在 attrs 的所有属性将被设置为节点属性。 + @param attrs Properties to be set to node + + @example + ```js + var attrs = { key: 0, num: 100 }; + node.attr(attrs); + ``` + */ + attr(attrs: any): void; + /** + !#en Returns a child from the container given its uuid. + !#zh 通过 uuid 获取节点的子节点。 + @param uuid The uuid to find the child node. + + @example + ```js + var child = node.getChildByUuid(uuid); + ``` + */ + getChildByUuid(uuid: string): Node; + /** + !#en Returns a child from the container given its name. + !#zh 通过名称获取节点的子节点。 + @param name A name to find the child node. + + @example + ```js + var child = node.getChildByName("Test Node"); + ``` + */ + getChildByName(name: string): Node; + /** + !#en + Inserts a child to the node at a specified index. + !#zh + 插入子节点到指定位置 + @param child the child node to be inserted + @param siblingIndex the sibling index to place the child in + + @example + ```js + node.insertChild(child, 2); + ``` + */ + insertChild(child: Node, siblingIndex: number): void; + /** + !#en Get the sibling index. + !#zh 获取同级索引。 + + @example + ```js + var index = node.getSiblingIndex(); + ``` + */ + getSiblingIndex(): number; + /** + !#en Set the sibling index of this node. + !#zh 设置节点同级索引。 + @param index index + + @example + ```js + node.setSiblingIndex(1); + ``` + */ + setSiblingIndex(index: number): void; + /** + !#en Walk though the sub children tree of the current node. + Each node, including the current node, in the sub tree will be visited two times, before all children and after all children. + This function call is not recursive, it's based on stack. + Please don't walk any other node inside the walk process. + !#zh 遍历该节点的子树里的所有节点并按规则执行回调函数。 + 对子树中的所有节点,包含当前节点,会执行两次回调,prefunc 会在访问它的子节点之前调用,postfunc 会在访问所有子节点之后调用。 + 这个函数的实现不是基于递归的,而是基于栈展开递归的方式。 + 请不要在 walk 过程中对任何其他的节点嵌套执行 walk。 + @param prefunc The callback to process node when reach the node for the first time + @param postfunc The callback to process node when re-visit the node after walked all children in its sub tree + + @example + ```js + node.walk(function (target) { + console.log('Walked through node ' + target.name + ' for the first time'); + }, function (target) { + console.log('Walked through node ' + target.name + ' after walked all children in its sub tree'); + }); + ``` + */ + walk(prefunc: (target: _BaseNode) => void, postfunc: (target: _BaseNode) => void): void; + /** + !#en + Remove itself from its parent node. If cleanup is `true`, then also remove all events and actions.
+ If the cleanup parameter is not passed, it will force a cleanup, so it is recommended that you always pass in the `false` parameter when calling this API.
+ If the node orphan, then nothing happens. + !#zh + 从父节点中删除该节点。如果不传入 cleanup 参数或者传入 `true`,那么这个节点上所有绑定的事件、action 都会被删除。
+ 因此建议调用这个 API 时总是传入 `false` 参数。
+ 如果这个节点是一个孤节点,那么什么都不会发生。 + @param cleanup true if all actions and callbacks on this node should be removed, false otherwise. + + @example + ```js + node.removeFromParent(); + node.removeFromParent(false); + ``` + */ + removeFromParent(cleanup?: boolean): void; + /** + !#en + Removes a child from the container. It will also cleanup all running actions depending on the cleanup parameter.

+ If the cleanup parameter is not passed, it will force a cleanup.
+ "remove" logic MUST only be on this method
+ If a class wants to extend the 'removeChild' behavior it only needs
+ to override this method. + !#zh + 移除节点中指定的子节点,是否需要清理所有正在运行的行为取决于 cleanup 参数。
+ 如果 cleanup 参数不传入,默认为 true 表示清理。
+ @param child The child node which will be removed. + @param cleanup true if all running actions and callbacks on the child node will be cleanup, false otherwise. + + @example + ```js + node.removeChild(newNode); + node.removeChild(newNode, false); + ``` + */ + removeChild(child: Node, cleanup?: boolean): void; + /** + !#en + Removes all children from the container and do a cleanup all running actions depending on the cleanup parameter.
+ If the cleanup parameter is not passed, it will force a cleanup. + !#zh + 移除节点所有的子节点,是否需要清理所有正在运行的行为取决于 cleanup 参数。
+ 如果 cleanup 参数不传入,默认为 true 表示清理。 + @param cleanup true if all running actions on all children nodes should be cleanup, false otherwise. + + @example + ```js + node.removeAllChildren(); + node.removeAllChildren(false); + ``` + */ + removeAllChildren(cleanup?: boolean): void; + /** + !#en Is this node a child of the given node? + !#zh 是否是指定节点的子节点? + @param parent parent + + @example + ```js + node.isChildOf(newNode); + ``` + */ + isChildOf(parent: Node): boolean; + /** + !#en + Returns the component of supplied type if the node has one attached, null if it doesn't.
+ You can also get component in the node by passing in the name of the script. + !#zh + 获取节点上指定类型的组件,如果节点有附加指定类型的组件,则返回,如果没有则为空。
+ 传入参数也可以是脚本的名称。 + @param typeOrClassName typeOrClassName + + @example + ```js + // get sprite component + var sprite = node.getComponent(cc.Sprite); + // get custom test class + var test = node.getComponent("Test"); + ``` + */ + getComponent(type: {prototype: T}): T; + getComponent(className: string): any; + /** + !#en Returns all components of supplied type in the node. + !#zh 返回节点上指定类型的所有组件。 + @param typeOrClassName typeOrClassName + + @example + ```js + var sprites = node.getComponents(cc.Sprite); + var tests = node.getComponents("Test"); + ``` + */ + getComponents(type: {prototype: T}): T[]; + getComponents(className: string): any[]; + /** + !#en Returns the component of supplied type in any of its children using depth first search. + !#zh 递归查找所有子节点中第一个匹配指定类型的组件。 + @param typeOrClassName typeOrClassName + + @example + ```js + var sprite = node.getComponentInChildren(cc.Sprite); + var Test = node.getComponentInChildren("Test"); + ``` + */ + getComponentInChildren(type: {prototype: T}): T; + getComponentInChildren(className: string): any; + /** + !#en Returns all components of supplied type in self or any of its children. + !#zh 递归查找自身或所有子节点中指定类型的组件 + @param typeOrClassName typeOrClassName + + @example + ```js + var sprites = node.getComponentsInChildren(cc.Sprite); + var tests = node.getComponentsInChildren("Test"); + ``` + */ + getComponentsInChildren(type: {prototype: T}): T[]; + getComponentsInChildren(className: string): any[]; + /** + !#en Adds a component class to the node. You can also add component to node by passing in the name of the script. + !#zh 向节点添加一个指定类型的组件类,你还可以通过传入脚本的名称来添加组件。 + @param typeOrClassName The constructor or the class name of the component to add + + @example + ```js + var sprite = node.addComponent(cc.Sprite); + var test = node.addComponent("Test"); + ``` + */ + addComponent(type: {new(): T}): T; + addComponent(className: string): any; + /** + !#en + Removes a component identified by the given name or removes the component object given. + You can also use component.destroy() if you already have the reference. + !#zh + 删除节点上的指定组件,传入参数可以是一个组件构造函数或组件名,也可以是已经获得的组件引用。 + 如果你已经获得组件引用,你也可以直接调用 component.destroy() + @param component The need remove component. + + @example + ```js + node.removeComponent(cc.Sprite); + var Test = require("Test"); + node.removeComponent(Test); + ``` + */ + removeComponent(component: string|Function|Component): void; + /** + !#en + Destroy all children from the node, and release all their own references to other objects.
+ Actual destruct operation will delayed until before rendering. + !#zh + 销毁所有子节点,并释放所有它们对其它对象的引用。
+ 实际销毁操作会延迟到当前帧渲染前执行。 + + @example + ```js + node.destroyAllChildren(); + ``` + */ + destroyAllChildren(): void; + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en + Register an callback of a specific event type on the EventTarget. + This type of event should be triggered via `emit`. + !#zh + 注册事件目标的特定事件类型回调。这种类型的事件应该被 `emit` 触发。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, node); + ``` + */ + on(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. + !#zh + 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + + @example + ```js + // register fire eventListener + var callback = eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, target); + // remove fire event listener + eventTarget.off('fire', callback, target); + // remove all fire event listeners + eventTarget.off('fire'); + ``` + */ + off(type: string, callback?: Function, target?: any): void; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.once('fire', function () { + cc.log("this is the callback and will be invoked only once"); + }, node); + ``` + */ + once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; + /** + !#en + Send an event with the event object. + !#zh + 通过事件对象派发事件 + @param event event + */ + dispatchEvent(event: Event): void; + } + /** !#en + Helper class for setting material blend function. + !#zh + 设置材质混合模式的辅助类。 */ + export class BlendFunc { + /** !#en specify the source Blend Factor, this will generate a custom material object, please pay attention to the memory cost. + !#zh 指定原图的混合模式,这会克隆一个新的材质对象,注意这带来的开销 */ + srcBlendFactor: macro.BlendFactor; + /** !#en specify the destination Blend Factor. + !#zh 指定目标的混合模式 */ + dstBlendFactor: macro.BlendFactor; + } + /** An internal helper class for switching render component's material between normal sprite material and gray sprite material. */ + export class GraySpriteState { + /** !#en The normal material. + !#zh 正常状态的材质。 */ + normalMaterial: Material; + /** !#en The gray material. + !#zh 置灰状态的材质。 */ + grayMaterial: Material; + } + /** misc utilities */ + export class misc { + /** + !#en Clamp a value between from and to. + !#zh + 限定浮点数的最大最小值。
+ 数值大于 max_inclusive 则返回 max_inclusive。
+ 数值小于 min_inclusive 则返回 min_inclusive。
+ 否则返回自身。 + @param value value + @param min_inclusive min_inclusive + @param max_inclusive max_inclusive + + @example + ```js + var v1 = cc.misc.clampf(20, 0, 20); // 20; + var v2 = cc.misc.clampf(-1, 0, 20); // 0; + var v3 = cc.misc.clampf(10, 0, 20); // 10; + ``` + */ + static clampf(value: number, min_inclusive: number, max_inclusive: number): number; + /** + !#en Clamp a value between 0 and 1. + !#zh 限定浮点数的取值范围为 0 ~ 1 之间。 + @param value value + + @example + ```js + var v1 = cc.misc.clamp01(20); // 1; + var v2 = cc.misc.clamp01(-1); // 0; + var v3 = cc.misc.clamp01(0.5); // 0.5; + ``` + */ + static clamp01(value: number): number; + /** + Linear interpolation between 2 numbers, the ratio sets how much it is biased to each end + @param a number A + @param b number B + @param r ratio between 0 and 1 + + @example + ```js + ---- + lerp + cc.misc.lerp(2,10,0.5)//returns 6 + cc.misc.lerp(2,10,0.2)//returns 3.6 + + ``` + */ + static lerp(a: number, b: number, r: number): number; + /** + converts degrees to radians + @param angle angle + */ + static degreesToRadians(angle: number): number; + /** + converts radians to degrees + @param angle angle + */ + static radiansToDegrees(angle: number): number; + } + /** !#en + Representation of RGBA colors. + + Each color component is a floating point value with a range from 0 to 255. + + You can also use the convenience method {{#crossLink "cc/color:method"}}cc.color{{/crossLink}} to create a new Color. + + !#zh + cc.Color 用于表示颜色。 + + 它包含 RGBA 四个以浮点数保存的颜色分量,每个的值都在 0 到 255 之间。 + + 您也可以通过使用 {{#crossLink "cc/color:method"}}cc.color{{/crossLink}} 的便捷方法来创建一个新的 Color。 */ + export class Color extends ValueType { + /** !#en Solid white, RGBA is [255, 255, 255, 255]. + !#zh 纯白色,RGBA 是 [255, 255, 255, 255]。 */ + static WHITE: Color; + /** !#en Solid black, RGBA is [0, 0, 0, 255]. + !#zh 纯黑色,RGBA 是 [0, 0, 0, 255]。 */ + static BLACK: Color; + /** !#en Transparent, RGBA is [0, 0, 0, 0]. + !#zh 透明,RGBA 是 [0, 0, 0, 0]。 */ + static TRANSPARENT: Color; + /** !#en Grey, RGBA is [127.5, 127.5, 127.5]. + !#zh 灰色,RGBA 是 [127.5, 127.5, 127.5]。 */ + static GRAY: Color; + /** !#en Solid red, RGBA is [255, 0, 0]. + !#zh 纯红色,RGBA 是 [255, 0, 0]。 */ + static RED: Color; + /** !#en Solid green, RGBA is [0, 255, 0]. + !#zh 纯绿色,RGBA 是 [0, 255, 0]。 */ + static GREEN: Color; + /** !#en Solid blue, RGBA is [0, 0, 255]. + !#zh 纯蓝色,RGBA 是 [0, 0, 255]。 */ + static BLUE: Color; + /** !#en Yellow, RGBA is [255, 235, 4]. + !#zh 黄色,RGBA 是 [255, 235, 4]。 */ + static YELLOW: Color; + /** !#en Orange, RGBA is [255, 127, 0]. + !#zh 橙色,RGBA 是 [255, 127, 0]。 */ + static ORANGE: Color; + /** !#en Cyan, RGBA is [0, 255, 255]. + !#zh 青色,RGBA 是 [0, 255, 255]。 */ + static CYAN: Color; + /** !#en Magenta, RGBA is [255, 0, 255]. + !#zh 洋红色(品红色),RGBA 是 [255, 0, 255]。 */ + static MAGENTA: Color; + /** + Copy content of a color into another. + */ + static copy (out: Color, a: Color): Color; + /** + Clone a new color. + */ + static clone (a: Color): Color; + /** + Set the components of a color to the given values. + */ + static set (out: Color, r = 255, g = 255, b = 255, a = 255): Color; + /** + Converts the hexadecimal formal color into rgb formal. + */ + static fromHex (out: Color, hex: number): Color; + /** + Add components of two colors, respectively. + */ + static add (out: Color, a: Color, b: Color): Color; + /** + Subtract components of color b from components of color a, respectively. + */ + static subtract (out: Color, a: Color, b: Color): Color; + /** + Multiply components of two colors, respectively. + */ + static multiply (out: Color, a: Color, b: Color): Color; + /** + Divide components of color a by components of color b, respectively. + */ + static divide (out: Color, a: Color, b: Color): Color; + /** + Scales a color by a number. + */ + static scale (out: Color, a: Color, b: number): Color; + /** + Performs a linear interpolation between two colors. + */ + static lerp (out: Color, a: Color, b: Color, t: number): Color; + /** + !#zh 颜色转数组 + !#en Turn an array of colors + @param ofs 数组起始偏移量 + */ + static toArray > (out: Out, a: IColorLike, ofs = 0); + /** + !#zh 数组转颜色 + !#en An array of colors turn + @param ofs 数组起始偏移量 + */ + static fromArray (arr: IWritableArrayLike, out: Out, ofs = 0); + /** + + @param r red component of the color, default value is 0. + @param g green component of the color, defualt value is 0. + @param b blue component of the color, default value is 0. + @param a alpha component of the color, default value is 255. + */ + constructor(r?: number, g?: number, b?: number, a?: number); + /** + !#en Clone a new color from the current color. + !#zh 克隆当前颜色。 + + @example + ```js + var color = new cc.Color(); + var newColor = color.clone();// Color {r: 0, g: 0, b: 0, a: 255} + ``` + */ + clone(): Color; + /** + !#en TODO + !#zh 判断两个颜色是否相等。 + @param other other + + @example + ```js + var color1 = cc.Color.WHITE; + var color2 = new cc.Color(255, 255, 255); + cc.log(color1.equals(color2)); // true; + color2 = cc.Color.RED; + cc.log(color2.equals(color1)); // false; + ``` + */ + equals(other: Color): boolean; + /** + !#en TODO + !#zh 线性插值 + @param to to + @param ratio the interpolation coefficient. + @param out optional, the receiving vector. + + @example + ```js + // Converts a white color to a black one trough time. + update: function (dt) { + var color = this.node.color; + if (color.equals(cc.Color.BLACK)) { + return; + } + this.ratio += dt * 0.1; + this.node.color = cc.Color.WHITE.lerp(cc.Color.BLACK, ratio); + } + + ``` + */ + lerp(to: Color, ratio: number, out?: Color): Color; + /** + !#en TODO + !#zh 转换为方便阅读的字符串。 + + @example + ```js + var color = cc.Color.WHITE; + color.toString(); // "rgba(255, 255, 255, 255)" + ``` + */ + toString(): string; + /** !#en Get or set red channel value + !#zh 获取或者设置红色通道 */ + r: number; + /** !#en Get or set green channel value + !#zh 获取或者设置绿色通道 */ + g: number; + /** !#en Get or set blue channel value + !#zh 获取或者设置蓝色通道 */ + b: number; + /** !#en Get or set alpha channel value + !#zh 获取或者设置透明通道 */ + a: number; + /** + !#en Gets red channel value + !#zh 获取当前颜色的红色值。 + */ + getR(): number; + /** + !#en Sets red value and return the current color object + !#zh 设置当前的红色值,并返回当前对象。 + @param red the new Red component. + + @example + ```js + var color = new cc.Color(); + color.setR(255); // Color {r: 255, g: 0, b: 0, a: 255} + ``` + */ + setR(red: number): Color; + /** + !#en Gets green channel value + !#zh 获取当前颜色的绿色值。 + */ + getG(): number; + /** + !#en Sets green value and return the current color object + !#zh 设置当前的绿色值,并返回当前对象。 + @param green the new Green component. + + @example + ```js + var color = new cc.Color(); + color.setG(255); // Color {r: 0, g: 255, b: 0, a: 255} + ``` + */ + setG(green: number): Color; + /** + !#en Gets blue channel value + !#zh 获取当前颜色的蓝色值。 + */ + getB(): number; + /** + !#en Sets blue value and return the current color object + !#zh 设置当前的蓝色值,并返回当前对象。 + @param blue the new Blue component. + + @example + ```js + var color = new cc.Color(); + color.setB(255); // Color {r: 0, g: 0, b: 255, a: 255} + ``` + */ + setB(blue: number): Color; + /** + !#en Gets alpha channel value + !#zh 获取当前颜色的透明度值。 + */ + getA(): number; + /** + !#en Sets alpha value and return the current color object + !#zh 设置当前的透明度,并返回当前对象。 + @param alpha the new Alpha component. + + @example + ```js + var color = new cc.Color(); + color.setA(0); // Color {r: 0, g: 0, b: 0, a: 0} + ``` + */ + setA(alpha: number): Color; + /** + !#en Convert color to css format. + !#zh 转换为 CSS 格式。 + @param opt "rgba", "rgb", "#rgb" or "#rrggbb". + + @example + ```js + var color = cc.Color.BLACK; + color.toCSS(); // "rgba(0,0,0,1.00)"; + color.toCSS("rgba"); // "rgba(0,0,0,1.00)"; + color.toCSS("rgb"); // "rgba(0,0,0)"; + color.toCSS("#rgb"); // "#000"; + color.toCSS("#rrggbb"); // "#000000"; + ``` + */ + toCSS(opt?: string): string; + /** + !#en Read hex string and store color data into the current color object, the hex string must be formated as rgba or rgb. + !#zh 读取 16 进制颜色。 + @param hexString hexString + + @example + ```js + var color = cc.Color.BLACK; + color.fromHEX("#FFFF33"); // Color {r: 255, g: 255, b: 51, a: 255}; + ``` + */ + fromHEX(hexString: string): Color; + /** + !#en convert Color to HEX color string. + e.g. cc.color(255,6,255) to : "#ff06ff" + !#zh 转换为 16 进制。 + @param fmt "#rgb", "#rrggbb" or "#rrggbbaa". + + @example + ```js + var color = cc.Color.BLACK; + color.toHEX("#rgb"); // "000"; + color.toHEX("#rrggbb"); // "000000"; + ``` + */ + toHEX(fmt: string): string; + /** + !#en Convert to 24bit rgb value. + !#zh 转换为 24bit 的 RGB 值。 + + @example + ```js + var color = cc.Color.YELLOW; + color.toRGBValue(); // 16771844; + ``` + */ + toRGBValue(): number; + /** + !#en Read HSV model color and convert to RGB color + !#zh 读取 HSV(色彩模型)格式。 + @param h h + @param s s + @param v v + + @example + ```js + var color = cc.Color.YELLOW; + color.fromHSV(0, 0, 1); // Color {r: 255, g: 255, b: 255, a: 255}; + ``` + */ + fromHSV(h: number, s: number, v: number): Color; + /** + !#en Transform to HSV model color + !#zh 转换为 HSV(色彩模型)格式。 + + @example + ```js + var color = cc.Color.YELLOW; + color.toHSV(); // Object {h: 0.1533864541832669, s: 0.9843137254901961, v: 1}; + ``` + */ + toHSV(): any; + /** + !#en Set the color + !#zh 设置颜色 + @param color color + */ + set (color: Color): Color; + /** + !#en Multiplies the current color by the specified color + !#zh 将当前颜色乘以与指定颜色 + @param other other + */ + multiply(other: Color): Color; + } + /** !#en Representation of 4*4 matrix. + !#zh 表示 4*4 矩阵 */ + export class Mat4 extends ValueType { + /** + !#en Multiply the current matrix with another one + !#zh 将当前矩阵与指定矩阵相乘 + @param other the second operand + @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created + */ + mul(other: Mat4, out?: Mat4): Mat4; + /** + !#en Multiply each element of the matrix by a scalar. + !#zh 将矩阵的每一个元素都乘以指定的缩放值。 + @param number amount to scale the matrix's elements by + @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created + */ + mulScalar(number: number, out?: Mat4): Mat4; + /** + !#en Subtracts the current matrix with another one + !#zh 将当前矩阵与指定的矩阵相减 + @param other the second operand + @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created + */ + sub(other: Mat4, out?: Mat4): Mat4; + /** Identity of Mat4 */ + static IDENTITY: Mat4; + /** + !#zh 获得指定矩阵的拷贝 + !#en Copy of the specified matrix to obtain + */ + static clone (a: Out); + /** + !#zh 复制目标矩阵 + !#en Copy the target matrix + */ + static copy (out: Out, a: Out); + /** + !#zh 将目标赋值为单位矩阵 + !#en The target of an assignment is the identity matrix + */ + static identity (out: Out); + /** + !#zh 转置矩阵 + !#en Transposed matrix + */ + static transpose (out: Out, a: Out); + /** + !#zh 矩阵求逆 + !#en Matrix inversion + */ + static invert (out: Out, a: Out); + /** + !#zh 矩阵行列式 + !#en Matrix determinant + */ + static determinant (a: Out): number; + /** + !#zh 矩阵乘法 + !#en Matrix Multiplication + */ + static multiply (out: Out, a: Out, b: Out); + /** + !#zh 在给定矩阵变换基础上加入变换 + !#en Was added in a given transformation matrix transformation on the basis of + */ + static transform (out: Out, a: Out, v: VecLike); + /** + !#zh 在给定矩阵变换基础上加入新位移变换 + !#en Add new displacement transducer in a matrix transformation on the basis of a given + */ + static translate (out: Out, a: Out, v: VecLike); + /** + !#zh 在给定矩阵变换基础上加入新缩放变换 + !#en Add new scaling transformation in a given matrix transformation on the basis of + */ + static scale (out: Out, a: Out, v: VecLike); + /** + !#zh 在给定矩阵变换基础上加入新旋转变换 + !#en Add a new rotational transform matrix transformation on the basis of a given + @param rad 旋转角度 + @param axis 旋转轴 + */ + static rotate (out: Out, a: Out, rad: number, axis: VecLike); + /** + !#zh 在给定矩阵变换基础上加入绕 X 轴的旋转变换 + !#en Add rotational transformation around the X axis at a given matrix transformation on the basis of + @param rad 旋转角度 + */ + static rotateX (out: Out, a: Out, rad: number); + /** + !#zh 在给定矩阵变换基础上加入绕 Y 轴的旋转变换 + !#en Add about the Y axis rotation transformation in a given matrix transformation on the basis of + @param rad 旋转角度 + */ + static rotateY (out: Out, a: Out, rad: number); + /** + !#zh 在给定矩阵变换基础上加入绕 Z 轴的旋转变换 + !#en Added about the Z axis at a given rotational transformation matrix transformation on the basis of + @param rad 旋转角度 + */ + static rotateZ (out: Out, a: Out, rad: number); + /** + !#zh 计算位移矩阵 + !#en Displacement matrix calculation + */ + static fromTranslation (out: Out, v: VecLike); + /** + !#zh 计算缩放矩阵 + !#en Scaling matrix calculation + */ + static fromScaling (out: Out, v: VecLike); + /** + !#zh 计算旋转矩阵 + !#en Calculates the rotation matrix + */ + static fromRotation (out: Out, rad: number, axis: VecLike); + /** + !#zh 计算绕 X 轴的旋转矩阵 + !#en Calculating rotation matrix about the X axis + */ + static fromXRotation (out: Out, rad: number); + /** + !#zh 计算绕 Y 轴的旋转矩阵 + !#en Calculating rotation matrix about the Y axis + */ + static fromYRotation (out: Out, rad: number); + /** + !#zh 计算绕 Z 轴的旋转矩阵 + !#en Calculating rotation matrix about the Z axis + */ + static fromZRotation (out: Out, rad: number); + /** + !#zh 根据旋转和位移信息计算矩阵 + !#en The rotation and displacement information calculating matrix + */ + static fromRT (out: Out, q: Quat, v: VecLike); + /** + !#zh 提取矩阵的位移信息, 默认矩阵中的变换以 S->R->T 的顺序应用 + !#en Extracting displacement information of the matrix, the matrix transform to the default sequential application S-> R-> T is + */ + static getTranslation (out: VecLike, mat: Out); + /** + !#zh 提取矩阵的缩放信息, 默认矩阵中的变换以 S->R->T 的顺序应用 + !#en Scaling information extraction matrix, the matrix transform to the default sequential application S-> R-> T is + */ + static getScaling (out: VecLike, mat: Out); + /** + !#zh 提取矩阵的旋转信息, 默认输入矩阵不含有缩放信息,如考虑缩放应使用 `toRTS` 函数。 + !#en Rotation information extraction matrix, the matrix containing no default input scaling information, such as the use of `toRTS` should consider the scaling function. + */ + static getRotation (out: Quat, mat: Out); + /** + !#zh 提取旋转、位移、缩放信息, 默认矩阵中的变换以 S->R->T 的顺序应用 + !#en Extracting rotational displacement, zoom information, the default matrix transformation in order S-> R-> T applications + */ + static toRTS (mat: Out, q: Quat, v: VecLike, s: VecLike); + /** + !#zh 根据旋转、位移、缩放信息计算矩阵,以 S->R->T 的顺序应用 + !#en The rotary displacement, the scaling matrix calculation information, the order S-> R-> T applications + */ + static fromRTS (out: Out, q: Quat, v: VecLike, s: VecLike); + /** + !#zh 根据指定的旋转、位移、缩放及变换中心信息计算矩阵,以 S->R->T 的顺序应用 + !#en According to the specified rotation, displacement, and scale conversion matrix calculation information center, order S-> R-> T applications + @param q 旋转值 + @param v 位移值 + @param s 缩放值 + @param o 指定变换中心 + */ + static fromRTSOrigin (out: Out, q: Quat, v: VecLike, s: VecLike, o: VecLike); + /** + !#zh 根据指定的旋转信息计算矩阵 + !#en The rotation matrix calculation information specified + */ + static fromQuat (out: Out, q: Quat); + /** + !#zh 根据指定的视锥体信息计算矩阵 + !#en The matrix calculation information specified frustum + @param left 左平面距离 + @param right 右平面距离 + @param bottom 下平面距离 + @param top 上平面距离 + @param near 近平面距离 + @param far 远平面距离 + */ + static frustum (out: Out, left: number, right: number, bottom: number, top: number, near: number, far: number); + /** + !#zh 计算透视投影矩阵 + !#en Perspective projection matrix calculation + @param fovy 纵向视角高度 + @param aspect 长宽比 + @param near 近平面距离 + @param far 远平面距离 + */ + static perspective (out: Out, fovy: number, aspect: number, near: number, far: number); + /** + !#zh 计算正交投影矩阵 + !#en Computing orthogonal projection matrix + @param left 左平面距离 + @param right 右平面距离 + @param bottom 下平面距离 + @param top 上平面距离 + @param near 近平面距离 + @param far 远平面距离 + */ + static ortho (out: Out, left: number, right: number, bottom: number, top: number, near: number, far: number); + /** + !#zh 根据视点计算矩阵,注意 `eye - center` 不能为零向量或与 `up` 向量平行 + !#en `Up` parallel vector or vector center` not be zero - the matrix calculation according to the viewpoint, note` eye + @param eye 当前位置 + @param center 目标视点 + @param up 视口上方向 + */ + static lookAt (out: Out, eye: VecLike, center: VecLike, up: VecLike); + /** + !#zh 计算逆转置矩阵 + !#en Reversal matrix calculation + */ + static inverseTranspose (out: Out, a: Out); + /** + !#zh 逐元素矩阵加法 + !#en Element by element matrix addition + */ + static add (out: Out, a: Out, b: Out); + /** + !#zh 逐元素矩阵减法 + !#en Matrix element by element subtraction + */ + static subtract (out: Out, a: Out, b: Out); + /** + !#zh 矩阵标量乘法 + !#en Matrix scalar multiplication + */ + static multiplyScalar (out: Out, a: Out, b: number); + /** + !#zh 逐元素矩阵标量乘加: A + B * scale + !#en Elements of the matrix by the scalar multiplication and addition: A + B * scale + */ + static multiplyScalarAndAdd (out: Out, a: Out, b: Out, scale: number); + /** + !#zh 矩阵等价判断 + !#en Analyzing the equivalent matrix + */ + static strictEquals (a: Out, b: Out); + /** + !#zh 排除浮点数误差的矩阵近似等价判断 + !#en Negative floating point error is approximately equivalent to determining a matrix + */ + static equals (a: Out, b: Out, epsilon = EPSILON); + /** + !#zh 矩阵转数组 + !#en Matrix transpose array + @param ofs 数组内的起始偏移量 + */ + static toArray > (out: Out, mat: IMat4Like, ofs = 0); + /** + !#zh 数组转矩阵 + !#en Transfer matrix array + @param ofs 数组起始偏移量 + */ + static fromArray (out: Out, arr: IWritableArrayLike, ofs = 0); + /** !#en Matrix Data + !#zh 矩阵数据 */ + m: Float64Array|Float32Array; + /** + !#en + Constructor + see {{#crossLink "cc/mat4:method"}}cc.mat4{{/crossLink}} + !#zh + 构造函数,可查看 {{#crossLink "cc/mat4:method"}}cc.mat4{{/crossLink}} + */ + constructor ( m00: number = 1, m01: number = 0, m02: number = 0, m03: number = 0, m10: number = 0, m11: number = 1, m12: number = 0, m13: number = 0, m20: number = 0, m21: number = 0, m22: number = 1, m23: number = 0, m30: number = 0, m31: number = 0, m32: number = 0, m33: number = 1); + /** + !#en clone a Mat4 object + !#zh 克隆一个 Mat4 对象 + */ + clone(): Mat4; + /** + !#en Sets the matrix with another one's value + !#zh 用另一个矩阵设置这个矩阵的值。 + @param srcObj srcObj + */ + set(srcObj: Mat4): Mat4; + /** + !#en Check whether two matrix equal + !#zh 当前的矩阵是否与指定的矩阵相等。 + @param other other + */ + equals(other: Mat4): boolean; + /** + !#en Check whether two matrix equal with default degree of variance. + !#zh + 近似判断两个矩阵是否相等。
+ 判断 2 个矩阵是否在默认误差范围之内,如果在则返回 true,反之则返回 false。 + @param other other + */ + fuzzyEquals(other: Mat4): boolean; + /** + !#en Transform to string with matrix informations + !#zh 转换为方便阅读的字符串。 + */ + toString(): string; + /** + Set the matrix to the identity matrix + */ + identity(): Mat4; + /** + Transpose the values of a mat4 + @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created. + */ + transpose(out?: Mat4): Mat4; + /** + Inverts a mat4 + @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created. + */ + invert(out?: Mat4): Mat4; + /** + Calculates the adjugate of a mat4 + @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created. + */ + adjoint(out?: Mat4): Mat4; + /** + Calculates the determinant of a mat4 + */ + determinant(): number; + /** + Adds two Mat4 + @param other the second operand + @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created. + */ + add(other: Mat4, out?: Mat4): Mat4; + /** + Subtracts the current matrix with another one + @param other the second operand + */ + subtract(other: Mat4): Mat4; + /** + Subtracts the current matrix with another one + @param other the second operand + */ + multiply(other: Mat4): Mat4; + /** + Multiply each element of the matrix by a scalar. + @param number amount to scale the matrix's elements by + */ + multiplyScalar(number: number): Mat4; + /** + Translate a mat4 by the given vector + @param v vector to translate by + @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created + */ + translate(v: Vec3, out?: Mat4): Mat4; + /** + Scales the mat4 by the dimensions in the given vec3 + @param v vector to scale by + @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created + */ + scale(v: Vec3, out?: Mat4): Mat4; + /** + Rotates a mat4 by the given angle around the given axis + @param rad the angle to rotate the matrix by + @param axis the axis to rotate around + @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created + */ + rotate(rad: number, axis: Vec3, out?: Mat4): Mat4; + /** + Returns the translation vector component of a transformation matrix. + @param out Vector to receive translation component, if not provided, a new vec3 will be created + */ + getTranslation(out: Vec3): Vec3; + /** + Returns the scale factor component of a transformation matrix + @param out Vector to receive scale component, if not provided, a new vec3 will be created + */ + getScale(out: Vec3): Vec3; + /** + Returns the rotation factor component of a transformation matrix + @param out Vector to receive rotation component, if not provided, a new quaternion object will be created + */ + getRotation(out: Quat): Quat; + /** + Restore the matrix values from a quaternion rotation, vector translation and vector scale + @param q Rotation quaternion + @param v Translation vector + @param s Scaling vector + */ + fromRTS(q: Quat, v: Vec3, s: Vec3): Mat4; + /** + Restore the matrix values from a quaternion rotation + @param q Rotation quaternion + */ + fromQuat(q: Quat): Mat4; + } + /** !#en Representation of 2D vectors and points. + !#zh 表示 2D 向量和坐标 */ + export class Quat extends ValueType { + /** + !#en + Constructor + see {{#crossLink "cc/quat:method"}}cc.quat{{/crossLink}} + !#zh + 构造函数,可查看 {{#crossLink "cc/quat:method"}}cc.quat{{/crossLink}} + @param x x + @param y y + @param z z + @param w w + */ + constructor(x?: number, y?: number, z?: number, w?: number); + /** + !#en Calculate the multiply result between this quaternion and another one + !#zh 计算四元数乘积的结果 + @param other other + @param out out + */ + mul(other: Quat, out?: Quat): Quat; + /** + !#zh 获得指定四元数的拷贝 + !#en Obtaining copy specified quaternion + */ + static clone (a: Out); + /** + !#zh 复制目标四元数 + !#en Copy quaternion target + */ + static copy (out: Out, a: QuatLike); + /** + !#zh 设置四元数值 + !#en Provided Quaternion Value + */ + static set (out: Out, x: number, y: number, z: number, w: number); + /** + !#zh 将目标赋值为单位四元数 + !#en The target of an assignment as a unit quaternion + */ + static identity (out: Out); + /** + !#zh 设置四元数为两向量间的最短路径旋转,默认两向量都已归一化 + !#en Set quaternion rotation is the shortest path between two vectors, the default two vectors are normalized + */ + static rotationTo (out: Out, a: VecLike, b: VecLike); + /** + !#zh 获取四元数的旋转轴和旋转弧度 + !#en Get the rotary shaft and the arc of rotation quaternion + @param outAxis 旋转轴输出 + @param q 源四元数 + */ + static getAxisAngle (outAxis: VecLike, q: Out); + /** + !#zh 四元数乘法 + !#en Quaternion multiplication + */ + static multiply (out: Out, a: QuatLike_1, b: QuatLike_2); + /** + !#zh 四元数标量乘法 + !#en Quaternion scalar multiplication + */ + static multiplyScalar (out: Out, a: Out, b: number); + /** + !#zh 四元数乘加:A + B * scale + !#en Quaternion multiplication and addition: A + B * scale + */ + static scaleAndAdd (out: Out, a: Out, b: Out, scale: number); + /** + !#zh 绕 X 轴旋转指定四元数 + !#en About the X axis specified quaternion + @param rad 旋转弧度 + */ + static rotateX (out: Out, a: Out, rad: number); + /** + !#zh 绕 Y 轴旋转指定四元数 + !#en Rotation about the Y axis designated quaternion + @param rad 旋转弧度 + */ + static rotateY (out: Out, a: Out, rad: number); + /** + !#zh 绕 Z 轴旋转指定四元数 + !#en Around the Z axis specified quaternion + @param rad 旋转弧度 + */ + static rotateZ (out: Out, a: Out, rad: number); + /** + !#zh 绕世界空间下指定轴旋转四元数 + !#en Space around the world at a given axis of rotation quaternion + @param axis 旋转轴,默认已归一化 + @param rad 旋转弧度 + */ + static rotateAround (out: Out, rot: Out, axis: VecLike, rad: number); + /** + !#zh 绕本地空间下指定轴旋转四元数 + !#en Local space around the specified axis rotation quaternion + @param axis 旋转轴 + @param rad 旋转弧度 + */ + static rotateAroundLocal (out: Out, rot: Out, axis: VecLike, rad: number); + /** + !#zh 根据 xyz 分量计算 w 分量,默认已归一化 + !#en The component w xyz components calculated, normalized by default + */ + static calculateW (out: Out, a: Out); + /** + !#zh 四元数点积(数量积) + !#en Quaternion dot product (scalar product) + */ + static dot (a: Out, b: Out); + /** + !#zh 逐元素线性插值: A + t * (B - A) + !#en Element by element linear interpolation: A + t * (B - A) + */ + static lerp (out: Out, a: Out, b: Out, t: number); + /** + !#zh 带两个控制点的四元数球面插值 + !#en Quaternion with two spherical interpolation control points + */ + static sqlerp (out: Out, a: Out, b: Out, c: Out, d: Out, t: number); + /** + !#zh 四元数求逆 + !#en Quaternion inverse + */ + static invert (out: Out, a: QuatLike); + /** + !#zh 求共轭四元数,对单位四元数与求逆等价,但更高效 + !#en Conjugating a quaternion, and the unit quaternion equivalent to inversion, but more efficient + */ + static conjugate (out: Out, a: Out); + /** + !#zh 求四元数长度 + !#en Seek length quaternion + */ + static len (a: Out); + /** + !#zh 求四元数长度平方 + !#en Seeking quaternion square of the length + */ + static lengthSqr (a: Out); + /** + !#zh 归一化四元数 + !#en Normalized quaternions + */ + static normalize (out: Out, a: Out); + /** + !#zh 根据本地坐标轴朝向计算四元数,默认三向量都已归一化且相互垂直 + !#en Calculated according to the local orientation quaternion coordinate axis, the default three vectors are normalized and mutually perpendicular + */ + static fromAxes (out: Out, xAxis: VecLike, yAxis: VecLike, zAxis: VecLike); + /** + !#zh 根据视口的前方向和上方向计算四元数 + !#en The forward direction and the direction of the viewport computing quaternion + @param view 视口面向的前方向,必须归一化 + @param up 视口的上方向,必须归一化,默认为 (0, 1, 0) + */ + static fromViewUp (out: Out, view: Vec3, up?: Vec3); + /** + !#zh 根据旋转轴和旋转弧度计算四元数 + !#en The quaternion calculated and the arc of rotation of the rotary shaft + */ + static fromAxisAngle (out: Out, axis: VecLike, rad: number); + /** + !#zh 根据三维矩阵信息计算四元数,默认输入矩阵不含有缩放信息 + !#en Calculating the three-dimensional quaternion matrix information, default zoom information input matrix does not contain + */ + static fromMat3 (out: Out, mat: Mat3); + /** + !#zh 根据欧拉角信息计算四元数,旋转顺序为 YZX + !#en The quaternion calculated Euler angle information, rotation order YZX + */ + static fromEuler (out: Out, x: number, y: number, z: number); + /** + !#zh 返回定义此四元数的坐标系 X 轴向量 + !#en This returns the result of the quaternion coordinate system X-axis vector + */ + static toAxisX (out: VecLike, q: Out); + /** + !#zh 返回定义此四元数的坐标系 Y 轴向量 + !#en This returns the result of the quaternion coordinate system Y axis vector + */ + static toAxisY (out: VecLike, q: Out); + /** + !#zh 返回定义此四元数的坐标系 Z 轴向量 + !#en This returns the result of the quaternion coordinate system the Z-axis vector + */ + static toAxisZ (out: VecLike, q: Out); + /** + !#zh 根据四元数计算欧拉角,返回角度 x, y 在 [-180, 180] 区间内, z 默认在 [-90, 90] 区间内,旋转顺序为 YZX + !#en The quaternion calculated Euler angles, return angle x, y in the [-180, 180] interval, z default the range [-90, 90] interval, the rotation order YZX + @param outerZ z 取值范围区间改为 [-180, -90] U [90, 180] + */ + static toEuler (out: Out, q: IQuatLike, outerZ?: boolean); + /** + !#zh 四元数等价判断 + !#en Analyzing quaternion equivalent + */ + static strictEquals (a: Out, b: Out); + /** + !#zh 排除浮点数误差的四元数近似等价判断 + !#en Negative floating point error quaternion approximately equivalent Analyzing + */ + static equals (a: Out, b: Out, epsilon = EPSILON); + /** + !#zh 四元数转数组 + !#en Quaternion rotation array + @param ofs 数组内的起始偏移量 + */ + static toArray > (out: Out, q: IQuatLike, ofs = 0); + /** + !#zh 数组转四元数 + !#en Array to a quaternion + @param ofs 数组起始偏移量 + */ + static fromArray (out: Out, arr: IWritableArrayLike, ofs = 0); + x: number; + y: number; + z: number; + w: number; + /** + !#en clone a Quat object and return the new object + !#zh 克隆一个四元数并返回 + */ + clone(): Quat; + /** + !#en Set values with another quaternion + !#zh 用另一个四元数的值设置到当前对象上。 + @param newValue !#en new value to set. !#zh 要设置的新值 + */ + set(newValue: Quat): Quat; + /** + !#en Check whether current quaternion equals another + !#zh 当前的四元数是否与指定的四元数相等。 + @param other other + */ + equals(other: Quat): boolean; + /** + !#en Convert quaternion to euler + !#zh 转换四元数到欧拉角 + @param out out + */ + toEuler(out: Vec3): Vec3; + /** + !#en Convert euler to quaternion + !#zh 转换欧拉角到四元数 + @param euler euler + */ + fromEuler(euler: Vec3): Quat; + /** + !#en Calculate the interpolation result between this quaternion and another one with given ratio + !#zh 计算四元数的插值结果 + @param to to + @param ratio ratio + @param out out + */ + lerp(to: Quat, ratio: number, out?: Quat): Quat; + /** + !#en Calculate the multiply result between this quaternion and another one + !#zh 计算四元数乘积的结果 + @param other other + */ + multiply(other: Quat): Quat; + /** + !#en Rotates a quaternion by the given angle (in radians) about a world space axis. + !#zh 围绕世界空间轴按给定弧度旋转四元数 + @param rot Quaternion to rotate + @param axis The axis around which to rotate in world space + @param rad Angle (in radians) to rotate + @param out Quaternion to store result + */ + rotateAround(rot: Quat, axis: Vec3, rad: number, out?: Quat): Quat; + } + /** !#en A 2D rectangle defined by x, y position and width, height. + !#zh 通过位置和宽高定义的 2D 矩形。 */ + export class Rect extends ValueType { + /** + !#en + Constructor of Rect class. + see {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} for convenience method. + !#zh + Rect类的构造函数。可以通过 {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} 简便方法进行创建。 + @param x x + @param y y + @param w w + @param h h + */ + constructor(x?: number, y?: number, w?: number, h?: number); + /** + !#en Creates a rectangle from two coordinate values. + !#zh 根据指定 2 个坐标创建出一个矩形区域。 + @param v1 v1 + @param v2 v2 + + @example + ```js + cc.Rect.fromMinMax(cc.v2(10, 10), cc.v2(20, 20)); // Rect {x: 10, y: 10, width: 10, height: 10}; + ``` + */ + static fromMinMax(v1: Vec2, v2: Vec2): Rect; + x: number; + y: number; + width: number; + height: number; + /** + !#en TODO + !#zh 克隆一个新的 Rect。 + + @example + ```js + var a = new cc.Rect(0, 0, 10, 10); + a.clone();// Rect {x: 0, y: 0, width: 10, height: 10} + ``` + */ + clone(): Rect; + /** + !#en TODO + !#zh 是否等于指定的矩形。 + @param other other + + @example + ```js + var a = new cc.Rect(0, 0, 10, 10); + var b = new cc.Rect(0, 0, 10, 10); + a.equals(b);// true; + ``` + */ + equals(other: Rect): boolean; + /** + !#en TODO + !#zh 线性插值 + @param to to + @param ratio the interpolation coefficient. + @param out optional, the receiving vector. + + @example + ```js + var a = new cc.Rect(0, 0, 10, 10); + var b = new cc.Rect(50, 50, 100, 100); + update (dt) { + // method 1; + var c = a.lerp(b, dt * 0.1); + // method 2; + a.lerp(b, dt * 0.1, c); + } + ``` + */ + lerp(to: Rect, ratio: number, out?: Rect): Rect; + /** + !#en Check whether the current rectangle intersects with the given one + !#zh 当前矩形与指定矩形是否相交。 + @param rect rect + + @example + ```js + var a = new cc.Rect(0, 0, 10, 10); + var b = new cc.Rect(0, 0, 20, 20); + a.intersects(b);// true + ``` + */ + intersects(rect: Rect): boolean; + /** + !#en Returns the overlapping portion of 2 rectangles. + !#zh 返回 2 个矩形重叠的部分。 + @param out Stores the result + @param rectB rectB + + @example + ```js + var a = new cc.Rect(0, 10, 20, 20); + var b = new cc.Rect(0, 10, 10, 10); + var intersection = new cc.Rect(); + a.intersection(intersection, b); // intersection {x: 0, y: 10, width: 10, height: 10}; + ``` + */ + intersection(out: Rect, rectB: Rect): Rect; + /** + !#en Check whether the current rect contains the given point + !#zh 当前矩形是否包含指定坐标点。 + Returns true if the point inside this rectangle. + @param point point + + @example + ```js + var a = new cc.Rect(0, 0, 10, 10); + var b = new cc.Vec2(0, 5); + a.contains(b);// true + ``` + */ + contains(point: Vec2): boolean; + /** + !#en Returns true if the other rect totally inside this rectangle. + !#zh 当前矩形是否包含指定矩形。 + @param rect rect + + @example + ```js + var a = new cc.Rect(0, 0, 20, 20); + var b = new cc.Rect(0, 0, 10, 10); + a.containsRect(b);// true + ``` + */ + containsRect(rect: Rect): boolean; + /** + !#en Returns the smallest rectangle that contains the current rect and the given rect. + !#zh 返回一个包含当前矩形和指定矩形的最小矩形。 + @param out Stores the result + @param rectB rectB + + @example + ```js + var a = new cc.Rect(0, 10, 20, 20); + var b = new cc.Rect(0, 10, 10, 10); + var union = new cc.Rect(); + a.union(union, b); // union {x: 0, y: 10, width: 20, height: 20}; + ``` + */ + union(out: Rect, rectB: Rect): Rect; + /** + !#en Apply matrix4 to the rect. + !#zh 使用 mat4 对矩形进行矩阵转换。 + @param out The output rect + @param mat The matrix4 + */ + transformMat4(out: Rect, mat: Mat4): void; + /** + !#en Output rect informations to string + !#zh 转换为方便阅读的字符串 + + @example + ```js + var a = new cc.Rect(0, 0, 10, 10); + a.toString();// "(0.00, 0.00, 10.00, 10.00)"; + ``` + */ + toString(): string; + /** !#en The minimum x value, equals to rect.x + !#zh 矩形 x 轴上的最小值,等价于 rect.x。 */ + xMin: number; + /** !#en The minimum y value, equals to rect.y + !#zh 矩形 y 轴上的最小值。 */ + yMin: number; + /** !#en The maximum x value. + !#zh 矩形 x 轴上的最大值。 */ + xMax: number; + /** !#en The maximum y value. + !#zh 矩形 y 轴上的最大值。 */ + yMax: number; + /** !#en The position of the center of the rectangle. + !#zh 矩形的中心点。 */ + center: Vec2; + /** !#en The X and Y position of the rectangle. + !#zh 矩形的 x 和 y 坐标。 */ + origin: Vec2; + /** !#en Width and height of the rectangle. + !#zh 矩形的大小。 */ + size: Size; + } + /** !#en + cc.Size is the class for size object,
+ please do not use its constructor to create sizes,
+ use {{#crossLink "cc/size:method"}}{{/crossLink}} alias function instead.
+ It will be deprecated soon, please use cc.Vec2 instead. + + !#zh + cc.Size 是 size 对象的类。
+ 请不要使用它的构造函数创建的 size,
+ 使用 {{#crossLink "cc/size:method"}}{{/crossLink}} 别名函数。
+ 它不久将被取消,请使用cc.Vec2代替。 */ + export class Size { + /** + + @param width width + @param height height + */ + constructor(width: number|Size, height?: number); + /** !#en return a Size object with width = 0 and height = 0. + !#zh 返回一个宽度为 0 和高度为 0 的 Size 对象。 */ + static ZERO: Size; + width: number; + height: number; + /** + !#en TODO + !#zh 克隆 size 对象。 + + @example + ```js + var a = new cc.size(10, 10); + a.clone();// return Size {width: 0, height: 0}; + ``` + */ + clone(): Size; + /** + !#en TODO + !#zh 当前 Size 对象是否等于指定 Size 对象。 + @param other other + + @example + ```js + var a = new cc.size(10, 10); + a.equals(new cc.size(10, 10));// return true; + ``` + */ + equals(other: Size): boolean; + /** + !#en TODO + !#zh 线性插值。 + @param to to + @param ratio the interpolation coefficient. + @param out optional, the receiving vector. + + @example + ```js + var a = new cc.size(10, 10); + var b = new cc.rect(50, 50, 100, 100); + update (dt) { + // method 1; + var c = a.lerp(b, dt * 0.1); + // method 2; + a.lerp(b, dt * 0.1, c); + } + ``` + */ + lerp(to: Rect, ratio: number, out?: Size): Size; + /** + !#en TODO + !#zh 转换为方便阅读的字符串。 + + @example + ```js + var a = new cc.size(10, 10); + a.toString();// return "(10.00, 10.00)"; + ``` + */ + toString(): string; + } + /** !#en The base class of all value types. + !#zh 所有值类型的基类。 */ + export class ValueType { + /** + !#en This method returns an exact copy of current value. + !#zh 克隆当前值,该方法返回一个新对象,新对象的值和原对象相等。 + */ + clone(): ValueType; + /** + !#en Compares this object with the other one. + !#zh 当前对象是否等于指定对象。 + @param other other + */ + equals(other: ValueType): boolean; + /** + !#en + Linearly interpolates between this value to to value by ratio which is in the range [0, 1]. + When ratio = 0 returns this. When ratio = 1 return to. When ratio = 0.5 returns the average of this and to. + !#zh + 线性插值。
+ 当 ratio = 0 时返回自身,ratio = 1 时返回目标,ratio = 0.5 返回自身和目标的平均值。。 + @param to the to value + @param ratio the interpolation coefficient + */ + lerp(to: ValueType, ratio: number): ValueType; + /** + !#en + Copys all the properties from another given object to this value. + !#zh + 从其它对象把所有属性复制到当前对象。 + @param source the source to copy + */ + set(source: ValueType): void; + /** + !#en Convert to a readable string. + !#zh 转换为方便阅读的字符串。 + */ + toString(): string; + } + /** !#en Representation of 2D vectors and points. + !#zh 表示 2D 向量和坐标 */ + export class Vec2 extends ValueType { + /** + !#en Returns the length of this vector. + !#zh 返回该向量的长度。 + + @example + ```js + var v = cc.v2(10, 10); + v.mag(); // return 14.142135623730951; + ``` + */ + mag(): number; + /** + !#en Returns the squared length of this vector. + !#zh 返回该向量的长度平方。 + + @example + ```js + var v = cc.v2(10, 10); + v.magSqr(); // return 200; + ``` + */ + magSqr(): number; + /** + !#en Subtracts one vector from this. If you want to save result to another vector, use sub() instead. + !#zh 向量减法。如果你想保存结果到另一个向量,可使用 sub() 代替。 + @param vector vector + + @example + ```js + var v = cc.v2(10, 10); + v.subSelf(cc.v2(5, 5));// return Vec2 {x: 5, y: 5}; + ``` + */ + subSelf(vector: Vec2): Vec2; + /** + !#en Subtracts one vector from this, and returns the new result. + !#zh 向量减法,并返回新结果。 + @param vector vector + @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created + + @example + ```js + var v = cc.v2(10, 10); + v.sub(cc.v2(5, 5)); // return Vec2 {x: 5, y: 5}; + var v1; + v.sub(cc.v2(5, 5), v1); // return Vec2 {x: 5, y: 5}; + ``` + */ + sub(vector: Vec2, out?: Vec2): Vec2; + /** + !#en Multiplies this by a number. If you want to save result to another vector, use mul() instead. + !#zh 缩放当前向量。如果你想结果保存到另一个向量,可使用 mul() 代替。 + @param num num + + @example + ```js + var v = cc.v2(10, 10); + v.mulSelf(5);// return Vec2 {x: 50, y: 50}; + ``` + */ + mulSelf(num: number): Vec2; + /** + !#en Multiplies by a number, and returns the new result. + !#zh 缩放向量,并返回新结果。 + @param num num + @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created + + @example + ```js + var v = cc.v2(10, 10); + v.mul(5); // return Vec2 {x: 50, y: 50}; + var v1; + v.mul(5, v1); // return Vec2 {x: 50, y: 50}; + ``` + */ + mul(num: number, out?: Vec2): Vec2; + /** + !#en Divides by a number. If you want to save result to another vector, use div() instead. + !#zh 向量除法。如果你想结果保存到另一个向量,可使用 div() 代替。 + @param num num + + @example + ```js + var v = cc.v2(10, 10); + v.divSelf(5); // return Vec2 {x: 2, y: 2}; + ``` + */ + divSelf(num: number): Vec2; + /** + !#en Divides by a number, and returns the new result. + !#zh 向量除法,并返回新的结果。 + @param num num + @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created + + @example + ```js + var v = cc.v2(10, 10); + v.div(5); // return Vec2 {x: 2, y: 2}; + var v1; + v.div(5, v1); // return Vec2 {x: 2, y: 2}; + ``` + */ + div(num: number, out?: Vec2): Vec2; + /** + !#en Multiplies two vectors. + !#zh 分量相乘。 + @param vector vector + + @example + ```js + var v = cc.v2(10, 10); + v.scaleSelf(cc.v2(5, 5));// return Vec2 {x: 50, y: 50}; + ``` + */ + scaleSelf(vector: Vec2): Vec2; + /** + !#en Multiplies two vectors, and returns the new result. + !#zh 分量相乘,并返回新的结果。 + @param vector vector + @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created + + @example + ```js + var v = cc.v2(10, 10); + v.scale(cc.v2(5, 5)); // return Vec2 {x: 50, y: 50}; + var v1; + v.scale(cc.v2(5, 5), v1); // return Vec2 {x: 50, y: 50}; + ``` + */ + scale(vector: Vec2, out?: Vec2): Vec2; + /** + !#en Negates the components. If you want to save result to another vector, use neg() instead. + !#zh 向量取反。如果你想结果保存到另一个向量,可使用 neg() 代替。 + + @example + ```js + var v = cc.v2(10, 10); + v.negSelf(); // return Vec2 {x: -10, y: -10}; + ``` + */ + negSelf(): Vec2; + /** + !#en Negates the components, and returns the new result. + !#zh 返回取反后的新向量。 + @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created + + @example + ```js + var v = cc.v2(10, 10); + var v1; + v.neg(v1); // return Vec2 {x: -10, y: -10}; + ``` + */ + neg(out?: Vec2): Vec2; + /** !#en return a Vec2 object with x = 1 and y = 1. + !#zh 新 Vec2 对象。 */ + static ONE: Vec2; + /** !#en return a Vec2 object with x = 0 and y = 0. + !#zh 返回 x = 0 和 y = 0 的 Vec2 对象。 */ + static ZERO: Vec2; + /** !#en return a readonly Vec2 object with x = 0 and y = 0. + !#zh 返回一个 x = 0 和 y = 0 的 Vec2 只读对象。 */ + static ZERO_R: Vec2; + /** !#en return a Vec2 object with x = 0 and y = 1. + !#zh 返回 x = 0 和 y = 1 的 Vec2 对象。 */ + static UP: Vec2; + /** !#en return a readonly Vec2 object with x = 0 and y = 1. + !#zh 返回 x = 0 和 y = 1 的 Vec2 只读对象。 */ + static UP_R: Vec2; + /** !#en return a readonly Vec2 object with x = 1 and y = 0. + !#zh 返回 x = 1 和 y = 0 的 Vec2 只读对象。 */ + static RIGHT: Vec2; + /** !#en return a Vec2 object with x = 1 and y = 0. + !#zh 返回 x = 1 和 y = 0 的 Vec2 对象。 */ + static RIGHT_R: Vec2; + /** + !#zh 获得指定向量的拷贝 + */ + static clone (a: Out); + /** + !#zh 复制指定向量的值 + */ + static copy (out: Out, a: Out); + /** + !#zh 设置向量值 + */ + static set (out: Out, x: number, y: number); + /** + !#zh 逐元素向量加法 + */ + static add (out: Out, a: Out, b: Out); + /** + !#zh 逐元素向量减法 + */ + static subtract (out: Out, a: Out, b: Out); + /** + !#zh 逐元素向量乘法 + */ + static multiply (out: Out, a: Out, b: Out); + /** + !#zh 逐元素向量除法 + */ + static divide (out: Out, a: Out, b: Out); + /** + !#zh 逐元素向量向上取整 + */ + static ceil (out: Out, a: Out); + /** + !#zh 逐元素向量向下取整 + */ + static floor (out: Out, a: Out); + /** + !#zh 逐元素向量最小值 + */ + static min (out: Out, a: Out, b: Out); + /** + !#zh 逐元素向量最大值 + */ + static max (out: Out, a: Out, b: Out); + /** + !#zh 逐元素向量四舍五入取整 + */ + static round (out: Out, a: Out); + /** + !#zh 向量标量乘法 + */ + static multiplyScalar (out: Out, a: Out, b: number); + /** + !#zh 逐元素向量乘加: A + B * scale + */ + static scaleAndAdd (out: Out, a: Out, b: Out, scale: number); + /** + !#zh 求两向量的欧氏距离 + */ + static distance (a: Out, b: Out); + /** + !#zh 求两向量的欧氏距离平方 + */ + static squaredDistance (a: Out, b: Out); + /** + !#zh 求向量长度 + */ + static len (a: Out); + /** + !#zh 求向量长度平方 + */ + static lengthSqr (a: Out); + /** + !#zh 逐元素向量取负 + */ + static negate (out: Out, a: Out); + /** + !#zh 逐元素向量取倒数,接近 0 时返回 Infinity + */ + static inverse (out: Out, a: Out); + /** + !#zh 逐元素向量取倒数,接近 0 时返回 0 + */ + static inverseSafe (out: Out, a: Out); + /** + !#zh 归一化向量 + */ + static normalize (out: Out, a: Vec2Like); + /** + !#zh 向量点积(数量积) + */ + static dot (a: Out, b: Out); + /** + !#zh 向量叉积(向量积),注意二维向量的叉积为与 Z 轴平行的三维向量 + */ + static cross (out: Vec2, a: Out, b: Out); + /** + !#zh 逐元素向量线性插值: A + t * (B - A) + */ + static lerp (out: Out, a: Out, b: Out, t: number); + /** + !#zh 生成一个在单位圆上均匀分布的随机向量 + */ + static random (out: Out, scale?: number); + /** + !#zh 向量与三维矩阵乘法,默认向量第三位为 1。 + */ + static transformMat3 (out: Out, a: Out, mat: IMat3Like); + /** + !#zh 向量与四维矩阵乘法,默认向量第三位为 0,第四位为 1。 + */ + static transformMat4 (out: Out, a: Out, mat: MatLike); + /** + !#zh 向量等价判断 + */ + static strictEquals (a: Out, b: Out); + /** + !#zh 排除浮点数误差的向量近似等价判断 + */ + static equals (a: Out, b: Out, epsilon = EPSILON); + /** + !#zh 排除浮点数误差的向量近似等价判断 + */ + static angle (a: Out, b: Out); + /** + !#zh 向量转数组 + */ + static toArray > (out: Out, v: IVec2Like, ofs = 0); + /** + !#zh 数组转向量 + */ + static fromArray (out: Out, arr: IWritableArrayLike, ofs = 0); + x: number; + y: number; + /** + !#en + Constructor + see {{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} or {{#crossLink "cc/p:method"}}cc.p{{/crossLink}} + !#zh + 构造函数,可查看 {{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} 或者 {{#crossLink "cc/p:method"}}cc.p{{/crossLink}} + @param x x + @param y y + */ + constructor(x?: number, y?: number); + /** + !#en clone a Vec2 object + !#zh 克隆一个 Vec2 对象 + */ + clone(): Vec2; + /** + !#en Sets vector with another's value + !#zh 设置向量值。 + @param newValue !#en new value to set. !#zh 要设置的新值 + */ + set(newValue: Vec2): Vec2; + /** + !#en Check whether two vector equal + !#zh 当前的向量是否与指定的向量相等。 + @param other other + */ + equals(other: Vec2): boolean; + /** + !#en Check whether two vector equal with some degree of variance. + !#zh + 近似判断两个点是否相等。
+ 判断 2 个向量是否在指定数值的范围之内,如果在则返回 true,反之则返回 false。 + @param other other + @param variance variance + */ + fuzzyEquals(other: Vec2, variance: number): boolean; + /** + !#en Transform to string with vector informations + !#zh 转换为方便阅读的字符串。 + */ + toString(): string; + /** + !#en Calculate linear interpolation result between this vector and another one with given ratio + !#zh 线性插值。 + @param to to + @param ratio the interpolation coefficient + @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created + */ + lerp(to: Vec2, ratio: number, out?: Vec2): Vec2; + /** + !#en Clamp the vector between from float and to float. + !#zh + 返回指定限制区域后的向量。
+ 向量大于 max_inclusive 则返回 max_inclusive。
+ 向量小于 min_inclusive 则返回 min_inclusive。
+ 否则返回自身。 + @param min_inclusive min_inclusive + @param max_inclusive max_inclusive + + @example + ```js + var min_inclusive = cc.v2(0, 0); + var max_inclusive = cc.v2(20, 20); + var v1 = cc.v2(20, 20).clampf(min_inclusive, max_inclusive); // Vec2 {x: 20, y: 20}; + var v2 = cc.v2(0, 0).clampf(min_inclusive, max_inclusive); // Vec2 {x: 0, y: 0}; + var v3 = cc.v2(10, 10).clampf(min_inclusive, max_inclusive); // Vec2 {x: 10, y: 10}; + ``` + */ + clampf(min_inclusive: Vec2, max_inclusive: Vec2): Vec2; + /** + !#en Adds this vector. + !#zh 向量加法。 + @param vector vector + @param out out + + @example + ```js + var v = cc.v2(10, 10); + v.add(cc.v2(5, 5));// return Vec2 {x: 15, y: 15}; + ``` + */ + add(vector: Vec2, out?: Vec2): Vec2; + /** + !#en Adds this vector. If you want to save result to another vector, use add() instead. + !#zh 向量加法。如果你想保存结果到另一个向量,使用 add() 代替。 + @param vector vector + */ + addSelf(vector: Vec2): Vec2; + /** + !#en Subtracts one vector from this. + !#zh 向量减法。 + @param vector vector + + @example + ```js + var v = cc.v2(10, 10); + v.subSelf(cc.v2(5, 5));// return Vec2 {x: 5, y: 5}; + ``` + */ + subtract(vector: Vec2): Vec2; + /** + !#en Multiplies this by a number. + !#zh 缩放当前向量。 + @param num num + + @example + ```js + var v = cc.v2(10, 10); + v.multiply(5);// return Vec2 {x: 50, y: 50}; + ``` + */ + multiplyScalar(num: number): Vec2; + /** + !#en Multiplies two vectors. + !#zh 分量相乘。 + @param vector vector + + @example + ```js + var v = cc.v2(10, 10); + v.multiply(cc.v2(5, 5));// return Vec2 {x: 50, y: 50}; + ``` + */ + multiply(vector: Vec2): Vec2; + /** + !#en Divides by a number. + !#zh 向量除法。 + @param num num + + @example + ```js + var v = cc.v2(10, 10); + v.divide(5); // return Vec2 {x: 2, y: 2}; + ``` + */ + divide(num: number): Vec2; + /** + !#en Negates the components. + !#zh 向量取反。 + + @example + ```js + var v = cc.v2(10, 10); + v.negate(); // return Vec2 {x: -10, y: -10}; + ``` + */ + negate(): Vec2; + /** + !#en Dot product + !#zh 当前向量与指定向量进行点乘。 + @param vector vector + + @example + ```js + var v = cc.v2(10, 10); + v.dot(cc.v2(5, 5)); // return 100; + ``` + */ + dot(vector?: Vec2): number; + /** + !#en Cross product + !#zh 当前向量与指定向量进行叉乘。 + @param vector vector + + @example + ```js + var v = cc.v2(10, 10); + v.cross(cc.v2(5, 5)); // return 0; + ``` + */ + cross(vector?: Vec2): number; + /** + !#en Returns the length of this vector. + !#zh 返回该向量的长度。 + + @example + ```js + var v = cc.v2(10, 10); + v.len(); // return 14.142135623730951; + ``` + */ + len(): number; + /** + !#en Returns the squared length of this vector. + !#zh 返回该向量的长度平方。 + + @example + ```js + var v = cc.v2(10, 10); + v.lengthSqr(); // return 200; + ``` + */ + lengthSqr(): number; + /** + !#en Make the length of this vector to 1. + !#zh 向量归一化,让这个向量的长度为 1。 + + @example + ```js + var v = cc.v2(10, 10); + v.normalizeSelf(); // return Vec2 {x: 0.7071067811865475, y: 0.7071067811865475}; + ``` + */ + normalizeSelf(): Vec2; + /** + !#en + Returns this vector with a magnitude of 1.
+
+ Note that the current vector is unchanged and a new normalized vector is returned. If you want to normalize the current vector, use normalizeSelf function. + !#zh + 返回归一化后的向量。
+
+ 注意,当前向量不变,并返回一个新的归一化向量。如果你想来归一化当前向量,可使用 normalizeSelf 函数。 + @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created + */ + normalize(out?: Vec2): Vec2; + /** + !#en Get angle in radian between this and vector. + !#zh 夹角的弧度。 + @param vector vector + */ + angle(vector: Vec2): number; + /** + !#en Get angle in radian between this and vector with direction. + !#zh 带方向的夹角的弧度。 + @param vector vector + */ + signAngle(vector: Vec2): number; + /** + !#en rotate + !#zh 返回旋转给定弧度后的新向量。 + @param radians radians + @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created + */ + rotate(radians: number, out?: Vec2): Vec2; + /** + !#en rotate self + !#zh 按指定弧度旋转向量。 + @param radians radians + */ + rotateSelf(radians: number): Vec2; + /** + !#en Calculates the projection of the current vector over the given vector. + !#zh 返回当前向量在指定 vector 向量上的投影向量。 + @param vector vector + + @example + ```js + var v1 = cc.v2(20, 20); + var v2 = cc.v2(5, 5); + v1.project(v2); // Vec2 {x: 20, y: 20}; + ``` + */ + project(vector: Vec2): Vec2; + /** + Transforms the vec2 with a mat4. 3rd vector component is implicitly '0', 4th vector component is implicitly '1' + @param m matrix to transform with + @param out the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created + */ + transformMat4(m: Mat4, out?: Vec2): Vec2; + /** + Returns the maximum value in x, y. + */ + maxAxis(): number; + } + /** !#en Representation of 3D vectors and points. + !#zh 表示 3D 向量和坐标 */ + export class Vec3 extends ValueType { + /** + !#en Returns the length of this vector. + !#zh 返回该向量的长度。 + + @example + ```js + var v = cc.v3(10, 10, 10); + v.mag(); // return 17.320508075688775; + ``` + */ + mag(): number; + /** + !#en Returns the squared length of this vector. + !#zh 返回该向量的长度平方。 + */ + magSqr(): number; + /** + !#en Subtracts one vector from this. If you want to save result to another vector, use sub() instead. + !#zh 向量减法。如果你想保存结果到另一个向量,可使用 sub() 代替。 + @param vector vector + */ + subSelf(vector: Vec3): Vec3; + /** + !#en Subtracts one vector from this, and returns the new result. + !#zh 向量减法,并返回新结果。 + @param vector vector + @param out optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created + */ + sub(vector: Vec3, out?: Vec3): Vec3; + /** + !#en Multiplies this by a number. If you want to save result to another vector, use mul() instead. + !#zh 缩放当前向量。如果你想结果保存到另一个向量,可使用 mul() 代替。 + @param num num + */ + mulSelf(num: number): Vec3; + /** + !#en Multiplies by a number, and returns the new result. + !#zh 缩放向量,并返回新结果。 + @param num num + @param out optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created + */ + mul(num: number, out?: Vec3): Vec3; + /** + !#en Divides by a number. If you want to save result to another vector, use div() instead. + !#zh 向量除法。如果你想结果保存到另一个向量,可使用 div() 代替。 + @param num num + */ + divSelf(num: number): Vec3; + /** + !#en Divides by a number, and returns the new result. + !#zh 向量除法,并返回新的结果。 + @param num num + @param out optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created + */ + div(num: number, out?: Vec3): Vec3; + /** + !#en Multiplies two vectors. + !#zh 分量相乘。 + @param vector vector + */ + scaleSelf(vector: Vec3): Vec3; + /** + !#en Multiplies two vectors, and returns the new result. + !#zh 分量相乘,并返回新的结果。 + @param vector vector + @param out optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created + */ + scale(vector: Vec3, out?: Vec3): Vec3; + /** + !#en Negates the components. If you want to save result to another vector, use neg() instead. + !#zh 向量取反。如果你想结果保存到另一个向量,可使用 neg() 代替。 + */ + negSelf(): Vec3; + /** + !#en Negates the components, and returns the new result. + !#zh 返回取反后的新向量。 + @param out optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created + */ + neg(out?: Vec3): Vec3; + /** !#en return a Vec3 object with x = 1, y = 1, z = 1. + !#zh 新 Vec3 对象。 */ + static ONE: Vec3; + /** !#en return a Vec3 object with x = 0, y = 0, z = 0. + !#zh 返回 x = 0,y = 0,z = 0 的 Vec3 对象。 */ + static ZERO: Vec3; + /** !#en return a Vec3 object with x = 0, y = 1, z = 0. + !#zh 返回 x = 0, y = 1, z = 0 的 Vec3 对象。 */ + static UP: Vec3; + /** !#en return a Vec3 object with x = 1, y = 0, z = 0. + !#zh 返回 x = 1,y = 0,z = 0 的 Vec3 对象。 */ + static RIGHT: Vec3; + /** !#en return a Vec3 object with x = 0, y = 0, z = 1. + !#zh 返回 x = 0,y = 0,z = 1 的 Vec3 对象。 */ + static FORWARD: Vec3; + /** + !#zh 将目标赋值为零向量 + !#en The target of an assignment zero vector + */ + static zero (out: Out); + /** + !#zh 获得指定向量的拷贝 + !#en Obtaining copy vectors designated + */ + static clone (a: Out); + /** + !#zh 复制目标向量 + !#en Copy the target vector + */ + static copy (out: Out, a: Vec3Like); + /** + !#zh 设置向量值 + !#en Set to value + */ + static set (out: Out, x: number, y: number, z: number); + /** + !#zh 逐元素向量加法 + !#en Element-wise vector addition + */ + static add (out: Out, a: Out, b: Out); + /** + !#zh 逐元素向量减法 + !#en Element-wise vector subtraction + */ + static subtract (out: Out, a: Out, b: Out); + /** + !#zh 逐元素向量乘法 (分量积) + !#en Element-wise vector multiplication (product component) + */ + static multiply (out: Out, a: Vec3Like_1, b: Vec3Like_2); + /** + !#zh 逐元素向量除法 + !#en Element-wise vector division + */ + static divide (out: Out, a: Out, b: Out); + /** + !#zh 逐元素向量向上取整 + !#en Rounding up by elements of the vector + */ + static ceil (out: Out, a: Out); + /** + !#zh 逐元素向量向下取整 + !#en Element vector by rounding down + */ + static floor (out: Out, a: Out); + /** + !#zh 逐元素向量最小值 + !#en The minimum by-element vector + */ + static min (out: Out, a: Out, b: Out); + /** + !#zh 逐元素向量最大值 + !#en The maximum value of the element-wise vector + */ + static max (out: Out, a: Out, b: Out); + /** + !#zh 逐元素向量四舍五入取整 + !#en Element-wise vector of rounding to whole + */ + static round (out: Out, a: Out); + /** + !#zh 向量标量乘法 + !#en Vector scalar multiplication + */ + static multiplyScalar (out: Out, a: Vec3Like, b: number); + /** + !#zh 逐元素向量乘加: A + B * scale + !#en Element-wise vector multiply add: A + B * scale + */ + static scaleAndAdd (out: Out, a: Out, b: Out, scale: number); + /** + !#zh 求两向量的欧氏距离 + !#en Seeking two vectors Euclidean distance + */ + static distance (a: Out, b: Out); + /** + !#zh 求两向量的欧氏距离平方 + !#en Euclidean distance squared seeking two vectors + */ + static squaredDistance (a: Out, b: Out); + /** + !#zh 求向量长度 + !#en Seeking vector length + */ + static len (a: Out); + /** + !#zh 求向量长度平方 + !#en Seeking squared vector length + */ + static lengthSqr (a: Out); + /** + !#zh 逐元素向量取负 + !#en By taking the negative elements of the vector + */ + static negate (out: Out, a: Out); + /** + !#zh 逐元素向量取倒数,接近 0 时返回 Infinity + !#en Element vector by taking the inverse, return near 0 Infinity + */ + static inverse (out: Out, a: Out); + /** + !#zh 逐元素向量取倒数,接近 0 时返回 0 + !#en Element vector by taking the inverse, return near 0 0 + */ + static inverseSafe (out: Out, a: Out); + /** + !#zh 归一化向量 + !#en Normalized vector + */ + static normalize (out: Out, a: Vec3Like); + /** + !#zh 向量点积(数量积) + !#en Vector dot product (scalar product) + */ + static dot (a: Out, b: Out); + /** + !#zh 向量叉积(向量积) + !#en Vector cross product (vector product) + */ + static cross (out: Out, a: Vec3Like_1, b: Vec3Like_2); + /** + !#zh 逐元素向量线性插值: A + t * (B - A) + !#en Vector element by element linear interpolation: A + t * (B - A) + */ + static lerp (out: Out, a: Out, b: Out, t: number); + /** + !#zh 生成一个在单位球体上均匀分布的随机向量 + !#en Generates a uniformly distributed random vectors on the unit sphere + @param scale 生成的向量长度 + */ + static random (out: Out, scale?: number); + /** + !#zh 向量与四维矩阵乘法,默认向量第四位为 1。 + !#en Four-dimensional vector and matrix multiplication, the default vectors fourth one. + */ + static transformMat4 (out: Out, a: Vec3Like, mat: MatLike); + /** + !#zh 向量与四维矩阵乘法,默认向量第四位为 0。 + !#en Four-dimensional vector and matrix multiplication, vector fourth default is 0. + */ + static transformMat4Normal (out: Out, a: Out, mat: MatLike); + /** + !#zh 向量与三维矩阵乘法 + !#en Dimensional vector matrix multiplication + */ + static transformMat3 (out: Out, a: Out, mat: MatLike); + /** + !#zh 向量四元数乘法 + !#en Vector quaternion multiplication + */ + static transformQuat (out: Out, a: VecLike, q: QuatLike); + /** + !#zh 绕 X 轴旋转向量指定弧度 + !#en Rotation vector specified angle about the X axis + @param v 待旋转向量 + @param o 旋转中心 + @param a 旋转弧度 + */ + static rotateX (out: Out, v: Out, o: Out, a: number); + /** + !#zh 绕 Y 轴旋转向量指定弧度 + !#en Rotation vector specified angle around the Y axis + @param v 待旋转向量 + @param o 旋转中心 + @param a 旋转弧度 + */ + static rotateY (out: Out, v: Out, o: Out, a: number); + /** + !#zh 绕 Z 轴旋转向量指定弧度 + !#en Around the Z axis specified angle vector + @param v 待旋转向量 + @param o 旋转中心 + @param a 旋转弧度 + */ + static rotateZ (out: Out, v: Out, o: Out, a: number); + /** + !#zh 向量等价判断 + !#en Equivalent vectors Analyzing + */ + static strictEquals (a: Out, b: Out); + /** + !#zh 排除浮点数误差的向量近似等价判断 + !#en Negative error vector floating point approximately equivalent Analyzing + */ + static equals (a: Out, b: Out, epsilon = EPSILON); + /** + !#zh 求两向量夹角弧度 + !#en Radian angle between two vectors seek + */ + static angle (a: Out, b: Out); + /** + !#zh 计算向量在指定平面上的投影 + !#en Calculating a projection vector in the specified plane + @param a 待投影向量 + @param n 指定平面的法线 + */ + static projectOnPlane (out: Out, a: Out, n: Out); + /** + !#zh 计算向量在指定向量上的投影 + !#en Projection vector calculated in the vector designated + @param a 待投影向量 + @param n 目标向量 + */ + static project (out: Out, a: Out, b: Out); + /** + !#zh 向量转数组 + !#en Vector transfer array + @param ofs 数组起始偏移量 + */ + static toArray > (out: Out, v: IVec3Like, ofs = 0); + /** + !#zh 数组转向量 + !#en Array steering amount + @param ofs 数组起始偏移量 + */ + static fromArray (out: Out, arr: IWritableArrayLike, ofs = 0); + x: number; + y: number; + z: number; + /** + !#en + Constructor + see {{#crossLink "cc/vec3:method"}}cc.v3{{/crossLink}} + !#zh + 构造函数,可查看 {{#crossLink "cc/vec3:method"}}cc.v3{{/crossLink}} + @param x x + @param y y + @param z z + */ + constructor(x?: Vec3|number, y?: number, z?: number); + /** + !#en clone a Vec3 value + !#zh 克隆一个 Vec3 值 + */ + clone(): Vec3; + /** + !#en Set the current vector value with the given vector. + !#zh 用另一个向量设置当前的向量对象值。 + @param newValue !#en new value to set. !#zh 要设置的新值 + */ + set(newValue: Vec3): Vec3; + /** + !#en Check whether the vector equals another one + !#zh 当前的向量是否与指定的向量相等。 + @param other other + */ + equals(other: Vec3): boolean; + /** + !#en Check whether two vector equal with some degree of variance. + !#zh + 近似判断两个点是否相等。
+ 判断 2 个向量是否在指定数值的范围之内,如果在则返回 true,反之则返回 false。 + @param other other + @param variance variance + */ + fuzzyEquals(other: Vec3, variance: number): boolean; + /** + !#en Transform to string with vector informations + !#zh 转换为方便阅读的字符串。 + */ + toString(): string; + /** + !#en Calculate linear interpolation result between this vector and another one with given ratio + !#zh 线性插值。 + @param to to + @param ratio the interpolation coefficient + @param out optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created + */ + lerp(to: Vec3, ratio: number, out?: Vec3): Vec3; + /** + !#en Clamp the vector between from float and to float. + !#zh + 返回指定限制区域后的向量。
+ 向量大于 max_inclusive 则返回 max_inclusive。
+ 向量小于 min_inclusive 则返回 min_inclusive。
+ 否则返回自身。 + @param min_inclusive min_inclusive + @param max_inclusive max_inclusive + */ + clampf(min_inclusive: Vec3, max_inclusive: Vec3): Vec3; + /** + !#en Adds this vector. If you want to save result to another vector, use add() instead. + !#zh 向量加法。如果你想保存结果到另一个向量,使用 add() 代替。 + @param vector vector + */ + addSelf(vector: Vec3): Vec3; + /** + !#en Adds two vectors, and returns the new result. + !#zh 向量加法,并返回新结果。 + @param vector vector + @param out optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created + */ + add(vector: Vec3, out?: Vec3): Vec3; + /** + !#en Subtracts one vector from this. + !#zh 向量减法。 + @param vector vector + */ + subtract(vector: Vec3): Vec3; + /** + !#en Multiplies this by a number. + !#zh 缩放当前向量。 + @param num num + */ + multiplyScalar(num: number): Vec3; + /** + !#en Multiplies two vectors. + !#zh 分量相乘。 + @param vector vector + */ + multiply(vector: Vec3): Vec3; + /** + !#en Divides by a number. + !#zh 向量除法。 + @param num num + */ + divide(num: number): Vec3; + /** + !#en Negates the components. + !#zh 向量取反。 + */ + negate(): Vec3; + /** + !#en Dot product + !#zh 当前向量与指定向量进行点乘。 + @param vector vector + */ + dot(vector?: Vec3): number; + /** + !#en Cross product + !#zh 当前向量与指定向量进行叉乘。 + @param vector vector + @param out out + */ + cross(vector: Vec3, out?: Vec3): Vec3; + /** + !#en Returns the length of this vector. + !#zh 返回该向量的长度。 + + @example + ```js + var v = cc.v3(10, 10, 10); + v.len(); // return 17.320508075688775; + ``` + */ + len(): number; + /** + !#en Returns the squared length of this vector. + !#zh 返回该向量的长度平方。 + */ + lengthSqr(): number; + /** + !#en Make the length of this vector to 1. + !#zh 向量归一化,让这个向量的长度为 1。 + */ + normalizeSelf(): Vec3; + /** + !#en + Returns this vector with a magnitude of 1.
+
+ Note that the current vector is unchanged and a new normalized vector is returned. If you want to normalize the current vector, use normalizeSelf function. + !#zh + 返回归一化后的向量。
+
+ 注意,当前向量不变,并返回一个新的归一化向量。如果你想来归一化当前向量,可使用 normalizeSelf 函数。 + @param out optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created + */ + normalize(out?: Vec3): Vec3; + /** + Transforms the vec3 with a mat4. 4th vector component is implicitly '1' + @param m matrix to transform with + @param out the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created + */ + transformMat4(m: Mat4, out?: Vec3): Vec3; + /** + Returns the maximum value in x, y, and z + */ + maxAxis(): number; + /** + !#en Get angle in radian between this and vector. + !#zh 夹角的弧度。 + @param vector vector + */ + angle(vector: Vec3): number; + /** + !#en Calculates the projection of the current vector over the given vector. + !#zh 返回当前向量在指定 vector 向量上的投影向量。 + @param vector vector + + @example + ```js + var v1 = cc.v3(20, 20, 20); + var v2 = cc.v3(5, 5, 5); + v1.project(v2); // Vec3 {x: 20, y: 20, z: 20}; + ``` + */ + project(vector: Vec3): Vec3; + /** + !#en Get angle in radian between this and vector with direction.
+ In order to compatible with the vec2 API. + !#zh 带方向的夹角的弧度。该方法仅用做兼容 2D 计算。 + @param vector vector + */ + signAngle(vector: Vec3|Vec2): number; + /** + !#en rotate. In order to compatible with the vec2 API. + !#zh 返回旋转给定弧度后的新向量。该方法仅用做兼容 2D 计算。 + @param radians radians + @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created + */ + rotate(radians: number, out?: Vec3): Vec2; + /** + !#en rotate self. In order to compatible with the vec2 API. + !#zh 按指定弧度旋转向量。该方法仅用做兼容 2D 计算。 + @param radians radians + */ + rotateSelf(radians: number): Vec3; + } + /** !#en Representation of 3D vectors and points. + !#zh 表示 3D 向量和坐标 */ + export class Vec4 extends ValueType { + /** + !#en Subtracts one vector from this. If you want to save result to another vector, use sub() instead. + !#zh 向量减法。如果你想保存结果到另一个向量,可使用 sub() 代替。 + @param vector vector + */ + subSelf(vector: Vec4): Vec4; + /** + !#en Subtracts one vector from this, and returns the new result. + !#zh 向量减法,并返回新结果。 + @param vector vector + @param out optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created + */ + sub(vector: Vec4, out?: Vec4): Vec4; + /** + !#en Multiplies this by a number. If you want to save result to another vector, use mul() instead. + !#zh 缩放当前向量。如果你想结果保存到另一个向量,可使用 mul() 代替。 + @param num num + */ + mulSelf(num: number): Vec4; + /** + !#en Multiplies by a number, and returns the new result. + !#zh 缩放向量,并返回新结果。 + @param num num + @param out optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created + */ + mul(num: number, out?: Vec4): Vec4; + /** + !#en Divides by a number. If you want to save result to another vector, use div() instead. + !#zh 向量除法。如果你想结果保存到另一个向量,可使用 div() 代替。 + @param num num + */ + divSelf(num: number): Vec4; + /** + !#en Divides by a number, and returns the new result. + !#zh 向量除法,并返回新的结果。 + @param num num + @param out optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created + */ + div(num: number, out?: Vec4): Vec4; + /** + !#en Multiplies two vectors. + !#zh 分量相乘。 + @param vector vector + */ + scaleSelf(vector: Vec4): Vec4; + /** + !#en Multiplies two vectors, and returns the new result. + !#zh 分量相乘,并返回新的结果。 + @param vector vector + @param out optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created + */ + scale(vector: Vec4, out?: Vec4): Vec4; + /** + !#en Negates the components. If you want to save result to another vector, use neg() instead. + !#zh 向量取反。如果你想结果保存到另一个向量,可使用 neg() 代替。 + */ + negSelf(): Vec4; + /** + !#en Negates the components, and returns the new result. + !#zh 返回取反后的新向量。 + @param out optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created + */ + neg(out?: Vec4): Vec4; + /** + !#zh 获得指定向量的拷贝 + !#en Obtaining copy vectors designated + */ + static clone (a: Out); + /** + !#zh 复制目标向量 + !#en Copy the target vector + */ + static copy (out: Out, a: Out); + /** + !#zh 设置向量值 + !#en Set to value + */ + static set (out: Out, x: number, y: number, z: number, w: number); + /** + !#zh 逐元素向量加法 + !#en Element-wise vector addition + */ + static add (out: Out, a: Out, b: Out); + /** + !#zh 逐元素向量减法 + !#en Element-wise vector subtraction + */ + static subtract (out: Out, a: Out, b: Out); + /** + !#zh 逐元素向量乘法 + !#en Element-wise vector multiplication + */ + static multiply (out: Out, a: Out, b: Out); + /** + !#zh 逐元素向量除法 + !#en Element-wise vector division + */ + static divide (out: Out, a: Out, b: Out); + /** + !#zh 逐元素向量向上取整 + !#en Rounding up by elements of the vector + */ + static ceil (out: Out, a: Out); + /** + !#zh 逐元素向量向下取整 + !#en Element vector by rounding down + */ + static floor (out: Out, a: Out); + /** + !#zh 逐元素向量最小值 + !#en The minimum by-element vector + */ + static min (out: Out, a: Out, b: Out); + /** + !#zh 逐元素向量最大值 + !#en The maximum value of the element-wise vector + */ + static max (out: Out, a: Out, b: Out); + /** + !#zh 逐元素向量四舍五入取整 + !#en Element-wise vector of rounding to whole + */ + static round (out: Out, a: Out); + /** + !#zh 向量标量乘法 + !#en Vector scalar multiplication + */ + static multiplyScalar (out: Out, a: Out, b: number); + /** + !#zh 逐元素向量乘加: A + B * scale + !#en Element-wise vector multiply add: A + B * scale + */ + static scaleAndAdd (out: Out, a: Out, b: Out, scale: number); + /** + !#zh 求两向量的欧氏距离 + !#en Seeking two vectors Euclidean distance + */ + static distance (a: Out, b: Out); + /** + !#zh 求两向量的欧氏距离平方 + !#en Euclidean distance squared seeking two vectors + */ + static squaredDistance (a: Out, b: Out); + /** + !#zh 求向量长度 + !#en Seeking vector length + */ + static len (a: Out); + /** + !#zh 求向量长度平方 + !#en Seeking squared vector length + */ + static lengthSqr (a: Out); + /** + !#zh 逐元素向量取负 + !#en By taking the negative elements of the vector + */ + static negate (out: Out, a: Out); + /** + !#zh 逐元素向量取倒数,接近 0 时返回 Infinity + !#en Element vector by taking the inverse, return near 0 Infinity + */ + static inverse (out: Out, a: Out); + /** + !#zh 逐元素向量取倒数,接近 0 时返回 0 + !#en Element vector by taking the inverse, return near 0 0 + */ + static inverseSafe (out: Out, a: Out); + /** + !#zh 归一化向量 + !#en Normalized vector + */ + static normalize (out: Out, a: Out); + /** + !#zh 向量点积(数量积) + !#en Vector dot product (scalar product) + */ + static dot (a: Out, b: Out); + /** + !#zh 逐元素向量线性插值: A + t * (B - A) + !#en Vector element by element linear interpolation: A + t * (B - A) + */ + static lerp (out: Out, a: Out, b: Out, t: number); + /** + !#zh 生成一个在单位球体上均匀分布的随机向量 + !#en Generates a uniformly distributed random vectors on the unit sphere + @param scale 生成的向量长度 + */ + static random (out: Out, scale?: number); + /** + !#zh 向量矩阵乘法 + !#en Vector matrix multiplication + */ + static transformMat4 (out: Out, a: Out, mat: MatLike); + /** + !#zh 向量四元数乘法 + !#en Vector quaternion multiplication + */ + static transformQuat (out: Out, a: Out, q: QuatLike); + /** + !#zh 向量等价判断 + !#en Equivalent vectors Analyzing + */ + static strictEquals (a: Out, b: Out); + /** + !#zh 排除浮点数误差的向量近似等价判断 + !#en Negative error vector floating point approximately equivalent Analyzing + */ + static equals (a: Out, b: Out, epsilon = EPSILON); + /** + !#zh 向量转数组 + !#en Vector transfer array + @param ofs 数组起始偏移量 + */ + static toArray > (out: Out, v: IVec4Like, ofs = 0); + /** + !#zh 数组转向量 + !#en Array steering amount + @param ofs 数组起始偏移量 + */ + static fromArray (out: Out, arr: IWritableArrayLike, ofs = 0); + x: number; + y: number; + z: number; + w: number; + /** + !#en + Constructor + see {{#crossLink "cc/vec4:method"}}cc.v4{{/crossLink}} + !#zh + 构造函数,可查看 {{#crossLink "cc/vec4:method"}}cc.v4{{/crossLink}} + @param x x + @param y y + @param z z + @param w w + */ + constructor(x?: number, y?: number, z?: number, w?: number); + /** + !#en clone a Vec4 value + !#zh 克隆一个 Vec4 值 + */ + clone(): Vec4; + /** + !#en Set the current vector value with the given vector. + !#zh 用另一个向量设置当前的向量对象值。 + @param newValue !#en new value to set. !#zh 要设置的新值 + */ + set(newValue: Vec4): Vec4; + /** + !#en Check whether the vector equals another one + !#zh 当前的向量是否与指定的向量相等。 + @param other other + @param epsilon epsilon + */ + equals(other: Vec4, epsilon?: number): boolean; + /** + !#en Check whether the vector equals another one + !#zh 判断当前向量是否在误差范围内与指定分量的向量相等。 + @param x 相比较的向量的 x 分量。 + @param y 相比较的向量的 y 分量。 + @param z 相比较的向量的 z 分量。 + @param w 相比较的向量的 w 分量。 + @param epsilon 允许的误差,应为非负数。 + */ + equals4f(x: number, y: number, z: number, w: number, epsilon?: number): boolean; + /** + !#en Check whether strict equals other Vec4 + !#zh 判断当前向量是否与指定向量相等。两向量的各分量都分别相等时返回 `true`;否则返回 `false`。 + @param other 相比较的向量。 + */ + strictEquals(other: Vec4): boolean; + /** + !#en Check whether strict equals other Vec4 + !#zh 判断当前向量是否与指定分量的向量相等。两向量的各分量都分别相等时返回 `true`;否则返回 `false`。 + @param x 指定向量的 x 分量。 + @param y 指定向量的 y 分量。 + @param z 指定向量的 z 分量。 + @param w 指定向量的 w 分量。 + */ + strictEquals4f(x: number, y: number, z: number, w: number): boolean; + /** + !#en Calculate linear interpolation result between this vector and another one with given ratio + !#zh 根据指定的插值比率,从当前向量到目标向量之间做插值。 + @param to 目标向量。 + @param ratio 插值比率,范围为 [0,1]。 + */ + lerp(to: Vec4, ratio: number): Vec4; + /** + !#en Transform to string with vector informations + !#zh 返回当前向量的字符串表示。 + */ + toString(): string; + /** + !#en Clamp the vector between minInclusive and maxInclusive. + !#zh 设置当前向量的值,使其各个分量都处于指定的范围内。 + @param minInclusive 每个分量都代表了对应分量允许的最小值。 + @param maxInclusive 每个分量都代表了对应分量允许的最大值。 + */ + clampf(minInclusive: Vec4, maxInclusive: Vec4): Vec4; + /** + !#en Adds this vector. If you want to save result to another vector, use add() instead. + !#zh 向量加法。如果你想保存结果到另一个向量,使用 add() 代替。 + @param vector vector + */ + addSelf(vector: Vec4): Vec4; + /** + !#en Adds two vectors, and returns the new result. + !#zh 向量加法,并返回新结果。 + @param vector vector + @param out optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created + */ + add(vector: Vec4, out?: Vec4): Vec4; + /** + !#en Subtracts one vector from this, and returns the new result. + !#zh 向量减法,并返回新结果。 + @param vector vector + @param out optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created + */ + subtract(vector: Vec4, out?: Vec4): Vec4; + /** + !#en Multiplies this by a number. + !#zh 缩放当前向量。 + @param num num + */ + multiplyScalar(num: number): Vec4; + /** + !#en Multiplies two vectors. + !#zh 分量相乘。 + @param vector vector + */ + multiply(vector: Vec4): Vec4; + /** + !#en Divides by a number. + !#zh 向量除法。 + @param num num + */ + divide(num: number): Vec4; + /** + !#en Negates the components. + !#zh 向量取反 + */ + negate(): Vec4; + /** + !#en Dot product + !#zh 当前向量与指定向量进行点乘。 + @param vector vector + */ + dot(vector?: Vec4): number; + /** + !#en Cross product + !#zh 当前向量与指定向量进行叉乘。 + @param vector vector + @param out out + */ + cross(vector: Vec4, out?: Vec4): Vec4; + /** + !#en Returns the length of this vector. + !#zh 返回该向量的长度。 + + @example + ```js + var v = cc.v4(10, 10); + v.len(); // return 14.142135623730951; + ``` + */ + len(): number; + /** + !#en Returns the squared length of this vector. + !#zh 返回该向量的长度平方。 + */ + lengthSqr(): number; + /** + !#en Make the length of this vector to 1. + !#zh 向量归一化,让这个向量的长度为 1。 + */ + normalizeSelf(): Vec4; + /** + !#en + Returns this vector with a magnitude of 1.
+
+ Note that the current vector is unchanged and a new normalized vector is returned. If you want to normalize the current vector, use normalizeSelf function. + !#zh + 返回归一化后的向量。
+
+ 注意,当前向量不变,并返回一个新的归一化向量。如果你想来归一化当前向量,可使用 normalizeSelf 函数。 + @param out optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created + */ + normalize(out?: Vec4): Vec4; + /** + Transforms the vec4 with a mat4. 4th vector component is implicitly '1' + @param m matrix to transform with + @param out the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created + */ + transformMat4(m: Mat4, out?: Vec4): Vec4; + /** + Returns the maximum value in x, y, z, w. + */ + maxAxis(): number; + } + /** !#en the device accelerometer reports values for each axis in units of g-force. + !#zh 设备重力传感器传递的各个轴的数据。 */ + export class constructor { + /** + whether enable accelerometer event + @param isEnable isEnable + */ + setAccelerometerEnabled(isEnable: boolean): void; + /** + set accelerometer interval value + @param interval interval + */ + setAccelerometerInterval(interval: number): void; + } + /** Predefined constants */ + export class macro { + /** PI / 180 */ + static RAD: number; + /** One degree */ + static DEG: number; + static REPEAT_FOREVER: number; + static FLT_EPSILON: number; + /** Minimum z index value for node */ + static MIN_ZINDEX: number; + /** Maximum z index value for node */ + static MAX_ZINDEX: number; + static ONE: number; + static ZERO: number; + static SRC_ALPHA: number; + static SRC_ALPHA_SATURATE: number; + static SRC_COLOR: number; + static DST_ALPHA: number; + static DST_COLOR: number; + static ONE_MINUS_SRC_ALPHA: number; + static ONE_MINUS_SRC_COLOR: number; + static ONE_MINUS_DST_ALPHA: number; + static ONE_MINUS_DST_COLOR: number; + static ONE_MINUS_CONSTANT_ALPHA: number; + static ONE_MINUS_CONSTANT_COLOR: number; + /** Oriented vertically */ + static ORIENTATION_PORTRAIT: number; + /** Oriented horizontally */ + static ORIENTATION_LANDSCAPE: number; + /** Oriented automatically */ + static ORIENTATION_AUTO: number; + /**

+ If enabled, the texture coordinates will be calculated by using this formula:
+ - texCoord.left = (rect.x*2+1) / (texture.wide*2);
+ - texCoord.right = texCoord.left + (rect.width*2-2)/(texture.wide*2);
+
+ The same for bottom and top.
+
+ This formula prevents artifacts by using 99% of the texture.
+ The "correct" way to prevent artifacts is by expand the texture's border with the same color by 1 pixel
+
+ Affected component:
+ - cc.TMXLayer
+
+ Enabled by default. To disabled set it to 0.
+ To modify it, in Web engine please refer to CCMacro.js, in JSB please refer to CCConfig.h +

*/ + static FIX_ARTIFACTS_BY_STRECHING_TEXEL_TMX: number; + /** Position of the FPS (Default: 0,0 (bottom-left corner))
+ To modify it, in Web engine please refer to CCMacro.js, in JSB please refer to CCConfig.h */ + static DIRECTOR_STATS_POSITION: Vec2; + /**

+ If enabled, actions that alter the position property (eg: CCMoveBy, CCJumpBy, CCBezierBy, etc..) will be stacked.
+ If you run 2 or more 'position' actions at the same time on a node, then end position will be the sum of all the positions.
+ If disabled, only the last run action will take effect. +

*/ + static ENABLE_STACKABLE_ACTIONS: number; + /** !#en + The timeout to determine whether a touch is no longer active and should be removed. + The reason to add this timeout is due to an issue in X5 browser core, + when X5 is presented in wechat on Android, if a touch is glissed from the bottom up, and leave the page area, + no touch cancel event is triggered, and the touch will be considered active forever. + After multiple times of this action, our maximum touches number will be reached and all new touches will be ignored. + So this new mechanism can remove the touch that should be inactive if it's not updated during the last 5000 milliseconds. + Though it might remove a real touch if it's just not moving for the last 5 seconds which is not easy with the sensibility of mobile touch screen. + You can modify this value to have a better behavior if you find it's not enough. + !#zh + 用于甄别一个触点对象是否已经失效并且可以被移除的延时时长 + 添加这个时长的原因是 X5 内核在微信浏览器中出现的一个 bug。 + 在这个环境下,如果用户将一个触点从底向上移出页面区域,将不会触发任何 touch cancel 或 touch end 事件,而这个触点会被永远当作停留在页面上的有效触点。 + 重复这样操作几次之后,屏幕上的触点数量将达到我们的事件系统所支持的最高触点数量,之后所有的触摸事件都将被忽略。 + 所以这个新的机制可以在触点在一定时间内没有任何更新的情况下视为失效触点并从事件系统中移除。 + 当然,这也可能移除一个真实的触点,如果用户的触点真的在一定时间段内完全没有移动(这在当前手机屏幕的灵敏度下会很难)。 + 你可以修改这个值来获得你需要的效果,默认值是 5000 毫秒。 */ + static TOUCH_TIMEOUT: number; + /** !#en + The maximum vertex count for a single batched draw call. + !#zh + 最大可以被单次批处理渲染的顶点数量。 */ + static BATCH_VERTEX_COUNT: number; + /** !#en + Whether or not enabled tiled map auto culling. If you set the TiledMap skew or rotation, then need to manually disable this, otherwise, the rendering will be wrong. + !#zh + 是否开启瓦片地图的自动裁减功能。瓦片地图如果设置了 skew, rotation 或者采用了摄像机的话,需要手动关闭,否则渲染会出错。 */ + static ENABLE_TILEDMAP_CULLING: boolean; + /** !#en + The max concurrent task number for the downloader + !#zh + 下载任务的最大并发数限制,在安卓平台部分机型或版本上可能需要限制在较低的水平 */ + static DOWNLOAD_MAX_CONCURRENT: number; + /** !#en + Boolean that indicates if the canvas contains an alpha channel, default sets to false for better performance. + Though if you want to make your canvas background transparent and show other dom elements at the background, + you can set it to true before `cc.game.run`. + Web only. + !#zh + 用于设置 Canvas 背景是否支持 alpha 通道,默认为 false,这样可以有更高的性能表现。 + 如果你希望 Canvas 背景是透明的,并显示背后的其他 DOM 元素,你可以在 `cc.game.run` 之前将这个值设为 true。 + 仅支持 Web */ + static ENABLE_TRANSPARENT_CANVAS: boolean; + /** !#en + Boolean that indicates if the WebGL context is created with `antialias` option turned on, default value is false. + Set it to true could make your game graphics slightly smoother, like texture hard edges when rotated. + Whether to use this really depend on your game design and targeted platform, + device with retina display usually have good detail on graphics with or without this option, + you probably don't want antialias if your game style is pixel art based. + Also, it could have great performance impact with some browser / device using software MSAA. + You can set it to true before `cc.game.run`. + Web only. + !#zh + 用于设置在创建 WebGL Context 时是否开启抗锯齿选项,默认值是 false。 + 将这个选项设置为 true 会让你的游戏画面稍稍平滑一些,比如旋转硬边贴图时的锯齿。是否开启这个选项很大程度上取决于你的游戏和面向的平台。 + 在大多数拥有 retina 级别屏幕的设备上用户往往无法区分这个选项带来的变化;如果你的游戏选择像素艺术风格,你也多半不会想开启这个选项。 + 同时,在少部分使用软件级别抗锯齿算法的设备或浏览器上,这个选项会对性能产生比较大的影响。 + 你可以在 `cc.game.run` 之前设置这个值,否则它不会生效。 + 仅支持 Web */ + static ENABLE_WEBGL_ANTIALIAS: boolean; + /** !#en + Whether or not enable auto culling. + This feature have been removed in v2.0 new renderer due to overall performance consumption. + We have no plan currently to re-enable auto culling. + If your game have more dynamic objects, we suggest to disable auto culling. + If your game have more static objects, we suggest to enable auto culling. + !#zh + 是否开启自动裁减功能,开启裁减功能将会把在屏幕外的物体从渲染队列中去除掉。 + 这个功能在 v2.0 的新渲染器中被移除了,因为它在大多数游戏中所带来的损耗要高于性能的提升,目前我们没有计划重新支持自动裁剪。 + 如果游戏中的动态物体比较多的话,建议将此选项关闭。 + 如果游戏中的静态物体比较多的话,建议将此选项打开。 */ + static ENABLE_CULLING: boolean; + /** !#en + Whether to clear the original image cache after uploaded a texture to GPU. If cleared, [Dynamic Atlas](https://docs.cocos.com/creator/manual/en/advanced-topics/dynamic-atlas.html) will not be supported. + Normally you don't need to enable this option on the web platform, because Image object doesn't consume too much memory. + But on WeChat Game platform, the current version cache decoded data in Image object, which has high memory usage. + So we enabled this option by default on WeChat, so that we can release Image cache immediately after uploaded to GPU. + !#zh + 是否在将贴图上传至 GPU 之后删除原始图片缓存,删除之后图片将无法进行 [动态合图](https://docs.cocos.com/creator/manual/zh/advanced-topics/dynamic-atlas.html)。 + 在 Web 平台,你通常不需要开启这个选项,因为在 Web 平台 Image 对象所占用的内存很小。 + 但是在微信小游戏平台的当前版本,Image 对象会缓存解码后的图片数据,它所占用的内存空间很大。 + 所以我们在微信平台默认开启了这个选项,这样我们就可以在上传 GL 贴图之后立即释放 Image 对象的内存,避免过高的内存占用。 */ + static CLEANUP_IMAGE_CACHE: boolean; + /** !#en + Whether or not show mesh wire frame. + !#zh + 是否显示网格的线框。 */ + static SHOW_MESH_WIREFRAME: boolean; + /** !#en + Whether or not show mesh normal. + !#zh + 是否显示网格的法线。 */ + static SHOW_MESH_NORMAL: boolean; + /** !#en + Whether to enable multi-touch. + !#zh + 是否开启多点触摸 */ + static ENABLE_MULTI_TOUCH: boolean; + /** !#en + The image format supported by the engine defaults, and the supported formats may differ in different build platforms and device types. + Currently all platform and device support ['.webp', '.jpg', '.jpeg', '.bmp', '.png'], The iOS mobile platform also supports the PVR format。 + !#zh + 引擎默认支持的图片格式,支持的格式可能在不同的构建平台和设备类型上有所差别。 + 目前所有平台和设备支持的格式有 ['.webp', '.jpg', '.jpeg', '.bmp', '.png']. 另外 Ios 手机平台还额外支持了 PVR 格式。 */ + static SUPPORT_TEXTURE_FORMATS: string[]; + } + /** undefined */ + export enum VerticalTextAlignment { + TOP = 0, + CENTER = 0, + BOTTOM = 0, + } + /** The base class of most of all the objects in Fireball. */ + export class Object { + /** !#en The name of the object. + !#zh 该对象的名称。 */ + name: string; + /** !#en + Indicates whether the object is not yet destroyed. (It will not be available after being destroyed)
+ When an object's `destroy` is called, it is actually destroyed after the end of this frame. + So `isValid` will return false from the next frame, while `isValid` in the current frame will still be true. + If you want to determine whether the current frame has called `destroy`, use `cc.isValid(obj, true)`, + but this is often caused by a particular logical requirements, which is not normally required. + + !#zh + 表示该对象是否可用(被 destroy 后将不可用)。
+ 当一个对象的 `destroy` 调用以后,会在这一帧结束后才真正销毁。因此从下一帧开始 `isValid` 就会返回 false,而当前帧内 `isValid` 仍然会是 true。如果希望判断当前帧是否调用过 `destroy`,请使用 `cc.isValid(obj, true)`,不过这往往是特殊的业务需求引起的,通常情况下不需要这样。 */ + isValid: boolean; + /** + !#en + Destroy this Object, and release all its own references to other objects.
+ Actual object destruction will delayed until before rendering. + From the next frame, this object is not usable any more. + You can use cc.isValid(obj) to check whether the object is destroyed before accessing it. + !#zh + 销毁该对象,并释放所有它对其它对象的引用。
+ 实际销毁操作会延迟到当前帧渲染前执行。从下一帧开始,该对象将不再可用。 + 您可以在访问对象之前使用 cc.isValid(obj) 来检查对象是否已被销毁。 + + @example + ```js + obj.destroy(); + ``` + */ + destroy(): boolean; + } + /** Bit mask that controls object states. */ + export enum Flags { + DontSave = 0, + EditorOnly = 0, + HideInHierarchy = 0, + } + /** The fullscreen API provides an easy way for web content to be presented using the user's entire screen. + It's invalid on safari, QQbrowser and android browser */ + export class screen { + /** + initialize + */ + init(): void; + /** + return true if it's full now. + */ + fullScreen(): boolean; + /** + change the screen to full mode. + @param element element + @param onFullScreenChange onFullScreenChange + @param onFullScreenError onFullScreenError + */ + requestFullScreen(element: Element, onFullScreenChange: Function, onFullScreenError: Function): void; + /** + exit the full mode. + */ + exitFullScreen(): boolean; + /** + Automatically request full screen with a touch/click event + @param element element + @param onFullScreenChange onFullScreenChange + */ + autoFullScreen(element: Element, onFullScreenChange: Function): void; + } + /** System variables */ + export class sys { + /** English language code */ + static LANGUAGE_ENGLISH: string; + /** Chinese language code */ + static LANGUAGE_CHINESE: string; + /** French language code */ + static LANGUAGE_FRENCH: string; + /** Italian language code */ + static LANGUAGE_ITALIAN: string; + /** German language code */ + static LANGUAGE_GERMAN: string; + /** Spanish language code */ + static LANGUAGE_SPANISH: string; + /** Spanish language code */ + static LANGUAGE_DUTCH: string; + /** Russian language code */ + static LANGUAGE_RUSSIAN: string; + /** Korean language code */ + static LANGUAGE_KOREAN: string; + /** Japanese language code */ + static LANGUAGE_JAPANESE: string; + /** Hungarian language code */ + static LANGUAGE_HUNGARIAN: string; + /** Portuguese language code */ + static LANGUAGE_PORTUGUESE: string; + /** Arabic language code */ + static LANGUAGE_ARABIC: string; + /** Norwegian language code */ + static LANGUAGE_NORWEGIAN: string; + /** Polish language code */ + static LANGUAGE_POLISH: string; + /** Turkish language code */ + static LANGUAGE_TURKISH: string; + /** Ukrainian language code */ + static LANGUAGE_UKRAINIAN: string; + /** Romanian language code */ + static LANGUAGE_ROMANIAN: string; + /** Bulgarian language code */ + static LANGUAGE_BULGARIAN: string; + /** Unknown language code */ + static LANGUAGE_UNKNOWN: string; + static OS_IOS: string; + static OS_ANDROID: string; + static OS_WINDOWS: string; + static OS_MARMALADE: string; + static OS_LINUX: string; + static OS_BADA: string; + static OS_BLACKBERRY: string; + static OS_OSX: string; + static OS_WP8: string; + static OS_WINRT: string; + static OS_UNKNOWN: string; + static UNKNOWN: number; + static WIN32: number; + static LINUX: number; + static MACOS: number; + static ANDROID: number; + static IPHONE: number; + static IPAD: number; + static BLACKBERRY: number; + static NACL: number; + static EMSCRIPTEN: number; + static TIZEN: number; + static WINRT: number; + static WP8: number; + static MOBILE_BROWSER: number; + static DESKTOP_BROWSER: number; + /** Indicates whether executes in editor's window process (Electron's renderer context) */ + static EDITOR_PAGE: number; + /** Indicates whether executes in editor's main process (Electron's browser context) */ + static EDITOR_CORE: number; + static WECHAT_GAME: number; + static QQ_PLAY: number; + static FB_PLAYABLE_ADS: number; + static BAIDU_GAME: number; + static VIVO_GAME: number; + static OPPO_GAME: number; + static HUAWEI_GAME: number; + static XIAOMI_GAME: number; + static JKW_GAME: number; + static ALIPAY_GAME: number; + static WECHAT_GAME_SUB: number; + static BAIDU_GAME_SUB: number; + static QTT_GAME: number; + /** BROWSER_TYPE_WECHAT */ + static BROWSER_TYPE_WECHAT: string; + /** BROWSER_TYPE_WECHAT_GAME */ + static BROWSER_TYPE_WECHAT_GAME: string; + /** BROWSER_TYPE_WECHAT_GAME_SUB */ + static BROWSER_TYPE_WECHAT_GAME_SUB: string; + /** BROWSER_TYPE_BAIDU_GAME */ + static BROWSER_TYPE_BAIDU_GAME: string; + /** BROWSER_TYPE_BAIDU_GAME_SUB */ + static BROWSER_TYPE_BAIDU_GAME_SUB: string; + /** BROWSER_TYPE_XIAOMI_GAME */ + static BROWSER_TYPE_XIAOMI_GAME: string; + /** BROWSER_TYPE_ALIPAY_GAME */ + static BROWSER_TYPE_ALIPAY_GAME: string; + /** BROWSER_TYPE_QQ_PLAY */ + static BROWSER_TYPE_QQ_PLAY: string; + static BROWSER_TYPE_ANDROID: string; + static BROWSER_TYPE_IE: string; + static BROWSER_TYPE_EDGE: string; + static BROWSER_TYPE_QQ: string; + static BROWSER_TYPE_MOBILE_QQ: string; + static BROWSER_TYPE_UC: string; + /** uc third party integration. */ + static BROWSER_TYPE_UCBS: string; + static BROWSER_TYPE_360: string; + static BROWSER_TYPE_BAIDU_APP: string; + static BROWSER_TYPE_BAIDU: string; + static BROWSER_TYPE_MAXTHON: string; + static BROWSER_TYPE_OPERA: string; + static BROWSER_TYPE_OUPENG: string; + static BROWSER_TYPE_MIUI: string; + static BROWSER_TYPE_FIREFOX: string; + static BROWSER_TYPE_SAFARI: string; + static BROWSER_TYPE_CHROME: string; + static BROWSER_TYPE_LIEBAO: string; + static BROWSER_TYPE_QZONE: string; + static BROWSER_TYPE_SOUGOU: string; + static BROWSER_TYPE_UNKNOWN: string; + /** Is native ? This is set to be true in jsb auto. */ + static isNative: boolean; + /** Is web browser ? */ + static isBrowser: boolean; + /** + Is webgl extension support? + @param name name + */ + static glExtension(name: any): void; + /** + Get max joint matrix size for skinned mesh renderer. + */ + static getMaxJointMatrixSize(): void; + /** Indicate whether system is mobile system */ + static isMobile: boolean; + /** Indicate the running platform */ + static platform: number; + /** Get current language iso 639-1 code. + Examples of valid language codes include "zh-tw", "en", "en-us", "fr", "fr-fr", "es-es", etc. + The actual value totally depends on results provided by destination platform. */ + static languageCode: string; + /** Indicate the current language of the running system */ + static language: string; + /** Indicate the running os name */ + static os: string; + /** Indicate the running os version */ + static osVersion: string; + /** Indicate the running os main version */ + static osMainVersion: number; + /** Indicate the running browser type */ + static browserType: string; + /** Indicate the running browser version */ + static browserVersion: string; + /** Indicate the real pixel resolution of the whole game window */ + static windowPixelResolution: Size; + /** cc.sys.localStorage is a local storage component. */ + static localStorage: any; + /** The capabilities of the current platform */ + static capabilities: any; + /** + !#en + Get the network type of current device, return cc.sys.NetworkType.LAN if failure. + !#zh + 获取当前设备的网络类型, 如果网络类型无法获取,默认将返回 cc.sys.NetworkType.LAN + */ + static getNetworkType(): sys.NetworkType; + /** + !#en + Get the battery level of current device, return 1.0 if failure. + !#zh + 获取当前设备的电池电量,如果电量无法获取,默认将返回 1 + */ + static getBatteryLevel(): number; + /** + Forces the garbage collection, only available in JSB + */ + static garbageCollect(): void; + /** + Restart the JS VM, only available in JSB + */ + static restartVM(): void; + /** + !#en + Return the safe area rect.
+ only available on the iOS native platform, otherwise it will return a rect with design resolution size. + !#zh + 返回手机屏幕安全区域,目前仅在 iOS 原生平台有效。其它平台将默认返回设计分辨率尺寸。 + */ + static getSafeAreaRect(): Rect; + /** + Check whether an object is valid, + In web engine, it will return true if the object exist + In native engine, it will return true if the JS object and the correspond native object are both valid + @param obj obj + */ + static isObjectValid(obj: any): boolean; + /** + Dump system informations + */ + static dump(): void; + /** + Open a url in browser + @param url url + */ + static openURL(url: string): void; + /** + Get the number of milliseconds elapsed since 1 January 1970 00:00:00 UTC. + */ + static now(): number; + } + /** cc.view is the singleton object which represents the game window.
+ It's main task include:
+ - Apply the design resolution policy
+ - Provide interaction with the window, like resize event on web, retina display support, etc...
+ - Manage the game view port which can be different with the window
+ - Manage the content scale and translation
+
+ Since the cc.view is a singleton, you don't need to call any constructor or create functions,
+ the standard way to use it is by calling:
+ - cc.view.methodName();
*/ + export class View extends EventTarget { + /** + !#en + Sets view's target-densitydpi for android mobile browser. it can be set to:
+ 1. cc.macro.DENSITYDPI_DEVICE, value is "device-dpi"
+ 2. cc.macro.DENSITYDPI_HIGH, value is "high-dpi" (default value)
+ 3. cc.macro.DENSITYDPI_MEDIUM, value is "medium-dpi" (browser's default value)
+ 4. cc.macro.DENSITYDPI_LOW, value is "low-dpi"
+ 5. Custom value, e.g: "480"
+ !#zh 设置目标内容的每英寸像素点密度。 + @param densityDPI densityDPI + */ + setTargetDensityDPI(densityDPI: string): void; + /** + !#en + Returns the current target-densitydpi value of cc.view. + !#zh 获取目标内容的每英寸像素点密度。 + */ + getTargetDensityDPI(): string; + /** + !#en + Sets whether resize canvas automatically when browser's size changed.
+ Useful only on web. + !#zh 设置当发现浏览器的尺寸改变时,是否自动调整 canvas 尺寸大小。 + 仅在 Web 模式下有效。 + @param enabled Whether enable automatic resize with browser's resize event + */ + resizeWithBrowserSize(enabled: boolean): void; + /** + !#en + Sets the callback function for cc.view's resize action,
+ this callback will be invoked before applying resolution policy,
+ so you can do any additional modifications within the callback.
+ Useful only on web. + !#zh 设置 cc.view 调整视窗尺寸行为的回调函数, + 这个回调函数会在应用适配模式之前被调用, + 因此你可以在这个回调函数内添加任意附加改变, + 仅在 Web 平台下有效。 + @param callback The callback function + */ + setResizeCallback(callback: Function|void): void; + /** + !#en + Sets the orientation of the game, it can be landscape, portrait or auto. + When set it to landscape or portrait, and screen w/h ratio doesn't fit, + cc.view will automatically rotate the game canvas using CSS. + Note that this function doesn't have any effect in native, + in native, you need to set the application orientation in native project settings + !#zh 设置游戏屏幕朝向,它能够是横版,竖版或自动。 + 当设置为横版或竖版,并且屏幕的宽高比例不匹配时, + cc.view 会自动用 CSS 旋转游戏场景的 canvas, + 这个方法不会对 native 部分产生任何影响,对于 native 而言,你需要在应用设置中的设置排版。 + @param orientation Possible values: cc.macro.ORIENTATION_LANDSCAPE | cc.macro.ORIENTATION_PORTRAIT | cc.macro.ORIENTATION_AUTO + */ + setOrientation(orientation: number): void; + /** + !#en + Sets whether the engine modify the "viewport" meta in your web page.
+ It's enabled by default, we strongly suggest you not to disable it.
+ And even when it's enabled, you can still set your own "viewport" meta, it won't be overridden
+ Only useful on web + !#zh 设置引擎是否调整 viewport meta 来配合屏幕适配。 + 默认设置为启动,我们强烈建议你不要将它设置为关闭。 + 即使当它启动时,你仍然能够设置你的 viewport meta,它不会被覆盖。 + 仅在 Web 模式下有效 + @param enabled Enable automatic modification to "viewport" meta + */ + adjustViewportMeta(enabled: boolean): void; + /** + !#en + Retina support is enabled by default for Apple device but disabled for other devices,
+ it takes effect only when you called setDesignResolutionPolicy
+ Only useful on web + !#zh 对于 Apple 这种支持 Retina 显示的设备上默认进行优化而其他类型设备默认不进行优化, + 它仅会在你调用 setDesignResolutionPolicy 方法时有影响。 + 仅在 Web 模式下有效。 + @param enabled Enable or disable retina display + */ + enableRetina(enabled: boolean): void; + /** + !#en + Check whether retina display is enabled.
+ Only useful on web + !#zh 检查是否对 Retina 显示设备进行优化。 + 仅在 Web 模式下有效。 + */ + isRetinaEnabled(): boolean; + /** + !#en Whether to Enable on anti-alias + !#zh 控制抗锯齿是否开启 + @param enabled Enable or not anti-alias + */ + enableAntiAlias(enabled: boolean): void; + /** + !#en Returns whether the current enable on anti-alias + !#zh 返回当前是否抗锯齿 + */ + isAntiAliasEnabled(): boolean; + /** + !#en + If enabled, the application will try automatically to enter full screen mode on mobile devices
+ You can pass true as parameter to enable it and disable it by passing false.
+ Only useful on web + !#zh 启动时,移动端游戏会在移动端自动尝试进入全屏模式。 + 你能够传入 true 为参数去启动它,用 false 参数来关闭它。 + @param enabled Enable or disable auto full screen on mobile devices + */ + enableAutoFullScreen(enabled: boolean): void; + /** + !#en + Check whether auto full screen is enabled.
+ Only useful on web + !#zh 检查自动进入全屏模式是否启动。 + 仅在 Web 模式下有效。 + */ + isAutoFullScreenEnabled(): boolean; + /** + !#en + Returns the canvas size of the view.
+ On native platforms, it returns the screen size since the view is a fullscreen view.
+ On web, it returns the size of the canvas element. + !#zh 返回视图中 canvas 的尺寸。 + 在 native 平台下,它返回全屏视图下屏幕的尺寸。 + 在 Web 平台下,它返回 canvas 元素尺寸。 + */ + getCanvasSize(): Size; + /** + !#en + Returns the frame size of the view.
+ On native platforms, it returns the screen size since the view is a fullscreen view.
+ On web, it returns the size of the canvas's outer DOM element. + !#zh 返回视图中边框尺寸。 + 在 native 平台下,它返回全屏视图下屏幕的尺寸。 + 在 web 平台下,它返回 canvas 元素的外层 DOM 元素尺寸。 + */ + getFrameSize(): Size; + /** + !#en + On native, it sets the frame size of view.
+ On web, it sets the size of the canvas's outer DOM element. + !#zh 在 native 平台下,设置视图框架尺寸。 + 在 web 平台下,设置 canvas 外层 DOM 元素尺寸。 + @param width width + @param height height + */ + setFrameSize(width: number, height: number): void; + /** + !#en + Returns the visible area size of the view port. + !#zh 返回视图窗口可见区域尺寸。 + */ + getVisibleSize(): Size; + /** + !#en + Returns the visible area size of the view port. + !#zh 返回视图窗口可见区域像素尺寸。 + */ + getVisibleSizeInPixel(): Size; + /** + !#en + Returns the visible origin of the view port. + !#zh 返回视图窗口可见区域原点。 + */ + getVisibleOrigin(): Vec2; + /** + !#en + Returns the visible origin of the view port. + !#zh 返回视图窗口可见区域像素原点。 + */ + getVisibleOriginInPixel(): Vec2; + /** + !#en + Returns the current resolution policy + !#zh 返回当前分辨率方案 + */ + getResolutionPolicy(): ResolutionPolicy; + /** + !#en + Sets the current resolution policy + !#zh 设置当前分辨率模式 + @param resolutionPolicy resolutionPolicy + */ + setResolutionPolicy(resolutionPolicy: ResolutionPolicy|number): void; + /** + !#en + Sets the resolution policy with designed view size in points.
+ The resolution policy include:
+ [1] ResolutionExactFit Fill screen by stretch-to-fit: if the design resolution ratio of width to height is different from the screen resolution ratio, your game view will be stretched.
+ [2] ResolutionNoBorder Full screen without black border: if the design resolution ratio of width to height is different from the screen resolution ratio, two areas of your game view will be cut.
+ [3] ResolutionShowAll Full screen with black border: if the design resolution ratio of width to height is different from the screen resolution ratio, two black borders will be shown.
+ [4] ResolutionFixedHeight Scale the content's height to screen's height and proportionally scale its width
+ [5] ResolutionFixedWidth Scale the content's width to screen's width and proportionally scale its height
+ [cc.ResolutionPolicy] [Web only feature] Custom resolution policy, constructed by cc.ResolutionPolicy
+ !#zh 通过设置设计分辨率和匹配模式来进行游戏画面的屏幕适配。 + @param width Design resolution width. + @param height Design resolution height. + @param resolutionPolicy The resolution policy desired + */ + setDesignResolutionSize(width: number, height: number, resolutionPolicy: ResolutionPolicy|number): void; + /** + !#en + Returns the designed size for the view. + Default resolution size is the same as 'getFrameSize'. + !#zh 返回视图的设计分辨率。 + 默认下分辨率尺寸同 `getFrameSize` 方法相同 + */ + getDesignResolutionSize(): Size; + /** + !#en + Sets the container to desired pixel resolution and fit the game content to it. + This function is very useful for adaptation in mobile browsers. + In some HD android devices, the resolution is very high, but its browser performance may not be very good. + In this case, enabling retina display is very costy and not suggested, and if retina is disabled, the image may be blurry. + But this API can be helpful to set a desired pixel resolution which is in between. + This API will do the following: + 1. Set viewport's width to the desired width in pixel + 2. Set body width to the exact pixel resolution + 3. The resolution policy will be reset with designed view size in points. + !#zh 设置容器(container)需要的像素分辨率并且适配相应分辨率的游戏内容。 + @param width Design resolution width. + @param height Design resolution height. + @param resolutionPolicy The resolution policy desired + */ + setRealPixelResolution(width: number, height: number, resolutionPolicy: ResolutionPolicy|number): void; + /** + !#en + Sets view port rectangle with points. + !#zh 用设计分辨率下的点尺寸来设置视窗。 + @param x x + @param y y + @param w width + @param h height + */ + setViewportInPoints(x: number, y: number, w: number, h: number): void; + /** + !#en + Sets Scissor rectangle with points. + !#zh 用设计分辨率下的点的尺寸来设置 scissor 剪裁区域。 + @param x x + @param y y + @param w w + @param h h + */ + setScissorInPoints(x: number, y: number, w: number, h: number): void; + /** + !#en + Returns whether GL_SCISSOR_TEST is enable + !#zh 检查 scissor 是否生效。 + */ + isScissorEnabled(): boolean; + /** + !#en + Returns the current scissor rectangle + !#zh 返回当前的 scissor 剪裁区域。 + */ + getScissorRect(): Rect; + /** + !#en + Returns the view port rectangle. + !#zh 返回视窗剪裁区域。 + */ + getViewportRect(): Rect; + /** + !#en + Returns scale factor of the horizontal direction (X axis). + !#zh 返回横轴的缩放比,这个缩放比是将画布像素分辨率放到设计分辨率的比例。 + */ + getScaleX(): number; + /** + !#en + Returns scale factor of the vertical direction (Y axis). + !#zh 返回纵轴的缩放比,这个缩放比是将画布像素分辨率缩放到设计分辨率的比例。 + */ + getScaleY(): number; + /** + !#en + Returns device pixel ratio for retina display. + !#zh 返回设备或浏览器像素比例。 + */ + getDevicePixelRatio(): number; + /** + !#en + Returns the real location in view for a translation based on a related position + !#zh 将屏幕坐标转换为游戏视图下的坐标。 + @param tx The X axis translation + @param ty The Y axis translation + @param relatedPos The related position object including "left", "top", "width", "height" informations + */ + convertToLocationInView(tx: number, ty: number, relatedPos: any): Vec2; + } + /**

cc.game.containerStrategy class is the root strategy class of container's scale strategy, + it controls the behavior of how to scale the cc.game.container and cc.game.canvas object

*/ + export class ContainerStrategy { + /** + !#en + Manipulation before appling the strategy + !#zh 在应用策略之前的操作 + @param view The target view + */ + preApply(view: View): void; + /** + !#en + Function to apply this strategy + !#zh 策略应用方法 + @param view view + @param designedResolution designedResolution + */ + apply(view: View, designedResolution: Size): void; + /** + !#en + Manipulation after applying the strategy + !#zh 策略调用之后的操作 + @param view The target view + */ + postApply(view: View): void; + } + /**

cc.ContentStrategy class is the root strategy class of content's scale strategy, + it controls the behavior of how to scale the scene and setup the viewport for the game

*/ + export class ContentStrategy { + /** + !#en + Manipulation before applying the strategy + !#zh 策略应用前的操作 + @param view The target view + */ + preApply(view: View): void; + /** + !#en Function to apply this strategy + The return value is {scale: [scaleX, scaleY], viewport: {cc.Rect}}, + The target view can then apply these value to itself, it's preferred not to modify directly its private variables + !#zh 调用策略方法 + @param view view + @param designedResolution designedResolution + */ + apply(view: View, designedResolution: Size): any; + /** + !#en + Manipulation after applying the strategy + !#zh 策略调用之后的操作 + @param view The target view + */ + postApply(view: View): void; + } + /** undefined */ + export class EqualToFrame extends ContainerStrategy { + } + /** undefined */ + export class ProportionalToFrame extends ContainerStrategy { + } + /** undefined */ + export class EqualToWindow extends EqualToFrame { + } + /** undefined */ + export class ProportionalToWindow extends ProportionalToFrame { + } + /** undefined */ + export class OriginalContainer extends ContainerStrategy { + } + /**

cc.ResolutionPolicy class is the root strategy class of scale strategy, + its main task is to maintain the compatibility with Cocos2d-x

*/ + export class ResolutionPolicy { + /** + + @param containerStg The container strategy + @param contentStg The content strategy + */ + constructor(containerStg: ContainerStrategy, contentStg: ContentStrategy); + /** + !#en Manipulation before applying the resolution policy + !#zh 策略应用前的操作 + @param view The target view + */ + preApply(view: View): void; + /** + !#en Function to apply this resolution policy + The return value is {scale: [scaleX, scaleY], viewport: {cc.Rect}}, + The target view can then apply these value to itself, it's preferred not to modify directly its private variables + !#zh 调用策略方法 + @param view The target view + @param designedResolution The user defined design resolution + */ + apply(view: View, designedResolution: Size): any; + /** + !#en Manipulation after appyling the strategy + !#zh 策略应用之后的操作 + @param view The target view + */ + postApply(view: View): void; + /** + !#en + Setup the container's scale strategy + !#zh 设置容器的适配策略 + @param containerStg containerStg + */ + setContainerStrategy(containerStg: ContainerStrategy): void; + /** + !#en + Setup the content's scale strategy + !#zh 设置内容的适配策略 + @param contentStg contentStg + */ + setContentStrategy(contentStg: ContentStrategy): void; + /** The entire application is visible in the specified area without trying to preserve the original aspect ratio.
+ Distortion can occur, and the application may appear stretched or compressed. */ + static EXACT_FIT: number; + /** The entire application fills the specified area, without distortion but possibly with some cropping,
+ while maintaining the original aspect ratio of the application. */ + static NO_BORDER: number; + /** The entire application is visible in the specified area without distortion while maintaining the original
+ aspect ratio of the application. Borders can appear on two sides of the application. */ + static SHOW_ALL: number; + /** The application takes the height of the design resolution size and modifies the width of the internal
+ canvas so that it fits the aspect ratio of the device
+ no distortion will occur however you must make sure your application works on different
+ aspect ratios */ + static FIXED_HEIGHT: number; + /** The application takes the width of the design resolution size and modifies the height of the internal
+ canvas so that it fits the aspect ratio of the device
+ no distortion will occur however you must make sure your application works on different
+ aspect ratios */ + static FIXED_WIDTH: number; + /** Unknow policy */ + static UNKNOWN: number; + } + /** cc.visibleRect is a singleton object which defines the actual visible rect of the current view, + it should represent the same rect as cc.view.getViewportRect() */ + export class visibleRect { + /** + initialize + @param visibleRect visibleRect + */ + static init(visibleRect: Rect): void; + /** Top left coordinate of the screen related to the game scene. */ + static topLeft: Vec2; + /** Top right coordinate of the screen related to the game scene. */ + static topRight: Vec2; + /** Top center coordinate of the screen related to the game scene. */ + static top: Vec2; + /** Bottom left coordinate of the screen related to the game scene. */ + static bottomLeft: Vec2; + /** Bottom right coordinate of the screen related to the game scene. */ + static bottomRight: Vec2; + /** Bottom center coordinate of the screen related to the game scene. */ + static bottom: Vec2; + /** Center coordinate of the screen related to the game scene. */ + static center: Vec2; + /** Left center coordinate of the screen related to the game scene. */ + static left: Vec2; + /** Right center coordinate of the screen related to the game scene. */ + static right: Vec2; + /** Width of the screen. */ + static width: number; + /** Height of the screen. */ + static height: number; + } + /** !#en The callbacks invoker to handle and invoke callbacks by key. + !#zh CallbacksInvoker 用来根据 Key 管理并调用回调方法。 */ + export class CallbacksInvoker { + /** + !#zh + 检查指定事件是否已注册回调。 + !#en + Check if the specified key has any registered callback. If a callback is also specified, + it will only return true if the callback is registered. + @param key key + @param callback callback + @param target target + */ + hasEventListener(key: string, callback?: Function, target?: any): boolean; + /** + !#zh + 移除在特定事件类型中注册的所有回调或在某个目标中注册的所有回调。 + + !#en + Removes all callbacks registered in a certain event type or all callbacks registered with a certain target + @param keyOrTarget The event key to be removed or the target to be removed + */ + removeAll(keyOrTarget: string|any): void; + /** + !#zh + 删除之前与同类型,回调,目标注册的回调。 + @param key key + @param callback callback + @param target target + */ + off(key: string, callback: Function, target?: any): void; + /** + !#en + Trigger an event directly with the event name and necessary arguments. + !#zh + 通过事件名发送自定义事件 + @param key event type + @param arg1 First argument + @param arg2 Second argument + @param arg3 Third argument + @param arg4 Fourth argument + @param arg5 Fifth argument + + @example + ```js + eventTarget.emit('fire', event); + eventTarget.emit('fire', message, emitter); + ``` + */ + emit(key: string, arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any): void; + } + /** !#en Contains information collected during deserialization + !#zh 包含反序列化时的一些信息 */ + export class Details { + /** list of the depends assets' uuid */ + uuidList: string[]; + /** the obj list whose field needs to load asset by uuid */ + uuidObjList: any[]; + /** the corresponding field name which referenced to the asset */ + uuidPropList: string[]; + reset(): void; + /** + + @param obj obj + @param propName propName + @param uuid uuid + */ + push(obj: any, propName: string, uuid: string): void; + } + /** undefined */ + export class url { + /** + Returns the url of raw assets, you will only need this if the raw asset is inside the "resources" folder. + @param url url + + @example + ```js + --- + var url = cc.url.raw("textures/myTexture.png"); + console.log(url); // "resources/raw/textures/myTexture.png" + + ``` + */ + static raw(url: string): string; + } + /** !#en The burst of 3d particle. + !#zh 3D 粒子发射时的爆发个数 */ + export class Burst { + /** !#en Time between the start of the particle system and the trigger of this Brust + !#zh 粒子系统开始运行到触发此次 Brust 的时间 */ + time: number; + /** !#en Minimum number of emitted particles + !#zh 发射粒子的最小数量 */ + minCount: number; + /** !#en Maximum number of emitted particles + !#zh 发射粒子的最大数量 */ + maxCount: number; + /** !#en The number of times Burst was triggered. + !#zh Burst 的触发次数 */ + repeatCount: number; + /** !#en Interval of each trigger + !#zh 每次触发的间隔时间 */ + repeatInterval: number; + /** !#en Number of particles emitted + !#zh 发射的粒子的数量 */ + count: CurveRange; + } + /** !#en The animation curve of 3d particle. + !#zh 3D 粒子动画曲线 */ + export class AnimationCurve { + } + /** !#en The ParticleSystem3D Component. + !#zh 3D 粒子组件 */ + export class ParticleSystem3D extends RenderComponent { + /** !#en The run time of particle. + !#zh 粒子系统运行时间 */ + duration: number; + /** !#en The maximum number of particles that a particle system can generate. + !#zh 粒子系统能生成的最大粒子数量 */ + capacity: number; + /** !#en Whether the particle system loops. + !#zh 粒子系统是否循环播放 */ + loop: boolean; + /** !#en Whether the particles start playing automatically after loaded. + !#zh 粒子系统加载后是否自动开始播放 */ + playOnAwake: boolean; + /** !#en When selected, the particle system will start playing after one round has been played (only effective when loop is enabled). + !#zh 选中之后,粒子系统会以已播放完一轮之后的状态开始播放(仅当循环播放启用时有效) */ + prewarm: boolean; + /** !#en The coordinate system in which the particle system is located.
+ World coordinates (does not change when the position of other objects changes)
+ Local coordinates (moving as the position of the parent node changes)
+ Custom coordinates (moving with the position of a custom node) + !#zh 选择粒子系统所在的坐标系
+ 世界坐标(不随其他物体位置改变而变换)
+ 局部坐标(跟随父节点位置改变而移动)
+ 自定坐标(跟随自定义节点的位置改变而移动) */ + simulationSpace: Space; + /** !#en Controlling the update speed of the entire particle system. + !#zh 控制整个粒子系统的更新速度。 */ + simulationSpeed: number; + /** !#en Delay particle emission time after particle system starts running. + !#zh 粒子系统开始运行后,延迟粒子发射的时间。 */ + startDelay: CurveRange; + /** !#en Particle life cycle。 + !#zh 粒子生命周期。 */ + startLifetime: CurveRange; + /** !#en Particle initial color + !#zh 粒子初始颜色 */ + startColor: GradientRange; + /** !#en Particle scale space + !#zh 缩放空间 */ + scaleSpace: Space; + /** !#en Initial particle size + !#zh 粒子初始大小 */ + startSize: CurveRange; + /** !#en Initial particle speed + !#zh 粒子初始速度 */ + startSpeed: CurveRange; + /** !#en Particle initial rotation angle + !#zh 粒子初始旋转角度 */ + startRotation: CurveRange; + /** !#en Gravity coefficient of particles affected by gravity + !#zh 粒子受重力影响的重力系数 */ + gravityModifier: CurveRange; + /** !#en Particles emitted per second + !#zh 每秒发射的粒子数 */ + rateOverTime: CurveRange; + /** !#en Number of particles emitted per unit distance moved + !#zh 每移动单位距离发射的粒子数 */ + rateOverDistance: CurveRange; + /** !#en The number of Brusts that emit a specified number of particles at a specified time + !#zh 设定在指定时间发射指定数量的粒子的 Brust 的数量 */ + bursts: Burst[]; + /** !#en Particle emitter module + !#zh 粒子发射器模块 */ + shapeModule: ShapeModule; + /** !#en Color control module + !#zh 颜色控制模块 */ + colorOverLifetimeModule: ColorOverLifetimeModule; + /** !#en Particle size module + !#zh 粒子大小模块 */ + sizeOvertimeModule: SizeOvertimeModule; + /** !#en Particle speed module + !#zh 粒子速度模块 */ + velocityOvertimeModule: VelocityOvertimeModule; + /** !#en Particle acceleration module + !#zh 粒子加速度模块 */ + forceOvertimeModule: ForceOvertimeModule; + /** !#en Particle limit speed module (only CPU particles are supported) + !#zh 粒子限制速度模块(只支持 CPU 粒子) */ + limitVelocityOvertimeModule: LimitVelocityOvertimeModule; + /** !#en Particle rotation module + !#zh 粒子旋转模块 */ + rotationOvertimeModule: RotationOvertimeModule; + /** !#en Texture Animation Module + !#zh 贴图动画模块 */ + textureAnimationModule: TextureAnimationModule; + /** !#en Particle Trajectory Module + !#zh 粒子轨迹模块 */ + trailModule: TrailModule; + /** !#en Particle generation mode + !#zh 设定粒子生成模式 */ + renderMode: ParticleSystem3DAssembler.RenderMode; + /** !#en When the particle generation mode is StrecthedBillboard, in the direction of movement of the particles is stretched by velocity magnitude + !#zh 在粒子生成方式为 StrecthedBillboard 时,对粒子在运动方向上按速度大小进行拉伸 */ + velocityScale: number; + /** !#en When the particle generation method is StrecthedBillboard, the particles are stretched according to the particle size in the direction of motion + !#zh 在粒子生成方式为 StrecthedBillboard 时,对粒子在运动方向上按粒子大小进行拉伸 */ + lengthScale: number; + /** !#en Particle model + !#zh 粒子模型 */ + mesh: Mesh; + /** !#en Particle material + !#zh 粒子材质 */ + particleMaterial: Material; + /** !#en Particle trail material + !#zh 粒子轨迹材质 */ + trailMaterial: Material; + /** + !#en Playing particle effects + !#zh 播放粒子效果 + */ + play(): void; + /** + !#en Pause particle effect + !#zh 暂停播放粒子效果 + */ + pause(): void; + /** + !#en Stop particle effect + !#zh 停止播放粒子效果 + */ + stop(): void; + /** + !#en Remove all particle effect + !#zh 将所有粒子从粒子系统中清除 + */ + clear(): void; + } + /** !#en + Helper class for ES5 Map. + !#zh + ES5 Map 辅助类。 */ + export class MapUtils { + } + /** !#en . + !#zh 。 */ + export class SkeletonAnimation extends Animation { + } + /** !#en SkeletonAnimationClip Asset. + !#zh 骨骼动画剪辑。 */ + export class SkeletonAnimationClip extends AnimationClip { + } + /** !#en + Skinned Mesh Renderer + !#zh + 蒙皮渲染组件 */ + export class SkinnedMeshRenderer { + /** !#en + Skeleton Asset + !#zh + 骨骼资源 */ + skeleton: sp.Skeleton; + /** !#en + Root Bone + !#zh + 骨骼根节点 */ + rootBone: Node; + } + /** !#en Effect Asset. + !#zh Effect 资源类型。 */ + export class EffectAsset extends Asset { + } + /** !#en Material Asset. + !#zh 材质资源类。 */ + export class Material extends Asset { + /** + !#en Creates a Material with builtin Effect. + !#zh 使用内建 Effect 创建一个材质。 + @param effectName effectName + @param techniqueIndex techniqueIndex + */ + static createWithBuiltin(effectName: string, techniqueIndex?: number): Material; + /** + !#en Creates a Material. + !#zh 创建一个材质。 + @param effectAsset effectAsset + @param techniqueIndex techniqueIndex + */ + static create(effectAsset: EffectAsset, techniqueIndex?: number): Material; + /** + !#en Sets the Material property + !#zh 是指材质的属性 + @param name name + @param val val + @param passIdx passIdx + @param directly directly + */ + setProperty(name: string, val: any, passIdx?: number, directly?: boolean): void; + /** + !#en Gets the Material property. + !#zh 获取材质的属性。 + @param name name + @param passIdx passIdx + */ + getProperty(name: string, passIdx: number): void; + /** + !#en Sets the Material define. + !#zh 设置材质的宏定义。 + @param name name + @param val val + @param passIdx passIdx + @param force force + */ + define(name: string, val: boolean|number, passIdx?: number, force?: boolean): void; + /** + !#en Gets the Material define. + !#zh 获取材质的宏定义。 + @param name name + @param passIdx passIdx + */ + getDefine(name: string, passIdx?: number): boolean; + /** + !#en Sets the Material cull mode. + !#zh 设置材质的裁减模式。 + @param cullMode cullMode + @param passIdx passIdx + */ + setCullMode(cullMode: number, passIdx: number): void; + /** + !#en Sets the Material depth states. + !#zh 设置材质的深度渲染状态。 + @param depthTest depthTest + @param depthWrite depthWrite + @param depthFunc depthFunc + @param passIdx passIdx + */ + setDepth(depthTest: boolean, depthWrite: boolean, depthFunc: number, passIdx: number): void; + /** + !#en Sets the Material blend states. + !#zh 设置材质的混合渲染状态。 + @param enabled enabled + @param blendEq blendEq + @param blendSrc blendSrc + @param blendDst blendDst + @param blendAlphaEq blendAlphaEq + @param blendSrcAlpha blendSrcAlpha + @param blendDstAlpha blendDstAlpha + @param blendColor blendColor + @param passIdx passIdx + */ + setBlend(enabled: number, blendEq: number, blendSrc: number, blendDst: number, blendAlphaEq: number, blendSrcAlpha: number, blendDstAlpha: number, blendColor: number, passIdx: number): void; + /** + !#en Sets whether enable the stencil test. + !#zh 设置是否开启模板测试。 + @param stencilTest stencilTest + @param passIdx passIdx + */ + setStencilEnabled(stencilTest: number, passIdx: number): void; + /** + !#en Sets the Material stencil render states. + !#zh 设置材质的模板测试渲染参数。 + @param stencilTest stencilTest + @param stencilFunc stencilFunc + @param stencilRef stencilRef + @param stencilMask stencilMask + @param stencilFailOp stencilFailOp + @param stencilZFailOp stencilZFailOp + @param stencilZPassOp stencilZPassOp + @param stencilWriteMask stencilWriteMask + @param passIdx passIdx + */ + setStencil(stencilTest: number, stencilFunc: number, stencilRef: number, stencilMask: number, stencilFailOp: number, stencilZFailOp: number, stencilZPassOp: number, stencilWriteMask: number, passIdx: number): void; + } + /** !#en + Material Variant is an extension of the Material Asset. + Changes to Material Variant do not affect other Material Variant or Material Asset, + and changes to Material Asset are synchronized to the Material Variant. + However, when a Material Variant had already modifies a state, the Material Asset state is not synchronized to the Material Variant. + !#zh + 材质变体是材质资源的一个延伸。 + 材质变体的修改不会影响到其他的材质变体或者材质资源,而材质资源的修改会同步体现到材质变体上, + 但是当材质变体对一个状态修改后,材质资源再对这个状态修改是不会同步到材质变体上的。 */ + export class MaterialVariant extends Material { + /** + + @param materialName materialName + @param owner owner + */ + static createWithBuiltin (materialName, owner: cc.RenderComponent): MaterialVariant | null; + /** + + @param material material + @param owner owner + */ + static create (material: Material, owner: cc.RenderComponent): MaterialVariant | null; + } + /** !#en cc.EditBox is a component for inputing text, you can use it to gather small amounts of text from users. + !#zh EditBox 组件,用于获取用户的输入文本。 */ + export class EditBox extends Component { + /** !#en Input string of EditBox. + !#zh 输入框的初始输入内容,如果为空则会显示占位符的文本。 */ + string: string; + /** !#en The Label component attached to the node for EditBox's input text label + !#zh 输入框输入文本节点上挂载的 Label 组件对象 */ + textLabel: Label; + /** !#en The Label component attached to the node for EditBox's placeholder text label + !#zh 输入框占位符节点上挂载的 Label 组件对象 */ + placeholderLabel: Label; + /** !#en The Sprite component attached to the node for EditBox's background + !#zh 输入框背景节点上挂载的 Sprite 组件对象 */ + background: Sprite; + /** !#en The background image of EditBox. This property will be removed in the future, use editBox.background instead please. + !#zh 输入框的背景图片。 该属性会在将来的版本中移除,请用 editBox.background */ + backgroundImage: SpriteFrame; + /** !#en + The return key type of EditBox. + Note: it is meaningless for web platforms and desktop platforms. + !#zh + 指定移动设备上面回车按钮的样式。 + 注意:这个选项对 web 平台与 desktop 平台无效。 */ + returnType: EditBox.KeyboardReturnType; + /** !#en Set the input flags that are to be applied to the EditBox. + !#zh 指定输入标志位,可以指定输入方式为密码或者单词首字母大写。 */ + inputFlag: EditBox.InputFlag; + /** !#en + Set the input mode of the edit box. + If you pass ANY, it will create a multiline EditBox. + !#zh + 指定输入模式: ANY表示多行输入,其它都是单行输入,移动平台上还可以指定键盘样式。 */ + inputMode: EditBox.InputMode; + /** !#en Font size of the input text. This property will be removed in the future, use editBox.textLabel.fontSize instead please. + !#zh 输入框文本的字体大小。 该属性会在将来的版本中移除,请使用 editBox.textLabel.fontSize。 */ + fontSize: number; + /** !#en Change the lineHeight of displayed text. This property will be removed in the future, use editBox.textLabel.lineHeight instead. + !#zh 输入框文本的行高。该属性会在将来的版本中移除,请使用 editBox.textLabel.lineHeight */ + lineHeight: number; + /** !#en Font color of the input text. This property will be removed in the future, use editBox.textLabel.node.color instead. + !#zh 输入框文本的颜色。该属性会在将来的版本中移除,请使用 editBox.textLabel.node.color */ + fontColor: Color; + /** !#en The display text of placeholder. + !#zh 输入框占位符的文本内容。 */ + placeholder: string; + /** !#en The font size of placeholder. This property will be removed in the future, use editBox.placeholderLabel.fontSize instead. + !#zh 输入框占位符的字体大小。该属性会在将来的版本中移除,请使用 editBox.placeholderLabel.fontSize */ + placeholderFontSize: number; + /** !#en The font color of placeholder. This property will be removed in the future, use editBox.placeholderLabel.node.color instead. + !#zh 输入框占位符的字体颜色。该属性会在将来的版本中移除,请使用 editBox.placeholderLabel.node.color */ + placeholderFontColor: Color; + /** !#en The maximize input length of EditBox. + - If pass a value less than 0, it won't limit the input number of characters. + - If pass 0, it doesn't allow input any characters. + !#zh 输入框最大允许输入的字符个数。 + - 如果值为小于 0 的值,则不会限制输入字符个数。 + - 如果值为 0,则不允许用户进行任何输入。 */ + maxLength: number; + /** !#en The input is always visible and be on top of the game view (only useful on Web), this property will be removed on v2.1 + !zh 输入框总是可见,并且永远在游戏视图的上面(这个属性只有在 Web 上面修改有意义),该属性会在 v2.1 中移除 + Note: only available on Web at the moment. */ + stayOnTop: boolean; + /** !#en Set the tabIndex of the DOM input element (only useful on Web). + !#zh 修改 DOM 输入元素的 tabIndex(这个属性只有在 Web 上面修改有意义)。 */ + tabIndex: number; + /** !#en The event handler to be called when EditBox began to edit text. + !#zh 开始编辑文本输入框触发的事件回调。 */ + editingDidBegan: Component.EventHandler[]; + /** !#en The event handler to be called when EditBox text changes. + !#zh 编辑文本输入框时触发的事件回调。 */ + textChanged: Component.EventHandler[]; + /** !#en The event handler to be called when EditBox edit ends. + !#zh 结束编辑文本输入框时触发的事件回调。 */ + editingDidEnded: Component.EventHandler[]; + /** !#en The event handler to be called when return key is pressed. Windows is not supported. + !#zh 当用户按下回车按键时的事件回调,目前不支持 windows 平台 */ + editingReturn: Component.EventHandler[]; + /** + !#en Let the EditBox get focus, this method will be removed on v2.1 + !#zh 让当前 EditBox 获得焦点, 这个方法会在 v2.1 中移除 + */ + setFocus(): void; + /** + !#en Let the EditBox get focus + !#zh 让当前 EditBox 获得焦点 + */ + focus(): void; + /** + !#en Let the EditBox lose focus + !#zh 让当前 EditBox 失去焦点 + */ + blur(): void; + /** + !#en Determine whether EditBox is getting focus or not. + !#zh 判断 EditBox 是否获得了焦点 + */ + isFocused(): void; + /** + !#en if you don't need the EditBox and it isn't in any running Scene, you should + call the destroy method on this component or the associated node explicitly. + Otherwise, the created DOM element won't be removed from web page. + !#zh + 如果你不再使用 EditBox,并且组件未添加到场景中,那么你必须手动对组件或所在节点调用 destroy。 + 这样才能移除网页上的 DOM 节点,避免 Web 平台内存泄露。 + + @example + ```js + editbox.node.parent = null; // or editbox.node.removeFromParent(false); + // when you don't need editbox anymore + editbox.node.destroy(); + ``` + */ + destroy(): boolean; + } + /** undefined */ + export class PhysicsBoxCollider extends PhysicsCollider implements Collider.Box { + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Box size + !#zh 包围盒大小 */ + size: Size; + } + /** undefined */ + export class PhysicsChainCollider extends PolygonCollider { + /** !#en Whether the chain is loop + !#zh 链条是否首尾相连 */ + loop: boolean; + /** !#en Chain points + !#zh 链条顶点数组 */ + points: Vec2[]; + } + /** undefined */ + export class PhysicsCircleCollider extends PhysicsCollider implements Collider.Circle { + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Circle radius + !#zh 圆形半径 */ + radius: number; + } + /** undefined */ + export class PhysicsCollider extends Collider { + /** !#en + The density. + !#zh + 密度 */ + density: number; + /** !#en + A sensor collider collects contact information but never generates a collision response + !#zh + 一个传感器类型的碰撞体会产生碰撞回调,但是不会发生物理碰撞效果。 */ + sensor: boolean; + /** !#en + The friction coefficient, usually in the range [0,1]. + !#zh + 摩擦系数,取值一般在 [0, 1] 之间 */ + friction: number; + /** !#en + The restitution (elasticity) usually in the range [0,1]. + !#zh + 弹性系数,取值一般在 [0, 1]之间 */ + restitution: number; + /** !#en + Physics collider will find the rigidbody component on the node and set to this property. + !#zh + 碰撞体会在初始化时查找节点上是否存在刚体,如果查找成功则赋值到这个属性上。 */ + body: RigidBody; + /** + !#en + Apply current changes to collider, this will regenerate inner box2d fixtures. + !#zh + 应用当前 collider 中的修改,调用此函数会重新生成内部 box2d 的夹具。 + */ + apply(): void; + /** + !#en + Get the world aabb of the collider + !#zh + 获取碰撞体的世界坐标系下的包围盒 + */ + getAABB(): void; + } + /** undefined */ + export class PhysicsPolygonCollider extends PhysicsCollider implements Collider.Polygon { + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Polygon points + !#zh 多边形顶点数组 */ + points: Vec2[]; + } + /** !#en + A distance joint constrains two points on two bodies + to remain at a fixed distance from each other. You can view + this as a massless, rigid rod. + !#zh + 距离关节通过一个固定的长度来约束关节链接的两个刚体。你可以将它想象成一个无质量,坚固的木棍。 */ + export class DistanceJoint extends Joint { + /** !#en + The distance separating the two ends of the joint. + !#zh + 关节两端的距离 */ + distance: number; + /** !#en + The spring frequency. + !#zh + 弹性系数。 */ + frequency: number; + /** !#en + The damping ratio. + !#zh + 阻尼,表示关节变形后,恢复到初始状态受到的阻力。 */ + dampingRatio: number; + } + /** !#en + A motor joint is used to control the relative motion + between two bodies. A typical usage is to control the movement + of a dynamic body with respect to the ground. + !#zh + 马达关节被用来控制两个刚体间的相对运动。 + 一个典型的例子是用来控制一个动态刚体相对于地面的运动。 */ + export class MotorJoint extends Joint { + /** !#en + The anchor of the rigidbody. + !#zh + 刚体的锚点。 */ + anchor: Vec2; + /** !#en + The anchor of the connected rigidbody. + !#zh + 关节另一端刚体的锚点。 */ + connectedAnchor: Vec2; + /** !#en + The linear offset from connected rigidbody to rigidbody. + !#zh + 关节另一端的刚体相对于起始端刚体的位置偏移量 */ + linearOffset: Vec2; + /** !#en + The angular offset from connected rigidbody to rigidbody. + !#zh + 关节另一端的刚体相对于起始端刚体的角度偏移量 */ + angularOffset: number; + /** !#en + The maximum force can be applied to rigidbody. + !#zh + 可以应用于刚体的最大的力值 */ + maxForce: number; + /** !#en + The maximum torque can be applied to rigidbody. + !#zh + 可以应用于刚体的最大扭矩值 */ + maxTorque: number; + /** !#en + The position correction factor in the range [0,1]. + !#zh + 位置矫正系数,范围为 [0, 1] */ + correctionFactor: number; + } + /** !#en + Base class for joints to connect rigidbody. + !#zh + 关节类的基类 */ + export class Joint extends Component { + /** !#en + The anchor of the rigidbody. + !#zh + 刚体的锚点。 */ + anchor: Vec2; + /** !#en + The anchor of the connected rigidbody. + !#zh + 关节另一端刚体的锚点。 */ + connectedAnchor: Vec2; + /** !#en + The rigidbody to which the other end of the joint is attached. + !#zh + 关节另一端链接的刚体 */ + connectedBody: RigidBody; + /** !#en + Should the two rigid bodies connected with this joint collide with each other? + !#zh + 链接到关节上的两个刚体是否应该相互碰撞? */ + collideConnected: boolean; + /** + !#en + Apply current changes to joint, this will regenerate inner box2d joint. + !#zh + 应用当前关节中的修改,调用此函数会重新生成内部 box2d 的关节。 + */ + apply(): void; + /** + !#en + Get the anchor point on rigidbody in world coordinates. + !#zh + 获取刚体世界坐标系下的锚点。 + */ + getWorldAnchor(): Vec2; + /** + !#en + Get the anchor point on connected rigidbody in world coordinates. + !#zh + 获取链接刚体世界坐标系下的锚点。 + */ + getWorldConnectedAnchor(): Vec2; + /** + !#en + Gets the reaction force of the joint. + !#zh + 获取关节的反作用力。 + @param timeStep The time to calculate the reaction force for. + */ + getReactionForce(timeStep: number): Vec2; + /** + !#en + Gets the reaction torque of the joint. + !#zh + 获取关节的反扭矩。 + @param timeStep The time to calculate the reaction torque for. + */ + getReactionTorque(timeStep: number): number; + } + /** !#en + A prismatic joint. This joint provides one degree of freedom: translation + along an axis fixed in rigidbody. Relative rotation is prevented. You can + use a joint limit to restrict the range of motion and a joint motor to + drive the motion or to model joint friction. + !#zh + 移动关节指定了只能在一个方向上移动刚体。 + 你可以开启关节限制来设置刚体运行移动的间距,也可以开启马达来使用关节马达驱动刚体的运行。 */ + export class PrismaticJoint extends Joint { + /** !#en + The local joint axis relative to rigidbody. + !#zh + 指定刚体可以移动的方向。 */ + localAxisA: Vec2; + /** !#en + The reference angle. + !#zh + 相对角度 */ + referenceAngle: number; + /** !#en + Enable joint distance limit? + !#zh + 是否开启关节的距离限制? */ + enableLimit: boolean; + /** !#en + Enable joint motor? + !#zh + 是否开启关节马达? */ + enableMotor: boolean; + /** !#en + The lower joint limit. + !#zh + 刚体能够移动的最小值 */ + lowerLimit: number; + /** !#en + The upper joint limit. + !#zh + 刚体能够移动的最大值 */ + upperLimit: number; + /** !#en + The maxium force can be applied to rigidbody to rearch the target motor speed. + !#zh + 可以施加到刚体的最大力。 */ + maxMotorForce: number; + /** !#en + The expected motor speed. + !#zh + 期望的马达速度。 */ + motorSpeed: number; + } + /** !#en + A mouse joint is used to make a point on a body track a + specified world point. This a soft constraint with a maximum + force. This allows the constraint to stretch and without + applying huge forces. + Mouse Joint will auto register the touch event with the mouse region node, + and move the choosed rigidbody in touch move event. + Note : generally mouse joint only used in test bed. + !#zh + 鼠标关节用于使刚体上的一个点追踪一个指定的世界坐标系下的位置。 + 鼠标关节可以指定一个最大的里来施加一个柔和的约束。 + 鼠标关节会自动使用 mouse region 节点来注册鼠标事件,并且在触摸移动事件中移动选中的刚体。 + 注意:一般鼠标关节只在测试环境中使用。 */ + export class MouseJoint extends Joint { + /** !#en + The anchor of the rigidbody. + !#zh + 刚体的锚点。 */ + anchor: Vec2; + /** !#en + The anchor of the connected rigidbody. + !#zh + 关节另一端刚体的锚点。 */ + connectedAnchor: Vec2; + /** !#en + The node used to register touch evnet. + If this is null, it will be the joint's node. + !#zh + 用于注册触摸事件的节点。 + 如果没有设置这个值,那么将会使用关节的节点来注册事件。 */ + mouseRegion: Node; + /** !#en + The target point. + The mouse joint will move choosed rigidbody to target point. + !#zh + 目标点,鼠标关节将会移动选中的刚体到指定的目标点 */ + target: Vec2; + /** !#en + The spring frequency. + !#zh + 弹簧系数。 */ + frequency: number; + /** !#en + The damping ratio. + !#zh + 阻尼,表示关节变形后,恢复到初始状态受到的阻力。 */ + 0: number; + /** !#en + The maximum force + !#zh + 最大阻力值 */ + maxForce: number; + } + /** !#en + A revolute joint constrains two bodies to share a common point while they + are free to rotate about the point. The relative rotation about the shared + point is the joint angle. You can limit the relative rotation with + a joint limit that specifies a lower and upper angle. You can use a motor + to drive the relative rotation about the shared point. A maximum motor torque + is provided so that infinite forces are not generated. + !#zh + 旋转关节可以约束两个刚体围绕一个点来进行旋转。 + 你可以通过开启关节限制来限制旋转的最大角度和最小角度。 + 你可以通过开启马达来施加一个扭矩力来驱动这两个刚体在这一点上的相对速度。 */ + export class RevoluteJoint extends Joint { + /** !#en + The reference angle. + An angle between bodies considered to be zero for the joint angle. + !#zh + 相对角度。 + 两个物体之间角度为零时可以看作相等于关节角度 */ + referenceAngle: number; + /** !#en + The lower angle. + !#zh + 角度的最低限制。 */ + lowerAngle: number; + /** !#en + The upper angle. + !#zh + 角度的最高限制。 */ + upperAngle: number; + /** !#en + The maxium torque can be applied to rigidbody to rearch the target motor speed. + !#zh + 可以施加到刚体的最大扭矩。 */ + maxMotorTorque: number; + /** !#en + The expected motor speed. + !#zh + 期望的马达速度。 */ + motorSpeed: number; + /** !#en + Enable joint limit? + !#zh + 是否开启关节的限制? */ + enableLimit: boolean; + /** !#en + Enable joint motor? + !#zh + 是否开启关节马达? */ + enableMotor: boolean; + /** + !#en + Get the joint angle. + !#zh + 获取关节角度。 + */ + getJointAngle(): number; + } + /** !#en + A rope joint enforces a maximum distance between two points + on two bodies. It has no other effect. + Warning: if you attempt to change the maximum length during + the simulation you will get some non-physical behavior. + !#zh + 绳子关节只指定两个刚体间的最大距离,没有其他的效果。 + 注意:如果你试图动态修改关节的长度,这有可能会得到一些意外的效果。 */ + export class RopeJoint extends Joint { + /** !#en + The max length. + !#zh + 最大长度。 */ + maxLength: number; + } + /** !#en + A weld joint essentially glues two bodies together. A weld joint may + distort somewhat because the island constraint solver is approximate. + !#zh + 熔接关节相当于将两个刚体粘在了一起。 + 熔接关节可能会使某些东西失真,因为约束求解器算出的都是近似值。 */ + export class WeldJoint extends Joint { + /** !#en + The reference angle. + !#zh + 相对角度。 */ + referenceAngle: number; + /** !#en + The frequency. + !#zh + 弹性系数。 */ + frequency: number; + /** !#en + The damping ratio. + !#zh + 阻尼,表示关节变形后,恢复到初始状态受到的阻力。 */ + 0: number; + } + /** !#en + A wheel joint. This joint provides two degrees of freedom: translation + along an axis fixed in bodyA and rotation in the plane. You can use a joint motor to drive + the rotation or to model rotational friction. + This joint is designed for vehicle suspensions. + !#zh + 轮子关节提供两个维度的自由度:旋转和沿着指定方向上位置的移动。 + 你可以通过开启关节马达来使用马达驱动刚体的旋转。 + 轮组关节是专门为机动车类型设计的。 */ + export class WheelJoint extends Joint { + /** !#en + The local joint axis relative to rigidbody. + !#zh + 指定刚体可以移动的方向。 */ + localAxisA: Vec2; + /** !#en + The maxium torque can be applied to rigidbody to rearch the target motor speed. + !#zh + 可以施加到刚体的最大扭矩。 */ + maxMotorTorque: number; + /** !#en + The expected motor speed. + !#zh + 期望的马达速度。 */ + motorSpeed: number; + /** !#en + Enable joint motor? + !#zh + 是否开启关节马达? */ + enableMotor: boolean; + /** !#en + The spring frequency. + !#zh + 弹性系数。 */ + frequency: number; + /** !#en + The damping ratio. + !#zh + 阻尼,表示关节变形后,恢复到初始状态受到的阻力。 */ + dampingRatio: number; + } + /** !#en The color over time module of 3d particle. + !#zh 3D 粒子颜色变化模块 */ + export class ColorOvertimeModule { + /** !#en The enable of ColorOvertimeModule. + !#zh 是否启用 */ + enable: boolean; + } + /** !#en The force over time module of 3d particle. + !#zh 3D 粒子的加速度模块 */ + export class ForceOvertimeModule { + /** !#en The enable of ColorOvertimeModule. + !#zh 是否启用 */ + enable: boolean; + /** !#en Coordinate system used in acceleration calculation. + !#zh 加速度计算时采用的坐标系。 */ + space: Space; + /** !#en X-axis acceleration component. + !#zh X 轴方向上的加速度分量。 */ + x: CurveRange; + /** !#en Y-axis acceleration component. + !#zh Y 轴方向上的加速度分量。 */ + y: CurveRange; + /** !#en Z-axis acceleration component. + !#zh Z 轴方向上的加速度分量。 */ + z: CurveRange; + } + /** !#en The curve range of target value. + !#zh 目标值的曲线范围 */ + export class CurveRange { + /** !#en Curve type. + !#zh 曲线类型。 */ + mode: ParticleSystem.EmitterMode; + /** !#en The curve to use when mode is Curve. + !#zh 当 mode 为 Curve 时,使用的曲线。 */ + curve: AnimationCurve; + /** !#en The lower limit of the curve to use when mode is TwoCurves + !#zh 当 mode 为 TwoCurves 时,使用的曲线下限。 */ + curveMin: AnimationCurve; + /** !#en The upper limit of the curve to use when mode is TwoCurves + !#zh 当 mode 为 TwoCurves 时,使用的曲线上限。 */ + curveMax: AnimationCurve; + /** !#en When mode is Constant, the value of the curve. + !#zh 当 mode 为 Constant 时,曲线的值。 */ + constant: number; + /** !#en The lower limit of the curve to use when mode is TwoConstants + !#zh 当 mode 为 TwoConstants 时,曲线的下限。 */ + constantMin: number; + /** !#en The upper limit of the curve to use when mode is TwoConstants + !#zh 当 mode 为 TwoConstants 时,曲线的上限。 */ + constantMax: number; + /** !#en Coefficients applied to curve interpolation. + !#zh 应用于曲线插值的系数。 */ + multiplier: number; + } + /** !#en The gradient range of color. + !#zh 颜色值的渐变范围 */ + export class GradientRange { + /** !#en Gradient type. + !#zh 渐变色类型。 */ + mode: ParticleSystem.EmitterMode; + /** !#en The color when mode is Color. + !#zh 当 mode 为 Color 时的颜色。 */ + color: Color; + /** !#en Lower color limit when mode is TwoColors. + !#zh 当 mode 为 TwoColors 时的颜色下限。 */ + colorMin: Color; + /** !#en Upper color limit when mode is TwoColors. + !#zh 当 mode 为 TwoColors 时的颜色上限。 */ + colorMax: Color; + /** !#en Color gradient when mode is Gradient + !#zh 当 mode 为 Gradient 时的颜色渐变。 */ + gradient: Gradient; + /** !#en Lower color gradient limit when mode is TwoGradients. + !#zh 当 mode 为 TwoGradients 时的颜色渐变下限。 */ + gradientMin: Gradient; + /** !#en Upper color gradient limit when mode is TwoGradients. + !#zh 当 mode 为 TwoGradients 时的颜色渐变上限。 */ + gradientMax: Gradient; + } + /** !#en The color key of gradient. + !#zh color 关键帧 */ + export class ColorKey { + } + /** !#en The alpha key of gradient. + !#zh alpha 关键帧 */ + export class AlphaKey { + } + /** !#en The gradient data of color. + !#zh 颜色渐变数据 */ + export class Gradient { + } + /** !#en The optimized curve. + !#zh 优化曲线 */ + export class OptimizedCurve { + } + /** !#en The limit velocity module of 3d particle. + !#zh 3D 粒子的限速模块 */ + export class LimitVelocityOvertimeModule { + /** !#en The enable of LimitVelocityOvertimeModule. + !#zh 是否启用 */ + enable: boolean; + /** !#en The coordinate system used when calculating the lower speed limit. + !#zh 计算速度下限时采用的坐标系。 */ + space: Space; + /** !#en Whether to limit the three axes separately. + !#zh 是否三个轴分开限制。 */ + separateAxes: boolean; + /** !#en Lower speed limit + !#zh 速度下限。 */ + limit: CurveRange; + /** !#en Lower speed limit in X direction. + !#zh X 轴方向上的速度下限。 */ + limitX: CurveRange; + /** !#en Lower speed limit in Y direction. + !#zh Y 轴方向上的速度下限。 */ + limitY: CurveRange; + /** !#en Lower speed limit in Z direction. + !#zh Z 轴方向上的速度下限。 */ + limitZ: CurveRange; + /** !#en Interpolation of current speed and lower speed limit. + !#zh 当前速度与速度下限的插值。 */ + dampen: number; + } + /** !#en The rotation module of 3d particle. + !#zh 3D 粒子的旋转模块 */ + export class RotationOvertimeModule { + /** !#en The enable of RotationOvertimeModule. + !#zh 是否启用 */ + enable: boolean; + /** !#en Whether to set the rotation of three axes separately (not currently supported) + !#zh 是否三个轴分开设定旋转(暂不支持)。 */ + separateAxes: boolean; + /** !#en Set rotation around X axis. + !#zh 绕 X 轴设定旋转。 */ + x: CurveRange; + /** !#en Set rotation around Y axis. + !#zh 绕 Y 轴设定旋转。 */ + y: CurveRange; + /** !#en Set rotation around Z axis. + !#zh 绕 Z 轴设定旋转。 */ + z: CurveRange; + } + /** !#en The size module of 3d particle. + !#zh 3D 粒子的大小模块 */ + export class SizeOvertimeModule { + /** !#en The enable of SizeOvertimeModule. + !#zh 是否启用 */ + enable: boolean; + /** !#en Decide whether to control particle size independently on each axis. + !#zh 决定是否在每个轴上独立控制粒子大小。 */ + separateAxes: boolean; + /** !#en Define a curve to determine the size change of particles during their life cycle. + !#zh 定义一条曲线来决定粒子在其生命周期中的大小变化。 */ + size: CurveRange; + /** !#en Defines a curve to determine the size change of particles in the X-axis direction during their life cycle. + !#zh 定义一条曲线来决定粒子在其生命周期中 X 轴方向上的大小变化。 */ + x: CurveRange; + /** !#en Defines a curve to determine the size change of particles in the Y-axis direction during their life cycle. + !#zh 定义一条曲线来决定粒子在其生命周期中 Y 轴方向上的大小变化。 */ + y: CurveRange; + /** !#en Defines a curve to determine the size change of particles in the Z-axis direction during their life cycle. + !#zh 定义一条曲线来决定粒子在其生命周期中 Z 轴方向上的大小变化。 */ + z: CurveRange; + } + /** !#en The texture animation module of 3d particle. + !#zh 3D 粒子的贴图动画模块 */ + export class TextureAnimationModule { + /** !#en The enable of TextureAnimationModule. + !#zh 是否启用 */ + enable: boolean; + /** !#en Set the type of particle map animation (only supports Grid mode for the time being) + !#zh 设定粒子贴图动画的类型(暂只支持 Grid 模式。 */ + mode: ParticleSystem.EmitterMode; + /** !#en Animation frames in X direction. + !#zh X 方向动画帧数。 */ + numTilesX: number; + /** !#en Animation frames in Y direction. + !#zh Y 方向动画帧数。 */ + numTilesY: number; + /** !#en The way of the animation plays. + !#zh 动画播放方式。 */ + animation: Animation; + /** !#en Randomly select a line from the animated map to generate the animation.
+ This option only takes effect when the animation playback mode is SingleRow. + !#zh 随机从动画贴图中选择一行以生成动画。
+ 此选项仅在动画播放方式为 SingleRow 时生效。 */ + randomRow: boolean; + /** !#en Select specific lines from the animation map to generate the animation.
+ This option is only available when the animation playback mode is SingleRow and randomRow is disabled. + !#zh 从动画贴图中选择特定行以生成动画。
+ 此选项仅在动画播放方式为 SingleRow 时且禁用 randomRow 时可用。 */ + rowIndex: number; + /** !#en Frame and time curve of animation playback in one cycle. + !#zh 一个周期内动画播放的帧与时间变化曲线。 */ + frameOverTime: CurveRange; + /** !#en Play from which frames, the time is the life cycle of the entire particle system. + !#zh 从第几帧开始播放,时间为整个粒子系统的生命周期。 */ + startFrame: CurveRange; + /** !#en Number of playback loops in a life cycle. + !#zh 一个生命周期内播放循环的次数。 */ + cycleCount: number; + } + /** !#en The velocity module of 3d particle. + !#zh 3D 粒子的速度模块 */ + export class VelocityOvertimeModule { + /** !#en The enable of VelocityOvertimeModule. + !#zh 是否启用 */ + enable: boolean; + /** !#en Coordinate system used in speed calculation. + !#zh 速度计算时采用的坐标系。 */ + space: Space; + /** !#en Velocity component in X axis direction + !#zh X 轴方向上的速度分量。 */ + x: CurveRange; + /** !#en Velocity component in Y axis direction + !#zh Y 轴方向上的速度分量。 */ + y: CurveRange; + /** !#en Velocity component in Z axis direction + !#zh Z 轴方向上的速度分量。 */ + z: CurveRange; + /** !#en Speed correction factor (only supports CPU particles). + !#zh 速度修正系数(只支持 CPU 粒子)。 */ + speedModifier: CurveRange; + } + /** !#en The shape module of 3d particle. + !#zh 3D 粒子的发射形状模块 */ + export class ShapeModule { + /** !#en The enable of shapeModule. + !#zh 是否启用 */ + enable: boolean; + /** !#en Particle emitter type. + !#zh 粒子发射器类型。 */ + shapeType: shapeModule.ShapeType; + /** !#en The emission site of the particle. + !#zh 粒子从发射器哪个部位发射。 */ + emitFrom: shapeModule.EmitLocation; + /** !#en Particle emitter radius. + !#zh 粒子发射器半径。 */ + radius: number; + /** !#en Particle emitter emission position (not valid for Box type emitters): + - 0 means emitted from the surface; + - 1 means launch from the center; + - 0 ~ 1 indicates emission from the center to the surface. + !#zh 粒子发射器发射位置(对 Box 类型的发射器无效): + - 0 表示从表面发射; + - 1 表示从中心发射; + - 0 ~ 1 之间表示在中心到表面之间发射。 */ + radiusThickness: number; + /** !#en The angle between the axis of the cone and the generatrix + Determines the opening and closing of the cone launcher + !#zh 圆锥的轴与母线的夹角。 + 决定圆锥发射器的开合程度。 */ + angle: number; + /** !#en Particle emitters emit in a fan-shaped range. + !#zh 粒子发射器在一个扇形范围内发射。 */ + arc: number; + /** !#en How particles are emitted in the sector range. + !#zh 粒子在扇形范围内的发射方式。 */ + arcMode: shapeModule.ArcMode; + /** !#en Controls the discrete intervals around the arcs where particles might be generated. + !#zh 控制可能产生粒子的弧周围的离散间隔。 */ + arcSpread: number; + /** !#en The speed at which particles are emitted around the circumference. + !#zh 粒子沿圆周发射的速度。 */ + arcSpeed: CurveRange; + /** !#en Axis length from top of cone to bottom of cone . + Determines the height of the cone emitter. + !#zh 圆锥顶部截面距离底部的轴长。 + 决定圆锥发射器的高度。 */ + length: number; + /** !#en Particle emitter emission location (for box-type particle emitters). + !#zh 粒子发射器发射位置(针对 Box 类型的粒子发射器。 */ + boxThickness: Vec3; + /** !#en Particle Emitter Position + !#zh 粒子发射器位置。 */ + position: Vec3; + /** !#en Particle emitter rotation angle. + !#zh 粒子发射器旋转角度。 */ + rotation: Vec3; + /** !#en Particle emitter scaling + !#zh 粒子发射器缩放比例。 */ + scale: Vec3; + /** !#en The direction of particle movement is determined based on the initial direction of the particles. + !#zh 根据粒子的初始方向决定粒子的移动方向。 */ + alignToDirection: boolean; + /** !#en Set particle generation direction randomly. + !#zh 粒子生成方向随机设定。 */ + randomDirectionAmount: number; + /** !#en Interpolation between the current emission direction and the direction from the current position to the center of the node. + !#zh 表示当前发射方向与当前位置到结点中心连线方向的插值。 */ + sphericalDirectionAmount: number; + } + /** !#en The trail module of 3d particle. + !#zh 3D 粒子拖尾模块 */ + export class TrailModule { + /** !#en The enable of trailModule. + !#zh 是否启用 */ + enable: boolean; + /** !#en Sets how particles generate trajectories. + !#zh 设定粒子生成轨迹的方式。 */ + mode: trailModule.TrailMode; + /** !#en Life cycle of trajectory. + !#zh 轨迹存在的生命周期。 */ + lifeTime: CurveRange; + /** !#en Minimum spacing between each track particle + !#zh 每个轨迹粒子之间的最小间距。 */ + minParticleDistance: number; + /** !#en The coordinate system of trajectories. + !#zh 轨迹设定时的坐标系。 */ + space: Space; + /** !#en Whether the particle itself exists. + !#zh 粒子本身是否存在。 */ + existWithParticles: boolean; + /** !#en Set the texture fill method + !#zh 设定纹理填充方式。 */ + textureMode: trailModule.TextureMode; + /** !#en Whether to use particle width + !#zh 是否使用粒子的宽度。 */ + widthFromParticle: boolean; + /** !#en Curves that control track length + !#zh 控制轨迹长度的曲线。 */ + widthRatio: CurveRange; + /** !#en Whether to use particle color + !#zh 是否使用粒子的颜色。 */ + colorFromParticle: boolean; + /** !#en The color of trajectories. + !#zh 轨迹的颜色。 */ + colorOverTrail: GradientRange; + /** !#en Trajectories color over time. + !#zh 轨迹随时间变化的颜色。 */ + colorOvertime: GradientRange; + } + /** !#en The rigid body type + !#zh 刚体类型 */ + export enum ERigidBodyType { + DYNAMIC = 0, + STATIC = 0, + KINEMATIC = 0, + } + /** !#en + Trigger event + !#zh + 触发事件。 */ + export class ITriggerEvent { + /** !#en + The type of event fired + !#zh + 触发的事件类型 */ + type: string; + /** !#en + Triggers its own collider in the event + !#zh + 触发事件中的自己的碰撞器 */ + selfCollider: Collider3D; + /** !#en + Triggers another collider in the event + !#zh + 触发事件中的另一个碰撞器 */ + otherCollider: Collider3D; + } + /** !#en + Collision information for collision events. + !#zh + 碰撞事件的碰撞信息。 */ + export class IContactEquation { + /** !#en + The collision point A in the collision information. + !#zh + 碰撞信息中的碰撞点A。 */ + contactA: Vec3; + /** !#en + Collision point B in collision information. + !#zh + 碰撞信息中的碰撞点B。 */ + contactB: Vec3; + /** !#en + Normals in collision information. + !#zh + 碰撞信息中的法线。 */ + normal: Vec3; + } + /** !#en + Collision events. + !#zh + 碰撞事件。 */ + export class ICollisionEvent { + /** !#en + Event type of collision. + !#zh + 碰撞的事件类型。 */ + type: string; + /** !#en + Collider of its own in collision. + !#zh + 碰撞中的自己的碰撞器。 */ + selfCollider: Collider3D; + /** !#en + Another collider in the collision. + !#zh + 碰撞中的另一个碰撞器。 */ + otherCollider: Collider3D; + /** !#en + Information about all the points of impact in the collision. + !#zh + 碰撞中的所有碰撞点的信息。 */ + contacts: IContactEquation[]; + } + /** !#en + Physical systems manager. + !#zh + 物理系统管理器。 */ + export class Physics3DManager { + /** !#en + Gets or sets whether to enable physical systems, which are not enabled by default. + !#zh + 获取或设置是否启用物理系统,默认不启用。 */ + enabled: boolean; + /** !#en + Gets or sets whether the physical system allows automatic sleep, which defaults to true. + !#zh + 获取或设置物理系统是否允许自动休眠,默认为 true */ + allowSleep: boolean; + /** !#en + Gets or sets the maximum number of child steps per frame simulated. + !#zh + 获取或设置每帧模拟的最大子步数。 */ + maxSubStep: number; + /** !#en + Gets or sets the fixed time consumed by each simulation step. + !#zh + 获取或设置每步模拟消耗的固定时间。 */ + deltaTime: number; + /** !#en + Gets or sets whether to use a fixed time step. + !#zh + 获取或设置是否使用固定的时间步长。 */ + useFixedTime: boolean; + /** !#en + Gets or sets the gravity value of the physical world, by default (0, -10, 0) + !#zh + 获取或设置物理世界的重力数值,默认为 (0, -10, 0) */ + gravity: Vec3; + /** !#en + Gets the global default physical material. Note that builtin is null + !#zh + 获取全局的默认物理材质,注意:builtin 时为 null */ + defaultMaterial: PhysicsMaterial|void; + /** + !#en + A physical system simulation is performed once and will now be performed automatically once per frame. + !#zh + 执行一次物理系统的模拟,目前将在每帧自动执行一次。 + @param deltaTime The time difference from the last execution is currently elapsed per frame + */ + update(deltaTime: number): void; + /** + !#en Detect all collision boxes and return all detected results, or null if none is detected. Note that the return value is taken from the object pool, so do not save the result reference or modify the result. + !#zh 检测所有的碰撞盒,并返回所有被检测到的结果,若没有检测到,则返回空值。注意返回值是从对象池中取的,所以请不要保存结果引用或者修改结果。 + @param worldRay A ray in world space + @param groupIndexOrName Collision group index or group name + @param maxDistance Maximum detection distance + @param queryTrigger Detect trigger or not + */ + raycast(worldRay: geomUtils.Ray, groupIndexOrName: number|string, maxDistance: number, queryTrigger: boolean): PhysicsRayResult[]; + /** + !#en Detect all collision boxes and return the detection result with the shortest ray distance. If not, return null value. Note that the return value is taken from the object pool, so do not save the result reference or modify the result. + !#zh 检测所有的碰撞盒,并返回射线距离最短的检测结果,若没有,则返回空值。注意返回值是从对象池中取的,所以请不要保存结果引用或者修改结果。 + @param worldRay A ray in world space + @param groupIndexOrName Collision group index or group name + @param maxDistance Maximum detection distance + @param queryTrigger Detect trigger or not + */ + raycastClosest(worldRay: geomUtils.Ray, groupIndexOrName: number|string, maxDistance: number, queryTrigger: boolean): PhysicsRayResult; + } + /** !#en + Used to store physical ray detection results + !#zh + 用于保存物理射线检测结果 */ + export class PhysicsRayResult { + /** !#en + Hit the point + !#zh + 击中点 */ + hitPoint: Vec3; + /** !#en + Distance + !#zh + 距离 */ + distance: number; + /** !#en + Hit the collision box + !#zh + 击中的碰撞盒 */ + collider: Collider3D; + /** + !#en + Set up ray. This method is used internally by the engine. Do not call it from an external script + !#zh + 设置射线,此方法由引擎内部使用,请勿在外部脚本调用 + @param hitPoint hitPoint + @param distance distance + @param collider collider + */ + _assign(hitPoint: Vec3, distance: number, collider: Collider3D): void; + /** + !#en + Clone + !#zh + 克隆 + */ + clone(): void; + } + /** Rigid body interface */ + export class IRigidBody { + rigidBody: RigidBody3D; + mass: number; + linearDamping: number; + angularDamping: number; + isKinematic: boolean; + useGravity: boolean; + fixedRotation: boolean; + linearFactor: IVec3Like; + angularFactor: IVec3Like; + allowSleep: boolean; + isAwake: boolean; + isSleepy: boolean; + isSleeping: boolean; + wakeUp(): void; + sleep(): void; + /** + + @param out out + */ + getLinearVelocity(out: IVec3Like): void; + /** + + @param out out + */ + setLinearVelocity(out: IVec3Like): void; + /** + + @param out out + */ + getAngularVelocity(out: IVec3Like): void; + /** + + @param out out + */ + setAngularVelocity(out: IVec3Like): void; + /** + + @param force force + @param relativePoint relativePoint + */ + applyForce(force: IVec3Like, relativePoint: IVec3Like): void; + /** + + @param force force + @param relativePoint relativePoint + */ + applyLocalForce(force: IVec3Like, relativePoint: IVec3Like): void; + /** + + @param force force + @param relativePoint relativePoint + */ + applyImpulse(force: IVec3Like, relativePoint: IVec3Like): void; + /** + + @param force force + @param relativePoint relativePoint + */ + applyLocalImpulse(force: IVec3Like, relativePoint: IVec3Like): void; + /** + + @param torque torque + */ + applyTorque(torque: IVec3Like): void; + /** + + @param torque torque + */ + applyLocalTorque(torque: IVec3Like): void; + } + /** Class has x y z properties */ + export class IVec3Like { + x: number; + y: number; + z: number; + } + /** Class has x y z w properties */ + export class IQuatLike { + x: number; + y: number; + z: number; + w: number; + } + /** !#en Base shape interface. */ + export class IBaseShape { + collider: Collider3D; + attachedRigidBody: RigidBody3D|void; + material: any; + isTrigger: boolean; + center: IVec3Like; + } + /** !#en box shape interface */ + export class IBoxShape { + size: IVec3Like; + } + /** !#en Sphere shape interface */ + export class ISphereShape { + radius: number; + } + /** Ray cast options */ + export class IRaycastOptions { + groupIndex: number; + queryTrigger: boolean; + maxDistance: number; + } + /** Collision detect */ + export class ICollisionDetect { + /** + Ray cast, and return information of the closest hit. + @param worldRay worldRay + @param options options + @param out out + */ + raycastClosest(worldRay: geomUtils.Ray, options: IRaycastOptions, out: PhysicsRayResult): boolean; + /** + Ray cast against all bodies. The provided callback will be executed for each hit with a RaycastResult as single argument. + @param worldRay worldRay + @param options options + @param pool pool + @param resultes resultes + */ + raycast(worldRay: geomUtils.Ray, options: IRaycastOptions, pool: RecyclePool, resultes: PhysicsRayResult[]): boolean; + } + /** Physics world interface */ + export class IPhysicsWorld { + } + /** !#en Manage Dynamic Atlas Manager. Dynamic Atlas Manager is used for merging textures at runtime, see [Dynamic Atlas](https://docs.cocos.com/creator/manual/en/advanced-topics/dynamic-atlas.html) for details. + !#zh 管理动态图集。动态图集用于在运行时对贴图进行合并,详见 [动态合图](https://docs.cocos.com/creator/manual/zh/advanced-topics/dynamic-atlas.html)。 */ + export class DynamicAtlasManager { + /** !#en Enable or disable the dynamic atlas, see [Dynamic Atlas](https://docs.cocos.com/creator/manual/en/advanced-topics/dynamic-atlas.html) for details. + !#zh 开启或者关闭动态图集,详见 [动态合图](https://docs.cocos.com/creator/manual/zh/advanced-topics/dynamic-atlas.html)。 */ + enabled: boolean; + /** !#en The maximum number of atlas that can be created. + !#zh 可以创建的最大图集数量。 */ + maxAtlasCount: number; + /** !#en Is enable textureBleeding. + !#zh 是否开启 textureBleeding */ + textureBleeding: boolean; + /** !#en The size of the atlas that was created + !#zh 创建的图集的宽高 */ + textureSize: number; + /** !#en The maximum size of the picture that can be added to the atlas. + !#zh 可以添加进图集的图片的最大尺寸。 */ + maxFrameSize: number; + /** !#en The minimum size of the picture that can be added to the atlas. + !#zh 可以添加进图集的图片的最小尺寸。 */ + minFrameSize: number; + /** + !#en Append a sprite frame into the dynamic atlas. + !#zh 添加碎图进入动态图集。 + @param spriteFrame spriteFrame + */ + insertSpriteFrame(spriteFrame: SpriteFrame): void; + /** + !#en Resets all dynamic atlas, and the existing ones will be destroyed. + !#zh 重置所有动态图集,已有的动态图集会被销毁。 + */ + reset(): void; + /** + !#en Displays all the dynamic atlas in the current scene, which you can use to view the current atlas state. + !#zh 在当前场景中显示所有动态图集,可以用来查看当前的合图状态。 + @param show show + */ + showDebug(show: boolean): void; + } + /** Physics material. */ + export class PhysicsMaterial extends Asset { + /** Friction for this material. + If non-negative, it will be used instead of the friction given by ContactMaterials. + If there's no matching ContactMaterial, the value from .defaultContactMaterial in the World will be used. */ + friction: number; + /** Restitution for this material. + If non-negative, it will be used instead of the restitution given by ContactMaterials. + If there's no matching ContactMaterial, the value from .defaultContactMaterial in the World will be used */ + restitution: number; + } + /** !#en + Each frame applies a constant force to a rigid body, depending on the RigidBody3D + !#zh + 在每帧对一个刚体施加持续的力,依赖 RigidBody3D 组件 */ + export class ConstantForce extends Component { + /** !#en + To get and set the force that the world is facing, use this.force = otherVec3 + !#zh + 获取和设置世界朝向的力, 设置时请用 this.force = otherVec3 的方式 */ + force: Vec3; + /** !#en + Get and set the force of the local orientation, using this.localforce = otherVec3 + !#zh + 获取和设置本地朝向的力, 设置时请用 this.localForce = otherVec3 的方式 */ + localForce: Vec3; + /** !#zh + 获取和设置世界朝向的扭转力 */ + torque: Vec3; + /** !#en + Get and set the torque of the local orientation using this.localtorque = otherVec3 + !#zh + 获取和设置本地朝向的扭转力, 设置时请用 this.localTorque = otherVec3 的方式 */ + localTorque: Vec3; + } + /** !#en + Rigid body. + !#zh + 刚体组件。 */ + export class RigidBody3D extends Component { + /** !#en + Gets or sets whether sleep is allowed + !#zh + 获取或设置是否允许休眠 */ + allowSleep: boolean; + /** !#en + Gets or sets the mass of the rigid body. + !#zh + 获取或设置刚体的质量。 */ + mass: number; + /** !#en + Gets or sets linear damping. + !#zh + 获取或设置线性阻尼。 */ + linearDamping: number; + /** !#en + Gets or sets rotational damping. + !#zh + 获取或设置旋转阻尼。 */ + angularDamping: number; + /** !#en + Gets or sets whether the rigid body is controlled by a physical system. + !#zh + 获取或设置刚体是否由物理系统控制运动。 */ + isKinematic: boolean; + /** !#en + Gets or sets whether the rigid body uses gravity. + !#zh + 获取或设置刚体是否使用重力。 */ + useGravity: boolean; + /** !#en + Gets or sets whether the rigid body is fixed for rotation. + !#zh + 获取或设置刚体是否固定旋转。 */ + fixedRotation: boolean; + /** !#en + Gets or sets a factor of linear velocity that can be used to control the scaling of velocity in each axis direction. + !#zh + 获取或设置线性速度的因子,可以用来控制每个轴方向上的速度的缩放。 */ + linearFactor: Vec3; + /** !#en + Gets or sets the rotation speed factor that can be used to control the rotation speed scaling in each axis direction. + !#zh + 获取或设置旋转速度的因子,可以用来控制每个轴方向上的旋转速度的缩放。 */ + angularFactor: Vec3; + /** !#en + Gets whether the state is awakened. + !#zh + 获取是否是唤醒的状态。 */ + isAwake: boolean; + /** !#en + Gets whether or not a dormant state can be entered. + !#zh + 获取是否是可进入休眠的状态。 */ + isSleepy: boolean; + /** !#en + Gets whether the state is dormant. + !#zh + 获取是否是正在休眠的状态。 */ + isSleeping: boolean; + /** !#en + Gets physics engine rigid body object. + !#zh + 获得物理引擎内部刚体对象 */ + rigidBody: IRigidBody; + /** + !#en + A force is applied to a rigid body at a point in world space. + !#zh + 在世界空间中的某点上对刚体施加一个作用力。 + @param force force + @param relativePoint The point of action, relative to the center of the rigid body + */ + applyForce(force: Vec3, relativePoint: Vec3): void; + /** + !#en + Apply a force on the rigid body at a point in local space. + !#zh + 在本地空间中的某点上对刚体施加一个作用力。 + @param force force + @param localPoint Point of application + */ + applyLocalForce(force: Vec3, localPoint: Vec3): void; + /** + !#en + Apply an impulse to a rigid body at a point in world space. + !#zh + 在世界空间的某点上对刚体施加一个冲量。 + @param impulse impulse + @param relativePoint The point of action, relative to the center of the rigid body + */ + applyImpulse(impulse: Vec3, relativePoint: Vec3): void; + /** + !#en + Apply an impulse to the rigid body at a point in local space. + !#zh + 在本地空间的某点上对刚体施加一个冲量。 + @param impulse impulse + @param localPoint Point of application + */ + applyLocalImpulse(impulse: Vec3, localPoint: Vec3): void; + /** + !#en + Apply a torque to the rigid body. + !#zh + 对刚体施加扭转力。 + @param torque torque + */ + applyTorque(torque: Vec3): void; + /** + !#en + Apply a local torque to the rigid body. + !#zh + 对刚体施加本地扭转力。 + @param torque torque + */ + applyLocalTorque(torque: Vec3): void; + /** + !#en + Awaken the rigid body. + !#zh + 唤醒刚体。 + */ + wakeUp(): void; + /** + !#en + Dormant rigid body. + !#zh + 休眠刚体。 + */ + sleep(): void; + /** + !#en + Get linear velocity. + !#zh + 获取线性速度。 + @param out out + */ + getLinearVelocity(out: Vec3): void; + /** + !#en + Set linear speed. + !#zh + 设置线性速度。 + @param value value + */ + setLinearVelocity(value: Vec3): void; + /** + !#en + Gets the rotation speed. + !#zh + 获取旋转速度。 + @param out out + */ + getAngularVelocity(out: Vec3): void; + /** + !#en + Set rotation speed. + !#zh + 设置旋转速度。 + @param value value + */ + setAngularVelocity(value: Vec3): void; + } + /** !#en + Physics box collider + !#zh + 物理盒子碰撞器 */ + export class BoxCollider3D extends Collider3D { + /** !#en + Get or set the size of the box, in local space. + !#zh + 获取或设置盒的大小。 */ + size: Vec3; + boxShape: IBoxShape; + } + /** !#en + The base class of the collider + !#zh + 碰撞器的基类 */ + export class Collider3D extends Component implements EventTarget { + sharedMaterial: PhysicsMaterial; + /** !#en + get or set the collider is trigger, this will be always trigger if using builtin. + !#zh + 获取或设置碰撞器是否为触发器 */ + isTrigger: boolean; + /** !#en + get or set the center of the collider, in local space. + !#zh + 获取或设置碰撞器的中心点。 */ + center: Vec3; + /** !#en + get the collider attached rigidbody, this may be null + !#zh + 获取碰撞器所绑定的刚体组件,可能为 null */ + attachedRigidbody: RigidBody3D|void; + /** !#en + get collider shape + !#zh + 获取碰撞器形状 */ + shape: IBaseShape; + /** + !#en + Register an callback of a specific event type on the EventTarget. + This type of event should be triggered via `emit`. + !#zh + 注册事件目标的特定事件类型回调。这种类型的事件应该被 `emit` 触发。 + @param type The type of collider event can be 'trigger-enter', 'trigger-stay', 'trigger-exit' or 'collision-enter', 'collision-stay', 'collision-exit'. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.on('fire', function (event) { + // event is ITriggerEvent or ICollisionEvent + }, node); + ``` + */ + on(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. + !#zh + 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。 + @param type The type of collider event can be 'trigger-enter', 'trigger-stay', 'trigger-exit' or 'collision-enter', 'collision-stay', 'collision-exit'. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + + @example + ```js + // register fire eventListener + var callback = eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, target); + // remove fire event listener + eventTarget.off('fire', callback, target); + // remove all fire event listeners + eventTarget.off('fire'); + ``` + */ + off(type: string, callback?: Function, target?: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type The type of collider event can be 'trigger-enter', 'trigger-stay', 'trigger-exit' or 'collision-enter', 'collision-stay', 'collision-exit'. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.once('fire', function (event) { + // event is ITriggerEvent or ICollisionEvent + }, node); + ``` + */ + once(type: string, callback: (event: ITriggerEvent|ICollisionEvent) => void, target?: any): void; + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Send an event with the event object. + !#zh + 通过事件对象派发事件 + @param event event + */ + dispatchEvent(event: Event): void; + } + /** !#en + Physics sphere collider + !#zh + 物理球碰撞器 */ + export class SphereCollider3D extends Collider3D { + /** !#en + Get or set the radius of the sphere. + !#zh + 获取或设置球的半径。 */ + radius: number; + sphereShape: ISphereShape; + } + /**************************************************** + * audioEngine + *****************************************************/ + + export namespace audioEngine { + /** !#en Audio state. + !#zh 声音播放状态 */ + export enum AudioState { + ERROR = 0, + INITIALZING = 0, + PLAYING = 0, + PAUSED = 0, + STOPPED = 0, + } + } + + /**************************************************** + * ParticleSystem + *****************************************************/ + + export namespace ParticleSystem { + /** !#en Enum for emitter modes + !#zh 发射模式 */ + export enum EmitterMode { + GRAVITY = 0, + RADIUS = 0, + } + } + + /**************************************************** + * ParticleSystem + *****************************************************/ + + export namespace ParticleSystem { + /** !#en Enum for particles movement type. + !#zh 粒子位置类型 */ + export enum PositionType { + FREE = 0, + RELATIVE = 0, + GROUPED = 0, + } + } + + /**************************************************** + * TiledMap + *****************************************************/ + + export namespace TiledMap { + /** !#en The orientation of tiled map. + !#zh Tiled Map 地图方向。 */ + export enum Orientation { + ORTHO = 0, + HEX = 0, + ISO = 0, + } + } + + /**************************************************** + * TiledMap + *****************************************************/ + + export namespace TiledMap { + /** The property type of tiled map. */ + export enum Property { + NONE = 0, + MAP = 0, + LAYER = 0, + OBJECTGROUP = 0, + OBJECT = 0, + TILE = 0, + } + } + + /**************************************************** + * TiledMap + *****************************************************/ + + export namespace TiledMap { + /** The tile flags of tiled map. */ + export enum TileFlag { + HORIZONTAL = 0, + VERTICAL = 0, + DIAGONAL = 0, + FLIPPED_ALL = 0, + FLIPPED_MASK = 0, + } + } + + /**************************************************** + * TiledMap + *****************************************************/ + + export namespace TiledMap { + /** !#en The stagger axis of Hex tiled map. + !#zh 六边形地图的 stagger axis 值 */ + export enum StaggerAxis { + STAGGERAXIS_X = 0, + STAGGERAXIS_Y = 0, + } + } + + /**************************************************** + * TiledMap + *****************************************************/ + + export namespace TiledMap { + /** !#en The render order of tiled map. + !#zh 地图的渲染顺序 */ + export enum RenderOrder { + STAGGERINDEX_ODD = 0, + STAGGERINDEX_EVEN = 0, + RightDown = 0, + RightUp = 0, + LeftDown = 0, + LeftUp = 0, + } + } + + /**************************************************** + * TiledMap + *****************************************************/ + + export namespace TiledMap { + /** !#en TiledMap Object Type + !#zh 地图物体类型 */ + export enum TMXObjectType { + RECT = 0, + ELLIPSE = 0, + POLYGON = 0, + POLYLINE = 0, + IMAGE = 0, + TEXT = 0, + } + } + + /**************************************************** + * WebView + *****************************************************/ + + export namespace WebView { + /** !#en WebView event type + !#zh 网页视图事件类型 */ + export enum EventType { + LOADED = 0, + LOADING = 0, + ERROR = 0, + } + } + + /**************************************************** + * VideoPlayer + *****************************************************/ + + export namespace VideoPlayer { + /** !#en Video event type + !#zh 视频事件类型 */ + export enum EventType { + PLAYING = 0, + PAUSED = 0, + STOPPED = 0, + COMPLETED = 0, + META_LOADED = 0, + CLICKED = 0, + READY_TO_PLAY = 0, + } + } + + /**************************************************** + * VideoPlayer + *****************************************************/ + + export namespace VideoPlayer { + /** !#en Enum for video resouce type type. + !#zh 视频来源 */ + export enum ResourceType { + REMOTE = 0, + LOCAL = 0, + } + } + + /**************************************************** + * debug + *****************************************************/ + + export namespace debug { + /** !#en Enum for debug modes. + !#zh 调试模式 */ + export enum DebugMode { + NONE = 0, + INFO = 0, + WARN = 0, + ERROR = 0, + INFO_FOR_WEB_PAGE = 0, + WARN_FOR_WEB_PAGE = 0, + ERROR_FOR_WEB_PAGE = 0, + } + } + + /**************************************************** + * Node + *****************************************************/ + + export namespace Node { + /** !#en Node's local dirty properties flag + !#zh Node 的本地属性 dirty 状态位 */ + export enum _LocalDirtyFlag { + POSITION = 0, + SCALE = 0, + ROTATION = 0, + SKEW = 0, + TRS = 0, + RS = 0, + TRS = 0, + PHYSICS_POSITION = 0, + PHYSICS_SCALE = 0, + PHYSICS_ROTATION = 0, + PHYSICS_TRS = 0, + PHYSICS_RS = 0, + ALL_POSITION = 0, + ALL_SCALE = 0, + ALL_ROTATION = 0, + ALL_TRS = 0, + ALL = 0, + } + } + + /**************************************************** + * Node + *****************************************************/ + + export namespace Node { + /** !#en The event type supported by Node + !#zh Node 支持的事件类型 */ + export class EventType { + /** !#en The event type for touch start event, you can use its value directly: 'touchstart' + !#zh 当手指触摸到屏幕时。 */ + static TOUCH_START: string; + /** !#en The event type for touch move event, you can use its value directly: 'touchmove' + !#zh 当手指在屏幕上移动时。 */ + static TOUCH_MOVE: string; + /** !#en The event type for touch end event, you can use its value directly: 'touchend' + !#zh 当手指在目标节点区域内离开屏幕时。 */ + static TOUCH_END: string; + /** !#en The event type for touch end event, you can use its value directly: 'touchcancel' + !#zh 当手指在目标节点区域外离开屏幕时。 */ + static TOUCH_CANCEL: string; + /** !#en The event type for mouse down events, you can use its value directly: 'mousedown' + !#zh 当鼠标按下时触发一次。 */ + static MOUSE_DOWN: string; + /** !#en The event type for mouse move events, you can use its value directly: 'mousemove' + !#zh 当鼠标在目标节点在目标节点区域中移动时,不论是否按下。 */ + static MOUSE_MOVE: string; + /** !#en The event type for mouse enter target events, you can use its value directly: 'mouseenter' + !#zh 当鼠标移入目标节点区域时,不论是否按下。 */ + static MOUSE_ENTER: string; + /** !#en The event type for mouse leave target events, you can use its value directly: 'mouseleave' + !#zh 当鼠标移出目标节点区域时,不论是否按下。 */ + static MOUSE_LEAVE: string; + /** !#en The event type for mouse up events, you can use its value directly: 'mouseup' + !#zh 当鼠标从按下状态松开时触发一次。 */ + static MOUSE_UP: string; + /** !#en The event type for mouse wheel events, you can use its value directly: 'mousewheel' + !#zh 当鼠标滚轮滚动时。 */ + static MOUSE_WHEEL: string; + /** !#en The event type for position change events. + Performance note, this event will be triggered every time corresponding properties being changed, + if the event callback have heavy logic it may have great performance impact, try to avoid such scenario. + !#zh 当节点位置改变时触发的事件。 + 性能警告:这个事件会在每次对应的属性被修改时触发,如果事件回调损耗较高,有可能对性能有很大的负面影响,请尽量避免这种情况。 */ + static POSITION_CHANGED: string; + /** !#en The event type for rotation change events. + Performance note, this event will be triggered every time corresponding properties being changed, + if the event callback have heavy logic it may have great performance impact, try to avoid such scenario. + !#zh 当节点旋转改变时触发的事件。 + 性能警告:这个事件会在每次对应的属性被修改时触发,如果事件回调损耗较高,有可能对性能有很大的负面影响,请尽量避免这种情况。 */ + static ROTATION_CHANGED: string; + /** !#en The event type for scale change events. + Performance note, this event will be triggered every time corresponding properties being changed, + if the event callback have heavy logic it may have great performance impact, try to avoid such scenario. + !#zh 当节点缩放改变时触发的事件。 + 性能警告:这个事件会在每次对应的属性被修改时触发,如果事件回调损耗较高,有可能对性能有很大的负面影响,请尽量避免这种情况。 */ + static SCALE_CHANGED: string; + /** !#en The event type for size change events. + Performance note, this event will be triggered every time corresponding properties being changed, + if the event callback have heavy logic it may have great performance impact, try to avoid such scenario. + !#zh 当节点尺寸改变时触发的事件。 + 性能警告:这个事件会在每次对应的属性被修改时触发,如果事件回调损耗较高,有可能对性能有很大的负面影响,请尽量避免这种情况。 */ + static SIZE_CHANGED: string; + /** !#en The event type for anchor point change events. + Performance note, this event will be triggered every time corresponding properties being changed, + if the event callback have heavy logic it may have great performance impact, try to avoid such scenario. + !#zh 当节点锚点改变时触发的事件。 + 性能警告:这个事件会在每次对应的属性被修改时触发,如果事件回调损耗较高,有可能对性能有很大的负面影响,请尽量避免这种情况。 */ + static ANCHOR_CHANGED: string; + /** !#en The event type for color change events. + Performance note, this event will be triggered every time corresponding properties being changed, + if the event callback have heavy logic it may have great performance impact, try to avoid such scenario. + !#zh 当节点颜色改变时触发的事件。 + 性能警告:这个事件会在每次对应的属性被修改时触发,如果事件回调损耗较高,有可能对性能有很大的负面影响,请尽量避免这种情况。 */ + static COLOR_CHANGED: string; + /** !#en The event type for new child added events. + !#zh 当新的子节点被添加时触发的事件。 */ + static CHILD_ADDED: string; + /** !#en The event type for child removed events. + !#zh 当子节点被移除时触发的事件。 */ + static CHILD_REMOVED: string; + /** !#en The event type for children reorder events. + !#zh 当子节点顺序改变时触发的事件。 */ + static CHILD_REORDER: string; + /** !#en The event type for node group changed events. + !#zh 当节点归属群组发生变化时触发的事件。 */ + static GROUP_CHANGED: string; + /** !#en The event type for node's sibling order changed. + !#zh 当节点在兄弟节点中的顺序发生变化时触发的事件。 */ + static SIBLING_ORDER_CHANGED: string; + } + } + + /**************************************************** + * Light + *****************************************************/ + + export namespace Light { + /** !#en The light source type + + !#zh 光源类型 */ + export enum Type { + DIRECTIONAL = 0, + POINT = 0, + SPOT = 0, + AMBIENT = 0, + } + } + + /**************************************************** + * Light + *****************************************************/ + + export namespace Light { + /** !#en The shadow type + + !#zh 阴影类型 */ + export enum ShadowType { + NONE = 0, + HARD = 0, + SOFT_PCF3X3 = 0, + SOFT_PCF5X5 = 0, + } + } + + /**************************************************** + * Prefab + *****************************************************/ + + export namespace Prefab { + /** !#zh + Prefab 创建实例所用的优化策略,配合 {{#crossLink "Prefab.optimizationPolicy"}}cc.Prefab#optimizationPolicy{{/crossLink}} 使用。 + !#en + An enumeration used with the {{#crossLink "Prefab.optimizationPolicy"}}cc.Prefab#optimizationPolicy{{/crossLink}} + to specify how to optimize the instantiate operation. */ + export enum OptimizationPolicy { + AUTO = 0, + SINGLE_INSTANCE = 0, + MULTI_INSTANCE = 0, + } + } + + /**************************************************** + * RenderTexture + *****************************************************/ + + export namespace RenderTexture { + /** !#en The depth buffer and stencil buffer format for RenderTexture. + !#zh RenderTexture 的深度缓冲以及模板缓冲格式。 */ + export enum DepthStencilFormat { + RB_FMT_D24S8 = 0, + RB_FMT_S8 = 0, + RB_FMT_D16 = 0, + } + } + + /**************************************************** + * Texture2D + *****************************************************/ + + export namespace Texture2D { + /** The texture pixel format, default value is RGBA8888, + you should note that textures loaded by normal image files (png, jpg) can only support RGBA8888 format, + other formats are supported by compressed file types or raw data. */ + export enum PixelFormat { + RGB565 = 0, + RGB5A1 = 0, + RGBA4444 = 0, + RGB888 = 0, + RGBA8888 = 0, + RGBA32F = 0, + A8 = 0, + I8 = 0, + AI88 = 0, + RGB_PVRTC_2BPPV1 = 0, + RGBA_PVRTC_2BPPV1 = 0, + RGB_A_PVRTC_2BPPV1 = 0, + RGB_PVRTC_4BPPV1 = 0, + RGBA_PVRTC_4BPPV1 = 0, + RGB_A_PVRTC_4BPPV1 = 0, + RGB_ETC1 = 0, + RGBA_ETC1 = 0, + RGB_ETC2 = 0, + RGBA_ETC2 = 0, + } + } + + /**************************************************** + * Texture2D + *****************************************************/ + + export namespace Texture2D { + /** The texture wrap mode */ + export enum WrapMode { + REPEAT = 0, + CLAMP_TO_EDGE = 0, + MIRRORED_REPEAT = 0, + } + } + + /**************************************************** + * Texture2D + *****************************************************/ + + export namespace Texture2D { + /** The texture filter mode */ + export enum Filter { + LINEAR = 0, + NEAREST = 0, + } + } + + /**************************************************** + * Collider + *****************************************************/ + + export namespace Collider { + /** !#en Defines a Box Collider . + !#zh 用来定义包围盒碰撞体 */ + export class Box { + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Box size + !#zh 包围盒大小 */ + size: Size; + } + } + + /**************************************************** + * Collider + *****************************************************/ + + export namespace Collider { + /** !#en Defines a Circle Collider . + !#zh 用来定义圆形碰撞体 */ + export class Circle { + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Circle radius + !#zh 圆形半径 */ + radius: number; + } + } + + /**************************************************** + * Collider + *****************************************************/ + + export namespace Collider { + /** !#en Defines a Polygon Collider . + !#zh 用来定义多边形碰撞体 */ + export class Polygon { + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Polygon points + !#zh 多边形顶点数组 */ + points: Vec2[]; + } + } + + /**************************************************** + * Camera + *****************************************************/ + + export namespace Camera { + /** !#en Values for Camera.clearFlags, determining what to clear when rendering a Camera. + !#zh 摄像机清除标记位,决定摄像机渲染时会清除哪些状态 */ + export enum ClearFlags { + COLOR = 0, + DEPTH = 0, + STENCIL = 0, + } + } + + /**************************************************** + * Animation + *****************************************************/ + + export namespace Animation { + /** !#en The event type supported by Animation + !#zh Animation 支持的事件类型 */ + export class EventType { + /** !#en Emit when begin playing animation + !#zh 开始播放时触发 */ + static PLAY: string; + /** !#en Emit when stop playing animation + !#zh 停止播放时触发 */ + static STOP: string; + /** !#en Emit when pause animation + !#zh 暂停播放时触发 */ + static PAUSE: string; + /** !#en Emit when resume animation + !#zh 恢复播放时触发 */ + static RESUME: string; + /** !#en If animation repeat count is larger than 1, emit when animation play to the last frame + !#zh 假如动画循环次数大于 1,当动画播放到最后一帧时触发 */ + static LASTFRAME: string; + /** !#en Emit when finish playing animation + !#zh 动画播放完成时触发 */ + static FINISHED: string; + } + } + + /**************************************************** + * Button + *****************************************************/ + + export namespace Button { + /** !#en Enum for transition type. + !#zh 过渡类型 */ + export enum Transition { + NONE = 0, + COLOR = 0, + SPRITE = 0, + SCALE = 0, + } + } + + /**************************************************** + * Component + *****************************************************/ + + export namespace Component { + /** !#en + Component will register a event to target component's handler. + And it will trigger the handler when a certain event occurs. + + !@zh + “EventHandler” 类用来设置场景中的事件回调, + 该类允许用户设置回调目标节点,目标组件名,组件方法名, + 并可通过 emit 方法调用目标函数。 */ + export class EventHandler { + /** !#en the node that contains target callback, such as the node example script belongs to + !#zh 事件响应函数所在节点 ,比如例子中脚本归属的节点本身 */ + target: Node; + /** !#en name of the component(script) that contains target callback, such as the name 'MainMenu' of script in example + !#zh 事件响应函数所在组件名(脚本名), 比如例子中的脚本名 'MainMenu' */ + component: string; + /** !#en Event handler, such as function's name 'onClick' in example + !#zh 响应事件函数名,比如例子中的 'onClick' */ + handler: string; + /** !#en Custom Event Data, such as 'eventType' in example + !#zh 自定义事件数据,比如例子中的 eventType */ + customEventData: string; + /** + + @param events events + @param params params + */ + static emitEvents(events: EventHandler[], ...params: any[]): void; + /** + !#en Emit event with params + !#zh 触发目标组件上的指定 handler 函数,该参数是回调函数的参数值(可不填)。 + @param params params + + @example + ```js + // Call Function + var eventHandler = new cc.Component.EventHandler(); + eventHandler.target = newTarget; + eventHandler.component = "MainMenu"; + eventHandler.handler = "OnClick" + eventHandler.emit(["param1", "param2", ....]); + ``` + */ + emit(params: any[]): void; + } + } + + /**************************************************** + * Label + *****************************************************/ + + export namespace Label { + /** !#en Enum for text alignment. + !#zh 文本横向对齐类型 */ + export enum HorizontalAlign { + LEFT = 0, + CENTER = 0, + RIGHT = 0, + } + } + + /**************************************************** + * Label + *****************************************************/ + + export namespace Label { + /** !#en Enum for vertical text alignment. + !#zh 文本垂直对齐类型 */ + export enum VerticalAlign { + TOP = 0, + CENTER = 0, + BOTTOM = 0, + } + } + + /**************************************************** + * Label + *****************************************************/ + + export namespace Label { + /** !#en Enum for Overflow. + !#zh Overflow 类型 */ + export enum Overflow { + NONE = 0, + CLAMP = 0, + SHRINK = 0, + RESIZE_HEIGHT = 0, + } + } + + /**************************************************** + * Label + *****************************************************/ + + export namespace Label { + /** !#en Enum for font type. + !#zh Type 类型 */ + export enum Type { + TTF = 0, + BMFont = 0, + SystemFont = 0, + } + } + + /**************************************************** + * Label + *****************************************************/ + + export namespace Label { + /** !#en Enum for cache mode. + !#zh CacheMode 类型 */ + export enum CacheMode { + NONE = 0, + BITMAP = 0, + CHAR = 0, + } + } + + /**************************************************** + * Layout + *****************************************************/ + + export namespace Layout { + /** !#en Enum for Layout type + !#zh 布局类型 */ + export enum Type { + NONE = 0, + HORIZONTAL = 0, + VERTICAL = 0, + GRID = 0, + } + } + + /**************************************************** + * Layout + *****************************************************/ + + export namespace Layout { + /** !#en Enum for Layout Resize Mode + !#zh 缩放模式 */ + export enum ResizeMode { + NONE = 0, + CONTAINER = 0, + CHILDREN = 0, + } + } + + /**************************************************** + * Layout + *****************************************************/ + + export namespace Layout { + /** !#en Enum for Grid Layout start axis direction. + The items in grid layout will be arranged in each axis at first.; + !#zh 布局轴向,只用于 GRID 布局。 */ + export enum AxisDirection { + HORIZONTAL = 0, + VERTICAL = 0, + } + } + + /**************************************************** + * Layout + *****************************************************/ + + export namespace Layout { + /** !#en Enum for vertical layout direction. + Used in Grid Layout together with AxisDirection is VERTICAL + !#zh 垂直方向布局方式 */ + export enum VerticalDirection { + BOTTOM_TO_TOP = 0, + TOP_TO_BOTTOM = 0, + } + } + + /**************************************************** + * Layout + *****************************************************/ + + export namespace Layout { + /** !#en Enum for horizontal layout direction. + Used in Grid Layout together with AxisDirection is HORIZONTAL + !#zh 水平方向布局方式 */ + export enum HorizontalDirection { + LEFT_TO_RIGHT = 0, + RIGHT_TO_LEFT = 0, + } + } + + /**************************************************** + * Mask + *****************************************************/ + + export namespace Mask { + /** !#en the type for mask. + !#zh 遮罩组件类型 */ + export enum Type { + RECT = 0, + ELLIPSE = 0, + IMAGE_STENCIL = 0, + } + } + + /**************************************************** + * PageView + *****************************************************/ + + export namespace PageView { + /** !#en The Page View Size Mode + !#zh 页面视图每个页面统一的大小类型 */ + export enum SizeMode { + Unified = 0, + Free = 0, + } + } + + /**************************************************** + * PageView + *****************************************************/ + + export namespace PageView { + /** !#en The Page View Direction + !#zh 页面视图滚动类型 */ + export enum Direction { + Horizontal = 0, + Vertical = 0, + } + } + + /**************************************************** + * PageView + *****************************************************/ + + export namespace PageView { + /** !#en Enum for ScrollView event type. + !#zh 滚动视图事件类型 */ + export enum EventType { + PAGE_TURNING = 0, + } + } + + /**************************************************** + * PageViewIndicator + *****************************************************/ + + export namespace PageViewIndicator { + /** !#en Enum for PageView Indicator direction + !#zh 页面视图指示器的摆放方向 */ + export enum Direction { + HORIZONTAL = 0, + VERTICAL = 0, + } + } + + /**************************************************** + * ProgressBar + *****************************************************/ + + export namespace ProgressBar { + /** !#en Enum for ProgressBar mode + !#zh 进度条模式 */ + export enum Mode { + HORIZONTAL = 0, + VERTICAL = 0, + FILLED = 0, + } + } + + /**************************************************** + * Scrollbar + *****************************************************/ + + export namespace Scrollbar { + /** Enum for Scrollbar direction */ + export enum Direction { + HORIZONTAL = 0, + VERTICAL = 0, + } + } + + /**************************************************** + * ScrollView + *****************************************************/ + + export namespace ScrollView { + /** !#en Enum for ScrollView event type. + !#zh 滚动视图事件类型 */ + export enum EventType { + SCROLL_TO_TOP = 0, + SCROLL_TO_BOTTOM = 0, + SCROLL_TO_LEFT = 0, + SCROLL_TO_RIGHT = 0, + SCROLLING = 0, + BOUNCE_TOP = 0, + BOUNCE_BOTTOM = 0, + BOUNCE_LEFT = 0, + BOUNCE_RIGHT = 0, + SCROLL_ENDED = 0, + TOUCH_UP = 0, + AUTOSCROLL_ENDED_WITH_THRESHOLD = 0, + SCROLL_BEGAN = 0, + } + } + + /**************************************************** + * Slider + *****************************************************/ + + export namespace Slider { + /** !#en The Slider Direction + !#zh 滑动器方向 */ + export enum Direction { + Horizontal = 0, + Vertical = 0, + } + } + + /**************************************************** + * Sprite + *****************************************************/ + + export namespace Sprite { + /** !#en Enum for sprite type. + !#zh Sprite 类型 */ + export enum Type { + SIMPLE = 0, + SLICED = 0, + TILED = 0, + FILLED = 0, + MESH = 0, + } + } + + /**************************************************** + * Sprite + *****************************************************/ + + export namespace Sprite { + /** !#en Enum for fill type. + !#zh 填充类型 */ + export enum FillType { + HORIZONTAL = 0, + VERTICAL = 0, + RADIAL = 0, + } + } + + /**************************************************** + * Sprite + *****************************************************/ + + export namespace Sprite { + /** !#en Sprite Size can track trimmed size, raw size or none. + !#zh 精灵尺寸调整模式 */ + export enum SizeMode { + CUSTOM = 0, + TRIMMED = 0, + RAW = 0, + } + } + + /**************************************************** + * Sprite + *****************************************************/ + + export namespace Sprite { + /** !#en Sprite state can choice the normal or grayscale. + !#zh 精灵颜色通道模式。 */ + export enum State { + NORMAL = 0, + GRAY = 0, + } + } + + /**************************************************** + * Widget + *****************************************************/ + + export namespace Widget { + /** !#en Enum for Widget's alignment mode, indicating when the widget should refresh. + !#zh Widget 的对齐模式,表示 Widget 应该何时刷新。 */ + export enum AlignMode { + ONCE = 0, + ON_WINDOW_RESIZE = 0, + ALWAYS = 0, + } + } + + /**************************************************** + * Event + *****************************************************/ + + export namespace Event { + /** !#en The Custom event + !#zh 自定义事件 */ + export class EventCustom extends Event { + /** + + @param type The name of the event (case-sensitive), e.g. "click", "fire", or "submit" + @param bubbles A boolean indicating whether the event bubbles up through the tree or not + */ + constructor(type: string, bubbles: boolean); + /** !#en A reference to the detailed data of the event + !#zh 事件的详细数据 */ + detail: any; + /** + !#en Sets user data + !#zh 设置用户数据 + @param data data + */ + setUserData(data: any): void; + /** + !#en Gets user data + !#zh 获取用户数据 + */ + getUserData(): any; + /** + !#en Gets event name + !#zh 获取事件名称 + */ + getEventName(): string; + } + } + + /**************************************************** + * SystemEvent + *****************************************************/ + + export namespace SystemEvent { + /** !#en The event type supported by SystemEvent + !#zh SystemEvent 支持的事件类型 */ + export class EventType { + /** !#en The event type for press the key down event, you can use its value directly: 'keydown' + !#zh 当按下按键时触发的事件 */ + static KEY_DOWN: string; + /** !#en The event type for press the key up event, you can use its value directly: 'keyup' + !#zh 当松开按键时触发的事件 */ + static KEY_UP: string; + /** !#en The event type for press the devicemotion event, you can use its value directly: 'devicemotion' + !#zh 重力感应 */ + static DEVICEMOTION: string; + } + } + + /**************************************************** + * Event + *****************************************************/ + + export namespace Event { + /** !#en The mouse event + !#zh 鼠标事件类型 */ + export class EventMouse extends Event { + /** + !#en Sets scroll data. + !#zh 设置鼠标的滚动数据。 + @param scrollX scrollX + @param scrollY scrollY + */ + setScrollData(scrollX: number, scrollY: number): void; + /** + !#en Returns the x axis scroll value. + !#zh 获取鼠标滚动的X轴距离,只有滚动时才有效。 + */ + getScrollX(): number; + /** + !#en Returns the y axis scroll value. + !#zh 获取滚轮滚动的 Y 轴距离,只有滚动时才有效。 + */ + getScrollY(): number; + /** + !#en Sets cursor location. + !#zh 设置当前鼠标位置。 + @param x x + @param y y + */ + setLocation(x: number, y: number): void; + /** + !#en Returns cursor location. + !#zh 获取鼠标位置对象,对象包含 x 和 y 属性。 + */ + getLocation(): Vec2; + /** + !#en Returns the current cursor location in screen coordinates. + !#zh 获取当前事件在游戏窗口内的坐标位置对象,对象包含 x 和 y 属性。 + */ + getLocationInView(): Vec2; + /** + !#en Returns the previous touch location. + !#zh 获取鼠标点击在上一次事件时的位置对象,对象包含 x 和 y 属性。 + */ + getPreviousLocation(): Vec2; + /** + !#en Returns the delta distance from the previous location to current location. + !#zh 获取鼠标距离上一次事件移动的距离对象,对象包含 x 和 y 属性。 + */ + getDelta(): Vec2; + /** + !#en Returns the X axis delta distance from the previous location to current location. + !#zh 获取鼠标距离上一次事件移动的 X 轴距离。 + */ + getDeltaX(): number; + /** + !#en Returns the Y axis delta distance from the previous location to current location. + !#zh 获取鼠标距离上一次事件移动的 Y 轴距离。 + */ + getDeltaY(): number; + /** + !#en Sets mouse button. + !#zh 设置鼠标按键。 + @param button button + */ + setButton(button: number): void; + /** + !#en Returns mouse button. + !#zh 获取鼠标按键。 + */ + getButton(): number; + /** + !#en Returns location X axis data. + !#zh 获取鼠标当前位置 X 轴。 + */ + getLocationX(): number; + /** + !#en Returns location Y axis data. + !#zh 获取鼠标当前位置 Y 轴。 + */ + getLocationY(): number; + /** !#en The none event code of mouse event. + !#zh 无。 */ + static NONE: number; + /** !#en The event type code of mouse down event. + !#zh 鼠标按下事件。 */ + static DOWN: number; + /** !#en The event type code of mouse up event. + !#zh 鼠标按下后释放事件。 */ + static UP: number; + /** !#en The event type code of mouse move event. + !#zh 鼠标移动事件。 */ + static MOVE: number; + /** !#en The event type code of mouse scroll event. + !#zh 鼠标滚轮事件。 */ + static SCROLL: number; + /** !#en The tag of Mouse left button. + !#zh 鼠标左键的标签。 */ + static BUTTON_LEFT: number; + /** !#en The tag of Mouse right button (The right button number is 2 on browser). + !#zh 鼠标右键的标签。 */ + static BUTTON_RIGHT: number; + /** !#en The tag of Mouse middle button (The right button number is 1 on browser). + !#zh 鼠标中键的标签。 */ + static BUTTON_MIDDLE: number; + /** !#en The tag of Mouse button 4. + !#zh 鼠标按键 4 的标签。 */ + static BUTTON_4: number; + /** !#en The tag of Mouse button 5. + !#zh 鼠标按键 5 的标签。 */ + static BUTTON_5: number; + /** !#en The tag of Mouse button 6. + !#zh 鼠标按键 6 的标签。 */ + static BUTTON_6: number; + /** !#en The tag of Mouse button 7. + !#zh 鼠标按键 7 的标签。 */ + static BUTTON_7: number; + /** !#en The tag of Mouse button 8. + !#zh 鼠标按键 8 的标签。 */ + static BUTTON_8: number; + } + } + + /**************************************************** + * Event + *****************************************************/ + + export namespace Event { + /** !#en The touch event + !#zh 触摸事件 */ + export class EventTouch extends Event { + /** + + @param touchArr The array of the touches + @param bubbles A boolean indicating whether the event bubbles up through the tree or not + */ + constructor(touchArr: any[], bubbles: boolean); + /** !#en The current touch object + !#zh 当前触点对象 */ + touch: Touch; + /** + !#en Returns event code. + !#zh 获取事件类型。 + */ + getEventCode(): number; + /** + !#en Returns touches of event. + !#zh 获取触摸点的列表。 + */ + getTouches(): any[]; + /** + !#en Sets touch location. + !#zh 设置当前触点位置 + @param x x + @param y y + */ + setLocation(x: number, y: number): void; + /** + !#en Returns touch location. + !#zh 获取触点位置。 + */ + getLocation(): Vec2; + /** + !#en Returns the current touch location in screen coordinates. + !#zh 获取当前触点在游戏窗口中的位置。 + */ + getLocationInView(): Vec2; + /** + !#en Returns the previous touch location. + !#zh 获取触点在上一次事件时的位置对象,对象包含 x 和 y 属性。 + */ + getPreviousLocation(): Vec2; + /** + !#en Returns the start touch location. + !#zh 获取触点落下时的位置对象,对象包含 x 和 y 属性。 + */ + getStartLocation(): Vec2; + /** + !#en Returns the id of cc.Touch. + !#zh 触点的标识 ID,可以用来在多点触摸中跟踪触点。 + */ + getID(): number; + /** + !#en Returns the delta distance from the previous location to current location. + !#zh 获取触点距离上一次事件移动的距离对象,对象包含 x 和 y 属性。 + */ + getDelta(): Vec2; + /** + !#en Returns the X axis delta distance from the previous location to current location. + !#zh 获取触点距离上一次事件移动的 x 轴距离。 + */ + getDeltaX(): number; + /** + !#en Returns the Y axis delta distance from the previous location to current location. + !#zh 获取触点距离上一次事件移动的 y 轴距离。 + */ + getDeltaY(): number; + /** + !#en Returns location X axis data. + !#zh 获取当前触点 X 轴位置。 + */ + getLocationX(): number; + /** + !#en Returns location Y axis data. + !#zh 获取当前触点 Y 轴位置。 + */ + getLocationY(): number; + } + } + + /**************************************************** + * Event + *****************************************************/ + + export namespace Event { + /** !#en The acceleration event + !#zh 加速度事件 */ + export class EventAcceleration extends Event { + } + } + + /**************************************************** + * Event + *****************************************************/ + + export namespace Event { + /** !#en The keyboard event + !#zh 键盘事件 */ + export class EventKeyboard extends Event { + /** !#en + The keyCode read-only property represents a system and implementation dependent numerical code identifying the unmodified value of the pressed key. + This is usually the decimal ASCII (RFC 20) or Windows 1252 code corresponding to the key. + If the key can't be identified, this value is 0. + + !#zh + keyCode 是只读属性它表示一个系统和依赖于实现的数字代码,可以识别按键的未修改值。 + 这通常是十进制 ASCII (RFC20) 或者 Windows 1252 代码,所对应的密钥。 + 如果无法识别该键,则该值为 0。 */ + keyCode: number; + } + } + + /**************************************************** + * Graphics + *****************************************************/ + + export namespace Graphics { + /** !#en Enum for LineCap. + !#zh 线段末端属性 */ + export enum LineCap { + BUTT = 0, + ROUND = 0, + SQUARE = 0, + } + } + + /**************************************************** + * Graphics + *****************************************************/ + + export namespace Graphics { + /** !#en Enum for LineJoin. + !#zh 线段拐角属性 */ + export enum LineJoin { + BEVEL = 0, + ROUND = 0, + MITER = 0, + } + } + + /**************************************************** + * Pipeline + *****************************************************/ + + export namespace Pipeline { + /** The downloader pipe, it can download several types of files: + 1. Text + 2. Image + 3. Script + 4. Audio + 5. Assets + All unknown type will be downloaded as plain text. + You can pass custom supported types in the constructor. */ + export class Downloader { + /** + Constructor of Downloader, you can pass custom supported types. + @param extMap Custom supported types with corresponded handler + + @example + ```js + var downloader = new Downloader({ + // This will match all url with `.scene` extension or all url with `scene` type + 'scene' : function (url, callback) {} + }); + ``` + */ + constructor(extMap: any); + /** + Add custom supported types handler or modify existing type handler. + @param extMap Custom supported types with corresponded handler + */ + addHandlers(extMap: any): void; + /** + !#en + Load subpackage with name. + !#zh + 通过子包名加载子包代码。 + @param name Subpackage name + @param progressCallback Callback when progress changed + @param completeCallback Callback invoked when subpackage loaded + */ + loadSubpackage(name: string, progressCallback?: Function, completeCallback?: (error: Error) => void): void; + } + } + + /**************************************************** + * Pipeline + *****************************************************/ + + export namespace Pipeline { + /** The loader pipe, it can load several types of files: + 1. Images + 2. JSON + 3. Plist + 4. Audio + 5. Font + 6. Cocos Creator scene + It will not interfere with items of unknown type. + You can pass custom supported types in the constructor. */ + export class Loader { + /** + Constructor of Loader, you can pass custom supported types. + @param extMap Custom supported types with corresponded handler + + @example + ```js + var loader = new Loader({ + // This will match all url with `.scene` extension or all url with `scene` type + 'scene' : function (url, callback) {} + }); + ``` + */ + constructor(extMap: any); + /** + Add custom supported types handler or modify existing type handler. + @param extMap Custom supported types with corresponded handler + */ + addHandlers(extMap: any): void; + } + } + + /**************************************************** + * LoadingItems + *****************************************************/ + + export namespace LoadingItems { + /** !#en The item states of the LoadingItems, its value could be LoadingItems.ItemState.WORKING | LoadingItems.ItemState.COMPLETET | LoadingItems.ItemState.ERROR + !#zh LoadingItems 队列中的加载项状态,状态的值可能是 LoadingItems.ItemState.WORKING | LoadingItems.ItemState.COMPLETET | LoadingItems.ItemState.ERROR */ + export enum ItemState { + WORKING = 0, + COMPLETET = 0, + ERROR = 0, + } + } + + /**************************************************** + * PhysicsManager + *****************************************************/ + + export namespace PhysicsManager { + /** !#en + The draw bits for drawing physics debug information.
+ example:
+ ```js + cc.director.getPhysicsManager().debugDrawFlags = + // cc.PhysicsManager.DrawBits.e_aabbBit | + // cc.PhysicsManager.DrawBits.e_pairBit | + // cc.PhysicsManager.DrawBits.e_centerOfMassBit | + cc.PhysicsManager.DrawBits.e_jointBit | + cc.PhysicsManager.DrawBits.e_shapeBit; + ``` + !#zh + 指定物理系统需要绘制哪些调试信息。
+ example:
+ ```js + cc.director.getPhysicsManager().debugDrawFlags = + // cc.PhysicsManager.DrawBits.e_aabbBit | + // cc.PhysicsManager.DrawBits.e_pairBit | + // cc.PhysicsManager.DrawBits.e_centerOfMassBit | + cc.PhysicsManager.DrawBits.e_jointBit | + cc.PhysicsManager.DrawBits.e_shapeBit; + ``` */ + export enum DrawBits { + e_aabbBit = 0, + e_jointBit = 0, + e_shapeBit = 0, + } + } + + /**************************************************** + * geomUtils + *****************************************************/ + + export namespace geomUtils { + /** Aabb */ + export class Aabb { + /** + create a new aabb + @param px X coordinates for aabb's original point + @param py Y coordinates for aabb's original point + @param pz Z coordinates for aabb's original point + @param w the half of aabb width + @param h the half of aabb height + @param l the half of aabb length + */ + create(px: number, py: number, pz: number, w: number, h: number, l: number): Aabb; + /** + clone a new aabb + @param a the source aabb + */ + clone(a: Aabb): Aabb; + /** + copy the values from one aabb to another + @param out the receiving aabb + @param a the source aabb + */ + copy(out: Aabb, a: Aabb): Aabb; + /** + create a new aabb from two corner points + @param out the receiving aabb + @param minPos lower corner position of the aabb + @param maxPos upper corner position of the aabb + */ + fromPoints(out: Aabb, minPos: Vec3, maxPos: Vec3): Aabb; + /** + Set the components of a aabb to the given values + @param out the receiving aabb + @param px X coordinates for aabb's original point + @param py Y coordinates for aabb's original point + @param pz Z coordinates for aabb's original point + @param w the half of aabb width + @param h the half of aabb height + @param l the half of aabb length + */ + set(out: Aabb, px: number, py: number, pz: number, w: number, h: number, l: number): Aabb; + center: Vec3; + halfExtents: Vec3; + _type: number; + /** + Get the bounding points of this shape + @param minPos minPos + @param maxPos maxPos + */ + getBoundary(minPos: Vec3, maxPos: Vec3): void; + /** + Transform this shape + @param m the transform matrix + @param pos the position part of the transform + @param rot the rotation part of the transform + @param scale the scale part of the transform + @param out the target shape + */ + transform(m: Mat4, pos: Vec3, rot: Quat, scale: Vec3, out?: Aabb): void; + } + } + + /**************************************************** + * geomUtils + *****************************************************/ + + export namespace geomUtils { + /** !#en Shape type. */ + export enum enums { + SHAPE_RAY = 0, + SHAPE_LINE = 0, + SHAPE_SPHERE = 0, + SHAPE_AABB = 0, + SHAPE_OBB = 0, + SHAPE_PLANE = 0, + SHAPE_TRIANGLE = 0, + SHAPE_FRUSTUM = 0, + SHAPE_FRUSTUM_ACCURATE = 0, + } + } + + /**************************************************** + * geomUtils + *****************************************************/ + + export namespace geomUtils { + /** !#en frustum + !#zh 平截头体 */ + export class Frustum { + /** Set whether to use accurate intersection testing function on this frustum */ + accurate: boolean; + /** + create a new frustum + */ + static create(): Frustum; + /** + Clone a frustum + @param f f + */ + static clone(f: Frustum): Frustum; + /** + Copy the values from one frustum to another + @param out out + @param f f + */ + copy(out: Frustum, f: Frustum): Frustum; + planes: geomUtils.Plane[]; + planes: Vec3[]; + /** + !#en Update the frustum information according to the given transform matrix. + Note that the resulting planes are not normalized under normal mode. + @param m the view-projection matrix + @param inv the inverse view-projection matrix + */ + update(m: Mat4, inv: Mat4): void; + /** + !#en transform by matrix + @param mat mat + */ + transform(mat: Mat4): void; + } + } + + /**************************************************** + * geomUtils + *****************************************************/ + + export namespace geomUtils { + /** undefined */ + export class intersect { + /** + !#en + Check whether ray intersect with nodes + !#zh + 检测射线是否与物体有交集 + @param root If root is null, then traversal nodes from scene node + @param worldRay worldRay + @param handler handler + @param filter filter + */ + static ray_cast(root: Node, worldRay: geomUtils.Ray, handler: Function, filter: Function): any[]; + /** + !#en ray-plane intersect
+ !#zh 射线与平面的相交性检测。 + @param ray ray + @param plane plane + */ + static ray_plane(ray: geomUtils.Ray, plane: geomUtils.Plane): number; + /** + !#en line-plane intersect
+ !#zh 线段与平面的相交性检测。 + @param line line + @param plane plane + */ + static line_plane(line: geomUtils.Line, plane: geomUtils.Plane): number; + /** + !#en ray-triangle intersect
+ !#zh 射线与三角形的相交性检测。 + @param ray ray + @param triangle triangle + @param doubleSided doubleSided + */ + static ray_triangle(ray: geomUtils.Ray, triangle: geomUtils.Triangle, doubleSided: boolean): number; + /** + !#en line-triangle intersect
+ !#zh 线段与三角形的相交性检测。 + @param line line + @param triangle triangle + @param outPt optional, The intersection point + */ + static line_triangle(line: geomUtils.Line, triangle: geomUtils.Triangle, outPt: Vec3): number; + /** + !#en line-quad intersect
+ !#zh 线段与四边形的相交性检测。 + @param p A point on a line segment + @param q Another point on the line segment + @param a Quadrilateral point a + @param b Quadrilateral point b + @param c Quadrilateral point c + @param d Quadrilateral point d + @param outPt optional, The intersection point + */ + static line_quad(p: Vec3, q: Vec3, a: Vec3, b: Vec3, c: Vec3, d: Vec3, outPt: Vec3): number; + /** + !#en ray-sphere intersect
+ !#zh 射线和球的相交性检测。 + @param ray ray + @param sphere sphere + */ + static ray_sphere(ray: geomUtils.Ray, sphere: geomUtils.Sphere): number; + /** + !#en ray-aabb intersect
+ !#zh 射线和轴对齐包围盒的相交性检测。 + @param ray ray + @param aabb Align the axis around the box + */ + static ray_aabb(ray: geomUtils.Ray, aabb: Aabb): number; + /** + !#en ray-obb intersect
+ !#zh 射线和方向包围盒的相交性检测。 + @param ray ray + @param obb Direction box + */ + static ray_obb(ray: geomUtils.Ray, obb: geomUtils.Obb): number; + /** + !#en aabb-aabb intersect
+ !#zh 轴对齐包围盒和轴对齐包围盒的相交性检测。 + @param aabb1 Axis alignment surrounds box 1 + @param aabb2 Axis alignment surrounds box 2 + */ + static aabb_aabb(aabb1: Aabb, aabb2: Aabb): number; + /** + !#en aabb-obb intersect
+ !#zh 轴对齐包围盒和方向包围盒的相交性检测。 + @param aabb Align the axis around the box + @param obb Direction box + */ + static aabb_obb(aabb: Aabb, obb: geomUtils.Obb): number; + /** + !#en aabb-plane intersect
+ !#zh 轴对齐包围盒和平面的相交性检测。 + @param aabb Align the axis around the box + @param plane plane + */ + static aabb_plane(aabb: Aabb, plane: geomUtils.Plane): number; + /** + !#en aabb-frustum intersect, faster but has false positive corner cases
+ !#zh 轴对齐包围盒和锥台相交性检测,速度快,但有错误情况。 + @param aabb Align the axis around the box + @param frustum frustum + */ + static aabb_frustum(aabb: Aabb, frustum: Frustum): number; + /** + !#en aabb-frustum intersect, handles most of the false positives correctly
+ !#zh 轴对齐包围盒和锥台相交性检测,正确处理大多数错误情况。 + @param aabb Align the axis around the box + @param frustum frustum + */ + static aabb_frustum_accurate(aabb: Aabb, frustum: Frustum): number; + /** + !#en obb-point intersect
+ !#zh 方向包围盒和点的相交性检测。 + @param obb Direction box + @param point point + */ + static obb_point(obb: geomUtils.Obb, point: geomUtils.Vec3): boolean; + /** + !#en obb-plane intersect
+ !#zh 方向包围盒和平面的相交性检测。 + @param obb Direction box + @param plane plane + */ + static obb_plane(obb: geomUtils.Obb, plane: geomUtils.Plane): number; + /** + !#en obb-frustum intersect, faster but has false positive corner cases
+ !#zh 方向包围盒和锥台相交性检测,速度快,但有错误情况。 + @param obb Direction box + @param frustum frustum + */ + static obb_frustum(obb: geomUtils.Obb, frustum: Frustum): number; + /** + !#en obb-frustum intersect, handles most of the false positives correctly
+ !#zh 方向包围盒和锥台相交性检测,正确处理大多数错误情况。 + @param obb Direction box + @param frustum frustum + */ + static obb_frustum_accurate(obb: geomUtils.Obb, frustum: Frustum): number; + /** + !#en obb-obb intersect
+ !#zh 方向包围盒和方向包围盒的相交性检测。 + @param obb1 Direction box1 + @param obb2 Direction box2 + */ + static obb_obb(obb1: geomUtils.Obb, obb2: geomUtils.Obb): number; + /** + !#en phere-plane intersect, not necessarily faster than obb-plane
+ due to the length calculation of the plane normal to factor out
+ the unnomalized plane distance
+ !#zh 球与平面的相交性检测。 + @param sphere sphere + @param plane plane + */ + static sphere_plane(sphere: geomUtils.Sphere, plane: geomUtils.Plane): number; + /** + !#en sphere-frustum intersect, faster but has false positive corner cases
+ !#zh 球和锥台的相交性检测,速度快,但有错误情况。 + @param sphere sphere + @param frustum frustum + */ + static sphere_frustum(sphere: geomUtils.Sphere, frustum: Frustum): number; + /** + !#en sphere-frustum intersect, handles the false positives correctly
+ !#zh 球和锥台的相交性检测,正确处理大多数错误情况。 + @param sphere sphere + @param frustum frustum + */ + static sphere_frustum_accurate(sphere: geomUtils.Sphere, frustum: Frustum): number; + /** + !#en sphere-sphere intersect
+ !#zh 球和球的相交性检测。 + @param sphere0 sphere0 + @param sphere1 sphere1 + */ + static sphere_sphere(sphere0: geomUtils.Sphere, sphere1: geomUtils.Sphere): boolean; + /** + !#en sphere-aabb intersect
+ !#zh 球和轴对齐包围盒的相交性检测。 + @param sphere sphere + @param aabb aabb + */ + static sphere_aabb(sphere: geomUtils.Sphere, aabb: Aabb): boolean; + /** + !#en sphere-obb intersect
+ !#zh 球和方向包围盒的相交性检测。 + @param sphere sphere + @param obb obb + */ + static sphere_obb(sphere: geomUtils.Sphere, obb: geomUtils.Obb): boolean; + /** + !#en + The intersection detection of g1 and g2 can fill in the shape in the basic geometry. + !#zh + g1 和 g2 的相交性检测,可填入基础几何中的形状。 + @param g1 Geometry 1 + @param g2 Geometry 2 + @param outPt optional, Intersection point. (note: only partial shape detection with this return value) + */ + static resolve(g1: any, g2: any, outPt: any): void; + } + } + + /**************************************************** + * geomUtils + *****************************************************/ + + export namespace geomUtils { + /** !#en + line + !#zh + 直线 */ + export class Line { + /** + !#en + create a new line + !#zh + 创建一个新的 line。 + @param sx The x part of the starting point. + @param sy The y part of the starting point. + @param sz The z part of the starting point. + @param ex The x part of the end point. + @param ey The y part of the end point. + @param ez The z part of the end point. + */ + create(sx: number, sy: number, sz: number, ex: number, ey: number, ez: number): Line; + /** + !#en + Creates a new line initialized with values from an existing line + !#zh + 克隆一个新的 line。 + @param a The source of cloning. + */ + clone(a: Line): Line; + /** + !#en + Copy the values from one line to another + !#zh + 复制一个线的值到另一个。 + @param out The object that accepts the action. + @param a The source of the copy. + */ + copy(out: Line, a: Line): Line; + /** + !#en + create a line from two points + !#zh + 用两个点创建一个线。 + @param out The object that accepts the action. + @param start The starting point. + @param end At the end. + */ + fromPoints(out: Line, start: Vec3, end: Vec3): Line; + /** + !#en + Set the components of a Vec3 to the given values + !#zh + 将给定线的属性设置为给定值。 + @param out The object that accepts the action. + @param sx The x part of the starting point. + @param sy The y part of the starting point. + @param sz The z part of the starting point. + @param ex The x part of the end point. + @param ey The y part of the end point. + @param ez The z part of the end point. + */ + set(out: Line, sx: number, sy: number, sz: number, ex: number, ey: number, ez: number): Line; + /** + !#en + Calculate the length of the line. + !#zh + 计算线的长度。 + @param a The line to calculate. + */ + len(a: Line): number; + /** !#en + Start points. + !#zh + 起点。 */ + s: Vec3; + /** !#en + End points. + !#zh + 终点。 */ + e: Vec3; + /** + !#en + Calculate the length of the line. + !#zh + 计算线的长度。 + */ + length(): number; + } + } + + /**************************************************** + * geomUtils + *****************************************************/ + + export namespace geomUtils { + /** !#en obb + !#zh + 基础几何 方向包围盒。 */ + export class Obb { + /** !#zh + 获取形状的类型。 */ + type: number; + /** + !#en + create a new obb + !#zh + 创建一个新的 obb 实例。 + @param cx X coordinates of the shape relative to the origin. + @param cy Y coordinates of the shape relative to the origin. + @param cz Z coordinates of the shape relative to the origin. + @param hw Obb is half the width. + @param hh Obb is half the height. + @param hl Obb is half the Length. + @param ox_1 Direction matrix parameter. + @param ox_2 Direction matrix parameter. + @param ox_3 Direction matrix parameter. + @param oy_1 Direction matrix parameter. + @param oy_2 Direction matrix parameter. + @param oy_3 Direction matrix parameter. + @param oz_1 Direction matrix parameter. + @param oz_2 Direction matrix parameter. + @param oz_3 Direction matrix parameter. + */ + create(cx: number, cy: number, cz: number, hw: number, hh: number, hl: number, ox_1: number, ox_2: number, ox_3: number, oy_1: number, oy_2: number, oy_3: number, oz_1: number, oz_2: number, oz_3: number): Obb; + /** + !#en + clone a new obb + !#zh + 克隆一个 obb。 + @param a The target of cloning. + */ + clone(a: Obb): Obb; + /** + !#en + copy the values from one obb to another + !#zh + 将从一个 obb 的值复制到另一个 obb。 + @param out Obb that accepts the operation. + @param a Obb being copied. + */ + copy(out: Obb, a: Obb): Obb; + /** + !#en + create a new obb from two corner points + !#zh + 用两个点创建一个新的 obb。 + @param out Obb that accepts the operation. + @param minPos The smallest point of obb. + @param maxPos Obb's maximum point. + */ + fromPoints(out: Obb, minPos: Vec3, maxPos: Vec3): Obb; + /** + !#en + Set the components of a obb to the given values + !#zh + 将给定 obb 的属性设置为给定的值。 + @param cx X coordinates of the shape relative to the origin. + @param cy Y coordinates of the shape relative to the origin. + @param cz Z coordinates of the shape relative to the origin. + @param hw Obb is half the width. + @param hh Obb is half the height. + @param hl Obb is half the Length. + @param ox_1 Direction matrix parameter. + @param ox_2 Direction matrix parameter. + @param ox_3 Direction matrix parameter. + @param oy_1 Direction matrix parameter. + @param oy_2 Direction matrix parameter. + @param oy_3 Direction matrix parameter. + @param oz_1 Direction matrix parameter. + @param oz_2 Direction matrix parameter. + @param oz_3 Direction matrix parameter. + */ + set(cx: number, cy: number, cz: number, hw: number, hh: number, hl: number, ox_1: number, ox_2: number, ox_3: number, oy_1: number, oy_2: number, oy_3: number, oz_1: number, oz_2: number, oz_3: number): Obb; + /** !#en + The center of the local coordinate. + !#zh + 本地坐标的中心点。 */ + center: Vec3; + /** !#en + Half the length, width, and height. + !#zh + 长宽高的一半。 */ + halfExtents: Vec3; + /** !#en + Direction matrix. + !#zh + 方向矩阵。 */ + orientation: Mat3; + /** + !#en + Get the bounding points of this shape + !#zh + 获取 obb 的最小点和最大点。 + @param minPos minPos + @param maxPos maxPos + */ + getBoundary(minPos: Vec3, maxPos: Vec3): void; + /** + !#en Transform this shape + !#zh + 将 out 根据这个 obb 的数据进行变换。 + @param m The transformation matrix. + @param pos The position part of the transformation. + @param rot The rotating part of the transformation. + @param scale The scaling part of the transformation. + @param out Target of transformation. + */ + transform(m: Mat4, pos: Vec3, rot: Quat, scale: Vec3, out: Obb): void; + /** + !#en + Transform out based on this obb data. + !#zh + 将 out 根据这个 obb 的数据进行变换。 + @param m The transformation matrix. + @param rot The rotating part of the transformation. + @param out Target of transformation. + */ + translateAndRotate(m: Mat4, rot: Quat, out: Obb): void; + /** + !#en + Scale out based on this obb data. + !#zh + 将 out 根据这个 obb 的数据进行缩放。 + @param scale Scale value. + @param out Scaled target. + */ + setScale(scale: Vec3, out: Obb): void; + } + } + + /**************************************************** + * geomUtils + *****************************************************/ + + export namespace geomUtils { + /** !#en + plane。 + !#zh + 平面。 */ + export class Plane { + /** + !#en + create a new plane + !#zh + 创建一个新的 plane。 + @param nx The x part of the normal component. + @param ny The y part of the normal component. + @param nz The z part of the normal component. + @param d Distance from the origin. + */ + create(nx: number, ny: number, nz: number, d: number): Plane; + /** + !#en + clone a new plane + !#zh + 克隆一个新的 plane。 + @param p The source of cloning. + */ + clone(p: Plane): Plane; + /** + !#en + copy the values from one plane to another + !#zh + 复制一个平面的值到另一个。 + @param out The object that accepts the action. + @param p The source of the copy. + */ + copy(out: Plane, p: Plane): Plane; + /** + !#en + create a plane from three points + !#zh + 用三个点创建一个平面。 + @param out The object that accepts the action. + @param a Point a。 + @param b Point b。 + @param c Point c。 + */ + fromPoints(out: Plane, a: Vec3, b: Vec3, c: Vec3): Plane; + /** + !#en + Set the components of a plane to the given values + !#zh + 将给定平面的属性设置为给定值。 + @param out The object that accepts the action. + @param nx The x part of the normal component. + @param ny The y part of the normal component. + @param nz The z part of the normal component. + @param d Distance from the origin. + */ + set(out: Plane, nx: number, ny: number, nz: number, d: number): Plane; + /** + !#en + create plane from normal and point + !#zh + 用一条法线和一个点创建平面。 + @param out The object that accepts the action. + @param normal The normal of a plane. + @param point A point on the plane. + */ + fromNormalAndPoint(out: Plane, normal: Vec3, point: Vec3): Plane; + /** + !#en + normalize a plane + !#zh + 归一化一个平面。 + @param out The object that accepts the action. + @param a Source data for operations. + */ + normalize(out: Plane, a: Plane): Plane; + /** !#en + A normal vector. + !#zh + 法线向量。 */ + n: Vec3; + /** !#en + The distance from the origin to the plane. + !#zh + 原点到平面的距离。 */ + d: number; + /** + !#en + Transform a plane. + !#zh + 变换一个平面。 + @param mat mat + */ + transform(mat: Mat4): void; + } + } + + /**************************************************** + * geomUtils + *****************************************************/ + + export namespace geomUtils { + /** !#en + ray + !#zh + 射线。 */ + export class Ray { + /** + !#en + create a new ray + !#zh + 创建一条射线。 + @param ox The x part of the starting point. + @param oy The y part of the starting point. + @param oz The z part of the starting point. + @param dx X in the direction. + @param dy Y in the direction. + @param dz Z in the direction. + */ + create(ox: number, oy: number, oz: number, dx: number, dy: number, dz: number): Ray; + /** + !#en + Creates a new ray initialized with values from an existing ray + !#zh + 从一条射线克隆出一条新的射线。 + @param a Clone target + */ + clone(a: Ray): Ray; + /** + !#en + Copy the values from one ray to another + !#zh + 将从一个 ray 的值复制到另一个 ray。 + @param out Accept the ray of the operation. + @param a Copied ray. + */ + copy(out: Ray, a: Ray): Ray; + /** + !#en + create a ray from two points + !#zh + 用两个点创建一条射线。 + @param out Receive the operating ray. + @param origin Origin of ray + @param target A point on a ray. + */ + fromPoints(out: Ray, origin: Vec3, target: Vec3): Ray; + /** + !#en + Set the components of a ray to the given values + !#zh + 将给定射线的属性设置为给定的值。 + @param out Receive the operating ray. + @param ox The x part of the starting point. + @param oy The y part of the starting point. + @param oz The z part of the starting point. + @param dx X in the direction. + @param dy Y in the direction. + @param dz Z in the direction. + */ + set(out: Ray, ox: number, oy: number, oz: number, dx: number, dy: number, dz: number): Ray; + /** !#en + Start point. + !#zh + 起点。 */ + o: Vec3; + /** !#e + Direction + !#zh + 方向。 */ + d: Vec3; + /** + !#en Compute hit. + @param out out + @param distance distance + */ + computeHit(out: IVec3Like, distance: number): void; + } + } + + /**************************************************** + * geomUtils + *****************************************************/ + + export namespace geomUtils { + /** !#en + Sphere. + !#zh + 轴对齐球。 */ + export class Sphere { + /** + !#en + create a new sphere + !#zh + 创建一个新的 sphere 实例。 + @param cx X coordinates of the shape relative to the origin. + @param cy Y coordinates of the shape relative to the origin. + @param cz Z coordinates of the shape relative to the origin. + @param r Radius of sphere + */ + create(cx: any, cy: any, cz: any, r: any): Sphere; + /** + !#en + clone a new sphere + !#zh + 克隆一个新的 sphere 实例。 + @param p The target of cloning. + */ + clone(p: Sphere): Sphere; + /** + !#en + copy the values from one sphere to another + !#zh + 将从一个 sphere 的值复制到另一个 sphere。 + @param out Accept the sphere of operations. + @param a Sphere being copied. + */ + copy(out: Sphere, a: Sphere): Sphere; + /** + !#en + create a new bounding sphere from two corner points + !#zh + 从两个点创建一个新的 sphere。 + @param out Accept the sphere of operations. + @param minPos The smallest point of sphere. + @param maxPos The maximum point of sphere. + */ + fromPoints(out: any, minPos: any, maxPos: any): Sphere; + /** + !#en Set the components of a sphere to the given values + !#zh 将球体的属性设置为给定的值。 + @param out Accept the sphere of operations. + @param cx X coordinates of the shape relative to the origin. + @param cy Y coordinates of the shape relative to the origin. + @param cz Z coordinates of the shape relative to the origin. + @param r Radius. + */ + set(out: Sphere, cx: any, cy: any, cz: any, r: number): Sphere; + /** !#en + The center of the local coordinate. + !#zh + 本地坐标的中心点。 */ + center: Vec3; + /** !#zh + 半径。 */ + radius: number; + /** + !#en + Clone. + !#zh + 获得克隆。 + */ + clone(): void; + /** + !#en + Copy sphere + !#zh + 拷贝对象。 + @param a Copy target. + */ + copy(a: any): void; + /** + !#en + Get the bounding points of this shape + !#zh + 获取此形状的边界点。 + @param minPos minPos + @param maxPos maxPos + */ + getBoundary(minPos: Vec3, maxPos: Vec3): void; + /** + !#en + Transform this shape + !#zh + 将 out 根据这个 sphere 的数据进行变换。 + @param m The transformation matrix. + @param pos The position part of the transformation. + @param rot The rotating part of the transformation. + @param scale The scaling part of the transformation. + @param out The target of the transformation. + */ + transform(m: any, pos: any, rot: any, scale: any, out: any): void; + /** + !#en + Scale out based on the sphere data. + !#zh + 将 out 根据这个 sphere 的数据进行缩放。 + @param scale Scale value + @param out Scale target + */ + setScale(scale: any, out: any): void; + } + } + + /**************************************************** + * geomUtils + *****************************************************/ + + export namespace geomUtils { + /** Triangle */ + export class Triangle { + /** + create a new triangle + @param ax ax + @param ay ay + @param az az + @param bx bx + @param by by + @param bz bz + @param cx cx + @param cy cy + @param cz cz + */ + create(ax: number, ay: number, az: number, bx: number, by: number, bz: number, cx: number, cy: number, cz: number): Triangle; + /** + clone a new triangle + @param t the source plane + */ + clone(t: Triangle): Triangle; + /** + copy the values from one triangle to another + @param out the receiving triangle + @param t the source triangle + */ + copy(out: Triangle, t: Triangle): Triangle; + /** + Create a triangle from three points + @param out the receiving triangle + @param a a + @param b b + @param c c + */ + fromPoints(out: Triangle, a: Vec3, b: Vec3, c: Vec3): Triangle; + /** + Set the components of a triangle to the given values + @param out the receiving plane + @param ax X component of a + @param ay Y component of a + @param az Z component of a + @param bx X component of b + @param by Y component of b + @param bz Z component of b + @param cx X component of c + @param cy Y component of c + @param cz Z component of c + */ + set(out: Triangle, ax: number, ay: number, az: number, bx: number, by: number, bz: number, cx: number, cy: number, cz: number): Plane; + a: Vec3; + b: Vec3; + c: Vec3; + } + } + + /**************************************************** + * MeshRenderer + *****************************************************/ + + export namespace MeshRenderer { + /** !#en Shadow projection mode + + !#ch 阴影投射方式 */ + export enum ShadowCastingMode { + OFF = 0, + ON = 0, + } + } + + /**************************************************** + * macro + *****************************************************/ + + export namespace macro { + /** !#en Key map for keyboard event + !#zh 键盘事件的按键值 */ + export enum KEY { + none = 0, + back = 0, + menu = 0, + backspace = 0, + tab = 0, + enter = 0, + shift = 0, + ctrl = 0, + alt = 0, + pause = 0, + capslock = 0, + escape = 0, + space = 0, + pageup = 0, + pagedown = 0, + end = 0, + home = 0, + left = 0, + up = 0, + right = 0, + down = 0, + select = 0, + insert = 0, + Delete = 0, + a = 0, + b = 0, + c = 0, + d = 0, + e = 0, + f = 0, + g = 0, + h = 0, + i = 0, + j = 0, + k = 0, + l = 0, + m = 0, + n = 0, + o = 0, + p = 0, + q = 0, + r = 0, + s = 0, + t = 0, + u = 0, + v = 0, + w = 0, + x = 0, + y = 0, + z = 0, + num0 = 0, + num1 = 0, + num2 = 0, + num3 = 0, + num4 = 0, + num5 = 0, + num6 = 0, + num7 = 0, + num8 = 0, + num9 = 0, + '*' = 0, + '+' = 0, + '-' = 0, + numdel = 0, + '/' = 0, + f1 = 0, + f2 = 0, + f3 = 0, + f4 = 0, + f5 = 0, + f6 = 0, + f7 = 0, + f8 = 0, + f9 = 0, + f10 = 0, + f11 = 0, + f12 = 0, + numlock = 0, + scrolllock = 0, + ';' = 0, + semicolon = 0, + equal = 0, + '=' = 0, + ',' = 0, + comma = 0, + dash = 0, + '.' = 0, + period = 0, + forwardslash = 0, + grave = 0, + '[' = 0, + openbracket = 0, + backslash = 0, + ']' = 0, + closebracket = 0, + quote = 0, + dpadLeft = 0, + dpadRight = 0, + dpadUp = 0, + dpadDown = 0, + dpadCenter = 0, + } + } + + /**************************************************** + * macro + *****************************************************/ + + export namespace macro { + /** Image formats */ + export enum ImageFormat { + JPG = 0, + PNG = 0, + TIFF = 0, + WEBP = 0, + PVR = 0, + ETC = 0, + S3TC = 0, + ATITC = 0, + TGA = 0, + RAWDATA = 0, + UNKNOWN = 0, + } + } + + /**************************************************** + * macro + *****************************************************/ + + export namespace macro { + /** !#en + Enum for blend factor + Refer to: http://www.andersriggelsen.dk/glblendfunc.php + !#zh + 混合因子 + 可参考: http://www.andersriggelsen.dk/glblendfunc.php */ + export enum BlendFactor { + ONE = 0, + ZERO = 0, + SRC_ALPHA = 0, + SRC_COLOR = 0, + DST_ALPHA = 0, + DST_COLOR = 0, + ONE_MINUS_SRC_ALPHA = 0, + ONE_MINUS_SRC_COLOR = 0, + ONE_MINUS_DST_ALPHA = 0, + ONE_MINUS_DST_COLOR = 0, + } + } + + /**************************************************** + * macro + *****************************************************/ + + export namespace macro { + /** undefined */ + export enum TextAlignment { + LEFT = 0, + CENTER = 0, + RIGHT = 0, + } + } + + /**************************************************** + * sys + *****************************************************/ + + export namespace sys { + /** !#en + Network type enumeration + !#zh + 网络类型枚举 */ + export enum NetworkType { + NONE = 0, + LAN = 0, + WWAN = 0, + } + } + + /**************************************************** + * primitive + *****************************************************/ + + export namespace primitive { + /** undefined */ + export enum PolyhedronType { + Tetrahedron = 0, + Octahedron = 0, + Dodecahedron = 0, + Icosahedron = 0, + Rhombicuboctahedron = 0, + TriangularPrism = 0, + PentagonalPrism = 0, + HexagonalPrism = 0, + SquarePyramid = 0, + PentagonalPyramid = 0, + TriangularDipyramid = 0, + PentagonalDipyramid = 0, + ElongatedSquareDipyramid = 0, + ElongatedPentagonalDipyramid = 0, + ElongatedPentagonalCupola = 0, + } + } + + /**************************************************** + * primitive + *****************************************************/ + + export namespace primitive { + /** undefined */ + export class VertexData { + positions: number[]; + normals: number[]; + uvs: number[]; + indices: number[]; + minPos: Vec3; + maxPos: Vec3; + boundingRadius: number; + } + } + + /**************************************************** + * ParticleSystem3DAssembler + *****************************************************/ + + export namespace ParticleSystem3DAssembler { + /** 粒子的生成模式 */ + export enum RenderMode { + } + } + + /**************************************************** + * shapeModule + *****************************************************/ + + export namespace shapeModule { + /** 粒子发射器类型 */ + export enum ShapeType { + Box = 0, + Circle = 0, + Cone = 0, + Sphere = 0, + Hemisphere = 0, + } + } + + /**************************************************** + * shapeModule + *****************************************************/ + + export namespace shapeModule { + /** 粒子从发射器的哪个部位发射 */ + export enum EmitLocation { + Base = 0, + Edge = 0, + Shell = 0, + Volume = 0, + } + } + + /**************************************************** + * shapeModule + *****************************************************/ + + export namespace shapeModule { + /** 粒子在扇形区域的发射方式 */ + export enum ArcMode { + Random = 0, + Loop = 0, + PingPong = 0, + } + } + + /**************************************************** + * trailModule + *****************************************************/ + + export namespace trailModule { + /** 选择如何为粒子系统生成轨迹 */ + export enum TrailMode { + } + } + + /**************************************************** + * trailModule + *****************************************************/ + + export namespace trailModule { + /** 纹理填充模式 */ + export enum TextureMode { + } + } + + /**************************************************** + * Material + *****************************************************/ + + export namespace Material { + /** !#en Material builtin name + !#zh 内置材质名字 */ + export enum BUILTIN_NAME { + SPRITE = 0, + GRAY_SPRITE = 0, + UNLIT = 0, + } + } + + /**************************************************** + * EditBox + *****************************************************/ + + export namespace EditBox { + /** !#en Enum for keyboard return types + !#zh 键盘的返回键类型 */ + export enum KeyboardReturnType { + DEFAULT = 0, + DONE = 0, + SEND = 0, + SEARCH = 0, + GO = 0, + NEXT = 0, + } + } + + /**************************************************** + * EditBox + *****************************************************/ + + export namespace EditBox { + /** !#en The EditBox's InputMode defines the type of text that the user is allowed to enter. + !#zh 输入模式 */ + export enum InputMode { + ANY = 0, + EMAIL_ADDR = 0, + NUMERIC = 0, + PHONE_NUMBER = 0, + URL = 0, + DECIMAL = 0, + SINGLE_LINE = 0, + } + } + + /**************************************************** + * EditBox + *****************************************************/ + + export namespace EditBox { + /** !#en Enum for the EditBox's input flags + !#zh 定义了一些用于设置文本显示和文本格式化的标志位。 */ + export enum InputFlag { + PASSWORD = 0, + SENSITIVE = 0, + INITIAL_CAPS_WORD = 0, + INITIAL_CAPS_SENTENCE = 0, + INITIAL_CAPS_ALL_CHARACTERS = 0, + DEFAULT = 0, + } + } + + /**************************************************** + * textureAnimationModule + *****************************************************/ + + export namespace textureAnimationModule { + /** 粒子贴图动画类型 */ + export enum Mode { + } + } + + /**************************************************** + * textureAnimationModule + *****************************************************/ + + export namespace textureAnimationModule { + /** 贴图动画的播放方式 */ + export enum Animation { + } + } + +} + +/** !#en +The global main namespace of Spine, all classes, functions, +properties and constants of Spine are defined in this namespace +!#zh +Spine 的全局的命名空间, +与 Spine 相关的所有的类,函数,属性,常量都在这个命名空间中定义。 */ +declare namespace sp { + /** !#en + The skeleton of Spine
+
+ (Skeleton has a reference to a SkeletonData and stores the state for skeleton instance, + which consists of the current pose's bone SRT, slot colors, and which slot attachments are visible.
+ Multiple skeletons can use the same SkeletonData which includes all animations, skins, and attachments.)
+ !#zh + Spine 骨骼动画
+
+ (Skeleton 具有对骨骼数据的引用并且存储了骨骼实例的状态, + 它由当前的骨骼动作,slot 颜色,和可见的 slot attachments 组成。
+ 多个 Skeleton 可以使用相同的骨骼数据,其中包括所有的动画,皮肤和 attachments。 */ + export class Skeleton extends cc.RenderComponent { + /** !#en The skeletal animation is paused? + !#zh 该骨骼动画是否暂停。 */ + paused: boolean; + /** !#en + The skeleton data contains the skeleton information (bind pose bones, slots, draw order, + attachments, skins, etc) and animations but does not hold any state.
+ Multiple skeletons can share the same skeleton data. + !#zh + 骨骼数据包含了骨骼信息(绑定骨骼动作,slots,渲染顺序, + attachments,皮肤等等)和动画但不持有任何状态。
+ 多个 Skeleton 可以共用相同的骨骼数据。 */ + skeletonData: SkeletonData; + /** !#en The name of default skin. + !#zh 默认的皮肤名称。 */ + defaultSkin: string; + /** !#en The name of default animation. + !#zh 默认的动画名称。 */ + defaultAnimation: string; + /** !#en The name of current playing animation. + !#zh 当前播放的动画名称。 */ + animation: string; + _defaultSkinIndex: number; + /** !#en TODO + !#zh 是否循环播放当前骨骼动画。 */ + loop: boolean; + /** !#en Indicates whether to enable premultiplied alpha. + You should disable this option when image's transparent area appears to have opaque pixels, + or enable this option when image's half transparent area appears to be darken. + !#zh 是否启用贴图预乘。 + 当图片的透明区域出现色块时需要关闭该选项,当图片的半透明区域颜色变黑时需要启用该选项。 */ + premultipliedAlpha: boolean; + /** !#en The time scale of this skeleton. + !#zh 当前骨骼中所有动画的时间缩放率。 */ + timeScale: number; + /** !#en Indicates whether open debug slots. + !#zh 是否显示 slot 的 debug 信息。 */ + debugSlots: boolean; + /** !#en Indicates whether open debug bones. + !#zh 是否显示 bone 的 debug 信息。 */ + debugBones: boolean; + /** !#en Indicates whether open debug mesh. + !#zh 是否显示 mesh 的 debug 信息。 */ + debugMesh: boolean; + /** !#en Enabled two color tint. + !#zh 是否启用染色效果。 */ + useTint: boolean; + /** !#en Enabled batch model, if skeleton is complex, do not enable batch, or will lower performance. + !#zh 开启合批,如果渲染大量相同纹理,且结构简单的骨骼动画,开启合批可以降低drawcall,否则请不要开启,cpu消耗会上升。 */ + enableBatch: boolean; + /** + !#en + Sets runtime skeleton data to sp.Skeleton.
+ This method is different from the `skeletonData` property. This method is passed in the raw data provided by the Spine runtime, and the skeletonData type is the asset type provided by Creator. + !#zh + 设置底层运行时用到的 SkeletonData。
+ 这个接口有别于 `skeletonData` 属性,这个接口传入的是 Spine runtime 提供的原始数据,而 skeletonData 的类型是 Creator 提供的资源类型。 + @param skeletonData skeletonData + */ + setSkeletonData(skeletonData: sp.spine.SkeletonData): void; + /** + !#en Sets slots visible range. + !#zh 设置骨骼插槽可视范围。 + @param startSlotIndex startSlotIndex + @param endSlotIndex endSlotIndex + */ + setSlotsRange(startSlotIndex: number, endSlotIndex: number): void; + /** + !#en Sets animation state data.
+ The parameter type is {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.AnimationStateData. + !#zh 设置动画状态数据。
+ 参数是 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.AnimationStateData。 + @param stateData stateData + */ + setAnimationStateData(stateData: sp.spine.AnimationStateData): void; + /** + !#en + It's best to set cache mode before set property 'dragonAsset', or will waste some cpu time. + If set the mode in editor, then no need to worry about order problem. + !#zh + 若想切换渲染模式,最好在设置'dragonAsset'之前,先设置好渲染模式,否则有运行时开销。 + 若在编辑中设置渲染模式,则无需担心设置次序的问题。 + @param cacheMode cacheMode + + @example + ```js + skeleton.setAnimationCacheMode(sp.Skeleton.AnimationCacheMode.SHARED_CACHE); + ``` + */ + setAnimationCacheMode(cacheMode: Skeleton.AnimationCacheMode): void; + /** + !#en Whether in cached mode. + !#zh 当前是否处于缓存模式。 + */ + isAnimationCached(): boolean; + /** + !#en Sets vertex effect delegate. + !#zh 设置顶点动画代理 + @param effectDelegate effectDelegate + */ + setVertexEffectDelegate(effectDelegate: VertexEffectDelegate): void; + /** + !#en Computes the world SRT from the local SRT for each bone. + !#zh 重新更新所有骨骼的世界 Transform, + 当获取 bone 的数值未更新时,即可使用该函数进行更新数值。 + + @example + ```js + var bone = spine.findBone('head'); + cc.log(bone.worldX); // return 0; + spine.updateWorldTransform(); + bone = spine.findBone('head'); + cc.log(bone.worldX); // return -23.12; + ``` + */ + updateWorldTransform(): void; + /** + !#en Sets the bones and slots to the setup pose. + !#zh 还原到起始动作 + */ + setToSetupPose(): void; + /** + !#en + Sets the bones to the setup pose, + using the values from the `BoneData` list in the `SkeletonData`. + !#zh + 设置 bone 到起始动作 + 使用 SkeletonData 中的 BoneData 列表中的值。 + */ + setBonesToSetupPose(): void; + /** + !#en + Sets the slots to the setup pose, + using the values from the `SlotData` list in the `SkeletonData`. + !#zh + 设置 slot 到起始动作。 + 使用 SkeletonData 中的 SlotData 列表中的值。 + */ + setSlotsToSetupPose(): void; + /** + !#en + Updating an animation cache to calculate all frame data in the animation is a cost in + performance due to calculating all data in a single frame. + To update the cache, use the invalidAnimationCache method with high performance. + !#zh + 更新某个动画缓存, 预计算动画中所有帧数据,由于在单帧计算所有数据,所以较消耗性能。 + 若想更新缓存,可使用 invalidAnimationCache 方法,具有较高性能。 + @param animName animName + */ + updateAnimationCache(animName: string): void; + /** + !#en + Invalidates the animation cache, which is then recomputed on each frame.. + !#zh + 使动画缓存失效,之后会在每帧重新计算。 + */ + invalidAnimationCache(): void; + /** + !#en + Finds a bone by name. + This does a string comparison for every bone.
+ Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Bone object. + !#zh + 通过名称查找 bone。 + 这里对每个 bone 的名称进行了对比。
+ 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Bone 对象。 + @param boneName boneName + */ + findBone(boneName: string): sp.spine.Bone; + /** + !#en + Finds a slot by name. This does a string comparison for every slot.
+ Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Slot object. + !#zh + 通过名称查找 slot。这里对每个 slot 的名称进行了比较。
+ 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Slot 对象。 + @param slotName slotName + */ + findSlot(slotName: string): sp.spine.Slot; + /** + !#en + Finds a skin by name and makes it the active skin. + This does a string comparison for every skin.
+ Note that setting the skin does not change which attachments are visible.
+ Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Skin object. + !#zh + 按名称查找皮肤,激活该皮肤。这里对每个皮肤的名称进行了比较。
+ 注意:设置皮肤不会改变 attachment 的可见性。
+ 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Skin 对象。 + @param skinName skinName + */ + setSkin(skinName: string): void; + /** + !#en + Returns the attachment for the slot and attachment name. + The skeleton looks first in its skin, then in the skeleton data’s default skin.
+ Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Attachment object. + !#zh + 通过 slot 和 attachment 的名称获取 attachment。Skeleton 优先查找它的皮肤,然后才是 Skeleton Data 中默认的皮肤。
+ 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Attachment 对象。 + @param slotName slotName + @param attachmentName attachmentName + */ + getAttachment(slotName: string, attachmentName: string): sp.spine.Attachment; + /** + !#en + Sets the attachment for the slot and attachment name. + The skeleton looks first in its skin, then in the skeleton data’s default skin. + !#zh + 通过 slot 和 attachment 的名字来设置 attachment。 + Skeleton 优先查找它的皮肤,然后才是 Skeleton Data 中默认的皮肤。 + @param slotName slotName + @param attachmentName attachmentName + */ + setAttachment(slotName: string, attachmentName: string): void; + /** + Return the renderer of attachment. + @param regionAttachment regionAttachment + */ + getTextureAtlas(regionAttachment: sp.spine.RegionAttachment|spine.BoundingBoxAttachment): sp.spine.TextureAtlasRegion; + /** + !#en + Mix applies all keyframe values, + interpolated for the specified time and mixed with the current values. + !#zh 为所有关键帧设定混合及混合时间(从当前值开始差值)。 + @param fromAnimation fromAnimation + @param toAnimation toAnimation + @param duration duration + */ + setMix(fromAnimation: string, toAnimation: string, duration: number): void; + /** + !#en Set the current animation. Any queued animations are cleared.
+ Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry object. + !#zh 设置当前动画。队列中的任何的动画将被清除。
+ 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry 对象。 + @param trackIndex trackIndex + @param name name + @param loop loop + */ + setAnimation(trackIndex: number, name: string, loop: boolean): sp.spine.TrackEntry; + /** + !#en Adds an animation to be played delay seconds after the current or last queued animation.
+ Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry object. + !#zh 添加一个动画到动画队列尾部,还可以延迟指定的秒数。
+ 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry 对象。 + @param trackIndex trackIndex + @param name name + @param loop loop + @param delay delay + */ + addAnimation(trackIndex: number, name: string, loop: boolean, delay?: number): sp.spine.TrackEntry; + /** + !#en Find animation with specified name. + !#zh 查找指定名称的动画 + @param name name + */ + findAnimation(name: string): sp.spine.Animation; + /** + !#en Returns track entry by trackIndex.
+ Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry object. + !#zh 通过 track 索引获取 TrackEntry。
+ 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry 对象。 + @param trackIndex trackIndex + */ + getCurrent(trackIndex: any): sp.spine.TrackEntry; + /** + !#en Clears all tracks of animation state. + !#zh 清除所有 track 的动画状态。 + */ + clearTracks(): void; + /** + !#en Clears track of animation state by trackIndex. + !#zh 清除出指定 track 的动画状态。 + @param trackIndex trackIndex + */ + clearTrack(trackIndex: number): void; + /** + !#en Set the start event listener. + !#zh 用来设置开始播放动画的事件监听。 + @param listener listener + */ + setStartListener(listener: Function): void; + /** + !#en Set the interrupt event listener. + !#zh 用来设置动画被打断的事件监听。 + @param listener listener + */ + setInterruptListener(listener: Function): void; + /** + !#en Set the end event listener. + !#zh 用来设置动画播放完后的事件监听。 + @param listener listener + */ + setEndListener(listener: Function): void; + /** + !#en Set the dispose event listener. + !#zh 用来设置动画将被销毁的事件监听。 + @param listener listener + */ + setDisposeListener(listener: Function): void; + /** + !#en Set the complete event listener. + !#zh 用来设置动画播放一次循环结束后的事件监听。 + @param listener listener + */ + setCompleteListener(listener: Function): void; + /** + !#en Set the animation event listener. + !#zh 用来设置动画播放过程中帧事件的监听。 + @param listener listener + */ + setEventListener(listener: Function): void; + /** + !#en Set the start event listener for specified TrackEntry. + !#zh 用来为指定的 TrackEntry 设置动画开始播放的事件监听。 + @param entry entry + @param listener listener + */ + setTrackStartListener(entry: sp.spine.TrackEntry, listener: Function): void; + /** + !#en Set the interrupt event listener for specified TrackEntry. + !#zh 用来为指定的 TrackEntry 设置动画被打断的事件监听。 + @param entry entry + @param listener listener + */ + setTrackInterruptListener(entry: sp.spine.TrackEntry, listener: Function): void; + /** + !#en Set the end event listener for specified TrackEntry. + !#zh 用来为指定的 TrackEntry 设置动画播放结束的事件监听。 + @param entry entry + @param listener listener + */ + setTrackEndListener(entry: sp.spine.TrackEntry, listener: Function): void; + /** + !#en Set the dispose event listener for specified TrackEntry. + !#zh 用来为指定的 TrackEntry 设置动画即将被销毁的事件监听。 + @param entry entry + @param listener listener + */ + setTrackDisposeListener(entry: sp.spine.TrackEntry, listener: Function): void; + /** + !#en Set the complete event listener for specified TrackEntry. + !#zh 用来为指定的 TrackEntry 设置动画一次循环播放结束的事件监听。 + @param entry entry + @param listener listener + */ + setTrackCompleteListener(entry: sp.spine.TrackEntry, listener: (entry: sp.spine.TrackEntry, loopCount: number) => void): void; + /** + !#en Set the event listener for specified TrackEntry. + !#zh 用来为指定的 TrackEntry 设置动画帧事件的监听。 + @param entry entry + @param listener listener + */ + setTrackEventListener(entry: sp.spine.TrackEntry, listener: Function): void; + /** + !#en Get the animation state object + !#zh 获取动画状态 + */ + getState(): sp.spine.AnimationState; + } + /** !#en The event type of spine skeleton animation. + !#zh 骨骼动画事件类型。 */ + export enum AnimationEventType { + START = 0, + END = 0, + COMPLETE = 0, + EVENT = 0, + } + /** !#en The skeleton data of spine. + !#zh Spine 的 骨骼数据。 */ + export class SkeletonData extends cc.Asset { + /** !#en See http://en.esotericsoftware.com/spine-json-format + !#zh 可查看 Spine 官方文档 http://zh.esotericsoftware.com/spine-json-format */ + skeletonJson: any; + atlasText: string; + textures: cc.Texture2D[]; + /** !#en + A scale can be specified on the JSON or binary loader which will scale the bone positions, + image sizes, and animation translations. + This can be useful when using different sized images than were used when designing the skeleton + in Spine. For example, if using images that are half the size than were used in Spine, + a scale of 0.5 can be used. This is commonly used for games that can run with either low or high + resolution texture atlases. + see http://en.esotericsoftware.com/spine-using-runtimes#Scaling + !#zh 可查看 Spine 官方文档: http://zh.esotericsoftware.com/spine-using-runtimes#Scaling */ + scale: number; + /** + !#en Get the included SkeletonData used in spine runtime.
+ Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.SkeletonData object. + !#zh 获取 Spine Runtime 使用的 SkeletonData。
+ 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.SkeletonData 对象。 + @param quiet quiet + */ + getRuntimeData(quiet?: boolean): sp.spine.SkeletonData; + } + /** !#en + The delegate of spine vertex effect + !#zh + Spine 顶点动画代理 */ + export class VertexEffectDelegate { + /** + !#en Clears vertex effect. + !#zh 清空顶点效果 + */ + clear(): void; + /** + !#en Inits delegate with jitter effect + !#zh 设置顶点抖动效果 + @param jitterX jitterX + @param jitterY jitterY + */ + initJitter(jitterX: number, jitterY: number): void; + /** + !#en Inits delegate with swirl effect + !#zh 设置顶点漩涡效果 + @param radius radius + @param power power + */ + initSwirlWithPow(radius: number, power: number): sp.spine.JitterEffect; + /** + !#en Inits delegate with swirl effect + !#zh 设置顶点漩涡效果 + @param radius radius + @param power power + */ + initSwirlWithPowOut(radius: number, power: number): sp.spine.SwirlEffect; + /** + !#en Gets jitter vertex effect + !#zh 获取顶点抖动效果 + */ + getJitterVertexEffect(): sp.spine.JitterEffect; + /** + !#en Gets swirl vertex effect + !#zh 获取顶点漩涡效果 + */ + getSwirlVertexEffect(): sp.spine.SwirlEffect; + /** + !#en Gets vertex effect + !#zh 获取顶点效果 + */ + getVertexEffect(): sp.spine.JitterEffect; + /** + !#en Gets effect type + !#zh 获取效果类型 + */ + getEffectType(): string; + } + /**************************************************** + * sp + *****************************************************/ + + export namespace sp { + /** !#en Attach node tool + !#zh 挂点工具类 */ + export class AttachUtil { + /** + !#en Gets attached root node. + !#zh 获取挂接节点树的根节点 + */ + getAttachedRootNode(): cc.Node; + /** + !#en Gets attached node which you want. + !#zh 获得对应的挂点 + @param boneName boneName + */ + getAttachedNodes(boneName: string): cc.Node[]; + /** + !#en Destroy attached node which you want. + !#zh 销毁对应的挂点 + @param boneName boneName + */ + destroyAttachedNodes(boneName: string): void; + /** + !#en Traverse all bones to generate the minimum node tree containing the given bone names, NOTE that make sure the skeleton has initialized before calling this interface. + !#zh 遍历所有插槽,生成包含所有给定插槽名称的最小节点树,注意,调用该接口前请确保骨骼动画已经初始化好。 + @param boneName boneName + */ + generateAttachedNodes(boneName: string): cc.Node[]; + /** + !#en Destroy all attached node. + !#zh 销毁所有挂点 + */ + destroyAllAttachedNodes(): void; + /** + !#en Traverse all bones to generate a tree containing all bones nodes, NOTE that make sure the skeleton has initialized before calling this interface. + !#zh 遍历所有插槽,生成包含所有插槽的节点树,注意,调用该接口前请确保骨骼动画已经初始化好。 + */ + generateAllAttachedNodes(): cc.Node; + } + } + + /**************************************************** + * Skeleton + *****************************************************/ + + export namespace Skeleton { + /** !#en Enum for animation cache mode type. + !#zh Spine动画缓存类型 */ + export enum AnimationCacheMode { + REALTIME = 0, + SHARED_CACHE = 0, + PRIVATE_CACHE = 0, + } + } + +} + +/** !#en +`sp.spine` is the namespace for official Spine Runtime, which officially implemented and maintained by Spine.
+Please refer to the official documentation for its detailed usage: [http://en.esotericsoftware.com/spine-using-runtimes](http://en.esotericsoftware.com/spine-using-runtimes) +!#zh +sp.spine 模块是 Spine 官方运行库的 API 入口,由 Spine 官方统一实现和维护,具体用法请参考:[http://zh.esotericsoftware.com/spine-using-runtimes](http://zh.esotericsoftware.com/spine-using-runtimes) */ +declare namespace sp.spine { +} + +/** !#en +The global main namespace of DragonBones, all classes, functions, +properties and constants of DragonBones are defined in this namespace +!#zh +DragonBones 的全局的命名空间, +与 DragonBones 相关的所有的类,函数,属性,常量都在这个命名空间中定义。 */ +declare namespace dragonBones { + /** !#en + The Armature Display of DragonBones
+
+ (Armature Display has a reference to a DragonBonesAsset and stores the state for ArmatureDisplay instance, + which consists of the current pose's bone SRT, slot colors, and which slot attachments are visible.
+ Multiple Armature Display can use the same DragonBonesAsset which includes all animations, skins, and attachments.)
+ !#zh + DragonBones 骨骼动画
+
+ (Armature Display 具有对骨骼数据的引用并且存储了骨骼实例的状态, + 它由当前的骨骼动作,slot 颜色,和可见的 slot attachments 组成。
+ 多个 Armature Display 可以使用相同的骨骼数据,其中包括所有的动画,皮肤和 attachments。)
*/ + export class ArmatureDisplay extends cc.RenderComponent { + /** !#en + The DragonBones data contains the armatures information (bind pose bones, slots, draw order, + attachments, skins, etc) and animations but does not hold any state.
+ Multiple ArmatureDisplay can share the same DragonBones data. + !#zh + 骨骼数据包含了骨骼信息(绑定骨骼动作,slots,渲染顺序, + attachments,皮肤等等)和动画但不持有任何状态。
+ 多个 ArmatureDisplay 可以共用相同的骨骼数据。 */ + dragonAsset: DragonBonesAsset; + /** !#en + The atlas asset for the DragonBones. + !#zh + 骨骼数据所需的 Atlas Texture 数据。 */ + dragonAtlasAsset: DragonBonesAtlasAsset; + /** !#en The name of current armature. + !#zh 当前的 Armature 名称。 */ + armatureName: string; + /** !#en The name of current playing animation. + !#zh 当前播放的动画名称。 */ + animationName: string; + _defaultArmatureIndex: number; + /** !#en The time scale of this armature. + !#zh 当前骨骼中所有动画的时间缩放率。 */ + timeScale: number; + /** !#en The play times of the default animation. + -1 means using the value of config file; + 0 means repeat for ever + >0 means repeat times + !#zh 播放默认动画的循环次数 + -1 表示使用配置文件中的默认值; + 0 表示无限循环 + >0 表示循环次数 */ + playTimes: number; + /** !#en Indicates whether to enable premultiplied alpha. + You should disable this option when image's transparent area appears to have opaque pixels, + or enable this option when image's half transparent area appears to be darken. + !#zh 是否启用贴图预乘。 + 当图片的透明区域出现色块时需要关闭该选项,当图片的半透明区域颜色变黑时需要启用该选项。 */ + premultipliedAlpha: boolean; + /** !#en Indicates whether open debug bones. + !#zh 是否显示 bone 的 debug 信息。 */ + debugBones: boolean; + /** !#en Enabled batch model, if skeleton is complex, do not enable batch, or will lower performance. + !#zh 开启合批,如果渲染大量相同纹理,且结构简单的骨骼动画,开启合批可以降低drawcall,否则请不要开启,cpu消耗会上升。 */ + enableBatch: boolean; + /** + !#en + The key of dragonbones cache data, which is regard as 'dragonbonesName', when you want to change dragonbones cloth. + !#zh + 缓存龙骨数据的key值,换装的时会使用到该值,作为dragonbonesName使用 + + @example + ```js + let factory = dragonBones.CCFactory.getInstance(); + let needChangeSlot = needChangeArmature.armature().getSlot("changeSlotName"); + factory.replaceSlotDisplay(toChangeArmature.getArmatureKey(), "armatureName", "slotName", "displayName", needChangeSlot); + ``` + */ + getArmatureKey(): string; + /** + !#en + It's best to set cache mode before set property 'dragonAsset', or will waste some cpu time. + If set the mode in editor, then no need to worry about order problem. + !#zh + 若想切换渲染模式,最好在设置'dragonAsset'之前,先设置好渲染模式,否则有运行时开销。 + 若在编辑中设置渲染模式,则无需担心设置次序的问题。 + @param cacheMode cacheMode + + @example + ```js + armatureDisplay.setAnimationCacheMode(dragonBones.ArmatureDisplay.AnimationCacheMode.SHARED_CACHE); + ``` + */ + setAnimationCacheMode(cacheMode: ArmatureDisplay.AnimationCacheMode): void; + /** + !#en Whether in cached mode. + !#zh 当前是否处于缓存模式。 + */ + isAnimationCached(): boolean; + /** + !#en + Play the specified animation. + Parameter animName specify the animation name. + Parameter playTimes specify the repeat times of the animation. + -1 means use the value of the config file. + 0 means play the animation for ever. + >0 means repeat times. + !#zh + 播放指定的动画. + animName 指定播放动画的名称。 + playTimes 指定播放动画的次数。 + -1 为使用配置文件中的次数。 + 0 为无限循环播放。 + >0 为动画的重复次数。 + @param animName animName + @param playTimes playTimes + */ + playAnimation(animName: string, playTimes: number): dragonBones.AnimationState; + /** + !#en + Updating an animation cache to calculate all frame data in the animation is a cost in + performance due to calculating all data in a single frame. + To update the cache, use the invalidAnimationCache method with high performance. + !#zh + 更新某个动画缓存, 预计算动画中所有帧数据,由于在单帧计算所有数据,所以较消耗性能。 + 若想更新缓存,可使用 invalidAnimationCache 方法,具有较高性能。 + @param animName animName + */ + updateAnimationCache(animName: string): void; + /** + !#en + Invalidates the animation cache, which is then recomputed on each frame.. + !#zh + 使动画缓存失效,之后会在每帧重新计算。 + */ + invalidAnimationCache(): void; + /** + !#en + Get the all armature names in the DragonBones Data. + !#zh + 获取 DragonBones 数据中所有的 armature 名称 + */ + getArmatureNames(): any[]; + /** + !#en + Get the all animation names of specified armature. + !#zh + 获取指定的 armature 的所有动画名称。 + @param armatureName armatureName + */ + getAnimationNames(armatureName: string): any[]; + /** + !#en + Add event listener for the DragonBones Event, the same to addEventListener. + !#zh + 添加 DragonBones 事件监听器,与 addEventListener 作用相同。 + @param type A string representing the event type to listen for. + @param listener The callback that will be invoked when the event is dispatched. + @param target The target (this object) to invoke the callback, can be null + */ + on(type: string, listener: (event: cc.Event) => void, target?: any): void; + /** + !#en + Remove the event listener for the DragonBones Event, the same to removeEventListener. + !#zh + 移除 DragonBones 事件监听器,与 removeEventListener 作用相同。 + @param type A string representing the event type to listen for. + @param listener listener + @param target target + */ + off(type: string, listener?: Function, target?: any): void; + /** + !#en + Add DragonBones one-time event listener, the callback will remove itself after the first time it is triggered. + !#zh + 添加 DragonBones 一次性事件监听器,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param listener The callback that will be invoked when the event is dispatched. + @param target The target (this object) to invoke the callback, can be null + */ + once(type: string, listener: (event: cc.Event) => void, target?: any): void; + /** + !#en + Add event listener for the DragonBones Event. + !#zh + 添加 DragonBones 事件监听器。 + @param type A string representing the event type to listen for. + @param listener The callback that will be invoked when the event is dispatched. + @param target The target (this object) to invoke the callback, can be null + */ + addEventListener(type: string, listener: (event: cc.Event) => void, target?: any): void; + /** + !#en + Remove the event listener for the DragonBones Event. + !#zh + 移除 DragonBones 事件监听器。 + @param type A string representing the event type to listen for. + @param listener listener + @param target target + */ + removeEventListener(type: string, listener?: Function, target?: any): void; + /** + !#en + Build the armature for specified name. + !#zh + 构建指定名称的 armature 对象 + @param armatureName armatureName + @param node node + */ + buildArmature(armatureName: string, node: cc.Node): ArmatureDisplay; + /** + !#en + Get the current armature object of the ArmatureDisplay. + !#zh + 获取 ArmatureDisplay 当前使用的 Armature 对象 + */ + armature(): any; + } + /** DragonBones factory */ + export class CCFactory extends BaseFactory { + /** + + + @example + ```js + let factory = dragonBones.CCFactory.getInstance(); + ``` + */ + static getInstance(): CCFactory; + } + /** !#en The skeleton data of dragonBones. + !#zh dragonBones 的 骨骼数据。 */ + export class DragonBonesAsset extends cc.Asset { + /** !#en See http://developer.egret.com/cn/github/egret-docs/DB/dbLibs/dataFormat/index.html + !#zh 可查看 DragonBones 官方文档 http://developer.egret.com/cn/github/egret-docs/DB/dbLibs/dataFormat/index.html */ + dragonBonesJson: string; + } + /** !#en The skeleton atlas data of dragonBones. + !#zh dragonBones 的骨骼纹理数据。 */ + export class DragonBonesAtlasAsset extends cc.Asset { + atlasJson: string; + texture: cc.Texture2D; + } + /**************************************************** + * ArmatureDisplay + *****************************************************/ + + export namespace ArmatureDisplay { + /** !#en Enum for cache mode type. + !#zh Dragonbones渲染类型 */ + export enum AnimationCacheMode { + REALTIME = 0, + SHARED_CACHE = 0, + PRIVATE_CACHE = 0, + } + } + + /**************************************************** + * dragonBones + *****************************************************/ + + export namespace dragonBones { + /** !#en Attach node tool + !#zh 挂点工具类 */ + export class AttachUtil { + /** + !#en Gets attached root node. + !#zh 获取挂接节点树的根节点 + */ + getAttachedRootNode(): cc.Node; + /** + !#en Gets attached node which you want. + !#zh 获得对应的挂点 + @param boneName boneName + */ + getAttachedNodes(boneName: string): cc.Node[]; + /** + !#en Destroy attached node which you want. + !#zh 销毁对应的挂点 + @param boneName boneName + */ + destroyAttachedNodes(boneName: string): void; + /** + !#en Traverse all bones to generate the minimum node tree containing the given bone names, NOTE that make sure the skeleton has initialized before calling this interface. + !#zh 遍历所有插槽,生成包含所有给定插槽名称的最小节点树,注意,调用该接口前请确保骨骼动画已经初始化好。 + @param boneName boneName + */ + generateAttachedNodes(boneName: string): cc.Node[]; + /** + !#en Destroy all attached node. + !#zh 销毁所有挂点 + */ + destroyAllAttachedNodes(): void; + /** + !#en Traverse all bones to generate a tree containing all bones nodes, NOTE that make sure the skeleton has initialized before calling this interface. + !#zh 遍历所有插槽,生成包含所有插槽的节点树,注意,调用该接口前请确保骨骼动画已经初始化好。 + */ + generateAllAttachedNodes(): cc.Node; + } + } + +} + +/** Some helpful utilities */ +declare namespace cc.geomUtils { + /** + !#en + the distance between a point and a plane + !#zh + 计算点和平面之间的距离。 + @param point point + @param plane plane + */ + export function point_plane(point: cc.Vec3, plane: cc.Plane): number; + /** + !#en + the closest point on plane to a given point + !#zh + 计算平面上最接近给定点的点。 + @param out Closest point + @param point Given point + @param plane plane + */ + export function pt_point_plane(out: cc.Vec3, point: cc.Vec3, plane: cc.Plane): cc.Vec3; + /** + !#en + the closest point on aabb to a given point + !#zh + 计算 aabb 上最接近给定点的点。 + @param out Closest point. + @param point Given point. + @param aabb Align the axis around the box. + */ + export function pt_point_aabb(out: cc.Vec3, point: cc.Vec3, aabb: cc.Aabb): cc.Vec3; + /** + !#en + the closest point on obb to a given point + !#zh + 计算 obb 上最接近给定点的点。 + @param out Closest point + @param point Given point + @param obb Direction box + */ + export function pt_point_obb(out: cc.Vec3, point: cc.Vec3, obb: cc.Obb): cc.Vec3; +} + +/** !#en Some JavaScript decorators which can be accessed with "cc._decorator". +!#zh 一些 JavaScript 装饰器,目前可以通过 "cc._decorator" 来访问。 +(这些 API 仍不完全稳定,有可能随着 JavaScript 装饰器的标准实现而调整) */ +declare namespace cc._decorator { + /** + !#en + Declare the standard [ES6 Class](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes) + as CCClass, please see [Class](../../../manual/en/scripting/class.html) for details. + !#zh + 将标准写法的 [ES6 Class](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes) 声明为 CCClass,具体用法请参阅[类型定义](../../../manual/zh/scripting/class.html)。 + @param name The class name used for serialization. + + @example + ```js + const {ccclass} = cc._decorator; + + // define a CCClass, omit the name + @ccclass + class NewScript extends cc.Component { + // ... + } + + // define a CCClass with a name + @ccclass('LoginData') + class LoginData { + // ... + } + ``` + */ + export function ccclass(name?: string): Function; + export function ccclass(_class?: Function): void; + /** + !#en + Declare property for [CCClass](../../../manual/en/scripting/reference/attributes.html). + !#zh + 定义 [CCClass](../../../manual/zh/scripting/reference/attributes.html) 所用的属性。 + @param options an object with some property attributes + + @example + ```js + const {ccclass, property} = cc._decorator; + + @ccclass + class NewScript extends cc.Component { + @property({ + type: cc.Node + }) + targetNode1 = null; + + @property(cc.Node) + targetNode2 = null; + + @property(cc.Button) + targetButton = null; + + @property + _width = 100; + + @property + get width () { + return this._width; + } + + @property + set width (value) { + this._width = value; + } + + @property + offset = new cc.Vec2(100, 100); + + @property(cc.Vec2) + offsets = []; + + @property(cc.SpriteFrame) + frame = null; + } + + // above is equivalent to (上面的代码相当于): + + var NewScript = cc.Class({ + properties: { + targetNode1: { + default: null, + type: cc.Node + }, + + targetNode2: { + default: null, + type: cc.Node + }, + + targetButton: { + default: null, + type: cc.Button + }, + + _width: 100, + + width: { + get () { + return this._width; + }, + set (value) { + this._width = value; + } + }, + + offset: new cc.Vec2(100, 100) + + offsets: { + default: [], + type: cc.Vec2 + } + + frame: { + default: null, + type: cc.SpriteFrame + }, + } + }); + ``` + */ + export function property(options?: {type?: any; visible?: boolean|(() => boolean); displayName?: string; tooltip?: string; multiline?: boolean; readonly?: boolean; min?: number; max?: number; step?: number; range?: number[]; slide?: boolean; serializable?: boolean; formerlySerializedAs?: string; editorOnly?: boolean; override?: boolean; animatable?: boolean} | any[]|Function|cc.ValueType|number|string|boolean): Function; + export function property(_target: Object, _key: any, _desc?: any): void; + /** + !#en + Makes a CCClass that inherit from component execute in edit mode.
+ By default, all components are only executed in play mode, + which means they will not have their callback functions executed while the Editor is in edit mode. + !#zh + 允许继承自 Component 的 CCClass 在编辑器里执行。
+ 默认情况下,所有 Component 都只会在运行时才会执行,也就是说它们的生命周期回调不会在编辑器里触发。 + + @example + ```js + const {ccclass, executeInEditMode} = cc._decorator; + + @ccclass + @executeInEditMode + class NewScript extends cc.Component { + // ... + } + ``` + */ + export function executeInEditMode(): Function; + export function executeInEditMode(_class: Function): void; + /** + !#en + Automatically add required component as a dependency for the CCClass that inherit from component. + !#zh + 为声明为 CCClass 的组件添加依赖的其它组件。当组件添加到节点上时,如果依赖的组件不存在,引擎将会自动将依赖组件添加到同一个节点,防止脚本出错。该设置在运行时同样有效。 + @param requiredComponent requiredComponent + + @example + ```js + const {ccclass, requireComponent} = cc._decorator; + + @ccclass + @requireComponent(cc.Sprite) + class SpriteCtrl extends cc.Component { + // ... + } + ``` + */ + export function requireComponent(requiredComponent: typeof cc.Component): Function; + /** + !#en + The menu path to register a component to the editors "Component" menu. Eg. "Rendering/CameraCtrl". + !#zh + 将当前组件添加到组件菜单中,方便用户查找。例如 "Rendering/CameraCtrl"。 + @param path The path is the menu represented like a pathname. + For example the menu could be "Rendering/CameraCtrl". + + @example + ```js + const {ccclass, menu} = cc._decorator; + + @ccclass + @menu("Rendering/CameraCtrl") + class NewScript extends cc.Component { + // ... + } + ``` + */ + export function menu(path: string): Function; + /** + !#en + The execution order of lifecycle methods for Component. + Those less than 0 will execute before while those greater than 0 will execute after. + The order will only affect onLoad, onEnable, start, update and lateUpdate while onDisable and onDestroy will not be affected. + !#zh + 设置脚本生命周期方法调用的优先级。优先级小于 0 的组件将会优先执行,优先级大于 0 的组件将会延后执行。优先级仅会影响 onLoad, onEnable, start, update 和 lateUpdate,而 onDisable 和 onDestroy 不受影响。 + @param order The execution order of lifecycle methods for Component. Those less than 0 will execute before while those greater than 0 will execute after. + + @example + ```js + const {ccclass, executionOrder} = cc._decorator; + + @ccclass + @executionOrder(1) + class CameraCtrl extends cc.Component { + // ... + } + ``` + */ + export function executionOrder(order: number): Function; + /** + !#en + Prevents Component of the same type (or subtype) to be added more than once to a Node. + !#zh + 防止多个相同类型(或子类型)的组件被添加到同一个节点。 + + @example + ```js + const {ccclass, disallowMultiple} = cc._decorator; + + @ccclass + @disallowMultiple + class CameraCtrl extends cc.Component { + // ... + } + ``` + */ + export function disallowMultiple(): Function; + export function disallowMultiple(_class: Function): void; + /** + !#en + If specified, the editor's scene view will keep updating this node in 60 fps when it is selected, otherwise, it will update only if necessary.
+ This property is only available if executeInEditMode is true. + !#zh + 当指定了 "executeInEditMode" 以后,playOnFocus 可以在选中当前组件所在的节点时,提高编辑器的场景刷新频率到 60 FPS,否则场景就只会在必要的时候进行重绘。 + + @example + ```js + const {ccclass, playOnFocus, executeInEditMode} = cc._decorator; + + @ccclass + @executeInEditMode + @playOnFocus + class CameraCtrl extends cc.Component { + // ... + } + ``` + */ + export function playOnFocus(): Function; + export function playOnFocus(_class: Function): void; + /** + !#en + Specifying the url of the custom html to draw the component in **Properties**. + !#zh + 自定义当前组件在 **属性检查器** 中渲染时所用的网页 url。 + @param url url + + @example + ```js + const {ccclass, inspector} = cc._decorator; + + @ccclass + @inspector("packages://inspector/inspectors/comps/camera-ctrl.js") + class NewScript extends cc.Component { + // ... + } + ``` + */ + export function inspector(path: string): Function; + /** + !#en + The custom documentation URL. + !#zh + 指定当前组件的帮助文档的 url,设置过后,在 **属性检查器** 中就会出现一个帮助图标,用户点击将打开指定的网页。 + @param url url + + @example + ```js + const {ccclass, help} = cc._decorator; + + @ccclass + @help("app://docs/html/components/spine.html") + class NewScript extends cc.Component { + // ... + } + ``` + */ + export function help(path: string): Function; + /** + NOTE:
+ The old mixins implemented in cc.Class(ES5) behaves exact the same as multiple inheritance. + But since ES6, class constructor can't be function-called and class methods become non-enumerable, + so we can not mix in ES6 Classes.
+ See:
+ [https://esdiscuss.org/topic/traits-are-now-impossible-in-es6-until-es7-since-rev32](https://esdiscuss.org/topic/traits-are-now-impossible-in-es6-until-es7-since-rev32)
+ One possible solution (but IDE unfriendly):
+ [http://justinfagnani.com/2015/12/21/real-mixins-with-javascript-classes](http://justinfagnani.com/2015/12/21/real-mixins-with-javascript-classes/)
+
+ NOTE:
+ You must manually call mixins constructor, this is different from cc.Class(ES5). + @param ctor constructors to mix, only support ES5 constructors or classes defined by using `cc.Class`, + not support ES6 Classes. + + @example + ```js + const {ccclass, mixins} = cc._decorator; + + class Animal { ... } + + const Fly = cc.Class({ + constructor () { ... } + }); + + @ccclass + @mixins(cc.EventTarget, Fly) + class Bird extends Animal { + constructor () { + super(); + + // You must manually call mixins constructor, this is different from cc.Class(ES5) + cc.EventTarget.call(this); + Fly.call(this); + } + // ... + } + ``` + */ + export function mixins(ctor: Function, ...rest: Function[]): Function; +} + +/** !#en This module provides some JavaScript utilities. All members can be accessed with `cc.js`. +!#zh 这个模块封装了 JavaScript 相关的一些实用函数,你可以通过 `cc.js` 来访问这个模块。 */ +declare namespace cc.js { + /** + Check the obj whether is number or not + If a number is created by using 'new Number(10086)', the typeof it will be "object"... + Then you can use this function if you care about this case. + @param obj obj + */ + export function isNumber(obj: any): boolean; + /** + Check the obj whether is string or not. + If a string is created by using 'new String("blabla")', the typeof it will be "object"... + Then you can use this function if you care about this case. + @param obj obj + */ + export function isString(obj: any): boolean; + /** + Copy all properties not defined in obj from arguments[1...n] + @param obj object to extend its properties + @param sourceObj source object to copy properties from + */ + export function addon(obj: any, ...sourceObj: any[]): any; + /** + copy all properties from arguments[1...n] to obj + @param obj obj + @param sourceObj sourceObj + */ + export function mixin(obj: any, ...sourceObj: any[]): any; + /** + Derive the class from the supplied base class. + Both classes are just native javascript constructors, not created by cc.Class, so + usually you will want to inherit using {{#crossLink "cc/Class:method"}}cc.Class {{/crossLink}} instead. + @param cls cls + @param base the baseclass to inherit + */ + export function extend(cls: Function, base: Function): Function; + /** + Get super class + @param ctor the constructor of subclass + */ + export function getSuper(ctor: Function): Function; + /** + Checks whether subclass is child of superclass or equals to superclass + @param subclass subclass + @param superclass superclass + */ + export function isChildClassOf(subclass: Function, superclass: Function): boolean; + /** + Removes all enumerable properties from object + @param obj obj + */ + export function clear(obj: any): void; + /** + Checks whether obj is an empty object + @param obj obj + */ + export function isEmptyObject(obj: any): boolean; + /** + Get property descriptor in object and all its ancestors + @param obj obj + @param name name + */ + export function getPropertyDescriptor(obj: any, name: string): any; + /** + Define value, just help to call Object.defineProperty.
+ The configurable will be true. + @param obj obj + @param prop prop + @param value value + @param writable writable + @param enumerable enumerable + */ + export function value(obj: any, prop: string, value: any, writable?: boolean, enumerable?: boolean): void; + /** + Define get set accessor, just help to call Object.defineProperty(...) + @param obj obj + @param prop prop + @param getter getter + @param setter setter + @param enumerable enumerable + @param configurable configurable + */ + export function getset(obj: any, prop: string, getter: Function, setter?: Function, enumerable?: boolean, configurable?: boolean): void; + /** + Define get accessor, just help to call Object.defineProperty(...) + @param obj obj + @param prop prop + @param getter getter + @param enumerable enumerable + @param configurable configurable + */ + export function get(obj: any, prop: string, getter: Function, enumerable?: boolean, configurable?: boolean): void; + /** + Define set accessor, just help to call Object.defineProperty(...) + @param obj obj + @param prop prop + @param setter setter + @param enumerable enumerable + @param configurable configurable + */ + export function set(obj: any, prop: string, setter: Function, enumerable?: boolean, configurable?: boolean): void; + /** + Get class name of the object, if object is just a {} (and which class named 'Object'), it will return "". + (modified from the code from this stackoverflow post) + @param objOrCtor instance or constructor + */ + export function getClassName(objOrCtor: any|Function): string; + /** !#en All classes registered in the engine, indexed by ID. + !#zh 引擎中已注册的所有类型,通过 ID 进行索引。 */ + export var _registeredClassIds: any; + /** !#en All classes registered in the engine, indexed by name. + !#zh 引擎中已注册的所有类型,通过名称进行索引。 */ + export var _registeredClassNames: any; + /** + Register the class by specified name manually + @param className className + @param constructor constructor + */ + export function setClassName(className: string, constructor: Function): void; + /** + Unregister a class from fireball. + + If you dont need a registered class anymore, you should unregister the class so that Fireball will not keep its reference anymore. + Please note that its still your responsibility to free other references to the class. + @param constructor the class you will want to unregister, any number of classes can be added + */ + export function unregisterClass(...constructor: Function[]): void; + /** + Get the registered class by name + @param classname classname + */ + export function getClassByName(classname: string): Function; + /** + Defines a polyfill field for deprecated codes. + @param obj YourObject or YourClass.prototype + @param obsoleted "OldParam" or "YourClass.OldParam" + @param newExpr "NewParam" or "YourClass.NewParam" + @param writable writable + */ + export function obsolete(obj: any, obsoleted: string, newExpr: string, writable?: boolean): void; + /** + Defines all polyfill fields for obsoleted codes corresponding to the enumerable properties of props. + @param obj YourObject or YourClass.prototype + @param objName "YourObject" or "YourClass" + @param props props + @param writable writable + */ + export function obsoletes(obj: any, objName: any, props: any, writable?: boolean): void; + /** + A string tool to construct a string with format string. + @param msg A JavaScript string containing zero or more substitution strings (%s). + @param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output. + + @example + ```js + cc.js.formatStr("a: %s, b: %s", a, b); + cc.js.formatStr(a, b, c); + ``` + */ + export function formatStr(msg: string|any, ...subst: any[]): string; + /** + !#en + A simple wrapper of `Object.create(null)` which ensures the return object have no prototype (and thus no inherited members). So we can skip `hasOwnProperty` calls on property lookups. It is a worthwhile optimization than the `{}` literal when `hasOwnProperty` calls are necessary. + !#zh + 该方法是对 `Object.create(null)` 的简单封装。`Object.create(null)` 用于创建无 prototype (也就无继承)的空对象。这样我们在该对象上查找属性时,就不用进行 `hasOwnProperty` 判断。在需要频繁判断 `hasOwnProperty` 时,使用这个方法性能会比 `{}` 更高。 + @param forceDictMode Apply the delete operator to newly created map object. This causes V8 to put the object in "dictionary mode" and disables creation of hidden classes which are very expensive for objects that are constantly changing shape. + */ + export function createMap(forceDictMode?: boolean): any; + /** undefined */ + export class array { + /** + Removes the array item at the specified index. + @param array array + @param index index + */ + static removeAt(array: any[], index: number): void; + /** + Removes the array item at the specified index. + It's faster but the order of the array will be changed. + @param array array + @param index index + */ + static fastRemoveAt(array: any[], index: number): void; + /** + Removes the first occurrence of a specific object from the array. + @param array array + @param value value + */ + static remove(array: any[], value: any): boolean; + /** + Removes the first occurrence of a specific object from the array. + It's faster but the order of the array will be changed. + @param array array + @param value value + */ + static fastRemove(array: any[], value: number): void; + /** + Verify array's Type + @param array array + @param type type + */ + static verifyType(array: any[], type: Function): boolean; + /** + Removes from array all values in minusArr. For each Value in minusArr, the first matching instance in array will be removed. + @param array Source Array + @param minusArr minus Array + */ + static removeArray(array: any[], minusArr: any[]): void; + /** + Inserts some objects at index + @param array array + @param addObjs addObjs + @param index index + */ + static appendObjectsAt(array: any[], addObjs: any[], index: number): any[]; + /** + Exact same function as Array.prototype.indexOf.
+ HACK: ugliy hack for Baidu mobile browser compatibility, stupid Baidu guys modify Array.prototype.indexOf for all pages loaded, their version changes strict comparison to non-strict comparison, it also ignores the second parameter of the original API, and this will cause event handler enter infinite loop.
+ Baidu developers, if you ever see this documentation, here is the standard: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf, Seriously! + @param searchElement Element to locate in the array. + @param fromIndex The index to start the search at + */ + static indexOf(searchElement: any, fromIndex?: number): number; + /** + Determines whether the array contains a specific value. + @param array array + @param value value + */ + static contains(array: any[], value: any): boolean; + /** + Copy an array's item to a new array (its performance is better than Array.slice) + @param array array + */ + static copy(array: any[]): any[]; + } + /** !#en + A fixed-length object pool designed for general type.
+ The implementation of this object pool is very simple, + it can helps you to improve your game performance for objects which need frequent release and recreate operations
+ !#zh + 长度固定的对象缓存池,可以用来缓存各种对象类型。
+ 这个对象池的实现非常精简,它可以帮助您提高游戏性能,适用于优化对象的反复创建和销毁。 */ + export class Pool { + /** + !#en + Constructor for creating an object pool for the specific object type. + You can pass a callback argument for process the cleanup logic when the object is recycled. + !#zh + 使用构造函数来创建一个指定对象类型的对象池,您可以传递一个回调函数,用于处理对象回收时的清理逻辑。 + @param cleanupFunc the callback method used to process the cleanup logic when the object is recycled. + @param size initializes the length of the array + */ + constructor(cleanupFunc: (obj: any) => void, size: number); + constructor(size: number); + /** + !#en + Get and initialize an object from pool. This method defaults to null and requires the user to implement it. + !#zh + 获取并初始化对象池中的对象。这个方法默认为空,需要用户自己实现。 + @param params parameters to used to initialize the object + */ + get(...params: any[]): any; + /** !#en + The current number of available objects, the default is 0, it will gradually increase with the recycle of the object, + the maximum will not exceed the size specified when the constructor is called. + !#zh + 当前可用对象数量,一开始默认是 0,随着对象的回收会逐渐增大,最大不会超过调用构造函数时指定的 size。 */ + count: number; + /** + !#en + Get an object from pool, if no available object in the pool, null will be returned. + !#zh + 获取对象池中的对象,如果对象池没有可用对象,则返回空。 + */ + _get(): any; + /** + !#en Put an object into the pool. + !#zh 向对象池返还一个不再需要的对象。 + */ + put(): void; + /** + !#en Resize the pool. + !#zh 设置对象池容量。 + */ + resize(): void; + } +} + +/** !#en A basic module for creating vertex data for 3D objects. You can access this module by `cc.primitive`. +!#zh 一个创建 3D 物体顶点数据的基础模块,你可以通过 `cc.primitive` 来访问这个模块。 */ +declare namespace cc.primitive { + /** + !#en Create box vertex data + !#zh 创建长方体顶点数据 + @param width width + @param height height + @param length length + @param opts opts + */ + export function box(width: number, height: number, length: number, opts: {widthSegments: number; heightSegments: number; lengthSegments: number; }): cc.VertexData; + /** + !#en Create cone vertex data + !#zh 创建圆锥体顶点数据 + @param radius radius + @param height height + @param opts opts + */ + export function cone(radius: number, height: number, opts: {radialSegments: number; heightSegments: number; capped: boolean; arc: number; }): cc.VertexData; + /** + !#en Create cylinder vertex data + !#zh 创建圆柱体顶点数据 + @param radiusTop radiusTop + @param radiusBottom radiusBottom + @param height height + @param opts opts + */ + export function cylinder(radiusTop: number, radiusBottom: number, height: number, opts: {radialSegments: number; heightSegments: number; capped: boolean; arc: number; }): cc.VertexData; + /** + !#en Create plane vertex data + !#zh 创建平台顶点数据 + @param width width + @param length length + @param opts opts + */ + export function plane(width: number, length: number, opts: {widthSegments: number; lengthSegments: number; }): cc.VertexData; + /** + !#en Create quad vertex data + !#zh 创建面片顶点数据 + */ + export function quad(): cc.VertexData; + /** + !#en Create sphere vertex data + !#zh 创建球体顶点数据 + @param radius radius + @param opts opts + */ + export function sphere(radius: number, opts: {segments: number; }): cc.VertexData; + /** + !#en Create torus vertex data + !#zh 创建圆环顶点数据 + @param radius radius + @param tube tube + @param opts opts + */ + export function torus(radius: number, tube: number, opts: {radialSegments: number; tubularSegments: number; arc: number; }): cc.VertexData; + /** + !#en Create capsule vertex data + !#zh 创建胶囊体顶点数据 + @param radiusTop radiusTop + @param radiusBottom radiusBottom + @param height height + @param opts opts + */ + export function capsule(radiusTop: number, radiusBottom: number, height: number, opts: {sides: number; heightSegments: number; capped: boolean; arc: number; }): cc.VertexData; + /** + !#en Create polyhedron vertex data + !#zh 创建多面体顶点数据 + @param type type + @param Size Size + @param opts opts + */ + export function polyhedron(type: cc.primitive.PolyhedronType, Size: number, opts: {sizeX: number; sizeY: number; sizeZ: number; }): cc.VertexData; +} + +declare let CC_JSB: boolean +declare let CC_NATIVERENDERER: boolean +declare let CC_EDITOR: boolean + +declare let cc: { + // polyfills: { + // destroyObject? (object: any): void; + // }; + [x: string]: any; +} + +// https://medium.com/dailyjs/typescript-create-a-condition-based-subset-types-9d902cea5b8c +type FlagExcludedType = { [Key in keyof Base]: Base[Key] extends Type ? never : Key }; +type AllowedNames = FlagExcludedType[keyof Base]; +type KeyPartial = { [P in K]?: T[P] }; +type OmitType = KeyPartial>; +type ConstructorType = OmitType; + +declare interface IWritableArrayLike { + readonly length: number; + [index: number]: T; +} + +declare let module: { + exports: object +} + + +type FloatArray = Float64Array | Float32Array; + +interface IColorLike { + r: number; + g: number; + b: number; + a: number; + _val: number; + +} + +interface IMat3Like { + m: FloatArray +} + +interface IMat4Like { + m: FloatArray +} + +interface IQuatLike { + x: number; + y: number; + z: number; + w: number; +} + +interface IRectLike { + x: number; + y: number; + width: number; + height: number; +} + +interface ISizeLike { + width: number; + height: number; +} + +interface IVec2Like { + x: number; + y: number; +} + +interface IVec3Like { + x: number; + y: number; + z: number; +} + +interface IVec4Like { + x: number; + y: number; + z: number; + w: number; +} +declare namespace dragonBones { + /** + * @internal + * @private + */ + const webAssemblyModule: { + HEAP16: Int16Array; + _malloc(byteSize: number): number; + _free(pointer: number): void; + setDataBinary(data: DragonBonesData, binaryPointer: number, intBytesLength: number, floatBytesLength: number, frameIntBytesLength: number, frameFloatBytesLength: number, frameBytesLength: number, timelineBytesLength: number): void; + }; +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + const enum BinaryOffset { + WeigthBoneCount = 0, + WeigthFloatOffset = 1, + WeigthBoneIndices = 2, + MeshVertexCount = 0, + MeshTriangleCount = 1, + MeshFloatOffset = 2, + MeshWeightOffset = 3, + MeshVertexIndices = 4, + TimelineScale = 0, + TimelineOffset = 1, + TimelineKeyFrameCount = 2, + TimelineFrameValueCount = 3, + TimelineFrameValueOffset = 4, + TimelineFrameOffset = 5, + FramePosition = 0, + FrameTweenType = 1, + FrameTweenEasingOrCurveSampleCount = 2, + FrameCurveSamples = 3, + DeformMeshOffset = 0, + DeformCount = 1, + DeformValueCount = 2, + DeformValueOffset = 3, + DeformFloatOffset = 4, + } + /** + * @internal + * @private + */ + const enum ArmatureType { + Armature = 0, + MovieClip = 1, + Stage = 2, + } + /** + * @internal + * @private + */ + const enum BoneType { + Bone = 0, + Surface = 1, + } + /** + * @private + */ + const enum DisplayType { + Image = 0, + Armature = 1, + Mesh = 2, + BoundingBox = 3, + } + /** + * - Bounding box type. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 边界框类型。 + * @version DragonBones 5.0 + * @language zh_CN + */ + const enum BoundingBoxType { + Rectangle = 0, + Ellipse = 1, + Polygon = 2, + } + /** + * @internal + * @private + */ + const enum ActionType { + Play = 0, + Frame = 10, + Sound = 11, + } + /** + * @internal + * @private + */ + const enum BlendMode { + Normal = 0, + Add = 1, + Alpha = 2, + Darken = 3, + Difference = 4, + Erase = 5, + HardLight = 6, + Invert = 7, + Layer = 8, + Lighten = 9, + Multiply = 10, + Overlay = 11, + Screen = 12, + Subtract = 13, + } + /** + * @internal + * @private + */ + const enum TweenType { + None = 0, + Line = 1, + Curve = 2, + QuadIn = 3, + QuadOut = 4, + QuadInOut = 5, + } + /** + * @internal + * @private + */ + const enum TimelineType { + Action = 0, + ZOrder = 1, + BoneAll = 10, + BoneTranslate = 11, + BoneRotate = 12, + BoneScale = 13, + Surface = 50, + SlotDisplay = 20, + SlotColor = 21, + SlotFFD = 22, + IKConstraint = 30, + AnimationTime = 40, + AnimationWeight = 41, + } + /** + * - Offset mode. + * @version DragonBones 5.5 + * @language en_US + */ + /** + * - 偏移模式。 + * @version DragonBones 5.5 + * @language zh_CN + */ + const enum OffsetMode { + None = 0, + Additive = 1, + Override = 2, + } + /** + * - Animation fade out mode. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画淡出模式。 + * @version DragonBones 4.5 + * @language zh_CN + */ + const enum AnimationFadeOutMode { + /** + * - Do not fade out of any animation states. + * @language en_US + */ + /** + * - 不淡出任何的动画状态。 + * @language zh_CN + */ + None = 0, + /** + * - Fade out the animation states of the same layer. + * @language en_US + */ + /** + * - 淡出同层的动画状态。 + * @language zh_CN + */ + SameLayer = 1, + /** + * - Fade out the animation states of the same group. + * @language en_US + */ + /** + * - 淡出同组的动画状态。 + * @language zh_CN + */ + SameGroup = 2, + /** + * - Fade out the animation states of the same layer and group. + * @language en_US + */ + /** + * - 淡出同层并且同组的动画状态。 + * @language zh_CN + */ + SameLayerAndGroup = 3, + /** + * - Fade out of all animation states. + * @language en_US + */ + /** + * - 淡出所有的动画状态。 + * @language zh_CN + */ + All = 4, + /** + * - Does not replace the animation state with the same name. + * @language en_US + */ + /** + * - 不替换同名的动画状态。 + * @language zh_CN + */ + Single = 5, + } + /** + * @private + */ + interface Map { + [key: string]: T; + } + /** + * @private + */ + class DragonBones { + static readonly VERSION: string; + static yDown: boolean; + static debug: boolean; + static debugDraw: boolean; + static webAssembly: boolean; + private readonly _clock; + private readonly _events; + private readonly _objects; + private _eventManager; + constructor(eventManager: IEventDispatcher); + advanceTime(passedTime: number): void; + bufferEvent(value: EventObject): void; + bufferObject(object: BaseObject): void; + readonly clock: WorldClock; + readonly eventManager: IEventDispatcher; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The BaseObject is the base class for all objects in the DragonBones framework. + * All BaseObject instances are cached to the object pool to reduce the performance consumption of frequent requests for memory or memory recovery. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 基础对象,通常 DragonBones 的对象都继承自该类。 + * 所有基础对象的实例都会缓存到对象池,以减少频繁申请内存或内存回收的性能消耗。 + * @version DragonBones 4.5 + * @language zh_CN + */ + abstract class BaseObject { + private static _hashCode; + private static _defaultMaxCount; + private static readonly _maxCountMap; + private static readonly _poolsMap; + private static _returnObject(object); + static toString(): string; + /** + * - Set the maximum cache count of the specify object pool. + * @param objectConstructor - The specify class. (Set all object pools max cache count if not set) + * @param maxCount - Max count. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 设置特定对象池的最大缓存数量。 + * @param objectConstructor - 特定的类。 (不设置则设置所有对象池的最大缓存数量) + * @param maxCount - 最大缓存数量。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static setMaxCount(objectConstructor: (typeof BaseObject) | null, maxCount: number): void; + /** + * - Clear the cached instances of a specify object pool. + * @param objectConstructor - Specify class. (Clear all cached instances if not set) + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 清除特定对象池的缓存实例。 + * @param objectConstructor - 特定的类。 (不设置则清除所有缓存的实例) + * @version DragonBones 4.5 + * @language zh_CN + */ + static clearPool(objectConstructor?: (typeof BaseObject) | null): void; + /** + * - Get an instance of the specify class from object pool. + * @param objectConstructor - The specify class. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 从对象池中获取特定类的实例。 + * @param objectConstructor - 特定的类。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static borrowObject(objectConstructor: { + new (): T; + }): T; + /** + * - A unique identification number assigned to the object. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 分配给此实例的唯一标识号。 + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly hashCode: number; + private _isInPool; + /** + * @private + */ + protected abstract _onClear(): void; + /** + * - Clear the object and return it back to object pool。 + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 清除该实例的所有数据并将其返还对象池。 + * @version DragonBones 4.5 + * @language zh_CN + */ + returnToPool(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - 2D Transform matrix. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 2D 转换矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class Matrix { + /** + * - The value that affects the positioning of pixels along the x axis when scaling or rotating an image. + * @default 1.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 缩放或旋转图像时影响像素沿 x 轴定位的值。 + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + a: number; + /** + * - The value that affects the positioning of pixels along the y axis when rotating or skewing an image. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 旋转或倾斜图像时影响像素沿 y 轴定位的值。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + b: number; + /** + * - The value that affects the positioning of pixels along the x axis when rotating or skewing an image. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 旋转或倾斜图像时影响像素沿 x 轴定位的值。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + c: number; + /** + * - The value that affects the positioning of pixels along the y axis when scaling or rotating an image. + * @default 1.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 缩放或旋转图像时影响像素沿 y 轴定位的值。 + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + d: number; + /** + * - The distance by which to translate each point along the x axis. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 沿 x 轴平移每个点的距离。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + tx: number; + /** + * - The distance by which to translate each point along the y axis. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 沿 y 轴平移每个点的距离。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + ty: number; + /** + * @private + */ + constructor(a?: number, b?: number, c?: number, d?: number, tx?: number, ty?: number); + toString(): string; + /** + * @private + */ + copyFrom(value: Matrix): Matrix; + /** + * @private + */ + copyFromArray(value: Array, offset?: number): Matrix; + /** + * - Convert to unit matrix. + * The resulting matrix has the following properties: a=1, b=0, c=0, d=1, tx=0, ty=0. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 转换为单位矩阵。 + * 该矩阵具有以下属性:a=1、b=0、c=0、d=1、tx=0、ty=0。 + * @version DragonBones 3.0 + * @language zh_CN + */ + identity(): Matrix; + /** + * - Multiplies the current matrix with another matrix. + * @param value - The matrix that needs to be multiplied. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 将当前矩阵与另一个矩阵相乘。 + * @param value - 需要相乘的矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + concat(value: Matrix): Matrix; + /** + * - Convert to inverse matrix. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 转换为逆矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + invert(): Matrix; + /** + * - Apply a matrix transformation to a specific point. + * @param x - X coordinate. + * @param y - Y coordinate. + * @param result - The point after the transformation is applied. + * @param delta - Whether to ignore tx, ty's conversion to point. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 将矩阵转换应用于特定点。 + * @param x - 横坐标。 + * @param y - 纵坐标。 + * @param result - 应用转换之后的点。 + * @param delta - 是否忽略 tx,ty 对点的转换。 + * @version DragonBones 3.0 + * @language zh_CN + */ + transformPoint(x: number, y: number, result: { + x: number; + y: number; + }, delta?: boolean): void; + /** + * @private + */ + transformRectangle(rectangle: { + x: number; + y: number; + width: number; + height: number; + }, delta?: boolean): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - 2D Transform. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 2D 变换。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class Transform { + /** + * @private + */ + static readonly PI: number; + /** + * @private + */ + static readonly PI_D: number; + /** + * @private + */ + static readonly PI_H: number; + /** + * @private + */ + static readonly PI_Q: number; + /** + * @private + */ + static readonly RAD_DEG: number; + /** + * @private + */ + static readonly DEG_RAD: number; + /** + * @private + */ + static normalizeRadian(value: number): number; + /** + * - Horizontal translate. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 水平位移。 + * @version DragonBones 3.0 + * @language zh_CN + */ + x: number; + /** + * - Vertical translate. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 垂直位移。 + * @version DragonBones 3.0 + * @language zh_CN + */ + y: number; + /** + * - Skew. (In radians) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 倾斜。 (以弧度为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + skew: number; + /** + * - rotation. (In radians) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 旋转。 (以弧度为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + rotation: number; + /** + * - Horizontal Scaling. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 水平缩放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + scaleX: number; + /** + * - Vertical scaling. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 垂直缩放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + scaleY: number; + /** + * @private + */ + constructor(x?: number, y?: number, skew?: number, rotation?: number, scaleX?: number, scaleY?: number); + toString(): string; + /** + * @private + */ + copyFrom(value: Transform): Transform; + /** + * @private + */ + identity(): Transform; + /** + * @private + */ + add(value: Transform): Transform; + /** + * @private + */ + minus(value: Transform): Transform; + /** + * @private + */ + fromMatrix(matrix: Matrix): Transform; + /** + * @private + */ + toMatrix(matrix: Matrix): Transform; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + class ColorTransform { + alphaMultiplier: number; + redMultiplier: number; + greenMultiplier: number; + blueMultiplier: number; + alphaOffset: number; + redOffset: number; + greenOffset: number; + blueOffset: number; + constructor(alphaMultiplier?: number, redMultiplier?: number, greenMultiplier?: number, blueMultiplier?: number, alphaOffset?: number, redOffset?: number, greenOffset?: number, blueOffset?: number); + copyFrom(value: ColorTransform): void; + identity(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The Point object represents a location in a two-dimensional coordinate system. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - Point 对象表示二维坐标系统中的某个位置。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class Point { + /** + * - The horizontal coordinate. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 该点的水平坐标。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + x: number; + /** + * - The vertical coordinate. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 该点的垂直坐标。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + y: number; + /** + * - Creates a new point. If you pass no parameters to this method, a point is created at (0,0). + * @param x - The horizontal coordinate. + * @param y - The vertical coordinate. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 创建一个 egret.Point 对象.若不传入任何参数,将会创建一个位于(0,0)位置的点。 + * @param x - 该对象的x属性值,默认为 0.0。 + * @param y - 该对象的y属性值,默认为 0.0。 + * @version DragonBones 3.0 + * @language zh_CN + */ + constructor(x?: number, y?: number); + /** + * @private + */ + copyFrom(value: Point): void; + /** + * @private + */ + clear(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - A Rectangle object is an area defined by its position, as indicated by its top-left corner point (x, y) and by its + * width and its height.
+ * The x, y, width, and height properties of the Rectangle class are independent of each other; changing the value of + * one property has no effect on the others. However, the right and bottom properties are integrally related to those + * four properties. For example, if you change the value of the right property, the value of the width property changes; + * if you change the bottom property, the value of the height property changes. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - Rectangle 对象是按其位置(由它左上角的点 (x, y) 确定)以及宽度和高度定义的区域。
+ * Rectangle 类的 x、y、width 和 height 属性相互独立;更改一个属性的值不会影响其他属性。 + * 但是,right 和 bottom 属性与这四个属性是整体相关的。例如,如果更改 right 属性的值,则 width + * 属性的值将发生变化;如果更改 bottom 属性,则 height 属性的值将发生变化。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class Rectangle { + /** + * - The x coordinate of the top-left corner of the rectangle. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 矩形左上角的 x 坐标。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + x: number; + /** + * - The y coordinate of the top-left corner of the rectangle. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 矩形左上角的 y 坐标。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + y: number; + /** + * - The width of the rectangle, in pixels. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 矩形的宽度(以像素为单位)。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + width: number; + /** + * - 矩形的高度(以像素为单位)。 + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - The height of the rectangle, in pixels. + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + height: number; + /** + * @private + */ + constructor(x?: number, y?: number, width?: number, height?: number); + /** + * @private + */ + copyFrom(value: Rectangle): void; + /** + * @private + */ + clear(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The user custom data. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 用户自定义数据。 + * @version DragonBones 5.0 + * @language zh_CN + */ + class UserData extends BaseObject { + static toString(): string; + /** + * - The custom int numbers. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 自定义整数。 + * @version DragonBones 5.0 + * @language zh_CN + */ + readonly ints: Array; + /** + * - The custom float numbers. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 自定义浮点数。 + * @version DragonBones 5.0 + * @language zh_CN + */ + readonly floats: Array; + /** + * - The custom strings. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 自定义字符串。 + * @version DragonBones 5.0 + * @language zh_CN + */ + readonly strings: Array; + /** + * @inheritDoc + */ + protected _onClear(): void; + /** + * @internal + * @private + */ + addInt(value: number): void; + /** + * @internal + * @private + */ + addFloat(value: number): void; + /** + * @internal + * @private + */ + addString(value: string): void; + /** + * - Get the custom int number. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 获取自定义整数。 + * @version DragonBones 5.0 + * @language zh_CN + */ + getInt(index?: number): number; + /** + * - Get the custom float number. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 获取自定义浮点数。 + * @version DragonBones 5.0 + * @language zh_CN + */ + getFloat(index?: number): number; + /** + * - Get the custom string. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 获取自定义字符串。 + * @version DragonBones 5.0 + * @language zh_CN + */ + getString(index?: number): string; + } + /** + * @internal + * @private + */ + class ActionData extends BaseObject { + static toString(): string; + type: ActionType; + name: string; + bone: BoneData | null; + slot: SlotData | null; + data: UserData | null; + protected _onClear(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The DragonBones data. + * A DragonBones data contains multiple armature data. + * @see dragonBones.ArmatureData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 龙骨数据。 + * 一个龙骨数据包含多个骨架数据。 + * @see dragonBones.ArmatureData + * @version DragonBones 3.0 + * @language zh_CN + */ + class DragonBonesData extends BaseObject { + static toString(): string; + /** + * @private + */ + autoSearch: boolean; + /** + * - The animation frame rate. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画帧频。 + * @version DragonBones 3.0 + * @language zh_CN + */ + frameRate: number; + /** + * - The data version. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 数据版本。 + * @version DragonBones 3.0 + * @language zh_CN + */ + version: string; + /** + * - The DragonBones data name. + * The name is consistent with the DragonBones project name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 龙骨数据名称。 + * 该名称与龙骨项目名保持一致。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + stage: ArmatureData | null; + /** + * @internal + * @private + */ + readonly frameIndices: Array; + /** + * @internal + * @private + */ + readonly cachedFrames: Array; + /** + * - All armature data names. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 所有的骨架数据名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly armatureNames: Array; + /** + * @private + */ + readonly armatures: Map; + /** + * @internal + * @private + */ + binary: ArrayBuffer; + /** + * @internal + * @private + */ + intArray: Int16Array; + /** + * @internal + * @private + */ + floatArray: Float32Array; + /** + * @internal + * @private + */ + frameIntArray: Int16Array; + /** + * @internal + * @private + */ + frameFloatArray: Float32Array; + /** + * @internal + * @private + */ + frameArray: Int16Array; + /** + * @internal + * @private + */ + timelineArray: Uint16Array; + /** + * @private + */ + userData: UserData | null; + /** + * @inheritDoc + */ + protected _onClear(): void; + /** + * @internal + * @private + */ + addArmature(value: ArmatureData): void; + /** + * - Get a specific armature data. + * @param name - The armature data name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的骨架数据。 + * @param name - 骨架数据名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + getArmature(name: string): ArmatureData | null; + /** + * - Deprecated, please refer to {@link #dragonBones.BaseFactory#removeDragonBonesData()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #dragonBones.BaseFactory#removeDragonBonesData()}。 + * @deprecated + * @language zh_CN + */ + dispose(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The armature data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨架数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class ArmatureData extends BaseObject { + static toString(): string; + /** + * @private + */ + type: ArmatureType; + /** + * - The animation frame rate. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画帧率。 + * @version DragonBones 3.0 + * @language zh_CN + */ + frameRate: number; + /** + * @private + */ + cacheFrameRate: number; + /** + * @private + */ + scale: number; + /** + * - The armature name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨架名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + readonly aabb: Rectangle; + /** + * - The names of all the animation data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 所有的动画数据名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly animationNames: Array; + /** + * @private + */ + readonly sortedBones: Array; + /** + * @private + */ + readonly sortedSlots: Array; + /** + * @private + */ + readonly defaultActions: Array; + /** + * @private + */ + readonly actions: Array; + /** + * @private + */ + readonly bones: Map; + /** + * @private + */ + readonly slots: Map; + /** + * @private + */ + readonly constraints: Map; + /** + * @private + */ + readonly skins: Map; + /** + * @private + */ + readonly animations: Map; + /** + * - The default skin data. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 默认插槽数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + defaultSkin: SkinData | null; + /** + * - The default animation data. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 默认动画数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + defaultAnimation: AnimationData | null; + /** + * @private + */ + canvas: CanvasData | null; + /** + * @private + */ + userData: UserData | null; + /** + * @private + */ + parent: DragonBonesData; + /** + * @inheritDoc + */ + protected _onClear(): void; + /** + * @internal + * @private + */ + sortBones(): void; + /** + * @internal + * @private + */ + cacheFrames(frameRate: number): void; + /** + * @internal + * @private + */ + setCacheFrame(globalTransformMatrix: Matrix, transform: Transform): number; + /** + * @internal + * @private + */ + getCacheFrame(globalTransformMatrix: Matrix, transform: Transform, arrayOffset: number): void; + /** + * @internal + * @private + */ + addBone(value: BoneData): void; + /** + * @internal + * @private + */ + addSlot(value: SlotData): void; + /** + * @internal + * @private + */ + addConstraint(value: ConstraintData): void; + /** + * @internal + * @private + */ + addSkin(value: SkinData): void; + /** + * @internal + * @private + */ + addAnimation(value: AnimationData): void; + /** + * @internal + * @private + */ + addAction(value: ActionData, isDefault: boolean): void; + /** + * - Get a specific done data. + * @param name - The bone name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的骨骼数据。 + * @param name - 骨骼名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + getBone(name: string): BoneData | null; + /** + * - Get a specific slot data. + * @param name - The slot name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的插槽数据。 + * @param name - 插槽名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + getSlot(name: string): SlotData | null; + /** + * @private + */ + getConstraint(name: string): ConstraintData | null; + /** + * - Get a specific skin data. + * @param name - The skin name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定皮肤数据。 + * @param name - 皮肤名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + getSkin(name: string): SkinData | null; + /** + * @internal + * @private + */ + getMesh(skinName: string, slotName: string, meshName: string): MeshDisplayData | null; + /** + * - Get a specific animation data. + * @param name - The animation name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的动画数据。 + * @param name - 动画名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + getAnimation(name: string): AnimationData | null; + } + /** + * - The bone data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨骼数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class BoneData extends BaseObject { + static toString(): string; + /** + * @private + */ + inheritTranslation: boolean; + /** + * @private + */ + inheritRotation: boolean; + /** + * @private + */ + inheritScale: boolean; + /** + * @private + */ + inheritReflection: boolean; + /** + * @private + */ + type: BoneType; + /** + * - The bone length. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨骼长度。 + * @version DragonBones 3.0 + * @language zh_CN + */ + length: number; + /** + * - The bone name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨骼名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + readonly transform: Transform; + /** + * @private + */ + userData: UserData | null; + /** + * - The parent bone data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 父骨骼数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + parent: BoneData | null; + /** + * @inheritDoc + */ + protected _onClear(): void; + } + /** + * @internal + * @private + */ + class SurfaceData extends BoneData { + static toString(): string; + segmentX: number; + segmentY: number; + readonly vertices: Array; + /** + * @inheritDoc + */ + protected _onClear(): void; + } + /** + * - The slot data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 插槽数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class SlotData extends BaseObject { + /** + * @internal + * @private + */ + static readonly DEFAULT_COLOR: ColorTransform; + /** + * @internal + * @private + */ + static createColor(): ColorTransform; + static toString(): string; + /** + * @private + */ + blendMode: BlendMode; + /** + * @private + */ + displayIndex: number; + /** + * @private + */ + zOrder: number; + /** + * - The slot name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 插槽名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + color: ColorTransform; + /** + * @private + */ + userData: UserData | null; + /** + * - The parent bone data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 父骨骼数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + parent: BoneData; + /** + * @inheritDoc + */ + protected _onClear(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + abstract class ConstraintData extends BaseObject { + order: number; + name: string; + target: BoneData; + root: BoneData; + bone: BoneData | null; + protected _onClear(): void; + } + /** + * @internal + * @private + */ + class IKConstraintData extends ConstraintData { + static toString(): string; + scaleEnabled: boolean; + bendPositive: boolean; + weight: number; + protected _onClear(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + class CanvasData extends BaseObject { + static toString(): string; + hasBackground: boolean; + color: number; + x: number; + y: number; + width: number; + height: number; + protected _onClear(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The skin data, typically a armature data instance contains at least one skinData. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 皮肤数据,通常一个骨架数据至少包含一个皮肤数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class SkinData extends BaseObject { + static toString(): string; + /** + * - The skin name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 皮肤名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + readonly displays: Map>; + /** + * @private + */ + parent: ArmatureData; + /** + * @inheritDoc + */ + protected _onClear(): void; + /** + * @internal + * @private + */ + addDisplay(slotName: string, value: DisplayData | null): void; + /** + * @private + */ + getDisplay(slotName: string, displayName: string): DisplayData | null; + /** + * @private + */ + getDisplays(slotName: string): Array | null; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + abstract class DisplayData extends BaseObject { + type: DisplayType; + name: string; + path: string; + parent: SkinData; + readonly transform: Transform; + protected _onClear(): void; + } + /** + * @internal + * @private + */ + class ImageDisplayData extends DisplayData { + static toString(): string; + readonly pivot: Point; + texture: TextureData | null; + protected _onClear(): void; + } + /** + * @internal + * @private + */ + class ArmatureDisplayData extends DisplayData { + static toString(): string; + inheritAnimation: boolean; + readonly actions: Array; + armature: ArmatureData | null; + protected _onClear(): void; + /** + * @private + */ + addAction(value: ActionData): void; + } + /** + * @internal + * @private + */ + class MeshDisplayData extends DisplayData { + static toString(): string; + inheritDeform: boolean; + offset: number; + weight: WeightData | null; + glue: GlueData | null; + texture: TextureData | null; + protected _onClear(): void; + } + /** + * @internal + * @private + */ + class BoundingBoxDisplayData extends DisplayData { + static toString(): string; + boundingBox: BoundingBoxData | null; + protected _onClear(): void; + } + /** + * @internal + * @private + */ + class WeightData extends BaseObject { + static toString(): string; + count: number; + offset: number; + readonly bones: Array; + protected _onClear(): void; + addBone(value: BoneData): void; + } + /** + * @internal + * @private + */ + class GlueData extends BaseObject { + static toString(): string; + readonly weights: Array; + readonly meshes: Array; + protected _onClear(): void; + addMesh(value: MeshDisplayData | null): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The base class of bounding box data. + * @see dragonBones.RectangleData + * @see dragonBones.EllipseData + * @see dragonBones.PolygonData + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 边界框数据基类。 + * @see dragonBones.RectangleData + * @see dragonBones.EllipseData + * @see dragonBones.PolygonData + * @version DragonBones 5.0 + * @language zh_CN + */ + abstract class BoundingBoxData extends BaseObject { + /** + * - The bounding box type. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 边界框类型。 + * @version DragonBones 5.0 + * @language zh_CN + */ + type: BoundingBoxType; + /** + * @private + */ + color: number; + /** + * @private + */ + width: number; + /** + * @private + */ + height: number; + /** + * @private + */ + protected _onClear(): void; + /** + * - Check whether the bounding box contains a specific point. (Local coordinate system) + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 检查边界框是否包含特定点。(本地坐标系) + * @version DragonBones 5.0 + * @language zh_CN + */ + abstract containsPoint(pX: number, pY: number): boolean; + /** + * - Check whether the bounding box intersects a specific segment. (Local coordinate system) + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 检查边界框是否与特定线段相交。(本地坐标系) + * @version DragonBones 5.0 + * @language zh_CN + */ + abstract intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA: { + x: number; + y: number; + } | null, intersectionPointB: { + x: number; + y: number; + } | null, normalRadians: { + x: number; + y: number; + } | null): number; + } + /** + * - The rectangle bounding box data. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 矩形边界框数据。 + * @version DragonBones 5.1 + * @language zh_CN + */ + class RectangleBoundingBoxData extends BoundingBoxData { + static toString(): string; + /** + * - Compute the bit code for a point (x, y) using the clip rectangle + */ + private static _computeOutCode(x, y, xMin, yMin, xMax, yMax); + /** + * @private + */ + static rectangleIntersectsSegment(xA: number, yA: number, xB: number, yB: number, xMin: number, yMin: number, xMax: number, yMax: number, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): number; + /** + * @inheritDoc + * @private + */ + protected _onClear(): void; + /** + * @inheritDoc + */ + containsPoint(pX: number, pY: number): boolean; + /** + * @inheritDoc + */ + intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): number; + } + /** + * - The ellipse bounding box data. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 椭圆边界框数据。 + * @version DragonBones 5.1 + * @language zh_CN + */ + class EllipseBoundingBoxData extends BoundingBoxData { + static toString(): string; + /** + * @private + */ + static ellipseIntersectsSegment(xA: number, yA: number, xB: number, yB: number, xC: number, yC: number, widthH: number, heightH: number, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): number; + /** + * @inheritDoc + * @private + */ + protected _onClear(): void; + /** + * @inheritDoc + */ + containsPoint(pX: number, pY: number): boolean; + /** + * @inheritDoc + */ + intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): number; + } + /** + * - The polygon bounding box data. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 多边形边界框数据。 + * @version DragonBones 5.1 + * @language zh_CN + */ + class PolygonBoundingBoxData extends BoundingBoxData { + static toString(): string; + /** + * @private + */ + static polygonIntersectsSegment(xA: number, yA: number, xB: number, yB: number, vertices: Array, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): number; + /** + * @private + */ + x: number; + /** + * @private + */ + y: number; + /** + * - The polygon vertices. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 多边形顶点。 + * @version DragonBones 5.1 + * @language zh_CN + */ + readonly vertices: Array; + /** + * @private + */ + weight: WeightData | null; + /** + * @inheritDoc + * @private + */ + protected _onClear(): void; + /** + * @inheritDoc + */ + containsPoint(pX: number, pY: number): boolean; + /** + * @inheritDoc + */ + intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): number; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The animation data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class AnimationData extends BaseObject { + static toString(): string; + /** + * - FrameIntArray. + * @internal + * @private + */ + frameIntOffset: number; + /** + * - FrameFloatArray. + * @internal + * @private + */ + frameFloatOffset: number; + /** + * - FrameArray. + * @internal + * @private + */ + frameOffset: number; + /** + * - The frame count of the animation. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画的帧数。 + * @version DragonBones 3.0 + * @language zh_CN + */ + frameCount: number; + /** + * - The play times of the animation. [0: Loop play, [1~N]: Play N times] + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画的播放次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次] + * @version DragonBones 3.0 + * @language zh_CN + */ + playTimes: number; + /** + * - The duration of the animation. (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画的持续时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + duration: number; + /** + * @private + */ + scale: number; + /** + * - The fade in time of the animation. (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画的淡入时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + fadeInTime: number; + /** + * @private + */ + cacheFrameRate: number; + /** + * - The animation name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + readonly cachedFrames: Array; + /** + * @private + */ + readonly boneTimelines: Map>; + /** + * @private + */ + readonly surfaceTimelines: Map>; + /** + * @private + */ + readonly slotTimelines: Map>; + /** + * @private + */ + readonly constraintTimelines: Map>; + /** + * @private + */ + readonly animationTimelines: Map>; + /** + * @private + */ + readonly boneCachedFrameIndices: Map>; + /** + * @private + */ + readonly slotCachedFrameIndices: Map>; + /** + * @private + */ + actionTimeline: TimelineData | null; + /** + * @private + */ + zOrderTimeline: TimelineData | null; + /** + * @private + */ + parent: ArmatureData; + /** + * @inheritDoc + */ + protected _onClear(): void; + /** + * @internal + * @private + */ + cacheFrames(frameRate: number): void; + /** + * @private + */ + addBoneTimeline(bone: BoneData, timeline: TimelineData): void; + /** + * @private + */ + addSurfaceTimeline(surface: SurfaceData, timeline: TimelineData): void; + /** + * @private + */ + addSlotTimeline(slot: SlotData, timeline: TimelineData): void; + /** + * @private + */ + addConstraintTimeline(constraint: ConstraintData, timeline: TimelineData): void; + /** + * @private + */ + addAnimationTimeline(name: string, timeline: TimelineData): void; + /** + * @private + */ + getBoneTimelines(name: string): Array | null; + /** + * @private + */ + getSurfaceTimelines(name: string): Array | null; + /** + * @private + */ + getSlotTimelines(name: string): Array | null; + /** + * @private + */ + getConstraintTimelines(name: string): Array | null; + /** + * @private + */ + getAnimationTimelines(name: string): Array | null; + /** + * @private + */ + getBoneCachedFrameIndices(name: string): Array | null; + /** + * @private + */ + getSlotCachedFrameIndices(name: string): Array | null; + } + /** + * @internal + * @private + */ + class TimelineData extends BaseObject { + static toString(): string; + type: TimelineType; + offset: number; + frameIndicesOffset: number; + protected _onClear(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The animation config is used to describe all the information needed to play an animation state. + * The API is still in the experimental phase and may encounter bugs or stability or compatibility issues when used. + * @see dragonBones.AnimationState + * @beta + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画配置用来描述播放一个动画状态所需要的全部信息。 + * 该 API 仍在实验阶段,使用时可能遭遇 bug 或稳定性或兼容性问题。 + * @see dragonBones.AnimationState + * @beta + * @version DragonBones 5.0 + * @language zh_CN + */ + class AnimationConfig extends BaseObject { + static toString(): string; + /** + * @private + */ + pauseFadeOut: boolean; + /** + * - Fade out the pattern of other animation states when the animation state is fade in. + * This property is typically used to specify the substitution of multiple animation states blend. + * @default dragonBones.AnimationFadeOutMode.All + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 淡入动画状态时淡出其他动画状态的模式。 + * 该属性通常用来指定多个动画状态混合时的相互替换关系。 + * @default dragonBones.AnimationFadeOutMode.All + * @version DragonBones 5.0 + * @language zh_CN + */ + fadeOutMode: AnimationFadeOutMode; + /** + * @private + */ + fadeOutTweenType: TweenType; + /** + * @private + */ + fadeOutTime: number; + /** + * @private + */ + pauseFadeIn: boolean; + /** + * @private + */ + actionEnabled: boolean; + /** + * @private + */ + additiveBlending: boolean; + /** + * - Whether the animation state has control over the display property of the slots. + * Sometimes blend a animation state does not want it to control the display properties of the slots, + * especially if other animation state are controlling the display properties of the slots. + * @default true + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画状态是否对插槽的显示对象属性有控制权。 + * 有时混合一个动画状态并不希望其控制插槽的显示对象属性, + * 尤其是其他动画状态正在控制这些插槽的显示对象属性时。 + * @default true + * @version DragonBones 5.0 + * @language zh_CN + */ + displayControl: boolean; + /** + * - Whether to reset the objects without animation to the armature pose when the animation state is start to play. + * This property should usually be set to false when blend multiple animation states. + * @default true + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 开始播放动画状态时是否将没有动画的对象重置为骨架初始值。 + * 通常在混合多个动画状态时应该将该属性设置为 false。 + * @default true + * @version DragonBones 5.1 + * @language zh_CN + */ + resetToPose: boolean; + /** + * @private + */ + fadeInTweenType: TweenType; + /** + * - The play times. [0: Loop play, [1~N]: Play N times] + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 播放次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次] + * @version DragonBones 3.0 + * @language zh_CN + */ + playTimes: number; + /** + * - The blend layer. + * High layer animation state will get the blend weight first. + * When the blend weight is assigned more than 1, the remaining animation states will no longer get the weight assigned. + * @readonly + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 混合图层。 + * 图层高的动画状态会优先获取混合权重。 + * 当混合权重分配超过 1 时,剩余的动画状态将不再获得权重分配。 + * @readonly + * @version DragonBones 5.0 + * @language zh_CN + */ + layer: number; + /** + * - The start time of play. (In seconds) + * @default 0.0 + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 播放的开始时间。 (以秒为单位) + * @default 0.0 + * @version DragonBones 5.0 + * @language zh_CN + */ + position: number; + /** + * - The duration of play. + * [-1: Use the default value of the animation data, 0: Stop play, (0~N]: The duration] (In seconds) + * @default -1.0 + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 播放的持续时间。 + * [-1: 使用动画数据默认值, 0: 动画停止, (0~N]: 持续时间] (以秒为单位) + * @default -1.0 + * @version DragonBones 5.0 + * @language zh_CN + */ + duration: number; + /** + * - The play speed. + * The value is an overlay relationship with {@link dragonBones.Animation#timeScale}. + * [(-N~0): Reverse play, 0: Stop play, (0~1): Slow play, 1: Normal play, (1~N): Fast play] + * @default 1.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 播放速度。 + * 该值与 {@link dragonBones.Animation#timeScale} 是叠加关系。 + * [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + timeScale: number; + /** + * - The blend weight. + * @default 1.0 + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 混合权重。 + * @default 1.0 + * @version DragonBones 5.0 + * @language zh_CN + */ + weight: number; + /** + * - The fade in time. + * [-1: Use the default value of the animation data, [0~N]: The fade in time] (In seconds) + * @default -1.0 + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 淡入时间。 + * [-1: 使用动画数据默认值, [0~N]: 淡入时间] (以秒为单位) + * @default -1.0 + * @version DragonBones 5.0 + * @language zh_CN + */ + fadeInTime: number; + /** + * - The auto fade out time when the animation state play completed. + * [-1: Do not fade out automatically, [0~N]: The fade out time] (In seconds) + * @default -1.0 + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画状态播放完成后的自动淡出时间。 + * [-1: 不自动淡出, [0~N]: 淡出时间] (以秒为单位) + * @default -1.0 + * @version DragonBones 5.0 + * @language zh_CN + */ + autoFadeOutTime: number; + /** + * - The name of the animation state. (Can be different from the name of the animation data) + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画状态名称。 (可以不同于动画数据) + * @version DragonBones 5.0 + * @language zh_CN + */ + name: string; + /** + * - The animation data name. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画数据名称。 + * @version DragonBones 5.0 + * @language zh_CN + */ + animation: string; + /** + * - The blend group name of the animation state. + * This property is typically used to specify the substitution of multiple animation states blend. + * @readonly + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 混合组名称。 + * 该属性通常用来指定多个动画状态混合时的相互替换关系。 + * @readonly + * @version DragonBones 5.0 + * @language zh_CN + */ + group: string; + /** + * @private + */ + readonly boneMask: Array; + /** + * @private + */ + protected _onClear(): void; + /** + * @private + */ + clear(): void; + /** + * @private + */ + copyFrom(value: AnimationConfig): void; + /** + * @private + */ + containsBoneMask(name: string): boolean; + /** + * @private + */ + addBoneMask(armature: Armature, name: string, recursive?: boolean): void; + /** + * @private + */ + removeBoneMask(armature: Armature, name: string, recursive?: boolean): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The texture atlas data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 贴图集数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + abstract class TextureAtlasData extends BaseObject { + /** + * @private + */ + autoSearch: boolean; + /** + * @private + */ + width: number; + /** + * @private + */ + height: number; + /** + * @private + */ + scale: number; + /** + * - The texture atlas name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 贴图集名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * - The image path of the texture atlas. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 贴图集图片路径。 + * @version DragonBones 3.0 + * @language zh_CN + */ + imagePath: string; + /** + * @private + */ + readonly textures: Map; + /** + * @inheritDoc + */ + protected _onClear(): void; + /** + * @private + */ + copyFrom(value: TextureAtlasData): void; + /** + * @internal + * @private + */ + abstract createTexture(): TextureData; + /** + * @internal + * @private + */ + addTexture(value: TextureData): void; + /** + * @private + */ + getTexture(name: string): TextureData | null; + } + /** + * @internal + * @private + */ + abstract class TextureData extends BaseObject { + static createRectangle(): Rectangle; + rotated: boolean; + name: string; + readonly region: Rectangle; + parent: TextureAtlasData; + frame: Rectangle | null; + protected _onClear(): void; + copyFrom(value: TextureData): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The armature proxy interface, the docking engine needs to implement it concretely. + * @see dragonBones.Armature + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 骨架代理接口,对接的引擎需要对其进行具体实现。 + * @see dragonBones.Armature + * @version DragonBones 5.0 + * @language zh_CN + */ + interface IArmatureProxy extends IEventDispatcher { + /** + * @internal + * @private + */ + dbInit(armature: Armature): void; + /** + * @internal + * @private + */ + dbClear(): void; + /** + * @internal + * @private + */ + dbUpdate(): void; + /** + * - Dispose the instance and the Armature instance. (The Armature instance will return to the object pool) + * @example + *
+         *     removeChild(armatureDisplay);
+         *     armatureDisplay.dispose();
+         * 
+ * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 释放该实例和骨架。 (骨架会回收到对象池) + * @example + *
+         *     removeChild(armatureDisplay);
+         *     armatureDisplay.dispose();
+         * 
+ * @version DragonBones 4.5 + * @language zh_CN + */ + dispose(disposeProxy: boolean): void; + /** + * - The armature. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 骨架。 + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly armature: Armature; + /** + * - The animation player. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画播放器。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly animation: Animation; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - Armature is the core of the skeleton animation system. + * @see dragonBones.ArmatureData + * @see dragonBones.Bone + * @see dragonBones.Slot + * @see dragonBones.Animation + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨架是骨骼动画系统的核心。 + * @see dragonBones.ArmatureData + * @see dragonBones.Bone + * @see dragonBones.Slot + * @see dragonBones.Animation + * @version DragonBones 3.0 + * @language zh_CN + */ + class Armature extends BaseObject implements IAnimatable { + static toString(): string; + private static _onSortSlots(a, b); + /** + * - Whether to inherit the animation control of the parent armature. + * True to try to have the child armature play an animation with the same name when the parent armature play the animation. + * @default true + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 是否继承父骨架的动画控制。 + * 如果该值为 true,当父骨架播放动画时,会尝试让子骨架播放同名动画。 + * @default true + * @version DragonBones 4.5 + * @language zh_CN + */ + inheritAnimation: boolean; + /** + * @private + */ + userData: any; + private _lockUpdate; + private _bonesDirty; + private _slotsDirty; + private _zOrderDirty; + private _flipX; + private _flipY; + /** + * @internal + * @private + */ + _cacheFrameIndex: number; + private readonly _bones; + private readonly _slots; + /** + * @internal + * @private + */ + readonly _glueSlots: Array; + /** + * @internal + * @private + */ + readonly _constraints: Array; + private readonly _actions; + /** + * @internal + * @private + */ + _armatureData: ArmatureData; + private _animation; + private _proxy; + private _display; + /** + * @internal + * @private + */ + _replaceTextureAtlasData: TextureAtlasData | null; + private _replacedTexture; + /** + * @internal + * @private + */ + _dragonBones: DragonBones; + private _clock; + /** + * @internal + * @private + */ + _parent: Slot | null; + /** + * @private + */ + protected _onClear(): void; + private _sortBones(); + private _sortSlots(); + /** + * @internal + * @private + */ + _sortZOrder(slotIndices: Array | Int16Array | null, offset: number): void; + /** + * @internal + * @private + */ + _addBoneToBoneList(value: Bone): void; + /** + * @internal + * @private + */ + _removeBoneFromBoneList(value: Bone): void; + /** + * @internal + * @private + */ + _addSlotToSlotList(value: Slot): void; + /** + * @internal + * @private + */ + _removeSlotFromSlotList(value: Slot): void; + /** + * @internal + * @private + */ + _bufferAction(action: ActionData, append: boolean): void; + /** + * - Dispose the armature. (Return to the object pool) + * @example + *
+         *     removeChild(armature.display);
+         *     armature.dispose();
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 释放骨架。 (回收到对象池) + * @example + *
+         *     removeChild(armature.display);
+         *     armature.dispose();
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + dispose(): void; + /** + * @internal + * @private + */ + init(armatureData: ArmatureData, proxy: IArmatureProxy, display: any, dragonBones: DragonBones): void; + /** + * @inheritDoc + */ + advanceTime(passedTime: number): void; + /** + * - Forces a specific bone or its owning slot to update the transform or display property in the next frame. + * @param boneName - The bone name. (If not set, all bones will be update) + * @param updateSlot - Whether to update the bone's slots. (Default: false) + * @see dragonBones.Bone#invalidUpdate() + * @see dragonBones.Slot#invalidUpdate() + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 强制特定骨骼或其拥有的插槽在下一帧更新变换或显示属性。 + * @param boneName - 骨骼名称。 (如果未设置,将更新所有骨骼) + * @param updateSlot - 是否更新骨骼的插槽。 (默认: false) + * @see dragonBones.Bone#invalidUpdate() + * @see dragonBones.Slot#invalidUpdate() + * @version DragonBones 3.0 + * @language zh_CN + */ + invalidUpdate(boneName?: string | null, updateSlot?: boolean): void; + /** + * - Check whether a specific point is inside a custom bounding box in a slot. + * The coordinate system of the point is the inner coordinate system of the armature. + * Custom bounding boxes need to be customized in Dragonbones Pro. + * @param x - The horizontal coordinate of the point. + * @param y - The vertical coordinate of the point. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 检查特定点是否在某个插槽的自定义边界框内。 + * 点的坐标系为骨架内坐标系。 + * 自定义边界框需要在 DragonBones Pro 中自定义。 + * @param x - 点的水平坐标。 + * @param y - 点的垂直坐标。 + * @version DragonBones 5.0 + * @language zh_CN + */ + containsPoint(x: number, y: number): Slot | null; + /** + * - Check whether a specific segment intersects a custom bounding box for a slot in the armature. + * The coordinate system of the segment and intersection is the inner coordinate system of the armature. + * Custom bounding boxes need to be customized in Dragonbones Pro. + * @param xA - The horizontal coordinate of the beginning of the segment. + * @param yA - The vertical coordinate of the beginning of the segment. + * @param xB - The horizontal coordinate of the end point of the segment. + * @param yB - The vertical coordinate of the end point of the segment. + * @param intersectionPointA - The first intersection at which a line segment intersects the bounding box from the beginning to the end. (If not set, the intersection point will not calculated) + * @param intersectionPointB - The first intersection at which a line segment intersects the bounding box from the end to the beginning. (If not set, the intersection point will not calculated) + * @param normalRadians - The normal radians of the tangent of the intersection boundary box. [x: Normal radian of the first intersection tangent, y: Normal radian of the second intersection tangent] (If not set, the normal will not calculated) + * @returns The slot of the first custom bounding box where the segment intersects from the start point to the end point. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 检查特定线段是否与骨架的某个插槽的自定义边界框相交。 + * 线段和交点的坐标系均为骨架内坐标系。 + * 自定义边界框需要在 DragonBones Pro 中自定义。 + * @param xA - 线段起点的水平坐标。 + * @param yA - 线段起点的垂直坐标。 + * @param xB - 线段终点的水平坐标。 + * @param yB - 线段终点的垂直坐标。 + * @param intersectionPointA - 线段从起点到终点与边界框相交的第一个交点。 (如果未设置,则不计算交点) + * @param intersectionPointB - 线段从终点到起点与边界框相交的第一个交点。 (如果未设置,则不计算交点) + * @param normalRadians - 交点边界框切线的法线弧度。 [x: 第一个交点切线的法线弧度, y: 第二个交点切线的法线弧度] (如果未设置,则不计算法线) + * @returns 线段从起点到终点相交的第一个自定义边界框的插槽。 + * @version DragonBones 5.0 + * @language zh_CN + */ + intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): Slot | null; + /** + * - Get a specific bone. + * @param name - The bone name. + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的骨骼。 + * @param name - 骨骼名称。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + getBone(name: string): Bone | null; + /** + * - Get a specific bone by the display. + * @param display - The display object. + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 通过显示对象获取特定的骨骼。 + * @param display - 显示对象。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + getBoneByDisplay(display: any): Bone | null; + /** + * - Get a specific slot. + * @param name - The slot name. + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的插槽。 + * @param name - 插槽名称。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + getSlot(name: string): Slot | null; + /** + * - Get a specific slot by the display. + * @param display - The display object. + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 通过显示对象获取特定的插槽。 + * @param display - 显示对象。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + getSlotByDisplay(display: any): Slot | null; + /** + * @deprecated + */ + addBone(value: Bone, parentName: string): void; + /** + * @deprecated + */ + addSlot(value: Slot, parentName: string): void; + /** + * @private + */ + addConstraint(value: Constraint): void; + /** + * @deprecated + */ + removeBone(value: Bone): void; + /** + * @deprecated + */ + removeSlot(value: Slot): void; + /** + * - Get all bones. + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取所有的骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + getBones(): Array; + /** + * - Get all slots. + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取所有的插槽。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + getSlots(): Array; + /** + * - Whether to flip the armature horizontally. + * @version DragonBones 5.5 + * @language en_US + */ + /** + * - 是否将骨架水平翻转。 + * @version DragonBones 5.5 + * @language zh_CN + */ + flipX: boolean; + /** + * - Whether to flip the armature vertically. + * @version DragonBones 5.5 + * @language en_US + */ + /** + * - 是否将骨架垂直翻转。 + * @version DragonBones 5.5 + * @language zh_CN + */ + flipY: boolean; + /** + * - The animation cache frame rate, which turns on the animation cache when the set value is greater than 0. + * There is a certain amount of memory overhead to improve performance by caching animation data in memory. + * The frame rate should not be set too high, usually with the frame rate of the animation is similar and lower than the program running frame rate. + * When the animation cache is turned on, some features will fail, such as the offset property of bone. + * @example + *
+         *     armature.cacheFrameRate = 24;
+         * 
+ * @see dragonBones.DragonBonesData#frameRate + * @see dragonBones.ArmatureData#frameRate + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画缓存帧率,当设置的值大于 0 的时,将会开启动画缓存。 + * 通过将动画数据缓存在内存中来提高运行性能,会有一定的内存开销。 + * 帧率不宜设置的过高,通常跟动画的帧率相当且低于程序运行的帧率。 + * 开启动画缓存后,某些功能将会失效,比如骨骼的 offset 属性等。 + * @example + *
+         *     armature.cacheFrameRate = 24;
+         * 
+ * @see dragonBones.DragonBonesData#frameRate + * @see dragonBones.ArmatureData#frameRate + * @version DragonBones 4.5 + * @language zh_CN + */ + cacheFrameRate: number; + /** + * - The armature name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨架名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly name: string; + /** + * - The armature data. + * @see dragonBones.ArmatureData + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 骨架数据。 + * @see dragonBones.ArmatureData + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly armatureData: ArmatureData; + /** + * - The animation player. + * @see dragonBones.Animation + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画播放器。 + * @see dragonBones.Animation + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly animation: Animation; + /** + * @pivate + */ + readonly proxy: IArmatureProxy; + /** + * - The EventDispatcher instance of the armature. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 该骨架的 EventDispatcher 实例。 + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly eventDispatcher: IEventDispatcher; + /** + * - The display container. + * The display of the slot is displayed as the parent. + * Depending on the rendering engine, the type will be different, usually the DisplayObjectContainer type. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 显示容器实例。 + * 插槽的显示对象都会以此显示容器为父级。 + * 根据渲染引擎的不同,类型会不同,通常是 DisplayObjectContainer 类型。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly display: any; + /** + * @private + */ + replacedTexture: any; + /** + * @inheritDoc + */ + clock: WorldClock | null; + /** + * - Get the parent slot which the armature belongs to. + * @see dragonBones.Slot + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 该骨架所属的父插槽。 + * @see dragonBones.Slot + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly parent: Slot | null; + /** + * @deprecated + * @private + */ + replaceTexture(texture: any): void; + /** + * - Deprecated, please refer to {@link #eventDispatcher}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #eventDispatcher}。 + * @deprecated + * @language zh_CN + */ + hasEventListener(type: EventStringType): boolean; + /** + * - Deprecated, please refer to {@link #eventDispatcher}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #eventDispatcher}。 + * @deprecated + * @language zh_CN + */ + addEventListener(type: EventStringType, listener: Function, target: any): void; + /** + * - Deprecated, please refer to {@link #eventDispatcher}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #eventDispatcher}。 + * @deprecated + * @language zh_CN + */ + removeEventListener(type: EventStringType, listener: Function, target: any): void; + /** + * - Deprecated, please refer to {@link #cacheFrameRate}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #cacheFrameRate}。 + * @deprecated + * @language zh_CN + */ + enableAnimationCache(frameRate: number): void; + /** + * - Deprecated, please refer to {@link #display}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #display}。 + * @deprecated + * @language zh_CN + */ + getDisplay(): any; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The base class of the transform object. + * @see dragonBones.Transform + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 变换对象的基类。 + * @see dragonBones.Transform + * @version DragonBones 4.5 + * @language zh_CN + */ + abstract class TransformObject extends BaseObject { + /** + * @private + */ + protected static readonly _helpMatrix: Matrix; + /** + * @private + */ + protected static readonly _helpTransform: Transform; + /** + * @private + */ + protected static readonly _helpPoint: Point; + /** + * - A matrix relative to the armature coordinate system. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 相对于骨架坐标系的矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly globalTransformMatrix: Matrix; + /** + * - A transform relative to the armature coordinate system. + * @see #updateGlobalTransform() + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 相对于骨架坐标系的变换。 + * @see #updateGlobalTransform() + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly global: Transform; + /** + * - The offset transform relative to the armature or the parent bone coordinate system. + * @see #dragonBones.Bone#invalidUpdate() + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 相对于骨架或父骨骼坐标系的偏移变换。 + * @see #dragonBones.Bone#invalidUpdate() + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly offset: Transform; + /** + * @private + */ + origin: Transform | null; + /** + * @private + */ + userData: any; + /** + * @private + */ + protected _globalDirty: boolean; + /** + * @internal + * @private + */ + _armature: Armature; + /** + * @internal + * @private + */ + _parent: Bone; + /** + * @private + */ + protected _onClear(): void; + /** + * @internal + * @private + */ + _setArmature(value: Armature | null): void; + /** + * @internal + * @private + */ + _setParent(value: Bone | null): void; + /** + * - For performance considerations, rotation or scale in the {@link #global} attribute of the bone or slot is not always properly accessible, + * some engines do not rely on these attributes to update rendering, such as Egret. + * The use of this method ensures that the access to the {@link #global} property is correctly rotation or scale. + * @example + *
+         *     bone.updateGlobalTransform();
+         *     let rotation = bone.global.rotation;
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 出于性能的考虑,骨骼或插槽的 {@link #global} 属性中的旋转或缩放并不总是正确可访问的,有些引擎并不依赖这些属性更新渲染,比如 Egret。 + * 使用此方法可以保证访问到 {@link #global} 属性中正确的旋转或缩放。 + * @example + *
+         *     bone.updateGlobalTransform();
+         *     let rotation = bone.global.rotation;
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + updateGlobalTransform(): void; + /** + * - The armature to which it belongs. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 所属的骨架。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly armature: Armature; + /** + * - The parent bone to which it belongs. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 所属的父骨骼。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly parent: Bone; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - Bone is one of the most important logical units in the armature animation system, + * and is responsible for the realization of translate, rotation, scaling in the animations. + * A armature can contain multiple bones. + * @see dragonBones.BoneData + * @see dragonBones.Armature + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨骼在骨骼动画体系中是最重要的逻辑单元之一,负责动画中的平移、旋转、缩放的实现。 + * 一个骨架中可以包含多个骨骼。 + * @see dragonBones.BoneData + * @see dragonBones.Armature + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + class Bone extends TransformObject { + static toString(): string; + /** + * - The offset mode. + * @see #offset + * @version DragonBones 5.5 + * @language en_US + */ + /** + * - 偏移模式。 + * @see #offset + * @version DragonBones 5.5 + * @language zh_CN + */ + offsetMode: OffsetMode; + /** + * @internal + * @private + */ + readonly animationPose: Transform; + /** + * @internal + * @private + */ + _transformDirty: boolean; + /** + * @internal + * @private + */ + _childrenTransformDirty: boolean; + protected _localDirty: boolean; + /** + * @internal + * @private + */ + _hasConstraint: boolean; + private _visible; + protected _cachedFrameIndex: number; + /** + * @internal + * @private + */ + readonly _blendState: BlendState; + /** + * @internal + * @private + */ + _boneData: BoneData; + /** + * @internal + * @private + */ + _cachedFrameIndices: Array | null; + /** + * @inheritDoc + */ + protected _onClear(): void; + /** + * @private + */ + protected _updateGlobalTransformMatrix(isCache: boolean): void; + /** + * @inheritDoc + */ + _setArmature(value: Armature | null): void; + /** + * @internal + * @private + */ + init(boneData: BoneData): void; + /** + * @internal + * @private + */ + update(cacheFrameIndex: number): void; + /** + * @internal + * @private + */ + updateByConstraint(): void; + /** + * - Forces the bone to update the transform in the next frame. + * When the bone is not animated or its animation state is finished, the bone will not continue to update, + * and when the skeleton must be updated for some reason, the method needs to be called explicitly. + * @example + *
+         *     let bone = armature.getBone("arm");
+         *     bone.offset.scaleX = 2.0;
+         *     bone.invalidUpdate();
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 强制骨骼在下一帧更新变换。 + * 当该骨骼没有动画状态或其动画状态播放完成时,骨骼将不在继续更新,而此时由于某些原因必须更新骨骼时,则需要显式调用该方法。 + * @example + *
+         *     let bone = armature.getBone("arm");
+         *     bone.offset.scaleX = 2.0;
+         *     bone.invalidUpdate();
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + invalidUpdate(): void; + /** + * - Check whether the bone contains a specific bone or slot. + * @see dragonBones.Bone + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 检查该骨骼是否包含特定的骨骼或插槽。 + * @see dragonBones.Bone + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + contains(value: TransformObject): boolean; + /** + * - The bone data. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 骨骼数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly boneData: BoneData; + /** + * - The visible of all slots in the bone. + * @default true + * @see dragonBones.Slot#visible + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 此骨骼所有插槽的可见。 + * @default true + * @see dragonBones.Slot#visible + * @version DragonBones 3.0 + * @language zh_CN + */ + visible: boolean; + /** + * - The bone name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨骼名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly name: string; + /** + * - Deprecated, please refer to {@link dragonBones.Armature#getBones()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link dragonBones.Armature#getBones()}。 + * @deprecated + * @language zh_CN + */ + getBones(): Array; + /** + * - Deprecated, please refer to {@link dragonBones.Armature#getSlots()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link dragonBones.Armature#getSlots()}。 + * @deprecated + * @language zh_CN + */ + getSlots(): Array; + /** + * - Deprecated, please refer to {@link dragonBones.Armature#getSlot()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link dragonBones.Armature#getSlot()}。 + * @deprecated + * @language zh_CN + */ + readonly slot: Slot | null; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + class Surface extends Bone { + static toString(): string; + private _dX; + private _dY; + private _k; + private _kX; + private _kY; + /** + * For debug draw. + * @internal + * @private + */ + readonly _vertices: Array; + /** + * For timeline state. + * @internal + * @private + */ + readonly _deformVertices: Array; + /** + * x1, y1, x2, y2, x3, y3, x4, y4, d1X, d1Y, d2X, d2Y + */ + private readonly _hullCache; + /** + * Inside [flag, a, b, c, d, tx, ty], Outside [flag, a, b, c, d, tx, ty] + */ + private readonly _matrixCahce; + /** + * @inheritDoc + */ + protected _onClear(): void; + private _getAffineTransform(x, y, lX, lY, aX, aY, bX, bY, cX, cY, transform, matrix, isDown); + private _updateVertices(); + /** + * @private + */ + protected _updateGlobalTransformMatrix(isCache: boolean): void; + _getGlobalTransformMatrix(x: number, y: number): Matrix; + init(surfaceData: SurfaceData): void; + /** + * @internal + * @private + */ + update(cacheFrameIndex: number): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The slot attached to the armature, controls the display status and properties of the display object. + * A bone can contain multiple slots. + * A slot can contain multiple display objects, displaying only one of the display objects at a time, + * but you can toggle the display object into frame animation while the animation is playing. + * The display object can be a normal texture, or it can be a display of a child armature, a grid display object, + * and a custom other display object. + * @see dragonBones.Armature + * @see dragonBones.Bone + * @see dragonBones.SlotData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 插槽附着在骨骼上,控制显示对象的显示状态和属性。 + * 一个骨骼上可以包含多个插槽。 + * 一个插槽中可以包含多个显示对象,同一时间只能显示其中的一个显示对象,但可以在动画播放的过程中切换显示对象实现帧动画。 + * 显示对象可以是普通的图片纹理,也可以是子骨架的显示容器,网格显示对象,还可以是自定义的其他显示对象。 + * @see dragonBones.Armature + * @see dragonBones.Bone + * @see dragonBones.SlotData + * @version DragonBones 3.0 + * @language zh_CN + */ + abstract class Slot extends TransformObject { + /** + * - Displays the animated state or mixed group name controlled by the object, set to null to be controlled by all animation states. + * @default null + * @see dragonBones.AnimationState#displayControl + * @see dragonBones.AnimationState#name + * @see dragonBones.AnimationState#group + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 显示对象受到控制的动画状态或混合组名称,设置为 null 则表示受所有的动画状态控制。 + * @default null + * @see dragonBones.AnimationState#displayControl + * @see dragonBones.AnimationState#name + * @see dragonBones.AnimationState#group + * @version DragonBones 4.5 + * @language zh_CN + */ + displayController: string | null; + /** + * @private + */ + protected _displayDirty: boolean; + /** + * @private + */ + protected _zOrderDirty: boolean; + /** + * @private + */ + protected _visibleDirty: boolean; + /** + * @private + */ + protected _blendModeDirty: boolean; + /** + * @internal + * @private + */ + _colorDirty: boolean; + /** + * @internal + * @private + */ + _meshDirty: boolean; + /** + * @private + */ + protected _transformDirty: boolean; + /** + * @private + */ + protected _visible: boolean; + /** + * @private + */ + protected _blendMode: BlendMode; + /** + * @private + */ + protected _displayIndex: number; + /** + * @private + */ + protected _animationDisplayIndex: number; + /** + * @internal + * @private + */ + _zOrder: number; + /** + * @private + */ + protected _cachedFrameIndex: number; + /** + * @internal + * @private + */ + _pivotX: number; + /** + * @internal + * @private + */ + _pivotY: number; + /** + * @private + */ + protected readonly _localMatrix: Matrix; + /** + * @internal + * @private + */ + readonly _colorTransform: ColorTransform; + /** + * @internal + * @private + */ + readonly _deformVertices: Array; + /** + * @private + */ + readonly _displayDatas: Array; + /** + * @private + */ + protected readonly _displayList: Array; + /** + * @private + */ + protected readonly _meshBones: Array; + /** + * @private + */ + protected readonly _meshSlots: Array; + /** + * @internal + * @private + */ + _slotData: SlotData; + /** + * @private + */ + protected _rawDisplayDatas: Array | null; + /** + * @private + */ + protected _displayData: DisplayData | null; + /** + * @private + */ + protected _textureData: TextureData | null; + /** + * @internal + * @private + */ + _meshData: MeshDisplayData | null; + /** + * @private + */ + protected _boundingBoxData: BoundingBoxData | null; + /** + * @private + */ + protected _rawDisplay: any; + /** + * @private + */ + protected _meshDisplay: any; + /** + * @private + */ + protected _display: any; + /** + * @private + */ + protected _childArmature: Armature | null; + /** + * @internal + * @private + */ + _cachedFrameIndices: Array | null; + /** + * @inheritDoc + */ + protected _onClear(): void; + /** + * @private + */ + protected abstract _initDisplay(value: any, isRetain: boolean): void; + /** + * @private + */ + protected abstract _disposeDisplay(value: any, isRelease: boolean): void; + /** + * @private + */ + protected abstract _onUpdateDisplay(): void; + /** + * @private + */ + protected abstract _addDisplay(): void; + /** + * @private + */ + protected abstract _replaceDisplay(value: any): void; + /** + * @private + */ + protected abstract _removeDisplay(): void; + /** + * @private + */ + protected abstract _updateZOrder(): void; + /** + * @private + */ + abstract _updateVisible(): void; + /** + * @private + */ + protected abstract _updateBlendMode(): void; + /** + * @private + */ + protected abstract _updateColor(): void; + /** + * @private + */ + protected abstract _updateFrame(): void; + /** + * @private + */ + protected abstract _updateMesh(): void; + /** + * @internal + * @private + */ + abstract _updateGlueMesh(): void; + /** + * @private + */ + protected abstract _updateTransform(): void; + /** + * @private + */ + protected abstract _identityTransform(): void; + /** + * @private + */ + protected _getDefaultRawDisplayData(): DisplayData | null; + /** + * @private + */ + protected _updateDisplayData(): void; + /** + * @private + */ + protected _updateDisplay(): void; + /** + * @private + */ + protected _updateGlobalTransformMatrix(isCache: boolean): void; + /** + * @private + */ + protected _isMeshBonesUpdate(): boolean; + /** + * @inheritDoc + */ + _setArmature(value: Armature | null): void; + /** + * @internal + * @private + */ + _setDisplayIndex(value: number, isAnimation?: boolean): boolean; + /** + * @internal + * @private + */ + _setZorder(value: number): boolean; + /** + * @internal + * @private + */ + _setColor(value: ColorTransform): boolean; + /** + * @internal + * @private + */ + _setDisplayList(value: Array | null): boolean; + /** + * @internal + * @private + */ + init(slotData: SlotData, displayDatas: Array | null, rawDisplay: any, meshDisplay: any): void; + /** + * @internal + * @private + */ + update(cacheFrameIndex: number): void; + /** + * @private + */ + updateTransformAndMatrix(): void; + /** + * @private + */ + replaceDisplayData(value: DisplayData | null, displayIndex?: number): void; + /** + * - Check whether a specific point is inside a custom bounding box in the slot. + * The coordinate system of the point is the inner coordinate system of the armature. + * Custom bounding boxes need to be customized in Dragonbones Pro. + * @param x - The horizontal coordinate of the point. + * @param y - The vertical coordinate of the point. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 检查特定点是否在插槽的自定义边界框内。 + * 点的坐标系为骨架内坐标系。 + * 自定义边界框需要在 DragonBones Pro 中自定义。 + * @param x - 点的水平坐标。 + * @param y - 点的垂直坐标。 + * @version DragonBones 5.0 + * @language zh_CN + */ + containsPoint(x: number, y: number): boolean; + /** + * - Check whether a specific segment intersects a custom bounding box for the slot. + * The coordinate system of the segment and intersection is the inner coordinate system of the armature. + * Custom bounding boxes need to be customized in Dragonbones Pro. + * @param xA - The horizontal coordinate of the beginning of the segment. + * @param yA - The vertical coordinate of the beginning of the segment. + * @param xB - The horizontal coordinate of the end point of the segment. + * @param yB - The vertical coordinate of the end point of the segment. + * @param intersectionPointA - The first intersection at which a line segment intersects the bounding box from the beginning to the end. (If not set, the intersection point will not calculated) + * @param intersectionPointB - The first intersection at which a line segment intersects the bounding box from the end to the beginning. (If not set, the intersection point will not calculated) + * @param normalRadians - The normal radians of the tangent of the intersection boundary box. [x: Normal radian of the first intersection tangent, y: Normal radian of the second intersection tangent] (If not set, the normal will not calculated) + * @returns Intersection situation. [1: Disjoint and segments within the bounding box, 0: Disjoint, 1: Intersecting and having a nodal point and ending in the bounding box, 2: Intersecting and having a nodal point and starting at the bounding box, 3: Intersecting and having two intersections, N: Intersecting and having N intersections] + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 检查特定线段是否与插槽的自定义边界框相交。 + * 线段和交点的坐标系均为骨架内坐标系。 + * 自定义边界框需要在 DragonBones Pro 中自定义。 + * @param xA - 线段起点的水平坐标。 + * @param yA - 线段起点的垂直坐标。 + * @param xB - 线段终点的水平坐标。 + * @param yB - 线段终点的垂直坐标。 + * @param intersectionPointA - 线段从起点到终点与边界框相交的第一个交点。 (如果未设置,则不计算交点) + * @param intersectionPointB - 线段从终点到起点与边界框相交的第一个交点。 (如果未设置,则不计算交点) + * @param normalRadians - 交点边界框切线的法线弧度。 [x: 第一个交点切线的法线弧度, y: 第二个交点切线的法线弧度] (如果未设置,则不计算法线) + * @returns 相交的情况。 [-1: 不相交且线段在包围盒内, 0: 不相交, 1: 相交且有一个交点且终点在包围盒内, 2: 相交且有一个交点且起点在包围盒内, 3: 相交且有两个交点, N: 相交且有 N 个交点] + * @version DragonBones 5.0 + * @language zh_CN + */ + intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): number; + /** + * - Forces the slot to update the state of the display object in the next frame. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 强制插槽在下一帧更新显示对象的状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + invalidUpdate(): void; + /** + * - The visible of slot's display object. + * @default true + * @version DragonBones 5.6 + * @language en_US + */ + /** + * - 插槽的显示对象的可见。 + * @default true + * @version DragonBones 5.6 + * @language zh_CN + */ + visible: boolean; + /** + * - The index of the display object displayed in the display list. + * @example + *
+         *     let slot = armature.getSlot("weapon");
+         *     slot.displayIndex = 3;
+         *     slot.displayController = "none";
+         * 
+ * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 此时显示的显示对象在显示列表中的索引。 + * @example + *
+         *     let slot = armature.getSlot("weapon");
+         *     slot.displayIndex = 3;
+         *     slot.displayController = "none";
+         * 
+ * @version DragonBones 4.5 + * @language zh_CN + */ + displayIndex: number; + /** + * - The slot name. + * @see dragonBones.SlotData#name + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 插槽名称。 + * @see dragonBones.SlotData#name + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly name: string; + /** + * - Contains a display list of display objects or child armatures. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 包含显示对象或子骨架的显示列表。 + * @version DragonBones 3.0 + * @language zh_CN + */ + displayList: Array; + /** + * - The slot data. + * @see dragonBones.SlotData + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 插槽数据。 + * @see dragonBones.SlotData + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly slotData: SlotData; + /** + * @private + */ + rawDisplayDatas: Array | null; + /** + * - The custom bounding box data for the slot at current time. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 插槽此时的自定义包围盒数据。 + * @version DragonBones 5.0 + * @language zh_CN + */ + readonly boundingBoxData: BoundingBoxData | null; + /** + * @private + */ + readonly rawDisplay: any; + /** + * @private + */ + readonly meshDisplay: any; + /** + * - The display object that the slot displays at this time. + * @example + *
+         *     let slot = armature.getSlot("text");
+         *     slot.display = new yourEngine.TextField();
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 插槽此时显示的显示对象。 + * @example + *
+         *     let slot = armature.getSlot("text");
+         *     slot.display = new yourEngine.TextField();
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + display: any; + /** + * - The child armature that the slot displayed at current time. + * @example + *
+         *     let slot = armature.getSlot("weapon");
+         *     slot.childArmature = factory.buildArmature("weapon_blabla", "weapon_blabla_project");
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 插槽此时显示的子骨架。 + * @example + *
+         *     let slot = armature.getSlot("weapon");
+         *     slot.childArmature = factory.buildArmature("weapon_blabla", "weapon_blabla_project");
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + childArmature: Armature | null; + /** + * - Deprecated, please refer to {@link #display}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #display}。 + * @deprecated + * @language zh_CN + */ + getDisplay(): any; + /** + * - Deprecated, please refer to {@link #display}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #display}。 + * @deprecated + * @language zh_CN + */ + setDisplay(value: any): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + abstract class Constraint extends BaseObject { + protected static readonly _helpMatrix: Matrix; + protected static readonly _helpTransform: Transform; + protected static readonly _helpPoint: Point; + /** + * - For timeline state. + * @internal + */ + _constraintData: ConstraintData; + protected _armature: Armature; + /** + * - For sort bones. + * @internal + */ + _target: Bone; + /** + * - For sort bones. + * @internal + */ + _root: Bone; + protected _bone: Bone | null; + protected _onClear(): void; + abstract init(constraintData: ConstraintData, armature: Armature): void; + abstract update(): void; + abstract invalidUpdate(): void; + readonly name: string; + } + /** + * @internal + * @private + */ + class IKConstraint extends Constraint { + static toString(): string; + private _scaleEnabled; + /** + * - For timeline state. + * @internal + */ + _bendPositive: boolean; + /** + * - For timeline state. + * @internal + */ + _weight: number; + protected _onClear(): void; + private _computeA(); + private _computeB(); + init(constraintData: ConstraintData, armature: Armature): void; + update(): void; + invalidUpdate(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - Play animation interface. (Both Armature and Wordclock implement the interface) + * Any instance that implements the interface can be added to the Worldclock instance and advance time by Worldclock instance uniformly. + * @see dragonBones.WorldClock + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 播放动画接口。 (Armature 和 WordClock 都实现了该接口) + * 任何实现了此接口的实例都可以添加到 WorldClock 实例中,由 WorldClock 实例统一更新时间。 + * @see dragonBones.WorldClock + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + interface IAnimatable { + /** + * - Advance time. + * @param passedTime - Passed time. (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 更新时间。 + * @param passedTime - 前进的时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + advanceTime(passedTime: number): void; + /** + * - The Wordclock instance to which the current belongs. + * @example + *
+         *     armature.clock = factory.clock; // Add armature to clock.
+         *     armature.clock = null; // Remove armature from clock.
+         * 
+ * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 当前所属的 WordClock 实例。 + * @example + *
+         *     armature.clock = factory.clock; // 将骨架添加到时钟。
+         *     armature.clock = null; // 将骨架从时钟移除。
+         * 
+ * @version DragonBones 5.0 + * @language zh_CN + */ + clock: WorldClock | null; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - Worldclock provides clock support for animations, advance time for each IAnimatable object added to the instance. + * @see dragonBones.IAnimateble + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - WorldClock 对动画提供时钟支持,为每个加入到该实例的 IAnimatable 对象更新时间。 + * @see dragonBones.IAnimateble + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + class WorldClock implements IAnimatable { + /** + * - Current time. (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 当前的时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + time: number; + /** + * - The play speed, used to control animation speed-shift play. + * [0: Stop play, (0~1): Slow play, 1: Normal play, (1~N): Fast play] + * @default 1.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 播放速度,用于控制动画变速播放。 + * [0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + timeScale: number; + private readonly _animatebles; + private _clock; + /** + * - Creating a Worldclock instance. Typically, you do not need to create Worldclock instance. + * When multiple Worldclock instances are running at different speeds, can achieving some specific animation effects, such as bullet time. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 创建一个 WorldClock 实例。通常并不需要创建 WorldClock 实例。 + * 当多个 WorldClock 实例使用不同的速度运行时,可以实现一些特殊的动画效果,比如子弹时间等。 + * @version DragonBones 3.0 + * @language zh_CN + */ + constructor(time?: number); + /** + * - Advance time for all IAnimatable instances. + * @param passedTime - Passed time. [-1: Automatically calculates the time difference between the current frame and the previous frame, [0~N): Passed time] (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 为所有的 IAnimatable 实例更新时间。 + * @param passedTime - 前进的时间。 [-1: 自动计算当前帧与上一帧的时间差, [0~N): 前进的时间] (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + advanceTime(passedTime: number): void; + /** + * - Check whether contains a specific instance of IAnimatable. + * @param value - The IAnimatable instance. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 检查是否包含特定的 IAnimatable 实例。 + * @param value - IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + contains(value: IAnimatable): boolean; + /** + * - Add IAnimatable instance. + * @param value - The IAnimatable instance. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 添加 IAnimatable 实例。 + * @param value - IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + add(value: IAnimatable): void; + /** + * - Removes a specified IAnimatable instance. + * @param value - The IAnimatable instance. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 移除特定的 IAnimatable 实例。 + * @param value - IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + remove(value: IAnimatable): void; + /** + * - Clear all IAnimatable instances. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 清除所有的 IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + clear(): void; + /** + * @inheritDoc + */ + clock: WorldClock | null; + /** + * - Deprecated, please refer to {@link dragonBones.BaseFactory#clock}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link dragonBones.BaseFactory#clock}。 + * @deprecated + * @language zh_CN + */ + static readonly clock: WorldClock; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The animation player is used to play the animation data and manage the animation states. + * @see dragonBones.AnimationData + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画播放器用来播放动画数据和管理动画状态。 + * @see dragonBones.AnimationData + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + class Animation extends BaseObject { + static toString(): string; + /** + * - The play speed of all animations. [0: Stop, (0~1): Slow, 1: Normal, (1~N): Fast] + * @default 1.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 所有动画的播放速度。 [0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + timeScale: number; + private _lockUpdate; + private _animationDirty; + private _inheritTimeScale; + private readonly _animationNames; + private readonly _animationStates; + private readonly _animations; + private _armature; + private _animationConfig; + private _lastAnimationState; + /** + * @private + */ + protected _onClear(): void; + private _fadeOut(animationConfig); + /** + * @internal + * @private + */ + init(armature: Armature): void; + /** + * @internal + * @private + */ + advanceTime(passedTime: number): void; + /** + * - Clear all animations states. + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 清除所有的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + reset(): void; + /** + * - Pause a specific animation state. + * @param animationName - The name of animation state. (If not set, it will pause all animations) + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 暂停指定动画状态的播放。 + * @param animationName - 动画状态名称。 (如果未设置,则暂停所有动画) + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + stop(animationName?: string | null): void; + /** + * - Play animation with a specific animation config. + * The API is still in the experimental phase and may encounter bugs or stability or compatibility issues when used. + * @param animationConfig - The animation config. + * @returns The playing animation state. + * @see dragonBones.AnimationConfig + * @beta + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 通过指定的动画配置来播放动画。 + * 该 API 仍在实验阶段,使用时可能遭遇 bug 或稳定性或兼容性问题。 + * @param animationConfig - 动画配置。 + * @returns 播放的动画状态。 + * @see dragonBones.AnimationConfig + * @beta + * @version DragonBones 5.0 + * @language zh_CN + */ + playConfig(animationConfig: AnimationConfig): AnimationState | null; + /** + * - Play a specific animation. + * @param animationName - The name of animation data. (If not set, The default animation will be played, or resume the animation playing from pause status, or replay the last playing animation) + * @param playTimes - Playing repeat times. [-1: Use default value of the animation data, 0: No end loop playing, [1~N]: Repeat N times] (default: -1) + * @returns The playing animation state. + * @example + *
+         *     armature.animation.play("walk");
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 播放指定动画。 + * @param animationName - 动画数据名称。 (如果未设置,则播放默认动画,或将暂停状态切换为播放状态,或重新播放之前播放的动画) + * @param playTimes - 循环播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) + * @returns 播放的动画状态。 + * @example + *
+         *     armature.animation.play("walk");
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + play(animationName?: string | null, playTimes?: number): AnimationState | null; + /** + * - Fade in a specific animation. + * @param animationName - The name of animation data. + * @param fadeInTime - The fade in time. [-1: Use the default value of animation data, [0~N]: The fade in time (In seconds)] (Default: -1) + * @param playTimes - playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) + * @param layer - The blending layer, the animation states in high level layer will get the blending weights with high priority, when the total blending weights are more than 1.0, there will be no more weights can be allocated to the other animation states. (Default: 0) + * @param group - The blending group name, it is typically used to specify the substitution of multiple animation states blending. (Default: null) + * @param fadeOutMode - The fade out mode, which is typically used to specify alternate mode of multiple animation states blending. (Default: AnimationFadeOutMode.SameLayerAndGroup) + * @returns The playing animation state. + * @example + *
+         *     armature.animation.fadeIn("walk", 0.3, 0, 0, "normalGroup").resetToPose = false;
+         *     armature.animation.fadeIn("attack", 0.3, 1, 0, "attackGroup").resetToPose = false;
+         * 
+ * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 淡入播放指定的动画。 + * @param animationName - 动画数据名称。 + * @param fadeInTime - 淡入时间。 [-1: 使用动画数据默认值, [0~N]: 淡入时间 (以秒为单位)] (默认: -1) + * @param playTimes - 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) + * @param layer - 混合图层,图层高的动画状态会优先获取混合权重,当混合权重分配总和超过 1.0 时,剩余的动画状态将不能再获得权重分配。 (默认: 0) + * @param group - 混合组名称,该属性通常用来指定多个动画状态混合时的相互替换关系。 (默认: null) + * @param fadeOutMode - 淡出模式,该属性通常用来指定多个动画状态混合时的相互替换模式。 (默认: AnimationFadeOutMode.SameLayerAndGroup) + * @returns 播放的动画状态。 + * @example + *
+         *     armature.animation.fadeIn("walk", 0.3, 0, 0, "normalGroup").resetToPose = false;
+         *     armature.animation.fadeIn("attack", 0.3, 1, 0, "attackGroup").resetToPose = false;
+         * 
+ * @version DragonBones 4.5 + * @language zh_CN + */ + fadeIn(animationName: string, fadeInTime?: number, playTimes?: number, layer?: number, group?: string | null, fadeOutMode?: AnimationFadeOutMode): AnimationState | null; + /** + * - Play a specific animation from the specific time. + * @param animationName - The name of animation data. + * @param time - The start time point of playing. (In seconds) + * @param playTimes - Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) + * @returns The played animation state. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 从指定时间开始播放指定的动画。 + * @param animationName - 动画数据名称。 + * @param time - 播放开始的时间。 (以秒为单位) + * @param playTimes - 循环播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) + * @returns 播放的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndPlayByTime(animationName: string, time?: number, playTimes?: number): AnimationState | null; + /** + * - Play a specific animation from the specific frame. + * @param animationName - The name of animation data. + * @param frame - The start frame of playing. + * @param playTimes - Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) + * @returns The played animation state. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 从指定帧开始播放指定的动画。 + * @param animationName - 动画数据名称。 + * @param frame - 播放开始的帧数。 + * @param playTimes - 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) + * @returns 播放的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndPlayByFrame(animationName: string, frame?: number, playTimes?: number): AnimationState | null; + /** + * - Play a specific animation from the specific progress. + * @param animationName - The name of animation data. + * @param progress - The start progress value of playing. + * @param playTimes - Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) + * @returns The played animation state. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 从指定进度开始播放指定的动画。 + * @param animationName - 动画数据名称。 + * @param progress - 开始播放的进度。 + * @param playTimes - 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) + * @returns 播放的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndPlayByProgress(animationName: string, progress?: number, playTimes?: number): AnimationState | null; + /** + * - Stop a specific animation at the specific time. + * @param animationName - The name of animation data. + * @param time - The stop time. (In seconds) + * @returns The played animation state. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 在指定时间停止指定动画播放 + * @param animationName - 动画数据名称。 + * @param time - 停止的时间。 (以秒为单位) + * @returns 播放的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndStopByTime(animationName: string, time?: number): AnimationState | null; + /** + * - Stop a specific animation at the specific frame. + * @param animationName - The name of animation data. + * @param frame - The stop frame. + * @returns The played animation state. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 在指定帧停止指定动画的播放 + * @param animationName - 动画数据名称。 + * @param frame - 停止的帧数。 + * @returns 播放的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndStopByFrame(animationName: string, frame?: number): AnimationState | null; + /** + * - Stop a specific animation at the specific progress. + * @param animationName - The name of animation data. + * @param progress - The stop progress value. + * @returns The played animation state. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 在指定的进度停止指定的动画播放。 + * @param animationName - 动画数据名称。 + * @param progress - 停止进度。 + * @returns 播放的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndStopByProgress(animationName: string, progress?: number): AnimationState | null; + /** + * - Get a specific animation state. + * @param animationName - The name of animation state. + * @example + *
+         *     armature.animation.play("walk");
+         *     let walkState = armature.animation.getState("walk");
+         *     walkState.timeScale = 0.5;
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取指定的动画状态 + * @param animationName - 动画状态名称。 + * @example + *
+         *     armature.animation.play("walk");
+         *     let walkState = armature.animation.getState("walk");
+         *     walkState.timeScale = 0.5;
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + getState(animationName: string): AnimationState | null; + /** + * - Check whether a specific animation data is included. + * @param animationName - The name of animation data. + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 检查是否包含指定的动画数据 + * @param animationName - 动画数据名称。 + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language zh_CN + */ + hasAnimation(animationName: string): boolean; + /** + * - Get all the animation states. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 获取所有的动画状态 + * @version DragonBones 5.1 + * @language zh_CN + */ + getStates(): Array; + /** + * - Check whether there is an animation state is playing + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 检查是否有动画状态正在播放 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly isPlaying: boolean; + /** + * - Check whether all the animation states' playing were finished. + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 检查是否所有的动画状态均已播放完毕。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly isCompleted: boolean; + /** + * - The name of the last playing animation state. + * @see #lastAnimationState + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 上一个播放的动画状态名称 + * @see #lastAnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly lastAnimationName: string; + /** + * - The name of all animation data + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 所有动画数据的名称 + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly animationNames: Array; + /** + * - All animation data. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 所有的动画数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + animations: Map; + /** + * - An AnimationConfig instance that can be used quickly. + * @see dragonBones.AnimationConfig + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 一个可以快速使用的动画配置实例。 + * @see dragonBones.AnimationConfig + * @version DragonBones 5.0 + * @language zh_CN + */ + readonly animationConfig: AnimationConfig; + /** + * - The last playing animation state + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 上一个播放的动画状态 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly lastAnimationState: AnimationState | null; + /** + * - Deprecated, please refer to {@link #play()} {@link #fadeIn()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #play()} {@link #fadeIn()}。 + * @deprecated + * @language zh_CN + */ + gotoAndPlay(animationName: string, fadeInTime?: number, duration?: number, playTimes?: number, layer?: number, group?: string | null, fadeOutMode?: AnimationFadeOutMode, pauseFadeOut?: boolean, pauseFadeIn?: boolean): AnimationState | null; + /** + * - Deprecated, please refer to {@link #gotoAndStopByTime()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #gotoAndStopByTime()}。 + * @deprecated + * @language zh_CN + */ + gotoAndStop(animationName: string, time?: number): AnimationState | null; + /** + * - Deprecated, please refer to {@link #animationNames}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #animationNames}。 + * @deprecated + * @language zh_CN + */ + readonly animationList: Array; + /** + * - Deprecated, please refer to {@link #animationNames}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #animationNames}。 + * @deprecated + * @language zh_CN + */ + readonly animationDataList: Array; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The animation state is generated when the animation data is played. + * @see dragonBones.Animation + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画状态由播放动画数据时产生。 + * @see dragonBones.Animation + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language zh_CN + */ + class AnimationState extends BaseObject { + static toString(): string; + /** + * @private + */ + actionEnabled: boolean; + /** + * @private + */ + additiveBlending: boolean; + /** + * - Whether the animation state has control over the display object properties of the slots. + * Sometimes blend a animation state does not want it to control the display object properties of the slots, + * especially if other animation state are controlling the display object properties of the slots. + * @default true + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画状态是否对插槽的显示对象属性有控制权。 + * 有时混合一个动画状态并不希望其控制插槽的显示对象属性, + * 尤其是其他动画状态正在控制这些插槽的显示对象属性时。 + * @default true + * @version DragonBones 5.0 + * @language zh_CN + */ + displayControl: boolean; + /** + * - Whether to reset the objects without animation to the armature pose when the animation state is start to play. + * This property should usually be set to false when blend multiple animation states. + * @default true + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 开始播放动画状态时是否将没有动画的对象重置为骨架初始值。 + * 通常在混合多个动画状态时应该将该属性设置为 false。 + * @default true + * @version DragonBones 5.1 + * @language zh_CN + */ + resetToPose: boolean; + /** + * - The play times. [0: Loop play, [1~N]: Play N times] + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 播放次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次] + * @version DragonBones 3.0 + * @language zh_CN + */ + playTimes: number; + /** + * - The blend layer. + * High layer animation state will get the blend weight first. + * When the blend weight is assigned more than 1, the remaining animation states will no longer get the weight assigned. + * @readonly + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 混合图层。 + * 图层高的动画状态会优先获取混合权重。 + * 当混合权重分配超过 1 时,剩余的动画状态将不再获得权重分配。 + * @readonly + * @version DragonBones 5.0 + * @language zh_CN + */ + layer: number; + /** + * - The play speed. + * The value is an overlay relationship with {@link dragonBones.Animation#timeScale}. + * [(-N~0): Reverse play, 0: Stop play, (0~1): Slow play, 1: Normal play, (1~N): Fast play] + * @default 1.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 播放速度。 + * 该值与 {@link dragonBones.Animation#timeScale} 是叠加关系。 + * [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + timeScale: number; + /** + * - The blend weight. + * @default 1.0 + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 混合权重。 + * @default 1.0 + * @version DragonBones 5.0 + * @language zh_CN + */ + weight: number; + /** + * - The auto fade out time when the animation state play completed. + * [-1: Do not fade out automatically, [0~N]: The fade out time] (In seconds) + * @default -1.0 + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画状态播放完成后的自动淡出时间。 + * [-1: 不自动淡出, [0~N]: 淡出时间] (以秒为单位) + * @default -1.0 + * @version DragonBones 5.0 + * @language zh_CN + */ + autoFadeOutTime: number; + /** + * @private + */ + fadeTotalTime: number; + /** + * - The name of the animation state. (Can be different from the name of the animation data) + * @readonly + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画状态名称。 (可以不同于动画数据) + * @readonly + * @version DragonBones 5.0 + * @language zh_CN + */ + name: string; + /** + * - The blend group name of the animation state. + * This property is typically used to specify the substitution of multiple animation states blend. + * @readonly + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 混合组名称。 + * 该属性通常用来指定多个动画状态混合时的相互替换关系。 + * @readonly + * @version DragonBones 5.0 + * @language zh_CN + */ + group: string; + private _timelineDirty; + /** + * - xx: Play Enabled, Fade Play Enabled + * @internal + * @private + */ + _playheadState: number; + /** + * -1: Fade in, 0: Fade complete, 1: Fade out; + * @internal + * @private + */ + _fadeState: number; + /** + * -1: Fade start, 0: Fading, 1: Fade complete; + * @internal + * @private + */ + _subFadeState: number; + /** + * @internal + * @private + */ + _position: number; + /** + * @internal + * @private + */ + _duration: number; + private _fadeTime; + private _time; + /** + * @internal + * @private + */ + _fadeProgress: number; + /** + * @internal + * @private + */ + _weightResult: number; + /** + * @internal + * @private + */ + readonly _blendState: BlendState; + private readonly _boneMask; + private readonly _boneTimelines; + private readonly _surfaceTimelines; + private readonly _slotTimelines; + private readonly _constraintTimelines; + private readonly _animationTimelines; + private readonly _poseTimelines; + private readonly _bonePoses; + /** + * @internal + * @private + */ + _animationData: AnimationData; + private _armature; + /** + * @internal + * @private + */ + _actionTimeline: ActionTimelineState; + private _zOrderTimeline; + /** + * @internal + * @private + */ + _parent: AnimationState; + /** + * @private + */ + protected _onClear(): void; + private _updateTimelines(); + private _updateBoneAndSlotTimelines(); + private _advanceFadeTime(passedTime); + /** + * @internal + * @private + */ + init(armature: Armature, animationData: AnimationData, animationConfig: AnimationConfig): void; + /** + * @internal + * @private + */ + advanceTime(passedTime: number, cacheFrameRate: number): void; + /** + * - Continue play. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 继续播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + play(): void; + /** + * - Stop play. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 暂停播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + stop(): void; + /** + * - Fade out the animation state. + * @param fadeOutTime - The fade out time. (In seconds) + * @param pausePlayhead - Whether to pause the animation playing when fade out. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 淡出动画状态。 + * @param fadeOutTime - 淡出时间。 (以秒为单位) + * @param pausePlayhead - 淡出时是否暂停播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + fadeOut(fadeOutTime: number, pausePlayhead?: boolean): void; + /** + * - Check if a specific bone mask is included. + * @param name - The bone name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 检查是否包含特定骨骼遮罩。 + * @param name - 骨骼名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + containsBoneMask(name: string): boolean; + /** + * - Add a specific bone mask. + * @param name - The bone name. + * @param recursive - Whether or not to add a mask to the bone's sub-bone. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 添加特定的骨骼遮罩。 + * @param name - 骨骼名称。 + * @param recursive - 是否为该骨骼的子骨骼添加遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + addBoneMask(name: string, recursive?: boolean): void; + /** + * - Remove the mask of a specific bone. + * @param name - The bone name. + * @param recursive - Whether to remove the bone's sub-bone mask. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 删除特定骨骼的遮罩。 + * @param name - 骨骼名称。 + * @param recursive - 是否删除该骨骼的子骨骼遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + removeBoneMask(name: string, recursive?: boolean): void; + /** + * - Remove all bone masks. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 删除所有骨骼遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + removeAllBoneMask(): void; + /** + * - Whether the animation state is fading in. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 是否正在淡入。 + * @version DragonBones 5.1 + * @language zh_CN + */ + readonly isFadeIn: boolean; + /** + * - Whether the animation state is fading out. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 是否正在淡出。 + * @version DragonBones 5.1 + * @language zh_CN + */ + readonly isFadeOut: boolean; + /** + * - Whether the animation state is fade completed. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 是否淡入或淡出完毕。 + * @version DragonBones 5.1 + * @language zh_CN + */ + readonly isFadeComplete: boolean; + /** + * - Whether the animation state is playing. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 是否正在播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly isPlaying: boolean; + /** + * - Whether the animation state is play completed. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 是否播放完毕。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly isCompleted: boolean; + /** + * - The times has been played. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 已经循环播放的次数。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly currentPlayTimes: number; + /** + * - The total time. (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 总播放时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly totalTime: number; + /** + * - The time is currently playing. (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 当前播放的时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + currentTime: number; + /** + * - The animation data. + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画数据。 + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly animationData: AnimationData; + } + /** + * @internal + * @private + */ + class BonePose extends BaseObject { + static toString(): string; + readonly current: Transform; + readonly delta: Transform; + readonly result: Transform; + protected _onClear(): void; + } + /** + * @internal + * @private + */ + class BlendState { + dirty: boolean; + layer: number; + leftWeight: number; + layerWeight: number; + blendWeight: number; + update(weight: number, layer: number): number; + clear(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + const enum TweenState { + None = 0, + Once = 1, + Always = 2, + } + /** + * @internal + * @private + */ + abstract class TimelineState extends BaseObject { + playState: number; + currentPlayTimes: number; + currentTime: number; + protected _tweenState: TweenState; + protected _frameRate: number; + protected _frameValueOffset: number; + protected _frameCount: number; + protected _frameOffset: number; + protected _frameIndex: number; + protected _frameRateR: number; + protected _position: number; + protected _duration: number; + protected _timeScale: number; + protected _timeOffset: number; + protected _dragonBonesData: DragonBonesData; + protected _animationData: AnimationData; + protected _timelineData: TimelineData | null; + protected _armature: Armature; + protected _animationState: AnimationState; + protected _actionTimeline: TimelineState; + protected _frameArray: Array | Int16Array; + protected _frameIntArray: Array | Int16Array; + protected _frameFloatArray: Array | Int16Array; + protected _timelineArray: Array | Uint16Array; + protected _frameIndices: Array; + protected _onClear(): void; + protected abstract _onArriveAtFrame(): void; + protected abstract _onUpdateFrame(): void; + protected _setCurrentTime(passedTime: number): boolean; + init(armature: Armature, animationState: AnimationState, timelineData: TimelineData | null): void; + fadeOut(): void; + update(passedTime: number): void; + } + /** + * @internal + * @private + */ + abstract class TweenTimelineState extends TimelineState { + private static _getEasingValue(tweenType, progress, easing); + private static _getEasingCurveValue(progress, samples, count, offset); + protected _tweenType: TweenType; + protected _curveCount: number; + protected _framePosition: number; + protected _frameDurationR: number; + protected _tweenProgress: number; + protected _tweenEasing: number; + protected _onClear(): void; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + } + /** + * @internal + * @private + */ + abstract class BoneTimelineState extends TweenTimelineState { + bone: Bone; + bonePose: BonePose; + protected _onClear(): void; + blend(state: number): void; + } + /** + * @internal + * @private + */ + abstract class SlotTimelineState extends TweenTimelineState { + slot: Slot; + protected _onClear(): void; + } + /** + * @internal + * @private + */ + abstract class ConstraintTimelineState extends TweenTimelineState { + constraint: Constraint; + protected _onClear(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + class ActionTimelineState extends TimelineState { + static toString(): string; + private _onCrossFrame(frameIndex); + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + update(passedTime: number): void; + setCurrentTime(value: number): void; + } + /** + * @internal + * @private + */ + class ZOrderTimelineState extends TimelineState { + static toString(): string; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + } + /** + * @internal + * @private + */ + class BoneAllTimelineState extends BoneTimelineState { + static toString(): string; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + fadeOut(): void; + } + /** + * @internal + * @private + */ + class BoneTranslateTimelineState extends BoneTimelineState { + static toString(): string; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + } + /** + * @internal + * @private + */ + class BoneRotateTimelineState extends BoneTimelineState { + static toString(): string; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + fadeOut(): void; + } + /** + * @internal + * @private + */ + class BoneScaleTimelineState extends BoneTimelineState { + static toString(): string; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + } + /** + * @internal + * @private + */ + class SurfaceTimelineState extends TweenTimelineState { + static toString(): string; + surface: Surface; + private _frameFloatOffset; + private _valueCount; + private _deformCount; + private _valueOffset; + private readonly _current; + private readonly _delta; + private readonly _result; + protected _onClear(): void; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + init(armature: Armature, animationState: AnimationState, timelineData: TimelineData | null): void; + blend(state: number): void; + } + /** + * @internal + * @private + */ + class SlotDislayTimelineState extends SlotTimelineState { + static toString(): string; + protected _onArriveAtFrame(): void; + } + /** + * @internal + * @private + */ + class SlotColorTimelineState extends SlotTimelineState { + static toString(): string; + private _dirty; + private readonly _current; + private readonly _delta; + private readonly _result; + protected _onClear(): void; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + fadeOut(): void; + update(passedTime: number): void; + } + /** + * @internal + * @private + */ + class SlotFFDTimelineState extends SlotTimelineState { + static toString(): string; + meshOffset: number; + private _dirty; + private _frameFloatOffset; + private _valueCount; + private _deformCount; + private _valueOffset; + private readonly _current; + private readonly _delta; + private readonly _result; + protected _onClear(): void; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + init(armature: Armature, animationState: AnimationState, timelineData: TimelineData | null): void; + fadeOut(): void; + update(passedTime: number): void; + } + /** + * @internal + * @private + */ + class IKConstraintTimelineState extends ConstraintTimelineState { + static toString(): string; + private _current; + private _delta; + protected _onClear(): void; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + } + /** + * @internal + * @private + */ + class AnimationTimelineState extends TweenTimelineState { + static toString(): string; + animationState: AnimationState; + private readonly _floats; + protected _onClear(): void; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + blend(state: number): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The properties of the object carry basic information about an event, + * which are passed as parameter or parameter's parameter to event listeners when an event occurs. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 事件对象,包含有关事件的基本信息,当发生事件时,该实例将作为参数或参数的参数传递给事件侦听器。 + * @version DragonBones 4.5 + * @language zh_CN + */ + class EventObject extends BaseObject { + /** + * - Animation start play. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画开始播放。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly START: string; + /** + * - Animation loop play complete once. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画循环播放完成一次。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly LOOP_COMPLETE: string; + /** + * - Animation play complete. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画播放完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly COMPLETE: string; + /** + * - Animation fade in start. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画淡入开始。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly FADE_IN: string; + /** + * - Animation fade in complete. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画淡入完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly FADE_IN_COMPLETE: string; + /** + * - Animation fade out start. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画淡出开始。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly FADE_OUT: string; + /** + * - Animation fade out complete. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画淡出完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly FADE_OUT_COMPLETE: string; + /** + * - Animation frame event. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画帧事件。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly FRAME_EVENT: string; + /** + * - Animation frame sound event. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画帧声音事件。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly SOUND_EVENT: string; + static toString(): string; + /** + * - If is a frame event, the value is used to describe the time that the event was in the animation timeline. (In seconds) + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 如果是帧事件,此值用来描述该事件在动画时间轴中所处的时间。(以秒为单位) + * @version DragonBones 4.5 + * @language zh_CN + */ + time: number; + /** + * - The event type。 + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 事件类型。 + * @version DragonBones 4.5 + * @language zh_CN + */ + type: EventStringType; + /** + * - The event name. (The frame event name or the frame sound name) + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 事件名称。 (帧事件的名称或帧声音的名称) + * @version DragonBones 4.5 + * @language zh_CN + */ + name: string; + /** + * - The armature that dispatch the event. + * @see dragonBones.Armature + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 发出该事件的骨架。 + * @see dragonBones.Armature + * @version DragonBones 4.5 + * @language zh_CN + */ + armature: Armature; + /** + * - The bone that dispatch the event. + * @see dragonBones.Bone + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 发出该事件的骨骼。 + * @see dragonBones.Bone + * @version DragonBones 4.5 + * @language zh_CN + */ + bone: Bone | null; + /** + * - The slot that dispatch the event. + * @see dragonBones.Slot + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 发出该事件的插槽。 + * @see dragonBones.Slot + * @version DragonBones 4.5 + * @language zh_CN + */ + slot: Slot | null; + /** + * - The animation state that dispatch the event. + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 发出该事件的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + animationState: AnimationState; + /** + * - The custom data. + * @see dragonBones.CustomData + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 自定义数据。 + * @see dragonBones.CustomData + * @version DragonBones 5.0 + * @language zh_CN + */ + data: UserData | null; + /** + * @private + */ + protected _onClear(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @private + */ + type EventStringType = string | "start" | "loopComplete" | "complete" | "fadeIn" | "fadeInComplete" | "fadeOut" | "fadeOutComplete" | "frameEvent" | "soundEvent"; + /** + * - The event dispatcher interface. + * Dragonbones event dispatch usually relies on docking engine to implement, which defines the event method to be implemented when docking the engine. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 事件派发接口。 + * DragonBones 的事件派发通常依赖于对接的引擎来实现,该接口定义了对接引擎时需要实现的事件方法。 + * @version DragonBones 4.5 + * @language zh_CN + */ + interface IEventDispatcher { + /** + * - Checks whether the object has any listeners registered for a specific type of event。 + * @param type - Event type. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 检查是否为特定的事件类型注册了任何侦听器。 + * @param type - 事件类型。 + * @version DragonBones 4.5 + * @language zh_CN + */ + hasDBEventListener(type: EventStringType): boolean; + /** + * - Dispatches an event into the event flow. + * @param type - Event type. + * @param eventObject - Event object. + * @see dragonBones.EventObject + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 分派特定的事件到事件流中。 + * @param type - 事件类型。 + * @param eventObject - 事件数据。 + * @see dragonBones.EventObject + * @version DragonBones 4.5 + * @language zh_CN + */ + dispatchDBEvent(type: EventStringType, eventObject: EventObject): void; + /** + * - Add an event listener object so that the listener receives notification of an event. + * @param type - Event type. + * @param listener - Event listener. + * @param thisObject - The listener function's "this". + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 添加特定事件类型的事件侦听器,以使侦听器能够接收事件通知。 + * @param type - 事件类型。 + * @param listener - 事件侦听器。 + * @param thisObject - 侦听函数绑定的 this 对象。 + * @version DragonBones 4.5 + * @language zh_CN + */ + addDBEventListener(type: EventStringType, listener: Function, thisObject: any): void; + /** + * - Removes a listener from the object. + * @param type - Event type. + * @param listener - Event listener. + * @param thisObject - The listener function's "this". + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 删除特定事件类型的侦听器。 + * @param type - 事件类型。 + * @param listener - 事件侦听器。 + * @param thisObject - 侦听函数绑定的 this 对象。 + * @version DragonBones 4.5 + * @language zh_CN + */ + removeDBEventListener(type: EventStringType, listener: Function, thisObject: any): void; + /** + * - Deprecated, please refer to {@link #hasDBEventListener()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #hasDBEventListener()}。 + * @deprecated + * @language zh_CN + */ + hasEvent(type: EventStringType): boolean; + /** + * - Deprecated, please refer to {@link #addDBEventListener()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #addDBEventListener()}。 + * @deprecated + * @language zh_CN + */ + addEvent(type: EventStringType, listener: Function, thisObject: any): void; + /** + * - Deprecated, please refer to {@link #removeDBEventListener()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #removeDBEventListener()}。 + * @deprecated + * @language zh_CN + */ + removeEvent(type: EventStringType, listener: Function, thisObject: any): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + abstract class DataParser { + protected static readonly DATA_VERSION_2_3: string; + protected static readonly DATA_VERSION_3_0: string; + protected static readonly DATA_VERSION_4_0: string; + protected static readonly DATA_VERSION_4_5: string; + protected static readonly DATA_VERSION_5_0: string; + protected static readonly DATA_VERSION_5_5: string; + protected static readonly DATA_VERSION: string; + protected static readonly DATA_VERSIONS: Array; + protected static readonly TEXTURE_ATLAS: string; + protected static readonly SUB_TEXTURE: string; + protected static readonly FORMAT: string; + protected static readonly IMAGE_PATH: string; + protected static readonly WIDTH: string; + protected static readonly HEIGHT: string; + protected static readonly ROTATED: string; + protected static readonly FRAME_X: string; + protected static readonly FRAME_Y: string; + protected static readonly FRAME_WIDTH: string; + protected static readonly FRAME_HEIGHT: string; + protected static readonly DRADON_BONES: string; + protected static readonly USER_DATA: string; + protected static readonly ARMATURE: string; + protected static readonly BONE: string; + protected static readonly SURFACE: string; + protected static readonly SLOT: string; + protected static readonly CONSTRAINT: string; + protected static readonly IK: string; + protected static readonly SKIN: string; + protected static readonly DISPLAY: string; + protected static readonly ANIMATION: string; + protected static readonly Z_ORDER: string; + protected static readonly FFD: string; + protected static readonly FRAME: string; + protected static readonly TRANSLATE_FRAME: string; + protected static readonly ROTATE_FRAME: string; + protected static readonly SCALE_FRAME: string; + protected static readonly DISPLAY_FRAME: string; + protected static readonly COLOR_FRAME: string; + protected static readonly DEFAULT_ACTIONS: string; + protected static readonly ACTIONS: string; + protected static readonly EVENTS: string; + protected static readonly INTS: string; + protected static readonly FLOATS: string; + protected static readonly STRINGS: string; + protected static readonly CANVAS: string; + protected static readonly TRANSFORM: string; + protected static readonly PIVOT: string; + protected static readonly AABB: string; + protected static readonly COLOR: string; + protected static readonly VERSION: string; + protected static readonly COMPATIBLE_VERSION: string; + protected static readonly FRAME_RATE: string; + protected static readonly TYPE: string; + protected static readonly SUB_TYPE: string; + protected static readonly NAME: string; + protected static readonly PARENT: string; + protected static readonly TARGET: string; + protected static readonly STAGE: string; + protected static readonly SHARE: string; + protected static readonly PATH: string; + protected static readonly LENGTH: string; + protected static readonly DISPLAY_INDEX: string; + protected static readonly BLEND_MODE: string; + protected static readonly INHERIT_TRANSLATION: string; + protected static readonly INHERIT_ROTATION: string; + protected static readonly INHERIT_SCALE: string; + protected static readonly INHERIT_REFLECTION: string; + protected static readonly INHERIT_ANIMATION: string; + protected static readonly INHERIT_DEFORM: string; + protected static readonly SEGMENT_X: string; + protected static readonly SEGMENT_Y: string; + protected static readonly BEND_POSITIVE: string; + protected static readonly CHAIN: string; + protected static readonly WEIGHT: string; + protected static readonly FADE_IN_TIME: string; + protected static readonly PLAY_TIMES: string; + protected static readonly SCALE: string; + protected static readonly OFFSET: string; + protected static readonly POSITION: string; + protected static readonly DURATION: string; + protected static readonly TWEEN_EASING: string; + protected static readonly TWEEN_ROTATE: string; + protected static readonly TWEEN_SCALE: string; + protected static readonly CLOCK_WISE: string; + protected static readonly CURVE: string; + protected static readonly SOUND: string; + protected static readonly EVENT: string; + protected static readonly ACTION: string; + protected static readonly X: string; + protected static readonly Y: string; + protected static readonly SKEW_X: string; + protected static readonly SKEW_Y: string; + protected static readonly SCALE_X: string; + protected static readonly SCALE_Y: string; + protected static readonly VALUE: string; + protected static readonly ROTATE: string; + protected static readonly SKEW: string; + protected static readonly ALPHA_OFFSET: string; + protected static readonly RED_OFFSET: string; + protected static readonly GREEN_OFFSET: string; + protected static readonly BLUE_OFFSET: string; + protected static readonly ALPHA_MULTIPLIER: string; + protected static readonly RED_MULTIPLIER: string; + protected static readonly GREEN_MULTIPLIER: string; + protected static readonly BLUE_MULTIPLIER: string; + protected static readonly UVS: string; + protected static readonly VERTICES: string; + protected static readonly TRIANGLES: string; + protected static readonly WEIGHTS: string; + protected static readonly SLOT_POSE: string; + protected static readonly BONE_POSE: string; + protected static readonly GLUE_WEIGHTS: string; + protected static readonly GLUE_MESHES: string; + protected static readonly GOTO_AND_PLAY: string; + protected static readonly DEFAULT_NAME: string; + protected static _getArmatureType(value: string): ArmatureType; + protected static _getBoneType(value: string): BoneType; + protected static _getDisplayType(value: string): DisplayType; + protected static _getBoundingBoxType(value: string): BoundingBoxType; + protected static _getActionType(value: string): ActionType; + protected static _getBlendMode(value: string): BlendMode; + abstract parseDragonBonesData(rawData: any, scale: number): DragonBonesData | null; + abstract parseTextureAtlasData(rawData: any, textureAtlasData: TextureAtlasData, scale: number): boolean; + /** + * - Deprecated, please refer to {@link dragonBones.BaseFactory#parsetTextureAtlasData()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link dragonBones.BaseFactory#parsetTextureAtlasData()}。 + * @deprecated + * @language zh_CN + */ + static parseDragonBonesData(rawData: any): DragonBonesData | null; + /** + * - Deprecated, please refer to {@link dragonBones.BaseFactory#parsetTextureAtlasData()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link dragonBones.BaseFactory#parsetTextureAtlasData()}。 + * @deprecated + * @language zh_CN + */ + static parseTextureAtlasData(rawData: any, scale?: number): any; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + class ObjectDataParser extends DataParser { + protected static _getBoolean(rawData: any, key: string, defaultValue: boolean): boolean; + protected static _getNumber(rawData: any, key: string, defaultValue: number): number; + protected static _getString(rawData: any, key: string, defaultValue: string): string; + protected _rawTextureAtlasIndex: number; + protected readonly _rawBones: Array; + protected _data: DragonBonesData; + protected _armature: ArmatureData; + protected _bone: BoneData; + protected _surface: SurfaceData; + protected _slot: SlotData; + protected _skin: SkinData; + protected _mesh: MeshDisplayData; + protected _animation: AnimationData; + protected _timeline: TimelineData; + protected _rawTextureAtlases: Array | null; + private _defaultColorOffset; + private _prevClockwise; + private _prevRotation; + private readonly _helpMatrixA; + private readonly _helpMatrixB; + private readonly _helpTransform; + private readonly _helpColorTransform; + private readonly _helpPoint; + private readonly _helpArray; + private readonly _intArray; + private readonly _floatArray; + private readonly _frameIntArray; + private readonly _frameFloatArray; + private readonly _frameArray; + private readonly _timelineArray; + private readonly _cacheRawMeshes; + private readonly _cacheMeshes; + private readonly _actionFrames; + private readonly _weightSlotPose; + private readonly _weightBonePoses; + private readonly _cacheBones; + private readonly _slotChildActions; + private _getCurvePoint(x1, y1, x2, y2, x3, y3, x4, y4, t, result); + private _samplingEasingCurve(curve, samples); + private _parseActionDataInFrame(rawData, frameStart, bone, slot); + private _mergeActionFrame(rawData, frameStart, type, bone, slot); + protected _parseArmature(rawData: any, scale: number): ArmatureData; + protected _parseBone(rawData: any): BoneData; + protected _parseIKConstraint(rawData: any): ConstraintData | null; + protected _parseSlot(rawData: any, zOrder: number): SlotData; + protected _parseSkin(rawData: any): SkinData; + protected _parseDisplay(rawData: any): DisplayData | null; + protected _parsePivot(rawData: any, display: ImageDisplayData): void; + protected _parseMesh(rawData: any, mesh: MeshDisplayData): void; + protected _parseMeshGlue(rawData: any, mesh: MeshDisplayData): void; + protected _parseBoundingBox(rawData: any): BoundingBoxData | null; + protected _parsePolygonBoundingBox(rawData: any): PolygonBoundingBoxData; + protected _parseAnimation(rawData: any): AnimationData; + protected _parseTimeline(rawData: any, rawFrames: Array | null, framesKey: string, type: TimelineType, addIntOffset: boolean, addFloatOffset: boolean, frameValueCount: number, frameParser: (rawData: any, frameStart: number, frameCount: number) => number): TimelineData | null; + protected _parseBoneTimeline(rawData: any): void; + protected _parseSlotTimeline(rawData: any): void; + protected _parseFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseTweenFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseActionFrame(frame: ActionFrame, frameStart: number, frameCount: number): number; + protected _parseZOrderFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseBoneAllFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseBoneTranslateFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseBoneRotateFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseBoneScaleFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseSurfaceFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseSlotDisplayFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseSlotColorFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseSlotFFDFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseIKConstraintFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseAnimationFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseActionData(rawData: any, type: ActionType, bone: BoneData | null, slot: SlotData | null): Array; + protected _parseTransform(rawData: any, transform: Transform, scale: number): void; + protected _parseColorTransform(rawData: any, color: ColorTransform): void; + protected _parseArray(rawData: any): void; + protected _modifyArray(): void; + parseDragonBonesData(rawData: any, scale?: number): DragonBonesData | null; + parseTextureAtlasData(rawData: any, textureAtlasData: TextureAtlasData, scale?: number): boolean; + private static _objectDataParserInstance; + /** + * - Deprecated, please refer to {@link dragonBones.BaseFactory#parseDragonBonesData()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link dragonBones.BaseFactory#parseDragonBonesData()}。 + * @deprecated + * @language zh_CN + */ + static getInstance(): ObjectDataParser; + } + /** + * @internal + * @private + */ + class ActionFrame { + frameStart: number; + readonly actions: Array; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + class BinaryDataParser extends ObjectDataParser { + private _binaryOffset; + private _binary; + private _intArrayBuffer; + private _floatArrayBuffer; + private _frameIntArrayBuffer; + private _frameFloatArrayBuffer; + private _frameArrayBuffer; + private _timelineArrayBuffer; + private _inRange(a, min, max); + private _decodeUTF8(data); + private _getUTF16Key(value); + private _parseBinaryTimeline(type, offset, timelineData?); + protected _parseMesh(rawData: any, mesh: MeshDisplayData): void; + protected _parseAnimation(rawData: any): AnimationData; + protected _parseArray(rawData: any): void; + parseDragonBonesData(rawData: any, scale?: number): DragonBonesData | null; + private static _binaryDataParserInstance; + /** + * - Deprecated, please refer to {@link dragonBones.BaseFactory#parseDragonBonesData()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link dragonBones.BaseFactory#parseDragonBonesData()}。 + * @deprecated + * @language zh_CN + */ + static getInstance(): BinaryDataParser; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - Base class for the factory that create the armatures. (Typically only one global factory instance is required) + * The factory instance create armatures by parsed and added DragonBonesData instances and TextureAtlasData instances. + * Once the data has been parsed, it has been cached in the factory instance and does not need to be parsed again until it is cleared by the factory instance. + * @see dragonBones.DragonBonesData + * @see dragonBones.TextureAtlasData + * @see dragonBones.ArmatureData + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 创建骨架的工厂基类。 (通常只需要一个全局工厂实例) + * 工厂通过解析并添加的 DragonBonesData 实例和 TextureAtlasData 实例来创建骨架。 + * 当数据被解析过之后,已经添加到工厂中,在没有被工厂清理之前,不需要再次解析。 + * @see dragonBones.DragonBonesData + * @see dragonBones.TextureAtlasData + * @see dragonBones.ArmatureData + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + abstract class BaseFactory { + /** + * @private + */ + protected static _objectParser: ObjectDataParser; + /** + * @private + */ + protected static _binaryParser: BinaryDataParser; + /** + * @private + */ + autoSearch: boolean; + /** + * @private + */ + protected readonly _dragonBonesDataMap: Map; + /** + * @private + */ + protected readonly _textureAtlasDataMap: Map>; + /** + * @private + */ + protected _dragonBones: DragonBones; + /** + * @private + */ + protected _dataParser: DataParser; + /** + * - Create a factory instance. (typically only one global factory instance is required) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 创建一个工厂实例。 (通常只需要一个全局工厂实例) + * @version DragonBones 3.0 + * @language zh_CN + */ + constructor(dataParser?: DataParser | null); + /** + * @private + */ + protected _isSupportMesh(): boolean; + /** + * @private + */ + protected _getTextureData(textureAtlasName: string, textureName: string): TextureData | null; + /** + * @private + */ + protected _fillBuildArmaturePackage(dataPackage: BuildArmaturePackage, dragonBonesName: string, armatureName: string, skinName: string, textureAtlasName: string): boolean; + /** + * @private + */ + protected _buildBones(dataPackage: BuildArmaturePackage, armature: Armature): void; + /** + * @private + */ + protected _buildSlots(dataPackage: BuildArmaturePackage, armature: Armature): void; + /** + * @private + */ + protected _buildChildArmature(dataPackage: BuildArmaturePackage | null, slot: Slot, displayData: DisplayData): Armature | null; + /** + * @private + */ + protected _getSlotDisplay(dataPackage: BuildArmaturePackage | null, displayData: DisplayData, rawDisplayData: DisplayData | null, slot: Slot): any; + /** + * @private + */ + protected abstract _buildTextureAtlasData(textureAtlasData: TextureAtlasData | null, textureAtlas: any): TextureAtlasData; + /** + * @private + */ + protected abstract _buildArmature(dataPackage: BuildArmaturePackage): Armature; + /** + * @private + */ + protected abstract _buildSlot(dataPackage: BuildArmaturePackage, slotData: SlotData, displays: Array | null, armature: Armature): Slot; + /** + * - Parse the raw data to a DragonBonesData instance and cache it to the factory. + * @param rawData - The raw data. + * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (If not set, use the instance name instead) + * @param scale - Specify a scaling value for all armatures. (Default: 1.0) + * @returns DragonBonesData instance + * @see #getDragonBonesData() + * @see #addDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 将原始数据解析为 DragonBonesData 实例,并缓存到工厂中。 + * @param rawData - 原始数据。 + * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) + * @param scale - 为所有的骨架指定一个缩放值。 (默认: 1.0) + * @returns DragonBonesData 实例 + * @see #getDragonBonesData() + * @see #addDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 4.5 + * @language zh_CN + */ + parseDragonBonesData(rawData: any, name?: string | null, scale?: number): DragonBonesData | null; + /** + * - Parse the raw texture atlas data and the texture atlas object to a TextureAtlasData instance and cache it to the factory. + * @param rawData - The raw texture atlas data. + * @param textureAtlas - The texture atlas object. + * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (If not set, use the instance name instead) + * @param scale - Specify a scaling value for the map set. (Default: 1.0) + * @returns TextureAtlasData instance + * @see #getTextureAtlasData() + * @see #addTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 将原始贴图集数据和贴图集对象解析为 TextureAtlasData 实例,并缓存到工厂中。 + * @param rawData - 原始贴图集数据。 + * @param textureAtlas - 贴图集对象。 + * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) + * @param scale - 为贴图集指定一个缩放值。 (默认: 1.0) + * @returns TextureAtlasData 实例 + * @see #getTextureAtlasData() + * @see #addTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 4.5 + * @language zh_CN + */ + parseTextureAtlasData(rawData: any, textureAtlas: any, name?: string | null, scale?: number): TextureAtlasData; + /** + * @private + */ + updateTextureAtlasData(name: string, textureAtlases: Array): void; + /** + * - Get a specific DragonBonesData instance. + * @param name - The DragonBonesData instance cache name. + * @returns DragonBonesData instance + * @see #parseDragonBonesData() + * @see #addDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的 DragonBonesData 实例。 + * @param name - DragonBonesData 实例的缓存名称。 + * @returns DragonBonesData 实例 + * @see #parseDragonBonesData() + * @see #addDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language zh_CN + */ + getDragonBonesData(name: string): DragonBonesData | null; + /** + * - Cache a DragonBonesData instance to the factory. + * @param data - The DragonBonesData instance. + * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (if not set, use the instance name instead) + * @see #parseDragonBonesData() + * @see #getDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 将 DragonBonesData 实例缓存到工厂中。 + * @param data - DragonBonesData 实例。 + * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) + * @see #parseDragonBonesData() + * @see #getDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language zh_CN + */ + addDragonBonesData(data: DragonBonesData, name?: string | null): void; + /** + * - Remove a DragonBonesData instance. + * @param name - The DragonBonesData instance cache name. + * @param disposeData - Whether to dispose data. (Default: true) + * @see #parseDragonBonesData() + * @see #getDragonBonesData() + * @see #addDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 移除 DragonBonesData 实例。 + * @param name - DragonBonesData 实例缓存名称。 + * @param disposeData - 是否释放数据。 (默认: true) + * @see #parseDragonBonesData() + * @see #getDragonBonesData() + * @see #addDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language zh_CN + */ + removeDragonBonesData(name: string, disposeData?: boolean): void; + /** + * - Get a list of specific TextureAtlasData instances. + * @param name - The TextureAtlasData cahce name. + * @see #parseTextureAtlasData() + * @see #addTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的 TextureAtlasData 实例列表。 + * @param name - TextureAtlasData 实例缓存名称。 + * @see #parseTextureAtlasData() + * @see #addTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language zh_CN + */ + getTextureAtlasData(name: string): Array | null; + /** + * - Cache a TextureAtlasData instance to the factory. + * @param data - The TextureAtlasData instance. + * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (if not set, use the instance name instead) + * @see #parseTextureAtlasData() + * @see #getTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 将 TextureAtlasData 实例缓存到工厂中。 + * @param data - TextureAtlasData 实例。 + * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) + * @see #parseTextureAtlasData() + * @see #getTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language zh_CN + */ + addTextureAtlasData(data: TextureAtlasData, name?: string | null): void; + /** + * - Remove a TextureAtlasData instance. + * @param name - The TextureAtlasData instance cache name. + * @param disposeData - Whether to dispose data. + * @see #parseTextureAtlasData() + * @see #getTextureAtlasData() + * @see #addTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 移除 TextureAtlasData 实例。 + * @param name - TextureAtlasData 实例的缓存名称。 + * @param disposeData - 是否释放数据。 + * @see #parseTextureAtlasData() + * @see #getTextureAtlasData() + * @see #addTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language zh_CN + */ + removeTextureAtlasData(name: string, disposeData?: boolean): void; + /** + * - Get a specific armature data. + * @param name - The armature data name. + * @param dragonBonesName - The cached name for DragonbonesData instance. + * @see dragonBones.ArmatureData + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 获取特定的骨架数据。 + * @param name - 骨架数据名称。 + * @param dragonBonesName - DragonBonesData 实例的缓存名称。 + * @see dragonBones.ArmatureData + * @version DragonBones 5.1 + * @language zh_CN + */ + getArmatureData(name: string, dragonBonesName?: string): ArmatureData | null; + /** + * - Clear all cached DragonBonesData instances and TextureAtlasData instances. + * @param disposeData - Whether to dispose data. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 清除缓存的所有 DragonBonesData 实例和 TextureAtlasData 实例。 + * @param disposeData - 是否释放数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + clear(disposeData?: boolean): void; + /** + * - Create a armature from cached DragonBonesData instances and TextureAtlasData instances. + * @param armatureName - The armature data name. + * @param dragonBonesName - The cached name of the DragonBonesData instance. (If not set, all DragonBonesData instances are retrieved, and when multiple DragonBonesData instances contain a the same name armature data, it may not be possible to accurately create a specific armature) + * @param skinName - The skin name, you can set a different ArmatureData name to share it's skin data. (If not set, use the default skin data) + * @returns The armature. + * @example + *
+         *     let armature = factory.buildArmature("armatureName", "dragonBonesName");
+         *     armature.clock = factory.clock;
+         * 
+ * @see dragonBones.DragonBonesData + * @see dragonBones.ArmatureData + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 通过缓存的 DragonBonesData 实例和 TextureAtlasData 实例创建一个骨架。 + * @param armatureName - 骨架数据名称。 + * @param dragonBonesName - DragonBonesData 实例的缓存名称。 (如果未设置,将检索所有的 DragonBonesData 实例,当多个 DragonBonesData 实例中包含同名的骨架数据时,可能无法准确的创建出特定的骨架) + * @param skinName - 皮肤名称,可以设置一个其他骨架数据名称来共享其皮肤数据(如果未设置,则使用默认的皮肤数据)。 + * @returns 骨架。 + * @example + *
+         *     let armature = factory.buildArmature("armatureName", "dragonBonesName");
+         *     armature.clock = factory.clock;
+         * 
+ * @see dragonBones.DragonBonesData + * @see dragonBones.ArmatureData + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + buildArmature(armatureName: string, dragonBonesName?: string, skinName?: string, textureAtlasName?: string): Armature | null; + /** + * @private + */ + replaceDisplay(slot: Slot, displayData: DisplayData, displayIndex?: number): void; + /** + * - Replaces the current display data for a particular slot with a specific display data. + * Specify display data with "dragonBonesName/armatureName/slotName/displayName". + * @param dragonBonesName - The DragonBonesData instance cache name. + * @param armatureName - The armature data name. + * @param slotName - The slot data name. + * @param displayName - The display data name. + * @param slot - The slot. + * @param displayIndex - The index of the display data that is replaced. (If it is not set, replaces the current display data) + * @example + *
+         *     let slot = armature.getSlot("weapon");
+         *     factory.replaceSlotDisplay("dragonBonesName", "armatureName", "slotName", "displayName", slot);
+         * 
+ * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 用特定的显示对象数据替换特定插槽当前的显示对象数据。 + * 用 "dragonBonesName/armatureName/slotName/displayName" 指定显示对象数据。 + * @param dragonBonesName - DragonBonesData 实例的缓存名称。 + * @param armatureName - 骨架数据名称。 + * @param slotName - 插槽数据名称。 + * @param displayName - 显示对象数据名称。 + * @param slot - 插槽。 + * @param displayIndex - 被替换的显示对象数据的索引。 (如果未设置,则替换当前的显示对象数据) + * @example + *
+         *     let slot = armature.getSlot("weapon");
+         *     factory.replaceSlotDisplay("dragonBonesName", "armatureName", "slotName", "displayName", slot);
+         * 
+ * @version DragonBones 4.5 + * @language zh_CN + */ + replaceSlotDisplay(dragonBonesName: string, armatureName: string, slotName: string, displayName: string, slot: Slot, displayIndex?: number): boolean; + /** + * @private + */ + replaceSlotDisplayList(dragonBonesName: string | null, armatureName: string, slotName: string, slot: Slot): boolean; + /** + * - Share specific skin data with specific armature. + * @param armature - The armature. + * @param skin - The skin data. + * @param isOverride - Whether it completely override the original skin. (Default: false) + * @param exclude - A list of slot names that do not need to be replace. + * @example + *
+         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
+         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
+         *     if (armatureDataB && armatureDataB.defaultSkin) {
+         *     factory.replaceSkin(armatureA, armatureDataB.defaultSkin, false, ["arm_l", "weapon_l"]);
+         *     }
+         * 
+ * @see dragonBones.Armature + * @see dragonBones.SkinData + * @version DragonBones 5.6 + * @language en_US + */ + /** + * - 将特定的皮肤数据共享给特定的骨架使用。 + * @param armature - 骨架。 + * @param skin - 皮肤数据。 + * @param isOverride - 是否完全覆盖原来的皮肤。 (默认: false) + * @param exclude - 不需要被替换的插槽名称列表。 + * @example + *
+         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
+         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
+         *     if (armatureDataB && armatureDataB.defaultSkin) {
+         *     factory.replaceSkin(armatureA, armatureDataB.defaultSkin, false, ["arm_l", "weapon_l"]);
+         *     }
+         * 
+ * @see dragonBones.Armature + * @see dragonBones.SkinData + * @version DragonBones 5.6 + * @language zh_CN + */ + replaceSkin(armature: Armature, skin: SkinData, isOverride?: boolean, exclude?: Array | null): boolean; + /** + * - Replaces the existing animation data for a specific armature with the animation data for the specific armature data. + * This enables you to make a armature template so that other armature without animations can share it's animations. + * @param armature - The armtaure. + * @param armatureData - The armature data. + * @param isOverride - Whether to completely overwrite the original animation. (Default: false) + * @example + *
+         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
+         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
+         *     if (armatureDataB) {
+         *     factory.replaceAnimation(armatureA, armatureDataB);
+         *     }
+         * 
+ * @see dragonBones.Armature + * @see dragonBones.ArmatureData + * @version DragonBones 5.6 + * @language en_US + */ + /** + * - 用特定骨架数据的动画数据替换特定骨架现有的动画数据。 + * 这样就能实现制作一个骨架动画模板,让其他没有制作动画的骨架共享该动画。 + * @param armature - 骨架。 + * @param armatureData - 骨架数据。 + * @param isOverride - 是否完全覆盖原来的动画。(默认: false)。 + * @example + *
+         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
+         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
+         *     if (armatureDataB) {
+         *     factory.replaceAnimation(armatureA, armatureDataB);
+         *     }
+         * 
+ * @see dragonBones.Armature + * @see dragonBones.ArmatureData + * @version DragonBones 5.6 + * @language zh_CN + */ + replaceAnimation(armature: Armature, armatureData: ArmatureData, isOverride?: boolean): boolean; + /** + * @private + */ + getAllDragonBonesData(): Map; + /** + * @private + */ + getAllTextureAtlasData(): Map>; + /** + * - An Worldclock instance updated by engine. + * @version DragonBones 5.7 + * @language en_US + */ + /** + * - 由引擎驱动的 WorldClock 实例。 + * @version DragonBones 5.7 + * @language zh_CN + */ + readonly clock: WorldClock; + /** + * @private + */ + readonly dragonBones: DragonBones; + /** + * - Deprecated, please refer to {@link #replaceSkin}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #replaceSkin}。 + * @deprecated + * @language zh_CN + */ + changeSkin(armature: Armature, skin: SkinData, exclude?: Array | null): boolean; + /** + * - Deprecated, please refer to {@link #replaceAnimation}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #replaceAnimation}。 + * @deprecated + * @language zh_CN + */ + copyAnimationsToArmature(toArmature: Armature, fromArmatreName: string, fromSkinName?: string, fromDragonBonesDataName?: string, replaceOriginalAnimation?: boolean): boolean; + } + /** + * @internal + * @private + */ + class BuildArmaturePackage { + dataName: string; + textureAtlasName: string; + data: DragonBonesData; + armature: ArmatureData; + skin: SkinData | null; + } +} + +declare namespace sp.spine { + class Animation { + name: string; + timelines: Array; + timelineIds: Array; + duration: number; + constructor(name: string, timelines: Array, duration: number); + hasTimeline(id: number): boolean; + apply(skeleton: Skeleton, lastTime: number, time: number, loop: boolean, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + static binarySearch(values: ArrayLike, target: number, step?: number): number; + static linearSearch(values: ArrayLike, target: number, step: number): number; + } + interface Timeline { + apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + getPropertyId(): number; + } + enum MixBlend { + setup = 0, + first = 1, + replace = 2, + add = 3 + } + enum MixDirection { + mixIn = 0, + mixOut = 1 + } + enum TimelineType { + rotate = 0, + translate = 1, + scale = 2, + shear = 3, + attachment = 4, + color = 5, + deform = 6, + event = 7, + drawOrder = 8, + ikConstraint = 9, + transformConstraint = 10, + pathConstraintPosition = 11, + pathConstraintSpacing = 12, + pathConstraintMix = 13, + twoColor = 14 + } + abstract class CurveTimeline implements Timeline { + static LINEAR: number; + static STEPPED: number; + static BEZIER: number; + static BEZIER_SIZE: number; + private curves; + abstract getPropertyId(): number; + constructor(frameCount: number); + getFrameCount(): number; + setLinear(frameIndex: number): void; + setStepped(frameIndex: number): void; + getCurveType(frameIndex: number): number; + setCurve(frameIndex: number, cx1: number, cy1: number, cx2: number, cy2: number): void; + getCurvePercent(frameIndex: number, percent: number): number; + abstract apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class RotateTimeline extends CurveTimeline { + static ENTRIES: number; + static PREV_TIME: number; + static PREV_ROTATION: number; + static ROTATION: number; + boneIndex: number; + frames: ArrayLike; + constructor(frameCount: number); + getPropertyId(): number; + setFrame(frameIndex: number, time: number, degrees: number): void; + apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class TranslateTimeline extends CurveTimeline { + static ENTRIES: number; + static PREV_TIME: number; + static PREV_X: number; + static PREV_Y: number; + static X: number; + static Y: number; + boneIndex: number; + frames: ArrayLike; + constructor(frameCount: number); + getPropertyId(): number; + setFrame(frameIndex: number, time: number, x: number, y: number): void; + apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class ScaleTimeline extends TranslateTimeline { + constructor(frameCount: number); + getPropertyId(): number; + apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class ShearTimeline extends TranslateTimeline { + constructor(frameCount: number); + getPropertyId(): number; + apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class ColorTimeline extends CurveTimeline { + static ENTRIES: number; + static PREV_TIME: number; + static PREV_R: number; + static PREV_G: number; + static PREV_B: number; + static PREV_A: number; + static R: number; + static G: number; + static B: number; + static A: number; + slotIndex: number; + frames: ArrayLike; + constructor(frameCount: number); + getPropertyId(): number; + setFrame(frameIndex: number, time: number, r: number, g: number, b: number, a: number): void; + apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class TwoColorTimeline extends CurveTimeline { + static ENTRIES: number; + static PREV_TIME: number; + static PREV_R: number; + static PREV_G: number; + static PREV_B: number; + static PREV_A: number; + static PREV_R2: number; + static PREV_G2: number; + static PREV_B2: number; + static R: number; + static G: number; + static B: number; + static A: number; + static R2: number; + static G2: number; + static B2: number; + slotIndex: number; + frames: ArrayLike; + constructor(frameCount: number); + getPropertyId(): number; + setFrame(frameIndex: number, time: number, r: number, g: number, b: number, a: number, r2: number, g2: number, b2: number): void; + apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class AttachmentTimeline implements Timeline { + slotIndex: number; + frames: ArrayLike; + attachmentNames: Array; + constructor(frameCount: number); + getPropertyId(): number; + getFrameCount(): number; + setFrame(frameIndex: number, time: number, attachmentName: string): void; + apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class DeformTimeline extends CurveTimeline { + slotIndex: number; + attachment: VertexAttachment; + frames: ArrayLike; + frameVertices: Array>; + constructor(frameCount: number); + getPropertyId(): number; + setFrame(frameIndex: number, time: number, vertices: ArrayLike): void; + apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class EventTimeline implements Timeline { + frames: ArrayLike; + events: Array; + constructor(frameCount: number); + getPropertyId(): number; + getFrameCount(): number; + setFrame(frameIndex: number, event: Event): void; + apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class DrawOrderTimeline implements Timeline { + frames: ArrayLike; + drawOrders: Array>; + constructor(frameCount: number); + getPropertyId(): number; + getFrameCount(): number; + setFrame(frameIndex: number, time: number, drawOrder: Array): void; + apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class IkConstraintTimeline extends CurveTimeline { + static ENTRIES: number; + static PREV_TIME: number; + static PREV_MIX: number; + static PREV_SOFTNESS: number; + static PREV_BEND_DIRECTION: number; + static PREV_COMPRESS: number; + static PREV_STRETCH: number; + static MIX: number; + static SOFTNESS: number; + static BEND_DIRECTION: number; + static COMPRESS: number; + static STRETCH: number; + ikConstraintIndex: number; + frames: ArrayLike; + constructor(frameCount: number); + getPropertyId(): number; + setFrame(frameIndex: number, time: number, mix: number, softness: number, bendDirection: number, compress: boolean, stretch: boolean): void; + apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class TransformConstraintTimeline extends CurveTimeline { + static ENTRIES: number; + static PREV_TIME: number; + static PREV_ROTATE: number; + static PREV_TRANSLATE: number; + static PREV_SCALE: number; + static PREV_SHEAR: number; + static ROTATE: number; + static TRANSLATE: number; + static SCALE: number; + static SHEAR: number; + transformConstraintIndex: number; + frames: ArrayLike; + constructor(frameCount: number); + getPropertyId(): number; + setFrame(frameIndex: number, time: number, rotateMix: number, translateMix: number, scaleMix: number, shearMix: number): void; + apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class PathConstraintPositionTimeline extends CurveTimeline { + static ENTRIES: number; + static PREV_TIME: number; + static PREV_VALUE: number; + static VALUE: number; + pathConstraintIndex: number; + frames: ArrayLike; + constructor(frameCount: number); + getPropertyId(): number; + setFrame(frameIndex: number, time: number, value: number): void; + apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class PathConstraintSpacingTimeline extends PathConstraintPositionTimeline { + constructor(frameCount: number); + getPropertyId(): number; + apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class PathConstraintMixTimeline extends CurveTimeline { + static ENTRIES: number; + static PREV_TIME: number; + static PREV_ROTATE: number; + static PREV_TRANSLATE: number; + static ROTATE: number; + static TRANSLATE: number; + pathConstraintIndex: number; + frames: ArrayLike; + constructor(frameCount: number); + getPropertyId(): number; + setFrame(frameIndex: number, time: number, rotateMix: number, translateMix: number): void; + apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } +} +declare namespace sp.spine { + class AnimationState { + static emptyAnimation: Animation; + static SUBSEQUENT: number; + static FIRST: number; + static HOLD: number; + static HOLD_MIX: number; + static NOT_LAST: number; + data: AnimationStateData; + tracks: TrackEntry[]; + timeScale: number; + events: Event[]; + listeners: AnimationStateListener[]; + queue: EventQueue; + propertyIDs: IntSet; + animationsChanged: boolean; + trackEntryPool: Pool; + constructor(data: AnimationStateData); + update(delta: number): void; + updateMixingFrom(to: TrackEntry, delta: number): boolean; + apply(skeleton: Skeleton): boolean; + applyMixingFrom(to: TrackEntry, skeleton: Skeleton, blend: MixBlend): number; + applyRotateTimeline(timeline: Timeline, skeleton: Skeleton, time: number, alpha: number, blend: MixBlend, timelinesRotation: Array, i: number, firstFrame: boolean): void; + queueEvents(entry: TrackEntry, animationTime: number): void; + clearTracks(): void; + clearTrack(trackIndex: number): void; + setCurrent(index: number, current: TrackEntry, interrupt: boolean): void; + setAnimation(trackIndex: number, animationName: string, loop: boolean): TrackEntry; + setAnimationWith(trackIndex: number, animation: Animation, loop: boolean): TrackEntry; + addAnimation(trackIndex: number, animationName: string, loop: boolean, delay: number): TrackEntry; + addAnimationWith(trackIndex: number, animation: Animation, loop: boolean, delay: number): TrackEntry; + setEmptyAnimation(trackIndex: number, mixDuration: number): TrackEntry; + addEmptyAnimation(trackIndex: number, mixDuration: number, delay: number): TrackEntry; + setEmptyAnimations(mixDuration: number): void; + expandToIndex(index: number): TrackEntry; + trackEntry(trackIndex: number, animation: Animation, loop: boolean, last: TrackEntry): TrackEntry; + disposeNext(entry: TrackEntry): void; + _animationsChanged(): void; + computeHold(entry: TrackEntry): void; + computeNotLast(entry: TrackEntry): void; + getCurrent(trackIndex: number): TrackEntry; + addListener(listener: AnimationStateListener): void; + removeListener(listener: AnimationStateListener): void; + clearListeners(): void; + clearListenerNotifications(): void; + } + class TrackEntry { + animation: Animation; + next: TrackEntry; + mixingFrom: TrackEntry; + mixingTo: TrackEntry; + listener: AnimationStateListener; + trackIndex: number; + loop: boolean; + holdPrevious: boolean; + eventThreshold: number; + attachmentThreshold: number; + drawOrderThreshold: number; + animationStart: number; + animationEnd: number; + animationLast: number; + nextAnimationLast: number; + delay: number; + trackTime: number; + trackLast: number; + nextTrackLast: number; + trackEnd: number; + timeScale: number; + alpha: number; + mixTime: number; + mixDuration: number; + interruptAlpha: number; + totalAlpha: number; + mixBlend: MixBlend; + timelineMode: number[]; + timelineHoldMix: TrackEntry[]; + timelinesRotation: number[]; + reset(): void; + getAnimationTime(): number; + setAnimationLast(animationLast: number): void; + isComplete(): boolean; + resetRotationDirections(): void; + } + class EventQueue { + objects: Array; + drainDisabled: boolean; + animState: AnimationState; + constructor(animState: AnimationState); + start(entry: TrackEntry): void; + interrupt(entry: TrackEntry): void; + end(entry: TrackEntry): void; + dispose(entry: TrackEntry): void; + complete(entry: TrackEntry): void; + event(entry: TrackEntry, event: Event): void; + drain(): void; + clear(): void; + } + enum EventType { + start = 0, + interrupt = 1, + end = 2, + dispose = 3, + complete = 4, + event = 5 + } + interface AnimationStateListener { + start(entry: TrackEntry): void; + interrupt(entry: TrackEntry): void; + end(entry: TrackEntry): void; + dispose(entry: TrackEntry): void; + complete(entry: TrackEntry): void; + event(entry: TrackEntry, event: Event): void; + } + abstract class AnimationStateAdapter implements AnimationStateListener { + start(entry: TrackEntry): void; + interrupt(entry: TrackEntry): void; + end(entry: TrackEntry): void; + dispose(entry: TrackEntry): void; + complete(entry: TrackEntry): void; + event(entry: TrackEntry, event: Event): void; + } +} +declare namespace sp.spine { + class AnimationStateData { + skeletonData: SkeletonData; + animationToMixTime: Map; + defaultMix: number; + constructor(skeletonData: SkeletonData); + setMix(fromName: string, toName: string, duration: number): void; + setMixWith(from: Animation, to: Animation, duration: number): void; + getMix(from: Animation, to: Animation): number; + } +} +declare namespace sp.spine { + class AssetManager implements Disposable { + private pathPrefix; + private textureLoader; + private assets; + private errors; + private toLoad; + private loaded; + constructor(textureLoader: (image: HTMLImageElement) => any, pathPrefix?: string); + private static downloadText; + private static downloadBinary; + loadBinary(path: string, success?: (path: string, binary: Uint8Array) => void, error?: (path: string, error: string) => void): void; + loadText(path: string, success?: (path: string, text: string) => void, error?: (path: string, error: string) => void): void; + loadTexture(path: string, success?: (path: string, image: HTMLImageElement) => void, error?: (path: string, error: string) => void): void; + loadTextureData(path: string, data: string, success?: (path: string, image: HTMLImageElement) => void, error?: (path: string, error: string) => void): void; + loadTextureAtlas(path: string, success?: (path: string, atlas: TextureAtlas) => void, error?: (path: string, error: string) => void): void; + get(path: string): any; + remove(path: string): void; + removeAll(): void; + isLoadingComplete(): boolean; + getToLoad(): number; + getLoaded(): number; + dispose(): void; + hasErrors(): boolean; + getErrors(): Map; + } +} +declare namespace sp.spine { + class AtlasAttachmentLoader implements AttachmentLoader { + atlas: TextureAtlas; + constructor(atlas: TextureAtlas); + newRegionAttachment(skin: Skin, name: string, path: string): RegionAttachment; + newMeshAttachment(skin: Skin, name: string, path: string): MeshAttachment; + newBoundingBoxAttachment(skin: Skin, name: string): BoundingBoxAttachment; + newPathAttachment(skin: Skin, name: string): PathAttachment; + newPointAttachment(skin: Skin, name: string): PointAttachment; + newClippingAttachment(skin: Skin, name: string): ClippingAttachment; + } +} +declare namespace sp.spine { + enum BlendMode { + Normal = 0, + Additive = 1, + Multiply = 2, + Screen = 3 + } +} +declare namespace sp.spine { + class Bone implements Updatable { + data: BoneData; + skeleton: Skeleton; + parent: Bone; + children: Bone[]; + x: number; + y: number; + rotation: number; + scaleX: number; + scaleY: number; + shearX: number; + shearY: number; + ax: number; + ay: number; + arotation: number; + ascaleX: number; + ascaleY: number; + ashearX: number; + ashearY: number; + appliedValid: boolean; + a: number; + b: number; + c: number; + d: number; + worldY: number; + worldX: number; + sorted: boolean; + active: boolean; + constructor(data: BoneData, skeleton: Skeleton, parent: Bone); + isActive(): boolean; + update(): void; + updateWorldTransform(): void; + updateWorldTransformWith(x: number, y: number, rotation: number, scaleX: number, scaleY: number, shearX: number, shearY: number): void; + setToSetupPose(): void; + getWorldRotationX(): number; + getWorldRotationY(): number; + getWorldScaleX(): number; + getWorldScaleY(): number; + updateAppliedTransform(): void; + worldToLocal(world: Vector2): Vector2; + localToWorld(local: Vector2): Vector2; + worldToLocalRotation(worldRotation: number): number; + localToWorldRotation(localRotation: number): number; + rotateWorld(degrees: number): void; + } +} +declare namespace sp.spine { + class BoneData { + index: number; + name: string; + parent: BoneData; + length: number; + x: number; + y: number; + rotation: number; + scaleX: number; + scaleY: number; + shearX: number; + shearY: number; + transformMode: TransformMode; + skinRequired: boolean; + color: Color; + constructor(index: number, name: string, parent: BoneData); + } + enum TransformMode { + Normal = 0, + OnlyTranslation = 1, + NoRotationOrReflection = 2, + NoScale = 3, + NoScaleOrReflection = 4 + } +} +declare namespace sp.spine { + abstract class ConstraintData { + name: string; + order: number; + skinRequired: boolean; + constructor(name: string, order: number, skinRequired: boolean); + } +} +declare namespace sp.spine { + class Event { + data: EventData; + intValue: number; + floatValue: number; + stringValue: string; + time: number; + volume: number; + balance: number; + constructor(time: number, data: EventData); + } +} +declare namespace sp.spine { + class EventData { + name: string; + intValue: number; + floatValue: number; + stringValue: string; + audioPath: string; + volume: number; + balance: number; + constructor(name: string); + } +} +declare namespace sp.spine { + class IkConstraint implements Updatable { + data: IkConstraintData; + bones: Array; + target: Bone; + bendDirection: number; + compress: boolean; + stretch: boolean; + mix: number; + softness: number; + active: boolean; + constructor(data: IkConstraintData, skeleton: Skeleton); + isActive(): boolean; + apply(): void; + update(): void; + apply1(bone: Bone, targetX: number, targetY: number, compress: boolean, stretch: boolean, uniform: boolean, alpha: number): void; + apply2(parent: Bone, child: Bone, targetX: number, targetY: number, bendDir: number, stretch: boolean, softness: number, alpha: number): void; + } +} +declare namespace sp.spine { + class IkConstraintData extends ConstraintData { + bones: BoneData[]; + target: BoneData; + bendDirection: number; + compress: boolean; + stretch: boolean; + uniform: boolean; + mix: number; + softness: number; + constructor(name: string); + } +} +declare namespace sp.spine { + class PathConstraint implements Updatable { + static NONE: number; + static BEFORE: number; + static AFTER: number; + static epsilon: number; + data: PathConstraintData; + bones: Array; + target: Slot; + position: number; + spacing: number; + rotateMix: number; + translateMix: number; + spaces: number[]; + positions: number[]; + world: number[]; + curves: number[]; + lengths: number[]; + segments: number[]; + active: boolean; + constructor(data: PathConstraintData, skeleton: Skeleton); + isActive(): boolean; + apply(): void; + update(): void; + computeWorldPositions(path: PathAttachment, spacesCount: number, tangents: boolean, percentPosition: boolean, percentSpacing: boolean): number[]; + addBeforePosition(p: number, temp: Array, i: number, out: Array, o: number): void; + addAfterPosition(p: number, temp: Array, i: number, out: Array, o: number): void; + addCurvePosition(p: number, x1: number, y1: number, cx1: number, cy1: number, cx2: number, cy2: number, x2: number, y2: number, out: Array, o: number, tangents: boolean): void; + } +} +declare namespace sp.spine { + class PathConstraintData extends ConstraintData { + bones: BoneData[]; + target: SlotData; + positionMode: PositionMode; + spacingMode: SpacingMode; + rotateMode: RotateMode; + offsetRotation: number; + position: number; + spacing: number; + rotateMix: number; + translateMix: number; + constructor(name: string); + } + enum PositionMode { + Fixed = 0, + Percent = 1 + } + enum SpacingMode { + Length = 0, + Fixed = 1, + Percent = 2 + } + enum RotateMode { + Tangent = 0, + Chain = 1, + ChainScale = 2 + } +} +declare namespace sp.spine { + class SharedAssetManager implements Disposable { + private pathPrefix; + private clientAssets; + private queuedAssets; + private rawAssets; + private errors; + constructor(pathPrefix?: string); + private queueAsset; + loadText(clientId: string, path: string): void; + loadJson(clientId: string, path: string): void; + loadTexture(clientId: string, textureLoader: (image: HTMLImageElement) => any, path: string): void; + get(clientId: string, path: string): any; + private updateClientAssets; + isLoadingComplete(clientId: string): boolean; + dispose(): void; + hasErrors(): boolean; + getErrors(): Map; + } +} +declare namespace sp.spine { + class Skeleton { + data: SkeletonData; + bones: Array; + slots: Array; + drawOrder: Array; + ikConstraints: Array; + transformConstraints: Array; + pathConstraints: Array; + _updateCache: Updatable[]; + updateCacheReset: Updatable[]; + skin: Skin; + color: Color; + time: number; + scaleX: number; + scaleY: number; + x: number; + y: number; + constructor(data: SkeletonData); + updateCache(): void; + sortIkConstraint(constraint: IkConstraint): void; + sortPathConstraint(constraint: PathConstraint): void; + sortTransformConstraint(constraint: TransformConstraint): void; + sortPathConstraintAttachment(skin: Skin, slotIndex: number, slotBone: Bone): void; + sortPathConstraintAttachmentWith(attachment: Attachment, slotBone: Bone): void; + sortBone(bone: Bone): void; + sortReset(bones: Array): void; + updateWorldTransform(): void; + setToSetupPose(): void; + setBonesToSetupPose(): void; + setSlotsToSetupPose(): void; + getRootBone(): Bone; + findBone(boneName: string): Bone; + findBoneIndex(boneName: string): number; + findSlot(slotName: string): Slot; + findSlotIndex(slotName: string): number; + setSkinByName(skinName: string): void; + setSkin(newSkin: Skin): void; + getAttachmentByName(slotName: string, attachmentName: string): Attachment; + getAttachment(slotIndex: number, attachmentName: string): Attachment; + setAttachment(slotName: string, attachmentName: string): void; + findIkConstraint(constraintName: string): IkConstraint; + findTransformConstraint(constraintName: string): TransformConstraint; + findPathConstraint(constraintName: string): PathConstraint; + getBounds(offset: Vector2, size: Vector2, temp?: Array): void; + update(delta: number): void; + } +} +declare namespace sp.spine { + class SkeletonBinary { + static AttachmentTypeValues: number[]; + static TransformModeValues: TransformMode[]; + static PositionModeValues: PositionMode[]; + static SpacingModeValues: SpacingMode[]; + static RotateModeValues: RotateMode[]; + static BlendModeValues: BlendMode[]; + static BONE_ROTATE: number; + static BONE_TRANSLATE: number; + static BONE_SCALE: number; + static BONE_SHEAR: number; + static SLOT_ATTACHMENT: number; + static SLOT_COLOR: number; + static SLOT_TWO_COLOR: number; + static PATH_POSITION: number; + static PATH_SPACING: number; + static PATH_MIX: number; + static CURVE_LINEAR: number; + static CURVE_STEPPED: number; + static CURVE_BEZIER: number; + scale: number; + attachmentLoader: AttachmentLoader; + private linkedMeshes; + constructor(attachmentLoader: AttachmentLoader); + readSkeletonData(binary: Uint8Array): SkeletonData; + private readSkin; + private readAttachment; + private readVertices; + private readFloatArray; + private readShortArray; + private readAnimation; + private readCurve; + setCurve(timeline: CurveTimeline, frameIndex: number, cx1: number, cy1: number, cx2: number, cy2: number): void; + } +} +declare namespace sp.spine { + class SkeletonBounds { + minX: number; + minY: number; + maxX: number; + maxY: number; + boundingBoxes: BoundingBoxAttachment[]; + polygons: ArrayLike[]; + private polygonPool; + update(skeleton: Skeleton, updateAabb: boolean): void; + aabbCompute(): void; + aabbContainsPoint(x: number, y: number): boolean; + aabbIntersectsSegment(x1: number, y1: number, x2: number, y2: number): boolean; + aabbIntersectsSkeleton(bounds: SkeletonBounds): boolean; + containsPoint(x: number, y: number): BoundingBoxAttachment; + containsPointPolygon(polygon: ArrayLike, x: number, y: number): boolean; + intersectsSegment(x1: number, y1: number, x2: number, y2: number): BoundingBoxAttachment; + intersectsSegmentPolygon(polygon: ArrayLike, x1: number, y1: number, x2: number, y2: number): boolean; + getPolygon(boundingBox: BoundingBoxAttachment): ArrayLike; + getWidth(): number; + getHeight(): number; + } +} +declare namespace sp.spine { + class SkeletonClipping { + private triangulator; + private clippingPolygon; + private clipOutput; + clippedVertices: number[]; + clippedTriangles: number[]; + private scratch; + private clipAttachment; + private clippingPolygons; + clipStart(slot: Slot, clip: ClippingAttachment): number; + clipEndWithSlot(slot: Slot): void; + clipEnd(): void; + isClipping(): boolean; + clipTriangles(vertices: ArrayLike, verticesLength: number, triangles: ArrayLike, trianglesLength: number, uvs: ArrayLike, light: Color, dark: Color, twoColor: boolean): void; + clip(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, clippingArea: Array, output: Array): boolean; + static makeClockwise(polygon: ArrayLike): void; + } +} +declare namespace sp.spine { + class SkeletonData { + name: string; + bones: BoneData[]; + slots: SlotData[]; + skins: Skin[]; + defaultSkin: Skin; + events: EventData[]; + animations: Animation[]; + ikConstraints: IkConstraintData[]; + transformConstraints: TransformConstraintData[]; + pathConstraints: PathConstraintData[]; + x: number; + y: number; + width: number; + height: number; + version: string; + hash: string; + fps: number; + imagesPath: string; + audioPath: string; + findBone(boneName: string): BoneData; + findBoneIndex(boneName: string): number; + findSlot(slotName: string): SlotData; + findSlotIndex(slotName: string): number; + findSkin(skinName: string): Skin; + findEvent(eventDataName: string): EventData; + findAnimation(animationName: string): Animation; + findIkConstraint(constraintName: string): IkConstraintData; + findTransformConstraint(constraintName: string): TransformConstraintData; + findPathConstraint(constraintName: string): PathConstraintData; + findPathConstraintIndex(pathConstraintName: string): number; + } +} +declare namespace sp.spine { + class SkeletonJson { + attachmentLoader: AttachmentLoader; + scale: number; + private linkedMeshes; + constructor(attachmentLoader: AttachmentLoader); + readSkeletonData(json: string | any): SkeletonData; + readAttachment(map: any, skin: Skin, slotIndex: number, name: string, skeletonData: SkeletonData): Attachment; + readVertices(map: any, attachment: VertexAttachment, verticesLength: number): void; + readAnimation(map: any, name: string, skeletonData: SkeletonData): void; + readCurve(map: any, timeline: CurveTimeline, frameIndex: number): void; + getValue(map: any, prop: string, defaultValue: any): any; + static blendModeFromString(str: string): BlendMode; + static positionModeFromString(str: string): PositionMode; + static spacingModeFromString(str: string): SpacingMode; + static rotateModeFromString(str: string): RotateMode; + static transformModeFromString(str: string): TransformMode; + } +} +declare namespace sp.spine { + class SkinEntry { + slotIndex: number; + name: string; + attachment: Attachment; + constructor(slotIndex: number, name: string, attachment: Attachment); + } + class Skin { + name: string; + attachments: Map[]; + bones: BoneData[]; + constraints: ConstraintData[]; + constructor(name: string); + setAttachment(slotIndex: number, name: string, attachment: Attachment): void; + addSkin(skin: Skin): void; + copySkin(skin: Skin): void; + getAttachment(slotIndex: number, name: string): Attachment; + removeAttachment(slotIndex: number, name: string): void; + getAttachments(): Array; + getAttachmentsForSlot(slotIndex: number, attachments: Array): void; + clear(): void; + attachAll(skeleton: Skeleton, oldSkin: Skin): void; + } +} +declare namespace sp.spine { + class Slot { + data: SlotData; + bone: Bone; + color: Color; + darkColor: Color; + private attachment; + private attachmentTime; + deform: number[]; + constructor(data: SlotData, bone: Bone); + getSkeleton(): Skeleton; + getAttachment(): Attachment; + setAttachment(attachment: Attachment): void; + setAttachmentTime(time: number): void; + getAttachmentTime(): number; + setToSetupPose(): void; + } +} +declare namespace sp.spine { + class SlotData { + index: number; + name: string; + boneData: BoneData; + color: Color; + darkColor: Color; + attachmentName: string; + blendMode: BlendMode; + constructor(index: number, name: string, boneData: BoneData); + } +} +declare namespace sp.spine { + abstract class Texture { + protected _image: HTMLImageElement; + constructor(image: HTMLImageElement); + getImage(): HTMLImageElement; + abstract setFilters(minFilter: TextureFilter, magFilter: TextureFilter): void; + abstract setWraps(uWrap: TextureWrap, vWrap: TextureWrap): void; + abstract dispose(): void; + static filterFromString(text: string): TextureFilter; + static wrapFromString(text: string): TextureWrap; + } + enum TextureFilter { + Nearest = 9728, + Linear = 9729, + MipMap = 9987, + MipMapNearestNearest = 9984, + MipMapLinearNearest = 9985, + MipMapNearestLinear = 9986, + MipMapLinearLinear = 9987 + } + enum TextureWrap { + MirroredRepeat = 33648, + ClampToEdge = 33071, + Repeat = 10497 + } + class TextureRegion { + renderObject: any; + u: number; + v: number; + u2: number; + v2: number; + width: number; + height: number; + rotate: boolean; + offsetX: number; + offsetY: number; + originalWidth: number; + originalHeight: number; + } + class FakeTexture extends Texture { + setFilters(minFilter: TextureFilter, magFilter: TextureFilter): void; + setWraps(uWrap: TextureWrap, vWrap: TextureWrap): void; + dispose(): void; + } +} +declare namespace sp.spine { + class TextureAtlas implements Disposable { + pages: TextureAtlasPage[]; + regions: TextureAtlasRegion[]; + constructor(atlasText: string, textureLoader: (path: string) => any); + private load; + findRegion(name: string): TextureAtlasRegion; + dispose(): void; + } + class TextureAtlasPage { + name: string; + minFilter: TextureFilter; + magFilter: TextureFilter; + uWrap: TextureWrap; + vWrap: TextureWrap; + texture: Texture; + width: number; + height: number; + } + class TextureAtlasRegion extends TextureRegion { + page: TextureAtlasPage; + name: string; + x: number; + y: number; + index: number; + rotate: boolean; + degrees: number; + texture: Texture; + } +} +declare namespace sp.spine { + class TransformConstraint implements Updatable { + data: TransformConstraintData; + bones: Array; + target: Bone; + rotateMix: number; + translateMix: number; + scaleMix: number; + shearMix: number; + temp: Vector2; + active: boolean; + constructor(data: TransformConstraintData, skeleton: Skeleton); + isActive(): boolean; + apply(): void; + update(): void; + applyAbsoluteWorld(): void; + applyRelativeWorld(): void; + applyAbsoluteLocal(): void; + applyRelativeLocal(): void; + } +} +declare namespace sp.spine { + class TransformConstraintData extends ConstraintData { + bones: BoneData[]; + target: BoneData; + rotateMix: number; + translateMix: number; + scaleMix: number; + shearMix: number; + offsetRotation: number; + offsetX: number; + offsetY: number; + offsetScaleX: number; + offsetScaleY: number; + offsetShearY: number; + relative: boolean; + local: boolean; + constructor(name: string); + } +} +declare namespace sp.spine { + class Triangulator { + private convexPolygons; + private convexPolygonsIndices; + private indicesArray; + private isConcaveArray; + private triangles; + private polygonPool; + private polygonIndicesPool; + triangulate(verticesArray: ArrayLike): Array; + decompose(verticesArray: Array, triangles: Array): Array>; + private static isConcave; + private static positiveArea; + private static winding; + } +} +declare namespace sp.spine { + interface Updatable { + update(): void; + isActive(): boolean; + } +} +declare namespace sp.spine { + interface Map { + [key: string]: T; + } + class IntSet { + array: number[]; + add(value: number): boolean; + contains(value: number): boolean; + remove(value: number): void; + clear(): void; + } + interface Disposable { + dispose(): void; + } + interface Restorable { + restore(): void; + } + class Color { + r: number; + g: number; + b: number; + a: number; + static WHITE: Color; + static RED: Color; + static GREEN: Color; + static BLUE: Color; + static MAGENTA: Color; + constructor(r?: number, g?: number, b?: number, a?: number); + set(r: number, g: number, b: number, a: number): this; + setFromColor(c: Color): this; + setFromString(hex: string): this; + add(r: number, g: number, b: number, a: number): this; + clamp(): this; + static rgba8888ToColor(color: Color, value: number): void; + static rgb888ToColor(color: Color, value: number): void; + } + class MathUtils { + static PI: number; + static PI2: number; + static radiansToDegrees: number; + static radDeg: number; + static degreesToRadians: number; + static degRad: number; + static clamp(value: number, min: number, max: number): number; + static cosDeg(degrees: number): number; + static sinDeg(degrees: number): number; + static signum(value: number): number; + static toInt(x: number): number; + static cbrt(x: number): number; + static randomTriangular(min: number, max: number): number; + static randomTriangularWith(min: number, max: number, mode: number): number; + } + abstract class Interpolation { + protected abstract applyInternal(a: number): number; + apply(start: number, end: number, a: number): number; + } + class Pow extends Interpolation { + protected power: number; + constructor(power: number); + applyInternal(a: number): number; + } + class PowOut extends Pow { + constructor(power: number); + applyInternal(a: number): number; + } + class Utils { + static SUPPORTS_TYPED_ARRAYS: boolean; + static arrayCopy(source: ArrayLike, sourceStart: number, dest: ArrayLike, destStart: number, numElements: number): void; + static setArraySize(array: Array, size: number, value?: any): Array; + static ensureArrayCapacity(array: Array, size: number, value?: any): Array; + static newArray(size: number, defaultValue: T): Array; + static newFloatArray(size: number): ArrayLike; + static newShortArray(size: number): ArrayLike; + static toFloatArray(array: Array): number[] | Float32Array; + static toSinglePrecision(value: number): number; + static webkit602BugfixHelper(alpha: number, blend: MixBlend): void; + static contains(array: Array, element: T, identity?: boolean): boolean; + } + class DebugUtils { + static logBones(skeleton: Skeleton): void; + } + class Pool { + private items; + private instantiator; + constructor(instantiator: () => T); + obtain(): T; + free(item: T): void; + freeAll(items: ArrayLike): void; + clear(): void; + } + class Vector2 { + x: number; + y: number; + constructor(x?: number, y?: number); + set(x: number, y: number): Vector2; + length(): number; + normalize(): this; + } + class TimeKeeper { + maxDelta: number; + framesPerSecond: number; + delta: number; + totalTime: number; + private lastTime; + private frameCount; + private frameTime; + update(): void; + } + interface ArrayLike { + length: number; + [n: number]: T; + } + class WindowedMean { + values: Array; + addedValues: number; + lastValue: number; + mean: number; + dirty: boolean; + constructor(windowSize?: number); + hasEnoughData(): boolean; + addValue(value: number): void; + getMean(): number; + } +} +declare namespace sp.spine { + interface VertexEffect { + begin(skeleton: Skeleton): void; + transform(position: Vector2, uv: Vector2, light: Color, dark: Color): void; + end(): void; + } +} +interface Math { + fround(n: number): number; +} +declare namespace sp.spine { + abstract class Attachment { + name: string; + constructor(name: string); + abstract copy(): Attachment; + } + abstract class VertexAttachment extends Attachment { + private static nextID; + id: number; + bones: Array; + vertices: ArrayLike; + worldVerticesLength: number; + deformAttachment: VertexAttachment; + constructor(name: string); + computeWorldVertices(slot: Slot, start: number, count: number, worldVertices: ArrayLike, offset: number, stride: number): void; + copyTo(attachment: VertexAttachment): void; + } +} +declare namespace sp.spine { + interface AttachmentLoader { + newRegionAttachment(skin: Skin, name: string, path: string): RegionAttachment; + newMeshAttachment(skin: Skin, name: string, path: string): MeshAttachment; + newBoundingBoxAttachment(skin: Skin, name: string): BoundingBoxAttachment; + newPathAttachment(skin: Skin, name: string): PathAttachment; + newPointAttachment(skin: Skin, name: string): PointAttachment; + newClippingAttachment(skin: Skin, name: string): ClippingAttachment; + } +} +declare namespace sp.spine { + enum AttachmentType { + Region = 0, + BoundingBox = 1, + Mesh = 2, + LinkedMesh = 3, + Path = 4, + Point = 5, + Clipping = 6 + } +} +declare namespace sp.spine { + class BoundingBoxAttachment extends VertexAttachment { + color: Color; + constructor(name: string); + copy(): Attachment; + } +} +declare namespace sp.spine { + class ClippingAttachment extends VertexAttachment { + endSlot: SlotData; + color: Color; + constructor(name: string); + copy(): Attachment; + } +} +declare namespace sp.spine { + class MeshAttachment extends VertexAttachment { + region: TextureRegion; + path: string; + regionUVs: ArrayLike; + uvs: ArrayLike; + triangles: Array; + color: Color; + width: number; + height: number; + hullLength: number; + edges: Array; + private parentMesh; + tempColor: Color; + constructor(name: string); + updateUVs(): void; + getParentMesh(): MeshAttachment; + setParentMesh(parentMesh: MeshAttachment): void; + copy(): Attachment; + newLinkedMesh(): MeshAttachment; + } +} +declare namespace sp.spine { + class PathAttachment extends VertexAttachment { + lengths: Array; + closed: boolean; + constantSpeed: boolean; + color: Color; + constructor(name: string); + copy(): Attachment; + } +} +declare namespace sp.spine { + class PointAttachment extends VertexAttachment { + x: number; + y: number; + rotation: number; + color: Color; + constructor(name: string); + computeWorldPosition(bone: Bone, point: Vector2): Vector2; + computeWorldRotation(bone: Bone): number; + copy(): Attachment; + } +} +declare namespace sp.spine { + class RegionAttachment extends Attachment { + static OX1: number; + static OY1: number; + static OX2: number; + static OY2: number; + static OX3: number; + static OY3: number; + static OX4: number; + static OY4: number; + static X1: number; + static Y1: number; + static C1R: number; + static C1G: number; + static C1B: number; + static C1A: number; + static U1: number; + static V1: number; + static X2: number; + static Y2: number; + static C2R: number; + static C2G: number; + static C2B: number; + static C2A: number; + static U2: number; + static V2: number; + static X3: number; + static Y3: number; + static C3R: number; + static C3G: number; + static C3B: number; + static C3A: number; + static U3: number; + static V3: number; + static X4: number; + static Y4: number; + static C4R: number; + static C4G: number; + static C4B: number; + static C4A: number; + static U4: number; + static V4: number; + x: number; + y: number; + scaleX: number; + scaleY: number; + rotation: number; + width: number; + height: number; + color: Color; + path: string; + rendererObject: any; + region: TextureRegion; + offset: ArrayLike; + uvs: ArrayLike; + tempColor: Color; + constructor(name: string); + updateOffset(): void; + setRegion(region: TextureRegion): void; + computeWorldVertices(bone: Bone, worldVertices: ArrayLike, offset: number, stride: number): void; + copy(): Attachment; + } +} +declare namespace sp.spine { + class JitterEffect implements VertexEffect { + jitterX: number; + jitterY: number; + constructor(jitterX: number, jitterY: number); + begin(skeleton: Skeleton): void; + transform(position: Vector2, uv: Vector2, light: Color, dark: Color): void; + end(): void; + } +} +declare namespace sp.spine { + class SwirlEffect implements VertexEffect { + static interpolation: PowOut; + centerX: number; + centerY: number; + radius: number; + angle: number; + private worldX; + private worldY; + constructor(radius: number); + begin(skeleton: Skeleton): void; + transform(position: Vector2, uv: Vector2, light: Color, dark: Color): void; + end(): void; + } +} + + +declare interface Math { + sign(v: number); +} + +declare interface Object { + assign(target: {}, source: {}); +} + +/** + * API for jsb module + * Author: haroel + * Homepage: https://github.com/haroel/creatorexDTS + */ +declare namespace jsb{ + export module reflection{ + /** + * https://docs.cocos.com/creator/manual/zh/advanced-topics/java-reflection.html + * call OBJC/Java static methods + * + * @param className + * @param methodName + * @param methodSignature + * @param parameters + */ + export function callStaticMethod(className: string, methodName: string, methodSignature: string, ...parameters:any): any; + } + /** + * 下载任务对象 + */ + export type DownloaderTask = { requestURL: string, storagePath: string, identifier: string }; + + /** + * Http file downloader for jsb! + */ + export class Downloader{ + /** + * create a download task + * @param requestURL + * @param storagePath + * @param identifier + */ + createDownloadFileTask(requestURL:string, storagePath:string, identifier?:string): DownloaderTask; + + setOnFileTaskSuccess(onSucceed: (task: DownloaderTask) => void): void; + + setOnTaskProgress(onProgress: (task: DownloaderTask, bytesReceived: number, totalBytesReceived: number, totalBytesExpected: number) => void): void; + + setOnTaskError(onError: (task: DownloaderTask, errorCode: number, errorCodeInternal: number, errorStr: string) => void): void; + + } + + /** + * FileUtils Helper class to handle file operations. + */ + export module fileUtils{ + /** + * Checks whether the path is an absolute path. + * + * @note On Android, if the parameter passed in is relative to "@assets/", this method will treat it as an absolute path. + * Also on Blackberry, path starts with "app/native/Resources/" is treated as an absolute path. + * + * @param path The path that needs to be checked. + * @return True if it's an absolute path, false if not. + */ + export function isAbsolutePath(path:string):boolean; + /** Returns the fullpath for a given filename. + + First it will try to get a new filename from the "filenameLookup" dictionary. + If a new filename can't be found on the dictionary, it will use the original filename. + Then it will try to obtain the full path of the filename using the FileUtils search rules: resolutions, and search paths. + The file search is based on the array element order of search paths and resolution directories. + + For instance: + + We set two elements("/mnt/sdcard/", "internal_dir/") to search paths vector by setSearchPaths, + and set three elements("resources-ipadhd/", "resources-ipad/", "resources-iphonehd") + to resolutions vector by setSearchResolutionsOrder. The "internal_dir" is relative to "Resources/". + + If we have a file named 'sprite.png', the mapping in fileLookup dictionary contains `key: sprite.png -> value: sprite.pvr.gz`. + Firstly, it will replace 'sprite.png' with 'sprite.pvr.gz', then searching the file sprite.pvr.gz as follows: + + /mnt/sdcard/resources-ipadhd/sprite.pvr.gz (if not found, search next) + /mnt/sdcard/resources-ipad/sprite.pvr.gz (if not found, search next) + /mnt/sdcard/resources-iphonehd/sprite.pvr.gz (if not found, search next) + /mnt/sdcard/sprite.pvr.gz (if not found, search next) + internal_dir/resources-ipadhd/sprite.pvr.gz (if not found, search next) + internal_dir/resources-ipad/sprite.pvr.gz (if not found, search next) + internal_dir/resources-iphonehd/sprite.pvr.gz (if not found, search next) + internal_dir/sprite.pvr.gz (if not found, return "sprite.png") + + If the filename contains relative path like "gamescene/uilayer/sprite.png", + and the mapping in fileLookup dictionary contains `key: gamescene/uilayer/sprite.png -> value: gamescene/uilayer/sprite.pvr.gz`. + The file search order will be: + + /mnt/sdcard/gamescene/uilayer/resources-ipadhd/sprite.pvr.gz (if not found, search next) + /mnt/sdcard/gamescene/uilayer/resources-ipad/sprite.pvr.gz (if not found, search next) + /mnt/sdcard/gamescene/uilayer/resources-iphonehd/sprite.pvr.gz (if not found, search next) + /mnt/sdcard/gamescene/uilayer/sprite.pvr.gz (if not found, search next) + internal_dir/gamescene/uilayer/resources-ipadhd/sprite.pvr.gz (if not found, search next) + internal_dir/gamescene/uilayer/resources-ipad/sprite.pvr.gz (if not found, search next) + internal_dir/gamescene/uilayer/resources-iphonehd/sprite.pvr.gz (if not found, search next) + internal_dir/gamescene/uilayer/sprite.pvr.gz (if not found, return "gamescene/uilayer/sprite.png") + + If the new file can't be found on the file system, it will return the parameter filename directly. + + This method was added to simplify multiplatform support. Whether you are using cocos2d-js or any cross-compilation toolchain like StellaSDK or Apportable, + you might need to load different resources for a given file in the different platforms. + + @since v2.1 + */ + export function fullPathForFilename(filename:string):string; + /** + * Gets string from a file. + */ + export function getStringFromFile(filename:string):string; + /** + * Removes a file. + * + * @param filepath The full path of the file, it must be an absolute path. + * @return True if the file have been removed successfully, false if not. + */ + export function removeFile(filepath:string):boolean; + /** + * Checks whether the path is a directory. + * + * @param dirPath The path of the directory, it could be a relative or an absolute path. + * @return True if the directory exists, false if not. + */ + export function isDirectoryExist(dirPath:string):boolean; + /** + * Normalize: remove . and .. + * @param filepath + */ + export function normalizePath(filepath:string):string; + /** + * Get default resource root path. + */ + export function getDefaultResourceRootPath():string; + /** + * Loads the filenameLookup dictionary from the contents of a filename. + * + * @note The plist file name should follow the format below: + * + * @code + * + * + * + * + * filenames + * + * sounds/click.wav + * sounds/click.caf + * sounds/endgame.wav + * sounds/endgame.caf + * sounds/gem-0.wav + * sounds/gem-0.caf + * + * metadata + * + * version + * 1 + * + * + * + * @endcode + * @param filename The plist file name. + * + @since v2.1 + * @js loadFilenameLookup + * @lua loadFilenameLookup + */ + export function loadFilenameLookup(filepath:string):void; + /** Checks whether to pop up a message box when failed to load an image. + * @return True if pop up a message box when failed to load an image, false if not. + */ + export function isPopupNotify():boolean; + /** + * Sets whether to pop-up a message box when failed to load an image. + */ + export function setPopupNotify(notify:boolean):void; + + // Converts the contents of a file to a ValueVector. + // This method is used internally. + export function getValueVectorFromFile(filepath:string):Array; + /** + * Gets the array of search paths. + * + * @return The array of search paths which may contain the prefix of default resource root path. + * @note In best practise, getter function should return the value of setter function passes in. + * But since we should not break the compatibility, we keep using the old logic. + * Therefore, If you want to get the original search paths, please call 'getOriginalSearchPaths()' instead. + * @see fullPathForFilename(const char*). + * @lua NA + */ + export function getSearchPaths(filepath:string):Array; + /** + * + * @param filepath + */ + export function getFileDir(filepath:string):string; + /** + * write a ValueMap into a plist file + * + *@param dict the ValueMap want to save (key,value) + *@param fullPath The full path to the file you want to save a string + *@return bool + */ + export function writeToFile( valueMap:any ):boolean; + /** + * Gets the original search path array set by 'setSearchPaths' or 'addSearchPath'. + * @return The array of the original search paths + */ + export function getOriginalSearchPaths():Array; + /** + * List all files in a directory. + * + * @param dirPath The path of the directory, it could be a relative or an absolute path. + * @return File paths in a string vector + */ + export function listFiles(filepath:string):Array; + /** + * Converts the contents of a file to a ValueMap. + * @param filename The filename of the file to gets content. + * @return ValueMap of the file contents. + * @note This method is used internally. + */ + export function getValueMapFromFile(filepath:string):any; + /** + * Retrieve the file size. + * + * @note If a relative path was passed in, it will be inserted a default root path at the beginning. + * @param filepath The path of the file, it could be a relative or absolute path. + * @return The file size. + */ + export function getFileSize(filepath:string):number; + + /** Converts the contents of a file to a ValueMap. + * This method is used internally. + */ + export function getValueMapFromData(filedata:string,filesize:number):any; + /** + * Removes a directory. + * + * @param dirPath The full path of the directory, it must be an absolute path. + * @return True if the directory have been removed successfully, false if not. + */ + export function removeDirectory(dirPath:string):boolean; + /** + * Sets the array of search paths. + * + * You can use this array to modify the search path of the resources. + * If you want to use "themes" or search resources in the "cache", you can do it easily by adding new entries in this array. + * + * @note This method could access relative path and absolute path. + * If the relative path was passed to the vector, FileUtils will add the default resource directory before the relative path. + * For instance: + * On Android, the default resource root path is "@assets/". + * If "/mnt/sdcard/" and "resources-large" were set to the search paths vector, + * "resources-large" will be converted to "@assets/resources-large" since it was a relative path. + * + * @param searchPaths The array contains search paths. + * @see fullPathForFilename(const char*) + * @since v2.1 + * In js:var setSearchPaths(var jsval); + * @lua NA + */ + export function setSearchPaths( searchPath:Array):void; + /** + * write a string into a file + * + * @param dataStr the string want to save + * @param fullPath The full path to the file you want to save a string + * @return bool True if write success + */ + export function writeStringToFile(dataStr:string,fullPath:string):boolean; + /** + * Sets the array that contains the search order of the resources. + * + * @param searchResolutionsOrder The source array that contains the search order of the resources. + * @see getSearchResolutionsOrder(), fullPathForFilename(const char*). + * @since v2.1 + * In js:var setSearchResolutionsOrder(var jsval) + * @lua NA + */ + export function setSearchResolutionsOrder(searchResolutionsOrder:Array):void; + /** + * Append search order of the resources. + * + * @see setSearchResolutionsOrder(), fullPathForFilename(). + * @since v2.1 + */ + export function addSearchResolutionsOrder(order:string,front:boolean):void; + /** + * Add search path. + * + * @since v2.1 + */ + export function addSearchPath(path:string,front:boolean):void; + /** + * write ValueVector into a plist file + * + *@param vecData the ValueVector want to save + *@param fullPath The full path to the file you want to save a string + *@return bool + */ + export function writeValueVectorToFile(vecData:Array,fullPath:string):boolean; + /** + * Checks whether a file exists. + * + * @note If a relative path was passed in, it will be inserted a default root path at the beginning. + * @param filename The path of the file, it could be a relative or absolute path. + * @return True if the file exists, false if not. + */ + export function isFileExist(filename:string):boolean; + /**©∫ + * Purges full path caches. + */ + export function purgeCachedEntries():void; + /** + * Gets full path from a file name and the path of the relative file. + * @param filename The file name. + * @param relativeFile The path of the relative file. + * @return The full path. + * e.g. filename: hello.png, pszRelativeFile: /User/path1/path2/hello.plist + * Return: /User/path1/path2/hello.pvr (If there a a key(hello.png)-value(hello.pvr) in FilenameLookup dictionary. ) + * + */ + export function fullPathFromRelativeFile(filename:string,relativeFile:string):string; + /** + * Windows fopen can't support UTF-8 filename + * Need convert all parameters fopen and other 3rd-party libs + * + * @param filenameUtf8 std::string name file for conversion from utf-8 + * @return std::string ansi filename in current locale + */ + export function getSuitableFOpen(filenameUtf8:string):string; + /** + * write ValueMap into a plist file + * + *@param dict the ValueMap want to save + *@param fullPath The full path to the file you want to save a string + *@return bool + */ + export function writeValueMapToFile(dict:any,fullPath:string):string; + /** + * Gets filename extension is a suffix (separated from the base filename by a dot) in lower case. + * Examples of filename extensions are .png, .jpeg, .exe, .dmg and .txt. + * @param filePath The path of the file, it could be a relative or absolute path. + * @return suffix for filename in lower case or empty if a dot not found. + */ + export function getFileExtension(filePath:string):string; + /** + * Sets writable path. + */ + export function setWritablePath(writablePath:string):void; + /** + * Set default resource root path. + */ + export function setDefaultResourceRootPath(filepath:string):void; + + /** + * Gets the array that contains the search order of the resources. + * + * @see setSearchResolutionsOrder(const std::vector&), fullPathForFilename(const char*). + * @since v2.1 + * @lua NA + */ + export function getSearchResolutionsOrder():Array; + /** + * Creates a directory. + * + * @param dirPath The path of the directory, it must be an absolute path. + * @return True if the directory have been created successfully, false if not. + */ + export function createDirectory(dirPath:string):string; + /** + * List all files recursively in a directory. + * + * @param dirPath The path of the directory, it could be a relative or an absolute path. + * @return File paths in a string vector + */ + export function listFilesRecursively(dirPath:string, files:Array):void; + /** + * Gets the writable path. + * @return The path that can be write/read a file in + */ + export function getWritablePath():string; + } +} + +/** Running in the editor. */ +declare const CC_EDITOR: boolean; +/** Preview in browser or simulator. */ +declare const CC_PREVIEW: boolean; +/** Running in the editor or preview. */ +declare const CC_DEV: boolean; +/** Running in the editor or preview, or build in debug mode. */ +declare const CC_DEBUG: boolean; +/** Running in published project. */ +declare const CC_BUILD: boolean; +/** Running in native platforms (mobile app, desktop app, or simulator). */ +declare const CC_JSB: boolean; +/** Running in runtime environments. */ +declare const CC_RUNTIME: boolean; +/** Running in the engine's unit test. */ +declare const CC_TEST: boolean; +/** Running in the WeChat Mini Game. */ +declare const CC_WECHATGAME: boolean; diff --git a/DncryptDemo/jsconfig.json b/DncryptDemo/jsconfig.json new file mode 100644 index 0000000..80c2563 --- /dev/null +++ b/DncryptDemo/jsconfig.json @@ -0,0 +1,15 @@ +{ + "compilerOptions": { + "target": "es6", + "module": "commonjs", + "experimentalDecorators": true + }, + "exclude": [ + "node_modules", + ".vscode", + "library", + "local", + "settings", + "temp" + ] +} \ No newline at end of file diff --git a/DncryptDemo/project.json b/DncryptDemo/project.json new file mode 100644 index 0000000..42f8d7b --- /dev/null +++ b/DncryptDemo/project.json @@ -0,0 +1,9 @@ +{ + "engine": "cocos2d-html5", + "packages": "packages", + "version": "2.3.3", + "name": "DncryptDemo", + "uuid": "e24b7d1c-2b1a-4104-8f1d-26a2f8240f2f", + "id": "18b5027d-70b2-4bcd-9204-818c7ad35c72", + "isNew": false +} \ No newline at end of file diff --git a/DncryptDemo/settings/builder.json b/DncryptDemo/settings/builder.json new file mode 100644 index 0000000..09f915c --- /dev/null +++ b/DncryptDemo/settings/builder.json @@ -0,0 +1,13 @@ +{ + "excludeScenes": [], + "orientation": { + "landscapeLeft": true, + "landscapeRight": true, + "portrait": false, + "upsideDown": false + }, + "packageName": "org.cocos2d.helloworld", + "startScene": "2d2f792f-a40c-49bb-a189-ed176a246e49", + "title": "hello_world", + "webOrientation": "auto" +} \ No newline at end of file diff --git a/DncryptDemo/settings/builder.panel.json b/DncryptDemo/settings/builder.panel.json new file mode 100644 index 0000000..6a7c356 --- /dev/null +++ b/DncryptDemo/settings/builder.panel.json @@ -0,0 +1,7 @@ +{ + "excludeScenes": [], + "packageName": "org.cocos2d.helloworld", + "platform": "web-mobile", + "startScene": "2d2f792f-a40c-49bb-a189-ed176a246e49", + "title": "HelloWorld" +} \ No newline at end of file diff --git a/DncryptDemo/settings/project.json b/DncryptDemo/settings/project.json new file mode 100644 index 0000000..1239abe --- /dev/null +++ b/DncryptDemo/settings/project.json @@ -0,0 +1,36 @@ +{ + "collision-matrix": [ + [ + true + ] + ], + "excluded-modules": [], + "group-list": [ + "default" + ], + "start-scene": "2d2f792f-a40c-49bb-a189-ed176a246e49", + "design-resolution-width": 960, + "design-resolution-height": 640, + "fit-width": false, + "fit-height": true, + "use-project-simulator-setting": false, + "simulator-orientation": false, + "use-customize-simulator": false, + "simulator-resolution": { + "width": 960, + "height": 640 + }, + "last-module-event-record-time": 0, + "assets-sort-type": "name", + "facebook": { + "enable": false, + "appID": "", + "live": { + "enable": false + }, + "audience": { + "enable": false + } + }, + "migrate-history": [] +} diff --git a/DncryptDemo/settings/services.json b/DncryptDemo/settings/services.json new file mode 100644 index 0000000..599b09e --- /dev/null +++ b/DncryptDemo/settings/services.json @@ -0,0 +1,6 @@ +{ + "game": { + "name": "未知游戏", + "appid": "UNKNOW" + } +} \ No newline at end of file diff --git a/DncryptDemo/template-banner.png b/DncryptDemo/template-banner.png new file mode 100644 index 0000000..d24a435 Binary files /dev/null and b/DncryptDemo/template-banner.png differ diff --git a/DncryptDemo/template.json b/DncryptDemo/template.json new file mode 100644 index 0000000..3bcc784 --- /dev/null +++ b/DncryptDemo/template.json @@ -0,0 +1,5 @@ +{ + "name": "TEMPLATES.helloworld.name", + "desc": "TEMPLATES.helloworld.desc", + "banner": "template-banner.png" +} \ No newline at end of file diff --git a/DncryptDemo/tsconfig.json b/DncryptDemo/tsconfig.json new file mode 100644 index 0000000..93c0b22 --- /dev/null +++ b/DncryptDemo/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ "es2015", "es2017", "dom" ], + "target": "es5", + "experimentalDecorators": true, + "skipLibCheck": true, + "outDir": "temp/vscode-dist", + "forceConsistentCasingInFileNames": true + }, + "exclude": [ + "node_modules", + "library", + "local", + "temp", + "build", + "settings" + ] +} \ No newline at end of file diff --git a/FakeLoadingBar/.gitignore b/FakeLoadingBar/.gitignore new file mode 100644 index 0000000..0c09bf3 --- /dev/null +++ b/FakeLoadingBar/.gitignore @@ -0,0 +1,51 @@ +#///////////////////////////////////////////////////////////////////////////// +# Fireball Projects +#///////////////////////////////////////////////////////////////////////////// + +/library/ +/temp/ +/local/ +/build/ + +#///////////////////////////////////////////////////////////////////////////// +# npm files +#///////////////////////////////////////////////////////////////////////////// + +npm-debug.log +node_modules/ + +#///////////////////////////////////////////////////////////////////////////// +# Logs and databases +#///////////////////////////////////////////////////////////////////////////// + +*.log +*.sql +*.sqlite + +#///////////////////////////////////////////////////////////////////////////// +# files for debugger +#///////////////////////////////////////////////////////////////////////////// + +*.sln +*.pidb +*.suo + +#///////////////////////////////////////////////////////////////////////////// +# OS generated files +#///////////////////////////////////////////////////////////////////////////// + +.DS_Store +ehthumbs.db +Thumbs.db + +#///////////////////////////////////////////////////////////////////////////// +# WebStorm files +#///////////////////////////////////////////////////////////////////////////// + +.idea/ + +#////////////////////////// +# VS Code files +#////////////////////////// + +.vscode/ diff --git a/FakeLoadingBar/README.md b/FakeLoadingBar/README.md new file mode 100644 index 0000000..8753a4c --- /dev/null +++ b/FakeLoadingBar/README.md @@ -0,0 +1,3 @@ +# 假进度条 +### 效果 +进度显示效果顺滑,不会出现突然进度到某点 diff --git a/FakeLoadingBar/assets/Scene.meta b/FakeLoadingBar/assets/Scene.meta new file mode 100644 index 0000000..1f1c69c --- /dev/null +++ b/FakeLoadingBar/assets/Scene.meta @@ -0,0 +1,12 @@ +{ + "ver": "1.1.2", + "uuid": "29f52784-2fca-467b-92e7-8fd9ef8c57b7", + "isBundle": false, + "bundleName": "", + "priority": 1, + "compressionType": {}, + "optimizeHotUpdate": {}, + "inlineSpriteFrames": {}, + "isRemoteBundle": {}, + "subMetas": {} +} \ No newline at end of file diff --git a/FakeLoadingBar/assets/Scene/helloworld.fire b/FakeLoadingBar/assets/Scene/helloworld.fire new file mode 100644 index 0000000..0c383d5 --- /dev/null +++ b/FakeLoadingBar/assets/Scene/helloworld.fire @@ -0,0 +1,925 @@ +[ + { + "__type__": "cc.SceneAsset", + "_name": "", + "_objFlags": 0, + "_native": "", + "scene": { + "__id__": 1 + } + }, + { + "__type__": "cc.Scene", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + } + ], + "_active": true, + "_components": [], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_is3DNode": true, + "_groupIndex": 0, + "groupIndex": 0, + "autoReleaseAssets": false, + "_id": "2d2f792f-a40c-49bb-a189-ed176a246e49" + }, + { + "__type__": "cc.Node", + "_name": "Canvas", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 3 + }, + { + "__id__": 5 + }, + { + "__id__": 8 + }, + { + "__id__": 10 + }, + { + "__id__": 12 + } + ], + "_active": true, + "_components": [ + { + "__id__": 19 + }, + { + "__id__": 20 + }, + { + "__id__": 21 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 252, + "g": 252, + "b": 252, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 960, + "height": 640 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 480, + 320, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "a286bbGknJLZpRpxROV6M94" + }, + { + "__type__": "cc.Node", + "_name": "Main Camera", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 4 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 244.20917453622894, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "5aPhbVpABDELbTh7Hoqs1l" + }, + { + "__type__": "cc.Camera", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 3 + }, + "_enabled": true, + "_cullingMask": 4294967295, + "_clearFlags": 7, + "_backgroundColor": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_depth": -1, + "_zoomRatio": 1, + "_targetTexture": null, + "_fov": 60, + "_orthoSize": 10, + "_nearClip": 1, + "_farClip": 4096, + "_ortho": true, + "_rect": { + "__type__": "cc.Rect", + "x": 0, + "y": 0, + "width": 1, + "height": 1 + }, + "_renderStages": 1, + "_alignWithScreen": true, + "_id": "51Az4/89xBCI470T9cXHVZ" + }, + { + "__type__": "cc.Node", + "_name": "background", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 6 + }, + { + "__id__": 7 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 27, + "g": 38, + "b": 46, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 960, + "height": 640 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "e2e0crkOLxGrpMxpbC4iQg1" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 5 + }, + "_enabled": true, + "alignMode": 0, + "_target": null, + "_alignFlags": 45, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 200, + "_originalHeight": 150, + "_id": "4fVP2SdyJNE4E3zPO0Zkm8" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 5 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "410fb916-8721-4663-bab8-34397391ace7" + }, + "_type": 1, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "c0q6IstQxPAp6vLywmxn5Z" + }, + { + "__type__": "cc.Node", + "_name": "cocos", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 9 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 195, + "height": 270 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 182.179, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "c4f30YOS65G64U2TwufdJ+2" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 8 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "31bc895a-c003-4566-a9f3-2e54ae1c17dc" + }, + "_type": 0, + "_sizeMode": 1, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "7fQbXk5XxBzp6ZPBrfC5Qs" + }, + { + "__type__": "cc.Node", + "_name": "label", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 11 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 342.33, + "height": 75.6 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + -180, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "31f1bH7V69Ajr1iXhluMpTB" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 10 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_useOriginalSize": false, + "_string": "Hello, World!", + "_N$string": "Hello, World!", + "_fontSize": 60, + "_lineHeight": 60, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_styleFlags": 0, + "_underlineHeight": 0, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 0, + "_id": "e7UOwbBCtCJpzoNwcowaoE" + }, + { + "__type__": "cc.Node", + "_name": "progress1", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [ + { + "__id__": 13 + }, + { + "__id__": 15 + } + ], + "_active": true, + "_components": [ + { + "__id__": 17 + }, + { + "__id__": 18 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 615, + "height": 63 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "6bXGHeGXpLk4pl2QjhPAPY" + }, + { + "__type__": "cc.Node", + "_name": "progress$bar1", + "_objFlags": 0, + "_parent": { + "__id__": 12 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 14 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 599, + "height": 41 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 3.396, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "1fNMDPCoxOgbSKrJj3lWHy" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 13 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "0231820e-1147-48c4-bcdc-da7657cbb6e8" + }, + "_type": 3, + "_sizeMode": 1, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "59Oz2bHq5FI5V3Z4A+FD+7" + }, + { + "__type__": "cc.Node", + "_name": "New Label", + "_objFlags": 0, + "_parent": { + "__id__": 12 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 16 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 97.87, + "height": 50.4 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + -69.928, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "c0fu1ghFFEm6sI83SK+sjr" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 15 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_useOriginalSize": false, + "_string": "Label", + "_N$string": "Label", + "_fontSize": 40, + "_lineHeight": 40, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_styleFlags": 0, + "_underlineHeight": 0, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 0, + "_id": "6dSSlencVBKavshSKM4qjG" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 12 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "498e0dad-1715-4e23-bee7-fdd8d3202e16" + }, + "_type": 0, + "_sizeMode": 1, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "6aSqxjJ0BFrY35RhlSPjgT" + }, + { + "__type__": "e1b90/rohdEk4SdmmEZANaD", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 12 + }, + "_enabled": true, + "progressBar": { + "__id__": 14 + }, + "tip": { + "__id__": 16 + }, + "_id": "65+pYvBCNEnqz1CD8DVqk9" + }, + { + "__type__": "cc.Canvas", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "_designResolution": { + "__type__": "cc.Size", + "width": 960, + "height": 640 + }, + "_fitWidth": false, + "_fitHeight": true, + "_id": "01xT8KY/VKO5t2hRnR4VAN" + }, + { + "__type__": "e1b90/rohdEk4SdmmEZANaD", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "progressBar": null, + "tip": null, + "_id": "88si+Ao0VIraC6SqwzlsBt" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "alignMode": 1, + "_target": null, + "_alignFlags": 45, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 0, + "_originalHeight": 0, + "_id": "4a0CTR2+5EXYxwmTG2wJMg" + } +] \ No newline at end of file diff --git a/FakeLoadingBar/assets/Scene/helloworld.fire.meta b/FakeLoadingBar/assets/Scene/helloworld.fire.meta new file mode 100644 index 0000000..19313c5 --- /dev/null +++ b/FakeLoadingBar/assets/Scene/helloworld.fire.meta @@ -0,0 +1,7 @@ +{ + "ver": "1.2.8", + "uuid": "2d2f792f-a40c-49bb-a189-ed176a246e49", + "asyncLoadAssets": false, + "autoReleaseAssets": false, + "subMetas": {} +} \ No newline at end of file diff --git a/FakeLoadingBar/assets/Script.meta b/FakeLoadingBar/assets/Script.meta new file mode 100644 index 0000000..776c9cc --- /dev/null +++ b/FakeLoadingBar/assets/Script.meta @@ -0,0 +1,12 @@ +{ + "ver": "1.1.2", + "uuid": "4734c20c-0db8-4eb2-92ea-e692f4d70934", + "isBundle": false, + "bundleName": "", + "priority": 1, + "compressionType": {}, + "optimizeHotUpdate": {}, + "inlineSpriteFrames": {}, + "isRemoteBundle": {}, + "subMetas": {} +} \ No newline at end of file diff --git a/FakeLoadingBar/assets/Script/FakeLoadingBar.ts b/FakeLoadingBar/assets/Script/FakeLoadingBar.ts new file mode 100644 index 0000000..a7870c2 --- /dev/null +++ b/FakeLoadingBar/assets/Script/FakeLoadingBar.ts @@ -0,0 +1,75 @@ +const { ccclass, property } = cc._decorator; + +@ccclass +export default class FakeLoadingBar extends cc.Component { + + private _progress: number = null; + @property(cc.Sprite) + progressBar: cc.Sprite = null; + @property(cc.Label) + tip: cc.Label = null + + private loadingText = ['加载数据包', '加载场景中', '加载资源中']; + + private set progress(value: number) { + if (this._progress == value) { + return; + } + this._progress = value; + + let count = Math.ceil(this._progress / 0.33); + + this.tip.string = this.loadingText[count] || this.loadingText[2]; + + this.progressBar.fillRange = this._progress; + } + + private loadTime: number = 0; + public currentLoad: number = 0; + public alreadyLoad: number = 0; + private totalLoad: number = 100; + private loadScale: number = 1; + + start() { + this.loadTime = 0; + this.currentLoad = 0; + this.alreadyLoad = 5; + this.loadScale = 2.5; + + this.scheduleOnce(() => { + this.alreadyLoad = this.totalLoad; + }, 20); + } + + loadSceneFn() { + console.log('加载完成', this.loadTime); + } + + update(dt) { + this.loadTime += dt; + + if (this.currentLoad < this.alreadyLoad) { + this.currentLoad += dt * (40 * (this.alreadyLoad - this.currentLoad) / this.totalLoad + 40) * this.loadScale; + + if (this.currentLoad >= this.alreadyLoad) { + this.currentLoad = this.alreadyLoad; + let limitLoad = this.totalLoad * 0.8; + + if (this.alreadyLoad < limitLoad) { + this.alreadyLoad = this.alreadyLoad + (limitLoad - this.alreadyLoad) * (Math.random() * 0.005); + if (this.alreadyLoad > limitLoad) { + this.alreadyLoad = limitLoad; + } + } + } + this.progress = this.currentLoad / this.totalLoad; + + if (this.currentLoad >= this.alreadyLoad) { + this.scheduleOnce(() => { + this.loadSceneFn(); + }, 0.1); + } + } + } + +} diff --git a/FakeLoadingBar/assets/Script/FakeLoadingBar.ts.meta b/FakeLoadingBar/assets/Script/FakeLoadingBar.ts.meta new file mode 100644 index 0000000..b99dded --- /dev/null +++ b/FakeLoadingBar/assets/Script/FakeLoadingBar.ts.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.8", + "uuid": "e1b90feb-a217-4493-849d-9a611900d683", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/FakeLoadingBar/assets/Texture.meta b/FakeLoadingBar/assets/Texture.meta new file mode 100644 index 0000000..ca86565 --- /dev/null +++ b/FakeLoadingBar/assets/Texture.meta @@ -0,0 +1,12 @@ +{ + "ver": "1.1.2", + "uuid": "7b81d4e8-ec84-4716-968d-500ac1d78a54", + "isBundle": false, + "bundleName": "", + "priority": 1, + "compressionType": {}, + "optimizeHotUpdate": {}, + "inlineSpriteFrames": {}, + "isRemoteBundle": {}, + "subMetas": {} +} \ No newline at end of file diff --git a/FakeLoadingBar/assets/Texture/HelloWorld.png b/FakeLoadingBar/assets/Texture/HelloWorld.png new file mode 100644 index 0000000..21d4326 Binary files /dev/null and b/FakeLoadingBar/assets/Texture/HelloWorld.png differ diff --git a/FakeLoadingBar/assets/Texture/HelloWorld.png.meta b/FakeLoadingBar/assets/Texture/HelloWorld.png.meta new file mode 100644 index 0000000..eb65993 --- /dev/null +++ b/FakeLoadingBar/assets/Texture/HelloWorld.png.meta @@ -0,0 +1,36 @@ +{ + "ver": "2.3.5", + "uuid": "6aa0aa6a-ebee-4155-a088-a687a6aadec4", + "type": "sprite", + "wrapMode": "clamp", + "filterMode": "bilinear", + "premultiplyAlpha": false, + "genMipmaps": false, + "packable": true, + "width": 195, + "height": 270, + "platformSettings": {}, + "subMetas": { + "HelloWorld": { + "ver": "1.0.4", + "uuid": "31bc895a-c003-4566-a9f3-2e54ae1c17dc", + "rawTextureUuid": "6aa0aa6a-ebee-4155-a088-a687a6aadec4", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 0, + "trimY": 0, + "width": 195, + "height": 270, + "rawWidth": 195, + "rawHeight": 270, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "subMetas": {} + } + } +} \ No newline at end of file diff --git a/FakeLoadingBar/assets/Texture/progress$bar1.png b/FakeLoadingBar/assets/Texture/progress$bar1.png new file mode 100644 index 0000000..c0cffed Binary files /dev/null and b/FakeLoadingBar/assets/Texture/progress$bar1.png differ diff --git a/FakeLoadingBar/assets/Texture/progress$bar1.png.meta b/FakeLoadingBar/assets/Texture/progress$bar1.png.meta new file mode 100644 index 0000000..2cb1a61 --- /dev/null +++ b/FakeLoadingBar/assets/Texture/progress$bar1.png.meta @@ -0,0 +1,36 @@ +{ + "ver": "2.3.5", + "uuid": "d2bab923-29d5-4268-be38-d41a06626a12", + "type": "sprite", + "wrapMode": "clamp", + "filterMode": "bilinear", + "premultiplyAlpha": false, + "genMipmaps": false, + "packable": true, + "width": 615, + "height": 63, + "platformSettings": {}, + "subMetas": { + "progress$bar1": { + "ver": "1.0.4", + "uuid": "0231820e-1147-48c4-bcdc-da7657cbb6e8", + "rawTextureUuid": "d2bab923-29d5-4268-be38-d41a06626a12", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 3, + "trimX": 8, + "trimY": 8, + "width": 599, + "height": 41, + "rawWidth": 615, + "rawHeight": 63, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "subMetas": {} + } + } +} \ No newline at end of file diff --git a/FakeLoadingBar/assets/Texture/progress1.png b/FakeLoadingBar/assets/Texture/progress1.png new file mode 100644 index 0000000..d9f4823 Binary files /dev/null and b/FakeLoadingBar/assets/Texture/progress1.png differ diff --git a/FakeLoadingBar/assets/Texture/progress1.png.meta b/FakeLoadingBar/assets/Texture/progress1.png.meta new file mode 100644 index 0000000..7579007 --- /dev/null +++ b/FakeLoadingBar/assets/Texture/progress1.png.meta @@ -0,0 +1,36 @@ +{ + "ver": "2.3.5", + "uuid": "bb0c93f4-9638-4b39-800c-b16338d11ebc", + "type": "sprite", + "wrapMode": "clamp", + "filterMode": "bilinear", + "premultiplyAlpha": false, + "genMipmaps": false, + "packable": true, + "width": 615, + "height": 63, + "platformSettings": {}, + "subMetas": { + "progress1": { + "ver": "1.0.4", + "uuid": "498e0dad-1715-4e23-bee7-fdd8d3202e16", + "rawTextureUuid": "bb0c93f4-9638-4b39-800c-b16338d11ebc", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 0, + "trimY": 0, + "width": 615, + "height": 63, + "rawWidth": 615, + "rawHeight": 63, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "subMetas": {} + } + } +} \ No newline at end of file diff --git a/FakeLoadingBar/assets/Texture/singleColor.png b/FakeLoadingBar/assets/Texture/singleColor.png new file mode 100644 index 0000000..fa6376e Binary files /dev/null and b/FakeLoadingBar/assets/Texture/singleColor.png differ diff --git a/FakeLoadingBar/assets/Texture/singleColor.png.meta b/FakeLoadingBar/assets/Texture/singleColor.png.meta new file mode 100644 index 0000000..a0a712e --- /dev/null +++ b/FakeLoadingBar/assets/Texture/singleColor.png.meta @@ -0,0 +1,36 @@ +{ + "ver": "2.3.5", + "uuid": "a8027877-d8d6-4645-97a0-52d4a0123dba", + "type": "sprite", + "wrapMode": "clamp", + "filterMode": "bilinear", + "premultiplyAlpha": false, + "genMipmaps": false, + "packable": true, + "width": 2, + "height": 2, + "platformSettings": {}, + "subMetas": { + "singleColor": { + "ver": "1.0.4", + "uuid": "410fb916-8721-4663-bab8-34397391ace7", + "rawTextureUuid": "a8027877-d8d6-4645-97a0-52d4a0123dba", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 0, + "trimY": 0, + "width": 2, + "height": 2, + "rawWidth": 2, + "rawHeight": 2, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "subMetas": {} + } + } +} \ No newline at end of file diff --git a/FakeLoadingBar/creator.d.ts b/FakeLoadingBar/creator.d.ts new file mode 100644 index 0000000..b33d9e5 --- /dev/null +++ b/FakeLoadingBar/creator.d.ts @@ -0,0 +1,32212 @@ + +/** !#en +The main namespace of Cocos2d-JS, all engine core classes, functions, properties and constants are defined in this namespace. +!#zh +Cocos 引擎的主要命名空间,引擎代码中所有的类,函数,属性和常量都在这个命名空间中定义。 */ +declare namespace cc { + /** The current version of Cocos2d being used.
+ Please DO NOT remove this String, it is an important flag for bug tracking.
+ If you post a bug to forum, please attach this flag. */ + export var ENGINE_VERSION: string; + /** + !#en + Creates the speed action which changes the speed of an action, making it take longer (speed > 1) + or less (speed < 1) time.
+ Useful to simulate 'slow motion' or 'fast forward' effect. + !#zh 修改目标动作的速率。 + @param action action + @param speed speed + + @example + ```js + // change the target action speed; + var action = cc.scaleTo(0.2, 1, 0.6); + var newAction = cc.speed(action, 0.5); + ``` + */ + export function speed(action: ActionInterval, speed: number): Action; + /** + !#en Create a follow action which makes its target follows another node. + !#zh 追踪目标节点的位置。 + @param followedNode followedNode + @param rect rect + + @example + ```js + // example + // creates the action with a set boundary + var followAction = cc.follow(targetNode, cc.rect(0, 0, screenWidth * 2 - 100, screenHeight)); + node.runAction(followAction); + + // creates the action with no boundary set + var followAction = cc.follow(targetNode); + node.runAction(followAction); + ``` + */ + export function follow(followedNode: Node, rect: Rect): Action; + /** + Points setter + @param points points + */ + export function setPoints(points: any[]): void; + /** + !#en Creates an action with a Cardinal Spline array of points and tension. + !#zh 按基数样条曲线轨迹移动到目标位置。 + @param duration duration + @param points array of control points + @param tension tension + + @example + ```js + //create a cc.CardinalSplineTo + var action1 = cc.cardinalSplineTo(3, array, 0); + ``` + */ + export function cardinalSplineTo(duration: number, points: any[], tension: number): ActionInterval; + /** + update position of target + @param newPos newPos + */ + export function updatePosition(newPos: Vec2): void; + /** + !#en Creates an action with a Cardinal Spline array of points and tension. + !#zh 按基数样条曲线轨迹移动指定的距离。 + @param duration duration + @param points points + @param tension tension + */ + export function cardinalSplineBy(duration: number, points: any[], tension: number): ActionInterval; + /** + !#en Creates an action with a Cardinal Spline array of points and tension. + !#zh 按 Catmull Rom 样条曲线轨迹移动到目标位置。 + @param dt dt + @param points points + + @example + ```js + var action1 = cc.catmullRomTo(3, array); + ``` + */ + export function catmullRomTo(dt: number, points: any[]): ActionInterval; + /** + !#en Creates an action with a Cardinal Spline array of points and tension. + !#zh 按 Catmull Rom 样条曲线轨迹移动指定的距离。 + @param dt dt + @param points points + + @example + ```js + var action1 = cc.catmullRomBy(3, array); + ``` + */ + export function catmullRomBy(dt: number, points: any[]): ActionInterval; + /** + !#en + Creates the action easing object with the rate parameter.
+ From slow to fast. + !#zh 创建 easeIn 缓动对象,由慢到快。 + @param rate rate + + @example + ```js + action.easing(cc.easeIn(3.0)); + ``` + */ + export function easeIn(rate: number): any; + /** + !#en + Creates the action easing object with the rate parameter.
+ From fast to slow. + !#zh 创建 easeOut 缓动对象,由快到慢。 + @param rate rate + + @example + ```js + action.easing(cc.easeOut(3.0)); + ``` + */ + export function easeOut(rate: number): any; + /** + !#en + Creates the action easing object with the rate parameter.
+ Slow to fast then to slow. + !#zh 创建 easeInOut 缓动对象,慢到快,然后慢。 + @param rate rate + + @example + ```js + action.easing(cc.easeInOut(3.0)); + ``` + */ + export function easeInOut(rate: number): any; + /** + !#en + Creates the action easing object with the rate parameter.
+ Reference easeInExpo:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeExponentialIn 缓动对象。
+ EaseExponentialIn 是按指数函数缓动进入的动作。
+ 参考 easeInExpo:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + action.easing(cc.easeExponentialIn()); + ``` + */ + export function easeExponentialIn(): any; + /** + !#en + Creates the action easing object.
+ Reference easeOutExpo:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeExponentialOut 缓动对象。
+ EaseExponentialOut 是按指数函数缓动退出的动作。
+ 参考 easeOutExpo:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + action.easing(cc.easeExponentialOut()); + ``` + */ + export function easeExponentialOut(): any; + /** + !#en + Creates an EaseExponentialInOut action easing object.
+ Reference easeInOutExpo:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeExponentialInOut 缓动对象。
+ EaseExponentialInOut 是按指数函数缓动进入并退出的动作。
+ 参考 easeInOutExpo:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + action.easing(cc.easeExponentialInOut()); + ``` + */ + export function easeExponentialInOut(): any; + /** + !#en + Creates an EaseSineIn action.
+ Reference easeInSine:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 EaseSineIn 缓动对象。
+ EaseSineIn 是按正弦函数缓动进入的动作。
+ 参考 easeInSine:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + action.easing(cc.easeSineIn()); + ``` + */ + export function easeSineIn(): any; + /** + !#en + Creates an EaseSineOut action easing object.
+ Reference easeOutSine:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 EaseSineOut 缓动对象。
+ EaseSineIn 是按正弦函数缓动退出的动作。
+ 参考 easeOutSine:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + action.easing(cc.easeSineOut()); + ``` + */ + export function easeSineOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInOutSine:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeSineInOut 缓动对象。
+ EaseSineIn 是按正弦函数缓动进入并退出的动作。
+ 参考 easeInOutSine:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + action.easing(cc.easeSineInOut()); + ``` + */ + export function easeSineInOut(): any; + /** + !#en + Creates the action easing object with the period in radians (default is 0.3).
+ Reference easeInElastic:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeElasticIn 缓动对象。
+ EaseElasticIn 是按弹性曲线缓动进入的动作。
+ 参数 easeInElastic:http://www.zhihu.com/question/21981571/answer/19925418 + @param period period + + @example + ```js + // example + action.easing(cc.easeElasticIn(3.0)); + ``` + */ + export function easeElasticIn(period: number): any; + /** + !#en + Creates the action easing object with the period in radians (default is 0.3).
+ Reference easeOutElastic:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeElasticOut 缓动对象。
+ EaseElasticOut 是按弹性曲线缓动退出的动作。
+ 参考 easeOutElastic:http://www.zhihu.com/question/21981571/answer/19925418 + @param period period + + @example + ```js + // example + action.easing(cc.easeElasticOut(3.0)); + ``` + */ + export function easeElasticOut(period: number): any; + /** + !#en + Creates the action easing object with the period in radians (default is 0.3).
+ Reference easeInOutElastic:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeElasticInOut 缓动对象。
+ EaseElasticInOut 是按弹性曲线缓动进入并退出的动作。
+ 参考 easeInOutElastic:http://www.zhihu.com/question/21981571/answer/19925418 + @param period period + + @example + ```js + // example + action.easing(cc.easeElasticInOut(3.0)); + ``` + */ + export function easeElasticInOut(period: number): any; + /** + !#en + Creates the action easing object.
+ Eased bounce effect at the beginning. + !#zh + 创建 easeBounceIn 缓动对象。
+ EaseBounceIn 是按弹跳动作缓动进入的动作。 + + @example + ```js + // example + action.easing(cc.easeBounceIn()); + ``` + */ + export function easeBounceIn(): any; + /** + !#en + Creates the action easing object.
+ Eased bounce effect at the ending. + !#zh + 创建 easeBounceOut 缓动对象。
+ EaseBounceOut 是按弹跳动作缓动退出的动作。 + + @example + ```js + // example + action.easing(cc.easeBounceOut()); + ``` + */ + export function easeBounceOut(): any; + /** + !#en + Creates the action easing object.
+ Eased bounce effect at the begining and ending. + !#zh + 创建 easeBounceInOut 缓动对象。
+ EaseBounceInOut 是按弹跳动作缓动进入并退出的动作。 + + @example + ```js + // example + action.easing(cc.easeBounceInOut()); + ``` + */ + export function easeBounceInOut(): any; + /** + !#en + Creates the action easing object.
+ In the opposite direction to move slowly, and then accelerated to the right direction. + !#zh + 创建 easeBackIn 缓动对象。
+ easeBackIn 是在相反的方向缓慢移动,然后加速到正确的方向。
+ + @example + ```js + // example + action.easing(cc.easeBackIn()); + ``` + */ + export function easeBackIn(): any; + /** + !#en + Creates the action easing object.
+ Fast moving more than the finish, and then slowly back to the finish. + !#zh + 创建 easeBackOut 缓动对象。
+ easeBackOut 快速移动超出目标,然后慢慢回到目标点。 + + @example + ```js + // example + action.easing(cc.easeBackOut()); + ``` + */ + export function easeBackOut(): any; + /** + !#en + Creates the action easing object.
+ Begining of cc.EaseBackIn. Ending of cc.EaseBackOut. + !#zh + 创建 easeBackInOut 缓动对象。
+ + @example + ```js + // example + action.easing(cc.easeBackInOut()); + ``` + */ + export function easeBackInOut(): any; + /** + !#en + Creates the action easing object.
+ Into the 4 reference point.
+ To calculate the motion curve. + !#zh + 创建 easeBezierAction 缓动对象。
+ EaseBezierAction 是按贝塞尔曲线缓动的动作。 + @param p0 The first bezier parameter + @param p1 The second bezier parameter + @param p2 The third bezier parameter + @param p3 The fourth bezier parameter + + @example + ```js + // example + action.easing(cc.easeBezierAction(0.5, 0.5, 1.0, 1.0)); + ``` + */ + export function easeBezierAction(p0: number, p1: number, p2: number, p3: number): any; + /** + !#en + Creates the action easing object.
+ Reference easeInQuad:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuadraticActionIn 缓动对象。
+ EaseQuadraticIn是按二次函数缓动进入的动作。
+ 参考 easeInQuad:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeQuadraticActionIn()); + ``` + */ + export function easeQuadraticActionIn(): any; + /** + !#en + Creates the action easing object.
+ Reference easeOutQuad:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuadraticActionOut 缓动对象。
+ EaseQuadraticOut 是按二次函数缓动退出的动作。
+ 参考 easeOutQuad:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeQuadraticActionOut()); + ``` + */ + export function easeQuadraticActionOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInOutQuad:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuadraticActionInOut 缓动对象。
+ EaseQuadraticInOut 是按二次函数缓动进入并退出的动作。
+ 参考 easeInOutQuad:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeQuadraticActionInOut()); + ``` + */ + export function easeQuadraticActionInOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeIntQuart:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuarticActionIn 缓动对象。
+ EaseQuarticIn 是按四次函数缓动进入的动作。
+ 参考 easeIntQuart:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeQuarticActionIn()); + ``` + */ + export function easeQuarticActionIn(): any; + /** + !#en + Creates the action easing object.
+ Reference easeOutQuart:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuarticActionOut 缓动对象。
+ EaseQuarticOut 是按四次函数缓动退出的动作。
+ 参考 easeOutQuart:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.QuarticActionOut()); + ``` + */ + export function easeQuarticActionOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInOutQuart:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuarticActionInOut 缓动对象。
+ EaseQuarticInOut 是按四次函数缓动进入并退出的动作。
+ 参考 easeInOutQuart:http://www.zhihu.com/question/21981571/answer/19925418 + */ + export function easeQuarticActionInOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInQuint:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuinticActionIn 缓动对象。
+ EaseQuinticIn 是按五次函数缓动进的动作。
+ 参考 easeInQuint:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeQuinticActionIn()); + ``` + */ + export function easeQuinticActionIn(): any; + /** + !#en + Creates the action easing object.
+ Reference easeOutQuint:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuinticActionOut 缓动对象。
+ EaseQuinticOut 是按五次函数缓动退出的动作 + 参考 easeOutQuint:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeQuadraticActionOut()); + ``` + */ + export function easeQuinticActionOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInOutQuint:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuinticActionInOut 缓动对象。
+ EaseQuinticInOut是按五次函数缓动进入并退出的动作。
+ 参考 easeInOutQuint:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeQuinticActionInOut()); + ``` + */ + export function easeQuinticActionInOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInCirc:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeCircleActionIn 缓动对象。
+ EaseCircleIn是按圆形曲线缓动进入的动作。
+ 参考 easeInCirc:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeCircleActionIn()); + ``` + */ + export function easeCircleActionIn(): any; + /** + !#en + Creates the action easing object.
+ Reference easeOutCirc:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeCircleActionOut 缓动对象。
+ EaseCircleOut是按圆形曲线缓动退出的动作。
+ 参考 easeOutCirc:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + actioneasing(cc.easeCircleActionOut()); + ``` + */ + export function easeCircleActionOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInOutCirc:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeCircleActionInOut 缓动对象。
+ EaseCircleInOut 是按圆形曲线缓动进入并退出的动作。
+ 参考 easeInOutCirc:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeCircleActionInOut()); + ``` + */ + export function easeCircleActionInOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInCubic:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeCubicActionIn 缓动对象。
+ EaseCubicIn 是按三次函数缓动进入的动作。
+ 参考 easeInCubic:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeCubicActionIn()); + ``` + */ + export function easeCubicActionIn(): any; + /** + !#en + Creates the action easing object.
+ Reference easeOutCubic:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeCubicActionOut 缓动对象。
+ EaseCubicOut 是按三次函数缓动退出的动作。
+ 参考 easeOutCubic:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeCubicActionOut()); + ``` + */ + export function easeCubicActionOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInOutCubic:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeCubicActionInOut 缓动对象。
+ EaseCubicInOut是按三次函数缓动进入并退出的动作。
+ 参考 easeInOutCubic:http://www.zhihu.com/question/21981571/answer/19925418 + */ + export function easeCubicActionInOut(): any; + /** + !#en Show the Node. + !#zh 立即显示。 + + @example + ```js + // example + var showAction = cc.show(); + ``` + */ + export function show(): ActionInstant; + /** + !#en Hide the node. + !#zh 立即隐藏。 + + @example + ```js + // example + var hideAction = cc.hide(); + ``` + */ + export function hide(): ActionInstant; + /** + !#en Toggles the visibility of a node. + !#zh 显隐状态切换。 + + @example + ```js + // example + var toggleVisibilityAction = cc.toggleVisibility(); + ``` + */ + export function toggleVisibility(): ActionInstant; + /** + !#en Create a RemoveSelf object with a flag indicate whether the target should be cleaned up while removing. + !#zh 从父节点移除自身。 + @param isNeedCleanUp isNeedCleanUp + + @example + ```js + // example + var removeSelfAction = cc.removeSelf(); + ``` + */ + export function removeSelf(isNeedCleanUp ?: boolean): ActionInstant; + /** + !#en Destroy self + !#zh 创建一个销毁自身的动作。 + + @example + ```js + var destroySelfAction = cc.destroySelf(); + ``` + */ + export function destroySelf(): ActionInstant; + /** + !#en Create a FlipX action to flip or unflip the target. + !#zh X轴翻转。 + @param flip Indicate whether the target should be flipped or not + + @example + ```js + var flipXAction = cc.flipX(true); + ``` + */ + export function flipX(flip: boolean): ActionInstant; + /** + !#en Create a FlipY action to flip or unflip the target. + !#zh Y轴翻转。 + @param flip flip + + @example + ```js + var flipYAction = cc.flipY(true); + ``` + */ + export function flipY(flip: boolean): ActionInstant; + /** + !#en Creates a Place action with a position. + !#zh 放置在目标位置。 + @param pos pos + @param y y + + @example + ```js + // example + var placeAction = cc.place(cc.v2(200, 200)); + var placeAction = cc.place(200, 200); + ``` + */ + export function place(pos: Vec2|number, y?: number): ActionInstant; + /** + !#en Creates the action with the callback. + !#zh 执行回调函数。 + @param selector selector + @param selectorTarget selectorTarget + @param data data for function, it accepts all data types. + + @example + ```js + // example + // CallFunc without data + var finish = cc.callFunc(this.removeSprite, this); + + // CallFunc with data + var finish = cc.callFunc(this.removeFromParentAndCleanup, this._grossini, true); + ``` + */ + export function callFunc(selector: Function, selectorTarget?: any, data?: any): ActionInstant; + /** + !#en + Helper constructor to create an array of sequenceable actions + The created action will run actions sequentially, one after another. + !#zh 顺序执行动作,创建的动作将按顺序依次运行。 + @param actionOrActionArray actionOrActionArray + @param tempArray tempArray + + @example + ```js + // example + // create sequence with actions + var seq = cc.sequence(act1, act2); + + // create sequence with array + var seq = cc.sequence(actArray); + ``` + */ + export function sequence(actionOrActionArray: FiniteTimeAction|FiniteTimeAction[], ...tempArray: FiniteTimeAction[]): ActionInterval; + /** + !#en Creates a Repeat action. Times is an unsigned integer between 1 and pow(2,30) + !#zh 重复动作,可以按一定次数重复一个动,如果想永远重复一个动作请使用 repeatForever 动作来完成。 + @param action action + @param times times + + @example + ```js + // example + var rep = cc.repeat(cc.sequence(jump2, jump1), 5); + ``` + */ + export function repeat(action: FiniteTimeAction, times: number): ActionInterval; + /** + !#en Create a acton which repeat forever, as it runs forever, it can't be added into cc.sequence and cc.spawn. + !#zh 永远地重复一个动作,有限次数内重复一个动作请使用 repeat 动作,由于这个动作不会停止,所以不能被添加到 cc.sequence 或 cc.spawn 中。 + @param action action + + @example + ```js + // example + var repeat = cc.repeatForever(cc.rotateBy(1.0, 360)); + ``` + */ + export function repeatForever(action: FiniteTimeAction): ActionInterval; + /** + !#en Create a spawn action which runs several actions in parallel. + !#zh 同步执行动作,同步执行一组动作。 + @param actionOrActionArray actionOrActionArray + @param tempArray tempArray + + @example + ```js + // example + var action = cc.spawn(cc.jumpBy(2, cc.v2(300, 0), 50, 4), cc.rotateBy(2, 720)); + todo:It should be the direct use new + ``` + */ + export function spawn(actionOrActionArray: FiniteTimeAction|FiniteTimeAction[], ...tempArray: FiniteTimeAction[]): FiniteTimeAction; + /** + !#en + Rotates a Node object to a certain angle by modifying its angle property.
+ The direction will be decided by the shortest angle. + !#zh 旋转到目标角度,通过逐帧修改它的 angle 属性,旋转方向将由最短的角度决定。 + @param duration duration in seconds + @param dstAngle dstAngle in degrees. + + @example + ```js + // example + var rotateTo = cc.rotateTo(2, 61.0); + ``` + */ + export function rotateTo(duration: number, dstAngle: number): ActionInterval; + /** + !#en + Rotates a Node object clockwise a number of degrees by modifying its angle property. + Relative to its properties to modify. + !#zh 旋转指定的角度。 + @param duration duration in seconds + @param deltaAngle deltaAngle in degrees + + @example + ```js + // example + var actionBy = cc.rotateBy(2, 360); + ``` + */ + export function rotateBy(duration: number, deltaAngle: number): ActionInterval; + /** + !#en + Moves a Node object x,y pixels by modifying its position property.
+ x and y are relative to the position of the object.
+ Several MoveBy actions can be concurrently called, and the resulting
+ movement will be the sum of individual movements. + !#zh 移动指定的距离。 + @param duration duration in seconds + @param deltaPos deltaPos + @param deltaY deltaY + + @example + ```js + // example + var actionTo = cc.moveBy(2, cc.v2(windowSize.width - 40, windowSize.height - 40)); + ``` + */ + export function moveBy(duration: number, deltaPos: Vec2|number, deltaY?: number): ActionInterval; + /** + !#en + Moves a Node object to the position x,y. x and y are absolute coordinates by modifying its position property.
+ Several MoveTo actions can be concurrently called, and the resulting
+ movement will be the sum of individual movements. + !#zh 移动到目标位置。 + @param duration duration in seconds + @param position position + @param y y + + @example + ```js + // example + var actionBy = cc.moveTo(2, cc.v2(80, 80)); + ``` + */ + export function moveTo(duration: number, position: Vec2|number, y?: number): ActionInterval; + /** + !#en + Create a action which skews a Node object to given angles by modifying its skewX and skewY properties. + Changes to the specified value. + !#zh 偏斜到目标角度。 + @param t time in seconds + @param sx sx + @param sy sy + + @example + ```js + // example + var actionTo = cc.skewTo(2, 37.2, -37.2); + ``` + */ + export function skewTo(t: number, sx: number, sy: number): ActionInterval; + /** + !#en + Skews a Node object by skewX and skewY degrees.
+ Relative to its property modification. + !#zh 偏斜指定的角度。 + @param t time in seconds + @param sx sx skew in degrees for X axis + @param sy sy skew in degrees for Y axis + + @example + ```js + // example + var actionBy = cc.skewBy(2, 0, -90); + ``` + */ + export function skewBy(t: number, sx: number, sy: number): ActionInterval; + /** + !#en + Moves a Node object simulating a parabolic jump movement by modifying it's position property. + Relative to its movement. + !#zh 用跳跃的方式移动指定的距离。 + @param duration duration + @param position position + @param y y + @param height height + @param jumps jumps + + @example + ```js + // example + var actionBy = cc.jumpBy(2, cc.v2(300, 0), 50, 4); + var actionBy = cc.jumpBy(2, 300, 0, 50, 4); + ``` + */ + export function jumpBy(duration: number, position: Vec2|number, y?: number, height?: number, jumps?: number): ActionInterval; + /** + !#en + Moves a Node object to a parabolic position simulating a jump movement by modifying its position property.
+ Jump to the specified location. + !#zh 用跳跃的方式移动到目标位置。 + @param duration duration + @param position position + @param y y + @param height height + @param jumps jumps + + @example + ```js + // example + var actionTo = cc.jumpTo(2, cc.v2(300, 300), 50, 4); + var actionTo = cc.jumpTo(2, 300, 300, 50, 4); + ``` + */ + export function jumpTo(duration: number, position: Vec2|number, y?: number, height?: number, jumps?: number): ActionInterval; + /** + !#en + An action that moves the target with a cubic Bezier curve by a certain distance. + Relative to its movement. + !#zh 按贝赛尔曲线轨迹移动指定的距离。 + @param t time in seconds + @param c Array of points + + @example + ```js + // example + var bezier = [cc.v2(0, windowSize.height / 2), cc.v2(300, -windowSize.height / 2), cc.v2(300, 100)]; + var bezierForward = cc.bezierBy(3, bezier); + ``` + */ + export function bezierBy(t: number, c: Vec2[]): ActionInterval; + /** + !#en An action that moves the target with a cubic Bezier curve to a destination point. + !#zh 按贝赛尔曲线轨迹移动到目标位置。 + @param t t + @param c Array of points + + @example + ```js + // example + var bezier = [cc.v2(0, windowSize.height / 2), cc.v2(300, -windowSize.height / 2), cc.v2(300, 100)]; + var bezierTo = cc.bezierTo(2, bezier); + ``` + */ + export function bezierTo(t: number, c: Vec2[]): ActionInterval; + /** + !#en Scales a Node object to a zoom factor by modifying it's scale property. + !#zh 将节点大小缩放到指定的倍数。 + @param duration duration + @param sx scale parameter in X + @param sy scale parameter in Y, if Null equal to sx + + @example + ```js + // example + // It scales to 0.5 in both X and Y. + var actionTo = cc.scaleTo(2, 0.5); + + // It scales to 0.5 in x and 2 in Y + var actionTo = cc.scaleTo(2, 0.5, 2); + ``` + */ + export function scaleTo(duration: number, sx: number, sy?: number): ActionInterval; + /** + !#en + Scales a Node object a zoom factor by modifying it's scale property. + Relative to its changes. + !#zh 按指定的倍数缩放节点大小。 + @param duration duration in seconds + @param sx sx scale parameter in X + @param sy sy scale parameter in Y, if Null equal to sx + + @example + ```js + // example without sy, it scales by 2 both in X and Y + var actionBy = cc.scaleBy(2, 2); + + //example with sy, it scales by 0.25 in X and 4.5 in Y + var actionBy2 = cc.scaleBy(2, 0.25, 4.5); + ``` + */ + export function scaleBy(duration: number, sx: number, sy?: number|void): ActionInterval; + /** + !#en Blinks a Node object by modifying it's visible property. + !#zh 闪烁(基于透明度)。 + @param duration duration in seconds + @param blinks blinks in times + + @example + ```js + // example + var action = cc.blink(2, 10); + ``` + */ + export function blink(duration: number, blinks: number): ActionInterval; + /** + !#en + Fades an object that implements the cc.RGBAProtocol protocol. + It modifies the opacity from the current value to a custom one. + !#zh 修改透明度到指定值。 + @param duration duration + @param opacity 0-255, 0 is transparent + + @example + ```js + // example + var action = cc.fadeTo(1.0, 0); + ``` + */ + export function fadeTo(duration: number, opacity: number): ActionInterval; + /** + !#en Fades In an object that implements the cc.RGBAProtocol protocol. It modifies the opacity from 0 to 255. + !#zh 渐显效果。 + @param duration duration in seconds + + @example + ```js + //example + var action = cc.fadeIn(1.0); + ``` + */ + export function fadeIn(duration: number): ActionInterval; + /** + !#en Fades Out an object that implements the cc.RGBAProtocol protocol. It modifies the opacity from 255 to 0. + !#zh 渐隐效果。 + @param d duration in seconds + + @example + ```js + // example + var action = cc.fadeOut(1.0); + ``` + */ + export function fadeOut(d: number): ActionInterval; + /** + !#en Tints a Node that implements the cc.NodeRGB protocol from current tint to a custom one. + !#zh 修改颜色到指定值。 + @param duration duration + @param red 0-255 + @param green 0-255 + @param blue 0-255 + + @example + ```js + // example + var action = cc.tintTo(2, 255, 0, 255); + ``` + */ + export function tintTo(duration: number, red: number, green: number, blue: number): ActionInterval; + /** + !#en + Tints a Node that implements the cc.NodeRGB protocol from current tint to a custom one. + Relative to their own color change. + !#zh 按照指定的增量修改颜色。 + @param duration duration in seconds + @param deltaRed deltaRed + @param deltaGreen deltaGreen + @param deltaBlue deltaBlue + + @example + ```js + // example + var action = cc.tintBy(2, -127, -255, -127); + ``` + */ + export function tintBy(duration: number, deltaRed: number, deltaGreen: number, deltaBlue: number): ActionInterval; + /** + !#en Delays the action a certain amount of seconds. + !#zh 延迟指定的时间量。 + @param d duration in seconds + + @example + ```js + // example + var delay = cc.delayTime(1); + ``` + */ + export function delayTime(d: number): ActionInterval; + /** + !#en Executes an action in reverse order, from time=duration to time=0. + !#zh 反转目标动作的时间轴。 + @param action action + + @example + ```js + // example + var reverse = cc.reverseTime(this); + ``` + */ + export function reverseTime(action: FiniteTimeAction): ActionInterval; + /** + !#en Create an action with the specified action and forced target. + !#zh 用已有动作和一个新的目标节点创建动作。 + @param target target + @param action action + */ + export function targetedAction(target: Node, action: FiniteTimeAction): ActionInterval; + /** + + @param target the target to animate + */ + export function tween (target?: T) : Tween; + /** + !#en + Outputs an error message to the Cocos Creator Console (editor) or Web Console (runtime).
+ - In Cocos Creator, error is red.
+ - In Chrome, error have a red icon along with red message text.
+ !#zh + 输出错误消息到 Cocos Creator 编辑器的 Console 或运行时页面端的 Console 中。
+ - 在 Cocos Creator 中,错误信息显示是红色的。
+ - 在 Chrome 中,错误信息有红色的图标以及红色的消息文本。
+ @param msg A JavaScript string containing zero or more substitution strings. + @param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output. + */ + export function error(msg: any, ...subst: any[]): void; + /** + !#en + Outputs a warning message to the Cocos Creator Console (editor) or Web Console (runtime). + - In Cocos Creator, warning is yellow. + - In Chrome, warning have a yellow warning icon with the message text. + !#zh + 输出警告消息到 Cocos Creator 编辑器的 Console 或运行时 Web 端的 Console 中。
+ - 在 Cocos Creator 中,警告信息显示是黄色的。
+ - 在 Chrome 中,警告信息有着黄色的图标以及黄色的消息文本。
+ @param msg A JavaScript string containing zero or more substitution strings. + @param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output. + */ + export function warn(msg: any, ...subst: any[]): void; + /** + !#en Outputs a message to the Cocos Creator Console (editor) or Web Console (runtime). + !#zh 输出一条消息到 Cocos Creator 编辑器的 Console 或运行时 Web 端的 Console 中。 + @param msg A JavaScript string containing zero or more substitution strings. + @param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output. + */ + export function log(msg: string|any, ...subst: any[]): void; + /** !#en This is a Game instance. + !#zh 这是一个 Game 类的实例,包含游戏主体信息并负责驱动游戏的游戏对象。。 */ + export var game: Game; + /** !#en Director + !#zh 导演类。 */ + export var director: Director; + /** !#en This is a Easing instance. + !#zh 这是一个 Easing 类实例。 */ + export var easing: Easing; + /** + !#en + Rotates a Node object to a certain angle by modifying its quternion property.
+ The direction will be decided by the shortest angle. + !#zh 旋转到目标角度,通过逐帧修改它的 quternion 属性,旋转方向将由最短的角度决定。 + @param duration duration in seconds + @param dstAngleX dstAngleX in degrees. + @param dstAngleY dstAngleY in degrees. + @param dstAngleZ dstAngleZ in degrees. + + @example + ```js + // example + var rotate3DTo = cc.rotate3DTo(2, cc.v3(0, 180, 0)); + ``` + */ + export function rotate3DTo(duration: number, dstAngleX: number|Vec3|Quat, dstAngleY?: number, dstAngleZ?: number): ActionInterval; + /** + !#en + Rotates a Node object counter clockwise a number of degrees by modifying its quaternion property. + Relative to its properties to modify. + !#zh 旋转指定的 3D 角度。 + @param duration duration in seconds + @param deltaAngleX deltaAngleX in degrees + @param deltaAngleY deltaAngleY in degrees + @param deltaAngleZ deltaAngleZ in degrees + + @example + ```js + // example + var actionBy = cc.rotate3DBy(2, cc.v3(0, 360, 0)); + ``` + */ + export function rotate3DBy(duration: number, deltaAngleX: number|Vec3, deltaAngleY?: number, deltaAngleZ?: number): ActionInterval; + export var assetManager: AssetManager; + /** !#en + cc.resources is a bundle and controls all asset under assets/resources + + !#zh + cc.resources 是一个 bundle,用于管理所有在 assets/resources 下的资源 */ + export var resources: AssetManager.Bundle; + /** !#en The System event singleton for global usage + !#zh 系统事件单例,方便全局使用 */ + export var systemEvent: SystemEvent; + /** + !#en Defines a CCClass using the given specification, please see [Class](/docs/editors_and_tools/creator-chapters/scripting/class.html) for details. + !#zh 定义一个 CCClass,传入参数必须是一个包含类型参数的字面量对象,具体用法请查阅[类型定义](/docs/creator/scripting/class.html)。 + @param options options + + @example + ```js + // define base class + var Node = cc.Class(); + + // define sub class + var Sprite = cc.Class({ + name: 'Sprite', + extends: Node, + + ctor: function () { + this.url = ""; + this.id = 0; + }, + + statics: { + // define static members + count: 0, + getBounds: function (spriteList) { + // compute bounds... + } + }, + + properties { + width: { + default: 128, + type: cc.Integer, + tooltip: 'The width of sprite' + }, + height: 128, + size: { + get: function () { + return cc.v2(this.width, this.height); + } + } + }, + + load: function () { + // load this.url... + }; + }); + + // instantiate + + var obj = new Sprite(); + obj.url = 'sprite.png'; + obj.load(); + ``` + */ + export function Class(options?: {name?: string; extends?: Function; ctor?: Function; __ctor__?: Function; properties?: any; statics?: any; mixins?: Function[]; editor?: {executeInEditMode?: boolean; requireComponent?: Function; menu?: string; executionOrder?: number; disallowMultiple?: boolean; playOnFocus?: boolean; inspector?: string; icon?: string; help?: string; }; update?: Function; lateUpdate?: Function; onLoad?: Function; start?: Function; onEnable?: Function; onDisable?: Function; onDestroy?: Function; onFocusInEditor?: Function; onLostFocusInEditor?: Function; resetInEditor?: Function; onRestore?: Function; _getLocalBounds?: Function; }): Function; + /** + !#en + Define an enum type.
+ If a enum item has a value of -1, it will be given an Integer number according to it's order in the list.
+ Otherwise it will use the value specified by user who writes the enum definition. + + !#zh + 定义一个枚举类型。
+ 用户可以把枚举值设为任意的整数,如果设为 -1,系统将会分配为上一个枚举值 + 1。 + @param obj a JavaScript literal object containing enum names and values, or a TypeScript enum type + + @example + ```js + // JavaScript: + + var WrapMode = cc.Enum({ + Repeat: -1, + Clamp: -1 + }); + + // Texture.WrapMode.Repeat == 0 + // Texture.WrapMode.Clamp == 1 + // Texture.WrapMode[0] == "Repeat" + // Texture.WrapMode[1] == "Clamp" + + var FlagType = cc.Enum({ + Flag1: 1, + Flag2: 2, + Flag3: 4, + Flag4: 8, + }); + + var AtlasSizeList = cc.Enum({ + 128: 128, + 256: 256, + 512: 512, + 1024: 1024, + }); + + // TypeScript: + + // If used in TypeScript, just define a TypeScript enum: + enum Direction { + Up, + Down, + Left, + Right + } + + // If you need to inspect the enum in Properties panel, you can call cc.Enum: + const {ccclass, property} = cc._decorator; + + @ccclass + class NewScript extends cc.Component { + @property({ + type: cc.Enum(Direction) // call cc.Enum + }) + direction: Direction = Direction.Up; + } + + ``` + */ + export function Enum(obj: T): T; + /** + + @param touches touches + */ + export function handleTouchesBegin(touches: any[]): void; + /** + + @param touches touches + */ + export function handleTouchesMove(touches: any[]): void; + /** + + @param touches touches + */ + export function handleTouchesEnd(touches: any[]): void; + /** + + @param touches touches + */ + export function handleTouchesCancel(touches: any[]): void; + /** + + @param touches touches + */ + export function getSetOfTouchesEndOrCancel(touches: any[]): any[]; + /** + + @param touch touch + */ + export function getPreTouch(touch: Touch): Touch; + /** + + @param touch touch + */ + export function setPreTouch(touch: Touch): void; + /** + + @param tx tx + @param ty ty + @param pos pos + */ + export function getTouchByXY(tx: number, ty: number, pos: Vec2): Touch; + /** + + @param location location + @param pos pos + @param eventType eventType + */ + export function getMouseEvent(location: Vec2, pos: Vec2, eventType: number): Event.EventMouse; + /** + + @param event event + @param pos pos + */ + export function getPointByEvent(event: Touch, pos: Vec2): Vec2; + /** + + @param event event + @param pos pos + */ + export function getTouchesByEvent(event: Touch, pos: Vec2): any[]; + /** + + @param element element + */ + export function registerSystemEvent(element: HTMLElement): void; + /** + + @param dt dt + */ + export function update(dt: number): void; + /** + !#en + Checks whether the object is non-nil and not yet destroyed.
+ When an object's `destroy` is called, it is actually destroyed after the end of this frame. + So `isValid` will return false from the next frame, while `isValid` in the current frame will still be true. + If you want to determine whether the current frame has called `destroy`, use `cc.isValid(obj, true)`, + but this is often caused by a particular logical requirements, which is not normally required. + + !#zh + 检查该对象是否不为 null 并且尚未销毁。
+ 当一个对象的 `destroy` 调用以后,会在这一帧结束后才真正销毁。因此从下一帧开始 `isValid` 就会返回 false,而当前帧内 `isValid` 仍然会是 true。如果希望判断当前帧是否调用过 `destroy`,请使用 `cc.isValid(obj, true)`,不过这往往是特殊的业务需求引起的,通常情况下不需要这样。 + @param value value + @param strictMode If true, Object called destroy() in this frame will also treated as invalid. + + @example + ```js + var node = new cc.Node(); + cc.log(cc.isValid(node)); // true + node.destroy(); + cc.log(cc.isValid(node)); // true, still valid in this frame + // after a frame... + cc.log(cc.isValid(node)); // false, destroyed in the end of last frame + ``` + */ + export function isValid(value: any, strictMode?: boolean): boolean; + /** !#en cc.view is the shared view object. + !#zh cc.view 是全局的视图对象。 */ + export var view: View; + /** !#en cc.winSize is the alias object for the size of the current game window. + !#zh cc.winSize 为当前的游戏窗口的大小。 */ + export var winSize: Size; + /** Specify that the input value must be integer in Inspector. + Also used to indicates that the elements in array should be type integer. */ + export var Integer: string; + /** Indicates that the elements in array should be type double. */ + export var Float: string; + /** Indicates that the elements in array should be type boolean. */ + export var Boolean: string; + /** Indicates that the elements in array should be type string. */ + export var String: string; + /** + !#en Deserialize json to cc.Asset + !#zh 将 JSON 反序列化为对象实例。 + @param data the serialized cc.Asset json string or json object. + @param details additional loading result + @param options options + */ + export function deserialize(data: string|any, details?: Details, options?: any): any; + /** + !#en Clones the object `original` and returns the clone, or instantiate a node from the Prefab. + !#zh 克隆指定的任意类型的对象,或者从 Prefab 实例化出新节点。 + + (Instantiate 时,function 和 dom 等非可序列化对象会直接保留原有引用,Asset 会直接进行浅拷贝,可序列化类型会进行深拷贝。) + @param original An existing object that you want to make a copy of. + + @example + ```js + // instantiate node from prefab + var scene = cc.director.getScene(); + var node = cc.instantiate(prefabAsset); + node.parent = scene; + // clone node + var scene = cc.director.getScene(); + var node = cc.instantiate(targetNode); + node.parent = scene; + ``` + */ + export function instantiate(original: Prefab): Node; + export function instantiate(original: T): T; + /** + !#en + The convenience method to create a new {{#crossLink "Color/Color:method"}}cc.Color{{/crossLink}} + Alpha channel is optional. Default value is 255. + + !#zh + 通过该方法来创建一个新的 {{#crossLink "Color/Color:method"}}cc.Color{{/crossLink}} 对象。 + Alpha 通道是可选的。默认值是 255。 + @param r r + @param g g + @param b b + @param a a + + @example + ```js + ----------------------- + // 1. All channels seperately as parameters + var color1 = new cc.Color(255, 255, 255, 255); + // 2. Convert a hex string to a color + var color2 = new cc.Color("#000000"); + // 3. An color object as parameter + var color3 = new cc.Color({r: 255, g: 255, b: 255, a: 255}); + + ``` + */ + export function color(r?: number, g?: number, b?: number, a?: number): Color; + /** + !#en The convenience method to create a new {{#crossLink "Mat4"}}cc.Mat4{{/crossLink}}. + !#zh 通过该简便的函数进行创建 {{#crossLink "Mat4"}}cc.Mat4{{/crossLink}} 对象。 + @param m00 Component in column 0, row 0 position (index 0) + @param m01 Component in column 0, row 1 position (index 1) + @param m02 Component in column 0, row 2 position (index 2) + @param m03 Component in column 0, row 3 position (index 3) + @param m10 Component in column 1, row 0 position (index 4) + @param m11 Component in column 1, row 1 position (index 5) + @param m12 Component in column 1, row 2 position (index 6) + @param m13 Component in column 1, row 3 position (index 7) + @param m20 Component in column 2, row 0 position (index 8) + @param m21 Component in column 2, row 1 position (index 9) + @param m22 Component in column 2, row 2 position (index 10) + @param m23 Component in column 2, row 3 position (index 11) + @param m30 Component in column 3, row 0 position (index 12) + @param m31 Component in column 3, row 1 position (index 13) + @param m32 Component in column 3, row 2 position (index 14) + @param m33 Component in column 3, row 3 position (index 15) + */ + export function mat4(m00?: number, m01?: number, m02?: number, m03?: number, m10?: number, m11?: number, m12?: number, m13?: number, m20?: number, m21?: number, m22?: number, m23?: number, m30?: number, m31?: number, m32?: number, m33?: number): Mat4; + /** + !#en The convenience method to create a new {{#crossLink "Quat"}}cc.Quat{{/crossLink}}. + !#zh 通过该简便的函数进行创建 {{#crossLink "Quat"}}cc.Quat{{/crossLink}} 对象。 + @param x x + @param y y + @param z z + @param w w + */ + export function quat(x?: number|any, y?: number, z?: number, w?: number): Quat; + /** + !#en + The convenience method to create a new Rect. + see {{#crossLink "Rect/Rect:method"}}cc.Rect{{/crossLink}} + !#zh + 该方法用来快速创建一个新的矩形。{{#crossLink "Rect/Rect:method"}}cc.Rect{{/crossLink}} + @param x x + @param y y + @param w w + @param h h + + @example + ```js + var a = new cc.Rect(0 , 0, 10, 0); + ``` + */ + export function rect(x?: number, y?: number, w?: number, h?: number): Rect; + /** + !#en + Helper function that creates a cc.Size.
+ Please use cc.p or cc.v2 instead, it will soon replace cc.Size. + !#zh + 创建一个 cc.Size 对象的帮助函数。
+ 注意:可以使用 cc.p 或者是 cc.v2 代替,它们将很快取代 cc.Size。 + @param w width or a size object + @param h height + + @example + ```js + var size1 = cc.size(); + var size2 = cc.size(100,100); + var size3 = cc.size(size2); + var size4 = cc.size({width: 100, height: 100}); + + ``` + */ + export function size(w: number|Size, h?: number): Size; + export var EPSILON: number; + /** + Clamps a value between a minimum float and maximum float value. + @param val val + @param min min + @param max max + */ + export function clamp(val: number, min: number, max: number): number; + /** + Clamps a value between 0 and 1. + @param val val + */ + export function clamp01(val: number): number; + /** + + @param from from + @param to to + @param ratio the interpolation coefficient + */ + export function lerp(from: number, to: number, ratio: number): number; + export function random(): void; + /** + Returns a floating-point random number between min (inclusive) and max (exclusive). + @param min min + @param max max + */ + export function randomRange(min: number, max: number): number; + /** + Returns a random integer between min (inclusive) and max (exclusive). + @param min min + @param max max + */ + export function randomRangeInt(min: number, max: number): number; + /** + Linear congruential generator using Hull-Dobell Theorem. + @param seed the random seed + */ + export function pseudoRandom(seed: number): number; + /** + Returns a floating-point pseudo-random number between min (inclusive) and max (exclusive). + @param seed seed + @param min min + @param max max + */ + export function pseudoRandomRange(seed: number, min: number, max: number): number; + /** + Returns a pseudo-random integer between min (inclusive) and max (exclusive). + @param seed seed + @param min min + @param max max + */ + export function pseudoRandomRangeInt(seed: number, min: number, max: number): number; + /** + Returns the next power of two for the value + @param val val + */ + export function nextPow2(val: number): number; + /** + Returns float remainder for t / length + @param t time start at 0 + @param length time of one cycle + */ + export function repeat(t: number, length: number): number; + /** + Returns time wrapped in ping-pong mode + @param t time start at 0 + @param length time of one cycle + */ + export function repeat(t: number, length: number): number; + /** + Returns ratio of a value within a given range + @param from start value + @param to end value + @param value given value + */ + export function repeat(from: number, to: number, value: number): number; + /** + Returns -1, 0, +1 depending on sign of x. + @param v v + */ + export function sign(v: number): void; + /** + !#en The convenience method to create a new {{#crossLink "Vec2"}}cc.Vec2{{/crossLink}}. + !#zh 通过该简便的函数进行创建 {{#crossLink "Vec2"}}cc.Vec2{{/crossLink}} 对象。 + @param x x + @param y y + + @example + ```js + var v1 = cc.v2(); + var v2 = cc.v2(0, 0); + var v3 = cc.v2(v2); + var v4 = cc.v2({x: 100, y: 100}); + ``` + */ + export function v2(x?: number|any, y?: number): Vec2; + /** + !#en The convenience method to create a new {{#crossLink "Vec3"}}cc.Vec3{{/crossLink}}. + !#zh 通过该简便的函数进行创建 {{#crossLink "Vec3"}}cc.Vec3{{/crossLink}} 对象。 + @param x x + @param y y + @param z z + + @example + ```js + var v1 = cc.v3(); + var v2 = cc.v3(0, 0, 0); + var v3 = cc.v3(v2); + var v4 = cc.v3({x: 100, y: 100, z: 0}); + ``` + */ + export function v3(x?: number|any, y?: number, z?: number): Vec3; + /** + Finds a node by hierarchy path, the path is case-sensitive. + It will traverse the hierarchy by splitting the path using '/' character. + This function will still returns the node even if it is inactive. + It is recommended to not use this function every frame instead cache the result at startup. + @param path path + @param referenceNode referenceNode + */ + export function find(path: string, referenceNode?: Node): Node; + export var dynamicAtlasManager: DynamicAtlasManager; + /** !#en The matrix storage */ + export var matrix: any[]; + /** + !#en Get an element + @param i i + @param j j + */ + export function get(i: number, j: number): number; + /** + !#en Set an element + @param i i + @param j j + @param value value + */ + export function set(i: number, j: number, value: boolean): void; + /** + !#en Sets all elements to zero + */ + export function reset(): void; + /** !#en + cc.NodePool is the cache pool designed for node type.
+ It can helps you to improve your game performance for objects which need frequent release and recreate operations
+ + It's recommended to create cc.NodePool instances by node type, the type corresponds to node type in game design, not the class, + for example, a prefab is a specific node type.
+ When you create a node pool, you can pass a Component which contains `unuse`, `reuse` functions to control the content of node.
+ + Some common use case is :
+ 1. Bullets in game (die very soon, massive creation and recreation, no side effect on other objects)
+ 2. Blocks in candy crash (massive creation and recreation)
+ etc... + !#zh + cc.NodePool 是用于管理节点对象的对象缓存池。
+ 它可以帮助您提高游戏性能,适用于优化对象的反复创建和销毁
+ 以前 cocos2d-x 中的 cc.pool 和新的节点事件注册系统不兼容,因此请使用 cc.NodePool 来代替。 + + 新的 NodePool 需要实例化之后才能使用,每种不同的节点对象池需要一个不同的对象池实例,这里的种类对应于游戏中的节点设计,一个 prefab 相当于一个种类的节点。
+ 在创建缓冲池时,可以传入一个包含 unuse, reuse 函数的组件类型用于节点的回收和复用逻辑。
+ + 一些常见的用例是:
+ 1.在游戏中的子弹(死亡很快,频繁创建,对其他对象无副作用)
+ 2.糖果粉碎传奇中的木块(频繁创建)。 + 等等.... */ + export class NodePool { + /** + !#en + Constructor for creating a pool for a specific node template (usually a prefab). You can pass a component (type or name) argument for handling event for reusing and recycling node. + !#zh + 使用构造函数来创建一个节点专用的对象池,您可以传递一个组件类型或名称,用于处理节点回收和复用时的事件逻辑。 + @param poolHandlerComp !#en The constructor or the class name of the component to control the unuse/reuse logic. !#zh 处理节点回收和复用事件逻辑的组件类型或名称。 + + @example + ```js + properties: { + template: cc.Prefab + }, + onLoad () { + // MyTemplateHandler is a component with 'unuse' and 'reuse' to handle events when node is reused or recycled. + this.myPool = new cc.NodePool('MyTemplateHandler'); + } + ``` + */ + constructor(poolHandlerComp?: {prototype: Component}|string); + /** !#en The pool handler component, it could be the class name or the constructor. + !#zh 缓冲池处理组件,用于节点的回收和复用逻辑,这个属性可以是组件类名或组件的构造函数。 */ + poolHandlerComp: Function|string; + /** + !#en The current available size in the pool + !#zh 获取当前缓冲池的可用对象数量 + */ + size(): number; + /** + !#en Destroy all cached nodes in the pool + !#zh 销毁对象池中缓存的所有节点 + */ + clear(): void; + /** + !#en Put a new Node into the pool. + It will automatically remove the node from its parent without cleanup. + It will also invoke unuse method of the poolHandlerComp if exist. + !#zh 向缓冲池中存入一个不再需要的节点对象。 + 这个函数会自动将目标节点从父节点上移除,但是不会进行 cleanup 操作。 + 这个函数会调用 poolHandlerComp 的 unuse 函数,如果组件和函数都存在的话。 + @param obj obj + + @example + ```js + let myNode = cc.instantiate(this.template); + this.myPool.put(myNode); + ``` + */ + put(obj: Node): void; + /** + !#en Get a obj from pool, if no available object in pool, null will be returned. + This function will invoke the reuse function of poolHandlerComp if exist. + !#zh 获取对象池中的对象,如果对象池没有可用对象,则返回空。 + 这个函数会调用 poolHandlerComp 的 reuse 函数,如果组件和函数都存在的话。 + @param params !#en Params to pass to 'reuse' method in poolHandlerComp !#zh 向 poolHandlerComp 中的 'reuse' 函数传递的参数 + + @example + ```js + let newNode = this.myPool.get(); + ``` + */ + get(...params: any[]): Node; + } + /** !#en Base class cc.Action for action classes. + !#zh Action 类是所有动作类型的基类。 */ + export class Action { + /** + !#en + to copy object with deep copy. + returns a clone of action. + !#zh 返回一个克隆的动作。 + */ + clone(): Action; + /** + !#en + return true if the action has finished. + !#zh 如果动作已完成就返回 true。 + */ + isDone(): boolean; + /** + !#en get the target. + !#zh 获取当前目标节点。 + */ + getTarget(): Node; + /** + !#en The action will modify the target properties. + !#zh 设置目标节点。 + @param target target + */ + setTarget(target: Node): void; + /** + !#en get the original target. + !#zh 获取原始目标节点。 + */ + getOriginalTarget(): Node; + /** + !#en get tag number. + !#zh 获取用于识别动作的标签。 + */ + getTag(): number; + /** + !#en set tag number. + !#zh 设置标签,用于识别动作。 + @param tag tag + */ + setTag(tag: number): void; + /** !#en Default Action tag. + !#zh 默认动作标签。 */ + static TAG_INVALID: number; + } + /** !#en + Base class actions that do have a finite time duration.
+ Possible actions:
+ - An action with a duration of 0 seconds.
+ - An action with a duration of 35.5 seconds. + + Infinite time actions are valid + !#zh 有限时间动作,这种动作拥有时长 duration 属性。 */ + export class FiniteTimeAction extends Action { + /** + !#en get duration of the action. (seconds). + !#zh 获取动作以秒为单位的持续时间。 + */ + getDuration(): number; + /** + !#en set duration of the action. (seconds). + !#zh 设置动作以秒为单位的持续时间。 + @param duration duration + */ + setDuration(duration: number): void; + /** + !#en + Returns a reversed action.
+ For example:
+ - The action will be x coordinates of 0 move to 100.
+ - The reversed action will be x of 100 move to 0. + - Will be rewritten + !#zh 返回一个新的动作,执行与原动作完全相反的动作。 + */ + reverse(): void; + /** + !#en + to copy object with deep copy. + returns a clone of action. + !#zh 返回一个克隆的动作。 + */ + clone(): FiniteTimeAction; + } + /** !#en Instant actions are immediate actions. They don't have a duration like the ActionInterval actions. + !#zh 即时动作,这种动作立即就会执行,继承自 FiniteTimeAction。 */ + export class ActionInstant extends FiniteTimeAction { + } + /** !#en +

An interval action is an action that takes place within a certain period of time.
+ It has an start time, and a finish time. The finish time is the parameter
+ duration plus the start time.

+ +

These CCActionInterval actions have some interesting properties, like:
+ - They can run normally (default)
+ - They can run reversed with the reverse method
+ - They can run with the time altered with the Accelerate, AccelDeccel and Speed actions.

+ +

For example, you can simulate a Ping Pong effect running the action normally and
+ then running it again in Reverse mode.

+ !#zh 时间间隔动作,这种动作在已定时间内完成,继承 FiniteTimeAction。 */ + export class ActionInterval extends FiniteTimeAction { + /** + !#en Implementation of ease motion. + !#zh 缓动运动。 + @param easeObj easeObj + + @example + ```js + action.easing(cc.easeIn(3.0)); + ``` + */ + easing(easeObj: any): ActionInterval; + /** + !#en + Repeats an action a number of times. + To repeat an action forever use the CCRepeatForever action. + !#zh 重复动作可以按一定次数重复一个动作,使用 RepeatForever 动作来永远重复一个动作。 + @param times times + */ + repeat(times: number): ActionInterval; + /** + !#en + Repeats an action for ever.
+ To repeat the an action for a limited number of times use the Repeat action.
+ !#zh 永远地重复一个动作,有限次数内重复一个动作请使用 Repeat 动作。 + */ + repeatForever(): ActionInterval; + } + /** !#en + cc.ActionManager is a class that can manage actions.
+ Normally you won't need to use this class directly. 99% of the cases you will use the CCNode interface, + which uses this class's singleton object. + But there are some cases where you might need to use this class.
+ Examples:
+ - When you want to run an action where the target is different from a CCNode.
+ - When you want to pause / resume the actions
+ !#zh + cc.ActionManager 是可以管理动作的单例类。
+ 通常你并不需要直接使用这个类,99%的情况您将使用 CCNode 的接口。
+ 但也有一些情况下,您可能需要使用这个类。
+ 例如: + - 当你想要运行一个动作,但目标不是 CCNode 类型时。
+ - 当你想要暂停/恢复动作时。
*/ + export class ActionManager { + /** + !#en + Adds an action with a target.
+ If the target is already present, then the action will be added to the existing target. + If the target is not present, a new instance of this target will be created either paused or not, and the action will be added to the newly created target. + When the target is paused, the queued actions won't be 'ticked'. + !#zh + 增加一个动作,同时还需要提供动作的目标对象,目标对象是否暂停作为参数。
+ 如果目标已存在,动作将会被直接添加到现有的节点中。
+ 如果目标不存在,将为这一目标创建一个新的实例,并将动作添加进去。
+ 当目标状态的 paused 为 true,动作将不会被执行 + @param action action + @param target target + @param paused paused + */ + addAction(action: Action, target: Node, paused: boolean): void; + /** + !#en Removes all actions from all the targets. + !#zh 移除所有对象的所有动作。 + */ + removeAllActions(): void; + /** + !#en + Removes all actions from a certain target.
+ All the actions that belongs to the target will be removed. + !#zh + 移除指定对象上的所有动作。
+ 属于该目标的所有的动作将被删除。 + @param target target + @param forceDelete forceDelete + */ + removeAllActionsFromTarget(target: Node, forceDelete: boolean): void; + /** + !#en Removes an action given an action reference. + !#zh 移除指定的动作。 + @param action action + */ + removeAction(action: Action): void; + /** + !#en Removes an action given its tag and the target. + !#zh 删除指定对象下特定标签的一个动作,将删除首个匹配到的动作。 + @param tag tag + @param target target + */ + removeActionByTag(tag: number, target?: Node): void; + /** + !#en Gets an action given its tag an a target. + !#zh 通过目标对象和标签获取一个动作。 + @param tag tag + @param target target + */ + getActionByTag(tag: number, target: Node): Action; + /** + !#en + Returns the numbers of actions that are running in a certain target.
+ Composable actions are counted as 1 action.
+ Example:
+ - If you are running 1 Sequence of 7 actions, it will return 1.
+ - If you are running 7 Sequences of 2 actions, it will return 7. + !#zh + 返回指定对象下所有正在运行的动作数量。
+ 组合动作被算作一个动作。
+ 例如:
+ - 如果您正在运行 7 个动作组成的序列动作(Sequence),这个函数将返回 1。
+ - 如果你正在运行 2 个序列动作(Sequence)和 5 个普通动作,这个函数将返回 7。
+ @param target target + */ + getNumberOfRunningActionsInTarget(target: Node): number; + /** + !#en Pauses the target: all running actions and newly added actions will be paused. + !#zh 暂停指定对象:所有正在运行的动作和新添加的动作都将会暂停。 + @param target target + */ + pauseTarget(target: Node): void; + /** + !#en Resumes the target. All queued actions will be resumed. + !#zh 让指定目标恢复运行。在执行序列中所有被暂停的动作将重新恢复运行。 + @param target target + */ + resumeTarget(target: Node): void; + /** + !#en Pauses all running actions, returning a list of targets whose actions were paused. + !#zh 暂停所有正在运行的动作,返回一个包含了那些动作被暂停了的目标对象的列表。 + */ + pauseAllRunningActions(): any[]; + /** + !#en Resume a set of targets (convenience function to reverse a pauseAllRunningActions or pauseTargets call). + !#zh 让一组指定对象恢复运行(用来逆转 pauseAllRunningActions 效果的便捷函数)。 + @param targetsToResume targetsToResume + */ + resumeTargets(targetsToResume: any[]): void; + /** + !#en Pause a set of targets. + !#zh 暂停一组指定对象。 + @param targetsToPause targetsToPause + */ + pauseTargets(targetsToPause: any[]): void; + /** + !#en + purges the shared action manager. It releases the retained instance.
+ because it uses this, so it can not be static. + !#zh + 清除共用的动作管理器。它释放了持有的实例。
+ 因为它使用 this,因此它不能是静态的。 + */ + purgeSharedManager(): void; + /** + !#en The ActionManager update。 + !#zh ActionManager 主循环。 + @param dt delta time in seconds + */ + update(dt: number): void; + } + /** !#en + Tween provide a simple and flexible way to create action. + Tween's api is more flexible than cc.Action: + - Support creating an action sequence in chained api, + - Support animate any objects' any properties, not limited to node's properties. + By contrast, cc.Action needs to create a new action class to support new node property. + - Support working with cc.Action, + - Support easing and progress function. + !#zh + Tween 提供了一个简单灵活的方法来创建 action。 + 相对于 Cocos 传统的 cc.Action,cc.Tween 在创建动画上要灵活非常多: + - 支持以链式结构的方式创建一个动画序列。 + - 支持对任意对象的任意属性进行缓动,不再局限于节点上的属性,而 cc.Action 添加一个属性的支持时还需要添加一个新的 action 类型。 + - 支持与 cc.Action 混用 + - 支持设置 {{#crossLink "Easing"}}{{/crossLink}} 或者 progress 函数 */ + export class Tween { + /** + + @param target target + */ + constructor(target?: any); + /** + !#en Stop all tweens + !#zh 停止所有缓动 + */ + static stopAll(): void; + /** + !#en Stop all tweens by tag + !#zh 停止所有指定标签的缓动 + @param tag tag + */ + static stopAllByTag(tag: number): void; + /** + !#en Stop all tweens by target + !#zh 停止所有指定对象的缓动 + @param target target + */ + static stopAllByTarget(target: any): void; + /** + !#en + Insert an action or tween to this sequence + !#zh + 插入一个 action 或者 tween 到队列中 + @param other other + */ + then(other: Action|Tween): Tween; + /** + !#en + Set tween target + !#zh + 设置 tween 的 target + @param target target + */ + target(target: any): Tween; + /** + !#en + Start this tween + !#zh + 运行当前 tween + */ + start(): Tween; + /** + !#en + Stop this tween + !#zh + 停止当前 tween + */ + stop(): Tween; + /** + !#en Sets tween tag + !#zh 设置缓动的标签 + @param tag tag + */ + tag(tag: number): Tween; + /** + !#en + Clone a tween + !#zh + 克隆当前 tween + @param target target + */ + clone(target?: any): Tween; + /** + !#en + Integrate all previous actions to an action. + !#zh + 将之前所有的 action 整合为一个 action。 + */ + union(): Tween; + /** + !#en Sets target's position property according to the bezier curve. + !#zh 按照贝塞尔路径设置目标的 position 属性。 + @param duration duration + @param c1 c1 + @param c2 c2 + @param to to + */ + bezierTo(duration: number, c1: Vec2, c2: Vec2, to: Vec2): Tween; + /** + !#en Sets target's position property according to the bezier curve. + !#zh 按照贝塞尔路径设置目标的 position 属性。 + @param duration duration + @param c1 c1 + @param c2 c2 + @param to to + */ + bezierBy(duration: number, c1: Vec2, c2: Vec2, to: Vec2): Tween; + /** + !#en Flips target's scaleX + !#zh 翻转目标的 scaleX 属性 + */ + flipX(): Tween; + /** + !#en Flips target's scaleY + !#zh 翻转目标的 scaleY 属性 + */ + flipY(): Tween; + /** + !#en Blinks target by set target's opacity property + !#zh 通过设置目标的 opacity 属性达到闪烁效果 + @param duration duration + @param times times + @param opts opts + */ + blink(duration: number, times: number, opts?: {progress?: Function; easing?: Function|string; }): Tween; + /** + !#en + Add an action which calculate with absolute value + !#zh + 添加一个对属性进行绝对值计算的 action + @param duration duration + @param props {scale: 2, position: cc.v3(100, 100, 100)} + @param opts opts + */ + to > (duration: number, props: ConstructorType, opts?: OPTS) : Tween; + /** + !#en + Add an action which calculate with relative value + !#zh + 添加一个对属性进行相对值计算的 action + @param duration duration + @param props {scale: 2, position: cc.v3(100, 100, 100)} + @param opts opts + */ + by > (duration: number, props: ConstructorType, opts?: OPTS) : Tween; + /** + !#en + Directly set target properties + !#zh + 直接设置 target 的属性 + @param props props + */ + set (props: ConstructorType) : Tween; + /** + !#en + Add an delay action + !#zh + 添加一个延时 action + @param duration duration + */ + delay(duration: number): Tween; + /** + !#en + Add an callback action + !#zh + 添加一个回调 action + @param callback callback + */ + call(callback: Function): Tween; + /** + !#en + Add an hide action + !#zh + 添加一个隐藏 action + */ + hide(): Tween; + /** + !#en + Add an show action + !#zh + 添加一个显示 action + */ + show(): Tween; + /** + !#en + Add an removeSelf action + !#zh + 添加一个移除自己 action + */ + removeSelf(): Tween; + /** + !#en + Add an sequence action + !#zh + 添加一个队列 action + @param action action + @param actions actions + */ + sequence(action: Action|Tween, ...actions: (Action|Tween)[]): Tween; + /** + !#en + Add an parallel action + !#zh + 添加一个并行 action + @param action action + @param actions actions + */ + parallel(action: Action|Tween, ...actions: (Action|Tween)[]): Tween; + /** + !#en + Add an repeat action. + This action will integrate before actions to a sequence action as their parameters. + !#zh + 添加一个重复 action,这个 action 会将前一个动作作为他的参数。 + @param repeatTimes repeatTimes + @param action action + */ + repeat(repeatTimes: number, action?: Action|Tween): Tween; + /** + !#en + Add an repeat forever action + This action will integrate before actions to a sequence action as their parameters. + !#zh + 添加一个永久重复 action,这个 action 会将前一个动作作为他的参数。 + @param action action + */ + repeatForever(action?: Action|Tween): Tween; + /** + !#en + Add an reverse time action. + This action will integrate before actions to a sequence action as their parameters. + !#zh + 添加一个倒置时间 action,这个 action 会将前一个动作作为他的参数。 + @param action action + */ + reverseTime(action?: Action|Tween): Tween; + } + /** !#en cc.audioEngine is the singleton object, it provide simple audio APIs. + !#zh + cc.audioengine是单例对象。
+ 主要用来播放音频,播放的时候会返回一个 audioID,之后都可以通过这个 audioID 来操作这个音频对象。
+ 不使用的时候,请使用 cc.audioEngine.uncache(filePath); 进行资源释放
+ 注意:
+ 在 Android 系统浏览器上,不同浏览器,不同版本的效果不尽相同。
+ 比如说:大多数浏览器都需要用户物理交互才可以开始播放音效,有一些不支持 WebAudio,
+ 有一些不支持多音轨播放。总之如果对音乐依赖比较强,请做尽可能多的测试。 */ + export class audioEngine { + /** + !#en Play audio. + !#zh 播放音频 + @param clip The audio clip to play. + @param loop Whether the music loop or not. + @param volume Volume size. + + @example + ```js + cc.resources.load(path, cc.AudioClip, null, function (err, clip) { + var audioID = cc.audioEngine.play(clip, false, 0.5); + }); + ``` + */ + static play(clip: AudioClip, loop: boolean, volume: number): number; + /** + !#en Set audio loop. + !#zh 设置音频是否循环。 + @param audioID audio id. + @param loop Whether cycle. + + @example + ```js + cc.audioEngine.setLoop(id, true); + ``` + */ + static setLoop(audioID: number, loop: boolean): void; + /** + !#en Get audio cycle state. + !#zh 获取音频的循环状态。 + @param audioID audio id. + + @example + ```js + cc.audioEngine.isLoop(id); + ``` + */ + static isLoop(audioID: number): boolean; + /** + !#en Set the volume of audio. + !#zh 设置音量(0.0 ~ 1.0)。 + @param audioID audio id. + @param volume Volume must be in 0.0~1.0 . + + @example + ```js + cc.audioEngine.setVolume(id, 0.5); + ``` + */ + static setVolume(audioID: number, volume: number): void; + /** + !#en The volume of the music max value is 1.0,the min value is 0.0 . + !#zh 获取音量(0.0 ~ 1.0)。 + @param audioID audio id. + + @example + ```js + var volume = cc.audioEngine.getVolume(id); + ``` + */ + static getVolume(audioID: number): number; + /** + !#en Set current time + !#zh 设置当前的音频时间。 + @param audioID audio id. + @param sec current time. + + @example + ```js + cc.audioEngine.setCurrentTime(id, 2); + ``` + */ + static setCurrentTime(audioID: number, sec: number): boolean; + /** + !#en Get current time + !#zh 获取当前的音频播放时间。 + @param audioID audio id. + + @example + ```js + var time = cc.audioEngine.getCurrentTime(id); + ``` + */ + static getCurrentTime(audioID: number): number; + /** + !#en Get audio duration + !#zh 获取音频总时长。 + @param audioID audio id. + + @example + ```js + var time = cc.audioEngine.getDuration(id); + ``` + */ + static getDuration(audioID: number): number; + /** + !#en Get audio state + !#zh 获取音频状态。 + @param audioID audio id. + + @example + ```js + var state = cc.audioEngine.getState(id); + ``` + */ + static getState(audioID: number): audioEngine.AudioState; + /** + !#en Set Audio finish callback + !#zh 设置一个音频结束后的回调 + @param audioID audio id. + @param callback loaded callback. + + @example + ```js + cc.audioEngine.setFinishCallback(id, function () {}); + ``` + */ + static setFinishCallback(audioID: number, callback: Function): void; + /** + !#en Pause playing audio. + !#zh 暂停正在播放音频。 + @param audioID The return value of function play. + + @example + ```js + cc.audioEngine.pause(audioID); + ``` + */ + static pause(audioID: number): void; + /** + !#en Pause all playing audio + !#zh 暂停现在正在播放的所有音频。 + + @example + ```js + cc.audioEngine.pauseAll(); + ``` + */ + static pauseAll(): void; + /** + !#en Resume playing audio. + !#zh 恢复播放指定的音频。 + @param audioID The return value of function play. + + @example + ```js + cc.audioEngine.resume(audioID); + ``` + */ + static resume(audioID: number): void; + /** + !#en Resume all playing audio. + !#zh 恢复播放所有之前暂停的所有音频。 + + @example + ```js + cc.audioEngine.resumeAll(); + ``` + */ + static resumeAll(): void; + /** + !#en Stop playing audio. + !#zh 停止播放指定音频。 + @param audioID The return value of function play. + + @example + ```js + cc.audioEngine.stop(audioID); + ``` + */ + static stop(audioID: number): void; + /** + !#en Stop all playing audio. + !#zh 停止正在播放的所有音频。 + + @example + ```js + cc.audioEngine.stopAll(); + ``` + */ + static stopAll(): void; + /** + !#en Set up an audio can generate a few examples. + !#zh 设置一个音频可以设置几个实例 + @param num a number of instances to be created from within an audio + + @example + ```js + cc.audioEngine.setMaxAudioInstance(20); + ``` + */ + static setMaxAudioInstance(num: number): void; + /** + !#en Getting audio can produce several examples. + !#zh 获取一个音频可以设置几个实例 + + @example + ```js + cc.audioEngine.getMaxAudioInstance(); + ``` + */ + static getMaxAudioInstance(): number; + /** + !#en Unload the preloaded audio from internal buffer. + !#zh 卸载预加载的音频。 + @param clip clip + + @example + ```js + cc.audioEngine.uncache(filePath); + ``` + */ + static uncache(clip: AudioClip): void; + /** + !#en Unload all audio from internal buffer. + !#zh 卸载所有音频。 + + @example + ```js + cc.audioEngine.uncacheAll(); + ``` + */ + static uncacheAll(): void; + /** + !#en Play background music + !#zh 播放背景音乐 + @param clip The audio clip to play. + @param loop Whether the music loop or not. + + @example + ```js + cc.resources.load(path, cc.AudioClip, null, function (err, clip) { + var audioID = cc.audioEngine.playMusic(clip, false); + }); + ``` + */ + static playMusic(clip: AudioClip, loop: boolean): number; + /** + !#en Stop background music. + !#zh 停止播放背景音乐。 + + @example + ```js + cc.audioEngine.stopMusic(); + ``` + */ + static stopMusic(): void; + /** + !#en Pause the background music. + !#zh 暂停播放背景音乐。 + + @example + ```js + cc.audioEngine.pauseMusic(); + ``` + */ + static pauseMusic(): void; + /** + !#en Resume playing background music. + !#zh 恢复播放背景音乐。 + + @example + ```js + cc.audioEngine.resumeMusic(); + ``` + */ + static resumeMusic(): void; + /** + !#en Get the volume(0.0 ~ 1.0). + !#zh 获取音量(0.0 ~ 1.0)。 + + @example + ```js + var volume = cc.audioEngine.getMusicVolume(); + ``` + */ + static getMusicVolume(): number; + /** + !#en Set the background music volume. + !#zh 设置背景音乐音量(0.0 ~ 1.0)。 + @param volume Volume must be in 0.0~1.0. + + @example + ```js + cc.audioEngine.setMusicVolume(0.5); + ``` + */ + static setMusicVolume(volume: number): void; + /** + !#en Background music playing state + !#zh 背景音乐是否正在播放 + + @example + ```js + cc.audioEngine.isMusicPlaying(); + ``` + */ + static isMusicPlaying(): boolean; + /** + !#en Play effect audio. + !#zh 播放音效 + @param clip The audio clip to play. + @param loop Whether the music loop or not. + + @example + ```js + cc.resources.load(path, cc.AudioClip, null, function (err, clip) { + var audioID = cc.audioEngine.playEffect(clip, false); + }); + ``` + */ + static playEffect(clip: AudioClip, loop: boolean): number; + /** + !#en Set the volume of effect audio. + !#zh 设置音效音量(0.0 ~ 1.0)。 + @param volume Volume must be in 0.0~1.0. + + @example + ```js + cc.audioEngine.setEffectsVolume(0.5); + ``` + */ + static setEffectsVolume(volume: number): void; + /** + !#en The volume of the effect audio max value is 1.0,the min value is 0.0 . + !#zh 获取音效音量(0.0 ~ 1.0)。 + + @example + ```js + var volume = cc.audioEngine.getEffectsVolume(); + ``` + */ + static getEffectsVolume(): number; + /** + !#en Pause effect audio. + !#zh 暂停播放音效。 + @param audioID audio id. + + @example + ```js + cc.audioEngine.pauseEffect(audioID); + ``` + */ + static pauseEffect(audioID: number): void; + /** + !#en Stop playing all the sound effects. + !#zh 暂停播放所有音效。 + + @example + ```js + cc.audioEngine.pauseAllEffects(); + ``` + */ + static pauseAllEffects(): void; + /** + !#en Resume effect audio. + !#zh 恢复播放音效音频。 + @param audioID The return value of function play. + + @example + ```js + cc.audioEngine.resumeEffect(audioID); + ``` + */ + static resumeEffect(audioID: number): void; + /** + !#en Resume all effect audio. + !#zh 恢复播放所有之前暂停的音效。 + + @example + ```js + cc.audioEngine.resumeAllEffects(); + ``` + */ + static resumeAllEffects(): void; + /** + !#en Stop playing the effect audio. + !#zh 停止播放音效。 + @param audioID audio id. + + @example + ```js + cc.audioEngine.stopEffect(id); + ``` + */ + static stopEffect(audioID: number): void; + /** + !#en Stop playing all the effects. + !#zh 停止播放所有音效。 + + @example + ```js + cc.audioEngine.stopAllEffects(); + ``` + */ + static stopAllEffects(): void; + } + /** !#en An object to boot the game. + !#zh 包含游戏主体信息并负责驱动游戏的游戏对象。 */ + export class debug { + /** + !#en Gets error message with the error id and possible parameters. + !#zh 通过 error id 和必要的参数来获取错误信息。 + @param errorId errorId + @param param param + */ + static getError(errorId: string, param?: any): string; + /** + !#en Returns whether or not to display the FPS informations. + !#zh 是否显示 FPS 信息。 + */ + static isDisplayStats(): boolean; + /** + !#en Sets whether display the FPS on the bottom-left corner. + !#zh 设置是否在左下角显示 FPS。 + @param displayStats displayStats + */ + static setDisplayStats(displayStats: boolean): void; + } + /** !#en An object to boot the game. + !#zh 包含游戏主体信息并负责驱动游戏的游戏对象。 */ + export class Game extends EventTarget { + /** !#en Event triggered when game hide to background. + Please note that this event is not 100% guaranteed to be fired on Web platform, + on native platforms, it corresponds to enter background event, os status bar or notification center may not trigger this event. + !#zh 游戏进入后台时触发的事件。 + 请注意,在 WEB 平台,这个事件不一定会 100% 触发,这完全取决于浏览器的回调行为。 + 在原生平台,它对应的是应用被切换到后台事件,下拉菜单和上拉状态栏等不一定会触发这个事件,这取决于系统行为。 */ + EVENT_HIDE: string; + /** !#en Event triggered when game back to foreground + Please note that this event is not 100% guaranteed to be fired on Web platform, + on native platforms, it corresponds to enter foreground event. + !#zh 游戏进入前台运行时触发的事件。 + 请注意,在 WEB 平台,这个事件不一定会 100% 触发,这完全取决于浏览器的回调行为。 + 在原生平台,它对应的是应用被切换到前台事件。 */ + EVENT_SHOW: string; + /** !#en Event triggered when game restart + !#zh 调用restart后,触发事件。 */ + EVENT_RESTART: string; + /** Event triggered after game inited, at this point all engine objects and game scripts are loaded */ + EVENT_GAME_INITED: string; + /** Event triggered after engine inited, at this point you will be able to use all engine classes. + It was defined as EVENT_RENDERER_INITED in cocos creator v1.x and renamed in v2.0 */ + EVENT_ENGINE_INITED: string; + /** Web Canvas 2d API as renderer backend */ + RENDER_TYPE_CANVAS: number; + /** WebGL API as renderer backend */ + RENDER_TYPE_WEBGL: number; + /** OpenGL API as renderer backend */ + RENDER_TYPE_OPENGL: number; + /** !#en The outer frame of the game canvas, parent of game container. + !#zh 游戏画布的外框,container 的父容器。 */ + frame: any; + /** !#en The container of game canvas. + !#zh 游戏画布的容器。 */ + container: HTMLDivElement; + /** !#en The canvas of the game. + !#zh 游戏的画布。 */ + canvas: HTMLCanvasElement; + /** !#en The renderer backend of the game. + !#zh 游戏的渲染器类型。 */ + renderType: number; + /** !#en + The current game configuration, including:
+ 1. debugMode
+ "debugMode" possible values :
+ 0 - No message will be printed.
+ 1 - cc.error, cc.assert, cc.warn, cc.log will print in console.
+ 2 - cc.error, cc.assert, cc.warn will print in console.
+ 3 - cc.error, cc.assert will print in console.
+ 4 - cc.error, cc.assert, cc.warn, cc.log will print on canvas, available only on web.
+ 5 - cc.error, cc.assert, cc.warn will print on canvas, available only on web.
+ 6 - cc.error, cc.assert will print on canvas, available only on web.
+ 2. showFPS
+ Left bottom corner fps information will show when "showFPS" equals true, otherwise it will be hide.
+ 3. exposeClassName
+ Expose class name to chrome debug tools, the class intantiate performance is a little bit slower when exposed.
+ 4. frameRate
+ "frameRate" set the wanted frame rate for your game, but the real fps depends on your game implementation and the running environment.
+ 5. id
+ "gameCanvas" sets the id of your canvas element on the web page, it's useful only on web.
+ 6. renderMode
+ "renderMode" sets the renderer type, only useful on web :
+ 0 - Automatically chosen by engine
+ 1 - Forced to use canvas renderer
+ 2 - Forced to use WebGL renderer, but this will be ignored on mobile browsers
+
+ Please DO NOT modify this object directly, it won't have any effect.
+ !#zh + 当前的游戏配置,包括:
+ 1. debugMode(debug 模式,但是在浏览器中这个选项会被忽略)
+ "debugMode" 各种设置选项的意义。
+ 0 - 没有消息被打印出来。
+ 1 - cc.error,cc.assert,cc.warn,cc.log 将打印在 console 中。
+ 2 - cc.error,cc.assert,cc.warn 将打印在 console 中。
+ 3 - cc.error,cc.assert 将打印在 console 中。
+ 4 - cc.error,cc.assert,cc.warn,cc.log 将打印在 canvas 中(仅适用于 web 端)。
+ 5 - cc.error,cc.assert,cc.warn 将打印在 canvas 中(仅适用于 web 端)。
+ 6 - cc.error,cc.assert 将打印在 canvas 中(仅适用于 web 端)。
+ 2. showFPS(显示 FPS)
+ 当 showFPS 为 true 的时候界面的左下角将显示 fps 的信息,否则被隐藏。
+ 3. exposeClassName
+ 暴露类名让 Chrome DevTools 可以识别,如果开启会稍稍降低类的创建过程的性能,但对对象构造没有影响。
+ 4. frameRate (帧率)
+ “frameRate” 设置想要的帧率你的游戏,但真正的FPS取决于你的游戏实现和运行环境。
+ 5. id
+ "gameCanvas" Web 页面上的 Canvas Element ID,仅适用于 web 端。
+ 6. renderMode(渲染模式)
+ “renderMode” 设置渲染器类型,仅适用于 web 端:
+ 0 - 通过引擎自动选择。
+ 1 - 强制使用 canvas 渲染。 + 2 - 强制使用 WebGL 渲染,但是在部分 Android 浏览器中这个选项会被忽略。
+
+ 注意:请不要直接修改这个对象,它不会有任何效果。 */ + config: any; + /** + !#en Callback when the scripts of engine have been load. + !#zh 当引擎完成启动后的回调函数。 + */ + onStart(): void; + /** + !#en Set frame rate of game. + !#zh 设置游戏帧率。 + @param frameRate frameRate + */ + setFrameRate(frameRate: number): void; + /** + !#en Get frame rate set for the game, it doesn't represent the real frame rate. + !#zh 获取设置的游戏帧率(不等同于实际帧率)。 + */ + getFrameRate(): number; + /** + !#en Run the game frame by frame. + !#zh 执行一帧游戏循环。 + */ + step(): void; + /** + !#en Pause the game main loop. This will pause: + game logic execution, rendering process, event manager, background music and all audio effects. + This is different with cc.director.pause which only pause the game logic execution. + !#zh 暂停游戏主循环。包含:游戏逻辑,渲染,事件处理,背景音乐和所有音效。这点和只暂停游戏逻辑的 cc.director.pause 不同。 + */ + pause(): void; + /** + !#en Resume the game from pause. This will resume: + game logic execution, rendering process, event manager, background music and all audio effects. + !#zh 恢复游戏主循环。包含:游戏逻辑,渲染,事件处理,背景音乐和所有音效。 + */ + resume(): void; + /** + !#en Check whether the game is paused. + !#zh 判断游戏是否暂停。 + */ + isPaused(): boolean; + /** + !#en Restart game. + !#zh 重新开始游戏 + */ + restart(): void; + /** + !#en End game, it will close the game window + !#zh 退出游戏 + */ + end(): void; + /** + !#en + Register an callback of a specific event type on the game object. + This type of event should be triggered via `emit`. + !#zh + 注册 game 的特定事件类型回调。这种类型的事件应该被 `emit` 触发。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + */ + on(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Register an callback of a specific event type on the game object, + the callback will remove itself after the first time it is triggered. + !#zh + 注册 game 的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + */ + once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; + /** + !#en Prepare game. + !#zh 准备引擎,请不要直接调用这个函数。 + @param cb cb + */ + prepare(cb: Function): void; + /** + !#en Run game with configuration object and onStart function. + !#zh 运行游戏,并且指定引擎配置和 onStart 的回调。 + @param config Pass configuration object or onStart function + @param onStart function to be executed after game initialized + */ + run(config: any, onStart: Function): void; + /** + !#en + Add a persistent root node to the game, the persistent node won't be destroyed during scene transition.
+ The target node must be placed in the root level of hierarchy, otherwise this API won't have any effect. + !#zh + 声明常驻根节点,该节点不会被在场景切换中被销毁。
+ 目标节点必须位于为层级的根节点,否则无效。 + @param node The node to be made persistent + */ + addPersistRootNode(node: Node): void; + /** + !#en Remove a persistent root node. + !#zh 取消常驻根节点。 + @param node The node to be removed from persistent node list + */ + removePersistRootNode(node: Node): void; + /** + !#en Check whether the node is a persistent root node. + !#zh 检查节点是否是常驻根节点。 + @param node The node to be checked + */ + isPersistRootNode(node: Node): boolean; + } + /** !#en + Class of all entities in Cocos Creator scenes.
+ For events supported by Node, please refer to {{#crossLink "Node.EventType"}}{{/crossLink}} + !#zh + Cocos Creator 场景中的所有节点类。
+ 支持的节点事件,请参阅 {{#crossLink "Node.EventType"}}{{/crossLink}}。 */ + export class Node extends _BaseNode { + /** !#en + Group index of node.
+ Which Group this node belongs to will resolve that this node's collision components can collide with which other collision componentns.
+ !#zh + 节点的分组索引。
+ 节点的分组将关系到节点的碰撞组件可以与哪些碰撞组件相碰撞。
*/ + groupIndex: number; + /** !#en + Group of node.
+ Which Group this node belongs to will resolve that this node's collision components can collide with which other collision componentns.
+ !#zh + 节点的分组。
+ 节点的分组将关系到节点的碰撞组件可以与哪些碰撞组件相碰撞。
*/ + group: string; + /** !#en The position (x, y) of the node in its parent's coordinates. + !#zh 节点在父节点坐标系中的位置(x, y)。 */ + position: Vec3; + /** !#en x axis position of node. + !#zh 节点 X 轴坐标。 */ + x: number; + /** !#en y axis position of node. + !#zh 节点 Y 轴坐标。 */ + y: number; + /** !#en z axis position of node. + !#zh 节点 Z 轴坐标。 */ + z: number; + /** !#en Rotation of node. + !#zh 该节点旋转角度。 */ + rotation: number; + /** !#en + Angle of node, the positive value is anti-clockwise direction. + !#zh + 该节点的旋转角度,正值为逆时针方向。 */ + angle: number; + /** !#en The rotation as Euler angles in degrees, used in 3D node. + !#zh 该节点的欧拉角度,用于 3D 节点。 */ + eulerAngles: Vec3; + /** !#en Rotation on x axis. + !#zh 该节点 X 轴旋转角度。 */ + rotationX: number; + /** !#en Rotation on y axis. + !#zh 该节点 Y 轴旋转角度。 */ + rotationY: number; + /** !#en The local scale relative to the parent. + !#zh 节点相对父节点的缩放。 */ + scale: number; + /** !#en Scale on x axis. + !#zh 节点 X 轴缩放。 */ + scaleX: number; + /** !#en Scale on y axis. + !#zh 节点 Y 轴缩放。 */ + scaleY: number; + /** !#en Scale on z axis. + !#zh 节点 Z 轴缩放。 */ + scaleZ: number; + /** !#en Skew x + !#zh 该节点 X 轴倾斜角度。 */ + skewX: number; + /** !#en Skew y + !#zh 该节点 Y 轴倾斜角度。 */ + skewY: number; + /** !#en Opacity of node, default value is 255. + !#zh 节点透明度,默认值为 255。 */ + opacity: number; + /** !#en Color of node, default value is white: (255, 255, 255). + !#zh 节点颜色。默认为白色,数值为:(255,255,255)。 */ + color: Color; + /** !#en Anchor point's position on x axis. + !#zh 节点 X 轴锚点位置。 */ + anchorX: number; + /** !#en Anchor point's position on y axis. + !#zh 节点 Y 轴锚点位置。 */ + anchorY: number; + /** !#en Width of node. + !#zh 节点宽度。 */ + width: number; + /** !#en Height of node. + !#zh 节点高度。 */ + height: number; + /** !#en zIndex is the 'key' used to sort the node relative to its siblings.
+ The value of zIndex should be in the range between cc.macro.MIN_ZINDEX and cc.macro.MAX_ZINDEX.
+ The Node's parent will sort all its children based on the zIndex value and the arrival order.
+ Nodes with greater zIndex will be sorted after nodes with smaller zIndex.
+ If two nodes have the same zIndex, then the node that was added first to the children's array will be in front of the other node in the array.
+ Node's order in children list will affect its rendering order. Parent is always rendering before all children. + !#zh zIndex 是用来对节点进行排序的关键属性,它决定一个节点在兄弟节点之间的位置。
+ zIndex 的取值应该介于 cc.macro.MIN_ZINDEX 和 cc.macro.MAX_ZINDEX 之间 + 父节点主要根据节点的 zIndex 和添加次序来排序,拥有更高 zIndex 的节点将被排在后面,如果两个节点的 zIndex 一致,先添加的节点会稳定排在另一个节点之前。
+ 节点在 children 中的顺序决定了其渲染顺序。父节点永远在所有子节点之前被渲染 */ + zIndex: number; + /** !#en + Switch 2D/3D node. The 2D nodes will run faster. + !#zh + 切换 2D/3D 节点,2D 节点会有更高的运行效率 */ + is3DNode: boolean; + /** !#en Returns a normalized vector representing the up direction (Y axis) of the node in world space. + !#zh 获取节点正上方(y 轴)面对的方向,返回值为世界坐标系下的归一化向量 */ + up: Vec3; + /** !#en Returns a normalized vector representing the right direction (X axis) of the node in world space. + !#zh 获取节点正右方(x 轴)面对的方向,返回值为世界坐标系下的归一化向量 */ + right: Vec3; + /** !#en Returns a normalized vector representing the forward direction (Z axis) of the node in world space. + !#zh 获取节点正前方(z 轴)面对的方向,返回值为世界坐标系下的归一化向量 */ + forward: Vec3; + /** + + @param name name + */ + constructor(name?: string); + /** + !#en + Register a callback of a specific event type on Node.
+ Use this method to register touch or mouse event permit propagation based on scene graph,
+ These kinds of event are triggered with dispatchEvent, the dispatch process has three steps:
+ 1. Capturing phase: dispatch in capture targets (`_getCapturingTargets`), e.g. parents in node tree, from root to the real target
+ 2. At target phase: dispatch to the listeners of the real target
+ 3. Bubbling phase: dispatch in bubble targets (`_getBubblingTargets`), e.g. parents in node tree, from the real target to root
+ In any moment of the dispatching process, it can be stopped via `event.stopPropagation()` or `event.stopPropagationImmidiate()`.
+ It's the recommended way to register touch/mouse event for Node,
+ please do not use cc.eventManager directly for Node.
+ You can also register custom event and use `emit` to trigger custom event on Node.
+ For such events, there won't be capturing and bubbling phase, your event will be dispatched directly to its listeners registered on the same node.
+ You can also pass event callback parameters with `emit` by passing parameters after `type`. + !#zh + 在节点上注册指定类型的回调函数,也可以设置 target 用于绑定响应函数的 this 对象。
+ 鼠标或触摸事件会被系统调用 dispatchEvent 方法触发,触发的过程包含三个阶段:
+ 1. 捕获阶段:派发事件给捕获目标(通过 `_getCapturingTargets` 获取),比如,节点树中注册了捕获阶段的父节点,从根节点开始派发直到目标节点。
+ 2. 目标阶段:派发给目标节点的监听器。
+ 3. 冒泡阶段:派发事件给冒泡目标(通过 `_getBubblingTargets` 获取),比如,节点树中注册了冒泡阶段的父节点,从目标节点开始派发直到根节点。
+ 同时您可以将事件派发到父节点或者通过调用 stopPropagation 拦截它。
+ 推荐使用这种方式来监听节点上的触摸或鼠标事件,请不要在节点上直接使用 cc.eventManager。
+ 你也可以注册自定义事件到节点上,并通过 emit 方法触发此类事件,对于这类事件,不会发生捕获冒泡阶段,只会直接派发给注册在该节点上的监听器
+ 你可以通过在 emit 方法调用时在 type 之后传递额外的参数作为事件回调的参数列表 + @param type A string representing the event type to listen for.
See {{#crossLink "Node/EventTyupe/POSITION_CHANGED"}}Node Events{{/crossLink}} for all builtin events. + @param callback The callback that will be invoked when the event is dispatched. The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + @param useCapture When set to true, the listener will be triggered at capturing phase which is ahead of the final target emit, otherwise it will be triggered during bubbling phase. + + @example + ```js + this.node.on(cc.Node.EventType.TOUCH_START, this.memberFunction, this); // if "this" is component and the "memberFunction" declared in CCClass. + node.on(cc.Node.EventType.TOUCH_START, callback, this); + node.on(cc.Node.EventType.TOUCH_MOVE, callback, this); + node.on(cc.Node.EventType.TOUCH_END, callback, this); + node.on(cc.Node.EventType.TOUCH_CANCEL, callback, this); + node.on(cc.Node.EventType.ANCHOR_CHANGED, callback); + node.on(cc.Node.EventType.COLOR_CHANGED, callback); + ``` + */ + on(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Register an callback of a specific event type on the Node, + the callback will remove itself after the first time it is triggered. + !#zh + 注册节点的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + node.once(cc.Node.EventType.ANCHOR_CHANGED, callback); + ``` + */ + once(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Removes the callback previously registered with the same type, callback, target and or useCapture. + This method is merely an alias to removeEventListener. + !#zh 删除之前与同类型,回调,目标或 useCapture 注册的回调。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + @param useCapture When set to true, the listener will be triggered at capturing phase which is ahead of the final target emit, otherwise it will be triggered during bubbling phase. + + @example + ```js + this.node.off(cc.Node.EventType.TOUCH_START, this.memberFunction, this); + node.off(cc.Node.EventType.TOUCH_START, callback, this.node); + node.off(cc.Node.EventType.ANCHOR_CHANGED, callback, this); + ``` + */ + off(type: string, callback?: Function, target?: any, useCapture?: boolean): void; + /** + !#en Removes all callbacks previously registered with the same target. + !#zh 移除目标上的所有注册事件。 + @param target The target to be searched for all related callbacks + + @example + ```js + node.targetOff(target); + ``` + */ + targetOff(target: any): void; + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en + Trigger an event directly with the event name and necessary arguments. + !#zh + 通过事件名发送自定义事件 + @param type event type + @param arg1 First argument in callback + @param arg2 Second argument in callback + @param arg3 Third argument in callback + @param arg4 Fourth argument in callback + @param arg5 Fifth argument in callback + + @example + ```js + eventTarget.emit('fire', event); + eventTarget.emit('fire', message, emitter); + ``` + */ + emit(type: string, arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any): void; + /** + !#en + Dispatches an event into the event flow. + The event target is the EventTarget object upon which the dispatchEvent() method is called. + !#zh 分发事件到事件流中。 + @param event The Event object that is dispatched into the event flow + */ + dispatchEvent(event: Event): void; + /** + !#en Pause node related system events registered with the current Node. Node system events includes touch and mouse events. + If recursive is set to true, then this API will pause the node system events for the node and all nodes in its sub node tree. + Reference: http://docs.cocos2d-x.org/editors_and_tools/creator-chapters/scripting/internal-events/ + !#zh 暂停当前节点上注册的所有节点系统事件,节点系统事件包含触摸和鼠标事件。 + 如果传递 recursive 为 true,那么这个 API 将暂停本节点和它的子树上所有节点的节点系统事件。 + 参考:https://www.cocos.com/docs/creator/scripting/internal-events.html + @param recursive Whether to pause node system events on the sub node tree. + + @example + ```js + node.pauseSystemEvents(true); + ``` + */ + pauseSystemEvents(recursive: boolean): void; + /** + !#en Resume node related system events registered with the current Node. Node system events includes touch and mouse events. + If recursive is set to true, then this API will resume the node system events for the node and all nodes in its sub node tree. + Reference: http://docs.cocos2d-x.org/editors_and_tools/creator-chapters/scripting/internal-events/ + !#zh 恢复当前节点上注册的所有节点系统事件,节点系统事件包含触摸和鼠标事件。 + 如果传递 recursive 为 true,那么这个 API 将恢复本节点和它的子树上所有节点的节点系统事件。 + 参考:https://www.cocos.com/docs/creator/scripting/internal-events.html + @param recursive Whether to resume node system events on the sub node tree. + + @example + ```js + node.resumeSystemEvents(true); + ``` + */ + resumeSystemEvents(recursive: boolean): void; + /** + !#en + Executes an action, and returns the action that is executed.
+ The node becomes the action's target. Refer to cc.Action's getTarget()
+ Calling runAction while the node is not active won't have any effect.
+ Note:You shouldn't modify the action after runAction, that won't take any effect.
+ if you want to modify, when you define action plus. + !#zh + 执行并返回该执行的动作。该节点将会变成动作的目标。
+ 调用 runAction 时,节点自身处于不激活状态将不会有任何效果。
+ 注意:你不应该修改 runAction 后的动作,将无法发挥作用,如果想进行修改,请在定义 action 时加入。 + @param action action + + @example + ```js + var action = cc.scaleTo(0.2, 1, 0.6); + node.runAction(action); + node.runAction(action).repeatForever(); // fail + node.runAction(action.repeatForever()); // right + ``` + */ + runAction(action: Action): Action; + /** + !#en Pause all actions running on the current node. Equals to `cc.director.getActionManager().pauseTarget(node)`. + !#zh 暂停本节点上所有正在运行的动作。和 `cc.director.getActionManager().pauseTarget(node);` 等价。 + + @example + ```js + node.pauseAllActions(); + ``` + */ + pauseAllActions(): void; + /** + !#en Resume all paused actions on the current node. Equals to `cc.director.getActionManager().resumeTarget(node)`. + !#zh 恢复运行本节点上所有暂停的动作。和 `cc.director.getActionManager().resumeTarget(node);` 等价。 + + @example + ```js + node.resumeAllActions(); + ``` + */ + resumeAllActions(): void; + /** + !#en Stops and removes all actions from the running action list . + !#zh 停止并且移除所有正在运行的动作列表。 + + @example + ```js + node.stopAllActions(); + ``` + */ + stopAllActions(): void; + /** + !#en Stops and removes an action from the running action list. + !#zh 停止并移除指定的动作。 + @param action An action object to be removed. + + @example + ```js + var action = cc.scaleTo(0.2, 1, 0.6); + node.stopAction(action); + ``` + */ + stopAction(action: Action): void; + /** + !#en Removes an action from the running action list by its tag. + !#zh 停止并且移除指定标签的动作。 + @param tag A tag that indicates the action to be removed. + + @example + ```js + node.stopActionByTag(1); + ``` + */ + stopActionByTag(tag: number): void; + /** + !#en Returns an action from the running action list by its tag. + !#zh 通过标签获取指定动作。 + @param tag tag + + @example + ```js + var action = node.getActionByTag(1); + ``` + */ + getActionByTag(tag: number): Action; + /** + !#en + Returns the numbers of actions that are running plus the ones that are schedule to run (actions in actionsToAdd and actions arrays).
+ Composable actions are counted as 1 action. Example:
+ If you are running 1 Sequence of 7 actions, it will return 1.
+ If you are running 7 Sequences of 2 actions, it will return 7.

+ !#zh + 获取运行着的动作加上正在调度运行的动作的总数。
+ 例如:
+ - 如果你正在运行 7 个动作中的 1 个 Sequence,它将返回 1。
+ - 如果你正在运行 2 个动作中的 7 个 Sequence,它将返回 7。
+ + @example + ```js + var count = node.getNumberOfRunningActions(); + cc.log("Running Action Count: " + count); + ``` + */ + getNumberOfRunningActions(): number; + /** + !#en + Returns a copy of the position (x, y, z) of the node in its parent's coordinates. + You can pass a cc.Vec2 or cc.Vec3 as the argument to receive the return values. + !#zh + 获取节点在父节点坐标系中的位置(x, y, z)。 + 你可以传一个 cc.Vec2 或者 cc.Vec3 作为参数来接收返回值。 + @param out The return value to receive position + + @example + ```js + cc.log("Node Position: " + node.getPosition()); + ``` + */ + getPosition(out?: Vec2|Vec3): Vec2; + /** + !#en + Sets the position (x, y, z) of the node in its parent's coordinates.
+ Usually we use cc.v2(x, y) to compose cc.Vec2 object,
+ and passing two numbers (x, y) is more efficient than passing cc.Vec2 object. + For 3D node we can use cc.v3(x, y, z) to compose cc.Vec3 object,
+ and passing three numbers (x, y, z) is more efficient than passing cc.Vec3 object. + !#zh + 设置节点在父节点坐标系中的位置。
+ 可以通过下面的方式设置坐标点:
+ 1. 传入 2 个数值 x, y。
+ 2. 传入 cc.v2(x, y) 类型为 cc.Vec2 的对象。 + 3. 对于 3D 节点可以传入 3 个数值 x, y, z。
+ 4. 对于 3D 节点可以传入 cc.v3(x, y, z) 类型为 cc.Vec3 的对象。 + @param newPosOrX X coordinate for position or the position (x, y, z) of the node in coordinates + @param y Y coordinate for position + @param z Z coordinate for position + */ + setPosition(newPosOrX: Vec2|Vec3|number, y?: number, z?: number): void; + /** + !#en + Returns the scale factor of the node. + Need pass a cc.Vec2 or cc.Vec3 as the argument to receive the return values. + !#zh 获取节点的缩放,需要传一个 cc.Vec2 或者 cc.Vec3 作为参数来接收返回值。 + @param out out + + @example + ```js + cc.log("Node Scale: " + node.getScale(cc.v3())); + ``` + */ + getScale(out: Vec2|Vec3): Vec2; + /** + !#en + Sets the scale of axis in local coordinates of the node. + You can operate 2 axis in 2D node, and 3 axis in 3D node. + !#zh + 设置节点在本地坐标系中坐标轴上的缩放比例。 + 2D 节点可以操作两个坐标轴,而 3D 节点可以操作三个坐标轴。 + @param x scaleX or scale object + @param y y + @param z z + + @example + ```js + node.setScale(cc.v2(2, 2)); + node.setScale(cc.v3(2, 2, 2)); // for 3D node + node.setScale(2); + ``` + */ + setScale(x: number|Vec2|Vec3, y?: number, z?: number): void; + /** + !#en + Get rotation of node (in quaternion). + Need pass a cc.Quat as the argument to receive the return values. + !#zh + 获取该节点的 quaternion 旋转角度,需要传一个 cc.Quat 作为参数来接收返回值。 + @param out out + */ + getRotation(out: Quat): Quat; + /** + !#en Set rotation of node (in quaternion). + !#zh 设置该节点的 quaternion 旋转角度。 + @param quat Quaternion object represents the rotation or the x value of quaternion + @param y y value of quternion + @param z z value of quternion + @param w w value of quternion + */ + setRotation(quat: Quat|number, y?: number, z?: number, w?: number): void; + /** + !#en + Returns a copy the untransformed size of the node.
+ The contentSize remains the same no matter the node is scaled or rotated.
+ All nodes has a size. Layer and Scene has the same size of the screen by default.
+ !#zh 获取节点自身大小,不受该节点是否被缩放或者旋转的影响。 + + @example + ```js + cc.log("Content Size: " + node.getContentSize()); + ``` + */ + getContentSize(): Size; + /** + !#en + Sets the untransformed size of the node.
+ The contentSize remains the same no matter the node is scaled or rotated.
+ All nodes has a size. Layer and Scene has the same size of the screen. + !#zh 设置节点原始大小,不受该节点是否被缩放或者旋转的影响。 + @param size The untransformed size of the node or The untransformed size's width of the node. + @param height The untransformed size's height of the node. + + @example + ```js + node.setContentSize(cc.size(100, 100)); + node.setContentSize(100, 100); + ``` + */ + setContentSize(size: Size|number, height?: number): void; + /** + !#en + Returns a copy of the anchor point.
+ Anchor point is the point around which all transformations and positioning manipulations take place.
+ It's like a pin in the node where it is "attached" to its parent.
+ The anchorPoint is normalized, like a percentage. (0,0) means the bottom-left corner and (1,1) means the top-right corner.
+ But you can use values higher than (1,1) and lower than (0,0) too.
+ The default anchor point is (0.5,0.5), so it starts at the center of the node. + !#zh + 获取节点锚点,用百分比表示。
+ 锚点应用于所有变换和坐标点的操作,它就像在节点上连接其父节点的大头针。
+ 锚点是标准化的,就像百分比一样。(0,0) 表示左下角,(1,1) 表示右上角。
+ 但是你可以使用比(1,1)更高的值或者比(0,0)更低的值。
+ 默认的锚点是(0.5,0.5),因此它开始于节点的中心位置。
+ 注意:Creator 中的锚点仅用于定位所在的节点,子节点的定位不受影响。 + + @example + ```js + cc.log("Node AnchorPoint: " + node.getAnchorPoint()); + ``` + */ + getAnchorPoint(): Vec2; + /** + !#en + Sets the anchor point in percent.
+ anchor point is the point around which all transformations and positioning manipulations take place.
+ It's like a pin in the node where it is "attached" to its parent.
+ The anchorPoint is normalized, like a percentage. (0,0) means the bottom-left corner and (1,1) means the top-right corner.
+ But you can use values higher than (1,1) and lower than (0,0) too.
+ The default anchor point is (0.5,0.5), so it starts at the center of the node. + !#zh + 设置锚点的百分比。
+ 锚点应用于所有变换和坐标点的操作,它就像在节点上连接其父节点的大头针。
+ 锚点是标准化的,就像百分比一样。(0,0) 表示左下角,(1,1) 表示右上角。
+ 但是你可以使用比(1,1)更高的值或者比(0,0)更低的值。
+ 默认的锚点是(0.5,0.5),因此它开始于节点的中心位置。
+ 注意:Creator 中的锚点仅用于定位所在的节点,子节点的定位不受影响。 + @param point The anchor point of node or The x axis anchor of node. + @param y The y axis anchor of node. + + @example + ```js + node.setAnchorPoint(cc.v2(1, 1)); + node.setAnchorPoint(1, 1); + ``` + */ + setAnchorPoint(point: Vec2|number, y?: number): void; + /** + !#en Set rotation by lookAt target point, normally used by Camera Node + !#zh 通过观察目标来设置 rotation,一般用于 Camera Node 上 + @param pos pos + @param up default is (0,1,0) + */ + lookAt(pos: Vec3, up?: Vec3): void; + /** + !#en + Get the local transform matrix (4x4), based on parent node coordinates + !#zh 返回局部空间坐标系的矩阵,基于父节点坐标系。 + @param out The matrix object to be filled with data + + @example + ```js + let mat4 = cc.mat4(); + node.getLocalMatrix(mat4); + ``` + */ + getLocalMatrix(out: Mat4): Mat4; + /** + !#en + Get the world transform matrix (4x4) + !#zh 返回世界空间坐标系的矩阵。 + @param out The matrix object to be filled with data + + @example + ```js + let mat4 = cc.mat4(); + node.getWorldMatrix(mat4); + ``` + */ + getWorldMatrix(out: Mat4): Mat4; + /** + !#en + Converts a Point to node (local) space coordinates. + !#zh + 将一个点转换到节点 (局部) 空间坐标系。 + @param worldPoint worldPoint + @param out out + + @example + ```js + var newVec2 = node.convertToNodeSpaceAR(cc.v2(100, 100)); + var newVec3 = node.convertToNodeSpaceAR(cc.v3(100, 100, 100)); + ``` + */ + convertToNodeSpaceAR(worldPoint: T, out?: T): T; + /** + !#en + Converts a Point in node coordinates to world space coordinates. + !#zh + 将节点坐标系下的一个点转换到世界空间坐标系。 + @param nodePoint nodePoint + @param out out + + @example + ```js + var newVec2 = node.convertToWorldSpaceAR(cc.v2(100, 100)); + var newVec3 = node.convertToWorldSpaceAR(cc.v3(100, 100, 100)); + ``` + */ + convertToWorldSpaceAR(nodePoint: T, out?: T): T; + /** + !#en Converts a Point to node (local) space coordinates then add the anchor point position. + So the return position will be related to the left bottom corner of the node's bounding box. + This equals to the API behavior of cocos2d-x, you probably want to use convertToNodeSpaceAR instead + !#zh 将一个点转换到节点 (局部) 坐标系,并加上锚点的坐标。
+ 也就是说返回的坐标是相对于节点包围盒左下角的坐标。
+ 这个 API 的设计是为了和 cocos2d-x 中行为一致,更多情况下你可能需要使用 convertToNodeSpaceAR。 + @param worldPoint worldPoint + + @example + ```js + var newVec2 = node.convertToNodeSpace(cc.v2(100, 100)); + ``` + */ + convertToNodeSpace(worldPoint: Vec2): Vec2; + /** + !#en Converts a Point related to the left bottom corner of the node's bounding box to world space coordinates. + This equals to the API behavior of cocos2d-x, you probably want to use convertToWorldSpaceAR instead + !#zh 将一个相对于节点左下角的坐标位置转换到世界空间坐标系。 + 这个 API 的设计是为了和 cocos2d-x 中行为一致,更多情况下你可能需要使用 convertToWorldSpaceAR + @param nodePoint nodePoint + + @example + ```js + var newVec2 = node.convertToWorldSpace(cc.v2(100, 100)); + ``` + */ + convertToWorldSpace(nodePoint: Vec2): Vec2; + /** + !#en + Returns the matrix that transform the node's (local) space coordinates into the parent's space coordinates.
+ The matrix is in Pixels. + !#zh 返回这个将节点(局部)的空间坐标系转换成父节点的空间坐标系的矩阵。这个矩阵以像素为单位。 + @param out The affine transform object to be filled with data + + @example + ```js + let affineTransform = cc.AffineTransform.create(); + node.getNodeToParentTransform(affineTransform); + ``` + */ + getNodeToParentTransform(out?: AffineTransform): AffineTransform; + /** + !#en + Returns the matrix that transform the node's (local) space coordinates into the parent's space coordinates.
+ The matrix is in Pixels.
+ This method is AR (Anchor Relative). + !#zh + 返回这个将节点(局部)的空间坐标系转换成父节点的空间坐标系的矩阵。
+ 这个矩阵以像素为单位。
+ 该方法基于节点坐标。 + @param out The affine transform object to be filled with data + + @example + ```js + let affineTransform = cc.AffineTransform.create(); + node.getNodeToParentTransformAR(affineTransform); + ``` + */ + getNodeToParentTransformAR(out?: AffineTransform): AffineTransform; + /** + !#en Returns the world affine transform matrix. The matrix is in Pixels. + !#zh 返回节点到世界坐标系的仿射变换矩阵。矩阵单位是像素。 + @param out The affine transform object to be filled with data + + @example + ```js + let affineTransform = cc.AffineTransform.create(); + node.getNodeToWorldTransform(affineTransform); + ``` + */ + getNodeToWorldTransform(out?: AffineTransform): AffineTransform; + /** + !#en + Returns the world affine transform matrix. The matrix is in Pixels.
+ This method is AR (Anchor Relative). + !#zh + 返回节点到世界坐标仿射变换矩阵。矩阵单位是像素。
+ 该方法基于节点坐标。 + @param out The affine transform object to be filled with data + + @example + ```js + let affineTransform = cc.AffineTransform.create(); + node.getNodeToWorldTransformAR(affineTransform); + ``` + */ + getNodeToWorldTransformAR(out?: AffineTransform): AffineTransform; + /** + !#en + Returns the matrix that transform parent's space coordinates to the node's (local) space coordinates.
+ The matrix is in Pixels. The returned transform is readonly and cannot be changed. + !#zh + 返回将父节点的坐标系转换成节点(局部)的空间坐标系的矩阵。
+ 该矩阵以像素为单位。返回的矩阵是只读的,不能更改。 + @param out The affine transform object to be filled with data + + @example + ```js + let affineTransform = cc.AffineTransform.create(); + node.getParentToNodeTransform(affineTransform); + ``` + */ + getParentToNodeTransform(out?: AffineTransform): AffineTransform; + /** + !#en Returns the inverse world affine transform matrix. The matrix is in Pixels. + !#en 返回世界坐标系到节点坐标系的逆矩阵。 + @param out The affine transform object to be filled with data + + @example + ```js + let affineTransform = cc.AffineTransform.create(); + node.getWorldToNodeTransform(affineTransform); + ``` + */ + getWorldToNodeTransform(out?: AffineTransform): AffineTransform; + /** + !#en convenience methods which take a cc.Touch instead of cc.Vec2. + !#zh 将触摸点转换成本地坐标系中位置。 + @param touch The touch object + + @example + ```js + var newVec2 = node.convertTouchToNodeSpace(touch); + ``` + */ + convertTouchToNodeSpace(touch: Touch): Vec2; + /** + !#en converts a cc.Touch (world coordinates) into a local coordinate. This method is AR (Anchor Relative). + !#zh 转换一个 cc.Touch(世界坐标)到一个局部坐标,该方法基于节点坐标。 + @param touch The touch object + + @example + ```js + var newVec2 = node.convertTouchToNodeSpaceAR(touch); + ``` + */ + convertTouchToNodeSpaceAR(touch: Touch): Vec2; + /** + !#en + Returns a "local" axis aligned bounding box of the node.
+ The returned box is relative only to its parent. + !#zh 返回父节坐标系下的轴向对齐的包围盒。 + + @example + ```js + var boundingBox = node.getBoundingBox(); + ``` + */ + getBoundingBox(): Rect; + /** + !#en + Returns a "world" axis aligned bounding box of the node.
+ The bounding box contains self and active children's world bounding box. + !#zh + 返回节点在世界坐标系下的对齐轴向的包围盒(AABB)。
+ 该边框包含自身和已激活的子节点的世界边框。 + + @example + ```js + var newRect = node.getBoundingBoxToWorld(); + ``` + */ + getBoundingBoxToWorld(): Rect; + /** + !#en + Adds a child to the node with z order and name. + !#zh + 添加子节点,并且可以修改该节点的 局部 Z 顺序和名字。 + @param child A child node + @param zIndex Z order for drawing priority. Please refer to zIndex property + @param name A name to identify the node easily. Please refer to name property + + @example + ```js + node.addChild(newNode, 1, "node"); + ``` + */ + addChild(child: Node, zIndex?: number, name?: string): void; + /** + !#en Stops all running actions and schedulers. + !#zh 停止所有正在播放的动作和计时器。 + + @example + ```js + node.cleanup(); + ``` + */ + cleanup(): void; + /** + !#en Sorts the children array depends on children's zIndex and arrivalOrder, + normally you won't need to invoke this function. + !#zh 根据子节点的 zIndex 和 arrivalOrder 进行排序,正常情况下开发者不需要手动调用这个函数。 + */ + sortAllChildren(): void; + /** + !#en + Returns the displayed opacity of Node, + the difference between displayed opacity and opacity is that displayed opacity is calculated based on opacity and parent node's opacity when cascade opacity enabled. + !#zh + 获取节点显示透明度, + 显示透明度和透明度之间的不同之处在于当启用级连透明度时, + 显示透明度是基于自身透明度和父节点透明度计算的。 + */ + getDisplayedOpacity(): number; + /** + !#en + Returns the displayed color of Node, + the difference between displayed color and color is that displayed color is calculated based on color and parent node's color when cascade color enabled. + !#zh + 获取节点的显示颜色, + 显示颜色和颜色之间的不同之处在于当启用级连颜色时, + 显示颜色是基于自身颜色和父节点颜色计算的。 + */ + getDisplayedColor(): Color; + /** !#en Cascade opacity is removed from v2.0 + Indicate whether node's opacity value affect its child nodes, default value is true. + !#zh 透明度级联功能从 v2.0 开始已移除 + 节点的不透明度值是否影响其子节点,默认值为 true。 */ + cascadeOpacity: boolean; + /** + !#en Cascade opacity is removed from v2.0 + Returns whether node's opacity value affect its child nodes. + !#zh 透明度级联功能从 v2.0 开始已移除 + 返回节点的不透明度值是否影响其子节点。 + */ + isCascadeOpacityEnabled(): boolean; + /** + !#en Cascade opacity is removed from v2.0 + Enable or disable cascade opacity, if cascade enabled, child nodes' opacity will be the multiplication of parent opacity and its own opacity. + !#zh 透明度级联功能从 v2.0 开始已移除 + 启用或禁用级连不透明度,如果级连启用,子节点的不透明度将是父不透明度乘上它自己的不透明度。 + @param cascadeOpacityEnabled cascadeOpacityEnabled + */ + setCascadeOpacityEnabled(cascadeOpacityEnabled: boolean): void; + /** + !#en Opacity modify RGB have been removed since v2.0 + Set whether color should be changed with the opacity value, + useless in ccsg.Node, but this function is override in some class to have such behavior. + !#zh 透明度影响颜色配置已经被废弃 + 设置更改透明度时是否修改RGB值, + @param opacityValue opacityValue + */ + setOpacityModifyRGB(opacityValue: boolean): void; + /** + !#en Opacity modify RGB have been removed since v2.0 + Get whether color should be changed with the opacity value. + !#zh 透明度影响颜色配置已经被废弃 + 获取更改透明度时是否修改RGB值。 + */ + isOpacityModifyRGB(): boolean; + } + /** !#en +

+ ATTENTION: USE cc.director INSTEAD OF cc.Director.
+ cc.director is a singleton object which manage your game's logic flow.
+ Since the cc.director is a singleton, you don't need to call any constructor or create functions,
+ the standard way to use it is by calling:
+ - cc.director.methodName();
+ + It creates and handle the main Window and manages how and when to execute the Scenes.
+
+ The cc.director is also responsible for:
+ - initializing the OpenGL context
+ - setting the OpenGL pixel format (default on is RGB565)
+ - setting the OpenGL buffer depth (default on is 0-bit)
+ - setting the color for clear screen (default one is BLACK)
+ - setting the projection (default one is 3D)
+ - setting the orientation (default one is Portrait)
+
+
+ The cc.director also sets the default OpenGL context:
+ - GL_TEXTURE_2D is enabled
+ - GL_VERTEX_ARRAY is enabled
+ - GL_COLOR_ARRAY is enabled
+ - GL_TEXTURE_COORD_ARRAY is enabled
+

+

+ cc.director also synchronizes timers with the refresh rate of the display.
+ Features and Limitations:
+ - Scheduled timers & drawing are synchronizes with the refresh rate of the display
+ - Only supports animation intervals of 1/60 1/30 & 1/15
+

+ + !#zh +

+ 注意:用 cc.director 代替 cc.Director。
+ cc.director 一个管理你的游戏的逻辑流程的单例对象。
+ 由于 cc.director 是一个单例,你不需要调用任何构造函数或创建函数,
+ 使用它的标准方法是通过调用:
+ - cc.director.methodName(); +
+ 它创建和处理主窗口并且管理什么时候执行场景。
+
+ cc.director 还负责:
+ - 初始化 OpenGL 环境。
+ - 设置OpenGL像素格式。(默认是 RGB565)
+ - 设置OpenGL缓冲区深度 (默认是 0-bit)
+ - 设置空白场景的颜色 (默认是 黑色)
+ - 设置投影 (默认是 3D)
+ - 设置方向 (默认是 Portrait)
+
+ cc.director 设置了 OpenGL 默认环境
+ - GL_TEXTURE_2D 启用。
+ - GL_VERTEX_ARRAY 启用。
+ - GL_COLOR_ARRAY 启用。
+ - GL_TEXTURE_COORD_ARRAY 启用。
+

+

+ cc.director 也同步定时器与显示器的刷新速率。 +
+ 特点和局限性:
+ - 将计时器 & 渲染与显示器的刷新频率同步。
+ - 只支持动画的间隔 1/60 1/30 & 1/15。
+

*/ + export class Director extends EventTarget { + /** + !#en + Converts a view coordinate to an WebGL coordinate
+ Useful to convert (multi) touches coordinates to the current layout (portrait or landscape)
+ Implementation can be found in CCDirectorWebGL. + !#zh 将触摸点的屏幕坐标转换为 WebGL View 下的坐标。 + @param uiPoint uiPoint + */ + convertToGL(uiPoint: Vec2): Vec2; + /** + !#en + Converts an OpenGL coordinate to a view coordinate
+ Useful to convert node points to window points for calls such as glScissor
+ Implementation can be found in CCDirectorWebGL. + !#zh 将触摸点的 WebGL View 坐标转换为屏幕坐标。 + @param glPoint glPoint + */ + convertToUI(glPoint: Vec2): Vec2; + /** + End the life of director in the next frame + */ + end(): void; + /** + !#en + Returns the size of the WebGL view in points.
+ It takes into account any possible rotation (device orientation) of the window. + !#zh 获取视图的大小,以点为单位。 + */ + getWinSize(): Size; + /** + !#en + Returns the size of the OpenGL view in pixels.
+ It takes into account any possible rotation (device orientation) of the window.
+ On Mac winSize and winSizeInPixels return the same value. + (The pixel here refers to the resource resolution. If you want to get the physics resolution of device, you need to use cc.view.getFrameSize()) + !#zh + 获取视图大小,以像素为单位(这里的像素指的是资源分辨率。 + 如果要获取屏幕物理分辨率,需要用 cc.view.getFrameSize()) + */ + getWinSizeInPixels(): Size; + /** + !#en Pause the director's ticker, only involve the game logic execution. + It won't pause the rendering process nor the event manager. + If you want to pause the entier game including rendering, audio and event, + please use {{#crossLink "Game.pause"}}cc.game.pause{{/crossLink}} + !#zh 暂停正在运行的场景,该暂停只会停止游戏逻辑执行,但是不会停止渲染和 UI 响应。 + 如果想要更彻底得暂停游戏,包含渲染,音频和事件,请使用 {{#crossLink "Game.pause"}}cc.game.pause{{/crossLink}}。 + */ + pause(): void; + /** + !#en + Run a scene. Replaces the running scene with a new one or enter the first scene.
+ The new scene will be launched immediately. + !#zh 立刻切换指定场景。 + @param scene The need run scene. + @param onBeforeLoadScene The function invoked at the scene before loading. + @param onLaunched The function invoked at the scene after launch. + */ + runSceneImmediate(scene: Scene|SceneAsset, onBeforeLoadScene?: Function, onLaunched?: Function): void; + /** + !#en + Run a scene. Replaces the running scene with a new one or enter the first scene. + The new scene will be launched at the end of the current frame. + !#zh 运行指定场景。 + @param scene The need run scene. + @param onBeforeLoadScene The function invoked at the scene before loading. + @param onLaunched The function invoked at the scene after launch. + */ + runScene(scene: Scene|SceneAsset, onBeforeLoadScene?: Function, onLaunched?: Function): void; + /** + !#en Loads the scene by its name. + !#zh 通过场景名称进行加载场景。 + @param sceneName The name of the scene to load. + @param onLaunched callback, will be called after scene launched. + */ + loadScene(sceneName: string, onLaunched?: Function): boolean; + /** + !#en + Preloads the scene to reduces loading time. You can call this method at any time you want. + After calling this method, you still need to launch the scene by `cc.director.loadScene`. + It will be totally fine to call `cc.director.loadScene` at any time even if the preloading is not + yet finished, the scene will be launched after loaded automatically. + !#zh 预加载场景,你可以在任何时候调用这个方法。 + 调用完后,你仍然需要通过 `cc.director.loadScene` 来启动场景,因为这个方法不会执行场景加载操作。 + 就算预加载还没完成,你也可以直接调用 `cc.director.loadScene`,加载完成后场景就会启动。 + @param sceneName The name of the scene to preload. + @param onProgress callback, will be called when the load progression change. + @param onLoaded callback, will be called after scene loaded. + */ + preloadScene(sceneName: string, onProgress?: (completedCount: number, totalCount: number, item: any) => void, onLoaded?: (error: Error) => void): void; + /** + !#en Resume game logic execution after pause, if the current scene is not paused, nothing will happen. + !#zh 恢复暂停场景的游戏逻辑,如果当前场景没有暂停将没任何事情发生。 + */ + resume(): void; + /** + !#en + Enables or disables WebGL depth test.
+ Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js + !#zh 启用/禁用深度测试(在 Canvas 渲染模式下不会生效)。 + @param on on + */ + setDepthTest(on: boolean): void; + /** + !#en + Set color for clear screen.
+ (Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js) + !#zh + 设置场景的默认擦除颜色。
+ 支持全透明,但不支持透明度为中间值。要支持全透明需手工开启 cc.macro.ENABLE_TRANSPARENT_CANVAS。 + @param clearColor clearColor + */ + setClearColor(clearColor: Color): void; + /** + !#en Returns current logic Scene. + !#zh 获取当前逻辑场景。 + + @example + ```js + // This will help you to get the Canvas node in scene + cc.director.getScene().getChildByName('Canvas'); + ``` + */ + getScene(): Scene; + /** + !#en Returns the FPS value. Please use {{#crossLink "Game.setFrameRate"}}cc.game.setFrameRate{{/crossLink}} to control animation interval. + !#zh 获取单位帧执行时间。请使用 {{#crossLink "Game.setFrameRate"}}cc.game.setFrameRate{{/crossLink}} 来控制游戏帧率。 + */ + getAnimationInterval(): number; + /** + Sets animation interval, this doesn't control the main loop. + To control the game's frame rate overall, please use {{#crossLink "Game.setFrameRate"}}cc.game.setFrameRate{{/crossLink}} + @param value The animation interval desired. + */ + setAnimationInterval(value: number): void; + /** + !#en Returns the delta time since last frame. + !#zh 获取上一帧的增量时间。 + */ + getDeltaTime(): number; + /** + !#en Returns the total passed time since game start, unit: ms + !#zh 获取从游戏开始到现在总共经过的时间,单位为 ms + */ + getTotalTime(): number; + /** + !#en Returns how many frames were called since the director started. + !#zh 获取 director 启动以来游戏运行的总帧数。 + */ + getTotalFrames(): number; + /** + !#en Returns whether or not the Director is paused. + !#zh 是否处于暂停状态。 + */ + isPaused(): boolean; + /** + !#en Returns the cc.Scheduler associated with this director. + !#zh 获取和 director 相关联的 cc.Scheduler。 + */ + getScheduler(): Scheduler; + /** + !#en Sets the cc.Scheduler associated with this director. + !#zh 设置和 director 相关联的 cc.Scheduler。 + @param scheduler scheduler + */ + setScheduler(scheduler: Scheduler): void; + /** + !#en Returns the cc.ActionManager associated with this director. + !#zh 获取和 director 相关联的 cc.ActionManager(动作管理器)。 + */ + getActionManager(): ActionManager; + /** + !#en Sets the cc.ActionManager associated with this director. + !#zh 设置和 director 相关联的 cc.ActionManager(动作管理器)。 + @param actionManager actionManager + */ + setActionManager(actionManager: ActionManager): void; + /** + !#en Returns the cc.CollisionManager associated with this director. + !#zh 获取和 director 相关联的 cc.CollisionManager (碰撞管理器)。 + */ + getCollisionManager(): CollisionManager; + /** + !#en Returns the cc.PhysicsManager associated with this director. + !#zh 返回与 director 相关联的 cc.PhysicsManager (物理管理器)。 + */ + getPhysicsManager(): PhysicsManager; + /** + !#en Returns the cc.Physics3DManager associated with this director. + !#zh 返回与 director 相关联的 cc.Physics3DManager (物理管理器)。 + */ + getPhysics3DManager(): Physics3DManager; + /** !#en The event projection changed of cc.Director. This event will not get triggered since v2.0 + !#zh cc.Director 投影变化的事件。从 v2.0 开始这个事件不会再被触发 */ + static EVENT_PROJECTION_CHANGED: string; + /** !#en The event which will be triggered before loading a new scene. + !#zh 加载新场景之前所触发的事件。 */ + static EVENT_BEFORE_SCENE_LOADING: string; + /** !#en The event which will be triggered before launching a new scene. + !#zh 运行新场景之前所触发的事件。 */ + static EVENT_BEFORE_SCENE_LAUNCH: string; + /** !#en The event which will be triggered after launching a new scene. + !#zh 运行新场景之后所触发的事件。 */ + static EVENT_AFTER_SCENE_LAUNCH: string; + /** !#en The event which will be triggered at the beginning of every frame. + !#zh 每个帧的开始时所触发的事件。 */ + static EVENT_BEFORE_UPDATE: string; + /** !#en The event which will be triggered after engine and components update logic. + !#zh 将在引擎和组件 “update” 逻辑之后所触发的事件。 */ + static EVENT_AFTER_UPDATE: string; + /** !#en The event is deprecated since v2.0, please use cc.Director.EVENT_BEFORE_DRAW instead + !#zh 这个事件从 v2.0 开始被废弃,请直接使用 cc.Director.EVENT_BEFORE_DRAW */ + static EVENT_BEFORE_VISIT: string; + /** !#en The event is deprecated since v2.0, please use cc.Director.EVENT_BEFORE_DRAW instead + !#zh 这个事件从 v2.0 开始被废弃,请直接使用 cc.Director.EVENT_BEFORE_DRAW */ + static EVENT_AFTER_VISIT: string; + /** !#en The event which will be triggered before the rendering process. + !#zh 渲染过程之前所触发的事件。 */ + static EVENT_BEFORE_DRAW: string; + /** !#en The event which will be triggered after the rendering process. + !#zh 渲染过程之后所触发的事件。 */ + static EVENT_AFTER_DRAW: string; + /** Constant for 2D projection (orthogonal projection) */ + static PROJECTION_2D: number; + /** Constant for 3D projection with a fovy=60, znear=0.5f and zfar=1500. */ + static PROJECTION_3D: number; + /** Constant for custom projection, if cc.Director's projection set to it, it calls "updateProjection" on the projection delegate. */ + static PROJECTION_CUSTOM: number; + /** Constant for default projection of cc.Director, default projection is 2D projection */ + static PROJECTION_DEFAULT: number; + } + /** !#en + cc.Scene is a subclass of cc.Node that is used only as an abstract concept.
+ cc.Scene and cc.Node are almost identical with the difference that users can not modify cc.Scene manually. + !#zh + cc.Scene 是 cc.Node 的子类,仅作为一个抽象的概念。
+ cc.Scene 和 cc.Node 有点不同,用户不应直接修改 cc.Scene。 */ + export class Scene extends Node { + /** !#en Indicates whether all (directly or indirectly) static referenced assets of this scene are releasable by default after scene unloading. + !#zh 指示该场景中直接或间接静态引用到的所有资源是否默认在场景切换后自动释放。 */ + autoReleaseAssets: boolean; + } + /** !#en + Class of private entities in Cocos Creator scenes.
+ The PrivateNode is hidden in editor, and completely transparent to users.
+ It's normally used as Node's private content created by components in parent node.
+ So in theory private nodes are not children, they are part of the parent node.
+ Private node have two important characteristics:
+ 1. It has the minimum z index and cannot be modified, because they can't be displayed over real children.
+ 2. The positioning of private nodes is also special, they will consider the left bottom corner of the parent node's bounding box as the origin of local coordinates.
+ In this way, they can be easily kept inside the bounding box.
+ Currently, it's used by RichText component and TileMap component. + !#zh + Cocos Creator 场景中的私有节点类。
+ 私有节点在编辑器中不可见,对用户透明。
+ 通常私有节点是被一些特殊的组件创建出来作为父节点的一部分而存在的,理论上来说,它们不是子节点,而是父节点的组成部分。
+ 私有节点有两个非常重要的特性:
+ 1. 它有着最小的渲染排序的 Z 轴深度,并且无法被更改,因为它们不能被显示在其他正常子节点之上。
+ 2. 它的定位也是特殊的,对于私有节点来说,父节点包围盒的左下角是它的局部坐标系原点,这个原点相当于父节点的位置减去它锚点的偏移。这样私有节点可以比较容易被控制在包围盒之中。
+ 目前在引擎中,RichText 和 TileMap 都有可能生成私有节点。 */ + export class PrivateNode extends Node { + /** + + @param name name + */ + constructor(name?: string); + } + /** !#en + Scheduler is responsible of triggering the scheduled callbacks.
+ You should not use NSTimer. Instead use this class.
+
+ There are 2 different types of callbacks (selectors):
+ - update callback: the 'update' callback will be called every frame. You can customize the priority.
+ - custom callback: A custom callback will be called every frame, or with a custom interval of time
+
+ The 'custom selectors' should be avoided when possible. It is faster, + and consumes less memory to use the 'update callback'. * + !#zh + Scheduler 是负责触发回调函数的类。
+ 通常情况下,建议使用 cc.director.getScheduler() 来获取系统定时器。
+ 有两种不同类型的定时器:
+ - update 定时器:每一帧都会触发。您可以自定义优先级。
+ - 自定义定时器:自定义定时器可以每一帧或者自定义的时间间隔触发。
+ 如果希望每帧都触发,应该使用 update 定时器,使用 update 定时器更快,而且消耗更少的内存。 */ + export class Scheduler { + /** + !#en This method should be called for any target which needs to schedule tasks, and this method should be called before any scheduler API usage. + This method will add a `_id` property if it doesn't exist. + !#zh 任何需要用 Scheduler 管理任务的对象主体都应该调用这个方法,并且应该在调用任何 Scheduler API 之前调用这个方法。 + 这个方法会给对象添加一个 `_id` 属性,如果这个属性不存在的话。 + @param target target + */ + enableForTarget(target: any): void; + /** + !#en + Modifies the time of all scheduled callbacks.
+ You can use this property to create a 'slow motion' or 'fast forward' effect.
+ Default is 1.0. To create a 'slow motion' effect, use values below 1.0.
+ To create a 'fast forward' effect, use values higher than 1.0.
+ Note:It will affect EVERY scheduled selector / action. + !#zh + 设置时间间隔的缩放比例。
+ 您可以使用这个方法来创建一个 “slow motion(慢动作)” 或 “fast forward(快进)” 的效果。
+ 默认是 1.0。要创建一个 “slow motion(慢动作)” 效果,使用值低于 1.0。
+ 要使用 “fast forward(快进)” 效果,使用值大于 1.0。
+ 注意:它影响该 Scheduler 下管理的所有定时器。 + @param timeScale timeScale + */ + setTimeScale(timeScale: number): void; + /** + !#en Returns time scale of scheduler. + !#zh 获取时间间隔的缩放比例。 + */ + getTimeScale(): number; + /** + !#en 'update' the scheduler. (You should NEVER call this method, unless you know what you are doing.) + !#zh update 调度函数。(不应该直接调用这个方法,除非完全了解这么做的结果) + @param dt delta time + */ + update(dt: number): void; + /** + !#en +

+ The scheduled method will be called every 'interval' seconds.
+ If paused is YES, then it won't be called until it is resumed.
+ If 'interval' is 0, it will be called every frame, but if so, it recommended to use 'scheduleUpdateForTarget:' instead.
+ If the callback function is already scheduled, then only the interval parameter will be updated without re-scheduling it again.
+ repeat let the action be repeated repeat + 1 times, use cc.macro.REPEAT_FOREVER to let the action run continuously
+ delay is the amount of time the action will wait before it'll start
+

+ !#zh + 指定回调函数,调用对象等信息来添加一个新的定时器。
+ 如果 paused 值为 true,那么直到 resume 被调用才开始计时。
+ 当时间间隔达到指定值时,设置的回调函数将会被调用。
+ 如果 interval 值为 0,那么回调函数每一帧都会被调用,但如果是这样, + 建议使用 scheduleUpdateForTarget 代替。
+ 如果回调函数已经被定时器使用,那么只会更新之前定时器的时间间隔参数,不会设置新的定时器。
+ repeat 值可以让定时器触发 repeat + 1 次,使用 cc.macro.REPEAT_FOREVER + 可以让定时器一直循环触发。
+ delay 值指定延迟时间,定时器会在延迟指定的时间之后开始计时。 + @param callback callback + @param target target + @param interval interval + @param repeat repeat + @param delay delay + @param paused paused + + @example + ```js + //register a schedule to scheduler + cc.director.getScheduler().schedule(callback, this, interval, !this._isRunning); + + ``` + */ + schedule(callback: Function, target: any, interval: number, repeat: number, delay: number, paused?: boolean): void; + schedule(callback: Function, target: any, interval: number, paused?: boolean): void; + /** + !#en + Schedules the update callback for a given target, + During every frame after schedule started, the "update" function of target will be invoked. + !#zh + 使用指定的优先级为指定的对象设置 update 定时器。 + update 定时器每一帧都会被触发,触发时自动调用指定对象的 "update" 函数。 + 优先级的值越低,定时器被触发的越早。 + @param target target + @param priority priority + @param paused paused + */ + scheduleUpdate(target: any, priority: number, paused: boolean): void; + /** + !#en + Unschedules a callback for a callback and a given target. + If you want to unschedule the "update", use `unscheduleUpdate()` + !#zh + 取消指定对象定时器。 + 如果需要取消 update 定时器,请使用 unscheduleUpdate()。 + @param callback The callback to be unscheduled + @param target The target bound to the callback. + */ + unschedule(callback: Function, target: any): void; + /** + !#en Unschedules the update callback for a given target. + !#zh 取消指定对象的 update 定时器。 + @param target The target to be unscheduled. + */ + unscheduleUpdate(target: any): void; + /** + !#en + Unschedules all scheduled callbacks for a given target. + This also includes the "update" callback. + !#zh 取消指定对象的所有定时器,包括 update 定时器。 + @param target The target to be unscheduled. + */ + unscheduleAllForTarget(target: any): void; + /** + !#en + Unschedules all scheduled callbacks from all targets including the system callbacks.
+ You should NEVER call this method, unless you know what you are doing. + !#zh + 取消所有对象的所有定时器,包括系统定时器。
+ 不要调用此函数,除非你确定你在做什么。 + */ + unscheduleAll(): void; + /** + !#en + Unschedules all callbacks from all targets with a minimum priority.
+ You should only call this with `PRIORITY_NON_SYSTEM_MIN` or higher. + !#zh + 取消所有优先级的值大于指定优先级的定时器。
+ 你应该只取消优先级的值大于 PRIORITY_NON_SYSTEM_MIN 的定时器。 + @param minPriority The minimum priority of selector to be unscheduled. Which means, all selectors which + priority is higher than minPriority will be unscheduled. + */ + unscheduleAllWithMinPriority(minPriority: number): void; + /** + !#en Checks whether a callback for a given target is scheduled. + !#zh 检查指定的回调函数和回调对象组合是否存在定时器。 + @param callback The callback to check. + @param target The target of the callback. + */ + isScheduled(callback: Function, target: any): boolean; + /** + !#en + Pause all selectors from all targets.
+ You should NEVER call this method, unless you know what you are doing. + !#zh + 暂停所有对象的所有定时器。
+ 不要调用这个方法,除非你知道你正在做什么。 + */ + pauseAllTargets(): void; + /** + !#en + Pause all selectors from all targets with a minimum priority.
+ You should only call this with kCCPriorityNonSystemMin or higher. + !#zh + 暂停所有优先级的值大于指定优先级的定时器。
+ 你应该只暂停优先级的值大于 PRIORITY_NON_SYSTEM_MIN 的定时器。 + @param minPriority minPriority + */ + pauseAllTargetsWithMinPriority(minPriority: number): void; + /** + !#en + Resume selectors on a set of targets.
+ This can be useful for undoing a call to pauseAllCallbacks. + !#zh + 恢复指定数组中所有对象的定时器。
+ 这个函数是 pauseAllCallbacks 的逆操作。 + @param targetsToResume targetsToResume + */ + resumeTargets(targetsToResume: any[]): void; + /** + !#en + Pauses the target.
+ All scheduled selectors/update for a given target won't be 'ticked' until the target is resumed.
+ If the target is not present, nothing happens. + !#zh + 暂停指定对象的定时器。
+ 指定对象的所有定时器都会被暂停。
+ 如果指定的对象没有定时器,什么也不会发生。 + @param target target + */ + pauseTarget(target: any): void; + /** + !#en + Resumes the target.
+ The 'target' will be unpaused, so all schedule selectors/update will be 'ticked' again.
+ If the target is not present, nothing happens. + !#zh + 恢复指定对象的所有定时器。
+ 指定对象的所有定时器将继续工作。
+ 如果指定的对象没有定时器,什么也不会发生。 + @param target target + */ + resumeTarget(target: any): void; + /** + !#en Returns whether or not the target is paused. + !#zh 返回指定对象的定时器是否暂停了。 + @param target target + */ + isTargetPaused(target: any): boolean; + /** !#en Priority level reserved for system services. + !#zh 系统服务的优先级。 */ + static PRIORITY_SYSTEM: number; + /** !#en Minimum priority level for user scheduling. + !#zh 用户调度最低优先级。 */ + static PRIORITY_NON_SYSTEM: number; + } + /** !#en Class for animation data handling. + !#zh 动画剪辑,用于存储动画数据。 */ + export class AnimationClip extends Asset { + /** !#en Duration of this animation. + !#zh 动画的持续时间。 */ + duration: number; + /** !#en FrameRate of this animation. + !#zh 动画的帧速率。 */ + sample: number; + /** !#en Speed of this animation. + !#zh 动画的播放速度。 */ + speed: number; + /** !#en WrapMode of this animation. + !#zh 动画的循环模式。 */ + wrapMode: WrapMode; + /** !#en Curve data. + !#zh 曲线数据。 */ + curveData: any; + /** !#en Event data. + !#zh 事件数据。 */ + events: {frame: number, func: string, params: string[]}[]; + /** + !#en Crate clip with a set of sprite frames + !#zh 使用一组序列帧图片来创建动画剪辑 + @param spriteFrames spriteFrames + @param sample sample + + @example + ```js + var clip = cc.AnimationClip.createWithSpriteFrames(spriteFrames, 10); + ``` + */ + static createWithSpriteFrames(spriteFrames: SpriteFrame[], sample: number): AnimationClip; + } + /** !#en + The AnimationState gives full control over animation playback process. + In most cases the Animation Component is sufficient and easier to use. Use the AnimationState if you need full control. + !#zh + AnimationState 完全控制动画播放过程。
+ 大多数情况下 动画组件 是足够和易于使用的。如果您需要更多的动画控制接口,请使用 AnimationState。 */ + export class AnimationState extends Playable { + /** + + @param clip clip + @param name name + */ + constructor(clip: AnimationClip, name?: string); + /** !#en The curves list. + !#zh 曲线列表。 */ + curves: any[]; + /** !#en The start delay which represents the number of seconds from an animation's start time to the start of + the active interval. + !#zh 延迟多少秒播放。 */ + delay: number; + /** !#en The animation's iteration count property. + + A real number greater than or equal to zero (including positive infinity) representing the number of times + to repeat the animation node. + + Values less than zero and NaN values are treated as the value 1.0 for the purpose of timing model + calculations. + + !#zh 迭代次数,指动画播放多少次后结束, normalize time。 如 2.5(2次半) */ + repeatCount: number; + /** !#en The iteration duration of this animation in seconds. (length) + !#zh 单次动画的持续时间,秒。 */ + duration: number; + /** !#en The animation's playback speed. 1 is normal playback speed. + !#zh 播放速率。 */ + speed: number; + /** !#en + Wrapping mode of the playing animation. + Notice : dynamic change wrapMode will reset time and repeatCount property + !#zh + 动画循环方式。 + 需要注意的是,动态修改 wrapMode 时,会重置 time 以及 repeatCount */ + wrapMode: WrapMode; + /** !#en The current time of this animation in seconds. + !#zh 动画当前的时间,秒。 */ + time: number; + /** !#en The clip that is being played by this animation state. + !#zh 此动画状态正在播放的剪辑。 */ + clip: AnimationClip; + /** !#en The name of the playing animation. + !#zh 动画的名字 */ + name: string; + } + /** !#en + This class provide easing methods for {{#crossLink "tween"}}{{/crossLink}} class.
+ Demonstratio: https://easings.net/ + !#zh + 缓动函数类,为 {{#crossLink "Tween"}}{{/crossLink}} 提供缓动效果函数。
+ 函数效果演示: https://easings.net/ */ + export class Easing { + /** + !#en Easing in with quadratic formula. From slow to fast. + !#zh 平方曲线缓入函数。运动由慢到快。 + @param t The current time as a percentage of the total time. + */ + quadIn(t: number): number; + /** + !#en Easing out with quadratic formula. From fast to slow. + !#zh 平方曲线缓出函数。运动由快到慢。 + @param t The current time as a percentage of the total time. + */ + quadOut(t: number): number; + /** + !#en Easing in and out with quadratic formula. From slow to fast, then back to slow. + !#zh 平方曲线缓入缓出函数。运动由慢到快再到慢。 + @param t The current time as a percentage of the total time. + */ + quadInOut(t: number): number; + /** + !#en Easing in with cubic formula. From slow to fast. + !#zh 立方曲线缓入函数。运动由慢到快。 + @param t The current time as a percentage of the total time. + */ + cubicIn(t: number): number; + /** + !#en Easing out with cubic formula. From slow to fast. + !#zh 立方曲线缓出函数。运动由快到慢。 + @param t The current time as a percentage of the total time. + */ + cubicOut(t: number): number; + /** + !#en Easing in and out with cubic formula. From slow to fast, then back to slow. + !#zh 立方曲线缓入缓出函数。运动由慢到快再到慢。 + @param t The current time as a percentage of the total time. + */ + cubicInOut(t: number): number; + /** + !#en Easing in with quartic formula. From slow to fast. + !#zh 四次方曲线缓入函数。运动由慢到快。 + @param t The current time as a percentage of the total time. + */ + quartIn(t: number): number; + /** + !#en Easing out with quartic formula. From fast to slow. + !#zh 四次方曲线缓出函数。运动由快到慢。 + @param t The current time as a percentage of the total time. + */ + quartOut(t: number): number; + /** + !#en Easing in and out with quartic formula. From slow to fast, then back to slow. + !#zh 四次方曲线缓入缓出函数。运动由慢到快再到慢。 + @param t The current time as a percentage of the total time. + */ + quartInOut(t: number): number; + /** + !#en Easing in with quintic formula. From slow to fast. + !#zh 五次方曲线缓入函数。运动由慢到快。 + @param t The current time as a percentage of the total time. + */ + quintIn(t: number): number; + /** + !#en Easing out with quintic formula. From fast to slow. + !#zh 五次方曲线缓出函数。运动由快到慢。 + @param t The current time as a percentage of the total time. + */ + quintOut(t: number): number; + /** + !#en Easing in and out with quintic formula. From slow to fast, then back to slow. + !#zh 五次方曲线缓入缓出函数。运动由慢到快再到慢。 + @param t The current time as a percentage of the total time. + */ + quintInOut(t: number): number; + /** + !#en Easing in and out with sine formula. From slow to fast. + !#zh 正弦曲线缓入函数。运动由慢到快。 + @param t The current time as a percentage of the total time. + */ + sineIn(t: number): number; + /** + !#en Easing in and out with sine formula. From fast to slow. + !#zh 正弦曲线缓出函数。运动由快到慢。 + @param t The current time as a percentage of the total time. + */ + sineOut(t: number): number; + /** + !#en Easing in and out with sine formula. From slow to fast, then back to slow. + !#zh 正弦曲线缓入缓出函数。运动由慢到快再到慢。 + @param t The current time as a percentage of the total time. + */ + sineInOut(t: number): number; + /** + !#en Easing in and out with exponential formula. From slow to fast. + !#zh 指数曲线缓入函数。运动由慢到快。 + @param t The current time as a percentage of the total time. + */ + expoIn(t: number): number; + /** + !#en Easing in and out with exponential formula. From fast to slow. + !#zh 指数曲线缓出函数。运动由快到慢。 + @param t The current time as a percentage of the total time. + */ + expoOut(t: number): number; + /** + !#en Easing in and out with exponential formula. From slow to fast. + !#zh 指数曲线缓入和缓出函数。运动由慢到很快再到慢。 + @param t The current time as a percentage of the total time, then back to slow. + */ + expoInOut(t: number): number; + /** + !#en Easing in and out with circular formula. From slow to fast. + !#zh 循环公式缓入函数。运动由慢到快。 + @param t The current time as a percentage of the total time. + */ + circIn(t: number): number; + /** + !#en Easing in and out with circular formula. From fast to slow. + !#zh 循环公式缓出函数。运动由快到慢。 + @param t The current time as a percentage of the total time. + */ + circOut(t: number): number; + /** + !#en Easing in and out with circular formula. From slow to fast. + !#zh 指数曲线缓入缓出函数。运动由慢到很快再到慢。 + @param t The current time as a percentage of the total time, then back to slow. + */ + circInOut(t: number): number; + /** + !#en Easing in action with a spring oscillating effect. + !#zh 弹簧回震效果的缓入函数。 + @param t The current time as a percentage of the total time. + */ + elasticIn(t: number): number; + /** + !#en Easing out action with a spring oscillating effect. + !#zh 弹簧回震效果的缓出函数。 + @param t The current time as a percentage of the total time. + */ + elasticOut(t: number): number; + /** + !#en Easing in and out action with a spring oscillating effect. + !#zh 弹簧回震效果的缓入缓出函数。 + @param t The current time as a percentage of the total time. + */ + elasticInOut(t: number): number; + /** + !#en Easing in action with "back up" behavior. + !#zh 回退效果的缓入函数。 + @param t The current time as a percentage of the total time. + */ + backIn(t: number): number; + /** + !#en Easing out action with "back up" behavior. + !#zh 回退效果的缓出函数。 + @param t The current time as a percentage of the total time. + */ + backOut(t: number): number; + /** + !#en Easing in and out action with "back up" behavior. + !#zh 回退效果的缓入缓出函数。 + @param t The current time as a percentage of the total time. + */ + backInOut(t: number): number; + /** + !#en Easing in action with bouncing effect. + !#zh 弹跳效果的缓入函数。 + @param t The current time as a percentage of the total time. + */ + bounceIn(t: number): number; + /** + !#en Easing out action with bouncing effect. + !#zh 弹跳效果的缓出函数。 + @param t The current time as a percentage of the total time. + */ + bounceOut(t: number): number; + /** + !#en Easing in and out action with bouncing effect. + !#zh 弹跳效果的缓入缓出函数。 + @param t The current time as a percentage of the total time. + */ + bounceInOut(t: number): number; + /** + !#en Target will run action with smooth effect. + !#zh 平滑效果函数。 + @param t The current time as a percentage of the total time. + */ + smooth(t: number): number; + /** + !#en Target will run action with fade effect. + !#zh 渐褪效果函数。 + @param t The current time as a percentage of the total time. + */ + fade(t: number): number; + } + /** undefined */ + export class Playable { + /** !#en Is playing or paused in play mode? + !#zh 当前是否正在播放。 */ + isPlaying: boolean; + /** !#en Is currently paused? This can be true even if in edit mode(isPlaying == false). + !#zh 当前是否正在暂停 */ + isPaused: boolean; + /** + !#en Play this animation. + !#zh 播放动画。 + */ + play(): void; + /** + !#en Stop this animation. + !#zh 停止动画播放。 + */ + stop(): void; + /** + !#en Pause this animation. + !#zh 暂停动画。 + */ + pause(): void; + /** + !#en Resume this animation. + !#zh 重新播放动画。 + */ + resume(): void; + /** + !#en Perform a single frame step. + !#zh 执行一帧动画。 + */ + step(): void; + } + /** !#en Specifies how time is treated when it is outside of the keyframe range of an Animation. + !#zh 动画使用的循环模式。 */ + export enum WrapMode { + Default = 0, + Normal = 0, + Reverse = 0, + Loop = 0, + LoopReverse = 0, + PingPong = 0, + PingPongReverse = 0, + } + /** !#en Render the TMX layer. + !#zh 渲染 TMX layer。 */ + export class TiledLayer extends Component { + /** + !#en enable or disable culling + !#zh 开启或关闭裁剪。 + @param value value + */ + enableCulling(value: any): void; + /** + !#en Adds user's node into layer. + !#zh 添加用户节点。 + @param node node + */ + addUserNode(node: Node): boolean; + /** + !#en Removes user's node. + !#zh 移除用户节点。 + @param node node + */ + removeUserNode(node: Node): boolean; + /** + !#en Destroy user's node. + !#zh 销毁用户节点。 + @param node node + */ + destroyUserNode(node: Node): void; + /** + !#en Gets the layer name. + !#zh 获取层的名称。 + + @example + ```js + let layerName = tiledLayer.getLayerName(); + cc.log(layerName); + ``` + */ + getLayerName(): string; + /** + !#en Set the layer name. + !#zh 设置层的名称 + @param layerName layerName + + @example + ```js + tiledLayer.setLayerName("New Layer"); + ``` + */ + SetLayerName(layerName: string): void; + /** + !#en Return the value for the specific property name. + !#zh 获取指定属性名的值。 + @param propertyName propertyName + + @example + ```js + let property = tiledLayer.getProperty("info"); + cc.log(property); + ``` + */ + getProperty(propertyName: string): any; + /** + !#en Returns the position in pixels of a given tile coordinate. + !#zh 获取指定 tile 的像素坐标。 + @param pos position or x + @param y y + + @example + ```js + let pos = tiledLayer.getPositionAt(cc.v2(0, 0)); + cc.log("Pos: " + pos); + let pos = tiledLayer.getPositionAt(0, 0); + cc.log("Pos: " + pos); + ``` + */ + getPositionAt(pos: Vec2|number, y?: number): Vec2; + /** + !#en + Sets the tiles gid (gid = tile global id) at a given tiles rect. + !#zh + 设置给定区域的 tile 的 gid (gid = tile 全局 id), + @param gids an array contains gid + @param beginCol begin col number + @param beginRow begin row number + @param totalCols count of column + + @example + ```js + tiledLayer.setTilesGIDAt([1, 1, 1, 1], 10, 10, 2) + ``` + */ + setTilesGIDAt(gids: any[], beginCol: number, beginRow: number, totalCols: number): void; + /** + !#en + Sets the tile gid (gid = tile global id) at a given tile coordinate.
+ The Tile GID can be obtained by using the method "tileGIDAt" or by using the TMX editor . Tileset Mgr +1.
+ If a tile is already placed at that position, then it will be removed. + !#zh + 设置给定坐标的 tile 的 gid (gid = tile 全局 id), + tile 的 GID 可以使用方法 “tileGIDAt” 来获得。
+ 如果一个 tile 已经放在那个位置,那么它将被删除。 + @param gid gid + @param posOrX position or x + @param flagsOrY flags or y + @param flags flags + + @example + ```js + tiledLayer.setTileGIDAt(1001, 10, 10, 1) + ``` + */ + setTileGIDAt(gid: number, posOrX: Vec2|number, flagsOrY: number, flags?: number): void; + /** + !#en + Returns the tile gid at a given tile coordinate.
+ if it returns 0, it means that the tile is empty.
+ !#zh + 通过给定的 tile 坐标、flags(可选)返回 tile 的 GID.
+ 如果它返回 0,则表示该 tile 为空。
+ @param pos or x + @param y y + + @example + ```js + let tileGid = tiledLayer.getTileGIDAt(0, 0); + ``` + */ + getTileGIDAt(pos: Vec2|number, y?: number): number; + /** + !#en Layer orientation, which is the same as the map orientation. + !#zh 获取 Layer 方向(同地图方向)。 + + @example + ```js + let orientation = tiledLayer.getLayerOrientation(); + cc.log("Layer Orientation: " + orientation); + ``` + */ + getLayerOrientation(): number; + /** + !#en properties from the layer. They can be added using Tiled. + !#zh 获取 layer 的属性,可以使用 Tiled 编辑器添加属性。 + + @example + ```js + let properties = tiledLayer.getProperties(); + cc.log("Properties: " + properties); + ``` + */ + getProperties(): any; + /** + !#en + Get the TiledTile with the tile coordinate.
+ If there is no tile in the specified coordinate and forceCreate parameter is true,
+ then will create a new TiledTile at the coordinate. + The renderer will render the tile with the rotation, scale, position and color property of the TiledTile. + !#zh + 通过指定的 tile 坐标获取对应的 TiledTile。
+ 如果指定的坐标没有 tile,并且设置了 forceCreate 那么将会在指定的坐标创建一个新的 TiledTile 。
+ 在渲染这个 tile 的时候,将会使用 TiledTile 的节点的旋转、缩放、位移、颜色属性。
+ @param x x + @param y y + @param forceCreate forceCreate + + @example + ```js + let tile = tiledLayer.getTiledTileAt(100, 100, true); + cc.log(tile); + ``` + */ + getTiledTileAt(x: number, y: number, forceCreate: boolean): TiledTile; + /** + !#en + Change tile to TiledTile at the specified coordinate. + !#zh + 将指定的 tile 坐标替换为指定的 TiledTile。 + @param x x + @param y y + @param tiledTile tiledTile + */ + setTiledTileAt(x: number, y: number, tiledTile: TiledTile): TiledTile; + /** + !#en Return texture. + !#zh 获取纹理。 + @param index The index of textures + */ + getTexture(index: any): Texture2D; + /** + !#en Return texture. + !#zh 获取纹理。 + */ + getTextures(): Texture2D; + /** + !#en Set the texture. + !#zh 设置纹理。 + @param texture texture + */ + setTexture(texture: Texture2D): void; + /** + !#en Set the texture. + !#zh 设置纹理。 + @param textures textures + */ + setTexture(textures: Texture2D): void; + /** + !#en Gets layer size. + !#zh 获得层大小。 + + @example + ```js + let size = tiledLayer.getLayerSize(); + cc.log("layer size: " + size); + ``` + */ + getLayerSize(): Size; + /** + !#en Size of the map's tile (could be different from the tile's size). + !#zh 获取 tile 的大小( tile 的大小可能会有所不同)。 + + @example + ```js + let mapTileSize = tiledLayer.getMapTileSize(); + cc.log("MapTile size: " + mapTileSize); + ``` + */ + getMapTileSize(): Size; + /** + !#en Gets Tile set first information for the layer. + !#zh 获取 layer 索引位置为0的 Tileset 信息。 + @param index The index of tilesets + */ + getTileSet(index: any): TMXTilesetInfo; + /** + !#en Gets tile set all information for the layer. + !#zh 获取 layer 所有的 Tileset 信息。 + */ + getTileSet(): TMXTilesetInfo; + /** + !#en Sets tile set information for the layer. + !#zh 设置 layer 的 tileset 信息。 + @param tileset tileset + */ + setTileSet(tileset: TMXTilesetInfo): void; + /** + !#en Sets Tile set information for the layer. + !#zh 设置 layer 的 Tileset 信息。 + @param tilesets tilesets + */ + setTileSets(tilesets: TMXTilesetInfo): void; + } + /** cc.TMXLayerInfo contains the information about the layers like: + - Layer name + - Layer size + - Layer opacity at creation time (it can be modified at runtime) + - Whether the layer is visible (if it's not visible, then the CocosNode won't be created) + This information is obtained from the TMX file. */ + export class TMXLayerInfo { + /** Properties of the layer info. */ + properties: any; + } + /** cc.TMXImageLayerInfo contains the information about the image layers. + This information is obtained from the TMX file. */ + export class TMXImageLayerInfo { + } + /**

cc.TMXObjectGroupInfo contains the information about the object group like: + - group name + - group size + - group opacity at creation time (it can be modified at runtime) + - Whether the group is visible + + This information is obtained from the TMX file.

*/ + export class TMXObjectGroupInfo { + /** Properties of the ObjectGroup info. */ + properties: any[]; + } + /**

cc.TMXTilesetInfo contains the information about the tilesets like:
+ - Tileset name
+ - Tileset spacing
+ - Tileset margin
+ - size of the tiles
+ - Image used for the tiles
+ - Image size
+ + This information is obtained from the TMX file.

*/ + export class TMXTilesetInfo { + /** Tileset name */ + name: string; + /** First grid */ + firstGid: number; + /** Spacing */ + spacing: number; + /** Margin */ + margin: number; + /** Texture containing the tiles (should be sprite sheet / texture atlas) */ + sourceImage: any; + /** Size in pixels of the image */ + imageSize: Size; + } + /**

cc.TMXMapInfo contains the information about the map like:
+ - Map orientation (hexagonal, isometric or orthogonal)
+ - Tile size
+ - Map size

+ +

And it also contains:
+ - Layers (an array of TMXLayerInfo objects)
+ - Tilesets (an array of TMXTilesetInfo objects)
+ - ObjectGroups (an array of TMXObjectGroupInfo objects)

+ +

This information is obtained from the TMX file.

*/ + export class TMXMapInfo { + /** Properties of the map info. */ + properties: any[]; + /** Map orientation. */ + orientation: number; + /** Parent element. */ + parentElement: any; + /** Parent GID. */ + parentGID: number; + /** Layer attributes. */ + layerAttrs: any; + /** Is reading storing characters stream. */ + storingCharacters: boolean; + /** Current string stored from characters stream. */ + currentString: string; + /** Width of the map */ + mapWidth: number; + /** Height of the map */ + mapHeight: number; + /** Width of a tile */ + tileWidth: number; + /** Height of a tile */ + tileHeight: number; + static ATTRIB_NONE: number; + static ATTRIB_BASE64: number; + static ATTRIB_GZIP: number; + static ATTRIB_ZLIB: number; + } + /** !#en Renders a TMX Tile Map in the scene. + !#zh 在场景中渲染一个 tmx 格式的 Tile Map。 */ + export class TiledMap extends Component { + /** !#en The TiledMap Asset. + !#zh TiledMap 资源。 */ + tmxAsset: TiledMapAsset; + /** + !#en Gets the map size. + !#zh 获取地图大小。 + + @example + ```js + let mapSize = tiledMap.getMapSize(); + cc.log("Map Size: " + mapSize); + ``` + */ + getMapSize(): Size; + /** + !#en Gets the tile size. + !#zh 获取地图背景中 tile 元素的大小。 + + @example + ```js + let tileSize = tiledMap.getTileSize(); + cc.log("Tile Size: " + tileSize); + ``` + */ + getTileSize(): Size; + /** + !#en map orientation. + !#zh 获取地图方向。 + + @example + ```js + let mapOrientation = tiledMap.getMapOrientation(); + cc.log("Map Orientation: " + mapOrientation); + ``` + */ + getMapOrientation(): number; + /** + !#en object groups. + !#zh 获取所有的对象层。 + + @example + ```js + let objGroups = titledMap.getObjectGroups(); + for (let i = 0; i < objGroups.length; ++i) { + cc.log("obj: " + objGroups[i]); + } + ``` + */ + getObjectGroups(): TiledObjectGroup[]; + /** + !#en Return the TMXObjectGroup for the specific group. + !#zh 获取指定的 TMXObjectGroup。 + @param groupName groupName + + @example + ```js + let group = titledMap.getObjectGroup("Players"); + cc.log("ObjectGroup: " + group); + ``` + */ + getObjectGroup(groupName: string): TiledObjectGroup; + /** + !#en enable or disable culling + !#zh 开启或关闭裁剪。 + @param value value + */ + enableCulling(value: any): void; + /** + !#en Gets the map properties. + !#zh 获取地图的属性。 + + @example + ```js + let properties = titledMap.getProperties(); + for (let i = 0; i < properties.length; ++i) { + cc.log("Properties: " + properties[i]); + } + ``` + */ + getProperties(): any[]; + /** + !#en Return All layers array. + !#zh 返回包含所有 layer 的数组。 + + @example + ```js + let layers = titledMap.getLayers(); + for (let i = 0; i < layers.length; ++i) { + cc.log("Layers: " + layers[i]); + } + ``` + */ + getLayers(): TiledLayer[]; + /** + !#en return the cc.TiledLayer for the specific layer. + !#zh 获取指定名称的 layer。 + @param layerName layerName + + @example + ```js + let layer = titledMap.getLayer("Player"); + cc.log(layer); + ``` + */ + getLayer(layerName: string): TiledLayer; + /** + !#en Return the value for the specific property name. + !#zh 通过属性名称,获取指定的属性。 + @param propertyName propertyName + + @example + ```js + let property = titledMap.getProperty("info"); + cc.log("Property: " + property); + ``` + */ + getProperty(propertyName: string): string; + /** + !#en Return properties dictionary for tile GID. + !#zh 通过 GID ,获取指定的属性。 + @param GID GID + + @example + ```js + let properties = titledMap.getPropertiesForGID(GID); + cc.log("Properties: " + properties); + ``` + */ + getPropertiesForGID(GID: number): any; + } + /** !#en Renders the TMX object group. + !#zh 渲染 tmx object group。 */ + export class TiledObjectGroup extends Component { + /** + !#en Offset position of child objects. + !#zh 获取子对象的偏移位置。 + + @example + ```js + let offset = tMXObjectGroup.getPositionOffset(); + ``` + */ + getPositionOffset(): Vec2; + /** + !#en List of properties stored in a dictionary. + !#zh 以映射的形式获取属性列表。 + + @example + ```js + let offset = tMXObjectGroup.getProperties(); + ``` + */ + getProperties(): any; + /** + !#en Gets the Group name. + !#zh 获取组名称。 + + @example + ```js + let groupName = tMXObjectGroup.getGroupName; + ``` + */ + getGroupName(): string; + /** + !#en + Return the object for the specific object name.
+ It will return the 1st object found on the array for the given name. + !#zh 获取指定的对象。 + @param objectName objectName + + @example + ```js + let object = tMXObjectGroup.getObject("Group"); + ``` + */ + getObject(objectName: string): any; + /** + !#en Gets the objects. + !#zh 获取对象数组。 + + @example + ```js + let objects = tMXObjectGroup.getObjects(); + ``` + */ + getObjects(): any[]; + } + /** Class for tiled map asset handling. */ + export class TiledMapAsset extends Asset { + textures: Texture2D[]; + textureNames: string[]; + textureSizes: Size[]; + imageLayerTextures: Texture2D[]; + imageLayerTextureNames: string[]; + } + /** !#en TiledTile can control the specified map tile. + It will apply the node rotation, scale, translate to the map tile. + You can change the TiledTile's gid to change the map tile's style. + !#zh TiledTile 可以单独对某一个地图块进行操作。 + 他会将节点的旋转,缩放,平移操作应用在这个地图块上,并可以通过更换当前地图块的 gid 来更换地图块的显示样式。 */ + export class TiledTile extends Component { + /** !#en Specify the TiledTile horizontal coordinate,use map tile as the unit. + !#zh 指定 TiledTile 的横向坐标,以地图块为单位 */ + x: number; + /** !#en Specify the TiledTile vertical coordinate,use map tile as the unit. + !#zh 指定 TiledTile 的纵向坐标,以地图块为单位 */ + y: number; + /** !#en Specify the TiledTile gid. + !#zh 指定 TiledTile 的 gid 值 */ + gid: number; + } + /** Class for particle asset handling. */ + export class ParticleAsset extends Asset { + } + /** Particle System base class.
+ Attributes of a Particle System:
+ - emmision rate of the particles
+ - Gravity Mode (Mode A):
+ - gravity
+ - direction
+ - speed +- variance
+ - tangential acceleration +- variance
+ - radial acceleration +- variance
+ - Radius Mode (Mode B):
+ - startRadius +- variance
+ - endRadius +- variance
+ - rotate +- variance
+ - Properties common to all modes:
+ - life +- life variance
+ - start spin +- variance
+ - end spin +- variance
+ - start size +- variance
+ - end size +- variance
+ - start color +- variance
+ - end color +- variance
+ - life +- variance
+ - blending function
+ - texture
+
+ cocos2d also supports particles generated by Particle Designer (http://particledesigner.71squared.com/).
+ 'Radius Mode' in Particle Designer uses a fixed emit rate of 30 hz. Since that can't be guarateed in cocos2d,
+ cocos2d uses a another approach, but the results are almost identical.
+ cocos2d supports all the variables used by Particle Designer plus a bit more:
+ - spinning particles (supported when using ParticleSystem)
+ - tangential acceleration (Gravity mode)
+ - radial acceleration (Gravity mode)
+ - radius direction (Radius mode) (Particle Designer supports outwards to inwards direction only)
+ It is possible to customize any of the above mentioned properties in runtime. Example:
*/ + export class ParticleSystem extends RenderComponent implements BlendFunc { + /** !#en Play particle in edit mode. + !#zh 在编辑器模式下预览粒子,启用后选中粒子时,粒子将自动播放。 */ + preview: boolean; + /** !#en + If set custom to true, then use custom properties insteadof read particle file. + !#zh 是否自定义粒子属性。 */ + custom: boolean; + /** !#en The plist file. + !#zh plist 格式的粒子配置文件。 */ + file: ParticleAsset; + /** !#en SpriteFrame used for particles display + !#zh 用于粒子呈现的 SpriteFrame */ + spriteFrame: SpriteFrame; + /** !#en Texture of Particle System, readonly, please use spriteFrame to setup new texture。 + !#zh 粒子贴图,只读属性,请使用 spriteFrame 属性来替换贴图。 */ + texture: string; + /** !#en Current quantity of particles that are being simulated. + !#zh 当前播放的粒子数量。 */ + particleCount: number; + /** !#en Indicate whether the system simulation have stopped. + !#zh 指示粒子播放是否完毕。 */ + stopped: boolean; + /** !#en If set to true, the particle system will automatically start playing on onLoad. + !#zh 如果设置为 true 运行时会自动发射粒子。 */ + playOnLoad: boolean; + /** !#en Indicate whether the owner node will be auto-removed when it has no particles left. + !#zh 粒子播放完毕后自动销毁所在的节点。 */ + autoRemoveOnFinish: boolean; + /** !#en Indicate whether the particle system is activated. + !#zh 是否激活粒子。 */ + active: boolean; + /** !#en Maximum particles of the system. + !#zh 粒子最大数量。 */ + totalParticles: number; + /** !#en How many seconds the emitter wil run. -1 means 'forever'. + !#zh 发射器生存时间,单位秒,-1表示持续发射。 */ + duration: number; + /** !#en Emission rate of the particles. + !#zh 每秒发射的粒子数目。 */ + emissionRate: number; + /** !#en Life of each particle setter. + !#zh 粒子的运行时间。 */ + life: number; + /** !#en Variation of life. + !#zh 粒子的运行时间变化范围。 */ + lifeVar: number; + /** !#en Start color of each particle. + !#zh 粒子初始颜色。 */ + startColor: Color; + /** !#en Variation of the start color. + !#zh 粒子初始颜色变化范围。 */ + startColorVar: Color; + /** !#en Ending color of each particle. + !#zh 粒子结束颜色。 */ + endColor: Color; + /** !#en Variation of the end color. + !#zh 粒子结束颜色变化范围。 */ + endColorVar: Color; + /** !#en Angle of each particle setter. + !#zh 粒子角度。 */ + angle: number; + /** !#en Variation of angle of each particle setter. + !#zh 粒子角度变化范围。 */ + angleVar: number; + /** !#en Start size in pixels of each particle. + !#zh 粒子的初始大小。 */ + startSize: number; + /** !#en Variation of start size in pixels. + !#zh 粒子初始大小的变化范围。 */ + startSizeVar: number; + /** !#en End size in pixels of each particle. + !#zh 粒子结束时的大小。 */ + endSize: number; + /** !#en Variation of end size in pixels. + !#zh 粒子结束大小的变化范围。 */ + endSizeVar: number; + /** !#en Start angle of each particle. + !#zh 粒子开始自旋角度。 */ + startSpin: number; + /** !#en Variation of start angle. + !#zh 粒子开始自旋角度变化范围。 */ + startSpinVar: number; + /** !#en End angle of each particle. + !#zh 粒子结束自旋角度。 */ + endSpin: number; + /** !#en Variation of end angle. + !#zh 粒子结束自旋角度变化范围。 */ + endSpinVar: number; + /** !#en Source position of the emitter. + !#zh 发射器位置。 */ + sourcePos: Vec2; + /** !#en Variation of source position. + !#zh 发射器位置的变化范围。(横向和纵向) */ + posVar: Vec2; + /** !#en Particles movement type. + !#zh 粒子位置类型。 */ + positionType: ParticleSystem.PositionType; + /** !#en Particles emitter modes. + !#zh 发射器类型。 */ + emitterMode: ParticleSystem.EmitterMode; + /** !#en Gravity of the emitter. + !#zh 重力。 */ + gravity: Vec2; + /** !#en Speed of the emitter. + !#zh 速度。 */ + speed: number; + /** !#en Variation of the speed. + !#zh 速度变化范围。 */ + speedVar: number; + /** !#en Tangential acceleration of each particle. Only available in 'Gravity' mode. + !#zh 每个粒子的切向加速度,即垂直于重力方向的加速度,只有在重力模式下可用。 */ + tangentialAccel: number; + /** !#en Variation of the tangential acceleration. + !#zh 每个粒子的切向加速度变化范围。 */ + tangentialAccelVar: number; + /** !#en Acceleration of each particle. Only available in 'Gravity' mode. + !#zh 粒子径向加速度,即平行于重力方向的加速度,只有在重力模式下可用。 */ + radialAccel: number; + /** !#en Variation of the radial acceleration. + !#zh 粒子径向加速度变化范围。 */ + radialAccelVar: number; + /** !#en Indicate whether the rotation of each particle equals to its direction. Only available in 'Gravity' mode. + !#zh 每个粒子的旋转是否等于其方向,只有在重力模式下可用。 */ + rotationIsDir: boolean; + /** !#en Starting radius of the particles. Only available in 'Radius' mode. + !#zh 初始半径,表示粒子出生时相对发射器的距离,只有在半径模式下可用。 */ + startRadius: number; + /** !#en Variation of the starting radius. + !#zh 初始半径变化范围。 */ + startRadiusVar: number; + /** !#en Ending radius of the particles. Only available in 'Radius' mode. + !#zh 结束半径,只有在半径模式下可用。 */ + endRadius: number; + /** !#en Variation of the ending radius. + !#zh 结束半径变化范围。 */ + endRadiusVar: number; + /** !#en Number of degress to rotate a particle around the source pos per second. Only available in 'Radius' mode. + !#zh 粒子每秒围绕起始点的旋转角度,只有在半径模式下可用。 */ + rotatePerS: number; + /** !#en Variation of the degress to rotate a particle around the source pos per second. + !#zh 粒子每秒围绕起始点的旋转角度变化范围。 */ + rotatePerSVar: number; + /** !#en The Particle emitter lives forever. + !#zh 表示发射器永久存在 */ + static DURATION_INFINITY: number; + /** !#en The starting size of the particle is equal to the ending size. + !#zh 表示粒子的起始大小等于结束大小。 */ + static START_SIZE_EQUAL_TO_END_SIZE: number; + /** !#en The starting radius of the particle is equal to the ending radius. + !#zh 表示粒子的起始半径等于结束半径。 */ + static START_RADIUS_EQUAL_TO_END_RADIUS: number; + /** + !#en Stop emitting particles. Running particles will continue to run until they die. + !#zh 停止发射器发射粒子,发射出去的粒子将继续运行,直至粒子生命结束。 + + @example + ```js + // stop particle system. + myParticleSystem.stopSystem(); + ``` + */ + stopSystem(): void; + /** + !#en Kill all living particles. + !#zh 杀死所有存在的粒子,然后重新启动粒子发射器。 + + @example + ```js + // play particle system. + myParticleSystem.resetSystem(); + ``` + */ + resetSystem(): void; + /** + !#en Whether or not the system is full. + !#zh 发射器中粒子是否大于等于设置的总粒子数量。 + */ + isFull(): boolean; + /** + !#en Sets a new texture with a rect. The rect is in texture position and size. + Please use spriteFrame property instead, this function is deprecated since v1.9 + !#zh 设置一张新贴图和关联的矩形。 + 请直接设置 spriteFrame 属性,这个函数从 v1.9 版本开始已经被废弃 + @param texture texture + @param rect rect + */ + setTextureWithRect(texture: Texture2D, rect: Rect): void; + /** !#en specify the source Blend Factor, this will generate a custom material object, please pay attention to the memory cost. + !#zh 指定原图的混合模式,这会克隆一个新的材质对象,注意这带来的开销 */ + srcBlendFactor: macro.BlendFactor; + /** !#en specify the destination Blend Factor. + !#zh 指定目标的混合模式 */ + dstBlendFactor: macro.BlendFactor; + } + /** !#en cc.VideoPlayer is a component for playing videos, you can use it for showing videos in your game. Because different platforms have different authorization, API and control methods for VideoPlayer component. And have not yet formed a unified standard, only Web, iOS, and Android platforms are currently supported. + !#zh Video 组件,用于在游戏中播放视频。由于不同平台对于 VideoPlayer 组件的授权、API、控制方式都不同,还没有形成统一的标准,所以目前只支持 Web、iOS 和 Android 平台。 */ + export class VideoPlayer extends Component { + /** !#en The resource type of videoplayer, REMOTE for remote url and LOCAL for local file path. + !#zh 视频来源:REMOTE 表示远程视频 URL,LOCAL 表示本地视频地址。 */ + resourceType: VideoPlayer.ResourceType; + /** !#en The remote URL of video. + !#zh 远程视频的 URL */ + remoteURL: string; + /** !#en The local video full path. + !#zh 本地视频的 URL */ + clip: string; + /** !#en The current playback time of the now playing item in seconds, you could also change the start playback time. + !#zh 指定视频从什么时间点开始播放,单位是秒,也可以用来获取当前视频播放的时间进度。 */ + currentTime: number; + /** !#en The volume of the video. + !#zh 视频的音量(0.0 ~ 1.0) */ + volume: number; + /** !#en Mutes the VideoPlayer. Mute sets the volume=0, Un-Mute restore the original volume. + !#zh 是否静音视频。静音时设置音量为 0,取消静音是恢复原来的音量。 */ + mute: boolean; + /** !#en Whether keep the aspect ration of the original video. + !#zh 是否保持视频原来的宽高比 */ + keepAspectRatio: boolean; + /** !#en Whether play video in fullscreen mode. + !#zh 是否全屏播放视频 */ + isFullscreen: boolean; + /** !#en Always below the game view (only useful on Web. Note: The specific effects are not guaranteed to be consistent, depending on whether each browser supports or restricts). + !#zh 永远在游戏视图最底层(这个属性只有在 Web 平台上有效果。注意:具体效果无法保证一致,跟各个浏览器是否支持与限制有关) */ + stayOnBottom: boolean; + /** !#en the video player's callback, it will be triggered when certain event occurs, like: playing, paused, stopped and completed. + !#zh 视频播放回调函数,该回调函数会在特定情况被触发,比如播放中,暂时,停止和完成播放。 */ + videoPlayerEvent: Component.EventHandler[]; + /** + !#en If a video is paused, call this method could resume playing. If a video is stopped, call this method to play from scratch. + !#zh 如果视频被暂停播放了,调用这个接口可以继续播放。如果视频被停止播放了,调用这个接口可以从头开始播放。 + */ + play(): void; + /** + !#en If a video is paused, call this method to resume playing. + !#zh 如果一个视频播放被暂停播放了,调用这个接口可以继续播放。 + */ + resume(): void; + /** + !#en If a video is playing, call this method to pause playing. + !#zh 如果一个视频正在播放,调用这个接口可以暂停播放。 + */ + pause(): void; + /** + !#en If a video is playing, call this method to stop playing immediately. + !#zh 如果一个视频正在播放,调用这个接口可以立马停止播放。 + */ + stop(): void; + /** + !#en Gets the duration of the video + !#zh 获取视频文件的播放总时长 + */ + getDuration(): number; + /** + !#en Determine whether video is playing or not. + !#zh 判断当前视频是否处于播放状态 + */ + isPlaying(): boolean; + /** + !#en if you don't need the VideoPlayer and it isn't in any running Scene, you should + call the destroy method on this component or the associated node explicitly. + Otherwise, the created DOM element won't be removed from web page. + !#zh + 如果你不再使用 VideoPlayer,并且组件未添加到场景中,那么你必须手动对组件或所在节点调用 destroy。 + 这样才能移除网页上的 DOM 节点,避免 Web 平台内存泄露。 + + @example + ```js + videoplayer.node.parent = null; // or videoplayer.node.removeFromParent(false); + // when you don't need videoplayer anymore + videoplayer.node.destroy(); + ``` + */ + destroy(): boolean; + } + /** !#en cc.WebView is a component for display web pages in the game. Because different platforms have different authorization, API and control methods for WebView component. And have not yet formed a unified standard, only Web, iOS, and Android platforms are currently supported. + !#zh WebView 组件,用于在游戏中显示网页。由于不同平台对于 WebView 组件的授权、API、控制方式都不同,还没有形成统一的标准,所以目前只支持 Web、iOS 和 Android 平台。 */ + export class WebView extends Component { + /** !#en A given URL to be loaded by the WebView, it should have a http or https prefix. + !#zh 指定 WebView 加载的网址,它应该是一个 http 或者 https 开头的字符串 */ + url: string; + /** !#en The webview's event callback , it will be triggered when certain webview event occurs. + !#zh WebView 的回调事件,当网页加载过程中,加载完成后或者加载出错时都会回调此函数 */ + webviewLoadedEvents: Component.EventHandler[]; + /** + !#en + Set javascript interface scheme (see also setOnJSCallback).
+ Note: Supports only on the Android and iOS. For HTML5, please refer to the official documentation.
+ Please refer to the official documentation for more details. + !#zh + 设置 JavaScript 接口方案(与 'setOnJSCallback' 配套使用)。
+ 注意:只支持 Android 和 iOS ,Web 端用法请前往官方文档查看。
+ 详情请参阅官方文档 + @param scheme scheme + */ + setJavascriptInterfaceScheme(scheme: string): void; + /** + !#en + This callback called when load URL that start with javascript + interface scheme (see also setJavascriptInterfaceScheme).
+ Note: Supports only on the Android and iOS. For HTML5, please refer to the official documentation.
+ Please refer to the official documentation for more details. + !#zh + 当加载 URL 以 JavaScript 接口方案开始时调用这个回调函数。
+ 注意:只支持 Android 和 iOS,Web 端用法请前往官方文档查看。 + 详情请参阅官方文档 + @param callback callback + */ + setOnJSCallback(callback: Function): void; + /** + !#en + Evaluates JavaScript in the context of the currently displayed page.
+ Please refer to the official document for more details
+ Note: Cross domain issues need to be resolved by yourself
+ !#zh + 执行 WebView 内部页面脚本(详情请参阅官方文档)
+ 注意:需要自行解决跨域问题 + @param str str + */ + evaluateJS(str: string): void; + /** + !#en if you don't need the WebView and it isn't in any running Scene, you should + call the destroy method on this component or the associated node explicitly. + Otherwise, the created DOM element won't be removed from web page. + !#zh + 如果你不再使用 WebView,并且组件未添加到场景中,那么你必须手动对组件或所在节点调用 destroy。 + 这样才能移除网页上的 DOM 节点,避免 Web 平台内存泄露。 + + @example + ```js + webview.node.parent = null; // or webview.node.removeFromParent(false); + // when you don't need webview anymore + webview.node.destroy(); + ``` + */ + destroy(): boolean; + } + /** !#en The Light Component + + !#zh 光源组件 */ + export class Light extends Component { + } + /** !#en + Camera is usefull when making reel game or other games which need scroll screen. + Using camera will be more efficient than moving node to scroll screen. + Camera + !#zh + 摄像机在制作卷轴或是其他需要移动屏幕的游戏时比较有用,使用摄像机将会比移动节点来移动屏幕更加高效。 */ + export class Camera extends Component { + /** !#en + The camera zoom ratio, only support 2D camera. + !#zh + 摄像机缩放比率, 只支持 2D camera。 */ + zoomRatio: number; + /** !#en + Field of view. The width of the Camera’s view angle, measured in degrees along the local Y axis. + !#zh + 决定摄像机视角的宽度,当摄像机处于透视投影模式下这个属性才会生效。 */ + fov: number; + /** !#en + The viewport size of the Camera when set to orthographic projection. + !#zh + 摄像机在正交投影模式下的视窗大小。 */ + orthoSize: number; + /** !#en + The near clipping plane. + !#zh + 摄像机的近剪裁面。 */ + nearClip: number; + /** !#en + The far clipping plane. + !#zh + 摄像机的远剪裁面。 */ + farClip: number; + /** !#en + Is the camera orthographic (true) or perspective (false)? + !#zh + 设置摄像机的投影模式是正交还是透视模式。 */ + ortho: boolean; + /** !#en + Four values (0 ~ 1) that indicate where on the screen this camera view will be drawn. + !#zh + 决定摄像机绘制在屏幕上哪个位置,值为(0 ~ 1)。 */ + rect: Rect; + /** !#en + This is used to render parts of the scene selectively. + !#zh + 决定摄像机会渲染场景的哪一部分。 */ + cullingMask: number; + /** !#en + Determining what to clear when camera rendering. + !#zh + 决定摄像机渲染时会清除哪些状态。 */ + clearFlags: Camera.ClearFlags; + /** !#en + The color with which the screen will be cleared. + !#zh + 摄像机用于清除屏幕的背景色。 */ + backgroundColor: Color; + /** !#en + Camera's depth in the camera rendering order. Cameras with higher depth are rendered after cameras with lower depth. + !#zh + 摄像机深度。用于决定摄像机的渲染顺序,值越大渲染在越上层。 */ + depth: number; + /** !#en + Destination render texture. + Usually cameras render directly to screen, but for some effects it is useful to make a camera render into a texture. + !#zh + 摄像机渲染的目标 RenderTexture。 + 一般摄像机会直接渲染到屏幕上,但是有一些效果可以使用摄像机渲染到 RenderTexture 上再对 RenderTexture 进行处理来实现。 */ + targetTexture: RenderTexture; + /** !#en + Sets the camera's render stages. + !#zh + 设置摄像机渲染的阶段 */ + renderStages: number; + /** !#en Whether auto align camera viewport to screen + !#zh 是否自动将摄像机的视口对准屏幕 */ + alignWithScreen: boolean; + /** !#en + The primary camera in the scene. Returns the rear most rendered camera, which is the camera with the lowest depth. + !#zh + 当前场景中激活的主摄像机。将会返回渲染在屏幕最底层,也就是 depth 最小的摄像机。 */ + static main: Camera; + /** !#en + All enabled cameras. + !#zh + 当前激活的所有摄像机。 */ + static cameras: Camera[]; + /** + !#en + Get the first camera which the node belong to. + !#zh + 获取节点所在的第一个摄像机。 + @param node node + */ + static findCamera(node: Node): Camera; + /** + !#en + Get the screen to world matrix, only support 2D camera which alignWithScreen is true. + !#zh + 获取屏幕坐标系到世界坐标系的矩阵,只适用于 alignWithScreen 为 true 的 2D 摄像机。 + @param out the matrix to receive the result + */ + getScreenToWorldMatrix2D(out: Mat4): Mat4; + /** + !#en + Get the world to camera matrix, only support 2D camera which alignWithScreen is true. + !#zh + 获取世界坐标系到摄像机坐标系的矩阵,只适用于 alignWithScreen 为 true 的 2D 摄像机。 + @param out the matrix to receive the result + */ + getWorldToScreenMatrix2D(out: Mat4): Mat4; + /** + !#en + Convert point from screen to world. + !#zh + 将坐标从屏幕坐标系转换到世界坐标系。 + @param screenPosition screenPosition + @param out out + */ + getScreenToWorldPoint(screenPosition: Vec3|Vec2, out?: Vec3|Vec2): Vec3; + /** + !#en + Convert point from world to screen. + !#zh + 将坐标从世界坐标系转化到屏幕坐标系。 + @param worldPosition worldPosition + @param out out + */ + getWorldToScreenPoint(worldPosition: Vec3|Vec2, out?: Vec3|Vec2): Vec3; + /** + !#en + Get a ray from screen position + !#zh + 从屏幕坐标获取一条射线 + @param screenPos screenPos + */ + getRay(screenPos: Vec2): geomUtils.Ray; + /** + !#en + Check whether the node is in the camera. + !#zh + 检测节点是否被此摄像机影响 + @param node the node which need to check + */ + containsNode(node: Node): boolean; + /** + !#en + Render the camera manually. + !#zh + 手动渲染摄像机。 + @param rootNode rootNode + */ + render(rootNode?: Node): void; + /** + !#en + Returns the matrix that transform the node's (local) space coordinates into the camera's space coordinates. + !#zh + 返回一个将节点坐标系转换到摄像机坐标系下的矩阵 + @param node the node which should transform + */ + getNodeToCameraTransform(node: Node): AffineTransform; + /** + !#en + Conver a camera coordinates point to world coordinates. + !#zh + 将一个摄像机坐标系下的点转换到世界坐标系下。 + @param point the point which should transform + @param out the point to receive the result + */ + getCameraToWorldPoint(point: Vec2, out?: Vec2): Vec2; + /** + !#en + Conver a world coordinates point to camera coordinates. + !#zh + 将一个世界坐标系下的点转换到摄像机坐标系下。 + @param point point + @param out the point to receive the result + */ + getWorldToCameraPoint(point: Vec2, out?: Vec2): Vec2; + /** + !#en + Get the camera to world matrix + !#zh + 获取摄像机坐标系到世界坐标系的矩阵 + @param out the matrix to receive the result + */ + getCameraToWorldMatrix(out: Mat4): Mat4; + /** + !#en + Get the world to camera matrix + !#zh + 获取世界坐标系到摄像机坐标系的矩阵 + @param out the matrix to receive the result + */ + getWorldToCameraMatrix(out: Mat4): Mat4; + } + /** !#en + This module controls asset's behaviors and information, include loading, releasing etc. it is a singleton + All member can be accessed with `cc.assetManager`. + + !#zh + 此模块管理资源的行为和信息,包括加载,释放等,这是一个单例,所有成员能够通过 `cc.assetManager` 调用 */ + export class AssetManager { + /** !#en + Normal loading pipeline + + !#zh + 正常加载管线 */ + pipeline: cc.AssetManager.Pipeline; + /** !#en + Fetching pipeline + + !#zh + 下载管线 */ + fetchPipeline: cc.AssetManager.Pipeline; + /** !#en + Url transformer + + !#zh + Url 转换器 */ + transformPipeline: cc.AssetManager.Pipeline; + /** !#en + The collection of bundle which is already loaded, you can remove cache with {{#crossLink "AssetManager/removeBundle:method"}}{{/crossLink}} + + !#zh + 已加载 bundle 的集合, 你能通过 {{#crossLink "AssetManager/removeBundle:method"}}{{/crossLink}} 来移除缓存 */ + bundles: AssetManager.Cache; + /** !#en + The collection of asset which is already loaded, you can remove cache with {{#crossLink "AssetManager/releaseAsset:method"}}{{/crossLink}} + + !#zh + 已加载资源的集合, 你能通过 {{#crossLink "AssetManager/releaseAsset:method"}}{{/crossLink}} 来移除缓存 */ + assets: AssetManager.Cache; + /** !#en + Manage relationship between asset and its dependencies + + !#zh + 管理资源依赖关系 */ + dependUtil: cc.AssetManager.DependUtil; + /** !#en + Whether or not cache the loaded asset + + !#zh + 是否缓存已加载的资源 */ + cacheAsset: boolean; + /** !#en + Whether or not load asset forcely, if it is true, asset will be loaded regardless of error + + !#zh + 是否强制加载资源, 如果为 true ,加载资源将会忽略报错 */ + force: boolean; + /** !#en + Some useful function + + !#zh + 一些有用的方法 */ + utils: cc.AssetManager.Helper; + /** !#en + Manage all downloading task + + !#zh + 管理所有下载任务 */ + downloader: cc.AssetManager.Downloader; + /** !#en + Manage all parsing task + + !#zh + 管理所有解析任务 */ + parser: cc.AssetManager.Parser; + /** !#en + Manage internal asset + + !#zh + 管理内置资源 */ + builtins: cc.AssetManager.Builtins; + /** !#en + Manage all packed asset + + !#zh + 管理所有合并后的资源 */ + packManager: cc.AssetManager.PackManager; + /** !#en + Cache manager is a module which controls all caches downloaded from server in non-web platform. + + !#zh + 缓存管理器是一个模块,在非 WEB 平台上,用于管理所有从服务器上下载下来的缓存 */ + cacheManager: cc.AssetManager.CacheManager|null; + /** !#en + The preset of options + + !#zh + 可选参数的预设集 */ + presets: Record>; + /** !#en + The builtin 'main' bundle + + !#zh + 内置 main 包 */ + main: cc.AssetManager.Bundle; + /** !#en + The builtin 'resources' bundle + + !#zh + 内置 resources 包 */ + resources: cc.AssetManager.Bundle; + /** !#en + The builtin 'internal' bundle + + !#zh + 内置 internal 包 */ + internal: cc.AssetManager.Bundle; + /** + !#en + Initialize assetManager with options + + !#zh + 初始化资源管理器 + @param options options + */ + init(options: Record): void; + /** + !#en + Get the bundle which has been loaded + + !#zh + 获取已加载的分包 + @param name The name of bundle + + @example + ```js + // ${project}/assets/test1 + cc.assetManager.getBundle('test1'); + + cc.assetManager.getBundle('resources'); + ``` + */ + getBundle (name: string): cc.AssetManager.Bundle; + /** + !#en + Remove this bundle. NOTE: The asset whthin this bundle will not be released automatically, you can call {{#crossLink "Bundle/releaseAll:method"}}{{/crossLink}} manually before remove it if you need + + !#zh + 移除此包, 注意:这个包内的资源不会自动释放, 如果需要的话你可以在摧毁之前手动调用 {{#crossLink "Bundle/releaseAll:method"}}{{/crossLink}} 进行释放 + @param bundle The bundle to be removed + */ + removeBundle(bundle: cc.AssetManager.Bundle): void; + /** + !#en + General interface used to load assets with a progression callback and a complete callback. You can achieve almost all effect you want with combination of `requests` and `options`. + It is highly recommended that you use more simple API, such as `load`, `loadDir` etc. Every custom parameter in `options` will be distribute to each of `requests`. + if request already has same one, the parameter in request will be given priority. Besides, if request has dependencies, `options` will distribute to dependencies too. + Every custom parameter in `requests` will be tranfered to handler of `downloader` and `parser` as `options`. + You can register you own handler downloader or parser to collect these custom parameters for some effect. + + Reserved Keyword: `uuid`, `url`, `path`, `dir`, `scene`, `type`, `priority`, `preset`, `audioLoadMode`, `ext`, `bundle`, `onFileProgress`, `maxConcurrency`, `maxRequestsPerFrame` + `maxRetryCount`, `version`, `responseType`, `withCredentials`, `mimeType`, `timeout`, `header`, `reload`, `cacheAsset`, `cacheEnabled`, + Please DO NOT use these words as custom options! + + !#zh + 通用加载资源接口,可传入进度回调以及完成回调,通过组合 `request` 和 `options` 参数,几乎可以实现和扩展所有想要的加载效果。非常建议你使用更简单的API,例如 `load`、`loadDir` 等。 + `options` 中的自定义参数将会分发到 `requests` 的每一项中,如果request中已存在同名的参数则以 `requests` 中为准,同时如果有其他 + 依赖资源,则 `options` 中的参数会继续向依赖项中分发。request中的自定义参数都会以 `options` 形式传入加载流程中的 `downloader`, `parser` 的方法中, 你可以 + 扩展 `downloader`, `parser` 收集参数完成想实现的效果。 + + 保留关键字: `uuid`, `url`, `path`, `dir`, `scene`, `type`, `priority`, `preset`, `audioLoadMode`, `ext`, `bundle`, `onFileProgress`, `maxConcurrency`, `maxRequestsPerFrame` + `maxRetryCount`, `version`, `responseType`, `withCredentials`, `mimeType`, `timeout`, `header`, `reload`, `cacheAsset`, `cacheEnabled`, + 请不要使用这些字段为自定义参数! + @param requests The request you want to load + @param options Optional parameters + @param onProgress Callback invoked when progression change + @param onComplete Callback invoked when finish loading + + @example + ```js + cc.assetManager.loadAny({url: 'http://example.com/a.png'}, (err, img) => cc.log(img)); + cc.assetManager.loadAny(['60sVXiTH1D/6Aft4MRt9VC'], (err, assets) => cc.log(assets)); + cc.assetManager.loadAny([{ uuid: '0cbZa5Y71CTZAccaIFluuZ'}, {url: 'http://example.com/a.png'}], (err, assets) => cc.log(assets)); + cc.assetManager.downloader.register('.asset', (url, options, onComplete) => { + url += '?userName=' + options.userName + "&password=" + options.password; + cc.assetManager.downloader.downloadFile(url, null, onComplete); + }); + cc.assetManager.parser.register('.asset', (file, options, onComplete) => { + var json = JSON.parse(file); + var skin = json[options.skin]; + var model = json[options.model]; + onComplete(null, {skin, model}); + }); + cc.assetManager.loadAny({ url: 'http://example.com/my.asset', skin: 'xxx', model: 'xxx', userName: 'xxx', password: 'xxx' }); + ``` + */ + loadAny(requests: string | string[] | Record | Record[], options: Record, onProgress: (finished: number, total: number, item: cc.AssetManager.RequestItem) => void, onComplete: (err: Error, data: any) => void): void; + loadAny(requests: string | string[] | Record | Record[], options: Record, onComplete: (err: Error, data: any) => void): void; + loadAny(requests: string | string[] | Record | Record[], options: Record): void; + loadAny(requests: string | string[] | Record | Record[], onProgress: (finished: number, total: number, item: cc.AssetManager.RequestItem) => void, onComplete: (err: Error, data: any) => void): void; + loadAny(requests: string | string[] | Record | Record[], onComplete: (err: Error, data: any) => void): void; + loadAny(requests: string | string[] | Record | Record[]): void; + /** + !#en + General interface used to preload assets with a progression callback and a complete callback.It is highly recommended that you use more simple API, such as `preloadRes`, `preloadResDir` etc. + Everything about preload is just likes `cc.assetManager.loadAny`, the difference is `cc.assetManager.preloadAny` will only download asset but not parse asset. You need to invoke `cc.assetManager.loadAny(preloadTask)` + to finish loading asset + + !#zh + 通用预加载资源接口,可传入进度回调以及完成回调,非常建议你使用更简单的 API ,例如 `preloadRes`, `preloadResDir` 等。`preloadAny` 和 `loadAny` 几乎一样,区别在于 `preloadAny` 只会下载资源,不会去解析资源,你需要调用 `cc.assetManager.loadAny(preloadTask)` + 来完成资源加载。 + @param requests The request you want to preload + @param options Optional parameters + @param onProgress Callback invoked when progression change + @param onComplete Callback invoked when finish preloading + + @example + ```js + cc.assetManager.preloadAny('0cbZa5Y71CTZAccaIFluuZ', (err) => cc.assetManager.loadAny('0cbZa5Y71CTZAccaIFluuZ')); + ``` + */ + preloadAny(requests: string | string[] | Record | Record[], options: Record, onProgress: (finished: number, total: number, item: cc.AssetManager.RequestItem) => void, onComplete: (err: Error, items: cc.AssetManager.RequestItem[]) => void): void; + preloadAny(requests: string | string[] | Record | Record[], options: Record, onComplete: (err: Error, items: cc.AssetManager.RequestItem[]) => void): void; + preloadAny(requests: string | string[] | Record | Record[], onProgress: (finished: number, total: number, item: cc.AssetManager.RequestItem) => void, onComplete: (err: Error, items: cc.AssetManager.RequestItem[]) => void): void; + preloadAny(requests: string | string[] | Record | Record[], onComplete: (err: Error, items: cc.AssetManager.RequestItem[]) => void): void; + preloadAny(requests: string | string[] | Record | Record[], options: Record): void; + preloadAny(requests: string | string[] | Record | Record[]): void; + /** + !#en + Load native file of asset, if you check the option 'Async Load Assets', you may need to load native file with this before you use the asset + + !#zh + 加载资源的原生文件,如果你勾选了'延迟加载资源'选项,你可能需要在使用资源之前调用此方法来加载原生文件 + @param asset The asset + @param options Some optional parameters + @param onComplete Callback invoked when finish loading + + @example + ```js + cc.assetManager.postLoadNative(texture, (err) => console.log(err)); + ``` + */ + postLoadNative(asset: cc.Asset, options: Record, onComplete: (err: Error) => void): void; + postLoadNative(asset: cc.Asset, options: Record): void; + postLoadNative(asset: cc.Asset, onComplete: (err: Error) => void): void; + postLoadNative(asset: cc.Asset): void; + /** + !#en + Load remote asset with url, such as audio, image, text and so on. + + !#zh + 使用 url 加载远程资源,例如音频,图片,文本等等。 + @param url The url of asset + @param options Some optional parameters + @param onComplete Callback invoked when finish loading + + @example + ```js + cc.assetManager.loadRemote('http://www.cloud.com/test1.jpg', (err, texture) => console.log(err)); + cc.assetManager.loadRemote('http://www.cloud.com/test2.mp3', (err, audioClip) => console.log(err)); + ``` + */ + loadRemote(url: string, options: Record, onComplete: (err: Error, asset: T) => void): void; + loadRemote(url: string, options: Record): void; + loadRemote(url: string, onComplete: (err: Error, asset: T) => void): void; + loadRemote(url: string): void; + /** + !#en + Load script + + !#zh + 加载脚本 + @param url Url of the script + @param options Some optional paramters + @param onComplete Callback when script loaded or failed + + @example + ```js + loadScript('http://localhost:8080/index.js', null, (err) => console.log(err)); + ``` + */ + loadScript(url: string|string[], options: Record, onComplete: (err: Error) => void): void;; + loadScript(url: string|string[], options: Record): void;; + loadScript(url: string|string[], onComplete: (err: Error) => void): void;; + loadScript(url: string|string[]): void;; + /** + !#en + load bundle + + !#zh + 加载资源包 + @param nameOrUrl The name or root path of bundle + @param options Some optional paramter, same like downloader.downloadFile + @param onComplete Callback when bundle loaded or failed + + @example + ```js + loadBundle('http://localhost:8080/test', null, (err, bundle) => console.log(err)); + ``` + */ + loadBundle(nameOrUrl: string, options: Record, onComplete: (err: Error, bundle: cc.AssetManager.Bundle) => void): void; + loadBundle(nameOrUrl: string, options: Record): void; + loadBundle(nameOrUrl: string, onComplete: (err: Error, bundle: cc.AssetManager.Bundle) => void): void; + loadBundle(nameOrUrl: string): void; + /** + !#en + Release asset and it's dependencies. + This method will not only remove the cache of the asset in assetManager, but also clean up its content. + For example, if you release a texture, the texture asset and its gl texture data will be freed up. + Notice, this method may cause the texture to be unusable, if there are still other nodes use the same texture, they may turn to black and report gl errors. + + !#zh + 释放资源以及其依赖资源, 这个方法不仅会从 assetManager 中删除资源的缓存引用,还会清理它的资源内容。 + 比如说,当你释放一个 texture 资源,这个 texture 和它的 gl 贴图数据都会被释放。 + 注意,这个函数可能会导致资源贴图或资源所依赖的贴图不可用,如果场景中存在节点仍然依赖同样的贴图,它们可能会变黑并报 GL 错误。 + @param asset The asset to be released + + @example + ```js + // release a texture which is no longer need + cc.assetManager.releaseAsset(texture); + ``` + */ + releaseAsset(asset: cc.Asset): void; + /** + !#en + Release all assets. Refer to {{#crossLink "AssetManager/releaseAsset:method"}}{{/crossLink}} for detailed informations. + + !#zh + 释放所有资源。详细信息请参考 {{#crossLink "AssetManager/releaseAsset:method"}}{{/crossLink}} + */ + releaseAll(): void; + } + /** `cc.loader` is deprecated, please backup your project and upgrade to {{#crossLink "AssetManager"}}{{/crossLink}} */ + export class loader { + /** `cc.loader.onProgress` is deprecated, please transfer onProgress to API as a parameter */ + static onProgress: any; + /** + `cc.loader.load` is deprecated, please use {{#crossLink "AssetManager/loadAny:method"}}{{/crossLink}} instead + @param resources Url list in an array + @param progressCallback Callback invoked when progression change + @param completeCallback Callback invoked when all resources loaded + */ + static load(resources: string|string[]|{uuid?: string, url?: string, type?: string}, completeCallback?: Function): void; + static load(resources: string|string[]|{uuid?: string, url?: string, type?: string}, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: Function|null): void; + /** + `cc.loader.getXMLHttpRequest` is deprecated, please use `XMLHttpRequest` directly + */ + static getXMLHttpRequest(): XMLHttpRequest; + /** + `cc.loader.getItem` is deprecated, please use `cc.assetManager.asset.get` instead + @param id The id of the item + */ + static getItem(id: any): any; + /** + `cc.loader.loadRes` is deprecated, please use {{#crossLink "Bundle/load:method"}}{{/crossLink}} instead + @param url Url of the target resource. + The url is relative to the "resources" folder, extensions must be omitted. + @param type Only asset of type will be loaded if this argument is supplied. + @param progressCallback Callback invoked when progression change. + @param completeCallback Callback invoked when the resource loaded. + */ + static loadRes(url: string, type: typeof cc.Asset, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any) => void)|null): void; + static loadRes(url: string, type: typeof cc.Asset, completeCallback: (error: Error, resource: any) => void): void; + static loadRes(url: string, type: typeof cc.Asset): void; + static loadRes(url: string, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any) => void)|null): void; + static loadRes(url: string, completeCallback: (error: Error, resource: any) => void): void; + static loadRes(url: string): void; + /** + `cc.loader.loadResArray` is deprecated, please use {{#crossLink "Bundle/load:method"}}{{/crossLink}} instead + @param urls Array of URLs of the target resource. + The url is relative to the "resources" folder, extensions must be omitted. + @param type Only asset of type will be loaded if this argument is supplied. + @param progressCallback Callback invoked when progression change. + @param completeCallback A callback which is called when all assets have been loaded, or an error occurs. + */ + static loadResArray(url: string[], type: typeof cc.Asset, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any[]) => void)|null): void; + static loadResArray(url: string[], type: typeof cc.Asset, completeCallback: (error: Error, resource: any[]) => void): void; + static loadResArray(url: string[], type: typeof cc.Asset): void; + static loadResArray(url: string[], progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any[]) => void)|null): void; + static loadResArray(url: string[], completeCallback: (error: Error, resource: any[]) => void): void; + static loadResArray(url: string[]): void; + static loadResArray(url: string[], type: typeof cc.Asset[]): void; + /** + `cc.loader.loadResDir` is deprecated, please use {{#crossLink "Bundle/loadDir:method"}}{{/crossLink}} instead + @param url Url of the target folder. + The url is relative to the "resources" folder, extensions must be omitted. + @param type Only asset of type will be loaded if this argument is supplied. + @param progressCallback Callback invoked when progression change. + @param completeCallback A callback which is called when all assets have been loaded, or an error occurs. + */ + static loadResDir(url: string, type: typeof cc.Asset, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any[], urls: string[]) => void)|null): void; + static loadResDir(url: string, type: typeof cc.Asset, completeCallback: (error: Error, resource: any[], urls: string[]) => void): void; + static loadResDir(url: string, type: typeof cc.Asset): void; + static loadResDir(url: string, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any[], urls: string[]) => void)|null): void; + static loadResDir(url: string, completeCallback: (error: Error, resource: any[], urls: string[]) => void): void; + static loadResDir(url: string): void; + /** + `cc.loader.getRes` is deprecated, please use {{#crossLink "Bundle/get:method"}}{{/crossLink}} instead + @param url url + @param type Only asset of type will be returned if this argument is supplied. + */ + static getRes(url: string, type?: Function): any; + /** + `cc.loader.getDependsRecursively` is deprecated, please use use {{#crossLink "DependUtil/getDepsRecursively:method"}}{{/crossLink}} instead + @param owner The owner asset or the resource url or the asset's uuid + */ + static getDependsRecursively(owner: Asset|string): any[]; + /** `cc.loader.assetLoader` was removed, assetLoader and md5Pipe were merged into {{#crossLink "AssetManager/transformPipeline:property"}}{{/crossLink}} */ + static assetLoader: any; + /** `cc.loader.md5Pipe` is deprecated, assetLoader and md5Pipe were merged into {{#crossLink "AssetManager/transformPipeline:property"}}{{/crossLink}} */ + static md5Pipe: any; + /** `cc.loader.downloader` is deprecated, please use {{#crossLink "AssetManager/downloader:property"}}{{/crossLink}} instead */ + static downloader: any; + /** `cc.loader.loader` is deprecated, please use {{#crossLink "AssetManager/parser:property"}}{{/crossLink}} instead */ + static loader: any; + /** + `cc.loader.addDownloadHandlers` is deprecated, please use `cc.assetManager.downloader.register` instead + @param extMap Custom supported types with corresponded handler + */ + static addDownloadHandlers(extMap: any): void; + /** + `cc.loader.addLoadHandlers` is deprecated, please use `cc.assetManager.parser.register` instead + @param extMap Custom supported types with corresponded handler + */ + static addLoadHandlers(extMap: any): void; + /** + `cc.loader.release` is deprecated, please use {{#crossLink "AssetManager/releaseAsset:method"}}{{/crossLink}} instead + @param asset asset + */ + static release(asset: Asset|string|any[]): void; + /** + `cc.loader.releaseAsset` is deprecated, please use {{#crossLink "AssetManager/releaseAsset:method"}}{{/crossLink}} instead + @param asset asset + */ + static releaseAsset(asset: Asset): void; + /** + `cc.loader.releaseRes` is deprecated, please use {{#crossLink "AssetManager/releaseRes:method"}}{{/crossLink}} instead + @param url url + @param type Only asset of type will be released if this argument is supplied. + */ + static releaseRes(url: string, type?: Function): void; + /** + `cc.loader.releaseResDir` was removed, please use {{#crossLink "AssetManager/releaseRes:method"}}{{/crossLink}} instead + */ + static releaseResDir(): void; + /** + `cc.loader.releaseAll` is deprecated, please use {{#crossLink "AssetManager/releaseAll:method"}}{{/crossLink}} instead + */ + static releaseAll(): void; + /** + `cc.loader.removeItem` is deprecated, please use `cc.assetManager.assets.remove` instead + @param id The id of the item + */ + static removeItem(id: any): boolean; + /** + `cc.loader.setAutoRelease` is deprecated, if you want to prevent some asset from auto releasing, please use {{#crossLink "Asset/addRef:method"}}{{/crossLink}} instead + @param assetOrUrlOrUuid asset object or the raw asset's url or uuid + @param autoRelease indicates whether should release automatically + */ + static setAutoRelease(assetOrUrlOrUuid: Asset|string, autoRelease: boolean): void; + /** + `cc.loader.setAutoReleaseRecursively` is deprecated, if you want to prevent some asset from auto releasing, please use {{#crossLink "Asset/addRef:method"}}{{/crossLink}} instead + @param assetOrUrlOrUuid asset object or the raw asset's url or uuid + @param autoRelease indicates whether should release automatically + */ + static setAutoReleaseRecursively(assetOrUrlOrUuid: Asset|string, autoRelease: boolean): void; + /** + `cc.loader.isAutoRelease` is deprecated + @param assetOrUrl asset object or the raw asset's url + */ + static isAutoRelease(assetOrUrl: Asset|string): boolean; + } + /** `cc.url` is deprecated */ + export class url { + /** + `cc.url.raw` is deprecated, please use `cc.resources.load` directly, or use `Asset.nativeUrl` instead. + @param url url + */ + static raw(url: string): string; + } + /** `cc.LoadingItems` was removed, please use {{#crossLink "Task"}}{{/crossLink}} instead */ + export class LoadingItems { + } + /** !#en + Base class for handling assets used in Creator.
+ + You may want to override:
+ - createNode
+ - getset functions of _nativeAsset
+ - cc.Object._serialize
+ - cc.Object._deserialize
+ !#zh + Creator 中的资源基类。
+ + 您可能需要重写:
+ - createNode
+ - _nativeAsset 的 getset 方法
+ - cc.Object._serialize
+ - cc.Object._deserialize
*/ + export class Asset extends Object { + /** `cc.Asset.url` is deprecated, please use {{#crossLink "Asset/nativeUrl:property"}}{{/crossLink}} instead */ + url: string; + /** !#en + Whether the asset is loaded or not. + !#zh + 该资源是否已经成功加载。 */ + loaded: boolean; + /** !#en + Returns the url of this asset's native object, if none it will returns an empty string. + !#zh + 返回该资源对应的目标平台资源的 URL,如果没有将返回一个空字符串。 */ + nativeUrl: string; + /** !#en + The number of reference + + !#zh + 引用的数量 */ + refCount: number; + /** !#en Indicates whether its dependent raw assets can support deferred load if the owner scene (or prefab) is marked as `asyncLoadAssets`. + !#zh 当场景或 Prefab 被标记为 `asyncLoadAssets`,禁止延迟加载该资源所依赖的其它原始资源。 */ + static preventDeferredLoadDependents: boolean; + /** !#en Indicates whether its native object should be preloaded from native url. + !#zh 禁止预加载原生对象。 */ + static preventPreloadNativeObject: boolean; + /** + !#en + Returns the asset's url. + + The `Asset` object overrides the `toString()` method of the `Object` object. + For `Asset` objects, the `toString()` method returns a string representation of the object. + JavaScript calls the `toString()` method automatically when an asset is to be represented as a text value or when a texture is referred to in a string concatenation. + !#zh + 返回资源的 URL。 + + Asset 对象将会重写 Object 对象的 `toString()` 方法。 + 对于 Asset 对象,`toString()` 方法返回该对象的字符串表示形式。 + 当资源要表示为文本值时或在字符串连接时引用时,JavaScript 会自动调用 `toString()` 方法。 + */ + toString(): string; + /** + !#en + Create a new node using this asset in the scene.
+ If this type of asset dont have its corresponding node type, this method should be null. + !#zh + 使用该资源在场景中创建一个新节点。
+ 如果这类资源没有相应的节点类型,该方法应该是空的。 + @param callback callback + */ + createNode(callback: (error: string, node: any) => void): void; + /** + !#en + Add references of asset + + !#zh + 增加资源的引用 + */ + addRef(): cc.Asset; + /** + !#en + Reduce references of asset and it will be auto released when refCount equals 0. + + !#zh + 减少资源的引用并尝试进行自动释放。 + */ + decRef(): cc.Asset; + } + /** Predefined constants */ + export class macro { + /** `cc.macro.DOWNLOAD_MAX_CONCURRENT` is deprecated now, please use {{#crossLink "Downloader/maxConcurrency:property"}}{{/crossLink}} instead */ + static DOWNLOAD_MAX_CONCURRENT: number; + /** PI / 180 */ + static RAD: number; + /** One degree */ + static DEG: number; + static REPEAT_FOREVER: number; + static FLT_EPSILON: number; + /** Minimum z index value for node */ + static MIN_ZINDEX: number; + /** Maximum z index value for node */ + static MAX_ZINDEX: number; + static ONE: number; + static ZERO: number; + static SRC_ALPHA: number; + static SRC_ALPHA_SATURATE: number; + static SRC_COLOR: number; + static DST_ALPHA: number; + static DST_COLOR: number; + static ONE_MINUS_SRC_ALPHA: number; + static ONE_MINUS_SRC_COLOR: number; + static ONE_MINUS_DST_ALPHA: number; + static ONE_MINUS_DST_COLOR: number; + static ONE_MINUS_CONSTANT_ALPHA: number; + static ONE_MINUS_CONSTANT_COLOR: number; + /** Oriented vertically */ + static ORIENTATION_PORTRAIT: number; + /** Oriented horizontally */ + static ORIENTATION_LANDSCAPE: number; + /** Oriented automatically */ + static ORIENTATION_AUTO: number; + /**

+ If enabled, the texture coordinates will be calculated by using this formula:
+ - texCoord.left = (rect.x*2+1) / (texture.wide*2);
+ - texCoord.right = texCoord.left + (rect.width*2-2)/(texture.wide*2);
+
+ The same for bottom and top.
+
+ This formula prevents artifacts by using 99% of the texture.
+ The "correct" way to prevent artifacts is by expand the texture's border with the same color by 1 pixel
+
+ Affected component:
+ - cc.TMXLayer
+
+ Enabled by default. To disabled set it to 0.
+ To modify it, in Web engine please refer to CCMacro.js, in JSB please refer to CCConfig.h +

*/ + static FIX_ARTIFACTS_BY_STRECHING_TEXEL_TMX: number; + /** Position of the FPS (Default: 0,0 (bottom-left corner))
+ To modify it, in Web engine please refer to CCMacro.js, in JSB please refer to CCConfig.h */ + static DIRECTOR_STATS_POSITION: Vec2; + /**

+ If enabled, actions that alter the position property (eg: CCMoveBy, CCJumpBy, CCBezierBy, etc..) will be stacked.
+ If you run 2 or more 'position' actions at the same time on a node, then end position will be the sum of all the positions.
+ If disabled, only the last run action will take effect. +

*/ + static ENABLE_STACKABLE_ACTIONS: number; + /** !#en + The timeout to determine whether a touch is no longer active and should be removed. + The reason to add this timeout is due to an issue in X5 browser core, + when X5 is presented in wechat on Android, if a touch is glissed from the bottom up, and leave the page area, + no touch cancel event is triggered, and the touch will be considered active forever. + After multiple times of this action, our maximum touches number will be reached and all new touches will be ignored. + So this new mechanism can remove the touch that should be inactive if it's not updated during the last 5000 milliseconds. + Though it might remove a real touch if it's just not moving for the last 5 seconds which is not easy with the sensibility of mobile touch screen. + You can modify this value to have a better behavior if you find it's not enough. + !#zh + 用于甄别一个触点对象是否已经失效并且可以被移除的延时时长 + 添加这个时长的原因是 X5 内核在微信浏览器中出现的一个 bug。 + 在这个环境下,如果用户将一个触点从底向上移出页面区域,将不会触发任何 touch cancel 或 touch end 事件,而这个触点会被永远当作停留在页面上的有效触点。 + 重复这样操作几次之后,屏幕上的触点数量将达到我们的事件系统所支持的最高触点数量,之后所有的触摸事件都将被忽略。 + 所以这个新的机制可以在触点在一定时间内没有任何更新的情况下视为失效触点并从事件系统中移除。 + 当然,这也可能移除一个真实的触点,如果用户的触点真的在一定时间段内完全没有移动(这在当前手机屏幕的灵敏度下会很难)。 + 你可以修改这个值来获得你需要的效果,默认值是 5000 毫秒。 */ + static TOUCH_TIMEOUT: number; + /** !#en + The maximum vertex count for a single batched draw call. + !#zh + 最大可以被单次批处理渲染的顶点数量。 */ + static BATCH_VERTEX_COUNT: number; + /** !#en + Whether or not enabled tiled map auto culling. If you set the TiledMap skew or rotation, then need to manually disable this, otherwise, the rendering will be wrong. + !#zh + 是否开启瓦片地图的自动裁减功能。瓦片地图如果设置了 skew, rotation 或者采用了摄像机的话,需要手动关闭,否则渲染会出错。 */ + static ENABLE_TILEDMAP_CULLING: boolean; + /** !#en + Boolean that indicates if the canvas contains an alpha channel, default sets to false for better performance. + Though if you want to make your canvas background transparent and show other dom elements at the background, + you can set it to true before `cc.game.run`. + Web only. + !#zh + 用于设置 Canvas 背景是否支持 alpha 通道,默认为 false,这样可以有更高的性能表现。 + 如果你希望 Canvas 背景是透明的,并显示背后的其他 DOM 元素,你可以在 `cc.game.run` 之前将这个值设为 true。 + 仅支持 Web */ + static ENABLE_TRANSPARENT_CANVAS: boolean; + /** !#en + Boolean that indicates if the WebGL context is created with `antialias` option turned on, default value is false. + Set it to true could make your game graphics slightly smoother, like texture hard edges when rotated. + Whether to use this really depend on your game design and targeted platform, + device with retina display usually have good detail on graphics with or without this option, + you probably don't want antialias if your game style is pixel art based. + Also, it could have great performance impact with some browser / device using software MSAA. + You can set it to true before `cc.game.run`. + Web only. + !#zh + 用于设置在创建 WebGL Context 时是否开启抗锯齿选项,默认值是 false。 + 将这个选项设置为 true 会让你的游戏画面稍稍平滑一些,比如旋转硬边贴图时的锯齿。是否开启这个选项很大程度上取决于你的游戏和面向的平台。 + 在大多数拥有 retina 级别屏幕的设备上用户往往无法区分这个选项带来的变化;如果你的游戏选择像素艺术风格,你也多半不会想开启这个选项。 + 同时,在少部分使用软件级别抗锯齿算法的设备或浏览器上,这个选项会对性能产生比较大的影响。 + 你可以在 `cc.game.run` 之前设置这个值,否则它不会生效。 + 仅支持 Web */ + static ENABLE_WEBGL_ANTIALIAS: boolean; + /** !#en + Whether or not enable auto culling. + This feature have been removed in v2.0 new renderer due to overall performance consumption. + We have no plan currently to re-enable auto culling. + If your game have more dynamic objects, we suggest to disable auto culling. + If your game have more static objects, we suggest to enable auto culling. + !#zh + 是否开启自动裁减功能,开启裁减功能将会把在屏幕外的物体从渲染队列中去除掉。 + 这个功能在 v2.0 的新渲染器中被移除了,因为它在大多数游戏中所带来的损耗要高于性能的提升,目前我们没有计划重新支持自动裁剪。 + 如果游戏中的动态物体比较多的话,建议将此选项关闭。 + 如果游戏中的静态物体比较多的话,建议将此选项打开。 */ + static ENABLE_CULLING: boolean; + /** !#en + Whether to clear the original image cache after uploaded a texture to GPU. If cleared, [Dynamic Atlas](https://docs.cocos.com/creator/manual/en/advanced-topics/dynamic-atlas.html) will not be supported. + Normally you don't need to enable this option on the web platform, because Image object doesn't consume too much memory. + But on WeChat Game platform, the current version cache decoded data in Image object, which has high memory usage. + So we enabled this option by default on WeChat, so that we can release Image cache immediately after uploaded to GPU. + !#zh + 是否在将贴图上传至 GPU 之后删除原始图片缓存,删除之后图片将无法进行 [动态合图](https://docs.cocos.com/creator/manual/zh/advanced-topics/dynamic-atlas.html)。 + 在 Web 平台,你通常不需要开启这个选项,因为在 Web 平台 Image 对象所占用的内存很小。 + 但是在微信小游戏平台的当前版本,Image 对象会缓存解码后的图片数据,它所占用的内存空间很大。 + 所以我们在微信平台默认开启了这个选项,这样我们就可以在上传 GL 贴图之后立即释放 Image 对象的内存,避免过高的内存占用。 */ + static CLEANUP_IMAGE_CACHE: boolean; + /** !#en + Whether or not show mesh wire frame. + !#zh + 是否显示网格的线框。 */ + static SHOW_MESH_WIREFRAME: boolean; + /** !#en + Whether or not show mesh normal. + !#zh + 是否显示网格的法线。 */ + static SHOW_MESH_NORMAL: boolean; + /** !#en + Whether to enable multi-touch. + !#zh + 是否开启多点触摸 */ + static ENABLE_MULTI_TOUCH: boolean; + /** References: + https://developer.mozilla.org/en-US/docs/Web/API/ImageBitmap + https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/createImageBitmap + + !#en + Whether to use image bitmap first. If enabled, memory usage will increase. + + !#zh + 是否优先使用 image bitmap,启用之后,内存占用会变高 */ + static ALLOW_IMAGE_BITMAP: boolean; + /** !#en + The image format supported by the engine defaults, and the supported formats may differ in different build platforms and device types. + Currently all platform and device support ['.webp', '.jpg', '.jpeg', '.bmp', '.png'], The iOS mobile platform also supports the PVR format。 + !#zh + 引擎默认支持的图片格式,支持的格式可能在不同的构建平台和设备类型上有所差别。 + 目前所有平台和设备支持的格式有 ['.webp', '.jpg', '.jpeg', '.bmp', '.png']. 另外 Ios 手机平台还额外支持了 PVR 格式。 */ + static SUPPORT_TEXTURE_FORMATS: string[]; + } + /** !#en Box Collider. + !#zh 包围盒碰撞组件 */ + export class BoxCollider extends Collider implements Collider.Box { + /** !#en + Collider info in world coordinate. + !#zh + 碰撞体的世界坐标系下的信息。 */ + world: ColliderInfo; + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Box size + !#zh 包围盒大小 */ + size: Size; + } + /** !#en Circle Collider. + !#zh 圆形碰撞组件 */ + export class CircleCollider extends Collider implements Collider.Circle { + /** !#en + Collider info in world coordinate. + !#zh + 碰撞体的世界坐标系下的信息。 */ + world: ColliderInfo; + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Circle radius + !#zh 圆形半径 */ + radius: number; + } + /** !#en Collider component base class. + !#zh 碰撞组件基类 */ + export class Collider extends Component { + /** !#en Tag. If a node has several collider components, you can judge which type of collider is collided according to the tag. + !#zh 标签。当一个节点上有多个碰撞组件时,在发生碰撞后,可以使用此标签来判断是节点上的哪个碰撞组件被碰撞了。 */ + tag: number; + } + /** !#en + Collider Info. + !#zh + 碰撞体信息。 */ + export class ColliderInfo { + /** !#en + Collider aabb information of last frame + !#zh + 碰撞体上一帧的 aabb 信息 */ + preAabb: Rect; + /** !#en + Collider aabb information of current frame + !#zh + 碰撞体当前帧的 aabb 信息 */ + aabb: Rect; + /** !#en + Collider matrix + !#zh + 碰撞体的矩阵信息 */ + matrix: Mat4; + /** !#en + Collider radius (for CircleCollider) + !#zh + 碰撞体的半径(只对 CircleCollider 有效) */ + radius: number; + /** !#en + Collider position (for CircleCollider) + !#zh + 碰撞体的位置(只对 CircleCollider 有效) */ + position: Vec2; + /** !#en + Collider points (for BoxCollider and PolygonCollider) + !#zh + 碰撞体的顶点信息(只对 BoxCollider 和 PolygonCollider 有效) */ + points: Vec2[]; + } + /** !#en + A simple collision manager class. + It will calculate whether the collider collides other colliders, if collides then call the callbacks. + !#zh + 一个简单的碰撞组件管理类,用于处理节点之间的碰撞组件是否产生了碰撞,并调用相应回调函数。 */ + export class CollisionManager implements EventTarget { + /** !#en + !#zh + 是否开启碰撞管理,默认为不开启 */ + enabled: boolean; + /** !#en + !#zh + 是否绘制碰撞组件的包围盒,默认为不绘制 */ + enabledDrawBoundingBox: boolean; + /** !#en + !#zh + 是否绘制碰撞组件的形状,默认为不绘制 */ + enabledDebugDraw: boolean; + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en + Register an callback of a specific event type on the EventTarget. + This type of event should be triggered via `emit`. + !#zh + 注册事件目标的特定事件类型回调。这种类型的事件应该被 `emit` 触发。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, node); + ``` + */ + on(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. + !#zh + 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + + @example + ```js + // register fire eventListener + var callback = eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, target); + // remove fire event listener + eventTarget.off('fire', callback, target); + // remove all fire event listeners + eventTarget.off('fire'); + ``` + */ + off(type: string, callback?: Function, target?: any): void; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.once('fire', function () { + cc.log("this is the callback and will be invoked only once"); + }, node); + ``` + */ + once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; + /** + !#en + Send an event with the event object. + !#zh + 通过事件对象派发事件 + @param event event + */ + dispatchEvent(event: Event): void; + } + /** !#en Intersection helper class + !#zh 辅助类,用于测试形状与形状是否相交 */ + export class Intersection { + /** + !#en Test line and line + !#zh 测试线段与线段是否相交 + @param a1 The start point of the first line + @param a2 The end point of the first line + @param b1 The start point of the second line + @param b2 The end point of the second line + */ + static lineLine(a1: Vec2, a2: Vec2, b1: Vec2, b2: Vec2): boolean; + /** + !#en Test line and rect + !#zh 测试线段与矩形是否相交 + @param a1 The start point of the line + @param a2 The end point of the line + @param b The rect + */ + static lineRect(a1: Vec2, a2: Vec2, b: Rect): boolean; + /** + !#en Test line and polygon + !#zh 测试线段与多边形是否相交 + @param a1 The start point of the line + @param a2 The end point of the line + @param b The polygon, a set of points + */ + static linePolygon(a1: Vec2, a2: Vec2, b: Vec2[]): boolean; + /** + !#en Test rect and rect + !#zh 测试矩形与矩形是否相交 + @param a The first rect + @param b The second rect + */ + static rectRect(a: Rect, b: Rect): boolean; + /** + !#en Test rect and polygon + !#zh 测试矩形与多边形是否相交 + @param a The rect + @param b The polygon, a set of points + */ + static rectPolygon(a: Rect, b: Vec2[]): boolean; + /** + !#en Test polygon and polygon + !#zh 测试多边形与多边形是否相交 + @param a The first polygon, a set of points + @param b The second polygon, a set of points + */ + static polygonPolygon(a: Vec2[], b: Vec2[]): boolean; + /** + !#en Test circle and circle + !#zh 测试圆形与圆形是否相交 + @param a Object contains position and radius + @param b Object contains position and radius + */ + static circleCircle(a: {position: Vec2, radius: number}, b: {position: Vec2, radius: number}): boolean; + /** + !#en Test polygon and circle + !#zh 测试矩形与圆形是否相交 + @param polygon The Polygon, a set of points + @param circle Object contains position and radius + */ + static polygonCircle(polygon: Vec2[], circle: {position: Vec2, radius: number}): boolean; + /** + !#en Test whether the point is in the polygon + !#zh 测试一个点是否在一个多边形中 + @param point The point + @param polygon The polygon, a set of points + */ + static pointInPolygon(point: Vec2, polygon: Vec2[]): boolean; + /** + !#en Calculate the distance of point to line. + !#zh 计算点到直线的距离。如果这是一条线段并且垂足不在线段内,则会计算点到线段端点的距离。 + @param point The point + @param start The start point of line + @param end The end point of line + @param isSegment whether this line is a segment + */ + static pointLineDistance(point: Vec2, start: Vec2, end: Vec2, isSegment: boolean): number; + } + /** !#en Polygon Collider. + !#zh 多边形碰撞组件 */ + export class PolygonCollider extends Collider implements Collider.Polygon { + /** !#en + Collider info in world coordinate. + !#zh + 碰撞体的世界坐标系下的信息。 */ + world: ColliderInfo; + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Polygon points + !#zh 多边形顶点数组 */ + points: Vec2[]; + } + /** !#en The animation component is used to play back animations. + + Animation provide several events to register: + - play : Emit when begin playing animation + - stop : Emit when stop playing animation + - pause : Emit when pause animation + - resume : Emit when resume animation + - lastframe : If animation repeat count is larger than 1, emit when animation play to the last frame + - finished : Emit when finish playing animation + + !#zh Animation 组件用于播放动画。 + + Animation 提供了一系列可注册的事件: + - play : 开始播放时 + - stop : 停止播放时 + - pause : 暂停播放时 + - resume : 恢复播放时 + - lastframe : 假如动画循环次数大于 1,当动画播放到最后一帧时 + - finished : 动画播放完成时 */ + export class Animation extends Component implements EventTarget { + /** !#en Animation will play the default clip when start game. + !#zh 在勾选自动播放或调用 play() 时默认播放的动画剪辑。 */ + defaultClip: AnimationClip; + /** !#en Current played clip. + !#zh 当前播放的动画剪辑。 */ + currentClip: AnimationClip; + /** !#en Whether the animation should auto play the default clip when start game. + !#zh 是否在运行游戏后自动播放默认动画剪辑。 */ + playOnLoad: boolean; + /** + !#en Get all the clips used in this animation. + !#zh 获取动画组件上的所有动画剪辑。 + */ + getClips(): AnimationClip[]; + /** + !#en Plays an animation and stop other animations. + !#zh 播放指定的动画,并且停止当前正在播放动画。如果没有指定动画,则播放默认动画。 + @param name The name of animation to play. If no name is supplied then the default animation will be played. + @param startTime play an animation from startTime + + @example + ```js + var animCtrl = this.node.getComponent(cc.Animation); + animCtrl.play("linear"); + ``` + */ + play(name?: string, startTime?: number): AnimationState; + /** + !#en + Plays an additive animation, it will not stop other animations. + If there are other animations playing, then will play several animations at the same time. + !#zh 播放指定的动画(将不会停止当前播放的动画)。如果没有指定动画,则播放默认动画。 + @param name The name of animation to play. If no name is supplied then the default animation will be played. + @param startTime play an animation from startTime + + @example + ```js + // linear_1 and linear_2 at the same time playing. + var animCtrl = this.node.getComponent(cc.Animation); + animCtrl.playAdditive("linear_1"); + animCtrl.playAdditive("linear_2"); + ``` + */ + playAdditive(name?: string, startTime?: number): AnimationState; + /** + !#en Stops an animation named name. If no name is supplied then stops all playing animations that were started with this Animation.
+ Stopping an animation also Rewinds it to the Start. + !#zh 停止指定的动画。如果没有指定名字,则停止当前正在播放的动画。 + @param name The animation to stop, if not supplied then stops all playing animations. + */ + stop(name?: string): void; + /** + !#en Pauses an animation named name. If no name is supplied then pauses all playing animations that were started with this Animation. + !#zh 暂停当前或者指定的动画。如果没有指定名字,则暂停当前正在播放的动画。 + @param name The animation to pauses, if not supplied then pauses all playing animations. + */ + pause(name?: string): void; + /** + !#en Resumes an animation named name. If no name is supplied then resumes all paused animations that were started with this Animation. + !#zh 重新播放指定的动画,如果没有指定名字,则重新播放当前正在播放的动画。 + @param name The animation to resumes, if not supplied then resumes all paused animations. + */ + resume(name?: string): void; + /** + !#en Make an animation named name go to the specified time. If no name is supplied then make all animations go to the specified time. + !#zh 设置指定动画的播放时间。如果没有指定名字,则设置当前播放动画的播放时间。 + @param time The time to go to + @param name Specified animation name, if not supplied then make all animations go to the time. + */ + setCurrentTime(time?: number, name?: string): void; + /** + !#en Returns the animation state named name. If no animation with the specified name, the function will return null. + !#zh 获取当前或者指定的动画状态,如果未找到指定动画剪辑则返回 null。 + @param name name + */ + getAnimationState(name: string): AnimationState; + /** + !#en Adds a clip to the animation with name newName. If a clip with that name already exists it will be replaced with the new clip. + !#zh 添加动画剪辑,并且可以重新设置该动画剪辑的名称。 + @param clip the clip to add + @param newName newName + */ + addClip(clip: AnimationClip, newName?: string): AnimationState; + /** + !#en + Remove clip from the animation list. This will remove the clip and any animation states based on it. + If there are animation states depand on the clip are playing or clip is defaultClip, it will not delete the clip. + But if force is true, then will always remove the clip and any animation states based on it. If clip is defaultClip, defaultClip will be reset to null + !#zh + 从动画列表中移除指定的动画剪辑,
+ 如果依赖于 clip 的 AnimationState 正在播放或者 clip 是 defaultClip 的话,默认是不会删除 clip 的。 + 但是如果 force 参数为 true,则会强制停止该动画,然后移除该动画剪辑和相关的动画。这时候如果 clip 是 defaultClip,defaultClip 将会被重置为 null。 + @param clip clip + @param force If force is true, then will always remove the clip and any animation states based on it. + */ + removeClip(clip: AnimationClip, force?: boolean): void; + /** + !#en + Samples animations at the current state.
+ This is useful when you explicitly want to set up some animation state, and sample it once. + !#zh 对指定或当前动画进行采样。你可以手动将动画设置到某一个状态,然后采样一次。 + @param name name + */ + sample(name: string): void; + /** + !#en + Register animation event callback. + The event arguments will provide the AnimationState which emit the event. + When play an animation, will auto register the event callback to the AnimationState, and unregister the event callback from the AnimationState when animation stopped. + !#zh + 注册动画事件回调。 + 回调的事件里将会附上发送事件的 AnimationState。 + 当播放一个动画时,会自动将事件注册到对应的 AnimationState 上,停止播放时会将事件从这个 AnimationState 上取消注册。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param state state + @param target The target (this object) to invoke the callback, can be null + @param useCapture When set to true, the capture argument prevents callback + from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. + When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE. + Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET. + + @example + ```js + onPlay: function (type, state) { + // callback + } + + // register event to all animation + animation.on('play', this.onPlay, this); + ``` + */ + on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void; + on(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void; + on(type: string, callback: (type: string, state: cc.AnimationState) => void, target?: any, useCapture?: boolean): (type: string, state: cc.AnimationState) => void; + /** + !#en + Unregister animation event callback. + !#zh + 取消注册动画事件回调。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not. + If not specified, useCapture defaults to false. If a callback was registered twice, + one with capture and one without, each must be removed separately. Removal of a capturing callback + does not affect a non-capturing version of the same listener, and vice versa. + + @example + ```js + // unregister event to all animation + animation.off('play', this.onPlay, this); + ``` + */ + off(type: string, callback?: Function, target?: any, useCapture?: boolean): void; + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.once('fire', function () { + cc.log("this is the callback and will be invoked only once"); + }, node); + ``` + */ + once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; + /** + !#en + Send an event with the event object. + !#zh + 通过事件对象派发事件 + @param event event + */ + dispatchEvent(event: Event): void; + } + /** !#en Audio Source. + !#zh 音频源组件,能对音频剪辑。 */ + export class AudioSource extends Component { + /** !#en + Is the audio source playing (Read Only).
+ Note: isPlaying is not supported for Native platforms. + !#zh + 该音频剪辑是否正播放(只读)。
+ 注意:Native 平台暂时不支持 isPlaying。 */ + isPlaying: boolean; + /** !#en The clip of the audio source to play. + !#zh 要播放的音频剪辑。 */ + clip: AudioClip; + /** !#en The volume of the audio source. + !#zh 音频源的音量(0.0 ~ 1.0)。 */ + volume: number; + /** !#en Is the audio source mute? + !#zh 是否静音音频源。Mute 是设置音量为 0,取消静音是恢复原来的音量。 */ + mute: boolean; + /** !#en Is the audio source looping? + !#zh 音频源是否循环播放? */ + loop: boolean; + /** !#en If set to true, the audio source will automatically start playing on onEnable. + !#zh 如果设置为 true,音频源将在 onEnable 时自动播放。 */ + playOnLoad: boolean; + /** + !#en Plays the clip. + !#zh 播放音频剪辑。 + */ + play(): void; + /** + !#en Stops the clip. + !#zh 停止当前音频剪辑。 + */ + stop(): void; + /** + !#en Pause the clip. + !#zh 暂停当前音频剪辑。 + */ + pause(): void; + /** + !#en Resume the clip. + !#zh 恢复播放。 + */ + resume(): void; + /** + !#en Rewind playing music. + !#zh 从头开始播放。 + */ + rewind(): void; + /** + !#en Get current time + !#zh 获取当前的播放时间 + */ + getCurrentTime(): number; + /** + !#en Set current time + !#zh 设置当前的播放时间 + @param time time + */ + setCurrentTime(time: number): number; + /** + !#en Get audio duration + !#zh 获取当前音频的长度 + */ + getDuration(): number; + } + /** !#en + This component will block all input events (mouse and touch) within the bounding box of the node, preventing the input from penetrating into the underlying node, typically for the background of the top UI.
+ This component does not have any API interface and can be added directly to the scene to take effect. + !#zh + 该组件将拦截所属节点 bounding box 内的所有输入事件(鼠标和触摸),防止输入穿透到下层节点,一般用于上层 UI 的背景。
+ 该组件没有任何 API 接口,直接添加到场景即可生效。 */ + export class BlockInputEvents extends Component { + } + /** !#en + Button has 4 Transition types
+ When Button state changed:
+ If Transition type is Button.Transition.NONE, Button will do nothing
+ If Transition type is Button.Transition.COLOR, Button will change target's color
+ If Transition type is Button.Transition.SPRITE, Button will change target Sprite's sprite
+ If Transition type is Button.Transition.SCALE, Button will change target node's scale
+ + Button will trigger 5 events:
+ Button.EVENT_TOUCH_DOWN
+ Button.EVENT_TOUCH_UP
+ Button.EVENT_HOVER_IN
+ Button.EVENT_HOVER_MOVE
+ Button.EVENT_HOVER_OUT
+ User can get the current clicked node with 'event.target' from event object which is passed as parameter in the callback function of click event. + + !#zh + 按钮组件。可以被按下,或者点击。 + + 按钮可以通过修改 Transition 来设置按钮状态过渡的方式: + + - Button.Transition.NONE // 不做任何过渡 + - Button.Transition.COLOR // 进行颜色之间过渡 + - Button.Transition.SPRITE // 进行精灵之间过渡 + - Button.Transition.SCALE // 进行缩放过渡 + + 按钮可以绑定事件(但是必须要在按钮的 Node 上才能绑定事件):
+ 以下事件可以在全平台上都触发: + + - cc.Node.EventType.TOUCH_START // 按下时事件 + - cc.Node.EventType.TOUCH_Move // 按住移动后事件 + - cc.Node.EventType.TOUCH_END // 按下后松开后事件 + - cc.Node.EventType.TOUCH_CANCEL // 按下取消事件 + + 以下事件只在 PC 平台上触发: + + - cc.Node.EventType.MOUSE_DOWN // 鼠标按下时事件 + - cc.Node.EventType.MOUSE_MOVE // 鼠标按住移动后事件 + - cc.Node.EventType.MOUSE_ENTER // 鼠标进入目标事件 + - cc.Node.EventType.MOUSE_LEAVE // 鼠标离开目标事件 + - cc.Node.EventType.MOUSE_UP // 鼠标松开事件 + - cc.Node.EventType.MOUSE_WHEEL // 鼠标滚轮事件 + + 用户可以通过获取 __点击事件__ 回调函数的参数 event 的 target 属性获取当前点击对象。 */ + export class Button extends Component implements GraySpriteState { + /** !#en + Whether the Button is disabled. + If true, the Button will trigger event and do transition. + !#zh + 按钮事件是否被响应,如果为 false,则按钮将被禁用。 */ + interactable: boolean; + /** !#en When this flag is true, Button target sprite will turn gray when interactable is false. + !#zh 如果这个标记为 true,当 button 的 interactable 属性为 false 的时候,会使用内置 shader 让 button 的 target 节点的 sprite 组件变灰 */ + enableAutoGrayEffect: boolean; + /** !#en Transition type + !#zh 按钮状态改变时过渡方式。 */ + transition: Button.Transition; + /** !#en Normal state color. + !#zh 普通状态下按钮所显示的颜色。 */ + normalColor: Color; + /** !#en Pressed state color + !#zh 按下状态时按钮所显示的颜色。 */ + pressedColor: Color; + /** !#en Hover state color + !#zh 悬停状态下按钮所显示的颜色。 */ + hoverColor: Color; + /** !#en Disabled state color + !#zh 禁用状态下按钮所显示的颜色。 */ + disabledColor: Color; + /** !#en Color and Scale transition duration + !#zh 颜色过渡和缩放过渡时所需时间 */ + duration: number; + /** !#en When user press the button, the button will zoom to a scale. + The final scale of the button equals (button original scale * zoomScale) + !#zh 当用户点击按钮后,按钮会缩放到一个值,这个值等于 Button 原始 scale * zoomScale */ + zoomScale: number; + /** !#en Normal state sprite + !#zh 普通状态下按钮所显示的 Sprite 。 */ + normalSprite: SpriteFrame; + /** !#en Pressed state sprite + !#zh 按下状态时按钮所显示的 Sprite 。 */ + pressedSprite: SpriteFrame; + /** !#en Hover state sprite + !#zh 悬停状态下按钮所显示的 Sprite 。 */ + hoverSprite: SpriteFrame; + /** !#en Disabled state sprite + !#zh 禁用状态下按钮所显示的 Sprite 。 */ + disabledSprite: SpriteFrame; + /** !#en + Transition target. + When Button state changed: + If Transition type is Button.Transition.NONE, Button will do nothing + If Transition type is Button.Transition.COLOR, Button will change target's color + If Transition type is Button.Transition.SPRITE, Button will change target Sprite's sprite + !#zh + 需要过渡的目标。 + 当前按钮状态改变规则: + -如果 Transition type 选择 Button.Transition.NONE,按钮不做任何过渡。 + -如果 Transition type 选择 Button.Transition.COLOR,按钮会对目标颜色进行颜色之间的过渡。 + -如果 Transition type 选择 Button.Transition.Sprite,按钮会对目标 Sprite 进行 Sprite 之间的过渡。 */ + target: Node; + /** !#en If Button is clicked, it will trigger event's handler + !#zh 按钮的点击事件列表。 */ + clickEvents: Component.EventHandler[]; + /** !#en The normal material. + !#zh 正常状态的材质。 */ + normalMaterial: Material; + /** !#en The gray material. + !#zh 置灰状态的材质。 */ + grayMaterial: Material; + } + /** !#zh: 作为 UI 根节点,为所有子节点提供视窗四边的位置信息以供对齐,另外提供屏幕适配策略接口,方便从编辑器设置。 + 注:由于本节点的尺寸会跟随屏幕拉伸,所以 anchorPoint 只支持 (0.5, 0.5),否则适配不同屏幕时坐标会有偏差。 */ + export class Canvas extends Component { + /** !#en Current active canvas, the scene should only have one active canvas at the same time. + !#zh 当前激活的画布组件,场景同一时间只能有一个激活的画布。 */ + static instance: Canvas; + /** !#en The desigin resolution for current scene. + !#zh 当前场景设计分辨率。 */ + designResolution: Size; + /** !#en TODO + !#zh: 是否优先将设计分辨率高度撑满视图高度。 */ + fitHeight: boolean; + /** !#en TODO + !#zh: 是否优先将设计分辨率宽度撑满视图宽度。 */ + fitWidth: boolean; + } + /** !#en + Base class for everything attached to Node(Entity).
+
+ NOTE: Not allowed to use construction parameters for Component's subclasses, + because Component is created by the engine. + !#zh + 所有附加到节点的基类。
+
+ 注意:不允许使用组件的子类构造参数,因为组件是由引擎创建的。 */ + export class Component extends Object { + /** !#en The node this component is attached to. A component is always attached to a node. + !#zh 该组件被附加到的节点。组件总会附加到一个节点。 */ + node: Node; + /** !#en The uuid for editor. + !#zh 组件的 uuid,用于编辑器。 */ + uuid: string; + /** !#en indicates whether this component is enabled or not. + !#zh 表示该组件自身是否启用。 */ + enabled: boolean; + /** !#en indicates whether this component is enabled and its node is also active in the hierarchy. + !#zh 表示该组件是否被启用并且所在的节点也处于激活状态。 */ + enabledInHierarchy: boolean; + /** !#en Returns a value which used to indicate the onLoad get called or not. + !#zh 返回一个值用来判断 onLoad 是否被调用过,不等于 0 时调用过,等于 0 时未调用。 */ + _isOnLoadCalled: number; + /** + !#en Update is called every frame, if the Component is enabled.
+ This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere. + !#zh 如果该组件启用,则每帧调用 update。
+ 该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。 + @param dt the delta time in seconds it took to complete the last frame + */ + protected update(dt: number): void; + /** + !#en LateUpdate is called every frame, if the Component is enabled.
+ This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere. + !#zh 如果该组件启用,则每帧调用 LateUpdate。
+ 该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。 + @param dt the delta time in seconds it took to complete the last frame + */ + protected lateUpdate(dt: number): void; + /** + !#en + When attaching to an active node or its node first activated. + onLoad is always called before any start functions, this allows you to order initialization of scripts.
+ This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere. + !#zh + 当附加到一个激活的节点上或者其节点第一次激活时候调用。onLoad 总是会在任何 start 方法调用前执行,这能用于安排脚本的初始化顺序。
+ 该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。 + */ + protected onLoad(): void; + /** + !#en + Called before all scripts' update if the Component is enabled the first time. + Usually used to initialize some logic which need to be called after all components' `onload` methods called.
+ This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere. + !#zh + 如果该组件第一次启用,则在所有组件的 update 之前调用。通常用于需要在所有组件的 onLoad 初始化完毕后执行的逻辑。
+ 该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。 + */ + protected start(): void; + /** + !#en Called when this component becomes enabled and its node is active.
+ This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere. + !#zh 当该组件被启用,并且它的节点也激活时。
+ 该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。 + */ + protected onEnable(): void; + /** + !#en Called when this component becomes disabled or its node becomes inactive.
+ This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere. + !#zh 当该组件被禁用或节点变为无效时调用。
+ 该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。 + */ + protected onDisable(): void; + /** + !#en Called when this component will be destroyed.
+ This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere. + !#zh 当该组件被销毁时调用
+ 该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。 + */ + protected onDestroy(): void; + protected onFocusInEditor(): void; + protected onLostFocusInEditor(): void; + /** + !#en Called to initialize the component or node’s properties when adding the component the first time or when the Reset command is used. This function is only called in editor. + !#zh 用来初始化组件或节点的一些属性,当该组件被第一次添加到节点上或用户点击了它的 Reset 菜单时调用。这个回调只会在编辑器下调用。 + */ + protected resetInEditor(): void; + /** + !#en Adds a component class to the node. You can also add component to node by passing in the name of the script. + !#zh 向节点添加一个组件类,你还可以通过传入脚本的名称来添加组件。 + @param typeOrClassName the constructor or the class name of the component to add + + @example + ```js + var sprite = node.addComponent(cc.Sprite); + var test = node.addComponent("Test"); + ``` + */ + addComponent(type: {new(): T}): T; + addComponent(className: string): any; + /** + !#en + Returns the component of supplied type if the node has one attached, null if it doesn't.
+ You can also get component in the node by passing in the name of the script. + !#zh + 获取节点上指定类型的组件,如果节点有附加指定类型的组件,则返回,如果没有则为空。
+ 传入参数也可以是脚本的名称。 + @param typeOrClassName typeOrClassName + + @example + ```js + // get sprite component. + var sprite = node.getComponent(cc.Sprite); + // get custom test calss. + var test = node.getComponent("Test"); + ``` + */ + getComponent(type: {prototype: T}): T; + getComponent(className: string): any; + /** + !#en Returns all components of supplied Type in the node. + !#zh 返回节点上指定类型的所有组件。 + @param typeOrClassName typeOrClassName + + @example + ```js + var sprites = node.getComponents(cc.Sprite); + var tests = node.getComponents("Test"); + ``` + */ + getComponents(type: {prototype: T}): T[]; + getComponents(className: string): any[]; + /** + !#en Returns the component of supplied type in any of its children using depth first search. + !#zh 递归查找所有子节点中第一个匹配指定类型的组件。 + @param typeOrClassName typeOrClassName + + @example + ```js + var sprite = node.getComponentInChildren(cc.Sprite); + var Test = node.getComponentInChildren("Test"); + ``` + */ + getComponentInChildren(type: {prototype: T}): T; + getComponentInChildren(className: string): any; + /** + !#en Returns the components of supplied type in self or any of its children using depth first search. + !#zh 递归查找自身或所有子节点中指定类型的组件 + @param typeOrClassName typeOrClassName + + @example + ```js + var sprites = node.getComponentsInChildren(cc.Sprite); + var tests = node.getComponentsInChildren("Test"); + ``` + */ + getComponentsInChildren(type: {prototype: T}): T[]; + getComponentsInChildren(className: string): any[]; + /** + !#en + If the component's bounding box is different from the node's, you can implement this method to supply + a custom axis aligned bounding box (AABB), so the editor's scene view can perform hit test properly. + !#zh + 如果组件的包围盒与节点不同,您可以实现该方法以提供自定义的轴向对齐的包围盒(AABB), + 以便编辑器的场景视图可以正确地执行点选测试。 + @param out_rect the Rect to receive the bounding box + */ + _getLocalBounds(out_rect: Rect): void; + /** + !#en + onRestore is called after the user clicks the Reset item in the Inspector's context menu or performs + an undo operation on this component.
+
+ If the component contains the "internal state", short for "temporary member variables which not included
+ in its CCClass properties", then you may need to implement this function.
+
+ The editor will call the getset accessors of your component to record/restore the component's state
+ for undo/redo operation. However, in extreme cases, it may not works well. Then you should implement
+ this function to manually synchronize your component's "internal states" with its public properties.
+ Once you implement this function, all the getset accessors of your component will not be called when
+ the user performs an undo/redo operation. Which means that only the properties with default value
+ will be recorded or restored by editor.
+
+ Similarly, the editor may failed to reset your component correctly in extreme cases. Then if you need
+ to support the reset menu, you should manually synchronize your component's "internal states" with its
+ properties in this function. Once you implement this function, all the getset accessors of your component
+ will not be called during reset operation. Which means that only the properties with default value
+ will be reset by editor. + + This function is only called in editor mode. + !#zh + onRestore 是用户在检查器菜单点击 Reset 时,对此组件执行撤消操作后调用的。
+
+ 如果组件包含了“内部状态”(不在 CCClass 属性中定义的临时成员变量),那么你可能需要实现该方法。
+
+ 编辑器执行撤销/重做操作时,将调用组件的 get set 来录制和还原组件的状态。然而,在极端的情况下,它可能无法良好运作。
+ 那么你就应该实现这个方法,手动根据组件的属性同步“内部状态”。一旦你实现这个方法,当用户撤销或重做时,组件的所有 get set 都不会再被调用。这意味着仅仅指定了默认值的属性将被编辑器记录和还原。
+
+ 同样的,编辑可能无法在极端情况下正确地重置您的组件。如果你需要支持组件重置菜单,则需要在该方法中手工同步组件属性到“内部状态”。一旦你实现这个方法,组件的所有 get set 都不会在重置操作时被调用。这意味着仅仅指定了默认值的属性将被编辑器重置。 +
+ 此方法仅在编辑器下会被调用。 + */ + onRestore(): void; + /** + !#en + Schedules a custom selector.
+ If the selector is already scheduled, then the interval parameter will be updated without scheduling it again. + !#zh + 调度一个自定义的回调函数。
+ 如果回调函数已调度,那么将不会重复调度它,只会更新时间间隔参数。 + @param callback The callback function + @param interval Tick interval in seconds. 0 means tick every frame. + @param repeat The selector will be executed (repeat + 1) times, you can use cc.macro.REPEAT_FOREVER for tick infinitely. + @param delay The amount of time that the first tick will wait before execution. Unit: s + + @example + ```js + var timeCallback = function (dt) { + cc.log("time: " + dt); + } + this.schedule(timeCallback, 1); + ``` + */ + schedule(callback: Function, interval?: number, repeat?: number, delay?: number): void; + /** + !#en Schedules a callback function that runs only once, with a delay of 0 or larger. + !#zh 调度一个只运行一次的回调函数,可以指定 0 让回调函数在下一帧立即执行或者在一定的延时之后执行。 + @param callback A function wrapped as a selector + @param delay The amount of time that the first tick will wait before execution. Unit: s + + @example + ```js + var timeCallback = function (dt) { + cc.log("time: " + dt); + } + this.scheduleOnce(timeCallback, 2); + ``` + */ + scheduleOnce(callback: Function, delay?: number): void; + /** + !#en Unschedules a custom callback function. + !#zh 取消调度一个自定义的回调函数。 + @param callback_fn A function wrapped as a selector + + @example + ```js + this.unschedule(_callback); + ``` + */ + unschedule(callback_fn: Function): void; + /** + !#en + unschedule all scheduled callback functions: custom callback functions, and the 'update' callback function.
+ Actions are not affected by this method. + !#zh 取消调度所有已调度的回调函数:定制的回调函数以及 `update` 回调函数。动作不受此方法影响。 + + @example + ```js + this.unscheduleAllCallbacks(); + ``` + */ + unscheduleAllCallbacks(): void; + } + /** !#en The Label Component. + !#zh 文字标签组件 */ + export class Label extends RenderComponent { + /** !#en Content string of label. + !#zh 标签显示的文本内容。 */ + string: string; + /** !#en Horizontal Alignment of label. + !#zh 文本内容的水平对齐方式。 */ + horizontalAlign: Label.HorizontalAlign; + /** !#en Vertical Alignment of label. + !#zh 文本内容的垂直对齐方式。 */ + verticalAlign: Label.VerticalAlign; + /** !#en The actual rendering font size in shrink mode + !#zh SHRINK 模式下面文本实际渲染的字体大小 */ + actualFontSize: number; + /** !#en Font size of label. + !#zh 文本字体大小。 */ + fontSize: number; + /** !#en Font family of label, only take effect when useSystemFont property is true. + !#zh 文本字体名称, 只在 useSystemFont 属性为 true 的时候生效。 */ + fontFamily: string; + /** !#en Line Height of label. + !#zh 文本行高。 */ + lineHeight: number; + /** !#en Overflow of label. + !#zh 文字显示超出范围时的处理方式。 */ + overflow: Label.Overflow; + /** !#en Whether auto wrap label when string width is large than label width. + !#zh 是否自动换行。 */ + enableWrapText: boolean; + /** !#en The font of label. + !#zh 文本字体。 */ + font: Font; + /** !#en Whether use system font name or not. + !#zh 是否使用系统字体。 */ + useSystemFont: boolean; + /** !#en The spacing of the x axis between characters, only take Effect when using bitmap fonts. + !#zh 文字之间 x 轴的间距,仅在使用位图字体时生效。 */ + spacingX: number; + /** !#en The cache mode of label. This mode only supports system fonts. + !#zh 文本缓存模式, 该模式只支持系统字体。 */ + cacheMode: Label.CacheMode; + /** !#en Whether enable bold. + !#zh 是否启用黑体。 */ + enableBold: boolean; + /** !#en Whether enable italic. + !#zh 是否启用黑体。 */ + enableItalic: boolean; + /** !#en Whether enable underline. + !#zh 是否启用下划线。 */ + enableUnderline: boolean; + /** !#en The height of underline. + !#zh 下划线高度。 */ + underlineHeight: number; + /** + !#zh 需要保证当前场景中没有使用CHAR缓存的Label才可以清除,否则已渲染的文字没有重新绘制会不显示 + !#en It can be cleared that need to ensure there is not use the CHAR cache in the current scene. Otherwise, the rendered text will not be displayed without repainting. + */ + static clearCharCache(): void; + } + /** !#en Outline effect used to change the display, only for system fonts or TTF fonts + !#zh 描边效果组件,用于字体描边,只能用于系统字体 */ + export class LabelOutline extends Component { + /** !#en outline color + !#zh 改变描边的颜色 */ + color: Color; + /** !#en Change the outline width + !#zh 改变描边的宽度 */ + width: number; + } + /** !#en Shadow effect for Label component, only for system fonts or TTF fonts + !#zh 用于给 Label 组件添加阴影效果,只能用于系统字体或 ttf 字体 */ + export class LabelShadow extends Component { + /** !#en The shadow color + !#zh 阴影的颜色 */ + color: Color; + /** !#en Offset between font and shadow + !#zh 字体与阴影的偏移 */ + offset: Vec2; + /** !#en A non-negative float specifying the level of shadow blur + !#zh 阴影的模糊程度 */ + blur: number; + } + /** !#en + The Layout is a container component, use it to arrange child elements easily.
+ Note:
+ 1.Scaling and rotation of child nodes are not considered.
+ 2.After setting the Layout, the results need to be updated until the next frame, + unless you manually call {{#crossLink "Layout/updateLayout:method"}}{{/crossLink}}。 + !#zh + Layout 组件相当于一个容器,能自动对它的所有子节点进行统一排版。
+ 注意:
+ 1.不会考虑子节点的缩放和旋转。
+ 2.对 Layout 设置后结果需要到下一帧才会更新,除非你设置完以后手动调用 {{#crossLink "Layout/updateLayout:method"}}{{/crossLink}}。 */ + export class Layout extends Component { + /** !#en The layout type. + !#zh 布局类型 */ + type: Layout.Type; + /** !#en + The are three resize modes for Layout. + None, resize Container and resize children. + !#zh 缩放模式 */ + resizeMode: Layout.ResizeMode; + /** !#en The cell size for grid layout. + !#zh 每个格子的大小,只有布局类型为 GRID 的时候才有效。 */ + cellSize: Size; + /** !#en + The start axis for grid layout. If you choose horizontal, then children will layout horizontally at first, + and then break line on demand. Choose vertical if you want to layout vertically at first . + !#zh 起始轴方向类型,可进行水平和垂直布局排列,只有布局类型为 GRID 的时候才有效。 */ + startAxis: Layout.AxisDirection; + /** !#en The left padding of layout, it only effect the layout in one direction. + !#zh 容器内左边距,只会在一个布局方向上生效。 */ + paddingLeft: number; + /** !#en The right padding of layout, it only effect the layout in one direction. + !#zh 容器内右边距,只会在一个布局方向上生效。 */ + paddingRight: number; + /** !#en The top padding of layout, it only effect the layout in one direction. + !#zh 容器内上边距,只会在一个布局方向上生效。 */ + paddingTop: number; + /** !#en The bottom padding of layout, it only effect the layout in one direction. + !#zh 容器内下边距,只会在一个布局方向上生效。 */ + paddingBottom: number; + /** !#en The distance in x-axis between each element in layout. + !#zh 子节点之间的水平间距。 */ + spacingX: number; + /** !#en The distance in y-axis between each element in layout. + !#zh 子节点之间的垂直间距。 */ + spacingY: number; + /** !#en + Only take effect in Vertical layout mode. + This option changes the start element's positioning. + !#zh 垂直排列子节点的方向。 */ + verticalDirection: Layout.VerticalDirection; + /** !#en + Only take effect in Horizontal layout mode. + This option changes the start element's positioning. + !#zh 水平排列子节点的方向。 */ + horizontalDirection: Layout.HorizontalDirection; + /** !#en Adjust the layout if the children scaled. + !#zh 子节点缩放比例是否影响布局。 */ + affectedByScale: boolean; + /** + !#en Perform the layout update + !#zh 立即执行更新布局 + + @example + ```js + layout.type = cc.Layout.HORIZONTAL; + layout.node.addChild(childNode); + cc.log(childNode.x); // not yet changed + layout.updateLayout(); + cc.log(childNode.x); // changed + ``` + */ + updateLayout(): void; + } + /** !#en The Mask Component + !#zh 遮罩组件 */ + export class Mask extends RenderComponent { + /** !#en The mask type. + !#zh 遮罩类型 */ + type: Mask.Type; + /** !#en The mask image + !#zh 遮罩所需要的贴图 */ + spriteFrame: SpriteFrame; + /** !#en + The alpha threshold.(Not supported Canvas Mode)
+ The content is drawn only where the stencil have pixel with alpha greater than the alphaThreshold.
+ Should be a float between 0 and 1.
+ This default to 0.1. + When it's set to 1, the stencil will discard all pixels, nothing will be shown. + !#zh + Alpha 阈值(不支持 Canvas 模式)
+ 只有当模板的像素的 alpha 大于等于 alphaThreshold 时,才会绘制内容。
+ 该数值 0 ~ 1 之间的浮点数,默认值为 0.1 + 当被设置为 1 时,会丢弃所有蒙版像素,所以不会显示任何内容 */ + alphaThreshold: number; + /** !#en Reverse mask (Not supported Canvas Mode) + !#zh 反向遮罩(不支持 Canvas 模式) */ + inverted: boolean; + /** TODO: remove segments, not supported by graphics + !#en The segements for ellipse mask. + !#zh 椭圆遮罩的曲线细分数 */ + segements: number; + } + /** !#en + cc.MotionStreak manages a Ribbon based on it's motion in absolute space.
+ You construct it with a fadeTime, minimum segment size, texture path, texture
+ length and color. The fadeTime controls how long it takes each vertex in
+ the streak to fade out, the minimum segment size it how many pixels the
+ streak will move before adding a new ribbon segment, and the texture
+ length is the how many pixels the texture is stretched across. The texture
+ is vertically aligned along the streak segment. + !#zh 运动轨迹,用于游戏对象的运动轨迹上实现拖尾渐隐效果。 */ + export class MotionStreak extends Component implements BlendFunc { + /** !#en + !#zh 在编辑器模式下预览拖尾效果。 */ + preview: boolean; + /** !#en The fade time to fade. + !#zh 拖尾的渐隐时间,以秒为单位。 */ + fadeTime: number; + /** !#en The minimum segment size. + !#zh 拖尾之间最小距离。 */ + minSeg: number; + /** !#en The stroke's width. + !#zh 拖尾的宽度。 */ + stroke: number; + /** !#en The texture of the MotionStreak. + !#zh 拖尾的贴图。 */ + texture: Texture2D; + /** !#en The color of the MotionStreak. + !#zh 拖尾的颜色 */ + color: Color; + /** !#en The fast Mode. + !#zh 是否启用了快速模式。当启用快速模式,新的点会被更快地添加,但精度较低。 */ + fastMode: boolean; + /** + !#en Remove all living segments of the ribbon. + !#zh 删除当前所有的拖尾片段。 + + @example + ```js + // Remove all living segments of the ribbon. + myMotionStreak.reset(); + ``` + */ + reset(): void; + /** !#en specify the source Blend Factor, this will generate a custom material object, please pay attention to the memory cost. + !#zh 指定原图的混合模式,这会克隆一个新的材质对象,注意这带来的开销 */ + srcBlendFactor: macro.BlendFactor; + /** !#en specify the destination Blend Factor. + !#zh 指定目标的混合模式 */ + dstBlendFactor: macro.BlendFactor; + } + /** !#en The PageView control + !#zh 页面视图组件 */ + export class PageView extends ScrollView { + /** !#en Specify the size type of each page in PageView. + !#zh 页面视图中每个页面大小类型 */ + sizeMode: PageView.SizeMode; + /** !#en The page view direction + !#zh 页面视图滚动类型 */ + direction: PageView.Direction; + /** !#en + The scroll threshold value, when drag exceeds this value, + release the next page will automatically scroll, less than the restore + !#zh 滚动临界值,默认单位百分比,当拖拽超出该数值时,松开会自动滚动下一页,小于时则还原。 */ + scrollThreshold: number; + /** !#en + Auto page turning velocity threshold. When users swipe the PageView quickly, + it will calculate a velocity based on the scroll distance and time, + if the calculated velocity is larger than the threshold, then it will trigger page turning. + !#zh + 快速滑动翻页临界值。 + 当用户快速滑动时,会根据滑动开始和结束的距离与时间计算出一个速度值, + 该值与此临界值相比较,如果大于临界值,则进行自动翻页。 */ + autoPageTurningThreshold: number; + /** !#en Change the PageTurning event timing of PageView. + !#zh 设置 PageView PageTurning 事件的发送时机。 */ + pageTurningEventTiming: number; + /** !#en The Page View Indicator + !#zh 页面视图指示器组件 */ + indicator: PageViewIndicator; + /** !#en The time required to turn over a page. unit: second + !#zh 每个页面翻页时所需时间。单位:秒 */ + pageTurningSpeed: number; + /** !#en PageView events callback + !#zh 滚动视图的事件回调函数 */ + pageEvents: Component.EventHandler[]; + /** + !#en Returns current page index + !#zh 返回当前页面索引 + */ + getCurrentPageIndex(): number; + /** + !#en Set current page index + !#zh 设置当前页面索引 + @param index index + */ + setCurrentPageIndex(index: number): void; + /** + !#en Returns all pages of pageview + !#zh 返回视图中的所有页面 + */ + getPages(): Node[]; + /** + !#en At the end of the current page view to insert a new view + !#zh 在当前页面视图的尾部插入一个新视图 + @param page page + */ + addPage(page: Node): void; + /** + !#en Inserts a page in the specified location + !#zh 将页面插入指定位置中 + @param page page + @param index index + */ + insertPage(page: Node, index: number): void; + /** + !#en Removes a page from PageView. + !#zh 移除指定页面 + @param page page + */ + removePage(page: Node): void; + /** + !#en Removes a page at index of PageView. + !#zh 移除指定下标的页面 + @param index index + */ + removePageAtIndex(index: number): void; + /** + !#en Removes all pages from PageView + !#zh 移除所有页面 + */ + removeAllPages(): void; + /** + !#en Scroll PageView to index. + !#zh 滚动到指定页面 + @param idx index of page. + @param timeInSecond scrolling time + */ + scrollToPage(idx: number, timeInSecond: number): void; + } + /** !#en The Page View Indicator Component + !#zh 页面视图每页标记组件 */ + export class PageViewIndicator extends Component { + /** !#en The spriteFrame for each element. + !#zh 每个页面标记显示的图片 */ + spriteFrame: SpriteFrame; + /** !#en The location direction of PageViewIndicator. + !#zh 页面标记摆放方向 */ + direction: PageViewIndicator.Direction; + /** !#en The cellSize for each element. + !#zh 每个页面标记的大小 */ + cellSize: Size; + /** !#en The distance between each element. + !#zh 每个页面标记之间的边距 */ + spacing: number; + /** + !#en Set Page View + !#zh 设置页面视图 + @param target target + */ + setPageView(target: PageView): void; + } + /** !#en + Visual indicator of progress in some operation. + Displays a bar to the user representing how far the operation has progressed. + !#zh + 进度条组件,可用于显示加载资源时的进度。 */ + export class ProgressBar extends Component { + /** !#en The targeted Sprite which will be changed progressively. + !#zh 用来显示进度条比例的 Sprite 对象。 */ + barSprite: Sprite; + /** !#en The progress mode, there are two modes supported now: horizontal and vertical. + !#zh 进度条的模式 */ + mode: ProgressBar.Mode; + /** !#en The total width or height of the bar sprite. + !#zh 进度条实际的总长度 */ + totalLength: number; + /** !#en The current progress of the bar sprite. The valid value is between 0-1. + !#zh 当前进度值,该数值的区间是 0-1 之间。 */ + progress: number; + /** !#en Whether reverse the progress direction of the bar sprite. + !#zh 进度条是否进行反方向变化。 */ + reverse: boolean; + } + /** !#en + Base class for components which supports rendering features. + !#zh + 所有支持渲染的组件的基类 */ + export class RenderComponent extends Component { + /** !#en The materials used by this render component. + !#zh 渲染组件使用的材质。 */ + sharedMaterials: Material[]; + /** + !#en Get the material by index. + !#zh 根据指定索引获取材质 + @param index index + */ + getMaterial(index: number): MaterialVariant; + /** + !#en Gets all the materials. + !#zh 获取所有材质。 + */ + getMaterials(): MaterialVariant[]; + /** + !#en Set the material by index. + !#zh 根据指定索引设置材质 + @param index index + @param material material + */ + setMaterial(index: number, material: Material): Material; + } + /** !#en The RichText Component. + !#zh 富文本组件 */ + export class RichText extends Component { + /** !#en Content string of RichText. + !#zh 富文本显示的文本内容。 */ + string: string; + /** !#en Horizontal Alignment of each line in RichText. + !#zh 文本内容的水平对齐方式。 */ + horizontalAlign: macro.TextAlignment; + /** !#en Font size of RichText. + !#zh 富文本字体大小。 */ + fontSize: number; + /** !#en Custom System font of RichText + !#zh 富文本定制系统字体 */ + fontFamily: string; + /** !#en Custom TTF font of RichText + !#zh 富文本定制字体 */ + font: TTFFont; + /** !#en Whether use system font name or not. + !#zh 是否使用系统字体。 */ + useSystemFont: boolean; + /** !#en The cache mode of label. This mode only supports system fonts. + !#zh 文本缓存模式, 该模式只支持系统字体。 */ + cacheMode: Label.CacheMode; + /** !#en The maximize width of the RichText + !#zh 富文本的最大宽度 */ + maxWidth: number; + /** !#en Line Height of RichText. + !#zh 富文本行高。 */ + lineHeight: number; + /** !#en The image atlas for the img tag. For each src value in the img tag, there should be a valid spriteFrame in the image atlas. + !#zh 对于 img 标签里面的 src 属性名称,都需要在 imageAtlas 里面找到一个有效的 spriteFrame,否则 img tag 会判定为无效。 */ + imageAtlas: SpriteAtlas; + /** !#en + Once checked, the RichText will block all input events (mouse and touch) within + the bounding box of the node, preventing the input from penetrating into the underlying node. + !#zh + 选中此选项后,RichText 将阻止节点边界框中的所有输入事件(鼠标和触摸),从而防止输入事件穿透到底层节点。 */ + handleTouchEvent: boolean; + } + /** !#en + This component is used to adjust the layout of current node to respect the safe area of a notched mobile device such as the iPhone X. + It is typically used for the top node of the UI interaction area. For specific usage, refer to the official [example-cases/02_ui/16_safeArea/SafeArea.fire](https://github.com/cocos-creator/example-cases). + + The concept of safe area is to give you a fixed inner rectangle in which you can safely display content that will be drawn on screen. + You are strongly discouraged from providing controls outside of this area. But your screen background could embellish edges. + + This component internally uses the API `cc.sys.getSafeAreaRect();` to obtain the safe area of the current iOS or Android device, + and implements the adaptation by using the Widget component and set anchor. + + !#zh + 该组件会将所在节点的布局适配到 iPhone X 等异形屏手机的安全区域内,通常用于 UI 交互区域的顶层节点,具体用法可参考官方范例 [example-cases/02_ui/16_safeArea/SafeArea.fire](https://github.com/cocos-creator/example-cases)。 + + 该组件内部通过 API `cc.sys.getSafeAreaRect();` 获取到当前 iOS 或 Android 设备的安全区域,并通过 Widget 组件实现适配。 */ + export class SafeArea extends Component { + /** + !#en Adapt to safe area + !#zh 立即适配安全区域 + + @example + ```js + let safeArea = this.node.addComponent(cc.SafeArea); + safeArea.updateArea(); + ``` + */ + updateArea(): void; + } + /** !#en + The Scrollbar control allows the user to scroll an image or other view that is too large to see completely + !#zh 滚动条组件 */ + export class Scrollbar extends Component { + /** !#en The "handle" part of the scrollbar. + !#zh 作为当前滚动区域位置显示的滑块 Sprite。 */ + handle: Sprite; + /** !#en The direction of scrollbar. + !#zh ScrollBar 的滚动方向。 */ + direction: Scrollbar.Direction; + /** !#en Whether enable auto hide or not. + !#zh 是否在没有滚动动作时自动隐藏 ScrollBar。 */ + enableAutoHide: boolean; + /** !#en + The time to hide scrollbar when scroll finished. + Note: This value is only useful when enableAutoHide is true. + !#zh + 没有滚动动作后经过多久会自动隐藏。 + 注意:只要当 “enableAutoHide” 为 true 时,才有效。 */ + autoHideTime: number; + } + /** !#en + Layout container for a view hierarchy that can be scrolled by the user, + allowing it to be larger than the physical display. + + !#zh + 滚动视图组件 */ + export class ScrollView extends Component { + /** !#en This is a reference to the UI element to be scrolled. + !#zh 可滚动展示内容的节点。 */ + content: Node; + /** !#en Enable horizontal scroll. + !#zh 是否开启水平滚动。 */ + horizontal: boolean; + /** !#en Enable vertical scroll. + !#zh 是否开启垂直滚动。 */ + vertical: boolean; + /** !#en When inertia is set, the content will continue to move when touch ended. + !#zh 是否开启滚动惯性。 */ + inertia: boolean; + /** !#en + It determines how quickly the content stop moving. A value of 1 will stop the movement immediately. + A value of 0 will never stop the movement until it reaches to the boundary of scrollview. + !#zh + 开启惯性后,在用户停止触摸后滚动多快停止,0表示永不停止,1表示立刻停止。 */ + brake: number; + /** !#en When elastic is set, the content will be bounce back when move out of boundary. + !#zh 是否允许滚动内容超过边界,并在停止触摸后回弹。 */ + elastic: boolean; + /** !#en The elapse time of bouncing back. A value of 0 will bounce back immediately. + !#zh 回弹持续的时间,0 表示将立即反弹。 */ + bounceDuration: number; + /** !#en The horizontal scrollbar reference. + !#zh 水平滚动的 ScrollBar。 */ + horizontalScrollBar: Scrollbar; + /** !#en The vertical scrollbar reference. + !#zh 垂直滚动的 ScrollBar。 */ + verticalScrollBar: Scrollbar; + /** !#en Scrollview events callback + !#zh 滚动视图的事件回调函数 */ + scrollEvents: Component.EventHandler[]; + /** !#en If cancelInnerEvents is set to true, the scroll behavior will cancel touch events on inner content nodes + It's set to true by default. + !#zh 如果这个属性被设置为 true,那么滚动行为会取消子节点上注册的触摸事件,默认被设置为 true。 + 注意,子节点上的 touchstart 事件仍然会触发,触点移动距离非常短的情况下 touchmove 和 touchend 也不会受影响。 */ + cancelInnerEvents: boolean; + /** + !#en Scroll the content to the bottom boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图底部。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the bottom boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the bottom of the view. + scrollView.scrollToBottom(0.1); + ``` + */ + scrollToBottom(timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the top boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图顶部。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the top boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the top of the view. + scrollView.scrollToTop(0.1); + ``` + */ + scrollToTop(timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the left boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图左边。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the left boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the left of the view. + scrollView.scrollToLeft(0.1); + ``` + */ + scrollToLeft(timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the right boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图右边。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the right boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the right of the view. + scrollView.scrollToRight(0.1); + ``` + */ + scrollToRight(timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the top left boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图左上角。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the top left boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the upper left corner of the view. + scrollView.scrollToTopLeft(0.1); + ``` + */ + scrollToTopLeft(timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the top right boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图右上角。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the top right boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the top right corner of the view. + scrollView.scrollToTopRight(0.1); + ``` + */ + scrollToTopRight(timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the bottom left boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图左下角。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the bottom left boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the lower left corner of the view. + scrollView.scrollToBottomLeft(0.1); + ``` + */ + scrollToBottomLeft(timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the bottom right boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图右下角。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the bottom right boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the lower right corner of the view. + scrollView.scrollToBottomRight(0.1); + ``` + */ + scrollToBottomRight(timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll with an offset related to the ScrollView's top left origin, if timeInSecond is omitted, then it will jump to the + specific offset immediately. + !#zh 视图内容在规定时间内将滚动到 ScrollView 相对左上角原点的偏移位置, 如果 timeInSecond参数不传,则立即滚动到指定偏移位置。 + @param offset A Vec2, the value of which each axis between 0 and maxScrollOffset + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the specific offset of ScrollView immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to middle position in 0.1 second in x-axis + let maxScrollOffset = this.getMaxScrollOffset(); + scrollView.scrollToOffset(cc.v2(maxScrollOffset.x / 2, 0), 0.1); + ``` + */ + scrollToOffset(offset: Vec2, timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Get the positive offset value corresponds to the content's top left boundary. + !#zh 获取滚动视图相对于左上角原点的当前滚动偏移 + */ + getScrollOffset(): Vec2; + /** + !#en Get the maximize available scroll offset + !#zh 获取滚动视图最大可以滚动的偏移量 + */ + getMaxScrollOffset(): Vec2; + /** + !#en Scroll the content to the horizontal percent position of ScrollView. + !#zh 视图内容在规定时间内将滚动到 ScrollView 水平方向的百分比位置上。 + @param percent A value between 0 and 1. + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the horizontal percent position of ScrollView immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to middle position. + scrollView.scrollToBottomRight(0.5, 0.1); + ``` + */ + scrollToPercentHorizontal(percent: number, timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the percent position of ScrollView in any direction. + !#zh 视图内容在规定时间内进行垂直方向和水平方向的滚动,并且滚动到指定百分比位置上。 + @param anchor A point which will be clamp between cc.v2(0,0) and cc.v2(1,1). + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the percent position of ScrollView immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Vertical scroll to the bottom of the view. + scrollView.scrollTo(cc.v2(0, 1), 0.1); + + // Horizontal scroll to view right. + scrollView.scrollTo(cc.v2(1, 0), 0.1); + ``` + */ + scrollTo(anchor: Vec2, timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the vertical percent position of ScrollView. + !#zh 视图内容在规定时间内滚动到 ScrollView 垂直方向的百分比位置上。 + @param percent A value between 0 and 1. + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the vertical percent position of ScrollView immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + // Scroll to middle position. + scrollView.scrollToPercentVertical(0.5, 0.1); + */ + scrollToPercentVertical(percent: number, timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Stop auto scroll immediately + !#zh 停止自动滚动, 调用此 API 可以让 Scrollview 立即停止滚动 + */ + stopAutoScroll(): void; + /** + !#en Modify the content position. + !#zh 设置当前视图内容的坐标点。 + @param position The position in content's parent space. + */ + setContentPosition(position: Vec2): void; + /** + !#en Query the content's position in its parent space. + !#zh 获取当前视图内容的坐标点。 + */ + getContentPosition(): Vec2; + /** + !#en Query whether the user is currently dragging the ScrollView to scroll it + !#zh 用户是否在拖拽当前滚动视图 + */ + isScrolling(): boolean; + /** + !#en Query whether the ScrollView is currently scrolling because of a bounceback or inertia slowdown. + !#zh 当前滚动视图是否在惯性滚动 + */ + isAutoScrolling(): boolean; + } + /** !#en The Slider Control + !#zh 滑动器组件 */ + export class Slider extends Component { + /** !#en The "handle" part of the slider + !#zh 滑动器滑块按钮部件 */ + handle: Button; + /** !#en The slider direction + !#zh 滑动器方向 */ + direction: Slider.Direction; + /** !#en The current progress of the slider. The valid value is between 0-1 + !#zh 当前进度值,该数值的区间是 0-1 之间 */ + progress: number; + /** !#en The slider slide events' callback array + !#zh 滑动器组件滑动事件回调函数数组 */ + slideEvents: Component.EventHandler[]; + } + /** !#en Renders a sprite in the scene. + !#zh 该组件用于在场景中渲染精灵。 */ + export class Sprite extends RenderComponent implements BlendFunc { + /** !#en The sprite frame of the sprite. + !#zh 精灵的精灵帧 */ + spriteFrame: SpriteFrame; + /** !#en The sprite render type. + !#zh 精灵渲染类型 */ + type: Sprite.Type; + /** !#en + The fill type, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”. + !#zh + 精灵填充类型,仅渲染类型设置为 cc.Sprite.Type.FILLED 时有效。 */ + fillType: Sprite.FillType; + /** !#en + The fill Center, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”. + !#zh + 填充中心点,仅渲染类型设置为 cc.Sprite.Type.FILLED 时有效。 */ + fillCenter: Vec2; + /** !#en + The fill Start, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”. + !#zh + 填充起始点,仅渲染类型设置为 cc.Sprite.Type.FILLED 时有效。 */ + fillStart: number; + /** !#en + The fill Range, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”. + !#zh + 填充范围,仅渲染类型设置为 cc.Sprite.Type.FILLED 时有效。 */ + fillRange: number; + /** !#en specify the frame is trimmed or not. + !#zh 是否使用裁剪模式 */ + trim: boolean; + /** !#en specify the size tracing mode. + !#zh 精灵尺寸调整模式 */ + sizeMode: Sprite.SizeMode; + /** + Change the state of sprite. + @param state NORMAL or GRAY State. + */ + setState(state: Sprite.State): void; + /** + Gets the current state. + */ + getState(): Sprite.State; + /** !#en specify the source Blend Factor, this will generate a custom material object, please pay attention to the memory cost. + !#zh 指定原图的混合模式,这会克隆一个新的材质对象,注意这带来的开销 */ + srcBlendFactor: macro.BlendFactor; + /** !#en specify the destination Blend Factor. + !#zh 指定目标的混合模式 */ + dstBlendFactor: macro.BlendFactor; + } + /** !#en The toggle component is a CheckBox, when it used together with a ToggleGroup, it + could be treated as a RadioButton. + !#zh Toggle 是一个 CheckBox,当它和 ToggleGroup 一起使用的时候,可以变成 RadioButton。 */ + export class Toggle extends Button implements GraySpriteState { + /** !#en When this value is true, the check mark component will be enabled, otherwise + the check mark component will be disabled. + !#zh 如果这个设置为 true,则 check mark 组件会处于 enabled 状态,否则处于 disabled 状态。 */ + isChecked: boolean; + /** !#en The toggle group which the toggle belongs to, when it is null, the toggle is a CheckBox. + Otherwise, the toggle is a RadioButton. + !#zh Toggle 所属的 ToggleGroup,这个属性是可选的。如果这个属性为 null,则 Toggle 是一个 CheckBox, + 否则,Toggle 是一个 RadioButton。 */ + toggleGroup: ToggleGroup; + /** !#en The image used for the checkmark. + !#zh Toggle 处于选中状态时显示的图片 */ + checkMark: Sprite; + /** !#en If Toggle is clicked, it will trigger event's handler + !#zh Toggle 按钮的点击事件列表。 */ + checkEvents: Component.EventHandler[]; + /** + !#en Make the toggle button checked. + !#zh 使 toggle 按钮处于选中状态 + */ + check(): void; + /** + !#en Make the toggle button unchecked. + !#zh 使 toggle 按钮处于未选中状态 + */ + uncheck(): void; + /** !#en The normal material. + !#zh 正常状态的材质。 */ + normalMaterial: Material; + /** !#en The gray material. + !#zh 置灰状态的材质。 */ + grayMaterial: Material; + } + /** !#en ToggleContainer is not a visiable UI component but a way to modify the behavior of a set of Toggles.
+ Toggles that belong to the same group could only have one of them to be switched on at a time.
+ Note: All the first layer child node containing the toggle component will auto be added to the container + !#zh ToggleContainer 不是一个可见的 UI 组件,它可以用来修改一组 Toggle 组件的行为。
+ 当一组 Toggle 属于同一个 ToggleContainer 的时候,任何时候只能有一个 Toggle 处于选中状态。
+ 注意:所有包含 Toggle 组件的一级子节点都会自动被添加到该容器中 */ + export class ToggleContainer extends Component { + /** !#en If this setting is true, a toggle could be switched off and on when pressed. + If it is false, it will make sure there is always only one toggle could be switched on + and the already switched on toggle can't be switched off. + !#zh 如果这个设置为 true, 那么 toggle 按钮在被点击的时候可以反复地被选中和未选中。 */ + allowSwitchOff: boolean; + /** !#en If Toggle is clicked, it will trigger event's handler + !#zh Toggle 按钮的点击事件列表。 */ + checkEvents: Component.EventHandler[]; + /** !#en Read only property, return the toggle items array reference managed by ToggleContainer. + !#zh 只读属性,返回 ToggleContainer 管理的 toggle 数组引用 */ + toggleItems: Toggle[]; + } + /** !#en ToggleGroup is not a visiable UI component but a way to modify the behavior of a set of Toggles. + Toggles that belong to the same group could only have one of them to be switched on at a time. + !#zh ToggleGroup 不是一个可见的 UI 组件,它可以用来修改一组 Toggle 组件的行为。当一组 Toggle 属于同一个 ToggleGroup 的时候, + 任何时候只能有一个 Toggle 处于选中状态。 */ + export class ToggleGroup extends Component { + /** !#en If this setting is true, a toggle could be switched off and on when pressed. + If it is false, it will make sure there is always only one toggle could be switched on + and the already switched on toggle can't be switched off. + !#zh 如果这个设置为 true, 那么 toggle 按钮在被点击的时候可以反复地被选中和未选中。 */ + allowSwitchOff: boolean; + /** !#en Read only property, return the toggle items array reference managed by toggleGroup. + !#zh 只读属性,返回 toggleGroup 管理的 toggle 数组引用 */ + toggleItems: any[]; + } + /** !#en + Stores and manipulate the anchoring based on its parent. + Widget are used for GUI but can also be used for other things. + Widget will adjust current node's position and size automatically, but the results after adjustment can not be obtained until the next frame unless you call {{#crossLink "Widget/updateAlignment:method"}}{{/crossLink}} manually. + !#zh + Widget 组件,用于设置和适配其相对于父节点的边距,Widget 通常被用于 UI 界面,也可以用于其他地方。 + Widget 会自动调整当前节点的坐标和宽高,不过目前调整后的结果要到下一帧才能在脚本里获取到,除非你先手动调用 {{#crossLink "Widget/updateAlignment:method"}}{{/crossLink}}。 */ + export class Widget extends Component { + /** !#en Specifies an alignment target that can only be one of the parent nodes of the current node. + The default value is null, and when null, indicates the current parent. + !#zh 指定一个对齐目标,只能是当前节点的其中一个父节点,默认为空,为空时表示当前父节点。 */ + target: Node; + /** !#en Whether to align the top. + !#zh 是否对齐上边。 */ + isAlignTop: boolean; + /** !#en + Vertically aligns the midpoint, This will open the other vertical alignment options cancel. + !#zh + 是否垂直方向对齐中点,开启此项会将垂直方向其他对齐选项取消。 */ + isAlignVerticalCenter: boolean; + /** !#en Whether to align the bottom. + !#zh 是否对齐下边。 */ + isAlignBottom: boolean; + /** !#en Whether to align the left. + !#zh 是否对齐左边 */ + isAlignLeft: boolean; + /** !#en + Horizontal aligns the midpoint. This will open the other horizontal alignment options canceled. + !#zh + 是否水平方向对齐中点,开启此选项会将水平方向其他对齐选项取消。 */ + isAlignHorizontalCenter: boolean; + /** !#en Whether to align the right. + !#zh 是否对齐右边。 */ + isAlignRight: boolean; + /** !#en + Whether the stretched horizontally, when enable the left and right alignment will be stretched horizontally, + the width setting is invalid (read only). + !#zh + 当前是否水平拉伸。当同时启用左右对齐时,节点将会被水平拉伸,此时节点的宽度只读。 */ + isStretchWidth: boolean; + /** !#en + Whether the stretched vertically, when enable the left and right alignment will be stretched vertically, + then height setting is invalid (read only) + !#zh + 当前是否垂直拉伸。当同时启用上下对齐时,节点将会被垂直拉伸,此时节点的高度只读。 */ + isStretchHeight: boolean; + /** !#en + The margins between the top of this node and the top of parent node, + the value can be negative, Only available in 'isAlignTop' open. + !#zh + 本节点顶边和父节点顶边的距离,可填写负值,只有在 isAlignTop 开启时才有作用。 */ + top: number; + /** !#en + The margins between the bottom of this node and the bottom of parent node, + the value can be negative, Only available in 'isAlignBottom' open. + !#zh + 本节点底边和父节点底边的距离,可填写负值,只有在 isAlignBottom 开启时才有作用。 */ + bottom: number; + /** !#en + The margins between the left of this node and the left of parent node, + the value can be negative, Only available in 'isAlignLeft' open. + !#zh + 本节点左边和父节点左边的距离,可填写负值,只有在 isAlignLeft 开启时才有作用。 */ + left: number; + /** !#en + The margins between the right of this node and the right of parent node, + the value can be negative, Only available in 'isAlignRight' open. + !#zh + 本节点右边和父节点右边的距离,可填写负值,只有在 isAlignRight 开启时才有作用。 */ + right: number; + /** !#en + Horizontal aligns the midpoint offset value, + the value can be negative, Only available in 'isAlignHorizontalCenter' open. + !#zh 水平居中的偏移值,可填写负值,只有在 isAlignHorizontalCenter 开启时才有作用。 */ + horizontalCenter: number; + /** !#en + Vertical aligns the midpoint offset value, + the value can be negative, Only available in 'isAlignVerticalCenter' open. + !#zh 垂直居中的偏移值,可填写负值,只有在 isAlignVerticalCenter 开启时才有作用。 */ + verticalCenter: number; + /** !#en If true, horizontalCenter is pixel margin, otherwise is percentage (0 - 1) margin. + !#zh 如果为 true,"horizontalCenter" 将会以像素作为偏移值,反之为百分比(0 到 1)。 */ + isAbsoluteHorizontalCenter: boolean; + /** !#en If true, verticalCenter is pixel margin, otherwise is percentage (0 - 1) margin. + !#zh 如果为 true,"verticalCenter" 将会以像素作为偏移值,反之为百分比(0 到 1)。 */ + isAbsoluteVerticalCenter: boolean; + /** !#en + If true, top is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's height. + !#zh + 如果为 true,"top" 将会以像素作为边距,否则将会以相对父物体高度的百分比(0 到 1)作为边距。 */ + isAbsoluteTop: boolean; + /** !#en + If true, bottom is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's height. + !#zh + 如果为 true,"bottom" 将会以像素作为边距,否则将会以相对父物体高度的百分比(0 到 1)作为边距。 */ + isAbsoluteBottom: boolean; + /** !#en + If true, left is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's width. + !#zh + 如果为 true,"left" 将会以像素作为边距,否则将会以相对父物体宽度的百分比(0 到 1)作为边距。 */ + isAbsoluteLeft: boolean; + /** !#en + If true, right is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's width. + !#zh + 如果为 true,"right" 将会以像素作为边距,否则将会以相对父物体宽度的百分比(0 到 1)作为边距。 */ + isAbsoluteRight: boolean; + /** !#en Specifies the alignment mode of the Widget, which determines when the widget should refresh. + !#zh 指定 Widget 的对齐模式,用于决定 Widget 应该何时刷新。 */ + alignMode: Widget.AlignMode; + /** + !#en + Immediately perform the widget alignment. You need to manually call this method only if + you need to get the latest results after the alignment before the end of current frame. + !#zh + 立刻执行 widget 对齐操作。这个接口一般不需要手工调用。 + 只有当你需要在当前帧结束前获得 widget 对齐后的最新结果时才需要手动调用这个方法。 + + @example + ```js + widget.top = 10; // change top margin + cc.log(widget.node.y); // not yet changed + widget.updateAlignment(); + cc.log(widget.node.y); // changed + ``` + */ + updateAlignment(): void; + /** !#en + When turned on, it will only be aligned once at the end of the onEnable frame, + then immediately disables the current component. + This will allow the script or animation to continue controlling the current node. + Note: It will still be aligned at the frame when onEnable is called. + !#zh + 开启后仅会在 onEnable 的当帧结束时对齐一次,然后立刻禁用当前组件。 + 这样便于脚本或动画继续控制当前节点。 + 注意:onEnable 时所在的那一帧仍然会进行对齐。 */ + isAlignOnce: boolean; + } + /** !#en + Handling touch events in a ViewGroup takes special care, + because it's common for a ViewGroup to have children that are targets for different touch events than the ViewGroup itself. + To make sure that each view correctly receives the touch events intended for it, + ViewGroup should register capture phase event and handle the event propagation properly. + Please refer to Scrollview for more information. + + !#zh + ViewGroup的事件处理比较特殊,因为 ViewGroup 里面的子节点关心的事件跟 ViewGroup 本身可能不一样。 + 为了让子节点能够正确地处理事件,ViewGroup 需要注册 capture 阶段的事件,并且合理地处理 ViewGroup 之间的事件传递。 + 请参考 ScrollView 的实现来获取更多信息。 */ + export class ViewGroup extends Component { + } + /** !#en SubContextView is a view component which controls open data context viewport in minigame platform.
+ The component's node size decide the viewport of the sub context content in main context, + the entire sub context texture will be scaled to the node's bounding box area.
+ This component provides multiple important features:
+ 1. Sub context could use its own resolution size and policy.
+ 2. Sub context could be minized to smallest size it needed.
+ 3. Resolution of sub context content could be increased.
+ 4. User touch input is transformed to the correct viewport.
+ 5. Texture update is handled by this component. User don't need to worry.
+ One important thing to be noted, whenever the node's bounding box change, + !#zh SubContextView 可以用来控制小游戏平台开放数据域在主域中的视窗的位置。
+ 这个组件的节点尺寸决定了开放数据域内容在主域中的尺寸,整个开放数据域会被缩放到节点的包围盒范围内。
+ 在这个组件的控制下,用户可以更自由得控制开放数据域:
+ 1. 子域中可以使用独立的设计分辨率和适配模式
+ 2. 子域区域尺寸可以缩小到只容纳内容即可
+ 3. 子域的分辨率也可以被放大,以便获得更清晰的显示效果
+ 4. 用户输入坐标会被自动转换到正确的子域视窗中
+ 5. 子域内容贴图的更新由组件负责,用户不需要处理
*/ + export class SubContextView extends Component { + /** + !#en Reset open data context size and viewport + !#zh 重置开放数据域的尺寸和视窗 + */ + reset(): void; + /** + !#en Update the sub context viewport manually, it should be called whenever the node's bounding box changes. + !#zh 更新开放数据域相对于主域的 viewport,这个函数应该在节点包围盒改变时手动调用。 + */ + updateSubContextViewport(): void; + } + /** !#en WXSubContextView is deprecated since v2.4.1, please use SubContextView instead. + !#zh 自 v2.4.1 起,WXSubContextView 已经废弃,请使用 SubContextView */ + export class WXSubContextView extends Component { + } + /** !#en SwanSubContextView is deprecated since v2.4.1, please use SubContextView instead. + !#zh 自 v2.4.1 起,SwanSubContextView 已经废弃,请使用 SubContextView */ + export class SwanSubContextView extends Component { + } + /** !#en Class for audio data handling. + !#zh 音频资源类。 */ + export class AudioClip extends Asset implements EventTarget { + /** !#en Get the audio clip duration + !#zh 获取音频剪辑的长度 */ + duration: number; + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en + Register an callback of a specific event type on the EventTarget. + This type of event should be triggered via `emit`. + !#zh + 注册事件目标的特定事件类型回调。这种类型的事件应该被 `emit` 触发。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, node); + ``` + */ + on(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. + !#zh + 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + + @example + ```js + // register fire eventListener + var callback = eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, target); + // remove fire event listener + eventTarget.off('fire', callback, target); + // remove all fire event listeners + eventTarget.off('fire'); + ``` + */ + off(type: string, callback?: Function, target?: any): void; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.once('fire', function () { + cc.log("this is the callback and will be invoked only once"); + }, node); + ``` + */ + once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; + /** + !#en + Send an event with the event object. + !#zh + 通过事件对象派发事件 + @param event event + */ + dispatchEvent(event: Event): void; + } + /** !#en Class for BitmapFont handling. + !#zh 位图字体资源类。 */ + export class BitmapFont extends Font { + } + /** undefined */ + export class BufferAsset extends Asset { + } + /** !#en Class for Font handling. + !#zh 字体资源类。 */ + export class Font extends Asset { + } + /** !#en + Class for JSON file. When the JSON file is loaded, this object is returned. + The parsed JSON object can be accessed through the `json` attribute in it.
+ If you want to get the original JSON text, you should modify the extname to `.txt` + so that it is loaded as a `TextAsset` instead of a `JsonAsset`. + + !#zh + JSON 资源类。JSON 文件加载后,将会返回该对象。可以通过其中的 `json` 属性访问解析后的 JSON 对象。
+ 如果你想要获得 JSON 的原始文本,那么应该修改源文件的后缀为 `.txt`,这样就会加载为一个 `TextAsset` 而不是 `JsonAsset`。 */ + export class JsonAsset extends Asset { + /** The loaded JSON object. */ + json: any; + } + /** !#en Class for LabelAtlas handling. + !#zh 艺术数字字体资源类。 */ + export class LabelAtlas extends BitmapFont { + } + /** !#en Class for prefab handling. + !#zh 预制资源类。 */ + export class Prefab extends Asset { + /** the main cc.Node in the prefab */ + data: Node; + /** !#zh + 设置实例化这个 prefab 时所用的优化策略。根据使用情况设置为合适的值,能优化该 prefab 实例化所用的时间。 + !#en + Indicates the optimization policy for instantiating this prefab. + Set to a suitable value based on usage, can optimize the time it takes to instantiate this prefab. */ + optimizationPolicy: Prefab.OptimizationPolicy; + /** !#en Indicates the raw assets of this prefab can be load after prefab loaded. + !#zh 指示该 Prefab 依赖的资源可否在 Prefab 加载后再延迟加载。 */ + asyncLoadAssets: boolean; + readonly: boolean; + /** + Dynamically translation prefab data into minimized code.
+ This method will be called automatically before the first time the prefab being instantiated, + but you can re-call to refresh the create function once you modified the original prefab data in script. + */ + compileCreateFunction(): void; + } + /** Render textures are textures that can be rendered to. */ + export class RenderTexture extends Texture2D { + /** + !#en + Init the render texture with size. + !#zh + 初始化 render texture + @param width width + @param height height + @param depthStencilFormat depthStencilFormat + */ + initWithSize(width?: number, height?: number, depthStencilFormat?: number): void; + /** + !#en + Get pixels from render texture, the pixels data stores in a RGBA Uint8Array. + It will return a new (width * height * 4) length Uint8Array by default。 + You can specify a data to store the pixels to reuse the data, + you and can specify other params to specify the texture region to read. + !#zh + 从 render texture 读取像素数据,数据类型为 RGBA 格式的 Uint8Array 数组。 + 默认每次调用此函数会生成一个大小为 (长 x 高 x 4) 的 Uint8Array。 + 你可以通过传入 data 来接收像素数据,也可以通过传参来指定需要读取的区域的像素。 + @param data data + @param x x + @param y y + @param w w + @param h h + */ + readPixels(data?: Uint8Array, x?: number, y?: number, w?: number, h?: number): Uint8Array; + } + /** !#en Class for scene handling. + !#zh 场景资源类。 */ + export class SceneAsset extends Asset { + scene: Scene; + /** !#en Indicates the raw assets of this scene can be load after scene launched. + !#zh 指示该场景依赖的资源可否在场景切换后再延迟加载。 */ + asyncLoadAssets: boolean; + } + /** !#en Class for script handling. + !#zh Script 资源类。 */ + export class _Script extends Asset { + } + /** !#en Class for JavaScript handling. + !#zh JavaScript 资源类。 */ + export class _JavaScript extends Asset { + } + /** !#en Class for TypeScript handling. + !#zh TypeScript 资源类。 */ + export class TypeScript extends Asset { + } + /** !#en Class for sprite atlas handling. + !#zh 精灵图集资源类。 */ + export class SpriteAtlas extends Asset { + /** + Returns the texture of the sprite atlas + */ + getTexture(): Texture2D; + /** + Returns the sprite frame correspond to the given key in sprite atlas. + @param key key + */ + getSpriteFrame(key: string): SpriteFrame; + /** + Returns the sprite frames in sprite atlas. + */ + getSpriteFrames(): SpriteFrame[]; + } + /** !#en + A cc.SpriteFrame has:
+ - texture: A cc.Texture2D that will be used by render components
+ - rectangle: A rectangle of the texture + + !#zh + 一个 SpriteFrame 包含:
+ - 纹理:会被渲染组件使用的 Texture2D 对象。
+ - 矩形:在纹理中的矩形区域。 */ + export class SpriteFrame extends Asset implements EventTarget { + /** !#en Top border of the sprite + !#zh sprite 的顶部边框 */ + insetTop: number; + /** !#en Bottom border of the sprite + !#zh sprite 的底部边框 */ + insetBottom: number; + /** !#en Left border of the sprite + !#zh sprite 的左边边框 */ + insetLeft: number; + /** !#en Right border of the sprite + !#zh sprite 的左边边框 */ + insetRight: number; + /** + !#en + Constructor of SpriteFrame class. + !#zh + SpriteFrame 类的构造函数。 + @param filename filename + @param rect rect + @param rotated Whether the frame is rotated in the texture + @param offset The offset of the frame in the texture + @param originalSize The size of the frame in the texture + */ + constructor(filename?: string|Texture2D, rect?: Rect, rotated?: boolean, offset?: Vec2, originalSize?: Size); + /** + !#en Returns whether the texture have been loaded + !#zh 返回是否已加载纹理 + */ + textureLoaded(): boolean; + /** + !#en Returns whether the sprite frame is rotated in the texture. + !#zh 获取 SpriteFrame 是否旋转 + */ + isRotated(): boolean; + /** + !#en Set whether the sprite frame is rotated in the texture. + !#zh 设置 SpriteFrame 是否旋转 + @param bRotated bRotated + */ + setRotated(bRotated: boolean): void; + /** + !#en Returns whether the sprite frame is flip x axis in the texture. + !#zh 获取 SpriteFrame 是否反转 x 轴 + */ + isFlipX(): boolean; + /** + !#en Returns whether the sprite frame is flip y axis in the texture. + !#zh 获取 SpriteFrame 是否反转 y 轴 + */ + isFlipY(): boolean; + /** + !#en Set whether the sprite frame is flip x axis in the texture. + !#zh 设置 SpriteFrame 是否翻转 x 轴 + @param flipX flipX + */ + setFlipX(flipX: boolean): void; + /** + !#en Set whether the sprite frame is flip y axis in the texture. + !#zh 设置 SpriteFrame 是否翻转 y 轴 + @param flipY flipY + */ + setFlipY(flipY: boolean): void; + /** + !#en Returns the rect of the sprite frame in the texture. + !#zh 获取 SpriteFrame 的纹理矩形区域 + */ + getRect(): Rect; + /** + !#en Sets the rect of the sprite frame in the texture. + !#zh 设置 SpriteFrame 的纹理矩形区域 + @param rect rect + */ + setRect(rect: Rect): void; + /** + !#en Returns the original size of the trimmed image. + !#zh 获取修剪前的原始大小 + */ + getOriginalSize(): Size; + /** + !#en Sets the original size of the trimmed image. + !#zh 设置修剪前的原始大小 + @param size size + */ + setOriginalSize(size: Size): void; + /** + !#en Returns the texture of the frame. + !#zh 获取使用的纹理实例 + */ + getTexture(): Texture2D; + /** + !#en Returns the offset of the frame in the texture. + !#zh 获取偏移量 + */ + getOffset(): Vec2; + /** + !#en Sets the offset of the frame in the texture. + !#zh 设置偏移量 + @param offsets offsets + */ + setOffset(offsets: Vec2): void; + /** + !#en Clone the sprite frame. + !#zh 克隆 SpriteFrame + */ + clone(): SpriteFrame; + /** + !#en Set SpriteFrame with Texture, rect, rotated, offset and originalSize.
+ !#zh 通过 Texture,rect,rotated,offset 和 originalSize 设置 SpriteFrame。 + @param texture texture + @param rect rect + @param rotated rotated + @param offset offset + @param originalSize originalSize + */ + setTexture(texture: Texture2D, rect?: Rect, rotated?: boolean, offset?: Vec2, originalSize?: Size): boolean; + /** + !#en If a loading scene (or prefab) is marked as `asyncLoadAssets`, all the textures of the SpriteFrame which + associated by user's custom Components in the scene, will not preload automatically. + These textures will be load when Sprite component is going to render the SpriteFrames. + You can call this method if you want to load the texture early. + !#zh 当加载中的场景或 Prefab 被标记为 `asyncLoadAssets` 时,用户在场景中由自定义组件关联到的所有 SpriteFrame 的贴图都不会被提前加载。 + 只有当 Sprite 组件要渲染这些 SpriteFrame 时,才会检查贴图是否加载。如果你希望加载过程提前,你可以手工调用这个方法。 + + @example + ```js + if (spriteFrame.textureLoaded()) { + this._onSpriteFrameLoaded(); + } + else { + spriteFrame.once('load', this._onSpriteFrameLoaded, this); + spriteFrame.ensureLoadTexture(); + } + ``` + */ + ensureLoadTexture(): void; + /** + !#en + If you do not need to use the SpriteFrame temporarily, you can call this method so that its texture could be garbage collected. Then when you need to render the SpriteFrame, you should call `ensureLoadTexture` manually to reload texture. + !#zh + 当你暂时不再使用这个 SpriteFrame 时,可以调用这个方法来保证引用的贴图对象能被 GC。然后当你要渲染 SpriteFrame 时,你需要手动调用 `ensureLoadTexture` 来重新加载贴图。 + */ + clearTexture(): void; + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en + Register an callback of a specific event type on the EventTarget. + This type of event should be triggered via `emit`. + !#zh + 注册事件目标的特定事件类型回调。这种类型的事件应该被 `emit` 触发。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, node); + ``` + */ + on(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. + !#zh + 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + + @example + ```js + // register fire eventListener + var callback = eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, target); + // remove fire event listener + eventTarget.off('fire', callback, target); + // remove all fire event listeners + eventTarget.off('fire'); + ``` + */ + off(type: string, callback?: Function, target?: any): void; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.once('fire', function () { + cc.log("this is the callback and will be invoked only once"); + }, node); + ``` + */ + once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; + /** + !#en + Send an event with the event object. + !#zh + 通过事件对象派发事件 + @param event event + */ + dispatchEvent(event: Event): void; + } + /** !#en Class for TTFFont handling. + !#zh TTF 字体资源类。 */ + export class TTFFont extends Font { + } + /** !#en Class for text file. + !#zh 文本资源类。 */ + export class TextAsset extends Asset { + /** The text contents of the resource. */ + text: string; + } + /** This class allows to easily create OpenGL or Canvas 2D textures from images or raw data. */ + export class Texture2D extends Asset implements EventTarget { + /** !#en Sets whether generate mipmaps for the texture + !#zh 是否为纹理设置生成 mipmaps。 */ + genMipmaps: boolean; + /** !#en + Sets whether texture can be packed into texture atlas. + If need use texture uv in custom Effect, please sets packable to false. + !#zh + 设置纹理是否允许参与合图。 + 如果需要在自定义 Effect 中使用纹理 UV,需要禁止该选项。 */ + packable: boolean; + /** !#en + Whether the texture is loaded or not + !#zh + 贴图是否已经成功加载 */ + loaded: boolean; + /** !#en + Texture width in pixel + !#zh + 贴图像素宽度 */ + width: number; + /** !#en + Texture height in pixel + !#zh + 贴图像素高度 */ + height: number; + /** + !#en + Get renderer texture implementation object + extended from render.Texture2D + !#zh 返回渲染器内部贴图对象 + */ + getImpl(): void; + /** + Update texture options, not available in Canvas render mode. + image, format, premultiplyAlpha can not be updated in native. + @param options options + */ + update(options: {image: DOMImageElement; genMipmaps: boolean; format: Texture2D.PixelFormat; minFilter: Texture2D.Filter; magFilter: Texture2D.Filter; wrapS: WrapMode; wrapT: WrapMode; premultiplyAlpha: boolean; }): void; + /** + !#en + Init with HTML element. + !#zh 用 HTML Image 或 Canvas 对象初始化贴图。 + @param element element + + @example + ```js + var img = new Image(); + img.src = dataURL; + texture.initWithElement(img); + ``` + */ + initWithElement(element: HTMLImageElement|HTMLCanvasElement): void; + /** + !#en + Intializes with texture data in ArrayBufferView. + !#zh 使用一个存储在 ArrayBufferView 中的图像数据(raw data)初始化数据。 + @param data data + @param pixelFormat pixelFormat + @param pixelsWidth pixelsWidth + @param pixelsHeight pixelsHeight + */ + initWithData(data: ArrayBufferView, pixelFormat: number, pixelsWidth: number, pixelsHeight: number): boolean; + /** + !#en + HTMLElement Object getter, available only on web.
+ Note: texture is packed into texture atlas by default
+ you should set texture.packable as false before getting Html element object. + !#zh 获取当前贴图对应的 HTML Image 或 Canvas 对象,只在 Web 平台下有效。
+ 注意:
+ texture 默认参与动态合图,如果需要获取到正确的 Html 元素对象,需要先设置 texture.packable 为 false + */ + getHtmlElementObj(): HTMLImageElement; + /** + !#en + Destory this texture and immediately release its video memory. (Inherit from cc.Object.destroy)
+ After destroy, this object is not usable anymore. + You can use cc.isValid(obj) to check whether the object is destroyed before accessing it. + !#zh + 销毁该贴图,并立即释放它对应的显存。(继承自 cc.Object.destroy)
+ 销毁后,该对象不再可用。您可以在访问对象之前使用 cc.isValid(obj) 来检查对象是否已被销毁。 + */ + destroy(): boolean; + /** + !#en + Pixel format of the texture. + !#zh 获取纹理的像素格式。 + */ + getPixelFormat(): number; + /** + !#en + Whether or not the texture has their Alpha premultiplied. + !#zh 检查纹理在上传 GPU 时预乘选项是否开启。 + */ + hasPremultipliedAlpha(): boolean; + /** + !#en + Handler of texture loaded event. + Since v2.0, you don't need to invoke this function, it will be invoked automatically after texture loaded. + !#zh 贴图加载事件处理器。v2.0 之后你将不在需要手动执行这个函数,它会在贴图加载成功之后自动执行。 + @param premultiplied premultiplied + */ + handleLoadedTexture(premultiplied?: boolean): void; + /** + !#en + Description of cc.Texture2D. + !#zh cc.Texture2D 描述。 + */ + description(): string; + /** + !#en + Release texture, please use destroy instead. + !#zh 释放纹理,请使用 destroy 替代。 + */ + releaseTexture(): void; + /** + !#en Sets the wrap s and wrap t options.
+ If the texture size is NPOT (non power of 2), then in can only use gl.CLAMP_TO_EDGE in gl.TEXTURE_WRAP_{S,T}. + !#zh 设置纹理包装模式。 + 若纹理贴图尺寸是 NPOT(non power of 2),则只能使用 Texture2D.WrapMode.CLAMP_TO_EDGE。 + @param wrapS wrapS + @param wrapT wrapT + */ + setTexParameters(wrapS: Texture2D.WrapMode, wrapT: Texture2D.WrapMode): void; + /** + !#en Sets the minFilter and magFilter options + !#zh 设置纹理贴图缩小和放大过滤器算法选项。 + @param minFilter minFilter + @param magFilter magFilter + */ + setFilters(minFilter: Texture2D.Filter, magFilter: Texture2D.Filter): void; + /** + !#en + Sets the flipY options + !#zh 设置贴图的纵向翻转选项。 + @param flipY flipY + */ + setFlipY(flipY: boolean): void; + /** + !#en + Sets the premultiply alpha options + !#zh 设置贴图的预乘选项。 + @param premultiply premultiply + */ + setPremultiplyAlpha(premultiply: boolean): void; + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en + Register an callback of a specific event type on the EventTarget. + This type of event should be triggered via `emit`. + !#zh + 注册事件目标的特定事件类型回调。这种类型的事件应该被 `emit` 触发。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, node); + ``` + */ + on(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. + !#zh + 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + + @example + ```js + // register fire eventListener + var callback = eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, target); + // remove fire event listener + eventTarget.off('fire', callback, target); + // remove all fire event listeners + eventTarget.off('fire'); + ``` + */ + off(type: string, callback?: Function, target?: any): void; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.once('fire', function () { + cc.log("this is the callback and will be invoked only once"); + }, node); + ``` + */ + once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; + /** + !#en + Send an event with the event object. + !#zh + 通过事件对象派发事件 + @param event event + */ + dispatchEvent(event: Event): void; + } + /** !#en The touch event class + !#zh 封装了触摸相关的信息。 */ + export class Touch { + /** + !#en Returns the current touch location in OpenGL coordinates.、 + !#zh 获取当前触点位置。 + */ + getLocation(): Vec2; + /** + !#en Returns X axis location value. + !#zh 获取当前触点 X 轴位置。 + */ + getLocationX(): number; + /** + !#en Returns Y axis location value. + !#zh 获取当前触点 Y 轴位置。 + */ + getLocationY(): number; + /** + !#en Returns the previous touch location in OpenGL coordinates. + !#zh 获取触点在上一次事件时的位置对象,对象包含 x 和 y 属性。 + */ + getPreviousLocation(): Vec2; + /** + !#en Returns the start touch location in OpenGL coordinates. + !#zh 获取触点落下时的位置对象,对象包含 x 和 y 属性。 + */ + getStartLocation(): Vec2; + /** + !#en Returns the delta distance from the previous touche to the current one in screen coordinates. + !#zh 获取触点距离上一次事件移动的距离对象,对象包含 x 和 y 属性。 + */ + getDelta(): Vec2; + /** + !#en Returns the current touch location in screen coordinates. + !#zh 获取当前事件在游戏窗口内的坐标位置对象,对象包含 x 和 y 属性。 + */ + getLocationInView(): Vec2; + /** + !#en Returns the previous touch location in screen coordinates. + !#zh 获取触点在上一次事件时在游戏窗口中的位置对象,对象包含 x 和 y 属性。 + */ + getPreviousLocationInView(): Vec2; + /** + !#en Returns the start touch location in screen coordinates. + !#zh 获取触点落下时在游戏窗口中的位置对象,对象包含 x 和 y 属性。 + */ + getStartLocationInView(): Vec2; + /** + !#en Returns the id of cc.Touch. + !#zh 触点的标识 ID,可以用来在多点触摸中跟踪触点。 + */ + getID(): number; + /** + !#en Sets information to touch. + !#zh 设置触摸相关的信息。用于监控触摸事件。 + @param id id + @param x x + @param y y + */ + setTouchInfo(id: number, x: number, y: number): void; + } + /** !#en Base class of all kinds of events. + !#zh 包含事件相关信息的对象。 */ + export class Event { + /** + + @param type The name of the event (case-sensitive), e.g. "click", "fire", or "submit" + @param bubbles A boolean indicating whether the event bubbles up through the tree or not + */ + constructor(type: string, bubbles: boolean); + /** !#en The name of the event (case-sensitive), e.g. "click", "fire", or "submit". + !#zh 事件类型。 */ + type: string; + /** !#en Indicate whether the event bubbles up through the tree or not. + !#zh 表示该事件是否进行冒泡。 */ + bubbles: boolean; + /** !#en A reference to the target to which the event was originally dispatched. + !#zh 最初事件触发的目标 */ + target: any; + /** !#en A reference to the currently registered target for the event. + !#zh 当前目标 */ + currentTarget: any; + /** !#en + Indicates which phase of the event flow is currently being evaluated. + Returns an integer value represented by 4 constants: + - Event.NONE = 0 + - Event.CAPTURING_PHASE = 1 + - Event.AT_TARGET = 2 + - Event.BUBBLING_PHASE = 3 + The phases are explained in the [section 3.1, Event dispatch and DOM event flow] + (http://www.w3.org/TR/DOM-Level-3-Events/#event-flow), of the DOM Level 3 Events specification. + !#zh 事件阶段 */ + eventPhase: number; + /** + !#en Reset the event for being stored in the object pool. + !#zh 重置对象池中存储的事件。 + */ + unuse(): string; + /** + !#en Reuse the event for being used again by the object pool. + !#zh 用于对象池再次使用的事件。 + */ + reuse(): string; + /** + !#en Stops propagation for current event. + !#zh 停止传递当前事件。 + */ + stopPropagation(): void; + /** + !#en Stops propagation for current event immediately, + the event won't even be dispatched to the listeners attached in the current target. + !#zh 立即停止当前事件的传递,事件甚至不会被分派到所连接的当前目标。 + */ + stopPropagationImmediate(): void; + /** + !#en Checks whether the event has been stopped. + !#zh 检查该事件是否已经停止传递. + */ + isStopped(): boolean; + /** + !#en +

+ Gets current target of the event
+ note: It only be available when the event listener is associated with node.
+ It returns 0 when the listener is associated with fixed priority. +

+ !#zh 获取当前目标节点 + */ + getCurrentTarget(): Node; + /** + !#en Gets the event type. + !#zh 获取事件类型 + */ + getType(): string; + /** !#en Code for event without type. + !#zh 没有类型的事件 */ + static NO_TYPE: string; + /** !#en The type code of Touch event. + !#zh 触摸事件类型 */ + static TOUCH: string; + /** !#en The type code of Mouse event. + !#zh 鼠标事件类型 */ + static MOUSE: string; + /** !#en The type code of Keyboard event. + !#zh 键盘事件类型 */ + static KEYBOARD: string; + /** !#en The type code of Acceleration event. + !#zh 加速器事件类型 */ + static ACCELERATION: string; + /** !#en Events not currently dispatched are in this phase + !#zh 尚未派发事件阶段 */ + static NONE: number; + /** !#en + The capturing phase comprises the journey from the root to the last node before the event target's node + see http://www.w3.org/TR/DOM-Level-3-Events/#event-flow + !#zh 捕获阶段,包括事件目标节点之前从根节点到最后一个节点的过程。 */ + static CAPTURING_PHASE: number; + /** !#en + The target phase comprises only the event target node + see http://www.w3.org/TR/DOM-Level-3-Events/#event-flow + !#zh 目标阶段仅包括事件目标节点。 */ + static AT_TARGET: number; + /** !#en + The bubbling phase comprises any subsequent nodes encountered on the return trip to the root of the hierarchy + see http://www.w3.org/TR/DOM-Level-3-Events/#event-flow + !#zh 冒泡阶段, 包括回程遇到到层次根节点的任何后续节点。 */ + static BUBBLING_PHASE: number; + } + /** !#en + EventTarget is an object to which an event is dispatched when something has occurred. + Entity are the most common event targets, but other objects can be event targets too. + + Event targets are an important part of the Fireball event model. + The event target serves as the focal point for how events flow through the scene graph. + When an event such as a mouse click or a keypress occurs, Fireball dispatches an event object + into the event flow from the root of the hierarchy. The event object then makes its way through + the scene graph until it reaches the event target, at which point it begins its return trip through + the scene graph. This round-trip journey to the event target is conceptually divided into three phases: + - The capture phase comprises the journey from the root to the last node before the event target's node + - The target phase comprises only the event target node + - The bubbling phase comprises any subsequent nodes encountered on the return trip to the root of the tree + See also: http://www.w3.org/TR/DOM-Level-3-Events/#event-flow + + Event targets can implement the following methods: + - _getCapturingTargets + - _getBubblingTargets + + !#zh + 事件目标是事件触发时,分派的事件对象,Node 是最常见的事件目标, + 但是其他对象也可以是事件目标。
*/ + export class EventTarget extends CallbacksInvoker { + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en + Register an callback of a specific event type on the EventTarget. + This type of event should be triggered via `emit`. + !#zh + 注册事件目标的特定事件类型回调。这种类型的事件应该被 `emit` 触发。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, node); + ``` + */ + on(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. + !#zh + 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + + @example + ```js + // register fire eventListener + var callback = eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, target); + // remove fire event listener + eventTarget.off('fire', callback, target); + // remove all fire event listeners + eventTarget.off('fire'); + ``` + */ + off(type: string, callback?: Function, target?: any): void; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.once('fire', function () { + cc.log("this is the callback and will be invoked only once"); + }, node); + ``` + */ + once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; + /** + !#en + Send an event with the event object. + !#zh + 通过事件对象派发事件 + @param event event + */ + dispatchEvent(event: Event): void; + } + /** !#en + The System event, it currently supports keyboard events and accelerometer events.
+ You can get the SystemEvent instance with cc.systemEvent.
+ !#zh + 系统事件,它目前支持按键事件和重力感应事件。
+ 你可以通过 cc.systemEvent 获取到 SystemEvent 的实例。
*/ + export class SystemEvent extends EventTarget { + /** + !#en whether enable accelerometer event + !#zh 是否启用加速度计事件 + @param isEnable isEnable + */ + setAccelerometerEnabled(isEnable: boolean): void; + /** + !#en set accelerometer interval value + !#zh 设置加速度计间隔值 + @param interval interval + */ + setAccelerometerInterval(interval: number): void; + } + /** undefined */ + export class Graphics extends RenderComponent { + /** !#en + Current line width. + !#zh + 当前线条宽度 */ + lineWidth: number; + /** !#en + lineJoin determines how two connecting segments (of lines, arcs or curves) with non-zero lengths in a shape are joined together. + !#zh + lineJoin 用来设置2个长度不为0的相连部分(线段,圆弧,曲线)如何连接在一起的属性。 */ + lineJoin: Graphics.LineJoin; + /** !#en + lineCap determines how the end points of every line are drawn. + !#zh + lineCap 指定如何绘制每一条线段末端。 */ + lineCap: Graphics.LineCap; + /** !#en + stroke color + !#zh + 线段颜色 */ + strokeColor: Color; + /** !#en + fill color + !#zh + 填充颜色 */ + fillColor: Color; + /** !#en + Sets the miter limit ratio + !#zh + 设置斜接面限制比例 */ + miterLimit: number; + /** + !#en Move path start point to (x,y). + !#zh 移动路径起点到坐标(x, y) + @param x The x axis of the coordinate for the end point. + @param y The y axis of the coordinate for the end point. + */ + moveTo(x?: number, y?: number): void; + /** + !#en Adds a straight line to the path + !#zh 绘制直线路径 + @param x The x axis of the coordinate for the end point. + @param y The y axis of the coordinate for the end point. + */ + lineTo(x?: number, y?: number): void; + /** + !#en Adds a cubic Bézier curve to the path + !#zh 绘制三次贝赛尔曲线路径 + @param c1x The x axis of the coordinate for the first control point. + @param c1y The y axis of the coordinate for first control point. + @param c2x The x axis of the coordinate for the second control point. + @param c2y The y axis of the coordinate for the second control point. + @param x The x axis of the coordinate for the end point. + @param y The y axis of the coordinate for the end point. + */ + bezierCurveTo(c1x?: number, c1y?: number, c2x?: number, c2y?: number, x?: number, y?: number): void; + /** + !#en Adds a quadratic Bézier curve to the path + !#zh 绘制二次贝赛尔曲线路径 + @param cx The x axis of the coordinate for the control point. + @param cy The y axis of the coordinate for the control point. + @param x The x axis of the coordinate for the end point. + @param y The y axis of the coordinate for the end point. + */ + quadraticCurveTo(cx?: number, cy?: number, x?: number, y?: number): void; + /** + !#en Adds an arc to the path which is centered at (cx, cy) position with radius r starting at startAngle and ending at endAngle going in the given direction by counterclockwise (defaulting to false). + !#zh 绘制圆弧路径。圆弧路径的圆心在 (cx, cy) 位置,半径为 r ,根据 counterclockwise (默认为false)指定的方向从 startAngle 开始绘制,到 endAngle 结束。 + @param cx The x axis of the coordinate for the center point. + @param cy The y axis of the coordinate for the center point. + @param r The arc's radius. + @param startAngle The angle at which the arc starts, measured clockwise from the positive x axis and expressed in radians. + @param endAngle The angle at which the arc ends, measured clockwise from the positive x axis and expressed in radians. + @param counterclockwise An optional Boolean which, if true, causes the arc to be drawn counter-clockwise between the two angles. By default it is drawn clockwise. + */ + arc(cx?: number, cy?: number, r?: number, startAngle?: number, endAngle?: number, counterclockwise?: boolean): void; + /** + !#en Adds an ellipse to the path. + !#zh 绘制椭圆路径。 + @param cx The x axis of the coordinate for the center point. + @param cy The y axis of the coordinate for the center point. + @param rx The ellipse's x-axis radius. + @param ry The ellipse's y-axis radius. + */ + ellipse(cx?: number, cy?: number, rx?: number, ry?: number): void; + /** + !#en Adds an circle to the path. + !#zh 绘制圆形路径。 + @param cx The x axis of the coordinate for the center point. + @param cy The y axis of the coordinate for the center point. + @param r The circle's radius. + */ + circle(cx?: number, cy?: number, r?: number): void; + /** + !#en Adds an rectangle to the path. + !#zh 绘制矩形路径。 + @param x The x axis of the coordinate for the rectangle starting point. + @param y The y axis of the coordinate for the rectangle starting point. + @param w The rectangle's width. + @param h The rectangle's height. + */ + rect(x?: number, y?: number, w?: number, h?: number): void; + /** + !#en Adds an round corner rectangle to the path. + !#zh 绘制圆角矩形路径。 + @param x The x axis of the coordinate for the rectangle starting point. + @param y The y axis of the coordinate for the rectangle starting point. + @param w The rectangles width. + @param h The rectangle's height. + @param r The radius of the rectangle. + */ + roundRect(x?: number, y?: number, w?: number, h?: number, r?: number): void; + /** + !#en Draws a filled rectangle. + !#zh 绘制填充矩形。 + @param x The x axis of the coordinate for the rectangle starting point. + @param y The y axis of the coordinate for the rectangle starting point. + @param w The rectangle's width. + @param h The rectangle's height. + */ + fillRect(x?: number, y?: number, w?: number, h?: number): void; + /** + !#en Erasing any previously drawn content. + !#zh 擦除之前绘制的所有内容的方法。 + @param clean Whether to clean the graphics inner cache. + */ + clear(clean?: boolean): void; + /** + !#en Causes the point of the pen to move back to the start of the current path. It tries to add a straight line from the current point to the start. + !#zh 将笔点返回到当前路径起始点的。它尝试从当前点到起始点绘制一条直线。 + */ + close(): void; + /** + !#en Strokes the current or given path with the current stroke style. + !#zh 根据当前的画线样式,绘制当前或已经存在的路径。 + */ + stroke(): void; + /** + !#en Fills the current or given path with the current fill style. + !#zh 根据当前的画线样式,填充当前或已经存在的路径。 + */ + fill(): void; + } + /** undefined */ + export class WorldManifold { + /** !#en + world contact point (point of intersection) + !#zh + 碰撞点集合 */ + points: Vec2[]; + /** !#en + world vector pointing from A to B + !#zh + 世界坐标系下由 A 指向 B 的向量 */ + normal: Vec2; + } + /** !#en + A manifold point is a contact point belonging to a contact manifold. + It holds details related to the geometry and dynamics of the contact points. + Note: the impulses are used for internal caching and may not + provide reliable contact forces, especially for high speed collisions. + !#zh + ManifoldPoint 是接触信息中的接触点信息。它拥有关于几何和接触点的详细信息。 + 注意:信息中的冲量用于系统内部缓存,提供的接触力可能不是很准确,特别是高速移动中的碰撞信息。 */ + export class ManifoldPoint { + /** !#en + The local point usage depends on the manifold type: + -e_circles: the local center of circleB + -e_faceA: the local center of circleB or the clip point of polygonB + -e_faceB: the clip point of polygonA + !#zh + 本地坐标点的用途取决于 manifold 的类型 + - e_circles: circleB 的本地中心点 + - e_faceA: circleB 的本地中心点 或者是 polygonB 的截取点 + - e_faceB: polygonB 的截取点 */ + localPoint: Vec2; + /** !#en + Normal impulse. + !#zh + 法线冲量。 */ + normalImpulse: number; + /** !#en + Tangent impulse. + !#zh + 切线冲量。 */ + tangentImpulse: number; + } + /** undefined */ + export class Manifold { + /** !#en + Manifold type : 0: e_circles, 1: e_faceA, 2: e_faceB + !#zh + Manifold 类型 : 0: e_circles, 1: e_faceA, 2: e_faceB */ + type: number; + /** !#en + The local point usage depends on the manifold type: + -e_circles: the local center of circleA + -e_faceA: the center of faceA + -e_faceB: the center of faceB + !#zh + 用途取决于 manifold 类型 + -e_circles: circleA 的本地中心点 + -e_faceA: faceA 的本地中心点 + -e_faceB: faceB 的本地中心点 */ + localPoint: Vec2; + /** !#en + -e_circles: not used + -e_faceA: the normal on polygonA + -e_faceB: the normal on polygonB + !#zh + -e_circles: 没被使用到 + -e_faceA: polygonA 的法向量 + -e_faceB: polygonB 的法向量 */ + localNormal: Vec2; + /** !#en + the points of contact. + !#zh + 接触点信息。 */ + points: ManifoldPoint[]; + } + /** !#en + Contact impulses for reporting. + !#zh + 用于返回给回调的接触冲量。 */ + export class PhysicsImpulse { + /** !#en + Normal impulses. + !#zh + 法线方向的冲量 */ + normalImpulses: any; + /** !#en + Tangent impulses + !#zh + 切线方向的冲量 */ + tangentImpulses: any; + } + /** !#en + PhysicsContact will be generated during begin and end collision as a parameter of the collision callback. + Note that contacts will be reused for speed up cpu time, so do not cache anything in the contact. + !#zh + 物理接触会在开始和结束碰撞之间生成,并作为参数传入到碰撞回调函数中。 + 注意:传入的物理接触会被系统进行重用,所以不要在使用中缓存里面的任何信息。 */ + export class PhysicsContact { + /** + !#en + Get the world manifold. + !#zh + 获取世界坐标系下的碰撞信息。 + */ + getWorldManifold(): WorldManifold; + /** + !#en + Get the manifold. + !#zh + 获取本地(局部)坐标系下的碰撞信息。 + */ + getManifold(): Manifold; + /** + !#en + Get the impulses. + Note: PhysicsImpulse can only used in onPostSolve callback. + !#zh + 获取冲量信息 + 注意:这个信息只有在 onPostSolve 回调中才能获取到 + */ + getImpulse(): PhysicsImpulse; + /** !#en + One of the collider that collided + !#zh + 发生碰撞的碰撞体之一 */ + colliderA: Collider; + /** !#en + One of the collider that collided + !#zh + 发生碰撞的碰撞体之一 */ + colliderB: Collider; + /** !#en + If set disabled to true, the contact will be ignored until contact end. + If you just want to disabled contact for current time step or sub-step, please use disabledOnce. + !#zh + 如果 disabled 被设置为 true,那么直到接触结束此接触都将被忽略。 + 如果只是希望在当前时间步或子步中忽略此接触,请使用 disabledOnce 。 */ + disabled: boolean; + /** !#en + Disabled contact for current time step or sub-step. + !#zh + 在当前时间步或子步中忽略此接触。 */ + disabledOnce: boolean; + /** + !#en + Is this contact touching? + !#zh + 返回碰撞体是否已经接触到。 + */ + isTouching(): boolean; + /** + !#en + Set the desired tangent speed for a conveyor belt behavior. + !#zh + 为传送带设置期望的切线速度 + @param tangentSpeed tangentSpeed + */ + setTangentSpeed(tangentSpeed: number): void; + /** + !#en + Get the desired tangent speed. + !#zh + 获取切线速度 + */ + getTangentSpeed(): number; + /** + !#en + Override the default friction mixture. You can call this in onPreSolve callback. + !#zh + 覆盖默认的摩擦力系数。你可以在 onPreSolve 回调中调用此函数。 + @param friction friction + */ + setFriction(friction: number): void; + /** + !#en + Get the friction. + !#zh + 获取当前摩擦力系数 + */ + getFriction(): number; + /** + !#en + Reset the friction mixture to the default value. + !#zh + 重置摩擦力系数到默认值 + */ + resetFriction(): void; + /** + !#en + Override the default restitution mixture. You can call this in onPreSolve callback. + !#zh + 覆盖默认的恢复系数。你可以在 onPreSolve 回调中调用此函数。 + @param restitution restitution + */ + setRestitution(restitution: number): void; + /** + !#en + Get the restitution. + !#zh + 获取当前恢复系数 + */ + getRestitution(): number; + /** + !#en + Reset the restitution mixture to the default value. + !#zh + 重置恢复系数到默认值 + */ + resetRestitution(): void; + } + /** !#en + Physics manager uses box2d as the inner physics system, and hide most box2d implement details(creating rigidbody, synchronize rigidbody info to node). + You can visit some common box2d function through physics manager(hit testing, raycast, debug info). + Physics manager distributes the collision information to each collision callback when collision is produced. + Note: You need first enable the collision listener in the rigidbody. + !#zh + 物理系统将 box2d 作为内部物理系统,并且隐藏了大部分 box2d 实现细节(比如创建刚体,同步刚体信息到节点中等)。 + 你可以通过物理系统访问一些 box2d 常用的功能,比如点击测试,射线测试,设置测试信息等。 + 物理系统还管理碰撞信息的分发,她会在产生碰撞时,将碰撞信息分发到各个碰撞回调中。 + 注意:你需要先在刚体中开启碰撞接听才会产生相应的碰撞回调。
+ 支持的物理系统指定绘制信息事件,请参阅 {{#crossLink "PhysicsManager.DrawBits"}}{{/crossLink}} */ + export class PhysicsManager implements EventTarget { + /** !#en + The ratio transform between physics unit and pixel unit, generally is 32. + !#zh + 物理单位与像素单位互相转换的比率,一般是 32。 */ + static PTM_RATIO: number; + /** !#en + The velocity iterations for the velocity constraint solver. + !#zh + 速度更新迭代数 */ + static VELOCITY_ITERATIONS: number; + /** !#en + The position Iterations for the position constraint solver. + !#zh + 位置迭代更新数 */ + static POSITION_ITERATIONS: number; + /** !#en + Specify the fixed time step. + Need enabledAccumulator to make it work. + !#zh + 指定固定的物理更新间隔时间,需要开启 enabledAccumulator 才有效。 */ + static FIXED_TIME_STEP: number; + /** !#en + Specify the max accumulator time. + Need enabledAccumulator to make it work. + !#zh + 每次可用于更新物理系统的最大时间,需要开启 enabledAccumulator 才有效。 */ + static MAX_ACCUMULATOR: number; + /** !#en + If enabled accumulator, then will call step function with the fixed time step FIXED_TIME_STEP. + And if the update dt is bigger than the time step, then will call step function several times. + If disabled accumulator, then will call step function with a time step calculated with the frame rate. + !#zh + 如果开启此选项,那么将会以固定的间隔时间 FIXED_TIME_STEP 来更新物理引擎,如果一个 update 的间隔时间大于 FIXED_TIME_STEP,则会对物理引擎进行多次更新。 + 如果关闭此选项,那么将会根据设定的 frame rate 计算出一个间隔时间来更新物理引擎。 */ + enabledAccumulator: boolean; + /** + !#en + Test which collider contains the given world point + !#zh + 获取包含给定世界坐标系点的碰撞体 + @param point the world point + */ + testPoint(point: Vec2): PhysicsCollider; + /** + !#en + Test which colliders intersect the given world rect + !#zh + 获取与给定世界坐标系矩形相交的碰撞体 + @param rect the world rect + */ + testAABB(rect: Rect): PhysicsCollider[]; + /** + !#en + Raycast the world for all colliders in the path of the ray. + The raycast ignores colliders that contain the starting point. + !#zh + 检测哪些碰撞体在给定射线的路径上,射线检测将忽略包含起始点的碰撞体。 + @param p1 start point of the raycast + @param p2 end point of the raycast + @param type optional, default is RayCastType.Closest + */ + rayCast(p1: Vec2, p2: Vec2, type: RayCastType): PhysicsRayCastResult[]; + /** !#en + Enabled the physics manager? + !#zh + 指定是否启用物理系统? */ + enabled: boolean; + /** !#en + Debug draw flags. + !#zh + 设置调试绘制标志 */ + debugDrawFlags: number; + /** !#en + The physics world gravity. + !#zh + 物理世界重力值 */ + gravity: Vec2; + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en + Register an callback of a specific event type on the EventTarget. + This type of event should be triggered via `emit`. + !#zh + 注册事件目标的特定事件类型回调。这种类型的事件应该被 `emit` 触发。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, node); + ``` + */ + on(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. + !#zh + 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + + @example + ```js + // register fire eventListener + var callback = eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, target); + // remove fire event listener + eventTarget.off('fire', callback, target); + // remove all fire event listeners + eventTarget.off('fire'); + ``` + */ + off(type: string, callback?: Function, target?: any): void; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.once('fire', function () { + cc.log("this is the callback and will be invoked only once"); + }, node); + ``` + */ + once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; + /** + !#en + Send an event with the event object. + !#zh + 通过事件对象派发事件 + @param event event + */ + dispatchEvent(event: Event): void; + } + /** undefined */ + export class PhysicsRayCastResult { + /** !#en + The PhysicsCollider which intersects with the raycast + !#zh + 与射线相交的碰撞体 */ + collider: PhysicsCollider; + /** !#en + The intersection point + !#zh + 射线与碰撞体相交的点 */ + point: Vec2; + /** !#en + The normal vector at the point of intersection + !#zh + 射线与碰撞体相交的点的法向量 */ + normal: Vec2; + /** !#en + The fraction of the raycast path at the point of intersection + !#zh + 射线与碰撞体相交的点占射线长度的分数 */ + fraction: number; + } + /** !#en Enum for RigidBodyType. + !#zh 刚体类型 */ + export enum RigidBodyType { + Static = 0, + Kinematic = 0, + Dynamic = 0, + Animated = 0, + } + /** !#en Enum for RayCastType. + !#zh 射线检测类型 */ + export enum RayCastType { + Closest = 0, + Any = 0, + AllClosest = 0, + All = 0, + } + /** undefined */ + export class RigidBody extends Component { + /** !#en + Should enabled contact listener? + When a collision is trigger, the collision callback will only be called when enabled contact listener. + !#zh + 是否启用接触接听器。 + 当 collider 产生碰撞时,只有开启了接触接听器才会调用相应的回调函数 */ + enabledContactListener: boolean; + /** + !#en + Collision callback. + Called when two collider begin to touch. + !#zh + 碰撞回调。 + 如果你的脚本中实现了这个函数,那么它将会在两个碰撞体开始接触时被调用。 + @param contact contact information + @param selfCollider the collider belong to this rigidbody + @param otherCollider the collider belong to another rigidbody + */ + onBeginContact(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void; + /** + !#en + Collision callback. + Called when two collider cease to touch. + !#zh + 碰撞回调。 + 如果你的脚本中实现了这个函数,那么它将会在两个碰撞体停止接触时被调用。 + @param contact contact information + @param selfCollider the collider belong to this rigidbody + @param otherCollider the collider belong to another rigidbody + */ + onEndContact(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void; + /** + !#en + Collision callback. + This is called when a contact is updated. + This allows you to inspect a contact before it goes to the solver(e.g. disable contact). + Note: this is called only for awake bodies. + Note: this is called even when the number of contact points is zero. + Note: this is not called for sensors. + !#zh + 碰撞回调。 + 如果你的脚本中实现了这个函数,那么它将会在接触更新时被调用。 + 你可以在接触被处理前根据他包含的信息作出相应的处理,比如将这个接触禁用掉。 + 注意:回调只会为醒着的刚体调用。 + 注意:接触点为零的时候也有可能被调用。 + 注意:感知体(sensor)的回调不会被调用。 + @param contact contact information + @param selfCollider the collider belong to this rigidbody + @param otherCollider the collider belong to another rigidbody + */ + onPreSolve(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void; + /** + !#en + Collision callback. + This is called after a contact is updated. + You can get the impulses from the contact in this callback. + !#zh + 碰撞回调。 + 如果你的脚本中实现了这个函数,那么它将会在接触更新完后被调用。 + 你可以在这个回调中从接触信息中获取到冲量信息。 + @param contact contact information + @param selfCollider the collider belong to this rigidbody + @param otherCollider the collider belong to another rigidbody + */ + onPostSolve(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void; + /** !#en + Is this a fast moving body that should be prevented from tunneling through + other moving bodies? + Note : + - All bodies are prevented from tunneling through kinematic and static bodies. This setting is only considered on dynamic bodies. + - You should use this flag sparingly since it increases processing time. + !#zh + 这个刚体是否是一个快速移动的刚体,并且需要禁止穿过其他快速移动的刚体? + 需要注意的是 : + - 所有刚体都被禁止从 运动刚体 和 静态刚体 中穿过。此选项只关注于 动态刚体。 + - 应该尽量少的使用此选项,因为它会增加程序处理时间。 */ + bullet: boolean; + /** !#en + Rigidbody type : Static, Kinematic, Dynamic or Animated. + !#zh + 刚体类型: Static, Kinematic, Dynamic or Animated. */ + type: RigidBodyType; + /** !#en + Set this flag to false if this body should never fall asleep. + Note that this increases CPU usage. + !#zh + 如果此刚体永远都不应该进入睡眠,那么设置这个属性为 false。 + 需要注意这将使 CPU 占用率提高。 */ + allowSleep: boolean; + /** !#en + Scale the gravity applied to this body. + !#zh + 缩放应用在此刚体上的重力值 */ + gravityScale: number; + /** !#en + Linear damping is use to reduce the linear velocity. + The damping parameter can be larger than 1, but the damping effect becomes sensitive to the + time step when the damping parameter is large. + !#zh + Linear damping 用于衰减刚体的线性速度。衰减系数可以大于 1,但是当衰减系数比较大的时候,衰减的效果会变得比较敏感。 */ + linearDamping: number; + /** !#en + Angular damping is use to reduce the angular velocity. The damping parameter + can be larger than 1 but the damping effect becomes sensitive to the + time step when the damping parameter is large. + !#zh + Angular damping 用于衰减刚体的角速度。衰减系数可以大于 1,但是当衰减系数比较大的时候,衰减的效果会变得比较敏感。 */ + angularDamping: number; + /** !#en + The linear velocity of the body's origin in world co-ordinates. + !#zh + 刚体在世界坐标下的线性速度 */ + linearVelocity: Vec2; + /** !#en + The angular velocity of the body. + !#zh + 刚体的角速度 */ + angularVelocity: number; + /** !#en + Should this body be prevented from rotating? + !#zh + 是否禁止此刚体进行旋转 */ + fixedRotation: boolean; + /** !#en + Set the sleep state of the body. A sleeping body has very low CPU cost.(When the rigid body is hit, if the rigid body is in sleep state, it will be immediately awakened.) + !#zh + 设置刚体的睡眠状态。 睡眠的刚体具有非常低的 CPU 成本。(当刚体被碰撞到时,如果刚体处于睡眠状态,它会立即被唤醒) */ + awake: boolean; + /** !#en + Whether to wake up this rigid body during initialization + !#zh + 是否在初始化时唤醒此刚体 */ + awakeOnLoad: boolean; + /** !#en + Set the active state of the body. An inactive body is not + simulated and cannot be collided with or woken up. + If body is active, all fixtures will be added to the + broad-phase. + If body is inactive, all fixtures will be removed from + the broad-phase and all contacts will be destroyed. + Fixtures on an inactive body are implicitly inactive and will + not participate in collisions, ray-casts, or queries. + Joints connected to an inactive body are implicitly inactive. + !#zh + 设置刚体的激活状态。一个非激活状态下的刚体是不会被模拟和碰撞的,不管它是否处于睡眠状态下。 + 如果刚体处于激活状态下,所有夹具会被添加到 粗测阶段(broad-phase)。 + 如果刚体处于非激活状态下,所有夹具会被从 粗测阶段(broad-phase)中移除。 + 在非激活状态下的夹具不会参与到碰撞,射线,或者查找中 + 链接到非激活状态下刚体的关节也是非激活的。 */ + active: boolean; + /** + !#en + Gets a local point relative to the body's origin given a world point. + !#zh + 将一个给定的世界坐标系下的点转换为刚体本地坐标系下的点 + @param worldPoint a point in world coordinates. + @param out optional, the receiving point + */ + getLocalPoint(worldPoint: Vec2, out: Vec2): Vec2; + /** + !#en + Get the world coordinates of a point given the local coordinates. + !#zh + 将一个给定的刚体本地坐标系下的点转换为世界坐标系下的点 + @param localPoint a point in local coordinates. + @param out optional, the receiving point + */ + getWorldPoint(localPoint: Vec2, out: Vec2): Vec2; + /** + !#en + Get the world coordinates of a vector given the local coordinates. + !#zh + 将一个给定的世界坐标系下的向量转换为刚体本地坐标系下的向量 + @param localVector a vector in world coordinates. + @param out optional, the receiving vector + */ + getWorldVector(localVector: Vec2, out: Vec2): Vec2; + /** + !#en + Gets a local vector relative to the body's origin given a world vector. + !#zh + 将一个给定的世界坐标系下的点转换为刚体本地坐标系下的点 + @param worldVector a vector in world coordinates. + @param out optional, the receiving vector + */ + getLocalVector(worldVector: Vec2, out: Vec2): Vec2; + /** + !#en + Get the world body origin position. + !#zh + 获取刚体世界坐标系下的原点值 + @param out optional, the receiving point + */ + getWorldPosition(out: Vec2): Vec2; + /** + !#en + Get the world body rotation angle. + !#zh + 获取刚体世界坐标系下的旋转值。 + */ + getWorldRotation(): number; + /** + !#en + Get the local position of the center of mass. + !#zh + 获取刚体本地坐标系下的质心 + */ + getLocalCenter(): Vec2; + /** + !#en + Get the world position of the center of mass. + !#zh + 获取刚体世界坐标系下的质心 + */ + getWorldCenter(): Vec2; + /** + !#en + Get the world linear velocity of a world point attached to this body. + !#zh + 获取刚体上指定点的线性速度 + @param worldPoint a point in world coordinates. + @param out optional, the receiving point + */ + getLinearVelocityFromWorldPoint(worldPoint: Vec2, out: Vec2): Vec2; + /** + !#en + Get total mass of the body. + !#zh + 获取刚体的质量。 + */ + getMass(): number; + /** + !#en + Get the rotational inertia of the body about the local origin. + !#zh + 获取刚体本地坐标系下原点的旋转惯性 + */ + getInertia(): number; + /** + !#en + Get all the joints connect to the rigidbody. + !#zh + 获取链接到此刚体的所有关节 + */ + getJointList(): Joint[]; + /** + !#en + Apply a force at a world point. If the force is not + applied at the center of mass, it will generate a torque and + affect the angular velocity. + !#zh + 施加一个力到刚体上的一个点。如果力没有施加到刚体的质心上,还会产生一个扭矩并且影响到角速度。 + @param force the world force vector. + @param point the world position. + @param wake also wake up the body. + */ + applyForce(force: Vec2, point: Vec2, wake: boolean): void; + /** + !#en + Apply a force to the center of mass. + !#zh + 施加一个力到刚体上的质心上。 + @param force the world force vector. + @param wake also wake up the body. + */ + applyForceToCenter(force: Vec2, wake: boolean): void; + /** + !#en + Apply a torque. This affects the angular velocity. + !#zh + 施加一个扭矩力,将影响刚体的角速度 + @param torque about the z-axis (out of the screen), usually in N-m. + @param wake also wake up the body + */ + applyTorque(torque: number, wake: boolean): void; + /** + !#en + Apply a impulse at a world point, This immediately modifies the velocity. + If the impulse is not applied at the center of mass, it will generate a torque and + affect the angular velocity. + !#zh + 施加冲量到刚体上的一个点,将立即改变刚体的线性速度。 + 如果冲量施加到的点不是刚体的质心,那么将产生一个扭矩并影响刚体的角速度。 + @param impulse the world impulse vector, usually in N-seconds or kg-m/s. + @param point the world position + @param wake alse wake up the body + */ + applyLinearImpulse(impulse: Vec2, point: Vec2, wake: boolean): void; + /** + !#en + Apply an angular impulse. + !#zh + 施加一个角速度冲量。 + @param impulse the angular impulse in units of kg*m*m/s + @param wake also wake up the body + */ + applyAngularImpulse(impulse: number, wake: boolean): void; + /** + !#en + Synchronize node's world position to box2d rigidbody's position. + If enableAnimated is true and rigidbody's type is Animated type, + will set linear velocity instead of directly set rigidbody's position. + !#zh + 同步节点的世界坐标到 box2d 刚体的坐标上。 + 如果 enableAnimated 是 true,并且刚体的类型是 Animated ,那么将设置刚体的线性速度来代替直接设置刚体的位置。 + @param enableAnimated enableAnimated + */ + syncPosition(enableAnimated: boolean): void; + /** + !#en + Synchronize node's world angle to box2d rigidbody's angle. + If enableAnimated is true and rigidbody's type is Animated type, + will set angular velocity instead of directly set rigidbody's angle. + !#zh + 同步节点的世界旋转角度值到 box2d 刚体的旋转值上。 + 如果 enableAnimated 是 true,并且刚体的类型是 Animated ,那么将设置刚体的角速度来代替直接设置刚体的角度。 + @param enableAnimated enableAnimated + */ + syncRotation(enableAnimated: boolean): void; + } + /** !#en the device accelerometer reports values for each axis in units of g-force. + !#zh 设备重力传感器传递的各个轴的数据。 */ + export class constructor { + /** + whether enable accelerometer event + @param isEnable isEnable + */ + setAccelerometerEnabled(isEnable: boolean): void; + /** + set accelerometer interval value + @param interval interval + */ + setAccelerometerInterval(interval: number): void; + } + /** undefined */ + export enum VerticalTextAlignment { + TOP = 0, + CENTER = 0, + BOTTOM = 0, + } + /** The base class of most of all the objects in Fireball. */ + export class Object { + /** !#en The name of the object. + !#zh 该对象的名称。 */ + name: string; + /** !#en + Indicates whether the object is not yet destroyed. (It will not be available after being destroyed)
+ When an object's `destroy` is called, it is actually destroyed after the end of this frame. + So `isValid` will return false from the next frame, while `isValid` in the current frame will still be true. + If you want to determine whether the current frame has called `destroy`, use `cc.isValid(obj, true)`, + but this is often caused by a particular logical requirements, which is not normally required. + + !#zh + 表示该对象是否可用(被 destroy 后将不可用)。
+ 当一个对象的 `destroy` 调用以后,会在这一帧结束后才真正销毁。因此从下一帧开始 `isValid` 就会返回 false,而当前帧内 `isValid` 仍然会是 true。如果希望判断当前帧是否调用过 `destroy`,请使用 `cc.isValid(obj, true)`,不过这往往是特殊的业务需求引起的,通常情况下不需要这样。 */ + isValid: boolean; + /** + !#en + Destroy this Object, and release all its own references to other objects.
+ Actual object destruction will delayed until before rendering. + From the next frame, this object is not usable anymore. + You can use `cc.isValid(obj)` to check whether the object is destroyed before accessing it. + !#zh + 销毁该对象,并释放所有它对其它对象的引用。
+ 实际销毁操作会延迟到当前帧渲染前执行。从下一帧开始,该对象将不再可用。 + 您可以在访问对象之前使用 `cc.isValid(obj)` 来检查对象是否已被销毁。 + + @example + ```js + obj.destroy(); + ``` + */ + destroy(): boolean; + } + /** Bit mask that controls object states. */ + export enum Flags { + DontSave = 0, + EditorOnly = 0, + HideInHierarchy = 0, + } + /** The fullscreen API provides an easy way for web content to be presented using the user's entire screen. + It's invalid on safari, QQbrowser and android browser */ + export class screen { + /** + initialize + */ + init(): void; + /** + return true if it's full now. + */ + fullScreen(): boolean; + /** + change the screen to full mode. + @param element element + @param onFullScreenChange onFullScreenChange + @param onFullScreenError onFullScreenError + */ + requestFullScreen(element: Element, onFullScreenChange: Function, onFullScreenError: Function): void; + /** + exit the full mode. + */ + exitFullScreen(): boolean; + /** + Automatically request full screen with a touch/click event + @param element element + @param onFullScreenChange onFullScreenChange + */ + autoFullScreen(element: Element, onFullScreenChange: Function): void; + } + /** System variables */ + export class sys { + /** English language code */ + static LANGUAGE_ENGLISH: string; + /** Chinese language code */ + static LANGUAGE_CHINESE: string; + /** French language code */ + static LANGUAGE_FRENCH: string; + /** Italian language code */ + static LANGUAGE_ITALIAN: string; + /** German language code */ + static LANGUAGE_GERMAN: string; + /** Spanish language code */ + static LANGUAGE_SPANISH: string; + /** Spanish language code */ + static LANGUAGE_DUTCH: string; + /** Russian language code */ + static LANGUAGE_RUSSIAN: string; + /** Korean language code */ + static LANGUAGE_KOREAN: string; + /** Japanese language code */ + static LANGUAGE_JAPANESE: string; + /** Hungarian language code */ + static LANGUAGE_HUNGARIAN: string; + /** Portuguese language code */ + static LANGUAGE_PORTUGUESE: string; + /** Arabic language code */ + static LANGUAGE_ARABIC: string; + /** Norwegian language code */ + static LANGUAGE_NORWEGIAN: string; + /** Polish language code */ + static LANGUAGE_POLISH: string; + /** Turkish language code */ + static LANGUAGE_TURKISH: string; + /** Ukrainian language code */ + static LANGUAGE_UKRAINIAN: string; + /** Romanian language code */ + static LANGUAGE_ROMANIAN: string; + /** Bulgarian language code */ + static LANGUAGE_BULGARIAN: string; + /** Unknown language code */ + static LANGUAGE_UNKNOWN: string; + static OS_IOS: string; + static OS_ANDROID: string; + static OS_WINDOWS: string; + static OS_MARMALADE: string; + static OS_LINUX: string; + static OS_BADA: string; + static OS_BLACKBERRY: string; + static OS_OSX: string; + static OS_WP8: string; + static OS_WINRT: string; + static OS_UNKNOWN: string; + static UNKNOWN: number; + static WIN32: number; + static LINUX: number; + static MACOS: number; + static ANDROID: number; + static IPHONE: number; + static IPAD: number; + static BLACKBERRY: number; + static NACL: number; + static EMSCRIPTEN: number; + static TIZEN: number; + static WINRT: number; + static WP8: number; + static MOBILE_BROWSER: number; + static DESKTOP_BROWSER: number; + /** Indicates whether executes in editor's window process (Electron's renderer context) */ + static EDITOR_PAGE: number; + /** Indicates whether executes in editor's main process (Electron's browser context) */ + static EDITOR_CORE: number; + static WECHAT_GAME: number; + static QQ_PLAY: number; + static FB_PLAYABLE_ADS: number; + static BAIDU_GAME: number; + static VIVO_GAME: number; + static OPPO_GAME: number; + static HUAWEI_GAME: number; + static XIAOMI_GAME: number; + static JKW_GAME: number; + static ALIPAY_GAME: number; + static WECHAT_GAME_SUB: number; + static BAIDU_GAME_SUB: number; + static QTT_GAME: number; + static BYTEDANCE_GAME: number; + static BYTEDANCE_GAME_SUB: number; + static LINKSURE: number; + /** BROWSER_TYPE_WECHAT */ + static BROWSER_TYPE_WECHAT: string; + static BROWSER_TYPE_ANDROID: string; + static BROWSER_TYPE_IE: string; + static BROWSER_TYPE_EDGE: string; + static BROWSER_TYPE_QQ: string; + static BROWSER_TYPE_MOBILE_QQ: string; + static BROWSER_TYPE_UC: string; + /** uc third party integration. */ + static BROWSER_TYPE_UCBS: string; + static BROWSER_TYPE_360: string; + static BROWSER_TYPE_BAIDU_APP: string; + static BROWSER_TYPE_BAIDU: string; + static BROWSER_TYPE_MAXTHON: string; + static BROWSER_TYPE_OPERA: string; + static BROWSER_TYPE_OUPENG: string; + static BROWSER_TYPE_MIUI: string; + static BROWSER_TYPE_FIREFOX: string; + static BROWSER_TYPE_SAFARI: string; + static BROWSER_TYPE_CHROME: string; + static BROWSER_TYPE_LIEBAO: string; + static BROWSER_TYPE_QZONE: string; + static BROWSER_TYPE_SOUGOU: string; + static BROWSER_TYPE_UNKNOWN: string; + /** Is native ? This is set to be true in jsb auto. */ + static isNative: boolean; + /** Is web browser ? */ + static isBrowser: boolean; + /** + Is webgl extension support? + @param name name + */ + static glExtension(name: any): void; + /** + Get max joint matrix size for skinned mesh renderer. + */ + static getMaxJointMatrixSize(): void; + /** + !#en + Returns the safe area of the screen. If the screen is not notched, the design resolution will be returned by default. + Only supported on Android, iOS and WeChat Mini Game platform. + !#zh + 返回手机屏幕安全区域,如果不是异形屏将默认返回设计分辨率尺寸。目前只支持安卓、iOS 原生平台和微信小游戏平台。 + */ + static getSafeAreaRect(): Rect; + /** Indicate whether system is mobile system */ + static isMobile: boolean; + /** Indicate the running platform */ + static platform: number; + /** Get current language iso 639-1 code. + Examples of valid language codes include "zh-tw", "en", "en-us", "fr", "fr-fr", "es-es", etc. + The actual value totally depends on results provided by destination platform. */ + static languageCode: string; + /** Indicate the current language of the running system */ + static language: string; + /** Indicate the running os name */ + static os: string; + /** Indicate the running os version */ + static osVersion: string; + /** Indicate the running os main version */ + static osMainVersion: number; + /** Indicate the running browser type */ + static browserType: string|void; + /** Indicate the running browser version */ + static browserVersion: string|void; + /** Indicate the real pixel resolution of the whole game window */ + static windowPixelResolution: Size; + /** cc.sys.localStorage is a local storage component. */ + static localStorage: any; + /** The capabilities of the current platform */ + static capabilities: any; + /** + !#en + Get the network type of current device, return cc.sys.NetworkType.LAN if failure. + !#zh + 获取当前设备的网络类型, 如果网络类型无法获取,默认将返回 cc.sys.NetworkType.LAN + */ + static getNetworkType(): sys.NetworkType; + /** + !#en + Get the battery level of current device, return 1.0 if failure. + !#zh + 获取当前设备的电池电量,如果电量无法获取,默认将返回 1 + */ + static getBatteryLevel(): number; + /** + Forces the garbage collection, only available in JSB + */ + static garbageCollect(): void; + /** + Restart the JS VM, only available in JSB + */ + static restartVM(): void; + /** + Check whether an object is valid, + In web engine, it will return true if the object exist + In native engine, it will return true if the JS object and the correspond native object are both valid + @param obj obj + */ + static isObjectValid(obj: any): boolean; + /** + Dump system informations + */ + static dump(): void; + /** + Open a url in browser + @param url url + */ + static openURL(url: string): void; + /** + Get the number of milliseconds elapsed since 1 January 1970 00:00:00 UTC. + */ + static now(): number; + } + /** cc.view is the singleton object which represents the game window.
+ It's main task include:
+ - Apply the design resolution policy
+ - Provide interaction with the window, like resize event on web, retina display support, etc...
+ - Manage the game view port which can be different with the window
+ - Manage the content scale and translation
+
+ Since the cc.view is a singleton, you don't need to call any constructor or create functions,
+ the standard way to use it is by calling:
+ - cc.view.methodName();
*/ + export class View extends EventTarget { + /** + !#en + Sets view's target-densitydpi for android mobile browser. it can be set to:
+ 1. cc.macro.DENSITYDPI_DEVICE, value is "device-dpi"
+ 2. cc.macro.DENSITYDPI_HIGH, value is "high-dpi" (default value)
+ 3. cc.macro.DENSITYDPI_MEDIUM, value is "medium-dpi" (browser's default value)
+ 4. cc.macro.DENSITYDPI_LOW, value is "low-dpi"
+ 5. Custom value, e.g: "480"
+ !#zh 设置目标内容的每英寸像素点密度。 + @param densityDPI densityDPI + */ + setTargetDensityDPI(densityDPI: string): void; + /** + !#en + Returns the current target-densitydpi value of cc.view. + !#zh 获取目标内容的每英寸像素点密度。 + */ + getTargetDensityDPI(): string; + /** + !#en + Sets whether resize canvas automatically when browser's size changed.
+ Useful only on web. + !#zh 设置当发现浏览器的尺寸改变时,是否自动调整 canvas 尺寸大小。 + 仅在 Web 模式下有效。 + @param enabled Whether enable automatic resize with browser's resize event + */ + resizeWithBrowserSize(enabled: boolean): void; + /** + !#en + Sets the callback function for cc.view's resize action,
+ this callback will be invoked before applying resolution policy,
+ so you can do any additional modifications within the callback.
+ Useful only on web. + !#zh 设置 cc.view 调整视窗尺寸行为的回调函数, + 这个回调函数会在应用适配模式之前被调用, + 因此你可以在这个回调函数内添加任意附加改变, + 仅在 Web 平台下有效。 + @param callback The callback function + */ + setResizeCallback(callback: Function|void): void; + /** + !#en + Sets the orientation of the game, it can be landscape, portrait or auto. + When set it to landscape or portrait, and screen w/h ratio doesn't fit, + cc.view will automatically rotate the game canvas using CSS. + Note that this function doesn't have any effect in native, + in native, you need to set the application orientation in native project settings + !#zh 设置游戏屏幕朝向,它能够是横版,竖版或自动。 + 当设置为横版或竖版,并且屏幕的宽高比例不匹配时, + cc.view 会自动用 CSS 旋转游戏场景的 canvas, + 这个方法不会对 native 部分产生任何影响,对于 native 而言,你需要在应用设置中的设置排版。 + @param orientation Possible values: cc.macro.ORIENTATION_LANDSCAPE | cc.macro.ORIENTATION_PORTRAIT | cc.macro.ORIENTATION_AUTO + */ + setOrientation(orientation: number): void; + /** + !#en + Sets whether the engine modify the "viewport" meta in your web page.
+ It's enabled by default, we strongly suggest you not to disable it.
+ And even when it's enabled, you can still set your own "viewport" meta, it won't be overridden
+ Only useful on web + !#zh 设置引擎是否调整 viewport meta 来配合屏幕适配。 + 默认设置为启动,我们强烈建议你不要将它设置为关闭。 + 即使当它启动时,你仍然能够设置你的 viewport meta,它不会被覆盖。 + 仅在 Web 模式下有效 + @param enabled Enable automatic modification to "viewport" meta + */ + adjustViewportMeta(enabled: boolean): void; + /** + !#en + Retina support is enabled by default for Apple device but disabled for other devices,
+ it takes effect only when you called setDesignResolutionPolicy
+ Only useful on web + !#zh 对于 Apple 这种支持 Retina 显示的设备上默认进行优化而其他类型设备默认不进行优化, + 它仅会在你调用 setDesignResolutionPolicy 方法时有影响。 + 仅在 Web 模式下有效。 + @param enabled Enable or disable retina display + */ + enableRetina(enabled: boolean): void; + /** + !#en + Check whether retina display is enabled.
+ Only useful on web + !#zh 检查是否对 Retina 显示设备进行优化。 + 仅在 Web 模式下有效。 + */ + isRetinaEnabled(): boolean; + /** + !#en Whether to Enable on anti-alias + !#zh 控制抗锯齿是否开启 + @param enabled Enable or not anti-alias + */ + enableAntiAlias(enabled: boolean): void; + /** + !#en Returns whether the current enable on anti-alias + !#zh 返回当前是否抗锯齿 + */ + isAntiAliasEnabled(): boolean; + /** + !#en + If enabled, the application will try automatically to enter full screen mode on mobile devices
+ You can pass true as parameter to enable it and disable it by passing false.
+ Only useful on web + !#zh 启动时,移动端游戏会在移动端自动尝试进入全屏模式。 + 你能够传入 true 为参数去启动它,用 false 参数来关闭它。 + @param enabled Enable or disable auto full screen on mobile devices + */ + enableAutoFullScreen(enabled: boolean): void; + /** + !#en + Check whether auto full screen is enabled.
+ Only useful on web + !#zh 检查自动进入全屏模式是否启动。 + 仅在 Web 模式下有效。 + */ + isAutoFullScreenEnabled(): boolean; + /** + !#en + Returns the canvas size of the view.
+ On native platforms, it returns the screen size since the view is a fullscreen view.
+ On web, it returns the size of the canvas element. + !#zh 返回视图中 canvas 的尺寸。 + 在 native 平台下,它返回全屏视图下屏幕的尺寸。 + 在 Web 平台下,它返回 canvas 元素尺寸。 + */ + getCanvasSize(): Size; + /** + !#en + Returns the frame size of the view.
+ On native platforms, it returns the screen size since the view is a fullscreen view.
+ On web, it returns the size of the canvas's outer DOM element. + !#zh 返回视图中边框尺寸。 + 在 native 平台下,它返回全屏视图下屏幕的尺寸。 + 在 web 平台下,它返回 canvas 元素的外层 DOM 元素尺寸。 + */ + getFrameSize(): Size; + /** + !#en + On native, it sets the frame size of view.
+ On web, it sets the size of the canvas's outer DOM element. + !#zh 在 native 平台下,设置视图框架尺寸。 + 在 web 平台下,设置 canvas 外层 DOM 元素尺寸。 + @param width width + @param height height + */ + setFrameSize(width: number, height: number): void; + /** + !#en + Returns the visible area size of the view port. + !#zh 返回视图窗口可见区域尺寸。 + */ + getVisibleSize(): Size; + /** + !#en + Returns the visible area size of the view port. + !#zh 返回视图窗口可见区域像素尺寸。 + */ + getVisibleSizeInPixel(): Size; + /** + !#en + Returns the visible origin of the view port. + !#zh 返回视图窗口可见区域原点。 + */ + getVisibleOrigin(): Vec2; + /** + !#en + Returns the visible origin of the view port. + !#zh 返回视图窗口可见区域像素原点。 + */ + getVisibleOriginInPixel(): Vec2; + /** + !#en + Returns the current resolution policy + !#zh 返回当前分辨率方案 + */ + getResolutionPolicy(): ResolutionPolicy; + /** + !#en + Sets the current resolution policy + !#zh 设置当前分辨率模式 + @param resolutionPolicy resolutionPolicy + */ + setResolutionPolicy(resolutionPolicy: ResolutionPolicy|number): void; + /** + !#en + Sets the resolution policy with designed view size in points.
+ The resolution policy include:
+ [1] ResolutionExactFit Fill screen by stretch-to-fit: if the design resolution ratio of width to height is different from the screen resolution ratio, your game view will be stretched.
+ [2] ResolutionNoBorder Full screen without black border: if the design resolution ratio of width to height is different from the screen resolution ratio, two areas of your game view will be cut.
+ [3] ResolutionShowAll Full screen with black border: if the design resolution ratio of width to height is different from the screen resolution ratio, two black borders will be shown.
+ [4] ResolutionFixedHeight Scale the content's height to screen's height and proportionally scale its width
+ [5] ResolutionFixedWidth Scale the content's width to screen's width and proportionally scale its height
+ [cc.ResolutionPolicy] [Web only feature] Custom resolution policy, constructed by cc.ResolutionPolicy
+ !#zh 通过设置设计分辨率和匹配模式来进行游戏画面的屏幕适配。 + @param width Design resolution width. + @param height Design resolution height. + @param resolutionPolicy The resolution policy desired + */ + setDesignResolutionSize(width: number, height: number, resolutionPolicy: ResolutionPolicy|number): void; + /** + !#en + Returns the designed size for the view. + Default resolution size is the same as 'getFrameSize'. + !#zh 返回视图的设计分辨率。 + 默认下分辨率尺寸同 `getFrameSize` 方法相同 + */ + getDesignResolutionSize(): Size; + /** + !#en + Sets the container to desired pixel resolution and fit the game content to it. + This function is very useful for adaptation in mobile browsers. + In some HD android devices, the resolution is very high, but its browser performance may not be very good. + In this case, enabling retina display is very costy and not suggested, and if retina is disabled, the image may be blurry. + But this API can be helpful to set a desired pixel resolution which is in between. + This API will do the following: + 1. Set viewport's width to the desired width in pixel + 2. Set body width to the exact pixel resolution + 3. The resolution policy will be reset with designed view size in points. + !#zh 设置容器(container)需要的像素分辨率并且适配相应分辨率的游戏内容。 + @param width Design resolution width. + @param height Design resolution height. + @param resolutionPolicy The resolution policy desired + */ + setRealPixelResolution(width: number, height: number, resolutionPolicy: ResolutionPolicy|number): void; + /** + !#en + Sets view port rectangle with points. + !#zh 用设计分辨率下的点尺寸来设置视窗。 + @param x x + @param y y + @param w width + @param h height + */ + setViewportInPoints(x: number, y: number, w: number, h: number): void; + /** + !#en + Sets Scissor rectangle with points. + !#zh 用设计分辨率下的点的尺寸来设置 scissor 剪裁区域。 + @param x x + @param y y + @param w w + @param h h + */ + setScissorInPoints(x: number, y: number, w: number, h: number): void; + /** + !#en + Returns whether GL_SCISSOR_TEST is enable + !#zh 检查 scissor 是否生效。 + */ + isScissorEnabled(): boolean; + /** + !#en + Returns the current scissor rectangle + !#zh 返回当前的 scissor 剪裁区域。 + */ + getScissorRect(): Rect; + /** + !#en + Returns the view port rectangle. + !#zh 返回视窗剪裁区域。 + */ + getViewportRect(): Rect; + /** + !#en + Returns scale factor of the horizontal direction (X axis). + !#zh 返回横轴的缩放比,这个缩放比是将画布像素分辨率放到设计分辨率的比例。 + */ + getScaleX(): number; + /** + !#en + Returns scale factor of the vertical direction (Y axis). + !#zh 返回纵轴的缩放比,这个缩放比是将画布像素分辨率缩放到设计分辨率的比例。 + */ + getScaleY(): number; + /** + !#en + Returns device pixel ratio for retina display. + !#zh 返回设备或浏览器像素比例。 + */ + getDevicePixelRatio(): number; + /** + !#en + Returns the real location in view for a translation based on a related position + !#zh 将屏幕坐标转换为游戏视图下的坐标。 + @param tx The X axis translation + @param ty The Y axis translation + @param relatedPos The related position object including "left", "top", "width", "height" informations + */ + convertToLocationInView(tx: number, ty: number, relatedPos: any): Vec2; + } + /**

cc.game.containerStrategy class is the root strategy class of container's scale strategy, + it controls the behavior of how to scale the cc.game.container and cc.game.canvas object

*/ + export class ContainerStrategy { + /** + !#en + Manipulation before appling the strategy + !#zh 在应用策略之前的操作 + @param view The target view + */ + preApply(view: View): void; + /** + !#en + Function to apply this strategy + !#zh 策略应用方法 + @param view view + @param designedResolution designedResolution + */ + apply(view: View, designedResolution: Size): void; + /** + !#en + Manipulation after applying the strategy + !#zh 策略调用之后的操作 + @param view The target view + */ + postApply(view: View): void; + } + /**

cc.ContentStrategy class is the root strategy class of content's scale strategy, + it controls the behavior of how to scale the scene and setup the viewport for the game

*/ + export class ContentStrategy { + /** + !#en + Manipulation before applying the strategy + !#zh 策略应用前的操作 + @param view The target view + */ + preApply(view: View): void; + /** + !#en Function to apply this strategy + The return value is {scale: [scaleX, scaleY], viewport: {cc.Rect}}, + The target view can then apply these value to itself, it's preferred not to modify directly its private variables + !#zh 调用策略方法 + @param view view + @param designedResolution designedResolution + */ + apply(view: View, designedResolution: Size): any; + /** + !#en + Manipulation after applying the strategy + !#zh 策略调用之后的操作 + @param view The target view + */ + postApply(view: View): void; + } + /** undefined */ + export class EqualToFrame extends ContainerStrategy { + } + /** undefined */ + export class ProportionalToFrame extends ContainerStrategy { + } + /** undefined */ + export class EqualToWindow extends EqualToFrame { + } + /** undefined */ + export class ProportionalToWindow extends ProportionalToFrame { + } + /** undefined */ + export class OriginalContainer extends ContainerStrategy { + } + /**

cc.ResolutionPolicy class is the root strategy class of scale strategy, + its main task is to maintain the compatibility with Cocos2d-x

*/ + export class ResolutionPolicy { + /** + + @param containerStg The container strategy + @param contentStg The content strategy + */ + constructor(containerStg: ContainerStrategy, contentStg: ContentStrategy); + /** + !#en Manipulation before applying the resolution policy + !#zh 策略应用前的操作 + @param view The target view + */ + preApply(view: View): void; + /** + !#en Function to apply this resolution policy + The return value is {scale: [scaleX, scaleY], viewport: {cc.Rect}}, + The target view can then apply these value to itself, it's preferred not to modify directly its private variables + !#zh 调用策略方法 + @param view The target view + @param designedResolution The user defined design resolution + */ + apply(view: View, designedResolution: Size): any; + /** + !#en Manipulation after appyling the strategy + !#zh 策略应用之后的操作 + @param view The target view + */ + postApply(view: View): void; + /** + !#en + Setup the container's scale strategy + !#zh 设置容器的适配策略 + @param containerStg containerStg + */ + setContainerStrategy(containerStg: ContainerStrategy): void; + /** + !#en + Setup the content's scale strategy + !#zh 设置内容的适配策略 + @param contentStg contentStg + */ + setContentStrategy(contentStg: ContentStrategy): void; + /** The entire application is visible in the specified area without trying to preserve the original aspect ratio.
+ Distortion can occur, and the application may appear stretched or compressed. */ + static EXACT_FIT: number; + /** The entire application fills the specified area, without distortion but possibly with some cropping,
+ while maintaining the original aspect ratio of the application. */ + static NO_BORDER: number; + /** The entire application is visible in the specified area without distortion while maintaining the original
+ aspect ratio of the application. Borders can appear on two sides of the application. */ + static SHOW_ALL: number; + /** The application takes the height of the design resolution size and modifies the width of the internal
+ canvas so that it fits the aspect ratio of the device
+ no distortion will occur however you must make sure your application works on different
+ aspect ratios */ + static FIXED_HEIGHT: number; + /** The application takes the width of the design resolution size and modifies the height of the internal
+ canvas so that it fits the aspect ratio of the device
+ no distortion will occur however you must make sure your application works on different
+ aspect ratios */ + static FIXED_WIDTH: number; + /** Unknow policy */ + static UNKNOWN: number; + } + /** cc.visibleRect is a singleton object which defines the actual visible rect of the current view, + it should represent the same rect as cc.view.getViewportRect() */ + export class visibleRect { + /** + initialize + @param visibleRect visibleRect + */ + static init(visibleRect: Rect): void; + /** Top left coordinate of the screen related to the game scene. */ + static topLeft: Vec2; + /** Top right coordinate of the screen related to the game scene. */ + static topRight: Vec2; + /** Top center coordinate of the screen related to the game scene. */ + static top: Vec2; + /** Bottom left coordinate of the screen related to the game scene. */ + static bottomLeft: Vec2; + /** Bottom right coordinate of the screen related to the game scene. */ + static bottomRight: Vec2; + /** Bottom center coordinate of the screen related to the game scene. */ + static bottom: Vec2; + /** Center coordinate of the screen related to the game scene. */ + static center: Vec2; + /** Left center coordinate of the screen related to the game scene. */ + static left: Vec2; + /** Right center coordinate of the screen related to the game scene. */ + static right: Vec2; + /** Width of the screen. */ + static width: number; + /** Height of the screen. */ + static height: number; + } + /** !#en The callbacks invoker to handle and invoke callbacks by key. + !#zh CallbacksInvoker 用来根据 Key 管理并调用回调方法。 */ + export class CallbacksInvoker { + /** + !#zh + 检查指定事件是否已注册回调。 + !#en + Check if the specified key has any registered callback. If a callback is also specified, + it will only return true if the callback is registered. + @param key key + @param callback callback + @param target target + */ + hasEventListener(key: string, callback?: Function, target?: any): boolean; + /** + !#zh + 移除在特定事件类型中注册的所有回调或在某个目标中注册的所有回调。 + + !#en + Removes all callbacks registered in a certain event type or all callbacks registered with a certain target + @param keyOrTarget The event key to be removed or the target to be removed + */ + removeAll(keyOrTarget: string|any): void; + /** + !#zh + 删除之前与同类型,回调,目标注册的回调。 + @param key key + @param callback callback + @param target target + */ + off(key: string, callback: Function, target?: any): void; + /** + !#en + Trigger an event directly with the event name and necessary arguments. + !#zh + 通过事件名发送自定义事件 + @param key event type + @param arg1 First argument + @param arg2 Second argument + @param arg3 Third argument + @param arg4 Fourth argument + @param arg5 Fifth argument + + @example + ```js + eventTarget.emit('fire', event); + eventTarget.emit('fire', message, emitter); + ``` + */ + emit(key: string, arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any): void; + } + /** !#en Contains information collected during deserialization + !#zh 包含反序列化时的一些信息 */ + export class Details { + /** list of the depends assets' uuid */ + uuidList: string[]; + /** the obj list whose field needs to load asset by uuid */ + uuidObjList: any[]; + /** the corresponding field name which referenced to the asset */ + uuidPropList: string[]; + reset(): void; + /** + + @param obj obj + @param propName propName + @param uuid uuid + */ + push(obj: any, propName: string, uuid: string): void; + } + /** !#en The renderer object which provide access to render system APIs, + detailed APIs will be available progressively. + !#zh 提供基础渲染接口的渲染器对象,渲染层的基础接口将逐步开放给用户 */ + export class renderer { + /** !#en The render engine is available only after cc.game.EVENT_ENGINE_INITED event.
+ Normally it will be inited as the webgl render engine, but in wechat open context domain, + it will be inited as the canvas render engine. Canvas render engine is no longer available for other use case since v2.0. + !#zh 基础渲染引擎对象只在 cc.game.EVENT_ENGINE_INITED 事件触发后才可获取。
+ 大多数情况下,它都会是 WebGL 渲染引擎实例,但是在微信开放数据域当中,它会是 Canvas 渲染引擎实例。请注意,从 2.0 开始,我们在其他平台和环境下都废弃了 Canvas 渲染器。 */ + static renderEngine: any; + /** !#en The total draw call count in last rendered frame. + !#zh 上一次渲染帧所提交的渲染批次总数。 */ + static drawCalls: number; + } + /** !#en Mesh Asset. + !#zh 网格资源。 */ + export class Mesh extends Asset implements EventTarget { + /** !#en Get ir set the sub meshes. + !#zh 设置或者获取子网格。 */ + subMeshes: InputAssembler[]; + /** + !#en + Init vertex buffer according to the vertex format. + !#zh + 根据顶点格式初始化顶点内存。 + @param vertexFormat vertex format + @param vertexCount how much vertex should be create in this buffer. + @param dynamic whether or not to use dynamic buffer. + @param index index + */ + init(vertexFormat: gfx.VertexFormat, vertexCount: number, dynamic?: boolean, index?: boolean): void; + /** + !#en + Set the vertex values. + !#zh + 设置顶点数据 + @param name the attribute name, e.g. gfx.ATTR_POSITION + @param values the vertex values + */ + setVertices(name: string, values: Vec2[]|Vec3[]|Color[]|number[]|Uint8Array|Float32Array): void; + /** + !#en + Set the sub mesh indices. + !#zh + 设置子网格索引。 + @param indices the sub mesh indices. + @param index sub mesh index. + @param dynamic whether or not to use dynamic buffer. + */ + setIndices(indices: number[]|Uint16Array|Uint8Array, index?: number, dynamic?: boolean): void; + /** + !#en + Set the sub mesh primitive type. + !#zh + 设置子网格绘制线条的方式。 + @param type type + @param index index + */ + setPrimitiveType(type: number, index: number): void; + /** + !#en + Clear the buffer data. + !#zh + 清除网格创建的内存数据。 + */ + clear(): void; + /** + !#en Set mesh bounding box + !#zh 设置网格的包围盒 + @param min min + @param max max + */ + setBoundingBox(min: Vec3, max: Vec3): void; + /** + !#en Read the specified attributes of the subgrid into the target buffer. + !#zh 读取子网格的指定属性到目标缓冲区中。 + @param primitiveIndex The subgrid index. + @param attributeName attribute name. + @param buffer The target buffer. + @param stride The byte interval between adjacent attributes in the target buffer. + @param offset The offset of the first attribute in the target buffer. + */ + copyAttribute(primitiveIndex: number, attributeName: string, buffer: ArrayBuffer, stride: number, offset: number): boolean; + /** + !#en Read the index data of the subgrid into the target array. + !#zh 读取子网格的索引数据到目标数组中。 + @param primitiveIndex The subgrid index. + @param outputArray The target array. + */ + copyIndices(primitiveIndex: number, outputArray: DataView): boolean; + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en + Register an callback of a specific event type on the EventTarget. + This type of event should be triggered via `emit`. + !#zh + 注册事件目标的特定事件类型回调。这种类型的事件应该被 `emit` 触发。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, node); + ``` + */ + on(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. + !#zh + 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + + @example + ```js + // register fire eventListener + var callback = eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, target); + // remove fire event listener + eventTarget.off('fire', callback, target); + // remove all fire event listeners + eventTarget.off('fire'); + ``` + */ + off(type: string, callback?: Function, target?: any): void; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.once('fire', function () { + cc.log("this is the callback and will be invoked only once"); + }, node); + ``` + */ + once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; + /** + !#en + Send an event with the event object. + !#zh + 通过事件对象派发事件 + @param event event + */ + dispatchEvent(event: Event): void; + } + /** !#en + Mesh Renderer Component + !#zh + 网格渲染组件 */ + export class MeshRenderer extends RenderComponent { + /** !#en + The mesh which the renderer uses. + !#zh + 设置使用的网格 */ + mesh: Mesh; + /** !#en + Whether the mesh should receive shadows. + !#zh + 网格是否接受光源投射的阴影 */ + receiveShadows: boolean; + /** !#en + Shadow Casting Mode + !#zh + 网格投射阴影的模式 */ + shadowCastingMode: MeshRenderer.ShadowCastingMode; + /** !#en + Enable auto merge mesh, only support when mesh's VertexFormat, PrimitiveType, materials are all the same + !#zh + 开启自动合并 mesh 功能,只有在网格的 顶点格式,PrimitiveType, 使用的材质 都一致的情况下才会有效 */ + enableAutoBatch: boolean; + } + /** The class BufferRange denotes a range of the buffer. */ + export class BufferRange { + /** The offset of the range. */ + offset: number; + /** The length of the range. */ + length: number; + } + /** undefined */ + export class VertexFormat { + /** The data range of this bundle. + This range of data is essentially mapped to a GPU vertex buffer. */ + data: BufferRange; + /** The attribute formats. */ + formats: VertexFormat; + /** The vertex bundle that the primitive use. */ + vertexBundleIndices: number[]; + /** The data range of the primitive. + This range of data is essentially mapped to a GPU indices buffer. */ + data: BufferRange; + /** The type of this primitive's indices. */ + indexUnit: number; + /** The primitive's topology. */ + topology: number; + } + /** !#en + Representation of RGBA colors. + + Each color component is a floating point value with a range from 0 to 255. + + You can also use the convenience method {{#crossLink "cc/color:method"}}cc.color{{/crossLink}} to create a new Color. + + !#zh + cc.Color 用于表示颜色。 + + 它包含 RGBA 四个以浮点数保存的颜色分量,每个的值都在 0 到 255 之间。 + + 您也可以通过使用 {{#crossLink "cc/color:method"}}cc.color{{/crossLink}} 的便捷方法来创建一个新的 Color。 */ + export class Color extends ValueType { + /** !#en Solid white, RGBA is [255, 255, 255, 255]. + !#zh 纯白色,RGBA 是 [255, 255, 255, 255]。 */ + static WHITE: Color; + /** !#en Solid black, RGBA is [0, 0, 0, 255]. + !#zh 纯黑色,RGBA 是 [0, 0, 0, 255]。 */ + static BLACK: Color; + /** !#en Transparent, RGBA is [0, 0, 0, 0]. + !#zh 透明,RGBA 是 [0, 0, 0, 0]。 */ + static TRANSPARENT: Color; + /** !#en Grey, RGBA is [127.5, 127.5, 127.5]. + !#zh 灰色,RGBA 是 [127.5, 127.5, 127.5]。 */ + static GRAY: Color; + /** !#en Solid red, RGBA is [255, 0, 0]. + !#zh 纯红色,RGBA 是 [255, 0, 0]。 */ + static RED: Color; + /** !#en Solid green, RGBA is [0, 255, 0]. + !#zh 纯绿色,RGBA 是 [0, 255, 0]。 */ + static GREEN: Color; + /** !#en Solid blue, RGBA is [0, 0, 255]. + !#zh 纯蓝色,RGBA 是 [0, 0, 255]。 */ + static BLUE: Color; + /** !#en Yellow, RGBA is [255, 235, 4]. + !#zh 黄色,RGBA 是 [255, 235, 4]。 */ + static YELLOW: Color; + /** !#en Orange, RGBA is [255, 127, 0]. + !#zh 橙色,RGBA 是 [255, 127, 0]。 */ + static ORANGE: Color; + /** !#en Cyan, RGBA is [0, 255, 255]. + !#zh 青色,RGBA 是 [0, 255, 255]。 */ + static CYAN: Color; + /** !#en Magenta, RGBA is [255, 0, 255]. + !#zh 洋红色(品红色),RGBA 是 [255, 0, 255]。 */ + static MAGENTA: Color; + /** + Copy content of a color into another. + */ + static copy (out: Color, a: Color): Color; + /** + Clone a new color. + */ + static clone (a: Color): Color; + /** + Set the components of a color to the given values. + */ + static set (out: Color, r?: number, g?: number, b?: number, a?: number): Color; + /** + Converts the hexadecimal formal color into rgb formal. + */ + static fromHex (out: Color, hex: number): Color; + /** + Converts the hexadecimal formal color into rgb formal. + */ + static fromHEX (out: Color, hex: string): Color; + /** + Add components of two colors, respectively. + */ + static add (out: Color, a: Color, b: Color): Color; + /** + Subtract components of color b from components of color a, respectively. + */ + static subtract (out: Color, a: Color, b: Color): Color; + /** + Multiply components of two colors, respectively. + */ + static multiply (out: Color, a: Color, b: Color): Color; + /** + Divide components of color a by components of color b, respectively. + */ + static divide (out: Color, a: Color, b: Color): Color; + /** + Scales a color by a number. + */ + static scale (out: Color, a: Color, b: number): Color; + /** + Performs a linear interpolation between two colors. + */ + static lerp (out: Color, a: Color, b: Color, t: number): Color; + /** + !#zh 颜色转数组 + !#en Turn an array of colors + @param ofs 数组起始偏移量 + */ + static toArray > (out: Out, a: IColorLike, ofs?: number): Out; + /** + !#zh 数组转颜色 + !#en An array of colors turn + @param ofs 数组起始偏移量 + */ + static fromArray (arr: IWritableArrayLike, out: Out, ofs?: number): Out; + /** + !#zh 颜色 RGB 预乘 Alpha 通道 + !#en RGB premultiply alpha channel + @param out 返回颜色 + @param color 预乘处理的目标颜色 + */ + static premultiplyAlpha (out: Out, a: IColorLike); + /** + + @param r red component of the color, default value is 0. + @param g green component of the color, defualt value is 0. + @param b blue component of the color, default value is 0. + @param a alpha component of the color, default value is 255. + */ + constructor(r?: number, g?: number, b?: number, a?: number); + /** + !#en Clone a new color from the current color. + !#zh 克隆当前颜色。 + + @example + ```js + var color = new cc.Color(); + var newColor = color.clone();// Color {r: 0, g: 0, b: 0, a: 255} + ``` + */ + clone(): Color; + /** + !#en TODO + !#zh 判断两个颜色是否相等。 + @param other other + + @example + ```js + var color1 = cc.Color.WHITE; + var color2 = new cc.Color(255, 255, 255); + cc.log(color1.equals(color2)); // true; + color2 = cc.Color.RED; + cc.log(color2.equals(color1)); // false; + ``` + */ + equals(other: Color): boolean; + /** + !#en TODO + !#zh 线性插值 + @param to to + @param ratio the interpolation coefficient. + @param out optional, the receiving vector. + + @example + ```js + // Converts a white color to a black one trough time. + update: function (dt) { + var color = this.node.color; + if (color.equals(cc.Color.BLACK)) { + return; + } + this.ratio += dt * 0.1; + this.node.color = cc.Color.WHITE.lerp(cc.Color.BLACK, ratio); + } + + ``` + */ + lerp(to: Color, ratio: number, out?: Color): Color; + /** + !#en TODO + !#zh 转换为方便阅读的字符串。 + + @example + ```js + var color = cc.Color.WHITE; + color.toString(); // "rgba(255, 255, 255, 255)" + ``` + */ + toString(): string; + /** !#en Get or set red channel value + !#zh 获取或者设置红色通道 */ + r: number; + /** !#en Get or set green channel value + !#zh 获取或者设置绿色通道 */ + g: number; + /** !#en Get or set blue channel value + !#zh 获取或者设置蓝色通道 */ + b: number; + /** !#en Get or set alpha channel value + !#zh 获取或者设置透明通道 */ + a: number; + /** + !#en Gets red channel value + !#zh 获取当前颜色的红色值。 + */ + getR(): number; + /** + !#en Sets red value and return the current color object + !#zh 设置当前的红色值,并返回当前对象。 + @param red the new Red component. + + @example + ```js + var color = new cc.Color(); + color.setR(255); // Color {r: 255, g: 0, b: 0, a: 255} + ``` + */ + setR(red: number): Color; + /** + !#en Gets green channel value + !#zh 获取当前颜色的绿色值。 + */ + getG(): number; + /** + !#en Sets green value and return the current color object + !#zh 设置当前的绿色值,并返回当前对象。 + @param green the new Green component. + + @example + ```js + var color = new cc.Color(); + color.setG(255); // Color {r: 0, g: 255, b: 0, a: 255} + ``` + */ + setG(green: number): Color; + /** + !#en Gets blue channel value + !#zh 获取当前颜色的蓝色值。 + */ + getB(): number; + /** + !#en Sets blue value and return the current color object + !#zh 设置当前的蓝色值,并返回当前对象。 + @param blue the new Blue component. + + @example + ```js + var color = new cc.Color(); + color.setB(255); // Color {r: 0, g: 0, b: 255, a: 255} + ``` + */ + setB(blue: number): Color; + /** + !#en Gets alpha channel value + !#zh 获取当前颜色的透明度值。 + */ + getA(): number; + /** + !#en Sets alpha value and return the current color object + !#zh 设置当前的透明度,并返回当前对象。 + @param alpha the new Alpha component. + + @example + ```js + var color = new cc.Color(); + color.setA(0); // Color {r: 0, g: 0, b: 0, a: 0} + ``` + */ + setA(alpha: number): Color; + /** + !#en Convert color to css format. + !#zh 转换为 CSS 格式。 + @param opt "rgba", "rgb", "#rgb" or "#rrggbb". + + @example + ```js + var color = cc.Color.BLACK; + color.toCSS(); // "rgba(0,0,0,1.00)"; + color.toCSS("rgba"); // "rgba(0,0,0,1.00)"; + color.toCSS("rgb"); // "rgba(0,0,0)"; + color.toCSS("#rgb"); // "#000"; + color.toCSS("#rrggbb"); // "#000000"; + ``` + */ + toCSS(opt?: string): string; + /** + !#en Read hex string and store color data into the current color object, the hex string must be formated as rgba or rgb. + !#zh 读取 16 进制颜色。 + @param hexString hexString + + @example + ```js + var color = cc.Color.BLACK; + color.fromHEX("#FFFF33"); // Color {r: 255, g: 255, b: 51, a: 255}; + ``` + */ + fromHEX(hexString: string): Color; + /** + !#en convert Color to HEX color string. + !#zh 转换为 16 进制。 + @param fmt "#rgb", "#rrggbb" or "#rrggbbaa". + + @example + ```js + var color = cc.Color.BLACK; + color.toHEX("#rgb"); // "000"; + color.toHEX("#rrggbb"); // "000000"; + ``` + */ + toHEX(fmt?: string): string; + /** + !#en Convert to 24bit rgb value. + !#zh 转换为 24bit 的 RGB 值。 + + @example + ```js + var color = cc.Color.YELLOW; + color.toRGBValue(); // 16771844; + ``` + */ + toRGBValue(): number; + /** + !#en Read HSV model color and convert to RGB color + !#zh 读取 HSV(色彩模型)格式。 + @param h h + @param s s + @param v v + + @example + ```js + var color = cc.Color.YELLOW; + color.fromHSV(0, 0, 1); // Color {r: 255, g: 255, b: 255, a: 255}; + ``` + */ + fromHSV(h: number, s: number, v: number): Color; + /** + !#en Transform to HSV model color + !#zh 转换为 HSV(色彩模型)格式。 + + @example + ```js + var color = cc.Color.YELLOW; + color.toHSV(); // Object {h: 0.1533864541832669, s: 0.9843137254901961, v: 1}; + ``` + */ + toHSV(): any; + /** + !#en Set the color + !#zh 设置颜色 + @param color color + */ + set (color: Color): Color; + /** + !#en Multiplies the current color by the specified color + !#zh 将当前颜色乘以与指定颜色 + @param other other + */ + multiply(other: Color): Color; + } + /** Mathematical 3x3 matrix. + + NOTE: we use column-major matrix for all matrix calculation. + + This may lead to some confusion when referencing OpenGL documentation, + however, which represents out all matricies in column-major format. + This means that while in code a matrix may be typed out as: + + [1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 1, 0, + x, y, z, 0] + + The same matrix in the [OpenGL documentation](https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glTranslate.xml) + is written as: + + 1 0 0 x + 0 1 0 y + 0 0 1 z + 0 0 0 0 + + Please rest assured, however, that they are the same thing! + This is not unique to glMatrix, either, as OpenGL developers have long been confused by the + apparent lack of consistency between the memory layout and the documentation. */ + export class Mat3 extends ValueType { + /** Identity of Mat3 */ + static IDENTITY: Mat3; + /** + !#zh 矩阵转数组 + !#en Matrix transpose array + @param ofs 数组内的起始偏移量 + */ + static toArray > (out: Out, mat: IMat3Like, ofs?: number): Out; + /** + !#zh 数组转矩阵 + !#en Transfer matrix array + @param ofs 数组起始偏移量 + */ + static fromArray (out: Out, arr: IWritableArrayLike, ofs?: number): Out; + /** !#en Matrix Data + !#zh 矩阵数据 */ + m: Float64Array|Float32Array; + constructor (m00?: number | Float32Array, m01?: number, m02?: number, m03?: number, m04?: number, m05?: number, m06?: number, m07?: number, m08?: number); + } + /** !#en Representation of 4*4 matrix. + !#zh 表示 4*4 矩阵 */ + export class Mat4 extends ValueType { + /** + !#en Multiply the current matrix with another one + !#zh 将当前矩阵与指定矩阵相乘 + @param other the second operand + @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created + */ + mul(other: Mat4, out?: Mat4): Mat4; + /** + !#en Multiply each element of the matrix by a scalar. + !#zh 将矩阵的每一个元素都乘以指定的缩放值。 + @param number amount to scale the matrix's elements by + @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created + */ + mulScalar(number: number, out?: Mat4): Mat4; + /** + !#en Subtracts the current matrix with another one + !#zh 将当前矩阵与指定的矩阵相减 + @param other the second operand + @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created + */ + sub(other: Mat4, out?: Mat4): Mat4; + /** Identity of Mat4 */ + static IDENTITY: Mat4; + /** + !#zh 获得指定矩阵的拷贝 + !#en Copy of the specified matrix to obtain + */ + static clone (a: Out): Mat4; + /** + !#zh 复制目标矩阵 + !#en Copy the target matrix + */ + static copy (out: Out, a: Out): Out; + /** + !#zh 将目标赋值为单位矩阵 + !#en The target of an assignment is the identity matrix + */ + static identity (out: Out): Out; + /** + !#zh 转置矩阵 + !#en Transposed matrix + */ + static transpose (out: Out, a: Out): Out; + /** + !#zh 矩阵求逆 + !#en Matrix inversion + */ + static invert (out: Out, a: Out): Out; + /** + !#zh 矩阵行列式 + !#en Matrix determinant + */ + static determinant (a: Out): number; + /** + !#zh 矩阵乘法 + !#en Matrix Multiplication + */ + static multiply (out: Out, a: Out, b: Out): Out; + /** + !#zh 在给定矩阵变换基础上加入变换 + !#en Was added in a given transformation matrix transformation on the basis of + */ + static transform (out: Out, a: Out, v: VecLike): Out; + /** + !#zh 在给定矩阵变换基础上加入新位移变换 + !#en Add new displacement transducer in a matrix transformation on the basis of a given + */ + static translate (out: Out, a: Out, v: VecLike): Out; + /** + !#zh 在给定矩阵变换基础上加入新缩放变换 + !#en Add new scaling transformation in a given matrix transformation on the basis of + */ + static scale (out: Out, a: Out, v: VecLike): Out; + /** + !#zh 在给定矩阵变换基础上加入新旋转变换 + !#en Add a new rotational transform matrix transformation on the basis of a given + @param rad 旋转角度 + @param axis 旋转轴 + */ + static rotate (out: Out, a: Out, rad: number, axis: VecLike): Out; + /** + !#zh 在给定矩阵变换基础上加入绕 X 轴的旋转变换 + !#en Add rotational transformation around the X axis at a given matrix transformation on the basis of + @param rad 旋转角度 + */ + static rotateX (out: Out, a: Out, rad: number): Out; + /** + !#zh 在给定矩阵变换基础上加入绕 Y 轴的旋转变换 + !#en Add about the Y axis rotation transformation in a given matrix transformation on the basis of + @param rad 旋转角度 + */ + static rotateY (out: Out, a: Out, rad: number): Out; + /** + !#zh 在给定矩阵变换基础上加入绕 Z 轴的旋转变换 + !#en Added about the Z axis at a given rotational transformation matrix transformation on the basis of + @param rad 旋转角度 + */ + static rotateZ (out: Out, a: Out, rad: number): Out; + /** + !#zh 计算位移矩阵 + !#en Displacement matrix calculation + */ + static fromTranslation (out: Out, v: VecLike): Out; + /** + !#zh 计算缩放矩阵 + !#en Scaling matrix calculation + */ + static fromScaling (out: Out, v: VecLike): Out; + /** + !#zh 计算旋转矩阵 + !#en Calculates the rotation matrix + */ + static fromRotation (out: Out, rad: number, axis: VecLike): Out; + /** + !#zh 计算绕 X 轴的旋转矩阵 + !#en Calculating rotation matrix about the X axis + */ + static fromXRotation (out: Out, rad: number): Out; + /** + !#zh 计算绕 Y 轴的旋转矩阵 + !#en Calculating rotation matrix about the Y axis + */ + static fromYRotation (out: Out, rad: number): Out; + /** + !#zh 计算绕 Z 轴的旋转矩阵 + !#en Calculating rotation matrix about the Z axis + */ + static fromZRotation (out: Out, rad: number): Out; + /** + !#zh 根据旋转和位移信息计算矩阵 + !#en The rotation and displacement information calculating matrix + */ + static fromRT (out: Out, q: Quat, v: VecLike): Out; + /** + !#zh 提取矩阵的位移信息, 默认矩阵中的变换以 S->R->T 的顺序应用 + !#en Extracting displacement information of the matrix, the matrix transform to the default sequential application S-> R-> T is + */ + static getTranslation (out: VecLike, mat: Out): VecLike; + /** + !#zh 提取矩阵的缩放信息, 默认矩阵中的变换以 S->R->T 的顺序应用 + !#en Scaling information extraction matrix, the matrix transform to the default sequential application S-> R-> T is + */ + static getScaling (out: VecLike, mat: Out): VecLike; + /** + !#zh 提取矩阵的旋转信息, 默认输入矩阵不含有缩放信息,如考虑缩放应使用 `toRTS` 函数。 + !#en Rotation information extraction matrix, the matrix containing no default input scaling information, such as the use of `toRTS` should consider the scaling function. + */ + static getRotation (out: Quat, mat: Out): Quat; + /** + !#zh 提取旋转、位移、缩放信息, 默认矩阵中的变换以 S->R->T 的顺序应用 + !#en Extracting rotational displacement, zoom information, the default matrix transformation in order S-> R-> T applications + */ + static toRTS (mat: Out, q: Quat, v: VecLike, s: VecLike): void; + /** + !#zh 根据旋转、位移、缩放信息计算矩阵,以 S->R->T 的顺序应用 + !#en The rotary displacement, the scaling matrix calculation information, the order S-> R-> T applications + */ + static fromRTS (out: Out, q: Quat, v: VecLike, s: VecLike): Out; + /** + !#zh 根据指定的旋转、位移、缩放及变换中心信息计算矩阵,以 S->R->T 的顺序应用 + !#en According to the specified rotation, displacement, and scale conversion matrix calculation information center, order S-> R-> T applications + @param q 旋转值 + @param v 位移值 + @param s 缩放值 + @param o 指定变换中心 + */ + static fromRTSOrigin (out: Out, q: Quat, v: VecLike, s: VecLike, o: VecLike): Out; + /** + !#zh 根据指定的旋转信息计算矩阵 + !#en The rotation matrix calculation information specified + */ + static fromQuat (out: Out, q: Quat): Out; + /** + !#zh 根据指定的视锥体信息计算矩阵 + !#en The matrix calculation information specified frustum + @param left 左平面距离 + @param right 右平面距离 + @param bottom 下平面距离 + @param top 上平面距离 + @param near 近平面距离 + @param far 远平面距离 + */ + static frustum (out: Out, left: number, right: number, bottom: number, top: number, near: number, far: number): Out; + /** + !#zh 计算透视投影矩阵 + !#en Perspective projection matrix calculation + @param fovy 纵向视角高度 + @param aspect 长宽比 + @param near 近平面距离 + @param far 远平面距离 + */ + static perspective (out: Out, fovy: number, aspect: number, near: number, far: number): Out; + /** + !#zh 计算正交投影矩阵 + !#en Computing orthogonal projection matrix + @param left 左平面距离 + @param right 右平面距离 + @param bottom 下平面距离 + @param top 上平面距离 + @param near 近平面距离 + @param far 远平面距离 + */ + static ortho (out: Out, left: number, right: number, bottom: number, top: number, near: number, far: number): Out; + /** + !#zh 根据视点计算矩阵,注意 `eye - center` 不能为零向量或与 `up` 向量平行 + !#en `Up` parallel vector or vector center` not be zero - the matrix calculation according to the viewpoint, note` eye + @param eye 当前位置 + @param center 目标视点 + @param up 视口上方向 + */ + static lookAt (out: Out, eye: VecLike, center: VecLike, up: VecLike): Out; + /** + !#zh 计算逆转置矩阵 + !#en Reversal matrix calculation + */ + static inverseTranspose (out: Out, a: Out): Out; + /** + !#zh 逐元素矩阵加法 + !#en Element by element matrix addition + */ + static add (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素矩阵减法 + !#en Matrix element by element subtraction + */ + static subtract (out: Out, a: Out, b: Out): Out; + /** + !#zh 矩阵标量乘法 + !#en Matrix scalar multiplication + */ + static multiplyScalar (out: Out, a: Out, b: number): Out; + /** + !#zh 逐元素矩阵标量乘加: A + B * scale + !#en Elements of the matrix by the scalar multiplication and addition: A + B * scale + */ + static multiplyScalarAndAdd (out: Out, a: Out, b: Out, scale: number): Out; + /** + !#zh 矩阵等价判断 + !#en Analyzing the equivalent matrix + */ + static strictEquals (a: Out, b: Out): boolean; + /** + !#zh 排除浮点数误差的矩阵近似等价判断 + !#en Negative floating point error is approximately equivalent to determining a matrix + */ + static equals (a: Out, b: Out, epsilon?: number): boolean; + /** + !#zh 矩阵转数组 + !#en Matrix transpose array + @param ofs 数组内的起始偏移量 + */ + static toArray > (out: Out, mat: IMat4Like, ofs?: number): Out; + /** + !#zh 数组转矩阵 + !#en Transfer matrix array + @param ofs 数组起始偏移量 + */ + static fromArray (out: Out, arr: IWritableArrayLike, ofs?: number): Out; + /** !#en Matrix Data + !#zh 矩阵数据 */ + m: Float64Array|Float32Array; + /** + !#en + Constructor + see {{#crossLink "cc/mat4:method"}}cc.mat4{{/crossLink}} + !#zh + 构造函数,可查看 {{#crossLink "cc/mat4:method"}}cc.mat4{{/crossLink}} + */ + constructor ( m00?: number, m01?: number, m02?: number, m03?: number, m10?: number, m11?: number, m12?: number, m13?: number, m20?: number, m21?: number, m22?: number, m23?: number, m30?: number, m31?: number, m32?: number, m33?: number); + /** + !#en clone a Mat4 object + !#zh 克隆一个 Mat4 对象 + */ + clone(): Mat4; + /** + !#en Sets the matrix with another one's value + !#zh 用另一个矩阵设置这个矩阵的值。 + @param srcObj srcObj + */ + set(srcObj: Mat4): Mat4; + /** + !#en Check whether two matrix equal + !#zh 当前的矩阵是否与指定的矩阵相等。 + @param other other + */ + equals(other: Mat4): boolean; + /** + !#en Check whether two matrix equal with default degree of variance. + !#zh + 近似判断两个矩阵是否相等。
+ 判断 2 个矩阵是否在默认误差范围之内,如果在则返回 true,反之则返回 false。 + @param other other + */ + fuzzyEquals(other: Mat4): boolean; + /** + !#en Transform to string with matrix informations + !#zh 转换为方便阅读的字符串。 + */ + toString(): string; + /** + Set the matrix to the identity matrix + */ + identity(): Mat4; + /** + Transpose the values of a mat4 + @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created. + */ + transpose(out?: Mat4): Mat4; + /** + Inverts a mat4 + @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created. + */ + invert(out?: Mat4): Mat4; + /** + Calculates the adjugate of a mat4 + @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created. + */ + adjoint(out?: Mat4): Mat4; + /** + Calculates the determinant of a mat4 + */ + determinant(): number; + /** + Adds two Mat4 + @param other the second operand + @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created. + */ + add(other: Mat4, out?: Mat4): Mat4; + /** + Subtracts the current matrix with another one + @param other the second operand + */ + subtract(other: Mat4): Mat4; + /** + Subtracts the current matrix with another one + @param other the second operand + */ + multiply(other: Mat4): Mat4; + /** + Multiply each element of the matrix by a scalar. + @param number amount to scale the matrix's elements by + */ + multiplyScalar(number: number): Mat4; + /** + Translate a mat4 by the given vector + @param v vector to translate by + @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created + */ + translate(v: Vec3, out?: Mat4): Mat4; + /** + Scales the mat4 by the dimensions in the given vec3 + @param v vector to scale by + @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created + */ + scale(v: Vec3, out?: Mat4): Mat4; + /** + Rotates a mat4 by the given angle around the given axis + @param rad the angle to rotate the matrix by + @param axis the axis to rotate around + @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created + */ + rotate(rad: number, axis: Vec3, out?: Mat4): Mat4; + /** + Returns the translation vector component of a transformation matrix. + @param out Vector to receive translation component, if not provided, a new vec3 will be created + */ + getTranslation(out: Vec3): Vec3; + /** + Returns the scale factor component of a transformation matrix + @param out Vector to receive scale component, if not provided, a new vec3 will be created + */ + getScale(out: Vec3): Vec3; + /** + Returns the rotation factor component of a transformation matrix + @param out Vector to receive rotation component, if not provided, a new quaternion object will be created + */ + getRotation(out: Quat): Quat; + /** + Restore the matrix values from a quaternion rotation, vector translation and vector scale + @param q Rotation quaternion + @param v Translation vector + @param s Scaling vector + */ + fromRTS(q: Quat, v: Vec3, s: Vec3): Mat4; + /** + Restore the matrix values from a quaternion rotation + @param q Rotation quaternion + */ + fromQuat(q: Quat): Mat4; + } + /** !#en Representation of 2D vectors and points. + !#zh 表示 2D 向量和坐标 */ + export class Quat extends ValueType { + /** + !#en + Constructor + see {{#crossLink "cc/quat:method"}}cc.quat{{/crossLink}} + !#zh + 构造函数,可查看 {{#crossLink "cc/quat:method"}}cc.quat{{/crossLink}} + @param x x + @param y y + @param z z + @param w w + */ + constructor(x?: number, y?: number, z?: number, w?: number); + /** + !#en Calculate the multiply result between this quaternion and another one + !#zh 计算四元数乘积的结果 + @param other other + @param out out + */ + mul(other: Quat, out?: Quat): Quat; + /** + !#zh 获得指定四元数的拷贝 + !#en Obtaining copy specified quaternion + */ + static clone (a: Out): Quat; + /** + !#zh 复制目标四元数 + !#en Copy quaternion target + */ + static copy (out: Out, a: QuatLike): Out; + /** + !#zh 设置四元数值 + !#en Provided Quaternion Value + */ + static set (out: Out, x: number, y: number, z: number, w: number): Out; + /** + !#zh 将目标赋值为单位四元数 + !#en The target of an assignment as a unit quaternion + */ + static identity (out: Out): Out; + /** + !#zh 设置四元数为两向量间的最短路径旋转,默认两向量都已归一化 + !#en Set quaternion rotation is the shortest path between two vectors, the default two vectors are normalized + */ + static rotationTo (out: Out, a: VecLike, b: VecLike): Out; + /** + !#zh 获取四元数的旋转轴和旋转弧度 + !#en Get the rotary shaft and the arc of rotation quaternion + @param outAxis 旋转轴输出 + @param q 源四元数 + */ + static getAxisAngle (outAxis: VecLike, q: Out): number; + /** + !#zh 四元数乘法 + !#en Quaternion multiplication + */ + static multiply (out: Out, a: QuatLike_1, b: QuatLike_2): Out; + /** + !#zh 四元数标量乘法 + !#en Quaternion scalar multiplication + */ + static multiplyScalar (out: Out, a: Out, b: number): Out; + /** + !#zh 四元数乘加:A + B * scale + !#en Quaternion multiplication and addition: A + B * scale + */ + static scaleAndAdd (out: Out, a: Out, b: Out, scale: number): Out; + /** + !#zh 绕 X 轴旋转指定四元数 + !#en About the X axis specified quaternion + @param rad 旋转弧度 + */ + static rotateX (out: Out, a: Out, rad: number): Out; + /** + !#zh 绕 Y 轴旋转指定四元数 + !#en Rotation about the Y axis designated quaternion + @param rad 旋转弧度 + */ + static rotateY (out: Out, a: Out, rad: number): Out; + /** + !#zh 绕 Z 轴旋转指定四元数 + !#en Around the Z axis specified quaternion + @param rad 旋转弧度 + */ + static rotateZ (out: Out, a: Out, rad: number): Out; + /** + !#zh 绕世界空间下指定轴旋转四元数 + !#en Space around the world at a given axis of rotation quaternion + @param axis 旋转轴,默认已归一化 + @param rad 旋转弧度 + */ + static rotateAround (out: Out, rot: Out, axis: VecLike, rad: number): Out; + /** + !#zh 绕本地空间下指定轴旋转四元数 + !#en Local space around the specified axis rotation quaternion + @param axis 旋转轴 + @param rad 旋转弧度 + */ + static rotateAroundLocal (out: Out, rot: Out, axis: VecLike, rad: number): Out; + /** + !#zh 根据 xyz 分量计算 w 分量,默认已归一化 + !#en The component w xyz components calculated, normalized by default + */ + static calculateW (out: Out, a: Out): Out; + /** + !#zh 四元数点积(数量积) + !#en Quaternion dot product (scalar product) + */ + static dot (a: Out, b: Out): number; + /** + !#zh 逐元素线性插值: A + t * (B - A) + !#en Element by element linear interpolation: A + t * (B - A) + */ + static lerp (out: Out, a: Out, b: Out, t: number): Out; + /** + !#zh 带两个控制点的四元数球面插值 + !#en Quaternion with two spherical interpolation control points + */ + static sqlerp (out: Out, a: Out, b: Out, c: Out, d: Out, t: number): Out; + /** + !#zh 四元数求逆 + !#en Quaternion inverse + */ + static invert (out: Out, a: QuatLike): Out; + /** + !#zh 求共轭四元数,对单位四元数与求逆等价,但更高效 + !#en Conjugating a quaternion, and the unit quaternion equivalent to inversion, but more efficient + */ + static conjugate (out: Out, a: Out): Out; + /** + !#zh 求四元数长度 + !#en Seek length quaternion + */ + static len (a: Out): number; + /** + !#zh 求四元数长度平方 + !#en Seeking quaternion square of the length + */ + static lengthSqr (a: Out): number; + /** + !#zh 归一化四元数 + !#en Normalized quaternions + */ + static normalize (out: Out, a: Out): Out; + /** + !#zh 根据本地坐标轴朝向计算四元数,默认三向量都已归一化且相互垂直 + !#en Calculated according to the local orientation quaternion coordinate axis, the default three vectors are normalized and mutually perpendicular + */ + static fromAxes (out: Out, xAxis: VecLike, yAxis: VecLike, zAxis: VecLike): Out; + /** + !#zh 根据视口的前方向和上方向计算四元数 + !#en The forward direction and the direction of the viewport computing quaternion + @param view 视口面向的前方向,必须归一化 + @param up 视口的上方向,必须归一化,默认为 (0, 1, 0) + */ + static fromViewUp (out: Out, view: Vec3, up?: Vec3): Out; + /** + !#zh 根据旋转轴和旋转弧度计算四元数 + !#en The quaternion calculated and the arc of rotation of the rotary shaft + */ + static fromAxisAngle (out: Out, axis: VecLike, rad: number): Out; + /** + !#zh 根据三维矩阵信息计算四元数,默认输入矩阵不含有缩放信息 + !#en Calculating the three-dimensional quaternion matrix information, default zoom information input matrix does not contain + */ + static fromMat3 (out: Out, mat: Mat3): Out; + /** + !#zh 根据欧拉角信息计算四元数,旋转顺序为 YZX + !#en The quaternion calculated Euler angle information, rotation order YZX + */ + static fromEuler (out: Out, x: number, y: number, z: number): Out; + /** + !#zh 返回定义此四元数的坐标系 X 轴向量 + !#en This returns the result of the quaternion coordinate system X-axis vector + */ + static toAxisX (out: VecLike, q: Out): VecLike; + /** + !#zh 返回定义此四元数的坐标系 Y 轴向量 + !#en This returns the result of the quaternion coordinate system Y axis vector + */ + static toAxisY (out: VecLike, q: Out): VecLike; + /** + !#zh 返回定义此四元数的坐标系 Z 轴向量 + !#en This returns the result of the quaternion coordinate system the Z-axis vector + */ + static toAxisZ (out: VecLike, q: Out): VecLike; + /** + !#zh 根据四元数计算欧拉角,返回角度 x, y 在 [-180, 180] 区间内, z 默认在 [-90, 90] 区间内,旋转顺序为 YZX + !#en The quaternion calculated Euler angles, return angle x, y in the [-180, 180] interval, z default the range [-90, 90] interval, the rotation order YZX + @param outerZ z 取值范围区间改为 [-180, -90] U [90, 180] + */ + static toEuler (out: Out, q: IQuatLike, outerZ?: boolean): Out; + /** + !#zh 四元数等价判断 + !#en Analyzing quaternion equivalent + */ + static strictEquals (a: Out, b: Out): boolean; + /** + !#zh 排除浮点数误差的四元数近似等价判断 + !#en Negative floating point error quaternion approximately equivalent Analyzing + */ + static equals (a: Out, b: Out, epsilon?: number): boolean; + /** + !#zh 四元数转数组 + !#en Quaternion rotation array + @param ofs 数组内的起始偏移量 + */ + static toArray > (out: Out, q: IQuatLike, ofs?: number): Out; + /** + !#zh 数组转四元数 + !#en Array to a quaternion + @param ofs 数组起始偏移量 + */ + static fromArray (out: Out, arr: IWritableArrayLike, ofs?: number): Out; + x: number; + y: number; + z: number; + w: number; + /** + !#en clone a Quat object and return the new object + !#zh 克隆一个四元数并返回 + */ + clone(): Quat; + /** + !#en Set values with another quaternion + !#zh 用另一个四元数的值设置到当前对象上。 + @param newValue !#en new value to set. !#zh 要设置的新值 + */ + set(newValue: Quat): Quat; + /** + !#en Check whether current quaternion equals another + !#zh 当前的四元数是否与指定的四元数相等。 + @param other other + */ + equals(other: Quat): boolean; + /** + !#en Convert quaternion to euler + !#zh 转换四元数到欧拉角 + @param out out + */ + toEuler(out: Vec3): Vec3; + /** + !#en Convert euler to quaternion + !#zh 转换欧拉角到四元数 + @param euler euler + */ + fromEuler(euler: Vec3): Quat; + /** + !#en Calculate the interpolation result between this quaternion and another one with given ratio + !#zh 计算四元数的插值结果 + @param to to + @param ratio ratio + @param out out + */ + lerp(to: Quat, ratio: number, out?: Quat): Quat; + /** + !#en Calculate the multiply result between this quaternion and another one + !#zh 计算四元数乘积的结果 + @param other other + */ + multiply(other: Quat): Quat; + /** + !#en Rotates a quaternion by the given angle (in radians) about a world space axis. + !#zh 围绕世界空间轴按给定弧度旋转四元数 + @param rot Quaternion to rotate + @param axis The axis around which to rotate in world space + @param rad Angle (in radians) to rotate + @param out Quaternion to store result + */ + rotateAround(rot: Quat, axis: Vec3, rad: number, out?: Quat): Quat; + } + /** !#en A 2D rectangle defined by x, y position and width, height. + !#zh 通过位置和宽高定义的 2D 矩形。 */ + export class Rect extends ValueType { + /** + !#en + Constructor of Rect class. + see {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} for convenience method. + !#zh + Rect类的构造函数。可以通过 {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} 简便方法进行创建。 + @param x x + @param y y + @param w w + @param h h + */ + constructor(x?: number, y?: number, w?: number, h?: number); + /** + !#en Creates a rectangle from two coordinate values. + !#zh 根据指定 2 个坐标创建出一个矩形区域。 + @param v1 v1 + @param v2 v2 + + @example + ```js + cc.Rect.fromMinMax(cc.v2(10, 10), cc.v2(20, 20)); // Rect {x: 10, y: 10, width: 10, height: 10}; + ``` + */ + static fromMinMax(v1: Vec2, v2: Vec2): Rect; + x: number; + y: number; + width: number; + height: number; + /** + !#en TODO + !#zh 克隆一个新的 Rect。 + + @example + ```js + var a = new cc.Rect(0, 0, 10, 10); + a.clone();// Rect {x: 0, y: 0, width: 10, height: 10} + ``` + */ + clone(): Rect; + /** + !#en TODO + !#zh 是否等于指定的矩形。 + @param other other + + @example + ```js + var a = new cc.Rect(0, 0, 10, 10); + var b = new cc.Rect(0, 0, 10, 10); + a.equals(b);// true; + ``` + */ + equals(other: Rect): boolean; + /** + !#en TODO + !#zh 线性插值 + @param to to + @param ratio the interpolation coefficient. + @param out optional, the receiving vector. + + @example + ```js + var a = new cc.Rect(0, 0, 10, 10); + var b = new cc.Rect(50, 50, 100, 100); + update (dt) { + // method 1; + var c = a.lerp(b, dt * 0.1); + // method 2; + a.lerp(b, dt * 0.1, c); + } + ``` + */ + lerp(to: Rect, ratio: number, out?: Rect): Rect; + /** + !#en Check whether the current rectangle intersects with the given one + !#zh 当前矩形与指定矩形是否相交。 + @param rect rect + + @example + ```js + var a = new cc.Rect(0, 0, 10, 10); + var b = new cc.Rect(0, 0, 20, 20); + a.intersects(b);// true + ``` + */ + intersects(rect: Rect): boolean; + /** + !#en Returns the overlapping portion of 2 rectangles. + !#zh 返回 2 个矩形重叠的部分。 + @param out Stores the result + @param rectB rectB + + @example + ```js + var a = new cc.Rect(0, 10, 20, 20); + var b = new cc.Rect(0, 10, 10, 10); + var intersection = new cc.Rect(); + a.intersection(intersection, b); // intersection {x: 0, y: 10, width: 10, height: 10}; + ``` + */ + intersection(out: Rect, rectB: Rect): Rect; + /** + !#en Check whether the current rect contains the given point + !#zh 当前矩形是否包含指定坐标点。 + Returns true if the point inside this rectangle. + @param point point + + @example + ```js + var a = new cc.Rect(0, 0, 10, 10); + var b = new cc.Vec2(0, 5); + a.contains(b);// true + ``` + */ + contains(point: Vec2): boolean; + /** + !#en Returns true if the other rect totally inside this rectangle. + !#zh 当前矩形是否包含指定矩形。 + @param rect rect + + @example + ```js + var a = new cc.Rect(0, 0, 20, 20); + var b = new cc.Rect(0, 0, 10, 10); + a.containsRect(b);// true + ``` + */ + containsRect(rect: Rect): boolean; + /** + !#en Returns the smallest rectangle that contains the current rect and the given rect. + !#zh 返回一个包含当前矩形和指定矩形的最小矩形。 + @param out Stores the result + @param rectB rectB + + @example + ```js + var a = new cc.Rect(0, 10, 20, 20); + var b = new cc.Rect(0, 10, 10, 10); + var union = new cc.Rect(); + a.union(union, b); // union {x: 0, y: 10, width: 20, height: 20}; + ``` + */ + union(out: Rect, rectB: Rect): Rect; + /** + !#en Apply matrix4 to the rect. + !#zh 使用 mat4 对矩形进行矩阵转换。 + @param out The output rect + @param mat The matrix4 + */ + transformMat4(out: Rect, mat: Mat4): void; + /** + !#en Output rect informations to string + !#zh 转换为方便阅读的字符串 + + @example + ```js + var a = new cc.Rect(0, 0, 10, 10); + a.toString();// "(0.00, 0.00, 10.00, 10.00)"; + ``` + */ + toString(): string; + /** !#en The minimum x value, equals to rect.x + !#zh 矩形 x 轴上的最小值,等价于 rect.x。 */ + xMin: number; + /** !#en The minimum y value, equals to rect.y + !#zh 矩形 y 轴上的最小值。 */ + yMin: number; + /** !#en The maximum x value. + !#zh 矩形 x 轴上的最大值。 */ + xMax: number; + /** !#en The maximum y value. + !#zh 矩形 y 轴上的最大值。 */ + yMax: number; + /** !#en The position of the center of the rectangle. + !#zh 矩形的中心点。 */ + center: Vec2; + /** !#en The X and Y position of the rectangle. + !#zh 矩形的 x 和 y 坐标。 */ + origin: Vec2; + /** !#en Width and height of the rectangle. + !#zh 矩形的大小。 */ + size: Size; + } + /** !#en + cc.Size is the class for size object,
+ please do not use its constructor to create sizes,
+ use {{#crossLink "cc/size:method"}}{{/crossLink}} alias function instead.
+ It will be deprecated soon, please use cc.Vec2 instead. + + !#zh + cc.Size 是 size 对象的类。
+ 请不要使用它的构造函数创建的 size,
+ 使用 {{#crossLink "cc/size:method"}}{{/crossLink}} 别名函数。
+ 它不久将被取消,请使用cc.Vec2代替。 */ + export class Size { + /** + + @param width width + @param height height + */ + constructor(width: number|Size, height?: number); + /** !#en return a Size object with width = 0 and height = 0. + !#zh 返回一个宽度为 0 和高度为 0 的 Size 对象。 */ + static ZERO: Size; + width: number; + height: number; + /** + !#en TODO + !#zh 克隆 size 对象。 + + @example + ```js + var a = new cc.size(10, 10); + a.clone();// return Size {width: 0, height: 0}; + ``` + */ + clone(): Size; + /** + !#en TODO + !#zh 当前 Size 对象是否等于指定 Size 对象。 + @param other other + + @example + ```js + var a = new cc.size(10, 10); + a.equals(new cc.size(10, 10));// return true; + ``` + */ + equals(other: Size): boolean; + /** + !#en TODO + !#zh 线性插值。 + @param to to + @param ratio the interpolation coefficient. + @param out optional, the receiving vector. + + @example + ```js + var a = new cc.size(10, 10); + var b = new cc.rect(50, 50, 100, 100); + update (dt) { + // method 1; + var c = a.lerp(b, dt * 0.1); + // method 2; + a.lerp(b, dt * 0.1, c); + } + ``` + */ + lerp(to: Rect, ratio: number, out?: Size): Size; + /** + !#en TODO + !#zh 转换为方便阅读的字符串。 + + @example + ```js + var a = new cc.size(10, 10); + a.toString();// return "(10.00, 10.00)"; + ``` + */ + toString(): string; + } + /** !#en The base class of all value types. + !#zh 所有值类型的基类。 */ + export class ValueType { + /** + !#en This method returns an exact copy of current value. + !#zh 克隆当前值,该方法返回一个新对象,新对象的值和原对象相等。 + */ + clone(): ValueType; + /** + !#en Compares this object with the other one. + !#zh 当前对象是否等于指定对象。 + @param other other + */ + equals(other: ValueType): boolean; + /** + !#en + Linearly interpolates between this value to to value by ratio which is in the range [0, 1]. + When ratio = 0 returns this. When ratio = 1 return to. When ratio = 0.5 returns the average of this and to. + !#zh + 线性插值。
+ 当 ratio = 0 时返回自身,ratio = 1 时返回目标,ratio = 0.5 返回自身和目标的平均值。。 + @param to the to value + @param ratio the interpolation coefficient + */ + lerp(to: ValueType, ratio: number): ValueType; + /** + !#en + Copys all the properties from another given object to this value. + !#zh + 从其它对象把所有属性复制到当前对象。 + @param source the source to copy + */ + set(source: ValueType): void; + /** + !#en Convert to a readable string. + !#zh 转换为方便阅读的字符串。 + */ + toString(): string; + } + /** !#en Representation of 2D vectors and points. + !#zh 表示 2D 向量和坐标 */ + export class Vec2 extends ValueType { + /** + !#en Returns the length of this vector. + !#zh 返回该向量的长度。 + + @example + ```js + var v = cc.v2(10, 10); + v.mag(); // return 14.142135623730951; + ``` + */ + mag(): number; + /** + !#en Returns the squared length of this vector. + !#zh 返回该向量的长度平方。 + + @example + ```js + var v = cc.v2(10, 10); + v.magSqr(); // return 200; + ``` + */ + magSqr(): number; + /** + !#en Subtracts one vector from this. If you want to save result to another vector, use sub() instead. + !#zh 向量减法。如果你想保存结果到另一个向量,可使用 sub() 代替。 + @param vector vector + + @example + ```js + var v = cc.v2(10, 10); + v.subSelf(cc.v2(5, 5));// return Vec2 {x: 5, y: 5}; + ``` + */ + subSelf(vector: Vec2): Vec2; + /** + !#en Subtracts one vector from this, and returns the new result. + !#zh 向量减法,并返回新结果。 + @param vector vector + @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created + + @example + ```js + var v = cc.v2(10, 10); + v.sub(cc.v2(5, 5)); // return Vec2 {x: 5, y: 5}; + var v1; + v.sub(cc.v2(5, 5), v1); // return Vec2 {x: 5, y: 5}; + ``` + */ + sub(vector: Vec2, out?: Vec2): Vec2; + /** + !#en Multiplies this by a number. If you want to save result to another vector, use mul() instead. + !#zh 缩放当前向量。如果你想结果保存到另一个向量,可使用 mul() 代替。 + @param num num + + @example + ```js + var v = cc.v2(10, 10); + v.mulSelf(5);// return Vec2 {x: 50, y: 50}; + ``` + */ + mulSelf(num: number): Vec2; + /** + !#en Multiplies by a number, and returns the new result. + !#zh 缩放向量,并返回新结果。 + @param num num + @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created + + @example + ```js + var v = cc.v2(10, 10); + v.mul(5); // return Vec2 {x: 50, y: 50}; + var v1; + v.mul(5, v1); // return Vec2 {x: 50, y: 50}; + ``` + */ + mul(num: number, out?: Vec2): Vec2; + /** + !#en Divides by a number. If you want to save result to another vector, use div() instead. + !#zh 向量除法。如果你想结果保存到另一个向量,可使用 div() 代替。 + @param num num + + @example + ```js + var v = cc.v2(10, 10); + v.divSelf(5); // return Vec2 {x: 2, y: 2}; + ``` + */ + divSelf(num: number): Vec2; + /** + !#en Divides by a number, and returns the new result. + !#zh 向量除法,并返回新的结果。 + @param num num + @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created + + @example + ```js + var v = cc.v2(10, 10); + v.div(5); // return Vec2 {x: 2, y: 2}; + var v1; + v.div(5, v1); // return Vec2 {x: 2, y: 2}; + ``` + */ + div(num: number, out?: Vec2): Vec2; + /** + !#en Multiplies two vectors. + !#zh 分量相乘。 + @param vector vector + + @example + ```js + var v = cc.v2(10, 10); + v.scaleSelf(cc.v2(5, 5));// return Vec2 {x: 50, y: 50}; + ``` + */ + scaleSelf(vector: Vec2): Vec2; + /** + !#en Multiplies two vectors, and returns the new result. + !#zh 分量相乘,并返回新的结果。 + @param vector vector + @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created + + @example + ```js + var v = cc.v2(10, 10); + v.scale(cc.v2(5, 5)); // return Vec2 {x: 50, y: 50}; + var v1; + v.scale(cc.v2(5, 5), v1); // return Vec2 {x: 50, y: 50}; + ``` + */ + scale(vector: Vec2, out?: Vec2): Vec2; + /** + !#en Negates the components. If you want to save result to another vector, use neg() instead. + !#zh 向量取反。如果你想结果保存到另一个向量,可使用 neg() 代替。 + + @example + ```js + var v = cc.v2(10, 10); + v.negSelf(); // return Vec2 {x: -10, y: -10}; + ``` + */ + negSelf(): Vec2; + /** + !#en Negates the components, and returns the new result. + !#zh 返回取反后的新向量。 + @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created + + @example + ```js + var v = cc.v2(10, 10); + var v1; + v.neg(v1); // return Vec2 {x: -10, y: -10}; + ``` + */ + neg(out?: Vec2): Vec2; + /** !#en return a Vec2 object with x = 1 and y = 1. + !#zh 新 Vec2 对象。 */ + static ONE: Vec2; + /** !#en return a Vec2 object with x = 0 and y = 0. + !#zh 返回 x = 0 和 y = 0 的 Vec2 对象。 */ + static ZERO: Vec2; + /** !#en return a readonly Vec2 object with x = 0 and y = 0. + !#zh 返回一个 x = 0 和 y = 0 的 Vec2 只读对象。 */ + static ZERO_R: Vec2; + /** !#en return a Vec2 object with x = 0 and y = 1. + !#zh 返回 x = 0 和 y = 1 的 Vec2 对象。 */ + static UP: Vec2; + /** !#en return a readonly Vec2 object with x = 0 and y = 1. + !#zh 返回 x = 0 和 y = 1 的 Vec2 只读对象。 */ + static UP_R: Vec2; + /** !#en return a readonly Vec2 object with x = 1 and y = 0. + !#zh 返回 x = 1 和 y = 0 的 Vec2 只读对象。 */ + static RIGHT: Vec2; + /** !#en return a Vec2 object with x = 1 and y = 0. + !#zh 返回 x = 1 和 y = 0 的 Vec2 对象。 */ + static RIGHT_R: Vec2; + /** + !#zh 获得指定向量的拷贝 + */ + static clone (a: Out): Vec2; + /** + !#zh 复制指定向量的值 + */ + static copy (out: Out, a: Out): Out; + /** + !#zh 设置向量值 + */ + static set (out: Out, x: number, y: number): Out; + /** + !#zh 逐元素向量加法 + */ + static add (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量减法 + */ + static subtract (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量乘法 + */ + static multiply (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量除法 + */ + static divide (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量向上取整 + */ + static ceil (out: Out, a: Out): Out; + /** + !#zh 逐元素向量向下取整 + */ + static floor (out: Out, a: Out): Out; + /** + !#zh 逐元素向量最小值 + */ + static min (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量最大值 + */ + static max (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量四舍五入取整 + */ + static round (out: Out, a: Out): Out; + /** + !#zh 向量标量乘法 + */ + static multiplyScalar (out: Out, a: Out, b: number): Out; + /** + !#zh 逐元素向量乘加: A + B * scale + */ + static scaleAndAdd (out: Out, a: Out, b: Out, scale: number): Out; + /** + !#zh 求两向量的欧氏距离 + */ + static distance (a: Out, b: Out): number; + /** + !#zh 求两向量的欧氏距离平方 + */ + static squaredDistance (a: Out, b: Out): number; + /** + !#zh 求向量长度 + */ + static len (a: Out): number; + /** + !#zh 求向量长度平方 + */ + static lengthSqr (a: Out): number; + /** + !#zh 逐元素向量取负 + */ + static negate (out: Out, a: Out): Out; + /** + !#zh 逐元素向量取倒数,接近 0 时返回 Infinity + */ + static inverse (out: Out, a: Out): Out; + /** + !#zh 逐元素向量取倒数,接近 0 时返回 0 + */ + static inverseSafe (out: Out, a: Out): Out; + /** + !#zh 归一化向量 + */ + static normalize (out: Out, a: Vec2Like): Out; + /** + !#zh 向量点积(数量积) + */ + static dot (a: Out, b: Out): number; + /** + !#zh 向量叉积(向量积),注意二维向量的叉积为与 Z 轴平行的三维向量 + */ + static cross (out: Vec2, a: Out, b: Out): Vec2; + /** + !#zh 逐元素向量线性插值: A + t * (B - A) + */ + static lerp (out: Out, a: Out, b: Out, t: number): Out; + /** + !#zh 生成一个在单位圆上均匀分布的随机向量 + */ + static random (out: Out, scale?: number): Out; + /** + !#zh 向量与三维矩阵乘法,默认向量第三位为 1。 + */ + static transformMat3 (out: Out, a: Out, mat: IMat3Like): Out; + /** + !#zh 向量与四维矩阵乘法,默认向量第三位为 0,第四位为 1。 + */ + static transformMat4 (out: Out, a: Out, mat: MatLike): Out; + /** + !#zh 向量等价判断 + */ + static strictEquals (a: Out, b: Out): boolean; + /** + !#zh 排除浮点数误差的向量近似等价判断 + */ + static equals (a: Out, b: Out, epsilon?: number): boolean; + /** + !#zh 排除浮点数误差的向量近似等价判断 + */ + static angle (a: Out, b: Out): number; + /** + !#zh 向量转数组 + */ + static toArray > (out: Out, v: IVec2Like, ofs?: number): Out; + /** + !#zh 数组转向量 + */ + static fromArray (out: Out, arr: IWritableArrayLike, ofs?: number): Out; + x: number; + y: number; + /** + !#en + Constructor + see {{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} or {{#crossLink "cc/p:method"}}cc.p{{/crossLink}} + !#zh + 构造函数,可查看 {{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} 或者 {{#crossLink "cc/p:method"}}cc.p{{/crossLink}} + @param x x + @param y y + */ + constructor(x?: number, y?: number); + /** + !#en clone a Vec2 object + !#zh 克隆一个 Vec2 对象 + */ + clone(): Vec2; + /** + !#en Sets vector with another's value + !#zh 设置向量值。 + @param newValue !#en new value to set. !#zh 要设置的新值 + */ + set(newValue: Vec2): Vec2; + /** + !#en Check whether two vector equal + !#zh 当前的向量是否与指定的向量相等。 + @param other other + */ + equals(other: Vec2): boolean; + /** + !#en Check whether two vector equal with some degree of variance. + !#zh + 近似判断两个点是否相等。
+ 判断 2 个向量是否在指定数值的范围之内,如果在则返回 true,反之则返回 false。 + @param other other + @param variance variance + */ + fuzzyEquals(other: Vec2, variance: number): boolean; + /** + !#en Transform to string with vector informations + !#zh 转换为方便阅读的字符串。 + */ + toString(): string; + /** + !#en Calculate linear interpolation result between this vector and another one with given ratio + !#zh 线性插值。 + @param to to + @param ratio the interpolation coefficient + @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created + */ + lerp(to: Vec2, ratio: number, out?: Vec2): Vec2; + /** + !#en Clamp the vector between from float and to float. + !#zh + 返回指定限制区域后的向量。
+ 向量大于 max_inclusive 则返回 max_inclusive。
+ 向量小于 min_inclusive 则返回 min_inclusive。
+ 否则返回自身。 + @param min_inclusive min_inclusive + @param max_inclusive max_inclusive + + @example + ```js + var min_inclusive = cc.v2(0, 0); + var max_inclusive = cc.v2(20, 20); + var v1 = cc.v2(20, 20).clampf(min_inclusive, max_inclusive); // Vec2 {x: 20, y: 20}; + var v2 = cc.v2(0, 0).clampf(min_inclusive, max_inclusive); // Vec2 {x: 0, y: 0}; + var v3 = cc.v2(10, 10).clampf(min_inclusive, max_inclusive); // Vec2 {x: 10, y: 10}; + ``` + */ + clampf(min_inclusive: Vec2, max_inclusive: Vec2): Vec2; + /** + !#en Adds this vector. + !#zh 向量加法。 + @param vector vector + @param out out + + @example + ```js + var v = cc.v2(10, 10); + v.add(cc.v2(5, 5));// return Vec2 {x: 15, y: 15}; + ``` + */ + add(vector: Vec2, out?: Vec2): Vec2; + /** + !#en Adds this vector. If you want to save result to another vector, use add() instead. + !#zh 向量加法。如果你想保存结果到另一个向量,使用 add() 代替。 + @param vector vector + */ + addSelf(vector: Vec2): Vec2; + /** + !#en Subtracts one vector from this. + !#zh 向量减法。 + @param vector vector + + @example + ```js + var v = cc.v2(10, 10); + v.subSelf(cc.v2(5, 5));// return Vec2 {x: 5, y: 5}; + ``` + */ + subtract(vector: Vec2): Vec2; + /** + !#en Multiplies this by a number. + !#zh 缩放当前向量。 + @param num num + + @example + ```js + var v = cc.v2(10, 10); + v.multiply(5);// return Vec2 {x: 50, y: 50}; + ``` + */ + multiplyScalar(num: number): Vec2; + /** + !#en Multiplies two vectors. + !#zh 分量相乘。 + @param vector vector + + @example + ```js + var v = cc.v2(10, 10); + v.multiply(cc.v2(5, 5));// return Vec2 {x: 50, y: 50}; + ``` + */ + multiply(vector: Vec2): Vec2; + /** + !#en Divides by a number. + !#zh 向量除法。 + @param num num + + @example + ```js + var v = cc.v2(10, 10); + v.divide(5); // return Vec2 {x: 2, y: 2}; + ``` + */ + divide(num: number): Vec2; + /** + !#en Negates the components. + !#zh 向量取反。 + + @example + ```js + var v = cc.v2(10, 10); + v.negate(); // return Vec2 {x: -10, y: -10}; + ``` + */ + negate(): Vec2; + /** + !#en Dot product + !#zh 当前向量与指定向量进行点乘。 + @param vector vector + + @example + ```js + var v = cc.v2(10, 10); + v.dot(cc.v2(5, 5)); // return 100; + ``` + */ + dot(vector?: Vec2): number; + /** + !#en Cross product + !#zh 当前向量与指定向量进行叉乘。 + @param vector vector + + @example + ```js + var v = cc.v2(10, 10); + v.cross(cc.v2(5, 5)); // return 0; + ``` + */ + cross(vector?: Vec2): number; + /** + !#en Returns the length of this vector. + !#zh 返回该向量的长度。 + + @example + ```js + var v = cc.v2(10, 10); + v.len(); // return 14.142135623730951; + ``` + */ + len(): number; + /** + !#en Returns the squared length of this vector. + !#zh 返回该向量的长度平方。 + + @example + ```js + var v = cc.v2(10, 10); + v.lengthSqr(); // return 200; + ``` + */ + lengthSqr(): number; + /** + !#en Make the length of this vector to 1. + !#zh 向量归一化,让这个向量的长度为 1。 + + @example + ```js + var v = cc.v2(10, 10); + v.normalizeSelf(); // return Vec2 {x: 0.7071067811865475, y: 0.7071067811865475}; + ``` + */ + normalizeSelf(): Vec2; + /** + !#en + Returns this vector with a magnitude of 1.
+
+ Note that the current vector is unchanged and a new normalized vector is returned. If you want to normalize the current vector, use normalizeSelf function. + !#zh + 返回归一化后的向量。
+
+ 注意,当前向量不变,并返回一个新的归一化向量。如果你想来归一化当前向量,可使用 normalizeSelf 函数。 + @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created + */ + normalize(out?: Vec2): Vec2; + /** + !#en Get angle in radian between this and vector. + !#zh 夹角的弧度。 + @param vector vector + */ + angle(vector: Vec2): number; + /** + !#en Get angle in radian between this and vector with direction. + !#zh 带方向的夹角的弧度。 + @param vector vector + */ + signAngle(vector: Vec2): number; + /** + !#en rotate + !#zh 返回旋转给定弧度后的新向量。 + @param radians radians + @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created + */ + rotate(radians: number, out?: Vec2): Vec2; + /** + !#en rotate self + !#zh 按指定弧度旋转向量。 + @param radians radians + */ + rotateSelf(radians: number): Vec2; + /** + !#en Calculates the projection of the current vector over the given vector. + !#zh 返回当前向量在指定 vector 向量上的投影向量。 + @param vector vector + + @example + ```js + var v1 = cc.v2(20, 20); + var v2 = cc.v2(5, 5); + v1.project(v2); // Vec2 {x: 20, y: 20}; + ``` + */ + project(vector: Vec2): Vec2; + /** + Transforms the vec2 with a mat4. 3rd vector component is implicitly '0', 4th vector component is implicitly '1' + @param m matrix to transform with + @param out the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created + */ + transformMat4(m: Mat4, out?: Vec2): Vec2; + /** + Returns the maximum value in x, y. + */ + maxAxis(): number; + } + /** !#en Representation of 3D vectors and points. + !#zh 表示 3D 向量和坐标 */ + export class Vec3 extends ValueType { + /** + !#en Returns the length of this vector. + !#zh 返回该向量的长度。 + + @example + ```js + var v = cc.v3(10, 10, 10); + v.mag(); // return 17.320508075688775; + ``` + */ + mag(): number; + /** + !#en Returns the squared length of this vector. + !#zh 返回该向量的长度平方。 + */ + magSqr(): number; + /** + !#en Subtracts one vector from this. If you want to save result to another vector, use sub() instead. + !#zh 向量减法。如果你想保存结果到另一个向量,可使用 sub() 代替。 + @param vector vector + */ + subSelf(vector: Vec3): Vec3; + /** + !#en Subtracts one vector from this, and returns the new result. + !#zh 向量减法,并返回新结果。 + @param vector vector + @param out optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created + */ + sub(vector: Vec3, out?: Vec3): Vec3; + /** + !#en Multiplies this by a number. If you want to save result to another vector, use mul() instead. + !#zh 缩放当前向量。如果你想结果保存到另一个向量,可使用 mul() 代替。 + @param num num + */ + mulSelf(num: number): Vec3; + /** + !#en Multiplies by a number, and returns the new result. + !#zh 缩放向量,并返回新结果。 + @param num num + @param out optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created + */ + mul(num: number, out?: Vec3): Vec3; + /** + !#en Divides by a number. If you want to save result to another vector, use div() instead. + !#zh 向量除法。如果你想结果保存到另一个向量,可使用 div() 代替。 + @param num num + */ + divSelf(num: number): Vec3; + /** + !#en Divides by a number, and returns the new result. + !#zh 向量除法,并返回新的结果。 + @param num num + @param out optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created + */ + div(num: number, out?: Vec3): Vec3; + /** + !#en Multiplies two vectors. + !#zh 分量相乘。 + @param vector vector + */ + scaleSelf(vector: Vec3): Vec3; + /** + !#en Multiplies two vectors, and returns the new result. + !#zh 分量相乘,并返回新的结果。 + @param vector vector + @param out optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created + */ + scale(vector: Vec3, out?: Vec3): Vec3; + /** + !#en Negates the components. If you want to save result to another vector, use neg() instead. + !#zh 向量取反。如果你想结果保存到另一个向量,可使用 neg() 代替。 + */ + negSelf(): Vec3; + /** + !#en Negates the components, and returns the new result. + !#zh 返回取反后的新向量。 + @param out optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created + */ + neg(out?: Vec3): Vec3; + /** !#en return a Vec3 object with x = 1, y = 1, z = 1. + !#zh 新 Vec3 对象。 */ + static ONE: Vec3; + /** !#en return a Vec3 object with x = 0, y = 0, z = 0. + !#zh 返回 x = 0,y = 0,z = 0 的 Vec3 对象。 */ + static ZERO: Vec3; + /** !#en return a Vec3 object with x = 0, y = 1, z = 0. + !#zh 返回 x = 0, y = 1, z = 0 的 Vec3 对象。 */ + static UP: Vec3; + /** !#en return a Vec3 object with x = 1, y = 0, z = 0. + !#zh 返回 x = 1,y = 0,z = 0 的 Vec3 对象。 */ + static RIGHT: Vec3; + /** !#en return a Vec3 object with x = 0, y = 0, z = 1. + !#zh 返回 x = 0,y = 0,z = 1 的 Vec3 对象。 */ + static FORWARD: Vec3; + /** + !#zh 将目标赋值为零向量 + !#en The target of an assignment zero vector + */ + static zero (out: Out): Out; + /** + !#zh 获得指定向量的拷贝 + !#en Obtaining copy vectors designated + */ + static clone (a: Out): Vec3; + /** + !#zh 复制目标向量 + !#en Copy the target vector + */ + static copy (out: Out, a: Vec3Like): Out; + /** + !#zh 设置向量值 + !#en Set to value + */ + static set (out: Out, x: number, y: number, z: number): Out; + /** + !#zh 逐元素向量加法 + !#en Element-wise vector addition + */ + static add (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量减法 + !#en Element-wise vector subtraction + */ + static subtract (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量乘法 (分量积) + !#en Element-wise vector multiplication (product component) + */ + static multiply (out: Out, a: Vec3Like_1, b: Vec3Like_2): Out; + /** + !#zh 逐元素向量除法 + !#en Element-wise vector division + */ + static divide (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量向上取整 + !#en Rounding up by elements of the vector + */ + static ceil (out: Out, a: Out): Out; + /** + !#zh 逐元素向量向下取整 + !#en Element vector by rounding down + */ + static floor (out: Out, a: Out): Out; + /** + !#zh 逐元素向量最小值 + !#en The minimum by-element vector + */ + static min (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量最大值 + !#en The maximum value of the element-wise vector + */ + static max (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量四舍五入取整 + !#en Element-wise vector of rounding to whole + */ + static round (out: Out, a: Out): Out; + /** + !#zh 向量标量乘法 + !#en Vector scalar multiplication + */ + static multiplyScalar (out: Out, a: Vec3Like, b: number): Out; + /** + !#zh 逐元素向量乘加: A + B * scale + !#en Element-wise vector multiply add: A + B * scale + */ + static scaleAndAdd (out: Out, a: Out, b: Out, scale: number): Out; + /** + !#zh 求两向量的欧氏距离 + !#en Seeking two vectors Euclidean distance + */ + static distance (a: Out, b: Out): number; + /** + !#zh 求两向量的欧氏距离平方 + !#en Euclidean distance squared seeking two vectors + */ + static squaredDistance (a: Out, b: Out): number; + /** + !#zh 求向量长度 + !#en Seeking vector length + */ + static len (a: Out): number; + /** + !#zh 求向量长度平方 + !#en Seeking squared vector length + */ + static lengthSqr (a: Out): number; + /** + !#zh 逐元素向量取负 + !#en By taking the negative elements of the vector + */ + static negate (out: Out, a: Out): Out; + /** + !#zh 逐元素向量取倒数,接近 0 时返回 Infinity + !#en Element vector by taking the inverse, return near 0 Infinity + */ + static inverse (out: Out, a: Out): Out; + /** + !#zh 逐元素向量取倒数,接近 0 时返回 0 + !#en Element vector by taking the inverse, return near 0 0 + */ + static inverseSafe (out: Out, a: Out): Out; + /** + !#zh 归一化向量 + !#en Normalized vector + */ + static normalize (out: Out, a: Vec3Like): Out; + /** + !#zh 向量点积(数量积) + !#en Vector dot product (scalar product) + */ + static dot (a: Out, b: Out): number; + /** + !#zh 向量叉积(向量积) + !#en Vector cross product (vector product) + */ + static cross (out: Out, a: Vec3Like_1, b: Vec3Like_2): Out; + /** + !#zh 逐元素向量线性插值: A + t * (B - A) + !#en Vector element by element linear interpolation: A + t * (B - A) + */ + static lerp (out: Out, a: Out, b: Out, t: number): Out; + /** + !#zh 生成一个在单位球体上均匀分布的随机向量 + !#en Generates a uniformly distributed random vectors on the unit sphere + @param scale 生成的向量长度 + */ + static random (out: Out, scale?: number): Out; + /** + !#zh 向量与四维矩阵乘法,默认向量第四位为 1。 + !#en Four-dimensional vector and matrix multiplication, the default vectors fourth one. + */ + static transformMat4 (out: Out, a: Vec3Like, mat: MatLike): Out; + /** + !#zh 向量与四维矩阵乘法,默认向量第四位为 0。 + !#en Four-dimensional vector and matrix multiplication, vector fourth default is 0. + */ + static transformMat4Normal (out: Out, a: Out, mat: MatLike): Out; + /** + !#zh 向量与三维矩阵乘法 + !#en Dimensional vector matrix multiplication + */ + static transformMat3 (out: Out, a: Out, mat: MatLike): Out; + /** + !#zh 向量仿射变换 + !#en Affine transformation vector + */ + static transformAffine(out: Out, v: VecLike, mat: MatLike): Out; + /** + !#zh 向量四元数乘法 + !#en Vector quaternion multiplication + */ + static transformQuat (out: Out, a: VecLike, q: QuatLike): Out; + /** + !#zh 以缩放 -> 旋转 -> 平移顺序变换向量 + !#en To scale -> rotation -> transformation vector sequence translation + */ + static transformRTS(out: Out, a: VecLike, r: QuatLike, t: VecLike, s: VecLike): Out; + /** + !#zh 以平移 -> 旋转 -> 缩放顺序逆变换向量 + !#en Translational -> rotation -> Zoom inverse transformation vector sequence + */ + static transformInverseRTS(out: Out, a: VecLike, r: QuatLike, t: VecLike, s: VecLike): Out; + /** + !#zh 绕 X 轴旋转向量指定弧度 + !#en Rotation vector specified angle about the X axis + @param v 待旋转向量 + @param o 旋转中心 + @param a 旋转弧度 + */ + static rotateX (out: Out, v: Out, o: Out, a: number): Out; + /** + !#zh 绕 Y 轴旋转向量指定弧度 + !#en Rotation vector specified angle around the Y axis + @param v 待旋转向量 + @param o 旋转中心 + @param a 旋转弧度 + */ + static rotateY (out: Out, v: Out, o: Out, a: number): Out; + /** + !#zh 绕 Z 轴旋转向量指定弧度 + !#en Around the Z axis specified angle vector + @param v 待旋转向量 + @param o 旋转中心 + @param a 旋转弧度 + */ + static rotateZ (out: Out, v: Out, o: Out, a: number): Out; + /** + !#zh 向量等价判断 + !#en Equivalent vectors Analyzing + */ + static strictEquals (a: Out, b: Out): boolean; + /** + !#zh 排除浮点数误差的向量近似等价判断 + !#en Negative error vector floating point approximately equivalent Analyzing + */ + static equals (a: Out, b: Out, epsilon?: number): boolean; + /** + !#zh 求两向量夹角弧度 + !#en Radian angle between two vectors seek + */ + static angle (a: Out, b: Out): number; + /** + !#zh 计算向量在指定平面上的投影 + !#en Calculating a projection vector in the specified plane + @param a 待投影向量 + @param n 指定平面的法线 + */ + static projectOnPlane (out: Out, a: Out, n: Out): Out; + /** + !#zh 计算向量在指定向量上的投影 + !#en Projection vector calculated in the vector designated + @param a 待投影向量 + @param n 目标向量 + */ + static project (out: Out, a: Out, b: Out): Out; + /** + !#zh 向量转数组 + !#en Vector transfer array + @param ofs 数组起始偏移量 + */ + static toArray > (out: Out, v: IVec3Like, ofs?: number): Out; + /** + !#zh 数组转向量 + !#en Array steering amount + @param ofs 数组起始偏移量 + */ + static fromArray (out: Out, arr: IWritableArrayLike, ofs?: number): Out; + x: number; + y: number; + z: number; + /** + !#en + Constructor + see {{#crossLink "cc/vec3:method"}}cc.v3{{/crossLink}} + !#zh + 构造函数,可查看 {{#crossLink "cc/vec3:method"}}cc.v3{{/crossLink}} + @param x x + @param y y + @param z z + */ + constructor(x?: Vec3|number, y?: number, z?: number); + /** + !#en clone a Vec3 value + !#zh 克隆一个 Vec3 值 + */ + clone(): Vec3; + /** + !#en Set the current vector value with the given vector. + !#zh 用另一个向量设置当前的向量对象值。 + @param newValue !#en new value to set. !#zh 要设置的新值 + */ + set(newValue: Vec3): Vec3; + /** + !#en Check whether the vector equals another one + !#zh 当前的向量是否与指定的向量相等。 + @param other other + */ + equals(other: Vec3): boolean; + /** + !#en Check whether two vector equal with some degree of variance. + !#zh + 近似判断两个点是否相等。
+ 判断 2 个向量是否在指定数值的范围之内,如果在则返回 true,反之则返回 false。 + @param other other + @param variance variance + */ + fuzzyEquals(other: Vec3, variance: number): boolean; + /** + !#en Transform to string with vector informations + !#zh 转换为方便阅读的字符串。 + */ + toString(): string; + /** + !#en Calculate linear interpolation result between this vector and another one with given ratio + !#zh 线性插值。 + @param to to + @param ratio the interpolation coefficient + @param out optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created + */ + lerp(to: Vec3, ratio: number, out?: Vec3): Vec3; + /** + !#en Clamp the vector between from float and to float. + !#zh + 返回指定限制区域后的向量。
+ 向量大于 max_inclusive 则返回 max_inclusive。
+ 向量小于 min_inclusive 则返回 min_inclusive。
+ 否则返回自身。 + @param min_inclusive min_inclusive + @param max_inclusive max_inclusive + */ + clampf(min_inclusive: Vec3, max_inclusive: Vec3): Vec3; + /** + !#en Adds this vector. If you want to save result to another vector, use add() instead. + !#zh 向量加法。如果你想保存结果到另一个向量,使用 add() 代替。 + @param vector vector + */ + addSelf(vector: Vec3): Vec3; + /** + !#en Adds two vectors, and returns the new result. + !#zh 向量加法,并返回新结果。 + @param vector vector + @param out optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created + */ + add(vector: Vec3, out?: Vec3): Vec3; + /** + !#en Subtracts one vector from this. + !#zh 向量减法。 + @param vector vector + */ + subtract(vector: Vec3): Vec3; + /** + !#en Multiplies this by a number. + !#zh 缩放当前向量。 + @param num num + */ + multiplyScalar(num: number): Vec3; + /** + !#en Multiplies two vectors. + !#zh 分量相乘。 + @param vector vector + */ + multiply(vector: Vec3): Vec3; + /** + !#en Divides by a number. + !#zh 向量除法。 + @param num num + */ + divide(num: number): Vec3; + /** + !#en Negates the components. + !#zh 向量取反。 + */ + negate(): Vec3; + /** + !#en Dot product + !#zh 当前向量与指定向量进行点乘。 + @param vector vector + */ + dot(vector?: Vec3): number; + /** + !#en Cross product + !#zh 当前向量与指定向量进行叉乘。 + @param vector vector + @param out out + */ + cross(vector: Vec3, out?: Vec3): Vec3; + /** + !#en Returns the length of this vector. + !#zh 返回该向量的长度。 + + @example + ```js + var v = cc.v3(10, 10, 10); + v.len(); // return 17.320508075688775; + ``` + */ + len(): number; + /** + !#en Returns the squared length of this vector. + !#zh 返回该向量的长度平方。 + */ + lengthSqr(): number; + /** + !#en Make the length of this vector to 1. + !#zh 向量归一化,让这个向量的长度为 1。 + */ + normalizeSelf(): Vec3; + /** + !#en + Returns this vector with a magnitude of 1.
+
+ Note that the current vector is unchanged and a new normalized vector is returned. If you want to normalize the current vector, use normalizeSelf function. + !#zh + 返回归一化后的向量。
+
+ 注意,当前向量不变,并返回一个新的归一化向量。如果你想来归一化当前向量,可使用 normalizeSelf 函数。 + @param out optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created + */ + normalize(out?: Vec3): Vec3; + /** + Transforms the vec3 with a mat4. 4th vector component is implicitly '1' + @param m matrix to transform with + @param out the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created + */ + transformMat4(m: Mat4, out?: Vec3): Vec3; + /** + Returns the maximum value in x, y, and z + */ + maxAxis(): number; + /** + !#en Get angle in radian between this and vector. + !#zh 夹角的弧度。 + @param vector vector + */ + angle(vector: Vec3): number; + /** + !#en Calculates the projection of the current vector over the given vector. + !#zh 返回当前向量在指定 vector 向量上的投影向量。 + @param vector vector + + @example + ```js + var v1 = cc.v3(20, 20, 20); + var v2 = cc.v3(5, 5, 5); + v1.project(v2); // Vec3 {x: 20, y: 20, z: 20}; + ``` + */ + project(vector: Vec3): Vec3; + /** + !#en Get angle in radian between this and vector with direction.
+ In order to compatible with the vec2 API. + !#zh 带方向的夹角的弧度。该方法仅用做兼容 2D 计算。 + @param vector vector + */ + signAngle(vector: Vec3|Vec2): number; + /** + !#en rotate. In order to compatible with the vec2 API. + !#zh 返回旋转给定弧度后的新向量。该方法仅用做兼容 2D 计算。 + @param radians radians + @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created + */ + rotate(radians: number, out?: Vec3): Vec2; + /** + !#en rotate self. In order to compatible with the vec2 API. + !#zh 按指定弧度旋转向量。该方法仅用做兼容 2D 计算。 + @param radians radians + */ + rotateSelf(radians: number): Vec3; + } + /** !#en Representation of 3D vectors and points. + !#zh 表示 3D 向量和坐标 */ + export class Vec4 extends ValueType { + /** + !#en Subtracts one vector from this. If you want to save result to another vector, use sub() instead. + !#zh 向量减法。如果你想保存结果到另一个向量,可使用 sub() 代替。 + @param vector vector + */ + subSelf(vector: Vec4): Vec4; + /** + !#en Subtracts one vector from this, and returns the new result. + !#zh 向量减法,并返回新结果。 + @param vector vector + @param out optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created + */ + sub(vector: Vec4, out?: Vec4): Vec4; + /** + !#en Multiplies this by a number. If you want to save result to another vector, use mul() instead. + !#zh 缩放当前向量。如果你想结果保存到另一个向量,可使用 mul() 代替。 + @param num num + */ + mulSelf(num: number): Vec4; + /** + !#en Multiplies by a number, and returns the new result. + !#zh 缩放向量,并返回新结果。 + @param num num + @param out optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created + */ + mul(num: number, out?: Vec4): Vec4; + /** + !#en Divides by a number. If you want to save result to another vector, use div() instead. + !#zh 向量除法。如果你想结果保存到另一个向量,可使用 div() 代替。 + @param num num + */ + divSelf(num: number): Vec4; + /** + !#en Divides by a number, and returns the new result. + !#zh 向量除法,并返回新的结果。 + @param num num + @param out optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created + */ + div(num: number, out?: Vec4): Vec4; + /** + !#en Multiplies two vectors. + !#zh 分量相乘。 + @param vector vector + */ + scaleSelf(vector: Vec4): Vec4; + /** + !#en Multiplies two vectors, and returns the new result. + !#zh 分量相乘,并返回新的结果。 + @param vector vector + @param out optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created + */ + scale(vector: Vec4, out?: Vec4): Vec4; + /** + !#en Negates the components. If you want to save result to another vector, use neg() instead. + !#zh 向量取反。如果你想结果保存到另一个向量,可使用 neg() 代替。 + */ + negSelf(): Vec4; + /** + !#en Negates the components, and returns the new result. + !#zh 返回取反后的新向量。 + @param out optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created + */ + neg(out?: Vec4): Vec4; + /** + !#zh 获得指定向量的拷贝 + !#en Obtaining copy vectors designated + */ + static clone (a: Out): Vec4; + /** + !#zh 复制目标向量 + !#en Copy the target vector + */ + static copy (out: Out, a: Out): Out; + /** + !#zh 设置向量值 + !#en Set to value + */ + static set (out: Out, x: number, y: number, z: number, w: number): Out; + /** + !#zh 逐元素向量加法 + !#en Element-wise vector addition + */ + static add (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量减法 + !#en Element-wise vector subtraction + */ + static subtract (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量乘法 + !#en Element-wise vector multiplication + */ + static multiply (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量除法 + !#en Element-wise vector division + */ + static divide (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量向上取整 + !#en Rounding up by elements of the vector + */ + static ceil (out: Out, a: Out): Out; + /** + !#zh 逐元素向量向下取整 + !#en Element vector by rounding down + */ + static floor (out: Out, a: Out): Out; + /** + !#zh 逐元素向量最小值 + !#en The minimum by-element vector + */ + static min (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量最大值 + !#en The maximum value of the element-wise vector + */ + static max (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量四舍五入取整 + !#en Element-wise vector of rounding to whole + */ + static round (out: Out, a: Out): Out; + /** + !#zh 向量标量乘法 + !#en Vector scalar multiplication + */ + static multiplyScalar (out: Out, a: Out, b: number): Out; + /** + !#zh 逐元素向量乘加: A + B * scale + !#en Element-wise vector multiply add: A + B * scale + */ + static scaleAndAdd (out: Out, a: Out, b: Out, scale: number): Out; + /** + !#zh 求两向量的欧氏距离 + !#en Seeking two vectors Euclidean distance + */ + static distance (a: Out, b: Out): number; + /** + !#zh 求两向量的欧氏距离平方 + !#en Euclidean distance squared seeking two vectors + */ + static squaredDistance (a: Out, b: Out): number; + /** + !#zh 求向量长度 + !#en Seeking vector length + */ + static len (a: Out): number; + /** + !#zh 求向量长度平方 + !#en Seeking squared vector length + */ + static lengthSqr (a: Out): number; + /** + !#zh 逐元素向量取负 + !#en By taking the negative elements of the vector + */ + static negate (out: Out, a: Out): Out; + /** + !#zh 逐元素向量取倒数,接近 0 时返回 Infinity + !#en Element vector by taking the inverse, return near 0 Infinity + */ + static inverse (out: Out, a: Out): Out; + /** + !#zh 逐元素向量取倒数,接近 0 时返回 0 + !#en Element vector by taking the inverse, return near 0 0 + */ + static inverseSafe (out: Out, a: Out): Out; + /** + !#zh 归一化向量 + !#en Normalized vector + */ + static normalize (out: Out, a: Out): Out; + /** + !#zh 向量点积(数量积) + !#en Vector dot product (scalar product) + */ + static dot (a: Out, b: Out): number; + /** + !#zh 逐元素向量线性插值: A + t * (B - A) + !#en Vector element by element linear interpolation: A + t * (B - A) + */ + static lerp (out: Out, a: Out, b: Out, t: number): Out; + /** + !#zh 生成一个在单位球体上均匀分布的随机向量 + !#en Generates a uniformly distributed random vectors on the unit sphere + @param scale 生成的向量长度 + */ + static random (out: Out, scale?: number): Out; + /** + !#zh 向量矩阵乘法 + !#en Vector matrix multiplication + */ + static transformMat4 (out: Out, a: Out, mat: MatLike): Out; + /** + !#zh 向量仿射变换 + !#en Affine transformation vector + */ + static transformAffine(out: Out, v: VecLike, mat: MatLike): Out; + /** + !#zh 向量四元数乘法 + !#en Vector quaternion multiplication + */ + static transformQuat (out: Out, a: Out, q: QuatLike): Out; + /** + !#zh 向量等价判断 + !#en Equivalent vectors Analyzing + */ + static strictEquals (a: Out, b: Out): boolean; + /** + !#zh 排除浮点数误差的向量近似等价判断 + !#en Negative error vector floating point approximately equivalent Analyzing + */ + static equals (a: Out, b: Out, epsilon?: number): boolean; + /** + !#zh 向量转数组 + !#en Vector transfer array + @param ofs 数组起始偏移量 + */ + static toArray > (out: Out, v: IVec4Like, ofs?: number): Out; + /** + !#zh 数组转向量 + !#en Array steering amount + @param ofs 数组起始偏移量 + */ + static fromArray (out: Out, arr: IWritableArrayLike, ofs?: number): Out; + x: number; + y: number; + z: number; + w: number; + /** + !#en + Constructor + see {{#crossLink "cc/vec4:method"}}cc.v4{{/crossLink}} + !#zh + 构造函数,可查看 {{#crossLink "cc/vec4:method"}}cc.v4{{/crossLink}} + @param x x + @param y y + @param z z + @param w w + */ + constructor(x?: number, y?: number, z?: number, w?: number); + /** + !#en clone a Vec4 value + !#zh 克隆一个 Vec4 值 + */ + clone(): Vec4; + /** + !#en Set the current vector value with the given vector. + !#zh 用另一个向量设置当前的向量对象值。 + @param newValue !#en new value to set. !#zh 要设置的新值 + */ + set(newValue: Vec4): Vec4; + /** + !#en Check whether the vector equals another one + !#zh 当前的向量是否与指定的向量相等。 + @param other other + @param epsilon epsilon + */ + equals(other: Vec4, epsilon?: number): boolean; + /** + !#en Check whether the vector equals another one + !#zh 判断当前向量是否在误差范围内与指定分量的向量相等。 + @param x 相比较的向量的 x 分量。 + @param y 相比较的向量的 y 分量。 + @param z 相比较的向量的 z 分量。 + @param w 相比较的向量的 w 分量。 + @param epsilon 允许的误差,应为非负数。 + */ + equals4f(x: number, y: number, z: number, w: number, epsilon?: number): boolean; + /** + !#en Check whether strict equals other Vec4 + !#zh 判断当前向量是否与指定向量相等。两向量的各分量都分别相等时返回 `true`;否则返回 `false`。 + @param other 相比较的向量。 + */ + strictEquals(other: Vec4): boolean; + /** + !#en Check whether strict equals other Vec4 + !#zh 判断当前向量是否与指定分量的向量相等。两向量的各分量都分别相等时返回 `true`;否则返回 `false`。 + @param x 指定向量的 x 分量。 + @param y 指定向量的 y 分量。 + @param z 指定向量的 z 分量。 + @param w 指定向量的 w 分量。 + */ + strictEquals4f(x: number, y: number, z: number, w: number): boolean; + /** + !#en Calculate linear interpolation result between this vector and another one with given ratio + !#zh 根据指定的插值比率,从当前向量到目标向量之间做插值。 + @param to 目标向量。 + @param ratio 插值比率,范围为 [0,1]。 + */ + lerp(to: Vec4, ratio: number): Vec4; + /** + !#en Transform to string with vector informations + !#zh 返回当前向量的字符串表示。 + */ + toString(): string; + /** + !#en Clamp the vector between minInclusive and maxInclusive. + !#zh 设置当前向量的值,使其各个分量都处于指定的范围内。 + @param minInclusive 每个分量都代表了对应分量允许的最小值。 + @param maxInclusive 每个分量都代表了对应分量允许的最大值。 + */ + clampf(minInclusive: Vec4, maxInclusive: Vec4): Vec4; + /** + !#en Adds this vector. If you want to save result to another vector, use add() instead. + !#zh 向量加法。如果你想保存结果到另一个向量,使用 add() 代替。 + @param vector vector + */ + addSelf(vector: Vec4): Vec4; + /** + !#en Adds two vectors, and returns the new result. + !#zh 向量加法,并返回新结果。 + @param vector vector + @param out optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created + */ + add(vector: Vec4, out?: Vec4): Vec4; + /** + !#en Subtracts one vector from this, and returns the new result. + !#zh 向量减法,并返回新结果。 + @param vector vector + @param out optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created + */ + subtract(vector: Vec4, out?: Vec4): Vec4; + /** + !#en Multiplies this by a number. + !#zh 缩放当前向量。 + @param num num + */ + multiplyScalar(num: number): Vec4; + /** + !#en Multiplies two vectors. + !#zh 分量相乘。 + @param vector vector + */ + multiply(vector: Vec4): Vec4; + /** + !#en Divides by a number. + !#zh 向量除法。 + @param num num + */ + divide(num: number): Vec4; + /** + !#en Negates the components. + !#zh 向量取反 + */ + negate(): Vec4; + /** + !#en Dot product + !#zh 当前向量与指定向量进行点乘。 + @param vector vector + */ + dot(vector?: Vec4): number; + /** + !#en Cross product + !#zh 当前向量与指定向量进行叉乘。 + @param vector vector + @param out out + */ + cross(vector: Vec4, out?: Vec4): Vec4; + /** + !#en Returns the length of this vector. + !#zh 返回该向量的长度。 + + @example + ```js + var v = cc.v4(10, 10); + v.len(); // return 14.142135623730951; + ``` + */ + len(): number; + /** + !#en Returns the squared length of this vector. + !#zh 返回该向量的长度平方。 + */ + lengthSqr(): number; + /** + !#en Make the length of this vector to 1. + !#zh 向量归一化,让这个向量的长度为 1。 + */ + normalizeSelf(): Vec4; + /** + !#en + Returns this vector with a magnitude of 1.
+
+ Note that the current vector is unchanged and a new normalized vector is returned. If you want to normalize the current vector, use normalizeSelf function. + !#zh + 返回归一化后的向量。
+
+ 注意,当前向量不变,并返回一个新的归一化向量。如果你想来归一化当前向量,可使用 normalizeSelf 函数。 + @param out optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created + */ + normalize(out?: Vec4): Vec4; + /** + Transforms the vec4 with a mat4. 4th vector component is implicitly '1' + @param m matrix to transform with + @param out the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created + */ + transformMat4(m: Mat4, out?: Vec4): Vec4; + /** + Returns the maximum value in x, y, z, w. + */ + maxAxis(): number; + } + /** !#en The module provides utilities for working with file and directory paths + !#zh 用于处理文件与目录的路径的模块 */ + export class path { + /** + !#en Join strings to be a path. + !#zh 拼接字符串为 Path + + @example + ```js + ------------------------------ + cc.path.join("a", "b.png"); //-->"a/b.png" + cc.path.join("a", "b", "c.png"); //-->"a/b/c.png" + cc.path.join("a", "b"); //-->"a/b" + cc.path.join("a", "b", "/"); //-->"a/b/" + cc.path.join("a", "b/", "/"); //-->"a/b/" + + ``` + */ + static join(): string; + /** + !#en Get the ext name of a path including '.', like '.png'. + !#zh 返回 Path 的扩展名,包括 '.',例如 '.png'。 + @param pathStr pathStr + + @example + ```js + --------------------------- + cc.path.extname("a/b.png"); //-->".png" + cc.path.extname("a/b.png?a=1&b=2"); //-->".png" + cc.path.extname("a/b"); //-->null + cc.path.extname("a/b?a=1&b=2"); //-->null + + ``` + */ + static extname(pathStr: string): any; + /** + !#en Get the main name of a file name + !#zh 获取文件名的主名称 + @param fileName fileName + */ + static mainFileName(fileName: string): string; + /** + !#en Get the file name of a file path. + !#zh 获取文件路径的文件名。 + @param pathStr pathStr + @param extname extname + + @example + ```js + --------------------------------- + cc.path.basename("a/b.png"); //-->"b.png" + cc.path.basename("a/b.png?a=1&b=2"); //-->"b.png" + cc.path.basename("a/b.png", ".png"); //-->"b" + cc.path.basename("a/b.png?a=1&b=2", ".png"); //-->"b" + cc.path.basename("a/b.png", ".txt"); //-->"b.png" + + ``` + */ + static basename(pathStr: string, extname?: string): any; + /** + !#en Get dirname of a file path. + !#zh 获取文件路径的目录名。 + @param pathStr pathStr + + @example + ```js + --------------------------------- + * unix + cc.path.driname("a/b/c.png"); //-->"a/b" + cc.path.driname("a/b/c.png?a=1&b=2"); //-->"a/b" + cc.path.dirname("a/b/"); //-->"a/b" + cc.path.dirname("c.png"); //-->"" + * windows + cc.path.driname("a\\b\\c.png"); //-->"a\b" + cc.path.driname("a\\b\\c.png?a=1&b=2"); //-->"a\b" + + ``` + */ + static dirname(pathStr: string): any; + /** + !#en Change extname of a file path. + !#zh 更改文件路径的扩展名。 + @param pathStr pathStr + @param extname extname + + @example + ```js + --------------------------------- + cc.path.changeExtname("a/b.png", ".plist"); //-->"a/b.plist" + cc.path.changeExtname("a/b.png?a=1&b=2", ".plist"); //-->"a/b.plist?a=1&b=2" + + ``` + */ + static changeExtname(pathStr: string, extname?: string): string; + } + /** A base node for CCNode, it will: + - maintain scene hierarchy and active logic + - notifications if some properties changed + - define some interfaces shares between CCNode + - define machanisms for Enity Component Systems + - define prefab and serialize functions */ + export class _BaseNode extends Object implements EventTarget { + /** !#en Name of node. + !#zh 该节点名称。 */ + name: string; + /** !#en The uuid for editor, will be stripped before building project. + !#zh 主要用于编辑器的 uuid,在编辑器下可用于持久化存储,在项目构建之后将变成自增的 id。 */ + uuid: string; + /** !#en All children nodes. + !#zh 节点的所有子节点。 */ + children: Node[]; + /** !#en All children nodes. + !#zh 节点的子节点数量。 */ + childrenCount: number; + /** !#en + The local active state of this node.
+ Note that a Node may be inactive because a parent is not active, even if this returns true.
+ Use {{#crossLink "Node/activeInHierarchy:property"}}{{/crossLink}} if you want to check if the Node is actually treated as active in the scene. + !#zh + 当前节点的自身激活状态。
+ 值得注意的是,一个节点的父节点如果不被激活,那么即使它自身设为激活,它仍然无法激活。
+ 如果你想检查节点在场景中实际的激活状态可以使用 {{#crossLink "Node/activeInHierarchy:property"}}{{/crossLink}}。 */ + active: boolean; + /** !#en Indicates whether this node is active in the scene. + !#zh 表示此节点是否在场景中激活。 */ + activeInHierarchy: boolean; + /** + + @param name name + */ + constructor(name?: string); + /** !#en The parent of the node. + !#zh 该节点的父节点。 */ + parent: Node; + /** + !#en Get parent of the node. + !#zh 获取该节点的父节点。 + + @example + ```js + var parent = this.node.getParent(); + ``` + */ + getParent(): Node; + /** + !#en Set parent of the node. + !#zh 设置该节点的父节点。 + @param value value + + @example + ```js + node.setParent(newNode); + ``` + */ + setParent(value: Node): void; + /** + !#en + Properties configuration function
+ All properties in attrs will be set to the node,
+ when the setter of the node is available,
+ the property will be set via setter function.
+ !#zh 属性配置函数。在 attrs 的所有属性将被设置为节点属性。 + @param attrs Properties to be set to node + + @example + ```js + var attrs = { key: 0, num: 100 }; + node.attr(attrs); + ``` + */ + attr(attrs: any): void; + /** + !#en Returns a child from the container given its uuid. + !#zh 通过 uuid 获取节点的子节点。 + @param uuid The uuid to find the child node. + + @example + ```js + var child = node.getChildByUuid(uuid); + ``` + */ + getChildByUuid(uuid: string): Node; + /** + !#en Returns a child from the container given its name. + !#zh 通过名称获取节点的子节点。 + @param name A name to find the child node. + + @example + ```js + var child = node.getChildByName("Test Node"); + ``` + */ + getChildByName(name: string): Node; + /** + !#en + Inserts a child to the node at a specified index. + !#zh + 插入子节点到指定位置 + @param child the child node to be inserted + @param siblingIndex the sibling index to place the child in + + @example + ```js + node.insertChild(child, 2); + ``` + */ + insertChild(child: Node, siblingIndex: number): void; + /** + !#en Get the sibling index. + !#zh 获取同级索引。 + + @example + ```js + var index = node.getSiblingIndex(); + ``` + */ + getSiblingIndex(): number; + /** + !#en Set the sibling index of this node. + !#zh 设置节点同级索引。 + @param index index + + @example + ```js + node.setSiblingIndex(1); + ``` + */ + setSiblingIndex(index: number): void; + /** + !#en Walk though the sub children tree of the current node. + Each node, including the current node, in the sub tree will be visited two times, before all children and after all children. + This function call is not recursive, it's based on stack. + Please don't walk any other node inside the walk process. + !#zh 遍历该节点的子树里的所有节点并按规则执行回调函数。 + 对子树中的所有节点,包含当前节点,会执行两次回调,prefunc 会在访问它的子节点之前调用,postfunc 会在访问所有子节点之后调用。 + 这个函数的实现不是基于递归的,而是基于栈展开递归的方式。 + 请不要在 walk 过程中对任何其他的节点嵌套执行 walk。 + @param prefunc The callback to process node when reach the node for the first time + @param postfunc The callback to process node when re-visit the node after walked all children in its sub tree + + @example + ```js + node.walk(function (target) { + console.log('Walked through node ' + target.name + ' for the first time'); + }, function (target) { + console.log('Walked through node ' + target.name + ' after walked all children in its sub tree'); + }); + ``` + */ + walk(prefunc: (target: _BaseNode) => void, postfunc: (target: _BaseNode) => void): void; + /** + !#en + Remove itself from its parent node. If cleanup is `true`, then also remove all events and actions.
+ If the cleanup parameter is not passed, it will force a cleanup, so it is recommended that you always pass in the `false` parameter when calling this API.
+ If the node orphan, then nothing happens. + !#zh + 从父节点中删除该节点。如果不传入 cleanup 参数或者传入 `true`,那么这个节点上所有绑定的事件、action 都会被删除。
+ 因此建议调用这个 API 时总是传入 `false` 参数。
+ 如果这个节点是一个孤节点,那么什么都不会发生。 + @param cleanup true if all actions and callbacks on this node should be removed, false otherwise. + + @example + ```js + node.removeFromParent(); + node.removeFromParent(false); + ``` + */ + removeFromParent(cleanup?: boolean): void; + /** + !#en + Removes a child from the container. It will also cleanup all running actions depending on the cleanup parameter.

+ If the cleanup parameter is not passed, it will force a cleanup.
+ "remove" logic MUST only be on this method
+ If a class wants to extend the 'removeChild' behavior it only needs
+ to override this method. + !#zh + 移除节点中指定的子节点,是否需要清理所有正在运行的行为取决于 cleanup 参数。
+ 如果 cleanup 参数不传入,默认为 true 表示清理。
+ @param child The child node which will be removed. + @param cleanup true if all running actions and callbacks on the child node will be cleanup, false otherwise. + + @example + ```js + node.removeChild(newNode); + node.removeChild(newNode, false); + ``` + */ + removeChild(child: Node, cleanup?: boolean): void; + /** + !#en + Removes all children from the container and do a cleanup all running actions depending on the cleanup parameter.
+ If the cleanup parameter is not passed, it will force a cleanup. + !#zh + 移除节点所有的子节点,是否需要清理所有正在运行的行为取决于 cleanup 参数。
+ 如果 cleanup 参数不传入,默认为 true 表示清理。 + @param cleanup true if all running actions on all children nodes should be cleanup, false otherwise. + + @example + ```js + node.removeAllChildren(); + node.removeAllChildren(false); + ``` + */ + removeAllChildren(cleanup?: boolean): void; + /** + !#en Is this node a child of the given node? + !#zh 是否是指定节点的子节点? + @param parent parent + + @example + ```js + node.isChildOf(newNode); + ``` + */ + isChildOf(parent: Node): boolean; + /** + !#en + Returns the component of supplied type if the node has one attached, null if it doesn't.
+ You can also get component in the node by passing in the name of the script. + !#zh + 获取节点上指定类型的组件,如果节点有附加指定类型的组件,则返回,如果没有则为空。
+ 传入参数也可以是脚本的名称。 + @param typeOrClassName typeOrClassName + + @example + ```js + // get sprite component + var sprite = node.getComponent(cc.Sprite); + // get custom test class + var test = node.getComponent("Test"); + ``` + */ + getComponent(type: {prototype: T}): T; + getComponent(className: string): any; + /** + !#en Returns all components of supplied type in the node. + !#zh 返回节点上指定类型的所有组件。 + @param typeOrClassName typeOrClassName + + @example + ```js + var sprites = node.getComponents(cc.Sprite); + var tests = node.getComponents("Test"); + ``` + */ + getComponents(type: {prototype: T}): T[]; + getComponents(className: string): any[]; + /** + !#en Returns the component of supplied type in any of its children using depth first search. + !#zh 递归查找所有子节点中第一个匹配指定类型的组件。 + @param typeOrClassName typeOrClassName + + @example + ```js + var sprite = node.getComponentInChildren(cc.Sprite); + var Test = node.getComponentInChildren("Test"); + ``` + */ + getComponentInChildren(type: {prototype: T}): T; + getComponentInChildren(className: string): any; + /** + !#en Returns all components of supplied type in self or any of its children. + !#zh 递归查找自身或所有子节点中指定类型的组件 + @param typeOrClassName typeOrClassName + + @example + ```js + var sprites = node.getComponentsInChildren(cc.Sprite); + var tests = node.getComponentsInChildren("Test"); + ``` + */ + getComponentsInChildren(type: {prototype: T}): T[]; + getComponentsInChildren(className: string): any[]; + /** + !#en Adds a component class to the node. You can also add component to node by passing in the name of the script. + !#zh 向节点添加一个指定类型的组件类,你还可以通过传入脚本的名称来添加组件。 + @param typeOrClassName The constructor or the class name of the component to add + + @example + ```js + var sprite = node.addComponent(cc.Sprite); + var test = node.addComponent("Test"); + ``` + */ + addComponent(type: {new(): T}): T; + addComponent(className: string): any; + /** + !#en + Removes a component identified by the given name or removes the component object given. + You can also use component.destroy() if you already have the reference. + !#zh + 删除节点上的指定组件,传入参数可以是一个组件构造函数或组件名,也可以是已经获得的组件引用。 + 如果你已经获得组件引用,你也可以直接调用 component.destroy() + @param component The need remove component. + + @example + ```js + node.removeComponent(cc.Sprite); + var Test = require("Test"); + node.removeComponent(Test); + ``` + */ + removeComponent(component: string|Function|Component): void; + /** + !#en + Destroy all children from the node, and release all their own references to other objects.
+ Actual destruct operation will delayed until before rendering. + !#zh + 销毁所有子节点,并释放所有它们对其它对象的引用。
+ 实际销毁操作会延迟到当前帧渲染前执行。 + + @example + ```js + node.destroyAllChildren(); + ``` + */ + destroyAllChildren(): void; + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en + Register an callback of a specific event type on the EventTarget. + This type of event should be triggered via `emit`. + !#zh + 注册事件目标的特定事件类型回调。这种类型的事件应该被 `emit` 触发。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, node); + ``` + */ + on(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. + !#zh + 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + + @example + ```js + // register fire eventListener + var callback = eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, target); + // remove fire event listener + eventTarget.off('fire', callback, target); + // remove all fire event listeners + eventTarget.off('fire'); + ``` + */ + off(type: string, callback?: Function, target?: any): void; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.once('fire', function () { + cc.log("this is the callback and will be invoked only once"); + }, node); + ``` + */ + once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; + /** + !#en + Send an event with the event object. + !#zh + 通过事件对象派发事件 + @param event event + */ + dispatchEvent(event: Event): void; + } + /** !#en + AffineTransform class represent an affine transform matrix. It's composed basically by translation, rotation, scale transformations.
+ !#zh + AffineTransform 类代表一个仿射变换矩阵。它基本上是由平移旋转,缩放转变所组成。
*/ + export class AffineTransform { + /** + !#en Create a AffineTransform object with all contents in the matrix. + !#zh 用在矩阵中的所有内容创建一个 AffineTransform 对象。 + @param a a + @param b b + @param c c + @param d d + @param tx tx + @param ty ty + */ + static create(a: number, b: number, c: number, d: number, tx: number, ty: number): AffineTransform; + /** + !#en + Create a identity transformation matrix:
+ [ 1, 0, 0,
+ 0, 1, 0 ] + !#zh + 单位矩阵:
+ [ 1, 0, 0,
+ 0, 1, 0 ] + */ + static identity(): AffineTransform; + /** + !#en Clone a AffineTransform object from the specified transform. + !#zh 克隆指定的 AffineTransform 对象。 + @param t t + */ + static clone(t: AffineTransform): AffineTransform; + /** + !#en + Concatenate a transform matrix to another + The results are reflected in the out affine transform + out = t1 * t2 + This function is memory free, you should create the output affine transform by yourself and manage its memory. + !#zh + 拼接两个矩阵,将结果保存到 out 矩阵。这个函数不创建任何内存,你需要先创建 AffineTransform 对象用来存储结果,并作为第一个参数传入函数。 + out = t1 * t2 + @param out Out object to store the concat result + @param t1 The first transform object. + @param t2 The transform object to concatenate. + */ + static concat(out: AffineTransform, t1: AffineTransform, t2: AffineTransform): AffineTransform; + /** + !#en Get the invert transform of an AffineTransform object. + This function is memory free, you should create the output affine transform by yourself and manage its memory. + !#zh 求逆矩阵。这个函数不创建任何内存,你需要先创建 AffineTransform 对象用来存储结果,并作为第一个参数传入函数。 + @param out out + @param t t + */ + static invert(out: AffineTransform, t: AffineTransform): AffineTransform; + /** + !#en Get an AffineTransform object from a given matrix 4x4. + This function is memory free, you should create the output affine transform by yourself and manage its memory. + !#zh 从一个 4x4 Matrix 获取 AffineTransform 对象。这个函数不创建任何内存,你需要先创建 AffineTransform 对象用来存储结果,并作为第一个参数传入函数。 + @param out out + @param mat mat + */ + static invert(out: AffineTransform, mat: Mat4): AffineTransform; + /** + !#en Apply the affine transformation on a point. + This function is memory free, you should create the output Vec2 by yourself and manage its memory. + !#zh 对一个点应用矩阵变换。这个函数不创建任何内存,你需要先创建一个 Vec2 对象用来存储结果,并作为第一个参数传入函数。 + @param out The output point to store the result + @param point Point to apply transform or x. + @param transOrY transform matrix or y. + @param t transform matrix. + */ + static transformVec2(out: Vec2, point: Vec2|number, transOrY: AffineTransform|number, t?: AffineTransform): Vec2; + /** + !#en Apply the affine transformation on a size. + This function is memory free, you should create the output Size by yourself and manage its memory. + !#zh 应用仿射变换矩阵到 Size 上。这个函数不创建任何内存,你需要先创建一个 Size 对象用来存储结果,并作为第一个参数传入函数。 + @param out The output point to store the result + @param size size + @param t t + */ + static transformSize(out: Size, size: Size, t: AffineTransform): Size; + /** + !#en Apply the affine transformation on a rect. + This function is memory free, you should create the output Rect by yourself and manage its memory. + !#zh 应用仿射变换矩阵到 Rect 上。这个函数不创建任何内存,你需要先创建一个 Rect 对象用来存储结果,并作为第一个参数传入函数。 + @param out out + @param rect rect + @param anAffineTransform anAffineTransform + */ + static transformRect(out: Rect, rect: Rect, anAffineTransform: AffineTransform): Rect; + /** + !#en Apply the affine transformation on a rect, and truns to an Oriented Bounding Box. + This function is memory free, you should create the output vectors by yourself and manage their memory. + !#zh 应用仿射变换矩阵到 Rect 上, 并转换为有向包围盒。这个函数不创建任何内存,你需要先创建包围盒的四个 Vector 对象用来存储结果,并作为前四个参数传入函数。 + @param out_bl out_bl + @param out_tl out_tl + @param out_tr out_tr + @param out_br out_br + @param rect rect + @param anAffineTransform anAffineTransform + */ + static transformObb(out_bl: Vec2, out_tl: Vec2, out_tr: Vec2, out_br: Vec2, rect: Rect, anAffineTransform: AffineTransform): void; + } + /** !#en + Helper class for setting material blend function. + !#zh + 设置材质混合模式的辅助类。 */ + export class BlendFunc { + /** !#en specify the source Blend Factor, this will generate a custom material object, please pay attention to the memory cost. + !#zh 指定原图的混合模式,这会克隆一个新的材质对象,注意这带来的开销 */ + srcBlendFactor: macro.BlendFactor; + /** !#en specify the destination Blend Factor. + !#zh 指定目标的混合模式 */ + dstBlendFactor: macro.BlendFactor; + } + /** An internal helper class for switching render component's material between normal sprite material and gray sprite material. */ + export class GraySpriteState { + /** !#en The normal material. + !#zh 正常状态的材质。 */ + normalMaterial: Material; + /** !#en The gray material. + !#zh 置灰状态的材质。 */ + grayMaterial: Material; + } + /** misc utilities */ + export class misc { + /** + !#en Clamp a value between from and to. + !#zh + 限定浮点数的最大最小值。
+ 数值大于 max_inclusive 则返回 max_inclusive。
+ 数值小于 min_inclusive 则返回 min_inclusive。
+ 否则返回自身。 + @param value value + @param min_inclusive min_inclusive + @param max_inclusive max_inclusive + + @example + ```js + var v1 = cc.misc.clampf(20, 0, 20); // 20; + var v2 = cc.misc.clampf(-1, 0, 20); // 0; + var v3 = cc.misc.clampf(10, 0, 20); // 10; + ``` + */ + static clampf(value: number, min_inclusive: number, max_inclusive: number): number; + /** + !#en Clamp a value between 0 and 1. + !#zh 限定浮点数的取值范围为 0 ~ 1 之间。 + @param value value + + @example + ```js + var v1 = cc.misc.clamp01(20); // 1; + var v2 = cc.misc.clamp01(-1); // 0; + var v3 = cc.misc.clamp01(0.5); // 0.5; + ``` + */ + static clamp01(value: number): number; + /** + Linear interpolation between 2 numbers, the ratio sets how much it is biased to each end + @param a number A + @param b number B + @param r ratio between 0 and 1 + + @example + ```js + ---- + lerp + cc.misc.lerp(2,10,0.5)//returns 6 + cc.misc.lerp(2,10,0.2)//returns 3.6 + + ``` + */ + static lerp(a: number, b: number, r: number): number; + /** + converts degrees to radians + @param angle angle + */ + static degreesToRadians(angle: number): number; + /** + converts radians to degrees + @param angle angle + */ + static radiansToDegrees(angle: number): number; + } + /** !#en The burst of 3d particle. + !#zh 3D 粒子发射时的爆发个数 */ + export class Burst { + /** !#en Time between the start of the particle system and the trigger of this Brust + !#zh 粒子系统开始运行到触发此次 Brust 的时间 */ + time: number; + /** !#en Minimum number of emitted particles + !#zh 发射粒子的最小数量 */ + minCount: number; + /** !#en Maximum number of emitted particles + !#zh 发射粒子的最大数量 */ + maxCount: number; + /** !#en The number of times Burst was triggered. + !#zh Burst 的触发次数 */ + repeatCount: number; + /** !#en Interval of each trigger + !#zh 每次触发的间隔时间 */ + repeatInterval: number; + /** !#en Number of particles emitted + !#zh 发射的粒子的数量 */ + count: CurveRange; + } + /** !#en The animation curve of 3d particle. + !#zh 3D 粒子动画曲线 */ + export class AnimationCurve { + } + /** !#en The ParticleSystem3D Component. + !#zh 3D 粒子组件 */ + export class ParticleSystem3D extends RenderComponent { + /** !#en The run time of particle. + !#zh 粒子系统运行时间 */ + duration: number; + /** !#en The maximum number of particles that a particle system can generate. + !#zh 粒子系统能生成的最大粒子数量 */ + capacity: number; + /** !#en Whether the particle system loops. + !#zh 粒子系统是否循环播放 */ + loop: boolean; + /** !#en Whether the particles start playing automatically after loaded. + !#zh 粒子系统加载后是否自动开始播放 */ + playOnAwake: boolean; + /** !#en When selected, the particle system will start playing after one round has been played (only effective when loop is enabled). + !#zh 选中之后,粒子系统会以已播放完一轮之后的状态开始播放(仅当循环播放启用时有效) */ + prewarm: boolean; + /** !#en The coordinate system in which the particle system is located.
+ World coordinates (does not change when the position of other objects changes)
+ Local coordinates (moving as the position of the parent node changes)
+ Custom coordinates (moving with the position of a custom node) + !#zh 选择粒子系统所在的坐标系
+ 世界坐标(不随其他物体位置改变而变换)
+ 局部坐标(跟随父节点位置改变而移动)
+ 自定坐标(跟随自定义节点的位置改变而移动) */ + simulationSpace: ParticleSystem3DAssembler.Space; + /** !#en Controlling the update speed of the entire particle system. + !#zh 控制整个粒子系统的更新速度。 */ + simulationSpeed: number; + /** !#en Delay particle emission time after particle system starts running. + !#zh 粒子系统开始运行后,延迟粒子发射的时间。 */ + startDelay: CurveRange; + /** !#en Particle life cycle。 + !#zh 粒子生命周期。 */ + startLifetime: CurveRange; + /** !#en Particle initial color + !#zh 粒子初始颜色 */ + startColor: GradientRange; + /** !#en Particle scale space + !#zh 缩放空间 */ + scaleSpace: ParticleSystem3DAssembler.Space; + /** !#en Initial particle size + !#zh 粒子初始大小 */ + startSize: CurveRange; + /** !#en Initial particle speed + !#zh 粒子初始速度 */ + startSpeed: CurveRange; + /** !#en Particle initial rotation angle + !#zh 粒子初始旋转角度 */ + startRotation: CurveRange; + /** !#en Gravity coefficient of particles affected by gravity + !#zh 粒子受重力影响的重力系数 */ + gravityModifier: CurveRange; + /** !#en Particles emitted per second + !#zh 每秒发射的粒子数 */ + rateOverTime: CurveRange; + /** !#en Number of particles emitted per unit distance moved + !#zh 每移动单位距离发射的粒子数 */ + rateOverDistance: CurveRange; + /** !#en The number of Brusts that emit a specified number of particles at a specified time + !#zh 设定在指定时间发射指定数量的粒子的 Brust 的数量 */ + bursts: Burst[]; + /** !#en Particle emitter module + !#zh 粒子发射器模块 */ + shapeModule: ShapeModule; + /** !#en Color control module + !#zh 颜色控制模块 */ + colorOverLifetimeModule: ColorOverLifetimeModule; + /** !#en Particle size module + !#zh 粒子大小模块 */ + sizeOvertimeModule: SizeOvertimeModule; + /** !#en Particle speed module + !#zh 粒子速度模块 */ + velocityOvertimeModule: VelocityOvertimeModule; + /** !#en Particle acceleration module + !#zh 粒子加速度模块 */ + forceOvertimeModule: ForceOvertimeModule; + /** !#en Particle limit speed module (only CPU particles are supported) + !#zh 粒子限制速度模块(只支持 CPU 粒子) */ + limitVelocityOvertimeModule: LimitVelocityOvertimeModule; + /** !#en Particle rotation module + !#zh 粒子旋转模块 */ + rotationOvertimeModule: RotationOvertimeModule; + /** !#en Texture Animation Module + !#zh 贴图动画模块 */ + textureAnimationModule: TextureAnimationModule; + /** !#en Particle Trajectory Module + !#zh 粒子轨迹模块 */ + trailModule: TrailModule; + /** !#en Particle generation mode + !#zh 设定粒子生成模式 */ + renderMode: ParticleSystem3DAssembler.RenderMode; + /** !#en When the particle generation mode is StrecthedBillboard, in the direction of movement of the particles is stretched by velocity magnitude + !#zh 在粒子生成方式为 StrecthedBillboard 时,对粒子在运动方向上按速度大小进行拉伸 */ + velocityScale: number; + /** !#en When the particle generation method is StrecthedBillboard, the particles are stretched according to the particle size in the direction of motion + !#zh 在粒子生成方式为 StrecthedBillboard 时,对粒子在运动方向上按粒子大小进行拉伸 */ + lengthScale: number; + /** !#en Particle model + !#zh 粒子模型 */ + mesh: Mesh; + /** !#en Particle material + !#zh 粒子材质 */ + particleMaterial: Material; + /** !#en Particle trail material + !#zh 粒子轨迹材质 */ + trailMaterial: Material; + /** + !#en Playing particle effects + !#zh 播放粒子效果 + */ + play(): void; + /** + !#en Pause particle effect + !#zh 暂停播放粒子效果 + */ + pause(): void; + /** + !#en Stop particle effect + !#zh 停止播放粒子效果 + */ + stop(): void; + /** + !#en Remove all particle effect + !#zh 将所有粒子从粒子系统中清除 + */ + clear(): void; + } + /** !#en + Helper class for ES5 Map. + !#zh + ES5 Map 辅助类。 */ + export class MapUtils { + } + /** !#en . + !#zh 。 */ + export class SkeletonAnimation extends Animation { + } + /** !#en SkeletonAnimationClip Asset. + !#zh 骨骼动画剪辑。 */ + export class SkeletonAnimationClip extends AnimationClip { + } + /** !#en + Skinned Mesh Renderer + !#zh + 蒙皮渲染组件 */ + export class SkinnedMeshRenderer { + /** !#en + Skeleton Asset + !#zh + 骨骼资源 */ + skeleton: sp.Skeleton; + /** !#en + Root Bone + !#zh + 骨骼根节点 */ + rootBone: Node; + } + /** !#en Effect Asset. + !#zh Effect 资源类型。 */ + export class EffectAsset extends Asset { + } + /** !#en Material Asset. + !#zh 材质资源类。 */ + export class Material extends Asset { + /** + !#en Get built-in materials + !#zh 获取内置材质 + @param name name + */ + static getBuiltinMaterial(name: string): Material; + /** + !#en Creates a Material with builtin Effect. + !#zh 使用内建 Effect 创建一个材质。 + @param effectName effectName + @param techniqueIndex techniqueIndex + */ + static createWithBuiltin(effectName: string, techniqueIndex?: number): Material; + /** + !#en Creates a Material. + !#zh 创建一个材质。 + @param effectAsset effectAsset + @param techniqueIndex techniqueIndex + */ + static create(effectAsset: EffectAsset, techniqueIndex?: number): Material; + /** + !#en Sets the Material property + !#zh 设置材质的属性 + @param name name + @param val val + @param passIdx passIdx + @param directly directly + */ + setProperty(name: string, val: any, passIdx?: number, directly?: boolean): void; + /** + !#en Gets the Material property. + !#zh 获取材质的属性。 + @param name name + @param passIdx passIdx + */ + getProperty(name: string, passIdx: number): any; + /** + !#en Sets the Material define. + !#zh 设置材质的宏定义。 + @param name name + @param val val + @param passIdx passIdx + @param force force + */ + define(name: string, val: boolean|number, passIdx?: number, force?: boolean): void; + /** + !#en Gets the Material define. + !#zh 获取材质的宏定义。 + @param name name + @param passIdx passIdx + */ + getDefine(name: string, passIdx?: number): boolean; + /** + !#en Sets the Material cull mode. + !#zh 设置材质的裁减模式。 + @param cullMode cullMode + @param passIdx passIdx + */ + setCullMode(cullMode: number, passIdx: number): void; + /** + !#en Sets the Material depth states. + !#zh 设置材质的深度渲染状态。 + @param depthTest depthTest + @param depthWrite depthWrite + @param depthFunc depthFunc + @param passIdx passIdx + */ + setDepth(depthTest: boolean, depthWrite: boolean, depthFunc: number, passIdx: number): void; + /** + !#en Sets the Material blend states. + !#zh 设置材质的混合渲染状态。 + @param enabled enabled + @param blendEq blendEq + @param blendSrc blendSrc + @param blendDst blendDst + @param blendAlphaEq blendAlphaEq + @param blendSrcAlpha blendSrcAlpha + @param blendDstAlpha blendDstAlpha + @param blendColor blendColor + @param passIdx passIdx + */ + setBlend(enabled: boolean, blendEq: number, blendSrc: number, blendDst: number, blendAlphaEq: number, blendSrcAlpha: number, blendDstAlpha: number, blendColor: number, passIdx: number): void; + /** + !#en Sets whether enable the stencil test. + !#zh 设置是否开启模板测试。 + @param stencilTest stencilTest + @param passIdx passIdx + */ + setStencilEnabled(stencilTest: number, passIdx: number): void; + /** + !#en Sets the Material stencil render states. + !#zh 设置材质的模板测试渲染参数。 + @param stencilTest stencilTest + @param stencilFunc stencilFunc + @param stencilRef stencilRef + @param stencilMask stencilMask + @param stencilFailOp stencilFailOp + @param stencilZFailOp stencilZFailOp + @param stencilZPassOp stencilZPassOp + @param stencilWriteMask stencilWriteMask + @param passIdx passIdx + */ + setStencil(stencilTest: number, stencilFunc: number, stencilRef: number, stencilMask: number, stencilFailOp: number, stencilZFailOp: number, stencilZPassOp: number, stencilWriteMask: number, passIdx: number): void; + } + /** !#en + Material Variant is an extension of the Material Asset. + Changes to Material Variant do not affect other Material Variant or Material Asset, + and changes to Material Asset are synchronized to the Material Variant. + However, when a Material Variant had already modifies a state, the Material Asset state is not synchronized to the Material Variant. + !#zh + 材质变体是材质资源的一个延伸。 + 材质变体的修改不会影响到其他的材质变体或者材质资源,而材质资源的修改会同步体现到材质变体上, + 但是当材质变体对一个状态修改后,材质资源再对这个状态修改是不会同步到材质变体上的。 */ + export class MaterialVariant extends Material { + /** + + @param materialName materialName + @param owner owner + */ + static createWithBuiltin (materialName: string, owner: cc.RenderComponent): MaterialVariant | null; + /** + + @param material material + @param owner owner + */ + static create (material: Material, owner: cc.RenderComponent): MaterialVariant | null; + } + /** !#en cc.EditBox is a component for inputing text, you can use it to gather small amounts of text from users. + !#zh EditBox 组件,用于获取用户的输入文本。 */ + export class EditBox extends Component { + /** !#en Input string of EditBox. + !#zh 输入框的初始输入内容,如果为空则会显示占位符的文本。 */ + string: string; + /** !#en The Label component attached to the node for EditBox's input text label + !#zh 输入框输入文本节点上挂载的 Label 组件对象 */ + textLabel: Label; + /** !#en The Label component attached to the node for EditBox's placeholder text label + !#zh 输入框占位符节点上挂载的 Label 组件对象 */ + placeholderLabel: Label; + /** !#en The Sprite component attached to the node for EditBox's background + !#zh 输入框背景节点上挂载的 Sprite 组件对象 */ + background: Sprite; + /** !#en The background image of EditBox. This property will be removed in the future, use editBox.background instead please. + !#zh 输入框的背景图片。 该属性会在将来的版本中移除,请用 editBox.background */ + backgroundImage: SpriteFrame; + /** !#en + The return key type of EditBox. + Note: it is meaningless for web platforms and desktop platforms. + !#zh + 指定移动设备上面回车按钮的样式。 + 注意:这个选项对 web 平台与 desktop 平台无效。 */ + returnType: EditBox.KeyboardReturnType; + /** !#en Set the input flags that are to be applied to the EditBox. + !#zh 指定输入标志位,可以指定输入方式为密码或者单词首字母大写。 */ + inputFlag: EditBox.InputFlag; + /** !#en + Set the input mode of the edit box. + If you pass ANY, it will create a multiline EditBox. + !#zh + 指定输入模式: ANY表示多行输入,其它都是单行输入,移动平台上还可以指定键盘样式。 */ + inputMode: EditBox.InputMode; + /** !#en Font size of the input text. This property will be removed in the future, use editBox.textLabel.fontSize instead please. + !#zh 输入框文本的字体大小。 该属性会在将来的版本中移除,请使用 editBox.textLabel.fontSize。 */ + fontSize: number; + /** !#en Change the lineHeight of displayed text. This property will be removed in the future, use editBox.textLabel.lineHeight instead. + !#zh 输入框文本的行高。该属性会在将来的版本中移除,请使用 editBox.textLabel.lineHeight */ + lineHeight: number; + /** !#en Font color of the input text. This property will be removed in the future, use editBox.textLabel.node.color instead. + !#zh 输入框文本的颜色。该属性会在将来的版本中移除,请使用 editBox.textLabel.node.color */ + fontColor: Color; + /** !#en The display text of placeholder. + !#zh 输入框占位符的文本内容。 */ + placeholder: string; + /** !#en The font size of placeholder. This property will be removed in the future, use editBox.placeholderLabel.fontSize instead. + !#zh 输入框占位符的字体大小。该属性会在将来的版本中移除,请使用 editBox.placeholderLabel.fontSize */ + placeholderFontSize: number; + /** !#en The font color of placeholder. This property will be removed in the future, use editBox.placeholderLabel.node.color instead. + !#zh 输入框占位符的字体颜色。该属性会在将来的版本中移除,请使用 editBox.placeholderLabel.node.color */ + placeholderFontColor: Color; + /** !#en The maximize input length of EditBox. + - If pass a value less than 0, it won't limit the input number of characters. + - If pass 0, it doesn't allow input any characters. + !#zh 输入框最大允许输入的字符个数。 + - 如果值为小于 0 的值,则不会限制输入字符个数。 + - 如果值为 0,则不允许用户进行任何输入。 */ + maxLength: number; + /** !#en The input is always visible and be on top of the game view (only useful on Web), this property will be removed on v2.1 + !zh 输入框总是可见,并且永远在游戏视图的上面(这个属性只有在 Web 上面修改有意义),该属性会在 v2.1 中移除 + Note: only available on Web at the moment. */ + stayOnTop: boolean; + /** !#en Set the tabIndex of the DOM input element (only useful on Web). + !#zh 修改 DOM 输入元素的 tabIndex(这个属性只有在 Web 上面修改有意义)。 */ + tabIndex: number; + /** !#en The event handler to be called when EditBox began to edit text. + !#zh 开始编辑文本输入框触发的事件回调。 */ + editingDidBegan: Component.EventHandler[]; + /** !#en The event handler to be called when EditBox text changes. + !#zh 编辑文本输入框时触发的事件回调。 */ + textChanged: Component.EventHandler[]; + /** !#en The event handler to be called when EditBox edit ends. + !#zh 结束编辑文本输入框时触发的事件回调。 */ + editingDidEnded: Component.EventHandler[]; + /** !#en The event handler to be called when return key is pressed. Windows is not supported. + !#zh 当用户按下回车按键时的事件回调,目前不支持 windows 平台 */ + editingReturn: Component.EventHandler[]; + /** + !#en Let the EditBox get focus, this method will be removed on v2.1 + !#zh 让当前 EditBox 获得焦点, 这个方法会在 v2.1 中移除 + */ + setFocus(): void; + /** + !#en Let the EditBox get focus + !#zh 让当前 EditBox 获得焦点 + */ + focus(): void; + /** + !#en Let the EditBox lose focus + !#zh 让当前 EditBox 失去焦点 + */ + blur(): void; + /** + !#en Determine whether EditBox is getting focus or not. + !#zh 判断 EditBox 是否获得了焦点 + */ + isFocused(): void; + /** + !#en if you don't need the EditBox and it isn't in any running Scene, you should + call the destroy method on this component or the associated node explicitly. + Otherwise, the created DOM element won't be removed from web page. + !#zh + 如果你不再使用 EditBox,并且组件未添加到场景中,那么你必须手动对组件或所在节点调用 destroy。 + 这样才能移除网页上的 DOM 节点,避免 Web 平台内存泄露。 + + @example + ```js + editbox.node.parent = null; // or editbox.node.removeFromParent(false); + // when you don't need editbox anymore + editbox.node.destroy(); + ``` + */ + destroy(): boolean; + } + /** undefined */ + export class PhysicsBoxCollider extends PhysicsCollider implements Collider.Box { + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Box size + !#zh 包围盒大小 */ + size: Size; + } + /** undefined */ + export class PhysicsChainCollider extends PolygonCollider { + /** !#en Whether the chain is loop + !#zh 链条是否首尾相连 */ + loop: boolean; + /** !#en Chain points + !#zh 链条顶点数组 */ + points: Vec2[]; + } + /** undefined */ + export class PhysicsCircleCollider extends PhysicsCollider implements Collider.Circle { + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Circle radius + !#zh 圆形半径 */ + radius: number; + } + /** undefined */ + export class PhysicsCollider extends Collider { + /** !#en + The density. + !#zh + 密度 */ + density: number; + /** !#en + A sensor collider collects contact information but never generates a collision response + !#zh + 一个传感器类型的碰撞体会产生碰撞回调,但是不会发生物理碰撞效果。 */ + sensor: boolean; + /** !#en + The friction coefficient, usually in the range [0,1]. + !#zh + 摩擦系数,取值一般在 [0, 1] 之间 */ + friction: number; + /** !#en + The restitution (elasticity) usually in the range [0,1]. + !#zh + 弹性系数,取值一般在 [0, 1]之间 */ + restitution: number; + /** !#en + Physics collider will find the rigidbody component on the node and set to this property. + !#zh + 碰撞体会在初始化时查找节点上是否存在刚体,如果查找成功则赋值到这个属性上。 */ + body: RigidBody; + /** + !#en + Apply current changes to collider, this will regenerate inner box2d fixtures. + !#zh + 应用当前 collider 中的修改,调用此函数会重新生成内部 box2d 的夹具。 + */ + apply(): void; + /** + !#en + Get the world aabb of the collider + !#zh + 获取碰撞体的世界坐标系下的包围盒 + */ + getAABB(): void; + } + /** undefined */ + export class PhysicsPolygonCollider extends PhysicsCollider implements Collider.Polygon { + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Polygon points + !#zh 多边形顶点数组 */ + points: Vec2[]; + } + /** !#en + A distance joint constrains two points on two bodies + to remain at a fixed distance from each other. You can view + this as a massless, rigid rod. + !#zh + 距离关节通过一个固定的长度来约束关节链接的两个刚体。你可以将它想象成一个无质量,坚固的木棍。 */ + export class DistanceJoint extends Joint { + /** !#en + The distance separating the two ends of the joint. + !#zh + 关节两端的距离 */ + distance: number; + /** !#en + The spring frequency. + !#zh + 弹性系数。 */ + frequency: number; + /** !#en + The damping ratio. + !#zh + 阻尼,表示关节变形后,恢复到初始状态受到的阻力。 */ + dampingRatio: number; + } + /** !#en + Base class for joints to connect rigidbody. + !#zh + 关节类的基类 */ + export class Joint extends Component { + /** !#en + The anchor of the rigidbody. + !#zh + 刚体的锚点。 */ + anchor: Vec2; + /** !#en + The anchor of the connected rigidbody. + !#zh + 关节另一端刚体的锚点。 */ + connectedAnchor: Vec2; + /** !#en + The rigidbody to which the other end of the joint is attached. + !#zh + 关节另一端链接的刚体 */ + connectedBody: RigidBody; + /** !#en + Should the two rigid bodies connected with this joint collide with each other? + !#zh + 链接到关节上的两个刚体是否应该相互碰撞? */ + collideConnected: boolean; + /** + !#en + Apply current changes to joint, this will regenerate inner box2d joint. + !#zh + 应用当前关节中的修改,调用此函数会重新生成内部 box2d 的关节。 + */ + apply(): void; + /** + !#en + Get the anchor point on rigidbody in world coordinates. + !#zh + 获取刚体世界坐标系下的锚点。 + */ + getWorldAnchor(): Vec2; + /** + !#en + Get the anchor point on connected rigidbody in world coordinates. + !#zh + 获取链接刚体世界坐标系下的锚点。 + */ + getWorldConnectedAnchor(): Vec2; + /** + !#en + Gets the reaction force of the joint. + !#zh + 获取关节的反作用力。 + @param timeStep The time to calculate the reaction force for. + */ + getReactionForce(timeStep: number): Vec2; + /** + !#en + Gets the reaction torque of the joint. + !#zh + 获取关节的反扭矩。 + @param timeStep The time to calculate the reaction torque for. + */ + getReactionTorque(timeStep: number): number; + } + /** !#en + A mouse joint is used to make a point on a body track a + specified world point. This a soft constraint with a maximum + force. This allows the constraint to stretch and without + applying huge forces. + Mouse Joint will auto register the touch event with the mouse region node, + and move the choosed rigidbody in touch move event. + Note : generally mouse joint only used in test bed. + !#zh + 鼠标关节用于使刚体上的一个点追踪一个指定的世界坐标系下的位置。 + 鼠标关节可以指定一个最大的里来施加一个柔和的约束。 + 鼠标关节会自动使用 mouse region 节点来注册鼠标事件,并且在触摸移动事件中移动选中的刚体。 + 注意:一般鼠标关节只在测试环境中使用。 */ + export class MouseJoint extends Joint { + /** !#en + The anchor of the rigidbody. + !#zh + 刚体的锚点。 */ + anchor: Vec2; + /** !#en + The anchor of the connected rigidbody. + !#zh + 关节另一端刚体的锚点。 */ + connectedAnchor: Vec2; + /** !#en + The node used to register touch evnet. + If this is null, it will be the joint's node. + !#zh + 用于注册触摸事件的节点。 + 如果没有设置这个值,那么将会使用关节的节点来注册事件。 */ + mouseRegion: Node; + /** !#en + The target point. + The mouse joint will move choosed rigidbody to target point. + !#zh + 目标点,鼠标关节将会移动选中的刚体到指定的目标点 */ + target: Vec2; + /** !#en + The spring frequency. + !#zh + 弹簧系数。 */ + frequency: number; + /** !#en + The damping ratio. + !#zh + 阻尼,表示关节变形后,恢复到初始状态受到的阻力。 */ + 0: number; + /** !#en + The maximum force + !#zh + 最大阻力值 */ + maxForce: number; + } + /** !#en + A motor joint is used to control the relative motion + between two bodies. A typical usage is to control the movement + of a dynamic body with respect to the ground. + !#zh + 马达关节被用来控制两个刚体间的相对运动。 + 一个典型的例子是用来控制一个动态刚体相对于地面的运动。 */ + export class MotorJoint extends Joint { + /** !#en + The anchor of the rigidbody. + !#zh + 刚体的锚点。 */ + anchor: Vec2; + /** !#en + The anchor of the connected rigidbody. + !#zh + 关节另一端刚体的锚点。 */ + connectedAnchor: Vec2; + /** !#en + The linear offset from connected rigidbody to rigidbody. + !#zh + 关节另一端的刚体相对于起始端刚体的位置偏移量 */ + linearOffset: Vec2; + /** !#en + The angular offset from connected rigidbody to rigidbody. + !#zh + 关节另一端的刚体相对于起始端刚体的角度偏移量 */ + angularOffset: number; + /** !#en + The maximum force can be applied to rigidbody. + !#zh + 可以应用于刚体的最大的力值 */ + maxForce: number; + /** !#en + The maximum torque can be applied to rigidbody. + !#zh + 可以应用于刚体的最大扭矩值 */ + maxTorque: number; + /** !#en + The position correction factor in the range [0,1]. + !#zh + 位置矫正系数,范围为 [0, 1] */ + correctionFactor: number; + } + /** !#en + A prismatic joint. This joint provides one degree of freedom: translation + along an axis fixed in rigidbody. Relative rotation is prevented. You can + use a joint limit to restrict the range of motion and a joint motor to + drive the motion or to model joint friction. + !#zh + 移动关节指定了只能在一个方向上移动刚体。 + 你可以开启关节限制来设置刚体运行移动的间距,也可以开启马达来使用关节马达驱动刚体的运行。 */ + export class PrismaticJoint extends Joint { + /** !#en + The local joint axis relative to rigidbody. + !#zh + 指定刚体可以移动的方向。 */ + localAxisA: Vec2; + /** !#en + The reference angle. + !#zh + 相对角度 */ + referenceAngle: number; + /** !#en + Enable joint distance limit? + !#zh + 是否开启关节的距离限制? */ + enableLimit: boolean; + /** !#en + Enable joint motor? + !#zh + 是否开启关节马达? */ + enableMotor: boolean; + /** !#en + The lower joint limit. + !#zh + 刚体能够移动的最小值 */ + lowerLimit: number; + /** !#en + The upper joint limit. + !#zh + 刚体能够移动的最大值 */ + upperLimit: number; + /** !#en + The maxium force can be applied to rigidbody to rearch the target motor speed. + !#zh + 可以施加到刚体的最大力。 */ + maxMotorForce: number; + /** !#en + The expected motor speed. + !#zh + 期望的马达速度。 */ + motorSpeed: number; + } + /** !#en + A revolute joint constrains two bodies to share a common point while they + are free to rotate about the point. The relative rotation about the shared + point is the joint angle. You can limit the relative rotation with + a joint limit that specifies a lower and upper angle. You can use a motor + to drive the relative rotation about the shared point. A maximum motor torque + is provided so that infinite forces are not generated. + !#zh + 旋转关节可以约束两个刚体围绕一个点来进行旋转。 + 你可以通过开启关节限制来限制旋转的最大角度和最小角度。 + 你可以通过开启马达来施加一个扭矩力来驱动这两个刚体在这一点上的相对速度。 */ + export class RevoluteJoint extends Joint { + /** !#en + The reference angle. + An angle between bodies considered to be zero for the joint angle. + !#zh + 相对角度。 + 两个物体之间角度为零时可以看作相等于关节角度 */ + referenceAngle: number; + /** !#en + The lower angle. + !#zh + 角度的最低限制。 */ + lowerAngle: number; + /** !#en + The upper angle. + !#zh + 角度的最高限制。 */ + upperAngle: number; + /** !#en + The maxium torque can be applied to rigidbody to rearch the target motor speed. + !#zh + 可以施加到刚体的最大扭矩。 */ + maxMotorTorque: number; + /** !#en + The expected motor speed. + !#zh + 期望的马达速度。 */ + motorSpeed: number; + /** !#en + Enable joint limit? + !#zh + 是否开启关节的限制? */ + enableLimit: boolean; + /** !#en + Enable joint motor? + !#zh + 是否开启关节马达? */ + enableMotor: boolean; + /** + !#en + Get the joint angle. + !#zh + 获取关节角度。 + */ + getJointAngle(): number; + } + /** !#en + A rope joint enforces a maximum distance between two points + on two bodies. It has no other effect. + Warning: if you attempt to change the maximum length during + the simulation you will get some non-physical behavior. + !#zh + 绳子关节只指定两个刚体间的最大距离,没有其他的效果。 + 注意:如果你试图动态修改关节的长度,这有可能会得到一些意外的效果。 */ + export class RopeJoint extends Joint { + /** !#en + The max length. + !#zh + 最大长度。 */ + maxLength: number; + } + /** !#en + A weld joint essentially glues two bodies together. A weld joint may + distort somewhat because the island constraint solver is approximate. + !#zh + 熔接关节相当于将两个刚体粘在了一起。 + 熔接关节可能会使某些东西失真,因为约束求解器算出的都是近似值。 */ + export class WeldJoint extends Joint { + /** !#en + The reference angle. + !#zh + 相对角度。 */ + referenceAngle: number; + /** !#en + The frequency. + !#zh + 弹性系数。 */ + frequency: number; + /** !#en + The damping ratio. + !#zh + 阻尼,表示关节变形后,恢复到初始状态受到的阻力。 */ + 0: number; + } + /** !#en + A wheel joint. This joint provides two degrees of freedom: translation + along an axis fixed in bodyA and rotation in the plane. You can use a joint motor to drive + the rotation or to model rotational friction. + This joint is designed for vehicle suspensions. + !#zh + 轮子关节提供两个维度的自由度:旋转和沿着指定方向上位置的移动。 + 你可以通过开启关节马达来使用马达驱动刚体的旋转。 + 轮组关节是专门为机动车类型设计的。 */ + export class WheelJoint extends Joint { + /** !#en + The local joint axis relative to rigidbody. + !#zh + 指定刚体可以移动的方向。 */ + localAxisA: Vec2; + /** !#en + The maxium torque can be applied to rigidbody to rearch the target motor speed. + !#zh + 可以施加到刚体的最大扭矩。 */ + maxMotorTorque: number; + /** !#en + The expected motor speed. + !#zh + 期望的马达速度。 */ + motorSpeed: number; + /** !#en + Enable joint motor? + !#zh + 是否开启关节马达? */ + enableMotor: boolean; + /** !#en + The spring frequency. + !#zh + 弹性系数。 */ + frequency: number; + /** !#en + The damping ratio. + !#zh + 阻尼,表示关节变形后,恢复到初始状态受到的阻力。 */ + dampingRatio: number; + } + /** !#en The rigid body type + !#zh 刚体类型 */ + export enum ERigidBodyType { + DYNAMIC = 0, + STATIC = 0, + KINEMATIC = 0, + } + /** !#en + Trigger event + !#zh + 触发事件。 */ + export class ITriggerEvent { + /** !#en + The type of event fired + !#zh + 触发的事件类型 */ + type: string; + /** !#en + Triggers its own collider in the event + !#zh + 触发事件中的自己的碰撞器 */ + selfCollider: Collider3D; + /** !#en + Triggers another collider in the event + !#zh + 触发事件中的另一个碰撞器 */ + otherCollider: Collider3D; + } + /** !#en + Collision information for collision events. + !#zh + 碰撞事件的碰撞信息。 */ + export class IContactEquation { + /** !#en + The collision point A in the collision information. + !#zh + 碰撞信息中的碰撞点 A。 */ + contactA: Vec3; + /** !#en + Collision point B in collision information. + !#zh + 碰撞信息中的碰撞点 B。 */ + contactB: Vec3; + /** !#en + Normals in collision information. + !#zh + 碰撞信息中的法线。 */ + normal: Vec3; + } + /** !#en + Collision events. + !#zh + 碰撞事件。 */ + export class ICollisionEvent { + /** !#en + Event type of collision. + !#zh + 碰撞的事件类型。 */ + type: string; + /** !#en + Collider of its own in collision. + !#zh + 碰撞中的自己的碰撞器。 */ + selfCollider: Collider3D; + /** !#en + Another collider in the collision. + !#zh + 碰撞中的另一个碰撞器。 */ + otherCollider: Collider3D; + /** !#en + Information about all the points of impact in the collision. + !#zh + 碰撞中的所有碰撞点的信息。 */ + contacts: IContactEquation[]; + } + /** !#en + Physical systems manager. + !#zh + 物理系统管理器。 */ + export class Physics3DManager { + /** !#en + Whether to enable the physics system, default is false. + !#zh + 是否启用物理系统,默认不启用。 */ + enabled: boolean; + /** !#en + Whether to allow the physics system to automatically hibernate, default is true. + !#zh + 物理系统是否允许自动休眠,默认为 true。 */ + allowSleep: boolean; + /** !#en + The maximum number of sub-steps a full step is permitted to be broken into, default is 2. + !#zh + 物理每帧模拟的最大子步数,默认为 2。 */ + maxSubStep: number; + /** !#en + Time spent in each simulation of physics, default is 1/60s. + !#zh + 物理每步模拟消耗的固定时间,默认为 1/60 秒。 */ + deltaTime: number; + /** !#en + Whether to use a fixed time step. + !#zh + 是否使用固定的时间步长。 */ + useFixedTime: boolean; + /** !#en + Gravity value of the physics simulation, default is (0, -10, 0). + !#zh + 物理世界的重力数值,默认为 (0, -10, 0)。 */ + gravity: Vec3; + /** !#en + Gets the global default physical material. Note that builtin is null. + !#zh + 获取全局的默认物理材质,注意:builtin 时为 null。 */ + defaultMaterial: PhysicsMaterial|void; + /** + !#en + A physical system simulation is performed once and will now be performed automatically once per frame. + !#zh + 执行一次物理系统的模拟,目前将在每帧自动执行一次。 + @param deltaTime The time difference from the last execution is currently elapsed per frame + */ + update(deltaTime: number): void; + /** + !#en Detect all collision boxes and return all detected results, or null if none is detected. Note that the return value is taken from the object pool, so do not save the result reference or modify the result. + !#zh 检测所有的碰撞盒,并返回所有被检测到的结果,若没有检测到,则返回空值。注意返回值是从对象池中取的,所以请不要保存结果引用或者修改结果。 + @param worldRay A ray in world space + @param groupIndexOrName Collision group index or group name + @param maxDistance Maximum detection distance + @param queryTrigger Detect trigger or not + */ + raycast(worldRay: geomUtils.Ray, groupIndexOrName: number|string, maxDistance: number, queryTrigger: boolean): PhysicsRayResult[]; + /** + !#en Detect all collision boxes and return the detection result with the shortest ray distance. If not, return null value. Note that the return value is taken from the object pool, so do not save the result reference or modify the result. + !#zh 检测所有的碰撞盒,并返回射线距离最短的检测结果,若没有,则返回空值。注意返回值是从对象池中取的,所以请不要保存结果引用或者修改结果。 + @param worldRay A ray in world space + @param groupIndexOrName Collision group index or group name + @param maxDistance Maximum detection distance + @param queryTrigger Detect trigger or not + */ + raycastClosest(worldRay: geomUtils.Ray, groupIndexOrName: number|string, maxDistance: number, queryTrigger: boolean): PhysicsRayResult; + } + /** !#en + Used to store physical ray detection results + !#zh + 用于保存物理射线检测结果 */ + export class PhysicsRayResult { + /** !#en + Hit the point + !#zh + 击中点 */ + hitPoint: Vec3; + /** !#en + Distance + !#zh + 距离 */ + distance: number; + /** !#en + Hit the collision box + !#zh + 击中的碰撞盒 */ + collider: Collider3D; + /** + !#en + Set up ray. This method is used internally by the engine. Do not call it from an external script + !#zh + 设置射线,此方法由引擎内部使用,请勿在外部脚本调用 + @param hitPoint hitPoint + @param distance distance + @param collider collider + */ + _assign(hitPoint: Vec3, distance: number, collider: Collider3D): void; + /** + !#en + Clone + !#zh + 克隆 + */ + clone(): void; + } + /** Rigid body interface */ + export class IRigidBody { + rigidBody: RigidBody3D; + mass: number; + linearDamping: number; + angularDamping: number; + isKinematic: boolean; + useGravity: boolean; + fixedRotation: boolean; + linearFactor: IVec3Like; + angularFactor: IVec3Like; + allowSleep: boolean; + isAwake: boolean; + isSleepy: boolean; + isSleeping: boolean; + wakeUp(): void; + sleep(): void; + /** + + @param out out + */ + getLinearVelocity(out: IVec3Like): void; + /** + + @param out out + */ + setLinearVelocity(out: IVec3Like): void; + /** + + @param out out + */ + getAngularVelocity(out: IVec3Like): void; + /** + + @param out out + */ + setAngularVelocity(out: IVec3Like): void; + /** + + @param force force + @param relativePoint relativePoint + */ + applyForce(force: IVec3Like, relativePoint: IVec3Like): void; + /** + + @param force force + @param relativePoint relativePoint + */ + applyLocalForce(force: IVec3Like, relativePoint: IVec3Like): void; + /** + + @param force force + @param relativePoint relativePoint + */ + applyImpulse(force: IVec3Like, relativePoint: IVec3Like): void; + /** + + @param force force + @param relativePoint relativePoint + */ + applyLocalImpulse(force: IVec3Like, relativePoint: IVec3Like): void; + /** + + @param torque torque + */ + applyTorque(torque: IVec3Like): void; + /** + + @param torque torque + */ + applyLocalTorque(torque: IVec3Like): void; + } + /** Class has x y z properties */ + export class IVec3Like { + x: number; + y: number; + z: number; + } + /** Class has x y z w properties */ + export class IQuatLike { + x: number; + y: number; + z: number; + w: number; + } + /** !#en Base shape interface. */ + export class IBaseShape { + collider: Collider3D; + attachedRigidBody: RigidBody3D|void; + material: any; + isTrigger: boolean; + center: IVec3Like; + } + /** !#en box shape interface */ + export class IBoxShape { + size: IVec3Like; + } + /** !#en Sphere shape interface */ + export class ISphereShape { + radius: number; + } + /** Ray cast options */ + export class IRaycastOptions { + groupIndex: number; + queryTrigger: boolean; + maxDistance: number; + } + /** Collision detect */ + export class ICollisionDetect { + /** + Ray cast, and return information of the closest hit. + @param worldRay worldRay + @param options options + @param out out + */ + raycastClosest(worldRay: geomUtils.Ray, options: IRaycastOptions, out: PhysicsRayResult): boolean; + /** + Ray cast against all bodies. The provided callback will be executed for each hit with a RaycastResult as single argument. + @param worldRay worldRay + @param options options + @param pool pool + @param resultes resultes + */ + raycast(worldRay: geomUtils.Ray, options: IRaycastOptions, pool: RecyclePool, resultes: PhysicsRayResult[]): boolean; + } + /** Physics world interface */ + export class IPhysicsWorld { + } + /** !#en The shape module of 3d particle. + !#zh 3D 粒子的发射形状模块 */ + export class ShapeModule { + /** !#en The enable of shapeModule. + !#zh 是否启用 */ + enable: boolean; + /** !#en Particle emitter type. + !#zh 粒子发射器类型。 */ + shapeType: shapeModule.ShapeType; + /** !#en The emission site of the particle. + !#zh 粒子从发射器哪个部位发射。 */ + emitFrom: shapeModule.EmitLocation; + /** !#en Particle emitter radius. + !#zh 粒子发射器半径。 */ + radius: number; + /** !#en Particle emitter emission position (not valid for Box type emitters): + - 0 means emitted from the surface; + - 1 means launch from the center; + - 0 ~ 1 indicates emission from the center to the surface. + !#zh 粒子发射器发射位置(对 Box 类型的发射器无效): + - 0 表示从表面发射; + - 1 表示从中心发射; + - 0 ~ 1 之间表示在中心到表面之间发射。 */ + radiusThickness: number; + /** !#en The angle between the axis of the cone and the generatrix + Determines the opening and closing of the cone launcher + !#zh 圆锥的轴与母线的夹角。 + 决定圆锥发射器的开合程度。 */ + angle: number; + /** !#en Particle emitters emit in a fan-shaped range. + !#zh 粒子发射器在一个扇形范围内发射。 */ + arc: number; + /** !#en How particles are emitted in the sector range. + !#zh 粒子在扇形范围内的发射方式。 */ + arcMode: shapeModule.ArcMode; + /** !#en Controls the discrete intervals around the arcs where particles might be generated. + !#zh 控制可能产生粒子的弧周围的离散间隔。 */ + arcSpread: number; + /** !#en The speed at which particles are emitted around the circumference. + !#zh 粒子沿圆周发射的速度。 */ + arcSpeed: CurveRange; + /** !#en Axis length from top of cone to bottom of cone . + Determines the height of the cone emitter. + !#zh 圆锥顶部截面距离底部的轴长。 + 决定圆锥发射器的高度。 */ + length: number; + /** !#en Particle emitter emission location (for box-type particle emitters). + !#zh 粒子发射器发射位置(针对 Box 类型的粒子发射器。 */ + boxThickness: Vec3; + /** !#en Particle Emitter Position + !#zh 粒子发射器位置。 */ + position: Vec3; + /** !#en Particle emitter rotation angle. + !#zh 粒子发射器旋转角度。 */ + rotation: Vec3; + /** !#en Particle emitter scaling + !#zh 粒子发射器缩放比例。 */ + scale: Vec3; + /** !#en The direction of particle movement is determined based on the initial direction of the particles. + !#zh 根据粒子的初始方向决定粒子的移动方向。 */ + alignToDirection: boolean; + /** !#en Set particle generation direction randomly. + !#zh 粒子生成方向随机设定。 */ + randomDirectionAmount: number; + /** !#en Interpolation between the current emission direction and the direction from the current position to the center of the node. + !#zh 表示当前发射方向与当前位置到结点中心连线方向的插值。 */ + sphericalDirectionAmount: number; + } + /** !#en The trail module of 3d particle. + !#zh 3D 粒子拖尾模块 */ + export class TrailModule { + /** !#en The enable of trailModule. + !#zh 是否启用 */ + enable: boolean; + /** !#en Sets how particles generate trajectories. + !#zh 设定粒子生成轨迹的方式。 */ + mode: trailModule.TrailMode; + /** !#en Life cycle of trajectory. + !#zh 轨迹存在的生命周期。 */ + lifeTime: CurveRange; + /** !#en Minimum spacing between each track particle + !#zh 每个轨迹粒子之间的最小间距。 */ + minParticleDistance: number; + /** !#en The coordinate system of trajectories. + !#zh 轨迹设定时的坐标系。 */ + space: ParticleSystem3DAssembler.Space; + /** !#en Whether the particle itself exists. + !#zh 粒子本身是否存在。 */ + existWithParticles: boolean; + /** !#en Set the texture fill method + !#zh 设定纹理填充方式。 */ + textureMode: trailModule.TextureMode; + /** !#en Whether to use particle width + !#zh 是否使用粒子的宽度。 */ + widthFromParticle: boolean; + /** !#en Curves that control track length + !#zh 控制轨迹长度的曲线。 */ + widthRatio: CurveRange; + /** !#en Whether to use particle color + !#zh 是否使用粒子的颜色。 */ + colorFromParticle: boolean; + /** !#en The color of trajectories. + !#zh 轨迹的颜色。 */ + colorOverTrail: GradientRange; + /** !#en Trajectories color over time. + !#zh 轨迹随时间变化的颜色。 */ + colorOvertime: GradientRange; + } + /** !#en The color over time module of 3d particle. + !#zh 3D 粒子颜色变化模块 */ + export class ColorOvertimeModule { + /** !#en The enable of ColorOvertimeModule. + !#zh 是否启用 */ + enable: boolean; + } + /** !#en The curve range of target value. + !#zh 目标值的曲线范围 */ + export class CurveRange { + /** !#en Curve type. + !#zh 曲线类型。 */ + mode: debug.DebugMode; + /** !#en The curve to use when mode is Curve. + !#zh 当 mode 为 Curve 时,使用的曲线。 */ + curve: AnimationCurve; + /** !#en The lower limit of the curve to use when mode is TwoCurves + !#zh 当 mode 为 TwoCurves 时,使用的曲线下限。 */ + curveMin: AnimationCurve; + /** !#en The upper limit of the curve to use when mode is TwoCurves + !#zh 当 mode 为 TwoCurves 时,使用的曲线上限。 */ + curveMax: AnimationCurve; + /** !#en When mode is Constant, the value of the curve. + !#zh 当 mode 为 Constant 时,曲线的值。 */ + constant: number; + /** !#en The lower limit of the curve to use when mode is TwoConstants + !#zh 当 mode 为 TwoConstants 时,曲线的下限。 */ + constantMin: number; + /** !#en The upper limit of the curve to use when mode is TwoConstants + !#zh 当 mode 为 TwoConstants 时,曲线的上限。 */ + constantMax: number; + /** !#en Coefficients applied to curve interpolation. + !#zh 应用于曲线插值的系数。 */ + multiplier: number; + } + /** !#en The force over time module of 3d particle. + !#zh 3D 粒子的加速度模块 */ + export class ForceOvertimeModule { + /** !#en The enable of ColorOvertimeModule. + !#zh 是否启用 */ + enable: boolean; + /** !#en Coordinate system used in acceleration calculation. + !#zh 加速度计算时采用的坐标系。 */ + space: ParticleSystem3DAssembler.Space; + /** !#en X-axis acceleration component. + !#zh X 轴方向上的加速度分量。 */ + x: CurveRange; + /** !#en Y-axis acceleration component. + !#zh Y 轴方向上的加速度分量。 */ + y: CurveRange; + /** !#en Z-axis acceleration component. + !#zh Z 轴方向上的加速度分量。 */ + z: CurveRange; + } + /** !#en The gradient range of color. + !#zh 颜色值的渐变范围 */ + export class GradientRange { + /** !#en Gradient type. + !#zh 渐变色类型。 */ + mode: debug.DebugMode; + /** !#en The color when mode is Color. + !#zh 当 mode 为 Color 时的颜色。 */ + color: Color; + /** !#en Lower color limit when mode is TwoColors. + !#zh 当 mode 为 TwoColors 时的颜色下限。 */ + colorMin: Color; + /** !#en Upper color limit when mode is TwoColors. + !#zh 当 mode 为 TwoColors 时的颜色上限。 */ + colorMax: Color; + /** !#en Color gradient when mode is Gradient + !#zh 当 mode 为 Gradient 时的颜色渐变。 */ + gradient: Gradient; + /** !#en Lower color gradient limit when mode is TwoGradients. + !#zh 当 mode 为 TwoGradients 时的颜色渐变下限。 */ + gradientMin: Gradient; + /** !#en Upper color gradient limit when mode is TwoGradients. + !#zh 当 mode 为 TwoGradients 时的颜色渐变上限。 */ + gradientMax: Gradient; + } + /** !#en The color key of gradient. + !#zh color 关键帧 */ + export class ColorKey { + } + /** !#en The alpha key of gradient. + !#zh alpha 关键帧 */ + export class AlphaKey { + } + /** !#en The gradient data of color. + !#zh 颜色渐变数据 */ + export class Gradient { + } + /** !#en The limit velocity module of 3d particle. + !#zh 3D 粒子的限速模块 */ + export class LimitVelocityOvertimeModule { + /** !#en The enable of LimitVelocityOvertimeModule. + !#zh 是否启用 */ + enable: boolean; + /** !#en The coordinate system used when calculating the lower speed limit. + !#zh 计算速度下限时采用的坐标系。 */ + space: ParticleSystem3DAssembler.Space; + /** !#en Whether to limit the three axes separately. + !#zh 是否三个轴分开限制。 */ + separateAxes: boolean; + /** !#en Lower speed limit + !#zh 速度下限。 */ + limit: CurveRange; + /** !#en Lower speed limit in X direction. + !#zh X 轴方向上的速度下限。 */ + limitX: CurveRange; + /** !#en Lower speed limit in Y direction. + !#zh Y 轴方向上的速度下限。 */ + limitY: CurveRange; + /** !#en Lower speed limit in Z direction. + !#zh Z 轴方向上的速度下限。 */ + limitZ: CurveRange; + /** !#en Interpolation of current speed and lower speed limit. + !#zh 当前速度与速度下限的插值。 */ + dampen: number; + } + /** !#en The optimized curve. + !#zh 优化曲线 */ + export class OptimizedCurve { + } + /** !#en The rotation module of 3d particle. + !#zh 3D 粒子的旋转模块 */ + export class RotationOvertimeModule { + /** !#en The enable of RotationOvertimeModule. + !#zh 是否启用 */ + enable: boolean; + /** !#en Whether to set the rotation of three axes separately (not currently supported) + !#zh 是否三个轴分开设定旋转(暂不支持)。 */ + separateAxes: boolean; + /** !#en Set rotation around X axis. + !#zh 绕 X 轴设定旋转。 */ + x: CurveRange; + /** !#en Set rotation around Y axis. + !#zh 绕 Y 轴设定旋转。 */ + y: CurveRange; + /** !#en Set rotation around Z axis. + !#zh 绕 Z 轴设定旋转。 */ + z: CurveRange; + } + /** !#en The size module of 3d particle. + !#zh 3D 粒子的大小模块 */ + export class SizeOvertimeModule { + /** !#en The enable of SizeOvertimeModule. + !#zh 是否启用 */ + enable: boolean; + /** !#en Decide whether to control particle size independently on each axis. + !#zh 决定是否在每个轴上独立控制粒子大小。 */ + separateAxes: boolean; + /** !#en Define a curve to determine the size change of particles during their life cycle. + !#zh 定义一条曲线来决定粒子在其生命周期中的大小变化。 */ + size: CurveRange; + /** !#en Defines a curve to determine the size change of particles in the X-axis direction during their life cycle. + !#zh 定义一条曲线来决定粒子在其生命周期中 X 轴方向上的大小变化。 */ + x: CurveRange; + /** !#en Defines a curve to determine the size change of particles in the Y-axis direction during their life cycle. + !#zh 定义一条曲线来决定粒子在其生命周期中 Y 轴方向上的大小变化。 */ + y: CurveRange; + /** !#en Defines a curve to determine the size change of particles in the Z-axis direction during their life cycle. + !#zh 定义一条曲线来决定粒子在其生命周期中 Z 轴方向上的大小变化。 */ + z: CurveRange; + } + /** !#en The texture animation module of 3d particle. + !#zh 3D 粒子的贴图动画模块 */ + export class TextureAnimationModule { + /** !#en The enable of TextureAnimationModule. + !#zh 是否启用 */ + enable: boolean; + /** !#en Set the type of particle map animation (only supports Grid mode for the time being) + !#zh 设定粒子贴图动画的类型(暂只支持 Grid 模式。 */ + mode: debug.DebugMode; + /** !#en Animation frames in X direction. + !#zh X 方向动画帧数。 */ + numTilesX: number; + /** !#en Animation frames in Y direction. + !#zh Y 方向动画帧数。 */ + numTilesY: number; + /** !#en The way of the animation plays. + !#zh 动画播放方式。 */ + animation: Animation; + /** !#en Randomly select a line from the animated map to generate the animation.
+ This option only takes effect when the animation playback mode is SingleRow. + !#zh 随机从动画贴图中选择一行以生成动画。
+ 此选项仅在动画播放方式为 SingleRow 时生效。 */ + randomRow: boolean; + /** !#en Select specific lines from the animation map to generate the animation.
+ This option is only available when the animation playback mode is SingleRow and randomRow is disabled. + !#zh 从动画贴图中选择特定行以生成动画。
+ 此选项仅在动画播放方式为 SingleRow 时且禁用 randomRow 时可用。 */ + rowIndex: number; + /** !#en Frame and time curve of animation playback in one cycle. + !#zh 一个周期内动画播放的帧与时间变化曲线。 */ + frameOverTime: CurveRange; + /** !#en Play from which frames, the time is the life cycle of the entire particle system. + !#zh 从第几帧开始播放,时间为整个粒子系统的生命周期。 */ + startFrame: CurveRange; + /** !#en Number of playback loops in a life cycle. + !#zh 一个生命周期内播放循环的次数。 */ + cycleCount: number; + } + /** !#en The velocity module of 3d particle. + !#zh 3D 粒子的速度模块 */ + export class VelocityOvertimeModule { + /** !#en The enable of VelocityOvertimeModule. + !#zh 是否启用 */ + enable: boolean; + /** !#en Coordinate system used in speed calculation. + !#zh 速度计算时采用的坐标系。 */ + space: ParticleSystem3DAssembler.Space; + /** !#en Velocity component in X axis direction + !#zh X 轴方向上的速度分量。 */ + x: CurveRange; + /** !#en Velocity component in Y axis direction + !#zh Y 轴方向上的速度分量。 */ + y: CurveRange; + /** !#en Velocity component in Z axis direction + !#zh Z 轴方向上的速度分量。 */ + z: CurveRange; + /** !#en Speed correction factor (only supports CPU particles). + !#zh 速度修正系数(只支持 CPU 粒子)。 */ + speedModifier: CurveRange; + } + /** !#en Manage Dynamic Atlas Manager. Dynamic Atlas Manager is used for merging textures at runtime, see [Dynamic Atlas](https://docs.cocos.com/creator/manual/en/advanced-topics/dynamic-atlas.html) for details. + !#zh 管理动态图集。动态图集用于在运行时对贴图进行合并,详见 [动态合图](https://docs.cocos.com/creator/manual/zh/advanced-topics/dynamic-atlas.html)。 */ + export class DynamicAtlasManager { + /** !#en Enable or disable the dynamic atlas, see [Dynamic Atlas](https://docs.cocos.com/creator/manual/en/advanced-topics/dynamic-atlas.html) for details. + !#zh 开启或者关闭动态图集,详见 [动态合图](https://docs.cocos.com/creator/manual/zh/advanced-topics/dynamic-atlas.html)。 */ + enabled: boolean; + /** !#en The maximum number of atlas that can be created. + !#zh 可以创建的最大图集数量。 */ + maxAtlasCount: number; + /** !#en Is enable textureBleeding. + !#zh 是否开启 textureBleeding */ + textureBleeding: boolean; + /** !#en The size of the atlas that was created + !#zh 创建的图集的宽高 */ + textureSize: number; + /** !#en The maximum size of the picture that can be added to the atlas. + !#zh 可以添加进图集的图片的最大尺寸。 */ + maxFrameSize: number; + /** !#en The minimum size of the picture that can be added to the atlas. + !#zh 可以添加进图集的图片的最小尺寸。 */ + minFrameSize: number; + /** + !#en Append a sprite frame into the dynamic atlas. + !#zh 添加碎图进入动态图集。 + @param spriteFrame spriteFrame + */ + insertSpriteFrame(spriteFrame: SpriteFrame): void; + /** + !#en Resets all dynamic atlas, and the existing ones will be destroyed. + !#zh 重置所有动态图集,已有的动态图集会被销毁。 + */ + reset(): void; + /** + !#en Displays all the dynamic atlas in the current scene, which you can use to view the current atlas state. + !#zh 在当前场景中显示所有动态图集,可以用来查看当前的合图状态。 + @param show show + */ + showDebug(show: boolean): Node; + } + /** !#en + Physics material. + !#zh + 物理材质。 */ + export class PhysicsMaterial extends Asset { + /** !#en + Friction for this material. + !#zh + 物理材质的摩擦力。 */ + friction: number; + /** !#en + Restitution for this material. + !#zh + 物理材质的弹力。 */ + restitution: number; + } + /** !#en + Each frame applies a constant force to a rigid body, depending on the RigidBody3D + !#zh + 在每帧对一个刚体施加持续的力,依赖 RigidBody3D 组件 */ + export class ConstantForce extends Component { + /** !#en + Set the force used in the world coordinate system, use `this.force = otherVec3`. + !#zh + 设置世界坐标系中使用的力,设置时请用 `this.force = otherVec3` 的方式。 */ + force: Vec3; + /** !#en + Set the force used in the local coordinate system, using `this.localforce = otherVec3`. + !#zh + 获取和设置本地坐标系中使用的力,设置时请用 `this.localForce = otherVec3` 的方式。 */ + localForce: Vec3; + /** !#en + Torque applied to the world orientation + !#zh + 对世界朝向施加的扭矩 */ + torque: Vec3; + /** !#en + Torque applied to local orientation, using `this.localtorque = otherVec3`. + !#zh + 对本地朝向施加的扭矩,设置时请用 `this.localTorque = otherVec3` 的方式。 */ + localTorque: Vec3; + } + /** !#en + RigidBody is the basic object that make up the physical world, and it can make a node physically affected and react. + !#zh + 刚体是组成物理世界的基本对象,可以让一个节点受到物理影响并产生反应。该组件在使用 Builtin 物理引擎时无效。 */ + export class RigidBody3D extends Component { + /** !#en + Whether sleep is allowed. + !#zh + 是否允许休眠。 */ + allowSleep: boolean; + /** !#en + The mass of the rigidbody. + !#zh + 刚体的质量。 */ + mass: number; + /** !#en + Used to reduce the linear rate of rigidbody. The larger the value, the slower the rigidbody moves. + !#zh + 线性阻尼,用于减小刚体的线性速率,值越大物体移动越慢。 */ + linearDamping: number; + /** !#en + Used to reduce the rotation rate of rigidbody. The larger the value, the slower the rigidbody rotates. + !#zh + 角阻尼,用于减小刚体的旋转速率,值越大刚体旋转越慢。 */ + angularDamping: number; + /** !#en + If enabled, the developer controls the displacement and rotation of the rigidbody, not the physics engine. + !#zh + 是否由开发者来控制刚体的位移和旋转,而不是受物理引擎的影响。 */ + isKinematic: boolean; + /** !#en + If enabled, the rigidbody is affected by gravity. + !#zh + 如果开启,刚体会受到重力影响。 */ + useGravity: boolean; + /** !#en + If enabled, the rigidbody will be fixed without rotation during a collision. + !#zh + 如果开启,发生碰撞时会固定刚体不产生旋转。 */ + fixedRotation: boolean; + /** !#en + It can affect the linear velocity change of the rigidbody in each axis. The larger the value, the faster the rigidbody moves. + !#zh + 线性因子,可影响刚体在每个轴向的线性速度变化,值越大刚体移动越快。 */ + linearFactor: Vec3; + /** !#en + It can affect the rotation speed change of the rigidbody in each axis. The larger the value, the faster the rigidbody rotates. + !#zh + 旋转因子,可影响刚体在每个轴向的旋转速度变化,值越大刚体旋转越快。 */ + angularFactor: Vec3; + /** !#en + The rigidbody is awake. + !#zh + 刚体是否为唤醒的状态。 */ + isAwake: boolean; + /** !#en + The rigidbody can enter hibernation. + !#zh + 刚体是否为可进入休眠的状态。 */ + isSleepy: boolean; + /** !#en + The rigidbody is sleeping. + !#zh + 刚体是否为正在休眠的状态。 */ + isSleeping: boolean; + /** !#en + Get the rigidbody object inside the physics engine. + !#zh + 获得物理引擎内部刚体对象。 */ + rigidBody: IRigidBody; + /** + !#en + A force is applied to a rigid body at a point in world space. + !#zh + 在世界空间中的某点上对刚体施加一个作用力。 + @param force force + @param relativePoint The point of action, relative to the center of the rigid body. + */ + applyForce(force: Vec3, relativePoint: Vec3): void; + /** + !#en + Apply a force on the rigid body at a point in local space. + !#zh + 在本地空间中的某点上对刚体施加一个作用力。 + @param force force + @param localPoint Point of application + */ + applyLocalForce(force: Vec3, localPoint: Vec3): void; + /** + !#en + Apply an impulse to a rigid body at a point in world space. + !#zh + 在世界空间的某点上对刚体施加一个冲量。 + @param impulse impulse + @param relativePoint The point of action, relative to the center of the rigid body. + */ + applyImpulse(impulse: Vec3, relativePoint: Vec3): void; + /** + !#en + Apply an impulse to the rigid body at a point in local space. + !#zh + 在本地空间的某点上对刚体施加一个冲量。 + @param impulse impulse + @param localPoint Point of application + */ + applyLocalImpulse(impulse: Vec3, localPoint: Vec3): void; + /** + !#en + Apply a torque to the rigid body. + !#zh + 对刚体施加扭转力。 + @param torque torque + */ + applyTorque(torque: Vec3): void; + /** + !#en + Apply a local torque to the rigid body. + !#zh + 对刚体施加本地扭转力。 + @param torque torque + */ + applyLocalTorque(torque: Vec3): void; + /** + !#en + Awaken the rigid body. + !#zh + 唤醒刚体。 + */ + wakeUp(): void; + /** + !#en + Dormant rigid body. + !#zh + 休眠刚体。 + */ + sleep(): void; + /** + !#en + Get linear velocity. + !#zh + 获取线性速度。 + @param out out + */ + getLinearVelocity(out: Vec3): void; + /** + !#en + Set linear speed. + !#zh + 设置线性速度。 + @param value value + */ + setLinearVelocity(value: Vec3): void; + /** + !#en + Gets the rotation speed. + !#zh + 获取旋转速度。 + @param out out + */ + getAngularVelocity(out: Vec3): void; + /** + !#en + Set rotation speed. + !#zh + 设置旋转速度。 + @param value value + */ + setAngularVelocity(value: Vec3): void; + } + /** !#en + Physics box collider + !#zh + 物理盒子碰撞器 */ + export class BoxCollider3D extends Collider3D { + /** !#en + Get or set the size of the box, in local space. + !#zh + 获取或设置盒的大小。 */ + size: Vec3; + boxShape: IBoxShape; + } + /** !#en + The base class of the collider. + !#zh + 碰撞器的基类。 */ + export class Collider3D extends Component implements EventTarget { + sharedMaterial: PhysicsMaterial; + /** !#en + get or set the collider is trigger, this will be always trigger if using builtin. + !#zh + 获取或设置碰撞器是否为触发器。 */ + isTrigger: boolean; + /** !#en + get or set the center of the collider, in local space. + !#zh + 获取或设置碰撞器的中心点。 */ + center: Vec3; + /** !#en + get the collider attached rigidbody, this may be null. + !#zh + 获取碰撞器所绑定的刚体组件,可能为 null。 */ + attachedRigidbody: RigidBody3D|void; + /** !#en + get collider shape. + !#zh + 获取碰撞器形状。 */ + shape: IBaseShape; + /** + !#en + Register an callback of a specific event type on the EventTarget. + This type of event should be triggered via `emit`. + !#zh + 注册事件目标的特定事件类型回调。这种类型的事件应该被 `emit` 触发。 + @param type The type of collider event can be `trigger-enter`, `trigger-stay`, `trigger-exit` or `collision-enter`, `collision-stay`, `collision-exit`. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null. + + @example + ```js + eventTarget.on('fire', function (event) { + // event is ITriggerEvent or ICollisionEvent + }, node); + ``` + */ + on(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. + !#zh + 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。 + @param type The type of collider event can be `trigger-enter`, `trigger-stay`, `trigger-exit` or `collision-enter`, `collision-stay`, `collision-exit`. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed. + + @example + ```js + // register fire eventListener + var callback = eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, target); + // remove fire event listener + eventTarget.off('fire', callback, target); + // remove all fire event listeners + eventTarget.off('fire'); + ``` + */ + off(type: string, callback?: Function, target?: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type The type of collider event can be `trigger-enter`, `trigger-stay`, `trigger-exit` or `collision-enter`, `collision-stay`, `collision-exit`. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null. + + @example + ```js + eventTarget.once('fire', function (event) { + // event is ITriggerEvent or ICollisionEvent + }, node); + ``` + */ + once(type: string, callback: (event: ITriggerEvent|ICollisionEvent) => void, target?: any): void; + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Send an event with the event object. + !#zh + 通过事件对象派发事件 + @param event event + */ + dispatchEvent(event: Event): void; + } + /** !#en + Physics sphere collider + !#zh + 物理球碰撞器 */ + export class SphereCollider3D extends Collider3D { + /** !#en + Get or set the radius of the sphere. + !#zh + 获取或设置球的半径。 */ + radius: number; + sphereShape: ISphereShape; + } + /**************************************************** + * audioEngine + *****************************************************/ + + export namespace audioEngine { + /** !#en Audio state. + !#zh 声音播放状态 */ + export enum AudioState { + ERROR = 0, + INITIALZING = 0, + PLAYING = 0, + PAUSED = 0, + STOPPED = 0, + } + } + + /**************************************************** + * debug + *****************************************************/ + + export namespace debug { + /** !#en Enum for debug modes. + !#zh 调试模式 */ + export enum DebugMode { + NONE = 0, + INFO = 0, + WARN = 0, + ERROR = 0, + INFO_FOR_WEB_PAGE = 0, + WARN_FOR_WEB_PAGE = 0, + ERROR_FOR_WEB_PAGE = 0, + } + } + + /**************************************************** + * Node + *****************************************************/ + + export namespace Node { + /** !#en Node's local dirty properties flag + !#zh Node 的本地属性 dirty 状态位 */ + export enum _LocalDirtyFlag { + POSITION = 0, + SCALE = 0, + ROTATION = 0, + SKEW = 0, + TRS = 0, + RS = 0, + TRS = 0, + PHYSICS_POSITION = 0, + PHYSICS_SCALE = 0, + PHYSICS_ROTATION = 0, + PHYSICS_TRS = 0, + PHYSICS_RS = 0, + ALL_POSITION = 0, + ALL_SCALE = 0, + ALL_ROTATION = 0, + ALL_TRS = 0, + ALL = 0, + } + } + + /**************************************************** + * Node + *****************************************************/ + + export namespace Node { + /** !#en The event type supported by Node + !#zh Node 支持的事件类型 */ + export class EventType { + /** !#en The event type for touch start event, you can use its value directly: 'touchstart' + !#zh 当手指触摸到屏幕时。 */ + static TOUCH_START: string; + /** !#en The event type for touch move event, you can use its value directly: 'touchmove' + !#zh 当手指在屏幕上移动时。 */ + static TOUCH_MOVE: string; + /** !#en The event type for touch end event, you can use its value directly: 'touchend' + !#zh 当手指在目标节点区域内离开屏幕时。 */ + static TOUCH_END: string; + /** !#en The event type for touch end event, you can use its value directly: 'touchcancel' + !#zh 当手指在目标节点区域外离开屏幕时。 */ + static TOUCH_CANCEL: string; + /** !#en The event type for mouse down events, you can use its value directly: 'mousedown' + !#zh 当鼠标按下时触发一次。 */ + static MOUSE_DOWN: string; + /** !#en The event type for mouse move events, you can use its value directly: 'mousemove' + !#zh 当鼠标在目标节点在目标节点区域中移动时,不论是否按下。 */ + static MOUSE_MOVE: string; + /** !#en The event type for mouse enter target events, you can use its value directly: 'mouseenter' + !#zh 当鼠标移入目标节点区域时,不论是否按下。 */ + static MOUSE_ENTER: string; + /** !#en The event type for mouse leave target events, you can use its value directly: 'mouseleave' + !#zh 当鼠标移出目标节点区域时,不论是否按下。 */ + static MOUSE_LEAVE: string; + /** !#en The event type for mouse up events, you can use its value directly: 'mouseup' + !#zh 当鼠标从按下状态松开时触发一次。 */ + static MOUSE_UP: string; + /** !#en The event type for mouse wheel events, you can use its value directly: 'mousewheel' + !#zh 当鼠标滚轮滚动时。 */ + static MOUSE_WHEEL: string; + /** !#en The event type for position change events. + Performance note, this event will be triggered every time corresponding properties being changed, + if the event callback have heavy logic it may have great performance impact, try to avoid such scenario. + !#zh 当节点位置改变时触发的事件。 + 性能警告:这个事件会在每次对应的属性被修改时触发,如果事件回调损耗较高,有可能对性能有很大的负面影响,请尽量避免这种情况。 */ + static POSITION_CHANGED: string; + /** !#en The event type for rotation change events. + Performance note, this event will be triggered every time corresponding properties being changed, + if the event callback have heavy logic it may have great performance impact, try to avoid such scenario. + !#zh 当节点旋转改变时触发的事件。 + 性能警告:这个事件会在每次对应的属性被修改时触发,如果事件回调损耗较高,有可能对性能有很大的负面影响,请尽量避免这种情况。 */ + static ROTATION_CHANGED: string; + /** !#en The event type for scale change events. + Performance note, this event will be triggered every time corresponding properties being changed, + if the event callback have heavy logic it may have great performance impact, try to avoid such scenario. + !#zh 当节点缩放改变时触发的事件。 + 性能警告:这个事件会在每次对应的属性被修改时触发,如果事件回调损耗较高,有可能对性能有很大的负面影响,请尽量避免这种情况。 */ + static SCALE_CHANGED: string; + /** !#en The event type for size change events. + Performance note, this event will be triggered every time corresponding properties being changed, + if the event callback have heavy logic it may have great performance impact, try to avoid such scenario. + !#zh 当节点尺寸改变时触发的事件。 + 性能警告:这个事件会在每次对应的属性被修改时触发,如果事件回调损耗较高,有可能对性能有很大的负面影响,请尽量避免这种情况。 */ + static SIZE_CHANGED: string; + /** !#en The event type for anchor point change events. + Performance note, this event will be triggered every time corresponding properties being changed, + if the event callback have heavy logic it may have great performance impact, try to avoid such scenario. + !#zh 当节点锚点改变时触发的事件。 + 性能警告:这个事件会在每次对应的属性被修改时触发,如果事件回调损耗较高,有可能对性能有很大的负面影响,请尽量避免这种情况。 */ + static ANCHOR_CHANGED: string; + /** !#en The event type for color change events. + Performance note, this event will be triggered every time corresponding properties being changed, + if the event callback have heavy logic it may have great performance impact, try to avoid such scenario. + !#zh 当节点颜色改变时触发的事件。 + 性能警告:这个事件会在每次对应的属性被修改时触发,如果事件回调损耗较高,有可能对性能有很大的负面影响,请尽量避免这种情况。 */ + static COLOR_CHANGED: string; + /** !#en The event type for new child added events. + !#zh 当新的子节点被添加时触发的事件。 */ + static CHILD_ADDED: string; + /** !#en The event type for child removed events. + !#zh 当子节点被移除时触发的事件。 */ + static CHILD_REMOVED: string; + /** !#en The event type for children reorder events. + !#zh 当子节点顺序改变时触发的事件。 */ + static CHILD_REORDER: string; + /** !#en The event type for node group changed events. + !#zh 当节点归属群组发生变化时触发的事件。 */ + static GROUP_CHANGED: string; + /** !#en The event type for node's sibling order changed. + !#zh 当节点在兄弟节点中的顺序发生变化时触发的事件。 */ + static SIBLING_ORDER_CHANGED: string; + } + } + + /**************************************************** + * TiledMap + *****************************************************/ + + export namespace TiledMap { + /** !#en The orientation of tiled map. + !#zh Tiled Map 地图方向。 */ + export enum Orientation { + ORTHO = 0, + HEX = 0, + ISO = 0, + } + } + + /**************************************************** + * TiledMap + *****************************************************/ + + export namespace TiledMap { + /** The property type of tiled map. */ + export enum Property { + NONE = 0, + MAP = 0, + LAYER = 0, + OBJECTGROUP = 0, + OBJECT = 0, + TILE = 0, + } + } + + /**************************************************** + * TiledMap + *****************************************************/ + + export namespace TiledMap { + /** The tile flags of tiled map. */ + export enum TileFlag { + HORIZONTAL = 0, + VERTICAL = 0, + DIAGONAL = 0, + FLIPPED_ALL = 0, + FLIPPED_MASK = 0, + } + } + + /**************************************************** + * TiledMap + *****************************************************/ + + export namespace TiledMap { + /** !#en The stagger axis of Hex tiled map. + !#zh 六边形地图的 stagger axis 值 */ + export enum StaggerAxis { + STAGGERAXIS_X = 0, + STAGGERAXIS_Y = 0, + } + } + + /**************************************************** + * TiledMap + *****************************************************/ + + export namespace TiledMap { + /** !#en The render order of tiled map. + !#zh 地图的渲染顺序 */ + export enum RenderOrder { + STAGGERINDEX_ODD = 0, + STAGGERINDEX_EVEN = 0, + RightDown = 0, + RightUp = 0, + LeftDown = 0, + LeftUp = 0, + } + } + + /**************************************************** + * TiledMap + *****************************************************/ + + export namespace TiledMap { + /** !#en TiledMap Object Type + !#zh 地图物体类型 */ + export enum TMXObjectType { + RECT = 0, + ELLIPSE = 0, + POLYGON = 0, + POLYLINE = 0, + IMAGE = 0, + TEXT = 0, + } + } + + /**************************************************** + * ParticleSystem + *****************************************************/ + + export namespace ParticleSystem { + /** !#en Enum for emitter modes + !#zh 发射模式 */ + export enum EmitterMode { + GRAVITY = 0, + RADIUS = 0, + } + } + + /**************************************************** + * ParticleSystem + *****************************************************/ + + export namespace ParticleSystem { + /** !#en Enum for particles movement type. + !#zh 粒子位置类型 */ + export enum PositionType { + FREE = 0, + RELATIVE = 0, + GROUPED = 0, + } + } + + /**************************************************** + * VideoPlayer + *****************************************************/ + + export namespace VideoPlayer { + /** !#en Video event type + !#zh 视频事件类型 */ + export enum EventType { + PLAYING = 0, + PAUSED = 0, + STOPPED = 0, + COMPLETED = 0, + META_LOADED = 0, + CLICKED = 0, + READY_TO_PLAY = 0, + } + } + + /**************************************************** + * VideoPlayer + *****************************************************/ + + export namespace VideoPlayer { + /** !#en Enum for video resouce type type. + !#zh 视频来源 */ + export enum ResourceType { + REMOTE = 0, + LOCAL = 0, + } + } + + /**************************************************** + * WebView + *****************************************************/ + + export namespace WebView { + /** !#en WebView event type + !#zh 网页视图事件类型 */ + export enum EventType { + LOADED = 0, + LOADING = 0, + ERROR = 0, + } + } + + /**************************************************** + * Light + *****************************************************/ + + export namespace Light { + /** !#en The light source type + + !#zh 光源类型 */ + export enum Type { + DIRECTIONAL = 0, + POINT = 0, + SPOT = 0, + AMBIENT = 0, + } + } + + /**************************************************** + * Light + *****************************************************/ + + export namespace Light { + /** !#en The shadow type + + !#zh 阴影类型 */ + export enum ShadowType { + NONE = 0, + HARD = 0, + SOFT_PCF3X3 = 0, + SOFT_PCF5X5 = 0, + } + } + + /**************************************************** + * Camera + *****************************************************/ + + export namespace Camera { + /** !#en Values for Camera.clearFlags, determining what to clear when rendering a Camera. + !#zh 摄像机清除标记位,决定摄像机渲染时会清除哪些状态 */ + export enum ClearFlags { + COLOR = 0, + DEPTH = 0, + STENCIL = 0, + } + } + + /**************************************************** + * Collider + *****************************************************/ + + export namespace Collider { + /** !#en Defines a Box Collider . + !#zh 用来定义包围盒碰撞体 */ + export class Box { + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Box size + !#zh 包围盒大小 */ + size: Size; + } + } + + /**************************************************** + * Collider + *****************************************************/ + + export namespace Collider { + /** !#en Defines a Circle Collider . + !#zh 用来定义圆形碰撞体 */ + export class Circle { + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Circle radius + !#zh 圆形半径 */ + radius: number; + } + } + + /**************************************************** + * Collider + *****************************************************/ + + export namespace Collider { + /** !#en Defines a Polygon Collider . + !#zh 用来定义多边形碰撞体 */ + export class Polygon { + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Polygon points + !#zh 多边形顶点数组 */ + points: Vec2[]; + } + } + + /**************************************************** + * Animation + *****************************************************/ + + export namespace Animation { + /** !#en The event type supported by Animation + !#zh Animation 支持的事件类型 */ + export class EventType { + /** !#en Emit when begin playing animation + !#zh 开始播放时触发 */ + static PLAY: string; + /** !#en Emit when stop playing animation + !#zh 停止播放时触发 */ + static STOP: string; + /** !#en Emit when pause animation + !#zh 暂停播放时触发 */ + static PAUSE: string; + /** !#en Emit when resume animation + !#zh 恢复播放时触发 */ + static RESUME: string; + /** !#en If animation repeat count is larger than 1, emit when animation play to the last frame + !#zh 假如动画循环次数大于 1,当动画播放到最后一帧时触发 */ + static LASTFRAME: string; + /** !#en Emit when finish playing animation + !#zh 动画播放完成时触发 */ + static FINISHED: string; + } + } + + /**************************************************** + * Button + *****************************************************/ + + export namespace Button { + /** !#en Enum for transition type. + !#zh 过渡类型 */ + export enum Transition { + NONE = 0, + COLOR = 0, + SPRITE = 0, + SCALE = 0, + } + } + + /**************************************************** + * Component + *****************************************************/ + + export namespace Component { + /** !#en + Component will register a event to target component's handler. + And it will trigger the handler when a certain event occurs. + + !@zh + “EventHandler” 类用来设置场景中的事件回调, + 该类允许用户设置回调目标节点,目标组件名,组件方法名, + 并可通过 emit 方法调用目标函数。 */ + export class EventHandler { + /** !#en the node that contains target callback, such as the node example script belongs to + !#zh 事件响应函数所在节点 ,比如例子中脚本归属的节点本身 */ + target: Node; + /** !#en name of the component(script) that contains target callback, such as the name 'MainMenu' of script in example + !#zh 事件响应函数所在组件名(脚本名), 比如例子中的脚本名 'MainMenu' */ + component: string; + /** !#en Event handler, such as function's name 'onClick' in example + !#zh 响应事件函数名,比如例子中的 'onClick' */ + handler: string; + /** !#en Custom Event Data, such as 'eventType' in example + !#zh 自定义事件数据,比如例子中的 eventType */ + customEventData: string; + /** + + @param events events + @param params params + */ + static emitEvents(events: EventHandler[], ...params: any[]): void; + /** + !#en Emit event with params + !#zh 触发目标组件上的指定 handler 函数,该参数是回调函数的参数值(可不填)。 + @param params params + + @example + ```js + // Call Function + var eventHandler = new cc.Component.EventHandler(); + eventHandler.target = newTarget; + eventHandler.component = "MainMenu"; + eventHandler.handler = "OnClick" + eventHandler.emit(["param1", "param2", ....]); + ``` + */ + emit(params: any[]): void; + } + } + + /**************************************************** + * Label + *****************************************************/ + + export namespace Label { + /** !#en Enum for text alignment. + !#zh 文本横向对齐类型 */ + export enum HorizontalAlign { + LEFT = 0, + CENTER = 0, + RIGHT = 0, + } + } + + /**************************************************** + * Label + *****************************************************/ + + export namespace Label { + /** !#en Enum for vertical text alignment. + !#zh 文本垂直对齐类型 */ + export enum VerticalAlign { + TOP = 0, + CENTER = 0, + BOTTOM = 0, + } + } + + /**************************************************** + * Label + *****************************************************/ + + export namespace Label { + /** !#en Enum for Overflow. + !#zh Overflow 类型 */ + export enum Overflow { + NONE = 0, + CLAMP = 0, + SHRINK = 0, + RESIZE_HEIGHT = 0, + } + } + + /**************************************************** + * Label + *****************************************************/ + + export namespace Label { + /** !#en Enum for font type. + !#zh Type 类型 */ + export enum Type { + TTF = 0, + BMFont = 0, + SystemFont = 0, + } + } + + /**************************************************** + * Label + *****************************************************/ + + export namespace Label { + /** !#en Enum for cache mode. + !#zh CacheMode 类型 */ + export enum CacheMode { + NONE = 0, + BITMAP = 0, + CHAR = 0, + } + } + + /**************************************************** + * Layout + *****************************************************/ + + export namespace Layout { + /** !#en Enum for Layout type + !#zh 布局类型 */ + export enum Type { + NONE = 0, + HORIZONTAL = 0, + VERTICAL = 0, + GRID = 0, + } + } + + /**************************************************** + * Layout + *****************************************************/ + + export namespace Layout { + /** !#en Enum for Layout Resize Mode + !#zh 缩放模式 */ + export enum ResizeMode { + NONE = 0, + CONTAINER = 0, + CHILDREN = 0, + } + } + + /**************************************************** + * Layout + *****************************************************/ + + export namespace Layout { + /** !#en Enum for Grid Layout start axis direction. + The items in grid layout will be arranged in each axis at first.; + !#zh 布局轴向,只用于 GRID 布局。 */ + export enum AxisDirection { + HORIZONTAL = 0, + VERTICAL = 0, + } + } + + /**************************************************** + * Layout + *****************************************************/ + + export namespace Layout { + /** !#en Enum for vertical layout direction. + Used in Grid Layout together with AxisDirection is VERTICAL + !#zh 垂直方向布局方式 */ + export enum VerticalDirection { + BOTTOM_TO_TOP = 0, + TOP_TO_BOTTOM = 0, + } + } + + /**************************************************** + * Layout + *****************************************************/ + + export namespace Layout { + /** !#en Enum for horizontal layout direction. + Used in Grid Layout together with AxisDirection is HORIZONTAL + !#zh 水平方向布局方式 */ + export enum HorizontalDirection { + LEFT_TO_RIGHT = 0, + RIGHT_TO_LEFT = 0, + } + } + + /**************************************************** + * Mask + *****************************************************/ + + export namespace Mask { + /** !#en the type for mask. + !#zh 遮罩组件类型 */ + export enum Type { + RECT = 0, + ELLIPSE = 0, + IMAGE_STENCIL = 0, + } + } + + /**************************************************** + * PageView + *****************************************************/ + + export namespace PageView { + /** !#en The Page View Size Mode + !#zh 页面视图每个页面统一的大小类型 */ + export enum SizeMode { + Unified = 0, + Free = 0, + } + } + + /**************************************************** + * PageView + *****************************************************/ + + export namespace PageView { + /** !#en The Page View Direction + !#zh 页面视图滚动类型 */ + export enum Direction { + Horizontal = 0, + Vertical = 0, + } + } + + /**************************************************** + * PageView + *****************************************************/ + + export namespace PageView { + /** !#en Enum for ScrollView event type. + !#zh 滚动视图事件类型 */ + export enum EventType { + PAGE_TURNING = 0, + } + } + + /**************************************************** + * PageViewIndicator + *****************************************************/ + + export namespace PageViewIndicator { + /** !#en Enum for PageView Indicator direction + !#zh 页面视图指示器的摆放方向 */ + export enum Direction { + HORIZONTAL = 0, + VERTICAL = 0, + } + } + + /**************************************************** + * ProgressBar + *****************************************************/ + + export namespace ProgressBar { + /** !#en Enum for ProgressBar mode + !#zh 进度条模式 */ + export enum Mode { + HORIZONTAL = 0, + VERTICAL = 0, + FILLED = 0, + } + } + + /**************************************************** + * Scrollbar + *****************************************************/ + + export namespace Scrollbar { + /** Enum for Scrollbar direction */ + export enum Direction { + HORIZONTAL = 0, + VERTICAL = 0, + } + } + + /**************************************************** + * ScrollView + *****************************************************/ + + export namespace ScrollView { + /** !#en Enum for ScrollView event type. + !#zh 滚动视图事件类型 */ + export enum EventType { + SCROLL_TO_TOP = 0, + SCROLL_TO_BOTTOM = 0, + SCROLL_TO_LEFT = 0, + SCROLL_TO_RIGHT = 0, + SCROLLING = 0, + BOUNCE_TOP = 0, + BOUNCE_BOTTOM = 0, + BOUNCE_LEFT = 0, + BOUNCE_RIGHT = 0, + SCROLL_ENDED = 0, + TOUCH_UP = 0, + AUTOSCROLL_ENDED_WITH_THRESHOLD = 0, + SCROLL_BEGAN = 0, + } + } + + /**************************************************** + * Slider + *****************************************************/ + + export namespace Slider { + /** !#en The Slider Direction + !#zh 滑动器方向 */ + export enum Direction { + Horizontal = 0, + Vertical = 0, + } + } + + /**************************************************** + * Sprite + *****************************************************/ + + export namespace Sprite { + /** !#en Enum for sprite type. + !#zh Sprite 类型 */ + export enum Type { + SIMPLE = 0, + SLICED = 0, + TILED = 0, + FILLED = 0, + MESH = 0, + } + } + + /**************************************************** + * Sprite + *****************************************************/ + + export namespace Sprite { + /** !#en Enum for fill type. + !#zh 填充类型 */ + export enum FillType { + HORIZONTAL = 0, + VERTICAL = 0, + RADIAL = 0, + } + } + + /**************************************************** + * Sprite + *****************************************************/ + + export namespace Sprite { + /** !#en Sprite Size can track trimmed size, raw size or none. + !#zh 精灵尺寸调整模式 */ + export enum SizeMode { + CUSTOM = 0, + TRIMMED = 0, + RAW = 0, + } + } + + /**************************************************** + * Sprite + *****************************************************/ + + export namespace Sprite { + /** !#en Sprite state can choice the normal or grayscale. + !#zh 精灵颜色通道模式。 */ + export enum State { + NORMAL = 0, + GRAY = 0, + } + } + + /**************************************************** + * Widget + *****************************************************/ + + export namespace Widget { + /** !#en Enum for Widget's alignment mode, indicating when the widget should refresh. + !#zh Widget 的对齐模式,表示 Widget 应该何时刷新。 */ + export enum AlignMode { + ONCE = 0, + ON_WINDOW_RESIZE = 0, + ALWAYS = 0, + } + } + + /**************************************************** + * Prefab + *****************************************************/ + + export namespace Prefab { + /** !#zh + Prefab 创建实例所用的优化策略,配合 {{#crossLink "Prefab.optimizationPolicy"}}cc.Prefab#optimizationPolicy{{/crossLink}} 使用。 + !#en + An enumeration used with the {{#crossLink "Prefab.optimizationPolicy"}}cc.Prefab#optimizationPolicy{{/crossLink}} + to specify how to optimize the instantiate operation. */ + export enum OptimizationPolicy { + AUTO = 0, + SINGLE_INSTANCE = 0, + MULTI_INSTANCE = 0, + } + } + + /**************************************************** + * RenderTexture + *****************************************************/ + + export namespace RenderTexture { + /** !#en The depth buffer and stencil buffer format for RenderTexture. + !#zh RenderTexture 的深度缓冲以及模板缓冲格式。 */ + export enum DepthStencilFormat { + RB_FMT_D24S8 = 0, + RB_FMT_S8 = 0, + RB_FMT_D16 = 0, + } + } + + /**************************************************** + * Texture2D + *****************************************************/ + + export namespace Texture2D { + /** The texture pixel format, default value is RGBA8888, + you should note that textures loaded by normal image files (png, jpg) can only support RGBA8888 format, + other formats are supported by compressed file types or raw data. */ + export enum PixelFormat { + RGB565 = 0, + RGB5A1 = 0, + RGBA4444 = 0, + RGB888 = 0, + RGBA8888 = 0, + RGBA32F = 0, + A8 = 0, + I8 = 0, + AI88 = 0, + RGB_PVRTC_2BPPV1 = 0, + RGBA_PVRTC_2BPPV1 = 0, + RGB_A_PVRTC_2BPPV1 = 0, + RGB_PVRTC_4BPPV1 = 0, + RGBA_PVRTC_4BPPV1 = 0, + RGB_A_PVRTC_4BPPV1 = 0, + RGB_ETC1 = 0, + RGBA_ETC1 = 0, + RGB_ETC2 = 0, + RGBA_ETC2 = 0, + } + } + + /**************************************************** + * Texture2D + *****************************************************/ + + export namespace Texture2D { + /** The texture wrap mode */ + export enum WrapMode { + REPEAT = 0, + CLAMP_TO_EDGE = 0, + MIRRORED_REPEAT = 0, + } + } + + /**************************************************** + * Texture2D + *****************************************************/ + + export namespace Texture2D { + /** The texture filter mode */ + export enum Filter { + LINEAR = 0, + NEAREST = 0, + } + } + + /**************************************************** + * Event + *****************************************************/ + + export namespace Event { + /** !#en The mouse event + !#zh 鼠标事件类型 */ + export class EventMouse extends Event { + /** + !#en Sets scroll data. + !#zh 设置鼠标的滚动数据。 + @param scrollX scrollX + @param scrollY scrollY + */ + setScrollData(scrollX: number, scrollY: number): void; + /** + !#en Returns the x axis scroll value. + !#zh 获取鼠标滚动的X轴距离,只有滚动时才有效。 + */ + getScrollX(): number; + /** + !#en Returns the y axis scroll value. + !#zh 获取滚轮滚动的 Y 轴距离,只有滚动时才有效。 + */ + getScrollY(): number; + /** + !#en Sets cursor location. + !#zh 设置当前鼠标位置。 + @param x x + @param y y + */ + setLocation(x: number, y: number): void; + /** + !#en Returns cursor location. + !#zh 获取鼠标位置对象,对象包含 x 和 y 属性。 + */ + getLocation(): Vec2; + /** + !#en Returns the current cursor location in screen coordinates. + !#zh 获取当前事件在游戏窗口内的坐标位置对象,对象包含 x 和 y 属性。 + */ + getLocationInView(): Vec2; + /** + !#en Returns the previous touch location. + !#zh 获取鼠标点击在上一次事件时的位置对象,对象包含 x 和 y 属性。 + */ + getPreviousLocation(): Vec2; + /** + !#en Returns the delta distance from the previous location to current location. + !#zh 获取鼠标距离上一次事件移动的距离对象,对象包含 x 和 y 属性。 + */ + getDelta(): Vec2; + /** + !#en Returns the X axis delta distance from the previous location to current location. + !#zh 获取鼠标距离上一次事件移动的 X 轴距离。 + */ + getDeltaX(): number; + /** + !#en Returns the Y axis delta distance from the previous location to current location. + !#zh 获取鼠标距离上一次事件移动的 Y 轴距离。 + */ + getDeltaY(): number; + /** + !#en Sets mouse button. + !#zh 设置鼠标按键。 + @param button button + */ + setButton(button: number): void; + /** + !#en Returns mouse button. + !#zh 获取鼠标按键。 + */ + getButton(): number; + /** + !#en Returns location X axis data. + !#zh 获取鼠标当前位置 X 轴。 + */ + getLocationX(): number; + /** + !#en Returns location Y axis data. + !#zh 获取鼠标当前位置 Y 轴。 + */ + getLocationY(): number; + /** !#en The none event code of mouse event. + !#zh 无。 */ + static NONE: number; + /** !#en The event type code of mouse down event. + !#zh 鼠标按下事件。 */ + static DOWN: number; + /** !#en The event type code of mouse up event. + !#zh 鼠标按下后释放事件。 */ + static UP: number; + /** !#en The event type code of mouse move event. + !#zh 鼠标移动事件。 */ + static MOVE: number; + /** !#en The event type code of mouse scroll event. + !#zh 鼠标滚轮事件。 */ + static SCROLL: number; + /** !#en The tag of Mouse left button. + !#zh 鼠标左键的标签。 */ + static BUTTON_LEFT: number; + /** !#en The tag of Mouse right button (The right button number is 2 on browser). + !#zh 鼠标右键的标签。 */ + static BUTTON_RIGHT: number; + /** !#en The tag of Mouse middle button (The right button number is 1 on browser). + !#zh 鼠标中键的标签。 */ + static BUTTON_MIDDLE: number; + /** !#en The tag of Mouse button 4. + !#zh 鼠标按键 4 的标签。 */ + static BUTTON_4: number; + /** !#en The tag of Mouse button 5. + !#zh 鼠标按键 5 的标签。 */ + static BUTTON_5: number; + /** !#en The tag of Mouse button 6. + !#zh 鼠标按键 6 的标签。 */ + static BUTTON_6: number; + /** !#en The tag of Mouse button 7. + !#zh 鼠标按键 7 的标签。 */ + static BUTTON_7: number; + /** !#en The tag of Mouse button 8. + !#zh 鼠标按键 8 的标签。 */ + static BUTTON_8: number; + } + } + + /**************************************************** + * Event + *****************************************************/ + + export namespace Event { + /** !#en The touch event + !#zh 触摸事件 */ + export class EventTouch extends Event { + /** + + @param touchArr The array of the touches + @param bubbles A boolean indicating whether the event bubbles up through the tree or not + */ + constructor(touchArr: any[], bubbles: boolean); + /** !#en The current touch object + !#zh 当前触点对象 */ + touch: Touch; + /** + !#en Returns event code. + !#zh 获取事件类型。 + */ + getEventCode(): number; + /** + !#en Returns touches of event. + !#zh 获取触摸点的列表。 + */ + getTouches(): any[]; + /** + !#en Sets touch location. + !#zh 设置当前触点位置 + @param x x + @param y y + */ + setLocation(x: number, y: number): void; + /** + !#en Returns touch location. + !#zh 获取触点位置。 + */ + getLocation(): Vec2; + /** + !#en Returns the current touch location in screen coordinates. + !#zh 获取当前触点在游戏窗口中的位置。 + */ + getLocationInView(): Vec2; + /** + !#en Returns the previous touch location. + !#zh 获取触点在上一次事件时的位置对象,对象包含 x 和 y 属性。 + */ + getPreviousLocation(): Vec2; + /** + !#en Returns the start touch location. + !#zh 获取触点落下时的位置对象,对象包含 x 和 y 属性。 + */ + getStartLocation(): Vec2; + /** + !#en Returns the id of cc.Touch. + !#zh 触点的标识 ID,可以用来在多点触摸中跟踪触点。 + */ + getID(): number; + /** + !#en Returns the delta distance from the previous location to current location. + !#zh 获取触点距离上一次事件移动的距离对象,对象包含 x 和 y 属性。 + */ + getDelta(): Vec2; + /** + !#en Returns the X axis delta distance from the previous location to current location. + !#zh 获取触点距离上一次事件移动的 x 轴距离。 + */ + getDeltaX(): number; + /** + !#en Returns the Y axis delta distance from the previous location to current location. + !#zh 获取触点距离上一次事件移动的 y 轴距离。 + */ + getDeltaY(): number; + /** + !#en Returns location X axis data. + !#zh 获取当前触点 X 轴位置。 + */ + getLocationX(): number; + /** + !#en Returns location Y axis data. + !#zh 获取当前触点 Y 轴位置。 + */ + getLocationY(): number; + } + } + + /**************************************************** + * Event + *****************************************************/ + + export namespace Event { + /** !#en The acceleration event + !#zh 加速度事件 */ + export class EventAcceleration extends Event { + } + } + + /**************************************************** + * Event + *****************************************************/ + + export namespace Event { + /** !#en The keyboard event + !#zh 键盘事件 */ + export class EventKeyboard extends Event { + /** !#en + The keyCode read-only property represents a system and implementation dependent numerical code identifying the unmodified value of the pressed key. + This is usually the decimal ASCII (RFC 20) or Windows 1252 code corresponding to the key. + If the key can't be identified, this value is 0. + + !#zh + keyCode 是只读属性它表示一个系统和依赖于实现的数字代码,可以识别按键的未修改值。 + 这通常是十进制 ASCII (RFC20) 或者 Windows 1252 代码,所对应的密钥。 + 如果无法识别该键,则该值为 0。 */ + keyCode: number; + } + } + + /**************************************************** + * Event + *****************************************************/ + + export namespace Event { + /** !#en The Custom event + !#zh 自定义事件 */ + export class EventCustom extends Event { + /** + + @param type The name of the event (case-sensitive), e.g. "click", "fire", or "submit" + @param bubbles A boolean indicating whether the event bubbles up through the tree or not + */ + constructor(type: string, bubbles: boolean); + /** !#en A reference to the detailed data of the event + !#zh 事件的详细数据 */ + detail: any; + /** + !#en Sets user data + !#zh 设置用户数据 + @param data data + */ + setUserData(data: any): void; + /** + !#en Gets user data + !#zh 获取用户数据 + */ + getUserData(): any; + /** + !#en Gets event name + !#zh 获取事件名称 + */ + getEventName(): string; + } + } + + /**************************************************** + * SystemEvent + *****************************************************/ + + export namespace SystemEvent { + /** !#en The event type supported by SystemEvent + !#zh SystemEvent 支持的事件类型 */ + export class EventType { + /** !#en The event type for press the key down event, you can use its value directly: 'keydown' + !#zh 当按下按键时触发的事件 */ + static KEY_DOWN: string; + /** !#en The event type for press the key up event, you can use its value directly: 'keyup' + !#zh 当松开按键时触发的事件 */ + static KEY_UP: string; + /** !#en The event type for press the devicemotion event, you can use its value directly: 'devicemotion' + !#zh 重力感应 */ + static DEVICEMOTION: string; + } + } + + /**************************************************** + * geomUtils + *****************************************************/ + + export namespace geomUtils { + /** Aabb */ + export class Aabb { + /** + create a new aabb + @param px X coordinates for aabb's original point + @param py Y coordinates for aabb's original point + @param pz Z coordinates for aabb's original point + @param w the half of aabb width + @param h the half of aabb height + @param l the half of aabb length + */ + create(px: number, py: number, pz: number, w: number, h: number, l: number): Aabb; + /** + clone a new aabb + @param a the source aabb + */ + clone(a: Aabb): Aabb; + /** + copy the values from one aabb to another + @param out the receiving aabb + @param a the source aabb + */ + copy(out: Aabb, a: Aabb): Aabb; + /** + create a new aabb from two corner points + @param out the receiving aabb + @param minPos lower corner position of the aabb + @param maxPos upper corner position of the aabb + */ + fromPoints(out: Aabb, minPos: Vec3, maxPos: Vec3): Aabb; + /** + Set the components of a aabb to the given values + @param out the receiving aabb + @param px X coordinates for aabb's original point + @param py Y coordinates for aabb's original point + @param pz Z coordinates for aabb's original point + @param w the half of aabb width + @param h the half of aabb height + @param l the half of aabb length + */ + set(out: Aabb, px: number, py: number, pz: number, w: number, h: number, l: number): Aabb; + center: Vec3; + halfExtents: Vec3; + _type: number; + /** + Get the bounding points of this shape + @param minPos minPos + @param maxPos maxPos + */ + getBoundary(minPos: Vec3, maxPos: Vec3): void; + /** + Transform this shape + @param m the transform matrix + @param pos the position part of the transform + @param rot the rotation part of the transform + @param scale the scale part of the transform + @param out the target shape + */ + transform(m: Mat4, pos: Vec3, rot: Quat, scale: Vec3, out?: Aabb): void; + } + } + + /**************************************************** + * geomUtils + *****************************************************/ + + export namespace geomUtils { + /** !#en Shape type. */ + export enum enums { + SHAPE_RAY = 0, + SHAPE_LINE = 0, + SHAPE_SPHERE = 0, + SHAPE_AABB = 0, + SHAPE_OBB = 0, + SHAPE_PLANE = 0, + SHAPE_TRIANGLE = 0, + SHAPE_FRUSTUM = 0, + SHAPE_FRUSTUM_ACCURATE = 0, + } + } + + /**************************************************** + * geomUtils + *****************************************************/ + + export namespace geomUtils { + /** !#en frustum + !#zh 平截头体 */ + export class Frustum { + /** Set whether to use accurate intersection testing function on this frustum */ + accurate: boolean; + /** + create a new frustum + */ + static create(): Frustum; + /** + Clone a frustum + @param f f + */ + static clone(f: Frustum): Frustum; + /** + Copy the values from one frustum to another + @param out out + @param f f + */ + copy(out: Frustum, f: Frustum): Frustum; + planes: geomUtils.Plane[]; + planes: Vec3[]; + /** + !#en Update the frustum information according to the given transform matrix. + Note that the resulting planes are not normalized under normal mode. + @param m the view-projection matrix + @param inv the inverse view-projection matrix + */ + update(m: Mat4, inv: Mat4): void; + /** + !#en transform by matrix + @param mat mat + */ + transform(mat: Mat4): void; + } + } + + /**************************************************** + * geomUtils + *****************************************************/ + + export namespace geomUtils { + /** undefined */ + export class intersect { + /** + !#en + Check whether ray intersect with nodes + !#zh + 检测射线是否与物体有交集 + @param root If root is null, then traversal nodes from scene node + @param worldRay worldRay + @param handler handler + @param filter filter + */ + static ray_cast(root: Node, worldRay: geomUtils.Ray, handler: Function, filter: Function): any[]; + /** + !#en ray-plane intersect
+ !#zh 射线与平面的相交性检测。 + @param ray ray + @param plane plane + */ + static ray_plane(ray: geomUtils.Ray, plane: geomUtils.Plane): number; + /** + !#en line-plane intersect
+ !#zh 线段与平面的相交性检测。 + @param line line + @param plane plane + */ + static line_plane(line: geomUtils.Line, plane: geomUtils.Plane): number; + /** + !#en ray-triangle intersect
+ !#zh 射线与三角形的相交性检测。 + @param ray ray + @param triangle triangle + @param doubleSided doubleSided + */ + static ray_triangle(ray: geomUtils.Ray, triangle: geomUtils.Triangle, doubleSided: boolean): number; + /** + !#en line-triangle intersect
+ !#zh 线段与三角形的相交性检测。 + @param line line + @param triangle triangle + @param outPt optional, The intersection point + */ + static line_triangle(line: geomUtils.Line, triangle: geomUtils.Triangle, outPt: Vec3): number; + /** + !#en line-quad intersect
+ !#zh 线段与四边形的相交性检测。 + @param p A point on a line segment + @param q Another point on the line segment + @param a Quadrilateral point a + @param b Quadrilateral point b + @param c Quadrilateral point c + @param d Quadrilateral point d + @param outPt optional, The intersection point + */ + static line_quad(p: Vec3, q: Vec3, a: Vec3, b: Vec3, c: Vec3, d: Vec3, outPt: Vec3): number; + /** + !#en ray-sphere intersect
+ !#zh 射线和球的相交性检测。 + @param ray ray + @param sphere sphere + */ + static ray_sphere(ray: geomUtils.Ray, sphere: geomUtils.Sphere): number; + /** + !#en ray-aabb intersect
+ !#zh 射线和轴对齐包围盒的相交性检测。 + @param ray ray + @param aabb Align the axis around the box + */ + static ray_aabb(ray: geomUtils.Ray, aabb: Aabb): number; + /** + !#en ray-obb intersect
+ !#zh 射线和方向包围盒的相交性检测。 + @param ray ray + @param obb Direction box + */ + static ray_obb(ray: geomUtils.Ray, obb: geomUtils.Obb): number; + /** + !#en aabb-aabb intersect
+ !#zh 轴对齐包围盒和轴对齐包围盒的相交性检测。 + @param aabb1 Axis alignment surrounds box 1 + @param aabb2 Axis alignment surrounds box 2 + */ + static aabb_aabb(aabb1: Aabb, aabb2: Aabb): number; + /** + !#en aabb-obb intersect
+ !#zh 轴对齐包围盒和方向包围盒的相交性检测。 + @param aabb Align the axis around the box + @param obb Direction box + */ + static aabb_obb(aabb: Aabb, obb: geomUtils.Obb): number; + /** + !#en aabb-plane intersect
+ !#zh 轴对齐包围盒和平面的相交性检测。 + @param aabb Align the axis around the box + @param plane plane + */ + static aabb_plane(aabb: Aabb, plane: geomUtils.Plane): number; + /** + !#en aabb-frustum intersect, faster but has false positive corner cases
+ !#zh 轴对齐包围盒和锥台相交性检测,速度快,但有错误情况。 + @param aabb Align the axis around the box + @param frustum frustum + */ + static aabb_frustum(aabb: Aabb, frustum: Frustum): number; + /** + !#en aabb-frustum intersect, handles most of the false positives correctly
+ !#zh 轴对齐包围盒和锥台相交性检测,正确处理大多数错误情况。 + @param aabb Align the axis around the box + @param frustum frustum + */ + static aabb_frustum_accurate(aabb: Aabb, frustum: Frustum): number; + /** + !#en obb-point intersect
+ !#zh 方向包围盒和点的相交性检测。 + @param obb Direction box + @param point point + */ + static obb_point(obb: geomUtils.Obb, point: geomUtils.Vec3): boolean; + /** + !#en obb-plane intersect
+ !#zh 方向包围盒和平面的相交性检测。 + @param obb Direction box + @param plane plane + */ + static obb_plane(obb: geomUtils.Obb, plane: geomUtils.Plane): number; + /** + !#en obb-frustum intersect, faster but has false positive corner cases
+ !#zh 方向包围盒和锥台相交性检测,速度快,但有错误情况。 + @param obb Direction box + @param frustum frustum + */ + static obb_frustum(obb: geomUtils.Obb, frustum: Frustum): number; + /** + !#en obb-frustum intersect, handles most of the false positives correctly
+ !#zh 方向包围盒和锥台相交性检测,正确处理大多数错误情况。 + @param obb Direction box + @param frustum frustum + */ + static obb_frustum_accurate(obb: geomUtils.Obb, frustum: Frustum): number; + /** + !#en obb-obb intersect
+ !#zh 方向包围盒和方向包围盒的相交性检测。 + @param obb1 Direction box1 + @param obb2 Direction box2 + */ + static obb_obb(obb1: geomUtils.Obb, obb2: geomUtils.Obb): number; + /** + !#en phere-plane intersect, not necessarily faster than obb-plane
+ due to the length calculation of the plane normal to factor out
+ the unnomalized plane distance
+ !#zh 球与平面的相交性检测。 + @param sphere sphere + @param plane plane + */ + static sphere_plane(sphere: geomUtils.Sphere, plane: geomUtils.Plane): number; + /** + !#en sphere-frustum intersect, faster but has false positive corner cases
+ !#zh 球和锥台的相交性检测,速度快,但有错误情况。 + @param sphere sphere + @param frustum frustum + */ + static sphere_frustum(sphere: geomUtils.Sphere, frustum: Frustum): number; + /** + !#en sphere-frustum intersect, handles the false positives correctly
+ !#zh 球和锥台的相交性检测,正确处理大多数错误情况。 + @param sphere sphere + @param frustum frustum + */ + static sphere_frustum_accurate(sphere: geomUtils.Sphere, frustum: Frustum): number; + /** + !#en sphere-sphere intersect
+ !#zh 球和球的相交性检测。 + @param sphere0 sphere0 + @param sphere1 sphere1 + */ + static sphere_sphere(sphere0: geomUtils.Sphere, sphere1: geomUtils.Sphere): boolean; + /** + !#en sphere-aabb intersect
+ !#zh 球和轴对齐包围盒的相交性检测。 + @param sphere sphere + @param aabb aabb + */ + static sphere_aabb(sphere: geomUtils.Sphere, aabb: Aabb): boolean; + /** + !#en sphere-obb intersect
+ !#zh 球和方向包围盒的相交性检测。 + @param sphere sphere + @param obb obb + */ + static sphere_obb(sphere: geomUtils.Sphere, obb: geomUtils.Obb): boolean; + /** + !#en + The intersection detection of g1 and g2 can fill in the shape in the basic geometry. + !#zh + g1 和 g2 的相交性检测,可填入基础几何中的形状。 + @param g1 Geometry 1 + @param g2 Geometry 2 + @param outPt optional, Intersection point. (note: only partial shape detection with this return value) + */ + static resolve(g1: any, g2: any, outPt: any): void; + } + } + + /**************************************************** + * geomUtils + *****************************************************/ + + export namespace geomUtils { + /** !#en + line + !#zh + 直线 */ + export class Line { + /** + !#en + create a new line + !#zh + 创建一个新的 line。 + @param sx The x part of the starting point. + @param sy The y part of the starting point. + @param sz The z part of the starting point. + @param ex The x part of the end point. + @param ey The y part of the end point. + @param ez The z part of the end point. + */ + create(sx: number, sy: number, sz: number, ex: number, ey: number, ez: number): Line; + /** + !#en + Creates a new line initialized with values from an existing line + !#zh + 克隆一个新的 line。 + @param a The source of cloning. + */ + clone(a: Line): Line; + /** + !#en + Copy the values from one line to another + !#zh + 复制一个线的值到另一个。 + @param out The object that accepts the action. + @param a The source of the copy. + */ + copy(out: Line, a: Line): Line; + /** + !#en + create a line from two points + !#zh + 用两个点创建一个线。 + @param out The object that accepts the action. + @param start The starting point. + @param end At the end. + */ + fromPoints(out: Line, start: Vec3, end: Vec3): Line; + /** + !#en + Set the components of a Vec3 to the given values + !#zh + 将给定线的属性设置为给定值。 + @param out The object that accepts the action. + @param sx The x part of the starting point. + @param sy The y part of the starting point. + @param sz The z part of the starting point. + @param ex The x part of the end point. + @param ey The y part of the end point. + @param ez The z part of the end point. + */ + set(out: Line, sx: number, sy: number, sz: number, ex: number, ey: number, ez: number): Line; + /** + !#en + Calculate the length of the line. + !#zh + 计算线的长度。 + @param a The line to calculate. + */ + len(a: Line): number; + /** !#en + Start points. + !#zh + 起点。 */ + s: Vec3; + /** !#en + End points. + !#zh + 终点。 */ + e: Vec3; + /** + !#en + Calculate the length of the line. + !#zh + 计算线的长度。 + */ + length(): number; + } + } + + /**************************************************** + * geomUtils + *****************************************************/ + + export namespace geomUtils { + /** !#en obb + !#zh + 基础几何 方向包围盒。 */ + export class Obb { + /** !#zh + 获取形状的类型。 */ + type: number; + /** + !#en + create a new obb + !#zh + 创建一个新的 obb 实例。 + @param cx X coordinates of the shape relative to the origin. + @param cy Y coordinates of the shape relative to the origin. + @param cz Z coordinates of the shape relative to the origin. + @param hw Obb is half the width. + @param hh Obb is half the height. + @param hl Obb is half the Length. + @param ox_1 Direction matrix parameter. + @param ox_2 Direction matrix parameter. + @param ox_3 Direction matrix parameter. + @param oy_1 Direction matrix parameter. + @param oy_2 Direction matrix parameter. + @param oy_3 Direction matrix parameter. + @param oz_1 Direction matrix parameter. + @param oz_2 Direction matrix parameter. + @param oz_3 Direction matrix parameter. + */ + create(cx: number, cy: number, cz: number, hw: number, hh: number, hl: number, ox_1: number, ox_2: number, ox_3: number, oy_1: number, oy_2: number, oy_3: number, oz_1: number, oz_2: number, oz_3: number): Obb; + /** + !#en + clone a new obb + !#zh + 克隆一个 obb。 + @param a The target of cloning. + */ + clone(a: Obb): Obb; + /** + !#en + copy the values from one obb to another + !#zh + 将从一个 obb 的值复制到另一个 obb。 + @param out Obb that accepts the operation. + @param a Obb being copied. + */ + copy(out: Obb, a: Obb): Obb; + /** + !#en + create a new obb from two corner points + !#zh + 用两个点创建一个新的 obb。 + @param out Obb that accepts the operation. + @param minPos The smallest point of obb. + @param maxPos Obb's maximum point. + */ + fromPoints(out: Obb, minPos: Vec3, maxPos: Vec3): Obb; + /** + !#en + Set the components of a obb to the given values + !#zh + 将给定 obb 的属性设置为给定的值。 + @param cx X coordinates of the shape relative to the origin. + @param cy Y coordinates of the shape relative to the origin. + @param cz Z coordinates of the shape relative to the origin. + @param hw Obb is half the width. + @param hh Obb is half the height. + @param hl Obb is half the Length. + @param ox_1 Direction matrix parameter. + @param ox_2 Direction matrix parameter. + @param ox_3 Direction matrix parameter. + @param oy_1 Direction matrix parameter. + @param oy_2 Direction matrix parameter. + @param oy_3 Direction matrix parameter. + @param oz_1 Direction matrix parameter. + @param oz_2 Direction matrix parameter. + @param oz_3 Direction matrix parameter. + */ + set(cx: number, cy: number, cz: number, hw: number, hh: number, hl: number, ox_1: number, ox_2: number, ox_3: number, oy_1: number, oy_2: number, oy_3: number, oz_1: number, oz_2: number, oz_3: number): Obb; + /** !#en + The center of the local coordinate. + !#zh + 本地坐标的中心点。 */ + center: Vec3; + /** !#en + Half the length, width, and height. + !#zh + 长宽高的一半。 */ + halfExtents: Vec3; + /** !#en + Direction matrix. + !#zh + 方向矩阵。 */ + orientation: Mat3; + /** + !#en + Get the bounding points of this shape + !#zh + 获取 obb 的最小点和最大点。 + @param minPos minPos + @param maxPos maxPos + */ + getBoundary(minPos: Vec3, maxPos: Vec3): void; + /** + !#en Transform this shape + !#zh + 将 out 根据这个 obb 的数据进行变换。 + @param m The transformation matrix. + @param pos The position part of the transformation. + @param rot The rotating part of the transformation. + @param scale The scaling part of the transformation. + @param out Target of transformation. + */ + transform(m: Mat4, pos: Vec3, rot: Quat, scale: Vec3, out: Obb): void; + /** + !#en + Transform out based on this obb data. + !#zh + 将 out 根据这个 obb 的数据进行变换。 + @param m The transformation matrix. + @param rot The rotating part of the transformation. + @param out Target of transformation. + */ + translateAndRotate(m: Mat4, rot: Quat, out: Obb): void; + /** + !#en + Scale out based on this obb data. + !#zh + 将 out 根据这个 obb 的数据进行缩放。 + @param scale Scale value. + @param out Scaled target. + */ + setScale(scale: Vec3, out: Obb): void; + } + } + + /**************************************************** + * geomUtils + *****************************************************/ + + export namespace geomUtils { + /** !#en + plane。 + !#zh + 平面。 */ + export class Plane { + /** + !#en + create a new plane + !#zh + 创建一个新的 plane。 + @param nx The x part of the normal component. + @param ny The y part of the normal component. + @param nz The z part of the normal component. + @param d Distance from the origin. + */ + create(nx: number, ny: number, nz: number, d: number): Plane; + /** + !#en + clone a new plane + !#zh + 克隆一个新的 plane。 + @param p The source of cloning. + */ + clone(p: Plane): Plane; + /** + !#en + copy the values from one plane to another + !#zh + 复制一个平面的值到另一个。 + @param out The object that accepts the action. + @param p The source of the copy. + */ + copy(out: Plane, p: Plane): Plane; + /** + !#en + create a plane from three points + !#zh + 用三个点创建一个平面。 + @param out The object that accepts the action. + @param a Point a。 + @param b Point b。 + @param c Point c。 + */ + fromPoints(out: Plane, a: Vec3, b: Vec3, c: Vec3): Plane; + /** + !#en + Set the components of a plane to the given values + !#zh + 将给定平面的属性设置为给定值。 + @param out The object that accepts the action. + @param nx The x part of the normal component. + @param ny The y part of the normal component. + @param nz The z part of the normal component. + @param d Distance from the origin. + */ + set(out: Plane, nx: number, ny: number, nz: number, d: number): Plane; + /** + !#en + create plane from normal and point + !#zh + 用一条法线和一个点创建平面。 + @param out The object that accepts the action. + @param normal The normal of a plane. + @param point A point on the plane. + */ + fromNormalAndPoint(out: Plane, normal: Vec3, point: Vec3): Plane; + /** + !#en + normalize a plane + !#zh + 归一化一个平面。 + @param out The object that accepts the action. + @param a Source data for operations. + */ + normalize(out: Plane, a: Plane): Plane; + /** !#en + A normal vector. + !#zh + 法线向量。 */ + n: Vec3; + /** !#en + The distance from the origin to the plane. + !#zh + 原点到平面的距离。 */ + d: number; + /** + !#en + Transform a plane. + !#zh + 变换一个平面。 + @param mat mat + */ + transform(mat: Mat4): void; + } + } + + /**************************************************** + * geomUtils + *****************************************************/ + + export namespace geomUtils { + /** !#en + ray + !#zh + 射线。 */ + export class Ray { + /** + !#en + create a new ray + !#zh + 创建一条射线。 + @param ox The x part of the starting point. + @param oy The y part of the starting point. + @param oz The z part of the starting point. + @param dx X in the direction. + @param dy Y in the direction. + @param dz Z in the direction. + */ + create(ox: number, oy: number, oz: number, dx: number, dy: number, dz: number): Ray; + /** + !#en + Creates a new ray initialized with values from an existing ray + !#zh + 从一条射线克隆出一条新的射线。 + @param a Clone target + */ + clone(a: Ray): Ray; + /** + !#en + Copy the values from one ray to another + !#zh + 将从一个 ray 的值复制到另一个 ray。 + @param out Accept the ray of the operation. + @param a Copied ray. + */ + copy(out: Ray, a: Ray): Ray; + /** + !#en + create a ray from two points + !#zh + 用两个点创建一条射线。 + @param out Receive the operating ray. + @param origin Origin of ray + @param target A point on a ray. + */ + fromPoints(out: Ray, origin: Vec3, target: Vec3): Ray; + /** + !#en + Set the components of a ray to the given values + !#zh + 将给定射线的属性设置为给定的值。 + @param out Receive the operating ray. + @param ox The x part of the starting point. + @param oy The y part of the starting point. + @param oz The z part of the starting point. + @param dx X in the direction. + @param dy Y in the direction. + @param dz Z in the direction. + */ + set(out: Ray, ox: number, oy: number, oz: number, dx: number, dy: number, dz: number): Ray; + /** !#en + Start point. + !#zh + 起点。 */ + o: Vec3; + /** !#e + Direction + !#zh + 方向。 */ + d: Vec3; + /** + !#en Compute hit. + @param out out + @param distance distance + */ + computeHit(out: IVec3Like, distance: number): void; + } + } + + /**************************************************** + * geomUtils + *****************************************************/ + + export namespace geomUtils { + /** !#en + Sphere. + !#zh + 轴对齐球。 */ + export class Sphere { + /** + !#en + create a new sphere + !#zh + 创建一个新的 sphere 实例。 + @param cx X coordinates of the shape relative to the origin. + @param cy Y coordinates of the shape relative to the origin. + @param cz Z coordinates of the shape relative to the origin. + @param r Radius of sphere + */ + create(cx: any, cy: any, cz: any, r: any): Sphere; + /** + !#en + clone a new sphere + !#zh + 克隆一个新的 sphere 实例。 + @param p The target of cloning. + */ + clone(p: Sphere): Sphere; + /** + !#en + copy the values from one sphere to another + !#zh + 将从一个 sphere 的值复制到另一个 sphere。 + @param out Accept the sphere of operations. + @param a Sphere being copied. + */ + copy(out: Sphere, a: Sphere): Sphere; + /** + !#en + create a new bounding sphere from two corner points + !#zh + 从两个点创建一个新的 sphere。 + @param out Accept the sphere of operations. + @param minPos The smallest point of sphere. + @param maxPos The maximum point of sphere. + */ + fromPoints(out: any, minPos: any, maxPos: any): Sphere; + /** + !#en Set the components of a sphere to the given values + !#zh 将球体的属性设置为给定的值。 + @param out Accept the sphere of operations. + @param cx X coordinates of the shape relative to the origin. + @param cy Y coordinates of the shape relative to the origin. + @param cz Z coordinates of the shape relative to the origin. + @param r Radius. + */ + set(out: Sphere, cx: any, cy: any, cz: any, r: number): Sphere; + /** !#en + The center of the local coordinate. + !#zh + 本地坐标的中心点。 */ + center: Vec3; + /** !#zh + 半径。 */ + radius: number; + /** + !#en + Clone. + !#zh + 获得克隆。 + */ + clone(): void; + /** + !#en + Copy sphere + !#zh + 拷贝对象。 + @param a Copy target. + */ + copy(a: any): void; + /** + !#en + Get the bounding points of this shape + !#zh + 获取此形状的边界点。 + @param minPos minPos + @param maxPos maxPos + */ + getBoundary(minPos: Vec3, maxPos: Vec3): void; + /** + !#en + Transform this shape + !#zh + 将 out 根据这个 sphere 的数据进行变换。 + @param m The transformation matrix. + @param pos The position part of the transformation. + @param rot The rotating part of the transformation. + @param scale The scaling part of the transformation. + @param out The target of the transformation. + */ + transform(m: any, pos: any, rot: any, scale: any, out: any): void; + /** + !#en + Scale out based on the sphere data. + !#zh + 将 out 根据这个 sphere 的数据进行缩放。 + @param scale Scale value + @param out Scale target + */ + setScale(scale: any, out: any): void; + } + } + + /**************************************************** + * geomUtils + *****************************************************/ + + export namespace geomUtils { + /** Triangle */ + export class Triangle { + /** + create a new triangle + @param ax ax + @param ay ay + @param az az + @param bx bx + @param by by + @param bz bz + @param cx cx + @param cy cy + @param cz cz + */ + create(ax: number, ay: number, az: number, bx: number, by: number, bz: number, cx: number, cy: number, cz: number): Triangle; + /** + clone a new triangle + @param t the source plane + */ + clone(t: Triangle): Triangle; + /** + copy the values from one triangle to another + @param out the receiving triangle + @param t the source triangle + */ + copy(out: Triangle, t: Triangle): Triangle; + /** + Create a triangle from three points + @param out the receiving triangle + @param a a + @param b b + @param c c + */ + fromPoints(out: Triangle, a: Vec3, b: Vec3, c: Vec3): Triangle; + /** + Set the components of a triangle to the given values + @param out the receiving plane + @param ax X component of a + @param ay Y component of a + @param az Z component of a + @param bx X component of b + @param by Y component of b + @param bz Z component of b + @param cx X component of c + @param cy Y component of c + @param cz Z component of c + */ + set(out: Triangle, ax: number, ay: number, az: number, bx: number, by: number, bz: number, cx: number, cy: number, cz: number): Plane; + a: Vec3; + b: Vec3; + c: Vec3; + } + } + + /**************************************************** + * Graphics + *****************************************************/ + + export namespace Graphics { + /** !#en Enum for LineCap. + !#zh 线段末端属性 */ + export enum LineCap { + BUTT = 0, + ROUND = 0, + SQUARE = 0, + } + } + + /**************************************************** + * Graphics + *****************************************************/ + + export namespace Graphics { + /** !#en Enum for LineJoin. + !#zh 线段拐角属性 */ + export enum LineJoin { + BEVEL = 0, + ROUND = 0, + MITER = 0, + } + } + + /**************************************************** + * PhysicsManager + *****************************************************/ + + export namespace PhysicsManager { + /** !#en + The draw bits for drawing physics debug information.
+ example:
+ ```js + cc.director.getPhysicsManager().debugDrawFlags = + // cc.PhysicsManager.DrawBits.e_aabbBit | + // cc.PhysicsManager.DrawBits.e_pairBit | + // cc.PhysicsManager.DrawBits.e_centerOfMassBit | + cc.PhysicsManager.DrawBits.e_jointBit | + cc.PhysicsManager.DrawBits.e_shapeBit; + ``` + !#zh + 指定物理系统需要绘制哪些调试信息。
+ example:
+ ```js + cc.director.getPhysicsManager().debugDrawFlags = + // cc.PhysicsManager.DrawBits.e_aabbBit | + // cc.PhysicsManager.DrawBits.e_pairBit | + // cc.PhysicsManager.DrawBits.e_centerOfMassBit | + cc.PhysicsManager.DrawBits.e_jointBit | + cc.PhysicsManager.DrawBits.e_shapeBit; + ``` */ + export enum DrawBits { + e_aabbBit = 0, + e_jointBit = 0, + e_shapeBit = 0, + } + } + + /**************************************************** + * macro + *****************************************************/ + + export namespace macro { + /** !#en Key map for keyboard event + !#zh 键盘事件的按键值 */ + export enum KEY { + none = 0, + back = 0, + menu = 0, + backspace = 0, + tab = 0, + enter = 0, + shift = 0, + ctrl = 0, + alt = 0, + pause = 0, + capslock = 0, + escape = 0, + space = 0, + pageup = 0, + pagedown = 0, + end = 0, + home = 0, + left = 0, + up = 0, + right = 0, + down = 0, + select = 0, + insert = 0, + Delete = 0, + a = 0, + b = 0, + c = 0, + d = 0, + e = 0, + f = 0, + g = 0, + h = 0, + i = 0, + j = 0, + k = 0, + l = 0, + m = 0, + n = 0, + o = 0, + p = 0, + q = 0, + r = 0, + s = 0, + t = 0, + u = 0, + v = 0, + w = 0, + x = 0, + y = 0, + z = 0, + num0 = 0, + num1 = 0, + num2 = 0, + num3 = 0, + num4 = 0, + num5 = 0, + num6 = 0, + num7 = 0, + num8 = 0, + num9 = 0, + '*' = 0, + '+' = 0, + '-' = 0, + numdel = 0, + '/' = 0, + f1 = 0, + f2 = 0, + f3 = 0, + f4 = 0, + f5 = 0, + f6 = 0, + f7 = 0, + f8 = 0, + f9 = 0, + f10 = 0, + f11 = 0, + f12 = 0, + numlock = 0, + scrolllock = 0, + ';' = 0, + semicolon = 0, + equal = 0, + '=' = 0, + ',' = 0, + comma = 0, + dash = 0, + '.' = 0, + period = 0, + forwardslash = 0, + grave = 0, + '[' = 0, + openbracket = 0, + backslash = 0, + ']' = 0, + closebracket = 0, + quote = 0, + dpadLeft = 0, + dpadRight = 0, + dpadUp = 0, + dpadDown = 0, + dpadCenter = 0, + } + } + + /**************************************************** + * macro + *****************************************************/ + + export namespace macro { + /** Image formats */ + export enum ImageFormat { + JPG = 0, + PNG = 0, + TIFF = 0, + WEBP = 0, + PVR = 0, + ETC = 0, + S3TC = 0, + ATITC = 0, + TGA = 0, + RAWDATA = 0, + UNKNOWN = 0, + } + } + + /**************************************************** + * macro + *****************************************************/ + + export namespace macro { + /** !#en + Enum for blend factor + Refer to: http://www.andersriggelsen.dk/glblendfunc.php + !#zh + 混合因子 + 可参考: http://www.andersriggelsen.dk/glblendfunc.php */ + export enum BlendFactor { + ONE = 0, + ZERO = 0, + SRC_ALPHA = 0, + SRC_COLOR = 0, + DST_ALPHA = 0, + DST_COLOR = 0, + ONE_MINUS_SRC_ALPHA = 0, + ONE_MINUS_SRC_COLOR = 0, + ONE_MINUS_DST_ALPHA = 0, + ONE_MINUS_DST_COLOR = 0, + } + } + + /**************************************************** + * macro + *****************************************************/ + + export namespace macro { + /** undefined */ + export enum TextAlignment { + LEFT = 0, + CENTER = 0, + RIGHT = 0, + } + } + + /**************************************************** + * sys + *****************************************************/ + + export namespace sys { + /** !#en + Network type enumeration + !#zh + 网络类型枚举 */ + export enum NetworkType { + NONE = 0, + LAN = 0, + WWAN = 0, + } + } + + /**************************************************** + * MeshRenderer + *****************************************************/ + + export namespace MeshRenderer { + /** !#en Shadow projection mode + + !#ch 阴影投射方式 */ + export enum ShadowCastingMode { + OFF = 0, + ON = 0, + } + } + + /**************************************************** + * ParticleSystem3DAssembler + *****************************************************/ + + export namespace ParticleSystem3DAssembler { + /** undefined */ + export enum Space { + } + } + + /**************************************************** + * ParticleSystem3DAssembler + *****************************************************/ + + export namespace ParticleSystem3DAssembler { + /** 粒子的生成模式 */ + export enum RenderMode { + } + } + + /**************************************************** + * shapeModule + *****************************************************/ + + export namespace shapeModule { + /** 粒子发射器类型 */ + export enum ShapeType { + Box = 0, + Circle = 0, + Cone = 0, + Sphere = 0, + Hemisphere = 0, + } + } + + /**************************************************** + * shapeModule + *****************************************************/ + + export namespace shapeModule { + /** 粒子从发射器的哪个部位发射 */ + export enum EmitLocation { + Base = 0, + Edge = 0, + Shell = 0, + Volume = 0, + } + } + + /**************************************************** + * shapeModule + *****************************************************/ + + export namespace shapeModule { + /** 粒子在扇形区域的发射方式 */ + export enum ArcMode { + Random = 0, + Loop = 0, + PingPong = 0, + } + } + + /**************************************************** + * trailModule + *****************************************************/ + + export namespace trailModule { + /** 选择如何为粒子系统生成轨迹 */ + export enum TrailMode { + } + } + + /**************************************************** + * trailModule + *****************************************************/ + + export namespace trailModule { + /** 纹理填充模式 */ + export enum TextureMode { + } + } + + /**************************************************** + * primitive + *****************************************************/ + + export namespace primitive { + /** undefined */ + export enum PolyhedronType { + Tetrahedron = 0, + Octahedron = 0, + Dodecahedron = 0, + Icosahedron = 0, + Rhombicuboctahedron = 0, + TriangularPrism = 0, + PentagonalPrism = 0, + HexagonalPrism = 0, + SquarePyramid = 0, + PentagonalPyramid = 0, + TriangularDipyramid = 0, + PentagonalDipyramid = 0, + ElongatedSquareDipyramid = 0, + ElongatedPentagonalDipyramid = 0, + ElongatedPentagonalCupola = 0, + } + } + + /**************************************************** + * primitive + *****************************************************/ + + export namespace primitive { + /** undefined */ + export class VertexData { + positions: number[]; + normals: number[]; + uvs: number[]; + indices: number[]; + minPos: Vec3; + maxPos: Vec3; + boundingRadius: number; + } + } + + /**************************************************** + * Material + *****************************************************/ + + export namespace Material { + /** !#en Material builtin name + !#zh 内置材质名字 */ + export enum BUILTIN_NAME { + SPRITE = 0, + GRAY_SPRITE = 0, + UNLIT = 0, + } + } + + /**************************************************** + * EditBox + *****************************************************/ + + export namespace EditBox { + /** !#en Enum for keyboard return types + !#zh 键盘的返回键类型 */ + export enum KeyboardReturnType { + DEFAULT = 0, + DONE = 0, + SEND = 0, + SEARCH = 0, + GO = 0, + NEXT = 0, + } + } + + /**************************************************** + * EditBox + *****************************************************/ + + export namespace EditBox { + /** !#en The EditBox's InputMode defines the type of text that the user is allowed to enter. + !#zh 输入模式 */ + export enum InputMode { + ANY = 0, + EMAIL_ADDR = 0, + NUMERIC = 0, + PHONE_NUMBER = 0, + URL = 0, + DECIMAL = 0, + SINGLE_LINE = 0, + } + } + + /**************************************************** + * EditBox + *****************************************************/ + + export namespace EditBox { + /** !#en Enum for the EditBox's input flags + !#zh 定义了一些用于设置文本显示和文本格式化的标志位。 */ + export enum InputFlag { + PASSWORD = 0, + SENSITIVE = 0, + INITIAL_CAPS_WORD = 0, + INITIAL_CAPS_SENTENCE = 0, + INITIAL_CAPS_ALL_CHARACTERS = 0, + DEFAULT = 0, + } + } + + /**************************************************** + * textureAnimationModule + *****************************************************/ + + export namespace textureAnimationModule { + /** 粒子贴图动画类型 */ + export enum Mode { + } + } + + /**************************************************** + * textureAnimationModule + *****************************************************/ + + export namespace textureAnimationModule { + /** 贴图动画的播放方式 */ + export enum Animation { + } + } + +} + +/** !#en +The global main namespace of DragonBones, all classes, functions, +properties and constants of DragonBones are defined in this namespace +!#zh +DragonBones 的全局的命名空间, +与 DragonBones 相关的所有的类,函数,属性,常量都在这个命名空间中定义。 */ +declare namespace dragonBones { + /** !#en + The Armature Display of DragonBones
+
+ (Armature Display has a reference to a DragonBonesAsset and stores the state for ArmatureDisplay instance, + which consists of the current pose's bone SRT, slot colors, and which slot attachments are visible.
+ Multiple Armature Display can use the same DragonBonesAsset which includes all animations, skins, and attachments.)
+ !#zh + DragonBones 骨骼动画
+
+ (Armature Display 具有对骨骼数据的引用并且存储了骨骼实例的状态, + 它由当前的骨骼动作,slot 颜色,和可见的 slot attachments 组成。
+ 多个 Armature Display 可以使用相同的骨骼数据,其中包括所有的动画,皮肤和 attachments。)
*/ + export class ArmatureDisplay extends cc.RenderComponent { + /** !#en + The DragonBones data contains the armatures information (bind pose bones, slots, draw order, + attachments, skins, etc) and animations but does not hold any state.
+ Multiple ArmatureDisplay can share the same DragonBones data. + !#zh + 骨骼数据包含了骨骼信息(绑定骨骼动作,slots,渲染顺序, + attachments,皮肤等等)和动画但不持有任何状态。
+ 多个 ArmatureDisplay 可以共用相同的骨骼数据。 */ + dragonAsset: DragonBonesAsset; + /** !#en + The atlas asset for the DragonBones. + !#zh + 骨骼数据所需的 Atlas Texture 数据。 */ + dragonAtlasAsset: DragonBonesAtlasAsset; + /** !#en The name of current armature. + !#zh 当前的 Armature 名称。 */ + armatureName: string; + /** !#en The name of current playing animation. + !#zh 当前播放的动画名称。 */ + animationName: string; + _defaultArmatureIndex: number; + /** !#en The time scale of this armature. + !#zh 当前骨骼中所有动画的时间缩放率。 */ + timeScale: number; + /** !#en The play times of the default animation. + -1 means using the value of config file; + 0 means repeat for ever + >0 means repeat times + !#zh 播放默认动画的循环次数 + -1 表示使用配置文件中的默认值; + 0 表示无限循环 + >0 表示循环次数 */ + playTimes: number; + /** !#en Indicates whether to enable premultiplied alpha. + You should disable this option when image's transparent area appears to have opaque pixels, + or enable this option when image's half transparent area appears to be darken. + !#zh 是否启用贴图预乘。 + 当图片的透明区域出现色块时需要关闭该选项,当图片的半透明区域颜色变黑时需要启用该选项。 */ + premultipliedAlpha: boolean; + /** !#en Indicates whether open debug bones. + !#zh 是否显示 bone 的 debug 信息。 */ + debugBones: boolean; + /** !#en Enabled batch model, if skeleton is complex, do not enable batch, or will lower performance. + !#zh 开启合批,如果渲染大量相同纹理,且结构简单的骨骼动画,开启合批可以降低drawcall,否则请不要开启,cpu消耗会上升。 */ + enableBatch: boolean; + /** + !#en + The key of dragonbones cache data, which is regard as 'dragonbonesName', when you want to change dragonbones cloth. + !#zh + 缓存龙骨数据的key值,换装的时会使用到该值,作为dragonbonesName使用 + + @example + ```js + let factory = dragonBones.CCFactory.getInstance(); + let needChangeSlot = needChangeArmature.armature().getSlot("changeSlotName"); + factory.replaceSlotDisplay(toChangeArmature.getArmatureKey(), "armatureName", "slotName", "displayName", needChangeSlot); + ``` + */ + getArmatureKey(): string; + /** + !#en + It's best to set cache mode before set property 'dragonAsset', or will waste some cpu time. + If set the mode in editor, then no need to worry about order problem. + !#zh + 若想切换渲染模式,最好在设置'dragonAsset'之前,先设置好渲染模式,否则有运行时开销。 + 若在编辑中设置渲染模式,则无需担心设置次序的问题。 + @param cacheMode cacheMode + + @example + ```js + armatureDisplay.setAnimationCacheMode(dragonBones.ArmatureDisplay.AnimationCacheMode.SHARED_CACHE); + ``` + */ + setAnimationCacheMode(cacheMode: ArmatureDisplay.AnimationCacheMode): void; + /** + !#en Whether in cached mode. + !#zh 当前是否处于缓存模式。 + */ + isAnimationCached(): boolean; + /** + !#en + Play the specified animation. + Parameter animName specify the animation name. + Parameter playTimes specify the repeat times of the animation. + -1 means use the value of the config file. + 0 means play the animation for ever. + >0 means repeat times. + !#zh + 播放指定的动画. + animName 指定播放动画的名称。 + playTimes 指定播放动画的次数。 + -1 为使用配置文件中的次数。 + 0 为无限循环播放。 + >0 为动画的重复次数。 + @param animName animName + @param playTimes playTimes + */ + playAnimation(animName: string, playTimes: number): dragonBones.AnimationState; + /** + !#en + Updating an animation cache to calculate all frame data in the animation is a cost in + performance due to calculating all data in a single frame. + To update the cache, use the invalidAnimationCache method with high performance. + !#zh + 更新某个动画缓存, 预计算动画中所有帧数据,由于在单帧计算所有数据,所以较消耗性能。 + 若想更新缓存,可使用 invalidAnimationCache 方法,具有较高性能。 + @param animName animName + */ + updateAnimationCache(animName: string): void; + /** + !#en + Invalidates the animation cache, which is then recomputed on each frame.. + !#zh + 使动画缓存失效,之后会在每帧重新计算。 + */ + invalidAnimationCache(): void; + /** + !#en + Get the all armature names in the DragonBones Data. + !#zh + 获取 DragonBones 数据中所有的 armature 名称 + */ + getArmatureNames(): any[]; + /** + !#en + Get the all animation names of specified armature. + !#zh + 获取指定的 armature 的所有动画名称。 + @param armatureName armatureName + */ + getAnimationNames(armatureName: string): any[]; + /** + !#en + Add event listener for the DragonBones Event, the same to addEventListener. + !#zh + 添加 DragonBones 事件监听器,与 addEventListener 作用相同。 + @param type A string representing the event type to listen for. + @param listener The callback that will be invoked when the event is dispatched. + @param target The target (this object) to invoke the callback, can be null + */ + on(type: string, listener: (event: cc.Event) => void, target?: any): void; + /** + !#en + Remove the event listener for the DragonBones Event, the same to removeEventListener. + !#zh + 移除 DragonBones 事件监听器,与 removeEventListener 作用相同。 + @param type A string representing the event type to listen for. + @param listener listener + @param target target + */ + off(type: string, listener?: Function, target?: any): void; + /** + !#en + Add DragonBones one-time event listener, the callback will remove itself after the first time it is triggered. + !#zh + 添加 DragonBones 一次性事件监听器,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param listener The callback that will be invoked when the event is dispatched. + @param target The target (this object) to invoke the callback, can be null + */ + once(type: string, listener: (event: cc.Event) => void, target?: any): void; + /** + !#en + Add event listener for the DragonBones Event. + !#zh + 添加 DragonBones 事件监听器。 + @param type A string representing the event type to listen for. + @param listener The callback that will be invoked when the event is dispatched. + @param target The target (this object) to invoke the callback, can be null + */ + addEventListener(type: string, listener: (event: cc.Event) => void, target?: any): void; + /** + !#en + Remove the event listener for the DragonBones Event. + !#zh + 移除 DragonBones 事件监听器。 + @param type A string representing the event type to listen for. + @param listener listener + @param target target + */ + removeEventListener(type: string, listener?: Function, target?: any): void; + /** + !#en + Build the armature for specified name. + !#zh + 构建指定名称的 armature 对象 + @param armatureName armatureName + @param node node + */ + buildArmature(armatureName: string, node: cc.Node): ArmatureDisplay; + /** + !#en + Get the current armature object of the ArmatureDisplay. + !#zh + 获取 ArmatureDisplay 当前使用的 Armature 对象 + */ + armature(): any; + } + /** DragonBones factory */ + export class CCFactory extends BaseFactory { + /** + + + @example + ```js + let factory = dragonBones.CCFactory.getInstance(); + ``` + */ + static getInstance(): CCFactory; + } + /** !#en The skeleton data of dragonBones. + !#zh dragonBones 的 骨骼数据。 */ + export class DragonBonesAsset extends cc.Asset { + /** !#en See http://developer.egret.com/cn/github/egret-docs/DB/dbLibs/dataFormat/index.html + !#zh 可查看 DragonBones 官方文档 http://developer.egret.com/cn/github/egret-docs/DB/dbLibs/dataFormat/index.html */ + dragonBonesJson: string; + } + /** !#en The skeleton atlas data of dragonBones. + !#zh dragonBones 的骨骼纹理数据。 */ + export class DragonBonesAtlasAsset extends cc.Asset { + atlasJson: string; + texture: cc.Texture2D; + } + /**************************************************** + * ArmatureDisplay + *****************************************************/ + + export namespace ArmatureDisplay { + /** !#en Enum for cache mode type. + !#zh Dragonbones渲染类型 */ + export enum AnimationCacheMode { + REALTIME = 0, + SHARED_CACHE = 0, + PRIVATE_CACHE = 0, + } + } + + /**************************************************** + * dragonBones + *****************************************************/ + + export namespace dragonBones { + /** !#en Attach node tool + !#zh 挂点工具类 */ + export class AttachUtil { + /** + !#en Gets attached root node. + !#zh 获取挂接节点树的根节点 + */ + getAttachedRootNode(): cc.Node; + /** + !#en Gets attached node which you want. + !#zh 获得对应的挂点 + @param boneName boneName + */ + getAttachedNodes(boneName: string): cc.Node[]; + /** + !#en Destroy attached node which you want. + !#zh 销毁对应的挂点 + @param boneName boneName + */ + destroyAttachedNodes(boneName: string): void; + /** + !#en Traverse all bones to generate the minimum node tree containing the given bone names, NOTE that make sure the skeleton has initialized before calling this interface. + !#zh 遍历所有插槽,生成包含所有给定插槽名称的最小节点树,注意,调用该接口前请确保骨骼动画已经初始化好。 + @param boneName boneName + */ + generateAttachedNodes(boneName: string): cc.Node[]; + /** + !#en Destroy all attached node. + !#zh 销毁所有挂点 + */ + destroyAllAttachedNodes(): void; + /** + !#en Traverse all bones to generate a tree containing all bones nodes, NOTE that make sure the skeleton has initialized before calling this interface. + !#zh 遍历所有插槽,生成包含所有插槽的节点树,注意,调用该接口前请确保骨骼动画已经初始化好。 + */ + generateAllAttachedNodes(): cc.Node; + } + } + +} + +/** !#en +The global main namespace of Spine, all classes, functions, +properties and constants of Spine are defined in this namespace +!#zh +Spine 的全局的命名空间, +与 Spine 相关的所有的类,函数,属性,常量都在这个命名空间中定义。 */ +declare namespace sp { + /** !#en The event type of spine skeleton animation. + !#zh 骨骼动画事件类型。 */ + export enum AnimationEventType { + START = 0, + END = 0, + COMPLETE = 0, + EVENT = 0, + } + /** !#en + The skeleton of Spine
+
+ (Skeleton has a reference to a SkeletonData and stores the state for skeleton instance, + which consists of the current pose's bone SRT, slot colors, and which slot attachments are visible.
+ Multiple skeletons can use the same SkeletonData which includes all animations, skins, and attachments.)
+ !#zh + Spine 骨骼动画
+
+ (Skeleton 具有对骨骼数据的引用并且存储了骨骼实例的状态, + 它由当前的骨骼动作,slot 颜色,和可见的 slot attachments 组成。
+ 多个 Skeleton 可以使用相同的骨骼数据,其中包括所有的动画,皮肤和 attachments。 */ + export class Skeleton extends cc.RenderComponent { + /** !#en The skeletal animation is paused? + !#zh 该骨骼动画是否暂停。 */ + paused: boolean; + /** !#en + The skeleton data contains the skeleton information (bind pose bones, slots, draw order, + attachments, skins, etc) and animations but does not hold any state.
+ Multiple skeletons can share the same skeleton data. + !#zh + 骨骼数据包含了骨骼信息(绑定骨骼动作,slots,渲染顺序, + attachments,皮肤等等)和动画但不持有任何状态。
+ 多个 Skeleton 可以共用相同的骨骼数据。 */ + skeletonData: SkeletonData; + /** !#en The name of default skin. + !#zh 默认的皮肤名称。 */ + defaultSkin: string; + /** !#en The name of default animation. + !#zh 默认的动画名称。 */ + defaultAnimation: string; + /** !#en The name of current playing animation. + !#zh 当前播放的动画名称。 */ + animation: string; + _defaultSkinIndex: number; + /** !#en TODO + !#zh 是否循环播放当前骨骼动画。 */ + loop: boolean; + /** !#en Indicates whether to enable premultiplied alpha. + You should disable this option when image's transparent area appears to have opaque pixels, + or enable this option when image's half transparent area appears to be darken. + !#zh 是否启用贴图预乘。 + 当图片的透明区域出现色块时需要关闭该选项,当图片的半透明区域颜色变黑时需要启用该选项。 */ + premultipliedAlpha: boolean; + /** !#en The time scale of this skeleton. + !#zh 当前骨骼中所有动画的时间缩放率。 */ + timeScale: number; + /** !#en Indicates whether open debug slots. + !#zh 是否显示 slot 的 debug 信息。 */ + debugSlots: boolean; + /** !#en Indicates whether open debug bones. + !#zh 是否显示 bone 的 debug 信息。 */ + debugBones: boolean; + /** !#en Indicates whether open debug mesh. + !#zh 是否显示 mesh 的 debug 信息。 */ + debugMesh: boolean; + /** !#en Enabled two color tint. + !#zh 是否启用染色效果。 */ + useTint: boolean; + /** !#en Enabled batch model, if skeleton is complex, do not enable batch, or will lower performance. + !#zh 开启合批,如果渲染大量相同纹理,且结构简单的骨骼动画,开启合批可以降低drawcall,否则请不要开启,cpu消耗会上升。 */ + enableBatch: boolean; + /** + !#en + Sets runtime skeleton data to sp.Skeleton.
+ This method is different from the `skeletonData` property. This method is passed in the raw data provided by the Spine runtime, and the skeletonData type is the asset type provided by Creator. + !#zh + 设置底层运行时用到的 SkeletonData。
+ 这个接口有别于 `skeletonData` 属性,这个接口传入的是 Spine runtime 提供的原始数据,而 skeletonData 的类型是 Creator 提供的资源类型。 + @param skeletonData skeletonData + */ + setSkeletonData(skeletonData: sp.spine.SkeletonData): void; + /** + !#en Sets slots visible range. + !#zh 设置骨骼插槽可视范围。 + @param startSlotIndex startSlotIndex + @param endSlotIndex endSlotIndex + */ + setSlotsRange(startSlotIndex: number, endSlotIndex: number): void; + /** + !#en Sets animation state data.
+ The parameter type is {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.AnimationStateData. + !#zh 设置动画状态数据。
+ 参数是 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.AnimationStateData。 + @param stateData stateData + */ + setAnimationStateData(stateData: sp.spine.AnimationStateData): void; + /** + !#en + It's best to set cache mode before set property 'dragonAsset', or will waste some cpu time. + If set the mode in editor, then no need to worry about order problem. + !#zh + 若想切换渲染模式,最好在设置'dragonAsset'之前,先设置好渲染模式,否则有运行时开销。 + 若在编辑中设置渲染模式,则无需担心设置次序的问题。 + @param cacheMode cacheMode + + @example + ```js + skeleton.setAnimationCacheMode(sp.Skeleton.AnimationCacheMode.SHARED_CACHE); + ``` + */ + setAnimationCacheMode(cacheMode: Skeleton.AnimationCacheMode): void; + /** + !#en Whether in cached mode. + !#zh 当前是否处于缓存模式。 + */ + isAnimationCached(): boolean; + /** + !#en Sets vertex effect delegate. + !#zh 设置顶点动画代理 + @param effectDelegate effectDelegate + */ + setVertexEffectDelegate(effectDelegate: VertexEffectDelegate): void; + /** + !#en Computes the world SRT from the local SRT for each bone. + !#zh 重新更新所有骨骼的世界 Transform, + 当获取 bone 的数值未更新时,即可使用该函数进行更新数值。 + + @example + ```js + var bone = spine.findBone('head'); + cc.log(bone.worldX); // return 0; + spine.updateWorldTransform(); + bone = spine.findBone('head'); + cc.log(bone.worldX); // return -23.12; + ``` + */ + updateWorldTransform(): void; + /** + !#en Sets the bones and slots to the setup pose. + !#zh 还原到起始动作 + */ + setToSetupPose(): void; + /** + !#en + Sets the bones to the setup pose, + using the values from the `BoneData` list in the `SkeletonData`. + !#zh + 设置 bone 到起始动作 + 使用 SkeletonData 中的 BoneData 列表中的值。 + */ + setBonesToSetupPose(): void; + /** + !#en + Sets the slots to the setup pose, + using the values from the `SlotData` list in the `SkeletonData`. + !#zh + 设置 slot 到起始动作。 + 使用 SkeletonData 中的 SlotData 列表中的值。 + */ + setSlotsToSetupPose(): void; + /** + !#en + Updating an animation cache to calculate all frame data in the animation is a cost in + performance due to calculating all data in a single frame. + To update the cache, use the invalidAnimationCache method with high performance. + !#zh + 更新某个动画缓存, 预计算动画中所有帧数据,由于在单帧计算所有数据,所以较消耗性能。 + 若想更新缓存,可使用 invalidAnimationCache 方法,具有较高性能。 + @param animName animName + */ + updateAnimationCache(animName: string): void; + /** + !#en + Invalidates the animation cache, which is then recomputed on each frame.. + !#zh + 使动画缓存失效,之后会在每帧重新计算。 + */ + invalidAnimationCache(): void; + /** + !#en + Finds a bone by name. + This does a string comparison for every bone.
+ Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Bone object. + !#zh + 通过名称查找 bone。 + 这里对每个 bone 的名称进行了对比。
+ 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Bone 对象。 + @param boneName boneName + */ + findBone(boneName: string): sp.spine.Bone; + /** + !#en + Finds a slot by name. This does a string comparison for every slot.
+ Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Slot object. + !#zh + 通过名称查找 slot。这里对每个 slot 的名称进行了比较。
+ 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Slot 对象。 + @param slotName slotName + */ + findSlot(slotName: string): sp.spine.Slot; + /** + !#en + Finds a skin by name and makes it the active skin. + This does a string comparison for every skin.
+ Note that setting the skin does not change which attachments are visible.
+ Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Skin object. + !#zh + 按名称查找皮肤,激活该皮肤。这里对每个皮肤的名称进行了比较。
+ 注意:设置皮肤不会改变 attachment 的可见性。
+ 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Skin 对象。 + @param skinName skinName + */ + setSkin(skinName: string): void; + /** + !#en + Returns the attachment for the slot and attachment name. + The skeleton looks first in its skin, then in the skeleton data’s default skin.
+ Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Attachment object. + !#zh + 通过 slot 和 attachment 的名称获取 attachment。Skeleton 优先查找它的皮肤,然后才是 Skeleton Data 中默认的皮肤。
+ 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Attachment 对象。 + @param slotName slotName + @param attachmentName attachmentName + */ + getAttachment(slotName: string, attachmentName: string): sp.spine.Attachment; + /** + !#en + Sets the attachment for the slot and attachment name. + The skeleton looks first in its skin, then in the skeleton data’s default skin. + !#zh + 通过 slot 和 attachment 的名字来设置 attachment。 + Skeleton 优先查找它的皮肤,然后才是 Skeleton Data 中默认的皮肤。 + @param slotName slotName + @param attachmentName attachmentName + */ + setAttachment(slotName: string, attachmentName: string): void; + /** + Return the renderer of attachment. + @param regionAttachment regionAttachment + */ + getTextureAtlas(regionAttachment: sp.spine.RegionAttachment|spine.BoundingBoxAttachment): sp.spine.TextureAtlasRegion; + /** + !#en + Mix applies all keyframe values, + interpolated for the specified time and mixed with the current values. + !#zh 为所有关键帧设定混合及混合时间(从当前值开始差值)。 + @param fromAnimation fromAnimation + @param toAnimation toAnimation + @param duration duration + */ + setMix(fromAnimation: string, toAnimation: string, duration: number): void; + /** + !#en Set the current animation. Any queued animations are cleared.
+ Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry object. + !#zh 设置当前动画。队列中的任何的动画将被清除。
+ 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry 对象。 + @param trackIndex trackIndex + @param name name + @param loop loop + */ + setAnimation(trackIndex: number, name: string, loop: boolean): sp.spine.TrackEntry; + /** + !#en Adds an animation to be played delay seconds after the current or last queued animation.
+ Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry object. + !#zh 添加一个动画到动画队列尾部,还可以延迟指定的秒数。
+ 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry 对象。 + @param trackIndex trackIndex + @param name name + @param loop loop + @param delay delay + */ + addAnimation(trackIndex: number, name: string, loop: boolean, delay?: number): sp.spine.TrackEntry; + /** + !#en Find animation with specified name. + !#zh 查找指定名称的动画 + @param name name + */ + findAnimation(name: string): sp.spine.Animation; + /** + !#en Returns track entry by trackIndex.
+ Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry object. + !#zh 通过 track 索引获取 TrackEntry。
+ 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry 对象。 + @param trackIndex trackIndex + */ + getCurrent(trackIndex: any): sp.spine.TrackEntry; + /** + !#en Clears all tracks of animation state. + !#zh 清除所有 track 的动画状态。 + */ + clearTracks(): void; + /** + !#en Clears track of animation state by trackIndex. + !#zh 清除出指定 track 的动画状态。 + @param trackIndex trackIndex + */ + clearTrack(trackIndex: number): void; + /** + !#en Set the start event listener. + !#zh 用来设置开始播放动画的事件监听。 + @param listener listener + */ + setStartListener(listener: Function): void; + /** + !#en Set the interrupt event listener. + !#zh 用来设置动画被打断的事件监听。 + @param listener listener + */ + setInterruptListener(listener: Function): void; + /** + !#en Set the end event listener. + !#zh 用来设置动画播放完后的事件监听。 + @param listener listener + */ + setEndListener(listener: Function): void; + /** + !#en Set the dispose event listener. + !#zh 用来设置动画将被销毁的事件监听。 + @param listener listener + */ + setDisposeListener(listener: Function): void; + /** + !#en Set the complete event listener. + !#zh 用来设置动画播放一次循环结束后的事件监听。 + @param listener listener + */ + setCompleteListener(listener: Function): void; + /** + !#en Set the animation event listener. + !#zh 用来设置动画播放过程中帧事件的监听。 + @param listener listener + */ + setEventListener(listener: Function): void; + /** + !#en Set the start event listener for specified TrackEntry. + !#zh 用来为指定的 TrackEntry 设置动画开始播放的事件监听。 + @param entry entry + @param listener listener + */ + setTrackStartListener(entry: sp.spine.TrackEntry, listener: Function): void; + /** + !#en Set the interrupt event listener for specified TrackEntry. + !#zh 用来为指定的 TrackEntry 设置动画被打断的事件监听。 + @param entry entry + @param listener listener + */ + setTrackInterruptListener(entry: sp.spine.TrackEntry, listener: Function): void; + /** + !#en Set the end event listener for specified TrackEntry. + !#zh 用来为指定的 TrackEntry 设置动画播放结束的事件监听。 + @param entry entry + @param listener listener + */ + setTrackEndListener(entry: sp.spine.TrackEntry, listener: Function): void; + /** + !#en Set the dispose event listener for specified TrackEntry. + !#zh 用来为指定的 TrackEntry 设置动画即将被销毁的事件监听。 + @param entry entry + @param listener listener + */ + setTrackDisposeListener(entry: sp.spine.TrackEntry, listener: Function): void; + /** + !#en Set the complete event listener for specified TrackEntry. + !#zh 用来为指定的 TrackEntry 设置动画一次循环播放结束的事件监听。 + @param entry entry + @param listener listener + */ + setTrackCompleteListener(entry: sp.spine.TrackEntry, listener: (entry: sp.spine.TrackEntry, loopCount: number) => void): void; + /** + !#en Set the event listener for specified TrackEntry. + !#zh 用来为指定的 TrackEntry 设置动画帧事件的监听。 + @param entry entry + @param listener listener + */ + setTrackEventListener(entry: sp.spine.TrackEntry, listener: Function): void; + /** + !#en Get the animation state object + !#zh 获取动画状态 + */ + getState(): sp.spine.AnimationState; + } + /** !#en The skeleton data of spine. + !#zh Spine 的 骨骼数据。 */ + export class SkeletonData extends cc.Asset { + /** !#en See http://en.esotericsoftware.com/spine-json-format + !#zh 可查看 Spine 官方文档 http://zh.esotericsoftware.com/spine-json-format */ + skeletonJson: any; + atlasText: string; + textures: cc.Texture2D[]; + /** !#en + A scale can be specified on the JSON or binary loader which will scale the bone positions, + image sizes, and animation translations. + This can be useful when using different sized images than were used when designing the skeleton + in Spine. For example, if using images that are half the size than were used in Spine, + a scale of 0.5 can be used. This is commonly used for games that can run with either low or high + resolution texture atlases. + see http://en.esotericsoftware.com/spine-using-runtimes#Scaling + !#zh 可查看 Spine 官方文档: http://zh.esotericsoftware.com/spine-using-runtimes#Scaling */ + scale: number; + /** + !#en Get the included SkeletonData used in spine runtime.
+ Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.SkeletonData object. + !#zh 获取 Spine Runtime 使用的 SkeletonData。
+ 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.SkeletonData 对象。 + @param quiet quiet + */ + getRuntimeData(quiet?: boolean): sp.spine.SkeletonData; + } + /** !#en + The delegate of spine vertex effect + !#zh + Spine 顶点动画代理 */ + export class VertexEffectDelegate { + /** + !#en Clears vertex effect. + !#zh 清空顶点效果 + */ + clear(): void; + /** + !#en Inits delegate with jitter effect + !#zh 设置顶点抖动效果 + @param jitterX jitterX + @param jitterY jitterY + */ + initJitter(jitterX: number, jitterY: number): void; + /** + !#en Inits delegate with swirl effect + !#zh 设置顶点漩涡效果 + @param radius radius + @param power power + */ + initSwirlWithPow(radius: number, power: number): sp.spine.JitterEffect; + /** + !#en Inits delegate with swirl effect + !#zh 设置顶点漩涡效果 + @param radius radius + @param power power + */ + initSwirlWithPowOut(radius: number, power: number): sp.spine.SwirlEffect; + /** + !#en Gets jitter vertex effect + !#zh 获取顶点抖动效果 + */ + getJitterVertexEffect(): sp.spine.JitterEffect; + /** + !#en Gets swirl vertex effect + !#zh 获取顶点漩涡效果 + */ + getSwirlVertexEffect(): sp.spine.SwirlEffect; + /** + !#en Gets vertex effect + !#zh 获取顶点效果 + */ + getVertexEffect(): sp.spine.JitterEffect; + /** + !#en Gets effect type + !#zh 获取效果类型 + */ + getEffectType(): string; + } + /**************************************************** + * sp + *****************************************************/ + + export namespace sp { + /** !#en Attach node tool + !#zh 挂点工具类 */ + export class AttachUtil { + /** + !#en Gets attached root node. + !#zh 获取挂接节点树的根节点 + */ + getAttachedRootNode(): cc.Node; + /** + !#en Gets attached node which you want. + !#zh 获得对应的挂点 + @param boneName boneName + */ + getAttachedNodes(boneName: string): cc.Node[]; + /** + !#en Destroy attached node which you want. + !#zh 销毁对应的挂点 + @param boneName boneName + */ + destroyAttachedNodes(boneName: string): void; + /** + !#en Traverse all bones to generate the minimum node tree containing the given bone names, NOTE that make sure the skeleton has initialized before calling this interface. + !#zh 遍历所有插槽,生成包含所有给定插槽名称的最小节点树,注意,调用该接口前请确保骨骼动画已经初始化好。 + @param boneName boneName + */ + generateAttachedNodes(boneName: string): cc.Node[]; + /** + !#en Destroy all attached node. + !#zh 销毁所有挂点 + */ + destroyAllAttachedNodes(): void; + /** + !#en Traverse all bones to generate a tree containing all bones nodes, NOTE that make sure the skeleton has initialized before calling this interface. + !#zh 遍历所有插槽,生成包含所有插槽的节点树,注意,调用该接口前请确保骨骼动画已经初始化好。 + */ + generateAllAttachedNodes(): cc.Node; + } + } + + /**************************************************** + * Skeleton + *****************************************************/ + + export namespace Skeleton { + /** !#en Enum for animation cache mode type. + !#zh Spine动画缓存类型 */ + export enum AnimationCacheMode { + REALTIME = 0, + SHARED_CACHE = 0, + PRIVATE_CACHE = 0, + } + } + +} + +/** !#en +`sp.spine` is the namespace for official Spine Runtime, which officially implemented and maintained by Spine.
+Please refer to the official documentation for its detailed usage: [http://en.esotericsoftware.com/spine-using-runtimes](http://en.esotericsoftware.com/spine-using-runtimes) +!#zh +sp.spine 模块是 Spine 官方运行库的 API 入口,由 Spine 官方统一实现和维护,具体用法请参考:[http://zh.esotericsoftware.com/spine-using-runtimes](http://zh.esotericsoftware.com/spine-using-runtimes) */ +declare namespace sp.spine { +} + +/** !#en +This module controls asset's behaviors and information, include loading, releasing etc. +All member can be accessed with `cc.assetManager`. All class or enum can be accessed with `cc.AssetManager` + +!#zh +此模块管理资源的行为和信息,包括加载,释放等,所有成员能够通过 `cc.assetManager` 调用. 所有类型或枚举能通过 `cc.AssetManager` 访问 */ +declare namespace cc.AssetManager { + /** !#en + This module contains the builtin asset, it's a singleton, all member can be accessed with `cc.assetManager.builtins` + + !#zh + 此模块包含内建资源,这是一个单例,所有成员能通过 `cc.assetManager.builtins` 访问 */ + export class Builtins { + /** + !#en + Initialize + + !#zh + 初始化 + @param cb Callback when finish loading built-in assets + */ + init (cb: () => void): void; + /** + !#en + Get the built-in asset using specific type and name. + + !#zh + 通过特定的类型和名称获取内建资源 + @param type The type of asset, such as `effect` + @param name The name of asset, such as `phong` + + @example + ```js + cc.assetManaer.builtins.getBuiltin('effect', 'phone'); + ``` + */ + getBuiltin(type?: string, name?: string): cc.Asset | Cache; + /** + !#en + Clear all builtin assets + + !#zh + 清空所有内置资源 + */ + clear(): void; + } + /** !#en + A bundle contains an amount of assets(includes scene), you can load, preload, release asset which is in this bundle + + !#zh + 一个包含一定数量资源(包括场景)的包,你可以加载,预加载,释放此包内的资源 */ + export class Bundle { + /** + !#en + Create a bundle + + !#zh + 创建一个 bundle + */ + constructor(); + /** !#en + The name of this bundle + + !#zh + 此 bundle 的名称 */ + name: string; + /** !#en + The dependency of this bundle + + !#zh + 此 bundle 的依赖 */ + deps: string[]; + /** !#en + The root path of this bundle, such like 'http://example.com/bundle1' + + !#zh + 此 bundle 的根路径, 例如 'http://example.com/bundle1' */ + base: string; + /** + !#en + Get asset's info using path, only valid when asset is in bundle folder. + + !#zh + 使用 path 获取资源的配置信息 + @param path The relative path of asset, such as 'images/a' + @param type The constructor of asset, such as `cc.Texture2D` + + @example + ```js + var info = bundle.getInfoWithPath('image/a', cc.Texture2D); + ``` + */ + getInfoWithPath (path: string, type?: typeof cc.Asset): Record; + /** + !#en + Get all asset's info within specific folder + + !#zh + 获取在某个指定文件夹下的所有资源信息 + @param path The relative path of folder, such as 'images' + @param type The constructor should be used to filter paths + @param out The output array + + @example + ```js + var infos = []; + bundle.getDirWithPath('images', cc.Texture2D, infos); + ``` + */ + getDirWithPath (path: string, type: typeof cc.Asset, out: Array>): Array>; + getDirWithPath (path: string, type: typeof cc.Asset): Array>; + getDirWithPath (path: string): Array>; + /** + !#en + Get asset's info with uuid + + !#zh + 通过 uuid 获取资源信息 + @param uuid The asset's uuid + + @example + ```js + var info = bundle.getAssetInfo('fcmR3XADNLgJ1ByKhqcC5Z'); + ``` + */ + getAssetInfo (uuid: string): Record; + /** + !#en + Get scene'info with name + + !#zh + 通过场景名获取场景信息 + @param name The name of scene + + @example + ```js + var info = bundle.getSceneInfo('first.fire'); + ``` + */ + getSceneInfo(name: string): Record; + /** + !#en + Initialize this bundle with options + + !#zh + 初始化此 bundle + @param options options + */ + init(options: Record): void; + /** + !#en + Load the asset within this bundle by the path which is relative to bundle's path + + !#zh + 通过相对路径加载分包中的资源。路径是相对分包文件夹路径的相对路径 + @param paths Paths of the target assets.The path is relative to the bundle's folder, extensions must be omitted. + @param type Only asset of type will be loaded if this argument is supplied. + @param onProgress Callback invoked when progression change. + @param onComplete Callback invoked when all assets loaded. + + @example + ```js + // load the texture (${project}/assets/resources/textures/background.jpg) from resources + cc.resources.load('textures/background', cc.Texture2D, (err, texture) => console.log(err)); + + // load the audio (${project}/assets/resources/music/hit.mp3) from resources + cc.resources.load('music/hit', cc.AudioClip, (err, audio) => console.log(err)); + + // load the prefab (${project}/assets/bundle1/misc/character/cocos) from bundle1 folder + bundle1.load('misc/character/cocos', cc.Prefab, (err, prefab) => console.log(err)); + + // load the sprite frame (${project}/assets/some/xxx/bundle2/imgs/cocos.png) from bundle2 folder + bundle2.load('imgs/cocos', cc.SpriteFrame, null, (err, spriteFrame) => console.log(err)); + ``` + */ + load(paths: string|string[], type: typeof cc.Asset, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, assets: T|Array) => void): void; + load(paths: string|string[], onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, assets: T|Array) => void): void; + load(paths: string|string[], type: typeof cc.Asset, onComplete: (error: Error, assets: T|Array) => void): void; + load(paths: string|string[], onComplete: (error: Error, assets: T|Array) => void): void; + load(paths: string|string[], type: typeof cc.Asset): void; + load(paths: string|string[]): void; + /** + !#en + Preload the asset within this bundle by the path which is relative to bundle's path. + After calling this method, you still need to finish loading by calling `Bundle.load`. + It will be totally fine to call `Bundle.load` at any time even if the preloading is not + yet finished + + !#zh + 通过相对路径预加载分包中的资源。路径是相对分包文件夹路径的相对路径。调用完后,你仍然需要通过 `Bundle.load` 来完成加载。 + 就算预加载还没完成,你也可以直接调用 `Bundle.load`。 + @param paths Paths of the target asset.The path is relative to bundle folder, extensions must be omitted. + @param type Only asset of type will be loaded if this argument is supplied. + @param onProgress Callback invoked when progression change. + @param onComplete Callback invoked when the resource loaded. + + @example + ```js + // preload the texture (${project}/assets/resources/textures/background.jpg) from resources + cc.resources.preload('textures/background', cc.Texture2D); + + // preload the audio (${project}/assets/resources/music/hit.mp3) from resources + cc.resources.preload('music/hit', cc.AudioClip); + // wait for while + cc.resources.load('music/hit', cc.AudioClip, (err, audioClip) => {}); + + * // preload the prefab (${project}/assets/bundle1/misc/character/cocos) from bundle1 folder + bundle1.preload('misc/character/cocos', cc.Prefab); + + // load the sprite frame of (${project}/assets/bundle2/imgs/cocos.png) from bundle2 folder + bundle2.preload('imgs/cocos', cc.SpriteFrame); + // wait for while + bundle2.load('imgs/cocos', cc.SpriteFrame, (err, spriteFrame) => {}); + ``` + */ + preload(paths: string|string[], type: typeof cc.Asset, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, items: RequestItem[]) => void): void; + preload(paths: string|string[], onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, items: RequestItem[]) => void): void; + preload(paths: string|string[], type: typeof cc.Asset, onComplete: (error: Error, items: RequestItem[]) => void): void; + preload(paths: string|string[], type: typeof cc.Asset): void; + preload(paths: string|string[], onComplete: (error: Error, items: RequestItem[]) => void): void; + preload(paths: string|string[]): void; + /** + !#en + Load all assets under a folder inside the bundle folder.
+
+ Note: All asset paths in Creator use forward slashes, paths using backslashes will not work. + + !#zh + 加载目标文件夹中的所有资源, 注意:路径中只能使用斜杠,反斜杠将停止工作 + @param dir path of the target folder.The path is relative to the bundle folder, extensions must be omitted. + @param type Only asset of type will be loaded if this argument is supplied. + @param onProgress Callback invoked when progression change. + @param onComplete A callback which is called when all assets have been loaded, or an error occurs. + + @example + ```js + // load all audios (resources/audios/) + cc.resources.loadDir('audios', cc.AudioClip, (err, audios) => {}); + + // load all textures in "resources/imgs/" + cc.resources.loadDir('imgs', cc.Texture2D, null, function (err, textures) { + var texture1 = textures[0]; + var texture2 = textures[1]; + }); + + // load all prefabs (${project}/assets/bundle1/misc/characters/) from bundle1 folder + bundle1.loadDir('misc/characters', cc.Prefab, (err, prefabs) => console.log(err)); + + // load all sprite frame (${project}/assets/some/xxx/bundle2/skills/) from bundle2 folder + bundle2.loadDir('skills', cc.SpriteFrame, null, (err, spriteFrames) => console.log(err)); + ``` + */ + loadDir(dir: string, type: typeof cc.Asset, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, assets: Array) => void): void; + loadDir(dir: string, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, assets: Array) => void): void; + loadDir(dir: string, type: typeof cc.Asset, onComplete: (error: Error, assets: Array) => void): void; + loadDir(dir: string, type: typeof cc.Asset): void; + loadDir(dir: string, onComplete: (error: Error, assets: Array) => void): void; + loadDir(dir: string): void; + /** + !#en + Preload all assets under a folder inside the bundle folder.
After calling this method, you still need to finish loading by calling `Bundle.loadDir`. + It will be totally fine to call `Bundle.loadDir` at any time even if the preloading is not yet finished + + !#zh + 预加载目标文件夹中的所有资源。调用完后,你仍然需要通过 `Bundle.loadDir` 来完成加载。 + 就算预加载还没完成,你也可以直接调用 `Bundle.loadDir`。 + @param dir path of the target folder.The path is relative to the bundle folder, extensions must be omitted. + @param type Only asset of type will be preloaded if this argument is supplied. + @param onProgress Callback invoked when progression change. + @param onComplete A callback which is called when all assets have been loaded, or an error occurs. + + @example + ```js + // preload all audios (resources/audios/) + cc.resources.preloadDir('audios', cc.AudioClip); + + // preload all textures in "resources/imgs/" + cc.resources.preloadDir('imgs', cc.Texture2D); + // wait for while + cc.resources.loadDir('imgs', cc.Texture2D, (err, textures) => {}); + + // preload all prefabs (${project}/assets/bundle1/misc/characters/) from bundle1 folder + bundle1.preloadDir('misc/characters', cc.Prefab); + + // preload all sprite frame (${project}/assets/some/xxx/bundle2/skills/) from bundle2 folder + bundle2.preloadDir('skills', cc.SpriteFrame); + // wait for while + bundle2.loadDir('skills', cc.SpriteFrame, (err, spriteFrames) => {}); + ``` + */ + preloadDir(dir: string, type: typeof cc.Asset, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, items: RequestItem[]) => void): void; + preloadDir(dir: string, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, items: RequestItem[]) => void): void; + preloadDir(dir: string, type: typeof cc.Asset, onComplete: (error: Error, items: RequestItem[]) => void): void; + preloadDir(dir: string, type: typeof cc.Asset): void; + preloadDir(dir: string, onComplete: (error: Error, items: RequestItem[]) => void): void; + preloadDir(dir: string): void; + /** + !#en + Loads the scene within this bundle by its name. + + !#zh + 通过场景名称加载分包中的场景。 + @param sceneName The name of the scene to load. + @param options Some optional parameters + @param onProgress Callback invoked when progression change. + @param onComplete callback, will be called after scene launched. + + @example + ```js + bundle1.loadScene('first', (err, sceneAsset) => cc.director.runScene(sceneAsset)); + ``` + */ + loadScene(sceneName: string, options: Record, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, sceneAsset: cc.SceneAsset) => void): void; + loadScene(sceneName: string, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, sceneAsset: cc.SceneAsset) => void): void; + loadScene(sceneName: string, options: Record, onComplete: (error: Error, sceneAsset: cc.SceneAsset) => void): void; + loadScene(sceneName: string, options: Record): void; + loadScene(sceneName: string, onComplete: (error: Error, sceneAsset: cc.SceneAsset) => void): void; + loadScene(sceneName: string): void; + /** + !#en + Preloads the scene within this bundle by its name. After calling this method, you still need to finish loading by calling `Bundle.loadScene` or `cc.director.loadScene`. + It will be totally fine to call `Bundle.loadDir` at any time even if the preloading is not yet finished + + !#zh + 通过场景名称预加载分包中的场景.调用完后,你仍然需要通过 `Bundle.loadScene` 或 `cc.director.loadScene` 来完成加载。 + 就算预加载还没完成,你也可以直接调用 `Bundle.loadScene` 或 `cc.director.loadScene`。 + @param sceneName The name of the scene to preload. + @param options Some optional parameters + @param onProgress callback, will be called when the load progression change. + @param onComplete callback, will be called after scene loaded. + + @example + ```js + bundle1.preloadScene('first'); + // wait for a while + bundle1.loadScene('first', (err, scene) => cc.director.runScene(scene)); + ``` + */ + preloadScene(sceneName: string, options: Record, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error) => void): void; + preloadScene(sceneName: string, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error) => void): void; + preloadScene(sceneName: string, options: Record, onComplete: (error: Error) => void): void; + preloadScene(sceneName: string, options: Record): void; + preloadScene(sceneName: string, onComplete: (error: Error) => void): void; + preloadScene(sceneName: string): void; + /** + !#en + Get asset within this bundle by path and type.
+ After you load asset with {{#crossLink "Bundle/load:method"}}{{/crossLink}} or {{#crossLink "Bundle/loadDir:method"}}{{/crossLink}}, + you can acquire them by passing the path to this API. + + !#zh + 通过路径与类型获取资源。在你使用 {{#crossLink "Bundle/load:method"}}{{/crossLink}} 或者 {{#crossLink "Bundle/loadDir:method"}}{{/crossLink}} 之后, + 你能通过传路径通过这个 API 获取到这些资源。 + @param path The path of asset + @param type Only asset of type will be returned if this argument is supplied. + + @example + ```js + bundle1.get('music/hit', cc.AudioClip); + ``` + */ + get (path: string, type?: typeof cc.Asset): cc.Asset; + /** + !#en + Release the asset loaded by {{#crossLink "Bundle/load:method"}}{{/crossLink}} or {{#crossLink "Bundle/loadDir:method"}}{{/crossLink}} and it's dependencies. + Refer to {{#crossLink "AssetManager/releaseAsset:method"}}{{/crossLink}} for detailed informations. + + !#zh + 释放通过 {{#crossLink "Bundle/load:method"}}{{/crossLink}} 或者 {{#crossLink "Bundle/loadDir:method"}}{{/crossLink}} 加载的资源。详细信息请参考 {{#crossLink "AssetManager/releaseAsset:method"}}{{/crossLink}} + @param path The path of asset + @param type Only asset of type will be released if this argument is supplied. + + @example + ```js + // release a texture which is no longer need + bundle1.release('misc/character/cocos'); + ``` + */ + release(path: string, type: typeof cc.Asset): void; + release(path: string): void; + /** + !#en + Release all assets within this bundle. Refer to {{#crossLink "AssetManager/releaseAll:method"}}{{/crossLink}} for detailed informations. + + !#zh + 释放此包中的所有资源。详细信息请参考 {{#crossLink "AssetManager/releaseAll:method"}}{{/crossLink}} + + @example + ```js + // release all asset within bundle1 + bundle1.releaseAll(); + ``` + */ + releaseAll(): void; + } + /** !#en + Cache manager is a module which controls all caches downloaded from server in non-web platform, it is a singleton + All member can be accessed with `cc.assetManager.cacheManager`. + + !#zh + 缓存管理器是一个模块,在非 WEB 平台上,用于管理所有从服务器上下载下来的缓存,这是一个单例,所有成员能通过 `cc.assetManager.cacheManager` 访问。 */ + export class CacheManager { + /** !#en + The name of cacheDir + + !#zh + 缓存目录的名称 */ + cacheDir: string; + /** !#en + Whether or not cache asset into user's storage space, this property only works on mini-game platforms + + !#zh + 是否缓存资源到用户存储空间,此属性只在小游戏平台有效 */ + cacheEnabled: boolean; + /** !#en + Whether or not auto clear cache when storage ran out, this property only works on mini-game platforms + + !#zh + 是否在存储空间满了后自动清理缓存,此属性只在小游戏平台有效 */ + autoClear: boolean; + /** !#en + The interval between caching resources, this property only works on mini-game platforms + + !#zh + 缓存资源的间隔时间,此属性只在小游戏平台有效 */ + cacheInterval: number; + /** !#en + The interval between deleting resources, when you use `cleanLRU`, the resources will be deleted as this interval + + !#zh + 清理资源的间隔时间,当你使用 `cleanLRU` 时,资源将以此间隔被删除 */ + deleteInterval: number; + /** + !#en + Get cached path with origin url + + !#zh + 通过原始 url 获取缓存后的路径 + @param originUrl originUrl + */ + getCache(originUrl: string): string; + /** + !#en + Get temporary path with origin url, this method only works on mini-game platforms + + !#zh + 通过原始 url 获取临时文件的路径,此方法只在小游戏平台有效 + @param originUrl originUrl + */ + getTemp(originUrl: string): string; + /** + !#en + Clear all caches, please use with caution, If necessary, we recommend using it before the game is launched + + !#zh + 清空所有缓存,请谨慎使用,如果必要的话,我们建议在游戏启动之前使用 + */ + clearCache(): void; + /** + !#en + Clear part of caches with LRU strategy + + !#zh + 使用 LRU 策略清空部分缓存 + */ + clearLRU(): void; + /** + !#en + Remove cache with origin url + + !#zh + 通过原始 url 移除缓存 + */ + removeCache(): void; + } + /** !#en + use to cache something + + !#zh + 用于缓存某些内容 */ + export class Cache { + /** + !#en + Create a cache + + !#zh + 创建一个 cache + @param map An object used to initialize + */ + constructor(map?: Record); + /** + !#en + Add Key-Value to cache + + !#zh + 增加键值对到缓存中 + @param key The key + @param val The value + + @example + ```js + var cache = new Cache(); + cache.add('test', null); + ``` + */ + add(key: string, val: T): T; + /** + !#en + Get the cached content by key + + !#zh + 通过 key 获取对应的 value + @param key The key + + @example + ```js + var cache = new Cache(); + var test = cache.get('test'); + ``` + */ + get(key: string): T; + /** + !#en + Check whether or not content exists by key + + !#zh + 通过 Key 判断是否存在对应的内容 + @param key The key + + @example + ```js + var cache = new Cache(); + var exist = cache.has('test'); + ``` + */ + has(key: string): boolean; + /** + !#en + Remove the cached content by key + + !#zh + 通过 Key 移除对应的内容 + @param key The key + + @example + ```js + var cache = new Cache(); + var content = cache.remove('test'); + ``` + */ + remove(key: string): T; + /** + !#en + Clear all content + + !#zh + 清除所有内容 + + @example + ```js + var cache = new Cache(); + cache.clear(); + ``` + */ + clear():void; + /** + !#en + Enumerate all content and invoke function + + !#zh + 枚举所有内容并执行方法 + @param func Function to be invoked + + @example + ```js + var cache = new Cache(); + cache.forEach((val, key) => console.log(key)); + ``` + */ + forEach(func: (val: T, key: string) => void): void; + /** + !#en + Enumerate all content to find one element which can fulfill condition + + !#zh + 枚举所有内容,找到一个可以满足条件的元素 + @param predicate The condition + + @example + ```js + var cache = new Cache(); + var val = cache.find((val, key) => key === 'test'); + ``` + */ + find(predicate: (val: T, key: string) => boolean): T; + /** !#en + The count of cached content + + !#zh + 缓存数量 */ + count: number; + /** + !#en + Destroy this cache + + !#zh + 销毁这个 cache + */ + destroy(): void; + } + /** !#en + Control asset's dependency list, it is a singleton. All member can be accessed with `cc.assetManager.dependUtil` + + !#zh + 控制资源的依赖列表,这是一个单例, 所有成员能通过 `cc.assetManager.dependUtil` 访问 */ + export class DependUtil { + /** + !#en + Get asset's native dependency. For example, Texture's native dependency is image. + + !#zh + 获取资源的原生依赖,例如 Texture 的原生依赖是图片 + @param uuid asset's uuid + + @example + ```js + var dep = dependUtil.getNativeDep('fcmR3XADNLgJ1ByKhqcC5Z'); + ``` + */ + getNativeDep(uuid: string): Record; + /** + !#en + Get asset's direct referencing non-native dependency list. For example, Material's non-native dependencies are Texture. + + !#zh + 获取资源直接引用的非原生依赖列表,例如,材质的非原生依赖是 Texture + @param uuid asset's uuid + + @example + ```js + var deps = dependUtil.getDeps('fcmR3XADNLgJ1ByKhqcC5Z'); + ``` + */ + getDeps(uuid: string): string[]; + /** + !#en + Get non-native dependency list of the loaded asset, include indirect reference. + The returned array stores the dependencies with their uuid, after retrieve dependencies, + + !#zh + 获取某个已经加载好的资源的所有非原生依赖资源列表,包括间接引用的资源,并保存在数组中返回。 + 返回的数组将仅保存依赖资源的 uuid。 + @param uuid The asset's uuid + + @example + ```js + var deps = dependUtil.getDepsRecursively('fcmR3XADNLgJ1ByKhqcC5Z'); + ``` + */ + getDepsRecursively(uuid: string): string[]; + } + /** !#en + Control all download process, it is a singleton. All member can be accessed with `cc.assetManager.downloader` , it can download several types of files: + 1. Text + 2. Image + 3. Audio + 4. Assets + 5. Scripts + + !#zh + 管理所有下载过程,downloader 是个单例,所有成员能通过 `cc.assetManager.downloader` 访问,它能下载以下几种类型的文件: + 1. 文本 + 2. 图片 + 3. 音频 + 4. 资源 + 5. 脚本 */ + export class Downloader { + /** !#en + The maximum number of concurrent when downloading + + !#zh + 下载时的最大并发数 */ + maxConcurrency: number; + /** !#en + The maximum number of request can be launched per frame when downloading + + !#zh + 下载时每帧可以启动的最大请求数 */ + maxRequestsPerFrame: number; + /** !#en + The max number of retries when fail + + !#zh + 失败重试次数 */ + maxRetryCount: number; + /** !#en + Wait for while before another retry, unit: ms + + !#zh + 重试的间隔时间 */ + retryInterval: number; + /** + !#en + Use Image element to download image + + !#zh + 使用 Image 元素来下载图片 + @param url Url of the image + @param options Some optional paramters + @param onComplete Callback when image loaded or failed + + @example + ```js + downloadDomImage('http://example.com/test.jpg', null, (err, img) => console.log(err)); + ``` + */ + downloadDomImage(url: string, options?: Record , onComplete?: (err: Error, img: HTMLImageElement) => void): HTMLImageElement; + downloadDomImage(url: string, onComplete?: (err: Error, img: HTMLImageElement) => void): HTMLImageElement; + /** + !#en + Use audio element to download audio + + !#zh + 使用 Audio 元素来下载音频 + @param url Url of the audio + @param options Some optional paramters + @param onComplete Callback invoked when audio loaded or failed + + @example + ```js + downloadDomAudio('http://example.com/test.mp3', null, (err, audio) => console.log(err)); + ``` + */ + downloadDomAudio(url: string, options?: Record, onComplete?: (err: Error, audio: HTMLAudioElement) => void): HTMLAudioElement; + downloadDomAudio(url: string, onComplete?: (err: Error, audio: HTMLAudioElement) => void): HTMLAudioElement; + /** + !#en + Use XMLHttpRequest to download file + + !#zh + 使用 XMLHttpRequest 来下载文件 + @param url Url of the file + @param options Some optional paramters + @param onFileProgress Callback continuously during download is processing + @param onComplete Callback when file loaded or failed + + @example + ```js + downloadFile('http://example.com/test.bin', {responseType: 'arraybuffer'}, null, (err, arrayBuffer) => console.log(err)); + ``` + */ + downloadFile(url: string, options?: Record, onFileProgress?: (loaded: Number, total: Number) => void, onComplete?: (err: Error, response: any) => void): XMLHttpRequest; + downloadFile(url: string, onFileProgress?: (loaded: Number, total: Number) => void, onComplete?: (err: Error, response: any) => void): XMLHttpRequest; + downloadFile(url: string, options?: Record, onComplete?: (err: Error, response: any) => void): XMLHttpRequest; + downloadFile(url: string, onComplete?: (err: Error, response: any) => void): XMLHttpRequest; + /** + !#en + Load script + + !#zh + 加载脚本 + @param url Url of the script + @param options Some optional paramters + @param onComplete Callback when script loaded or failed + + @example + ```js + downloadScript('http://localhost:8080/index.js', null, (err) => console.log(err)); + ``` + */ + downloadScript(url: string, options?: Record, onComplete?: (err: Error) => void): void;; + downloadScript(url: string, onComplete?: (err: Error) => void): void;; + /** + !#en + Register custom handler if you want to change default behavior or extend downloader to download other format file + + !#zh + 当你想修改默认行为或者拓展 downloader 来下载其他格式文件时可以注册自定义的 handler + @param type Extension likes '.jpg' or map likes {'.jpg': jpgHandler, '.png': pngHandler} + @param handler handler + + @example + ```js + downloader.register('.tga', (url, options, onComplete) => onComplete(null, null)); + downloader.register({'.tga': (url, options, onComplete) => onComplete(null, null), '.ext': (url, options, onComplete) => onComplete(null, null)}); + ``` + */ + register(type: string, handler: (url: string, options: Record, onComplete: (err: Error, content: any) => void) => void): void; + register(map: Record, onComplete: (err: Error, content: any) => void) => void>): void; + /** + !#en + Use corresponding handler to download file under limitation + + !#zh + 在限制下使用对应的 handler 来下载文件 + @param url The url should be downloaded + @param type The type indicates that which handler should be used to download, such as '.jpg' + @param options some optional paramters will be transferred to the corresponding handler. + @param onComplete callback when finishing downloading + + @example + ```js + download('http://example.com/test.tga', '.tga', {onFileProgress: (loaded, total) => console.lgo(loaded/total)}, onComplete: (err) => console.log(err)); + ``` + */ + download(id: string, url: string, type: string, options: Record, onComplete: (err: Error, content: any) => void): void; + } + /** !#en + Provide some helpful function, it is a singleton. All member can be accessed with `cc.assetManager.utils` + + !#zh + 提供一些辅助方法,helper 是一个单例, 所有成员能通过 `cc.assetManager.utils` 访问 */ + export class Helper { + /** + !#en + Decode uuid, returns the original uuid + + !#zh + 解码 uuid,返回原始 uuid + @param base64 the encoded uuid + + @example + ```js + var uuid = 'fcmR3XADNLgJ1ByKhqcC5Z'; + var originalUuid = decodeUuid(uuid); // fc991dd7-0033-4b80-9d41-c8a86a702e59 + ``` + */ + decodeUuid(base64: string): string; + /** + !#en + Extract uuid from url + + !#zh + 从 url 中提取 uuid + @param url url + + @example + ```js + var url = 'res/import/fc/fc991dd7-0033-4b80-9d41-c8a86a702e59.json'; + var uuid = getUuidFromURL(url); // fc991dd7-0033-4b80-9d41-c8a86a702e59 + ``` + */ + getUuidFromURL(url: string): string; + /** + !#en + Transform uuid to url + + !#zh + 转换 uuid 为 url + @param uuid The uuid of asset + @param options Some optional parameters + + @example + ```js + var url = getUrlWithUuid('fcmR3XADNLgJ1ByKhqcC5Z', {isNative: false}); + ``` + */ + getUrlWithUuid(uuid: string, options?: Record): string; + /** + !#en + Check if the type of data is cc.Scene or cc.Prefab + + !#zh + 检测数据的类型是否是 Scene 或者 Prefab + @param json serialized data + */ + isSceneObj(json: any): boolean; + /** + !#en + Check if the type of asset is scene + + !#zh + 检查资源类型是否是场景 + @param asset asset + */ + isScene(asset: any): boolean; + /** + !#en + Normalize url, strip './' and '/' + + !#zh + 标准化 url ,去除 './' 和 '/' + @param url url + */ + normalize(url: string): string; + } + /** !#en + Handle the packed asset, include unpacking, loading, cache and so on. It is a singleton. All member can be accessed with `cc.assetManager.packManager` + + !#zh + 处理打包资源,包括拆包,加载,缓存等等,这是一个单例, 所有成员能通过 `cc.assetManager.packManager` 访问 */ + export class PackManager { + /** + !#en + Unpack the json, revert to what it was before packing + + !#zh + 拆解 json 包,恢复为打包之前的内容 + @param pack The pack + @param json The content of pack + @param options Some optional parameters + @param onComplete Callback when finish unpacking + + @example + ```js + downloader.downloadFile('pack.json', {responseType: 'json'}, null, (err, file) => { + packManager.unpackJson(['a', 'b'], file, null, (err, data) => console.log(err)); + }); + ``` + */ + unpackJson(pack: string[], json: any, options: Record, onComplete?: (err: Error, content: any) => void): void; + /** + !#en + Register custom handler if you want to change default behavior or extend packManager to unpack other format pack + + !#zh + 当你想修改默认行为或者拓展 packManager 来拆分其他格式的包时可以注册自定义的 handler + @param type Extension likes '.bin' or map likes {'.bin': binHandler, '.ab': abHandler} + @param handler handler + + @example + ```js + packManager.register('.bin', (packUuid, file, options, onComplete) => onComplete(null, null)); + packManager.register({'.bin': (packUuid, file, options, onComplete) => onComplete(null, null), '.ab': (packUuid, file, options, onComplete) => onComplete(null, null)}); + ``` + */ + register(type: string, handler: (packUuid: string, data: any, options: Record, onComplete: (err: Error, content: any) => void) => void): void; + register(map: Record, onComplete: (err: Error, content: any) => void) => void>): void; + /** + !#en + Use corresponding handler to unpack package + + !#zh + 用对应的 handler 来进行解包 + @param pack The uuid of packed assets + @param data The packed data + @param type The type indicates that which handler should be used to download, such as '.jpg' + @param options Some optional parameter + @param onComplete callback when finishing unpacking + + @example + ```js + downloader.downloadFile('pack.json', {responseType: 'json'}, null, (err, file) => { + packManager.unpack(['2fawq123d', '1zsweq23f'], file, '.json', null, (err, data) => console.log(err)); + }); + ``` + */ + unpack(pack: string[], data: any, type: string, options: Record, onComplete?: (err: Error, data: any) => void): void; + /** + !#en + Download request item, If item is not in any package, download as usual. Otherwise, download the corresponding package and unpack it. + And then retrieve the corresponding content form it. + + !#zh + 下载请求对象,如果请求对象不在任何包内,则正常下载,否则下载对应的 package 并进行拆解,并取回包内对应的内容 + @param item Some item you want to download + @param options Some optional parameters + @param onComplete Callback when finished + + @example + ```js + var requestItem = cc.AssetManager.RequestItem.create(); + requestItem.uuid = 'fcmR3XADNLgJ1ByKhqcC5Z'; + requestItem.info = config.getAssetInfo('fcmR3XADNLgJ1ByKhqcC5Z'); + packManager.load(requestItem, null, (err, data) => console.log(err)); + ``` + */ + load(item: RequestItem, options: Record, onComplete: (err: Error, data: any) => void): void; + } + /** !#en + Parse the downloaded file, it's a singleton, all member can be accessed with `cc.assetManager.parser` + + !#zh + 解析已下载的文件,parser 是一个单例, 所有成员能通过 `cc.assetManaager.parser` 访问 */ + export class Parser { + /** + !#en + Parse image file + + !#zh + 解析图片文件 + @param file The downloaded file + @param options Some optional paramters + @param onComplete callback when finish parsing. + + @example + ```js + downloader.downloadFile('test.jpg', {responseType: 'blob'}, null, (err, file) => { + parser.parseImage(file, null, (err, img) => console.log(err)); + }); + ``` + */ + parseImage(file: Blob, options: Record, onComplete?: (err: Error, img: ImageBitmap|HTMLImageElement) => void): void; + /** + !#en + Parse audio file + + !#zh + 解析音频文件 + @param file The downloaded file + @param options Some optional paramters + @param onComplete Callback when finish parsing. + + @example + ```js + downloader.downloadFile('test.mp3', {responseType: 'arraybuffer'}, null, (err, file) => { + parser.parseAudio(file, null, (err, audio) => console.log(err)); + }); + ``` + */ + parseAudio(file: ArrayBuffer|HTMLAudioElement, options: Record, onComplete?: (err: Error, audio: AudioBuffer|HTMLAudioElement) => void): void; + /** + !#en + Parse pvr file + + !#zh + 解析压缩纹理格式 pvr 文件 + @param file The downloaded file + @param options Some optional paramters + @param onComplete Callback when finish parsing. + + @example + ```js + downloader.downloadFile('test.pvr', {responseType: 'arraybuffer'}, null, (err, file) => { + parser.parsePVRTex(file, null, (err, pvrAsset) => console.log(err)); + }); + ``` + */ + parsePVRTex(file: ArrayBuffer|ArrayBufferView, options: Record, onComplete: (err: Error, pvrAsset: {_data: Uint8Array, _compressed: boolean, width: number, height: number}) => void): void; + /** + !#en + Parse pkm file + + !#zh + 解析压缩纹理格式 pkm 文件 + @param file The downloaded file + @param options Some optional paramters + @param onComplete Callback when finish parsing. + + @example + ```js + downloader.downloadFile('test.pkm', {responseType: 'arraybuffer'}, null, (err, file) => { + parser.parsePKMTex(file, null, (err, etcAsset) => console.log(err)); + }); + ``` + */ + parsePKMTex(file: ArrayBuffer|ArrayBufferView, options: Record, onComplete: (err: Error, etcAsset: {_data: Uint8Array, _compressed: boolean, width: number, height: number}) => void): void; + /** + !#en + Parse plist file + + !#zh + 解析 plist 文件 + @param file The downloaded file + @param options Some optional paramters + @param onComplete Callback when finish parsing + + @example + ```js + downloader.downloadFile('test.plist', {responseType: 'text'}, null, (err, file) => { + parser.parsePlist(file, null, (err, data) => console.log(err)); + }); + ``` + */ + parsePlist(file: string, options: Record, onComplete?: (err: Error, data: any) => void): void; + /** + !#en + Deserialize asset file + + !#zh + 反序列化资源文件 + @param file The serialized json + @param options Some optional paramters + @param onComplete Callback when finish parsing + + @example + ```js + downloader.downloadFile('test.json', {responseType: 'json'}, null, (err, file) => { + parser.parseImport(file, null, (err, data) => console.log(err)); + }); + ``` + */ + parseImport (file: any, options: Record, onComplete?: (err: Error, asset: cc.Asset) => void): void; + /** + !#en + Register custom handler if you want to change default behavior or extend parser to parse other format file + + !#zh + 当你想修改默认行为或者拓展 parser 来解析其他格式文件时可以注册自定义的handler + @param type Extension likes '.jpg' or map likes {'.jpg': jpgHandler, '.png': pngHandler} + @param handler The corresponding handler + + @example + ```js + parser.register('.tga', (file, options, onComplete) => onComplete(null, null)); + parser.register({'.tga': (file, options, onComplete) => onComplete(null, null), '.ext': (file, options, onComplete) => onComplete(null, null)}); + ``` + */ + register(type: string, handler: (file: any, options: Record, onComplete: (err: Error, data: any) => void) => void): void; + register(map: Record, onComplete: (err: Error, data: any) => void) => void>): void; + /** + !#en + Use corresponding handler to parse file + + !#zh + 使用对应的handler来解析文件 + @param id The id of file + @param file File + @param type The corresponding type of file, likes '.jpg'. + @param options Some optional paramters will be transferred to the corresponding handler. + @param onComplete callback when finishing downloading + + @example + ```js + downloader.downloadFile('test.jpg', {responseType: 'blob'}, null, (err, file) => { + parser.parse('test.jpg', file, '.jpg', null, (err, img) => console.log(err)); + }); + ``` + */ + parse(id: string, file: any, type: string, options: Record, onComplete: (err: Error, content: any) => void): void; + } + /** !#en + Pipeline can execute the task for some effect. + + !#zh + 管线能执行任务达到某个效果 */ + export class Pipeline { + /** !#en + The id of pipeline + + !#zh + 管线的 id */ + id: number; + /** !#en + The name of pipeline + + !#zh + 管线的名字 */ + name: string; + /** !#en + All pipes of pipeline + + !#zh + 所有的管道 */ + pipes: Function[]; + /** + !#en + Create a new pipeline + + !#zh + 创建一个管线 + @param name The name of pipeline + @param funcs The array of pipe, every pipe must be function which take two parameters, the first is a `Task` flowed in pipeline, the second is complete callback + + @example + ```js + var pipeline = new Pipeline('download', [ + (task, done) => { + var url = task.input; + cc.assetManager.downloader.downloadFile(url, null, null, (err, result) => { + task.output = result; + done(err); + }); + }, + (task, done) => { + var text = task.input; + var json = JSON.stringify(text); + task.output = json; + done(); + } + ]); + ``` + */ + constructor(name: string, funcs: Array<(task: Task, done?: (err: Error) => void) => void>); + /** + !#en + At specific point insert a new pipe to pipeline + + !#zh + 在某个特定的点为管线插入一个新的 pipe + @param func The new pipe + @param index The specific point you want to insert at. + + @example + ```js + var pipeline = new Pipeline('test', []); + pipeline.insert((task, done) => { + // do something + done(); + }, 0); + ``` + */ + insert(func: (task: Task, callback?: (err: Error) => void) => void, index: number): Pipeline; + /** + !#en + Append a new pipe to the pipeline + + !#zh + 添加一个管道到管线中 + @param func The new pipe + + @example + ```js + var pipeline = new Pipeline('test', []); + pipeline.append((task, done) => { + // do something + done(); + }); + ``` + */ + append(func: (task: Task, callback?: (err: Error) => void) => void): Pipeline; + /** + !#en + Remove pipe which at specific point + + !#zh + 移除特定位置的管道 + @param index The specific point + + @example + ```js + var pipeline = new Pipeline('test', (task, done) => { + // do something + done(); + }); + pipeline.remove(0); + ``` + */ + remove(index: number): Pipeline; + /** + !#en + Execute task synchronously + + !#zh + 同步执行任务 + @param task The task will be executed + + @example + ```js + var pipeline = new Pipeline('sync', [(task) => { + let input = task.input; + task.output = doSomething(task.input); + }]); + + var task = new Task({input: 'test'}); + console.log(pipeline.sync(task)); + ``` + */ + sync(task: Task): any; + /** + !#en + Execute task asynchronously + + !#zh + 异步执行任务 + @param task The task will be executed + + @example + ```js + var pipeline = new Pipeline('sync', [(task, done) => { + let input = task.input; + task.output = doSomething(task.input); + done(); + }]); + var task = new Task({input: 'test', onComplete: (err, result) => console.log(result)}); + pipeline.async(task); + ``` + */ + async(task: Task): void; + } + /** !#en + A collection of information about a request + + !#zh + 请求的相关信息集合 */ + export class RequestItem { + /** !#en + The uuid of request + + !#zh + 请求资源的uuid */ + uuid: string; + /** !#en + The final url of request + + !#zh + 请求的最终url */ + url: string; + /** !#en + The extension name of asset + + !#zh + 资源的扩展名 */ + ext: string; + /** !#en + The content of asset + + !#zh + 资源的内容 */ + content: any; + /** !#en + The file of asset + + !#zh + 资源的文件 */ + file: any; + /** !#en + The information of asset + + !#zh + 资源的相关信息 */ + info: any; + /** !#en + Whether or not it is native asset + + !#zh + 资源是否是原生资源 */ + isNative: boolean; + /** !#en + Custom options + + !#zh + 自定义参数 */ + options: any; + /** + !#en + Create a request item + + !#zh + 创建一个 request item + */ + constructor(); + /** !#en + The id of request, combined from uuid and isNative + + !#zh + 请求的 id, 由 uuid 和 isNative 组合而成 */ + id: string; + /** + !#en + Recycle this for reuse + + !#zh + 回收 requestItem 用于复用 + */ + recycle(): void; + /** + !#en + Create a new request item from pool + + !#zh + 从对象池中创建 requestItem + */ + static create(): RequestItem; + } + /** !#en + The builtin bundles + + !#zh + 内置 bundle */ + export enum BuiltinBundleName { + RESOURCES = 0, + INTERNAL = 0, + MAIN = 0, + START_SCENE = 0, + } + /** !#en + Task is used to run in the pipeline for some effect + + !#zh + 任务用于在管线中运行以达成某种效果 */ + export class Task { + /** !#en + The id of task + + !#zh + 任务id */ + id: number; + /** !#en + The callback when task is completed + + !#zh + 完成回调 */ + onComplete: Function; + /** !#en + The callback of progression + + !#zh + 进度回调 */ + onProgress: Function; + /** !#en + The callback when something goes wrong + + !#zh + 错误回调 */ + onError: Function; + /** !#en + The source of task + + !#zh + 任务的源 */ + source: any; + /** !#en + The output of task + + !#zh + 任务的输出 */ + output: any; + /** !#en + The input of task + + !#zh + 任务的输入 */ + input: any; + /** !#en + The progression of task + + !#zh + 任务的进度 */ + progress: any; + /** !#en + Custom options + + !#zh + 自定义参数 */ + options: any; + /** + !#en + Create a new Task + + !#zh + 创建一个任务 + @param options Some optional paramters + */ + constructor(options?: {onComplete?: (err: Error, result: any) => void, onError?: () => void, onProgress?: Function, input: any, progress?: any, options?: Record}); + /** + !#en + Set paramters of this task + + !#zh + 设置任务的参数 + @param options Some optional paramters + + @example + ```js + var task = new Task(); + task.set({input: ['test'], onComplete: (err, result) => console.log(err), onProgress: (finish, total) => console.log(finish / total)}); + ``` + */ + set(options?: {onComplete?: (err: Error, result: any) => void, onError?: () => void, onProgress?: Function, input: any, progress?: any, options?: Record}): void; + /** + !#en + Dispatch event + + !#zh + 发布事件 + @param event The event name + @param param1 Parameter 1 + @param param2 Parameter 2 + @param param3 Parameter 3 + @param param4 Parameter 4 + + @example + ```js + var task = Task.create(); + Task.onComplete = (msg) => console.log(msg); + Task.dispatch('complete', 'hello world'); + ``` + */ + dispatch(event: string, param1?: any, param2?: any, param3?: any, param4?: any): void; + /** + !#en + Recycle this for reuse + + !#zh + 回收 task 用于复用 + */ + recycle(): void; + /** !#en + Whether or not this task is completed + + !#zh + 此任务是否已经完成 */ + isFinish: boolean; + /** + !#en + Create a new task from pool + + !#zh + 从对象池中创建 task + @param options Some optional paramters + */ + static create(options?: {onComplete?: (err: Error, result: any) => void, onError?: () => void, onProgress?: Function, input: any, progress?: any, options?: Record}): Task; + } +} + +/** Some helpful utilities */ +declare namespace cc.geomUtils { + /** + !#en + the distance between a point and a plane + !#zh + 计算点和平面之间的距离。 + @param point point + @param plane plane + */ + export function point_plane(point: cc.Vec3, plane: cc.Plane): number; + /** + !#en + the closest point on plane to a given point + !#zh + 计算平面上最接近给定点的点。 + @param out Closest point + @param point Given point + @param plane plane + */ + export function pt_point_plane(out: cc.Vec3, point: cc.Vec3, plane: cc.Plane): cc.Vec3; + /** + !#en + the closest point on aabb to a given point + !#zh + 计算 aabb 上最接近给定点的点。 + @param out Closest point. + @param point Given point. + @param aabb Align the axis around the box. + */ + export function pt_point_aabb(out: cc.Vec3, point: cc.Vec3, aabb: cc.Aabb): cc.Vec3; + /** + !#en + the closest point on obb to a given point + !#zh + 计算 obb 上最接近给定点的点。 + @param out Closest point + @param point Given point + @param obb Direction box + */ + export function pt_point_obb(out: cc.Vec3, point: cc.Vec3, obb: cc.Obb): cc.Vec3; +} + +/** !#en Some JavaScript decorators which can be accessed with "cc._decorator". +!#zh 一些 JavaScript 装饰器,目前可以通过 "cc._decorator" 来访问。 +(这些 API 仍不完全稳定,有可能随着 JavaScript 装饰器的标准实现而调整) */ +declare namespace cc._decorator { + /** + !#en + Declare the standard [ES6 Class](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes) + as CCClass, please see [Class](../../../manual/en/scripting/class.html) for details. + !#zh + 将标准写法的 [ES6 Class](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes) 声明为 CCClass,具体用法请参阅[类型定义](../../../manual/zh/scripting/class.html)。 + @param name The class name used for serialization. + + @example + ```js + const {ccclass} = cc._decorator; + + // define a CCClass, omit the name + @ccclass + class NewScript extends cc.Component { + // ... + } + + // define a CCClass with a name + @ccclass('LoginData') + class LoginData { + // ... + } + ``` + */ + export function ccclass(name?: string): Function; + export function ccclass(_class?: Function): void; + /** + !#en + Declare property for [CCClass](../../../manual/en/scripting/reference/attributes.html). + !#zh + 定义 [CCClass](../../../manual/zh/scripting/reference/attributes.html) 所用的属性。 + @param options an object with some property attributes + + @example + ```js + const {ccclass, property} = cc._decorator; + + @ccclass + class NewScript extends cc.Component { + @property({ + type: cc.Node + }) + targetNode1 = null; + + @property(cc.Node) + targetNode2 = null; + + @property(cc.Button) + targetButton = null; + + @property + _width = 100; + + @property + get width () { + return this._width; + } + + @property + set width (value) { + this._width = value; + } + + @property + offset = new cc.Vec2(100, 100); + + @property(cc.Vec2) + offsets = []; + + @property(cc.SpriteFrame) + frame = null; + } + + // above is equivalent to (上面的代码相当于): + + var NewScript = cc.Class({ + properties: { + targetNode1: { + default: null, + type: cc.Node + }, + + targetNode2: { + default: null, + type: cc.Node + }, + + targetButton: { + default: null, + type: cc.Button + }, + + _width: 100, + + width: { + get () { + return this._width; + }, + set (value) { + this._width = value; + } + }, + + offset: new cc.Vec2(100, 100) + + offsets: { + default: [], + type: cc.Vec2 + } + + frame: { + default: null, + type: cc.SpriteFrame + }, + } + }); + ``` + */ + export function property(options?: {type?: any; visible?: boolean|(() => boolean); displayName?: string; tooltip?: string; multiline?: boolean; readonly?: boolean; min?: number; max?: number; step?: number; range?: number[]; slide?: boolean; serializable?: boolean; formerlySerializedAs?: string; editorOnly?: boolean; override?: boolean; animatable?: boolean} | any[]|Function|cc.ValueType|number|string|boolean): Function; + export function property(_target: Object, _key: any, _desc?: any): void; + /** + !#en + Makes a CCClass that inherit from component execute in edit mode.
+ By default, all components are only executed in play mode, + which means they will not have their callback functions executed while the Editor is in edit mode. + !#zh + 允许继承自 Component 的 CCClass 在编辑器里执行。
+ 默认情况下,所有 Component 都只会在运行时才会执行,也就是说它们的生命周期回调不会在编辑器里触发。 + + @example + ```js + const {ccclass, executeInEditMode} = cc._decorator; + + @ccclass + @executeInEditMode + class NewScript extends cc.Component { + // ... + } + ``` + */ + export function executeInEditMode(): Function; + export function executeInEditMode(_class: Function): void; + /** + !#en + Automatically add required component as a dependency for the CCClass that inherit from component. + !#zh + 为声明为 CCClass 的组件添加依赖的其它组件。当组件添加到节点上时,如果依赖的组件不存在,引擎将会自动将依赖组件添加到同一个节点,防止脚本出错。该设置在运行时同样有效。 + @param requiredComponent requiredComponent + + @example + ```js + const {ccclass, requireComponent} = cc._decorator; + + @ccclass + @requireComponent(cc.Sprite) + class SpriteCtrl extends cc.Component { + // ... + } + ``` + */ + export function requireComponent(requiredComponent: typeof cc.Component): Function; + /** + !#en + The menu path to register a component to the editors "Component" menu. Eg. "Rendering/CameraCtrl". + !#zh + 将当前组件添加到组件菜单中,方便用户查找。例如 "Rendering/CameraCtrl"。 + @param path The path is the menu represented like a pathname. + For example the menu could be "Rendering/CameraCtrl". + + @example + ```js + const {ccclass, menu} = cc._decorator; + + @ccclass + @menu("Rendering/CameraCtrl") + class NewScript extends cc.Component { + // ... + } + ``` + */ + export function menu(path: string): Function; + /** + !#en + The execution order of lifecycle methods for Component. + Those less than 0 will execute before while those greater than 0 will execute after. + The order will only affect onLoad, onEnable, start, update and lateUpdate while onDisable and onDestroy will not be affected. + !#zh + 设置脚本生命周期方法调用的优先级。优先级小于 0 的组件将会优先执行,优先级大于 0 的组件将会延后执行。优先级仅会影响 onLoad, onEnable, start, update 和 lateUpdate,而 onDisable 和 onDestroy 不受影响。 + @param order The execution order of lifecycle methods for Component. Those less than 0 will execute before while those greater than 0 will execute after. + + @example + ```js + const {ccclass, executionOrder} = cc._decorator; + + @ccclass + @executionOrder(1) + class CameraCtrl extends cc.Component { + // ... + } + ``` + */ + export function executionOrder(order: number): Function; + /** + !#en + Prevents Component of the same type (or subtype) to be added more than once to a Node. + !#zh + 防止多个相同类型(或子类型)的组件被添加到同一个节点。 + + @example + ```js + const {ccclass, disallowMultiple} = cc._decorator; + + @ccclass + @disallowMultiple + class CameraCtrl extends cc.Component { + // ... + } + ``` + */ + export function disallowMultiple(): Function; + export function disallowMultiple(_class: Function): void; + /** + !#en + If specified, the editor's scene view will keep updating this node in 60 fps when it is selected, otherwise, it will update only if necessary.
+ This property is only available if executeInEditMode is true. + !#zh + 当指定了 "executeInEditMode" 以后,playOnFocus 可以在选中当前组件所在的节点时,提高编辑器的场景刷新频率到 60 FPS,否则场景就只会在必要的时候进行重绘。 + + @example + ```js + const {ccclass, playOnFocus, executeInEditMode} = cc._decorator; + + @ccclass + @executeInEditMode + @playOnFocus + class CameraCtrl extends cc.Component { + // ... + } + ``` + */ + export function playOnFocus(): Function; + export function playOnFocus(_class: Function): void; + /** + !#en + Specifying the url of the custom html to draw the component in **Properties**. + !#zh + 自定义当前组件在 **属性检查器** 中渲染时所用的网页 url。 + @param url url + + @example + ```js + const {ccclass, inspector} = cc._decorator; + + @ccclass + @inspector("packages://inspector/inspectors/comps/camera-ctrl.js") + class NewScript extends cc.Component { + // ... + } + ``` + */ + export function inspector(path: string): Function; + /** + !#en + The custom documentation URL. + !#zh + 指定当前组件的帮助文档的 url,设置过后,在 **属性检查器** 中就会出现一个帮助图标,用户点击将打开指定的网页。 + @param url url + + @example + ```js + const {ccclass, help} = cc._decorator; + + @ccclass + @help("app://docs/html/components/spine.html") + class NewScript extends cc.Component { + // ... + } + ``` + */ + export function help(path: string): Function; + /** + NOTE:
+ The old mixins implemented in cc.Class(ES5) behaves exact the same as multiple inheritance. + But since ES6, class constructor can't be function-called and class methods become non-enumerable, + so we can not mix in ES6 Classes.
+ See:
+ [https://esdiscuss.org/topic/traits-are-now-impossible-in-es6-until-es7-since-rev32](https://esdiscuss.org/topic/traits-are-now-impossible-in-es6-until-es7-since-rev32)
+ One possible solution (but IDE unfriendly):
+ [http://justinfagnani.com/2015/12/21/real-mixins-with-javascript-classes](http://justinfagnani.com/2015/12/21/real-mixins-with-javascript-classes/)
+
+ NOTE:
+ You must manually call mixins constructor, this is different from cc.Class(ES5). + @param ctor constructors to mix, only support ES5 constructors or classes defined by using `cc.Class`, + not support ES6 Classes. + + @example + ```js + const {ccclass, mixins} = cc._decorator; + + class Animal { ... } + + const Fly = cc.Class({ + constructor () { ... } + }); + + @ccclass + @mixins(cc.EventTarget, Fly) + class Bird extends Animal { + constructor () { + super(); + + // You must manually call mixins constructor, this is different from cc.Class(ES5) + cc.EventTarget.call(this); + Fly.call(this); + } + // ... + } + ``` + */ + export function mixins(ctor: Function, ...rest: Function[]): Function; +} + +/** !#en This module provides some JavaScript utilities. All members can be accessed with `cc.js`. +!#zh 这个模块封装了 JavaScript 相关的一些实用函数,你可以通过 `cc.js` 来访问这个模块。 */ +declare namespace cc.js { + /** + Check the obj whether is number or not + If a number is created by using 'new Number(10086)', the typeof it will be "object"... + Then you can use this function if you care about this case. + @param obj obj + */ + export function isNumber(obj: any): boolean; + /** + Check the obj whether is string or not. + If a string is created by using 'new String("blabla")', the typeof it will be "object"... + Then you can use this function if you care about this case. + @param obj obj + */ + export function isString(obj: any): boolean; + /** + Copy all properties not defined in obj from arguments[1...n] + @param obj object to extend its properties + @param sourceObj source object to copy properties from + */ + export function addon(obj: any, ...sourceObj: any[]): any; + /** + copy all properties from arguments[1...n] to obj + @param obj obj + @param sourceObj sourceObj + */ + export function mixin(obj: any, ...sourceObj: any[]): any; + /** + Derive the class from the supplied base class. + Both classes are just native javascript constructors, not created by cc.Class, so + usually you will want to inherit using {{#crossLink "cc/Class:method"}}cc.Class {{/crossLink}} instead. + @param cls cls + @param base the baseclass to inherit + */ + export function extend(cls: Function, base: Function): Function; + /** + Get super class + @param ctor the constructor of subclass + */ + export function getSuper(ctor: Function): Function; + /** + Checks whether subclass is child of superclass or equals to superclass + @param subclass subclass + @param superclass superclass + */ + export function isChildClassOf(subclass: Function, superclass: Function): boolean; + /** + Removes all enumerable properties from object + @param obj obj + */ + export function clear(obj: any): void; + /** + Checks whether obj is an empty object + @param obj obj + */ + export function isEmptyObject(obj: any): boolean; + /** + Get property descriptor in object and all its ancestors + @param obj obj + @param name name + */ + export function getPropertyDescriptor(obj: any, name: string): any; + /** + Define value, just help to call Object.defineProperty.
+ The configurable will be true. + @param obj obj + @param prop prop + @param value value + @param writable writable + @param enumerable enumerable + */ + export function value(obj: any, prop: string, value: any, writable?: boolean, enumerable?: boolean): void; + /** + Define get set accessor, just help to call Object.defineProperty(...) + @param obj obj + @param prop prop + @param getter getter + @param setter setter + @param enumerable enumerable + @param configurable configurable + */ + export function getset(obj: any, prop: string, getter: Function, setter?: Function, enumerable?: boolean, configurable?: boolean): void; + /** + Define get accessor, just help to call Object.defineProperty(...) + @param obj obj + @param prop prop + @param getter getter + @param enumerable enumerable + @param configurable configurable + */ + export function get(obj: any, prop: string, getter: Function, enumerable?: boolean, configurable?: boolean): void; + /** + Define set accessor, just help to call Object.defineProperty(...) + @param obj obj + @param prop prop + @param setter setter + @param enumerable enumerable + @param configurable configurable + */ + export function set(obj: any, prop: string, setter: Function, enumerable?: boolean, configurable?: boolean): void; + /** + Get class name of the object, if object is just a {} (and which class named 'Object'), it will return "". + (modified from the code from this stackoverflow post) + @param objOrCtor instance or constructor + */ + export function getClassName(objOrCtor: any|Function): string; + /** !#en All classes registered in the engine, indexed by ID. + !#zh 引擎中已注册的所有类型,通过 ID 进行索引。 */ + export var _registeredClassIds: any; + /** !#en All classes registered in the engine, indexed by name. + !#zh 引擎中已注册的所有类型,通过名称进行索引。 */ + export var _registeredClassNames: any; + /** + Register the class by specified name manually + @param className className + @param constructor constructor + */ + export function setClassName(className: string, constructor: Function): void; + /** + Unregister a class from fireball. + + If you dont need a registered class anymore, you should unregister the class so that Fireball will not keep its reference anymore. + Please note that its still your responsibility to free other references to the class. + @param constructor the class you will want to unregister, any number of classes can be added + */ + export function unregisterClass(...constructor: Function[]): void; + /** + Get the registered class by name + @param classname classname + */ + export function getClassByName(classname: string): Function; + /** + Defines a polyfill field for deprecated codes. + @param obj YourObject or YourClass.prototype + @param obsoleted "OldParam" or "YourClass.OldParam" + @param newExpr "NewParam" or "YourClass.NewParam" + @param writable writable + */ + export function obsolete(obj: any, obsoleted: string, newExpr: string, writable?: boolean): void; + /** + Defines all polyfill fields for obsoleted codes corresponding to the enumerable properties of props. + @param obj YourObject or YourClass.prototype + @param objName "YourObject" or "YourClass" + @param props props + @param writable writable + */ + export function obsoletes(obj: any, objName: any, props: any, writable?: boolean): void; + /** + A string tool to construct a string with format string. + @param msg A JavaScript string containing zero or more substitution strings (%s). + @param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output. + + @example + ```js + cc.js.formatStr("a: %s, b: %s", a, b); + cc.js.formatStr(a, b, c); + ``` + */ + export function formatStr(msg: string|any, ...subst: any[]): string; + /** + !#en + A simple wrapper of `Object.create(null)` which ensures the return object have no prototype (and thus no inherited members). So we can skip `hasOwnProperty` calls on property lookups. It is a worthwhile optimization than the `{}` literal when `hasOwnProperty` calls are necessary. + !#zh + 该方法是对 `Object.create(null)` 的简单封装。`Object.create(null)` 用于创建无 prototype (也就无继承)的空对象。这样我们在该对象上查找属性时,就不用进行 `hasOwnProperty` 判断。在需要频繁判断 `hasOwnProperty` 时,使用这个方法性能会比 `{}` 更高。 + @param forceDictMode Apply the delete operator to newly created map object. This causes V8 to put the object in "dictionary mode" and disables creation of hidden classes which are very expensive for objects that are constantly changing shape. + */ + export function createMap(forceDictMode?: boolean): any; + /** undefined */ + export class array { + /** + Removes the array item at the specified index. + @param array array + @param index index + */ + static removeAt(array: any[], index: number): void; + /** + Removes the array item at the specified index. + It's faster but the order of the array will be changed. + @param array array + @param index index + */ + static fastRemoveAt(array: any[], index: number): void; + /** + Removes the first occurrence of a specific object from the array. + @param array array + @param value value + */ + static remove(array: any[], value: any): boolean; + /** + Removes the first occurrence of a specific object from the array. + It's faster but the order of the array will be changed. + @param array array + @param value value + */ + static fastRemove(array: any[], value: number): void; + /** + Verify array's Type + @param array array + @param type type + */ + static verifyType(array: any[], type: Function): boolean; + /** + Removes from array all values in minusArr. For each Value in minusArr, the first matching instance in array will be removed. + @param array Source Array + @param minusArr minus Array + */ + static removeArray(array: any[], minusArr: any[]): void; + /** + Inserts some objects at index + @param array array + @param addObjs addObjs + @param index index + */ + static appendObjectsAt(array: any[], addObjs: any[], index: number): any[]; + /** + Determines whether the array contains a specific value. + @param array array + @param value value + */ + static contains(array: any[], value: any): boolean; + /** + Copy an array's item to a new array (its performance is better than Array.slice) + @param array array + */ + static copy(array: any[]): any[]; + } + /** !#en + A fixed-length object pool designed for general type.
+ The implementation of this object pool is very simple, + it can helps you to improve your game performance for objects which need frequent release and recreate operations
+ !#zh + 长度固定的对象缓存池,可以用来缓存各种对象类型。
+ 这个对象池的实现非常精简,它可以帮助您提高游戏性能,适用于优化对象的反复创建和销毁。 */ + export class Pool { + /** + !#en + Constructor for creating an object pool for the specific object type. + You can pass a callback argument for process the cleanup logic when the object is recycled. + !#zh + 使用构造函数来创建一个指定对象类型的对象池,您可以传递一个回调函数,用于处理对象回收时的清理逻辑。 + @param cleanupFunc the callback method used to process the cleanup logic when the object is recycled. + @param size initializes the length of the array + */ + constructor(cleanupFunc: (obj: any) => void, size: number); + constructor(size: number); + /** + !#en + Get and initialize an object from pool. This method defaults to null and requires the user to implement it. + !#zh + 获取并初始化对象池中的对象。这个方法默认为空,需要用户自己实现。 + @param params parameters to used to initialize the object + */ + get(...params: any[]): any; + /** !#en + The current number of available objects, the default is 0, it will gradually increase with the recycle of the object, + the maximum will not exceed the size specified when the constructor is called. + !#zh + 当前可用对象数量,一开始默认是 0,随着对象的回收会逐渐增大,最大不会超过调用构造函数时指定的 size。 */ + count: number; + /** + !#en + Get an object from pool, if no available object in the pool, null will be returned. + !#zh + 获取对象池中的对象,如果对象池没有可用对象,则返回空。 + */ + _get(): any; + /** + !#en Put an object into the pool. + !#zh 向对象池返还一个不再需要的对象。 + */ + put(): void; + /** + !#en Resize the pool. + !#zh 设置对象池容量。 + */ + resize(): void; + } +} + +/** !#en A basic module for creating vertex data for 3D objects. You can access this module by `cc.primitive`. +!#zh 一个创建 3D 物体顶点数据的基础模块,你可以通过 `cc.primitive` 来访问这个模块。 */ +declare namespace cc.primitive { + /** + !#en Create box vertex data + !#zh 创建长方体顶点数据 + @param width width + @param height height + @param length length + @param opts opts + */ + export function box(width: number, height: number, length: number, opts: {widthSegments: number; heightSegments: number; lengthSegments: number; }): cc.VertexData; + /** + !#en Create cone vertex data + !#zh 创建圆锥体顶点数据 + @param radius radius + @param height height + @param opts opts + */ + export function cone(radius: number, height: number, opts: {radialSegments: number; heightSegments: number; capped: boolean; arc: number; }): cc.VertexData; + /** + !#en Create cylinder vertex data + !#zh 创建圆柱体顶点数据 + @param radiusTop radiusTop + @param radiusBottom radiusBottom + @param height height + @param opts opts + */ + export function cylinder(radiusTop: number, radiusBottom: number, height: number, opts: {radialSegments: number; heightSegments: number; capped: boolean; arc: number; }): cc.VertexData; + /** + !#en Create plane vertex data + !#zh 创建平台顶点数据 + @param width width + @param length length + @param opts opts + */ + export function plane(width: number, length: number, opts: {widthSegments: number; lengthSegments: number; }): cc.VertexData; + /** + !#en Create quad vertex data + !#zh 创建面片顶点数据 + */ + export function quad(): cc.VertexData; + /** + !#en Create sphere vertex data + !#zh 创建球体顶点数据 + @param radius radius + @param opts opts + */ + export function sphere(radius: number, opts: {segments: number; }): cc.VertexData; + /** + !#en Create torus vertex data + !#zh 创建圆环顶点数据 + @param radius radius + @param tube tube + @param opts opts + */ + export function torus(radius: number, tube: number, opts: {radialSegments: number; tubularSegments: number; arc: number; }): cc.VertexData; + /** + !#en Create capsule vertex data + !#zh 创建胶囊体顶点数据 + @param radiusTop radiusTop + @param radiusBottom radiusBottom + @param height height + @param opts opts + */ + export function capsule(radiusTop: number, radiusBottom: number, height: number, opts: {sides: number; heightSegments: number; capped: boolean; arc: number; }): cc.VertexData; + /** + !#en Create polyhedron vertex data + !#zh 创建多面体顶点数据 + @param type type + @param Size Size + @param opts opts + */ + export function polyhedron(type: cc.primitive.PolyhedronType, Size: number, opts: {sizeX: number; sizeY: number; sizeZ: number; }): cc.VertexData; +} + +declare let CC_JSB: boolean +declare let CC_NATIVERENDERER: boolean +declare let CC_EDITOR: boolean + +declare let cc: { + // polyfills: { + // destroyObject? (object: any): void; + // }; + [x: string]: any; +} + +// https://medium.com/dailyjs/typescript-create-a-condition-based-subset-types-9d902cea5b8c +type FlagExcludedType = { [Key in keyof Base]: Base[Key] extends Type ? never : Key }; +type AllowedNames = FlagExcludedType[keyof Base]; +type KeyPartial = { [P in K]?: T[P] }; +type OmitType = KeyPartial>; +type ConstructorType = OmitType; + +declare interface IWritableArrayLike { + readonly length: number; + [index: number]: T; +} + +declare let module: { + exports: object +} + + +declare interface Math { + sign(v: number); +} + +declare interface Object { + assign(target: {}, source: {}); +} + +/** + * @module cc.AssetManager + */ + +declare namespace cc.AssetManager { + /** + * !#en + * Cache manager is a module which controls all caches downloaded from server in non-web platform, it is a singleton + * All member can be accessed with `cc.assetManager.cacheManager`. + * + * !#zh + * 缓存管理器是一个模块,在非 WEB 平台上,用于管理所有从服务器上下载下来的缓存,这是一个单例,所有成员能通过 `cc.assetManager.cacheManager` 访问。 + * + * @class CacheManager + */ + class CacheManager { + /** + * !#en + * The name of cacheDir + * + * !#zh + * 缓存目录的名称 + * + * @property cacheDir + * @type {String} + * @default 'gamecaches' + */ + public cacheDir: String; + + /** + * !#en + * Whether or not cache asset into user's storage space, this property only works on mini-game platforms + * + * !#zh + * 是否缓存资源到用户存储空间,此属性只在小游戏平台有效 + * + * @property cacheEnabled + * @type {Boolean} + * @default true + */ + public cacheEnabled: Boolean; + + /** + * !#en + * Whether or not auto clear cache when storage ran out, this property only works on mini-game platforms + * + * !#zh + * 是否在存储空间满了后自动清理缓存,此属性只在小游戏平台有效 + * + * @property autoClear + * @type {Boolean} + * @default true + */ + public autoClear: Boolean; + + /** + * !#en + * The interval between caching resources, this property only works on mini-game platforms + * + * !#zh + * 缓存资源的间隔时间,此属性只在小游戏平台有效 + * + * @property cacheInterval + * @type {Number} + * @default 500 + */ + public cacheInterval: Number; + + /** + * !#en + * The interval between deleting resources, when you use `cleanLRU`, the resources will be deleted as this interval + * + * !#zh + * 清理资源的间隔时间,当你使用 `cleanLRU` 时,资源将以此间隔被删除 + * + * @property deleteInterval + * @type {Number} + * @default 500 + */ + public deleteInterval: Number; + + /** + * !#en + * Get cached path with origin url + * + * !#zh + * 通过原始 url 获取缓存后的路径 + * + * @method getCache + * @param {string} originUrl + * @returns {String} The cached path + */ + public getCache (originUrl: string): string; + + /** + * !#en + * Get temporary path with origin url, this method only works on mini-game platforms + * + * !#zh + * 通过原始 url 获取临时文件的路径,此方法只在小游戏平台有效 + * + * @method getTemp + * @param {string} originUrl + * @returns {String} The temp path + */ + public getTemp (originUrl: string): string; + + /** + * !#en + * Clear all caches, please use with caution, If necessary, we recommend using it before the game is launched + * + * !#zh + * 清空所有缓存,请谨慎使用,如果必要的话,我们建议在游戏启动之前使用 + * + * @method clearCache + */ + public clearCache (): void; + + /** + * !#en + * Clear part of caches with LRU strategy + * + * !#zh + * 使用 LRU 策略清空部分缓存 + * + * @method clearLRU + */ + public clearLRU (): void; + + /** + * !#en + * Remove cache with origin url + * + * !#zh + * 通过原始 url 移除缓存 + * + * @method removeCache + */ + public removeCache (originUrl: string): void; + } +} + +type FloatArray = Float64Array | Float32Array; + +interface IColorLike { + r: number; + g: number; + b: number; + a: number; + _val: number; + +} + +interface IMat3Like { + m: FloatArray +} + +interface IMat4Like { + m: FloatArray +} + +interface IQuatLike { + x: number; + y: number; + z: number; + w: number; +} + +interface IRectLike { + x: number; + y: number; + width: number; + height: number; +} + +interface ISizeLike { + width: number; + height: number; +} + +interface IVec2Like { + x: number; + y: number; +} + +interface IVec3Like { + x: number; + y: number; + z: number; +} + +interface IVec4Like { + x: number; + y: number; + z: number; + w: number; +} +declare namespace dragonBones { + /** + * @internal + * @private + */ + const webAssemblyModule: { + HEAP16: Int16Array; + _malloc(byteSize: number): number; + _free(pointer: number): void; + setDataBinary(data: DragonBonesData, binaryPointer: number, intBytesLength: number, floatBytesLength: number, frameIntBytesLength: number, frameFloatBytesLength: number, frameBytesLength: number, timelineBytesLength: number): void; + }; +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + const enum BinaryOffset { + WeigthBoneCount = 0, + WeigthFloatOffset = 1, + WeigthBoneIndices = 2, + MeshVertexCount = 0, + MeshTriangleCount = 1, + MeshFloatOffset = 2, + MeshWeightOffset = 3, + MeshVertexIndices = 4, + TimelineScale = 0, + TimelineOffset = 1, + TimelineKeyFrameCount = 2, + TimelineFrameValueCount = 3, + TimelineFrameValueOffset = 4, + TimelineFrameOffset = 5, + FramePosition = 0, + FrameTweenType = 1, + FrameTweenEasingOrCurveSampleCount = 2, + FrameCurveSamples = 3, + DeformMeshOffset = 0, + DeformCount = 1, + DeformValueCount = 2, + DeformValueOffset = 3, + DeformFloatOffset = 4, + } + /** + * @internal + * @private + */ + const enum ArmatureType { + Armature = 0, + MovieClip = 1, + Stage = 2, + } + /** + * @internal + * @private + */ + const enum BoneType { + Bone = 0, + Surface = 1, + } + /** + * @private + */ + const enum DisplayType { + Image = 0, + Armature = 1, + Mesh = 2, + BoundingBox = 3, + } + /** + * - Bounding box type. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 边界框类型。 + * @version DragonBones 5.0 + * @language zh_CN + */ + const enum BoundingBoxType { + Rectangle = 0, + Ellipse = 1, + Polygon = 2, + } + /** + * @internal + * @private + */ + const enum ActionType { + Play = 0, + Frame = 10, + Sound = 11, + } + /** + * @internal + * @private + */ + const enum BlendMode { + Normal = 0, + Add = 1, + Alpha = 2, + Darken = 3, + Difference = 4, + Erase = 5, + HardLight = 6, + Invert = 7, + Layer = 8, + Lighten = 9, + Multiply = 10, + Overlay = 11, + Screen = 12, + Subtract = 13, + } + /** + * @internal + * @private + */ + const enum TweenType { + None = 0, + Line = 1, + Curve = 2, + QuadIn = 3, + QuadOut = 4, + QuadInOut = 5, + } + /** + * @internal + * @private + */ + const enum TimelineType { + Action = 0, + ZOrder = 1, + BoneAll = 10, + BoneTranslate = 11, + BoneRotate = 12, + BoneScale = 13, + Surface = 50, + SlotDisplay = 20, + SlotColor = 21, + SlotFFD = 22, + IKConstraint = 30, + AnimationTime = 40, + AnimationWeight = 41, + } + /** + * - Offset mode. + * @version DragonBones 5.5 + * @language en_US + */ + /** + * - 偏移模式。 + * @version DragonBones 5.5 + * @language zh_CN + */ + const enum OffsetMode { + None = 0, + Additive = 1, + Override = 2, + } + /** + * - Animation fade out mode. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画淡出模式。 + * @version DragonBones 4.5 + * @language zh_CN + */ + const enum AnimationFadeOutMode { + /** + * - Do not fade out of any animation states. + * @language en_US + */ + /** + * - 不淡出任何的动画状态。 + * @language zh_CN + */ + None = 0, + /** + * - Fade out the animation states of the same layer. + * @language en_US + */ + /** + * - 淡出同层的动画状态。 + * @language zh_CN + */ + SameLayer = 1, + /** + * - Fade out the animation states of the same group. + * @language en_US + */ + /** + * - 淡出同组的动画状态。 + * @language zh_CN + */ + SameGroup = 2, + /** + * - Fade out the animation states of the same layer and group. + * @language en_US + */ + /** + * - 淡出同层并且同组的动画状态。 + * @language zh_CN + */ + SameLayerAndGroup = 3, + /** + * - Fade out of all animation states. + * @language en_US + */ + /** + * - 淡出所有的动画状态。 + * @language zh_CN + */ + All = 4, + /** + * - Does not replace the animation state with the same name. + * @language en_US + */ + /** + * - 不替换同名的动画状态。 + * @language zh_CN + */ + Single = 5, + } + /** + * @private + */ + interface Map { + [key: string]: T; + } + /** + * @private + */ + class DragonBones { + static readonly VERSION: string; + static yDown: boolean; + static debug: boolean; + static debugDraw: boolean; + static webAssembly: boolean; + private readonly _clock; + private readonly _events; + private readonly _objects; + private _eventManager; + constructor(eventManager: IEventDispatcher); + advanceTime(passedTime: number): void; + bufferEvent(value: EventObject): void; + bufferObject(object: BaseObject): void; + readonly clock: WorldClock; + readonly eventManager: IEventDispatcher; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The BaseObject is the base class for all objects in the DragonBones framework. + * All BaseObject instances are cached to the object pool to reduce the performance consumption of frequent requests for memory or memory recovery. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 基础对象,通常 DragonBones 的对象都继承自该类。 + * 所有基础对象的实例都会缓存到对象池,以减少频繁申请内存或内存回收的性能消耗。 + * @version DragonBones 4.5 + * @language zh_CN + */ + abstract class BaseObject { + private static _hashCode; + private static _defaultMaxCount; + private static readonly _maxCountMap; + private static readonly _poolsMap; + private static _returnObject(object); + static toString(): string; + /** + * - Set the maximum cache count of the specify object pool. + * @param objectConstructor - The specify class. (Set all object pools max cache count if not set) + * @param maxCount - Max count. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 设置特定对象池的最大缓存数量。 + * @param objectConstructor - 特定的类。 (不设置则设置所有对象池的最大缓存数量) + * @param maxCount - 最大缓存数量。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static setMaxCount(objectConstructor: (typeof BaseObject) | null, maxCount: number): void; + /** + * - Clear the cached instances of a specify object pool. + * @param objectConstructor - Specify class. (Clear all cached instances if not set) + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 清除特定对象池的缓存实例。 + * @param objectConstructor - 特定的类。 (不设置则清除所有缓存的实例) + * @version DragonBones 4.5 + * @language zh_CN + */ + static clearPool(objectConstructor?: (typeof BaseObject) | null): void; + /** + * - Get an instance of the specify class from object pool. + * @param objectConstructor - The specify class. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 从对象池中获取特定类的实例。 + * @param objectConstructor - 特定的类。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static borrowObject(objectConstructor: { + new (): T; + }): T; + /** + * - A unique identification number assigned to the object. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 分配给此实例的唯一标识号。 + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly hashCode: number; + private _isInPool; + /** + * @private + */ + protected abstract _onClear(): void; + /** + * - Clear the object and return it back to object pool。 + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 清除该实例的所有数据并将其返还对象池。 + * @version DragonBones 4.5 + * @language zh_CN + */ + returnToPool(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - 2D Transform matrix. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 2D 转换矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class Matrix { + /** + * - The value that affects the positioning of pixels along the x axis when scaling or rotating an image. + * @default 1.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 缩放或旋转图像时影响像素沿 x 轴定位的值。 + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + a: number; + /** + * - The value that affects the positioning of pixels along the y axis when rotating or skewing an image. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 旋转或倾斜图像时影响像素沿 y 轴定位的值。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + b: number; + /** + * - The value that affects the positioning of pixels along the x axis when rotating or skewing an image. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 旋转或倾斜图像时影响像素沿 x 轴定位的值。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + c: number; + /** + * - The value that affects the positioning of pixels along the y axis when scaling or rotating an image. + * @default 1.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 缩放或旋转图像时影响像素沿 y 轴定位的值。 + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + d: number; + /** + * - The distance by which to translate each point along the x axis. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 沿 x 轴平移每个点的距离。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + tx: number; + /** + * - The distance by which to translate each point along the y axis. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 沿 y 轴平移每个点的距离。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + ty: number; + /** + * @private + */ + constructor(a?: number, b?: number, c?: number, d?: number, tx?: number, ty?: number); + toString(): string; + /** + * @private + */ + copyFrom(value: Matrix): Matrix; + /** + * @private + */ + copyFromArray(value: Array, offset?: number): Matrix; + /** + * - Convert to unit matrix. + * The resulting matrix has the following properties: a=1, b=0, c=0, d=1, tx=0, ty=0. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 转换为单位矩阵。 + * 该矩阵具有以下属性:a=1、b=0、c=0、d=1、tx=0、ty=0。 + * @version DragonBones 3.0 + * @language zh_CN + */ + identity(): Matrix; + /** + * - Multiplies the current matrix with another matrix. + * @param value - The matrix that needs to be multiplied. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 将当前矩阵与另一个矩阵相乘。 + * @param value - 需要相乘的矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + concat(value: Matrix): Matrix; + /** + * - Convert to inverse matrix. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 转换为逆矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + invert(): Matrix; + /** + * - Apply a matrix transformation to a specific point. + * @param x - X coordinate. + * @param y - Y coordinate. + * @param result - The point after the transformation is applied. + * @param delta - Whether to ignore tx, ty's conversion to point. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 将矩阵转换应用于特定点。 + * @param x - 横坐标。 + * @param y - 纵坐标。 + * @param result - 应用转换之后的点。 + * @param delta - 是否忽略 tx,ty 对点的转换。 + * @version DragonBones 3.0 + * @language zh_CN + */ + transformPoint(x: number, y: number, result: { + x: number; + y: number; + }, delta?: boolean): void; + /** + * @private + */ + transformRectangle(rectangle: { + x: number; + y: number; + width: number; + height: number; + }, delta?: boolean): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - 2D Transform. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 2D 变换。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class Transform { + /** + * @private + */ + static readonly PI: number; + /** + * @private + */ + static readonly PI_D: number; + /** + * @private + */ + static readonly PI_H: number; + /** + * @private + */ + static readonly PI_Q: number; + /** + * @private + */ + static readonly RAD_DEG: number; + /** + * @private + */ + static readonly DEG_RAD: number; + /** + * @private + */ + static normalizeRadian(value: number): number; + /** + * - Horizontal translate. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 水平位移。 + * @version DragonBones 3.0 + * @language zh_CN + */ + x: number; + /** + * - Vertical translate. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 垂直位移。 + * @version DragonBones 3.0 + * @language zh_CN + */ + y: number; + /** + * - Skew. (In radians) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 倾斜。 (以弧度为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + skew: number; + /** + * - rotation. (In radians) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 旋转。 (以弧度为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + rotation: number; + /** + * - Horizontal Scaling. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 水平缩放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + scaleX: number; + /** + * - Vertical scaling. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 垂直缩放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + scaleY: number; + /** + * @private + */ + constructor(x?: number, y?: number, skew?: number, rotation?: number, scaleX?: number, scaleY?: number); + toString(): string; + /** + * @private + */ + copyFrom(value: Transform): Transform; + /** + * @private + */ + identity(): Transform; + /** + * @private + */ + add(value: Transform): Transform; + /** + * @private + */ + minus(value: Transform): Transform; + /** + * @private + */ + fromMatrix(matrix: Matrix): Transform; + /** + * @private + */ + toMatrix(matrix: Matrix): Transform; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + class ColorTransform { + alphaMultiplier: number; + redMultiplier: number; + greenMultiplier: number; + blueMultiplier: number; + alphaOffset: number; + redOffset: number; + greenOffset: number; + blueOffset: number; + constructor(alphaMultiplier?: number, redMultiplier?: number, greenMultiplier?: number, blueMultiplier?: number, alphaOffset?: number, redOffset?: number, greenOffset?: number, blueOffset?: number); + copyFrom(value: ColorTransform): void; + identity(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The Point object represents a location in a two-dimensional coordinate system. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - Point 对象表示二维坐标系统中的某个位置。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class Point { + /** + * - The horizontal coordinate. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 该点的水平坐标。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + x: number; + /** + * - The vertical coordinate. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 该点的垂直坐标。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + y: number; + /** + * - Creates a new point. If you pass no parameters to this method, a point is created at (0,0). + * @param x - The horizontal coordinate. + * @param y - The vertical coordinate. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 创建一个 egret.Point 对象.若不传入任何参数,将会创建一个位于(0,0)位置的点。 + * @param x - 该对象的x属性值,默认为 0.0。 + * @param y - 该对象的y属性值,默认为 0.0。 + * @version DragonBones 3.0 + * @language zh_CN + */ + constructor(x?: number, y?: number); + /** + * @private + */ + copyFrom(value: Point): void; + /** + * @private + */ + clear(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - A Rectangle object is an area defined by its position, as indicated by its top-left corner point (x, y) and by its + * width and its height.
+ * The x, y, width, and height properties of the Rectangle class are independent of each other; changing the value of + * one property has no effect on the others. However, the right and bottom properties are integrally related to those + * four properties. For example, if you change the value of the right property, the value of the width property changes; + * if you change the bottom property, the value of the height property changes. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - Rectangle 对象是按其位置(由它左上角的点 (x, y) 确定)以及宽度和高度定义的区域。
+ * Rectangle 类的 x、y、width 和 height 属性相互独立;更改一个属性的值不会影响其他属性。 + * 但是,right 和 bottom 属性与这四个属性是整体相关的。例如,如果更改 right 属性的值,则 width + * 属性的值将发生变化;如果更改 bottom 属性,则 height 属性的值将发生变化。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class Rectangle { + /** + * - The x coordinate of the top-left corner of the rectangle. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 矩形左上角的 x 坐标。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + x: number; + /** + * - The y coordinate of the top-left corner of the rectangle. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 矩形左上角的 y 坐标。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + y: number; + /** + * - The width of the rectangle, in pixels. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 矩形的宽度(以像素为单位)。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + width: number; + /** + * - 矩形的高度(以像素为单位)。 + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - The height of the rectangle, in pixels. + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + height: number; + /** + * @private + */ + constructor(x?: number, y?: number, width?: number, height?: number); + /** + * @private + */ + copyFrom(value: Rectangle): void; + /** + * @private + */ + clear(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The user custom data. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 用户自定义数据。 + * @version DragonBones 5.0 + * @language zh_CN + */ + class UserData extends BaseObject { + static toString(): string; + /** + * - The custom int numbers. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 自定义整数。 + * @version DragonBones 5.0 + * @language zh_CN + */ + readonly ints: Array; + /** + * - The custom float numbers. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 自定义浮点数。 + * @version DragonBones 5.0 + * @language zh_CN + */ + readonly floats: Array; + /** + * - The custom strings. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 自定义字符串。 + * @version DragonBones 5.0 + * @language zh_CN + */ + readonly strings: Array; + /** + * @inheritDoc + */ + protected _onClear(): void; + /** + * @internal + * @private + */ + addInt(value: number): void; + /** + * @internal + * @private + */ + addFloat(value: number): void; + /** + * @internal + * @private + */ + addString(value: string): void; + /** + * - Get the custom int number. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 获取自定义整数。 + * @version DragonBones 5.0 + * @language zh_CN + */ + getInt(index?: number): number; + /** + * - Get the custom float number. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 获取自定义浮点数。 + * @version DragonBones 5.0 + * @language zh_CN + */ + getFloat(index?: number): number; + /** + * - Get the custom string. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 获取自定义字符串。 + * @version DragonBones 5.0 + * @language zh_CN + */ + getString(index?: number): string; + } + /** + * @internal + * @private + */ + class ActionData extends BaseObject { + static toString(): string; + type: ActionType; + name: string; + bone: BoneData | null; + slot: SlotData | null; + data: UserData | null; + protected _onClear(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The DragonBones data. + * A DragonBones data contains multiple armature data. + * @see dragonBones.ArmatureData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 龙骨数据。 + * 一个龙骨数据包含多个骨架数据。 + * @see dragonBones.ArmatureData + * @version DragonBones 3.0 + * @language zh_CN + */ + class DragonBonesData extends BaseObject { + static toString(): string; + /** + * @private + */ + autoSearch: boolean; + /** + * - The animation frame rate. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画帧频。 + * @version DragonBones 3.0 + * @language zh_CN + */ + frameRate: number; + /** + * - The data version. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 数据版本。 + * @version DragonBones 3.0 + * @language zh_CN + */ + version: string; + /** + * - The DragonBones data name. + * The name is consistent with the DragonBones project name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 龙骨数据名称。 + * 该名称与龙骨项目名保持一致。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + stage: ArmatureData | null; + /** + * @internal + * @private + */ + readonly frameIndices: Array; + /** + * @internal + * @private + */ + readonly cachedFrames: Array; + /** + * - All armature data names. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 所有的骨架数据名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly armatureNames: Array; + /** + * @private + */ + readonly armatures: Map; + /** + * @internal + * @private + */ + binary: ArrayBuffer; + /** + * @internal + * @private + */ + intArray: Int16Array; + /** + * @internal + * @private + */ + floatArray: Float32Array; + /** + * @internal + * @private + */ + frameIntArray: Int16Array; + /** + * @internal + * @private + */ + frameFloatArray: Float32Array; + /** + * @internal + * @private + */ + frameArray: Int16Array; + /** + * @internal + * @private + */ + timelineArray: Uint16Array; + /** + * @private + */ + userData: UserData | null; + /** + * @inheritDoc + */ + protected _onClear(): void; + /** + * @internal + * @private + */ + addArmature(value: ArmatureData): void; + /** + * - Get a specific armature data. + * @param name - The armature data name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的骨架数据。 + * @param name - 骨架数据名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + getArmature(name: string): ArmatureData | null; + /** + * - Deprecated, please refer to {@link #dragonBones.BaseFactory#removeDragonBonesData()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #dragonBones.BaseFactory#removeDragonBonesData()}。 + * @deprecated + * @language zh_CN + */ + dispose(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The armature data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨架数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class ArmatureData extends BaseObject { + static toString(): string; + /** + * @private + */ + type: ArmatureType; + /** + * - The animation frame rate. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画帧率。 + * @version DragonBones 3.0 + * @language zh_CN + */ + frameRate: number; + /** + * @private + */ + cacheFrameRate: number; + /** + * @private + */ + scale: number; + /** + * - The armature name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨架名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + readonly aabb: Rectangle; + /** + * - The names of all the animation data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 所有的动画数据名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly animationNames: Array; + /** + * @private + */ + readonly sortedBones: Array; + /** + * @private + */ + readonly sortedSlots: Array; + /** + * @private + */ + readonly defaultActions: Array; + /** + * @private + */ + readonly actions: Array; + /** + * @private + */ + readonly bones: Map; + /** + * @private + */ + readonly slots: Map; + /** + * @private + */ + readonly constraints: Map; + /** + * @private + */ + readonly skins: Map; + /** + * @private + */ + readonly animations: Map; + /** + * - The default skin data. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 默认插槽数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + defaultSkin: SkinData | null; + /** + * - The default animation data. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 默认动画数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + defaultAnimation: AnimationData | null; + /** + * @private + */ + canvas: CanvasData | null; + /** + * @private + */ + userData: UserData | null; + /** + * @private + */ + parent: DragonBonesData; + /** + * @inheritDoc + */ + protected _onClear(): void; + /** + * @internal + * @private + */ + sortBones(): void; + /** + * @internal + * @private + */ + cacheFrames(frameRate: number): void; + /** + * @internal + * @private + */ + setCacheFrame(globalTransformMatrix: Matrix, transform: Transform): number; + /** + * @internal + * @private + */ + getCacheFrame(globalTransformMatrix: Matrix, transform: Transform, arrayOffset: number): void; + /** + * @internal + * @private + */ + addBone(value: BoneData): void; + /** + * @internal + * @private + */ + addSlot(value: SlotData): void; + /** + * @internal + * @private + */ + addConstraint(value: ConstraintData): void; + /** + * @internal + * @private + */ + addSkin(value: SkinData): void; + /** + * @internal + * @private + */ + addAnimation(value: AnimationData): void; + /** + * @internal + * @private + */ + addAction(value: ActionData, isDefault: boolean): void; + /** + * - Get a specific done data. + * @param name - The bone name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的骨骼数据。 + * @param name - 骨骼名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + getBone(name: string): BoneData | null; + /** + * - Get a specific slot data. + * @param name - The slot name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的插槽数据。 + * @param name - 插槽名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + getSlot(name: string): SlotData | null; + /** + * @private + */ + getConstraint(name: string): ConstraintData | null; + /** + * - Get a specific skin data. + * @param name - The skin name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定皮肤数据。 + * @param name - 皮肤名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + getSkin(name: string): SkinData | null; + /** + * @internal + * @private + */ + getMesh(skinName: string, slotName: string, meshName: string): MeshDisplayData | null; + /** + * - Get a specific animation data. + * @param name - The animation name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的动画数据。 + * @param name - 动画名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + getAnimation(name: string): AnimationData | null; + } + /** + * - The bone data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨骼数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class BoneData extends BaseObject { + static toString(): string; + /** + * @private + */ + inheritTranslation: boolean; + /** + * @private + */ + inheritRotation: boolean; + /** + * @private + */ + inheritScale: boolean; + /** + * @private + */ + inheritReflection: boolean; + /** + * @private + */ + type: BoneType; + /** + * - The bone length. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨骼长度。 + * @version DragonBones 3.0 + * @language zh_CN + */ + length: number; + /** + * - The bone name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨骼名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + readonly transform: Transform; + /** + * @private + */ + userData: UserData | null; + /** + * - The parent bone data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 父骨骼数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + parent: BoneData | null; + /** + * @inheritDoc + */ + protected _onClear(): void; + } + /** + * @internal + * @private + */ + class SurfaceData extends BoneData { + static toString(): string; + segmentX: number; + segmentY: number; + readonly vertices: Array; + /** + * @inheritDoc + */ + protected _onClear(): void; + } + /** + * - The slot data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 插槽数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class SlotData extends BaseObject { + /** + * @internal + * @private + */ + static readonly DEFAULT_COLOR: ColorTransform; + /** + * @internal + * @private + */ + static createColor(): ColorTransform; + static toString(): string; + /** + * @private + */ + blendMode: BlendMode; + /** + * @private + */ + displayIndex: number; + /** + * @private + */ + zOrder: number; + /** + * - The slot name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 插槽名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + color: ColorTransform; + /** + * @private + */ + userData: UserData | null; + /** + * - The parent bone data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 父骨骼数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + parent: BoneData; + /** + * @inheritDoc + */ + protected _onClear(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + abstract class ConstraintData extends BaseObject { + order: number; + name: string; + target: BoneData; + root: BoneData; + bone: BoneData | null; + protected _onClear(): void; + } + /** + * @internal + * @private + */ + class IKConstraintData extends ConstraintData { + static toString(): string; + scaleEnabled: boolean; + bendPositive: boolean; + weight: number; + protected _onClear(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + class CanvasData extends BaseObject { + static toString(): string; + hasBackground: boolean; + color: number; + x: number; + y: number; + width: number; + height: number; + protected _onClear(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The skin data, typically a armature data instance contains at least one skinData. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 皮肤数据,通常一个骨架数据至少包含一个皮肤数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class SkinData extends BaseObject { + static toString(): string; + /** + * - The skin name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 皮肤名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + readonly displays: Map>; + /** + * @private + */ + parent: ArmatureData; + /** + * @inheritDoc + */ + protected _onClear(): void; + /** + * @internal + * @private + */ + addDisplay(slotName: string, value: DisplayData | null): void; + /** + * @private + */ + getDisplay(slotName: string, displayName: string): DisplayData | null; + /** + * @private + */ + getDisplays(slotName: string): Array | null; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + abstract class DisplayData extends BaseObject { + type: DisplayType; + name: string; + path: string; + parent: SkinData; + readonly transform: Transform; + protected _onClear(): void; + } + /** + * @internal + * @private + */ + class ImageDisplayData extends DisplayData { + static toString(): string; + readonly pivot: Point; + texture: TextureData | null; + protected _onClear(): void; + } + /** + * @internal + * @private + */ + class ArmatureDisplayData extends DisplayData { + static toString(): string; + inheritAnimation: boolean; + readonly actions: Array; + armature: ArmatureData | null; + protected _onClear(): void; + /** + * @private + */ + addAction(value: ActionData): void; + } + /** + * @internal + * @private + */ + class MeshDisplayData extends DisplayData { + static toString(): string; + inheritDeform: boolean; + offset: number; + weight: WeightData | null; + glue: GlueData | null; + texture: TextureData | null; + protected _onClear(): void; + } + /** + * @internal + * @private + */ + class BoundingBoxDisplayData extends DisplayData { + static toString(): string; + boundingBox: BoundingBoxData | null; + protected _onClear(): void; + } + /** + * @internal + * @private + */ + class WeightData extends BaseObject { + static toString(): string; + count: number; + offset: number; + readonly bones: Array; + protected _onClear(): void; + addBone(value: BoneData): void; + } + /** + * @internal + * @private + */ + class GlueData extends BaseObject { + static toString(): string; + readonly weights: Array; + readonly meshes: Array; + protected _onClear(): void; + addMesh(value: MeshDisplayData | null): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The base class of bounding box data. + * @see dragonBones.RectangleData + * @see dragonBones.EllipseData + * @see dragonBones.PolygonData + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 边界框数据基类。 + * @see dragonBones.RectangleData + * @see dragonBones.EllipseData + * @see dragonBones.PolygonData + * @version DragonBones 5.0 + * @language zh_CN + */ + abstract class BoundingBoxData extends BaseObject { + /** + * - The bounding box type. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 边界框类型。 + * @version DragonBones 5.0 + * @language zh_CN + */ + type: BoundingBoxType; + /** + * @private + */ + color: number; + /** + * @private + */ + width: number; + /** + * @private + */ + height: number; + /** + * @private + */ + protected _onClear(): void; + /** + * - Check whether the bounding box contains a specific point. (Local coordinate system) + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 检查边界框是否包含特定点。(本地坐标系) + * @version DragonBones 5.0 + * @language zh_CN + */ + abstract containsPoint(pX: number, pY: number): boolean; + /** + * - Check whether the bounding box intersects a specific segment. (Local coordinate system) + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 检查边界框是否与特定线段相交。(本地坐标系) + * @version DragonBones 5.0 + * @language zh_CN + */ + abstract intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA: { + x: number; + y: number; + } | null, intersectionPointB: { + x: number; + y: number; + } | null, normalRadians: { + x: number; + y: number; + } | null): number; + } + /** + * - The rectangle bounding box data. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 矩形边界框数据。 + * @version DragonBones 5.1 + * @language zh_CN + */ + class RectangleBoundingBoxData extends BoundingBoxData { + static toString(): string; + /** + * - Compute the bit code for a point (x, y) using the clip rectangle + */ + private static _computeOutCode(x, y, xMin, yMin, xMax, yMax); + /** + * @private + */ + static rectangleIntersectsSegment(xA: number, yA: number, xB: number, yB: number, xMin: number, yMin: number, xMax: number, yMax: number, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): number; + /** + * @inheritDoc + * @private + */ + protected _onClear(): void; + /** + * @inheritDoc + */ + containsPoint(pX: number, pY: number): boolean; + /** + * @inheritDoc + */ + intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): number; + } + /** + * - The ellipse bounding box data. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 椭圆边界框数据。 + * @version DragonBones 5.1 + * @language zh_CN + */ + class EllipseBoundingBoxData extends BoundingBoxData { + static toString(): string; + /** + * @private + */ + static ellipseIntersectsSegment(xA: number, yA: number, xB: number, yB: number, xC: number, yC: number, widthH: number, heightH: number, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): number; + /** + * @inheritDoc + * @private + */ + protected _onClear(): void; + /** + * @inheritDoc + */ + containsPoint(pX: number, pY: number): boolean; + /** + * @inheritDoc + */ + intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): number; + } + /** + * - The polygon bounding box data. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 多边形边界框数据。 + * @version DragonBones 5.1 + * @language zh_CN + */ + class PolygonBoundingBoxData extends BoundingBoxData { + static toString(): string; + /** + * @private + */ + static polygonIntersectsSegment(xA: number, yA: number, xB: number, yB: number, vertices: Array, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): number; + /** + * @private + */ + x: number; + /** + * @private + */ + y: number; + /** + * - The polygon vertices. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 多边形顶点。 + * @version DragonBones 5.1 + * @language zh_CN + */ + readonly vertices: Array; + /** + * @private + */ + weight: WeightData | null; + /** + * @inheritDoc + * @private + */ + protected _onClear(): void; + /** + * @inheritDoc + */ + containsPoint(pX: number, pY: number): boolean; + /** + * @inheritDoc + */ + intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): number; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The animation data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class AnimationData extends BaseObject { + static toString(): string; + /** + * - FrameIntArray. + * @internal + * @private + */ + frameIntOffset: number; + /** + * - FrameFloatArray. + * @internal + * @private + */ + frameFloatOffset: number; + /** + * - FrameArray. + * @internal + * @private + */ + frameOffset: number; + /** + * - The frame count of the animation. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画的帧数。 + * @version DragonBones 3.0 + * @language zh_CN + */ + frameCount: number; + /** + * - The play times of the animation. [0: Loop play, [1~N]: Play N times] + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画的播放次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次] + * @version DragonBones 3.0 + * @language zh_CN + */ + playTimes: number; + /** + * - The duration of the animation. (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画的持续时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + duration: number; + /** + * @private + */ + scale: number; + /** + * - The fade in time of the animation. (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画的淡入时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + fadeInTime: number; + /** + * @private + */ + cacheFrameRate: number; + /** + * - The animation name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + readonly cachedFrames: Array; + /** + * @private + */ + readonly boneTimelines: Map>; + /** + * @private + */ + readonly surfaceTimelines: Map>; + /** + * @private + */ + readonly slotTimelines: Map>; + /** + * @private + */ + readonly constraintTimelines: Map>; + /** + * @private + */ + readonly animationTimelines: Map>; + /** + * @private + */ + readonly boneCachedFrameIndices: Map>; + /** + * @private + */ + readonly slotCachedFrameIndices: Map>; + /** + * @private + */ + actionTimeline: TimelineData | null; + /** + * @private + */ + zOrderTimeline: TimelineData | null; + /** + * @private + */ + parent: ArmatureData; + /** + * @inheritDoc + */ + protected _onClear(): void; + /** + * @internal + * @private + */ + cacheFrames(frameRate: number): void; + /** + * @private + */ + addBoneTimeline(bone: BoneData, timeline: TimelineData): void; + /** + * @private + */ + addSurfaceTimeline(surface: SurfaceData, timeline: TimelineData): void; + /** + * @private + */ + addSlotTimeline(slot: SlotData, timeline: TimelineData): void; + /** + * @private + */ + addConstraintTimeline(constraint: ConstraintData, timeline: TimelineData): void; + /** + * @private + */ + addAnimationTimeline(name: string, timeline: TimelineData): void; + /** + * @private + */ + getBoneTimelines(name: string): Array | null; + /** + * @private + */ + getSurfaceTimelines(name: string): Array | null; + /** + * @private + */ + getSlotTimelines(name: string): Array | null; + /** + * @private + */ + getConstraintTimelines(name: string): Array | null; + /** + * @private + */ + getAnimationTimelines(name: string): Array | null; + /** + * @private + */ + getBoneCachedFrameIndices(name: string): Array | null; + /** + * @private + */ + getSlotCachedFrameIndices(name: string): Array | null; + } + /** + * @internal + * @private + */ + class TimelineData extends BaseObject { + static toString(): string; + type: TimelineType; + offset: number; + frameIndicesOffset: number; + protected _onClear(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The animation config is used to describe all the information needed to play an animation state. + * The API is still in the experimental phase and may encounter bugs or stability or compatibility issues when used. + * @see dragonBones.AnimationState + * @beta + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画配置用来描述播放一个动画状态所需要的全部信息。 + * 该 API 仍在实验阶段,使用时可能遭遇 bug 或稳定性或兼容性问题。 + * @see dragonBones.AnimationState + * @beta + * @version DragonBones 5.0 + * @language zh_CN + */ + class AnimationConfig extends BaseObject { + static toString(): string; + /** + * @private + */ + pauseFadeOut: boolean; + /** + * - Fade out the pattern of other animation states when the animation state is fade in. + * This property is typically used to specify the substitution of multiple animation states blend. + * @default dragonBones.AnimationFadeOutMode.All + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 淡入动画状态时淡出其他动画状态的模式。 + * 该属性通常用来指定多个动画状态混合时的相互替换关系。 + * @default dragonBones.AnimationFadeOutMode.All + * @version DragonBones 5.0 + * @language zh_CN + */ + fadeOutMode: AnimationFadeOutMode; + /** + * @private + */ + fadeOutTweenType: TweenType; + /** + * @private + */ + fadeOutTime: number; + /** + * @private + */ + pauseFadeIn: boolean; + /** + * @private + */ + actionEnabled: boolean; + /** + * @private + */ + additiveBlending: boolean; + /** + * - Whether the animation state has control over the display property of the slots. + * Sometimes blend a animation state does not want it to control the display properties of the slots, + * especially if other animation state are controlling the display properties of the slots. + * @default true + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画状态是否对插槽的显示对象属性有控制权。 + * 有时混合一个动画状态并不希望其控制插槽的显示对象属性, + * 尤其是其他动画状态正在控制这些插槽的显示对象属性时。 + * @default true + * @version DragonBones 5.0 + * @language zh_CN + */ + displayControl: boolean; + /** + * - Whether to reset the objects without animation to the armature pose when the animation state is start to play. + * This property should usually be set to false when blend multiple animation states. + * @default true + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 开始播放动画状态时是否将没有动画的对象重置为骨架初始值。 + * 通常在混合多个动画状态时应该将该属性设置为 false。 + * @default true + * @version DragonBones 5.1 + * @language zh_CN + */ + resetToPose: boolean; + /** + * @private + */ + fadeInTweenType: TweenType; + /** + * - The play times. [0: Loop play, [1~N]: Play N times] + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 播放次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次] + * @version DragonBones 3.0 + * @language zh_CN + */ + playTimes: number; + /** + * - The blend layer. + * High layer animation state will get the blend weight first. + * When the blend weight is assigned more than 1, the remaining animation states will no longer get the weight assigned. + * @readonly + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 混合图层。 + * 图层高的动画状态会优先获取混合权重。 + * 当混合权重分配超过 1 时,剩余的动画状态将不再获得权重分配。 + * @readonly + * @version DragonBones 5.0 + * @language zh_CN + */ + layer: number; + /** + * - The start time of play. (In seconds) + * @default 0.0 + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 播放的开始时间。 (以秒为单位) + * @default 0.0 + * @version DragonBones 5.0 + * @language zh_CN + */ + position: number; + /** + * - The duration of play. + * [-1: Use the default value of the animation data, 0: Stop play, (0~N]: The duration] (In seconds) + * @default -1.0 + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 播放的持续时间。 + * [-1: 使用动画数据默认值, 0: 动画停止, (0~N]: 持续时间] (以秒为单位) + * @default -1.0 + * @version DragonBones 5.0 + * @language zh_CN + */ + duration: number; + /** + * - The play speed. + * The value is an overlay relationship with {@link dragonBones.Animation#timeScale}. + * [(-N~0): Reverse play, 0: Stop play, (0~1): Slow play, 1: Normal play, (1~N): Fast play] + * @default 1.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 播放速度。 + * 该值与 {@link dragonBones.Animation#timeScale} 是叠加关系。 + * [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + timeScale: number; + /** + * - The blend weight. + * @default 1.0 + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 混合权重。 + * @default 1.0 + * @version DragonBones 5.0 + * @language zh_CN + */ + weight: number; + /** + * - The fade in time. + * [-1: Use the default value of the animation data, [0~N]: The fade in time] (In seconds) + * @default -1.0 + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 淡入时间。 + * [-1: 使用动画数据默认值, [0~N]: 淡入时间] (以秒为单位) + * @default -1.0 + * @version DragonBones 5.0 + * @language zh_CN + */ + fadeInTime: number; + /** + * - The auto fade out time when the animation state play completed. + * [-1: Do not fade out automatically, [0~N]: The fade out time] (In seconds) + * @default -1.0 + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画状态播放完成后的自动淡出时间。 + * [-1: 不自动淡出, [0~N]: 淡出时间] (以秒为单位) + * @default -1.0 + * @version DragonBones 5.0 + * @language zh_CN + */ + autoFadeOutTime: number; + /** + * - The name of the animation state. (Can be different from the name of the animation data) + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画状态名称。 (可以不同于动画数据) + * @version DragonBones 5.0 + * @language zh_CN + */ + name: string; + /** + * - The animation data name. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画数据名称。 + * @version DragonBones 5.0 + * @language zh_CN + */ + animation: string; + /** + * - The blend group name of the animation state. + * This property is typically used to specify the substitution of multiple animation states blend. + * @readonly + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 混合组名称。 + * 该属性通常用来指定多个动画状态混合时的相互替换关系。 + * @readonly + * @version DragonBones 5.0 + * @language zh_CN + */ + group: string; + /** + * @private + */ + readonly boneMask: Array; + /** + * @private + */ + protected _onClear(): void; + /** + * @private + */ + clear(): void; + /** + * @private + */ + copyFrom(value: AnimationConfig): void; + /** + * @private + */ + containsBoneMask(name: string): boolean; + /** + * @private + */ + addBoneMask(armature: Armature, name: string, recursive?: boolean): void; + /** + * @private + */ + removeBoneMask(armature: Armature, name: string, recursive?: boolean): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The texture atlas data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 贴图集数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + abstract class TextureAtlasData extends BaseObject { + /** + * @private + */ + autoSearch: boolean; + /** + * @private + */ + width: number; + /** + * @private + */ + height: number; + /** + * @private + */ + scale: number; + /** + * - The texture atlas name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 贴图集名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * - The image path of the texture atlas. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 贴图集图片路径。 + * @version DragonBones 3.0 + * @language zh_CN + */ + imagePath: string; + /** + * @private + */ + readonly textures: Map; + /** + * @inheritDoc + */ + protected _onClear(): void; + /** + * @private + */ + copyFrom(value: TextureAtlasData): void; + /** + * @internal + * @private + */ + abstract createTexture(): TextureData; + /** + * @internal + * @private + */ + addTexture(value: TextureData): void; + /** + * @private + */ + getTexture(name: string): TextureData | null; + } + /** + * @internal + * @private + */ + abstract class TextureData extends BaseObject { + static createRectangle(): Rectangle; + rotated: boolean; + name: string; + readonly region: Rectangle; + parent: TextureAtlasData; + frame: Rectangle | null; + protected _onClear(): void; + copyFrom(value: TextureData): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The armature proxy interface, the docking engine needs to implement it concretely. + * @see dragonBones.Armature + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 骨架代理接口,对接的引擎需要对其进行具体实现。 + * @see dragonBones.Armature + * @version DragonBones 5.0 + * @language zh_CN + */ + interface IArmatureProxy extends IEventDispatcher { + /** + * @internal + * @private + */ + dbInit(armature: Armature): void; + /** + * @internal + * @private + */ + dbClear(): void; + /** + * @internal + * @private + */ + dbUpdate(): void; + /** + * - Dispose the instance and the Armature instance. (The Armature instance will return to the object pool) + * @example + *
+         *     removeChild(armatureDisplay);
+         *     armatureDisplay.dispose();
+         * 
+ * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 释放该实例和骨架。 (骨架会回收到对象池) + * @example + *
+         *     removeChild(armatureDisplay);
+         *     armatureDisplay.dispose();
+         * 
+ * @version DragonBones 4.5 + * @language zh_CN + */ + dispose(disposeProxy: boolean): void; + /** + * - The armature. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 骨架。 + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly armature: Armature; + /** + * - The animation player. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画播放器。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly animation: Animation; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - Armature is the core of the skeleton animation system. + * @see dragonBones.ArmatureData + * @see dragonBones.Bone + * @see dragonBones.Slot + * @see dragonBones.Animation + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨架是骨骼动画系统的核心。 + * @see dragonBones.ArmatureData + * @see dragonBones.Bone + * @see dragonBones.Slot + * @see dragonBones.Animation + * @version DragonBones 3.0 + * @language zh_CN + */ + class Armature extends BaseObject implements IAnimatable { + static toString(): string; + private static _onSortSlots(a, b); + /** + * - Whether to inherit the animation control of the parent armature. + * True to try to have the child armature play an animation with the same name when the parent armature play the animation. + * @default true + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 是否继承父骨架的动画控制。 + * 如果该值为 true,当父骨架播放动画时,会尝试让子骨架播放同名动画。 + * @default true + * @version DragonBones 4.5 + * @language zh_CN + */ + inheritAnimation: boolean; + /** + * @private + */ + userData: any; + private _lockUpdate; + private _bonesDirty; + private _slotsDirty; + private _zOrderDirty; + private _flipX; + private _flipY; + /** + * @internal + * @private + */ + _cacheFrameIndex: number; + private readonly _bones; + private readonly _slots; + /** + * @internal + * @private + */ + readonly _glueSlots: Array; + /** + * @internal + * @private + */ + readonly _constraints: Array; + private readonly _actions; + /** + * @internal + * @private + */ + _armatureData: ArmatureData; + private _animation; + private _proxy; + private _display; + /** + * @internal + * @private + */ + _replaceTextureAtlasData: TextureAtlasData | null; + private _replacedTexture; + /** + * @internal + * @private + */ + _dragonBones: DragonBones; + private _clock; + /** + * @internal + * @private + */ + _parent: Slot | null; + /** + * @private + */ + protected _onClear(): void; + private _sortBones(); + private _sortSlots(); + /** + * @internal + * @private + */ + _sortZOrder(slotIndices: Array | Int16Array | null, offset: number): void; + /** + * @internal + * @private + */ + _addBoneToBoneList(value: Bone): void; + /** + * @internal + * @private + */ + _removeBoneFromBoneList(value: Bone): void; + /** + * @internal + * @private + */ + _addSlotToSlotList(value: Slot): void; + /** + * @internal + * @private + */ + _removeSlotFromSlotList(value: Slot): void; + /** + * @internal + * @private + */ + _bufferAction(action: ActionData, append: boolean): void; + /** + * - Dispose the armature. (Return to the object pool) + * @example + *
+         *     removeChild(armature.display);
+         *     armature.dispose();
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 释放骨架。 (回收到对象池) + * @example + *
+         *     removeChild(armature.display);
+         *     armature.dispose();
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + dispose(): void; + /** + * @internal + * @private + */ + init(armatureData: ArmatureData, proxy: IArmatureProxy, display: any, dragonBones: DragonBones): void; + /** + * @inheritDoc + */ + advanceTime(passedTime: number): void; + /** + * - Forces a specific bone or its owning slot to update the transform or display property in the next frame. + * @param boneName - The bone name. (If not set, all bones will be update) + * @param updateSlot - Whether to update the bone's slots. (Default: false) + * @see dragonBones.Bone#invalidUpdate() + * @see dragonBones.Slot#invalidUpdate() + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 强制特定骨骼或其拥有的插槽在下一帧更新变换或显示属性。 + * @param boneName - 骨骼名称。 (如果未设置,将更新所有骨骼) + * @param updateSlot - 是否更新骨骼的插槽。 (默认: false) + * @see dragonBones.Bone#invalidUpdate() + * @see dragonBones.Slot#invalidUpdate() + * @version DragonBones 3.0 + * @language zh_CN + */ + invalidUpdate(boneName?: string | null, updateSlot?: boolean): void; + /** + * - Check whether a specific point is inside a custom bounding box in a slot. + * The coordinate system of the point is the inner coordinate system of the armature. + * Custom bounding boxes need to be customized in Dragonbones Pro. + * @param x - The horizontal coordinate of the point. + * @param y - The vertical coordinate of the point. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 检查特定点是否在某个插槽的自定义边界框内。 + * 点的坐标系为骨架内坐标系。 + * 自定义边界框需要在 DragonBones Pro 中自定义。 + * @param x - 点的水平坐标。 + * @param y - 点的垂直坐标。 + * @version DragonBones 5.0 + * @language zh_CN + */ + containsPoint(x: number, y: number): Slot | null; + /** + * - Check whether a specific segment intersects a custom bounding box for a slot in the armature. + * The coordinate system of the segment and intersection is the inner coordinate system of the armature. + * Custom bounding boxes need to be customized in Dragonbones Pro. + * @param xA - The horizontal coordinate of the beginning of the segment. + * @param yA - The vertical coordinate of the beginning of the segment. + * @param xB - The horizontal coordinate of the end point of the segment. + * @param yB - The vertical coordinate of the end point of the segment. + * @param intersectionPointA - The first intersection at which a line segment intersects the bounding box from the beginning to the end. (If not set, the intersection point will not calculated) + * @param intersectionPointB - The first intersection at which a line segment intersects the bounding box from the end to the beginning. (If not set, the intersection point will not calculated) + * @param normalRadians - The normal radians of the tangent of the intersection boundary box. [x: Normal radian of the first intersection tangent, y: Normal radian of the second intersection tangent] (If not set, the normal will not calculated) + * @returns The slot of the first custom bounding box where the segment intersects from the start point to the end point. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 检查特定线段是否与骨架的某个插槽的自定义边界框相交。 + * 线段和交点的坐标系均为骨架内坐标系。 + * 自定义边界框需要在 DragonBones Pro 中自定义。 + * @param xA - 线段起点的水平坐标。 + * @param yA - 线段起点的垂直坐标。 + * @param xB - 线段终点的水平坐标。 + * @param yB - 线段终点的垂直坐标。 + * @param intersectionPointA - 线段从起点到终点与边界框相交的第一个交点。 (如果未设置,则不计算交点) + * @param intersectionPointB - 线段从终点到起点与边界框相交的第一个交点。 (如果未设置,则不计算交点) + * @param normalRadians - 交点边界框切线的法线弧度。 [x: 第一个交点切线的法线弧度, y: 第二个交点切线的法线弧度] (如果未设置,则不计算法线) + * @returns 线段从起点到终点相交的第一个自定义边界框的插槽。 + * @version DragonBones 5.0 + * @language zh_CN + */ + intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): Slot | null; + /** + * - Get a specific bone. + * @param name - The bone name. + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的骨骼。 + * @param name - 骨骼名称。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + getBone(name: string): Bone | null; + /** + * - Get a specific bone by the display. + * @param display - The display object. + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 通过显示对象获取特定的骨骼。 + * @param display - 显示对象。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + getBoneByDisplay(display: any): Bone | null; + /** + * - Get a specific slot. + * @param name - The slot name. + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的插槽。 + * @param name - 插槽名称。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + getSlot(name: string): Slot | null; + /** + * - Get a specific slot by the display. + * @param display - The display object. + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 通过显示对象获取特定的插槽。 + * @param display - 显示对象。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + getSlotByDisplay(display: any): Slot | null; + /** + * @deprecated + */ + addBone(value: Bone, parentName: string): void; + /** + * @deprecated + */ + addSlot(value: Slot, parentName: string): void; + /** + * @private + */ + addConstraint(value: Constraint): void; + /** + * @deprecated + */ + removeBone(value: Bone): void; + /** + * @deprecated + */ + removeSlot(value: Slot): void; + /** + * - Get all bones. + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取所有的骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + getBones(): Array; + /** + * - Get all slots. + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取所有的插槽。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + getSlots(): Array; + /** + * - Whether to flip the armature horizontally. + * @version DragonBones 5.5 + * @language en_US + */ + /** + * - 是否将骨架水平翻转。 + * @version DragonBones 5.5 + * @language zh_CN + */ + flipX: boolean; + /** + * - Whether to flip the armature vertically. + * @version DragonBones 5.5 + * @language en_US + */ + /** + * - 是否将骨架垂直翻转。 + * @version DragonBones 5.5 + * @language zh_CN + */ + flipY: boolean; + /** + * - The animation cache frame rate, which turns on the animation cache when the set value is greater than 0. + * There is a certain amount of memory overhead to improve performance by caching animation data in memory. + * The frame rate should not be set too high, usually with the frame rate of the animation is similar and lower than the program running frame rate. + * When the animation cache is turned on, some features will fail, such as the offset property of bone. + * @example + *
+         *     armature.cacheFrameRate = 24;
+         * 
+ * @see dragonBones.DragonBonesData#frameRate + * @see dragonBones.ArmatureData#frameRate + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画缓存帧率,当设置的值大于 0 的时,将会开启动画缓存。 + * 通过将动画数据缓存在内存中来提高运行性能,会有一定的内存开销。 + * 帧率不宜设置的过高,通常跟动画的帧率相当且低于程序运行的帧率。 + * 开启动画缓存后,某些功能将会失效,比如骨骼的 offset 属性等。 + * @example + *
+         *     armature.cacheFrameRate = 24;
+         * 
+ * @see dragonBones.DragonBonesData#frameRate + * @see dragonBones.ArmatureData#frameRate + * @version DragonBones 4.5 + * @language zh_CN + */ + cacheFrameRate: number; + /** + * - The armature name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨架名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly name: string; + /** + * - The armature data. + * @see dragonBones.ArmatureData + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 骨架数据。 + * @see dragonBones.ArmatureData + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly armatureData: ArmatureData; + /** + * - The animation player. + * @see dragonBones.Animation + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画播放器。 + * @see dragonBones.Animation + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly animation: Animation; + /** + * @pivate + */ + readonly proxy: IArmatureProxy; + /** + * - The EventDispatcher instance of the armature. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 该骨架的 EventDispatcher 实例。 + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly eventDispatcher: IEventDispatcher; + /** + * - The display container. + * The display of the slot is displayed as the parent. + * Depending on the rendering engine, the type will be different, usually the DisplayObjectContainer type. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 显示容器实例。 + * 插槽的显示对象都会以此显示容器为父级。 + * 根据渲染引擎的不同,类型会不同,通常是 DisplayObjectContainer 类型。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly display: any; + /** + * @private + */ + replacedTexture: any; + /** + * @inheritDoc + */ + clock: WorldClock | null; + /** + * - Get the parent slot which the armature belongs to. + * @see dragonBones.Slot + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 该骨架所属的父插槽。 + * @see dragonBones.Slot + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly parent: Slot | null; + /** + * @deprecated + * @private + */ + replaceTexture(texture: any): void; + /** + * - Deprecated, please refer to {@link #eventDispatcher}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #eventDispatcher}。 + * @deprecated + * @language zh_CN + */ + hasEventListener(type: EventStringType): boolean; + /** + * - Deprecated, please refer to {@link #eventDispatcher}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #eventDispatcher}。 + * @deprecated + * @language zh_CN + */ + addEventListener(type: EventStringType, listener: Function, target: any): void; + /** + * - Deprecated, please refer to {@link #eventDispatcher}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #eventDispatcher}。 + * @deprecated + * @language zh_CN + */ + removeEventListener(type: EventStringType, listener: Function, target: any): void; + /** + * - Deprecated, please refer to {@link #cacheFrameRate}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #cacheFrameRate}。 + * @deprecated + * @language zh_CN + */ + enableAnimationCache(frameRate: number): void; + /** + * - Deprecated, please refer to {@link #display}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #display}。 + * @deprecated + * @language zh_CN + */ + getDisplay(): any; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The base class of the transform object. + * @see dragonBones.Transform + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 变换对象的基类。 + * @see dragonBones.Transform + * @version DragonBones 4.5 + * @language zh_CN + */ + abstract class TransformObject extends BaseObject { + /** + * @private + */ + protected static readonly _helpMatrix: Matrix; + /** + * @private + */ + protected static readonly _helpTransform: Transform; + /** + * @private + */ + protected static readonly _helpPoint: Point; + /** + * - A matrix relative to the armature coordinate system. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 相对于骨架坐标系的矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly globalTransformMatrix: Matrix; + /** + * - A transform relative to the armature coordinate system. + * @see #updateGlobalTransform() + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 相对于骨架坐标系的变换。 + * @see #updateGlobalTransform() + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly global: Transform; + /** + * - The offset transform relative to the armature or the parent bone coordinate system. + * @see #dragonBones.Bone#invalidUpdate() + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 相对于骨架或父骨骼坐标系的偏移变换。 + * @see #dragonBones.Bone#invalidUpdate() + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly offset: Transform; + /** + * @private + */ + origin: Transform | null; + /** + * @private + */ + userData: any; + /** + * @private + */ + protected _globalDirty: boolean; + /** + * @internal + * @private + */ + _armature: Armature; + /** + * @internal + * @private + */ + _parent: Bone; + /** + * @private + */ + protected _onClear(): void; + /** + * @internal + * @private + */ + _setArmature(value: Armature | null): void; + /** + * @internal + * @private + */ + _setParent(value: Bone | null): void; + /** + * - For performance considerations, rotation or scale in the {@link #global} attribute of the bone or slot is not always properly accessible, + * some engines do not rely on these attributes to update rendering, such as Egret. + * The use of this method ensures that the access to the {@link #global} property is correctly rotation or scale. + * @example + *
+         *     bone.updateGlobalTransform();
+         *     let rotation = bone.global.rotation;
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 出于性能的考虑,骨骼或插槽的 {@link #global} 属性中的旋转或缩放并不总是正确可访问的,有些引擎并不依赖这些属性更新渲染,比如 Egret。 + * 使用此方法可以保证访问到 {@link #global} 属性中正确的旋转或缩放。 + * @example + *
+         *     bone.updateGlobalTransform();
+         *     let rotation = bone.global.rotation;
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + updateGlobalTransform(): void; + /** + * - The armature to which it belongs. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 所属的骨架。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly armature: Armature; + /** + * - The parent bone to which it belongs. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 所属的父骨骼。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly parent: Bone; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - Bone is one of the most important logical units in the armature animation system, + * and is responsible for the realization of translate, rotation, scaling in the animations. + * A armature can contain multiple bones. + * @see dragonBones.BoneData + * @see dragonBones.Armature + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨骼在骨骼动画体系中是最重要的逻辑单元之一,负责动画中的平移、旋转、缩放的实现。 + * 一个骨架中可以包含多个骨骼。 + * @see dragonBones.BoneData + * @see dragonBones.Armature + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + class Bone extends TransformObject { + static toString(): string; + /** + * - The offset mode. + * @see #offset + * @version DragonBones 5.5 + * @language en_US + */ + /** + * - 偏移模式。 + * @see #offset + * @version DragonBones 5.5 + * @language zh_CN + */ + offsetMode: OffsetMode; + /** + * @internal + * @private + */ + readonly animationPose: Transform; + /** + * @internal + * @private + */ + _transformDirty: boolean; + /** + * @internal + * @private + */ + _childrenTransformDirty: boolean; + protected _localDirty: boolean; + /** + * @internal + * @private + */ + _hasConstraint: boolean; + private _visible; + protected _cachedFrameIndex: number; + /** + * @internal + * @private + */ + readonly _blendState: BlendState; + /** + * @internal + * @private + */ + _boneData: BoneData; + /** + * @internal + * @private + */ + _cachedFrameIndices: Array | null; + /** + * @inheritDoc + */ + protected _onClear(): void; + /** + * @private + */ + protected _updateGlobalTransformMatrix(isCache: boolean): void; + /** + * @inheritDoc + */ + _setArmature(value: Armature | null): void; + /** + * @internal + * @private + */ + init(boneData: BoneData): void; + /** + * @internal + * @private + */ + update(cacheFrameIndex: number): void; + /** + * @internal + * @private + */ + updateByConstraint(): void; + /** + * - Forces the bone to update the transform in the next frame. + * When the bone is not animated or its animation state is finished, the bone will not continue to update, + * and when the skeleton must be updated for some reason, the method needs to be called explicitly. + * @example + *
+         *     let bone = armature.getBone("arm");
+         *     bone.offset.scaleX = 2.0;
+         *     bone.invalidUpdate();
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 强制骨骼在下一帧更新变换。 + * 当该骨骼没有动画状态或其动画状态播放完成时,骨骼将不在继续更新,而此时由于某些原因必须更新骨骼时,则需要显式调用该方法。 + * @example + *
+         *     let bone = armature.getBone("arm");
+         *     bone.offset.scaleX = 2.0;
+         *     bone.invalidUpdate();
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + invalidUpdate(): void; + /** + * - Check whether the bone contains a specific bone or slot. + * @see dragonBones.Bone + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 检查该骨骼是否包含特定的骨骼或插槽。 + * @see dragonBones.Bone + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + contains(value: TransformObject): boolean; + /** + * - The bone data. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 骨骼数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly boneData: BoneData; + /** + * - The visible of all slots in the bone. + * @default true + * @see dragonBones.Slot#visible + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 此骨骼所有插槽的可见。 + * @default true + * @see dragonBones.Slot#visible + * @version DragonBones 3.0 + * @language zh_CN + */ + visible: boolean; + /** + * - The bone name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨骼名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly name: string; + /** + * - Deprecated, please refer to {@link dragonBones.Armature#getBones()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link dragonBones.Armature#getBones()}。 + * @deprecated + * @language zh_CN + */ + getBones(): Array; + /** + * - Deprecated, please refer to {@link dragonBones.Armature#getSlots()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link dragonBones.Armature#getSlots()}。 + * @deprecated + * @language zh_CN + */ + getSlots(): Array; + /** + * - Deprecated, please refer to {@link dragonBones.Armature#getSlot()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link dragonBones.Armature#getSlot()}。 + * @deprecated + * @language zh_CN + */ + readonly slot: Slot | null; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + class Surface extends Bone { + static toString(): string; + private _dX; + private _dY; + private _k; + private _kX; + private _kY; + /** + * For debug draw. + * @internal + * @private + */ + readonly _vertices: Array; + /** + * For timeline state. + * @internal + * @private + */ + readonly _deformVertices: Array; + /** + * x1, y1, x2, y2, x3, y3, x4, y4, d1X, d1Y, d2X, d2Y + */ + private readonly _hullCache; + /** + * Inside [flag, a, b, c, d, tx, ty], Outside [flag, a, b, c, d, tx, ty] + */ + private readonly _matrixCahce; + /** + * @inheritDoc + */ + protected _onClear(): void; + private _getAffineTransform(x, y, lX, lY, aX, aY, bX, bY, cX, cY, transform, matrix, isDown); + private _updateVertices(); + /** + * @private + */ + protected _updateGlobalTransformMatrix(isCache: boolean): void; + _getGlobalTransformMatrix(x: number, y: number): Matrix; + init(surfaceData: SurfaceData): void; + /** + * @internal + * @private + */ + update(cacheFrameIndex: number): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The slot attached to the armature, controls the display status and properties of the display object. + * A bone can contain multiple slots. + * A slot can contain multiple display objects, displaying only one of the display objects at a time, + * but you can toggle the display object into frame animation while the animation is playing. + * The display object can be a normal texture, or it can be a display of a child armature, a grid display object, + * and a custom other display object. + * @see dragonBones.Armature + * @see dragonBones.Bone + * @see dragonBones.SlotData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 插槽附着在骨骼上,控制显示对象的显示状态和属性。 + * 一个骨骼上可以包含多个插槽。 + * 一个插槽中可以包含多个显示对象,同一时间只能显示其中的一个显示对象,但可以在动画播放的过程中切换显示对象实现帧动画。 + * 显示对象可以是普通的图片纹理,也可以是子骨架的显示容器,网格显示对象,还可以是自定义的其他显示对象。 + * @see dragonBones.Armature + * @see dragonBones.Bone + * @see dragonBones.SlotData + * @version DragonBones 3.0 + * @language zh_CN + */ + abstract class Slot extends TransformObject { + /** + * - Displays the animated state or mixed group name controlled by the object, set to null to be controlled by all animation states. + * @default null + * @see dragonBones.AnimationState#displayControl + * @see dragonBones.AnimationState#name + * @see dragonBones.AnimationState#group + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 显示对象受到控制的动画状态或混合组名称,设置为 null 则表示受所有的动画状态控制。 + * @default null + * @see dragonBones.AnimationState#displayControl + * @see dragonBones.AnimationState#name + * @see dragonBones.AnimationState#group + * @version DragonBones 4.5 + * @language zh_CN + */ + displayController: string | null; + /** + * @private + */ + protected _displayDirty: boolean; + /** + * @private + */ + protected _zOrderDirty: boolean; + /** + * @private + */ + protected _visibleDirty: boolean; + /** + * @private + */ + protected _blendModeDirty: boolean; + /** + * @internal + * @private + */ + _colorDirty: boolean; + /** + * @internal + * @private + */ + _meshDirty: boolean; + /** + * @private + */ + protected _transformDirty: boolean; + /** + * @private + */ + protected _visible: boolean; + /** + * @private + */ + protected _blendMode: BlendMode; + /** + * @private + */ + protected _displayIndex: number; + /** + * @private + */ + protected _animationDisplayIndex: number; + /** + * @internal + * @private + */ + _zOrder: number; + /** + * @private + */ + protected _cachedFrameIndex: number; + /** + * @internal + * @private + */ + _pivotX: number; + /** + * @internal + * @private + */ + _pivotY: number; + /** + * @private + */ + protected readonly _localMatrix: Matrix; + /** + * @internal + * @private + */ + readonly _colorTransform: ColorTransform; + /** + * @internal + * @private + */ + readonly _deformVertices: Array; + /** + * @private + */ + readonly _displayDatas: Array; + /** + * @private + */ + protected readonly _displayList: Array; + /** + * @private + */ + protected readonly _meshBones: Array; + /** + * @private + */ + protected readonly _meshSlots: Array; + /** + * @internal + * @private + */ + _slotData: SlotData; + /** + * @private + */ + protected _rawDisplayDatas: Array | null; + /** + * @private + */ + protected _displayData: DisplayData | null; + /** + * @private + */ + protected _textureData: TextureData | null; + /** + * @internal + * @private + */ + _meshData: MeshDisplayData | null; + /** + * @private + */ + protected _boundingBoxData: BoundingBoxData | null; + /** + * @private + */ + protected _rawDisplay: any; + /** + * @private + */ + protected _meshDisplay: any; + /** + * @private + */ + protected _display: any; + /** + * @private + */ + protected _childArmature: Armature | null; + /** + * @internal + * @private + */ + _cachedFrameIndices: Array | null; + /** + * @inheritDoc + */ + protected _onClear(): void; + /** + * @private + */ + protected abstract _initDisplay(value: any, isRetain: boolean): void; + /** + * @private + */ + protected abstract _disposeDisplay(value: any, isRelease: boolean): void; + /** + * @private + */ + protected abstract _onUpdateDisplay(): void; + /** + * @private + */ + protected abstract _addDisplay(): void; + /** + * @private + */ + protected abstract _replaceDisplay(value: any): void; + /** + * @private + */ + protected abstract _removeDisplay(): void; + /** + * @private + */ + protected abstract _updateZOrder(): void; + /** + * @private + */ + abstract _updateVisible(): void; + /** + * @private + */ + protected abstract _updateBlendMode(): void; + /** + * @private + */ + protected abstract _updateColor(): void; + /** + * @private + */ + protected abstract _updateFrame(): void; + /** + * @private + */ + protected abstract _updateMesh(): void; + /** + * @internal + * @private + */ + abstract _updateGlueMesh(): void; + /** + * @private + */ + protected abstract _updateTransform(): void; + /** + * @private + */ + protected abstract _identityTransform(): void; + /** + * @private + */ + protected _getDefaultRawDisplayData(): DisplayData | null; + /** + * @private + */ + protected _updateDisplayData(): void; + /** + * @private + */ + protected _updateDisplay(): void; + /** + * @private + */ + protected _updateGlobalTransformMatrix(isCache: boolean): void; + /** + * @private + */ + protected _isMeshBonesUpdate(): boolean; + /** + * @inheritDoc + */ + _setArmature(value: Armature | null): void; + /** + * @internal + * @private + */ + _setDisplayIndex(value: number, isAnimation?: boolean): boolean; + /** + * @internal + * @private + */ + _setZorder(value: number): boolean; + /** + * @internal + * @private + */ + _setColor(value: ColorTransform): boolean; + /** + * @internal + * @private + */ + _setDisplayList(value: Array | null): boolean; + /** + * @internal + * @private + */ + init(slotData: SlotData, displayDatas: Array | null, rawDisplay: any, meshDisplay: any): void; + /** + * @internal + * @private + */ + update(cacheFrameIndex: number): void; + /** + * @private + */ + updateTransformAndMatrix(): void; + /** + * @private + */ + replaceDisplayData(value: DisplayData | null, displayIndex?: number): void; + /** + * - Check whether a specific point is inside a custom bounding box in the slot. + * The coordinate system of the point is the inner coordinate system of the armature. + * Custom bounding boxes need to be customized in Dragonbones Pro. + * @param x - The horizontal coordinate of the point. + * @param y - The vertical coordinate of the point. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 检查特定点是否在插槽的自定义边界框内。 + * 点的坐标系为骨架内坐标系。 + * 自定义边界框需要在 DragonBones Pro 中自定义。 + * @param x - 点的水平坐标。 + * @param y - 点的垂直坐标。 + * @version DragonBones 5.0 + * @language zh_CN + */ + containsPoint(x: number, y: number): boolean; + /** + * - Check whether a specific segment intersects a custom bounding box for the slot. + * The coordinate system of the segment and intersection is the inner coordinate system of the armature. + * Custom bounding boxes need to be customized in Dragonbones Pro. + * @param xA - The horizontal coordinate of the beginning of the segment. + * @param yA - The vertical coordinate of the beginning of the segment. + * @param xB - The horizontal coordinate of the end point of the segment. + * @param yB - The vertical coordinate of the end point of the segment. + * @param intersectionPointA - The first intersection at which a line segment intersects the bounding box from the beginning to the end. (If not set, the intersection point will not calculated) + * @param intersectionPointB - The first intersection at which a line segment intersects the bounding box from the end to the beginning. (If not set, the intersection point will not calculated) + * @param normalRadians - The normal radians of the tangent of the intersection boundary box. [x: Normal radian of the first intersection tangent, y: Normal radian of the second intersection tangent] (If not set, the normal will not calculated) + * @returns Intersection situation. [1: Disjoint and segments within the bounding box, 0: Disjoint, 1: Intersecting and having a nodal point and ending in the bounding box, 2: Intersecting and having a nodal point and starting at the bounding box, 3: Intersecting and having two intersections, N: Intersecting and having N intersections] + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 检查特定线段是否与插槽的自定义边界框相交。 + * 线段和交点的坐标系均为骨架内坐标系。 + * 自定义边界框需要在 DragonBones Pro 中自定义。 + * @param xA - 线段起点的水平坐标。 + * @param yA - 线段起点的垂直坐标。 + * @param xB - 线段终点的水平坐标。 + * @param yB - 线段终点的垂直坐标。 + * @param intersectionPointA - 线段从起点到终点与边界框相交的第一个交点。 (如果未设置,则不计算交点) + * @param intersectionPointB - 线段从终点到起点与边界框相交的第一个交点。 (如果未设置,则不计算交点) + * @param normalRadians - 交点边界框切线的法线弧度。 [x: 第一个交点切线的法线弧度, y: 第二个交点切线的法线弧度] (如果未设置,则不计算法线) + * @returns 相交的情况。 [-1: 不相交且线段在包围盒内, 0: 不相交, 1: 相交且有一个交点且终点在包围盒内, 2: 相交且有一个交点且起点在包围盒内, 3: 相交且有两个交点, N: 相交且有 N 个交点] + * @version DragonBones 5.0 + * @language zh_CN + */ + intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): number; + /** + * - Forces the slot to update the state of the display object in the next frame. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 强制插槽在下一帧更新显示对象的状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + invalidUpdate(): void; + /** + * - The visible of slot's display object. + * @default true + * @version DragonBones 5.6 + * @language en_US + */ + /** + * - 插槽的显示对象的可见。 + * @default true + * @version DragonBones 5.6 + * @language zh_CN + */ + visible: boolean; + /** + * - The index of the display object displayed in the display list. + * @example + *
+         *     let slot = armature.getSlot("weapon");
+         *     slot.displayIndex = 3;
+         *     slot.displayController = "none";
+         * 
+ * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 此时显示的显示对象在显示列表中的索引。 + * @example + *
+         *     let slot = armature.getSlot("weapon");
+         *     slot.displayIndex = 3;
+         *     slot.displayController = "none";
+         * 
+ * @version DragonBones 4.5 + * @language zh_CN + */ + displayIndex: number; + /** + * - The slot name. + * @see dragonBones.SlotData#name + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 插槽名称。 + * @see dragonBones.SlotData#name + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly name: string; + /** + * - Contains a display list of display objects or child armatures. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 包含显示对象或子骨架的显示列表。 + * @version DragonBones 3.0 + * @language zh_CN + */ + displayList: Array; + /** + * - The slot data. + * @see dragonBones.SlotData + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 插槽数据。 + * @see dragonBones.SlotData + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly slotData: SlotData; + /** + * @private + */ + rawDisplayDatas: Array | null; + /** + * - The custom bounding box data for the slot at current time. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 插槽此时的自定义包围盒数据。 + * @version DragonBones 5.0 + * @language zh_CN + */ + readonly boundingBoxData: BoundingBoxData | null; + /** + * @private + */ + readonly rawDisplay: any; + /** + * @private + */ + readonly meshDisplay: any; + /** + * - The display object that the slot displays at this time. + * @example + *
+         *     let slot = armature.getSlot("text");
+         *     slot.display = new yourEngine.TextField();
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 插槽此时显示的显示对象。 + * @example + *
+         *     let slot = armature.getSlot("text");
+         *     slot.display = new yourEngine.TextField();
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + display: any; + /** + * - The child armature that the slot displayed at current time. + * @example + *
+         *     let slot = armature.getSlot("weapon");
+         *     slot.childArmature = factory.buildArmature("weapon_blabla", "weapon_blabla_project");
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 插槽此时显示的子骨架。 + * @example + *
+         *     let slot = armature.getSlot("weapon");
+         *     slot.childArmature = factory.buildArmature("weapon_blabla", "weapon_blabla_project");
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + childArmature: Armature | null; + /** + * - Deprecated, please refer to {@link #display}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #display}。 + * @deprecated + * @language zh_CN + */ + getDisplay(): any; + /** + * - Deprecated, please refer to {@link #display}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #display}。 + * @deprecated + * @language zh_CN + */ + setDisplay(value: any): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + abstract class Constraint extends BaseObject { + protected static readonly _helpMatrix: Matrix; + protected static readonly _helpTransform: Transform; + protected static readonly _helpPoint: Point; + /** + * - For timeline state. + * @internal + */ + _constraintData: ConstraintData; + protected _armature: Armature; + /** + * - For sort bones. + * @internal + */ + _target: Bone; + /** + * - For sort bones. + * @internal + */ + _root: Bone; + protected _bone: Bone | null; + protected _onClear(): void; + abstract init(constraintData: ConstraintData, armature: Armature): void; + abstract update(): void; + abstract invalidUpdate(): void; + readonly name: string; + } + /** + * @internal + * @private + */ + class IKConstraint extends Constraint { + static toString(): string; + private _scaleEnabled; + /** + * - For timeline state. + * @internal + */ + _bendPositive: boolean; + /** + * - For timeline state. + * @internal + */ + _weight: number; + protected _onClear(): void; + private _computeA(); + private _computeB(); + init(constraintData: ConstraintData, armature: Armature): void; + update(): void; + invalidUpdate(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - Play animation interface. (Both Armature and Wordclock implement the interface) + * Any instance that implements the interface can be added to the Worldclock instance and advance time by Worldclock instance uniformly. + * @see dragonBones.WorldClock + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 播放动画接口。 (Armature 和 WordClock 都实现了该接口) + * 任何实现了此接口的实例都可以添加到 WorldClock 实例中,由 WorldClock 实例统一更新时间。 + * @see dragonBones.WorldClock + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + interface IAnimatable { + /** + * - Advance time. + * @param passedTime - Passed time. (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 更新时间。 + * @param passedTime - 前进的时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + advanceTime(passedTime: number): void; + /** + * - The Wordclock instance to which the current belongs. + * @example + *
+         *     armature.clock = factory.clock; // Add armature to clock.
+         *     armature.clock = null; // Remove armature from clock.
+         * 
+ * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 当前所属的 WordClock 实例。 + * @example + *
+         *     armature.clock = factory.clock; // 将骨架添加到时钟。
+         *     armature.clock = null; // 将骨架从时钟移除。
+         * 
+ * @version DragonBones 5.0 + * @language zh_CN + */ + clock: WorldClock | null; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - Worldclock provides clock support for animations, advance time for each IAnimatable object added to the instance. + * @see dragonBones.IAnimateble + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - WorldClock 对动画提供时钟支持,为每个加入到该实例的 IAnimatable 对象更新时间。 + * @see dragonBones.IAnimateble + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + class WorldClock implements IAnimatable { + /** + * - Current time. (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 当前的时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + time: number; + /** + * - The play speed, used to control animation speed-shift play. + * [0: Stop play, (0~1): Slow play, 1: Normal play, (1~N): Fast play] + * @default 1.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 播放速度,用于控制动画变速播放。 + * [0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + timeScale: number; + private readonly _animatebles; + private _clock; + /** + * - Creating a Worldclock instance. Typically, you do not need to create Worldclock instance. + * When multiple Worldclock instances are running at different speeds, can achieving some specific animation effects, such as bullet time. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 创建一个 WorldClock 实例。通常并不需要创建 WorldClock 实例。 + * 当多个 WorldClock 实例使用不同的速度运行时,可以实现一些特殊的动画效果,比如子弹时间等。 + * @version DragonBones 3.0 + * @language zh_CN + */ + constructor(time?: number); + /** + * - Advance time for all IAnimatable instances. + * @param passedTime - Passed time. [-1: Automatically calculates the time difference between the current frame and the previous frame, [0~N): Passed time] (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 为所有的 IAnimatable 实例更新时间。 + * @param passedTime - 前进的时间。 [-1: 自动计算当前帧与上一帧的时间差, [0~N): 前进的时间] (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + advanceTime(passedTime: number): void; + /** + * - Check whether contains a specific instance of IAnimatable. + * @param value - The IAnimatable instance. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 检查是否包含特定的 IAnimatable 实例。 + * @param value - IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + contains(value: IAnimatable): boolean; + /** + * - Add IAnimatable instance. + * @param value - The IAnimatable instance. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 添加 IAnimatable 实例。 + * @param value - IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + add(value: IAnimatable): void; + /** + * - Removes a specified IAnimatable instance. + * @param value - The IAnimatable instance. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 移除特定的 IAnimatable 实例。 + * @param value - IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + remove(value: IAnimatable): void; + /** + * - Clear all IAnimatable instances. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 清除所有的 IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + clear(): void; + /** + * @inheritDoc + */ + clock: WorldClock | null; + /** + * - Deprecated, please refer to {@link dragonBones.BaseFactory#clock}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link dragonBones.BaseFactory#clock}。 + * @deprecated + * @language zh_CN + */ + static readonly clock: WorldClock; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The animation player is used to play the animation data and manage the animation states. + * @see dragonBones.AnimationData + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画播放器用来播放动画数据和管理动画状态。 + * @see dragonBones.AnimationData + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + class Animation extends BaseObject { + static toString(): string; + /** + * - The play speed of all animations. [0: Stop, (0~1): Slow, 1: Normal, (1~N): Fast] + * @default 1.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 所有动画的播放速度。 [0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + timeScale: number; + private _lockUpdate; + private _animationDirty; + private _inheritTimeScale; + private readonly _animationNames; + private readonly _animationStates; + private readonly _animations; + private _armature; + private _animationConfig; + private _lastAnimationState; + /** + * @private + */ + protected _onClear(): void; + private _fadeOut(animationConfig); + /** + * @internal + * @private + */ + init(armature: Armature): void; + /** + * @internal + * @private + */ + advanceTime(passedTime: number): void; + /** + * - Clear all animations states. + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 清除所有的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + reset(): void; + /** + * - Pause a specific animation state. + * @param animationName - The name of animation state. (If not set, it will pause all animations) + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 暂停指定动画状态的播放。 + * @param animationName - 动画状态名称。 (如果未设置,则暂停所有动画) + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + stop(animationName?: string | null): void; + /** + * - Play animation with a specific animation config. + * The API is still in the experimental phase and may encounter bugs or stability or compatibility issues when used. + * @param animationConfig - The animation config. + * @returns The playing animation state. + * @see dragonBones.AnimationConfig + * @beta + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 通过指定的动画配置来播放动画。 + * 该 API 仍在实验阶段,使用时可能遭遇 bug 或稳定性或兼容性问题。 + * @param animationConfig - 动画配置。 + * @returns 播放的动画状态。 + * @see dragonBones.AnimationConfig + * @beta + * @version DragonBones 5.0 + * @language zh_CN + */ + playConfig(animationConfig: AnimationConfig): AnimationState | null; + /** + * - Play a specific animation. + * @param animationName - The name of animation data. (If not set, The default animation will be played, or resume the animation playing from pause status, or replay the last playing animation) + * @param playTimes - Playing repeat times. [-1: Use default value of the animation data, 0: No end loop playing, [1~N]: Repeat N times] (default: -1) + * @returns The playing animation state. + * @example + *
+         *     armature.animation.play("walk");
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 播放指定动画。 + * @param animationName - 动画数据名称。 (如果未设置,则播放默认动画,或将暂停状态切换为播放状态,或重新播放之前播放的动画) + * @param playTimes - 循环播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) + * @returns 播放的动画状态。 + * @example + *
+         *     armature.animation.play("walk");
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + play(animationName?: string | null, playTimes?: number): AnimationState | null; + /** + * - Fade in a specific animation. + * @param animationName - The name of animation data. + * @param fadeInTime - The fade in time. [-1: Use the default value of animation data, [0~N]: The fade in time (In seconds)] (Default: -1) + * @param playTimes - playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) + * @param layer - The blending layer, the animation states in high level layer will get the blending weights with high priority, when the total blending weights are more than 1.0, there will be no more weights can be allocated to the other animation states. (Default: 0) + * @param group - The blending group name, it is typically used to specify the substitution of multiple animation states blending. (Default: null) + * @param fadeOutMode - The fade out mode, which is typically used to specify alternate mode of multiple animation states blending. (Default: AnimationFadeOutMode.SameLayerAndGroup) + * @returns The playing animation state. + * @example + *
+         *     armature.animation.fadeIn("walk", 0.3, 0, 0, "normalGroup").resetToPose = false;
+         *     armature.animation.fadeIn("attack", 0.3, 1, 0, "attackGroup").resetToPose = false;
+         * 
+ * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 淡入播放指定的动画。 + * @param animationName - 动画数据名称。 + * @param fadeInTime - 淡入时间。 [-1: 使用动画数据默认值, [0~N]: 淡入时间 (以秒为单位)] (默认: -1) + * @param playTimes - 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) + * @param layer - 混合图层,图层高的动画状态会优先获取混合权重,当混合权重分配总和超过 1.0 时,剩余的动画状态将不能再获得权重分配。 (默认: 0) + * @param group - 混合组名称,该属性通常用来指定多个动画状态混合时的相互替换关系。 (默认: null) + * @param fadeOutMode - 淡出模式,该属性通常用来指定多个动画状态混合时的相互替换模式。 (默认: AnimationFadeOutMode.SameLayerAndGroup) + * @returns 播放的动画状态。 + * @example + *
+         *     armature.animation.fadeIn("walk", 0.3, 0, 0, "normalGroup").resetToPose = false;
+         *     armature.animation.fadeIn("attack", 0.3, 1, 0, "attackGroup").resetToPose = false;
+         * 
+ * @version DragonBones 4.5 + * @language zh_CN + */ + fadeIn(animationName: string, fadeInTime?: number, playTimes?: number, layer?: number, group?: string | null, fadeOutMode?: AnimationFadeOutMode): AnimationState | null; + /** + * - Play a specific animation from the specific time. + * @param animationName - The name of animation data. + * @param time - The start time point of playing. (In seconds) + * @param playTimes - Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) + * @returns The played animation state. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 从指定时间开始播放指定的动画。 + * @param animationName - 动画数据名称。 + * @param time - 播放开始的时间。 (以秒为单位) + * @param playTimes - 循环播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) + * @returns 播放的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndPlayByTime(animationName: string, time?: number, playTimes?: number): AnimationState | null; + /** + * - Play a specific animation from the specific frame. + * @param animationName - The name of animation data. + * @param frame - The start frame of playing. + * @param playTimes - Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) + * @returns The played animation state. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 从指定帧开始播放指定的动画。 + * @param animationName - 动画数据名称。 + * @param frame - 播放开始的帧数。 + * @param playTimes - 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) + * @returns 播放的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndPlayByFrame(animationName: string, frame?: number, playTimes?: number): AnimationState | null; + /** + * - Play a specific animation from the specific progress. + * @param animationName - The name of animation data. + * @param progress - The start progress value of playing. + * @param playTimes - Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) + * @returns The played animation state. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 从指定进度开始播放指定的动画。 + * @param animationName - 动画数据名称。 + * @param progress - 开始播放的进度。 + * @param playTimes - 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) + * @returns 播放的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndPlayByProgress(animationName: string, progress?: number, playTimes?: number): AnimationState | null; + /** + * - Stop a specific animation at the specific time. + * @param animationName - The name of animation data. + * @param time - The stop time. (In seconds) + * @returns The played animation state. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 在指定时间停止指定动画播放 + * @param animationName - 动画数据名称。 + * @param time - 停止的时间。 (以秒为单位) + * @returns 播放的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndStopByTime(animationName: string, time?: number): AnimationState | null; + /** + * - Stop a specific animation at the specific frame. + * @param animationName - The name of animation data. + * @param frame - The stop frame. + * @returns The played animation state. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 在指定帧停止指定动画的播放 + * @param animationName - 动画数据名称。 + * @param frame - 停止的帧数。 + * @returns 播放的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndStopByFrame(animationName: string, frame?: number): AnimationState | null; + /** + * - Stop a specific animation at the specific progress. + * @param animationName - The name of animation data. + * @param progress - The stop progress value. + * @returns The played animation state. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 在指定的进度停止指定的动画播放。 + * @param animationName - 动画数据名称。 + * @param progress - 停止进度。 + * @returns 播放的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndStopByProgress(animationName: string, progress?: number): AnimationState | null; + /** + * - Get a specific animation state. + * @param animationName - The name of animation state. + * @example + *
+         *     armature.animation.play("walk");
+         *     let walkState = armature.animation.getState("walk");
+         *     walkState.timeScale = 0.5;
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取指定的动画状态 + * @param animationName - 动画状态名称。 + * @example + *
+         *     armature.animation.play("walk");
+         *     let walkState = armature.animation.getState("walk");
+         *     walkState.timeScale = 0.5;
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + getState(animationName: string): AnimationState | null; + /** + * - Check whether a specific animation data is included. + * @param animationName - The name of animation data. + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 检查是否包含指定的动画数据 + * @param animationName - 动画数据名称。 + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language zh_CN + */ + hasAnimation(animationName: string): boolean; + /** + * - Get all the animation states. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 获取所有的动画状态 + * @version DragonBones 5.1 + * @language zh_CN + */ + getStates(): Array; + /** + * - Check whether there is an animation state is playing + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 检查是否有动画状态正在播放 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly isPlaying: boolean; + /** + * - Check whether all the animation states' playing were finished. + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 检查是否所有的动画状态均已播放完毕。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly isCompleted: boolean; + /** + * - The name of the last playing animation state. + * @see #lastAnimationState + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 上一个播放的动画状态名称 + * @see #lastAnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly lastAnimationName: string; + /** + * - The name of all animation data + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 所有动画数据的名称 + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly animationNames: Array; + /** + * - All animation data. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 所有的动画数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + animations: Map; + /** + * - An AnimationConfig instance that can be used quickly. + * @see dragonBones.AnimationConfig + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 一个可以快速使用的动画配置实例。 + * @see dragonBones.AnimationConfig + * @version DragonBones 5.0 + * @language zh_CN + */ + readonly animationConfig: AnimationConfig; + /** + * - The last playing animation state + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 上一个播放的动画状态 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly lastAnimationState: AnimationState | null; + /** + * - Deprecated, please refer to {@link #play()} {@link #fadeIn()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #play()} {@link #fadeIn()}。 + * @deprecated + * @language zh_CN + */ + gotoAndPlay(animationName: string, fadeInTime?: number, duration?: number, playTimes?: number, layer?: number, group?: string | null, fadeOutMode?: AnimationFadeOutMode, pauseFadeOut?: boolean, pauseFadeIn?: boolean): AnimationState | null; + /** + * - Deprecated, please refer to {@link #gotoAndStopByTime()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #gotoAndStopByTime()}。 + * @deprecated + * @language zh_CN + */ + gotoAndStop(animationName: string, time?: number): AnimationState | null; + /** + * - Deprecated, please refer to {@link #animationNames}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #animationNames}。 + * @deprecated + * @language zh_CN + */ + readonly animationList: Array; + /** + * - Deprecated, please refer to {@link #animationNames}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #animationNames}。 + * @deprecated + * @language zh_CN + */ + readonly animationDataList: Array; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The animation state is generated when the animation data is played. + * @see dragonBones.Animation + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画状态由播放动画数据时产生。 + * @see dragonBones.Animation + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language zh_CN + */ + class AnimationState extends BaseObject { + static toString(): string; + /** + * @private + */ + actionEnabled: boolean; + /** + * @private + */ + additiveBlending: boolean; + /** + * - Whether the animation state has control over the display object properties of the slots. + * Sometimes blend a animation state does not want it to control the display object properties of the slots, + * especially if other animation state are controlling the display object properties of the slots. + * @default true + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画状态是否对插槽的显示对象属性有控制权。 + * 有时混合一个动画状态并不希望其控制插槽的显示对象属性, + * 尤其是其他动画状态正在控制这些插槽的显示对象属性时。 + * @default true + * @version DragonBones 5.0 + * @language zh_CN + */ + displayControl: boolean; + /** + * - Whether to reset the objects without animation to the armature pose when the animation state is start to play. + * This property should usually be set to false when blend multiple animation states. + * @default true + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 开始播放动画状态时是否将没有动画的对象重置为骨架初始值。 + * 通常在混合多个动画状态时应该将该属性设置为 false。 + * @default true + * @version DragonBones 5.1 + * @language zh_CN + */ + resetToPose: boolean; + /** + * - The play times. [0: Loop play, [1~N]: Play N times] + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 播放次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次] + * @version DragonBones 3.0 + * @language zh_CN + */ + playTimes: number; + /** + * - The blend layer. + * High layer animation state will get the blend weight first. + * When the blend weight is assigned more than 1, the remaining animation states will no longer get the weight assigned. + * @readonly + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 混合图层。 + * 图层高的动画状态会优先获取混合权重。 + * 当混合权重分配超过 1 时,剩余的动画状态将不再获得权重分配。 + * @readonly + * @version DragonBones 5.0 + * @language zh_CN + */ + layer: number; + /** + * - The play speed. + * The value is an overlay relationship with {@link dragonBones.Animation#timeScale}. + * [(-N~0): Reverse play, 0: Stop play, (0~1): Slow play, 1: Normal play, (1~N): Fast play] + * @default 1.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 播放速度。 + * 该值与 {@link dragonBones.Animation#timeScale} 是叠加关系。 + * [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + timeScale: number; + /** + * - The blend weight. + * @default 1.0 + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 混合权重。 + * @default 1.0 + * @version DragonBones 5.0 + * @language zh_CN + */ + weight: number; + /** + * - The auto fade out time when the animation state play completed. + * [-1: Do not fade out automatically, [0~N]: The fade out time] (In seconds) + * @default -1.0 + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画状态播放完成后的自动淡出时间。 + * [-1: 不自动淡出, [0~N]: 淡出时间] (以秒为单位) + * @default -1.0 + * @version DragonBones 5.0 + * @language zh_CN + */ + autoFadeOutTime: number; + /** + * @private + */ + fadeTotalTime: number; + /** + * - The name of the animation state. (Can be different from the name of the animation data) + * @readonly + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画状态名称。 (可以不同于动画数据) + * @readonly + * @version DragonBones 5.0 + * @language zh_CN + */ + name: string; + /** + * - The blend group name of the animation state. + * This property is typically used to specify the substitution of multiple animation states blend. + * @readonly + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 混合组名称。 + * 该属性通常用来指定多个动画状态混合时的相互替换关系。 + * @readonly + * @version DragonBones 5.0 + * @language zh_CN + */ + group: string; + private _timelineDirty; + /** + * - xx: Play Enabled, Fade Play Enabled + * @internal + * @private + */ + _playheadState: number; + /** + * -1: Fade in, 0: Fade complete, 1: Fade out; + * @internal + * @private + */ + _fadeState: number; + /** + * -1: Fade start, 0: Fading, 1: Fade complete; + * @internal + * @private + */ + _subFadeState: number; + /** + * @internal + * @private + */ + _position: number; + /** + * @internal + * @private + */ + _duration: number; + private _fadeTime; + private _time; + /** + * @internal + * @private + */ + _fadeProgress: number; + /** + * @internal + * @private + */ + _weightResult: number; + /** + * @internal + * @private + */ + readonly _blendState: BlendState; + private readonly _boneMask; + private readonly _boneTimelines; + private readonly _surfaceTimelines; + private readonly _slotTimelines; + private readonly _constraintTimelines; + private readonly _animationTimelines; + private readonly _poseTimelines; + private readonly _bonePoses; + /** + * @internal + * @private + */ + _animationData: AnimationData; + private _armature; + /** + * @internal + * @private + */ + _actionTimeline: ActionTimelineState; + private _zOrderTimeline; + /** + * @internal + * @private + */ + _parent: AnimationState; + /** + * @private + */ + protected _onClear(): void; + private _updateTimelines(); + private _updateBoneAndSlotTimelines(); + private _advanceFadeTime(passedTime); + /** + * @internal + * @private + */ + init(armature: Armature, animationData: AnimationData, animationConfig: AnimationConfig): void; + /** + * @internal + * @private + */ + advanceTime(passedTime: number, cacheFrameRate: number): void; + /** + * - Continue play. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 继续播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + play(): void; + /** + * - Stop play. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 暂停播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + stop(): void; + /** + * - Fade out the animation state. + * @param fadeOutTime - The fade out time. (In seconds) + * @param pausePlayhead - Whether to pause the animation playing when fade out. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 淡出动画状态。 + * @param fadeOutTime - 淡出时间。 (以秒为单位) + * @param pausePlayhead - 淡出时是否暂停播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + fadeOut(fadeOutTime: number, pausePlayhead?: boolean): void; + /** + * - Check if a specific bone mask is included. + * @param name - The bone name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 检查是否包含特定骨骼遮罩。 + * @param name - 骨骼名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + containsBoneMask(name: string): boolean; + /** + * - Add a specific bone mask. + * @param name - The bone name. + * @param recursive - Whether or not to add a mask to the bone's sub-bone. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 添加特定的骨骼遮罩。 + * @param name - 骨骼名称。 + * @param recursive - 是否为该骨骼的子骨骼添加遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + addBoneMask(name: string, recursive?: boolean): void; + /** + * - Remove the mask of a specific bone. + * @param name - The bone name. + * @param recursive - Whether to remove the bone's sub-bone mask. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 删除特定骨骼的遮罩。 + * @param name - 骨骼名称。 + * @param recursive - 是否删除该骨骼的子骨骼遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + removeBoneMask(name: string, recursive?: boolean): void; + /** + * - Remove all bone masks. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 删除所有骨骼遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + removeAllBoneMask(): void; + /** + * - Whether the animation state is fading in. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 是否正在淡入。 + * @version DragonBones 5.1 + * @language zh_CN + */ + readonly isFadeIn: boolean; + /** + * - Whether the animation state is fading out. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 是否正在淡出。 + * @version DragonBones 5.1 + * @language zh_CN + */ + readonly isFadeOut: boolean; + /** + * - Whether the animation state is fade completed. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 是否淡入或淡出完毕。 + * @version DragonBones 5.1 + * @language zh_CN + */ + readonly isFadeComplete: boolean; + /** + * - Whether the animation state is playing. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 是否正在播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly isPlaying: boolean; + /** + * - Whether the animation state is play completed. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 是否播放完毕。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly isCompleted: boolean; + /** + * - The times has been played. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 已经循环播放的次数。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly currentPlayTimes: number; + /** + * - The total time. (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 总播放时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly totalTime: number; + /** + * - The time is currently playing. (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 当前播放的时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + currentTime: number; + /** + * - The animation data. + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画数据。 + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly animationData: AnimationData; + } + /** + * @internal + * @private + */ + class BonePose extends BaseObject { + static toString(): string; + readonly current: Transform; + readonly delta: Transform; + readonly result: Transform; + protected _onClear(): void; + } + /** + * @internal + * @private + */ + class BlendState { + dirty: boolean; + layer: number; + leftWeight: number; + layerWeight: number; + blendWeight: number; + update(weight: number, layer: number): number; + clear(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + const enum TweenState { + None = 0, + Once = 1, + Always = 2, + } + /** + * @internal + * @private + */ + abstract class TimelineState extends BaseObject { + playState: number; + currentPlayTimes: number; + currentTime: number; + protected _tweenState: TweenState; + protected _frameRate: number; + protected _frameValueOffset: number; + protected _frameCount: number; + protected _frameOffset: number; + protected _frameIndex: number; + protected _frameRateR: number; + protected _position: number; + protected _duration: number; + protected _timeScale: number; + protected _timeOffset: number; + protected _dragonBonesData: DragonBonesData; + protected _animationData: AnimationData; + protected _timelineData: TimelineData | null; + protected _armature: Armature; + protected _animationState: AnimationState; + protected _actionTimeline: TimelineState; + protected _frameArray: Array | Int16Array; + protected _frameIntArray: Array | Int16Array; + protected _frameFloatArray: Array | Int16Array; + protected _timelineArray: Array | Uint16Array; + protected _frameIndices: Array; + protected _onClear(): void; + protected abstract _onArriveAtFrame(): void; + protected abstract _onUpdateFrame(): void; + protected _setCurrentTime(passedTime: number): boolean; + init(armature: Armature, animationState: AnimationState, timelineData: TimelineData | null): void; + fadeOut(): void; + update(passedTime: number): void; + } + /** + * @internal + * @private + */ + abstract class TweenTimelineState extends TimelineState { + private static _getEasingValue(tweenType, progress, easing); + private static _getEasingCurveValue(progress, samples, count, offset); + protected _tweenType: TweenType; + protected _curveCount: number; + protected _framePosition: number; + protected _frameDurationR: number; + protected _tweenProgress: number; + protected _tweenEasing: number; + protected _onClear(): void; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + } + /** + * @internal + * @private + */ + abstract class BoneTimelineState extends TweenTimelineState { + bone: Bone; + bonePose: BonePose; + protected _onClear(): void; + blend(state: number): void; + } + /** + * @internal + * @private + */ + abstract class SlotTimelineState extends TweenTimelineState { + slot: Slot; + protected _onClear(): void; + } + /** + * @internal + * @private + */ + abstract class ConstraintTimelineState extends TweenTimelineState { + constraint: Constraint; + protected _onClear(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + class ActionTimelineState extends TimelineState { + static toString(): string; + private _onCrossFrame(frameIndex); + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + update(passedTime: number): void; + setCurrentTime(value: number): void; + } + /** + * @internal + * @private + */ + class ZOrderTimelineState extends TimelineState { + static toString(): string; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + } + /** + * @internal + * @private + */ + class BoneAllTimelineState extends BoneTimelineState { + static toString(): string; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + fadeOut(): void; + } + /** + * @internal + * @private + */ + class BoneTranslateTimelineState extends BoneTimelineState { + static toString(): string; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + } + /** + * @internal + * @private + */ + class BoneRotateTimelineState extends BoneTimelineState { + static toString(): string; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + fadeOut(): void; + } + /** + * @internal + * @private + */ + class BoneScaleTimelineState extends BoneTimelineState { + static toString(): string; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + } + /** + * @internal + * @private + */ + class SurfaceTimelineState extends TweenTimelineState { + static toString(): string; + surface: Surface; + private _frameFloatOffset; + private _valueCount; + private _deformCount; + private _valueOffset; + private readonly _current; + private readonly _delta; + private readonly _result; + protected _onClear(): void; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + init(armature: Armature, animationState: AnimationState, timelineData: TimelineData | null): void; + blend(state: number): void; + } + /** + * @internal + * @private + */ + class SlotDislayTimelineState extends SlotTimelineState { + static toString(): string; + protected _onArriveAtFrame(): void; + } + /** + * @internal + * @private + */ + class SlotColorTimelineState extends SlotTimelineState { + static toString(): string; + private _dirty; + private readonly _current; + private readonly _delta; + private readonly _result; + protected _onClear(): void; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + fadeOut(): void; + update(passedTime: number): void; + } + /** + * @internal + * @private + */ + class SlotFFDTimelineState extends SlotTimelineState { + static toString(): string; + meshOffset: number; + private _dirty; + private _frameFloatOffset; + private _valueCount; + private _deformCount; + private _valueOffset; + private readonly _current; + private readonly _delta; + private readonly _result; + protected _onClear(): void; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + init(armature: Armature, animationState: AnimationState, timelineData: TimelineData | null): void; + fadeOut(): void; + update(passedTime: number): void; + } + /** + * @internal + * @private + */ + class IKConstraintTimelineState extends ConstraintTimelineState { + static toString(): string; + private _current; + private _delta; + protected _onClear(): void; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + } + /** + * @internal + * @private + */ + class AnimationTimelineState extends TweenTimelineState { + static toString(): string; + animationState: AnimationState; + private readonly _floats; + protected _onClear(): void; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + blend(state: number): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The properties of the object carry basic information about an event, + * which are passed as parameter or parameter's parameter to event listeners when an event occurs. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 事件对象,包含有关事件的基本信息,当发生事件时,该实例将作为参数或参数的参数传递给事件侦听器。 + * @version DragonBones 4.5 + * @language zh_CN + */ + class EventObject extends BaseObject { + /** + * - Animation start play. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画开始播放。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly START: string; + /** + * - Animation loop play complete once. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画循环播放完成一次。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly LOOP_COMPLETE: string; + /** + * - Animation play complete. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画播放完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly COMPLETE: string; + /** + * - Animation fade in start. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画淡入开始。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly FADE_IN: string; + /** + * - Animation fade in complete. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画淡入完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly FADE_IN_COMPLETE: string; + /** + * - Animation fade out start. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画淡出开始。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly FADE_OUT: string; + /** + * - Animation fade out complete. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画淡出完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly FADE_OUT_COMPLETE: string; + /** + * - Animation frame event. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画帧事件。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly FRAME_EVENT: string; + /** + * - Animation frame sound event. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画帧声音事件。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly SOUND_EVENT: string; + static toString(): string; + /** + * - If is a frame event, the value is used to describe the time that the event was in the animation timeline. (In seconds) + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 如果是帧事件,此值用来描述该事件在动画时间轴中所处的时间。(以秒为单位) + * @version DragonBones 4.5 + * @language zh_CN + */ + time: number; + /** + * - The event type。 + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 事件类型。 + * @version DragonBones 4.5 + * @language zh_CN + */ + type: EventStringType; + /** + * - The event name. (The frame event name or the frame sound name) + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 事件名称。 (帧事件的名称或帧声音的名称) + * @version DragonBones 4.5 + * @language zh_CN + */ + name: string; + /** + * - The armature that dispatch the event. + * @see dragonBones.Armature + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 发出该事件的骨架。 + * @see dragonBones.Armature + * @version DragonBones 4.5 + * @language zh_CN + */ + armature: Armature; + /** + * - The bone that dispatch the event. + * @see dragonBones.Bone + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 发出该事件的骨骼。 + * @see dragonBones.Bone + * @version DragonBones 4.5 + * @language zh_CN + */ + bone: Bone | null; + /** + * - The slot that dispatch the event. + * @see dragonBones.Slot + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 发出该事件的插槽。 + * @see dragonBones.Slot + * @version DragonBones 4.5 + * @language zh_CN + */ + slot: Slot | null; + /** + * - The animation state that dispatch the event. + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 发出该事件的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + animationState: AnimationState; + /** + * - The custom data. + * @see dragonBones.CustomData + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 自定义数据。 + * @see dragonBones.CustomData + * @version DragonBones 5.0 + * @language zh_CN + */ + data: UserData | null; + /** + * @private + */ + protected _onClear(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @private + */ + type EventStringType = string | "start" | "loopComplete" | "complete" | "fadeIn" | "fadeInComplete" | "fadeOut" | "fadeOutComplete" | "frameEvent" | "soundEvent"; + /** + * - The event dispatcher interface. + * Dragonbones event dispatch usually relies on docking engine to implement, which defines the event method to be implemented when docking the engine. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 事件派发接口。 + * DragonBones 的事件派发通常依赖于对接的引擎来实现,该接口定义了对接引擎时需要实现的事件方法。 + * @version DragonBones 4.5 + * @language zh_CN + */ + interface IEventDispatcher { + /** + * - Checks whether the object has any listeners registered for a specific type of event。 + * @param type - Event type. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 检查是否为特定的事件类型注册了任何侦听器。 + * @param type - 事件类型。 + * @version DragonBones 4.5 + * @language zh_CN + */ + hasDBEventListener(type: EventStringType): boolean; + /** + * - Dispatches an event into the event flow. + * @param type - Event type. + * @param eventObject - Event object. + * @see dragonBones.EventObject + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 分派特定的事件到事件流中。 + * @param type - 事件类型。 + * @param eventObject - 事件数据。 + * @see dragonBones.EventObject + * @version DragonBones 4.5 + * @language zh_CN + */ + dispatchDBEvent(type: EventStringType, eventObject: EventObject): void; + /** + * - Add an event listener object so that the listener receives notification of an event. + * @param type - Event type. + * @param listener - Event listener. + * @param thisObject - The listener function's "this". + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 添加特定事件类型的事件侦听器,以使侦听器能够接收事件通知。 + * @param type - 事件类型。 + * @param listener - 事件侦听器。 + * @param thisObject - 侦听函数绑定的 this 对象。 + * @version DragonBones 4.5 + * @language zh_CN + */ + addDBEventListener(type: EventStringType, listener: Function, thisObject: any): void; + /** + * - Removes a listener from the object. + * @param type - Event type. + * @param listener - Event listener. + * @param thisObject - The listener function's "this". + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 删除特定事件类型的侦听器。 + * @param type - 事件类型。 + * @param listener - 事件侦听器。 + * @param thisObject - 侦听函数绑定的 this 对象。 + * @version DragonBones 4.5 + * @language zh_CN + */ + removeDBEventListener(type: EventStringType, listener: Function, thisObject: any): void; + /** + * - Deprecated, please refer to {@link #hasDBEventListener()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #hasDBEventListener()}。 + * @deprecated + * @language zh_CN + */ + hasEvent(type: EventStringType): boolean; + /** + * - Deprecated, please refer to {@link #addDBEventListener()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #addDBEventListener()}。 + * @deprecated + * @language zh_CN + */ + addEvent(type: EventStringType, listener: Function, thisObject: any): void; + /** + * - Deprecated, please refer to {@link #removeDBEventListener()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #removeDBEventListener()}。 + * @deprecated + * @language zh_CN + */ + removeEvent(type: EventStringType, listener: Function, thisObject: any): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + abstract class DataParser { + protected static readonly DATA_VERSION_2_3: string; + protected static readonly DATA_VERSION_3_0: string; + protected static readonly DATA_VERSION_4_0: string; + protected static readonly DATA_VERSION_4_5: string; + protected static readonly DATA_VERSION_5_0: string; + protected static readonly DATA_VERSION_5_5: string; + protected static readonly DATA_VERSION: string; + protected static readonly DATA_VERSIONS: Array; + protected static readonly TEXTURE_ATLAS: string; + protected static readonly SUB_TEXTURE: string; + protected static readonly FORMAT: string; + protected static readonly IMAGE_PATH: string; + protected static readonly WIDTH: string; + protected static readonly HEIGHT: string; + protected static readonly ROTATED: string; + protected static readonly FRAME_X: string; + protected static readonly FRAME_Y: string; + protected static readonly FRAME_WIDTH: string; + protected static readonly FRAME_HEIGHT: string; + protected static readonly DRADON_BONES: string; + protected static readonly USER_DATA: string; + protected static readonly ARMATURE: string; + protected static readonly BONE: string; + protected static readonly SURFACE: string; + protected static readonly SLOT: string; + protected static readonly CONSTRAINT: string; + protected static readonly IK: string; + protected static readonly SKIN: string; + protected static readonly DISPLAY: string; + protected static readonly ANIMATION: string; + protected static readonly Z_ORDER: string; + protected static readonly FFD: string; + protected static readonly FRAME: string; + protected static readonly TRANSLATE_FRAME: string; + protected static readonly ROTATE_FRAME: string; + protected static readonly SCALE_FRAME: string; + protected static readonly DISPLAY_FRAME: string; + protected static readonly COLOR_FRAME: string; + protected static readonly DEFAULT_ACTIONS: string; + protected static readonly ACTIONS: string; + protected static readonly EVENTS: string; + protected static readonly INTS: string; + protected static readonly FLOATS: string; + protected static readonly STRINGS: string; + protected static readonly CANVAS: string; + protected static readonly TRANSFORM: string; + protected static readonly PIVOT: string; + protected static readonly AABB: string; + protected static readonly COLOR: string; + protected static readonly VERSION: string; + protected static readonly COMPATIBLE_VERSION: string; + protected static readonly FRAME_RATE: string; + protected static readonly TYPE: string; + protected static readonly SUB_TYPE: string; + protected static readonly NAME: string; + protected static readonly PARENT: string; + protected static readonly TARGET: string; + protected static readonly STAGE: string; + protected static readonly SHARE: string; + protected static readonly PATH: string; + protected static readonly LENGTH: string; + protected static readonly DISPLAY_INDEX: string; + protected static readonly BLEND_MODE: string; + protected static readonly INHERIT_TRANSLATION: string; + protected static readonly INHERIT_ROTATION: string; + protected static readonly INHERIT_SCALE: string; + protected static readonly INHERIT_REFLECTION: string; + protected static readonly INHERIT_ANIMATION: string; + protected static readonly INHERIT_DEFORM: string; + protected static readonly SEGMENT_X: string; + protected static readonly SEGMENT_Y: string; + protected static readonly BEND_POSITIVE: string; + protected static readonly CHAIN: string; + protected static readonly WEIGHT: string; + protected static readonly FADE_IN_TIME: string; + protected static readonly PLAY_TIMES: string; + protected static readonly SCALE: string; + protected static readonly OFFSET: string; + protected static readonly POSITION: string; + protected static readonly DURATION: string; + protected static readonly TWEEN_EASING: string; + protected static readonly TWEEN_ROTATE: string; + protected static readonly TWEEN_SCALE: string; + protected static readonly CLOCK_WISE: string; + protected static readonly CURVE: string; + protected static readonly SOUND: string; + protected static readonly EVENT: string; + protected static readonly ACTION: string; + protected static readonly X: string; + protected static readonly Y: string; + protected static readonly SKEW_X: string; + protected static readonly SKEW_Y: string; + protected static readonly SCALE_X: string; + protected static readonly SCALE_Y: string; + protected static readonly VALUE: string; + protected static readonly ROTATE: string; + protected static readonly SKEW: string; + protected static readonly ALPHA_OFFSET: string; + protected static readonly RED_OFFSET: string; + protected static readonly GREEN_OFFSET: string; + protected static readonly BLUE_OFFSET: string; + protected static readonly ALPHA_MULTIPLIER: string; + protected static readonly RED_MULTIPLIER: string; + protected static readonly GREEN_MULTIPLIER: string; + protected static readonly BLUE_MULTIPLIER: string; + protected static readonly UVS: string; + protected static readonly VERTICES: string; + protected static readonly TRIANGLES: string; + protected static readonly WEIGHTS: string; + protected static readonly SLOT_POSE: string; + protected static readonly BONE_POSE: string; + protected static readonly GLUE_WEIGHTS: string; + protected static readonly GLUE_MESHES: string; + protected static readonly GOTO_AND_PLAY: string; + protected static readonly DEFAULT_NAME: string; + protected static _getArmatureType(value: string): ArmatureType; + protected static _getBoneType(value: string): BoneType; + protected static _getDisplayType(value: string): DisplayType; + protected static _getBoundingBoxType(value: string): BoundingBoxType; + protected static _getActionType(value: string): ActionType; + protected static _getBlendMode(value: string): BlendMode; + abstract parseDragonBonesData(rawData: any, scale: number): DragonBonesData | null; + abstract parseTextureAtlasData(rawData: any, textureAtlasData: TextureAtlasData, scale: number): boolean; + /** + * - Deprecated, please refer to {@link dragonBones.BaseFactory#parsetTextureAtlasData()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link dragonBones.BaseFactory#parsetTextureAtlasData()}。 + * @deprecated + * @language zh_CN + */ + static parseDragonBonesData(rawData: any): DragonBonesData | null; + /** + * - Deprecated, please refer to {@link dragonBones.BaseFactory#parsetTextureAtlasData()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link dragonBones.BaseFactory#parsetTextureAtlasData()}。 + * @deprecated + * @language zh_CN + */ + static parseTextureAtlasData(rawData: any, scale?: number): any; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + class ObjectDataParser extends DataParser { + protected static _getBoolean(rawData: any, key: string, defaultValue: boolean): boolean; + protected static _getNumber(rawData: any, key: string, defaultValue: number): number; + protected static _getString(rawData: any, key: string, defaultValue: string): string; + protected _rawTextureAtlasIndex: number; + protected readonly _rawBones: Array; + protected _data: DragonBonesData; + protected _armature: ArmatureData; + protected _bone: BoneData; + protected _surface: SurfaceData; + protected _slot: SlotData; + protected _skin: SkinData; + protected _mesh: MeshDisplayData; + protected _animation: AnimationData; + protected _timeline: TimelineData; + protected _rawTextureAtlases: Array | null; + private _defaultColorOffset; + private _prevClockwise; + private _prevRotation; + private readonly _helpMatrixA; + private readonly _helpMatrixB; + private readonly _helpTransform; + private readonly _helpColorTransform; + private readonly _helpPoint; + private readonly _helpArray; + private readonly _intArray; + private readonly _floatArray; + private readonly _frameIntArray; + private readonly _frameFloatArray; + private readonly _frameArray; + private readonly _timelineArray; + private readonly _cacheRawMeshes; + private readonly _cacheMeshes; + private readonly _actionFrames; + private readonly _weightSlotPose; + private readonly _weightBonePoses; + private readonly _cacheBones; + private readonly _slotChildActions; + private _getCurvePoint(x1, y1, x2, y2, x3, y3, x4, y4, t, result); + private _samplingEasingCurve(curve, samples); + private _parseActionDataInFrame(rawData, frameStart, bone, slot); + private _mergeActionFrame(rawData, frameStart, type, bone, slot); + protected _parseArmature(rawData: any, scale: number): ArmatureData; + protected _parseBone(rawData: any): BoneData; + protected _parseIKConstraint(rawData: any): ConstraintData | null; + protected _parseSlot(rawData: any, zOrder: number): SlotData; + protected _parseSkin(rawData: any): SkinData; + protected _parseDisplay(rawData: any): DisplayData | null; + protected _parsePivot(rawData: any, display: ImageDisplayData): void; + protected _parseMesh(rawData: any, mesh: MeshDisplayData): void; + protected _parseMeshGlue(rawData: any, mesh: MeshDisplayData): void; + protected _parseBoundingBox(rawData: any): BoundingBoxData | null; + protected _parsePolygonBoundingBox(rawData: any): PolygonBoundingBoxData; + protected _parseAnimation(rawData: any): AnimationData; + protected _parseTimeline(rawData: any, rawFrames: Array | null, framesKey: string, type: TimelineType, addIntOffset: boolean, addFloatOffset: boolean, frameValueCount: number, frameParser: (rawData: any, frameStart: number, frameCount: number) => number): TimelineData | null; + protected _parseBoneTimeline(rawData: any): void; + protected _parseSlotTimeline(rawData: any): void; + protected _parseFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseTweenFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseActionFrame(frame: ActionFrame, frameStart: number, frameCount: number): number; + protected _parseZOrderFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseBoneAllFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseBoneTranslateFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseBoneRotateFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseBoneScaleFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseSurfaceFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseSlotDisplayFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseSlotColorFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseSlotFFDFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseIKConstraintFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseAnimationFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseActionData(rawData: any, type: ActionType, bone: BoneData | null, slot: SlotData | null): Array; + protected _parseTransform(rawData: any, transform: Transform, scale: number): void; + protected _parseColorTransform(rawData: any, color: ColorTransform): void; + protected _parseArray(rawData: any): void; + protected _modifyArray(): void; + parseDragonBonesData(rawData: any, scale?: number): DragonBonesData | null; + parseTextureAtlasData(rawData: any, textureAtlasData: TextureAtlasData, scale?: number): boolean; + private static _objectDataParserInstance; + /** + * - Deprecated, please refer to {@link dragonBones.BaseFactory#parseDragonBonesData()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link dragonBones.BaseFactory#parseDragonBonesData()}。 + * @deprecated + * @language zh_CN + */ + static getInstance(): ObjectDataParser; + } + /** + * @internal + * @private + */ + class ActionFrame { + frameStart: number; + readonly actions: Array; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + class BinaryDataParser extends ObjectDataParser { + private _binaryOffset; + private _binary; + private _intArrayBuffer; + private _floatArrayBuffer; + private _frameIntArrayBuffer; + private _frameFloatArrayBuffer; + private _frameArrayBuffer; + private _timelineArrayBuffer; + private _inRange(a, min, max); + private _decodeUTF8(data); + private _getUTF16Key(value); + private _parseBinaryTimeline(type, offset, timelineData?); + protected _parseMesh(rawData: any, mesh: MeshDisplayData): void; + protected _parseAnimation(rawData: any): AnimationData; + protected _parseArray(rawData: any): void; + parseDragonBonesData(rawData: any, scale?: number): DragonBonesData | null; + private static _binaryDataParserInstance; + /** + * - Deprecated, please refer to {@link dragonBones.BaseFactory#parseDragonBonesData()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link dragonBones.BaseFactory#parseDragonBonesData()}。 + * @deprecated + * @language zh_CN + */ + static getInstance(): BinaryDataParser; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - Base class for the factory that create the armatures. (Typically only one global factory instance is required) + * The factory instance create armatures by parsed and added DragonBonesData instances and TextureAtlasData instances. + * Once the data has been parsed, it has been cached in the factory instance and does not need to be parsed again until it is cleared by the factory instance. + * @see dragonBones.DragonBonesData + * @see dragonBones.TextureAtlasData + * @see dragonBones.ArmatureData + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 创建骨架的工厂基类。 (通常只需要一个全局工厂实例) + * 工厂通过解析并添加的 DragonBonesData 实例和 TextureAtlasData 实例来创建骨架。 + * 当数据被解析过之后,已经添加到工厂中,在没有被工厂清理之前,不需要再次解析。 + * @see dragonBones.DragonBonesData + * @see dragonBones.TextureAtlasData + * @see dragonBones.ArmatureData + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + abstract class BaseFactory { + /** + * @private + */ + protected static _objectParser: ObjectDataParser; + /** + * @private + */ + protected static _binaryParser: BinaryDataParser; + /** + * @private + */ + autoSearch: boolean; + /** + * @private + */ + protected readonly _dragonBonesDataMap: Map; + /** + * @private + */ + protected readonly _textureAtlasDataMap: Map>; + /** + * @private + */ + protected _dragonBones: DragonBones; + /** + * @private + */ + protected _dataParser: DataParser; + /** + * - Create a factory instance. (typically only one global factory instance is required) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 创建一个工厂实例。 (通常只需要一个全局工厂实例) + * @version DragonBones 3.0 + * @language zh_CN + */ + constructor(dataParser?: DataParser | null); + /** + * @private + */ + protected _isSupportMesh(): boolean; + /** + * @private + */ + protected _getTextureData(textureAtlasName: string, textureName: string): TextureData | null; + /** + * @private + */ + protected _fillBuildArmaturePackage(dataPackage: BuildArmaturePackage, dragonBonesName: string, armatureName: string, skinName: string, textureAtlasName: string): boolean; + /** + * @private + */ + protected _buildBones(dataPackage: BuildArmaturePackage, armature: Armature): void; + /** + * @private + */ + protected _buildSlots(dataPackage: BuildArmaturePackage, armature: Armature): void; + /** + * @private + */ + protected _buildChildArmature(dataPackage: BuildArmaturePackage | null, slot: Slot, displayData: DisplayData): Armature | null; + /** + * @private + */ + protected _getSlotDisplay(dataPackage: BuildArmaturePackage | null, displayData: DisplayData, rawDisplayData: DisplayData | null, slot: Slot): any; + /** + * @private + */ + protected abstract _buildTextureAtlasData(textureAtlasData: TextureAtlasData | null, textureAtlas: any): TextureAtlasData; + /** + * @private + */ + protected abstract _buildArmature(dataPackage: BuildArmaturePackage): Armature; + /** + * @private + */ + protected abstract _buildSlot(dataPackage: BuildArmaturePackage, slotData: SlotData, displays: Array | null, armature: Armature): Slot; + /** + * - Parse the raw data to a DragonBonesData instance and cache it to the factory. + * @param rawData - The raw data. + * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (If not set, use the instance name instead) + * @param scale - Specify a scaling value for all armatures. (Default: 1.0) + * @returns DragonBonesData instance + * @see #getDragonBonesData() + * @see #addDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 将原始数据解析为 DragonBonesData 实例,并缓存到工厂中。 + * @param rawData - 原始数据。 + * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) + * @param scale - 为所有的骨架指定一个缩放值。 (默认: 1.0) + * @returns DragonBonesData 实例 + * @see #getDragonBonesData() + * @see #addDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 4.5 + * @language zh_CN + */ + parseDragonBonesData(rawData: any, name?: string | null, scale?: number): DragonBonesData | null; + /** + * - Parse the raw texture atlas data and the texture atlas object to a TextureAtlasData instance and cache it to the factory. + * @param rawData - The raw texture atlas data. + * @param textureAtlas - The texture atlas object. + * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (If not set, use the instance name instead) + * @param scale - Specify a scaling value for the map set. (Default: 1.0) + * @returns TextureAtlasData instance + * @see #getTextureAtlasData() + * @see #addTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 将原始贴图集数据和贴图集对象解析为 TextureAtlasData 实例,并缓存到工厂中。 + * @param rawData - 原始贴图集数据。 + * @param textureAtlas - 贴图集对象。 + * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) + * @param scale - 为贴图集指定一个缩放值。 (默认: 1.0) + * @returns TextureAtlasData 实例 + * @see #getTextureAtlasData() + * @see #addTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 4.5 + * @language zh_CN + */ + parseTextureAtlasData(rawData: any, textureAtlas: any, name?: string | null, scale?: number): TextureAtlasData; + /** + * @private + */ + updateTextureAtlasData(name: string, textureAtlases: Array): void; + /** + * - Get a specific DragonBonesData instance. + * @param name - The DragonBonesData instance cache name. + * @returns DragonBonesData instance + * @see #parseDragonBonesData() + * @see #addDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的 DragonBonesData 实例。 + * @param name - DragonBonesData 实例的缓存名称。 + * @returns DragonBonesData 实例 + * @see #parseDragonBonesData() + * @see #addDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language zh_CN + */ + getDragonBonesData(name: string): DragonBonesData | null; + /** + * - Cache a DragonBonesData instance to the factory. + * @param data - The DragonBonesData instance. + * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (if not set, use the instance name instead) + * @see #parseDragonBonesData() + * @see #getDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 将 DragonBonesData 实例缓存到工厂中。 + * @param data - DragonBonesData 实例。 + * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) + * @see #parseDragonBonesData() + * @see #getDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language zh_CN + */ + addDragonBonesData(data: DragonBonesData, name?: string | null): void; + /** + * - Remove a DragonBonesData instance. + * @param name - The DragonBonesData instance cache name. + * @param disposeData - Whether to dispose data. (Default: true) + * @see #parseDragonBonesData() + * @see #getDragonBonesData() + * @see #addDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 移除 DragonBonesData 实例。 + * @param name - DragonBonesData 实例缓存名称。 + * @param disposeData - 是否释放数据。 (默认: true) + * @see #parseDragonBonesData() + * @see #getDragonBonesData() + * @see #addDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language zh_CN + */ + removeDragonBonesData(name: string, disposeData?: boolean): void; + /** + * - Get a list of specific TextureAtlasData instances. + * @param name - The TextureAtlasData cahce name. + * @see #parseTextureAtlasData() + * @see #addTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的 TextureAtlasData 实例列表。 + * @param name - TextureAtlasData 实例缓存名称。 + * @see #parseTextureAtlasData() + * @see #addTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language zh_CN + */ + getTextureAtlasData(name: string): Array | null; + /** + * - Cache a TextureAtlasData instance to the factory. + * @param data - The TextureAtlasData instance. + * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (if not set, use the instance name instead) + * @see #parseTextureAtlasData() + * @see #getTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 将 TextureAtlasData 实例缓存到工厂中。 + * @param data - TextureAtlasData 实例。 + * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) + * @see #parseTextureAtlasData() + * @see #getTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language zh_CN + */ + addTextureAtlasData(data: TextureAtlasData, name?: string | null): void; + /** + * - Remove a TextureAtlasData instance. + * @param name - The TextureAtlasData instance cache name. + * @param disposeData - Whether to dispose data. + * @see #parseTextureAtlasData() + * @see #getTextureAtlasData() + * @see #addTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 移除 TextureAtlasData 实例。 + * @param name - TextureAtlasData 实例的缓存名称。 + * @param disposeData - 是否释放数据。 + * @see #parseTextureAtlasData() + * @see #getTextureAtlasData() + * @see #addTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language zh_CN + */ + removeTextureAtlasData(name: string, disposeData?: boolean): void; + /** + * - Get a specific armature data. + * @param name - The armature data name. + * @param dragonBonesName - The cached name for DragonbonesData instance. + * @see dragonBones.ArmatureData + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 获取特定的骨架数据。 + * @param name - 骨架数据名称。 + * @param dragonBonesName - DragonBonesData 实例的缓存名称。 + * @see dragonBones.ArmatureData + * @version DragonBones 5.1 + * @language zh_CN + */ + getArmatureData(name: string, dragonBonesName?: string): ArmatureData | null; + /** + * - Clear all cached DragonBonesData instances and TextureAtlasData instances. + * @param disposeData - Whether to dispose data. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 清除缓存的所有 DragonBonesData 实例和 TextureAtlasData 实例。 + * @param disposeData - 是否释放数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + clear(disposeData?: boolean): void; + /** + * - Create a armature from cached DragonBonesData instances and TextureAtlasData instances. + * @param armatureName - The armature data name. + * @param dragonBonesName - The cached name of the DragonBonesData instance. (If not set, all DragonBonesData instances are retrieved, and when multiple DragonBonesData instances contain a the same name armature data, it may not be possible to accurately create a specific armature) + * @param skinName - The skin name, you can set a different ArmatureData name to share it's skin data. (If not set, use the default skin data) + * @returns The armature. + * @example + *
+         *     let armature = factory.buildArmature("armatureName", "dragonBonesName");
+         *     armature.clock = factory.clock;
+         * 
+ * @see dragonBones.DragonBonesData + * @see dragonBones.ArmatureData + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 通过缓存的 DragonBonesData 实例和 TextureAtlasData 实例创建一个骨架。 + * @param armatureName - 骨架数据名称。 + * @param dragonBonesName - DragonBonesData 实例的缓存名称。 (如果未设置,将检索所有的 DragonBonesData 实例,当多个 DragonBonesData 实例中包含同名的骨架数据时,可能无法准确的创建出特定的骨架) + * @param skinName - 皮肤名称,可以设置一个其他骨架数据名称来共享其皮肤数据(如果未设置,则使用默认的皮肤数据)。 + * @returns 骨架。 + * @example + *
+         *     let armature = factory.buildArmature("armatureName", "dragonBonesName");
+         *     armature.clock = factory.clock;
+         * 
+ * @see dragonBones.DragonBonesData + * @see dragonBones.ArmatureData + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + buildArmature(armatureName: string, dragonBonesName?: string, skinName?: string, textureAtlasName?: string): Armature | null; + /** + * @private + */ + replaceDisplay(slot: Slot, displayData: DisplayData, displayIndex?: number): void; + /** + * - Replaces the current display data for a particular slot with a specific display data. + * Specify display data with "dragonBonesName/armatureName/slotName/displayName". + * @param dragonBonesName - The DragonBonesData instance cache name. + * @param armatureName - The armature data name. + * @param slotName - The slot data name. + * @param displayName - The display data name. + * @param slot - The slot. + * @param displayIndex - The index of the display data that is replaced. (If it is not set, replaces the current display data) + * @example + *
+         *     let slot = armature.getSlot("weapon");
+         *     factory.replaceSlotDisplay("dragonBonesName", "armatureName", "slotName", "displayName", slot);
+         * 
+ * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 用特定的显示对象数据替换特定插槽当前的显示对象数据。 + * 用 "dragonBonesName/armatureName/slotName/displayName" 指定显示对象数据。 + * @param dragonBonesName - DragonBonesData 实例的缓存名称。 + * @param armatureName - 骨架数据名称。 + * @param slotName - 插槽数据名称。 + * @param displayName - 显示对象数据名称。 + * @param slot - 插槽。 + * @param displayIndex - 被替换的显示对象数据的索引。 (如果未设置,则替换当前的显示对象数据) + * @example + *
+         *     let slot = armature.getSlot("weapon");
+         *     factory.replaceSlotDisplay("dragonBonesName", "armatureName", "slotName", "displayName", slot);
+         * 
+ * @version DragonBones 4.5 + * @language zh_CN + */ + replaceSlotDisplay(dragonBonesName: string, armatureName: string, slotName: string, displayName: string, slot: Slot, displayIndex?: number): boolean; + /** + * @private + */ + replaceSlotDisplayList(dragonBonesName: string | null, armatureName: string, slotName: string, slot: Slot): boolean; + /** + * - Share specific skin data with specific armature. + * @param armature - The armature. + * @param skin - The skin data. + * @param isOverride - Whether it completely override the original skin. (Default: false) + * @param exclude - A list of slot names that do not need to be replace. + * @example + *
+         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
+         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
+         *     if (armatureDataB && armatureDataB.defaultSkin) {
+         *     factory.replaceSkin(armatureA, armatureDataB.defaultSkin, false, ["arm_l", "weapon_l"]);
+         *     }
+         * 
+ * @see dragonBones.Armature + * @see dragonBones.SkinData + * @version DragonBones 5.6 + * @language en_US + */ + /** + * - 将特定的皮肤数据共享给特定的骨架使用。 + * @param armature - 骨架。 + * @param skin - 皮肤数据。 + * @param isOverride - 是否完全覆盖原来的皮肤。 (默认: false) + * @param exclude - 不需要被替换的插槽名称列表。 + * @example + *
+         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
+         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
+         *     if (armatureDataB && armatureDataB.defaultSkin) {
+         *     factory.replaceSkin(armatureA, armatureDataB.defaultSkin, false, ["arm_l", "weapon_l"]);
+         *     }
+         * 
+ * @see dragonBones.Armature + * @see dragonBones.SkinData + * @version DragonBones 5.6 + * @language zh_CN + */ + replaceSkin(armature: Armature, skin: SkinData, isOverride?: boolean, exclude?: Array | null): boolean; + /** + * - Replaces the existing animation data for a specific armature with the animation data for the specific armature data. + * This enables you to make a armature template so that other armature without animations can share it's animations. + * @param armature - The armtaure. + * @param armatureData - The armature data. + * @param isOverride - Whether to completely overwrite the original animation. (Default: false) + * @example + *
+         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
+         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
+         *     if (armatureDataB) {
+         *     factory.replaceAnimation(armatureA, armatureDataB);
+         *     }
+         * 
+ * @see dragonBones.Armature + * @see dragonBones.ArmatureData + * @version DragonBones 5.6 + * @language en_US + */ + /** + * - 用特定骨架数据的动画数据替换特定骨架现有的动画数据。 + * 这样就能实现制作一个骨架动画模板,让其他没有制作动画的骨架共享该动画。 + * @param armature - 骨架。 + * @param armatureData - 骨架数据。 + * @param isOverride - 是否完全覆盖原来的动画。(默认: false)。 + * @example + *
+         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
+         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
+         *     if (armatureDataB) {
+         *     factory.replaceAnimation(armatureA, armatureDataB);
+         *     }
+         * 
+ * @see dragonBones.Armature + * @see dragonBones.ArmatureData + * @version DragonBones 5.6 + * @language zh_CN + */ + replaceAnimation(armature: Armature, armatureData: ArmatureData, isOverride?: boolean): boolean; + /** + * @private + */ + getAllDragonBonesData(): Map; + /** + * @private + */ + getAllTextureAtlasData(): Map>; + /** + * - An Worldclock instance updated by engine. + * @version DragonBones 5.7 + * @language en_US + */ + /** + * - 由引擎驱动的 WorldClock 实例。 + * @version DragonBones 5.7 + * @language zh_CN + */ + readonly clock: WorldClock; + /** + * @private + */ + readonly dragonBones: DragonBones; + /** + * - Deprecated, please refer to {@link #replaceSkin}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #replaceSkin}。 + * @deprecated + * @language zh_CN + */ + changeSkin(armature: Armature, skin: SkinData, exclude?: Array | null): boolean; + /** + * - Deprecated, please refer to {@link #replaceAnimation}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #replaceAnimation}。 + * @deprecated + * @language zh_CN + */ + copyAnimationsToArmature(toArmature: Armature, fromArmatreName: string, fromSkinName?: string, fromDragonBonesDataName?: string, replaceOriginalAnimation?: boolean): boolean; + } + /** + * @internal + * @private + */ + class BuildArmaturePackage { + dataName: string; + textureAtlasName: string; + data: DragonBonesData; + armature: ArmatureData; + skin: SkinData | null; + } +} + +declare namespace sp.spine { + class Animation { + name: string; + timelines: Array; + timelineIds: Array; + duration: number; + constructor(name: string, timelines: Array, duration: number); + hasTimeline(id: number): boolean; + apply(skeleton: Skeleton, lastTime: number, time: number, loop: boolean, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + static binarySearch(values: ArrayLike, target: number, step?: number): number; + static linearSearch(values: ArrayLike, target: number, step: number): number; + } + interface Timeline { + apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + getPropertyId(): number; + } + enum MixBlend { + setup = 0, + first = 1, + replace = 2, + add = 3 + } + enum MixDirection { + mixIn = 0, + mixOut = 1 + } + enum TimelineType { + rotate = 0, + translate = 1, + scale = 2, + shear = 3, + attachment = 4, + color = 5, + deform = 6, + event = 7, + drawOrder = 8, + ikConstraint = 9, + transformConstraint = 10, + pathConstraintPosition = 11, + pathConstraintSpacing = 12, + pathConstraintMix = 13, + twoColor = 14 + } + abstract class CurveTimeline implements Timeline { + static LINEAR: number; + static STEPPED: number; + static BEZIER: number; + static BEZIER_SIZE: number; + private curves; + abstract getPropertyId(): number; + constructor(frameCount: number); + getFrameCount(): number; + setLinear(frameIndex: number): void; + setStepped(frameIndex: number): void; + getCurveType(frameIndex: number): number; + setCurve(frameIndex: number, cx1: number, cy1: number, cx2: number, cy2: number): void; + getCurvePercent(frameIndex: number, percent: number): number; + abstract apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class RotateTimeline extends CurveTimeline { + static ENTRIES: number; + static PREV_TIME: number; + static PREV_ROTATION: number; + static ROTATION: number; + boneIndex: number; + frames: ArrayLike; + constructor(frameCount: number); + getPropertyId(): number; + setFrame(frameIndex: number, time: number, degrees: number): void; + apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class TranslateTimeline extends CurveTimeline { + static ENTRIES: number; + static PREV_TIME: number; + static PREV_X: number; + static PREV_Y: number; + static X: number; + static Y: number; + boneIndex: number; + frames: ArrayLike; + constructor(frameCount: number); + getPropertyId(): number; + setFrame(frameIndex: number, time: number, x: number, y: number): void; + apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class ScaleTimeline extends TranslateTimeline { + constructor(frameCount: number); + getPropertyId(): number; + apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class ShearTimeline extends TranslateTimeline { + constructor(frameCount: number); + getPropertyId(): number; + apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class ColorTimeline extends CurveTimeline { + static ENTRIES: number; + static PREV_TIME: number; + static PREV_R: number; + static PREV_G: number; + static PREV_B: number; + static PREV_A: number; + static R: number; + static G: number; + static B: number; + static A: number; + slotIndex: number; + frames: ArrayLike; + constructor(frameCount: number); + getPropertyId(): number; + setFrame(frameIndex: number, time: number, r: number, g: number, b: number, a: number): void; + apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class TwoColorTimeline extends CurveTimeline { + static ENTRIES: number; + static PREV_TIME: number; + static PREV_R: number; + static PREV_G: number; + static PREV_B: number; + static PREV_A: number; + static PREV_R2: number; + static PREV_G2: number; + static PREV_B2: number; + static R: number; + static G: number; + static B: number; + static A: number; + static R2: number; + static G2: number; + static B2: number; + slotIndex: number; + frames: ArrayLike; + constructor(frameCount: number); + getPropertyId(): number; + setFrame(frameIndex: number, time: number, r: number, g: number, b: number, a: number, r2: number, g2: number, b2: number): void; + apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class AttachmentTimeline implements Timeline { + slotIndex: number; + frames: ArrayLike; + attachmentNames: Array; + constructor(frameCount: number); + getPropertyId(): number; + getFrameCount(): number; + setFrame(frameIndex: number, time: number, attachmentName: string): void; + apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class DeformTimeline extends CurveTimeline { + slotIndex: number; + attachment: VertexAttachment; + frames: ArrayLike; + frameVertices: Array>; + constructor(frameCount: number); + getPropertyId(): number; + setFrame(frameIndex: number, time: number, vertices: ArrayLike): void; + apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class EventTimeline implements Timeline { + frames: ArrayLike; + events: Array; + constructor(frameCount: number); + getPropertyId(): number; + getFrameCount(): number; + setFrame(frameIndex: number, event: Event): void; + apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class DrawOrderTimeline implements Timeline { + frames: ArrayLike; + drawOrders: Array>; + constructor(frameCount: number); + getPropertyId(): number; + getFrameCount(): number; + setFrame(frameIndex: number, time: number, drawOrder: Array): void; + apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class IkConstraintTimeline extends CurveTimeline { + static ENTRIES: number; + static PREV_TIME: number; + static PREV_MIX: number; + static PREV_SOFTNESS: number; + static PREV_BEND_DIRECTION: number; + static PREV_COMPRESS: number; + static PREV_STRETCH: number; + static MIX: number; + static SOFTNESS: number; + static BEND_DIRECTION: number; + static COMPRESS: number; + static STRETCH: number; + ikConstraintIndex: number; + frames: ArrayLike; + constructor(frameCount: number); + getPropertyId(): number; + setFrame(frameIndex: number, time: number, mix: number, softness: number, bendDirection: number, compress: boolean, stretch: boolean): void; + apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class TransformConstraintTimeline extends CurveTimeline { + static ENTRIES: number; + static PREV_TIME: number; + static PREV_ROTATE: number; + static PREV_TRANSLATE: number; + static PREV_SCALE: number; + static PREV_SHEAR: number; + static ROTATE: number; + static TRANSLATE: number; + static SCALE: number; + static SHEAR: number; + transformConstraintIndex: number; + frames: ArrayLike; + constructor(frameCount: number); + getPropertyId(): number; + setFrame(frameIndex: number, time: number, rotateMix: number, translateMix: number, scaleMix: number, shearMix: number): void; + apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class PathConstraintPositionTimeline extends CurveTimeline { + static ENTRIES: number; + static PREV_TIME: number; + static PREV_VALUE: number; + static VALUE: number; + pathConstraintIndex: number; + frames: ArrayLike; + constructor(frameCount: number); + getPropertyId(): number; + setFrame(frameIndex: number, time: number, value: number): void; + apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class PathConstraintSpacingTimeline extends PathConstraintPositionTimeline { + constructor(frameCount: number); + getPropertyId(): number; + apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class PathConstraintMixTimeline extends CurveTimeline { + static ENTRIES: number; + static PREV_TIME: number; + static PREV_ROTATE: number; + static PREV_TRANSLATE: number; + static ROTATE: number; + static TRANSLATE: number; + pathConstraintIndex: number; + frames: ArrayLike; + constructor(frameCount: number); + getPropertyId(): number; + setFrame(frameIndex: number, time: number, rotateMix: number, translateMix: number): void; + apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } +} +declare namespace sp.spine { + class AnimationState { + static emptyAnimation: Animation; + static SUBSEQUENT: number; + static FIRST: number; + static HOLD: number; + static HOLD_MIX: number; + static NOT_LAST: number; + data: AnimationStateData; + tracks: TrackEntry[]; + timeScale: number; + events: Event[]; + listeners: AnimationStateListener[]; + queue: EventQueue; + propertyIDs: IntSet; + animationsChanged: boolean; + trackEntryPool: Pool; + constructor(data: AnimationStateData); + update(delta: number): void; + updateMixingFrom(to: TrackEntry, delta: number): boolean; + apply(skeleton: Skeleton): boolean; + applyMixingFrom(to: TrackEntry, skeleton: Skeleton, blend: MixBlend): number; + applyRotateTimeline(timeline: Timeline, skeleton: Skeleton, time: number, alpha: number, blend: MixBlend, timelinesRotation: Array, i: number, firstFrame: boolean): void; + queueEvents(entry: TrackEntry, animationTime: number): void; + clearTracks(): void; + clearTrack(trackIndex: number): void; + setCurrent(index: number, current: TrackEntry, interrupt: boolean): void; + setAnimation(trackIndex: number, animationName: string, loop: boolean): TrackEntry; + setAnimationWith(trackIndex: number, animation: Animation, loop: boolean): TrackEntry; + addAnimation(trackIndex: number, animationName: string, loop: boolean, delay: number): TrackEntry; + addAnimationWith(trackIndex: number, animation: Animation, loop: boolean, delay: number): TrackEntry; + setEmptyAnimation(trackIndex: number, mixDuration: number): TrackEntry; + addEmptyAnimation(trackIndex: number, mixDuration: number, delay: number): TrackEntry; + setEmptyAnimations(mixDuration: number): void; + expandToIndex(index: number): TrackEntry; + trackEntry(trackIndex: number, animation: Animation, loop: boolean, last: TrackEntry): TrackEntry; + disposeNext(entry: TrackEntry): void; + _animationsChanged(): void; + computeHold(entry: TrackEntry): void; + computeNotLast(entry: TrackEntry): void; + getCurrent(trackIndex: number): TrackEntry; + addListener(listener: AnimationStateListener): void; + removeListener(listener: AnimationStateListener): void; + clearListeners(): void; + clearListenerNotifications(): void; + } + class TrackEntry { + animation: Animation; + next: TrackEntry; + mixingFrom: TrackEntry; + mixingTo: TrackEntry; + listener: AnimationStateListener; + trackIndex: number; + loop: boolean; + holdPrevious: boolean; + eventThreshold: number; + attachmentThreshold: number; + drawOrderThreshold: number; + animationStart: number; + animationEnd: number; + animationLast: number; + nextAnimationLast: number; + delay: number; + trackTime: number; + trackLast: number; + nextTrackLast: number; + trackEnd: number; + timeScale: number; + alpha: number; + mixTime: number; + mixDuration: number; + interruptAlpha: number; + totalAlpha: number; + mixBlend: MixBlend; + timelineMode: number[]; + timelineHoldMix: TrackEntry[]; + timelinesRotation: number[]; + reset(): void; + getAnimationTime(): number; + setAnimationLast(animationLast: number): void; + isComplete(): boolean; + resetRotationDirections(): void; + } + class EventQueue { + objects: Array; + drainDisabled: boolean; + animState: AnimationState; + constructor(animState: AnimationState); + start(entry: TrackEntry): void; + interrupt(entry: TrackEntry): void; + end(entry: TrackEntry): void; + dispose(entry: TrackEntry): void; + complete(entry: TrackEntry): void; + event(entry: TrackEntry, event: Event): void; + drain(): void; + clear(): void; + } + enum EventType { + start = 0, + interrupt = 1, + end = 2, + dispose = 3, + complete = 4, + event = 5 + } + interface AnimationStateListener { + start(entry: TrackEntry): void; + interrupt(entry: TrackEntry): void; + end(entry: TrackEntry): void; + dispose(entry: TrackEntry): void; + complete(entry: TrackEntry): void; + event(entry: TrackEntry, event: Event): void; + } + abstract class AnimationStateAdapter implements AnimationStateListener { + start(entry: TrackEntry): void; + interrupt(entry: TrackEntry): void; + end(entry: TrackEntry): void; + dispose(entry: TrackEntry): void; + complete(entry: TrackEntry): void; + event(entry: TrackEntry, event: Event): void; + } +} +declare namespace sp.spine { + class AnimationStateData { + skeletonData: SkeletonData; + animationToMixTime: Map; + defaultMix: number; + constructor(skeletonData: SkeletonData); + setMix(fromName: string, toName: string, duration: number): void; + setMixWith(from: Animation, to: Animation, duration: number): void; + getMix(from: Animation, to: Animation): number; + } +} +declare namespace sp.spine { + class AssetManager implements Disposable { + private pathPrefix; + private textureLoader; + private assets; + private errors; + private toLoad; + private loaded; + constructor(textureLoader: (image: HTMLImageElement) => any, pathPrefix?: string); + private static downloadText; + private static downloadBinary; + loadBinary(path: string, success?: (path: string, binary: Uint8Array) => void, error?: (path: string, error: string) => void): void; + loadText(path: string, success?: (path: string, text: string) => void, error?: (path: string, error: string) => void): void; + loadTexture(path: string, success?: (path: string, image: HTMLImageElement) => void, error?: (path: string, error: string) => void): void; + loadTextureData(path: string, data: string, success?: (path: string, image: HTMLImageElement) => void, error?: (path: string, error: string) => void): void; + loadTextureAtlas(path: string, success?: (path: string, atlas: TextureAtlas) => void, error?: (path: string, error: string) => void): void; + get(path: string): any; + remove(path: string): void; + removeAll(): void; + isLoadingComplete(): boolean; + getToLoad(): number; + getLoaded(): number; + dispose(): void; + hasErrors(): boolean; + getErrors(): Map; + } +} +declare namespace sp.spine { + class AtlasAttachmentLoader implements AttachmentLoader { + atlas: TextureAtlas; + constructor(atlas: TextureAtlas); + newRegionAttachment(skin: Skin, name: string, path: string): RegionAttachment; + newMeshAttachment(skin: Skin, name: string, path: string): MeshAttachment; + newBoundingBoxAttachment(skin: Skin, name: string): BoundingBoxAttachment; + newPathAttachment(skin: Skin, name: string): PathAttachment; + newPointAttachment(skin: Skin, name: string): PointAttachment; + newClippingAttachment(skin: Skin, name: string): ClippingAttachment; + } +} +declare namespace sp.spine { + enum BlendMode { + Normal = 0, + Additive = 1, + Multiply = 2, + Screen = 3 + } +} +declare namespace sp.spine { + class Bone implements Updatable { + data: BoneData; + skeleton: Skeleton; + parent: Bone; + children: Bone[]; + x: number; + y: number; + rotation: number; + scaleX: number; + scaleY: number; + shearX: number; + shearY: number; + ax: number; + ay: number; + arotation: number; + ascaleX: number; + ascaleY: number; + ashearX: number; + ashearY: number; + appliedValid: boolean; + a: number; + b: number; + c: number; + d: number; + worldY: number; + worldX: number; + sorted: boolean; + active: boolean; + constructor(data: BoneData, skeleton: Skeleton, parent: Bone); + isActive(): boolean; + update(): void; + updateWorldTransform(): void; + updateWorldTransformWith(x: number, y: number, rotation: number, scaleX: number, scaleY: number, shearX: number, shearY: number): void; + setToSetupPose(): void; + getWorldRotationX(): number; + getWorldRotationY(): number; + getWorldScaleX(): number; + getWorldScaleY(): number; + updateAppliedTransform(): void; + worldToLocal(world: Vector2): Vector2; + localToWorld(local: Vector2): Vector2; + worldToLocalRotation(worldRotation: number): number; + localToWorldRotation(localRotation: number): number; + rotateWorld(degrees: number): void; + } +} +declare namespace sp.spine { + class BoneData { + index: number; + name: string; + parent: BoneData; + length: number; + x: number; + y: number; + rotation: number; + scaleX: number; + scaleY: number; + shearX: number; + shearY: number; + transformMode: TransformMode; + skinRequired: boolean; + color: Color; + constructor(index: number, name: string, parent: BoneData); + } + enum TransformMode { + Normal = 0, + OnlyTranslation = 1, + NoRotationOrReflection = 2, + NoScale = 3, + NoScaleOrReflection = 4 + } +} +declare namespace sp.spine { + abstract class ConstraintData { + name: string; + order: number; + skinRequired: boolean; + constructor(name: string, order: number, skinRequired: boolean); + } +} +declare namespace sp.spine { + class Event { + data: EventData; + intValue: number; + floatValue: number; + stringValue: string; + time: number; + volume: number; + balance: number; + constructor(time: number, data: EventData); + } +} +declare namespace sp.spine { + class EventData { + name: string; + intValue: number; + floatValue: number; + stringValue: string; + audioPath: string; + volume: number; + balance: number; + constructor(name: string); + } +} +declare namespace sp.spine { + class IkConstraint implements Updatable { + data: IkConstraintData; + bones: Array; + target: Bone; + bendDirection: number; + compress: boolean; + stretch: boolean; + mix: number; + softness: number; + active: boolean; + constructor(data: IkConstraintData, skeleton: Skeleton); + isActive(): boolean; + apply(): void; + update(): void; + apply1(bone: Bone, targetX: number, targetY: number, compress: boolean, stretch: boolean, uniform: boolean, alpha: number): void; + apply2(parent: Bone, child: Bone, targetX: number, targetY: number, bendDir: number, stretch: boolean, softness: number, alpha: number): void; + } +} +declare namespace sp.spine { + class IkConstraintData extends ConstraintData { + bones: BoneData[]; + target: BoneData; + bendDirection: number; + compress: boolean; + stretch: boolean; + uniform: boolean; + mix: number; + softness: number; + constructor(name: string); + } +} +declare namespace sp.spine { + class PathConstraint implements Updatable { + static NONE: number; + static BEFORE: number; + static AFTER: number; + static epsilon: number; + data: PathConstraintData; + bones: Array; + target: Slot; + position: number; + spacing: number; + rotateMix: number; + translateMix: number; + spaces: number[]; + positions: number[]; + world: number[]; + curves: number[]; + lengths: number[]; + segments: number[]; + active: boolean; + constructor(data: PathConstraintData, skeleton: Skeleton); + isActive(): boolean; + apply(): void; + update(): void; + computeWorldPositions(path: PathAttachment, spacesCount: number, tangents: boolean, percentPosition: boolean, percentSpacing: boolean): number[]; + addBeforePosition(p: number, temp: Array, i: number, out: Array, o: number): void; + addAfterPosition(p: number, temp: Array, i: number, out: Array, o: number): void; + addCurvePosition(p: number, x1: number, y1: number, cx1: number, cy1: number, cx2: number, cy2: number, x2: number, y2: number, out: Array, o: number, tangents: boolean): void; + } +} +declare namespace sp.spine { + class PathConstraintData extends ConstraintData { + bones: BoneData[]; + target: SlotData; + positionMode: PositionMode; + spacingMode: SpacingMode; + rotateMode: RotateMode; + offsetRotation: number; + position: number; + spacing: number; + rotateMix: number; + translateMix: number; + constructor(name: string); + } + enum PositionMode { + Fixed = 0, + Percent = 1 + } + enum SpacingMode { + Length = 0, + Fixed = 1, + Percent = 2 + } + enum RotateMode { + Tangent = 0, + Chain = 1, + ChainScale = 2 + } +} +declare namespace sp.spine { + class SharedAssetManager implements Disposable { + private pathPrefix; + private clientAssets; + private queuedAssets; + private rawAssets; + private errors; + constructor(pathPrefix?: string); + private queueAsset; + loadText(clientId: string, path: string): void; + loadJson(clientId: string, path: string): void; + loadTexture(clientId: string, textureLoader: (image: HTMLImageElement) => any, path: string): void; + get(clientId: string, path: string): any; + private updateClientAssets; + isLoadingComplete(clientId: string): boolean; + dispose(): void; + hasErrors(): boolean; + getErrors(): Map; + } +} +declare namespace sp.spine { + class Skeleton { + data: SkeletonData; + bones: Array; + slots: Array; + drawOrder: Array; + ikConstraints: Array; + transformConstraints: Array; + pathConstraints: Array; + _updateCache: Updatable[]; + updateCacheReset: Updatable[]; + skin: Skin; + color: Color; + time: number; + scaleX: number; + scaleY: number; + x: number; + y: number; + constructor(data: SkeletonData); + updateCache(): void; + sortIkConstraint(constraint: IkConstraint): void; + sortPathConstraint(constraint: PathConstraint): void; + sortTransformConstraint(constraint: TransformConstraint): void; + sortPathConstraintAttachment(skin: Skin, slotIndex: number, slotBone: Bone): void; + sortPathConstraintAttachmentWith(attachment: Attachment, slotBone: Bone): void; + sortBone(bone: Bone): void; + sortReset(bones: Array): void; + updateWorldTransform(): void; + setToSetupPose(): void; + setBonesToSetupPose(): void; + setSlotsToSetupPose(): void; + getRootBone(): Bone; + findBone(boneName: string): Bone; + findBoneIndex(boneName: string): number; + findSlot(slotName: string): Slot; + findSlotIndex(slotName: string): number; + setSkinByName(skinName: string): void; + setSkin(newSkin: Skin): void; + getAttachmentByName(slotName: string, attachmentName: string): Attachment; + getAttachment(slotIndex: number, attachmentName: string): Attachment; + setAttachment(slotName: string, attachmentName: string): void; + findIkConstraint(constraintName: string): IkConstraint; + findTransformConstraint(constraintName: string): TransformConstraint; + findPathConstraint(constraintName: string): PathConstraint; + getBounds(offset: Vector2, size: Vector2, temp?: Array): void; + update(delta: number): void; + } +} +declare namespace sp.spine { + class SkeletonBinary { + static AttachmentTypeValues: number[]; + static TransformModeValues: TransformMode[]; + static PositionModeValues: PositionMode[]; + static SpacingModeValues: SpacingMode[]; + static RotateModeValues: RotateMode[]; + static BlendModeValues: BlendMode[]; + static BONE_ROTATE: number; + static BONE_TRANSLATE: number; + static BONE_SCALE: number; + static BONE_SHEAR: number; + static SLOT_ATTACHMENT: number; + static SLOT_COLOR: number; + static SLOT_TWO_COLOR: number; + static PATH_POSITION: number; + static PATH_SPACING: number; + static PATH_MIX: number; + static CURVE_LINEAR: number; + static CURVE_STEPPED: number; + static CURVE_BEZIER: number; + scale: number; + attachmentLoader: AttachmentLoader; + private linkedMeshes; + constructor(attachmentLoader: AttachmentLoader); + readSkeletonData(binary: Uint8Array): SkeletonData; + private readSkin; + private readAttachment; + private readVertices; + private readFloatArray; + private readShortArray; + private readAnimation; + private readCurve; + setCurve(timeline: CurveTimeline, frameIndex: number, cx1: number, cy1: number, cx2: number, cy2: number): void; + } +} +declare namespace sp.spine { + class SkeletonBounds { + minX: number; + minY: number; + maxX: number; + maxY: number; + boundingBoxes: BoundingBoxAttachment[]; + polygons: ArrayLike[]; + private polygonPool; + update(skeleton: Skeleton, updateAabb: boolean): void; + aabbCompute(): void; + aabbContainsPoint(x: number, y: number): boolean; + aabbIntersectsSegment(x1: number, y1: number, x2: number, y2: number): boolean; + aabbIntersectsSkeleton(bounds: SkeletonBounds): boolean; + containsPoint(x: number, y: number): BoundingBoxAttachment; + containsPointPolygon(polygon: ArrayLike, x: number, y: number): boolean; + intersectsSegment(x1: number, y1: number, x2: number, y2: number): BoundingBoxAttachment; + intersectsSegmentPolygon(polygon: ArrayLike, x1: number, y1: number, x2: number, y2: number): boolean; + getPolygon(boundingBox: BoundingBoxAttachment): ArrayLike; + getWidth(): number; + getHeight(): number; + } +} +declare namespace sp.spine { + class SkeletonClipping { + private triangulator; + private clippingPolygon; + private clipOutput; + clippedVertices: number[]; + clippedTriangles: number[]; + private scratch; + private clipAttachment; + private clippingPolygons; + clipStart(slot: Slot, clip: ClippingAttachment): number; + clipEndWithSlot(slot: Slot): void; + clipEnd(): void; + isClipping(): boolean; + clipTriangles(vertices: ArrayLike, verticesLength: number, triangles: ArrayLike, trianglesLength: number, uvs: ArrayLike, light: Color, dark: Color, twoColor: boolean): void; + clip(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, clippingArea: Array, output: Array): boolean; + static makeClockwise(polygon: ArrayLike): void; + } +} +declare namespace sp.spine { + class SkeletonData { + name: string; + bones: BoneData[]; + slots: SlotData[]; + skins: Skin[]; + defaultSkin: Skin; + events: EventData[]; + animations: Animation[]; + ikConstraints: IkConstraintData[]; + transformConstraints: TransformConstraintData[]; + pathConstraints: PathConstraintData[]; + x: number; + y: number; + width: number; + height: number; + version: string; + hash: string; + fps: number; + imagesPath: string; + audioPath: string; + findBone(boneName: string): BoneData; + findBoneIndex(boneName: string): number; + findSlot(slotName: string): SlotData; + findSlotIndex(slotName: string): number; + findSkin(skinName: string): Skin; + findEvent(eventDataName: string): EventData; + findAnimation(animationName: string): Animation; + findIkConstraint(constraintName: string): IkConstraintData; + findTransformConstraint(constraintName: string): TransformConstraintData; + findPathConstraint(constraintName: string): PathConstraintData; + findPathConstraintIndex(pathConstraintName: string): number; + } +} +declare namespace sp.spine { + class SkeletonJson { + attachmentLoader: AttachmentLoader; + scale: number; + private linkedMeshes; + constructor(attachmentLoader: AttachmentLoader); + readSkeletonData(json: string | any): SkeletonData; + readAttachment(map: any, skin: Skin, slotIndex: number, name: string, skeletonData: SkeletonData): Attachment; + readVertices(map: any, attachment: VertexAttachment, verticesLength: number): void; + readAnimation(map: any, name: string, skeletonData: SkeletonData): void; + readCurve(map: any, timeline: CurveTimeline, frameIndex: number): void; + getValue(map: any, prop: string, defaultValue: any): any; + static blendModeFromString(str: string): BlendMode; + static positionModeFromString(str: string): PositionMode; + static spacingModeFromString(str: string): SpacingMode; + static rotateModeFromString(str: string): RotateMode; + static transformModeFromString(str: string): TransformMode; + } +} +declare namespace sp.spine { + class SkinEntry { + slotIndex: number; + name: string; + attachment: Attachment; + constructor(slotIndex: number, name: string, attachment: Attachment); + } + class Skin { + name: string; + attachments: Map[]; + bones: BoneData[]; + constraints: ConstraintData[]; + constructor(name: string); + setAttachment(slotIndex: number, name: string, attachment: Attachment): void; + addSkin(skin: Skin): void; + copySkin(skin: Skin): void; + getAttachment(slotIndex: number, name: string): Attachment; + removeAttachment(slotIndex: number, name: string): void; + getAttachments(): Array; + getAttachmentsForSlot(slotIndex: number, attachments: Array): void; + clear(): void; + attachAll(skeleton: Skeleton, oldSkin: Skin): void; + } +} +declare namespace sp.spine { + class Slot { + data: SlotData; + bone: Bone; + color: Color; + darkColor: Color; + private attachment; + private attachmentTime; + deform: number[]; + constructor(data: SlotData, bone: Bone); + getSkeleton(): Skeleton; + getAttachment(): Attachment; + setAttachment(attachment: Attachment): void; + setAttachmentTime(time: number): void; + getAttachmentTime(): number; + setToSetupPose(): void; + } +} +declare namespace sp.spine { + class SlotData { + index: number; + name: string; + boneData: BoneData; + color: Color; + darkColor: Color; + attachmentName: string; + blendMode: BlendMode; + constructor(index: number, name: string, boneData: BoneData); + } +} +declare namespace sp.spine { + abstract class Texture { + protected _image: HTMLImageElement; + constructor(image: HTMLImageElement); + getImage(): HTMLImageElement; + abstract setFilters(minFilter: TextureFilter, magFilter: TextureFilter): void; + abstract setWraps(uWrap: TextureWrap, vWrap: TextureWrap): void; + abstract dispose(): void; + static filterFromString(text: string): TextureFilter; + static wrapFromString(text: string): TextureWrap; + } + enum TextureFilter { + Nearest = 9728, + Linear = 9729, + MipMap = 9987, + MipMapNearestNearest = 9984, + MipMapLinearNearest = 9985, + MipMapNearestLinear = 9986, + MipMapLinearLinear = 9987 + } + enum TextureWrap { + MirroredRepeat = 33648, + ClampToEdge = 33071, + Repeat = 10497 + } + class TextureRegion { + renderObject: any; + u: number; + v: number; + u2: number; + v2: number; + width: number; + height: number; + rotate: boolean; + offsetX: number; + offsetY: number; + originalWidth: number; + originalHeight: number; + } + class FakeTexture extends Texture { + setFilters(minFilter: TextureFilter, magFilter: TextureFilter): void; + setWraps(uWrap: TextureWrap, vWrap: TextureWrap): void; + dispose(): void; + } +} +declare namespace sp.spine { + class TextureAtlas implements Disposable { + pages: TextureAtlasPage[]; + regions: TextureAtlasRegion[]; + constructor(atlasText: string, textureLoader: (path: string) => any); + private load; + findRegion(name: string): TextureAtlasRegion; + dispose(): void; + } + class TextureAtlasPage { + name: string; + minFilter: TextureFilter; + magFilter: TextureFilter; + uWrap: TextureWrap; + vWrap: TextureWrap; + texture: Texture; + width: number; + height: number; + } + class TextureAtlasRegion extends TextureRegion { + page: TextureAtlasPage; + name: string; + x: number; + y: number; + index: number; + rotate: boolean; + degrees: number; + texture: Texture; + } +} +declare namespace sp.spine { + class TransformConstraint implements Updatable { + data: TransformConstraintData; + bones: Array; + target: Bone; + rotateMix: number; + translateMix: number; + scaleMix: number; + shearMix: number; + temp: Vector2; + active: boolean; + constructor(data: TransformConstraintData, skeleton: Skeleton); + isActive(): boolean; + apply(): void; + update(): void; + applyAbsoluteWorld(): void; + applyRelativeWorld(): void; + applyAbsoluteLocal(): void; + applyRelativeLocal(): void; + } +} +declare namespace sp.spine { + class TransformConstraintData extends ConstraintData { + bones: BoneData[]; + target: BoneData; + rotateMix: number; + translateMix: number; + scaleMix: number; + shearMix: number; + offsetRotation: number; + offsetX: number; + offsetY: number; + offsetScaleX: number; + offsetScaleY: number; + offsetShearY: number; + relative: boolean; + local: boolean; + constructor(name: string); + } +} +declare namespace sp.spine { + class Triangulator { + private convexPolygons; + private convexPolygonsIndices; + private indicesArray; + private isConcaveArray; + private triangles; + private polygonPool; + private polygonIndicesPool; + triangulate(verticesArray: ArrayLike): Array; + decompose(verticesArray: Array, triangles: Array): Array>; + private static isConcave; + private static positiveArea; + private static winding; + } +} +declare namespace sp.spine { + interface Updatable { + update(): void; + isActive(): boolean; + } +} +declare namespace sp.spine { + interface Map { + [key: string]: T; + } + class IntSet { + array: number[]; + add(value: number): boolean; + contains(value: number): boolean; + remove(value: number): void; + clear(): void; + } + interface Disposable { + dispose(): void; + } + interface Restorable { + restore(): void; + } + class Color { + r: number; + g: number; + b: number; + a: number; + static WHITE: Color; + static RED: Color; + static GREEN: Color; + static BLUE: Color; + static MAGENTA: Color; + constructor(r?: number, g?: number, b?: number, a?: number); + set(r: number, g: number, b: number, a: number): this; + setFromColor(c: Color): this; + setFromString(hex: string): this; + add(r: number, g: number, b: number, a: number): this; + clamp(): this; + static rgba8888ToColor(color: Color, value: number): void; + static rgb888ToColor(color: Color, value: number): void; + } + class MathUtils { + static PI: number; + static PI2: number; + static radiansToDegrees: number; + static radDeg: number; + static degreesToRadians: number; + static degRad: number; + static clamp(value: number, min: number, max: number): number; + static cosDeg(degrees: number): number; + static sinDeg(degrees: number): number; + static signum(value: number): number; + static toInt(x: number): number; + static cbrt(x: number): number; + static randomTriangular(min: number, max: number): number; + static randomTriangularWith(min: number, max: number, mode: number): number; + } + abstract class Interpolation { + protected abstract applyInternal(a: number): number; + apply(start: number, end: number, a: number): number; + } + class Pow extends Interpolation { + protected power: number; + constructor(power: number); + applyInternal(a: number): number; + } + class PowOut extends Pow { + constructor(power: number); + applyInternal(a: number): number; + } + class Utils { + static SUPPORTS_TYPED_ARRAYS: boolean; + static arrayCopy(source: ArrayLike, sourceStart: number, dest: ArrayLike, destStart: number, numElements: number): void; + static setArraySize(array: Array, size: number, value?: any): Array; + static ensureArrayCapacity(array: Array, size: number, value?: any): Array; + static newArray(size: number, defaultValue: T): Array; + static newFloatArray(size: number): ArrayLike; + static newShortArray(size: number): ArrayLike; + static toFloatArray(array: Array): number[] | Float32Array; + static toSinglePrecision(value: number): number; + static webkit602BugfixHelper(alpha: number, blend: MixBlend): void; + static contains(array: Array, element: T, identity?: boolean): boolean; + } + class DebugUtils { + static logBones(skeleton: Skeleton): void; + } + class Pool { + private items; + private instantiator; + constructor(instantiator: () => T); + obtain(): T; + free(item: T): void; + freeAll(items: ArrayLike): void; + clear(): void; + } + class Vector2 { + x: number; + y: number; + constructor(x?: number, y?: number); + set(x: number, y: number): Vector2; + length(): number; + normalize(): this; + } + class TimeKeeper { + maxDelta: number; + framesPerSecond: number; + delta: number; + totalTime: number; + private lastTime; + private frameCount; + private frameTime; + update(): void; + } + interface ArrayLike { + length: number; + [n: number]: T; + } + class WindowedMean { + values: Array; + addedValues: number; + lastValue: number; + mean: number; + dirty: boolean; + constructor(windowSize?: number); + hasEnoughData(): boolean; + addValue(value: number): void; + getMean(): number; + } +} +declare namespace sp.spine { + interface VertexEffect { + begin(skeleton: Skeleton): void; + transform(position: Vector2, uv: Vector2, light: Color, dark: Color): void; + end(): void; + } +} +interface Math { + fround(n: number): number; +} +declare namespace sp.spine { + abstract class Attachment { + name: string; + constructor(name: string); + abstract copy(): Attachment; + } + abstract class VertexAttachment extends Attachment { + private static nextID; + id: number; + bones: Array; + vertices: ArrayLike; + worldVerticesLength: number; + deformAttachment: VertexAttachment; + constructor(name: string); + computeWorldVertices(slot: Slot, start: number, count: number, worldVertices: ArrayLike, offset: number, stride: number): void; + copyTo(attachment: VertexAttachment): void; + } +} +declare namespace sp.spine { + interface AttachmentLoader { + newRegionAttachment(skin: Skin, name: string, path: string): RegionAttachment; + newMeshAttachment(skin: Skin, name: string, path: string): MeshAttachment; + newBoundingBoxAttachment(skin: Skin, name: string): BoundingBoxAttachment; + newPathAttachment(skin: Skin, name: string): PathAttachment; + newPointAttachment(skin: Skin, name: string): PointAttachment; + newClippingAttachment(skin: Skin, name: string): ClippingAttachment; + } +} +declare namespace sp.spine { + enum AttachmentType { + Region = 0, + BoundingBox = 1, + Mesh = 2, + LinkedMesh = 3, + Path = 4, + Point = 5, + Clipping = 6 + } +} +declare namespace sp.spine { + class BoundingBoxAttachment extends VertexAttachment { + color: Color; + constructor(name: string); + copy(): Attachment; + } +} +declare namespace sp.spine { + class ClippingAttachment extends VertexAttachment { + endSlot: SlotData; + color: Color; + constructor(name: string); + copy(): Attachment; + } +} +declare namespace sp.spine { + class MeshAttachment extends VertexAttachment { + region: TextureRegion; + path: string; + regionUVs: ArrayLike; + uvs: ArrayLike; + triangles: Array; + color: Color; + width: number; + height: number; + hullLength: number; + edges: Array; + private parentMesh; + tempColor: Color; + constructor(name: string); + updateUVs(): void; + getParentMesh(): MeshAttachment; + setParentMesh(parentMesh: MeshAttachment): void; + copy(): Attachment; + newLinkedMesh(): MeshAttachment; + } +} +declare namespace sp.spine { + class PathAttachment extends VertexAttachment { + lengths: Array; + closed: boolean; + constantSpeed: boolean; + color: Color; + constructor(name: string); + copy(): Attachment; + } +} +declare namespace sp.spine { + class PointAttachment extends VertexAttachment { + x: number; + y: number; + rotation: number; + color: Color; + constructor(name: string); + computeWorldPosition(bone: Bone, point: Vector2): Vector2; + computeWorldRotation(bone: Bone): number; + copy(): Attachment; + } +} +declare namespace sp.spine { + class RegionAttachment extends Attachment { + static OX1: number; + static OY1: number; + static OX2: number; + static OY2: number; + static OX3: number; + static OY3: number; + static OX4: number; + static OY4: number; + static X1: number; + static Y1: number; + static C1R: number; + static C1G: number; + static C1B: number; + static C1A: number; + static U1: number; + static V1: number; + static X2: number; + static Y2: number; + static C2R: number; + static C2G: number; + static C2B: number; + static C2A: number; + static U2: number; + static V2: number; + static X3: number; + static Y3: number; + static C3R: number; + static C3G: number; + static C3B: number; + static C3A: number; + static U3: number; + static V3: number; + static X4: number; + static Y4: number; + static C4R: number; + static C4G: number; + static C4B: number; + static C4A: number; + static U4: number; + static V4: number; + x: number; + y: number; + scaleX: number; + scaleY: number; + rotation: number; + width: number; + height: number; + color: Color; + path: string; + rendererObject: any; + region: TextureRegion; + offset: ArrayLike; + uvs: ArrayLike; + tempColor: Color; + constructor(name: string); + updateOffset(): void; + setRegion(region: TextureRegion): void; + computeWorldVertices(bone: Bone, worldVertices: ArrayLike, offset: number, stride: number): void; + copy(): Attachment; + } +} +declare namespace sp.spine { + class JitterEffect implements VertexEffect { + jitterX: number; + jitterY: number; + constructor(jitterX: number, jitterY: number); + begin(skeleton: Skeleton): void; + transform(position: Vector2, uv: Vector2, light: Color, dark: Color): void; + end(): void; + } +} +declare namespace sp.spine { + class SwirlEffect implements VertexEffect { + static interpolation: PowOut; + centerX: number; + centerY: number; + radius: number; + angle: number; + private worldX; + private worldY; + constructor(radius: number); + begin(skeleton: Skeleton): void; + transform(position: Vector2, uv: Vector2, light: Color, dark: Color): void; + end(): void; + } +} + +/** + * API for jsb module + * Author: haroel + * Homepage: https://github.com/haroel/creatorexDTS + */ +declare namespace jsb{ + export module reflection{ + /** + * https://docs.cocos.com/creator/manual/zh/advanced-topics/java-reflection.html + * call OBJC/Java static methods + * + * @param className + * @param methodName + * @param methodSignature + * @param parameters + */ + export function callStaticMethod (className: string, methodName: string, methodSignature: string, ...parameters:any): any; + } + /** + * 下载任务对象 + */ + export type DownloaderTask = { requestURL: string, storagePath: string, identifier: string }; + + /** + * Http file downloader for jsb! + */ + export class Downloader{ + /** + * create a download task + * @param requestURL + * @param storagePath + * @param identifier + */ + createDownloadFileTask (requestURL:string, storagePath:string, identifier?:string): DownloaderTask; + + setOnFileTaskSuccess (onSucceed: (task: DownloaderTask) => void): void; + + setOnTaskProgress (onProgress: (task: DownloaderTask, bytesReceived: number, totalBytesReceived: number, totalBytesExpected: number) => void): void; + + setOnTaskError (onError: (task: DownloaderTask, errorCode: number, errorCodeInternal: number, errorStr: string) => void): void; + + } + + export interface ManifestAsset { + md5: string; + path: string; + compressed: boolean; + size: number; + downloadState: number; + } + + export class Manifest { + constructor (manifestUrl: string); + constructor (content: string, manifestRoot: string); + parseFile (manifestUrl: string): void; + parseJSONString (content: string, manifestRoot: string): void; + + getManifestRoot (): string; + getManifestFileUrl (): string; + getVersionFileUrl (): string; + getSearchPaths (): [string]; + getVersion (): string; + getPackageUrl (): boolean; + + setUpdating (isUpdating: boolean): void; + isUpdating (): boolean; + isVersionLoaded (): boolean; + isLoaded (): boolean; + } + + export class EventAssetsManager { + // EventCode + static ERROR_NO_LOCAL_MANIFEST: number; + static ERROR_DOWNLOAD_MANIFEST: number; + static ERROR_PARSE_MANIFEST: number; + static NEW_VERSION_FOUND: number; + static ALREADY_UP_TO_DATE: number; + static UPDATE_PROGRESSION: number; + static ASSET_UPDATED: number; + static ERROR_UPDATING: number; + static UPDATE_FINISHED: number; + static UPDATE_FAILED: number; + static ERROR_DECOMPRESS: number; + + constructor (eventName: string, manager: AssetsManager, eventCode: number, + assetId?: string, message?: string, curleCode?: number, curlmCode?: number); + getAssetsManagerEx (): AssetsManager; + isResuming (): boolean; + + getDownloadedFiles (): number; + getDownloadedBytes (): number; + getTotalFiles (): number; + getTotalBytes (): number; + getPercent (): number; + getPercentByFile (): number; + + getEventCode (): number; + getMessage (): string; + getAssetId (): string; + getCURLECode (): number; + getCURLMCode (): number; + } + + export module AssetsManager { + export enum State { + UNINITED, + UNCHECKED, + PREDOWNLOAD_VERSION, + DOWNLOADING_VERSION, + VERSION_LOADED, + PREDOWNLOAD_MANIFEST, + DOWNLOADING_MANIFEST, + MANIFEST_LOADED, + NEED_UPDATE, + READY_TO_UPDATE, + UPDATING, + UNZIPPING, + UP_TO_DATE, + FAIL_TO_UPDATE, + } + } + + export class AssetsManager { + constructor (manifestUrl: string, storagePath: string, versionCompareHandle?: (versionA: string, versionB: string) => number); + static create (manifestUrl: string, storagePath: string): AssetsManager; + + getState (): AssetsManager.State; + getStoragePath (): string + getMaxConcurrentTask (): number; + // setMaxConcurrentTask (max: number): void; // actually not supported + + checkUpdate (): void; + prepareUpdate (): void; + update (): void; + isResuming (): boolean; + + getDownloadedFiles (): number; + getDownloadedBytes (): number; + getTotalFiles (): number; + getTotalBytes (): number; + downloadFailedAssets (): void; + + getLocalManifest (): Manifest; + loadLocalManifest (manifestUrl: string): boolean; + loadLocalManifest (localManifest: Manifest, storagePath: string): boolean; + getRemoteManifest (): Manifest; + loadRemoteManifest (remoteManifest: Manifest): boolean; + + /** + * Setup your own version compare handler, versionA and B is versions in string. + * if the return value greater than 0, versionA is greater than B, + * if the return value equals 0, versionA equals to B, + * if the return value smaller than 0, versionA is smaller than B. + */ + setVersionCompareHandle (versionCompareHandle?: (versionA: string, versionB: string) => number): void; + /** + * Setup the verification callback, Return true if the verification passed, otherwise return false + */ + setVerifyCallback (verifyCallback: (path: string, asset: ManifestAsset) => boolean): void; + setEventCallback (eventCallback: (event: EventAssetsManager) => void): void; + } + + /** + * FileUtils Helper class to handle file operations. + */ + export module fileUtils{ + /** + * Checks whether the path is an absolute path. + * + * @note On Android, if the parameter passed in is relative to "@assets/", this method will treat it as an absolute path. + * Also on Blackberry, path starts with "app/native/Resources/" is treated as an absolute path. + * + * @param path The path that needs to be checked. + * @return True if it's an absolute path, false if not. + */ + export function isAbsolutePath (path:string):boolean; + /** Returns the fullpath for a given filename. + + First it will try to get a new filename from the "filenameLookup" dictionary. + If a new filename can't be found on the dictionary, it will use the original filename. + Then it will try to obtain the full path of the filename using the FileUtils search rules: resolutions, and search paths. + The file search is based on the array element order of search paths and resolution directories. + + For instance: + + We set two elements("/mnt/sdcard/", "internal_dir/") to search paths vector by setSearchPaths, + and set three elements("resources-ipadhd/", "resources-ipad/", "resources-iphonehd") + to resolutions vector by setSearchResolutionsOrder. The "internal_dir" is relative to "Resources/". + + If we have a file named 'sprite.png', the mapping in fileLookup dictionary contains `key: sprite.png -> value: sprite.pvr.gz`. + Firstly, it will replace 'sprite.png' with 'sprite.pvr.gz', then searching the file sprite.pvr.gz as follows: + + /mnt/sdcard/resources-ipadhd/sprite.pvr.gz (if not found, search next) + /mnt/sdcard/resources-ipad/sprite.pvr.gz (if not found, search next) + /mnt/sdcard/resources-iphonehd/sprite.pvr.gz (if not found, search next) + /mnt/sdcard/sprite.pvr.gz (if not found, search next) + internal_dir/resources-ipadhd/sprite.pvr.gz (if not found, search next) + internal_dir/resources-ipad/sprite.pvr.gz (if not found, search next) + internal_dir/resources-iphonehd/sprite.pvr.gz (if not found, search next) + internal_dir/sprite.pvr.gz (if not found, return "sprite.png") + + If the filename contains relative path like "gamescene/uilayer/sprite.png", + and the mapping in fileLookup dictionary contains `key: gamescene/uilayer/sprite.png -> value: gamescene/uilayer/sprite.pvr.gz`. + The file search order will be: + + /mnt/sdcard/gamescene/uilayer/resources-ipadhd/sprite.pvr.gz (if not found, search next) + /mnt/sdcard/gamescene/uilayer/resources-ipad/sprite.pvr.gz (if not found, search next) + /mnt/sdcard/gamescene/uilayer/resources-iphonehd/sprite.pvr.gz (if not found, search next) + /mnt/sdcard/gamescene/uilayer/sprite.pvr.gz (if not found, search next) + internal_dir/gamescene/uilayer/resources-ipadhd/sprite.pvr.gz (if not found, search next) + internal_dir/gamescene/uilayer/resources-ipad/sprite.pvr.gz (if not found, search next) + internal_dir/gamescene/uilayer/resources-iphonehd/sprite.pvr.gz (if not found, search next) + internal_dir/gamescene/uilayer/sprite.pvr.gz (if not found, return "gamescene/uilayer/sprite.png") + + If the new file can't be found on the file system, it will return the parameter filename directly. + + This method was added to simplify multiplatform support. Whether you are using cocos2d-js or any cross-compilation toolchain like StellaSDK or Apportable, + you might need to load different resources for a given file in the different platforms. + + @since v2.1 + */ + export function fullPathForFilename (filename:string):string; + /** + * Gets string from a file. + */ + export function getStringFromFile (filename:string):string; + /** + * Removes a file. + * + * @param filepath The full path of the file, it must be an absolute path. + * @return True if the file have been removed successfully, false if not. + */ + export function removeFile (filepath:string):boolean; + /** + * Checks whether the path is a directory. + * + * @param dirPath The path of the directory, it could be a relative or an absolute path. + * @return True if the directory exists, false if not. + */ + export function isDirectoryExist (dirPath:string):boolean; + /** + * Normalize: remove . and .. + * @param filepath + */ + export function normalizePath (filepath:string):string; + /** + * Get default resource root path. + */ + export function getDefaultResourceRootPath ():string; + /** + * Loads the filenameLookup dictionary from the contents of a filename. + * + * @note The plist file name should follow the format below: + * + * @code + * + * + * + * + * filenames + * + * sounds/click.wav + * sounds/click.caf + * sounds/endgame.wav + * sounds/endgame.caf + * sounds/gem-0.wav + * sounds/gem-0.caf + * + * metadata + * + * version + * 1 + * + * + * + * @endcode + * @param filename The plist file name. + * + @since v2.1 + * @js loadFilenameLookup + * @lua loadFilenameLookup + */ + export function loadFilenameLookup (filepath:string):void; + /** Checks whether to pop up a message box when failed to load an image. + * @return True if pop up a message box when failed to load an image, false if not. + */ + export function isPopupNotify ():boolean; + /** + * Sets whether to pop-up a message box when failed to load an image. + */ + export function setPopupNotify (notify:boolean):void; + + // Converts the contents of a file to a ValueVector. + // This method is used internally. + export function getValueVectorFromFile (filepath:string):Array; + /** + * Gets the array of search paths. + * + * @return The array of search paths which may contain the prefix of default resource root path. + * @note In best practise, getter function should return the value of setter function passes in. + * But since we should not break the compatibility, we keep using the old logic. + * Therefore, If you want to get the original search paths, please call 'getOriginalSearchPaths()' instead. + * @see fullPathForFilename(const char*). + * @lua NA + */ + export function getSearchPaths ():Array; + /** + * + * @param filepath + */ + export function getFileDir (filepath:string):string; + /** + * write a ValueMap into a plist file + * + *@param dict the ValueMap want to save (key,value) + *@param fullPath The full path to the file you want to save a string + *@return bool + */ + export function writeToFile ( valueMap:any ):boolean; + /** + * Gets the original search path array set by 'setSearchPaths' or 'addSearchPath'. + * @return The array of the original search paths + */ + export function getOriginalSearchPaths ():Array; + /** + * List all files in a directory. + * + * @param dirPath The path of the directory, it could be a relative or an absolute path. + * @return File paths in a string vector + */ + export function listFiles (filepath:string):Array; + /** + * Converts the contents of a file to a ValueMap. + * @param filename The filename of the file to gets content. + * @return ValueMap of the file contents. + * @note This method is used internally. + */ + export function getValueMapFromFile (filepath:string):any; + /** + * Retrieve the file size. + * + * @note If a relative path was passed in, it will be inserted a default root path at the beginning. + * @param filepath The path of the file, it could be a relative or absolute path. + * @return The file size. + */ + export function getFileSize (filepath:string):number; + + /** Converts the contents of a file to a ValueMap. + * This method is used internally. + */ + export function getValueMapFromData (filedata:string,filesize:number):any; + /** + * Removes a directory. + * + * @param dirPath The full path of the directory, it must be an absolute path. + * @return True if the directory have been removed successfully, false if not. + */ + export function removeDirectory (dirPath:string):boolean; + /** + * Sets the array of search paths. + * + * You can use this array to modify the search path of the resources. + * If you want to use "themes" or search resources in the "cache", you can do it easily by adding new entries in this array. + * + * @note This method could access relative path and absolute path. + * If the relative path was passed to the vector, FileUtils will add the default resource directory before the relative path. + * For instance: + * On Android, the default resource root path is "@assets/". + * If "/mnt/sdcard/" and "resources-large" were set to the search paths vector, + * "resources-large" will be converted to "@assets/resources-large" since it was a relative path. + * + * @param searchPaths The array contains search paths. + * @see fullPathForFilename(const char*) + * @since v2.1 + * In js:var setSearchPaths(var jsval); + * @lua NA + */ + export function setSearchPaths ( searchPath:Array):void; + /** + * write a string into a file + * + * @param dataStr the string want to save + * @param fullPath The full path to the file you want to save a string + * @return bool True if write success + */ + export function writeStringToFile (dataStr:string,fullPath:string):boolean; + /** + * Sets the array that contains the search order of the resources. + * + * @param searchResolutionsOrder The source array that contains the search order of the resources. + * @see getSearchResolutionsOrder(), fullPathForFilename(const char*). + * @since v2.1 + * In js:var setSearchResolutionsOrder(var jsval) + * @lua NA + */ + export function setSearchResolutionsOrder (searchResolutionsOrder:Array):void; + /** + * Append search order of the resources. + * + * @see setSearchResolutionsOrder(), fullPathForFilename(). + * @since v2.1 + */ + export function addSearchResolutionsOrder (order:string,front:boolean):void; + /** + * Add search path. + * + * @since v2.1 + */ + export function addSearchPath (path:string,front:boolean):void; + /** + * write ValueVector into a plist file + * + *@param vecData the ValueVector want to save + *@param fullPath The full path to the file you want to save a string + *@return bool + */ + export function writeValueVectorToFile (vecData:Array,fullPath:string):boolean; + /** + * Checks whether a file exists. + * + * @note If a relative path was passed in, it will be inserted a default root path at the beginning. + * @param filename The path of the file, it could be a relative or absolute path. + * @return True if the file exists, false if not. + */ + export function isFileExist (filename:string):boolean; + /**©∫ + * Purges full path caches. + */ + export function purgeCachedEntries ():void; + /** + * Gets full path from a file name and the path of the relative file. + * @param filename The file name. + * @param relativeFile The path of the relative file. + * @return The full path. + * e.g. filename: hello.png, pszRelativeFile: /User/path1/path2/hello.plist + * Return: /User/path1/path2/hello.pvr (If there a a key(hello.png)-value(hello.pvr) in FilenameLookup dictionary. ) + * + */ + export function fullPathFromRelativeFile (filename:string,relativeFile:string):string; + /** + * Windows fopen can't support UTF-8 filename + * Need convert all parameters fopen and other 3rd-party libs + * + * @param filenameUtf8 std::string name file for conversion from utf-8 + * @return std::string ansi filename in current locale + */ + export function getSuitableFOpen (filenameUtf8:string):string; + /** + * write ValueMap into a plist file + * + *@param dict the ValueMap want to save + *@param fullPath The full path to the file you want to save a string + *@return bool + */ + export function writeValueMapToFile (dict:any,fullPath:string):string; + /** + * Gets filename extension is a suffix (separated from the base filename by a dot) in lower case. + * Examples of filename extensions are .png, .jpeg, .exe, .dmg and .txt. + * @param filePath The path of the file, it could be a relative or absolute path. + * @return suffix for filename in lower case or empty if a dot not found. + */ + export function getFileExtension (filePath:string):string; + /** + * Sets writable path. + */ + export function setWritablePath (writablePath:string):void; + /** + * Set default resource root path. + */ + export function setDefaultResourceRootPath (filepath:string):void; + + /** + * Gets the array that contains the search order of the resources. + * + * @see setSearchResolutionsOrder(const std::vector&), fullPathForFilename(const char*). + * @since v2.1 + * @lua NA + */ + export function getSearchResolutionsOrder ():Array; + /** + * Creates a directory. + * + * @param dirPath The path of the directory, it must be an absolute path. + * @return True if the directory have been created successfully, false if not. + */ + export function createDirectory (dirPath:string):string; + /** + * List all files recursively in a directory. + * + * @param dirPath The path of the directory, it could be a relative or an absolute path. + * @return File paths in a string vector + */ + export function listFilesRecursively (dirPath:string, files:Array):void; + /** + * Gets the writable path. + * @return The path that can be write/read a file in + */ + export function getWritablePath ():string; + } +} + +/** Running in the editor. */ +declare const CC_EDITOR: boolean; +/** Preview in browser or simulator. */ +declare const CC_PREVIEW: boolean; +/** Running in the editor or preview. */ +declare const CC_DEV: boolean; +/** Running in the editor or preview, or build in debug mode. */ +declare const CC_DEBUG: boolean; +/** Running in published project. */ +declare const CC_BUILD: boolean; +/** Running in native platforms (mobile app, desktop app, or simulator). */ +declare const CC_JSB: boolean; +/** Running in runtime environments. */ +declare const CC_RUNTIME: boolean; +/** Running in the engine's unit test. */ +declare const CC_TEST: boolean; +/** Running in the WeChat Mini Game. */ +declare const CC_WECHATGAME: boolean; diff --git a/FakeLoadingBar/jsconfig.json b/FakeLoadingBar/jsconfig.json new file mode 100644 index 0000000..05394dd --- /dev/null +++ b/FakeLoadingBar/jsconfig.json @@ -0,0 +1,13 @@ +{ + "compilerOptions": { + "target": "es6", + "module": "commonjs" + }, + "exclude": [ + "node_modules", + "library", + "local", + "settings", + "temp" + ] +} \ No newline at end of file diff --git a/FakeLoadingBar/project.json b/FakeLoadingBar/project.json new file mode 100644 index 0000000..2e3f4a6 --- /dev/null +++ b/FakeLoadingBar/project.json @@ -0,0 +1,8 @@ +{ + "engine": "cocos2d-html5", + "packages": "packages", + "version": "2.4.2", + "name": "FakeLoadingBar", + "id": "b0fcbce7-cd24-4c63-8a70-338d736d25a5", + "isNew": false +} \ No newline at end of file diff --git a/FakeLoadingBar/settings/builder.json b/FakeLoadingBar/settings/builder.json new file mode 100644 index 0000000..09f915c --- /dev/null +++ b/FakeLoadingBar/settings/builder.json @@ -0,0 +1,13 @@ +{ + "excludeScenes": [], + "orientation": { + "landscapeLeft": true, + "landscapeRight": true, + "portrait": false, + "upsideDown": false + }, + "packageName": "org.cocos2d.helloworld", + "startScene": "2d2f792f-a40c-49bb-a189-ed176a246e49", + "title": "hello_world", + "webOrientation": "auto" +} \ No newline at end of file diff --git a/FakeLoadingBar/settings/builder.panel.json b/FakeLoadingBar/settings/builder.panel.json new file mode 100644 index 0000000..6a7c356 --- /dev/null +++ b/FakeLoadingBar/settings/builder.panel.json @@ -0,0 +1,7 @@ +{ + "excludeScenes": [], + "packageName": "org.cocos2d.helloworld", + "platform": "web-mobile", + "startScene": "2d2f792f-a40c-49bb-a189-ed176a246e49", + "title": "HelloWorld" +} \ No newline at end of file diff --git a/FakeLoadingBar/settings/project.json b/FakeLoadingBar/settings/project.json new file mode 100644 index 0000000..79babe1 --- /dev/null +++ b/FakeLoadingBar/settings/project.json @@ -0,0 +1,35 @@ +{ + "collision-matrix": [ + [ + true + ] + ], + "excluded-modules": [], + "group-list": [ + "default" + ], + "start-scene": "2d2f792f-a40c-49bb-a189-ed176a246e49", + "design-resolution-width": 960, + "design-resolution-height": 640, + "fit-width": false, + "fit-height": true, + "use-project-simulator-setting": false, + "simulator-orientation": false, + "use-customize-simulator": false, + "simulator-resolution": { + "width": 960, + "height": 640 + }, + "last-module-event-record-time": 0, + "assets-sort-type": "name", + "facebook": { + "enable": false, + "appID": "", + "live": { + "enable": false + }, + "audience": { + "enable": false + } + } +} diff --git a/FakeLoadingBar/settings/services.json b/FakeLoadingBar/settings/services.json new file mode 100644 index 0000000..599b09e --- /dev/null +++ b/FakeLoadingBar/settings/services.json @@ -0,0 +1,6 @@ +{ + "game": { + "name": "未知游戏", + "appid": "UNKNOW" + } +} \ No newline at end of file diff --git a/FakeLoadingBar/template-banner.png b/FakeLoadingBar/template-banner.png new file mode 100644 index 0000000..2aa766f Binary files /dev/null and b/FakeLoadingBar/template-banner.png differ diff --git a/FakeLoadingBar/template.json b/FakeLoadingBar/template.json new file mode 100644 index 0000000..78d02bc --- /dev/null +++ b/FakeLoadingBar/template.json @@ -0,0 +1,5 @@ +{ + "name": "TEMPLATES.helloworld-ts.name", + "desc": "TEMPLATES.helloworld-ts.desc", + "banner": "template-banner.png" +} \ No newline at end of file diff --git a/FakeLoadingBar/tsconfig.json b/FakeLoadingBar/tsconfig.json new file mode 100644 index 0000000..93c0b22 --- /dev/null +++ b/FakeLoadingBar/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ "es2015", "es2017", "dom" ], + "target": "es5", + "experimentalDecorators": true, + "skipLibCheck": true, + "outDir": "temp/vscode-dist", + "forceConsistentCasingInFileNames": true + }, + "exclude": [ + "node_modules", + "library", + "local", + "temp", + "build", + "settings" + ] +} \ No newline at end of file diff --git a/FanShooterDemo/.gitignore b/FanShooterDemo/.gitignore new file mode 100644 index 0000000..640d65b --- /dev/null +++ b/FanShooterDemo/.gitignore @@ -0,0 +1,67 @@ +#///////////////////////////////////////////////////////////////////////////// +# Fireball Projects +#///////////////////////////////////////////////////////////////////////////// + +library/ +temp/ +local/ +build/ + +#///////////////////////////////////////////////////////////////////////////// +# Logs and databases +#///////////////////////////////////////////////////////////////////////////// + +*.log +*.sql +*.sqlite + +#///////////////////////////////////////////////////////////////////////////// +# files for debugger +#///////////////////////////////////////////////////////////////////////////// + +*.sln +*.csproj +*.pidb +*.unityproj +*.suo + +#///////////////////////////////////////////////////////////////////////////// +# OS generated files +#///////////////////////////////////////////////////////////////////////////// + +.DS_Store +ehthumbs.db +Thumbs.db + +#///////////////////////////////////////////////////////////////////////////// +# exvim files +#///////////////////////////////////////////////////////////////////////////// + +*UnityVS.meta +*.err +*.err.meta +*.exvim +*.exvim.meta +*.vimentry +*.vimentry.meta +*.vimproject +*.vimproject.meta +.vimfiles.*/ +.exvim.*/ +quick_gen_project_*_autogen.bat +quick_gen_project_*_autogen.bat.meta +quick_gen_project_*_autogen.sh +quick_gen_project_*_autogen.sh.meta +.exvim.app + +#///////////////////////////////////////////////////////////////////////////// +# webstorm files +#///////////////////////////////////////////////////////////////////////////// + +.idea/ + +#////////////////////////// +# VS Code +#////////////////////////// + +.vscode/ \ No newline at end of file diff --git a/FanShooterDemo/README.md b/FanShooterDemo/README.md new file mode 100644 index 0000000..09b0019 --- /dev/null +++ b/FanShooterDemo/README.md @@ -0,0 +1,2 @@ +# hello-world +Hello world new project template. diff --git a/FanShooterDemo/assets/Scene.meta b/FanShooterDemo/assets/Scene.meta new file mode 100644 index 0000000..7da30b0 --- /dev/null +++ b/FanShooterDemo/assets/Scene.meta @@ -0,0 +1,6 @@ +{ + "ver": "1.0.1", + "uuid": "29f52784-2fca-467b-92e7-8fd9ef8c57b7", + "isGroup": false, + "subMetas": {} +} \ No newline at end of file diff --git a/FanShooterDemo/assets/Scene/helloworld.fire b/FanShooterDemo/assets/Scene/helloworld.fire new file mode 100644 index 0000000..19091ef --- /dev/null +++ b/FanShooterDemo/assets/Scene/helloworld.fire @@ -0,0 +1,847 @@ +[ + { + "__type__": "cc.SceneAsset", + "_name": "", + "_objFlags": 0, + "_rawFiles": null, + "scene": { + "__id__": 1 + } + }, + { + "__type__": "cc.Scene", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + } + ], + "_tag": -1, + "_active": true, + "_components": [], + "_prefab": null, + "_id": "2d2f792f-a40c-49bb-a189-ed176a246e49", + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_cascadeOpacityEnabled": true, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_localZOrder": 0, + "_globalZOrder": 0, + "_opacityModifyRGB": false, + "groupIndex": 0, + "autoReleaseAssets": false + }, + { + "__type__": "cc.Node", + "_name": "Canvas", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 3 + }, + { + "__id__": 6 + }, + { + "__id__": 22 + } + ], + "_tag": -1, + "_active": true, + "_components": [ + { + "__id__": 24 + } + ], + "_prefab": null, + "_id": "a286bbGknJLZpRpxROV6M94", + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 252, + "g": 252, + "b": 252, + "a": 255 + }, + "_cascadeOpacityEnabled": true, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 720, + "height": 1280 + }, + "_rotationX": 0, + "_rotationY": 0, + "_scaleX": 1, + "_scaleY": 1, + "_position": { + "__type__": "cc.Vec2", + "x": 360, + "y": 640 + }, + "_skewX": 0, + "_skewY": 0, + "_localZOrder": 0, + "_globalZOrder": 0, + "_opacityModifyRGB": false, + "groupIndex": 0 + }, + { + "__type__": "cc.Node", + "_name": "background", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_tag": -1, + "_active": true, + "_components": [ + { + "__id__": 4 + }, + { + "__id__": 5 + } + ], + "_prefab": null, + "_id": "e2e0crkOLxGrpMxpbC4iQg1", + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 27, + "g": 38, + "b": 46, + "a": 255 + }, + "_cascadeOpacityEnabled": true, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 720, + "height": 1280 + }, + "_rotationX": 0, + "_rotationY": 0, + "_scaleX": 1, + "_scaleY": 1, + "_position": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_localZOrder": 0, + "_globalZOrder": 0, + "_opacityModifyRGB": false, + "groupIndex": 0 + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 3 + }, + "_enabled": true, + "isAlignOnce": true, + "_target": null, + "_alignFlags": 45, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 200, + "_originalHeight": 150 + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 3 + }, + "_enabled": true, + "_spriteFrame": { + "__uuid__": "410fb916-8721-4663-bab8-34397391ace7" + }, + "_type": 1, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_atlas": null + }, + { + "__type__": "cc.Node", + "_name": "Bullet", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [ + { + "__id__": 7 + }, + { + "__id__": 10 + }, + { + "__id__": 13 + }, + { + "__id__": 16 + }, + { + "__id__": 19 + } + ], + "_tag": -1, + "_active": true, + "_components": [], + "_prefab": null, + "_id": "92kwPCv/pMF5e9atYUd7i3", + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_cascadeOpacityEnabled": true, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_rotationX": 0, + "_rotationY": 0, + "_scaleX": 1, + "_scaleY": 1, + "_position": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_localZOrder": 0, + "_globalZOrder": 0, + "_opacityModifyRGB": false, + "groupIndex": 0 + }, + { + "__type__": "cc.Node", + "_name": "Bullet", + "_objFlags": 0, + "_parent": { + "__id__": 6 + }, + "_children": [], + "_tag": -1, + "_active": true, + "_components": [ + { + "__id__": 8 + }, + { + "__id__": 9 + } + ], + "_prefab": null, + "_id": "0b5vsV6t9HmbzkadvfRB1v", + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_cascadeOpacityEnabled": true, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 9, + "height": 54 + }, + "_rotationX": 0, + "_rotationY": 0, + "_scaleX": 1, + "_scaleY": 1, + "_position": { + "__type__": "cc.Vec2", + "x": 0, + "y": -492 + }, + "_skewX": 0, + "_skewY": 0, + "_localZOrder": 0, + "_globalZOrder": 0, + "_opacityModifyRGB": false, + "groupIndex": 0 + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 7 + }, + "_enabled": true, + "_spriteFrame": { + "__uuid__": "2a41fb5b-28ea-446f-b222-5c4082ef084a" + }, + "_type": 0, + "_sizeMode": 1, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_atlas": null + }, + { + "__type__": "c1907tLZzZLh7bRut/8atj3", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 7 + }, + "_enabled": true, + "rotaion": 90, + "speed": 1000, + "time": 0, + "lifetime": 2.5 + }, + { + "__type__": "cc.Node", + "_name": "Bullet", + "_objFlags": 0, + "_parent": { + "__id__": 6 + }, + "_children": [], + "_tag": -1, + "_active": true, + "_components": [ + { + "__id__": 11 + }, + { + "__id__": 12 + } + ], + "_prefab": null, + "_id": "c9ehBJi5ZLW5RQuz7QL8p2", + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_cascadeOpacityEnabled": true, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 9, + "height": 54 + }, + "_rotationX": 5, + "_rotationY": 5, + "_scaleX": 1, + "_scaleY": 1, + "_position": { + "__type__": "cc.Vec2", + "x": 0, + "y": -492 + }, + "_skewX": 0, + "_skewY": 0, + "_localZOrder": 0, + "_globalZOrder": 0, + "_opacityModifyRGB": false, + "groupIndex": 0 + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 10 + }, + "_enabled": true, + "_spriteFrame": { + "__uuid__": "2a41fb5b-28ea-446f-b222-5c4082ef084a" + }, + "_type": 0, + "_sizeMode": 1, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_atlas": null + }, + { + "__type__": "c1907tLZzZLh7bRut/8atj3", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 10 + }, + "_enabled": true, + "rotaion": 85, + "speed": 1000, + "time": 0, + "lifetime": 2.5 + }, + { + "__type__": "cc.Node", + "_name": "Bullet", + "_objFlags": 0, + "_parent": { + "__id__": 6 + }, + "_children": [], + "_tag": -1, + "_active": true, + "_components": [ + { + "__id__": 14 + }, + { + "__id__": 15 + } + ], + "_prefab": null, + "_id": "a4MqwbqFdIc6Exc87X+zpw", + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_cascadeOpacityEnabled": true, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 9, + "height": 54 + }, + "_rotationX": 10, + "_rotationY": 10, + "_scaleX": 1, + "_scaleY": 1, + "_position": { + "__type__": "cc.Vec2", + "x": 0, + "y": -492 + }, + "_skewX": 0, + "_skewY": 0, + "_localZOrder": 0, + "_globalZOrder": 0, + "_opacityModifyRGB": false, + "groupIndex": 0 + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 13 + }, + "_enabled": true, + "_spriteFrame": { + "__uuid__": "2a41fb5b-28ea-446f-b222-5c4082ef084a" + }, + "_type": 0, + "_sizeMode": 1, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_atlas": null + }, + { + "__type__": "c1907tLZzZLh7bRut/8atj3", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 13 + }, + "_enabled": true, + "rotaion": 80, + "speed": 1000, + "time": 0, + "lifetime": 2.5 + }, + { + "__type__": "cc.Node", + "_name": "Bullet", + "_objFlags": 0, + "_parent": { + "__id__": 6 + }, + "_children": [], + "_tag": -1, + "_active": true, + "_components": [ + { + "__id__": 17 + }, + { + "__id__": 18 + } + ], + "_prefab": null, + "_id": "fbmzgedMNAZra7RJUFZNat", + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_cascadeOpacityEnabled": true, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 9, + "height": 54 + }, + "_rotationX": -5, + "_rotationY": -5, + "_scaleX": 1, + "_scaleY": 1, + "_position": { + "__type__": "cc.Vec2", + "x": 0, + "y": -492 + }, + "_skewX": 0, + "_skewY": 0, + "_localZOrder": 0, + "_globalZOrder": 0, + "_opacityModifyRGB": false, + "groupIndex": 0 + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 16 + }, + "_enabled": true, + "_spriteFrame": { + "__uuid__": "2a41fb5b-28ea-446f-b222-5c4082ef084a" + }, + "_type": 0, + "_sizeMode": 1, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_atlas": null + }, + { + "__type__": "c1907tLZzZLh7bRut/8atj3", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 16 + }, + "_enabled": true, + "rotaion": 95, + "speed": 1000, + "time": 0, + "lifetime": 2.5 + }, + { + "__type__": "cc.Node", + "_name": "Bullet", + "_objFlags": 0, + "_parent": { + "__id__": 6 + }, + "_children": [], + "_tag": -1, + "_active": true, + "_components": [ + { + "__id__": 20 + }, + { + "__id__": 21 + } + ], + "_prefab": null, + "_id": "9bQ2YTRvtMQrQgswIlCIkk", + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_cascadeOpacityEnabled": true, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 9, + "height": 54 + }, + "_rotationX": -10, + "_rotationY": -10, + "_scaleX": 1, + "_scaleY": 1, + "_position": { + "__type__": "cc.Vec2", + "x": 0, + "y": -492 + }, + "_skewX": 0, + "_skewY": 0, + "_localZOrder": 0, + "_globalZOrder": 0, + "_opacityModifyRGB": false, + "groupIndex": 0 + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 19 + }, + "_enabled": true, + "_spriteFrame": { + "__uuid__": "2a41fb5b-28ea-446f-b222-5c4082ef084a" + }, + "_type": 0, + "_sizeMode": 1, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_atlas": null + }, + { + "__type__": "c1907tLZzZLh7bRut/8atj3", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 19 + }, + "_enabled": true, + "rotaion": 100, + "speed": 1000, + "time": 0, + "lifetime": 2.5 + }, + { + "__type__": "cc.Node", + "_name": "Ship", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_tag": -1, + "_active": true, + "_components": [ + { + "__id__": 23 + } + ], + "_prefab": null, + "_id": "af/qs8RDRMMaGgrc0uuBCx", + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_cascadeOpacityEnabled": true, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 112, + "height": 75 + }, + "_rotationX": 0, + "_rotationY": 0, + "_scaleX": 1, + "_scaleY": 1, + "_position": { + "__type__": "cc.Vec2", + "x": 0, + "y": -524 + }, + "_skewX": 0, + "_skewY": 0, + "_localZOrder": 0, + "_globalZOrder": 0, + "_opacityModifyRGB": false, + "groupIndex": 0 + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 22 + }, + "_enabled": true, + "_spriteFrame": { + "__uuid__": "654a384b-e1a9-4de1-9771-4d1e9e094cb5" + }, + "_type": 0, + "_sizeMode": 1, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_atlas": null + }, + { + "__type__": "cc.Canvas", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "_designResolution": { + "__type__": "cc.Size", + "width": 720, + "height": 1280 + }, + "_fitWidth": false, + "_fitHeight": true + } +] \ No newline at end of file diff --git a/FanShooterDemo/assets/Scene/helloworld.fire.meta b/FanShooterDemo/assets/Scene/helloworld.fire.meta new file mode 100644 index 0000000..2bff939 --- /dev/null +++ b/FanShooterDemo/assets/Scene/helloworld.fire.meta @@ -0,0 +1,7 @@ +{ + "ver": "1.0.0", + "uuid": "2d2f792f-a40c-49bb-a189-ed176a246e49", + "asyncLoadAssets": false, + "autoReleaseAssets": false, + "subMetas": {} +} \ No newline at end of file diff --git a/FanShooterDemo/assets/Script.meta b/FanShooterDemo/assets/Script.meta new file mode 100644 index 0000000..7259168 --- /dev/null +++ b/FanShooterDemo/assets/Script.meta @@ -0,0 +1,6 @@ +{ + "ver": "1.0.1", + "uuid": "4734c20c-0db8-4eb2-92ea-e692f4d70934", + "isGroup": false, + "subMetas": {} +} \ No newline at end of file diff --git a/FanShooterDemo/assets/Script/Bullet.js b/FanShooterDemo/assets/Script/Bullet.js new file mode 100644 index 0000000..84ca983 --- /dev/null +++ b/FanShooterDemo/assets/Script/Bullet.js @@ -0,0 +1,53 @@ + + +cc.Class({ + extends: cc.Component, + + properties: { + rotaion: 90, + speed: 1000, + time: 0, + lifetime: 2.5 + }, + + // onLoad () {}, + + registerEvent() { + + }, + + start() { + this.originPos = this.node.position; + }, + + onMove(dt) { + console.log(this.time); + this.time += dt; + if (this.time >= this.lifetime) { + this.node.position = this.originPos; + this.time = 0; + } + let distance = dt * this.speed, radian = this.rotaion * Math.PI / 180; + + let v2 = this.node.position, delta = cc.v2(distance * Math.cos(radian), distance * Math.sin(radian)); + v2.x += delta.x; + v2.y += delta.y; + this.node.position = v2; + }, + + + onEnable() { + this.registerEvent(); + }, + + onDisable() { + this.offEvent(); + }, + + offEvent() { + }, + + update(dt) { + this.onMove(dt); + }, +}); diff --git a/FanShooterDemo/assets/Script/Bullet.js.meta b/FanShooterDemo/assets/Script/Bullet.js.meta new file mode 100644 index 0000000..61a4d1e --- /dev/null +++ b/FanShooterDemo/assets/Script/Bullet.js.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.5", + "uuid": "c1907b4b-6736-4b87-b6d1-badffc6ad8f7", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/FanShooterDemo/assets/Script/HelloWorld.js b/FanShooterDemo/assets/Script/HelloWorld.js new file mode 100644 index 0000000..b8d80cc --- /dev/null +++ b/FanShooterDemo/assets/Script/HelloWorld.js @@ -0,0 +1,22 @@ +cc.Class({ + extends: cc.Component, + + properties: { + label: { + default: null, + type: cc.Label + }, + // defaults, set visually when attaching this script to the Canvas + text: 'Hello, World!' + }, + + // use this for initialization + onLoad: function () { + this.label.string = this.text; + }, + + // called every frame + update: function (dt) { + + }, +}); diff --git a/FanShooterDemo/assets/Script/HelloWorld.js.meta b/FanShooterDemo/assets/Script/HelloWorld.js.meta new file mode 100644 index 0000000..bdd969e --- /dev/null +++ b/FanShooterDemo/assets/Script/HelloWorld.js.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.5", + "uuid": "280c3aec-6492-4a9d-9f51-a9b00b570b4a", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/FanShooterDemo/assets/Texture.meta b/FanShooterDemo/assets/Texture.meta new file mode 100644 index 0000000..f483d19 --- /dev/null +++ b/FanShooterDemo/assets/Texture.meta @@ -0,0 +1,6 @@ +{ + "ver": "1.0.1", + "uuid": "7b81d4e8-ec84-4716-968d-500ac1d78a54", + "isGroup": false, + "subMetas": {} +} \ No newline at end of file diff --git a/FanShooterDemo/assets/Texture/HelloWorld.png b/FanShooterDemo/assets/Texture/HelloWorld.png new file mode 100644 index 0000000..21d4326 Binary files /dev/null and b/FanShooterDemo/assets/Texture/HelloWorld.png differ diff --git a/FanShooterDemo/assets/Texture/HelloWorld.png.meta b/FanShooterDemo/assets/Texture/HelloWorld.png.meta new file mode 100644 index 0000000..9c52a59 --- /dev/null +++ b/FanShooterDemo/assets/Texture/HelloWorld.png.meta @@ -0,0 +1,30 @@ +{ + "ver": "1.0.0", + "uuid": "6aa0aa6a-ebee-4155-a088-a687a6aadec4", + "type": "sprite", + "wrapMode": "clamp", + "filterMode": "bilinear", + "subMetas": { + "HelloWorld": { + "ver": "1.0.3", + "uuid": "31bc895a-c003-4566-a9f3-2e54ae1c17dc", + "rawTextureUuid": "6aa0aa6a-ebee-4155-a088-a687a6aadec4", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 0, + "trimY": 0, + "width": 195, + "height": 270, + "rawWidth": 195, + "rawHeight": 270, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "subMetas": {} + } + } +} \ No newline at end of file diff --git a/FanShooterDemo/assets/Texture/laserGreen11.png b/FanShooterDemo/assets/Texture/laserGreen11.png new file mode 100644 index 0000000..100cddb Binary files /dev/null and b/FanShooterDemo/assets/Texture/laserGreen11.png differ diff --git a/FanShooterDemo/assets/Texture/laserGreen11.png.meta b/FanShooterDemo/assets/Texture/laserGreen11.png.meta new file mode 100644 index 0000000..f32ccd3 --- /dev/null +++ b/FanShooterDemo/assets/Texture/laserGreen11.png.meta @@ -0,0 +1,30 @@ +{ + "ver": "1.0.0", + "uuid": "557dd9c0-9394-49d0-a17e-61587ed6983d", + "type": "sprite", + "wrapMode": "clamp", + "filterMode": "bilinear", + "subMetas": { + "laserGreen11": { + "ver": "1.0.3", + "uuid": "2a41fb5b-28ea-446f-b222-5c4082ef084a", + "rawTextureUuid": "557dd9c0-9394-49d0-a17e-61587ed6983d", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 0, + "trimY": 0, + "width": 9, + "height": 54, + "rawWidth": 9, + "rawHeight": 54, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "subMetas": {} + } + } +} \ No newline at end of file diff --git a/FanShooterDemo/assets/Texture/playerShip2_orange.png b/FanShooterDemo/assets/Texture/playerShip2_orange.png new file mode 100644 index 0000000..82ddc80 Binary files /dev/null and b/FanShooterDemo/assets/Texture/playerShip2_orange.png differ diff --git a/FanShooterDemo/assets/Texture/playerShip2_orange.png.meta b/FanShooterDemo/assets/Texture/playerShip2_orange.png.meta new file mode 100644 index 0000000..7a73e1e --- /dev/null +++ b/FanShooterDemo/assets/Texture/playerShip2_orange.png.meta @@ -0,0 +1,30 @@ +{ + "ver": "1.0.0", + "uuid": "49f4c72e-c614-456c-a09b-a98cf3646d15", + "type": "sprite", + "wrapMode": "clamp", + "filterMode": "bilinear", + "subMetas": { + "playerShip2_orange": { + "ver": "1.0.3", + "uuid": "654a384b-e1a9-4de1-9771-4d1e9e094cb5", + "rawTextureUuid": "49f4c72e-c614-456c-a09b-a98cf3646d15", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 0, + "trimY": 0, + "width": 112, + "height": 75, + "rawWidth": 112, + "rawHeight": 75, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "subMetas": {} + } + } +} \ No newline at end of file diff --git a/FanShooterDemo/assets/Texture/singleColor.png b/FanShooterDemo/assets/Texture/singleColor.png new file mode 100644 index 0000000..ea5bd0b Binary files /dev/null and b/FanShooterDemo/assets/Texture/singleColor.png differ diff --git a/FanShooterDemo/assets/Texture/singleColor.png.meta b/FanShooterDemo/assets/Texture/singleColor.png.meta new file mode 100644 index 0000000..89cdf74 --- /dev/null +++ b/FanShooterDemo/assets/Texture/singleColor.png.meta @@ -0,0 +1,30 @@ +{ + "ver": "1.0.0", + "uuid": "a8027877-d8d6-4645-97a0-52d4a0123dba", + "type": "sprite", + "wrapMode": "clamp", + "filterMode": "bilinear", + "subMetas": { + "singleColor": { + "ver": "1.0.3", + "uuid": "410fb916-8721-4663-bab8-34397391ace7", + "rawTextureUuid": "a8027877-d8d6-4645-97a0-52d4a0123dba", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 0, + "trimY": 0, + "width": 2, + "height": 2, + "rawWidth": 2, + "rawHeight": 2, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "subMetas": {} + } + } +} \ No newline at end of file diff --git a/FanShooterDemo/creator.d.ts b/FanShooterDemo/creator.d.ts new file mode 100644 index 0000000..9714d9c --- /dev/null +++ b/FanShooterDemo/creator.d.ts @@ -0,0 +1,20635 @@ + +/** !#en +The main namespace of Cocos2d-JS, all engine core classes, functions, properties and constants are defined in this namespace. +!#zh +Cocos 引擎的主要命名空间,引擎代码中所有的类,函数,属性和常量都在这个命名空间中定义。 */ +declare module cc { + /** The current version of Cocos2d being used.
+ Please DO NOT remove this String, it is an important flag for bug tracking.
+ If you post a bug to forum, please attach this flag. */ + export var ENGINE_VERSION: string; + /** The element contains the game canvas */ + export var container: HTMLDivElement; + /** + !#en Init Debug setting. + !#zh 设置调试模式。 + @param mode mode + */ + export function _initDebugSetting(mode: DebugMode): void; + /** + !#en + Outputs an error message to the Cocos Creator Console (editor) or Web Console (runtime).
+ - In Cocos Creator, error is red.
+ - In Chrome, error have a red icon along with red message text.
+ !#zh + 输出错误消息到 Cocos Creator 编辑器的 Console 或运行时页面端的 Console 中。
+ - 在 Cocos Creator 中,错误信息显示是红色的。
+ - 在 Chrome 中,错误信息有红色的图标以及红色的消息文本。
+ @param msg A JavaScript string containing zero or more substitution strings. + @param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output. + */ + export function error(msg: any, ...subst: any[]): void; + /** + !#en + Outputs a warning message to the Cocos Creator Console (editor) or Web Console (runtime). + - In Cocos Creator, warning is yellow. + - In Chrome, warning have a yellow warning icon with the message text. + !#zh + 输出警告消息到 Cocos Creator 编辑器的 Console 或运行时 Web 端的 Console 中。
+ - 在 Cocos Creator 中,警告信息显示是黄色的。
+ - 在 Chrome 中,警告信息有着黄色的图标以及黄色的消息文本。
+ @param msg A JavaScript string containing zero or more substitution strings. + @param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output. + */ + export function warn(msg: any, ...subst: any[]): void; + /** + !#en Outputs a message to the Cocos Creator Console (editor) or Web Console (runtime). + !#zh 输出一条消息到 Cocos Creator 编辑器的 Console 或运行时 Web 端的 Console 中。 + @param msg A JavaScript string containing zero or more substitution strings. + @param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output. + */ + export function log(msg: string|any, ...subst: any[]): void; + /** + !#en + Outputs an informational message to the Cocos Creator Console (editor) or Web Console (runtime). + - In Cocos Creator, info is blue. + - In Firefox and Chrome, a small "i" icon is displayed next to these items in the Web Console's log. + !#zh + 输出一条信息消息到 Cocos Creator 编辑器的 Console 或运行时 Web 端的 Console 中。 + - 在 Cocos Creator 中,Info 信息显示是蓝色的。
+ - 在 Firefox 和 Chrome 中,Info 信息有着小 “i” 图标。 + @param msg A JavaScript string containing zero or more substitution strings. + @param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output. + */ + export function info(msg: any, ...subst: any[]): void; + /** + !#en + Creates the speed action which changes the speed of an action, making it take longer (speed > 1) + or less (speed < 1) time.
+ Useful to simulate 'slow motion' or 'fast forward' effect. + !#zh 修改目标动作的速率。 + @param action action + @param speed speed + + @example + ```js + // change the target action speed; + var action = cc.scaleTo(0.2, 1, 0.6); + var newAction = cc.speed(action, 0.5); + ``` + */ + export function speed(action: ActionInterval, speed: number): Action; + /** + !#en Create a follow action which makes its target follows another node. + !#zh 追踪目标节点的位置。 + @param followedNode followedNode + @param rect rect + + @example + ```js + // example + // creates the action with a set boundary + var followAction = cc.follow(targetNode, cc.rect(0, 0, screenWidth * 2 - 100, screenHeight)); + node.runAction(followAction); + + // creates the action with no boundary set + var followAction = cc.follow(targetNode); + node.runAction(followAction); + ``` + */ + export function follow(followedNode: Node, rect: Rect): Action; + /** + Points setter + @param points points + */ + export function setPoints(points: any[]): void; + /** + !#en Creates an action with a Cardinal Spline array of points and tension. + !#zh 按基数样条曲线轨迹移动到目标位置。 + @param duration duration + @param points array of control points + @param tension tension + + @example + ```js + //create a cc.CardinalSplineTo + var action1 = cc.cardinalSplineTo(3, array, 0); + ``` + */ + export function cardinalSplineTo(duration: number, points: any[], tension: number): ActionInterval; + /** + update position of target + @param newPos newPos + */ + export function updatePosition(newPos: Vec2): void; + /** + !#en Creates an action with a Cardinal Spline array of points and tension. + !#zh 按基数样条曲线轨迹移动指定的距离。 + @param duration duration + @param points points + @param tension tension + */ + export function cardinalSplineBy(duration: number, points: any[], tension: number): ActionInterval; + /** + !#en Creates an action with a Cardinal Spline array of points and tension. + !#zh 按 Catmull Rom 样条曲线轨迹移动到目标位置。 + @param dt dt + @param points points + + @example + ```js + var action1 = cc.catmullRomTo(3, array); + ``` + */ + export function catmullRomTo(dt: number, points: any[]): ActionInterval; + /** + !#en Creates an action with a Cardinal Spline array of points and tension. + !#zh 按 Catmull Rom 样条曲线轨迹移动指定的距离。 + @param dt dt + @param points points + + @example + ```js + var action1 = cc.catmullRomBy(3, array); + ``` + */ + export function catmullRomBy(dt: number, points: any[]): ActionInterval; + /** + !#en + Creates the action easing object with the rate parameter.
+ From slow to fast. + !#zh 创建 easeIn 缓动对象,由慢到快。 + @param rate rate + + @example + ```js + action.easing(cc.easeIn(3.0)); + ``` + */ + export function easeIn(rate: number): any; + /** + !#en + Creates the action easing object with the rate parameter.
+ From fast to slow. + !#zh 创建 easeOut 缓动对象,由快到慢。 + @param rate rate + + @example + ```js + action.easing(cc.easeOut(3.0)); + ``` + */ + export function easeOut(rate: number): any; + /** + !#en + Creates the action easing object with the rate parameter.
+ Slow to fast then to slow. + !#zh 创建 easeInOut 缓动对象,慢到快,然后慢。 + @param rate rate + + @example + ```js + action.easing(cc.easeInOut(3.0)); + ``` + */ + export function easeInOut(rate: number): any; + /** + !#en + Creates the action easing object with the rate parameter.
+ Reference easeInExpo:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeExponentialIn 缓动对象。
+ EaseExponentialIn 是按指数函数缓动进入的动作。
+ 参考 easeInExpo:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + action.easing(cc.easeExponentialIn()); + ``` + */ + export function easeExponentialIn(): any; + /** + !#en + Creates the action easing object.
+ Reference easeOutExpo:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeExponentialOut 缓动对象。
+ EaseExponentialOut 是按指数函数缓动退出的动作。
+ 参考 easeOutExpo:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + action.easing(cc.easeExponentialOut()); + ``` + */ + export function easeExponentialOut(): any; + /** + !#en + Creates an EaseExponentialInOut action easing object.
+ Reference easeInOutExpo:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeExponentialInOut 缓动对象。
+ EaseExponentialInOut 是按指数函数缓动进入并退出的动作。
+ 参考 easeInOutExpo:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + action.easing(cc.easeExponentialInOut()); + ``` + */ + export function easeExponentialInOut(): any; + /** + !#en + Creates an EaseSineIn action.
+ Reference easeInSine:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 EaseSineIn 缓动对象。
+ EaseSineIn 是按正弦函数缓动进入的动作。
+ 参考 easeInSine:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + action.easing(cc.easeSineIn()); + ``` + */ + export function easeSineIn(): any; + /** + !#en + Creates an EaseSineOut action easing object.
+ Reference easeOutSine:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 EaseSineOut 缓动对象。
+ EaseSineIn 是按正弦函数缓动退出的动作。
+ 参考 easeOutSine:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + action.easing(cc.easeSineOut()); + ``` + */ + export function easeSineOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInOutSine:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeSineInOut 缓动对象。
+ EaseSineIn 是按正弦函数缓动进入并退出的动作。
+ 参考 easeInOutSine:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + action.easing(cc.easeSineInOut()); + ``` + */ + export function easeSineInOut(): any; + /** + !#en + Creates the action easing obejct with the period in radians (default is 0.3).
+ Reference easeInElastic:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeElasticIn 缓动对象。
+ EaseElasticIn 是按弹性曲线缓动进入的动作。
+ 参数 easeInElastic:http://www.zhihu.com/question/21981571/answer/19925418 + @param period period + + @example + ```js + // example + action.easing(cc.easeElasticIn(3.0)); + ``` + */ + export function easeElasticIn(period: number): any; + /** + !#en + Creates the action easing object with the period in radians (default is 0.3).
+ Reference easeOutElastic:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeElasticOut 缓动对象。
+ EaseElasticOut 是按弹性曲线缓动退出的动作。
+ 参考 easeOutElastic:http://www.zhihu.com/question/21981571/answer/19925418 + @param period period + + @example + ```js + // example + action.easing(cc.easeElasticOut(3.0)); + ``` + */ + export function easeElasticOut(period: number): any; + /** + !#en + Creates the action easing object with the period in radians (default is 0.3).
+ Reference easeInOutElastic:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeElasticInOut 缓动对象。
+ EaseElasticInOut 是按弹性曲线缓动进入并退出的动作。
+ 参考 easeInOutElastic:http://www.zhihu.com/question/21981571/answer/19925418 + @param period period + + @example + ```js + // example + action.easing(cc.easeElasticInOut(3.0)); + ``` + */ + export function easeElasticInOut(period: number): any; + /** + !#en + Creates the action easing object.
+ Eased bounce effect at the beginning. + !#zh + 创建 easeBounceIn 缓动对象。
+ EaseBounceIn 是按弹跳动作缓动进入的动作。 + + @example + ```js + // example + action.easing(cc.easeBounceIn()); + ``` + */ + export function easeBounceIn(): any; + /** + !#en + Creates the action easing object.
+ Eased bounce effect at the ending. + !#zh + 创建 easeBounceOut 缓动对象。
+ EaseBounceOut 是按弹跳动作缓动退出的动作。 + + @example + ```js + // example + action.easing(cc.easeBounceOut()); + ``` + */ + export function easeBounceOut(): any; + /** + !#en + Creates the action easing object.
+ Eased bounce effect at the begining and ending. + !#zh + 创建 easeBounceInOut 缓动对象。
+ EaseBounceInOut 是按弹跳动作缓动进入并退出的动作。 + + @example + ```js + // example + action.easing(cc.easeBounceInOut()); + ``` + */ + export function easeBounceInOut(): any; + /** + !#en + Creates the action easing object.
+ In the opposite direction to move slowly, and then accelerated to the right direction. + !#zh + 创建 easeBackIn 缓动对象。
+ easeBackIn 是在相反的方向缓慢移动,然后加速到正确的方向。
+ + @example + ```js + // example + action.easing(cc.easeBackIn()); + ``` + */ + export function easeBackIn(): any; + /** + !#en + Creates the action easing object.
+ Fast moving more than the finish, and then slowly back to the finish. + !#zh + 创建 easeBackOut 缓动对象。
+ easeBackOut 快速移动超出目标,然后慢慢回到目标点。 + + @example + ```js + // example + action.easing(cc.easeBackOut()); + ``` + */ + export function easeBackOut(): any; + /** + !#en + Creates the action easing object.
+ Begining of cc.EaseBackIn. Ending of cc.EaseBackOut. + !#zh + 创建 easeBackInOut 缓动对象。
+ + @example + ```js + // example + action.easing(cc.easeBackInOut()); + ``` + */ + export function easeBackInOut(): any; + /** + !#en + Creates the action easing object.
+ Into the 4 reference point.
+ To calculate the motion curve. + !#zh + 创建 easeBezierAction 缓动对象。
+ EaseBezierAction 是按贝塞尔曲线缓动的动作。 + @param p0 The first bezier parameter + @param p1 The second bezier parameter + @param p2 The third bezier parameter + @param p3 The fourth bezier parameter + + @example + ```js + // example + action.easing(cc.easeBezierAction(0.5, 0.5, 1.0, 1.0)); + ``` + */ + export function easeBezierAction(p0: number, p1: number, p2: number, p3: number): any; + /** + !#en + Creates the action easing object.
+ Reference easeInQuad:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuadraticActionIn 缓动对象。
+ EaseQuadraticIn是按二次函数缓动进入的动作。
+ 参考 easeInQuad:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeQuadraticActionIn()); + ``` + */ + export function easeQuadraticActionIn(): any; + /** + !#en + Creates the action easing object.
+ Reference easeOutQuad:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuadraticActionOut 缓动对象。
+ EaseQuadraticOut 是按二次函数缓动退出的动作。
+ 参考 easeOutQuad:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeQuadraticActionOut()); + ``` + */ + export function easeQuadraticActionOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInOutQuad:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuadraticActionInOut 缓动对象。
+ EaseQuadraticInOut 是按二次函数缓动进入并退出的动作。
+ 参考 easeInOutQuad:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeQuadraticActionInOut()); + ``` + */ + export function easeQuadraticActionInOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeIntQuart:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuarticActionIn 缓动对象。
+ EaseQuarticIn 是按四次函数缓动进入的动作。
+ 参考 easeIntQuart:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeQuarticActionIn()); + ``` + */ + export function easeQuarticActionIn(): any; + /** + !#en + Creates the action easing object.
+ Reference easeOutQuart:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuarticActionOut 缓动对象。
+ EaseQuarticOut 是按四次函数缓动退出的动作。
+ 参考 easeOutQuart:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.QuarticActionOut()); + ``` + */ + export function easeQuarticActionOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInOutQuart:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuarticActionInOut 缓动对象。
+ EaseQuarticInOut 是按四次函数缓动进入并退出的动作。
+ 参考 easeInOutQuart:http://www.zhihu.com/question/21981571/answer/19925418 + */ + export function easeQuarticActionInOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInQuint:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuinticActionIn 缓动对象。
+ EaseQuinticIn 是按五次函数缓动进的动作。
+ 参考 easeInQuint:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeQuinticActionIn()); + ``` + */ + export function easeQuinticActionIn(): any; + /** + !#en + Creates the action easing object.
+ Reference easeOutQuint:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuinticActionOut 缓动对象。
+ EaseQuinticOut 是按五次函数缓动退出的动作 + 参考 easeOutQuint:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeQuadraticActionOut()); + ``` + */ + export function easeQuinticActionOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInOutQuint:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuinticActionInOut 缓动对象。
+ EaseQuinticInOut是按五次函数缓动进入并退出的动作。
+ 参考 easeInOutQuint:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeQuinticActionInOut()); + ``` + */ + export function easeQuinticActionInOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInCirc:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeCircleActionIn 缓动对象。
+ EaseCircleIn是按圆形曲线缓动进入的动作。
+ 参考 easeInCirc:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeCircleActionIn()); + ``` + */ + export function easeCircleActionIn(): any; + /** + !#en + Creates the action easing object.
+ Reference easeOutCirc:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeCircleActionOut 缓动对象。
+ EaseCircleOut是按圆形曲线缓动退出的动作。
+ 参考 easeOutCirc:http://www.zhihu.com/question/21981571/answer/19925418 + */ + export function easeCircleActionOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInOutCirc:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeCircleActionInOut 缓动对象。
+ EaseCircleInOut 是按圆形曲线缓动进入并退出的动作。
+ 参考 easeInOutCirc:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeCircleActionInOut()); + ``` + */ + export function easeCircleActionInOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInCubic:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeCubicActionIn 缓动对象。
+ EaseCubicIn 是按三次函数缓动进入的动作。
+ 参考 easeInCubic:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeCubicActionIn()); + ``` + */ + export function easeCubicActionIn(): any; + /** + !#en + Creates the action easing object.
+ Reference easeOutCubic:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeCubicActionOut 缓动对象。
+ EaseCubicOut 是按三次函数缓动退出的动作。
+ 参考 easeOutCubic:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeCubicActionOut()); + ``` + */ + export function easeCubicActionOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInOutCubic:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeCubicActionInOut 缓动对象。
+ EaseCubicInOut是按三次函数缓动进入并退出的动作。
+ 参考 easeInOutCubic:http://www.zhihu.com/question/21981571/answer/19925418 + */ + export function easeCubicActionInOut(): any; + /** + !#en Show the Node. + !#zh 立即显示。 + + @example + ```js + // example + var showAction = cc.show(); + ``` + */ + export function show(): ActionInstant; + /** + !#en Hide the node. + !#zh 立即隐藏。 + + @example + ```js + // example + var hideAction = cc.hide(); + ``` + */ + export function hide(): ActionInstant; + /** + !#en Toggles the visibility of a node. + !#zh 显隐状态切换。 + + @example + ```js + // example + var toggleVisibilityAction = cc.toggleVisibility(); + ``` + */ + export function toggleVisibility(): ActionInstant; + /** + !#en Create a RemoveSelf object with a flag indicate whether the target should be cleaned up while removing. + !#zh 从父节点移除自身。 + @param isNeedCleanUp isNeedCleanUp + + @example + ```js + // example + var removeSelfAction = cc.removeSelf(); + ``` + */ + export function removeSelf(isNeedCleanUp ?: boolean): ActionInstant; + /** + !#en Create a FlipX action to flip or unflip the target. + !#zh X轴翻转。 + @param flip Indicate whether the target should be flipped or not + + @example + ```js + var flipXAction = cc.flipX(true); + ``` + */ + export function flipX(flip: boolean): ActionInstant; + /** + !#en Create a FlipY action to flip or unflip the target. + !#zh Y轴翻转。 + @param flip flip + + @example + ```js + var flipYAction = cc.flipY(true); + ``` + */ + export function flipY(flip: boolean): ActionInstant; + /** + !#en Creates a Place action with a position. + !#zh 放置在目标位置。 + @param pos pos + @param y y + + @example + ```js + // example + var placeAction = cc.place(cc.p(200, 200)); + var placeAction = cc.place(200, 200); + ``` + */ + export function place(pos: Vec2|number, y?: number): ActionInstant; + /** + !#en Creates the action with the callback. + !#zh 执行回调函数。 + @param selector selector + @param selectorTarget selectorTarget + @param data data for function, it accepts all data types. + + @example + ```js + // example + // CallFunc without data + var finish = cc.callFunc(this.removeSprite, this); + + // CallFunc with data + var finish = cc.callFunc(this.removeFromParentAndCleanup, this._grossini, true); + ``` + */ + export function callFunc(selector: Function, selectorTarget?: any, data?: any): ActionInstant; + /** + !#en + Helper constructor to create an array of sequenceable actions + The created action will run actions sequentially, one after another. + !#zh 顺序执行动作,创建的动作将按顺序依次运行。 + @param actionOrActionArray actionOrActionArray + @param tempArray tempArray + + @example + ```js + // example + // create sequence with actions + var seq = cc.sequence(act1, act2); + + // create sequence with array + var seq = cc.sequence(actArray); + ``` + */ + export function sequence(actionOrActionArray: FiniteTimeAction|FiniteTimeAction[], ...tempArray: FiniteTimeAction[]): ActionInterval; + /** + !#en Creates a Repeat action. Times is an unsigned integer between 1 and pow(2,30) + !#zh 重复动作,可以按一定次数重复一个动,如果想永远重复一个动作请使用 repeatForever 动作来完成。 + @param action action + @param times times + + @example + ```js + // example + var rep = cc.repeat(cc.sequence(jump2, jump1), 5); + ``` + */ + export function repeat(action: FiniteTimeAction, times: number): ActionInterval; + /** + !#en Create a acton which repeat forever, as it runs forever, it can't be added into cc.sequence and cc.spawn. + !#zh 永远地重复一个动作,有限次数内重复一个动作请使用 repeat 动作,由于这个动作不会停止,所以不能被添加到 cc.sequence 或 cc.spawn 中。 + @param action action + + @example + ```js + // example + var repeat = cc.repeatForever(cc.rotateBy(1.0, 360)); + ``` + */ + export function repeatForever(action: FiniteTimeAction): ActionInterval; + /** + !#en Create a spawn action which runs several actions in parallel. + !#zh 同步执行动作,同步执行一组动作。 + @param actionOrActionArray actionOrActionArray + @param tempArray tempArray + + @example + ```js + // example + var action = cc.spawn(cc.jumpBy(2, cc.p(300, 0), 50, 4), cc.rotateBy(2, 720)); + todo:It should be the direct use new + ``` + */ + export function spawn(actionOrActionArray: FiniteTimeAction|FiniteTimeAction[], ...tempArray: FiniteTimeAction[]): FiniteTimeAction; + /** + !#en + Rotates a Node object to a certain angle by modifying its rotation property.
+ The direction will be decided by the shortest angle. + !#zh 旋转到目标角度,通过逐帧修改它的 rotation 属性,旋转方向将由最短的角度决定。 + @param duration duration in seconds + @param deltaAngleX deltaAngleX in degrees. + @param deltaAngleY deltaAngleY in degrees. + + @example + ```js + // example + var rotateTo = cc.rotateTo(2, 61.0); + ``` + */ + export function rotateTo(duration: number, deltaAngleX: number, deltaAngleY?: number): ActionInterval; + /** + !#en + Rotates a Node object clockwise a number of degrees by modifying its rotation property. + Relative to its properties to modify. + !#zh 旋转指定的角度。 + @param duration duration in seconds + @param deltaAngleX deltaAngleX in degrees + @param deltaAngleY deltaAngleY in degrees + + @example + ```js + // example + var actionBy = cc.rotateBy(2, 360); + ``` + */ + export function rotateBy(duration: number, deltaAngleX: number, deltaAngleY?: number): ActionInterval; + /** + !#en + Moves a Node object x,y pixels by modifying its position property.
+ x and y are relative to the position of the object.
+ Several MoveBy actions can be concurrently called, and the resulting
+ movement will be the sum of individual movements. + !#zh 移动指定的距离。 + @param duration duration in seconds + @param deltaPos deltaPos + @param deltaY deltaY + + @example + ```js + // example + var actionTo = cc.moveBy(2, cc.p(windowSize.width - 40, windowSize.height - 40)); + ``` + */ + export function moveBy(duration: number, deltaPos: Vec2|number, deltaY?: number): ActionInterval; + /** + !#en + Moves a Node object to the position x,y. x and y are absolute coordinates by modifying its position property.
+ Several MoveTo actions can be concurrently called, and the resulting
+ movement will be the sum of individual movements. + !#zh 移动到目标位置。 + @param duration duration in seconds + @param position position + @param y y + + @example + ```js + // example + var actionBy = cc.moveTo(2, cc.p(80, 80)); + ``` + */ + export function moveTo(duration: number, position: Vec2|number, y?: number): ActionInterval; + /** + !#en + Create a action which skews a Node object to given angles by modifying its skewX and skewY properties. + Changes to the specified value. + !#zh 偏斜到目标角度。 + @param t time in seconds + @param sx sx + @param sy sy + + @example + ```js + // example + var actionTo = cc.skewTo(2, 37.2, -37.2); + ``` + */ + export function skewTo(t: number, sx: number, sy: number): ActionInterval; + /** + !#en + Skews a Node object by skewX and skewY degrees.
+ Relative to its property modification. + !#zh 偏斜指定的角度。 + @param t time in seconds + @param sx sx skew in degrees for X axis + @param sy sy skew in degrees for Y axis + + @example + ```js + // example + var actionBy = cc.skewBy(2, 0, -90); + ``` + */ + export function skewBy(t: number, sx: number, sy: number): ActionInterval; + /** + !#en + Moves a Node object simulating a parabolic jump movement by modifying it's position property. + Relative to its movement. + !#zh 用跳跃的方式移动指定的距离。 + @param duration duration + @param position position + @param y y + @param height height + @param jumps jumps + + @example + ```js + // example + var actionBy = cc.jumpBy(2, cc.p(300, 0), 50, 4); + var actionBy = cc.jumpBy(2, 300, 0, 50, 4); + ``` + */ + export function jumpBy(duration: number, position: Vec2|number, y?: number, height?: number, jumps?: number): ActionInterval; + /** + !#en + Moves a Node object to a parabolic position simulating a jump movement by modifying its position property.
+ Jump to the specified location. + !#zh 用跳跃的方式移动到目标位置。 + @param duration duration + @param position position + @param y y + @param height height + @param jumps jumps + + @example + ```js + // example + var actionTo = cc.jumpTo(2, cc.p(300, 300), 50, 4); + var actionTo = cc.jumpTo(2, 300, 300, 50, 4); + ``` + */ + export function jumpTo(duration: number, position: Vec2|number, y?: number, height?: number, jumps?: number): ActionInterval; + /** + !#en + An action that moves the target with a cubic Bezier curve by a certain distance. + Relative to its movement. + !#zh 按贝赛尔曲线轨迹移动指定的距离。 + @param t time in seconds + @param c Array of points + + @example + ```js + // example + var bezier = [cc.p(0, windowSize.height / 2), cc.p(300, -windowSize.height / 2), cc.p(300, 100)]; + var bezierForward = cc.bezierBy(3, bezier); + ``` + */ + export function bezierBy(t: number, c: Vec2[]): ActionInterval; + /** + !#en An action that moves the target with a cubic Bezier curve to a destination point. + !#zh 按贝赛尔曲线轨迹移动到目标位置。 + @param t t + @param c Array of points + + @example + ```js + // example + var bezier = [cc.p(0, windowSize.height / 2), cc.p(300, -windowSize.height / 2), cc.p(300, 100)]; + var bezierTo = cc.bezierTo(2, bezier); + ``` + */ + export function bezierTo(t: number, c: Vec2[]): ActionInterval; + /** + !#en Scales a Node object to a zoom factor by modifying it's scale property. + !#zh 将节点大小缩放到指定的倍数。 + @param duration duration + @param sx scale parameter in X + @param sy scale parameter in Y, if Null equal to sx + + @example + ```js + // example + // It scales to 0.5 in both X and Y. + var actionTo = cc.scaleTo(2, 0.5); + + // It scales to 0.5 in x and 2 in Y + var actionTo = cc.scaleTo(2, 0.5, 2); + ``` + */ + export function scaleTo(duration: number, sx: number, sy?: number): ActionInterval; + /** + !#en + Scales a Node object a zoom factor by modifying it's scale property. + Relative to its changes. + !#zh 按指定的倍数缩放节点大小。 + @param duration duration in seconds + @param sx sx scale parameter in X + @param sy sy scale parameter in Y, if Null equal to sx + + @example + ```js + // example without sy, it scales by 2 both in X and Y + var actionBy = cc.scaleBy(2, 2); + + //example with sy, it scales by 0.25 in X and 4.5 in Y + var actionBy2 = cc.scaleBy(2, 0.25, 4.5); + ``` + */ + export function scaleBy(duration: number, sx: number, sy?: number|void): ActionInterval; + /** + !#en Blinks a Node object by modifying it's visible property. + !#zh 闪烁(基于透明度)。 + @param duration duration in seconds + @param blinks blinks in times + + @example + ```js + // example + var action = cc.blink(2, 10); + ``` + */ + export function blink(duration: number, blinks: number): ActionInterval; + /** + !#en + Fades an object that implements the cc.RGBAProtocol protocol. + It modifies the opacity from the current value to a custom one. + !#zh 修改透明度到指定值。 + @param duration duration + @param opacity 0-255, 0 is transparent + + @example + ```js + // example + var action = cc.fadeTo(1.0, 0); + ``` + */ + export function fadeTo(duration: number, opacity: number): ActionInterval; + /** + !#en Fades In an object that implements the cc.RGBAProtocol protocol. It modifies the opacity from 0 to 255. + !#zh 渐显效果。 + @param duration duration in seconds + + @example + ```js + //example + var action = cc.fadeIn(1.0); + ``` + */ + export function fadeIn(duration: number): ActionInterval; + /** + !#en Fades Out an object that implements the cc.RGBAProtocol protocol. It modifies the opacity from 255 to 0. + !#zh 渐隐效果。 + @param d duration in seconds + + @example + ```js + // example + var action = cc.fadeOut(1.0); + ``` + */ + export function fadeOut(d: number): ActionInterval; + /** + !#en Tints a Node that implements the cc.NodeRGB protocol from current tint to a custom one. + !#zh 修改颜色到指定值。 + @param duration duration + @param red 0-255 + @param green 0-255 + @param blue 0-255 + + @example + ```js + // example + var action = cc.tintTo(2, 255, 0, 255); + ``` + */ + export function tintTo(duration: number, red: number, green: number, blue: number): ActionInterval; + /** + !#en + Tints a Node that implements the cc.NodeRGB protocol from current tint to a custom one. + Relative to their own color change. + !#zh 按照指定的增量修改颜色。 + @param duration duration in seconds + @param deltaRed deltaRed + @param deltaGreen deltaGreen + @param deltaBlue deltaBlue + + @example + ```js + // example + var action = cc.tintBy(2, -127, -255, -127); + ``` + */ + export function tintBy(duration: number, deltaRed: number, deltaGreen: number, deltaBlue: number): ActionInterval; + /** + !#en Delays the action a certain amount of seconds. + !#en 延迟指定的时间量。 + @param d duration in seconds + + @example + ```js + // example + var delay = cc.delayTime(1); + ``` + */ + export function delayTime(d: number): ActionInterval; + /** + !#en Executes an action in reverse order, from time=duration to time=0. + !#zh 反转目标动作的时间轴。 + @param action action + + @example + ```js + // example + var reverse = cc.reverseTime(this); + ``` + */ + export function reverseTime(action: FiniteTimeAction): ActionInterval; + /** + !#en Create an action with the specified action and forced target. + !#zh 用已有动作和一个新的目标节点创建动作。 + @param target target + @param action action + */ + export function targetedAction(target: Node, action: FiniteTimeAction): ActionInterval; + /** !#en cc.view is the shared view object. + !#zh cc.view 是全局的视图对象。 */ + export var view: View; + /** !#en Director + !#zh 导演类。 */ + export var director: Director; + /** !#en cc.winSize is the alias object for the size of the current game window. + !#zh cc.winSize 为当前的游戏窗口的大小。 */ + export var winSize: Size; + export var game: Game; + /** !#en The System event singleton for global usage + !#zh 系统事件单例,方便全局使用 */ + export var systemEvent: SystemEvent; + /** + + @param touches touches + */ + export function handleTouchesBegin(touches: any[]): void; + /** + + @param touches touches + */ + export function handleTouchesMove(touches: any[]): void; + /** + + @param touches touches + */ + export function handleTouchesEnd(touches: any[]): void; + /** + + @param touches touches + */ + export function handleTouchesCancel(touches: any[]): void; + /** + + @param touches touches + */ + export function getSetOfTouchesEndOrCancel(touches: any[]): any[]; + /** + + @param element element + */ + export function getHTMLElementPosition(element: HTMLElement): any; + /** + + @param touch touch + */ + export function getPreTouch(touch: Touch): Touch; + /** + + @param touch touch + */ + export function setPreTouch(touch: Touch): void; + /** + + @param tx tx + @param ty ty + @param pos pos + */ + export function getTouchByXY(tx: number, ty: number, pos: Vec2): Touch; + /** + + @param event event + @param pos pos + */ + export function getPointByEvent(event: Touch, pos: Vec2): Vec2; + /** + + @param event event + @param pos pos + */ + export function getTouchesByEvent(event: Touch, pos: Vec2): any[]; + /** + + @param element element + */ + export function registerSystemEvent(element: HTMLElement): void; + /** + !#en Defines a CCClass using the given specification, please see [Class](/docs/editors_and_tools/creator-chapters/scripting/class.html) for details. + !#zh 定义一个 CCClass,传入参数必须是一个包含类型参数的字面量对象,具体用法请查阅[类型定义](/docs/creator/scripting/class.html)。 + @param options options + + @example + ```js + // define base class + var Node = cc.Class(); + + // define sub class + var Sprite = cc.Class({ + name: 'Sprite', + extends: Node, + ctor: function () { + this.url = ""; + this.id = 0; + }, + + statics: { + // define static members + count: 0, + getBounds: function (spriteList) { + // compute bounds... + } + }, + + properties { + width: { + default: 128, + type: 'Integer', + tooltip: 'The width of sprite' + }, + height: 128, + size: { + get: function () { + return cc.v2(this.width, this.height); + } + } + }, + + load: function () { + // load this.url... + }; + }); + + // instantiate + + var obj = new Sprite(); + obj.url = 'sprite.png'; + obj.load(); + ``` + */ + export function Class(options?: {name?: string; extends?: Function; ctor?: Function; __ctor__?: Function; properties?: any; statics?: any; mixins?: Function[]; editor?: {executeInEditMode?: boolean; requireComponent?: Function; menu?: string; executionOrder?: number; disallowMultiple?: boolean; playOnFocus?: boolean; inspector?: string; icon?: string; help?: string; }; update?: Function; lateUpdate?: Function; onLoad?: Function; start?: Function; onEnable?: Function; onDisable?: Function; onDestroy?: Function; onFocusInEditor?: Function; onLostFocusInEditor?: Function; resetInEditor?: Function; onRestore?: Function; _getLocalBounds?: Function; }): Function; + /** + Checks whether subclass is child of superclass or equals to superclass + @param subclass subclass + @param superclass superclass + */ + export function isChildClassOf(subclass: Function, superclass: Function): boolean; + /** + Return all super classes + @param constructor constructor + */ + export function getInheritanceChain(constructor: Function): Function[]; + /** + !#en + Define an enum type.
+ If a enum item has a value of -1, it will be given an Integer number according to it's order in the list.
+ Otherwise it will use the value specified by user who writes the enum definition. + + !#zh + 定义一个枚举类型。
+ 用户可以把枚举值设为任意的整数,如果设为 -1,系统将会分配为上一个枚举值 + 1。 + @param obj a JavaScript literal object containing enum names and values, or a TypeScript enum type + + @example + ```js + // JavaScript: + + var WrapMode = cc.Enum({ + Repeat: -1, + Clamp: -1 + }); + + // Texture.WrapMode.Repeat == 0 + // Texture.WrapMode.Clamp == 1 + // Texture.WrapMode[0] == "Repeat" + // Texture.WrapMode[1] == "Clamp" + + var FlagType = cc.Enum({ + Flag1: 1, + Flag2: 2, + Flag3: 4, + Flag4: 8, + }); + + var AtlasSizeList = cc.Enum({ + 128: 128, + 256: 256, + 512: 512, + 1024: 1024, + }); + + // TypeScript: + + // If used in TypeScript, just define a TypeScript enum: + enum Direction { + Up, + Down, + Left, + Right + } + + // If you need to inspect the enum in Properties panel, you can call cc.Enum: + const {ccclass, property} = cc._decorator; + + @ccclass + class NewScript extends cc.Component { + @property({ + default: Direction.Up, + type: cc.Enum(Direction) // call cc.Enum + }) + direction: Direction = Direction.Up; + } + + ``` + */ + export function Enum(obj: T): T; + /** + whether enable accelerometer event + @param isEnable isEnable + */ + export function setAccelerometerEnabled(isEnable: boolean): void; + /** + set accelerometer interval value + @param interval interval + */ + export function setAccelerometerInterval(interval: number): void; + /** + + @param touches touches + */ + export function handleTouchesBegin(touches: any[]): void; + /** + + @param touches touches + */ + export function handleTouchesMove(touches: any[]): void; + /** + + @param touches touches + */ + export function handleTouchesEnd(touches: any[]): void; + /** + + @param touches touches + */ + export function handleTouchesCancel(touches: any[]): void; + /** + + @param touches touches + */ + export function getSetOfTouchesEndOrCancel(touches: any[]): any[]; + /** + + @param element element + */ + export function getHTMLElementPosition(element: HTMLElement): any; + /** + + @param touch touch + */ + export function getPreTouch(touch: Touch): Touch; + /** + + @param touch touch + */ + export function setPreTouch(touch: Touch): void; + /** + + @param tx tx + @param ty ty + @param pos pos + */ + export function getTouchByXY(tx: number, ty: number, pos: Vec2): Touch; + /** + + @param location location + @param pos pos + @param eventType eventType + */ + export function getTouchByXY(location: Vec2, pos: Vec2, eventType: number): Event.EventMouse; + /** + + @param event event + @param pos pos + */ + export function getPointByEvent(event: Touch, pos: Vec2): Vec2; + /** + + @param event event + @param pos pos + */ + export function getTouchesByEvent(event: Touch, pos: Vec2): any[]; + /** + + @param element element + */ + export function registerSystemEvent(element: HTMLElement): void; + /** + + @param dt dt + */ + export function update(dt: number): void; + /** +

+ Linear interpolation between 2 numbers, the ratio sets how much it is biased to each end +

+ @param a number A + @param b number B + @param r ratio between 0 and 1 + + @example + ```js + ---- + lerp + cc.lerp(2,10,0.5)//returns 6 + cc.lerp(2,10,0.2)//returns 3.6 + + ``` + */ + export function lerp(a: number, b: number, r: number): void; + /** + get a random number from 0 to 0xffffff + */ + export function rand(): number; + /** + returns a random float between -1 and 1 + */ + export function randomMinus1To1(): number; + /** + returns a random float between 0 and 1, use Math.random directly + */ + export function random0To1(): number; + /** + converts degrees to radians + @param angle angle + */ + export function degreesToRadians(angle: number): number; + /** + converts radians to degrees + @param angle angle + */ + export function radiansToDegrees(angle: number): number; + /** + Helpful macro that setups the GL server state, the correct GL program and sets the Model View Projection matrix + @param node setup node + */ + export function nodeDrawSetup(node: Node): void; + /** +

+ Increments the GL Draws counts by one.
+ The number of calls per frame are displayed on the screen when the CCDirector's stats are enabled.
+

+ @param addNumber addNumber + */ + export function incrementGLDraws(addNumber: number): void; + /** + Check webgl error.Error will be shown in console if exists. + */ + export function checkGLErrorDebug(): void; + /** + !#en + Checks whether the object is non-nil and not yet destroyed.
+ When an object's `destroy` is called, it is actually destroyed after the end of this frame. + So `isValid` will return false from the next frame, while `isValid` in the current frame will still be true. + If you want to determine whether the current frame has called `destroy`, use `cc.isValid(obj, true)`, + but this is often caused by a particular logical requirements, which is not normally required. + + !#zh + 检查该对象是否不为 null 并且尚未销毁。
+ 当一个对象的 `destroy` 调用以后,会在这一帧结束后才真正销毁。因此从下一帧开始 `isValid` 就会返回 false,而当前帧内 `isValid` 仍然会是 true。如果希望判断当前帧是否调用过 `destroy`,请使用 `cc.isValid(obj, true)`,不过这往往是特殊的业务需求引起的,通常情况下不需要这样。 + @param value value + @param strictMode If true, Object called destroy() in this frame will also treated as invalid. + + @example + ```js + var node = new cc.Node(); + cc.log(cc.isValid(node)); // true + node.destroy(); + cc.log(cc.isValid(node)); // true, still valid in this frame + // after a frame... + cc.log(cc.isValid(node)); // false, destroyed in the end of last frame + ``` + */ + export function isValid(value: any, strictMode?: boolean): boolean; + /** Specify that the input value must be integer in Inspector. + Also used to indicates that the elements in array should be type integer. */ + export var Integer: string; + /** Indicates that the elements in array should be type double. */ + export var Float: string; + /** Indicates that the elements in array should be type boolean. */ + export var Boolean: string; + /** Indicates that the elements in array should be type string. */ + export var String: string; + /** + !#en Deserialize json to cc.Asset + !#zh 将 JSON 反序列化为对象实例。 + + 当指定了 target 选项时,如果 target 引用的其它 asset 的 uuid 不变,则不会改变 target 对 asset 的引用, + 也不会将 uuid 保存到 result 对象中。 + @param data the serialized cc.Asset json string or json object. + @param details additional loading result + @param options options + */ + export function deserialize(data: string|any, details?: Details, options?: any): any; + /** + !#en Clones the object `original` and returns the clone, or instantiate a node from the Prefab. + !#zh 克隆指定的任意类型的对象,或者从 Prefab 实例化出新节点。 + + (Instantiate 时,function 和 dom 等非可序列化对象会直接保留原有引用,Asset 会直接进行浅拷贝,可序列化类型会进行深拷贝。) + @param original An existing object that you want to make a copy of. + + @example + ```js + // instantiate node from prefab + var scene = cc.director.getScene(); + var node = cc.instantiate(prefabAsset); + node.parent = scene; + // clone node + var scene = cc.director.getScene(); + var node = cc.instantiate(targetNode); + node.parent = scene; + ``` + */ + export function instantiate(original: Prefab): Node; + export function instantiate(original: T): T; + /** + Finds a node by hierarchy path, the path is case-sensitive. + It will traverse the hierarchy by splitting the path using '/' character. + This function will still returns the node even if it is inactive. + It is recommended to not use this function every frame instead cache the result at startup. + @param path path + @param referenceNode referenceNode + */ + export function find(path: string, referenceNode?: Node): Node; + /** + !#en + The convenience method to create a new {{#crossLink "Color/Color:method"}}cc.Color{{/crossLink}} + Alpha channel is optional. Default value is 255. + + !#zh + 通过该方法来创建一个新的 {{#crossLink "Color/Color:method"}}cc.Color{{/crossLink}} 对象。 + Alpha 通道是可选的。默认值是 255。 + @param r r + @param g g + @param b b + @param a a + + @example + ```js + ----------------------- + // 1. All channels seperately as parameters + var color1 = new cc.Color(255, 255, 255, 255); + // 2. Convert a hex string to a color + var color2 = new cc.Color("#000000"); + // 3. An color object as parameter + var color3 = new cc.Color({r: 255, g: 255, b: 255, a: 255}); + + ``` + */ + export function color(r?: number, g?: number, b?: number, a?: number): Color; + /** + !#en returns true if both ccColor3B are equal. Otherwise it returns false. + !#zh 判断两个颜色对象的 RGB 部分是否相等,不比较透明度。 + @param color1 color1 + @param color2 color2 + + @example + ```js + cc.log(cc.colorEqual(cc.Color.RED, new cc.Color(255, 0, 0))); // true + ``` + */ + export function colorEqual(color1: Color, color2: Color): boolean; + /** + !#en + convert a string of color for style to Color. + e.g. "#ff06ff" to : cc.color(255,6,255)。 + !#zh 16 进制转换为 Color + @param hex hex + + @example + ```js + cc.hexToColor("#FFFF33"); // Color {r: 255, g: 255, b: 51, a: 255}; + ``` + */ + export function hexToColor(hex: string): Color; + /** + !#en + convert Color to a string of color for style. + e.g. cc.color(255,6,255) to : "#ff06ff" + !#zh Color 转换为 16进制。 + @param color color + + @example + ```js + var color = new cc.Color(255, 6, 255) + cc.colorToHex(color); // #ff06ff; + ``` + */ + export function colorToHex(color: Color): string; + /** + !#en Returns opposite of Vec2. + !#zh 返回相反的向量。 + @param point point + + @example + ```js + cc.pNeg(cc.v2(10, 10));// Vec2 {x: -10, y: -10}; + ``` + */ + export function pNeg(point: Vec2): Vec2; + /** + !#en Calculates sum of two points. + !#zh 返回两个向量的和。 + @param v1 v1 + @param v2 v2 + + @example + ```js + cc.pAdd(cc.v2(1, 1), cc.v2(2, 2));// Vec2 {x: 3, y: 3}; + ``` + */ + export function pAdd(v1: Vec2, v2: Vec2): Vec2; + /** + !#en Calculates difference of two points. + !#zh 返回两个向量的差。 + @param v1 v1 + @param v2 v2 + + @example + ```js + cc.pSub(cc.v2(20, 20), cc.v2(5, 5)); // Vec2 {x: 15, y: 15}; + ``` + */ + export function pSub(v1: Vec2, v2: Vec2): Vec2; + /** + !#en Returns point multiplied by given factor. + !#zh 向量缩放。 + @param point point + @param floatVar floatVar + + @example + ```js + cc.pMult(cc.v2(5, 5), 4); // Vec2 {x: 20, y: 20}; + ``` + */ + export function pMult(point: Vec2, floatVar: number): Vec2; + /** + !#en Calculates midpoint between two points. + !#zh 两个向量之间的中心点。 + @param v1 v1 + @param v2 v2 + + @example + ```js + cc.pMidpoint(cc.v2(10, 10), cc.v2(5, 5)); // Vec2 {x: 7.5, y: 7.5}; + ``` + */ + export function pMidpoint(v1: Vec2, v2: Vec2): Vec2; + /** + !#en Calculates dot product of two points. + !#zh 两个向量之间进行点乘。 + @param v1 v1 + @param v2 v2 + + @example + ```js + cc.pDot(cc.v2(20, 20), cc.v2(5, 5)); // 200; + ``` + */ + export function pDot(v1: Vec2, v2: Vec2): number; + /** + !#en Calculates cross product of two points. + !#zh 两个向量之间进行叉乘。 + @param v1 v1 + @param v2 v2 + + @example + ```js + cc.pCross(cc.v2(20, 20), cc.v2(5, 5)); // 0; + ``` + */ + export function pCross(v1: Vec2, v2: Vec2): number; + /** + !#en Calculates perpendicular of v, rotated 90 degrees counter-clockwise -- cross(v, perp(v)) greater than 0. + !#zh 返回逆时针旋转 90 度后的新向量。 + @param point point + + @example + ```js + cc.pPerp(cc.v2(20, 20)); // Vec2 {x: -20, y: 20}; + ``` + */ + export function pPerp(point: Vec2): Vec2; + /** + !#en Calculates perpendicular of v, rotated 90 degrees clockwise -- cross(v, rperp(v)) smaller than 0. + !#zh 将指定向量顺时针旋转 90 度并返回。 + @param point point + + @example + ```js + cc.pRPerp(cc.v2(20, 20)); // Vec2 {x: 20, y: -20}; + ``` + */ + export function pRPerp(point: Vec2): Vec2; + /** + !#en Calculates the projection of v1 over v2. + !#zh 返回 v1 在 v2 上的投影向量。 + @param v1 v1 + @param v2 v2 + + @example + ```js + var v1 = cc.v2(20, 20); + var v2 = cc.v2(5, 5); + cc.pProject(v1, v2); // Vec2 {x: 20, y: 20}; + ``` + */ + export function pProject(v1: Vec2, v2: Vec2): Vec2; + /** + !#en Calculates the square length of a cc.Vec2 (not calling sqrt() ). + !#zh 返回指定向量长度的平方。 + @param v v + + @example + ```js + cc.pLengthSQ(cc.v2(20, 20)); // 800; + ``` + */ + export function pLengthSQ(v: Vec2): number; + /** + !#en Calculates the square distance between two points (not calling sqrt() ). + !#zh 返回两个点之间距离的平方。 + @param point1 point1 + @param point2 point2 + + @example + ```js + var point1 = cc.v2(20, 20); + var point2 = cc.v2(5, 5); + cc.pDistanceSQ(point1, point2); // 450; + ``` + */ + export function pDistanceSQ(point1: Vec2, point2: Vec2): number; + /** + !#en Calculates distance between point an origin. + !#zh 返回指定向量的长度. + @param v v + + @example + ```js + cc.pLength(cc.v2(20, 20)); // 28.284271247461902; + ``` + */ + export function pLength(v: Vec2): number; + /** + !#en Calculates the distance between two points. + !#zh 返回指定 2 个向量之间的距离。 + @param v1 v1 + @param v2 v2 + + @example + ```js + var v1 = cc.v2(20, 20); + var v2 = cc.v2(5, 5); + cc.pDistance(v1, v2); // 21.213203435596427; + ``` + */ + export function pDistance(v1: Vec2, v2: Vec2): number; + /** + !#en Returns this vector with a magnitude of 1. + !#zh 返回一个长度为 1 的标准化过后的向量。 + @param v v + + @example + ```js + cc.pNormalize(cc.v2(20, 20)); // Vec2 {x: 0.7071067811865475, y: 0.7071067811865475}; + ``` + */ + export function pNormalize(v: Vec2): Vec2; + /** + !#en Converts radians to a normalized vector. + !#zh 将弧度转换为一个标准化后的向量,返回坐标 x = cos(a) , y = sin(a)。 + @param a a + + @example + ```js + cc.pForAngle(20); // Vec2 {x: 0.40808206181339196, y: 0.9129452507276277}; + ``` + */ + export function pForAngle(a: number): Vec2; + /** + !#en Converts a vector to radians. + !#zh 返回指定向量的弧度。 + @param v v + + @example + ```js + cc.pToAngle(cc.v2(20, 20)); // 0.7853981633974483; + ``` + */ + export function pToAngle(v: Vec2): number; + /** + !#en Clamp a value between from and to. + !#zh + 限定浮点数的最大最小值。
+ 数值大于 max_inclusive 则返回 max_inclusive。
+ 数值小于 min_inclusive 则返回 min_inclusive。
+ 否则返回自身。 + @param value value + @param min_inclusive min_inclusive + @param max_inclusive max_inclusive + + @example + ```js + var v1 = cc.clampf(20, 0, 20); // 20; + var v2 = cc.clampf(-1, 0, 20); // 0; + var v3 = cc.clampf(10, 0, 20); // 10; + ``` + */ + export function clampf(value: number, min_inclusive: number, max_inclusive: number): number; + /** + !#en Clamp a value between 0 and 1. + !#zh 限定浮点数的取值范围为 0 ~ 1 之间。 + @param value value + + @example + ```js + var v1 = cc.clampf(20); // 1; + var v2 = cc.clampf(-1); // 0; + var v3 = cc.clampf(0.5); // 0.5; + ``` + */ + export function clamp01(value: number): number; + /** + !#en Clamp a point between from and to. + !#zh + 返回指定限制区域后的向量。
+ 向量大于 max_inclusive 则返回 max_inclusive。
+ 向量小于 min_inclusive 则返回 min_inclusive。
+ 否则返回自身。 + @param p p + @param min_inclusive min_inclusive + @param max_inclusive max_inclusive + + @example + ```js + var min_inclusive = cc.v2(0, 0); + var max_inclusive = cc.v2(20, 20); + var v1 = cc.pClamp(cc.v2(20, 20), min_inclusive, max_inclusive); // Vec2 {x: 20, y: 20}; + var v2 = cc.pClamp(cc.v2(0, 0), min_inclusive, max_inclusive); // Vec2 {x: 0, y: 0}; + var v3 = cc.pClamp(cc.v2(10, 10), min_inclusive, max_inclusive); // Vec2 {x: 10, y: 10}; + ``` + */ + export function pClamp(p: Vec2, min_inclusive: Vec2, max_inclusive: Vec2): Vec2; + /** + !#en Quickly convert cc.Size to a cc.Vec2. + !#zh 快速转换 cc.Size 为 cc.Vec2。 + @param s s + + @example + ```js + cc.pFromSize(new cc.size(20, 20)); // Vec2 {x: 20, y: 20}; + ``` + */ + export function pFromSize(s: Size): Vec2; + /** + !#en + Run a math operation function on each point component
+ Math.abs, Math.fllor, Math.ceil, Math.round. + !#zh 通过运行指定的数学运算函数来计算指定的向量。 + @param p p + @param opFunc opFunc + + @example + ```js + cc.pCompOp(cc.p(-10, -10), Math.abs); // Vec2 {x: 10, y: 10}; + ``` + */ + export function pCompOp(p: Vec2, opFunc: Function): Vec2; + /** + !#en + Linear Interpolation between two points a and b.
+ alpha == 0 ? a
+ alpha == 1 ? b
+ otherwise a value between a..b. + !#zh + 两个点 A 和 B 之间的线性插值。
+ alpha == 0 ? a
+ alpha == 1 ? b
+ 否则这个数值在 a ~ b 之间。 + @param a a + @param b b + @param alpha alpha + + @example + ```js + cc.pLerp(cc.v2(20, 20), cc.v2(5, 5), 0.5); // Vec2 {x: 12.5, y: 12.5}; + ``` + */ + export function pLerp(a: Vec2, b: Vec2, alpha: number): Vec2; + /** + !#en TODO + !#zh + 近似判断两个点是否相等。
+ 判断 2 个向量是否在指定数值的范围之内,如果在则返回 true,反之则返回 false。 + @param a a + @param b b + @param variance variance + + @example + ```js + var a = cc.v2(20, 20); + var b = cc.v2(5, 5); + var b1 = cc.pFuzzyEqual(a, b, 10); // false; + var b2 = cc.pFuzzyEqual(a, b, 18); // true; + ``` + */ + export function pFuzzyEqual(a: Vec2, b: Vec2, variance: number): boolean; + /** + !#en Multiplies a nd b components, a.x*b.x, a.y*b.y. + !#zh 计算两个向量的每个分量的乘积, a.x * b.x, a.y * b.y。 + @param a a + @param b b + + @example + ```js + cc.pCompMult(acc.v2(20, 20), cc.v2(5, 5)); // Vec2 {x: 100, y: 100}; + ``` + */ + export function pCompMult(a: Vec2, b: Vec2): Vec2; + /** + !#en TODO + !#zh 返回两个向量之间带正负号的弧度。 + @param a a + @param b b + */ + export function pAngleSigned(a: Vec2, b: Vec2): number; + /** + !#en TODO + !#zh 获取当前向量与指定向量之间的弧度角。 + @param a a + @param b b + */ + export function pAngle(a: Vec2, b: Vec2): number; + /** + !#en Rotates a point counter clockwise by the angle around a pivot. + !#zh 返回给定向量围绕指定轴心顺时针旋转一定弧度后的结果。 + @param v v is the point to rotate + @param pivot pivot is the pivot, naturally + @param angle angle is the angle of rotation cw in radians + */ + export function pRotateByAngle(v: Vec2, pivot: Vec2, angle: number): Vec2; + /** + !#en + A general line-line intersection test + indicating successful intersection of a line
+ note that to truly test intersection for segments we have to make
+ sure that s & t lie within [0..1] and for rays, make sure s & t > 0
+ the hit point is p3 + t * (p4 - p3);
+ the hit point also is p1 + s * (p2 - p1); + !#zh + 返回 A 为起点 B 为终点线段 1 所在直线和 C 为起点 D 为终点线段 2 所在的直线是否相交,
+ 如果相交返回 true,反之则为 false,参数 retP 是返回交点在线段 1、线段 2 上的比例。 + @param A A is the startpoint for the first line P1 = (p1 - p2). + @param B B is the endpoint for the first line P1 = (p1 - p2). + @param C C is the startpoint for the second line P2 = (p3 - p4). + @param D D is the endpoint for the second line P2 = (p3 - p4). + @param retP retP.x is the range for a hitpoint in P1 (pa = p1 + s*(p2 - p1)),
+ retP.y is the range for a hitpoint in P3 (pa = p2 + t*(p4 - p3)). + */ + export function pLineIntersect(A: Vec2, B: Vec2, C: Vec2, D: Vec2, retP: Vec2): boolean; + /** + !#en ccpSegmentIntersect return YES if Segment A-B intersects with segment C-D. + !#zh 返回线段 A - B 和线段 C - D 是否相交。 + @param A A + @param B B + @param C C + @param D D + */ + export function pSegmentIntersect(A: Vec2, B: Vec2, C: Vec2, D: Vec2): boolean; + /** + !#en ccpIntersectPoint return the intersection point of line A-B, C-D. + !#zh 返回线段 A - B 和线段 C - D 的交点。 + @param A A + @param B B + @param C C + @param D D + */ + export function pIntersectPoint(A: Vec2, B: Vec2, C: Vec2, D: Vec2): Vec2; + /** + !#en check to see if both points are equal. + !#zh 检查指定的 2 个向量是否相等。 + @param A A ccp a + @param B B ccp b to be compared + */ + export function pSameAs(A: Vec2, B: Vec2): boolean; + /** + !#en sets the position of the point to 0. + !#zh 设置指定向量归 0。 + @param v v + */ + export function pZeroIn(v: Vec2): void; + /** + !#en copies the position of one point to another. + !#zh 令 v1 向量等同于 v2。 + @param v1 v1 + @param v2 v2 + */ + export function pIn(v1: Vec2, v2: Vec2): void; + /** + !#en multiplies the point with the given factor (inplace). + !#zh 向量缩放,结果保存到第一个向量。 + @param point point + @param floatVar floatVar + */ + export function pMultIn(point: Vec2, floatVar: number): void; + /** + !#en subtracts one point from another (inplace). + !#zh 向量减法,结果保存到第一个向量。 + @param v1 v1 + @param v2 v2 + */ + export function pSubIn(v1: Vec2, v2: Vec2): void; + /** + !#en adds one point to another (inplace). + !#zh 向量加法,结果保存到第一个向量。 + @param v1 v1 + @param v2 v2 + */ + export function pAddIn(v1: Vec2, v2: Vec2): void; + /** + !#en normalizes the point (inplace). + !#zh 规范化 v 向量,设置 v 向量长度为 1。 + @param v v + */ + export function pNormalizeIn(v: Vec2): void; + /** + !#en + The convenience method to create a new Rect. + see {{#crossLink "Rect/Rect:method"}}cc.Rect{{/crossLink}} + !#zh + 该方法用来快速创建一个新的矩形。{{#crossLink "Rect/Rect:method"}}cc.Rect{{/crossLink}} + @param x x + @param y y + @param w w + @param h h + + @example + ```js + var a = new cc.Rect(0 , 0, 10, 0); + ``` + */ + export function rect(x?: number, y?: number, w?: number, h?: number): Rect; + /** + !#en Check whether a rect's value equals to another. + !#zh 判断两个矩形是否相等。 + @param rect1 rect1 + @param rect2 rect2 + + @example + ```js + var a = new cc.Rect(0, 0, 10, 10); + var b = new cc.Rect(0, 0, 5, 5); + cc.rectEqualToRect(a, b); // false; + var c = new cc.Rect(0, 0, 5, 5); + cc.rectEqualToRect(b, c); // true; + ``` + */ + export function rectEqualToRect(rect1: Rect, rect2: Rect): boolean; + /** + !#en Check whether the rect1 contains rect2. + !#zh + 检查 rect1 矩形是否包含 rect2 矩形。
+ 注意:如果要允许 rect1 和 rect2 的边界重合,应该用 cc.rectOverlapsRect + @param rect1 rect1 + @param rect2 rect2 + + @example + ```js + var a = new cc.Rect(0, 0, 20, 20); + var b = new cc.Rect(10, 10, 20, 20); + cc.rectContainsRect(a, b); // true; + ``` + */ + export function rectContainsRect(rect1: Rect, rect2: Rect): boolean; + /** + !#en Returns the rightmost x-value of a rect. + !#zh 返回矩形在 x 轴上的最大值 + @param rect rect + + @example + ```js + var a = new cc.Rect(10, 0, 20, 20); + cc.rectGetMaxX(a); // 30; + ``` + */ + export function rectGetMaxX(rect: Rect): number; + /** + !#en Return the midpoint x-value of a rect. + !#zh 返回矩形在 x 轴上的中点。 + @param rect rect + + @example + ```js + var a = new cc.Rect(10, 0, 20, 20); + cc.rectGetMidX(a); // 20; + ``` + */ + export function rectGetMidX(rect: Rect): number; + /** + !#en Returns the leftmost x-value of a rect. + !#zh 返回矩形在 x 轴上的最小值。 + @param rect rect + + @example + ```js + var a = new cc.Rect(10, 0, 20, 20); + cc.rectGetMinX(a); // 10; + ``` + */ + export function rectGetMinX(rect: Rect): number; + /** + !#en Return the topmost y-value of a rect. + !#zh 返回矩形在 y 轴上的最大值。 + @param rect rect + + @example + ```js + var a = new cc.Rect(0, 10, 20, 20); + cc.rectGetMaxY(a); // 30; + ``` + */ + export function rectGetMaxY(rect: Rect): number; + /** + !#en Return the midpoint y-value of `rect'. + !#zh 返回矩形在 y 轴上的中点。 + @param rect rect + + @example + ```js + var a = new cc.Rect(0, 10, 20, 20); + cc.rectGetMidY(a); // 20; + ``` + */ + export function rectGetMidY(rect: Rect): number; + /** + !#en Return the bottommost y-value of a rect. + !#zh 返回矩形在 y 轴上的最小值。 + @param rect rect + + @example + ```js + var a = new cc.Rect(0, 10, 20, 20); + cc.rectGetMinY(a); // 10; + ``` + */ + export function rectGetMinY(rect: Rect): number; + /** + !#en Check whether a rect contains a point. + !#zh 检查一个矩形是否包含某个坐标点。 + @param rect rect + @param point point + + @example + ```js + var a = new cc.Rect(0, 10, 20, 20); + var b = new cc.Vec2(0, 10, 10, 10); + cc.rectContainsPoint(a, b); // true; + ``` + */ + export function rectContainsPoint(rect: Rect, point: Vec2): boolean; + /** + !#en Check whether a rect intersect with another. + !#zh 检查一个矩形是否与另一个相交。 + @param rectA rectA + @param rectB rectB + + @example + ```js + var a = new cc.Rect(0, 10, 20, 20); + var b = new cc.Rect(0, 10, 10, 10); + cc.rectIntersectsRect(a, b); // true; + ``` + */ + export function rectIntersectsRect(rectA: Rect, rectB: Rect): boolean; + /** + !#en Check whether a rect overlaps another. + !#zh 检查一个矩形是否重叠另一个。 + @param rectA rectA + @param rectB rectB + + @example + ```js + var a = new cc.Rect(0, 10, 20, 20); + var b = new cc.Rect(0, 10, 10, 10); + cc.rectOverlapsRect(a, b); // true; + ``` + */ + export function rectOverlapsRect(rectA: Rect, rectB: Rect): boolean; + /** + !#en Returns the smallest rectangle that contains the two source rectangles. + !#zh 返回一个包含两个指定矩形的最小矩形。 + @param rectA rectA + @param rectB rectB + + @example + ```js + var a = new cc.Rect(0, 10, 20, 20); + var b = new cc.Rect(0, 10, 10, 10); + cc.rectUnion(a, b); // Rect {x: 0, y: 10, width: 20, height: 20}; + ``` + */ + export function rectUnion(rectA: Rect, rectB: Rect): Rect; + /** + !#en Returns the overlapping portion of 2 rectangles. + !#zh 返回 2 个矩形重叠的部分。 + @param rectA rectA + @param rectB rectB + + @example + ```js + var a = new cc.Rect(0, 10, 20, 20); + var b = new cc.Rect(0, 10, 10, 10); + cc.rectIntersection(a, b); // Rect {x: 0, y: 10, width: 10, height: 10}; + ``` + */ + export function rectIntersection(rectA: Rect, rectB: Rect): Rect; + /** + !#en + Helper function that creates a cc.Size.
+ Please use cc.p or cc.v2 instead, it will soon replace cc.Size. + !#zh + 创建一个 cc.Size 对象的帮助函数。
+ 注意:可以使用 cc.p 或者是 cc.v2 代替,它们将很快取代 cc.Size。 + @param w width or a size object + @param h height + + @example + ```js + var size1 = cc.size(); + var size2 = cc.size(100,100); + var size3 = cc.size(size2); + var size4 = cc.size({width: 100, height: 100}); + + ``` + */ + export function size(w: number|Size, h?: number): Size; + /** + !#en Check whether a point's value equals to another. + !#zh 检查 Size 对象是否等于另一个。 + @param size1 size1 + @param size2 size2 + + @example + ```js + var a = new cc.size(10, 10); + var b = new cc.size(10, 10); + cc.sizeEqualToSize(a, b);// return true; + var b = new cc.size(5, 10); + cc.sizeEqualToSize(a, b);// return false; + ``` + */ + export function sizeEqualToSize(size1: Size, size2: Size): boolean; + export function V3F_C4B_T2F_QuadZero(): V3F_C4B_T2F_Quad; + /** + + @param sourceQuad sourceQuad + */ + export function V3F_C4B_T2F_QuadCopy(sourceQuad: V3F_C4B_T2F_Quad): V3F_C4B_T2F_Quad; + /** + + @param sourceQuads sourceQuads + */ + export function V3F_C4B_T2F_QuadsCopy(sourceQuads: any[]): any[]; + /** + !#en The convenience method to create a new {{#crossLink "Vec2"}}cc.Vec2{{/crossLink}}. + !#zh 通过该简便的函数进行创建 {{#crossLink "Vec2"}}cc.Vec2{{/crossLink}} 对象。 + @param x x + @param y y + + @example + ```js + var v1 = cc.v2(); + var v2 = cc.v2(0, 0); + var v3 = cc.v2(v2); + var v4 = cc.v2({x: 100, y: 100}); + ``` + */ + export function v2(x?: number|any, y?: number): Vec2; + /** + !#en The convenience method to creates a new {{#crossLink "Vec2"}}cc.Vec2{{/crossLink}}. + !#zh 通过该简便的函数进行创建 {{#crossLink "Vec2"}}cc.Vec2{{/crossLink}} 对象。 + @param x a Number or a size object + @param y y + + @example + ```js + var point1 = cc.p(); + var point2 = cc.p(100, 100); + var point3 = cc.p(point2); + var point4 = cc.p({x: 100, y: 100}); + ``` + */ + export function p(x?: number|any, y?: number): Vec2; + /** + !#en Check whether a point's value equals to another. + !#zh 判断两个向量是否相等。 + @param point1 point1 + @param point2 point2 + */ + export function pointEqualToPoint(point1: Vec2, point2: Vec2): boolean; + /** !#en Enum for debug modes. + !#zh 调试模式 */ + export enum DebugMode { + NONE = 0, + INFO = 0, + WARN = 0, + ERROR = 0, + INFO_FOR_WEB_PAGE = 0, + WARN_FOR_WEB_PAGE = 0, + ERROR_FOR_WEB_PAGE = 0, + } + /** !#en Base class cc.Action for action classes. + !#zh Action 类是所有动作类型的基类。 */ + export class Action { + /** + !#en + to copy object with deep copy. + returns a clone of action. + !#zh 返回一个克隆的动作。 + */ + clone(): Action; + /** + !#en + return true if the action has finished. + !#zh 如果动作已完成就返回 true。 + */ + isDone(): boolean; + /** + !#en get the target. + !#zh 获取当前目标节点。 + */ + getTarget(): Node; + /** + !#en The action will modify the target properties. + !#zh 设置目标节点。 + @param target target + */ + setTarget(target: Node): void; + /** + !#en get the original target. + !#zh 获取原始目标节点。 + */ + getOriginalTarget(): Node; + /** + !#en get tag number. + !#zh 获取用于识别动作的标签。 + */ + getTag(): number; + /** + !#en set tag number. + !#zh 设置标签,用于识别动作。 + @param tag tag + */ + setTag(tag: number): void; + /** !#en Default Action tag. + !#zh 默认动作标签。 */ + static TAG_INVALID: number; + } + /** !#en + Base class actions that do have a finite time duration.
+ Possible actions:
+ - An action with a duration of 0 seconds.
+ - An action with a duration of 35.5 seconds. + + Infinite time actions are valid + !#zh 有限时间动作,这种动作拥有时长 duration 属性。 */ + export class FiniteTimeAction extends Action { + /** + !#en get duration of the action. (seconds). + !#zh 获取动作以秒为单位的持续时间。 + */ + getDuration(): number; + /** + !#en set duration of the action. (seconds). + !#zh 设置动作以秒为单位的持续时间。 + @param duration duration + */ + setDuration(duration: number): void; + /** + !#en + Returns a reversed action.
+ For example:
+ - The action will be x coordinates of 0 move to 100.
+ - The reversed action will be x of 100 move to 0. + - Will be rewritten + !#zh 返回一个新的动作,执行与原动作完全相反的动作。 + */ + reverse(): void; + /** + !#en + to copy object with deep copy. + returns a clone of action. + !#zh 返回一个克隆的动作。 + */ + clone(): FiniteTimeAction; + } + /** !#en Base class for Easing actions. + !#zh 所有缓动动作基类,用于修饰 ActionInterval。 */ + export class ActionEase extends ActionInterval { + } + /** !#en Base class for Easing actions with rate parameters + !#zh 拥有速率属性的缓动动作基类。 */ + export class EaseRateAction extends ActionEase { + } + /** !#en Ease Elastic abstract class. + !#zh 弹性缓动动作基类。 */ + export class EaseElastic extends ActionEase { + } + /** !#en cc.EaseBounce abstract class. + !#zh 反弹缓动动作基类。 */ + export class EaseBounce extends ActionEase { + } + /** !#en Instant actions are immediate actions. They don't have a duration like the ActionInterval actions. + !#zh 即时动作,这种动作立即就会执行,继承自 FiniteTimeAction。 */ + export class ActionInstant extends FiniteTimeAction { + } + /** !#en +

An interval action is an action that takes place within a certain period of time.
+ It has an start time, and a finish time. The finish time is the parameter
+ duration plus the start time.

+ +

These CCActionInterval actions have some interesting properties, like:
+ - They can run normally (default)
+ - They can run reversed with the reverse method
+ - They can run with the time altered with the Accelerate, AccelDeccel and Speed actions.

+ +

For example, you can simulate a Ping Pong effect running the action normally and
+ then running it again in Reverse mode.

+ !#zh 时间间隔动作,这种动作在已定时间内完成,继承 FiniteTimeAction。 */ + export class ActionInterval extends FiniteTimeAction { + /** + !#en Implementation of ease motion. + !#zh 缓动运动。 + @param easeObj easeObj + + @example + ```js + action.easing(cc.easeIn(3.0)); + ``` + */ + easing(easeObj: any): ActionInterval; + /** + !#en + Repeats an action a number of times. + To repeat an action forever use the CCRepeatForever action. + !#zh 重复动作可以按一定次数重复一个动作,使用 RepeatForever 动作来永远重复一个动作。 + @param times times + */ + repeat(times: number): ActionInterval; + /** + !#en + Repeats an action for ever.
+ To repeat the an action for a limited number of times use the Repeat action.
+ !#zh 永远地重复一个动作,有限次数内重复一个动作请使用 Repeat 动作。 + */ + repeatForever(): ActionInterval; + } + /** !#en + cc.ActionManager is a class that can manage actions.
+ Normally you won't need to use this class directly. 99% of the cases you will use the CCNode interface, + which uses this class's singleton object. + But there are some cases where you might need to use this class.
+ Examples:
+ - When you want to run an action where the target is different from a CCNode.
+ - When you want to pause / resume the actions
+ !#zh + cc.ActionManager 是可以管理动作的单例类。
+ 通常你并不需要直接使用这个类,99%的情况您将使用 CCNode 的接口。
+ 但也有一些情况下,您可能需要使用这个类。
+ 例如: + - 当你想要运行一个动作,但目标不是 CCNode 类型时。
+ - 当你想要暂停/恢复动作时。
*/ + export class ActionManager { + /** + !#en + Adds an action with a target.
+ If the target is already present, then the action will be added to the existing target. + If the target is not present, a new instance of this target will be created either paused or not, and the action will be added to the newly created target. + When the target is paused, the queued actions won't be 'ticked'. + !#zh + 增加一个动作,同时还需要提供动作的目标对象,目标对象是否暂停作为参数。
+ 如果目标已存在,动作将会被直接添加到现有的节点中。
+ 如果目标不存在,将为这一目标创建一个新的实例,并将动作添加进去。
+ 当目标状态的 paused 为 true,动作将不会被执行 + @param action action + @param target target + @param paused paused + */ + addAction(action: Action, target: Node, paused: boolean): void; + /** + !#en Removes all actions from all the targets. + !#zh 移除所有对象的所有动作。 + */ + removeAllActions(): void; + /** + !#en + Removes all actions from a certain target.
+ All the actions that belongs to the target will be removed. + !#zh + 移除指定对象上的所有动作。
+ 属于该目标的所有的动作将被删除。 + @param target target + @param forceDelete forceDelete + */ + removeAllActionsFromTarget(target: Node, forceDelete: boolean): void; + /** + !#en Removes an action given an action reference. + !#zh 移除指定的动作。 + @param action action + */ + removeAction(action: Action): void; + /** + !#en Removes an action given its tag and the target. + !#zh 删除指定对象下特定标签的一个动作,将删除首个匹配到的动作。 + @param tag tag + @param target target + */ + removeActionByTag(tag: number, target: Node): void; + /** + !#en Gets an action given its tag an a target. + !#zh 通过目标对象和标签获取一个动作。 + @param tag tag + @param target target + */ + getActionByTag(tag: number, target: Node): Action; + /** + !#en + Returns the numbers of actions that are running in a certain target.
+ Composable actions are counted as 1 action.
+ Example:
+ - If you are running 1 Sequence of 7 actions, it will return 1.
+ - If you are running 7 Sequences of 2 actions, it will return 7. + !#zh + 返回指定对象下所有正在运行的动作数量。
+ 组合动作被算作一个动作。
+ 例如:
+ - 如果您正在运行 7 个动作组成的序列动作(Sequence),这个函数将返回 1。
+ - 如果你正在运行 2 个序列动作(Sequence)和 5 个普通动作,这个函数将返回 7。
+ @param target target + */ + getNumberOfRunningActionsInTarget(target: Node): number; + /** + !#en Pauses the target: all running actions and newly added actions will be paused. + !#zh 暂停指定对象:所有正在运行的动作和新添加的动作都将会暂停。 + @param target target + */ + pauseTarget(target: Node): void; + /** + !#en Resumes the target. All queued actions will be resumed. + !#zh 让指定目标恢复运行。在执行序列中所有被暂停的动作将重新恢复运行。 + @param target target + */ + resumeTarget(target: Node): void; + /** + !#en Pauses all running actions, returning a list of targets whose actions were paused. + !#zh 暂停所有正在运行的动作,返回一个包含了那些动作被暂停了的目标对象的列表。 + */ + pauseAllRunningActions(): any[]; + /** + !#en Resume a set of targets (convenience function to reverse a pauseAllRunningActions or pauseTargets call). + !#zh 让一组指定对象恢复运行(用来逆转 pauseAllRunningActions 效果的便捷函数)。 + @param targetsToResume targetsToResume + */ + resumeTargets(targetsToResume: any[]): void; + /** + !#en Pause a set of targets. + !#zh 暂停一组指定对象。 + @param targetsToPause targetsToPause + */ + pauseTargets(targetsToPause: any[]): void; + /** + !#en + purges the shared action manager. It releases the retained instance.
+ because it uses this, so it can not be static. + !#zh + 清除共用的动作管理器。它释放了持有的实例。
+ 因为它使用 this,因此它不能是静态的。 + */ + purgeSharedManager(): void; + /** + !#en The ActionManager update。 + !#zh ActionManager 主循环。 + @param dt delta time in seconds + */ + update(dt: number): void; + } + /** !#en Class for animation data handling. + !#zh 动画剪辑,用于存储动画数据。 */ + export class AnimationClip extends Asset { + /** !#en Duration of this animation. + !#zh 动画的持续时间。 */ + duration: number; + /** !#en FrameRate of this animation. + !#zh 动画的帧速率。 */ + sample: number; + /** !#en Speed of this animation. + !#zh 动画的播放速度。 */ + speed: number; + /** !#en WrapMode of this animation. + !#zh 动画的循环模式。 */ + wrapMode: WrapMode; + /** !#en Curve data. + !#zh 曲线数据。 */ + curveData: any; + /** !#en Event data. + !#zh 事件数据。 */ + events: {frame: number, func: string, params: string[]}[]; + /** + !#en Crate clip with a set of sprite frames + !#zh 使用一组序列帧图片来创建动画剪辑 + @param spriteFrames spriteFrames + @param sample sample + + @example + ```js + var clip = cc.AnimationClip.createWithSpriteFrames(spriteFrames, 10); + ``` + */ + static createWithSpriteFrames(spriteFrames: [SpriteFrame], sample: number): AnimationClip; + } + /** !#en + The AnimationState gives full control over animation playback process. + In most cases the Animation Component is sufficient and easier to use. Use the AnimationState if you need full control. + !#zh + AnimationState 完全控制动画播放过程。
+ 大多数情况下 动画组件 是足够和易于使用的。如果您需要更多的动画控制接口,请使用 AnimationState。 */ + export class AnimationState extends Playable { + /** + + @param clip clip + @param name name + */ + constructor(clip: AnimationClip, name?: string); + animator: AnimationAnimator; + /** !#en The curves list. + !#zh 曲线列表。 */ + curves: any[]; + /** !#en The start delay which represents the number of seconds from an animation's start time to the start of + the active interval. + !#zh 延迟多少秒播放。 */ + delay: number; + /** !#en The animation's iteration count property. + + A real number greater than or equal to zero (including positive infinity) representing the number of times + to repeat the animation node. + + Values less than zero and NaN values are treated as the value 1.0 for the purpose of timing model + calculations. + + !#zh 迭代次数,指动画播放多少次后结束, normalize time。 如 2.5(2次半) */ + repeatCount: number; + /** !#en The iteration duration of this animation in seconds. (length) + !#zh 单次动画的持续时间,秒。 */ + duration: number; + /** !#en The animation's playback speed. 1 is normal playback speed. + !#zh 播放速率。 */ + speed: number; + /** !#en + Wrapping mode of the playing animation. + Notice : dynamic change wrapMode will reset time and repeatCount property + !#zh + 动画循环方式。 + 需要注意的是,动态修改 wrapMode 时,会重置 time 以及 repeatCount */ + wrapMode: WrapMode; + /** !#en The current time of this animation in seconds. + !#zh 动画当前的时间,秒。 */ + time: number; + /** !#en The clip that is being played by this animation state. + !#zh 此动画状态正在播放的剪辑。 */ + clip: AnimationClip; + /** !#en The name of the playing animation. + !#zh 动画的名字 */ + name: string; + } + /** undefined */ + export class Playable { + /** !#en Is playing or paused in play mode? + !#zh 当前是否正在播放。 */ + isPlaying: boolean; + /** !#en Is currently paused? This can be true even if in edit mode(isPlaying == false). + !#zh 当前是否正在暂停 */ + isPaused: boolean; + /** + !#en Play this animation. + !#zh 播放动画。 + */ + play(): void; + /** + !#en Stop this animation. + !#zh 停止动画播放。 + */ + stop(): void; + /** + !#en Pause this animation. + !#zh 暂停动画。 + */ + pause(): void; + /** + !#en Resume this animation. + !#zh 重新播放动画。 + */ + resume(): void; + /** + !#en Perform a single frame step. + !#zh 执行一帧动画。 + */ + step(): void; + } + /** !#en Specifies how time is treated when it is outside of the keyframe range of an Animation. + !#zh 动画使用的循环模式。 */ + export enum WrapMode { + Default = 0, + Normal = 0, + Reverse = 0, + Loop = 0, + LoopReverse = 0, + PingPong = 0, + PingPongReverse = 0, + } + /** !#en cc.audioEngine is the singleton object, it provide simple audio APIs. + !#zh + cc.audioengine是单例对象。
+ 主要用来播放音频,播放的时候会返回一个 audioID,之后都可以通过这个 audioID 来操作这个音频对象。
+ 不使用的时候,请使用 cc.audioEngine.uncache(filePath); 进行资源释放
+ 注意:
+ 在 Android 系统浏览器上,不同浏览器,不同版本的效果不尽相同。
+ 比如说:大多数浏览器都需要用户物理交互才可以开始播放音效,有一些不支持 WebAudio,
+ 有一些不支持多音轨播放。总之如果对音乐依赖比较强,请做尽可能多的测试。 */ + export class audioEngine { + /** + !#en Play audio. + !#zh 播放音频 + @param filePath The path of the audio file without filename extension. + @param loop Whether the music loop or not. + @param volume Volume size. + + @example + ```js + var audioID = cc.audioEngine.play(path, false, 0.5); + ``` + */ + static play(filePath: string, loop: boolean, volume: number): number; + /** + !#en Set audio loop. + !#zh 设置音频是否循环。 + @param audioID audio id. + @param loop Whether cycle. + + @example + ```js + cc.audioEngine.setLoop(id, true); + ``` + */ + static setLoop(audioID: number, loop: boolean): void; + /** + !#en Get audio cycle state. + !#zh 获取音频的循环状态。 + @param audioID audio id. + + @example + ```js + cc.audioEngine.isLoop(id); + ``` + */ + static isLoop(audioID: number): boolean; + /** + !#en Set the volume of audio. + !#zh 设置音量(0.0 ~ 1.0)。 + @param audioID audio id. + @param volume Volume must be in 0.0~1.0 . + + @example + ```js + cc.audioEngine.setVolume(id, 0.5); + ``` + */ + static setVolume(audioID: number, volume: number): void; + /** + !#en The volume of the music max value is 1.0,the min value is 0.0 . + !#zh 获取音量(0.0 ~ 1.0)。 + @param audioID audio id. + + @example + ```js + var volume = cc.audioEngine.getVolume(id); + ``` + */ + static getVolume(audioID: number): number; + /** + !#en Set current time + !#zh 设置当前的音频时间。 + @param audioID audio id. + @param sec current time. + + @example + ```js + cc.audioEngine.setCurrentTime(id, 2); + ``` + */ + static setCurrentTime(audioID: number, sec: number): boolean; + /** + !#en Get current time + !#zh 获取当前的音频播放时间。 + @param audioID audio id. + + @example + ```js + var time = cc.audioEngine.getCurrentTime(id); + ``` + */ + static getCurrentTime(audioID: number): number; + /** + !#en Get audio duration + !#zh 获取音频总时长。 + @param audioID audio id. + + @example + ```js + var time = cc.audioEngine.getDuration(id); + ``` + */ + static getDuration(audioID: number): number; + /** + !#en Get audio state + !#zh 获取音频状态。 + @param audioID audio id. + + @example + ```js + var state = cc.audioEngine.getState(id); + ``` + */ + static getState(audioID: number): audioEngine.AudioState; + /** + !#en Set Audio finish callback + !#zh 设置一个音频结束后的回调 + @param audioID audio id. + @param callback loaded callback. + + @example + ```js + cc.audioEngine.setFinishCallback(id, function () {}); + ``` + */ + static setFinishCallback(audioID: number, callback: Function): void; + /** + !#en Pause playing audio. + !#zh 暂停正在播放音频。 + @param audioID The return value of function play. + + @example + ```js + cc.audioEngine.pause(audioID); + ``` + */ + static pause(audioID: number): void; + /** + !#en Pause all playing audio + !#zh 暂停现在正在播放的所有音频。 + + @example + ```js + cc.audioEngine.pauseAll(); + ``` + */ + static pauseAll(): void; + /** + !#en Resume playing audio. + !#zh 恢复播放指定的音频。 + @param audioID The return value of function play. + + @example + ```js + cc.audioEngine.resume(audioID); + ``` + */ + static resume(audioID: number): void; + /** + !#en Resume all playing audio. + !#zh 恢复播放所有之前暂停的所有音频。 + + @example + ```js + cc.audioEngine.resumeAll(); + ``` + */ + static resumeAll(): void; + /** + !#en Stop playing audio. + !#zh 停止播放指定音频。 + @param audioID The return value of function play. + + @example + ```js + cc.audioEngine.stop(audioID); + ``` + */ + static stop(audioID: number): void; + /** + !#en Stop all playing audio. + !#zh 停止正在播放的所有音频。 + + @example + ```js + cc.audioEngine.stopAll(); + ``` + */ + static stopAll(): void; + /** + !#en Set up an audio can generate a few examples. + !#zh 设置一个音频可以设置几个实例 + @param num a number of instances to be created from within an audio + + @example + ```js + cc.audioEngine.setMaxAudioInstance(20); + ``` + */ + static setMaxAudioInstance(num: number): void; + /** + !#en Getting audio can produce several examples. + !#zh 获取一个音频可以设置几个实例 + + @example + ```js + cc.audioEngine.getMaxAudioInstance(); + ``` + */ + static getMaxAudioInstance(): number; + /** + !#en Unload the preloaded audio from internal buffer. + !#zh 卸载预加载的音频。 + @param filePath filePath + + @example + ```js + cc.audioEngine.uncache(filePath); + ``` + */ + static uncache(filePath: string): void; + /** + !#en Unload all audio from internal buffer. + !#zh 卸载所有音频。 + + @example + ```js + cc.audioEngine.uncacheAll(); + ``` + */ + static uncacheAll(): void; + /** + !#en Preload audio file. + !#zh 预加载一个音频 + @param filePath The file path of an audio. + @param callback The callback of an audio. + + @example + ```js + cc.audioEngine.preload(path); + ``` + */ + static preload(filePath: string, callback?: Function): void; + /** + !#en Set a size, the unit is KB. Over this size is directly resolved into DOM nodes. + !#zh 设置一个以 KB 为单位的尺寸,大于这个尺寸的音频在加载的时候会强制使用 dom 方式加载 + @param kb The file path of an audio. + + @example + ```js + cc.audioEngine.setMaxWebAudioSize(300); + ``` + */ + static setMaxWebAudioSize(kb: number): void; + } + /** !#en +

+ ATTENTION: USE cc.director INSTEAD OF cc.Director.
+ cc.director is a singleton object which manage your game's logic flow.
+ Since the cc.director is a singleton, you don't need to call any constructor or create functions,
+ the standard way to use it is by calling:
+ - cc.director.methodName();
+ + It creates and handle the main Window and manages how and when to execute the Scenes.
+
+ The cc.director is also responsible for:
+ - initializing the OpenGL context
+ - setting the OpenGL pixel format (default on is RGB565)
+ - setting the OpenGL buffer depth (default on is 0-bit)
+ - setting the color for clear screen (default one is BLACK)
+ - setting the projection (default one is 3D)
+ - setting the orientation (default one is Portrait)
+
+
+ The cc.director also sets the default OpenGL context:
+ - GL_TEXTURE_2D is enabled
+ - GL_VERTEX_ARRAY is enabled
+ - GL_COLOR_ARRAY is enabled
+ - GL_TEXTURE_COORD_ARRAY is enabled
+

+

+ cc.director also synchronizes timers with the refresh rate of the display.
+ Features and Limitations:
+ - Scheduled timers & drawing are synchronizes with the refresh rate of the display
+ - Only supports animation intervals of 1/60 1/30 & 1/15
+

+ + !#zh +

+ 注意:用 cc.director 代替 cc.Director。
+ cc.director 一个管理你的游戏的逻辑流程的单例对象。
+ 由于 cc.director 是一个单例,你不需要调用任何构造函数或创建函数,
+ 使用它的标准方法是通过调用:
+ - cc.director.methodName(); +
+ 它创建和处理主窗口并且管理什么时候执行场景。
+
+ cc.director 还负责:
+ - 初始化 OpenGL 环境。
+ - 设置OpenGL像素格式。(默认是 RGB565)
+ - 设置OpenGL缓冲区深度 (默认是 0-bit)
+ - 设置空白场景的颜色 (默认是 黑色)
+ - 设置投影 (默认是 3D)
+ - 设置方向 (默认是 Portrait)
+
+ cc.director 设置了 OpenGL 默认环境
+ - GL_TEXTURE_2D 启用。
+ - GL_VERTEX_ARRAY 启用。
+ - GL_COLOR_ARRAY 启用。
+ - GL_TEXTURE_COORD_ARRAY 启用。
+

+

+ cc.director 也同步定时器与显示器的刷新速率。 +
+ 特点和局限性:
+ - 将计时器 & 渲染与显示器的刷新频率同步。
+ - 只支持动画的间隔 1/60 1/30 & 1/15。
+

*/ + export class Director extends EventTarget { + /** + !#en + Converts an OpenGL coordinate to a view coordinate
+ Useful to convert node points to window points for calls such as glScissor
+ Implementation can be found in CCDirectorWebGL. + !#zh 将触摸点的 WebGL View 坐标转换为屏幕坐标。 + @param glPoint glPoint + */ + convertToUI(glPoint: Vec2): Vec2; + /** + !#en + Returns the size of the WebGL view in points.
+ It takes into account any possible rotation (device orientation) of the window. + !#zh 获取视图的大小,以点为单位。 + */ + getWinSize(): Size; + /** + !#en + Returns the size of the OpenGL view in pixels.
+ It takes into account any possible rotation (device orientation) of the window.
+ On Mac winSize and winSizeInPixels return the same value. + (The pixel here refers to the resource resolution. If you want to get the physics resolution of device, you need to use cc.view.getFrameSize()) + !#zh + 获取视图大小,以像素为单位(这里的像素指的是资源分辨率。 + 如果要获取屏幕物理分辨率,需要用 cc.view.getFrameSize()) + */ + getWinSizeInPixels(): Size; + /** + !#en Returns the visible size of the running scene. + !#zh 获取运行场景的可见大小。 + */ + getVisibleSize(): Size; + /** + !#en Returns the visible origin of the running scene. + !#zh 获取视图在游戏内容中的坐标原点。 + */ + getVisibleOrigin(): Vec2; + /** + !#en Pause the director's ticker, only involve the game logic execution. + It won't pause the rendering process nor the event manager. + If you want to pause the entier game including rendering, audio and event, + please use {{#crossLink "Game.pause"}}cc.game.pause{{/crossLink}} + !#zh 暂停正在运行的场景,该暂停只会停止游戏逻辑执行,但是不会停止渲染和 UI 响应。 + 如果想要更彻底得暂停游戏,包含渲染,音频和事件,请使用 {{#crossLink "Game.pause"}}cc.game.pause{{/crossLink}}。 + */ + pause(): void; + /** + !#en + Run a scene. Replaces the running scene with a new one or enter the first scene.
+ The new scene will be launched immediately. + !#zh 立刻切换指定场景。 + @param scene The need run scene. + @param onBeforeLoadScene The function invoked at the scene before loading. + @param onLaunched The function invoked at the scene after launch. + */ + runSceneImmediate(scene: Scene, onBeforeLoadScene?: Function, onLaunched?: Function): void; + /** + !#en Loads the scene by its name. + !#zh 通过场景名称进行加载场景。 + @param sceneName The name of the scene to load. + @param onLaunched callback, will be called after scene launched. + */ + loadScene(sceneName: string, onLaunched?: Function): boolean; + /** + !#en + Preloads the scene to reduces loading time. You can call this method at any time you want. + After calling this method, you still need to launch the scene by `cc.director.loadScene`. + It will be totally fine to call `cc.director.loadScene` at any time even if the preloading is not + yet finished, the scene will be launched after loaded automatically. + !#zh 预加载场景,你可以在任何时候调用这个方法。 + 调用完后,你仍然需要通过 `cc.director.loadScene` 来启动场景,因为这个方法不会执行场景加载操作。 + 就算预加载还没完成,你也可以直接调用 `cc.director.loadScene`,加载完成后场景就会启动。 + @param sceneName The name of the scene to preload. + @param onLoaded callback, will be called after scene loaded. + */ + preloadScene(sceneName: string, onLoaded?: (error: Error) => void): void; + /** + !#en Resume game logic execution after pause, if the current scene is not paused, nothing will happen. + !#zh 恢复暂停场景的游戏逻辑,如果当前场景没有暂停将没任何事情发生。 + */ + resume(): void; + /** + !#en + Enables or disables WebGL depth test.
+ Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js + !#zh 启用/禁用深度测试(在 Canvas 渲染模式下不会生效)。 + @param on on + */ + setDepthTest(on: boolean): void; + /** + !#en + Set color for clear screen.
+ (Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js) + !#zh + 设置场景的默认擦除颜色。
+ 支持全透明,但不支持透明度为中间值。要支持全透明需手工开启 cc.macro.ENABLE_TRANSPARENT_CANVAS。 + @param clearColor clearColor + */ + setClearColor(clearColor: Color): void; + /** + !#en + Sets an OpenGL projection.
+ Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js. + !#zh 设置 OpenGL 投影。 + @param projection projection + */ + setProjection(projection: number): void; + /** + !#en + Update the view port.
+ Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js. + !#zh 设置视窗(请不要主动调用这个接口,除非你知道你在做什么)。 + */ + setViewport(): void; + /** + !#en + Sets an OpenGL projection.
+ Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js. + !#zh 获取 OpenGL 投影。 + */ + getProjection(): number; + /** + !#en + Enables/disables OpenGL alpha blending.
+ Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js. + !#zh 启用/禁用 透明度融合。 + @param on on + */ + setAlphaBlending(on: boolean): void; + /** + !#en + Returns whether or not the replaced scene will receive the cleanup message.
+ If the new scene is pushed, then the old scene won't receive the "cleanup" message.
+ If the new scene replaces the old one, the it will receive the "cleanup" message. + !#zh + 更换场景时是否接收清理消息。
+ 如果新场景是采用 push 方式进入的,那么旧的场景将不会接收到 “cleanup” 消息。
+ 如果新场景取代旧的场景,它将会接收到 “cleanup” 消息。
+ */ + isSendCleanupToScene(): boolean; + /** + !#en Returns current logic Scene. + !#zh 获取当前逻辑场景。 + + @example + ```js + // This will help you to get the Canvas node in scene + cc.director.getScene().getChildByName('Canvas'); + ``` + */ + getScene(): Scene; + /** + !#en Returns the FPS value. + !#zh 获取单位帧执行时间。 + */ + getAnimationInterval(): number; + /** + !#en Returns whether or not to display the FPS informations. + !#zh 获取是否显示 FPS 信息。 + */ + isDisplayStats(): boolean; + /** + !#en Sets whether display the FPS on the bottom-left corner. + !#zh 设置是否在左下角显示 FPS。 + @param displayStats displayStats + */ + setDisplayStats(displayStats: boolean): void; + /** + !#en Returns whether next delta time equals to zero. + !#zh 返回下一个 “delta time” 是否等于零。 + */ + isNextDeltaTimeZero(): boolean; + /** + !#en Returns whether or not the Director is paused. + !#zh 是否处于暂停状态。 + */ + isPaused(): boolean; + /** + !#en Returns how many frames were called since the director started. + !#zh 获取 director 启动以来游戏运行的总帧数。 + */ + getTotalFrames(): number; + /** + !#en Returns the cc.Scheduler associated with this director. + !#zh 获取和 director 相关联的 cc.Scheduler。 + */ + getScheduler(): Scheduler; + /** + !#en Sets the cc.Scheduler associated with this director. + !#zh 设置和 director 相关联的 cc.Scheduler。 + @param scheduler scheduler + */ + setScheduler(scheduler: Scheduler): void; + /** + !#en Returns the cc.ActionManager associated with this director. + !#zh 获取和 director 相关联的 cc.ActionManager(动作管理器)。 + */ + getActionManager(): ActionManager; + /** + !#en Sets the cc.ActionManager associated with this director. + !#zh 设置和 director 相关联的 cc.ActionManager(动作管理器)。 + @param actionManager actionManager + */ + setActionManager(actionManager: ActionManager): void; + /** + Returns the cc.CollisionManager associated with this director. + */ + getCollisionManager(): CollisionManager; + /** + Returns the cc.PhysicsManager associated with this director. + */ + getPhysicsManager(): PhysicsManager; + /** + !#en Returns the delta time since last frame. + !#zh 获取上一帧的 “delta time”。 + */ + getDeltaTime(): number; + /** !#en The event projection changed of cc.Director. + !#zh cc.Director 投影变化的事件。 */ + static EVENT_PROJECTION_CHANGED: string; + /** !#en The event which will be triggered before loading a new scene. + !#zh 加载新场景之前所触发的事件。 */ + static EVENT_BEFORE_SCENE_LOADING: string; + /** !#en The event which will be triggered before launching a new scene. + !#zh 运行新场景之前所触发的事件。 */ + static EVENT_BEFORE_SCENE_LAUNCH: string; + /** !#en The event which will be triggered after launching a new scene. + !#zh 运行新场景之后所触发的事件。 */ + static EVENT_AFTER_SCENE_LAUNCH: string; + /** !#en The event which will be triggered at the beginning of every frame. + !#zh 每个帧的开始时所触发的事件。 */ + static EVENT_BEFORE_UPDATE: string; + /** !#en The event which will be triggered after engine and components update logic. + !#zh 将在引擎和组件 “update” 逻辑之后所触发的事件。 */ + static EVENT_AFTER_UPDATE: string; + /** !#en The event which will be triggered before visiting the rendering scene graph. + !#zh 访问渲染场景树之前所触发的事件。 */ + static EVENT_BEFORE_VISIT: string; + /** !#en + The event which will be triggered after visiting the rendering scene graph, + the render queue is ready but not rendered at this point. + !#zh + 访问渲染场景图之后所触发的事件,渲染队列已准备就绪,但在这一时刻还没有呈现在画布上。 */ + static EVENT_AFTER_VISIT: string; + /** !#en The event which will be triggered after the rendering process. + !#zh 渲染过程之后所触发的事件。 */ + static EVENT_AFTER_DRAW: string; + /** Constant for 2D projection (orthogonal projection) */ + static PROJECTION_2D: number; + /** Constant for 3D projection with a fovy=60, znear=0.5f and zfar=1500. */ + static PROJECTION_3D: number; + /** Constant for custom projection, if cc.Director's projection set to it, it calls "updateProjection" on the projection delegate. */ + static PROJECTION_CUSTOM: number; + /** Constant for default projection of cc.Director, default projection is 2D projection */ + static PROJECTION_DEFAULT: number; + } + /** !#en cc.game is the singleton object for game related functions. + !#zh cc.game 是 Game 的实例,用来驱动整个游戏。 */ + export class Game extends EventTarget { + /** !#en Event triggered when game hide to background. + Please note that this event is not 100% guaranteed to be fired on Web platform, + on native platforms, it corresponds to enter background event, os status bar or notification center may not trigger this event. + !#zh 游戏进入后台时触发的事件。 + 请注意,在 WEB 平台,这个事件不一定会 100% 触发,这完全取决于浏览器的回调行为。 + 在原生平台,它对应的是应用被切换到后台事件,下拉菜单和上拉状态栏等不一定会触发这个事件,这取决于系统行为。 */ + EVENT_HIDE: string; + /** Event triggered when game back to foreground + Please note that this event is not 100% guaranteed to be fired on Web platform, + on native platforms, it corresponds to enter foreground event. + !#zh 游戏进入前台运行时触发的事件。 + 请注意,在 WEB 平台,这个事件不一定会 100% 触发,这完全取决于浏览器的回调行为。 + 在原生平台,它对应的是应用被切换到前台事件。 */ + EVENT_SHOW: string; + /** Event triggered after game inited, at this point all engine objects and game scripts are loaded */ + EVENT_GAME_INITED: string; + /** Event triggered after renderer inited, at this point you will be able to use the render context */ + EVENT_RENDERER_INITED: string; + /** Key of config */ + CONFIG_KEY: any; + /** !#en The outer frame of the game canvas, parent of cc.container. + !#zh 游戏画布的外框,cc.container 的父类。 */ + frame: any; + /** !#en The container of game canvas, equals to cc.container. + !#zh 游戏画布的容器。 */ + container: HTMLDivElement; + /** !#en The canvas of the game, equals to cc._canvas. + !#zh 游戏的画布。 */ + canvas: HTMLCanvasElement; + /** !#en + The current game configuration, including:
+ 1. debugMode
+ "debugMode" possible values :
+ 0 - No message will be printed.
+ 1 - cc.error, cc.assert, cc.warn, cc.log will print in console.
+ 2 - cc.error, cc.assert, cc.warn will print in console.
+ 3 - cc.error, cc.assert will print in console.
+ 4 - cc.error, cc.assert, cc.warn, cc.log will print on canvas, available only on web.
+ 5 - cc.error, cc.assert, cc.warn will print on canvas, available only on web.
+ 6 - cc.error, cc.assert will print on canvas, available only on web.
+ 2. showFPS
+ Left bottom corner fps information will show when "showFPS" equals true, otherwise it will be hide.
+ 3. exposeClassName
+ Expose class name to chrome debug tools, the class intantiate performance is a little bit slower when exposed.
+ 4. frameRate
+ "frameRate" set the wanted frame rate for your game, but the real fps depends on your game implementation and the running environment.
+ 5. id
+ "gameCanvas" sets the id of your canvas element on the web page, it's useful only on web.
+ 6. renderMode
+ "renderMode" sets the renderer type, only useful on web :
+ 0 - Automatically chosen by engine
+ 1 - Forced to use canvas renderer
+ 2 - Forced to use WebGL renderer, but this will be ignored on mobile browsers
+ 7. scenes
+ "scenes" include available scenes in the current bundle.
+
+ Please DO NOT modify this object directly, it won't have any effect.
+ !#zh + 当前的游戏配置,包括:
+ 1. debugMode(debug 模式,但是在浏览器中这个选项会被忽略)
+ "debugMode" 各种设置选项的意义。
+ 0 - 没有消息被打印出来。
+ 1 - cc.error,cc.assert,cc.warn,cc.log 将打印在 console 中。
+ 2 - cc.error,cc.assert,cc.warn 将打印在 console 中。
+ 3 - cc.error,cc.assert 将打印在 console 中。
+ 4 - cc.error,cc.assert,cc.warn,cc.log 将打印在 canvas 中(仅适用于 web 端)。
+ 5 - cc.error,cc.assert,cc.warn 将打印在 canvas 中(仅适用于 web 端)。
+ 6 - cc.error,cc.assert 将打印在 canvas 中(仅适用于 web 端)。
+ 2. showFPS(显示 FPS)
+ 当 showFPS 为 true 的时候界面的左下角将显示 fps 的信息,否则被隐藏。
+ 3. exposeClassName
+ 暴露类名让 Chrome DevTools 可以识别,如果开启会稍稍降低类的创建过程的性能,但对对象构造没有影响。
+ 4. frameRate (帧率)
+ “frameRate” 设置想要的帧率你的游戏,但真正的FPS取决于你的游戏实现和运行环境。
+ 5. id
+ "gameCanvas" Web 页面上的 Canvas Element ID,仅适用于 web 端。
+ 6. renderMode(渲染模式)
+ “renderMode” 设置渲染器类型,仅适用于 web 端:
+ 0 - 通过引擎自动选择。
+ 1 - 强制使用 canvas 渲染。 + 2 - 强制使用 WebGL 渲染,但是在部分 Android 浏览器中这个选项会被忽略。
+ 7. scenes
+ “scenes” 当前包中可用场景。
+
+ 注意:请不要直接修改这个对象,它不会有任何效果。 */ + config: any; + /** + !#en Callback when the scripts of engine have been load. + !#zh 当引擎完成启动后的回调函数。 + */ + onStart(): void; + /** + !#en Set frameRate of game. + !#zh 设置游戏帧率。 + @param frameRate frameRate + */ + setFrameRate(frameRate: number): void; + /** + !#en Run the game frame by frame. + !#zh 执行一帧游戏循环。 + */ + step(): void; + /** + !#en Pause the game main loop. This will pause: + game logic execution, rendering process, event manager, background music and all audio effects. + This is different with cc.director.pause which only pause the game logic execution. + !#zh 暂停游戏主循环。包含:游戏逻辑,渲染,事件处理,背景音乐和所有音效。这点和只暂停游戏逻辑的 cc.director.pause 不同。 + */ + pause(): void; + /** + !#en Resume the game from pause. This will resume: + game logic execution, rendering process, event manager, background music and all audio effects. + !#zh 恢复游戏主循环。包含:游戏逻辑,渲染,事件处理,背景音乐和所有音效。 + */ + resume(): void; + /** + !#en Check whether the game is paused. + !#zh 判断游戏是否暂停。 + */ + isPaused(): boolean; + /** + !#en Restart game. + !#zh 重新开始游戏 + */ + restart(): void; + /** + !#en End game, it will close the game window + !#zh 退出游戏 + */ + end(): void; + /** + !#en Prepare game. + !#zh 准备引擎,请不要直接调用这个函数。 + @param cb cb + */ + prepare(cb: Function): void; + /** + !#en Run game with configuration object and onStart function. + !#zh 运行游戏,并且指定引擎配置和 onStart 的回调。 + @param config Pass configuration object or onStart function + @param onStart function to be executed after game initialized + */ + run(config?: any|Function, onStart?: Function): void; + /** + !#en + Add a persistent root node to the game, the persistent node won't be destroyed during scene transition.
+ The target node must be placed in the root level of hierarchy, otherwise this API won't have any effect. + !#zh + 声明常驻根节点,该节点不会被在场景切换中被销毁。
+ 目标节点必须位于为层级的根节点,否则无效。 + @param node The node to be made persistent + */ + addPersistRootNode(node: Node): void; + /** + !#en Remove a persistent root node. + !#zh 取消常驻根节点。 + @param node The node to be removed from persistent node list + */ + removePersistRootNode(node: Node): void; + /** + !#en Check whether the node is a persistent root node. + !#zh 检查节点是否是常驻根节点。 + @param node The node to be checked + */ + isPersistRootNode(node: Node): boolean; + } + /** !#en + Class of all entities in Cocos Creator scenes.
+ Node also inherits from {{#crossLink "EventTarget"}}Event Target{{/crossLink}}, it permits Node to dispatch events. + For events supported by Node, please refer to {{#crossLink "Node.EventType"}}{{/crossLink}} + !#zh + Cocos Creator 场景中的所有节点类。节点也继承了 {{#crossLink "EventTarget"}}EventTarget{{/crossLink}},它允许节点发送事件。
+ 支持的节点事件,请参阅 {{#crossLink "Node.EventType"}}{{/crossLink}}。 */ + export class Node extends _BaseNode { + /** !#en + Group index of node.
+ Which Group this node belongs to will resolve that this node's collision components can collide with which other collision componentns.
+ !#zh + 节点的分组索引。
+ 节点的分组将关系到节点的碰撞组件可以与哪些碰撞组件相碰撞。
*/ + groupIndex: number; + /** !#en + Group of node.
+ Which Group this node belongs to will resolve that this node's collision components can collide with which other collision componentns.
+ !#zh + 节点的分组。
+ 节点的分组将关系到节点的碰撞组件可以与哪些碰撞组件相碰撞。
*/ + group: string; + /** !#en The position (x, y) of the node in its parent's coordinates. + !#zh 节点在父节点坐标系中的位置(x, y)。 */ + position: Vec2; + /** !#en x axis position of node. + !#zh 节点 X 轴坐标。 */ + x: number; + /** !#en y axis position of node. + !#zh 节点 Y 轴坐标。 */ + y: number; + /** !#en Rotation of node. + !#zh 该节点旋转角度。 */ + rotation: number; + /** !#en Rotation on x axis. + !#zh 该节点 X 轴旋转角度。 */ + rotationX: number; + /** !#en Rotation on y axis. + !#zh 该节点 Y 轴旋转角度。 */ + rotationY: number; + /** !#en Scale on x axis. + !#zh 节点 X 轴缩放。 */ + scaleX: number; + /** !#en Scale on y axis. + !#zh 节点 Y 轴缩放。 */ + scaleY: number; + /** !#en Skew x + !#zh 该节点 Y 轴倾斜角度。 */ + skewX: number; + /** !#en Skew y + !#zh 该节点 X 轴倾斜角度。 */ + skewY: number; + /** !#en Opacity of node, default value is 255. + !#zh 节点透明度,默认值为 255。 */ + opacity: number; + /** !#en Indicate whether node's opacity value affect its child nodes, default value is true. + !#zh 节点的不透明度值是否影响其子节点,默认值为 true。 */ + cascadeOpacity: boolean; + /** !#en Color of node, default value is white: (255, 255, 255). + !#zh 节点颜色。默认为白色,数值为:(255,255,255)。 */ + color: Color; + /** !#en Anchor point's position on x axis. + !#zh 节点 X 轴锚点位置。 */ + anchorX: number; + /** !#en Anchor point's position on y axis. + !#zh 节点 Y 轴锚点位置。 */ + anchorY: number; + /** !#en Width of node. + !#zh 节点宽度。 */ + width: number; + /** !#en Height of node. + !#zh 节点高度。 */ + height: number; + /** !#en Z order in depth which stands for the drawing order. + !#zh 该节点渲染排序的 Z 轴深度。 */ + zIndex: number; + /** + + @param name name + */ + constructor(name?: string); + /** + !#en + Register a callback of a specific event type on Node.
+ Use this method to register touch or mouse event permit propagation based on scene graph, + you can propagate the event to the parents or swallow it by calling stopPropagation on the event.
+ It's the recommended way to register touch/mouse event for Node, + please do not use cc.eventManager directly for Node. + !#zh + 在节点上注册指定类型的回调函数,也可以设置 target 用于绑定响应函数的 this 对象。
+ 同时您可以将事件派发到父节点或者通过调用 stopPropagation 拦截它。
+ 推荐使用这种方式来监听节点上的触摸或鼠标事件,请不要在节点上直接使用 cc.eventManager。 + @param type A string representing the event type to listen for.
+ See {{#crossLink "Node/position-changed:event"}}Node Events{{/crossLink}} for all builtin events. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + @param useCapture When set to true, the capture argument prevents callback + from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. + When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE. + Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET. + + @example + ```js + this.node.on(cc.Node.EventType.TOUCH_START, this.memberFunction, this); // if "this" is component and the "memberFunction" declared in CCClass. + node.on(cc.Node.EventType.TOUCH_START, callback, this.node); + node.on(cc.Node.EventType.TOUCH_MOVE, callback, this.node); + node.on(cc.Node.EventType.TOUCH_END, callback, this.node); + node.on(cc.Node.EventType.TOUCH_CANCEL, callback, this.node); + node.on("anchor-changed", callback, this); + ``` + */ + on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void; + on(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void; + /** + !#en + Removes the callback previously registered with the same type, callback, target and or useCapture. + This method is merely an alias to removeEventListener. + !#zh 删除之前与同类型,回调,目标或 useCapture 注册的回调。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not. + If not specified, useCapture defaults to false. If a callback was registered twice, + one with capture and one without, each must be removed separately. Removal of a capturing callback + does not affect a non-capturing version of the same listener, and vice versa. + + @example + ```js + this.node.off(cc.Node.EventType.TOUCH_START, this.memberFunction, this); + node.off(cc.Node.EventType.TOUCH_START, callback, this.node); + node.off("anchor-changed", callback, this); + ``` + */ + off(type: string, callback: Function, target?: any, useCapture?: boolean): void; + /** + !#en Removes all callbacks previously registered with the same target. + !#zh 移除目标上的所有注册事件。 + @param target The target to be searched for all related callbacks + + @example + ```js + node.targetOff(target); + ``` + */ + targetOff(target: any): void; + /** + !#en Pause node related system events registered with the current Node. Node system events includes touch and mouse events. + If recursive is set to true, then this API will pause the node system events for the node and all nodes in its sub node tree. + Reference: http://cocos2d-x.org/docs/editors_and_tools/creator-chapters/scripting/internal-events/ + !#zh 暂停当前节点上注册的所有节点系统事件,节点系统事件包含触摸和鼠标事件。 + 如果传递 recursive 为 true,那么这个 API 将暂停本节点和它的子树上所有节点的节点系统事件。 + 参考:http://cocos.com/docs/creator/scripting/internal-events.html + @param recursive Whether to pause node system events on the sub node tree. + + @example + ```js + node.pauseSystemEvents(true); + ``` + */ + pauseSystemEvents(recursive: boolean): void; + /** + !#en Resume node related system events registered with the current Node. Node system events includes touch and mouse events. + If recursive is set to true, then this API will resume the node system events for the node and all nodes in its sub node tree. + Reference: http://cocos2d-x.org/docs/editors_and_tools/creator-chapters/scripting/internal-events/ + !#zh 恢复当前节点上注册的所有节点系统事件,节点系统事件包含触摸和鼠标事件。 + 如果传递 recursive 为 true,那么这个 API 将恢复本节点和它的子树上所有节点的节点系统事件。 + 参考:http://cocos.com/docs/creator/scripting/internal-events.html + @param recursive Whether to resume node system events on the sub node tree. + + @example + ```js + node.resumeSystemEvents(true); + ``` + */ + resumeSystemEvents(recursive: boolean): void; + /** + !#en + Executes an action, and returns the action that is executed.
+ The node becomes the action's target. Refer to cc.Action's getTarget()
+ Calling runAction while the node is not active won't have any effect.
+ Note:You shouldn't modify the action after runAction, that won't take any effect.
+ if you want to modify, when you define action plus. + !#zh + 执行并返回该执行的动作。该节点将会变成动作的目标。
+ 调用 runAction 时,节点自身处于不激活状态将不会有任何效果。
+ 注意:你不应该修改 runAction 后的动作,将无法发挥作用,如果想进行修改,请在定义 action 时加入。 + @param action action + + @example + ```js + var action = cc.scaleTo(0.2, 1, 0.6); + node.runAction(action); + node.runAction(action).repeatForever(); // fail + node.runAction(action.repeatForever()); // right + ``` + */ + runAction(action: Action): Action; + /** + !#en Pause all actions running on the current node. Equals to `cc.director.getActionManager().pauseTarget(node)`. + !#zh 暂停本节点上所有正在运行的动作。和 `cc.director.getActionManager().pauseTarget(node);` 等价。 + + @example + ```js + node.pauseAllActions(); + ``` + */ + pauseAllActions(): void; + /** + !#en Resume all paused actions on the current node. Equals to `cc.director.getActionManager().resumeTarget(node)`. + !#zh 恢复运行本节点上所有暂停的动作。和 `cc.director.getActionManager().resumeTarget(node);` 等价。 + + @example + ```js + node.resumeAllActions(); + ``` + */ + resumeAllActions(): void; + /** + !#en Stops and removes all actions from the running action list . + !#zh 停止并且移除所有正在运行的动作列表。 + + @example + ```js + node.stopAllActions(); + ``` + */ + stopAllActions(): void; + /** + !#en Stops and removes an action from the running action list. + !#zh 停止并移除指定的动作。 + @param action An action object to be removed. + + @example + ```js + var action = cc.scaleTo(0.2, 1, 0.6); + node.stopAction(action); + ``` + */ + stopAction(action: Action): void; + /** + !#en Removes an action from the running action list by its tag. + !#zh 停止并且移除指定标签的动作。 + @param tag A tag that indicates the action to be removed. + + @example + ```js + node.stopAction(1); + ``` + */ + stopActionByTag(tag: number): void; + /** + !#en Returns an action from the running action list by its tag. + !#zh 通过标签获取指定动作。 + @param tag tag + + @example + ```js + var action = node.getActionByTag(1); + ``` + */ + getActionByTag(tag: number): Action; + /** + !#en + Returns the numbers of actions that are running plus the ones that are schedule to run (actions in actionsToAdd and actions arrays).
+ Composable actions are counted as 1 action. Example:
+ If you are running 1 Sequence of 7 actions, it will return 1.
+ If you are running 7 Sequences of 2 actions, it will return 7.

+ !#zh + 获取运行着的动作加上正在调度运行的动作的总数。
+ 例如:
+ - 如果你正在运行 7 个动作中的 1 个 Sequence,它将返回 1。
+ - 如果你正在运行 2 个动作中的 7 个 Sequence,它将返回 7。
+ + @example + ```js + var count = node.getNumberOfRunningActions(); + cc.log("Running Action Count: " + count); + ``` + */ + getNumberOfRunningActions(): number; + /** + !#en Returns a copy of the position (x, y) of the node in its parent's coordinates. + !#zh 获取节点在父节点坐标系中的位置(x, y)。 + + @example + ```js + cc.log("Node Position: " + node.getPosition()); + ``` + */ + getPosition(): Vec2; + /** + !#en + Sets the position (x, y) of the node in its parent's coordinates.
+ Usually we use cc.v2(x, y) to compose cc.Vec2 object.
+ and Passing two numbers (x, y) is more efficient than passing cc.Vec2 object. + !#zh + 设置节点在父节点坐标系中的位置。
+ 可以通过两种方式设置坐标点:
+ 1. 传入 2 个数值 x 和 y。
+ 2. 传入 cc.v2(x, y) 类型为 cc.Vec2 的对象。 + @param newPosOrX X coordinate for position or the position (x, y) of the node in coordinates + @param y Y coordinate for position + + @example + ```js + node.setPosition(cc.v2(0, 0)); + node.setPosition(0, 0); + + ``` + */ + setPosition(newPosOrX: Vec2|number, y?: number): void; + /** + !#en + Returns the scale factor of the node. + Assertion will fail when _scaleX != _scaleY. + !#zh 获取节点的缩放。当 X 轴和 Y 轴有相同的缩放数值时。 + + @example + ```js + cc.log("Node Scale: " + node.getScale()); + ``` + */ + getScale(): number; + /** + !#en Sets the scale factor of the node. 1.0 is the default scale factor. This function can modify the X and Y scale at the same time. + !#zh 设置节点的缩放比例,默认值为 1.0。这个函数可以在同一时间修改 X 和 Y 缩放。 + @param scaleX scaleX or scale + @param scaleY scaleY + + @example + ```js + node.setScale(cc.v2(1, 1)); + node.setScale(1, 1); + ``` + */ + setScale(scaleX: number|Vec2, scaleY?: number): void; + /** + !#en + Returns a copy the untransformed size of the node.
+ The contentSize remains the same no matter the node is scaled or rotated.
+ All nodes has a size. Layer and Scene has the same size of the screen by default.
+ !#zh 获取节点自身大小,不受该节点是否被缩放或者旋转的影响。 + @param ignoreSizeProvider true if you need to get the original size of the node + + @example + ```js + cc.log("Content Size: " + node.getContentSize()); + ``` + */ + getContentSize(ignoreSizeProvider?: boolean): Size; + /** + !#en + Sets the untransformed size of the node.
+ The contentSize remains the same no matter the node is scaled or rotated.
+ All nodes has a size. Layer and Scene has the same size of the screen. + !#zh 设置节点原始大小,不受该节点是否被缩放或者旋转的影响。 + @param size The untransformed size of the node or The untransformed size's width of the node. + @param height The untransformed size's height of the node. + + @example + ```js + node.setContentSize(cc.size(100, 100)); + node.setContentSize(100, 100); + ``` + */ + setContentSize(size: Size|number, height?: number): void; + /** + !#en + Set whether color should be changed with the opacity value, + useless in ccsg.Node, but this function is override in some class to have such behavior. + !#zh 设置更改透明度时是否修改RGB值, + @param opacityValue opacityValue + + @example + ```js + node.setOpacityModifyRGB(true); + ``` + */ + setOpacityModifyRGB(opacityValue: boolean): void; + /** + !#en Get whether color should be changed with the opacity value. + !#zh 更改透明度时是否修改RGB值。 + + @example + ```js + var hasChange = node.isOpacityModifyRGB(); + ``` + */ + isOpacityModifyRGB(): boolean; + /** + !#en + Returns a copy of the anchor point.
+ Anchor point is the point around which all transformations and positioning manipulations take place.
+ It's like a pin in the node where it is "attached" to its parent.
+ The anchorPoint is normalized, like a percentage. (0,0) means the bottom-left corner and (1,1) means the top-right corner.
+ But you can use values higher than (1,1) and lower than (0,0) too.
+ The default anchor point is (0.5,0.5), so it starts at the center of the node. + !#zh + 获取节点锚点,用百分比表示。
+ 锚点应用于所有变换和坐标点的操作,它就像在节点上连接其父节点的大头针。
+ 锚点是标准化的,就像百分比一样。(0,0) 表示左下角,(1,1) 表示右上角。
+ 但是你可以使用比(1,1)更高的值或者比(0,0)更低的值。
+ 默认的锚点是(0.5,0.5),因此它开始于节点的中心位置。
+ 注意:Creator 中的锚点仅用于定位所在的节点,子节点的定位不受影响。 + + @example + ```js + cc.log("Node AnchorPoint: " + node.getAnchorPoint()); + ``` + */ + getAnchorPoint(): Vec2; + /** + !#en + Sets the anchor point in percent.
+ anchor point is the point around which all transformations and positioning manipulations take place.
+ It's like a pin in the node where it is "attached" to its parent.
+ The anchorPoint is normalized, like a percentage. (0,0) means the bottom-left corner and (1,1) means the top-right corner.
+ But you can use values higher than (1,1) and lower than (0,0) too.
+ The default anchor point is (0.5,0.5), so it starts at the center of the node. + !#zh + 设置锚点的百分比。
+ 锚点应用于所有变换和坐标点的操作,它就像在节点上连接其父节点的大头针。
+ 锚点是标准化的,就像百分比一样。(0,0) 表示左下角,(1,1) 表示右上角。
+ 但是你可以使用比(1,1)更高的值或者比(0,0)更低的值。
+ 默认的锚点是(0.5,0.5),因此它开始于节点的中心位置。
+ 注意:Creator 中的锚点仅用于定位所在的节点,子节点的定位不受影响。 + @param point The anchor point of node or The x axis anchor of node. + @param y The y axis anchor of node. + + @example + ```js + node.setAnchorPoint(cc.v2(1, 1)); + node.setAnchorPoint(1, 1); + ``` + */ + setAnchorPoint(point: Vec2|number, y?: number): void; + /** + !#en + Returns a copy of the anchor point in absolute pixels.
+ you can only read it. If you wish to modify it, use setAnchorPoint. + !#zh + 返回锚点的绝对像素位置。
+ 你只能读它。如果您要修改它,使用 setAnchorPoint。 + + @example + ```js + cc.log("AnchorPointInPoints: " + node.getAnchorPointInPoints()); + ``` + */ + getAnchorPointInPoints(): Vec2; + /** + !#en + Returns the displayed opacity of Node, + the difference between displayed opacity and opacity is that displayed opacity is calculated based on opacity and parent node's opacity when cascade opacity enabled. + !#zh + 获取节点显示透明度, + 显示透明度和透明度之间的不同之处在于当启用级连透明度时, + 显示透明度是基于自身透明度和父节点透明度计算的。 + + @example + ```js + var displayOpacity = node.getDisplayedOpacity(); + ``` + */ + getDisplayedOpacity(): number; + /** + !#en + Returns the displayed color of Node, + the difference between displayed color and color is that displayed color is calculated based on color and parent node's color when cascade color enabled. + !#zh + 获取节点的显示颜色, + 显示颜色和颜色之间的不同之处在于当启用级连颜色时, + 显示颜色是基于自身颜色和父节点颜色计算的。 + + @example + ```js + var displayColor = node.getDisplayedColor(); + ``` + */ + getDisplayedColor(): Color; + /** + !#en + Returns the matrix that transform the node's (local) space coordinates into the parent's space coordinates.
+ The matrix is in Pixels.
+ This method is AR (Anchor Relative). + !#zh + 返回这个将节点(局部)的空间坐标系转换成父节点的空间坐标系的矩阵。
+ 这个矩阵以像素为单位。
+ 该方法基于节点坐标。 + + @example + ```js + var affineTransform = node.getNodeToParentTransformAR(); + ``` + */ + getNodeToParentTransformAR(): AffineTransform; + /** + !#en + Returns a "local" axis aligned bounding box of the node.
+ The returned box is relative only to its parent. + !#zh 返回父节坐标系下的轴向对齐的包围盒。 + + @example + ```js + var boundingBox = node.getBoundingBox(); + ``` + */ + getBoundingBox(): Rect; + /** + !#en + Returns a "world" axis aligned bounding box of the node.
+ The bounding box contains self and active children's world bounding box. + !#zh + 返回节点在世界坐标系下的对齐轴向的包围盒(AABB)。
+ 该边框包含自身和已激活的子节点的世界边框。 + + @example + ```js + var newRect = node.getBoundingBoxToWorld(); + ``` + */ + getBoundingBoxToWorld(): Rect; + /** + !#en + Returns the matrix that transform the node's (local) space coordinates into the parent's space coordinates.
+ The matrix is in Pixels. + !#zh 返回这个将节点(局部)的空间坐标系转换成父节点的空间坐标系的矩阵。这个矩阵以像素为单位。 + + @example + ```js + var affineTransform = node.getNodeToParentTransform(); + ``` + */ + getNodeToParentTransform(): AffineTransform; + /** + !#en Returns the world affine transform matrix. The matrix is in Pixels. + !#zh 返回节点到世界坐标系的仿射变换矩阵。矩阵单位是像素。 + + @example + ```js + var affineTransform = node.getNodeToWorldTransform(); + ``` + */ + getNodeToWorldTransform(): AffineTransform; + /** + !#en + Returns the world affine transform matrix. The matrix is in Pixels.
+ This method is AR (Anchor Relative). + !#zh + 返回节点到世界坐标仿射变换矩阵。矩阵单位是像素。
+ 该方法基于节点坐标。 + + @example + ```js + var mat = node.getNodeToWorldTransformAR(); + ``` + */ + getNodeToWorldTransformAR(): AffineTransform; + /** + !#en + Returns the matrix that transform parent's space coordinates to the node's (local) space coordinates.
+ The matrix is in Pixels. The returned transform is readonly and cannot be changed. + !#zh + 返回将父节点的坐标系转换成节点(局部)的空间坐标系的矩阵。
+ 该矩阵以像素为单位。返回的矩阵是只读的,不能更改。 + + @example + ```js + var affineTransform = node.getParentToNodeTransform(); + ``` + */ + getParentToNodeTransform(): AffineTransform; + /** + !#en Returns the inverse world affine transform matrix. The matrix is in Pixels. + !#en 返回世界坐标系到节点坐标系的逆矩阵。 + + @example + ```js + var affineTransform = node.getWorldToNodeTransform(); + ``` + */ + getWorldToNodeTransform(): AffineTransform; + /** + !#en Converts a Point to node (local) space coordinates. The result is in Vec2. + !#zh 将一个点转换到节点 (局部) 坐标系。结果以 Vec2 为单位。 + @param worldPoint worldPoint + + @example + ```js + var newVec2 = node.convertToNodeSpace(cc.v2(100, 100)); + ``` + */ + convertToNodeSpace(worldPoint: Vec2): Vec2; + /** + !#en Converts a Point to world space coordinates. The result is in Points. + !#zh 将一个点转换到世界空间坐标系。结果以 Vec2 为单位。 + @param nodePoint nodePoint + + @example + ```js + var newVec2 = node.convertToWorldSpace(cc.v2(100, 100)); + ``` + */ + convertToWorldSpace(nodePoint: Vec2): Vec2; + /** + !#en + Converts a Point to node (local) space coordinates. The result is in Points.
+ treating the returned/received node point as anchor relative. + !#zh + 将一个点转换到节点 (局部) 空间坐标系。结果以 Vec2 为单位。
+ 返回值将基于节点坐标。 + @param worldPoint worldPoint + + @example + ```js + var newVec2 = node.convertToNodeSpaceAR(cc.v2(100, 100)); + ``` + */ + convertToNodeSpaceAR(worldPoint: Vec2): Vec2; + /** + !#en + Converts a local Point to world space coordinates.The result is in Points.
+ treating the returned/received node point as anchor relative. + !#zh + 将一个点转换到世界空间坐标系。结果以 Vec2 为单位。
+ 返回值将基于世界坐标。 + @param nodePoint nodePoint + + @example + ```js + var newVec2 = node.convertToWorldSpaceAR(cc.v2(100, 100)); + ``` + */ + convertToWorldSpaceAR(nodePoint: Vec2): Vec2; + /** + !#en convenience methods which take a cc.Touch instead of cc.Vec2. + !#zh 将触摸点转换成本地坐标系中位置。 + @param touch The touch object + + @example + ```js + var newVec2 = node.convertTouchToNodeSpace(touch); + ``` + */ + convertTouchToNodeSpace(touch: Touch): Vec2; + /** + !#en converts a cc.Touch (world coordinates) into a local coordinate. This method is AR (Anchor Relative). + !#zh 转换一个 cc.Touch(世界坐标)到一个局部坐标,该方法基于节点坐标。 + @param touch The touch object + + @example + ```js + var newVec2 = node.convertTouchToNodeSpaceAR(touch); + ``` + */ + convertTouchToNodeSpaceAR(touch: Touch): Vec2; + /** + !#en + Adds a child to the node with z order and tag. + !#zh + 添加子节点,并且可以修改该节点的 局部 Z 顺序和标签。 + @param child A child node + @param localZOrder Z order for drawing priority. Please refer to setZOrder(int) + @param tag An integer or a name to identify the node easily. Please refer to setTag(int) and setName(string) + + @example + ```js + node.addChild(newNode, 1, 1001); + ``` + */ + addChild(child: Node, localZOrder?: number, tag?: number|string): void; + /** + !#en Stops all running actions and schedulers. + !#zh 停止所有正在播放的动作和计时器。 + + @example + ```js + node.cleanup(); + ``` + */ + cleanup(): void; + /** + !#en Sorts the children array depends on children's zIndex and arrivalOrder, + normally you won't need to invoke this function. + !#zh 根据子节点的 zIndex 和 arrivalOrder 进行排序,正常情况下开发者不需要手动调用这个函数。 + */ + sortAllChildren(): void; + /** !#en The local scale relative to the parent. + !#zh 节点相对父节点的缩放。 */ + scale: number; + /** + !#en Returns the x axis position of the node in cocos2d coordinates. + !#zh 获取节点 X 轴坐标。 + + @example + ```js + var posX = node.getPositionX(); + ``` + */ + getPositionX(): number; + /** + !#en Sets the x axis position of the node in cocos2d coordinates. + !#zh 设置节点 X 轴坐标。 + @param x x + + @example + ```js + node.setPositionX(1); + ``` + */ + setPositionX(x: number): void; + /** + !#en Returns the y axis position of the node in cocos2d coordinates. + !#zh 获取节点 Y 轴坐标。 + + @example + ```js + var posY = node.getPositionY(); + ``` + */ + getPositionY(): number; + /** + !#en Sets the y axis position of the node in cocos2d coordinates. + !#zh 设置节点 Y 轴坐标。 + @param y The new position in y axis + + @example + ```js + node.setPositionY(100); + ``` + */ + setPositionY(y: number): void; + /** + !#en Returns the local Z order of this node. + !#zh 获取节点局部 Z 轴顺序。 + + @example + ```js + var localZorder = node.getLocalZOrder(); + ``` + */ + getLocalZOrder(): number; + /** + !#en + LocalZOrder is the 'key' used to sort the node relative to its siblings.
+
+ The Node's parent will sort all its children based ont the LocalZOrder value.
+ If two nodes have the same LocalZOrder, then the node that was added first to the children's array
+ will be in front of the other node in the array.
+ Also, the Scene Graph is traversed using the "In-Order" tree traversal algorithm ( http://en.wikipedia.org/wiki/Tree_traversal#In-order )
+ And Nodes that have LocalZOder values smaller than 0 are the "left" subtree
+ While Nodes with LocalZOder greater than 0 are the "right" subtree. + !#zh + LocalZOrder 是 “key” (关键)来分辨节点和它兄弟节点的相关性。 + 父节点将会通过 LocalZOrder 的值来分辨所有的子节点。 + 如果两个节点有同样的 LocalZOrder,那么先加入子节点数组的节点将会显示在后加入的节点的前面。 + 同样的,场景图使用 “In-Order(按顺序)” 遍历数算法来遍历 + ( http://en.wikipedia.org/wiki/Tree_traversal#In-order ) 并且拥有小于 0 的 LocalZOrder 的值的节点是 “ left ” 子树(左子树) + 所以拥有大于 0 的 LocalZOrder 的值得节点是 “ right ”子树(右子树)。 + @param localZOrder localZOrder + + @example + ```js + node.setLocalZOrder(1); + ``` + */ + setLocalZOrder(localZOrder: number): void; + /** + !#en Returns whether node's opacity value affect its child nodes. + !#zh 返回节点的不透明度值是否影响其子节点。 + + @example + ```js + cc.log(node.isCascadeOpacityEnabled()); + ``` + */ + isCascadeOpacityEnabled(): boolean; + /** + !#en Enable or disable cascade opacity, if cascade enabled, child nodes' opacity will be the multiplication of parent opacity and its own opacity. + !#zh 启用或禁用级连不透明度,如果级连启用,子节点的不透明度将是父不透明度乘上它自己的不透明度。 + @param cascadeOpacityEnabled cascadeOpacityEnabled + + @example + ```js + node.setCascadeOpacityEnabled(true); + ``` + */ + setCascadeOpacityEnabled(cascadeOpacityEnabled: boolean): void; + } + /** !#en + cc.Scene is a subclass of cc.Node that is used only as an abstract concept.
+ cc.Scene and cc.Node are almost identical with the difference that users can not modify cc.Scene manually. + !#zh + cc.Scene 是 cc.Node 的子类,仅作为一个抽象的概念。
+ cc.Scene 和 cc.Node 有点不同,用户不应直接修改 cc.Scene。 */ + export class Scene extends Node { + /** !#en Indicates whether all (directly or indirectly) static referenced assets of this scene are releasable by default after scene unloading. + !#zh 指示该场景中直接或间接静态引用到的所有资源是否默认在场景切换后自动释放。 */ + autoReleaseAssets: boolean; + } + /** !#en + Scheduler is responsible of triggering the scheduled callbacks.
+ You should not use NSTimer. Instead use this class.
+
+ There are 2 different types of callbacks (selectors):
+ - update callback: the 'update' callback will be called every frame. You can customize the priority.
+ - custom callback: A custom callback will be called every frame, or with a custom interval of time
+
+ The 'custom selectors' should be avoided when possible. It is faster, + and consumes less memory to use the 'update callback'. * + !#zh + Scheduler 是负责触发回调函数的类。
+ 通常情况下,建议使用 cc.director.getScheduler() 来获取系统定时器。
+ 有两种不同类型的定时器:
+ - update 定时器:每一帧都会触发。您可以自定义优先级。
+ - 自定义定时器:自定义定时器可以每一帧或者自定义的时间间隔触发。
+ 如果希望每帧都触发,应该使用 update 定时器,使用 update 定时器更快,而且消耗更少的内存。 */ + export class Scheduler { + /** + !#en + Modifies the time of all scheduled callbacks.
+ You can use this property to create a 'slow motion' or 'fast forward' effect.
+ Default is 1.0. To create a 'slow motion' effect, use values below 1.0.
+ To create a 'fast forward' effect, use values higher than 1.0.
+ Note:It will affect EVERY scheduled selector / action. + !#zh + 设置时间间隔的缩放比例。
+ 您可以使用这个方法来创建一个 “slow motion(慢动作)” 或 “fast forward(快进)” 的效果。
+ 默认是 1.0。要创建一个 “slow motion(慢动作)” 效果,使用值低于 1.0。
+ 要使用 “fast forward(快进)” 效果,使用值大于 1.0。
+ 注意:它影响该 Scheduler 下管理的所有定时器。 + @param timeScale timeScale + */ + setTimeScale(timeScale: number): void; + /** + !#en Returns time scale of scheduler. + !#zh 获取时间间隔的缩放比例。 + */ + getTimeScale(): number; + /** + !#en 'update' the scheduler. (You should NEVER call this method, unless you know what you are doing.) + !#zh update 调度函数。(不应该直接调用这个方法,除非完全了解这么做的结果) + @param dt delta time + */ + update(dt: number): void; + /** + !#en +

+ The scheduled method will be called every 'interval' seconds.
+ If paused is YES, then it won't be called until it is resumed.
+ If 'interval' is 0, it will be called every frame, but if so, it recommended to use 'scheduleUpdateForTarget:' instead.
+ If the callback function is already scheduled, then only the interval parameter will be updated without re-scheduling it again.
+ repeat let the action be repeated repeat + 1 times, use cc.macro.REPEAT_FOREVER to let the action run continuously
+ delay is the amount of time the action will wait before it'll start
+

+ !#zh + 指定回调函数,调用对象等信息来添加一个新的定时器。
+ 当时间间隔达到指定值时,设置的回调函数将会被调用。
+ 如果 paused 值为 true,那么直到 resume 被调用才开始计时。
+ 如果 interval 值为 0,那么回调函数每一帧都会被调用,但如果是这样, + 建议使用 scheduleUpdateForTarget 代替。
+ 如果回调函数已经被定时器使用,那么只会更新之前定时器的时间间隔参数,不会设置新的定时器。
+ repeat 值可以让定时器触发 repeat + 1 次,使用 cc.macro.REPEAT_FOREVER + 可以让定时器一直循环触发。
+ delay 值指定延迟时间,定时器会在延迟指定的时间之后开始计时。 + @param target target + @param callback_fn callback_fn + @param interval interval + @param repeat repeat + @param delay delay + @param paused paused + + @example + ```js + //register a schedule to scheduler + var scheduler = cc.director.getScheduler(); + scheduler.scheduleCallbackForTarget(this, function, interval, repeat, delay, !this._isRunning); + + ``` + */ + scheduleCallbackForTarget(target: any, callback: Function, interval: number, repeat: number, delay: number, paused?: boolean): void; + scheduleCallbackForTarget(target: any, callback: Function, interval: number, paused?: boolean): void; + /** + !#en The schedule + !#zh 定时器 + @param callback callback + @param target target + @param interval interval + @param repeat repeat + @param delay delay + @param paused paused + + @example + ```js + //register a schedule to scheduler + cc.director.getScheduler().schedule(callback, this, interval, !this._isRunning); + + ``` + */ + schedule(callback: Function, target: any, interval: number, repeat: number, delay: number, paused?: boolean): void; + schedule(callback: Function, target: any, interval: number, paused?: boolean): void; + /** + !#en + Schedules the update callback for a given target, + the callback will be invoked every frame after schedule started. + !#zh + 使用指定的优先级为指定的对象设置 update 定时器。 + update 定时器每一帧都会被触发。优先级的值越低,定时器被触发的越早。 + @param target target + @param priority priority + @param paused paused + @param updateFunc updateFunc + */ + scheduleUpdate(target: any, priority: number, paused: boolean, updateFunc: Function): void; + /** + !#en + Unschedules a callback for a callback and a given target. + If you want to unschedule the "update", use `unscheduleUpdate()` + !#zh + 根据指定的回调函数和调用对象。 + 如果需要取消 update 定时器,请使用 unscheduleUpdate()。 + @param callback The callback to be unscheduled + @param target The target bound to the callback. + */ + unschedule(callback: Function, target: any): void; + /** + !#en Unschedules the update callback for a given target. + !#zh 取消指定对象的 update 定时器。 + @param target The target to be unscheduled. + */ + unscheduleUpdate(target: any): void; + /** + !#en + Unschedules all scheduled callbacks for a given target. + This also includes the "update" callback. + !#zh 取消指定对象的所有定时器,包括 update 定时器。 + @param target The target to be unscheduled. + */ + unscheduleAllForTarget(target: any): void; + /** + !#en + Unschedules all scheduled callbacks from all targets including the system callbacks.
+ You should NEVER call this method, unless you know what you are doing. + !#zh + 取消所有对象的所有定时器,包括系统定时器。
+ 不用调用此函数,除非你确定你在做什么。 + */ + unscheduleAll(): void; + /** + !#en + Unschedules all callbacks from all targets with a minimum priority.
+ You should only call this with `PRIORITY_NON_SYSTEM_MIN` or higher. + !#zh + 取消所有优先级的值大于指定优先级的定时器。
+ 你应该只取消优先级的值大于 PRIORITY_NON_SYSTEM_MIN 的定时器。 + @param minPriority The minimum priority of selector to be unscheduled. Which means, all selectors which + priority is higher than minPriority will be unscheduled. + */ + unscheduleAllWithMinPriority(minPriority: number): void; + /** + !#en Checks whether a callback for a given target is scheduled. + !#zh 检查指定的回调函数和回调对象组合是否存在定时器。 + @param callback The callback to check. + @param target The target of the callback. + */ + isScheduled(callback: Function, target: any): boolean; + /** + !#en + Pause all selectors from all targets.
+ You should NEVER call this method, unless you know what you are doing. + !#zh + 暂停所有对象的所有定时器。
+ 不要调用这个方法,除非你知道你正在做什么。 + */ + pauseAllTargets(): void; + /** + !#en + Pause all selectors from all targets with a minimum priority.
+ You should only call this with kCCPriorityNonSystemMin or higher. + !#zh + 暂停所有优先级的值大于指定优先级的定时器。
+ 你应该只暂停优先级的值大于 PRIORITY_NON_SYSTEM_MIN 的定时器。 + @param minPriority minPriority + */ + pauseAllTargetsWithMinPriority(minPriority: number): void; + /** + !#en + Resume selectors on a set of targets.
+ This can be useful for undoing a call to pauseAllCallbacks. + !#zh + 恢复指定数组中所有对象的定时器。
+ 这个函数是 pauseAllCallbacks 的逆操作。 + @param targetsToResume targetsToResume + */ + resumeTargets(targetsToResume: any[]): void; + /** + !#en + Pauses the target.
+ All scheduled selectors/update for a given target won't be 'ticked' until the target is resumed.
+ If the target is not present, nothing happens. + !#zh + 暂停指定对象的定时器。
+ 指定对象的所有定时器都会被暂停。
+ 如果指定的对象没有定时器,什么也不会发生。 + @param target target + */ + pauseTarget(target: any): void; + /** + !#en + Resumes the target.
+ The 'target' will be unpaused, so all schedule selectors/update will be 'ticked' again.
+ If the target is not present, nothing happens. + !#zh + 恢复指定对象的所有定时器。
+ 指定对象的所有定时器将继续工作。
+ 如果指定的对象没有定时器,什么也不会发生。 + @param target target + */ + resumeTarget(target: any): void; + /** + !#en Returns whether or not the target is paused. + !#zh 返回指定对象的定时器是否暂停了。 + @param target target + */ + isTargetPaused(target: any): boolean; + /** + !#en + Schedules the 'update' callback_fn for a given target with a given priority.
+ The 'update' callback_fn will be called every frame.
+ The lower the priority, the earlier it is called. + !#zh + 为指定对象设置 update 定时器。
+ update 定时器每一帧都会被调用。
+ 优先级的值越低,越早被调用。 + @param target target + @param priority priority + @param paused paused + + @example + ```js + //register this object to scheduler + var scheduler = cc.director.getScheduler(); + scheduler.scheduleUpdateForTarget(this, priority, !this._isRunning ); + + ``` + */ + scheduleUpdateForTarget(target: any, priority: number, paused: boolean): void; + /** + !#en + Unschedule a callback function for a given target.
+ If you want to unschedule the "update", use unscheduleUpdateForTarget. + !#zh + 根据指定的回调函数和调用对象对象取消相应的定时器。
+ 如果需要取消 update 定时器,请使用 unscheduleUpdateForTarget()。 + @param target target + @param callback callback[Function] or key[String] + + @example + ```js + //unschedule a callback of target + var scheduler = cc.director.getScheduler(); + scheduler.unscheduleCallbackForTarget(this, callback); + + ``` + */ + unscheduleCallbackForTarget(target: any, callback: Function): void; + /** + !#en Unschedules the update callback function for a given target. + !#zh 取消指定对象的所有定时器。 + @param target target + + @example + ```js + //unschedules the "update" method. + var scheduler = cc.director.getScheduler(); + scheduler.unscheduleUpdateForTarget(this); + + ``` + */ + unscheduleUpdateForTarget(target: any): void; + /** + !#en + Unschedules all function callbacks for a given target.
+ This also includes the "update" callback function. + !#zh 取消指定对象的所有定时器,包括 update 定时器。 + @param target target + */ + unscheduleAllCallbacksForTarget(target: any): void; + /** + !#en + Unschedules all function callbacks from all targets.
+ You should NEVER call this method, unless you know what you are doing. + !#zh + 取消所有对象的所有定时器。
+ 不要调用这个方法,除非你知道你正在做什么。 + */ + unscheduleAllCallbacks(): void; + /** + !#en + Unschedules all function callbacks from all targets with a minimum priority.
+ You should only call this with kCCPriorityNonSystemMin or higher. + !#zh + 取消所有优先级的值大于指定优先级的所有对象的所有定时器。
+ 你应该只暂停优先级的值大于 PRIORITY_NON_SYSTEM_MIN 的定时器。 + @param minPriority minPriority + */ + unscheduleAllCallbacksWithMinPriority(minPriority: number): void; + /** !#en Priority level reserved for system services. + !#zh 系统服务的优先级。 */ + static PRIORITY_SYSTEM: number; + /** !#en Minimum priority level for user scheduling. + !#zh 用户调度最低优先级。 */ + static PRIORITY_NON_SYSTEM: number; + } + /** !#en + cc.MotionStreak manages a Ribbon based on it's motion in absolute space.
+ You construct it with a fadeTime, minimum segment size, texture path, texture
+ length and color. The fadeTime controls how long it takes each vertex in
+ the streak to fade out, the minimum segment size it how many pixels the
+ streak will move before adding a new ribbon segment, and the texture
+ length is the how many pixels the texture is stretched across. The texture
+ is vertically aligned along the streak segment. + !#zh 运动轨迹,用于游戏对象的运动轨迹上实现拖尾渐隐效果。 */ + export class MotionStreak extends Component { + /** !#en + !#zh 在编辑器模式下预览拖尾效果。 */ + preview: boolean; + /** !#en The fade time to fade. + !#zh 拖尾的渐隐时间,以秒为单位。 */ + fadeTime: number; + /** !#en The minimum segment size. + !#zh 拖尾之间最小距离。 */ + minSeg: number; + /** !#en The stroke's width. + !#zh 拖尾的宽度。 */ + stroke: number; + /** !#en The texture of the MotionStreak. + !#zh 拖尾的贴图。 */ + texture: Texture2D; + /** !#en The color of the MotionStreak. + !#zh 拖尾的颜色 */ + color: Color; + /** !#en The fast Mode. + !#zh 是否启用了快速模式。当启用快速模式,新的点会被更快地添加,但精度较低。 */ + fastMode: boolean; + /** + !#en Remove all living segments of the ribbon. + !#zh 删除当前所有的拖尾片段。 + + @example + ```js + // stop particle system. + myParticleSystem.stopSystem(); + ``` + */ + reset(): void; + } + /** Particle System base class.
+ Attributes of a Particle System:
+ - emmision rate of the particles
+ - Gravity Mode (Mode A):
+ - gravity
+ - direction
+ - speed +- variance
+ - tangential acceleration +- variance
+ - radial acceleration +- variance
+ - Radius Mode (Mode B):
+ - startRadius +- variance
+ - endRadius +- variance
+ - rotate +- variance
+ - Properties common to all modes:
+ - life +- life variance
+ - start spin +- variance
+ - end spin +- variance
+ - start size +- variance
+ - end size +- variance
+ - start color +- variance
+ - end color +- variance
+ - life +- variance
+ - blending function
+ - texture
+
+ cocos2d also supports particles generated by Particle Designer (http://particledesigner.71squared.com/).
+ 'Radius Mode' in Particle Designer uses a fixed emit rate of 30 hz. Since that can't be guarateed in cocos2d,
+ cocos2d uses a another approach, but the results are almost identical.
+ cocos2d supports all the variables used by Particle Designer plus a bit more:
+ - spinning particles (supported when using ParticleSystem)
+ - tangential acceleration (Gravity mode)
+ - radial acceleration (Gravity mode)
+ - radius direction (Radius mode) (Particle Designer supports outwards to inwards direction only)
+ It is possible to customize any of the above mentioned properties in runtime. Example:
*/ + export class ParticleSystem extends _RendererUnderSG { + /** !#en Play particle in edit mode. + !#zh 在编辑器模式下预览粒子,启用后选中粒子时,粒子将自动播放。 */ + preview: boolean; + /** !#en + If set custom to true, then use custom properties insteadof read particle file. + !#zh 是否自定义粒子属性。 */ + custom: boolean; + /** !#en The plist file. + !#zh plist 格式的粒子配置文件。 */ + file: string; + /** . */ + texture: Texture2D; + /** !#en Current quantity of particles that are being simulated. + !#zh 当前播放的粒子数量。 */ + particleCount: number; + /** !#en Specify the source Blend Factor. + !#zh 指定原图混合模式。 */ + srcBlendFactor: BlendFactor; + /** !#en Specify the destination Blend Factor. + !#zh 指定目标的混合模式。 */ + dstBlendFactor: BlendFactor; + /** !#en If set to true, the particle system will automatically start playing on onLoad. + !#zh 如果设置为 true 运行时会自动发射粒子。 */ + playOnLoad: boolean; + /** !#en Indicate whether the owner node will be auto-removed when it has no particles left. + !#zh 粒子播放完毕后自动销毁所在的节点。 */ + autoRemoveOnFinish: boolean; + /** !#en Indicate whether the particle system is activated. + !#zh 是否激活粒子。 */ + active: boolean; + /** !#en Maximum particles of the system. + !#zh 粒子最大数量。 */ + totalParticles: number; + /** !#en How many seconds the emitter wil run. -1 means 'forever'. + !#zh 发射器生存时间,单位秒,-1表示持续发射。 */ + duration: number; + /** !#en Emission rate of the particles. + !#zh 每秒发射的粒子数目。 */ + emissionRate: number; + /** !#en Life of each particle setter. + !#zh 粒子的运行时间。 */ + life: number; + /** !#en Variation of life. + !#zh 粒子的运行时间变化范围。 */ + lifeVar: number; + /** !#en Start color of each particle. + !#zh 粒子初始颜色。 */ + startColor: Color; + /** !#en Variation of the start color. + !#zh 粒子初始颜色变化范围。 */ + startColorVar: Color; + /** !#en Ending color of each particle. + !#zh 粒子结束颜色。 */ + endColor: Color; + /** !#en Variation of the end color. + !#zh 粒子结束颜色变化范围。 */ + endColorVar: Color; + /** !#en Angle of each particle setter. + !#zh 粒子角度。 */ + angle: number; + /** !#en Variation of angle of each particle setter. + !#zh 粒子角度变化范围。 */ + angleVar: number; + /** !#en Start size in pixels of each particle. + !#zh 粒子的初始大小。 */ + startSize: number; + /** !#en Variation of start size in pixels. + !#zh 粒子初始大小的变化范围。 */ + startSizeVar: number; + /** !#en End size in pixels of each particle. + !#zh 粒子结束时的大小。 */ + endSize: number; + /** !#en Variation of end size in pixels. + !#zh 粒子结束大小的变化范围。 */ + endSizeVar: number; + /** !#en Start angle of each particle. + !#zh 粒子开始自旋角度。 */ + startSpin: number; + /** !#en Variation of start angle. + !#zh 粒子开始自旋角度变化范围。 */ + startSpinVar: number; + /** !#en End angle of each particle. + !#zh 粒子结束自旋角度。 */ + endSpin: number; + /** !#en Variation of end angle. + !#zh 粒子结束自旋角度变化范围。 */ + endSpinVar: number; + /** !#en Source position of the emitter. + !#zh 发射器位置。 */ + sourcePos: Vec2; + /** !#en Variation of source position. + !#zh 发射器位置的变化范围。(横向和纵向) */ + posVar: Vec2; + /** !#en Particles movement type. + !#zh 粒子位置类型。 */ + positionType: ParticleSystem.PositionType; + /** !#en Particles emitter modes. + !#zh 发射器类型。 */ + emitterMode: ParticleSystem.EmitterMode; + /** !#en Gravity of the emitter. + !#zh 重力。 */ + gravity: Vec2; + /** !#en Speed of the emitter. + !#zh 速度。 */ + speed: number; + /** !#en Variation of the speed. + !#zh 速度变化范围。 */ + speedVar: number; + /** !#en Tangential acceleration of each particle. Only available in 'Gravity' mode. + !#zh 每个粒子的切向加速度,即垂直于重力方向的加速度,只有在重力模式下可用。 */ + tangentialAccel: number; + /** !#en Variation of the tangential acceleration. + !#zh 每个粒子的切向加速度变化范围。 */ + tangentialAccelVar: number; + /** !#en Acceleration of each particle. Only available in 'Gravity' mode. + !#zh 粒子径向加速度,即平行于重力方向的加速度,只有在重力模式下可用。 */ + radialAccel: number; + /** !#en Variation of the radial acceleration. + !#zh 粒子径向加速度变化范围。 */ + radialAccelVar: number; + /** !#en Indicate whether the rotation of each particle equals to its direction. Only available in 'Gravity' mode. + !#zh 每个粒子的旋转是否等于其方向,只有在重力模式下可用。 */ + rotationIsDir: boolean; + /** !#en Starting radius of the particles. Only available in 'Radius' mode. + !#zh 初始半径,表示粒子出生时相对发射器的距离,只有在半径模式下可用。 */ + startRadius: number; + /** !#en Variation of the starting radius. + !#zh 初始半径变化范围。 */ + startRadiusVar: number; + /** !#en Ending radius of the particles. Only available in 'Radius' mode. + !#zh 结束半径,只有在半径模式下可用。 */ + endRadius: number; + /** !#en Variation of the ending radius. + !#zh 结束半径变化范围。 */ + endRadiusVar: number; + /** !#en Number of degress to rotate a particle around the source pos per second. Only available in 'Radius' mode. + !#zh 粒子每秒围绕起始点的旋转角度,只有在半径模式下可用。 */ + rotatePerS: number; + /** !#en Variation of the degress to rotate a particle around the source pos per second. + !#zh 粒子每秒围绕起始点的旋转角度变化范围。 */ + rotatePerSVar: number; + /** !#en The Particle emitter lives forever. + !#zh 表示发射器永久存在 */ + static DURATION_INFINITY: number; + /** !#en The starting size of the particle is equal to the ending size. + !#zh 表示粒子的起始大小等于结束大小。 */ + static START_SIZE_EQUAL_TO_END_SIZE: number; + /** !#en The starting radius of the particle is equal to the ending radius. + !#zh 表示粒子的起始半径等于结束半径。 */ + static START_RADIUS_EQUAL_TO_END_RADIUS: number; + /** + !#en Add a particle to the emitter. + !#zh 添加一个粒子到发射器中。 + */ + addParticle(): boolean; + /** + !#en Stop emitting particles. Running particles will continue to run until they die. + !#zh 停止发射器发射粒子,发射出去的粒子将继续运行,直至粒子生命结束。 + + @example + ```js + // stop particle system. + myParticleSystem.stopSystem(); + ``` + */ + stopSystem(): void; + /** + !#en Kill all living particles. + !#zh 杀死所有存在的粒子,然后重新启动粒子发射器。 + + @example + ```js + // play particle system. + myParticleSystem.resetSystem(); + ``` + */ + resetSystem(): void; + /** + !#en Whether or not the system is full. + !#zh 发射器中粒子是否大于等于设置的总粒子数量。 + */ + isFull(): boolean; + /** + !#en +

Sets a new CCSpriteFrame as particle.
+ WARNING: this method is experimental. Use setTextureWithRect instead. +

+ !#zh +

设置一个新的精灵帧为粒子。
+ 警告:这个函数只是试验,请使用 setTextureWithRect 实现。 +

+ @param spriteFrame spriteFrame + */ + setDisplayFrame(spriteFrame: SpriteFrame): void; + /** + !#en Sets a new texture with a rect. The rect is in texture position and size. + !#zh 设置一张新贴图和关联的矩形。 + @param texture texture + @param rect rect + */ + setTextureWithRect(texture: Texture2D, rect: Rect): void; + } + /** !#en Renders the TMX object. + !#zh 渲染 tmx object。 */ + export class TMXObject { + /** + !#en Get the name of object + !#zh 获取对象的名称 + */ + getObjectName(): string; + /** + !#en Get the property of object + !#zh 获取对象的属性 + @param propertyName propertyName + */ + getProperty(propertyName: string): any; + /** + !#en Get the properties of object + !#zh 获取对象的属性 + */ + getProperties(): any; + /** + !#en Set the object name + !#zh 设置对象名称 + @param name name + */ + setObjectName(name: string): void; + /** + !#en Set the properties of the object + !#zh 设置对象的属性 + @param props props + */ + setProperties(props: any): void; + } + /** !#en Render the TMX layer. + !#zh 渲染 TMX layer。 */ + export class TiledLayer extends _SGComponent { + /** + !#en Gets the layer name. + !#zh 获取层的名称。 + + @example + ```js + var layerName = tiledLayer.getLayerName(); + cc.log(layerName); + ``` + */ + getLayerName(): string; + /** + !#en Set the layer name. + !#zh 设置层的名称 + @param layerName layerName + + @example + ```js + tiledLayer.setLayerName("New Layer"); + ``` + */ + SetLayerName(layerName: string): void; + /** + !#en Return the value for the specific property name. + !#zh 获取指定属性名的值。 + @param propertyName propertyName + + @example + ```js + var property = tiledLayer.getProperty("info"); + cc.log(property); + ``` + */ + getProperty(propertyName: string): any; + /** + !#en Returns the position in pixels of a given tile coordinate. + !#zh 获取指定 tile 的像素坐标。 + @param pos position or x + @param y y + + @example + ```js + var pos = tiledLayer.getPositionAt(cc.v2(0, 0)); + cc.log("Pos: " + pos); + var pos = tiledLayer.getPositionAt(0, 0); + cc.log("Pos: " + pos); + ``` + */ + getPositionAt(pos: Vec2|number, y?: number): Vec2; + /** + !#en Removes a tile at given tile coordinate. + !#zh 删除指定坐标上的 tile。 + @param pos position or x + @param y y + + @example + ```js + tiledLayer.removeTileAt(cc.v2(0, 0)); + tiledLayer.removeTileAt(0, 0); + ``` + */ + removeTileAt(pos: Vec2|number, y?: number): void; + /** + !#en + Sets the tile gid (gid = tile global id) at a given tile coordinate.
+ The Tile GID can be obtained by using the method "tileGIDAt" or by using the TMX editor . Tileset Mgr +1.
+ If a tile is already placed at that position, then it will be removed. + !#zh + 设置给定坐标的 tile 的 gid (gid = tile 全局 id), + tile 的 GID 可以使用方法 “tileGIDAt” 来获得。
+ 如果一个 tile 已经放在那个位置,那么它将被删除。 + @param gid gid + @param posOrX position or x + @param flagsOrY flags or y + @param flags flags + + @example + ```js + tiledLayer.setTileGID(1001, 10, 10, 1) + ``` + */ + setTileGID(gid: number, posOrX: Vec2|number, flagsOrY: number, flags?: number): void; + /** + !#en + Returns the tile gid at a given tile coordinate.
+ if it returns 0, it means that the tile is empty.
+ This method requires the the tile map has not been previously released (eg. don't call layer.releaseMap())
+ !#zh + 通过给定的 tile 坐标、flags(可选)返回 tile 的 GID.
+ 如果它返回 0,则表示该 tile 为空。
+ 该方法要求 tile 地图之前没有被释放过(如:没有调用过layer.releaseMap()). + @param pos or x + @param y y + + @example + ```js + var tileGid = tiledLayer.getTileGIDAt(0, 0); + ``` + */ + getTileGIDAt(pos: Vec2|number, y?: number): number; + /** + !#en + Returns the tile (_ccsg.Sprite) at a given a tile coordinate.
+ The returned _ccsg.Sprite will be already added to the _ccsg.TMXLayer. Don't add it again.
+ The _ccsg.Sprite can be treated like any other _ccsg.Sprite: rotated, scaled, translated, opacity, color, etc.
+ You can remove either by calling:
+ - layer.removeChild(sprite, cleanup);
+ - or layer.removeTileAt(ccp(x,y)); + !#zh + 通过指定的 tile 坐标获取对应的 tile(Sprite)。 返回的 tile(Sprite) 应是已经添加到 TMXLayer,请不要重复添加。
+ 这个 tile(Sprite) 如同其他的 Sprite 一样,可以旋转、缩放、翻转、透明化、设置颜色等。
+ 你可以通过调用以下方法来对它进行删除:
+ 1. layer.removeChild(sprite, cleanup);
+ 2. 或 layer.removeTileAt(cc.v2(x,y)); + @param pos or x + @param y y + + @example + ```js + var title = tiledLayer.getTileAt(100, 100); + cc.log(title); + ``` + */ + getTileAt(pos: Vec2|number, y?: number): _ccsg.Sprite; + /** + !#en + Dealloc the map that contains the tile position from memory.
+ Unless you want to know at runtime the tiles positions, you can safely call this method.
+ If you are going to call layer.getTileGIDAt() then, don't release the map. + !#zh + 从内存中释放包含 tile 位置信息的地图。
+ 除了在运行时想要知道 tiles 的位置信息外,你都可安全的调用此方法。
+ 如果你之后还要调用 layer.tileGIDAt(), 请不要释放地图. + + @example + ```js + tiledLayer.releaseMap(); + ``` + */ + releaseMap(): void; + /** + !#en Sets the untransformed size of the _ccsg.TMXLayer. + !#zh 设置未转换的 layer 大小。 + @param size The untransformed size of the _ccsg.TMXLayer or The untransformed size's width of the TMXLayer. + @param height The untransformed size's height of the _ccsg.TMXLayer. + + @example + ```js + tiledLayer.setContentSize(100, 100); + ``` + */ + setContentSize(size: Size|number, height?: number): void; + /** + !#en Return texture of cc.SpriteBatchNode. + !#zh 获取纹理。 + + @example + ```js + var texture = tiledLayer.getTexture(); + cc.log("Texture: " + texture); + ``` + */ + getTexture(): Texture2D; + /** + !#en Set the texture of cc.SpriteBatchNode. + !#zh 设置纹理。 + @param texture texture + + @example + ```js + tiledLayer.setTexture(texture); + ``` + */ + setTexture(texture: Texture2D): void; + /** + !#en Set the opacity of all tiles + !#zh 设置所有 Tile 的透明度 + @param opacity opacity + + @example + ```js + tiledLayer.setTileOpacity(128); + ``` + */ + setTileOpacity(opacity: number): void; + /** + !#en Gets layer size. + !#zh 获得层大小。 + + @example + ```js + var size = tiledLayer.getLayerSize(); + cc.log("layer size: " + size); + ``` + */ + getLayerSize(): Size; + /** + !#en Set layer size. + !#zh 设置层大小。 + @param layerSize layerSize + + @example + ```js + tiledLayer.setLayerSize(new cc.size(5, 5)); + ``` + */ + setLayerSize(layerSize: Size): void; + /** + !#en Size of the map's tile (could be different from the tile's size). + !#zh 获取 tile 的大小( tile 的大小可能会有所不同)。 + + @example + ```js + var mapTileSize = tiledLayer.getMapTileSize(); + cc.log("MapTile size: " + mapTileSize); + ``` + */ + getMapTileSize(): Size; + /** + !#en Set the map tile size. + !#zh 设置 tile 的大小。 + @param tileSize tileSize + + @example + ```js + tiledLayer.setMapTileSize(new cc.size(10, 10)); + ``` + */ + setMapTileSize(tileSize: Size): void; + /** + !#en Pointer to the map of tiles. + !#zh 获取地图 tiles。 + + @example + ```js + var tiles = tiledLayer.getTiles(); + ``` + */ + getTiles(): any[]; + /** + !#en Pointer to the map of tiles. + !#zh 设置地图 tiles + @param tiles tiles + + @example + ```js + tiledLayer.setTiles(tiles); + ``` + */ + setTiles(tiles: any[]): void; + /** + !#en Tile set information for the layer. + !#zh 获取 layer 的 Tileset 信息。 + + @example + ```js + var tileset = tiledLayer.getTileSet(); + ``` + */ + getTileSet(): TMXTilesetInfo; + /** + !#en Tile set information for the layer. + !#zh 设置 layer 的 Tileset 信息。 + @param tileset tileset + + @example + ```js + tiledLayer.setTileSet(tileset); + ``` + */ + setTileSet(tileset: TMXTilesetInfo): void; + /** + !#en Layer orientation, which is the same as the map orientation. + !#zh 获取 Layer 方向(同地图方向)。 + + @example + ```js + var orientation = tiledLayer.getLayerOrientation(); + cc.log("Layer Orientation: " + orientation); + ``` + */ + getLayerOrientation(): number; + /** + !#en Layer orientation, which is the same as the map orientation. + !#zh 设置 Layer 方向(同地图方向)。 + @param orientation orientation + + @example + ```js + tiledLayer.setLayerOrientation(TiledMap.Orientation.ORTHO); + ``` + */ + setLayerOrientation(orientation: TiledMap.Orientation): void; + /** + !#en properties from the layer. They can be added using Tiled. + !#zh 获取 layer 的属性,可以使用 Tiled 编辑器添加属性。 + + @example + ```js + var properties = tiledLayer.getProperties(); + cc.log("Properties: " + properties); + ``` + */ + getProperties(): any[]; + /** + !#en properties from the layer. They can be added using Tiled. + !#zh 设置层属性。 + @param properties properties + + @example + ```js + tiledLayer.setLayerOrientation(properties); + ``` + */ + setProperties(properties: any[]): void; + } + /** !#en Renders a TMX Tile Map in the scene. + !#zh 在场景中渲染一个 tmx 格式的 Tile Map。 */ + export class TiledMap extends Component { + /** !#en The TiledMap Asset. + !#zh TiledMap 资源。 */ + tmxAsset: TiledMapAsset; + /** + !#en Gets the map size. + !#zh 获取地图大小。 + + @example + ```js + var mapSize = tiledMap.getMapSize(); + cc.log("Map Size: " + mapSize); + ``` + */ + getMapSize(): Size; + /** + !#en Set the map size. + !#zh 设置地图大小。 + @param mapSize mapSize + + @example + ```js + tiledMap.setMapSize(new cc.size(960, 640)); + ``` + */ + setMapSize(mapSize: Size): void; + /** + !#en Gets the tile size. + !#zh 获取地图背景中 tile 元素的大小。 + + @example + ```js + var tileSize = tiledMap.getTileSize(); + cc.log("Tile Size: " + tileSize); + ``` + */ + getTileSize(): Size; + /** + !#en Set the tile size. + !#zh 设置地图背景中 tile 元素的大小。 + @param tileSize tileSize + + @example + ```js + tiledMap.setTileSize(new cc.size(10, 10)); + ``` + */ + setTileSize(tileSize: Size): void; + /** + !#en map orientation. + !#zh 获取地图方向。 + + @example + ```js + var mapOrientation = tiledMap.getMapOrientation(); + cc.log("Map Orientation: " + mapOrientation); + ``` + */ + getMapOrientation(): number; + /** + !#en map orientation. + !#zh 设置地图方向。 + @param orientation orientation + + @example + ```js + tiledMap.setMapOrientation(TiledMap.Orientation.ORTHO); + ``` + */ + setMapOrientation(orientation: TiledMap.Orientation): void; + /** + !#en object groups. + !#zh 获取所有的对象层。 + + @example + ```js + var objGroups = titledMap.getObjectGroups(); + for (var i = 0; i < objGroups.length; ++i) { + cc.log("obj: " + objGroups[i]); + } + ``` + */ + getObjectGroups(): TiledObjectGroup[]; + /** + !#en Gets the map properties. + !#zh 获取地图的属性。 + + @example + ```js + var properties = titledMap.getProperties(); + for (var i = 0; i < properties.length; ++i) { + cc.log("Properties: " + properties[i]); + } + ``` + */ + getProperties(): any[]; + /** + !#en Set the map properties. + !#zh 设置地图的属性。 + @param properties properties + + @example + ```js + titledMap.setProperties(properties); + ``` + */ + setProperties(properties: any[]): void; + /** + !#en Return All layers array. + !#zh 返回包含所有 layer 的数组。 + + @example + ```js + var layers = titledMap.allLayers(); + for (var i = 0; i < layers.length; ++i) { + cc.log("Layers: " + layers[i]); + } + ``` + */ + allLayers(): TiledLayer[]; + /** + !#en return the cc.TiledLayer for the specific layer. + !#zh 获取指定名称的 layer。 + @param layerName layerName + + @example + ```js + var layer = titledMap.getLayer("Player"); + cc.log(layer); + ``` + */ + getLayer(layerName: string): TiledLayer; + /** + !#en Return the TMXObjectGroup for the specific group. + !#zh 获取指定的 TMXObjectGroup。 + @param groupName groupName + + @example + ```js + var group = titledMap.getObjectGroup("Players"); + cc.log("ObjectGroup: " + group); + ``` + */ + getObjectGroup(groupName: string): TiledObjectGroup; + /** + !#en Return the value for the specific property name. + !#zh 通过属性名称,获取指定的属性。 + @param propertyName propertyName + + @example + ```js + var property = titledMap.getProperty("info"); + cc.log("Property: " + property); + ``` + */ + getProperty(propertyName: string): string; + /** + !#en Return properties dictionary for tile GID. + !#zh 通过 GID ,获取指定的属性。 + @param GID GID + + @example + ```js + var properties = titledMap.getPropertiesForGID(GID); + cc.log("Properties: " + properties); + ``` + */ + getPropertiesForGID(GID: number): any; + } + /** Class for tiled map asset handling. */ + export class TiledMapAsset extends Asset { + } + /** !#en Renders the TMX object group. + !#zh 渲染 tmx object group。 */ + export class TiledObjectGroup extends _SGComponent { + /** + !#en Offset position of child objects. + !#zh 获取子对象的偏移位置。 + + @example + ```js + var offset = tMXObjectGroup.getPositionOffset(); + ``` + */ + getPositionOffset(): Vec2; + /** + !#en Offset position of child objects. + !#zh 设置子对象的偏移位置。 + @param offset offset + + @example + ```js + tMXObjectGroup.setPositionOffset(cc.v2(5, 5)); + ``` + */ + setPositionOffset(offset: Vec2): void; + /** + !#en List of properties stored in a dictionary. + !#zh 以映射的形式获取属性列表。 + + @example + ```js + var offset = tMXObjectGroup.getProperties(); + ``` + */ + getProperties(): any; + /** + !#en Set the properties of the object group. + !#zh 设置属性列表。 + @param Var Var + + @example + ```js + tMXObjectGroup.setProperties(obj); + ``` + */ + setProperties(Var: any): void; + /** + !#en Gets the Group name. + !#zh 获取组名称。 + + @example + ```js + var groupName = tMXObjectGroup.getGroupName; + ``` + */ + getGroupName(): string; + /** + !#en Set the Group name. + !#zh 设置组名称。 + @param groupName groupName + + @example + ```js + tMXObjectGroup.setGroupName("New Group"); + ``` + */ + setGroupName(groupName: string): void; + /** + !#en + Return the object for the specific object name.
+ It will return the 1st object found on the array for the given name. + !#zh 获取指定的对象。 + @param objectName objectName + + @example + ```js + var object = tMXObjectGroup.getObject("Group"); + ``` + */ + getObject(objectName: string): any; + /** + !#en Gets the objects. + !#zh 获取对象数组。 + + @example + ```js + var objects = tMXObjectGroup.getObjects(); + ``` + */ + getObjects(): any[]; + } + /** !#en + cc.NodePool is the cache pool designed for node type.
+ It can helps you to improve your game performance for objects which need frequent release and recreate operations
+ + It's recommended to create cc.NodePool instances by node type, the type corresponds to node type in game design, not the class, + for example, a prefab is a specific node type.
+ When you create a node pool, you can pass a Component which contains `unuse`, `reuse` functions to control the content of node.
+ + Some common use case is :
+ 1. Bullets in game (die very soon, massive creation and recreation, no side effect on other objects)
+ 2. Blocks in candy crash (massive creation and recreation)
+ etc... + !#zh + cc.NodePool 是用于管理节点对象的对象缓存池。
+ 它可以帮助您提高游戏性能,适用于优化对象的反复创建和销毁
+ 以前 cocos2d-x 中的 cc.pool 和新的节点事件注册系统不兼容,因此请使用 cc.NodePool 来代替。 + + 新的 NodePool 需要实例化之后才能使用,每种不同的节点对象池需要一个不同的对象池实例,这里的种类对应于游戏中的节点设计,一个 prefab 相当于一个种类的节点。
+ 在创建缓冲池时,可以传入一个包含 unuse, reuse 函数的组件类型用于节点的回收和复用逻辑。
+ + 一些常见的用例是:
+ 1.在游戏中的子弹(死亡很快,频繁创建,对其他对象无副作用)
+ 2.糖果粉碎传奇中的木块(频繁创建)。 + 等等.... */ + export class NodePool { + /** + !#en + Constructor for creating a pool for a specific node template (usually a prefab). You can pass a component (type or name) argument for handling event for reusing and recycling node. + !#zh + 使用构造函数来创建一个节点专用的对象池,您可以传递一个组件类型或名称,用于处理节点回收和复用时的事件逻辑。 + @param poolHandlerComp !#en The constructor or the class name of the component to control the unuse/reuse logic. !#zh 处理节点回收和复用事件逻辑的组件类型或名称。 + + @example + ```js + properties: { + template: cc.Prefab + }, + onLoad () { + // MyTemplateHandler is a component with 'unuse' and 'reuse' to handle events when node is reused or recycled. + this.myPool = new cc.NodePool('MyTemplateHandler'); + } + ``` + */ + constructor(poolHandlerComp?: {prototype: Component}|string); + /** !#en The pool handler component, it could be the class name or the constructor. + !#zh 缓冲池处理组件,用于节点的回收和复用逻辑,这个属性可以是组件类名或组件的构造函数。 */ + poolHandlerComp: Function|string; + /** + !#en The current available size in the pool + !#zh 获取当前缓冲池的可用对象数量 + */ + size(): number; + /** + !#en Destroy all cached nodes in the pool + !#zh 销毁对象池中缓存的所有节点 + */ + clear(): void; + /** + !#en Put a new Node into the pool. + It will automatically remove the node from its parent without cleanup. + It will also invoke unuse method of the poolHandlerComp if exist. + !#zh 向缓冲池中存入一个不再需要的节点对象。 + 这个函数会自动将目标节点从父节点上移除,但是不会进行 cleanup 操作。 + 这个函数会调用 poolHandlerComp 的 unuse 函数,如果组件和函数都存在的话。 + @param obj obj + + @example + ```js + let myNode = cc.instantiate(this.template); + this.myPool.put(myNode); + ``` + */ + put(obj: Node): void; + /** + !#en Get a obj from pool, if no available object in pool, null will be returned. + This function will invoke the reuse function of poolHandlerComp if exist. + !#zh 获取对象池中的对象,如果对象池没有可用对象,则返回空。 + 这个函数会调用 poolHandlerComp 的 reuse 函数,如果组件和函数都存在的话。 + @param params !#en Params to pass to 'reuse' method in poolHandlerComp !#zh 向 poolHandlerComp 中的 'reuse' 函数传递的参数 + + @example + ```js + let newNode = this.myPool.get(); + ``` + */ + get(...params: any[]): Node; + } + /** !#en + Attention: In creator, it's strongly not recommended to use cc.pool to manager cc.Node. + We provided {{#crossLink "NodePool"}}cc.NodePool{{/crossLink}} instead. + + cc.pool is a singleton object serves as an object cache pool.
+ It can helps you to improve your game performance for objects which need frequent release and recreate operations
+ !#zh + 首先请注意,在 Creator 中我们强烈不建议使用 cc.pool 来管理 cc.Node 节点对象,请使用 {{#crossLink "NodePool"}}cc.NodePool{{/crossLink}} 代替 + 因为 cc.pool 是面向类来设计的,而 cc.Node 中使用 Component 来进行组合,它的类永远都一样,实际却千差万别。 + + cc.pool 是一个单例对象,用作为对象缓存池。
+ 它可以帮助您提高游戏性能,适用于优化对象的反复创建和销毁
*/ + export class pool { + /** + !#en Put the obj in pool. + !#zh 加入对象到对象池中。 + @param obj The need put in pool object. + + @example + ```js + --------------------------------- + var sp = new _ccsg.Sprite("a.png"); + this.addChild(sp); + cc.pool.putInPool(sp); + cc.pool.getFromPool(_ccsg.Sprite, "a.png"); + + ``` + */ + putInPool(obj: any): void; + /** + !#en Check if this kind of obj has already in pool. + !#zh 检查对象池中是否有指定对象的存在。 + @param objClass The check object class. + */ + hasObject(objClass: any): boolean; + /** + !#en Remove the obj if you want to delete it. + !#zh 移除在对象池中指定的对象。 + */ + removeObject(): void; + /** + !#en Get the obj from pool. + !#zh 获取对象池中的指定对象。 + */ + getFromPool(): any; + /** + !#en Remove all objs in pool and reset the pool. + !#zh 移除对象池中的所有对象,并且重置对象池。 + */ + drainAllPools(): void; + } + /** !#en Box Collider. + !#zh 包围盒碰撞组件 */ + export class BoxCollider extends Collider implements Collider.Box { + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Box size + !#zh 包围盒大小 */ + size: Size; + } + /** !#en Circle Collider. + !#zh 圆形碰撞组件 */ + export class CircleCollider extends Collider implements Collider.Circle { + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Circle radius + !#zh 圆形半径 */ + radius: number; + } + /** !#en Collider component base class. + !#zh 碰撞组件基类 */ + export class Collider extends Component { + /** !#en Tag. If a node has several collider components, you can judge which type of collider is collided according to the tag. + !#zh 标签。当一个节点上有多个碰撞组件时,在发生碰撞后,可以使用此标签来判断是节点上的哪个碰撞组件被碰撞了。 */ + tag: number; + } + /** !#en + A simple collision manager class. + It will calculate whether the collider collides other colliders, if collides then call the callbacks. + !#zh + 一个简单的碰撞组件管理类,用于处理节点之间的碰撞组件是否产生了碰撞,并调用相应回调函数。 */ + export class CollisionManager implements EventTarget { + /** !#en + !#zh + 是否开启碰撞管理,默认为不开启 */ + enabled: boolean; + /** !#en + !#zh + 是否绘制碰撞组件的包围盒,默认为不绘制 */ + enabledDrawBoundingBox: boolean; + /** !#en + !#zh + 是否绘制碰撞组件的形状,默认为不绘制 */ + enabledDebugDraw: boolean; + /** + !#en + Register an callback of a specific event type on the EventTarget. + !#zh + 注册事件目标的特定事件类型回调。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + @param useCapture When set to true, the capture argument prevents callback + from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. + When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE. + Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET. + + @example + ```js + node.on(cc.Node.EventType.TOUCH_END, function (event) { + cc.log("this is callback"); + }, node); + ``` + */ + on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void; + on(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void; + /** + !#en + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. + !#zh + 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not. + If not specified, useCapture defaults to false. If a callback was registered twice, + one with capture and one without, each must be removed separately. Removal of a capturing callback + does not affect a non-capturing version of the same listener, and vice versa. + + @example + ```js + // register touchEnd eventListener + var touchEnd = node.on(cc.Node.EventType.TOUCH_END, function (event) { + cc.log("this is callback"); + }, node); + // remove touch end event listener + node.off(cc.Node.EventType.TOUCH_END, touchEnd, node); + // remove all touch end event listeners + node.off(cc.Node.EventType.TOUCH_END); + ``` + */ + off(type: string, callback?: Function, target?: any, useCapture?: boolean): void; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + @param useCapture When set to true, the capture argument prevents callback + from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. + When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE. + Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET. + + @example + ```js + node.once(cc.Node.EventType.TOUCH_END, function (event) { + cc.log("this is callback"); + }, node); + ``` + */ + once(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void; + once(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void; + /** + !#en + Dispatches an event into the event flow. + The event target is the EventTarget object upon which the dispatchEvent() method is called. + !#zh 分发事件到事件流中。 + @param event The Event object that is dispatched into the event flow + */ + dispatchEvent(event: Event): void; + /** + !#en + Send an event to this object directly, this method will not propagate the event to any other objects. + The event will be created from the supplied message, you can get the "detail" argument from event.detail. + !#zh + 该对象直接发送事件, 这种方法不会对事件传播到任何其他对象。 + @param message the message to send + @param detail whatever argument the message needs + */ + emit(message: string, detail?: any): void; + } + /** !#en Intersection helper class + !#zh 辅助类,用于测试形状与形状是否相交 */ + export class Intersection { + /** + !#en Test line and line + !#zh 测试线段与线段是否相交 + @param a1 The start point of the first line + @param a2 The end point of the first line + @param b1 The start point of the second line + @param b2 The end point of the second line + */ + static lineLine(a1: Vec2, a2: Vec2, b1: Vec2, b2: Vec2): boolean; + /** + !#en Test line and rect + !#zh 测试线段与矩形是否相交 + @param a1 The start point of the line + @param a2 The end point of the line + @param b The rect + */ + static lineRect(a1: Vec2, a2: Vec2, b: Rect): boolean; + /** + !#en Test line and polygon + !#zh 测试线段与多边形是否相交 + @param a1 The start point of the line + @param a2 The end point of the line + @param b The polygon, a set of points + */ + static linePolygon(a1: Vec2, a2: Vec2, b: Vec2[]): boolean; + /** + !#en Test rect and rect + !#zh 测试矩形与矩形是否相交 + @param a The first rect + @param b The second rect + */ + static rectRect(a: Rect, b: Rect): boolean; + /** + !#en Test rect and polygon + !#zh 测试矩形与多边形是否相交 + @param a The rect + @param b The polygon, a set of points + */ + static rectPolygon(a: Rect, b: Vec2[]): boolean; + /** + !#en Test polygon and polygon + !#zh 测试多边形与多边形是否相交 + @param a The first polygon, a set of points + @param b The second polygon, a set of points + */ + static polygonPolygon(a: Vec2[], b: Vec2[]): boolean; + /** + !#en Test circle and circle + !#zh 测试圆形与圆形是否相交 + @param a Object contains position and radius + @param b Object contains position and radius + */ + static circleCircle(a: {position: Vec2, radius: number}, b: {position: Vec2, radius: number}): boolean; + /** + !#en Test polygon and circle + !#zh 测试矩形与圆形是否相交 + @param polygon The Polygon, a set of points + @param circle Object contains position and radius + */ + static polygonCircle(polygon: Vec2[], circle: {position: Vec2, radius: number}): boolean; + /** + !#en Test whether the point is in the polygon + !#zh 测试一个点是否在一个多边形中 + @param point The point + @param polygon The polygon, a set of points + */ + static pointInPolygon(point: Vec2, polygon: Vec2[]): boolean; + /** + !#en Calculate the distance of point to line. + !#zh 计算点到直线的距离。如果这是一条线段并且垂足不在线段内,则会计算点到线段端点的距离。 + @param point The point + @param start The start point of line + @param end The end point of line + @param isSegment whether this line is a segment + */ + static pointLineDistance(point: Vec2, start: Vec2, end: Vec2, isSegment: boolean): boolean; + } + /** !#en Polygon Collider. + !#zh 多边形碰撞组件 */ + export class PolygonCollider extends Collider implements Collider.Polygon { + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Polygon points + !#zh 多边形顶点数组 */ + points: [Vec2]; + } + /** !#en + Base class for handling assets used in Fireball. This class can be instantiate. + + You may want to override:
+ - createNode
+ - cc.Object._serialize
+ - cc.Object._deserialize
+ !#zh + 资源基类,该类可以被实例化。
+ + 您可能需要重写:
+ - createNode
+ - cc.Object._serialize
+ - cc.Object._deserialize
*/ + export class Asset extends RawAsset { + /** !#en + Returns the url of this asset's first raw file, if none of rawFile exists, + it will returns an empty string. + !#zh 返回该资源的原始文件的 URL,如果不支持 RAW 文件,它将返回一个空字符串。 */ + rawUrl: string; + /** !#en + Returns the url of this asset's raw files, if none of rawFile exists, + it will returns an empty array. + !#zh 返回该资源的原文件的 URL 数组,如果不支持 RAW 文件,它将返回一个空数组。 */ + rawUrls: string[]; + /** !#en Indicates whether its dependent raw assets can support deferred load if the owner scene (or prefab) is marked as `asyncLoadAssets`. + !#zh 当场景或 Prefab 被标记为 `asyncLoadAssets`,禁止延迟加载该资源所依赖的其它 RawAsset。 */ + static preventDeferredLoadDependents: boolean; + /** + !#en + Create a new node using this asset in the scene.
+ If this type of asset dont have its corresponding node type, this method should be null. + !#zh + 使用该资源在场景中创建一个新节点。
+ 如果这类资源没有相应的节点类型,该方法应该是空的。 + @param callback callback + */ + createNode(callback: (error: string, node: any) => void): void; + } + /** !#en Class for audio data handling. + !#zh 音频资源类。 */ + export class AudioClip extends RawAsset { + } + /** !#en Class for BitmapFont handling. + !#zh 位图字体资源类。 */ + export class BitmapFont extends RawAsset { + } + /** !#en Class for Font handling. + !#zh 字体资源类。 */ + export class Font extends RawAsset { + } + /** !#en Class for LabelAtlas handling. + !#zh 艺术数字字体资源类。 */ + export class LabelAtlas extends BitmapFont { + } + /** !#en Class for prefab handling. + !#zh 预制资源类。 */ + export class Prefab extends Asset { + /** the main cc.Node in the prefab */ + data: Node; + /** !#en Indicates the raw assets of this prefab can be load after prefab loaded. + !#zh 指示该 Prefab 依赖的资源可否在 Prefab 加载后再延迟加载。 */ + asyncLoadAssets: boolean; + /** + Dynamically translation prefab data into minimized code.
+ This method will be called automatically before the first time the prefab being instantiated, + but you can re-call to refresh the create function once you modified the original prefab data in script. + */ + compileCreateFunction(): void; + } + /** !#en + The base class for registering asset types. + + You may want to override: + - createNode (static) + !#zh + 注册用的资源基类。
+ 你可能要重写:
+ - createNode (static) */ + export class RawAsset extends Object { + /** + !#en + Create a new node in the scene.
+ If this type of asset dont have its corresponding node type, this method should be null. + !#zh + 在场景中创建一个新节点。
+ 如果这类资源没有相应的节点类型,该方法应该是空的。 + @param Info Info + @param callback callback + */ + static createNodeByInfo(Info: any, callback: (error: string, node: any) => void): void; + } + /** !#en Class for scene handling. + !#zh 场景资源类。 */ + export class SceneAsset extends Asset { + scene: Scene; + /** !#en Indicates the raw assets of this scene can be load after scene launched. + !#zh 指示该场景依赖的资源可否在场景切换后再延迟加载。 */ + asyncLoadAssets: boolean; + } + /** !#en Class for script handling. + !#zh Script 资源类。 */ + export class _Script extends Asset { + } + /** !#en Class for JavaScript handling. + !#zh JavaScript 资源类。 */ + export class _JavaScript extends Asset { + } + /** !#en Class for coffeescript handling. + !#zh CoffeeScript 资源类。 */ + export class CoffeeScript extends Asset { + } + /** !#en Class for TypeScript handling. + !#zh TypeScript 资源类。 */ + export class TypeScript extends Asset { + } + /** !#en Class for sprite atlas handling. + !#zh 精灵图集资源类。 */ + export class SpriteAtlas extends RawAsset { + /** + Returns the texture of the sprite atlas + */ + getTexture(): Texture2D; + /** + Returns the sprite frame correspond to the given key in sprite atlas. + @param key key + */ + getSpriteFrame(key: string): SpriteFrame; + /** + Returns the sprite frames in sprite atlas. + */ + getSpriteFrames(): [SpriteFrame]; + } + /** !#en Class for TTFFont handling. + !#zh TTF 字体资源类。 */ + export class TTFFont extends Asset { + } + /** !#en Class for text file. + !#zh 文本资源类。 */ + export class TextAsset extends Asset { + } + /** !#en + Camera is usefull when making reel game or other games which need scroll screen. + Using camera will be more efficient than moving node to scroll screen. + Camera + !#zh + 摄像机在制作卷轴或是其他需要移动屏幕的游戏时比较有用,使用摄像机将会比移动节点来移动屏幕更加高效。 */ + export class Camera extends _RendererUnderSG { + /** !#en + The camera zoom ratio. + !#zh + 摄像机缩放比率 */ + zoomRatio: number; + /** !#en + Current active camera, the scene should only have one active camera at the same time. + !#zh + 当前激活的摄像机,场景中在同一时间内只能有一个激活的摄像机。 */ + static main: Camera; + /** + !#en + Add the specified target to camera. + !#zh + 将指定的节点添加到摄像机中。 + @param target target + */ + addTarget(target: Node): void; + /** + !#en + Remove the specified target from camera. + !#zh + 将指定的节点从摄像机中移除。 + @param target target + */ + removeTarget(target: Node): void; + /** + !#en + Get all camera targets. + !#zh + 获取所有摄像机目标节点。 + */ + getTargets(): [Node]; + /** + !#en + Returns the matrix that transform the node's (local) space coordinates into the camera's space coordinates. + !#zh + 返回一个将节点坐标系转换到摄像机坐标系下的矩阵 + @param node the node which should transform + */ + getNodeToCameraTransform(node: Node): AffineTransform; + /** + !#en + Conver a camera coordinates point to world coordinates. + !#zh + 将一个摄像机坐标系下的点转换到世界坐标系下。 + @param point the point which should transform + */ + getCameraToWorldPoint(point: Node): Vec2; + /** + !#en + Check whether the node is in the camera. + !#zh + 检测节点是否被此摄像机影响 + @param node the node which need to check + */ + containsNode(node: Node): boolean; + } + /** !#en The animation component is used to play back animations. + + Animation provide several events to register: + - play : Emit when begin playing animation + - stop : Emit when stop playing animation + - pause : Emit when pause animation + - resume : Emit when resume animation + - lastframe : If animation repeat count is larger than 1, emit when animation play to the last frame + - finished : Emit when finish playing animation + + !#zh Animation 组件用于播放动画。 + + Animation 提供了一系列可注册的事件: + - play : 开始播放时 + - stop : 停止播放时 + - pause : 暂停播放时 + - resume : 恢复播放时 + - lastframe : 假如动画循环次数大于 1,当动画播放到最后一帧时 + - finished : 动画播放完成时 */ + export class Animation extends Component implements EventTarget { + /** !#en Animation will play the default clip when start game. + !#zh 在勾选自动播放或调用 play() 时默认播放的动画剪辑。 */ + defaultClip: AnimationClip; + /** !#en Current played clip. + !#zh 当前播放的动画剪辑。 */ + currentClip: AnimationClip; + /** !#en Whether the animation should auto play the default clip when start game. + !#zh 是否在运行游戏后自动播放默认动画剪辑。 */ + playOnLoad: boolean; + /** + !#en Get all the clips used in this animation. + !#zh 获取动画组件上的所有动画剪辑。 + */ + getClips(): AnimationClip[]; + /** + !#en Plays an animation and stop other animations. + !#zh 播放指定的动画,并且停止当前正在播放动画。如果没有指定动画,则播放默认动画。 + @param name The name of animation to play. If no name is supplied then the default animation will be played. + @param startTime play an animation from startTime + + @example + ```js + var animCtrl = this.node.getComponent(cc.Animation); + animCtrl.play("linear"); + ``` + */ + play(name?: string, startTime?: number): AnimationState; + /** + !#en + Plays an additive animation, it will not stop other animations. + If there are other animations playing, then will play several animations at the same time. + !#zh 播放指定的动画(将不会停止当前播放的动画)。如果没有指定动画,则播放默认动画。 + @param name The name of animation to play. If no name is supplied then the default animation will be played. + @param startTime play an animation from startTime + + @example + ```js + // linear_1 and linear_2 at the same time playing. + var animCtrl = this.node.getComponent(cc.Animation); + animCtrl.playAdditive("linear_1"); + animCtrl.playAdditive("linear_2"); + ``` + */ + playAdditive(name?: string, startTime?: number): AnimationState; + /** + !#en Stops an animation named name. If no name is supplied then stops all playing animations that were started with this Animation.
+ Stopping an animation also Rewinds it to the Start. + !#zh 停止指定的动画。如果没有指定名字,则停止当前正在播放的动画。 + @param name The animation to stop, if not supplied then stops all playing animations. + */ + stop(name?: string): void; + /** + !#en Pauses an animation named name. If no name is supplied then pauses all playing animations that were started with this Animation. + !#zh 暂停当前或者指定的动画。如果没有指定名字,则暂停当前正在播放的动画。 + @param name The animation to pauses, if not supplied then pauses all playing animations. + */ + pause(name?: string): void; + /** + !#en Resumes an animation named name. If no name is supplied then resumes all paused animations that were started with this Animation. + !#zh 重新播放指定的动画,如果没有指定名字,则重新播放当前正在播放的动画。 + @param name The animation to resumes, if not supplied then resumes all paused animations. + */ + resume(name?: string): void; + /** + !#en Make an animation named name go to the specified time. If no name is supplied then make all animations go to the specified time. + !#zh 设置指定动画的播放时间。如果没有指定名字,则设置当前播放动画的播放时间。 + @param time The time to go to + @param name Specified animation name, if not supplied then make all animations go to the time. + */ + setCurrentTime(time?: number, name?: string): void; + /** + !#en Returns the animation state named name. If no animation with the specified name, the function will return null. + !#zh 获取当前或者指定的动画状态,如果未找到指定动画剪辑则返回 null。 + @param name name + */ + getAnimationState(name: string): AnimationState; + /** + !#en Adds a clip to the animation with name newName. If a clip with that name already exists it will be replaced with the new clip. + !#zh 添加动画剪辑,并且可以重新设置该动画剪辑的名称。 + @param clip the clip to add + @param newName newName + */ + addClip(clip: AnimationClip, newName?: string): AnimationState; + /** + !#en + Remove clip from the animation list. This will remove the clip and any animation states based on it. + If there are animation states depand on the clip are playing or clip is defaultClip, it will not delete the clip. + But if force is true, then will always remove the clip and any animation states based on it. If clip is defaultClip, defaultClip will be reset to null + !#zh + 从动画列表中移除指定的动画剪辑,
+ 如果依赖于 clip 的 AnimationState 正在播放或者 clip 是 defaultClip 的话,默认是不会删除 clip 的。 + 但是如果 force 参数为 true,则会强制停止该动画,然后移除该动画剪辑和相关的动画。这时候如果 clip 是 defaultClip,defaultClip 将会被重置为 null。 + @param clip clip + @param force If force is true, then will always remove the clip and any animation states based on it. + */ + removeClip(clip: AnimationClip, force?: boolean): void; + /** + !#en + Samples animations at the current state.
+ This is useful when you explicitly want to set up some animation state, and sample it once. + !#zh 对指定或当前动画进行采样。你可以手动将动画设置到某一个状态,然后采样一次。 + @param name name + */ + sample(name: string): void; + /** + !#en + Register animation event callback. + The event arguments will provide the AnimationState which emit the event. + When play an animation, will auto register the event callback to the AnimationState, and unregister the event callback from the AnimationState when animation stopped. + !#zh + 注册动画事件回调。 + 回调的事件里将会附上发送事件的 AnimationState。 + 当播放一个动画时,会自动将事件注册到对应的 AnimationState 上,停止播放时会将事件从这个 AnimationState 上取消注册。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + @param useCapture When set to true, the capture argument prevents callback + from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. + When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE. + Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET. + + @example + ```js + onPlay: function (event) { + var state = event.detail; // state instanceof cc.AnimationState + var type = event.type; // type === 'play'; + } + + // register event to all animation + animation.on('play', this.onPlay, this); + ``` + */ + on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void; + on(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void; + /** + !#en + Unregister animation event callback. + !#zh + 取消注册动画事件回调。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not. + If not specified, useCapture defaults to false. If a callback was registered twice, + one with capture and one without, each must be removed separately. Removal of a capturing callback + does not affect a non-capturing version of the same listener, and vice versa. + + @example + ```js + // unregister event to all animation + animation.off('play', this.onPlay, this); + ``` + */ + off(type: string, callback: Function, target?: any, useCapture?: boolean): void; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + @param useCapture When set to true, the capture argument prevents callback + from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. + When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE. + Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET. + + @example + ```js + node.once(cc.Node.EventType.TOUCH_END, function (event) { + cc.log("this is callback"); + }, node); + ``` + */ + once(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void; + once(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void; + /** + !#en + Dispatches an event into the event flow. + The event target is the EventTarget object upon which the dispatchEvent() method is called. + !#zh 分发事件到事件流中。 + @param event The Event object that is dispatched into the event flow + */ + dispatchEvent(event: Event): void; + /** + !#en + Send an event to this object directly, this method will not propagate the event to any other objects. + The event will be created from the supplied message, you can get the "detail" argument from event.detail. + !#zh + 该对象直接发送事件, 这种方法不会对事件传播到任何其他对象。 + @param message the message to send + @param detail whatever argument the message needs + */ + emit(message: string, detail?: any): void; + } + /** !#en Audio Source. + !#zh 音频源组件,能对音频剪辑。 */ + export class AudioSource extends Component { + /** !#en + Is the audio source playing (Read Only).
+ Note: isPlaying is not supported for Native platforms. + !#zh + 该音频剪辑是否正播放(只读)。
+ 注意:Native 平台暂时不支持 isPlaying。 */ + isPlaying: boolean; + /** !#en The clip of the audio source. + !#zh 默认要播放的音频剪辑。 */ + clip: AudioClip; + /** !#en The volume of the audio source. + !#zh 音频源的音量(0.0 ~ 1.0)。 */ + volume: number; + /** !#en Is the audio source mute? + !#zh 是否静音音频源。Mute 是设置音量为 0,取消静音是恢复原来的音量。 */ + mute: boolean; + /** !#en Is the audio source looping? + !#zh 音频源是否循环播放? */ + loop: boolean; + /** !#en If set to true, the audio source will automatically start playing on onLoad. + !#zh 如果设置为true,音频源将在 onLoad 时自动播放。 */ + playOnLoad: boolean; + /** + !#en Plays the clip. + !#zh 播放音频剪辑。 + */ + play(): void; + /** + !#en Stops the clip. + !#zh 停止当前音频剪辑。 + */ + stop(): void; + /** + !#en Pause the clip. + !#zh 暂停当前音频剪辑。 + */ + pause(): void; + /** + !#en Resume the clip. + !#zh 恢复播放。 + */ + resume(): void; + /** + !#en Rewind playing music. + !#zh 从头开始播放。 + */ + rewind(): void; + /** + !#en Get current time + !#zh 获取当前的播放时间 + */ + getCurrentTime(): void; + /** + !#en Set current time + !#zh 设置当前的播放时间 + @param time time + */ + setCurrentTime(time: number): void; + /** + !#en Get audio duration + !#zh 获取当前音频的长度 + */ + getDuration(): void; + } + /** !#en + This component will block all input events (mouse and touch) within the bounding box of the node, preventing the input from penetrating into the underlying node, typically for the background of the top UI.
+ This component does not have any API interface and can be added directly to the scene to take effect. + !#zh + 该组件将拦截所属节点 bounding box 内的所有输入事件(鼠标和触摸),防止输入穿透到下层节点,一般用于上层 UI 的背景。
+ 该组件没有任何 API 接口,直接添加到场景即可生效。 */ + export class BlockInputEvents extends Component { + } + /** !#en + Button has 4 Transition types + When Button state changed: + If Transition type is Button.Transition.NONE, Button will do nothing + If Transition type is Button.Transition.COLOR, Button will change target's color + If Transition type is Button.Transition.SPRITE, Button will change target Sprite's sprite + If Transition type is Button.Transition.SCALE, Button will change target node's scale + + Button will trigger 5 events: + Button.EVENT_TOUCH_DOWN + Button.EVENT_TOUCH_UP + Button.EVENT_HOVER_IN + Button.EVENT_HOVER_MOVE + Button.EVENT_HOVER_OUT + + !#zh + 按钮组件。可以被按下,或者点击。
+ + 按钮可以通过修改 Transition 来设置按钮状态过渡的方式:
+ -Button.Transition.NONE // 不做任何过渡
+ -Button.Transition.COLOR // 进行颜色之间过渡
+ -Button.Transition.SPRITE // 进行精灵之间过渡
+ -Button.Transition.SCALE // 进行缩放过渡
+ + 按钮可以绑定事件(但是必须要在按钮的 Node 上才能绑定事件):
+ // 以下事件可以在全平台上都触发
+ -cc.Node.EventType.TOUCH_START // 按下时事件
+ -cc.Node.EventType.TOUCH_Move // 按住移动后事件
+ -cc.Node.EventType.TOUCH_END // 按下后松开后事件
+ -cc.Node.EventType.TOUCH_CANCEL // 按下取消事件
+ // 以下事件只在 PC 平台上触发
+ -cc.Node.EventType.MOUSE_DOWN // 鼠标按下时事件
+ -cc.Node.EventType.MOUSE_MOVE // 鼠标按住移动后事件
+ -cc.Node.EventType.MOUSE_ENTER // 鼠标进入目标事件
+ -cc.Node.EventType.MOUSE_LEAVE // 鼠标离开目标事件
+ -cc.Node.EventType.MOUSE_UP // 鼠标松开事件
+ -cc.Node.EventType.MOUSE_WHEEL // 鼠标滚轮事件
*/ + export class Button extends Component { + /** !#en + Whether the Button is disabled. + If true, the Button will trigger event and do transition. + !#zh + 按钮事件是否被响应,如果为 false,则按钮将被禁用。 */ + interactable: boolean; + /** !#en When this flag is true, Button target sprite will turn gray when interactable is false. + !#zh 如果这个标记为 true,当 button 的 interactable 属性为 false 的时候,会使用内置 shader 让 button 的 target 节点的 sprite 组件变灰 */ + enableAutoGrayEffect: boolean; + /** !#en Transition type + !#zh 按钮状态改变时过渡方式。 */ + transition: Button.Transition; + /** !#en Normal state color. + !#zh 普通状态下按钮所显示的颜色。 */ + normalColor: Color; + /** !#en Pressed state color + !#zh 按下状态时按钮所显示的颜色。 */ + pressedColor: Color; + /** !#en Hover state color + !#zh 悬停状态下按钮所显示的颜色。 */ + hoverColor: Color; + /** !#en Disabled state color + !#zh 禁用状态下按钮所显示的颜色。 */ + disabledColor: Color; + /** !#en Color and Scale transition duration + !#zh 颜色过渡和缩放过渡时所需时间 */ + duration: number; + /** !#en When user press the button, the button will zoom to a scale. + The final scale of the button equals (button original scale * zoomScale) + !#zh 当用户点击按钮后,按钮会缩放到一个值,这个值等于 Button 原始 scale * zoomScale */ + zoomScale: number; + /** !#en Normal state sprite + !#zh 普通状态下按钮所显示的 Sprite 。 */ + normalSprite: SpriteFrame; + /** !#en Pressed state sprite + !#zh 按下状态时按钮所显示的 Sprite 。 */ + pressedSprite: SpriteFrame; + /** !#en Hover state sprite + !#zh 悬停状态下按钮所显示的 Sprite 。 */ + hoverSprite: SpriteFrame; + /** !#en Disabled state sprite + !#zh 禁用状态下按钮所显示的 Sprite 。 */ + disabledSprite: SpriteFrame; + /** !#en + Transition target. + When Button state changed: + If Transition type is Button.Transition.NONE, Button will do nothing + If Transition type is Button.Transition.COLOR, Button will change target's color + If Transition type is Button.Transition.SPRITE, Button will change target Sprite's sprite + !#zh + 需要过渡的目标。 + 当前按钮状态改变规则: + -如果 Transition type 选择 Button.Transition.NONE,按钮不做任何过渡。 + -如果 Transition type 选择 Button.Transition.COLOR,按钮会对目标颜色进行颜色之间的过渡。 + -如果 Transition type 选择 Button.Transition.Sprite,按钮会对目标 Sprite 进行 Sprite 之间的过渡。 */ + target: Node; + /** !#en If Button is clicked, it will trigger event's handler + !#zh 按钮的点击事件列表。 */ + clickEvents: Component.EventHandler[]; + } + /** !#zh: 作为 UI 根节点,为所有子节点提供视窗四边的位置信息以供对齐,另外提供屏幕适配策略接口,方便从编辑器设置。 + 注:由于本节点的尺寸会跟随屏幕拉伸,所以 anchorPoint 只支持 (0.5, 0.5),否则适配不同屏幕时坐标会有偏差。 */ + export class Canvas extends Component { + /** !#en Current active canvas, the scene should only have one active canvas at the same time. + !#zh 当前激活的画布组件,场景同一时间只能有一个激活的画布。 */ + static instance: Canvas; + /** !#en The desigin resolution for current scene. + !#zh 当前场景设计分辨率。 */ + designResolution: Size; + /** !#en TODO + !#zh: 是否优先将设计分辨率高度撑满视图高度。 */ + fitHeight: boolean; + /** !#en TODO + !#zh: 是否优先将设计分辨率宽度撑满视图宽度。 */ + fitWidth: boolean; + } + /** !#en + Base class for everything attached to Node(Entity).
+
+ NOTE: Not allowed to use construction parameters for Component's subclasses, + because Component is created by the engine. + !#zh + 所有附加到节点的基类。
+
+ 注意:不允许使用组件的子类构造参数,因为组件是由引擎创建的。 */ + export class Component extends Object { + /** !#en The node this component is attached to. A component is always attached to a node. + !#zh 该组件被附加到的节点。组件总会附加到一个节点。 */ + node: Node; + /** !#en The uuid for editor. + !#zh 组件的 uuid,用于编辑器。 */ + uuid: string; + /** !#en indicates whether this component is enabled or not. + !#zh 表示该组件自身是否启用。 */ + enabled: boolean; + /** !#en indicates whether this component is enabled and its node is also active in the hierarchy. + !#zh 表示该组件是否被启用并且所在的节点也处于激活状态。 */ + enabledInHierarchy: boolean; + /** !#en Returns a value which used to indicate the onLoad get called or not. + !#zh 返回一个值用来判断 onLoad 是否被调用过,不等于 0 时调用过,等于 0 时未调用。 */ + _isOnLoadCalled: number; + /** + !#en Update is called every frame, if the Component is enabled. + !#zh 如果该组件启用,则每帧调用 update。 + @param dt the delta time in seconds it took to complete the last frame + */ + protected update(dt: number): void; + /** + !#en LateUpdate is called every frame, if the Component is enabled. + !#zh 如果该组件启用,则每帧调用 LateUpdate。 + */ + protected lateUpdate(): void; + /** + !#en + When attaching to an active node or its node first activated. + onLoad is always called before any start functions, this allows you to order initialization of scripts. + !#zh + 当附加到一个激活的节点上或者其节点第一次激活时候调用。onLoad 总是会在任何 start 方法调用前执行,这能用于安排脚本的初始化顺序。 + */ + protected onLoad(): void; + /** + !#en + Called before all scripts' update if the Component is enabled the first time. + Usually used to initialize some logic which need to be called after all components' `onload` methods called. + !#zh + 如果该组件第一次启用,则在所有组件的 update 之前调用。通常用于需要在所有组件的 onLoad 初始化完毕后执行的逻辑。 + */ + protected start(): void; + /** + !#en Called when this component becomes enabled and its node is active. + !#zh 当该组件被启用,并且它的节点也激活时。 + */ + protected onEnable(): void; + /** + !#en Called when this component becomes disabled or its node becomes inactive. + !#zh 当该组件被禁用或节点变为无效时调用。 + */ + protected onDisable(): void; + /** + !#en Called when this component will be destroyed. + !#zh 当该组件被销毁时调用 + */ + protected onDestroy(): void; + protected onFocusInEditor(): void; + protected onLostFocusInEditor(): void; + /** + !#en Called to initialize the component or node’s properties when adding the component the first time or when the Reset command is used. This function is only called in editor. + !#zh 用来初始化组件或节点的一些属性,当该组件被第一次添加到节点上或用户点击了它的 Reset 菜单时调用。这个回调只会在编辑器下调用。 + */ + protected resetInEditor(): void; + /** + !#en Adds a component class to the node. You can also add component to node by passing in the name of the script. + !#zh 向节点添加一个组件类,你还可以通过传入脚本的名称来添加组件。 + @param typeOrClassName the constructor or the class name of the component to add + + @example + ```js + var sprite = node.addComponent(cc.Sprite); + var test = node.addComponent("Test"); + ``` + */ + addComponent(type: {new(): T}): T; + addComponent(className: string): any; + /** + !#en + Returns the component of supplied type if the node has one attached, null if it doesn't.
+ You can also get component in the node by passing in the name of the script. + !#zh + 获取节点上指定类型的组件,如果节点有附加指定类型的组件,则返回,如果没有则为空。
+ 传入参数也可以是脚本的名称。 + @param typeOrClassName typeOrClassName + + @example + ```js + // get sprite component. + var sprite = node.getComponent(cc.Sprite); + // get custom test calss. + var test = node.getComponent("Test"); + ``` + */ + getComponent(type: {prototype: T}): T; + getComponent(className: string): any; + /** + !#en Returns all components of supplied Type in the node. + !#zh 返回节点上指定类型的所有组件。 + @param typeOrClassName typeOrClassName + + @example + ```js + var sprites = node.getComponents(cc.Sprite); + var tests = node.getComponents("Test"); + ``` + */ + getComponents(type: {prototype: T}): T[]; + getComponents(className: string): any[]; + /** + !#en Returns the component of supplied type in any of its children using depth first search. + !#zh 递归查找所有子节点中第一个匹配指定类型的组件。 + @param typeOrClassName typeOrClassName + + @example + ```js + var sprite = node.getComponentInChildren(cc.Sprite); + var Test = node.getComponentInChildren("Test"); + ``` + */ + getComponentInChildren(type: {prototype: T}): T; + getComponentInChildren(className: string): any; + /** + !#en Returns the components of supplied type in self or any of its children using depth first search. + !#zh 递归查找自身或所有子节点中指定类型的组件 + @param typeOrClassName typeOrClassName + + @example + ```js + var sprites = node.getComponentsInChildren(cc.Sprite); + var tests = node.getComponentsInChildren("Test"); + ``` + */ + getComponentsInChildren(type: {prototype: T}): T[]; + getComponentsInChildren(className: string): any[]; + /** + !#en + If the component's bounding box is different from the node's, you can implement this method to supply + a custom axis aligned bounding box (AABB), so the editor's scene view can perform hit test properly. + !#zh + 如果组件的包围盒与节点不同,您可以实现该方法以提供自定义的轴向对齐的包围盒(AABB), + 以便编辑器的场景视图可以正确地执行点选测试。 + @param out_rect the Rect to receive the bounding box + */ + _getLocalBounds(out_rect: Rect): void; + /** + !#en + onRestore is called after the user clicks the Reset item in the Inspector's context menu or performs + an undo operation on this component.
+
+ If the component contains the "internal state", short for "temporary member variables which not included
+ in its CCClass properties", then you may need to implement this function.
+
+ The editor will call the getset accessors of your component to record/restore the component's state
+ for undo/redo operation. However, in extreme cases, it may not works well. Then you should implement
+ this function to manually synchronize your component's "internal states" with its public properties.
+ Once you implement this function, all the getset accessors of your component will not be called when
+ the user performs an undo/redo operation. Which means that only the properties with default value
+ will be recorded or restored by editor.
+
+ Similarly, the editor may failed to reset your component correctly in extreme cases. Then if you need
+ to support the reset menu, you should manually synchronize your component's "internal states" with its
+ properties in this function. Once you implement this function, all the getset accessors of your component
+ will not be called during reset operation. Which means that only the properties with default value
+ will be reset by editor. + + This function is only called in editor mode. + !#zh + onRestore 是用户在检查器菜单点击 Reset 时,对此组件执行撤消操作后调用的。
+
+ 如果组件包含了“内部状态”(不在 CCClass 属性中定义的临时成员变量),那么你可能需要实现该方法。
+
+ 编辑器执行撤销/重做操作时,将调用组件的 get set 来录制和还原组件的状态。 + 然而,在极端的情况下,它可能无法良好运作。
+ 那么你就应该实现这个方法,手动根据组件的属性同步“内部状态”。 + 一旦你实现这个方法,当用户撤销或重做时,组件的所有 get set 都不会再被调用。 + 这意味着仅仅指定了默认值的属性将被编辑器记录和还原。
+
+ 同样的,编辑可能无法在极端情况下正确地重置您的组件。
+ 于是如果你需要支持组件重置菜单,你需要在该方法中手工同步组件属性到“内部状态”。
+ 一旦你实现这个方法,组件的所有 get set 都不会在重置操作时被调用。 + 这意味着仅仅指定了默认值的属性将被编辑器重置。 +
+ 此方法仅在编辑器下会被调用。 + */ + onRestore(): void; + /** + !#en + Schedules a custom selector.
+ If the selector is already scheduled, then the interval parameter will be updated without scheduling it again. + !#zh + 调度一个自定义的回调函数。
+ 如果回调函数已调度,那么将不会重复调度它,只会更新时间间隔参数。 + @param callback The callback function + @param interval Tick interval in seconds. 0 means tick every frame. + @param repeat The selector will be executed (repeat + 1) times, you can use cc.macro.REPEAT_FOREVER for tick infinitely. + @param delay The amount of time that the first tick will wait before execution. + + @example + ```js + var timeCallback = function (dt) { + cc.log("time: " + dt); + } + this.schedule(timeCallback, 1); + ``` + */ + schedule(callback: Function, interval?: number, repeat?: number, delay?: number): void; + /** + !#en Schedules a callback function that runs only once, with a delay of 0 or larger. + !#zh 调度一个只运行一次的回调函数,可以指定 0 让回调函数在下一帧立即执行或者在一定的延时之后执行。 + @param callback A function wrapped as a selector + @param delay The amount of time that the first tick will wait before execution. + + @example + ```js + var timeCallback = function (dt) { + cc.log("time: " + dt); + } + this.scheduleOnce(timeCallback, 2); + ``` + */ + scheduleOnce(callback: Function, delay?: number): void; + /** + !#en Unschedules a custom callback function. + !#zh 取消调度一个自定义的回调函数。 + @param callback_fn A function wrapped as a selector + + @example + ```js + this.unschedule(_callback); + ``` + */ + unschedule(callback_fn: Function): void; + /** + !#en + unschedule all scheduled callback functions: custom callback functions, and the 'update' callback function.
+ Actions are not affected by this method. + !#zh 取消调度所有已调度的回调函数:定制的回调函数以及 'update' 回调函数。动作不受此方法影响。 + + @example + ```js + this.unscheduleAllCallbacks(); + ``` + */ + unscheduleAllCallbacks(): void; + } + /** !#en cc.EditBox is a component for inputing text, you can use it to gather small amounts of text from users. + !#zh EditBox 组件,用于获取用户的输入文本。 */ + export class EditBox extends _RendererUnderSG { + /** !#en Input string of EditBox. + !#zh 输入框的初始输入内容,如果为空则会显示占位符的文本。 */ + string: string; + /** !#en The background image of EditBox. + !#zh 输入框的背景图片 */ + backgroundImage: SpriteFrame; + /** !#en + The return key type of EditBox. + Note: it is meaningless for web platforms and desktop platforms. + !#zh + 指定移动设备上面回车按钮的样式。 + 注意:这个选项对 web 平台与 desktop 平台无效。 */ + returnType: EditBox.KeyboardReturnType; + /** !#en Set the input flags that are to be applied to the EditBox. + !#zh 指定输入标志位,可以指定输入方式为密码或者单词首字母大写。 */ + inputFlag: EditBox.InputFlag; + /** !#en + Set the input mode of the edit box. + If you pass ANY, it will create a multiline EditBox. + !#zh + 指定输入模式: ANY表示多行输入,其它都是单行输入,移动平台上还可以指定键盘样式。 */ + inputMode: EditBox.InputMode; + /** !#en Font size of the input text. + !#zh 输入框文本的字体大小 */ + fontSize: number; + /** !#en Change the lineHeight of displayed text. + !#zh 输入框文本的行高。 */ + lineHeight: number; + /** !#en Font color of the input text. + !#zh 输入框文本的颜色。 */ + fontColor: Color; + /** !#en The display text of placeholder. + !#zh 输入框占位符的文本内容。 */ + placeholder: string; + /** !#en The font size of placeholder. + !#zh 输入框占位符的字体大小。 */ + placeholderFontSize: number; + /** !#en The font color of placeholder. + !#zh 输入框最大允许输入的字符个数。 */ + placeholderFontColor: Color; + /** !#en The maximize input length of EditBox. + - If pass a value less than 0, it won't limit the input number of characters. + - If pass 0, it doesn't allow input any characters. + !#zh 输入框最大允许输入的字符个数。 + - 如果值为小于 0 的值,则不会限制输入字符个数。 + - 如果值为 0,则不允许用户进行任何输入。 */ + maxLength: number; + /** !#en The input is always visible and be on top of the game view. + !zh 输入框总是可见,并且永远在游戏视图的上面 + Note: only available on Web at the moment. */ + stayOnTop: boolean; + /** !#en Set the tabIndex of the DOM input element, only useful on Web. + !#zh 修改 DOM 输入元素的 tabIndex,这个属性只有在 Web 上面修改有意义。 */ + tabIndex: number; + /** !#en The event handler to be called when EditBox began to edit text. + !#zh 开始编辑文本输入框触发的事件回调。 */ + editingDidBegan: Component.EventHandler[]; + /** !#en The event handler to be called when EditBox text changes. + !#zh 编辑文本输入框时触发的事件回调。 */ + textChanged: Component.EventHandler[]; + /** !#en The event handler to be called when EditBox edit ends. + !#zh 结束编辑文本输入框时触发的事件回调。 */ + editingDidEnded: Component.EventHandler[]; + /** !#en The event handler to be called when return key is pressed. Windows is not supported. + !#zh 当用户按下回车按键时的事件回调,目前不支持 windows 平台 */ + editingReturn: Component.EventHandler[]; + /** + !#en Let the EditBox get focus, only valid when stayOnTop is true. + !#zh 让当前 EditBox 获得焦点,只有在 stayOnTop 为 true 的时候设置有效 + Note: only available on Web at the moment. + */ + setFocus(): void; + /** + !#en Determine whether EditBox is getting focus or not. + !#zh 判断 EditBox 是否获得了焦点 + Note: only available on Web at the moment. + */ + isFocused(): void; + /** + !#en if you don't need the EditBox and it isn't in any running Scene, you should + call the destroy method on this component or the associated node explicitly. + Otherwise, the created DOM element won't be removed from web page. + !#zh + 如果你不再使用 EditBox,并且组件未添加到场景中,那么你必须手动对组件或所在节点调用 destroy。 + 这样才能移除网页上的 DOM 节点,避免 Web 平台内存泄露。 + + @example + ```js + editbox.node.parent = null; // or editbox.node.removeFromParent(false); + // when you don't need editbox anymore + editbox.node.destroy(); + ``` + */ + destroy(): boolean; + } + /** !#en The Label Component. + !#zh 文字标签组件 */ + export class Label extends _RendererUnderSG { + /** !#en Content string of label. + !#zh 标签显示的文本内容。 */ + string: string; + /** !#en Horizontal Alignment of label. + !#zh 文本内容的水平对齐方式。 */ + horizontalAlign: Label.HorizontalAlign; + /** !#en Vertical Alignment of label. + !#zh 文本内容的垂直对齐方式。 */ + verticalAlign: Label.VerticalAlign; + /** !#en The actual rendering font size in shrink mode + !#zh SHRINK 模式下面文本实际渲染的字体大小 */ + actualFontSize: number; + /** !#en Font size of label. + !#zh 文本字体大小。 */ + fontSize: number; + /** !#en Font family of label, only take effect when useSystemFont property is true. + !#zh 文本字体名称, 只在 useSystemFont 属性为 true 的时候生效。 */ + fontFamily: string; + /** !#en Line Height of label. + !#zh 文本行高。 */ + lineHeight: number; + /** !#en Overflow of label. + !#zh 文字显示超出范围时的处理方式。 */ + overflow: Label.Overflow; + /** !#en Whether auto wrap label when string width is large than label width. + !#zh 是否自动换行。 */ + enableWrapText: boolean; + /** !#en The font of label. + !#zh 文本字体。 */ + font: Font; + /** !#en Whether use system font name or not. + !#zh 是否使用系统字体。 */ + isSystemFontUsed: boolean; + } + /** !#en Outline effect used to change the display, only used for TTF font + !#zh 描边效果组件,用于字体描边,只能用于系统字体 */ + export class LabelOutline extends Component { + /** !#en Change the outline color + !#zh 改变描边的颜色 */ + color: Color; + /** !#en Change the outline width + !#zh 改变描边的宽度 */ + width: number; + } + /** !#en + The Layout is a container component, use it to arrange child elements easily.
+ Note:
+ 1.Scaling and rotation of child nodes are not considered.
+ 2.After setting the Layout, the results need to be updated until the next frame, + unless you manually call {{#crossLink "Layout/updateLayout:method"}}{{/crossLink}}。 + !#zh + Layout 组件相当于一个容器,能自动对它的所有子节点进行统一排版。
+ 注意:
+ 1.不会考虑子节点的缩放和旋转。
+ 2.对 Layout 设置后结果需要到下一帧才会更新,除非你设置完以后手动调用 {{#crossLink "Layout/updateLayout:method"}}{{/crossLink}}。 */ + export class Layout extends Component { + /** !#en The layout type. + !#zh 布局类型 */ + type: Layout.Type; + /** !#en + The are three resize modes for Layout. + None, resize Container and resize children. + !#zh 缩放模式 */ + resizeMode: Layout.ResizeMode; + /** !#en The cell size for grid layout. + !#zh 每个格子的大小,只有布局类型为 GRID 的时候才有效。 */ + cellSize: Size; + /** !#en + The start axis for grid layout. If you choose horizontal, then children will layout horizontally at first, + and then break line on demand. Choose vertical if you want to layout vertically at first . + !#zh 起始轴方向类型,可进行水平和垂直布局排列,只有布局类型为 GRID 的时候才有效。 */ + startAxis: Layout.AxisDirection; + /** !#en The left padding of layout, it only effect the layout in one direction. + !#zh 容器内左边距,只会在一个布局方向上生效。 */ + paddingLeft: number; + /** !#en The right padding of layout, it only effect the layout in one direction. + !#zh 容器内右边距,只会在一个布局方向上生效。 */ + paddingRight: number; + /** !#en The top padding of layout, it only effect the layout in one direction. + !#zh 容器内上边距,只会在一个布局方向上生效。 */ + paddingTop: number; + /** !#en The bottom padding of layout, it only effect the layout in one direction. + !#zh 容器内下边距,只会在一个布局方向上生效。 */ + paddingBottom: number; + /** !#en The distance in x-axis between each element in layout. + !#zh 子节点之间的水平间距。 */ + spacingX: number; + /** !#en The distance in y-axis between each element in layout. + !#zh 子节点之间的垂直间距。 */ + spacingY: number; + /** !#en + Only take effect in Vertical layout mode. + This option changes the start element's positioning. + !#zh 垂直排列子节点的方向。 */ + verticalDirection: Layout.VerticalDirection; + /** !#en + Only take effect in Horizontal layout mode. + This option changes the start element's positioning. + !#zh 水平排列子节点的方向。 */ + horizontalDirection: Layout.HorizontalDirection; + /** + !#en Perform the layout update + !#zh 立即执行更新布局 + + @example + ```js + layout.type = cc.Layout.HORIZONTAL; + layout.node.addChild(childNode); + cc.log(childNode.x); // not yet changed + layout.updateLayout(); + cc.log(childNode.x); // changed + ``` + */ + updateLayout(): void; + /** !#en The padding of layout, it effects the layout in four direction. + !#zh 容器内边距,该属性会在四个布局方向上生效。 */ + padding: number; + } + /** !#en The Mask Component + !#zh 遮罩组件 */ + export class Mask extends _RendererInSG { + /** !#en The mask type. + !#zh 遮罩类型 */ + type: Mask.Type; + /** !#en The mask image + !#zh 遮罩所需要的贴图 */ + spriteFrame: SpriteFrame; + /** !#en + The alpha threshold.(Not supported Canvas Mode)
+ The content is drawn only where the stencil have pixel with alpha greater than the alphaThreshold.
+ Should be a float between 0 and 1.
+ This default to 1 (so alpha test is disabled). + !#zh + Alpha 阈值(不支持 Canvas 模式)
+ 只有当模板的像素的 alpha 大于 alphaThreshold 时,才会绘制内容。
+ 该数值 0 ~ 1 之间的浮点数,默认值为 1(因此禁用 alpha) */ + alphaThreshold: number; + /** !#en Reverse mask (Not supported Canvas Mode) + !#zh 反向遮罩(不支持 Canvas 模式) */ + inverted: boolean; + /** !#en The segements for ellipse mask. + !#zh 椭圆遮罩的曲线细分数 */ + segements: number; + } + /** !#en The PageView control + !#zh 页面视图组件 */ + export class PageView extends ScrollView { + /** !#en Specify the size type of each page in PageView. + !#zh 页面视图中每个页面大小类型 */ + sizeMode: PageView.SizeMode; + /** !#en The page view direction + !#zh 页面视图滚动类型 */ + direction: PageView.Direction; + /** !#en + The scroll threshold value, when drag exceeds this value, + release the next page will automatically scroll, less than the restore + !#zh 滚动临界值,默认单位百分比,当拖拽超出该数值时,松开会自动滚动下一页,小于时则还原。 */ + scrollThreshold: number; + /** !#en + Auto page turning velocity threshold. When users swipe the PageView quickly, + it will calculate a velocity based on the scroll distance and time, + if the calculated velocity is larger than the threshold, then it will trigger page turning. + !#zh + 快速滑动翻页临界值。 + 当用户快速滑动时,会根据滑动开始和结束的距离与时间计算出一个速度值, + 该值与此临界值相比较,如果大于临界值,则进行自动翻页。 */ + autoPageTurningThreshold: number; + /** !#en Change the PageTurning event timing of PageView. + !#zh 设置 PageView PageTurning 事件的发送时机。 */ + pageTurningEventTiming: number; + /** !#en The Page View Indicator + !#zh 页面视图指示器组件 */ + indicator: PageViewIndicator; + /** !#en The time required to turn over a page. unit: second + !#zh 每个页面翻页时所需时间。单位:秒 */ + pageTurningSpeed: number; + /** !#en PageView events callback + !#zh 滚动视图的事件回调函数 */ + pageEvents: Component.EventHandler[]; + /** + !#en Returns current page index + !#zh 返回当前页面索引 + */ + getCurrentPageIndex(): number; + /** + !#en Set current page index + !#zh 设置当前页面索引 + @param index index + */ + setCurrentPageIndex(index: number): void; + /** + !#en Returns all pages of pageview + !#zh 返回视图中的所有页面 + */ + getPages(): Node[]; + /** + !#en At the end of the current page view to insert a new view + !#zh 在当前页面视图的尾部插入一个新视图 + @param page page + */ + addPage(page: Node): void; + /** + !#en Inserts a page in the specified location + !#zh 将页面插入指定位置中 + @param page page + @param index index + */ + insertPage(page: Node, index: number): void; + /** + !#en Removes a page from PageView. + !#zh 移除指定页面 + @param page page + */ + removePage(page: Node): void; + /** + !#en Removes a page at index of PageView. + !#zh 移除指定下标的页面 + @param index index + */ + removePageAtIndex(index: number): void; + /** + !#en Removes all pages from PageView + !#zh 移除所有页面 + */ + removeAllPages(): void; + /** + !#en Scroll PageView to index. + !#zh 滚动到指定页面 + @param idx index of page. + @param timeInSecond scrolling time + */ + scrollToPage(idx: number, timeInSecond: number): void; + } + /** !#en The Page View Indicator Component + !#zh 页面视图每页标记组件 */ + export class PageViewIndicator extends Component { + /** !#en The spriteFrame for each element. + !#zh 每个页面标记显示的图片 */ + spriteFrame: SpriteFrame; + /** !#en The location direction of PageViewIndicator. + !#zh 页面标记摆放方向 */ + direction: PageViewIndicator.Direction; + /** !#en The cellSize for each element. + !#zh 每个页面标记的大小 */ + cellSize: Size; + /** !#en The distance between each element. + !#zh 每个页面标记之间的边距 */ + spacing: number; + /** + !#en Set Page View + !#zh 设置页面视图 + @param target target + */ + setPageView(target: PageView): void; + } + /** !#en + Visual indicator of progress in some operation. + Displays a bar to the user representing how far the operation has progressed. + !#zh + 进度条组件,可用于显示加载资源时的进度。 */ + export class ProgressBar extends Component { + /** !#en The targeted Sprite which will be changed progressively. + !#zh 用来显示进度条比例的 Sprite 对象。 */ + barSprite: Sprite; + /** !#en The progress mode, there are two modes supported now: horizontal and vertical. + !#zh 进度条的模式 */ + mode: ProgressBar.Mode; + /** !#en The total width or height of the bar sprite. + !#zh 进度条实际的总长度 */ + totalLength: number; + /** !#en The current progress of the bar sprite. The valid value is between 0-1. + !#zh 当前进度值,该数值的区间是 0-1 之间。 */ + progress: number; + /** !#en Whether reverse the progress direction of the bar sprite. + !#zh 进度条是否进行反方向变化。 */ + reverse: boolean; + } + /** Rendering component in scene graph. + Maintains a node which will be the scene graph of component's Node. */ + export class _RendererInSG extends _SGComponent { + } + /** The base rendering component which will attach a leaf node to the cocos2d scene graph. */ + export class _RendererUnderSG extends _SGComponent { + } + /** !#en The RichText Component. + !#zh 富文本组件 */ + export class RichText extends Component { + /** !#en Content string of RichText. + !#zh 富文本显示的文本内容。 */ + string: string; + /** !#en Horizontal Alignment of each line in RichText. + !#zh 文本内容的水平对齐方式。 */ + horizontalAlign: TextAlignment; + /** !#en Font size of RichText. + !#zh 富文本字体大小。 */ + fontSize: number; + /** !#en Custom TTF font of RichText + !#zh 富文本定制字体 */ + font: cc.TTFFont; + /** !#en The maximize width of the RichText + !#zh 富文本的最大宽度 */ + maxWidth: number; + /** !#en Line Height of RichText. + !#zh 富文本行高。 */ + lineHeight: number; + /** !#en The image atlas for the img tag. For each src value in the img tag, there should be a valid spriteFrame in the image atlas. + !#zh 对于 img 标签里面的 src 属性名称,都需要在 imageAtlas 里面找到一个有效的 spriteFrame,否则 img tag 会判定为无效。 */ + imageAtlas: SpriteAtlas; + /** !#en + Once checked, the RichText will block all input events (mouse and touch) within + the bounding box of the node, preventing the input from penetrating into the underlying node. + !#zh + 选中此选项后,RichText 将阻止节点边界框中的所有输入事件(鼠标和触摸),从而防止输入事件穿透到底层节点。 */ + handleTouchEvent: boolean; + } + /** The base class for all rendering component in scene graph. + + You should override: + - _createSgNode + - _initSgNode */ + export class _SGComponent extends Component { + } + /** !#en + The Scrollbar control allows the user to scroll an image or other view that is too large to see completely + !#zh 滚动条组件 */ + export class Scrollbar extends Component { + /** !#en The "handle" part of the scrollbar. + !#zh 作为当前滚动区域位置显示的滑块 Sprite。 */ + handle: Sprite; + /** !#en The direction of scrollbar. + !#zh ScrollBar 的滚动方向。 */ + direction: Scrollbar.Direction; + /** !#en Whether enable auto hide or not. + !#zh 是否在没有滚动动作时自动隐藏 ScrollBar。 */ + enableAutoHide: boolean; + /** !#en + The time to hide scrollbar when scroll finished. + Note: This value is only useful when enableAutoHide is true. + !#zh + 没有滚动动作后经过多久会自动隐藏。 + 注意:只要当 “enableAutoHide” 为 true 时,才有效。 */ + autoHideTime: number; + } + /** !#en + Layout container for a view hierarchy that can be scrolled by the user, + allowing it to be larger than the physical display. + + !#zh + 滚动视图组件 */ + export class ScrollView extends Component { + /** !#en This is a reference to the UI element to be scrolled. + !#zh 可滚动展示内容的节点。 */ + content: Node; + /** !#en Enable horizontal scroll. + !#zh 是否开启水平滚动。 */ + horizontal: boolean; + /** !#en Enable vertical scroll. + !#zh 是否开启垂直滚动。 */ + vertical: boolean; + /** !#en When inertia is set, the content will continue to move when touch ended. + !#zh 是否开启滚动惯性。 */ + inertia: boolean; + /** !#en + It determines how quickly the content stop moving. A value of 1 will stop the movement immediately. + A value of 0 will never stop the movement until it reaches to the boundary of scrollview. + !#zh + 开启惯性后,在用户停止触摸后滚动多快停止,0表示永不停止,1表示立刻停止。 */ + brake: number; + /** !#en When elastic is set, the content will be bounce back when move out of boundary. + !#zh 是否允许滚动内容超过边界,并在停止触摸后回弹。 */ + elastic: boolean; + /** !#en The elapse time of bouncing back. A value of 0 will bounce back immediately. + !#zh 回弹持续的时间,0 表示将立即反弹。 */ + bounceDuration: number; + /** !#en The horizontal scrollbar reference. + !#zh 水平滚动的 ScrollBar。 */ + horizontalScrollBar: Scrollbar; + /** !#en The vertical scrollbar reference. + !#zh 垂直滚动的 ScrollBar。 */ + verticalScrollBar: Scrollbar; + /** !#en Scrollview events callback + !#zh 滚动视图的事件回调函数 */ + scrollEvents: Component.EventHandler[]; + /** !#en If cancelInnerEvents is set to true, the scroll behavior will cancel touch events on inner content nodes + It's set to true by default. + !#zh 如果这个属性被设置为 true,那么滚动行为会取消子节点上注册的触摸事件,默认被设置为 true。 + 注意,子节点上的 touchstart 事件仍然会触发,触点移动距离非常短的情况下 touchmove 和 touchend 也不会受影响。 */ + cancelInnerEvents: boolean; + /** + !#en Scroll the content to the bottom boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图底部。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the bottom boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the bottom of the view. + scrollView.scrollToBottom(0.1); + ``` + */ + scrollToBottom(timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the top boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图顶部。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the top boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the top of the view. + scrollView.scrollToTop(0.1); + ``` + */ + scrollToTop(timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the left boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图左边。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the left boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the left of the view. + scrollView.scrollToLeft(0.1); + ``` + */ + scrollToLeft(timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the right boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图右边。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the right boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the right of the view. + scrollView.scrollToRight(0.1); + ``` + */ + scrollToRight(timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the top left boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图左上角。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the top left boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the upper left corner of the view. + scrollView.scrollToTopLeft(0.1); + ``` + */ + scrollToTopLeft(timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the top right boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图右上角。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the top right boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the top right corner of the view. + scrollView.scrollToTopRight(0.1); + ``` + */ + scrollToTopRight(timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the bottom left boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图左下角。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the bottom left boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the lower left corner of the view. + scrollView.scrollToBottomLeft(0.1); + ``` + */ + scrollToBottomLeft(timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the bottom right boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图右下角。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the bottom right boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the lower right corner of the view. + scrollView.scrollToBottomRight(0.1); + ``` + */ + scrollToBottomRight(timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll with an offset related to the ScrollView's top left origin, if timeInSecond is omitted, then it will jump to the + specific offset immediately. + !#zh 视图内容在规定时间内将滚动到 ScrollView 相对左上角原点的偏移位置, 如果 timeInSecond参数不传,则立即滚动到指定偏移位置。 + @param offset A Vec2, the value of which each axis between 0 and maxScrollOffset + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the specific offset of ScrollView immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to middle position in 0.1 second in x-axis + var maxScrollOffset = this.getMaxScrollOffset(); + scrollView.scrollToOffset(cc.p(maxScrollOffset.x / 2, 0), 0.1); + ``` + */ + scrollToOffset(offset: Vec2, timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Get the positive offset value corresponds to the content's top left boundary. + !#zh 获取滚动视图相对于左上角原点的当前滚动偏移 + */ + getScrollOffset(): Vec2; + /** + !#en Get the maximize available scroll offset + !#zh 获取滚动视图最大可以滚动的偏移量 + */ + getMaxScrollOffset(): Vec2; + /** + !#en Scroll the content to the horizontal percent position of ScrollView. + !#zh 视图内容在规定时间内将滚动到 ScrollView 水平方向的百分比位置上。 + @param percent A value between 0 and 1. + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the horizontal percent position of ScrollView immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to middle position. + scrollView.scrollToBottomRight(0.5, 0.1); + ``` + */ + scrollToPercentHorizontal(percent: number, timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the percent position of ScrollView in any direction. + !#zh 视图内容在规定时间内进行垂直方向和水平方向的滚动,并且滚动到指定百分比位置上。 + @param anchor A point which will be clamp between cc.p(0,0) and cc.p(1,1). + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the percent position of ScrollView immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Vertical scroll to the bottom of the view. + scrollView.scrollTo(cc.p(0, 1), 0.1); + + // Horizontal scroll to view right. + scrollView.scrollTo(cc.p(1, 0), 0.1); + ``` + */ + scrollTo(anchor: Vec2, timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the vertical percent position of ScrollView. + !#zh 视图内容在规定时间内滚动到 ScrollView 垂直方向的百分比位置上。 + @param percent A value between 0 and 1. + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the vertical percent position of ScrollView immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + // Scroll to middle position. + scrollView.scrollToPercentVertical(0.5, 0.1); + */ + scrollToPercentVertical(percent: number, timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Stop auto scroll immediately + !#zh 停止自动滚动, 调用此 API 可以让 Scrollview 立即停止滚动 + */ + stopAutoScroll(): void; + /** + !#en Modify the content position. + !#zh 设置当前视图内容的坐标点。 + @param position The position in content's parent space. + */ + setContentPosition(position: Vec2): void; + /** + !#en Query the content's position in its parent space. + !#zh 获取当前视图内容的坐标点。 + */ + getContentPosition(): Position; + /** + !#en Query whether the user is currently dragging the ScrollView to scroll it + !#zh 用户是否在拖拽当前滚动视图 + */ + isScrolling(): boolean; + /** + !#en Query whether the ScrollView is currently scrolling because of a bounceback or inertia slowdown. + !#zh 当前滚动视图是否在惯性滚动 + */ + isAutoScrolling(): boolean; + } + /** !#en The Slider Control + !#zh 滑动器组件 */ + export class Slider extends Component { + /** !#en The "handle" part of the slider + !#zh 滑动器滑块按钮部件 */ + handle: Button; + /** !#en The slider direction + !#zh 滑动器方向 */ + direction: Slider.Direction; + /** !#en The current progress of the slider. The valid value is between 0-1 + !#zh 当前进度值,该数值的区间是 0-1 之间 */ + progress: number; + /** !#en The slider events callback + !#zh 滑动器组件事件回调函数 */ + slideEvents: Component.EventHandler[]; + } + /** !#en Renders a sprite in the scene. + !#zh 该组件用于在场景中渲染精灵。 */ + export class Sprite extends _RendererUnderSG { + /** !#en The sprite frame of the sprite. + !#zh 精灵的精灵帧 */ + spriteFrame: SpriteFrame; + /** !#en The sprite render type. + !#zh 精灵渲染类型 */ + type: Sprite.SpriteType; + /** !#en + The fill type, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”. + !#zh + 精灵填充类型,仅渲染类型设置为 cc.Sprite.SpriteType.FILLED 时有效。 */ + fillType: Sprite.FillType; + /** !#en + The fill Center, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”. + !#zh + 填充中心点,仅渲染类型设置为 cc.Sprite.SpriteType.FILLED 时有效。 */ + fillCenter: Vec2; + /** !#en + The fill Start, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”. + !#zh + 填充起始点,仅渲染类型设置为 cc.Sprite.SpriteType.FILLED 时有效。 */ + fillStart: number; + /** !#en + The fill Range, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”. + !#zh + 填充范围,仅渲染类型设置为 cc.Sprite.SpriteType.FILLED 时有效。 */ + fillRange: number; + /** !#en specify the frame is trimmed or not. + !#zh 是否使用裁剪模式 */ + trim: boolean; + /** !#en specify the source Blend Factor. + !#zh 指定原图的混合模式 */ + srcBlendFactor: BlendFactor; + /** !#en specify the destination Blend Factor. + !#zh 指定目标的混合模式 */ + dstBlendFactor: BlendFactor; + /** !#en specify the size tracing mode. + !#zh 精灵尺寸调整模式 */ + sizeMode: Sprite.SizeMode; + /** + !#en Change the left sprite's cap inset. + !#zh 设置精灵左边框-用于九宫格。 + @param insetLeft The values to use for the cap inset. + + @example + ```js + sprite.setInsetLeft(5); + ``` + */ + setInsetLeft(insetLeft: number): void; + /** + !#en Query the left sprite's cap inset. + !#zh 获取精灵左边框 + + @example + ```js + var insetLeft = sprite.getInsetLeft(); + cc.log("Inset Left:" + insetLeft); + ``` + */ + getInsetLeft(): number; + /** + !#en Change the top sprite's cap inset. + !#zh 设置精灵上边框-用于九宫格。 + @param insetTop The values to use for the cap inset. + + @example + ```js + sprite.setInsetTop(5); + ``` + */ + setInsetTop(insetTop: number): void; + /** + !#en Query the top sprite's cap inset. + !#zh 获取精灵上边框。 + + @example + ```js + var insetTop = sprite.getInsetTop(); + cc.log("Inset Top:" + insetTop); + ``` + */ + getInsetTop(): number; + /** + !#en Change the right sprite's cap inset. + !#zh 设置精灵右边框-用于九宫格。 + @param insetRight The values to use for the cap inset. + + @example + ```js + sprite.setInsetRight(5); + ``` + */ + setInsetRight(insetRight: number): void; + /** + !#en Query the right sprite's cap inset. + !#zh 获取精灵右边框。 + + @example + ```js + var insetRight = sprite.getInsetRight(); + cc.log("Inset Right:" + insetRight); + ``` + */ + getInsetRight(): number; + /** + !#en Change the bottom sprite's cap inset. + !#zh 设置精灵下边框-用于九宫格。 + @param bottomInset The values to use for the cap inset. + + @example + ```js + sprite.setInsetBottom(5); + ``` + */ + setInsetBottom(bottomInset: number): void; + /** + !#en Query the bottom sprite's cap inset. + !#zh 获取精灵下边框。 + + @example + ```js + var insetBottom = sprite.getInsetBottom(); + cc.log("Inset Bottom:" + insetBottom); + ``` + */ + getInsetBottom(): number; + } + /** !#en A distortion used to change the rendering of simple sprite.If will take effect after sprite component is added. + !#zh 扭曲效果组件,用于改变SIMPLE类型sprite的渲染,只有当sprite组件已经添加后,才能起作用. */ + export class SpriteDistortion extends Component { + /** !#en Change the UV offset for distortion rendering. + !#zh 在渲染时改变UV的整体偏移. */ + offset: Vec2; + /** !#en Change the UV scale for distortion rendering. + !#zh 在渲染时改变UV的寻址系数 */ + tiling: Vec2; + } + /** !#en The toggle component is a CheckBox, when it used together with a ToggleGroup, it + could be treated as a RadioButton. + !#zh Toggle 是一个 CheckBox,当它和 ToggleGroup 一起使用的时候,可以变成 RadioButton。 */ + export class Toggle extends Button { + /** !#en When this value is true, the check mark component will be enabled, otherwise + the check mark component will be disabled. + !#zh 如果这个设置为 true,则 check mark 组件会处于 enabled 状态,否则处于 disabled 状态。 */ + isChecked: boolean; + /** !#en The toggle group which the toggle belongs to, when it is null, the toggle is a CheckBox. + Otherwise, the toggle is a RadioButton. + !#zh Toggle 所属的 ToggleGroup,这个属性是可选的。如果这个属性为 null,则 Toggle 是一个 CheckBox, + 否则,Toggle 是一个 RadioButton。 */ + toggleGroup: ToggleGroup; + /** !#en The image used for the checkmark. + !#zh Toggle 处于选中状态时显示的图片 */ + checkMark: Sprite; + /** !#en If Toggle is clicked, it will trigger event's handler + !#zh Toggle 按钮的点击事件列表。 */ + checkEvents: Component.EventHandler[]; + /** + !#en Make the toggle button checked. + !#zh 使 toggle 按钮处于选中状态 + */ + check(): void; + /** + !#en Make the toggle button unchecked. + !#zh 使 toggle 按钮处于未选中状态 + */ + uncheck(): void; + } + /** !#en ToggleContainer is not a visiable UI component but a way to modify the behavior of a set of Toggles.
+ Toggles that belong to the same group could only have one of them to be switched on at a time.
+ Note: All the first layer child node containing the toggle component will auto be added to the container + !#zh ToggleContainer 不是一个可见的 UI 组件,它可以用来修改一组 Toggle 组件的行为。
+ 当一组 Toggle 属于同一个 ToggleContainer 的时候,任何时候只能有一个 Toggle 处于选中状态。
+ 注意:所有包含 Toggle 组件的一级子节点都会自动被添加到该容器中 */ + export class ToggleContainer extends Component { + /** !#en If this setting is true, a toggle could be switched off and on when pressed. + If it is false, it will make sure there is always only one toggle could be switched on + and the already switched on toggle can't be switched off. + !#zh 如果这个设置为 true, 那么 toggle 按钮在被点击的时候可以反复地被选中和未选中。 */ + allowSwitchOff: boolean; + /** !#en Read only property, return the toggle items array reference managed by ToggleContainer. + !#zh 只读属性,返回 ToggleContainer 管理的 toggle 数组引用 */ + toggleItems: Toggle[]; + } + /** !#en ToggleGroup is not a visiable UI component but a way to modify the behavior of a set of Toggles. + Toggles that belong to the same group could only have one of them to be switched on at a time. + !#zh ToggleGroup 不是一个可见的 UI 组件,它可以用来修改一组 Toggle 组件的行为。当一组 Toggle 属于同一个 ToggleGroup 的时候, + 任何时候只能有一个 Toggle 处于选中状态。 */ + export class ToggleGroup extends Component { + /** !#en If this setting is true, a toggle could be switched off and on when pressed. + If it is false, it will make sure there is always only one toggle could be switched on + and the already switched on toggle can't be switched off. + !#zh 如果这个设置为 true, 那么 toggle 按钮在被点击的时候可以反复地被选中和未选中。 */ + allowSwitchOff: boolean; + /** !#en Read only property, return the toggle items array reference managed by toggleGroup. + !#zh 只读属性,返回 toggleGroup 管理的 toggle 数组引用 */ + toggleItems: any[]; + } + /** !#en cc.VideoPlayer is a component for playing videos, you can use it for showing videos in your game. + !#zh Video 组件,用于在游戏中播放视频 */ + export class VideoPlayer extends _RendererUnderSG { + /** !#en The resource type of videoplayer, REMOTE for remote url and LOCAL for local file path. + !#zh 视频来源:REMOTE 表示远程视频 URL,LOCAL 表示本地视频地址。 */ + resourceType: VideoPlayer.ResourceType; + /** !#en The remote URL of video. + !#zh 远程视频的 URL */ + remoteURL: string; + /** !#en The local video full path. + !#zh 本地视频的 URL */ + clip: string; + /** !#en The current playback time of the now playing item in seconds, you could also change the start playback time. + !#zh 指定视频从什么时间点开始播放,单位是秒,也可以用来获取当前视频播放的时间进度。 */ + currentTime: number; + /** !#en Whether keep the aspect ration of the original video. + !#zh 是否保持视频原来的宽高比 */ + keepAspectRatio: boolean; + /** !#en Whether play video in fullscreen mode. + !#zh 是否全屏播放视频 */ + isFullscreen: boolean; + /** !#en the video player's callback, it will be triggered when certain event occurs, like: playing, paused, stopped and completed. + !#zh 视频播放回调函数,该回调函数会在特定情况被触发,比如播放中,暂时,停止和完成播放。 */ + videoPlayerEvent: Component.EventHandler[]; + /** + !#en If a video is paused, call this method could resume playing. If a video is stopped, call this method to play from scratch. + !#zh 如果视频被暂停播放了,调用这个接口可以继续播放。如果视频被停止播放了,调用这个接口可以从头开始播放。 + */ + play(): void; + /** + !#en If a video is paused, call this method to resume playing. + !#zh 如果一个视频播放被暂停播放了,调用这个接口可以继续播放。 + */ + resume(): void; + /** + !#en If a video is playing, call this method to pause playing. + !#zh 如果一个视频正在播放,调用这个接口可以暂停播放。 + */ + pause(): void; + /** + !#en If a video is playing, call this method to stop playing immediately. + !#zh 如果一个视频正在播放,调用这个接口可以立马停止播放。 + */ + stop(): void; + /** + !#en Gets the duration of the video + !#zh 获取视频文件的播放总时长 + */ + getDuration(): number; + /** + !#en Determine whether video is playing or not. + !#zh 判断当前视频是否处于播放状态 + */ + isPlaying(): boolean; + /** + !#en if you don't need the VideoPlayer and it isn't in any running Scene, you should + call the destroy method on this component or the associated node explicitly. + Otherwise, the created DOM element won't be removed from web page. + !#zh + 如果你不再使用 VideoPlayer,并且组件未添加到场景中,那么你必须手动对组件或所在节点调用 destroy。 + 这样才能移除网页上的 DOM 节点,避免 Web 平台内存泄露。 + + @example + ```js + videoplayer.node.parent = null; // or videoplayer.node.removeFromParent(false); + // when you don't need videoplayer anymore + videoplayer.node.destroy(); + ``` + */ + destroy(): boolean; + } + /** !#en + Handling touch events in a ViewGroup takes special care, + because it's common for a ViewGroup to have children that are targets for different touch events than the ViewGroup itself. + To make sure that each view correctly receives the touch events intended for it, + ViewGroup should register capture phase event and handle the event propagation properly. + Please refer to Scrollview for more information. + + !#zh + ViewGroup的事件处理比较特殊,因为 ViewGroup 里面的子节点关心的事件跟 ViewGroup 本身可能不一样。 + 为了让子节点能够正确地处理事件,ViewGroup 需要注册 capture 阶段的事件,并且合理地处理 ViewGroup 之间的事件传递。 + 请参考 ScrollView 的实现来获取更多信息。 */ + export class ViewGroup extends Component { + } + /** !#en cc.WebView is a component for display web pages in the game + !#zh WebView 组件,用于在游戏中显示网页 */ + export class WebView extends _RendererUnderSG { + /** !#en A given URL to be loaded by the WebView, it should have a http or https prefix. + !#zh 指定 WebView 加载的网址,它应该是一个 http 或者 https 开头的字符串 */ + url: string; + /** !#en The webview's event callback , it will be triggered when certain webview event occurs. + !#zh WebView 的回调事件,当网页加载过程中,加载完成后或者加载出错时都会回调此函数 */ + webviewLoadedEvents: Component.EventHandler[]; + /** + !#en + Set javascript interface scheme (see also setOnJSCallback).
+ Note: Supports only on the Android and iOS. For HTML5, please refer to the official documentation.
+ Please refer to the official documentation for more details. + !#zh + 设置 JavaScript 接口方案(与 'setOnJSCallback' 配套使用)。
+ 注意:只支持 Android 和 iOS ,Web 端用法请前往官方文档查看。
+ 详情请参阅官方文档 + @param scheme scheme + */ + setJavascriptInterfaceScheme(scheme: string): void; + /** + !#en + This callback called when load URL that start with javascript + interface scheme (see also setJavascriptInterfaceScheme).
+ Note: Supports only on the Android and iOS. For HTML5, please refer to the official documentation.
+ Please refer to the official documentation for more details. + !#zh + 当加载 URL 以 JavaScript 接口方案开始时调用这个回调函数。
+ 注意:只支持 Android 和 iOS,Web 端用法请前往官方文档查看。 + 详情请参阅官方文档 + @param callback callback + */ + setOnJSCallback(callback: Function): void; + /** + !#en + Evaluates JavaScript in the context of the currently displayed page.
+ Please refer to the official document for more details
+ Note: Cross domain issues need to be resolved by yourself
+ !#zh + 执行 WebView 内部页面脚本(详情请参阅官方文档)
+ 注意:需要自行解决跨域问题 + @param str str + */ + evaluateJS(str: string): void; + /** + !#en if you don't need the WebView and it isn't in any running Scene, you should + call the destroy method on this component or the associated node explicitly. + Otherwise, the created DOM element won't be removed from web page. + !#zh + 如果你不再使用 WebView,并且组件未添加到场景中,那么你必须手动对组件或所在节点调用 destroy。 + 这样才能移除网页上的 DOM 节点,避免 Web 平台内存泄露。 + + @example + ```js + webview.node.parent = null; // or webview.node.removeFromParent(false); + // when you don't need webview anymore + webview.node.destroy(); + ``` + */ + destroy(): void; + } + /** !#en + Stores and manipulate the anchoring based on its parent. + Widget are used for GUI but can also be used for other things. + Widget will adjust current node's position and size automatically, but the results after adjustment can not be obtained until the next frame unless you call {{#crossLink "Widget/updateAlignment:method"}}{{/crossLink}} manually. + !#zh + Widget 组件,用于设置和适配其相对于父节点的边距,Widget 通常被用于 UI 界面,也可以用于其他地方。 + Widget 会自动调整当前节点的坐标和宽高,不过目前调整后的结果要到下一帧才能在脚本里获取到,除非你先手动调用 {{#crossLink "Widget/updateAlignment:method"}}{{/crossLink}}。 */ + export class Widget extends Component { + /** !#en Specifies an alignment target that can only be one of the parent nodes of the current node. + The default value is null, and when null, indicates the current parent. + !#zh 指定一个对齐目标,只能是当前节点的其中一个父节点,默认为空,为空时表示当前父节点。 */ + target: Node; + /** !#en Whether to align the top. + !#zh 是否对齐上边。 */ + isAlignTop: boolean; + /** !#en + Vertically aligns the midpoint, This will open the other vertical alignment options cancel. + !#zh + 是否垂直方向对齐中点,开启此项会将垂直方向其他对齐选项取消。 */ + isAlignVerticalCenter: boolean; + /** !#en Whether to align the bottom. + !#zh 是否对齐下边。 */ + isAlignBottom: boolean; + /** !#en Whether to align the left. + !#zh 是否对齐左边 */ + isAlignLeft: boolean; + /** !#en + Horizontal aligns the midpoint. This will open the other horizontal alignment options canceled. + !#zh + 是否水平方向对齐中点,开启此选项会将水平方向其他对齐选项取消。 */ + isAlignHorizontalCenter: boolean; + /** !#en Whether to align the right. + !#zh 是否对齐右边。 */ + isAlignRight: boolean; + /** !#en + Whether the stretched horizontally, when enable the left and right alignment will be stretched horizontally, + the width setting is invalid (read only). + !#zh + 当前是否水平拉伸。当同时启用左右对齐时,节点将会被水平拉伸,此时节点的宽度只读。 */ + isStretchWidth: boolean; + /** !#en + Whether the stretched vertically, when enable the left and right alignment will be stretched vertically, + then height setting is invalid (read only) + !#zh + 当前是否垂直拉伸。当同时启用上下对齐时,节点将会被垂直拉伸,此时节点的高度只读。 */ + isStretchHeight: boolean; + /** !#en + The margins between the top of this node and the top of parent node, + the value can be negative, Only available in 'isAlignTop' open. + !#zh + 本节点顶边和父节点顶边的距离,可填写负值,只有在 isAlignTop 开启时才有作用。 */ + top: number; + /** !#en + The margins between the bottom of this node and the bottom of parent node, + the value can be negative, Only available in 'isAlignBottom' open. + !#zh + 本节点底边和父节点底边的距离,可填写负值,只有在 isAlignBottom 开启时才有作用。 */ + bottom: number; + /** !#en + The margins between the left of this node and the left of parent node, + the value can be negative, Only available in 'isAlignLeft' open. + !#zh + 本节点左边和父节点左边的距离,可填写负值,只有在 isAlignLeft 开启时才有作用。 */ + left: number; + /** !#en + The margins between the right of this node and the right of parent node, + the value can be negative, Only available in 'isAlignRight' open. + !#zh + 本节点右边和父节点右边的距离,可填写负值,只有在 isAlignRight 开启时才有作用。 */ + right: number; + /** !#en + Horizontal aligns the midpoint offset value, + the value can be negative, Only available in 'isAlignHorizontalCenter' open. + !#zh 水平居中的偏移值,可填写负值,只有在 isAlignHorizontalCenter 开启时才有作用。 */ + horizontalCenter: number; + /** !#en + Vertical aligns the midpoint offset value, + the value can be negative, Only available in 'isAlignVerticalCenter' open. + !#zh 垂直居中的偏移值,可填写负值,只有在 isAlignVerticalCenter 开启时才有作用。 */ + verticalCenter: number; + /** !#en If true, horizontalCenter is pixel margin, otherwise is percentage (0 - 1) margin. + !#zh 如果为 true,"horizontalCenter" 将会以像素作为偏移值,反之为百分比(0 到 1)。 */ + isAbsoluteHorizontalCenter: boolean; + /** !#en If true, verticalCenter is pixel margin, otherwise is percentage (0 - 1) margin. + !#zh 如果为 true,"verticalCenter" 将会以像素作为偏移值,反之为百分比(0 到 1)。 */ + isAbsoluteVerticalCenter: boolean; + /** !#en + If true, top is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's height. + !#zh + 如果为 true,"top" 将会以像素作为边距,否则将会以相对父物体高度的百分比(0 到 1)作为边距。 */ + isAbsoluteTop: boolean; + /** !#en + If true, bottom is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's height. + !#zh + 如果为 true,"bottom" 将会以像素作为边距,否则将会以相对父物体高度的百分比(0 到 1)作为边距。 */ + isAbsoluteBottom: boolean; + /** !#en + If true, left is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's width. + !#zh + 如果为 true,"left" 将会以像素作为边距,否则将会以相对父物体宽度的百分比(0 到 1)作为边距。 */ + isAbsoluteLeft: boolean; + /** !#en + If true, right is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's width. + !#zh + 如果为 true,"right" 将会以像素作为边距,否则将会以相对父物体宽度的百分比(0 到 1)作为边距。 */ + isAbsoluteRight: boolean; + /** !#en TODO + !#zh + 开启后仅会在 onEnable 的当帧结束时对齐一次,然后立刻禁用当前组件。 + 这样便于脚本或动画继续控制当前节点。 + 注意:onEnable 时所在的那一帧仍然会进行对齐。 */ + isAlignOnce: boolean; + /** + !#en + Immediately perform the widget alignment. You need to manually call this method only if + you need to get the latest results after the alignment before the end of current frame. + !#zh + 立刻执行 widget 对齐操作。这个接口一般不需要手工调用。 + 只有当你需要在当前帧结束前获得 widget 对齐后的最新结果时才需要手动调用这个方法。 + + @example + ```js + widget.top = 10; // change top margin + cc.log(widget.node.y); // not yet changed + widget.updateAlignment(); + cc.log(widget.node.y); // changed + ``` + */ + updateAlignment(): void; + } + /** !#en + EventTarget is an object to which an event is dispatched when something has occurred. + Entity are the most common event targets, but other objects can be event targets too. + + Event targets are an important part of the Fireball event model. + The event target serves as the focal point for how events flow through the scene graph. + When an event such as a mouse click or a keypress occurs, Fireball dispatches an event object + into the event flow from the root of the hierarchy. The event object then makes its way through + the scene graph until it reaches the event target, at which point it begins its return trip through + the scene graph. This round-trip journey to the event target is conceptually divided into three phases: + - The capture phase comprises the journey from the root to the last node before the event target's node + - The target phase comprises only the event target node + - The bubbling phase comprises any subsequent nodes encountered on the return trip to the root of the tree + See also: http://www.w3.org/TR/DOM-Level-3-Events/#event-flow + + Event targets can implement the following methods: + - _getCapturingTargets + - _getBubblingTargets + + !#zh + 事件目标是事件触发时,分派的事件对象,Node 是最常见的事件目标, + 但是其他对象也可以是事件目标。
*/ + export class EventTarget { + /** + !#en + Register an callback of a specific event type on the EventTarget. + !#zh + 注册事件目标的特定事件类型回调。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + @param useCapture When set to true, the capture argument prevents callback + from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. + When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE. + Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET. + + @example + ```js + node.on(cc.Node.EventType.TOUCH_END, function (event) { + cc.log("this is callback"); + }, node); + ``` + */ + on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void; + on(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void; + /** + !#en + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. + !#zh + 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not. + If not specified, useCapture defaults to false. If a callback was registered twice, + one with capture and one without, each must be removed separately. Removal of a capturing callback + does not affect a non-capturing version of the same listener, and vice versa. + + @example + ```js + // register touchEnd eventListener + var touchEnd = node.on(cc.Node.EventType.TOUCH_END, function (event) { + cc.log("this is callback"); + }, node); + // remove touch end event listener + node.off(cc.Node.EventType.TOUCH_END, touchEnd, node); + // remove all touch end event listeners + node.off(cc.Node.EventType.TOUCH_END); + ``` + */ + off(type: string, callback?: Function, target?: any, useCapture?: boolean): void; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + @param useCapture When set to true, the capture argument prevents callback + from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. + When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE. + Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET. + + @example + ```js + node.once(cc.Node.EventType.TOUCH_END, function (event) { + cc.log("this is callback"); + }, node); + ``` + */ + once(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void; + once(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void; + /** + !#en + Dispatches an event into the event flow. + The event target is the EventTarget object upon which the dispatchEvent() method is called. + !#zh 分发事件到事件流中。 + @param event The Event object that is dispatched into the event flow + */ + dispatchEvent(event: Event): void; + /** + !#en + Send an event to this object directly, this method will not propagate the event to any other objects. + The event will be created from the supplied message, you can get the "detail" argument from event.detail. + !#zh + 该对象直接发送事件, 这种方法不会对事件传播到任何其他对象。 + @param message the message to send + @param detail whatever argument the message needs + */ + emit(message: string, detail?: any): void; + } + /** !#en Base class of all kinds of events. + !#zh 包含事件相关信息的对象。 */ + export class Event { + /** + + @param type The name of the event (case-sensitive), e.g. "click", "fire", or "submit" + @param bubbles A boolean indicating whether the event bubbles up through the tree or not + */ + constructor(type: string, bubbles: boolean); + /** !#en The name of the event (case-sensitive), e.g. "click", "fire", or "submit". + !#zh 事件类型。 */ + type: string; + /** !#en Indicate whether the event bubbles up through the tree or not. + !#zh 表示该事件是否进行冒泡。 */ + bubbles: boolean; + /** !#en A reference to the target to which the event was originally dispatched. + !#zh 最初事件触发的目标 */ + target: any; + /** !#en A reference to the currently registered target for the event. + !#zh 当前目标 */ + currentTarget: any; + /** !#en + Indicates which phase of the event flow is currently being evaluated. + Returns an integer value represented by 4 constants: + - Event.NONE = 0 + - Event.CAPTURING_PHASE = 1 + - Event.AT_TARGET = 2 + - Event.BUBBLING_PHASE = 3 + The phases are explained in the [section 3.1, Event dispatch and DOM event flow] + (http://www.w3.org/TR/DOM-Level-3-Events/#event-flow), of the DOM Level 3 Events specification. + !#zh 事件阶段 */ + eventPhase: number; + /** + !#en Reset the event for being stored in the object pool. + !#zh 重置对象池中存储的事件。 + */ + unuse(): string; + /** + !#en Reuse the event for being used again by the object pool. + !#zh 用于对象池再次使用的事件。 + */ + reuse(): string; + /** + !#en Stops propagation for current event. + !#zh 停止传递当前事件。 + */ + stopPropagation(): void; + /** + !#en Stops propagation for current event immediately, + the event won't even be dispatched to the listeners attached in the current target. + !#zh 立即停止当前事件的传递,事件甚至不会被分派到所连接的当前目标。 + */ + stopPropagationImmediate(): void; + /** + !#en Checks whether the event has been stopped. + !#zh 检查该事件是否已经停止传递. + */ + isStopped(): boolean; + /** + !#en +

+ Gets current target of the event
+ note: It only be available when the event listener is associated with node.
+ It returns 0 when the listener is associated with fixed priority. +

+ !#zh 获取当前目标节点 + */ + getCurrentTarget(): Node; + /** + !#en Gets the event type. + !#zh 获取事件类型 + */ + getType(): string; + /** !#en Code for event without type. + !#zh 没有类型的事件 */ + static NO_TYPE: string; + /** !#en The type code of Touch event. + !#zh 触摸事件类型 */ + static TOUCH: string; + /** !#en The type code of Mouse event. + !#zh 鼠标事件类型 */ + static MOUSE: string; + /** !#en The type code of Keyboard event. + !#zh 键盘事件类型 */ + static KEYBOARD: string; + /** !#en The type code of Acceleration event. + !#zh 加速器事件类型 */ + static ACCELERATION: string; + /** !#en Events not currently dispatched are in this phase + !#zh 尚未派发事件阶段 */ + static NONE: number; + /** !#en + The capturing phase comprises the journey from the root to the last node before the event target's node + see http://www.w3.org/TR/DOM-Level-3-Events/#event-flow + !#zh 捕获阶段,包括事件目标节点之前从根节点到最后一个节点的过程。 */ + static CAPTURING_PHASE: number; + /** !#en + The target phase comprises only the event target node + see http://www.w3.org/TR/DOM-Level-3-Events/#event-flow + !#zh 目标阶段仅包括事件目标节点。 */ + static AT_TARGET: number; + /** !#en + The bubbling phase comprises any subsequent nodes encountered on the return trip to the root of the hierarchy + see http://www.w3.org/TR/DOM-Level-3-Events/#event-flow + !#zh 冒泡阶段, 包括回程遇到到层次根节点的任何后续节点。 */ + static BUBBLING_PHASE: number; + } + /** !#en The System event, it currently supports the key events and accelerometer events + !#zh 系统事件,它目前支持按键事件和重力感应事件 */ + export class SystemEvent extends EventTarget { + /** + !#en whether enable accelerometer event + !#zh 是否启用加速度计事件 + @param isEnable isEnable + */ + setAccelerometerEnabled(isEnable: boolean): void; + /** + !#en set accelerometer interval value + !#zh 设置加速度计间隔值 + @param interval interval + */ + setAccelerometerInterval(interval: number): void; + } + /** !#en +

+ The base class of event listener.
+ If you need custom listener which with different callback, you need to inherit this class.
+ For instance, you could refer to EventListenerAcceleration, EventListenerKeyboard,
+ EventListenerTouchOneByOne, EventListenerCustom. +

+ + !#zh + 封装用户的事件处理逻辑。 + 注意:这是一个抽象类,开发者不应该直接实例化这个类,请参考 {{#crossLink "EventListener/create:method"}}cc.EventListener.create{{/crossLink}}。 */ + export class EventListener { + /** + Constructor + @param type type + @param listenerID listenerID + @param callback callback + */ + constructor(type: number, listenerID: number, callback: number); + /** + !#en Checks whether the listener is available. + !#zh 检测监听器是否有效 + */ + checkAvailable(): boolean; + /** + !#en Clones the listener, its subclasses have to override this method. + !#zh 克隆监听器,它的子类必须重写此方法。 + */ + clone(): EventListener; + /** + !#en Enables or disables the listener + !#zh 启用或禁用监听器。 + @param enabled enabled + */ + setEnabled(enabled: boolean): void; + /** + !#en Checks whether the listener is enabled + !#zh 检查监听器是否可用。 + */ + isEnabled(): boolean; + /** !#en The type code of unknown event listener. + !#zh 未知的事件监听器类型 */ + static UNKNOWN: number; + /** !#en The type code of keyboard event listener. + !#zh 键盘事件监听器类型 */ + static KEYBOARD: number; + /** !#en The type code of acceleration event listener. + !#zh 加速器事件监听器类型 */ + static ACCELERATION: number; + /** + !#en + Create a EventListener object with configuration including the event type, handlers and other parameters. + In handlers, this refer to the event listener object itself. + You can also pass custom parameters in the configuration object, + all custom parameters will be polyfilled into the event listener object and can be accessed in handlers. + !#zh 通过指定不同的 Event 对象来设置想要创建的事件监听器。 + @param argObj a json object + + @example + ```js + // Create KEYBOARD EventListener. + cc.EventListener.create({ + event: cc.EventListener.KEYBOARD, + onKeyPressed: function (keyCode, event) { + cc.log('pressed key: ' + keyCode); + }, + onKeyReleased: function (keyCode, event) { + cc.log('released key: ' + keyCode); + } + }); + + // Create ACCELERATION EventListener. + cc.EventListener.create({ + event: cc.EventListener.ACCELERATION, + callback: function (acc, event) { + cc.log('acc: ' + keyCode); + } + }); + ``` + */ + static create(argObj: any): EventListener; + } + /** !#en + This class has been deprecated, please use cc.systemEvent or cc.EventTarget instead. See [Listen to and launch events](../../../manual/en/scripting/events.md) for details.
+
+ cc.eventManager is a singleton object which manages event listener subscriptions and event dispatching. + The EventListener list is managed in such way so that event listeners can be added and removed + while events are being dispatched. + + !#zh + 该类已废弃,请使用 cc.systemEvent 或 cc.EventTarget 代替,详见 [监听和发射事件](../../../manual/zh/scripting/events.md)。
+
+ 事件管理器,它主要管理事件监听器注册和派发系统事件。 */ + export class eventManager { + /** + !#en Pauses all listeners which are associated the specified target. + !#zh 暂停传入的 node 相关的所有监听器的事件响应。 + @param node node + @param recursive recursive + */ + static pauseTarget(node: Node, recursive?: boolean): void; + /** + !#en Resumes all listeners which are associated the specified target. + !#zh 恢复传入的 node 相关的所有监听器的事件响应。 + @param node node + @param recursive recursive + */ + static resumeTarget(node: Node, recursive?: boolean): void; + /** + !#en Query whether the specified event listener id has been added. + !#zh 查询指定的事件 ID 是否存在 + @param listenerID The listener id. + */ + static hasEventListener(listenerID: string|number): boolean; + /** + !#en +

+ Adds a event listener for a specified event.
+ if the parameter "nodeOrPriority" is a node, + it means to add a event listener for a specified event with the priority of scene graph.
+ if the parameter "nodeOrPriority" is a Number, + it means to add a event listener for a specified event with the fixed priority.
+

+ !#zh + 将事件监听器添加到事件管理器中。
+ 如果参数 “nodeOrPriority” 是节点,优先级由 node 的渲染顺序决定,显示在上层的节点将优先收到事件。
+ 如果参数 “nodeOrPriority” 是数字,优先级则固定为该参数的数值,数字越小,优先级越高。
+ @param listener The listener of a specified event or a object of some event parameters. + @param nodeOrPriority The priority of the listener is based on the draw order of this node or fixedPriority The fixed priority of the listener. + */ + static addListener(listener: EventListener|any, nodeOrPriority: Node|number): EventListener; + /** + !#en Remove a listener. + !#zh 移除一个已添加的监听器。 + @param listener an event listener or a registered node target + + @example + ```js + + // 1. remove eventManager add Listener; + var mouseListener1 = cc.eventManager.addListener({ + event: cc.EventListener.MOUSE, + onMouseDown: function(keyCode, event){ }, + onMouseUp: function(keyCode, event){ }, + onMouseMove: function () { }, + onMouseScroll: function () { } + }, node); + + cc.eventManager.removeListener(mouseListener1); + + // 2. remove eventListener create Listener; + var mouseListener2 = cc.EventListener.create({ + event: cc.EventListener.MOUSE, + onMouseDown: function(keyCode, event){ }, + onMouseUp: function(keyCode, event){ }, + onMouseMove: function () { }, + onMouseScroll: function () { } + }); + + cc.eventManager.removeListener(mouseListener2); + + ``` + */ + static removeListener(listener: EventListener): void; + /** + !#en Removes all listeners with the same event listener type or removes all listeners of a node. + !#zh + 移除注册到 eventManager 中指定类型的所有事件监听器。
+ 1. 如果传入的第一个参数类型是 Node,那么事件管理器将移除与该对象相关的所有事件监听器。 + (如果第二参数 recursive 是 true 的话,就会连同该对象的子控件上所有的事件监听器也一并移除)
+ 2. 如果传入的第一个参数类型是 Number(该类型 EventListener 中定义的事件类型), + 那么事件管理器将移除该类型的所有事件监听器。
+ + 下列是目前存在监听器类型:
+ cc.EventListener.UNKNOWN
+ cc.EventListener.KEYBOARD
+ cc.EventListener.ACCELERATION,
+ @param listenerType listenerType or a node + @param recursive recursive + */ + static removeListeners(listenerType: number|Node, recursive?: boolean): void; + /** + !#en Removes all listeners + !#zh 移除所有事件监听器。 + */ + static removeAllListeners(): void; + /** + !#en Sets listener's priority with fixed value. + !#zh 设置 FixedPriority 类型监听器的优先级。 + @param listener listener + @param fixedPriority fixedPriority + */ + static setPriority(listener: EventListener, fixedPriority: number): void; + /** + !#en Whether to enable dispatching events + !#zh 启用或禁用事件管理器,禁用后不会分发任何事件。 + @param enabled enabled + */ + static setEnabled(enabled: boolean): void; + /** + !#en Checks whether dispatching events is enabled + !#zh 检测事件管理器是否启用。 + */ + static isEnabled(): boolean; + } + /** !#en The touch event class + !#zh 封装了触摸相关的信息。 */ + export class Touch { + /** + !#en Returns the current touch location in OpenGL coordinates.、 + !#zh 获取当前触点位置。 + */ + getLocation(): Vec2; + /** + !#en Returns X axis location value. + !#zh 获取当前触点 X 轴位置。 + */ + getLocationX(): number; + /** + !#en Returns Y axis location value. + !#zh 获取当前触点 Y 轴位置。 + */ + getLocationY(): number; + /** + !#en Returns the previous touch location in OpenGL coordinates. + !#zh 获取触点在上一次事件时的位置对象,对象包含 x 和 y 属性。 + */ + getPreviousLocation(): Vec2; + /** + !#en Returns the start touch location in OpenGL coordinates. + !#zh 获获取触点落下时的位置对象,对象包含 x 和 y 属性。 + */ + getStartLocation(): Vec2; + /** + !#en Returns the delta distance from the previous touche to the current one in screen coordinates. + !#zh 获取触点距离上一次事件移动的距离对象,对象包含 x 和 y 属性。 + */ + getDelta(): Vec2; + /** + !#en Returns the current touch location in screen coordinates. + !#zh 获取当前事件在游戏窗口内的坐标位置对象,对象包含 x 和 y 属性。 + */ + getLocationInView(): Vec2; + /** + !#en Returns the previous touch location in screen coordinates. + !#zh 获取触点在上一次事件时在游戏窗口中的位置对象,对象包含 x 和 y 属性。 + */ + getPreviousLocationInView(): Vec2; + /** + !#en Returns the start touch location in screen coordinates. + !#zh 获取触点落下时在游戏窗口中的位置对象,对象包含 x 和 y 属性。 + */ + getStartLocationInView(): Vec2; + /** + !#en Returns the id of cc.Touch. + !#zh 触点的标识 ID,可以用来在多点触摸中跟踪触点。 + */ + getID(): number; + /** + !#en Sets information to touch. + !#zh 设置触摸相关的信息。用于监控触摸事件。 + @param id id + @param x x + @param y y + */ + setTouchInfo(id: number, x: number, y: number): void; + } + /** undefined */ + export class Graphics extends _RendererUnderSG { + /** !#en + Current line width. + !#zh + 当前线条宽度 */ + lineWidth: number; + /** !#en + lineJoin determines how two connecting segments (of lines, arcs or curves) with non-zero lengths in a shape are joined together. + !#zh + lineJoin 用来设置2个长度不为0的相连部分(线段,圆弧,曲线)如何连接在一起的属性。 */ + lineJoin: Graphics.LineJoin; + /** !#en + lineCap determines how the end points of every line are drawn. + !#zh + lineCap 指定如何绘制每一条线段末端。 */ + lineCap: Graphics.LineCap; + /** !#en + stroke color + !#zh + 线段颜色 */ + strokeColor: Color; + /** !#en + fill color + !#zh + 填充颜色 */ + fillColor: Color; + /** !#en + Sets the miter limit ratio + !#zh + 设置斜接面限制比例 */ + miterLimit: number; + /** + !#en Move path start point to (x,y). + !#zh 移动路径起点到坐标(x, y) + @param x The x axis of the coordinate for the end point. + @param y The y axis of the coordinate for the end point. + */ + moveTo(x?: number, y?: number): void; + /** + !#en Adds a straight line to the path + !#zh 绘制直线路径 + @param x The x axis of the coordinate for the end point. + @param y The y axis of the coordinate for the end point. + */ + lineTo(x?: number, y?: number): void; + /** + !#en Adds a cubic Bézier curve to the path + !#zh 绘制三次贝赛尔曲线路径 + @param c1x The x axis of the coordinate for the first control point. + @param c1y The y axis of the coordinate for first control point. + @param c2x The x axis of the coordinate for the second control point. + @param c2y The y axis of the coordinate for the second control point. + @param x The x axis of the coordinate for the end point. + @param y The y axis of the coordinate for the end point. + */ + bezierCurveTo(c1x?: number, c1y?: number, c2x?: number, c2y?: number, x?: number, y?: number): void; + /** + !#en Adds a quadratic Bézier curve to the path + !#zh 绘制二次贝赛尔曲线路径 + @param cx The x axis of the coordinate for the control point. + @param cy The y axis of the coordinate for the control point. + @param x The x axis of the coordinate for the end point. + @param y The y axis of the coordinate for the end point. + */ + quadraticCurveTo(cx?: number, cy?: number, x?: number, y?: number): void; + /** + !#en Adds an arc to the path which is centered at (cx, cy) position with radius r starting at startAngle and ending at endAngle going in the given direction by counterclockwise (defaulting to false). + !#zh 绘制圆弧路径。圆弧路径的圆心在 (cx, cy) 位置,半径为 r ,根据 counterclockwise (默认为false)指定的方向从 startAngle 开始绘制,到 endAngle 结束。 + @param cx The x axis of the coordinate for the center point. + @param cy The y axis of the coordinate for the center point. + @param r The arc's radius. + @param startAngle The angle at which the arc starts, measured clockwise from the positive x axis and expressed in radians. + @param endAngle The angle at which the arc ends, measured clockwise from the positive x axis and expressed in radians. + @param counterclockwise An optional Boolean which, if true, causes the arc to be drawn counter-clockwise between the two angles. By default it is drawn clockwise. + */ + arc(cx?: number, cy?: number, r?: number, startAngle?: number, endAngle?: number, counterclockwise?: number): void; + /** + !#en Adds an ellipse to the path. + !#zh 绘制椭圆路径。 + @param cx The x axis of the coordinate for the center point. + @param cy The y axis of the coordinate for the center point. + @param rx The ellipse's x-axis radius. + @param ry The ellipse's y-axis radius. + */ + ellipse(cx?: number, cy?: number, rx?: number, ry?: number): void; + /** + !#en Adds an circle to the path. + !#zh 绘制圆形路径。 + @param cx The x axis of the coordinate for the center point. + @param cy The y axis of the coordinate for the center point. + @param r The circle's radius. + */ + circle(cx?: number, cy?: number, r?: number): void; + /** + !#en Adds an rectangle to the path. + !#zh 绘制矩形路径。 + @param x The x axis of the coordinate for the rectangle starting point. + @param y The y axis of the coordinate for the rectangle starting point. + @param w The rectangle's width. + @param h The rectangle's height. + */ + rect(x?: number, y?: number, w?: number, h?: number): void; + /** + !#en Adds an round corner rectangle to the path. + !#zh 绘制圆角矩形路径。 + @param x The x axis of the coordinate for the rectangle starting point. + @param y The y axis of the coordinate for the rectangle starting point. + @param w The rectangles width. + @param h The rectangle's height. + @param r The radius of the rectangle. + */ + roundRect(x?: number, y?: number, w?: number, h?: number, r?: number): void; + /** + !#en Draws a filled rectangle. + !#zh 绘制填充矩形。 + @param x The x axis of the coordinate for the rectangle starting point. + @param y The y axis of the coordinate for the rectangle starting point. + @param w The rectangle's width. + @param h The rectangle's height. + */ + fillRect(x?: number, y?: number, w?: number, h?: number): void; + /** + !#en Erasing any previously drawn content. + !#zh 擦除之前绘制的所有内容的方法。 + @param clean Whether to clean the graphics inner cache. + */ + clear(clean?: boolean): void; + /** + !#en Causes the point of the pen to move back to the start of the current path. It tries to add a straight line from the current point to the start. + !#zh 将笔点返回到当前路径起始点的。它尝试从当前点到起始点绘制一条直线。 + */ + close(): void; + /** + !#en Strokes the current or given path with the current stroke style. + !#zh 根据当前的画线样式,绘制当前或已经存在的路径。 + */ + stroke(): void; + /** + !#en Fills the current or given path with the current fill style. + !#zh 根据当前的画线样式,填充当前或已经存在的路径。 + */ + fill(): void; + } + /** undefined */ + export class WorldManifold { + /** !#en + world contact point (point of intersection) + !#zh + 碰撞点集合 */ + points: [Vec2]; + /** !#en + world vector pointing from A to B + !#zh + 世界坐标系下由 A 指向 B 的向量 */ + normal: Vec2; + } + /** !#en + A manifold point is a contact point belonging to a contact manifold. + It holds details related to the geometry and dynamics of the contact points. + Note: the impulses are used for internal caching and may not + provide reliable contact forces, especially for high speed collisions. + !#zh + ManifoldPoint 是接触信息中的接触点信息。它拥有关于几何和接触点的详细信息。 + 注意:信息中的冲量用于系统内部缓存,提供的接触力可能不是很准确,特别是高速移动中的碰撞信息。 */ + export class ManifoldPoint { + /** !#en + The local point usage depends on the manifold type: + -e_circles: the local center of circleB + -e_faceA: the local center of circleB or the clip point of polygonB + -e_faceB: the clip point of polygonA + !#zh + 本地坐标点的用途取决于 manifold 的类型 + - e_circles: circleB 的本地中心点 + - e_faceA: circleB 的本地中心点 或者是 polygonB 的截取点 + - e_faceB: polygonB 的截取点 */ + localPoint: Vec2; + /** !#en + Normal impulse. + !#zh + 法线冲量。 */ + normalImpulse: number; + /** !#en + Tangent impulse. + !#zh + 切线冲量。 */ + tangentImpulse: number; + } + /** undefined */ + export class Manifold { + /** !#en + Manifold type : 0: e_circles, 1: e_faceA, 2: e_faceB + !#zh + Manifold 类型 : 0: e_circles, 1: e_faceA, 2: e_faceB */ + type: number; + /** !#en + The local point usage depends on the manifold type: + -e_circles: the local center of circleA + -e_faceA: the center of faceA + -e_faceB: the center of faceB + !#zh + 用途取决于 manifold 类型 + -e_circles: circleA 的本地中心点 + -e_faceA: faceA 的本地中心点 + -e_faceB: faceB 的本地中心点 */ + localPoint: Vec2; + /** !#en + -e_circles: not used + -e_faceA: the normal on polygonA + -e_faceB: the normal on polygonB + !#zh + -e_circles: 没被使用到 + -e_faceA: polygonA 的法向量 + -e_faceB: polygonB 的法向量 */ + localNormal: Vec2; + /** !#en + the points of contact. + !#zh + 接触点信息。 */ + points: [ManifoldPoint]; + } + /** !#en + Contact impulses for reporting. + !#zh + 用于返回给回调的接触冲量。 */ + export class PhysicsImpulse { + /** !#en + Normal impulses. + !#zh + 法线方向的冲量 */ + normalImpulses: void; + /** !#en + Tangent impulses + !#zh + 切线方向的冲量 */ + tangentImpulses: void; + } + /** !#en + PhysicsContact will be generated during begin and end collision as a parameter of the collision callback. + Note that contacts will be reused for speed up cpu time, so do not cache anything in the contact. + !#zh + 物理接触会在开始和结束碰撞之间生成,并作为参数传入到碰撞回调函数中。 + 注意:传入的物理接触会被系统进行重用,所以不要在使用中缓存里面的任何信息。 */ + export class PhysicsContact { + /** + !#en + Get the world manifold. + !#zh + 获取世界坐标系下的碰撞信息。 + */ + getWorldManifold(): WorldManifold; + /** + !#en + Get the manifold. + !#zh + 获取世界坐标系下的碰撞信息。 + */ + getManifold(): Manifold; + /** + !#en + Get the impulses. + Note: PhysicsImpulse can only used in onPostSolve callback. + !#zh + 获取冲量信息 + 注意:这个信息只有在 onPostSolve 回调中才能获取到 + */ + getImpulse(): PhysicsImpulse; + colliderA: Collider; + colliderB: Collider; + /** !#en + If set disabled to true, the contact will be ignored until contact end. + If you just want to disabled contact for current time step or sub-step, please use disabledOnce. + !#zh + 如果 disabled 被设置为 true,那么直到接触结束此接触都将被忽略。 + 如果只是希望在当前时间步或子步中忽略此接触,请使用 disabledOnce 。 */ + disabled: boolean; + /** !#en + Disabled contact for current time step or sub-step. + !#zh + 在当前时间步或子步中忽略此接触。 */ + disabledOnce: boolean; + /** + !#en + Is this contact touching? + !#zh + 返回碰撞体是否已经接触到。 + */ + isTouching(): boolean; + /** + !#en + Set the desired tangent speed for a conveyor belt behavior. + !#zh + 为传送带设置期望的切线速度 + @param tangentSpeed tangentSpeed + */ + setTangentSpeed(tangentSpeed: number): void; + /** + !#en + Get the desired tangent speed. + !#zh + 获取切线速度 + */ + getTangentSpeed(): number; + /** + !#en + Override the default friction mixture. You can call this in onPreSolve callback. + !#zh + 覆盖默认的摩擦力系数。你可以在 onPreSolve 回调中调用此函数。 + @param friction friction + */ + setFriction(friction: number): void; + /** + !#en + Get the friction. + !#zh + 获取当前摩擦力系数 + */ + getFriction(): number; + /** + !#en + Reset the friction mixture to the default value. + !#zh + 重置摩擦力系数到默认值 + */ + resetFriction(): void; + /** + !#en + Override the default restitution mixture. You can call this in onPreSolve callback. + !#zh + 覆盖默认的恢复系数。你可以在 onPreSolve 回调中调用此函数。 + @param restitution restitution + */ + setRestitution(restitution: number): void; + /** + !#en + Get the restitution. + !#zh + 获取当前恢复系数 + */ + getRestitution(): number; + /** + !#en + Reset the restitution mixture to the default value. + !#zh + 重置恢复系数到默认值 + */ + resetRestitution(): void; + } + /** !#en + Physics manager uses box2d as the inner physics system, and hide most box2d implement details(creating rigidbody, synchronize rigidbody info to node). + You can visit some common box2d function through physics manager(hit testing, raycast, debug info). + Physics manager distributes the collision information to each collision callback when collision is produced. + Note: You need first enable the collision listener in the rigidbody. + !#zh + 物理系统将 box2d 作为内部物理系统,并且隐藏了大部分 box2d 实现细节(比如创建刚体,同步刚体信息到节点中等)。 + 你可以通过物理系统访问一些 box2d 常用的功能,比如点击测试,射线测试,设置测试信息等。 + 物理系统还管理碰撞信息的分发,她会在产生碰撞时,将碰撞信息分发到各个碰撞回调中。 + 注意:你需要先在刚体中开启碰撞接听才会产生相应的碰撞回调。 */ + export class PhysicsManager implements EventTarget { + /** !#en + The draw bits for drawing physics debug information. + !#zh + 指定物理系统需要绘制哪些调试信息。 */ + static DrawBits: DrawBits; + /** !#en + The ratio transform between physics unit and pixel unit, generally is 32. + !#zh + 物理单位与像素单位互相转换的比率,一般是 32。 */ + static PTM_RATIO: number; + /** !#en + The velocity iterations for the velocity constraint solver. + !#zh + 速度更新迭代数 */ + static VELOCITY_ITERATIONS: number; + /** !#en + The position Iterations for the position constraint solver. + !#zh + 位置迭代更新数 */ + static POSITION_ITERATIONS: number; + /** !#en + Specify the fixed time step. + Need enabledAccumulator to make it work. + !#zh + 指定固定的物理更新间隔时间,需要开启 enabledAccumulator 才有效。 */ + static FIXED_TIME_STEP: number; + /** !#en + Specify the max accumulator time. + Need enabledAccumulator to make it work. + !#zh + 每次可用于更新物理系统的最大时间,需要开启 enabledAccumulator 才有效。 */ + static MAX_ACCUMULATOR: number; + /** !#en + If enabled accumulator, then will call step function with the fixed time step FIXED_TIME_STEP. + And if the update dt is bigger than the time step, then will call step function several times. + If disabled accumulator, then will call step function with a time step calculated with the frame rate. + !#zh + 如果开启此选项,那么将会以固定的间隔时间 FIXED_TIME_STEP 来更新物理引擎,如果一个 update 的间隔时间大于 FIXED_TIME_STEP,则会对物理引擎进行多次更新。 + 如果关闭此选项,那么将会根据设定的 frame rate 计算出一个间隔时间来更新物理引擎。 */ + enabledAccumulator: boolean; + /** + !#en + Test which collider contains the given world point + !#zh + 获取包含给定世界坐标系点的碰撞体 + @param point the world point + */ + testPoint(point: Vec2): PhysicsCollider; + /** + !#en + Test which colliders intersect the given world rect + !#zh + 获取与给定世界坐标系矩形相交的碰撞体 + @param rect the world rect + */ + testAABB(rect: Rect): [PhysicsCollider]; + /** + !#en + Raycast the world for all colliders in the path of the ray. + The raycast ignores colliders that contain the starting point. + !#zh + 检测哪些碰撞体在给定射线的路径上,射线检测将忽略包含起始点的碰撞体。 + @param p1 start point of the raycast + @param p2 end point of the raycast + @param type optional, default is RayCastType.Closest + */ + rayCast(p1: Vec2, p2: Vec2, type: RayCastType): [PhysicsRayCastResult]; + /** + !#en + Attach physics debug draw to camera + !#zh + 将物理的调试绘制信息附加到指定摄像机上 + @param camera camera + */ + attachDebugDrawToCamera(camera: Camera): void; + /** + !#en + Detach physics debug draw to camera + !#zh + 将物理的调试绘制信息从指定摄像机上移除 + @param camera camera + */ + detachDebugDrawFromCamera(camera: Camera): void; + /** !#en + Enabled the physics manager? + !#zh + 指定是否启用物理系统? */ + enabled: boolean; + /** !#en + Debug draw flags. + !#zh + 设置调试绘制标志 */ + debugDrawFlags: number; + /** !#en + The physics world gravity. + !#zh + 物理世界重力值 */ + gravity: Vec2; + /** + !#en + Register an callback of a specific event type on the EventTarget. + !#zh + 注册事件目标的特定事件类型回调。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + @param useCapture When set to true, the capture argument prevents callback + from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. + When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE. + Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET. + + @example + ```js + node.on(cc.Node.EventType.TOUCH_END, function (event) { + cc.log("this is callback"); + }, node); + ``` + */ + on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void; + on(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void; + /** + !#en + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. + !#zh + 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not. + If not specified, useCapture defaults to false. If a callback was registered twice, + one with capture and one without, each must be removed separately. Removal of a capturing callback + does not affect a non-capturing version of the same listener, and vice versa. + + @example + ```js + // register touchEnd eventListener + var touchEnd = node.on(cc.Node.EventType.TOUCH_END, function (event) { + cc.log("this is callback"); + }, node); + // remove touch end event listener + node.off(cc.Node.EventType.TOUCH_END, touchEnd, node); + // remove all touch end event listeners + node.off(cc.Node.EventType.TOUCH_END); + ``` + */ + off(type: string, callback?: Function, target?: any, useCapture?: boolean): void; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + @param useCapture When set to true, the capture argument prevents callback + from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. + When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE. + Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET. + + @example + ```js + node.once(cc.Node.EventType.TOUCH_END, function (event) { + cc.log("this is callback"); + }, node); + ``` + */ + once(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void; + once(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void; + /** + !#en + Dispatches an event into the event flow. + The event target is the EventTarget object upon which the dispatchEvent() method is called. + !#zh 分发事件到事件流中。 + @param event The Event object that is dispatched into the event flow + */ + dispatchEvent(event: Event): void; + /** + !#en + Send an event to this object directly, this method will not propagate the event to any other objects. + The event will be created from the supplied message, you can get the "detail" argument from event.detail. + !#zh + 该对象直接发送事件, 这种方法不会对事件传播到任何其他对象。 + @param message the message to send + @param detail whatever argument the message needs + */ + emit(message: string, detail?: any): void; + } + /** undefined */ + export enum DrawBits { + e_aabbBit = 0, + e_pairBit = 0, + e_centerOfMassBit = 0, + e_jointBit = 0, + e_shapeBit = 0, + } + /** undefined */ + export class PhysicsRayCastResult { + /** !#en + The PhysicsCollider which intersects with the raycast + !#zh + 与射线相交的碰撞体 */ + collider: PhysicsCollider; + /** !#en + The intersection point + !#zh + 射线与碰撞体相交的点 */ + point: Vec2; + /** !#en + The normal vector at the point of intersection + !#zh + 射线与碰撞体相交的点的法向量 */ + normal: Vec2; + /** !#en + The fraction of the raycast path at the point of intersection + !#zh + 射线与碰撞体相交的点占射线长度的分数 */ + fraction: number; + } + /** !#en Enum for RigidBodyType. + !#zh 刚体类型 */ + export enum RigidBodyType { + Static = 0, + Kinematic = 0, + Dynamic = 0, + Animated = 0, + } + /** !#en Enum for RayCastType. + !#zh 射线检测类型 */ + export enum RayCastType { + Closest = 0, + Any = 0, + AllClosest = 0, + All = 0, + } + /** undefined */ + export class RigidBody extends Component { + /** !#en + Should enabled contact listener? + When a collision is trigger, the collision callback will only be called when enabled contact listener. + !#zh + 是否启用接触接听器。 + 当 collider 产生碰撞时,只有开启了接触接听器才会调用相应的回调函数 */ + enabledContactListener: boolean; + /** + !#en + Collision callback. + Called when two collider begin to touch. + !#zh + 碰撞回调。 + 如果你的脚本中实现了这个函数,那么它将会在两个碰撞体开始接触时被调用。 + @param contact contact information + @param selfCollider the collider belong to this rigidbody + @param otherCollider the collider belong to another rigidbody + */ + onBeginContact(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void; + /** + !#en + Collision callback. + Called when two collider cease to touch. + !#zh + 碰撞回调。 + 如果你的脚本中实现了这个函数,那么它将会在两个碰撞体停止接触时被调用。 + @param contact contact information + @param selfCollider the collider belong to this rigidbody + @param otherCollider the collider belong to another rigidbody + */ + onEndContact(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void; + /** + !#en + Collision callback. + This is called when a contact is updated. + This allows you to inspect a contact before it goes to the solver(e.g. disable contact). + Note: this is called only for awake bodies. + Note: this is called even when the number of contact points is zero. + Note: this is not called for sensors. + !#zh + 碰撞回调。 + 如果你的脚本中实现了这个函数,那么它将会在接触更新时被调用。 + 你可以在接触被处理前根据他包含的信息作出相应的处理,比如将这个接触禁用掉。 + 注意:回调只会为醒着的刚体调用。 + 注意:接触点为零的时候也有可能被调用。 + 注意:感知体(sensor)的回调不会被调用。 + @param contact contact information + @param selfCollider the collider belong to this rigidbody + @param otherCollider the collider belong to another rigidbody + */ + onPreSolve(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void; + /** + !#en + Collision callback. + This is called after a contact is updated. + You can get the impulses from the contact in this callback. + !#zh + 碰撞回调。 + 如果你的脚本中实现了这个函数,那么它将会在接触更新完后被调用。 + 你可以在这个回调中从接触信息中获取到冲量信息。 + @param contact contact information + @param selfCollider the collider belong to this rigidbody + @param otherCollider the collider belong to another rigidbody + */ + onPostSolve(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void; + /** !#en + Is this a fast moving body that should be prevented from tunneling through + other moving bodies? + Note : + - All bodies are prevented from tunneling through kinematic and static bodies. This setting is only considered on dynamic bodies. + - You should use this flag sparingly since it increases processing time. + !#zh + 这个刚体是否是一个快速移动的刚体,并且需要禁止穿过其他快速移动的刚体? + 需要注意的是 : + - 所有刚体都被禁止从 运动刚体 和 静态刚体 中穿过。此选项只关注于 动态刚体。 + - 应该尽量少的使用此选项,因为它会增加程序处理时间。 */ + bullet: boolean; + /** !#en + Rigidbody type : Static, Kinematic, Dynamic or Animated. + !#zh + 刚体类型: Static, Kinematic, Dynamic or Animated. */ + type: RigidBodyType; + /** !#en + Set this flag to false if this body should never fall asleep. + Note that this increases CPU usage. + !#zh + 如果此刚体永远都不应该进入睡眠,那么设置这个属性为 false。 + 需要注意这将使 CPU 占用率提高。 */ + allowSleep: boolean; + /** !#en + Scale the gravity applied to this body. + !#zh + 缩放应用在此刚体上的重力值 */ + gravityScale: number; + /** !#en + Linear damping is use to reduce the linear velocity. + The damping parameter can be larger than 1, but the damping effect becomes sensitive to the + time step when the damping parameter is large. + !#zh + Linear damping 用于衰减刚体的线性速度。衰减系数可以大于 1,但是当衰减系数比较大的时候,衰减的效果会变得比较敏感。 */ + linearDamping: number; + /** !#en + Angular damping is use to reduce the angular velocity. The damping parameter + can be larger than 1 but the damping effect becomes sensitive to the + time step when the damping parameter is large. + !#zh + Angular damping 用于衰减刚体的角速度。衰减系数可以大于 1,但是当衰减系数比较大的时候,衰减的效果会变得比较敏感。 */ + angularDamping: number; + /** !#en + The linear velocity of the body's origin in world co-ordinates. + !#zh + 刚体在世界坐标下的线性速度 */ + linearVelocity: Vec2; + /** !#en + The angular velocity of the body. + !#zh + 刚体的角速度 */ + angularVelocity: number; + /** !#en + Should this body be prevented from rotating? + !#zh + 是否禁止此刚体进行旋转 */ + fixedRotation: boolean; + /** !#en + Is this body initially awake or sleeping? + !#zh + 是否立刻唤醒此刚体 */ + awake: boolean; + /** !#en + Set the active state of the body. An inactive body is not + simulated and cannot be collided with or woken up. + If body is active, all fixtures will be added to the + broad-phase. + If body is inactive, all fixtures will be removed from + the broad-phase and all contacts will be destroyed. + Fixtures on an inactive body are implicitly inactive and will + not participate in collisions, ray-casts, or queries. + Joints connected to an inactive body are implicitly inactive. + !#zh + 设置刚体的激活状态。一个非激活状态下的刚体是不会被模拟和碰撞的,不管它是否处于睡眠状态下。 + 如果刚体处于激活状态下,所有夹具会被添加到 粗测阶段(broad-phase)。 + 如果刚体处于非激活状态下,所有夹具会被从 粗测阶段(broad-phase)中移除。 + 在非激活状态下的夹具不会参与到碰撞,射线,或者查找中 + 链接到非激活状态下刚体的关节也是非激活的。 */ + active: boolean; + /** + !#en + Gets a local point relative to the body's origin given a world point. + !#zh + 将一个给定的世界坐标系下的点转换为刚体本地坐标系下的点 + @param worldPoint a point in world coordinates. + @param out optional, the receiving point + */ + getLocalPoint(worldPoint: Vec2, out: Vec2): Vec2; + /** + !#en + Get the world coordinates of a point given the local coordinates. + !#zh + 将一个给定的刚体本地坐标系下的点转换为世界坐标系下的点 + @param localPoint a point in local coordinates. + @param out optional, the receiving point + */ + getWorldPoint(localPoint: Vec2, out: Vec2): Vec2; + /** + !#en + Get the world coordinates of a vector given the local coordinates. + !#zh + 将一个给定的世界坐标系下的向量转换为刚体本地坐标系下的向量 + @param localVector a vector in world coordinates. + @param out optional, the receiving vector + */ + getWorldVector(localVector: Vec2, out: Vec2): Vec2; + /** + !#en + Gets a local vector relative to the body's origin given a world vector. + !#zh + 将一个给定的世界坐标系下的点转换为刚体本地坐标系下的点 + @param worldVector a vector in world coordinates. + @param out optional, the receiving vector + */ + getLocalVector(worldVector: Vec2, out: Vec2): Vec2; + /** + !#en + Get the world body origin position. + !#zh + 获取刚体世界坐标系下的原点值 + @param out optional, the receiving point + */ + getWorldPosition(out: Vec2): Vec2; + /** + !#en + Get the world body rotation angle. + !#zh + 获取刚体世界坐标系下的旋转值。 + */ + getWorldRotation(): number; + /** + !#en + Get the local position of the center of mass. + !#zh + 获取刚体本地坐标系下的质心 + */ + getLocalCenter(): Vec2; + /** + !#en + Get the world position of the center of mass. + !#zh + 获取刚体世界坐标系下的质心 + */ + getWorldCenter(): Vec2; + /** + !#en + Get the world linear velocity of a world point attached to this body. + !#zh + 获取刚体上指定点的线性速度 + @param worldPoint a point in world coordinates. + @param out optional, the receiving point + */ + getLinearVelocityFromWorldPoint(worldPoint: Vec2, out: Vec2): Vec2; + /** + !#en + Get total mass of the body. + !#zh + 获取刚体的质量。 + */ + getMass(): number; + /** + !#en + Get the rotational inertia of the body about the local origin. + !#zh + 获取刚体本地坐标系下原点的旋转惯性 + */ + getInertia(): number; + /** + !#en + Get all the joints connect to the rigidbody. + !#zh + 获取链接到此刚体的所有关节 + */ + getJointList(): [Joint]; + /** + !#en + Apply a force at a world point. If the force is not + applied at the center of mass, it will generate a torque and + affect the angular velocity. + !#zh + 施加一个力到刚体上的一个点。如果力没有施加到刚体的质心上,还会产生一个扭矩并且影响到角速度。 + @param force the world force vector. + @param point the world position. + @param wake also wake up the body. + */ + applyForce(force: Vec2, point: Vec2, wake: boolean): void; + /** + !#en + Apply a force to the center of mass. + !#zh + 施加一个力到刚体上的质心上。 + @param force the world force vector. + @param wake also wake up the body. + */ + applyForceToCenter(force: Vec2, wake: boolean): void; + /** + !#en + Apply a torque. This affects the angular velocity. + !#zh + 施加一个扭矩力,将影响刚体的角速度 + @param torque about the z-axis (out of the screen), usually in N-m. + @param wake also wake up the body + */ + applyTorque(torque: number, wake: boolean): void; + /** + !#en + Apply a impulse at a world point, This immediately modifies the velocity. + If the impulse is not applied at the center of mass, it will generate a torque and + affect the angular velocity. + !#zh + 施加冲量到刚体上的一个点,将立即改变刚体的线性速度。 + 如果冲量施加到的点不是刚体的质心,那么将产生一个扭矩并影响刚体的角速度。 + @param impulse the world impulse vector, usually in N-seconds or kg-m/s. + @param point the world position + @param wake alse wake up the body + */ + applyLinearImpulse(impulse: Vec2, point: Vec2, wake: boolean): void; + /** + !#en + Apply an angular impulse. + !#zh + 施加一个角速度冲量。 + @param impulse the angular impulse in units of kg*m*m/s + @param wake also wake up the body + */ + applyAngularImpulse(impulse: number, wake: boolean): void; + /** + !#en + Synchronize node's world position to box2d rigidbody's position. + If enableAnimated is true and rigidbody's type is Animated type, + will set linear velocity instead of directly set rigidbody's position. + !#zh + 同步节点的世界坐标到 box2d 刚体的坐标上。 + 如果 enableAnimated 是 true,并且刚体的类型是 Animated ,那么将设置刚体的线性速度来代替直接设置刚体的位置。 + @param enableAnimated enableAnimated + */ + syncPosition(enableAnimated: boolean): void; + /** + !#en + Synchronize node's world angle to box2d rigidbody's angle. + If enableAnimated is true and rigidbody's type is Animated type, + will set angular velocity instead of directly set rigidbody's angle. + !#zh + 同步节点的世界旋转角度值到 box2d 刚体的旋转值上。 + 如果 enableAnimated 是 true,并且刚体的类型是 Animated ,那么将设置刚体的角速度来代替直接设置刚体的角度。 + @param enableAnimated enableAnimated + */ + syncRotation(enableAnimated: boolean): void; + } + /** Loader for resource loading process. It's a singleton object. */ + export class loader extends Pipeline { + /** The asset loader in cc.loader's pipeline, it's by default the first pipe. + It's used to identify an asset's type, and determine how to download it. */ + static assetLoader: any; + /** The downloader in cc.loader's pipeline, it's by default the second pipe. + It's used to download files with several handlers: pure text, image, script, audio, font, uuid. + You can add your own download function with addDownloadHandlers */ + static downloader: any; + /** The downloader in cc.loader's pipeline, it's by default the third pipe. + It's used to parse downloaded content with several handlers: JSON, image, plist, fnt, uuid. + You can add your own download function with addLoadHandlers */ + static loader: any; + /** + Gets a new XMLHttpRequest instance. + */ + static getXMLHttpRequest(): XMLHttpRequest; + /** + Add custom supported types handler or modify existing type handler for download process. + @param extMap Custom supported types with corresponded handler + + @example + ```js + cc.loader.addDownloadHandlers({ + // This will match all url with `.scene` extension or all url with `scene` type + 'scene' : function (url, callback) {} + }); + ``` + */ + static addDownloadHandlers(extMap: any): void; + /** + Add custom supported types handler or modify existing type handler for load process. + @param extMap Custom supported types with corresponded handler + + @example + ```js + cc.loader.addLoadHandlers({ + // This will match all url with `.scene` extension or all url with `scene` type + 'scene' : function (url, callback) {} + }); + ``` + */ + static addLoadHandlers(extMap: any): void; + /** + Load resources with a progression callback and a complete callback. + The progression callback is the same as Pipeline's {{#crossLink "LoadingItems/onProgress:method"}}onProgress{{/crossLink}} + The complete callback is almost the same as Pipeline's {{#crossLink "LoadingItems/onComplete:method"}}onComplete{{/crossLink}} + The only difference is when user pass a single url as resources, the complete callback will set its result directly as the second parameter. + @param resources Url list in an array + @param progressCallback Callback invoked when progression change + @param completeCallback Callback invoked when all resources loaded + + @example + ```js + cc.loader.load('a.png', function (err, tex) { + cc.log('Result should be a texture: ' + (tex instanceof cc.Texture2D)); + }); + + cc.loader.load('http://example.com/a.png', function (err, tex) { + cc.log('Should load a texture from external url: ' + (tex instanceof cc.Texture2D)); + }); + + cc.loader.load({url: 'http://example.com/getImageREST?file=a.png', type: 'png'}, function (err, tex) { + cc.log('Should load a texture from RESTful API by specify the type: ' + (tex instanceof cc.Texture2D)); + }); + + cc.loader.load(['a.png', 'b.json'], function (errors, results) { + if (errors) { + for (var i = 0; i < errors.length; i++) { + cc.log('Error url [' + errors[i] + ']: ' + results.getError(errors[i])); + } + } + var aTex = results.getContent('a.png'); + var bJsonObj = results.getContent('b.json'); + }); + ``` + */ + static load(resources: string|string[]|{uuid?: string, url?: string, type?: string}, completeCallback?: Function): void; + static load(resources: string|string[]|{uuid?: string, url?: string, type?: string}, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: Function|null): void; + /** + Load resources from the "resources" folder inside the "assets" folder of your project.
+
+ Note: All asset URLs in Creator use forward slashes, URLs using backslashes will not work. + @param url Url of the target resource. + The url is relative to the "resources" folder, extensions must be omitted. + @param type Only asset of type will be loaded if this argument is supplied. + @param progressCallback Callback invoked when progression change. + @param completeCallback Callback invoked when the resource loaded. + + @example + ```js + // load the prefab (project/assets/resources/misc/character/cocos) from resources folder + cc.loader.loadRes('misc/character/cocos', function (err, prefab) { + if (err) { + cc.error(err.message || err); + return; + } + cc.log('Result should be a prefab: ' + (prefab instanceof cc.Prefab)); + }); + + // load the sprite frame of (project/assets/resources/imgs/cocos.png) from resources folder + cc.loader.loadRes('imgs/cocos', cc.SpriteFrame, function (err, spriteFrame) { + if (err) { + cc.error(err.message || err); + return; + } + cc.log('Result should be a sprite frame: ' + (spriteFrame instanceof cc.SpriteFrame)); + }); + ``` + */ + static loadRes(url: string, type: typeof cc.Asset, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any) => void)|null): void; + static loadRes(url: string, type: typeof cc.Asset, completeCallback: (error: Error, resource: any) => void): void; + static loadRes(url: string, type: typeof cc.Asset): void; + static loadRes(url: string, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any) => void)|null): void; + static loadRes(url: string, completeCallback: (error: Error, resource: any) => void): void; + static loadRes(url: string): void; + /** + This method is like {{#crossLink "loader/loadRes:method"}}{{/crossLink}} except that it accepts array of url. + @param urls Array of URLs of the target resource. + The url is relative to the "resources" folder, extensions must be omitted. + @param type Only asset of type will be loaded if this argument is supplied. + @param progressCallback Callback invoked when progression change. + @param completeCallback A callback which is called when all assets have been loaded, or an error occurs. + + @example + ```js + // load the SpriteFrames from resources folder + var spriteFrames; + var urls = ['misc/characters/character_01', 'misc/weapons/weapons_01']; + cc.loader.loadResArray(urls, cc.SpriteFrame, function (err, assets) { + if (err) { + cc.error(err); + return; + } + spriteFrames = assets; + // ... + }); + ``` + */ + static loadResArray(url: string[], type: typeof cc.Asset, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any[]) => void)|null): void; + static loadResArray(url: string[], type: typeof cc.Asset, completeCallback: (error: Error, resource: any[]) => void): void; + static loadResArray(url: string[], type: typeof cc.Asset): void; + static loadResArray(url: string[], progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any[]) => void)|null): void; + static loadResArray(url: string[], completeCallback: (error: Error, resource: any[]) => void): void; + static loadResArray(url: string[]): void; + /** + Load all assets in a folder inside the "assets/resources" folder of your project.
+
+ Note: All asset URLs in Creator use forward slashes, URLs using backslashes will not work. + @param url Url of the target folder. + The url is relative to the "resources" folder, extensions must be omitted. + @param type Only asset of type will be loaded if this argument is supplied. + @param progressCallback Callback invoked when progression change. + @param completeCallback A callback which is called when all assets have been loaded, or an error occurs. + + @example + ```js + // load the texture (resources/imgs/cocos.png) and the corresponding sprite frame + cc.loader.loadResDir('imgs/cocos', function (err, assets) { + if (err) { + cc.error(err); + return; + } + var texture = assets[0]; + var spriteFrame = assets[1]; + }); + + // load all textures in "resources/imgs/" + cc.loader.loadResDir('imgs', cc.Texture2D, function (err, textures) { + var texture1 = textures[0]; + var texture2 = textures[1]; + }); + + // load all JSONs in "resources/data/" + cc.loader.loadResDir('data', function (err, objects, urls) { + var data = objects[0]; + var url = urls[0]; + }); + ``` + */ + static loadResDir(url: string, type: typeof cc.Asset, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any[], urls: string[]) => void)|null): void; + static loadResDir(url: string, type: typeof cc.Asset, completeCallback: (error: Error, resource: any[], urls: string[]) => void): void; + static loadResDir(url: string, type: typeof cc.Asset): void; + static loadResDir(url: string, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any[], urls: string[]) => void)|null): void; + static loadResDir(url: string, completeCallback: (error: Error, resource: any[], urls: string[]) => void): void; + static loadResDir(url: string): void; + /** + Get resource data by id.
+ When you load resources with {{#crossLink "loader/load:method"}}{{/crossLink}} or {{#crossLink "loader/loadRes:method"}}{{/crossLink}}, + the url will be the unique identity of the resource. + After loaded, you can acquire them by passing the url to this API. + @param url url + @param type Only asset of type will be returned if this argument is supplied. + */ + static getRes(url: string, type?: Function): any; + /** + !#en Get all resource dependencies of the requested asset in an array, including itself. + The owner parameter accept the following types: 1. The asset itself; 2. The resource url; 3. The asset's uuid.
+ The returned array stores the dependencies with their uuids, after retrieve dependencies, + you can release them, access dependent assets by passing the uuid to {{#crossLink "loader/getRes:method"}}{{/crossLink}}, or other stuffs you want.
+ For release all dependencies of an asset, please refer to {{#crossLink "loader/release:method"}}{{/crossLink}} + Here is some examples: + !#zh 获取一个指定资源的所有依赖资源,包含它自身,并保存在数组中返回。owner 参数接收以下几种类型:1. 资源 asset 对象;2. 资源目录下的 url;3. 资源的 uuid。
+ 返回的数组将仅保存依赖资源的 uuid,获取这些 uuid 后,你可以从 loader 释放这些资源;通过 {{#crossLink "loader/getRes:method"}}{{/crossLink}} 获取某个资源或者进行其他你需要的操作。
+ 想要释放一个资源及其依赖资源,可以参考 {{#crossLink "loader/release:method"}}{{/crossLink}}。下面是一些示例代码: + @param owner The owner asset or the resource url or the asset's uuid + + @example + ```js + // Release all dependencies of a loaded prefab + var deps = cc.loader.getDependsRecursively(prefab); + cc.loader.release(deps); + // Retrieve all dependent textures + var deps = cc.loader.getDependsRecursively('prefabs/sample'); + var textures = []; + for (var i = 0; i < deps.length; ++i) { + var item = cc.loader.getRes(deps[i]); + if (item instanceof cc.Texture2D) { + textures.push(item); + } + } + ``` + */ + static getDependsRecursively(owner: Asset|RawAsset|string): any[]; + /** + !#en + Release the content of an asset or an array of assets by uuid. + Start from v1.3, this method will not only remove the cache of the asset in loader, but also clean up its content. + For example, if you release a texture, the texture asset and its gl texture data will be freed up. + In complexe project, you can use this function with {{#crossLink "loader/getDependsRecursively:method"}}{{/crossLink}} to free up memory in critical circumstances. + Notice, this method may cause the texture to be unusable, if there are still other nodes use the same texture, they may turn to black and report gl errors. + If you only want to remove the cache of an asset, please use {{#crossLink "pipeline/removeItem:method"}}{{/crossLink}} + !#zh + 通过 id(通常是资源 url)来释放一个资源或者一个资源数组。 + 从 v1.3 开始,这个方法不仅会从 loader 中删除资源的缓存引用,还会清理它的资源内容。 + 比如说,当你释放一个 texture 资源,这个 texture 和它的 gl 贴图数据都会被释放。 + 在复杂项目中,我们建议你结合 {{#crossLink "loader/getDependsRecursively:method"}}{{/crossLink}} 来使用,便于在设备内存告急的情况下更快地释放不再需要的资源的内存。 + 注意,这个函数可能会导致资源贴图或资源所依赖的贴图不可用,如果场景中存在节点仍然依赖同样的贴图,它们可能会变黑并报 GL 错误。 + 如果你只想删除一个资源的缓存引用,请使用 {{#crossLink "pipeline/removeItem:method"}}{{/crossLink}} + @param asset asset + + @example + ```js + // Release a texture which is no longer need + cc.loader.release(texture); + // Release all dependencies of a loaded prefab + var deps = cc.loader.getDependsRecursively('prefabs/sample'); + cc.loader.release(deps); + // If there is no instance of this prefab in the scene, the prefab and its dependencies like textures, sprite frames, etc, will be freed up. + // If you have some other nodes share a texture in this prefab, you can skip it in two ways: + // 1. Forbid auto release a texture before release + cc.loader.setAutoRelease(texture2d, false); + // 2. Remove it from the dependencies array + var deps = cc.loader.getDependsRecursively('prefabs/sample'); + var index = deps.indexOf(texture2d._uuid); + if (index !== -1) + deps.splice(index, 1); + cc.loader.release(deps); + ``` + */ + static release(asset: Asset|RawAsset|string|any[]): void; + /** + !#en Release the asset by its object. Refer to {{#crossLink "loader/release:method"}}{{/crossLink}} for detailed informations. + !#zh 通过资源对象自身来释放资源。详细信息请参考 {{#crossLink "loader/release:method"}}{{/crossLink}} + @param asset asset + */ + static releaseAsset(asset: Asset): void; + /** + !#en Release the asset loaded by {{#crossLink "loader/loadRes:method"}}{{/crossLink}}. Refer to {{#crossLink "loader/release:method"}}{{/crossLink}} for detailed informations. + !#zh 释放通过 {{#crossLink "loader/loadRes:method"}}{{/crossLink}} 加载的资源。详细信息请参考 {{#crossLink "loader/release:method"}}{{/crossLink}} + @param url url + @param type Only asset of type will be released if this argument is supplied. + */ + static releaseRes(url: string, type?: Function): void; + /** + !#en Release the all assets loaded by {{#crossLink "loader/loadResDir:method"}}{{/crossLink}}. Refer to {{#crossLink "loader/release:method"}}{{/crossLink}} for detailed informations. + !#zh 释放通过 {{#crossLink "loader/loadResDir:method"}}{{/crossLink}} 加载的资源。详细信息请参考 {{#crossLink "loader/release:method"}}{{/crossLink}} + @param url url + @param type Only asset of type will be released if this argument is supplied. + */ + static releaseResDir(url: string, type?: Function): void; + /** + !#en Resource all assets. Refer to {{#crossLink "loader/release:method"}}{{/crossLink}} for detailed informations. + !#zh 释放所有资源。详细信息请参考 {{#crossLink "loader/release:method"}}{{/crossLink}} + */ + static releaseAll(): void; + /** + !#en + Indicates whether to release the asset when loading a new scene.
+ By default, when loading a new scene, all assets in the previous scene will be released or preserved + according to whether the previous scene checked the "Auto Release Assets" option. + On the other hand, assets dynamically loaded by using `cc.loader.loadRes` or `cc.loader.loadResDir` + will not be affected by that option, remain not released by default.
+ Use this API to change the default behavior on a single asset, to force preserve or release specified asset when scene switching.
+
+ See: {{#crossLink "loader/setAutoReleaseRecursively:method"}}cc.loader.setAutoReleaseRecursively{{/crossLink}}, {{#crossLink "loader/isAutoRelease:method"}}cc.loader.isAutoRelease{{/crossLink}} + !#zh + 设置当场景切换时是否自动释放资源。
+ 默认情况下,当加载新场景时,旧场景的资源根据旧场景是否勾选“Auto Release Assets”,将会被释放或者保留。 + 而使用 `cc.loader.loadRes` 或 `cc.loader.loadResDir` 动态加载的资源,则不受场景设置的影响,默认不自动释放。
+ 使用这个 API 可以在单个资源上改变这个默认行为,强制在切换场景时保留或者释放指定资源。
+
+ 参考:{{#crossLink "loader/setAutoReleaseRecursively:method"}}cc.loader.setAutoReleaseRecursively{{/crossLink}},{{#crossLink "loader/isAutoRelease:method"}}cc.loader.isAutoRelease{{/crossLink}} + @param assetOrUrlOrUuid asset object or the raw asset's url or uuid + @param autoRelease indicates whether should release automatically + + @example + ```js + // auto release the texture event if "Auto Release Assets" disabled in current scene + cc.loader.setAutoRelease(texture2d, true); + // don't release the texture even if "Auto Release Assets" enabled in current scene + cc.loader.setAutoRelease(texture2d, false); + // first parameter can be url + cc.loader.setAutoRelease(audioUrl, false); + ``` + */ + static setAutoRelease(assetOrUrlOrUuid: Asset|string, autoRelease: boolean): void; + /** + !#en + Indicates whether to release the asset and its referenced other assets when loading a new scene.
+ By default, when loading a new scene, all assets in the previous scene will be released or preserved + according to whether the previous scene checked the "Auto Release Assets" option. + On the other hand, assets dynamically loaded by using `cc.loader.loadRes` or `cc.loader.loadResDir` + will not be affected by that option, remain not released by default.
+ Use this API to change the default behavior on the specified asset and its recursively referenced assets, to force preserve or release specified asset when scene switching.
+
+ See: {{#crossLink "loader/setAutoRelease:method"}}cc.loader.setAutoRelease{{/crossLink}}, {{#crossLink "loader/isAutoRelease:method"}}cc.loader.isAutoRelease{{/crossLink}} + !#zh + 设置当场景切换时是否自动释放资源及资源引用的其它资源。
+ 默认情况下,当加载新场景时,旧场景的资源根据旧场景是否勾选“Auto Release Assets”,将会被释放或者保留。 + 而使用 `cc.loader.loadRes` 或 `cc.loader.loadResDir` 动态加载的资源,则不受场景设置的影响,默认不自动释放。
+ 使用这个 API 可以在指定资源及资源递归引用到的所有资源上改变这个默认行为,强制在切换场景时保留或者释放指定资源。
+
+ 参考:{{#crossLink "loader/setAutoRelease:method"}}cc.loader.setAutoRelease{{/crossLink}},{{#crossLink "loader/isAutoRelease:method"}}cc.loader.isAutoRelease{{/crossLink}} + @param assetOrUrlOrUuid asset object or the raw asset's url or uuid + @param autoRelease indicates whether should release automatically + + @example + ```js + // auto release the SpriteFrame and its Texture event if "Auto Release Assets" disabled in current scene + cc.loader.setAutoReleaseRecursively(spriteFrame, true); + // don't release the SpriteFrame and its Texture even if "Auto Release Assets" enabled in current scene + cc.loader.setAutoReleaseRecursively(spriteFrame, false); + // don't release the Prefab and all the referenced assets + cc.loader.setAutoReleaseRecursively(prefab, false); + ``` + */ + static setAutoReleaseRecursively(assetOrUrlOrUuid: Asset|string, autoRelease: boolean): void; + /** + !#en + Returns whether the asset is configured as auto released, despite how "Auto Release Assets" property is set on scene asset.
+
+ See: {{#crossLink "loader/setAutoRelease:method"}}cc.loader.setAutoRelease{{/crossLink}}, {{#crossLink "loader/setAutoReleaseRecursively:method"}}cc.loader.setAutoReleaseRecursively{{/crossLink}} + + !#zh + 返回指定的资源是否有被设置为自动释放,不论场景的“Auto Release Assets”如何设置。
+
+ 参考:{{#crossLink "loader/setAutoRelease:method"}}cc.loader.setAutoRelease{{/crossLink}},{{#crossLink "loader/setAutoReleaseRecursively:method"}}cc.loader.setAutoReleaseRecursively{{/crossLink}} + @param assetOrUrl asset object or the raw asset's url + */ + static isAutoRelease(assetOrUrl: Asset|string): boolean; + } + /** !#en + LoadingItems is the queue of items which can flow them into the loading pipeline.
+ Please don't construct it directly, use {{#crossLink "LoadingItems.create"}}LoadingItems.create{{/crossLink}} instead, because we use an internal pool to recycle the queues.
+ It hold a map of items, each entry in the map is a url to object key value pair.
+ Each item always contains the following property:
+ - id: The identification of the item, usually it's identical to url
+ - url: The url
+ - type: The type, it's the extension name of the url by default, could be specified manually too.
+ - error: The error happened in pipeline will be stored in this property.
+ - content: The content processed by the pipeline, the final result will also be stored in this property.
+ - complete: The flag indicate whether the item is completed by the pipeline.
+ - states: An object stores the states of each pipe the item go through, the state can be: Pipeline.ItemState.WORKING | Pipeline.ItemState.ERROR | Pipeline.ItemState.COMPLETE
+
+ Item can hold other custom properties.
+ Each LoadingItems object will be destroyed for recycle after onComplete callback
+ So please don't hold its reference for later usage, you can copy properties in it though. + !#zh + LoadingItems 是一个加载对象队列,可以用来输送加载对象到加载管线中。
+ 请不要直接使用 new 构造这个类的对象,你可以使用 {{#crossLink "LoadingItems.create"}}LoadingItems.create{{/crossLink}} 来创建一个新的加载队列,这样可以允许我们的内部对象池回收并重利用加载队列。 + 它有一个 map 属性用来存放加载项,在 map 对象中已 url 为 key 值。
+ 每个对象都会包含下列属性:
+ - id:该对象的标识,通常与 url 相同。
+ - url:路径
+ - type: 类型,它这是默认的 URL 的扩展名,可以手动指定赋值。
+ - error:pipeline 中发生的错误将被保存在这个属性中。
+ - content: pipeline 中处理的临时结果,最终的结果也将被存储在这个属性中。
+ - complete:该标志表明该对象是否通过 pipeline 完成。
+ - states:该对象存储每个管道中对象经历的状态,状态可以是 Pipeline.ItemState.WORKING | Pipeline.ItemState.ERROR | Pipeline.ItemState.COMPLETE
+
+ 对象可容纳其他自定义属性。
+ 每个 LoadingItems 对象都会在 onComplete 回调之后被销毁,所以请不要持有它的引用并在结束回调之后依赖它的内容执行任何逻辑,有这种需求的话你可以提前复制它的内容。 */ + export class LoadingItems extends CallbacksInvoker { + /** + !#en This is a callback which will be invoked while an item flow out the pipeline. + You can pass the callback function in LoadingItems.create or set it later. + !#zh 这个回调函数将在 item 加载结束后被调用。你可以在构造时传递这个回调函数或者是在构造之后直接设置。 + @param completedCount The number of the items that are already completed. + @param totalCount The total number of the items. + @param item The latest item which flow out the pipeline. + + @example + ```js + loadingItems.onProgress = function (completedCount, totalCount, item) { + var progress = (100 * completedCount / totalCount).toFixed(2); + cc.log(progress + '%'); + } + ``` + */ + onProgress(completedCount: number, totalCount: number, item: any): void; + /** + !#en This is a callback which will be invoked while all items is completed, + You can pass the callback function in LoadingItems.create or set it later. + !#zh 该函数将在加载队列全部完成时被调用。你可以在构造时传递这个回调函数或者是在构造之后直接设置。 + @param errors All errored urls will be stored in this array, if no error happened, then it will be null + @param items All items. + + @example + ```js + loadingItems.onComplete = function (errors, items) { + if (error) + cc.log('Completed with ' + errors.length + ' errors'); + else + cc.log('Completed ' + items.totalCount + ' items'); + } + ``` + */ + onComplete(errors: any[], items: LoadingItems): void; + /** !#en The map of all items. + !#zh 存储所有加载项的对象。 */ + map: any; + /** !#en The map of completed items. + !#zh 存储已经完成的加载项。 */ + completed: any; + /** !#en Total count of all items. + !#zh 所有加载项的总数。 */ + totalCount: number; + /** !#en Total count of completed items. + !#zh 所有完成加载项的总数。 */ + completedCount: number; + /** !#en Activated or not. + !#zh 是否启用。 */ + active: boolean; + /** + !#en The constructor function of LoadingItems, this will use recycled LoadingItems in the internal pool if possible. + You can pass onProgress and onComplete callbacks to visualize the loading process. + !#zh LoadingItems 的构造函数,这种构造方式会重用内部对象缓冲池中的 LoadingItems 队列,以尽量避免对象创建。 + 你可以传递 onProgress 和 onComplete 回调函数来获知加载进度信息。 + @param pipeline The pipeline to process the queue. + @param urlList The items array. + @param onProgress The progression callback, refer to {{#crossLink "LoadingItems.onProgress"}}{{/crossLink}} + @param onComplete The completion callback, refer to {{#crossLink "LoadingItems.onComplete"}}{{/crossLink}} + + @example + ```js + LoadingItems.create(cc.loader, ['a.png', 'b.plist'], function (completedCount, totalCount, item) { + var progress = (100 * completedCount / totalCount).toFixed(2); + cc.log(progress + '%'); + }, function (errors, items) { + if (errors) { + for (var i = 0; i < errors.length; ++i) { + cc.log('Error url: ' + errors[i] + ', error: ' + items.getError(errors[i])); + } + } + else { + var result_a = items.getContent('a.png'); + // ... + } + }) + ``` + */ + static create(pipeline: Pipeline, urlList: any[], onProgress: Function, onComplete: Function): LoadingItems; + /** + !#en Retrieve the LoadingItems queue object for an item. + !#zh 通过 item 对象获取它的 LoadingItems 队列。 + @param item The item to query + */ + static getQueue(item: any): LoadingItems; + /** + !#en Complete an item in the LoadingItems queue, please do not call this method unless you know what's happening. + !#zh 通知 LoadingItems 队列一个 item 对象已完成,请不要调用这个函数,除非你知道自己在做什么。 + @param item The item which has completed + */ + static itemComplete(item: any): void; + /** + !#en Add urls to the LoadingItems queue. + !#zh 向一个 LoadingItems 队列添加加载项。 + @param urlList The url list to be appended, the url can be object or string + */ + append(urlList: any[]): any[]; + /** + !#en Complete a LoadingItems queue, please do not call this method unless you know what's happening. + !#zh 完成一个 LoadingItems 队列,请不要调用这个函数,除非你知道自己在做什么。 + */ + allComplete(): void; + /** + !#en Check whether all items are completed. + !#zh 检查是否所有加载项都已经完成。 + */ + isCompleted(): boolean; + /** + !#en Check whether an item is completed. + !#zh 通过 id 检查指定加载项是否已经加载完成。 + @param id The item's id. + */ + isItemCompleted(id: string): boolean; + /** + !#en Check whether an item exists. + !#zh 通过 id 检查加载项是否存在。 + @param id The item's id. + */ + exists(id: string): boolean; + /** + !#en Returns the content of an internal item. + !#zh 通过 id 获取指定对象的内容。 + @param id The item's id. + */ + getContent(id: string): any; + /** + !#en Returns the error of an internal item. + !#zh 通过 id 获取指定对象的错误信息。 + @param id The item's id. + */ + getError(id: string): any; + /** + !#en Add a listener for an item, the callback will be invoked when the item is completed. + !#zh 监听加载项(通过 key 指定)的完成事件。 + @param key key + @param callback can be null + @param target can be null + */ + addListener(key: string, callback: Function, target: any): boolean; + /** + !#en + Check if the specified key has any registered callback.
+ If a callback is also specified, it will only return true if the callback is registered. + !#zh + 检查指定的加载项是否有完成事件监听器。
+ 如果同时还指定了一个回调方法,并且回调有注册,它只会返回 true。 + @param key key + @param callback callback + @param target target + */ + hasListener(key: string, callback?: Function, target?: any): boolean; + /** + !#en + Removes a listener.
+ It will only remove when key, callback, target all match correctly. + !#zh + 移除指定加载项已经注册的完成事件监听器。
+ 只会删除 key, callback, target 均匹配的监听器。 + @param key key + @param callback callback + @param target target + */ + remove(key: string, callback: Function, target: any): boolean; + /** + !#en + Removes all callbacks registered in a certain event + type or all callbacks registered with a certain target. + !#zh 删除指定目标的所有完成事件监听器。 + @param key The event key to be removed or the target to be removed + */ + removeAllListeners(key: string|any): void; + /** + !#en Complete an item in the LoadingItems queue, please do not call this method unless you know what's happening. + !#zh 通知 LoadingItems 队列一个 item 对象已完成,请不要调用这个函数,除非你知道自己在做什么。 + @param id The item url + */ + itemComplete(id: string): void; + /** + !#en Destroy the LoadingItems queue, the queue object won't be garbage collected, it will be recycled, so every after destroy is not reliable. + !#zh 销毁一个 LoadingItems 队列,这个队列对象会被内部缓冲池回收,所以销毁后的所有内部信息都是不可依赖的。 + */ + destroy(): void; + } + /** !#en + A pipeline describes a sequence of manipulations, each manipulation is called a pipe.
+ It's designed for loading process. so items should be urls, and the url will be the identity of each item during the process.
+ A list of items can flow in the pipeline and it will output the results of all pipes.
+ They flow in the pipeline like water in tubes, they go through pipe by pipe separately.
+ Finally all items will flow out the pipeline and the process is finished. + + !#zh + pipeline 描述了一系列的操作,每个操作都被称为 pipe。
+ 它被设计来做加载过程的流程管理。所以 item 应该是 url,并且该 url 将是在处理中的每个 item 的身份标识。
+ 一个 item 列表可以在 pipeline 中流动,它将输出加载项经过所有 pipe 之后的结果。
+ 它们穿过 pipeline 就像水在管子里流动,将会按顺序流过每个 pipe。
+ 最后当所有加载项都流出 pipeline 时,整个加载流程就结束了。 */ + export class Pipeline { + /** + !#en + Constructor, pass an array of pipes to construct a new Pipeline, + the pipes will be chained in the given order.
+ A pipe is an object which must contain an `id` in string and a `handle` function, + the id must be unique in the pipeline.
+ It can also include `async` property to identify whether it's an asynchronous process. + !#zh + 构造函数,通过一系列的 pipe 来构造一个新的 pipeline,pipes 将会在给定的顺序中被锁定。
+ 一个 pipe 就是一个对象,它包含了字符串类型的 ‘id’ 和 ‘handle’ 函数,在 pipeline 中 id 必须是唯一的。
+ 它还可以包括 ‘async’ 属性以确定它是否是一个异步过程。 + @param pipes pipes + + @example + ```js + var pipeline = new Pipeline([ + { + id: 'Downloader', + handle: function (item, callback) {}, + async: true + }, + {id: 'Parser', handle: function (item) {}, async: false} + ]); + ``` + */ + constructor(pipes: any[]); + /** + !#en + Insert a new pipe at the given index of the pipeline.
+ A pipe must contain an `id` in string and a `handle` function, the id must be unique in the pipeline. + !#zh + 在给定的索引位置插入一个新的 pipe。
+ 一个 pipe 必须包含一个字符串类型的 ‘id’ 和 ‘handle’ 函数,该 id 在 pipeline 必须是唯一标识。 + @param pipe The pipe to be inserted + @param index The index to insert + */ + insertPipe(pipe: any, index: number): void; + /** + !en + Insert a pipe to the end of an existing pipe. The existing pipe must be a valid pipe in the pipeline. + !zh + 在当前 pipeline 的一个已知 pipe 后面插入一个新的 pipe。 + @param refPipe An existing pipe in the pipeline. + @param newPipe The pipe to be inserted. + */ + insertPipeAfter(refPipe: any, newPipe: any): void; + /** + !#en + Add a new pipe at the end of the pipeline.
+ A pipe must contain an `id` in string and a `handle` function, the id must be unique in the pipeline. + !#zh + 添加一个新的 pipe 到 pipeline 尾部。
+ 该 pipe 必须包含一个字符串类型 ‘id’ 和 ‘handle’ 函数,该 id 在 pipeline 必须是唯一标识。 + @param pipe The pipe to be appended + */ + appendPipe(pipe: any): void; + /** + !#en + Let new items flow into the pipeline.
+ Each item can be a simple url string or an object, + if it's an object, it must contain `id` property.
+ You can specify its type by `type` property, by default, the type is the extension name in url.
+ By adding a `skips` property including pipe ids, you can skip these pipe.
+ The object can contain any supplementary property as you want.
+ !#zh + 让新的 item 流入 pipeline 中。
+ 这里的每个 item 可以是一个简单字符串类型的 url 或者是一个对象, + 如果它是一个对象的话,他必须要包含 ‘id’ 属性。
+ 你也可以指定它的 ‘type’ 属性类型,默认情况下,该类型是 ‘url’ 的后缀名。
+ 也通过添加一个 包含 ‘skips’ 属性的 item 对象,你就可以跳过 skips 中包含的 pipe。
+ 该对象可以包含任何附加属性。 + @param items items + + @example + ```js + pipeline.flowIn([ + 'res/Background.png', + { + id: 'res/scene.json', + type: 'scene', + name: 'scene', + skips: ['Downloader'] + } + ]); + ``` + */ + flowIn(items: any[]): void; + /** + !#en + Let new items flow into the pipeline and give a callback when the list of items are all completed.
+ This is for loading dependencies for an existing item in flow, usually used in a pipe logic.
+ For example, we have a loader for scene configuration file in JSON, the scene will only be fully loaded
+ after all its dependencies are loaded, then you will need to use function to flow in all dependencies
+ found in the configuration file, and finish the loader pipe only after all dependencies are loaded (in the callback). + !#zh + 让新 items 流入 pipeline 并且当 item 列表完成时进行回调函数。
+ 这个 API 的使用通常是为了加载依赖项。
+ 例如:
+ 我们需要加载一个场景配置的 JSON 文件,该场景会将所有的依赖项全部都加载完毕以后,进行回调表示加载完毕。 + @param urlList urlList + @param callback callback + */ + flowInDeps(urlList: any[], callback: Function): any[]; + /** + !#en + Copy the item states from one source item to all destination items.
+ It's quite useful when a pipe generate new items from one source item,
+ then you should flowIn these generated items into pipeline,
+ but you probably want them to skip all pipes the source item already go through,
+ you can achieve it with this API.
+
+ For example, an unzip pipe will generate more items, but you won't want them to pass unzip or download pipe again. + !#zh + 从一个源 item 向所有目标 item 复制它的 pipe 状态,用于避免重复通过部分 pipe。
+ 当一个源 item 生成了一系列新的 items 时很有用,
+ 你希望让这些新的依赖项进入 pipeline,但是又不希望它们通过源 item 已经经过的 pipe,
+ 但是你可能希望他们源 item 已经通过并跳过所有 pipes,
+ 这个时候就可以使用这个 API。 + @param srcItem The source item + @param dstItems A single destination item or an array of destination items + */ + copyItemStates(srcItem: any, dstItems: any[]|any): void; + /** + !#en Returns whether the pipeline is flowing (contains item) currently. + !#zh 获取 pipeline 当前是否正在处理中。 + */ + isFlowing(): boolean; + /** + !#en Returns all items in pipeline. Returns null, please use API of Loader or LoadingItems. + !#zh 获取 pipeline 中的所有 items。返回 null,请使用 Loader / LoadingItems API。 + */ + getItems(): LoadingItems; + /** + !#en Returns an item in pipeline. + !#zh 根据 id 获取一个 item + @param id The id of the item + */ + getItem(id: any): any; + /** + !#en Removes an completed item in pipeline. + It will only remove the cache in the pipeline or loader, its dependencies won't be released. + cc.loader provided another method to completely cleanup the resource and its dependencies, + please refer to {{#crossLink "loader/release:method"}}cc.loader.release{{/crossLink}} + !#zh 移除指定的已完成 item。 + 这将仅仅从 pipeline 或者 loader 中删除其缓存,并不会释放它所依赖的资源。 + cc.loader 中提供了另一种删除资源及其依赖的清理方法,请参考 {{#crossLink "loader/release:method"}}cc.loader.release{{/crossLink}} + @param id The id of the item + */ + removeItem(id: any): boolean; + /** + !#en Clear the current pipeline, this function will clean up the items. + !#zh 清空当前 pipeline,该函数将清理 items。 + */ + clear(): void; + } + /** !#en Key map for keyboard event + !#zh 键盘事件的按键值 */ + export enum KEY { + none = 0, + back = 0, + menu = 0, + backspace = 0, + tab = 0, + enter = 0, + shift = 0, + ctrl = 0, + alt = 0, + pause = 0, + capslock = 0, + escape = 0, + space = 0, + pageup = 0, + pagedown = 0, + end = 0, + home = 0, + left = 0, + up = 0, + right = 0, + down = 0, + select = 0, + insert = 0, + Delete = 0, + a = 0, + b = 0, + c = 0, + d = 0, + e = 0, + f = 0, + g = 0, + h = 0, + i = 0, + j = 0, + k = 0, + l = 0, + m = 0, + n = 0, + o = 0, + p = 0, + q = 0, + r = 0, + s = 0, + t = 0, + u = 0, + v = 0, + w = 0, + x = 0, + y = 0, + z = 0, + num0 = 0, + num1 = 0, + num2 = 0, + num3 = 0, + num4 = 0, + num5 = 0, + num6 = 0, + num7 = 0, + num8 = 0, + num9 = 0, + '*' = 0, + '+' = 0, + '-' = 0, + numdel = 0, + '/' = 0, + f1 = 0, + f2 = 0, + f3 = 0, + f4 = 0, + f5 = 0, + f6 = 0, + f7 = 0, + f8 = 0, + f9 = 0, + f10 = 0, + f11 = 0, + f12 = 0, + numlock = 0, + scrolllock = 0, + ';' = 0, + semicolon = 0, + equal = 0, + '=' = 0, + ',' = 0, + comma = 0, + dash = 0, + '.' = 0, + period = 0, + forwardslash = 0, + grave = 0, + '[' = 0, + openbracket = 0, + backslash = 0, + ']' = 0, + closebracket = 0, + quote = 0, + dpadLeft = 0, + dpadRight = 0, + dpadUp = 0, + dpadDown = 0, + dpadCenter = 0, + } + /** Image formats */ + export enum ImageFormat { + JPG = 0, + PNG = 0, + TIFF = 0, + WEBP = 0, + PVR = 0, + ETC = 0, + S3TC = 0, + ATITC = 0, + TGA = 0, + RAWDATA = 0, + UNKNOWN = 0, + getImageFormatByData = 0, + } + /** Predefined constants */ + export enum macro { + INVALID_INDEX = 0, + NODE_TAG_INVALID = 0, + PI = 0, + PI2 = 0, + FLT_MAX = 0, + FLT_MIN = 0, + RAD = 0, + DEG = 0, + UINT_MAX = 0, + REPEAT_FOREVER = 0, + FLT_EPSILON = 0, + ONE = 0, + ZERO = 0, + SRC_ALPHA = 0, + SRC_ALPHA_SATURATE = 0, + SRC_COLOR = 0, + DST_ALPHA = 0, + DST_COLOR = 0, + ONE_MINUS_SRC_ALPHA = 0, + ONE_MINUS_SRC_COLOR = 0, + ONE_MINUS_DST_ALPHA = 0, + ONE_MINUS_DST_COLOR = 0, + ONE_MINUS_CONSTANT_ALPHA = 0, + ONE_MINUS_CONSTANT_COLOR = 0, + LINEAR = 0, + BLEND_DST = 0, + WEB_ORIENTATION_PORTRAIT = 0, + WEB_ORIENTATION_LANDSCAPE_LEFT = 0, + WEB_ORIENTATION_PORTRAIT_UPSIDE_DOWN = 0, + WEB_ORIENTATION_LANDSCAPE_RIGHT = 0, + ORIENTATION_PORTRAIT = 0, + ORIENTATION_LANDSCAPE = 0, + ORIENTATION_AUTO = 0, + VERTEX_ATTRIB_FLAG_NONE = 0, + VERTEX_ATTRIB_FLAG_POSITION = 0, + VERTEX_ATTRIB_FLAG_COLOR = 0, + VERTEX_ATTRIB_FLAG_TEX_COORDS = 0, + VERTEX_ATTRIB_FLAG_POS_COLOR_TEX = 0, + GL_ALL = 0, + VERTEX_ATTRIB_POSITION = 0, + VERTEX_ATTRIB_COLOR = 0, + VERTEX_ATTRIB_TEX_COORDS = 0, + VERTEX_ATTRIB_MAX = 0, + UNIFORM_PMATRIX = 0, + UNIFORM_MVMATRIX = 0, + UNIFORM_MVPMATRIX = 0, + UNIFORM_TIME = 0, + UNIFORM_SINTIME = 0, + UNIFORM_COSTIME = 0, + UNIFORM_RANDOM01 = 0, + UNIFORM_SAMPLER = 0, + UNIFORM_MAX = 0, + SHADER_POSITION_TEXTURECOLOR = 0, + SHADER_SPRITE_POSITION_TEXTURECOLOR = 0, + SHADER_POSITION_TEXTURECOLORALPHATEST = 0, + SHADER_SPRITE_POSITION_TEXTURECOLORALPHATEST = 0, + SHADER_POSITION_COLOR = 0, + SHADER_SPRITE_POSITION_COLOR = 0, + SHADER_POSITION_TEXTURE = 0, + SHADER_POSITION_TEXTURE_UCOLOR = 0, + SHADER_POSITION_TEXTUREA8COLOR = 0, + SHADER_POSITION_UCOLOR = 0, + SHADER_POSITION_LENGTHTEXTURECOLOR = 0, + UNIFORM_PMATRIX_S = 0, + UNIFORM_MVMATRIX_S = 0, + UNIFORM_MVPMATRIX_S = 0, + UNIFORM_TIME_S = 0, + UNIFORM_SINTIME_S = 0, + UNIFORM_COSTIME_S = 0, + UNIFORM_RANDOM01_S = 0, + UNIFORM_SAMPLER_S = 0, + UNIFORM_ALPHA_TEST_VALUE_S = 0, + ATTRIBUTE_NAME_COLOR = 0, + ATTRIBUTE_NAME_POSITION = 0, + ATTRIBUTE_NAME_TEX_COORD = 0, + ITEM_SIZE = 0, + CURRENT_ITEM = 0, + ZOOM_ACTION_TAG = 0, + NORMAL_TAG = 0, + SELECTED_TAG = 0, + DISABLE_TAG = 0, + FIX_ARTIFACTS_BY_STRECHING_TEXEL = 0, + FIX_ARTIFACTS_BY_STRECHING_TEXEL_TMX = 0, + DIRECTOR_STATS_POSITION = 0, + DIRECTOR_FPS_INTERVAL = 0, + COCOSNODE_RENDER_SUBPIXEL = 0, + SPRITEBATCHNODE_RENDER_SUBPIXEL = 0, + AUTO_PREMULTIPLIED_ALPHA_FOR_PNG = 0, + OPTIMIZE_BLEND_FUNC_FOR_PREMULTIPLIED_ALPHA = 0, + TEXTURE_NPOT_SUPPORT = 0, + USE_LA88_LABELS = 0, + SPRITE_DEBUG_DRAW = 0, + LABELBMFONT_DEBUG_DRAW = 0, + LABELATLAS_DEBUG_DRAW = 0, + ENABLE_STACKABLE_ACTIONS = 0, + ENABLE_GL_STATE_CACHE = 0, + TOUCH_TIMEOUT = 0, + BATCH_VERTEX_COUNT = 0, + ENABLE_GC_FOR_NATIVE_OBJECTS = 0, + ENABLE_TILEDMAP_CULLING = 0, + DOWNLOAD_MAX_CONCURRENT = 0, + ENABLE_TRANSPARENT_CANVAS = 0, + ENABLE_WEBGL_ANTIALIAS = 0, + ENABLE_CULLING = 0, + BLEND_SRC = 0, + } + /** The base class of most of all the objects in Fireball. */ + export class Object { + /** !#en The name of the object. + !#zh 该对象的名称。 */ + name: string; + /** !#en + Indicates whether the object is not yet destroyed. (It will not be available after being destroyed)
+ When an object's `destroy` is called, it is actually destroyed after the end of this frame. + So `isValid` will return false from the next frame, while `isValid` in the current frame will still be true. + If you want to determine whether the current frame has called `destroy`, use `cc.isValid(obj, true)`, + but this is often caused by a particular logical requirements, which is not normally required. + + !#zh + 表示该对象是否可用(被 destroy 后将不可用)。
+ 当一个对象的 `destroy` 调用以后,会在这一帧结束后才真正销毁。因此从下一帧开始 `isValid` 就会返回 false,而当前帧内 `isValid` 仍然会是 true。如果希望判断当前帧是否调用过 `destroy`,请使用 `cc.isValid(obj, true)`,不过这往往是特殊的业务需求引起的,通常情况下不需要这样。 */ + isValid: boolean; + /** + !#en + Destroy this Object, and release all its own references to other objects.
+ Actual object destruction will delayed until before rendering. + From the next frame, this CCObject is not usable any more. + You can use cc.isValid(obj) to check whether the object is destroyed before accessing it. + !#zh + 销毁该对象,并释放所有它对其它对象的引用。
+ 实际销毁操作会延迟到当前帧渲染前执行。从下一帧开始,CCObject 将不再可用。 + 您可以在访问对象之前使用 cc.isValid(obj) 来检查对象是否已被销毁。 + + @example + ```js + obj.destroy(); + ``` + */ + destroy(): boolean; + } + /** Bit mask that controls object states. */ + export enum Flags { + DontSave = 0, + EditorOnly = 0, + } + /** The fullscreen API provides an easy way for web content to be presented using the user's entire screen. + It's invalid on safari, QQbrowser and android browser */ + export class screen { + /** + initialize + */ + init(): void; + /** + return true if it's full now. + */ + fullScreen(): boolean; + /** + change the screen to full mode. + @param element element + @param onFullScreenChange onFullScreenChange + */ + requestFullScreen(element: Element, onFullScreenChange: Function): void; + /** + exit the full mode. + */ + exitFullScreen(): boolean; + /** + Automatically request full screen with a touch/click event + @param element element + @param onFullScreenChange onFullScreenChange + */ + autoFullScreen(element: Element, onFullScreenChange: Function): void; + } + /** System variables */ + export class sys { + /** English language code */ + static LANGUAGE_ENGLISH: string; + /** Chinese language code */ + static LANGUAGE_CHINESE: string; + /** French language code */ + static LANGUAGE_FRENCH: string; + /** Italian language code */ + static LANGUAGE_ITALIAN: string; + /** German language code */ + static LANGUAGE_GERMAN: string; + /** Spanish language code */ + static LANGUAGE_SPANISH: string; + /** Spanish language code */ + static LANGUAGE_DUTCH: string; + /** Russian language code */ + static LANGUAGE_RUSSIAN: string; + /** Korean language code */ + static LANGUAGE_KOREAN: string; + /** Japanese language code */ + static LANGUAGE_JAPANESE: string; + /** Hungarian language code */ + static LANGUAGE_HUNGARIAN: string; + /** Portuguese language code */ + static LANGUAGE_PORTUGUESE: string; + /** Arabic language code */ + static LANGUAGE_ARABIC: string; + /** Norwegian language code */ + static LANGUAGE_NORWEGIAN: string; + /** Polish language code */ + static LANGUAGE_POLISH: string; + /** Turkish language code */ + static LANGUAGE_TURKISH: string; + /** Ukrainian language code */ + static LANGUAGE_UKRAINIAN: string; + /** Romanian language code */ + static LANGUAGE_ROMANIAN: string; + /** Bulgarian language code */ + static LANGUAGE_BULGARIAN: string; + /** Unknown language code */ + static LANGUAGE_UNKNOWN: string; + static OS_IOS: string; + static OS_ANDROID: string; + static OS_WINDOWS: string; + static OS_MARMALADE: string; + static OS_LINUX: string; + static OS_BADA: string; + static OS_BLACKBERRY: string; + static OS_OSX: string; + static OS_WP8: string; + static OS_WINRT: string; + static OS_UNKNOWN: string; + static UNKNOWN: number; + static WIN32: number; + static LINUX: number; + static MACOS: number; + static ANDROID: number; + static IPHONE: number; + static IPAD: number; + static BLACKBERRY: number; + static NACL: number; + static EMSCRIPTEN: number; + static TIZEN: number; + static WINRT: number; + static WP8: number; + static MOBILE_BROWSER: number; + static DESKTOP_BROWSER: number; + /** Indicates whether executes in editor's window process (Electron's renderer context) */ + static EDITOR_PAGE: number; + /** Indicates whether executes in editor's main process (Electron's browser context) */ + static EDITOR_CORE: number; + static WECHAT_GAME: number; + static QQ_PLAY: number; + /** BROWSER_TYPE_WECHAT */ + static BROWSER_TYPE_WECHAT: string; + /** BROWSER_TYPE_WECHAT_GAME */ + static BROWSER_TYPE_WECHAT_GAME: string; + /** BROWSER_TYPE_QQ_PLAY */ + static BROWSER_TYPE_QQ_PLAY: string; + static BROWSER_TYPE_ANDROID: string; + static BROWSER_TYPE_IE: string; + static BROWSER_TYPE_QQ: string; + static BROWSER_TYPE_MOBILE_QQ: string; + static BROWSER_TYPE_UC: string; + static BROWSER_TYPE_360: string; + static BROWSER_TYPE_BAIDU_APP: string; + static BROWSER_TYPE_BAIDU: string; + static BROWSER_TYPE_MAXTHON: string; + static BROWSER_TYPE_OPERA: string; + static BROWSER_TYPE_OUPENG: string; + static BROWSER_TYPE_MIUI: string; + static BROWSER_TYPE_FIREFOX: string; + static BROWSER_TYPE_SAFARI: string; + static BROWSER_TYPE_CHROME: string; + static BROWSER_TYPE_LIEBAO: string; + static BROWSER_TYPE_QZONE: string; + static BROWSER_TYPE_SOUGOU: string; + static BROWSER_TYPE_UNKNOWN: string; + /** Is native ? This is set to be true in jsb auto. */ + static isNative: boolean; + /** Is web browser ? */ + static isBrowser: boolean; + /** Indicate whether system is mobile system */ + static isMobile: boolean; + /** Indicate the running platform */ + static platform: number; + /** Indicate the current language of the running system */ + static language: string; + /** Indicate the running os name */ + static os: string; + /** Indicate the running os version */ + static osVersion: string; + /** Indicate the running os main version */ + static osMainVersion: number; + /** Indicate the running browser type */ + static browserType: string; + /** Indicate the running browser version */ + static browserVersion: string; + /** Indicate the real pixel resolution of the whole game window */ + static windowPixelResolution: Size; + /** cc.sys.localStorage is a local storage component. */ + static localStorage: any; + /** The capabilities of the current platform */ + static capabilities: any; + /** + Forces the garbage collection, only available in JSB + */ + static garbageCollect(): void; + /** + Dumps rooted objects, only available in JSB + */ + static dumpRoot(): void; + /** + Restart the JS VM, only available in JSB + */ + static restartVM(): void; + /** + Clean a script in the JS VM, only available in JSB + @param jsfile jsfile + */ + static cleanScript(jsfile: string): void; + /** + Check whether an object is valid, + In web engine, it will return true if the object exist + In native engine, it will return true if the JS object and the correspond native object are both valid + @param obj obj + */ + static isObjectValid(obj: any): boolean; + /** + Dump system informations + */ + static dump(): void; + /** + Open a url in browser + @param url url + */ + static openURL(url: string): void; + /** + Get the number of milliseconds elapsed since 1 January 1970 00:00:00 UTC. + */ + static now(): number; + } + /** cc.view is the singleton object which represents the game window.
+ It's main task include:
+ - Apply the design resolution policy
+ - Provide interaction with the window, like resize event on web, retina display support, etc...
+ - Manage the game view port which can be different with the window
+ - Manage the content scale and translation
+
+ Since the cc.view is a singleton, you don't need to call any constructor or create functions,
+ the standard way to use it is by calling:
+ - cc.view.methodName();
*/ + export class View { + /** +

+ Sets view's target-densitydpi for android mobile browser. it can be set to:
+ 1. cc.macro.DENSITYDPI_DEVICE, value is "device-dpi"
+ 2. cc.macro.DENSITYDPI_HIGH, value is "high-dpi" (default value)
+ 3. cc.macro.DENSITYDPI_MEDIUM, value is "medium-dpi" (browser's default value)
+ 4. cc.macro.DENSITYDPI_LOW, value is "low-dpi"
+ 5. Custom value, e.g: "480"
+

+ @param densityDPI densityDPI + */ + setTargetDensityDPI(densityDPI: string): void; + /** + Returns the current target-densitydpi value of cc.view. + */ + getTargetDensityDPI(): string; + /** + Sets whether resize canvas automatically when browser's size changed.
+ Useful only on web. + @param enabled Whether enable automatic resize with browser's resize event + */ + resizeWithBrowserSize(enabled: boolean): void; + /** + Sets the callback function for cc.view's resize action,
+ this callback will be invoked before applying resolution policy,
+ so you can do any additional modifications within the callback.
+ Useful only on web. + @param callback The callback function + */ + setResizeCallback(callback: Function|void): void; + /** + Sets the orientation of the game, it can be landscape, portrait or auto. + When set it to landscape or portrait, and screen w/h ratio doesn't fit, + cc.view will automatically rotate the game canvas using CSS. + Note that this function doesn't have any effect in native, + in native, you need to set the application orientation in native project settings + @param orientation Possible values: cc.macro.ORIENTATION_LANDSCAPE | cc.macro.ORIENTATION_PORTRAIT | cc.macro.ORIENTATION_AUTO + */ + setOrientation(orientation: number): void; + /** + Sets whether the engine modify the "viewport" meta in your web page.
+ It's enabled by default, we strongly suggest you not to disable it.
+ And even when it's enabled, you can still set your own "viewport" meta, it won't be overridden
+ Only useful on web + @param enabled Enable automatic modification to "viewport" meta + */ + adjustViewPort(enabled: boolean): void; + /** + Retina support is enabled by default for Apple device but disabled for other devices,
+ it takes effect only when you called setDesignResolutionPolicy
+ Only useful on web + @param enabled Enable or disable retina display + */ + enableRetina(enabled: boolean): void; + /** + Check whether retina display is enabled.
+ Only useful on web + */ + isRetinaEnabled(): boolean; + /** + !#en Whether to Enable on anti-alias + !#zh 控制抗锯齿是否开启 + @param enabled Enable or not anti-alias + */ + enableAntiAlias(enabled: boolean): void; + /** + !#en Returns whether the current enable on anti-alias + !#zh 返回当前是否抗锯齿 + */ + isAntiAliasEnabled(): boolean; + /** + If enabled, the application will try automatically to enter full screen mode on mobile devices
+ You can pass true as parameter to enable it and disable it by passing false.
+ Only useful on web + @param enabled Enable or disable auto full screen on mobile devices + */ + enableAutoFullScreen(enabled: boolean): void; + /** + Check whether auto full screen is enabled.
+ Only useful on web + */ + isAutoFullScreenEnabled(): boolean; + /** + Get whether render system is ready(no matter opengl or canvas),
+ this name is for the compatibility with cocos2d-x, subclass must implement this method. + */ + isViewReady(): boolean; + /** + Sets the resolution translate on View. + @param offsetLeft offsetLeft + @param offsetTop offsetTop + */ + setContentTranslateLeftTop(offsetLeft: number, offsetTop: number): void; + /** + Returns the resolution translate on View + */ + getContentTranslateLeftTop(): Size; + /** + Returns the frame size of the view.
+ On native platforms, it returns the screen size since the view is a fullscreen view.
+ On web, it returns the size of the canvas's outer DOM element. + */ + getFrameSize(): Size; + /** + On native, it sets the frame size of view.
+ On web, it sets the size of the canvas's outer DOM element. + @param width width + @param height height + */ + setFrameSize(width: number, height: number): void; + /** + Returns the visible area size of the view port. + */ + getVisibleSize(): Size; + /** + Returns the visible area size of the view port. + */ + getVisibleSizeInPixel(): Size; + /** + Returns the visible origin of the view port. + */ + getVisibleOrigin(): Vec2; + /** + Returns the visible origin of the view port. + */ + getVisibleOriginInPixel(): Vec2; + /** + Returns whether developer can set content's scale factor. + */ + canSetContentScaleFactor(): boolean; + /** + Returns the current resolution policy + */ + getResolutionPolicy(): ResolutionPolicy; + /** + Sets the current resolution policy + @param resolutionPolicy resolutionPolicy + */ + setResolutionPolicy(resolutionPolicy: ResolutionPolicy|number): void; + /** + Sets the resolution policy with designed view size in points.
+ The resolution policy include:
+ [1] ResolutionExactFit Fill screen by stretch-to-fit: if the design resolution ratio of width to height is different from the screen resolution ratio, your game view will be stretched.
+ [2] ResolutionNoBorder Full screen without black border: if the design resolution ratio of width to height is different from the screen resolution ratio, two areas of your game view will be cut.
+ [3] ResolutionShowAll Full screen with black border: if the design resolution ratio of width to height is different from the screen resolution ratio, two black borders will be shown.
+ [4] ResolutionFixedHeight Scale the content's height to screen's height and proportionally scale its width
+ [5] ResolutionFixedWidth Scale the content's width to screen's width and proportionally scale its height
+ [cc.ResolutionPolicy] [Web only feature] Custom resolution policy, constructed by cc.ResolutionPolicy
+ @param width Design resolution width. + @param height Design resolution height. + @param resolutionPolicy The resolution policy desired + */ + setDesignResolutionSize(width: number, height: number, resolutionPolicy: ResolutionPolicy|number): void; + /** + Returns the designed size for the view. + Default resolution size is the same as 'getFrameSize'. + */ + getDesignResolutionSize(): Size; + /** + Sets the container to desired pixel resolution and fit the game content to it. + This function is very useful for adaptation in mobile browsers. + In some HD android devices, the resolution is very high, but its browser performance may not be very good. + In this case, enabling retina display is very costy and not suggested, and if retina is disabled, the image may be blurry. + But this API can be helpful to set a desired pixel resolution which is in between. + This API will do the following: + 1. Set viewport's width to the desired width in pixel + 2. Set body width to the exact pixel resolution + 3. The resolution policy will be reset with designed view size in points. + @param width Design resolution width. + @param height Design resolution height. + @param resolutionPolicy The resolution policy desired + */ + setRealPixelResolution(width: number, height: number, resolutionPolicy: ResolutionPolicy|number): void; + /** + Sets view port rectangle with points. + @param x x + @param y y + @param w width + @param h height + */ + setViewPortInPoints(x: number, y: number, w: number, h: number): void; + /** + Sets Scissor rectangle with points. + @param x x + @param y y + @param w w + @param h h + */ + setScissorInPoints(x: number, y: number, w: number, h: number): void; + /** + Returns whether GL_SCISSOR_TEST is enable + */ + isScissorEnabled(): boolean; + /** + Returns the current scissor rectangle + */ + getScissorRect(): Rect; + /** + Sets the name of the view + @param viewName viewName + */ + setViewName(viewName: string): void; + /** + Returns the name of the view + */ + getViewName(): string; + /** + Returns the view port rectangle. + */ + getViewPortRect(): Rect; + /** + Returns scale factor of the horizontal direction (X axis). + */ + getScaleX(): number; + /** + Returns scale factor of the vertical direction (Y axis). + */ + getScaleY(): number; + /** + Returns device pixel ratio for retina display. + */ + getDevicePixelRatio(): number; + /** + Returns the real location in view for a translation based on a related position + @param tx The X axis translation + @param ty The Y axis translation + @param relatedPos The related position object including "left", "top", "width", "height" informations + */ + convertToLocationInView(tx: number, ty: number, relatedPos: any): Vec2; + } + /**

cc.ContainerStrategy class is the root strategy class of container's scale strategy, + it controls the behavior of how to scale the cc.container and cc.game.canvas object

*/ + export class ContainerStrategy { + /** + Manipulation before appling the strategy + @param view The target view + */ + preApply(view: View): void; + /** + Function to apply this strategy + @param view view + @param designedResolution designedResolution + */ + apply(view: View, designedResolution: Size): void; + /** + Manipulation after applying the strategy + @param view The target view + */ + postApply(view: View): void; + } + /**

cc.ContentStrategy class is the root strategy class of content's scale strategy, + it controls the behavior of how to scale the scene and setup the viewport for the game

*/ + export class ContentStrategy { + /** + Manipulation before applying the strategy + @param view The target view + */ + preApply(view: View): void; + /** + Function to apply this strategy + The return value is {scale: [scaleX, scaleY], viewport: {cc.Rect}}, + The target view can then apply these value to itself, it's preferred not to modify directly its private variables + @param view view + @param designedResolution designedResolution + */ + apply(view: View, designedResolution: Size): any; + /** + Manipulation after applying the strategy + @param view The target view + */ + postApply(view: View): void; + } + /** undefined */ + export class EqualToFrame extends ContainerStrategy { + } + /** undefined */ + export class ProportionalToFrame extends ContainerStrategy { + } + /** undefined */ + export class EqualToWindow extends EqualToFrame { + } + /** undefined */ + export class ProportionalToWindow extends ProportionalToFrame { + } + /** undefined */ + export class OriginalContainer extends ContainerStrategy { + } + /**

cc.ResolutionPolicy class is the root strategy class of scale strategy, + its main task is to maintain the compatibility with Cocos2d-x

*/ + export class ResolutionPolicy { + /** + + @param containerStg The container strategy + @param contentStg The content strategy + */ + constructor(containerStg: ContainerStrategy, contentStg: ContentStrategy); + /** + Manipulation before applying the resolution policy + @param view The target view + */ + preApply(view: View): void; + /** + Function to apply this resolution policy + The return value is {scale: [scaleX, scaleY], viewport: {cc.Rect}}, + The target view can then apply these value to itself, it's preferred not to modify directly its private variables + @param view The target view + @param designedResolution The user defined design resolution + */ + apply(view: View, designedResolution: Size): any; + /** + Manipulation after appyling the strategy + @param view The target view + */ + postApply(view: View): void; + /** + Setup the container's scale strategy + @param containerStg containerStg + */ + setContainerStrategy(containerStg: ContainerStrategy): void; + /** + Setup the content's scale strategy + @param contentStg contentStg + */ + setContentStrategy(contentStg: ContentStrategy): void; + /** The entire application is visible in the specified area without trying to preserve the original aspect ratio.
+ Distortion can occur, and the application may appear stretched or compressed. */ + static EXACT_FIT: number; + /** The entire application fills the specified area, without distortion but possibly with some cropping,
+ while maintaining the original aspect ratio of the application. */ + static NO_BORDER: number; + /** The entire application is visible in the specified area without distortion while maintaining the original
+ aspect ratio of the application. Borders can appear on two sides of the application. */ + static SHOW_ALL: number; + /** The application takes the height of the design resolution size and modifies the width of the internal
+ canvas so that it fits the aspect ratio of the device
+ no distortion will occur however you must make sure your application works on different
+ aspect ratios */ + static FIXED_HEIGHT: number; + /** The application takes the width of the design resolution size and modifies the height of the internal
+ canvas so that it fits the aspect ratio of the device
+ no distortion will occur however you must make sure your application works on different
+ aspect ratios */ + static FIXED_WIDTH: number; + /** Unknow policy */ + static UNKNOWN: number; + } + /** cc.visibleRect is a singleton object which defines the actual visible rect of the current view, + it should represent the same rect as cc.view.getViewportRect() */ + export class visibleRect { + /** + initialize + @param visibleRect visibleRect + */ + init(visibleRect: Rect): void; + /** Top left coordinate of the screen related to the game scene. */ + topLeft: Vec2; + /** Top right coordinate of the screen related to the game scene. */ + topRight: Vec2; + /** Top center coordinate of the screen related to the game scene. */ + top: Vec2; + /** Bottom left coordinate of the screen related to the game scene. */ + bottomLeft: Vec2; + /** Bottom right coordinate of the screen related to the game scene. */ + bottomRight: Vec2; + /** Bottom center coordinate of the screen related to the game scene. */ + bottom: Vec2; + /** Center coordinate of the screen related to the game scene. */ + center: Vec2; + /** Left center coordinate of the screen related to the game scene. */ + left: Vec2; + /** Right center coordinate of the screen related to the game scene. */ + right: Vec2; + /** Width of the screen. */ + width: number; + /** Height of the screen. */ + height: number; + } + /** The CallbacksHandler is an abstract class that can register and unregister callbacks by key. + Subclasses should implement their own methods about how to invoke the callbacks. */ + export class _CallbacksHandler { + /** + + @param key key + @param callback callback + @param target can be null + */ + add(key: string, callback: Function, target?: any): void; + /** + Check if the specified key has any registered callback. If a callback is also specified, + it will only return true if the callback is registered. + @param key key + @param callback callback + @param target target + */ + has(key: string, callback?: Function, target?: any): boolean; + /** + Removes all callbacks registered in a certain event type or all callbacks registered with a certain target + @param keyOrTarget The event key to be removed or the target to be removed + */ + removeAll(keyOrTarget: string|any): void; + /** + + @param key key + @param callback callback + @param target target + */ + remove(key: string, callback: Function, target?: any): void; + } + /** !#en The callbacks invoker to handle and invoke callbacks by key. + !#zh CallbacksInvoker 用来根据 Key 管理并调用回调方法。 */ + export class CallbacksInvoker extends _CallbacksHandler { + /** + + @param key key + @param p1 p1 + @param p2 p2 + @param p3 p3 + @param p4 p4 + @param p5 p5 + */ + invoke(key: string, p1?: any, p2?: any, p3?: any, p4?: any, p5?: any): void; + } + /** !#en Contains information collected during deserialization + !#zh 包含反序列化时的一些信息 */ + export class Details { + /** list of the depends assets' uuid */ + uuidList: string[]; + /** the obj list whose field needs to load asset by uuid */ + uuidObjList: any[]; + /** the corresponding field name which referenced to the asset */ + uuidPropList: string[]; + /** the corresponding field name which referenced to the raw object */ + rawProp: string; + reset(): void; + /** + + @param obj obj + @param propName propName + */ + getUuidOf(obj: any, propName: string): string; + /** + + @param obj obj + @param propName propName + @param uuid uuid + */ + push(obj: any, propName: string, uuid: string): void; + } + /** undefined */ + export class url { + /** + Returns the url of raw assets, you will only need this if the raw asset is inside the "resources" folder. + @param url url + + @example + ```js + --- + var url = cc.url.raw("textures/myTexture.png"); + console.log(url); // "resources/raw/textures/myTexture.png" + + ``` + */ + static raw(url: string): string; + /** + Returns the url of builtin raw assets. This method can only used in editor. + @param url url + + @example + ```js + --- + var url = cc.url.builtinRaw("textures/myTexture.png"); + console.log(url); // "resources/default-raw/textures/myTexture.png" + + ``` + */ + static builtinRaw(url: string): string; + } + /** !#en + A cc.SpriteFrame has:
+ - texture: A cc.Texture2D that will be used by the _ccsg.Sprite
+ - rectangle: A rectangle of the texture + + !#zh + 一个 SpriteFrame 包含:
+ - 纹理:会被 Sprite 使用的 Texture2D 对象。
+ - 矩形:在纹理中的矩形区域。 */ + export class SpriteFrame extends Asset implements EventTarget { + /** + !#en + Constructor of SpriteFrame class. + !#zh + SpriteFrame 类的构造函数。 + @param filename filename + @param rect rect + @param rotated Whether the frame is rotated in the texture + @param offset The offset of the frame in the texture + @param originalSize The size of the frame in the texture + */ + constructor(filename?: string|Texture2D, rect?: Rect, rotated?: boolean, offset?: Vec2, originalSize?: Size); + /** !#en Top border of the sprite + !#zh sprite 的顶部边框 */ + insetTop: number; + /** !#en Bottom border of the sprite + !#zh sprite 的底部边框 */ + insetBottom: number; + /** !#en Left border of the sprite + !#zh sprite 的左边边框 */ + insetLeft: number; + /** !#en Right border of the sprite + !#zh sprite 的左边边框 */ + insetRight: number; + /** + !#en Returns whether the texture have been loaded + !#zh 返回是否已加载纹理 + */ + textureLoaded(): boolean; + /** + Add a event listener for texture loaded event. + @param callback callback + @param target target + */ + addLoadedEventListener(callback: Function, target: any): void; + /** + !#en Returns whether the sprite frame is rotated in the texture. + !#zh 获取 SpriteFrame 是否旋转 + */ + isRotated(): boolean; + /** + !#en Set whether the sprite frame is rotated in the texture. + !#zh 设置 SpriteFrame 是否旋转 + @param bRotated bRotated + */ + setRotated(bRotated: boolean): void; + /** + !#en Returns the rect of the sprite frame in the texture. + !#zh 获取 SpriteFrame 的纹理矩形区域 + */ + getRect(): Rect; + /** + !#en Sets the rect of the sprite frame in the texture. + !#zh 设置 SpriteFrame 的纹理矩形区域 + @param rect rect + */ + setRect(rect: Rect): void; + /** + !#en Returns the original size of the trimmed image. + !#zh 获取修剪前的原始大小 + */ + getOriginalSize(): Size; + /** + !#en Sets the original size of the trimmed image. + !#zh 设置修剪前的原始大小 + @param size size + */ + setOriginalSize(size: Size): void; + /** + !#en Returns the texture of the frame. + !#zh 获取使用的纹理实例 + */ + getTexture(): Texture2D; + /** + !#en Returns the offset of the frame in the texture. + !#zh 获取偏移量 + */ + getOffset(): Vec2; + /** + !#en Sets the offset of the frame in the texture. + !#zh 设置偏移量 + @param offsets offsets + */ + setOffset(offsets: Vec2): void; + /** + !#en Clone the sprite frame. + !#zh 克隆 SpriteFrame + */ + clone(): SpriteFrame; + /** + !#en Set SpriteFrame with Texture, rect, rotated, offset and originalSize.
+ !#zh 通过 Texture,rect,rotated,offset 和 originalSize 设置 SpriteFrame + @param textureOrTextureFile textureOrTextureFile + @param rect rect + @param rotated rotated + @param offset offset + @param originalSize originalSize + */ + setTexture(textureOrTextureFile: string|Texture2D, rect?: Rect, rotated?: boolean, offset?: Vec2, originalSize?: Size): boolean; + /** + !#en If a loading scene (or prefab) is marked as `asyncLoadAssets`, all the textures of the SpriteFrame which + associated by user's custom Components in the scene, will not preload automatically. + These textures will be load when Sprite component is going to render the SpriteFrames. + You can call this method if you want to load the texture early. + !#zh 当加载中的场景或 Prefab 被标记为 `asyncLoadAssets` 时,用户在场景中由自定义组件关联到的所有 SpriteFrame 的贴图都不会被提前加载。 + 只有当 Sprite 组件要渲染这些 SpriteFrame 时,才会检查贴图是否加载。如果你希望加载过程提前,你可以手工调用这个方法。 + + @example + ```js + if (spriteFrame.textureLoaded()) { + this._onSpriteFrameLoaded(); + } + else { + spriteFrame.once('load', this._onSpriteFrameLoaded, this); + spriteFrame.ensureLoadTexture(); + } + ``` + */ + ensureLoadTexture(): void; + /** + !#en + If you do not need to use the SpriteFrame temporarily, you can call this method so that its texture could be garbage collected. Then when you need to render the SpriteFrame, you should call `ensureLoadTexture` manually to reload texture. + !#zh + 当你暂时不再使用这个 SpriteFrame 时,可以调用这个方法来保证引用的贴图对象能被 GC。然后当你要渲染 SpriteFrame 时,你需要手动调用 `ensureLoadTexture` 来重新加载贴图。 + + @example + ```js + spriteFrame.clearTexture(); + // when you need the SpriteFrame again... + spriteFrame.once('load', onSpriteFrameLoaded); + spriteFrame.ensureLoadTexture(); + ``` + */ + clearTexture(): void; + /** + !#en + Register an callback of a specific event type on the EventTarget. + !#zh + 注册事件目标的特定事件类型回调。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + @param useCapture When set to true, the capture argument prevents callback + from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. + When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE. + Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET. + + @example + ```js + node.on(cc.Node.EventType.TOUCH_END, function (event) { + cc.log("this is callback"); + }, node); + ``` + */ + on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void; + on(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void; + /** + !#en + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. + !#zh + 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not. + If not specified, useCapture defaults to false. If a callback was registered twice, + one with capture and one without, each must be removed separately. Removal of a capturing callback + does not affect a non-capturing version of the same listener, and vice versa. + + @example + ```js + // register touchEnd eventListener + var touchEnd = node.on(cc.Node.EventType.TOUCH_END, function (event) { + cc.log("this is callback"); + }, node); + // remove touch end event listener + node.off(cc.Node.EventType.TOUCH_END, touchEnd, node); + // remove all touch end event listeners + node.off(cc.Node.EventType.TOUCH_END); + ``` + */ + off(type: string, callback?: Function, target?: any, useCapture?: boolean): void; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + @param useCapture When set to true, the capture argument prevents callback + from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. + When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE. + Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET. + + @example + ```js + node.once(cc.Node.EventType.TOUCH_END, function (event) { + cc.log("this is callback"); + }, node); + ``` + */ + once(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void; + once(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void; + /** + !#en + Dispatches an event into the event flow. + The event target is the EventTarget object upon which the dispatchEvent() method is called. + !#zh 分发事件到事件流中。 + @param event The Event object that is dispatched into the event flow + */ + dispatchEvent(event: Event): void; + /** + !#en + Send an event to this object directly, this method will not propagate the event to any other objects. + The event will be created from the supplied message, you can get the "detail" argument from event.detail. + !#zh + 该对象直接发送事件, 这种方法不会对事件传播到任何其他对象。 + @param message the message to send + @param detail whatever argument the message needs + */ + emit(message: string, detail?: any): void; + } + /**

+ This class allows to easily create OpenGL or Canvas 2D textures from images, text or raw data.
+ The created cc.Texture2D object will always have power-of-two dimensions.
+ Depending on how you create the cc.Texture2D object, the actual image area of the texture might be smaller than the texture dimensions
+ i.e. "contentSize" != (pixelsWide, pixelsHigh) and (maxS, maxT) != (1.0, 1.0).
+ Be aware that the content of the generated textures will be upside-down!

*/ + export class Texture2D extends RawAsset implements EventTarget { + /** !#en + The url of the texture, this coule be empty if the texture wasn't created via a file. + !#zh + 贴图文件的 url,当贴图不是由文件创建时值可能为空 */ + url: string; + /** !#en + Whether the texture is loaded or not + !#zh + 贴图是否已经成功加载 */ + loaded: boolean; + /** !#en + Texture width in pixel + !#zh + 贴图像素宽度 */ + width: number; + /** !#en + Texture height in pixel + !#zh + 贴图像素高度 */ + height: number; + /** + Update texture options, not available in Canvas render mode. + image, format, premultiplyAlpha can not be updated in native. + @param options options + */ + update(options: {image: DOMImageElement; mipmap: boolean; format: PixelFormat; minFilter: Filter; magFilter: Filter; wrapS: WrapMode; wrapT: WrapMode; premultiplyAlpha: boolean; }): void; + /** + Get width in pixels. + */ + getPixelWidth(): number; + /** + Get height of in pixels. + */ + getPixelHeight(): number; + /** + Get content size. + */ + getContentSize(): Size; + /** + Get content size in pixels. + */ + getContentSizeInPixels(): Size; + /** + Init with HTML element. + @param element element + + @example + ```js + var img = new Image(); + img.src = dataURL; + texture.initWithElement(img); + texture.handleLoadedTexture(); + ``` + */ + initWithElement(element: HTMLImageElement|HTMLCanvasElement): void; + /** + Intializes with a texture2d with data. + @param data data + @param pixelFormat pixelFormat + @param pixelsWidth pixelsWidth + @param pixelsHeight pixelsHeight + @param contentSize contentSize is deprecated and ignored + */ + initWithData(data: TypedArray, pixelFormat: number, pixelsWidth: number, pixelsHeight: number, contentSize: Size): boolean; + /** + Initializes a texture from a UIImage object. + Extensions to make it easy to create a CCTexture2D object from an image file. + Note that RGBA type textures will have their alpha premultiplied - use the blending mode (gl.ONE, gl.ONE_MINUS_SRC_ALPHA). + @param uiImage uiImage + */ + initWithImage(uiImage: HTMLImageElement): boolean; + /** + HTMLElement Object getter, available only on web. + In most case, it will return null, because we are recycling the dom image element for better loading performance and lower image cache memory usage. + */ + getHtmlElementObj(): HTMLImageElement; + /** + Check whether texture is loaded. + */ + isLoaded(): boolean; + /** + Handler of texture loaded event. + @param premultiplied premultiplied + */ + handleLoadedTexture(premultiplied?: boolean): void; + /** + Description of cc.Texture2D. + */ + description(): string; + /** + Release texture. + */ + releaseTexture(): void; + /** + Pixel format of the texture. + */ + getPixelFormat(): number; + /** + Whether or not the texture has their Alpha premultiplied, + support only in WebGl rendering mode. + */ + hasPremultipliedAlpha(): boolean; + /** + Whether or not use mipmap, support only in WebGl rendering mode. + */ + hasMipmaps(): boolean; + /** + Sets the min filter, mag filter, wrap s and wrap t texture parameters.
+ If the texture size is NPOT (non power of 2), then in can only use gl.CLAMP_TO_EDGE in gl.TEXTURE_WRAP_{S,T}. + @param texParams texParams object or minFilter + @param magFilter magFilter + @param wrapS wrapS + @param wrapT wrapT + */ + setTexParameters(texParams: any|number, magFilter?: number, wrapS?: Texture2D.WrapMode, wrapT?: Texture2D.WrapMode): void; + /** + sets antialias texture parameters:
+ - GL_TEXTURE_MIN_FILTER = GL_NEAREST
+ - GL_TEXTURE_MAG_FILTER = GL_NEAREST
+ supported only in native or WebGl rendering mode + */ + setAntiAliasTexParameters(): void; + /** + Sets alias texture parameters:
+ GL_TEXTURE_MIN_FILTER = GL_NEAREST
+ GL_TEXTURE_MAG_FILTER = GL_NEAREST
+ supported only in native or WebGl rendering mode + */ + setAliasTexParameters(): void; + /** Pixel format of the texture. */ + pixelFormat: number; + /** Width in pixels. */ + pixelWidth: number; + /** Height in pixels. */ + pixelHeight: number; + /** + !#en + Register an callback of a specific event type on the EventTarget. + !#zh + 注册事件目标的特定事件类型回调。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + @param useCapture When set to true, the capture argument prevents callback + from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. + When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE. + Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET. + + @example + ```js + node.on(cc.Node.EventType.TOUCH_END, function (event) { + cc.log("this is callback"); + }, node); + ``` + */ + on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void; + on(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void; + /** + !#en + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. + !#zh + 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not. + If not specified, useCapture defaults to false. If a callback was registered twice, + one with capture and one without, each must be removed separately. Removal of a capturing callback + does not affect a non-capturing version of the same listener, and vice versa. + + @example + ```js + // register touchEnd eventListener + var touchEnd = node.on(cc.Node.EventType.TOUCH_END, function (event) { + cc.log("this is callback"); + }, node); + // remove touch end event listener + node.off(cc.Node.EventType.TOUCH_END, touchEnd, node); + // remove all touch end event listeners + node.off(cc.Node.EventType.TOUCH_END); + ``` + */ + off(type: string, callback?: Function, target?: any, useCapture?: boolean): void; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + @param useCapture When set to true, the capture argument prevents callback + from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. + When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE. + Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET. + + @example + ```js + node.once(cc.Node.EventType.TOUCH_END, function (event) { + cc.log("this is callback"); + }, node); + ``` + */ + once(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void; + once(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void; + /** + !#en + Dispatches an event into the event flow. + The event target is the EventTarget object upon which the dispatchEvent() method is called. + !#zh 分发事件到事件流中。 + @param event The Event object that is dispatched into the event flow + */ + dispatchEvent(event: Event): void; + /** + !#en + Send an event to this object directly, this method will not propagate the event to any other objects. + The event will be created from the supplied message, you can get the "detail" argument from event.detail. + !#zh + 该对象直接发送事件, 这种方法不会对事件传播到任何其他对象。 + @param message the message to send + @param detail whatever argument the message needs + */ + emit(message: string, detail?: any): void; + } + /** cc.textureCache is a singleton object, it's the global cache for cc.Texture2D */ + export class textureCache { + /** + Description + */ + static description(): string; + /** + Returns an already created texture. Returns null if the texture doesn't exist. + @param textureKeyName textureKeyName + + @example + ```js + ------------------ + var key = cc.textureCache.textureForKey("hello.png"); + + ``` + */ + static textureForKey(textureKeyName: string): Texture2D; + /** + Returns an already created texture. Returns null if the texture doesn't exist. + @param textureKeyName textureKeyName + + @example + ```js + ------------------ + var key = cc.textureCache.getTextureForKey("hello.png"); + + ``` + */ + static getTextureForKey(textureKeyName: string): Texture2D; + /** + + @param texture texture + + @example + ```js + --------------- + var cacheTextureForColor = cc.textureCache.getTextureColors(texture); + + ``` + */ + static getTextureColors(texture: HTMLImageElement): any[]; + /** + !#en get all textures + !#zh 获取所有贴图 + */ + static getAllTextures(): Texture2D[]; + /** +

Purges the dictionary of loaded textures.
+ Call this method if you receive the "Memory Warning"
+ In the short term: it will free some resources preventing your app from being killed
+ In the medium term: it will allocate more resources
+ In the long term: it will be the same

+ + @example + ```js + -------- + cc.textureCache.removeAllTextures(); + + ``` + */ + static removeAllTextures(): void; + /** + Deletes a texture from the cache given a texture. + @param texture texture + + @example + ```js + ----- + cc.textureCache.removeTexture(texture); + + ``` + */ + static removeTexture(texture: HTMLImageElement): void; + /** + Deletes a texture from the cache given a its key name. + @param textureKeyName textureKeyName + + @example + ```js + ------ + cc.textureCache.removeTexture("hello.png"); + + ``` + */ + static removeTextureForKey(textureKeyName: string): void; + /** +

Returns a Texture2D object given an file image
+ If the file image was not previously loaded, it will create a new Texture2D
+ object and it will return it. It will use the filename as a key.
+ Otherwise it will return a reference of a previously loaded image.
+ Supported image extensions: .png, .jpg, .gif

+ @param url url + @param cb cb + @param target target + + @example + ```js + ---- + cc.textureCache.addImage("hello.png"); + + ``` + */ + static addImage(url: string, cb: Function, target: any): Texture2D; + /** + Cache the image data. + @param path path + @param texture texture + */ + static cacheImage(path: string, texture: HTMLImageElement|HTMLCanvasElement): void; + } + /** A base node for CCNode, it will: + - maintain scene hierarchy and active logic + - notifications if some properties changed + - define some interfaces shares between CCNode + - define machanisms for Enity Component Systems + - define prefab and serialize functions */ + export class _BaseNode extends Object implements EventTarget { + /** !#en Name of node. + !#zh 该节点名称。 */ + name: string; + /** !#en The uuid for editor, will be stripped before building project. + !#zh 主要用于编辑器的 uuid,在编辑器下可用于持久化存储,在项目构建之后将变成自增的 id。 */ + uuid: string; + /** !#en All children nodes. + !#zh 节点的所有子节点。 */ + children: Node[]; + /** !#en All children nodes. + !#zh 节点的子节点数量。 */ + childrenCount: number; + /** !#en + The local active state of this node.
+ Note that a Node may be inactive because a parent is not active, even if this returns true.
+ Use {{#crossLink "Node/activeInHierarchy:property"}}{{/crossLink}} if you want to check if the Node is actually treated as active in the scene. + !#zh + 当前节点的自身激活状态。
+ 值得注意的是,一个节点的父节点如果不被激活,那么即使它自身设为激活,它仍然无法激活。
+ 如果你想检查节点在场景中实际的激活状态可以使用 {{#crossLink "Node/activeInHierarchy:property"}}{{/crossLink}}。 */ + active: boolean; + /** !#en Indicates whether this node is active in the scene. + !#zh 表示此节点是否在场景中激活。 */ + activeInHierarchy: boolean; + /** !#en Tag of node. + !#zh 节点标签。 */ + tag: number; + /** + + @param name name + */ + constructor(name?: string); + /** !#en The parent of the node. + !#zh 该节点的父节点。 */ + parent: Node; + /** + !#en + Properties configuration function
+ All properties in attrs will be set to the node,
+ when the setter of the node is available,
+ the property will be set via setter function.
+ !#zh 属性配置函数。在 attrs 的所有属性将被设置为节点属性。 + @param attrs Properties to be set to node + + @example + ```js + var attrs = { key: 0, num: 100 }; + node.attr(attrs); + ``` + */ + attr(attrs: any): void; + /** + !#en Returns a child from the container given its tag. + !#zh 通过标签获取节点的子节点。 + @param aTag An identifier to find the child node. + + @example + ```js + var child = node.getChildByTag(1001); + ``` + */ + getChildByTag(aTag: number): Node; + /** + !#en Returns a child from the container given its uuid. + !#zh 通过 uuid 获取节点的子节点。 + @param uuid The uuid to find the child node. + + @example + ```js + var child = node.getChildByUuid(uuid); + ``` + */ + getChildByUuid(uuid: string): Node; + /** + !#en Returns a child from the container given its name. + !#zh 通过名称获取节点的子节点。 + @param name A name to find the child node. + + @example + ```js + var child = node.getChildByName("Test Node"); + ``` + */ + getChildByName(name: string): Node; + /** + !#en + Inserts a child to the node at a specified index. + !#zh + 插入子节点到指定位置 + @param child the child node to be inserted + @param siblingIndex the sibling index to place the child in + + @example + ```js + node.insertChild(child, 2); + ``` + */ + insertChild(child: Node, siblingIndex: number): void; + /** + !#en Get the sibling index. + !#zh 获取同级索引。 + + @example + ```js + var index = node.getSiblingIndex(); + ``` + */ + getSiblingIndex(): number; + /** + !#en Set the sibling index of this node. + !#zh 设置节点同级索引。 + @param index index + + @example + ```js + node.setSiblingIndex(1); + ``` + */ + setSiblingIndex(index: number): void; + /** + !#en + Remove itself from its parent node. If cleanup is `true`, then also remove all events and actions.
+ If the cleanup parameter is not passed, it will force a cleanup, so it is recommended that you always pass in the `false` parameter when calling this API.
+ If the node orphan, then nothing happens. + !#zh + 从父节点中删除该节点。如果不传入 cleanup 参数或者传入 `true`,那么这个节点上所有绑定的事件、action 都会被删除。
+ 因此建议调用这个 API 时总是传入 `false` 参数。
+ 如果这个节点是一个孤节点,那么什么都不会发生。 + @param cleanup true if all actions and callbacks on this node should be removed, false otherwise. + + @example + ```js + node.removeFromParent(); + node.removeFromParent(false); + ``` + */ + removeFromParent(cleanup?: boolean): void; + /** + !#en + Removes a child from the container. It will also cleanup all running actions depending on the cleanup parameter.

+ If the cleanup parameter is not passed, it will force a cleanup.
+ "remove" logic MUST only be on this method
+ If a class wants to extend the 'removeChild' behavior it only needs
+ to override this method. + !#zh + 移除节点中指定的子节点,是否需要清理所有正在运行的行为取决于 cleanup 参数。
+ 如果 cleanup 参数不传入,默认为 true 表示清理。
+ @param child The child node which will be removed. + @param cleanup true if all running actions and callbacks on the child node will be cleanup, false otherwise. + + @example + ```js + node.removeChild(newNode); + node.removeChild(newNode, false); + ``` + */ + removeChild(child: Node, cleanup?: boolean): void; + /** + !#en + Removes a child from the container by tag value. It will also cleanup all running actions depending on the cleanup parameter. + If the cleanup parameter is not passed, it will force a cleanup.
+ !#zh + 通过标签移除节点中指定的子节点,是否需要清理所有正在运行的行为取决于 cleanup 参数。
+ 如果 cleanup 参数不传入,默认为 true 表示清理。 + @param tag An integer number that identifies a child node + @param cleanup true if all running actions and callbacks on the child node will be cleanup, false otherwise. + + @example + ```js + node.removeChildByTag(1001); + node.removeChildByTag(1001, false); + ``` + */ + removeChildByTag(tag: number, cleanup?: boolean): void; + /** + !#en + Removes all children from the container and do a cleanup all running actions depending on the cleanup parameter.
+ If the cleanup parameter is not passed, it will force a cleanup. + !#zh + 移除节点所有的子节点,是否需要清理所有正在运行的行为取决于 cleanup 参数。
+ 如果 cleanup 参数不传入,默认为 true 表示清理。 + @param cleanup true if all running actions on all children nodes should be cleanup, false otherwise. + + @example + ```js + node.removeAllChildren(); + node.removeAllChildren(false); + ``` + */ + removeAllChildren(cleanup?: boolean): void; + /** + !#en Is this node a child of the given node? + !#zh 是否是指定节点的子节点? + @param parent parent + + @example + ```js + node.isChildOf(newNode); + ``` + */ + isChildOf(parent: Node): boolean; + /** + !#en + Returns the component of supplied type if the node has one attached, null if it doesn't.
+ You can also get component in the node by passing in the name of the script. + !#zh + 获取节点上指定类型的组件,如果节点有附加指定类型的组件,则返回,如果没有则为空。
+ 传入参数也可以是脚本的名称。 + @param typeOrClassName typeOrClassName + + @example + ```js + // get sprite component. + var sprite = node.getComponent(cc.Sprite); + // get custom test calss. + var test = node.getComponent("Test"); + ``` + */ + getComponent(type: {prototype: T}): T; + getComponent(className: string): any; + /** + !#en Returns all components of supplied type in the node. + !#zh 返回节点上指定类型的所有组件。 + @param typeOrClassName typeOrClassName + + @example + ```js + var sprites = node.getComponents(cc.Sprite); + var tests = node.getComponents("Test"); + ``` + */ + getComponents(type: {prototype: T}): T[]; + getComponents(className: string): any[]; + /** + !#en Returns the component of supplied type in any of its children using depth first search. + !#zh 递归查找所有子节点中第一个匹配指定类型的组件。 + @param typeOrClassName typeOrClassName + + @example + ```js + var sprite = node.getComponentInChildren(cc.Sprite); + var Test = node.getComponentInChildren("Test"); + ``` + */ + getComponentInChildren(type: {prototype: T}): T; + getComponentInChildren(className: string): any; + /** + !#en Returns all components of supplied type in self or any of its children. + !#zh 递归查找自身或所有子节点中指定类型的组件 + @param typeOrClassName typeOrClassName + + @example + ```js + var sprites = node.getComponentsInChildren(cc.Sprite); + var tests = node.getComponentsInChildren("Test"); + ``` + */ + getComponentsInChildren(type: {prototype: T}): T[]; + getComponentsInChildren(className: string): any[]; + /** + !#en Adds a component class to the node. You can also add component to node by passing in the name of the script. + !#zh 向节点添加一个指定类型的组件类,你还可以通过传入脚本的名称来添加组件。 + @param typeOrClassName The constructor or the class name of the component to add + + @example + ```js + var sprite = node.addComponent(cc.Sprite); + var test = node.addComponent("Test"); + ``` + */ + addComponent(type: {new(): T}): T; + addComponent(className: string): any; + /** + !#en + Removes a component identified by the given name or removes the component object given. + You can also use component.destroy() if you already have the reference. + !#zh + 删除节点上的指定组件,传入参数可以是一个组件构造函数或组件名,也可以是已经获得的组件引用。 + 如果你已经获得组件引用,你也可以直接调用 component.destroy() + @param component The need remove component. + + @example + ```js + node.removeComponent(cc.Sprite); + var Test = require("Test"); + node.removeComponent(Test); + ``` + */ + removeComponent(component: string|Function|Component): void; + /** + !#en + Destroy all children from the node, and release all their own references to other objects.
+ Actual destruct operation will delayed until before rendering. + !#zh + 销毁所有子节点,并释放所有它们对其它对象的引用。
+ 实际销毁操作会延迟到当前帧渲染前执行。 + + @example + ```js + node.destroyAllChildren(); + ``` + */ + destroyAllChildren(): void; + /** + !#en + Register an callback of a specific event type on the EventTarget. + !#zh + 注册事件目标的特定事件类型回调。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + @param useCapture When set to true, the capture argument prevents callback + from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. + When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE. + Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET. + + @example + ```js + node.on(cc.Node.EventType.TOUCH_END, function (event) { + cc.log("this is callback"); + }, node); + ``` + */ + on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void; + on(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void; + /** + !#en + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. + !#zh + 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not. + If not specified, useCapture defaults to false. If a callback was registered twice, + one with capture and one without, each must be removed separately. Removal of a capturing callback + does not affect a non-capturing version of the same listener, and vice versa. + + @example + ```js + // register touchEnd eventListener + var touchEnd = node.on(cc.Node.EventType.TOUCH_END, function (event) { + cc.log("this is callback"); + }, node); + // remove touch end event listener + node.off(cc.Node.EventType.TOUCH_END, touchEnd, node); + // remove all touch end event listeners + node.off(cc.Node.EventType.TOUCH_END); + ``` + */ + off(type: string, callback?: Function, target?: any, useCapture?: boolean): void; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + @param useCapture When set to true, the capture argument prevents callback + from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. + When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE. + Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET. + + @example + ```js + node.once(cc.Node.EventType.TOUCH_END, function (event) { + cc.log("this is callback"); + }, node); + ``` + */ + once(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void; + once(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void; + /** + !#en + Dispatches an event into the event flow. + The event target is the EventTarget object upon which the dispatchEvent() method is called. + !#zh 分发事件到事件流中。 + @param event The Event object that is dispatched into the event flow + */ + dispatchEvent(event: Event): void; + /** + !#en + Send an event to this object directly, this method will not propagate the event to any other objects. + The event will be created from the supplied message, you can get the "detail" argument from event.detail. + !#zh + 该对象直接发送事件, 这种方法不会对事件传播到任何其他对象。 + @param message the message to send + @param detail whatever argument the message needs + */ + emit(message: string, detail?: any): void; + } + /** !#en + cc.AffineTransform class represent an affine transform matrix. It's composed basically by translation, rotation, scale transformations.
+ Please do not use its constructor directly, use cc.affineTransformMake alias function instead. + !#zh + cc.AffineTransform 类代表一个仿射变换矩阵。它基本上是由平移旋转,缩放转变所组成。
+ 请不要直接使用它的构造,请使用 cc.affineTransformMake 函数代替。 */ + export class AffineTransform { + /** + !#en Create a cc.AffineTransform object with all contents in the matrix. + !#zh 用在矩阵中的所有内容创建一个 cc.AffineTransform 对象。 + @param a a + @param b b + @param c c + @param d d + @param tx tx + @param ty ty + */ + affineTransformMake(a: number, b: number, c: number, d: number, tx: number, ty: number): AffineTransform; + /** + !#en Clone a cc.AffineTransform object from the specified transform. + !#zh 克隆指定的 cc.AffineTransform 对象。 + @param t t + */ + affineTransformClone(t: AffineTransform): AffineTransform; + /** + !#en Apply the affine transformation on a point. + !#zh 对一个点应用矩阵变换。 + @param point or x. + @param transOrY transform matrix or y. + @param t transform matrix or y. + */ + pointApplyAffineTransform(point: Vec2|number, transOrY: AffineTransform|number, t: AffineTransform): Vec2; + /** + !#en Apply the affine transformation on a size. + !#zh 应用 Size 到仿射变换矩阵上。 + @param size size + @param t t + */ + sizeApplyAffineTransform(size: Size, t: AffineTransform): Size; + /** + !#en + Create a identity transformation matrix:
+ [ 1, 0, 0,
+ 0, 1, 0 ] + !#zh + 单位矩阵:
+ [ 1, 0, 0,
+ 0, 1, 0 ] + */ + affineTransformMakeIdentity(): AffineTransform; + /** + !#en Apply the affine transformation on a rect. + !#zh 应用 Rect 到仿射变换矩阵上。 + @param rect rect + @param anAffineTransform anAffineTransform + */ + rectApplyAffineTransform(rect: Rect, anAffineTransform: AffineTransform): Rect; + /** + !#en Apply the affine transformation on a rect, and truns to an Oriented Bounding Box. + !#zh 应用 Rect 到仿射变换矩阵上, 并转换为有向包围盒 + @param rect rect + @param anAffineTransform anAffineTransform + @param out_bl out_bl + @param out_tl out_tl + @param out_tr out_tr + @param out_br out_br + */ + obbApplyAffineTransform(rect: Rect, anAffineTransform: AffineTransform, out_bl: Vec2, out_tl: Vec2, out_tr: Vec2, out_br: Vec2): void; + /** + !#en Create a new affine transformation with a base transformation matrix and a translation based on it. + !#zh 基于一个基础矩阵加上一个平移操作来创建一个新的矩阵。 + @param t The base affine transform object. + @param tx The translation on x axis. + @param ty The translation on y axis. + */ + affineTransformTranslate(t: AffineTransform, tx: number, ty: number): AffineTransform; + /** + !#en Create a new affine transformation with a base transformation matrix and a scale based on it. + !#zh 创建一个基础变换矩阵,并在此基础上进行了 Scale 仿射变换。 + @param t The base affine transform object. + @param sx The scale on x axis. + @param sy The scale on y axis. + */ + affineTransformScale(t: AffineTransform, sx: number, sy: number): AffineTransform; + /** + !#en Create a new affine transformation with a base transformation matrix and a rotation based on it. + !#zh 创建一个基础变换矩阵,并在此基础上进行了 Rotation 仿射变换。 + @param aTransform The base affine transform object. + @param anAngle The angle to rotate. + */ + affineTransformRotate(aTransform: AffineTransform, anAngle: number): AffineTransform; + /** + !#en + Concatenate a transform matrix to another and return the result:
+ t' = t1 * t2 + !#zh 拼接两个矩阵,并返回结果:
+ t' = t1 * t2 + @param t1 The first transform object. + @param t2 The transform object to concatenate. + */ + affineTransformConcat(t1: AffineTransform, t2: AffineTransform): AffineTransform; + /** + !#en + Concatenate a transform matrix to another
+ The results are reflected in the first matrix.
+ t' = t1 * t2 + !#zh + 拼接两个矩阵,将结果保存到第一个矩阵。
+ t' = t1 * t2 + @param t1 The first transform object. + @param t2 The transform object to concatenate. + */ + affineTransformConcatIn(t1: AffineTransform, t2: AffineTransform): AffineTransform; + /** + !#en Return true if an affine transform equals to another, false otherwise. + !#zh 判断两个矩阵是否相等。 + @param t1 t1 + @param t2 t2 + */ + affineTransformEqualToTransform(t1: AffineTransform, t2: AffineTransform): boolean; + /** + !#en Get the invert transform of an AffineTransform object. + !#zh 求逆矩阵。 + @param t t + */ + affineTransformInvert(t: AffineTransform): AffineTransform; + /** + !#en Put the invert transform of an AffineTransform object into the out AffineTransform object. + !#zh 求逆矩阵并存入用户传入的矩阵对象参数。 + @param t t + @param out out + */ + affineTransformInvert(t: AffineTransform, out: AffineTransform): void; + } + /** !#en + Representation of RGBA colors. + + Each color component is a floating point value with a range from 0 to 255. + + You can also use the convenience method {{#crossLink "cc/color:method"}}cc.color{{/crossLink}} to create a new Color. + + !#zh + cc.Color 用于表示颜色。 + + 它包含 RGBA 四个以浮点数保存的颜色分量,每个的值都在 0 到 255 之间。 + + 您也可以通过使用 {{#crossLink "cc/color:method"}}cc.color{{/crossLink}} 的便捷方法来创建一个新的 Color。 */ + export class Color extends ValueType { + /** + + @param r red component of the color, default value is 0. + @param g green component of the color, defualt value is 0. + @param b blue component of the color, default value is 0. + @param a alpha component of the color, default value is 255. + */ + constructor(r?: number, g?: number, b?: number, a?: number); + /** !#en Solid white, RGBA is [255, 255, 255, 255]. + !#zh 纯白色,RGBA 是 [255, 255, 255, 255]。 */ + static WHITE: Color; + /** !#en Solid black, RGBA is [0, 0, 0, 255]. + !#zh 纯黑色,RGBA 是 [0, 0, 0, 255]。 */ + static BLACK: Color; + /** !#en Transparent, RGBA is [0, 0, 0, 0]. + !#zh 透明,RGBA 是 [0, 0, 0, 0]。 */ + static TRANSPARENT: Color; + /** !#en Grey, RGBA is [127.5, 127.5, 127.5]. + !#zh 灰色,RGBA 是 [127.5, 127.5, 127.5]。 */ + static GRAY: Color; + /** !#en Solid red, RGBA is [255, 0, 0]. + !#zh 纯红色,RGBA 是 [255, 0, 0]。 */ + static RED: Color; + /** !#en Solid green, RGBA is [0, 255, 0]. + !#zh 纯绿色,RGBA 是 [0, 255, 0]。 */ + static GREEN: Color; + /** !#en Solid blue, RGBA is [0, 0, 255]. + !#zh 纯蓝色,RGBA 是 [0, 0, 255]。 */ + static BLUE: Color; + /** !#en Yellow, RGBA is [255, 235, 4]. + !#zh 黄色,RGBA 是 [255, 235, 4]。 */ + static YELLOW: Color; + /** !#en Orange, RGBA is [255, 127, 0]. + !#zh 橙色,RGBA 是 [255, 127, 0]。 */ + static ORANGE: Color; + /** !#en Cyan, RGBA is [0, 255, 255]. + !#zh 青色,RGBA 是 [0, 255, 255]。 */ + static CYAN: Color; + /** !#en Magenta, RGBA is [255, 0, 255]. + !#zh 洋红色(品红色),RGBA 是 [255, 0, 255]。 */ + static MAGENTA: Color; + /** + !#en Clone a new color from the current color. + !#zh 克隆当前颜色。 + + @example + ```js + var color = new cc.Color(); + var newColor = color.clone();// Color {r: 0, g: 0, b: 0, a: 255} + ``` + */ + clone(): Color; + /** + !#en TODO + !#zh 判断两个颜色是否相等。 + @param other other + + @example + ```js + var color1 = cc.Color.WHITE; + var color2 = new cc.Color(255, 255, 255); + cc.log(color1.equals(color2)); // true; + color2 = cc.Color.RED; + cc.log(color2.equals(color1)); // false; + ``` + */ + equals(other: Color): boolean; + /** + !#en TODO + !#zh 线性插值 + @param to to + @param ratio the interpolation coefficient. + @param out optional, the receiving vector. + + @example + ```js + // Converts a white color to a black one trough time. + update: function (dt) { + var color = this.node.color; + if (color.equals(cc.Color.BLACK)) { + return; + } + this.ratio += dt * 0.1; + this.node.color = cc.Color.WHITE.lerp(cc.Color.BLACK, ratio); + } + + ``` + */ + lerp(to: Color, ratio: number, out?: Color): Color; + /** + !#en TODO + !#zh 转换为方便阅读的字符串。 + + @example + ```js + var color = cc.Color.WHITE; + color.toString(); // "rgba(255, 255, 255, 255)" + ``` + */ + toString(): string; + /** + !#en Gets red channel value + !#zh 获取当前颜色的红色值。 + */ + getR(): number; + /** + !#en Sets red value and return the current color object + !#zh 设置当前的红色值,并返回当前对象。 + @param red the new Red component. + + @example + ```js + var color = new cc.Color(); + color.setR(255); // Color {r: 255, g: 0, b: 0, a: 255} + ``` + */ + setR(red: number): Color; + /** + !#en Gets green channel value + !#zh 获取当前颜色的绿色值。 + */ + getG(): number; + /** + !#en Sets green value and return the current color object + !#zh 设置当前的绿色值,并返回当前对象。 + @param green the new Green component. + + @example + ```js + var color = new cc.Color(); + color.setG(255); // Color {r: 0, g: 255, b: 0, a: 255} + ``` + */ + setG(green: number): Color; + /** + !#en Gets blue channel value + !#zh 获取当前颜色的蓝色值。 + */ + getB(): number; + /** + !#en Sets blue value and return the current color object + !#zh 设置当前的蓝色值,并返回当前对象。 + @param blue the new Blue component. + + @example + ```js + var color = new cc.Color(); + color.setB(255); // Color {r: 0, g: 0, b: 255, a: 255} + ``` + */ + setB(blue: number): Color; + /** + !#en Gets alpha channel value + !#zh 获取当前颜色的透明度值。 + */ + getA(): number; + /** + !#en Sets alpha value and return the current color object + !#zh 设置当前的透明度,并返回当前对象。 + @param alpha the new Alpha component. + + @example + ```js + var color = new cc.Color(); + color.setA(0); // Color {r: 0, g: 0, b: 0, a: 0} + ``` + */ + setA(alpha: number): Color; + /** + !#en Convert color to css format. + !#zh 转换为 CSS 格式。 + @param opt "rgba", "rgb", "#rgb" or "#rrggbb". + + @example + ```js + var color = cc.Color.BLACK; + color.toCSS(); // "#000"; + color.toCSS("rgba"); // "rgba(0,0,0,1.00)"; + color.toCSS("rgb"); // "rgba(0,0,0)"; + color.toCSS("#rgb"); // "#000"; + color.toCSS("#rrggbb"); // "#000000"; + ``` + */ + toCSS(opt: string): string; + /** + !#en Clamp this color to make all components between 0 to 255。 + !#zh 限制颜色数值,在 0 到 255 之间。 + + @example + ```js + var color = new cc.Color(1000, 0, 0, 255); + color.clamp(); + cc.log(color); // (255, 0, 0, 255) + ``` + */ + clamp(): void; + /** + !#en Read hex string and store color data into the current color object, the hex string must be formated as rgba or rgb. + !#zh 读取 16 进制颜色。 + @param hexString hexString + + @example + ```js + var color = cc.Color.BLACK; + color.fromHEX("#FFFF33"); // Color {r: 255, g: 255, b: 51, a: 255}; + ``` + */ + fromHEX(hexString: string): Color; + /** + !#en TODO + !#zh 转换为 16 进制。 + @param fmt "#rgb" or "#rrggbb". + + @example + ```js + var color = cc.Color.BLACK; + color.toHEX("#rgb"); // "000"; + color.toHEX("#rrggbb"); // "000000"; + ``` + */ + toHEX(fmt: string): string; + /** + !#en Convert to 24bit rgb value. + !#zh 转换为 24bit 的 RGB 值。 + + @example + ```js + var color = cc.Color.YELLOW; + color.toRGBValue(); // 16771844; + ``` + */ + toRGBValue(): number; + /** + !#en TODO + !#zh 读取 HSV(色彩模型)格式。 + @param h h + @param s s + @param v v + + @example + ```js + var color = cc.Color.YELLOW; + color.fromHSV(0, 0, 1); // Color {r: 255, g: 255, b: 255, a: 255}; + ``` + */ + fromHSV(h: number, s: number, v: number): Color; + /** + !#en TODO + !#zh 转换为 HSV(色彩模型)格式。 + + @example + ```js + var color = cc.Color.YELLOW; + color.toHSV(); // Object {h: 0.1533864541832669, s: 0.9843137254901961, v: 1}; + ``` + */ + toHSV(): any; + /** + !#en TODO + !#zh RGB 转换为 HSV。 + @param r red, must be [0, 255]. + @param g red, must be [0, 255]. + @param b red, must be [0, 255]. + + @example + ```js + cc.Color.rgb2hsv(255, 255, 255); // Object {h: 0, s: 0, v: 1}; + ``` + */ + static rgb2hsv(r: number, g: number, b: number): any; + /** + !#en TODO + !#zh HSV 转换为 RGB。 + @param h h + @param s s + @param v v + + @example + ```js + cc.Color.hsv2rgb(0, 0, 1); // Object {r: 255, g: 255, b: 255}; + ``` + */ + static hsv2rgb(h: number, s: number, v: number): any; + } + /** !#en A 2D rectangle defined by x, y position and width, height. + !#zh 通过位置和宽高定义的 2D 矩形。 */ + export class Rect extends ValueType { + /** + !#en + Constructor of cc.Rect class. + see {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} for convenience method. + !#zh + cc.Rect类的构造函数。可以通过 {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} 简便方法进行创建。 + @param x x + @param y y + @param w w + @param h h + */ + constructor(x?: number, y?: number, w?: number, h?: number); + x: number; + y: number; + width: number; + height: number; + /** + !#en Creates a rectangle from two coordinate values. + !#zh 根据指定 2 个坐标创建出一个矩形区域。 + @param v1 v1 + @param v2 v2 + + @example + ```js + cc.Rect.fromMinMax(cc.v2(10, 10), cc.v2(20, 20)); // Rect {x: 10, y: 10, width: 10, height: 10}; + ``` + */ + static fromMinMax(v1: Vec2, v2: Vec2): Rect; + /** + !#en Checks if rect contains. + !#zh + 判断 2 个矩形是否有包含。
+ 返回 1 为 a 包含 b,如果 -1 为 b 包含 a, + 0 这则都不包含。 + @param a Rect a + @param b Rect b + + @example + ```js + var a = new cc.Rect(0, 0, 10, 10); + var b = new cc.Rect(5, 5, 5, 5); + var c = new cc.Rect(20, 20, 10, 10); + cc.Rect.contain(a, b); // 1; + cc.Rect.contain(b, a); // -1; + cc.Rect.contain(a, c); // 0; + ``` + */ + static contain(a: Rect, b: Rect): number; + /** + !#en TODO + !#zh 克隆一个新的 Rect。 + + @example + ```js + var a = new cc.Rect(0, 0, 10, 10); + a.clone();// Rect {x: 0, y: 0, width: 10, height: 10} + ``` + */ + clone(): Rect; + /** + !#en TODO + !#zh 是否等于指定的矩形。 + @param other other + + @example + ```js + var a = new cc.Rect(0, 0, 10, 10); + var b = new cc.Rect(0, 0, 10, 10); + a.equals(b);// true; + ``` + */ + equals(other: Rect): boolean; + /** + !#en TODO + !#zh 线性插值 + @param to to + @param ratio the interpolation coefficient. + @param out optional, the receiving vector. + + @example + ```js + var a = new cc.Rect(0, 0, 10, 10); + var b = new cc.Rect(50, 50, 100, 100); + update (dt) { + // method 1; + var c = a.lerp(b, dt * 0.1); + // method 2; + a.lerp(b, dt * 0.1, c); + } + ``` + */ + lerp(to: Rect, ratio: number, out?: Rect): Rect; + /** + !#en TODO + !#zh 转换为方便阅读的字符串 + + @example + ```js + var a = new cc.Rect(0, 0, 10, 10); + a.toString();// "(0.00, 0.00, 10.00, 10.00)"; + ``` + */ + toString(): string; + /** !#en TODO + !#zh 矩形 x 轴上的最小值。 */ + xMin: number; + /** !#en TODO + !#zh 矩形 y 轴上的最小值。 */ + yMin: number; + /** !#en TODO + !#zh 矩形 x 轴上的最大值。 */ + xMax: number; + /** !#en TODO + !#zh 矩形 y 轴上的最大值。 */ + yMax: number; + /** !#en The position of the center of the rectangle. + !#zh 矩形的中心点。 */ + center: Vec2; + /** !#en The X and Y position of the rectangle. + !#zh 矩形的 x 和 y 坐标。 */ + origin: Vec2; + /** !#en Width and height of the rectangle. + !#zh 矩形的大小。 */ + size: Size; + /** + !#en TODO + !#zh 当前矩形与指定矩形是否相交。 + @param rect rect + + @example + ```js + var a = new cc.Rect(0, 0, 10, 10); + var b = new cc.Rect(0, 0, 20, 20); + a.intersects(b);// true + ``` + */ + intersects(rect: Rect): void; + /** + !#en TODO + !#zh 当前矩形是否包含指定坐标点。 + Returns true if the point inside this rectangle. + @param point point + + @example + ```js + var a = new cc.Rect(0, 0, 10, 10); + var b = new cc.Vec2(0, 5); + a.contains(b);// true + ``` + */ + contains(point: Vec2): void; + /** + !#en Returns true if the other rect totally inside this rectangle. + !#zh 当前矩形是否包含指定矩形。 + @param rect rect + + @example + ```js + var a = new cc.Rect(0, 0, 20, 20); + var b = new cc.Rect(0, 0, 10, 10); + a.containsRect(b);// true + ``` + */ + containsRect(rect: Rect): void; + } + /** !#en + cc.Size is the class for size object,
+ please do not use its constructor to create sizes,
+ use {{#crossLink "cc/size:method"}}{{/crossLink}} alias function instead.
+ It will be deprecated soon, please use cc.Vec2 instead. + + !#zh + cc.Size 是 size 对象的类。
+ 请不要使用它的构造函数创建的 size,
+ 使用 {{#crossLink "cc/size:method"}}{{/crossLink}} 别名函数。
+ 它不久将被取消,请使用cc.Vec2代替。 */ + export class Size { + /** + + @param width width + @param height height + */ + constructor(width: number|Size, height?: number); + width: number; + height: number; + /** !#en return a Size object with width = 0 and height = 0. + !#zh 返回一个宽度为 0 和高度为 0 的 Size 对象。 */ + static ZERO: Size; + /** + !#en TODO + !#zh 克隆 size 对象。 + + @example + ```js + var a = new cc.size(10, 10); + a.clone();// return Size {width: 0, height: 0}; + ``` + */ + clone(): Size; + /** + !#en TODO + !#zh 当前 Size 对象是否等于指定 Size 对象。 + @param other other + + @example + ```js + var a = new cc.size(10, 10); + a.equals(new cc.size(10, 10));// return true; + ``` + */ + equals(other: Size): boolean; + /** + !#en TODO + !#zh 线性插值。 + @param to to + @param ratio the interpolation coefficient. + @param out optional, the receiving vector. + + @example + ```js + var a = new cc.size(10, 10); + var b = new cc.rect(50, 50, 100, 100); + update (dt) { + // method 1; + var c = a.lerp(b, dt * 0.1); + // method 2; + a.lerp(b, dt * 0.1, c); + } + ``` + */ + lerp(to: Rect, ratio: number, out?: Size): Size; + /** + !#en TODO + !#zh 转换为方便阅读的字符串。 + + @example + ```js + var a = new cc.size(10, 10); + a.toString();// return "(10.00, 10.00)"; + ``` + */ + toString(): string; + } + /** !#en the device accelerometer reports values for each axis in units of g-force. + !#zh 设备重力传感器传递的各个轴的数据。 */ + export class Acceleration { + /** + + @param x x + @param y y + @param z z + @param timestamp timestamp + */ + constructor(x: number, y: number, z: number, timestamp: number); + } + /** !#en Blend Function used for textures. + !#zh 图像的混合方式。 */ + export class BlendFunc { + /** + + @param src1 source blend function + @param dst1 destination blend function + */ + constructor(src1: number, dst1: number); + } + /** !#en + Enum for blend factor + Refer to: http://www.andersriggelsen.dk/glblendfunc.php + !#zh + 混合因子 + 可参考: http://www.andersriggelsen.dk/glblendfunc.php */ + export enum BlendFactor { + ONE = 0, + ZERO = 0, + SRC_ALPHA = 0, + SRC_COLOR = 0, + DST_ALPHA = 0, + DST_COLOR = 0, + ONE_MINUS_SRC_ALPHA = 0, + ONE_MINUS_SRC_COLOR = 0, + ONE_MINUS_DST_ALPHA = 0, + ONE_MINUS_DST_COLOR = 0, + blendFuncDisable = 0, + } + /** undefined */ + export enum TextAlignment { + LEFT = 0, + CENTER = 0, + RIGHT = 0, + } + /** undefined */ + export class WebGLColor { + /** + + @param r r + @param g g + @param b b + @param a a + @param arrayBuffer arrayBuffer + @param offset offset + */ + constructor(r: number, g: number, b: number, a: number, arrayBuffer: any[], offset: number); + BYTES_PER_ELEMENT: number; + } + /** undefined */ + export class Vertex2F { + /** + + @param x x + @param y y + @param arrayBuffer arrayBuffer + @param offset offset + */ + constructor(x: number, y: number, arrayBuffer: any[], offset: number); + BYTES_PER_ELEMENT: number; + } + /** undefined */ + export class Vertex3F { + /** + + @param x x + @param y y + @param z z + @param arrayBuffer arrayBuffer + @param offset offset + */ + constructor(x: number, y: number, z: number, arrayBuffer: any[], offset: number); + BYTES_PER_ELEMENT: number; + } + /** undefined */ + export class Tex2F { + /** + + @param u u + @param v v + @param arrayBuffer arrayBuffer + @param offset offset + */ + constructor(u: number, v: number, arrayBuffer: any[], offset: number); + BYTES_PER_ELEMENT: number; + } + /** undefined */ + export class Quad2 { + /** + + @param tl tl + @param tr tr + @param bl bl + @param br br + @param arrayBuffer arrayBuffer + @param offset offset + */ + constructor(tl: Vertex2F, tr: Vertex2F, bl: Vertex2F, br: Vertex2F, arrayBuffer: any[], offset: number); + BYTES_PER_ELEMENT: number; + } + /** A 3D Quad. 4 * 3 floats */ + export class Quad3 { + /** + + @param bl1 bl1 + @param br1 br1 + @param tl1 tl1 + @param tr1 tr1 + @param arrayBuffer arrayBuffer + @param offset offset + */ + constructor(bl1: Vertex3F, br1: Vertex3F, tl1: Vertex3F, tr1: Vertex3F, arrayBuffer: any[], offset: number); + } + /** undefined */ + export class V3F_C4B_T2F { + /** + + @param vertices vertices + @param colors colors + @param texCoords texCoords + @param arrayBuffer arrayBuffer + @param offset offset + */ + constructor(vertices: Vertex3F, colors: Color, texCoords: Tex2F, arrayBuffer: any[], offset: number); + BYTES_PER_ELEMENT(): void; + } + /** undefined */ + export class V3F_C4B_T2F_Quad { + /** + + @param tl tl + @param bl bl + @param tr tr + @param br br + @param arrayBuffer arrayBuffer + @param offset offset + */ + constructor(tl: V3F_C4B_T2F, bl: V3F_C4B_T2F, tr: V3F_C4B_T2F, br: V3F_C4B_T2F, arrayBuffer: any[], offset: number); + BYTES_PER_ELEMENT: number; + } + /** undefined */ + export class V2F_C4B_T2F { + /** + + @param vertices vertices + @param colors colors + @param texCoords texCoords + @param arrayBuffer arrayBuffer + @param offset offset + */ + constructor(vertices: Vertex2F, colors: Color, texCoords: Tex2F, arrayBuffer: any[], offset: number); + BYTES_PER_ELEMENT: number; + } + /** undefined */ + export class V2F_C4B_T2F_Triangle { + /** + + @param a a + @param b b + @param c c + @param arrayBuffer arrayBuffer + @param offset offset + */ + constructor(a: V2F_C4B_T2F, b: V2F_C4B_T2F, c: V2F_C4B_T2F, arrayBuffer: any[], offset: number); + } + /** !#en The base class of all value types. + !#zh 所有值类型的基类。 */ + export class ValueType { + /** + !#en This method returns an exact copy of current value. + !#zh 克隆当前值,该方法返回一个新对象,新对象的值和原对象相等。 + */ + clone(): ValueType; + /** + !#en Compares this object with the other one. + !#zh 当前对象是否等于指定对象。 + @param other other + */ + equals(other: ValueType): boolean; + /** + !#en + Linearly interpolates between this value to to value by ratio which is in the range [0, 1]. + When ratio = 0 returns this. When ratio = 1 return to. When ratio = 0.5 returns the average of this and to. + !#zh + 线性插值。
+ 当 ratio = 0 时返回自身,ratio = 1 时返回目标,ratio = 0.5 返回自身和目标的平均值。。 + @param to the to value + @param ratio the interpolation coefficient + */ + lerp(to: ValueType, ratio: number): ValueType; + /** + !#en TODO + !#zh 转换为方便阅读的字符串。 + */ + toString(): string; + } + /** !#en Representation of 2D vectors and points. + !#zh 表示 2D 向量和坐标 */ + export class Vec2 extends ValueType { + /** + !#en + Constructor + see {{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} or {{#crossLink "cc/p:method"}}cc.p{{/crossLink}} + !#zh + 构造函数,可查看 {{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} 或者 {{#crossLink "cc/p:method"}}cc.p{{/crossLink}} + @param x x + @param y y + */ + constructor(x?: number, y?: number); + x: number; + y: number; + /** + !#en clone a Vec2 value + !#zh 克隆一个 Vec2 值 + */ + clone(): Vec2; + /** + !#en TODO + !#zh 设置向量值。 + @param newValue !#en new value to set. !#zh 要设置的新值 + */ + set(newValue: Vec2): Vec2; + /** + !#en TODO + !#zh 当前的向量是否与指定的向量相等。 + @param other other + */ + equals(other: Vec2): boolean; + /** + !#en TODO + !#zh 转换为方便阅读的字符串。 + */ + toString(): string; + /** + !#en TODO + !#zh 线性插值。 + @param to to + @param ratio the interpolation coefficient + @param out optional, the receiving vector + */ + lerp(to: Vec2, ratio: number, out?: Vec2): Vec2; + /** + !#en Adds this vector. If you want to save result to another vector, use add() instead. + !#zh 向量加法。如果你想保存结果到另一个向量,使用 add() 代替。 + @param vector vector + + @example + ```js + var v = cc.v2(10, 10); + v.addSelf(cc.v2(5, 5));// return Vec2 {x: 15, y: 15}; + ``` + */ + addSelf(vector: Vec2): Vec2; + /** + !#en Adds two vectors, and returns the new result. + !#zh 向量加法,并返回新结果。 + @param vector vector + @param out optional, the receiving vector + + @example + ```js + var v = cc.v2(10, 10); + v.add(cc.v2(5, 5)); // return Vec2 {x: 15, y: 15}; + var v1; + v.add(cc.v2(5, 5), v1); // return Vec2 {x: 15, y: 15}; + ``` + */ + add(vector: Vec2, out?: Vec2): Vec2; + /** + !#en Subtracts one vector from this. If you want to save result to another vector, use sub() instead. + !#zh 向量减法。如果你想保存结果到另一个向量,可使用 sub() 代替。 + @param vector vector + + @example + ```js + var v = cc.v2(10, 10); + v.subSelf(cc.v2(5, 5));// return Vec2 {x: 5, y: 5}; + ``` + */ + subSelf(vector: Vec2): Vec2; + /** + !#en Subtracts one vector from this, and returns the new result. + !#zh 向量减法,并返回新结果。 + @param vector vector + @param out optional, the receiving vector + + @example + ```js + var v = cc.v2(10, 10); + v.sub(cc.v2(5, 5)); // return Vec2 {x: 5, y: 5}; + var v1; + v.sub(cc.v2(5, 5), v1); // return Vec2 {x: 5, y: 5}; + ``` + */ + sub(vector: Vec2, out?: Vec2): Vec2; + /** + !#en Multiplies this by a number. If you want to save result to another vector, use mul() instead. + !#zh 缩放当前向量。如果你想结果保存到另一个向量,可使用 mul() 代替。 + @param num num + + @example + ```js + var v = cc.v2(10, 10); + v.mulSelf(5);// return Vec2 {x: 50, y: 50}; + ``` + */ + mulSelf(num: number): Vec2; + /** + !#en Multiplies by a number, and returns the new result. + !#zh 缩放向量,并返回新结果。 + @param num num + @param out optional, the receiving vector + + @example + ```js + var v = cc.v2(10, 10); + v.mul(5); // return Vec2 {x: 50, y: 50}; + var v1; + v.mul(5, v1); // return Vec2 {x: 50, y: 50}; + ``` + */ + mul(num: number, out?: Vec2): Vec2; + /** + !#en Multiplies two vectors. + !#zh 分量相乘。 + @param vector vector + + @example + ```js + var v = cc.v2(10, 10); + v.scaleSelf(cc.v2(5, 5));// return Vec2 {x: 50, y: 50}; + ``` + */ + scaleSelf(vector: Vec2): Vec2; + /** + !#en Multiplies two vectors, and returns the new result. + !#zh 分量相乘,并返回新的结果。 + @param vector vector + @param out optional, the receiving vector + + @example + ```js + var v = cc.v2(10, 10); + v.scale(cc.v2(5, 5)); // return Vec2 {x: 50, y: 50}; + var v1; + v.scale(cc.v2(5, 5), v1); // return Vec2 {x: 50, y: 50}; + ``` + */ + scale(vector: Vec2, out?: Vec2): Vec2; + /** + !#en Divides by a number. If you want to save result to another vector, use div() instead. + !#zh 向量除法。如果你想结果保存到另一个向量,可使用 div() 代替。 + @param vector vector + + @example + ```js + var v = cc.v2(10, 10); + v.divSelf(5); // return Vec2 {x: 2, y: 2}; + ``` + */ + divSelf(vector: Vec2): Vec2; + /** + !#en Divides by a number, and returns the new result. + !#zh 向量除法,并返回新的结果。 + @param vector vector + @param out optional, the receiving vector + + @example + ```js + var v = cc.v2(10, 10); + v.div(5); // return Vec2 {x: 2, y: 2}; + var v1; + v.div(5, v1); // return Vec2 {x: 2, y: 2}; + ``` + */ + div(vector: Vec2, out?: Vec2): Vec2; + /** + !#en Negates the components. If you want to save result to another vector, use neg() instead. + !#zh 向量取反。如果你想结果保存到另一个向量,可使用 neg() 代替。 + + @example + ```js + var v = cc.v2(10, 10); + v.negSelf(); // return Vec2 {x: -10, y: -10}; + ``` + */ + negSelf(): Vec2; + /** + !#en Negates the components, and returns the new result. + !#zh 返回取反后的新向量。 + @param out optional, the receiving vector + + @example + ```js + var v = cc.v2(10, 10); + var v1; + v.neg(v1); // return Vec2 {x: -10, y: -10}; + ``` + */ + neg(out?: Vec2): Vec2; + /** + !#en Dot product + !#zh 当前向量与指定向量进行点乘。 + @param vector vector + + @example + ```js + var v = cc.v2(10, 10); + v.dot(cc.v2(5, 5)); // return 100; + ``` + */ + dot(vector?: Vec2): number; + /** + !#en Cross product + !#zh 当前向量与指定向量进行叉乘。 + @param vector vector + + @example + ```js + var v = cc.v2(10, 10); + v.cross(cc.v2(5, 5)); // return 0; + ``` + */ + cross(vector?: Vec2): number; + /** + !#en Returns the length of this vector. + !#zh 返回该向量的长度。 + + @example + ```js + var v = cc.v2(10, 10); + v.mag(); // return 14.142135623730951; + ``` + */ + mag(): number; + /** + !#en Returns the squared length of this vector. + !#zh 返回该向量的长度平方。 + + @example + ```js + var v = cc.v2(10, 10); + v.magSqr(); // return 200; + ``` + */ + magSqr(): number; + /** + !#en Make the length of this vector to 1. + !#zh 向量归一化,让这个向量的长度为 1。 + + @example + ```js + var v = cc.v2(10, 10); + v.normalizeSelf(); // return Vec2 {x: 0.7071067811865475, y: 0.7071067811865475}; + ``` + */ + normalizeSelf(): Vec2; + /** + !#en + Returns this vector with a magnitude of 1.
+
+ Note that the current vector is unchanged and a new normalized vector is returned. If you want to normalize the current vector, use normalizeSelf function. + !#zh + 返回归一化后的向量。
+
+ 注意,当前向量不变,并返回一个新的归一化向量。如果你想来归一化当前向量,可使用 normalizeSelf 函数。 + @param out optional, the receiving vector + */ + normalize(out?: Vec2): Vec2; + /** + !#en Get angle in radian between this and vector. + !#zh 夹角的弧度。 + @param vector vector + */ + angle(vector: Vec2): number; + /** + !#en Get angle in radian between this and vector with direction. + !#zh 带方向的夹角的弧度。 + @param vector vector + */ + signAngle(vector: Vec2): number; + /** + !#en rotate + !#zh 返回旋转给定弧度后的新向量。 + @param radians radians + @param out optional, the receiving vector + */ + rotate(radians: number, out?: Vec2): Vec2; + /** + !#en rotate self + !#zh 按指定弧度旋转向量。 + @param radians radians + */ + rotateSelf(radians: number): Vec2; + /** !#en return a Vec2 object with x = 1 and y = 1. + !#zh 新 Vec2 对象。 */ + static ONE: Vec2; + /** !#en return a Vec2 object with x = 0 and y = 0. + !#zh 返回 x = 0 和 y = 0 的 Vec2 对象。 */ + static ZERO: Vec2; + /** !#en return a Vec2 object with x = 0 and y = 1. + !#zh 返回 x = 0 和 y = 1 的 Vec2 对象。 */ + static UP: Vec2; + /** !#en return a Vec2 object with x = 1 and y = 0. + !#zh 返回 x = 1 和 y = 0 的 Vec2 对象。 */ + static RIGHT: Vec2; + } + /** undefined */ + export class PhysicsBoxCollider extends PhysicsCollider implements Collider.Box { + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Box size + !#zh 包围盒大小 */ + size: Size; + } + /** undefined */ + export class PhysicsChainCollider extends PolygonCollider { + /** !#en Whether the chain is loop + !#zh 链条是否首尾相连 */ + loop: boolean; + /** !#en Chain points + !#zh 链条顶点数组 */ + points: [Vec2]; + } + /** undefined */ + export class PhysicsCircleCollider extends PhysicsCollider implements Collider.Circle { + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Circle radius + !#zh 圆形半径 */ + radius: number; + } + /** undefined */ + export class PhysicsCollider { + /** !#en + The density. + !#zh + 密度 */ + density: number; + /** !#en + A sensor collider collects contact information but never generates a collision response + !#zh + 一个传感器类型的碰撞体会产生碰撞回调,但是不会发生物理碰撞效果。 */ + sensor: boolean; + /** !#en + The friction coefficient, usually in the range [0,1]. + !#zh + 摩擦系数,取值一般在 [0, 1] 之间 */ + friction: number; + /** !#en + The restitution (elasticity) usually in the range [0,1]. + !#zh + 弹性系数,取值一般在 [0, 1]之间 */ + restitution: number; + /** !#en + Physics collider will find the rigidbody component on the node and set to this property. + !#zh + 碰撞体会在初始化时查找节点上是否存在刚体,如果查找成功则赋值到这个属性上。 */ + body: RigidBody; + /** + !#en + Apply current changes to collider, this will regenerate inner box2d fixtures. + !#zh + 应用当前 collider 中的修改,调用此函数会重新生成内部 box2d 的夹具。 + */ + apply(): void; + /** + !#en + Get the world aabb of the collider + !#zh + 获取碰撞体的世界坐标系下的包围盒 + */ + getAABB(): void; + } + /** undefined */ + export class PhysicsPolygonCollider extends PhysicsCollider implements Collider.Polygon { + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Polygon points + !#zh 多边形顶点数组 */ + points: [Vec2]; + } + /** !#en + A distance joint constrains two points on two bodies + to remain at a fixed distance from each other. You can view + this as a massless, rigid rod. + !#zh + 距离关节通过一个固定的长度来约束关节链接的两个刚体。你可以将它想象成一个无质量,坚固的木棍。 */ + export class DistanceJoint extends Joint { + /** !#en + The distance separating the two ends of the joint. + !#zh + 关节两端的距离 */ + distance: number; + /** !#en + The spring frequency. + !#zh + 弹性系数。 */ + frequency: number; + /** !#en + The damping ratio. + !#zh + 阻尼,表示关节变形后,恢复到初始状态受到的阻力。 */ + 0: number; + } + /** !#en + Base class for joints to connect rigidbody. + !#zh + 关节类的基类 */ + export class Joint extends Component { + /** !#en + The anchor of the rigidbody. + !#zh + 刚体的锚点。 */ + anchor: Vec2; + /** !#en + The anchor of the connected rigidbody. + !#zh + 关节另一端刚体的锚点。 */ + connectedAnchor: Vec2; + /** !#en + The rigidbody to which the other end of the joint is attached. + !#zh + 关节另一端链接的刚体 */ + connectedBody: RigidBody; + /** !#en + Should the two rigid bodies connected with this joint collide with each other? + !#zh + 链接到关节上的两个刚体是否应该相互碰撞? */ + collideConnected: boolean; + /** + !#en + Apply current changes to joint, this will regenerate inner box2d joint. + !#zh + 应用当前关节中的修改,调用此函数会重新生成内部 box2d 的关节。 + */ + apply(): void; + /** + !#en + Get the anchor point on rigidbody in world coordinates. + !#zh + 获取刚体世界坐标系下的锚点。 + */ + getWorldAnchor(): Vec2; + /** + !#en + Get the anchor point on connected rigidbody in world coordinates. + !#zh + 获取链接刚体世界坐标系下的锚点。 + */ + getWorldConnectedAnchor(): Vec2; + /** + !#en + Gets the reaction force of the joint. + !#zh + 获取关节的反作用力。 + @param timeStep The time to calculate the reaction force for. + */ + getReactionForce(timeStep: number): number; + /** + !#en + Gets the reaction torque of the joint. + !#zh + 获取关节的反扭矩。 + @param timeStep The time to calculate the reaction torque for. + */ + getReactionTorque(timeStep: number): number; + } + /** !#en + A motor joint is used to control the relative motion + between two bodies. A typical usage is to control the movement + of a dynamic body with respect to the ground. + !#zh + 马达关节被用来控制两个刚体间的相对运动。 + 一个典型的例子是用来控制一个动态刚体相对于地面的运动。 */ + export class MotorJoint extends Joint { + /** !#en + The anchor of the rigidbody. + !#zh + 刚体的锚点。 */ + anchor: Vec2; + /** !#en + The anchor of the connected rigidbody. + !#zh + 关节另一端刚体的锚点。 */ + connectedAnchor: Vec2; + /** !#en + The linear offset from connected rigidbody to rigidbody. + !#zh + 关节另一端的刚体相对于起始端刚体的位置偏移量 */ + linearOffset: Vec2; + /** !#en + The angular offset from connected rigidbody to rigidbody. + !#zh + 关节另一端的刚体相对于起始端刚体的角度偏移量 */ + angularOffset: number; + /** !#en + The maximum force can be applied to rigidbody. + !#zh + 可以应用于刚体的最大的力值 */ + maxForce: number; + /** !#en + The maximum torque can be applied to rigidbody. + !#zh + 可以应用于刚体的最大扭矩值 */ + maxTorque: number; + /** !#en + The position correction factor in the range [0,1]. + !#zh + 位置矫正系数,范围为 [0, 1] */ + correctionFactor: number; + } + /** !#en + A mouse joint is used to make a point on a body track a + specified world point. This a soft constraint with a maximum + force. This allows the constraint to stretch and without + applying huge forces. + Mouse Joint will auto register the touch event with the mouse region node, + and move the choosed rigidbody in touch move event. + Note : generally mouse joint only used in test bed. + !#zh + 鼠标关节用于使刚体上的一个点追踪一个指定的世界坐标系下的位置。 + 鼠标关节可以指定一个最大的里来施加一个柔和的约束。 + 鼠标关节会自动使用 mouse region 节点来注册鼠标事件,并且在触摸移动事件中移动选中的刚体。 + 注意:一般鼠标关节只在测试环境中使用。 */ + export class MouseJoint extends Joint { + /** !#en + The anchor of the rigidbody. + !#zh + 刚体的锚点。 */ + anchor: Vec2; + /** !#en + The anchor of the connected rigidbody. + !#zh + 关节另一端刚体的锚点。 */ + connectedAnchor: Vec2; + /** !#en + The node used to register touch evnet. + If this is null, it will be the joint's node. + !#zh + 用于注册触摸事件的节点。 + 如果没有设置这个值,那么将会使用关节的节点来注册事件。 */ + mouseRegion: Node; + /** !#en + The target point. + The mouse joint will move choosed rigidbody to target point. + !#zh + 目标点,鼠标关节将会移动选中的刚体到指定的目标点 */ + target: Vec2; + /** !#en + The spring frequency. + !#zh + 弹簧系数。 */ + frequency: number; + /** !#en + The damping ratio. + !#zh + 阻尼,表示关节变形后,恢复到初始状态受到的阻力。 */ + 0: number; + /** !#en + The maximum force + !#zh + 最大阻力值 */ + maxForce: number; + } + /** !#en + A prismatic joint. This joint provides one degree of freedom: translation + along an axis fixed in rigidbody. Relative rotation is prevented. You can + use a joint limit to restrict the range of motion and a joint motor to + drive the motion or to model joint friction. + !#zh + 移动关节指定了只能在一个方向上移动刚体。 + 你可以开启关节限制来设置刚体运行移动的间距,也可以开启马达来使用关节马达驱动刚体的运行。 */ + export class PrismaticJoint extends Joint { + /** !#en + The local joint axis relative to rigidbody. + !#zh + 指定刚体可以移动的方向。 */ + localAxisA: Vec2; + /** !#en + The reference angle. + !#zh + 相对角度 */ + referenceAngle: number; + /** !#en + Enable joint distance limit? + !#zh + 是否开启关节的距离限制? */ + enableLimit: boolean; + /** !#en + Enable joint motor? + !#zh + 是否开启关节马达? */ + enableMotor: boolean; + /** !#en + The lower joint limit. + !#zh + 刚体能够移动的最小值 */ + lowerLimit: number; + /** !#en + The upper joint limit. + !#zh + 刚体能够移动的最大值 */ + upperLimit: number; + /** !#en + The maxium force can be applied to rigidbody to rearch the target motor speed. + !#zh + 可以施加到刚体的最大力。 */ + maxMotorForce: number; + /** !#en + The expected motor speed. + !#zh + 期望的马达速度。 */ + motorSpeed: number; + } + /** !#en + A revolute joint constrains two bodies to share a common point while they + are free to rotate about the point. The relative rotation about the shared + point is the joint angle. You can limit the relative rotation with + a joint limit that specifies a lower and upper angle. You can use a motor + to drive the relative rotation about the shared point. A maximum motor torque + is provided so that infinite forces are not generated. + !#zh + 旋转关节可以约束两个刚体围绕一个点来进行旋转。 + 你可以通过开启关节限制来限制旋转的最大角度和最小角度。 + 你可以通过开启马达来施加一个扭矩力来驱动这两个刚体在这一点上的相对速度。 */ + export class RevoluteJoint extends Joint { + /** !#en + The reference angle. + An angle between bodies considered to be zero for the joint angle. + !#zh + 相对角度。 + 两个物体之间角度为零时可以看作相等于关节角度 */ + referenceAngle: number; + /** !#en + The lower angle. + !#zh + 角度的最低限制。 */ + lowerAngle: number; + /** !#en + The upper angle. + !#zh + 角度的最高限制。 */ + upperAngle: number; + /** !#en + The maxium torque can be applied to rigidbody to rearch the target motor speed. + !#zh + 可以施加到刚体的最大扭矩。 */ + maxMotorTorque: number; + /** !#en + The expected motor speed. + !#zh + 期望的马达速度。 */ + motorSpeed: number; + /** !#en + Enable joint limit? + !#zh + 是否开启关节的限制? */ + enableLimit: boolean; + /** !#en + Enable joint motor? + !#zh + 是否开启关节马达? */ + enableMotor: boolean; + /** + !#en + Get the joint angle. + !#zh + 获取关节角度。 + */ + getJointAngle(): number; + } + /** !#en + A rope joint enforces a maximum distance between two points + on two bodies. It has no other effect. + Warning: if you attempt to change the maximum length during + the simulation you will get some non-physical behavior. + !#zh + 绳子关节只指定两个刚体间的最大距离,没有其他的效果。 + 注意:如果你试图动态修改关节的长度,这有可能会得到一些意外的效果。 */ + export class RopeJoint extends Joint { + /** !#en + The max length. + !#zh + 最大长度。 */ + maxLength: number; + } + /** !#en + A weld joint essentially glues two bodies together. A weld joint may + distort somewhat because the island constraint solver is approximate. + !#zh + 熔接关节相当于将两个刚体粘在了一起。 + 熔接关节可能会使某些东西失真,因为约束求解器算出的都是近似值。 */ + export class WeldJoint extends Joint { + /** !#en + The reference angle. + !#zh + 相对角度。 */ + referenceAngle: number; + /** !#en + The frequency. + !#zh + 弹性系数。 */ + frequency: number; + /** !#en + The damping ratio. + !#zh + 阻尼,表示关节变形后,恢复到初始状态受到的阻力。 */ + 0: number; + } + /** !#en + A wheel joint. This joint provides two degrees of freedom: translation + along an axis fixed in bodyA and rotation in the plane. You can use a joint motor to drive + the rotation or to model rotational friction. + This joint is designed for vehicle suspensions. + !#zh + 轮子关节提供两个维度的自由度:旋转和沿着指定方向上位置的移动。 + 你可以通过开启关节马达来使用马达驱动刚体的旋转。 + 轮组关节是专门为机动车类型设计的。 */ + export class WheelJoint extends Joint { + /** !#en + The local joint axis relative to rigidbody. + !#zh + 指定刚体可以移动的方向。 */ + localAxisA: Vec2; + /** !#en + The maxium torque can be applied to rigidbody to rearch the target motor speed. + !#zh + 可以施加到刚体的最大扭矩。 */ + maxMotorTorque: number; + /** !#en + The expected motor speed. + !#zh + 期望的马达速度。 */ + motorSpeed: number; + /** !#en + Enable joint motor? + !#zh + 是否开启关节马达? */ + enableMotor: boolean; + /** !#en + The spring frequency. + !#zh + 弹性系数。 */ + frequency: number; + /** !#en + The damping ratio. + !#zh + 阻尼,表示关节变形后,恢复到初始状态受到的阻力。 */ + dampingRatio: number; + } + /**************************************************** + * audioEngine + *****************************************************/ + + export module audioEngine { + /** !#en Audio state. + !#zh 声音播放状态 */ + export enum AudioState { + ERROR = 0, + INITIALZING = 0, + PLAYING = 0, + PAUSED = 0, + } + } + + /**************************************************** + * Node + *****************************************************/ + + export module Node { + /** !#en The event type supported by Node + !#zh Node 支持的事件类型 */ + export class EventType { + /** !#en The event type for touch start event, you can use its value directly: 'touchstart' + !#zh 当手指触摸到屏幕时。 */ + static TOUCH_START: string; + /** !#en The event type for touch move event, you can use its value directly: 'touchmove' + !#zh 当手指在屏幕上目标节点区域内移动时。 */ + static TOUCH_MOVE: string; + /** !#en The event type for touch end event, you can use its value directly: 'touchend' + !#zh 当手指在目标节点区域内离开屏幕时。 */ + static TOUCH_END: string; + /** !#en The event type for touch end event, you can use its value directly: 'touchcancel' + !#zh 当手指在目标节点区域外离开屏幕时。 */ + static TOUCH_CANCEL: string; + /** !#en The event type for mouse down events, you can use its value directly: 'mousedown' + !#zh 当鼠标按下时触发一次。 */ + static MOUSE_DOWN: string; + /** !#en The event type for mouse move events, you can use its value directly: 'mousemove' + !#zh 当鼠标在目标节点在目标节点区域中移动时,不论是否按下。 */ + static MOUSE_MOVE: string; + /** !#en The event type for mouse enter target events, you can use its value directly: 'mouseenter' + !#zh 当鼠标移入目标节点区域时,不论是否按下。 */ + static MOUSE_ENTER: string; + /** !#en The event type for mouse leave target events, you can use its value directly: 'mouseleave' + !#zh 当鼠标移出目标节点区域时,不论是否按下。 */ + static MOUSE_LEAVE: string; + /** !#en The event type for mouse up events, you can use its value directly: 'mouseup' + !#zh 当鼠标从按下状态松开时触发一次。 */ + static MOUSE_UP: string; + /** !#en The event type for mouse wheel events, you can use its value directly: 'mousewheel' + !#zh 当鼠标滚轮滚动时。 */ + static MOUSE_WHEEL: string; + } + } + + /**************************************************** + * ParticleSystem + *****************************************************/ + + export module ParticleSystem { + /** !#en Enum for emitter modes + !#zh 发射模式 */ + export enum EmitterMode { + GRAVITY = 0, + RADIUS = 0, + } + } + + /**************************************************** + * ParticleSystem + *****************************************************/ + + export module ParticleSystem { + /** !#en Enum for particles movement type. + !#zh 粒子位置类型 */ + export enum PositionType { + FREE = 0, + RELATIVE = 0, + GROUPED = 0, + } + } + + /**************************************************** + * TiledMap + *****************************************************/ + + export module TiledMap { + /** !#en The orientation of tiled map. + !#zh Tiled Map 地图方向。 */ + export enum Orientation { + ORTHO = 0, + HEX = 0, + ISO = 0, + NONE = 0, + MAP = 0, + LAYER = 0, + OBJECTGROUP = 0, + OBJECT = 0, + TILE = 0, + HORIZONTAL = 0, + VERTICAL = 0, + DIAGONAL = 0, + FLIPPED_ALL = 0, + FLIPPED_MASK = 0, + STAGGERAXIS_X = 0, + STAGGERAXIS_Y = 0, + STAGGERINDEX_ODD = 0, + STAGGERINDEX_EVEN = 0, + } + } + + /**************************************************** + * Collider + *****************************************************/ + + export module Collider { + /** !#en Defines a Box Collider . + !#zh 用来定义包围盒碰撞体 */ + export class Box { + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Box size + !#zh 包围盒大小 */ + size: Size; + } + } + + /**************************************************** + * Collider + *****************************************************/ + + export module Collider { + /** !#en Defines a Circle Collider . + !#zh 用来定义圆形碰撞体 */ + export class Circle { + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Circle radius + !#zh 圆形半径 */ + radius: number; + } + } + + /**************************************************** + * Collider + *****************************************************/ + + export module Collider { + /** !#en Defines a Polygon Collider . + !#zh 用来定义多边形碰撞体 */ + export class Polygon { + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Polygon points + !#zh 多边形顶点数组 */ + points: [Vec2]; + } + } + + /**************************************************** + * Button + *****************************************************/ + + export module Button { + /** !#en Enum for transition type. + !#zh 过渡类型 */ + export enum Transition { + NONE = 0, + COLOR = 0, + SPRITE = 0, + SCALE = 0, + } + } + + /**************************************************** + * Component + *****************************************************/ + + export module Component { + /** !#en + Component will register a event to target component's handler. + And it will trigger the handler when a certain event occurs. + + !@zh + “EventHandler” 类用来设置场景中的事件回调, + 该类允许用户设置回调目标节点,目标组件名,组件方法名, + 并可通过 emit 方法调用目标函数。 */ + export class EventHandler { + /** !#en Event target + !#zh 目标节点 */ + target: Node; + /** !#en Component name + !#zh 目标组件名 */ + component: string; + /** !#en Event handler + !#zh 响应事件函数名 */ + handler: string; + /** !#en Custom Event Data + !#zh 自定义事件数据 */ + customEventData: string; + /** + + @param events events + @param params params + */ + static emitEvents(events: Component.EventHandler[], ...params: any[]): void; + /** + !#en Emit event with params + !#zh 触发目标组件上的指定 handler 函数,该参数是回调函数的参数值(可不填)。 + @param params params + + @example + ```js + // Call Function + var eventHandler = new cc.Component.EventHandler(); + eventHandler.target = newTarget; + eventHandler.component = "MainMenu"; + eventHandler.handler = "OnClick" + eventHandler.emit(["param1", "param2", ....]); + ``` + */ + emit(params: any[]): void; + } + } + + /**************************************************** + * EditBox + *****************************************************/ + + export module EditBox { + /** !#en Enum for keyboard return types + !#zh 键盘的返回键类型 */ + export enum KeyboardReturnType { + DEFAULT = 0, + DONE = 0, + SEND = 0, + SEARCH = 0, + GO = 0, + } + } + + /**************************************************** + * EditBox + *****************************************************/ + + export module EditBox { + /** !#en The EditBox's InputMode defines the type of text that the user is allowed to enter. + !#zh 输入模式 */ + export enum InputMode { + ANY = 0, + EMAIL_ADDR = 0, + NUMERIC = 0, + PHONE_NUMBER = 0, + URL = 0, + DECIMAL = 0, + SINGLE_LINE = 0, + } + } + + /**************************************************** + * EditBox + *****************************************************/ + + export module EditBox { + /** !#en Enum for the EditBox's input flags + !#zh 定义了一些用于设置文本显示和文本格式化的标志位。 */ + export enum InputFlag { + PASSWORD = 0, + SENSITIVE = 0, + INITIAL_CAPS_WORD = 0, + INITIAL_CAPS_SENTENCE = 0, + INITIAL_CAPS_ALL_CHARACTERS = 0, + } + } + + /**************************************************** + * Label + *****************************************************/ + + export module Label { + /** !#en Enum for text alignment. + !#zh 文本横向对齐类型 */ + export enum HorizontalAlign { + LEFT = 0, + CENTER = 0, + RIGHT = 0, + } + } + + /**************************************************** + * Label + *****************************************************/ + + export module Label { + /** !#en Enum for vertical text alignment. + !#zh 文本垂直对齐类型 */ + export enum VerticalAlign { + TOP = 0, + CENTER = 0, + BOTTOM = 0, + } + } + + /**************************************************** + * Label + *****************************************************/ + + export module Label { + /** !#en Enum for Overflow. + !#zh Overflow 类型 */ + export enum Overflow { + NONE = 0, + CLAMP = 0, + SHRINK = 0, + RESIZE_HEIGHT = 0, + } + } + + /**************************************************** + * Label + *****************************************************/ + + export module Label { + /** !#en Enum for font type. + !#zh Type 类型 */ + export enum Type { + TTF = 0, + BMFont = 0, + SystemFont = 0, + } + } + + /**************************************************** + * Layout + *****************************************************/ + + export module Layout { + /** !#en Enum for Layout type + !#zh 布局类型 */ + export enum Type { + NONE = 0, + HORIZONTAL = 0, + VERTICAL = 0, + GRID = 0, + } + } + + /**************************************************** + * Layout + *****************************************************/ + + export module Layout { + /** !#en Enum for Layout Resize Mode + !#zh 缩放模式 */ + export enum ResizeMode { + NONE = 0, + CONTAINER = 0, + CHILDREN = 0, + } + } + + /**************************************************** + * Layout + *****************************************************/ + + export module Layout { + /** !#en Enum for Grid Layout start axis direction. + The items in grid layout will be arranged in each axis at first.; + !#zh 布局轴向,只用于 GRID 布局。 */ + export enum AxisDirection { + HORIZONTAL = 0, + VERTICAL = 0, + } + } + + /**************************************************** + * Layout + *****************************************************/ + + export module Layout { + /** !#en Enum for vertical layout direction. + Used in Grid Layout together with AxisDirection is VERTICAL + !#zh 垂直方向布局方式 */ + export enum VerticalDirection { + BOTTOM_TO_TOP = 0, + TOP_TO_BOTTOM = 0, + } + } + + /**************************************************** + * Layout + *****************************************************/ + + export module Layout { + /** !#en Enum for horizontal layout direction. + Used in Grid Layout together with AxisDirection is HORIZONTAL + !#zh 水平方向布局方式 */ + export enum HorizontalDirection { + LEFT_TO_RIGHT = 0, + RIGHT_TO_LEFT = 0, + } + } + + /**************************************************** + * Mask + *****************************************************/ + + export module Mask { + /** !#en the type for mask. + !#zh 遮罩组件类型 */ + export enum Type { + RECT = 0, + ELLIPSE = 0, + IMAGE_STENCIL = 0, + } + } + + /**************************************************** + * PageView + *****************************************************/ + + export module PageView { + /** !#en The Page View Size Mode + !#zh 页面视图每个页面统一的大小类型 */ + export enum SizeMode { + Unified = 0, + Free = 0, + } + } + + /**************************************************** + * PageView + *****************************************************/ + + export module PageView { + /** !#en The Page View Direction + !#zh 页面视图滚动类型 */ + export enum Direction { + Horizontal = 0, + Vertical = 0, + } + } + + /**************************************************** + * PageView + *****************************************************/ + + export module PageView { + /** !#en Enum for ScrollView event type. + !#zh 滚动视图事件类型 */ + export enum EventType { + PAGE_TURNING = 0, + } + } + + /**************************************************** + * PageViewIndicator + *****************************************************/ + + export module PageViewIndicator { + /** !#en Enum for PageView Indicator direction + !#zh 页面视图指示器的摆放方向 */ + export enum Direction { + HORIZONTAL = 0, + VERTICAL = 0, + } + } + + /**************************************************** + * ProgressBar + *****************************************************/ + + export module ProgressBar { + /** !#en Enum for ProgressBar mode + !#zh 进度条模式 */ + export enum Mode { + HORIZONTAL = 0, + VERTICAL = 0, + FILLED = 0, + } + } + + /**************************************************** + * Scrollbar + *****************************************************/ + + export module Scrollbar { + /** Enum for Scrollbar direction */ + export enum Direction { + HORIZONTAL = 0, + VERTICAL = 0, + } + } + + /**************************************************** + * ScrollView + *****************************************************/ + + export module ScrollView { + /** !#en Enum for ScrollView event type. + !#zh 滚动视图事件类型 */ + export enum EventType { + SCROLL_TO_TOP = 0, + SCROLL_TO_BOTTOM = 0, + SCROLL_TO_LEFT = 0, + SCROLL_TO_RIGHT = 0, + SCROLLING = 0, + BOUNCE_TOP = 0, + BOUNCE_BOTTOM = 0, + BOUNCE_LEFT = 0, + BOUNCE_RIGHT = 0, + SCROLL_ENDED = 0, + TOUCH_UP = 0, + AUTOSCROLL_ENDED_WITH_THRESHOLD = 0, + SCROLL_BEGAN = 0, + } + } + + /**************************************************** + * Slider + *****************************************************/ + + export module Slider { + /** !#en The Slider Direction + !#zh 滑动器方向 */ + export enum Direction { + Horizontal = 0, + Vertical = 0, + } + } + + /**************************************************** + * Sprite + *****************************************************/ + + export module Sprite { + /** !#en Enum for sprite type. + !#zh Sprite 类型 */ + export enum Type { + SIMPLE = 0, + SLICED = 0, + TILED = 0, + FILLED = 0, + } + } + + /**************************************************** + * Sprite + *****************************************************/ + + export module Sprite { + /** !#en Enum for fill type. + !#zh 填充类型 */ + export enum FillType { + HORIZONTAL = 0, + VERTICAL = 0, + RADIAL = 0, + } + } + + /**************************************************** + * Sprite + *****************************************************/ + + export module Sprite { + /** !#en Sprite Size can track trimmed size, raw size or none. + !#zh 精灵尺寸调整模式 */ + export enum SizeMode { + CUSTOM = 0, + TRIMMED = 0, + RAW = 0, + } + } + + /**************************************************** + * VideoPlayer + *****************************************************/ + + export module VideoPlayer { + /** !#en Video event type + !#zh 视频事件类型 */ + export enum EventType { + PLAYING = 0, + PAUSED = 0, + STOPPED = 0, + COMPLETED = 0, + META_LOADED = 0, + CLICKED = 0, + READY_TO_PLAY = 0, + } + } + + /**************************************************** + * VideoPlayer + *****************************************************/ + + export module VideoPlayer { + /** !#en Enum for video resouce type type. + !#zh 视频来源 */ + export enum ResourceType { + REMOTE = 0, + LOCAL = 0, + } + } + + /**************************************************** + * WebView + *****************************************************/ + + export module WebView { + /** !#en WebView event type + !#zh 网页视图事件类型 */ + export enum EventType { + LOADED = 0, + LOADING = 0, + ERROR = 0, + } + } + + /**************************************************** + * Event + *****************************************************/ + + export module Event { + /** !#en The Custom event + !#zh 自定义事件 */ + export class EventCustom extends Event { + /** + + @param type The name of the event (case-sensitive), e.g. "click", "fire", or "submit" + @param bubbles A boolean indicating whether the event bubbles up through the tree or not + */ + constructor(type: string, bubbles: boolean); + /** !#en A reference to the detailed data of the event + !#zh 事件的详细数据 */ + detail: any; + /** + !#en Sets user data + !#zh 设置用户数据 + @param data data + */ + setUserData(data: any): void; + /** + !#en Gets user data + !#zh 获取用户数据 + */ + getUserData(): any; + /** + !#en Gets event name + !#zh 获取事件名称 + */ + getEventName(): string; + /** !#en + The keyCode read-only property represents a system and implementation dependent numerical code identifying the unmodified value of the pressed key.
+ This is usually the decimal ASCII (RFC 20) or Windows 1252 code corresponding to the key.
+ If the key can't be identified, this value is 0.
+ + !#zh + keyCode 是只读属性它表示一个系统和依赖于实现的数字代码,可以识别按键的未修改值。
+ 这通常是十进制 ASCII (RFC20) 或者 Windows 1252 代码,所对应的密钥。
+ 如果无法识别该键,则该值为 0。 */ + keyCode: number; + } + } + + /**************************************************** + * SystemEvent + *****************************************************/ + + export module SystemEvent { + /** !#en The event type supported by SystemEvent + !#zh SystemEvent 支持的事件类型 */ + export class EventType { + /** !#en The event type for press the key down event, you can use its value directly: 'keydown' + !#zh 当按下按键时触发的事件 */ + static KEY_DOWN: string; + /** !#en The event type for press the key up event, you can use its value directly: 'keyup' + !#zh 当松开按键时触发的事件 */ + static KEY_UP: string; + /** !#en The event type for press the devicemotion event, you can use its value directly: 'devicemotion' + !#zh 重力感应 */ + static DEVICEMOTION: string; + } + } + + /**************************************************** + * Event + *****************************************************/ + + export module Event { + /** !#en The mouse event + !#zh 鼠标事件类型 */ + export class EventMouse extends Event { + /** + !#en Sets scroll data. + !#zh 设置鼠标的滚动数据。 + @param scrollX scrollX + @param scrollY scrollY + */ + setScrollData(scrollX: number, scrollY: number): void; + /** + !#en Returns the x axis scroll value. + !#zh 获取鼠标滚动的X轴距离,只有滚动时才有效。 + */ + getScrollX(): number; + /** + !#en Returns the y axis scroll value. + !#zh 获取滚轮滚动的 Y 轴距离,只有滚动时才有效。 + */ + getScrollY(): number; + /** + !#en Sets cursor location. + !#zh 设置当前鼠标位置。 + @param x x + @param y y + */ + setLocation(x: number, y: number): void; + /** + !#en Returns cursor location. + !#zh 获取鼠标位置对象,对象包含 x 和 y 属性。 + */ + getLocation(): Vec2; + /** + !#en Returns the current cursor location in screen coordinates. + !#zh 获取当前事件在游戏窗口内的坐标位置对象,对象包含 x 和 y 属性。 + */ + getLocationInView(): Vec2; + /** + !#en Returns the previous touch location. + !#zh 获取鼠标点击在上一次事件时的位置对象,对象包含 x 和 y 属性。 + */ + getPreviousLocation(): Vec2; + /** + !#en Returns the delta distance from the previous location to current location. + !#zh 获取鼠标距离上一次事件移动的距离对象,对象包含 x 和 y 属性。 + */ + getDelta(): Vec2; + /** + !#en Returns the X axis delta distance from the previous location to current location. + !#zh 获取鼠标距离上一次事件移动的 X 轴距离。 + */ + getDeltaX(): number; + /** + !#en Returns the Y axis delta distance from the previous location to current location. + !#zh 获取鼠标距离上一次事件移动的 Y 轴距离。 + */ + getDeltaY(): number; + /** + !#en Sets mouse button. + !#zh 设置鼠标按键。 + @param button button + */ + setButton(button: number): void; + /** + !#en Returns mouse button. + !#zh 获取鼠标按键。 + */ + getButton(): number; + /** + !#en Returns location X axis data. + !#zh 获取鼠标当前位置 X 轴。 + */ + getLocationX(): number; + /** + !#en Returns location Y axis data. + !#zh 获取鼠标当前位置 Y 轴。 + */ + getLocationY(): number; + /** !#en The none event code of mouse event. + !#zh 无。 */ + static NONE: number; + /** !#en The event type code of mouse down event. + !#zh 鼠标按下事件。 */ + static DOWN: number; + /** !#en The event type code of mouse up event. + !#zh 鼠标按下后释放事件。 */ + static UP: number; + /** !#en The event type code of mouse move event. + !#zh 鼠标移动事件。 */ + static MOVE: number; + /** !#en The event type code of mouse scroll event. + !#zh 鼠标滚轮事件。 */ + static SCROLL: number; + /** !#en The tag of Mouse left button. + !#zh 鼠标左键的标签。 */ + static BUTTON_LEFT: number; + /** !#en The tag of Mouse right button (The right button number is 2 on browser). + !#zh 鼠标右键的标签。 */ + static BUTTON_RIGHT: number; + /** !#en The tag of Mouse middle button (The right button number is 1 on browser). + !#zh 鼠标中键的标签。 */ + static BUTTON_MIDDLE: number; + /** !#en The tag of Mouse button 4. + !#zh 鼠标按键 4 的标签。 */ + static BUTTON_4: number; + /** !#en The tag of Mouse button 5. + !#zh 鼠标按键 5 的标签。 */ + static BUTTON_5: number; + /** !#en The tag of Mouse button 6. + !#zh 鼠标按键 6 的标签。 */ + static BUTTON_6: number; + /** !#en The tag of Mouse button 7. + !#zh 鼠标按键 7 的标签。 */ + static BUTTON_7: number; + /** !#en The tag of Mouse button 8. + !#zh 鼠标按键 8 的标签。 */ + static BUTTON_8: number; + } + } + + /**************************************************** + * Event + *****************************************************/ + + export module Event { + /** !#en The touch event + !#zh 触摸事件 */ + export class EventTouch extends Event { + /** + + @param touchArr The array of the touches + @param bubbles A boolean indicating whether the event bubbles up through the tree or not + */ + constructor(touchArr: any[], bubbles: boolean); + /** !#en The current touch object + !#zh 当前触点对象 */ + touch: Touch; + /** + !#en Returns event code. + !#zh 获取事件类型。 + */ + getEventCode(): number; + /** + !#en Returns touches of event. + !#zh 获取触摸点的列表。 + */ + getTouches(): any[]; + /** + !#en Sets touch location. + !#zh 设置当前触点位置 + @param x x + @param y y + */ + setLocation(x: number, y: number): void; + /** + !#en Returns touch location. + !#zh 获取触点位置。 + */ + getLocation(): Vec2; + /** + !#en Returns the current touch location in screen coordinates. + !#zh 获取当前触点在游戏窗口中的位置。 + */ + getLocationInView(): Vec2; + /** + !#en Returns the previous touch location. + !#zh 获取触点在上一次事件时的位置对象,对象包含 x 和 y 属性。 + */ + getPreviousLocation(): Vec2; + /** + !#en Returns the start touch location. + !#zh 获获取触点落下时的位置对象,对象包含 x 和 y 属性。 + */ + getStartLocation(): Vec2; + /** + !#en Returns the id of cc.Touch. + !#zh 触点的标识 ID,可以用来在多点触摸中跟踪触点。 + */ + getID(): number; + /** + !#en Returns the delta distance from the previous location to current location. + !#zh 获取触点距离上一次事件移动的距离对象,对象包含 x 和 y 属性。 + */ + getDelta(): Vec2; + /** + !#en Returns the X axis delta distance from the previous location to current location. + !#zh 获取触点距离上一次事件移动的 x 轴距离。 + */ + getDeltaX(): number; + /** + !#en Returns the Y axis delta distance from the previous location to current location. + !#zh 获取触点距离上一次事件移动的 y 轴距离。 + */ + getDeltaY(): number; + /** + !#en Returns location X axis data. + !#zh 获取当前触点 X 轴位置。 + */ + getLocationX(): number; + /** + !#en Returns location Y axis data. + !#zh 获取当前触点 Y 轴位置。 + */ + getLocationY(): number; + } + } + + /**************************************************** + * Event + *****************************************************/ + + export module Event { + /** !#en The acceleration event + !#zh 加速度事件 */ + export class EventAcceleration extends Event { + } + } + + /**************************************************** + * Event + *****************************************************/ + + export module Event { + /** !#en The keyboard event + !#zh 键盘事件 */ + export class EventKeyboard extends Event { + } + } + + /**************************************************** + * Graphics + *****************************************************/ + + export module Graphics { + /** !#en Enum for LineCap. + !#zh 线段末端属性 */ + export enum LineCap { + BUTT = 0, + ROUND = 0, + SQUARE = 0, + } + } + + /**************************************************** + * Graphics + *****************************************************/ + + export module Graphics { + /** !#en Enum for LineJoin. + !#zh 线段拐角属性 */ + export enum LineJoin { + BEVEL = 0, + ROUND = 0, + MITER = 0, + } + } + + /**************************************************** + * Pipeline + *****************************************************/ + + export module Pipeline { + /** The downloader pipe, it can download several types of files: + 1. Text + 2. Image + 3. Script + 4. Audio + 5. Assets + All unknown type will be downloaded as plain text. + You can pass custom supported types in the constructor. */ + export class Downloader { + /** + Constructor of Downloader, you can pass custom supported types. + @param extMap Custom supported types with corresponded handler + + @example + ```js + var downloader = new Downloader({ + // This will match all url with `.scene` extension or all url with `scene` type + 'scene' : function (url, callback) {} + }); + ``` + */ + constructor(extMap: any); + /** + Add custom supported types handler or modify existing type handler. + @param extMap Custom supported types with corresponded handler + */ + addHandlers(extMap: any): void; + } + } + + /**************************************************** + * Pipeline + *****************************************************/ + + export module Pipeline { + /** The loader pipe, it can load several types of files: + 1. Images + 2. JSON + 3. Plist + 4. Audio + 5. Font + 6. Cocos Creator scene + It will not interfere with items of unknown type. + You can pass custom supported types in the constructor. */ + export class Loader { + /** + Constructor of Loader, you can pass custom supported types. + @param extMap Custom supported types with corresponded handler + + @example + ```js + var loader = new Loader({ + // This will match all url with `.scene` extension or all url with `scene` type + 'scene' : function (url, callback) {} + }); + ``` + */ + constructor(extMap: any); + /** + Add custom supported types handler or modify existing type handler. + @param extMap Custom supported types with corresponded handler + */ + addHandlers(extMap: any): void; + } + } + + /**************************************************** + * LoadingItems + *****************************************************/ + + export module LoadingItems { + /** !#en The item states of the LoadingItems, its value could be LoadingItems.ItemState.WORKING | LoadingItems.ItemState.COMPLETET | LoadingItems.ItemState.ERROR + !#zh LoadingItems 队列中的加载项状态,状态的值可能是 LoadingItems.ItemState.WORKING | LoadingItems.ItemState.COMPLETET | LoadingItems.ItemState.ERROR */ + export enum ItemState { + WORKING = 0, + COMPLETET = 0, + ERROR = 0, + } + } + + /**************************************************** + * Texture2D + *****************************************************/ + + export module Texture2D { + /** The texture pixel format, default value is RGBA8888 */ + export enum PixelFormat { + RGB565 = 0, + RGB5A1 = 0, + RGBA4444 = 0, + RGB888 = 0, + RGBA8888 = 0, + A8 = 0, + I8 = 0, + AI88 = 0, + } + } + + /**************************************************** + * Texture2D + *****************************************************/ + + export module Texture2D { + /** The texture wrap mode */ + export enum WrapMode { + REPEAT = 0, + CLAMP_TO_EDGE = 0, + MIRRORED_REPEAT = 0, + } + } + + /**************************************************** + * Texture2D + *****************************************************/ + + export module Texture2D { + /** The texture filter mode */ + export enum Filter { + LINEAR = 0, + NEAREST = 0, + } + } + +} + +/** !#en +AnySDK is a third party solution that offers game developers SDK integration without making changes to the SDK's features or parameters.It can do all of this while remaining invisible to your end user.Our goal is to handle all the tedious SDK integration work for you so that you can use your time to focus on the game itself.No matter if it’s the channel SDK, user system, payment system, ad system, statistics system, sharing system or any other type of SDK: we’ll take care of it for you. +!#zh +AnySDK 为 CP 提供一套第三方 SDK 接入解决方案,整个接入过程,不改变任何 SDK 的功能、特性、参数等,对于最终玩家而言是完全透明无感知的。 +目的是让 CP 商能有更多时间更专注于游戏本身的品质,所有 SDK 的接入工作统统交给我们吧。第三方 SDK 包括了渠道SDK、用户系统、支付系统、广告系统、统计系统、分享系统等等。 */ +declare module anysdk { + /** !#en + agent manager of plugin + !#zh + 插件管理对象 */ + export var agentManager: anysdk.AgentManager; + /** !#en + agent manager of plugin + !#zh + 插件管理类 */ + export class AgentManager { + /** + !#en + AppKey appSecret and privateKey are the only three parameters generated + after the packing tool client finishes creating the game. + The oauthLoginServer parameter is the API address provided by the game service + to login verification + !#zh + appKey、appSecret、privateKey是通过 AnySDK 客户端工具创建游戏后生成的。 + oauthLoginServer参数是游戏服务提供的用来做登陆验证转发的接口地址。 + @param appKey appKey + @param appSecret appSecret + @param privateKey privateKey + @param oauthLoginServer oauthLoginServer + */ + init(appKey: string, appSecret: string, privateKey: string, oauthLoginServer: string): void; + /** + !#en + load all plugins, the operation includes SDK`s initialization + !#zh + 加载所有插件,该操作包含了 SDKs 初始化 + @param callback callback + @param target The object to bind to. + */ + loadAllPlugins(callback: Function, target: any): void; + /** + !#en + unload all plugins + !#zh + 卸载插件 + */ + unloadAllPlugins(): void; + /** + !#en + get user system plugin + !#zh + 获取用户系统插件 + */ + getUserPlugin(): anysdk.ProtocolUser; + /** + !#en + get IAP system plugins + !#zh + 获取支付系统插件 + */ + getIAPPlugins(): anysdk.ProtocolIAP[]; + /** + !#en + get IAP system plugin + !#zh + 获取支付系统插件 + */ + getIAPPlugin(): anysdk.ProtocolIAP; + /** + !#en + get social system plugin + !#zh + 获取社交系统插件 + */ + getSocialPlugin(): anysdk.ProtocolSocial; + /** + !#en + get share system plugin + !#zh + 获取分享系统插件 + */ + getSharePlugin(): anysdk.ProtocolShare; + /** + !#en + get analytics system plugin + !#zh + 获取统计系统插件 + */ + getAnalyticsPlugin(): anysdk.ProtocolAnalytics; + /** + !#en + get ads system plugin + !#zh + 获取广告系统插件 + */ + getAdsPlugin(): anysdk.ProtocolAds; + /** + !#en + get push system plugin + !#zh + 获取推送系统插件 + */ + getPushPlugin(): anysdk.ProtocolPush; + /** + !#en + get REC system plugin + !#zh + 获取录屏系统插件 + */ + getRECPlugin(): anysdk.ProtocolREC; + /** + !#en + get crash system plugin + !#zh + 获取崩溃分析系统插件 + */ + getCrashPlugin(): anysdk.ProtocolCrash; + /** + !#en + get ad track system plugin + !#zh + 获取广告追踪系统插件 + */ + getAdTrackingPlugin(): anysdk.ProtocolAdTracking; + /** + !#en + get custom system plugin + !#zh + 获取自定义系统插件 + */ + getCustomPlugin(): anysdk.ProtocolCustom; + /** + !#en + get custom parameter + !#zh + 获取自定义参数 + */ + getCustomParam(): string; + /** + !#en + get channel id + !#zh + 获取渠道唯一表示符 + */ + getChannelId(): string; + /** + !#en + get status of analytics + !#zh + 获取统计状态 + */ + isAnaylticsEnabled(): boolean; + /** + !#en + set whether to analytics + !#zh + 设置是否统计 + @param enabled enabled + */ + setIsAnaylticsEnabled(enabled: boolean): void; + /** + !#en + destory instance + !#zh + 销毁单例 + */ + static end(): void; + /** + !#en + get instance + !#zh + 获取单例 + */ + static getInstance(): anysdk.AgentManager; + } + /** !#en + plugin protocol + !#zh + 插件协议 */ + export class PluginProtocol { + /** + !#en + Check whether the function is supported + !#zh + 判断函数是否支持 + @param functionName functionName + */ + isFunctionSupported(functionName: string): boolean; + /** + !#en + get plugin name + !#zh + 获取插件名称 + */ + getPluginName(): string; + /** + !#en + get plugin version + !#zh + 获取插件版本 + */ + getPluginVersion(): string; + /** + !#en + get SDK version + !#zh + 获取 SDK 版本 + */ + getSDKVersion(): string; + /** + !#en + void methods for reflections with parameter + !#zh + 反射调用带参数的void方法 + @param funName funName + @param args optional arguments + */ + callFuncWithParam(funName: string, ...args: any|anysdk.PluginParam[]): void; + /** + !#en + String methods for reflections with parameter + !#zh + 反射调用带参数的 String 方法 + @param funName funName + @param args optional arguments + */ + callStringFuncWithParam(funName: string, ...args: any|anysdk.PluginParam[]): string; + /** + !#en + int methods for reflections with parameter + !#zh + 反射调用带参数的 Int 方法 + @param funName funName + @param args optional arguments + */ + callIntFuncWithParam(funName: string, ...args: any|anysdk.PluginParam[]): number; + /** + !#en + boolean methods for reflections with parameter + !#zh + 反射调用带参数的 boolean 方法 + @param funName funName + @param args optional arguments + */ + callBoolFuncWithParam(funName: string, ...args: any|anysdk.PluginParam[]): boolean; + /** + !#en + float methods for reflections with parameter + !#zh + 反射调用带参数的 float 方法 + @param funName funName + @param args optional arguments + */ + callFloatFuncWithParam(funName: string, ...args: any|anysdk.PluginParam[]): number; + } + /** !#en + user protocol + !#zh + 用户系统协议接口 */ + export class ProtocolUser extends PluginProtocol { + /** + !#en + login interface + !#zh + 登录接口 + @param args optional arguments + */ + login(...args: string|any[]): void; + /** + !#en + get status of login + !#zh + 获取登录状态 + */ + isLogined(): boolean; + /** + !#en + get user ID + !#zh + 获取用户唯一标示符 + */ + getUserID(): string; + /** + !#en + get plugin ID + !#zh + 获取插件ID + */ + getPluginId(): string; + /** + !#en + set listener + !#zh + 设置用户系统的监听 + @param listener listener + @param target target + */ + setListener(listener: Function, target: any): void; + /** + !#en + get listener + !#zh + 获取用户系统的监听 + */ + getListener(): Function; + /** + !#en + logout + Before to invoke, you need to verdict whether this properties existed + !#zh + 登出,调用前需要判断属性是否存在 + */ + logout(): void; + /** + !#en + show toolbar + Before to invoke, you need to verdict whether this properties existed + !#zh + 显示悬浮窗,调用前需要判断属性是否存在 + @param place place + */ + showToolBar(place: anysdk.ToolBarPlace): void; + /** + !#en + hide toolbar + Before to invoke, you need to verdict whether this properties existed + !#zh + 隐藏悬浮窗,调用前需要判断属性是否存在 + */ + hideToolBar(): void; + /** + !#en + enter platform + Before to invoke, you need to verdict whether this properties existed + !#zh + 显示平台中心,调用前需要判断属性是否存在 + */ + enterPlatform(): void; + /** + !#en + show exit page + Before to invoke, you need to verdict whether this properties existed + !#zh + 显示退出界面,调用前需要判断属性是否存在 + */ + exit(): void; + /** + !#en + show pause page + Before to invoke, you need to verdict whether this properties existed + !#zh + 显示暂停界面,调用前需要判断属性是否存在 + */ + pause(): void; + /** + !#en + Real-name registration + Before to invoke, you need to verdict whether this properties existed + !#zh + 实名注册,调用前需要判断属性是否存在 + */ + realNameRegister(): void; + /** + !#en + Anti-addiction query + Before to invoke, you need to verdict whether this properties existed + !#zh + 防沉迷查询,调用前需要判断属性是否存在 + */ + antiAddictionQuery(): void; + /** + !#en + submit game role information + Before to invoke, you need to verdict whether this properties existed + !#zh + 提交角色信息,调用前需要判断属性是否存在 + @param data data + */ + submitLoginGameRole(data: any): void; + /** + !#en + get user information + Before to invoke, you need to verdict whether this properties existed + !#zh + 获取用户信息,调用前需要判断属性是否存在 + @param info info + */ + getUserInfo(info: any): void; + /** + !#en + set login type + Before to invoke, you need to verdict whether this properties existed + !#zh + 设置登录类型,调用前需要判断属性是否存在 + @param info info + */ + getAvailableLoginType(info: any): void; + /** + !#en + set login type + Before to invoke, you need to verdict whether this properties existed + !#zh + 设置登录类型,调用前需要判断属性是否存在 + @param loginType loginType + */ + setLoginType(loginType: string): void; + /** + !#en + send to desktop + Before to invoke, you need to verdict whether this properties existed + !#zh + 发送到桌面,调用前需要判断属性是否存在 + */ + sendToDesktop(): void; + /** + !#en + open bbs + Before to invoke, you need to verdict whether this properties existed + !#zh + 打开论坛,调用前需要判断属性是否存在 + */ + openBBS(): void; + } + /** !#en + IAP protocol + !#zh + 支付系统协议接口 */ + export class ProtocolIAP extends PluginProtocol { + /** + !#en + pay interface + !#zh + 支付接口 + @param info Type:map + */ + payForProduct(info: any): void; + /** + !#en + get order ID + !#zh + 获取订单ID + */ + getOrderId(): string; + /** + !#en + reset the pay status + !#zh + 重置支付状态 + */ + static resetPayState(): void; + /** + !#en + get plugin ID + !#zh + 获取插件ID + */ + getPluginId(): string; + /** + !#en + set listener + !#zh + 设置支付系统的监听 + @param listener listener + @param target target + */ + setListener(listener: Function, target: any): void; + /** + !#en + get listener + !#zh + 获取支付系统的监听 + */ + getListener(): Function; + } + /** !#en + analytics protocol + !#zh + 统计系统协议接口 */ + export class ProtocolAnalytics extends PluginProtocol { + /** + !#en + Start a new session. + !#zh + 启动会话 + */ + startSession(): void; + /** + !#en + Stop a session. + !#zh + 关闭会话 + */ + stopSession(): void; + /** + !#en + Set the timeout for expiring a session. + !#zh + 设置会话超时时间 + @param millis Type: long + */ + setSessionContinueMillis(millis: number): void; + /** + !#en + log an error + !#zh + 捕捉异常 + @param errorId errorId + @param message message + */ + logError(errorId: string, message: string): void; + /** + !#en + log an event. + !#zh + 捕捉事件 + @param errorId errorId + @param args optional arguments Type: map + */ + logEvent(errorId: string, ...args: any[]): void; + /** + !#en + Track an event begin. + !#zh + 统计事件开始 + @param eventId eventId + */ + logTimedEventBegin(eventId: string): void; + /** + !#en + Track an event end. + !#zh + 统计事件结束 + @param eventId eventId + */ + logTimedEventEnd(eventId: string): void; + /** + !#en + set Whether to catch uncaught exceptions to server. + !#zh + 设置是否开启自动异常捕捉 + @param enabled enabled + */ + setCaptureUncaughtException(enabled: boolean): void; + /** + !#en + analytics account information + !#zh + 统计玩家帐户信息 + @param paramMap Type: map + */ + setAccount(paramMap: any): void; + /** + !#en + track user to request payment + !#zh + 跟踪用户支付请求 + @param paramMap Type: map + */ + onChargeRequest(paramMap: any): void; + /** + !#en + track Successful payment + !#zh + 追踪用户支付成功 + @param orderID orderID + */ + onChargeSuccess(orderID: string): void; + /** + !#en + track failed payment + !#zh + 追踪用户支付失败 + @param paramMap Type: map + */ + onChargeFail(paramMap: any): void; + /** + !#en + track Successful payment + !#zh + 统计玩家支付成功 + @param paramMap Type: map + */ + onChargeOnlySuccess(paramMap: any): void; + /** + !#en + track user purchase + !#zh + 统计玩家消费 + @param paramMap Type: map + */ + onPurchase(paramMap: any): void; + /** + !#en + track user to use goods + !#zh + 统计玩家使用道具 + @param paramMap Type: map + */ + onUse(paramMap: any): void; + /** + !#en + track user to reward goods + !#zh + 统计玩家获取奖励 + @param paramMap Type: map + */ + onReward(paramMap: any): void; + /** + !#en + start level + !#zh + 开始关卡 + @param paramMap Type: map + */ + startLevel(paramMap: any): void; + /** + !#en + finish level + !#zh + 结束关卡 + @param levelID levelID + */ + finishLevel(levelID: string): void; + /** + !#en + failed level + !#zh + 关卡失败 + @param paramMap Type: map + */ + failLevel(paramMap: any): void; + /** + !#en + start task + !#zh + 开始任务 + @param paramMap Type: map + */ + startTask(paramMap: any): void; + /** + !#en + finish task + !#zh + 完成任务 + @param taskID taskID + */ + finishTask(taskID: string): void; + /** + !#en + failed task + !#zh + 任务失败 + @param paramMap Type: map + */ + failTask(paramMap: any): void; + } + /** !#en + share protocol + !#zh + 分享系统协议接口 */ + export class ProtocolShare extends PluginProtocol { + /** + !#en + share interface + !#zh + 分享 + @param info Type: map + */ + share(info: any): void; + /** + !#en + set listener + !#zh + 设置分享系统的监听 + @param listener listener + @param target target + */ + setListener(listener: Function, target: any): void; + /** + !#en + get listener + !#zh + 获取分享系统的监听 + */ + getListener(): Function; + } + /** !#en + ads protocol + !#zh + 广告系统协议接口 */ + export class ProtocolAds extends PluginProtocol { + /** + !#en + hide ads view + !#zh + 隐藏广告 + @param adstype adstype + @param idx idx + */ + hideAds(adstype: anysdk.AdsType, idx: number): void; + /** + !#en + preload ads view + !#zh + 预加载广告 + @param adstype adstype + @param idx idx + */ + preloadAds(adstype: anysdk.AdsType, idx: number): void; + /** + !#en + query points + !#zh + 查询分数 + */ + queryPoints(): number; + /** + !#en + get whether the ads type is supported + !#zh + 获取广告类型是否支持 + @param arg0 arg0 + */ + isAdTypeSupported(arg0: anysdk.AdsType): boolean; + /** + !#en + spend point + !#zh + 消费分数 + @param points points + */ + spendPoints(points: number): void; + /** + !#en + set listener + !#zh + 设置广告系统的监听 + @param listener listener + @param target target + */ + setListener(listener: Function, target: any): void; + /** + !#en + get listener + !#zh + 获取广告系统的监听 + */ + getListener(): Function; + } + /** !#en + social protocol + !#zh + 社交系统协议接口 */ + export class ProtocolSocial extends PluginProtocol { + /** + !#en + sign in + !#zh + 登录 + */ + signIn(): void; + /** + !#en + sign out + !#zh + 登出 + */ + signOut(): void; + /** + !#en + submit score + !#zh + 提交分数 + @param leadboardID leadboardID + @param score Type: long + */ + submitScore(leadboardID: string, score: number): void; + /** + !#en + show the id of Leaderboard page + !#zh + 根据唯一标识符显示排行榜 + @param leaderboardID leaderboardID + */ + showLeaderboard(leaderboardID: string): void; + /** + !#en + show the page of achievements + !#zh + 显示成就榜 + */ + showAchievements(): void; + /** + !#en + unlock achievement + !#zh + 解锁成就 + @param info Type: map + */ + share(info: any): void; + /** + !#en + set listener + !#zh + 设置社交系统的监听 + @param listener listener + @param target target + */ + setListener(listener: Function, target: any): void; + /** + !#en + get listener + !#zh + 获取社交系统的监听 + */ + getListener(): Function; + /** + !#en + get friends info + Before to invoke, you need to verdict whether this properties existed + !#zh + 获取好友信息,调用前需要判断属性是否存在 + */ + pauseRecording(): void; + /** + !#en + interact + Before to invoke, you need to verdict whether this properties existed + !#zh + 订阅,调用前需要判断属性是否存在 + */ + interact(): void; + /** + !#en + subscribe + Before to invoke, you need to verdict whether this properties existed + !#zh + 关注,调用前需要判断属性是否存在 + */ + subscribe(): void; + } + /** !#en + push protocol + !#zh + 推送系统协议接口 */ + export class ProtocolPush extends PluginProtocol { + /** + !#en + start Push services + !#zh + 启动推送服务 + */ + startPush(): void; + /** + !#en + close Push services + !#zh + 暂停推送服务 + */ + closePush(): void; + /** + !#en + delete alias + !#zh + 删除别名 + @param alias alias + */ + delAlias(alias: string): void; + /** + !#en + set alias + !#zh + 设置别名 + @param alias alias + */ + setAlias(alias: string): void; + /** + !#en + delete tags + !#zh + 删除标签 + @param tags Type: list + */ + delTags(tags: any): void; + /** + !#en + set tags + !#zh + 设置标签 + @param tags Type: list + */ + setTags(tags: any): void; + /** + !#en + set listener + !#zh + 设置推送系统的监听 + @param listener listener + @param target target + */ + setListener(listener: Function, target: any): void; + /** + !#en + get listener + !#zh + 获取推送系统的监听 + */ + getListener(): Function; + } + /** !#en + crash protocol + !#zh + 崩溃分析系统协议接口 */ + export class ProtocolCrash extends PluginProtocol { + /** + !#en + set user identifier + !#zh + 统计用户唯一标识符 + @param identifier identifier + */ + setUserIdentifier(identifier: string): void; + /** + !#en + The uploader captured in exception information + !#zh + 上报异常信息 + @param message message + @param exception exception + */ + reportException(message: string, exception: string): void; + /** + !#en + customize logging + !#zh + 自定义日志记录 + @param breadcrumb breadcrumb + */ + leaveBreadcrumb(breadcrumb: string): void; + } + /** !#en + REC protocol + !#zh + 录屏系统协议接口 */ + export class ProtocolREC extends PluginProtocol { + /** + !#en + share video + !#zh + 分享视频 + @param info Type: map + */ + share(info: any): void; + /** + !#en + Start to record video + !#zh + 开始录制视频 + */ + startRecording(): void; + /** + !#en + Start to record video + !#zh + 结束录制视频 + */ + stopRecording(): void; + /** + !#en + set listener + !#zh + 设置录屏系统的监听 + @param listener listener + @param target target + */ + setListener(listener: Function, target: any): void; + /** + !#en + get listener + !#zh + 获取录屏系统的监听 + */ + getListener(): Function; + /** + !#en + pause to record video + Before to invoke, you need to verdict whether this properties existed + !#zh + 暂停录制视频,调用前需要判断属性是否存在 + */ + pauseRecording(): void; + /** + !#en + resume to record video + Before to invoke, you need to verdict whether this properties existed + !#zh + 恢复录制视频,调用前需要判断属性是否存在 + */ + resumeRecording(): void; + /** + !#en + get whether the device is isAvailable + Before to invoke, you need to verdict whether this properties existed + !#zh + 获取设备是否可用,调用前需要判断属性是否存在 + */ + isAvailable(): boolean; + /** + !#en + get status of recording + Before to invoke, you need to verdict whether this properties existed + !#zh + 获取录制状态,调用前需要判断属性是否存在 + */ + isRecording(): boolean; + /** + !#en + show toolbar + Before to invoke, you need to verdict whether this properties existed + !#zh + 显示悬浮窗,调用前需要判断属性是否存在 + */ + showToolBar(): void; + /** + !#en + hide toolbar + Before to invoke, you need to verdict whether this properties existed + !#zh + 隐藏悬浮窗,调用前需要判断属性是否存在 + */ + hideToolBar(): void; + /** + !#en + show video center + Before to invoke, you need to verdict whether this properties existed + !#zh + 显示视频中心,调用前需要判断属性是否存在 + */ + showVideoCenter(): void; + /** + !#en + enter platform + Before to invoke, you need to verdict whether this properties existed + !#zh + 显示平台中心,调用前需要判断属性是否存在 + */ + enterPlatform(): void; + /** + !#en + Set the video data, it is recommended to check whether are recorded firstly + Before to invoke, you need to verdict whether this properties existed + !#zh + 设置视频相关数据,建议先检查是否是正在录制,调用前需要判断属性是否存在 + @param info Type: map + */ + setMetaData(info: any): void; + } + /** !#en + ad tracking protocol + !#zh + 广告追踪系统协议接口 */ + export class ProtocolAdTracking extends PluginProtocol { + /** + !#en + Call this method if you want to track register events as happening during a section. + !#zh + 统计用户注册信息 + @param productInfo Type: map + */ + onPay(productInfo: any): void; + /** + !#en + Call this method if you want to track register events as happening during a section. + !#zh + 统计用户注册信息 + @param userInfo Type: map + */ + onLogin(userInfo: any): void; + /** + !#en + Call this method if you want to track register events as happening during a section. + !#zh + 统计用户注册信息 + @param userId userId + */ + onRegister(userId: string): void; + /** + !#en + Call this method if you want to track custom events with parameters as happening during a section. + !#zh + 统计自定义事件 + @param eventId eventId + @param paramMap Type: map + */ + trackEvent(eventId: string, paramMap: any): void; + /** + !#en + Call this method with parameters if you want to create role as happening during a section. + !#zh + 统计创建角色事件,调用前需要判断属性是否存在 + @param userInfo Type: map + */ + onCreateRole(userInfo: any): void; + /** + !#en + Call this method if you want to track levelup events with parameters as happening during a section. + Before to invoke, you need to verdict whether this properties existed + !#zh + 统计角色升级事件,调用前需要判断属性是否存在 + @param info Type: map + */ + onLevelUp(info: any): void; + /** + !#en + Invoke this method with parameters if you want to start to pay as happening during a section. + Before to invoke, you need to verdict whether this properties existed + !#zh + 统计开始充值事件,调用前需要判断属性是否存在 + @param info Type: map + */ + onStartToPay(info: any): void; + } + /** !#en + custom protocol + !#zh + 自定义系统协议接口 */ + export class ProtocolCustom extends PluginProtocol { + /** + !#en + set listener + !#zh + 设置自定义系统的监听 + @param listener listener + @param target target + */ + setListener(listener: Function, target: any): void; + /** + !#en + get listener + !#zh + 获取自定义系统的监听 + */ + getListener(): Function; + } + /** !#en + Data structure class + !#zh + 数据结构类 */ + export class PluginParam { + /** + !#en + create plugin parameters + !#zh + 创建对象 + @param parameters parameters + */ + static create(parameters: number|string|any): anysdk.PluginParam; + } + /** !#en The callback of user system + !#zh 用户系统回调 */ + export enum UserActionResultCode { + kInitSuccess = 0, + kInitFail = 0, + kLoginSuccess = 0, + kLoginNetworkError = 0, + kLoginNoNeed = 0, + kLoginFail = 0, + kLoginCancel = 0, + kLogoutSuccess = 0, + kLogoutFail = 0, + kPlatformEnter = 0, + kPlatformBack = 0, + kPausePage = 0, + kExitPage = 0, + kAntiAddictionQuery = 0, + kRealNameRegister = 0, + kAccountSwitchSuccess = 0, + kAccountSwitchFail = 0, + kOpenShop = 0, + kAccountSwitchCancel = 0, + kUserExtension = 0, + kSendToDesktopSuccess = 0, + kSendToDesktopFail = 0, + kGetAvailableLoginTypeSuccess = 0, + kGetAvailableLoginTypeFail = 0, + kGetUserInfoSuccess = 0, + kGetUserInfoFail = 0, + kOpenBBSSuccess = 0, + kOpenBBSFail = 0, + } + /** !#en The toolbar position of user type + !#zh 用户系统悬浮窗位置 */ + export enum ToolBarPlace { + kToolBarTopLeft = 0, + kToolBarTopRight = 0, + kToolBarMidLeft = 0, + kToolBarMidRight = 0, + kToolBarBottomLeft = 0, + kToolBarBottomRight = 0, + } + /** !#en The callback of requesting reStringge + !#zh 支付系统支付请求回调 */ + export enum PayResultCode { + kPaySuccess = 0, + kPayFail = 0, + kPayCancel = 0, + kPayNetworkError = 0, + kPayProductionInforIncomplete = 0, + kPayInitSuccess = 0, + kPayInitFail = 0, + kPayNowPaying = 0, + kPayReStringgeSuccess = 0, + kPayExtension = 0, + kPayNeedLoginAgain = 0, + kRequestSuccess = 0, + kRequestFail = 0, + } + /** !#en The enum of account type + !#zh 统计系统的账号类型 */ + export enum AccountType { + ANONYMOUS = 0, + REGISTED = 0, + SINA_WEIBO = 0, + TENCENT_WEIBO = 0, + QQ = 0, + ND91 = 0, + } + /** !#en The enum of account operation + !#zh 统计系统的账号操作 */ + export enum AccountOperate { + LOGIN = 0, + LOGOUT = 0, + REGISTER = 0, + } + /** !#en The enum of gender + !#zh 统计系统的账号性别 */ + export enum AccountGender { + MALE = 0, + FEMALE = 0, + UNKNOWN = 0, + } + /** !#en The enum of task type + !#zh 统计系统的任务类型 */ + export enum TaskType { + GUIDE_LINE = 0, + MAIN_LINE = 0, + BRANCH_LINE = 0, + DAILY = 0, + ACTIVITY = 0, + OTHER = 0, + } + /** !#en The callback of share system + !#zh 分享系统回调 */ + export enum ShareResultCode { + kShareSuccess = 0, + kShareFail = 0, + kShareCancel = 0, + kShareNetworkError = 0, + kShareExtension = 0, + } + /** !#en The callback of social system + !#zh 社交系统回调 */ + export enum SocialRetCode { + kScoreSubmitSucceed = 0, + kScoreSubmitfail = 0, + kAchUnlockSucceed = 0, + kAchUnlockFail = 0, + kSocialSignInSucceed = 0, + kSocialSignInFail = 0, + kSocialSignOutSucceed = 0, + kSocialSignOutFail = 0, + kSocialGetGameFriends = 0, + kSocialExtensionCode = 0, + kSocialGetFriendsInfoSuccess = 0, + kSocialGetFriendsInfoFail = 0, + kSocialAlreadySubscription = 0, + kSocialNoSubscription = 0, + kSocialSubscriptionFail = 0, + } + /** !#en The callback of ads system + !#zh 广告系统回调 */ + export enum AdsResultCode { + kAdsReceived = 0, + kAdsShown = 0, + kAdsDismissed = 0, + kPointsSpendSucceed = 0, + kPointsSpendFailed = 0, + kNetworkError = 0, + kUnknownError = 0, + kOfferWallOnPointsChanged = 0, + kRewardedVideoWithReward = 0, + kInAppPurchaseFinished = 0, + kAdsClicked = 0, + kAdsExtension = 0, + } + /** !#en The enum of ads position + !#zh 广告位置 */ + export enum AdsPos { + kPosCenter = 0, + kPosTop = 0, + kPosTopLeft = 0, + kPosTopRight = 0, + kPosBottom = 0, + kPosBottomLeft = 0, + kPosBottomRight = 0, + } + /** !#en The enum of ads type + !#zh 广告类型 */ + export enum AdsType { + AD_TYPE_BANNER = 0, + AD_TYPE_FULLSCREEN = 0, + AD_TYPE_MOREAPP = 0, + AD_TYPE_OFFERWALL = 0, + AD_TYPE_REWARDEDVIDEO = 0, + AD_TYPE_NATIVEEXPRESS = 0, + AD_TYPE_NATIVEADVANCED = 0, + } + /** !#en The callback of push system + !#zh 推送系统回调 */ + export enum PushActionResultCode { + kPushReceiveMessage = 0, + kPushExtensionCode = 0, + } + /** !#en The callback of custom system + !#zh 自定义系统回调 */ + export enum CustomResultCode { + kCustomExtension = 0, + } + /** !#en The callback of REC system + !#zh 录屏系统回调 */ + export enum RECResultCode { + kRECInitSuccess = 0, + kRECInitFail = 0, + kRECStartRecording = 0, + kRECStopRecording = 0, + kRECPauseRecording = 0, + kRECResumeRecording = 0, + kRECEnterSDKPage = 0, + kRECQuitSDKPage = 0, + kRECShareSuccess = 0, + kRECShareFail = 0, + kRECExtension = 0, + } +} + +/** !#en +The global main namespace of DragonBones, all classes, functions, +properties and constants of DragonBones are defined in this namespace +!#zh +DragonBones 的全局的命名空间, +与 DragonBones 相关的所有的类,函数,属性,常量都在这个命名空间中定义。 */ +declare module dragonBones { + /** !#en + The Armature Display of DragonBones
+
+ (Armature Display has a reference to a DragonBonesAsset and stores the state for ArmatureDisplay instance, + which consists of the current pose's bone SRT, slot colors, and which slot attachments are visible.
+ Multiple Armature Display can use the same DragonBonesAsset which includes all animations, skins, and attachments.)
+ !#zh + DragonBones 骨骼动画
+
+ (Armature Display 具有对骨骼数据的引用并且存储了骨骼实例的状态, + 它由当前的骨骼动作,slot 颜色,和可见的 slot attachments 组成。
+ 多个 Armature Display 可以使用相同的骨骼数据,其中包括所有的动画,皮肤和 attachments。)
*/ + export class ArmatureDisplay extends cc._RendererUnderSG { + /** !#en + The DragonBones data contains the armatures information (bind pose bones, slots, draw order, + attachments, skins, etc) and animations but does not hold any state.
+ Multiple ArmatureDisplay can share the same DragonBones data. + !#zh + 骨骼数据包含了骨骼信息(绑定骨骼动作,slots,渲染顺序, + attachments,皮肤等等)和动画但不持有任何状态。
+ 多个 ArmatureDisplay 可以共用相同的骨骼数据。 */ + dragonAsset: DragonBonesAsset; + /** !#en + The atlas asset for the DragonBones. + !#zh + 骨骼数据所需的 Atlas Texture 数据。 */ + dragonAtlasAsset: DragonBonesAtlasAsset; + /** !#en The name of current armature. + !#zh 当前的 Armature 名称。 */ + armatureName: string; + /** !#en The name of current playing animation. + !#zh 当前播放的动画名称。 */ + animationName: string; + _defaultArmatureIndex: number; + /** !#en The time scale of this armature. + !#zh 当前骨骼中所有动画的时间缩放率。 */ + timeScale: number; + /** !#en The play times of the default animation. + -1 means using the value of config file; + 0 means repeat for ever + >0 means repeat times + !#zh 播放默认动画的循环次数 + -1 表示使用配置文件中的默认值; + 0 表示无限循环 + >0 表示循环次数 */ + playTimes: number; + /** !#en Indicates whether open debug bones. + !#zh 是否显示 bone 的 debug 信息。 */ + debugBones: boolean; + /** + !#en + Play the specified animation. + Parameter animName specify the animation name. + Parameter playTimes specify the repeat times of the animation. + -1 means use the value of the config file. + 0 means play the animation for ever. + >0 means repeat times. + !#zh + 播放指定的动画. + animName 指定播放动画的名称。 + playTimes 指定播放动画的次数。 + -1 为使用配置文件中的次数。 + 0 为无限循环播放。 + >0 为动画的重复次数。 + @param animName animName + @param playTimes playTimes + */ + playAnimation(animName: string, playTimes: number): dragonBones.AnimationState; + /** + !#en + Get the all armature names in the DragonBones Data. + !#zh + 获取 DragonBones 数据中所有的 armature 名称 + */ + getArmatureNames(): any[]; + /** + !#en + Get the all animation names of specified armature. + !#zh + 获取指定的 armature 的所有动画名称。 + @param armatureName armatureName + */ + getAnimationNames(armatureName: string): any[]; + /** + !#en + Add event listener for the DragonBones Event. + !#zh + 添加 DragonBones 事件监听器。 + @param eventType eventType + @param listener listener + @param target target + */ + addEventListener(eventType: dragonBones.EventObject, listener: Function, target: any): void; + /** + !#en + Remove the event listener for the DragonBones Event. + !#zh + 移除 DragonBones 事件监听器。 + @param eventType eventType + @param listener listener + @param target target + */ + removeEventListener(eventType: dragonBones.EventObject, listener: Function, target: any): void; + /** + !#en + Build the armature for specified name. + !#zh + 构建指定名称的 armature 对象 + @param armatureName armatureName + */ + buildArmature(armatureName: string): dragonBones.Armature; + /** + !#en + Get the current armature object of the ArmatureDisplay. + !#zh + 获取 ArmatureDisplay 当前使用的 Armature 对象 + */ + armature(): any; + } + /** !#en The skeleton data of dragonBones. + !#zh dragonBones 的 骨骼数据。 */ + export class DragonBonesAsset extends cc.Asset { + /** !#en See http://developer.egret.com/cn/github/egret-docs/DB/dbLibs/dataFormat/index.html + !#zh 可查看 DragonBones 官方文档 http://developer.egret.com/cn/github/egret-docs/DB/dbLibs/dataFormat/index.html */ + dragonBonesJson: string; + } + /** !#en The skeleton atlas data of dragonBones. + !#zh dragonBones 的骨骼纹理数据。 */ + export class DragonBonesAtlasAsset extends cc.Asset { + atlasJson: string; + texture: cc.Texture2D; + } +} + +/** !#en +The global main namespace of Spine, all classes, functions, +properties and constants of Spine are defined in this namespace +!#zh +Spine 的全局的命名空间, +与 Spine 相关的所有的类,函数,属性,常量都在这个命名空间中定义。 */ +declare module sp { + /** !#en + The skeleton of Spine
+
+ (Skeleton has a reference to a SkeletonData and stores the state for skeleton instance, + which consists of the current pose's bone SRT, slot colors, and which slot attachments are visible.
+ Multiple skeletons can use the same SkeletonData which includes all animations, skins, and attachments.)
+ !#zh + Spine 骨骼动画
+
+ (Skeleton 具有对骨骼数据的引用并且存储了骨骼实例的状态, + 它由当前的骨骼动作,slot 颜色,和可见的 slot attachments 组成。
+ 多个 Skeleton 可以使用相同的骨骼数据,其中包括所有的动画,皮肤和 attachments。 */ + export class Skeleton extends cc._RendererUnderSG { + /** !#en The skeletal animation is paused? + !#zh 该骨骼动画是否暂停。 */ + paused: boolean; + /** !#en + The skeleton data contains the skeleton information (bind pose bones, slots, draw order, + attachments, skins, etc) and animations but does not hold any state.
+ Multiple skeletons can share the same skeleton data. + !#zh + 骨骼数据包含了骨骼信息(绑定骨骼动作,slots,渲染顺序, + attachments,皮肤等等)和动画但不持有任何状态。
+ 多个 Skeleton 可以共用相同的骨骼数据。 */ + skeletonData: SkeletonData; + /** !#en The name of default skin. + !#zh 默认的皮肤名称。 */ + defaultSkin: string; + /** !#en The name of default animation. + !#zh 默认的动画名称。 */ + defaultAnimation: string; + /** !#en The name of current playing animation. + !#zh 当前播放的动画名称。 */ + animation: string; + _defaultSkinIndex: number; + /** !#en TODO + !#zh 是否循环播放当前骨骼动画。 */ + loop: boolean; + /** !#en Indicates whether to enable premultiplied alpha. + You should disable this option when image's transparent area appears to have opaque pixels, + or enable this option when image's half transparent area appears to be darken. + !#zh 是否启用贴图预乘。 + 当图片的透明区域出现色块时需要关闭该选项,当图片的半透明区域颜色变黑时需要启用该选项。 */ + premultipliedAlpha: boolean; + /** !#en The time scale of this skeleton. + !#zh 当前骨骼中所有动画的时间缩放率。 */ + timeScale: number; + /** !#en Indicates whether open debug slots. + !#zh 是否显示 slot 的 debug 信息。 */ + debugSlots: boolean; + /** !#en Indicates whether open debug bones. + !#zh 是否显示 bone 的 debug 信息。 */ + debugBones: boolean; + /** + !#en Computes the world SRT from the local SRT for each bone. + !#zh 重新更新所有骨骼的世界 Transform, + 当获取 bone 的数值未更新时,即可使用该函数进行更新数值。 + + @example + ```js + var bone = spine.findBone('head'); + cc.log(bone.worldX); // return 0; + spine.updateWorldTransform(); + bone = spine.findBone('head'); + cc.log(bone.worldX); // return -23.12; + ``` + */ + updateWorldTransform(): void; + /** + !#en Sets the bones and slots to the setup pose. + !#zh 还原到起始动作 + */ + setToSetupPose(): void; + /** + !#en + Sets the bones to the setup pose, + using the values from the `BoneData` list in the `SkeletonData`. + !#zh + 设置 bone 到起始动作 + 使用 SkeletonData 中的 BoneData 列表中的值。 + */ + setBonesToSetupPose(): void; + /** + !#en + Sets the slots to the setup pose, + using the values from the `SlotData` list in the `SkeletonData`. + !#zh + 设置 slot 到起始动作。 + 使用 SkeletonData 中的 SlotData 列表中的值。 + */ + setSlotsToSetupPose(): void; + /** + !#en + Finds a bone by name. + This does a string comparison for every bone.
+ Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Bone object. + !#zh + 通过名称查找 bone。 + 这里对每个 bone 的名称进行了对比。
+ 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Bone 对象。 + @param boneName boneName + */ + findBone(boneName: string): sp.spine.Bone; + /** + !#en + Finds a slot by name. This does a string comparison for every slot.
+ Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Slot object. + !#zh + 通过名称查找 slot。这里对每个 slot 的名称进行了比较。
+ 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Slot 对象。 + @param slotName slotName + */ + findSlot(slotName: string): sp.spine.Slot; + /** + !#en + Finds a skin by name and makes it the active skin. + This does a string comparison for every skin.
+ Note that setting the skin does not change which attachments are visible.
+ Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Skin object. + !#zh + 按名称查找皮肤,激活该皮肤。这里对每个皮肤的名称进行了比较。
+ 注意:设置皮肤不会改变 attachment 的可见性。
+ 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Skin 对象。 + @param skinName skinName + */ + setSkin(skinName: string): sp.spine.Skin; + /** + !#en + Returns the attachment for the slot and attachment name. + The skeleton looks first in its skin, then in the skeleton data’s default skin.
+ Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Attachment object. + !#zh + 通过 slot 和 attachment 的名称获取 attachment。Skeleton 优先查找它的皮肤,然后才是 Skeleton Data 中默认的皮肤。
+ 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Attachment 对象。 + @param slotName slotName + @param attachmentName attachmentName + */ + getAttachment(slotName: string, attachmentName: string): sp.spine.Attachment; + /** + !#en + Sets the attachment for the slot and attachment name. + The skeleton looks first in its skin, then in the skeleton data’s default skin. + !#zh + 通过 slot 和 attachment 的名字来设置 attachment。 + Skeleton 优先查找它的皮肤,然后才是 Skeleton Data 中默认的皮肤。 + @param slotName slotName + @param attachmentName attachmentName + */ + setAttachment(slotName: string, attachmentName: string): void; + /** + !#en + Sets runtime skeleton data to sp.Skeleton.
+ This method is different from the `skeletonData` property. This method is passed in the raw data provided by the Spine runtime, and the skeletonData type is the asset type provided by Creator. + !#zh + 设置底层运行时用到的 SkeletonData。
+ 这个接口有别于 `skeletonData` 属性,这个接口传入的是 Spine runtime 提供的原始数据,而 skeletonData 的类型是 Creator 提供的资源类型。 + @param skeletonData skeletonData + @param ownsSkeletonData ownsSkeletonData + */ + setSkeletonData(skeletonData: sp.spine.SkeletonData, ownsSkeletonData: sp.spine.SkeletonData): void; + /** + !#en Sets animation state data.
+ The parameter type is {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.AnimationStateData. + !#zh 设置动画状态数据。
+ 参数是 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.AnimationStateData。 + @param stateData stateData + */ + setAnimationStateData(stateData: sp.spine.AnimationStateData): void; + /** + !#en + Mix applies all keyframe values, + interpolated for the specified time and mixed with the current values. + !#zh 为所有关键帧设定混合及混合时间(从当前值开始差值)。 + @param fromAnimation fromAnimation + @param toAnimation toAnimation + @param duration duration + */ + setMix(fromAnimation: string, toAnimation: string, duration: number): void; + /** + !#en Sets event listener. + !#zh 设置动画事件监听器。 + @param target target + @param callback callback + */ + setAnimationListener(target: any, callback: Function): void; + /** + !#en Set the current animation. Any queued animations are cleared.
+ Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry object. + !#zh 设置当前动画。队列中的任何的动画将被清除。
+ 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry 对象。 + @param trackIndex trackIndex + @param name name + @param loop loop + */ + setAnimation(trackIndex: number, name: string, loop: boolean): sp.spine.TrackEntry; + /** + !#en Adds an animation to be played delay seconds after the current or last queued animation.
+ Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry object. + !#zh 添加一个动画到动画队列尾部,还可以延迟指定的秒数。
+ 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry 对象。 + @param trackIndex trackIndex + @param name name + @param loop loop + @param delay delay + */ + addAnimation(trackIndex: number, name: string, loop: boolean, delay?: number): sp.spine.TrackEntry; + /** + !#en Find animation with specified name. + !#zh 查找指定名称的动画 + @param name name + */ + findAnimation(name: string): sp.spine.Animation; + /** + !#en Returns track entry by trackIndex.
+ Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry object. + !#zh 通过 track 索引获取 TrackEntry。
+ 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry 对象。 + @param trackIndex trackIndex + */ + getCurrent(trackIndex: void): sp.spine.TrackEntry; + /** + !#en Clears all tracks of animation state. + !#zh 清除所有 track 的动画状态。 + */ + clearTracks(): void; + /** + !#en Clears track of animation state by trackIndex. + !#zh 清除出指定 track 的动画状态。 + @param trackIndex trackIndex + */ + clearTrack(trackIndex: number): void; + /** + !#en Set the start event listener. + !#zh 用来设置开始播放动画的事件监听。 + @param listener listener + */ + setStartListener(listener: Function): void; + /** + !#en Set the interrupt event listener. + !#zh 用来设置动画被打断的事件监听。 + @param listener listener + */ + setInterruptListener(listener: Function): void; + /** + !#en Set the end event listener. + !#zh 用来设置动画播放完后的事件监听。 + @param listener listener + */ + setEndListener(listener: Function): void; + /** + !#en Set the dispose event listener. + !#zh 用来设置动画将被销毁的事件监听。 + @param listener listener + */ + setDisposeListener(listener: Function): void; + /** + !#en Set the complete event listener. + !#zh 用来设置动画播放一次循环结束后的事件监听。 + @param listener listener + */ + setCompleteListener(listener: Function): void; + /** + !#en Set the animation event listener. + !#zh 用来设置动画播放过程中帧事件的监听。 + @param listener listener + */ + setEventListener(listener: Function): void; + /** + !#en Set the start event listener for specified TrackEntry (only supported on Web). + !#zh 用来为指定的 TrackEntry 设置动画开始播放的事件监听。(只支持 Web 平台) + @param entry entry + @param listener listener + */ + setTrackStartListener(entry: sp.spine.TrackEntry, listener: Function): void; + /** + !#en Set the interrupt event listener for specified TrackEntry (only supported on Web). + !#zh 用来为指定的 TrackEntry 设置动画被打断的事件监听。(只支持 Web 平台) + @param entry entry + @param listener listener + */ + setTrackInterruptListener(entry: sp.spine.TrackEntry, listener: Function): void; + /** + !#en Set the end event listener for specified TrackEntry (only supported on Web). + !#zh 用来为指定的 TrackEntry 设置动画播放结束的事件监听。(只支持 Web 平台) + @param entry entry + @param listener listener + */ + setTrackEndListener(entry: sp.spine.TrackEntry, listener: Function): void; + /** + !#en Set the dispose event listener for specified TrackEntry (only supported on Web). + !#zh 用来为指定的 TrackEntry 设置动画即将被销毁的事件监听。(只支持 Web 平台) + @param entry entry + @param listener listener + */ + setTrackDisposeListener(entry: sp.spine.TrackEntry, listener: Function): void; + /** + !#en Set the complete event listener for specified TrackEntry (only supported on Web). + !#zh 用来为指定的 TrackEntry 设置动画一次循环播放结束的事件监听。(只支持 Web 平台) + @param entry entry + @param listener listener + */ + setTrackCompleteListener(entry: sp.spine.TrackEntry, listener: Function): void; + /** + !#en Set the event listener for specified TrackEntry (only supported on Web). + !#zh 用来为指定的 TrackEntry 设置动画帧事件的监听。(只支持 Web 平台) + @param entry entry + @param listener listener + */ + setTrackEventListener(entry: sp.spine.TrackEntry, listener: Function): void; + } + /** !#en The skeleton data of spine. + !#zh Spine 的 骨骼数据。 */ + export class SkeletonData extends cc.Asset { + /** !#en See http://en.esotericsoftware.com/spine-json-format + !#zh 可查看 Spine 官方文档 http://zh.esotericsoftware.com/spine-json-format */ + skeletonJson: any; + atlasText: string; + textures: cc.Texture2D[]; + /** !#en + A scale can be specified on the JSON or binary loader which will scale the bone positions, + image sizes, and animation translations. + This can be useful when using different sized images than were used when designing the skeleton + in Spine. For example, if using images that are half the size than were used in Spine, + a scale of 0.5 can be used. This is commonly used for games that can run with either low or high + resolution texture atlases. + see http://en.esotericsoftware.com/spine-using-runtimes#Scaling + !#zh 可查看 Spine 官方文档: http://zh.esotericsoftware.com/spine-using-runtimes#Scaling */ + scale: number; + /** + !#en Get the included SkeletonData used in spine runtime.
+ Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.SkeletonData object. + !#zh 获取 Spine Runtime 使用的 SkeletonData。
+ 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.SkeletonData 对象。 + @param quiet quiet + */ + getRuntimeData(quiet?: boolean): sp.spine.SkeletonData; + } + /** !#en The event type of spine skeleton animation. + !#zh 骨骼动画事件类型。 */ + export enum AnimationEventType { + START = 0, + END = 0, + COMPLETE = 0, + EVENT = 0, + } +} + +/** !#en +`sp.spine` is the namespace for official Spine Runtime, which officially implemented and maintained by Spine.
+Please refer to the official documentation for its detailed usage: [http://en.esotericsoftware.com/spine-using-runtimes](http://en.esotericsoftware.com/spine-using-runtimes) +!#zh +sp.spine 模块是 Spine 官方运行库的 API 入口,由 Spine 官方统一实现和维护,具体用法请参考:[http://zh.esotericsoftware.com/spine-using-runtimes](http://zh.esotericsoftware.com/spine-using-runtimes) */ +declare module sp.spine { +} + +/** !#en Some JavaScript decorators which can be accessed with "cc._decorator". +!#zh 一些 JavaScript 装饰器,目前可以通过 "cc._decorator" 来访问。 +(这些 API 仍不完全稳定,有可能随着 JavaScript 装饰器的标准实现而调整) */ +declare module cc._decorator { + /** + !#en + Declare the standard [ES6 Class](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes) + as CCClass, please see [Class](/docs/editors_and_tools/creator-chapters/scripting/class/) for details. + !#zh + 将标准写法的 [ES6 Class](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes) 声明为 CCClass,具体用法请参阅[类型定义](/docs/creator/scripting/class/)。 + @param name The class name used for serialization. + + @example + ```js + const {ccclass} = cc._decorator; + + // define a CCClass, omit the name + @ccclass + class NewScript extends cc.Component { + // ... + } + + // define a CCClass with a name + @ccclass('LoginData') + class LoginData { + // ... + } + ``` + */ + export function ccclass(name?: string): Function; + export function ccclass(_class?: Function): void; + /** + !#en + Declare property for [CCClass](/docs/editors_and_tools/creator-chapters/scripting/class/). + !#zh + 定义 [CCClass](/docs/creator/scripting/class/) 所用的属性。 + @param options an object with some property attributes + + @example + ```js + const {ccclass, property} = cc._decorator; + + @ccclass + class NewScript extends cc.Component { + @property({ + type: cc.Node + }) + targetNode1 = null; + + @property(cc.Node) + targetNode2 = null; + + @property(cc.Button) + targetButton = null; + + @property + _width = 100; + + @property + get width () { + return this._width; + } + + @property + set width (value) { + this._width = value; + } + + @property + offset = new cc.Vec2(100, 100); + + @property(cc.Vec2) + offsets = []; + + @property(cc.Texture2D) + texture = ""; + } + + // above is equivalent to (上面的代码相当于): + + var NewScript = cc.Class({ + properties: { + targetNode1: { + default: null, + type: cc.Node + }, + + targetNode2: { + default: null, + type: cc.Node + }, + + targetButton: { + default: null, + type: cc.Button + }, + + _width: 100, + + width: { + get () { + return this._width; + }, + set (value) { + this._width = value; + } + }, + + offset: new cc.Vec2(100, 100) + + offsets: { + default: [], + type: cc.Vec2 + } + + texture: { + default: "", + url: cc.Texture2D + }, + } + }); + ``` + */ + export function property(options?: {type?: any; url?: typeof cc.RawAsset; visible?: boolean|(() => boolean); displayName?: string; tooltip?: string; multiline?: boolean; readonly?: boolean; min?: number; max?: number; step?: number; range?: number[]; slide?: boolean; serializable?: boolean; formerlySerializedAs?: string; editorOnly?: boolean; override?: boolean; animatable?: boolean} | any[]|Function|cc.ValueType|number|string|boolean): Function; + export function property(_target: Object, _key: any, _desc?: any): void; + /** + !#en + Makes a CCClass that inherit from component execute in edit mode.
+ By default, all components are only executed in play mode, + which means they will not have their callback functions executed while the Editor is in edit mode. + !#zh + 允许继承自 Component 的 CCClass 在编辑器里执行。
+ 默认情况下,所有 Component 都只会在运行时才会执行,也就是说它们的生命周期回调不会在编辑器里触发。 + + @example + ```js + const {ccclass, executeInEditMode} = cc._decorator; + + @ccclass + @executeInEditMode + class NewScript extends cc.Component { + // ... + } + ``` + */ + export function executeInEditMode(): Function; + export function executeInEditMode(_class: Function): void; + /** + !#en + Automatically add required component as a dependency for the CCClass that inherit from component. + !#zh + 为声明为 CCClass 的组件添加依赖的其它组件。当组件添加到节点上时,如果依赖的组件不存在,引擎将会自动将依赖组件添加到同一个节点,防止脚本出错。该设置在运行时同样有效。 + @param requiredComponent requiredComponent + + @example + ```js + const {ccclass, requireComponent} = cc._decorator; + + @ccclass + @requireComponent(cc.Sprite) + class SpriteCtrl extends cc.Component { + // ... + } + ``` + */ + export function requireComponent(requiredComponent: typeof cc.Component): Function; + /** + !#en + The menu path to register a component to the editors "Component" menu. Eg. "Rendering/CameraCtrl". + !#zh + 将当前组件添加到组件菜单中,方便用户查找。例如 "Rendering/CameraCtrl"。 + @param path The path is the menu represented like a pathname. + For example the menu could be "Rendering/CameraCtrl". + + @example + ```js + const {ccclass, menu} = cc._decorator; + + @ccclass + @menu("Rendering/CameraCtrl") + class NewScript extends cc.Component { + // ... + } + ``` + */ + export function menu(path: string): Function; + /** + !#en + The execution order of lifecycle methods for Component. + Those less than 0 will execute before while those greater than 0 will execute after. + The order will only affect onLoad, onEnable, start, update and lateUpdate while onDisable and onDestroy will not be affected. + !#zh + 设置脚本生命周期方法调用的优先级。优先级小于 0 的组件将会优先执行,优先级大于 0 的组件将会延后执行。优先级仅会影响 onLoad, onEnable, start, update 和 lateUpdate,而 onDisable 和 onDestroy 不受影响。 + @param order The execution order of lifecycle methods for Component. Those less than 0 will execute before while those greater than 0 will execute after. + + @example + ```js + const {ccclass, executionOrder} = cc._decorator; + + @ccclass + @executionOrder(1) + class CameraCtrl extends cc.Component { + // ... + } + ``` + */ + export function executionOrder(order: number): Function; + /** + !#en + Prevents Component of the same type (or subtype) to be added more than once to a Node. + !#zh + 防止多个相同类型(或子类型)的组件被添加到同一个节点。 + + @example + ```js + const {ccclass, disallowMultiple} = cc._decorator; + + @ccclass + @disallowMultiple + class CameraCtrl extends cc.Component { + // ... + } + ``` + */ + export function disallowMultiple(): Function; + export function disallowMultiple(_class: Function): void; + /** + !#en + If specified, the editor's scene view will keep updating this node in 60 fps when it is selected, otherwise, it will update only if necessary.
+ This property is only available if executeInEditMode is true. + !#zh + 当指定了 "executeInEditMode" 以后,playOnFocus 可以在选中当前组件所在的节点时,提高编辑器的场景刷新频率到 60 FPS,否则场景就只会在必要的时候进行重绘。 + + @example + ```js + const {ccclass, playOnFocus, executeInEditMode} = cc._decorator; + + @ccclass + @executeInEditMode + @playOnFocus + class CameraCtrl extends cc.Component { + // ... + } + ``` + */ + export function playOnFocus(): Function; + export function playOnFocus(_class: Function): void; + /** + !#en + Specifying the url of the custom html to draw the component in **Properties**. + !#zh + 自定义当前组件在 **属性检查器** 中渲染时所用的网页 url。 + @param url url + + @example + ```js + const {ccclass, inspector} = cc._decorator; + + @ccclass + @inspector("packages://inspector/inspectors/comps/camera-ctrl.js") + class NewScript extends cc.Component { + // ... + } + ``` + */ + export function inspector(path: string): Function; + /** + !#en + The custom documentation URL. + !#zh + 指定当前组件的帮助文档的 url,设置过后,在 **属性检查器** 中就会出现一个帮助图标,用户点击将打开指定的网页。 + @param url url + + @example + ```js + const {ccclass, help} = cc._decorator; + + @ccclass + @help("app://docs/html/components/spine.html") + class NewScript extends cc.Component { + // ... + } + ``` + */ + export function help(path: string): Function; + /** + NOTE:
+ The old mixins implemented in cc.Class(ES5) behaves exact the same as multiple inheritance. + But since ES6, class constructor can't be function-called and class methods become non-enumerable, + so we can not mix in ES6 Classes.
+ See:
+ [https://esdiscuss.org/topic/traits-are-now-impossible-in-es6-until-es7-since-rev32](https://esdiscuss.org/topic/traits-are-now-impossible-in-es6-until-es7-since-rev32)
+ One possible solution (but IDE unfriendly):
+ [http://justinfagnani.com/2015/12/21/real-mixins-with-javascript-classes](http://justinfagnani.com/2015/12/21/real-mixins-with-javascript-classes/)
+
+ NOTE:
+ You must manually call mixins constructor, this is different from cc.Class(ES5). + @param ctor constructors to mix, only support ES5 constructors or classes defined by using `cc.Class`, + not support ES6 Classes. + + @example + ```js + const {ccclass, mixins} = cc._decorator; + + class Animal { ... } + + const Fly = cc.Class({ + constructor () { ... } + }); + + @ccclass + @mixins(cc.EventTarget, Fly) + class Bird extends Animal { + constructor () { + super(); + + // You must manually call mixins constructor, this is different from cc.Class(ES5) + cc.EventTarget.call(this); + Fly.call(this); + } + // ... + } + ``` + */ + export function mixins(ctor: Function, ...rest: Function[]): Function; +} + +/** This module provides some JavaScript utilities. +All members can be accessed with "cc.js". */ +declare module cc.js { + /** + Check the obj whether is number or not + If a number is created by using 'new Number(10086)', the typeof it will be "object"... + Then you can use this function if you care about this case. + @param obj obj + */ + export function isNumber(obj: any): boolean; + /** + Check the obj whether is string or not. + If a string is created by using 'new String("blabla")', the typeof it will be "object"... + Then you can use this function if you care about this case. + @param obj obj + */ + export function isString(obj: any): boolean; + /** + This method is deprecated, use cc.js.mixin please.
+ Copy all properties not defined in obj from arguments[1...n] + @param obj object to extend its properties + @param sourceObj source object to copy properties from + */ + export function addon(obj: any, ...sourceObj: any[]): any; + /** + copy all properties from arguments[1...n] to obj + @param obj obj + @param sourceObj sourceObj + */ + export function mixin(obj: any, ...sourceObj: any[]): any; + /** + Derive the class from the supplied base class. + Both classes are just native javascript constructors, not created by cc.Class, so + usually you will want to inherit using {{#crossLink "cc/Class:method"}}cc.Class {{/crossLink}} instead. + @param cls cls + @param base the baseclass to inherit + */ + export function extend(cls: Function, base: Function): Function; + /** + Get super class + @param ctor the constructor of subclass + */ + export function getSuper(ctor: Function): Function; + /** + Removes all enumerable properties from object + @param obj obj + */ + export function clear(obj: any): void; + /** + Get property descriptor in object and all its ancestors + @param obj obj + @param name name + */ + export function getPropertyDescriptor(obj: any, name: string): any; + /** + Define value, just help to call Object.defineProperty.
+ The configurable will be true. + @param obj obj + @param prop prop + @param value value + @param writable writable + @param enumerable enumerable + */ + export function value(obj: any, prop: string, value: any, writable?: boolean, enumerable?: boolean): void; + /** + Define get set accessor, just help to call Object.defineProperty(...) + @param obj obj + @param prop prop + @param getter getter + @param setter setter + @param enumerable enumerable + */ + export function getset(obj: any, prop: string, getter: Function, setter: Function, enumerable?: boolean): void; + /** + Define get accessor, just help to call Object.defineProperty(...) + @param obj obj + @param prop prop + @param getter getter + @param enumerable enumerable + @param configurable configurable + */ + export function get(obj: any, prop: string, getter: Function, enumerable?: boolean, configurable?: boolean): void; + /** + Define set accessor, just help to call Object.defineProperty(...) + @param obj obj + @param prop prop + @param setter setter + @param enumerable enumerable + @param configurable configurable + */ + export function set(obj: any, prop: string, setter: Function, enumerable?: boolean, configurable?: boolean): void; + /** + Get class name of the object, if object is just a {} (and which class named 'Object'), it will return "". + (modified from the code from this stackoverflow post) + @param objOrCtor instance or constructor + */ + export function getClassName(objOrCtor: any|Function): string; + /** + Register the class by specified name manually + @param className className + @param constructor constructor + */ + export function setClassName(className: string, constructor: Function): void; + /** + Unregister a class from fireball. + + If you dont need a registered class anymore, you should unregister the class so that Fireball will not keep its reference anymore. + Please note that its still your responsibility to free other references to the class. + @param constructor the class you will want to unregister, any number of classes can be added + */ + export function unregisterClass(...constructor: Function[]): void; + /** + Get the registered class by name + @param classname classname + */ + export function getClassByName(classname: string): Function; + /** + Defines a polyfill field for obsoleted codes. + @param obj YourObject or YourClass.prototype + @param obsoleted "OldParam" or "YourClass.OldParam" + @param newPropName "NewParam" + @param writable writable + */ + export function obsolete(obj: any, obsoleted: string, newPropName: string, writable?: boolean): void; + /** + Defines all polyfill fields for obsoleted codes corresponding to the enumerable properties of props. + @param obj YourObject or YourClass.prototype + @param objName "YourObject" or "YourClass" + @param props props + @param writable writable + */ + export function obsoletes(obj: any, objName: any, props: any, writable?: boolean): void; + /** + A string tool to construct a string with format string. + @param msg A JavaScript string containing zero or more substitution strings (%s). + @param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output. + + @example + ```js + cc.js.formatStr("a: %s, b: %s", a, b); + cc.js.formatStr(a, b, c); + ``` + */ + export function formatStr(msg: string|any, ...subst: any[]): string; + /** + !#en + A simple wrapper of `Object.create(null)` which ensures the return object have no prototype (and thus no inherited members). So we can skip `hasOwnProperty` calls on property lookups. It is a worthwhile optimization than the `{}` literal when `hasOwnProperty` calls are necessary. + !#zh + 该方法是对 `Object.create(null)` 的简单封装。`Object.create(null)` 用于创建无 prototype (也就无继承)的空对象。这样我们在该对象上查找属性时,就不用进行 `hasOwnProperty` 判断。在需要频繁判断 `hasOwnProperty` 时,使用这个方法性能会比 `{}` 更高。 + @param forceDictMode Apply the delete operator to newly created map object. This causes V8 to put the object in "dictionary mode" and disables creation of hidden classes which are very expensive for objects that are constantly changing shape. + */ + export function createMap(forceDictMode?: boolean): any; + /** undefined */ + export class array { + /** + Removes the array item at the specified index. + @param array array + @param index index + */ + static removeAt(array: any[], index: number): void; + /** + Removes the array item at the specified index. + It's faster but the order of the array will be changed. + @param array array + @param index index + */ + static fastRemoveAt(array: any[], index: number): void; + /** + Removes the first occurrence of a specific object from the array. + @param array array + @param value value + */ + static remove(array: any[], value: any): boolean; + /** + Removes the first occurrence of a specific object from the array. + It's faster but the order of the array will be changed. + @param array array + @param value value + */ + static fastRemove(array: any[], value: number): void; + /** + Verify array's Type + @param array array + @param type type + */ + static verifyType(array: any[], type: Function): boolean; + /** + Removes from array all values in minusArr. For each Value in minusArr, the first matching instance in array will be removed. + @param array Source Array + @param minusArr minus Array + */ + static removeArray(array: any[], minusArr: any[]): void; + /** + Inserts some objects at index + @param array array + @param addObjs addObjs + @param index index + */ + static appendObjectsAt(array: any[], addObjs: any[], index: number): any[]; + /** + Exact same function as Array.prototype.indexOf.
+ HACK: ugliy hack for Baidu mobile browser compatibility, stupid Baidu guys modify Array.prototype.indexOf for all pages loaded, their version changes strict comparison to non-strict comparison, it also ignores the second parameter of the original API, and this will cause event handler enter infinite loop.
+ Baidu developers, if you ever see this documentation, here is the standard: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf, Seriously! + @param searchElement Element to locate in the array. + @param fromIndex The index to start the search at + */ + static indexOf(searchElement: any, fromIndex?: number): number; + /** + Determines whether the array contains a specific value. + @param array array + @param value value + */ + static contains(array: any[], value: any): boolean; + /** + Copy an array's item to a new array (its performance is better than Array.slice) + @param array array + */ + static copy(array: any[]): any[]; + } + /** !#en + A fixed-length object pool designed for general type.
+ The implementation of this object pool is very simple, + it can helps you to improve your game performance for objects which need frequent release and recreate operations
+ !#zh + 长度固定的对象缓存池,可以用来缓存各种对象类型。
+ 这个对象池的实现非常精简,它可以帮助您提高游戏性能,适用于优化对象的反复创建和销毁。 */ + export class Pool { + /** + !#en + Constructor for creating an object pool for the specific object type. + You can pass a callback argument for process the cleanup logic when the object is recycled. + !#zh + 使用构造函数来创建一个指定对象类型的对象池,您可以传递一个回调函数,用于处理对象回收时的清理逻辑。 + @param cleanupFunc the callback method used to process the cleanup logic when the object is recycled. + @param size initializes the length of the array + */ + constructor(cleanupFunc: (obj: any) => void, size: number); + constructor(size: number); + /** + !#en + Get and initialize an object from pool. This method defaults to null and requires the user to implement it. + !#zh + 获取并初始化对象池中的对象。这个方法默认为空,需要用户自己实现。 + @param params parameters to used to initialize the object + */ + get(...params: any[]): any; + /** !#en + The current number of available objects, the default is 0, it will gradually increase with the recycle of the object, + the maximum will not exceed the size specified when the constructor is called. + !#zh + 当前可用对象数量,一开始默认是 0,随着对象的回收会逐渐增大,最大不会超过调用构造函数时指定的 size。 */ + count: number; + /** + !#en + Get an object from pool, if no available object in the pool, null will be returned. + !#zh + 获取对象池中的对象,如果对象池没有可用对象,则返回空。 + */ + _get(): any; + /** + !#en Put an object into the pool. + !#zh 向对象池返还一个不再需要的对象。 + */ + put(): void; + /** + !#en Resize the pool. + !#zh 设置对象池容量。 + */ + resize(): void; + } +} +declare namespace dragonBones { + /** + * @private + */ + const enum ArmatureType { + Armature = 0, + MovieClip = 1, + Stage = 2, + } + /** + * @private + */ + const enum DisplayType { + Image = 0, + Armature = 1, + Mesh = 2, + } + /** + * @private + */ + const enum ExtensionType { + FFD = 0, + AdjustColor = 10, + BevelFilter = 11, + BlurFilter = 12, + DropShadowFilter = 13, + GlowFilter = 14, + GradientBevelFilter = 15, + GradientGlowFilter = 16, + } + /** + * @private + */ + const enum EventType { + Frame = 10, + Sound = 11, + } + /** + * @private + */ + const enum ActionType { + Play = 0, + Stop = 1, + GotoAndPlay = 2, + GotoAndStop = 3, + FadeIn = 4, + FadeOut = 5, + } + /** + * @private + */ + const enum BlendMode { + Normal = 0, + Add = 1, + Alpha = 2, + Darken = 3, + Difference = 4, + Erase = 5, + HardLight = 6, + Invert = 7, + Layer = 8, + Lighten = 9, + Multiply = 10, + Overlay = 11, + Screen = 12, + Subtract = 13, + } + /** + * @private + */ + interface Map { + [key: string]: T; + } + /** + * DragonBones + */ + class DragonBones { + /** + * @private + */ + static PI_D: number; + /** + * @private + */ + static PI_H: number; + /** + * @private + */ + static PI_Q: number; + /** + * @private + */ + static ANGLE_TO_RADIAN: number; + /** + * @private + */ + static RADIAN_TO_ANGLE: number; + /** + * @private + */ + static SECOND_TO_MILLISECOND: number; + static VERSION: string; + /** + * @private + */ + static debug: boolean; + /** + * @private + */ + static debugDraw: boolean; + } +} +declare namespace dragonBones { + /** + * @language zh_CN + * 基础对象。 + * @version DragonBones 4.5 + */ + abstract class BaseObject { + private static _hashCode; + private static _defaultMaxCount; + private static _maxCountMap; + private static _poolsMap; + private static _returnObject(object); + /** + * @language zh_CN + * 设置每种对象池的最大缓存数量。 + * @param objectConstructor 对象类。 + * @param maxCount 最大缓存数量。 (设置为 0 则不缓存) + * @version DragonBones 4.5 + */ + static setMaxCount(objectConstructor: typeof BaseObject, maxCount: number): void; + /** + * @language zh_CN + * 清除对象池缓存的对象。 + * @param objectConstructor 对象类。 (不设置则清除所有缓存) + * @version DragonBones 4.5 + */ + static clearPool(objectConstructor?: typeof BaseObject): void; + /** + * @language zh_CN + * 从对象池中创建指定对象。 + * @param objectConstructor 对象类。 + * @version DragonBones 4.5 + */ + static borrowObject(objectConstructor: { + new (): T; + }): T; + /** + * @language zh_CN + * 对象的唯一标识。 + * @version DragonBones 4.5 + */ + hashCode: number; + /** + * @private + */ + protected abstract _onClear(): void; + /** + * @language zh_CN + * 清除数据并返还对象池。 + * @version DragonBones 4.5 + */ + returnToPool(): void; + } +} +declare namespace dragonBones { +} +declare namespace dragonBones { + /** + * @language zh_CN + * 动画混合时,使用的淡出方式。 + * @see dragonBones.Animation#fadeIn() + * @version DragonBones 4.5 + */ + const enum AnimationFadeOutMode { + /** + * @language zh_CN + * 不淡出动画。 + * @version DragonBones 4.5 + */ + None = 0, + /** + * @language zh_CN + * 淡出同层的动画。 + * @version DragonBones 4.5 + */ + SameLayer = 1, + /** + * @language zh_CN + * 淡出同组的动画。 + * @version DragonBones 4.5 + */ + SameGroup = 2, + /** + * @language zh_CN + * 淡出同层并且同组的动画。 + * @version DragonBones 4.5 + */ + SameLayerAndGroup = 3, + /** + * @language zh_CN + * 淡出所有动画。 + * @version DragonBones 4.5 + */ + All = 4, + } + /** + * @language zh_CN + * 播放动画组件接口。 (Armature 和 WordClock 都实现了该接口) + * 任何实现了此接口的实例都可以加到 WorldClock 时钟中,由时钟统一控制动画的播放。 + * @see dragonBones.WorldClock + * @see dragonBones.Armature + * @version DragonBones 3.0 + */ + interface IAnimateble { + /** + * @language zh_CN + * 更新一个指定的时间。 + * @param passedTime 前进的时间。 (以秒为单位) + * @version DragonBones 3.0 + */ + advanceTime(passedTime: number): void; + } + /** + * @language zh_CN + * 动画控制器,用来播放动画数据,管理动画状态。 + * @see dragonBones.AnimationData + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + */ + class Animation extends BaseObject { + /** + * @private + */ + private static _sortAnimationState(a, b); + /** + * @private + */ + static toString(): string; + /** + * @language zh_CN + * 动画的播放速度。 [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1 + * @version DragonBones 3.0 + */ + timeScale: number; + /** + * @private + */ + _armature: Armature; + private _isPlaying; + private _time; + private _duration; + private _lastAnimationState; + private _animations; + private _animationNames; + private _animationStates; + /** + * @inheritDoc + */ + protected _onClear(): void; + private _fadeOut(fadeOutTime, layer, group, fadeOutMode, pauseFadeOut); + /** + * @language zh_CN + * 清除所有正在播放的动画状态。 + * @version DragonBones 4.5 + */ + reset(): void; + /** + * @language zh_CN + * 暂停播放动画。 + * @param animationName 动画状态的名称,如果未设置,则暂停所有动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + */ + stop(animationName?: string): void; + /** + * @language zh_CN + * 播放动画。 + * @param animationName 动画数据的名称,如果未设置,则播放默认动画,或将暂停状态切换为播放状态,或重新播放上一个正在播放的动画。 + * @param playTimes 动画需要播放的次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @returns 返回控制这个动画数据的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + */ + play(animationName?: string, playTimes?: number): AnimationState; + /** + * @language zh_CN + * 淡入播放指定名称的动画。 + * @param animationName 动画数据的名称。 + * @param playTimes 循环播放的次数。 [-1: 使用数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @param fadeInTime 淡入的时间。 [-1: 使用数据默认值, [0~N]: N 秒淡入完毕] (以秒为单位) + * @param layer 混合的图层,图层高会优先获取混合权重。 + * @param group 混合的组,用于给动画状态编组,方便混合淡出控制。 + * @param fadeOutMode 淡出的模式。 + * @param additiveBlending 以叠加的形式混合。 + * @param displayControl 是否对显示对象属性可控。 + * @param pauseFadeOut 暂停需要淡出的动画。 + * @param pauseFadeIn 暂停需要淡入的动画,直到淡入结束才开始播放。 + * @returns 返回控制这个动画数据的动画状态。 + * @see dragonBones.AnimationFadeOutMode + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + */ + fadeIn(animationName: string, fadeInTime?: number, playTimes?: number, layer?: number, group?: string, fadeOutMode?: AnimationFadeOutMode, additiveBlending?: boolean, displayControl?: boolean, pauseFadeOut?: boolean, pauseFadeIn?: boolean): AnimationState; + /** + * @language zh_CN + * 指定名称的动画从指定时间开始播放。 + * @param animationName 动画数据的名称。 + * @param time 时间。 (以秒为单位) + * @param playTimes 动画循环播放的次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @param toTime 播放到指定的时间,如果未设置则播放整个动画。 + * @returns 返回控制这个动画数据的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + */ + gotoAndPlayByTime(animationName: string, time?: number, playTimes?: number, toTime?: number): AnimationState; + /** + * @language zh_CN + * 指定名称的动画从指定帧开始播放。 + * @param animationName 动画数据的名称。 + * @param frame 帧。 + * @param playTimes 动画循环播放的次数。[-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @param toFrame 播放到指定的帧,如果未设置则播放整个动画。 + * @returns 返回控制这个动画数据的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + */ + gotoAndPlayByFrame(animationName: string, frame?: number, playTimes?: number, toFrame?: number): AnimationState; + /** + * @language zh_CN + * 指定名称的动画从指定进度开始播放。 + * @param animationName 动画数据的名称。 + * @param progress 进度。 [0~1] + * @param playTimes 动画循环播放的次数。[-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @param toProgress 播放到指定的进度,如果未设置则播放整个动画。 + * @returns 返回控制这个动画数据的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + */ + gotoAndPlayByProgress(animationName: string, progress?: number, playTimes?: number, toProgress?: number): AnimationState; + /** + * @language zh_CN + * 播放指定名称的动画到指定的时间并停止。 + * @param animationName 动画数据的名称。 + * @param time 时间。 (以秒为单位) + * @returns 返回控制这个动画数据的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + */ + gotoAndStopByTime(animationName: string, time?: number): AnimationState; + /** + * @language zh_CN + * 播放指定名称的动画到指定的帧并停止。 + * @param animationName 动画数据的名称。 + * @param frame 帧。 + * @returns 返回控制这个动画数据的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + */ + gotoAndStopByFrame(animationName: string, frame?: number): AnimationState; + /** + * @language zh_CN + * 播放指定名称的动画到指定的进度并停止。 + * @param animationName 动画数据的名称。 + * @param progress 进度。 [0~1] + * @returns 返回控制这个动画数据的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + */ + gotoAndStopByProgress(animationName: string, progress?: number): AnimationState; + /** + * @language zh_CN + * 获取指定名称的动画状态。 + * @param animationName 动画状态的名称。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + */ + getState(animationName: string): AnimationState; + /** + * @language zh_CN + * 是否包含指定名称的动画数据。 + * @param animationName 动画数据的名称。 + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + */ + hasAnimation(animationName: string): boolean; + /** + * @language zh_CN + * 动画是否处于播放状态。 + * @version DragonBones 3.0 + */ + isPlaying: boolean; + /** + * @language zh_CN + * 所有动画状态是否均已播放完毕。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + */ + isCompleted: boolean; + /** + * @language zh_CN + * 上一个正在播放的动画状态的名称。 + * @see #lastAnimationState + * @version DragonBones 3.0 + */ + lastAnimationName: string; + /** + * @language zh_CN + * 上一个正在播放的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + */ + lastAnimationState: AnimationState; + /** + * @language zh_CN + * 所有动画数据名称。 + * @see #animations + * @version DragonBones 4.5 + */ + animationNames: Array; + /** + * @language zh_CN + * 所有的动画数据。 + * @see dragonBones.AnimationData + * @version DragonBones 4.5 + */ + animations: Map; + /** + * @deprecated + * @see #play() + * @see #fadeIn() + * @see #gotoAndPlayByTime() + * @see #gotoAndPlayByFrame() + * @see #gotoAndPlayByProgress() + */ + gotoAndPlay(animationName: string, fadeInTime?: number, duration?: number, playTimes?: number, layer?: number, group?: string, fadeOutMode?: AnimationFadeOutMode, pauseFadeOut?: boolean, pauseFadeIn?: boolean): AnimationState; + /** + * @deprecated + * @see #gotoAndStopByTime() + * @see #gotoAndStopByFrame() + * @see #gotoAndStopByProgress() + */ + gotoAndStop(animationName: string, time?: number): AnimationState; + /** + * @deprecated + * @see #animationNames + * @see #animations + */ + animationList: Array; + /** + * @language zh_CN + * @deprecated + * @see #animationNames + * @see #animations + */ + animationDataList: Array; + } +} +declare namespace dragonBones { + /** + * @language zh_CN + * 动画状态,播放动画时产生,可以对单个动画的播放进行更细致的控制和调节。 + * @see dragonBones.Animation + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + */ + class AnimationState extends BaseObject { + /** + * @private + */ + static stateActionEnabled: boolean; + /** + * @private + */ + static toString(): string; + /** + * @language zh_CN + * 是否对插槽的颜色,显示序列索引,深度排序,行为等拥有控制的权限。 + * @see dragonBones.Slot#displayController + * @version DragonBones 3.0 + */ + displayControl: boolean; + /** + * @language zh_CN + * 是否以叠加的方式混合动画。 + * @version DragonBones 3.0 + */ + additiveBlending: boolean; + /** + * @private + */ + actionEnabled: boolean; + /** + * @language zh_CN + * 需要播放的次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次] + * @version DragonBones 3.0 + */ + playTimes: number; + /** + * @language zh_CN + * 播放速度。 [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1 + * @version DragonBones 3.0 + */ + timeScale: number; + /** + * @language zh_CN + * 进行动画混合时的权重。 + * @default 1 + * @version DragonBones 3.0 + */ + weight: number; + /** + * @language zh_CN + * 自动淡出时需要的时间,当设置一个大于等于 0 的值,动画状态将会在播放完成后自动淡出。 (以秒为单位) + * @default -1 + * @version DragonBones 3.0 + */ + autoFadeOutTime: number; + /** + * @private + */ + fadeTotalTime: number; + /** + * @private + */ + private _isPlaying; + /** + * @private + */ + private _isPausePlayhead; + /** + * @private + */ + private _fadeTime; + /** + * @private + */ + private _time; + /** + * @private + */ + private _name; + /** + * @private + */ + private _armature; + /** + * @private + */ + private _animationData; + /** + * @private + */ + private _zOrderTimeline; + /** + * @private + */ + private _boneMask; + /** + * @private + */ + private _boneTimelines; + /** + * @private + */ + private _slotTimelines; + /** + * @private + */ + private _ffdTimelines; + /** + * @inheritDoc + */ + protected _onClear(): void; + private _updateTimelineStates(); + private _advanceFadeTime(passedTime); + /** + * @language zh_CN + * 继续播放。 + * @version DragonBones 3.0 + */ + play(): void; + /** + * @language zh_CN + * 暂停播放。 + * @version DragonBones 3.0 + */ + stop(): void; + /** + * @language zh_CN + * 淡出动画。 + * @param fadeOutTime 淡出时间。 (以秒为单位) + * @param pausePlayhead 淡出时是否暂停动画。 [true: 暂停, false: 不暂停] + * @version DragonBones 3.0 + */ + fadeOut(fadeOutTime: number, pausePlayhead?: boolean): void; + /** + * @language zh_CN + * 是否包含指定的骨骼遮罩。 + * @param name 指定的骨骼名称。 + * @version DragonBones 3.0 + */ + containsBoneMask(name: string): boolean; + /** + * @language zh_CN + * 添加指定的骨骼遮罩。 + * @param boneName 指定的骨骼名称。 + * @param recursive 是否为该骨骼的子骨骼添加遮罩。 + * @version DragonBones 3.0 + */ + addBoneMask(name: string, recursive?: boolean): void; + /** + * @language zh_CN + * 删除指定的骨骼遮罩。 + * @param boneName 指定的骨骼名称。 + * @param recursive 是否删除该骨骼的子骨骼遮罩。 + * @version DragonBones 3.0 + */ + removeBoneMask(name: string, recursive?: boolean): void; + /** + * @language zh_CN + * 删除所有骨骼遮罩。 + * @version DragonBones 3.0 + */ + removeAllBoneMask(): void; + /** + * @language zh_CN + * 动画图层。 + * @see dragonBones.Animation#fadeIn() + * @version DragonBones 3.0 + */ + layer: number; + /** + * @language zh_CN + * 动画组。 + * @see dragonBones.Animation#fadeIn() + * @version DragonBones 3.0 + */ + group: string; + /** + * @language zh_CN + * 动画名称。 + * @see dragonBones.AnimationData#name + * @version DragonBones 3.0 + */ + name: string; + /** + * @language zh_CN + * 动画数据。 + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + */ + animationData: AnimationData; + /** + * @language zh_CN + * 是否播放完毕。 + * @version DragonBones 3.0 + */ + isCompleted: boolean; + /** + * @language zh_CN + * 是否正在播放。 + * @version DragonBones 3.0 + */ + isPlaying: boolean; + /** + * @language zh_CN + * 当前动画的播放次数。 + * @version DragonBones 3.0 + */ + currentPlayTimes: number; + /** + * @language zh_CN + * 当前动画的总时间。 (以秒为单位) + * @version DragonBones 3.0 + */ + totalTime: number; + /** + * @language zh_CN + * 当前动画的播放时间。 (以秒为单位) + * @version DragonBones 3.0 + */ + currentTime: number; + /** + * @deprecated + */ + autoTween: boolean; + /** + * @deprecated + * @see #animationData + */ + clip: AnimationData; + } +} +declare namespace dragonBones { +} +declare namespace dragonBones { + /** + * @language zh_CN + * WorldClock 提供时钟的支持,为每个加入到时钟的 IAnimatable 对象更新时间。 + * @see dragonBones.IAnimatable + * @see dragonBones.Armature + * @version DragonBones 3.0 + */ + class WorldClock implements IAnimateble { + private static _clock; + /** + * @language zh_CN + * 一个可以直接使用的全局 WorldClock 实例. + * @version DragonBones 3.0 + */ + static clock: WorldClock; + /** + * @language zh_CN + * 当前的时间。 (以秒为单位) + * @version DragonBones 3.0 + */ + time: number; + /** + * @language zh_CN + * 时间流逝的速度,用于实现动画的变速播放。 [0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1 + * @version DragonBones 3.0 + */ + timeScale: number; + private _animatebles; + /** + * @language zh_CN + * 创建一个新的 WorldClock 实例。 + * 通常并不需要单独创建 WorldClock 的实例,可以直接使用 WorldClock.clock 静态实例。 + * (创建更多独立的 WorldClock 可以更灵活的为需要更新的 IAnimateble 实例分组,实现不同组不同速度的动画播放) + * @version DragonBones 3.0 + */ + constructor(); + /** + * @language zh_CN + * 为所有的 IAnimatable 实例向前播放一个指定的时间。 (通常这个方法需要在 ENTER_FRAME 事件的响应函数中被调用) + * @param passedTime 前进的时间。 (以秒为单位,当设置为 -1 时将自动计算当前帧与上一帧的时间差) + * @version DragonBones 3.0 + */ + advanceTime(passedTime: number): void; + /** + * 是否包含指定的 IAnimatable 实例 + * @param value 指定的 IAnimatable 实例。 + * @returns [true: 包含,false: 不包含]。 + * @version DragonBones 3.0 + */ + contains(value: IAnimateble): boolean; + /** + * @language zh_CN + * 添加指定的 IAnimatable 实例。 + * @param value IAnimatable 实例。 + * @version DragonBones 3.0 + */ + add(value: IAnimateble): void; + /** + * @language zh_CN + * 移除指定的 IAnimatable 实例。 + * @param value IAnimatable 实例。 + * @version DragonBones 3.0 + */ + remove(value: IAnimateble): void; + /** + * @language zh_CN + * 清除所有的 IAnimatable 实例。 + * @version DragonBones 3.0 + */ + clear(): void; + } +} +declare namespace dragonBones { + /** + * @language zh_CN + * 基础变换对象。 + * @version DragonBones 4.5 + */ + abstract class TransformObject extends BaseObject { + /** + * @language zh_CN + * 可以用于存储临时数据。 + * @version DragonBones 3.0 + */ + userData: any; + /** + * @language zh_CN + * 对象的名称。 + * @version DragonBones 3.0 + */ + name: string; + /** + * @language zh_CN + * 相对于骨架坐标系的矩阵。 + * @version DragonBones 3.0 + */ + globalTransformMatrix: Matrix; + /** + * @language zh_CN + * 相对于骨架坐标系的变换。 + * @see dragonBones.Transform + * @version DragonBones 3.0 + */ + global: Transform; + /** + * @language zh_CN + * 相对于骨架或父骨骼坐标系的绑定变换。 + * @see dragonBones.Transform + * @version DragonBones 3.0 + */ + origin: Transform; + /** + * @language zh_CN + * 相对于骨架或父骨骼坐标系的偏移变换。 + * @see dragonBones.Transform + * @version DragonBones 3.0 + */ + offset: Transform; + /** + * @private + */ + _armature: Armature; + /** + * @private + */ + _parent: Bone; + /** + * @private + */ + protected _globalTransformMatrix: Matrix; + /** + * @inheritDoc + */ + protected _onClear(): void; + /** + * @language zh_CN + * 所属的骨架。 + * @see dragonBones.Armature + * @version DragonBones 3.0 + */ + armature: Armature; + /** + * @language zh_CN + * 所属的父骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + */ + parent: Bone; + } +} +declare namespace dragonBones { + /** + * @language zh_CN + * 骨架,是骨骼动画系统的核心,由显示容器、骨骼、插槽、动画、事件系统构成。 + * @see dragonBones.ArmatureData + * @see dragonBones.Bone + * @see dragonBones.Slot + * @see dragonBones.Animation + * @see dragonBones.IArmatureDisplay + * @version DragonBones 3.0 + */ + class Armature extends BaseObject implements IAnimateble { + /** + * @private + */ + static toString(): string; + private static _onSortSlots(a, b); + /** + * @language zh_CN + * 可以用于存储临时数据。 + * @version DragonBones 3.0 + */ + userData: any; + /** + * @private + */ + _cacheFrameIndex: number; + /** + * @private + */ + _armatureData: ArmatureData; + /** + * @private + */ + _skinData: SkinData; + /** + * @private + */ + _animation: Animation; + /** + * @private + */ + _display: IArmatureDisplay; + /** + * @private + */ + _eventManager: IEventDispatcher; + private _delayDispose; + private _lockDispose; + private _slotsDirty; + private _replacedTexture; + private _bones; + private _slots; + private _actions; + private _events; + /** + * @inheritDoc + */ + protected _onClear(): void; + private _sortBones(); + private _sortSlots(); + private _doAction(value); + /** + * @private + */ + _sortZOrder(slotIndices: Array): void; + /** + * @private + */ + _bufferAction(value: ActionData): void; + /** + * @language zh_CN + * 释放骨架。 (会回收到内存池) + * @version DragonBones 3.0 + */ + dispose(): void; + /** + * @language zh_CN + * 更新骨架和动画。 (可以使用时钟实例或显示容器来更新) + * @param passedTime 两帧之前的时间间隔。 (以秒为单位) + * @see dragonBones.IAnimateble + * @see dragonBones.WorldClock + * @see dragonBones.IArmatureDisplay + * @version DragonBones 3.0 + */ + advanceTime(passedTime: number): void; + /** + * @language zh_CN + * 更新骨骼和插槽的变换。 (当骨骼没有动画状态或动画状态播放完成时,骨骼将不在更新) + * @param boneName 指定的骨骼名称,如果未设置,将更新所有骨骼。 + * @param updateSlotDisplay 是否更新插槽的显示对象。 + * @see dragonBones.Bone + * @see dragonBones.Slot + * @version DragonBones 3.0 + */ + invalidUpdate(boneName?: string, updateSlotDisplay?: boolean): void; + /** + * @language zh_CN + * 获取指定名称的骨骼。 + * @param name 骨骼的名称。 + * @returns 骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + */ + getBone(name: string): Bone; + /** + * @language zh_CN + * 通过显示对象获取骨骼。 + * @param display 显示对象。 + * @returns 包含这个显示对象的骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + */ + getBoneByDisplay(display: any): Bone; + /** + * @language zh_CN + * 获取指定名称的插槽。 + * @param name 插槽的名称。 + * @returns 插槽。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + */ + getSlot(name: string): Slot; + /** + * @language zh_CN + * 通过显示对象获取插槽。 + * @param display 显示对象。 + * @returns 包含这个显示对象的插槽。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + */ + getSlotByDisplay(display: any): Slot; + /** + * @language zh_CN + * 替换骨架的主贴图,根据渲染引擎的不同,提供不同的贴图数据。 + * @param texture 贴图。 + * @version DragonBones 4.5 + */ + replaceTexture(texture: any): void; + /** + * @language zh_CN + * 获取所有骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + */ + getBones(): Array; + /** + * @language zh_CN + * 获取所有插槽。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + */ + getSlots(): Array; + /** + * @language zh_CN + * 骨架名称。 + * @see dragonBones.ArmatureData#name + * @version DragonBones 3.0 + */ + name: string; + /** + * @language zh_CN + * 获取骨架数据。 + * @see dragonBones.ArmatureData + * @version DragonBones 4.5 + */ + armatureData: ArmatureData; + /** + * @language zh_CN + * 获得动画控制器。 + * @see dragonBones.Animation + * @version DragonBones 3.0 + */ + animation: Animation; + /** + * @language zh_CN + * 获取显示容器,插槽的显示对象都会以此显示容器为父级,根据渲染平台的不同,类型会不同,通常是 DisplayObjectContainer 类型。 + * @version DragonBones 3.0 + */ + display: IArmatureDisplay | any; + /** + * @language zh_CN + * 获取父插槽。 (当此骨架是某个骨架的子骨架时,可以通过此属性向上查找从属关系) + * @see dragonBones.Slot + * @version DragonBones 4.5 + */ + parent: Slot; + /** + * @language zh_CN + * 动画缓存的帧率,当设置一个大于 0 的帧率时,将会开启动画缓存。 + * 通过将动画数据缓存在内存中来提高运行性能,会有一定的内存开销。 + * 帧率不宜设置的过高,通常跟动画的帧率相当且低于程序运行的帧率。 + * 开启动画缓存后,某些功能将会失效,比如 Bone 和 Slot 的 offset 属性等。 + * @see dragonBones.DragonBonesData#frameRate + * @see dragonBones.ArmatureData#frameRate + * @version DragonBones 4.5 + */ + cacheFrameRate: number; + /** + * @language zh_CN + * 替换骨架的主贴图,根据渲染引擎的不同,提供不同的贴图数据。 + * @version DragonBones 4.5 + */ + replacedTexture: any; + /** + * @language zh_CN + * 开启动画缓存。 + * @param frameRate 动画缓存的帧率 + * @see #cacheFrameRate + * @version DragonBones 4.5 + */ + enableAnimationCache(frameRate: number): void; + /** + * @language zh_CN + * 是否包含指定类型的事件。 + * @param type 事件类型。 + * @returns [true: 包含, false: 不包含] + * @version DragonBones 3.0 + */ + hasEventListener(type: EventStringType): void; + /** + * @language zh_CN + * 添加事件。 + * @param type 事件类型。 + * @param listener 事件回调。 + * @version DragonBones 3.0 + */ + addEventListener(type: EventStringType, listener: Function, target: any): void; + /** + * @language zh_CN + * 移除事件。 + * @param type 事件类型。 + * @param listener 事件回调。 + * @version DragonBones 3.0 + */ + removeEventListener(type: EventStringType, listener: Function, target: any): void; + /** + * @deprecated + */ + addBone(value: Bone, parentName?: string): void; + /** + * @deprecated + */ + addSlot(value: Slot, parentName: string): void; + /** + * @deprecated + */ + removeBone(value: Bone): void; + /** + * @deprecated + */ + removeSlot(value: Slot): void; + /** + * @deprecated + * @see #display + */ + getDisplay(): any; + /** + * @deprecated + * @see #cacheFrameRate + */ + enableCache: boolean; + } +} +declare namespace dragonBones { + /** + * @language zh_CN + * 骨骼,一个骨架中可以包含多个骨骼,骨骼以树状结构组成骨架。 + * 骨骼在骨骼动画体系中是最重要的逻辑单元之一,负责动画中的平移旋转缩放的实现。 + * @see dragonBones.BoneData + * @see dragonBones.Armature + * @see dragonBones.Slot + * @version DragonBones 3.0 + */ + class Bone extends TransformObject { + /** + * @private + */ + static toString(): string; + /** + * @language zh_CN + * 是否继承父骨骼的平移。 [true: 继承, false: 不继承] + * @version DragonBones 3.0 + */ + inheritTranslation: boolean; + /** + * @language zh_CN + * 是否继承父骨骼的旋转。 [true: 继承, false: 不继承] + * @version DragonBones 3.0 + */ + inheritRotation: boolean; + /** + * @language zh_CN + * 是否继承父骨骼的缩放。 [true: 继承, false: 不继承] + * @version DragonBones 4.5 + */ + inheritScale: boolean; + /** + * @language zh_CN + * IK 约束时骨骼方向是否为顺时针方向。 [true: 顺时针, false: 逆时针] + * @version DragonBones 4.5 + */ + ikBendPositive: boolean; + /** + * @language zh_CN + * IK 约束的权重。 + * @version DragonBones 4.5 + */ + ikWeight: number; + /** + * @language zh_CN + * 骨骼长度。 + * @version DragonBones 4.5 + */ + length: number; + /** + * @private + */ + private _visible; + /** + * @private + */ + private _ikChain; + /** + * @private + */ + private _ikChainIndex; + /** + * @private + */ + private _ik; + /** + * @private + */ + private _bones; + /** + * @private + */ + private _slots; + /** + * @inheritDoc + */ + protected _onClear(): void; + /** + * @private + */ + private _updateGlobalTransformMatrix(); + /** + * @private + */ + private _computeIKA(); + /** + * @private + */ + private _computeIKB(); + /** + * @inheritDoc + */ + _setArmature(value: Armature): void; + /** + * @language zh_CN + * 下一帧更新变换。 (当骨骼没有动画状态或动画状态播放完成时,骨骼将不在更新) + * @version DragonBones 3.0 + */ + invalidUpdate(): void; + /** + * @language zh_CN + * 是否包含某个指定的骨骼或插槽。 + * @returns [true: 包含,false: 不包含] + * @see dragonBones.TransformObject + * @version DragonBones 3.0 + */ + contains(child: TransformObject): boolean; + /** + * @language zh_CN + * 所有的子骨骼。 + * @version DragonBones 3.0 + */ + getBones(): Array; + /** + * @language zh_CN + * 所有的插槽。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + */ + getSlots(): Array; + /** + * @private + */ + ikChain: number; + /** + * @private + */ + ikChainIndex: number; + /** + * @language zh_CN + * 当前的 IK 约束目标。 + * @version DragonBones 4.5 + */ + ik: Bone; + /** + * @language zh_CN + * 控制此骨骼所有插槽的显示。 + * @default true + * @see dragonBones.Slot + * @version DragonBones 3.0 + */ + visible: boolean; + /** + * @deprecated + * @see dragonBones.Armature#getSlot() + */ + slot: Slot; + } +} +declare namespace dragonBones { + /** + * @language zh_CN + * 骨架显示容器和事件的接口。 + * @see dragonBones.Armature#display + * @version DragonBones 4.5 + */ + interface IArmatureDisplay extends IEventDispatcher { + /** + * @language zh_CN + * 释放显示对象和骨架。 + * @version DragonBones 4.5 + */ + dispose(): void; + /** + * @language zh_CN + * 获取使用这个显示容器的骨架。 + * @readOnly + * @see dragonBones.Armature + * @version DragonBones 4.5 + */ + armature: Armature; + /** + * @language zh_CN + * 获取使用骨架的动画控制器。 + * @readOnly + * @see dragonBones.Animation + * @version DragonBones 4.5 + */ + animation: Animation; + /** + * @language zh_CN + * 由显示容器来更新骨架和动画。 + * @param on 开启或关闭显示容器对骨架与动画的更新。 + * @version DragonBones 4.5 + */ + advanceTimeBySelf(on: boolean): void; + } +} +declare namespace dragonBones { + /** + * @language zh_CN + * 插槽,附着在骨骼上,控制显示对象的显示状态和属性。 + * 一个骨骼上可以包含多个插槽。 + * 一个插槽中可以包含多个显示对象,同一时间只能显示其中的一个显示对象,但可以在动画播放的过程中切换显示对象实现帧动画。 + * 显示对象可以是普通的图片纹理,也可以是子骨架的显示容器,网格显示对象,还可以是自定义的其他显示对象。 + * @see dragonBones.Armature + * @see dragonBones.Bone + * @see dragonBones.SlotData + * @version DragonBones 3.0 + */ + abstract class Slot extends TransformObject { + private static _helpPoint; + private static _helpMatrix; + /** + * @language zh_CN + * 子骨架是否继承父骨架的动画。 [true: 继承, false: 不继承] + * @default true + * @version DragonBones 4.5 + */ + inheritAnimation: boolean; + /** + * @language zh_CN + * 显示对象受到控制的对象,应设置为动画状态的名称或组名称,设置为 null 则表示受所有的动画状态控制。 + * @default null + * @see dragonBones.AnimationState#displayControl + * @see dragonBones.AnimationState#name + * @see dragonBones.AnimationState#group + * @version DragonBones 4.5 + */ + displayController: string; + /** + * @private + */ + _zOrder: number; + /** + * @private + */ + _pivotX: number; + /** + * @private + */ + _pivotY: number; + /** + * @private + */ + _displayDataSet: SlotDisplayDataSet; + /** + * @private + */ + _meshData: MeshData; + /** + * @private + */ + _childArmature: Armature; + /** + * @private + */ + _rawDisplay: any; + /** + * @private + */ + _meshDisplay: any; + /** + * @private + */ + _cacheFrames: Array; + /** + * @private + */ + _colorTransform: ColorTransform; + /** + * @private + */ + _ffdVertices: Array; + /** + * @private + */ + _replacedDisplayDataSet: Array; + /** + * @private + */ + protected _displayDirty: boolean; + /** + * @private + */ + protected _blendModeDirty: boolean; + /** + * @private + */ + protected _originDirty: boolean; + /** + * @private + */ + protected _transformDirty: boolean; + /** + * @private + */ + protected _displayIndex: number; + /** + * @private + */ + protected _blendMode: BlendMode; + /** + * @private + */ + protected _display: any; + /** + * @private + */ + protected _localMatrix: Matrix; + /** + * @private + */ + protected _displayList: Array; + /** + * @private + */ + protected _meshBones: Array; + /** + * @inheritDoc + */ + protected _onClear(): void; + /** + * @private + */ + protected abstract _initDisplay(value: any): void; + /** + * @private + */ + protected abstract _disposeDisplay(value: any): void; + /** + * @private + */ + protected abstract _onUpdateDisplay(): void; + /** + * @private + */ + protected abstract _addDisplay(): void; + /** + * @private + */ + protected abstract _replaceDisplay(value: any): void; + /** + * @private + */ + protected abstract _removeDisplay(): void; + /** + * @private + */ + protected abstract _updateZOrder(): void; + /** + * @private + */ + protected abstract _updateBlendMode(): void; + /** + * @private + */ + protected abstract _updateColor(): void; + /** + * @private + */ + protected abstract _updateFilters(): void; + /** + * @private + */ + protected abstract _updateFrame(): void; + /** + * @private + */ + protected abstract _updateMesh(): void; + /** + * @private + */ + protected abstract _updateTransform(): void; + private _isMeshBonesUpdate(); + /** + * @private + */ + protected _updatePivot(rawDisplayData: DisplayData, currentDisplayData: DisplayData, currentTextureData: TextureData): void; + /** + * @private + */ + protected _updateDisplay(): void; + /** + * @private + */ + protected _updateLocalTransformMatrix(): void; + /** + * @private + */ + protected _updateGlobalTransformMatrix(): void; + /** + * @private Factory + */ + _setDisplayList(value: Array): boolean; + /** + * @language zh_CN + * 在下一帧更新显示对象的状态。 + * @version DragonBones 4.5 + */ + invalidUpdate(): void; + /** + * @private + */ + rawDisplay: any; + /** + * @private + */ + MeshDisplay: any; + /** + * @language zh_CN + * 此时显示的显示对象在显示列表中的索引。 + * @version DragonBones 4.5 + */ + displayIndex: number; + /** + * @language zh_CN + * 包含显示对象或子骨架的显示列表。 + * @version DragonBones 3.0 + */ + displayList: Array; + /** + * @language zh_CN + * 此时显示的显示对象。 + * @version DragonBones 3.0 + */ + display: any; + /** + * @language zh_CN + * 此时显示的子骨架。 + * @see dragonBones.Armature + * @version DragonBones 3.0 + */ + childArmature: Armature; + /** + * @deprecated + * @see #display + */ + getDisplay(): any; + /** + * @deprecated + * @see #display + */ + setDisplay(value: any): void; + } +} +declare namespace dragonBones { + /** + * @private + */ + type EventStringType = string | "start" | "loopComplete" | "complete" | "fadeIn" | "fadeInComplete" | "fadeOut" | "fadeOutComplete" | "frameEvent" | "soundEvent"; + /** + * @language zh_CN + * 事件接口。 + * @version DragonBones 4.5 + */ + interface IEventDispatcher { + /** + * @language zh_CN + * 是否包含指定类型的事件。 + * @param type 事件类型。 + * @returns [true: 包含, false: 不包含] + * @version DragonBones 4.5 + */ + hasEvent(type: EventStringType): boolean; + /** + * @language zh_CN + * 添加事件。 + * @param type 事件类型。 + * @param listener 事件回调。 + * @version DragonBones 4.5 + */ + addEvent(type: EventStringType, listener: Function, target: any): void; + /** + * @language zh_CN + * 移除事件。 + * @param type 事件类型。 + * @param listener 事件回调。 + * @version DragonBones 4.5 + */ + removeEvent(type: EventStringType, listener: Function, target: any): void; + } + /** + * @language zh_CN + * 事件数据。 + * @version DragonBones 4.5 + */ + class EventObject extends BaseObject { + /** + * @language zh_CN + * 动画开始。 + * @version DragonBones 4.5 + */ + static START: string; + /** + * @language zh_CN + * 动画循环播放一次完成。 + * @version DragonBones 4.5 + */ + static LOOP_COMPLETE: string; + /** + * @language zh_CN + * 动画播放完成。 + * @version DragonBones 4.5 + */ + static COMPLETE: string; + /** + * @language zh_CN + * 动画淡入开始。 + * @version DragonBones 4.5 + */ + static FADE_IN: string; + /** + * @language zh_CN + * 动画淡入完成。 + * @version DragonBones 4.5 + */ + static FADE_IN_COMPLETE: string; + /** + * @language zh_CN + * 动画淡出开始。 + * @version DragonBones 4.5 + */ + static FADE_OUT: string; + /** + * @language zh_CN + * 动画淡出完成。 + * @version DragonBones 4.5 + */ + static FADE_OUT_COMPLETE: string; + /** + * @language zh_CN + * 动画帧事件。 + * @version DragonBones 4.5 + */ + static FRAME_EVENT: string; + /** + * @language zh_CN + * 动画声音事件。 + * @version DragonBones 4.5 + */ + static SOUND_EVENT: string; + /** + * @private + */ + static toString(): string; + /** + * @language zh_CN + * 事件类型。 + * @version DragonBones 4.5 + */ + type: EventStringType; + /** + * @language zh_CN + * 事件名称。 (帧标签的名称或声音的名称) + * @version DragonBones 4.5 + */ + name: string; + /** + * @language zh_CN + * 扩展的数据。 + * @version DragonBones 4.5 + */ + data: any; + /** + * @language zh_CN + * 发出事件的骨架。 + * @version DragonBones 4.5 + */ + armature: Armature; + /** + * @language zh_CN + * 发出事件的骨骼。 + * @version DragonBones 4.5 + */ + bone: Bone; + /** + * @language zh_CN + * 发出事件的插槽。 + * @version DragonBones 4.5 + */ + slot: Slot; + /** + * @language zh_CN + * 发出事件的动画状态。 + * @version DragonBones 4.5 + */ + animationState: AnimationState; + /** + * @private + */ + frame: AnimationFrameData; + /** + * @language zh_CN + * 用户数据。 + * @version DragonBones 4.5 + */ + userData: any; + /** + * @inheritDoc + */ + protected _onClear(): void; + } +} +declare namespace dragonBones { + /** + * @private + */ + class ColorTransform { + alphaMultiplier: number; + redMultiplier: number; + greenMultiplier: number; + blueMultiplier: number; + alphaOffset: number; + redOffset: number; + greenOffset: number; + blueOffset: number; + constructor(alphaMultiplier?: number, redMultiplier?: number, greenMultiplier?: number, blueMultiplier?: number, alphaOffset?: number, redOffset?: number, greenOffset?: number, blueOffset?: number); + copyFrom(value: ColorTransform): void; + identity(): void; + } +} +declare namespace dragonBones { + /** + * @language zh_CN + * 2D 矩阵。 + * @version DragonBones 3.0 + */ + class Matrix { + a: number; + b: number; + c: number; + d: number; + tx: number; + ty: number; + constructor(a?: number, b?: number, c?: number, d?: number, tx?: number, ty?: number); + /** + * @private + */ + toString(): string; + /** + * @language zh_CN + * 复制矩阵。 + * @param value 需要复制的矩阵。 + * @version DragonBones 3.0 + */ + copyFrom(value: Matrix): void; + /** + * @language zh_CN + * 转换为恒等矩阵。 + * @version DragonBones 3.0 + */ + identity(): void; + /** + * @language zh_CN + * 将当前矩阵与另一个矩阵相乘。 + * @param value 需要相乘的矩阵。 + * @version DragonBones 3.0 + */ + concat(value: Matrix): void; + /** + * @language zh_CN + * 转换为逆矩阵。 + * @version DragonBones 3.0 + */ + invert(): void; + /** + * @language zh_CN + * 将矩阵转换应用于指定点。 + * @param x 横坐标。 + * @param y 纵坐标。 + * @param result 应用转换之后的坐标。 + * @params delta 是否忽略 tx,ty 对坐标的转换。 + * @version DragonBones 3.0 + */ + transformPoint(x: number, y: number, result: { + x: number; + y: number; + }, delta?: boolean): void; + } +} +declare namespace dragonBones { + /** + * @private + */ + class Point { + x: number; + y: number; + constructor(x?: number, y?: number); + copyFrom(value: Point): void; + clear(): void; + } +} +declare namespace dragonBones { + /** + * @private + */ + class Rectangle { + x: number; + y: number; + width: number; + height: number; + constructor(x?: number, y?: number, width?: number, height?: number); + copyFrom(value: Rectangle): void; + clear(): void; + } +} +declare namespace dragonBones { + /** + * @language zh_CN + * 2D 变换。 + * @version DragonBones 3.0 + */ + class Transform { + /** + * @language zh_CN + * 水平位移。 + * @version DragonBones 3.0 + */ + x: number; + /** + * @language zh_CN + * 垂直位移。 + * @version DragonBones 3.0 + */ + y: number; + /** + * @language zh_CN + * 水平倾斜。 (以弧度为单位) + * @version DragonBones 3.0 + */ + skewX: number; + /** + * @language zh_CN + * 垂直倾斜。 (以弧度为单位) + * @version DragonBones 3.0 + */ + skewY: number; + /** + * @language zh_CN + * 水平缩放。 + * @version DragonBones 3.0 + */ + scaleX: number; + /** + * @language zh_CN + * 垂直缩放。 + * @version DragonBones 3.0 + */ + scaleY: number; + /** + * @private + */ + static normalizeRadian(value: number): number; + /** + * @private + */ + constructor( + /** + * @language zh_CN + * 水平位移。 + * @version DragonBones 3.0 + */ + x?: number, + /** + * @language zh_CN + * 垂直位移。 + * @version DragonBones 3.0 + */ + y?: number, + /** + * @language zh_CN + * 水平倾斜。 (以弧度为单位) + * @version DragonBones 3.0 + */ + skewX?: number, + /** + * @language zh_CN + * 垂直倾斜。 (以弧度为单位) + * @version DragonBones 3.0 + */ + skewY?: number, + /** + * @language zh_CN + * 水平缩放。 + * @version DragonBones 3.0 + */ + scaleX?: number, + /** + * @language zh_CN + * 垂直缩放。 + * @version DragonBones 3.0 + */ + scaleY?: number); + /** + * @private + */ + toString(): string; + /** + * @private + */ + copyFrom(value: Transform): Transform; + /** + * @private + */ + identity(): Transform; + /** + * @private + */ + add(value: Transform): Transform; + /** + * @private + */ + minus(value: Transform): Transform; + /** + * @private + */ + fromMatrix(matrix: Matrix): Transform; + /** + * @language zh_CN + * 转换为矩阵。 + * @param 矩阵。 + * @version DragonBones 3.0 + */ + toMatrix(matrix: Matrix): Transform; + /** + * @language zh_CN + * 旋转。 (以弧度为单位) + * @version DragonBones 3.0 + */ + rotation: number; + } +} +declare namespace dragonBones { + /** + * @private + */ + abstract class TimelineData> extends BaseObject { + /** + * @private + */ + static toString(): string; + scale: number; + /** + * @private + */ + offset: number; + /** + * @private + */ + frames: Array; + constructor(); + /** + * @inheritDoc + */ + protected _onClear(): void; + } + /** + * @private + */ + class ZOrderTimelineData extends TimelineData { + static toString(): string; + } + /** + * @private + */ + class BoneTimelineData extends TimelineData { + static cacheFrame(cacheFrames: Array, cacheFrameIndex: number, globalTransformMatrix: Matrix): Matrix; + static toString(): string; + bone: BoneData; + originalTransform: Transform; + cachedFrames: Array; + constructor(); + /** + * @inheritDoc + */ + protected _onClear(): void; + cacheFrames(cacheFrameCount: number): void; + } + /** + * @private + */ + class SlotTimelineData extends TimelineData { + static cacheFrame(cacheFrames: Array, cacheFrameIndex: number, globalTransformMatrix: Matrix): Matrix; + static toString(): string; + slot: SlotData; + cachedFrames: Array; + constructor(); + /** + * @inheritDoc + */ + protected _onClear(): void; + cacheFrames(cacheFrameCount: number): void; + } + /** + * @private + */ + class FFDTimelineData extends TimelineData { + static toString(): string; + displayIndex: number; + skin: SkinData; + slot: SlotDisplayDataSet; + constructor(); + /** + * @inheritDoc + */ + protected _onClear(): void; + } +} +declare namespace dragonBones { + /** + * @language zh_CN + * 动画数据。 + * @version DragonBones 3.0 + */ + class AnimationData extends TimelineData { + /** + * @private + */ + static toString(): string; + /** + * @private + */ + hasAsynchronyTimeline: boolean; + /** + * @language zh_CN + * 持续的帧数。 + * @version DragonBones 3.0 + */ + frameCount: number; + /** + * @language zh_CN + * 循环播放的次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次] + * @version DragonBones 3.0 + */ + playTimes: number; + /** + * @language zh_CN + * 开始的时间。 (以秒为单位) + * @version DragonBones 3.0 + */ + position: number; + /** + * @language zh_CN + * 持续的时间。 (以秒为单位) + * @version DragonBones 3.0 + */ + duration: number; + /** + * @language zh_CN + * 淡入混合的时间。 (以秒为单位) + * @version DragonBones 3.0 + */ + fadeInTime: number; + /** + * @private + */ + cacheTimeToFrameScale: number; + /** + * @language zh_CN + * 数据名称。 + * @version DragonBones 3.0 + */ + name: string; + /** + * @private + */ + animation: AnimationData; + /** + * @private + */ + zOrderTimeline: TimelineData; + /** + * @private + */ + boneTimelines: Map; + /** + * @private + */ + slotTimelines: Map; + /** + * @private + */ + ffdTimelines: Map>>; + /** + * @private + */ + cachedFrames: Array; + /** + * @private + */ + constructor(); + /** + * @inheritDoc + */ + protected _onClear(): void; + /** + * @private + */ + cacheFrames(value: number): void; + /** + * @private + */ + addBoneTimeline(value: BoneTimelineData): void; + /** + * @private + */ + addSlotTimeline(value: SlotTimelineData): void; + /** + * @private + */ + addFFDTimeline(value: FFDTimelineData): void; + /** + * @private + */ + getBoneTimeline(name: string): BoneTimelineData; + /** + * @private + */ + getSlotTimeline(name: string): SlotTimelineData; + /** + * @private + */ + getFFDTimeline(skinName: string, slotName: string, displayIndex: number): FFDTimelineData; + } +} +declare namespace dragonBones { + /** + * @language zh_CN + * 骨架数据。 + * @see dragonBones.Armature + * @version DragonBones 3.0 + */ + class ArmatureData extends BaseObject { + private static _onSortSlots(a, b); + /** + * @private + */ + static toString(): string; + /** + * @language zh_CN + * 动画帧率。 + * @version DragonBones 3.0 + */ + frameRate: number; + /** + * @language zh_CN + * 骨架类型。 + * @see dragonBones.ArmatureType + * @version DragonBones 3.0 + */ + type: ArmatureType; + /** + * @language zh_CN + * 数据名称。 + * @version DragonBones 3.0 + */ + name: string; + /** + * @private + */ + parent: DragonBonesData; + /** + * @private + */ + userData: any; + /** + * @private + */ + aabb: Rectangle; + /** + * @language zh_CN + * 所有的骨骼数据。 + * @see dragonBones.BoneData + * @version DragonBones 3.0 + */ + bones: Map; + /** + * @language zh_CN + * 所有的插槽数据。 + * @see dragonBones.SlotData + * @version DragonBones 3.0 + */ + slots: Map; + /** + * @language zh_CN + * 所有的皮肤数据。 + * @see dragonBones.SkinData + * @version DragonBones 3.0 + */ + skins: Map; + /** + * @language zh_CN + * 所有的动画数据。 + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + */ + animations: Map; + /** + * @private + */ + actions: Array; + /** + * @private + */ + cacheFrameRate: number; + /** + * @private + */ + scale: number; + private _boneDirty; + private _slotDirty; + private _defaultSkin; + private _defaultAnimation; + private _sortedBones; + private _sortedSlots; + private _bonesChildren; + /** + * @private + */ + constructor(); + /** + * @inheritDoc + */ + protected _onClear(): void; + private _sortBones(); + private _sortSlots(); + /** + * @private + */ + cacheFrames(value: number): void; + /** + * @private + */ + addBone(value: BoneData, parentName: string): void; + /** + * @private + */ + addSlot(value: SlotData): void; + /** + * @private + */ + addSkin(value: SkinData): void; + /** + * @private + */ + addAnimation(value: AnimationData): void; + /** + * @language zh_CN + * 获取指定名称的骨骼数据。 + * @param name 骨骼数据名称。 + * @see dragonBones.BoneData + * @version DragonBones 3.0 + */ + getBone(name: string): BoneData; + /** + * @language zh_CN + * 获取指定名称的插槽数据。 + * @param name 插槽数据名称。 + * @see dragonBones.SlotData + * @version DragonBones 3.0 + */ + getSlot(name: string): SlotData; + /** + * @language zh_CN + * 获取指定名称的皮肤数据。 + * @param name 皮肤数据名称。 + * @see dragonBones.SkinData + * @version DragonBones 3.0 + */ + getSkin(name: string): SkinData; + /** + * @language zh_CN + * 获取指定名称的动画数据。 + * @param name 动画数据名称。 + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + */ + getAnimation(name: string): AnimationData; + /** + * @private + */ + sortedBones: Array; + /** + * @private + */ + sortedSlots: Array; + /** + * @language zh_CN + * 获取默认的皮肤数据。 + * @see dragonBones.SkinData + * @version DragonBones 4.5 + */ + defaultSkin: SkinData; + /** + * @language zh_CN + * 获取默认的动画数据。 + * @see dragonBones.AnimationData + * @version DragonBones 4.5 + */ + defaultAnimation: AnimationData; + } + /** + * @language zh_CN + * 骨骼数据。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + */ + class BoneData extends BaseObject { + /** + * @private + */ + static toString(): string; + /** + * @private + */ + inheritTranslation: boolean; + /** + * @private + */ + inheritRotation: boolean; + /** + * @private + */ + inheritScale: boolean; + /** + * @private + */ + bendPositive: boolean; + /** + * @private + */ + chain: number; + /** + * @private + */ + chainIndex: number; + /** + * @private + */ + weight: number; + /** + * @private + */ + length: number; + /** + * @language zh_CN + * 数据名称。 + * @version DragonBones 3.0 + */ + name: string; + /** + * @language zh_CN + * 所属的父骨骼数据。 + * @version DragonBones 3.0 + */ + parent: BoneData; + /** + * @private + */ + ik: BoneData; + /** + * @private + */ + transform: Transform; + /** + * @private + */ + constructor(); + /** + * @inheritDoc + */ + protected _onClear(): void; + } + /** + * @language zh_CN + * 插槽数据。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + */ + class SlotData extends BaseObject { + /** + * @private + */ + static DEFAULT_COLOR: ColorTransform; + /** + * @private + */ + static generateColor(): ColorTransform; + /** + * @private + */ + static toString(): string; + /** + * @private + */ + displayIndex: number; + /** + * @private + */ + zOrder: number; + /** + * @private + */ + blendMode: BlendMode; + /** + * @language zh_CN + * 数据名称。 + * @version DragonBones 3.0 + */ + name: string; + /** + * @language zh_CN + * 所属的父骨骼数据。 + * @see dragonBones.BoneData + * @version DragonBones 3.0 + */ + parent: BoneData; + /** + * @private + */ + color: ColorTransform; + /** + * @private + */ + actions: Array; + /** + * @private + */ + constructor(); + /** + * @inheritDoc + */ + protected _onClear(): void; + } + /** + * @language zh_CN + * 皮肤数据。 + * @version DragonBones 3.0 + */ + class SkinData extends BaseObject { + /** + * @private + */ + static toString(): string; + /** + * @language zh_CN + * 数据名称。 + * @version DragonBones 3.0 + */ + name: string; + /** + * @private + */ + slots: Map; + /** + * @private + */ + constructor(); + /** + * @inheritDoc + */ + protected _onClear(): void; + /** + * @private + */ + addSlot(value: SlotDisplayDataSet): void; + /** + * @private + */ + getSlot(name: string): SlotDisplayDataSet; + } + /** + * @private + */ + class SlotDisplayDataSet extends BaseObject { + static toString(): string; + slot: SlotData; + displays: Array; + constructor(); + /** + * @inheritDoc + */ + protected _onClear(): void; + } + /** + * @private + */ + class DisplayData extends BaseObject { + static toString(): string; + isRelativePivot: boolean; + type: DisplayType; + name: string; + texture: TextureData; + armature: ArmatureData; + mesh: MeshData; + pivot: Point; + transform: Transform; + constructor(); + /** + * @inheritDoc + */ + protected _onClear(): void; + } + /** + * @private + */ + class MeshData extends BaseObject { + static toString(): string; + skinned: boolean; + slotPose: Matrix; + uvs: Array; + vertices: Array; + vertexIndices: Array; + boneIndices: Array>; + weights: Array>; + boneVertices: Array>; + bones: Array; + inverseBindPose: Array; + constructor(); + /** + * @inheritDoc + */ + protected _onClear(): void; + } +} +declare namespace dragonBones { + /** + * @language zh_CN + * 龙骨数据,包含多个骨架数据。 + * @see dragonBones.ArmatureData + * @version DragonBones 3.0 + */ + class DragonBonesData extends BaseObject { + /** + * @private + */ + static toString(): string; + /** + * @language zh_CN + * 是否开启共享搜索。 [true: 开启, false: 不开启] + * @default false + * @see dragonBones.ArmatureData + * @version DragonBones 4.5 + */ + autoSearch: boolean; + /** + * @language zh_CN + * 动画帧频。 + * @version DragonBones 3.0 + */ + frameRate: number; + /** + * @language zh_CN + * 数据名称。 + * @version DragonBones 3.0 + */ + name: string; + /** + * @language zh_CN + * 所有的骨架数据。 + * @see dragonBones.ArmatureData + * @version DragonBones 3.0 + */ + armatures: Map; + private _armatureNames; + /** + * @inheritDoc + */ + protected _onClear(): void; + /** + * @language zh_CN + * 获取指定名称的骨架。 + * @param name 骨架数据骨架名称。 + * @see dragonBones.ArmatureData + * @version DragonBones 3.0 + */ + getArmature(name: string): ArmatureData; + /** + * @language zh_CN + * 所有的骨架数据名称。 + * @see #armatures + * @version DragonBones 3.0 + */ + armatureNames: Array; + /** + * @deprecated + * @see dragonBones.BaseFactory#removeDragonBonesData() + */ + dispose(): void; + } +} +declare namespace dragonBones { + /** + * @private + */ + class ActionData extends BaseObject { + static toString(): string; + type: ActionType; + bone: BoneData; + slot: SlotData; + data: Array; + constructor(); + protected _onClear(): void; + } + /** + * @private + */ + class EventData extends BaseObject { + static toString(): string; + type: EventType; + name: string; + data: any; + bone: BoneData; + slot: SlotData; + constructor(); + protected _onClear(): void; + } + /** + * @private + */ + abstract class FrameData extends BaseObject { + position: number; + duration: number; + prev: T; + next: T; + constructor(); + /** + * @inheritDoc + */ + protected _onClear(): void; + } + /** + * @private + */ + abstract class TweenFrameData extends FrameData { + static samplingCurve(curve: Array, frameCount: number): Array; + tweenEasing: number; + curve: Array; + constructor(); + /** + * @inheritDoc + */ + protected _onClear(): void; + } + /** + * @private + */ + class AnimationFrameData extends FrameData { + static toString(): string; + actions: Array; + events: Array; + constructor(); + /** + * @inheritDoc + */ + protected _onClear(): void; + } + /** + * @private + */ + class ZOrderFrameData extends FrameData { + zOrder: Array; + constructor(); + /** + * @inheritDoc + */ + protected _onClear(): void; + } + /** + * @private + */ + class BoneFrameData extends TweenFrameData { + static toString(): string; + tweenScale: boolean; + tweenRotate: number; + guideCurve: Array; + transform: Transform; + constructor(); + /** + * @inheritDoc + */ + protected _onClear(): void; + } + /** + * @private + */ + class SlotFrameData extends TweenFrameData { + static DEFAULT_COLOR: ColorTransform; + static generateColor(): ColorTransform; + static toString(): string; + displayIndex: number; + color: ColorTransform; + constructor(); + /** + * @inheritDoc + */ + protected _onClear(): void; + } + /** + * @private + */ + class ExtensionFrameData extends TweenFrameData { + static toString(): string; + type: ExtensionType; + tweens: Array; + keys: Array; + constructor(); + /** + * @inheritDoc + */ + protected _onClear(): void; + } +} +declare namespace dragonBones { + /** + * @private + */ + abstract class DataParser { + protected static DATA_VERSION_2_3: string; + protected static DATA_VERSION_3_0: string; + protected static DATA_VERSION_4_0: string; + protected static DATA_VERSION: string; + protected static TEXTURE_ATLAS: string; + protected static SUB_TEXTURE: string; + protected static FORMAT: string; + protected static IMAGE_PATH: string; + protected static WIDTH: string; + protected static HEIGHT: string; + protected static ROTATED: string; + protected static FRAME_X: string; + protected static FRAME_Y: string; + protected static FRAME_WIDTH: string; + protected static FRAME_HEIGHT: string; + protected static DRADON_BONES: string; + protected static ARMATURE: string; + protected static BONE: string; + protected static IK: string; + protected static SLOT: string; + protected static SKIN: string; + protected static DISPLAY: string; + protected static ANIMATION: string; + protected static Z_ORDER: string; + protected static FFD: string; + protected static FRAME: string; + protected static PIVOT: string; + protected static TRANSFORM: string; + protected static AABB: string; + protected static COLOR: string; + protected static FILTER: string; + protected static VERSION: string; + protected static IS_GLOBAL: string; + protected static FRAME_RATE: string; + protected static TYPE: string; + protected static NAME: string; + protected static PARENT: string; + protected static LENGTH: string; + protected static DATA: string; + protected static DISPLAY_INDEX: string; + protected static BLEND_MODE: string; + protected static INHERIT_TRANSLATION: string; + protected static INHERIT_ROTATION: string; + protected static INHERIT_SCALE: string; + protected static TARGET: string; + protected static BEND_POSITIVE: string; + protected static CHAIN: string; + protected static WEIGHT: string; + protected static FADE_IN_TIME: string; + protected static PLAY_TIMES: string; + protected static SCALE: string; + protected static OFFSET: string; + protected static POSITION: string; + protected static DURATION: string; + protected static TWEEN_EASING: string; + protected static TWEEN_ROTATE: string; + protected static TWEEN_SCALE: string; + protected static CURVE: string; + protected static GUIDE_CURVE: string; + protected static EVENT: string; + protected static SOUND: string; + protected static ACTION: string; + protected static ACTIONS: string; + protected static DEFAULT_ACTIONS: string; + protected static X: string; + protected static Y: string; + protected static SKEW_X: string; + protected static SKEW_Y: string; + protected static SCALE_X: string; + protected static SCALE_Y: string; + protected static ALPHA_OFFSET: string; + protected static RED_OFFSET: string; + protected static GREEN_OFFSET: string; + protected static BLUE_OFFSET: string; + protected static ALPHA_MULTIPLIER: string; + protected static RED_MULTIPLIER: string; + protected static GREEN_MULTIPLIER: string; + protected static BLUE_MULTIPLIER: string; + protected static UVS: string; + protected static VERTICES: string; + protected static TRIANGLES: string; + protected static WEIGHTS: string; + protected static SLOT_POSE: string; + protected static BONE_POSE: string; + protected static TWEEN: string; + protected static KEY: string; + protected static COLOR_TRANSFORM: string; + protected static TIMELINE: string; + protected static PIVOT_X: string; + protected static PIVOT_Y: string; + protected static Z: string; + protected static LOOP: string; + protected static AUTO_TWEEN: string; + protected static HIDE: string; + protected static _getArmatureType(value: string): ArmatureType; + protected static _getDisplayType(value: string): DisplayType; + protected static _getBlendMode(value: string): BlendMode; + protected static _getActionType(value: string): ActionType; + protected _data: DragonBonesData; + protected _armature: ArmatureData; + protected _skin: SkinData; + protected _slotDisplayDataSet: SlotDisplayDataSet; + protected _mesh: MeshData; + protected _animation: AnimationData; + protected _timeline: any; + protected _isOldData: boolean; + protected _isGlobalTransform: boolean; + protected _isAutoTween: boolean; + protected _animationTweenEasing: number; + protected _timelinePivot: Point; + protected _helpPoint: Point; + protected _helpTransformA: Transform; + protected _helpTransformB: Transform; + protected _helpMatrix: Matrix; + protected _rawBones: Array; + constructor(); + /** + * @private + */ + abstract parseDragonBonesData(rawData: any, scale: number): DragonBonesData; + /** + * @private + */ + abstract parseTextureAtlasData(rawData: any, textureAtlasData: TextureAtlasData, scale: number): void; + private _getTimelineFrameMatrix(animation, timeline, position, transform); + protected _globalToLocal(armature: ArmatureData): void; + protected _mergeFrameToAnimationTimeline(framePostion: number, actions: Array, events: Array): void; + /** + * @deprecated + * @see dragonBones.BaseFactory#parseDragonBonesData() + */ + static parseDragonBonesData(rawData: any): DragonBonesData; + /** + * @deprecated + * @see dragonBones.BaseFactory#parsetTextureAtlasData() + */ + static parseTextureAtlasData(rawData: any, scale?: number): any; + } +} +declare namespace dragonBones { + /** + * @private + */ + class ObjectDataParser extends DataParser { + /** + * @private + */ + protected static _getBoolean(rawData: any, key: string, defaultValue: boolean): boolean; + /** + * @private + */ + protected static _getNumber(rawData: any, key: string, defaultValue: number): number; + /** + * @private + */ + protected static _getString(rawData: any, key: string, defaultValue: string): string; + /** + * @private + */ + protected static _getParameter(rawData: Array, index: number, defaultValue: any): any; + /** + * @private + */ + constructor(); + /** + * @private + */ + protected _parseArmature(rawData: any, scale: number): ArmatureData; + /** + * @private + */ + protected _parseBone(rawData: any): BoneData; + /** + * @private + */ + protected _parseIK(rawData: any): void; + /** + * @private + */ + protected _parseSlot(rawData: any, zOrder: number): SlotData; + /** + * @private + */ + protected _parseSkin(rawData: any): SkinData; + /** + * @private + */ + protected _parseSlotDisplaySet(rawData: any): SlotDisplayDataSet; + /** + * @private + */ + protected _parseDisplay(rawData: any): DisplayData; + /** + * @private + */ + protected _parseMesh(rawData: any): MeshData; + /** + * @private + */ + protected _parseAnimation(rawData: any): AnimationData; + /** + * @private + */ + protected _parseBoneTimeline(rawData: any): BoneTimelineData; + /** + * @private + */ + protected _parseSlotTimeline(rawData: any): SlotTimelineData; + /** + * @private + */ + protected _parseFFDTimeline(rawData: any): FFDTimelineData; + /** + * @private + */ + protected _parseAnimationFrame(rawData: any, frameStart: number, frameCount: number): AnimationFrameData; + /** + * @private + */ + protected _parseZOrderFrame(rawData: any, frameStart: number, frameCount: number): ZOrderFrameData; + /** + * @private + */ + protected _parseBoneFrame(rawData: Object, frameStart: number, frameCount: number): BoneFrameData; + /** + * @private + */ + protected _parseSlotFrame(rawData: any, frameStart: number, frameCount: number): SlotFrameData; + /** + * @private + */ + protected _parseFFDFrame(rawData: any, frameStart: number, frameCount: number): ExtensionFrameData; + /** + * @private + */ + protected _parseTweenFrame>(rawData: any, frame: T, frameStart: number, frameCount: number): void; + /** + * @private + */ + protected _parseFrame>(rawData: any, frame: T, frameStart: number, frameCount: number): void; + /** + * @private + */ + protected _parseTimeline>(rawData: Object, timeline: TimelineData, frameParser: (rawData: any, frameStart: number, frameCount: number) => T): void; + /** + * @private + */ + protected _parseActionData(rawData: any, actions: Array, bone: BoneData, slot: SlotData): void; + /** + * @private + */ + protected _parseEventData(rawData: any, events: Array, bone: BoneData, slot: SlotData): void; + /** + * @private + */ + protected _parseTransform(rawData: Object, transform: Transform): void; + /** + * @private + */ + protected _parseColorTransform(rawData: Object, color: ColorTransform): void; + /** + * @inheritDoc + */ + parseDragonBonesData(rawData: any, scale?: number): DragonBonesData; + /** + * @inheritDoc + */ + parseTextureAtlasData(rawData: any, textureAtlasData: TextureAtlasData, scale?: number): void; + /** + * @private + */ + private static _instance; + /** + * @deprecated + * @see dragonBones.BaseFactory#parseDragonBonesData() + */ + static getInstance(): ObjectDataParser; + } +} +declare namespace dragonBones { + /** + * @language zh_CN + * 贴图集数据。 + * @version DragonBones 3.0 + */ + abstract class TextureAtlasData extends BaseObject { + /** + * @language zh_CN + * 是否开启共享搜索。 [true: 开启, false: 不开启] + * @default false + * @version DragonBones 4.5 + */ + autoSearch: boolean; + /** + * @language zh_CN + * 贴图集缩放系数。 + * @version DragonBones 3.0 + */ + scale: number; + /** + * @language zh_CN + * 贴图集名称。 + * @version DragonBones 3.0 + */ + name: string; + /** + * @language zh_CN + * 贴图集图片路径。 + * @version DragonBones 3.0 + */ + imagePath: string; + /** + * @inheritDoc + */ + protected _onClear(): void; + /** + * @private + */ + getTexture(name: string): TextureData; + } + /** + * @private + */ + abstract class TextureData extends BaseObject { + static generateRectangle(): Rectangle; + rotated: boolean; + name: string; + frame: Rectangle; + parent: TextureAtlasData; + region: Rectangle; + constructor(); + /** + * @inheritDoc + */ + protected _onClear(): void; + } +} +declare namespace dragonBones { + /** + * @private + */ + type BuildArmaturePackage = { + dataName?: string; + textureAtlasName?: string; + data?: DragonBonesData; + armature?: ArmatureData; + skin?: SkinData; + }; + /** + * @language zh_CN + * 创建骨架的基础工厂。 (通常只需要一个全局工厂实例) + * @see dragonBones.DragonBonesData + * @see dragonBones.TextureAtlasData + * @see dragonBones.ArmatureData + * @see dragonBones.Armature + * @version DragonBones 3.0 + */ + abstract class BaseFactory { + protected static _defaultParser: ObjectDataParser; + /** + * @language zh_CN + * 是否开启共享搜索。 [true: 开启, false: 不开启] + * 如果开启,创建一个骨架时,可以从多个龙骨数据中寻找骨架数据,或贴图集数据中寻找贴图数据。 (通常在有共享导出的数据时开启) + * @see dragonBones.DragonBonesData#autoSearch + * @see dragonBones.TextureAtlasData#autoSearch + * @version DragonBones 4.5 + */ + autoSearch: boolean; + /** + * @private + */ + protected _dataParser: DataParser; + /** + * @private + */ + protected _dragonBonesDataMap: Map; + /** + * @private + */ + protected _textureAtlasDataMap: Map>; + /** + * @private + */ + constructor(dataParser?: DataParser); + /** + * @private + */ + protected _getTextureData(textureAtlasName: string, textureName: string): TextureData; + /** + * @private + */ + protected _fillBuildArmaturePackage(dataPackage: BuildArmaturePackage, dragonBonesName: string, armatureName: string, skinName: string, textureAtlasName: string): boolean; + /** + * @private + */ + protected _buildBones(dataPackage: BuildArmaturePackage, armature: Armature): void; + /** + * @private + */ + protected _buildSlots(dataPackage: BuildArmaturePackage, armature: Armature): void; + /** + * @private + */ + protected _replaceSlotDisplay(dataPackage: BuildArmaturePackage, displayData: DisplayData, slot: Slot, displayIndex: number): void; + /** + * @private + */ + protected abstract _generateTextureAtlasData(textureAtlasData: TextureAtlasData, textureAtlas: any): TextureAtlasData; + /** + * @private + */ + protected abstract _generateArmature(dataPackage: BuildArmaturePackage): Armature; + /** + * @private + */ + protected abstract _generateSlot(dataPackage: BuildArmaturePackage, slotDisplayDataSet: SlotDisplayDataSet, armature: Armature): Slot; + /** + * @language zh_CN + * 解析并添加龙骨数据。 + * @param rawData 需要解析的原始数据。 (JSON) + * @param name 为数据提供一个名称,以便可以通过这个名称获取数据,如果未设置,则使用数据中的名称。 + * @returns DragonBonesData + * @see #getDragonBonesData() + * @see #addDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 4.5 + */ + parseDragonBonesData(rawData: any, name?: string, scale?: number): DragonBonesData; + /** + * @language zh_CN + * 解析并添加贴图集数据。 + * @param rawData 需要解析的原始数据。 (JSON) + * @param textureAtlas 贴图集数据。 (JSON) + * @param name 为数据指定一个名称,以便可以通过这个名称获取数据,如果未设置,则使用数据中的名称。 + * @param scale 为贴图集设置一个缩放值。 + * @returns 贴图集数据 + * @see #getTextureAtlasData() + * @see #addTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 4.5 + */ + parseTextureAtlasData(rawData: any, textureAtlas: Object, name?: string, scale?: number): TextureAtlasData; + /** + * @language zh_CN + * 获取指定名称的龙骨数据。 + * @param name 数据名称。 + * @returns DragonBonesData + * @see #parseDragonBonesData() + * @see #addDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + */ + getDragonBonesData(name: string): DragonBonesData; + /** + * @language zh_CN + * 添加龙骨数据。 + * @param data 龙骨数据。 + * @param name 为数据指定一个名称,以便可以通过这个名称获取数据,如果未设置,则使用数据中的名称。 + * @see #parseDragonBonesData() + * @see #getDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + */ + addDragonBonesData(data: DragonBonesData, name?: string): void; + /** + * @language zh_CN + * 移除龙骨数据。 + * @param name 数据名称。 + * @param disposeData 是否释放数据。 [false: 不释放, true: 释放] + * @see #parseDragonBonesData() + * @see #getDragonBonesData() + * @see #addDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + */ + removeDragonBonesData(name: string, disposeData?: boolean): void; + /** + * @language zh_CN + * 获取指定名称的贴图集数据列表。 + * @param name 数据名称。 + * @returns 贴图集数据列表。 + * @see #parseTextureAtlasData() + * @see #addTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.textures.TextureAtlasData + * @version DragonBones 3.0 + */ + getTextureAtlasData(name: string): Array; + /** + * @language zh_CN + * 添加贴图集数据。 + * @param data 贴图集数据。 + * @param name 为数据指定一个名称,以便可以通过这个名称获取数据,如果未设置,则使用数据中的名称。 + * @see #parseTextureAtlasData() + * @see #getTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.textures.TextureAtlasData + * @version DragonBones 3.0 + */ + addTextureAtlasData(data: TextureAtlasData, name?: string): void; + /** + * @language zh_CN + * 移除贴图集数据。 + * @param name 数据名称。 + * @param disposeData 是否释放数据。 [false: 不释放, true: 释放] + * @see #parseTextureAtlasData() + * @see #getTextureAtlasData() + * @see #addTextureAtlasData() + * @see dragonBones.textures.TextureAtlasData + * @version DragonBones 3.0 + */ + removeTextureAtlasData(name: string, disposeData?: boolean): void; + /** + * @language zh_CN + * 清除所有的数据。 + * @param disposeData 是否释放数据。 [false: 不释放, true: 释放] + * @version DragonBones 4.5 + */ + clear(disposeData?: boolean): void; + /** + * @language zh_CN + * 创建一个指定名称的骨架。 + * @param armatureName 骨架数据名称。 + * @param dragonBonesName 龙骨数据名称,如果未设置,将检索所有的龙骨数据,当多个龙骨数据中包含同名的骨架数据时,可能无法创建出准确的骨架。 + * @param skinName 皮肤名称,如果未设置,则使用默认皮肤。 + * @param textureAtlasName 贴图集数据名称,如果未设置,则使用龙骨数据。 + * @returns 骨架 + * @see dragonBones.Armature + * @version DragonBones 3.0 + */ + buildArmature(armatureName: string, dragonBonesName?: string, skinName?: string, textureAtlasName?: string): Armature; + /** + * @language zh_CN + * 将指定骨架的动画替换成其他骨架的动画。 (通常这些骨架应该具有相同的骨架结构) + * @param toArmature 指定的骨架。 + * @param fromArmatreName 其他骨架的名称。 + * @param fromSkinName 其他骨架的皮肤名称,如果未设置,则使用默认皮肤。 + * @param fromDragonBonesDataName 其他骨架属于的龙骨数据名称,如果未设置,则检索所有的龙骨数据。 + * @param ifRemoveOriginalAnimationList 是否移除原有的动画。 [true: 移除, false: 不移除] + * @returns 是否替换成功。 [true: 成功, false: 不成功] + * @see dragonBones.Armature + * @version DragonBones 4.5 + */ + copyAnimationsToArmature(toArmature: Armature, fromArmatreName: string, fromSkinName?: string, fromDragonBonesDataName?: string, ifRemoveOriginalAnimationList?: boolean): boolean; + /** + * @language zh_CN + * 将指定插槽的显示对象替换为指定资源创造出的显示对象。 + * @param dragonBonesName 指定的龙骨数据名称。 + * @param armatureName 指定的骨架名称。 + * @param slotName 指定的插槽名称。 + * @param displayName 指定的显示对象名称。 + * @param slot 指定的插槽实例。 + * @param displayIndex 要替换的显示对象的索引,如果未设置,则替换当前正在显示的显示对象。 + * @version DragonBones 4.5 + */ + replaceSlotDisplay(dragonBonesName: string, armatureName: string, slotName: string, displayName: string, slot: Slot, displayIndex?: number): void; + /** + * @language zh_CN + * 将指定插槽的显示对象列表替换为指定资源创造出的显示对象列表。 + * @param dragonBonesName 指定的 DragonBonesData 名称。 + * @param armatureName 指定的骨架名称。 + * @param slotName 指定的插槽名称。 + * @param slot 指定的插槽实例。 + * @version DragonBones 4.5 + */ + replaceSlotDisplayList(dragonBonesName: string, armatureName: string, slotName: string, slot: Slot): void; + /** + * @private + */ + getAllDragonBonesData(): Map; + /** + * @private + */ + getAllTextureAtlasData(): Map>; + } +} + +declare let jsb: any; +/** Running in the editor. */ +declare let CC_EDITOR: boolean; +/** Preview in browser or simulator. */ +declare let CC_PREVIEW: boolean; +/** Running in the editor or preview. */ +declare let CC_DEV: boolean; +/** Running in the editor or preview, or build in debug mode. */ +declare let CC_DEBUG: boolean; +/** Running in published project. */ +declare let CC_BUILD: boolean; +/** Running in native platform (mobile app, desktop app, or simulator). */ +declare let CC_JSB: boolean; +/** Running in the engine's unit test. */ +declare let CC_TEST: boolean; diff --git a/FanShooterDemo/jsconfig.json b/FanShooterDemo/jsconfig.json new file mode 100644 index 0000000..80c2563 --- /dev/null +++ b/FanShooterDemo/jsconfig.json @@ -0,0 +1,15 @@ +{ + "compilerOptions": { + "target": "es6", + "module": "commonjs", + "experimentalDecorators": true + }, + "exclude": [ + "node_modules", + ".vscode", + "library", + "local", + "settings", + "temp" + ] +} \ No newline at end of file diff --git a/FanShooterDemo/project.json b/FanShooterDemo/project.json new file mode 100644 index 0000000..4257d04 --- /dev/null +++ b/FanShooterDemo/project.json @@ -0,0 +1,4 @@ +{ + "engine": "cocos2d-html5", + "packages": "packages" +} \ No newline at end of file diff --git a/FanShooterDemo/settings/builder.json b/FanShooterDemo/settings/builder.json new file mode 100644 index 0000000..09f915c --- /dev/null +++ b/FanShooterDemo/settings/builder.json @@ -0,0 +1,13 @@ +{ + "excludeScenes": [], + "orientation": { + "landscapeLeft": true, + "landscapeRight": true, + "portrait": false, + "upsideDown": false + }, + "packageName": "org.cocos2d.helloworld", + "startScene": "2d2f792f-a40c-49bb-a189-ed176a246e49", + "title": "hello_world", + "webOrientation": "auto" +} \ No newline at end of file diff --git a/FanShooterDemo/settings/builder.panel.json b/FanShooterDemo/settings/builder.panel.json new file mode 100644 index 0000000..6a7c356 --- /dev/null +++ b/FanShooterDemo/settings/builder.panel.json @@ -0,0 +1,7 @@ +{ + "excludeScenes": [], + "packageName": "org.cocos2d.helloworld", + "platform": "web-mobile", + "startScene": "2d2f792f-a40c-49bb-a189-ed176a246e49", + "title": "HelloWorld" +} \ No newline at end of file diff --git a/FanShooterDemo/settings/project.json b/FanShooterDemo/settings/project.json new file mode 100644 index 0000000..ac399c6 --- /dev/null +++ b/FanShooterDemo/settings/project.json @@ -0,0 +1,28 @@ +{ + "collision-matrix": [ + [ + true + ] + ], + "excluded-modules": [], + "group-list": [ + "default" + ], + "start-scene": "current", + "design-resolution-width": 960, + "design-resolution-height": 640, + "fit-width": false, + "fit-height": true, + "use-project-simulator-setting": false, + "simulator-orientation": false, + "use-customize-simulator": false, + "simulator-resolution": { + "width": 960, + "height": 640 + }, + "cocos-analytics": { + "enable": false, + "appID": "13798", + "appSecret": "959b3ac0037d0f3c2fdce94f8421a9b2" + } +} \ No newline at end of file diff --git a/FanShooterDemo/template-banner.png b/FanShooterDemo/template-banner.png new file mode 100644 index 0000000..d24a435 Binary files /dev/null and b/FanShooterDemo/template-banner.png differ diff --git a/FanShooterDemo/template.json b/FanShooterDemo/template.json new file mode 100644 index 0000000..3bcc784 --- /dev/null +++ b/FanShooterDemo/template.json @@ -0,0 +1,5 @@ +{ + "name": "TEMPLATES.helloworld.name", + "desc": "TEMPLATES.helloworld.desc", + "banner": "template-banner.png" +} \ No newline at end of file diff --git a/HorseRaceLamp/assets/RollingMachine.js b/HorseRaceLamp/assets/RollingMachine.js new file mode 100644 index 0000000..2d3374c --- /dev/null +++ b/HorseRaceLamp/assets/RollingMachine.js @@ -0,0 +1,76 @@ +cc.Class({ + extends: cc.Component, + + properties: { + list: [cc.Node], + loopTimes: 4, + awardTime: 1, + loopTimeList: [cc.Float] + }, + + onLoad() { + this.flickerTime = 0.15; + // this.loopTimeList = [0.04, 0.04, 0.12, 0.2, 0.2]; + }, + + registerEvent() { + + }, + + init(data) { + + }, + + play(index, fn) { + let seqList = [], len = this.list.length, i = 0, deltaTime = 0; + let realTimes = len * this.loopTimes + index; + for (i = 0; i <= realTimes; i++) { + if (realTimes - i < 3) { + deltaTime += this.loopTimeList[this.loopTimeList.length - 1]; + } + let item = this.list[i % len]; + seqList.push(this.createAction(item, this.loopTimeList[Math.floor(i / len)] + deltaTime, true)); + } + for (i = 0; i < 3; i++) { + let item = this.list[index]; + seqList.push(this.createAction(item, this.flickerTime, false)); + seqList.push(cc.delayTime(this.flickerTime)); + } + + seqList.push(cc.delayTime(this.awardTime)); + seqList.push(cc.callFunc(() => { + fn && fn(); + })); + + this.node.runAction(cc.sequence(seqList)); + }, + + createAction(item, time, isShow) { + let seq = cc.sequence(cc.callFunc((data) => { + item.active = isShow; + }), cc.delayTime(time), cc.callFunc((data) => { + item.active = !isShow; + })); + return seq; + }, + + update(dt) { + + }, + + onEnable() { + this.registerEvent(); + }, + + onDisable() { + this.offEvent(); + }, + + offEvent() { + cc.emitter.offThis(this); + }, + + onDestroy() { + + } +}); \ No newline at end of file diff --git a/HorseRaceLamp/assets/RollingMachine.js.meta b/HorseRaceLamp/assets/RollingMachine.js.meta new file mode 100644 index 0000000..356c38c --- /dev/null +++ b/HorseRaceLamp/assets/RollingMachine.js.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.5", + "uuid": "1d222780-1af2-440a-8e0b-749bd8755e19", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/HorseRaceLamp/assets/SlotMachine.fire b/HorseRaceLamp/assets/SlotMachine.fire new file mode 100644 index 0000000..0843be9 --- /dev/null +++ b/HorseRaceLamp/assets/SlotMachine.fire @@ -0,0 +1,1445 @@ +[ + { + "__type__": "cc.SceneAsset", + "_name": "", + "_objFlags": 0, + "_rawFiles": null, + "scene": { + "__id__": 1 + } + }, + { + "__type__": "cc.Scene", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + } + ], + "_tag": -1, + "_active": true, + "_components": [], + "_prefab": null, + "_id": "31bca123-0de6-409a-94d8-28d1b2634535", + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_cascadeOpacityEnabled": true, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_localZOrder": 0, + "_globalZOrder": 0, + "_opacityModifyRGB": false, + "groupIndex": 0, + "autoReleaseAssets": false + }, + { + "__type__": "cc.Node", + "_name": "Canvas", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 3 + }, + { + "__id__": 29 + } + ], + "_tag": -1, + "_active": true, + "_components": [ + { + "__id__": 35 + }, + { + "__id__": 36 + } + ], + "_prefab": null, + "_id": "81b+qLVsNPcJ56dNigXhPS", + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_cascadeOpacityEnabled": true, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 960, + "height": 640 + }, + "_rotationX": 0, + "_rotationY": 0, + "_scaleX": 1, + "_scaleY": 1, + "_position": { + "__type__": "cc.Vec2", + "x": 480, + "y": 320 + }, + "_skewX": 0, + "_skewY": 0, + "_localZOrder": 0, + "_globalZOrder": 0, + "_opacityModifyRGB": false, + "groupIndex": 0 + }, + { + "__type__": "cc.Node", + "_name": "List", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [ + { + "__id__": 4 + }, + { + "__id__": 8 + }, + { + "__id__": 12 + }, + { + "__id__": 16 + }, + { + "__id__": 20 + }, + { + "__id__": 24 + } + ], + "_tag": -1, + "_active": true, + "_components": [ + { + "__id__": 28 + } + ], + "_prefab": null, + "_id": "9dvb4pUCVEWJu5Lt1qL98g", + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_cascadeOpacityEnabled": true, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_rotationX": 0, + "_rotationY": 0, + "_scaleX": 1, + "_scaleY": 1, + "_position": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_localZOrder": 0, + "_globalZOrder": 0, + "_opacityModifyRGB": false, + "groupIndex": 0 + }, + { + "__type__": "cc.Node", + "_name": "item", + "_objFlags": 0, + "_parent": { + "__id__": 3 + }, + "_children": [ + { + "__id__": 5 + } + ], + "_tag": -1, + "_active": true, + "_components": [ + { + "__id__": 7 + } + ], + "_prefab": null, + "_id": "72TGwUpzBHg6XrwKWQDQUW", + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_cascadeOpacityEnabled": true, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 100 + }, + "_rotationX": 0, + "_rotationY": 0, + "_scaleX": 1, + "_scaleY": 1, + "_position": { + "__type__": "cc.Vec2", + "x": -200, + "y": 100 + }, + "_skewX": 0, + "_skewY": 0, + "_localZOrder": 0, + "_globalZOrder": 0, + "_opacityModifyRGB": false, + "groupIndex": 0 + }, + { + "__type__": "cc.Node", + "_name": "element", + "_objFlags": 0, + "_parent": { + "__id__": 4 + }, + "_children": [], + "_tag": -1, + "_active": false, + "_components": [ + { + "__id__": 6 + } + ], + "_prefab": null, + "_id": "73Ne8Q+WpB9pPlqhQkuQo4", + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 250, + "g": 56, + "b": 56, + "a": 255 + }, + "_cascadeOpacityEnabled": true, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 90, + "height": 90 + }, + "_rotationX": 0, + "_rotationY": 0, + "_scaleX": 1, + "_scaleY": 1, + "_position": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_localZOrder": 0, + "_globalZOrder": 0, + "_opacityModifyRGB": false, + "groupIndex": 0 + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 5 + }, + "_enabled": true, + "_spriteFrame": { + "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_atlas": null + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 4 + }, + "_enabled": true, + "_spriteFrame": { + "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_atlas": null + }, + { + "__type__": "cc.Node", + "_name": "item", + "_objFlags": 0, + "_parent": { + "__id__": 3 + }, + "_children": [ + { + "__id__": 9 + } + ], + "_tag": -1, + "_active": true, + "_components": [ + { + "__id__": 11 + } + ], + "_prefab": null, + "_id": "8eE/pxjOdBc6o/f5Pz6JWN", + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_cascadeOpacityEnabled": true, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 100 + }, + "_rotationX": 0, + "_rotationY": 0, + "_scaleX": 1, + "_scaleY": 1, + "_position": { + "__type__": "cc.Vec2", + "x": 0, + "y": 100 + }, + "_skewX": 0, + "_skewY": 0, + "_localZOrder": 0, + "_globalZOrder": 0, + "_opacityModifyRGB": false, + "groupIndex": 0 + }, + { + "__type__": "cc.Node", + "_name": "element", + "_objFlags": 0, + "_parent": { + "__id__": 8 + }, + "_children": [], + "_tag": -1, + "_active": false, + "_components": [ + { + "__id__": 10 + } + ], + "_prefab": null, + "_id": "51+fwHb9VGrqtnbbx/ozm1", + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 250, + "g": 56, + "b": 56, + "a": 255 + }, + "_cascadeOpacityEnabled": true, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 90, + "height": 90 + }, + "_rotationX": 0, + "_rotationY": 0, + "_scaleX": 1, + "_scaleY": 1, + "_position": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_localZOrder": 0, + "_globalZOrder": 0, + "_opacityModifyRGB": false, + "groupIndex": 0 + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 9 + }, + "_enabled": true, + "_spriteFrame": { + "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_atlas": null + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 8 + }, + "_enabled": true, + "_spriteFrame": { + "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_atlas": null + }, + { + "__type__": "cc.Node", + "_name": "item", + "_objFlags": 0, + "_parent": { + "__id__": 3 + }, + "_children": [ + { + "__id__": 13 + } + ], + "_tag": -1, + "_active": true, + "_components": [ + { + "__id__": 15 + } + ], + "_prefab": null, + "_id": "07xvxjzB5DXa4j+pWNrKyy", + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_cascadeOpacityEnabled": true, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 100 + }, + "_rotationX": 0, + "_rotationY": 0, + "_scaleX": 1, + "_scaleY": 1, + "_position": { + "__type__": "cc.Vec2", + "x": 200, + "y": 100 + }, + "_skewX": 0, + "_skewY": 0, + "_localZOrder": 0, + "_globalZOrder": 0, + "_opacityModifyRGB": false, + "groupIndex": 0 + }, + { + "__type__": "cc.Node", + "_name": "element", + "_objFlags": 0, + "_parent": { + "__id__": 12 + }, + "_children": [], + "_tag": -1, + "_active": false, + "_components": [ + { + "__id__": 14 + } + ], + "_prefab": null, + "_id": "d8dA89PRZGy76SnFZzMvsI", + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 250, + "g": 56, + "b": 56, + "a": 255 + }, + "_cascadeOpacityEnabled": true, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 90, + "height": 90 + }, + "_rotationX": 0, + "_rotationY": 0, + "_scaleX": 1, + "_scaleY": 1, + "_position": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_localZOrder": 0, + "_globalZOrder": 0, + "_opacityModifyRGB": false, + "groupIndex": 0 + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 13 + }, + "_enabled": true, + "_spriteFrame": { + "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_atlas": null + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 12 + }, + "_enabled": true, + "_spriteFrame": { + "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_atlas": null + }, + { + "__type__": "cc.Node", + "_name": "item", + "_objFlags": 0, + "_parent": { + "__id__": 3 + }, + "_children": [ + { + "__id__": 17 + } + ], + "_tag": -1, + "_active": true, + "_components": [ + { + "__id__": 19 + } + ], + "_prefab": null, + "_id": "ea+exycYpEC7PuId+mZmes", + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_cascadeOpacityEnabled": true, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 100 + }, + "_rotationX": 0, + "_rotationY": 0, + "_scaleX": 1, + "_scaleY": 1, + "_position": { + "__type__": "cc.Vec2", + "x": -200, + "y": -100 + }, + "_skewX": 0, + "_skewY": 0, + "_localZOrder": 0, + "_globalZOrder": 0, + "_opacityModifyRGB": false, + "groupIndex": 0 + }, + { + "__type__": "cc.Node", + "_name": "element", + "_objFlags": 0, + "_parent": { + "__id__": 16 + }, + "_children": [], + "_tag": -1, + "_active": false, + "_components": [ + { + "__id__": 18 + } + ], + "_prefab": null, + "_id": "41C8aroPxE8Ihm1Bj8Egv2", + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 250, + "g": 56, + "b": 56, + "a": 255 + }, + "_cascadeOpacityEnabled": true, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 90, + "height": 90 + }, + "_rotationX": 0, + "_rotationY": 0, + "_scaleX": 1, + "_scaleY": 1, + "_position": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_localZOrder": 0, + "_globalZOrder": 0, + "_opacityModifyRGB": false, + "groupIndex": 0 + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 17 + }, + "_enabled": true, + "_spriteFrame": { + "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_atlas": null + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 16 + }, + "_enabled": true, + "_spriteFrame": { + "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_atlas": null + }, + { + "__type__": "cc.Node", + "_name": "item", + "_objFlags": 0, + "_parent": { + "__id__": 3 + }, + "_children": [ + { + "__id__": 21 + } + ], + "_tag": -1, + "_active": true, + "_components": [ + { + "__id__": 23 + } + ], + "_prefab": null, + "_id": "97rWDezzBHhruSKsvPhe7w", + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_cascadeOpacityEnabled": true, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 100 + }, + "_rotationX": 0, + "_rotationY": 0, + "_scaleX": 1, + "_scaleY": 1, + "_position": { + "__type__": "cc.Vec2", + "x": 0, + "y": -100 + }, + "_skewX": 0, + "_skewY": 0, + "_localZOrder": 0, + "_globalZOrder": 0, + "_opacityModifyRGB": false, + "groupIndex": 0 + }, + { + "__type__": "cc.Node", + "_name": "element", + "_objFlags": 0, + "_parent": { + "__id__": 20 + }, + "_children": [], + "_tag": -1, + "_active": false, + "_components": [ + { + "__id__": 22 + } + ], + "_prefab": null, + "_id": "27NPj5EStCTITzUEQVcaak", + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 250, + "g": 56, + "b": 56, + "a": 255 + }, + "_cascadeOpacityEnabled": true, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 90, + "height": 90 + }, + "_rotationX": 0, + "_rotationY": 0, + "_scaleX": 1, + "_scaleY": 1, + "_position": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_localZOrder": 0, + "_globalZOrder": 0, + "_opacityModifyRGB": false, + "groupIndex": 0 + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 21 + }, + "_enabled": true, + "_spriteFrame": { + "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_atlas": null + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 20 + }, + "_enabled": true, + "_spriteFrame": { + "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_atlas": null + }, + { + "__type__": "cc.Node", + "_name": "item", + "_objFlags": 0, + "_parent": { + "__id__": 3 + }, + "_children": [ + { + "__id__": 25 + } + ], + "_tag": -1, + "_active": true, + "_components": [ + { + "__id__": 27 + } + ], + "_prefab": null, + "_id": "24KvWxtCtOGag3IGv7WPe0", + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_cascadeOpacityEnabled": true, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 100 + }, + "_rotationX": 0, + "_rotationY": 0, + "_scaleX": 1, + "_scaleY": 1, + "_position": { + "__type__": "cc.Vec2", + "x": 200, + "y": -100 + }, + "_skewX": 0, + "_skewY": 0, + "_localZOrder": 0, + "_globalZOrder": 0, + "_opacityModifyRGB": false, + "groupIndex": 0 + }, + { + "__type__": "cc.Node", + "_name": "element", + "_objFlags": 0, + "_parent": { + "__id__": 24 + }, + "_children": [], + "_tag": -1, + "_active": false, + "_components": [ + { + "__id__": 26 + } + ], + "_prefab": null, + "_id": "e7e+r6LMFBzI5X7QnTR3dJ", + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 250, + "g": 56, + "b": 56, + "a": 255 + }, + "_cascadeOpacityEnabled": true, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 90, + "height": 90 + }, + "_rotationX": 0, + "_rotationY": 0, + "_scaleX": 1, + "_scaleY": 1, + "_position": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_localZOrder": 0, + "_globalZOrder": 0, + "_opacityModifyRGB": false, + "groupIndex": 0 + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 25 + }, + "_enabled": true, + "_spriteFrame": { + "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_atlas": null + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 24 + }, + "_enabled": true, + "_spriteFrame": { + "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_atlas": null + }, + { + "__type__": "1d222eAGvJECo4LdJvYdV4Z", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 3 + }, + "_enabled": true, + "list": [ + { + "__id__": 5 + }, + { + "__id__": 9 + }, + { + "__id__": 13 + }, + { + "__id__": 17 + }, + { + "__id__": 21 + }, + { + "__id__": 25 + } + ], + "loopTimes": 4, + "awardTime": 1, + "loopTimeList": [ + 0.04, + 0.04, + 0.12, + 0.2, + 0.2 + ] + }, + { + "__type__": "cc.Node", + "_name": "New Button", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [ + { + "__id__": 30 + } + ], + "_tag": -1, + "_active": true, + "_components": [ + { + "__id__": 32 + }, + { + "__id__": 33 + } + ], + "_prefab": null, + "_id": "6cXF5GvgpGxZj+JNel1Rk/", + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_cascadeOpacityEnabled": true, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 40 + }, + "_rotationX": 0, + "_rotationY": 0, + "_scaleX": 1, + "_scaleY": 1, + "_position": { + "__type__": "cc.Vec2", + "x": 0, + "y": -261 + }, + "_skewX": 0, + "_skewY": 0, + "_localZOrder": 0, + "_globalZOrder": 0, + "_opacityModifyRGB": false, + "groupIndex": 0 + }, + { + "__type__": "cc.Node", + "_name": "Label", + "_objFlags": 0, + "_parent": { + "__id__": 29 + }, + "_children": [], + "_tag": -1, + "_active": true, + "_components": [ + { + "__id__": 31 + } + ], + "_prefab": null, + "_id": "dccx9KgyNHzY6YdN4YpnrD", + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_cascadeOpacityEnabled": true, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 40 + }, + "_rotationX": 0, + "_rotationY": 0, + "_scaleX": 1, + "_scaleY": 1, + "_position": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_localZOrder": 0, + "_globalZOrder": 0, + "_opacityModifyRGB": false, + "groupIndex": 0 + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 30 + }, + "_enabled": true, + "_useOriginalSize": false, + "_actualFontSize": 20, + "_fontSize": 20, + "_lineHeight": 40, + "_enableWrapText": false, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_N$string": "play", + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 1 + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 29 + }, + "_enabled": true, + "_spriteFrame": { + "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952" + }, + "_type": 1, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_atlas": null + }, + { + "__type__": "cc.Button", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 29 + }, + "_enabled": true, + "transition": 2, + "pressedColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "duration": 0.1, + "zoomScale": 1.2, + "clickEvents": [ + { + "__id__": 34 + } + ], + "_N$interactable": true, + "_N$enableAutoGrayEffect": false, + "_N$normalColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$disabledColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$normalSprite": { + "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952" + }, + "_N$pressedSprite": { + "__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a" + }, + "pressedSprite": { + "__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a" + }, + "_N$hoverSprite": { + "__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a" + }, + "hoverSprite": { + "__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a" + }, + "_N$disabledSprite": { + "__uuid__": "29158224-f8dd-4661-a796-1ffab537140e" + }, + "_N$target": { + "__id__": 29 + } + }, + { + "__type__": "cc.ClickEvent", + "target": { + "__id__": 2 + }, + "component": "SlotMachine", + "handler": "onEventClicked_play", + "customEventData": "" + }, + { + "__type__": "cc.Canvas", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "_designResolution": { + "__type__": "cc.Size", + "width": 960, + "height": 640 + }, + "_fitWidth": false, + "_fitHeight": true + }, + { + "__type__": "1af8adx3FFDq6lfLClbNl7w", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "rolling": { + "__id__": 3 + } + } +] \ No newline at end of file diff --git a/HorseRaceLamp/assets/SlotMachine.fire.meta b/HorseRaceLamp/assets/SlotMachine.fire.meta new file mode 100644 index 0000000..91aa093 --- /dev/null +++ b/HorseRaceLamp/assets/SlotMachine.fire.meta @@ -0,0 +1,7 @@ +{ + "ver": "1.0.0", + "uuid": "31bca123-0de6-409a-94d8-28d1b2634535", + "asyncLoadAssets": false, + "autoReleaseAssets": false, + "subMetas": {} +} \ No newline at end of file diff --git a/HorseRaceLamp/assets/SlotMachine.js b/HorseRaceLamp/assets/SlotMachine.js new file mode 100644 index 0000000..8053f58 --- /dev/null +++ b/HorseRaceLamp/assets/SlotMachine.js @@ -0,0 +1,44 @@ +cc.Class({ + extends: cc.Component, + + properties: { + rolling: cc.Node, + }, + + onLoad() { + this.rollingMachine = this.rolling.getComponent('RollingMachine'); + }, + + registerEvent() { + + }, + + init(data) { + + }, + + onEventClicked_play() { + let index = 2 + this.rollingMachine.play(index); + }, + + update(dt) { + + }, + + onEnable() { + this.registerEvent(); + }, + + onDisable() { + this.offEvent(); + }, + + offEvent() { + cc.emitter.offThis(this); + }, + + onDestroy() { + + } +}); \ No newline at end of file diff --git a/HorseRaceLamp/assets/SlotMachine.js.meta b/HorseRaceLamp/assets/SlotMachine.js.meta new file mode 100644 index 0000000..8663c0a --- /dev/null +++ b/HorseRaceLamp/assets/SlotMachine.js.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.5", + "uuid": "1af8a771-dc51-43ab-a95f-2c295b365ef0", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/HotUpdateDemo/README.md b/HotUpdateDemo/README.md index 685f3d6..84d9db0 100644 --- a/HotUpdateDemo/README.md +++ b/HotUpdateDemo/README.md @@ -10,7 +10,7 @@ ~~~ npm install ~~~ -安装Node的库 +安装Node的库 fs-jetpack 用于对文件操作 * 构建Android 工程 选择link模式 ![link](https://upload-images.jianshu.io/upload_images/2315803-f28aec8ccdff1858.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) diff --git a/HotUpdateDemo/build-templates/jsb-binary/main.js b/HotUpdateDemo/build-templates/jsb-binary/main.js index 08004b6..90b2ae1 100644 --- a/HotUpdateDemo/build-templates/jsb-binary/main.js +++ b/HotUpdateDemo/build-templates/jsb-binary/main.js @@ -24,7 +24,12 @@ } //版本比最近版本等于or大于。需要清理热更新cache; if (versionCompareHandle(version, curVersion) >= 0) { - hotUpdateSearchPaths && jsb.fileUtils.removeDirectory(hotUpdateSearchPaths); + if (hotUpdateSearchPaths) { + let list = JSON.parse(hotUpdateSearchPaths); + list.forEach((path) => { + jsb.fileUtils.removeDirectory(path); + }); + } } //设置搜索路径 if (window.cc && cc.sys.isNative) { diff --git a/HotUpdateDemo/build-templates/jsb-default/main.js b/HotUpdateDemo/build-templates/jsb-default/main.js index 08004b6..90b2ae1 100644 --- a/HotUpdateDemo/build-templates/jsb-default/main.js +++ b/HotUpdateDemo/build-templates/jsb-default/main.js @@ -24,7 +24,12 @@ } //版本比最近版本等于or大于。需要清理热更新cache; if (versionCompareHandle(version, curVersion) >= 0) { - hotUpdateSearchPaths && jsb.fileUtils.removeDirectory(hotUpdateSearchPaths); + if (hotUpdateSearchPaths) { + let list = JSON.parse(hotUpdateSearchPaths); + list.forEach((path) => { + jsb.fileUtils.removeDirectory(path); + }); + } } //设置搜索路径 if (window.cc && cc.sys.isNative) { diff --git a/HotUpdateDemo/build-templates/jsb-link/main.js b/HotUpdateDemo/build-templates/jsb-link/main.js index 08004b6..90b2ae1 100644 --- a/HotUpdateDemo/build-templates/jsb-link/main.js +++ b/HotUpdateDemo/build-templates/jsb-link/main.js @@ -24,7 +24,12 @@ } //版本比最近版本等于or大于。需要清理热更新cache; if (versionCompareHandle(version, curVersion) >= 0) { - hotUpdateSearchPaths && jsb.fileUtils.removeDirectory(hotUpdateSearchPaths); + if (hotUpdateSearchPaths) { + let list = JSON.parse(hotUpdateSearchPaths); + list.forEach((path) => { + jsb.fileUtils.removeDirectory(path); + }); + } } //设置搜索路径 if (window.cc && cc.sys.isNative) { diff --git a/HotUpdateDemo/package-lock.json b/HotUpdateDemo/package-lock.json index a2b413d..0008751 100644 --- a/HotUpdateDemo/package-lock.json +++ b/HotUpdateDemo/package-lock.json @@ -16,7 +16,7 @@ "integrity": "sha1-r9+UiPsezvyDSPb7IvRk4ypYs2s=", "dev": true, "requires": { - "acorn": "^3.0.4" + "acorn": "3.3.0" }, "dependencies": { "acorn": { @@ -33,10 +33,10 @@ "integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=", "dev": true, "requires": { - "co": "^4.6.0", - "fast-deep-equal": "^1.0.0", - "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.3.0" + "co": "4.6.0", + "fast-deep-equal": "1.1.0", + "fast-json-stable-stringify": "2.0.0", + "json-schema-traverse": "0.3.1" } }, "ajv-keywords": { @@ -85,7 +85,6 @@ "resolved": "http://registry.npm.taobao.org/archive-type/download/archive-type-3.2.0.tgz", "integrity": "sha1-nNnABpV+vpX62tW9YJiUKoE3N/Y=", "dev": true, - "optional": true, "requires": { "file-type": "3.9.0" }, @@ -94,8 +93,7 @@ "version": "3.9.0", "resolved": "http://registry.npm.taobao.org/file-type/download/file-type-3.9.0.tgz", "integrity": "sha1-JXoHg4TR24CHvESdEH1SpSZyuek=", - "dev": true, - "optional": true + "dev": true } } }, @@ -145,8 +143,7 @@ "version": "1.0.2", "resolved": "http://registry.npm.taobao.org/array-find-index/download/array-find-index-1.0.2.tgz", "integrity": "sha1-3wEKoSh+Fku9pvlyOwqWoexBh6E=", - "dev": true, - "optional": true + "dev": true }, "array-slice": { "version": "1.1.0", @@ -188,9 +185,9 @@ "integrity": "sha1-Y/1D99weO7fONZR9uP42mj9Yx0s=", "dev": true, "requires": { - "chalk": "^1.1.3", - "esutils": "^2.0.2", - "js-tokens": "^3.0.2" + "chalk": "1.1.3", + "esutils": "2.0.2", + "js-tokens": "3.0.2" }, "dependencies": { "chalk": { @@ -199,11 +196,11 @@ "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", "dev": true, "requires": { - "ansi-styles": "^2.2.1", - "escape-string-regexp": "^1.0.2", - "has-ansi": "^2.0.0", - "strip-ansi": "^3.0.0", - "supports-color": "^2.0.0" + "ansi-styles": "2.2.1", + "escape-string-regexp": "1.0.5", + "has-ansi": "2.0.0", + "strip-ansi": "3.0.1", + "supports-color": "2.0.0" } }, "strip-ansi": { @@ -212,7 +209,7 @@ "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, "requires": { - "ansi-regex": "^2.0.0" + "ansi-regex": "2.1.1" } } } @@ -368,7 +365,6 @@ "resolved": "http://registry.npm.taobao.org/bl/download/bl-1.2.1.tgz", "integrity": "sha1-ysMo977kVzDUBLaSID/LWQ4XLV4=", "dev": true, - "optional": true, "requires": { "readable-stream": "2.3.3" } @@ -397,15 +393,13 @@ "version": "0.2.13", "resolved": "http://registry.npm.taobao.org/buffer-crc32/download/buffer-crc32-0.2.13.tgz", "integrity": "sha1-DTM+PwDqxQqhRUq9MO+MKl2ackI=", - "dev": true, - "optional": true + "dev": true }, "buffer-to-vinyl": { "version": "1.1.0", "resolved": "http://registry.npm.taobao.org/buffer-to-vinyl/download/buffer-to-vinyl-1.1.0.tgz", "integrity": "sha1-APFfruOreh3aLN5tkSG//dB7ImI=", "dev": true, - "optional": true, "requires": { "file-type": "3.9.0", "readable-stream": "2.3.3", @@ -417,22 +411,19 @@ "version": "3.9.0", "resolved": "http://registry.npm.taobao.org/file-type/download/file-type-3.9.0.tgz", "integrity": "sha1-JXoHg4TR24CHvESdEH1SpSZyuek=", - "dev": true, - "optional": true + "dev": true }, "uuid": { "version": "2.0.3", "resolved": "http://registry.npm.taobao.org/uuid/download/uuid-2.0.3.tgz", "integrity": "sha1-Z+LoY3lyFVMN/zGOW/nc6/1Hsho=", - "dev": true, - "optional": true + "dev": true }, "vinyl": { "version": "1.2.0", "resolved": "http://registry.npm.taobao.org/vinyl/download/vinyl-1.2.0.tgz", "integrity": "sha1-XIgDbPVl5d8FVYv8kR+GVt8hiIQ=", "dev": true, - "optional": true, "requires": { "clone": "1.0.3", "clone-stats": "0.0.1", @@ -454,8 +445,7 @@ "version": "1.1.1", "resolved": "http://registry.npm.taobao.org/builtin-modules/download/builtin-modules-1.1.1.tgz", "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=", - "dev": true, - "optional": true + "dev": true }, "caller-path": { "version": "0.1.0", @@ -463,7 +453,7 @@ "integrity": "sha1-lAhe9jWB7NPaqSREqP6U6CV3dR8=", "dev": true, "requires": { - "callsites": "^0.2.0" + "callsites": "0.2.0" } }, "callsites": { @@ -493,7 +483,6 @@ "resolved": "http://registry.npm.taobao.org/camelcase-keys/download/camelcase-keys-2.1.0.tgz", "integrity": "sha1-MIvur/3ygRkFHvodkyITyRuPkuc=", "dev": true, - "optional": true, "requires": { "camelcase": "2.1.1", "map-obj": "1.0.1" @@ -503,8 +492,7 @@ "version": "2.1.1", "resolved": "http://registry.npm.taobao.org/camelcase/download/camelcase-2.1.1.tgz", "integrity": "sha1-fB0W1nmhu+WcoCys7PsBHiAfWh8=", - "dev": true, - "optional": true + "dev": true } } }, @@ -512,15 +500,13 @@ "version": "1.0.0", "resolved": "http://registry.npm.taobao.org/capture-stack-trace/download/capture-stack-trace-1.0.0.tgz", "integrity": "sha1-Sm+gc5nCa7pH8LJJa00PtAjFVQ0=", - "dev": true, - "optional": true + "dev": true }, "caw": { "version": "1.2.0", "resolved": "http://registry.npm.taobao.org/caw/download/caw-1.2.0.tgz", "integrity": "sha1-/7Im/n78VHKI3GLuPpcHPCEtEDQ=", "dev": true, - "optional": true, "requires": { "get-proxy": "1.1.0", "is-obj": "1.0.1", @@ -532,8 +518,7 @@ "version": "3.0.0", "resolved": "http://registry.npm.taobao.org/object-assign/download/object-assign-3.0.0.tgz", "integrity": "sha1-m+3VygiXlJvKR+f/QIBi1Un1h/I=", - "dev": true, - "optional": true + "dev": true } } }, @@ -794,8 +779,7 @@ "version": "1.5.1", "resolved": "http://registry.npm.taobao.org/convert-source-map/download/convert-source-map-1.5.1.tgz", "integrity": "sha1-uCeAl7m8IpNl3lxiz1/K7YtVmeU=", - "dev": true, - "optional": true + "dev": true }, "core-js": { "version": "2.5.2", @@ -814,7 +798,6 @@ "resolved": "http://registry.npm.taobao.org/create-error-class/download/create-error-class-3.0.2.tgz", "integrity": "sha1-Br56vvlHo/FKMP1hBnHUAbyot7Y=", "dev": true, - "optional": true, "requires": { "capture-stack-trace": "1.0.0" } @@ -861,7 +844,6 @@ "resolved": "http://registry.npm.taobao.org/currently-unhandled/download/currently-unhandled-0.4.1.tgz", "integrity": "sha1-mI3zP+qxke95mmE2nddsF635V+o=", "dev": true, - "optional": true, "requires": { "array-find-index": "1.0.2" } @@ -878,7 +860,7 @@ "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", "dev": true, "requires": { - "ms": "^2.1.1" + "ms": "2.1.2" } }, "decamelize": { @@ -892,7 +874,6 @@ "resolved": "http://registry.npm.taobao.org/decompress/download/decompress-3.0.0.tgz", "integrity": "sha1-rx3VDQbjv8QyRh033hGzjA2ZG+0=", "dev": true, - "optional": true, "requires": { "buffer-to-vinyl": "1.1.0", "concat-stream": "1.6.0", @@ -910,7 +891,6 @@ "resolved": "http://registry.npm.taobao.org/glob/download/glob-5.0.15.tgz", "integrity": "sha1-G8k2ueAvSmA/zCIuz3Yz0wuLk7E=", "dev": true, - "optional": true, "requires": { "inflight": "1.0.6", "inherits": "2.0.3", @@ -924,7 +904,6 @@ "resolved": "http://registry.npm.taobao.org/glob-parent/download/glob-parent-3.1.0.tgz", "integrity": "sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4=", "dev": true, - "optional": true, "requires": { "is-glob": "3.1.0", "path-dirname": "1.0.2" @@ -935,7 +914,6 @@ "resolved": "http://registry.npm.taobao.org/glob-stream/download/glob-stream-5.3.5.tgz", "integrity": "sha1-pVZlqajM3EGRWofHAeMtTgFvrSI=", "dev": true, - "optional": true, "requires": { "extend": "3.0.1", "glob": "5.0.15", @@ -952,7 +930,6 @@ "resolved": "http://registry.npm.taobao.org/readable-stream/download/readable-stream-1.0.34.tgz", "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", "dev": true, - "optional": true, "requires": { "core-util-is": "1.0.2", "inherits": "2.0.3", @@ -965,7 +942,6 @@ "resolved": "http://registry.npm.taobao.org/through2/download/through2-0.6.5.tgz", "integrity": "sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=", "dev": true, - "optional": true, "requires": { "readable-stream": "1.0.34", "xtend": "4.0.1" @@ -977,15 +953,13 @@ "version": "2.1.1", "resolved": "http://registry.npm.taobao.org/is-extglob/download/is-extglob-2.1.1.tgz", "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", - "dev": true, - "optional": true + "dev": true }, "is-glob": { "version": "3.1.0", "resolved": "http://registry.npm.taobao.org/is-glob/download/is-glob-3.1.0.tgz", "integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=", "dev": true, - "optional": true, "requires": { "is-extglob": "2.1.1" } @@ -994,15 +968,13 @@ "version": "0.0.1", "resolved": "http://registry.npm.taobao.org/isarray/download/isarray-0.0.1.tgz", "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true, - "optional": true + "dev": true }, "ordered-read-streams": { "version": "0.3.0", "resolved": "http://registry.npm.taobao.org/ordered-read-streams/download/ordered-read-streams-0.3.0.tgz", "integrity": "sha1-cTfmmzKYuzQiR6G77jiByA4v14s=", "dev": true, - "optional": true, "requires": { "is-stream": "1.1.0", "readable-stream": "2.3.3" @@ -1012,15 +984,13 @@ "version": "0.10.31", "resolved": "http://registry.npm.taobao.org/string_decoder/download/string_decoder-0.10.31.tgz", "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", - "dev": true, - "optional": true + "dev": true }, "strip-bom": { "version": "2.0.0", "resolved": "http://registry.npm.taobao.org/strip-bom/download/strip-bom-2.0.0.tgz", "integrity": "sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4=", "dev": true, - "optional": true, "requires": { "is-utf8": "0.2.1" } @@ -1030,7 +1000,6 @@ "resolved": "http://registry.npm.taobao.org/unique-stream/download/unique-stream-2.2.1.tgz", "integrity": "sha1-WqADz76Uxf+GbE59ZouxxNuts2k=", "dev": true, - "optional": true, "requires": { "json-stable-stringify": "1.0.1", "through2-filter": "2.0.0" @@ -1041,7 +1010,6 @@ "resolved": "http://registry.npm.taobao.org/vinyl/download/vinyl-1.2.0.tgz", "integrity": "sha1-XIgDbPVl5d8FVYv8kR+GVt8hiIQ=", "dev": true, - "optional": true, "requires": { "clone": "1.0.3", "clone-stats": "0.0.1", @@ -1053,7 +1021,6 @@ "resolved": "http://registry.npm.taobao.org/vinyl-fs/download/vinyl-fs-2.4.4.tgz", "integrity": "sha1-vm/zJwy1Xf19MGNkDegfJddTIjk=", "dev": true, - "optional": true, "requires": { "duplexify": "3.5.1", "glob-stream": "5.3.5", @@ -1081,7 +1048,6 @@ "resolved": "http://registry.npm.taobao.org/decompress-tar/download/decompress-tar-3.1.0.tgz", "integrity": "sha1-IXx4n5uURQ76rcXF5TeXj8MzxGY=", "dev": true, - "optional": true, "requires": { "is-tar": "1.0.0", "object-assign": "2.1.1", @@ -1095,29 +1061,25 @@ "version": "0.2.0", "resolved": "http://registry.npm.taobao.org/clone/download/clone-0.2.0.tgz", "integrity": "sha1-xhJqkK1Pctv1rNskPMN3JP6T/B8=", - "dev": true, - "optional": true + "dev": true }, "isarray": { "version": "0.0.1", "resolved": "http://registry.npm.taobao.org/isarray/download/isarray-0.0.1.tgz", "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true, - "optional": true + "dev": true }, "object-assign": { "version": "2.1.1", "resolved": "http://registry.npm.taobao.org/object-assign/download/object-assign-2.1.1.tgz", "integrity": "sha1-Q8NuXVaf+OSBbE76i+AtJpZ8GKo=", - "dev": true, - "optional": true + "dev": true }, "readable-stream": { "version": "1.0.34", "resolved": "http://registry.npm.taobao.org/readable-stream/download/readable-stream-1.0.34.tgz", "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", "dev": true, - "optional": true, "requires": { "core-util-is": "1.0.2", "inherits": "2.0.3", @@ -1129,15 +1091,13 @@ "version": "0.10.31", "resolved": "http://registry.npm.taobao.org/string_decoder/download/string_decoder-0.10.31.tgz", "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", - "dev": true, - "optional": true + "dev": true }, "through2": { "version": "0.6.5", "resolved": "http://registry.npm.taobao.org/through2/download/through2-0.6.5.tgz", "integrity": "sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=", "dev": true, - "optional": true, "requires": { "readable-stream": "1.0.34", "xtend": "4.0.1" @@ -1148,7 +1108,6 @@ "resolved": "http://registry.npm.taobao.org/vinyl/download/vinyl-0.4.6.tgz", "integrity": "sha1-LzVsh6VQolVGHza76ypbqL94SEc=", "dev": true, - "optional": true, "requires": { "clone": "0.2.0", "clone-stats": "0.0.1" @@ -1161,7 +1120,6 @@ "resolved": "http://registry.npm.taobao.org/decompress-tarbz2/download/decompress-tarbz2-3.1.0.tgz", "integrity": "sha1-iyOTVoE1X58YnYclag+L3ZbZZm0=", "dev": true, - "optional": true, "requires": { "is-bzip2": "1.0.0", "object-assign": "2.1.1", @@ -1176,29 +1134,25 @@ "version": "0.2.0", "resolved": "http://registry.npm.taobao.org/clone/download/clone-0.2.0.tgz", "integrity": "sha1-xhJqkK1Pctv1rNskPMN3JP6T/B8=", - "dev": true, - "optional": true + "dev": true }, "isarray": { "version": "0.0.1", "resolved": "http://registry.npm.taobao.org/isarray/download/isarray-0.0.1.tgz", "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true, - "optional": true + "dev": true }, "object-assign": { "version": "2.1.1", "resolved": "http://registry.npm.taobao.org/object-assign/download/object-assign-2.1.1.tgz", "integrity": "sha1-Q8NuXVaf+OSBbE76i+AtJpZ8GKo=", - "dev": true, - "optional": true + "dev": true }, "readable-stream": { "version": "1.0.34", "resolved": "http://registry.npm.taobao.org/readable-stream/download/readable-stream-1.0.34.tgz", "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", "dev": true, - "optional": true, "requires": { "core-util-is": "1.0.2", "inherits": "2.0.3", @@ -1210,15 +1164,13 @@ "version": "0.10.31", "resolved": "http://registry.npm.taobao.org/string_decoder/download/string_decoder-0.10.31.tgz", "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", - "dev": true, - "optional": true + "dev": true }, "through2": { "version": "0.6.5", "resolved": "http://registry.npm.taobao.org/through2/download/through2-0.6.5.tgz", "integrity": "sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=", "dev": true, - "optional": true, "requires": { "readable-stream": "1.0.34", "xtend": "4.0.1" @@ -1229,7 +1181,6 @@ "resolved": "http://registry.npm.taobao.org/vinyl/download/vinyl-0.4.6.tgz", "integrity": "sha1-LzVsh6VQolVGHza76ypbqL94SEc=", "dev": true, - "optional": true, "requires": { "clone": "0.2.0", "clone-stats": "0.0.1" @@ -1242,7 +1193,6 @@ "resolved": "http://registry.npm.taobao.org/decompress-targz/download/decompress-targz-3.1.0.tgz", "integrity": "sha1-ssE9+YFmJomRtxXWRH9kLpaW9aA=", "dev": true, - "optional": true, "requires": { "is-gzip": "1.0.0", "object-assign": "2.1.1", @@ -1256,29 +1206,25 @@ "version": "0.2.0", "resolved": "http://registry.npm.taobao.org/clone/download/clone-0.2.0.tgz", "integrity": "sha1-xhJqkK1Pctv1rNskPMN3JP6T/B8=", - "dev": true, - "optional": true + "dev": true }, "isarray": { "version": "0.0.1", "resolved": "http://registry.npm.taobao.org/isarray/download/isarray-0.0.1.tgz", "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true, - "optional": true + "dev": true }, "object-assign": { "version": "2.1.1", "resolved": "http://registry.npm.taobao.org/object-assign/download/object-assign-2.1.1.tgz", "integrity": "sha1-Q8NuXVaf+OSBbE76i+AtJpZ8GKo=", - "dev": true, - "optional": true + "dev": true }, "readable-stream": { "version": "1.0.34", "resolved": "http://registry.npm.taobao.org/readable-stream/download/readable-stream-1.0.34.tgz", "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", "dev": true, - "optional": true, "requires": { "core-util-is": "1.0.2", "inherits": "2.0.3", @@ -1290,15 +1236,13 @@ "version": "0.10.31", "resolved": "http://registry.npm.taobao.org/string_decoder/download/string_decoder-0.10.31.tgz", "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", - "dev": true, - "optional": true + "dev": true }, "through2": { "version": "0.6.5", "resolved": "http://registry.npm.taobao.org/through2/download/through2-0.6.5.tgz", "integrity": "sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=", "dev": true, - "optional": true, "requires": { "readable-stream": "1.0.34", "xtend": "4.0.1" @@ -1309,7 +1253,6 @@ "resolved": "http://registry.npm.taobao.org/vinyl/download/vinyl-0.4.6.tgz", "integrity": "sha1-LzVsh6VQolVGHza76ypbqL94SEc=", "dev": true, - "optional": true, "requires": { "clone": "0.2.0", "clone-stats": "0.0.1" @@ -1322,7 +1265,6 @@ "resolved": "http://registry.npm.taobao.org/decompress-unzip/download/decompress-unzip-3.4.0.tgz", "integrity": "sha1-YUdbQVIGa74/7hL51inRX+ZHjus=", "dev": true, - "optional": true, "requires": { "is-zip": "1.0.0", "read-all-stream": "3.1.0", @@ -1338,7 +1280,6 @@ "resolved": "http://registry.npm.taobao.org/vinyl/download/vinyl-1.2.0.tgz", "integrity": "sha1-XIgDbPVl5d8FVYv8kR+GVt8hiIQ=", "dev": true, - "optional": true, "requires": { "clone": "1.0.3", "clone-stats": "0.0.1", @@ -1351,8 +1292,7 @@ "version": "0.4.2", "resolved": "http://registry.npm.taobao.org/deep-extend/download/deep-extend-0.4.2.tgz", "integrity": "sha1-SLaZwn4zS/ifEIkr5DL25MfTSn8=", - "dev": true, - "optional": true + "dev": true }, "deep-is": { "version": "0.1.3", @@ -1404,7 +1344,7 @@ "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", "dev": true, "requires": { - "esutils": "^2.0.2" + "esutils": "2.0.2" } }, "download": { @@ -1412,7 +1352,6 @@ "resolved": "http://registry.npm.taobao.org/download/download/download-4.4.3.tgz", "integrity": "sha1-qlX9rTktldS2jowr4D4MKqIbqaw=", "dev": true, - "optional": true, "requires": { "caw": "1.2.0", "concat-stream": "1.6.0", @@ -1436,7 +1375,6 @@ "resolved": "http://registry.npm.taobao.org/glob/download/glob-5.0.15.tgz", "integrity": "sha1-G8k2ueAvSmA/zCIuz3Yz0wuLk7E=", "dev": true, - "optional": true, "requires": { "inflight": "1.0.6", "inherits": "2.0.3", @@ -1450,7 +1388,6 @@ "resolved": "http://registry.npm.taobao.org/glob-parent/download/glob-parent-3.1.0.tgz", "integrity": "sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4=", "dev": true, - "optional": true, "requires": { "is-glob": "3.1.0", "path-dirname": "1.0.2" @@ -1461,7 +1398,6 @@ "resolved": "http://registry.npm.taobao.org/glob-stream/download/glob-stream-5.3.5.tgz", "integrity": "sha1-pVZlqajM3EGRWofHAeMtTgFvrSI=", "dev": true, - "optional": true, "requires": { "extend": "3.0.1", "glob": "5.0.15", @@ -1478,7 +1414,6 @@ "resolved": "http://registry.npm.taobao.org/readable-stream/download/readable-stream-1.0.34.tgz", "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", "dev": true, - "optional": true, "requires": { "core-util-is": "1.0.2", "inherits": "2.0.3", @@ -1491,7 +1426,6 @@ "resolved": "http://registry.npm.taobao.org/through2/download/through2-0.6.5.tgz", "integrity": "sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=", "dev": true, - "optional": true, "requires": { "readable-stream": "1.0.34", "xtend": "4.0.1" @@ -1503,15 +1437,13 @@ "version": "2.1.1", "resolved": "http://registry.npm.taobao.org/is-extglob/download/is-extglob-2.1.1.tgz", "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", - "dev": true, - "optional": true + "dev": true }, "is-glob": { "version": "3.1.0", "resolved": "http://registry.npm.taobao.org/is-glob/download/is-glob-3.1.0.tgz", "integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=", "dev": true, - "optional": true, "requires": { "is-extglob": "2.1.1" } @@ -1520,15 +1452,13 @@ "version": "0.0.1", "resolved": "http://registry.npm.taobao.org/isarray/download/isarray-0.0.1.tgz", "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true, - "optional": true + "dev": true }, "ordered-read-streams": { "version": "0.3.0", "resolved": "http://registry.npm.taobao.org/ordered-read-streams/download/ordered-read-streams-0.3.0.tgz", "integrity": "sha1-cTfmmzKYuzQiR6G77jiByA4v14s=", "dev": true, - "optional": true, "requires": { "is-stream": "1.1.0", "readable-stream": "2.3.3" @@ -1538,15 +1468,13 @@ "version": "0.10.31", "resolved": "http://registry.npm.taobao.org/string_decoder/download/string_decoder-0.10.31.tgz", "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", - "dev": true, - "optional": true + "dev": true }, "strip-bom": { "version": "2.0.0", "resolved": "http://registry.npm.taobao.org/strip-bom/download/strip-bom-2.0.0.tgz", "integrity": "sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4=", "dev": true, - "optional": true, "requires": { "is-utf8": "0.2.1" } @@ -1556,7 +1484,6 @@ "resolved": "http://registry.npm.taobao.org/unique-stream/download/unique-stream-2.2.1.tgz", "integrity": "sha1-WqADz76Uxf+GbE59ZouxxNuts2k=", "dev": true, - "optional": true, "requires": { "json-stable-stringify": "1.0.1", "through2-filter": "2.0.0" @@ -1567,7 +1494,6 @@ "resolved": "http://registry.npm.taobao.org/vinyl/download/vinyl-1.2.0.tgz", "integrity": "sha1-XIgDbPVl5d8FVYv8kR+GVt8hiIQ=", "dev": true, - "optional": true, "requires": { "clone": "1.0.3", "clone-stats": "0.0.1", @@ -1579,7 +1505,6 @@ "resolved": "http://registry.npm.taobao.org/vinyl-fs/download/vinyl-fs-2.4.4.tgz", "integrity": "sha1-vm/zJwy1Xf19MGNkDegfJddTIjk=", "dev": true, - "optional": true, "requires": { "duplexify": "3.5.1", "glob-stream": "5.3.5", @@ -1642,7 +1567,6 @@ "resolved": "http://registry.npm.taobao.org/duplexify/download/duplexify-3.5.1.tgz", "integrity": "sha1-ThUWvmiDi8kKSZlPCzmm5ZYL780=", "dev": true, - "optional": true, "requires": { "end-of-stream": "1.4.0", "inherits": "2.0.3", @@ -1655,7 +1579,6 @@ "resolved": "http://registry.npm.taobao.org/end-of-stream/download/end-of-stream-1.4.0.tgz", "integrity": "sha1-epDYM+/abPpurA9JSduw+tOmMgY=", "dev": true, - "optional": true, "requires": { "once": "1.4.0" } @@ -1667,7 +1590,6 @@ "resolved": "http://registry.npm.taobao.org/each-async/download/each-async-1.1.1.tgz", "integrity": "sha1-3uUim98KtrogEqOV4bhpq/iBNHM=", "dev": true, - "optional": true, "requires": { "onetime": "1.1.0", "set-immediate-shim": "1.0.1" @@ -1677,8 +1599,7 @@ "version": "1.1.0", "resolved": "http://registry.npm.taobao.org/onetime/download/onetime-1.1.0.tgz", "integrity": "sha1-ofeDj4MUxRbwXs78vEzP4EtO14k=", - "dev": true, - "optional": true + "dev": true } } }, @@ -1716,7 +1637,6 @@ "resolved": "http://registry.npm.taobao.org/error-ex/download/error-ex-1.3.1.tgz", "integrity": "sha1-+FWobOYa3E6GIcPNoh56dhLDqNw=", "dev": true, - "optional": true, "requires": { "is-arrayish": "0.2.1" } @@ -1787,43 +1707,43 @@ "integrity": "sha512-qy4i3wODqKMYfz9LUI8N2qYDkHkoieTbiHpMrYUI/WbjhXJQr7lI4VngixTgaG+yHX+NBCv7nW4hA0ShbvaNKw==", "dev": true, "requires": { - "ajv": "^5.3.0", - "babel-code-frame": "^6.22.0", - "chalk": "^2.1.0", - "concat-stream": "^1.6.0", - "cross-spawn": "^5.1.0", - "debug": "^3.1.0", - "doctrine": "^2.1.0", - "eslint-scope": "^3.7.1", - "eslint-visitor-keys": "^1.0.0", - "espree": "^3.5.2", - "esquery": "^1.0.0", - "esutils": "^2.0.2", - "file-entry-cache": "^2.0.0", - "functional-red-black-tree": "^1.0.1", - "glob": "^7.1.2", - "globals": "^11.0.1", - "ignore": "^3.3.3", - "imurmurhash": "^0.1.4", - "inquirer": "^3.0.6", - "is-resolvable": "^1.0.0", - "js-yaml": "^3.9.1", - "json-stable-stringify-without-jsonify": "^1.0.1", - "levn": "^0.3.0", - "lodash": "^4.17.4", - "minimatch": "^3.0.2", - "mkdirp": "^0.5.1", - "natural-compare": "^1.4.0", - "optionator": "^0.8.2", - "path-is-inside": "^1.0.2", - "pluralize": "^7.0.0", - "progress": "^2.0.0", - "require-uncached": "^1.0.3", - "semver": "^5.3.0", - "strip-ansi": "^4.0.0", - "strip-json-comments": "~2.0.1", + "ajv": "5.5.2", + "babel-code-frame": "6.26.0", + "chalk": "2.3.0", + "concat-stream": "1.6.0", + "cross-spawn": "5.1.0", + "debug": "3.2.6", + "doctrine": "2.1.0", + "eslint-scope": "3.7.3", + "eslint-visitor-keys": "1.0.0", + "espree": "3.5.4", + "esquery": "1.0.1", + "esutils": "2.0.2", + "file-entry-cache": "2.0.0", + "functional-red-black-tree": "1.0.1", + "glob": "7.1.2", + "globals": "11.12.0", + "ignore": "3.3.10", + "imurmurhash": "0.1.4", + "inquirer": "3.3.0", + "is-resolvable": "1.1.0", + "js-yaml": "3.13.1", + "json-stable-stringify-without-jsonify": "1.0.1", + "levn": "0.3.0", + "lodash": "4.17.4", + "minimatch": "3.0.4", + "mkdirp": "0.5.1", + "natural-compare": "1.4.0", + "optionator": "0.8.2", + "path-is-inside": "1.0.2", + "pluralize": "7.0.0", + "progress": "2.0.3", + "require-uncached": "1.0.3", + "semver": "5.4.1", + "strip-ansi": "4.0.0", + "strip-json-comments": "2.0.1", "table": "4.0.2", - "text-table": "~0.2.0" + "text-table": "0.2.0" } }, "eslint-scope": { @@ -1832,8 +1752,8 @@ "integrity": "sha512-W+B0SvF4gamyCTmUc+uITPY0989iXVfKvhwtmJocTaYoc/3khEHmEmvfY/Gn9HA9VV75jrQECsHizkNw1b68FA==", "dev": true, "requires": { - "esrecurse": "^4.1.0", - "estraverse": "^4.1.1" + "esrecurse": "4.2.1", + "estraverse": "4.2.0" } }, "eslint-visitor-keys": { @@ -1941,8 +1861,8 @@ "integrity": "sha512-yAcIQxtmMiB/jL32dzEp2enBeidsB7xWPLNiw3IIkpVds1P+h7qF9YwJq1yUNzp2OKXgAprs4F61ih66UsoD1A==", "dev": true, "requires": { - "acorn": "^5.5.0", - "acorn-jsx": "^3.0.0" + "acorn": "5.7.3", + "acorn-jsx": "3.0.1" } }, "esprima": { @@ -1957,7 +1877,7 @@ "integrity": "sha512-SmiyZ5zIWH9VM+SRUReLS5Q8a7GxtRdxEBVZpm98rJM7Sb+A9DVCndXfkeFUd3byderg+EbDkfnevfCwynWaNA==", "dev": true, "requires": { - "estraverse": "^4.0.0" + "estraverse": "4.2.0" } }, "esrecurse": { @@ -1966,7 +1886,7 @@ "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", "dev": true, "requires": { - "estraverse": "^4.1.0" + "estraverse": "4.2.0" } }, "esshorten": { @@ -2089,7 +2009,6 @@ "resolved": "http://registry.npm.taobao.org/extend-shallow/download/extend-shallow-2.0.1.tgz", "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, - "optional": true, "requires": { "is-extendable": "0.1.1" } @@ -2171,7 +2090,6 @@ "resolved": "http://registry.npm.taobao.org/fd-slicer/download/fd-slicer-1.0.1.tgz", "integrity": "sha1-i1vL2ewyfFBBv5qwI/1nUPEXfmU=", "dev": true, - "optional": true, "requires": { "pend": "1.2.0" } @@ -2191,8 +2109,8 @@ "integrity": "sha1-w5KZDD5oR4PYOLjISkXYoEhFg2E=", "dev": true, "requires": { - "flat-cache": "^1.2.1", - "object-assign": "^4.0.1" + "flat-cache": "1.3.4", + "object-assign": "4.1.1" } }, "file-type": { @@ -2211,15 +2129,13 @@ "version": "1.0.0", "resolved": "http://registry.npm.taobao.org/filename-reserved-regex/download/filename-reserved-regex-1.0.0.tgz", "integrity": "sha1-5hz4BfDeHJhFZ9A4bcXfUO5a9+Q=", - "dev": true, - "optional": true + "dev": true }, "filenamify": { "version": "1.2.1", "resolved": "http://registry.npm.taobao.org/filenamify/download/filenamify-1.2.1.tgz", "integrity": "sha1-qfL/0RxQO+0wABUCknI3jx8TZaU=", "dev": true, - "optional": true, "requires": { "filename-reserved-regex": "1.0.0", "strip-outer": "1.0.0", @@ -2250,7 +2166,6 @@ "resolved": "http://registry.npm.taobao.org/find-up/download/find-up-1.1.2.tgz", "integrity": "sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8=", "dev": true, - "optional": true, "requires": { "path-exists": "2.1.0", "pinkie-promise": "2.0.1" @@ -2323,10 +2238,10 @@ "integrity": "sha512-VwyB3Lkgacfik2vhqR4uv2rvebqmDvFu4jlN/C1RzWoJEo8I7z4Q404oiqYCkq41mni8EzQnm95emU9seckwtg==", "dev": true, "requires": { - "circular-json": "^0.3.1", - "graceful-fs": "^4.1.2", - "rimraf": "~2.6.2", - "write": "^0.2.1" + "circular-json": "0.3.3", + "graceful-fs": "4.1.11", + "rimraf": "2.6.2", + "write": "0.2.1" } }, "for-in": { @@ -2407,7 +2322,6 @@ "resolved": "http://registry.npm.taobao.org/get-proxy/download/get-proxy-1.1.0.tgz", "integrity": "sha1-iUhUSRvFkbDxR9euVw9cZ4tyVus=", "dev": true, - "optional": true, "requires": { "rc": "1.2.2" } @@ -2416,8 +2330,7 @@ "version": "4.0.1", "resolved": "http://registry.npm.taobao.org/get-stdin/download/get-stdin-4.0.1.tgz", "integrity": "sha1-uWjGsKBDhDJJAui/Gl3zJXmkUP4=", - "dev": true, - "optional": true + "dev": true }, "get-stream": { "version": "3.0.0", @@ -2681,7 +2594,6 @@ "resolved": "http://registry.npm.taobao.org/got/download/got-5.7.1.tgz", "integrity": "sha1-X4FjWmHkplifGAVp6k44FoClHzU=", "dev": true, - "optional": true, "requires": { "create-error-class": "3.0.2", "duplexer2": "0.1.4", @@ -2705,7 +2617,6 @@ "resolved": "http://registry.npm.taobao.org/duplexer2/download/duplexer2-0.1.4.tgz", "integrity": "sha1-ixLauHjA1p4+eJEFFmKjL8a93ME=", "dev": true, - "optional": true, "requires": { "readable-stream": "2.3.3" } @@ -2786,7 +2697,6 @@ "resolved": "http://registry.npm.taobao.org/gulp-decompress/download/gulp-decompress-1.2.0.tgz", "integrity": "sha1-jutlpeAV+O2FMsr+KEVJYGJvDcc=", "dev": true, - "optional": true, "requires": { "archive-type": "3.2.0", "decompress": "3.0.0", @@ -2853,8 +2763,7 @@ "version": "1.2.2", "resolved": "http://registry.npm.taobao.org/gulp-rename/download/gulp-rename-1.2.2.tgz", "integrity": "sha1-OtRCh2PwXidk3sHGfYaNsnVoeBc=", - "dev": true, - "optional": true + "dev": true }, "gulp-replace": { "version": "0.6.1", @@ -2898,7 +2807,6 @@ "resolved": "http://registry.npm.taobao.org/gulp-sourcemaps/download/gulp-sourcemaps-1.6.0.tgz", "integrity": "sha1-uG/zSdgBzrVuHZ59x7vLS33uYAw=", "dev": true, - "optional": true, "requires": { "convert-source-map": "1.5.1", "graceful-fs": "4.1.11", @@ -2912,7 +2820,6 @@ "resolved": "http://registry.npm.taobao.org/strip-bom/download/strip-bom-2.0.0.tgz", "integrity": "sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4=", "dev": true, - "optional": true, "requires": { "is-utf8": "0.2.1" } @@ -2922,7 +2829,6 @@ "resolved": "http://registry.npm.taobao.org/vinyl/download/vinyl-1.2.0.tgz", "integrity": "sha1-XIgDbPVl5d8FVYv8kR+GVt8hiIQ=", "dev": true, - "optional": true, "requires": { "clone": "1.0.3", "clone-stats": "0.0.1", @@ -3045,8 +2951,7 @@ "version": "2.5.0", "resolved": "http://registry.npm.taobao.org/hosted-git-info/download/hosted-git-info-2.5.0.tgz", "integrity": "sha1-bWDjSzq7yDEwYsO3mO+NkBoHrzw=", - "dev": true, - "optional": true + "dev": true }, "html-comment-regex": { "version": "1.1.1", @@ -3210,7 +3115,6 @@ "resolved": "http://registry.npm.taobao.org/indent-string/download/indent-string-2.1.0.tgz", "integrity": "sha1-ji1INIdCEhtKghi3oTfppSBJ3IA=", "dev": true, - "optional": true, "requires": { "repeating": "2.0.1" } @@ -3241,20 +3145,20 @@ "integrity": "sha512-h+xtnyk4EwKvFWHrUYsWErEVR+igKtLdchu+o0Z1RL7VU/jVMFbYir2bp6bAj8efFNxWqHX0dIss6fJQ+/+qeQ==", "dev": true, "requires": { - "ansi-escapes": "^3.0.0", - "chalk": "^2.0.0", - "cli-cursor": "^2.1.0", - "cli-width": "^2.0.0", - "external-editor": "^2.0.4", - "figures": "^2.0.0", - "lodash": "^4.3.0", + "ansi-escapes": "3.2.0", + "chalk": "2.3.0", + "cli-cursor": "2.1.0", + "cli-width": "2.2.0", + "external-editor": "2.1.0", + "figures": "2.0.0", + "lodash": "4.17.4", "mute-stream": "0.0.7", - "run-async": "^2.2.0", - "rx-lite": "^4.0.8", - "rx-lite-aggregates": "^4.0.8", - "string-width": "^2.1.0", - "strip-ansi": "^4.0.0", - "through": "^2.3.6" + "run-async": "2.3.0", + "rx-lite": "4.0.8", + "rx-lite-aggregates": "4.0.8", + "string-width": "2.1.1", + "strip-ansi": "4.0.0", + "through": "2.3.8" } }, "interpret": { @@ -3296,8 +3200,7 @@ "version": "0.2.1", "resolved": "http://registry.npm.taobao.org/is-arrayish/download/is-arrayish-0.2.1.tgz", "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=", - "dev": true, - "optional": true + "dev": true }, "is-buffer": { "version": "1.1.6", @@ -3310,7 +3213,6 @@ "resolved": "http://registry.npm.taobao.org/is-builtin-module/download/is-builtin-module-1.0.0.tgz", "integrity": "sha1-VAVy0096wxGfj3bDDLwbHgN6/74=", "dev": true, - "optional": true, "requires": { "builtin-modules": "1.1.1" } @@ -3319,8 +3221,7 @@ "version": "1.0.0", "resolved": "http://registry.npm.taobao.org/is-bzip2/download/is-bzip2-1.0.0.tgz", "integrity": "sha1-XuWOqlounIDiFAe+3yOuWsCRs/w=", - "dev": true, - "optional": true + "dev": true }, "is-dotfile": { "version": "1.0.3", @@ -3354,7 +3255,6 @@ "resolved": "http://registry.npm.taobao.org/is-finite/download/is-finite-1.0.2.tgz", "integrity": "sha1-zGZ3aVYCvlUO8R6LSqYwU0K20Ko=", "dev": true, - "optional": true, "requires": { "number-is-nan": "1.0.1" } @@ -3385,8 +3285,7 @@ "version": "1.0.0", "resolved": "http://registry.npm.taobao.org/is-gzip/download/is-gzip-1.0.0.tgz", "integrity": "sha1-bKiwe5nHeZgCWQDlVc7Y7YCHmoM=", - "dev": true, - "optional": true + "dev": true }, "is-jpg": { "version": "1.0.0", @@ -3399,8 +3298,7 @@ "version": "2.1.1", "resolved": "http://registry.npm.taobao.org/is-natural-number/download/is-natural-number-2.1.1.tgz", "integrity": "sha1-fUxXKDd+84bD4ZSpkRv1fG3DNec=", - "dev": true, - "optional": true + "dev": true }, "is-number": { "version": "2.1.0", @@ -3415,8 +3313,7 @@ "version": "1.0.1", "resolved": "http://registry.npm.taobao.org/is-obj/download/is-obj-1.0.1.tgz", "integrity": "sha1-PkcprB9f3gJc19g6iW2rn09n2w8=", - "dev": true, - "optional": true + "dev": true }, "is-path-cwd": { "version": "1.0.0", @@ -3494,8 +3391,7 @@ "version": "1.0.0", "resolved": "http://registry.npm.taobao.org/is-redirect/download/is-redirect-1.0.0.tgz", "integrity": "sha1-HQPd7VO9jbDzDCbk+V02/HyH3CQ=", - "dev": true, - "optional": true + "dev": true }, "is-relative": { "version": "0.2.1", @@ -3516,8 +3412,7 @@ "version": "1.1.0", "resolved": "http://registry.npm.taobao.org/is-retry-allowed/download/is-retry-allowed-1.1.0.tgz", "integrity": "sha1-EaBgVotnM5REAz0BJaYaINVk+zQ=", - "dev": true, - "optional": true + "dev": true }, "is-stream": { "version": "1.1.0", @@ -3539,8 +3434,7 @@ "version": "1.0.0", "resolved": "http://registry.npm.taobao.org/is-tar/download/is-tar-1.0.0.tgz", "integrity": "sha1-L2suF5LB9bs2UZrKqdZcDSb+hT0=", - "dev": true, - "optional": true + "dev": true }, "is-unc-path": { "version": "0.1.2", @@ -3555,8 +3449,7 @@ "version": "1.2.2", "resolved": "http://registry.npm.taobao.org/is-url/download/is-url-1.2.2.tgz", "integrity": "sha1-SYkFpZO/R8wtnn9zg3K792lsfyY=", - "dev": true, - "optional": true + "dev": true }, "is-utf8": { "version": "0.2.1", @@ -3568,8 +3461,7 @@ "version": "0.3.0", "resolved": "http://registry.npm.taobao.org/is-valid-glob/download/is-valid-glob-0.3.0.tgz", "integrity": "sha1-1LVcafUYhvm2XHDWwmItN+KfSP4=", - "dev": true, - "optional": true + "dev": true }, "is-windows": { "version": "0.2.0", @@ -3581,8 +3473,7 @@ "version": "1.0.0", "resolved": "http://registry.npm.taobao.org/is-zip/download/is-zip-1.0.0.tgz", "integrity": "sha1-R7Co/004p2QxzP2ZqOFaTIa6IyU=", - "dev": true, - "optional": true + "dev": true }, "isarray": { "version": "1.0.0", @@ -3671,8 +3562,8 @@ "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", "dev": true, "requires": { - "argparse": "^1.0.7", - "esprima": "^4.0.0" + "argparse": "1.0.9", + "esprima": "4.0.0" } }, "json-schema-traverse": { @@ -3686,7 +3577,6 @@ "resolved": "http://registry.npm.taobao.org/json-stable-stringify/download/json-stable-stringify-1.0.1.tgz", "integrity": "sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8=", "dev": true, - "optional": true, "requires": { "jsonify": "0.0.0" } @@ -3701,8 +3591,7 @@ "version": "0.0.0", "resolved": "http://registry.npm.taobao.org/jsonify/download/jsonify-0.0.0.tgz", "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=", - "dev": true, - "optional": true + "dev": true }, "kind-of": { "version": "3.2.2", @@ -3731,7 +3620,6 @@ "resolved": "http://registry.npm.taobao.org/lazystream/download/lazystream-1.0.0.tgz", "integrity": "sha1-9plf4PggOS9hOWvolGJAe7dxaOQ=", "dev": true, - "optional": true, "requires": { "readable-stream": "2.3.3" } @@ -3768,7 +3656,6 @@ "resolved": "http://registry.npm.taobao.org/load-json-file/download/load-json-file-1.1.0.tgz", "integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=", "dev": true, - "optional": true, "requires": { "graceful-fs": "4.1.11", "parse-json": "2.2.0", @@ -3781,15 +3668,13 @@ "version": "2.3.0", "resolved": "http://registry.npm.taobao.org/pify/download/pify-2.3.0.tgz", "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", - "dev": true, - "optional": true + "dev": true }, "strip-bom": { "version": "2.0.0", "resolved": "http://registry.npm.taobao.org/strip-bom/download/strip-bom-2.0.0.tgz", "integrity": "sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4=", "dev": true, - "optional": true, "requires": { "is-utf8": "0.2.1" } @@ -3881,8 +3766,7 @@ "version": "4.5.0", "resolved": "http://registry.npm.taobao.org/lodash.isequal/download/lodash.isequal-4.5.0.tgz", "integrity": "sha1-QVxEePK8wwEgwizhDtMib30+GOA=", - "dev": true, - "optional": true + "dev": true }, "lodash.isplainobject": { "version": "4.0.6", @@ -3981,7 +3865,6 @@ "resolved": "http://registry.npm.taobao.org/loud-rejection/download/loud-rejection-1.6.0.tgz", "integrity": "sha1-W0b4AUft7leIcPCG0Eghz5mOVR8=", "dev": true, - "optional": true, "requires": { "currently-unhandled": "0.4.1", "signal-exit": "3.0.2" @@ -3997,8 +3880,7 @@ "version": "1.0.0", "resolved": "http://registry.npm.taobao.org/lowercase-keys/download/lowercase-keys-1.0.0.tgz", "integrity": "sha1-TjNms55/VFfjXxMkvfb4jQv8cwY=", - "dev": true, - "optional": true + "dev": true }, "lpad-align": { "version": "1.1.2", @@ -4042,8 +3924,7 @@ "version": "1.0.1", "resolved": "http://registry.npm.taobao.org/map-obj/download/map-obj-1.0.1.tgz", "integrity": "sha1-2TPOuSBdgr3PSIb2dCvcK03qFG0=", - "dev": true, - "optional": true + "dev": true }, "md5": { "version": "2.2.1", @@ -4061,7 +3942,6 @@ "resolved": "http://registry.npm.taobao.org/meow/download/meow-3.7.0.tgz", "integrity": "sha1-cstmi0JSKCkKu/qFaJJYcwioAfs=", "dev": true, - "optional": true, "requires": { "camelcase-keys": "2.1.0", "decamelize": "1.2.0", @@ -4079,8 +3959,7 @@ "version": "1.2.0", "resolved": "http://registry.npm.taobao.org/minimist/download/minimist-1.2.0.tgz", "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", - "dev": true, - "optional": true + "dev": true } } }, @@ -4089,7 +3968,6 @@ "resolved": "http://registry.npm.taobao.org/merge-stream/download/merge-stream-1.0.1.tgz", "integrity": "sha1-QEEgLVCKNCugAXQAjfDCUbjBNeE=", "dev": true, - "optional": true, "requires": { "readable-stream": "2.3.3" } @@ -4215,15 +4093,13 @@ "version": "1.0.0", "resolved": "http://registry.npm.taobao.org/node-status-codes/download/node-status-codes-1.0.0.tgz", "integrity": "sha1-WuVUHQJGRdMqWPzdyc7s6nrjrC8=", - "dev": true, - "optional": true + "dev": true }, "normalize-package-data": { "version": "2.4.0", "resolved": "http://registry.npm.taobao.org/normalize-package-data/download/normalize-package-data-2.4.0.tgz", "integrity": "sha1-EvlaMH1YNSB1oEkHuErIvpisAS8=", "dev": true, - "optional": true, "requires": { "hosted-git-info": "2.5.0", "is-builtin-module": "1.0.0", @@ -4254,8 +4130,7 @@ "version": "1.0.1", "resolved": "http://registry.npm.taobao.org/number-is-nan/download/number-is-nan-1.0.1.tgz", "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", - "dev": true, - "optional": true + "dev": true }, "object-assign": { "version": "4.1.1", @@ -4483,8 +4358,7 @@ "version": "1.0.0", "resolved": "http://registry.npm.taobao.org/p-finally/download/p-finally-1.0.0.tgz", "integrity": "sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4=", - "dev": true, - "optional": true + "dev": true }, "p-map": { "version": "1.2.0", @@ -4535,7 +4409,6 @@ "resolved": "http://registry.npm.taobao.org/parse-json/download/parse-json-2.2.0.tgz", "integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=", "dev": true, - "optional": true, "requires": { "error-ex": "1.3.1" } @@ -4550,15 +4423,13 @@ "version": "1.0.2", "resolved": "http://registry.npm.taobao.org/path-dirname/download/path-dirname-1.0.2.tgz", "integrity": "sha1-zDPSTVJeCZpTiMAzbG4yuRYGCeA=", - "dev": true, - "optional": true + "dev": true }, "path-exists": { "version": "2.1.0", "resolved": "http://registry.npm.taobao.org/path-exists/download/path-exists-2.1.0.tgz", "integrity": "sha1-D+tsZPD8UY2adU3V77YscCJ2H0s=", "dev": true, - "optional": true, "requires": { "pinkie-promise": "2.0.1" } @@ -4607,7 +4478,6 @@ "resolved": "http://registry.npm.taobao.org/path-type/download/path-type-1.1.0.tgz", "integrity": "sha1-WcRPfuSR2nBNpBXaWkBwuk+P5EE=", "dev": true, - "optional": true, "requires": { "graceful-fs": "4.1.11", "pify": "2.3.0", @@ -4618,8 +4488,7 @@ "version": "2.3.0", "resolved": "http://registry.npm.taobao.org/pify/download/pify-2.3.0.tgz", "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", - "dev": true, - "optional": true + "dev": true } } }, @@ -4627,8 +4496,7 @@ "version": "1.2.0", "resolved": "http://registry.npm.taobao.org/pend/download/pend-1.2.0.tgz", "integrity": "sha1-elfrVQpng/kRUzH89GY9XI4AelA=", - "dev": true, - "optional": true + "dev": true }, "pify": { "version": "3.0.0", @@ -4676,8 +4544,7 @@ "version": "1.0.4", "resolved": "http://registry.npm.taobao.org/prepend-http/download/prepend-http-1.0.4.tgz", "integrity": "sha1-1PRWKwzjaW5BrFLQ4ALlemNdxtw=", - "dev": true, - "optional": true + "dev": true }, "preserve": { "version": "0.2.0", @@ -4768,7 +4635,6 @@ "resolved": "http://registry.npm.taobao.org/rc/download/rc-1.2.2.tgz", "integrity": "sha1-2M6ctX6NZNnHut2YdsfDTL48cHc=", "dev": true, - "optional": true, "requires": { "deep-extend": "0.4.2", "ini": "1.3.5", @@ -4780,8 +4646,7 @@ "version": "1.2.0", "resolved": "http://registry.npm.taobao.org/minimist/download/minimist-1.2.0.tgz", "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", - "dev": true, - "optional": true + "dev": true } } }, @@ -4790,7 +4655,6 @@ "resolved": "http://registry.npm.taobao.org/read-all-stream/download/read-all-stream-3.1.0.tgz", "integrity": "sha1-NcPhd/IHjveJ7kv6+kNzB06u9Po=", "dev": true, - "optional": true, "requires": { "pinkie-promise": "2.0.1", "readable-stream": "2.3.3" @@ -4801,7 +4665,6 @@ "resolved": "http://registry.npm.taobao.org/read-pkg/download/read-pkg-1.1.0.tgz", "integrity": "sha1-9f+qXs0pyzHAR0vKfXVra7KePyg=", "dev": true, - "optional": true, "requires": { "load-json-file": "1.1.0", "normalize-package-data": "2.4.0", @@ -4813,7 +4676,6 @@ "resolved": "http://registry.npm.taobao.org/read-pkg-up/download/read-pkg-up-1.0.1.tgz", "integrity": "sha1-nWPBMnbAZZGNV/ACpX9AobZD+wI=", "dev": true, - "optional": true, "requires": { "find-up": "1.1.2", "read-pkg": "1.1.0" @@ -4848,7 +4710,6 @@ "resolved": "http://registry.npm.taobao.org/redent/download/redent-1.0.0.tgz", "integrity": "sha1-z5Fqsf1fHxbfsggi3W7H9zDCr94=", "dev": true, - "optional": true, "requires": { "indent-string": "2.1.0", "strip-indent": "1.0.1" @@ -4904,7 +4765,6 @@ "resolved": "http://registry.npm.taobao.org/repeating/download/repeating-2.0.1.tgz", "integrity": "sha1-UhTFOpJtNVJwdSf7q0FdvAjQbdo=", "dev": true, - "optional": true, "requires": { "is-finite": "1.0.2" } @@ -4932,8 +4792,8 @@ "integrity": "sha1-Tg1W1slmL9MeQwEcS5WqSZVUIdM=", "dev": true, "requires": { - "caller-path": "^0.1.0", - "resolve-from": "^1.0.0" + "caller-path": "0.1.0", + "resolve-from": "1.0.1" } }, "resolve": { @@ -5031,7 +4891,7 @@ "integrity": "sha1-dTuHqJoRyVRnxKwWJsTvxOBcZ74=", "dev": true, "requires": { - "rx-lite": "*" + "rx-lite": "4.0.8" } }, "safe-buffer": { @@ -5052,7 +4912,6 @@ "resolved": "http://registry.npm.taobao.org/seek-bzip/download/seek-bzip-1.0.5.tgz", "integrity": "sha1-z+kXyz0nS8/6x5J1ivUxc+sfq9w=", "dev": true, - "optional": true, "requires": { "commander": "2.8.1" } @@ -5090,8 +4949,7 @@ "version": "1.0.1", "resolved": "http://registry.npm.taobao.org/set-immediate-shim/download/set-immediate-shim-1.0.1.tgz", "integrity": "sha1-SysbJ+uAip+NzEgaWOXlb1mfP2E=", - "dev": true, - "optional": true + "dev": true }, "shebang-command": { "version": "1.2.0", @@ -5126,7 +4984,7 @@ "integrity": "sha512-POqxBK6Lb3q6s047D/XsDVNPnF9Dl8JSaqe9h9lURl0OdNqy/ujDrOiIHtsqXMGbWWTIomRzAMaTyawAU//Reg==", "dev": true, "requires": { - "is-fullwidth-code-point": "^2.0.0" + "is-fullwidth-code-point": "2.0.0" } }, "sort-keys": { @@ -5175,7 +5033,6 @@ "resolved": "http://registry.npm.taobao.org/spdx-correct/download/spdx-correct-1.0.2.tgz", "integrity": "sha1-SzBz2TP/UfORLwOsVRlJikFQ20A=", "dev": true, - "optional": true, "requires": { "spdx-license-ids": "1.2.2" } @@ -5184,15 +5041,13 @@ "version": "1.0.4", "resolved": "http://registry.npm.taobao.org/spdx-expression-parse/download/spdx-expression-parse-1.0.4.tgz", "integrity": "sha1-m98vIOH0DtRH++JzJmGR/O1RYmw=", - "dev": true, - "optional": true + "dev": true }, "spdx-license-ids": { "version": "1.2.2", "resolved": "http://registry.npm.taobao.org/spdx-license-ids/download/spdx-license-ids-1.2.2.tgz", "integrity": "sha1-yd96NCRZSt5r0RkA1ZZpbcBrrFc=", - "dev": true, - "optional": true + "dev": true }, "sprintf-js": { "version": "1.0.3", @@ -5242,15 +5097,13 @@ "version": "0.2.2", "resolved": "http://registry.npm.taobao.org/stat-mode/download/stat-mode-0.2.2.tgz", "integrity": "sha1-5sgLYjEj19gM8TLOU480YokHJQI=", - "dev": true, - "optional": true + "dev": true }, "stream-combiner2": { "version": "1.1.1", "resolved": "http://registry.npm.taobao.org/stream-combiner2/download/stream-combiner2-1.1.1.tgz", "integrity": "sha1-+02KFCDqNidk4hrUeAOXvry0HL4=", "dev": true, - "optional": true, "requires": { "duplexer2": "0.1.4", "readable-stream": "2.3.3" @@ -5261,7 +5114,6 @@ "resolved": "http://registry.npm.taobao.org/duplexer2/download/duplexer2-0.1.4.tgz", "integrity": "sha1-ixLauHjA1p4+eJEFFmKjL8a93ME=", "dev": true, - "optional": true, "requires": { "readable-stream": "2.3.3" } @@ -5278,8 +5130,7 @@ "version": "1.0.0", "resolved": "http://registry.npm.taobao.org/stream-shift/download/stream-shift-1.0.0.tgz", "integrity": "sha1-1cdSgl5TZ+eG944Y5EXqIjoVWVI=", - "dev": true, - "optional": true + "dev": true }, "string-template": { "version": "1.0.0", @@ -5347,7 +5198,6 @@ "resolved": "http://registry.npm.taobao.org/strip-bom-stream/download/strip-bom-stream-1.0.0.tgz", "integrity": "sha1-5xRDmFd9Uaa+0PoZlPoF9D/ZiO4=", "dev": true, - "optional": true, "requires": { "first-chunk-stream": "1.0.0", "strip-bom": "2.0.0" @@ -5358,7 +5208,6 @@ "resolved": "http://registry.npm.taobao.org/strip-bom/download/strip-bom-2.0.0.tgz", "integrity": "sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4=", "dev": true, - "optional": true, "requires": { "is-utf8": "0.2.1" } @@ -5370,7 +5219,6 @@ "resolved": "http://registry.npm.taobao.org/strip-dirs/download/strip-dirs-1.1.1.tgz", "integrity": "sha1-lgu9EoeETzl1pFWKoQOoJV4kVqA=", "dev": true, - "optional": true, "requires": { "chalk": "1.1.3", "get-stdin": "4.0.1", @@ -5385,7 +5233,6 @@ "resolved": "http://registry.npm.taobao.org/chalk/download/chalk-1.1.3.tgz", "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", "dev": true, - "optional": true, "requires": { "ansi-styles": "2.2.1", "escape-string-regexp": "1.0.5", @@ -5399,7 +5246,6 @@ "resolved": "http://registry.npm.taobao.org/is-absolute/download/is-absolute-0.1.7.tgz", "integrity": "sha1-hHSREZ/MtftDYhfMc39/qtUPYD8=", "dev": true, - "optional": true, "requires": { "is-relative": "0.1.3" } @@ -5408,22 +5254,19 @@ "version": "0.1.3", "resolved": "http://registry.npm.taobao.org/is-relative/download/is-relative-0.1.3.tgz", "integrity": "sha1-kF/uiuhvRbPsYUvDwVyGnfCHboI=", - "dev": true, - "optional": true + "dev": true }, "minimist": { "version": "1.2.0", "resolved": "http://registry.npm.taobao.org/minimist/download/minimist-1.2.0.tgz", "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", - "dev": true, - "optional": true + "dev": true }, "strip-ansi": { "version": "3.0.1", "resolved": "http://registry.npm.taobao.org/strip-ansi/download/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, - "optional": true, "requires": { "ansi-regex": "2.1.1" } @@ -5442,7 +5285,6 @@ "resolved": "http://registry.npm.taobao.org/strip-indent/download/strip-indent-1.0.1.tgz", "integrity": "sha1-DHlipq3vp7vUrDZkYKY4VSrhoKI=", "dev": true, - "optional": true, "requires": { "get-stdin": "4.0.1" } @@ -5458,7 +5300,6 @@ "resolved": "http://registry.npm.taobao.org/strip-outer/download/strip-outer-1.0.0.tgz", "integrity": "sha1-qsC6YNLpDF1PJ1/Yhp/ZotMQ/7g=", "dev": true, - "optional": true, "requires": { "escape-string-regexp": "1.0.5" } @@ -5468,7 +5309,6 @@ "resolved": "http://registry.npm.taobao.org/sum-up/download/sum-up-1.0.3.tgz", "integrity": "sha1-HGYfZnBX9jvLeHWqFDi8FiUlFW4=", "dev": true, - "optional": true, "requires": { "chalk": "1.1.3" }, @@ -5478,7 +5318,6 @@ "resolved": "http://registry.npm.taobao.org/chalk/download/chalk-1.1.3.tgz", "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", "dev": true, - "optional": true, "requires": { "ansi-styles": "2.2.1", "escape-string-regexp": "1.0.5", @@ -5492,7 +5331,6 @@ "resolved": "http://registry.npm.taobao.org/strip-ansi/download/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, - "optional": true, "requires": { "ansi-regex": "2.1.1" } @@ -5547,12 +5385,12 @@ "integrity": "sha512-UUkEAPdSGxtRpiV9ozJ5cMTtYiqz7Ni1OGqLXRCynrvzdtR1p+cfOWe2RJLwvUG8hNanaSRjecIqwOjqeatDsA==", "dev": true, "requires": { - "ajv": "^5.2.3", - "ajv-keywords": "^2.1.0", - "chalk": "^2.1.0", - "lodash": "^4.17.4", + "ajv": "5.5.2", + "ajv-keywords": "2.1.1", + "chalk": "2.3.0", + "lodash": "4.17.4", "slice-ansi": "1.0.0", - "string-width": "^2.1.1" + "string-width": "2.1.1" } }, "tar-stream": { @@ -5560,7 +5398,6 @@ "resolved": "http://registry.npm.taobao.org/tar-stream/download/tar-stream-1.5.5.tgz", "integrity": "sha1-XK2Ed59FyDsfJQjZawnYjHIYr1U=", "dev": true, - "optional": true, "requires": { "bl": "1.2.1", "end-of-stream": "1.4.0", @@ -5573,7 +5410,6 @@ "resolved": "http://registry.npm.taobao.org/end-of-stream/download/end-of-stream-1.4.0.tgz", "integrity": "sha1-epDYM+/abPpurA9JSduw+tOmMgY=", "dev": true, - "optional": true, "requires": { "once": "1.4.0" } @@ -5640,7 +5476,6 @@ "resolved": "http://registry.npm.taobao.org/through2-filter/download/through2-filter-2.0.0.tgz", "integrity": "sha1-YLxVoNrLdghdsfna6Zq0P4PWIuw=", "dev": true, - "optional": true, "requires": { "through2": "2.0.3", "xtend": "4.0.1" @@ -5665,8 +5500,7 @@ "version": "3.1.3", "resolved": "http://registry.npm.taobao.org/timed-out/download/timed-out-3.1.3.tgz", "integrity": "sha1-lYYL/MXHbCd/j4Mm/Q9bLiDrohc=", - "dev": true, - "optional": true + "dev": true }, "tmp": { "version": "0.0.33", @@ -5682,7 +5516,6 @@ "resolved": "http://registry.npm.taobao.org/to-absolute-glob/download/to-absolute-glob-0.1.1.tgz", "integrity": "sha1-HN+kcqnvUMI57maZm2YsoOs5k38=", "dev": true, - "optional": true, "requires": { "extend-shallow": "2.0.1" } @@ -5691,15 +5524,13 @@ "version": "1.0.0", "resolved": "http://registry.npm.taobao.org/trim-newlines/download/trim-newlines-1.0.0.tgz", "integrity": "sha1-WIeWa7WCpFA6QetST301ARgVphM=", - "dev": true, - "optional": true + "dev": true }, "trim-repeated": { "version": "1.0.0", "resolved": "http://registry.npm.taobao.org/trim-repeated/download/trim-repeated-1.0.0.tgz", "integrity": "sha1-42RqLqTokTEr9+rObPsFOAvAHCE=", "dev": true, - "optional": true, "requires": { "escape-string-regexp": "1.0.5" } @@ -5720,8 +5551,7 @@ "version": "0.4.3", "resolved": "http://registry.npm.taobao.org/tunnel-agent/download/tunnel-agent-0.4.3.tgz", "integrity": "sha1-Y3PbdpCf5XDgjXNYM2Xtgop07us=", - "dev": true, - "optional": true + "dev": true }, "type-check": { "version": "0.3.2", @@ -5786,8 +5616,7 @@ "version": "1.0.2", "resolved": "http://registry.npm.taobao.org/unzip-response/download/unzip-response-1.0.2.tgz", "integrity": "sha1-uYTwh3/AqJwsdzzB73tbIytbBv4=", - "dev": true, - "optional": true + "dev": true }, "upper-case": { "version": "1.1.3", @@ -5800,7 +5629,6 @@ "resolved": "http://registry.npm.taobao.org/url-parse-lax/download/url-parse-lax-1.0.0.tgz", "integrity": "sha1-evjzA2Rem9eaJy56FKxovAYJ2nM=", "dev": true, - "optional": true, "requires": { "prepend-http": "1.0.4" } @@ -5847,15 +5675,13 @@ "version": "1.0.0", "resolved": "http://registry.npm.taobao.org/vali-date/download/vali-date-1.0.0.tgz", "integrity": "sha1-G5BKWWCfsyjvB4E4Qgk09rhnCaY=", - "dev": true, - "optional": true + "dev": true }, "validate-npm-package-license": { "version": "3.0.1", "resolved": "http://registry.npm.taobao.org/validate-npm-package-license/download/validate-npm-package-license-3.0.1.tgz", "integrity": "sha1-KAS6vnEq0zeUWaz74kdGqywwP7w=", "dev": true, - "optional": true, "requires": { "spdx-correct": "1.0.2", "spdx-expression-parse": "1.0.4" @@ -5883,7 +5709,6 @@ "resolved": "http://registry.npm.taobao.org/vinyl-assign/download/vinyl-assign-1.2.1.tgz", "integrity": "sha1-TRmIkbVRWRHXcajNnFSApGoHSkU=", "dev": true, - "optional": true, "requires": { "object-assign": "4.1.1", "readable-stream": "2.3.3" @@ -6052,7 +5877,6 @@ "resolved": "http://registry.npm.taobao.org/ware/download/ware-1.3.0.tgz", "integrity": "sha1-0bFPOdLiy0q4xAmPdW/ksWTkc9Q=", "dev": true, - "optional": true, "requires": { "wrap-fn": "0.1.5" } @@ -6090,7 +5914,6 @@ "resolved": "http://registry.npm.taobao.org/wrap-fn/download/wrap-fn-0.1.5.tgz", "integrity": "sha1-8htuQQFv9KfjFyDbxjoJAWvfmEU=", "dev": true, - "optional": true, "requires": { "co": "3.1.0" }, @@ -6099,8 +5922,7 @@ "version": "3.1.0", "resolved": "http://registry.npm.taobao.org/co/download/co-3.1.0.tgz", "integrity": "sha1-TqVOpaCJOBUxheFSEMaNkJK8G3g=", - "dev": true, - "optional": true + "dev": true } } }, @@ -6115,7 +5937,7 @@ "integrity": "sha1-X8A4KOJkzqP+kUVUdvejxWbLB1c=", "dev": true, "requires": { - "mkdirp": "^0.5.1" + "mkdirp": "0.5.1" } }, "xml-char-classes": { @@ -6153,7 +5975,6 @@ "resolved": "http://registry.npm.taobao.org/yauzl/download/yauzl-2.9.1.tgz", "integrity": "sha1-qBmB6nCleUYTOIPwKcWCGok1mn8=", "dev": true, - "optional": true, "requires": { "buffer-crc32": "0.2.13", "fd-slicer": "1.0.1" diff --git a/HotUpdateDemo/tools/BuildBeforeSetting.js b/HotUpdateDemo/tools/BuildBeforeSetting.js new file mode 100644 index 0000000..578d819 --- /dev/null +++ b/HotUpdateDemo/tools/BuildBeforeSetting.js @@ -0,0 +1,21 @@ +const fileUtil = require('./FileUtil'); +let version, androidVersionXml; + +function initParams(configPath) { + let data = JSON.parse(fileUtil.read(configPath)); + version = data.version; + androidVersionXml = data.root + 'frameworks/runtime-src/proj.android/AndroidManifest.xml'; +} + +function repreatAndroidVersion(path) { + let old = fileUtil.read(path); + old = old.replace(/android:versionName="([1-9]\d|[1-9])(\.([1-9]\d|\d)){2}"/, `android:versionName="${version}"`); + let result = Buffer.from(old); + return fileUtil.write(path, result) +} + +function main(params) { + initParams('./GameConfig.json'); + //修改android 版本号 + repreatAndroidVersion(androidVersionXml); +} \ No newline at end of file diff --git a/HotUpdateDemo/tools/CopyHotFiles.js b/HotUpdateDemo/tools/CopyHotFiles.js new file mode 100644 index 0000000..05af35d --- /dev/null +++ b/HotUpdateDemo/tools/CopyHotFiles.js @@ -0,0 +1,33 @@ +const fileUtil = require('./FileUtil'); + +let hotUpdateRoot, hotUpdateDesRoot; +//要复制的目录 +const targetDir = ['res', 'src']; + +function initParams(configPath) { + let data = JSON.parse(fileUtil.read(configPath)); + hotUpdateRoot = data.src; + hotUpdateDesRoot = data.root + data.hotUpdateDirName; +} + +function forEachDir(list) { + for (let i = 0; i < list.length; i++) { + let item = list[i]; + let desPath = hotUpdateDesRoot + '/' + item; + let srcPath = hotUpdateRoot + item; + fileUtil.copyDir(srcPath, desPath); + } +} + +function main() { + initParams('./GameConfig.json'); + //消除目录文件 + fileUtil.checkDir(hotUpdateDesRoot); + forEachDir(targetDir); +} + +main(); + + + + diff --git a/HotUpdateDemo/tools/ExportHotupdateDir.js b/HotUpdateDemo/tools/ExportHotupdateDir.js new file mode 100644 index 0000000..7f1021a --- /dev/null +++ b/HotUpdateDemo/tools/ExportHotupdateDir.js @@ -0,0 +1,50 @@ +const fileUtil = require('./FileUtil'); + +let hotUpdateRoot, hotUpdateFile, exportHotUpdateDir, version, packageUrl; +const hotUpdateDir = 'hotUpdate', dirNameTemplate = 'hotUpdate-v', time = Date.parse(new Date()) / 1000; + +function initParams(configPath) { + let data = JSON.parse(fileUtil.read(configPath)); + hotUpdateRoot = data.src; + hotUpdateFile = hotUpdateRoot + data.hotUpdateDirName; + exportHotUpdateDir = hotUpdateRoot + data.hotupdateDirExport; + version = data.version; + packageUrl = data.packageUrl; +} + +function getVersion() { + return version.replace(/\./g, '-'); +} + +function reWritePackageUrl(dir, replaceName) { + let desPath = dir; + let game = fileUtil.read(desPath); + let conf = JSON.parse(game); + conf.packageUrl = conf.packageUrl.replace(hotUpdateDir, replaceName); + fileUtil.write(desPath, JSON.stringify(conf)); + return conf.packageUrl; +} + +function main() { + initParams('./GameConfig.json'); + const versionNo = getVersion(), dirName = `${dirNameTemplate}${versionNo}-${time}`; + + //消除目录文件 + fileUtil.checkDir(exportHotUpdateDir); + + let desPath = exportHotUpdateDir + '/' + dirName; + //复制到新目录 + fileUtil.copyDir(hotUpdateFile, desPath); + + //复制project.manifest/version.manifest + fileUtil.copy(hotUpdateFile + '/project.manifest', exportHotUpdateDir + '/project.manifest'); + fileUtil.copy(hotUpdateFile + '/version.manifest', exportHotUpdateDir + '/version.manifest'); + //修改project.manifest 中的packageUrl为新资源 + reWritePackageUrl(exportHotUpdateDir + '/project.manifest', dirName); +} + +main(); + + + + diff --git a/HotUpdateDemo/tools/FileUtil.js b/HotUpdateDemo/tools/FileUtil.js new file mode 100644 index 0000000..2e7f137 --- /dev/null +++ b/HotUpdateDemo/tools/FileUtil.js @@ -0,0 +1,143 @@ +const jetpack = require('fs-jetpack'); + +/** 以下所有方法均为同步 **/ +//参考 https://www.npmjs.com/package/fs-jetpack#removepath + +/** + * 读取文件 + * @param {*} path + * return string + */ +function read(path) { + const data = jetpack.read(path); + return data; +} + +function readDir(dir, fn) { + if (jetpack.exists(dir) == 'dir') { + let list = jetpack.list(dir); + for (let i = 0; i < list.length; i++) { + let name = list[i]; + if (name[0] === '.') continue; + let subPath = jetpack.path(dir, name); + if (jetpack.exists(subPath) == 'dir') { + readDir(subPath, fn); + } else if (jetpack.exists(subPath) == 'file') { + fn && fn(subPath); + } + } + } +} + +/** + * + * @param {*} path + * @param {*} data String, Buffer, Object or Array + */ +function write(path, data) { + jetpack.write(path, data); +} + +/** + * 取得该路径 文件类型 + * @param {*} path + * return + * false if path doesn't exist. + * "dir" if path is a directory. + * "file" if path is a file. + * "other" if none of the above. + */ +function exists(path) { + const state = jetpack.exists(path); + return state; +} + +/** + * 取得该路径下的文件与目录 + * 返回一个数组 + * 等同于 fs.readdir + * @param {*} path + */ +function list(path) { + const list = jetpack.list(path); + return list || []; +} + +/** + * 新建目录 + * @param {*} path + */ +function dir(path) { + jetpack.dir(path); +} + +/** + * 复制 文件 or 目录 + * @param {*} src + * @param {*} des + */ +function copy(src, des, isClear) { + if (isClear && jetpack.exists(des)) { + jetpack.remove(des); + } + //过滤文件 jetpack.copy('foo', 'bar', { matching: ['*.md', '!top-secret.md'] }); + jetpack.copy(src, des); +} + +/** + * 删除 文件 or 目录 + * @param {*} params + */ +function remove(path) { + jetpack.remove(path); +} + +/** + * 返回一个所在路径 + * @param {*} arg1 + * @param {*} arg2 + */ +function path(arg1, arg2) { + if (arguments.length == 0) {//当前路径 + const result = jetpack.path(); + return result; + } else if (arguments.length == 1) {//当前路径下的子目录 + const result = jetpack.path(arg1); + return result; + } else if (arguments.length = 2) { + const result = jetpack.path(arg1, arg2); + return result; + } +} + +function checkDir(dir) { + if (jetpack.exists(dir)) { + console.log('clear dir'); + jetpack.remove(dir); + } + jetpack.dir(dir); +} + +function copyDir(src, des, isClear) { + isClear && checkDir(des); + jetpack.copy(src, des); +} + +module.exports = { + read, + readDir, + write, + exists, + list, + dir, + copy, + remove, + path, + checkDir, + copyDir +} + + + + + diff --git a/HotUpdateDemo/tools/GameConfig.json b/HotUpdateDemo/tools/GameConfig.json new file mode 100644 index 0000000..55b3f2d --- /dev/null +++ b/HotUpdateDemo/tools/GameConfig.json @@ -0,0 +1,12 @@ +{ + "type": 1, + "version": "1.0.1", + "packageUrl": "http://localhost/hotUpdate/", + "root": "../build/jsb-link/", + "src": "../build/jsb-link/", + "hotUpdateDirName": "hotUpdateFiles", + "hotupdateDirExport": "exportHotUpdate", + "zipDir": [ + "/res/import" + ] +} \ No newline at end of file diff --git a/HotUpdateDemo/tools/ModifyFileTime.py b/HotUpdateDemo/tools/ModifyFileTime.py new file mode 100644 index 0000000..a525a59 --- /dev/null +++ b/HotUpdateDemo/tools/ModifyFileTime.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import os +import sys +import os.path +import json + +relativePath = '' +zipDirList = [] +TIMESTAMP = 1330712292 + + +def modifyFileTime(filePath, time): + # 修改访问和修改时间 + os.utime(filePath, (time, time)) + + +def modify(rootdir): + for parent, dirnames, filenames in os.walk(rootdir): + for filename in filenames: + print(os.path.join(parent, filename)) + path1 = os.path.join(parent, filename) + modifyFileTime(path1, TIMESTAMP) + + for parent, dirnames, filenames in os.walk(rootdir): + for filename in dirnames: + print(os.path.join(parent, filename)) + path1 = os.path.join(parent, filename) + modifyFileTime(path1, TIMESTAMP) + + +def initParams(configPath): + data = open(configPath, 'r') + data = json.load(data) + global relativePath + relativePath = data['root'] + data['hotUpdateDirName'] + global zipDirList + zipDirList = data['zipDir'] + des = data['des'] + + +def main(): + configPath = os.path.abspath(os.path.join( + os.getcwd(), "./GameConfig.json")) + initParams(configPath) + for dir in zipDirList: + abspath = os.path.abspath(os.path.join(os.getcwd(), relativePath+dir)) + print(abspath) + modify(abspath) + pass + + +main() diff --git a/HotUpdateDemo/tools/README.md b/HotUpdateDemo/tools/README.md new file mode 100644 index 0000000..9d6d82b --- /dev/null +++ b/HotUpdateDemo/tools/README.md @@ -0,0 +1,37 @@ +# 热更新工具说明 +* GameConfig.json 游戏版本、打包配置 +* BuildBeforeSetting.js 构建前准备工作 如:设置版本号,设置为正式服,等等~ +* FileUtil.js 文件操作工具类 +* CopyHotFiles.js 把需要热更文件复制到新文件夹 +* VersionGenerator.js 生成文件信息,作为版本资源对比。十分重要 +* ModifyFileTime.py 修改文件的生成时间 +* ZipFile.py 把文件压缩 + +### 准备 +* 操作系统:window +* 安装Node https://nodejs.org/zh-cn/ +* 安装Python 2.7 or 3.7 +* 以下操作都是基于android 打包 且模式为[link](https://docs.cocos.com/creator/manual/zh/publish/publish-native.html?h=link)。 +### 安装依赖 +* 打开命令行输入: +~~~ +npm install +~~~ +安装Node的库 fs-jetpack 用于对文件操作 + +### 操作 +首先进入tools +* 运行 BuildBeforeSetting.js 对项目初始化 +然后进行构建工程, +* 构建Android 工程 选择link模式 +![link](https://upload-images.jianshu.io/upload_images/2315803-f28aec8ccdff1858.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) +进入tools后 +* 运行CopyHotFiles.js 把热更新文件放到hotUpdateFiles文件夹 +* ModifyFileTime.py and ZipFile.py 对hotUpdateFiles中zipDir变量内文件修改时间(用于生成zip后,进行MD5后,md5信息不变)、zip压缩(用于更新时可以减少下载请求,提高热更速度、与更新文件的稳定性) +* 运行VersionGenerator.js 对hotUpdateFiles进行md5得到版本信息 +* 运行ExportHotupdateDir.js 得到热更新资源到exportHotUpdate文件夹 + +### 支持https +* 打开工程,修改libcocos2dx工程中Cocos2dxDownloader.java类。找到new AsyncHttpClient() 修改成new AsyncHttpClient(true, 80, 443) +* 参考文章:https://forum.cocos.com/t/https/52302 + diff --git a/HotUpdateDemo/tools/VersionGenerator.js b/HotUpdateDemo/tools/VersionGenerator.js new file mode 100644 index 0000000..7859969 --- /dev/null +++ b/HotUpdateDemo/tools/VersionGenerator.js @@ -0,0 +1,77 @@ +const fileUtil = require('./FileUtil'); +const crypto = require('crypto'); +const fs = require('fs'); +var path = require('path'); + +let manifest = { + packageUrl: 'http://localhost/tutorial-hot-update/remote-assets/', + remoteManifestUrl: 'http://localhost/tutorial-hot-update/remote-assets/project.manifest', + remoteVersionUrl: 'http://localhost/tutorial-hot-update/remote-assets/version.manifest', + version: '1.0.0', + assets: {}, + searchPaths: [] +}; + +let dest = './remote-assets/'; +let src = './jsb/'; + +function initParams(configPath) { + let data = JSON.parse(fileUtil.read(configPath)); + //得到远程url + manifest.packageUrl = data.packageUrl; + manifest.remoteManifestUrl = data.packageUrl + 'project.manifest'; + manifest.remoteVersionUrl = data.packageUrl + 'version.manifest'; + //版本信息 + manifest.version = data.version; + //构建后的对应目录 + src = data.root + data.hotUpdateDirName; + + //目的目录 + dest = src; +} + +function md5InfoFromDir(dir, obj) { + function fn(subPath) { + let stat, size, md5, compressed, relative; + stat = fs.statSync(subPath); + size = stat['size']; + // md5 = crypto.createHash('md5').update(fs.readFileSync(subpath, 'binary')).digest('hex');//返回的并非二进制类型,而是String。这会导致非文本文件md5计算错误 + md5 = crypto.createHash('md5').update(fs.readFileSync(subPath)).digest('hex'); + compressed = path.extname(subPath).toLowerCase() === '.zip'; + relative = path.relative(src, subPath); + relative = relative.replace(/\\/g, '/'); + relative = encodeURI(relative); + obj[relative] = { + 'size': size, + 'md5': md5 + }; + if (compressed) { + obj[relative].compressed = true; + } + } + fileUtil.readDir(dir, fn); +} + +function main() { + initParams('./GameConfig.json'); + + md5InfoFromDir(path.join(src, 'src'), manifest.assets); + md5InfoFromDir(path.join(src, 'res'), manifest.assets); + + let destManifest = path.join(dest, 'project.manifest'); + fileUtil.write(destManifest, JSON.stringify(manifest)); + + delete manifest.assets; + delete manifest.searchPaths; + + destVersion = path.join(dest, 'version.manifest'); + fileUtil.write(destVersion, JSON.stringify(manifest)); +} + +main(); + + + + + + diff --git a/HotUpdateDemo/tools/ZipFile.py b/HotUpdateDemo/tools/ZipFile.py new file mode 100644 index 0000000..5ede154 --- /dev/null +++ b/HotUpdateDemo/tools/ZipFile.py @@ -0,0 +1,90 @@ +import os +import os.path +import zipfile +import shutil +import json + +relativePath = '' +zipDirList = [] + + +def zip_dir(dirname, zipfilename): + filelist = [] + if os.path.isfile(dirname): + filelist.append(dirname) + else: + for root, dirs, files in os.walk(dirname): + for name in files: + filelist.append(os.path.join(root, name)) + + zf = zipfile.ZipFile(zipfilename, "w", zipfile.zlib.DEFLATED) + for tar in filelist: + arcname = tar[len(dirname):] + # print arcname + zf.write(tar, arcname) + zf.close() + + +def unzip_file(zipfilename, unziptodir): + if not os.path.exists(unziptodir): + os.mkdir(unziptodir, 777) + zfobj = zipfile.ZipFile(zipfilename) + for name in zfobj.namelist(): + name = name.replace('\\', '/') + + if name.endswith('/'): + os.mkdir(os.path.join(unziptodir, name)) + else: + ext_filename = os.path.join(unziptodir, name) + ext_dir = os.path.dirname(ext_filename) + if not os.path.exists(ext_dir): + os.mkdir(ext_dir, 777) + outfile = open(ext_filename, 'wb') + outfile.write(zfobj.read(name)) + outfile.close() + + +def encodeDir(rootdir): + for parent, dirnames, filenames in os.walk(rootdir): + print(parent, dirnames) + for dirname in dirnames: + print(parent) + print(dirname) + abspath = os.path.join(parent, dirname) + # finishPath=os.path.join() + zip_dir(abspath, abspath+'.zip') + deleteDir(abspath) + + +def deleteDir(dir): + if(os.path.exists(dir)): + shutil.rmtree(dir) + + +def checkDir(rootdir): + if os.path.exists(rootdir): + os.removedirs(rootdir) + os.makedirs(rootdir) + + +def initParams(configPath): + data = open(configPath, 'r') + data = json.load(data) + global relativePath + relativePath = data['root'] + data['hotUpdateDirName'] + global zipDirList + zipDirList = data['zipDir'] + + +def main(): + configPath = os.path.abspath(os.path.join( + os.getcwd(), "./GameConfig.json")) + initParams(configPath) + for dir in zipDirList: + abspath = os.path.abspath(os.path.join(os.getcwd(), relativePath+dir)) + print(abspath) + encodeDir(abspath) + pass + + +main() diff --git a/HotUpdateDemo/tools/version_generator.js b/HotUpdateDemo/tools/version_generator.js deleted file mode 100644 index 1a15683..0000000 --- a/HotUpdateDemo/tools/version_generator.js +++ /dev/null @@ -1,250 +0,0 @@ -var fs = require('fs'); -var path = require('path'); -var crypto = require('crypto'); -const jetpack = require('fs-jetpack'); - -var manifest = { - packageUrl: 'http://localhost/tutorial-hot-update/remote-assets/', - remoteManifestUrl: 'http://localhost/tutorial-hot-update/remote-assets/project.manifest', - remoteVersionUrl: 'http://localhost/tutorial-hot-update/remote-assets/version.manifest', - version: '1.0.0', - assets: {}, - searchPaths: [] -}; - -var dest = './remote-assets/'; -var src = './jsb/'; -var hotDir = null; -var packageRes = null; -// Parse arguments -var i = 2; -while (i < process.argv.length) { - var arg = process.argv[i]; - - switch (arg) { - case '--url': - case '-u': - var url = process.argv[i + 1]; - manifest.packageUrl = url; - manifest.remoteManifestUrl = url + 'project.manifest'; - manifest.remoteVersionUrl = url + 'version.manifest'; - i += 2; - break; - case '--version': - case '-v': - manifest.version = process.argv[i + 1]; - console.log('version=', manifest.version); - i += 2; - break; - case '--src': - case '-s': - src = process.argv[i + 1]; - hotDir = path.join(src, 'hotUpdate'); - console.log('hotDir=', hotDir); - packageRes = path.join(src, 'res'); - console.log('hpackageRes', packageRes); - i += 2; - break; - case '--dest': - case '-d': - dest = process.argv[i + 1]; - i += 2; - break; - default: - i += 2; - break; - } -} - -/** - * 读取文件到obj中 - * 过滤渠道json - * @param {*} dir - * @param {*} obj - */ -function readDir(dir, obj) { - console.log('readDir = ', dir); - var stat = fs.statSync(dir); - if (!stat.isDirectory()) { - return; - } - var subpaths = fs.readdirSync(dir), - subpath, size, md5, compressed, relative; - for (var i = 0; i < subpaths.length; ++i) { - if (subpaths[i][0] === '.') { - continue; - } - if (subpaths[i] == 'channel.json') { - console.log('---------------channel.json-------------------'); - continue; - } - subpath = path.join(dir, subpaths[i]); - stat = fs.statSync(subpath); - if (stat.isDirectory()) { - readDir(subpath, obj); - } else if (stat.isFile()) { - // Size in Bytes - size = stat['size']; - console.log('md5 ', subpath); - // md5 = crypto.createHash('md5').update(fs.readFileSync(subpath, 'binary')).digest('hex');//返回的并非二进制类型,而是String。这会导致非文本文件md5计算错误 - md5 = crypto.createHash('md5').update(fs.readFileSync(subpath)).digest('hex'); // - compressed = path.extname(subpath).toLowerCase() === '.zip'; - - relative = path.relative(src, subpath); - relative = relative.replace(/\\/g, '/'); - relative = encodeURI(relative); - obj[relative] = { - 'size': size, - 'md5': md5 - }; - if (compressed) { - obj[relative].compressed = true; - } - } - } -} - -//创建文件夹 -var mkdirSync = function (path) { - try { - fs.mkdirSync(path); - } catch (e) { - if (e.code != 'EEXIST') throw e; - } -}; - -// Iterate res and src folder -readDir(path.join(src, 'src'), manifest.assets); -readDir(path.join(src, 'res'), manifest.assets); - -var hotManifest = path.join(hotDir, 'project.manifest'); -var hotVersion = path.join(hotDir, 'version.manifest'); -var tmp = path.join(packageRes, 'raw-assets'); -var packageMenifest = path.join(tmp, 'project.manifest'); -console.log('packageMenifest', packageMenifest); -mkdirSync(dest); -//生成热更新目录 -mkdirSync(hotDir); - - -//生成文件manifest转成hotProject.js -let hotProjectPath = path.join(dest, 'hotManifest.js'); -console.log('create hotProject', hotProjectPath); -isfailed = fs.writeFileSync(hotProjectPath, 'module.exports = ' + JSON.stringify(manifest)); -if (!isfailed) { - console.log('hotManifest successfully generated'); -} - -//生成文件manifest到hotUpdate -isfailed = fs.writeFileSync(hotManifest, JSON.stringify(manifest)); -if (!isfailed) { - console.log('hotManifest successfully generated'); -} - -delete manifest.assets; -delete manifest.searchPaths; - -//生成版本manifest到hotUpdate -isfailed = fs.writeFileSync(hotVersion, JSON.stringify(manifest)); -if (isfailed) { - console.log('hotVersion successfully generated'); -} -/* - * 复制目录、子目录,及其中的文件 - * @param src {String} 要复制的目录 - * @param dist {String} 复制到目标目录 - */ -function copyDirSync(path, dest) { - let flist = jetpack.list(path) - for (let i = 0; i < flist.length; i++) { - let absolutePath = `${path}/${flist[i]}` - if (jetpack.exists(absolutePath) == "file") { // 是文件则复制 - jetpack.copy(absolutePath, `${dest}/${flist[i]}`, { - overwrite: true - }); - } - if (jetpack.exists(absolutePath) == "dir") { // 是目录则递归 - copyDirSync(absolutePath, `${dest}/${flist[i]}`) - } - } -} - -/** - * 删除目录 - */ -var rmdirSync = (function () { - /** - * 删除文件,如果是目录加入dirs 且进入 - * inner函数 - * @param {*} url - * @param {*} dirs - */ - function iterator(url, dirs) { - var stat = fs.statSync(url); - if (stat.isDirectory()) { - //收集目录 - dirs.unshift(url); - inner(url, dirs); - } else if (stat.isFile()) { - fs.unlinkSync(url); - } - } - /** - * - * @param {*} path - * @param {*} dirs - */ - function inner(path, dirs) { - var arr = fs.readdirSync(path); - for (var i = 0; i < arr.length; i++) { - iterator(path + '/' + arr[i], dirs); - } - } - return function (dir, cb) { - cb = cb || function () {}; - var dirs = []; - try { - //删除文件,得到目录 - iterator(dir, dirs); - //一次性删除所有收集到的目录 - for (var i = 0; i < dirs.length; i++) { - fs.rmdirSync(dirs[i]); - } - cb(); - } catch (error) { - //如果文件或目录本来就不存在,fs.statSync会报错,不过我们还是当成没有异常发生 - error.code === 'ENOENT' ? cb() : cb(error); - } - }; -})(); - -const srcPath = path.join(src, 'src'); -const resPath = path.join(src, 'res'); -const distSrcPath = path.join(hotDir, 'src'); -const distResPath = path.join(hotDir, 'res'); - -//复制src目录前,先删除原有目录 -rmdirSync(distSrcPath, (err) => { - err && console.log('err=', err); - console.log('delete success'); -}); - -//复制res目录前,先删除原有目录 -rmdirSync(distResPath, (err) => { - err && console.log('err=', err); - console.log('delete success'); -}); - -//复制src目录 -copyDirSync(srcPath, distSrcPath); -console.log('copy finish ', srcPath); - -//复制res目录 -copyDirSync(resPath, distResPath); -console.log('copy finish ', resPath); - -//把生成的maifest 同步到build\jsb-xxx\res\raw-assets 而不需要再次构建重新生成 -fs.writeFileSync(packageMenifest, fs.readFileSync(hotManifest)); -console.log(`copy hotupdate to ${packageMenifest} successful`); - -console.log('build hotupdte finish'); \ No newline at end of file diff --git a/Layered_virtual_list_2.x/README.md b/Layered_virtual_list_2.x/README.md new file mode 100644 index 0000000..09b0019 --- /dev/null +++ b/Layered_virtual_list_2.x/README.md @@ -0,0 +1,2 @@ +# hello-world +Hello world new project template. diff --git a/Layered_virtual_list_2.x/assets/Scene.meta b/Layered_virtual_list_2.x/assets/Scene.meta new file mode 100644 index 0000000..240fb44 --- /dev/null +++ b/Layered_virtual_list_2.x/assets/Scene.meta @@ -0,0 +1,13 @@ +{ + "ver": "1.1.3", + "uuid": "29f52784-2fca-467b-92e7-8fd9ef8c57b7", + "importer": "folder", + "isBundle": false, + "bundleName": "", + "priority": 1, + "compressionType": {}, + "optimizeHotUpdate": {}, + "inlineSpriteFrames": {}, + "isRemoteBundle": {}, + "subMetas": {} +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/assets/Scene/Demo.fire b/Layered_virtual_list_2.x/assets/Scene/Demo.fire new file mode 100644 index 0000000..d710ee2 --- /dev/null +++ b/Layered_virtual_list_2.x/assets/Scene/Demo.fire @@ -0,0 +1,2468 @@ +[ + { + "__type__": "cc.SceneAsset", + "_name": "", + "_objFlags": 0, + "_native": "", + "scene": { + "__id__": 1 + } + }, + { + "__type__": "cc.Scene", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + } + ], + "_active": false, + "_components": [], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_is3DNode": true, + "_groupIndex": 0, + "groupIndex": 0, + "autoReleaseAssets": false, + "_id": "ad26be66-5bff-4a2d-aa4c-87e71ad64839" + }, + { + "__type__": "cc.Node", + "_name": "Canvas", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 3 + }, + { + "__id__": 5 + }, + { + "__id__": 14 + }, + { + "__id__": 34 + }, + { + "__id__": 49 + } + ], + "_active": true, + "_components": [ + { + "__id__": 56 + }, + { + "__id__": 57 + }, + { + "__id__": 58 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 252, + "g": 252, + "b": 252, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 750, + "height": 1334 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 375, + 667, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "a286bbGknJLZpRpxROV6M94" + }, + { + "__type__": "cc.Node", + "_name": "Main Camera", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 4 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "09K3aRxxtPX4CkhgKEDjJC" + }, + { + "__type__": "cc.Camera", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 3 + }, + "_enabled": true, + "_cullingMask": 4294967295, + "_clearFlags": 7, + "_backgroundColor": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_depth": -1, + "_zoomRatio": 1, + "_targetTexture": null, + "_fov": 60, + "_orthoSize": 10, + "_nearClip": 1, + "_farClip": 4096, + "_ortho": true, + "_rect": { + "__type__": "cc.Rect", + "x": 0, + "y": 0, + "width": 1, + "height": 1 + }, + "_renderStages": 1, + "_alignWithScreen": true, + "_id": "39hvvfgtBNGI33C9knv3qJ" + }, + { + "__type__": "cc.Node", + "_name": "Horizontal", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [ + { + "__id__": 6 + } + ], + "_active": false, + "_components": [ + { + "__id__": 12 + }, + { + "__id__": 13 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 500, + "height": 1000 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "36VvP0G09KXaygeBwQJi38" + }, + { + "__type__": "cc.Node", + "_name": "view", + "_objFlags": 0, + "_parent": { + "__id__": 5 + }, + "_children": [ + { + "__id__": 7 + } + ], + "_active": true, + "_components": [ + { + "__id__": 10 + }, + { + "__id__": 11 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 500, + "height": 1000 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -250, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "5cVJZx64VDAbE0+GHS+ljM" + }, + { + "__type__": "cc.Node", + "_name": "content", + "_objFlags": 0, + "_parent": { + "__id__": 6 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 8 + }, + { + "__id__": 9 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 220, + "height": 1000 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "044WGrpVlJX6HvptTPUEC1" + }, + { + "__type__": "cc.Layout", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 7 + }, + "_enabled": true, + "_layoutSize": { + "__type__": "cc.Size", + "width": 220, + "height": 1000 + }, + "_resize": 1, + "_N$layoutType": 1, + "_N$cellSize": { + "__type__": "cc.Size", + "width": 40, + "height": 40 + }, + "_N$startAxis": 0, + "_N$paddingLeft": 0, + "_N$paddingRight": 0, + "_N$paddingTop": 0, + "_N$paddingBottom": 0, + "_N$spacingX": 0, + "_N$spacingY": 5, + "_N$verticalDirection": 1, + "_N$horizontalDirection": 0, + "_N$affectedByScale": false, + "_id": "55aN0610JMRq/gQKnyzhAY" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 7 + }, + "_enabled": true, + "alignMode": 1, + "_target": null, + "_alignFlags": 13, + "_left": 0, + "_right": 280, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 220, + "_originalHeight": 0, + "_id": "e4s1D76VBHvauUganIA4KW" + }, + { + "__type__": "cc.Mask", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 6 + }, + "_enabled": false, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_spriteFrame": null, + "_type": 0, + "_segments": 64, + "_N$alphaThreshold": 0, + "_N$inverted": false, + "_id": "bf6UMcWrhOr4jcJ8Xr/ccS" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 6 + }, + "_enabled": true, + "alignMode": 1, + "_target": null, + "_alignFlags": 45, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 240, + "_originalHeight": 250, + "_id": "795+OK4EFMo68XgmKpU2O+" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 5 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "9bbda31e-ad49-43c9-aaf2-f7d9896bac69" + }, + "_type": 1, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "27RDHW2iJEgbMioz+T5We3" + }, + { + "__type__": "cc.ScrollView", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 5 + }, + "_enabled": true, + "horizontal": true, + "vertical": false, + "inertia": true, + "brake": 0.75, + "elastic": true, + "bounceDuration": 0.23, + "scrollEvents": [], + "cancelInnerEvents": true, + "_N$content": { + "__id__": 7 + }, + "content": { + "__id__": 7 + }, + "_N$horizontalScrollBar": null, + "_N$verticalScrollBar": null, + "_id": "9f7KeQvGdBb42l9mua/S+H" + }, + { + "__type__": "cc.Node", + "_name": "parent", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [ + { + "__id__": 15 + }, + { + "__id__": 21 + }, + { + "__id__": 27 + } + ], + "_active": false, + "_components": [ + { + "__id__": 33 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 40, + "g": 168, + "b": 45, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 500, + "height": 500 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "4eapwQhy9FJr1oDtIF5XMt" + }, + { + "__type__": "cc.Node", + "_name": "1", + "_objFlags": 0, + "_parent": { + "__id__": 14 + }, + "_children": [ + { + "__id__": 16 + } + ], + "_active": true, + "_components": [ + { + "__id__": 19 + }, + { + "__id__": 20 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 100 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -80.714, + 123.761, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "cclp30DuxPI40Ql8RTgIp5" + }, + { + "__type__": "cc.Node", + "_name": "New Label", + "_objFlags": 0, + "_parent": { + "__id__": 15 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 17 + }, + { + "__id__": 18 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 22.25, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "d1NK110VBOjL8p0409QsTv" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 16 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_string": "1", + "_N$string": "1", + "_fontSize": 40, + "_lineHeight": 40, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_styleFlags": 0, + "_underlineHeight": 0, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 2, + "_id": "1ec9ZPVK9DiY33RUQtjAmR" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 16 + }, + "_enabled": true, + "renderZIndex": 0, + "syncInv": 0, + "_id": "28rh4vPCtDH7mfQfnunwP+" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 15 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "dctkJzgctIRbPAF7CX/X0D" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 15 + }, + "_enabled": true, + "renderZIndex": 0, + "syncInv": 0, + "_id": "34s75vARxOxYwCNg9irB9g" + }, + { + "__type__": "cc.Node", + "_name": "2", + "_objFlags": 0, + "_parent": { + "__id__": 14 + }, + "_children": [ + { + "__id__": 22 + } + ], + "_active": true, + "_components": [ + { + "__id__": 25 + }, + { + "__id__": 26 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 184, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 100 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -80.714, + 123.761, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "f3s/MnZNRHTIi/Q+H1UxKx" + }, + { + "__type__": "cc.Node", + "_name": "New Label", + "_objFlags": 0, + "_parent": { + "__id__": 21 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 23 + }, + { + "__id__": 24 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 22.25, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "d32B7NZuBGY63WBdbVTVyG" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 22 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_string": "2", + "_N$string": "2", + "_fontSize": 40, + "_lineHeight": 40, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_styleFlags": 0, + "_underlineHeight": 0, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 2, + "_id": "14NDOGnfhG9K+YOHXLcfhJ" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 22 + }, + "_enabled": true, + "renderZIndex": 0, + "syncInv": 0, + "_id": "3b2tZBLXFLfbVjUa9moptZ" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 21 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "56VszVbJ5PB7PzxYIgK1UZ" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 21 + }, + "_enabled": true, + "renderZIndex": 0, + "syncInv": 0, + "_id": "98jNMDg2NNpL0CwReAWY24" + }, + { + "__type__": "cc.Node", + "_name": "3", + "_objFlags": 0, + "_parent": { + "__id__": 14 + }, + "_children": [ + { + "__id__": 28 + } + ], + "_active": true, + "_components": [ + { + "__id__": 31 + }, + { + "__id__": 32 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 10, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 100 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -80.714, + 123.761, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "1e4i8OlSlN1L+L8ylsTJMp" + }, + { + "__type__": "cc.Node", + "_name": "New Label", + "_objFlags": 0, + "_parent": { + "__id__": 27 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 29 + }, + { + "__id__": 30 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 22.25, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "d8eW94wH5Emo/po5DP/fed" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 28 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_string": "3", + "_N$string": "3", + "_fontSize": 40, + "_lineHeight": 40, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_styleFlags": 0, + "_underlineHeight": 0, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 2, + "_id": "7fju1YtiROgKcUrz8Jbxoo" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 28 + }, + "_enabled": true, + "renderZIndex": 0, + "syncInv": 0, + "_id": "04gNKYOURMUYIzBSFmEZQb" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 27 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "e3/Rip1ZxCQrAeRRXarp6n" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 27 + }, + "_enabled": true, + "renderZIndex": 0, + "syncInv": 0, + "_id": "27WCjM2uhB5pVrJMpptJfp" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 14 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "69pO2jE6tFNr13iHtLu7XS" + }, + { + "__type__": "cc.Node", + "_name": "New ScrollView", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [ + { + "__id__": 35 + }, + { + "__id__": 41 + } + ], + "_active": true, + "_components": [ + { + "__id__": 48 + }, + { + "__id__": 39 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 750, + "height": 800 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "4eGuzFXoZNobw3BF4ASKAl" + }, + { + "__type__": "cc.Node", + "_name": "scrollBar", + "_objFlags": 512, + "_parent": { + "__id__": 34 + }, + "_children": [ + { + "__id__": 36 + } + ], + "_active": true, + "_components": [ + { + "__id__": 38 + }, + { + "__id__": 46 + }, + { + "__id__": 47 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 12, + "height": 800 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 1, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 375, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "8akGSmvKdGfpkBdpJRBHZE" + }, + { + "__type__": "cc.Node", + "_name": "bar", + "_objFlags": 512, + "_parent": { + "__id__": 35 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 37 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 10, + "height": 30 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 1, + "y": 0 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -1, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "7bmTftw15O4qa5K7nMaeeP" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 36 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "5c3bb932-6c3c-468f-88a9-c8c61d458641" + }, + "_type": 1, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "d1YRo81MlPh75Wn1ly3AHz" + }, + { + "__type__": "cc.Scrollbar", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 35 + }, + "_enabled": true, + "_scrollView": { + "__id__": 39 + }, + "_touching": false, + "_opacity": 255, + "enableAutoHide": true, + "autoHideTime": 1, + "_N$handle": { + "__id__": 37 + }, + "_N$direction": 1, + "_id": "0aw0b7ZDtMv4f4xfCJmUds" + }, + { + "__type__": "cc.ScrollView", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 34 + }, + "_enabled": true, + "horizontal": false, + "vertical": true, + "inertia": true, + "brake": 0.75, + "elastic": true, + "bounceDuration": 0.23, + "scrollEvents": [], + "cancelInnerEvents": true, + "_N$content": { + "__id__": 40 + }, + "content": { + "__id__": 40 + }, + "_N$horizontalScrollBar": null, + "_N$verticalScrollBar": { + "__id__": 38 + }, + "_id": "a15DEfCgFF96pX2ZD3tyRp" + }, + { + "__type__": "cc.Node", + "_name": "content", + "_objFlags": 0, + "_parent": { + "__id__": 41 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 44 + }, + { + "__id__": 45 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 750, + "height": 400 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 1 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 400, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "eaaskmjr1JNpm0IyW6NXUv" + }, + { + "__type__": "cc.Node", + "_name": "view", + "_objFlags": 512, + "_parent": { + "__id__": 34 + }, + "_children": [ + { + "__id__": 40 + }, + { + "__id__": 42 + } + ], + "_active": true, + "_components": [ + { + "__id__": 43 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 750, + "height": 800 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "0eJGBTx2lAfZ5rKiVwDRan" + }, + { + "__type__": "cc.Node", + "_name": "layer", + "_objFlags": 0, + "_parent": { + "__id__": 41 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "57l2vDrEVENoXOVjZya0Sq" + }, + { + "__type__": "cc.Mask", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 41 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_spriteFrame": null, + "_type": 0, + "_segments": 64, + "_N$alphaThreshold": 0, + "_N$inverted": false, + "_id": "eagMrCa6xBFYH2Zf5TZb6W" + }, + { + "__type__": "cc.Layout", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 40 + }, + "_enabled": true, + "_layoutSize": { + "__type__": "cc.Size", + "width": 750, + "height": 400 + }, + "_resize": 1, + "_N$layoutType": 2, + "_N$cellSize": { + "__type__": "cc.Size", + "width": 40, + "height": 40 + }, + "_N$startAxis": 0, + "_N$paddingLeft": 0, + "_N$paddingRight": 0, + "_N$paddingTop": 0, + "_N$paddingBottom": 0, + "_N$spacingX": 0, + "_N$spacingY": 10, + "_N$verticalDirection": 1, + "_N$horizontalDirection": 0, + "_N$affectedByScale": false, + "_id": "0a0C+3FExHp6QjuUrpje5d" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 40 + }, + "_enabled": true, + "alignMode": 1, + "_target": null, + "_alignFlags": 41, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 220, + "_originalHeight": 0, + "_id": "b0bf5HmcdPO6RE8va/SD78" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 35 + }, + "_enabled": true, + "alignMode": 0, + "_target": null, + "_alignFlags": 37, + "_left": 350.07654921020657, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 0, + "_originalHeight": 237, + "_id": "0aL6Pd3k1COanH0KlFfNJT" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 35 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "5fe5dcaa-b513-4dc5-a166-573627b3a159" + }, + "_type": 1, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "028UkzTehDxJuY5Slc8IhY" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 34 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "9bbda31e-ad49-43c9-aaf2-f7d9896bac69" + }, + "_type": 1, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "ffF25iPJlH+Kxp09D8v2RS" + }, + { + "__type__": "cc.Node", + "_name": "New Button", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [ + { + "__id__": 50 + } + ], + "_active": false, + "_components": [ + { + "__id__": 55 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + -488.632, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "4eYy0vpB1LBY2A3u7SD33M" + }, + { + "__type__": "cc.Node", + "_name": "Background", + "_objFlags": 512, + "_parent": { + "__id__": 49 + }, + "_children": [ + { + "__id__": 51 + } + ], + "_active": true, + "_components": [ + { + "__id__": 53 + }, + { + "__id__": 54 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 0 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "74AS41UFlDxoKuiVw7MDrT" + }, + { + "__type__": "cc.Node", + "_name": "Label", + "_objFlags": 512, + "_parent": { + "__id__": 50 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 52 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "01ioYlqgpO3Zz31GV3fSke" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 51 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_string": "button", + "_N$string": "button", + "_fontSize": 20, + "_lineHeight": 40, + "_enableWrapText": false, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_styleFlags": 0, + "_underlineHeight": 0, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 1, + "_N$cacheMode": 1, + "_id": "d8YhzvrDBC3pyKvNP8jM2s" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 50 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952" + }, + "_type": 1, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "3ahjbsxYVD0KHQ1J1t4rhw" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 50 + }, + "_enabled": true, + "alignMode": 0, + "_target": null, + "_alignFlags": 45, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 100, + "_originalHeight": 40, + "_id": "5fZebfqLxKXKIP0kbOHNfA" + }, + { + "__type__": "cc.Button", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 49 + }, + "_enabled": true, + "_normalMaterial": null, + "_grayMaterial": null, + "duration": 0.1, + "zoomScale": 1.2, + "clickEvents": [], + "_N$interactable": true, + "_N$enableAutoGrayEffect": false, + "_N$transition": 3, + "transition": 3, + "_N$normalColor": { + "__type__": "cc.Color", + "r": 230, + "g": 230, + "b": 230, + "a": 255 + }, + "_N$pressedColor": { + "__type__": "cc.Color", + "r": 200, + "g": 200, + "b": 200, + "a": 255 + }, + "pressedColor": { + "__type__": "cc.Color", + "r": 200, + "g": 200, + "b": 200, + "a": 255 + }, + "_N$hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$disabledColor": { + "__type__": "cc.Color", + "r": 120, + "g": 120, + "b": 120, + "a": 200 + }, + "_N$normalSprite": { + "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952" + }, + "_N$pressedSprite": { + "__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a" + }, + "pressedSprite": { + "__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a" + }, + "_N$hoverSprite": { + "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952" + }, + "hoverSprite": { + "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952" + }, + "_N$disabledSprite": { + "__uuid__": "29158224-f8dd-4661-a796-1ffab537140e" + }, + "_N$target": { + "__id__": 50 + }, + "_id": "caKLIVawdPZ64Zt8ZkLprq" + }, + { + "__type__": "cc.Canvas", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "_designResolution": { + "__type__": "cc.Size", + "width": 750, + "height": 1334 + }, + "_fitWidth": true, + "_fitHeight": false, + "_id": "dfvGuB0gdP+bfdBA5GrvZn" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "alignMode": 1, + "_target": null, + "_alignFlags": 45, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 0, + "_originalHeight": 0, + "_id": "ddKTtCCMFIwpiha8iT+uxE" + }, + { + "__type__": "b9be0tgoIVPk72LiE6N39f/", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "scrollView": { + "__id__": 39 + }, + "prefab": { + "__uuid__": "3a3767fc-5a7c-4f4b-b174-8f4038113095" + }, + "layer": { + "__id__": 42 + }, + "_id": "7fT97q3OtHbLCfyWtjclN3" + } +] \ No newline at end of file diff --git a/Layered_virtual_list_2.x/assets/Scene/Demo.fire.meta b/Layered_virtual_list_2.x/assets/Scene/Demo.fire.meta new file mode 100644 index 0000000..bacc131 --- /dev/null +++ b/Layered_virtual_list_2.x/assets/Scene/Demo.fire.meta @@ -0,0 +1,8 @@ +{ + "ver": "1.3.2", + "uuid": "ad26be66-5bff-4a2d-aa4c-87e71ad64839", + "importer": "scene", + "asyncLoadAssets": false, + "autoReleaseAssets": false, + "subMetas": {} +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/assets/Scene/Item.prefab b/Layered_virtual_list_2.x/assets/Scene/Item.prefab new file mode 100644 index 0000000..f8e25b7 --- /dev/null +++ b/Layered_virtual_list_2.x/assets/Scene/Item.prefab @@ -0,0 +1,992 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "asyncLoadAssets": false, + "readonly": false + }, + { + "__type__": "cc.Node", + "_name": "Item", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + }, + { + "__id__": 6 + }, + { + "__id__": 11 + }, + { + "__id__": 23 + } + ], + "_active": true, + "_components": [ + { + "__id__": 28 + } + ], + "_prefab": { + "__id__": 29 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 750, + "height": 80 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 1 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bg", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 3 + }, + { + "__id__": 4 + } + ], + "_prefab": { + "__id__": 5 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 48, + "g": 147, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 750, + "height": 80 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + -40, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "alignMode": 2, + "_target": null, + "_alignFlags": 45, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 100, + "_originalHeight": 100, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "2fWAV/kSxKbLNNotfg0pAI", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "nameLb", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 7 + }, + { + "__id__": 8 + }, + { + "__id__": 9 + } + ], + "_prefab": { + "__id__": 10 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 142.25, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -261.821, + -45.115, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 6 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_string": "我是第1", + "_N$string": "我是第1", + "_fontSize": 40, + "_lineHeight": 40, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_styleFlags": 1, + "_underlineHeight": 0, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 2, + "_id": "" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 6 + }, + "_enabled": true, + "renderZIndex": 1, + "syncInv": 0.01, + "_id": "" + }, + { + "__type__": "cc.LabelShadow", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 6 + }, + "_enabled": true, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_offset": { + "__type__": "cc.Vec2", + "x": 2, + "y": -5 + }, + "_blur": 2, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "50Nr1a5SVMCLPTFU4WTSCP", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "New Button", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 12 + } + ], + "_active": true, + "_components": [ + { + "__id__": 21 + } + ], + "_prefab": { + "__id__": 22 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -106.669, + -44.121, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Background", + "_objFlags": 0, + "_parent": { + "__id__": 11 + }, + "_children": [ + { + "__id__": 13 + } + ], + "_active": true, + "_components": [ + { + "__id__": 17 + }, + { + "__id__": 18 + }, + { + "__id__": 19 + } + ], + "_prefab": { + "__id__": 20 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 0 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Label", + "_objFlags": 0, + "_parent": { + "__id__": 12 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 14 + }, + { + "__id__": 15 + } + ], + "_prefab": { + "__id__": 16 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 13 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_string": "button", + "_N$string": "button", + "_fontSize": 20, + "_lineHeight": 40, + "_enableWrapText": false, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_styleFlags": 0, + "_underlineHeight": 0, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 1, + "_N$cacheMode": 2, + "_id": "" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 13 + }, + "_enabled": true, + "renderZIndex": 1, + "syncInv": 0.01, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "12747hBa5Ok7wyGD/cQP/v", + "sync": false + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 12 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952" + }, + "_type": 1, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 12 + }, + "_enabled": true, + "alignMode": 0, + "_target": null, + "_alignFlags": 45, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 100, + "_originalHeight": 40, + "_id": "" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 12 + }, + "_enabled": true, + "renderZIndex": 0, + "syncInv": 0.01, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "b2yBk+BHFOF7B8n1gYypgp", + "sync": false + }, + { + "__type__": "cc.Button", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 11 + }, + "_enabled": true, + "_normalMaterial": null, + "_grayMaterial": null, + "duration": 0.1, + "zoomScale": 1.2, + "clickEvents": [], + "_N$interactable": true, + "_N$enableAutoGrayEffect": false, + "_N$transition": 3, + "transition": 3, + "_N$normalColor": { + "__type__": "cc.Color", + "r": 230, + "g": 230, + "b": 230, + "a": 255 + }, + "_N$pressedColor": { + "__type__": "cc.Color", + "r": 200, + "g": 200, + "b": 200, + "a": 255 + }, + "pressedColor": { + "__type__": "cc.Color", + "r": 200, + "g": 200, + "b": 200, + "a": 255 + }, + "_N$hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$disabledColor": { + "__type__": "cc.Color", + "r": 120, + "g": 120, + "b": 120, + "a": 200 + }, + "_N$normalSprite": { + "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952" + }, + "_N$pressedSprite": { + "__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a" + }, + "pressedSprite": { + "__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a" + }, + "_N$hoverSprite": { + "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952" + }, + "hoverSprite": { + "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952" + }, + "_N$disabledSprite": { + "__uuid__": "29158224-f8dd-4661-a796-1ffab537140e" + }, + "_N$target": { + "__id__": 12 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "14TO6K8WlMjp8gwgtWA0qf", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "contentLb", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 24 + }, + { + "__id__": 25 + }, + { + "__id__": 26 + } + ], + "_prefab": { + "__id__": 27 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 333.07, + "height": 44 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 151.722, + -43.961, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 23 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_string": "ScrollView content", + "_N$string": "ScrollView content", + "_fontSize": 40, + "_lineHeight": 40, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_styleFlags": 0, + "_underlineHeight": 0, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 2, + "_id": "" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 23 + }, + "_enabled": true, + "renderZIndex": 1, + "syncInv": 0.01, + "_id": "" + }, + { + "__type__": "cc.LabelOutline", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 23 + }, + "_enabled": true, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_width": 2, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "41ShEz5VJCm68duiIf01ZR", + "sync": false + }, + { + "__type__": "7e1f6lmx11Hho9BNV3MqKkZ", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "nameLb": { + "__id__": 7 + }, + "contentLb": { + "__id__": 24 + }, + "Button": { + "__id__": 11 + }, + "ButtonLb": { + "__id__": 14 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "", + "sync": false + } +] \ No newline at end of file diff --git a/Layered_virtual_list_2.x/assets/Scene/Item.prefab.meta b/Layered_virtual_list_2.x/assets/Scene/Item.prefab.meta new file mode 100644 index 0000000..192f01b --- /dev/null +++ b/Layered_virtual_list_2.x/assets/Scene/Item.prefab.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.3.2", + "uuid": "3a3767fc-5a7c-4f4b-b174-8f4038113095", + "importer": "prefab", + "optimizationPolicy": "AUTO", + "asyncLoadAssets": false, + "readonly": false, + "subMetas": {} +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/assets/Scene/Item.ts b/Layered_virtual_list_2.x/assets/Scene/Item.ts new file mode 100644 index 0000000..5dc360a --- /dev/null +++ b/Layered_virtual_list_2.x/assets/Scene/Item.ts @@ -0,0 +1,41 @@ +import RenderAlternativeItem from "../Script/RenderAlternativeItem"; + + +const { ccclass, property } = cc._decorator; + +@ccclass +export default class Item extends RenderAlternativeItem { + + /** */ + @property(cc.Label) + public nameLb: cc.Label = null; + /** */ + @property(cc.Label) + public contentLb: cc.Label = null; + /** */ + @property(cc.Node) + public Button: cc.Node = null; + /** */ + @property(cc.Label) + public ButtonLb: cc.Label = null; + + data: any = null; + + init(data: any) { + this.data = data.data; + let layer = data.layer; + this.initRenderLayer(layer); + this.initShow(); + } + + /** + * 初始化显示 + * @param data + */ + initShow() { + this.nameLb.string = "我是第" + this.data.index + "个"; + this.contentLb.string = "我是内容" + this.data.name; + } + + // update (dt) {} +} diff --git a/Layered_virtual_list_2.x/assets/Scene/Item.ts.meta b/Layered_virtual_list_2.x/assets/Scene/Item.ts.meta new file mode 100644 index 0000000..b74f950 --- /dev/null +++ b/Layered_virtual_list_2.x/assets/Scene/Item.ts.meta @@ -0,0 +1,10 @@ +{ + "ver": "1.1.0", + "uuid": "7e1f6966-c75d-4786-8f41-355dcca8a919", + "importer": "typescript", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/assets/Scene/TestLoop.ts b/Layered_virtual_list_2.x/assets/Scene/TestLoop.ts new file mode 100644 index 0000000..ebde452 --- /dev/null +++ b/Layered_virtual_list_2.x/assets/Scene/TestLoop.ts @@ -0,0 +1,64 @@ + + +import LoopList from '../Script/LoopList'; +import { IData } from './TestShowNode'; +const { ccclass, property } = cc._decorator; + +@ccclass +export class TestLoop extends cc.Component { + /**分层渲染节点 */ + @property(cc.Node) + public rendeLayer: cc.Node = null; + /**显示节点预制件 */ + @property(cc.ScrollView) + public scrollView: cc.ScrollView = null; + /**显示节点预制件 */ + @property(cc.Prefab) + public showPrefab: cc.Prefab = null; + + start() { + //测试横向宽高数据 + /* let baseWidth = 80; + let changeWidth = 20; + let baseHeight = 600; + let changeHeight = 150; + let anchor = cc.v2(0.5, 0.5) */ + + //测试纵向宽高数据 + let baseWidth = 600; + let changeWidth = 150; + let baseHeight = 80; + let changeHeight = 20; + let anchor = cc.v2(0.5, 0.5); + + let data: IData[] = []; + for (let i = 0, len = 30; i < len; ++i) { + data.push({ + index: i, text: "内容" + i + }); + } + LoopList.ins("Test").init(this.scrollView, this.rendeLayer, 18); + LoopList.ins("Test").initData(data, this.showPrefab, cc.size(baseWidth, baseHeight), anchor); + + /* //测试插入数据 + this.scheduleOnce(() => { + LoopList.ins("Test").insertData({ index: 1, text: "我是插入1", size: cc.size(baseWidth, baseHeight) }, 1); + }, 3) + + //测试压入数据 + this.scheduleOnce(() => { + LoopList.ins("Test").pushDatas([ + { index: 1, text: "我是压入1", size: cc.size(baseWidth, baseHeight) }, + { index: 2, text: "我是压入2", size: cc.size(baseWidth, baseHeight) }, + { index: 3, text: "我是压入3", size: cc.size(baseWidth, baseHeight) }, + ]); + }, 4) + + //测试压入数据 + this.scheduleOnce(() => { + LoopList.ins("Test").removeData(1); + }, 5) */ + } +} + + diff --git a/Layered_virtual_list_2.x/assets/Scene/TestLoop.ts.meta b/Layered_virtual_list_2.x/assets/Scene/TestLoop.ts.meta new file mode 100644 index 0000000..3f1222a --- /dev/null +++ b/Layered_virtual_list_2.x/assets/Scene/TestLoop.ts.meta @@ -0,0 +1,10 @@ +{ + "ver": "1.1.0", + "uuid": "4850b0af-dba5-44dc-b723-5907091dc85e", + "importer": "typescript", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/assets/Scene/TestMatrix.fire b/Layered_virtual_list_2.x/assets/Scene/TestMatrix.fire new file mode 100644 index 0000000..4c962c7 --- /dev/null +++ b/Layered_virtual_list_2.x/assets/Scene/TestMatrix.fire @@ -0,0 +1,653 @@ +[ + { + "__type__": "cc.SceneAsset", + "_name": "", + "_objFlags": 0, + "_native": "", + "scene": { + "__id__": 1 + } + }, + { + "__type__": "cc.Scene", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + } + ], + "_active": true, + "_components": [], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_is3DNode": true, + "_groupIndex": 0, + "groupIndex": 0, + "autoReleaseAssets": false, + "_id": "3ed1232c-1b00-4818-8d5e-2112f30b11a4" + }, + { + "__type__": "cc.Node", + "_name": "Canvas", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 3 + }, + { + "__id__": 5 + }, + { + "__id__": 9 + } + ], + "_active": true, + "_components": [ + { + "__id__": 12 + }, + { + "__id__": 13 + }, + { + "__id__": 14 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 1334, + "height": 750 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 667, + 375, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "a5esZu+45LA5mBpvttspPD" + }, + { + "__type__": "cc.Node", + "_name": "Main Camera", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 4 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 960, + "height": 640 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "e1WoFrQ79G7r4ZuQE3HlNb" + }, + { + "__type__": "cc.Camera", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 3 + }, + "_enabled": true, + "_cullingMask": 4294967295, + "_clearFlags": 7, + "_backgroundColor": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_depth": -1, + "_zoomRatio": 1, + "_targetTexture": null, + "_fov": 60, + "_orthoSize": 10, + "_nearClip": 1, + "_farClip": 4096, + "_ortho": true, + "_rect": { + "__type__": "cc.Rect", + "x": 0, + "y": 0, + "width": 1, + "height": 1 + }, + "_renderStages": 1, + "_alignWithScreen": true, + "_id": "81GN3uXINKVLeW4+iKSlim" + }, + { + "__type__": "cc.Node", + "_name": "targetParent", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [ + { + "__id__": 6 + } + ], + "_active": true, + "_components": [ + { + "__id__": 8 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 40, + "height": 36 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -284.547, + -47.425, + 0, + 0, + 0, + 0.10452846326765347, + 0.9945218953682733, + 0.8, + 0.8, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 12 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "edt8E0W/NHXJRfLL5w0FEx" + }, + { + "__type__": "cc.Node", + "_name": "target", + "_objFlags": 0, + "_parent": { + "__id__": 5 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 7 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 234, + "g": 105, + "b": 105, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 40, + "height": 36 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 62.57, + -72.45, + 0, + 0, + 0, + 0.13917310096006544, + 0.9902680687415704, + 0.2, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 16 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "6eHCMdQvJGuZlXE52ZvHyf" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 6 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "8cdb44ac-a3f6-449f-b354-7cd48cf84061" + }, + "_type": 0, + "_sizeMode": 1, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "12C4OEfbpPZ7D293sA4N2X" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 5 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "8cdb44ac-a3f6-449f-b354-7cd48cf84061" + }, + "_type": 0, + "_sizeMode": 1, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "32BW2ujgdMuoadwfa8sy8R" + }, + { + "__type__": "cc.Node", + "_name": "SrcParent", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [ + { + "__id__": 10 + } + ], + "_active": true, + "_components": [], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 134.369, + 51.377, + 0, + 0, + 0, + -0.25881904510252074, + 0.9659258262890683, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": -30 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "fe2RbrNhxIUZiF7XIU03Th" + }, + { + "__type__": "cc.Node", + "_name": "src", + "_objFlags": 0, + "_parent": { + "__id__": 9 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 11 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 100 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -71.628, + 13.407, + 0, + 0, + 0, + 0, + 1, + 1.2, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "a6z5vIfndNfZSVcOsoQPPR" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 10 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "b41guspOdA+rTJ9wP8FM7K" + }, + { + "__type__": "cc.Canvas", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "_designResolution": { + "__type__": "cc.Size", + "width": 1334, + "height": 750 + }, + "_fitWidth": false, + "_fitHeight": true, + "_id": "59Cd0ovbdF4byw5sbjJDx7" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "alignMode": 1, + "_target": null, + "_alignFlags": 45, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 0, + "_originalHeight": 0, + "_id": "29zXboiXFBKoIV4PQ2liTe" + }, + { + "__type__": "41fb7HlhIJNzZMkSaq31ryP", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "target": { + "__id__": 6 + }, + "targetParent": { + "__id__": 5 + }, + "srcTarget": { + "__id__": 10 + }, + "srcTargetParent": { + "__id__": 9 + }, + "_id": "61Ee/a6NhDDKpan+btqgEB" + } +] \ No newline at end of file diff --git a/Layered_virtual_list_2.x/assets/Scene/TestMatrix.fire.meta b/Layered_virtual_list_2.x/assets/Scene/TestMatrix.fire.meta new file mode 100644 index 0000000..04e9be9 --- /dev/null +++ b/Layered_virtual_list_2.x/assets/Scene/TestMatrix.fire.meta @@ -0,0 +1,8 @@ +{ + "ver": "1.3.2", + "uuid": "3ed1232c-1b00-4818-8d5e-2112f30b11a4", + "importer": "scene", + "asyncLoadAssets": false, + "autoReleaseAssets": false, + "subMetas": {} +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/assets/Scene/TestMatrix.ts b/Layered_virtual_list_2.x/assets/Scene/TestMatrix.ts new file mode 100644 index 0000000..e104cf3 --- /dev/null +++ b/Layered_virtual_list_2.x/assets/Scene/TestMatrix.ts @@ -0,0 +1,148 @@ +// Learn TypeScript: +// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html +// Learn Attribute: +// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html +// Learn life-cycle callbacks: +// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html + +const { ccclass, property } = cc._decorator; + +@ccclass +export default class NewClass extends cc.Component { + + @property(cc.Node) + target: cc.Node = null; + + @property(cc.Node) + targetParent: cc.Node = null; + + @property(cc.Node) + srcTarget: cc.Node = null; + + @property(cc.Node) + srcTargetParent: cc.Node = null; + // LIFE-CYCLE CALLBACKS: + + onLoad() { + // cc.director.on(cc.Director.EVENT_BEFORE_DRAW, this.onBeforeDraw, this); + } + + start() { + // this.scheduleOnce(() => { + // this.target.x = 100; + // this.target.scaleX = 2; + // }, 3); + + // this.scheduleOnce(() => { + // this.targetParent.x = 10; + // this.target.scaleX = 1.1; + // }, 1); + let targetNode = this.target; // 需要获取世界矩阵的节点 + let parentNode = this.targetParent; // 要转换到的节点 + + let localMatrix = cc.mat4(); + targetNode.getLocalMatrix(localMatrix); + this.getMatrixInfo(localMatrix); + + // 获取目标节点的世界矩阵 + let worldMatrix = cc.mat4(); + targetNode.getWorldMatrix(worldMatrix) + // 获取父节点的世界矩阵 + let parentWorldMatrix = cc.mat4(); + parentNode.getWorldMatrix(parentWorldMatrix); + + // 获取父节点的逆矩阵 + let parentInverseMatrix = parentWorldMatrix.invert(); + + // 将目标节点的世界矩阵转换为父节点的本地矩阵 + let localMatrix2 = parentInverseMatrix.multiply(worldMatrix); + + this.getMatrixInfo(localMatrix2); + + } + + matrixTransform() { + // 假设我们有一个目标节点和一个父节点 + let targetNode = this.target; // 需要获取世界矩阵的节点 + let parentNode = this.srcTargetParent; // 要转换到的节点 + + // 获取目标节点的世界矩阵 + let worldMatrix = cc.mat4(); + targetNode.getWorldMatrix(worldMatrix) + + // 获取父节点的世界矩阵 + let parentWorldMatrix = cc.mat4(); + parentNode.getWorldMatrix(parentWorldMatrix) + + // 获取父节点的逆矩阵 + let parentInverseMatrix = parentWorldMatrix.invert(); + + // 将目标节点的世界矩阵转换为父节点的本地矩阵 + let localMatrix = parentInverseMatrix.multiply(worldMatrix); + + + // 提取位置 + let position = cc.v3(worldMatrix.m[12], worldMatrix.m[13], worldMatrix.m[14]); + + // 提取缩放 + let scaleX = Math.sqrt(worldMatrix.m[0] * worldMatrix.m[0] + worldMatrix.m[1] * worldMatrix.m[1] + worldMatrix.m[2] * worldMatrix.m[2]); + let scaleY = Math.sqrt(worldMatrix.m[4] * worldMatrix.m[4] + worldMatrix.m[5] * worldMatrix.m[5] + worldMatrix.m[6] * worldMatrix.m[6]); + let scaleZ = Math.sqrt(worldMatrix.m[8] * worldMatrix.m[8] + worldMatrix.m[9] * worldMatrix.m[9] + worldMatrix.m[10] * worldMatrix.m[10]); + + // 提取旋转(假设是二维旋转) + let angle = Math.atan2(worldMatrix.m[1] / scaleX, worldMatrix.m[0] / scaleX) * (180 / Math.PI); + + // 输出结果 + console.log("Position:", position); + console.log("Scale:", cc.v3(scaleX, scaleY, scaleZ)); + console.log("Angle:", angle); + } + + getMatrixInfo(matrix: cc.Mat4) { + // 提取位置 + let position = cc.v3(matrix.m[12], matrix.m[13], matrix.m[14]); + + // 提取缩放 + let scaleX = Math.sqrt(matrix.m[0] * matrix.m[0] + matrix.m[1] * matrix.m[1] + matrix.m[2] * matrix.m[2]); + let scaleY = Math.sqrt(matrix.m[4] * matrix.m[4] + matrix.m[5] * matrix.m[5] + matrix.m[6] * matrix.m[6]); + let scaleZ = Math.sqrt(matrix.m[8] * matrix.m[8] + matrix.m[9] * matrix.m[9] + matrix.m[10] * matrix.m[10]); + + // 提取旋转(假设是二维旋转) + let angle = Math.atan2(matrix.m[1] / scaleX, matrix.m[0] / scaleX) * (180 / Math.PI); + + // 输出结果 + console.log("Position:", position); + console.log("Scale:", cc.v3(scaleX, scaleY, scaleZ)); + console.log("Angle:", angle); + } + + onDestroy(): void { + cc.director.off(cc.Director.EVENT_BEFORE_DRAW, this.onBeforeDraw, this); + } + + + onBeforeDraw() { + this.checkDirty(this.target); + this.checkDirty(this.targetParent); + } + + checkDirty(node: cc.Node) { + //@ts-ignore + let _localMatDirty = node._localMatDirty; + if (_localMatDirty) { + console.log(node.name, _localMatDirty); + } + //@ts-ignore + let _worldMatDirty = node._worldMatDirty; + if (_worldMatDirty) { + console.log(node.name, _worldMatDirty); + } + //@ts-ignore + let _renderFlag = node._renderFlag; + if (_renderFlag) { + console.log(node.name, _renderFlag); + } + } + + // update (dt) {} +} diff --git a/Layered_virtual_list_2.x/assets/Scene/TestMatrix.ts.meta b/Layered_virtual_list_2.x/assets/Scene/TestMatrix.ts.meta new file mode 100644 index 0000000..42d3908 --- /dev/null +++ b/Layered_virtual_list_2.x/assets/Scene/TestMatrix.ts.meta @@ -0,0 +1,10 @@ +{ + "ver": "1.1.0", + "uuid": "41fb71e5-8482-4dcd-9324-49aab7d6bc8f", + "importer": "typescript", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/assets/Scene/TestRenderAlternative.ts b/Layered_virtual_list_2.x/assets/Scene/TestRenderAlternative.ts new file mode 100644 index 0000000..2f2cdda --- /dev/null +++ b/Layered_virtual_list_2.x/assets/Scene/TestRenderAlternative.ts @@ -0,0 +1,40 @@ +// Learn TypeScript: +// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html +// Learn Attribute: +// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html +// Learn life-cycle callbacks: +// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html + +const { ccclass, property } = cc._decorator; + +@ccclass +export default class TestRenderAlternative extends cc.Component { + + @property(cc.ScrollView) + scrollView: cc.ScrollView = null; + + @property(cc.Prefab) + prefab: cc.Prefab = null; + + @property(cc.Node) + layer: cc.Node = null; + + // onLoad () {} + + start() { + let count = 1000; + let datas = []; + for (let i = 0; i < count; i++) { + let data = { name: 'name' + i, index: i }; + datas.push({ data: data, layer: this.layer }); + } + + for (let i = 0; i < datas.length; i++) { + let item = cc.instantiate(this.prefab); + this.scrollView.content.addChild(item); + item.getComponent('Item').init(datas[i]); + } + } + + // update (dt) {} +} diff --git a/Layered_virtual_list_2.x/assets/Scene/TestRenderAlternative.ts.meta b/Layered_virtual_list_2.x/assets/Scene/TestRenderAlternative.ts.meta new file mode 100644 index 0000000..8620226 --- /dev/null +++ b/Layered_virtual_list_2.x/assets/Scene/TestRenderAlternative.ts.meta @@ -0,0 +1,10 @@ +{ + "ver": "1.1.0", + "uuid": "b9be0b60-a085-4f93-bd8b-884e8ddfd7ff", + "importer": "typescript", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/assets/Scene/TestShowNode.ts b/Layered_virtual_list_2.x/assets/Scene/TestShowNode.ts new file mode 100644 index 0000000..b4d8517 --- /dev/null +++ b/Layered_virtual_list_2.x/assets/Scene/TestShowNode.ts @@ -0,0 +1,56 @@ +import ItemCell, { ShowNode } from "../Script/LoopList"; +import RenderAlternative from "../Script/RenderAlternative"; +const { ccclass, property } = cc._decorator; +export interface IData { + size?: cc.Size, + index: number, + text: string +} + +@ccclass +export class TestShowNode extends ShowNode { + /** */ + @property(cc.Label) + public nameLb: cc.Label = null; + /** */ + @property(cc.Label) + public contentLb: cc.Label = null; + /** */ + @property(cc.Node) + public Button: cc.Node = null; + /** */ + @property(cc.Label) + public ButtonLb: cc.Label = null; + + /** + * 初始化显示 + * @param data + */ + initShow() { + this.node.width = this.data.size.width; + this.node.height = this.data.size.height; + this.nameLb.string = "我是第" + this.data.index + "个"; + this.contentLb.string = "我是内容" + this.data.text; + //这个是改变控件大小的事例 + if (this.data.index == 5 || this.data.index == 11) { + //this.changeSize(cell); + } + } + + /** + * 改变大小 + * @param cell + */ + changeSize(cell: ItemCell) { + this.resize(cc.size(cell.size.width, 100 + (Math.random() * 400))); + this.scheduleOnce(() => { + this.changeSize(cell) + }, 3 + Math.random() * 3) + } + + onRecircle() { + //做释放操作 + } +} + + diff --git a/Layered_virtual_list_2.x/assets/Scene/TestShowNode.ts.meta b/Layered_virtual_list_2.x/assets/Scene/TestShowNode.ts.meta new file mode 100644 index 0000000..e3db967 --- /dev/null +++ b/Layered_virtual_list_2.x/assets/Scene/TestShowNode.ts.meta @@ -0,0 +1,10 @@ +{ + "ver": "1.1.0", + "uuid": "9e17833a-ad49-48e6-a822-d7e1dc2cedf4", + "importer": "typescript", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/assets/Scene/helloworld.fire b/Layered_virtual_list_2.x/assets/Scene/helloworld.fire new file mode 100644 index 0000000..36e9c6c --- /dev/null +++ b/Layered_virtual_list_2.x/assets/Scene/helloworld.fire @@ -0,0 +1,1953 @@ +[ + { + "__type__": "cc.SceneAsset", + "_name": "", + "_objFlags": 0, + "_native": "", + "scene": { + "__id__": 1 + } + }, + { + "__type__": "cc.Scene", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + } + ], + "_active": false, + "_components": [], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_is3DNode": true, + "_groupIndex": 0, + "groupIndex": 0, + "autoReleaseAssets": false, + "_id": "2d2f792f-a40c-49bb-a189-ed176a246e49" + }, + { + "__type__": "cc.Node", + "_name": "Canvas", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 3 + }, + { + "__id__": 5 + }, + { + "__id__": 9 + }, + { + "__id__": 17 + }, + { + "__id__": 26 + } + ], + "_active": true, + "_components": [ + { + "__id__": 46 + }, + { + "__id__": 47 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 252, + "g": 252, + "b": 252, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 750, + "height": 1334 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 375, + 667, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "a286bbGknJLZpRpxROV6M94" + }, + { + "__type__": "cc.Node", + "_name": "Main Camera", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 4 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "09K3aRxxtPX4CkhgKEDjJC" + }, + { + "__type__": "cc.Camera", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 3 + }, + "_enabled": true, + "_cullingMask": 4294967295, + "_clearFlags": 7, + "_backgroundColor": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_depth": -1, + "_zoomRatio": 1, + "_targetTexture": null, + "_fov": 60, + "_orthoSize": 10, + "_nearClip": 1, + "_farClip": 4096, + "_ortho": true, + "_rect": { + "__type__": "cc.Rect", + "x": 0, + "y": 0, + "width": 1, + "height": 1 + }, + "_renderStages": 1, + "_alignWithScreen": true, + "_id": "39hvvfgtBNGI33C9knv3qJ" + }, + { + "__type__": "cc.Node", + "_name": "TestLoop", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 6 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "ea+1z95MVNUJtfZx0Pj5uw" + }, + { + "__type__": "4850bCv26VE3LcjWQcJHche", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 5 + }, + "_enabled": true, + "rendeLayer": { + "__id__": 7 + }, + "scrollView": { + "__id__": 11 + }, + "showPrefab": { + "__uuid__": "6b1c6ed5-0dab-415a-b3cc-4408f270a2d0" + }, + "_id": "4ecJ/NvtNECq11eqajw/72" + }, + { + "__type__": "cc.Node", + "_name": "layer", + "_objFlags": 0, + "_parent": { + "__id__": 8 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 200, + "height": 300 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 123.761, + -500, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "50nGMWMotB8IRitJD4pcqd" + }, + { + "__type__": "cc.Node", + "_name": "view", + "_objFlags": 0, + "_parent": { + "__id__": 9 + }, + "_children": [ + { + "__id__": 12 + }, + { + "__id__": 7 + } + ], + "_active": true, + "_components": [ + { + "__id__": 15 + }, + { + "__id__": 16 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 750, + "height": 1000 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 1 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 500, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "c6mYKChI5JOIj+cE9APPY7" + }, + { + "__type__": "cc.Node", + "_name": "Vertical", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [ + { + "__id__": 8 + } + ], + "_active": true, + "_components": [ + { + "__id__": 10 + }, + { + "__id__": 11 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 750, + "height": 1000 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "43vHaNbn5LBatV59YArlhV" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 9 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "9bbda31e-ad49-43c9-aaf2-f7d9896bac69" + }, + "_type": 1, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "1d6unlyRJMsoRZ4n/erVRP" + }, + { + "__type__": "cc.ScrollView", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 9 + }, + "_enabled": true, + "horizontal": false, + "vertical": true, + "inertia": true, + "brake": 0.75, + "elastic": true, + "bounceDuration": 0.23, + "scrollEvents": [], + "cancelInnerEvents": true, + "_N$content": { + "__id__": 12 + }, + "content": { + "__id__": 12 + }, + "_N$horizontalScrollBar": null, + "_N$verticalScrollBar": null, + "_id": "85FvdcFWBDV4M9KxRZecCJ" + }, + { + "__type__": "cc.Node", + "_name": "content", + "_objFlags": 0, + "_parent": { + "__id__": 8 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 13 + }, + { + "__id__": 14 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 750, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 1 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "1bXfuT7ExLwJKge3owlyzF" + }, + { + "__type__": "cc.Layout", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 12 + }, + "_enabled": true, + "_layoutSize": { + "__type__": "cc.Size", + "width": 750, + "height": 0 + }, + "_resize": 1, + "_N$layoutType": 2, + "_N$cellSize": { + "__type__": "cc.Size", + "width": 40, + "height": 40 + }, + "_N$startAxis": 0, + "_N$paddingLeft": 0, + "_N$paddingRight": 0, + "_N$paddingTop": 0, + "_N$paddingBottom": 0, + "_N$spacingX": 0, + "_N$spacingY": 10, + "_N$verticalDirection": 1, + "_N$horizontalDirection": 0, + "_N$affectedByScale": false, + "_id": "97UH7rpo1KOJZZSsFYERBu" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 12 + }, + "_enabled": true, + "alignMode": 1, + "_target": null, + "_alignFlags": 41, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 220, + "_originalHeight": 0, + "_id": "94j1vJKZhC7rvaDXU/XM+I" + }, + { + "__type__": "cc.Mask", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 8 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_spriteFrame": null, + "_type": 0, + "_segments": 64, + "_N$alphaThreshold": 0, + "_N$inverted": false, + "_id": "cdlgF0KFZAAZzi3KNcEqEW" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 8 + }, + "_enabled": true, + "alignMode": 1, + "_target": null, + "_alignFlags": 45, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 240, + "_originalHeight": 250, + "_id": "a7YdvisBhKuIlN3CCuPMaJ" + }, + { + "__type__": "cc.Node", + "_name": "Horizontal", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [ + { + "__id__": 18 + } + ], + "_active": false, + "_components": [ + { + "__id__": 24 + }, + { + "__id__": 25 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 500, + "height": 1000 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "36VvP0G09KXaygeBwQJi38" + }, + { + "__type__": "cc.Node", + "_name": "view", + "_objFlags": 0, + "_parent": { + "__id__": 17 + }, + "_children": [ + { + "__id__": 19 + } + ], + "_active": true, + "_components": [ + { + "__id__": 22 + }, + { + "__id__": 23 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 500, + "height": 1000 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -250, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "5cVJZx64VDAbE0+GHS+ljM" + }, + { + "__type__": "cc.Node", + "_name": "content", + "_objFlags": 0, + "_parent": { + "__id__": 18 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 20 + }, + { + "__id__": 21 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 220, + "height": 1000 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "044WGrpVlJX6HvptTPUEC1" + }, + { + "__type__": "cc.Layout", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 19 + }, + "_enabled": true, + "_layoutSize": { + "__type__": "cc.Size", + "width": 220, + "height": 1000 + }, + "_resize": 1, + "_N$layoutType": 1, + "_N$cellSize": { + "__type__": "cc.Size", + "width": 40, + "height": 40 + }, + "_N$startAxis": 0, + "_N$paddingLeft": 0, + "_N$paddingRight": 0, + "_N$paddingTop": 0, + "_N$paddingBottom": 0, + "_N$spacingX": 0, + "_N$spacingY": 5, + "_N$verticalDirection": 1, + "_N$horizontalDirection": 0, + "_N$affectedByScale": false, + "_id": "55aN0610JMRq/gQKnyzhAY" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 19 + }, + "_enabled": true, + "alignMode": 1, + "_target": null, + "_alignFlags": 13, + "_left": 0, + "_right": 280, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 220, + "_originalHeight": 0, + "_id": "e4s1D76VBHvauUganIA4KW" + }, + { + "__type__": "cc.Mask", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 18 + }, + "_enabled": false, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_spriteFrame": null, + "_type": 0, + "_segments": 64, + "_N$alphaThreshold": 0, + "_N$inverted": false, + "_id": "bf6UMcWrhOr4jcJ8Xr/ccS" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 18 + }, + "_enabled": true, + "alignMode": 1, + "_target": null, + "_alignFlags": 45, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 240, + "_originalHeight": 250, + "_id": "795+OK4EFMo68XgmKpU2O+" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 17 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "9bbda31e-ad49-43c9-aaf2-f7d9896bac69" + }, + "_type": 1, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "27RDHW2iJEgbMioz+T5We3" + }, + { + "__type__": "cc.ScrollView", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 17 + }, + "_enabled": true, + "horizontal": true, + "vertical": false, + "inertia": true, + "brake": 0.75, + "elastic": true, + "bounceDuration": 0.23, + "scrollEvents": [], + "cancelInnerEvents": true, + "_N$content": { + "__id__": 19 + }, + "content": { + "__id__": 19 + }, + "_N$horizontalScrollBar": null, + "_N$verticalScrollBar": null, + "_id": "9f7KeQvGdBb42l9mua/S+H" + }, + { + "__type__": "cc.Node", + "_name": "parent", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [ + { + "__id__": 27 + }, + { + "__id__": 33 + }, + { + "__id__": 39 + } + ], + "_active": false, + "_components": [ + { + "__id__": 45 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 40, + "g": 168, + "b": 45, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 500, + "height": 500 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "4eapwQhy9FJr1oDtIF5XMt" + }, + { + "__type__": "cc.Node", + "_name": "1", + "_objFlags": 0, + "_parent": { + "__id__": 26 + }, + "_children": [ + { + "__id__": 28 + } + ], + "_active": true, + "_components": [ + { + "__id__": 31 + }, + { + "__id__": 32 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 100 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -80.714, + 123.761, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "cclp30DuxPI40Ql8RTgIp5" + }, + { + "__type__": "cc.Node", + "_name": "New Label", + "_objFlags": 0, + "_parent": { + "__id__": 27 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 29 + }, + { + "__id__": 30 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 22.25, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "d1NK110VBOjL8p0409QsTv" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 28 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_string": "1", + "_N$string": "1", + "_fontSize": 40, + "_lineHeight": 40, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_styleFlags": 0, + "_underlineHeight": 0, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 2, + "_id": "1ec9ZPVK9DiY33RUQtjAmR" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 28 + }, + "_enabled": true, + "renderLayer": { + "__id__": 7 + }, + "renderZIndex": 0, + "syncInv": 0, + "_id": "28rh4vPCtDH7mfQfnunwP+" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 27 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "dctkJzgctIRbPAF7CX/X0D" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 27 + }, + "_enabled": true, + "renderLayer": { + "__id__": 7 + }, + "renderZIndex": 0, + "syncInv": 0, + "_id": "34s75vARxOxYwCNg9irB9g" + }, + { + "__type__": "cc.Node", + "_name": "2", + "_objFlags": 0, + "_parent": { + "__id__": 26 + }, + "_children": [ + { + "__id__": 34 + } + ], + "_active": true, + "_components": [ + { + "__id__": 37 + }, + { + "__id__": 38 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 184, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 100 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -80.714, + 123.761, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "f3s/MnZNRHTIi/Q+H1UxKx" + }, + { + "__type__": "cc.Node", + "_name": "New Label", + "_objFlags": 0, + "_parent": { + "__id__": 33 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 35 + }, + { + "__id__": 36 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 22.25, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "d32B7NZuBGY63WBdbVTVyG" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 34 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_string": "2", + "_N$string": "2", + "_fontSize": 40, + "_lineHeight": 40, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_styleFlags": 0, + "_underlineHeight": 0, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 2, + "_id": "14NDOGnfhG9K+YOHXLcfhJ" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 34 + }, + "_enabled": true, + "renderLayer": { + "__id__": 7 + }, + "renderZIndex": 0, + "syncInv": 0, + "_id": "3b2tZBLXFLfbVjUa9moptZ" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 33 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "56VszVbJ5PB7PzxYIgK1UZ" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 33 + }, + "_enabled": true, + "renderLayer": { + "__id__": 7 + }, + "renderZIndex": 0, + "syncInv": 0, + "_id": "98jNMDg2NNpL0CwReAWY24" + }, + { + "__type__": "cc.Node", + "_name": "3", + "_objFlags": 0, + "_parent": { + "__id__": 26 + }, + "_children": [ + { + "__id__": 40 + } + ], + "_active": true, + "_components": [ + { + "__id__": 43 + }, + { + "__id__": 44 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 10, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 100 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -80.714, + 123.761, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "1e4i8OlSlN1L+L8ylsTJMp" + }, + { + "__type__": "cc.Node", + "_name": "New Label", + "_objFlags": 0, + "_parent": { + "__id__": 39 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 41 + }, + { + "__id__": 42 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 22.25, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "d8eW94wH5Emo/po5DP/fed" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 40 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_string": "3", + "_N$string": "3", + "_fontSize": 40, + "_lineHeight": 40, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_styleFlags": 0, + "_underlineHeight": 0, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 2, + "_id": "7fju1YtiROgKcUrz8Jbxoo" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 40 + }, + "_enabled": true, + "renderLayer": { + "__id__": 7 + }, + "renderZIndex": 0, + "syncInv": 0, + "_id": "04gNKYOURMUYIzBSFmEZQb" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 39 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "e3/Rip1ZxCQrAeRRXarp6n" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 39 + }, + "_enabled": true, + "renderLayer": { + "__id__": 7 + }, + "renderZIndex": 0, + "syncInv": 0, + "_id": "27WCjM2uhB5pVrJMpptJfp" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 26 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "69pO2jE6tFNr13iHtLu7XS" + }, + { + "__type__": "cc.Canvas", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "_designResolution": { + "__type__": "cc.Size", + "width": 750, + "height": 1334 + }, + "_fitWidth": true, + "_fitHeight": false, + "_id": "dfvGuB0gdP+bfdBA5GrvZn" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "alignMode": 1, + "_target": null, + "_alignFlags": 45, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 0, + "_originalHeight": 0, + "_id": "ddKTtCCMFIwpiha8iT+uxE" + } +] \ No newline at end of file diff --git a/Layered_virtual_list_2.x/assets/Scene/helloworld.fire.meta b/Layered_virtual_list_2.x/assets/Scene/helloworld.fire.meta new file mode 100644 index 0000000..f8dccc5 --- /dev/null +++ b/Layered_virtual_list_2.x/assets/Scene/helloworld.fire.meta @@ -0,0 +1,8 @@ +{ + "ver": "1.3.2", + "uuid": "2d2f792f-a40c-49bb-a189-ed176a246e49", + "importer": "scene", + "asyncLoadAssets": false, + "autoReleaseAssets": false, + "subMetas": {} +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/assets/Scene/showNode.prefab b/Layered_virtual_list_2.x/assets/Scene/showNode.prefab new file mode 100644 index 0000000..5a12a05 --- /dev/null +++ b/Layered_virtual_list_2.x/assets/Scene/showNode.prefab @@ -0,0 +1,1041 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "asyncLoadAssets": false, + "readonly": false + }, + { + "__type__": "cc.Node", + "_name": "showNode", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + }, + { + "__id__": 7 + }, + { + "__id__": 12 + }, + { + "__id__": 24 + } + ], + "_active": true, + "_components": [ + { + "__id__": 29 + }, + { + "__id__": 30 + } + ], + "_prefab": { + "__id__": 31 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 750, + "height": 1334 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 1 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 375, + 1334, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bg", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 3 + }, + { + "__id__": 4 + }, + { + "__id__": 5 + } + ], + "_prefab": { + "__id__": 6 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 48, + "g": 147, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 750, + "height": 1334 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + -667, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "alignMode": 2, + "_target": null, + "_alignFlags": 45, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 100, + "_originalHeight": 100, + "_id": "" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "renderLayer": null, + "renderZIndex": 0, + "syncInv": 0.01, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "2fWAV/kSxKbLNNotfg0pAI", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "nameLb", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 8 + }, + { + "__id__": 9 + }, + { + "__id__": 10 + } + ], + "_prefab": { + "__id__": 11 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 142.25, + "height": 50.4 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -261.821, + -45.115, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 7 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_string": "我是第1", + "_N$string": "我是第1", + "_fontSize": 40, + "_lineHeight": 40, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_styleFlags": 0, + "_underlineHeight": 0, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 0, + "_id": "" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 7 + }, + "_enabled": true, + "renderLayer": null, + "renderZIndex": 1, + "syncInv": 0.01, + "_id": "" + }, + { + "__type__": "cc.LabelShadow", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 7 + }, + "_enabled": true, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_offset": { + "__type__": "cc.Vec2", + "x": 2, + "y": -5 + }, + "_blur": 2, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "50Nr1a5SVMCLPTFU4WTSCP", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "New Button", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 13 + }, + { + "__id__": 18 + } + ], + "_active": true, + "_components": [ + { + "__id__": 22 + } + ], + "_prefab": { + "__id__": 23 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -106.669, + -44.121, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Background", + "_objFlags": 0, + "_parent": { + "__id__": 12 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 14 + }, + { + "__id__": 15 + }, + { + "__id__": 16 + } + ], + "_prefab": { + "__id__": 17 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 0 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 13 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952" + }, + "_type": 1, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 13 + }, + "_enabled": true, + "alignMode": 0, + "_target": null, + "_alignFlags": 45, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 100, + "_originalHeight": 40, + "_id": "" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 13 + }, + "_enabled": true, + "renderLayer": null, + "renderZIndex": 0, + "syncInv": 0.01, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "b2yBk+BHFOF7B8n1gYypgp", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "Label", + "_objFlags": 0, + "_parent": { + "__id__": 12 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 19 + }, + { + "__id__": 20 + } + ], + "_prefab": { + "__id__": 21 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 18 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_string": "button", + "_N$string": "button", + "_fontSize": 20, + "_lineHeight": 40, + "_enableWrapText": false, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_styleFlags": 0, + "_underlineHeight": 0, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 1, + "_N$cacheMode": 2, + "_id": "" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 18 + }, + "_enabled": true, + "renderLayer": null, + "renderZIndex": 1, + "syncInv": 0.01, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "78ZrwHpmZIaZAh4fh1OXyZ", + "sync": false + }, + { + "__type__": "cc.Button", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 12 + }, + "_enabled": true, + "_normalMaterial": null, + "_grayMaterial": null, + "duration": 0.1, + "zoomScale": 1.2, + "clickEvents": [], + "_N$interactable": true, + "_N$enableAutoGrayEffect": false, + "_N$transition": 3, + "transition": 3, + "_N$normalColor": { + "__type__": "cc.Color", + "r": 230, + "g": 230, + "b": 230, + "a": 255 + }, + "_N$pressedColor": { + "__type__": "cc.Color", + "r": 200, + "g": 200, + "b": 200, + "a": 255 + }, + "pressedColor": { + "__type__": "cc.Color", + "r": 200, + "g": 200, + "b": 200, + "a": 255 + }, + "_N$hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$disabledColor": { + "__type__": "cc.Color", + "r": 120, + "g": 120, + "b": 120, + "a": 200 + }, + "_N$normalSprite": { + "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952" + }, + "_N$pressedSprite": { + "__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a" + }, + "pressedSprite": { + "__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a" + }, + "_N$hoverSprite": { + "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952" + }, + "hoverSprite": { + "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952" + }, + "_N$disabledSprite": { + "__uuid__": "29158224-f8dd-4661-a796-1ffab537140e" + }, + "_N$target": { + "__id__": 13 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "14TO6K8WlMjp8gwgtWA0qf", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "contentLb", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 25 + }, + { + "__id__": 26 + }, + { + "__id__": 27 + } + ], + "_prefab": { + "__id__": 28 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 333.07, + "height": 44 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 151.722, + -43.961, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 24 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_string": "ScrollView content", + "_N$string": "ScrollView content", + "_fontSize": 40, + "_lineHeight": 40, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_styleFlags": 0, + "_underlineHeight": 0, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 2, + "_id": "" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 24 + }, + "_enabled": true, + "renderLayer": null, + "renderZIndex": 1, + "syncInv": 0.01, + "_id": "" + }, + { + "__type__": "cc.LabelOutline", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 24 + }, + "_enabled": true, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_width": 2, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "41ShEz5VJCm68duiIf01ZR", + "sync": false + }, + { + "__type__": "9e178M6rUlI5qgi1+HcLO30", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "nameLb": { + "__id__": 8 + }, + "contentLb": { + "__id__": 25 + }, + "Button": { + "__id__": 12 + }, + "ButtonLb": { + "__id__": 19 + }, + "_id": "" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "alignMode": 2, + "_target": null, + "_alignFlags": 45, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 750, + "_originalHeight": 100, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "", + "sync": false + } +] \ No newline at end of file diff --git a/Layered_virtual_list_2.x/assets/Scene/showNode.prefab.meta b/Layered_virtual_list_2.x/assets/Scene/showNode.prefab.meta new file mode 100644 index 0000000..68e0ebc --- /dev/null +++ b/Layered_virtual_list_2.x/assets/Scene/showNode.prefab.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.3.2", + "uuid": "6b1c6ed5-0dab-415a-b3cc-4408f270a2d0", + "importer": "prefab", + "optimizationPolicy": "AUTO", + "asyncLoadAssets": false, + "readonly": false, + "subMetas": {} +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/assets/Scene/showNodeH.prefab b/Layered_virtual_list_2.x/assets/Scene/showNodeH.prefab new file mode 100644 index 0000000..64e193a --- /dev/null +++ b/Layered_virtual_list_2.x/assets/Scene/showNodeH.prefab @@ -0,0 +1,1002 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "asyncLoadAssets": false, + "readonly": false + }, + { + "__type__": "cc.Node", + "_name": "showNodeH", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + }, + { + "__id__": 7 + }, + { + "__id__": 11 + }, + { + "__id__": 23 + } + ], + "_active": true, + "_components": [ + { + "__id__": 27 + }, + { + "__id__": 28 + } + ], + "_prefab": { + "__id__": 29 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 750, + "height": 1334 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 1 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 375, + 1334, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bg", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 3 + }, + { + "__id__": 4 + }, + { + "__id__": 5 + } + ], + "_prefab": { + "__id__": 6 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 48, + "g": 147, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 750, + "height": 1334 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + -667, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "alignMode": 2, + "_target": null, + "_alignFlags": 45, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 100, + "_originalHeight": 100, + "_id": "" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "renderLayer": null, + "renderZIndex": 0, + "syncInv": 0.01, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "75120702-79b9-4d8a-9e06-0ab82828c5ba" + }, + "fileId": "2fWAV/kSxKbLNNotfg0pAI", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "nameLb", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 8 + }, + { + "__id__": 9 + } + ], + "_prefab": { + "__id__": 10 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 40, + "height": 160 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + -91.236, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 7 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_string": "我是第1", + "_N$string": "我是第1", + "_fontSize": 40, + "_lineHeight": 40, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_styleFlags": 0, + "_underlineHeight": 0, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 3, + "_N$cacheMode": 2, + "_id": "" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 7 + }, + "_enabled": true, + "renderLayer": null, + "renderZIndex": 1, + "syncInv": 0.01, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "75120702-79b9-4d8a-9e06-0ab82828c5ba" + }, + "fileId": "50Nr1a5SVMCLPTFU4WTSCP", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "New Button", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 12 + }, + { + "__id__": 17 + } + ], + "_active": true, + "_components": [ + { + "__id__": 21 + } + ], + "_prefab": { + "__id__": 22 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + -200.564, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Background", + "_objFlags": 0, + "_parent": { + "__id__": 11 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 13 + }, + { + "__id__": 14 + }, + { + "__id__": 15 + } + ], + "_prefab": { + "__id__": 16 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 0 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 12 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952" + }, + "_type": 1, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 12 + }, + "_enabled": true, + "alignMode": 0, + "_target": null, + "_alignFlags": 45, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 100, + "_originalHeight": 40, + "_id": "" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 12 + }, + "_enabled": true, + "renderLayer": null, + "renderZIndex": 0, + "syncInv": 0.01, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "75120702-79b9-4d8a-9e06-0ab82828c5ba" + }, + "fileId": "b2yBk+BHFOF7B8n1gYypgp", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "Label", + "_objFlags": 0, + "_parent": { + "__id__": 11 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 18 + }, + { + "__id__": 19 + } + ], + "_prefab": { + "__id__": 20 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 17 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_string": "button", + "_N$string": "button", + "_fontSize": 20, + "_lineHeight": 40, + "_enableWrapText": false, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_styleFlags": 0, + "_underlineHeight": 0, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 1, + "_N$cacheMode": 2, + "_id": "" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 17 + }, + "_enabled": true, + "renderLayer": null, + "renderZIndex": 1, + "syncInv": 0.01, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "75120702-79b9-4d8a-9e06-0ab82828c5ba" + }, + "fileId": "78ZrwHpmZIaZAh4fh1OXyZ", + "sync": false + }, + { + "__type__": "cc.Button", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 11 + }, + "_enabled": true, + "_normalMaterial": null, + "_grayMaterial": null, + "duration": 0.1, + "zoomScale": 1.2, + "clickEvents": [], + "_N$interactable": true, + "_N$enableAutoGrayEffect": false, + "_N$transition": 3, + "transition": 3, + "_N$normalColor": { + "__type__": "cc.Color", + "r": 230, + "g": 230, + "b": 230, + "a": 255 + }, + "_N$pressedColor": { + "__type__": "cc.Color", + "r": 200, + "g": 200, + "b": 200, + "a": 255 + }, + "pressedColor": { + "__type__": "cc.Color", + "r": 200, + "g": 200, + "b": 200, + "a": 255 + }, + "_N$hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$disabledColor": { + "__type__": "cc.Color", + "r": 120, + "g": 120, + "b": 120, + "a": 200 + }, + "_N$normalSprite": { + "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952" + }, + "_N$pressedSprite": { + "__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a" + }, + "pressedSprite": { + "__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a" + }, + "_N$hoverSprite": { + "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952" + }, + "hoverSprite": { + "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952" + }, + "_N$disabledSprite": { + "__uuid__": "29158224-f8dd-4661-a796-1ffab537140e" + }, + "_N$target": { + "__id__": 12 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "75120702-79b9-4d8a-9e06-0ab82828c5ba" + }, + "fileId": "14TO6K8WlMjp8gwgtWA0qf", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "contentLb", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 24 + }, + { + "__id__": 25 + } + ], + "_prefab": { + "__id__": 26 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 40, + "height": 440 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + -466.093, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 23 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_string": "ScrollView content", + "_N$string": "ScrollView content", + "_fontSize": 40, + "_lineHeight": 40, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_styleFlags": 0, + "_underlineHeight": 0, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 3, + "_N$cacheMode": 2, + "_id": "" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 23 + }, + "_enabled": true, + "renderLayer": null, + "renderZIndex": 1, + "syncInv": 0.01, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "75120702-79b9-4d8a-9e06-0ab82828c5ba" + }, + "fileId": "41ShEz5VJCm68duiIf01ZR", + "sync": false + }, + { + "__type__": "9e178M6rUlI5qgi1+HcLO30", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "renderAlternatives": [ + { + "__id__": 3 + }, + { + "__id__": 13 + } + ], + "nameLb": { + "__id__": 8 + }, + "contentLb": { + "__id__": 24 + }, + "Button": { + "__id__": 11 + }, + "ButtonLb": { + "__id__": 18 + }, + "_id": "" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "alignMode": 2, + "_target": null, + "_alignFlags": 45, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 750, + "_originalHeight": 100, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "75120702-79b9-4d8a-9e06-0ab82828c5ba" + }, + "fileId": "", + "sync": false + } +] \ No newline at end of file diff --git a/Layered_virtual_list_2.x/assets/Scene/showNodeH.prefab.meta b/Layered_virtual_list_2.x/assets/Scene/showNodeH.prefab.meta new file mode 100644 index 0000000..c2490c8 --- /dev/null +++ b/Layered_virtual_list_2.x/assets/Scene/showNodeH.prefab.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.3.2", + "uuid": "75120702-79b9-4d8a-9e06-0ab82828c5ba", + "importer": "prefab", + "optimizationPolicy": "AUTO", + "asyncLoadAssets": false, + "readonly": false, + "subMetas": {} +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/assets/Script.meta b/Layered_virtual_list_2.x/assets/Script.meta new file mode 100644 index 0000000..4474a1c --- /dev/null +++ b/Layered_virtual_list_2.x/assets/Script.meta @@ -0,0 +1,13 @@ +{ + "ver": "1.1.3", + "uuid": "4734c20c-0db8-4eb2-92ea-e692f4d70934", + "importer": "folder", + "isBundle": false, + "bundleName": "", + "priority": 1, + "compressionType": {}, + "optimizeHotUpdate": {}, + "inlineSpriteFrames": {}, + "isRemoteBundle": {}, + "subMetas": {} +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/assets/Script/LoopList.ts b/Layered_virtual_list_2.x/assets/Script/LoopList.ts new file mode 100644 index 0000000..eedd67e --- /dev/null +++ b/Layered_virtual_list_2.x/assets/Script/LoopList.ts @@ -0,0 +1,844 @@ +import RenderAlternative from "./RenderAlternative"; + +interface IBorder { + leftSide?: number; + rightSide?: number; + bottomSide?: number; + topSide?: number; + size?: cc.Size; +} +type TDate = { size?: cc.Size }; +export class ShowNode extends cc.Component { + /**是否初始化过代理组建 */ + private hasInit: boolean = false; + /**渲染分层开启的挂载节点 */ + public renderLayer: cc.Node; + /**上级的cell */ + public cell: ItemCell; + /**数据 */ + public data: T; + /**初始化 */ + public init(cell: ItemCell, data: T, renderLayer: cc.Node) { + this.cell = cell; + this.data = data; + if (this.renderLayer != renderLayer) { + this.renderLayer = renderLayer; + renderLayer && this.initRenders(); + } + this.initShow(); + } + /**初始化操作 */ + initShow() { } + /**被回收,应该做一些释放的操作 */ + onRecircle() { } + + /** + * 在特定时间内进行大小变化 + * @param targetSize + * @param time + */ + public resize(targetSize: cc.Size, time: number = 0.3) { + this.cell.resize(targetSize, time); + } + /** + * 处理分层代理渲染 + */ + private initRenders() { + if (!this.hasInit && this.renderLayer) { + let propMap: WeakMap = new WeakMap(); + let keys = Object.keys(this); + for (let i = 0, len = keys.length; i < len; ++i) { + let value = this[keys[i]]; + let alternative: RenderAlternative = null; + if (value instanceof cc.Node) { + alternative = value.getComponent(RenderAlternative); + if (alternative) { + alternative.init(this.renderLayer); + } + } else if (value instanceof cc.RenderComponent) { + alternative = value.getComponent(RenderAlternative); + if (alternative) { + this[keys[i]] = alternative.init(this.renderLayer); + } + } + alternative && propMap.set(alternative, true); + } + this.dealChilrenAlternative(this.node, propMap, 0, 0); + this.hasInit = true; + } + } + /** + * 处理子节点代理 + * @param node + * @param propMap 记录脚本已经处理过的属性代理 + * @param parentSindex 父节点的所在的顺序 + * @param depth 深度 + */ + dealChilrenAlternative(node: cc.Node, propMap: WeakMap, parentSindex: number, depth: number) { + for (let i = 0, len = node.children.length; i < len; i++) { + let children = node.children[i]; + let alternative = children.getComponent(cc.RenderComponent)?.getComponent(RenderAlternative); + let sIndex = parentSindex + (i * Math.pow(0.1, depth)); + if (alternative) { + if ((!propMap.has(alternative) || !propMap.get(alternative))) { + alternative.init(this.renderLayer); + } + alternative.sIndex = sIndex; + } + this.dealChilrenAlternative(children, propMap, sIndex, depth + 1); + } + } +} +export class ItemCell { + /**持有cell的list */ + public looplist: LoopList = null; + /**位置节点 */ + public node: cc.Node = null; + /**显示节点 */ + public showNode: ShowNode = null; + /**尺寸 */ + public size: cc.Size = null; + /**数据下标 */ + public dataIndex: number = null; + /**cell下标 */ + public cellIndex: number = null; + /**数据 */ + public data: T = null; + /** + * 构造函数 + * @param node + * @param looplist + */ + constructor(node: cc.Node, looplist: LoopList) { + this.node = node; + this.looplist = looplist; + } + + /** + * 初始化 + * @param data + * @param size + * @param dataIndex + * @param cellIndex + * @param looplist + */ + public init(data: T, size: cc.Size, dataIndex: number, cellIndex: number, looplist: LoopList) { + cc.Tween.stopAllByTarget(this.node); + this.cellIndex = cellIndex; + this.dataIndex = dataIndex; + this.looplist = looplist; + this.node.width = size.width; + this.node.height = size.height; + this.data = data; + this.size = size; + } + /** + * 重置大小 + * @param size + */ + resize(size: cc.Size, time: number) { + let nodeSides = getNodeBorder(this, [true, true, true, true]); + let changeSize = cc.size(size.width - this.size.width, size.height - this.size.height); + this.size = size; + this.looplist.dealChangeSize(this, nodeSides, changeSize, time).then(() => { + this.node.width = size.width; + this.node.height = size.height; + this.looplist.updateNodes(); + }); + } + + /** + * 更新节点显示 + * @param isShow 是否显示 + * @param prefab 需要显示的节点的预制件(也可以是节点,或者预制件url,生成方式自由改动) + * @param cacheNode 对象池中的显示节点 + * @param renderLayer 分层节点 + */ + updateShow(isShow: boolean, prefab: cc.Prefab, cacheNode: ShowNode, renderLayer: cc.Node) { + if (isShow) { + //当前没有显示节点 + if (!this.showNode) { + //如果是临时对象池还有节点则重用 + if (cacheNode) { + this.showNode = cacheNode; + } else {//否则使用传入的预制件进行生成 + this.showNode = cc.instantiate(prefab).getComponent(ShowNode); + } + this.showNode.node.setParent(this.node); + this.showNode.node.position = cc.v3(); + this.updateShowNode(renderLayer); + } + } + } + /** + * 更新showNode节点显示 + * @param renderLayer + */ + updateShowNode(renderLayer: cc.Node) { + //当前有显示节点 + if (this.showNode) { + this.showNode.init(this, this.data, renderLayer); + } + } + + get hasNoNode() { + return !this.showNode; + } + + recircle() { + if (this.showNode) { + let node = this.showNode; + this.showNode.getComponent(ShowNode).onRecircle(); + this.showNode.node.removeFromParent(false); + this.showNode = null; + return node; + } + } + + + destroy() { + this.node.destroy(); + this.node = null; + this.looplist = null; + } + + /** + * 失去 + * @returns + */ + lostShowNode() { + if (this.showNode) { + let node = this.showNode; + this.showNode.node.removeFromParent(false); + this.showNode = null; + return node; + } + } + + /** + * 获取显示节点 + * @param showNode + */ + getShowNode(showNode: ShowNode) { + this.showNode = showNode; + showNode.node.setParent(this.node); + this.showNode.cell = this; + } +} + +/** + * 目前列表注意事项 + * 1.开启cellMaxNum后不能一行多列或者一列多行,只能单行或者单列 + */ +export default class LoopList { + public static insMap: Map> = new Map(); + public static ins(listName: string): LoopList { + if (!this.insMap.has(listName)) { + this.insMap.set(listName, new LoopList()); + } + return this.insMap.get(listName) as LoopList; + } + /**分层节点(只有在showNode中挂载了RenderAlternative才能起作用) */ + private renderLayer: cc.Node = null; + /**滚动组件 */ + private scrollView: cc.ScrollView = null; + /**cell节点最大数量 */ + private cellMaxNum: number = null; + /**当前起点 */ + private curStartIndex: number = null; + /**数据 */ + private datas: T[] = []; + /**item节点们 */ + private itemCells: ItemCell[] = []; + /**预制件 */ + private prefab: cc.Prefab = null; + /**显示节点的池子 */ + private showNodePool: ShowNode[] = []; + /**边缘数据 */ + private viewSides: IBorder = {}; + /**上一帧滚动容器的坐标 */ + public lastPos: cc.Vec3 = null; + /**刷新显示的间隔次数 */ + public updateInv: number = 0; + /**循环切换的最后一次时间 */ + public lastChange: number = 0; + /**通用尺寸 */ + public size: cc.Size = null; + /**通用锚点 */ + public anchor: cc.Vec2 = null; + + onLoad() { + this.updateBorder() + } + + /** + * 更新边界 + */ + public updateBorder() { + let view = this.scrollView.node.getChildByName("view"); + view.anchorX = this.scrollView.content.anchorX; + view.anchorY = this.scrollView.content.anchorY; + //修改锚点之后下一帧世界坐标才会更新,没办法只能等一帧了 + return new Promise((resolve, reject) => { + requestAnimationFrame(() => { + let wpos = getNodeWPos(view); + //显示区域左边缘 + let leftSide = wpos.x - (view.width * view.anchorX); + //显示区域右边缘 + let rightSide = wpos.x + (view.width * (1 - view.anchorX)); + //显示区域下边缘 + let bottomSide = wpos.y - (view.height * view.anchorY); + //显示区域上边缘 + let topSide = wpos.y + (view.height * (1 - view.anchorY)); + this.viewSides = { + leftSide, rightSide, bottomSide, topSide, size: cc.size(view.width, view.height) + }; + this.scrollView.content.setPosition(cc.v3(0, 0)); + resolve(); + }) + }) + + } + + /** + * 初始化滚动列表 + * @param scrollView + * @param cellMaxNum cell节点的最大数量,设置成null则不启用,启用的话,要设置成(可视窗刚好能显示的最大数量*2)+2,假设最多能看到10个节点,那么设置成22 + * @param renderLayer 渲染分层的父节点,如果传入则可以配合showNode上的renderAlternative来进行渲染分层 + */ + async init(scrollView: cc.ScrollView, renderLayer?: cc.Node, cellMaxNum?: number) { + cellMaxNum && (this.cellMaxNum = cellMaxNum); + renderLayer && (this.renderLayer = renderLayer); + this.scrollView = scrollView; + await this.updateBorder(); + this.scrollView.node.on("scrolling", this.scrollingListener, this); + } + + /**滚动监听 */ + scrollingListener() { + this.updateInv--; + if (this.updateInv <= 0) { + this.updateInv = 2; + let showCells = this.updateNodes(); + + if (!this.cellMaxNum) { + return; + } + if (!this.lastPos) { + this.lastPos = this.scrollView.content.position.clone(); + } else { + let offset = this.scrollView.content.position.clone().sub(this.lastPos); + this.lastPos = this.scrollView.content.position.clone(); + let now = cc.sys.now(); + if (!this.lastChange || (now - this.lastChange) > 100) { + this.lastChange = now; + this.dealLoopList(offset, showCells); + } + } + } + } + /** + * 初始化 + * @param data 数据组 + * @param prefab 预制件 + * @param size 通用尺寸 + * @param anchor cell的锚点 + */ + public initData(data: T[], prefab: cc.Prefab, size?: cc.Size, anchor: cc.Vec2 = cc.v2(0.5, 0.5)) { + this.datas = data; + this.size = size; + this.anchor = anchor; + this.prefab = prefab; + let len = this.cellMaxNum ? this.cellMaxNum : data.length; + this.curStartIndex = 0; + for (let i = 0; i < len; ++i) { + let itemCell = this.itemCells[i]; + if (!itemCell) { + let node = new cc.Node('LoopListCell') + itemCell = this.itemCells[i] = new ItemCell(node, this); + node.setAnchorPoint(anchor); + node.setParent(this.scrollView.content); + } + let data = this.datas[this.curStartIndex + i]; + let cellSize = data.size ? data.size : size; + itemCell.init(data, cellSize, this.curStartIndex + i, i, this); + } + for (let i = data.length, len = this.itemCells.length; i < len; ++i) { + this.recircleShowNode(this.itemCells[i].recircle()); + this.itemCells[i].destroy() + this.itemCells[i] = null; + } + this.updateNodes(); + } + + /** + * 压入新的数据 + * @param datas + */ + public pushDatas(datas: T[]) { + let length = this.datas.length; + for (let i = 0, len = datas.length; i < len; ++i) { + let data = datas[i]; + this.datas.push(data); + let index = length + i; + this.addNodeFromIndex(index); + } + } + /** + * 插入新的数据 + * @param data + * @param insertIndex + */ + public insertData(data: T, insertIndex: number) { + if (this.datas.length >= insertIndex) { + this.datas.splice(insertIndex, 0, data); + this.addNodeFromIndex(insertIndex); + } else { + this.pushDatas([data]); + } + } + /** + * 移除对应数据 + * @param removeIndex + */ + public removeData(removeIndex: number) { + if (this.datas.length >= removeIndex) { + this.datas.splice(removeIndex, 1); + if (this.cellMaxNum) { + let cellIndex = removeIndex - this.curStartIndex; + //在使用范围内 + if (cellIndex >= 0 && cellIndex < this.cellMaxNum) { + let itemCell = this.itemCells[cellIndex]; + let nodeSides = getNodeBorder(itemCell, [true, true, true, true]); + let changeSize = cc.size(-itemCell.size.width, -itemCell.size.height); + itemCell.size = cc.size(0, 0); + this.dealChangeSize(itemCell, nodeSides, changeSize).then(() => { + //更新数据 + for (let i = cellIndex; i < this.cellMaxNum; i++) { + let curDataIndex = this.curStartIndex + i; + let curData = this.datas[curDataIndex]; + let curCellSize: cc.Size = curData.size ? curData.size : this.size; + this.itemCells[i].init(curData, curCellSize, curDataIndex, i, this); + this.itemCells[i].updateShowNode(this.renderLayer); + } + }); + } + } else { + let itemCell = this.itemCells.splice(removeIndex, 1)[0]; + let nodeSides = getNodeBorder(itemCell, [true, true, true, true]); + let changeSize = cc.size(-itemCell.size.width, -itemCell.size.height); + itemCell.size = cc.size(0, 0); + this.dealChangeSize(itemCell, nodeSides, changeSize).then(() => { + this.recircleShowNode(itemCell.recircle()) + itemCell.node.destroy(); + }); + } + } + } + /** + * 从某个数据开始更新 + * @param dataIndex + */ + private async addNodeFromIndex(dataIndex: number) { + let data = this.datas[dataIndex]; + let cellSize: cc.Size = data.size ? data.size : this.size; + //是否开启cell循环 + if (this.cellMaxNum) { + let cellIndex = dataIndex - this.curStartIndex; + //在使用范围内 + if (cellIndex >= 0 && cellIndex < this.cellMaxNum) { + //更新数据 + for (let i = cellIndex; i < this.cellMaxNum; i++) { + let curDataIndex = this.curStartIndex + i; + let curData = this.datas[curDataIndex]; + let curCellSize: cc.Size = curData.size ? curData.size : this.size; + this.itemCells[i].init(curData, curCellSize, curDataIndex, i, this); + this.itemCells[i].updateShowNode(this.renderLayer); + } + //获取当前的位置 + let nodeSides: IBorder = null; + let itemCell: ItemCell = this.itemCells[cellIndex]; + if (itemCell) { + nodeSides = getNodeBorder(itemCell, [true, true, true, true]); + itemCell.node.width = 0; + itemCell.node.height = 0; + this.dealChangeSize(itemCell, nodeSides, cellSize).then(() => { + itemCell.node.width = cellSize.width; + itemCell.node.height = cellSize.height; + }); + } + } + } else { + //获取当前的位置 + let nodeSides: IBorder = null; + if (this.itemCells[dataIndex]) { + nodeSides = getNodeBorder(this.itemCells[dataIndex], [true, true, true, true]); + } + let node = new cc.Node('LoopListCell') + node.setAnchorPoint(this.anchor); + node.setParent(this.scrollView.content); + node.setSiblingIndex(dataIndex); + let itemCell: ItemCell = new ItemCell(node, this); + this.itemCells.splice(dataIndex, 0, itemCell) + itemCell.init(data, cellSize, dataIndex, dataIndex, this); + if (!nodeSides) { + await new Promise((resolve, reject) => { + requestAnimationFrame(() => { + nodeSides = getNodeBorder(itemCell, [true, true, true, true]); + resolve(); + }) + }); + } + if (nodeSides) { + itemCell.node.width = 0; + itemCell.node.height = 0; + this.dealChangeSize(itemCell, nodeSides, cellSize).then(() => { + itemCell.node.width = cellSize.width; + itemCell.node.height = cellSize.height; + }); + } + this.dealItemShow(itemCell); + } + } + + /** + * 处理列表的循环利用 + * @param offset + * @param dataIndexs + */ + private dealLoopList(offset: cc.Vec3, showCells: ItemCell[]) { + let startCell = showCells[0]; + let endCell = showCells[showCells.length - 1]; + if (this.scrollView.vertical) { + /**内容上移 */ + if (offset.y > 0) { + //已经到达最后倒数第二个节点并且还有数据 + if (this.scrollView.content.y >= (- this.itemCells[this.itemCells.length - 2].node.y - this.viewSides.size.height) && endCell.dataIndex < this.datas.length - 2) { + //显示开始数据下标(这里-1是想要顶部留一个itemcell做缓冲) + let showStart = startCell.dataIndex - 1; + //剩余可展示的数据量 + let leave = this.datas.length - showStart; + //计算应该从那个位置开始重新赋值,因为如果直接移动到最上方,数据量不够覆盖所有的cell + let cellStartIndex = Math.max(0, this.itemCells.length - leave); + //计算第一个cell的数据下标 + this.curStartIndex = showStart - cellStartIndex; + + let cellTop = getNodeBorder(this.itemCells[startCell.cellIndex], [true]).topSide; + + let contentHeight = 0; + let targetY = 0; + let jumpFirst = true; + let showIndex = 0; + for (let i = 0, len = this.itemCells.length; i < len; ++i) { + if (i >= cellStartIndex) { + //将当前已经显示的showNode节点直接重新设置到移动后的节点上 + if (showIndex < showCells.length && !jumpFirst) { + if (showIndex == 0) { + targetY = contentHeight; + } + let showNode = showCells[showIndex].lostShowNode(); + showIndex++; + this.itemCells[i].getShowNode(showNode); + } + jumpFirst = false; + } + let dataIndex = this.curStartIndex + i; + let data = this.datas[dataIndex]; + let cellSize = data.size ? data.size : this.size; + contentHeight += cellSize.height; + this.itemCells[i].init(data, cellSize, dataIndex, i, this); + } + + //将content的位置移动到最上方并对齐移动前的状态 + let posY = targetY + (cellTop - this.viewSides.topSide) + this.scrollView.content.setPosition(cc.v3(this.scrollView.content.position.x, posY)); + this.scrollView.scrollToOffset(cc.v2(0, posY + endCell.size.height), 1) + this.lastPos = null; + } + } //内容下移 + else if (offset.y < 0) { + //已经到达第二个节点并且还有数据 + if (this.scrollView.content.y < (- this.itemCells[2].node.y) && startCell.dataIndex > 1) { + //展示的最后一个数据下表,+1是为了在底部预留一部分空间 + let showEndIndex = endCell.dataIndex + 1; + //计算应该从那个位置开始重新赋值,因为如果直接移动到最下方,数据量不够覆盖所有的cell + let cellEndIndex = Math.min(this.itemCells.length - 2, showEndIndex - 1); + //计算第一个cell的数据下标 + this.curStartIndex = Math.max(showEndIndex - (this.itemCells.length - 1), 0); + + //将content的位置移动到最下方并对齐移动前的状态 + let cellTop = getNodeBorder(this.itemCells[startCell.cellIndex], [true]).topSide; + + let contentHeight = 0; + let showIndex = showCells.length - 1; + for (let i = this.itemCells.length - 1; i >= 0; --i) { + if (i <= cellEndIndex) { + //将当前已经显示的showNode节点直接重新设置到移动后的节点上 + if (showIndex >= 0) { + let showNode = showCells[showIndex].lostShowNode(); + showIndex--; + this.itemCells[i].getShowNode(showNode); + } else { + showIndex--; + } + } + let dataIndex = this.curStartIndex + i; + let data = this.datas[dataIndex]; + let cellSize = data.size ? data.size : this.size; + if (showIndex < -1) { + contentHeight += cellSize.height; + } + this.itemCells[i].init(data, cellSize, dataIndex, i, this); + } + + //将content的位置移动到最下方并对齐移动前的状态 + let posY = contentHeight + (cellTop - this.viewSides.topSide) + this.scrollView.content.setPosition(cc.v3(this.scrollView.content.position.x, posY)); + this.scrollView.scrollToOffset(cc.v2(0, posY - startCell.size.height), 1) + this.lastPos = null; + } + } + } else if (this.scrollView.horizontal) { + if (offset.x < 0) { + //已经到达最后倒数第二个节点并且还有数据 + if (this.scrollView.content.x <= (- (this.itemCells[this.itemCells.length - 2].node.x - this.viewSides.size.width)) && endCell.dataIndex < this.datas.length - 2) { + //显示开始数据下标(这里-1是想要左侧留一个itemcell做缓冲) + let showStart = startCell.dataIndex - 1; + //剩余可展示的数据量 + let leave = this.datas.length - showStart; + //计算应该从那个位置开始重新赋值,因为如果直接移动到最左侧,数据量不够覆盖所有的cell + let cellStartIndex = Math.max(0, this.itemCells.length - leave); + //计算第一个cell的数据下标 + this.curStartIndex = showStart - cellStartIndex; + + let cellLeft = getNodeBorder(this.itemCells[startCell.cellIndex], [false, false, true]).leftSide; + + let contentWidth = 0; + let targetX = 0; + let jumpFirst = true; + let showIndex = 0; + for (let i = 0, len = this.itemCells.length; i < len; ++i) { + if (i >= cellStartIndex) { + //将当前已经显示的showNode节点直接重新设置到移动后的节点上 + if (showIndex < showCells.length && !jumpFirst) { + if (showIndex == 0) { + targetX = contentWidth; + } + let showNode = showCells[showIndex].lostShowNode(); + showIndex++; + this.itemCells[i].getShowNode(showNode); + } + jumpFirst = false; + } + let dataIndex = this.curStartIndex + i; + let data = this.datas[dataIndex]; + let cellSize = data.size ? data.size : this.size; + contentWidth += cellSize.width; + this.itemCells[i].init(data, cellSize, dataIndex, i, this); + } + + //将content的位置移动到最左侧并对齐移动前的状态 + let posX = (cellLeft - this.viewSides.leftSide) - targetX; + this.scrollView.content.setPosition(cc.v3(posX, this.scrollView.content.position.y)); + this.scrollView.scrollToOffset(cc.v2(-(posX - endCell.size.width), 0), 1) + this.lastPos = null; + } + } else if (offset.x > 0) { + //已经到达第二个节点并且还有数据 + if (this.scrollView.content.x > (-this.itemCells[2].node.x) && startCell.dataIndex > 1) { + //展示的最后一个数据下表,+1是为了在右侧预留一部分空间 + let showEndIndex = endCell.dataIndex + 1; + //计算应该从那个位置开始重新赋值,因为如果直接移动到最右侧,数据量不够覆盖所有的cell + let cellEndIndex = Math.min(this.itemCells.length - 2, showEndIndex - 1); + //计算第一个cell的数据下标 + this.curStartIndex = Math.max(showEndIndex - (this.itemCells.length - 1), 0); + + //将content的位置移动到最右侧并对齐移动前的状态 + let cellLeft = getNodeBorder(this.itemCells[startCell.cellIndex], [false, false, true]).leftSide; + + let contentWidth = 0; + let showIndex = showCells.length - 1; + for (let i = this.itemCells.length - 1; i >= 0; --i) { + if (i <= cellEndIndex) { + //将当前已经显示的showNode节点直接重新设置到移动后的节点上 + if (showIndex >= 0) { + let showNode = showCells[showIndex].lostShowNode(); + showIndex--; + this.itemCells[i].getShowNode(showNode); + } else { + showIndex--; + } + } + let dataIndex = this.curStartIndex + i; + let data = this.datas[dataIndex]; + let cellSize = data.size ? data.size : this.size; + if (showIndex < -1) { + contentWidth += cellSize.width; + } + this.itemCells[i].init(data, cellSize, dataIndex, i, this); + } + + //将content的位置移动到最右侧并对齐移动前的状态 + let posX = (cellLeft - this.viewSides.leftSide) - contentWidth; + this.scrollView.content.setPosition(cc.v3(posX, this.scrollView.content.position.y)); + this.scrollView.scrollToOffset(cc.v2(- (posX + startCell.size.width), 0), 1) + this.lastPos = null; + } + } + } + } + + + /**更新节点的显示 */ + public updateNodes() { + let showCells: ItemCell[] = []; + for (let i = 0, len = this.itemCells.length; i < len; ++i) { + let itemCell = this.itemCells[i]; + let isShow = this.dealItemShow(itemCell) + if (isShow) { + showCells.push(itemCell) + } + } + return showCells; + } + + /** + * 处理cell的显示隐藏 + * @param itemCell + */ + private dealItemShow(itemCell: ItemCell) { + if (itemCell) { + let isShow = this.checkInView(itemCell); + if (isShow) { + itemCell.hasNoNode && itemCell.updateShow(isShow, this.prefab, this.showNodePool.length > 0 ? this.showNodePool.pop() : null, this.renderLayer); + } else { + !itemCell.hasNoNode && this.recircleShowNode(itemCell.recircle()); + } + return isShow; + } + } + + + /** + * 检查是否在屏幕内 + * @param node + * @returns + */ + private checkInView(itemCell: ItemCell) { + let nodeSides = getNodeBorder(itemCell, [true, true, true, true]); + //节点右侧边缘在屏幕左侧外面或者节点左边缘在屏幕右侧外面 则不在显示区域 + let horizontalOutside = nodeSides.rightSide < this.viewSides.leftSide + || nodeSides.leftSide > this.viewSides.rightSide; + + let verticalOutside = false; + if (!horizontalOutside) { + //节点上边缘在屏幕下方外面或者节点下边缘在屏幕上方外面 则不在显示区域 + verticalOutside = nodeSides.topSide < this.viewSides.bottomSide + || nodeSides.bottomSide > this.viewSides.topSide; + } + return !horizontalOutside && !verticalOutside; + } + /** + * 处理变化的大小 + * @param cell + * @param nodeSides + * @param changeSize + */ + public async dealChangeSize(cell: ItemCell, nodeSides: IBorder, changeSize: cc.Size, time: number = 0.3) { + let topToBottomFulfill = (this.scrollView.content.anchorY == 1 && nodeSides.bottomSide >= this.viewSides.topSide); + let bottomToTopFulfill = (this.scrollView.content.anchorY == 0 && nodeSides.topSide <= this.viewSides.bottomSide); + if (topToBottomFulfill || bottomToTopFulfill) { + if (topToBottomFulfill) { + this.scrollView.setContentPosition(cc.v2(this.scrollView.content.x, this.scrollView.content.y + changeSize.height)) + } else { + this.scrollView.setContentPosition(cc.v2(this.scrollView.content.x, this.scrollView.content.y - changeSize.height)) + } + } + let leftToRightFulfill = (this.scrollView.content.anchorX == 0 && nodeSides.rightSide <= this.viewSides.leftSide); + let RightToLeftFulfill = (this.scrollView.content.anchorX == 1 && nodeSides.leftSide >= this.viewSides.rightSide); + if (leftToRightFulfill || RightToLeftFulfill) { + if (RightToLeftFulfill) { + this.scrollView.setContentPosition(cc.v2(this.scrollView.content.x + changeSize.width, this.scrollView.content.y)) + } else { + this.scrollView.setContentPosition(cc.v2(this.scrollView.content.x - changeSize.width, this.scrollView.content.y)) + } + } + if (!(topToBottomFulfill || bottomToTopFulfill || leftToRightFulfill || RightToLeftFulfill)) { + cc.Tween.stopAllByTarget(cell.node); + await new Promise((resolve, reject) => { + cc.tween(cell.node).to(time, { width: cell.size.width, height: cell.size.height }).call(() => { + resolve(); + }).start(); + }) + } + this.updateNodes(); + return true; + } + + /** + * 回收显示节点 + * @param node + */ + private recircleShowNode(node: ShowNode) { + node && this.showNodePool.push(node); + } + + /** + * 释放当前列表 + */ + public freeList() { + this.scrollView.node.off("scrolling", this.scrollingListener); + for (let i = 0, len = this.itemCells.length; i < len; ++i) { + this.recircleShowNode(this.itemCells[i].recircle()); + this.itemCells[i].destroy(); + } + this.itemCells = []; + for (let index = 0, len = this.showNodePool.length; index < len; ++index) { + this.showNodePool[index].destroy(); + } + this.showNodePool = []; + this.renderLayer = null; + this.scrollView = null; + this.prefab = null; + } + +} +/** + * 获取节点的边缘 + * @param node + * @param needArr 顺序是上 下 左 右 + */ +function getNodeBorder(cell: ItemCell, needArr: boolean[]) { + let node = cell.node + let boderData: IBorder = {}; + let wpos = getNodeWPos(node); + //显示区域上边缘 + if (needArr[0]) { + boderData.topSide = wpos.y + (node.height * (1 - node.anchorY)); + } + //显示区域下边缘 + if (needArr[1]) { + boderData.bottomSide = wpos.y - (node.height * node.anchorY); + } + //显示区域左边缘 + if (needArr[2]) { + boderData.leftSide = wpos.x - (node.width * node.anchorX); + } + //显示区域右边缘 + if (needArr[3]) { + boderData.rightSide = wpos.x + (node.width * (1 - node.anchorX)); + } + boderData.size = cc.size(node.width, node.height); + return boderData; +} + +/** + * 获取节点世界坐标 + * @param node + * @returns + */ +function getNodeWPos(node: cc.Node) { + return node.parent.convertToWorldSpaceAR(node.position); +} + + diff --git a/Layered_virtual_list_2.x/assets/Script/LoopList.ts.meta b/Layered_virtual_list_2.x/assets/Script/LoopList.ts.meta new file mode 100644 index 0000000..58b982f --- /dev/null +++ b/Layered_virtual_list_2.x/assets/Script/LoopList.ts.meta @@ -0,0 +1,10 @@ +{ + "ver": "1.1.0", + "uuid": "b4ec1494-dff7-4875-91b7-3837f064a937", + "importer": "typescript", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/assets/Script/RenderAlternative.ts b/Layered_virtual_list_2.x/assets/Script/RenderAlternative.ts new file mode 100644 index 0000000..c7e0afd --- /dev/null +++ b/Layered_virtual_list_2.x/assets/Script/RenderAlternative.ts @@ -0,0 +1,230 @@ +import { RenderReactiveHandler } from "./RenderReactiveHandler"; + +/** + * 目前该渲染代理功能存在的问题 + * 1.被代理节点的父级不能出现scaleX和scaleY不一致的情况,被代理节点本身没有这个限制 + */ +const { ccclass, property } = cc._decorator; +@ccclass +export default class RenderAlternative extends cc.Component { + /**渲染层节点 */ + public renderLayer: cc.Node = null; + /**渲染的zIndex 动态调整zIndex,用于方便临近合批 */ + @property + public renderZIndex: number = 0; + /**同步的间隔(帧为单位) */ + @property({ + tooltip: '设置同步的间隔(秒为单位),0就是每帧都同步,0.1就是隔0.1秒同步一次' + }) + public syncInv: number = 0.01; + /**渲染的sIndex */ + public sIndex: number = 0; + /**非渲染组件 */ + public proxyRender: cc.RenderComponent = null; + /**渲染组件 */ + private renderCompnent: cc.RenderComponent = null; + /**上次更新的数据 */ + public lastWMat4: cc.Mat4 = null; + /**上次更新的数据 */ + public lastLMat4: cc.Mat4 = null; + /**上次更新的数据 */ + public lastPos: cc.Vec3 = null; + /**距离下次刷新累计了多少间隔 */ + public accuTime: number = 0; + /**最后一次刷新时间 */ + public lastFrameTime: number = null; + /**是否进行刷新 */ + public isAttachFrame: boolean = false; + + /**获取总的ZIndex */ + get zIndex() { + let zIndex = this.renderZIndex + (this.sIndex * 0.01); + let parentNode = this.node.parent; + while (parentNode != this.renderLayer.parent && parentNode != cc.director.getScene()) { + let render = parentNode.getComponent(RenderAlternative); + if (render) { + zIndex += render.zIndex + 1; + break; + } + parentNode = parentNode.parent; + } + return zIndex; + } + + /** + * 设置渲染节点层 + * @param layer + */ + init(layer?: cc.Node): T { + if (layer) { + this.renderLayer = layer; + } + if (!this.renderLayer) { + console.warn(`节点${this.node.name}没有设置渲染层`) + return null; + } + return this.initRender(); + } + /** + * 初始化渲染节点 + */ + private initRender(): T { + let node = this.getRender(); + node.setParent(this.renderLayer ? this.renderLayer : cc.director.getScene().getChildByName("Canvas")); + this.isAttachFrame = true; + requestAnimationFrame(this.frameUpdate.bind(this)); + return this.doProxy(); + } + /**生成代理 */ + private doProxy(): T { + this.proxyRender = new Proxy(this.renderCompnent, new RenderReactiveHandler()) as T; + return this.proxyRender as T; + } + + + protected frameUpdate(): void { + let now = cc.sys.now(); + !this.lastFrameTime && (this.lastFrameTime = now); + let dt = now - this.lastFrameTime; + if (this.proxyRender) { + this.accuTime += dt; + if (this.accuTime >= this.syncInv) { + this.accuTime -= this.syncInv; + this.updateProp(); + } + } + if (this.isAttachFrame) { + requestAnimationFrame(this.frameUpdate.bind(this)); + } + } + + /**更新最新状态 */ + public updateProp() { + let node = this.renderCompnent.node; + if (!this.node.activeInHierarchy) { + node.opacity = 0; + return; + } + node.anchorX = this.node.anchorX; + node.anchorY = this.node.anchorY; + node.width = this.node.width; + node.height = this.node.height; + node.group = this.node.group; + node.color = this.node.color; + node.opacity = this.getOpacity(this.node); + + let wMat4 = cc.mat4(); + this.node.getWorldMatrix(wMat4); + if (!this.lastWMat4 || !this.lastWMat4.equals(wMat4)) { + let localMatrix = this.getLocalMatrix(wMat4, node); + this.setLocalXYZScaleAngle(localMatrix, node, this.lastLMat4); + this.lastWMat4 = wMat4; + this.lastLMat4 = localMatrix; + } + node.zIndex = this.zIndex; + } + + private getLocalMatrix(worldMatrix: cc.Mat4, node: cc.Node) { + let parentNode = null; + if (cc.isValid(node)) { + if (cc.isValid(node.parent)) { + parentNode = node.parent + } + } + // 获取父节点的世界矩阵 + let parentWorldMatrix = cc.mat4(); + parentNode.getWorldMatrix(parentWorldMatrix); + // 获取父节点的逆矩阵 + let parentInverseMatrix = parentWorldMatrix.invert(); + // 将目标节点的世界矩阵转换为父节点的本地矩阵 + let localMatrix = parentInverseMatrix.multiply(worldMatrix); + return localMatrix; + + } + + private setLocalXYZScaleAngle(matrix: cc.Mat4, node: cc.Node, lastMatrix?: cc.Mat4) { + if (lastMatrix && matrix.equals(lastMatrix)) { + return; + } + + // 提取位置 + node.setPosition(matrix.m[12], matrix.m[13], matrix.m[14]); + + let scaleX = null; + let scaleY = null; + let angle = null; + // 提取缩放X + if (!lastMatrix) { + scaleX = Math.sqrt(matrix.m[0] * matrix.m[0] + matrix.m[1] * matrix.m[1] + matrix.m[2] * matrix.m[2]); + } else if (!this.equalsValue(matrix.m[0], lastMatrix.m[0]) + || !this.equalsValue(matrix.m[1], lastMatrix.m[1]) + || !this.equalsValue(matrix.m[2], lastMatrix.m[2])) { + scaleX = Math.sqrt(matrix.m[0] * matrix.m[0] + matrix.m[1] * matrix.m[1] + matrix.m[2] * matrix.m[2]); + } + // 提取缩放Y + if (!lastMatrix) { + scaleY = Math.sqrt(matrix.m[4] * matrix.m[4] + matrix.m[5] * matrix.m[5] + matrix.m[6] * matrix.m[6]); + } else if (!this.equalsValue(matrix.m[4], lastMatrix.m[4]) + || !this.equalsValue(matrix.m[5], lastMatrix.m[5]) + || !this.equalsValue(matrix.m[6], lastMatrix.m[6])) { + scaleY = Math.sqrt(matrix.m[4] * matrix.m[4] + matrix.m[5] * matrix.m[5] + matrix.m[6] * matrix.m[6]); + } + //设置缩放X + if (scaleX !== null) { + node.scaleX = scaleX; + // 提取旋转 + angle = Math.atan2(matrix.m[1] / scaleX, matrix.m[0] / scaleX) * (180 / Math.PI); + } + if (scaleY !== null) { + node.scaleY = scaleY; + } + if (angle !== null) { + node.rotation = angle; + } + } + + private equalsValue(a: number, b: number, epsilon: number = 0.00001) { + return Math.abs(a - b) < epsilon; + } + + protected onDestroy(): void { + this.renderCompnent.node.destroy(); + this.renderCompnent = null; + this.proxyRender = null; + } + + /** + * 获取节点透明度 + * @param node + */ + private getOpacity(node: cc.Node) { + let opacity = (node.opacity / 255); + let parentNode = node.parent + while (parentNode != this.renderLayer.parent && parentNode != cc.director.getScene()) { + opacity *= (parentNode.opacity / 255); + parentNode = parentNode.parent; + } + return opacity * 255; + } + /** + * 获取渲染组件 + * @param node + */ + private getRender() { + let node = cc.instantiate(this.node); + node.removeAllChildren(); + this.renderCompnent = node.getComponent(cc.RenderComponent); + this.node.getComponent(cc.LabelOutline)?.destroy(); + this.node.getComponent(cc.LabelShadow)?.destroy(); + this.node.getComponent(cc.RenderComponent).destroy(); + let components = node.getComponents(cc.Component); + for (let i = 0, len = components.length; i < len; ++i) { + let comp = components[i]; + if (!((comp instanceof cc.RenderComponent) || (comp instanceof cc.LabelOutline) || (comp instanceof cc.LabelShadow))) { + comp.destroy(); + } + } + return node; + } + +} diff --git a/Layered_virtual_list_2.x/assets/Script/RenderAlternative.ts.meta b/Layered_virtual_list_2.x/assets/Script/RenderAlternative.ts.meta new file mode 100644 index 0000000..01ad845 --- /dev/null +++ b/Layered_virtual_list_2.x/assets/Script/RenderAlternative.ts.meta @@ -0,0 +1,10 @@ +{ + "ver": "1.1.0", + "uuid": "f9782c63-e103-4af3-8d8e-007a1a6d115b", + "importer": "typescript", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/assets/Script/RenderAlternative1.ts b/Layered_virtual_list_2.x/assets/Script/RenderAlternative1.ts new file mode 100644 index 0000000..c7e0afd --- /dev/null +++ b/Layered_virtual_list_2.x/assets/Script/RenderAlternative1.ts @@ -0,0 +1,230 @@ +import { RenderReactiveHandler } from "./RenderReactiveHandler"; + +/** + * 目前该渲染代理功能存在的问题 + * 1.被代理节点的父级不能出现scaleX和scaleY不一致的情况,被代理节点本身没有这个限制 + */ +const { ccclass, property } = cc._decorator; +@ccclass +export default class RenderAlternative extends cc.Component { + /**渲染层节点 */ + public renderLayer: cc.Node = null; + /**渲染的zIndex 动态调整zIndex,用于方便临近合批 */ + @property + public renderZIndex: number = 0; + /**同步的间隔(帧为单位) */ + @property({ + tooltip: '设置同步的间隔(秒为单位),0就是每帧都同步,0.1就是隔0.1秒同步一次' + }) + public syncInv: number = 0.01; + /**渲染的sIndex */ + public sIndex: number = 0; + /**非渲染组件 */ + public proxyRender: cc.RenderComponent = null; + /**渲染组件 */ + private renderCompnent: cc.RenderComponent = null; + /**上次更新的数据 */ + public lastWMat4: cc.Mat4 = null; + /**上次更新的数据 */ + public lastLMat4: cc.Mat4 = null; + /**上次更新的数据 */ + public lastPos: cc.Vec3 = null; + /**距离下次刷新累计了多少间隔 */ + public accuTime: number = 0; + /**最后一次刷新时间 */ + public lastFrameTime: number = null; + /**是否进行刷新 */ + public isAttachFrame: boolean = false; + + /**获取总的ZIndex */ + get zIndex() { + let zIndex = this.renderZIndex + (this.sIndex * 0.01); + let parentNode = this.node.parent; + while (parentNode != this.renderLayer.parent && parentNode != cc.director.getScene()) { + let render = parentNode.getComponent(RenderAlternative); + if (render) { + zIndex += render.zIndex + 1; + break; + } + parentNode = parentNode.parent; + } + return zIndex; + } + + /** + * 设置渲染节点层 + * @param layer + */ + init(layer?: cc.Node): T { + if (layer) { + this.renderLayer = layer; + } + if (!this.renderLayer) { + console.warn(`节点${this.node.name}没有设置渲染层`) + return null; + } + return this.initRender(); + } + /** + * 初始化渲染节点 + */ + private initRender(): T { + let node = this.getRender(); + node.setParent(this.renderLayer ? this.renderLayer : cc.director.getScene().getChildByName("Canvas")); + this.isAttachFrame = true; + requestAnimationFrame(this.frameUpdate.bind(this)); + return this.doProxy(); + } + /**生成代理 */ + private doProxy(): T { + this.proxyRender = new Proxy(this.renderCompnent, new RenderReactiveHandler()) as T; + return this.proxyRender as T; + } + + + protected frameUpdate(): void { + let now = cc.sys.now(); + !this.lastFrameTime && (this.lastFrameTime = now); + let dt = now - this.lastFrameTime; + if (this.proxyRender) { + this.accuTime += dt; + if (this.accuTime >= this.syncInv) { + this.accuTime -= this.syncInv; + this.updateProp(); + } + } + if (this.isAttachFrame) { + requestAnimationFrame(this.frameUpdate.bind(this)); + } + } + + /**更新最新状态 */ + public updateProp() { + let node = this.renderCompnent.node; + if (!this.node.activeInHierarchy) { + node.opacity = 0; + return; + } + node.anchorX = this.node.anchorX; + node.anchorY = this.node.anchorY; + node.width = this.node.width; + node.height = this.node.height; + node.group = this.node.group; + node.color = this.node.color; + node.opacity = this.getOpacity(this.node); + + let wMat4 = cc.mat4(); + this.node.getWorldMatrix(wMat4); + if (!this.lastWMat4 || !this.lastWMat4.equals(wMat4)) { + let localMatrix = this.getLocalMatrix(wMat4, node); + this.setLocalXYZScaleAngle(localMatrix, node, this.lastLMat4); + this.lastWMat4 = wMat4; + this.lastLMat4 = localMatrix; + } + node.zIndex = this.zIndex; + } + + private getLocalMatrix(worldMatrix: cc.Mat4, node: cc.Node) { + let parentNode = null; + if (cc.isValid(node)) { + if (cc.isValid(node.parent)) { + parentNode = node.parent + } + } + // 获取父节点的世界矩阵 + let parentWorldMatrix = cc.mat4(); + parentNode.getWorldMatrix(parentWorldMatrix); + // 获取父节点的逆矩阵 + let parentInverseMatrix = parentWorldMatrix.invert(); + // 将目标节点的世界矩阵转换为父节点的本地矩阵 + let localMatrix = parentInverseMatrix.multiply(worldMatrix); + return localMatrix; + + } + + private setLocalXYZScaleAngle(matrix: cc.Mat4, node: cc.Node, lastMatrix?: cc.Mat4) { + if (lastMatrix && matrix.equals(lastMatrix)) { + return; + } + + // 提取位置 + node.setPosition(matrix.m[12], matrix.m[13], matrix.m[14]); + + let scaleX = null; + let scaleY = null; + let angle = null; + // 提取缩放X + if (!lastMatrix) { + scaleX = Math.sqrt(matrix.m[0] * matrix.m[0] + matrix.m[1] * matrix.m[1] + matrix.m[2] * matrix.m[2]); + } else if (!this.equalsValue(matrix.m[0], lastMatrix.m[0]) + || !this.equalsValue(matrix.m[1], lastMatrix.m[1]) + || !this.equalsValue(matrix.m[2], lastMatrix.m[2])) { + scaleX = Math.sqrt(matrix.m[0] * matrix.m[0] + matrix.m[1] * matrix.m[1] + matrix.m[2] * matrix.m[2]); + } + // 提取缩放Y + if (!lastMatrix) { + scaleY = Math.sqrt(matrix.m[4] * matrix.m[4] + matrix.m[5] * matrix.m[5] + matrix.m[6] * matrix.m[6]); + } else if (!this.equalsValue(matrix.m[4], lastMatrix.m[4]) + || !this.equalsValue(matrix.m[5], lastMatrix.m[5]) + || !this.equalsValue(matrix.m[6], lastMatrix.m[6])) { + scaleY = Math.sqrt(matrix.m[4] * matrix.m[4] + matrix.m[5] * matrix.m[5] + matrix.m[6] * matrix.m[6]); + } + //设置缩放X + if (scaleX !== null) { + node.scaleX = scaleX; + // 提取旋转 + angle = Math.atan2(matrix.m[1] / scaleX, matrix.m[0] / scaleX) * (180 / Math.PI); + } + if (scaleY !== null) { + node.scaleY = scaleY; + } + if (angle !== null) { + node.rotation = angle; + } + } + + private equalsValue(a: number, b: number, epsilon: number = 0.00001) { + return Math.abs(a - b) < epsilon; + } + + protected onDestroy(): void { + this.renderCompnent.node.destroy(); + this.renderCompnent = null; + this.proxyRender = null; + } + + /** + * 获取节点透明度 + * @param node + */ + private getOpacity(node: cc.Node) { + let opacity = (node.opacity / 255); + let parentNode = node.parent + while (parentNode != this.renderLayer.parent && parentNode != cc.director.getScene()) { + opacity *= (parentNode.opacity / 255); + parentNode = parentNode.parent; + } + return opacity * 255; + } + /** + * 获取渲染组件 + * @param node + */ + private getRender() { + let node = cc.instantiate(this.node); + node.removeAllChildren(); + this.renderCompnent = node.getComponent(cc.RenderComponent); + this.node.getComponent(cc.LabelOutline)?.destroy(); + this.node.getComponent(cc.LabelShadow)?.destroy(); + this.node.getComponent(cc.RenderComponent).destroy(); + let components = node.getComponents(cc.Component); + for (let i = 0, len = components.length; i < len; ++i) { + let comp = components[i]; + if (!((comp instanceof cc.RenderComponent) || (comp instanceof cc.LabelOutline) || (comp instanceof cc.LabelShadow))) { + comp.destroy(); + } + } + return node; + } + +} diff --git a/Layered_virtual_list_2.x/assets/Script/RenderAlternative1.ts.meta b/Layered_virtual_list_2.x/assets/Script/RenderAlternative1.ts.meta new file mode 100644 index 0000000..827e316 --- /dev/null +++ b/Layered_virtual_list_2.x/assets/Script/RenderAlternative1.ts.meta @@ -0,0 +1,10 @@ +{ + "ver": "1.1.0", + "uuid": "5be1578b-9d99-422a-a3ca-e01dd8e09eb1", + "importer": "typescript", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/assets/Script/RenderAlternativeItem.ts b/Layered_virtual_list_2.x/assets/Script/RenderAlternativeItem.ts new file mode 100644 index 0000000..0203397 --- /dev/null +++ b/Layered_virtual_list_2.x/assets/Script/RenderAlternativeItem.ts @@ -0,0 +1,73 @@ +import RenderAlternative from "./RenderAlternative"; + + +const { ccclass, property } = cc._decorator; + +@ccclass +/** + * 渲染分层Item挂载组件 + * 处理渲染分层Item的渲染分层 + */ +export default class RenderAlternativeItem extends cc.Component { + + /**是否初始化过代理组建 */ + private hasInit: boolean = false; + /**渲染分层开启的挂载节点 */ + public renderLayer: cc.Node; + /**初始化 */ + public initRenderLayer(renderLayer: cc.Node) { + if (this.renderLayer != renderLayer) { + this.renderLayer = renderLayer; + renderLayer && this.initRenders(); + } + } + /** + * 处理分层代理渲染 + */ + private initRenders() { + if (!this.hasInit && this.renderLayer) { + // + let propMap: WeakMap = new WeakMap(); + let keys = Object.keys(this); + for (let i = 0, len = keys.length; i < len; ++i) { + let value = this[keys[i]]; + let alternative: RenderAlternative = null; + if (value instanceof cc.Node) { + alternative = value.getComponent(RenderAlternative); + if (alternative) { + alternative.init(this.renderLayer); + } + } else if (value instanceof cc.RenderComponent) { + alternative = value.getComponent(RenderAlternative); + if (alternative) { + this[keys[i]] = alternative.init(this.renderLayer); + } + } + alternative && propMap.set(alternative, true); + } + this.dealChilrenAlternative(this.node, propMap, 0, 0); + this.hasInit = true; + } + } + /** + * 处理子节点代理 + * @param node + * @param propMap 记录脚本已经处理过的属性代理 + * @param parentSindex 父节点的所在的顺序 + * @param depth 深度 + */ + dealChilrenAlternative(node: cc.Node, propMap: WeakMap, parentSindex: number, depth: number) { + for (let i = 0, len = node.children.length; i < len; i++) { + let children = node.children[i]; + let alternative = children.getComponent(cc.RenderComponent)?.getComponent(RenderAlternative); + let sIndex = parentSindex + (i * Math.pow(0.1, depth)); + if (alternative) { + if ((!propMap.has(alternative) || !propMap.get(alternative))) { + alternative.init(this.renderLayer); + } + alternative.sIndex = sIndex; + } + this.dealChilrenAlternative(children, propMap, sIndex, depth + 1); + } + } +} diff --git a/Layered_virtual_list_2.x/assets/Script/RenderAlternativeItem.ts.meta b/Layered_virtual_list_2.x/assets/Script/RenderAlternativeItem.ts.meta new file mode 100644 index 0000000..0e46ff8 --- /dev/null +++ b/Layered_virtual_list_2.x/assets/Script/RenderAlternativeItem.ts.meta @@ -0,0 +1,10 @@ +{ + "ver": "1.1.0", + "uuid": "d33f6314-18ec-4937-978c-27d5334b7287", + "importer": "typescript", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/assets/Script/RenderAlternative_old.ts b/Layered_virtual_list_2.x/assets/Script/RenderAlternative_old.ts new file mode 100644 index 0000000..444e0ab --- /dev/null +++ b/Layered_virtual_list_2.x/assets/Script/RenderAlternative_old.ts @@ -0,0 +1,219 @@ +import { RenderReactiveHandler } from "./RenderReactiveHandler"; + +/** + * 目前该渲染代理功能存在的问题 + * 1.被代理节点的父级不能出现scaleX和scaleY不一致的情况,被代理节点本身没有这个限制 + */ +const { ccclass, property } = cc._decorator; +@ccclass +export default class RenderAlternative extends cc.Component { + /**渲染层节点 */ + public renderLayer: cc.Node = null; + /**渲染的zIndex 动态调整zIndex,用于方便临近合批 */ + @property + public renderZIndex: number = 0; + /**同步的间隔(帧为单位) */ + @property({ + tooltip: '设置同步的间隔(秒为单位),0就是每帧都同步,0.1就是隔0.1秒同步一次' + }) + public syncInv: number = 0.01; + /**渲染的sIndex */ + public sIndex: number = 0; + /**非渲染组件 */ + public proxyRender: cc.RenderComponent = null; + /**渲染组件 */ + private renderCompnent: cc.RenderComponent = null; + /**上次更新的数据 */ + public lastWMat4: cc.Mat4 = null; + /**上次更新的数据 */ + public lastLMat4: cc.Mat4 = null; + /**上次更新的数据 */ + public lastPos: cc.Vec3 = null; + /**距离下次刷新累计了多少间隔 */ + public accuTime: number = 0; + /**最后一次刷新时间 */ + public lastFrameTime: number = null; + /**是否进行刷新 */ + public isAttachFrame: boolean = false; + + /**获取总的ZIndex */ + get zIndex() { + let zIndex = this.renderZIndex + (this.sIndex * 0.01); + let parentNode = this.node.parent; + while (parentNode != this.renderLayer.parent && parentNode != cc.director.getScene()) { + let render = parentNode.getComponent(RenderAlternative); + if (render) { + zIndex += render.zIndex + 1; + break; + } + parentNode = parentNode.parent; + } + return zIndex; + } + + /** + * 设置渲染节点层 + * @param layer + */ + init(layer?: cc.Node): T { + if (layer) { + this.renderLayer = layer; + } + if (!this.renderLayer) { + console.warn(`节点${this.node.name}没有设置渲染层`) + return null; + } + return this.initRender(); + } + /** + * 初始化渲染节点 + */ + private initRender(): T { + let node = this.getRender(); + node.setParent(this.renderLayer ? this.renderLayer : cc.director.getScene().getChildByName("Canvas")); + this.isAttachFrame = true; + requestAnimationFrame(this.frameUpdate.bind(this)); + return this.doProxy(); + } + /**生成代理 */ + private doProxy(): T { + this.proxyRender = new Proxy(this.renderCompnent, new RenderReactiveHandler()) as T; + return this.proxyRender as T; + } + + + protected frameUpdate(): void { + let now = cc.sys.now(); + !this.lastFrameTime && (this.lastFrameTime = now); + let dt = now - this.lastFrameTime; + if (this.proxyRender) { + this.accuTime += dt; + if (this.accuTime >= this.syncInv) { + this.accuTime -= this.syncInv; + this.updateProp(); + } + } + if (this.isAttachFrame) { + requestAnimationFrame(this.frameUpdate.bind(this)); + } + } + + /**更新最新状态 */ + public updateProp() { + let node = this.renderCompnent.node; + if (!this.node.activeInHierarchy) { + node.opacity = 0; + return; + } + node.anchorX = this.node.anchorX; + node.anchorY = this.node.anchorY; + node.width = this.node.width; + node.height = this.node.height; + node.group = this.node.group; + node.color = this.node.color; + node.opacity = this.getOpacity(this.node); + + let wMat4 = cc.mat4(); + this.node.getWorldMatrix(wMat4); + /* let lMat4 = cc.mat4(); + this.node.getLocalMatrix(wMat4); */ + //此处本可以过滤许多不必要的更新,但尚未排查出问题 + if (true /* || !this.lastWMat4?.equals(wMat4) || !this.lastLMat4?.equals(lMat4) */) { + this.onAngleChange(wMat4); + this.onScaleChange(wMat4); + this.onPosChange(); + /* this.lastLMat4 = lMat4; + this.lastWMat4 = wMat4; */ + } + node.zIndex = this.zIndex; + node.zIndex = this.zIndex; + } + + protected onDestroy(): void { + this.renderCompnent.node.destroy(); + this.renderCompnent = null; + this.proxyRender = null; + } + + /** + * 获取节点透明度 + * @param node + */ + private getOpacity(node: cc.Node) { + let opacity = (node.opacity / 255); + let parentNode = node.parent + while (parentNode != this.renderLayer.parent && parentNode != cc.director.getScene()) { + opacity *= (parentNode.opacity / 255); + parentNode = parentNode.parent; + } + return opacity * 255; + } + /**位置变化处理 */ + private onPosChange() { + let wpos = this.node.parent.convertToWorldSpaceAR(this.node.position); + this.renderCompnent.node.position = this.renderLayer.convertToNodeSpaceAR(wpos); + } + /**旋转变化处理 */ + private onAngleChange(mat4: cc.Mat4) { + this.renderCompnent.node.angle = this.extractRotationAngleFromMat4(mat4); + } + /** + * 从 cc.Mat4 中获取旋转角度(不受缩放影响) + * @param matrix 输入的 cc.Mat4 矩阵 + * @returns 旋转角度(以度为单位) + */ + private extractRotationAngleFromMat4(matrix: cc.Mat4): number { + // 提取旋转部分 + let scaleX = Math.sqrt(matrix.m[0] * matrix.m[0] + matrix.m[4] * matrix.m[4] + matrix.m[8] * matrix.m[8]); + let scaleY = Math.sqrt(matrix.m[1] * matrix.m[1] + matrix.m[5] * matrix.m[5] + matrix.m[9] * matrix.m[9]); + + // 计算 Z 轴旋转角度(绕 Z 轴的旋转角度) + let angle = Math.atan2(matrix.m[1] / scaleY, matrix.m[0] / scaleX); + + // 将弧度转换为角度 + let degrees = angle * (180 / Math.PI); + return degrees; + } + /** + * 缩放变化处理 + * @param mat4 + */ + private onScaleChange(mat4: cc.Mat4) { + let scale = this.extractScaleFromMat4(mat4) + this.renderCompnent.node.scaleX = scale.x; + this.renderCompnent.node.scaleY = scale.y; + this.renderCompnent.node.scaleZ = scale.z; + } + /** + * 从mat4中获取缩放值 + * @param mat4 + * @returns + */ + private extractScaleFromMat4(mat4: cc.Mat4): cc.Vec3 { + let scaleX = cc.v3(mat4.m[0], mat4.m[1], mat4.m[2]).mag(); + let scaleY = cc.v3(mat4.m[4], mat4.m[5], mat4.m[6]).mag(); + let scaleZ = cc.v3(mat4.m[8], mat4.m[9], mat4.m[10]).mag(); + return cc.v3(scaleX, scaleY, scaleZ); + } + /** + * 获取渲染组件 + * @param node + */ + private getRender() { + let node = cc.instantiate(this.node); + node.removeAllChildren(); + this.renderCompnent = node.getComponent(cc.RenderComponent); + this.node.getComponent(cc.LabelOutline)?.destroy(); + this.node.getComponent(cc.LabelShadow)?.destroy(); + this.node.getComponent(cc.RenderComponent).destroy(); + let components = node.getComponents(cc.Component); + for (let i = 0, len = components.length; i < len; ++i) { + let comp = components[i]; + if (!((comp instanceof cc.RenderComponent) || (comp instanceof cc.LabelOutline) || (comp instanceof cc.LabelShadow))) { + comp.destroy(); + } + } + return node; + } + +} diff --git a/Layered_virtual_list_2.x/assets/Script/RenderAlternative_old.ts.meta b/Layered_virtual_list_2.x/assets/Script/RenderAlternative_old.ts.meta new file mode 100644 index 0000000..e5b19f1 --- /dev/null +++ b/Layered_virtual_list_2.x/assets/Script/RenderAlternative_old.ts.meta @@ -0,0 +1,10 @@ +{ + "ver": "1.1.0", + "uuid": "1b4785ab-e079-4c84-b756-9c959c0fa7e2", + "importer": "typescript", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/assets/Script/RenderReactiveHandler.ts b/Layered_virtual_list_2.x/assets/Script/RenderReactiveHandler.ts new file mode 100644 index 0000000..0808316 --- /dev/null +++ b/Layered_virtual_list_2.x/assets/Script/RenderReactiveHandler.ts @@ -0,0 +1,81 @@ + +export function isObject(value: unknown): value is Record { + return value !== null && typeof value === 'object'; +} + +const hasOwnProperty = Object.prototype.hasOwnProperty +/** 是否自身上存在属性 */ +export function hasOwn(val: object, key: string | number | symbol): key is keyof typeof val { + if (val instanceof cc.Component) { + return key in val; + } + return hasOwnProperty.call(val, key); +} + +/** 比较值是否变化了,考虑NaN;如果是对象直接认为改变了 */ +export function hasChanged(value: any, oldValue: any): boolean { + let type = typeof value; + if (type === "object") return true; + return !Object.is(value, oldValue); +} + + +export class RenderReactiveHandler { + constructor(reactiveTarget?: object) { + this.reactiveTarget = reactiveTarget; + } + /**需要作出反应的对象 */ + private reactiveTarget: object = null; + + /** + * + * @param target 被代理的对象 + * @param prop 被代理的对象的属性名 + * @param value 被代理的对象的属性值 + * @param receiver 代理对象 + * @returns + */ + set(target: object, prop: string | symbol, value: any, receiver: any): boolean { + + let oldValue = Reflect.get(target, prop); + let hadKey = hasOwn(target, prop); + let result = Reflect.set(target, prop, value); + if (!hadKey || hasChanged(value, oldValue)) { + if (prop == "angle" || prop == 'scale' || prop == "position" || prop == "_renderFlag") return; + if (prop == 'activeInHierarchy') { + console.warn(target); + } + // 属性变化 + this.reactiveTarget && (Reflect.set(this.reactiveTarget, prop, value)); + } + + return result + } + + apply() { + console.warn(arguments) + } + + get(target: object, prop: string | symbol, receiver: any): any { + + if (prop === '__raw__') { + return target; + } + else if (prop === '__isReactive__') { + return true; + } + let rawValue = Reflect.get(target, prop); + return rawValue; + } + + deleteProperty(target: object, prop: string | symbol): boolean { + let hadKey = hasOwn(target, prop); + let oldValue = target[prop]; + let result = Reflect.deleteProperty(target, prop); + if (result && hadKey) { + //trigger(target, prop, void 0, oldValue); + } + + return result; + } +} diff --git a/Layered_virtual_list_2.x/assets/Script/RenderReactiveHandler.ts.meta b/Layered_virtual_list_2.x/assets/Script/RenderReactiveHandler.ts.meta new file mode 100644 index 0000000..01cc381 --- /dev/null +++ b/Layered_virtual_list_2.x/assets/Script/RenderReactiveHandler.ts.meta @@ -0,0 +1,10 @@ +{ + "ver": "1.1.0", + "uuid": "d38d025a-fb9d-4cf0-bf13-61343069ef50", + "importer": "typescript", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/build/web-mobile/assets/internal/config.cb4f5.json b/Layered_virtual_list_2.x/build/web-mobile/assets/internal/config.cb4f5.json new file mode 100644 index 0000000..bd71453 --- /dev/null +++ b/Layered_virtual_list_2.x/build/web-mobile/assets/internal/config.cb4f5.json @@ -0,0 +1,149 @@ +{ + "paths": { + "30aC+Hnw1PF4pEcoY3kUYb": [ + "effects/builtin-2d-graphics", + "cc.EffectAsset" + ], + "14TDKXr2NJ6LjvHPops74o": [ + "effects/builtin-2d-gray-sprite", + "cc.EffectAsset" + ], + "f1h0LXVtJOta5JLZ1xCzfI": [ + "effects/builtin-2d-label", + "cc.EffectAsset" + ], + "0ek66qC1NOQLjgYmi04HvX": [ + "effects/builtin-2d-spine", + "cc.EffectAsset" + ], + "28dPjdQWxEQIG3VVl1Qm6T": [ + "effects/builtin-2d-sprite", + "cc.EffectAsset" + ], + "82migssElAGb04Ws6NimQX": [ + "effects/builtin-3d-particle", + "cc.EffectAsset" + ], + "2afAA24LNP4YmYiaVLiivs": [ + "effects/builtin-3d-trail", + "cc.EffectAsset" + ], + "c0BAyVxX9JzZy8EjFrc9DU": [ + "effects/builtin-clear-stencil", + "cc.EffectAsset" + ], + "6dkeWRTOBGXICfYQ7JUBnG": [ + "effects/builtin-unlit", + "cc.EffectAsset" + ], + "6fgBCSDDdPMInvyNlggls2": [ + "materials/builtin-2d-base", + "cc.Material" + ], + "a1U5RdJRFMFL57BdJC9H1X": [ + "materials/builtin-2d-graphics", + "cc.Material" + ], + "3ae7efMv1CLq2ilvUY/tQi": [ + "materials/builtin-2d-gray-sprite", + "cc.Material" + ], + "e0LYfU5ZlNFoAB4UiRrGUG": [ + "materials/builtin-2d-label", + "cc.Material" + ], + "7a/QZLET9IDreTiBfRn2PD": [ + "materials/builtin-2d-spine", + "cc.Material" + ], + "ecpdLyjvZBwrvm+cedCcQy": [ + "materials/builtin-2d-sprite", + "cc.Material" + ], + "43L6CczwNM/6GGmCYEQIoH": [ + "materials/builtin-3d-particle", + "cc.Material" + ], + "46bU+b5fROqIXVPG6aZWWK": [ + "materials/builtin-3d-trail", + "cc.Material" + ], + "cffgu4qBxEqa150o1DmRAy": [ + "materials/builtin-clear-stencil", + "cc.Material" + ], + "2aKWBXJHxKHLvrBUi2yYZQ": [ + "materials/builtin-unlit", + "cc.Material" + ] + }, + "uuids": [ + "02delMVqdBD70a/HSD99FK", + "0ek66qC1NOQLjgYmi04HvX", + "14TDKXr2NJ6LjvHPops74o", + "28dPjdQWxEQIG3VVl1Qm6T", + "2aKWBXJHxKHLvrBUi2yYZQ", + "2afAA24LNP4YmYiaVLiivs", + "30aC+Hnw1PF4pEcoY3kUYb", + "3ae7efMv1CLq2ilvUY/tQi", + "43L6CczwNM/6GGmCYEQIoH", + "46bU+b5fROqIXVPG6aZWWK", + "60AwGqM1dKELCGhPAR+jK6", + "6dkeWRTOBGXICfYQ7JUBnG", + "6fgBCSDDdPMInvyNlggls2", + "7a/QZLET9IDreTiBfRn2PD", + "82migssElAGb04Ws6NimQX", + "a1U5RdJRFMFL57BdJC9H1X", + "c0BAyVxX9JzZy8EjFrc9DU", + "cffgu4qBxEqa150o1DmRAy", + "e0LYfU5ZlNFoAB4UiRrGUG", + "ecpdLyjvZBwrvm+cedCcQy", + "f1h0LXVtJOta5JLZ1xCzfI" + ], + "scenes": {}, + "redirect": [], + "deps": [], + "packs": { + "0b6c4470e": [ + "02delMVqdBD70a/HSD99FK", + "0ek66qC1NOQLjgYmi04HvX", + "14TDKXr2NJ6LjvHPops74o", + "28dPjdQWxEQIG3VVl1Qm6T", + "2aKWBXJHxKHLvrBUi2yYZQ", + "2afAA24LNP4YmYiaVLiivs", + "30aC+Hnw1PF4pEcoY3kUYb", + "3ae7efMv1CLq2ilvUY/tQi", + "43L6CczwNM/6GGmCYEQIoH", + "46bU+b5fROqIXVPG6aZWWK", + "60AwGqM1dKELCGhPAR+jK6", + "6dkeWRTOBGXICfYQ7JUBnG", + "6fgBCSDDdPMInvyNlggls2", + "7a/QZLET9IDreTiBfRn2PD", + "82migssElAGb04Ws6NimQX", + "a1U5RdJRFMFL57BdJC9H1X", + "c0BAyVxX9JzZy8EjFrc9DU", + "cffgu4qBxEqa150o1DmRAy", + "e0LYfU5ZlNFoAB4UiRrGUG", + "ecpdLyjvZBwrvm+cedCcQy", + "f1h0LXVtJOta5JLZ1xCzfI" + ] + }, + "name": "internal", + "importBase": "import", + "nativeBase": "native", + "debug": true, + "isZip": false, + "encrypted": false, + "versions": { + "import": [ + "0b6c4470e", + "ff771" + ], + "native": [ + "02delMVqdBD70a/HSD99FK", + "cea68", + "60AwGqM1dKELCGhPAR+jK6", + "c3a3a" + ] + } +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/build/web-mobile/assets/internal/import/0b/0b6c4470e.ff771.json b/Layered_virtual_list_2.x/build/web-mobile/assets/internal/import/0b/0b6c4470e.ff771.json new file mode 100644 index 0000000..1452bfd --- /dev/null +++ b/Layered_virtual_list_2.x/build/web-mobile/assets/internal/import/0b/0b6c4470e.ff771.json @@ -0,0 +1,3058 @@ +[ + 1, + [ + "02delMVqdBD70a/HSD99FK", + "28dPjdQWxEQIG3VVl1Qm6T", + "6dkeWRTOBGXICfYQ7JUBnG", + "14TDKXr2NJ6LjvHPops74o", + "60AwGqM1dKELCGhPAR+jK6", + "82migssElAGb04Ws6NimQX", + "2afAA24LNP4YmYiaVLiivs", + "0ek66qC1NOQLjgYmi04HvX", + "30aC+Hnw1PF4pEcoY3kUYb", + "c0BAyVxX9JzZy8EjFrc9DU", + "f1h0LXVtJOta5JLZ1xCzfI" + ], + [ + "_effectAsset", + "mainTexture", + "diffuseTexture" + ], + [ + "cc.Texture2D", + [ + "cc.EffectAsset", + [ + "_name", + "shaders", + "techniques" + ], + 0 + ], + [ + "cc.Material", + [ + "_name", + "_techniqueData" + ], + 2, + 11 + ], + [ + "cc.Material", + [ + "_name", + "_techniqueData" + ], + 1 + ] + ], + [ + [ + 1, + 0, + 1, + 2, + 4 + ], + [ + 3, + 0, + 1, + 3 + ], + [ + 2, + 0, + 1, + 2 + ] + ], + [ + [ + [ + "0,9729,9729,33071,33071,0,0,1", + -1 + ], + [ + 0 + ], + 0, + [], + [], + [] + ], + [ + [ + [ + 0, + "builtin-2d-spine", + [ + { + "hash": 3550530479, + "record": null, + "name": "builtin-2d-spine|vs|fs", + "glsl3": { + "vert": "\nprecision highp float;\nuniform CCGlobal {\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\nuniform CCLocal {\n mat4 cc_matWorld;\n mat4 cc_matWorldIT;\n};\nin vec3 a_position;\nin vec4 a_color;\n#if USE_TINT\n in vec4 a_color0;\n#endif\nin vec2 a_uv0;\nout vec2 v_uv0;\nout vec4 v_light;\n#if USE_TINT\n out vec4 v_dark;\n#endif\nvoid main () {\n mat4 mvp;\n #if CC_USE_MODEL\n mvp = cc_matViewProj * cc_matWorld;\n #else\n mvp = cc_matViewProj;\n #endif\n v_uv0 = a_uv0;\n v_light = a_color;\n #if USE_TINT\n v_dark = a_color0;\n #endif\n gl_Position = mvp * vec4(a_position, 1);\n}", + "frag": "\nprecision highp float;\nuniform sampler2D texture;\nin vec2 v_uv0;\nin vec4 v_light;\n#if USE_TINT\n in vec4 v_dark;\n#endif\n#if USE_ALPHA_TEST\n uniform ALPHA_TEST {\n float alphaThreshold;\n };\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\nvoid main () {\n vec4 texColor = vec4(1.0);\n vec4 texture_tmp = texture(texture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture\n texture_tmp.a *= texture(texture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n texColor.rgb *= (texture_tmp.rgb * texture_tmp.rgb);\n texColor.a *= texture_tmp.a;\n #else\n texColor *= texture_tmp;\n #endif\n vec4 finalColor;\n #if USE_TINT\n finalColor.a = v_light.a * texColor.a;\n finalColor.rgb = ((texColor.a - 1.0) * v_dark.a + 1.0 - texColor.rgb) * v_dark.rgb + texColor.rgb * v_light.rgb;\n #else\n finalColor = texColor * v_light;\n #endif\n ALPHA_TEST(finalColor);\n gl_FragColor = finalColor;\n}" + }, + "glsl1": { + "vert": "\nprecision highp float;\nuniform mat4 cc_matViewProj;\nuniform mat4 cc_matWorld;\nattribute vec3 a_position;\nattribute vec4 a_color;\n#if USE_TINT\n attribute vec4 a_color0;\n#endif\nattribute vec2 a_uv0;\nvarying vec2 v_uv0;\nvarying vec4 v_light;\n#if USE_TINT\n varying vec4 v_dark;\n#endif\nvoid main () {\n mat4 mvp;\n #if CC_USE_MODEL\n mvp = cc_matViewProj * cc_matWorld;\n #else\n mvp = cc_matViewProj;\n #endif\n v_uv0 = a_uv0;\n v_light = a_color;\n #if USE_TINT\n v_dark = a_color0;\n #endif\n gl_Position = mvp * vec4(a_position, 1);\n}", + "frag": "\nprecision highp float;\nuniform sampler2D texture;\nvarying vec2 v_uv0;\nvarying vec4 v_light;\n#if USE_TINT\n varying vec4 v_dark;\n#endif\n#if USE_ALPHA_TEST\n uniform float alphaThreshold;\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\nvoid main () {\n vec4 texColor = vec4(1.0);\n vec4 texture_tmp = texture2D(texture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture\n texture_tmp.a *= texture2D(texture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n texColor.rgb *= (texture_tmp.rgb * texture_tmp.rgb);\n texColor.a *= texture_tmp.a;\n #else\n texColor *= texture_tmp;\n #endif\n vec4 finalColor;\n #if USE_TINT\n finalColor.a = v_light.a * texColor.a;\n finalColor.rgb = ((texColor.a - 1.0) * v_dark.a + 1.0 - texColor.rgb) * v_dark.rgb + texColor.rgb * v_light.rgb;\n #else\n finalColor = texColor * v_light;\n #endif\n ALPHA_TEST(finalColor);\n gl_FragColor = finalColor;\n}" + }, + "builtins": { + "globals": { + "blocks": [ + { + "name": "CCGlobal", + "defines": [] + } + ], + "samplers": [] + }, + "locals": { + "blocks": [ + { + "name": "CCLocal", + "defines": [] + } + ], + "samplers": [] + } + }, + "defines": [ + { + "name": "USE_TINT", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_MODEL", + "type": "boolean", + "defines": [] + }, + { + "name": "USE_ALPHA_TEST", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_ALPHA_ATLAS_texture", + "type": "boolean", + "defines": [] + }, + { + "name": "INPUT_IS_GAMMA", + "type": "boolean", + "defines": [] + } + ], + "blocks": [ + { + "name": "ALPHA_TEST", + "binding": 0, + "members": [ + { + "name": "alphaThreshold", + "type": 13, + "count": 1 + } + ], + "defines": [ + "USE_ALPHA_TEST" + ] + } + ], + "samplers": [ + { + "name": "texture", + "type": 29, + "count": 1, + "binding": 30, + "defines": [] + } + ] + } + ], + [ + { + "passes": [ + { + "program": "builtin-2d-spine|vs|fs", + "blendState": { + "targets": [ + { + "blend": true + } + ] + }, + "rasterizerState": { + "cullMode": 0 + }, + "properties": { + "texture": { + "value": "white", + "type": 29 + }, + "alphaThreshold": { + "type": 13, + "value": [ + 0.5 + ] + } + } + } + ] + } + ] + ] + ], + 0, + 0, + [], + [], + [] + ], + [ + [ + [ + 0, + "builtin-2d-gray-sprite", + [ + { + "hash": 4278481454, + "record": null, + "name": "builtin-2d-gray-sprite|vs|fs", + "glsl3": { + "vert": "\nprecision highp float;\nuniform CCGlobal {\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\nin vec3 a_position;\nin mediump vec2 a_uv0;\nout mediump vec2 v_uv0;\nin vec4 a_color;\nout vec4 v_color;\nvoid main () {\n gl_Position = cc_matViewProj * vec4(a_position, 1);\n v_uv0 = a_uv0;\n v_color = a_color;\n}", + "frag": "\nprecision highp float;\nuniform sampler2D texture;\nin mediump vec2 v_uv0;\nin vec4 v_color;\nvoid main () {\n vec4 color = v_color;\n vec4 texture_tmp = texture(texture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture\n texture_tmp.a *= texture(texture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n color.rgb *= (texture_tmp.rgb * texture_tmp.rgb);\n color.a *= texture_tmp.a;\n #else\n color *= texture_tmp;\n #endif\n float gray = 0.2126*color.r + 0.7152*color.g + 0.0722*color.b;\n gl_FragColor = vec4(gray, gray, gray, color.a);\n}" + }, + "glsl1": { + "vert": "\nprecision highp float;\nuniform mat4 cc_matViewProj;\nattribute vec3 a_position;\nattribute mediump vec2 a_uv0;\nvarying mediump vec2 v_uv0;\nattribute vec4 a_color;\nvarying vec4 v_color;\nvoid main () {\n gl_Position = cc_matViewProj * vec4(a_position, 1);\n v_uv0 = a_uv0;\n v_color = a_color;\n}", + "frag": "\nprecision highp float;\nuniform sampler2D texture;\nvarying mediump vec2 v_uv0;\nvarying vec4 v_color;\nvoid main () {\n vec4 color = v_color;\n vec4 texture_tmp = texture2D(texture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture\n texture_tmp.a *= texture2D(texture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n color.rgb *= (texture_tmp.rgb * texture_tmp.rgb);\n color.a *= texture_tmp.a;\n #else\n color *= texture_tmp;\n #endif\n float gray = 0.2126*color.r + 0.7152*color.g + 0.0722*color.b;\n gl_FragColor = vec4(gray, gray, gray, color.a);\n}" + }, + "builtins": { + "globals": { + "blocks": [ + { + "name": "CCGlobal", + "defines": [] + } + ], + "samplers": [] + }, + "locals": { + "blocks": [], + "samplers": [] + } + }, + "defines": [ + { + "name": "CC_USE_ALPHA_ATLAS_texture", + "type": "boolean", + "defines": [] + }, + { + "name": "INPUT_IS_GAMMA", + "type": "boolean", + "defines": [] + } + ], + "blocks": [], + "samplers": [ + { + "name": "texture", + "type": 29, + "count": 1, + "binding": 30, + "defines": [] + } + ] + } + ], + [ + { + "passes": [ + { + "program": "builtin-2d-gray-sprite|vs|fs", + "blendState": { + "targets": [ + { + "blend": true + } + ] + }, + "rasterizerState": { + "cullMode": 0 + }, + "properties": { + "texture": { + "value": "white", + "type": 29 + } + } + } + ] + } + ] + ] + ], + 0, + 0, + [], + [], + [] + ], + [ + [ + [ + 0, + "builtin-2d-sprite", + [ + { + "hash": 2440430725, + "record": null, + "name": "builtin-2d-sprite|vs|fs", + "glsl3": { + "vert": "\nprecision highp float;\nuniform CCGlobal {\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\nuniform CCLocal {\n mat4 cc_matWorld;\n mat4 cc_matWorldIT;\n};\nin vec3 a_position;\nin vec4 a_color;\nout vec4 v_color;\n#if USE_TEXTURE\nin vec2 a_uv0;\nout vec2 v_uv0;\n#endif\nvoid main () {\n vec4 pos = vec4(a_position, 1);\n #if CC_USE_MODEL\n pos = cc_matViewProj * cc_matWorld * pos;\n #else\n pos = cc_matViewProj * pos;\n #endif\n #if USE_TEXTURE\n v_uv0 = a_uv0;\n #endif\n v_color = a_color;\n gl_Position = pos;\n}", + "frag": "\nprecision highp float;\n#if USE_ALPHA_TEST\n uniform ALPHA_TEST {\n float alphaThreshold;\n };\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\nin vec4 v_color;\n#if USE_TEXTURE\nin vec2 v_uv0;\nuniform sampler2D texture;\n#endif\nvoid main () {\n vec4 o = vec4(1, 1, 1, 1);\n #if USE_TEXTURE\n vec4 texture_tmp = texture(texture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture\n texture_tmp.a *= texture(texture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n o.rgb *= (texture_tmp.rgb * texture_tmp.rgb);\n o.a *= texture_tmp.a;\n #else\n o *= texture_tmp;\n #endif\n #endif\n o *= v_color;\n ALPHA_TEST(o);\n #if USE_BGRA\n gl_FragColor = o.bgra;\n #else\n gl_FragColor = o.rgba;\n #endif\n}" + }, + "glsl1": { + "vert": "\nprecision highp float;\nuniform mat4 cc_matViewProj;\nuniform mat4 cc_matWorld;\nattribute vec3 a_position;\nattribute vec4 a_color;\nvarying vec4 v_color;\n#if USE_TEXTURE\nattribute vec2 a_uv0;\nvarying vec2 v_uv0;\n#endif\nvoid main () {\n vec4 pos = vec4(a_position, 1);\n #if CC_USE_MODEL\n pos = cc_matViewProj * cc_matWorld * pos;\n #else\n pos = cc_matViewProj * pos;\n #endif\n #if USE_TEXTURE\n v_uv0 = a_uv0;\n #endif\n v_color = a_color;\n gl_Position = pos;\n}", + "frag": "\nprecision highp float;\n#if USE_ALPHA_TEST\n uniform float alphaThreshold;\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\nvarying vec4 v_color;\n#if USE_TEXTURE\nvarying vec2 v_uv0;\nuniform sampler2D texture;\n#endif\nvoid main () {\n vec4 o = vec4(1, 1, 1, 1);\n #if USE_TEXTURE\n vec4 texture_tmp = texture2D(texture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture\n texture_tmp.a *= texture2D(texture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n o.rgb *= (texture_tmp.rgb * texture_tmp.rgb);\n o.a *= texture_tmp.a;\n #else\n o *= texture_tmp;\n #endif\n #endif\n o *= v_color;\n ALPHA_TEST(o);\n #if USE_BGRA\n gl_FragColor = o.bgra;\n #else\n gl_FragColor = o.rgba;\n #endif\n}" + }, + "builtins": { + "globals": { + "blocks": [ + { + "name": "CCGlobal", + "defines": [] + } + ], + "samplers": [] + }, + "locals": { + "blocks": [ + { + "name": "CCLocal", + "defines": [] + } + ], + "samplers": [] + } + }, + "defines": [ + { + "name": "USE_TEXTURE", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_MODEL", + "type": "boolean", + "defines": [] + }, + { + "name": "USE_ALPHA_TEST", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_ALPHA_ATLAS_texture", + "type": "boolean", + "defines": [ + "USE_TEXTURE" + ] + }, + { + "name": "INPUT_IS_GAMMA", + "type": "boolean", + "defines": [ + "USE_TEXTURE" + ] + }, + { + "name": "USE_BGRA", + "type": "boolean", + "defines": [] + } + ], + "blocks": [ + { + "name": "ALPHA_TEST", + "binding": 0, + "members": [ + { + "name": "alphaThreshold", + "type": 13, + "count": 1 + } + ], + "defines": [ + "USE_ALPHA_TEST" + ] + } + ], + "samplers": [ + { + "name": "texture", + "type": 29, + "count": 1, + "binding": 30, + "defines": [ + "USE_TEXTURE" + ] + } + ] + } + ], + [ + { + "passes": [ + { + "program": "builtin-2d-sprite|vs|fs", + "blendState": { + "targets": [ + { + "blend": true + } + ] + }, + "rasterizerState": { + "cullMode": 0 + }, + "properties": { + "texture": { + "value": "white", + "type": 29 + }, + "alphaThreshold": { + "type": 13, + "value": [ + 0.5 + ] + } + } + } + ] + } + ] + ] + ], + 0, + 0, + [], + [], + [] + ], + [ + [ + [ + 2, + "builtin-unlit", + [ + {}, + "0", + 11, + [ + { + "defines": { + "USE_DIFFUSE_TEXTURE": true + } + }, + "props", + 11, + [ + {}, + "diffuseTexture", + 6, + 0 + ] + ] + ] + ] + ], + 0, + 0, + [ + 0, + 0 + ], + [ + 2, + 0 + ], + [ + 0, + 2 + ] + ], + [ + [ + [ + 0, + "builtin-3d-trail", + [ + { + "hash": 2929688198, + "record": null, + "name": "builtin-3d-trail|particle-trail:vs_main|tinted-fs:add", + "glsl3": { + "vert": "\nprecision mediump float;\nuniform Constants{\n vec4 mainTiling_Offset;\n vec4 frameTile_velLenScale;\n vec4 scale;\n};\nuniform CCGlobal {\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\nuniform CCLocal {\n mat4 cc_matWorld;\n mat4 cc_matWorldIT;\n};\nout vec2 uv;\nout vec4 color;\nin vec3 a_position;\nin vec4 a_texCoord;\nin vec3 a_texCoord1;\nin vec3 a_texCoord2;\nin vec4 a_color;\n#if CC_DRAW_WIRE_FRAME\n out vec3 vBarycentric;\n#endif\nvec4 vs_main() {\n highp vec4 pos = vec4(a_position, 1);\n vec4 velocity = vec4(a_texCoord1.xyz, 0);\n#if !CC_USE_WORLD_SPACE\n pos = cc_matWorld * pos;\n velocity = cc_matWorld * velocity;\n#endif\n float vertOffset = (a_texCoord.x - 0.5) * a_texCoord.y;\n vec3 camUp = normalize(cross(pos.xyz - cc_cameraPos.xyz, velocity.xyz));\n pos.xyz += camUp * vertOffset;\n pos = cc_matViewProj * pos;\n uv = a_texCoord.zw * mainTiling_Offset.xy + mainTiling_Offset.zw;;\n color = a_color;\n#if CC_DRAW_WIRE_FRAME\n vBarycentric = a_texCoord2;\n#endif\n return pos;\n}\nvoid main() { gl_Position = vs_main(); }", + "frag": "\nprecision mediump float;\nvec4 CCFragOutput (vec4 color) {\n #if OUTPUT_TO_GAMMA\n color.rgb = sqrt(color.rgb);\n #endif\n\treturn color;\n}\nin vec2 uv;\nin vec4 color;\n#if CC_DRAW_WIRE_FRAME\n in vec3 vBarycentric;\n#endif\nuniform sampler2D mainTexture;\nuniform FragConstants {\n vec4 tintColor;\n};\nvec4 add () {\n vec4 col = 2.0 * color * tintColor * texture(mainTexture, uv);\n #if CC_DRAW_WIRE_FRAME\n if (any(lessThan(vBarycentric, vec3(0.02)))) {\n col = vec4(0., 1., 1., 1.);\n }\n #endif\n return CCFragOutput(col);\n}\nout vec4 cc_FragColor;\nvoid main() { cc_FragColor = add(); }" + }, + "glsl1": { + "vert": "\nprecision mediump float;\nuniform vec4 mainTiling_Offset;\nuniform mat4 cc_matViewProj;\nuniform vec4 cc_cameraPos;\nuniform mat4 cc_matWorld;\nvarying vec2 uv;\nvarying vec4 color;\nattribute vec3 a_position;\nattribute vec4 a_texCoord;\nattribute vec3 a_texCoord1;\nattribute vec3 a_texCoord2;\nattribute vec4 a_color;\n#if CC_DRAW_WIRE_FRAME\n varying vec3 vBarycentric;\n#endif\nvec4 vs_main() {\n highp vec4 pos = vec4(a_position, 1);\n vec4 velocity = vec4(a_texCoord1.xyz, 0);\n#if !CC_USE_WORLD_SPACE\n pos = cc_matWorld * pos;\n velocity = cc_matWorld * velocity;\n#endif\n float vertOffset = (a_texCoord.x - 0.5) * a_texCoord.y;\n vec3 camUp = normalize(cross(pos.xyz - cc_cameraPos.xyz, velocity.xyz));\n pos.xyz += camUp * vertOffset;\n pos = cc_matViewProj * pos;\n uv = a_texCoord.zw * mainTiling_Offset.xy + mainTiling_Offset.zw;;\n color = a_color;\n#if CC_DRAW_WIRE_FRAME\n vBarycentric = a_texCoord2;\n#endif\n return pos;\n}\nvoid main() { gl_Position = vs_main(); }", + "frag": "\nprecision mediump float;\nvec4 CCFragOutput (vec4 color) {\n #if OUTPUT_TO_GAMMA\n color.rgb = sqrt(color.rgb);\n #endif\n\treturn color;\n}\nvarying vec2 uv;\nvarying vec4 color;\n#if CC_DRAW_WIRE_FRAME\n varying vec3 vBarycentric;\n#endif\nuniform sampler2D mainTexture;\nuniform vec4 tintColor;\nvec4 add () {\n vec4 col = 2.0 * color * tintColor * texture2D(mainTexture, uv);\n #if CC_DRAW_WIRE_FRAME\n if (any(lessThan(vBarycentric, vec3(0.02)))) {\n col = vec4(0., 1., 1., 1.);\n }\n #endif\n return CCFragOutput(col);\n}\nvoid main() { gl_FragColor = add(); }" + }, + "builtins": { + "globals": { + "blocks": [ + { + "name": "CCGlobal", + "defines": [] + } + ], + "samplers": [] + }, + "locals": { + "blocks": [ + { + "name": "CCLocal", + "defines": [] + } + ], + "samplers": [] + } + }, + "defines": [ + { + "name": "CC_DRAW_WIRE_FRAME", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_WORLD_SPACE", + "type": "boolean", + "defines": [] + }, + { + "name": "OUTPUT_TO_GAMMA", + "type": "boolean", + "defines": [] + } + ], + "blocks": [ + { + "name": "Constants", + "binding": 0, + "members": [ + { + "name": "mainTiling_Offset", + "type": 16, + "count": 1 + }, + { + "name": "frameTile_velLenScale", + "type": 16, + "count": 1 + }, + { + "name": "scale", + "type": 16, + "count": 1 + } + ], + "defines": [] + }, + { + "name": "FragConstants", + "binding": 1, + "members": [ + { + "name": "tintColor", + "type": 16, + "count": 1 + } + ], + "defines": [] + } + ], + "samplers": [ + { + "name": "mainTexture", + "type": 29, + "count": 1, + "binding": 30, + "defines": [] + } + ] + }, + { + "hash": 4224037318, + "record": null, + "name": "builtin-3d-trail|particle-trail:vs_main|tinted-fs:multiply", + "glsl3": { + "vert": "\nprecision mediump float;\nuniform Constants{\n vec4 mainTiling_Offset;\n vec4 frameTile_velLenScale;\n vec4 scale;\n};\nuniform CCGlobal {\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\nuniform CCLocal {\n mat4 cc_matWorld;\n mat4 cc_matWorldIT;\n};\nout vec2 uv;\nout vec4 color;\nin vec3 a_position;\nin vec4 a_texCoord;\nin vec3 a_texCoord1;\nin vec3 a_texCoord2;\nin vec4 a_color;\n#if CC_DRAW_WIRE_FRAME\n out vec3 vBarycentric;\n#endif\nvec4 vs_main() {\n highp vec4 pos = vec4(a_position, 1);\n vec4 velocity = vec4(a_texCoord1.xyz, 0);\n#if !CC_USE_WORLD_SPACE\n pos = cc_matWorld * pos;\n velocity = cc_matWorld * velocity;\n#endif\n float vertOffset = (a_texCoord.x - 0.5) * a_texCoord.y;\n vec3 camUp = normalize(cross(pos.xyz - cc_cameraPos.xyz, velocity.xyz));\n pos.xyz += camUp * vertOffset;\n pos = cc_matViewProj * pos;\n uv = a_texCoord.zw * mainTiling_Offset.xy + mainTiling_Offset.zw;;\n color = a_color;\n#if CC_DRAW_WIRE_FRAME\n vBarycentric = a_texCoord2;\n#endif\n return pos;\n}\nvoid main() { gl_Position = vs_main(); }", + "frag": "\nprecision mediump float;\nvec4 CCFragOutput (vec4 color) {\n #if OUTPUT_TO_GAMMA\n color.rgb = sqrt(color.rgb);\n #endif\n\treturn color;\n}\nin vec2 uv;\nin vec4 color;\n#if CC_DRAW_WIRE_FRAME\n in vec3 vBarycentric;\n#endif\nuniform sampler2D mainTexture;\nuniform FragConstants {\n vec4 tintColor;\n};\nvec4 multiply () {\n vec4 col;\n vec4 texColor = texture(mainTexture, uv);\n col.rgb = tintColor.rgb * texColor.rgb * color.rgb * vec3(2.0);\n col.a = (1.0 - texColor.a) * (tintColor.a * color.a * 2.0);\n #if CC_DRAW_WIRE_FRAME\n if (any(lessThan(vBarycentric, vec3(0.02)))) {\n col = vec4(0., 1., 1., col.a);\n }\n #endif\n return CCFragOutput(col);\n}\nout vec4 cc_FragColor;\nvoid main() { cc_FragColor = multiply(); }" + }, + "glsl1": { + "vert": "\nprecision mediump float;\nuniform vec4 mainTiling_Offset;\nuniform mat4 cc_matViewProj;\nuniform vec4 cc_cameraPos;\nuniform mat4 cc_matWorld;\nvarying vec2 uv;\nvarying vec4 color;\nattribute vec3 a_position;\nattribute vec4 a_texCoord;\nattribute vec3 a_texCoord1;\nattribute vec3 a_texCoord2;\nattribute vec4 a_color;\n#if CC_DRAW_WIRE_FRAME\n varying vec3 vBarycentric;\n#endif\nvec4 vs_main() {\n highp vec4 pos = vec4(a_position, 1);\n vec4 velocity = vec4(a_texCoord1.xyz, 0);\n#if !CC_USE_WORLD_SPACE\n pos = cc_matWorld * pos;\n velocity = cc_matWorld * velocity;\n#endif\n float vertOffset = (a_texCoord.x - 0.5) * a_texCoord.y;\n vec3 camUp = normalize(cross(pos.xyz - cc_cameraPos.xyz, velocity.xyz));\n pos.xyz += camUp * vertOffset;\n pos = cc_matViewProj * pos;\n uv = a_texCoord.zw * mainTiling_Offset.xy + mainTiling_Offset.zw;;\n color = a_color;\n#if CC_DRAW_WIRE_FRAME\n vBarycentric = a_texCoord2;\n#endif\n return pos;\n}\nvoid main() { gl_Position = vs_main(); }", + "frag": "\nprecision mediump float;\nvec4 CCFragOutput (vec4 color) {\n #if OUTPUT_TO_GAMMA\n color.rgb = sqrt(color.rgb);\n #endif\n\treturn color;\n}\nvarying vec2 uv;\nvarying vec4 color;\n#if CC_DRAW_WIRE_FRAME\n varying vec3 vBarycentric;\n#endif\nuniform sampler2D mainTexture;\nuniform vec4 tintColor;\nvec4 multiply () {\n vec4 col;\n vec4 texColor = texture2D(mainTexture, uv);\n col.rgb = tintColor.rgb * texColor.rgb * color.rgb * vec3(2.0);\n col.a = (1.0 - texColor.a) * (tintColor.a * color.a * 2.0);\n #if CC_DRAW_WIRE_FRAME\n if (any(lessThan(vBarycentric, vec3(0.02)))) {\n col = vec4(0., 1., 1., col.a);\n }\n #endif\n return CCFragOutput(col);\n}\nvoid main() { gl_FragColor = multiply(); }" + }, + "builtins": { + "globals": { + "blocks": [ + { + "name": "CCGlobal", + "defines": [] + } + ], + "samplers": [] + }, + "locals": { + "blocks": [ + { + "name": "CCLocal", + "defines": [] + } + ], + "samplers": [] + } + }, + "defines": [ + { + "name": "CC_DRAW_WIRE_FRAME", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_WORLD_SPACE", + "type": "boolean", + "defines": [] + }, + { + "name": "OUTPUT_TO_GAMMA", + "type": "boolean", + "defines": [] + } + ], + "blocks": [ + { + "name": "Constants", + "binding": 0, + "members": [ + { + "name": "mainTiling_Offset", + "type": 16, + "count": 1 + }, + { + "name": "frameTile_velLenScale", + "type": 16, + "count": 1 + }, + { + "name": "scale", + "type": 16, + "count": 1 + } + ], + "defines": [] + }, + { + "name": "FragConstants", + "binding": 1, + "members": [ + { + "name": "tintColor", + "type": 16, + "count": 1 + } + ], + "defines": [] + } + ], + "samplers": [ + { + "name": "mainTexture", + "type": 29, + "count": 1, + "binding": 30, + "defines": [] + } + ] + }, + { + "hash": 1704877102, + "record": null, + "name": "builtin-3d-trail|particle-trail:vs_main|no-tint-fs:addSmooth", + "glsl3": { + "vert": "\nprecision mediump float;\nuniform Constants{\n vec4 mainTiling_Offset;\n vec4 frameTile_velLenScale;\n vec4 scale;\n};\nuniform CCGlobal {\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\nuniform CCLocal {\n mat4 cc_matWorld;\n mat4 cc_matWorldIT;\n};\nout vec2 uv;\nout vec4 color;\nin vec3 a_position;\nin vec4 a_texCoord;\nin vec3 a_texCoord1;\nin vec3 a_texCoord2;\nin vec4 a_color;\n#if CC_DRAW_WIRE_FRAME\n out vec3 vBarycentric;\n#endif\nvec4 vs_main() {\n highp vec4 pos = vec4(a_position, 1);\n vec4 velocity = vec4(a_texCoord1.xyz, 0);\n#if !CC_USE_WORLD_SPACE\n pos = cc_matWorld * pos;\n velocity = cc_matWorld * velocity;\n#endif\n float vertOffset = (a_texCoord.x - 0.5) * a_texCoord.y;\n vec3 camUp = normalize(cross(pos.xyz - cc_cameraPos.xyz, velocity.xyz));\n pos.xyz += camUp * vertOffset;\n pos = cc_matViewProj * pos;\n uv = a_texCoord.zw * mainTiling_Offset.xy + mainTiling_Offset.zw;;\n color = a_color;\n#if CC_DRAW_WIRE_FRAME\n vBarycentric = a_texCoord2;\n#endif\n return pos;\n}\nvoid main() { gl_Position = vs_main(); }", + "frag": "\nprecision mediump float;\nvec4 CCFragOutput (vec4 color) {\n #if OUTPUT_TO_GAMMA\n color.rgb = sqrt(color.rgb);\n #endif\n\treturn color;\n}\nin vec2 uv;\nin vec4 color;\nuniform sampler2D mainTexture;\nvec4 addSmooth () {\n vec4 col = color * texture(mainTexture, uv);\n col.rgb *= col.a;\n return CCFragOutput(col);\n}\nout vec4 cc_FragColor;\nvoid main() { cc_FragColor = addSmooth(); }" + }, + "glsl1": { + "vert": "\nprecision mediump float;\nuniform vec4 mainTiling_Offset;\nuniform mat4 cc_matViewProj;\nuniform vec4 cc_cameraPos;\nuniform mat4 cc_matWorld;\nvarying vec2 uv;\nvarying vec4 color;\nattribute vec3 a_position;\nattribute vec4 a_texCoord;\nattribute vec3 a_texCoord1;\nattribute vec3 a_texCoord2;\nattribute vec4 a_color;\n#if CC_DRAW_WIRE_FRAME\n varying vec3 vBarycentric;\n#endif\nvec4 vs_main() {\n highp vec4 pos = vec4(a_position, 1);\n vec4 velocity = vec4(a_texCoord1.xyz, 0);\n#if !CC_USE_WORLD_SPACE\n pos = cc_matWorld * pos;\n velocity = cc_matWorld * velocity;\n#endif\n float vertOffset = (a_texCoord.x - 0.5) * a_texCoord.y;\n vec3 camUp = normalize(cross(pos.xyz - cc_cameraPos.xyz, velocity.xyz));\n pos.xyz += camUp * vertOffset;\n pos = cc_matViewProj * pos;\n uv = a_texCoord.zw * mainTiling_Offset.xy + mainTiling_Offset.zw;;\n color = a_color;\n#if CC_DRAW_WIRE_FRAME\n vBarycentric = a_texCoord2;\n#endif\n return pos;\n}\nvoid main() { gl_Position = vs_main(); }", + "frag": "\nprecision mediump float;\nvec4 CCFragOutput (vec4 color) {\n #if OUTPUT_TO_GAMMA\n color.rgb = sqrt(color.rgb);\n #endif\n\treturn color;\n}\nvarying vec2 uv;\nvarying vec4 color;\nuniform sampler2D mainTexture;\nvec4 addSmooth () {\n vec4 col = color * texture2D(mainTexture, uv);\n col.rgb *= col.a;\n return CCFragOutput(col);\n}\nvoid main() { gl_FragColor = addSmooth(); }" + }, + "builtins": { + "globals": { + "blocks": [ + { + "name": "CCGlobal", + "defines": [] + } + ], + "samplers": [] + }, + "locals": { + "blocks": [ + { + "name": "CCLocal", + "defines": [] + } + ], + "samplers": [] + } + }, + "defines": [ + { + "name": "CC_DRAW_WIRE_FRAME", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_WORLD_SPACE", + "type": "boolean", + "defines": [] + }, + { + "name": "OUTPUT_TO_GAMMA", + "type": "boolean", + "defines": [] + } + ], + "blocks": [ + { + "name": "Constants", + "binding": 0, + "members": [ + { + "name": "mainTiling_Offset", + "type": 16, + "count": 1 + }, + { + "name": "frameTile_velLenScale", + "type": 16, + "count": 1 + }, + { + "name": "scale", + "type": 16, + "count": 1 + } + ], + "defines": [] + } + ], + "samplers": [ + { + "name": "mainTexture", + "type": 29, + "count": 1, + "binding": 30, + "defines": [] + } + ] + }, + { + "hash": 2717357054, + "record": null, + "name": "builtin-3d-trail|particle-trail:vs_main|no-tint-fs:premultiplied", + "glsl3": { + "vert": "\nprecision mediump float;\nuniform Constants{\n vec4 mainTiling_Offset;\n vec4 frameTile_velLenScale;\n vec4 scale;\n};\nuniform CCGlobal {\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\nuniform CCLocal {\n mat4 cc_matWorld;\n mat4 cc_matWorldIT;\n};\nout vec2 uv;\nout vec4 color;\nin vec3 a_position;\nin vec4 a_texCoord;\nin vec3 a_texCoord1;\nin vec3 a_texCoord2;\nin vec4 a_color;\n#if CC_DRAW_WIRE_FRAME\n out vec3 vBarycentric;\n#endif\nvec4 vs_main() {\n highp vec4 pos = vec4(a_position, 1);\n vec4 velocity = vec4(a_texCoord1.xyz, 0);\n#if !CC_USE_WORLD_SPACE\n pos = cc_matWorld * pos;\n velocity = cc_matWorld * velocity;\n#endif\n float vertOffset = (a_texCoord.x - 0.5) * a_texCoord.y;\n vec3 camUp = normalize(cross(pos.xyz - cc_cameraPos.xyz, velocity.xyz));\n pos.xyz += camUp * vertOffset;\n pos = cc_matViewProj * pos;\n uv = a_texCoord.zw * mainTiling_Offset.xy + mainTiling_Offset.zw;;\n color = a_color;\n#if CC_DRAW_WIRE_FRAME\n vBarycentric = a_texCoord2;\n#endif\n return pos;\n}\nvoid main() { gl_Position = vs_main(); }", + "frag": "\nprecision mediump float;\nvec4 CCFragOutput (vec4 color) {\n #if OUTPUT_TO_GAMMA\n color.rgb = sqrt(color.rgb);\n #endif\n\treturn color;\n}\nin vec2 uv;\nin vec4 color;\nuniform sampler2D mainTexture;\nvec4 premultiplied () {\n vec4 col = color * texture(mainTexture, uv) * color.a;\n return CCFragOutput(col);\n}\nout vec4 cc_FragColor;\nvoid main() { cc_FragColor = premultiplied(); }" + }, + "glsl1": { + "vert": "\nprecision mediump float;\nuniform vec4 mainTiling_Offset;\nuniform mat4 cc_matViewProj;\nuniform vec4 cc_cameraPos;\nuniform mat4 cc_matWorld;\nvarying vec2 uv;\nvarying vec4 color;\nattribute vec3 a_position;\nattribute vec4 a_texCoord;\nattribute vec3 a_texCoord1;\nattribute vec3 a_texCoord2;\nattribute vec4 a_color;\n#if CC_DRAW_WIRE_FRAME\n varying vec3 vBarycentric;\n#endif\nvec4 vs_main() {\n highp vec4 pos = vec4(a_position, 1);\n vec4 velocity = vec4(a_texCoord1.xyz, 0);\n#if !CC_USE_WORLD_SPACE\n pos = cc_matWorld * pos;\n velocity = cc_matWorld * velocity;\n#endif\n float vertOffset = (a_texCoord.x - 0.5) * a_texCoord.y;\n vec3 camUp = normalize(cross(pos.xyz - cc_cameraPos.xyz, velocity.xyz));\n pos.xyz += camUp * vertOffset;\n pos = cc_matViewProj * pos;\n uv = a_texCoord.zw * mainTiling_Offset.xy + mainTiling_Offset.zw;;\n color = a_color;\n#if CC_DRAW_WIRE_FRAME\n vBarycentric = a_texCoord2;\n#endif\n return pos;\n}\nvoid main() { gl_Position = vs_main(); }", + "frag": "\nprecision mediump float;\nvec4 CCFragOutput (vec4 color) {\n #if OUTPUT_TO_GAMMA\n color.rgb = sqrt(color.rgb);\n #endif\n\treturn color;\n}\nvarying vec2 uv;\nvarying vec4 color;\nuniform sampler2D mainTexture;\nvec4 premultiplied () {\n vec4 col = color * texture2D(mainTexture, uv) * color.a;\n return CCFragOutput(col);\n}\nvoid main() { gl_FragColor = premultiplied(); }" + }, + "builtins": { + "globals": { + "blocks": [ + { + "name": "CCGlobal", + "defines": [] + } + ], + "samplers": [] + }, + "locals": { + "blocks": [ + { + "name": "CCLocal", + "defines": [] + } + ], + "samplers": [] + } + }, + "defines": [ + { + "name": "CC_DRAW_WIRE_FRAME", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_WORLD_SPACE", + "type": "boolean", + "defines": [] + }, + { + "name": "OUTPUT_TO_GAMMA", + "type": "boolean", + "defines": [] + } + ], + "blocks": [ + { + "name": "Constants", + "binding": 0, + "members": [ + { + "name": "mainTiling_Offset", + "type": 16, + "count": 1 + }, + { + "name": "frameTile_velLenScale", + "type": 16, + "count": 1 + }, + { + "name": "scale", + "type": 16, + "count": 1 + } + ], + "defines": [] + } + ], + "samplers": [ + { + "name": "mainTexture", + "type": 29, + "count": 1, + "binding": 30, + "defines": [] + } + ] + } + ], + [ + { + "name": "add", + "passes": [ + { + "program": "builtin-3d-trail|particle-trail:vs_main|tinted-fs:add", + "rasterizerState": { + "cullMode": 0 + }, + "blendState": { + "targets": [ + { + "blend": true, + "blendSrc": 770, + "blendDst": 1, + "blendSrcAlpha": 770, + "blendDstAlpha": 1 + } + ] + }, + "depthStencilState": { + "depthTest": true, + "depthWrite": false + }, + "properties": { + "mainTexture": { + "value": "grey", + "type": 29 + }, + "mainTiling_Offset": { + "type": 16, + "value": [ + 1, + 1, + 0, + 0 + ] + }, + "frameTile_velLenScale": { + "type": 16, + "value": [ + 1, + 1, + 0, + 0 + ] + }, + "tintColor": { + "type": 16, + "value": [ + 0.5, + 0.5, + 0.5, + 0.5 + ], + "inspector": { + "type": "color" + } + } + } + } + ] + }, + { + "name": "alpha-blend", + "passes": [ + { + "program": "builtin-3d-trail|particle-trail:vs_main|tinted-fs:add", + "rasterizerState": { + "cullMode": 0 + }, + "blendState": { + "targets": [ + { + "blend": true, + "blendSrc": 1, + "blendDst": 771, + "blendSrcAlpha": 1, + "blendDstAlpha": 771 + } + ] + }, + "depthStencilState": { + "depthTest": true, + "depthWrite": false + }, + "properties": { + "mainTexture": { + "value": "grey", + "type": 29 + }, + "mainTiling_Offset": { + "type": 16, + "value": [ + 1, + 1, + 0, + 0 + ] + }, + "frameTile_velLenScale": { + "type": 16, + "value": [ + 1, + 1, + 0, + 0 + ] + }, + "tintColor": { + "type": 16, + "value": [ + 0.5, + 0.5, + 0.5, + 0.5 + ], + "inspector": { + "type": "color" + } + } + } + } + ] + }, + { + "name": "add-multiply", + "passes": [ + { + "program": "builtin-3d-trail|particle-trail:vs_main|tinted-fs:multiply", + "rasterizerState": { + "cullMode": 0 + }, + "blendState": { + "targets": [ + { + "blend": true, + "blendSrc": 1, + "blendDst": 771, + "blendSrcAlpha": 1, + "blendDstAlpha": 771 + } + ] + }, + "depthStencilState": { + "depthTest": true, + "depthWrite": false + }, + "properties": { + "mainTexture": { + "value": "grey", + "type": 29 + }, + "mainTiling_Offset": { + "type": 16, + "value": [ + 1, + 1, + 0, + 0 + ] + }, + "frameTile_velLenScale": { + "type": 16, + "value": [ + 1, + 1, + 0, + 0 + ] + }, + "tintColor": { + "type": 16, + "value": [ + 0.5, + 0.5, + 0.5, + 0.5 + ], + "inspector": { + "type": "color" + } + } + } + } + ] + }, + { + "name": "add-smooth", + "passes": [ + { + "program": "builtin-3d-trail|particle-trail:vs_main|no-tint-fs:addSmooth", + "rasterizerState": { + "cullMode": 0 + }, + "blendState": { + "targets": [ + { + "blend": true, + "blendSrc": 1, + "blendDst": 771, + "blendSrcAlpha": 1, + "blendDstAlpha": 771 + } + ] + }, + "depthStencilState": { + "depthTest": true, + "depthWrite": false + }, + "properties": { + "mainTexture": { + "value": "grey", + "type": 29 + }, + "mainTiling_Offset": { + "type": 16, + "value": [ + 1, + 1, + 0, + 0 + ] + }, + "frameTile_velLenScale": { + "type": 16, + "value": [ + 1, + 1, + 0, + 0 + ] + } + } + } + ] + }, + { + "name": "premultiply-blend", + "passes": [ + { + "program": "builtin-3d-trail|particle-trail:vs_main|no-tint-fs:premultiplied", + "rasterizerState": { + "cullMode": 0 + }, + "blendState": { + "targets": [ + { + "blend": true, + "blendSrc": 1, + "blendDst": 771, + "blendSrcAlpha": 1, + "blendDstAlpha": 771 + } + ] + }, + "depthStencilState": { + "depthTest": true, + "depthWrite": false + }, + "properties": { + "mainTexture": { + "value": "grey", + "type": 29 + }, + "mainTiling_Offset": { + "type": 16, + "value": [ + 1, + 1, + 0, + 0 + ] + }, + "frameTile_velLenScale": { + "type": 16, + "value": [ + 1, + 1, + 0, + 0 + ] + } + } + } + ] + } + ] + ] + ], + 0, + 0, + [], + [], + [] + ], + [ + [ + [ + 0, + "builtin-2d-graphics", + [ + { + "hash": 550349795, + "record": null, + "name": "builtin-2d-graphics|vs|fs", + "glsl3": { + "vert": "\nprecision highp float;\nuniform CCGlobal {\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\nuniform CCLocal {\n mat4 cc_matWorld;\n mat4 cc_matWorldIT;\n};\nin vec3 a_position;\nin vec4 a_color;\nout vec4 v_color;\nin float a_dist;\nout float v_dist;\nvoid main () {\n vec4 pos = vec4(a_position, 1);\n pos = cc_matViewProj * cc_matWorld * pos;\n v_color = a_color;\n v_dist = a_dist;\n gl_Position = pos;\n}", + "frag": "\n#if CC_SUPPORT_standard_derivatives\n #extension GL_OES_standard_derivatives : enable\n#endif\nprecision highp float;\n#if USE_ALPHA_TEST\n uniform ALPHA_TEST {\n float alphaThreshold;\n };\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\nin vec4 v_color;\nin float v_dist;\nvoid main () {\n vec4 o = v_color;\n ALPHA_TEST(o);\n #if CC_SUPPORT_standard_derivatives\n float aa = fwidth(v_dist);\n #else\n float aa = 0.05;\n #endif\n float alpha = 1. - smoothstep(-aa, 0., abs(v_dist) - 1.0);\n o.rgb *= o.a;\n o *= alpha;\n gl_FragColor = o;\n}" + }, + "glsl1": { + "vert": "\nprecision highp float;\nuniform mat4 cc_matViewProj;\nuniform mat4 cc_matWorld;\nattribute vec3 a_position;\nattribute vec4 a_color;\nvarying vec4 v_color;\nattribute float a_dist;\nvarying float v_dist;\nvoid main () {\n vec4 pos = vec4(a_position, 1);\n pos = cc_matViewProj * cc_matWorld * pos;\n v_color = a_color;\n v_dist = a_dist;\n gl_Position = pos;\n}", + "frag": "\n#if CC_SUPPORT_standard_derivatives\n #extension GL_OES_standard_derivatives : enable\n#endif\nprecision highp float;\n#if USE_ALPHA_TEST\n uniform float alphaThreshold;\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\nvarying vec4 v_color;\nvarying float v_dist;\nvoid main () {\n vec4 o = v_color;\n ALPHA_TEST(o);\n #if CC_SUPPORT_standard_derivatives\n float aa = fwidth(v_dist);\n #else\n float aa = 0.05;\n #endif\n float alpha = 1. - smoothstep(-aa, 0., abs(v_dist) - 1.0);\n o.rgb *= o.a;\n o *= alpha;\n gl_FragColor = o;\n}" + }, + "builtins": { + "globals": { + "blocks": [ + { + "name": "CCGlobal", + "defines": [] + } + ], + "samplers": [] + }, + "locals": { + "blocks": [ + { + "name": "CCLocal", + "defines": [] + } + ], + "samplers": [] + } + }, + "defines": [ + { + "name": "CC_SUPPORT_standard_derivatives", + "type": "boolean", + "defines": [] + }, + { + "name": "USE_ALPHA_TEST", + "type": "boolean", + "defines": [] + } + ], + "blocks": [ + { + "name": "ALPHA_TEST", + "binding": 0, + "members": [ + { + "name": "alphaThreshold", + "type": 13, + "count": 1 + } + ], + "defines": [ + "USE_ALPHA_TEST" + ] + } + ], + "samplers": [] + } + ], + [ + { + "passes": [ + { + "program": "builtin-2d-graphics|vs|fs", + "blendState": { + "targets": [ + { + "blend": true, + "blendSrc": 1, + "blendDst": 771, + "blendSrcAlpha": 1, + "blendDstAlpha": 771 + } + ] + }, + "rasterizerState": { + "cullMode": 0 + }, + "properties": { + "alphaThreshold": { + "type": 13, + "value": [ + 0.5 + ] + } + } + } + ] + } + ] + ] + ], + 0, + 0, + [], + [], + [] + ], + [ + [ + [ + 1, + "builtin-2d-gray-sprite", + {} + ] + ], + 0, + 0, + [ + 0 + ], + [ + 0 + ], + [ + 3 + ] + ], + [ + [ + [ + 2, + "builtin-3d-particle", + [ + {}, + "0", + 11, + [ + { + "defines": { + "CC_USE_BILLBOARD": true, + "CC_USE_STRETCHED_BILLBOARD": false, + "CC_USE_HORIZONTAL_BILLBOARD": false, + "CC_USE_VERTICAL_BILLBOARD": false, + "CC_USE_MESH": false + } + }, + "props", + 11, + [ + {}, + "mainTiling_Offset", + 8, + [ + 2, + 1, + 1, + 0, + 0 + ], + "tintColor", + 8, + [ + 4, + 2141562284 + ], + "mainTexture", + 6, + 0 + ] + ] + ] + ] + ], + 0, + 0, + [ + 0, + 0 + ], + [ + 1, + 0 + ], + [ + 4, + 5 + ] + ], + [ + [ + [ + 2, + "builtin-3d-trail", + [ + {}, + "0", + 11, + [ + {}, + "props", + 11, + [ + {}, + "mainTexture", + 6, + 0 + ] + ] + ] + ] + ], + 0, + 0, + [ + 0, + 0 + ], + [ + 1, + 0 + ], + [ + 0, + 6 + ] + ], + [ + [ + "0,9729,9729,33071,33071,1,0,0", + -1 + ], + [ + 0 + ], + 0, + [], + [], + [] + ], + [ + [ + [ + 0, + "builtin-unlit", + [ + { + "hash": 922858114, + "record": null, + "name": "builtin-unlit|unlit-vs|unlit-fs", + "glsl3": { + "vert": "\nprecision highp float;\nuniform CCLocal {\n mat4 cc_matWorld;\n mat4 cc_matWorldIT;\n};\nuniform CCGlobal {\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\n#if CC_USE_SKINNING\n in vec4 a_weights;\n in vec4 a_joints;\n #if CC_USE_JOINTS_TEXTRUE\n uniform SKINNING {\n vec2 jointsTextureSize;\n };\n uniform sampler2D jointsTexture;\n #if CC_JOINTS_TEXTURE_FLOAT32\n mat4 getBoneMatrix(const in float i) {\n float width = jointsTextureSize.x;\n float height = jointsTextureSize.y;\n float j = i * 4.0;\n float x = mod(j, width);\n float y = floor(j / width);\n float dx = 1.0 / width;\n float dy = 1.0 / height;\n y = dy * (y + 0.5);\n vec4 v1 = texture(jointsTexture, vec2(dx * (x + 0.5), y));\n vec4 v2 = texture(jointsTexture, vec2(dx * (x + 1.5), y));\n vec4 v3 = texture(jointsTexture, vec2(dx * (x + 2.5), y));\n vec4 v4 = texture(jointsTexture, vec2(dx * (x + 3.5), y));\n return mat4(v1, v2, v3, v4);\n }\n #else\n float decode32(vec4 rgba) {\n float Sign = 1.0 - step(128.0, rgba[0]) * 2.0;\n float Exponent = 2.0 * mod(rgba[0], 128.0) + step(128.0, rgba[1]) - 127.0;\n float Mantissa = mod(rgba[1], 128.0) * 65536.0 + rgba[2] * 256.0 + rgba[3] + 8388608.0;\n return Sign * exp2(Exponent - 23.0) * Mantissa;\n }\n vec4 decodevec4 (vec4 x, vec4 y, vec4 z, vec4 w) {\n return vec4(\n decode32(x.wzyx * 255.0),\n decode32(y.wzyx * 255.0),\n decode32(z.wzyx * 255.0),\n decode32(w.wzyx * 255.0)\n );\n }\n vec4 decodevec4 (float dx, float x, float y) {\n return decodevec4(\n texture(jointsTexture, vec2(dx * (x + 0.5), y)),\n texture(jointsTexture, vec2(dx * (x + 1.5), y)),\n texture(jointsTexture, vec2(dx * (x + 2.5), y)),\n texture(jointsTexture, vec2(dx * (x + 3.5), y))\n );\n }\n mat4 getBoneMatrix(const in float i) {\n float width = jointsTextureSize.x;\n float height = jointsTextureSize.y;\n float j = i * 16.0;\n float x = mod(j, width);\n float y = floor(j / width);\n float dx = 1.0 / width;\n float dy = 1.0 / height;\n y = dy * (y + 0.5);\n vec4 v1 = decodevec4(dx, x, y);\n vec4 v2 = decodevec4(dx, x+4.0, y);\n vec4 v3 = decodevec4(dx, x+8.0, y);\n vec4 v4 = decodevec4(dx, x+12.0, y);\n return mat4(v1, v2, v3, v4);\n }\n #endif\n #else\n uniform JOINT_MATRIX {\n mat4 jointMatrices[50];\n };\n mat4 getBoneMatrix(const in float i) {\n return jointMatrices[int(i)];\n }\n #endif\n mat4 skinMatrix() {\n return\n getBoneMatrix(a_joints.x) * a_weights.x +\n getBoneMatrix(a_joints.y) * a_weights.y +\n getBoneMatrix(a_joints.z) * a_weights.z +\n getBoneMatrix(a_joints.w) * a_weights.w\n ;\n }\n#endif\nstruct StandardVertInput {\n vec2 uv;\n vec4 position;\n vec3 normal;\n vec4 tangent;\n vec4 color;\n};\nin vec3 a_position;\n#if CC_USE_ATTRIBUTE_UV0\nin vec2 a_uv0;\n#endif\n#if CC_USE_ATTRIBUTE_COLOR\nin vec4 a_color;\n#endif\n#if CC_USE_ATTRIBUTE_NORMAL\nin vec3 a_normal;\n#endif\n#if CC_USE_ATTRIBUTE_TANGENT\nin vec4 a_tangent;\n#endif\nvoid CCAttribute (out StandardVertInput In) {\n In.position = vec4(a_position, 1.0);\n #if CC_USE_ATTRIBUTE_UV0\n In.uv = a_uv0;\n #else\n In.uv = vec2(0.0);\n #endif\n #if CC_USE_ATTRIBUTE_COLOR\n In.color = a_color;\n #else\n In.color = vec4(1.0);\n #endif\n #if CC_USE_ATTRIBUTE_NORMAL\n In.normal = a_normal;\n #else\n In.normal = vec3(0.0, 1.0, 0.0);\n #endif\n #if CC_USE_ATTRIBUTE_TANGENT\n In.tangent = a_tangent;\n #else\n In.tangent = vec4(1.0, 0.0, 0.0, 0.0);\n #endif\n}\nvoid CCVertInput(out StandardVertInput In) {\n CCAttribute(In);\n #if CC_USE_SKINNING\n mat4 m = skinMatrix();\n In.position = m * In.position;\n #if CC_USE_ATTRIBUTE_NORMAL\n In.normal = (m * vec4(In.normal, 0)).xyz;\n #endif\n #if CC_USE_ATTRIBUTE_TANGENT\n In.tangent = m * In.tangent;\n #endif\n #endif\n}\nuniform MAIN_TILING {\n vec2 mainTiling;\n vec2 mainOffset;\n};\n#if CC_USE_ATTRIBUTE_UV0 && USE_DIFFUSE_TEXTURE\n out mediump vec2 v_uv0;\n#endif\n#if CC_USE_ATTRIBUTE_COLOR\n out lowp vec4 v_color;\n#endif\nvoid main () {\n StandardVertInput In;\n CCVertInput(In);\n #if CC_USE_ATTRIBUTE_COLOR\n v_color = In.color;\n #endif\n #if CC_USE_ATTRIBUTE_UV0 && USE_DIFFUSE_TEXTURE\n v_uv0 = In.uv * mainTiling + mainOffset;\n #endif\n gl_Position = cc_matViewProj * cc_matWorld * In.position;\n}", + "frag": "\nprecision highp float;\n#if USE_ALPHA_TEST\n uniform ALPHA_TEST {\n float alphaThreshold;\n };\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\nvec4 CCFragOutput (vec4 color) {\n #if OUTPUT_TO_GAMMA\n color.rgb = sqrt(color.rgb);\n #endif\n\treturn color;\n}\nuniform UNLIT {\n lowp vec4 diffuseColor;\n};\n#if USE_DIFFUSE_TEXTURE\n uniform sampler2D diffuseTexture;\n#endif\n#if CC_USE_ATTRIBUTE_COLOR\n in lowp vec4 v_color;\n#endif\n#if CC_USE_ATTRIBUTE_UV0 && USE_DIFFUSE_TEXTURE\n in mediump vec2 v_uv0;\n#endif\nvoid main () {\n vec4 color = diffuseColor;\n #if CC_USE_ATTRIBUTE_UV0 && USE_DIFFUSE_TEXTURE\n vec4 diffuseTexture_tmp = texture(diffuseTexture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_diffuseTexture\n diffuseTexture_tmp.a *= texture(diffuseTexture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n color.rgb *= (diffuseTexture_tmp.rgb * diffuseTexture_tmp.rgb);\n color.a *= diffuseTexture_tmp.a;\n #else\n color *= diffuseTexture_tmp;\n #endif\n #endif\n #if CC_USE_ATTRIBUTE_COLOR\n color *= v_color;\n #endif\n ALPHA_TEST(color);\n gl_FragColor = CCFragOutput(color);\n}" + }, + "glsl1": { + "vert": "\nprecision highp float;\nuniform mat4 cc_matWorld;\nuniform mat4 cc_matViewProj;\n#if CC_USE_SKINNING\n attribute vec4 a_weights;\n attribute vec4 a_joints;\n #if CC_USE_JOINTS_TEXTRUE\n uniform vec2 jointsTextureSize;\n uniform sampler2D jointsTexture;\n #if CC_JOINTS_TEXTURE_FLOAT32\n mat4 getBoneMatrix(const in float i) {\n float width = jointsTextureSize.x;\n float height = jointsTextureSize.y;\n float j = i * 4.0;\n float x = mod(j, width);\n float y = floor(j / width);\n float dx = 1.0 / width;\n float dy = 1.0 / height;\n y = dy * (y + 0.5);\n vec4 v1 = texture2D(jointsTexture, vec2(dx * (x + 0.5), y));\n vec4 v2 = texture2D(jointsTexture, vec2(dx * (x + 1.5), y));\n vec4 v3 = texture2D(jointsTexture, vec2(dx * (x + 2.5), y));\n vec4 v4 = texture2D(jointsTexture, vec2(dx * (x + 3.5), y));\n return mat4(v1, v2, v3, v4);\n }\n #else\n float decode32(vec4 rgba) {\n float Sign = 1.0 - step(128.0, rgba[0]) * 2.0;\n float Exponent = 2.0 * mod(rgba[0], 128.0) + step(128.0, rgba[1]) - 127.0;\n float Mantissa = mod(rgba[1], 128.0) * 65536.0 + rgba[2] * 256.0 + rgba[3] + 8388608.0;\n return Sign * exp2(Exponent - 23.0) * Mantissa;\n }\n vec4 decodevec4 (vec4 x, vec4 y, vec4 z, vec4 w) {\n return vec4(\n decode32(x.wzyx * 255.0),\n decode32(y.wzyx * 255.0),\n decode32(z.wzyx * 255.0),\n decode32(w.wzyx * 255.0)\n );\n }\n vec4 decodevec4 (float dx, float x, float y) {\n return decodevec4(\n texture2D(jointsTexture, vec2(dx * (x + 0.5), y)),\n texture2D(jointsTexture, vec2(dx * (x + 1.5), y)),\n texture2D(jointsTexture, vec2(dx * (x + 2.5), y)),\n texture2D(jointsTexture, vec2(dx * (x + 3.5), y))\n );\n }\n mat4 getBoneMatrix(const in float i) {\n float width = jointsTextureSize.x;\n float height = jointsTextureSize.y;\n float j = i * 16.0;\n float x = mod(j, width);\n float y = floor(j / width);\n float dx = 1.0 / width;\n float dy = 1.0 / height;\n y = dy * (y + 0.5);\n vec4 v1 = decodevec4(dx, x, y);\n vec4 v2 = decodevec4(dx, x+4.0, y);\n vec4 v3 = decodevec4(dx, x+8.0, y);\n vec4 v4 = decodevec4(dx, x+12.0, y);\n return mat4(v1, v2, v3, v4);\n }\n #endif\n #else\n uniform mat4 jointMatrices[50];\n mat4 getBoneMatrix(const in float i) {\n return jointMatrices[int(i)];\n }\n #endif\n mat4 skinMatrix() {\n return\n getBoneMatrix(a_joints.x) * a_weights.x +\n getBoneMatrix(a_joints.y) * a_weights.y +\n getBoneMatrix(a_joints.z) * a_weights.z +\n getBoneMatrix(a_joints.w) * a_weights.w\n ;\n }\n#endif\nstruct StandardVertInput {\n vec2 uv;\n vec4 position;\n vec3 normal;\n vec4 tangent;\n vec4 color;\n};\nattribute vec3 a_position;\n#if CC_USE_ATTRIBUTE_UV0\nattribute vec2 a_uv0;\n#endif\n#if CC_USE_ATTRIBUTE_COLOR\nattribute vec4 a_color;\n#endif\n#if CC_USE_ATTRIBUTE_NORMAL\nattribute vec3 a_normal;\n#endif\n#if CC_USE_ATTRIBUTE_TANGENT\nattribute vec4 a_tangent;\n#endif\nvoid CCAttribute (out StandardVertInput In) {\n In.position = vec4(a_position, 1.0);\n #if CC_USE_ATTRIBUTE_UV0\n In.uv = a_uv0;\n #else\n In.uv = vec2(0.0);\n #endif\n #if CC_USE_ATTRIBUTE_COLOR\n In.color = a_color;\n #else\n In.color = vec4(1.0);\n #endif\n #if CC_USE_ATTRIBUTE_NORMAL\n In.normal = a_normal;\n #else\n In.normal = vec3(0.0, 1.0, 0.0);\n #endif\n #if CC_USE_ATTRIBUTE_TANGENT\n In.tangent = a_tangent;\n #else\n In.tangent = vec4(1.0, 0.0, 0.0, 0.0);\n #endif\n}\nvoid CCVertInput(out StandardVertInput In) {\n CCAttribute(In);\n #if CC_USE_SKINNING\n mat4 m = skinMatrix();\n In.position = m * In.position;\n #if CC_USE_ATTRIBUTE_NORMAL\n In.normal = (m * vec4(In.normal, 0)).xyz;\n #endif\n #if CC_USE_ATTRIBUTE_TANGENT\n In.tangent = m * In.tangent;\n #endif\n #endif\n}\nuniform vec2 mainTiling;\nuniform vec2 mainOffset;\n#if CC_USE_ATTRIBUTE_UV0 && USE_DIFFUSE_TEXTURE\n varying mediump vec2 v_uv0;\n#endif\n#if CC_USE_ATTRIBUTE_COLOR\n varying lowp vec4 v_color;\n#endif\nvoid main () {\n StandardVertInput In;\n CCVertInput(In);\n #if CC_USE_ATTRIBUTE_COLOR\n v_color = In.color;\n #endif\n #if CC_USE_ATTRIBUTE_UV0 && USE_DIFFUSE_TEXTURE\n v_uv0 = In.uv * mainTiling + mainOffset;\n #endif\n gl_Position = cc_matViewProj * cc_matWorld * In.position;\n}", + "frag": "\nprecision highp float;\n#if USE_ALPHA_TEST\n uniform float alphaThreshold;\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\nvec4 CCFragOutput (vec4 color) {\n #if OUTPUT_TO_GAMMA\n color.rgb = sqrt(color.rgb);\n #endif\n\treturn color;\n}\nuniform lowp vec4 diffuseColor;\n#if USE_DIFFUSE_TEXTURE\n uniform sampler2D diffuseTexture;\n#endif\n#if CC_USE_ATTRIBUTE_COLOR\n varying lowp vec4 v_color;\n#endif\n#if CC_USE_ATTRIBUTE_UV0 && USE_DIFFUSE_TEXTURE\n varying mediump vec2 v_uv0;\n#endif\nvoid main () {\n vec4 color = diffuseColor;\n #if CC_USE_ATTRIBUTE_UV0 && USE_DIFFUSE_TEXTURE\n vec4 diffuseTexture_tmp = texture2D(diffuseTexture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_diffuseTexture\n diffuseTexture_tmp.a *= texture2D(diffuseTexture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n color.rgb *= (diffuseTexture_tmp.rgb * diffuseTexture_tmp.rgb);\n color.a *= diffuseTexture_tmp.a;\n #else\n color *= diffuseTexture_tmp;\n #endif\n #endif\n #if CC_USE_ATTRIBUTE_COLOR\n color *= v_color;\n #endif\n ALPHA_TEST(color);\n gl_FragColor = CCFragOutput(color);\n}" + }, + "builtins": { + "globals": { + "blocks": [ + { + "name": "CCGlobal", + "defines": [] + } + ], + "samplers": [] + }, + "locals": { + "blocks": [ + { + "name": "CCLocal", + "defines": [] + } + ], + "samplers": [] + } + }, + "defines": [ + { + "name": "CC_USE_SKINNING", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_JOINTS_TEXTRUE", + "type": "boolean", + "defines": [ + "CC_USE_SKINNING" + ] + }, + { + "name": "CC_JOINTS_TEXTURE_FLOAT32", + "type": "boolean", + "defines": [ + "CC_USE_SKINNING", + "CC_USE_JOINTS_TEXTRUE" + ] + }, + { + "name": "CC_USE_ATTRIBUTE_UV0", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_ATTRIBUTE_COLOR", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_ATTRIBUTE_NORMAL", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_ATTRIBUTE_TANGENT", + "type": "boolean", + "defines": [] + }, + { + "name": "USE_DIFFUSE_TEXTURE", + "type": "boolean", + "defines": [] + }, + { + "name": "USE_ALPHA_TEST", + "type": "boolean", + "defines": [] + }, + { + "name": "OUTPUT_TO_GAMMA", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_ALPHA_ATLAS_diffuseTexture", + "type": "boolean", + "defines": [ + "CC_USE_ATTRIBUTE_UV0", + "USE_DIFFUSE_TEXTURE" + ] + }, + { + "name": "INPUT_IS_GAMMA", + "type": "boolean", + "defines": [ + "CC_USE_ATTRIBUTE_UV0", + "USE_DIFFUSE_TEXTURE" + ] + } + ], + "blocks": [ + { + "name": "SKINNING", + "binding": 0, + "members": [ + { + "name": "jointsTextureSize", + "type": 14, + "count": 1 + } + ], + "defines": [ + "CC_USE_SKINNING", + "CC_USE_JOINTS_TEXTRUE" + ] + }, + { + "name": "JOINT_MATRIX", + "binding": 1, + "members": [ + { + "name": "jointMatrices", + "type": 26, + "count": 50 + } + ], + "defines": [ + "CC_USE_SKINNING" + ] + }, + { + "name": "MAIN_TILING", + "binding": 2, + "members": [ + { + "name": "mainTiling", + "type": 14, + "count": 1 + }, + { + "name": "mainOffset", + "type": 14, + "count": 1 + } + ], + "defines": [] + }, + { + "name": "ALPHA_TEST", + "binding": 3, + "members": [ + { + "name": "alphaThreshold", + "type": 13, + "count": 1 + } + ], + "defines": [ + "USE_ALPHA_TEST" + ] + }, + { + "name": "UNLIT", + "binding": 4, + "members": [ + { + "name": "diffuseColor", + "type": 16, + "count": 1 + } + ], + "defines": [] + } + ], + "samplers": [ + { + "name": "jointsTexture", + "type": 29, + "count": 1, + "binding": 30, + "defines": [ + "CC_USE_SKINNING", + "CC_USE_JOINTS_TEXTRUE" + ] + }, + { + "name": "diffuseTexture", + "type": 29, + "count": 1, + "binding": 31, + "defines": [ + "USE_DIFFUSE_TEXTURE" + ] + } + ] + } + ], + [ + { + "name": "opaque", + "passes": [ + { + "program": "builtin-unlit|unlit-vs|unlit-fs", + "blendState": { + "targets": [ + { + "blend": true + } + ] + }, + "rasterizerState": { + "cullMode": 0 + }, + "depthStencilState": { + "depthTest": true, + "depthWrite": true + }, + "properties": { + "diffuseTexture": { + "value": "white", + "type": 29 + }, + "diffuseColor": { + "type": 16, + "value": [ + 1, + 1, + 1, + 1 + ], + "editor": { + "type": "color" + } + }, + "alphaThreshold": { + "type": 13, + "value": [ + 0.5 + ] + }, + "mainTiling": { + "type": 14, + "value": [ + 1, + 1 + ] + }, + "mainOffset": { + "type": 14, + "value": [ + 0, + 0 + ] + } + } + } + ] + }, + { + "name": "transparent", + "passes": [ + { + "stage": "transparent", + "program": "builtin-unlit|unlit-vs|unlit-fs", + "blendState": { + "targets": [ + { + "blend": true + } + ] + }, + "rasterizerState": { + "cullMode": 0 + }, + "depthStencilState": { + "depthTest": true, + "depthWrite": false + }, + "properties": { + "diffuseTexture": { + "value": "white", + "type": 29 + }, + "diffuseColor": { + "type": 16, + "value": [ + 1, + 1, + 1, + 1 + ], + "editor": { + "type": "color" + } + }, + "alphaThreshold": { + "type": 13, + "value": [ + 0.5 + ] + }, + "mainTiling": { + "type": 14, + "value": [ + 1, + 1 + ] + }, + "mainOffset": { + "type": 14, + "value": [ + 0, + 0 + ] + } + } + } + ] + } + ] + ] + ], + 0, + 0, + [], + [], + [] + ], + [ + [ + [ + 1, + "builtin-2d-base", + {} + ] + ], + 0, + 0, + [ + 0 + ], + [ + 0 + ], + [ + 1 + ] + ], + [ + [ + [ + 1, + "builtin-2d-spine", + {} + ] + ], + 0, + 0, + [ + 0 + ], + [ + 0 + ], + [ + 7 + ] + ], + [ + [ + [ + 0, + "builtin-3d-particle", + [ + { + "hash": 1682193167, + "record": null, + "name": "builtin-3d-particle|particle-vs-legacy:lpvs_main|tinted-fs:add", + "glsl3": { + "vert": "\nprecision highp float;\nvec4 quaternionFromAxis(vec3 xAxis,vec3 yAxis,vec3 zAxis){\n mat3 m = mat3(xAxis,yAxis,zAxis);\n float trace = m[0][0] + m[1][1] + m[2][2];\n vec4 quat;\n if (trace > 0.) {\n float s = 0.5 / sqrt(trace + 1.0);\n quat.w = 0.25 / s;\n quat.x = (m[2][1] - m[1][2]) * s;\n quat.y = (m[0][2] - m[2][0]) * s;\n quat.z = (m[1][0] - m[0][1]) * s;\n } else if ((m[0][0] > m[1][1]) && (m[0][0] > m[2][2])) {\n float s = 2.0 * sqrt(1.0 + m[0][0] - m[1][1] - m[2][2]);\n quat.w = (m[2][1] - m[1][2]) / s;\n quat.x = 0.25 * s;\n quat.y = (m[0][1] + m[1][0]) / s;\n quat.z = (m[0][2] + m[2][0]) / s;\n } else if (m[1][1] > m[2][2]) {\n float s = 2.0 * sqrt(1.0 + m[1][1] - m[0][0] - m[2][2]);\n quat.w = (m[0][2] - m[2][0]) / s;\n quat.x = (m[0][1] + m[1][0]) / s;\n quat.y = 0.25 * s;\n quat.z = (m[1][2] + m[2][1]) / s;\n } else {\n float s = 2.0 * sqrt(1.0 + m[2][2] - m[0][0] - m[1][1]);\n quat.w = (m[1][0] - m[0][1]) / s;\n quat.x = (m[0][2] + m[2][0]) / s;\n quat.y = (m[1][2] + m[2][1]) / s;\n quat.z = 0.25 * s;\n }\n float len = quat.x * quat.x + quat.y * quat.y + quat.z * quat.z + quat.w * quat.w;\n if (len > 0.) {\n len = 1. / sqrt(len);\n quat.x = quat.x * len;\n quat.y = quat.y * len;\n quat.z = quat.z * len;\n quat.w = quat.w * len;\n }\n return quat;\n}\nvec4 quaternionFromEuler(vec3 angle){\n float x = angle.x / 2.;\n float y = angle.y / 2.;\n float z = angle.z / 2.;\n float sx = sin(x);\n float cx = cos(x);\n float sy = sin(y);\n float cy = cos(y);\n float sz = sin(z);\n float cz = cos(z);\n vec4 quat = vec4(0);\n quat.x = sx * cy * cz + cx * sy * sz;\n quat.y = cx * sy * cz + sx * cy * sz;\n quat.z = cx * cy * sz - sx * sy * cz;\n quat.w = cx * cy * cz - sx * sy * sz;\n return quat;\n}\nmat4 matrixFromRT(vec4 q, vec3 p){\n float x2 = q.x + q.x;\n float y2 = q.y + q.y;\n float z2 = q.z + q.z;\n float xx = q.x * x2;\n float xy = q.x * y2;\n float xz = q.x * z2;\n float yy = q.y * y2;\n float yz = q.y * z2;\n float zz = q.z * z2;\n float wx = q.w * x2;\n float wy = q.w * y2;\n float wz = q.w * z2;\n return mat4(\n 1. - (yy + zz), xy + wz, xz - wy, 0,\n xy - wz, 1. - (xx + zz), yz + wx, 0,\n xz + wy, yz - wx, 1. - (xx + yy), 0,\n p.x, p.y, p.z, 1\n );\n}\nmat4 matFromRTS(vec4 q, vec3 t, vec3 s){\n float x = q.x, y = q.y, z = q.z, w = q.w;\n float x2 = x + x;\n float y2 = y + y;\n float z2 = z + z;\n float xx = x * x2;\n float xy = x * y2;\n float xz = x * z2;\n float yy = y * y2;\n float yz = y * z2;\n float zz = z * z2;\n float wx = w * x2;\n float wy = w * y2;\n float wz = w * z2;\n float sx = s.x;\n float sy = s.y;\n float sz = s.z;\n return mat4((1. - (yy + zz)) * sx, (xy + wz) * sx, (xz - wy) * sx, 0,\n (xy - wz) * sy, (1. - (xx + zz)) * sy, (yz + wx) * sy, 0,\n (xz + wy) * sz, (yz - wx) * sz, (1. - (xx + yy)) * sz, 0,\n t.x, t.y, t.z, 1);\n}\nvec4 quatMultiply(vec4 a, vec4 b){\n vec4 quat;\n quat.x = a.x * b.w + a.w * b.x + a.y * b.z - a.z * b.y;\n quat.y = a.y * b.w + a.w * b.y + a.z * b.x - a.x * b.z;\n quat.z = a.z * b.w + a.w * b.z + a.x * b.y - a.y * b.x;\n quat.w = a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z;\n return quat;\n}\nvoid rotateVecFromQuat(inout vec3 v, vec4 q){\n float ix = q.w * v.x + q.y * v.z - q.z * v.y;\n float iy = q.w * v.y + q.z * v.x - q.x * v.z;\n float iz = q.w * v.z + q.x * v.y - q.y * v.x;\n float iw = -q.x * v.x - q.y * v.y - q.z * v.z;\n v.x = ix * q.w + iw * -q.x + iy * -q.z - iz * -q.y;\n v.y = iy * q.w + iw * -q.y + iz * -q.x - ix * -q.z;\n v.z = iz * q.w + iw * -q.z + ix * -q.y - iy * -q.x;\n}\nvec3 rotateInLocalSpace(vec3 pos, vec3 xAxis, vec3 yAxis, vec3 zAxis, vec4 q){\n float z = pos.z;\n float x = pos.x;\n float y = pos.y;\n vec4 viewQuat = quaternionFromAxis(xAxis, yAxis, zAxis);\n vec4 rotQuat = quatMultiply(viewQuat, q);\n rotateVecFromQuat(pos, rotQuat);\n return pos;\n}\nvoid rotateCorner(inout vec2 corner, float angle){\n float xOS = cos(angle) * corner.x - sin(angle) * corner.y;\n float yOS = sin(angle) * corner.x + cos(angle) * corner.y;\n corner.x = xOS;\n corner.y = yOS;\n}\nuniform Constants{\n vec4 mainTiling_Offset;\n vec4 frameTile_velLenScale;\n vec4 scale;\n};\nuniform CCGlobal {\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\nuniform CCLocal {\n mat4 cc_matWorld;\n mat4 cc_matWorldIT;\n};\nout vec2 uv;\nout vec4 color;\nvoid computeVertPos(inout vec4 pos, vec2 vertOffset, vec4 q, vec3 s\n#if CC_USE_BILLBOARD || CC_USE_VERTICAL_BILLBOARD\n , mat4 viewInv\n#endif\n#if CC_USE_STRETCHED_BILLBOARD\n , vec3 eye\n , vec4 velocity\n , float velocityScale\n , float lengthScale\n , float xIndex\n#endif\n) {\n#if CC_USE_BILLBOARD\n vec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\n vec3 camX = normalize(vec3(viewInv[0][0], viewInv[1][0], viewInv[2][0]));\n vec3 camY = normalize(vec3(viewInv[0][1], viewInv[1][1], viewInv[2][1]));\n vec3 camZ = normalize(vec3(viewInv[0][2], viewInv[1][2], viewInv[2][2]));\n pos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, camZ, q);\n#elif CC_USE_STRETCHED_BILLBOARD\n vec3 camRight = normalize(cross(pos.xyz - eye, velocity.xyz)) * s.x;\n vec3 camUp = velocity.xyz * velocityScale + normalize(velocity.xyz) * lengthScale * s.y;\n pos.xyz += (camRight * abs(vertOffset.x) * sign(vertOffset.y)) - camUp * xIndex;\n#elif CC_USE_HORIZONTAL_BILLBOARD\n vec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\n vec3 camX = vec3(1, 0, 0);\n vec3 camY = vec3(0, 0, -1);\n pos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, cross(camX, camY), q);\n#elif CC_USE_VERTICAL_BILLBOARD\n vec2 viewSpaceVert = vec2(vertOffset.x * s.x, vertOffset.y * s.y);\n rotateCorner(viewSpaceVert, q.z);\n vec3 camX = normalize(vec3(cc_matView[0][0], cc_matView[1][0], cc_matView[2][0]));\n vec3 camY = vec3(0, 1, 0);\n vec3 offset = camX * viewSpaceVert.x + camY * viewSpaceVert.y;\n pos.xyz += offset;\n#else\n pos.x += vertOffset.x;\n pos.y += vertOffset.y;\n#endif\n}\nvec2 computeUV(float frameIndex, vec2 vertIndex, vec2 frameTile){\n vec2 aniUV = vec2(0, floor(frameIndex * frameTile.y));\n aniUV.x = floor(frameIndex * frameTile.x * frameTile.y - aniUV.y * frameTile.x);\n#if !CC_USE_MESH\n vertIndex.y = 1. - vertIndex.y;\n#endif\n return (aniUV.xy + vertIndex) / vec2(frameTile.x, frameTile.y);\n}\nin vec3 a_position;\nin vec3 a_texCoord;\nin vec3 a_texCoord1;\nin vec3 a_texCoord2;\nin vec4 a_color;\n#if CC_USE_STRETCHED_BILLBOARD\n in vec3 a_color1;\n#endif\n#if CC_USE_MESH\n in vec3 a_texCoord3;\n in vec3 a_normal;\n in vec4 a_color1;\n#endif\nvec4 lpvs_main() {\n vec3 compScale = scale.xyz * a_texCoord1;\n vec4 pos = vec4(a_position, 1);\n#if CC_USE_STRETCHED_BILLBOARD\n vec4 velocity = vec4(a_color1.xyz, 0);\n#endif\n#if !CC_USE_WORLD_SPACE\n pos = cc_matWorld * pos;\n #if CC_USE_STRETCHED_BILLBOARD\n velocity = cc_matWorld * velocity;\n #endif\n#endif\n#if !CC_USE_MESH\n vec2 cornerOffset = vec2((a_texCoord.xy - 0.5));\n #if CC_USE_BILLBOARD\n vec3 rotEuler = a_texCoord2;\n #elif CC_USE_STRETCHED_BILLBOARD\n vec3 rotEuler = vec3(0.);\n #else\n vec3 rotEuler = vec3(0., 0., a_texCoord2.z);\n #endif\n computeVertPos(pos, cornerOffset, quaternionFromEuler(rotEuler), compScale\n #if CC_USE_BILLBOARD || CC_USE_VERTICAL_BILLBOARD\n , cc_matViewInv\n #endif\n #if CC_USE_STRETCHED_BILLBOARD\n , cc_cameraPos.xyz\n , velocity\n , frameTile_velLenScale.z\n , frameTile_velLenScale.w\n , a_texCoord.x\n #endif\n );\n color = a_color;\n#else\n mat4 xformNoScale = matrixFromRT(quaternionFromEuler(a_texCoord2), pos.xyz);\n mat4 xform = matFromRTS(quaternionFromEuler(a_texCoord2), pos.xyz, compScale);\n pos = xform * vec4(a_texCoord3, 1);\n vec4 normal = xformNoScale * vec4(a_normal, 0);\n color = a_color * a_color1;\n#endif\n uv = computeUV(a_texCoord.z, a_texCoord.xy, frameTile_velLenScale.xy) * mainTiling_Offset.xy + mainTiling_Offset.zw;\n pos = cc_matViewProj * pos;\n return pos;\n}\nvoid main() { gl_Position = lpvs_main(); }", + "frag": "\nprecision highp float;\nvec4 CCFragOutput (vec4 color) {\n #if OUTPUT_TO_GAMMA\n color.rgb = sqrt(color.rgb);\n #endif\n\treturn color;\n}\nin vec2 uv;\nin vec4 color;\nuniform sampler2D mainTexture;\nuniform FragConstants {\n vec4 tintColor;\n};\nvec4 add () {\n vec4 col = 2.0 * color * tintColor * texture(mainTexture, uv);\n return CCFragOutput(col);\n}\nout vec4 cc_FragColor;\nvoid main() { cc_FragColor = add(); }" + }, + "glsl1": { + "vert": "\nprecision highp float;\nvec4 quaternionFromAxis(vec3 xAxis,vec3 yAxis,vec3 zAxis){\n mat3 m = mat3(xAxis,yAxis,zAxis);\n float trace = m[0][0] + m[1][1] + m[2][2];\n vec4 quat;\n if (trace > 0.) {\n float s = 0.5 / sqrt(trace + 1.0);\n quat.w = 0.25 / s;\n quat.x = (m[2][1] - m[1][2]) * s;\n quat.y = (m[0][2] - m[2][0]) * s;\n quat.z = (m[1][0] - m[0][1]) * s;\n } else if ((m[0][0] > m[1][1]) && (m[0][0] > m[2][2])) {\n float s = 2.0 * sqrt(1.0 + m[0][0] - m[1][1] - m[2][2]);\n quat.w = (m[2][1] - m[1][2]) / s;\n quat.x = 0.25 * s;\n quat.y = (m[0][1] + m[1][0]) / s;\n quat.z = (m[0][2] + m[2][0]) / s;\n } else if (m[1][1] > m[2][2]) {\n float s = 2.0 * sqrt(1.0 + m[1][1] - m[0][0] - m[2][2]);\n quat.w = (m[0][2] - m[2][0]) / s;\n quat.x = (m[0][1] + m[1][0]) / s;\n quat.y = 0.25 * s;\n quat.z = (m[1][2] + m[2][1]) / s;\n } else {\n float s = 2.0 * sqrt(1.0 + m[2][2] - m[0][0] - m[1][1]);\n quat.w = (m[1][0] - m[0][1]) / s;\n quat.x = (m[0][2] + m[2][0]) / s;\n quat.y = (m[1][2] + m[2][1]) / s;\n quat.z = 0.25 * s;\n }\n float len = quat.x * quat.x + quat.y * quat.y + quat.z * quat.z + quat.w * quat.w;\n if (len > 0.) {\n len = 1. / sqrt(len);\n quat.x = quat.x * len;\n quat.y = quat.y * len;\n quat.z = quat.z * len;\n quat.w = quat.w * len;\n }\n return quat;\n}\nvec4 quaternionFromEuler(vec3 angle){\n float x = angle.x / 2.;\n float y = angle.y / 2.;\n float z = angle.z / 2.;\n float sx = sin(x);\n float cx = cos(x);\n float sy = sin(y);\n float cy = cos(y);\n float sz = sin(z);\n float cz = cos(z);\n vec4 quat = vec4(0);\n quat.x = sx * cy * cz + cx * sy * sz;\n quat.y = cx * sy * cz + sx * cy * sz;\n quat.z = cx * cy * sz - sx * sy * cz;\n quat.w = cx * cy * cz - sx * sy * sz;\n return quat;\n}\nmat4 matrixFromRT(vec4 q, vec3 p){\n float x2 = q.x + q.x;\n float y2 = q.y + q.y;\n float z2 = q.z + q.z;\n float xx = q.x * x2;\n float xy = q.x * y2;\n float xz = q.x * z2;\n float yy = q.y * y2;\n float yz = q.y * z2;\n float zz = q.z * z2;\n float wx = q.w * x2;\n float wy = q.w * y2;\n float wz = q.w * z2;\n return mat4(\n 1. - (yy + zz), xy + wz, xz - wy, 0,\n xy - wz, 1. - (xx + zz), yz + wx, 0,\n xz + wy, yz - wx, 1. - (xx + yy), 0,\n p.x, p.y, p.z, 1\n );\n}\nmat4 matFromRTS(vec4 q, vec3 t, vec3 s){\n float x = q.x, y = q.y, z = q.z, w = q.w;\n float x2 = x + x;\n float y2 = y + y;\n float z2 = z + z;\n float xx = x * x2;\n float xy = x * y2;\n float xz = x * z2;\n float yy = y * y2;\n float yz = y * z2;\n float zz = z * z2;\n float wx = w * x2;\n float wy = w * y2;\n float wz = w * z2;\n float sx = s.x;\n float sy = s.y;\n float sz = s.z;\n return mat4((1. - (yy + zz)) * sx, (xy + wz) * sx, (xz - wy) * sx, 0,\n (xy - wz) * sy, (1. - (xx + zz)) * sy, (yz + wx) * sy, 0,\n (xz + wy) * sz, (yz - wx) * sz, (1. - (xx + yy)) * sz, 0,\n t.x, t.y, t.z, 1);\n}\nvec4 quatMultiply(vec4 a, vec4 b){\n vec4 quat;\n quat.x = a.x * b.w + a.w * b.x + a.y * b.z - a.z * b.y;\n quat.y = a.y * b.w + a.w * b.y + a.z * b.x - a.x * b.z;\n quat.z = a.z * b.w + a.w * b.z + a.x * b.y - a.y * b.x;\n quat.w = a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z;\n return quat;\n}\nvoid rotateVecFromQuat(inout vec3 v, vec4 q){\n float ix = q.w * v.x + q.y * v.z - q.z * v.y;\n float iy = q.w * v.y + q.z * v.x - q.x * v.z;\n float iz = q.w * v.z + q.x * v.y - q.y * v.x;\n float iw = -q.x * v.x - q.y * v.y - q.z * v.z;\n v.x = ix * q.w + iw * -q.x + iy * -q.z - iz * -q.y;\n v.y = iy * q.w + iw * -q.y + iz * -q.x - ix * -q.z;\n v.z = iz * q.w + iw * -q.z + ix * -q.y - iy * -q.x;\n}\nvec3 rotateInLocalSpace(vec3 pos, vec3 xAxis, vec3 yAxis, vec3 zAxis, vec4 q){\n float z = pos.z;\n float x = pos.x;\n float y = pos.y;\n vec4 viewQuat = quaternionFromAxis(xAxis, yAxis, zAxis);\n vec4 rotQuat = quatMultiply(viewQuat, q);\n rotateVecFromQuat(pos, rotQuat);\n return pos;\n}\nvoid rotateCorner(inout vec2 corner, float angle){\n float xOS = cos(angle) * corner.x - sin(angle) * corner.y;\n float yOS = sin(angle) * corner.x + cos(angle) * corner.y;\n corner.x = xOS;\n corner.y = yOS;\n}\nuniform vec4 mainTiling_Offset;\nuniform vec4 frameTile_velLenScale;\nuniform vec4 scale;\nuniform mat4 cc_matView;\nuniform mat4 cc_matViewInv;\nuniform mat4 cc_matViewProj;\nuniform vec4 cc_cameraPos;\nuniform mat4 cc_matWorld;\nvarying vec2 uv;\nvarying vec4 color;\nvoid computeVertPos(inout vec4 pos, vec2 vertOffset, vec4 q, vec3 s\n#if CC_USE_BILLBOARD || CC_USE_VERTICAL_BILLBOARD\n , mat4 viewInv\n#endif\n#if CC_USE_STRETCHED_BILLBOARD\n , vec3 eye\n , vec4 velocity\n , float velocityScale\n , float lengthScale\n , float xIndex\n#endif\n) {\n#if CC_USE_BILLBOARD\n vec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\n vec3 camX = normalize(vec3(viewInv[0][0], viewInv[1][0], viewInv[2][0]));\n vec3 camY = normalize(vec3(viewInv[0][1], viewInv[1][1], viewInv[2][1]));\n vec3 camZ = normalize(vec3(viewInv[0][2], viewInv[1][2], viewInv[2][2]));\n pos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, camZ, q);\n#elif CC_USE_STRETCHED_BILLBOARD\n vec3 camRight = normalize(cross(pos.xyz - eye, velocity.xyz)) * s.x;\n vec3 camUp = velocity.xyz * velocityScale + normalize(velocity.xyz) * lengthScale * s.y;\n pos.xyz += (camRight * abs(vertOffset.x) * sign(vertOffset.y)) - camUp * xIndex;\n#elif CC_USE_HORIZONTAL_BILLBOARD\n vec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\n vec3 camX = vec3(1, 0, 0);\n vec3 camY = vec3(0, 0, -1);\n pos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, cross(camX, camY), q);\n#elif CC_USE_VERTICAL_BILLBOARD\n vec2 viewSpaceVert = vec2(vertOffset.x * s.x, vertOffset.y * s.y);\n rotateCorner(viewSpaceVert, q.z);\n vec3 camX = normalize(vec3(cc_matView[0][0], cc_matView[1][0], cc_matView[2][0]));\n vec3 camY = vec3(0, 1, 0);\n vec3 offset = camX * viewSpaceVert.x + camY * viewSpaceVert.y;\n pos.xyz += offset;\n#else\n pos.x += vertOffset.x;\n pos.y += vertOffset.y;\n#endif\n}\nvec2 computeUV(float frameIndex, vec2 vertIndex, vec2 frameTile){\n vec2 aniUV = vec2(0, floor(frameIndex * frameTile.y));\n aniUV.x = floor(frameIndex * frameTile.x * frameTile.y - aniUV.y * frameTile.x);\n#if !CC_USE_MESH\n vertIndex.y = 1. - vertIndex.y;\n#endif\n return (aniUV.xy + vertIndex) / vec2(frameTile.x, frameTile.y);\n}\nattribute vec3 a_position;\nattribute vec3 a_texCoord;\nattribute vec3 a_texCoord1;\nattribute vec3 a_texCoord2;\nattribute vec4 a_color;\n#if CC_USE_STRETCHED_BILLBOARD\n attribute vec3 a_color1;\n#endif\n#if CC_USE_MESH\n attribute vec3 a_texCoord3;\n attribute vec3 a_normal;\n attribute vec4 a_color1;\n#endif\nvec4 lpvs_main() {\n vec3 compScale = scale.xyz * a_texCoord1;\n vec4 pos = vec4(a_position, 1);\n#if CC_USE_STRETCHED_BILLBOARD\n vec4 velocity = vec4(a_color1.xyz, 0);\n#endif\n#if !CC_USE_WORLD_SPACE\n pos = cc_matWorld * pos;\n #if CC_USE_STRETCHED_BILLBOARD\n velocity = cc_matWorld * velocity;\n #endif\n#endif\n#if !CC_USE_MESH\n vec2 cornerOffset = vec2((a_texCoord.xy - 0.5));\n #if CC_USE_BILLBOARD\n vec3 rotEuler = a_texCoord2;\n #elif CC_USE_STRETCHED_BILLBOARD\n vec3 rotEuler = vec3(0.);\n #else\n vec3 rotEuler = vec3(0., 0., a_texCoord2.z);\n #endif\n computeVertPos(pos, cornerOffset, quaternionFromEuler(rotEuler), compScale\n #if CC_USE_BILLBOARD || CC_USE_VERTICAL_BILLBOARD\n , cc_matViewInv\n #endif\n #if CC_USE_STRETCHED_BILLBOARD\n , cc_cameraPos.xyz\n , velocity\n , frameTile_velLenScale.z\n , frameTile_velLenScale.w\n , a_texCoord.x\n #endif\n );\n color = a_color;\n#else\n mat4 xformNoScale = matrixFromRT(quaternionFromEuler(a_texCoord2), pos.xyz);\n mat4 xform = matFromRTS(quaternionFromEuler(a_texCoord2), pos.xyz, compScale);\n pos = xform * vec4(a_texCoord3, 1);\n vec4 normal = xformNoScale * vec4(a_normal, 0);\n color = a_color * a_color1;\n#endif\n uv = computeUV(a_texCoord.z, a_texCoord.xy, frameTile_velLenScale.xy) * mainTiling_Offset.xy + mainTiling_Offset.zw;\n pos = cc_matViewProj * pos;\n return pos;\n}\nvoid main() { gl_Position = lpvs_main(); }", + "frag": "\nprecision highp float;\nvec4 CCFragOutput (vec4 color) {\n #if OUTPUT_TO_GAMMA\n color.rgb = sqrt(color.rgb);\n #endif\n\treturn color;\n}\nvarying vec2 uv;\nvarying vec4 color;\nuniform sampler2D mainTexture;\nuniform vec4 tintColor;\nvec4 add () {\n vec4 col = 2.0 * color * tintColor * texture2D(mainTexture, uv);\n return CCFragOutput(col);\n}\nvoid main() { gl_FragColor = add(); }" + }, + "builtins": { + "globals": { + "blocks": [ + { + "name": "CCGlobal", + "defines": [] + } + ], + "samplers": [] + }, + "locals": { + "blocks": [ + { + "name": "CCLocal", + "defines": [] + } + ], + "samplers": [] + } + }, + "defines": [ + { + "name": "CC_USE_BILLBOARD", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_STRETCHED_BILLBOARD", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_HORIZONTAL_BILLBOARD", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_VERTICAL_BILLBOARD", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_MESH", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_WORLD_SPACE", + "type": "boolean", + "defines": [] + }, + { + "name": "OUTPUT_TO_GAMMA", + "type": "boolean", + "defines": [] + } + ], + "blocks": [ + { + "name": "Constants", + "binding": 0, + "members": [ + { + "name": "mainTiling_Offset", + "type": 16, + "count": 1 + }, + { + "name": "frameTile_velLenScale", + "type": 16, + "count": 1 + }, + { + "name": "scale", + "type": 16, + "count": 1 + } + ], + "defines": [] + }, + { + "name": "FragConstants", + "binding": 1, + "members": [ + { + "name": "tintColor", + "type": 16, + "count": 1 + } + ], + "defines": [] + } + ], + "samplers": [ + { + "name": "mainTexture", + "type": 29, + "count": 1, + "binding": 30, + "defines": [] + } + ] + }, + { + "hash": 1933642753, + "record": null, + "name": "builtin-3d-particle|particle-vs-legacy:lpvs_main|tinted-fs:multiply", + "glsl3": { + "vert": "\nprecision highp float;\nvec4 quaternionFromAxis(vec3 xAxis,vec3 yAxis,vec3 zAxis){\n mat3 m = mat3(xAxis,yAxis,zAxis);\n float trace = m[0][0] + m[1][1] + m[2][2];\n vec4 quat;\n if (trace > 0.) {\n float s = 0.5 / sqrt(trace + 1.0);\n quat.w = 0.25 / s;\n quat.x = (m[2][1] - m[1][2]) * s;\n quat.y = (m[0][2] - m[2][0]) * s;\n quat.z = (m[1][0] - m[0][1]) * s;\n } else if ((m[0][0] > m[1][1]) && (m[0][0] > m[2][2])) {\n float s = 2.0 * sqrt(1.0 + m[0][0] - m[1][1] - m[2][2]);\n quat.w = (m[2][1] - m[1][2]) / s;\n quat.x = 0.25 * s;\n quat.y = (m[0][1] + m[1][0]) / s;\n quat.z = (m[0][2] + m[2][0]) / s;\n } else if (m[1][1] > m[2][2]) {\n float s = 2.0 * sqrt(1.0 + m[1][1] - m[0][0] - m[2][2]);\n quat.w = (m[0][2] - m[2][0]) / s;\n quat.x = (m[0][1] + m[1][0]) / s;\n quat.y = 0.25 * s;\n quat.z = (m[1][2] + m[2][1]) / s;\n } else {\n float s = 2.0 * sqrt(1.0 + m[2][2] - m[0][0] - m[1][1]);\n quat.w = (m[1][0] - m[0][1]) / s;\n quat.x = (m[0][2] + m[2][0]) / s;\n quat.y = (m[1][2] + m[2][1]) / s;\n quat.z = 0.25 * s;\n }\n float len = quat.x * quat.x + quat.y * quat.y + quat.z * quat.z + quat.w * quat.w;\n if (len > 0.) {\n len = 1. / sqrt(len);\n quat.x = quat.x * len;\n quat.y = quat.y * len;\n quat.z = quat.z * len;\n quat.w = quat.w * len;\n }\n return quat;\n}\nvec4 quaternionFromEuler(vec3 angle){\n float x = angle.x / 2.;\n float y = angle.y / 2.;\n float z = angle.z / 2.;\n float sx = sin(x);\n float cx = cos(x);\n float sy = sin(y);\n float cy = cos(y);\n float sz = sin(z);\n float cz = cos(z);\n vec4 quat = vec4(0);\n quat.x = sx * cy * cz + cx * sy * sz;\n quat.y = cx * sy * cz + sx * cy * sz;\n quat.z = cx * cy * sz - sx * sy * cz;\n quat.w = cx * cy * cz - sx * sy * sz;\n return quat;\n}\nmat4 matrixFromRT(vec4 q, vec3 p){\n float x2 = q.x + q.x;\n float y2 = q.y + q.y;\n float z2 = q.z + q.z;\n float xx = q.x * x2;\n float xy = q.x * y2;\n float xz = q.x * z2;\n float yy = q.y * y2;\n float yz = q.y * z2;\n float zz = q.z * z2;\n float wx = q.w * x2;\n float wy = q.w * y2;\n float wz = q.w * z2;\n return mat4(\n 1. - (yy + zz), xy + wz, xz - wy, 0,\n xy - wz, 1. - (xx + zz), yz + wx, 0,\n xz + wy, yz - wx, 1. - (xx + yy), 0,\n p.x, p.y, p.z, 1\n );\n}\nmat4 matFromRTS(vec4 q, vec3 t, vec3 s){\n float x = q.x, y = q.y, z = q.z, w = q.w;\n float x2 = x + x;\n float y2 = y + y;\n float z2 = z + z;\n float xx = x * x2;\n float xy = x * y2;\n float xz = x * z2;\n float yy = y * y2;\n float yz = y * z2;\n float zz = z * z2;\n float wx = w * x2;\n float wy = w * y2;\n float wz = w * z2;\n float sx = s.x;\n float sy = s.y;\n float sz = s.z;\n return mat4((1. - (yy + zz)) * sx, (xy + wz) * sx, (xz - wy) * sx, 0,\n (xy - wz) * sy, (1. - (xx + zz)) * sy, (yz + wx) * sy, 0,\n (xz + wy) * sz, (yz - wx) * sz, (1. - (xx + yy)) * sz, 0,\n t.x, t.y, t.z, 1);\n}\nvec4 quatMultiply(vec4 a, vec4 b){\n vec4 quat;\n quat.x = a.x * b.w + a.w * b.x + a.y * b.z - a.z * b.y;\n quat.y = a.y * b.w + a.w * b.y + a.z * b.x - a.x * b.z;\n quat.z = a.z * b.w + a.w * b.z + a.x * b.y - a.y * b.x;\n quat.w = a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z;\n return quat;\n}\nvoid rotateVecFromQuat(inout vec3 v, vec4 q){\n float ix = q.w * v.x + q.y * v.z - q.z * v.y;\n float iy = q.w * v.y + q.z * v.x - q.x * v.z;\n float iz = q.w * v.z + q.x * v.y - q.y * v.x;\n float iw = -q.x * v.x - q.y * v.y - q.z * v.z;\n v.x = ix * q.w + iw * -q.x + iy * -q.z - iz * -q.y;\n v.y = iy * q.w + iw * -q.y + iz * -q.x - ix * -q.z;\n v.z = iz * q.w + iw * -q.z + ix * -q.y - iy * -q.x;\n}\nvec3 rotateInLocalSpace(vec3 pos, vec3 xAxis, vec3 yAxis, vec3 zAxis, vec4 q){\n float z = pos.z;\n float x = pos.x;\n float y = pos.y;\n vec4 viewQuat = quaternionFromAxis(xAxis, yAxis, zAxis);\n vec4 rotQuat = quatMultiply(viewQuat, q);\n rotateVecFromQuat(pos, rotQuat);\n return pos;\n}\nvoid rotateCorner(inout vec2 corner, float angle){\n float xOS = cos(angle) * corner.x - sin(angle) * corner.y;\n float yOS = sin(angle) * corner.x + cos(angle) * corner.y;\n corner.x = xOS;\n corner.y = yOS;\n}\nuniform Constants{\n vec4 mainTiling_Offset;\n vec4 frameTile_velLenScale;\n vec4 scale;\n};\nuniform CCGlobal {\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\nuniform CCLocal {\n mat4 cc_matWorld;\n mat4 cc_matWorldIT;\n};\nout vec2 uv;\nout vec4 color;\nvoid computeVertPos(inout vec4 pos, vec2 vertOffset, vec4 q, vec3 s\n#if CC_USE_BILLBOARD || CC_USE_VERTICAL_BILLBOARD\n , mat4 viewInv\n#endif\n#if CC_USE_STRETCHED_BILLBOARD\n , vec3 eye\n , vec4 velocity\n , float velocityScale\n , float lengthScale\n , float xIndex\n#endif\n) {\n#if CC_USE_BILLBOARD\n vec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\n vec3 camX = normalize(vec3(viewInv[0][0], viewInv[1][0], viewInv[2][0]));\n vec3 camY = normalize(vec3(viewInv[0][1], viewInv[1][1], viewInv[2][1]));\n vec3 camZ = normalize(vec3(viewInv[0][2], viewInv[1][2], viewInv[2][2]));\n pos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, camZ, q);\n#elif CC_USE_STRETCHED_BILLBOARD\n vec3 camRight = normalize(cross(pos.xyz - eye, velocity.xyz)) * s.x;\n vec3 camUp = velocity.xyz * velocityScale + normalize(velocity.xyz) * lengthScale * s.y;\n pos.xyz += (camRight * abs(vertOffset.x) * sign(vertOffset.y)) - camUp * xIndex;\n#elif CC_USE_HORIZONTAL_BILLBOARD\n vec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\n vec3 camX = vec3(1, 0, 0);\n vec3 camY = vec3(0, 0, -1);\n pos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, cross(camX, camY), q);\n#elif CC_USE_VERTICAL_BILLBOARD\n vec2 viewSpaceVert = vec2(vertOffset.x * s.x, vertOffset.y * s.y);\n rotateCorner(viewSpaceVert, q.z);\n vec3 camX = normalize(vec3(cc_matView[0][0], cc_matView[1][0], cc_matView[2][0]));\n vec3 camY = vec3(0, 1, 0);\n vec3 offset = camX * viewSpaceVert.x + camY * viewSpaceVert.y;\n pos.xyz += offset;\n#else\n pos.x += vertOffset.x;\n pos.y += vertOffset.y;\n#endif\n}\nvec2 computeUV(float frameIndex, vec2 vertIndex, vec2 frameTile){\n vec2 aniUV = vec2(0, floor(frameIndex * frameTile.y));\n aniUV.x = floor(frameIndex * frameTile.x * frameTile.y - aniUV.y * frameTile.x);\n#if !CC_USE_MESH\n vertIndex.y = 1. - vertIndex.y;\n#endif\n return (aniUV.xy + vertIndex) / vec2(frameTile.x, frameTile.y);\n}\nin vec3 a_position;\nin vec3 a_texCoord;\nin vec3 a_texCoord1;\nin vec3 a_texCoord2;\nin vec4 a_color;\n#if CC_USE_STRETCHED_BILLBOARD\n in vec3 a_color1;\n#endif\n#if CC_USE_MESH\n in vec3 a_texCoord3;\n in vec3 a_normal;\n in vec4 a_color1;\n#endif\nvec4 lpvs_main() {\n vec3 compScale = scale.xyz * a_texCoord1;\n vec4 pos = vec4(a_position, 1);\n#if CC_USE_STRETCHED_BILLBOARD\n vec4 velocity = vec4(a_color1.xyz, 0);\n#endif\n#if !CC_USE_WORLD_SPACE\n pos = cc_matWorld * pos;\n #if CC_USE_STRETCHED_BILLBOARD\n velocity = cc_matWorld * velocity;\n #endif\n#endif\n#if !CC_USE_MESH\n vec2 cornerOffset = vec2((a_texCoord.xy - 0.5));\n #if CC_USE_BILLBOARD\n vec3 rotEuler = a_texCoord2;\n #elif CC_USE_STRETCHED_BILLBOARD\n vec3 rotEuler = vec3(0.);\n #else\n vec3 rotEuler = vec3(0., 0., a_texCoord2.z);\n #endif\n computeVertPos(pos, cornerOffset, quaternionFromEuler(rotEuler), compScale\n #if CC_USE_BILLBOARD || CC_USE_VERTICAL_BILLBOARD\n , cc_matViewInv\n #endif\n #if CC_USE_STRETCHED_BILLBOARD\n , cc_cameraPos.xyz\n , velocity\n , frameTile_velLenScale.z\n , frameTile_velLenScale.w\n , a_texCoord.x\n #endif\n );\n color = a_color;\n#else\n mat4 xformNoScale = matrixFromRT(quaternionFromEuler(a_texCoord2), pos.xyz);\n mat4 xform = matFromRTS(quaternionFromEuler(a_texCoord2), pos.xyz, compScale);\n pos = xform * vec4(a_texCoord3, 1);\n vec4 normal = xformNoScale * vec4(a_normal, 0);\n color = a_color * a_color1;\n#endif\n uv = computeUV(a_texCoord.z, a_texCoord.xy, frameTile_velLenScale.xy) * mainTiling_Offset.xy + mainTiling_Offset.zw;\n pos = cc_matViewProj * pos;\n return pos;\n}\nvoid main() { gl_Position = lpvs_main(); }", + "frag": "\nprecision highp float;\nvec4 CCFragOutput (vec4 color) {\n #if OUTPUT_TO_GAMMA\n color.rgb = sqrt(color.rgb);\n #endif\n\treturn color;\n}\nin vec2 uv;\nin vec4 color;\nuniform sampler2D mainTexture;\nuniform FragConstants {\n vec4 tintColor;\n};\nvec4 multiply () {\n vec4 col;\n vec4 texColor = texture(mainTexture, uv);\n col.rgb = tintColor.rgb * texColor.rgb * color.rgb * vec3(2.0);\n col.a = (1.0 - texColor.a) * (tintColor.a * color.a * 2.0);\n return CCFragOutput(col);\n}\nout vec4 cc_FragColor;\nvoid main() { cc_FragColor = multiply(); }" + }, + "glsl1": { + "vert": "\nprecision highp float;\nvec4 quaternionFromAxis(vec3 xAxis,vec3 yAxis,vec3 zAxis){\n mat3 m = mat3(xAxis,yAxis,zAxis);\n float trace = m[0][0] + m[1][1] + m[2][2];\n vec4 quat;\n if (trace > 0.) {\n float s = 0.5 / sqrt(trace + 1.0);\n quat.w = 0.25 / s;\n quat.x = (m[2][1] - m[1][2]) * s;\n quat.y = (m[0][2] - m[2][0]) * s;\n quat.z = (m[1][0] - m[0][1]) * s;\n } else if ((m[0][0] > m[1][1]) && (m[0][0] > m[2][2])) {\n float s = 2.0 * sqrt(1.0 + m[0][0] - m[1][1] - m[2][2]);\n quat.w = (m[2][1] - m[1][2]) / s;\n quat.x = 0.25 * s;\n quat.y = (m[0][1] + m[1][0]) / s;\n quat.z = (m[0][2] + m[2][0]) / s;\n } else if (m[1][1] > m[2][2]) {\n float s = 2.0 * sqrt(1.0 + m[1][1] - m[0][0] - m[2][2]);\n quat.w = (m[0][2] - m[2][0]) / s;\n quat.x = (m[0][1] + m[1][0]) / s;\n quat.y = 0.25 * s;\n quat.z = (m[1][2] + m[2][1]) / s;\n } else {\n float s = 2.0 * sqrt(1.0 + m[2][2] - m[0][0] - m[1][1]);\n quat.w = (m[1][0] - m[0][1]) / s;\n quat.x = (m[0][2] + m[2][0]) / s;\n quat.y = (m[1][2] + m[2][1]) / s;\n quat.z = 0.25 * s;\n }\n float len = quat.x * quat.x + quat.y * quat.y + quat.z * quat.z + quat.w * quat.w;\n if (len > 0.) {\n len = 1. / sqrt(len);\n quat.x = quat.x * len;\n quat.y = quat.y * len;\n quat.z = quat.z * len;\n quat.w = quat.w * len;\n }\n return quat;\n}\nvec4 quaternionFromEuler(vec3 angle){\n float x = angle.x / 2.;\n float y = angle.y / 2.;\n float z = angle.z / 2.;\n float sx = sin(x);\n float cx = cos(x);\n float sy = sin(y);\n float cy = cos(y);\n float sz = sin(z);\n float cz = cos(z);\n vec4 quat = vec4(0);\n quat.x = sx * cy * cz + cx * sy * sz;\n quat.y = cx * sy * cz + sx * cy * sz;\n quat.z = cx * cy * sz - sx * sy * cz;\n quat.w = cx * cy * cz - sx * sy * sz;\n return quat;\n}\nmat4 matrixFromRT(vec4 q, vec3 p){\n float x2 = q.x + q.x;\n float y2 = q.y + q.y;\n float z2 = q.z + q.z;\n float xx = q.x * x2;\n float xy = q.x * y2;\n float xz = q.x * z2;\n float yy = q.y * y2;\n float yz = q.y * z2;\n float zz = q.z * z2;\n float wx = q.w * x2;\n float wy = q.w * y2;\n float wz = q.w * z2;\n return mat4(\n 1. - (yy + zz), xy + wz, xz - wy, 0,\n xy - wz, 1. - (xx + zz), yz + wx, 0,\n xz + wy, yz - wx, 1. - (xx + yy), 0,\n p.x, p.y, p.z, 1\n );\n}\nmat4 matFromRTS(vec4 q, vec3 t, vec3 s){\n float x = q.x, y = q.y, z = q.z, w = q.w;\n float x2 = x + x;\n float y2 = y + y;\n float z2 = z + z;\n float xx = x * x2;\n float xy = x * y2;\n float xz = x * z2;\n float yy = y * y2;\n float yz = y * z2;\n float zz = z * z2;\n float wx = w * x2;\n float wy = w * y2;\n float wz = w * z2;\n float sx = s.x;\n float sy = s.y;\n float sz = s.z;\n return mat4((1. - (yy + zz)) * sx, (xy + wz) * sx, (xz - wy) * sx, 0,\n (xy - wz) * sy, (1. - (xx + zz)) * sy, (yz + wx) * sy, 0,\n (xz + wy) * sz, (yz - wx) * sz, (1. - (xx + yy)) * sz, 0,\n t.x, t.y, t.z, 1);\n}\nvec4 quatMultiply(vec4 a, vec4 b){\n vec4 quat;\n quat.x = a.x * b.w + a.w * b.x + a.y * b.z - a.z * b.y;\n quat.y = a.y * b.w + a.w * b.y + a.z * b.x - a.x * b.z;\n quat.z = a.z * b.w + a.w * b.z + a.x * b.y - a.y * b.x;\n quat.w = a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z;\n return quat;\n}\nvoid rotateVecFromQuat(inout vec3 v, vec4 q){\n float ix = q.w * v.x + q.y * v.z - q.z * v.y;\n float iy = q.w * v.y + q.z * v.x - q.x * v.z;\n float iz = q.w * v.z + q.x * v.y - q.y * v.x;\n float iw = -q.x * v.x - q.y * v.y - q.z * v.z;\n v.x = ix * q.w + iw * -q.x + iy * -q.z - iz * -q.y;\n v.y = iy * q.w + iw * -q.y + iz * -q.x - ix * -q.z;\n v.z = iz * q.w + iw * -q.z + ix * -q.y - iy * -q.x;\n}\nvec3 rotateInLocalSpace(vec3 pos, vec3 xAxis, vec3 yAxis, vec3 zAxis, vec4 q){\n float z = pos.z;\n float x = pos.x;\n float y = pos.y;\n vec4 viewQuat = quaternionFromAxis(xAxis, yAxis, zAxis);\n vec4 rotQuat = quatMultiply(viewQuat, q);\n rotateVecFromQuat(pos, rotQuat);\n return pos;\n}\nvoid rotateCorner(inout vec2 corner, float angle){\n float xOS = cos(angle) * corner.x - sin(angle) * corner.y;\n float yOS = sin(angle) * corner.x + cos(angle) * corner.y;\n corner.x = xOS;\n corner.y = yOS;\n}\nuniform vec4 mainTiling_Offset;\nuniform vec4 frameTile_velLenScale;\nuniform vec4 scale;\nuniform mat4 cc_matView;\nuniform mat4 cc_matViewInv;\nuniform mat4 cc_matViewProj;\nuniform vec4 cc_cameraPos;\nuniform mat4 cc_matWorld;\nvarying vec2 uv;\nvarying vec4 color;\nvoid computeVertPos(inout vec4 pos, vec2 vertOffset, vec4 q, vec3 s\n#if CC_USE_BILLBOARD || CC_USE_VERTICAL_BILLBOARD\n , mat4 viewInv\n#endif\n#if CC_USE_STRETCHED_BILLBOARD\n , vec3 eye\n , vec4 velocity\n , float velocityScale\n , float lengthScale\n , float xIndex\n#endif\n) {\n#if CC_USE_BILLBOARD\n vec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\n vec3 camX = normalize(vec3(viewInv[0][0], viewInv[1][0], viewInv[2][0]));\n vec3 camY = normalize(vec3(viewInv[0][1], viewInv[1][1], viewInv[2][1]));\n vec3 camZ = normalize(vec3(viewInv[0][2], viewInv[1][2], viewInv[2][2]));\n pos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, camZ, q);\n#elif CC_USE_STRETCHED_BILLBOARD\n vec3 camRight = normalize(cross(pos.xyz - eye, velocity.xyz)) * s.x;\n vec3 camUp = velocity.xyz * velocityScale + normalize(velocity.xyz) * lengthScale * s.y;\n pos.xyz += (camRight * abs(vertOffset.x) * sign(vertOffset.y)) - camUp * xIndex;\n#elif CC_USE_HORIZONTAL_BILLBOARD\n vec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\n vec3 camX = vec3(1, 0, 0);\n vec3 camY = vec3(0, 0, -1);\n pos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, cross(camX, camY), q);\n#elif CC_USE_VERTICAL_BILLBOARD\n vec2 viewSpaceVert = vec2(vertOffset.x * s.x, vertOffset.y * s.y);\n rotateCorner(viewSpaceVert, q.z);\n vec3 camX = normalize(vec3(cc_matView[0][0], cc_matView[1][0], cc_matView[2][0]));\n vec3 camY = vec3(0, 1, 0);\n vec3 offset = camX * viewSpaceVert.x + camY * viewSpaceVert.y;\n pos.xyz += offset;\n#else\n pos.x += vertOffset.x;\n pos.y += vertOffset.y;\n#endif\n}\nvec2 computeUV(float frameIndex, vec2 vertIndex, vec2 frameTile){\n vec2 aniUV = vec2(0, floor(frameIndex * frameTile.y));\n aniUV.x = floor(frameIndex * frameTile.x * frameTile.y - aniUV.y * frameTile.x);\n#if !CC_USE_MESH\n vertIndex.y = 1. - vertIndex.y;\n#endif\n return (aniUV.xy + vertIndex) / vec2(frameTile.x, frameTile.y);\n}\nattribute vec3 a_position;\nattribute vec3 a_texCoord;\nattribute vec3 a_texCoord1;\nattribute vec3 a_texCoord2;\nattribute vec4 a_color;\n#if CC_USE_STRETCHED_BILLBOARD\n attribute vec3 a_color1;\n#endif\n#if CC_USE_MESH\n attribute vec3 a_texCoord3;\n attribute vec3 a_normal;\n attribute vec4 a_color1;\n#endif\nvec4 lpvs_main() {\n vec3 compScale = scale.xyz * a_texCoord1;\n vec4 pos = vec4(a_position, 1);\n#if CC_USE_STRETCHED_BILLBOARD\n vec4 velocity = vec4(a_color1.xyz, 0);\n#endif\n#if !CC_USE_WORLD_SPACE\n pos = cc_matWorld * pos;\n #if CC_USE_STRETCHED_BILLBOARD\n velocity = cc_matWorld * velocity;\n #endif\n#endif\n#if !CC_USE_MESH\n vec2 cornerOffset = vec2((a_texCoord.xy - 0.5));\n #if CC_USE_BILLBOARD\n vec3 rotEuler = a_texCoord2;\n #elif CC_USE_STRETCHED_BILLBOARD\n vec3 rotEuler = vec3(0.);\n #else\n vec3 rotEuler = vec3(0., 0., a_texCoord2.z);\n #endif\n computeVertPos(pos, cornerOffset, quaternionFromEuler(rotEuler), compScale\n #if CC_USE_BILLBOARD || CC_USE_VERTICAL_BILLBOARD\n , cc_matViewInv\n #endif\n #if CC_USE_STRETCHED_BILLBOARD\n , cc_cameraPos.xyz\n , velocity\n , frameTile_velLenScale.z\n , frameTile_velLenScale.w\n , a_texCoord.x\n #endif\n );\n color = a_color;\n#else\n mat4 xformNoScale = matrixFromRT(quaternionFromEuler(a_texCoord2), pos.xyz);\n mat4 xform = matFromRTS(quaternionFromEuler(a_texCoord2), pos.xyz, compScale);\n pos = xform * vec4(a_texCoord3, 1);\n vec4 normal = xformNoScale * vec4(a_normal, 0);\n color = a_color * a_color1;\n#endif\n uv = computeUV(a_texCoord.z, a_texCoord.xy, frameTile_velLenScale.xy) * mainTiling_Offset.xy + mainTiling_Offset.zw;\n pos = cc_matViewProj * pos;\n return pos;\n}\nvoid main() { gl_Position = lpvs_main(); }", + "frag": "\nprecision highp float;\nvec4 CCFragOutput (vec4 color) {\n #if OUTPUT_TO_GAMMA\n color.rgb = sqrt(color.rgb);\n #endif\n\treturn color;\n}\nvarying vec2 uv;\nvarying vec4 color;\nuniform sampler2D mainTexture;\nuniform vec4 tintColor;\nvec4 multiply () {\n vec4 col;\n vec4 texColor = texture2D(mainTexture, uv);\n col.rgb = tintColor.rgb * texColor.rgb * color.rgb * vec3(2.0);\n col.a = (1.0 - texColor.a) * (tintColor.a * color.a * 2.0);\n return CCFragOutput(col);\n}\nvoid main() { gl_FragColor = multiply(); }" + }, + "builtins": { + "globals": { + "blocks": [ + { + "name": "CCGlobal", + "defines": [] + } + ], + "samplers": [] + }, + "locals": { + "blocks": [ + { + "name": "CCLocal", + "defines": [] + } + ], + "samplers": [] + } + }, + "defines": [ + { + "name": "CC_USE_BILLBOARD", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_STRETCHED_BILLBOARD", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_HORIZONTAL_BILLBOARD", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_VERTICAL_BILLBOARD", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_MESH", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_WORLD_SPACE", + "type": "boolean", + "defines": [] + }, + { + "name": "OUTPUT_TO_GAMMA", + "type": "boolean", + "defines": [] + } + ], + "blocks": [ + { + "name": "Constants", + "binding": 0, + "members": [ + { + "name": "mainTiling_Offset", + "type": 16, + "count": 1 + }, + { + "name": "frameTile_velLenScale", + "type": 16, + "count": 1 + }, + { + "name": "scale", + "type": 16, + "count": 1 + } + ], + "defines": [] + }, + { + "name": "FragConstants", + "binding": 1, + "members": [ + { + "name": "tintColor", + "type": 16, + "count": 1 + } + ], + "defines": [] + } + ], + "samplers": [ + { + "name": "mainTexture", + "type": 29, + "count": 1, + "binding": 30, + "defines": [] + } + ] + }, + { + "hash": 1851787849, + "record": null, + "name": "builtin-3d-particle|particle-vs-legacy:lpvs_main|no-tint-fs:addSmooth", + "glsl3": { + "vert": "\nprecision highp float;\nvec4 quaternionFromAxis(vec3 xAxis,vec3 yAxis,vec3 zAxis){\n mat3 m = mat3(xAxis,yAxis,zAxis);\n float trace = m[0][0] + m[1][1] + m[2][2];\n vec4 quat;\n if (trace > 0.) {\n float s = 0.5 / sqrt(trace + 1.0);\n quat.w = 0.25 / s;\n quat.x = (m[2][1] - m[1][2]) * s;\n quat.y = (m[0][2] - m[2][0]) * s;\n quat.z = (m[1][0] - m[0][1]) * s;\n } else if ((m[0][0] > m[1][1]) && (m[0][0] > m[2][2])) {\n float s = 2.0 * sqrt(1.0 + m[0][0] - m[1][1] - m[2][2]);\n quat.w = (m[2][1] - m[1][2]) / s;\n quat.x = 0.25 * s;\n quat.y = (m[0][1] + m[1][0]) / s;\n quat.z = (m[0][2] + m[2][0]) / s;\n } else if (m[1][1] > m[2][2]) {\n float s = 2.0 * sqrt(1.0 + m[1][1] - m[0][0] - m[2][2]);\n quat.w = (m[0][2] - m[2][0]) / s;\n quat.x = (m[0][1] + m[1][0]) / s;\n quat.y = 0.25 * s;\n quat.z = (m[1][2] + m[2][1]) / s;\n } else {\n float s = 2.0 * sqrt(1.0 + m[2][2] - m[0][0] - m[1][1]);\n quat.w = (m[1][0] - m[0][1]) / s;\n quat.x = (m[0][2] + m[2][0]) / s;\n quat.y = (m[1][2] + m[2][1]) / s;\n quat.z = 0.25 * s;\n }\n float len = quat.x * quat.x + quat.y * quat.y + quat.z * quat.z + quat.w * quat.w;\n if (len > 0.) {\n len = 1. / sqrt(len);\n quat.x = quat.x * len;\n quat.y = quat.y * len;\n quat.z = quat.z * len;\n quat.w = quat.w * len;\n }\n return quat;\n}\nvec4 quaternionFromEuler(vec3 angle){\n float x = angle.x / 2.;\n float y = angle.y / 2.;\n float z = angle.z / 2.;\n float sx = sin(x);\n float cx = cos(x);\n float sy = sin(y);\n float cy = cos(y);\n float sz = sin(z);\n float cz = cos(z);\n vec4 quat = vec4(0);\n quat.x = sx * cy * cz + cx * sy * sz;\n quat.y = cx * sy * cz + sx * cy * sz;\n quat.z = cx * cy * sz - sx * sy * cz;\n quat.w = cx * cy * cz - sx * sy * sz;\n return quat;\n}\nmat4 matrixFromRT(vec4 q, vec3 p){\n float x2 = q.x + q.x;\n float y2 = q.y + q.y;\n float z2 = q.z + q.z;\n float xx = q.x * x2;\n float xy = q.x * y2;\n float xz = q.x * z2;\n float yy = q.y * y2;\n float yz = q.y * z2;\n float zz = q.z * z2;\n float wx = q.w * x2;\n float wy = q.w * y2;\n float wz = q.w * z2;\n return mat4(\n 1. - (yy + zz), xy + wz, xz - wy, 0,\n xy - wz, 1. - (xx + zz), yz + wx, 0,\n xz + wy, yz - wx, 1. - (xx + yy), 0,\n p.x, p.y, p.z, 1\n );\n}\nmat4 matFromRTS(vec4 q, vec3 t, vec3 s){\n float x = q.x, y = q.y, z = q.z, w = q.w;\n float x2 = x + x;\n float y2 = y + y;\n float z2 = z + z;\n float xx = x * x2;\n float xy = x * y2;\n float xz = x * z2;\n float yy = y * y2;\n float yz = y * z2;\n float zz = z * z2;\n float wx = w * x2;\n float wy = w * y2;\n float wz = w * z2;\n float sx = s.x;\n float sy = s.y;\n float sz = s.z;\n return mat4((1. - (yy + zz)) * sx, (xy + wz) * sx, (xz - wy) * sx, 0,\n (xy - wz) * sy, (1. - (xx + zz)) * sy, (yz + wx) * sy, 0,\n (xz + wy) * sz, (yz - wx) * sz, (1. - (xx + yy)) * sz, 0,\n t.x, t.y, t.z, 1);\n}\nvec4 quatMultiply(vec4 a, vec4 b){\n vec4 quat;\n quat.x = a.x * b.w + a.w * b.x + a.y * b.z - a.z * b.y;\n quat.y = a.y * b.w + a.w * b.y + a.z * b.x - a.x * b.z;\n quat.z = a.z * b.w + a.w * b.z + a.x * b.y - a.y * b.x;\n quat.w = a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z;\n return quat;\n}\nvoid rotateVecFromQuat(inout vec3 v, vec4 q){\n float ix = q.w * v.x + q.y * v.z - q.z * v.y;\n float iy = q.w * v.y + q.z * v.x - q.x * v.z;\n float iz = q.w * v.z + q.x * v.y - q.y * v.x;\n float iw = -q.x * v.x - q.y * v.y - q.z * v.z;\n v.x = ix * q.w + iw * -q.x + iy * -q.z - iz * -q.y;\n v.y = iy * q.w + iw * -q.y + iz * -q.x - ix * -q.z;\n v.z = iz * q.w + iw * -q.z + ix * -q.y - iy * -q.x;\n}\nvec3 rotateInLocalSpace(vec3 pos, vec3 xAxis, vec3 yAxis, vec3 zAxis, vec4 q){\n float z = pos.z;\n float x = pos.x;\n float y = pos.y;\n vec4 viewQuat = quaternionFromAxis(xAxis, yAxis, zAxis);\n vec4 rotQuat = quatMultiply(viewQuat, q);\n rotateVecFromQuat(pos, rotQuat);\n return pos;\n}\nvoid rotateCorner(inout vec2 corner, float angle){\n float xOS = cos(angle) * corner.x - sin(angle) * corner.y;\n float yOS = sin(angle) * corner.x + cos(angle) * corner.y;\n corner.x = xOS;\n corner.y = yOS;\n}\nuniform Constants{\n vec4 mainTiling_Offset;\n vec4 frameTile_velLenScale;\n vec4 scale;\n};\nuniform CCGlobal {\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\nuniform CCLocal {\n mat4 cc_matWorld;\n mat4 cc_matWorldIT;\n};\nout vec2 uv;\nout vec4 color;\nvoid computeVertPos(inout vec4 pos, vec2 vertOffset, vec4 q, vec3 s\n#if CC_USE_BILLBOARD || CC_USE_VERTICAL_BILLBOARD\n , mat4 viewInv\n#endif\n#if CC_USE_STRETCHED_BILLBOARD\n , vec3 eye\n , vec4 velocity\n , float velocityScale\n , float lengthScale\n , float xIndex\n#endif\n) {\n#if CC_USE_BILLBOARD\n vec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\n vec3 camX = normalize(vec3(viewInv[0][0], viewInv[1][0], viewInv[2][0]));\n vec3 camY = normalize(vec3(viewInv[0][1], viewInv[1][1], viewInv[2][1]));\n vec3 camZ = normalize(vec3(viewInv[0][2], viewInv[1][2], viewInv[2][2]));\n pos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, camZ, q);\n#elif CC_USE_STRETCHED_BILLBOARD\n vec3 camRight = normalize(cross(pos.xyz - eye, velocity.xyz)) * s.x;\n vec3 camUp = velocity.xyz * velocityScale + normalize(velocity.xyz) * lengthScale * s.y;\n pos.xyz += (camRight * abs(vertOffset.x) * sign(vertOffset.y)) - camUp * xIndex;\n#elif CC_USE_HORIZONTAL_BILLBOARD\n vec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\n vec3 camX = vec3(1, 0, 0);\n vec3 camY = vec3(0, 0, -1);\n pos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, cross(camX, camY), q);\n#elif CC_USE_VERTICAL_BILLBOARD\n vec2 viewSpaceVert = vec2(vertOffset.x * s.x, vertOffset.y * s.y);\n rotateCorner(viewSpaceVert, q.z);\n vec3 camX = normalize(vec3(cc_matView[0][0], cc_matView[1][0], cc_matView[2][0]));\n vec3 camY = vec3(0, 1, 0);\n vec3 offset = camX * viewSpaceVert.x + camY * viewSpaceVert.y;\n pos.xyz += offset;\n#else\n pos.x += vertOffset.x;\n pos.y += vertOffset.y;\n#endif\n}\nvec2 computeUV(float frameIndex, vec2 vertIndex, vec2 frameTile){\n vec2 aniUV = vec2(0, floor(frameIndex * frameTile.y));\n aniUV.x = floor(frameIndex * frameTile.x * frameTile.y - aniUV.y * frameTile.x);\n#if !CC_USE_MESH\n vertIndex.y = 1. - vertIndex.y;\n#endif\n return (aniUV.xy + vertIndex) / vec2(frameTile.x, frameTile.y);\n}\nin vec3 a_position;\nin vec3 a_texCoord;\nin vec3 a_texCoord1;\nin vec3 a_texCoord2;\nin vec4 a_color;\n#if CC_USE_STRETCHED_BILLBOARD\n in vec3 a_color1;\n#endif\n#if CC_USE_MESH\n in vec3 a_texCoord3;\n in vec3 a_normal;\n in vec4 a_color1;\n#endif\nvec4 lpvs_main() {\n vec3 compScale = scale.xyz * a_texCoord1;\n vec4 pos = vec4(a_position, 1);\n#if CC_USE_STRETCHED_BILLBOARD\n vec4 velocity = vec4(a_color1.xyz, 0);\n#endif\n#if !CC_USE_WORLD_SPACE\n pos = cc_matWorld * pos;\n #if CC_USE_STRETCHED_BILLBOARD\n velocity = cc_matWorld * velocity;\n #endif\n#endif\n#if !CC_USE_MESH\n vec2 cornerOffset = vec2((a_texCoord.xy - 0.5));\n #if CC_USE_BILLBOARD\n vec3 rotEuler = a_texCoord2;\n #elif CC_USE_STRETCHED_BILLBOARD\n vec3 rotEuler = vec3(0.);\n #else\n vec3 rotEuler = vec3(0., 0., a_texCoord2.z);\n #endif\n computeVertPos(pos, cornerOffset, quaternionFromEuler(rotEuler), compScale\n #if CC_USE_BILLBOARD || CC_USE_VERTICAL_BILLBOARD\n , cc_matViewInv\n #endif\n #if CC_USE_STRETCHED_BILLBOARD\n , cc_cameraPos.xyz\n , velocity\n , frameTile_velLenScale.z\n , frameTile_velLenScale.w\n , a_texCoord.x\n #endif\n );\n color = a_color;\n#else\n mat4 xformNoScale = matrixFromRT(quaternionFromEuler(a_texCoord2), pos.xyz);\n mat4 xform = matFromRTS(quaternionFromEuler(a_texCoord2), pos.xyz, compScale);\n pos = xform * vec4(a_texCoord3, 1);\n vec4 normal = xformNoScale * vec4(a_normal, 0);\n color = a_color * a_color1;\n#endif\n uv = computeUV(a_texCoord.z, a_texCoord.xy, frameTile_velLenScale.xy) * mainTiling_Offset.xy + mainTiling_Offset.zw;\n pos = cc_matViewProj * pos;\n return pos;\n}\nvoid main() { gl_Position = lpvs_main(); }", + "frag": "\nprecision highp float;\nvec4 CCFragOutput (vec4 color) {\n #if OUTPUT_TO_GAMMA\n color.rgb = sqrt(color.rgb);\n #endif\n\treturn color;\n}\nin vec2 uv;\nin vec4 color;\nuniform sampler2D mainTexture;\nvec4 addSmooth () {\n vec4 col = color * texture(mainTexture, uv);\n col.rgb *= col.a;\n return CCFragOutput(col);\n}\nout vec4 cc_FragColor;\nvoid main() { cc_FragColor = addSmooth(); }" + }, + "glsl1": { + "vert": "\nprecision highp float;\nvec4 quaternionFromAxis(vec3 xAxis,vec3 yAxis,vec3 zAxis){\n mat3 m = mat3(xAxis,yAxis,zAxis);\n float trace = m[0][0] + m[1][1] + m[2][2];\n vec4 quat;\n if (trace > 0.) {\n float s = 0.5 / sqrt(trace + 1.0);\n quat.w = 0.25 / s;\n quat.x = (m[2][1] - m[1][2]) * s;\n quat.y = (m[0][2] - m[2][0]) * s;\n quat.z = (m[1][0] - m[0][1]) * s;\n } else if ((m[0][0] > m[1][1]) && (m[0][0] > m[2][2])) {\n float s = 2.0 * sqrt(1.0 + m[0][0] - m[1][1] - m[2][2]);\n quat.w = (m[2][1] - m[1][2]) / s;\n quat.x = 0.25 * s;\n quat.y = (m[0][1] + m[1][0]) / s;\n quat.z = (m[0][2] + m[2][0]) / s;\n } else if (m[1][1] > m[2][2]) {\n float s = 2.0 * sqrt(1.0 + m[1][1] - m[0][0] - m[2][2]);\n quat.w = (m[0][2] - m[2][0]) / s;\n quat.x = (m[0][1] + m[1][0]) / s;\n quat.y = 0.25 * s;\n quat.z = (m[1][2] + m[2][1]) / s;\n } else {\n float s = 2.0 * sqrt(1.0 + m[2][2] - m[0][0] - m[1][1]);\n quat.w = (m[1][0] - m[0][1]) / s;\n quat.x = (m[0][2] + m[2][0]) / s;\n quat.y = (m[1][2] + m[2][1]) / s;\n quat.z = 0.25 * s;\n }\n float len = quat.x * quat.x + quat.y * quat.y + quat.z * quat.z + quat.w * quat.w;\n if (len > 0.) {\n len = 1. / sqrt(len);\n quat.x = quat.x * len;\n quat.y = quat.y * len;\n quat.z = quat.z * len;\n quat.w = quat.w * len;\n }\n return quat;\n}\nvec4 quaternionFromEuler(vec3 angle){\n float x = angle.x / 2.;\n float y = angle.y / 2.;\n float z = angle.z / 2.;\n float sx = sin(x);\n float cx = cos(x);\n float sy = sin(y);\n float cy = cos(y);\n float sz = sin(z);\n float cz = cos(z);\n vec4 quat = vec4(0);\n quat.x = sx * cy * cz + cx * sy * sz;\n quat.y = cx * sy * cz + sx * cy * sz;\n quat.z = cx * cy * sz - sx * sy * cz;\n quat.w = cx * cy * cz - sx * sy * sz;\n return quat;\n}\nmat4 matrixFromRT(vec4 q, vec3 p){\n float x2 = q.x + q.x;\n float y2 = q.y + q.y;\n float z2 = q.z + q.z;\n float xx = q.x * x2;\n float xy = q.x * y2;\n float xz = q.x * z2;\n float yy = q.y * y2;\n float yz = q.y * z2;\n float zz = q.z * z2;\n float wx = q.w * x2;\n float wy = q.w * y2;\n float wz = q.w * z2;\n return mat4(\n 1. - (yy + zz), xy + wz, xz - wy, 0,\n xy - wz, 1. - (xx + zz), yz + wx, 0,\n xz + wy, yz - wx, 1. - (xx + yy), 0,\n p.x, p.y, p.z, 1\n );\n}\nmat4 matFromRTS(vec4 q, vec3 t, vec3 s){\n float x = q.x, y = q.y, z = q.z, w = q.w;\n float x2 = x + x;\n float y2 = y + y;\n float z2 = z + z;\n float xx = x * x2;\n float xy = x * y2;\n float xz = x * z2;\n float yy = y * y2;\n float yz = y * z2;\n float zz = z * z2;\n float wx = w * x2;\n float wy = w * y2;\n float wz = w * z2;\n float sx = s.x;\n float sy = s.y;\n float sz = s.z;\n return mat4((1. - (yy + zz)) * sx, (xy + wz) * sx, (xz - wy) * sx, 0,\n (xy - wz) * sy, (1. - (xx + zz)) * sy, (yz + wx) * sy, 0,\n (xz + wy) * sz, (yz - wx) * sz, (1. - (xx + yy)) * sz, 0,\n t.x, t.y, t.z, 1);\n}\nvec4 quatMultiply(vec4 a, vec4 b){\n vec4 quat;\n quat.x = a.x * b.w + a.w * b.x + a.y * b.z - a.z * b.y;\n quat.y = a.y * b.w + a.w * b.y + a.z * b.x - a.x * b.z;\n quat.z = a.z * b.w + a.w * b.z + a.x * b.y - a.y * b.x;\n quat.w = a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z;\n return quat;\n}\nvoid rotateVecFromQuat(inout vec3 v, vec4 q){\n float ix = q.w * v.x + q.y * v.z - q.z * v.y;\n float iy = q.w * v.y + q.z * v.x - q.x * v.z;\n float iz = q.w * v.z + q.x * v.y - q.y * v.x;\n float iw = -q.x * v.x - q.y * v.y - q.z * v.z;\n v.x = ix * q.w + iw * -q.x + iy * -q.z - iz * -q.y;\n v.y = iy * q.w + iw * -q.y + iz * -q.x - ix * -q.z;\n v.z = iz * q.w + iw * -q.z + ix * -q.y - iy * -q.x;\n}\nvec3 rotateInLocalSpace(vec3 pos, vec3 xAxis, vec3 yAxis, vec3 zAxis, vec4 q){\n float z = pos.z;\n float x = pos.x;\n float y = pos.y;\n vec4 viewQuat = quaternionFromAxis(xAxis, yAxis, zAxis);\n vec4 rotQuat = quatMultiply(viewQuat, q);\n rotateVecFromQuat(pos, rotQuat);\n return pos;\n}\nvoid rotateCorner(inout vec2 corner, float angle){\n float xOS = cos(angle) * corner.x - sin(angle) * corner.y;\n float yOS = sin(angle) * corner.x + cos(angle) * corner.y;\n corner.x = xOS;\n corner.y = yOS;\n}\nuniform vec4 mainTiling_Offset;\nuniform vec4 frameTile_velLenScale;\nuniform vec4 scale;\nuniform mat4 cc_matView;\nuniform mat4 cc_matViewInv;\nuniform mat4 cc_matViewProj;\nuniform vec4 cc_cameraPos;\nuniform mat4 cc_matWorld;\nvarying vec2 uv;\nvarying vec4 color;\nvoid computeVertPos(inout vec4 pos, vec2 vertOffset, vec4 q, vec3 s\n#if CC_USE_BILLBOARD || CC_USE_VERTICAL_BILLBOARD\n , mat4 viewInv\n#endif\n#if CC_USE_STRETCHED_BILLBOARD\n , vec3 eye\n , vec4 velocity\n , float velocityScale\n , float lengthScale\n , float xIndex\n#endif\n) {\n#if CC_USE_BILLBOARD\n vec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\n vec3 camX = normalize(vec3(viewInv[0][0], viewInv[1][0], viewInv[2][0]));\n vec3 camY = normalize(vec3(viewInv[0][1], viewInv[1][1], viewInv[2][1]));\n vec3 camZ = normalize(vec3(viewInv[0][2], viewInv[1][2], viewInv[2][2]));\n pos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, camZ, q);\n#elif CC_USE_STRETCHED_BILLBOARD\n vec3 camRight = normalize(cross(pos.xyz - eye, velocity.xyz)) * s.x;\n vec3 camUp = velocity.xyz * velocityScale + normalize(velocity.xyz) * lengthScale * s.y;\n pos.xyz += (camRight * abs(vertOffset.x) * sign(vertOffset.y)) - camUp * xIndex;\n#elif CC_USE_HORIZONTAL_BILLBOARD\n vec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\n vec3 camX = vec3(1, 0, 0);\n vec3 camY = vec3(0, 0, -1);\n pos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, cross(camX, camY), q);\n#elif CC_USE_VERTICAL_BILLBOARD\n vec2 viewSpaceVert = vec2(vertOffset.x * s.x, vertOffset.y * s.y);\n rotateCorner(viewSpaceVert, q.z);\n vec3 camX = normalize(vec3(cc_matView[0][0], cc_matView[1][0], cc_matView[2][0]));\n vec3 camY = vec3(0, 1, 0);\n vec3 offset = camX * viewSpaceVert.x + camY * viewSpaceVert.y;\n pos.xyz += offset;\n#else\n pos.x += vertOffset.x;\n pos.y += vertOffset.y;\n#endif\n}\nvec2 computeUV(float frameIndex, vec2 vertIndex, vec2 frameTile){\n vec2 aniUV = vec2(0, floor(frameIndex * frameTile.y));\n aniUV.x = floor(frameIndex * frameTile.x * frameTile.y - aniUV.y * frameTile.x);\n#if !CC_USE_MESH\n vertIndex.y = 1. - vertIndex.y;\n#endif\n return (aniUV.xy + vertIndex) / vec2(frameTile.x, frameTile.y);\n}\nattribute vec3 a_position;\nattribute vec3 a_texCoord;\nattribute vec3 a_texCoord1;\nattribute vec3 a_texCoord2;\nattribute vec4 a_color;\n#if CC_USE_STRETCHED_BILLBOARD\n attribute vec3 a_color1;\n#endif\n#if CC_USE_MESH\n attribute vec3 a_texCoord3;\n attribute vec3 a_normal;\n attribute vec4 a_color1;\n#endif\nvec4 lpvs_main() {\n vec3 compScale = scale.xyz * a_texCoord1;\n vec4 pos = vec4(a_position, 1);\n#if CC_USE_STRETCHED_BILLBOARD\n vec4 velocity = vec4(a_color1.xyz, 0);\n#endif\n#if !CC_USE_WORLD_SPACE\n pos = cc_matWorld * pos;\n #if CC_USE_STRETCHED_BILLBOARD\n velocity = cc_matWorld * velocity;\n #endif\n#endif\n#if !CC_USE_MESH\n vec2 cornerOffset = vec2((a_texCoord.xy - 0.5));\n #if CC_USE_BILLBOARD\n vec3 rotEuler = a_texCoord2;\n #elif CC_USE_STRETCHED_BILLBOARD\n vec3 rotEuler = vec3(0.);\n #else\n vec3 rotEuler = vec3(0., 0., a_texCoord2.z);\n #endif\n computeVertPos(pos, cornerOffset, quaternionFromEuler(rotEuler), compScale\n #if CC_USE_BILLBOARD || CC_USE_VERTICAL_BILLBOARD\n , cc_matViewInv\n #endif\n #if CC_USE_STRETCHED_BILLBOARD\n , cc_cameraPos.xyz\n , velocity\n , frameTile_velLenScale.z\n , frameTile_velLenScale.w\n , a_texCoord.x\n #endif\n );\n color = a_color;\n#else\n mat4 xformNoScale = matrixFromRT(quaternionFromEuler(a_texCoord2), pos.xyz);\n mat4 xform = matFromRTS(quaternionFromEuler(a_texCoord2), pos.xyz, compScale);\n pos = xform * vec4(a_texCoord3, 1);\n vec4 normal = xformNoScale * vec4(a_normal, 0);\n color = a_color * a_color1;\n#endif\n uv = computeUV(a_texCoord.z, a_texCoord.xy, frameTile_velLenScale.xy) * mainTiling_Offset.xy + mainTiling_Offset.zw;\n pos = cc_matViewProj * pos;\n return pos;\n}\nvoid main() { gl_Position = lpvs_main(); }", + "frag": "\nprecision highp float;\nvec4 CCFragOutput (vec4 color) {\n #if OUTPUT_TO_GAMMA\n color.rgb = sqrt(color.rgb);\n #endif\n\treturn color;\n}\nvarying vec2 uv;\nvarying vec4 color;\nuniform sampler2D mainTexture;\nvec4 addSmooth () {\n vec4 col = color * texture2D(mainTexture, uv);\n col.rgb *= col.a;\n return CCFragOutput(col);\n}\nvoid main() { gl_FragColor = addSmooth(); }" + }, + "builtins": { + "globals": { + "blocks": [ + { + "name": "CCGlobal", + "defines": [] + } + ], + "samplers": [] + }, + "locals": { + "blocks": [ + { + "name": "CCLocal", + "defines": [] + } + ], + "samplers": [] + } + }, + "defines": [ + { + "name": "CC_USE_BILLBOARD", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_STRETCHED_BILLBOARD", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_HORIZONTAL_BILLBOARD", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_VERTICAL_BILLBOARD", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_MESH", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_WORLD_SPACE", + "type": "boolean", + "defines": [] + }, + { + "name": "OUTPUT_TO_GAMMA", + "type": "boolean", + "defines": [] + } + ], + "blocks": [ + { + "name": "Constants", + "binding": 0, + "members": [ + { + "name": "mainTiling_Offset", + "type": 16, + "count": 1 + }, + { + "name": "frameTile_velLenScale", + "type": 16, + "count": 1 + }, + { + "name": "scale", + "type": 16, + "count": 1 + } + ], + "defines": [] + } + ], + "samplers": [ + { + "name": "mainTexture", + "type": 29, + "count": 1, + "binding": 30, + "defines": [] + } + ] + }, + { + "hash": 145387972, + "record": null, + "name": "builtin-3d-particle|particle-vs-legacy:lpvs_main|no-tint-fs:premultiplied", + "glsl3": { + "vert": "\nprecision highp float;\nvec4 quaternionFromAxis(vec3 xAxis,vec3 yAxis,vec3 zAxis){\n mat3 m = mat3(xAxis,yAxis,zAxis);\n float trace = m[0][0] + m[1][1] + m[2][2];\n vec4 quat;\n if (trace > 0.) {\n float s = 0.5 / sqrt(trace + 1.0);\n quat.w = 0.25 / s;\n quat.x = (m[2][1] - m[1][2]) * s;\n quat.y = (m[0][2] - m[2][0]) * s;\n quat.z = (m[1][0] - m[0][1]) * s;\n } else if ((m[0][0] > m[1][1]) && (m[0][0] > m[2][2])) {\n float s = 2.0 * sqrt(1.0 + m[0][0] - m[1][1] - m[2][2]);\n quat.w = (m[2][1] - m[1][2]) / s;\n quat.x = 0.25 * s;\n quat.y = (m[0][1] + m[1][0]) / s;\n quat.z = (m[0][2] + m[2][0]) / s;\n } else if (m[1][1] > m[2][2]) {\n float s = 2.0 * sqrt(1.0 + m[1][1] - m[0][0] - m[2][2]);\n quat.w = (m[0][2] - m[2][0]) / s;\n quat.x = (m[0][1] + m[1][0]) / s;\n quat.y = 0.25 * s;\n quat.z = (m[1][2] + m[2][1]) / s;\n } else {\n float s = 2.0 * sqrt(1.0 + m[2][2] - m[0][0] - m[1][1]);\n quat.w = (m[1][0] - m[0][1]) / s;\n quat.x = (m[0][2] + m[2][0]) / s;\n quat.y = (m[1][2] + m[2][1]) / s;\n quat.z = 0.25 * s;\n }\n float len = quat.x * quat.x + quat.y * quat.y + quat.z * quat.z + quat.w * quat.w;\n if (len > 0.) {\n len = 1. / sqrt(len);\n quat.x = quat.x * len;\n quat.y = quat.y * len;\n quat.z = quat.z * len;\n quat.w = quat.w * len;\n }\n return quat;\n}\nvec4 quaternionFromEuler(vec3 angle){\n float x = angle.x / 2.;\n float y = angle.y / 2.;\n float z = angle.z / 2.;\n float sx = sin(x);\n float cx = cos(x);\n float sy = sin(y);\n float cy = cos(y);\n float sz = sin(z);\n float cz = cos(z);\n vec4 quat = vec4(0);\n quat.x = sx * cy * cz + cx * sy * sz;\n quat.y = cx * sy * cz + sx * cy * sz;\n quat.z = cx * cy * sz - sx * sy * cz;\n quat.w = cx * cy * cz - sx * sy * sz;\n return quat;\n}\nmat4 matrixFromRT(vec4 q, vec3 p){\n float x2 = q.x + q.x;\n float y2 = q.y + q.y;\n float z2 = q.z + q.z;\n float xx = q.x * x2;\n float xy = q.x * y2;\n float xz = q.x * z2;\n float yy = q.y * y2;\n float yz = q.y * z2;\n float zz = q.z * z2;\n float wx = q.w * x2;\n float wy = q.w * y2;\n float wz = q.w * z2;\n return mat4(\n 1. - (yy + zz), xy + wz, xz - wy, 0,\n xy - wz, 1. - (xx + zz), yz + wx, 0,\n xz + wy, yz - wx, 1. - (xx + yy), 0,\n p.x, p.y, p.z, 1\n );\n}\nmat4 matFromRTS(vec4 q, vec3 t, vec3 s){\n float x = q.x, y = q.y, z = q.z, w = q.w;\n float x2 = x + x;\n float y2 = y + y;\n float z2 = z + z;\n float xx = x * x2;\n float xy = x * y2;\n float xz = x * z2;\n float yy = y * y2;\n float yz = y * z2;\n float zz = z * z2;\n float wx = w * x2;\n float wy = w * y2;\n float wz = w * z2;\n float sx = s.x;\n float sy = s.y;\n float sz = s.z;\n return mat4((1. - (yy + zz)) * sx, (xy + wz) * sx, (xz - wy) * sx, 0,\n (xy - wz) * sy, (1. - (xx + zz)) * sy, (yz + wx) * sy, 0,\n (xz + wy) * sz, (yz - wx) * sz, (1. - (xx + yy)) * sz, 0,\n t.x, t.y, t.z, 1);\n}\nvec4 quatMultiply(vec4 a, vec4 b){\n vec4 quat;\n quat.x = a.x * b.w + a.w * b.x + a.y * b.z - a.z * b.y;\n quat.y = a.y * b.w + a.w * b.y + a.z * b.x - a.x * b.z;\n quat.z = a.z * b.w + a.w * b.z + a.x * b.y - a.y * b.x;\n quat.w = a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z;\n return quat;\n}\nvoid rotateVecFromQuat(inout vec3 v, vec4 q){\n float ix = q.w * v.x + q.y * v.z - q.z * v.y;\n float iy = q.w * v.y + q.z * v.x - q.x * v.z;\n float iz = q.w * v.z + q.x * v.y - q.y * v.x;\n float iw = -q.x * v.x - q.y * v.y - q.z * v.z;\n v.x = ix * q.w + iw * -q.x + iy * -q.z - iz * -q.y;\n v.y = iy * q.w + iw * -q.y + iz * -q.x - ix * -q.z;\n v.z = iz * q.w + iw * -q.z + ix * -q.y - iy * -q.x;\n}\nvec3 rotateInLocalSpace(vec3 pos, vec3 xAxis, vec3 yAxis, vec3 zAxis, vec4 q){\n float z = pos.z;\n float x = pos.x;\n float y = pos.y;\n vec4 viewQuat = quaternionFromAxis(xAxis, yAxis, zAxis);\n vec4 rotQuat = quatMultiply(viewQuat, q);\n rotateVecFromQuat(pos, rotQuat);\n return pos;\n}\nvoid rotateCorner(inout vec2 corner, float angle){\n float xOS = cos(angle) * corner.x - sin(angle) * corner.y;\n float yOS = sin(angle) * corner.x + cos(angle) * corner.y;\n corner.x = xOS;\n corner.y = yOS;\n}\nuniform Constants{\n vec4 mainTiling_Offset;\n vec4 frameTile_velLenScale;\n vec4 scale;\n};\nuniform CCGlobal {\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\nuniform CCLocal {\n mat4 cc_matWorld;\n mat4 cc_matWorldIT;\n};\nout vec2 uv;\nout vec4 color;\nvoid computeVertPos(inout vec4 pos, vec2 vertOffset, vec4 q, vec3 s\n#if CC_USE_BILLBOARD || CC_USE_VERTICAL_BILLBOARD\n , mat4 viewInv\n#endif\n#if CC_USE_STRETCHED_BILLBOARD\n , vec3 eye\n , vec4 velocity\n , float velocityScale\n , float lengthScale\n , float xIndex\n#endif\n) {\n#if CC_USE_BILLBOARD\n vec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\n vec3 camX = normalize(vec3(viewInv[0][0], viewInv[1][0], viewInv[2][0]));\n vec3 camY = normalize(vec3(viewInv[0][1], viewInv[1][1], viewInv[2][1]));\n vec3 camZ = normalize(vec3(viewInv[0][2], viewInv[1][2], viewInv[2][2]));\n pos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, camZ, q);\n#elif CC_USE_STRETCHED_BILLBOARD\n vec3 camRight = normalize(cross(pos.xyz - eye, velocity.xyz)) * s.x;\n vec3 camUp = velocity.xyz * velocityScale + normalize(velocity.xyz) * lengthScale * s.y;\n pos.xyz += (camRight * abs(vertOffset.x) * sign(vertOffset.y)) - camUp * xIndex;\n#elif CC_USE_HORIZONTAL_BILLBOARD\n vec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\n vec3 camX = vec3(1, 0, 0);\n vec3 camY = vec3(0, 0, -1);\n pos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, cross(camX, camY), q);\n#elif CC_USE_VERTICAL_BILLBOARD\n vec2 viewSpaceVert = vec2(vertOffset.x * s.x, vertOffset.y * s.y);\n rotateCorner(viewSpaceVert, q.z);\n vec3 camX = normalize(vec3(cc_matView[0][0], cc_matView[1][0], cc_matView[2][0]));\n vec3 camY = vec3(0, 1, 0);\n vec3 offset = camX * viewSpaceVert.x + camY * viewSpaceVert.y;\n pos.xyz += offset;\n#else\n pos.x += vertOffset.x;\n pos.y += vertOffset.y;\n#endif\n}\nvec2 computeUV(float frameIndex, vec2 vertIndex, vec2 frameTile){\n vec2 aniUV = vec2(0, floor(frameIndex * frameTile.y));\n aniUV.x = floor(frameIndex * frameTile.x * frameTile.y - aniUV.y * frameTile.x);\n#if !CC_USE_MESH\n vertIndex.y = 1. - vertIndex.y;\n#endif\n return (aniUV.xy + vertIndex) / vec2(frameTile.x, frameTile.y);\n}\nin vec3 a_position;\nin vec3 a_texCoord;\nin vec3 a_texCoord1;\nin vec3 a_texCoord2;\nin vec4 a_color;\n#if CC_USE_STRETCHED_BILLBOARD\n in vec3 a_color1;\n#endif\n#if CC_USE_MESH\n in vec3 a_texCoord3;\n in vec3 a_normal;\n in vec4 a_color1;\n#endif\nvec4 lpvs_main() {\n vec3 compScale = scale.xyz * a_texCoord1;\n vec4 pos = vec4(a_position, 1);\n#if CC_USE_STRETCHED_BILLBOARD\n vec4 velocity = vec4(a_color1.xyz, 0);\n#endif\n#if !CC_USE_WORLD_SPACE\n pos = cc_matWorld * pos;\n #if CC_USE_STRETCHED_BILLBOARD\n velocity = cc_matWorld * velocity;\n #endif\n#endif\n#if !CC_USE_MESH\n vec2 cornerOffset = vec2((a_texCoord.xy - 0.5));\n #if CC_USE_BILLBOARD\n vec3 rotEuler = a_texCoord2;\n #elif CC_USE_STRETCHED_BILLBOARD\n vec3 rotEuler = vec3(0.);\n #else\n vec3 rotEuler = vec3(0., 0., a_texCoord2.z);\n #endif\n computeVertPos(pos, cornerOffset, quaternionFromEuler(rotEuler), compScale\n #if CC_USE_BILLBOARD || CC_USE_VERTICAL_BILLBOARD\n , cc_matViewInv\n #endif\n #if CC_USE_STRETCHED_BILLBOARD\n , cc_cameraPos.xyz\n , velocity\n , frameTile_velLenScale.z\n , frameTile_velLenScale.w\n , a_texCoord.x\n #endif\n );\n color = a_color;\n#else\n mat4 xformNoScale = matrixFromRT(quaternionFromEuler(a_texCoord2), pos.xyz);\n mat4 xform = matFromRTS(quaternionFromEuler(a_texCoord2), pos.xyz, compScale);\n pos = xform * vec4(a_texCoord3, 1);\n vec4 normal = xformNoScale * vec4(a_normal, 0);\n color = a_color * a_color1;\n#endif\n uv = computeUV(a_texCoord.z, a_texCoord.xy, frameTile_velLenScale.xy) * mainTiling_Offset.xy + mainTiling_Offset.zw;\n pos = cc_matViewProj * pos;\n return pos;\n}\nvoid main() { gl_Position = lpvs_main(); }", + "frag": "\nprecision highp float;\nvec4 CCFragOutput (vec4 color) {\n #if OUTPUT_TO_GAMMA\n color.rgb = sqrt(color.rgb);\n #endif\n\treturn color;\n}\nin vec2 uv;\nin vec4 color;\nuniform sampler2D mainTexture;\nvec4 premultiplied () {\n vec4 col = color * texture(mainTexture, uv) * color.a;\n return CCFragOutput(col);\n}\nout vec4 cc_FragColor;\nvoid main() { cc_FragColor = premultiplied(); }" + }, + "glsl1": { + "vert": "\nprecision highp float;\nvec4 quaternionFromAxis(vec3 xAxis,vec3 yAxis,vec3 zAxis){\n mat3 m = mat3(xAxis,yAxis,zAxis);\n float trace = m[0][0] + m[1][1] + m[2][2];\n vec4 quat;\n if (trace > 0.) {\n float s = 0.5 / sqrt(trace + 1.0);\n quat.w = 0.25 / s;\n quat.x = (m[2][1] - m[1][2]) * s;\n quat.y = (m[0][2] - m[2][0]) * s;\n quat.z = (m[1][0] - m[0][1]) * s;\n } else if ((m[0][0] > m[1][1]) && (m[0][0] > m[2][2])) {\n float s = 2.0 * sqrt(1.0 + m[0][0] - m[1][1] - m[2][2]);\n quat.w = (m[2][1] - m[1][2]) / s;\n quat.x = 0.25 * s;\n quat.y = (m[0][1] + m[1][0]) / s;\n quat.z = (m[0][2] + m[2][0]) / s;\n } else if (m[1][1] > m[2][2]) {\n float s = 2.0 * sqrt(1.0 + m[1][1] - m[0][0] - m[2][2]);\n quat.w = (m[0][2] - m[2][0]) / s;\n quat.x = (m[0][1] + m[1][0]) / s;\n quat.y = 0.25 * s;\n quat.z = (m[1][2] + m[2][1]) / s;\n } else {\n float s = 2.0 * sqrt(1.0 + m[2][2] - m[0][0] - m[1][1]);\n quat.w = (m[1][0] - m[0][1]) / s;\n quat.x = (m[0][2] + m[2][0]) / s;\n quat.y = (m[1][2] + m[2][1]) / s;\n quat.z = 0.25 * s;\n }\n float len = quat.x * quat.x + quat.y * quat.y + quat.z * quat.z + quat.w * quat.w;\n if (len > 0.) {\n len = 1. / sqrt(len);\n quat.x = quat.x * len;\n quat.y = quat.y * len;\n quat.z = quat.z * len;\n quat.w = quat.w * len;\n }\n return quat;\n}\nvec4 quaternionFromEuler(vec3 angle){\n float x = angle.x / 2.;\n float y = angle.y / 2.;\n float z = angle.z / 2.;\n float sx = sin(x);\n float cx = cos(x);\n float sy = sin(y);\n float cy = cos(y);\n float sz = sin(z);\n float cz = cos(z);\n vec4 quat = vec4(0);\n quat.x = sx * cy * cz + cx * sy * sz;\n quat.y = cx * sy * cz + sx * cy * sz;\n quat.z = cx * cy * sz - sx * sy * cz;\n quat.w = cx * cy * cz - sx * sy * sz;\n return quat;\n}\nmat4 matrixFromRT(vec4 q, vec3 p){\n float x2 = q.x + q.x;\n float y2 = q.y + q.y;\n float z2 = q.z + q.z;\n float xx = q.x * x2;\n float xy = q.x * y2;\n float xz = q.x * z2;\n float yy = q.y * y2;\n float yz = q.y * z2;\n float zz = q.z * z2;\n float wx = q.w * x2;\n float wy = q.w * y2;\n float wz = q.w * z2;\n return mat4(\n 1. - (yy + zz), xy + wz, xz - wy, 0,\n xy - wz, 1. - (xx + zz), yz + wx, 0,\n xz + wy, yz - wx, 1. - (xx + yy), 0,\n p.x, p.y, p.z, 1\n );\n}\nmat4 matFromRTS(vec4 q, vec3 t, vec3 s){\n float x = q.x, y = q.y, z = q.z, w = q.w;\n float x2 = x + x;\n float y2 = y + y;\n float z2 = z + z;\n float xx = x * x2;\n float xy = x * y2;\n float xz = x * z2;\n float yy = y * y2;\n float yz = y * z2;\n float zz = z * z2;\n float wx = w * x2;\n float wy = w * y2;\n float wz = w * z2;\n float sx = s.x;\n float sy = s.y;\n float sz = s.z;\n return mat4((1. - (yy + zz)) * sx, (xy + wz) * sx, (xz - wy) * sx, 0,\n (xy - wz) * sy, (1. - (xx + zz)) * sy, (yz + wx) * sy, 0,\n (xz + wy) * sz, (yz - wx) * sz, (1. - (xx + yy)) * sz, 0,\n t.x, t.y, t.z, 1);\n}\nvec4 quatMultiply(vec4 a, vec4 b){\n vec4 quat;\n quat.x = a.x * b.w + a.w * b.x + a.y * b.z - a.z * b.y;\n quat.y = a.y * b.w + a.w * b.y + a.z * b.x - a.x * b.z;\n quat.z = a.z * b.w + a.w * b.z + a.x * b.y - a.y * b.x;\n quat.w = a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z;\n return quat;\n}\nvoid rotateVecFromQuat(inout vec3 v, vec4 q){\n float ix = q.w * v.x + q.y * v.z - q.z * v.y;\n float iy = q.w * v.y + q.z * v.x - q.x * v.z;\n float iz = q.w * v.z + q.x * v.y - q.y * v.x;\n float iw = -q.x * v.x - q.y * v.y - q.z * v.z;\n v.x = ix * q.w + iw * -q.x + iy * -q.z - iz * -q.y;\n v.y = iy * q.w + iw * -q.y + iz * -q.x - ix * -q.z;\n v.z = iz * q.w + iw * -q.z + ix * -q.y - iy * -q.x;\n}\nvec3 rotateInLocalSpace(vec3 pos, vec3 xAxis, vec3 yAxis, vec3 zAxis, vec4 q){\n float z = pos.z;\n float x = pos.x;\n float y = pos.y;\n vec4 viewQuat = quaternionFromAxis(xAxis, yAxis, zAxis);\n vec4 rotQuat = quatMultiply(viewQuat, q);\n rotateVecFromQuat(pos, rotQuat);\n return pos;\n}\nvoid rotateCorner(inout vec2 corner, float angle){\n float xOS = cos(angle) * corner.x - sin(angle) * corner.y;\n float yOS = sin(angle) * corner.x + cos(angle) * corner.y;\n corner.x = xOS;\n corner.y = yOS;\n}\nuniform vec4 mainTiling_Offset;\nuniform vec4 frameTile_velLenScale;\nuniform vec4 scale;\nuniform mat4 cc_matView;\nuniform mat4 cc_matViewInv;\nuniform mat4 cc_matViewProj;\nuniform vec4 cc_cameraPos;\nuniform mat4 cc_matWorld;\nvarying vec2 uv;\nvarying vec4 color;\nvoid computeVertPos(inout vec4 pos, vec2 vertOffset, vec4 q, vec3 s\n#if CC_USE_BILLBOARD || CC_USE_VERTICAL_BILLBOARD\n , mat4 viewInv\n#endif\n#if CC_USE_STRETCHED_BILLBOARD\n , vec3 eye\n , vec4 velocity\n , float velocityScale\n , float lengthScale\n , float xIndex\n#endif\n) {\n#if CC_USE_BILLBOARD\n vec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\n vec3 camX = normalize(vec3(viewInv[0][0], viewInv[1][0], viewInv[2][0]));\n vec3 camY = normalize(vec3(viewInv[0][1], viewInv[1][1], viewInv[2][1]));\n vec3 camZ = normalize(vec3(viewInv[0][2], viewInv[1][2], viewInv[2][2]));\n pos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, camZ, q);\n#elif CC_USE_STRETCHED_BILLBOARD\n vec3 camRight = normalize(cross(pos.xyz - eye, velocity.xyz)) * s.x;\n vec3 camUp = velocity.xyz * velocityScale + normalize(velocity.xyz) * lengthScale * s.y;\n pos.xyz += (camRight * abs(vertOffset.x) * sign(vertOffset.y)) - camUp * xIndex;\n#elif CC_USE_HORIZONTAL_BILLBOARD\n vec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\n vec3 camX = vec3(1, 0, 0);\n vec3 camY = vec3(0, 0, -1);\n pos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, cross(camX, camY), q);\n#elif CC_USE_VERTICAL_BILLBOARD\n vec2 viewSpaceVert = vec2(vertOffset.x * s.x, vertOffset.y * s.y);\n rotateCorner(viewSpaceVert, q.z);\n vec3 camX = normalize(vec3(cc_matView[0][0], cc_matView[1][0], cc_matView[2][0]));\n vec3 camY = vec3(0, 1, 0);\n vec3 offset = camX * viewSpaceVert.x + camY * viewSpaceVert.y;\n pos.xyz += offset;\n#else\n pos.x += vertOffset.x;\n pos.y += vertOffset.y;\n#endif\n}\nvec2 computeUV(float frameIndex, vec2 vertIndex, vec2 frameTile){\n vec2 aniUV = vec2(0, floor(frameIndex * frameTile.y));\n aniUV.x = floor(frameIndex * frameTile.x * frameTile.y - aniUV.y * frameTile.x);\n#if !CC_USE_MESH\n vertIndex.y = 1. - vertIndex.y;\n#endif\n return (aniUV.xy + vertIndex) / vec2(frameTile.x, frameTile.y);\n}\nattribute vec3 a_position;\nattribute vec3 a_texCoord;\nattribute vec3 a_texCoord1;\nattribute vec3 a_texCoord2;\nattribute vec4 a_color;\n#if CC_USE_STRETCHED_BILLBOARD\n attribute vec3 a_color1;\n#endif\n#if CC_USE_MESH\n attribute vec3 a_texCoord3;\n attribute vec3 a_normal;\n attribute vec4 a_color1;\n#endif\nvec4 lpvs_main() {\n vec3 compScale = scale.xyz * a_texCoord1;\n vec4 pos = vec4(a_position, 1);\n#if CC_USE_STRETCHED_BILLBOARD\n vec4 velocity = vec4(a_color1.xyz, 0);\n#endif\n#if !CC_USE_WORLD_SPACE\n pos = cc_matWorld * pos;\n #if CC_USE_STRETCHED_BILLBOARD\n velocity = cc_matWorld * velocity;\n #endif\n#endif\n#if !CC_USE_MESH\n vec2 cornerOffset = vec2((a_texCoord.xy - 0.5));\n #if CC_USE_BILLBOARD\n vec3 rotEuler = a_texCoord2;\n #elif CC_USE_STRETCHED_BILLBOARD\n vec3 rotEuler = vec3(0.);\n #else\n vec3 rotEuler = vec3(0., 0., a_texCoord2.z);\n #endif\n computeVertPos(pos, cornerOffset, quaternionFromEuler(rotEuler), compScale\n #if CC_USE_BILLBOARD || CC_USE_VERTICAL_BILLBOARD\n , cc_matViewInv\n #endif\n #if CC_USE_STRETCHED_BILLBOARD\n , cc_cameraPos.xyz\n , velocity\n , frameTile_velLenScale.z\n , frameTile_velLenScale.w\n , a_texCoord.x\n #endif\n );\n color = a_color;\n#else\n mat4 xformNoScale = matrixFromRT(quaternionFromEuler(a_texCoord2), pos.xyz);\n mat4 xform = matFromRTS(quaternionFromEuler(a_texCoord2), pos.xyz, compScale);\n pos = xform * vec4(a_texCoord3, 1);\n vec4 normal = xformNoScale * vec4(a_normal, 0);\n color = a_color * a_color1;\n#endif\n uv = computeUV(a_texCoord.z, a_texCoord.xy, frameTile_velLenScale.xy) * mainTiling_Offset.xy + mainTiling_Offset.zw;\n pos = cc_matViewProj * pos;\n return pos;\n}\nvoid main() { gl_Position = lpvs_main(); }", + "frag": "\nprecision highp float;\nvec4 CCFragOutput (vec4 color) {\n #if OUTPUT_TO_GAMMA\n color.rgb = sqrt(color.rgb);\n #endif\n\treturn color;\n}\nvarying vec2 uv;\nvarying vec4 color;\nuniform sampler2D mainTexture;\nvec4 premultiplied () {\n vec4 col = color * texture2D(mainTexture, uv) * color.a;\n return CCFragOutput(col);\n}\nvoid main() { gl_FragColor = premultiplied(); }" + }, + "builtins": { + "globals": { + "blocks": [ + { + "name": "CCGlobal", + "defines": [] + } + ], + "samplers": [] + }, + "locals": { + "blocks": [ + { + "name": "CCLocal", + "defines": [] + } + ], + "samplers": [] + } + }, + "defines": [ + { + "name": "CC_USE_BILLBOARD", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_STRETCHED_BILLBOARD", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_HORIZONTAL_BILLBOARD", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_VERTICAL_BILLBOARD", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_MESH", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_WORLD_SPACE", + "type": "boolean", + "defines": [] + }, + { + "name": "OUTPUT_TO_GAMMA", + "type": "boolean", + "defines": [] + } + ], + "blocks": [ + { + "name": "Constants", + "binding": 0, + "members": [ + { + "name": "mainTiling_Offset", + "type": 16, + "count": 1 + }, + { + "name": "frameTile_velLenScale", + "type": 16, + "count": 1 + }, + { + "name": "scale", + "type": 16, + "count": 1 + } + ], + "defines": [] + } + ], + "samplers": [ + { + "name": "mainTexture", + "type": 29, + "count": 1, + "binding": 30, + "defines": [] + } + ] + } + ], + [ + { + "name": "opaque-add", + "passes": [ + { + "stage": "opaque", + "program": "builtin-3d-particle|particle-vs-legacy:lpvs_main|tinted-fs:add", + "rasterizerState": { + "cullMode": 0 + }, + "blendState": { + "targets": [ + { + "blend": true, + "blendSrc": 770, + "blendDst": 1, + "blendSrcAlpha": 770, + "blendDstAlpha": 1 + } + ] + }, + "depthStencilState": { + "depthTest": true, + "depthWrite": false + }, + "properties": { + "mainTexture": { + "value": "grey", + "type": 29 + }, + "mainTiling_Offset": { + "type": 16, + "value": [ + 1, + 1, + 0, + 0 + ] + }, + "tintColor": { + "type": 16, + "value": [ + 0.5, + 0.5, + 0.5, + 0.5 + ], + "inspector": { + "type": "color" + } + } + } + } + ] + }, + { + "name": "opaque-alpha-blend", + "passes": [ + { + "stage": "opaque", + "program": "builtin-3d-particle|particle-vs-legacy:lpvs_main|tinted-fs:add", + "rasterizerState": { + "cullMode": 0 + }, + "blendState": { + "targets": [ + { + "blend": true, + "blendSrc": 770, + "blendDst": 771, + "blendSrcAlpha": 770, + "blendDstAlpha": 771 + } + ] + }, + "depthStencilState": { + "depthTest": true, + "depthWrite": false + }, + "properties": { + "mainTexture": { + "value": "grey", + "type": 29 + }, + "mainTiling_Offset": { + "type": 16, + "value": [ + 1, + 1, + 0, + 0 + ] + }, + "tintColor": { + "type": 16, + "value": [ + 0.5, + 0.5, + 0.5, + 0.5 + ], + "inspector": { + "type": "color" + } + } + } + } + ] + }, + { + "name": "opaque-add-multiply", + "passes": [ + { + "stage": "opaque", + "program": "builtin-3d-particle|particle-vs-legacy:lpvs_main|tinted-fs:multiply", + "rasterizerState": { + "cullMode": 0 + }, + "blendState": { + "targets": [ + { + "blend": true, + "blendSrc": 770, + "blendDst": 771, + "blendSrcAlpha": 770, + "blendDstAlpha": 771 + } + ] + }, + "depthStencilState": { + "depthTest": true, + "depthWrite": false + }, + "properties": { + "mainTexture": { + "value": "grey", + "type": 29 + }, + "mainTiling_Offset": { + "type": 16, + "value": [ + 1, + 1, + 0, + 0 + ] + }, + "tintColor": { + "type": 16, + "value": [ + 0.5, + 0.5, + 0.5, + 0.5 + ], + "inspector": { + "type": "color" + } + } + } + } + ] + }, + { + "name": "opaque-add-smooth", + "passes": [ + { + "stage": "opaque", + "program": "builtin-3d-particle|particle-vs-legacy:lpvs_main|no-tint-fs:addSmooth", + "rasterizerState": { + "cullMode": 0 + }, + "blendState": { + "targets": [ + { + "blend": true, + "blendSrc": 770, + "blendDst": 771, + "blendSrcAlpha": 770, + "blendDstAlpha": 771 + } + ] + }, + "depthStencilState": { + "depthTest": true, + "depthWrite": false + }, + "properties": { + "mainTexture": { + "value": "grey", + "type": 29 + }, + "mainTiling_Offset": { + "type": 16, + "value": [ + 1, + 1, + 0, + 0 + ] + } + } + } + ] + }, + { + "name": "opaque-premultiply-blend", + "passes": [ + { + "stage": "opaque", + "program": "builtin-3d-particle|particle-vs-legacy:lpvs_main|no-tint-fs:premultiplied", + "rasterizerState": { + "cullMode": 0 + }, + "blendState": { + "targets": [ + { + "blend": true, + "blendSrc": 770, + "blendDst": 771, + "blendSrcAlpha": 770, + "blendDstAlpha": 771 + } + ] + }, + "depthStencilState": { + "depthTest": true, + "depthWrite": false + }, + "properties": { + "mainTexture": { + "value": "grey", + "type": 29 + }, + "mainTiling_Offset": { + "type": 16, + "value": [ + 1, + 1, + 0, + 0 + ] + } + } + } + ] + }, + { + "name": "transparent-add", + "passes": [ + { + "stage": "transparent", + "program": "builtin-3d-particle|particle-vs-legacy:lpvs_main|tinted-fs:add", + "rasterizerState": { + "cullMode": 0 + }, + "blendState": { + "targets": [ + { + "blend": true, + "blendSrc": 770, + "blendDst": 1, + "blendSrcAlpha": 770, + "blendDstAlpha": 1 + } + ] + }, + "depthStencilState": { + "depthTest": true, + "depthWrite": false + }, + "properties": { + "mainTexture": { + "value": "grey", + "type": 29 + }, + "mainTiling_Offset": { + "type": 16, + "value": [ + 1, + 1, + 0, + 0 + ] + }, + "tintColor": { + "type": 16, + "value": [ + 0.5, + 0.5, + 0.5, + 0.5 + ], + "inspector": { + "type": "color" + } + } + } + } + ] + }, + { + "name": "transparent-alpha-blend", + "passes": [ + { + "stage": "transparent", + "program": "builtin-3d-particle|particle-vs-legacy:lpvs_main|tinted-fs:add", + "rasterizerState": { + "cullMode": 0 + }, + "blendState": { + "targets": [ + { + "blend": true, + "blendSrc": 770, + "blendDst": 771, + "blendSrcAlpha": 770, + "blendDstAlpha": 771 + } + ] + }, + "depthStencilState": { + "depthTest": true, + "depthWrite": false + }, + "properties": { + "mainTexture": { + "value": "grey", + "type": 29 + }, + "mainTiling_Offset": { + "type": 16, + "value": [ + 1, + 1, + 0, + 0 + ] + }, + "tintColor": { + "type": 16, + "value": [ + 0.5, + 0.5, + 0.5, + 0.5 + ], + "inspector": { + "type": "color" + } + } + } + } + ] + }, + { + "name": "transparent-add-multiply", + "passes": [ + { + "stage": "transparent", + "program": "builtin-3d-particle|particle-vs-legacy:lpvs_main|tinted-fs:multiply", + "rasterizerState": { + "cullMode": 0 + }, + "blendState": { + "targets": [ + { + "blend": true, + "blendSrc": 770, + "blendDst": 771, + "blendSrcAlpha": 770, + "blendDstAlpha": 771 + } + ] + }, + "depthStencilState": { + "depthTest": true, + "depthWrite": false + }, + "properties": { + "mainTexture": { + "value": "grey", + "type": 29 + }, + "mainTiling_Offset": { + "type": 16, + "value": [ + 1, + 1, + 0, + 0 + ] + }, + "tintColor": { + "type": 16, + "value": [ + 0.5, + 0.5, + 0.5, + 0.5 + ], + "inspector": { + "type": "color" + } + } + } + } + ] + }, + { + "name": "transparent-add-smooth", + "passes": [ + { + "stage": "transparent", + "program": "builtin-3d-particle|particle-vs-legacy:lpvs_main|no-tint-fs:addSmooth", + "rasterizerState": { + "cullMode": 0 + }, + "blendState": { + "targets": [ + { + "blend": true, + "blendSrc": 770, + "blendDst": 771, + "blendSrcAlpha": 770, + "blendDstAlpha": 771 + } + ] + }, + "depthStencilState": { + "depthTest": true, + "depthWrite": false + }, + "properties": { + "mainTexture": { + "value": "grey", + "type": 29 + }, + "mainTiling_Offset": { + "type": 16, + "value": [ + 1, + 1, + 0, + 0 + ] + } + } + } + ] + }, + { + "name": "transparent-premultiply-blend", + "passes": [ + { + "stage": "transparent", + "program": "builtin-3d-particle|particle-vs-legacy:lpvs_main|no-tint-fs:premultiplied", + "rasterizerState": { + "cullMode": 0 + }, + "blendState": { + "targets": [ + { + "blend": true, + "blendSrc": 770, + "blendDst": 771, + "blendSrcAlpha": 770, + "blendDstAlpha": 771 + } + ] + }, + "depthStencilState": { + "depthTest": true, + "depthWrite": false + }, + "properties": { + "mainTexture": { + "value": "grey", + "type": 29 + }, + "mainTiling_Offset": { + "type": 16, + "value": [ + 1, + 1, + 0, + 0 + ] + } + } + } + ] + } + ] + ] + ], + 0, + 0, + [], + [], + [] + ], + [ + [ + [ + 1, + "builtin-2d-graphics", + { + "0": { + "defines": {} + } + } + ] + ], + 0, + 0, + [ + 0 + ], + [ + 0 + ], + [ + 8 + ] + ], + [ + [ + [ + 0, + "builtin-clear-stencil", + [ + { + "hash": 2075641479, + "record": null, + "name": "builtin-clear-stencil|vs|fs", + "glsl3": { + "vert": "\nprecision highp float;\nin vec3 a_position;\nvoid main () {\n gl_Position = vec4(a_position, 1);\n}", + "frag": "\nprecision highp float;\nvoid main () {\n gl_FragColor = vec4(1.0);\n}" + }, + "glsl1": { + "vert": "\nprecision highp float;\nattribute vec3 a_position;\nvoid main () {\n gl_Position = vec4(a_position, 1);\n}", + "frag": "\nprecision highp float;\nvoid main () {\n gl_FragColor = vec4(1.0);\n}" + }, + "builtins": { + "globals": { + "blocks": [], + "samplers": [] + }, + "locals": { + "blocks": [], + "samplers": [] + } + }, + "defines": [], + "blocks": [], + "samplers": [] + } + ], + [ + { + "passes": [ + { + "program": "builtin-clear-stencil|vs|fs", + "blendState": { + "targets": [ + { + "blend": true + } + ] + }, + "rasterizerState": { + "cullMode": 0 + } + } + ] + } + ] + ] + ], + 0, + 0, + [], + [], + [] + ], + [ + [ + [ + 1, + "builtin-clear-stencil", + {} + ] + ], + 0, + 0, + [ + 0 + ], + [ + 0 + ], + [ + 9 + ] + ], + [ + [ + [ + 1, + "builtin-2d-label", + { + "0": { + "defines": { + "USE_TEXTURE": true + } + } + } + ] + ], + 0, + 0, + [ + 0 + ], + [ + 0 + ], + [ + 10 + ] + ], + [ + [ + [ + 1, + "builtin-2d-sprite", + { + "0": { + "defines": { + "USE_TEXTURE": true + } + } + } + ] + ], + 0, + 0, + [ + 0 + ], + [ + 0 + ], + [ + 1 + ] + ], + [ + [ + [ + 0, + "builtin-2d-label", + [ + { + "hash": 1105459032, + "record": null, + "name": "builtin-2d-label|vs|fs", + "glsl3": { + "vert": "\nprecision highp float;\nuniform CCGlobal {\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\nuniform CCLocal {\n mat4 cc_matWorld;\n mat4 cc_matWorldIT;\n};\nin vec3 a_position;\nin vec4 a_color;\nout vec4 v_color;\n#if USE_TEXTURE\nin vec2 a_uv0;\nout vec2 v_uv0;\n#endif\nvoid main () {\n vec4 pos = vec4(a_position, 1);\n #if CC_USE_MODEL\n pos = cc_matViewProj * cc_matWorld * pos;\n #else\n pos = cc_matViewProj * pos;\n #endif\n #if USE_TEXTURE\n v_uv0 = a_uv0;\n #endif\n v_color = a_color;\n gl_Position = pos;\n}", + "frag": "\n#if CC_SUPPORT_standard_derivatives\n #extension GL_OES_standard_derivatives : enable\n#endif\nprecision highp float;\n#if USE_ALPHA_TEST\n uniform ALPHA_TEST {\n float alphaThreshold;\n };\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\nin vec4 v_color;\n#if USE_TEXTURE\nin vec2 v_uv0;\nuniform sampler2D texture;\n#endif\n#if USE_SDF\nuniform Outline {\n vec4 outlineColor;\n float outlineSize;\n};\n#endif\nvoid main () {\n#if USE_SDF\n #if USE_TEXTURE_ALPHAONLY\n float dist = texture(texture, v_uv0).a;\n #else\n float dist = texture(texture, v_uv0).r;\n #endif\n #if USE_SDF_EXTEND\n const float EDGE_VALUE = 0.45;\n #else\n const float EDGE_VALUE = 0.5;\n #endif\n #if CC_SUPPORT_standard_derivatives\n float smoothing = fwidth(dist);\n #else\n float smoothing = 0.05;\n #endif\n float outEdge = EDGE_VALUE - outlineSize;\n float bg = smoothstep(outEdge - smoothing, outEdge, dist);\n float fg = smoothstep(EDGE_VALUE - smoothing, EDGE_VALUE, dist);\n vec4 fgColor = outlineColor * (1.0 - fg) + v_color * fg;\n gl_FragColor = vec4(fgColor.rgb, fgColor.a * bg);\n#else\n vec4 o = vec4(1, 1, 1, 1);\n #if USE_TEXTURE\n #if USE_TEXTURE_ALPHAONLY\n o.a *= texture(texture, v_uv0).a;\n #else\n o *= texture(texture, v_uv0);\n #endif\n #if CC_USE_ALPHA_ATLAS_TEXTURE\n o.a *= texture2D(texture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #endif\n o *= v_color;\n ALPHA_TEST(o);\n gl_FragColor = o;\n#endif\n}" + }, + "glsl1": { + "vert": "\nprecision highp float;\nuniform mat4 cc_matViewProj;\nuniform mat4 cc_matWorld;\nattribute vec3 a_position;\nattribute vec4 a_color;\nvarying vec4 v_color;\n#if USE_TEXTURE\nattribute vec2 a_uv0;\nvarying vec2 v_uv0;\n#endif\nvoid main () {\n vec4 pos = vec4(a_position, 1);\n #if CC_USE_MODEL\n pos = cc_matViewProj * cc_matWorld * pos;\n #else\n pos = cc_matViewProj * pos;\n #endif\n #if USE_TEXTURE\n v_uv0 = a_uv0;\n #endif\n v_color = a_color;\n gl_Position = pos;\n}", + "frag": "\n#if CC_SUPPORT_standard_derivatives\n #extension GL_OES_standard_derivatives : enable\n#endif\nprecision highp float;\n#if USE_ALPHA_TEST\n uniform float alphaThreshold;\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\nvarying vec4 v_color;\n#if USE_TEXTURE\nvarying vec2 v_uv0;\nuniform sampler2D texture;\n#endif\n#if USE_SDF\nuniform vec4 outlineColor;\nuniform float outlineSize;\n#endif\nvoid main () {\n#if USE_SDF\n #if USE_TEXTURE_ALPHAONLY\n float dist = texture2D(texture, v_uv0).a;\n #else\n float dist = texture2D(texture, v_uv0).r;\n #endif\n #if USE_SDF_EXTEND\n const float EDGE_VALUE = 0.45;\n #else\n const float EDGE_VALUE = 0.5;\n #endif\n #if CC_SUPPORT_standard_derivatives\n float smoothing = fwidth(dist);\n #else\n float smoothing = 0.05;\n #endif\n float outEdge = EDGE_VALUE - outlineSize;\n float bg = smoothstep(outEdge - smoothing, outEdge, dist);\n float fg = smoothstep(EDGE_VALUE - smoothing, EDGE_VALUE, dist);\n vec4 fgColor = outlineColor * (1.0 - fg) + v_color * fg;\n gl_FragColor = vec4(fgColor.rgb, fgColor.a * bg);\n#else\n vec4 o = vec4(1, 1, 1, 1);\n #if USE_TEXTURE\n #if USE_TEXTURE_ALPHAONLY\n o.a *= texture2D(texture, v_uv0).a;\n #else\n o *= texture2D(texture, v_uv0);\n #endif\n #if CC_USE_ALPHA_ATLAS_TEXTURE\n o.a *= texture2D(texture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #endif\n o *= v_color;\n ALPHA_TEST(o);\n gl_FragColor = o;\n#endif\n}" + }, + "builtins": { + "globals": { + "blocks": [ + { + "name": "CCGlobal", + "defines": [] + } + ], + "samplers": [] + }, + "locals": { + "blocks": [ + { + "name": "CCLocal", + "defines": [] + } + ], + "samplers": [] + } + }, + "defines": [ + { + "name": "USE_TEXTURE", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_MODEL", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_SUPPORT_standard_derivatives", + "type": "boolean", + "defines": [] + }, + { + "name": "USE_ALPHA_TEST", + "type": "boolean", + "defines": [] + }, + { + "name": "USE_SDF", + "type": "boolean", + "defines": [] + }, + { + "name": "USE_TEXTURE_ALPHAONLY", + "type": "boolean", + "defines": [ + "USE_SDF" + ] + }, + { + "name": "USE_SDF_EXTEND", + "type": "boolean", + "defines": [ + "USE_SDF" + ] + }, + { + "name": "CC_USE_ALPHA_ATLAS_TEXTURE", + "type": "boolean", + "defines": [ + "USE_TEXTURE" + ] + } + ], + "blocks": [ + { + "name": "ALPHA_TEST", + "binding": 0, + "members": [ + { + "name": "alphaThreshold", + "type": 13, + "count": 1 + } + ], + "defines": [ + "USE_ALPHA_TEST" + ] + }, + { + "name": "Outline", + "binding": 1, + "members": [ + { + "name": "outlineColor", + "type": 16, + "count": 1 + }, + { + "name": "outlineSize", + "type": 13, + "count": 1 + } + ], + "defines": [ + "USE_SDF" + ] + } + ], + "samplers": [ + { + "name": "texture", + "type": 29, + "count": 1, + "binding": 30, + "defines": [ + "USE_TEXTURE" + ] + } + ] + } + ], + [ + { + "passes": [ + { + "program": "builtin-2d-label|vs|fs", + "blendState": { + "targets": [ + { + "blend": true + } + ] + }, + "rasterizerState": { + "cullMode": 0 + }, + "properties": { + "texture": { + "value": "white", + "type": 29 + }, + "alphaThreshold": { + "type": 13, + "value": [ + 0.5 + ] + }, + "outlineSize": { + "type": 13, + "value": [ + 0 + ] + }, + "outlineColor": { + "type": 16, + "value": [ + 1, + 1, + 1, + 1 + ] + } + } + } + ] + } + ] + ] + ], + 0, + 0, + [], + [], + [] + ] + ] +] \ No newline at end of file diff --git a/Layered_virtual_list_2.x/build/web-mobile/assets/internal/index.cb4f5.js b/Layered_virtual_list_2.x/build/web-mobile/assets/internal/index.cb4f5.js new file mode 100644 index 0000000..f3e1735 --- /dev/null +++ b/Layered_virtual_list_2.x/build/web-mobile/assets/internal/index.cb4f5.js @@ -0,0 +1,28 @@ +(function e(t, n, r) { + function s(o, u) { + if (!n[o]) { + if (!t[o]) { + var b = o.split("/"); + b = b[b.length - 1]; + if (!t[b]) { + var a = "function" == typeof __require && __require; + if (!u && a) return a(b, !0); + if (i) return i(b, !0); + throw new Error("Cannot find module '" + o + "'"); + } + o = b; + } + var f = n[o] = { + exports: {} + }; + t[o][0].call(f.exports, function(e) { + var n = t[o][1][e]; + return s(n || e); + }, f, f.exports, e, t, n, r); + } + return n[o].exports; + } + var i = "function" == typeof __require && __require; + for (var o = 0; o < r.length; o++) s(r[o]); + return s; +})({}, {}, []); \ No newline at end of file diff --git a/Layered_virtual_list_2.x/build/web-mobile/assets/internal/native/02/0275e94c-56a7-410f-bd1a-fc7483f7d14a.cea68.png b/Layered_virtual_list_2.x/build/web-mobile/assets/internal/native/02/0275e94c-56a7-410f-bd1a-fc7483f7d14a.cea68.png new file mode 100644 index 0000000..fa6376e Binary files /dev/null and b/Layered_virtual_list_2.x/build/web-mobile/assets/internal/native/02/0275e94c-56a7-410f-bd1a-fc7483f7d14a.cea68.png differ diff --git a/Layered_virtual_list_2.x/build/web-mobile/assets/internal/native/60/600301aa-3357-4a10-b086-84f011fa32ba.c3a3a.png b/Layered_virtual_list_2.x/build/web-mobile/assets/internal/native/60/600301aa-3357-4a10-b086-84f011fa32ba.c3a3a.png new file mode 100644 index 0000000..c6adfe9 Binary files /dev/null and b/Layered_virtual_list_2.x/build/web-mobile/assets/internal/native/60/600301aa-3357-4a10-b086-84f011fa32ba.c3a3a.png differ diff --git a/Layered_virtual_list_2.x/build/web-mobile/assets/main/config.c102c.json b/Layered_virtual_list_2.x/build/web-mobile/assets/main/config.c102c.json new file mode 100644 index 0000000..191c0ae --- /dev/null +++ b/Layered_virtual_list_2.x/build/web-mobile/assets/main/config.c102c.json @@ -0,0 +1,71 @@ +{ + "paths": {}, + "uuids": [ + "02delMVqdBD70a/HSD99FK", + "29FYIk+N1GYaeWH/q1NxQO", + "2dL3kvpAxJu6GJ7RdqJG5J", + "6bHG7VDatBWrPMRAjycKLQ", + "71VhFCTINJM6/Ky3oX9nBT", + "9bvaMerUlDyary99mJa6xp", + "a2MjXRFdtLlYQ5ouAFv/+R", + "b4P/PCArtIdIH38t6mlw8Y", + "d8HsitJHxOYqo801xBk8ev", + "e8Ueib+qJEhL6mXAHdnwbi", + "e97GVMl6JHh5Ml5qEDdSGa", + "ecpdLyjvZBwrvm+cedCcQy", + "f0BIwQ8D5Ml7nTNQbh1YlS" + ], + "scenes": { + "db://assets/Scene/helloworld.fire": "2dL3kvpAxJu6GJ7RdqJG5J" + }, + "redirect": [ + "02delMVqdBD70a/HSD99FK", + 0, + "ecpdLyjvZBwrvm+cedCcQy", + 0 + ], + "deps": [ + "internal" + ], + "packs": { + "048df28f0": [ + "29FYIk+N1GYaeWH/q1NxQO", + "2dL3kvpAxJu6GJ7RdqJG5J", + "6bHG7VDatBWrPMRAjycKLQ", + "9bvaMerUlDyary99mJa6xp", + "a2MjXRFdtLlYQ5ouAFv/+R", + "e97GVMl6JHh5Ml5qEDdSGa", + "f0BIwQ8D5Ml7nTNQbh1YlS" + ], + "053ef0d56": [ + "71VhFCTINJM6/Ky3oX9nBT", + "b4P/PCArtIdIH38t6mlw8Y", + "d8HsitJHxOYqo801xBk8ev", + "e8Ueib+qJEhL6mXAHdnwbi" + ] + }, + "name": "main", + "importBase": "import", + "nativeBase": "native", + "debug": true, + "isZip": false, + "encrypted": false, + "versions": { + "import": [ + "048df28f0", + "a673e", + "053ef0d56", + "56856" + ], + "native": [ + "71VhFCTINJM6/Ky3oX9nBT", + "c06a9", + "b4P/PCArtIdIH38t6mlw8Y", + "83fcc", + "d8HsitJHxOYqo801xBk8ev", + "cdbc9", + "e8Ueib+qJEhL6mXAHdnwbi", + "90cf4" + ] + } +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/build/web-mobile/assets/main/import/04/048df28f0.a673e.json b/Layered_virtual_list_2.x/build/web-mobile/assets/main/import/04/048df28f0.a673e.json new file mode 100644 index 0000000..f1a5b1f --- /dev/null +++ b/Layered_virtual_list_2.x/build/web-mobile/assets/main/import/04/048df28f0.a673e.json @@ -0,0 +1,2313 @@ +[ + 1, + [ + "ecpdLyjvZBwrvm+cedCcQy", + "a2MjXRFdtLlYQ5ouAFv/+R", + "f0BIwQ8D5Ml7nTNQbh1YlS", + "9bvaMerUlDyary99mJa6xp", + "71VhFCTINJM6/Ky3oX9nBT", + "6bHG7VDatBWrPMRAjycKLQ", + "e97GVMl6JHh5Ml5qEDdSGa", + "29FYIk+N1GYaeWH/q1NxQO", + "d8HsitJHxOYqo801xBk8ev", + "02delMVqdBD70a/HSD99FK", + "b4P/PCArtIdIH38t6mlw8Y", + "e8Ueib+qJEhL6mXAHdnwbi" + ], + [ + "node", + "_spriteFrame", + "_textureSetter", + "_parent", + "_N$content", + "scrollView", + "scene", + "showPrefab", + "root", + "ButtonLb", + "Button", + "contentLb", + "nameLb", + "_N$target", + "data", + "_N$normalSprite", + "_N$pressedSprite", + "_N$hoverSprite", + "_N$disabledSprite" + ], + [ + [ + "cc.Node", + [ + "_name", + "_active", + "_id", + "_components", + "_contentSize", + "_parent", + "_trs", + "_children", + "_color", + "_anchorPoint", + "_prefab" + ], + 0, + 9, + 5, + 1, + 7, + 2, + 5, + 5, + 4 + ], + "cc.SpriteFrame", + [ + "cc.Widget", + [ + "_alignFlags", + "_originalWidth", + "_originalHeight", + "_right", + "alignMode", + "node" + ], + -2, + 1 + ], + [ + "cc.Node", + [ + "_name", + "_parent", + "_components", + "_contentSize", + "_prefab", + "_color", + "_children", + "_trs" + ], + 2, + 1, + 12, + 5, + 4, + 5, + 2, + 7 + ], + [ + "f9782xj4QNK842OAHoabRFb", + [ + "syncInv", + "renderZIndex", + "node", + "renderLayer" + ], + 1, + 1, + 1 + ], + [ + "cc.Label", + [ + "_string", + "_N$horizontalAlign", + "_N$verticalAlign", + "_N$cacheMode", + "_fontSize", + "_enableWrapText", + "_N$overflow", + "node", + "_materials" + ], + -4, + 1, + 3 + ], + [ + "cc.Mask", + [ + "_N$alphaThreshold", + "_enabled", + "node", + "_materials" + ], + 1, + 1, + 3 + ], + [ + "cc.Sprite", + [ + "_sizeMode", + "_type", + "node", + "_materials", + "_spriteFrame" + ], + 1, + 1, + 3, + 6 + ], + [ + "cc.ScrollView", + [ + "brake", + "bounceDuration", + "_N$horizontalScrollBar", + "_N$verticalScrollBar", + "vertical", + "horizontal", + "node", + "_N$content" + ], + -3, + 1, + 1 + ], + [ + "cc.PrefabInfo", + [ + "fileId", + "root" + ], + 2, + 1 + ], + [ + "cc.SceneAsset", + [ + "_name", + "asyncLoadAssets" + ], + 1 + ], + [ + "cc.Canvas", + [ + "_fitWidth", + "_fitHeight", + "node", + "_designResolution" + ], + 1, + 1, + 5 + ], + [ + "cc.Layout", + [ + "_resize", + "_N$layoutType", + "_N$spacingY", + "node", + "_layoutSize" + ], + 0, + 1, + 5 + ], + [ + "cc.Scene", + [ + "_name", + "_active", + "_children", + "_anchorPoint", + "_trs" + ], + 1, + 2, + 5, + 7 + ], + [ + "cc.Camera", + [ + "_clearFlags", + "_depth", + "node" + ], + 1, + 1 + ], + [ + "4850bCv26VE3LcjWQcJHche", + [ + "node", + "rendeLayer", + "scrollView", + "showPrefab" + ], + 3, + 1, + 1, + 1, + 6 + ], + [ + "cc.Prefab", + [ + "_name" + ], + 2 + ], + [ + "9e178M6rUlI5qgi1+HcLO30", + [ + "node", + "nameLb", + "contentLb", + "Button", + "ButtonLb" + ], + 3, + 1, + 1, + 1, + 1, + 1 + ], + [ + "cc.Button", + [ + "_N$transition", + "node", + "_N$normalColor", + "_N$pressedColor", + "_N$disabledColor", + "_N$target", + "_N$normalSprite", + "_N$pressedSprite", + "_N$hoverSprite", + "_N$disabledSprite" + ], + 2, + 1, + 5, + 5, + 5, + 1, + 6, + 6, + 6, + 6 + ], + [ + "cc.LabelShadow", + [ + "node", + "_offset" + ], + 3, + 1, + 5 + ], + [ + "cc.LabelOutline", + [ + "_width", + "node" + ], + 2, + 1 + ] + ], + [ + [ + 4, + 0, + 2, + 3, + 2 + ], + [ + 9, + 0, + 1, + 2 + ], + [ + 7, + 0, + 2, + 3, + 4, + 2 + ], + [ + 5, + 0, + 1, + 2, + 3, + 7, + 8, + 5 + ], + [ + 0, + 0, + 5, + 7, + 3, + 8, + 4, + 6, + 2 + ], + [ + 0, + 0, + 5, + 3, + 8, + 4, + 2 + ], + [ + 2, + 4, + 0, + 1, + 2, + 5, + 5 + ], + [ + 7, + 1, + 0, + 2, + 3, + 4, + 3 + ], + [ + 4, + 1, + 2, + 2 + ], + [ + 0, + 0, + 5, + 3, + 4, + 9, + 2 + ], + [ + 0, + 0, + 5, + 3, + 2 + ], + [ + 3, + 0, + 1, + 2, + 4, + 5, + 3, + 7, + 2 + ], + [ + 2, + 0, + 1, + 2, + 5, + 4 + ], + [ + 12, + 0, + 1, + 2, + 3, + 4, + 4 + ], + [ + 4, + 2, + 1 + ], + [ + 10, + 0, + 1, + 3 + ], + [ + 0, + 0, + 2, + 7, + 3, + 8, + 4, + 6, + 3 + ], + [ + 0, + 0, + 4, + 6, + 2 + ], + [ + 0, + 0, + 7, + 3, + 4, + 9, + 6, + 2 + ], + [ + 0, + 0, + 1, + 5, + 7, + 3, + 8, + 4, + 3 + ], + [ + 0, + 0, + 1, + 5, + 7, + 3, + 4, + 3 + ], + [ + 0, + 0, + 5, + 7, + 3, + 4, + 9, + 6, + 2 + ], + [ + 0, + 0, + 7, + 3, + 10, + 8, + 4, + 9, + 6, + 2 + ], + [ + 0, + 0, + 5, + 7, + 3, + 10, + 4, + 6, + 2 + ], + [ + 0, + 0, + 5, + 3, + 10, + 4, + 6, + 2 + ], + [ + 0, + 0, + 5, + 3, + 10, + 8, + 4, + 6, + 2 + ], + [ + 3, + 0, + 1, + 6, + 2, + 3, + 2 + ], + [ + 3, + 0, + 1, + 2, + 4, + 5, + 3, + 2 + ], + [ + 11, + 0, + 1, + 2, + 3, + 3 + ], + [ + 2, + 0, + 5, + 2 + ], + [ + 2, + 0, + 1, + 5, + 3 + ], + [ + 2, + 0, + 3, + 1, + 5, + 4 + ], + [ + 6, + 0, + 2, + 3, + 2 + ], + [ + 6, + 1, + 0, + 2, + 3, + 3 + ], + [ + 8, + 4, + 0, + 1, + 2, + 3, + 6, + 7, + 6 + ], + [ + 8, + 5, + 0, + 1, + 2, + 3, + 6, + 7, + 6 + ], + [ + 5, + 0, + 1, + 2, + 7, + 8, + 4 + ], + [ + 5, + 0, + 4, + 5, + 1, + 2, + 6, + 3, + 7, + 8, + 8 + ], + [ + 13, + 0, + 1, + 2, + 3, + 4, + 3 + ], + [ + 14, + 0, + 1, + 2, + 3 + ], + [ + 15, + 0, + 1, + 2, + 3, + 1 + ], + [ + 16, + 0, + 2 + ], + [ + 17, + 0, + 1, + 2, + 3, + 4, + 1 + ], + [ + 9, + 1, + 1 + ], + [ + 18, + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 2 + ], + [ + 19, + 0, + 1, + 1 + ], + [ + 20, + 0, + 1, + 2 + ] + ], + [ + [ + [ + { + "name": "default_btn_disabled", + "rect": [ + 0, + 0, + 40, + 40 + ], + "offset": [ + 0, + 0 + ], + "originalSize": [ + 40, + 40 + ], + "capInsets": [ + 12, + 12, + 12, + 12 + ] + } + ], + [ + 1 + ], + 0, + [ + 0 + ], + [ + 2 + ], + [ + 4 + ] + ], + [ + [ + [ + 15, + "helloworld", + null + ], + [ + 16, + "Canvas", + "a286bbGknJLZpRpxROV6M94", + [ + -3, + -4, + -5, + -6, + -7 + ], + [ + [ + 28, + true, + false, + -1, + [ + 5, + 750, + 1334 + ] + ], + [ + 29, + 45, + -2 + ] + ], + [ + 4, + 4294769916 + ], + [ + 5, + 750, + 1334 + ], + [ + 375, + 667, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + ], + [ + 17, + "layer", + [ + 5, + 200, + 300 + ], + [ + 123.761, + -500, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + ], + [ + 18, + "view", + [ + -10, + 2 + ], + [ + [ + 32, + 0, + -8, + [ + 2 + ] + ], + [ + 12, + 45, + 240, + 250, + -9 + ] + ], + [ + 5, + 750, + 1000 + ], + [ + 0, + 0.5, + 1 + ], + [ + 0, + 500, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + ], + [ + 19, + "parent", + false, + 1, + [ + -12, + -13, + -14 + ], + [ + [ + 2, + 0, + -11, + [ + 16 + ], + 17 + ] + ], + [ + 4, + 4281182248 + ], + [ + 5, + 500, + 500 + ] + ], + [ + 26, + "Vertical", + 1, + [ + 3 + ], + [ + [ + [ + 7, + 1, + 0, + -15, + [ + 0 + ], + 1 + ], + -16 + ], + 4, + 1 + ], + [ + 5, + 750, + 1000 + ] + ], + [ + 9, + "content", + 3, + [ + [ + 13, + 1, + 2, + 10, + -17, + [ + 5, + 750, + 0 + ] + ], + [ + 30, + 41, + 220, + -18 + ] + ], + [ + 5, + 750, + 0 + ], + [ + 0, + 0.5, + 1 + ] + ], + [ + 20, + "Horizontal", + false, + 1, + [ + -22 + ], + [ + [ + 7, + 1, + 0, + -19, + [ + 5 + ], + 6 + ], + [ + 34, + false, + 0.75, + 0.23, + null, + null, + -21, + -20 + ] + ], + [ + 5, + 500, + 1000 + ] + ], + [ + 21, + "view", + 7, + [ + -25 + ], + [ + [ + 33, + false, + 0, + -23, + [ + 4 + ] + ], + [ + 12, + 45, + 240, + 250, + -24 + ] + ], + [ + 5, + 500, + 1000 + ], + [ + 0, + 0, + 0.5 + ], + [ + -250, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + ], + [ + 9, + "content", + 8, + [ + [ + 13, + 1, + 1, + 5, + -26, + [ + 5, + 220, + 1000 + ] + ], + [ + 31, + 13, + 280, + 220, + -27 + ] + ], + [ + 5, + 220, + 1000 + ], + [ + 0, + 0, + 0.5 + ] + ], + [ + 4, + "1", + 4, + [ + -30 + ], + [ + [ + 2, + 0, + -28, + [ + 8 + ], + 9 + ], + [ + 0, + 0, + -29, + 2 + ] + ], + [ + 4, + 4278190335 + ], + [ + 5, + 100, + 100 + ], + [ + -80.714, + 123.761, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + ], + [ + 4, + "2", + 4, + [ + -33 + ], + [ + [ + 2, + 0, + -31, + [ + 11 + ], + 12 + ], + [ + 0, + 0, + -32, + 2 + ] + ], + [ + 4, + 4278237439 + ], + [ + 5, + 100, + 100 + ], + [ + -80.714, + 123.761, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + ], + [ + 4, + "3", + 4, + [ + -36 + ], + [ + [ + 2, + 0, + -34, + [ + 14 + ], + 15 + ], + [ + 0, + 0, + -35, + 2 + ] + ], + [ + 4, + 4294904320 + ], + [ + 5, + 100, + 100 + ], + [ + -80.714, + 123.761, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + ], + [ + 5, + "New Label", + 10, + [ + [ + 3, + "1", + 1, + 1, + 2, + -37, + [ + 7 + ] + ], + [ + 0, + 0, + -38, + 2 + ] + ], + [ + 4, + 4278190080 + ], + [ + 5, + 22.25, + 40 + ] + ], + [ + 5, + "New Label", + 11, + [ + [ + 3, + "2", + 1, + 1, + 2, + -39, + [ + 10 + ] + ], + [ + 0, + 0, + -40, + 2 + ] + ], + [ + 4, + 4278190080 + ], + [ + 5, + 22.25, + 40 + ] + ], + [ + 5, + "New Label", + 12, + [ + [ + 3, + "3", + 1, + 1, + 2, + -41, + [ + 13 + ] + ], + [ + 0, + 0, + -42, + 2 + ] + ], + [ + 4, + 4278190080 + ], + [ + 5, + 22.25, + 40 + ] + ], + [ + 38, + "New Node", + false, + [ + 1 + ], + [ + 0, + 0, + 0 + ], + [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + ], + [ + 10, + "Main Camera", + 1, + [ + [ + 39, + 7, + -1, + -43 + ] + ] + ], + [ + 10, + "TestLoop", + 1, + [ + [ + 40, + -45, + 2, + -44, + 3 + ] + ] + ], + [ + 35, + false, + 0.75, + 0.23, + null, + null, + 5, + 6 + ] + ], + 0, + [ + 0, + 0, + 1, + 0, + 0, + 1, + 0, + -1, + 17, + 0, + -2, + 18, + 0, + -3, + 5, + 0, + -4, + 7, + 0, + -5, + 4, + 0, + 0, + 3, + 0, + 0, + 3, + 0, + -1, + 6, + 0, + 0, + 4, + 0, + -1, + 10, + 0, + -2, + 11, + 0, + -3, + 12, + 0, + 0, + 5, + 0, + -2, + 19, + 0, + 0, + 6, + 0, + 0, + 6, + 0, + 0, + 7, + 0, + 4, + 9, + 0, + 0, + 7, + 0, + -1, + 8, + 0, + 0, + 8, + 0, + 0, + 8, + 0, + -1, + 9, + 0, + 0, + 9, + 0, + 0, + 9, + 0, + 0, + 10, + 0, + 0, + 10, + 0, + -1, + 13, + 0, + 0, + 11, + 0, + 0, + 11, + 0, + -1, + 14, + 0, + 0, + 12, + 0, + 0, + 12, + 0, + -1, + 15, + 0, + 0, + 13, + 0, + 0, + 13, + 0, + 0, + 14, + 0, + 0, + 14, + 0, + 0, + 15, + 0, + 0, + 15, + 0, + 0, + 17, + 0, + 5, + 19, + 0, + 0, + 18, + 0, + 6, + 16, + 1, + 3, + 16, + 2, + 3, + 3, + 3, + 3, + 5, + 45 + ], + [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + [ + -1, + 1, + -1, + 7, + -1, + -1, + 1, + -1, + -1, + 1, + -1, + -1, + 1, + -1, + -1, + 1, + -1, + 1 + ], + [ + 0, + 3, + 0, + 5, + 0, + 0, + 3, + 0, + 0, + 1, + 0, + 0, + 1, + 0, + 0, + 1, + 0, + 1 + ] + ], + [ + [ + [ + 41, + "showNode" + ], + [ + 22, + "showNode", + [ + -8, + -9, + -10, + -11 + ], + [ + [ + 42, + -6, + -5, + -4, + -3, + -2 + ], + [ + 6, + 2, + 45, + 750, + 100, + -7 + ] + ], + [ + 43, + -1 + ], + [ + 4, + 4278190080 + ], + [ + 5, + 750, + 1334 + ], + [ + 0, + 0.5, + 1 + ], + [ + 375, + 1334, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + ], + [ + 23, + "New Button", + 1, + [ + -14, + -15 + ], + [ + [ + 44, + 3, + -13, + [ + 4, + 4293322470 + ], + [ + 4, + 4291348680 + ], + [ + 4, + 3363338360 + ], + -12, + 6, + 7, + 8, + 9 + ] + ], + [ + 1, + "14TO6K8WlMjp8gwgtWA0qf", + 1 + ], + [ + 5, + 100, + 40 + ], + [ + -106.669, + -44.121, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + ], + [ + 24, + "Background", + 2, + [ + [ + 7, + 1, + 0, + -16, + [ + 3 + ], + 4 + ], + [ + 6, + 0, + 45, + 100, + 40, + -17 + ], + [ + 14, + -18 + ] + ], + [ + 1, + "b2yBk+BHFOF7B8n1gYypgp", + 1 + ], + [ + 5, + 100, + 40 + ], + [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 0 + ] + ], + [ + 25, + "Bg", + 1, + [ + [ + 2, + 0, + -19, + [ + 0 + ], + 1 + ], + [ + 6, + 2, + 45, + 100, + 100, + -20 + ], + [ + 14, + -21 + ] + ], + [ + 1, + "2fWAV/kSxKbLNNotfg0pAI", + 1 + ], + [ + 4, + 4294939440 + ], + [ + 5, + 750, + 1334 + ], + [ + 0, + -667, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + ], + [ + 11, + "nameLb", + 1, + [ + [ + -22, + [ + 8, + 1, + -23 + ], + [ + 45, + -24, + [ + 0, + 2, + -5 + ] + ] + ], + 1, + 4, + 4 + ], + [ + 1, + "50Nr1a5SVMCLPTFU4WTSCP", + 1 + ], + [ + 4, + 4278190080 + ], + [ + 5, + 142.25, + 50.4 + ], + [ + -261.821, + -45.115, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + ], + [ + 11, + "contentLb", + 1, + [ + [ + -25, + [ + 8, + 1, + -26 + ], + [ + 46, + 2, + -27 + ] + ], + 1, + 4, + 4 + ], + [ + 1, + "41ShEz5VJCm68duiIf01ZR", + 1 + ], + [ + 4, + 4278190080 + ], + [ + 5, + 333.07, + 44 + ], + [ + 151.722, + -43.961, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + ], + [ + 27, + "Label", + 2, + [ + [ + -28, + [ + 8, + 1, + -29 + ] + ], + 1, + 4 + ], + [ + 1, + "78ZrwHpmZIaZAh4fh1OXyZ", + 1 + ], + [ + 4, + 4278190080 + ], + [ + 5, + 100, + 40 + ] + ], + [ + 36, + "我是第1", + 1, + 1, + 5, + [ + 2 + ] + ], + [ + 37, + "button", + 20, + false, + 1, + 1, + 1, + 2, + 7, + [ + 5 + ] + ], + [ + 3, + "ScrollView content", + 1, + 1, + 2, + 6, + [ + 10 + ] + ] + ], + 0, + [ + 0, + 8, + 1, + 0, + 9, + 9, + 0, + 10, + 2, + 0, + 11, + 10, + 0, + 12, + 8, + 0, + 0, + 1, + 0, + 0, + 1, + 0, + -1, + 4, + 0, + -2, + 5, + 0, + -3, + 2, + 0, + -4, + 6, + 0, + 13, + 3, + 0, + 0, + 2, + 0, + -1, + 3, + 0, + -2, + 7, + 0, + 0, + 3, + 0, + 0, + 3, + 0, + 0, + 3, + 0, + 0, + 4, + 0, + 0, + 4, + 0, + 0, + 4, + 0, + -1, + 8, + 0, + 0, + 5, + 0, + 0, + 5, + 0, + -1, + 10, + 0, + 0, + 6, + 0, + 0, + 6, + 0, + -1, + 9, + 0, + 0, + 7, + 0, + 14, + 1, + 29 + ], + [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + [ + -1, + 1, + -1, + -1, + 1, + -1, + 15, + 16, + 17, + 18, + -1 + ], + [ + 0, + 1, + 0, + 0, + 2, + 0, + 2, + 6, + 2, + 7, + 0 + ] + ], + [ + [ + { + "name": "default_panel", + "rect": [ + 0, + 0, + 20, + 20 + ], + "offset": [ + 0, + 0 + ], + "originalSize": [ + 20, + 20 + ], + "capInsets": [ + 6, + 6, + 6, + 6 + ] + } + ], + [ + 1 + ], + 0, + [ + 0 + ], + [ + 2 + ], + [ + 8 + ] + ], + [ + [ + { + "name": "default_sprite_splash", + "rect": [ + 0, + 0, + 2, + 2 + ], + "offset": [ + 0, + 0 + ], + "originalSize": [ + 2, + 2 + ], + "capInsets": [ + 0, + 0, + 0, + 0 + ] + } + ], + [ + 1 + ], + 0, + [ + 0 + ], + [ + 2 + ], + [ + 9 + ] + ], + [ + [ + { + "name": "default_btn_pressed", + "rect": [ + 0, + 0, + 40, + 40 + ], + "offset": [ + 0, + 0 + ], + "originalSize": [ + 40, + 40 + ], + "capInsets": [ + 12, + 12, + 12, + 12 + ] + } + ], + [ + 1 + ], + 0, + [ + 0 + ], + [ + 2 + ], + [ + 10 + ] + ], + [ + [ + { + "name": "default_btn_normal", + "rect": [ + 0, + 0, + 40, + 40 + ], + "offset": [ + 0, + 0 + ], + "originalSize": [ + 40, + 40 + ], + "capInsets": [ + 12, + 12, + 12, + 12 + ] + } + ], + [ + 1 + ], + 0, + [ + 0 + ], + [ + 2 + ], + [ + 11 + ] + ] + ] +] \ No newline at end of file diff --git a/Layered_virtual_list_2.x/build/web-mobile/assets/main/import/05/053ef0d56.56856.json b/Layered_virtual_list_2.x/build/web-mobile/assets/main/import/05/053ef0d56.56856.json new file mode 100644 index 0000000..61f4b9b --- /dev/null +++ b/Layered_virtual_list_2.x/build/web-mobile/assets/main/import/05/053ef0d56.56856.json @@ -0,0 +1,4 @@ +{ + "type": "cc.Texture2D", + "data": "0,9729,9729,33071,33071,0,0,1|0,9729,9729,33071,33071,0,0,1|0,9729,9729,33071,33071,0,0,1|0,9729,9729,33071,33071,0,0,1" +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/build/web-mobile/assets/main/index.c102c.js b/Layered_virtual_list_2.x/build/web-mobile/assets/main/index.c102c.js new file mode 100644 index 0000000..3146dfc --- /dev/null +++ b/Layered_virtual_list_2.x/build/web-mobile/assets/main/index.c102c.js @@ -0,0 +1,1147 @@ +window.__require = function e(t, n, r) { + function s(o, u) { + if (!n[o]) { + if (!t[o]) { + var b = o.split("/"); + b = b[b.length - 1]; + if (!t[b]) { + var a = "function" == typeof __require && __require; + if (!u && a) return a(b, !0); + if (i) return i(b, !0); + throw new Error("Cannot find module '" + o + "'"); + } + o = b; + } + var f = n[o] = { + exports: {} + }; + t[o][0].call(f.exports, function(e) { + var n = t[o][1][e]; + return s(n || e); + }, f, f.exports, e, t, n, r); + } + return n[o].exports; + } + var i = "function" == typeof __require && __require; + for (var o = 0; o < r.length; o++) s(r[o]); + return s; +}({ + LoopList: [ function(require, module, exports) { + "use strict"; + cc._RF.push(module, "b4ec1SU3/dIdZG3ODfwZKk3", "LoopList"); + "use strict"; + var __extends = this && this.__extends || function() { + var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || { + __proto__: [] + } instanceof Array && function(d, b) { + d.__proto__ = b; + } || function(d, b) { + for (var p in b) Object.prototype.hasOwnProperty.call(b, p) && (d[p] = b[p]); + }; + return extendStatics(d, b); + }; + return function(d, b) { + extendStatics(d, b); + function __() { + this.constructor = d; + } + d.prototype = null === b ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + }(); + var __awaiter = this && this.__awaiter || function(thisArg, _arguments, P, generator) { + function adopt(value) { + return value instanceof P ? value : new P(function(resolve) { + resolve(value); + }); + } + return new (P || (P = Promise))(function(resolve, reject) { + function fulfilled(value) { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + } + function rejected(value) { + try { + step(generator["throw"](value)); + } catch (e) { + reject(e); + } + } + function step(result) { + result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); + } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); + }; + var __generator = this && this.__generator || function(thisArg, body) { + var _ = { + label: 0, + sent: function() { + if (1 & t[0]) throw t[1]; + return t[1]; + }, + trys: [], + ops: [] + }, f, y, t, g; + return g = { + next: verb(0), + throw: verb(1), + return: verb(2) + }, "function" === typeof Symbol && (g[Symbol.iterator] = function() { + return this; + }), g; + function verb(n) { + return function(v) { + return step([ n, v ]); + }; + } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = 2 & op[0] ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), + 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + (y = 0, t) && (op = [ 2 & op[0], t.value ]); + switch (op[0]) { + case 0: + case 1: + t = op; + break; + + case 4: + _.label++; + return { + value: op[1], + done: false + }; + + case 5: + _.label++; + y = op[1]; + op = [ 0 ]; + continue; + + case 7: + op = _.ops.pop(); + _.trys.pop(); + continue; + + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (6 === op[0] || 2 === op[0])) { + _ = 0; + continue; + } + if (3 === op[0] && (!t || op[1] > t[0] && op[1] < t[3])) { + _.label = op[1]; + break; + } + if (6 === op[0] && _.label < t[1]) { + _.label = t[1]; + t = op; + break; + } + if (t && _.label < t[2]) { + _.label = t[2]; + _.ops.push(op); + break; + } + t[2] && _.ops.pop(); + _.trys.pop(); + continue; + } + op = body.call(thisArg, _); + } catch (e) { + op = [ 6, e ]; + y = 0; + } finally { + f = t = 0; + } + if (5 & op[0]) throw op[1]; + return { + value: op[0] ? op[1] : void 0, + done: true + }; + } + }; + Object.defineProperty(exports, "__esModule", { + value: true + }); + exports.ItemCell = exports.ShowNode = void 0; + var RenderAlternative_1 = require("./RenderAlternative"); + var ShowNode = function(_super) { + __extends(ShowNode, _super); + function ShowNode() { + var _this = null !== _super && _super.apply(this, arguments) || this; + _this.hasInit = false; + return _this; + } + ShowNode.prototype.init = function(cell, data, renderLayer) { + this.cell = cell; + this.data = data; + if (this.renderLayer != renderLayer) { + this.renderLayer = renderLayer; + renderLayer && this.initRenders(); + } + this.initShow(); + }; + ShowNode.prototype.initShow = function() {}; + ShowNode.prototype.onRecircle = function() {}; + ShowNode.prototype.resize = function(targetSize, time) { + void 0 === time && (time = .3); + this.cell.resize(targetSize, time); + }; + ShowNode.prototype.initRenders = function() { + if (!this.hasInit && this.renderLayer) { + var propMap = new WeakMap(); + var keys = Object.keys(this); + for (var i = 0, len = keys.length; i < len; ++i) { + var value = this[keys[i]]; + var alternative = null; + if (value instanceof cc.Node) { + alternative = value.getComponent(RenderAlternative_1.default); + alternative && alternative.init(this.renderLayer); + } else if (value instanceof cc.RenderComponent) { + alternative = value.getComponent(RenderAlternative_1.default); + alternative && (this[keys[i]] = alternative.init(this.renderLayer)); + } + alternative && propMap.set(alternative, true); + } + this.dealChilrenAlternative(this.node, propMap, 0, 0); + this.hasInit = true; + } + }; + ShowNode.prototype.dealChilrenAlternative = function(node, propMap, parentSindex, depth) { + var _a; + for (var i = 0, len = node.children.length; i < len; i++) { + var children = node.children[i]; + var alternative = null === (_a = children.getComponent(cc.RenderComponent)) || void 0 === _a ? void 0 : _a.getComponent(RenderAlternative_1.default); + var sIndex = parentSindex + i * Math.pow(.1, depth); + if (alternative) { + propMap.has(alternative) && propMap.get(alternative) || alternative.init(this.renderLayer); + alternative.sIndex = sIndex; + } + this.dealChilrenAlternative(children, propMap, sIndex, depth + 1); + } + }; + return ShowNode; + }(cc.Component); + exports.ShowNode = ShowNode; + var ItemCell = function() { + function ItemCell(node, looplist) { + this.looplist = null; + this.node = null; + this.showNode = null; + this.size = null; + this.dataIndex = null; + this.cellIndex = null; + this.data = null; + this.node = node; + this.looplist = looplist; + } + ItemCell.prototype.init = function(data, size, dataIndex, cellIndex, looplist) { + cc.Tween.stopAllByTarget(this.node); + this.cellIndex = cellIndex; + this.dataIndex = dataIndex; + this.looplist = looplist; + this.node.width = size.width; + this.node.height = size.height; + this.data = data; + this.size = size; + }; + ItemCell.prototype.resize = function(size, time) { + var _this = this; + var nodeSides = getNodeBorder(this, [ true, true, true, true ]); + var changeSize = cc.size(size.width - this.size.width, size.height - this.size.height); + this.size = size; + this.looplist.dealChangeSize(this, nodeSides, changeSize, time).then(function() { + _this.node.width = size.width; + _this.node.height = size.height; + _this.looplist.updateNodes(); + }); + }; + ItemCell.prototype.updateShow = function(isShow, prefab, cacheNode, renderLayer) { + if (isShow && !this.showNode) { + this.showNode = cacheNode || cc.instantiate(prefab).getComponent(ShowNode); + this.showNode.node.setParent(this.node); + this.showNode.node.position = cc.v3(); + this.updateShowNode(renderLayer); + } + }; + ItemCell.prototype.updateShowNode = function(renderLayer) { + this.showNode && this.showNode.init(this, this.data, renderLayer); + }; + Object.defineProperty(ItemCell.prototype, "hasNoNode", { + get: function() { + return !this.showNode; + }, + enumerable: false, + configurable: true + }); + ItemCell.prototype.recircle = function() { + if (this.showNode) { + var node = this.showNode; + this.showNode.getComponent(ShowNode).onRecircle(); + this.showNode.node.removeFromParent(false); + this.showNode = null; + return node; + } + }; + ItemCell.prototype.destroy = function() { + this.node.destroy(); + this.node = null; + this.looplist = null; + }; + ItemCell.prototype.lostShowNode = function() { + if (this.showNode) { + var node = this.showNode; + this.showNode.node.removeFromParent(false); + this.showNode = null; + return node; + } + }; + ItemCell.prototype.getShowNode = function(showNode) { + this.showNode = showNode; + showNode.node.setParent(this.node); + this.showNode.cell = this; + }; + return ItemCell; + }(); + exports.ItemCell = ItemCell; + var LoopList = function() { + function LoopList() { + this.renderLayer = null; + this.scrollView = null; + this.cellMaxNum = null; + this.curStartIndex = null; + this.datas = []; + this.itemCells = []; + this.prefab = null; + this.showNodePool = []; + this.viewSides = {}; + this.lastPos = null; + this.updateInv = 0; + this.lastChange = 0; + this.size = null; + this.anchor = null; + } + LoopList.ins = function(listName) { + this.insMap.has(listName) || this.insMap.set(listName, new LoopList()); + return this.insMap.get(listName); + }; + LoopList.prototype.onLoad = function() { + this.updateBorder(); + }; + LoopList.prototype.updateBorder = function() { + var _this = this; + var view = this.scrollView.node.getChildByName("view"); + view.anchorX = this.scrollView.content.anchorX; + view.anchorY = this.scrollView.content.anchorY; + return new Promise(function(resolve, reject) { + requestAnimationFrame(function() { + var wpos = getNodeWPos(view); + var leftSide = wpos.x - view.width * view.anchorX; + var rightSide = wpos.x + view.width * (1 - view.anchorX); + var bottomSide = wpos.y - view.height * view.anchorY; + var topSide = wpos.y + view.height * (1 - view.anchorY); + _this.viewSides = { + leftSide: leftSide, + rightSide: rightSide, + bottomSide: bottomSide, + topSide: topSide, + size: cc.size(view.width, view.height) + }; + _this.scrollView.content.setPosition(cc.v3(0, 0)); + resolve(); + }); + }); + }; + LoopList.prototype.init = function(scrollView, renderLayer, cellMaxNum) { + return __awaiter(this, void 0, void 0, function() { + return __generator(this, function(_a) { + switch (_a.label) { + case 0: + cellMaxNum && (this.cellMaxNum = cellMaxNum); + renderLayer && (this.renderLayer = renderLayer); + this.scrollView = scrollView; + return [ 4, this.updateBorder() ]; + + case 1: + _a.sent(); + this.scrollView.node.on("scrolling", this.scrollingListener, this); + return [ 2 ]; + } + }); + }); + }; + LoopList.prototype.scrollingListener = function() { + this.updateInv--; + if (this.updateInv <= 0) { + this.updateInv = 2; + var showCells = this.updateNodes(); + if (!this.cellMaxNum) return; + if (this.lastPos) { + var offset = this.scrollView.content.position.clone().sub(this.lastPos); + this.lastPos = this.scrollView.content.position.clone(); + var now = cc.sys.now(); + if (!this.lastChange || now - this.lastChange > 100) { + this.lastChange = now; + this.dealLoopList(offset, showCells); + } + } else this.lastPos = this.scrollView.content.position.clone(); + } + }; + LoopList.prototype.initData = function(data, prefab, size, anchor) { + void 0 === anchor && (anchor = cc.v2(.5, .5)); + this.datas = data; + this.size = size; + this.anchor = anchor; + this.prefab = prefab; + var len = this.cellMaxNum ? this.cellMaxNum : data.length; + this.curStartIndex = 0; + for (var i = 0; i < len; ++i) { + var itemCell = this.itemCells[i]; + if (!itemCell) { + var node = new cc.Node("LoopListCell"); + itemCell = this.itemCells[i] = new ItemCell(node, this); + node.setAnchorPoint(anchor); + node.setParent(this.scrollView.content); + } + var data_1 = this.datas[this.curStartIndex + i]; + var cellSize = data_1.size ? data_1.size : size; + itemCell.init(data_1, cellSize, this.curStartIndex + i, i, this); + } + for (var i = data.length, len_1 = this.itemCells.length; i < len_1; ++i) { + this.recircleShowNode(this.itemCells[i].recircle()); + this.itemCells[i].destroy(); + this.itemCells[i] = null; + } + this.updateNodes(); + }; + LoopList.prototype.pushDatas = function(datas) { + var length = this.datas.length; + for (var i = 0, len = datas.length; i < len; ++i) { + var data = datas[i]; + this.datas.push(data); + var index = length + i; + this.addNodeFromIndex(index); + } + }; + LoopList.prototype.insertData = function(data, insertIndex) { + if (this.datas.length >= insertIndex) { + this.datas.splice(insertIndex, 0, data); + this.addNodeFromIndex(insertIndex); + } else this.pushDatas([ data ]); + }; + LoopList.prototype.removeData = function(removeIndex) { + var _this = this; + if (this.datas.length >= removeIndex) { + this.datas.splice(removeIndex, 1); + if (this.cellMaxNum) { + var cellIndex_1 = removeIndex - this.curStartIndex; + if (cellIndex_1 >= 0 && cellIndex_1 < this.cellMaxNum) { + var itemCell = this.itemCells[cellIndex_1]; + var nodeSides = getNodeBorder(itemCell, [ true, true, true, true ]); + var changeSize = cc.size(-itemCell.size.width, -itemCell.size.height); + itemCell.size = cc.size(0, 0); + this.dealChangeSize(itemCell, nodeSides, changeSize).then(function() { + for (var i = cellIndex_1; i < _this.cellMaxNum; i++) { + var curDataIndex = _this.curStartIndex + i; + var curData = _this.datas[curDataIndex]; + var curCellSize = curData.size ? curData.size : _this.size; + _this.itemCells[i].init(curData, curCellSize, curDataIndex, i, _this); + _this.itemCells[i].updateShowNode(_this.renderLayer); + } + }); + } + } else { + var itemCell_1 = this.itemCells.splice(removeIndex, 1)[0]; + var nodeSides = getNodeBorder(itemCell_1, [ true, true, true, true ]); + var changeSize = cc.size(-itemCell_1.size.width, -itemCell_1.size.height); + itemCell_1.size = cc.size(0, 0); + this.dealChangeSize(itemCell_1, nodeSides, changeSize).then(function() { + _this.recircleShowNode(itemCell_1.recircle()); + itemCell_1.node.destroy(); + }); + } + } + }; + LoopList.prototype.addNodeFromIndex = function(dataIndex) { + return __awaiter(this, void 0, void 0, function() { + var data, cellSize, cellIndex, i, curDataIndex, curData, curCellSize, nodeSides, itemCell_2, nodeSides_1, node, itemCell_3; + return __generator(this, function(_a) { + switch (_a.label) { + case 0: + data = this.datas[dataIndex]; + cellSize = data.size ? data.size : this.size; + if (!this.cellMaxNum) return [ 3, 1 ]; + cellIndex = dataIndex - this.curStartIndex; + if (cellIndex >= 0 && cellIndex < this.cellMaxNum) { + for (i = cellIndex; i < this.cellMaxNum; i++) { + curDataIndex = this.curStartIndex + i; + curData = this.datas[curDataIndex]; + curCellSize = curData.size ? curData.size : this.size; + this.itemCells[i].init(curData, curCellSize, curDataIndex, i, this); + this.itemCells[i].updateShowNode(this.renderLayer); + } + nodeSides = null; + itemCell_2 = this.itemCells[cellIndex]; + if (itemCell_2) { + nodeSides = getNodeBorder(itemCell_2, [ true, true, true, true ]); + itemCell_2.node.width = 0; + itemCell_2.node.height = 0; + this.dealChangeSize(itemCell_2, nodeSides, cellSize).then(function() { + itemCell_2.node.width = cellSize.width; + itemCell_2.node.height = cellSize.height; + }); + } + } + return [ 3, 4 ]; + + case 1: + nodeSides_1 = null; + this.itemCells[dataIndex] && (nodeSides_1 = getNodeBorder(this.itemCells[dataIndex], [ true, true, true, true ])); + node = new cc.Node("LoopListCell"); + node.setAnchorPoint(this.anchor); + node.setParent(this.scrollView.content); + node.setSiblingIndex(dataIndex); + itemCell_3 = new ItemCell(node, this); + this.itemCells.splice(dataIndex, 0, itemCell_3); + itemCell_3.init(data, cellSize, dataIndex, dataIndex, this); + if (!!nodeSides_1) return [ 3, 3 ]; + return [ 4, new Promise(function(resolve, reject) { + requestAnimationFrame(function() { + nodeSides_1 = getNodeBorder(itemCell_3, [ true, true, true, true ]); + resolve(); + }); + }) ]; + + case 2: + _a.sent(); + _a.label = 3; + + case 3: + if (nodeSides_1) { + itemCell_3.node.width = 0; + itemCell_3.node.height = 0; + this.dealChangeSize(itemCell_3, nodeSides_1, cellSize).then(function() { + itemCell_3.node.width = cellSize.width; + itemCell_3.node.height = cellSize.height; + }); + } + this.dealItemShow(itemCell_3); + _a.label = 4; + + case 4: + return [ 2 ]; + } + }); + }); + }; + LoopList.prototype.dealLoopList = function(offset, showCells) { + var startCell = showCells[0]; + var endCell = showCells[showCells.length - 1]; + if (this.scrollView.vertical) { + if (offset.y > 0) { + if (this.scrollView.content.y >= -this.itemCells[this.itemCells.length - 2].node.y - this.viewSides.size.height && endCell.dataIndex < this.datas.length - 2) { + var showStart = startCell.dataIndex - 1; + var leave = this.datas.length - showStart; + var cellStartIndex = Math.max(0, this.itemCells.length - leave); + this.curStartIndex = showStart - cellStartIndex; + var cellTop = getNodeBorder(this.itemCells[startCell.cellIndex], [ true ]).topSide; + var contentHeight = 0; + var targetY = 0; + var jumpFirst = true; + var showIndex = 0; + for (var i = 0, len = this.itemCells.length; i < len; ++i) { + if (i >= cellStartIndex) { + if (showIndex < showCells.length && !jumpFirst) { + 0 == showIndex && (targetY = contentHeight); + var showNode = showCells[showIndex].lostShowNode(); + showIndex++; + this.itemCells[i].getShowNode(showNode); + } + jumpFirst = false; + } + var dataIndex = this.curStartIndex + i; + var data = this.datas[dataIndex]; + var cellSize = data.size ? data.size : this.size; + contentHeight += cellSize.height; + this.itemCells[i].init(data, cellSize, dataIndex, i, this); + } + var posY = targetY + (cellTop - this.viewSides.topSide); + this.scrollView.content.setPosition(cc.v3(this.scrollView.content.position.x, posY)); + this.scrollView.scrollToOffset(cc.v2(0, posY + endCell.size.height), 1); + this.lastPos = null; + } + } else if (offset.y < 0 && this.scrollView.content.y < -this.itemCells[2].node.y && startCell.dataIndex > 1) { + var showEndIndex = endCell.dataIndex + 1; + var cellEndIndex = Math.min(this.itemCells.length - 2, showEndIndex - 1); + this.curStartIndex = Math.max(showEndIndex - (this.itemCells.length - 1), 0); + var cellTop = getNodeBorder(this.itemCells[startCell.cellIndex], [ true ]).topSide; + var contentHeight = 0; + var showIndex = showCells.length - 1; + for (var i = this.itemCells.length - 1; i >= 0; --i) { + if (i <= cellEndIndex) if (showIndex >= 0) { + var showNode = showCells[showIndex].lostShowNode(); + showIndex--; + this.itemCells[i].getShowNode(showNode); + } else showIndex--; + var dataIndex = this.curStartIndex + i; + var data = this.datas[dataIndex]; + var cellSize = data.size ? data.size : this.size; + showIndex < -1 && (contentHeight += cellSize.height); + this.itemCells[i].init(data, cellSize, dataIndex, i, this); + } + var posY = contentHeight + (cellTop - this.viewSides.topSide); + this.scrollView.content.setPosition(cc.v3(this.scrollView.content.position.x, posY)); + this.scrollView.scrollToOffset(cc.v2(0, posY - startCell.size.height), 1); + this.lastPos = null; + } + } else if (this.scrollView.horizontal) if (offset.x < 0) { + if (this.scrollView.content.x <= -(this.itemCells[this.itemCells.length - 2].node.x - this.viewSides.size.width) && endCell.dataIndex < this.datas.length - 2) { + var showStart = startCell.dataIndex - 1; + var leave = this.datas.length - showStart; + var cellStartIndex = Math.max(0, this.itemCells.length - leave); + this.curStartIndex = showStart - cellStartIndex; + var cellLeft = getNodeBorder(this.itemCells[startCell.cellIndex], [ false, false, true ]).leftSide; + var contentWidth = 0; + var targetX = 0; + var jumpFirst = true; + var showIndex = 0; + for (var i = 0, len = this.itemCells.length; i < len; ++i) { + if (i >= cellStartIndex) { + if (showIndex < showCells.length && !jumpFirst) { + 0 == showIndex && (targetX = contentWidth); + var showNode = showCells[showIndex].lostShowNode(); + showIndex++; + this.itemCells[i].getShowNode(showNode); + } + jumpFirst = false; + } + var dataIndex = this.curStartIndex + i; + var data = this.datas[dataIndex]; + var cellSize = data.size ? data.size : this.size; + contentWidth += cellSize.width; + this.itemCells[i].init(data, cellSize, dataIndex, i, this); + } + var posX = cellLeft - this.viewSides.leftSide - targetX; + this.scrollView.content.setPosition(cc.v3(posX, this.scrollView.content.position.y)); + this.scrollView.scrollToOffset(cc.v2(-(posX - endCell.size.width), 0), 1); + this.lastPos = null; + } + } else if (offset.x > 0 && this.scrollView.content.x > -this.itemCells[2].node.x && startCell.dataIndex > 1) { + var showEndIndex = endCell.dataIndex + 1; + var cellEndIndex = Math.min(this.itemCells.length - 2, showEndIndex - 1); + this.curStartIndex = Math.max(showEndIndex - (this.itemCells.length - 1), 0); + var cellLeft = getNodeBorder(this.itemCells[startCell.cellIndex], [ false, false, true ]).leftSide; + var contentWidth = 0; + var showIndex = showCells.length - 1; + for (var i = this.itemCells.length - 1; i >= 0; --i) { + if (i <= cellEndIndex) if (showIndex >= 0) { + var showNode = showCells[showIndex].lostShowNode(); + showIndex--; + this.itemCells[i].getShowNode(showNode); + } else showIndex--; + var dataIndex = this.curStartIndex + i; + var data = this.datas[dataIndex]; + var cellSize = data.size ? data.size : this.size; + showIndex < -1 && (contentWidth += cellSize.width); + this.itemCells[i].init(data, cellSize, dataIndex, i, this); + } + var posX = cellLeft - this.viewSides.leftSide - contentWidth; + this.scrollView.content.setPosition(cc.v3(posX, this.scrollView.content.position.y)); + this.scrollView.scrollToOffset(cc.v2(-(posX + startCell.size.width), 0), 1); + this.lastPos = null; + } + }; + LoopList.prototype.updateNodes = function() { + var showCells = []; + for (var i = 0, len = this.itemCells.length; i < len; ++i) { + var itemCell = this.itemCells[i]; + var isShow = this.dealItemShow(itemCell); + isShow && showCells.push(itemCell); + } + return showCells; + }; + LoopList.prototype.dealItemShow = function(itemCell) { + if (itemCell) { + var isShow = this.checkInView(itemCell); + isShow ? itemCell.hasNoNode && itemCell.updateShow(isShow, this.prefab, this.showNodePool.length > 0 ? this.showNodePool.pop() : null, this.renderLayer) : !itemCell.hasNoNode && this.recircleShowNode(itemCell.recircle()); + return isShow; + } + }; + LoopList.prototype.checkInView = function(itemCell) { + var nodeSides = getNodeBorder(itemCell, [ true, true, true, true ]); + var horizontalOutside = nodeSides.rightSide < this.viewSides.leftSide || nodeSides.leftSide > this.viewSides.rightSide; + var verticalOutside = false; + horizontalOutside || (verticalOutside = nodeSides.topSide < this.viewSides.bottomSide || nodeSides.bottomSide > this.viewSides.topSide); + return !horizontalOutside && !verticalOutside; + }; + LoopList.prototype.dealChangeSize = function(cell, nodeSides, changeSize, time) { + void 0 === time && (time = .3); + return __awaiter(this, void 0, void 0, function() { + var topToBottomFulfill, bottomToTopFulfill, leftToRightFulfill, RightToLeftFulfill; + return __generator(this, function(_a) { + switch (_a.label) { + case 0: + topToBottomFulfill = 1 == this.scrollView.content.anchorY && nodeSides.bottomSide >= this.viewSides.topSide; + bottomToTopFulfill = 0 == this.scrollView.content.anchorY && nodeSides.topSide <= this.viewSides.bottomSide; + (topToBottomFulfill || bottomToTopFulfill) && (topToBottomFulfill ? this.scrollView.setContentPosition(cc.v2(this.scrollView.content.x, this.scrollView.content.y + changeSize.height)) : this.scrollView.setContentPosition(cc.v2(this.scrollView.content.x, this.scrollView.content.y - changeSize.height))); + leftToRightFulfill = 0 == this.scrollView.content.anchorX && nodeSides.rightSide <= this.viewSides.leftSide; + RightToLeftFulfill = 1 == this.scrollView.content.anchorX && nodeSides.leftSide >= this.viewSides.rightSide; + (leftToRightFulfill || RightToLeftFulfill) && (RightToLeftFulfill ? this.scrollView.setContentPosition(cc.v2(this.scrollView.content.x + changeSize.width, this.scrollView.content.y)) : this.scrollView.setContentPosition(cc.v2(this.scrollView.content.x - changeSize.width, this.scrollView.content.y))); + if (!!(topToBottomFulfill || bottomToTopFulfill || leftToRightFulfill || RightToLeftFulfill)) return [ 3, 2 ]; + cc.Tween.stopAllByTarget(cell.node); + return [ 4, new Promise(function(resolve, reject) { + cc.tween(cell.node).to(time, { + width: cell.size.width, + height: cell.size.height + }).call(function() { + resolve(); + }).start(); + }) ]; + + case 1: + _a.sent(); + _a.label = 2; + + case 2: + this.updateNodes(); + return [ 2, true ]; + } + }); + }); + }; + LoopList.prototype.recircleShowNode = function(node) { + node && this.showNodePool.push(node); + }; + LoopList.prototype.freeList = function() { + this.scrollView.node.off("scrolling", this.scrollingListener); + for (var i = 0, len = this.itemCells.length; i < len; ++i) { + this.recircleShowNode(this.itemCells[i].recircle()); + this.itemCells[i].destroy(); + } + this.itemCells = []; + for (var index = 0, len = this.showNodePool.length; index < len; ++index) this.showNodePool[index].destroy(); + this.showNodePool = []; + this.renderLayer = null; + this.scrollView = null; + this.prefab = null; + }; + LoopList.insMap = new Map(); + return LoopList; + }(); + exports.default = LoopList; + function getNodeBorder(cell, needArr) { + var node = cell.node; + var boderData = {}; + var wpos = getNodeWPos(node); + needArr[0] && (boderData.topSide = wpos.y + node.height * (1 - node.anchorY)); + needArr[1] && (boderData.bottomSide = wpos.y - node.height * node.anchorY); + needArr[2] && (boderData.leftSide = wpos.x - node.width * node.anchorX); + needArr[3] && (boderData.rightSide = wpos.x + node.width * (1 - node.anchorX)); + boderData.size = cc.size(node.width, node.height); + return boderData; + } + function getNodeWPos(node) { + return node.parent.convertToWorldSpaceAR(node.position); + } + cc._RF.pop(); + }, { + "./RenderAlternative": "RenderAlternative" + } ], + RenderAlternative: [ function(require, module, exports) { + "use strict"; + cc._RF.push(module, "f9782xj4QNK842OAHoabRFb", "RenderAlternative"); + "use strict"; + var __extends = this && this.__extends || function() { + var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || { + __proto__: [] + } instanceof Array && function(d, b) { + d.__proto__ = b; + } || function(d, b) { + for (var p in b) Object.prototype.hasOwnProperty.call(b, p) && (d[p] = b[p]); + }; + return extendStatics(d, b); + }; + return function(d, b) { + extendStatics(d, b); + function __() { + this.constructor = d; + } + d.prototype = null === b ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + }(); + var __decorate = this && this.__decorate || function(decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if ("object" === typeof Reflect && "function" === typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) (d = decorators[i]) && (r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r); + return c > 3 && r && Object.defineProperty(target, key, r), r; + }; + Object.defineProperty(exports, "__esModule", { + value: true + }); + var RenderReactiveHandler_1 = require("./RenderReactiveHandler"); + var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property; + var RenderAlternative = function(_super) { + __extends(RenderAlternative, _super); + function RenderAlternative() { + var _this = null !== _super && _super.apply(this, arguments) || this; + _this.renderLayer = null; + _this.renderZIndex = 0; + _this.syncInv = .01; + _this.sIndex = 0; + _this.proxyRender = null; + _this.renderCompnent = null; + _this.lastWMat4 = null; + _this.lastLMat4 = null; + _this.lastPos = null; + _this.accuTime = 0; + _this.lastFrameTime = null; + _this.isAttachFrame = false; + return _this; + } + RenderAlternative_1 = RenderAlternative; + Object.defineProperty(RenderAlternative.prototype, "zIndex", { + get: function() { + var zIndex = this.renderZIndex + .01 * this.sIndex; + var parentNode = this.node.parent; + while (parentNode != this.renderLayer.parent && parentNode != cc.director.getScene()) { + var render = parentNode.getComponent(RenderAlternative_1); + if (render) { + zIndex += render.zIndex + 1; + break; + } + parentNode = parentNode.parent; + } + return zIndex; + }, + enumerable: false, + configurable: true + }); + RenderAlternative.prototype.init = function(layer) { + layer && (this.renderLayer = layer); + if (!this.renderLayer) { + console.warn("\u8282\u70b9" + this.node.name + "\u6ca1\u6709\u8bbe\u7f6e\u6e32\u67d3\u5c42"); + return null; + } + return this.initRender(); + }; + RenderAlternative.prototype.initRender = function() { + var node = this.getRender(); + node.setParent(this.renderLayer ? this.renderLayer : cc.director.getScene().getChildByName("Canvas")); + this.isAttachFrame = true; + requestAnimationFrame(this.frameUpdate.bind(this)); + return this.doProxy(); + }; + RenderAlternative.prototype.doProxy = function() { + this.proxyRender = new Proxy(this.renderCompnent, new RenderReactiveHandler_1.RenderReactiveHandler()); + return this.proxyRender; + }; + RenderAlternative.prototype.frameUpdate = function() { + var now = cc.sys.now(); + !this.lastFrameTime && (this.lastFrameTime = now); + var dt = now - this.lastFrameTime; + if (this.proxyRender) { + this.accuTime += dt; + if (this.accuTime >= this.syncInv) { + this.accuTime -= this.syncInv; + this.updateProp(); + } + } + this.isAttachFrame && requestAnimationFrame(this.frameUpdate.bind(this)); + }; + RenderAlternative.prototype.updateProp = function() { + var node = this.renderCompnent.node; + if (!this.node.activeInHierarchy) { + node.opacity = 0; + return; + } + node.anchorX = this.node.anchorX; + node.anchorY = this.node.anchorY; + node.width = this.node.width; + node.height = this.node.height; + node.group = this.node.group; + node.color = this.node.color; + node.opacity = this.getOpacity(this.node); + var wMat4 = cc.mat4(); + this.node.getWorldMatrix(wMat4); + true; + this.onAngleChange(wMat4); + this.onScaleChange(wMat4); + this.onPosChange(); + node.zIndex = this.zIndex; + }; + RenderAlternative.prototype.onDestroy = function() { + this.renderCompnent.node.destroy(); + this.renderCompnent = null; + this.proxyRender = null; + }; + RenderAlternative.prototype.getOpacity = function(node) { + var opacity = node.opacity / 255; + var parentNode = node.parent; + while (parentNode != this.renderLayer.parent && parentNode != cc.director.getScene()) { + opacity *= parentNode.opacity / 255; + parentNode = parentNode.parent; + } + return 255 * opacity; + }; + RenderAlternative.prototype.onPosChange = function() { + var wpos = this.node.parent.convertToWorldSpaceAR(this.node.position); + this.renderCompnent.node.position = this.renderLayer.convertToNodeSpaceAR(wpos); + }; + RenderAlternative.prototype.onAngleChange = function(mat4) { + this.renderCompnent.node.angle = this.extractRotationAngleFromMat4(mat4); + }; + RenderAlternative.prototype.extractRotationAngleFromMat4 = function(matrix) { + var scaleX = Math.sqrt(matrix.m[0] * matrix.m[0] + matrix.m[4] * matrix.m[4] + matrix.m[8] * matrix.m[8]); + var scaleY = Math.sqrt(matrix.m[1] * matrix.m[1] + matrix.m[5] * matrix.m[5] + matrix.m[9] * matrix.m[9]); + var angle = Math.atan2(matrix.m[1] / scaleY, matrix.m[0] / scaleX); + var degrees = angle * (180 / Math.PI); + return degrees; + }; + RenderAlternative.prototype.onScaleChange = function(mat4) { + var scale = this.extractScaleFromMat4(mat4); + this.renderCompnent.node.scaleX = scale.x; + this.renderCompnent.node.scaleY = scale.y; + this.renderCompnent.node.scaleZ = scale.z; + }; + RenderAlternative.prototype.extractScaleFromMat4 = function(mat4) { + var scaleX = cc.v3(mat4.m[0], mat4.m[1], mat4.m[2]).mag(); + var scaleY = cc.v3(mat4.m[4], mat4.m[5], mat4.m[6]).mag(); + var scaleZ = cc.v3(mat4.m[8], mat4.m[9], mat4.m[10]).mag(); + return cc.v3(scaleX, scaleY, scaleZ); + }; + RenderAlternative.prototype.getRender = function() { + var _a, _b; + var node = cc.instantiate(this.node); + node.removeAllChildren(); + this.renderCompnent = node.getComponent(cc.RenderComponent); + null === (_a = this.node.getComponent(cc.LabelOutline)) || void 0 === _a ? void 0 : _a.destroy(); + null === (_b = this.node.getComponent(cc.LabelShadow)) || void 0 === _b ? void 0 : _b.destroy(); + this.node.getComponent(cc.RenderComponent).destroy(); + var components = node.getComponents(cc.Component); + for (var i = 0, len = components.length; i < len; ++i) { + var comp = components[i]; + comp instanceof cc.RenderComponent || comp instanceof cc.LabelOutline || comp instanceof cc.LabelShadow || comp.destroy(); + } + return node; + }; + var RenderAlternative_1; + __decorate([ property(cc.Node) ], RenderAlternative.prototype, "renderLayer", void 0); + __decorate([ property ], RenderAlternative.prototype, "renderZIndex", void 0); + __decorate([ property({ + tooltip: "\u8bbe\u7f6e\u540c\u6b65\u7684\u95f4\u9694(\u79d2\u4e3a\u5355\u4f4d)\uff0c0\u5c31\u662f\u6bcf\u5e27\u90fd\u540c\u6b65\uff0c0.1\u5c31\u662f\u96940.1\u79d2\u540c\u6b65\u4e00\u6b21" + }) ], RenderAlternative.prototype, "syncInv", void 0); + RenderAlternative = RenderAlternative_1 = __decorate([ ccclass ], RenderAlternative); + return RenderAlternative; + }(cc.Component); + exports.default = RenderAlternative; + cc._RF.pop(); + }, { + "./RenderReactiveHandler": "RenderReactiveHandler" + } ], + RenderReactiveHandler: [ function(require, module, exports) { + "use strict"; + cc._RF.push(module, "d38d0Ja+51M8L8TYTQwae9Q", "RenderReactiveHandler"); + "use strict"; + Object.defineProperty(exports, "__esModule", { + value: true + }); + exports.RenderReactiveHandler = exports.hasChanged = exports.hasOwn = exports.isObject = void 0; + function isObject(value) { + return null !== value && "object" === typeof value; + } + exports.isObject = isObject; + var hasOwnProperty = Object.prototype.hasOwnProperty; + function hasOwn(val, key) { + if (val instanceof cc.Component) return key in val; + return hasOwnProperty.call(val, key); + } + exports.hasOwn = hasOwn; + function hasChanged(value, oldValue) { + var type = typeof value; + if ("object" === type) return true; + return !Object.is(value, oldValue); + } + exports.hasChanged = hasChanged; + var RenderReactiveHandler = function() { + function RenderReactiveHandler(reactiveTarget) { + this.reactiveTarget = null; + this.reactiveTarget = reactiveTarget; + } + RenderReactiveHandler.prototype.set = function(target, prop, value, receiver) { + var oldValue = Reflect.get(target, prop); + var hadKey = hasOwn(target, prop); + var result = Reflect.set(target, prop, value); + if (!hadKey || hasChanged(value, oldValue)) { + if ("angle" == prop || "scale" == prop || "position" == prop || "_renderFlag" == prop) return; + "activeInHierarchy" == prop && console.warn(target); + this.reactiveTarget && Reflect.set(this.reactiveTarget, prop, value); + } + return result; + }; + RenderReactiveHandler.prototype.apply = function() { + console.warn(arguments); + }; + RenderReactiveHandler.prototype.get = function(target, prop, receiver) { + if ("__raw__" === prop) return target; + if ("__isReactive__" === prop) return true; + var rawValue = Reflect.get(target, prop); + return rawValue; + }; + RenderReactiveHandler.prototype.deleteProperty = function(target, prop) { + var hadKey = hasOwn(target, prop); + var oldValue = target[prop]; + var result = Reflect.deleteProperty(target, prop); + result && hadKey; + return result; + }; + return RenderReactiveHandler; + }(); + exports.RenderReactiveHandler = RenderReactiveHandler; + cc._RF.pop(); + }, {} ], + TestLoop: [ function(require, module, exports) { + "use strict"; + cc._RF.push(module, "4850bCv26VE3LcjWQcJHche", "TestLoop"); + "use strict"; + var __extends = this && this.__extends || function() { + var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || { + __proto__: [] + } instanceof Array && function(d, b) { + d.__proto__ = b; + } || function(d, b) { + for (var p in b) Object.prototype.hasOwnProperty.call(b, p) && (d[p] = b[p]); + }; + return extendStatics(d, b); + }; + return function(d, b) { + extendStatics(d, b); + function __() { + this.constructor = d; + } + d.prototype = null === b ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + }(); + var __decorate = this && this.__decorate || function(decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if ("object" === typeof Reflect && "function" === typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) (d = decorators[i]) && (r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r); + return c > 3 && r && Object.defineProperty(target, key, r), r; + }; + Object.defineProperty(exports, "__esModule", { + value: true + }); + exports.TestLoop = void 0; + var LoopList_1 = require("../Script/LoopList"); + var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property; + var TestLoop = function(_super) { + __extends(TestLoop, _super); + function TestLoop() { + var _this = null !== _super && _super.apply(this, arguments) || this; + _this.rendeLayer = null; + _this.scrollView = null; + _this.showPrefab = null; + return _this; + } + TestLoop.prototype.start = function() { + var baseWidth = 600; + var changeWidth = 150; + var baseHeight = 80; + var changeHeight = 20; + var anchor = cc.v2(.5, .5); + var data = []; + for (var i = 0, len = 30; i < len; ++i) data.push({ + index: i, + text: "\u5185\u5bb9" + i, + size: cc.size(baseWidth + Math.random() * changeWidth, baseHeight + Math.random() * changeHeight) + }); + LoopList_1.default.ins("Test").init(this.scrollView, this.rendeLayer, 18); + LoopList_1.default.ins("Test").initData(data, this.showPrefab, cc.size(baseWidth, baseHeight), anchor); + }; + __decorate([ property(cc.Node) ], TestLoop.prototype, "rendeLayer", void 0); + __decorate([ property(cc.ScrollView) ], TestLoop.prototype, "scrollView", void 0); + __decorate([ property(cc.Prefab) ], TestLoop.prototype, "showPrefab", void 0); + TestLoop = __decorate([ ccclass ], TestLoop); + return TestLoop; + }(cc.Component); + exports.TestLoop = TestLoop; + cc._RF.pop(); + }, { + "../Script/LoopList": "LoopList" + } ], + TestShowNode: [ function(require, module, exports) { + "use strict"; + cc._RF.push(module, "9e178M6rUlI5qgi1+HcLO30", "TestShowNode"); + "use strict"; + var __extends = this && this.__extends || function() { + var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || { + __proto__: [] + } instanceof Array && function(d, b) { + d.__proto__ = b; + } || function(d, b) { + for (var p in b) Object.prototype.hasOwnProperty.call(b, p) && (d[p] = b[p]); + }; + return extendStatics(d, b); + }; + return function(d, b) { + extendStatics(d, b); + function __() { + this.constructor = d; + } + d.prototype = null === b ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + }(); + var __decorate = this && this.__decorate || function(decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if ("object" === typeof Reflect && "function" === typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) (d = decorators[i]) && (r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r); + return c > 3 && r && Object.defineProperty(target, key, r), r; + }; + Object.defineProperty(exports, "__esModule", { + value: true + }); + exports.TestShowNode = void 0; + var LoopList_1 = require("../Script/LoopList"); + var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property; + var TestShowNode = function(_super) { + __extends(TestShowNode, _super); + function TestShowNode() { + var _this = null !== _super && _super.apply(this, arguments) || this; + _this.nameLb = null; + _this.contentLb = null; + _this.Button = null; + _this.ButtonLb = null; + return _this; + } + TestShowNode.prototype.initShow = function() { + this.node.width = this.data.size.width; + this.node.height = this.data.size.height; + this.nameLb.string = "\u6211\u662f\u7b2c" + this.data.index + "\u4e2a"; + this.contentLb.string = "\u6211\u662f\u5185\u5bb9" + this.data.text; + 5 == this.data.index || 11 == this.data.index; + }; + TestShowNode.prototype.changeSize = function(cell) { + var _this = this; + this.resize(cc.size(cell.size.width, 100 + 400 * Math.random())); + this.scheduleOnce(function() { + _this.changeSize(cell); + }, 3 + 3 * Math.random()); + }; + TestShowNode.prototype.onRecircle = function() {}; + __decorate([ property(cc.Label) ], TestShowNode.prototype, "nameLb", void 0); + __decorate([ property(cc.Label) ], TestShowNode.prototype, "contentLb", void 0); + __decorate([ property(cc.Node) ], TestShowNode.prototype, "Button", void 0); + __decorate([ property(cc.Label) ], TestShowNode.prototype, "ButtonLb", void 0); + TestShowNode = __decorate([ ccclass ], TestShowNode); + return TestShowNode; + }(LoopList_1.ShowNode); + exports.TestShowNode = TestShowNode; + cc._RF.pop(); + }, { + "../Script/LoopList": "LoopList" + } ] +}, {}, [ "TestLoop", "TestShowNode", "LoopList", "RenderAlternative", "RenderReactiveHandler" ]); \ No newline at end of file diff --git a/Layered_virtual_list_2.x/build/web-mobile/assets/main/native/71/71561142-4c83-4933-afca-cb7a17f67053.c06a9.png b/Layered_virtual_list_2.x/build/web-mobile/assets/main/native/71/71561142-4c83-4933-afca-cb7a17f67053.c06a9.png new file mode 100644 index 0000000..a3f2d16 Binary files /dev/null and b/Layered_virtual_list_2.x/build/web-mobile/assets/main/native/71/71561142-4c83-4933-afca-cb7a17f67053.c06a9.png differ diff --git a/Layered_virtual_list_2.x/build/web-mobile/assets/main/native/b4/b43ff3c2-02bb-4874-81f7-f2dea6970f18.83fcc.png b/Layered_virtual_list_2.x/build/web-mobile/assets/main/native/b4/b43ff3c2-02bb-4874-81f7-f2dea6970f18.83fcc.png new file mode 100644 index 0000000..3bb6159 Binary files /dev/null and b/Layered_virtual_list_2.x/build/web-mobile/assets/main/native/b4/b43ff3c2-02bb-4874-81f7-f2dea6970f18.83fcc.png differ diff --git a/Layered_virtual_list_2.x/build/web-mobile/assets/main/native/d8/d81ec8ad-247c-4e62-aa3c-d35c4193c7af.cdbc9.png b/Layered_virtual_list_2.x/build/web-mobile/assets/main/native/d8/d81ec8ad-247c-4e62-aa3c-d35c4193c7af.cdbc9.png new file mode 100644 index 0000000..78314b4 Binary files /dev/null and b/Layered_virtual_list_2.x/build/web-mobile/assets/main/native/d8/d81ec8ad-247c-4e62-aa3c-d35c4193c7af.cdbc9.png differ diff --git a/Layered_virtual_list_2.x/build/web-mobile/assets/main/native/e8/e851e89b-faa2-4484-bea6-5c01dd9f06e2.90cf4.png b/Layered_virtual_list_2.x/build/web-mobile/assets/main/native/e8/e851e89b-faa2-4484-bea6-5c01dd9f06e2.90cf4.png new file mode 100644 index 0000000..dff9999 Binary files /dev/null and b/Layered_virtual_list_2.x/build/web-mobile/assets/main/native/e8/e851e89b-faa2-4484-bea6-5c01dd9f06e2.90cf4.png differ diff --git a/Layered_virtual_list_2.x/build/web-mobile/cocos2d-js.1eca1.js b/Layered_virtual_list_2.x/build/web-mobile/cocos2d-js.1eca1.js new file mode 100644 index 0000000..308b93e --- /dev/null +++ b/Layered_virtual_list_2.x/build/web-mobile/cocos2d-js.1eca1.js @@ -0,0 +1,104394 @@ +(function outer(modules, cache, entry) { + function newRequire(name, jumped) { + var module = cache[name]; + if (!module) { + var moduleData = modules[name]; + if (!moduleData) return; + var exports = {}; + module = cache[name] = { + exports: exports + }; + moduleData[0]((function(x) { + return newRequire(moduleData[1][x] || x); + }), module, exports); + } + return module.exports; + } + for (var i = 0; i < entry.length; i++) newRequire(entry[i]); + return newRequire; +})({ + 1: [ (function(require, module, exports) { + module.exports = { + 1001: "cocos2d: removeAction: Target not found", + 1002: "cc.ActionManager.removeActionByTag(): an invalid tag", + 1003: "cc.ActionManager.removeActionByTag(): target must be non-null", + 1004: "cc.ActionManager.getActionByTag(): an invalid tag", + 1005: "cocos2d : getActionByTag(tag = %s): Action not found", + 1006: "[Action step]. override me", + 1007: "[Action update]. override me", + 1008: "cocos2d: FiniteTimeAction#reverse: Implement me", + 1009: "cc.EaseElastic.reverse(): it should be overridden in subclass.", + 1010: "cc.IntervalAction: reverse not implemented.", + 1011: "cc.ActionInterval.setAmplitudeRate(): it should be overridden in subclass.", + 1012: "cc.ActionInterval.getAmplitudeRate(): it should be overridden in subclass.", + 1013: "The speed parameter error", + 1014: "The repeat parameter error", + 1015: "parameters should not be ending with null in Javascript", + 1016: "cc.RotateTo.reverse(): it should be overridden in subclass.", + 1019: "Failed to construct, Sequence construction needs two or more actions.", + 1020: "Failed to construct, Spawn construction needs two or more actions.", + 1021: "cc.Speed.initWithAction(): action must be non nil", + 1022: "cc.Follow.initWithAction(): followedNode must be non nil", + 1023: "cc.ActionEase.initWithAction(): action must be non nil", + 1024: "Invalid configuration. It must at least have one control point", + 1025: "cc.Sequence.initWithTwoActions(): arguments must all be non nil", + 1026: "cc.RepeatForever.initWithAction(): action must be non null", + 1027: "cc.Spawn.initWithTwoActions(): arguments must all be non null", + 1028: "cc.ReverseTime.initWithAction(): action must be non null", + 1029: "cc.ReverseTime.initWithAction(): the action was already passed in.", + 1030: "cc.Animate.initWithAnimation(): animation must be non-NULL", + 1031: "Illegal parameter get passed in cc.tween: %s.", + 1100: "Expected 'data' dict, but not found. Config file: %s", + 1101: "Please load the resource first : %s", + 1200: "cocos2d: Director: Error in gettimeofday", + 1201: "cocos2d: Director: unrecognized projection", + 1203: "cocos2d: Director: Error in gettimeofday", + 1204: "running scene should not null", + 1205: "the scene should not null", + 1206: "loadScene: The scene index to load (%s) is out of range.", + 1207: "loadScene: Unknown name type to load: '%s'", + 1208: "loadScene: Failed to load scene '%s' because '%s' is already being loaded.", + 1209: "loadScene: Can not load the scene '%s' because it was not in the build settings before playing.", + 1210: "Failed to preload '%s', %s", + 1211: "loadScene: The scene index to load (%s) is out of range.", + 1212: "loadScene: Unknown name type to load: '%s'", + 1213: "loadScene: Failed to load scene '%s' because '%s' is already loading", + 1214: "loadScene: Can not load the scene '%s' because it was not in the build settings before playing.", + 1215: "Failed to preload '%s', %s", + 1216: "Director.runSceneImmediate: scene is not valid", + 1300: "element type is wrong!", + 1400: "'%s' is deprecated, please use '%s' instead.", + 1404: "cc.spriteFrameCache is removed, please use cc.loader to load and cache sprite frames of atlas format.", + 1405: "The '%s' has been removed, please use '%s' instead.", + 1406: "'%s.%s' is removed", + 1408: "'%s' is not support in the '%s', please use '%s' instead.", + 1502: "cc.scheduler.scheduleCallbackForTarget(): target should be non-null.", + 1503: "cc.Scheduler.pauseTarget():target should be non-null", + 1504: "cc.Scheduler.resumeTarget():target should be non-null", + 1505: "cc.Scheduler.isTargetPaused():target should be non-null", + 1506: "warning: you CANNOT change update priority in scheduled function", + 1507: 'CCScheduler#scheduleSelector. Selector already scheduled. Updating interval from: %s to %s"', + 1508: "Argument callback must not be empty", + 1509: "Argument target must be non-nullptr", + 1510: "cc.Scheduler: Illegal target which doesn't have uuid or instanceId.", + 1511: "cc.Scheduler: pause state of the scheduled task doesn't match the element pause state in Scheduler, the given paused state will be ignored.", + 1513: "cc.Scheduler: scheduler stopped using `__instanceId` as id since v2.0, you should do scheduler.enableForTarget(target) before all scheduler API usage on target", + 1605: "child already added. It can't be added again", + 1606: "child must be non-null", + 1610: "cocos2d: removeChildByTag(tag = %s): child not found!", + 1612: "cc.Node.stopActionBy(): argument tag an invalid tag", + 1613: "cc.Node.getActionByTag(): argument tag is an invalid tag", + 1617: "child must be non-null", + 1618: "cc.Node.runAction(): action must be non-null", + 1619: "callback function must be non-null", + 1620: "interval must be positive", + 1623: "Set '%s' to normal node (not persist root node).", + 1624: "Replacing with the same sgNode", + 1625: "The replacement sgNode should not contain any child.", + 1626: "Should not set alpha via 'color', set 'opacity' please.", + 1627: "Not support for asynchronous creating node in SG", + 1632: "Node name can not include '/'.", + 1633: "Internal error, should not remove unknown node from parent.", + 1634: "addChild: The child to add must be instance of cc.Node, not %s.", + 1635: "reorderChild: this child is not in children list.", + 1636: "Node's zIndex value can't be greater than cc.macro.MAX_ZINDEX, setting to the maximum value", + 1637: "Node's zIndex value can't be smaller than cc.macro.MIN_ZINDEX, setting to the minimum value", + 1638: "Private node's zIndex can't be set, it will keep cc.macro.MIN_ZINDEX as its value", + 1639: "cc.Action is deprecated, please use cc.Tween instead", + 1800: "cc._EventListenerKeyboard.checkAvailable(): Invalid EventListenerKeyboard!", + 1801: "cc._EventListenerTouchOneByOne.checkAvailable(): Invalid EventListenerTouchOneByOne!", + 1802: "cc._EventListenerTouchAllAtOnce.checkAvailable(): Invalid EventListenerTouchAllAtOnce!", + 1803: "cc._EventListenerAcceleration.checkAvailable(): _onAccelerationEvent must be non-nil", + 1900: "Invalid parameter.", + 2e3: "Don't call this method if the event is for touch.", + 2200: "Design resolution not valid", + 2201: "should set resolutionPolicy", + 2300: "The touches is more than MAX_TOUCHES, nUnusedIndex = %s", + 2400: "WebGL error %s", + 2602: "cc.Sprite.setDisplayFrameWithAnimationName(): Frame not found", + 2603: "cc.Sprite.setDisplayFrameWithAnimationName(): Invalid frame index", + 2606: "cc.Sprite.initWithSpriteFrame(): spriteFrame should be non-null", + 2607: "cc.Sprite.initWithSpriteFrameName(): spriteFrameName should be non-null", + 2608: "%s is null, please check.", + 2609: "cc.Sprite.initWithFile(): filename should be non-null", + 2610: "cc.Sprite.setDisplayFrameWithAnimationName(): animationName must be non-null", + 2614: "cc.Sprite.addChild(): child should be non-null", + 2616: "cc.SpriteBatchNode.updateQuadFromSprite(): cc.SpriteBatchNode only supports cc.Sprites as children", + 2617: "cc.SpriteBatchNode.insertQuadFromSprite(): cc.SpriteBatchNode only supports cc.Sprites as children", + 2618: "cc.SpriteBatchNode.addChild(): cc.SpriteBatchNode only supports cc.Sprites as children", + 2619: "cc.SpriteBatchNode.addChild(): cc.Sprite is not using the same texture", + 2623: "cc.SpriteBatchNode.updateQuadFromSprite(): sprite should be non-null", + 2625: "too many tiles, only 16384 tiles will be show", + 2626: "Unrecognized fill type in bar fill", + 2627: "Can not generate quad", + 2628: "%s does not exist", + 2712: "Invalid spriteFrameName", + 3005: "cocos2d: '%s' id=%s %s x %s", + 3006: "cocos2d: '%s' id= HTMLCanvasElement %s x %s", + 3007: "cocos2d: TextureCache dumpDebugInfo: %s textures, HTMLCanvasElement for %s KB (%s MB)", + 3103: "cc.Texture.addImage(): path should be non-null", + 3112: "cc.Texture.addImage(): path should be non-null", + 3113: "NSInternalInconsistencyException", + 3116: "WebGLRenderingContext.CLAMP_TO_EDGE should be used in NPOT textures", + 3117: "Mimpap texture only works in POT textures", + 3119: "Lazy init texture with image element failed due to image loading failure: %s", + 3120: "Loading texture with unsupported type: '%s'. Add '%s' into 'cc.macro.SUPPORT_TEXTURE_FORMATS' please.", + 3121: "Can't find a texture format supported by the current platform! Please add a fallback format in the editor.", + 3300: "Rect width exceeds maximum margin: %s", + 3400: "Rect height exceeds maximum margin: %s", + 3401: "Set texture with a url of image is not supported anymore. Please use cc.assetManager.loadRemote to load a texture first.", + 3500: "0 priority is forbidden for fixed priority since it's used for scene graph based priority.", + 3501: "Invalid listener type!", + 3502: "Can't set fixed priority with scene graph based listener.", + 3503: "Invalid parameters.", + 3504: "listener must be a cc.EventListener object when adding a fixed priority listener", + 3505: "The listener has been registered, please don't register it again.", + 3506: "Unsupported listener target.", + 3507: "Invalid scene graph priority!", + 3508: "If program goes here, there should be event in dispatch.", + 3509: "_inDispatch should be 1 here.", + 3510: "%s's scene graph node not contains in the parent's children", + 3511: "event is undefined", + 3600: "cc.Class will automatically call super constructor of %s, you should not call it manually.", + 3601: "The editor property 'playOnFocus' should be used with 'executeInEditMode' in class '%s'", + 3602: "Unknown editor property '%s' in class '%s'.", + 3603: "Use 'cc.Float' or 'cc.Integer' instead of 'cc.Number' please.", + 3604: "Can only indicate one type attribute for %s.", + 3605: "The default value of %s is not instance of %s.", + 3606: "No needs to indicate the '%s' attribute for %s, which its default value is type of %s.", + 3607: "The default value of %s must be an empty string.", + 3608: "The type of %s must be cc.String, not String.", + 3609: "The type of %s must be cc.Boolean, not Boolean.", + 3610: "The type of %s must be cc.Float or cc.Integer, not Number.", + 3611: "Can not indicate the '%s' attribute for %s, which its default value is type of %s.", + 3612: "%s Just set the default value to 'new %s()' and it will be handled properly.", + 3613: "'No need to use 'serializable: false' or 'editorOnly: true' for the getter of '%s.%s', every getter is actually non-serialized.", + 3614: "Should not define constructor for cc.Component %s.", + 3615: "Each script can have at most one Component.", + 3616: "Should not specify class name %s for Component which defines in project.", + 3617: "Can not instantiate CCClass '%s' with arguments.", + 3618: "ctor of '%s' can not be another CCClass", + 3619: "ctor of '%s' must be function type", + 3620: "this._super declared in '%s.%s' but no super method defined", + 3621: "Unknown type of %s.%s, maybe you want is '%s'.", + 3622: "Unknown type of %s.%s, property should be defined in 'properties' or 'ctor'", + 3623: "Can not use 'editor' attribute, '%s' not inherits from Components.", + 3624: "'%s' overrided '%s' but '%s' is defined as 'false' so the super method will not be called. You can set '%s' to null to disable this warning.", + 3625: "[isChildClassOf] superclass should be function type, not", + 3626: "Can't remove '%s' because '%s' depends on it.", + 3627: "Should not add renderer component (%s) to a Canvas node.", + 3628: "Should not add %s to a node which size is already used by its other component.", + 3633: "Properties function of '%s' should return an object!", + 3634: "Disallow to use '.' in property name", + 3635: "Default array must be empty, set default value of %s.%s to [], and initialize in 'onLoad' or 'ctor' please. (just like 'this.%s = [...];')", + 3636: "Do not set default value to non-empty object, unless the object defines its own 'clone' function. Set default value of %s.%s to null or {}, and initialize in 'onLoad' or 'ctor' please. (just like 'this.%s = {foo: bar};')", + 3637: "Can not declare %s.%s, it is already defined in the prototype of %s", + 3638: "'%s': the getter of '%s' is already defined!", + 3639: "Can not apply the specified attribute to the getter of '%s.%s', attribute index: %s", + 3640: "'%s': the setter of '%s' is already defined!", + 3641: "Can not construct %s because it contains object property.", + 3642: "Cannot define %s.%s because static member name can not be '%s'.", + 3643: "Can not define a member called 'constructor' in the class '%s', please use 'ctor' instead.", + 3644: "Please define 'type' parameter of %s.%s as the actual constructor.", + 3645: "Please define 'type' parameter of %s.%s as the constructor of %s.", + 3646: "Unknown 'type' parameter of %s.%s\uff1a%s", + 3647: "The length of range array must be equal or greater than 2", + 3648: "Can not declare %s.%s method, it is already defined in the properties of %s.", + 3649: "CCClass %s have conflict between its ctor and __ctor__.", + 3651: 'Can not call `_super` or `prototype.ctor` in ES6 Classes "%s", use `super` instead please.', + 3652: "Failed to `new %s()` under the hood, %s\nIt is used for getting default values declared in TypeScript in the first place.\nPlease ensure the constructor can be called during the script's initialization.", + 3653: 'Please do not specifiy "default" attribute in decorator of "%s" property in "%s" class. \nDefault value must be initialized at their declaration:\n \n// Before:\n@property({\n type: cc.SpriteFrame\n default: null // <--\n})\nmyProp;\n// After:\n@property({\n type: cc.SpriteFrame\n})\nmyProp = null; // <--', + 3654: 'Please specifiy a default value for "%s.%s" at its declaration:\n \n// Before:\n@property(...)\nmyProp;\n// After:\n@property(...)\nmyProp = 0;', + 3655: 'Can not specifiy "get" or "set" attribute in decorator for "%s" property in "%s" class. \nPlease use:\n \n@property(...)\nget %s () {\n ...\n}\n@property\nset %s (value) {\n ...\n}', + 3700: "internal error: _prefab is undefined", + 3701: "Failed to load prefab asset for node '%s'", + 3800: "The target can not be made persist because it's not a cc.Node or it doesn't have _id property.", + 3801: "The node can not be made persist because it's not under root node.", + 3802: "The node can not be made persist because it's not in current scene.", + 3803: "The target can not be made persist because it's not a cc.Node or it doesn't have _id property.", + 3804: "getComponent: Type must be non-nil", + 3805: "Can't add component '%s' because %s already contains the same component.", + 3806: "Can't add component '%s' to %s because it conflicts with the existing '%s' derived component.", + 3807: "addComponent: Failed to get class '%s'", + 3808: "addComponent: Should not add component ('%s') when the scripts are still loading.", + 3809: "addComponent: The component to add must be a constructor", + 3810: "addComponent: The component to add must be child class of cc.Component", + 3811: "_addComponentAt: The component to add must be a constructor", + 3812: "_addComponentAt: Index out of range", + 3813: "removeComponent: Component must be non-nil", + 3814: "Argument must be non-nil", + 3815: "Component not owned by this entity", + 3816: "Node '%s' is already activating", + 3817: "Sorry, the component of '%s' which with an index of %s is corrupted! It has been removed.", + 3818: "Failed to read or parse project.json", + 3819: "Warning: target element is not a DIV or CANVAS", + 3820: "The renderer doesn't support the renderMode %s", + 3821: "Cannot change hierarchy while activating or deactivating the parent.", + 3900: "Invalid clip to add", + 3901: "Invalid clip to remove", + 3902: "clip is defaultClip, set force to true to force remove clip and animation state", + 3903: "animation state is playing, set force to true to force stop and remove clip and animation state", + 3904: "motion path of target [%s] in prop [%s] frame [%s] is not valid", + 3905: "sprite frames must be an Array.", + 3906: "Can't find easing type [%s]", + 3907: "animator not added or already removed", + 3912: "already-playing", + 4003: "Label font size can't be shirnked less than 0!", + 4004: "force notify all fonts loaded!", + 4011: "Property spriteFrame of Font '%s' is invalid. Using system font instead.", + 4012: "The texture of Font '%s' must be already loaded on JSB. Using system font instead.", + 4013: "Sorry, lineHeight of system font not supported on JSB.", + 4200: "MaskType: IMAGE_STENCIL only support WebGL mode.", + 4201: "The alphaThreshold invalid in Canvas Mode.", + 4202: "The inverted invalid in Canvas Mode.", + 4300: "can not found the %s page.", + 4400: "Invalid RichText img tag! The sprite frame name can't be found in the ImageAtlas!", + 4600: "Script attached to '%s' is missing or invalid.", + 4700: "The dom control is not created!", + 4800: "unknown asset type", + 4901: "loadRes: should not specify the extname in %s %s", + 4902: "No need to release non-cached asset.", + 4914: "Resources url '%s' does not exist.", + 4915: "Pack indices and data do not match in size", + 4916: "Failed to download package for %s", + 4921: "Invalid pipe or invalid index provided!", + 4922: "The pipe to be inserted is already in the pipeline!", + 4923: "Uuid Loader: Parse asset [ %s ] failed : %s", + 4924: "JSON Loader: Input item doesn't contain string content", + 4925: "Uuid Loader: Deserialize asset [ %s ] failed : %s", + 4926: "Audio Downloader: no web audio context.", + 4927: "Audio Downloader: audio not supported on this browser!", + 4928: "Load %s failed!", + 4929: "Load Webp ( %s ) failed", + 4930: "Load image ( %s ) failed", + 4932: 'Since v1.10, for any atlas ("%s") in the "resources" directory, it is not possible to find the contained SpriteFrames via `loadRes`, `getRes` or `releaseRes`. Load the SpriteAtlas first and then use `spriteAtlas.getSpriteFrame(name)` instead please.', + 4933: "Download Font [ %s ] failed, using Arial or system default font instead", + 5e3: "object already destroyed", + 5001: "object not yet destroyed", + 5100: "Not a plist file!", + 5200: "Warning: localStorage isn't enabled. Please confirm browser cookie or privacy option", + 5201: "browser don't support web audio", + 5202: "This feature supports WebGL render mode only.", + 5300: "Type of target to deserialize not matched with data: target is %s, data is %s", + 5301: "Can not find script '%s'", + 5302: "Can not find class '%s'", + 5303: "Failed to deserialize %s, missing _deserialize function.", + 5304: "Unable to deserialize version %s data.", + 5402: "cc.js.addon called on non-object:", + 5403: "cc.js.mixin: arguments must be type object:", + 5404: "The base class to extend from must be non-nil", + 5405: "The class to extend must be non-nil", + 5406: "Class should be extended before assigning any prototype members.", + 5500: "'notify' can not be used in 'get/set' !", + 5501: "'notify' must be used with 'default' !", + 5507: "The 'default' attribute of '%s.%s' must be an array", + 5508: "Invalid type of %s.%s", + 5510: "The 'type' attribute of '%s.%s' can not be 'Number', use cc.Float or cc.Integer instead please.", + 5511: "The 'type' attribute of '%s.%s' is undefined when loading script", + 5512: "Can not serialize '%s.%s' because the specified type is anonymous, please provide a class name or set the 'serializable' attribute of '%s.%s' to 'false'.", + 5513: "The 'default' value of '%s.%s' should not be used with a 'get' function.", + 5514: "The 'default' value of '%s.%s' should not be used with a 'set' function.", + 5515: "The 'default' value of '%s.%s' can not be an constructor. Set default to null please.", + 5516: "Property '%s.%s' must define at least one of 'default', 'get' or 'set'.", + 5517: "'%s.%s' hides inherited property '%s.%s'. To make the current property override that implementation, add the `override: true` attribute please.", + 5601: "Can not get current scene.", + 5602: "Scene is destroyed", + 5603: "reference node is destroyed", + 5700: "no %s or %s on %s", + 5800: "%s.lerp not yet implemented.", + 5801: "%s.clone not yet implemented.", + 5802: "%s.equals not yet implemented.", + 5900: "MotionStreak only support WebGL mode.", + 5901: "cc.MotionStreak.getOpacity has not been supported.", + 5902: "cc.MotionStreak.setOpacity has not been supported.", + 6e3: "Custom should not be false if file is not specified.", + 6001: "The new %s must not be NaN", + 6017: "Incomplete or corrupt PNG file", + 6018: "Invalid filter algorithm: %s", + 6019: "Invalid byte order value.", + 6020: "You forgot your towel!", + 6021: "Unknown Field Tag: %s", + 6022: "Too many bits requested", + 6023: "No bits requested", + 6024: "Cannot recover from missing StripByteCounts", + 6025: "Cannot handle sub-byte bits per sample", + 6026: "Cannot handle sub-byte bits per pixel", + 6027: "Palette image missing color map", + 6028: "Unknown Photometric Interpretation: %s", + 6029: "Unkown error", + 6030: "cc.ParticleSystem: error decoding or ungzipping textureImageData in plist '%s'", + 6031: "cc.ParticleSystem: unknown image format with Data in plist %s", + 6032: "cc.ParticleSystem.initWithDictionary() : error loading the texture in plist '%s'", + 6400: "asset.url is not usable in core process", + 6402: "AssetLibrary has already been initialized!", + 6500: "Widget target must be one of the parent nodes of it", + 6600: "collider not added or already removed", + 6601: "Can't find testFunc for (%s, $s).", + 6700: "Can't init canvas '%s' because it conflicts with the existing '%s', the scene should only have one active canvas at the same time.", + 6800: "Callback of event must be non-nil", + 6801: "The message must be provided", + 6900: "The thing you want to instantiate must be an object", + 6901: "The thing you want to instantiate is nil", + 6902: "The thing you want to instantiate is destroyed", + 6903: "The instantiate method for given asset do not implemented", + 6904: "Can not instantiate array", + 6905: "Can not instantiate DOM element", + 7100: "%s already defined in Enum.", + 7101: "Sorry, 'cc.Enum' not available on this platform, please report this error here: https://github.com/cocos-creator/engine/issues/new", + 7200: "Method 'initWithTMXFile' is no effect now, please set property 'tmxAsset' instead.", + 7201: "Method 'initWithXML' is no effect now, please set property 'tmxAsset' instead.", + 7202: "Add component TiledLayer into node failed.", + 7203: "Property 'mapLoaded' is unused now. Please write the logic to the callback 'start'.", + 7210: "TMX Hexa zOrder not supported", + 7211: "TMX invalid value", + 7215: "cocos2d: Warning: TMX Layer %s has no tiles", + 7216: "cocos2d: TMXFormat: Unsupported TMX version: %s", + 7217: "cocos2d: TMXFomat: Unsupported orientation: %s", + 7218: "cc.TMXMapInfo.parseXMLFile(): unsupported compression method", + 7219: "cc.TMXMapInfo.parseXMLFile(): Only base64 and/or gzip/zlib maps are supported", + 7221: "cc.TMXMapInfo.parseXMLFile(): Texture '%s' not found.", + 7222: "Parse %s failed.", + 7236: "cc.TMXLayer.getTileAt(): TMXLayer: the tiles map has been released", + 7237: "cc.TMXLayer.getTileGIDAt(): TMXLayer: the tiles map has been released", + 7238: "cc.TMXLayer.setTileGID(): TMXLayer: the tiles map has been released", + 7239: "cc.TMXLayer.setTileGID(): invalid gid: %s", + 7240: "cc.TMXLayer.getTileFlagsAt(): TMXLayer: the tiles map has been released", + 7241: "cc.TiledMap.initWithXML(): Map not found. Please check the filename.", + 7401: "Failed to set _defaultArmatureIndex for '%s' because the index is out of range.", + 7402: "Failed to set _animationIndex for '%s' because the index is out of range.", + 7501: "Failed to set _defaultSkinIndex for '%s' because the index is out of range.", + 7502: "Failed to set _animationIndex for '%s' because its skeletonData is invalid.", + 7503: "Failed to set _animationIndex for '%s' because the index is out of range.", + 7504: "Can not render dynamic created SkeletonData", + 7506: "Failed to load spine atlas '$s'", + 7507: "Please re-import '%s' because its textures is not initialized! (This workflow will be improved in the future.)", + 7508: "The atlas asset of '%s' is not exists!", + 7509: "Spine: Animation not found: %s", + 7510: "Spine: Animation not found: %s", + 7600: "The context of RenderTexture is invalid.", + 7601: "cc.RenderTexture._initWithWidthAndHeightForWebGL() : only RGB and RGBA formats are valid for a render texture;", + 7602: "Could not attach texture to the framebuffer", + 7603: "clearDepth isn't supported on Cocos2d-Html5", + 7604: "saveToFile isn't supported on Cocos2d-Html5", + 7605: "newCCImage isn't supported on Cocos2d-Html5", + 7700: "On the web is always keep the aspect ratio", + 7701: "Can't know status", + 7702: "Video player's duration is not ready to get now!", + 7800: "Web does not support loading", + 7801: "Web does not support query history", + 7802: "Web does not support query history", + 7803: "The current browser does not support the GoBack", + 7804: "The current browser does not support the GoForward", + 7805: "Web does not support zoom", + 7900: "cc.math.Matrix3.assign(): current matrix equals matIn", + 7901: "cc.math.mat4Assign(): pOut equals pIn", + 7902: "cc.mat.Matrix4.assignFrom(): mat4 equals current matrix", + 7903: "cc.math.Matrix4 equal: pMat1 and pMat2 are same object.", + 7904: "cc.math.Matrix4.extractPlane: Invalid plane index", + 7905: "cc.math.mat4Assign(): pOut equals pIn", + 7906: "cc.mat.Matrix4.assignFrom(): mat4 equals current matrix", + 7907: "cc.math.Matrix4 equals: pMat1 and pMat2 are same object.", + 7908: "Invalid matrix mode specified", + 7909: "current quaternion is an invalid value", + 8e3: "Can't handle this field type or size", + 8001: "No bytes requested", + 8002: "Too many bytes requested", + 8003: "Missing StripByteCounts!", + 8103: "cc.GLProgram.link(): Cannot link invalid program", + 8104: "cocos2d: ERROR: Failed to link program: %s", + 8105: "cocos2d: cc.shaderCache._loadDefaultShader, error shader type", + 8106: "Please load the resource firset : %s", + 8107: "cc.GLProgram.getUniformLocationForName(): uniform name should be non-null", + 8108: "cc.GLProgram.getUniformLocationForName(): Invalid operation. Cannot get uniform location when program is not initialized", + 8109: "modelView matrix is undefined.", + 8200: "Please set node's active instead of rigidbody's enabled.", + 8300: "Should only one camera exists, please check your project.", + 8301: "Camera does not support Canvas Mode.", + 8400: "Wrong type arguments, 'filePath' must be a String.", + 8401: "Since 1.10, `%s` accept %s instance directly, not a URL string. Please directly reference the %s object in your script, or load %s by loader first. Don't use %s's URL anymore.", + 9e3: "Stencil manager does not support level bigger than %d in this device.", + 9001: "Stencil manager is already empty, cannot pop any mask.", + 9100: "LabelAtlas '%s' cannot be loaded, raw texture does not exist.", + 9101: "LabelAtlas '%s' cannot be loaded, fnt data does not exist.", + 9102: "Program not support highp precision, will change to mediump.", + 9103: "%s : Failed to set property [%s], property not found.", + 9104: "%s : Failed to define [%s], define not found.", + 9105: "%s : Failed to set property [%s], property length not correct.", + 9106: "%s : Set property [%s] warning : should transform object to ArrayBuffer.", + 9107: "%s : illegal property: [%s], myabe defined an unused property;", + 9200: "cc.view.enableAntiAlias is deprecated, please use cc.Texture2D.setFilters instead", + "0100": "%s not yet implemented." + }; + }), {} ], + 2: [ (function(require, module, exports) { + "use strict"; + require("../core/platform/CCClass"); + var misc = require("../core/utils/misc"); + cc.Action = cc.Class({ + name: "cc.Action", + ctor: function ctor() { + this.originalTarget = null; + this.target = null; + this.tag = cc.Action.TAG_INVALID; + }, + clone: function clone() { + var action = new cc.Action(); + action.originalTarget = null; + action.target = null; + action.tag = this.tag; + return action; + }, + isDone: function isDone() { + return true; + }, + startWithTarget: function startWithTarget(target) { + this.originalTarget = target; + this.target = target; + }, + stop: function stop() { + this.target = null; + }, + step: function step(dt) { + cc.logID(1006); + }, + update: function update(dt) { + cc.logID(1007); + }, + getTarget: function getTarget() { + return this.target; + }, + setTarget: function setTarget(target) { + this.target = target; + }, + getOriginalTarget: function getOriginalTarget() { + return this.originalTarget; + }, + setOriginalTarget: function setOriginalTarget(originalTarget) { + this.originalTarget = originalTarget; + }, + getTag: function getTag() { + return this.tag; + }, + setTag: function setTag(tag) { + this.tag = tag; + }, + retain: function retain() {}, + release: function release() {} + }); + cc.Action.TAG_INVALID = -1; + cc.FiniteTimeAction = cc.Class({ + name: "cc.FiniteTimeAction", + extends: cc.Action, + ctor: function ctor() { + this._duration = 0; + }, + getDuration: function getDuration() { + return this._duration * (this._timesForRepeat || 1); + }, + setDuration: function setDuration(duration) { + this._duration = duration; + }, + reverse: function reverse() { + cc.logID(1008); + return null; + }, + clone: function clone() { + return new cc.FiniteTimeAction(); + } + }); + cc.Speed = cc.Class({ + name: "cc.Speed", + extends: cc.Action, + ctor: function ctor(action, speed) { + this._speed = 0; + this._innerAction = null; + action && this.initWithAction(action, speed); + }, + getSpeed: function getSpeed() { + return this._speed; + }, + setSpeed: function setSpeed(speed) { + this._speed = speed; + }, + initWithAction: function initWithAction(action, speed) { + if (!action) { + cc.errorID(1021); + return false; + } + this._innerAction = action; + this._speed = speed; + return true; + }, + clone: function clone() { + var action = new cc.Speed(); + action.initWithAction(this._innerAction.clone(), this._speed); + return action; + }, + startWithTarget: function startWithTarget(target) { + cc.Action.prototype.startWithTarget.call(this, target); + this._innerAction.startWithTarget(target); + }, + stop: function stop() { + this._innerAction.stop(); + cc.Action.prototype.stop.call(this); + }, + step: function step(dt) { + this._innerAction.step(dt * this._speed); + }, + isDone: function isDone() { + return this._innerAction.isDone(); + }, + reverse: function reverse() { + return new cc.Speed(this._innerAction.reverse(), this._speed); + }, + setInnerAction: function setInnerAction(action) { + this._innerAction !== action && (this._innerAction = action); + }, + getInnerAction: function getInnerAction() { + return this._innerAction; + } + }); + cc.speed = function(action, speed) { + return new cc.Speed(action, speed); + }; + cc.Follow = cc.Class({ + name: "cc.Follow", + extends: cc.Action, + ctor: function ctor(followedNode, rect) { + this._followedNode = null; + this._boundarySet = false; + this._boundaryFullyCovered = false; + this._halfScreenSize = null; + this._fullScreenSize = null; + this.leftBoundary = 0; + this.rightBoundary = 0; + this.topBoundary = 0; + this.bottomBoundary = 0; + this._worldRect = cc.rect(0, 0, 0, 0); + followedNode && (rect ? this.initWithTarget(followedNode, rect) : this.initWithTarget(followedNode)); + }, + clone: function clone() { + var action = new cc.Follow(); + var locRect = this._worldRect; + var rect = new cc.Rect(locRect.x, locRect.y, locRect.width, locRect.height); + action.initWithTarget(this._followedNode, rect); + return action; + }, + isBoundarySet: function isBoundarySet() { + return this._boundarySet; + }, + setBoundarySet: function setBoundarySet(value) { + this._boundarySet = value; + }, + setBoudarySet: function setBoudarySet(value) { + this.setBoundarySet(value); + }, + initWithTarget: function initWithTarget(followedNode, rect) { + if (!followedNode) { + cc.errorID(1022); + return false; + } + var _this = this; + rect = rect || cc.rect(0, 0, 0, 0); + _this._followedNode = followedNode; + _this._worldRect = rect; + _this._boundarySet = !(0 === rect.width && 0 === rect.height); + _this._boundaryFullyCovered = false; + var winSize = cc.winSize; + _this._fullScreenSize = cc.v2(winSize.width, winSize.height); + _this._halfScreenSize = _this._fullScreenSize.mul(.5); + if (_this._boundarySet) { + _this.leftBoundary = -(rect.x + rect.width - _this._fullScreenSize.x); + _this.rightBoundary = -rect.x; + _this.topBoundary = -rect.y; + _this.bottomBoundary = -(rect.y + rect.height - _this._fullScreenSize.y); + _this.rightBoundary < _this.leftBoundary && (_this.rightBoundary = _this.leftBoundary = (_this.leftBoundary + _this.rightBoundary) / 2); + _this.topBoundary < _this.bottomBoundary && (_this.topBoundary = _this.bottomBoundary = (_this.topBoundary + _this.bottomBoundary) / 2); + _this.topBoundary === _this.bottomBoundary && _this.leftBoundary === _this.rightBoundary && (_this._boundaryFullyCovered = true); + } + return true; + }, + step: function step(dt) { + var targetWorldPos = this.target.convertToWorldSpaceAR(cc.Vec2.ZERO); + var followedWorldPos = this._followedNode.convertToWorldSpaceAR(cc.Vec2.ZERO); + var delta = targetWorldPos.sub(followedWorldPos); + var tempPos = this.target.parent.convertToNodeSpaceAR(delta.add(this._halfScreenSize)); + if (this._boundarySet) { + if (this._boundaryFullyCovered) return; + this.target.setPosition(misc.clampf(tempPos.x, this.leftBoundary, this.rightBoundary), misc.clampf(tempPos.y, this.bottomBoundary, this.topBoundary)); + } else this.target.setPosition(tempPos.x, tempPos.y); + }, + isDone: function isDone() { + return !this._followedNode.activeInHierarchy; + }, + stop: function stop() { + this.target = null; + cc.Action.prototype.stop.call(this); + } + }); + cc.follow = function(followedNode, rect) { + return new cc.Follow(followedNode, rect); + }; + }), { + "../core/platform/CCClass": 240, + "../core/utils/misc": 325 + } ], + 3: [ (function(require, module, exports) { + "use strict"; + function cardinalSplineAt(p0, p1, p2, p3, tension, t) { + var t2 = t * t; + var t3 = t2 * t; + var s = (1 - tension) / 2; + var b1 = s * (2 * t2 - t3 - t); + var b2 = s * (-t3 + t2) + (2 * t3 - 3 * t2 + 1); + var b3 = s * (t3 - 2 * t2 + t) + (-2 * t3 + 3 * t2); + var b4 = s * (t3 - t2); + var x = p0.x * b1 + p1.x * b2 + p2.x * b3 + p3.x * b4; + var y = p0.y * b1 + p1.y * b2 + p2.y * b3 + p3.y * b4; + return cc.v2(x, y); + } + function getControlPointAt(controlPoints, pos) { + var p = Math.min(controlPoints.length - 1, Math.max(pos, 0)); + return controlPoints[p]; + } + function reverseControlPoints(controlPoints) { + var newArray = []; + for (var i = controlPoints.length - 1; i >= 0; i--) newArray.push(cc.v2(controlPoints[i].x, controlPoints[i].y)); + return newArray; + } + function cloneControlPoints(controlPoints) { + var newArray = []; + for (var i = 0; i < controlPoints.length; i++) newArray.push(cc.v2(controlPoints[i].x, controlPoints[i].y)); + return newArray; + } + cc.CardinalSplineTo = cc.Class({ + name: "cc.CardinalSplineTo", + extends: cc.ActionInterval, + ctor: function ctor(duration, points, tension) { + this._points = []; + this._deltaT = 0; + this._tension = 0; + this._previousPosition = null; + this._accumulatedDiff = null; + void 0 !== tension && cc.CardinalSplineTo.prototype.initWithDuration.call(this, duration, points, tension); + }, + initWithDuration: function initWithDuration(duration, points, tension) { + if (!points || 0 === points.length) { + cc.errorID(1024); + return false; + } + if (cc.ActionInterval.prototype.initWithDuration.call(this, duration)) { + this.setPoints(points); + this._tension = tension; + return true; + } + return false; + }, + clone: function clone() { + var action = new cc.CardinalSplineTo(); + action.initWithDuration(this._duration, cloneControlPoints(this._points), this._tension); + return action; + }, + startWithTarget: function startWithTarget(target) { + cc.ActionInterval.prototype.startWithTarget.call(this, target); + this._deltaT = 1 / (this._points.length - 1); + this._previousPosition = cc.v2(this.target.x, this.target.y); + this._accumulatedDiff = cc.v2(0, 0); + }, + update: function update(dt) { + dt = this._computeEaseTime(dt); + var p, lt; + var ps = this._points; + if (1 === dt) { + p = ps.length - 1; + lt = 1; + } else { + var locDT = this._deltaT; + p = 0 | dt / locDT; + lt = (dt - locDT * p) / locDT; + } + var newPos = cardinalSplineAt(getControlPointAt(ps, p - 1), getControlPointAt(ps, p - 0), getControlPointAt(ps, p + 1), getControlPointAt(ps, p + 2), this._tension, lt); + if (cc.macro.ENABLE_STACKABLE_ACTIONS) { + var tempX, tempY; + tempX = this.target.x - this._previousPosition.x; + tempY = this.target.y - this._previousPosition.y; + if (0 !== tempX || 0 !== tempY) { + var locAccDiff = this._accumulatedDiff; + tempX = locAccDiff.x + tempX; + tempY = locAccDiff.y + tempY; + locAccDiff.x = tempX; + locAccDiff.y = tempY; + newPos.x += tempX; + newPos.y += tempY; + } + } + this.updatePosition(newPos); + }, + reverse: function reverse() { + var reversePoints = reverseControlPoints(this._points); + return cc.cardinalSplineTo(this._duration, reversePoints, this._tension); + }, + updatePosition: function updatePosition(newPos) { + this.target.setPosition(newPos); + this._previousPosition = newPos; + }, + getPoints: function getPoints() { + return this._points; + }, + setPoints: function setPoints(points) { + this._points = points; + } + }); + cc.cardinalSplineTo = function(duration, points, tension) { + return new cc.CardinalSplineTo(duration, points, tension); + }; + cc.CardinalSplineBy = cc.Class({ + name: "cc.CardinalSplineBy", + extends: cc.CardinalSplineTo, + ctor: function ctor(duration, points, tension) { + this._startPosition = cc.v2(0, 0); + void 0 !== tension && this.initWithDuration(duration, points, tension); + }, + startWithTarget: function startWithTarget(target) { + cc.CardinalSplineTo.prototype.startWithTarget.call(this, target); + this._startPosition.x = target.x; + this._startPosition.y = target.y; + }, + reverse: function reverse() { + var copyConfig = this._points.slice(); + var current; + var p = copyConfig[0]; + for (var i = 1; i < copyConfig.length; ++i) { + current = copyConfig[i]; + copyConfig[i] = current.sub(p); + p = current; + } + var reverseArray = reverseControlPoints(copyConfig); + p = reverseArray[reverseArray.length - 1]; + reverseArray.pop(); + p.x = -p.x; + p.y = -p.y; + reverseArray.unshift(p); + for (var i = 1; i < reverseArray.length; ++i) { + current = reverseArray[i]; + current.x = -current.x; + current.y = -current.y; + current.x += p.x; + current.y += p.y; + reverseArray[i] = current; + p = current; + } + return cc.cardinalSplineBy(this._duration, reverseArray, this._tension); + }, + updatePosition: function updatePosition(newPos) { + var pos = this._startPosition; + var posX = newPos.x + pos.x; + var posY = newPos.y + pos.y; + this._previousPosition.x = posX; + this._previousPosition.y = posY; + this.target.setPosition(posX, posY); + }, + clone: function clone() { + var a = new cc.CardinalSplineBy(); + a.initWithDuration(this._duration, cloneControlPoints(this._points), this._tension); + return a; + } + }); + cc.cardinalSplineBy = function(duration, points, tension) { + return new cc.CardinalSplineBy(duration, points, tension); + }; + cc.CatmullRomTo = cc.Class({ + name: "cc.CatmullRomTo", + extends: cc.CardinalSplineTo, + ctor: function ctor(dt, points) { + points && this.initWithDuration(dt, points); + }, + initWithDuration: function initWithDuration(dt, points) { + return cc.CardinalSplineTo.prototype.initWithDuration.call(this, dt, points, .5); + }, + clone: function clone() { + var action = new cc.CatmullRomTo(); + action.initWithDuration(this._duration, cloneControlPoints(this._points)); + return action; + } + }); + cc.catmullRomTo = function(dt, points) { + return new cc.CatmullRomTo(dt, points); + }; + cc.CatmullRomBy = cc.Class({ + name: "cc.CatmullRomBy", + extends: cc.CardinalSplineBy, + ctor: function ctor(dt, points) { + points && this.initWithDuration(dt, points); + }, + initWithDuration: function initWithDuration(dt, points) { + return cc.CardinalSplineTo.prototype.initWithDuration.call(this, dt, points, .5); + }, + clone: function clone() { + var action = new cc.CatmullRomBy(); + action.initWithDuration(this._duration, cloneControlPoints(this._points)); + return action; + } + }); + cc.catmullRomBy = function(dt, points) { + return new cc.CatmullRomBy(dt, points); + }; + }), {} ], + 4: [ (function(require, module, exports) { + "use strict"; + cc.easeIn = function(rate) { + return { + _rate: rate, + easing: function easing(dt) { + return Math.pow(dt, this._rate); + }, + reverse: function reverse() { + return cc.easeIn(1 / this._rate); + } + }; + }; + cc.easeOut = function(rate) { + return { + _rate: rate, + easing: function easing(dt) { + return Math.pow(dt, 1 / this._rate); + }, + reverse: function reverse() { + return cc.easeOut(1 / this._rate); + } + }; + }; + cc.easeInOut = function(rate) { + return { + _rate: rate, + easing: function easing(dt) { + dt *= 2; + return dt < 1 ? .5 * Math.pow(dt, this._rate) : 1 - .5 * Math.pow(2 - dt, this._rate); + }, + reverse: function reverse() { + return cc.easeInOut(this._rate); + } + }; + }; + var _easeExponentialInObj = { + easing: function easing(dt) { + return 0 === dt ? 0 : Math.pow(2, 10 * (dt - 1)); + }, + reverse: function reverse() { + return _easeExponentialOutObj; + } + }; + cc.easeExponentialIn = function() { + return _easeExponentialInObj; + }; + var _easeExponentialOutObj = { + easing: function easing(dt) { + return 1 === dt ? 1 : 1 - Math.pow(2, -10 * dt); + }, + reverse: function reverse() { + return _easeExponentialInObj; + } + }; + cc.easeExponentialOut = function() { + return _easeExponentialOutObj; + }; + var _easeExponentialInOutObj = { + easing: function easing(dt) { + if (1 !== dt && 0 !== dt) { + dt *= 2; + return dt < 1 ? .5 * Math.pow(2, 10 * (dt - 1)) : .5 * (2 - Math.pow(2, -10 * (dt - 1))); + } + return dt; + }, + reverse: function reverse() { + return _easeExponentialInOutObj; + } + }; + cc.easeExponentialInOut = function() { + return _easeExponentialInOutObj; + }; + var _easeSineInObj = { + easing: function easing(dt) { + return 0 === dt || 1 === dt ? dt : -1 * Math.cos(dt * Math.PI / 2) + 1; + }, + reverse: function reverse() { + return _easeSineOutObj; + } + }; + cc.easeSineIn = function() { + return _easeSineInObj; + }; + var _easeSineOutObj = { + easing: function easing(dt) { + return 0 === dt || 1 === dt ? dt : Math.sin(dt * Math.PI / 2); + }, + reverse: function reverse() { + return _easeSineInObj; + } + }; + cc.easeSineOut = function() { + return _easeSineOutObj; + }; + var _easeSineInOutObj = { + easing: function easing(dt) { + return 0 === dt || 1 === dt ? dt : -.5 * (Math.cos(Math.PI * dt) - 1); + }, + reverse: function reverse() { + return _easeSineInOutObj; + } + }; + cc.easeSineInOut = function() { + return _easeSineInOutObj; + }; + var _easeElasticInObj = { + easing: function easing(dt) { + if (0 === dt || 1 === dt) return dt; + dt -= 1; + return -Math.pow(2, 10 * dt) * Math.sin((dt - .075) * Math.PI * 2 / .3); + }, + reverse: function reverse() { + return _easeElasticOutObj; + } + }; + cc.easeElasticIn = function(period) { + if (period && .3 !== period) return { + _period: period, + easing: function easing(dt) { + if (0 === dt || 1 === dt) return dt; + dt -= 1; + return -Math.pow(2, 10 * dt) * Math.sin((dt - this._period / 4) * Math.PI * 2 / this._period); + }, + reverse: function reverse() { + return cc.easeElasticOut(this._period); + } + }; + return _easeElasticInObj; + }; + var _easeElasticOutObj = { + easing: function easing(dt) { + return 0 === dt || 1 === dt ? dt : Math.pow(2, -10 * dt) * Math.sin((dt - .075) * Math.PI * 2 / .3) + 1; + }, + reverse: function reverse() { + return _easeElasticInObj; + } + }; + cc.easeElasticOut = function(period) { + if (period && .3 !== period) return { + _period: period, + easing: function easing(dt) { + return 0 === dt || 1 === dt ? dt : Math.pow(2, -10 * dt) * Math.sin((dt - this._period / 4) * Math.PI * 2 / this._period) + 1; + }, + reverse: function reverse() { + return cc.easeElasticIn(this._period); + } + }; + return _easeElasticOutObj; + }; + cc.easeElasticInOut = function(period) { + period = period || .3; + return { + _period: period, + easing: function easing(dt) { + var newT = 0; + var locPeriod = this._period; + if (0 === dt || 1 === dt) newT = dt; else { + dt *= 2; + locPeriod || (locPeriod = this._period = .3 * 1.5); + var s = locPeriod / 4; + dt -= 1; + newT = dt < 0 ? -.5 * Math.pow(2, 10 * dt) * Math.sin((dt - s) * Math.PI * 2 / locPeriod) : Math.pow(2, -10 * dt) * Math.sin((dt - s) * Math.PI * 2 / locPeriod) * .5 + 1; + } + return newT; + }, + reverse: function reverse() { + return cc.easeElasticInOut(this._period); + } + }; + }; + function _bounceTime(time1) { + if (time1 < 1 / 2.75) return 7.5625 * time1 * time1; + if (time1 < 2 / 2.75) { + time1 -= 1.5 / 2.75; + return 7.5625 * time1 * time1 + .75; + } + if (time1 < 2.5 / 2.75) { + time1 -= 2.25 / 2.75; + return 7.5625 * time1 * time1 + .9375; + } + time1 -= 2.625 / 2.75; + return 7.5625 * time1 * time1 + .984375; + } + var _easeBounceInObj = { + easing: function easing(dt) { + return 1 - _bounceTime(1 - dt); + }, + reverse: function reverse() { + return _easeBounceOutObj; + } + }; + cc.easeBounceIn = function() { + return _easeBounceInObj; + }; + var _easeBounceOutObj = { + easing: function easing(dt) { + return _bounceTime(dt); + }, + reverse: function reverse() { + return _easeBounceInObj; + } + }; + cc.easeBounceOut = function() { + return _easeBounceOutObj; + }; + var _easeBounceInOutObj = { + easing: function easing(time1) { + var newT; + if (time1 < .5) { + time1 *= 2; + newT = .5 * (1 - _bounceTime(1 - time1)); + } else newT = .5 * _bounceTime(2 * time1 - 1) + .5; + return newT; + }, + reverse: function reverse() { + return _easeBounceInOutObj; + } + }; + cc.easeBounceInOut = function() { + return _easeBounceInOutObj; + }; + var _easeBackInObj = { + easing: function easing(time1) { + var overshoot = 1.70158; + return 0 === time1 || 1 === time1 ? time1 : time1 * time1 * ((overshoot + 1) * time1 - overshoot); + }, + reverse: function reverse() { + return _easeBackOutObj; + } + }; + cc.easeBackIn = function() { + return _easeBackInObj; + }; + var _easeBackOutObj = { + easing: function easing(time1) { + if (0 === time1) return 0; + var overshoot = 1.70158; + time1 -= 1; + return time1 * time1 * ((overshoot + 1) * time1 + overshoot) + 1; + }, + reverse: function reverse() { + return _easeBackInObj; + } + }; + cc.easeBackOut = function() { + return _easeBackOutObj; + }; + var _easeBackInOutObj = { + easing: function easing(time1) { + var overshoot = 2.5949095; + time1 *= 2; + if (time1 < 1) return time1 * time1 * ((overshoot + 1) * time1 - overshoot) / 2; + time1 -= 2; + return time1 * time1 * ((overshoot + 1) * time1 + overshoot) / 2 + 1; + }, + reverse: function reverse() { + return _easeBackInOutObj; + } + }; + cc.easeBackInOut = function() { + return _easeBackInOutObj; + }; + cc.easeBezierAction = function(a, b, c, d) { + return { + easing: function easing(t) { + return Math.pow(1 - t, 3) * a + 3 * t * Math.pow(1 - t, 2) * b + 3 * Math.pow(t, 2) * (1 - t) * c + Math.pow(t, 3) * d; + }, + reverse: function reverse() { + return cc.easeBezierAction(d, c, b, a); + } + }; + }; + var _easeQuadraticActionIn = { + easing: function easing(time) { + return Math.pow(time, 2); + }, + reverse: function reverse() { + return _easeQuadraticActionIn; + } + }; + cc.easeQuadraticActionIn = function() { + return _easeQuadraticActionIn; + }; + var _easeQuadraticActionOut = { + easing: function easing(time) { + return -time * (time - 2); + }, + reverse: function reverse() { + return _easeQuadraticActionOut; + } + }; + cc.easeQuadraticActionOut = function() { + return _easeQuadraticActionOut; + }; + var _easeQuadraticActionInOut = { + easing: function easing(time) { + var resultTime = time; + time *= 2; + if (time < 1) resultTime = time * time * .5; else { + --time; + resultTime = -.5 * (time * (time - 2) - 1); + } + return resultTime; + }, + reverse: function reverse() { + return _easeQuadraticActionInOut; + } + }; + cc.easeQuadraticActionInOut = function() { + return _easeQuadraticActionInOut; + }; + var _easeQuarticActionIn = { + easing: function easing(time) { + return time * time * time * time; + }, + reverse: function reverse() { + return _easeQuarticActionIn; + } + }; + cc.easeQuarticActionIn = function() { + return _easeQuarticActionIn; + }; + var _easeQuarticActionOut = { + easing: function easing(time) { + time -= 1; + return -(time * time * time * time - 1); + }, + reverse: function reverse() { + return _easeQuarticActionOut; + } + }; + cc.easeQuarticActionOut = function() { + return _easeQuarticActionOut; + }; + var _easeQuarticActionInOut = { + easing: function easing(time) { + time *= 2; + if (time < 1) return .5 * time * time * time * time; + time -= 2; + return -.5 * (time * time * time * time - 2); + }, + reverse: function reverse() { + return _easeQuarticActionInOut; + } + }; + cc.easeQuarticActionInOut = function() { + return _easeQuarticActionInOut; + }; + var _easeQuinticActionIn = { + easing: function easing(time) { + return time * time * time * time * time; + }, + reverse: function reverse() { + return _easeQuinticActionIn; + } + }; + cc.easeQuinticActionIn = function() { + return _easeQuinticActionIn; + }; + var _easeQuinticActionOut = { + easing: function easing(time) { + time -= 1; + return time * time * time * time * time + 1; + }, + reverse: function reverse() { + return _easeQuinticActionOut; + } + }; + cc.easeQuinticActionOut = function() { + return _easeQuinticActionOut; + }; + var _easeQuinticActionInOut = { + easing: function easing(time) { + time *= 2; + if (time < 1) return .5 * time * time * time * time * time; + time -= 2; + return .5 * (time * time * time * time * time + 2); + }, + reverse: function reverse() { + return _easeQuinticActionInOut; + } + }; + cc.easeQuinticActionInOut = function() { + return _easeQuinticActionInOut; + }; + var _easeCircleActionIn = { + easing: function easing(time) { + return -1 * (Math.sqrt(1 - time * time) - 1); + }, + reverse: function reverse() { + return _easeCircleActionIn; + } + }; + cc.easeCircleActionIn = function() { + return _easeCircleActionIn; + }; + var _easeCircleActionOut = { + easing: function easing(time) { + time -= 1; + return Math.sqrt(1 - time * time); + }, + reverse: function reverse() { + return _easeCircleActionOut; + } + }; + cc.easeCircleActionOut = function() { + return _easeCircleActionOut; + }; + var _easeCircleActionInOut = { + easing: function easing(time) { + time *= 2; + if (time < 1) return -.5 * (Math.sqrt(1 - time * time) - 1); + time -= 2; + return .5 * (Math.sqrt(1 - time * time) + 1); + }, + reverse: function reverse() { + return _easeCircleActionInOut; + } + }; + cc.easeCircleActionInOut = function() { + return _easeCircleActionInOut; + }; + var _easeCubicActionIn = { + easing: function easing(time) { + return time * time * time; + }, + reverse: function reverse() { + return _easeCubicActionIn; + } + }; + cc.easeCubicActionIn = function() { + return _easeCubicActionIn; + }; + var _easeCubicActionOut = { + easing: function easing(time) { + time -= 1; + return time * time * time + 1; + }, + reverse: function reverse() { + return _easeCubicActionOut; + } + }; + cc.easeCubicActionOut = function() { + return _easeCubicActionOut; + }; + var _easeCubicActionInOut = { + easing: function easing(time) { + time *= 2; + if (time < 1) return .5 * time * time * time; + time -= 2; + return .5 * (time * time * time + 2); + }, + reverse: function reverse() { + return _easeCubicActionInOut; + } + }; + cc.easeCubicActionInOut = function() { + return _easeCubicActionInOut; + }; + }), {} ], + 5: [ (function(require, module, exports) { + "use strict"; + cc.ActionInstant = cc.Class({ + name: "cc.ActionInstant", + extends: cc.FiniteTimeAction, + isDone: function isDone() { + return true; + }, + step: function step(dt) { + this.update(1); + }, + update: function update(dt) {}, + reverse: function reverse() { + return this.clone(); + }, + clone: function clone() { + return new cc.ActionInstant(); + } + }); + cc.Show = cc.Class({ + name: "cc.Show", + extends: cc.ActionInstant, + update: function update(dt) { + var _renderComps = this.target.getComponentsInChildren(cc.RenderComponent); + for (var i = 0; i < _renderComps.length; ++i) { + var render = _renderComps[i]; + render.enabled = true; + } + }, + reverse: function reverse() { + return new cc.Hide(); + }, + clone: function clone() { + return new cc.Show(); + } + }); + cc.show = function() { + return new cc.Show(); + }; + cc.Hide = cc.Class({ + name: "cc.Hide", + extends: cc.ActionInstant, + update: function update(dt) { + var _renderComps = this.target.getComponentsInChildren(cc.RenderComponent); + for (var i = 0; i < _renderComps.length; ++i) { + var render = _renderComps[i]; + render.enabled = false; + } + }, + reverse: function reverse() { + return new cc.Show(); + }, + clone: function clone() { + return new cc.Hide(); + } + }); + cc.hide = function() { + return new cc.Hide(); + }; + cc.ToggleVisibility = cc.Class({ + name: "cc.ToggleVisibility", + extends: cc.ActionInstant, + update: function update(dt) { + var _renderComps = this.target.getComponentsInChildren(cc.RenderComponent); + for (var i = 0; i < _renderComps.length; ++i) { + var render = _renderComps[i]; + render.enabled = !render.enabled; + } + }, + reverse: function reverse() { + return new cc.ToggleVisibility(); + }, + clone: function clone() { + return new cc.ToggleVisibility(); + } + }); + cc.toggleVisibility = function() { + return new cc.ToggleVisibility(); + }; + cc.RemoveSelf = cc.Class({ + name: "cc.RemoveSelf", + extends: cc.ActionInstant, + ctor: function ctor(isNeedCleanUp) { + this._isNeedCleanUp = true; + void 0 !== isNeedCleanUp && this.init(isNeedCleanUp); + }, + update: function update(dt) { + this.target.removeFromParent(this._isNeedCleanUp); + }, + init: function init(isNeedCleanUp) { + this._isNeedCleanUp = isNeedCleanUp; + return true; + }, + reverse: function reverse() { + return new cc.RemoveSelf(this._isNeedCleanUp); + }, + clone: function clone() { + return new cc.RemoveSelf(this._isNeedCleanUp); + } + }); + cc.removeSelf = function(isNeedCleanUp) { + return new cc.RemoveSelf(isNeedCleanUp); + }; + cc.DestroySelf = cc.Class({ + name: "cc.DestroySelf", + extends: cc.ActionInstant, + update: function update() { + this.target.destroy(); + }, + reverse: function reverse() { + return new cc.DestroySelf(); + }, + clone: function clone() { + return new cc.DestroySelf(); + } + }); + cc.destroySelf = function() { + return new cc.DestroySelf(); + }; + cc.FlipX = cc.Class({ + name: "cc.FlipX", + extends: cc.ActionInstant, + ctor: function ctor(flip) { + this._flippedX = false; + void 0 !== flip && this.initWithFlipX(flip); + }, + initWithFlipX: function initWithFlipX(flip) { + this._flippedX = flip; + return true; + }, + update: function update(dt) { + this.target.scaleX = Math.abs(this.target.scaleX) * (this._flippedX ? -1 : 1); + }, + reverse: function reverse() { + return new cc.FlipX(!this._flippedX); + }, + clone: function clone() { + var action = new cc.FlipX(); + action.initWithFlipX(this._flippedX); + return action; + } + }); + cc.flipX = function(flip) { + return new cc.FlipX(flip); + }; + cc.FlipY = cc.Class({ + name: "cc.FlipY", + extends: cc.ActionInstant, + ctor: function ctor(flip) { + this._flippedY = false; + void 0 !== flip && this.initWithFlipY(flip); + }, + initWithFlipY: function initWithFlipY(flip) { + this._flippedY = flip; + return true; + }, + update: function update(dt) { + this.target.scaleY = Math.abs(this.target.scaleY) * (this._flippedY ? -1 : 1); + }, + reverse: function reverse() { + return new cc.FlipY(!this._flippedY); + }, + clone: function clone() { + var action = new cc.FlipY(); + action.initWithFlipY(this._flippedY); + return action; + } + }); + cc.flipY = function(flip) { + return new cc.FlipY(flip); + }; + cc.Place = cc.Class({ + name: "cc.Place", + extends: cc.ActionInstant, + ctor: function ctor(pos, y) { + this._x = 0; + this._y = 0; + if (void 0 !== pos) { + if (void 0 !== pos.x) { + y = pos.y; + pos = pos.x; + } + this.initWithPosition(pos, y); + } + }, + initWithPosition: function initWithPosition(x, y) { + this._x = x; + this._y = y; + return true; + }, + update: function update(dt) { + this.target.setPosition(this._x, this._y); + }, + clone: function clone() { + var action = new cc.Place(); + action.initWithPosition(this._x, this._y); + return action; + } + }); + cc.place = function(pos, y) { + return new cc.Place(pos, y); + }; + cc.CallFunc = cc.Class({ + name: "cc.CallFunc", + extends: cc.ActionInstant, + ctor: function ctor(selector, selectorTarget, data) { + this._selectorTarget = null; + this._function = null; + this._data = null; + this.initWithFunction(selector, selectorTarget, data); + }, + initWithFunction: function initWithFunction(selector, selectorTarget, data) { + selector && (this._function = selector); + selectorTarget && (this._selectorTarget = selectorTarget); + void 0 !== data && (this._data = data); + return true; + }, + execute: function execute() { + this._function && this._function.call(this._selectorTarget, this.target, this._data); + }, + update: function update(dt) { + this.execute(); + }, + getTargetCallback: function getTargetCallback() { + return this._selectorTarget; + }, + setTargetCallback: function setTargetCallback(sel) { + if (sel !== this._selectorTarget) { + this._selectorTarget && (this._selectorTarget = null); + this._selectorTarget = sel; + } + }, + clone: function clone() { + var action = new cc.CallFunc(); + action.initWithFunction(this._function, this._selectorTarget, this._data); + return action; + } + }); + cc.callFunc = function(selector, selectorTarget, data) { + return new cc.CallFunc(selector, selectorTarget, data); + }; + }), {} ], + 6: [ (function(require, module, exports) { + "use strict"; + cc.ActionInterval = cc.Class({ + name: "cc.ActionInterval", + extends: cc.FiniteTimeAction, + ctor: function ctor(d) { + this.MAX_VALUE = 2; + this._elapsed = 0; + this._firstTick = false; + this._easeList = null; + this._speed = 1; + this._timesForRepeat = 1; + this._repeatForever = false; + this._repeatMethod = false; + this._speedMethod = false; + void 0 !== d && cc.ActionInterval.prototype.initWithDuration.call(this, d); + }, + getElapsed: function getElapsed() { + return this._elapsed; + }, + initWithDuration: function initWithDuration(d) { + this._duration = 0 === d ? cc.macro.FLT_EPSILON : d; + this._elapsed = 0; + this._firstTick = true; + return true; + }, + isDone: function isDone() { + return this._elapsed >= this._duration; + }, + _cloneDecoration: function _cloneDecoration(action) { + action._repeatForever = this._repeatForever; + action._speed = this._speed; + action._timesForRepeat = this._timesForRepeat; + action._easeList = this._easeList; + action._speedMethod = this._speedMethod; + action._repeatMethod = this._repeatMethod; + }, + _reverseEaseList: function _reverseEaseList(action) { + if (this._easeList) { + action._easeList = []; + for (var i = 0; i < this._easeList.length; i++) action._easeList.push(this._easeList[i].reverse()); + } + }, + clone: function clone() { + var action = new cc.ActionInterval(this._duration); + this._cloneDecoration(action); + return action; + }, + easing: function easing(easeObj) { + this._easeList ? this._easeList.length = 0 : this._easeList = []; + for (var i = 0; i < arguments.length; i++) this._easeList.push(arguments[i]); + return this; + }, + _computeEaseTime: function _computeEaseTime(dt) { + var locList = this._easeList; + if (!locList || 0 === locList.length) return dt; + for (var i = 0, n = locList.length; i < n; i++) dt = locList[i].easing(dt); + return dt; + }, + step: function step(dt) { + if (this._firstTick) { + this._firstTick = false; + this._elapsed = 0; + } else this._elapsed += dt; + var t = this._elapsed / (this._duration > 1.192092896e-7 ? this._duration : 1.192092896e-7); + t = 1 > t ? t : 1; + this.update(t > 0 ? t : 0); + if (this._repeatMethod && this._timesForRepeat > 1 && this.isDone()) { + this._repeatForever || this._timesForRepeat--; + this.startWithTarget(this.target); + this.step(this._elapsed - this._duration); + } + }, + startWithTarget: function startWithTarget(target) { + cc.Action.prototype.startWithTarget.call(this, target); + this._elapsed = 0; + this._firstTick = true; + }, + reverse: function reverse() { + cc.logID(1010); + return null; + }, + setAmplitudeRate: function setAmplitudeRate(amp) { + cc.logID(1011); + }, + getAmplitudeRate: function getAmplitudeRate() { + cc.logID(1012); + return 0; + }, + speed: function speed(_speed) { + if (_speed <= 0) { + cc.logID(1013); + return this; + } + this._speedMethod = true; + this._speed *= _speed; + return this; + }, + getSpeed: function getSpeed() { + return this._speed; + }, + setSpeed: function setSpeed(speed) { + this._speed = speed; + return this; + }, + repeat: function repeat(times) { + times = Math.round(times); + if (isNaN(times) || times < 1) { + cc.logID(1014); + return this; + } + this._repeatMethod = true; + this._timesForRepeat *= times; + return this; + }, + repeatForever: function repeatForever() { + this._repeatMethod = true; + this._timesForRepeat = this.MAX_VALUE; + this._repeatForever = true; + return this; + } + }); + cc.actionInterval = function(d) { + return new cc.ActionInterval(d); + }; + cc.Sequence = cc.Class({ + name: "cc.Sequence", + extends: cc.ActionInterval, + ctor: function ctor(tempArray) { + this._actions = []; + this._split = null; + this._last = 0; + this._reversed = false; + var paramArray = tempArray instanceof Array ? tempArray : arguments; + if (1 === paramArray.length) { + cc.errorID(1019); + return; + } + var last = paramArray.length - 1; + last >= 0 && null == paramArray[last] && cc.logID(1015); + if (last >= 0) { + var prev = paramArray[0], action1; + for (var i = 1; i < last; i++) if (paramArray[i]) { + action1 = prev; + prev = cc.Sequence._actionOneTwo(action1, paramArray[i]); + } + this.initWithTwoActions(prev, paramArray[last]); + } + }, + initWithTwoActions: function initWithTwoActions(actionOne, actionTwo) { + if (!actionOne || !actionTwo) { + cc.errorID(1025); + return false; + } + var durationOne = actionOne._duration, durationTwo = actionTwo._duration; + durationOne *= actionOne._repeatMethod ? actionOne._timesForRepeat : 1; + durationTwo *= actionTwo._repeatMethod ? actionTwo._timesForRepeat : 1; + var d = durationOne + durationTwo; + this.initWithDuration(d); + this._actions[0] = actionOne; + this._actions[1] = actionTwo; + return true; + }, + clone: function clone() { + var action = new cc.Sequence(); + this._cloneDecoration(action); + action.initWithTwoActions(this._actions[0].clone(), this._actions[1].clone()); + return action; + }, + startWithTarget: function startWithTarget(target) { + cc.ActionInterval.prototype.startWithTarget.call(this, target); + this._split = this._actions[0]._duration / this._duration; + this._split *= this._actions[0]._repeatMethod ? this._actions[0]._timesForRepeat : 1; + this._last = -1; + }, + stop: function stop() { + -1 !== this._last && this._actions[this._last].stop(); + cc.Action.prototype.stop.call(this); + }, + update: function update(dt) { + var new_t, found = 0; + var locSplit = this._split, locActions = this._actions, locLast = this._last, actionFound; + dt = this._computeEaseTime(dt); + if (dt < locSplit) { + new_t = 0 !== locSplit ? dt / locSplit : 1; + if (0 === found && 1 === locLast && this._reversed) { + locActions[1].update(0); + locActions[1].stop(); + } + } else { + found = 1; + new_t = 1 === locSplit ? 1 : (dt - locSplit) / (1 - locSplit); + if (-1 === locLast) { + locActions[0].startWithTarget(this.target); + locActions[0].update(1); + locActions[0].stop(); + } + if (0 === locLast) { + locActions[0].update(1); + locActions[0].stop(); + } + } + actionFound = locActions[found]; + if (locLast === found && actionFound.isDone()) return; + locLast !== found && actionFound.startWithTarget(this.target); + new_t *= actionFound._timesForRepeat; + actionFound.update(new_t > 1 ? new_t % 1 : new_t); + this._last = found; + }, + reverse: function reverse() { + var action = cc.Sequence._actionOneTwo(this._actions[1].reverse(), this._actions[0].reverse()); + this._cloneDecoration(action); + this._reverseEaseList(action); + action._reversed = true; + return action; + } + }); + cc.sequence = function(tempArray) { + var paramArray = tempArray instanceof Array ? tempArray : arguments; + if (1 === paramArray.length) { + cc.errorID(1019); + return null; + } + var last = paramArray.length - 1; + last >= 0 && null == paramArray[last] && cc.logID(1015); + var result = null; + if (last >= 0) { + result = paramArray[0]; + for (var i = 1; i <= last; i++) paramArray[i] && (result = cc.Sequence._actionOneTwo(result, paramArray[i])); + } + return result; + }; + cc.Sequence._actionOneTwo = function(actionOne, actionTwo) { + var sequence = new cc.Sequence(); + sequence.initWithTwoActions(actionOne, actionTwo); + return sequence; + }; + cc.Repeat = cc.Class({ + name: "cc.Repeat", + extends: cc.ActionInterval, + ctor: function ctor(action, times) { + this._times = 0; + this._total = 0; + this._nextDt = 0; + this._actionInstant = false; + this._innerAction = null; + void 0 !== times && this.initWithAction(action, times); + }, + initWithAction: function initWithAction(action, times) { + var duration = action._duration * times; + if (this.initWithDuration(duration)) { + this._times = times; + this._innerAction = action; + if (action instanceof cc.ActionInstant) { + this._actionInstant = true; + this._times -= 1; + } + this._total = 0; + return true; + } + return false; + }, + clone: function clone() { + var action = new cc.Repeat(); + this._cloneDecoration(action); + action.initWithAction(this._innerAction.clone(), this._times); + return action; + }, + startWithTarget: function startWithTarget(target) { + this._total = 0; + this._nextDt = this._innerAction._duration / this._duration; + cc.ActionInterval.prototype.startWithTarget.call(this, target); + this._innerAction.startWithTarget(target); + }, + stop: function stop() { + this._innerAction.stop(); + cc.Action.prototype.stop.call(this); + }, + update: function update(dt) { + dt = this._computeEaseTime(dt); + var locInnerAction = this._innerAction; + var locDuration = this._duration; + var locTimes = this._times; + var locNextDt = this._nextDt; + if (dt >= locNextDt) { + while (dt > locNextDt && this._total < locTimes) { + locInnerAction.update(1); + this._total++; + locInnerAction.stop(); + locInnerAction.startWithTarget(this.target); + locNextDt += locInnerAction._duration / locDuration; + this._nextDt = locNextDt > 1 ? 1 : locNextDt; + } + if (dt >= 1 && this._total < locTimes) { + locInnerAction.update(1); + this._total++; + } + this._actionInstant || (this._total === locTimes ? locInnerAction.stop() : locInnerAction.update(dt - (locNextDt - locInnerAction._duration / locDuration))); + } else locInnerAction.update(dt * locTimes % 1); + }, + isDone: function isDone() { + return this._total === this._times; + }, + reverse: function reverse() { + var action = new cc.Repeat(this._innerAction.reverse(), this._times); + this._cloneDecoration(action); + this._reverseEaseList(action); + return action; + }, + setInnerAction: function setInnerAction(action) { + this._innerAction !== action && (this._innerAction = action); + }, + getInnerAction: function getInnerAction() { + return this._innerAction; + } + }); + cc.repeat = function(action, times) { + return new cc.Repeat(action, times); + }; + cc.repeatForever = function(action) { + return new cc.RepeatForever(action); + }; + cc.RepeatForever = cc.Class({ + name: "cc.RepeatForever", + extends: cc.ActionInterval, + ctor: function ctor(action) { + this._innerAction = null; + action && this.initWithAction(action); + }, + initWithAction: function initWithAction(action) { + if (!action) { + cc.errorID(1026); + return false; + } + this._innerAction = action; + return true; + }, + clone: function clone() { + var action = new cc.RepeatForever(); + this._cloneDecoration(action); + action.initWithAction(this._innerAction.clone()); + return action; + }, + startWithTarget: function startWithTarget(target) { + cc.ActionInterval.prototype.startWithTarget.call(this, target); + this._innerAction.startWithTarget(target); + }, + step: function step(dt) { + var locInnerAction = this._innerAction; + locInnerAction.step(dt); + if (locInnerAction.isDone()) { + locInnerAction.startWithTarget(this.target); + locInnerAction.step(locInnerAction.getElapsed() - locInnerAction._duration); + } + }, + isDone: function isDone() { + return false; + }, + reverse: function reverse() { + var action = new cc.RepeatForever(this._innerAction.reverse()); + this._cloneDecoration(action); + this._reverseEaseList(action); + return action; + }, + setInnerAction: function setInnerAction(action) { + this._innerAction !== action && (this._innerAction = action); + }, + getInnerAction: function getInnerAction() { + return this._innerAction; + } + }); + cc.repeatForever = function(action) { + return new cc.RepeatForever(action); + }; + cc.Spawn = cc.Class({ + name: "cc.Spawn", + extends: cc.ActionInterval, + ctor: function ctor(tempArray) { + this._one = null; + this._two = null; + var paramArray = tempArray instanceof Array ? tempArray : arguments; + if (1 === paramArray.length) { + cc.errorID(1020); + return; + } + var last = paramArray.length - 1; + last >= 0 && null == paramArray[last] && cc.logID(1015); + if (last >= 0) { + var prev = paramArray[0], action1; + for (var i = 1; i < last; i++) if (paramArray[i]) { + action1 = prev; + prev = cc.Spawn._actionOneTwo(action1, paramArray[i]); + } + this.initWithTwoActions(prev, paramArray[last]); + } + }, + initWithTwoActions: function initWithTwoActions(action1, action2) { + if (!action1 || !action2) { + cc.errorID(1027); + return false; + } + var ret = false; + var d1 = action1._duration; + var d2 = action2._duration; + if (this.initWithDuration(Math.max(d1, d2))) { + this._one = action1; + this._two = action2; + d1 > d2 ? this._two = cc.Sequence._actionOneTwo(action2, cc.delayTime(d1 - d2)) : d1 < d2 && (this._one = cc.Sequence._actionOneTwo(action1, cc.delayTime(d2 - d1))); + ret = true; + } + return ret; + }, + clone: function clone() { + var action = new cc.Spawn(); + this._cloneDecoration(action); + action.initWithTwoActions(this._one.clone(), this._two.clone()); + return action; + }, + startWithTarget: function startWithTarget(target) { + cc.ActionInterval.prototype.startWithTarget.call(this, target); + this._one.startWithTarget(target); + this._two.startWithTarget(target); + }, + stop: function stop() { + this._one.stop(); + this._two.stop(); + cc.Action.prototype.stop.call(this); + }, + update: function update(dt) { + dt = this._computeEaseTime(dt); + this._one && this._one.update(dt); + this._two && this._two.update(dt); + }, + reverse: function reverse() { + var action = cc.Spawn._actionOneTwo(this._one.reverse(), this._two.reverse()); + this._cloneDecoration(action); + this._reverseEaseList(action); + return action; + } + }); + cc.spawn = function(tempArray) { + var paramArray = tempArray instanceof Array ? tempArray : arguments; + if (1 === paramArray.length) { + cc.errorID(1020); + return null; + } + paramArray.length > 0 && null == paramArray[paramArray.length - 1] && cc.logID(1015); + var prev = paramArray[0]; + for (var i = 1; i < paramArray.length; i++) null != paramArray[i] && (prev = cc.Spawn._actionOneTwo(prev, paramArray[i])); + return prev; + }; + cc.Spawn._actionOneTwo = function(action1, action2) { + var pSpawn = new cc.Spawn(); + pSpawn.initWithTwoActions(action1, action2); + return pSpawn; + }; + cc.RotateTo = cc.Class({ + name: "cc.RotateTo", + extends: cc.ActionInterval, + statics: { + _reverse: false + }, + ctor: function ctor(duration, dstAngle) { + this._startAngle = 0; + this._dstAngle = 0; + this._angle = 0; + void 0 !== dstAngle && this.initWithDuration(duration, dstAngle); + }, + initWithDuration: function initWithDuration(duration, dstAngle) { + if (cc.ActionInterval.prototype.initWithDuration.call(this, duration)) { + this._dstAngle = dstAngle; + return true; + } + return false; + }, + clone: function clone() { + var action = new cc.RotateTo(); + this._cloneDecoration(action); + action.initWithDuration(this._duration, this._dstAngle); + return action; + }, + startWithTarget: function startWithTarget(target) { + cc.ActionInterval.prototype.startWithTarget.call(this, target); + var startAngle = target.angle % 360; + var angle = cc.RotateTo._reverse ? this._dstAngle - startAngle : this._dstAngle + startAngle; + angle > 180 && (angle -= 360); + angle < -180 && (angle += 360); + this._startAngle = startAngle; + this._angle = cc.RotateTo._reverse ? angle : -angle; + }, + reverse: function reverse() { + cc.logID(1016); + }, + update: function update(dt) { + dt = this._computeEaseTime(dt); + this.target && (this.target.angle = this._startAngle + this._angle * dt); + } + }); + cc.rotateTo = function(duration, dstAngle) { + return new cc.RotateTo(duration, dstAngle); + }; + cc.RotateBy = cc.Class({ + name: "cc.RotateBy", + extends: cc.ActionInterval, + statics: { + _reverse: false + }, + ctor: function ctor(duration, deltaAngle) { + deltaAngle *= cc.RotateBy._reverse ? 1 : -1; + this._deltaAngle = 0; + this._startAngle = 0; + void 0 !== deltaAngle && this.initWithDuration(duration, deltaAngle); + }, + initWithDuration: function initWithDuration(duration, deltaAngle) { + if (cc.ActionInterval.prototype.initWithDuration.call(this, duration)) { + this._deltaAngle = deltaAngle; + return true; + } + return false; + }, + clone: function clone() { + var action = new cc.RotateBy(); + this._cloneDecoration(action); + action.initWithDuration(this._duration, this._deltaAngle); + return action; + }, + startWithTarget: function startWithTarget(target) { + cc.ActionInterval.prototype.startWithTarget.call(this, target); + this._startAngle = target.angle; + }, + update: function update(dt) { + dt = this._computeEaseTime(dt); + this.target && (this.target.angle = this._startAngle + this._deltaAngle * dt); + }, + reverse: function reverse() { + var action = new cc.RotateBy(); + action.initWithDuration(this._duration, -this._deltaAngle); + this._cloneDecoration(action); + this._reverseEaseList(action); + return action; + } + }); + cc.rotateBy = function(duration, deltaAngle) { + return new cc.RotateBy(duration, deltaAngle); + }; + cc.MoveBy = cc.Class({ + name: "cc.MoveBy", + extends: cc.ActionInterval, + ctor: function ctor(duration, deltaPos, deltaY) { + this._positionDelta = cc.v2(0, 0); + this._startPosition = cc.v2(0, 0); + this._previousPosition = cc.v2(0, 0); + void 0 !== deltaPos && cc.MoveBy.prototype.initWithDuration.call(this, duration, deltaPos, deltaY); + }, + initWithDuration: function initWithDuration(duration, position, y) { + if (cc.ActionInterval.prototype.initWithDuration.call(this, duration)) { + if (void 0 !== position.x) { + y = position.y; + position = position.x; + } + this._positionDelta.x = position; + this._positionDelta.y = y; + return true; + } + return false; + }, + clone: function clone() { + var action = new cc.MoveBy(); + this._cloneDecoration(action); + action.initWithDuration(this._duration, this._positionDelta); + return action; + }, + startWithTarget: function startWithTarget(target) { + cc.ActionInterval.prototype.startWithTarget.call(this, target); + var locPosX = target.x; + var locPosY = target.y; + this._previousPosition.x = locPosX; + this._previousPosition.y = locPosY; + this._startPosition.x = locPosX; + this._startPosition.y = locPosY; + }, + update: function update(dt) { + dt = this._computeEaseTime(dt); + if (this.target) { + var x = this._positionDelta.x * dt; + var y = this._positionDelta.y * dt; + var locStartPosition = this._startPosition; + if (cc.macro.ENABLE_STACKABLE_ACTIONS) { + var targetX = this.target.x; + var targetY = this.target.y; + var locPreviousPosition = this._previousPosition; + locStartPosition.x = locStartPosition.x + targetX - locPreviousPosition.x; + locStartPosition.y = locStartPosition.y + targetY - locPreviousPosition.y; + x += locStartPosition.x; + y += locStartPosition.y; + locPreviousPosition.x = x; + locPreviousPosition.y = y; + this.target.setPosition(x, y); + } else this.target.setPosition(locStartPosition.x + x, locStartPosition.y + y); + } + }, + reverse: function reverse() { + var action = new cc.MoveBy(this._duration, cc.v2(-this._positionDelta.x, -this._positionDelta.y)); + this._cloneDecoration(action); + this._reverseEaseList(action); + return action; + } + }); + cc.moveBy = function(duration, deltaPos, deltaY) { + return new cc.MoveBy(duration, deltaPos, deltaY); + }; + cc.MoveTo = cc.Class({ + name: "cc.MoveTo", + extends: cc.MoveBy, + ctor: function ctor(duration, position, y) { + this._endPosition = cc.v2(0, 0); + void 0 !== position && this.initWithDuration(duration, position, y); + }, + initWithDuration: function initWithDuration(duration, position, y) { + if (cc.MoveBy.prototype.initWithDuration.call(this, duration, position, y)) { + if (void 0 !== position.x) { + y = position.y; + position = position.x; + } + this._endPosition.x = position; + this._endPosition.y = y; + return true; + } + return false; + }, + clone: function clone() { + var action = new cc.MoveTo(); + this._cloneDecoration(action); + action.initWithDuration(this._duration, this._endPosition); + return action; + }, + startWithTarget: function startWithTarget(target) { + cc.MoveBy.prototype.startWithTarget.call(this, target); + this._positionDelta.x = this._endPosition.x - target.x; + this._positionDelta.y = this._endPosition.y - target.y; + } + }); + cc.moveTo = function(duration, position, y) { + return new cc.MoveTo(duration, position, y); + }; + cc.SkewTo = cc.Class({ + name: "cc.SkewTo", + extends: cc.ActionInterval, + ctor: function ctor(t, sx, sy) { + this._skewX = 0; + this._skewY = 0; + this._startSkewX = 0; + this._startSkewY = 0; + this._endSkewX = 0; + this._endSkewY = 0; + this._deltaX = 0; + this._deltaY = 0; + void 0 !== sy && cc.SkewTo.prototype.initWithDuration.call(this, t, sx, sy); + }, + initWithDuration: function initWithDuration(t, sx, sy) { + var ret = false; + if (cc.ActionInterval.prototype.initWithDuration.call(this, t)) { + this._endSkewX = sx; + this._endSkewY = sy; + ret = true; + } + return ret; + }, + clone: function clone() { + var action = new cc.SkewTo(); + this._cloneDecoration(action); + action.initWithDuration(this._duration, this._endSkewX, this._endSkewY); + return action; + }, + startWithTarget: function startWithTarget(target) { + cc.ActionInterval.prototype.startWithTarget.call(this, target); + this._startSkewX = target.skewX % 180; + this._deltaX = this._endSkewX - this._startSkewX; + this._deltaX > 180 && (this._deltaX -= 360); + this._deltaX < -180 && (this._deltaX += 360); + this._startSkewY = target.skewY % 360; + this._deltaY = this._endSkewY - this._startSkewY; + this._deltaY > 180 && (this._deltaY -= 360); + this._deltaY < -180 && (this._deltaY += 360); + }, + update: function update(dt) { + dt = this._computeEaseTime(dt); + this.target.skewX = this._startSkewX + this._deltaX * dt; + this.target.skewY = this._startSkewY + this._deltaY * dt; + } + }); + cc.skewTo = function(t, sx, sy) { + return new cc.SkewTo(t, sx, sy); + }; + cc.SkewBy = cc.Class({ + name: "cc.SkewBy", + extends: cc.SkewTo, + ctor: function ctor(t, sx, sy) { + void 0 !== sy && this.initWithDuration(t, sx, sy); + }, + initWithDuration: function initWithDuration(t, deltaSkewX, deltaSkewY) { + var ret = false; + if (cc.SkewTo.prototype.initWithDuration.call(this, t, deltaSkewX, deltaSkewY)) { + this._skewX = deltaSkewX; + this._skewY = deltaSkewY; + ret = true; + } + return ret; + }, + clone: function clone() { + var action = new cc.SkewBy(); + this._cloneDecoration(action); + action.initWithDuration(this._duration, this._skewX, this._skewY); + return action; + }, + startWithTarget: function startWithTarget(target) { + cc.SkewTo.prototype.startWithTarget.call(this, target); + this._deltaX = this._skewX; + this._deltaY = this._skewY; + this._endSkewX = this._startSkewX + this._deltaX; + this._endSkewY = this._startSkewY + this._deltaY; + }, + reverse: function reverse() { + var action = new cc.SkewBy(this._duration, -this._skewX, -this._skewY); + this._cloneDecoration(action); + this._reverseEaseList(action); + return action; + } + }); + cc.skewBy = function(t, sx, sy) { + return new cc.SkewBy(t, sx, sy); + }; + cc.JumpBy = cc.Class({ + name: "cc.JumpBy", + extends: cc.ActionInterval, + ctor: function ctor(duration, position, y, height, jumps) { + this._startPosition = cc.v2(0, 0); + this._previousPosition = cc.v2(0, 0); + this._delta = cc.v2(0, 0); + this._height = 0; + this._jumps = 0; + void 0 !== height && cc.JumpBy.prototype.initWithDuration.call(this, duration, position, y, height, jumps); + }, + initWithDuration: function initWithDuration(duration, position, y, height, jumps) { + if (cc.ActionInterval.prototype.initWithDuration.call(this, duration)) { + if (void 0 === jumps) { + jumps = height; + height = y; + y = position.y; + position = position.x; + } + this._delta.x = position; + this._delta.y = y; + this._height = height; + this._jumps = jumps; + return true; + } + return false; + }, + clone: function clone() { + var action = new cc.JumpBy(); + this._cloneDecoration(action); + action.initWithDuration(this._duration, this._delta, this._height, this._jumps); + return action; + }, + startWithTarget: function startWithTarget(target) { + cc.ActionInterval.prototype.startWithTarget.call(this, target); + var locPosX = target.x; + var locPosY = target.y; + this._previousPosition.x = locPosX; + this._previousPosition.y = locPosY; + this._startPosition.x = locPosX; + this._startPosition.y = locPosY; + }, + update: function update(dt) { + dt = this._computeEaseTime(dt); + if (this.target) { + var frac = dt * this._jumps % 1; + var y = 4 * this._height * frac * (1 - frac); + y += this._delta.y * dt; + var x = this._delta.x * dt; + var locStartPosition = this._startPosition; + if (cc.macro.ENABLE_STACKABLE_ACTIONS) { + var targetX = this.target.x; + var targetY = this.target.y; + var locPreviousPosition = this._previousPosition; + locStartPosition.x = locStartPosition.x + targetX - locPreviousPosition.x; + locStartPosition.y = locStartPosition.y + targetY - locPreviousPosition.y; + x += locStartPosition.x; + y += locStartPosition.y; + locPreviousPosition.x = x; + locPreviousPosition.y = y; + this.target.setPosition(x, y); + } else this.target.setPosition(locStartPosition.x + x, locStartPosition.y + y); + } + }, + reverse: function reverse() { + var action = new cc.JumpBy(this._duration, cc.v2(-this._delta.x, -this._delta.y), this._height, this._jumps); + this._cloneDecoration(action); + this._reverseEaseList(action); + return action; + } + }); + cc.jumpBy = function(duration, position, y, height, jumps) { + return new cc.JumpBy(duration, position, y, height, jumps); + }; + cc.JumpTo = cc.Class({ + name: "cc.JumpTo", + extends: cc.JumpBy, + ctor: function ctor(duration, position, y, height, jumps) { + this._endPosition = cc.v2(0, 0); + void 0 !== height && this.initWithDuration(duration, position, y, height, jumps); + }, + initWithDuration: function initWithDuration(duration, position, y, height, jumps) { + if (cc.JumpBy.prototype.initWithDuration.call(this, duration, position, y, height, jumps)) { + if (void 0 === jumps) { + y = position.y; + position = position.x; + } + this._endPosition.x = position; + this._endPosition.y = y; + return true; + } + return false; + }, + startWithTarget: function startWithTarget(target) { + cc.JumpBy.prototype.startWithTarget.call(this, target); + this._delta.x = this._endPosition.x - this._startPosition.x; + this._delta.y = this._endPosition.y - this._startPosition.y; + }, + clone: function clone() { + var action = new cc.JumpTo(); + this._cloneDecoration(action); + action.initWithDuration(this._duration, this._endPosition, this._height, this._jumps); + return action; + } + }); + cc.jumpTo = function(duration, position, y, height, jumps) { + return new cc.JumpTo(duration, position, y, height, jumps); + }; + function bezierAt(a, b, c, d, t) { + return Math.pow(1 - t, 3) * a + 3 * t * Math.pow(1 - t, 2) * b + 3 * Math.pow(t, 2) * (1 - t) * c + Math.pow(t, 3) * d; + } + cc.BezierBy = cc.Class({ + name: "cc.BezierBy", + extends: cc.ActionInterval, + ctor: function ctor(t, c) { + this._config = []; + this._startPosition = cc.v2(0, 0); + this._previousPosition = cc.v2(0, 0); + c && cc.BezierBy.prototype.initWithDuration.call(this, t, c); + }, + initWithDuration: function initWithDuration(t, c) { + if (cc.ActionInterval.prototype.initWithDuration.call(this, t)) { + this._config = c; + return true; + } + return false; + }, + clone: function clone() { + var action = new cc.BezierBy(); + this._cloneDecoration(action); + var newConfigs = []; + for (var i = 0; i < this._config.length; i++) { + var selConf = this._config[i]; + newConfigs.push(cc.v2(selConf.x, selConf.y)); + } + action.initWithDuration(this._duration, newConfigs); + return action; + }, + startWithTarget: function startWithTarget(target) { + cc.ActionInterval.prototype.startWithTarget.call(this, target); + var locPosX = target.x; + var locPosY = target.y; + this._previousPosition.x = locPosX; + this._previousPosition.y = locPosY; + this._startPosition.x = locPosX; + this._startPosition.y = locPosY; + }, + update: function update(dt) { + dt = this._computeEaseTime(dt); + if (this.target) { + var locConfig = this._config; + var xa = 0; + var xb = locConfig[0].x; + var xc = locConfig[1].x; + var xd = locConfig[2].x; + var ya = 0; + var yb = locConfig[0].y; + var yc = locConfig[1].y; + var yd = locConfig[2].y; + var x = bezierAt(xa, xb, xc, xd, dt); + var y = bezierAt(ya, yb, yc, yd, dt); + var locStartPosition = this._startPosition; + if (cc.macro.ENABLE_STACKABLE_ACTIONS) { + var targetX = this.target.x; + var targetY = this.target.y; + var locPreviousPosition = this._previousPosition; + locStartPosition.x = locStartPosition.x + targetX - locPreviousPosition.x; + locStartPosition.y = locStartPosition.y + targetY - locPreviousPosition.y; + x += locStartPosition.x; + y += locStartPosition.y; + locPreviousPosition.x = x; + locPreviousPosition.y = y; + this.target.setPosition(x, y); + } else this.target.setPosition(locStartPosition.x + x, locStartPosition.y + y); + } + }, + reverse: function reverse() { + var locConfig = this._config; + var x0 = locConfig[0].x, y0 = locConfig[0].y; + var x1 = locConfig[1].x, y1 = locConfig[1].y; + var x2 = locConfig[2].x, y2 = locConfig[2].y; + var r = [ cc.v2(x1 - x2, y1 - y2), cc.v2(x0 - x2, y0 - y2), cc.v2(-x2, -y2) ]; + var action = new cc.BezierBy(this._duration, r); + this._cloneDecoration(action); + this._reverseEaseList(action); + return action; + } + }); + cc.bezierBy = function(t, c) { + return new cc.BezierBy(t, c); + }; + cc.BezierTo = cc.Class({ + name: "cc.BezierTo", + extends: cc.BezierBy, + ctor: function ctor(t, c) { + this._toConfig = []; + c && this.initWithDuration(t, c); + }, + initWithDuration: function initWithDuration(t, c) { + if (cc.ActionInterval.prototype.initWithDuration.call(this, t)) { + this._toConfig = c; + return true; + } + return false; + }, + clone: function clone() { + var action = new cc.BezierTo(); + this._cloneDecoration(action); + action.initWithDuration(this._duration, this._toConfig); + return action; + }, + startWithTarget: function startWithTarget(target) { + cc.BezierBy.prototype.startWithTarget.call(this, target); + var locStartPos = this._startPosition; + var locToConfig = this._toConfig; + var locConfig = this._config; + locConfig[0] = locToConfig[0].sub(locStartPos); + locConfig[1] = locToConfig[1].sub(locStartPos); + locConfig[2] = locToConfig[2].sub(locStartPos); + } + }); + cc.bezierTo = function(t, c) { + return new cc.BezierTo(t, c); + }; + cc.ScaleTo = cc.Class({ + name: "cc.ScaleTo", + extends: cc.ActionInterval, + ctor: function ctor(duration, sx, sy) { + this._scaleX = 1; + this._scaleY = 1; + this._startScaleX = 1; + this._startScaleY = 1; + this._endScaleX = 0; + this._endScaleY = 0; + this._deltaX = 0; + this._deltaY = 0; + void 0 !== sx && cc.ScaleTo.prototype.initWithDuration.call(this, duration, sx, sy); + }, + initWithDuration: function initWithDuration(duration, sx, sy) { + if (cc.ActionInterval.prototype.initWithDuration.call(this, duration)) { + this._endScaleX = sx; + this._endScaleY = null != sy ? sy : sx; + return true; + } + return false; + }, + clone: function clone() { + var action = new cc.ScaleTo(); + this._cloneDecoration(action); + action.initWithDuration(this._duration, this._endScaleX, this._endScaleY); + return action; + }, + startWithTarget: function startWithTarget(target) { + cc.ActionInterval.prototype.startWithTarget.call(this, target); + this._startScaleX = target.scaleX; + this._startScaleY = target.scaleY; + this._deltaX = this._endScaleX - this._startScaleX; + this._deltaY = this._endScaleY - this._startScaleY; + }, + update: function update(dt) { + dt = this._computeEaseTime(dt); + if (this.target) { + this.target.scaleX = this._startScaleX + this._deltaX * dt; + this.target.scaleY = this._startScaleY + this._deltaY * dt; + } + } + }); + cc.scaleTo = function(duration, sx, sy) { + return new cc.ScaleTo(duration, sx, sy); + }; + cc.ScaleBy = cc.Class({ + name: "cc.ScaleBy", + extends: cc.ScaleTo, + startWithTarget: function startWithTarget(target) { + cc.ScaleTo.prototype.startWithTarget.call(this, target); + this._deltaX = this._startScaleX * this._endScaleX - this._startScaleX; + this._deltaY = this._startScaleY * this._endScaleY - this._startScaleY; + }, + reverse: function reverse() { + var action = new cc.ScaleBy(this._duration, 1 / this._endScaleX, 1 / this._endScaleY); + this._cloneDecoration(action); + this._reverseEaseList(action); + return action; + }, + clone: function clone() { + var action = new cc.ScaleBy(); + this._cloneDecoration(action); + action.initWithDuration(this._duration, this._endScaleX, this._endScaleY); + return action; + } + }); + cc.scaleBy = function(duration, sx, sy) { + return new cc.ScaleBy(duration, sx, sy); + }; + cc.Blink = cc.Class({ + name: "cc.Blink", + extends: cc.ActionInterval, + ctor: function ctor(duration, blinks) { + this._times = 0; + this._originalState = false; + void 0 !== blinks && this.initWithDuration(duration, blinks); + }, + initWithDuration: function initWithDuration(duration, blinks) { + if (cc.ActionInterval.prototype.initWithDuration.call(this, duration)) { + this._times = blinks; + return true; + } + return false; + }, + clone: function clone() { + var action = new cc.Blink(); + this._cloneDecoration(action); + action.initWithDuration(this._duration, this._times); + return action; + }, + update: function update(dt) { + dt = this._computeEaseTime(dt); + if (this.target && !this.isDone()) { + var slice = 1 / this._times; + var m = dt % slice; + this.target.opacity = m > slice / 2 ? 255 : 0; + } + }, + startWithTarget: function startWithTarget(target) { + cc.ActionInterval.prototype.startWithTarget.call(this, target); + this._originalState = target.opacity; + }, + stop: function stop() { + this.target.opacity = this._originalState; + cc.ActionInterval.prototype.stop.call(this); + }, + reverse: function reverse() { + var action = new cc.Blink(this._duration, this._times); + this._cloneDecoration(action); + this._reverseEaseList(action); + return action; + } + }); + cc.blink = function(duration, blinks) { + return new cc.Blink(duration, blinks); + }; + cc.FadeTo = cc.Class({ + name: "cc.FadeTo", + extends: cc.ActionInterval, + ctor: function ctor(duration, opacity) { + this._toOpacity = 0; + this._fromOpacity = 0; + void 0 !== opacity && cc.FadeTo.prototype.initWithDuration.call(this, duration, opacity); + }, + initWithDuration: function initWithDuration(duration, opacity) { + if (cc.ActionInterval.prototype.initWithDuration.call(this, duration)) { + this._toOpacity = opacity; + return true; + } + return false; + }, + clone: function clone() { + var action = new cc.FadeTo(); + this._cloneDecoration(action); + action.initWithDuration(this._duration, this._toOpacity); + return action; + }, + update: function update(time) { + time = this._computeEaseTime(time); + var fromOpacity = void 0 !== this._fromOpacity ? this._fromOpacity : 255; + this.target.opacity = fromOpacity + (this._toOpacity - fromOpacity) * time; + }, + startWithTarget: function startWithTarget(target) { + cc.ActionInterval.prototype.startWithTarget.call(this, target); + this._fromOpacity = target.opacity; + } + }); + cc.fadeTo = function(duration, opacity) { + return new cc.FadeTo(duration, opacity); + }; + cc.FadeIn = cc.Class({ + name: "cc.FadeIn", + extends: cc.FadeTo, + ctor: function ctor(duration) { + null == duration && (duration = 0); + this._reverseAction = null; + this.initWithDuration(duration, 255); + }, + reverse: function reverse() { + var action = new cc.FadeOut(); + action.initWithDuration(this._duration, 0); + this._cloneDecoration(action); + this._reverseEaseList(action); + return action; + }, + clone: function clone() { + var action = new cc.FadeIn(); + this._cloneDecoration(action); + action.initWithDuration(this._duration, this._toOpacity); + return action; + }, + startWithTarget: function startWithTarget(target) { + this._reverseAction && (this._toOpacity = this._reverseAction._fromOpacity); + cc.FadeTo.prototype.startWithTarget.call(this, target); + } + }); + cc.fadeIn = function(duration) { + return new cc.FadeIn(duration); + }; + cc.FadeOut = cc.Class({ + name: "cc.FadeOut", + extends: cc.FadeTo, + ctor: function ctor(duration) { + null == duration && (duration = 0); + this._reverseAction = null; + this.initWithDuration(duration, 0); + }, + reverse: function reverse() { + var action = new cc.FadeIn(); + action._reverseAction = this; + action.initWithDuration(this._duration, 255); + this._cloneDecoration(action); + this._reverseEaseList(action); + return action; + }, + clone: function clone() { + var action = new cc.FadeOut(); + this._cloneDecoration(action); + action.initWithDuration(this._duration, this._toOpacity); + return action; + } + }); + cc.fadeOut = function(d) { + return new cc.FadeOut(d); + }; + cc.TintTo = cc.Class({ + name: "cc.TintTo", + extends: cc.ActionInterval, + ctor: function ctor(duration, red, green, blue) { + this._to = cc.color(0, 0, 0); + this._from = cc.color(0, 0, 0); + if (red instanceof cc.Color) { + blue = red.b; + green = red.g; + red = red.r; + } + void 0 !== blue && this.initWithDuration(duration, red, green, blue); + }, + initWithDuration: function initWithDuration(duration, red, green, blue) { + if (cc.ActionInterval.prototype.initWithDuration.call(this, duration)) { + this._to = cc.color(red, green, blue); + return true; + } + return false; + }, + clone: function clone() { + var action = new cc.TintTo(); + this._cloneDecoration(action); + var locTo = this._to; + action.initWithDuration(this._duration, locTo.r, locTo.g, locTo.b); + return action; + }, + startWithTarget: function startWithTarget(target) { + cc.ActionInterval.prototype.startWithTarget.call(this, target); + this._from = this.target.color; + }, + update: function update(dt) { + dt = this._computeEaseTime(dt); + var locFrom = this._from, locTo = this._to; + locFrom && (this.target.color = cc.color(locFrom.r + (locTo.r - locFrom.r) * dt, locFrom.g + (locTo.g - locFrom.g) * dt, locFrom.b + (locTo.b - locFrom.b) * dt)); + } + }); + cc.tintTo = function(duration, red, green, blue) { + return new cc.TintTo(duration, red, green, blue); + }; + cc.TintBy = cc.Class({ + name: "cc.TintBy", + extends: cc.ActionInterval, + ctor: function ctor(duration, deltaRed, deltaGreen, deltaBlue) { + this._deltaR = 0; + this._deltaG = 0; + this._deltaB = 0; + this._fromR = 0; + this._fromG = 0; + this._fromB = 0; + void 0 !== deltaBlue && this.initWithDuration(duration, deltaRed, deltaGreen, deltaBlue); + }, + initWithDuration: function initWithDuration(duration, deltaRed, deltaGreen, deltaBlue) { + if (cc.ActionInterval.prototype.initWithDuration.call(this, duration)) { + this._deltaR = deltaRed; + this._deltaG = deltaGreen; + this._deltaB = deltaBlue; + return true; + } + return false; + }, + clone: function clone() { + var action = new cc.TintBy(); + this._cloneDecoration(action); + action.initWithDuration(this._duration, this._deltaR, this._deltaG, this._deltaB); + return action; + }, + startWithTarget: function startWithTarget(target) { + cc.ActionInterval.prototype.startWithTarget.call(this, target); + var color = target.color; + this._fromR = color.r; + this._fromG = color.g; + this._fromB = color.b; + }, + update: function update(dt) { + dt = this._computeEaseTime(dt); + this.target.color = cc.color(this._fromR + this._deltaR * dt, this._fromG + this._deltaG * dt, this._fromB + this._deltaB * dt); + }, + reverse: function reverse() { + var action = new cc.TintBy(this._duration, -this._deltaR, -this._deltaG, -this._deltaB); + this._cloneDecoration(action); + this._reverseEaseList(action); + return action; + } + }); + cc.tintBy = function(duration, deltaRed, deltaGreen, deltaBlue) { + return new cc.TintBy(duration, deltaRed, deltaGreen, deltaBlue); + }; + cc.DelayTime = cc.Class({ + name: "cc.DelayTime", + extends: cc.ActionInterval, + update: function update(dt) {}, + reverse: function reverse() { + var action = new cc.DelayTime(this._duration); + this._cloneDecoration(action); + this._reverseEaseList(action); + return action; + }, + clone: function clone() { + var action = new cc.DelayTime(); + this._cloneDecoration(action); + action.initWithDuration(this._duration); + return action; + } + }); + cc.delayTime = function(d) { + return new cc.DelayTime(d); + }; + cc.ReverseTime = cc.Class({ + name: "cc.ReverseTime", + extends: cc.ActionInterval, + ctor: function ctor(action) { + this._other = null; + action && this.initWithAction(action); + }, + initWithAction: function initWithAction(action) { + if (!action) { + cc.errorID(1028); + return false; + } + if (action === this._other) { + cc.errorID(1029); + return false; + } + if (cc.ActionInterval.prototype.initWithDuration.call(this, action._duration)) { + this._other = action; + return true; + } + return false; + }, + clone: function clone() { + var action = new cc.ReverseTime(); + this._cloneDecoration(action); + action.initWithAction(this._other.clone()); + return action; + }, + startWithTarget: function startWithTarget(target) { + cc.ActionInterval.prototype.startWithTarget.call(this, target); + this._other.startWithTarget(target); + }, + update: function update(dt) { + dt = this._computeEaseTime(dt); + this._other && this._other.update(1 - dt); + }, + reverse: function reverse() { + return this._other.clone(); + }, + stop: function stop() { + this._other.stop(); + cc.Action.prototype.stop.call(this); + } + }); + cc.reverseTime = function(action) { + return new cc.ReverseTime(action); + }; + cc.TargetedAction = cc.Class({ + name: "cc.TargetedAction", + extends: cc.ActionInterval, + ctor: function ctor(target, action) { + this._action = null; + this._forcedTarget = null; + action && this.initWithTarget(target, action); + }, + initWithTarget: function initWithTarget(target, action) { + if (this.initWithDuration(action._duration)) { + this._forcedTarget = target; + this._action = action; + return true; + } + return false; + }, + clone: function clone() { + var action = new cc.TargetedAction(); + this._cloneDecoration(action); + action.initWithTarget(this._forcedTarget, this._action.clone()); + return action; + }, + startWithTarget: function startWithTarget(target) { + cc.ActionInterval.prototype.startWithTarget.call(this, target); + this._action.startWithTarget(this._forcedTarget); + }, + stop: function stop() { + this._action.stop(); + }, + update: function update(dt) { + dt = this._computeEaseTime(dt); + this._action.update(dt); + }, + getForcedTarget: function getForcedTarget() { + return this._forcedTarget; + }, + setForcedTarget: function setForcedTarget(forcedTarget) { + this._forcedTarget !== forcedTarget && (this._forcedTarget = forcedTarget); + } + }); + cc.targetedAction = function(target, action) { + return new cc.TargetedAction(target, action); + }; + }), {} ], + 7: [ (function(require, module, exports) { + "use strict"; + require("../core/platform/CCClass"); + var js = require("../core/platform/js"); + var HashElement = function HashElement() { + this.actions = []; + this.target = null; + this.actionIndex = 0; + this.currentAction = null; + this.paused = false; + this.lock = false; + }; + cc.ActionManager = function() { + this._hashTargets = js.createMap(true); + this._arrayTargets = []; + this._currentTarget = null; + cc.director._scheduler && cc.director._scheduler.enableForTarget(this); + }; + cc.ActionManager.prototype = { + constructor: cc.ActionManager, + _elementPool: [], + _searchElementByTarget: function _searchElementByTarget(arr, target) { + for (var k = 0; k < arr.length; k++) if (target === arr[k].target) return arr[k]; + return null; + }, + _getElement: function _getElement(target, paused) { + var element = this._elementPool.pop(); + element || (element = new HashElement()); + element.target = target; + element.paused = !!paused; + return element; + }, + _putElement: function _putElement(element) { + element.actions.length = 0; + element.actionIndex = 0; + element.currentAction = null; + element.paused = false; + element.target = null; + element.lock = false; + this._elementPool.push(element); + }, + addAction: function addAction(action, target, paused) { + if (!action || !target) { + cc.errorID(1e3); + return; + } + var element = this._hashTargets[target._id]; + if (element) element.actions || (element.actions = []); else { + element = this._getElement(target, paused); + this._hashTargets[target._id] = element; + this._arrayTargets.push(element); + } + element.actions.push(action); + action.startWithTarget(target); + }, + removeAllActions: function removeAllActions() { + var locTargets = this._arrayTargets; + for (var i = 0; i < locTargets.length; i++) { + var element = locTargets[i]; + element && this._putElement(element); + } + this._arrayTargets.length = 0; + this._hashTargets = js.createMap(true); + }, + removeAllActionsFromTarget: function removeAllActionsFromTarget(target, forceDelete) { + if (null == target) return; + var element = this._hashTargets[target._id]; + if (element) { + element.actions.length = 0; + this._deleteHashElement(element); + } + }, + removeAction: function removeAction(action) { + if (!action) return; + var target = action.getOriginalTarget(); + var element = this._hashTargets[target._id]; + if (!element) return; + for (var i = 0; i < element.actions.length; i++) if (element.actions[i] === action) { + element.actions.splice(i, 1); + element.actionIndex >= i && element.actionIndex--; + break; + } + }, + _removeActionByTag: function _removeActionByTag(tag, element, target) { + for (var i = 0, l = element.actions.length; i < l; ++i) { + var action = element.actions[i]; + if (action && action.getTag() === tag) { + if (target && action.getOriginalTarget() !== target) continue; + this._removeActionAtIndex(i, element); + break; + } + } + }, + _removeAllActionsByTag: function _removeAllActionsByTag(tag, element, target) { + for (var i = element.actions.length - 1; i >= 0; --i) { + var action = element.actions[i]; + if (action && action.getTag() === tag) { + if (target && action.getOriginalTarget() !== target) continue; + this._removeActionAtIndex(i, element); + } + } + }, + removeActionByTag: function removeActionByTag(tag, target) { + tag === cc.Action.TAG_INVALID && cc.logID(1002); + var hashTargets = this._hashTargets; + if (target) { + var element = hashTargets[target._id]; + element && this._removeActionByTag(tag, element, target); + } else for (var name in hashTargets) { + var _element = hashTargets[name]; + this._removeActionByTag(tag, _element); + } + }, + removeAllActionsByTag: function removeAllActionsByTag(tag, target) { + tag === cc.Action.TAG_INVALID && cc.logID(1002); + var hashTargets = this._hashTargets; + if (target) { + var element = hashTargets[target._id]; + element && this._removeAllActionsByTag(tag, element, target); + } else for (var name in hashTargets) { + var _element2 = hashTargets[name]; + this._removeAllActionsByTag(tag, _element2); + } + }, + getActionByTag: function getActionByTag(tag, target) { + tag === cc.Action.TAG_INVALID && cc.logID(1004); + var element = this._hashTargets[target._id]; + if (element) { + if (null != element.actions) for (var i = 0; i < element.actions.length; ++i) { + var action = element.actions[i]; + if (action && action.getTag() === tag) return action; + } + cc.logID(1005, tag); + } + return null; + }, + getNumberOfRunningActionsInTarget: function getNumberOfRunningActionsInTarget(target) { + var element = this._hashTargets[target._id]; + if (element) return element.actions ? element.actions.length : 0; + return 0; + }, + pauseTarget: function pauseTarget(target) { + var element = this._hashTargets[target._id]; + element && (element.paused = true); + }, + resumeTarget: function resumeTarget(target) { + var element = this._hashTargets[target._id]; + element && (element.paused = false); + }, + pauseAllRunningActions: function pauseAllRunningActions() { + var idsWithActions = []; + var locTargets = this._arrayTargets; + for (var i = 0; i < locTargets.length; i++) { + var element = locTargets[i]; + if (element && !element.paused) { + element.paused = true; + idsWithActions.push(element.target); + } + } + return idsWithActions; + }, + resumeTargets: function resumeTargets(targetsToResume) { + if (!targetsToResume) return; + for (var i = 0; i < targetsToResume.length; i++) targetsToResume[i] && this.resumeTarget(targetsToResume[i]); + }, + pauseTargets: function pauseTargets(targetsToPause) { + if (!targetsToPause) return; + for (var i = 0; i < targetsToPause.length; i++) targetsToPause[i] && this.pauseTarget(targetsToPause[i]); + }, + purgeSharedManager: function purgeSharedManager() { + cc.director.getScheduler().unscheduleUpdate(this); + }, + _removeActionAtIndex: function _removeActionAtIndex(index, element) { + var action = element.actions[index]; + element.actions.splice(index, 1); + element.actionIndex >= index && element.actionIndex--; + 0 === element.actions.length && this._deleteHashElement(element); + }, + _deleteHashElement: function _deleteHashElement(element) { + var ret = false; + if (element && !element.lock && this._hashTargets[element.target._id]) { + delete this._hashTargets[element.target._id]; + var targets = this._arrayTargets; + for (var i = 0, l = targets.length; i < l; i++) if (targets[i] === element) { + targets.splice(i, 1); + break; + } + this._putElement(element); + ret = true; + } + return ret; + }, + update: function update(dt) { + var locTargets = this._arrayTargets, locCurrTarget; + for (var elt = 0; elt < locTargets.length; elt++) { + this._currentTarget = locTargets[elt]; + locCurrTarget = this._currentTarget; + if (!locCurrTarget.paused && locCurrTarget.actions) { + locCurrTarget.lock = true; + for (locCurrTarget.actionIndex = 0; locCurrTarget.actionIndex < locCurrTarget.actions.length; locCurrTarget.actionIndex++) { + locCurrTarget.currentAction = locCurrTarget.actions[locCurrTarget.actionIndex]; + if (!locCurrTarget.currentAction) continue; + locCurrTarget.currentAction.step(dt * (locCurrTarget.currentAction._speedMethod ? locCurrTarget.currentAction._speed : 1)); + if (locCurrTarget.currentAction && locCurrTarget.currentAction.isDone()) { + locCurrTarget.currentAction.stop(); + var action = locCurrTarget.currentAction; + locCurrTarget.currentAction = null; + this.removeAction(action); + } + locCurrTarget.currentAction = null; + } + locCurrTarget.lock = false; + } + 0 === locCurrTarget.actions.length && this._deleteHashElement(locCurrTarget) && elt--; + } + } + }; + false; + }), { + "../core/platform/CCClass": 240, + "../core/platform/js": 261 + } ], + 8: [ (function(require, module, exports) { + "use strict"; + require("./CCActionManager"); + require("./CCAction"); + require("./CCActionInterval"); + require("./CCActionInstant"); + require("./CCActionEase"); + require("./CCActionCatmullRom"); + require("./tween"); + }), { + "./CCAction": 2, + "./CCActionCatmullRom": 3, + "./CCActionEase": 4, + "./CCActionInstant": 5, + "./CCActionInterval": 6, + "./CCActionManager": 7, + "./tween": 9 + } ], + 9: [ (function(require, module, exports) { + "use strict"; + var _bezier = require("../animation/bezier"); + var _tweenID = 0; + var TweenAction = cc.Class({ + name: "cc.TweenAction", + extends: cc.ActionInterval, + ctor: function ctor(duration, props, opts) { + this._opts = opts = opts || Object.create(null); + this._props = Object.create(null); + opts.progress = opts.progress || this.progress; + if (opts.easing && "string" === typeof opts.easing) { + var easingName = opts.easing; + opts.easing = cc.easing[easingName]; + !opts.easing && cc.warnID(1031, easingName); + } + var relative = this._opts.relative; + for (var name in props) { + var value = props[name]; + var easing = void 0, progress = void 0; + if (void 0 !== value.value && (value.easing || value.progress)) { + if ("string" === typeof value.easing) { + easing = cc.easing[value.easing]; + !easing && cc.warnID(1031, value.easing); + } else easing = value.easing; + progress = value.progress; + value = value.value; + } + var isNumber = "number" === typeof value; + if (!isNumber && (!value.lerp || relative && !value.add && !value.mul || !value.clone)) { + cc.warn("Can not animate " + name + " property, because it do not have [lerp, (add|mul), clone] function."); + continue; + } + var prop = Object.create(null); + prop.value = value; + prop.easing = easing; + prop.progress = progress; + this._props[name] = prop; + } + this._originProps = props; + this.initWithDuration(duration); + }, + clone: function clone() { + var action = new TweenAction(this._duration, this._originProps, this._opts); + this._cloneDecoration(action); + return action; + }, + startWithTarget: function startWithTarget(target) { + cc.ActionInterval.prototype.startWithTarget.call(this, target); + var relative = !!this._opts.relative; + var props = this._props; + for (var name in props) { + var value = target[name]; + var prop = props[name]; + if ("number" === typeof value) { + prop.start = value; + prop.current = value; + prop.end = relative ? value + prop.value : prop.value; + } else { + prop.start = value.clone(); + prop.current = value.clone(); + prop.end = relative ? (value.add || value.mul).call(value, prop.value) : prop.value; + } + } + }, + update: function update(t) { + var opts = this._opts; + var easingTime = t; + opts.easing && (easingTime = opts.easing(t)); + var target = this.target; + if (!target) return; + var props = this._props; + var progress = opts.progress; + for (var name in props) { + var prop = props[name]; + var time = prop.easing ? prop.easing(t) : easingTime; + var current = prop.current = (prop.progress || progress)(prop.start, prop.end, prop.current, time); + target[name] = current; + } + var onUpdate = opts.onUpdate; + onUpdate && onUpdate(target, t); + }, + progress: function progress(start, end, current, t) { + "number" === typeof start ? current = start + (end - start) * t : start.lerp(end, t, current); + return current; + } + }); + var SetAction = cc.Class({ + name: "cc.SetAction", + extends: cc.ActionInstant, + ctor: function ctor(props) { + this._props = {}; + void 0 !== props && this.init(props); + }, + init: function init(props) { + for (var name in props) this._props[name] = props[name]; + return true; + }, + update: function update() { + var props = this._props; + var target = this.target; + for (var name in props) target[name] = props[name]; + }, + clone: function clone() { + var action = new SetAction(); + action.init(this._props); + return action; + } + }); + function Tween(target) { + this._actions = []; + this._finalAction = null; + this._target = target; + this._tag = cc.Action.TAG_INVALID; + } + Tween.stopAll = function() { + cc.director.getActionManager().removeAllActions(); + }; + Tween.stopAllByTag = function(tag) { + cc.director.getActionManager().removeAllActionsByTag(tag); + }; + Tween.stopAllByTarget = function(target) { + cc.director.getActionManager().removeAllActionsFromTarget(target); + }; + Tween.prototype.then = function(other) { + other instanceof cc.Action ? this._actions.push(other.clone()) : this._actions.push(other._union()); + return this; + }; + Tween.prototype.target = function(target) { + this._target = target; + return this; + }; + Tween.prototype.start = function() { + var target = this._target; + if (!target) { + cc.warn("Please set target to tween first"); + return this; + } + if (target instanceof cc.Object && !target.isValid) return; + this._finalAction && cc.director.getActionManager().removeAction(this._finalAction); + this._finalAction = this._union(); + void 0 === target._id && (target._id = ++_tweenID); + this._finalAction.setTag(this._tag); + cc.director.getActionManager().addAction(this._finalAction, target, false); + return this; + }; + Tween.prototype.stop = function() { + this._finalAction && cc.director.getActionManager().removeAction(this._finalAction); + return this; + }; + Tween.prototype.tag = function(tag) { + this._tag = tag; + return this; + }; + Tween.prototype.clone = function(target) { + var action = this._union(); + return cc.tween(target).then(action.clone()); + }; + Tween.prototype.union = function() { + var action = this._union(); + this._actions.length = 0; + this._actions.push(action); + return this; + }; + Tween.prototype._union = function() { + var actions = this._actions; + actions = 1 === actions.length ? actions[0] : cc.sequence(actions); + return actions; + }; + Object.assign(Tween.prototype, { + bezierTo: function bezierTo(duration, c1, c2, to, opts) { + var c0x = c1.x, c0y = c1.y, c1x = c2.x, c1y = c2.y; + opts = opts || Object.create(null); + opts.progress = function(start, end, current, t) { + current.x = (0, _bezier.bezier)(start.x, c0x, c1x, end.x, t); + current.y = (0, _bezier.bezier)(start.y, c0y, c1y, end.y, t); + return current; + }; + return this.to(duration, { + position: to + }, opts); + }, + bezierBy: function bezierBy(duration, c1, c2, to, opts) { + var c0x = c1.x, c0y = c1.y, c1x = c2.x, c1y = c2.y; + opts = opts || Object.create(null); + opts.progress = function(start, end, current, t) { + var sx = start.x, sy = start.y; + current.x = (0, _bezier.bezier)(sx, c0x + sx, c1x + sx, end.x, t); + current.y = (0, _bezier.bezier)(sy, c0y + sy, c1y + sy, end.y, t); + return current; + }; + return this.by(duration, { + position: to + }, opts); + }, + flipX: function flipX() { + var _this = this; + return this.call((function() { + _this._target.scaleX *= -1; + }), this); + }, + flipY: function flipY() { + var _this2 = this; + return this.call((function() { + _this2._target.scaleY *= -1; + }), this); + }, + blink: function blink(duration, times, opts) { + var slice = 1 / times; + opts = opts || Object.create(null); + opts.progress = function(start, end, current, t) { + if (t >= 1) return start; + var m = t % slice; + return m > slice / 2 ? 255 : 0; + }; + return this.to(duration, { + opacity: 1 + }, opts); + } + }); + var tmp_args = []; + function wrapAction(action) { + return function() { + tmp_args.length = 0; + for (var l = arguments.length, i = 0; i < l; i++) { + var arg = tmp_args[i] = arguments[i]; + arg instanceof Tween && (tmp_args[i] = arg._union()); + } + return action.apply(this, tmp_args); + }; + } + var actions = { + to: function to(duration, props, opts) { + opts = opts || Object.create(null); + opts.relative = false; + return new TweenAction(duration, props, opts); + }, + by: function by(duration, props, opts) { + opts = opts || Object.create(null); + opts.relative = true; + return new TweenAction(duration, props, opts); + }, + set: function set(props) { + return new SetAction(props); + }, + delay: cc.delayTime, + call: cc.callFunc, + hide: cc.hide, + show: cc.show, + removeSelf: cc.removeSelf, + sequence: wrapAction(cc.sequence), + parallel: wrapAction(cc.spawn) + }; + var previousAsInputActions = { + repeat: cc.repeat, + repeatForever: cc.repeatForever, + reverseTime: cc.reverseTime + }; + var keys = Object.keys(actions); + var _loop = function _loop(i) { + var key = keys[i]; + Tween.prototype[key] = function() { + var action = actions[key].apply(this, arguments); + this._actions.push(action); + return this; + }; + }; + for (var i = 0; i < keys.length; i++) _loop(i); + keys = Object.keys(previousAsInputActions); + var _loop2 = function _loop2(_i) { + var key = keys[_i]; + Tween.prototype[key] = function() { + var actions = this._actions; + var action = arguments[arguments.length - 1]; + var length = arguments.length - 1; + if (action instanceof cc.Tween) action = action._union(); else if (!(action instanceof cc.Action)) { + action = actions[actions.length - 1]; + actions.length -= 1; + length += 1; + } + var args = [ action ]; + for (var _i2 = 0; _i2 < length; _i2++) args.push(arguments[_i2]); + action = previousAsInputActions[key].apply(this, args); + actions.push(action); + return this; + }; + }; + for (var _i = 0; _i < keys.length; _i++) _loop2(_i); + cc.tween = function(target) { + return new Tween(target); + }; + cc.Tween = Tween; + }), { + "../animation/bezier": 15 + } ], + 10: [ (function(require, module, exports) { + "use strict"; + var js = cc.js; + var Playable = require("./playable"); + var _require = require("./animation-curves"), EventAnimCurve = _require.EventAnimCurve, EventInfo = _require.EventInfo; + var WrapModeMask = require("./types").WrapModeMask; + var binarySearch = require("../core/utils/binary-search").binarySearchEpsilon; + function AnimationAnimator(target, animation) { + Playable.call(this); + this.target = target; + this.animation = animation; + this._anims = new js.array.MutableForwardIterator([]); + } + js.extend(AnimationAnimator, Playable); + var p = AnimationAnimator.prototype; + p.playState = function(state, startTime) { + if (!state.clip) return; + state.curveLoaded || initClipData(this.target, state); + state.animator = this; + state.play(); + "number" === typeof startTime && state.setTime(startTime); + this.play(); + }; + p.stopStatesExcept = function(state) { + var iterator = this._anims; + var array = iterator.array; + for (iterator.i = 0; iterator.i < array.length; ++iterator.i) { + var anim = array[iterator.i]; + if (anim === state) continue; + this.stopState(anim); + } + }; + p.addAnimation = function(anim) { + var index = this._anims.array.indexOf(anim); + -1 === index && this._anims.push(anim); + anim._setEventTarget(this.animation); + }; + p.removeAnimation = function(anim) { + var index = this._anims.array.indexOf(anim); + if (index >= 0) { + this._anims.fastRemoveAt(index); + 0 === this._anims.array.length && this.stop(); + } else cc.errorID(3907); + anim.animator = null; + }; + p.sample = function() { + var iterator = this._anims; + var array = iterator.array; + for (iterator.i = 0; iterator.i < array.length; ++iterator.i) { + var anim = array[iterator.i]; + anim.sample(); + } + }; + p.stopState = function(state) { + state && state.stop(); + }; + p.pauseState = function(state) { + state && state.pause(); + }; + p.resumeState = function(state) { + state && state.resume(); + this.isPaused && this.resume(); + }; + p.setStateTime = function(state, time) { + if (void 0 !== time) { + if (state) { + state.setTime(time); + state.sample(); + } + } else { + time = state; + var array = this._anims.array; + for (var i = 0; i < array.length; ++i) { + var anim = array[i]; + anim.setTime(time); + anim.sample(); + } + } + }; + p.onStop = function() { + var iterator = this._anims; + var array = iterator.array; + for (iterator.i = 0; iterator.i < array.length; ++iterator.i) { + var anim = array[iterator.i]; + anim.stop(); + } + }; + p.onPause = function() { + var array = this._anims.array; + for (var i = 0; i < array.length; ++i) { + var anim = array[i]; + anim.pause(); + anim.animator = null; + } + }; + p.onResume = function() { + var array = this._anims.array; + for (var i = 0; i < array.length; ++i) { + var anim = array[i]; + anim.animator = this; + anim.resume(); + } + }; + p._reloadClip = function(state) { + initClipData(this.target, state); + }; + function createBatchedProperty(propPath, firstDotIndex, mainValue, animValue) { + mainValue = mainValue.clone(); + var nextValue = mainValue; + var leftIndex = firstDotIndex + 1; + var rightIndex = propPath.indexOf(".", leftIndex); + while (-1 !== rightIndex) { + var nextName = propPath.slice(leftIndex, rightIndex); + nextValue = nextValue[nextName]; + leftIndex = rightIndex + 1; + rightIndex = propPath.indexOf(".", leftIndex); + } + var lastPropName = propPath.slice(leftIndex); + nextValue[lastPropName] = animValue; + return mainValue; + } + false; + function initClipData(root, state) { + var clip = state.clip; + state.duration = clip.duration; + state.speed = clip.speed; + state.wrapMode = clip.wrapMode; + state.frameRate = clip.sample; + (state.wrapMode & WrapModeMask.Loop) === WrapModeMask.Loop ? state.repeatCount = Infinity : state.repeatCount = 1; + var curves = state.curves = clip.createCurves(state, root); + var events = clip.events; + if (true, events) { + var curve; + for (var i = 0, l = events.length; i < l; i++) { + if (!curve) { + curve = new EventAnimCurve(); + curve.target = root; + curves.push(curve); + } + var eventData = events[i]; + var ratio = eventData.frame / state.duration; + var eventInfo = void 0; + var index = binarySearch(curve.ratios, ratio); + if (index >= 0) eventInfo = curve.events[index]; else { + eventInfo = new EventInfo(); + curve.ratios.push(ratio); + curve.events.push(eventInfo); + } + eventInfo.add(eventData.func, eventData.params); + } + } + } + false; + module.exports = AnimationAnimator; + }), { + "../core/utils/binary-search": 318, + "./animation-curves": 12, + "./playable": 19, + "./types": 20 + } ], + 11: [ (function(require, module, exports) { + "use strict"; + var WrapMode = require("./types").WrapMode; + var _require = require("./animation-curves"), DynamicAnimCurve = _require.DynamicAnimCurve, quickFindIndex = _require.quickFindIndex; + var sampleMotionPaths = require("./motion-path-helper").sampleMotionPaths; + var binarySearch = require("../core/utils/binary-search").binarySearchEpsilon; + var AnimationClip = cc.Class({ + name: "cc.AnimationClip", + extends: cc.Asset, + properties: { + _duration: { + default: 0, + type: cc.Float + }, + duration: { + get: function get() { + return this._duration; + } + }, + sample: { + default: 60 + }, + speed: { + default: 1 + }, + wrapMode: { + default: WrapMode.Normal + }, + curveData: { + default: {}, + visible: false + }, + events: { + default: [], + visible: false + } + }, + statics: { + createWithSpriteFrames: function createWithSpriteFrames(spriteFrames, sample) { + if (!Array.isArray(spriteFrames)) { + cc.errorID(3905); + return null; + } + var clip = new AnimationClip(); + clip.sample = sample || clip.sample; + clip._duration = spriteFrames.length / clip.sample; + var frames = []; + var step = 1 / clip.sample; + for (var i = 0, l = spriteFrames.length; i < l; i++) frames[i] = { + frame: i * step, + value: spriteFrames[i] + }; + clip.curveData = { + comps: { + "cc.Sprite": { + spriteFrame: frames + } + } + }; + return clip; + } + }, + onLoad: function onLoad() { + this._duration = Number.parseFloat(this.duration); + this.speed = Number.parseFloat(this.speed); + this.wrapMode = Number.parseInt(this.wrapMode); + this.frameRate = Number.parseFloat(this.sample); + }, + createPropCurve: function createPropCurve(target, propPath, keyframes) { + var motionPaths = []; + var isMotionPathProp = target instanceof cc.Node && "position" === propPath; + var curve = new DynamicAnimCurve(); + curve.target = target; + curve.prop = propPath; + for (var i = 0, l = keyframes.length; i < l; i++) { + var keyframe = keyframes[i]; + var ratio = keyframe.frame / this.duration; + curve.ratios.push(ratio); + isMotionPathProp && motionPaths.push(keyframe.motionPath); + var curveValue = keyframe.value; + curve.values.push(curveValue); + var curveTypes = keyframe.curve; + if (curveTypes) { + if ("string" === typeof curveTypes) { + curve.types.push(curveTypes); + continue; + } + if (Array.isArray(curveTypes)) { + curveTypes[0] === curveTypes[1] && curveTypes[2] === curveTypes[3] ? curve.types.push(DynamicAnimCurve.Linear) : curve.types.push(DynamicAnimCurve.Bezier(curveTypes)); + continue; + } + } + curve.types.push(DynamicAnimCurve.Linear); + } + isMotionPathProp && sampleMotionPaths(motionPaths, curve, this.duration, this.sample, target); + var ratios = curve.ratios; + var currRatioDif, lastRatioDif; + var canOptimize = true; + var EPSILON = 1e-6; + for (var _i = 1, _l = ratios.length; _i < _l; _i++) { + currRatioDif = ratios[_i] - ratios[_i - 1]; + if (1 === _i) lastRatioDif = currRatioDif; else if (Math.abs(currRatioDif - lastRatioDif) > EPSILON) { + canOptimize = false; + break; + } + } + curve._findFrameIndex = canOptimize ? quickFindIndex : binarySearch; + var firstValue = curve.values[0]; + void 0 === firstValue || null === firstValue || curve._lerp || ("number" === typeof firstValue ? curve._lerp = DynamicAnimCurve.prototype._lerpNumber : firstValue instanceof cc.Quat ? curve._lerp = DynamicAnimCurve.prototype._lerpQuat : firstValue instanceof cc.Vec2 ? curve._lerp = DynamicAnimCurve.prototype._lerpVector2 : firstValue instanceof cc.Vec3 ? curve._lerp = DynamicAnimCurve.prototype._lerpVector3 : firstValue.lerp && (curve._lerp = DynamicAnimCurve.prototype._lerpObject)); + return curve; + }, + createTargetCurves: function createTargetCurves(target, curveData, curves) { + var propsData = curveData.props; + var compsData = curveData.comps; + if (propsData) for (var propPath in propsData) { + var data = propsData[propPath]; + var curve = this.createPropCurve(target, propPath, data); + curves.push(curve); + } + if (compsData) for (var compName in compsData) { + var comp = target.getComponent(compName); + if (!comp) continue; + var compData = compsData[compName]; + for (var _propPath in compData) { + var _data = compData[_propPath]; + var _curve = this.createPropCurve(comp, _propPath, _data); + curves.push(_curve); + } + } + }, + createCurves: function createCurves(state, root) { + var curveData = this.curveData; + var childrenCurveDatas = curveData.paths; + var curves = []; + this.createTargetCurves(root, curveData, curves); + for (var namePath in childrenCurveDatas) { + var target = cc.find(namePath, root); + if (!target) continue; + var childCurveDatas = childrenCurveDatas[namePath]; + this.createTargetCurves(target, childCurveDatas, curves); + } + return curves; + } + }); + cc.AnimationClip = module.exports = AnimationClip; + }), { + "../core/utils/binary-search": 318, + "./animation-curves": 12, + "./motion-path-helper": 18, + "./types": 20 + } ], + 12: [ (function(require, module, exports) { + "use strict"; + var bezierByTime = require("./bezier").bezierByTime; + var binarySearch = require("../core/utils/binary-search").binarySearchEpsilon; + var WrapModeMask = require("./types").WrapModeMask; + var WrappedInfo = require("./types").WrappedInfo; + function computeRatioByType(ratio, type) { + if ("string" === typeof type) { + var func = cc.easing[type]; + func ? ratio = func(ratio) : cc.errorID(3906, type); + } else Array.isArray(type) && (ratio = bezierByTime(type, ratio)); + return ratio; + } + var AnimCurve = cc.Class({ + name: "cc.AnimCurve", + sample: function sample(time, ratio, state) {}, + onTimeChangedManually: void 0 + }); + function quickFindIndex(ratios, ratio) { + var length = ratios.length - 1; + if (0 === length) return 0; + var start = ratios[0]; + if (ratio < start) return 0; + var end = ratios[length]; + if (ratio > end) return ~ratios.length; + ratio = (ratio - start) / (end - start); + var eachLength = 1 / length; + var index = ratio / eachLength; + var floorIndex = 0 | index; + var EPSILON = 1e-6; + if (index - floorIndex < EPSILON) return floorIndex; + if (floorIndex + 1 - index < EPSILON) return floorIndex + 1; + return ~(floorIndex + 1); + } + var DynamicAnimCurve = cc.Class({ + name: "cc.DynamicAnimCurve", + extends: AnimCurve, + ctor: function ctor() { + this._cachedIndex = 0; + }, + properties: { + target: null, + prop: "", + values: [], + ratios: [], + types: [] + }, + _findFrameIndex: binarySearch, + _lerp: void 0, + _lerpNumber: function _lerpNumber(from, to, t) { + return from + (to - from) * t; + }, + _lerpObject: function _lerpObject(from, to, t) { + return from.lerp(to, t); + }, + _lerpQuat: (function() { + var out = cc.quat(); + return function(from, to, t) { + return from.lerp(to, t, out); + }; + })(), + _lerpVector2: (function() { + var out = cc.v2(); + return function(from, to, t) { + return from.lerp(to, t, out); + }; + })(), + _lerpVector3: (function() { + var out = cc.v3(); + return function(from, to, t) { + return from.lerp(to, t, out); + }; + })(), + sample: function sample(time, ratio, state) { + var values = this.values; + var ratios = this.ratios; + var frameCount = ratios.length; + if (0 === frameCount) return; + var shoudRefind = true; + var cachedIndex = this._cachedIndex; + if (cachedIndex < 0) { + cachedIndex = ~cachedIndex; + if (cachedIndex > 0 && cachedIndex < ratios.length) { + var _fromRatio = ratios[cachedIndex - 1]; + var _toRatio = ratios[cachedIndex]; + ratio > _fromRatio && ratio < _toRatio && (shoudRefind = false); + } + } + shoudRefind && (this._cachedIndex = this._findFrameIndex(ratios, ratio)); + var value; + var index = this._cachedIndex; + if (index < 0) { + index = ~index; + if (index <= 0) value = values[0]; else if (index >= frameCount) value = values[frameCount - 1]; else { + var fromVal = values[index - 1]; + if (this._lerp) { + var fromRatio = ratios[index - 1]; + var toRatio = ratios[index]; + var type = this.types[index - 1]; + var ratioBetweenFrames = (ratio - fromRatio) / (toRatio - fromRatio); + type && (ratioBetweenFrames = computeRatioByType(ratioBetweenFrames, type)); + var toVal = values[index]; + value = this._lerp(fromVal, toVal, ratioBetweenFrames); + } else value = fromVal; + } + } else value = values[index]; + this.target[this.prop] = value; + } + }); + DynamicAnimCurve.Linear = null; + DynamicAnimCurve.Bezier = function(controlPoints) { + return controlPoints; + }; + var EventInfo = function EventInfo() { + this.events = []; + }; + EventInfo.prototype.add = function(func, params) { + this.events.push({ + func: func || "", + params: params || [] + }); + }; + var EventAnimCurve = cc.Class({ + name: "cc.EventAnimCurve", + extends: AnimCurve, + properties: { + target: null, + ratios: [], + events: [], + _wrappedInfo: { + default: function _default() { + return new WrappedInfo(); + } + }, + _lastWrappedInfo: null, + _ignoreIndex: NaN + }, + _wrapIterations: function _wrapIterations(iterations) { + iterations - (0 | iterations) === 0 && (iterations -= 1); + return 0 | iterations; + }, + sample: function sample(time, ratio, state) { + var length = this.ratios.length; + var currentWrappedInfo = state.getWrappedInfo(state.time, this._wrappedInfo); + var direction = currentWrappedInfo.direction; + var currentIndex = binarySearch(this.ratios, currentWrappedInfo.ratio); + if (currentIndex < 0) { + currentIndex = ~currentIndex - 1; + direction < 0 && (currentIndex += 1); + } + this._ignoreIndex !== currentIndex && (this._ignoreIndex = NaN); + currentWrappedInfo.frameIndex = currentIndex; + if (!this._lastWrappedInfo) { + this._fireEvent(currentIndex); + this._lastWrappedInfo = new WrappedInfo(currentWrappedInfo); + return; + } + var wrapMode = state.wrapMode; + var currentIterations = this._wrapIterations(currentWrappedInfo.iterations); + var lastWrappedInfo = this._lastWrappedInfo; + var lastIterations = this._wrapIterations(lastWrappedInfo.iterations); + var lastIndex = lastWrappedInfo.frameIndex; + var lastDirection = lastWrappedInfo.direction; + var interationsChanged = -1 !== lastIterations && currentIterations !== lastIterations; + if (lastIndex === currentIndex && interationsChanged && 1 === length) this._fireEvent(0); else if (lastIndex !== currentIndex || interationsChanged) { + direction = lastDirection; + do { + if (lastIndex !== currentIndex) { + if (-1 === direction && 0 === lastIndex && currentIndex > 0) { + (wrapMode & WrapModeMask.PingPong) === WrapModeMask.PingPong ? direction *= -1 : lastIndex = length; + lastIterations++; + } else if (1 === direction && lastIndex === length - 1 && currentIndex < length - 1) { + (wrapMode & WrapModeMask.PingPong) === WrapModeMask.PingPong ? direction *= -1 : lastIndex = -1; + lastIterations++; + } + if (lastIndex === currentIndex) break; + if (lastIterations > currentIterations) break; + } + lastIndex += direction; + cc.director.getAnimationManager().pushDelayEvent(this, "_fireEvent", [ lastIndex ]); + } while (lastIndex !== currentIndex && lastIndex > -1 && lastIndex < length); + } + this._lastWrappedInfo.set(currentWrappedInfo); + }, + _fireEvent: function _fireEvent(index) { + if (index < 0 || index >= this.events.length || this._ignoreIndex === index) return; + var eventInfo = this.events[index]; + var events = eventInfo.events; + if (!this.target.isValid) return; + var components = this.target._components; + for (var i = 0; i < events.length; i++) { + var event = events[i]; + var funcName = event.func; + for (var j = 0; j < components.length; j++) { + var component = components[j]; + var func = component[funcName]; + func && func.apply(component, event.params); + } + } + }, + onTimeChangedManually: function onTimeChangedManually(time, state) { + this._lastWrappedInfo = null; + this._ignoreIndex = NaN; + var info = state.getWrappedInfo(time, this._wrappedInfo); + var direction = info.direction; + var frameIndex = binarySearch(this.ratios, info.ratio); + if (frameIndex < 0) { + frameIndex = ~frameIndex - 1; + direction < 0 && (frameIndex += 1); + this._ignoreIndex = frameIndex; + } + } + }); + false; + module.exports = { + AnimCurve: AnimCurve, + DynamicAnimCurve: DynamicAnimCurve, + EventAnimCurve: EventAnimCurve, + EventInfo: EventInfo, + computeRatioByType: computeRatioByType, + quickFindIndex: quickFindIndex + }; + }), { + "../core/utils/binary-search": 318, + "./bezier": 15, + "./types": 20 + } ], + 13: [ (function(require, module, exports) { + "use strict"; + var js = cc.js; + var AnimationManager = cc.Class({ + ctor: function ctor() { + this._anims = new js.array.MutableForwardIterator([]); + this._delayEvents = []; + cc.director._scheduler && cc.director._scheduler.enableForTarget(this); + }, + update: function update(dt) { + var iterator = this._anims; + var array = iterator.array; + for (iterator.i = 0; iterator.i < array.length; ++iterator.i) { + var anim = array[iterator.i]; + anim._isPlaying && !anim._isPaused && anim.update(dt); + } + var events = this._delayEvents; + for (var i = 0; i < events.length; i++) { + var event = events[i]; + event.target[event.func].apply(event.target, event.args); + } + events.length = 0; + }, + destruct: function destruct() {}, + addAnimation: function addAnimation(anim) { + var index = this._anims.array.indexOf(anim); + -1 === index && this._anims.push(anim); + }, + removeAnimation: function removeAnimation(anim) { + var index = this._anims.array.indexOf(anim); + index >= 0 ? this._anims.fastRemoveAt(index) : cc.errorID(3907); + }, + pushDelayEvent: function pushDelayEvent(target, func, args) { + this._delayEvents.push({ + target: target, + func: func, + args: args + }); + } + }); + cc.AnimationManager = module.exports = AnimationManager; + }), {} ], + 14: [ (function(require, module, exports) { + "use strict"; + var js = cc.js; + var Playable = require("./playable"); + var Types = require("./types"); + var WrappedInfo = Types.WrappedInfo; + var WrapMode = Types.WrapMode; + var WrapModeMask = Types.WrapModeMask; + function AnimationState(clip, name) { + Playable.call(this); + this._currentFramePlayed = false; + this._delay = 0; + this._delayTime = 0; + this._wrappedInfo = new WrappedInfo(); + this._lastWrappedInfo = null; + this._process = process; + this._clip = clip; + this._name = name || clip && clip.name; + this.animator = null; + this.curves = []; + this.delay = 0; + this.repeatCount = 1; + this.duration = 1; + this.speed = 1; + this.wrapMode = WrapMode.Normal; + this.time = 0; + this._target = null; + this._lastframeEventOn = false; + this.emit = function() { + var args = new Array(arguments.length); + for (var i = 0, l = args.length; i < l; i++) args[i] = arguments[i]; + cc.director.getAnimationManager().pushDelayEvent(this, "_emit", args); + }; + } + js.extend(AnimationState, Playable); + var proto = AnimationState.prototype; + proto._emit = function(type, state) { + this._target && this._target.isValid && this._target.emit(type, type, state); + }; + proto.on = function(type, callback, target) { + if (this._target && this._target.isValid) { + "lastframe" === type && (this._lastframeEventOn = true); + return this._target.on(type, callback, target); + } + return null; + }; + proto.once = function(type, callback, target) { + if (this._target && this._target.isValid) { + "lastframe" === type && (this._lastframeEventOn = true); + var self = this; + return this._target.once(type, (function(event) { + callback.call(target, event); + self._lastframeEventOn = false; + })); + } + return null; + }; + proto.off = function(type, callback, target) { + if (this._target && this._target.isValid) { + "lastframe" === type && (this._target.hasEventListener(type) || (this._lastframeEventOn = false)); + this._target.off(type, callback, target); + } + }; + proto._setEventTarget = function(target) { + this._target = target; + }; + proto.onPlay = function() { + this.setTime(0); + this._delayTime = this._delay; + cc.director.getAnimationManager().addAnimation(this); + this.animator && this.animator.addAnimation(this); + this.emit("play", this); + }; + proto.onStop = function() { + this.isPaused || cc.director.getAnimationManager().removeAnimation(this); + this.animator && this.animator.removeAnimation(this); + this.emit("stop", this); + }; + proto.onResume = function() { + cc.director.getAnimationManager().addAnimation(this); + this.emit("resume", this); + }; + proto.onPause = function() { + cc.director.getAnimationManager().removeAnimation(this); + this.emit("pause", this); + }; + proto.setTime = function(time) { + this._currentFramePlayed = false; + this.time = time || 0; + var curves = this.curves; + for (var i = 0, l = curves.length; i < l; i++) { + var curve = curves[i]; + curve.onTimeChangedManually && curve.onTimeChangedManually(time, this); + } + }; + function process() { + var info = this.sample(); + if (this._lastframeEventOn) { + var lastInfo; + lastInfo = this._lastWrappedInfo ? this._lastWrappedInfo : this._lastWrappedInfo = new WrappedInfo(info); + this.repeatCount > 1 && (0 | info.iterations) > (0 | lastInfo.iterations) && this.emit("lastframe", this); + lastInfo.set(info); + } + if (info.stopped) { + this.stop(); + this.emit("finished", this); + } + } + function simpleProcess() { + var time = this.time; + var duration = this.duration; + if (time > duration) { + time %= duration; + 0 === time && (time = duration); + } else if (time < 0) { + time %= duration; + 0 !== time && (time += duration); + } + var ratio = time / duration; + var curves = this.curves; + for (var i = 0, len = curves.length; i < len; i++) { + var curve = curves[i]; + curve.sample(time, ratio, this); + } + if (this._lastframeEventOn) { + void 0 === this._lastIterations && (this._lastIterations = ratio); + (this.time > 0 && this._lastIterations > ratio || this.time < 0 && this._lastIterations < ratio) && this.emit("lastframe", this); + this._lastIterations = ratio; + } + } + proto.update = function(delta) { + if (this._delayTime > 0) { + this._delayTime -= delta; + if (this._delayTime > 0) return; + } + this._currentFramePlayed ? this.time += delta * this.speed : this._currentFramePlayed = true; + this._process(); + }; + proto._needRevers = function(currentIterations) { + var wrapMode = this.wrapMode; + var needRevers = false; + if ((wrapMode & WrapModeMask.PingPong) === WrapModeMask.PingPong) { + var isEnd = currentIterations - (0 | currentIterations) === 0; + isEnd && currentIterations > 0 && (currentIterations -= 1); + var isOddIteration = 1 & currentIterations; + isOddIteration && (needRevers = !needRevers); + } + (wrapMode & WrapModeMask.Reverse) === WrapModeMask.Reverse && (needRevers = !needRevers); + return needRevers; + }; + proto.getWrappedInfo = function(time, info) { + info = info || new WrappedInfo(); + var stopped = false; + var duration = this.duration; + var repeatCount = this.repeatCount; + var currentIterations = time > 0 ? time / duration : -time / duration; + if (currentIterations >= repeatCount) { + currentIterations = repeatCount; + stopped = true; + var tempRatio = repeatCount - (0 | repeatCount); + 0 === tempRatio && (tempRatio = 1); + time = tempRatio * duration * (time > 0 ? 1 : -1); + } + if (time > duration) { + var tempTime = time % duration; + time = 0 === tempTime ? duration : tempTime; + } else if (time < 0) { + time %= duration; + 0 !== time && (time += duration); + } + var needRevers = false; + var shouldWrap = this._wrapMode & WrapModeMask.ShouldWrap; + shouldWrap && (needRevers = this._needRevers(currentIterations)); + var direction = needRevers ? -1 : 1; + this.speed < 0 && (direction *= -1); + shouldWrap && needRevers && (time = duration - time); + info.ratio = time / duration; + info.time = time; + info.direction = direction; + info.stopped = stopped; + info.iterations = currentIterations; + return info; + }; + proto.sample = function() { + var info = this.getWrappedInfo(this.time, this._wrappedInfo); + var curves = this.curves; + for (var i = 0, len = curves.length; i < len; i++) { + var curve = curves[i]; + curve.sample(info.time, info.ratio, this); + } + return info; + }; + js.get(proto, "clip", (function() { + return this._clip; + })); + js.get(proto, "name", (function() { + return this._name; + })); + js.obsolete(proto, "AnimationState.length", "duration"); + js.getset(proto, "curveLoaded", (function() { + return this.curves.length > 0; + }), (function() { + this.curves.length = 0; + })); + js.getset(proto, "wrapMode", (function() { + return this._wrapMode; + }), (function(value) { + this._wrapMode = value; + false; + this.time = 0; + value & WrapModeMask.Loop ? this.repeatCount = Infinity : this.repeatCount = 1; + })); + js.getset(proto, "repeatCount", (function() { + return this._repeatCount; + }), (function(value) { + this._repeatCount = value; + var shouldWrap = this._wrapMode & WrapModeMask.ShouldWrap; + var reverse = (this.wrapMode & WrapModeMask.Reverse) === WrapModeMask.Reverse; + this._process = Infinity !== value || shouldWrap || reverse ? process : simpleProcess; + })); + js.getset(proto, "delay", (function() { + return this._delay; + }), (function(value) { + this._delayTime = this._delay = value; + })); + cc.AnimationState = module.exports = AnimationState; + }), { + "./playable": 19, + "./types": 20 + } ], + 15: [ (function(require, module, exports) { + "use strict"; + function bezier(C1, C2, C3, C4, t) { + var t1 = 1 - t; + return t1 * (t1 * (C1 + (3 * C2 - C1) * t) + 3 * C3 * t * t) + C4 * t * t * t; + } + var cos = Math.cos, acos = Math.acos, max = Math.max, pi = Math.PI, tau = 2 * pi, sqrt = Math.sqrt; + function crt(v) { + return v < 0 ? -Math.pow(-v, 1 / 3) : Math.pow(v, 1 / 3); + } + function cardano(curve, x) { + var pa = x - 0; + var pb = x - curve[0]; + var pc = x - curve[2]; + var pd = x - 1; + var pa3 = 3 * pa; + var pb3 = 3 * pb; + var pc3 = 3 * pc; + var d = -pa + pb3 - pc3 + pd, rd = 1 / d, r3 = 1 / 3, a = (pa3 - 6 * pb + pc3) * rd, a3 = a * r3, b = (-pa3 + pb3) * rd, c = pa * rd, p = (3 * b - a * a) * r3, p3 = p * r3, q = (2 * a * a * a - 9 * a * b + 27 * c) / 27, q2 = q / 2, discriminant = q2 * q2 + p3 * p3 * p3, u1, v1, x1, x2, x3; + if (discriminant < 0) { + var mp3 = -p * r3, mp33 = mp3 * mp3 * mp3, r = sqrt(mp33), t = -q / (2 * r), cosphi = t < -1 ? -1 : t > 1 ? 1 : t, phi = acos(cosphi), crtr = crt(r), t1 = 2 * crtr; + x1 = t1 * cos(phi * r3) - a3; + x2 = t1 * cos((phi + tau) * r3) - a3; + x3 = t1 * cos((phi + 2 * tau) * r3) - a3; + return 0 <= x1 && x1 <= 1 ? 0 <= x2 && x2 <= 1 ? 0 <= x3 && x3 <= 1 ? max(x1, x2, x3) : max(x1, x2) : 0 <= x3 && x3 <= 1 ? max(x1, x3) : x1 : 0 <= x2 && x2 <= 1 ? 0 <= x3 && x3 <= 1 ? max(x2, x3) : x2 : x3; + } + if (0 === discriminant) { + u1 = q2 < 0 ? crt(-q2) : -crt(q2); + x1 = 2 * u1 - a3; + x2 = -u1 - a3; + return 0 <= x1 && x1 <= 1 ? 0 <= x2 && x2 <= 1 ? max(x1, x2) : x1 : x2; + } + var sd = sqrt(discriminant); + u1 = crt(-q2 + sd); + v1 = crt(q2 + sd); + x1 = u1 - v1 - a3; + return x1; + } + function bezierByTime(controlPoints, x) { + var percent = cardano(controlPoints, x); + var p1y = controlPoints[1]; + var p2y = controlPoints[3]; + return ((1 - percent) * (p1y + (p2y - p1y) * percent) * 3 + percent * percent) * percent; + } + false; + module.exports = { + bezier: bezier, + bezierByTime: bezierByTime + }; + }), {} ], + 16: [ (function(require, module, exports) { + "use strict"; + var easing = { + constant: function constant() { + return 0; + }, + linear: function linear(k) { + return k; + }, + quadIn: function quadIn(k) { + return k * k; + }, + quadOut: function quadOut(k) { + return k * (2 - k); + }, + quadInOut: function quadInOut(k) { + if ((k *= 2) < 1) return .5 * k * k; + return -.5 * (--k * (k - 2) - 1); + }, + cubicIn: function cubicIn(k) { + return k * k * k; + }, + cubicOut: function cubicOut(k) { + return --k * k * k + 1; + }, + cubicInOut: function cubicInOut(k) { + if ((k *= 2) < 1) return .5 * k * k * k; + return .5 * ((k -= 2) * k * k + 2); + }, + quartIn: function quartIn(k) { + return k * k * k * k; + }, + quartOut: function quartOut(k) { + return 1 - --k * k * k * k; + }, + quartInOut: function quartInOut(k) { + if ((k *= 2) < 1) return .5 * k * k * k * k; + return -.5 * ((k -= 2) * k * k * k - 2); + }, + quintIn: function quintIn(k) { + return k * k * k * k * k; + }, + quintOut: function quintOut(k) { + return --k * k * k * k * k + 1; + }, + quintInOut: function quintInOut(k) { + if ((k *= 2) < 1) return .5 * k * k * k * k * k; + return .5 * ((k -= 2) * k * k * k * k + 2); + }, + sineIn: function sineIn(k) { + return 1 - Math.cos(k * Math.PI / 2); + }, + sineOut: function sineOut(k) { + return Math.sin(k * Math.PI / 2); + }, + sineInOut: function sineInOut(k) { + return .5 * (1 - Math.cos(Math.PI * k)); + }, + expoIn: function expoIn(k) { + return 0 === k ? 0 : Math.pow(1024, k - 1); + }, + expoOut: function expoOut(k) { + return 1 === k ? 1 : 1 - Math.pow(2, -10 * k); + }, + expoInOut: function expoInOut(k) { + if (0 === k) return 0; + if (1 === k) return 1; + if ((k *= 2) < 1) return .5 * Math.pow(1024, k - 1); + return .5 * (2 - Math.pow(2, -10 * (k - 1))); + }, + circIn: function circIn(k) { + return 1 - Math.sqrt(1 - k * k); + }, + circOut: function circOut(k) { + return Math.sqrt(1 - --k * k); + }, + circInOut: function circInOut(k) { + if ((k *= 2) < 1) return -.5 * (Math.sqrt(1 - k * k) - 1); + return .5 * (Math.sqrt(1 - (k -= 2) * k) + 1); + }, + elasticIn: function elasticIn(k) { + var s, a = .1, p = .4; + if (0 === k) return 0; + if (1 === k) return 1; + if (!a || a < 1) { + a = 1; + s = p / 4; + } else s = p * Math.asin(1 / a) / (2 * Math.PI); + return -a * Math.pow(2, 10 * (k -= 1)) * Math.sin((k - s) * (2 * Math.PI) / p); + }, + elasticOut: function elasticOut(k) { + var s, a = .1, p = .4; + if (0 === k) return 0; + if (1 === k) return 1; + if (!a || a < 1) { + a = 1; + s = p / 4; + } else s = p * Math.asin(1 / a) / (2 * Math.PI); + return a * Math.pow(2, -10 * k) * Math.sin((k - s) * (2 * Math.PI) / p) + 1; + }, + elasticInOut: function elasticInOut(k) { + var s, a = .1, p = .4; + if (0 === k) return 0; + if (1 === k) return 1; + if (!a || a < 1) { + a = 1; + s = p / 4; + } else s = p * Math.asin(1 / a) / (2 * Math.PI); + if ((k *= 2) < 1) return a * Math.pow(2, 10 * (k -= 1)) * Math.sin((k - s) * (2 * Math.PI) / p) * -.5; + return a * Math.pow(2, -10 * (k -= 1)) * Math.sin((k - s) * (2 * Math.PI) / p) * .5 + 1; + }, + backIn: function backIn(k) { + var s = 1.70158; + return k * k * ((s + 1) * k - s); + }, + backOut: function backOut(k) { + var s = 1.70158; + return --k * k * ((s + 1) * k + s) + 1; + }, + backInOut: function backInOut(k) { + var s = 2.5949095; + if ((k *= 2) < 1) return k * k * ((s + 1) * k - s) * .5; + return .5 * ((k -= 2) * k * ((s + 1) * k + s) + 2); + }, + bounceIn: function bounceIn(k) { + return 1 - easing.bounceOut(1 - k); + }, + bounceOut: function bounceOut(k) { + return k < 1 / 2.75 ? 7.5625 * k * k : k < 2 / 2.75 ? 7.5625 * (k -= 1.5 / 2.75) * k + .75 : k < 2.5 / 2.75 ? 7.5625 * (k -= 2.25 / 2.75) * k + .9375 : 7.5625 * (k -= 2.625 / 2.75) * k + .984375; + }, + bounceInOut: function bounceInOut(k) { + if (k < .5) return .5 * easing.bounceIn(2 * k); + return .5 * easing.bounceOut(2 * k - 1) + .5; + }, + smooth: function smooth(t) { + if (t <= 0) return 0; + if (t >= 1) return 1; + return t * t * (3 - 2 * t); + }, + fade: function fade(t) { + if (t <= 0) return 0; + if (t >= 1) return 1; + return t * t * t * (t * (6 * t - 15) + 10); + } + }; + function _makeOutIn(fnIn, fnOut) { + return function(k) { + if (k < .5) return fnOut(2 * k) / 2; + return fnIn(2 * k - 1) / 2 + .5; + }; + } + easing.quadOutIn = _makeOutIn(easing.quadIn, easing.quadOut); + easing.cubicOutIn = _makeOutIn(easing.cubicIn, easing.cubicOut); + easing.quartOutIn = _makeOutIn(easing.quartIn, easing.quartOut); + easing.quintOutIn = _makeOutIn(easing.quintIn, easing.quintOut); + easing.sineOutIn = _makeOutIn(easing.sineIn, easing.sineOut); + easing.expoOutIn = _makeOutIn(easing.expoIn, easing.expoOut); + easing.circOutIn = _makeOutIn(easing.circIn, easing.circOut); + easing.backOutIn = _makeOutIn(easing.backIn, easing.backOut); + easing.bounceIn = function(k) { + return 1 - easing.bounceOut(1 - k); + }; + easing.bounceInOut = function(k) { + if (k < .5) return .5 * easing.bounceIn(2 * k); + return .5 * easing.bounceOut(2 * k - 1) + .5; + }; + easing.bounceOutIn = _makeOutIn(easing.bounceIn, easing.bounceOut); + cc.easing = module.exports = easing; + }), {} ], + 17: [ (function(require, module, exports) { + "use strict"; + require("./bezier"); + require("./easing"); + require("./types"); + require("./motion-path-helper"); + require("./animation-curves"); + require("./animation-clip"); + require("./animation-manager"); + require("./animation-state"); + require("./animation-animator"); + }), { + "./animation-animator": 10, + "./animation-clip": 11, + "./animation-curves": 12, + "./animation-manager": 13, + "./animation-state": 14, + "./bezier": 15, + "./easing": 16, + "./motion-path-helper": 18, + "./types": 20 + } ], + 18: [ (function(require, module, exports) { + "use strict"; + var DynamicAnimCurve = require("./animation-curves").DynamicAnimCurve; + var computeRatioByType = require("./animation-curves").computeRatioByType; + var bezier = require("./bezier").bezier; + var binarySearch = require("../core/utils/binary-search").binarySearchEpsilon; + var v2 = cc.v2; + function Curve(points) { + this.points = points || []; + this.beziers = []; + this.ratios = []; + this.progresses = []; + this.length = 0; + this.computeBeziers(); + } + Curve.prototype.computeBeziers = function() { + this.beziers.length = 0; + this.ratios.length = 0; + this.progresses.length = 0; + this.length = 0; + var bezier; + for (var i = 1; i < this.points.length; i++) { + var startPoint = this.points[i - 1]; + var endPoint = this.points[i]; + bezier = new Bezier(); + bezier.start = startPoint.pos; + bezier.startCtrlPoint = startPoint.out; + bezier.end = endPoint.pos; + bezier.endCtrlPoint = endPoint["in"]; + this.beziers.push(bezier); + this.length += bezier.getLength(); + } + var current = 0; + for (var i = 0; i < this.beziers.length; i++) { + bezier = this.beziers[i]; + this.ratios[i] = bezier.getLength() / this.length; + this.progresses[i] = current += this.ratios[i]; + } + return this.beziers; + }; + function Bezier() { + this.start = v2(); + this.end = v2(); + this.startCtrlPoint = v2(); + this.endCtrlPoint = v2(); + } + Bezier.prototype.getPointAt = function(u) { + var t = this.getUtoTmapping(u); + return this.getPoint(t); + }; + Bezier.prototype.getPoint = function(t) { + var x = bezier(this.start.x, this.startCtrlPoint.x, this.endCtrlPoint.x, this.end.x, t); + var y = bezier(this.start.y, this.startCtrlPoint.y, this.endCtrlPoint.y, this.end.y, t); + return new v2(x, y); + }; + Bezier.prototype.getLength = function() { + var lengths = this.getLengths(); + return lengths[lengths.length - 1]; + }; + Bezier.prototype.getLengths = function(divisions) { + divisions || (divisions = this.__arcLengthDivisions ? this.__arcLengthDivisions : 200); + if (this.cacheArcLengths && this.cacheArcLengths.length === divisions + 1) return this.cacheArcLengths; + var cache = []; + var current, last = this.getPoint(0), vector = v2(); + var p, sum = 0; + cache.push(0); + for (p = 1; p <= divisions; p++) { + current = this.getPoint(p / divisions); + vector.x = last.x - current.x; + vector.y = last.y - current.y; + sum += vector.mag(); + cache.push(sum); + last = current; + } + this.cacheArcLengths = cache; + return cache; + }; + Bezier.prototype.getUtoTmapping = function(u, distance) { + var arcLengths = this.getLengths(); + var i = 0, il = arcLengths.length; + var targetArcLength; + targetArcLength = distance || u * arcLengths[il - 1]; + var low = 0, high = il - 1, comparison; + while (low <= high) { + i = Math.floor(low + (high - low) / 2); + comparison = arcLengths[i] - targetArcLength; + if (comparison < 0) { + low = i + 1; + continue; + } + if (comparison > 0) { + high = i - 1; + continue; + } + high = i; + break; + } + i = high; + if (arcLengths[i] === targetArcLength) { + var t = i / (il - 1); + return t; + } + var lengthBefore = arcLengths[i]; + var lengthAfter = arcLengths[i + 1]; + var segmentLength = lengthAfter - lengthBefore; + var segmentFraction = (targetArcLength - lengthBefore) / segmentLength; + var t = (i + segmentFraction) / (il - 1); + return t; + }; + function checkMotionPath(motionPath) { + if (!Array.isArray(motionPath)) return false; + for (var i = 0, l = motionPath.length; i < l; i++) { + var controls = motionPath[i]; + if (!Array.isArray(controls) || 6 !== controls.length) return false; + } + return true; + } + function sampleMotionPaths(motionPaths, data, duration, fps, target) { + function createControlPoints(array) { + if (array instanceof cc.Vec2) return { + in: array, + pos: array, + out: array + }; + if (Array.isArray(array) && 6 === array.length) return { + in: v2(array[2], array[3]), + pos: v2(array[0], array[1]), + out: v2(array[4], array[5]) + }; + return { + in: cc.Vec2.ZERO, + pos: cc.Vec2.ZERO, + out: cc.Vec2.ZERO + }; + } + var values = data.values = data.values.map((function(value) { + Array.isArray(value) && (value = 2 === value.length ? cc.v2(value[0], value[1]) : cc.v3(value[0], value[1], value[2])); + return value; + })); + if (0 === motionPaths.length || 0 === values.length) return; + var motionPathValid = false; + for (var _i = 0; _i < motionPaths.length; _i++) { + var _motionPath = motionPaths[_i]; + if (_motionPath && !checkMotionPath(_motionPath)) { + cc.errorID(3904, target ? target.name : "", "position", _i); + _motionPath = null; + } + if (_motionPath && _motionPath.length > 0) { + motionPathValid = true; + break; + } + } + if (!motionPathValid) return; + if (1 === values.length) return; + var types = data.types; + var ratios = data.ratios; + var newValues = data.values = []; + var newTypes = data.types = []; + var newRatios = data.ratios = []; + function addNewDatas(value, type, ratio) { + newValues.push(value); + newTypes.push(type); + newRatios.push(ratio); + } + var startRatioOffset = 0; + var EPSILON = 1e-6; + var newType = DynamicAnimCurve.Linear; + for (var i = 0, l = motionPaths.length; i < l - 1; i++) { + var motionPath = motionPaths[i]; + var ratio = ratios[i]; + var nextRatio = ratios[i + 1]; + var betweenRatio = nextRatio - ratio; + var value = values[i]; + var nextValue = values[i + 1]; + var type = types[i]; + var results = []; + var progress = startRatioOffset / betweenRatio; + var speed = 1 / (betweenRatio * duration * fps); + var finalProgress; + if (motionPath && motionPath.length > 0) { + var points = []; + points.push(createControlPoints(value)); + for (var j = 0, l2 = motionPath.length; j < l2; j++) { + var controlPoints = createControlPoints(motionPath[j]); + points.push(controlPoints); + } + points.push(createControlPoints(nextValue)); + var curve = new Curve(points); + curve.computeBeziers(); + var progresses = curve.progresses; + while (1 - progress > EPSILON) { + finalProgress = progress; + finalProgress = computeRatioByType(finalProgress, type); + var pos, bezier, normal, length; + if (finalProgress < 0) { + bezier = curve.beziers[0]; + length = (0 - finalProgress) * bezier.getLength(); + normal = bezier.start.sub(bezier.endCtrlPoint).normalize(); + pos = bezier.start.add(normal.mul(length)); + } else if (finalProgress > 1) { + bezier = curve.beziers[curve.beziers.length - 1]; + length = (finalProgress - 1) * bezier.getLength(); + normal = bezier.end.sub(bezier.startCtrlPoint).normalize(); + pos = bezier.end.add(normal.mul(length)); + } else { + var bezierIndex = binarySearch(progresses, finalProgress); + bezierIndex < 0 && (bezierIndex = ~bezierIndex); + finalProgress -= bezierIndex > 0 ? progresses[bezierIndex - 1] : 0; + finalProgress /= curve.ratios[bezierIndex]; + pos = curve.beziers[bezierIndex].getPointAt(finalProgress); + } + results.push(pos); + progress += speed; + } + } else while (1 - progress > EPSILON) { + finalProgress = progress; + finalProgress = computeRatioByType(finalProgress, type); + results.push(value.lerp(nextValue, finalProgress)); + progress += speed; + } + newType = "constant" === type ? type : DynamicAnimCurve.Linear; + for (var j = 0, l2 = results.length; j < l2; j++) { + var newRatio = ratio + startRatioOffset + speed * j * betweenRatio; + addNewDatas(results[j], newType, newRatio); + } + startRatioOffset = Math.abs(progress - 1) > EPSILON ? (progress - 1) * betweenRatio : 0; + } + ratios[ratios.length - 1] !== newRatios[newRatios.length - 1] && addNewDatas(values[values.length - 1], newType, ratios[ratios.length - 1]); + } + false; + module.exports = { + sampleMotionPaths: sampleMotionPaths, + Curve: Curve, + Bezier: Bezier + }; + }), { + "../core/utils/binary-search": 318, + "./animation-curves": 12, + "./bezier": 15 + } ], + 19: [ (function(require, module, exports) { + "use strict"; + var js = cc.js; + var debug = require("../core/CCDebug"); + function Playable() { + this._isPlaying = false; + this._isPaused = false; + this._stepOnce = false; + } + var prototype = Playable.prototype; + js.get(prototype, "isPlaying", (function() { + return this._isPlaying; + }), true); + js.get(prototype, "isPaused", (function() { + return this._isPaused; + }), true); + var virtual = function virtual() {}; + prototype.onPlay = virtual; + prototype.onPause = virtual; + prototype.onResume = virtual; + prototype.onStop = virtual; + prototype.onError = virtual; + prototype.play = function() { + if (this._isPlaying) if (this._isPaused) { + this._isPaused = false; + this.onResume(); + } else this.onError(debug.getError(3912)); else { + this._isPlaying = true; + this.onPlay(); + } + }; + prototype.stop = function() { + if (this._isPlaying) { + this._isPlaying = false; + this.onStop(); + this._isPaused = false; + } + }; + prototype.pause = function() { + if (this._isPlaying && !this._isPaused) { + this._isPaused = true; + this.onPause(); + } + }; + prototype.resume = function() { + if (this._isPlaying && this._isPaused) { + this._isPaused = false; + this.onResume(); + } + }; + prototype.step = function() { + this.pause(); + this._stepOnce = true; + this._isPlaying || this.play(); + }; + module.exports = Playable; + }), { + "../core/CCDebug": 70 + } ], + 20: [ (function(require, module, exports) { + "use strict"; + var WrapModeMask = { + Loop: 2, + ShouldWrap: 4, + PingPong: 22, + Reverse: 36 + }; + var WrapMode = cc.Enum({ + Default: 0, + Normal: 1, + Reverse: WrapModeMask.Reverse, + Loop: WrapModeMask.Loop, + LoopReverse: WrapModeMask.Loop | WrapModeMask.Reverse, + PingPong: WrapModeMask.PingPong, + PingPongReverse: WrapModeMask.PingPong | WrapModeMask.Reverse + }); + cc.WrapMode = WrapMode; + function WrappedInfo(info) { + if (info) { + this.set(info); + return; + } + this.ratio = 0; + this.time = 0; + this.direction = 1; + this.stopped = true; + this.iterations = 0; + this.frameIndex = void 0; + } + WrappedInfo.prototype.set = function(info) { + this.ratio = info.ratio; + this.time = info.time; + this.direction = info.direction; + this.stopped = info.stopped; + this.iterations = info.iterations; + this.frameIndex = info.frameIndex; + }; + module.exports = { + WrapModeMask: WrapModeMask, + WrapMode: WrapMode, + WrappedInfo: WrappedInfo + }; + }), {} ], + 21: [ (function(require, module, exports) { + "use strict"; + var EventTarget = require("../core/event/event-target"); + var sys = require("../core/platform/CCSys"); + var LoadMode = require("../core/assets/CCAudioClip").LoadMode; + var touchBinded = false; + var touchPlayList = []; + var Audio = function Audio(src) { + EventTarget.call(this); + this._shouldRecycleOnEnded = false; + this._src = src; + this._element = null; + this.id = 0; + this._state = Audio.State.INITIALZING; + var self = this; + this._onended = function() { + self._state = Audio.State.STOPPED; + self.emit("ended"); + }; + this._onendedSecond = function() { + self._unbindEnded(self._onendedSecond); + self._bindEnded(); + }; + }; + cc.js.extend(Audio, EventTarget); + Audio.State = { + ERROR: -1, + INITIALZING: 0, + PLAYING: 1, + PAUSED: 2, + STOPPED: 3 + }; + (function(proto) { + proto._bindEnded = function(callback) { + callback = callback || this._onended; + if (callback._binded) return; + callback._binded = true; + var elem = this._element; + this._src && elem instanceof HTMLAudioElement ? elem.addEventListener("ended", callback) : elem.onended = callback; + }; + proto._unbindEnded = function(callback) { + callback = callback || this._onended; + if (!callback._binded) return; + callback._binded = false; + var elem = this._element; + elem instanceof HTMLAudioElement ? elem.removeEventListener("ended", callback) : elem && (elem.onended = null); + }; + proto._onLoaded = function() { + this._createElement(); + this._state = Audio.State.INITIALZING; + this.setVolume(1); + this.setLoop(false); + }; + proto._createElement = function() { + var elem = this._src._nativeAsset; + if (elem instanceof HTMLAudioElement) { + this._element || (this._element = document.createElement("audio")); + this._element.src = elem.src; + } else this._element = new WebAudioElement(elem, this); + }; + proto.play = function() { + var self = this; + this._src && this._src._ensureLoaded((function() { + self._state = Audio.State.PLAYING; + self._bindEnded(); + var playPromise = self._element.play(); + window.Promise && playPromise instanceof Promise && playPromise["catch"]((function(err) {})); + self._touchToPlay(); + })); + }; + proto._touchToPlay = function() { + this._src && this._src.loadMode === LoadMode.DOM_AUDIO && this._element.paused && touchPlayList.push({ + instance: this, + offset: 0, + audio: this._element + }); + if (touchBinded) return; + touchBinded = true; + var touchEventName = "ontouchend" in window ? "touchend" : "mousedown"; + cc.game.canvas.addEventListener(touchEventName, (function() { + var item; + while (item = touchPlayList.pop()) item.audio.play(item.offset); + })); + }; + proto.destroy = function() { + this._element = null; + }; + proto.pause = function() { + if (this.getState() !== Audio.State.PLAYING) return; + var self = this; + this._src && this._src._ensureLoaded((function() { + self._unbindEnded(); + self._element.pause(); + self._state = Audio.State.PAUSED; + })); + }; + proto.resume = function() { + if (this.getState() !== Audio.State.PAUSED) return; + var self = this; + this._src && this._src._ensureLoaded((function() { + self._bindEnded(); + self._element.play(); + self._state = Audio.State.PLAYING; + })); + }; + proto.stop = function() { + var self = this; + this._src && this._src._ensureLoaded((function() { + self._element.pause(); + self._element.currentTime = 0; + for (var i = 0; i < touchPlayList.length; i++) if (touchPlayList[i].instance === self) { + touchPlayList.splice(i, 1); + break; + } + self._unbindEnded(); + self.emit("stop"); + self._state = Audio.State.STOPPED; + })); + }; + proto.setLoop = function(loop) { + var self = this; + this._src && this._src._ensureLoaded((function() { + self._element.loop = loop; + })); + }; + proto.getLoop = function() { + return !!this._element && this._element.loop; + }; + proto.setVolume = function(num) { + var self = this; + this._src && this._src._ensureLoaded((function() { + self._element.volume = num; + })); + }; + proto.getVolume = function() { + return this._element ? this._element.volume : 1; + }; + proto.setCurrentTime = function(num) { + var self = this; + this._src && this._src._ensureLoaded((function() { + self._unbindEnded(); + self._bindEnded(self._onendedSecond); + self._element.currentTime = num; + })); + }; + proto.getCurrentTime = function() { + return this._element ? this._element.currentTime : 0; + }; + proto.getDuration = function() { + return this._src ? this._src.duration : 0; + }; + proto.getState = function(forceUpdating) { + void 0 === forceUpdating && (forceUpdating = true); + forceUpdating && this._forceUpdatingState(); + return this._state; + }; + proto._forceUpdatingState = function() { + var elem = this._element; + elem && (Audio.State.PLAYING === this._state && elem.paused ? this._state = Audio.State.STOPPED : Audio.State.STOPPED !== this._state || elem.paused || (this._state = Audio.State.PLAYING)); + }; + Object.defineProperty(proto, "src", { + get: function get() { + return this._src; + }, + set: function set(clip) { + this._unbindEnded(); + if (clip && clip.isValid) { + if (clip !== this._src) { + this._src = clip; + if (clip.loaded) this._onLoaded(); else { + var self = this; + clip.once("load", (function() { + clip === self._src && self._onLoaded(); + })); + } + } + } else { + this._src = null; + this._element instanceof WebAudioElement ? this._element = null : this._element && (this._element.src = ""); + this._state = Audio.State.INITIALZING; + } + return clip; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(proto, "paused", { + get: function get() { + return !this._element || this._element.paused; + }, + enumerable: true, + configurable: true + }); + })(Audio.prototype); + var TIME_CONSTANT; + TIME_CONSTANT = cc.sys.browserType === cc.sys.BROWSER_TYPE_EDGE || cc.sys.browserType === cc.sys.BROWSER_TYPE_BAIDU || cc.sys.browserType === cc.sys.BROWSER_TYPE_UC ? .01 : 0; + var WebAudioElement = function WebAudioElement(buffer, audio) { + this._audio = audio; + this._context = sys.__audioSupport.context; + this._buffer = buffer; + this._gainObj = this._context["createGain"](); + this.volume = 1; + this._gainObj["connect"](this._context["destination"]); + this._loop = false; + this._startTime = -1; + this._currentSource = null; + this.playedLength = 0; + this._currentTimer = null; + this._endCallback = function() { + this.onended && this.onended(this); + }.bind(this); + }; + (function(proto) { + proto.play = function(offset) { + if (this._currentSource && !this.paused) { + this._currentSource.onended = null; + this._currentSource.stop(0); + this.playedLength = 0; + } + var audio = this._context["createBufferSource"](); + audio.buffer = this._buffer; + audio["connect"](this._gainObj); + audio.loop = this._loop; + this._startTime = this._context.currentTime; + offset = offset || this.playedLength; + offset && (this._startTime -= offset); + var duration = this._buffer.duration; + var startTime = offset; + var endTime; + if (this._loop) audio.start ? audio.start(0, startTime) : audio["notoGrainOn"] ? audio["noteGrainOn"](0, startTime) : audio["noteOn"](0, startTime); else { + endTime = duration - offset; + audio.start ? audio.start(0, startTime, endTime) : audio["noteGrainOn"] ? audio["noteGrainOn"](0, startTime, endTime) : audio["noteOn"](0, startTime, endTime); + } + this._currentSource = audio; + audio.onended = this._endCallback; + if ((!audio.context.state || "suspended" === audio.context.state) && 0 === this._context.currentTime) { + var self = this; + clearTimeout(this._currentTimer); + this._currentTimer = setTimeout((function() { + 0 === self._context.currentTime && touchPlayList.push({ + instance: self._audio, + offset: offset, + audio: self + }); + }), 10); + } + var sys = cc.sys; + sys.os === sys.OS_IOS && sys.isBrowser && sys.isMobile && ("suspended" === audio.context.state && 0 !== this._context.currentTime || "interrupted" === audio.context.state) && audio.context.resume(); + }; + proto.pause = function() { + clearTimeout(this._currentTimer); + if (this.paused) return; + this.playedLength = this._context.currentTime - this._startTime; + this.playedLength %= this._buffer.duration; + var audio = this._currentSource; + if (audio) { + if (audio.onended) { + audio.onended._binded = false; + audio.onended = null; + } + audio.stop(0); + } + this._currentSource = null; + this._startTime = -1; + }; + Object.defineProperty(proto, "paused", { + get: function get() { + if (this._currentSource && this._currentSource.loop) return false; + if (-1 === this._startTime) return true; + return this._context.currentTime - this._startTime > this._buffer.duration; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(proto, "loop", { + get: function get() { + return this._loop; + }, + set: function set(bool) { + this._currentSource && (this._currentSource.loop = bool); + return this._loop = bool; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(proto, "volume", { + get: function get() { + return this._volume; + }, + set: function set(num) { + this._volume = num; + if (this._gainObj.gain.setTargetAtTime) try { + this._gainObj.gain.setTargetAtTime(num, this._context.currentTime, TIME_CONSTANT); + } catch (e) { + this._gainObj.gain.setTargetAtTime(num, this._context.currentTime, .01); + } else this._gainObj.gain.value = num; + if (sys.os === sys.OS_IOS && !this.paused && this._currentSource) { + this._currentSource.onended = null; + this.pause(); + this.play(); + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(proto, "currentTime", { + get: function get() { + if (this.paused) return this.playedLength; + this.playedLength = this._context.currentTime - this._startTime; + this.playedLength %= this._buffer.duration; + return this.playedLength; + }, + set: function set(num) { + if (this.paused) this.playedLength = num; else { + this.pause(); + this.playedLength = num; + this.play(); + } + return num; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(proto, "duration", { + get: function get() { + return this._buffer.duration; + }, + enumerable: true, + configurable: true + }); + })(WebAudioElement.prototype); + module.exports = cc._Audio = Audio; + }), { + "../core/assets/CCAudioClip": 107, + "../core/event/event-target": 187, + "../core/platform/CCSys": 249 + } ], + 22: [ (function(require, module, exports) { + "use strict"; + var Audio = require("./CCAudio"); + var AudioClip = require("../core/assets/CCAudioClip"); + var js = cc.js; + var _instanceId = 0; + var _id2audio = js.createMap(true); + var _url2id = {}; + var _audioPool = []; + var recycleAudio = function recycleAudio(audio) { + if (!audio._shouldRecycleOnEnded) return; + audio._finishCallback = null; + audio.off("ended"); + audio.off("stop"); + audio.src = null; + _audioPool.includes(audio) || (_audioPool.length < audioEngine._maxPoolSize ? _audioPool.push(audio) : audio.destroy()); + audio._shouldRecycleOnEnded = false; + }; + var getAudioFromPath = function getAudioFromPath(path) { + var id = ++_instanceId; + var list = _url2id[path]; + list || (list = _url2id[path] = []); + if (audioEngine._maxAudioInstance <= list.length) { + var oldId = list.shift(); + var oldAudio = getAudioFromId(oldId); + oldAudio.stop(); + } + var audio = _audioPool.pop() || new Audio(); + var callback = function callback() { + var audioInList = getAudioFromId(this.id); + if (audioInList) { + delete _id2audio[this.id]; + var index = list.indexOf(this.id); + cc.js.array.fastRemoveAt(list, index); + } + recycleAudio(this); + }; + audio.on("ended", (function() { + this._finishCallback && this._finishCallback(); + this.getLoop() || callback.call(this); + }), audio); + audio.on("stop", callback, audio); + audio.id = id; + _id2audio[id] = audio; + list.push(id); + return audio; + }; + var getAudioFromId = function getAudioFromId(id) { + return _id2audio[id]; + }; + var handleVolume = function handleVolume(volume) { + void 0 === volume ? volume = 1 : "string" === typeof volume && (volume = Number.parseFloat(volume)); + return volume; + }; + var audioEngine = { + AudioState: Audio.State, + _maxAudioInstance: 24, + _maxPoolSize: 32, + _id2audio: _id2audio, + play: function play(clip, loop, volume) { + false; + if (!(clip instanceof AudioClip)) return cc.error("Wrong type of AudioClip."); + var path = clip.nativeUrl; + var audio = getAudioFromPath(path); + audio.src = clip; + clip._ensureLoaded(); + audio._shouldRecycleOnEnded = true; + audio.setLoop(loop || false); + volume = handleVolume(volume); + audio.setVolume(volume); + audio.play(); + return audio.id; + }, + setLoop: function setLoop(audioID, loop) { + var audio = getAudioFromId(audioID); + if (!audio || !audio.setLoop) return; + audio.setLoop(loop); + }, + isLoop: function isLoop(audioID) { + var audio = getAudioFromId(audioID); + if (!audio || !audio.getLoop) return false; + return audio.getLoop(); + }, + setVolume: function setVolume(audioID, volume) { + var audio = getAudioFromId(audioID); + audio && audio.setVolume(volume); + }, + getVolume: function getVolume(audioID) { + var audio = getAudioFromId(audioID); + return audio ? audio.getVolume() : 1; + }, + setCurrentTime: function setCurrentTime(audioID, sec) { + var audio = getAudioFromId(audioID); + if (audio) { + audio.setCurrentTime(sec); + return true; + } + return false; + }, + getCurrentTime: function getCurrentTime(audioID) { + var audio = getAudioFromId(audioID); + return audio ? audio.getCurrentTime() : 0; + }, + getDuration: function getDuration(audioID) { + var audio = getAudioFromId(audioID); + return audio ? audio.getDuration() : 0; + }, + getState: function getState(audioID) { + var audio = getAudioFromId(audioID); + return audio ? audio.getState() : this.AudioState.ERROR; + }, + isPlaying: function isPlaying(audioID) { + return this.getState(audioID) === this.AudioState.PLAYING; + }, + setFinishCallback: function setFinishCallback(audioID, callback) { + var audio = getAudioFromId(audioID); + if (!audio) return; + audio._finishCallback = callback; + }, + pause: function pause(audioID) { + var audio = getAudioFromId(audioID); + if (audio) { + audio.pause(); + return true; + } + return false; + }, + _pauseIDCache: [], + pauseAll: function pauseAll() { + for (var id in _id2audio) { + var audio = _id2audio[id]; + var state = audio.getState(); + if (state === Audio.State.PLAYING) { + this._pauseIDCache.push(id); + audio.pause(); + } + } + }, + resume: function resume(audioID) { + var audio = getAudioFromId(audioID); + audio && audio.resume(); + }, + resumeAll: function resumeAll() { + for (var i = 0; i < this._pauseIDCache.length; ++i) { + var id = this._pauseIDCache[i]; + var audio = getAudioFromId(id); + audio && audio.resume(); + } + this._pauseIDCache.length = 0; + }, + stop: function stop(audioID) { + var audio = getAudioFromId(audioID); + if (audio) { + audio.stop(); + return true; + } + return false; + }, + stopAll: function stopAll() { + for (var id in _id2audio) { + var audio = _id2audio[id]; + audio && audio.stop(); + } + }, + setMaxAudioInstance: function setMaxAudioInstance(num) { + true; + cc.warn("Since v2.4.0, maxAudioInstance has become a read only property.\naudioEngine.setMaxAudioInstance() method will be removed in the future"); + }, + getMaxAudioInstance: function getMaxAudioInstance() { + return this._maxAudioInstance; + }, + uncache: function uncache(clip) { + var filePath = clip; + if ("string" === typeof clip) { + cc.warnID(8401, "cc.audioEngine", "cc.AudioClip", "AudioClip", "cc.AudioClip", "audio"); + filePath = clip; + } else { + if (!clip) return; + filePath = clip.nativeUrl; + } + var list = _url2id[filePath]; + if (!list) return; + while (list.length > 0) { + var id = list.pop(); + var audio = _id2audio[id]; + if (audio) { + audio.stop(); + delete _id2audio[id]; + } + } + }, + uncacheAll: function uncacheAll() { + this.stopAll(); + var audio; + for (var id in _id2audio) { + audio = _id2audio[id]; + audio && audio.destroy(); + } + while (audio = _audioPool.pop()) audio.destroy(); + _id2audio = js.createMap(true); + _url2id = {}; + }, + _breakCache: null, + _break: function _break() { + this._breakCache = []; + for (var id in _id2audio) { + var audio = _id2audio[id]; + var state = audio.getState(); + if (state === Audio.State.PLAYING) { + this._breakCache.push(id); + audio.pause(); + } + } + }, + _restore: function _restore() { + if (!this._breakCache) return; + while (this._breakCache.length > 0) { + var id = this._breakCache.pop(); + var audio = getAudioFromId(id); + audio && audio.resume && audio.resume(); + } + this._breakCache = null; + }, + _music: { + id: -1, + loop: false, + volume: 1 + }, + _effect: { + volume: 1, + pauseCache: [] + }, + playMusic: function playMusic(clip, loop) { + var music = this._music; + this.stop(music.id); + music.id = this.play(clip, loop, music.volume); + music.loop = loop; + return music.id; + }, + stopMusic: function stopMusic() { + this.stop(this._music.id); + }, + pauseMusic: function pauseMusic() { + this.pause(this._music.id); + return this._music.id; + }, + resumeMusic: function resumeMusic() { + this.resume(this._music.id); + return this._music.id; + }, + getMusicVolume: function getMusicVolume() { + return this._music.volume; + }, + setMusicVolume: function setMusicVolume(volume) { + volume = handleVolume(volume); + var music = this._music; + music.volume = volume; + this.setVolume(music.id, music.volume); + return music.volume; + }, + isMusicPlaying: function isMusicPlaying() { + return this.getState(this._music.id) === this.AudioState.PLAYING; + }, + playEffect: function playEffect(clip, loop) { + return this.play(clip, loop || false, this._effect.volume); + }, + setEffectsVolume: function setEffectsVolume(volume) { + volume = handleVolume(volume); + var musicId = this._music.id; + this._effect.volume = volume; + for (var id in _id2audio) { + var audio = _id2audio[id]; + if (!audio || audio.id === musicId) continue; + audioEngine.setVolume(id, volume); + } + }, + getEffectsVolume: function getEffectsVolume() { + return this._effect.volume; + }, + pauseEffect: function pauseEffect(audioID) { + return this.pause(audioID); + }, + pauseAllEffects: function pauseAllEffects() { + var musicId = this._music.id; + var effect = this._effect; + effect.pauseCache.length = 0; + for (var id in _id2audio) { + var audio = _id2audio[id]; + if (!audio || audio.id === musicId) continue; + var state = audio.getState(); + if (state === this.AudioState.PLAYING) { + effect.pauseCache.push(id); + audio.pause(); + } + } + }, + resumeEffect: function resumeEffect(id) { + this.resume(id); + }, + resumeAllEffects: function resumeAllEffects() { + var pauseIDCache = this._effect.pauseCache; + for (var i = 0; i < pauseIDCache.length; ++i) { + var id = pauseIDCache[i]; + var audio = _id2audio[id]; + audio && audio.resume(); + } + }, + stopEffect: function stopEffect(audioID) { + return this.stop(audioID); + }, + stopAllEffects: function stopAllEffects() { + var musicId = this._music.id; + for (var id in _id2audio) { + var audio = _id2audio[id]; + if (!audio || audio.id === musicId) continue; + var state = audio.getState(); + state === audioEngine.AudioState.PLAYING && audio.stop(); + } + } + }; + module.exports = cc.audioEngine = audioEngine; + }), { + "../core/assets/CCAudioClip": 107, + "./CCAudio": 21 + } ], + 23: [ (function(require, module, exports) { + "use strict"; + var codec = { + name: "Jacob__Codec" + }; + codec.Base64 = require("./base64"); + codec.GZip = require("./gzip"); + codec.unzip = function() { + return codec.GZip.gunzip.apply(codec.GZip, arguments); + }; + codec.unzipBase64 = function() { + var buffer = codec.Base64.decode.apply(codec.Base64, arguments); + try { + return codec.GZip.gunzip.call(codec.GZip, buffer); + } catch (e) { + return buffer.slice(7); + } + }; + codec.unzipBase64AsArray = function(input, bytes) { + bytes = bytes || 1; + var dec = this.unzipBase64(input), ar = [], i, j, len; + for (i = 0, len = dec.length / bytes; i < len; i++) { + ar[i] = 0; + for (j = bytes - 1; j >= 0; --j) ar[i] += dec.charCodeAt(i * bytes + j) << 8 * j; + } + return ar; + }; + codec.unzipAsArray = function(input, bytes) { + bytes = bytes || 1; + var dec = this.unzip(input), ar = [], i, j, len; + for (i = 0, len = dec.length / bytes; i < len; i++) { + ar[i] = 0; + for (j = bytes - 1; j >= 0; --j) ar[i] += dec.charCodeAt(i * bytes + j) << 8 * j; + } + return ar; + }; + cc.codec = module.exports = codec; + }), { + "./base64": 24, + "./gzip": 25 + } ], + 24: [ (function(require, module, exports) { + "use strict"; + var misc = require("../core/utils/misc"); + var strValue = misc.BASE64_VALUES; + var Base64 = { + name: "Jacob__Codec__Base64" + }; + Base64.decode = function Jacob__Codec__Base64__decode(input) { + var output = [], chr1, chr2, chr3, enc1, enc2, enc3, enc4, i = 0; + input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); + while (i < input.length) { + enc1 = strValue[input.charCodeAt(i++)]; + enc2 = strValue[input.charCodeAt(i++)]; + enc3 = strValue[input.charCodeAt(i++)]; + enc4 = strValue[input.charCodeAt(i++)]; + chr1 = enc1 << 2 | enc2 >> 4; + chr2 = (15 & enc2) << 4 | enc3 >> 2; + chr3 = (3 & enc3) << 6 | enc4; + output.push(String.fromCharCode(chr1)); + 64 !== enc3 && output.push(String.fromCharCode(chr2)); + 64 !== enc4 && output.push(String.fromCharCode(chr3)); + } + output = output.join(""); + return output; + }; + Base64.decodeAsArray = function Jacob__Codec__Base64___decodeAsArray(input, bytes) { + var dec = this.decode(input), ar = [], i, j, len; + for (i = 0, len = dec.length / bytes; i < len; i++) { + ar[i] = 0; + for (j = bytes - 1; j >= 0; --j) ar[i] += dec.charCodeAt(i * bytes + j) << 8 * j; + } + return ar; + }; + module.exports = Base64; + }), { + "../core/utils/misc": 325 + } ], + 25: [ (function(require, module, exports) { + "use strict"; + var GZip = function Jacob__GZip(data) { + this.data = data; + this.debug = false; + this.gpflags = void 0; + this.files = 0; + this.unzipped = []; + this.buf32k = new Array(32768); + this.bIdx = 0; + this.modeZIP = false; + this.bytepos = 0; + this.bb = 1; + this.bits = 0; + this.nameBuf = []; + this.fileout = void 0; + this.literalTree = new Array(GZip.LITERALS); + this.distanceTree = new Array(32); + this.treepos = 0; + this.Places = null; + this.len = 0; + this.fpos = new Array(17); + this.fpos[0] = 0; + this.flens = void 0; + this.fmax = void 0; + }; + GZip.gunzip = function(string) { + string.constructor === Array || string.constructor === String; + var gzip = new GZip(string); + return gzip.gunzip()[0][0]; + }; + GZip.HufNode = function() { + this.b0 = 0; + this.b1 = 0; + this.jump = null; + this.jumppos = -1; + }; + GZip.LITERALS = 288; + GZip.NAMEMAX = 256; + GZip.bitReverse = [ 0, 128, 64, 192, 32, 160, 96, 224, 16, 144, 80, 208, 48, 176, 112, 240, 8, 136, 72, 200, 40, 168, 104, 232, 24, 152, 88, 216, 56, 184, 120, 248, 4, 132, 68, 196, 36, 164, 100, 228, 20, 148, 84, 212, 52, 180, 116, 244, 12, 140, 76, 204, 44, 172, 108, 236, 28, 156, 92, 220, 60, 188, 124, 252, 2, 130, 66, 194, 34, 162, 98, 226, 18, 146, 82, 210, 50, 178, 114, 242, 10, 138, 74, 202, 42, 170, 106, 234, 26, 154, 90, 218, 58, 186, 122, 250, 6, 134, 70, 198, 38, 166, 102, 230, 22, 150, 86, 214, 54, 182, 118, 246, 14, 142, 78, 206, 46, 174, 110, 238, 30, 158, 94, 222, 62, 190, 126, 254, 1, 129, 65, 193, 33, 161, 97, 225, 17, 145, 81, 209, 49, 177, 113, 241, 9, 137, 73, 201, 41, 169, 105, 233, 25, 153, 89, 217, 57, 185, 121, 249, 5, 133, 69, 197, 37, 165, 101, 229, 21, 149, 85, 213, 53, 181, 117, 245, 13, 141, 77, 205, 45, 173, 109, 237, 29, 157, 93, 221, 61, 189, 125, 253, 3, 131, 67, 195, 35, 163, 99, 227, 19, 147, 83, 211, 51, 179, 115, 243, 11, 139, 75, 203, 43, 171, 107, 235, 27, 155, 91, 219, 59, 187, 123, 251, 7, 135, 71, 199, 39, 167, 103, 231, 23, 151, 87, 215, 55, 183, 119, 247, 15, 143, 79, 207, 47, 175, 111, 239, 31, 159, 95, 223, 63, 191, 127, 255 ]; + GZip.cplens = [ 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0 ]; + GZip.cplext = [ 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 99, 99 ]; + GZip.cpdist = [ 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577 ]; + GZip.cpdext = [ 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13 ]; + GZip.border = [ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 ]; + GZip.prototype.gunzip = function() { + this.outputArr = []; + this.nextFile(); + return this.unzipped; + }; + GZip.prototype.readByte = function() { + this.bits += 8; + return this.bytepos < this.data.length ? this.data.charCodeAt(this.bytepos++) : -1; + }; + GZip.prototype.byteAlign = function() { + this.bb = 1; + }; + GZip.prototype.readBit = function() { + var carry; + this.bits++; + carry = 1 & this.bb; + this.bb >>= 1; + if (0 === this.bb) { + this.bb = this.readByte(); + carry = 1 & this.bb; + this.bb = this.bb >> 1 | 128; + } + return carry; + }; + GZip.prototype.readBits = function(a) { + var res = 0, i = a; + while (i--) res = res << 1 | this.readBit(); + a && (res = GZip.bitReverse[res] >> 8 - a); + return res; + }; + GZip.prototype.flushBuffer = function() { + this.bIdx = 0; + }; + GZip.prototype.addBuffer = function(a) { + this.buf32k[this.bIdx++] = a; + this.outputArr.push(String.fromCharCode(a)); + 32768 === this.bIdx && (this.bIdx = 0); + }; + GZip.prototype.IsPat = function() { + while (1) { + if (this.fpos[this.len] >= this.fmax) return -1; + if (this.flens[this.fpos[this.len]] === this.len) return this.fpos[this.len]++; + this.fpos[this.len]++; + } + }; + GZip.prototype.Rec = function() { + var curplace = this.Places[this.treepos]; + var tmp; + if (17 === this.len) return -1; + this.treepos++; + this.len++; + tmp = this.IsPat(); + if (tmp >= 0) curplace.b0 = tmp; else { + curplace.b0 = 32768; + if (this.Rec()) return -1; + } + tmp = this.IsPat(); + if (tmp >= 0) { + curplace.b1 = tmp; + curplace.jump = null; + } else { + curplace.b1 = 32768; + curplace.jump = this.Places[this.treepos]; + curplace.jumppos = this.treepos; + if (this.Rec()) return -1; + } + this.len--; + return 0; + }; + GZip.prototype.CreateTree = function(currentTree, numval, lengths, show) { + var i; + this.Places = currentTree; + this.treepos = 0; + this.flens = lengths; + this.fmax = numval; + for (i = 0; i < 17; i++) this.fpos[i] = 0; + this.len = 0; + if (this.Rec()) return -1; + return 0; + }; + GZip.prototype.DecodeValue = function(currentTree) { + var len, i, xtreepos = 0, X = currentTree[xtreepos], b; + while (1) { + b = this.readBit(); + if (b) { + if (!(32768 & X.b1)) return X.b1; + X = X.jump; + len = currentTree.length; + for (i = 0; i < len; i++) if (currentTree[i] === X) { + xtreepos = i; + break; + } + } else { + if (!(32768 & X.b0)) return X.b0; + xtreepos++; + X = currentTree[xtreepos]; + } + } + return -1; + }; + GZip.prototype.DeflateLoop = function() { + var last, c, type, i, len; + do { + last = this.readBit(); + type = this.readBits(2); + if (0 === type) { + var blockLen, cSum; + this.byteAlign(); + blockLen = this.readByte(); + blockLen |= this.readByte() << 8; + cSum = this.readByte(); + cSum |= this.readByte() << 8; + 65535 & (blockLen ^ ~cSum) && document.write("BlockLen checksum mismatch\n"); + while (blockLen--) { + c = this.readByte(); + this.addBuffer(c); + } + } else if (1 === type) { + var j; + while (1) { + j = GZip.bitReverse[this.readBits(7)] >> 1; + if (j > 23) { + j = j << 1 | this.readBit(); + if (j > 199) { + j -= 128; + j = j << 1 | this.readBit(); + } else { + j -= 48; + j > 143 && (j += 136); + } + } else j += 256; + if (j < 256) this.addBuffer(j); else { + if (256 === j) break; + var len, dist; + j -= 257; + len = this.readBits(GZip.cplext[j]) + GZip.cplens[j]; + j = GZip.bitReverse[this.readBits(5)] >> 3; + if (GZip.cpdext[j] > 8) { + dist = this.readBits(8); + dist |= this.readBits(GZip.cpdext[j] - 8) << 8; + } else dist = this.readBits(GZip.cpdext[j]); + dist += GZip.cpdist[j]; + for (j = 0; j < len; j++) { + var c = this.buf32k[this.bIdx - dist & 32767]; + this.addBuffer(c); + } + } + } + } else if (2 === type) { + var j, n, literalCodes, distCodes, lenCodes; + var ll = new Array(320); + literalCodes = 257 + this.readBits(5); + distCodes = 1 + this.readBits(5); + lenCodes = 4 + this.readBits(4); + for (j = 0; j < 19; j++) ll[j] = 0; + for (j = 0; j < lenCodes; j++) ll[GZip.border[j]] = this.readBits(3); + len = this.distanceTree.length; + for (i = 0; i < len; i++) this.distanceTree[i] = new GZip.HufNode(); + if (this.CreateTree(this.distanceTree, 19, ll, 0)) { + this.flushBuffer(); + return 1; + } + n = literalCodes + distCodes; + i = 0; + var z = -1; + while (i < n) { + z++; + j = this.DecodeValue(this.distanceTree); + if (j < 16) ll[i++] = j; else if (16 === j) { + var l; + j = 3 + this.readBits(2); + if (i + j > n) { + this.flushBuffer(); + return 1; + } + l = i ? ll[i - 1] : 0; + while (j--) ll[i++] = l; + } else { + j = 17 === j ? 3 + this.readBits(3) : 11 + this.readBits(7); + if (i + j > n) { + this.flushBuffer(); + return 1; + } + while (j--) ll[i++] = 0; + } + } + len = this.literalTree.length; + for (i = 0; i < len; i++) this.literalTree[i] = new GZip.HufNode(); + if (this.CreateTree(this.literalTree, literalCodes, ll, 0)) { + this.flushBuffer(); + return 1; + } + len = this.literalTree.length; + for (i = 0; i < len; i++) this.distanceTree[i] = new GZip.HufNode(); + var ll2 = new Array(); + for (i = literalCodes; i < ll.length; i++) ll2[i - literalCodes] = ll[i]; + if (this.CreateTree(this.distanceTree, distCodes, ll2, 0)) { + this.flushBuffer(); + return 1; + } + while (1) { + j = this.DecodeValue(this.literalTree); + if (j >= 256) { + var len, dist; + j -= 256; + if (0 === j) break; + j--; + len = this.readBits(GZip.cplext[j]) + GZip.cplens[j]; + j = this.DecodeValue(this.distanceTree); + if (GZip.cpdext[j] > 8) { + dist = this.readBits(8); + dist |= this.readBits(GZip.cpdext[j] - 8) << 8; + } else dist = this.readBits(GZip.cpdext[j]); + dist += GZip.cpdist[j]; + while (len--) { + var c = this.buf32k[this.bIdx - dist & 32767]; + this.addBuffer(c); + } + } else this.addBuffer(j); + } + } + } while (!last); + this.flushBuffer(); + this.byteAlign(); + return 0; + }; + GZip.prototype.unzipFile = function(name) { + var i; + this.gunzip(); + for (i = 0; i < this.unzipped.length; i++) if (this.unzipped[i][1] === name) return this.unzipped[i][0]; + }; + GZip.prototype.nextFile = function() { + this.outputArr = []; + this.modeZIP = false; + var tmp = []; + tmp[0] = this.readByte(); + tmp[1] = this.readByte(); + if (120 === tmp[0] && 218 === tmp[1]) { + this.DeflateLoop(); + this.unzipped[this.files] = [ this.outputArr.join(""), "geonext.gxt" ]; + this.files++; + } + if (31 === tmp[0] && 139 === tmp[1]) { + this.skipdir(); + this.unzipped[this.files] = [ this.outputArr.join(""), "file" ]; + this.files++; + } + if (80 === tmp[0] && 75 === tmp[1]) { + this.modeZIP = true; + tmp[2] = this.readByte(); + tmp[3] = this.readByte(); + if (3 === tmp[2] && 4 === tmp[3]) { + tmp[0] = this.readByte(); + tmp[1] = this.readByte(); + this.gpflags = this.readByte(); + this.gpflags |= this.readByte() << 8; + var method = this.readByte(); + method |= this.readByte() << 8; + this.readByte(); + this.readByte(); + this.readByte(); + this.readByte(); + var compSize = this.readByte(); + compSize |= this.readByte() << 8; + compSize |= this.readByte() << 16; + compSize |= this.readByte() << 24; + var size = this.readByte(); + size |= this.readByte() << 8; + size |= this.readByte() << 16; + size |= this.readByte() << 24; + var filelen = this.readByte(); + filelen |= this.readByte() << 8; + var extralen = this.readByte(); + extralen |= this.readByte() << 8; + i = 0; + this.nameBuf = []; + while (filelen--) { + var c = this.readByte(); + "/" === c | ":" === c ? i = 0 : i < GZip.NAMEMAX - 1 && (this.nameBuf[i++] = String.fromCharCode(c)); + } + this.fileout || (this.fileout = this.nameBuf); + var i = 0; + while (i < extralen) { + c = this.readByte(); + i++; + } + if (8 === method) { + this.DeflateLoop(); + this.unzipped[this.files] = [ this.outputArr.join(""), this.nameBuf.join("") ]; + this.files++; + } + this.skipdir(); + } + } + }; + GZip.prototype.skipdir = function() { + var tmp = []; + var compSize, size, os, i, c; + if (8 & this.gpflags) { + tmp[0] = this.readByte(); + tmp[1] = this.readByte(); + tmp[2] = this.readByte(); + tmp[3] = this.readByte(); + compSize = this.readByte(); + compSize |= this.readByte() << 8; + compSize |= this.readByte() << 16; + compSize |= this.readByte() << 24; + size = this.readByte(); + size |= this.readByte() << 8; + size |= this.readByte() << 16; + size |= this.readByte() << 24; + } + this.modeZIP && this.nextFile(); + tmp[0] = this.readByte(); + if (8 !== tmp[0]) return 0; + this.gpflags = this.readByte(); + this.readByte(); + this.readByte(); + this.readByte(); + this.readByte(); + this.readByte(); + os = this.readByte(); + if (4 & this.gpflags) { + tmp[0] = this.readByte(); + tmp[2] = this.readByte(); + this.len = tmp[0] + 256 * tmp[1]; + for (i = 0; i < this.len; i++) this.readByte(); + } + if (8 & this.gpflags) { + i = 0; + this.nameBuf = []; + while (c = this.readByte()) { + "7" !== c && ":" !== c || (i = 0); + i < GZip.NAMEMAX - 1 && (this.nameBuf[i++] = c); + } + } + if (16 & this.gpflags) while (c = this.readByte()) ; + if (2 & this.gpflags) { + this.readByte(); + this.readByte(); + } + this.DeflateLoop(); + size = this.readByte(); + size |= this.readByte() << 8; + size |= this.readByte() << 16; + size |= this.readByte() << 24; + this.modeZIP && this.nextFile(); + }; + module.exports = GZip; + }), {} ], + 26: [ (function(require, module, exports) { + "use strict"; + (function() { + function i(a) { + throw a; + } + var r = void 0, v = !0, aa = this; + function y(a, c) { + var b = a.split("."), e = aa; + !(b[0] in e) && e.execScript && e.execScript("var " + b[0]); + for (var f; b.length && (f = b.shift()); ) b.length || c === r ? e = e[f] ? e[f] : e[f] = {} : e[f] = c; + } + var H = "undefined" !== typeof Uint8Array && "undefined" !== typeof Uint16Array && "undefined" !== typeof Uint32Array; + function ba(a) { + if ("string" === typeof a) { + var c = a.split(""), b, e; + b = 0; + for (e = c.length; b < e; b++) c[b] = (255 & c[b].charCodeAt(0)) >>> 0; + a = c; + } + for (var f = 1, d = 0, g = a.length, h, m = 0; 0 < g; ) { + h = 1024 < g ? 1024 : g; + g -= h; + do { + f += a[m++], d += f; + } while (--h); + f %= 65521; + d %= 65521; + } + return (d << 16 | f) >>> 0; + } + function J(a, c) { + this.index = "number" === typeof c ? c : 0; + this.i = 0; + this.buffer = a instanceof (H ? Uint8Array : Array) ? a : new (H ? Uint8Array : Array)(32768); + 2 * this.buffer.length <= this.index && i(Error("invalid index")); + this.buffer.length <= this.index && this.f(); + } + J.prototype.f = function() { + var a = this.buffer, c, b = a.length, e = new (H ? Uint8Array : Array)(b << 1); + if (H) e.set(a); else for (c = 0; c < b; ++c) e[c] = a[c]; + return this.buffer = e; + }; + J.prototype.d = function(a, c, b) { + var e = this.buffer, f = this.index, d = this.i, g = e[f], h; + b && 1 < c && (a = 8 < c ? (N[255 & a] << 24 | N[a >>> 8 & 255] << 16 | N[a >>> 16 & 255] << 8 | N[a >>> 24 & 255]) >> 32 - c : N[a] >> 8 - c); + if (8 > c + d) g = g << c | a, d += c; else for (h = 0; h < c; ++h) g = g << 1 | a >> c - h - 1 & 1, + 8 === ++d && (d = 0, e[f++] = N[g], g = 0, f === e.length && (e = this.f())); + e[f] = g; + this.buffer = e; + this.i = d; + this.index = f; + }; + J.prototype.finish = function() { + var a = this.buffer, c = this.index, b; + 0 < this.i && (a[c] <<= 8 - this.i, a[c] = N[a[c]], c++); + H ? b = a.subarray(0, c) : (a.length = c, b = a); + return b; + }; + var ca = new (H ? Uint8Array : Array)(256), ha; + for (ha = 0; 256 > ha; ++ha) { + for (var R = ha, ia = R, ja = 7, R = R >>> 1; R; R >>>= 1) ia <<= 1, ia |= 1 & R, + --ja; + ca[ha] = (ia << ja & 255) >>> 0; + } + var N = ca; + var ka = [ 0, 1996959894, 3993919788, 2567524794, 124634137, 1886057615, 3915621685, 2657392035, 249268274, 2044508324, 3772115230, 2547177864, 162941995, 2125561021, 3887607047, 2428444049, 498536548, 1789927666, 4089016648, 2227061214, 450548861, 1843258603, 4107580753, 2211677639, 325883990, 1684777152, 4251122042, 2321926636, 335633487, 1661365465, 4195302755, 2366115317, 997073096, 1281953886, 3579855332, 2724688242, 1006888145, 1258607687, 3524101629, 2768942443, 901097722, 1119000684, 3686517206, 2898065728, 853044451, 1172266101, 3705015759, 2882616665, 651767980, 1373503546, 3369554304, 3218104598, 565507253, 1454621731, 3485111705, 3099436303, 671266974, 1594198024, 3322730930, 2970347812, 795835527, 1483230225, 3244367275, 3060149565, 1994146192, 31158534, 2563907772, 4023717930, 1907459465, 112637215, 2680153253, 3904427059, 2013776290, 251722036, 2517215374, 3775830040, 2137656763, 141376813, 2439277719, 3865271297, 1802195444, 476864866, 2238001368, 4066508878, 1812370925, 453092731, 2181625025, 4111451223, 1706088902, 314042704, 2344532202, 4240017532, 1658658271, 366619977, 2362670323, 4224994405, 1303535960, 984961486, 2747007092, 3569037538, 1256170817, 1037604311, 2765210733, 3554079995, 1131014506, 879679996, 2909243462, 3663771856, 1141124467, 855842277, 2852801631, 3708648649, 1342533948, 654459306, 3188396048, 3373015174, 1466479909, 544179635, 3110523913, 3462522015, 1591671054, 702138776, 2966460450, 3352799412, 1504918807, 783551873, 3082640443, 3233442989, 3988292384, 2596254646, 62317068, 1957810842, 3939845945, 2647816111, 81470997, 1943803523, 3814918930, 2489596804, 225274430, 2053790376, 3826175755, 2466906013, 167816743, 2097651377, 4027552580, 2265490386, 503444072, 1762050814, 4150417245, 2154129355, 426522225, 1852507879, 4275313526, 2312317920, 282753626, 1742555852, 4189708143, 2394877945, 397917763, 1622183637, 3604390888, 2714866558, 953729732, 1340076626, 3518719985, 2797360999, 1068828381, 1219638859, 3624741850, 2936675148, 906185462, 1090812512, 3747672003, 2825379669, 829329135, 1181335161, 3412177804, 3160834842, 628085408, 1382605366, 3423369109, 3138078467, 570562233, 1426400815, 3317316542, 2998733608, 733239954, 1555261956, 3268935591, 3050360625, 752459403, 1541320221, 2607071920, 3965973030, 1969922972, 40735498, 2617837225, 3943577151, 1913087877, 83908371, 2512341634, 3803740692, 2075208622, 213261112, 2463272603, 3855990285, 2094854071, 198958881, 2262029012, 4057260610, 1759359992, 534414190, 2176718541, 4139329115, 1873836001, 414664567, 2282248934, 4279200368, 1711684554, 285281116, 2405801727, 4167216745, 1634467795, 376229701, 2685067896, 3608007406, 1308918612, 956543938, 2808555105, 3495958263, 1231636301, 1047427035, 2932959818, 3654703836, 1088359270, 936918e3, 2847714899, 3736837829, 1202900863, 817233897, 3183342108, 3401237130, 1404277552, 615818150, 3134207493, 3453421203, 1423857449, 601450431, 3009837614, 3294710456, 1567103746, 711928724, 3020668471, 3272380065, 1510334235, 755167117 ]; + H && new Uint32Array(ka); + function la(a) { + this.buffer = new (H ? Uint16Array : Array)(2 * a); + this.length = 0; + } + la.prototype.getParent = function(a) { + return 2 * ((a - 2) / 4 | 0); + }; + la.prototype.push = function(a, c) { + var b, e, f = this.buffer, d; + b = this.length; + f[this.length++] = c; + for (f[this.length++] = a; 0 < b; ) { + if (e = this.getParent(b), !(f[b] > f[e])) break; + d = f[b], f[b] = f[e], f[e] = d, d = f[b + 1], f[b + 1] = f[e + 1], f[e + 1] = d, + b = e; + } + return this.length; + }; + la.prototype.pop = function() { + var a, c, b = this.buffer, e, f, d; + c = b[0]; + a = b[1]; + this.length -= 2; + b[0] = b[this.length]; + b[1] = b[this.length + 1]; + for (d = 0; ;) { + f = 2 * d + 2; + if (f >= this.length) break; + f + 2 < this.length && b[f + 2] > b[f] && (f += 2); + if (!(b[f] > b[d])) break; + e = b[d], b[d] = b[f], b[f] = e, e = b[d + 1], b[d + 1] = b[f + 1], b[f + 1] = e; + d = f; + } + return { + index: a, + value: c, + length: this.length + }; + }; + function S(a) { + var c = a.length, b = 0, e = Number.POSITIVE_INFINITY, f, d, g, h, m, j, s, n, l; + for (n = 0; n < c; ++n) a[n] > b && (b = a[n]), a[n] < e && (e = a[n]); + f = 1 << b; + d = new (H ? Uint32Array : Array)(f); + g = 1; + h = 0; + for (m = 2; g <= b; ) { + for (n = 0; n < c; ++n) if (a[n] === g) { + j = 0; + s = h; + for (l = 0; l < g; ++l) j = j << 1 | 1 & s, s >>= 1; + for (l = j; l < f; l += m) d[l] = g << 16 | n; + ++h; + } + ++g; + h <<= 1; + m <<= 1; + } + return [ d, b, e ]; + } + function ma(a, c) { + this.h = pa; + this.w = 0; + this.input = a; + this.b = 0; + c && (c.lazy && (this.w = c.lazy), "number" === typeof c.compressionType && (this.h = c.compressionType), + c.outputBuffer && (this.a = H && c.outputBuffer instanceof Array ? new Uint8Array(c.outputBuffer) : c.outputBuffer), + "number" === typeof c.outputIndex && (this.b = c.outputIndex)); + this.a || (this.a = new (H ? Uint8Array : Array)(32768)); + } + var pa = 2, qa = { + NONE: 0, + r: 1, + j: pa, + N: 3 + }, ra = [], T; + for (T = 0; 288 > T; T++) switch (v) { + case 143 >= T: + ra.push([ T + 48, 8 ]); + break; + + case 255 >= T: + ra.push([ T - 144 + 400, 9 ]); + break; + + case 279 >= T: + ra.push([ T - 256 + 0, 7 ]); + break; + + case 287 >= T: + ra.push([ T - 280 + 192, 8 ]); + break; + + default: + i("invalid literal: " + T); + } + ma.prototype.n = function() { + var a, c, b, e, f = this.input; + switch (this.h) { + case 0: + b = 0; + for (e = f.length; b < e; ) { + c = H ? f.subarray(b, b + 65535) : f.slice(b, b + 65535); + b += c.length; + var d = c, g = b === e, h = r, m = r, j = r, s = r, n = r, l = this.a, q = this.b; + if (H) { + for (l = new Uint8Array(this.a.buffer); l.length <= q + d.length + 5; ) l = new Uint8Array(l.length << 1); + l.set(this.a); + } + h = g ? 1 : 0; + l[q++] = 0 | h; + m = d.length; + j = 65536 + ~m & 65535; + l[q++] = 255 & m; + l[q++] = m >>> 8 & 255; + l[q++] = 255 & j; + l[q++] = j >>> 8 & 255; + if (H) l.set(d, q), q += d.length, l = l.subarray(0, q); else { + s = 0; + for (n = d.length; s < n; ++s) l[q++] = d[s]; + l.length = q; + } + this.b = q; + this.a = l; + } + break; + + case 1: + var E = new J(new Uint8Array(this.a.buffer), this.b); + E.d(1, 1, v); + E.d(1, 2, v); + var t = sa(this, f), z, K, A; + z = 0; + for (K = t.length; z < K; z++) if (A = t[z], J.prototype.d.apply(E, ra[A]), 256 < A) E.d(t[++z], t[++z], v), + E.d(t[++z], 5), E.d(t[++z], t[++z], v); else if (256 === A) break; + this.a = E.finish(); + this.b = this.a.length; + break; + + case pa: + var x = new J(new Uint8Array(this.a), this.b), B, k, p, D, C, da = [ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 ], W, Ma, ea, Na, na, va = Array(19), Oa, $, oa, F, Pa; + B = pa; + x.d(1, 1, v); + x.d(B, 2, v); + k = sa(this, f); + W = ta(this.L, 15); + Ma = ua(W); + ea = ta(this.K, 7); + Na = ua(ea); + for (p = 286; 257 < p && 0 === W[p - 1]; p--) ; + for (D = 30; 1 < D && 0 === ea[D - 1]; D--) ; + var Qa = p, Ra = D, M = new (H ? Uint32Array : Array)(Qa + Ra), u, O, w, fa, L = new (H ? Uint32Array : Array)(316), I, G, P = new (H ? Uint8Array : Array)(19); + for (u = O = 0; u < Qa; u++) M[O++] = W[u]; + for (u = 0; u < Ra; u++) M[O++] = ea[u]; + if (!H) { + u = 0; + for (fa = P.length; u < fa; ++u) P[u] = 0; + } + u = I = 0; + for (fa = M.length; u < fa; u += O) { + for (O = 1; u + O < fa && M[u + O] === M[u]; ++O) ; + w = O; + if (0 === M[u]) if (3 > w) for (;0 < w--; ) L[I++] = 0, P[0]++; else for (;0 < w; ) G = 138 > w ? w : 138, + G > w - 3 && G < w && (G = w - 3), 10 >= G ? (L[I++] = 17, L[I++] = G - 3, P[17]++) : (L[I++] = 18, + L[I++] = G - 11, P[18]++), w -= G; else if (L[I++] = M[u], P[M[u]]++, w--, 3 > w) for (;0 < w--; ) L[I++] = M[u], + P[M[u]]++; else for (;0 < w; ) G = 6 > w ? w : 6, G > w - 3 && G < w && (G = w - 3), + L[I++] = 16, L[I++] = G - 3, P[16]++, w -= G; + } + a = H ? L.subarray(0, I) : L.slice(0, I); + na = ta(P, 7); + for (F = 0; 19 > F; F++) va[F] = na[da[F]]; + for (C = 19; 4 < C && 0 === va[C - 1]; C--) ; + Oa = ua(na); + x.d(p - 257, 5, v); + x.d(D - 1, 5, v); + x.d(C - 4, 4, v); + for (F = 0; F < C; F++) x.d(va[F], 3, v); + F = 0; + for (Pa = a.length; F < Pa; F++) if ($ = a[F], x.d(Oa[$], na[$], v), 16 <= $) { + F++; + switch ($) { + case 16: + oa = 2; + break; + + case 17: + oa = 3; + break; + + case 18: + oa = 7; + break; + + default: + i("invalid code: " + $); + } + x.d(a[F], oa, v); + } + var Sa = [ Ma, W ], Ta = [ Na, ea ], Q, Ua, ga, ya, Va, Wa, Xa, Ya; + Va = Sa[0]; + Wa = Sa[1]; + Xa = Ta[0]; + Ya = Ta[1]; + Q = 0; + for (Ua = k.length; Q < Ua; ++Q) if (ga = k[Q], x.d(Va[ga], Wa[ga], v), 256 < ga) x.d(k[++Q], k[++Q], v), + ya = k[++Q], x.d(Xa[ya], Ya[ya], v), x.d(k[++Q], k[++Q], v); else if (256 === ga) break; + this.a = x.finish(); + this.b = this.a.length; + break; + + default: + i("invalid compression type"); + } + return this.a; + }; + function wa(a, c) { + this.length = a; + this.G = c; + } + function xa() { + var a = za; + switch (v) { + case 3 === a: + return [ 257, a - 3, 0 ]; + + case 4 === a: + return [ 258, a - 4, 0 ]; + + case 5 === a: + return [ 259, a - 5, 0 ]; + + case 6 === a: + return [ 260, a - 6, 0 ]; + + case 7 === a: + return [ 261, a - 7, 0 ]; + + case 8 === a: + return [ 262, a - 8, 0 ]; + + case 9 === a: + return [ 263, a - 9, 0 ]; + + case 10 === a: + return [ 264, a - 10, 0 ]; + + case 12 >= a: + return [ 265, a - 11, 1 ]; + + case 14 >= a: + return [ 266, a - 13, 1 ]; + + case 16 >= a: + return [ 267, a - 15, 1 ]; + + case 18 >= a: + return [ 268, a - 17, 1 ]; + + case 22 >= a: + return [ 269, a - 19, 2 ]; + + case 26 >= a: + return [ 270, a - 23, 2 ]; + + case 30 >= a: + return [ 271, a - 27, 2 ]; + + case 34 >= a: + return [ 272, a - 31, 2 ]; + + case 42 >= a: + return [ 273, a - 35, 3 ]; + + case 50 >= a: + return [ 274, a - 43, 3 ]; + + case 58 >= a: + return [ 275, a - 51, 3 ]; + + case 66 >= a: + return [ 276, a - 59, 3 ]; + + case 82 >= a: + return [ 277, a - 67, 4 ]; + + case 98 >= a: + return [ 278, a - 83, 4 ]; + + case 114 >= a: + return [ 279, a - 99, 4 ]; + + case 130 >= a: + return [ 280, a - 115, 4 ]; + + case 162 >= a: + return [ 281, a - 131, 5 ]; + + case 194 >= a: + return [ 282, a - 163, 5 ]; + + case 226 >= a: + return [ 283, a - 195, 5 ]; + + case 257 >= a: + return [ 284, a - 227, 5 ]; + + case 258 === a: + return [ 285, a - 258, 0 ]; + + default: + i("invalid length: " + a); + } + } + var Aa = [], za, Ba; + for (za = 3; 258 >= za; za++) Ba = xa(), Aa[za] = Ba[2] << 24 | Ba[1] << 16 | Ba[0]; + var Ca = H ? new Uint32Array(Aa) : Aa; + function sa(a, c) { + function b(a, c) { + var b = a.G, d = [], e = 0, f; + f = Ca[a.length]; + d[e++] = 65535 & f; + d[e++] = f >> 16 & 255; + d[e++] = f >> 24; + var g; + switch (v) { + case 1 === b: + g = [ 0, b - 1, 0 ]; + break; + + case 2 === b: + g = [ 1, b - 2, 0 ]; + break; + + case 3 === b: + g = [ 2, b - 3, 0 ]; + break; + + case 4 === b: + g = [ 3, b - 4, 0 ]; + break; + + case 6 >= b: + g = [ 4, b - 5, 1 ]; + break; + + case 8 >= b: + g = [ 5, b - 7, 1 ]; + break; + + case 12 >= b: + g = [ 6, b - 9, 2 ]; + break; + + case 16 >= b: + g = [ 7, b - 13, 2 ]; + break; + + case 24 >= b: + g = [ 8, b - 17, 3 ]; + break; + + case 32 >= b: + g = [ 9, b - 25, 3 ]; + break; + + case 48 >= b: + g = [ 10, b - 33, 4 ]; + break; + + case 64 >= b: + g = [ 11, b - 49, 4 ]; + break; + + case 96 >= b: + g = [ 12, b - 65, 5 ]; + break; + + case 128 >= b: + g = [ 13, b - 97, 5 ]; + break; + + case 192 >= b: + g = [ 14, b - 129, 6 ]; + break; + + case 256 >= b: + g = [ 15, b - 193, 6 ]; + break; + + case 384 >= b: + g = [ 16, b - 257, 7 ]; + break; + + case 512 >= b: + g = [ 17, b - 385, 7 ]; + break; + + case 768 >= b: + g = [ 18, b - 513, 8 ]; + break; + + case 1024 >= b: + g = [ 19, b - 769, 8 ]; + break; + + case 1536 >= b: + g = [ 20, b - 1025, 9 ]; + break; + + case 2048 >= b: + g = [ 21, b - 1537, 9 ]; + break; + + case 3072 >= b: + g = [ 22, b - 2049, 10 ]; + break; + + case 4096 >= b: + g = [ 23, b - 3073, 10 ]; + break; + + case 6144 >= b: + g = [ 24, b - 4097, 11 ]; + break; + + case 8192 >= b: + g = [ 25, b - 6145, 11 ]; + break; + + case 12288 >= b: + g = [ 26, b - 8193, 12 ]; + break; + + case 16384 >= b: + g = [ 27, b - 12289, 12 ]; + break; + + case 24576 >= b: + g = [ 28, b - 16385, 13 ]; + break; + + case 32768 >= b: + g = [ 29, b - 24577, 13 ]; + break; + + default: + i("invalid distance"); + } + f = g; + d[e++] = f[0]; + d[e++] = f[1]; + d[e++] = f[2]; + var h, j; + h = 0; + for (j = d.length; h < j; ++h) l[q++] = d[h]; + t[d[0]]++; + z[d[3]]++; + E = a.length + c - 1; + n = null; + } + var e, f, d, g, h, m = {}, j, s, n, l = H ? new Uint16Array(2 * c.length) : [], q = 0, E = 0, t = new (H ? Uint32Array : Array)(286), z = new (H ? Uint32Array : Array)(30), K = a.w, A; + if (!H) { + for (d = 0; 285 >= d; ) t[d++] = 0; + for (d = 0; 29 >= d; ) z[d++] = 0; + } + t[256] = 1; + e = 0; + for (f = c.length; e < f; ++e) { + d = h = 0; + for (g = 3; d < g && e + d !== f; ++d) h = h << 8 | c[e + d]; + m[h] === r && (m[h] = []); + j = m[h]; + if (!(0 < E--)) { + for (;0 < j.length && 32768 < e - j[0]; ) j.shift(); + if (e + 3 >= f) { + n && b(n, -1); + d = 0; + for (g = f - e; d < g; ++d) A = c[e + d], l[q++] = A, ++t[A]; + break; + } + if (0 < j.length) { + var x = r, B = r, k = 0, p = r, D = r, C = r, da = r, W = c.length, D = 0, da = j.length; + a: for (;D < da; D++) { + x = j[da - D - 1]; + p = 3; + if (3 < k) { + for (C = k; 3 < C; C--) if (c[x + C - 1] !== c[e + C - 1]) continue a; + p = k; + } + for (;258 > p && e + p < W && c[x + p] === c[e + p]; ) ++p; + p > k && (B = x, k = p); + if (258 === p) break; + } + s = new wa(k, e - B); + n ? n.length < s.length ? (A = c[e - 1], l[q++] = A, ++t[A], b(s, 0)) : b(n, -1) : s.length < K ? n = s : b(s, 0); + } else n ? b(n, -1) : (A = c[e], l[q++] = A, ++t[A]); + } + j.push(e); + } + l[q++] = 256; + t[256]++; + a.L = t; + a.K = z; + return H ? l.subarray(0, q) : l; + } + function ta(a, c) { + function b(a) { + var c = z[a][K[a]]; + c === n ? (b(a + 1), b(a + 1)) : --E[c]; + ++K[a]; + } + var e = a.length, f = new la(572), d = new (H ? Uint8Array : Array)(e), g, h, m, j, s; + if (!H) for (j = 0; j < e; j++) d[j] = 0; + for (j = 0; j < e; ++j) 0 < a[j] && f.push(j, a[j]); + g = Array(f.length / 2); + h = new (H ? Uint32Array : Array)(f.length / 2); + if (1 === g.length) return d[f.pop().index] = 1, d; + j = 0; + for (s = f.length / 2; j < s; ++j) g[j] = f.pop(), h[j] = g[j].value; + var n = h.length, l = new (H ? Uint16Array : Array)(c), q = new (H ? Uint8Array : Array)(c), E = new (H ? Uint8Array : Array)(n), t = Array(c), z = Array(c), K = Array(c), A = (1 << c) - n, x = 1 << c - 1, B, k, p, D, C; + l[c - 1] = n; + for (k = 0; k < c; ++k) A < x ? q[k] = 0 : (q[k] = 1, A -= x), A <<= 1, l[c - 2 - k] = (l[c - 1 - k] / 2 | 0) + n; + l[0] = q[0]; + t[0] = Array(l[0]); + z[0] = Array(l[0]); + for (k = 1; k < c; ++k) l[k] > 2 * l[k - 1] + q[k] && (l[k] = 2 * l[k - 1] + q[k]), + t[k] = Array(l[k]), z[k] = Array(l[k]); + for (B = 0; B < n; ++B) E[B] = c; + for (p = 0; p < l[c - 1]; ++p) t[c - 1][p] = h[p], z[c - 1][p] = p; + for (B = 0; B < c; ++B) K[B] = 0; + 1 === q[c - 1] && (--E[0], ++K[c - 1]); + for (k = c - 2; 0 <= k; --k) { + D = B = 0; + C = K[k + 1]; + for (p = 0; p < l[k]; p++) D = t[k + 1][C] + t[k + 1][C + 1], D > h[B] ? (t[k][p] = D, + z[k][p] = n, C += 2) : (t[k][p] = h[B], z[k][p] = B, ++B); + K[k] = 0; + 1 === q[k] && b(k); + } + m = E; + j = 0; + for (s = g.length; j < s; ++j) d[g[j].index] = m[j]; + return d; + } + function ua(a) { + var c = new (H ? Uint16Array : Array)(a.length), b = [], e = [], f = 0, d, g, h, m; + d = 0; + for (g = a.length; d < g; d++) b[a[d]] = 1 + (0 | b[a[d]]); + d = 1; + for (g = 16; d <= g; d++) e[d] = f, f += 0 | b[d], f > 1 << d && i("overcommitted"), + f <<= 1; + 65536 > f && i("undercommitted"); + d = 0; + for (g = a.length; d < g; d++) { + f = e[a[d]]; + e[a[d]] += 1; + h = c[d] = 0; + for (m = a[d]; h < m; h++) c[d] = c[d] << 1 | 1 & f, f >>>= 1; + } + return c; + } + function Da(a, c) { + this.input = a; + this.a = new (H ? Uint8Array : Array)(32768); + this.h = U.j; + var b = {}, e; + !c && (c = {}) || "number" !== typeof c.compressionType || (this.h = c.compressionType); + for (e in c) b[e] = c[e]; + b.outputBuffer = this.a; + this.z = new ma(this.input, b); + } + var U = qa; + Da.prototype.n = function() { + var a, c, b, e, f, d, g, h = 0; + g = this.a; + a = Ea; + switch (a) { + case Ea: + c = Math.LOG2E * Math.log(32768) - 8; + break; + + default: + i(Error("invalid compression method")); + } + b = c << 4 | a; + g[h++] = b; + switch (a) { + case Ea: + switch (this.h) { + case U.NONE: + f = 0; + break; + + case U.r: + f = 1; + break; + + case U.j: + f = 2; + break; + + default: + i(Error("unsupported compression type")); + } + break; + + default: + i(Error("invalid compression method")); + } + e = f << 6 | 0; + g[h++] = e | 31 - (256 * b + e) % 31; + d = ba(this.input); + this.z.b = h; + g = this.z.n(); + h = g.length; + H && (g = new Uint8Array(g.buffer), g.length <= h + 4 && (this.a = new Uint8Array(g.length + 4), + this.a.set(g), g = this.a), g = g.subarray(0, h + 4)); + g[h++] = d >> 24 & 255; + g[h++] = d >> 16 & 255; + g[h++] = d >> 8 & 255; + g[h++] = 255 & d; + return g; + }; + y("Zlib.Deflate", Da); + y("Zlib.Deflate.compress", (function(a, c) { + return new Da(a, c).n(); + })); + y("Zlib.Deflate.CompressionType", U); + y("Zlib.Deflate.CompressionType.NONE", U.NONE); + y("Zlib.Deflate.CompressionType.FIXED", U.r); + y("Zlib.Deflate.CompressionType.DYNAMIC", U.j); + function V(a, c) { + this.k = []; + this.l = 32768; + this.e = this.g = this.c = this.q = 0; + this.input = H ? new Uint8Array(a) : a; + this.s = !1; + this.m = Fa; + this.B = !1; + !c && (c = {}) || (c.index && (this.c = c.index), c.bufferSize && (this.l = c.bufferSize), + c.bufferType && (this.m = c.bufferType), c.resize && (this.B = c.resize)); + switch (this.m) { + case Ga: + this.b = 32768; + this.a = new (H ? Uint8Array : Array)(32768 + this.l + 258); + break; + + case Fa: + this.b = 0; + this.a = new (H ? Uint8Array : Array)(this.l); + this.f = this.J; + this.t = this.H; + this.o = this.I; + break; + + default: + i(Error("invalid inflate mode")); + } + } + var Ga = 0, Fa = 1, Ha = { + D: Ga, + C: Fa + }; + V.prototype.p = function() { + for (;!this.s; ) { + var a = X(this, 3); + 1 & a && (this.s = v); + a >>>= 1; + switch (a) { + case 0: + var c = this.input, b = this.c, e = this.a, f = this.b, d = r, g = r, h = r, m = e.length, j = r; + this.e = this.g = 0; + d = c[b++]; + d === r && i(Error("invalid uncompressed block header: LEN (first byte)")); + g = d; + d = c[b++]; + d === r && i(Error("invalid uncompressed block header: LEN (second byte)")); + g |= d << 8; + d = c[b++]; + d === r && i(Error("invalid uncompressed block header: NLEN (first byte)")); + h = d; + d = c[b++]; + d === r && i(Error("invalid uncompressed block header: NLEN (second byte)")); + h |= d << 8; + g === ~h && i(Error("invalid uncompressed block header: length verify")); + b + g > c.length && i(Error("input buffer is broken")); + switch (this.m) { + case Ga: + for (;f + g > e.length; ) { + j = m - f; + g -= j; + if (H) e.set(c.subarray(b, b + j), f), f += j, b += j; else for (;j--; ) e[f++] = c[b++]; + this.b = f; + e = this.f(); + f = this.b; + } + break; + + case Fa: + for (;f + g > e.length; ) e = this.f({ + v: 2 + }); + break; + + default: + i(Error("invalid inflate mode")); + } + if (H) e.set(c.subarray(b, b + g), f), f += g, b += g; else for (;g--; ) e[f++] = c[b++]; + this.c = b; + this.b = f; + this.a = e; + break; + + case 1: + this.o(Ia, Ja); + break; + + case 2: + Ka(this); + break; + + default: + i(Error("unknown BTYPE: " + a)); + } + } + return this.t(); + }; + var La = [ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 ], Za = H ? new Uint16Array(La) : La, $a = [ 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 258, 258 ], ab = H ? new Uint16Array($a) : $a, bb = [ 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 0, 0 ], cb = H ? new Uint8Array(bb) : bb, db = [ 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577 ], eb = H ? new Uint16Array(db) : db, fb = [ 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13 ], gb = H ? new Uint8Array(fb) : fb, hb = new (H ? Uint8Array : Array)(288), Y, ib; + Y = 0; + for (ib = hb.length; Y < ib; ++Y) hb[Y] = 143 >= Y ? 8 : 255 >= Y ? 9 : 279 >= Y ? 7 : 8; + var Ia = S(hb), jb = new (H ? Uint8Array : Array)(30), kb, lb; + kb = 0; + for (lb = jb.length; kb < lb; ++kb) jb[kb] = 5; + var Ja = S(jb); + function X(a, c) { + for (var b = a.g, e = a.e, f = a.input, d = a.c, g; e < c; ) g = f[d++], g === r && i(Error("input buffer is broken")), + b |= g << e, e += 8; + g = b & (1 << c) - 1; + a.g = b >>> c; + a.e = e - c; + a.c = d; + return g; + } + function mb(a, c) { + for (var b = a.g, e = a.e, f = a.input, d = a.c, g = c[0], h = c[1], m, j, s; e < h; ) m = f[d++], + m === r && i(Error("input buffer is broken")), b |= m << e, e += 8; + j = g[b & (1 << h) - 1]; + s = j >>> 16; + a.g = b >> s; + a.e = e - s; + a.c = d; + return 65535 & j; + } + function Ka(a) { + function c(a, b, c) { + var d, e, f, g; + for (g = 0; g < a; ) switch (d = mb(this, b), d) { + case 16: + for (f = 3 + X(this, 2); f--; ) c[g++] = e; + break; + + case 17: + for (f = 3 + X(this, 3); f--; ) c[g++] = 0; + e = 0; + break; + + case 18: + for (f = 11 + X(this, 7); f--; ) c[g++] = 0; + e = 0; + break; + + default: + e = c[g++] = d; + } + return c; + } + var b = X(a, 5) + 257, e = X(a, 5) + 1, f = X(a, 4) + 4, d = new (H ? Uint8Array : Array)(Za.length), g, h, m, j; + for (j = 0; j < f; ++j) d[Za[j]] = X(a, 3); + g = S(d); + h = new (H ? Uint8Array : Array)(b); + m = new (H ? Uint8Array : Array)(e); + a.o(S(c.call(a, b, g, h)), S(c.call(a, e, g, m))); + } + V.prototype.o = function(a, c) { + var b = this.a, e = this.b; + this.u = a; + for (var f = b.length - 258, d, g, h, m; 256 !== (d = mb(this, a)); ) if (256 > d) e >= f && (this.b = e, + b = this.f(), e = this.b), b[e++] = d; else { + g = d - 257; + m = ab[g]; + 0 < cb[g] && (m += X(this, cb[g])); + d = mb(this, c); + h = eb[d]; + 0 < gb[d] && (h += X(this, gb[d])); + e >= f && (this.b = e, b = this.f(), e = this.b); + for (;m--; ) b[e] = b[e++ - h]; + } + for (;8 <= this.e; ) this.e -= 8, this.c--; + this.b = e; + }; + V.prototype.I = function(a, c) { + var b = this.a, e = this.b; + this.u = a; + for (var f = b.length, d, g, h, m; 256 !== (d = mb(this, a)); ) if (256 > d) e >= f && (b = this.f(), + f = b.length), b[e++] = d; else { + g = d - 257; + m = ab[g]; + 0 < cb[g] && (m += X(this, cb[g])); + d = mb(this, c); + h = eb[d]; + 0 < gb[d] && (h += X(this, gb[d])); + e + m > f && (b = this.f(), f = b.length); + for (;m--; ) b[e] = b[e++ - h]; + } + for (;8 <= this.e; ) this.e -= 8, this.c--; + this.b = e; + }; + V.prototype.f = function() { + var a = new (H ? Uint8Array : Array)(this.b - 32768), c = this.b - 32768, b, e, f = this.a; + if (H) a.set(f.subarray(32768, a.length)); else { + b = 0; + for (e = a.length; b < e; ++b) a[b] = f[b + 32768]; + } + this.k.push(a); + this.q += a.length; + if (H) f.set(f.subarray(c, c + 32768)); else for (b = 0; 32768 > b; ++b) f[b] = f[c + b]; + this.b = 32768; + return f; + }; + V.prototype.J = function(a) { + var c, b = this.input.length / this.c + 1 | 0, e, f, d, g = this.input, h = this.a; + a && ("number" === typeof a.v && (b = a.v), "number" === typeof a.F && (b += a.F)); + 2 > b ? (e = (g.length - this.c) / this.u[2], d = e / 2 * 258 | 0, f = d < h.length ? h.length + d : h.length << 1) : f = h.length * b; + H ? (c = new Uint8Array(f), c.set(h)) : c = h; + return this.a = c; + }; + V.prototype.t = function() { + var a = 0, c = this.a, b = this.k, e, f = new (H ? Uint8Array : Array)(this.q + (this.b - 32768)), d, g, h, m; + if (0 === b.length) return H ? this.a.subarray(32768, this.b) : this.a.slice(32768, this.b); + d = 0; + for (g = b.length; d < g; ++d) { + e = b[d]; + h = 0; + for (m = e.length; h < m; ++h) f[a++] = e[h]; + } + d = 32768; + for (g = this.b; d < g; ++d) f[a++] = c[d]; + this.k = []; + return this.buffer = f; + }; + V.prototype.H = function() { + var a, c = this.b; + H ? this.B ? (a = new Uint8Array(c), a.set(this.a.subarray(0, c))) : a = this.a.subarray(0, c) : (this.a.length > c && (this.a.length = c), + a = this.a); + return this.buffer = a; + }; + function nb(a, c) { + var b, e; + this.input = a; + this.c = 0; + !c && (c = {}) || (c.index && (this.c = c.index), c.verify && (this.M = c.verify)); + b = a[this.c++]; + e = a[this.c++]; + switch (15 & b) { + case Ea: + this.method = Ea; + break; + + default: + i(Error("unsupported compression method")); + } + 0 !== ((b << 8) + e) % 31 && i(Error("invalid fcheck flag:" + ((b << 8) + e) % 31)); + 32 & e && i(Error("fdict flag is not supported")); + this.A = new V(a, { + index: this.c, + bufferSize: c.bufferSize, + bufferType: c.bufferType, + resize: c.resize + }); + } + nb.prototype.p = function() { + var a = this.input, c, b; + c = this.A.p(); + this.c = this.A.c; + this.M && (b = (a[this.c++] << 24 | a[this.c++] << 16 | a[this.c++] << 8 | a[this.c++]) >>> 0, + b !== ba(c) && i(Error("invalid adler-32 checksum"))); + return c; + }; + y("Zlib.Inflate", nb); + y("Zlib.Inflate.BufferType", Ha); + Ha.ADAPTIVE = Ha.C; + Ha.BLOCK = Ha.D; + y("Zlib.Inflate.prototype.decompress", nb.prototype.p); + var ob = [ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 ]; + H && new Uint16Array(ob); + var pb = [ 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 258, 258 ]; + H && new Uint16Array(pb); + var qb = [ 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 0, 0 ]; + H && new Uint8Array(qb); + var rb = [ 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577 ]; + H && new Uint16Array(rb); + var sb = [ 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13 ]; + H && new Uint8Array(sb); + var tb = new (H ? Uint8Array : Array)(288), Z, ub; + Z = 0; + for (ub = tb.length; Z < ub; ++Z) tb[Z] = 143 >= Z ? 8 : 255 >= Z ? 9 : 279 >= Z ? 7 : 8; + S(tb); + var vb = new (H ? Uint8Array : Array)(30), wb, xb; + wb = 0; + for (xb = vb.length; wb < xb; ++wb) vb[wb] = 5; + S(vb); + var Ea = 8; + }).call(window); + var _p = window.Zlib; + _p.Deflate = _p["Deflate"]; + _p.Deflate.compress = _p.Deflate["compress"]; + _p.Inflate = _p["Inflate"]; + _p.Inflate.BufferType = _p.Inflate["BufferType"]; + _p.Inflate.prototype.decompress = _p.Inflate.prototype["decompress"]; + module.exports = _p; + }), {} ], + 27: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _enums = _interopRequireDefault(require("../../renderer/enums")); + var _color = _interopRequireDefault(require("../value-types/color")); + var _valueTypes = require("../value-types"); + var _index = _interopRequireDefault(require("../renderer/index")); + var _CCEnum = _interopRequireDefault(require("../platform/CCEnum")); + var _CCComponent2 = _interopRequireDefault(require("../components/CCComponent")); + var _CCClassDecorator = require("../platform/CCClassDecorator"); + var _dec, _dec2, _dec3, _dec4, _dec5, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6, _descriptor7, _descriptor8, _descriptor9, _descriptor10, _descriptor11, _descriptor12, _descriptor13, _class3, _temp; + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + 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 + }); + } + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + "value" in descriptor && (descriptor.writable = true); + Object.defineProperty(target, descriptor.key, descriptor); + } + } + function _createClass(Constructor, protoProps, staticProps) { + protoProps && _defineProperties(Constructor.prototype, protoProps); + staticProps && _defineProperties(Constructor, staticProps); + return Constructor; + } + function _assertThisInitialized(self) { + if (void 0 === self) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + return self; + } + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + _setPrototypeOf(subClass, superClass); + } + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + return _setPrototypeOf(o, p); + } + 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; + ("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 && void 0 !== desc.initializer) { + desc.value = desc.initializer ? desc.initializer.call(context) : void 0; + desc.initializer = void 0; + } + if (void 0 === desc.initializer) { + Object.defineProperty(target, property, desc); + desc = null; + } + return desc; + } + function _initializerWarningHelper(descriptor, context) { + throw new Error("Decorating class property failed. Please ensure that proposal-class-properties is enabled and runs after the decorators transform."); + } + var RendererLight = null; + false; + RendererLight = require("../../renderer/scene/light"); + var LightType = (0, _CCEnum["default"])({ + DIRECTIONAL: 0, + POINT: 1, + SPOT: 2, + AMBIENT: 3 + }); + var LightShadowType = (0, _CCEnum["default"])({ + NONE: 0, + HARD: 2, + SOFT_PCF3X3: 3, + SOFT_PCF5X5: 4 + }); + var Light = (_dec = (0, _CCClassDecorator.ccclass)("cc.Light"), _dec2 = (0, _CCClassDecorator.menu)("i18n:MAIN_MENU.component.renderers/Light"), + _dec3 = (0, _CCClassDecorator.inspector)("packages://inspector/inspectors/comps/light.js"), + _dec4 = (0, _CCClassDecorator.property)({ + type: LightType + }), _dec5 = (0, _CCClassDecorator.property)({ + type: LightShadowType + }), _dec(_class = _dec2(_class = (0, _CCClassDecorator.executeInEditMode)(_class = _dec3(_class = (_class2 = (_temp = _class3 = (function(_CCComponent) { + _inheritsLoose(Light, _CCComponent); + function Light() { + var _this; + _this = _CCComponent.call(this) || this; + _initializerDefineProperty(_this, "_type", _descriptor, _assertThisInitialized(_this)); + _initializerDefineProperty(_this, "_color", _descriptor2, _assertThisInitialized(_this)); + _initializerDefineProperty(_this, "_intensity", _descriptor3, _assertThisInitialized(_this)); + _initializerDefineProperty(_this, "_range", _descriptor4, _assertThisInitialized(_this)); + _initializerDefineProperty(_this, "_spotAngle", _descriptor5, _assertThisInitialized(_this)); + _initializerDefineProperty(_this, "_spotExp", _descriptor6, _assertThisInitialized(_this)); + _initializerDefineProperty(_this, "_shadowType", _descriptor7, _assertThisInitialized(_this)); + _initializerDefineProperty(_this, "_shadowResolution", _descriptor8, _assertThisInitialized(_this)); + _initializerDefineProperty(_this, "_shadowDarkness", _descriptor9, _assertThisInitialized(_this)); + _initializerDefineProperty(_this, "_shadowMinDepth", _descriptor10, _assertThisInitialized(_this)); + _initializerDefineProperty(_this, "_shadowMaxDepth", _descriptor11, _assertThisInitialized(_this)); + _initializerDefineProperty(_this, "_shadowFrustumSize", _descriptor12, _assertThisInitialized(_this)); + _initializerDefineProperty(_this, "_shadowBias", _descriptor13, _assertThisInitialized(_this)); + _this._light = new RendererLight(); + return _this; + } + var _proto = Light.prototype; + _proto.onLoad = function onLoad() { + this._light.setNode(this.node); + this.type = this._type; + this.color = this._color; + this.intensity = this._intensity; + this.range = this._range; + this.spotAngle = this._spotAngle; + this.spotExp = this._spotExp; + this.shadowType = this._shadowType; + this.shadowResolution = this._shadowResolution; + this.shadowDarkness = this._shadowDarkness; + this.shadowMaxDepth = this._shadowMaxDepth; + this.shadowFrustumSize = this._shadowFrustumSize; + this.shadowBias = this._shadowBias; + }; + _proto.onEnable = function onEnable() { + _index["default"].scene.addLight(this._light); + }; + _proto.onDisable = function onDisable() { + _index["default"].scene.removeLight(this._light); + }; + _createClass(Light, [ { + key: "type", + get: function get() { + return this._type; + }, + set: function set(val) { + this._type = val; + var type = _enums["default"].LIGHT_DIRECTIONAL; + val === LightType.POINT ? type = _enums["default"].LIGHT_POINT : val === LightType.SPOT ? type = _enums["default"].LIGHT_SPOT : val === LightType.AMBIENT && (type = _enums["default"].LIGHT_AMBIENT); + this._light.setType(type); + } + }, { + key: "color", + get: function get() { + return this._color; + }, + set: function set(val) { + this._color.equals(val) || this._color.set(val); + this._light.setColor(val.r / 255, val.g / 255, val.b / 255); + } + }, { + key: "intensity", + get: function get() { + return this._intensity; + }, + set: function set(val) { + this._intensity = val; + this._light.setIntensity(val); + } + }, { + key: "range", + get: function get() { + return this._range; + }, + set: function set(val) { + this._range = val; + this._light.setRange(val); + } + }, { + key: "spotAngle", + get: function get() { + return this._spotAngle; + }, + set: function set(val) { + this._spotAngle = val; + this._light.setSpotAngle((0, _valueTypes.toRadian)(val)); + } + }, { + key: "spotExp", + get: function get() { + return this._spotExp; + }, + set: function set(val) { + this._spotExp = val; + this._light.setSpotExp(val); + } + }, { + key: "shadowType", + get: function get() { + return this._shadowType; + }, + set: function set(val) { + this._shadowType = val; + this._light.setShadowType(val); + } + }, { + key: "shadowResolution", + get: function get() { + return this._shadowResolution; + }, + set: function set(val) { + this._shadowResolution = val; + this._light.setShadowResolution(val); + } + }, { + key: "shadowDarkness", + get: function get() { + return this._shadowDarkness; + }, + set: function set(val) { + this._shadowDarkness = val; + this._light.setShadowDarkness(val); + } + }, { + key: "shadowMinDepth", + get: function get() { + return this._shadowMinDepth; + }, + set: function set(val) { + this._shadowMinDepth = val; + this._light.setShadowMinDepth(val); + } + }, { + key: "shadowMaxDepth", + get: function get() { + return this._shadowMaxDepth; + }, + set: function set(val) { + this._shadowMaxDepth = val; + this._light.setShadowMaxDepth(val); + } + }, { + key: "shadowFrustumSize", + get: function get() { + return this._shadowFrustumSize; + }, + set: function set(val) { + this._shadowFrustumSize = val; + this._light.setShadowFrustumSize(val); + } + } ]); + return Light; + })(_CCComponent2["default"]), _class3.Type = LightType, _class3.ShadowType = LightShadowType, + _temp), _descriptor = _applyDecoratedDescriptor(_class2.prototype, "_type", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return LightType.DIRECTIONAL; + } + }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "_color", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return _color["default"].WHITE; + } + }), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "_intensity", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return 1; + } + }), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "_range", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return 1e3; + } + }), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, "_spotAngle", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return 60; + } + }), _descriptor6 = _applyDecoratedDescriptor(_class2.prototype, "_spotExp", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return 1; + } + }), _descriptor7 = _applyDecoratedDescriptor(_class2.prototype, "_shadowType", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return LightShadowType.NONE; + } + }), _descriptor8 = _applyDecoratedDescriptor(_class2.prototype, "_shadowResolution", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return 1024; + } + }), _descriptor9 = _applyDecoratedDescriptor(_class2.prototype, "_shadowDarkness", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return .5; + } + }), _descriptor10 = _applyDecoratedDescriptor(_class2.prototype, "_shadowMinDepth", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return 1; + } + }), _descriptor11 = _applyDecoratedDescriptor(_class2.prototype, "_shadowMaxDepth", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return 4096; + } + }), _descriptor12 = _applyDecoratedDescriptor(_class2.prototype, "_shadowFrustumSize", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return 1024; + } + }), _descriptor13 = _applyDecoratedDescriptor(_class2.prototype, "_shadowBias", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return 5e-4; + } + }), _applyDecoratedDescriptor(_class2.prototype, "type", [ _dec4 ], Object.getOwnPropertyDescriptor(_class2.prototype, "type"), _class2.prototype), + _applyDecoratedDescriptor(_class2.prototype, "color", [ _CCClassDecorator.property ], Object.getOwnPropertyDescriptor(_class2.prototype, "color"), _class2.prototype), + _applyDecoratedDescriptor(_class2.prototype, "intensity", [ _CCClassDecorator.property ], Object.getOwnPropertyDescriptor(_class2.prototype, "intensity"), _class2.prototype), + _applyDecoratedDescriptor(_class2.prototype, "range", [ _CCClassDecorator.property ], Object.getOwnPropertyDescriptor(_class2.prototype, "range"), _class2.prototype), + _applyDecoratedDescriptor(_class2.prototype, "spotAngle", [ _CCClassDecorator.property ], Object.getOwnPropertyDescriptor(_class2.prototype, "spotAngle"), _class2.prototype), + _applyDecoratedDescriptor(_class2.prototype, "spotExp", [ _CCClassDecorator.property ], Object.getOwnPropertyDescriptor(_class2.prototype, "spotExp"), _class2.prototype), + _applyDecoratedDescriptor(_class2.prototype, "shadowType", [ _dec5 ], Object.getOwnPropertyDescriptor(_class2.prototype, "shadowType"), _class2.prototype), + _applyDecoratedDescriptor(_class2.prototype, "shadowResolution", [ _CCClassDecorator.property ], Object.getOwnPropertyDescriptor(_class2.prototype, "shadowResolution"), _class2.prototype), + _applyDecoratedDescriptor(_class2.prototype, "shadowDarkness", [ _CCClassDecorator.property ], Object.getOwnPropertyDescriptor(_class2.prototype, "shadowDarkness"), _class2.prototype), + _applyDecoratedDescriptor(_class2.prototype, "shadowMinDepth", [ _CCClassDecorator.property ], Object.getOwnPropertyDescriptor(_class2.prototype, "shadowMinDepth"), _class2.prototype), + _applyDecoratedDescriptor(_class2.prototype, "shadowMaxDepth", [ _CCClassDecorator.property ], Object.getOwnPropertyDescriptor(_class2.prototype, "shadowMaxDepth"), _class2.prototype), + _applyDecoratedDescriptor(_class2.prototype, "shadowFrustumSize", [ _CCClassDecorator.property ], Object.getOwnPropertyDescriptor(_class2.prototype, "shadowFrustumSize"), _class2.prototype), + _class2)) || _class) || _class) || _class) || _class); + exports["default"] = Light; + cc.Light = Light; + module.exports = exports["default"]; + }), { + "../../renderer/enums": 368, + "../../renderer/scene/light": 394, + "../components/CCComponent": 150, + "../platform/CCClassDecorator": 241, + "../platform/CCEnum": 242, + "../renderer/index": 272, + "../value-types": 340, + "../value-types/color": 339 + } ], + 28: [ (function(require, module, exports) { + "use strict"; + var Model = cc.Class({ + name: "cc.Model", + extends: cc.Asset, + ctor: function ctor() { + this._rootNode = null; + this.loaded = false; + }, + properties: { + _nodes: { + default: [] + }, + _precomputeJointMatrix: false, + nodes: { + get: function get() { + return this._nodes; + } + }, + rootNode: { + get: function get() { + return this._rootNode; + } + }, + precomputeJointMatrix: { + get: function get() { + return this._precomputeJointMatrix; + } + } + }, + onLoad: function onLoad() { + var nodes = this._nodes; + this._rootNode = nodes[0]; + for (var i = 0; i < nodes.length; i++) { + var node = nodes[i]; + node.position = cc.v3.apply(this, node.position); + node.scale = cc.v3.apply(this, node.scale); + node.quat = cc.quat.apply(this, node.quat); + node.uniqueBindPose && (node.uniqueBindPose = cc.mat4.apply(this, node.uniqueBindPose)); + var pose = node.bindpose; + if (pose) for (var _i in pose) pose[_i] = cc.mat4.apply(this, pose[_i]); + var children = node.children; + if (children) for (var _i2 = 0; _i2 < children.length; _i2++) children[_i2] = nodes[children[_i2]]; + } + } + }); + cc.Model = module.exports = Model; + }), {} ], + 29: [ (function(require, module, exports) { + "use strict"; + var _quat = _interopRequireDefault(require("../value-types/quat")); + var _vec = _interopRequireDefault(require("../value-types/vec3")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + var _quat_tmp = cc.quat(); + var _vec3_tmp = cc.v3(); + cc.Rotate3DTo = cc.Class({ + name: "cc.Rotate3DTo", + extends: cc.ActionInterval, + ctor: function ctor(duration, dstAngleX, dstAngleY, dstAngleZ) { + this._startQuat = cc.quat(); + this._dstQuat = cc.quat(); + void 0 !== dstAngleX && this.initWithDuration(duration, dstAngleX, dstAngleY, dstAngleZ); + }, + initWithDuration: function initWithDuration(duration, dstAngleX, dstAngleY, dstAngleZ) { + if (cc.ActionInterval.prototype.initWithDuration.call(this, duration)) { + var dstQuat = this._dstQuat; + if (dstAngleX instanceof cc.Quat) dstQuat.set(dstAngleX); else { + if (dstAngleX instanceof cc.Vec3) { + dstAngleY = dstAngleX.y; + dstAngleZ = dstAngleX.z; + dstAngleX = dstAngleX.x; + } else { + dstAngleY = dstAngleY || 0; + dstAngleZ = dstAngleZ || 0; + } + _quat["default"].fromEuler(dstQuat, dstAngleX, dstAngleY, dstAngleZ); + } + return true; + } + return false; + }, + clone: function clone() { + var action = new cc.Rotate3DTo(); + this._cloneDecoration(action); + action.initWithDuration(this._duration, this._dstQuat); + return action; + }, + startWithTarget: function startWithTarget(target) { + cc.ActionInterval.prototype.startWithTarget.call(this, target); + this._startQuat.set(target.quat); + }, + reverse: function reverse() { + cc.logID(1016); + }, + update: function update(dt) { + dt = this._computeEaseTime(dt); + if (this.target) { + _quat["default"].slerp(_quat_tmp, this._startQuat, this._dstQuat, dt); + this.target.setRotation(_quat_tmp); + } + } + }); + cc.rotate3DTo = function(duration, dstAngleX, dstAngleY, dstAngleZ) { + return new cc.Rotate3DTo(duration, dstAngleX, dstAngleY, dstAngleZ); + }; + cc.Rotate3DBy = cc.Class({ + name: "cc.Rotate3DBy", + extends: cc.ActionInterval, + ctor: function ctor(duration, deltaAngleX, deltaAngleY, deltaAngleZ) { + this._startQuat = cc.quat(); + this._dstQuat = cc.quat(); + this._deltaAngle = cc.v3(); + void 0 !== deltaAngleX && this.initWithDuration(duration, deltaAngleX, deltaAngleY, deltaAngleZ); + }, + initWithDuration: function initWithDuration(duration, deltaAngleX, deltaAngleY, deltaAngleZ) { + if (cc.ActionInterval.prototype.initWithDuration.call(this, duration)) { + if (deltaAngleX instanceof cc.Vec3) { + deltaAngleY = deltaAngleX.y; + deltaAngleZ = deltaAngleX.z; + deltaAngleX = deltaAngleX.x; + } else { + deltaAngleY = deltaAngleY || 0; + deltaAngleZ = deltaAngleZ || 0; + } + _vec["default"].set(this._deltaAngle, deltaAngleX, deltaAngleY, deltaAngleZ); + return true; + } + return false; + }, + clone: function clone() { + var action = new cc.Rotate3DBy(); + this._cloneDecoration(action); + action.initWithDuration(this._duration, this._angle); + return action; + }, + startWithTarget: function startWithTarget(target) { + cc.ActionInterval.prototype.startWithTarget.call(this, target); + var startAngle = target.eulerAngles; + var deltaAngle = this._deltaAngle; + _quat["default"].fromEuler(this._dstQuat, startAngle.x + deltaAngle.x, startAngle.y + deltaAngle.y, startAngle.z + deltaAngle.z); + this._startQuat.set(target.quat); + }, + update: (function() { + var RAD = Math.PI / 180; + return function(dt) { + dt = this._computeEaseTime(dt); + if (this.target) { + _quat["default"].slerp(_quat_tmp, this._startQuat, this._dstQuat, dt); + this.target.setRotation(_quat_tmp); + } + }; + })(), + reverse: function reverse() { + var angle = this._angle; + _vec3_tmp.x = -angle.x; + _vec3_tmp.y = -angle.y; + _vec3_tmp.z = -angle.z; + var action = new cc.Rotate3DBy(this._duration, _vec3_tmp); + this._cloneDecoration(action); + this._reverseEaseList(action); + return action; + } + }); + cc.rotate3DBy = function(duration, deltaAngleX, deltaAngleY, deltaAngleZ) { + return new cc.Rotate3DBy(duration, deltaAngleX, deltaAngleY, deltaAngleZ); + }; + }), { + "../value-types/quat": 343, + "../value-types/vec3": 350 + } ], + 30: [ (function(require, module, exports) { + "use strict"; + true, true; + require("./primitive"); + require("./physics/exports/physics-builtin"); + require("./physics/exports/physics-cannon"); + require("./physics/exports/physics-framework"); + require("./CCModel"); + require("./skeleton/CCSkeleton"); + require("./skeleton/CCSkeletonAnimationClip"); + require("./actions"); + require("./physics/framework/assets/physics-material"); + true; + require("./skeleton/CCSkeletonAnimation"); + require("./skeleton/CCSkinnedMeshRenderer"); + require("./skeleton/skinned-mesh-renderer"); + require("./CCLightComponent"); + require("./particle/particle-system-3d"); + require("./particle/renderer/particle-system-3d-renderer"); + }), { + "./CCLightComponent": 27, + "./CCModel": 28, + "./actions": 29, + "./particle/particle-system-3d": 46, + "./particle/renderer/particle-system-3d-renderer": 49, + "./physics/exports/physics-builtin": void 0, + "./physics/exports/physics-cannon": void 0, + "./physics/exports/physics-framework": void 0, + "./physics/framework/assets/physics-material": void 0, + "./primitive": 56, + "./skeleton/CCSkeleton": 65, + "./skeleton/CCSkeletonAnimation": 66, + "./skeleton/CCSkeletonAnimationClip": 67, + "./skeleton/CCSkinnedMeshRenderer": 68, + "./skeleton/skinned-mesh-renderer": 69 + } ], + 31: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _CCClassDecorator = require("../../../platform/CCClassDecorator"); + var _valueTypes = require("../../../value-types"); + var _gradientRange = _interopRequireDefault(require("./gradient-range")); + var _dec, _dec2, _class, _class2, _descriptor, _descriptor2; + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + 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 + }); + } + 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; + ("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 && void 0 !== desc.initializer) { + desc.value = desc.initializer ? desc.initializer.call(context) : void 0; + desc.initializer = void 0; + } + if (void 0 === desc.initializer) { + Object.defineProperty(target, property, desc); + desc = null; + } + return desc; + } + function _initializerWarningHelper(descriptor, context) { + throw new Error("Decorating class property failed. Please ensure that proposal-class-properties is enabled and runs after the decorators transform."); + } + var COLOR_OVERTIME_RAND_OFFSET = 91041; + var ColorOvertimeModule = (_dec = (0, _CCClassDecorator.ccclass)("cc.ColorOvertimeModule"), + _dec2 = (0, _CCClassDecorator.property)({ + type: _gradientRange["default"] + }), _dec(_class = (_class2 = (function() { + function ColorOvertimeModule() { + _initializerDefineProperty(this, "enable", _descriptor, this); + _initializerDefineProperty(this, "color", _descriptor2, this); + } + var _proto = ColorOvertimeModule.prototype; + _proto.animate = function animate(particle) { + if (this.enable) { + particle.color.set(particle.startColor); + particle.color.multiply(this.color.evaluate(1 - particle.remainingLifetime / particle.startLifetime, (0, + _valueTypes.pseudoRandom)(particle.randomSeed + COLOR_OVERTIME_RAND_OFFSET))); + } + }; + return ColorOvertimeModule; + })(), _descriptor = _applyDecoratedDescriptor(_class2.prototype, "enable", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return false; + } + }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "color", [ _dec2 ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new _gradientRange["default"](); + } + }), _class2)) || _class); + exports["default"] = ColorOvertimeModule; + module.exports = exports["default"]; + }), { + "../../../platform/CCClassDecorator": 241, + "../../../value-types": 340, + "./gradient-range": 34 + } ], + 32: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = exports.Mode = void 0; + var _CCClassDecorator = require("../../../platform/CCClassDecorator"); + var _CCEnum = _interopRequireDefault(require("../../../platform/CCEnum")); + var _valueTypes = require("../../../value-types"); + var _curve = require("../curve"); + var _dec, _dec2, _dec3, _dec4, _dec5, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6, _descriptor7, _descriptor8, _class3, _temp; + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + 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 + }); + } + 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; + ("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 && void 0 !== desc.initializer) { + desc.value = desc.initializer ? desc.initializer.call(context) : void 0; + desc.initializer = void 0; + } + if (void 0 === desc.initializer) { + Object.defineProperty(target, property, desc); + desc = null; + } + return desc; + } + function _initializerWarningHelper(descriptor, context) { + throw new Error("Decorating class property failed. Please ensure that proposal-class-properties is enabled and runs after the decorators transform."); + } + var SerializableTable = false; + var Mode = (0, _CCEnum["default"])({ + Constant: 0, + Curve: 1, + TwoCurves: 2, + TwoConstants: 3 + }); + exports.Mode = Mode; + var CurveRange = (_dec = (0, _CCClassDecorator.ccclass)("cc.CurveRange"), _dec2 = (0, + _CCClassDecorator.property)({ + type: Mode + }), _dec3 = (0, _CCClassDecorator.property)({ + type: _curve.AnimationCurve + }), _dec4 = (0, _CCClassDecorator.property)({ + type: _curve.AnimationCurve + }), _dec5 = (0, _CCClassDecorator.property)({ + type: _curve.AnimationCurve + }), _dec(_class = (_class2 = (_temp = _class3 = (function() { + function CurveRange() { + _initializerDefineProperty(this, "mode", _descriptor, this); + _initializerDefineProperty(this, "curve", _descriptor2, this); + _initializerDefineProperty(this, "curveMin", _descriptor3, this); + _initializerDefineProperty(this, "curveMax", _descriptor4, this); + _initializerDefineProperty(this, "constant", _descriptor5, this); + _initializerDefineProperty(this, "constantMin", _descriptor6, this); + _initializerDefineProperty(this, "constantMax", _descriptor7, this); + _initializerDefineProperty(this, "multiplier", _descriptor8, this); + } + var _proto = CurveRange.prototype; + _proto.evaluate = function evaluate(time, rndRatio) { + switch (this.mode) { + case Mode.Constant: + return this.constant; + + case Mode.Curve: + return this.curve.evaluate(time) * this.multiplier; + + case Mode.TwoCurves: + return (0, _valueTypes.lerp)(this.curveMin.evaluate(time), this.curveMax.evaluate(time), rndRatio) * this.multiplier; + + case Mode.TwoConstants: + return (0, _valueTypes.lerp)(this.constantMin, this.constantMax, rndRatio); + } + }; + _proto.getMax = function getMax() { + switch (this.mode) { + case Mode.Constant: + return this.constant; + + case Mode.Curve: + return this.multiplier; + + case Mode.TwoConstants: + return this.constantMax; + + case Mode.TwoCurves: + return this.multiplier; + } + return 0; + }; + return CurveRange; + })(), _class3.Mode = Mode, _temp), _descriptor = _applyDecoratedDescriptor(_class2.prototype, "mode", [ _dec2 ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return Mode.Constant; + } + }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "curve", [ _dec3 ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new _curve.AnimationCurve(); + } + }), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "curveMin", [ _dec4 ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new _curve.AnimationCurve(); + } + }), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "curveMax", [ _dec5 ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new _curve.AnimationCurve(); + } + }), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, "constant", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return 0; + } + }), _descriptor6 = _applyDecoratedDescriptor(_class2.prototype, "constantMin", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return 0; + } + }), _descriptor7 = _applyDecoratedDescriptor(_class2.prototype, "constantMax", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return 0; + } + }), _descriptor8 = _applyDecoratedDescriptor(_class2.prototype, "multiplier", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return 1; + } + }), _class2)) || _class); + exports["default"] = CurveRange; + false; + cc.CurveRange = CurveRange; + }), { + "../../../platform/CCClassDecorator": 241, + "../../../platform/CCEnum": 242, + "../../../value-types": 340, + "../curve": 42 + } ], + 33: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _CCClassDecorator = require("../../../platform/CCClassDecorator"); + var _valueTypes = require("../../../value-types"); + var _enum = require("../enum"); + var _particleGeneralFunction = require("../particle-general-function"); + var _curveRange = _interopRequireDefault(require("./curve-range")); + var _dec, _dec2, _dec3, _dec4, _dec5, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5; + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + 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 + }); + } + 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; + ("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 && void 0 !== desc.initializer) { + desc.value = desc.initializer ? desc.initializer.call(context) : void 0; + desc.initializer = void 0; + } + if (void 0 === desc.initializer) { + Object.defineProperty(target, property, desc); + desc = null; + } + return desc; + } + function _initializerWarningHelper(descriptor, context) { + throw new Error("Decorating class property failed. Please ensure that proposal-class-properties is enabled and runs after the decorators transform."); + } + var FORCE_OVERTIME_RAND_OFFSET = 212165; + var _temp_v3 = cc.v3(); + var ForceOvertimeModule = (_dec = (0, _CCClassDecorator.ccclass)("cc.ForceOvertimeModule"), + _dec2 = (0, _CCClassDecorator.property)({ + type: _enum.Space + }), _dec3 = (0, _CCClassDecorator.property)({ + type: _curveRange["default"], + range: [ -1, 1 ] + }), _dec4 = (0, _CCClassDecorator.property)({ + type: _curveRange["default"], + range: [ -1, 1 ] + }), _dec5 = (0, _CCClassDecorator.property)({ + type: _curveRange["default"], + range: [ -1, 1 ], + displayOrder: 4 + }), _dec(_class = (_class2 = (function() { + function ForceOvertimeModule() { + _initializerDefineProperty(this, "enable", _descriptor, this); + _initializerDefineProperty(this, "space", _descriptor2, this); + _initializerDefineProperty(this, "x", _descriptor3, this); + _initializerDefineProperty(this, "y", _descriptor4, this); + _initializerDefineProperty(this, "z", _descriptor5, this); + this.randomized = false; + this.rotation = null; + this.needTransform = false; + this.rotation = new _valueTypes.Quat(); + this.needTransform = false; + } + var _proto = ForceOvertimeModule.prototype; + _proto.update = function update(space, worldTransform) { + this.needTransform = (0, _particleGeneralFunction.calculateTransform)(space, this.space, worldTransform, this.rotation); + }; + _proto.animate = function animate(p, dt) { + var normalizedTime = 1 - p.remainingLifetime / p.startLifetime; + var force = _valueTypes.Vec3.set(_temp_v3, this.x.evaluate(normalizedTime, (0, _valueTypes.pseudoRandom)(p.randomSeed + FORCE_OVERTIME_RAND_OFFSET)), this.y.evaluate(normalizedTime, (0, + _valueTypes.pseudoRandom)(p.randomSeed + FORCE_OVERTIME_RAND_OFFSET)), this.z.evaluate(normalizedTime, (0, + _valueTypes.pseudoRandom)(p.randomSeed + FORCE_OVERTIME_RAND_OFFSET))); + this.needTransform && _valueTypes.Vec3.transformQuat(force, force, this.rotation); + _valueTypes.Vec3.scaleAndAdd(p.velocity, p.velocity, force, dt); + }; + return ForceOvertimeModule; + })(), _descriptor = _applyDecoratedDescriptor(_class2.prototype, "enable", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return false; + } + }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "space", [ _dec2 ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return _enum.Space.Local; + } + }), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "x", [ _dec3 ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new _curveRange["default"](); + } + }), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "y", [ _dec4 ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new _curveRange["default"](); + } + }), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, "z", [ _dec5 ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new _curveRange["default"](); + } + }), _class2)) || _class); + exports["default"] = ForceOvertimeModule; + module.exports = exports["default"]; + }), { + "../../../platform/CCClassDecorator": 241, + "../../../value-types": 340, + "../enum": 44, + "../particle-general-function": 45, + "./curve-range": 32 + } ], + 34: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _CCClassDecorator = require("../../../platform/CCClassDecorator"); + var _CCEnum = _interopRequireDefault(require("../../../platform/CCEnum")); + var _gradient = require("./gradient"); + var _dec, _dec2, _dec3, _dec4, _dec5, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6, _descriptor7, _descriptor8, _class3, _temp; + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + 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 + }); + } + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + "value" in descriptor && (descriptor.writable = true); + Object.defineProperty(target, descriptor.key, descriptor); + } + } + function _createClass(Constructor, protoProps, staticProps) { + protoProps && _defineProperties(Constructor.prototype, protoProps); + staticProps && _defineProperties(Constructor, staticProps); + return Constructor; + } + 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; + ("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 && void 0 !== desc.initializer) { + desc.value = desc.initializer ? desc.initializer.call(context) : void 0; + desc.initializer = void 0; + } + if (void 0 === desc.initializer) { + Object.defineProperty(target, property, desc); + desc = null; + } + return desc; + } + function _initializerWarningHelper(descriptor, context) { + throw new Error("Decorating class property failed. Please ensure that proposal-class-properties is enabled and runs after the decorators transform."); + } + var GRADIENT_MODE_FIX = 0; + var GRADIENT_MODE_BLEND = 1; + var GRADIENT_RANGE_MODE_COLOR = 0; + var GRADIENT_RANGE_MODE_TWO_COLOR = 1; + var GRADIENT_RANGE_MODE_RANDOM_COLOR = 2; + var GRADIENT_RANGE_MODE_GRADIENT = 3; + var GRADIENT_RANGE_MODE_TWO_GRADIENT = 4; + var SerializableTable = false; + var Mode = (0, _CCEnum["default"])({ + Color: 0, + Gradient: 1, + TwoColors: 2, + TwoGradients: 3, + RandomColor: 4 + }); + var GradientRange = (_dec = (0, _CCClassDecorator.ccclass)("cc.GradientRange"), + _dec2 = (0, _CCClassDecorator.property)({ + type: Mode + }), _dec3 = (0, _CCClassDecorator.property)({ + type: _gradient.Gradient + }), _dec4 = (0, _CCClassDecorator.property)({ + type: _gradient.Gradient + }), _dec5 = (0, _CCClassDecorator.property)({ + type: _gradient.Gradient + }), _dec(_class = (_class2 = (_temp = _class3 = (function() { + function GradientRange() { + _initializerDefineProperty(this, "_mode", _descriptor, this); + _initializerDefineProperty(this, "_color", _descriptor2, this); + _initializerDefineProperty(this, "color", _descriptor3, this); + _initializerDefineProperty(this, "colorMin", _descriptor4, this); + _initializerDefineProperty(this, "colorMax", _descriptor5, this); + _initializerDefineProperty(this, "gradient", _descriptor6, this); + _initializerDefineProperty(this, "gradientMin", _descriptor7, this); + _initializerDefineProperty(this, "gradientMax", _descriptor8, this); + } + var _proto = GradientRange.prototype; + _proto.evaluate = function evaluate(time, rndRatio) { + switch (this._mode) { + case Mode.Color: + return this.color; + + case Mode.TwoColors: + this.colorMin.lerp(this.colorMax, rndRatio, this._color); + return this._color; + + case Mode.RandomColor: + return this.gradient.randomColor(); + + case Mode.Gradient: + return this.gradient.evaluate(time); + + case Mode.TwoGradients: + this.gradientMin.evaluate(time).lerp(this.gradientMax.evaluate(time), rndRatio, this._color); + return this._color; + + default: + return this.color; + } + }; + _createClass(GradientRange, [ { + key: "mode", + get: function get() { + return this._mode; + }, + set: function set(m) { + false; + this._mode = m; + } + } ]); + return GradientRange; + })(), _class3.Mode = Mode, _temp), _descriptor = _applyDecoratedDescriptor(_class2.prototype, "_mode", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return Mode.Color; + } + }), _applyDecoratedDescriptor(_class2.prototype, "mode", [ _dec2 ], Object.getOwnPropertyDescriptor(_class2.prototype, "mode"), _class2.prototype), + _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "_color", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return cc.Color.WHITE.clone(); + } + }), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "color", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return cc.Color.WHITE.clone(); + } + }), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "colorMin", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return cc.Color.WHITE.clone(); + } + }), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, "colorMax", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return cc.Color.WHITE.clone(); + } + }), _descriptor6 = _applyDecoratedDescriptor(_class2.prototype, "gradient", [ _dec3 ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new _gradient.Gradient(); + } + }), _descriptor7 = _applyDecoratedDescriptor(_class2.prototype, "gradientMin", [ _dec4 ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new _gradient.Gradient(); + } + }), _descriptor8 = _applyDecoratedDescriptor(_class2.prototype, "gradientMax", [ _dec5 ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new _gradient.Gradient(); + } + }), _class2)) || _class); + exports["default"] = GradientRange; + false; + cc.GradientRange = GradientRange; + module.exports = exports["default"]; + }), { + "../../../platform/CCClassDecorator": 241, + "../../../platform/CCEnum": 242, + "./gradient": 35 + } ], + 35: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports.Gradient = exports.ColorKey = exports.AlphaKey = void 0; + var _CCClassDecorator = require("../../../platform/CCClassDecorator"); + var _CCEnum = _interopRequireDefault(require("../../../platform/CCEnum")); + var _valueTypes = require("../../../value-types"); + var _dec, _class, _class2, _descriptor, _descriptor2, _dec2, _class4, _class5, _descriptor3, _descriptor4, _dec3, _dec4, _dec5, _dec6, _class7, _class8, _descriptor5, _descriptor6, _descriptor7, _class9, _temp; + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + 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 + }); + } + 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; + ("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 && void 0 !== desc.initializer) { + desc.value = desc.initializer ? desc.initializer.call(context) : void 0; + desc.initializer = void 0; + } + if (void 0 === desc.initializer) { + Object.defineProperty(target, property, desc); + desc = null; + } + return desc; + } + function _initializerWarningHelper(descriptor, context) { + throw new Error("Decorating class property failed. Please ensure that proposal-class-properties is enabled and runs after the decorators transform."); + } + var Mode = (0, _CCEnum["default"])({ + Blend: 0, + Fixed: 1 + }); + var ColorKey = (_dec = (0, _CCClassDecorator.ccclass)("cc.ColorKey"), _dec(_class = (_class2 = function ColorKey() { + _initializerDefineProperty(this, "color", _descriptor, this); + _initializerDefineProperty(this, "time", _descriptor2, this); + }, _descriptor = _applyDecoratedDescriptor(_class2.prototype, "color", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return cc.Color.WHITE.clone(); + } + }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "time", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return 0; + } + }), _class2)) || _class); + exports.ColorKey = ColorKey; + var AlphaKey = (_dec2 = (0, _CCClassDecorator.ccclass)("cc.AlphaKey"), _dec2(_class4 = (_class5 = function AlphaKey() { + _initializerDefineProperty(this, "alpha", _descriptor3, this); + _initializerDefineProperty(this, "time", _descriptor4, this); + }, _descriptor3 = _applyDecoratedDescriptor(_class5.prototype, "alpha", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return 1; + } + }), _descriptor4 = _applyDecoratedDescriptor(_class5.prototype, "time", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return 0; + } + }), _class5)) || _class4); + exports.AlphaKey = AlphaKey; + var Gradient = (_dec3 = (0, _CCClassDecorator.ccclass)("cc.Gradient"), _dec4 = (0, + _CCClassDecorator.property)({ + type: [ ColorKey ] + }), _dec5 = (0, _CCClassDecorator.property)({ + type: [ AlphaKey ] + }), _dec6 = (0, _CCClassDecorator.property)({ + type: Mode + }), _dec3(_class7 = (_class8 = (_temp = _class9 = (function() { + function Gradient() { + _initializerDefineProperty(this, "colorKeys", _descriptor5, this); + _initializerDefineProperty(this, "alphaKeys", _descriptor6, this); + _initializerDefineProperty(this, "mode", _descriptor7, this); + this._color = null; + this._color = cc.Color.WHITE.clone(); + } + var _proto = Gradient.prototype; + _proto.setKeys = function setKeys(colorKeys, alphaKeys) { + this.colorKeys = colorKeys; + this.alphaKeys = alphaKeys; + }; + _proto.sortKeys = function sortKeys() { + this.colorKeys.length > 1 && this.colorKeys.sort((function(a, b) { + return a.time - b.time; + })); + this.alphaKeys.length > 1 && this.alphaKeys.sort((function(a, b) { + return a.time - b.time; + })); + }; + _proto.evaluate = function evaluate(time) { + this.getRGB(time); + this._color._fastSetA(this.getAlpha(time)); + return this._color; + }; + _proto.randomColor = function randomColor() { + var c = this.colorKeys[Math.trunc(Math.random() * this.colorKeys.length)]; + var a = this.alphaKeys[Math.trunc(Math.random() * this.alphaKeys.length)]; + this._color.set(c.color); + this._color._fastSetA(a.alpha); + return this._color; + }; + _proto.getRGB = function getRGB(time) { + if (!(this.colorKeys.length > 1)) { + if (1 === this.colorKeys.length) { + this._color.set(this.colorKeys[0].color); + return this._color; + } + this._color.set(cc.Color.WHITE); + return this._color; + } + time = (0, _valueTypes.repeat)(time, 1); + for (var i = 1; i < this.colorKeys.length; ++i) { + var preTime = this.colorKeys[i - 1].time; + var curTime = this.colorKeys[i].time; + if (time >= preTime && time < curTime) { + if (this.mode === Mode.Fixed) return this.colorKeys[i].color; + var factor = (time - preTime) / (curTime - preTime); + this.colorKeys[i - 1].color.lerp(this.colorKeys[i].color, factor, this._color); + return this._color; + } + } + var lastIndex = this.colorKeys.length - 1; + time < this.colorKeys[0].time ? cc.Color.BLACK.lerp(this.colorKeys[0].color, time / this.colorKeys[0].time, this._color) : time > this.colorKeys[lastIndex].time && this.colorKeys[lastIndex].color.lerp(cc.Color.BLACK, (time - this.colorKeys[lastIndex].time) / (1 - this.colorKeys[lastIndex].time), this._color); + }; + _proto.getAlpha = function getAlpha(time) { + if (!(this.alphaKeys.length > 1)) return 1 === this.alphaKeys.length ? this.alphaKeys[0].alpha : 255; + time = (0, _valueTypes.repeat)(time, 1); + for (var i = 1; i < this.alphaKeys.length; ++i) { + var preTime = this.alphaKeys[i - 1].time; + var curTime = this.alphaKeys[i].time; + if (time >= preTime && time < curTime) { + if (this.mode === Mode.Fixed) return this.alphaKeys[i].alpha; + var factor = (time - preTime) / (curTime - preTime); + return (0, _valueTypes.lerp)(this.alphaKeys[i - 1].alpha, this.alphaKeys[i].alpha, factor); + } + } + var lastIndex = this.alphaKeys.length - 1; + if (time < this.alphaKeys[0].time) return (0, _valueTypes.lerp)(255, this.alphaKeys[0].alpha, time / this.alphaKeys[0].time); + if (time > this.alphaKeys[lastIndex].time) return (0, _valueTypes.lerp)(this.alphaKeys[lastIndex].alpha, 255, (time - this.alphaKeys[lastIndex].time) / (1 - this.alphaKeys[lastIndex].time)); + }; + return Gradient; + })(), _class9.Mode = Mode, _temp), _descriptor5 = _applyDecoratedDescriptor(_class8.prototype, "colorKeys", [ _dec4 ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new Array(); + } + }), _descriptor6 = _applyDecoratedDescriptor(_class8.prototype, "alphaKeys", [ _dec5 ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new Array(); + } + }), _descriptor7 = _applyDecoratedDescriptor(_class8.prototype, "mode", [ _dec6 ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return Mode.Blend; + } + }), _class8)) || _class7); + exports.Gradient = Gradient; + cc.ColorKey = ColorKey; + cc.AlphaKey = AlphaKey; + cc.Gradient = Gradient; + }), { + "../../../platform/CCClassDecorator": 241, + "../../../platform/CCEnum": 242, + "../../../value-types": 340 + } ], + 36: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _CCClassDecorator = require("../../../platform/CCClassDecorator"); + var _valueTypes = require("../../../value-types"); + var _enum = require("../enum"); + var _curveRange = _interopRequireDefault(require("./curve-range")); + var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6, _descriptor7, _descriptor8; + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + 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 + }); + } + 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; + ("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 && void 0 !== desc.initializer) { + desc.value = desc.initializer ? desc.initializer.call(context) : void 0; + desc.initializer = void 0; + } + if (void 0 === desc.initializer) { + Object.defineProperty(target, property, desc); + desc = null; + } + return desc; + } + function _initializerWarningHelper(descriptor, context) { + throw new Error("Decorating class property failed. Please ensure that proposal-class-properties is enabled and runs after the decorators transform."); + } + var LIMIT_VELOCITY_RAND_OFFSET = 23541; + var _temp_v3 = cc.v3(); + var _temp_v3_1 = cc.v3(); + function dampenBeyondLimit(vel, limit, dampen) { + var sgn = Math.sign(vel); + var abs = Math.abs(vel); + abs > limit && (abs = (0, _valueTypes.lerp)(abs, limit, dampen)); + return abs * sgn; + } + var LimitVelocityOvertimeModule = (_dec = (0, _CCClassDecorator.ccclass)("cc.LimitVelocityOvertimeModule"), + _dec2 = (0, _CCClassDecorator.property)({ + type: _enum.Space + }), _dec3 = (0, _CCClassDecorator.property)({ + type: _curveRange["default"], + range: [ -1, 1 ], + visible: function visible() { + return !this.separateAxes; + } + }), _dec4 = (0, _CCClassDecorator.property)({ + type: _curveRange["default"], + range: [ -1, 1 ], + visible: function visible() { + return this.separateAxes; + } + }), _dec5 = (0, _CCClassDecorator.property)({ + type: _curveRange["default"], + range: [ -1, 1 ], + visible: function visible() { + return this.separateAxes; + } + }), _dec6 = (0, _CCClassDecorator.property)({ + type: _curveRange["default"], + range: [ -1, 1 ], + visible: function visible() { + return this.separateAxes; + } + }), _dec(_class = (_class2 = (function() { + function LimitVelocityOvertimeModule() { + _initializerDefineProperty(this, "enable", _descriptor, this); + _initializerDefineProperty(this, "space", _descriptor2, this); + _initializerDefineProperty(this, "separateAxes", _descriptor3, this); + _initializerDefineProperty(this, "limit", _descriptor4, this); + _initializerDefineProperty(this, "limitX", _descriptor5, this); + _initializerDefineProperty(this, "limitY", _descriptor6, this); + _initializerDefineProperty(this, "limitZ", _descriptor7, this); + _initializerDefineProperty(this, "dampen", _descriptor8, this); + this.drag = null; + this.multiplyDragByParticleSize = false; + this.multiplyDragByParticleVelocity = false; + this.rotation = null; + this.needTransform = false; + this.rotation = new _valueTypes.Quat(); + this.needTransform = false; + } + var _proto = LimitVelocityOvertimeModule.prototype; + _proto.update = function update(space, worldTransform) { + this.needTransform = calculateTransform(space, this.space, worldTransform, this.rotation); + }; + _proto.animate = function animate(p) { + var normalizedTime = 1 - p.remainingLifetime / p.startLifetime; + var dampedVel = _temp_v3; + if (this.separateAxes) { + _valueTypes.Vec3.set(_temp_v3_1, this.limitX.evaluate(normalizedTime, (0, _valueTypes.pseudoRandom)(p.randomSeed + LIMIT_VELOCITY_RAND_OFFSET)), this.limitY.evaluate(normalizedTime, (0, + _valueTypes.pseudoRandom)(p.randomSeed + LIMIT_VELOCITY_RAND_OFFSET)), this.limitZ.evaluate(normalizedTime, (0, + _valueTypes.pseudoRandom)(p.randomSeed + LIMIT_VELOCITY_RAND_OFFSET))); + this.needTransform && _valueTypes.Vec3.transformQuat(_temp_v3_1, _temp_v3_1, this.rotation); + _valueTypes.Vec3.set(dampedVel, dampenBeyondLimit(p.ultimateVelocity.x, _temp_v3_1.x, this.dampen), dampenBeyondLimit(p.ultimateVelocity.y, _temp_v3_1.y, this.dampen), dampenBeyondLimit(p.ultimateVelocity.z, _temp_v3_1.z, this.dampen)); + } else { + _valueTypes.Vec3.normalize(dampedVel, p.ultimateVelocity); + _valueTypes.Vec3.scale(dampedVel, dampedVel, dampenBeyondLimit(p.ultimateVelocity.len(), this.limit.evaluate(normalizedTime, (0, + _valueTypes.pseudoRandom)(p.randomSeed + LIMIT_VELOCITY_RAND_OFFSET)), this.dampen)); + } + _valueTypes.Vec3.copy(p.ultimateVelocity, dampedVel); + }; + return LimitVelocityOvertimeModule; + })(), _descriptor = _applyDecoratedDescriptor(_class2.prototype, "enable", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return false; + } + }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "space", [ _dec2 ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return _enum.Space.Local; + } + }), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "separateAxes", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return false; + } + }), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "limit", [ _dec3 ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new _curveRange["default"](); + } + }), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, "limitX", [ _dec4 ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new _curveRange["default"](); + } + }), _descriptor6 = _applyDecoratedDescriptor(_class2.prototype, "limitY", [ _dec5 ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new _curveRange["default"](); + } + }), _descriptor7 = _applyDecoratedDescriptor(_class2.prototype, "limitZ", [ _dec6 ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new _curveRange["default"](); + } + }), _descriptor8 = _applyDecoratedDescriptor(_class2.prototype, "dampen", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return 3; + } + }), _class2)) || _class); + exports["default"] = LimitVelocityOvertimeModule; + module.exports = exports["default"]; + }), { + "../../../platform/CCClassDecorator": 241, + "../../../value-types": 340, + "../enum": 44, + "./curve-range": 32 + } ], + 37: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _CCClassDecorator = require("../../../platform/CCClassDecorator"); + var _valueTypes = require("../../../value-types"); + var _curveRange = _interopRequireDefault(require("./curve-range")); + var _dec, _dec2, _dec3, _dec4, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5; + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + 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 + }); + } + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + "value" in descriptor && (descriptor.writable = true); + Object.defineProperty(target, descriptor.key, descriptor); + } + } + function _createClass(Constructor, protoProps, staticProps) { + protoProps && _defineProperties(Constructor.prototype, protoProps); + staticProps && _defineProperties(Constructor, staticProps); + return Constructor; + } + 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; + ("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 && void 0 !== desc.initializer) { + desc.value = desc.initializer ? desc.initializer.call(context) : void 0; + desc.initializer = void 0; + } + if (void 0 === desc.initializer) { + Object.defineProperty(target, property, desc); + desc = null; + } + return desc; + } + function _initializerWarningHelper(descriptor, context) { + throw new Error("Decorating class property failed. Please ensure that proposal-class-properties is enabled and runs after the decorators transform."); + } + var ROTATION_OVERTIME_RAND_OFFSET = 125292; + var RotationOvertimeModule = (_dec = (0, _CCClassDecorator.ccclass)("cc.RotationOvertimeModule"), + _dec2 = (0, _CCClassDecorator.property)({ + type: _curveRange["default"], + range: [ -1, 1 ], + radian: true, + visible: function visible() { + return this._separateAxes; + } + }), _dec3 = (0, _CCClassDecorator.property)({ + type: _curveRange["default"], + range: [ -1, 1 ], + radian: true, + visible: function visible() { + return this._separateAxes; + } + }), _dec4 = (0, _CCClassDecorator.property)({ + type: _curveRange["default"], + range: [ -1, 1 ], + radian: true + }), _dec(_class = (_class2 = (function() { + function RotationOvertimeModule() { + _initializerDefineProperty(this, "enable", _descriptor, this); + _initializerDefineProperty(this, "_separateAxes", _descriptor2, this); + _initializerDefineProperty(this, "x", _descriptor3, this); + _initializerDefineProperty(this, "y", _descriptor4, this); + _initializerDefineProperty(this, "z", _descriptor5, this); + } + var _proto = RotationOvertimeModule.prototype; + _proto.animate = function animate(p, dt) { + var normalizedTime = 1 - p.remainingLifetime / p.startLifetime; + if (this._separateAxes) { + var rotationRand = (0, _valueTypes.pseudoRandom)(p.randomSeed + ROTATION_OVERTIME_RAND_OFFSET); + p.rotation.x += this.x.evaluate(normalizedTime, rotationRand) * dt; + p.rotation.y += this.y.evaluate(normalizedTime, rotationRand) * dt; + p.rotation.z += this.z.evaluate(normalizedTime, rotationRand) * dt; + } else p.rotation.x += this.z.evaluate(normalizedTime, (0, _valueTypes.pseudoRandom)(p.randomSeed + ROTATION_OVERTIME_RAND_OFFSET)) * dt; + }; + _createClass(RotationOvertimeModule, [ { + key: "separateAxes", + get: function get() { + return this._separateAxes; + }, + set: function set(val) { + this._separateAxes = val; + } + } ]); + return RotationOvertimeModule; + })(), _descriptor = _applyDecoratedDescriptor(_class2.prototype, "enable", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return false; + } + }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "_separateAxes", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return false; + } + }), _applyDecoratedDescriptor(_class2.prototype, "separateAxes", [ _CCClassDecorator.property ], Object.getOwnPropertyDescriptor(_class2.prototype, "separateAxes"), _class2.prototype), + _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "x", [ _dec2 ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new _curveRange["default"](); + } + }), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "y", [ _dec3 ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new _curveRange["default"](); + } + }), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, "z", [ _dec4 ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new _curveRange["default"](); + } + }), _class2)) || _class); + exports["default"] = RotationOvertimeModule; + module.exports = exports["default"]; + }), { + "../../../platform/CCClassDecorator": 241, + "../../../value-types": 340, + "./curve-range": 32 + } ], + 38: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _CCClassDecorator = require("../../../platform/CCClassDecorator"); + var _valueTypes = require("../../../value-types"); + var _curveRange = _interopRequireDefault(require("./curve-range")); + var _dec, _dec2, _dec3, _dec4, _dec5, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6; + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + 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 + }); + } + 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; + ("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 && void 0 !== desc.initializer) { + desc.value = desc.initializer ? desc.initializer.call(context) : void 0; + desc.initializer = void 0; + } + if (void 0 === desc.initializer) { + Object.defineProperty(target, property, desc); + desc = null; + } + return desc; + } + function _initializerWarningHelper(descriptor, context) { + throw new Error("Decorating class property failed. Please ensure that proposal-class-properties is enabled and runs after the decorators transform."); + } + var SIZE_OVERTIME_RAND_OFFSET = 39825; + var SizeOvertimeModule = (_dec = (0, _CCClassDecorator.ccclass)("cc.SizeOvertimeModule"), + _dec2 = (0, _CCClassDecorator.property)({ + type: _curveRange["default"], + visible: function visible() { + return !this.separateAxes; + } + }), _dec3 = (0, _CCClassDecorator.property)({ + type: _curveRange["default"], + visible: function visible() { + return this.separateAxes; + } + }), _dec4 = (0, _CCClassDecorator.property)({ + type: _curveRange["default"], + visible: function visible() { + return this.separateAxes; + } + }), _dec5 = (0, _CCClassDecorator.property)({ + type: _curveRange["default"], + visible: function visible() { + return this.separateAxes; + } + }), _dec(_class = (_class2 = (function() { + function SizeOvertimeModule() { + _initializerDefineProperty(this, "enable", _descriptor, this); + _initializerDefineProperty(this, "separateAxes", _descriptor2, this); + _initializerDefineProperty(this, "size", _descriptor3, this); + _initializerDefineProperty(this, "x", _descriptor4, this); + _initializerDefineProperty(this, "y", _descriptor5, this); + _initializerDefineProperty(this, "z", _descriptor6, this); + } + var _proto = SizeOvertimeModule.prototype; + _proto.animate = function animate(particle) { + if (this.separateAxes) { + var currLifetime = 1 - particle.remainingLifetime / particle.startLifetime; + var sizeRand = (0, _valueTypes.pseudoRandom)(particle.randomSeed + SIZE_OVERTIME_RAND_OFFSET); + particle.size.x = particle.startSize.x * this.x.evaluate(currLifetime, sizeRand); + particle.size.y = particle.startSize.y * this.y.evaluate(currLifetime, sizeRand); + particle.size.z = particle.startSize.z * this.z.evaluate(currLifetime, sizeRand); + } else _valueTypes.Vec3.scale(particle.size, particle.startSize, this.size.evaluate(1 - particle.remainingLifetime / particle.startLifetime, (0, + _valueTypes.pseudoRandom)(particle.randomSeed + SIZE_OVERTIME_RAND_OFFSET))); + }; + return SizeOvertimeModule; + })(), _descriptor = _applyDecoratedDescriptor(_class2.prototype, "enable", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return false; + } + }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "separateAxes", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return false; + } + }), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "size", [ _dec2 ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new _curveRange["default"](); + } + }), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "x", [ _dec3 ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new _curveRange["default"](); + } + }), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, "y", [ _dec4 ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new _curveRange["default"](); + } + }), _descriptor6 = _applyDecoratedDescriptor(_class2.prototype, "z", [ _dec5 ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new _curveRange["default"](); + } + }), _class2)) || _class); + exports["default"] = SizeOvertimeModule; + module.exports = exports["default"]; + }), { + "../../../platform/CCClassDecorator": 241, + "../../../value-types": 340, + "./curve-range": 32 + } ], + 39: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _CCClassDecorator = require("../../../platform/CCClassDecorator"); + var _CCEnum = _interopRequireDefault(require("../../../platform/CCEnum")); + var _valueTypes = require("../../../value-types"); + var _curveRange = _interopRequireDefault(require("./curve-range")); + var _dec, _dec2, _dec3, _dec4, _dec5, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6, _descriptor7, _descriptor8, _descriptor9, _descriptor10; + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + 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 + }); + } + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + "value" in descriptor && (descriptor.writable = true); + Object.defineProperty(target, descriptor.key, descriptor); + } + } + function _createClass(Constructor, protoProps, staticProps) { + protoProps && _defineProperties(Constructor.prototype, protoProps); + staticProps && _defineProperties(Constructor, staticProps); + return Constructor; + } + 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; + ("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 && void 0 !== desc.initializer) { + desc.value = desc.initializer ? desc.initializer.call(context) : void 0; + desc.initializer = void 0; + } + if (void 0 === desc.initializer) { + Object.defineProperty(target, property, desc); + desc = null; + } + return desc; + } + function _initializerWarningHelper(descriptor, context) { + throw new Error("Decorating class property failed. Please ensure that proposal-class-properties is enabled and runs after the decorators transform."); + } + var TEXTURE_ANIMATION_RAND_OFFSET = 90794; + var Mode = (0, _CCEnum["default"])({ + Grid: 0 + }); + var Animation = (0, _CCEnum["default"])({ + WholeSheet: 0, + SingleRow: 1 + }); + var TextureAnimationModule = (_dec = (0, _CCClassDecorator.ccclass)("cc.TextureAnimationModule"), + _dec2 = (0, _CCClassDecorator.property)({ + type: Mode + }), _dec3 = (0, _CCClassDecorator.property)({ + type: Animation + }), _dec4 = (0, _CCClassDecorator.property)({ + type: _curveRange["default"] + }), _dec5 = (0, _CCClassDecorator.property)({ + type: _curveRange["default"] + }), _dec(_class = (_class2 = (function() { + function TextureAnimationModule() { + _initializerDefineProperty(this, "_enable", _descriptor, this); + _initializerDefineProperty(this, "_mode", _descriptor2, this); + _initializerDefineProperty(this, "_numTilesX", _descriptor3, this); + _initializerDefineProperty(this, "_numTilesY", _descriptor4, this); + _initializerDefineProperty(this, "animation", _descriptor5, this); + _initializerDefineProperty(this, "randomRow", _descriptor6, this); + _initializerDefineProperty(this, "rowIndex", _descriptor7, this); + _initializerDefineProperty(this, "frameOverTime", _descriptor8, this); + _initializerDefineProperty(this, "startFrame", _descriptor9, this); + _initializerDefineProperty(this, "cycleCount", _descriptor10, this); + this._flipU = 0; + this._flipV = 0; + this._uvChannelMask = -1; + this.ps = null; + } + var _proto = TextureAnimationModule.prototype; + _proto.onInit = function onInit(ps) { + this.ps = ps; + }; + _proto.init = function init(p) { + p.startRow = Math.floor(Math.random() * this.numTilesY); + }; + _proto.animate = function animate(p) { + var normalizedTime = 1 - p.remainingLifetime / p.startLifetime; + var startFrame = this.startFrame.evaluate(normalizedTime, (0, _valueTypes.pseudoRandom)(p.randomSeed + TEXTURE_ANIMATION_RAND_OFFSET)) / (this.numTilesX * this.numTilesY); + if (this.animation === Animation.WholeSheet) p.frameIndex = (0, _valueTypes.repeat)(this.cycleCount * (this.frameOverTime.evaluate(normalizedTime, (0, + _valueTypes.pseudoRandom)(p.randomSeed + TEXTURE_ANIMATION_RAND_OFFSET)) + startFrame), 1); else if (this.animation === Animation.SingleRow) { + var rowLength = 1 / this.numTilesY; + if (this.randomRow) { + var f = (0, _valueTypes.repeat)(this.cycleCount * (this.frameOverTime.evaluate(normalizedTime, (0, + _valueTypes.pseudoRandom)(p.randomSeed + TEXTURE_ANIMATION_RAND_OFFSET)) + startFrame), 1); + var from = p.startRow * rowLength; + var to = from + rowLength; + p.frameIndex = (0, _valueTypes.lerp)(from, to, f); + } else { + var _from = this.rowIndex * rowLength; + var _to = _from + rowLength; + p.frameIndex = (0, _valueTypes.lerp)(_from, _to, (0, _valueTypes.repeat)(this.cycleCount * (this.frameOverTime.evaluate(normalizedTime, (0, + _valueTypes.pseudoRandom)(p.randomSeed + TEXTURE_ANIMATION_RAND_OFFSET)) + startFrame), 1)); + } + } + }; + _createClass(TextureAnimationModule, [ { + key: "enable", + get: function get() { + return this._enable; + }, + set: function set(val) { + this._enable = val; + this.ps._assembler._updateMaterialParams(); + } + }, { + key: "mode", + get: function get() { + return this._mode; + }, + set: function set(val) { + if (val !== Mode.Grid) { + console.error("particle texture animation's sprites is not supported!"); + return; + } + } + }, { + key: "numTilesX", + get: function get() { + return this._numTilesX; + }, + set: function set(val) { + if (this._numTilesX === val) return; + this._numTilesX = val; + this.ps && this.ps._assembler && this.ps._assembler._updateMaterialParams(); + } + }, { + key: "numTilesY", + get: function get() { + return this._numTilesY; + }, + set: function set(val) { + if (this._numTilesY === val) return; + this._numTilesY = val; + this.ps && this.ps._assembler && this.ps._assembler._updateMaterialParams(); + } + }, { + key: "flipU", + get: function get() { + return this._flipU; + }, + set: function set(val) { + console.error("particle texture animation's flipU is not supported!"); + } + }, { + key: "flipV", + get: function get() { + return this._flipV; + }, + set: function set(val) { + console.error("particle texture animation's flipV is not supported!"); + } + }, { + key: "uvChannelMask", + get: function get() { + return this._uvChannelMask; + }, + set: function set(val) { + console.error("particle texture animation's uvChannelMask is not supported!"); + } + } ]); + return TextureAnimationModule; + })(), _descriptor = _applyDecoratedDescriptor(_class2.prototype, "_enable", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return false; + } + }), _applyDecoratedDescriptor(_class2.prototype, "enable", [ _CCClassDecorator.property ], Object.getOwnPropertyDescriptor(_class2.prototype, "enable"), _class2.prototype), + _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "_mode", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return Mode.Grid; + } + }), _applyDecoratedDescriptor(_class2.prototype, "mode", [ _dec2 ], Object.getOwnPropertyDescriptor(_class2.prototype, "mode"), _class2.prototype), + _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "_numTilesX", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return 0; + } + }), _applyDecoratedDescriptor(_class2.prototype, "numTilesX", [ _CCClassDecorator.property ], Object.getOwnPropertyDescriptor(_class2.prototype, "numTilesX"), _class2.prototype), + _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "_numTilesY", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return 0; + } + }), _applyDecoratedDescriptor(_class2.prototype, "numTilesY", [ _CCClassDecorator.property ], Object.getOwnPropertyDescriptor(_class2.prototype, "numTilesY"), _class2.prototype), + _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, "animation", [ _dec3 ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return Animation.WholeSheet; + } + }), _descriptor6 = _applyDecoratedDescriptor(_class2.prototype, "randomRow", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return false; + } + }), _descriptor7 = _applyDecoratedDescriptor(_class2.prototype, "rowIndex", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return 0; + } + }), _descriptor8 = _applyDecoratedDescriptor(_class2.prototype, "frameOverTime", [ _dec4 ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new _curveRange["default"](); + } + }), _descriptor9 = _applyDecoratedDescriptor(_class2.prototype, "startFrame", [ _dec5 ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new _curveRange["default"](); + } + }), _descriptor10 = _applyDecoratedDescriptor(_class2.prototype, "cycleCount", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return 0; + } + }), _applyDecoratedDescriptor(_class2.prototype, "flipU", [ _CCClassDecorator.property ], Object.getOwnPropertyDescriptor(_class2.prototype, "flipU"), _class2.prototype), + _applyDecoratedDescriptor(_class2.prototype, "flipV", [ _CCClassDecorator.property ], Object.getOwnPropertyDescriptor(_class2.prototype, "flipV"), _class2.prototype), + _applyDecoratedDescriptor(_class2.prototype, "uvChannelMask", [ _CCClassDecorator.property ], Object.getOwnPropertyDescriptor(_class2.prototype, "uvChannelMask"), _class2.prototype), + _class2)) || _class); + exports["default"] = TextureAnimationModule; + module.exports = exports["default"]; + }), { + "../../../platform/CCClassDecorator": 241, + "../../../platform/CCEnum": 242, + "../../../value-types": 340, + "./curve-range": 32 + } ], + 40: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _CCClassDecorator = require("../../../platform/CCClassDecorator"); + var _valueTypes = require("../../../value-types"); + var _enum = require("../enum"); + var _particleGeneralFunction = require("../particle-general-function"); + var _curveRange = _interopRequireDefault(require("./curve-range")); + var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6; + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + 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 + }); + } + 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; + ("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 && void 0 !== desc.initializer) { + desc.value = desc.initializer ? desc.initializer.call(context) : void 0; + desc.initializer = void 0; + } + if (void 0 === desc.initializer) { + Object.defineProperty(target, property, desc); + desc = null; + } + return desc; + } + function _initializerWarningHelper(descriptor, context) { + throw new Error("Decorating class property failed. Please ensure that proposal-class-properties is enabled and runs after the decorators transform."); + } + var VELOCITY_OVERTIME_RAND_OFFSET = 197866; + var _temp_v3 = cc.v3(); + var VelocityOvertimeModule = (_dec = (0, _CCClassDecorator.ccclass)("cc.VelocityOvertimeModule"), + _dec2 = (0, _CCClassDecorator.property)({ + type: _enum.Space + }), _dec3 = (0, _CCClassDecorator.property)({ + type: _curveRange["default"], + range: [ -1, 1 ] + }), _dec4 = (0, _CCClassDecorator.property)({ + type: _curveRange["default"], + range: [ -1, 1 ] + }), _dec5 = (0, _CCClassDecorator.property)({ + type: _curveRange["default"], + range: [ -1, 1 ] + }), _dec6 = (0, _CCClassDecorator.property)({ + type: _curveRange["default"], + range: [ -1, 1 ] + }), _dec(_class = (_class2 = (function() { + function VelocityOvertimeModule() { + _initializerDefineProperty(this, "enable", _descriptor, this); + _initializerDefineProperty(this, "space", _descriptor2, this); + _initializerDefineProperty(this, "x", _descriptor3, this); + _initializerDefineProperty(this, "y", _descriptor4, this); + _initializerDefineProperty(this, "z", _descriptor5, this); + _initializerDefineProperty(this, "speedModifier", _descriptor6, this); + this.rotation = null; + this.needTransform = false; + this.rotation = new _valueTypes.Quat(); + this.speedModifier.constant = 1; + this.needTransform = false; + } + var _proto = VelocityOvertimeModule.prototype; + _proto.update = function update(space, worldTransform) { + this.needTransform = (0, _particleGeneralFunction.calculateTransform)(space, this.space, worldTransform, this.rotation); + }; + _proto.animate = function animate(p) { + var normalizedTime = 1 - p.remainingLifetime / p.startLifetime; + var vel = _valueTypes.Vec3.set(_temp_v3, this.x.evaluate(normalizedTime, (0, _valueTypes.pseudoRandom)(p.randomSeed + VELOCITY_OVERTIME_RAND_OFFSET)), this.y.evaluate(normalizedTime, (0, + _valueTypes.pseudoRandom)(p.randomSeed + VELOCITY_OVERTIME_RAND_OFFSET)), this.z.evaluate(normalizedTime, (0, + _valueTypes.pseudoRandom)(p.randomSeed + VELOCITY_OVERTIME_RAND_OFFSET))); + this.needTransform && _valueTypes.Vec3.transformQuat(vel, vel, this.rotation); + _valueTypes.Vec3.add(p.animatedVelocity, p.animatedVelocity, vel); + _valueTypes.Vec3.add(p.ultimateVelocity, p.velocity, p.animatedVelocity); + _valueTypes.Vec3.scale(p.ultimateVelocity, p.ultimateVelocity, this.speedModifier.evaluate(1 - p.remainingLifetime / p.startLifetime, (0, + _valueTypes.pseudoRandom)(p.randomSeed + VELOCITY_OVERTIME_RAND_OFFSET))); + }; + return VelocityOvertimeModule; + })(), _descriptor = _applyDecoratedDescriptor(_class2.prototype, "enable", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return false; + } + }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "space", [ _dec2 ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return _enum.Space.Local; + } + }), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "x", [ _dec3 ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new _curveRange["default"](); + } + }), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "y", [ _dec4 ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new _curveRange["default"](); + } + }), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, "z", [ _dec5 ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new _curveRange["default"](); + } + }), _descriptor6 = _applyDecoratedDescriptor(_class2.prototype, "speedModifier", [ _dec6 ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new _curveRange["default"](); + } + }), _class2)) || _class); + exports["default"] = VelocityOvertimeModule; + module.exports = exports["default"]; + }), { + "../../../platform/CCClassDecorator": 241, + "../../../value-types": 340, + "../enum": 44, + "../particle-general-function": 45, + "./curve-range": 32 + } ], + 41: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _CCClassDecorator = require("../../platform/CCClassDecorator"); + var _valueTypes = require("../../value-types"); + var _curveRange = _interopRequireDefault(require("./animator/curve-range")); + var _dec, _dec2, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6; + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + 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 + }); + } + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + "value" in descriptor && (descriptor.writable = true); + Object.defineProperty(target, descriptor.key, descriptor); + } + } + function _createClass(Constructor, protoProps, staticProps) { + protoProps && _defineProperties(Constructor.prototype, protoProps); + staticProps && _defineProperties(Constructor, staticProps); + return Constructor; + } + 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; + ("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 && void 0 !== desc.initializer) { + desc.value = desc.initializer ? desc.initializer.call(context) : void 0; + desc.initializer = void 0; + } + if (void 0 === desc.initializer) { + Object.defineProperty(target, property, desc); + desc = null; + } + return desc; + } + function _initializerWarningHelper(descriptor, context) { + throw new Error("Decorating class property failed. Please ensure that proposal-class-properties is enabled and runs after the decorators transform."); + } + var Burst = (_dec = (0, _CCClassDecorator.ccclass)("cc.Burst"), _dec2 = (0, _CCClassDecorator.property)({ + type: _curveRange["default"] + }), _dec(_class = (_class2 = (function() { + function Burst() { + _initializerDefineProperty(this, "_time", _descriptor, this); + _initializerDefineProperty(this, "minCount", _descriptor2, this); + _initializerDefineProperty(this, "maxCount", _descriptor3, this); + _initializerDefineProperty(this, "_repeatCount", _descriptor4, this); + _initializerDefineProperty(this, "repeatInterval", _descriptor5, this); + _initializerDefineProperty(this, "count", _descriptor6, this); + this._remainingCount = 0; + this._curTime = 0; + this._remainingCount = 0; + this._curTime = 0; + } + var _proto = Burst.prototype; + _proto.update = function update(psys, dt) { + if (0 === this._remainingCount) { + this._remainingCount = this._repeatCount; + this._curTime = this._time; + } + if (this._remainingCount > 0) { + var preFrameTime = (0, _valueTypes.repeat)(psys._time - psys.startDelay.evaluate(0, 1), psys.duration) - dt; + preFrameTime = preFrameTime > 0 ? preFrameTime : 0; + var curFrameTime = (0, _valueTypes.repeat)(psys.time - psys.startDelay.evaluate(0, 1), psys.duration); + if (this._curTime >= preFrameTime && this._curTime < curFrameTime) { + psys.emit(this.count.evaluate(this._curTime / psys.duration, 1), dt - (curFrameTime - this._curTime)); + this._curTime += this.repeatInterval; + --this._remainingCount; + } + } + }; + _proto.getMaxCount = function getMaxCount(psys) { + return this.count.getMax() * Math.min(Math.ceil(psys.duration / this.repeatInterval), this.repeatCount); + }; + _createClass(Burst, [ { + key: "time", + get: function get() { + return this._time; + }, + set: function set(val) { + this._time = val; + this._curTime = val; + } + }, { + key: "repeatCount", + get: function get() { + return this._repeatCount; + }, + set: function set(val) { + this._repeatCount = val; + this._remainingCount = val; + } + } ]); + return Burst; + })(), _descriptor = _applyDecoratedDescriptor(_class2.prototype, "_time", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return 0; + } + }), _applyDecoratedDescriptor(_class2.prototype, "time", [ _CCClassDecorator.property ], Object.getOwnPropertyDescriptor(_class2.prototype, "time"), _class2.prototype), + _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "minCount", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return 30; + } + }), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "maxCount", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return 30; + } + }), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "_repeatCount", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return 1; + } + }), _applyDecoratedDescriptor(_class2.prototype, "repeatCount", [ _CCClassDecorator.property ], Object.getOwnPropertyDescriptor(_class2.prototype, "repeatCount"), _class2.prototype), + _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, "repeatInterval", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return 1; + } + }), _descriptor6 = _applyDecoratedDescriptor(_class2.prototype, "count", [ _dec2 ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new _curveRange["default"](); + } + }), _class2)) || _class); + exports["default"] = Burst; + module.exports = exports["default"]; + }), { + "../../platform/CCClassDecorator": 241, + "../../value-types": 340, + "./animator/curve-range": 32 + } ], + 42: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports.OptimizedKey = exports.Keyframe = exports.AnimationCurve = void 0; + exports.evalOptCurve = evalOptCurve; + var _CCEnum = _interopRequireDefault(require("../../platform/CCEnum")); + var _valueTypes = require("../../value-types"); + var _CCClassDecorator = require("../../platform/CCClassDecorator"); + var _dec, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _dec2, _dec3, _dec4, _dec5, _class4, _class5, _descriptor5, _descriptor6, _descriptor7; + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + 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 + }); + } + 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; + ("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 && void 0 !== desc.initializer) { + desc.value = desc.initializer ? desc.initializer.call(context) : void 0; + desc.initializer = void 0; + } + if (void 0 === desc.initializer) { + Object.defineProperty(target, property, desc); + desc = null; + } + return desc; + } + function _initializerWarningHelper(descriptor, context) { + throw new Error("Decorating class property failed. Please ensure that proposal-class-properties is enabled and runs after the decorators transform."); + } + var LOOK_FORWARD = 3; + var WrapMode = (0, _CCEnum["default"])({ + Default: 0, + Once: 1, + Loop: 2, + PingPong: 3, + ClampForever: 4 + }); + var Keyframe = (_dec = (0, _CCClassDecorator.ccclass)("cc.Keyframe"), _dec(_class = (_class2 = function Keyframe(time, value, inTangent, outTangent) { + _initializerDefineProperty(this, "time", _descriptor, this); + _initializerDefineProperty(this, "value", _descriptor2, this); + _initializerDefineProperty(this, "inTangent", _descriptor3, this); + _initializerDefineProperty(this, "outTangent", _descriptor4, this); + this.time = time || 0; + this.value = value || 0; + this.inTangent = inTangent || 0; + this.outTangent = outTangent || 0; + }, _descriptor = _applyDecoratedDescriptor(_class2.prototype, "time", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return 0; + } + }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "value", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return 0; + } + }), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "inTangent", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return 0; + } + }), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "outTangent", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return 0; + } + }), _class2)) || _class); + exports.Keyframe = Keyframe; + var OptimizedKey = (function() { + function OptimizedKey() { + this.index = 0; + this.time = 0; + this.endTime = 0; + this.coefficient = null; + this.index = -1; + this.time = 0; + this.endTime = 0; + this.coefficient = new Float32Array(4); + } + var _proto = OptimizedKey.prototype; + _proto.evaluate = function evaluate(T) { + var t = T - this.time; + return evalOptCurve(t, this.coefficient); + }; + return OptimizedKey; + })(); + exports.OptimizedKey = OptimizedKey; + function evalOptCurve(t, coefs) { + return t * (t * (t * coefs[0] + coefs[1]) + coefs[2]) + coefs[3]; + } + var defaultKFStart = new Keyframe(0, 1, 0, 0); + var defaultKFEnd = new Keyframe(1, 1, 0, 0); + var AnimationCurve = (_dec2 = (0, _CCClassDecorator.ccclass)("cc.AnimationCurve"), + _dec3 = (0, _CCClassDecorator.property)({ + type: [ Keyframe ] + }), _dec4 = (0, _CCClassDecorator.property)({ + type: cc.Enum(WrapMode), + visible: false + }), _dec5 = (0, _CCClassDecorator.property)({ + type: cc.Enum(WrapMode), + visible: false + }), _dec2(_class4 = (_class5 = (function() { + function AnimationCurve(keyFrames) { + void 0 === keyFrames && (keyFrames = null); + _initializerDefineProperty(this, "keyFrames", _descriptor5, this); + _initializerDefineProperty(this, "preWrapMode", _descriptor6, this); + _initializerDefineProperty(this, "postWrapMode", _descriptor7, this); + this.cachedKey = null; + if (keyFrames) this.keyFrames = keyFrames; else { + this.keyFrames.push(defaultKFStart); + this.keyFrames.push(defaultKFEnd); + } + this.cachedKey = new OptimizedKey(); + } + var _proto2 = AnimationCurve.prototype; + _proto2.addKey = function addKey(keyFrame) { + null == this.keyFrames && (this.keyFrames = []); + this.keyFrames.push(keyFrame); + }; + _proto2.evaluate_slow = function evaluate_slow(time) { + var wrappedTime = time; + var wrapMode = time < 0 ? this.preWrapMode : this.postWrapMode; + var startTime = this.keyFrames[0].time; + var endTime = this.keyFrames[this.keyFrames.length - 1].time; + switch (wrapMode) { + case WrapMode.Loop: + wrappedTime = (0, _valueTypes.repeat)(time - startTime, endTime - startTime) + startTime; + break; + + case WrapMode.PingPong: + wrappedTime = (0, _valueTypes.pingPong)(time - startTime, endTime - startTime) + startTime; + break; + + case WrapMode.ClampForever: + wrappedTime = (0, _valueTypes.clamp)(time, startTime, endTime); + } + var preKFIndex = 0; + if (wrappedTime > this.keyFrames[0].time) if (wrappedTime >= this.keyFrames[this.keyFrames.length - 1].time) preKFIndex = this.keyFrames.length - 2; else for (var i = 0; i < this.keyFrames.length - 1; i++) if (wrappedTime >= this.keyFrames[0].time && wrappedTime <= this.keyFrames[i + 1].time) { + preKFIndex = i; + break; + } + var keyframe0 = this.keyFrames[preKFIndex]; + var keyframe1 = this.keyFrames[preKFIndex + 1]; + var t = (0, _valueTypes.inverseLerp)(keyframe0.time, keyframe1.time, wrappedTime); + var dt = keyframe1.time - keyframe0.time; + var m0 = keyframe0.outTangent * dt; + var m1 = keyframe1.inTangent * dt; + var t2 = t * t; + var t3 = t2 * t; + var a = 2 * t3 - 3 * t2 + 1; + var b = t3 - 2 * t2 + t; + var c = t3 - t2; + var d = -2 * t3 + 3 * t2; + return a * keyframe0.value + b * m0 + c * m1 + d * keyframe1.value; + }; + _proto2.evaluate = function evaluate(time) { + var wrappedTime = time; + var wrapMode = time < 0 ? this.preWrapMode : this.postWrapMode; + var startTime = this.keyFrames[0].time; + var endTime = this.keyFrames[this.keyFrames.length - 1].time; + switch (wrapMode) { + case WrapMode.Loop: + wrappedTime = (0, _valueTypes.repeat)(time - startTime, endTime - startTime) + startTime; + break; + + case WrapMode.PingPong: + wrappedTime = (0, _valueTypes.pingPong)(time - startTime, endTime - startTime) + startTime; + break; + + case WrapMode.ClampForever: + wrappedTime = (0, _valueTypes.clamp)(time, startTime, endTime); + } + true; + if (wrappedTime >= this.cachedKey.time && wrappedTime < this.cachedKey.endTime) return this.cachedKey.evaluate(wrappedTime); + var leftIndex = this.findIndex(this.cachedKey, wrappedTime); + var rightIndex = Math.min(leftIndex + 1, this.keyFrames.length - 1); + this.calcOptimizedKey(this.cachedKey, leftIndex, rightIndex); + return this.cachedKey.evaluate(wrappedTime); + }; + _proto2.calcOptimizedKey = function calcOptimizedKey(optKey, leftIndex, rightIndex) { + var lhs = this.keyFrames[leftIndex]; + var rhs = this.keyFrames[rightIndex]; + optKey.index = leftIndex; + optKey.time = lhs.time; + optKey.endTime = rhs.time; + var dx = rhs.time - lhs.time; + var dy = rhs.value - lhs.value; + var length = 1 / (dx * dx); + var d1 = lhs.outTangent * dx; + var d2 = rhs.inTangent * dx; + optKey.coefficient[0] = (d1 + d2 - dy - dy) * length / dx; + optKey.coefficient[1] = (dy + dy + dy - d1 - d1 - d2) * length; + optKey.coefficient[2] = lhs.outTangent; + optKey.coefficient[3] = lhs.value; + }; + _proto2.findIndex = function findIndex(optKey, t) { + var cachedIndex = optKey.index; + if (-1 !== cachedIndex) { + var cachedTime = this.keyFrames[cachedIndex].time; + if (t > cachedTime) for (var i = 0; i < LOOK_FORWARD; i++) { + var currIndex = cachedIndex + i; + if (currIndex + 1 < this.keyFrames.length && this.keyFrames[currIndex + 1].time > t) return currIndex; + } else for (var _i = 0; _i < LOOK_FORWARD; _i++) { + var _currIndex = cachedIndex - _i; + if (_currIndex - 1 >= 0 && this.keyFrames[_currIndex - 1].time <= t) return _currIndex - 1; + } + } + var left = 0; + var right = this.keyFrames.length; + var mid; + while (right - left > 1) { + mid = Math.floor((left + right) / 2); + this.keyFrames[mid].time >= t ? right = mid : left = mid; + } + return left; + }; + return AnimationCurve; + })(), _descriptor5 = _applyDecoratedDescriptor(_class5.prototype, "keyFrames", [ _dec3 ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new Array(); + } + }), _descriptor6 = _applyDecoratedDescriptor(_class5.prototype, "preWrapMode", [ _dec4 ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return WrapMode.ClampForever; + } + }), _descriptor7 = _applyDecoratedDescriptor(_class5.prototype, "postWrapMode", [ _dec5 ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return WrapMode.ClampForever; + } + }), _class5)) || _class4); + exports.AnimationCurve = AnimationCurve; + cc.Keyframe = Keyframe; + cc.AnimationCurve = AnimationCurve; + }), { + "../../platform/CCClassDecorator": 241, + "../../platform/CCEnum": 242, + "../../value-types": 340 + } ], + 43: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _CCClassDecorator = require("../../../platform/CCClassDecorator"); + var _valueTypes = require("../../../value-types"); + var _curveRange = _interopRequireDefault(require("../animator/curve-range")); + var _particleGeneralFunction = require("../particle-general-function"); + var _enum = require("../enum"); + var _dec, _dec2, _dec3, _dec4, _dec5, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6, _descriptor7, _descriptor8, _descriptor9, _descriptor10, _descriptor11, _descriptor12, _descriptor13, _descriptor14, _descriptor15, _descriptor16, _descriptor17, _descriptor18, _descriptor19; + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + 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 + }); + } + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + "value" in descriptor && (descriptor.writable = true); + Object.defineProperty(target, descriptor.key, descriptor); + } + } + function _createClass(Constructor, protoProps, staticProps) { + protoProps && _defineProperties(Constructor.prototype, protoProps); + staticProps && _defineProperties(Constructor, staticProps); + return Constructor; + } + 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; + ("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 && void 0 !== desc.initializer) { + desc.value = desc.initializer ? desc.initializer.call(context) : void 0; + desc.initializer = void 0; + } + if (void 0 === desc.initializer) { + Object.defineProperty(target, property, desc); + desc = null; + } + return desc; + } + function _initializerWarningHelper(descriptor, context) { + throw new Error("Decorating class property failed. Please ensure that proposal-class-properties is enabled and runs after the decorators transform."); + } + var _intermediVec = new _valueTypes.Vec3(0, 0, 0); + var _intermediArr = new Array(); + var _unitBoxExtent = new _valueTypes.Vec3(.5, .5, .5); + var ShapeModule = (_dec = (0, _CCClassDecorator.ccclass)("cc.ShapeModule"), _dec2 = (0, + _CCClassDecorator.property)({ + type: _enum.ShapeType + }), _dec3 = (0, _CCClassDecorator.property)({ + type: _enum.EmitLocation + }), _dec4 = (0, _CCClassDecorator.property)({ + type: _enum.ArcMode + }), _dec5 = (0, _CCClassDecorator.property)({ + type: _curveRange["default"] + }), _dec(_class = (_class2 = (function() { + function ShapeModule() { + _initializerDefineProperty(this, "enable", _descriptor, this); + _initializerDefineProperty(this, "_shapeType", _descriptor2, this); + _initializerDefineProperty(this, "emitFrom", _descriptor3, this); + _initializerDefineProperty(this, "radius", _descriptor4, this); + _initializerDefineProperty(this, "radiusThickness", _descriptor5, this); + _initializerDefineProperty(this, "_angle", _descriptor6, this); + _initializerDefineProperty(this, "_arc", _descriptor7, this); + _initializerDefineProperty(this, "arcMode", _descriptor8, this); + _initializerDefineProperty(this, "arcSpread", _descriptor9, this); + _initializerDefineProperty(this, "arcSpeed", _descriptor10, this); + _initializerDefineProperty(this, "length", _descriptor11, this); + _initializerDefineProperty(this, "boxThickness", _descriptor12, this); + _initializerDefineProperty(this, "_position", _descriptor13, this); + _initializerDefineProperty(this, "_rotation", _descriptor14, this); + _initializerDefineProperty(this, "_scale", _descriptor15, this); + _initializerDefineProperty(this, "alignToDirection", _descriptor16, this); + _initializerDefineProperty(this, "randomDirectionAmount", _descriptor17, this); + _initializerDefineProperty(this, "sphericalDirectionAmount", _descriptor18, this); + _initializerDefineProperty(this, "randomPositionAmount", _descriptor19, this); + this.mat = null; + this.Quat = null; + this.particleSystem = null; + this.lastTime = null; + this.totalAngle = null; + this.mat = new _valueTypes.Mat4(); + this.quat = new _valueTypes.Quat(); + this.particleSystem = null; + this.lastTime = 0; + this.totalAngle = 0; + } + var _proto = ShapeModule.prototype; + _proto.onInit = function onInit(ps) { + this.particleSystem = ps; + this.constructMat(); + this.lastTime = this.particleSystem._time; + }; + _proto.constructMat = function constructMat() { + _valueTypes.Quat.fromEuler(this.quat, this._rotation.x, this._rotation.y, this._rotation.z); + _valueTypes.Mat4.fromRTS(this.mat, this.quat, this._position, this._scale); + }; + _proto.emit = function emit(p) { + switch (this.shapeType) { + case _enum.ShapeType.Box: + boxEmit(this.emitFrom, this.boxThickness, p.position, p.velocity); + break; + + case _enum.ShapeType.Circle: + circleEmit(this.radius, this.radiusThickness, this.generateArcAngle(), p.position, p.velocity); + break; + + case _enum.ShapeType.Cone: + coneEmit(this.emitFrom, this.radius, this.radiusThickness, this.generateArcAngle(), this._angle, this.length, p.position, p.velocity); + break; + + case _enum.ShapeType.Sphere: + sphereEmit(this.emitFrom, this.radius, this.radiusThickness, p.position, p.velocity); + break; + + case _enum.ShapeType.Hemisphere: + hemisphereEmit(this.emitFrom, this.radius, this.radiusThickness, p.position, p.velocity); + break; + + default: + console.warn(this.shapeType + " shapeType is not supported by ShapeModule."); + } + if (this.randomPositionAmount > 0) { + p.position.x += (0, _valueTypes.randomRange)(-this.randomPositionAmount, this.randomPositionAmount); + p.position.y += (0, _valueTypes.randomRange)(-this.randomPositionAmount, this.randomPositionAmount); + p.position.z += (0, _valueTypes.randomRange)(-this.randomPositionAmount, this.randomPositionAmount); + } + _valueTypes.Vec3.transformQuat(p.velocity, p.velocity, this.quat); + _valueTypes.Vec3.transformMat4(p.position, p.position, this.mat); + if (this.sphericalDirectionAmount > 0) { + var sphericalVel = _valueTypes.Vec3.normalize(_intermediVec, p.position); + _valueTypes.Vec3.lerp(p.velocity, p.velocity, sphericalVel, this.sphericalDirectionAmount); + } + this.lastTime = this.particleSystem._time; + }; + _proto.generateArcAngle = function generateArcAngle() { + if (this.arcMode === _enum.ArcMode.Random) return (0, _valueTypes.randomRange)(0, this._arc); + var angle = this.totalAngle + 2 * Math.PI * this.arcSpeed.evaluate(this.particleSystem._time, 1) * (this.particleSystem._time - this.lastTime); + this.totalAngle = angle; + 0 !== this.arcSpread && (angle = Math.floor(angle / (this._arc * this.arcSpread)) * this._arc * this.arcSpread); + switch (this.arcMode) { + case _enum.ArcMode.Loop: + return (0, _valueTypes.repeat)(angle, this._arc); + + case _enum.ArcMode.PingPong: + return (0, _valueTypes.pingPong)(angle, this._arc); + } + }; + _createClass(ShapeModule, [ { + key: "shapeType", + get: function get() { + return this._shapeType; + }, + set: function set(val) { + this._shapeType = val; + switch (this._shapeType) { + case _enum.ShapeType.Box: + this.emitFrom === _enum.EmitLocation.Base && (this.emitFrom = _enum.EmitLocation.Volume); + break; + + case _enum.ShapeType.Cone: + this.emitFrom === _enum.EmitLocation.Edge && (this.emitFrom = _enum.EmitLocation.Base); + break; + + case _enum.ShapeType.Sphere: + case _enum.ShapeType.Hemisphere: + this.emitFrom !== _enum.EmitLocation.Base && this.emitFrom !== _enum.EmitLocation.Edge || (this.emitFrom = _enum.EmitLocation.Volume); + } + } + }, { + key: "angle", + get: function get() { + return Math.round(100 * (0, _valueTypes.toDegree)(this._angle)) / 100; + }, + set: function set(val) { + this._angle = (0, _valueTypes.toRadian)(val); + } + }, { + key: "arc", + get: function get() { + return (0, _valueTypes.toDegree)(this._arc); + }, + set: function set(val) { + this._arc = (0, _valueTypes.toRadian)(val); + } + }, { + key: "position", + get: function get() { + return this._position; + }, + set: function set(val) { + this._position = val; + this.constructMat(); + } + }, { + key: "rotation", + get: function get() { + return this._rotation; + }, + set: function set(val) { + this._rotation = val; + this.constructMat(); + } + }, { + key: "scale", + get: function get() { + return this._scale; + }, + set: function set(val) { + this._scale = val; + this.constructMat(); + } + } ]); + return ShapeModule; + })(), _descriptor = _applyDecoratedDescriptor(_class2.prototype, "enable", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return false; + } + }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "_shapeType", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return _enum.ShapeType.Cone; + } + }), _applyDecoratedDescriptor(_class2.prototype, "shapeType", [ _dec2 ], Object.getOwnPropertyDescriptor(_class2.prototype, "shapeType"), _class2.prototype), + _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "emitFrom", [ _dec3 ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return _enum.EmitLocation.Volume; + } + }), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "radius", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return 1; + } + }), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, "radiusThickness", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return 1; + } + }), _descriptor6 = _applyDecoratedDescriptor(_class2.prototype, "_angle", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return (0, _valueTypes.toRadian)(25); + } + }), _applyDecoratedDescriptor(_class2.prototype, "angle", [ _CCClassDecorator.property ], Object.getOwnPropertyDescriptor(_class2.prototype, "angle"), _class2.prototype), + _descriptor7 = _applyDecoratedDescriptor(_class2.prototype, "_arc", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return (0, _valueTypes.toRadian)(360); + } + }), _applyDecoratedDescriptor(_class2.prototype, "arc", [ _CCClassDecorator.property ], Object.getOwnPropertyDescriptor(_class2.prototype, "arc"), _class2.prototype), + _descriptor8 = _applyDecoratedDescriptor(_class2.prototype, "arcMode", [ _dec4 ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return _enum.ArcMode.Random; + } + }), _descriptor9 = _applyDecoratedDescriptor(_class2.prototype, "arcSpread", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return 0; + } + }), _descriptor10 = _applyDecoratedDescriptor(_class2.prototype, "arcSpeed", [ _dec5 ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new _curveRange["default"](); + } + }), _descriptor11 = _applyDecoratedDescriptor(_class2.prototype, "length", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return 5; + } + }), _descriptor12 = _applyDecoratedDescriptor(_class2.prototype, "boxThickness", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new _valueTypes.Vec3(0, 0, 0); + } + }), _descriptor13 = _applyDecoratedDescriptor(_class2.prototype, "_position", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new _valueTypes.Vec3(0, 0, 0); + } + }), _applyDecoratedDescriptor(_class2.prototype, "position", [ _CCClassDecorator.property ], Object.getOwnPropertyDescriptor(_class2.prototype, "position"), _class2.prototype), + _descriptor14 = _applyDecoratedDescriptor(_class2.prototype, "_rotation", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new _valueTypes.Vec3(0, 0, 0); + } + }), _applyDecoratedDescriptor(_class2.prototype, "rotation", [ _CCClassDecorator.property ], Object.getOwnPropertyDescriptor(_class2.prototype, "rotation"), _class2.prototype), + _descriptor15 = _applyDecoratedDescriptor(_class2.prototype, "_scale", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new _valueTypes.Vec3(1, 1, 1); + } + }), _applyDecoratedDescriptor(_class2.prototype, "scale", [ _CCClassDecorator.property ], Object.getOwnPropertyDescriptor(_class2.prototype, "scale"), _class2.prototype), + _descriptor16 = _applyDecoratedDescriptor(_class2.prototype, "alignToDirection", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return false; + } + }), _descriptor17 = _applyDecoratedDescriptor(_class2.prototype, "randomDirectionAmount", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return 0; + } + }), _descriptor18 = _applyDecoratedDescriptor(_class2.prototype, "sphericalDirectionAmount", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return 0; + } + }), _descriptor19 = _applyDecoratedDescriptor(_class2.prototype, "randomPositionAmount", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return 0; + } + }), _class2)) || _class); + exports["default"] = ShapeModule; + function sphereEmit(emitFrom, radius, radiusThickness, pos, dir) { + switch (emitFrom) { + case _enum.EmitLocation.Volume: + (0, _particleGeneralFunction.randomPointBetweenSphere)(pos, radius * (1 - radiusThickness), radius); + _valueTypes.Vec3.copy(dir, pos); + _valueTypes.Vec3.normalize(dir, dir); + break; + + case _enum.EmitLocation.Shell: + (0, _particleGeneralFunction.randomUnitVector)(pos); + _valueTypes.Vec3.scale(pos, pos, radius); + _valueTypes.Vec3.copy(dir, pos); + break; + + default: + console.warn(emitFrom + " is not supported for sphere emitter."); + } + } + function hemisphereEmit(emitFrom, radius, radiusThickness, pos, dir) { + switch (emitFrom) { + case _enum.EmitLocation.Volume: + (0, _particleGeneralFunction.randomPointBetweenSphere)(pos, radius * (1 - radiusThickness), radius); + pos.z > 0 && (pos.z *= -1); + _valueTypes.Vec3.copy(dir, pos); + _valueTypes.Vec3.normalize(dir, dir); + break; + + case _enum.EmitLocation.Shell: + (0, _particleGeneralFunction.randomUnitVector)(pos); + _valueTypes.Vec3.scale(pos, pos, radius); + pos.z < 0 && (pos.z *= -1); + _valueTypes.Vec3.copy(dir, pos); + break; + + default: + console.warn(emitFrom + " is not supported for hemisphere emitter."); + } + } + function coneEmit(emitFrom, radius, radiusThickness, theta, angle, length, pos, dir) { + switch (emitFrom) { + case _enum.EmitLocation.Base: + (0, _particleGeneralFunction.randomPointBetweenCircleAtFixedAngle)(pos, radius * (1 - radiusThickness), radius, theta); + _valueTypes.Vec2.scale(dir, pos, Math.sin(angle)); + dir.z = -Math.cos(angle) * radius; + _valueTypes.Vec3.normalize(dir, dir); + pos.z = 0; + break; + + case _enum.EmitLocation.Shell: + (0, _particleGeneralFunction.fixedAngleUnitVector2)(pos, theta); + _valueTypes.Vec2.scale(dir, pos, Math.sin(angle)); + dir.z = -Math.cos(angle); + _valueTypes.Vec3.normalize(dir, dir); + _valueTypes.Vec2.scale(pos, pos, radius); + pos.z = 0; + break; + + case _enum.EmitLocation.Volume: + (0, _particleGeneralFunction.randomPointBetweenCircleAtFixedAngle)(pos, radius * (1 - radiusThickness), radius, theta); + _valueTypes.Vec2.scale(dir, pos, Math.sin(angle)); + dir.z = -Math.cos(angle) * radius; + _valueTypes.Vec3.normalize(dir, dir); + pos.z = 0; + _valueTypes.Vec3.add(pos, pos, _valueTypes.Vec3.scale(_intermediVec, dir, length * (0, + _valueTypes.random)() / -dir.z)); + break; + + default: + console.warn(emitFrom + " is not supported for cone emitter."); + } + } + function boxEmit(emitFrom, boxThickness, pos, dir) { + switch (emitFrom) { + case _enum.EmitLocation.Volume: + (0, _particleGeneralFunction.randomPointInCube)(pos, _unitBoxExtent); + break; + + case _enum.EmitLocation.Shell: + _intermediArr.splice(0, _intermediArr.length); + _intermediArr.push((0, _valueTypes.randomRange)(-.5, .5)); + _intermediArr.push((0, _valueTypes.randomRange)(-.5, .5)); + _intermediArr.push(.5 * (0, _particleGeneralFunction.randomSign)()); + (0, _particleGeneralFunction.randomSortArray)(_intermediArr); + applyBoxThickness(_intermediArr, boxThickness); + _valueTypes.Vec3.set(pos, _intermediArr[0], _intermediArr[1], _intermediArr[2]); + break; + + case _enum.EmitLocation.Edge: + _intermediArr.splice(0, _intermediArr.length); + _intermediArr.push((0, _valueTypes.randomRange)(-.5, .5)); + _intermediArr.push(.5 * (0, _particleGeneralFunction.randomSign)()); + _intermediArr.push(.5 * (0, _particleGeneralFunction.randomSign)()); + (0, _particleGeneralFunction.randomSortArray)(_intermediArr); + applyBoxThickness(_intermediArr, boxThickness); + _valueTypes.Vec3.set(pos, _intermediArr[0], _intermediArr[1], _intermediArr[2]); + break; + + default: + console.warn(emitFrom + " is not supported for box emitter."); + } + _valueTypes.Vec3.copy(dir, _particleGeneralFunction.particleEmitZAxis); + } + function circleEmit(radius, radiusThickness, theta, pos, dir) { + (0, _particleGeneralFunction.randomPointBetweenCircleAtFixedAngle)(pos, radius * (1 - radiusThickness), radius, theta); + _valueTypes.Vec3.normalize(dir, pos); + } + function applyBoxThickness(pos, thickness) { + if (thickness.x > 0) { + pos[0] += .5 * (0, _valueTypes.randomRange)(-thickness.x, thickness.x); + pos[0] = (0, _valueTypes.clamp)(pos[0], -.5, .5); + } + if (thickness.y > 0) { + pos[1] += .5 * (0, _valueTypes.randomRange)(-thickness.y, thickness.y); + pos[1] = (0, _valueTypes.clamp)(pos[1], -.5, .5); + } + if (thickness.z > 0) { + pos[2] += .5 * (0, _valueTypes.randomRange)(-thickness.z, thickness.z); + pos[2] = (0, _valueTypes.clamp)(pos[2], -.5, .5); + } + } + module.exports = exports["default"]; + }), { + "../../../platform/CCClassDecorator": 241, + "../../../value-types": 340, + "../animator/curve-range": 32, + "../enum": 44, + "../particle-general-function": 45 + } ], + 44: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports.TrailMode = exports.TextureMode = exports.Space = exports.ShapeType = exports.RenderMode = exports.EmitLocation = exports.ArcMode = void 0; + var _CCEnum = _interopRequireDefault(require("../../platform/CCEnum")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + var Space = (0, _CCEnum["default"])({ + World: 0, + Local: 1, + Custom: 2 + }); + exports.Space = Space; + var RenderMode = (0, _CCEnum["default"])({ + Billboard: 0, + StrecthedBillboard: 1, + HorizontalBillboard: 2, + VerticalBillboard: 3, + Mesh: 4 + }); + exports.RenderMode = RenderMode; + var ShapeType = (0, _CCEnum["default"])({ + Box: 0, + Circle: 1, + Cone: 2, + Sphere: 3, + Hemisphere: 4 + }); + exports.ShapeType = ShapeType; + var EmitLocation = (0, _CCEnum["default"])({ + Base: 0, + Edge: 1, + Shell: 2, + Volume: 3 + }); + exports.EmitLocation = EmitLocation; + var ArcMode = (0, _CCEnum["default"])({ + Random: 0, + Loop: 1, + PingPong: 2 + }); + exports.ArcMode = ArcMode; + var TrailMode = (0, _CCEnum["default"])({ + Particles: 0, + Ribbon: 1 + }); + exports.TrailMode = TrailMode; + var TextureMode = (0, _CCEnum["default"])({ + Stretch: 0, + Repeat: 1 + }); + exports.TextureMode = TextureMode; + }), { + "../../platform/CCEnum": 242 + } ], + 45: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports.calculateTransform = calculateTransform; + exports.fixedAngleUnitVector2 = fixedAngleUnitVector2; + exports.particleEmitZAxis = void 0; + exports.randomPointBetweenCircle = randomPointBetweenCircle; + exports.randomPointBetweenCircleAtFixedAngle = randomPointBetweenCircleAtFixedAngle; + exports.randomPointBetweenCube = randomPointBetweenCube; + exports.randomPointBetweenSphere = randomPointBetweenSphere; + exports.randomPointInCube = randomPointInCube; + exports.randomPointInUnitCircle = randomPointInUnitCircle; + exports.randomPointInUnitSphere = randomPointInUnitSphere; + exports.randomSign = randomSign; + exports.randomSortArray = randomSortArray; + exports.randomUnitVector = randomUnitVector; + exports.randomUnitVector2 = randomUnitVector2; + var _valueTypes = require("../../value-types"); + var _utils = require("../../value-types/utils"); + var _enum = require("./enum"); + var particleEmitZAxis = new _valueTypes.Vec3(0, 0, -1); + exports.particleEmitZAxis = particleEmitZAxis; + function calculateTransform(systemSpace, moduleSpace, worldTransform, outQuat) { + if (moduleSpace !== systemSpace) { + if (systemSpace === _enum.Space.World) _valueTypes.Mat4.getRotation(outQuat, worldTransform); else { + _valueTypes.Mat4.invert(worldTransform, worldTransform); + _valueTypes.Mat4.getRotation(outQuat, worldTransform); + } + return true; + } + _valueTypes.Quat.set(outQuat, 0, 0, 0, 1); + return false; + } + function fixedAngleUnitVector2(out, theta) { + _valueTypes.Vec2.set(out, Math.cos(theta), Math.sin(theta)); + } + function randomUnitVector2(out) { + var a = (0, _valueTypes.randomRange)(0, 2 * Math.PI); + var x = Math.cos(a); + var y = Math.sin(a); + _valueTypes.Vec2.set(out, x, y); + } + function randomUnitVector(out) { + var z = (0, _valueTypes.randomRange)(-1, 1); + var a = (0, _valueTypes.randomRange)(0, 2 * Math.PI); + var r = Math.sqrt(1 - z * z); + var x = r * Math.cos(a); + var y = r * Math.sin(a); + _valueTypes.Vec3.set(out, x, y, z); + } + function randomPointInUnitSphere(out) { + randomUnitVector(out); + _valueTypes.Vec3.scale(out, out, (0, _valueTypes.random)()); + } + function randomPointBetweenSphere(out, minRadius, maxRadius) { + randomUnitVector(out); + _valueTypes.Vec3.scale(out, out, minRadius + (maxRadius - minRadius) * (0, _valueTypes.random)()); + } + function randomPointInUnitCircle(out) { + randomUnitVector2(out); + out.z = 0; + _valueTypes.Vec3.scale(out, out, (0, _valueTypes.random)()); + } + function randomPointBetweenCircle(out, minRadius, maxRadius) { + randomUnitVector2(out); + out.z = 0; + _valueTypes.Vec3.scale(out, out, minRadius + (maxRadius - minRadius) * (0, _valueTypes.random)()); + } + function randomPointBetweenCircleAtFixedAngle(out, minRadius, maxRadius, theta) { + fixedAngleUnitVector2(out, theta); + out.z = 0; + _valueTypes.Vec3.scale(out, out, minRadius + (maxRadius - minRadius) * (0, _valueTypes.random)()); + } + function randomPointInCube(out, extents) { + _valueTypes.Vec3.set(out, (0, _valueTypes.randomRange)(-extents.x, extents.x), (0, + _valueTypes.randomRange)(-extents.y, extents.y), (0, _valueTypes.randomRange)(-extents.z, extents.z)); + } + function randomPointBetweenCube(out, minBox, maxBox) { + var subscript = [ "x", "y", "z" ]; + var edge = (0, _valueTypes.randomRangeInt)(0, 3); + for (var i = 0; i < 3; i++) { + if (i === edge) { + out[subscript[i]] = (0, _valueTypes.randomRange)(-maxBox[subscript[i]], maxBox[subscript[i]]); + continue; + } + var x = 2 * (0, _valueTypes.random)() - 1; + out[subscript[i]] = x < 0 ? -minBox[subscript[i]] + x * (maxBox[subscript[i]] - minBox[subscript[i]]) : minBox[subscript[i]] + x * (maxBox[subscript[i]] - minBox[subscript[i]]); + } + } + function randomSortArray(arr) { + for (var i = 0; i < arr.length; i++) { + var transpose = i + (0, _valueTypes.randomRangeInt)(0, arr.length - i); + var val = arr[transpose]; + arr[transpose] = arr[i]; + arr[i] = val; + } + } + function randomSign() { + var sgn = (0, _valueTypes.randomRange)(-1, 1); + 0 === sgn ? sgn++ : sgn; + return (0, _utils.sign)(sgn); + } + }), { + "../../value-types": 340, + "../../value-types/utils": 347, + "./enum": 44 + } ], + 46: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _valueTypes = require("../../value-types"); + var _utils = require("../../value-types/utils"); + var _CCMaterial = _interopRequireDefault(require("../../assets/material/CCMaterial")); + var _colorOvertime = _interopRequireDefault(require("./animator/color-overtime")); + var _curveRange = _interopRequireWildcard(require("./animator/curve-range")); + var _forceOvertime = _interopRequireDefault(require("./animator/force-overtime")); + var _gradientRange = _interopRequireDefault(require("./animator/gradient-range")); + var _limitVelocityOvertime = _interopRequireDefault(require("./animator/limit-velocity-overtime")); + var _rotationOvertime = _interopRequireDefault(require("./animator/rotation-overtime")); + var _sizeOvertime = _interopRequireDefault(require("./animator/size-overtime")); + var _textureAnimation = _interopRequireDefault(require("./animator/texture-animation")); + var _velocityOvertime = _interopRequireDefault(require("./animator/velocity-overtime")); + var _burst = _interopRequireDefault(require("./burst")); + var _shapeModule = _interopRequireDefault(require("./emitter/shape-module")); + var _enum = require("./enum"); + var _particleGeneralFunction = require("./particle-general-function"); + var _trail = _interopRequireDefault(require("./renderer/trail")); + var _CCMesh = _interopRequireDefault(require("../../mesh/CCMesh")); + var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _dec9, _dec10, _dec11, _dec12, _dec13, _dec14, _dec15, _dec16, _dec17, _dec18, _dec19, _dec20, _dec21, _dec22, _dec23, _dec24, _dec25, _dec26, _dec27, _dec28, _dec29, _dec30, _dec31, _dec32, _dec33, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6, _descriptor7, _descriptor8, _descriptor9, _descriptor10, _descriptor11, _descriptor12, _descriptor13, _descriptor14, _descriptor15, _descriptor16, _descriptor17, _descriptor18, _descriptor19, _descriptor20, _descriptor21, _descriptor22, _descriptor23, _descriptor24, _descriptor25, _descriptor26, _descriptor27, _descriptor28, _descriptor29, _descriptor30, _descriptor31; + function _getRequireWildcardCache(nodeInterop) { + if ("function" !== typeof WeakMap) return null; + var cacheBabelInterop = new WeakMap(); + var cacheNodeInterop = new WeakMap(); + return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { + return nodeInterop ? cacheNodeInterop : cacheBabelInterop; + })(nodeInterop); + } + function _interopRequireWildcard(obj, nodeInterop) { + if (!nodeInterop && obj && obj.__esModule) return obj; + if (null === obj || "object" !== typeof obj && "function" !== typeof obj) return { + default: obj + }; + var cache = _getRequireWildcardCache(nodeInterop); + if (cache && cache.has(obj)) return cache.get(obj); + var newObj = {}; + var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; + for (var key in obj) if ("default" !== key && Object.prototype.hasOwnProperty.call(obj, key)) { + var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; + desc && (desc.get || desc.set) ? Object.defineProperty(newObj, key, desc) : newObj[key] = obj[key]; + } + newObj["default"] = obj; + cache && cache.set(obj, newObj); + return newObj; + } + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _createForOfIteratorHelperLoose(o, allowArrayLike) { + var it = "undefined" !== typeof Symbol && o[Symbol.iterator] || o["@@iterator"]; + if (it) return (it = it.call(o)).next.bind(it); + if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && "number" === typeof o.length) { + it && (o = it); + var i = 0; + return function() { + if (i >= o.length) return { + done: true + }; + return { + done: false, + value: o[i++] + }; + }; + } + throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + function _unsupportedIterableToArray(o, minLen) { + if (!o) return; + if ("string" === typeof o) return _arrayLikeToArray(o, minLen); + var n = Object.prototype.toString.call(o).slice(8, -1); + "Object" === n && o.constructor && (n = o.constructor.name); + if ("Map" === n || "Set" === n) return Array.from(o); + if ("Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); + } + function _arrayLikeToArray(arr, len) { + (null == len || len > arr.length) && (len = arr.length); + for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; + return arr2; + } + 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 + }); + } + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + "value" in descriptor && (descriptor.writable = true); + Object.defineProperty(target, descriptor.key, descriptor); + } + } + function _createClass(Constructor, protoProps, staticProps) { + protoProps && _defineProperties(Constructor.prototype, protoProps); + staticProps && _defineProperties(Constructor, staticProps); + return Constructor; + } + function _assertThisInitialized(self) { + if (void 0 === self) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + return self; + } + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + _setPrototypeOf(subClass, superClass); + } + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + return _setPrototypeOf(o, p); + } + 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; + ("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 && void 0 !== desc.initializer) { + desc.value = desc.initializer ? desc.initializer.call(context) : void 0; + desc.initializer = void 0; + } + if (void 0 === desc.initializer) { + Object.defineProperty(target, property, desc); + desc = null; + } + return desc; + } + function _initializerWarningHelper(descriptor, context) { + throw new Error("Decorating class property failed. Please ensure that proposal-class-properties is enabled and runs after the decorators transform."); + } + var _require = require("../../platform/CCClassDecorator"), ccclass = _require.ccclass, menu = _require.menu, property = _require.property, executeInEditMode = _require.executeInEditMode, executionOrder = _require.executionOrder; + var RenderComponent = require("../../components/CCRenderComponent"); + var _world_mat = new _valueTypes.Mat4(); + var _module_props = false; + var ParticleSystem3D = (_dec = ccclass("cc.ParticleSystem3D"), _dec2 = menu("i18n:MAIN_MENU.component.renderers/ParticleSystem3D"), + _dec3 = executionOrder(99), _dec4 = property({ + animatable: false + }), _dec5 = property({ + animatable: false + }), _dec6 = property({ + type: _enum.Space, + animatable: false + }), _dec7 = property({ + type: _curveRange["default"] + }), _dec8 = property({ + type: _curveRange["default"] + }), _dec9 = property({ + type: _gradientRange["default"] + }), _dec10 = property({ + type: _enum.Space + }), _dec11 = property({ + type: _curveRange["default"] + }), _dec12 = property({ + type: _curveRange["default"], + range: [ -1, 1 ] + }), _dec13 = property({ + type: _curveRange["default"], + range: [ -1, 1 ], + radian: true + }), _dec14 = property({ + type: _curveRange["default"], + range: [ -1, 1 ] + }), _dec15 = property({ + type: _curveRange["default"] + }), _dec16 = property({ + type: _curveRange["default"] + }), _dec17 = property({ + type: [ _burst["default"] ], + animatable: false + }), _dec18 = property({ + type: [ _CCMaterial["default"] ], + displayName: "Materials", + visible: false, + override: true + }), _dec19 = property({ + type: _shapeModule["default"], + animatable: false + }), _dec20 = property({ + type: _colorOvertime["default"], + animatable: false + }), _dec21 = property({ + type: _sizeOvertime["default"], + animatable: false + }), _dec22 = property({ + type: _velocityOvertime["default"], + animatable: false + }), _dec23 = property({ + type: _forceOvertime["default"], + animatable: false + }), _dec24 = property({ + type: _limitVelocityOvertime["default"], + animatable: false + }), _dec25 = property({ + type: _rotationOvertime["default"], + animatable: false + }), _dec26 = property({ + type: _textureAnimation["default"], + animatable: false + }), _dec27 = property({ + type: _trail["default"], + animatable: false + }), _dec28 = property({ + type: _enum.RenderMode, + animatable: false + }), _dec29 = property({ + animatable: false + }), _dec30 = property({ + animatable: false + }), _dec31 = property({ + type: _CCMesh["default"], + animatable: false + }), _dec32 = property({ + type: _CCMaterial["default"], + animatable: false + }), _dec33 = property({ + type: _CCMaterial["default"], + animatable: false + }), _dec(_class = _dec2(_class = _dec3(_class = executeInEditMode(_class = (_class2 = (function(_RenderComponent) { + _inheritsLoose(ParticleSystem3D, _RenderComponent); + function ParticleSystem3D() { + var _this2; + _this2 = _RenderComponent.call(this) || this; + _initializerDefineProperty(_this2, "duration", _descriptor, _assertThisInitialized(_this2)); + _initializerDefineProperty(_this2, "_capacity", _descriptor2, _assertThisInitialized(_this2)); + _initializerDefineProperty(_this2, "loop", _descriptor3, _assertThisInitialized(_this2)); + _initializerDefineProperty(_this2, "playOnAwake", _descriptor4, _assertThisInitialized(_this2)); + _initializerDefineProperty(_this2, "_prewarm", _descriptor5, _assertThisInitialized(_this2)); + _initializerDefineProperty(_this2, "_simulationSpace", _descriptor6, _assertThisInitialized(_this2)); + _initializerDefineProperty(_this2, "simulationSpeed", _descriptor7, _assertThisInitialized(_this2)); + _initializerDefineProperty(_this2, "startDelay", _descriptor8, _assertThisInitialized(_this2)); + _initializerDefineProperty(_this2, "startLifetime", _descriptor9, _assertThisInitialized(_this2)); + _initializerDefineProperty(_this2, "startColor", _descriptor10, _assertThisInitialized(_this2)); + _initializerDefineProperty(_this2, "scaleSpace", _descriptor11, _assertThisInitialized(_this2)); + _initializerDefineProperty(_this2, "startSize", _descriptor12, _assertThisInitialized(_this2)); + _initializerDefineProperty(_this2, "startSpeed", _descriptor13, _assertThisInitialized(_this2)); + _initializerDefineProperty(_this2, "startRotation", _descriptor14, _assertThisInitialized(_this2)); + _initializerDefineProperty(_this2, "gravityModifier", _descriptor15, _assertThisInitialized(_this2)); + _initializerDefineProperty(_this2, "rateOverTime", _descriptor16, _assertThisInitialized(_this2)); + _initializerDefineProperty(_this2, "rateOverDistance", _descriptor17, _assertThisInitialized(_this2)); + _initializerDefineProperty(_this2, "bursts", _descriptor18, _assertThisInitialized(_this2)); + _initializerDefineProperty(_this2, "_shapeModule", _descriptor19, _assertThisInitialized(_this2)); + _initializerDefineProperty(_this2, "_colorOverLifetimeModule", _descriptor20, _assertThisInitialized(_this2)); + _initializerDefineProperty(_this2, "_sizeOvertimeModule", _descriptor21, _assertThisInitialized(_this2)); + _initializerDefineProperty(_this2, "_velocityOvertimeModule", _descriptor22, _assertThisInitialized(_this2)); + _initializerDefineProperty(_this2, "_forceOvertimeModule", _descriptor23, _assertThisInitialized(_this2)); + _initializerDefineProperty(_this2, "_limitVelocityOvertimeModule", _descriptor24, _assertThisInitialized(_this2)); + _initializerDefineProperty(_this2, "_rotationOvertimeModule", _descriptor25, _assertThisInitialized(_this2)); + _initializerDefineProperty(_this2, "_textureAnimationModule", _descriptor26, _assertThisInitialized(_this2)); + _initializerDefineProperty(_this2, "_trailModule", _descriptor27, _assertThisInitialized(_this2)); + _initializerDefineProperty(_this2, "_renderMode", _descriptor28, _assertThisInitialized(_this2)); + _initializerDefineProperty(_this2, "_velocityScale", _descriptor29, _assertThisInitialized(_this2)); + _initializerDefineProperty(_this2, "_lengthScale", _descriptor30, _assertThisInitialized(_this2)); + _initializerDefineProperty(_this2, "_mesh", _descriptor31, _assertThisInitialized(_this2)); + _this2._isPlaying = void 0; + _this2._isPaused = void 0; + _this2._isStopped = void 0; + _this2._isEmitting = void 0; + _this2._time = void 0; + _this2._emitRateTimeCounter = void 0; + _this2._emitRateDistanceCounter = void 0; + _this2._oldWPos = void 0; + _this2._curWPos = void 0; + _this2._customData1 = void 0; + _this2._customData2 = void 0; + _this2._subEmitters = void 0; + _this2.rateOverTime.constant = 10; + _this2.startLifetime.constant = 5; + _this2.startSize.constant = 1; + _this2.startSpeed.constant = 5; + _this2._isPlaying = false; + _this2._isPaused = false; + _this2._isStopped = true; + _this2._isEmitting = false; + _this2._time = 0; + _this2._emitRateTimeCounter = 0; + _this2._emitRateDistanceCounter = 0; + _this2._oldWPos = new _valueTypes.Vec3(0, 0, 0); + _this2._curWPos = new _valueTypes.Vec3(0, 0, 0); + _this2._customData1 = new _valueTypes.Vec2(0, 0); + _this2._customData2 = new _valueTypes.Vec2(0, 0); + _this2._subEmitters = []; + return _this2; + } + var _proto = ParticleSystem3D.prototype; + _proto.onLoad = function onLoad() { + this._assembler.onInit(this); + this.shapeModule.onInit(this); + this.trailModule.onInit(this); + this.textureAnimationModule.onInit(this); + this._resetPosition(); + }; + _proto._onMaterialModified = function _onMaterialModified(index, material) { + this._assembler && this._assembler._onMaterialModified(index, material); + }; + _proto._onRebuildPSO = function _onRebuildPSO(index, material) { + this._assembler && this._assembler._onRebuildPSO(index, material); + }; + _proto.play = function play() { + this._isPaused && (this._isPaused = false); + this._isStopped && (this._isStopped = false); + this._isPlaying = true; + this._isEmitting = true; + this._resetPosition(); + this._prewarm && this._prewarmSystem(); + }; + _proto.pause = function pause() { + if (this._isStopped) { + console.warn("pause(): particle system is already stopped."); + return; + } + this._isPlaying && (this._isPlaying = false); + this._isPaused = true; + }; + _proto.stop = function stop() { + (this._isPlaying || this._isPaused) && this.clear(); + this._isPlaying && (this._isPlaying = false); + this._isPaused && (this._isPaused = false); + this._time = 0; + this._emitRateTimeCounter = 0; + this._emitRateDistanceCounter = 0; + this._isStopped = true; + }; + _proto.clear = function clear() { + if (this.enabledInHierarchy) { + this._assembler && this._assembler.clear(); + this.trailModule.clear(); + } + }; + _proto.getParticleCount = function getParticleCount() { + return this._assembler ? this._assembler.getParticleCount() : 0; + }; + _proto.setCustomData1 = function setCustomData1(x, y) { + _valueTypes.Vec2.set(this._customData1, x, y); + }; + _proto.setCustomData2 = function setCustomData2(x, y) { + _valueTypes.Vec2.set(this._customData2, x, y); + }; + _proto.onDestroy = function onDestroy() { + this._assembler.onDestroy(); + this.trailModule.destroy(); + }; + _proto.onEnable = function onEnable() { + _RenderComponent.prototype.onEnable.call(this); + this.playOnAwake && this.play(); + this._assembler.onEnable(); + this.trailModule.onEnable(); + }; + _proto.onDisable = function onDisable() { + _RenderComponent.prototype.onDisable.call(this); + this._assembler.onDisable(); + this.trailModule.onDisable(); + }; + _proto.update = function update(dt) { + var scaledDeltaTime = dt * this.simulationSpeed; + if (this._isPlaying) { + this._time += scaledDeltaTime; + this._emit(scaledDeltaTime); + 0 !== this._assembler._updateParticles(scaledDeltaTime) || this._isEmitting || this.stop(); + this._assembler.updateParticleBuffer(); + this.trailModule.enable && this.trailModule.updateTrailBuffer(); + } + }; + _proto.emit = function emit(count, dt) { + if (!this._assembler) return; + this._simulationSpace === _enum.Space.World && this.node.getWorldMatrix(_world_mat); + for (var i = 0; i < count; ++i) { + var particle = this._assembler._getFreeParticle(); + if (null === particle) return; + var rand = (0, _valueTypes.pseudoRandom)((0, _valueTypes.randomRangeInt)(0, _utils.INT_MAX)); + if (this.shapeModule.enable) this.shapeModule.emit(particle); else { + _valueTypes.Vec3.set(particle.position, 0, 0, 0); + _valueTypes.Vec3.copy(particle.velocity, _particleGeneralFunction.particleEmitZAxis); + } + this.textureAnimationModule.enable && this.textureAnimationModule.init(particle); + _valueTypes.Vec3.scale(particle.velocity, particle.velocity, this.startSpeed.evaluate(this._time / this.duration, rand)); + switch (this._simulationSpace) { + case _enum.Space.Local: + break; + + case _enum.Space.World: + _valueTypes.Vec3.transformMat4(particle.position, particle.position, _world_mat); + var worldRot = new _valueTypes.Quat(); + this.node.getWorldRotation(worldRot); + _valueTypes.Vec3.transformQuat(particle.velocity, particle.velocity, worldRot); + break; + + case _enum.Space.Custom: + } + _valueTypes.Vec3.copy(particle.ultimateVelocity, particle.velocity); + _valueTypes.Vec3.set(particle.rotation, 0, 0, this.startRotation.evaluate(this._time / this.duration, rand)); + _valueTypes.Vec3.set(particle.startSize, this.startSize.evaluate(this._time / this.duration, rand), 1, 1); + particle.startSize.y = particle.startSize.x; + _valueTypes.Vec3.copy(particle.size, particle.startSize); + particle.startColor.set(this.startColor.evaluate(this._time / this.duration, rand)); + particle.color.set(particle.startColor); + particle.startLifetime = this.startLifetime.evaluate(this._time / this.duration, rand) + dt; + particle.remainingLifetime = particle.startLifetime; + particle.randomSeed = (0, _valueTypes.randomRangeInt)(0, 233280); + this._assembler._setNewParticle(particle); + } + }; + _proto._prewarmSystem = function _prewarmSystem() { + this.startDelay.mode = _curveRange.Mode.Constant; + this.startDelay.constant = 0; + var dt = 1; + var cnt = this.duration / dt; + for (var i = 0; i < cnt; ++i) { + this._time += dt; + this._emit(dt); + this._assembler && this._assembler._updateParticles(dt); + } + }; + _proto._emit = function _emit(dt) { + var startDelay = this.startDelay.evaluate(0, 1); + if (this._time > startDelay) { + if (this._time > this.duration + startDelay && !this.loop) { + this._isEmitting = false; + return; + } + this._emitRateTimeCounter += this.rateOverTime.evaluate(this._time / this.duration, 1) * dt; + if (this._emitRateTimeCounter > 1 && this._isEmitting) { + var emitNum = Math.floor(this._emitRateTimeCounter); + this._emitRateTimeCounter -= emitNum; + this.emit(emitNum, dt); + } + this.node.getWorldPosition(this._curWPos); + var distance = _valueTypes.Vec3.distance(this._curWPos, this._oldWPos); + _valueTypes.Vec3.copy(this._oldWPos, this._curWPos); + this._emitRateDistanceCounter += distance * this.rateOverDistance.evaluate(this._time / this.duration, 1); + if (this._emitRateDistanceCounter > 1 && this._isEmitting) { + var _emitNum = Math.floor(this._emitRateDistanceCounter); + this._emitRateDistanceCounter -= _emitNum; + this.emit(_emitNum, dt); + } + for (var _iterator = _createForOfIteratorHelperLoose(this.bursts), _step; !(_step = _iterator()).done; ) { + var burst = _step.value; + burst.update(this, dt); + } + } + }; + _proto._activateMaterial = function _activateMaterial() {}; + _proto._resetPosition = function _resetPosition() { + this.node.getWorldPosition(this._oldWPos); + _valueTypes.Vec3.copy(this._curWPos, this._oldWPos); + }; + _proto.addSubEmitter = function addSubEmitter(subEmitter) { + this._subEmitters.push(subEmitter); + }; + _proto.removeSubEmitter = function removeSubEmitter(idx) { + this._subEmitters.splice(this._subEmitters.indexOf(idx), 1); + }; + _proto.addBurst = function addBurst(burst) { + this.bursts.push(burst); + }; + _proto.removeBurst = function removeBurst(idx) { + this.bursts.splice(this.bursts.indexOf(idx), 1); + }; + _proto._checkBacth = function _checkBacth() {}; + _createClass(ParticleSystem3D, [ { + key: "capacity", + get: function get() { + return this._capacity; + }, + set: function set(val) { + this._capacity = val; + this._assembler && this._assembler.setCapacity(this._capacity); + } + }, { + key: "prewarm", + get: function get() { + return this._prewarm; + }, + set: function set(val) { + true === val && false === this.loop; + this._prewarm = val; + } + }, { + key: "simulationSpace", + get: function get() { + return this._simulationSpace; + }, + set: function set(val) { + if (val !== this._simulationSpace) { + this._simulationSpace = val; + if (this._assembler) { + this._assembler._updateMaterialParams(); + this._assembler._updateTrailMaterial(); + } + } + } + }, { + key: "materials", + get: function get() { + return this._materials; + }, + set: function set(val) { + this._materials = val; + this._activateMaterial(); + } + }, { + key: "shapeModule", + get: function get() { + return this._shapeModule; + }, + set: function set(val) { + this._shapeModule = val; + this._shapeModule.onInit(this); + } + }, { + key: "colorOverLifetimeModule", + get: function get() { + return this._colorOverLifetimeModule; + }, + set: function set(val) { + this._colorOverLifetimeModule = val; + } + }, { + key: "sizeOvertimeModule", + get: function get() { + return this._sizeOvertimeModule; + }, + set: function set(val) { + this._sizeOvertimeModule = val; + } + }, { + key: "velocityOvertimeModule", + get: function get() { + return this._velocityOvertimeModule; + }, + set: function set(val) { + this._velocityOvertimeModule = val; + } + }, { + key: "forceOvertimeModule", + get: function get() { + return this._forceOvertimeModule; + }, + set: function set(val) { + this._forceOvertimeModule = val; + } + }, { + key: "limitVelocityOvertimeModule", + get: function get() { + return this._limitVelocityOvertimeModule; + }, + set: function set(val) { + this._limitVelocityOvertimeModule = val; + } + }, { + key: "rotationOvertimeModule", + get: function get() { + return this._rotationOvertimeModule; + }, + set: function set(val) { + this._rotationOvertimeModule = val; + } + }, { + key: "textureAnimationModule", + get: function get() { + return this._textureAnimationModule; + }, + set: function set(val) { + this._textureAnimationModule = val; + this._textureAnimationModule.onInit(this); + } + }, { + key: "trailModule", + get: function get() { + return this._trailModule; + }, + set: function set(val) { + this._trailModule = val; + this._trailModule.onInit(this); + } + }, { + key: "renderMode", + get: function get() { + return this._renderMode; + }, + set: function set(val) { + if (this._renderMode === val) return; + this._renderMode = val; + if (this._assembler) { + this._assembler._setVertexAttrib(); + this._assembler._updateModel(); + this._assembler._updateMaterialParams(); + } + } + }, { + key: "velocityScale", + get: function get() { + return this._velocityScale; + }, + set: function set(val) { + this._velocityScale = val; + this._assembler && this._assembler._updateMaterialParams(); + } + }, { + key: "lengthScale", + get: function get() { + return this._lengthScale; + }, + set: function set(val) { + this._lengthScale = val; + this._assembler && this._assembler._updateMaterialParams(); + } + }, { + key: "mesh", + get: function get() { + return this._mesh; + }, + set: function set(val) { + this._mesh = val; + this._assembler && this._assembler._updateModel(); + } + }, { + key: "particleMaterial", + get: function get() { + return this.getMaterial(0); + }, + set: function set(val) { + this.setMaterial(0, val); + this._onMaterialModified(0, val); + } + }, { + key: "trailMaterial", + get: function get() { + return this.getMaterial(1); + }, + set: function set(val) { + this.setMaterial(1, val); + this._onMaterialModified(1, val); + } + }, { + key: "isPlaying", + get: function get() { + return this._isPlaying; + } + }, { + key: "isPaused", + get: function get() { + return this._isPaused; + } + }, { + key: "isStopped", + get: function get() { + return this._isStopped; + } + }, { + key: "isEmitting", + get: function get() { + return this._isEmitting; + } + }, { + key: "time", + get: function get() { + return this._time; + } + } ]); + return ParticleSystem3D; + })(RenderComponent), _descriptor = _applyDecoratedDescriptor(_class2.prototype, "duration", [ property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return 5; + } + }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "_capacity", [ property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return 100; + } + }), _applyDecoratedDescriptor(_class2.prototype, "capacity", [ property ], Object.getOwnPropertyDescriptor(_class2.prototype, "capacity"), _class2.prototype), + _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "loop", [ property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return true; + } + }), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "playOnAwake", [ _dec4 ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return true; + } + }), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, "_prewarm", [ property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return false; + } + }), _applyDecoratedDescriptor(_class2.prototype, "prewarm", [ _dec5 ], Object.getOwnPropertyDescriptor(_class2.prototype, "prewarm"), _class2.prototype), + _descriptor6 = _applyDecoratedDescriptor(_class2.prototype, "_simulationSpace", [ property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return _enum.Space.Local; + } + }), _applyDecoratedDescriptor(_class2.prototype, "simulationSpace", [ _dec6 ], Object.getOwnPropertyDescriptor(_class2.prototype, "simulationSpace"), _class2.prototype), + _descriptor7 = _applyDecoratedDescriptor(_class2.prototype, "simulationSpeed", [ property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return 1; + } + }), _descriptor8 = _applyDecoratedDescriptor(_class2.prototype, "startDelay", [ _dec7 ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new _curveRange["default"](); + } + }), _descriptor9 = _applyDecoratedDescriptor(_class2.prototype, "startLifetime", [ _dec8 ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new _curveRange["default"](); + } + }), _descriptor10 = _applyDecoratedDescriptor(_class2.prototype, "startColor", [ _dec9 ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new _gradientRange["default"](); + } + }), _descriptor11 = _applyDecoratedDescriptor(_class2.prototype, "scaleSpace", [ _dec10 ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return _enum.Space.Local; + } + }), _descriptor12 = _applyDecoratedDescriptor(_class2.prototype, "startSize", [ _dec11 ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new _curveRange["default"](); + } + }), _descriptor13 = _applyDecoratedDescriptor(_class2.prototype, "startSpeed", [ _dec12 ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new _curveRange["default"](); + } + }), _descriptor14 = _applyDecoratedDescriptor(_class2.prototype, "startRotation", [ _dec13 ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new _curveRange["default"](); + } + }), _descriptor15 = _applyDecoratedDescriptor(_class2.prototype, "gravityModifier", [ _dec14 ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new _curveRange["default"](); + } + }), _descriptor16 = _applyDecoratedDescriptor(_class2.prototype, "rateOverTime", [ _dec15 ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new _curveRange["default"](); + } + }), _descriptor17 = _applyDecoratedDescriptor(_class2.prototype, "rateOverDistance", [ _dec16 ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new _curveRange["default"](); + } + }), _descriptor18 = _applyDecoratedDescriptor(_class2.prototype, "bursts", [ _dec17 ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new Array(); + } + }), _applyDecoratedDescriptor(_class2.prototype, "materials", [ _dec18 ], Object.getOwnPropertyDescriptor(_class2.prototype, "materials"), _class2.prototype), + _descriptor19 = _applyDecoratedDescriptor(_class2.prototype, "_shapeModule", [ property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new _shapeModule["default"](); + } + }), _applyDecoratedDescriptor(_class2.prototype, "shapeModule", [ _dec19 ], Object.getOwnPropertyDescriptor(_class2.prototype, "shapeModule"), _class2.prototype), + _descriptor20 = _applyDecoratedDescriptor(_class2.prototype, "_colorOverLifetimeModule", [ property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new _colorOvertime["default"](); + } + }), _applyDecoratedDescriptor(_class2.prototype, "colorOverLifetimeModule", [ _dec20 ], Object.getOwnPropertyDescriptor(_class2.prototype, "colorOverLifetimeModule"), _class2.prototype), + _descriptor21 = _applyDecoratedDescriptor(_class2.prototype, "_sizeOvertimeModule", [ property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new _sizeOvertime["default"](); + } + }), _applyDecoratedDescriptor(_class2.prototype, "sizeOvertimeModule", [ _dec21 ], Object.getOwnPropertyDescriptor(_class2.prototype, "sizeOvertimeModule"), _class2.prototype), + _descriptor22 = _applyDecoratedDescriptor(_class2.prototype, "_velocityOvertimeModule", [ property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new _velocityOvertime["default"](); + } + }), _applyDecoratedDescriptor(_class2.prototype, "velocityOvertimeModule", [ _dec22 ], Object.getOwnPropertyDescriptor(_class2.prototype, "velocityOvertimeModule"), _class2.prototype), + _descriptor23 = _applyDecoratedDescriptor(_class2.prototype, "_forceOvertimeModule", [ property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new _forceOvertime["default"](); + } + }), _applyDecoratedDescriptor(_class2.prototype, "forceOvertimeModule", [ _dec23 ], Object.getOwnPropertyDescriptor(_class2.prototype, "forceOvertimeModule"), _class2.prototype), + _descriptor24 = _applyDecoratedDescriptor(_class2.prototype, "_limitVelocityOvertimeModule", [ property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new _limitVelocityOvertime["default"](); + } + }), _applyDecoratedDescriptor(_class2.prototype, "limitVelocityOvertimeModule", [ _dec24 ], Object.getOwnPropertyDescriptor(_class2.prototype, "limitVelocityOvertimeModule"), _class2.prototype), + _descriptor25 = _applyDecoratedDescriptor(_class2.prototype, "_rotationOvertimeModule", [ property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new _rotationOvertime["default"](); + } + }), _applyDecoratedDescriptor(_class2.prototype, "rotationOvertimeModule", [ _dec25 ], Object.getOwnPropertyDescriptor(_class2.prototype, "rotationOvertimeModule"), _class2.prototype), + _descriptor26 = _applyDecoratedDescriptor(_class2.prototype, "_textureAnimationModule", [ property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new _textureAnimation["default"](); + } + }), _applyDecoratedDescriptor(_class2.prototype, "textureAnimationModule", [ _dec26 ], Object.getOwnPropertyDescriptor(_class2.prototype, "textureAnimationModule"), _class2.prototype), + _descriptor27 = _applyDecoratedDescriptor(_class2.prototype, "_trailModule", [ property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new _trail["default"](); + } + }), _applyDecoratedDescriptor(_class2.prototype, "trailModule", [ _dec27 ], Object.getOwnPropertyDescriptor(_class2.prototype, "trailModule"), _class2.prototype), + _descriptor28 = _applyDecoratedDescriptor(_class2.prototype, "_renderMode", [ property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return _enum.RenderMode.Billboard; + } + }), _applyDecoratedDescriptor(_class2.prototype, "renderMode", [ _dec28 ], Object.getOwnPropertyDescriptor(_class2.prototype, "renderMode"), _class2.prototype), + _descriptor29 = _applyDecoratedDescriptor(_class2.prototype, "_velocityScale", [ property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return 1; + } + }), _applyDecoratedDescriptor(_class2.prototype, "velocityScale", [ _dec29 ], Object.getOwnPropertyDescriptor(_class2.prototype, "velocityScale"), _class2.prototype), + _descriptor30 = _applyDecoratedDescriptor(_class2.prototype, "_lengthScale", [ property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return 1; + } + }), _applyDecoratedDescriptor(_class2.prototype, "lengthScale", [ _dec30 ], Object.getOwnPropertyDescriptor(_class2.prototype, "lengthScale"), _class2.prototype), + _descriptor31 = _applyDecoratedDescriptor(_class2.prototype, "_mesh", [ property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return null; + } + }), _applyDecoratedDescriptor(_class2.prototype, "mesh", [ _dec31 ], Object.getOwnPropertyDescriptor(_class2.prototype, "mesh"), _class2.prototype), + _applyDecoratedDescriptor(_class2.prototype, "particleMaterial", [ _dec32 ], Object.getOwnPropertyDescriptor(_class2.prototype, "particleMaterial"), _class2.prototype), + _applyDecoratedDescriptor(_class2.prototype, "trailMaterial", [ _dec33 ], Object.getOwnPropertyDescriptor(_class2.prototype, "trailMaterial"), _class2.prototype), + _class2)) || _class) || _class) || _class) || _class); + exports["default"] = ParticleSystem3D; + false; + cc.ParticleSystem3D = ParticleSystem3D; + module.exports = exports["default"]; + }), { + "../../assets/material/CCMaterial": 125, + "../../components/CCRenderComponent": 161, + "../../mesh/CCMesh": 208, + "../../platform/CCClassDecorator": 241, + "../../value-types": 340, + "../../value-types/utils": 347, + "./animator/color-overtime": 31, + "./animator/curve-range": 32, + "./animator/force-overtime": 33, + "./animator/gradient-range": 34, + "./animator/limit-velocity-overtime": 36, + "./animator/rotation-overtime": 37, + "./animator/size-overtime": 38, + "./animator/texture-animation": 39, + "./animator/velocity-overtime": 40, + "./burst": 41, + "./emitter/shape-module": 43, + "./enum": 44, + "./particle-general-function": 45, + "./renderer/trail": 50 + } ], + 47: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _valueTypes = require("../../value-types"); + var Particle = function Particle(particleSystem) { + this.particleSystem = null; + this.position = null; + this.velocity = null; + this.animatedVelocity = null; + this.ultimateVelocity = null; + this.angularVelocity = null; + this.axisOfRotation = null; + this.rotation = null; + this.startSize = null; + this.size = null; + this.startColor = null; + this.color = cc.Color.WHITE; + this.randomSeed = null; + this.remainingLifetime = null; + this.startLifetime = null; + this.emitAccumulator0 = null; + this.emitAccumulator1 = null; + this.frameIndex = null; + this.particleSystem = particleSystem; + this.position = new _valueTypes.Vec3(0, 0, 0); + this.velocity = new _valueTypes.Vec3(0, 0, 0); + this.animatedVelocity = new _valueTypes.Vec3(0, 0, 0); + this.ultimateVelocity = new _valueTypes.Vec3(0, 0, 0); + this.angularVelocity = new _valueTypes.Vec3(0, 0, 0); + this.axisOfRotation = new _valueTypes.Vec3(0, 0, 0); + this.rotation = new _valueTypes.Vec3(0, 0, 0); + this.startSize = new _valueTypes.Vec3(0, 0, 0); + this.size = new _valueTypes.Vec3(0, 0, 0); + this.startColor = cc.Color.WHITE.clone(); + this.color = cc.Color.WHITE.clone(); + this.randomSeed = 0; + this.remainingLifetime = 0; + this.startLifetime = 0; + this.emitAccumulator0 = 0; + this.emitAccumulator1 = 0; + this.frameIndex = 0; + }; + exports["default"] = Particle; + module.exports = exports["default"]; + }), { + "../../value-types": 340 + } ], + 48: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _gfx = _interopRequireDefault(require("../../../../renderer/gfx")); + var _inputAssembler = _interopRequireDefault(require("../../../../renderer/core/input-assembler")); + var _meshData = require("../../../mesh/mesh-data"); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + var renderer = require("../../../renderer"); + var ParticleBatchModel = (function() { + function ParticleBatchModel() { + this._capacity = 0; + this._vertFormat = null; + this._vertAttrsFloatCount = 0; + this._mesh = null; + this._vertCount = 0; + this._indexCount = 0; + this._material = null; + this._capacity = 0; + this._vertFormat = null; + this._vertAttrsFloatCount = 0; + this._mesh = null; + this._subDatas = []; + this._subMeshes = []; + } + var _proto = ParticleBatchModel.prototype; + _proto.setCapacity = function setCapacity(capacity) { + var capChanged = this._capacity !== capacity; + this._capacity = capacity; + this._inited && capChanged && this._recreateBuffer(); + }; + _proto.setVertexAttributes = function setVertexAttributes(mesh, vfmt) { + if (this._mesh === mesh && this._vertFormat === vfmt) return; + this._mesh = mesh; + this._vertFormat = vfmt; + this._vertAttrsFloatCount = this._vertFormat._bytes / 4; + this._createParticleData(); + this._inited = true; + }; + _proto._recreateBuffer = function _recreateBuffer() { + this._createParticleData(); + }; + _proto._createParticleData = function _createParticleData() { + this.destroyIAData(); + this._vertCount = 4; + this._indexCount = 6; + var vbData = null; + var ibData = null; + var vertSize = this._vertFormat._bytes; + if (this._mesh) { + var subData = this._mesh._subDatas[0]; + this._vertCount = subData.vData.byteLength / subData.vfm._bytes; + this._indexCount = subData.iData.byteLength / 2; + vbData = new Float32Array(vertSize * this._capacity * this._vertCount / 4); + ibData = new Uint16Array(this._capacity * this._indexCount); + var posEle = this._vertFormat.element(_gfx["default"].ATTR_TEX_COORD3); + var normalEle = this._vertFormat.element(_gfx["default"].ATTR_NORMAL); + var uvEle = this._vertFormat.element(_gfx["default"].ATTR_TEX_COORD); + var colorEle = this._vertFormat.element(_gfx["default"].ATTR_COLOR1); + this._mesh.copyAttribute(0, _gfx["default"].ATTR_POSITION, vbData.buffer, vertSize, posEle.offset); + this._mesh.copyAttribute(0, _gfx["default"].ATTR_NORMAL, vbData.buffer, vertSize, normalEle.offset); + this._mesh.copyAttribute(0, _gfx["default"].ATTR_UV0, vbData.buffer, vertSize, uvEle.offset); + if (!this._mesh.copyAttribute(0, _gfx["default"].ATTR_COLOR, vbData.buffer, vertSize, colorEle.offset)) { + var vb = new Uint32Array(vbData.buffer); + for (var i = 0; i < this._vertCount; ++i) vb[i * this._vertAttrsFloatCount + colorEle.offset / 4] = cc.Color.WHITE._val; + } + var vbFloatArray = new Float32Array(vbData.buffer); + for (var i = 1; i < this._capacity; i++) vbFloatArray.copyWithin(i * vertSize * this._vertCount / 4, 0, vertSize * this._vertCount / 4); + this._mesh.copyIndices(0, ibData); + for (var i = 1; i < this._capacity; i++) for (var j = 0; j < this._indexCount; j++) ibData[i * this._indexCount + j] = ibData[j] + i * this._vertCount; + } else { + vbData = new Float32Array(vertSize * this._capacity * this._vertCount / 4); + ibData = new Uint16Array(this._capacity * this._indexCount); + var dst = 0; + for (var i = 0; i < this._capacity; ++i) { + var baseIdx = 4 * i; + ibData[dst++] = baseIdx; + ibData[dst++] = baseIdx + 1; + ibData[dst++] = baseIdx + 2; + ibData[dst++] = baseIdx + 3; + ibData[dst++] = baseIdx + 2; + ibData[dst++] = baseIdx + 1; + } + } + var meshData = new _meshData.MeshData(); + meshData.vData = vbData; + meshData.iData = ibData; + meshData.vfm = this._vertFormat; + meshData.vDirty = true; + meshData.iDirty = true; + meshData.enable = true; + this._subDatas[0] = meshData; + false; + var _vb = new _gfx["default"].VertexBuffer(renderer.device, this._vertFormat, _gfx["default"].USAGE_DYNAMIC, vbData); + var ib = new _gfx["default"].IndexBuffer(renderer.device, _gfx["default"].INDEX_FMT_UINT16, _gfx["default"].USAGE_STATIC, ibData, ibData.length); + this._subMeshes[0] = new _inputAssembler["default"](_vb, ib); + }; + _proto.createTrailData = function createTrailData(vfmt, num) { + if (this._subDatas[1]) return; + var vertSize = vfmt._bytes; + var vBuffer = new ArrayBuffer(vertSize * (num + 1) * 2); + var ibData = new Uint16Array(6 * num); + var meshData = new _meshData.MeshData(); + meshData.vData = new Float32Array(vBuffer); + meshData.iData = ibData; + meshData.vfm = vfmt; + meshData.vDirty = true; + meshData.iDirty = true; + meshData.enable = true; + this._subDatas[1] = meshData; + false; + var vb = new _gfx["default"].VertexBuffer(renderer.device, vfmt, _gfx["default"].USAGE_DYNAMIC, vBuffer); + var ib = new _gfx["default"].IndexBuffer(renderer.device, _gfx["default"].INDEX_FMT_UINT16, _gfx["default"].USAGE_DYNAMIC, ibData, 6 * num); + this._subMeshes[1] = new _inputAssembler["default"](vb, ib); + }; + _proto.setModelMaterial = function setModelMaterial(mat) { + this._material = mat; + }; + _proto.addParticleVertexData = function addParticleVertexData(index, pvdata) { + var subData = this._subDatas[0]; + var vData = subData.getVData(); + var uintVData = subData.getVData(Uint32Array); + if (this._mesh) for (var i = 0; i < this._vertCount; i++) { + var _offset = (index * this._vertCount + i) * this._vertAttrsFloatCount; + vData[_offset++] = pvdata[0].x; + vData[_offset++] = pvdata[0].y; + vData[_offset++] = pvdata[0].z; + _offset += 2; + vData[_offset++] = pvdata[1].z; + vData[_offset++] = pvdata[2].x; + vData[_offset++] = pvdata[2].y; + vData[_offset++] = pvdata[2].z; + vData[_offset++] = pvdata[3].x; + vData[_offset++] = pvdata[3].y; + vData[_offset++] = pvdata[3].z; + uintVData[_offset++] = pvdata[4]; + } else { + var offset = index * this._vertAttrsFloatCount; + vData[offset++] = pvdata[0].x; + vData[offset++] = pvdata[0].y; + vData[offset++] = pvdata[0].z; + vData[offset++] = pvdata[1].x; + vData[offset++] = pvdata[1].y; + vData[offset++] = pvdata[1].z; + vData[offset++] = pvdata[2].x; + vData[offset++] = pvdata[2].y; + vData[offset++] = pvdata[2].z; + vData[offset++] = pvdata[3].x; + vData[offset++] = pvdata[3].y; + vData[offset++] = pvdata[3].z; + uintVData[offset++] = pvdata[4]; + if (pvdata[5]) { + vData[offset++] = pvdata[5].x; + vData[offset++] = pvdata[5].y; + vData[offset++] = pvdata[5].z; + } + } + }; + _proto._uploadData = function _uploadData() { + var subDatas = this._subDatas; + var subMeshes = this._subMeshes; + for (var i = 0, len = subDatas.length; i < len; i++) { + var subData = subDatas[i]; + var subMesh = subMeshes[i]; + if (subData.vDirty) { + var vBuffer = subMesh._vertexBuffer, vData = subData.vData; + vBuffer.update(0, vData); + subData.vDirty = false; + } + if (subData.iDirty) { + var iBuffer = subMesh._indexBuffer, iData = subData.iData; + iBuffer.update(0, iData); + subData.iDirty = false; + } + } + }; + _proto.updateIA = function updateIA(index, count, vDirty, iDirty) { + false; + this._subMeshes[index]._count = count; + var subData = this._subDatas[index]; + subData.vDirty = vDirty; + subData.iDirty = iDirty; + }; + _proto.clear = function clear() { + var subMesh = this._subMeshes[0]; + subMesh && (subMesh.indexCount = 0); + }; + _proto.destroy = function destroy() { + this._subDatas.length = 0; + var subMeshes = this._subMeshes; + for (var i = 0, len = subMeshes.length; i < len; i++) { + var vb = subMeshes[i]._vertexBuffer; + vb && vb.destroy(); + var ib = subMeshes[i]._indexBuffer; + ib && ib.destroy(); + } + subMeshes.length = 0; + }; + _proto.destroyIAData = function destroyIAData() { + if (this._subMeshes[0]) { + this._subMeshes[0]._vertexBuffer.destroy(); + this._subMeshes[0]._indexBuffer.destroy(); + this._subMeshes[0] = null; + } + this._subDatas[0] = null; + }; + return ParticleBatchModel; + })(); + exports["default"] = ParticleBatchModel; + module.exports = exports["default"]; + }), { + "../../../../renderer/core/input-assembler": 363, + "../../../../renderer/gfx": 373, + "../../../mesh/mesh-data": 211, + "../../../renderer": 272 + } ], + 49: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _valueTypes = require("../../../value-types"); + var _gfx = _interopRequireDefault(require("../../../../renderer/gfx")); + var _particleBatchModel = _interopRequireDefault(require("./particle-batch-model")); + var _materialVariant = _interopRequireDefault(require("../../../assets/material/material-variant")); + var _recyclePool = _interopRequireDefault(require("../../../../renderer/memop/recycle-pool")); + var _enum = require("../enum"); + var _particle = _interopRequireDefault(require("../particle")); + var _assembler = _interopRequireDefault(require("../../../renderer/assembler")); + var _particleSystem3d = _interopRequireDefault(require("../particle-system-3d")); + var _dec, _class; + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + _setPrototypeOf(subClass, superClass); + } + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + return _setPrototypeOf(o, p); + } + var _require = require("../../../platform/CCClassDecorator"), ccclass = _require.ccclass, property = _require.property; + var _tempAttribUV = new _valueTypes.Vec3(); + var _tempAttribUV0 = new _valueTypes.Vec2(); + var _tempAttribColor = new _valueTypes.Vec4(); + var _tempWorldTrans = new _valueTypes.Mat4(); + var _uvs = [ 0, 0, 1, 0, 0, 1, 1, 1 ]; + var CC_USE_WORLD_SPACE = "CC_USE_WORLD_SPACE"; + var CC_USE_BILLBOARD = "CC_USE_BILLBOARD"; + var CC_USE_STRETCHED_BILLBOARD = "CC_USE_STRETCHED_BILLBOARD"; + var CC_USE_HORIZONTAL_BILLBOARD = "CC_USE_HORIZONTAL_BILLBOARD"; + var CC_USE_VERTICAL_BILLBOARD = "CC_USE_VERTICAL_BILLBOARD"; + var CC_USE_MESH = "CC_USE_MESH"; + var vfmtNormal = new _gfx["default"].VertexFormat([ { + name: _gfx["default"].ATTR_POSITION, + type: _gfx["default"].ATTR_TYPE_FLOAT32, + num: 3 + }, { + name: _gfx["default"].ATTR_TEX_COORD, + type: _gfx["default"].ATTR_TYPE_FLOAT32, + num: 3 + }, { + name: _gfx["default"].ATTR_TEX_COORD1, + type: _gfx["default"].ATTR_TYPE_FLOAT32, + num: 3 + }, { + name: _gfx["default"].ATTR_TEX_COORD2, + type: _gfx["default"].ATTR_TYPE_FLOAT32, + num: 3 + }, { + name: _gfx["default"].ATTR_COLOR, + type: _gfx["default"].ATTR_TYPE_UINT8, + num: 4, + normalize: true + } ]); + vfmtNormal.name = "vfmtNormal"; + var vfmtStretch = new _gfx["default"].VertexFormat([ { + name: _gfx["default"].ATTR_POSITION, + type: _gfx["default"].ATTR_TYPE_FLOAT32, + num: 3 + }, { + name: _gfx["default"].ATTR_TEX_COORD, + type: _gfx["default"].ATTR_TYPE_FLOAT32, + num: 3 + }, { + name: _gfx["default"].ATTR_TEX_COORD1, + type: _gfx["default"].ATTR_TYPE_FLOAT32, + num: 3 + }, { + name: _gfx["default"].ATTR_TEX_COORD2, + type: _gfx["default"].ATTR_TYPE_FLOAT32, + num: 3 + }, { + name: _gfx["default"].ATTR_COLOR, + type: _gfx["default"].ATTR_TYPE_UINT8, + num: 4, + normalize: true + }, { + name: _gfx["default"].ATTR_COLOR1, + type: _gfx["default"].ATTR_TYPE_FLOAT32, + num: 3 + } ]); + vfmtStretch.name = "vfmtStretch"; + var vfmtMesh = new _gfx["default"].VertexFormat([ { + name: _gfx["default"].ATTR_POSITION, + type: _gfx["default"].ATTR_TYPE_FLOAT32, + num: 3 + }, { + name: _gfx["default"].ATTR_TEX_COORD, + type: _gfx["default"].ATTR_TYPE_FLOAT32, + num: 3 + }, { + name: _gfx["default"].ATTR_TEX_COORD1, + type: _gfx["default"].ATTR_TYPE_FLOAT32, + num: 3 + }, { + name: _gfx["default"].ATTR_TEX_COORD2, + type: _gfx["default"].ATTR_TYPE_FLOAT32, + num: 3 + }, { + name: _gfx["default"].ATTR_COLOR, + type: _gfx["default"].ATTR_TYPE_UINT8, + num: 4, + normalize: true + }, { + name: _gfx["default"].ATTR_TEX_COORD3, + type: _gfx["default"].ATTR_TYPE_FLOAT32, + num: 3 + }, { + name: _gfx["default"].ATTR_NORMAL, + type: _gfx["default"].ATTR_TYPE_FLOAT32, + num: 3 + }, { + name: _gfx["default"].ATTR_COLOR1, + type: _gfx["default"].ATTR_TYPE_UINT8, + num: 4, + normalize: true + } ]); + vfmtMesh.name = "vfmtMesh"; + var ParticleSystem3DAssembler = (_dec = ccclass("cc.ParticleSystem3DAssembler"), + _dec(_class = (function(_Assembler) { + _inheritsLoose(ParticleSystem3DAssembler, _Assembler); + function ParticleSystem3DAssembler() { + var _this; + _this = _Assembler.call(this) || this; + _this._defines = null; + _this._trailDefines = null; + _this._model = null; + _this.frameTile_velLenScale = null; + _this.attrs = []; + _this._vertFormat = []; + _this._particleSystem = null; + _this._particles = null; + _this._defaultMat = null; + _this._isAssetReady = false; + _this._defaultTrailMat = null; + _this._customProperties = null; + _this._node_scale = null; + _this._model = null; + _this.frameTile_velLenScale = cc.v4(1, 1, 0, 0); + _this._node_scale = cc.v4(); + _this.attrs = new Array(5); + _this._trailDefines = { + CC_USE_WORLD_SPACE: true + }; + return _this; + } + var _proto = ParticleSystem3DAssembler.prototype; + _proto.onInit = function onInit(ps) { + var _this2 = this; + this._particleSystem = ps; + this._particles = new _recyclePool["default"](function() { + return new _particle["default"](_this2); + }, 16); + this._setVertexAttrib(); + this.onEnable(); + this._updateModel(); + this._updateMaterialParams(); + this._updateTrailMaterial(); + }; + _proto.onEnable = function onEnable() { + if (!this._particleSystem) return; + null == this._model && (this._model = new _particleBatchModel["default"]()); + this._model.inited || this._model.setCapacity(this._particleSystem.capacity); + this._model.enabled = this._particleSystem.enabledInHierarchy; + }; + _proto.onDisable = function onDisable() { + this._model && (this._model.enabled = this._particleSystem.enabledInHierarchy); + }; + _proto.onDestroy = function onDestroy() { + this._model = null; + }; + _proto.clear = function clear() { + this._particles.reset(); + this.updateParticleBuffer(); + }; + _proto._getFreeParticle = function _getFreeParticle() { + if (this._particles.length >= this._particleSystem.capacity) return null; + return this._particles.add(); + }; + _proto._setNewParticle = function _setNewParticle(p) {}; + _proto._updateParticles = function _updateParticles(dt) { + this._particleSystem.node.getWorldMatrix(_tempWorldTrans); + switch (this._particleSystem.scaleSpace) { + case _enum.Space.Local: + this._particleSystem.node.getScale(this._node_scale); + break; + + case _enum.Space.World: + this._particleSystem.node.getWorldScale(this._node_scale); + } + var material = this._particleSystem.materials[0]; + var mat = material ? this._particleSystem.particleMaterial : this._defaultMat; + mat.setProperty("scale", this._node_scale); + this._particleSystem.velocityOvertimeModule.enable && this._particleSystem.velocityOvertimeModule.update(this._particleSystem._simulationSpace, _tempWorldTrans); + this._particleSystem.forceOvertimeModule.enable && this._particleSystem.forceOvertimeModule.update(this._particleSystem._simulationSpace, _tempWorldTrans); + this._particleSystem.trailModule.enable && this._particleSystem.trailModule.update(); + for (var i = 0; i < this._particles.length; ++i) { + var p = this._particles.data[i]; + p.remainingLifetime -= dt; + _valueTypes.Vec3.set(p.animatedVelocity, 0, 0, 0); + if (p.remainingLifetime < 0) { + this._particleSystem.trailModule.enable && this._particleSystem.trailModule.removeParticle(p); + this._particles.remove(i); + --i; + continue; + } + p.velocity.y -= 9.8 * this._particleSystem.gravityModifier.evaluate(1 - p.remainingLifetime / p.startLifetime, p.randomSeed) * dt; + this._particleSystem.sizeOvertimeModule.enable && this._particleSystem.sizeOvertimeModule.animate(p); + this._particleSystem.colorOverLifetimeModule.enable && this._particleSystem.colorOverLifetimeModule.animate(p); + this._particleSystem.forceOvertimeModule.enable && this._particleSystem.forceOvertimeModule.animate(p, dt); + this._particleSystem.velocityOvertimeModule.enable ? this._particleSystem.velocityOvertimeModule.animate(p) : _valueTypes.Vec3.copy(p.ultimateVelocity, p.velocity); + this._particleSystem.limitVelocityOvertimeModule.enable && this._particleSystem.limitVelocityOvertimeModule.animate(p); + this._particleSystem.rotationOvertimeModule.enable && this._particleSystem.rotationOvertimeModule.animate(p, dt); + this._particleSystem.textureAnimationModule.enable && this._particleSystem.textureAnimationModule.animate(p); + _valueTypes.Vec3.scaleAndAdd(p.position, p.position, p.ultimateVelocity, dt); + this._particleSystem.trailModule.enable && this._particleSystem.trailModule.animate(p, dt); + } + return this._particles.length; + }; + _proto.updateParticleBuffer = function updateParticleBuffer() { + var idx = 0; + var uploadVel = this._particleSystem.renderMode === _enum.RenderMode.StrecthedBillboard; + for (var i = 0; i < this._particles.length; ++i) { + var p = this._particles.data[i]; + var fi = 0; + this._particleSystem.textureAnimationModule.enable && (fi = p.frameIndex); + idx = 4 * i; + var attrNum = 0; + if (this._particleSystem.renderMode !== _enum.RenderMode.Mesh) for (var j = 0; j < 4; ++j) { + attrNum = 0; + this.attrs[attrNum++] = p.position; + _tempAttribUV.x = _uvs[2 * j]; + _tempAttribUV.y = _uvs[2 * j + 1]; + _tempAttribUV.z = fi; + this.attrs[attrNum++] = _tempAttribUV; + this.attrs[attrNum++] = p.size; + this.attrs[attrNum++] = p.rotation; + this.attrs[attrNum++] = p.color._val; + this.attrs[attrNum++] = uploadVel ? p.ultimateVelocity : null; + this._model.addParticleVertexData(idx++, this.attrs); + } else { + attrNum = 0; + this.attrs[attrNum++] = p.position; + _tempAttribUV.z = fi; + this.attrs[attrNum++] = _tempAttribUV; + this.attrs[attrNum++] = p.size; + this.attrs[attrNum++] = p.rotation; + this.attrs[attrNum++] = p.color._val; + this._model.addParticleVertexData(i, this.attrs); + } + } + this.updateIA(0, this._particles.length * this._model._indexCount, true); + }; + _proto.updateShaderUniform = function updateShaderUniform() {}; + _proto.updateIA = function updateIA(index, count, vDirty, iDirty) { + if (!this._model) return; + this._model.updateIA(index, count, vDirty, iDirty); + }; + _proto.getParticleCount = function getParticleCount() { + return this._particles.data.length; + }; + _proto._onMaterialModified = function _onMaterialModified(index, material) { + if (0 === index) { + this._updateModel(); + this._updateMaterialParams(); + } else this._updateTrailMaterial(); + }; + _proto._onRebuildPSO = function _onRebuildPSO(index, material) { + this._model && 0 === index && this._model.setModelMaterial(material); + this._particleSystem.trailModule._trailModel && 1 === index && this._particleSystem.trailModule._trailModel.setModelMaterial(material); + }; + _proto._ensureLoadMesh = function _ensureLoadMesh() { + this._particleSystem.mesh && !this._particleSystem.mesh.loaded && cc.assetManager.postLoadNative(this._particleSystem.mesh); + }; + _proto.setCapacity = function setCapacity(capacity) { + if (!this._model) return; + this._model.setCapacity(capacity); + }; + _proto._setVertexAttrib = function _setVertexAttrib() { + switch (this._particleSystem.renderMode) { + case _enum.RenderMode.StrecthedBillboard: + this._vertFormat = vfmtStretch; + break; + + case _enum.RenderMode.Mesh: + this._vertFormat = vfmtMesh; + break; + + default: + this._vertFormat = vfmtNormal; + } + }; + _proto._updateMaterialParams = function _updateMaterialParams() { + if (!this._particleSystem) return; + var mat = this._particleSystem.materials[0]; + mat = null == mat && null == this._defaultMat ? this._defaultMat = _materialVariant["default"].createWithBuiltin("3d-particle", this) : _materialVariant["default"].create(mat, this._particleSystem); + mat = mat || this._defaultMat; + this._particleSystem._simulationSpace === _enum.Space.World ? mat.define(CC_USE_WORLD_SPACE, true) : mat.define(CC_USE_WORLD_SPACE, false); + if (this._particleSystem.renderMode === _enum.RenderMode.Billboard) { + mat.define(CC_USE_BILLBOARD, true); + mat.define(CC_USE_STRETCHED_BILLBOARD, false); + mat.define(CC_USE_HORIZONTAL_BILLBOARD, false); + mat.define(CC_USE_VERTICAL_BILLBOARD, false); + mat.define(CC_USE_MESH, false); + } else if (this._particleSystem.renderMode === _enum.RenderMode.StrecthedBillboard) { + mat.define(CC_USE_BILLBOARD, false); + mat.define(CC_USE_STRETCHED_BILLBOARD, true); + mat.define(CC_USE_HORIZONTAL_BILLBOARD, false); + mat.define(CC_USE_VERTICAL_BILLBOARD, false); + mat.define(CC_USE_MESH, false); + this.frameTile_velLenScale.z = this._particleSystem.velocityScale; + this.frameTile_velLenScale.w = this._particleSystem.lengthScale; + } else if (this._particleSystem.renderMode === _enum.RenderMode.HorizontalBillboard) { + mat.define(CC_USE_BILLBOARD, false); + mat.define(CC_USE_STRETCHED_BILLBOARD, false); + mat.define(CC_USE_HORIZONTAL_BILLBOARD, true); + mat.define(CC_USE_VERTICAL_BILLBOARD, false); + mat.define(CC_USE_MESH, false); + } else if (this._particleSystem.renderMode === _enum.RenderMode.VerticalBillboard) { + mat.define(CC_USE_BILLBOARD, false); + mat.define(CC_USE_STRETCHED_BILLBOARD, false); + mat.define(CC_USE_HORIZONTAL_BILLBOARD, false); + mat.define(CC_USE_VERTICAL_BILLBOARD, true); + mat.define(CC_USE_MESH, false); + } else if (this._particleSystem.renderMode === _enum.RenderMode.Mesh) { + mat.define(CC_USE_BILLBOARD, false); + mat.define(CC_USE_STRETCHED_BILLBOARD, false); + mat.define(CC_USE_HORIZONTAL_BILLBOARD, false); + mat.define(CC_USE_VERTICAL_BILLBOARD, false); + mat.define(CC_USE_MESH, true); + } else console.warn("particle system renderMode " + this._particleSystem.renderMode + " not support."); + this._particleSystem.textureAnimationModule.enable && _valueTypes.Vec2.set(this.frameTile_velLenScale, this._particleSystem.textureAnimationModule.numTilesX, this._particleSystem.textureAnimationModule.numTilesY); + mat.setProperty("frameTile_velLenScale", this.frameTile_velLenScale); + this._particleSystem.setMaterial(0, mat); + }; + _proto._updateTrailMaterial = function _updateTrailMaterial() { + var mat = this._particleSystem.trailMaterial; + if (this._particleSystem.trailModule.enable) { + null === mat && null === this._defaultTrailMat && (this._defaultTrailMat = _materialVariant["default"].createWithBuiltin("3d-trail", this)); + if (null === mat) { + mat = this._defaultTrailMat; + this._particleSystem.trailMaterial = mat; + } + this._particleSystem._simulationSpace === _enum.Space.World || this._particleSystem.trailModule.space === _enum.Space.World ? mat.define(CC_USE_WORLD_SPACE, true) : mat.define(CC_USE_WORLD_SPACE, false); + this._particleSystem.trailModule._updateMaterial(); + } + }; + _proto._updateTrailEnable = function _updateTrailEnable(enable) { + if (!this._model) return; + var subData = this._model._subDatas[1]; + subData && (subData.enable = enable); + }; + _proto._updateModel = function _updateModel() { + if (!this._model) return; + this._model.setVertexAttributes(this._particleSystem.renderMode === _enum.RenderMode.Mesh ? this._particleSystem.mesh : null, this._vertFormat); + }; + _proto.setVertexAttributes = function setVertexAttributes(mesh, vfmt) { + if (!this._model) return; + this._model.setVertexAttributes(mesh, vfmt); + }; + _proto.fillBuffers = function fillBuffers(comp, renderer) { + if (!this._model) return; + this._model._uploadData(); + var submeshes = this._model._subMeshes; + var subDatas = this._model._subDatas; + var materials = comp.materials; + renderer._flush(); + for (var i = 0, len = submeshes.length; i < len; i++) { + var ia = submeshes[i]; + var meshData = subDatas[i]; + var material = materials[i]; + if (meshData.enable) { + renderer.material = material; + renderer.cullingMask = comp.node._cullingMask; + renderer.node = comp.node; + renderer._flushIA(ia); + } + } + }; + return ParticleSystem3DAssembler; + })(_assembler["default"])) || _class); + exports["default"] = ParticleSystem3DAssembler; + Object.assign(ParticleSystem3DAssembler, { + uv: _uvs + }); + _assembler["default"].register(_particleSystem3d["default"], ParticleSystem3DAssembler); + module.exports = exports["default"]; + }), { + "../../../../renderer/gfx": 373, + "../../../../renderer/memop/recycle-pool": 388, + "../../../assets/material/material-variant": 132, + "../../../platform/CCClassDecorator": 241, + "../../../renderer/assembler": 269, + "../../../value-types": 340, + "../enum": 44, + "../particle": 47, + "../particle-system-3d": 46, + "./particle-batch-model": 48 + } ], + 50: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _CCClassDecorator = require("../../../platform/CCClassDecorator"); + var _valueTypes = require("../../../value-types"); + var _gfx = _interopRequireDefault(require("../../../../renderer/gfx")); + var _pool = _interopRequireDefault(require("../../../../renderer/memop/pool")); + var _curveRange = _interopRequireDefault(require("../animator/curve-range")); + var _gradientRange = _interopRequireDefault(require("../animator/gradient-range")); + var _enum = require("../enum"); + var _utils = _interopRequireDefault(require("../utils")); + var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6, _descriptor7, _descriptor8, _descriptor9, _descriptor10, _descriptor11, _descriptor12; + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _createForOfIteratorHelperLoose(o, allowArrayLike) { + var it = "undefined" !== typeof Symbol && o[Symbol.iterator] || o["@@iterator"]; + if (it) return (it = it.call(o)).next.bind(it); + if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && "number" === typeof o.length) { + it && (o = it); + var i = 0; + return function() { + if (i >= o.length) return { + done: true + }; + return { + done: false, + value: o[i++] + }; + }; + } + throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + function _unsupportedIterableToArray(o, minLen) { + if (!o) return; + if ("string" === typeof o) return _arrayLikeToArray(o, minLen); + var n = Object.prototype.toString.call(o).slice(8, -1); + "Object" === n && o.constructor && (n = o.constructor.name); + if ("Map" === n || "Set" === n) return Array.from(o); + if ("Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); + } + function _arrayLikeToArray(arr, len) { + (null == len || len > arr.length) && (len = arr.length); + for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; + return arr2; + } + 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 + }); + } + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + "value" in descriptor && (descriptor.writable = true); + Object.defineProperty(target, descriptor.key, descriptor); + } + } + function _createClass(Constructor, protoProps, staticProps) { + protoProps && _defineProperties(Constructor.prototype, protoProps); + staticProps && _defineProperties(Constructor, staticProps); + return Constructor; + } + 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; + ("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 && void 0 !== desc.initializer) { + desc.value = desc.initializer ? desc.initializer.call(context) : void 0; + desc.initializer = void 0; + } + if (void 0 === desc.initializer) { + Object.defineProperty(target, property, desc); + desc = null; + } + return desc; + } + function _initializerWarningHelper(descriptor, context) { + throw new Error("Decorating class property failed. Please ensure that proposal-class-properties is enabled and runs after the decorators transform."); + } + var PRE_TRIANGLE_INDEX = 1; + var NEXT_TRIANGLE_INDEX = 4; + var DIRECTION_THRESHOLD = Math.cos((0, _valueTypes.toRadian)(100)); + var _temp_trailEle = { + position: cc.v3(), + velocity: cc.v3() + }; + var _temp_quat = cc.quat(); + var _temp_xform = cc.mat4(); + var _temp_Vec3 = cc.v3(); + var _temp_Vec3_1 = cc.v3(); + var _temp_color = cc.color(); + var ITrailElement = function ITrailElement() { + this.position = void 0; + this.lifetime = void 0; + this.width = void 0; + this.velocity = void 0; + this.color = void 0; + }; + var TrailSegment = (function() { + function TrailSegment(maxTrailElementNum) { + this.start = void 0; + this.end = void 0; + this.trailElements = []; + this.start = -1; + this.end = -1; + this.trailElements = []; + while (maxTrailElementNum--) this.trailElements.push({ + position: cc.v3(), + lifetime: 0, + width: 0, + velocity: cc.v3(), + direction: 0, + color: cc.color() + }); + } + var _proto = TrailSegment.prototype; + _proto.getElement = function getElement(idx) { + if (-1 === this.start) return null; + idx < 0 && (idx = (idx + this.trailElements.length) % this.trailElements.length); + idx >= this.trailElements.length && (idx %= this.trailElements.length); + return this.trailElements[idx]; + }; + _proto.addElement = function addElement() { + if (0 === this.trailElements.length) return null; + if (-1 === this.start) { + this.start = 0; + this.end = 1; + return this.trailElements[0]; + } + if (this.start === this.end) { + this.trailElements.splice(this.end, 0, { + position: cc.v3(), + lifetime: 0, + width: 0, + velocity: cc.v3(), + direction: 0, + color: cc.color() + }); + this.start++; + this.start %= this.trailElements.length; + } + var newEleLoc = this.end++; + this.end %= this.trailElements.length; + return this.trailElements[newEleLoc]; + }; + _proto.iterateElement = function iterateElement(target, f, p, dt) { + var end = this.start >= this.end ? this.end + this.trailElements.length : this.end; + for (var i = this.start; i < end; i++) if (f(target, this.trailElements[i % this.trailElements.length], p, dt)) { + this.start++; + this.start %= this.trailElements.length; + } + if (this.start === end) { + this.start = -1; + this.end = -1; + } + }; + _proto.count = function count() { + return this.start < this.end ? this.end - this.start : this.trailElements.length + this.end - this.start; + }; + _proto.clear = function clear() { + this.start = -1; + this.end = -1; + }; + return TrailSegment; + })(); + var TrailModule = (_dec = (0, _CCClassDecorator.ccclass)("cc.TrailModule"), _dec2 = (0, + _CCClassDecorator.property)({ + type: _enum.TrailMode + }), _dec3 = (0, _CCClassDecorator.property)({ + type: _curveRange["default"] + }), _dec4 = (0, _CCClassDecorator.property)({ + type: _enum.Space + }), _dec5 = (0, _CCClassDecorator.property)({ + type: _enum.TextureMode + }), _dec6 = (0, _CCClassDecorator.property)({ + type: _curveRange["default"] + }), _dec7 = (0, _CCClassDecorator.property)({ + type: _gradientRange["default"] + }), _dec8 = (0, _CCClassDecorator.property)({ + type: _gradientRange["default"] + }), _dec(_class = (_class2 = (function() { + function TrailModule() { + _initializerDefineProperty(this, "_enable", _descriptor, this); + _initializerDefineProperty(this, "mode", _descriptor2, this); + _initializerDefineProperty(this, "lifeTime", _descriptor3, this); + _initializerDefineProperty(this, "_minParticleDistance", _descriptor4, this); + _initializerDefineProperty(this, "_space", _descriptor5, this); + _initializerDefineProperty(this, "existWithParticles", _descriptor6, this); + _initializerDefineProperty(this, "textureMode", _descriptor7, this); + _initializerDefineProperty(this, "widthFromParticle", _descriptor8, this); + _initializerDefineProperty(this, "widthRatio", _descriptor9, this); + _initializerDefineProperty(this, "colorFromParticle", _descriptor10, this); + _initializerDefineProperty(this, "colorOverTrail", _descriptor11, this); + _initializerDefineProperty(this, "colorOvertime", _descriptor12, this); + this._particleSystem = null; + this._minSquaredDistance = 0; + this._vertSize = 0; + this._trailNum = 0; + this._trailLifetime = 0; + this.vbOffset = 0; + this.ibOffset = 0; + this._trailSegments = null; + this._particleTrail = null; + this._ia = null; + this._gfxVFmt = null; + this._vbF32 = null; + this._vbUint32 = null; + this._iBuffer = null; + this._needTransform = null; + this._defaultMat = null; + this._material = null; + this._gfxVFmt = new _gfx["default"].VertexFormat([ { + name: _gfx["default"].ATTR_POSITION, + type: _gfx["default"].ATTR_TYPE_FLOAT32, + num: 3 + }, { + name: _gfx["default"].ATTR_TEX_COORD, + type: _gfx["default"].ATTR_TYPE_FLOAT32, + num: 4 + }, { + name: _gfx["default"].ATTR_TEX_COORD1, + type: _gfx["default"].ATTR_TYPE_FLOAT32, + num: 3 + }, { + name: _gfx["default"].ATTR_COLOR, + type: _gfx["default"].ATTR_TYPE_UINT8, + num: 4, + normalize: true + } ]); + this._vertSize = this._gfxVFmt._bytes; + this._particleTrail = new _utils["default"](); + } + var _proto2 = TrailModule.prototype; + _proto2.onInit = function onInit(ps) { + this._particleSystem = ps; + this.minParticleDistance = this._minParticleDistance; + var burstCount = 0; + for (var _iterator = _createForOfIteratorHelperLoose(ps.bursts), _step; !(_step = _iterator()).done; ) { + var b = _step.value; + burstCount += b.getMaxCount(ps); + } + this.lifeTime.constant = 1; + this._trailNum = Math.ceil(ps.startLifetime.getMax() * this.lifeTime.getMax() * 60 * (ps.rateOverTime.getMax() * ps.duration + burstCount)); + this._trailSegments = new _pool["default"](function() { + return new TrailSegment(10); + }, Math.ceil(ps.rateOverTime.getMax() * ps.duration)); + if (this._enable) { + this.enable = this._enable; + this._updateMaterial(); + } + }; + _proto2.onEnable = function onEnable() {}; + _proto2.onDisable = function onDisable() {}; + _proto2.destroy = function destroy() { + if (this._trailSegments) { + this._trailSegments.clear((function(obj) { + obj.trailElements.length = 0; + })); + this._trailSegments = null; + } + }; + _proto2.clear = function clear() { + if (this.enable) { + var trailIter = this._particleTrail.values(); + var trail = trailIter.next(); + while (!trail.done) { + trail.value.clear(); + trail = trailIter.next(); + } + this._particleTrail.clear(); + this.updateTrailBuffer(); + } + }; + _proto2._createTrailData = function _createTrailData() { + var model = this._particleSystem._assembler._model; + if (model) { + model.createTrailData(this._gfxVFmt, this._trailNum); + var subData = model._subDatas[1]; + this._vbF32 = subData.getVData(); + this._vbUint32 = subData.getVData(Uint32Array); + this._iBuffer = subData.iData; + } + }; + _proto2._updateMaterial = function _updateMaterial() { + if (this._particleSystem) { + var mat = this._particleSystem.trailMaterial; + this._material = mat || this._particleSystem._assembler._defaultTrailMat; + } + }; + _proto2.update = function update() { + this._trailLifetime = this.lifeTime.evaluate(this._particleSystem._time, 1); + if (this.space === _enum.Space.World && this._particleSystem._simulationSpace === _enum.Space.Local) { + this._needTransform = true; + this._particleSystem.node.getWorldMatrix(_temp_xform); + this._particleSystem.node.getWorldRotation(_temp_quat); + } else this._needTransform = false; + }; + _proto2.animate = function animate(p, scaledDt) { + if (!this._trailSegments) return; + var trail = this._particleTrail.get(p); + if (!trail) { + trail = this._trailSegments.alloc(); + this._particleTrail.set(p, trail); + return; + } + var lastSeg = trail.getElement(trail.end - 1); + this._needTransform ? _valueTypes.Vec3.transformMat4(_temp_Vec3, p.position, _temp_xform) : _valueTypes.Vec3.copy(_temp_Vec3, p.position); + if (lastSeg) { + trail.iterateElement(this, this._updateTrailElement, p, scaledDt); + if (_valueTypes.Vec3.squaredDistance(lastSeg.position, _temp_Vec3) < this._minSquaredDistance) return; + } + lastSeg = trail.addElement(); + if (!lastSeg) return; + _valueTypes.Vec3.copy(lastSeg.position, _temp_Vec3); + lastSeg.lifetime = 0; + this.widthFromParticle ? lastSeg.width = p.size.x * this.widthRatio.evaluate(0, 1) : lastSeg.width = this.widthRatio.evaluate(0, 1); + var trailNum = trail.count(); + if (2 === trailNum) { + var lastSecondTrail = trail.getElement(trail.end - 2); + _valueTypes.Vec3.subtract(lastSecondTrail.velocity, lastSeg.position, lastSecondTrail.position); + } else if (trailNum > 2) { + var _lastSecondTrail = trail.getElement(trail.end - 2); + var lastThirdTrail = trail.getElement(trail.end - 3); + _valueTypes.Vec3.subtract(_temp_Vec3, lastThirdTrail.position, _lastSecondTrail.position); + _valueTypes.Vec3.subtract(_temp_Vec3_1, lastSeg.position, _lastSecondTrail.position); + _valueTypes.Vec3.subtract(_lastSecondTrail.velocity, _temp_Vec3_1, _temp_Vec3); + _valueTypes.Vec3.equals(cc.Vec3.ZERO, _lastSecondTrail.velocity) && _valueTypes.Vec3.copy(_lastSecondTrail.velocity, _temp_Vec3); + } + this.colorFromParticle ? lastSeg.color.set(p.color) : lastSeg.color.set(this.colorOvertime.evaluate(0, 1)); + }; + _proto2._updateTrailElement = function _updateTrailElement(trail, trailEle, p, dt) { + trailEle.lifetime += dt; + if (trail.colorFromParticle) { + trailEle.color.set(p.color); + trailEle.color.multiply(trail.colorOvertime.evaluate(1 - p.remainingLifetime / p.startLifetime, 1)); + } else trailEle.color.set(trail.colorOvertime.evaluate(1 - p.remainingLifetime / p.startLifetime, 1)); + trail.widthFromParticle ? trailEle.width = p.size.x * trail.widthRatio.evaluate(trailEle.lifetime / trail._trailLifetime, 1) : trailEle.width = trail.widthRatio.evaluate(trailEle.lifetime / trail._trailLifetime, 1); + return trailEle.lifetime > trail._trailLifetime; + }; + _proto2.removeParticle = function removeParticle(p) { + var trail = this._particleTrail.get(p); + if (trail && this._trailSegments) { + trail.clear(); + this._trailSegments.free(trail); + this._particleTrail["delete"](p); + } + }; + _proto2.updateTrailBuffer = function updateTrailBuffer() { + this.vbOffset = 0; + this.ibOffset = 0; + for (var _iterator2 = _createForOfIteratorHelperLoose(this._particleTrail.keys()), _step2; !(_step2 = _iterator2()).done; ) { + var p = _step2.value; + var trailSeg = this._particleTrail.get(p); + if (-1 === trailSeg.start) continue; + var indexOffset = 4 * this.vbOffset / this._vertSize; + var end = trailSeg.start >= trailSeg.end ? trailSeg.end + trailSeg.trailElements.length : trailSeg.end; + var trailNum = end - trailSeg.start; + var textCoordSeg = 1 / trailNum; + var startSegEle = trailSeg.trailElements[trailSeg.start]; + this._fillVertexBuffer(startSegEle, this.colorOverTrail.evaluate(1, 1), indexOffset, 1, 0, NEXT_TRIANGLE_INDEX); + for (var i = trailSeg.start + 1; i < end; i++) { + var segEle = trailSeg.trailElements[i % trailSeg.trailElements.length]; + var j = i - trailSeg.start; + this._fillVertexBuffer(segEle, this.colorOverTrail.evaluate(1 - j / trailNum, 1), indexOffset, 1 - j * textCoordSeg, j, PRE_TRIANGLE_INDEX | NEXT_TRIANGLE_INDEX); + } + this._needTransform ? _valueTypes.Vec3.transformMat4(_temp_trailEle.position, p.position, _temp_xform) : _valueTypes.Vec3.copy(_temp_trailEle.position, p.position); + if (1 === trailNum || 2 === trailNum) { + var lastSecondTrail = trailSeg.getElement(trailSeg.end - 1); + _valueTypes.Vec3.subtract(lastSecondTrail.velocity, _temp_trailEle.position, lastSecondTrail.position); + this._vbF32[this.vbOffset - this._vertSize / 4 - 4] = lastSecondTrail.velocity.x; + this._vbF32[this.vbOffset - this._vertSize / 4 - 3] = lastSecondTrail.velocity.y; + this._vbF32[this.vbOffset - this._vertSize / 4 - 2] = lastSecondTrail.velocity.z; + this._vbF32[this.vbOffset - 4] = lastSecondTrail.velocity.x; + this._vbF32[this.vbOffset - 3] = lastSecondTrail.velocity.y; + this._vbF32[this.vbOffset - 2] = lastSecondTrail.velocity.z; + _valueTypes.Vec3.subtract(_temp_trailEle.velocity, _temp_trailEle.position, lastSecondTrail.position); + this._checkDirectionReverse(_temp_trailEle, lastSecondTrail); + } else if (trailNum > 2) { + var _lastSecondTrail2 = trailSeg.getElement(trailSeg.end - 1); + var lastThirdTrail = trailSeg.getElement(trailSeg.end - 2); + _valueTypes.Vec3.subtract(_temp_Vec3, lastThirdTrail.position, _lastSecondTrail2.position); + _valueTypes.Vec3.subtract(_temp_Vec3_1, _temp_trailEle.position, _lastSecondTrail2.position); + _valueTypes.Vec3.normalize(_temp_Vec3, _temp_Vec3); + _valueTypes.Vec3.normalize(_temp_Vec3_1, _temp_Vec3_1); + _valueTypes.Vec3.subtract(_lastSecondTrail2.velocity, _temp_Vec3_1, _temp_Vec3); + _valueTypes.Vec3.normalize(_lastSecondTrail2.velocity, _lastSecondTrail2.velocity); + this._checkDirectionReverse(_lastSecondTrail2, lastThirdTrail); + this.vbOffset -= this._vertSize / 4 * 2; + this.ibOffset -= 6; + this._fillVertexBuffer(_lastSecondTrail2, this.colorOverTrail.evaluate(textCoordSeg, 1), indexOffset, textCoordSeg, trailNum - 1, PRE_TRIANGLE_INDEX | NEXT_TRIANGLE_INDEX); + _valueTypes.Vec3.subtract(_temp_trailEle.velocity, _temp_trailEle.position, _lastSecondTrail2.position); + _valueTypes.Vec3.normalize(_temp_trailEle.velocity, _temp_trailEle.velocity); + this._checkDirectionReverse(_temp_trailEle, _lastSecondTrail2); + } + this.widthFromParticle ? _temp_trailEle.width = p.size.x * this.widthRatio.evaluate(0, 1) : _temp_trailEle.width = this.widthRatio.evaluate(0, 1); + _temp_trailEle.color = p.color; + _valueTypes.Vec3.equals(_temp_trailEle.velocity, cc.Vec3.ZERO) ? this.ibOffset -= 3 : this._fillVertexBuffer(_temp_trailEle, this.colorOverTrail.evaluate(0, 1), indexOffset, 0, trailNum, PRE_TRIANGLE_INDEX); + } + this._updateIA(this.ibOffset); + }; + _proto2._fillVertexBuffer = function _fillVertexBuffer(trailSeg, colorModifer, indexOffset, xTexCoord, trailEleIdx, indexSet) { + this._vbF32[this.vbOffset++] = trailSeg.position.x; + this._vbF32[this.vbOffset++] = trailSeg.position.y; + this._vbF32[this.vbOffset++] = trailSeg.position.z; + this._vbF32[this.vbOffset++] = 0; + this._vbF32[this.vbOffset++] = trailSeg.width; + this._vbF32[this.vbOffset++] = xTexCoord; + this._vbF32[this.vbOffset++] = 0; + this._vbF32[this.vbOffset++] = trailSeg.velocity.x; + this._vbF32[this.vbOffset++] = trailSeg.velocity.y; + this._vbF32[this.vbOffset++] = trailSeg.velocity.z; + _temp_color.set(trailSeg.color); + _temp_color.multiply(colorModifer); + this._vbUint32[this.vbOffset++] = _temp_color._val; + this._vbF32[this.vbOffset++] = trailSeg.position.x; + this._vbF32[this.vbOffset++] = trailSeg.position.y; + this._vbF32[this.vbOffset++] = trailSeg.position.z; + this._vbF32[this.vbOffset++] = 1; + this._vbF32[this.vbOffset++] = trailSeg.width; + this._vbF32[this.vbOffset++] = xTexCoord; + this._vbF32[this.vbOffset++] = 1; + this._vbF32[this.vbOffset++] = trailSeg.velocity.x; + this._vbF32[this.vbOffset++] = trailSeg.velocity.y; + this._vbF32[this.vbOffset++] = trailSeg.velocity.z; + this._vbUint32[this.vbOffset++] = _temp_color._val; + if (indexSet & PRE_TRIANGLE_INDEX) { + this._iBuffer[this.ibOffset++] = indexOffset + 2 * trailEleIdx; + this._iBuffer[this.ibOffset++] = indexOffset + 2 * trailEleIdx - 1; + this._iBuffer[this.ibOffset++] = indexOffset + 2 * trailEleIdx + 1; + } + if (indexSet & NEXT_TRIANGLE_INDEX) { + this._iBuffer[this.ibOffset++] = indexOffset + 2 * trailEleIdx; + this._iBuffer[this.ibOffset++] = indexOffset + 2 * trailEleIdx + 1; + this._iBuffer[this.ibOffset++] = indexOffset + 2 * trailEleIdx + 2; + } + }; + _proto2._updateIA = function _updateIA(count) { + this._particleSystem && this._particleSystem._assembler && this._particleSystem._assembler.updateIA(1, count, true, true); + }; + _proto2._checkDirectionReverse = function _checkDirectionReverse(currElement, prevElement) { + _valueTypes.Vec3.dot(currElement.velocity, prevElement.velocity) < DIRECTION_THRESHOLD ? currElement.direction = 1 - prevElement.direction : currElement.direction = prevElement.direction; + }; + _createClass(TrailModule, [ { + key: "enable", + get: function get() { + return this._enable; + }, + set: function set(val) { + val && this._createTrailData(); + if (val && !this._enable) { + this._enable = val; + this._particleSystem._assembler._updateTrailMaterial(); + } + this._enable = val; + this._particleSystem._assembler._updateTrailEnable(this._enable); + } + }, { + key: "minParticleDistance", + get: function get() { + return this._minParticleDistance; + }, + set: function set(val) { + this._minParticleDistance = val; + this._minSquaredDistance = val * val; + } + }, { + key: "space", + get: function get() { + return this._space; + }, + set: function set(val) { + this._space = val; + this._particleSystem && this._particleSystem._assembler._updateTrailMaterial(); + } + } ]); + return TrailModule; + })(), _descriptor = _applyDecoratedDescriptor(_class2.prototype, "_enable", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return false; + } + }), _applyDecoratedDescriptor(_class2.prototype, "enable", [ _CCClassDecorator.property ], Object.getOwnPropertyDescriptor(_class2.prototype, "enable"), _class2.prototype), + _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "mode", [ _dec2 ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return _enum.TrailMode.Particles; + } + }), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "lifeTime", [ _dec3 ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new _curveRange["default"](); + } + }), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "_minParticleDistance", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return .1; + } + }), _applyDecoratedDescriptor(_class2.prototype, "minParticleDistance", [ _CCClassDecorator.property ], Object.getOwnPropertyDescriptor(_class2.prototype, "minParticleDistance"), _class2.prototype), + _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, "_space", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return _enum.Space.World; + } + }), _applyDecoratedDescriptor(_class2.prototype, "space", [ _dec4 ], Object.getOwnPropertyDescriptor(_class2.prototype, "space"), _class2.prototype), + _descriptor6 = _applyDecoratedDescriptor(_class2.prototype, "existWithParticles", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return true; + } + }), _descriptor7 = _applyDecoratedDescriptor(_class2.prototype, "textureMode", [ _dec5 ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return _enum.TextureMode.Stretch; + } + }), _descriptor8 = _applyDecoratedDescriptor(_class2.prototype, "widthFromParticle", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return true; + } + }), _descriptor9 = _applyDecoratedDescriptor(_class2.prototype, "widthRatio", [ _dec6 ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new _curveRange["default"](); + } + }), _descriptor10 = _applyDecoratedDescriptor(_class2.prototype, "colorFromParticle", [ _CCClassDecorator.property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return false; + } + }), _descriptor11 = _applyDecoratedDescriptor(_class2.prototype, "colorOverTrail", [ _dec7 ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new _gradientRange["default"](); + } + }), _descriptor12 = _applyDecoratedDescriptor(_class2.prototype, "colorOvertime", [ _dec8 ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new _gradientRange["default"](); + } + }), _class2)) || _class); + exports["default"] = TrailModule; + module.exports = exports["default"]; + }), { + "../../../../renderer/gfx": 373, + "../../../../renderer/memop/pool": 387, + "../../../platform/CCClassDecorator": 241, + "../../../value-types": 340, + "../animator/curve-range": 32, + "../animator/gradient-range": 34, + "../enum": 44, + "../utils": 51 + } ], + 51: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + Object.is || (Object.is = function(x, y) { + return x === y ? 0 !== x || 1 / x === 1 / y : x !== x && y !== y; + }); + var MapUtils = (function() { + function MapUtils(data) { + this.datas = []; + !data && (data = []); + this.datas = []; + var that = this; + data.forEach((function(item) { + that.has(item[0]) || that.datas.push({ + key: item[0], + value: item[1] + }); + })); + } + var _proto = MapUtils.prototype; + _proto.size = function size() { + return this.datas.length; + }; + _proto.set = function set(key, value) { + this["delete"](key); + this.datas.push({ + key: key, + value: value + }); + }; + _proto.get = function get(key) { + var value = void 0; + var datas = this.datas; + for (var i = 0, len = datas.length; i < len; i++) if (Object.is(key, datas[i].key)) { + value = datas[i].value; + break; + } + return value; + }; + _proto.has = function has(key) { + var res = false; + var datas = this.datas; + for (var i = 0, len = datas.length; i < len; i++) if (Object.is(key, datas[i].key)) { + res = true; + break; + } + return res; + }; + _proto.clear = function clear() { + this.datas.length = 0; + }; + _proto["delete"] = function _delete(key) { + var res = false; + var datas = this.datas; + for (var i = 0, len = datas.length; i < len; i++) if (Object.is(key, datas[i].key)) { + datas.splice(i, 1); + res = true; + break; + } + return res; + }; + _proto.keys = function keys() { + var datas = this.datas; + var keys = []; + for (var i = 0, len = datas.length; i < len; i++) keys.push(datas[i].key); + return keys; + }; + _proto.values = function values() { + var index = 0; + var datas = this.datas; + return { + next: function next() { + if (0 === datas.length || void 0 === datas[index]) return { + value: void 0, + done: true + }; + return { + value: datas[index++].value, + done: false + }; + } + }; + }; + return MapUtils; + })(); + exports["default"] = MapUtils; + module.exports = exports["default"]; + }), {} ], + 52: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = _default; + var _vec = _interopRequireDefault(require("../../value-types/vec3")); + var _vertexData = _interopRequireDefault(require("./vertex-data")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + var temp1 = new _vec["default"](); + var temp2 = new _vec["default"](); + var temp3 = new _vec["default"](); + var r = new _vec["default"](); + var c0 = new _vec["default"](); + var c1 = new _vec["default"](); + var c2 = new _vec["default"](); + var c3 = new _vec["default"](); + var c4 = new _vec["default"](); + var c5 = new _vec["default"](); + var c6 = new _vec["default"](); + var c7 = new _vec["default"](); + function _default(width, height, length, opts) { + void 0 === width && (width = 1); + void 0 === height && (height = 1); + void 0 === length && (length = 1); + void 0 === opts && (opts = { + widthSegments: 1, + heightSegments: 1, + lengthSegments: 1, + invWinding: false + }); + var ws = opts.widthSegments; + var hs = opts.heightSegments; + var ls = opts.lengthSegments; + var inv = opts.invWinding; + var hw = .5 * width; + var hh = .5 * height; + var hl = .5 * length; + var corners = [ _vec["default"].set(c0, -hw, -hh, hl), _vec["default"].set(c1, hw, -hh, hl), _vec["default"].set(c2, hw, hh, hl), _vec["default"].set(c3, -hw, hh, hl), _vec["default"].set(c4, hw, -hh, -hl), _vec["default"].set(c5, -hw, -hh, -hl), _vec["default"].set(c6, -hw, hh, -hl), _vec["default"].set(c7, hw, hh, -hl) ]; + var faceAxes = [ [ 2, 3, 1 ], [ 4, 5, 7 ], [ 7, 6, 2 ], [ 1, 0, 4 ], [ 1, 4, 2 ], [ 5, 0, 6 ] ]; + var faceNormals = [ [ 0, 0, 1 ], [ 0, 0, -1 ], [ 0, 1, 0 ], [ 0, -1, 0 ], [ 1, 0, 0 ], [ -1, 0, 0 ] ]; + var positions = []; + var normals = []; + var uvs = []; + var indices = []; + var minPos = new _vec["default"](-hw, -hh, -hl); + var maxPos = new _vec["default"](hw, hh, hl); + var boundingRadius = Math.sqrt(hw * hw + hh * hh + hl * hl); + function _buildPlane(side, uSegments, vSegments) { + var u, v; + var ix, iy; + var offset = positions.length / 3; + var faceAxe = faceAxes[side]; + var faceNormal = faceNormals[side]; + for (iy = 0; iy <= vSegments; iy++) for (ix = 0; ix <= uSegments; ix++) { + u = ix / uSegments; + v = iy / vSegments; + _vec["default"].lerp(temp1, corners[faceAxe[0]], corners[faceAxe[1]], u); + _vec["default"].lerp(temp2, corners[faceAxe[0]], corners[faceAxe[2]], v); + _vec["default"].subtract(temp3, temp2, corners[faceAxe[0]]); + _vec["default"].add(r, temp1, temp3); + positions.push(r.x, r.y, r.z); + normals.push(faceNormal[0], faceNormal[1], faceNormal[2]); + uvs.push(u, v); + if (ix < uSegments && iy < vSegments) { + var useg1 = uSegments + 1; + var a = ix + iy * useg1; + var b = ix + (iy + 1) * useg1; + var c = ix + 1 + (iy + 1) * useg1; + var d = ix + 1 + iy * useg1; + if (inv) { + indices.push(offset + a, offset + b, offset + d); + indices.push(offset + d, offset + b, offset + c); + } else { + indices.push(offset + a, offset + d, offset + b); + indices.push(offset + b, offset + d, offset + c); + } + } + } + } + _buildPlane(0, ws, hs); + _buildPlane(4, ls, hs); + _buildPlane(1, ws, hs); + _buildPlane(5, ls, hs); + _buildPlane(3, ws, ls); + _buildPlane(2, ws, ls); + return new _vertexData["default"](positions, normals, uvs, indices, minPos, maxPos, boundingRadius); + } + module.exports = exports["default"]; + }), { + "../../value-types/vec3": 350, + "./vertex-data": 63 + } ], + 53: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = _default; + var _vec = _interopRequireDefault(require("../../value-types/vec3")); + var _vertexData = _interopRequireDefault(require("./vertex-data")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + var temp1 = cc.v3(0, 0, 0); + var temp2 = cc.v3(0, 0, 0); + function _default(radiusTop, radiusBottom, height, opts) { + void 0 === radiusTop && (radiusTop = .5); + void 0 === radiusBottom && (radiusBottom = .5); + void 0 === height && (height = 2); + void 0 === opts && (opts = { + sides: 32, + heightSegments: 32, + arc: 2 * Math.PI + }); + var torsoHeight = height - radiusTop - radiusBottom; + var sides = opts.sides; + var heightSegments = opts.heightSegments; + var bottomProp = radiusBottom / height; + var torProp = torsoHeight / height; + var topProp = radiusTop / height; + var bottomSegments = Math.floor(heightSegments * bottomProp); + var topSegments = Math.floor(heightSegments * topProp); + var torSegments = Math.floor(heightSegments * torProp); + var topOffset = torsoHeight + radiusBottom - height / 2; + var torOffset = radiusBottom - height / 2; + var bottomOffset = radiusBottom - height / 2; + var arc = opts.arc; + var positions = []; + var normals = []; + var uvs = []; + var indices = []; + var maxRadius = Math.max(radiusTop, radiusBottom); + var minPos = cc.v3(-maxRadius, -height / 2, -maxRadius); + var maxPos = cc.v3(maxRadius, height / 2, maxRadius); + var boundingRadius = height / 2; + var index = 0; + var indexArray = []; + generateBottom(); + generateTorso(); + generateTop(); + return new _vertexData["default"](positions, normals, uvs, indices, minPos, maxPos, boundingRadius); + function generateTorso() { + var slope = (radiusTop - radiusBottom) / torsoHeight; + for (var y = 0; y <= torSegments; y++) { + var indexRow = []; + var lat = y / torSegments; + var radius = lat * (radiusTop - radiusBottom) + radiusBottom; + for (var x = 0; x <= sides; ++x) { + var u = x / sides; + var v = lat * torProp + bottomProp; + var theta = u * arc - arc / 4; + var sinTheta = Math.sin(theta); + var cosTheta = Math.cos(theta); + positions.push(radius * sinTheta); + positions.push(lat * torsoHeight + torOffset); + positions.push(radius * cosTheta); + _vec["default"].normalize(temp1, _vec["default"].set(temp2, sinTheta, -slope, cosTheta)); + normals.push(temp1.x); + normals.push(temp1.y); + normals.push(temp1.z); + uvs.push(u, v); + indexRow.push(index); + ++index; + } + indexArray.push(indexRow); + } + for (var _y = 0; _y < torSegments; ++_y) for (var _x = 0; _x < sides; ++_x) { + var i1 = indexArray[_y][_x]; + var i2 = indexArray[_y + 1][_x]; + var i3 = indexArray[_y + 1][_x + 1]; + var i4 = indexArray[_y][_x + 1]; + indices.push(i1); + indices.push(i4); + indices.push(i2); + indices.push(i4); + indices.push(i3); + indices.push(i2); + } + } + function generateBottom() { + for (var lat = 0; lat <= bottomSegments; ++lat) { + var theta = lat * Math.PI / bottomSegments / 2; + var sinTheta = Math.sin(theta); + var cosTheta = -Math.cos(theta); + for (var lon = 0; lon <= sides; ++lon) { + var phi = 2 * lon * Math.PI / sides - Math.PI / 2; + var sinPhi = Math.sin(phi); + var cosPhi = Math.cos(phi); + var x = sinPhi * sinTheta; + var y = cosTheta; + var z = cosPhi * sinTheta; + var u = lon / sides; + var v = lat / heightSegments; + positions.push(x * radiusBottom, y * radiusBottom + bottomOffset, z * radiusBottom); + normals.push(x, y, z); + uvs.push(u, v); + if (lat < bottomSegments && lon < sides) { + var seg1 = sides + 1; + var a = seg1 * lat + lon; + var b = seg1 * (lat + 1) + lon; + var c = seg1 * (lat + 1) + lon + 1; + var d = seg1 * lat + lon + 1; + indices.push(a, d, b); + indices.push(d, c, b); + } + ++index; + } + } + } + function generateTop() { + for (var lat = 0; lat <= topSegments; ++lat) { + var theta = lat * Math.PI / topSegments / 2 + Math.PI / 2; + var sinTheta = Math.sin(theta); + var cosTheta = -Math.cos(theta); + for (var lon = 0; lon <= sides; ++lon) { + var phi = 2 * lon * Math.PI / sides - Math.PI / 2; + var sinPhi = Math.sin(phi); + var cosPhi = Math.cos(phi); + var x = sinPhi * sinTheta; + var y = cosTheta; + var z = cosPhi * sinTheta; + var u = lon / sides; + var v = lat / heightSegments + (1 - topProp); + positions.push(x * radiusTop, y * radiusTop + topOffset, z * radiusTop); + normals.push(x, y, z); + uvs.push(u, v); + if (lat < topSegments && lon < sides) { + var seg1 = sides + 1; + var a = seg1 * lat + lon + indexArray[torSegments][sides] + 1; + var b = seg1 * (lat + 1) + lon + indexArray[torSegments][sides] + 1; + var c = seg1 * (lat + 1) + lon + 1 + indexArray[torSegments][sides] + 1; + var d = seg1 * lat + lon + 1 + indexArray[torSegments][sides] + 1; + indices.push(a, d, b); + indices.push(d, c, b); + } + } + } + } + } + module.exports = exports["default"]; + }), { + "../../value-types/vec3": 350, + "./vertex-data": 63 + } ], + 54: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = _default; + var _cylinder = _interopRequireDefault(require("./cylinder")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _default(radius, height, opts) { + void 0 === radius && (radius = .5); + void 0 === height && (height = 1); + void 0 === opts && (opts = { + radialSegments: 32, + heightSegments: 1, + capped: true, + arc: 2 * Math.PI + }); + return (0, _cylinder["default"])(0, radius, height, opts); + } + module.exports = exports["default"]; + }), { + "./cylinder": 55 + } ], + 55: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = _default; + var _vec = _interopRequireDefault(require("../../value-types/vec3")); + var _vertexData = _interopRequireDefault(require("./vertex-data")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + var temp1 = new _vec["default"](); + var temp2 = new _vec["default"](); + function _default(radiusTop, radiusBottom, height, opts) { + void 0 === radiusTop && (radiusTop = .5); + void 0 === radiusBottom && (radiusBottom = .5); + void 0 === height && (height = 2); + void 0 === opts && (opts = { + radialSegments: 32, + heightSegments: 1, + capped: true, + arc: 2 * Math.PI + }); + var halfHeight = .5 * height; + var radialSegments = opts.radialSegments; + var heightSegments = opts.heightSegments; + var capped = opts.capped; + var arc = opts.arc; + var cntCap = 0; + if (!capped) { + radiusTop > 0 && cntCap++; + radiusBottom > 0 && cntCap++; + } + var vertCount = (radialSegments + 1) * (heightSegments + 1); + capped && (vertCount += (radialSegments + 1) * cntCap + radialSegments * cntCap); + var indexCount = radialSegments * heightSegments * 2 * 3; + capped && (indexCount += radialSegments * cntCap * 3); + var indices = new Array(indexCount); + var positions = new Array(3 * vertCount); + var normals = new Array(3 * vertCount); + var uvs = new Array(2 * vertCount); + var maxRadius = Math.max(radiusTop, radiusBottom); + var minPos = new _vec["default"](-maxRadius, -halfHeight, -maxRadius); + var maxPos = new _vec["default"](maxRadius, halfHeight, maxRadius); + var boundingRadius = Math.sqrt(maxRadius * maxRadius + halfHeight * halfHeight); + var index = 0; + var indexOffset = 0; + generateTorso(); + if (capped) { + radiusBottom > 0 && generateCap(false); + radiusTop > 0 && generateCap(true); + } + return new _vertexData["default"](positions, normals, uvs, indices, minPos, maxPos, boundingRadius); + function generateTorso() { + var indexArray = []; + var r = radiusTop - radiusBottom; + var slope = r * r / height * Math.sign(r); + for (var y = 0; y <= heightSegments; y++) { + var indexRow = []; + var v = y / heightSegments; + var radius = v * r + radiusBottom; + for (var x = 0; x <= radialSegments; ++x) { + var u = x / radialSegments; + var theta = u * arc; + var sinTheta = Math.sin(theta); + var cosTheta = Math.cos(theta); + positions[3 * index] = radius * sinTheta; + positions[3 * index + 1] = v * height - halfHeight; + positions[3 * index + 2] = radius * cosTheta; + _vec["default"].normalize(temp1, _vec["default"].set(temp2, sinTheta, -slope, cosTheta)); + normals[3 * index] = temp1.x; + normals[3 * index + 1] = temp1.y; + normals[3 * index + 2] = temp1.z; + uvs[2 * index] = 2 * (1 - u) % 1; + uvs[2 * index + 1] = v; + indexRow.push(index); + ++index; + } + indexArray.push(indexRow); + } + for (var _y = 0; _y < heightSegments; ++_y) for (var _x = 0; _x < radialSegments; ++_x) { + var i1 = indexArray[_y][_x]; + var i2 = indexArray[_y + 1][_x]; + var i3 = indexArray[_y + 1][_x + 1]; + var i4 = indexArray[_y][_x + 1]; + indices[indexOffset] = i1; + ++indexOffset; + indices[indexOffset] = i4; + ++indexOffset; + indices[indexOffset] = i2; + ++indexOffset; + indices[indexOffset] = i4; + ++indexOffset; + indices[indexOffset] = i3; + ++indexOffset; + indices[indexOffset] = i2; + ++indexOffset; + } + } + function generateCap(top) { + var centerIndexStart, centerIndexEnd; + var radius = top ? radiusTop : radiusBottom; + var sign = top ? 1 : -1; + centerIndexStart = index; + for (var x = 1; x <= radialSegments; ++x) { + positions[3 * index] = 0; + positions[3 * index + 1] = halfHeight * sign; + positions[3 * index + 2] = 0; + normals[3 * index] = 0; + normals[3 * index + 1] = sign; + normals[3 * index + 2] = 0; + uvs[2 * index] = .5; + uvs[2 * index + 1] = .5; + ++index; + } + centerIndexEnd = index; + for (var _x2 = 0; _x2 <= radialSegments; ++_x2) { + var u = _x2 / radialSegments; + var theta = u * arc; + var cosTheta = Math.cos(theta); + var sinTheta = Math.sin(theta); + positions[3 * index] = radius * sinTheta; + positions[3 * index + 1] = halfHeight * sign; + positions[3 * index + 2] = radius * cosTheta; + normals[3 * index] = 0; + normals[3 * index + 1] = sign; + normals[3 * index + 2] = 0; + uvs[2 * index] = .5 - .5 * sinTheta * sign; + uvs[2 * index + 1] = .5 + .5 * cosTheta; + ++index; + } + for (var _x3 = 0; _x3 < radialSegments; ++_x3) { + var c = centerIndexStart + _x3; + var i = centerIndexEnd + _x3; + if (top) { + indices[indexOffset] = i + 1; + ++indexOffset; + indices[indexOffset] = c; + ++indexOffset; + indices[indexOffset] = i; + ++indexOffset; + } else { + indices[indexOffset] = c; + ++indexOffset; + indices[indexOffset] = i + 1; + ++indexOffset; + indices[indexOffset] = i; + ++indexOffset; + } + } + } + } + module.exports = exports["default"]; + }), { + "../../value-types/vec3": 350, + "./vertex-data": 63 + } ], + 56: [ (function(require, module, exports) { + "use strict"; + var utils = _interopRequireWildcard(require("./utils")); + var _box = _interopRequireDefault(require("./box")); + var _cone = _interopRequireDefault(require("./cone")); + var _cylinder = _interopRequireDefault(require("./cylinder")); + var _plane = _interopRequireDefault(require("./plane")); + var _quad = _interopRequireDefault(require("./quad")); + var _sphere = _interopRequireDefault(require("./sphere")); + var _torus = _interopRequireDefault(require("./torus")); + var _capsule = _interopRequireDefault(require("./capsule")); + var _polyhedron = require("./polyhedron"); + var _vertexData = _interopRequireDefault(require("./vertex-data")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _getRequireWildcardCache(nodeInterop) { + if ("function" !== typeof WeakMap) return null; + var cacheBabelInterop = new WeakMap(); + var cacheNodeInterop = new WeakMap(); + return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { + return nodeInterop ? cacheNodeInterop : cacheBabelInterop; + })(nodeInterop); + } + function _interopRequireWildcard(obj, nodeInterop) { + if (!nodeInterop && obj && obj.__esModule) return obj; + if (null === obj || "object" !== typeof obj && "function" !== typeof obj) return { + default: obj + }; + var cache = _getRequireWildcardCache(nodeInterop); + if (cache && cache.has(obj)) return cache.get(obj); + var newObj = {}; + var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; + for (var key in obj) if ("default" !== key && Object.prototype.hasOwnProperty.call(obj, key)) { + var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; + desc && (desc.get || desc.set) ? Object.defineProperty(newObj, key, desc) : newObj[key] = obj[key]; + } + newObj["default"] = obj; + cache && cache.set(obj, newObj); + return newObj; + } + cc.primitive = Object.assign({ + box: _box["default"], + cone: _cone["default"], + cylinder: _cylinder["default"], + plane: _plane["default"], + quad: _quad["default"], + sphere: _sphere["default"], + torus: _torus["default"], + capsule: _capsule["default"], + polyhedron: _polyhedron.polyhedron, + PolyhedronType: _polyhedron.PolyhedronType, + VertexData: _vertexData["default"] + }, utils); + }), { + "./box": 52, + "./capsule": 53, + "./cone": 54, + "./cylinder": 55, + "./plane": 57, + "./polyhedron": 58, + "./quad": 59, + "./sphere": 60, + "./torus": 61, + "./utils": 62, + "./vertex-data": 63 + } ], + 57: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = _default; + var _vec = _interopRequireDefault(require("../../value-types/vec3")); + var _vertexData = _interopRequireDefault(require("./vertex-data")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + var temp1 = new _vec["default"](); + var temp2 = new _vec["default"](); + var temp3 = new _vec["default"](); + var r = new _vec["default"](); + var c00 = new _vec["default"](); + var c10 = new _vec["default"](); + var c01 = new _vec["default"](); + function _default(width, length, opts) { + void 0 === width && (width = 10); + void 0 === length && (length = 10); + void 0 === opts && (opts = { + widthSegments: 10, + lengthSegments: 10 + }); + var uSegments = opts.widthSegments; + var vSegments = opts.lengthSegments; + var hw = .5 * width; + var hl = .5 * length; + var positions = []; + var normals = []; + var uvs = []; + var indices = []; + var minPos = new _vec["default"](-hw, 0, -hl); + var maxPos = new _vec["default"](hw, 0, hl); + var boundingRadius = Math.sqrt(width * width + length * length); + _vec["default"].set(c00, -hw, 0, hl); + _vec["default"].set(c10, hw, 0, hl); + _vec["default"].set(c01, -hw, 0, -hl); + for (var y = 0; y <= vSegments; y++) for (var x = 0; x <= uSegments; x++) { + var u = x / uSegments; + var v = y / vSegments; + _vec["default"].lerp(temp1, c00, c10, u); + _vec["default"].lerp(temp2, c00, c01, v); + _vec["default"].sub(temp3, temp2, c00); + _vec["default"].add(r, temp1, temp3); + positions.push(r.x, r.y, r.z); + normals.push(0, 1, 0); + uvs.push(u, v); + if (x < uSegments && y < vSegments) { + var useg1 = uSegments + 1; + var a = x + y * useg1; + var b = x + (y + 1) * useg1; + var c = x + 1 + (y + 1) * useg1; + var d = x + 1 + y * useg1; + indices.push(a, d, b); + indices.push(d, c, b); + } + } + return new _vertexData["default"](positions, normals, uvs, indices, minPos, maxPos, boundingRadius); + } + module.exports = exports["default"]; + }), { + "../../value-types/vec3": 350, + "./vertex-data": 63 + } ], + 58: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports.polyhedron = exports.PolyhedronType = void 0; + var _utils = require("./utils"); + var _vertexData = _interopRequireDefault(require("./vertex-data")); + var _valueTypes = require("../../value-types"); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + var PolyhedronType = cc.Enum({ + Tetrahedron: 0, + Octahedron: 1, + Dodecahedron: 2, + Icosahedron: 3, + Rhombicuboctahedron: 4, + TriangularPrism: 5, + PentagonalPrism: 6, + HexagonalPrism: 7, + SquarePyramid: 8, + PentagonalPyramid: 9, + TriangularDipyramid: 10, + PentagonalDipyramid: 11, + ElongatedSquareDipyramid: 12, + ElongatedPentagonalDipyramid: 13, + ElongatedPentagonalCupola: 14 + }); + exports.PolyhedronType = PolyhedronType; + var polyhedra = []; + polyhedra[0] = { + vertex: [ [ 0, 0, 1.732051 ], [ 1.632993, 0, -.5773503 ], [ -.8164966, 1.414214, -.5773503 ], [ -.8164966, -1.414214, -.5773503 ] ], + face: [ [ 0, 1, 2 ], [ 0, 2, 3 ], [ 0, 3, 1 ], [ 1, 3, 2 ] ] + }; + polyhedra[1] = { + vertex: [ [ 0, 0, 1.414214 ], [ 1.414214, 0, 0 ], [ 0, 1.414214, 0 ], [ -1.414214, 0, 0 ], [ 0, -1.414214, 0 ], [ 0, 0, -1.414214 ] ], + face: [ [ 0, 1, 2 ], [ 0, 2, 3 ], [ 0, 3, 4 ], [ 0, 4, 1 ], [ 1, 4, 5 ], [ 1, 5, 2 ], [ 2, 5, 3 ], [ 3, 5, 4 ] ] + }; + polyhedra[2] = { + vertex: [ [ 0, 0, 1.070466 ], [ .7136442, 0, .7978784 ], [ -.3568221, .618034, .7978784 ], [ -.3568221, -.618034, .7978784 ], [ .7978784, .618034, .3568221 ], [ .7978784, -.618034, .3568221 ], [ -.9341724, .381966, .3568221 ], [ .1362939, 1, .3568221 ], [ .1362939, -1, .3568221 ], [ -.9341724, -.381966, .3568221 ], [ .9341724, .381966, -.3568221 ], [ .9341724, -.381966, -.3568221 ], [ -.7978784, .618034, -.3568221 ], [ -.1362939, 1, -.3568221 ], [ -.1362939, -1, -.3568221 ], [ -.7978784, -.618034, -.3568221 ], [ .3568221, .618034, -.7978784 ], [ .3568221, -.618034, -.7978784 ], [ -.7136442, 0, -.7978784 ], [ 0, 0, -1.070466 ] ], + face: [ [ 0, 1, 4, 7, 2 ], [ 0, 2, 6, 9, 3 ], [ 0, 3, 8, 5, 1 ], [ 1, 5, 11, 10, 4 ], [ 2, 7, 13, 12, 6 ], [ 3, 9, 15, 14, 8 ], [ 4, 10, 16, 13, 7 ], [ 5, 8, 14, 17, 11 ], [ 6, 12, 18, 15, 9 ], [ 10, 11, 17, 19, 16 ], [ 12, 13, 16, 19, 18 ], [ 14, 15, 18, 19, 17 ] ] + }; + polyhedra[3] = { + vertex: [ [ 0, 0, 1.175571 ], [ 1.051462, 0, .5257311 ], [ .3249197, 1, .5257311 ], [ -.8506508, .618034, .5257311 ], [ -.8506508, -.618034, .5257311 ], [ .3249197, -1, .5257311 ], [ .8506508, .618034, -.5257311 ], [ .8506508, -.618034, -.5257311 ], [ -.3249197, 1, -.5257311 ], [ -1.051462, 0, -.5257311 ], [ -.3249197, -1, -.5257311 ], [ 0, 0, -1.175571 ] ], + face: [ [ 0, 1, 2 ], [ 0, 2, 3 ], [ 0, 3, 4 ], [ 0, 4, 5 ], [ 0, 5, 1 ], [ 1, 5, 7 ], [ 1, 7, 6 ], [ 1, 6, 2 ], [ 2, 6, 8 ], [ 2, 8, 3 ], [ 3, 8, 9 ], [ 3, 9, 4 ], [ 4, 9, 10 ], [ 4, 10, 5 ], [ 5, 10, 7 ], [ 6, 7, 11 ], [ 6, 11, 8 ], [ 7, 10, 11 ], [ 8, 11, 9 ], [ 9, 11, 10 ] ] + }; + polyhedra[4] = { + vertex: [ [ 0, 0, 1.070722 ], [ .7148135, 0, .7971752 ], [ -.104682, .7071068, .7971752 ], [ -.6841528, .2071068, .7971752 ], [ -.104682, -.7071068, .7971752 ], [ .6101315, .7071068, .5236279 ], [ 1.04156, .2071068, .1367736 ], [ .6101315, -.7071068, .5236279 ], [ -.3574067, 1, .1367736 ], [ -.7888348, -.5, .5236279 ], [ -.9368776, .5, .1367736 ], [ -.3574067, -1, .1367736 ], [ .3574067, 1, -.1367736 ], [ .9368776, -.5, -.1367736 ], [ .7888348, .5, -.5236279 ], [ .3574067, -1, -.1367736 ], [ -.6101315, .7071068, -.5236279 ], [ -1.04156, -.2071068, -.1367736 ], [ -.6101315, -.7071068, -.5236279 ], [ .104682, .7071068, -.7971752 ], [ .6841528, -.2071068, -.7971752 ], [ .104682, -.7071068, -.7971752 ], [ -.7148135, 0, -.7971752 ], [ 0, 0, -1.070722 ] ], + face: [ [ 0, 2, 3 ], [ 1, 6, 5 ], [ 4, 9, 11 ], [ 7, 15, 13 ], [ 8, 16, 10 ], [ 12, 14, 19 ], [ 17, 22, 18 ], [ 20, 21, 23 ], [ 0, 1, 5, 2 ], [ 0, 3, 9, 4 ], [ 0, 4, 7, 1 ], [ 1, 7, 13, 6 ], [ 2, 5, 12, 8 ], [ 2, 8, 10, 3 ], [ 3, 10, 17, 9 ], [ 4, 11, 15, 7 ], [ 5, 6, 14, 12 ], [ 6, 13, 20, 14 ], [ 8, 12, 19, 16 ], [ 9, 17, 18, 11 ], [ 10, 16, 22, 17 ], [ 11, 18, 21, 15 ], [ 13, 15, 21, 20 ], [ 14, 20, 23, 19 ], [ 16, 19, 23, 22 ], [ 18, 22, 23, 21 ] ] + }; + polyhedra[5] = { + vertex: [ [ 0, 0, 1.322876 ], [ 1.309307, 0, .1889822 ], [ -.9819805, .8660254, .1889822 ], [ .1636634, -1.299038, .1889822 ], [ .3273268, .8660254, -.9449112 ], [ -.8183171, -.4330127, -.9449112 ] ], + face: [ [ 0, 3, 1 ], [ 2, 4, 5 ], [ 0, 1, 4, 2 ], [ 0, 2, 5, 3 ], [ 1, 3, 5, 4 ] ] + }; + polyhedra[6] = { + vertex: [ [ 0, 0, 1.159953 ], [ 1.013464, 0, .5642542 ], [ -.3501431, .9510565, .5642542 ], [ -.7715208, -.6571639, .5642542 ], [ .6633206, .9510565, -.03144481 ], [ .8682979, -.6571639, -.3996071 ], [ -1.121664, .2938926, -.03144481 ], [ -.2348831, -1.063314, -.3996071 ], [ .5181548, .2938926, -.9953061 ], [ -.5850262, -.112257, -.9953061 ] ], + face: [ [ 0, 1, 4, 2 ], [ 0, 2, 6, 3 ], [ 1, 5, 8, 4 ], [ 3, 6, 9, 7 ], [ 5, 7, 9, 8 ], [ 0, 3, 7, 5, 1 ], [ 2, 4, 8, 9, 6 ] ] + }; + polyhedra[7] = { + vertex: [ [ 0, 0, 1.118034 ], [ .8944272, 0, .6708204 ], [ -.2236068, .8660254, .6708204 ], [ -.7826238, -.4330127, .6708204 ], [ .6708204, .8660254, .2236068 ], [ 1.006231, -.4330127, -.2236068 ], [ -1.006231, .4330127, .2236068 ], [ -.6708204, -.8660254, -.2236068 ], [ .7826238, .4330127, -.6708204 ], [ .2236068, -.8660254, -.6708204 ], [ -.8944272, 0, -.6708204 ], [ 0, 0, -1.118034 ] ], + face: [ [ 0, 1, 4, 2 ], [ 0, 2, 6, 3 ], [ 1, 5, 8, 4 ], [ 3, 6, 10, 7 ], [ 5, 9, 11, 8 ], [ 7, 10, 11, 9 ], [ 0, 3, 7, 9, 5, 1 ], [ 2, 4, 8, 11, 10, 6 ] ] + }; + polyhedra[8] = { + vertex: [ [ -.729665, .670121, .319155 ], [ -.655235, -.29213, -.754096 ], [ -.093922, -.607123, .537818 ], [ .702196, .595691, .485187 ], [ .776626, -.36656, -.588064 ] ], + face: [ [ 1, 4, 2 ], [ 0, 1, 2 ], [ 3, 0, 2 ], [ 4, 3, 2 ], [ 4, 1, 0, 3 ] ] + }; + polyhedra[9] = { + vertex: [ [ -.868849, -.100041, .61257 ], [ -.329458, .976099, .28078 ], [ -.26629, -.013796, -.477654 ], [ -.13392, -1.034115, .229829 ], [ .738834, .707117, -.307018 ], [ .859683, -.535264, -.338508 ] ], + face: [ [ 3, 0, 2 ], [ 5, 3, 2 ], [ 4, 5, 2 ], [ 1, 4, 2 ], [ 0, 1, 2 ], [ 0, 3, 5, 4, 1 ] ] + }; + polyhedra[10] = { + vertex: [ [ -.610389, .243975, .531213 ], [ -.187812, -.48795, -.664016 ], [ -.187812, .9759, -.664016 ], [ .187812, -.9759, .664016 ], [ .798201, .243975, .132803 ] ], + face: [ [ 1, 3, 0 ], [ 3, 4, 0 ], [ 3, 1, 4 ], [ 0, 2, 1 ], [ 0, 4, 2 ], [ 2, 4, 1 ] ] + }; + polyhedra[11] = { + vertex: [ [ -1.028778, .392027, -.048786 ], [ -.640503, -.646161, .621837 ], [ -.125162, -.395663, -.540059 ], [ .004683, .888447, -.651988 ], [ .125161, .395663, .540059 ], [ .632925, -.791376, .433102 ], [ 1.031672, .157063, -.354165 ] ], + face: [ [ 3, 2, 0 ], [ 2, 1, 0 ], [ 2, 5, 1 ], [ 0, 4, 3 ], [ 0, 1, 4 ], [ 4, 1, 5 ], [ 2, 3, 6 ], [ 3, 4, 6 ], [ 5, 2, 6 ], [ 4, 5, 6 ] ] + }; + polyhedra[12] = { + vertex: [ [ -.669867, .334933, -.529576 ], [ -.669867, .334933, .529577 ], [ -.4043, 1.212901, 0 ], [ -.334933, -.669867, -.529576 ], [ -.334933, -.669867, .529577 ], [ .334933, .669867, -.529576 ], [ .334933, .669867, .529577 ], [ .4043, -1.212901, 0 ], [ .669867, -.334933, -.529576 ], [ .669867, -.334933, .529577 ] ], + face: [ [ 8, 9, 7 ], [ 6, 5, 2 ], [ 3, 8, 7 ], [ 5, 0, 2 ], [ 4, 3, 7 ], [ 0, 1, 2 ], [ 9, 4, 7 ], [ 1, 6, 2 ], [ 9, 8, 5, 6 ], [ 8, 3, 0, 5 ], [ 3, 4, 1, 0 ], [ 4, 9, 6, 1 ] ] + }; + polyhedra[13] = { + vertex: [ [ -.931836, .219976, -.264632 ], [ -.636706, .318353, .692816 ], [ -.613483, -.735083, -.264632 ], [ -.326545, .979634, 0 ], [ -.318353, -.636706, .692816 ], [ -.159176, .477529, -.856368 ], [ .159176, -.477529, -.856368 ], [ .318353, .636706, .692816 ], [ .326545, -.979634, 0 ], [ .613482, .735082, -.264632 ], [ .636706, -.318353, .692816 ], [ .931835, -.219977, -.264632 ] ], + face: [ [ 11, 10, 8 ], [ 7, 9, 3 ], [ 6, 11, 8 ], [ 9, 5, 3 ], [ 2, 6, 8 ], [ 5, 0, 3 ], [ 4, 2, 8 ], [ 0, 1, 3 ], [ 10, 4, 8 ], [ 1, 7, 3 ], [ 10, 11, 9, 7 ], [ 11, 6, 5, 9 ], [ 6, 2, 0, 5 ], [ 2, 4, 1, 0 ], [ 4, 10, 7, 1 ] ] + }; + polyhedra[14] = { + vertex: [ [ -.93465, .300459, -.271185 ], [ -.838689, -.260219, -.516017 ], [ -.711319, .717591, .128359 ], [ -.710334, -.156922, .080946 ], [ -.599799, .556003, -.725148 ], [ -.503838, -.004675, -.969981 ], [ -.487004, .26021, .48049 ], [ -.460089, -.750282, -.512622 ], [ -.376468, .973135, -.325605 ], [ -.331735, -.646985, .084342 ], [ -.254001, .831847, .530001 ], [ -.125239, -.494738, -.966586 ], [ .029622, .027949, .730817 ], [ .056536, -.982543, -.262295 ], [ .08085, 1.087391, .076037 ], [ .125583, -.532729, .485984 ], [ .262625, .599586, .780328 ], [ .391387, -.726999, -.716259 ], [ .513854, -.868287, .139347 ], [ .597475, .85513, .326364 ], [ .641224, .109523, .783723 ], [ .737185, -.451155, .538891 ], [ .848705, -.612742, -.314616 ], [ .976075, .365067, .32976 ], [ 1.072036, -.19561, .084927 ] ], + face: [ [ 15, 18, 21 ], [ 12, 20, 16 ], [ 6, 10, 2 ], [ 3, 0, 1 ], [ 9, 7, 13 ], [ 2, 8, 4, 0 ], [ 0, 4, 5, 1 ], [ 1, 5, 11, 7 ], [ 7, 11, 17, 13 ], [ 13, 17, 22, 18 ], [ 18, 22, 24, 21 ], [ 21, 24, 23, 20 ], [ 20, 23, 19, 16 ], [ 16, 19, 14, 10 ], [ 10, 14, 8, 2 ], [ 15, 9, 13, 18 ], [ 12, 15, 21, 20 ], [ 6, 12, 16, 10 ], [ 3, 6, 2, 0 ], [ 9, 3, 1, 7 ], [ 9, 15, 12, 6, 3 ], [ 22, 17, 11, 5, 4, 8, 14, 19, 23, 24 ] ] + }; + var polyhedron = function polyhedron(type, size, opts) { + void 0 === size && (size = 1); + void 0 === opts && (opts = { + sizeX: 0, + sizeY: 0, + sizeZ: 0 + }); + type = type && (type < 0 || type >= polyhedra.length) ? 0 : type || 0; + var sizeX = opts.sizeX || size; + var sizeY = opts.sizeY || size; + var sizeZ = opts.sizeZ || size; + var data = polyhedra[type]; + var nbfaces = data.face.length; + var positions = []; + var indices = []; + var normals = []; + var uvs = []; + var minPos = new _valueTypes.Vec3(Infinity, Infinity, Infinity); + var maxPos = new _valueTypes.Vec3(-Infinity, -Infinity, -Infinity); + for (var i = 0; i < data.vertex.length; i++) { + var x = data.vertex[i][0] * sizeX; + var y = data.vertex[i][1] * sizeY; + var z = data.vertex[i][2] * sizeZ; + minPos.x = Math.min(minPos.x, x); + minPos.y = Math.min(minPos.y, y); + minPos.z = Math.min(minPos.z, z); + maxPos.x = Math.max(maxPos.x, x); + maxPos.y = Math.max(maxPos.y, y); + maxPos.z = Math.max(maxPos.z, z); + positions.push(x, y, z); + uvs.push(0, 0); + } + for (var f = 0; f < nbfaces; f++) for (var _i = 0; _i < data.face[f].length - 2; _i++) indices.push(data.face[f][0], data.face[f][_i + 2], data.face[f][_i + 1]); + (0, _utils.calcNormals)(positions, indices, normals); + var boundingRadius = Math.sqrt(Math.pow(maxPos.x - minPos.x, 2), Math.pow(maxPos.y - minPos.y, 2), Math.pow(maxPos.z - minPos.z, 2)); + return new _vertexData["default"](positions, normals, uvs, indices, minPos, maxPos, boundingRadius); + }; + exports.polyhedron = polyhedron; + }), { + "../../value-types": 340, + "./utils": 62, + "./vertex-data": 63 + } ], + 59: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = _default; + var _vertexData = _interopRequireDefault(require("./vertex-data")); + var _valueTypes = require("../../value-types"); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + var positions = [ -.5, -.5, 0, -.5, .5, 0, .5, .5, 0, .5, -.5, 0 ]; + var normals = [ 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1 ]; + var uvs = [ 0, 0, 0, 1, 1, 1, 1, 0 ]; + var indices = [ 0, 3, 1, 3, 2, 1 ]; + var minPos = new _valueTypes.Vec3(-.5, -.5, 0); + var maxPos = new _valueTypes.Vec3(.5, .5, 0); + var boundingRadius = Math.sqrt(.5); + function _default() { + return new _vertexData["default"](positions, normals, uvs, indices, minPos, maxPos, boundingRadius); + } + module.exports = exports["default"]; + }), { + "../../value-types": 340, + "./vertex-data": 63 + } ], + 60: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = _default; + var _vertexData = _interopRequireDefault(require("./vertex-data")); + var _valueTypes = require("../../value-types"); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _default(radius, opts) { + void 0 === radius && (radius = .5); + void 0 === opts && (opts = { + segments: 32 + }); + var segments = opts.segments; + var positions = []; + var normals = []; + var uvs = []; + var indices = []; + var minPos = new _valueTypes.Vec3(-radius, -radius, -radius); + var maxPos = new _valueTypes.Vec3(radius, radius, radius); + var boundingRadius = radius; + for (var lat = 0; lat <= segments; ++lat) { + var theta = lat * Math.PI / segments; + var sinTheta = Math.sin(theta); + var cosTheta = -Math.cos(theta); + for (var lon = 0; lon <= segments; ++lon) { + var phi = 2 * lon * Math.PI / segments - Math.PI / 2; + var sinPhi = Math.sin(phi); + var cosPhi = Math.cos(phi); + var x = sinPhi * sinTheta; + var y = cosTheta; + var z = cosPhi * sinTheta; + var u = lon / segments; + var v = lat / segments; + positions.push(x * radius, y * radius, z * radius); + normals.push(x, y, z); + uvs.push(u, v); + if (lat < segments && lon < segments) { + var seg1 = segments + 1; + var a = seg1 * lat + lon; + var b = seg1 * (lat + 1) + lon; + var c = seg1 * (lat + 1) + lon + 1; + var d = seg1 * lat + lon + 1; + indices.push(a, d, b); + indices.push(d, c, b); + } + } + } + return new _vertexData["default"](positions, normals, uvs, indices, minPos, maxPos, boundingRadius); + } + module.exports = exports["default"]; + }), { + "../../value-types": 340, + "./vertex-data": 63 + } ], + 61: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = _default; + var _vertexData = _interopRequireDefault(require("./vertex-data")); + var _valueTypes = require("../../value-types"); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _default(radius, tube, opts) { + void 0 === radius && (radius = .4); + void 0 === tube && (tube = .1); + void 0 === opts && (opts = { + radialSegments: 32, + tubularSegments: 32, + arc: 2 * Math.PI + }); + var radialSegments = opts.radialSegments; + var tubularSegments = opts.tubularSegments; + var arc = opts.arc; + var positions = []; + var normals = []; + var uvs = []; + var indices = []; + var minPos = new _valueTypes.Vec3(-radius - tube, -tube, -radius - tube); + var maxPos = new _valueTypes.Vec3(radius + tube, tube, radius + tube); + var boundingRadius = radius + tube; + for (var j = 0; j <= radialSegments; j++) for (var i = 0; i <= tubularSegments; i++) { + var u = i / tubularSegments; + var v = j / radialSegments; + var u1 = u * arc; + var v1 = v * Math.PI * 2; + var x = (radius + tube * Math.cos(v1)) * Math.sin(u1); + var y = tube * Math.sin(v1); + var z = (radius + tube * Math.cos(v1)) * Math.cos(u1); + var nx = Math.sin(u1) * Math.cos(v1); + var ny = Math.sin(v1); + var nz = Math.cos(u1) * Math.cos(v1); + positions.push(x, y, z); + normals.push(nx, ny, nz); + uvs.push(u, v); + if (i < tubularSegments && j < radialSegments) { + var seg1 = tubularSegments + 1; + var a = seg1 * j + i; + var b = seg1 * (j + 1) + i; + var c = seg1 * (j + 1) + i + 1; + var d = seg1 * j + i + 1; + indices.push(a, d, b); + indices.push(d, c, b); + } + } + return new _vertexData["default"](positions, normals, uvs, indices, minPos, maxPos, boundingRadius); + } + module.exports = exports["default"]; + }), { + "../../value-types": 340, + "./vertex-data": 63 + } ], + 62: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports.calcNormals = calcNormals; + exports.invWinding = invWinding; + exports.normals = normals; + exports.toWavefrontOBJ = toWavefrontOBJ; + exports.wireframe = wireframe; + var _vec = _interopRequireDefault(require("../../value-types/vec3")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function wireframe(indices) { + var offsets = [ [ 0, 1 ], [ 1, 2 ], [ 2, 0 ] ]; + var lines = []; + var lineIDs = {}; + for (var i = 0; i < indices.length; i += 3) for (var k = 0; k < 3; ++k) { + var i1 = indices[i + offsets[k][0]]; + var i2 = indices[i + offsets[k][1]]; + var id = i1 > i2 ? i2 << 16 | i1 : i1 << 16 | i2; + if (void 0 === lineIDs[id]) { + lineIDs[id] = 0; + lines.push(i1, i2); + } + } + return lines; + } + function invWinding(indices) { + var newIB = []; + for (var i = 0; i < indices.length; i += 3) newIB.push(indices[i], indices[i + 2], indices[i + 1]); + return newIB; + } + function toWavefrontOBJ(primitive, scale) { + void 0 === scale && (scale = 1); + var v = primitive.positions, t = primitive.uvs, n = primitive.normals, IB = primitive.indices; + var V = function V(i) { + return IB[i] + 1 + "/" + (IB[i] + 1) + "/" + (IB[i] + 1); + }; + var content = ""; + for (var i = 0; i < v.length; i += 3) content += "v " + v[i] * scale + " " + v[i + 1] * scale + " " + v[i + 2] * scale + "\n"; + for (var _i = 0; _i < t.length; _i += 2) content += "vt " + t[_i] + " " + t[_i + 1] + "\n"; + for (var _i2 = 0; _i2 < n.length; _i2 += 3) content += "vn " + n[_i2] + " " + n[_i2 + 1] + " " + n[_i2 + 2] + "\n"; + for (var _i3 = 0; _i3 < IB.length; _i3 += 3) content += "f " + V(_i3) + " " + V(_i3 + 1) + " " + V(_i3 + 2) + "\n"; + return content; + } + function normals(positions, normals, length) { + void 0 === length && (length = 1); + var verts = new Array(2 * positions.length); + for (var i = 0; i < positions.length / 3; ++i) { + var i3 = 3 * i; + var i6 = 6 * i; + verts[i6 + 0] = positions[i3 + 0]; + verts[i6 + 1] = positions[i3 + 1]; + verts[i6 + 2] = positions[i3 + 2]; + verts[i6 + 3] = positions[i3 + 0] + normals[i3 + 0] * length; + verts[i6 + 4] = positions[i3 + 1] + normals[i3 + 1] * length; + verts[i6 + 5] = positions[i3 + 2] + normals[i3 + 2] * length; + } + return verts; + } + function fromArray(out, a, offset) { + out.x = a[offset]; + out.y = a[offset + 1]; + out.z = a[offset + 2]; + } + function calcNormals(positions, indices, normals) { + normals = normals || new Array(positions.length); + for (var i = 0, l = normals.length; i < l; i++) normals[i] = 0; + var vA, vB, vC; + var pA = cc.v3(), pB = cc.v3(), pC = cc.v3(); + var cb = cc.v3(), ab = cc.v3(); + for (var _i4 = 0, il = indices.length; _i4 < il; _i4 += 3) { + vA = 3 * indices[_i4 + 0]; + vB = 3 * indices[_i4 + 1]; + vC = 3 * indices[_i4 + 2]; + fromArray(pA, positions, vA); + fromArray(pB, positions, vB); + fromArray(pC, positions, vC); + _vec["default"].subtract(cb, pC, pB); + _vec["default"].subtract(ab, pA, pB); + _vec["default"].cross(cb, cb, ab); + normals[vA] += cb.x; + normals[vA + 1] += cb.y; + normals[vA + 2] += cb.z; + normals[vB] += cb.x; + normals[vB + 1] += cb.y; + normals[vB + 2] += cb.z; + normals[vC] += cb.x; + normals[vC + 1] += cb.y; + normals[vC + 2] += cb.z; + } + var tempNormal = cc.v3(); + for (var _i5 = 0, _l = normals.length; _i5 < _l; _i5 += 3) { + tempNormal.x = normals[_i5]; + tempNormal.y = normals[_i5 + 1]; + tempNormal.z = normals[_i5 + 2]; + tempNormal.normalizeSelf(); + normals[_i5] = tempNormal.x; + normals[_i5 + 1] = tempNormal.y; + normals[_i5 + 2] = tempNormal.z; + } + return normals; + } + }), { + "../../value-types/vec3": 350 + } ], + 63: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var VertexData = function VertexData(positions, normals, uvs, indices, minPos, maxPos, boundingRadius) { + this.positions = void 0; + this.normals = void 0; + this.uvs = void 0; + this.indices = void 0; + this.minPos = void 0; + this.maxPos = void 0; + this.boundingRadius = void 0; + this.positions = positions; + this.normals = normals; + this.uvs = uvs; + this.indices = indices; + this.minPos = minPos; + this.maxPos = maxPos; + this.boundingRadius = boundingRadius; + }; + exports["default"] = VertexData; + module.exports = exports["default"]; + }), {} ], + 64: [ (function(require, module, exports) { + "use strict"; + var _require = require("../../../animation/animation-curves"), DynamicAnimCurve = _require.DynamicAnimCurve, quickFindIndex = _require.quickFindIndex; + var JointMatrixCurve = cc.Class({ + name: "cc.JointMatrixCurve", + extends: DynamicAnimCurve, + _findFrameIndex: quickFindIndex, + sample: function sample(time, ratio) { + var ratios = this.ratios; + var index = this._findFrameIndex(ratios, ratio); + index < -1 && (index = ~index - 1); + var pairs = this.pairs; + for (var i = 0; i < pairs.length; i++) { + var pair = pairs[i]; + pair.target._jointMatrix = pair.values[index]; + } + } + }); + module.exports = JointMatrixCurve; + }), { + "../../../animation/animation-curves": 12 + } ], + 65: [ (function(require, module, exports) { + "use strict"; + var Skeleton = cc.Class({ + name: "cc.Skeleton", + extends: cc.Asset, + ctor: function ctor() { + this.loaded = false; + this._bindposes = []; + this._uniqueBindPoses = []; + this._jointPaths = []; + }, + properties: { + _model: cc.Model, + _jointIndices: [], + _skinIndex: -1, + jointPaths: { + get: function get() { + return this._jointPaths; + } + }, + bindposes: { + get: function get() { + return this._bindposes; + } + }, + uniqueBindPoses: { + get: function get() { + return this._uniqueBindPoses; + } + }, + model: { + get: function get() { + return this._model; + } + } + }, + onLoad: function onLoad() { + var nodes = this._model.nodes; + var jointIndices = this._jointIndices; + var jointPaths = this._jointPaths; + var bindposes = this._bindposes; + var uniqueBindPoses = this._uniqueBindPoses; + for (var i = 0; i < jointIndices.length; i++) { + var node = nodes[jointIndices[i]]; + jointPaths[i] = node.path; + node.uniqueBindPose ? bindposes[i] = uniqueBindPoses[i] = node.uniqueBindPose : bindposes[i] = node.bindpose[this._skinIndex]; + } + } + }); + cc.Skeleton = module.exports = Skeleton; + }), {} ], + 66: [ (function(require, module, exports) { + "use strict"; + var Animation = require("../../components/CCAnimation"); + var Model = require("../CCModel"); + var SkeletonAnimationClip = require("./CCSkeletonAnimationClip"); + var SkeletonAnimation = cc.Class({ + name: "cc.SkeletonAnimation", + extends: Animation, + editor: false, + properties: { + _model: { + default: null, + type: Model + }, + _defaultClip: { + override: true, + default: null, + type: SkeletonAnimationClip + }, + _clips: { + override: true, + default: [], + type: [ SkeletonAnimationClip ], + visible: true + }, + defaultClip: { + override: true, + get: function get() { + return this._defaultClip; + }, + set: function set(v) { + this._defaultClip = v; + }, + type: SkeletonAnimationClip + }, + model: { + get: function get() { + return this._model; + }, + set: function set(val) { + this._model = val; + this._updateClipModel(); + }, + type: Model + } + }, + __preload: function __preload() { + this._updateClipModel(); + }, + _updateClipModel: function _updateClipModel() { + this._defaultClip && (this._defaultClip._model = this._model); + var clips = this._clips; + for (var i = 0; i < clips.length; i++) clips[i]._model = this._model; + }, + addClip: function addClip(clip, newName) { + clip._model = this._model; + return Animation.prototype.addClip.call(this, clip, newName); + }, + searchClips: false + }); + cc.SkeletonAnimation = module.exports = SkeletonAnimation; + }), { + "../../components/CCAnimation": 145, + "../CCModel": 28, + "./CCSkeletonAnimationClip": 67, + "fire-path": void 0 + } ], + 67: [ (function(require, module, exports) { + "use strict"; + var _mat = _interopRequireDefault(require("../../value-types/mat4")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + var AnimationClip = require("../../../animation/animation-clip"); + var JointMatrixCurve = require("./CCJointMatrixCurve"); + function maxtrixToArray(matrix) { + var data = new Float32Array(16); + data.set(matrix.m); + return data; + } + var SkeletonAnimationClip = cc.Class({ + name: "cc.SkeletonAnimationClip", + extends: AnimationClip, + properties: { + _nativeAsset: { + override: true, + get: function get() { + return this._buffer; + }, + set: function set(bin) { + var buffer = ArrayBuffer.isView(bin) ? bin.buffer : bin; + this._buffer = new Float32Array(buffer || bin, 0, buffer.byteLength / 4); + } + }, + description: { + default: null, + type: Object + }, + curveData: { + visible: false, + override: true, + get: function get() { + return this._curveData || {}; + }, + set: function set() {} + } + }, + statics: { + preventDeferredLoadDependents: true + }, + _init: function _init() { + if (this._curveData) return this._curveData; + this._curveData = {}; + this._generateCommonCurve(); + this._model.precomputeJointMatrix && this._generateJointMatrixCurve(); + return this._curveData; + }, + _generateCommonCurve: function _generateCommonCurve() { + var buffer = this._buffer; + var description = this.description; + var offset = 0; + function getValue() { + return buffer[offset++]; + } + this._curveData.paths || (this._curveData.paths = {}); + var paths = this._curveData.paths; + for (var path in description) { + var des = description[path]; + var curves = {}; + paths[path] = { + props: curves + }; + for (var property in des) { + var frames = []; + var frameCount = des[property].frameCount; + offset = des[property].offset; + for (var i = 0; i < frameCount; i++) { + var frame = getValue(); + var value = void 0; + "position" === property || "scale" === property ? value = cc.v3(getValue(), getValue(), getValue()) : "quat" === property && (value = cc.quat(getValue(), getValue(), getValue(), getValue())); + frames.push({ + frame: frame, + value: value + }); + } + curves[property] = frames; + } + } + }, + _generateJointMatrixCurve: function _generateJointMatrixCurve() { + var rootNode = this._model.rootNode; + var curveData = this._curveData; + var paths = curveData.paths; + var newCurveData = { + ratios: [], + jointMatrixMap: {} + }; + var jointMatrixMap = newCurveData.jointMatrixMap; + function walk(node, time, pm) { + var matrix; + var EPSILON = 1e-4; + var path = paths[node.path]; + if (node !== rootNode && path) { + var props = path.props; + for (var prop in props) { + var frames = props[prop]; + for (var i = 0; i < frames.length; i++) { + var end = frames[i]; + if (Math.abs(end.frame - time) < EPSILON) { + node[prop].set(end.value); + break; + } + if (end.frame > time) { + var start = frames[i - 1]; + var ratio = (time - start.frame) / (end.frame - start.frame); + start.value.lerp(end.value, ratio, node[prop]); + break; + } + } + } + matrix = cc.mat4(); + _mat["default"].fromRTS(matrix, node.quat, node.position, node.scale); + pm && _mat["default"].mul(matrix, pm, matrix); + props._jointMatrix || (props._jointMatrix = []); + var bindWorldMatrix; + if (node.uniqueBindPose) { + bindWorldMatrix = cc.mat4(); + _mat["default"].mul(bindWorldMatrix, matrix, node.uniqueBindPose); + } + jointMatrixMap[node.path] || (jointMatrixMap[node.path] = []); + bindWorldMatrix ? jointMatrixMap[node.path].push(maxtrixToArray(bindWorldMatrix)) : jointMatrixMap[node.path].push(matrix); + } + var children = node.children; + for (var name in children) { + var child = children[name]; + walk(child, time, matrix); + } + } + var time = 0; + var duration = this.duration; + var step = 1 / this.sample; + while (time < duration) { + newCurveData.ratios.push(time / duration); + walk(rootNode, time); + time += step; + } + this._curveData = newCurveData; + }, + _createJointMatrixCurve: function _createJointMatrixCurve(state, root) { + var curve = new JointMatrixCurve(); + curve.ratios = this.curveData.ratios; + curve.pairs = []; + var jointMatrixMap = this.curveData.jointMatrixMap; + for (var path in jointMatrixMap) { + var target = cc.find(path, root); + if (!target) continue; + curve.pairs.push({ + target: target, + values: jointMatrixMap[path] + }); + } + return [ curve ]; + }, + createCurves: function createCurves(state, root) { + if (!this._model) { + cc.warn("Skeleton Animation Clip [" + this.name + "] Can not find model"); + return []; + } + this._init(); + return this._model.precomputeJointMatrix ? this._createJointMatrixCurve(state, root) : AnimationClip.prototype.createCurves.call(this, state, root); + } + }); + cc.SkeletonAnimationClip = module.exports = SkeletonAnimationClip; + }), { + "../../../animation/animation-clip": 11, + "../../value-types/mat4": 342, + "./CCJointMatrixCurve": 64 + } ], + 68: [ (function(require, module, exports) { + "use strict"; + var _mat = _interopRequireDefault(require("../../value-types/mat4")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + var Skeleton = require("./CCSkeleton"); + var MeshRenderer = require("../../mesh/CCMeshRenderer"); + var RenderFlow = require("../../renderer/render-flow"); + var enums = require("../../../renderer/enums"); + var _m4_tmp = cc.mat4(); + var _m4_tmp2 = cc.mat4(); + var SkinnedMeshRenderer = cc.Class({ + name: "cc.SkinnedMeshRenderer", + extends: MeshRenderer, + editor: false, + ctor: function ctor() { + this._jointsData = this._jointsFloat32Data = null; + this._jointsTexture = null; + this._joints = []; + this._dummyNode = new cc.Node(); + this._jointsTextureOptions = null; + this._usingRGBA8Texture = false; + }, + properties: { + _skeleton: Skeleton, + _rootBone: cc.Node, + skeleton: { + get: function get() { + return this._skeleton; + }, + set: function set(val) { + this._skeleton = val; + this._init(); + }, + type: Skeleton + }, + rootBone: { + get: function get() { + return this._rootBone; + }, + set: function set(val) { + this._rootBone = val; + this._init(); + }, + type: cc.Node + }, + enableAutoBatch: { + get: function get() { + return false; + }, + visible: false, + override: true + } + }, + __preload: function __preload() { + this._super(); + this._init(); + }, + _init: function _init() { + this._model = this._skeleton && this._skeleton.model; + this._calFunc = null; + this._initJoints(); + this._initJointsTexture(); + this._initCalcFunc(); + this._updateRenderNode(); + }, + _calcWorldMatrixToRoot: function _calcWorldMatrixToRoot(joint) { + var worldMatrixToRoot = joint._worldMatrixToRoot; + if (worldMatrixToRoot) return; + joint._worldMatrixToRoot = worldMatrixToRoot = cc.mat4(); + joint.getLocalMatrix(worldMatrixToRoot); + var parent = joint.parent; + if (parent !== this.rootBone) { + parent._worldMatrixToRoot || this._calcWorldMatrixToRoot(parent); + _mat["default"].mul(worldMatrixToRoot, parent._worldMatrixToRoot, worldMatrixToRoot); + } + }, + _validateRender: function _validateRender() { + if (!this._jointsData) { + this.disableRender(); + return; + } + this._super(); + }, + _initJoints: function _initJoints() { + var joints = this._joints; + joints.length = 0; + if (!this.skeleton || !this.rootBone) return; + var useJointMatrix = this._useJointMatrix(); + var jointPaths = this.skeleton.jointPaths; + var rootBone = this.rootBone; + for (var i = 0; i < jointPaths.length; i++) { + var joint = cc.find(jointPaths[i], rootBone); + joint || cc.warn("Can not find joint in root bone [%s] with path [%s]", rootBone.name, jointPaths[i]); + if (useJointMatrix) { + joint._renderFlag &= ~RenderFlow.FLAG_CHILDREN; + this._calcWorldMatrixToRoot(joint); + } + joints.push(joint); + } + if (useJointMatrix) { + var uniqueBindPoses = this.skeleton.uniqueBindPoses; + for (var _i = 0; _i < jointPaths.length; _i++) { + var _joint = joints[_i]; + if (uniqueBindPoses[_i]) { + _mat["default"].mul(_m4_tmp, _joint._worldMatrixToRoot, uniqueBindPoses[_i]); + _joint._jointMatrix = _mat["default"].toArray([], _m4_tmp); + } else _joint._jointMatrix = _joint._worldMatrixToRoot; + } + } + }, + _initJointsTexture: function _initJointsTexture() { + if (!this._skeleton) return; + var jointCount = this._joints.length; + var inited = false; + if (jointCount <= cc.sys.getMaxJointMatrixSize()) { + inited = true; + this._jointsData = this._jointsFloat32Data = new Float32Array(16 * jointCount); + } + if (!inited) { + var SUPPORT_FLOAT_TEXTURE = !!cc.sys.glExtension("OES_texture_float"); + var size; + size = jointCount > 256 ? 64 : jointCount > 64 ? 32 : jointCount > 16 ? 16 : 8; + this._jointsData = this._jointsFloat32Data = new Float32Array(size * size * 4); + var pixelFormat = cc.Texture2D.PixelFormat.RGBA32F, width = size, height = size; + if (!SUPPORT_FLOAT_TEXTURE) { + this._jointsData = new Uint8Array(this._jointsFloat32Data.buffer); + pixelFormat = cc.Texture2D.PixelFormat.RGBA8888; + width *= 4; + this._usingRGBA8Texture = true; + cc.warn("SkinnedMeshRenderer [" + this.node.name + "] has too many joints [" + jointCount + "] and device do not support float32 texture, fallback to use RGBA8888 texture, which is much slower."); + } + var texture = this._jointsTexture || new cc.Texture2D(); + var NEAREST = cc.Texture2D.Filter.NEAREST; + texture.setFilters(NEAREST, NEAREST); + texture.initWithData(this._jointsData, pixelFormat, width, height); + this._jointsTexture = texture; + this._jointsTextureOptions = { + format: pixelFormat, + width: texture.width, + height: texture.height, + images: [] + }; + } + this._updateMaterial(); + }, + _updateMaterial: function _updateMaterial() { + MeshRenderer.prototype._updateMaterial.call(this); + var materials = this.getMaterials(); + for (var i = 0; i < materials.length; i++) { + var material = materials[i]; + if (this._jointsTexture) { + material.setProperty("jointsTexture", this._jointsTexture); + material.setProperty("jointsTextureSize", new Float32Array([ this._jointsTexture.width, this._jointsTexture.height ])); + material.define("CC_JOINTS_TEXTURE_FLOAT32", !!cc.sys.glExtension("OES_texture_float")); + material.define("CC_USE_JOINTS_TEXTRUE", true); + } else { + this._jointsFloat32Data && material.setProperty("jointMatrices", this._jointsFloat32Data, void 0, true); + material.define("CC_USE_JOINTS_TEXTRUE", false); + } + material.define("CC_USE_SKINNING", true); + } + }, + _setJointsDataWithArray: function _setJointsDataWithArray(iMatrix, matrixArray) { + var data = this._jointsFloat32Data; + data.set(matrixArray, 16 * iMatrix); + }, + _setJointsDataWithMatrix: function _setJointsDataWithMatrix(iMatrix, matrix) { + this._jointsFloat32Data.set(matrix.m, 16 * iMatrix); + }, + _commitJointsData: function _commitJointsData() { + if (this._jointsTexture) { + this._jointsTextureOptions.images[0] = this._jointsData; + this._jointsTexture.update(this._jointsTextureOptions); + } + }, + _useJointMatrix: function _useJointMatrix() { + return this._model && this._model.precomputeJointMatrix; + }, + _updateRenderNode: function _updateRenderNode() { + this._useJointMatrix() || this._usingRGBA8Texture ? this._assembler.setRenderNode(this.rootBone) : this._assembler.setRenderNode(this._dummyNode); + }, + _initCalcFunc: function _initCalcFunc() { + this._useJointMatrix() ? this._calFunc = this._calJointMatrix : this._usingRGBA8Texture ? this._calFunc = this._calRGBA8WorldMatrix : this._calFunc = this._calWorldMatrix; + }, + _calJointMatrix: function _calJointMatrix() { + var joints = this._joints; + var bindposes = this.skeleton.bindposes; + var uniqueBindPoses = this.skeleton.uniqueBindPoses; + for (var i = 0; i < joints.length; ++i) { + var joint = joints[i]; + var jointMatrix = joint._jointMatrix; + if (uniqueBindPoses[i]) this._setJointsDataWithArray(i, jointMatrix); else { + _mat["default"].multiply(_m4_tmp, jointMatrix, bindposes[i]); + this._setJointsDataWithMatrix(i, _m4_tmp); + } + } + }, + _calRGBA8WorldMatrix: function _calRGBA8WorldMatrix() { + var joints = this._joints; + var bindposes = this.skeleton.bindposes; + this.rootBone._updateWorldMatrix(); + var rootMatrix = this.rootBone._worldMatrix; + var invRootMat = _mat["default"].invert(_m4_tmp2, rootMatrix); + for (var i = 0; i < joints.length; ++i) { + var joint = joints[i]; + joint._updateWorldMatrix(); + _mat["default"].multiply(_m4_tmp, invRootMat, joint._worldMatrix); + _mat["default"].multiply(_m4_tmp, _m4_tmp, bindposes[i]); + this._setJointsDataWithMatrix(i, _m4_tmp); + } + }, + _calWorldMatrix: function _calWorldMatrix() { + var joints = this._joints; + var bindposes = this.skeleton.bindposes; + for (var i = 0; i < joints.length; ++i) { + var joint = joints[i]; + joint._updateWorldMatrix(); + _mat["default"].multiply(_m4_tmp, joint._worldMatrix, bindposes[i]); + this._setJointsDataWithMatrix(i, _m4_tmp); + } + }, + calcJointMatrix: function calcJointMatrix() { + if (!this.skeleton || !this.rootBone) return; + this._calFunc.call(this); + this._commitJointsData(); + } + }); + cc.SkinnedMeshRenderer = module.exports = SkinnedMeshRenderer; + }), { + "../../../renderer/enums": 368, + "../../mesh/CCMeshRenderer": 209, + "../../renderer/render-flow": 273, + "../../value-types/mat4": 342, + "./CCSkeleton": 65 + } ], + 69: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + _setPrototypeOf(subClass, superClass); + } + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + return _setPrototypeOf(o, p); + } + var SkinnedMeshRenderer = require("./CCSkinnedMeshRenderer"); + var MeshRendererAssembler = require("../../mesh/mesh-renderer"); + var RenderFlow = require("../../renderer/render-flow"); + var SkinnedMeshRendererAssembler = (function(_MeshRendererAssemble) { + _inheritsLoose(SkinnedMeshRendererAssembler, _MeshRendererAssemble); + function SkinnedMeshRendererAssembler() { + return _MeshRendererAssemble.apply(this, arguments) || this; + } + var _proto = SkinnedMeshRendererAssembler.prototype; + _proto.fillBuffers = function fillBuffers(comp, renderer) { + comp.calcJointMatrix(); + _MeshRendererAssemble.prototype.fillBuffers.call(this, comp, renderer); + }; + return SkinnedMeshRendererAssembler; + })(MeshRendererAssembler); + exports["default"] = SkinnedMeshRendererAssembler; + cc.Assembler.register(SkinnedMeshRenderer, SkinnedMeshRendererAssembler); + module.exports = exports["default"]; + }), { + "../../mesh/mesh-renderer": 212, + "../../renderer/render-flow": 273, + "./CCSkinnedMeshRenderer": 68 + } ], + 70: [ (function(require, module, exports) { + "use strict"; + var utils = require("./platform/utils"); + var debugInfos = require("../../DebugInfos") || {}; + var ERROR_MAP_URL = "https://github.com/cocos-creator/engine/blob/master/EngineErrorMap.md"; + var logList; + cc.log = cc.warn = cc.error = cc.assert = console.log.bind ? console.log.bind(console) : console.log; + var resetDebugSetting = function resetDebugSetting(mode) { + cc.log = cc.warn = cc.error = cc.assert = function() {}; + if (mode === DebugMode.NONE) return; + if (mode > DebugMode.ERROR) { + var logToWebPage = function logToWebPage(msg) { + if (!cc.game.canvas) return; + if (!logList) { + var logDiv = document.createElement("Div"); + logDiv.setAttribute("id", "logInfoDiv"); + logDiv.setAttribute("width", "200"); + logDiv.setAttribute("height", cc.game.canvas.height); + var logDivStyle = logDiv.style; + logDivStyle.zIndex = "99999"; + logDivStyle.position = "absolute"; + logDivStyle.top = logDivStyle.left = "0"; + logList = document.createElement("textarea"); + logList.setAttribute("rows", "20"); + logList.setAttribute("cols", "30"); + logList.setAttribute("disabled", "true"); + var logListStyle = logList.style; + logListStyle.backgroundColor = "transparent"; + logListStyle.borderBottom = "1px solid #cccccc"; + logListStyle.borderTopWidth = logListStyle.borderLeftWidth = logListStyle.borderRightWidth = "0px"; + logListStyle.borderTopStyle = logListStyle.borderLeftStyle = logListStyle.borderRightStyle = "none"; + logListStyle.padding = "0px"; + logListStyle.margin = 0; + logDiv.appendChild(logList); + cc.game.canvas.parentNode.appendChild(logDiv); + } + logList.value = logList.value + msg + "\r\n"; + logList.scrollTop = logList.scrollHeight; + }; + cc.error = function() { + logToWebPage("ERROR : " + cc.js.formatStr.apply(null, arguments)); + }; + cc.assert = function(cond, msg) { + if (!cond && msg) { + msg = cc.js.formatStr.apply(null, cc.js.shiftArguments.apply(null, arguments)); + logToWebPage("ASSERT: " + msg); + } + }; + mode !== DebugMode.ERROR_FOR_WEB_PAGE && (cc.warn = function() { + logToWebPage("WARN : " + cc.js.formatStr.apply(null, arguments)); + }); + mode === DebugMode.INFO_FOR_WEB_PAGE && (cc.log = function() { + logToWebPage(cc.js.formatStr.apply(null, arguments)); + }); + } else if (console && console.log.apply) { + console.error || (console.error = console.log); + console.warn || (console.warn = console.log); + false; + console.error.bind ? cc.error = console.error.bind(console) : cc.error = (false, + function() { + return console.error.apply(console, arguments); + }); + cc.assert = function(cond, msg) { + if (!cond) { + msg && (msg = cc.js.formatStr.apply(null, cc.js.shiftArguments.apply(null, arguments))); + false; + false; + throw new Error(msg); + } + }; + } + if (mode !== DebugMode.ERROR) { + false; + console.warn.bind ? cc.warn = console.warn.bind(console) : cc.warn = (false, function() { + return console.warn.apply(console, arguments); + }); + } + false; + if (mode === DebugMode.INFO) { + false, false; + console.log.bind ? cc.log = console.log.bind(console) : cc.log = function() { + return console.log.apply(console, arguments); + }; + } + }; + cc._throw = function(error) { + utils.callInNextTick((function() { + throw error; + })); + }; + function getTypedFormatter(type) { + return function() { + var id = arguments[0]; + var msg = debugInfos[id] || "unknown id"; + if (1 === arguments.length) return msg; + if (2 === arguments.length) return cc.js.formatStr(msg, arguments[1]); + var argsArray = cc.js.shiftArguments.apply(null, arguments); + return cc.js.formatStr.apply(null, [ msg ].concat(argsArray)); + }; + } + var logFormatter = getTypedFormatter("Log"); + cc.logID = function() { + cc.log(logFormatter.apply(null, arguments)); + }; + var warnFormatter = getTypedFormatter("Warning"); + cc.warnID = function() { + cc.warn(warnFormatter.apply(null, arguments)); + }; + var errorFormatter = getTypedFormatter("Error"); + cc.errorID = function() { + cc.error(errorFormatter.apply(null, arguments)); + }; + var assertFormatter = getTypedFormatter("Assert"); + cc.assertID = function(cond) { + if (cond) return; + cc.assert(false, assertFormatter.apply(null, cc.js.shiftArguments.apply(null, arguments))); + }; + var DebugMode = cc.Enum({ + NONE: 0, + INFO: 1, + WARN: 2, + ERROR: 3, + INFO_FOR_WEB_PAGE: 4, + WARN_FOR_WEB_PAGE: 5, + ERROR_FOR_WEB_PAGE: 6 + }); + module.exports = cc.debug = { + DebugMode: DebugMode, + _resetDebugSetting: resetDebugSetting, + getError: getTypedFormatter("ERROR"), + isDisplayStats: function isDisplayStats() { + return !!cc.profiler && cc.profiler.isShowingStats(); + }, + setDisplayStats: function setDisplayStats(displayStats) { + if (cc.profiler && cc.game.renderType !== cc.game.RENDER_TYPE_CANVAS) { + displayStats ? cc.profiler.showStats() : cc.profiler.hideStats(); + cc.game.config.showFPS = !!displayStats; + } + } + }; + }), { + "../../DebugInfos": 1, + "./platform/utils": 264 + } ], + 71: [ (function(require, module, exports) { + "use strict"; + var EventTarget = require("./event/event-target"); + var ComponentScheduler = require("./component-scheduler"); + var NodeActivator = require("./node-activator"); + var Obj = require("./platform/CCObject"); + var game = require("./CCGame"); + var renderer = require("./renderer"); + var eventManager = require("./event-manager"); + var Scheduler = require("./CCScheduler"); + cc.Director = function() { + EventTarget.call(this); + this._paused = false; + this._purgeDirectorInNextLoop = false; + this._winSizeInPoints = null; + this._scene = null; + this._loadingScene = ""; + this._totalFrames = 0; + this._lastUpdate = 0; + this._deltaTime = 0; + this._startTime = 0; + this._maxParticleDeltaTime = 0; + this._scheduler = null; + this._compScheduler = null; + this._nodeActivator = null; + this._actionManager = null; + var self = this; + game.on(game.EVENT_SHOW, (function() { + self._lastUpdate = performance.now(); + })); + game.once(game.EVENT_ENGINE_INITED, this.init, this); + }; + cc.Director.prototype = { + constructor: cc.Director, + init: function init() { + this._totalFrames = 0; + this._lastUpdate = performance.now(); + this._startTime = this._lastUpdate; + this._paused = false; + this._purgeDirectorInNextLoop = false; + this._winSizeInPoints = cc.size(0, 0); + this._scheduler = new Scheduler(); + if (cc.ActionManager) { + this._actionManager = new cc.ActionManager(); + this._scheduler.scheduleUpdate(this._actionManager, Scheduler.PRIORITY_SYSTEM, false); + } else this._actionManager = null; + this.sharedInit(); + return true; + }, + sharedInit: function sharedInit() { + this._compScheduler = new ComponentScheduler(); + this._nodeActivator = new NodeActivator(); + eventManager && eventManager.setEnabled(true); + if (cc.AnimationManager) { + this._animationManager = new cc.AnimationManager(); + this._scheduler.scheduleUpdate(this._animationManager, Scheduler.PRIORITY_SYSTEM, false); + } else this._animationManager = null; + if (cc.CollisionManager) { + this._collisionManager = new cc.CollisionManager(); + this._scheduler.scheduleUpdate(this._collisionManager, Scheduler.PRIORITY_SYSTEM, false); + } else this._collisionManager = null; + if (cc.PhysicsManager) { + this._physicsManager = new cc.PhysicsManager(); + this._scheduler.scheduleUpdate(this._physicsManager, Scheduler.PRIORITY_SYSTEM, false); + } else this._physicsManager = null; + if (cc.Physics3DManager && (false, true)) { + this._physics3DManager = new cc.Physics3DManager(); + this._scheduler.scheduleUpdate(this._physics3DManager, Scheduler.PRIORITY_SYSTEM, false); + } else this._physics3DManager = null; + cc._widgetManager && cc._widgetManager.init(this); + }, + calculateDeltaTime: function calculateDeltaTime(now) { + now || (now = performance.now()); + this._deltaTime = now > this._lastUpdate ? (now - this._lastUpdate) / 1e3 : 0; + (true, this._deltaTime > 1) && (this._deltaTime = 1 / 60); + this._lastUpdate = now; + }, + convertToGL: function convertToGL(uiPoint) { + var container = game.container; + var view = cc.view; + var box = container.getBoundingClientRect(); + var left = box.left + window.pageXOffset - container.clientLeft; + var top = box.top + window.pageYOffset - container.clientTop; + var x = view._devicePixelRatio * (uiPoint.x - left); + var y = view._devicePixelRatio * (top + box.height - uiPoint.y); + return view._isRotated ? cc.v2(view._viewportRect.width - y, x) : cc.v2(x, y); + }, + convertToUI: function convertToUI(glPoint) { + var container = game.container; + var view = cc.view; + var box = container.getBoundingClientRect(); + var left = box.left + window.pageXOffset - container.clientLeft; + var top = box.top + window.pageYOffset - container.clientTop; + var uiPoint = cc.v2(0, 0); + if (view._isRotated) { + uiPoint.x = left + glPoint.y / view._devicePixelRatio; + uiPoint.y = top + box.height - (view._viewportRect.width - glPoint.x) / view._devicePixelRatio; + } else { + uiPoint.x = left + glPoint.x * view._devicePixelRatio; + uiPoint.y = top + box.height - glPoint.y * view._devicePixelRatio; + } + return uiPoint; + }, + end: function end() { + this._purgeDirectorInNextLoop = true; + }, + getWinSize: function getWinSize() { + return cc.size(cc.winSize); + }, + getWinSizeInPixels: function getWinSizeInPixels() { + return cc.size(cc.winSize); + }, + pause: function pause() { + if (this._paused) return; + this._paused = true; + }, + purgeCachedData: function purgeCachedData() { + cc.assetManager.releaseAll(); + }, + purgeDirector: function purgeDirector() { + this._scheduler.unscheduleAll(); + this._compScheduler.unscheduleAll(); + this._nodeActivator.reset(); + eventManager && eventManager.setEnabled(false); + true; + cc.isValid(this._scene) && this._scene.destroy(); + this._scene = null; + cc.renderer.clear(); + cc.assetManager.builtins.clear(); + cc.game.pause(); + cc.assetManager.releaseAll(); + }, + reset: function reset() { + this.purgeDirector(); + eventManager && eventManager.setEnabled(true); + this._actionManager && this._scheduler.scheduleUpdate(this._actionManager, cc.Scheduler.PRIORITY_SYSTEM, false); + this._animationManager && this._scheduler.scheduleUpdate(this._animationManager, cc.Scheduler.PRIORITY_SYSTEM, false); + this._collisionManager && this._scheduler.scheduleUpdate(this._collisionManager, cc.Scheduler.PRIORITY_SYSTEM, false); + this._physicsManager && this._scheduler.scheduleUpdate(this._physicsManager, cc.Scheduler.PRIORITY_SYSTEM, false); + cc.game.resume(); + }, + runSceneImmediate: function runSceneImmediate(scene, onBeforeLoadScene, onLaunched) { + cc.assertID(scene instanceof cc.Scene || scene instanceof cc.SceneAsset, 1216); + scene instanceof cc.SceneAsset && (scene = scene.scene); + (true, true) && console.time("InitScene"); + scene._load(); + (true, true) && console.timeEnd("InitScene"); + (true, true) && console.time("AttachPersist"); + var persistNodeList = Object.keys(game._persistRootNodes).map((function(x) { + return game._persistRootNodes[x]; + })); + for (var i = 0; i < persistNodeList.length; i++) { + var node = persistNodeList[i]; + var existNode = scene.getChildByUuid(node.uuid); + if (existNode) { + var index = existNode.getSiblingIndex(); + existNode._destroyImmediate(); + scene.insertChild(node, index); + } else node.parent = scene; + } + (true, true) && console.timeEnd("AttachPersist"); + var oldScene = this._scene; + true; + (true, true) && console.time("AutoRelease"); + cc.assetManager._releaseManager._autoRelease(oldScene, scene, game._persistRootNodes); + (true, true) && console.timeEnd("AutoRelease"); + (true, true) && console.time("Destroy"); + cc.isValid(oldScene) && oldScene.destroy(); + this._scene = null; + Obj._deferredDestroy(); + (true, true) && console.timeEnd("Destroy"); + onBeforeLoadScene && onBeforeLoadScene(); + this.emit(cc.Director.EVENT_BEFORE_SCENE_LAUNCH, scene); + this._scene = scene; + (true, true) && console.time("Activate"); + scene._activate(); + (true, true) && console.timeEnd("Activate"); + cc.game.resume(); + onLaunched && onLaunched(null, scene); + this.emit(cc.Director.EVENT_AFTER_SCENE_LAUNCH, scene); + }, + runScene: function runScene(scene, onBeforeLoadScene, onLaunched) { + cc.assertID(scene, 1205); + cc.assertID(scene instanceof cc.Scene || scene instanceof cc.SceneAsset, 1216); + scene instanceof cc.SceneAsset && (scene = scene.scene); + scene._load(); + this.once(cc.Director.EVENT_AFTER_DRAW, (function() { + this.runSceneImmediate(scene, onBeforeLoadScene, onLaunched); + }), this); + }, + loadScene: function loadScene(sceneName, onLaunched, _onUnloaded) { + if (this._loadingScene) { + cc.warnID(1208, sceneName, this._loadingScene); + return false; + } + var bundle = cc.assetManager.bundles.find((function(bundle) { + return bundle.getSceneInfo(sceneName); + })); + if (bundle) { + this.emit(cc.Director.EVENT_BEFORE_SCENE_LOADING, sceneName); + this._loadingScene = sceneName; + var self = this; + console.time("LoadScene " + sceneName); + bundle.loadScene(sceneName, (function(err, scene) { + console.timeEnd("LoadScene " + sceneName); + self._loadingScene = ""; + if (err) { + err = "Failed to load scene: " + err; + cc.error(err); + onLaunched && onLaunched(err); + } else self.runSceneImmediate(scene, _onUnloaded, onLaunched); + })); + return true; + } + cc.errorID(1209, sceneName); + return false; + }, + preloadScene: function preloadScene(sceneName, onProgress, onLoaded) { + var bundle = cc.assetManager.bundles.find((function(bundle) { + return bundle.getSceneInfo(sceneName); + })); + if (!bundle) { + cc.errorID(1209, sceneName); + return null; + } + bundle.preloadScene(sceneName, null, onProgress, onLoaded); + }, + resume: function resume() { + if (!this._paused) return; + this._lastUpdate = performance.now(); + this._lastUpdate || cc.logID(1200); + this._paused = false; + this._deltaTime = 0; + }, + setDepthTest: function setDepthTest(value) { + if (!cc.Camera.main) return; + cc.Camera.main.depth = !!value; + }, + setClearColor: function setClearColor(clearColor) { + if (!cc.Camera.main) return; + cc.Camera.main.backgroundColor = clearColor; + }, + getRunningScene: function getRunningScene() { + return this._scene; + }, + getScene: function getScene() { + return this._scene; + }, + getAnimationInterval: function getAnimationInterval() { + return 1e3 / game.getFrameRate(); + }, + setAnimationInterval: function setAnimationInterval(value) { + game.setFrameRate(Math.round(1e3 / value)); + }, + getDeltaTime: function getDeltaTime() { + return this._deltaTime; + }, + getTotalTime: function getTotalTime() { + return performance.now() - this._startTime; + }, + getTotalFrames: function getTotalFrames() { + return this._totalFrames; + }, + isPaused: function isPaused() { + return this._paused; + }, + getScheduler: function getScheduler() { + return this._scheduler; + }, + setScheduler: function setScheduler(scheduler) { + this._scheduler !== scheduler && (this._scheduler = scheduler); + }, + getActionManager: function getActionManager() { + return this._actionManager; + }, + setActionManager: function setActionManager(actionManager) { + if (this._actionManager !== actionManager) { + this._actionManager && this._scheduler.unscheduleUpdate(this._actionManager); + this._actionManager = actionManager; + this._scheduler.scheduleUpdate(this._actionManager, cc.Scheduler.PRIORITY_SYSTEM, false); + } + }, + getAnimationManager: function getAnimationManager() { + return this._animationManager; + }, + getCollisionManager: function getCollisionManager() { + return this._collisionManager; + }, + getPhysicsManager: function getPhysicsManager() { + return this._physicsManager; + }, + getPhysics3DManager: function getPhysics3DManager() { + return this._physics3DManager; + }, + startAnimation: function startAnimation() { + cc.game.resume(); + }, + stopAnimation: function stopAnimation() { + cc.game.pause(); + }, + _resetDeltaTime: function _resetDeltaTime() { + this._lastUpdate = performance.now(); + this._deltaTime = 0; + }, + mainLoop: function(now) { + if (this._purgeDirectorInNextLoop) { + this._purgeDirectorInNextLoop = false; + this.purgeDirector(); + } else { + this.calculateDeltaTime(now); + if (!this._paused) { + this.emit(cc.Director.EVENT_BEFORE_UPDATE); + this._compScheduler.startPhase(); + this._compScheduler.updatePhase(this._deltaTime); + this._scheduler.update(this._deltaTime); + this._compScheduler.lateUpdatePhase(this._deltaTime); + this.emit(cc.Director.EVENT_AFTER_UPDATE); + Obj._deferredDestroy(); + } + this.emit(cc.Director.EVENT_BEFORE_DRAW); + renderer.render(this._scene, this._deltaTime); + this.emit(cc.Director.EVENT_AFTER_DRAW); + eventManager.frameUpdateListeners(); + this._totalFrames++; + } + }, + __fastOn: function __fastOn(type, callback, target) { + this.on(type, callback, target); + }, + __fastOff: function __fastOff(type, callback, target) { + this.off(type, callback, target); + } + }; + cc.js.addon(cc.Director.prototype, EventTarget.prototype); + cc.Director.EVENT_PROJECTION_CHANGED = "director_projection_changed"; + cc.Director.EVENT_BEFORE_SCENE_LOADING = "director_before_scene_loading"; + cc.Director.EVENT_BEFORE_SCENE_LAUNCH = "director_before_scene_launch"; + cc.Director.EVENT_AFTER_SCENE_LAUNCH = "director_after_scene_launch"; + cc.Director.EVENT_BEFORE_UPDATE = "director_before_update"; + cc.Director.EVENT_AFTER_UPDATE = "director_after_update"; + cc.Director.EVENT_BEFORE_VISIT = "director_before_draw"; + cc.Director.EVENT_AFTER_VISIT = "director_before_draw"; + cc.Director.EVENT_BEFORE_DRAW = "director_before_draw"; + cc.Director.EVENT_AFTER_DRAW = "director_after_draw"; + cc.Director.PROJECTION_2D = 0; + cc.Director.PROJECTION_3D = 1; + cc.Director.PROJECTION_CUSTOM = 3; + cc.Director.PROJECTION_DEFAULT = cc.Director.PROJECTION_2D; + cc.Director.EVENT_BEFORE_PHYSICS = "director_before_physics"; + cc.Director.EVENT_AFTER_PHYSICS = "director_after_physics"; + cc.director = new cc.Director(); + module.exports = cc.director; + }), { + "./CCGame": 72, + "./CCScheduler": 76, + "./component-scheduler": 144, + "./event-manager": 185, + "./event/event-target": 187, + "./node-activator": 213, + "./platform/CCObject": 246, + "./renderer": 272 + } ], + 72: [ (function(require, module, exports) { + "use strict"; + var EventTarget = require("./event/event-target"); + require("../audio/CCAudioEngine"); + var debug = require("./CCDebug"); + var renderer = require("./renderer/index.js"); + var dynamicAtlasManager = require("../core/renderer/utils/dynamic-atlas/manager"); + var game = { + EVENT_HIDE: "game_on_hide", + EVENT_SHOW: "game_on_show", + EVENT_RESTART: "game_on_restart", + EVENT_GAME_INITED: "game_inited", + EVENT_ENGINE_INITED: "engine_inited", + EVENT_RENDERER_INITED: "engine_inited", + RENDER_TYPE_CANVAS: 0, + RENDER_TYPE_WEBGL: 1, + RENDER_TYPE_OPENGL: 2, + _persistRootNodes: {}, + _paused: true, + _configLoaded: false, + _isCloning: false, + _prepared: false, + _rendererInitialized: false, + _renderContext: null, + _intervalId: null, + _lastTime: null, + _frameTime: null, + frame: null, + container: null, + canvas: null, + renderType: -1, + config: null, + onStart: null, + setFrameRate: function setFrameRate(frameRate) { + var config = this.config; + config.frameRate = frameRate; + this._intervalId && window.cancelAnimFrame(this._intervalId); + this._intervalId = 0; + this._paused = true; + this._setAnimFrame(); + this._runMainLoop(); + }, + getFrameRate: function getFrameRate() { + return this.config.frameRate; + }, + step: function step() { + cc.director.mainLoop(); + }, + pause: function pause() { + if (this._paused) return; + this._paused = true; + cc.audioEngine && cc.audioEngine._break(); + this._intervalId && window.cancelAnimFrame(this._intervalId); + this._intervalId = 0; + }, + resume: function resume() { + if (!this._paused) return; + this._paused = false; + cc.audioEngine && cc.audioEngine._restore(); + cc.director._resetDeltaTime(); + this._runMainLoop(); + }, + isPaused: function isPaused() { + return this._paused; + }, + restart: function restart() { + cc.director.once(cc.Director.EVENT_AFTER_DRAW, (function() { + for (var id in game._persistRootNodes) game.removePersistRootNode(game._persistRootNodes[id]); + cc.director.getScene().destroy(); + cc.Object._deferredDestroy(); + cc.audioEngine && cc.audioEngine.uncacheAll(); + cc.director.reset(); + game.pause(); + cc.assetManager.builtins.init((function() { + game.onStart(); + game.emit(game.EVENT_RESTART); + })); + })); + }, + end: function end() { + close(); + }, + _initEngine: function _initEngine() { + if (this._rendererInitialized) return; + this._initRenderer(); + true; + this._initEvents(); + this.emit(this.EVENT_ENGINE_INITED); + }, + _loadPreviewScript: function _loadPreviewScript(cb) { + false; + cb(); + }, + _prepareFinished: function _prepareFinished(cb) { + var _this = this; + this._initEngine(); + this._setAnimFrame(); + cc.assetManager.builtins.init((function() { + console.log("Cocos Creator v" + cc.ENGINE_VERSION); + _this._prepared = true; + _this._runMainLoop(); + _this.emit(_this.EVENT_GAME_INITED); + cb && cb(); + })); + }, + eventTargetOn: EventTarget.prototype.on, + eventTargetOnce: EventTarget.prototype.once, + on: function on(type, callback, target, once) { + this._prepared && type === this.EVENT_ENGINE_INITED || !this._paused && type === this.EVENT_GAME_INITED ? callback.call(target) : this.eventTargetOn(type, callback, target, once); + }, + once: function once(type, callback, target) { + this._prepared && type === this.EVENT_ENGINE_INITED || !this._paused && type === this.EVENT_GAME_INITED ? callback.call(target) : this.eventTargetOnce(type, callback, target); + }, + prepare: function prepare(cb) { + var _this2 = this; + if (this._prepared) { + cb && cb(); + return; + } + this._loadPreviewScript((function() { + _this2._prepareFinished(cb); + })); + }, + run: function run(config, onStart) { + this._initConfig(config); + this.onStart = onStart; + this.prepare(game.onStart && game.onStart.bind(game)); + }, + addPersistRootNode: function addPersistRootNode(node) { + if (!cc.Node.isNode(node) || !node.uuid) { + cc.warnID(3800); + return; + } + var id = node.uuid; + if (!this._persistRootNodes[id]) { + var scene = cc.director._scene; + if (cc.isValid(scene)) if (node.parent) { + if (!(node.parent instanceof cc.Scene)) { + cc.warnID(3801); + return; + } + if (node.parent !== scene) { + cc.warnID(3802); + return; + } + } else node.parent = scene; + this._persistRootNodes[id] = node; + node._persistNode = true; + cc.assetManager._releaseManager._addPersistNodeRef(node); + } + }, + removePersistRootNode: function removePersistRootNode(node) { + var id = node.uuid || ""; + if (node === this._persistRootNodes[id]) { + delete this._persistRootNodes[id]; + node._persistNode = false; + cc.assetManager._releaseManager._removePersistNodeRef(node); + } + }, + isPersistRootNode: function isPersistRootNode(node) { + return node._persistNode; + }, + _setAnimFrame: function _setAnimFrame() { + this._lastTime = performance.now(); + var frameRate = game.config.frameRate; + this._frameTime = 1e3 / frameRate; + cc.director._maxParticleDeltaTime = this._frameTime / 1e3 * 2; + false, false; + var rAF = window.requestAnimationFrame = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame; + if (60 !== frameRate && 30 !== frameRate) { + window.requestAnimFrame = rAF ? this._stTimeWithRAF : this._stTime; + window.cancelAnimFrame = this._ctTime; + } else { + window.requestAnimFrame = rAF || this._stTime; + window.cancelAnimFrame = window.cancelAnimationFrame || window.cancelRequestAnimationFrame || window.msCancelRequestAnimationFrame || window.mozCancelRequestAnimationFrame || window.oCancelRequestAnimationFrame || window.webkitCancelRequestAnimationFrame || window.msCancelAnimationFrame || window.mozCancelAnimationFrame || window.webkitCancelAnimationFrame || window.oCancelAnimationFrame || this._ctTime; + } + }, + _stTimeWithRAF: function _stTimeWithRAF(callback) { + var currTime = performance.now(); + var timeToCall = Math.max(0, game._frameTime - (currTime - game._lastTime)); + var id = window.setTimeout((function() { + window.requestAnimationFrame(callback); + }), timeToCall); + game._lastTime = currTime + timeToCall; + return id; + }, + _stTime: function _stTime(callback) { + var currTime = performance.now(); + var timeToCall = Math.max(0, game._frameTime - (currTime - game._lastTime)); + var id = window.setTimeout((function() { + callback(); + }), timeToCall); + game._lastTime = currTime + timeToCall; + return id; + }, + _ctTime: function _ctTime(id) { + window.clearTimeout(id); + }, + _runMainLoop: function _runMainLoop() { + false; + if (!this._prepared) return; + var self = this, _callback, config = self.config, director = cc.director, skip = true, frameRate = config.frameRate; + debug.setDisplayStats(config.showFPS); + _callback = function callback(now) { + if (!self._paused) { + self._intervalId = window.requestAnimFrame(_callback); + if ((true, true) && 30 === frameRate && (skip = !skip)) return; + director.mainLoop(now); + } + }; + self._intervalId = window.requestAnimFrame(_callback); + self._paused = false; + }, + _initConfig: function _initConfig(config) { + "number" !== typeof config.debugMode && (config.debugMode = 0); + config.exposeClassName = !!config.exposeClassName; + "number" !== typeof config.frameRate && (config.frameRate = 60); + var renderMode = config.renderMode; + ("number" !== typeof renderMode || renderMode > 2 || renderMode < 0) && (config.renderMode = 0); + "boolean" !== typeof config.registerSystemEvent && (config.registerSystemEvent = true); + config.showFPS = 1 !== renderMode && !!config.showFPS; + this.collisionMatrix = config.collisionMatrix || []; + this.groupList = config.groupList || []; + debug._resetDebugSetting(config.debugMode); + this.config = config; + this._configLoaded = true; + }, + _determineRenderType: function _determineRenderType() { + var config = this.config, userRenderMode = parseInt(config.renderMode) || 0; + this.renderType = this.RENDER_TYPE_CANVAS; + var supportRender = false; + if (0 === userRenderMode) { + if (cc.sys.capabilities["opengl"]) { + this.renderType = this.RENDER_TYPE_WEBGL; + supportRender = true; + } else if (cc.sys.capabilities["canvas"]) { + this.renderType = this.RENDER_TYPE_CANVAS; + supportRender = true; + } + } else if (1 === userRenderMode && cc.sys.capabilities["canvas"]) { + this.renderType = this.RENDER_TYPE_CANVAS; + supportRender = true; + } else if (2 === userRenderMode && cc.sys.capabilities["opengl"]) { + this.renderType = this.RENDER_TYPE_WEBGL; + supportRender = true; + } + if (!supportRender) throw new Error(debug.getError(3820, userRenderMode)); + }, + _initRenderer: function _initRenderer() { + if (this._rendererInitialized) return; + var el = this.config.id, width, height, localCanvas, localContainer; + false, false; + var addClass = function addClass(element, name) { + var hasClass = (" " + element.className + " ").indexOf(" " + name + " ") > -1; + if (!hasClass) { + element.className && (element.className += " "); + element.className += name; + } + }; + var element = el instanceof HTMLElement ? el : document.querySelector(el) || document.querySelector("#" + el); + if ("CANVAS" === element.tagName) { + width = element.width; + height = element.height; + this.canvas = localCanvas = element; + this.container = localContainer = document.createElement("DIV"); + localCanvas.parentNode && localCanvas.parentNode.insertBefore(localContainer, localCanvas); + } else { + "DIV" !== element.tagName && cc.warnID(3819); + width = element.clientWidth; + height = element.clientHeight; + this.canvas = localCanvas = document.createElement("CANVAS"); + this.container = localContainer = document.createElement("DIV"); + element.appendChild(localContainer); + } + localContainer.setAttribute("id", "Cocos2dGameContainer"); + localContainer.appendChild(localCanvas); + this.frame = localContainer.parentNode === document.body ? document.documentElement : localContainer.parentNode; + addClass(localCanvas, "gameCanvas"); + localCanvas.setAttribute("width", width || 480); + localCanvas.setAttribute("height", height || 320); + localCanvas.setAttribute("tabindex", 99); + this._determineRenderType(); + if (this.renderType === this.RENDER_TYPE_WEBGL) { + var opts = { + stencil: true, + antialias: cc.macro.ENABLE_WEBGL_ANTIALIAS, + alpha: cc.macro.ENABLE_TRANSPARENT_CANVAS + }; + renderer.initWebGL(localCanvas, opts); + this._renderContext = renderer.device._gl; + !cc.macro.CLEANUP_IMAGE_CACHE && dynamicAtlasManager && (dynamicAtlasManager.enabled = true); + } + if (!this._renderContext) { + this.renderType = this.RENDER_TYPE_CANVAS; + renderer.initCanvas(localCanvas); + this._renderContext = renderer.device._ctx; + } + this.canvas.oncontextmenu = function() { + if (!cc._isContextMenuEnable) return false; + }; + this._rendererInitialized = true; + }, + _initEvents: function _initEvents() { + var win = window, hiddenPropName; + this.config.registerSystemEvent && cc.internal.inputManager.registerSystemEvent(this.canvas); + "undefined" !== typeof document.hidden ? hiddenPropName = "hidden" : "undefined" !== typeof document.mozHidden ? hiddenPropName = "mozHidden" : "undefined" !== typeof document.msHidden ? hiddenPropName = "msHidden" : "undefined" !== typeof document.webkitHidden && (hiddenPropName = "webkitHidden"); + var hidden = false; + function onHidden() { + if (!hidden) { + hidden = true; + game.emit(game.EVENT_HIDE); + } + } + function onShown(arg0, arg1, arg2, arg3, arg4) { + if (hidden) { + hidden = false; + game.emit(game.EVENT_SHOW, arg0, arg1, arg2, arg3, arg4); + } + } + if (hiddenPropName) { + var changeList = [ "visibilitychange", "mozvisibilitychange", "msvisibilitychange", "webkitvisibilitychange", "qbrowserVisibilityChange" ]; + for (var i = 0; i < changeList.length; i++) document.addEventListener(changeList[i], (function(event) { + var visible = document[hiddenPropName]; + visible = visible || event["hidden"]; + visible ? onHidden() : onShown(); + })); + } else { + win.addEventListener("blur", onHidden); + win.addEventListener("focus", onShown); + } + navigator.userAgent.indexOf("MicroMessenger") > -1 && (win.onfocus = onShown); + if ("onpageshow" in window && "onpagehide" in window) { + win.addEventListener("pagehide", onHidden); + win.addEventListener("pageshow", onShown); + document.addEventListener("pagehide", onHidden); + document.addEventListener("pageshow", onShown); + } + this.on(game.EVENT_HIDE, (function() { + game.pause(); + })); + this.on(game.EVENT_SHOW, (function() { + game.resume(); + })); + } + }; + EventTarget.call(game); + cc.js.addon(game, EventTarget.prototype); + cc.game = module.exports = game; + }), { + "../audio/CCAudioEngine": 22, + "../core/renderer/utils/dynamic-atlas/manager": 275, + "./CCDebug": 70, + "./event/event-target": 187, + "./renderer/index.js": 272 + } ], + 73: [ (function(require, module, exports) { + "use strict"; + var _valueTypes = require("./value-types"); + var _utils = require("./value-types/utils"); + var BaseNode = require("./utils/base-node"); + var PrefabHelper = require("./utils/prefab-helper"); + var nodeMemPool = require("./utils/trans-pool").NodeMemPool; + var AffineTrans = require("./utils/affine-transform"); + var eventManager = require("./event-manager"); + var macro = require("./platform/CCMacro"); + var js = require("./platform/js"); + var Event = require("./event/event"); + var EventTarget = require("./event/event-target"); + var RenderFlow = require("./renderer/render-flow"); + var Flags = cc.Object.Flags; + var Destroying = Flags.Destroying; + var ERR_INVALID_NUMBER = false; + var ONE_DEGREE = Math.PI / 180; + var ActionManagerExist = !!cc.ActionManager; + var emptyFunc = function emptyFunc() {}; + var _gwpVec3 = new _valueTypes.Vec3(); + var _gwpQuat = new _valueTypes.Quat(); + var _tpVec3a = new _valueTypes.Vec3(); + var _tpVec3b = new _valueTypes.Vec3(); + var _tpQuata = new _valueTypes.Quat(); + var _tpQuatb = new _valueTypes.Quat(); + var _swpVec3 = new _valueTypes.Vec3(); + var _gwsVec3 = new _valueTypes.Vec3(); + var _swsVec3 = new _valueTypes.Vec3(); + var _gwrtVec3a = new _valueTypes.Vec3(); + var _gwrtVec3b = new _valueTypes.Vec3(); + var _gwrtQuata = new _valueTypes.Quat(); + var _gwrtQuatb = new _valueTypes.Quat(); + var _laVec3 = new _valueTypes.Vec3(); + var _laQuat = new _valueTypes.Quat(); + var _urfVec3 = new _valueTypes.Vec3(); + var _urfQuat = new _valueTypes.Quat(); + var _htVec3a = new _valueTypes.Vec3(); + var _htVec3b = new _valueTypes.Vec3(); + var _gwrQuat = new _valueTypes.Quat(); + var _swrQuat = new _valueTypes.Quat(); + var _quata = new _valueTypes.Quat(); + var _mat4_temp = cc.mat4(); + var _vec3_temp = new _valueTypes.Vec3(); + var POSITION_ON = 1; + var SCALE_ON = 2; + var ROTATION_ON = 4; + var SIZE_ON = 8; + var ANCHOR_ON = 16; + var COLOR_ON = 32; + var _cachedPool = new js.Pool(); + _cachedPool.get = function() { + return this._get() || []; + }; + var BuiltinGroupIndex = cc.Enum({ + DEBUG: 31 + }); + var LocalDirtyFlag = cc.Enum({ + POSITION: 1, + SCALE: 2, + ROTATION: 4, + SKEW: 8, + TRS: 7, + RS: 6, + TRSS: 15, + PHYSICS_POSITION: 16, + PHYSICS_SCALE: 32, + PHYSICS_ROTATION: 64, + PHYSICS_TRS: 112, + PHYSICS_RS: 96, + ALL_POSITION: 17, + ALL_SCALE: 34, + ALL_ROTATION: 68, + ALL_TRS: 119, + ALL: 65535 + }); + var EventType = cc.Enum({ + TOUCH_START: "touchstart", + TOUCH_MOVE: "touchmove", + TOUCH_END: "touchend", + TOUCH_CANCEL: "touchcancel", + MOUSE_DOWN: "mousedown", + MOUSE_MOVE: "mousemove", + MOUSE_ENTER: "mouseenter", + MOUSE_LEAVE: "mouseleave", + MOUSE_UP: "mouseup", + MOUSE_WHEEL: "mousewheel", + POSITION_CHANGED: "position-changed", + ROTATION_CHANGED: "rotation-changed", + SCALE_CHANGED: "scale-changed", + SIZE_CHANGED: "size-changed", + ANCHOR_CHANGED: "anchor-changed", + COLOR_CHANGED: "color-changed", + CHILD_ADDED: "child-added", + CHILD_REMOVED: "child-removed", + CHILD_REORDER: "child-reorder", + GROUP_CHANGED: "group-changed", + SIBLING_ORDER_CHANGED: "sibling-order-changed" + }); + var _touchEvents = [ EventType.TOUCH_START, EventType.TOUCH_MOVE, EventType.TOUCH_END, EventType.TOUCH_CANCEL ]; + var _mouseEvents = [ EventType.MOUSE_DOWN, EventType.MOUSE_ENTER, EventType.MOUSE_MOVE, EventType.MOUSE_LEAVE, EventType.MOUSE_UP, EventType.MOUSE_WHEEL ]; + var _skewNeedWarn = true; + var _skewWarn = function _skewWarn(value, node) { + if (0 !== value) { + var nodePath = ""; + var NodeUtils; + false; + _skewNeedWarn && cc.warn("`cc.Node.skewX/Y` is deprecated since v2.2.1, please use 3D node instead.", nodePath); + true, _skewNeedWarn = false; + } + }; + var _currentHovered = null; + var _touchStartHandler = function _touchStartHandler(touch, event) { + var pos = touch.getLocation(); + var node = this.owner; + if (node._hitTest(pos, this)) { + event.type = EventType.TOUCH_START; + event.touch = touch; + event.bubbles = true; + node.dispatchEvent(event); + return true; + } + return false; + }; + var _touchMoveHandler = function _touchMoveHandler(touch, event) { + var node = this.owner; + event.type = EventType.TOUCH_MOVE; + event.touch = touch; + event.bubbles = true; + node.dispatchEvent(event); + }; + var _touchEndHandler = function _touchEndHandler(touch, event) { + var pos = touch.getLocation(); + var node = this.owner; + node._hitTest(pos, this) ? event.type = EventType.TOUCH_END : event.type = EventType.TOUCH_CANCEL; + event.touch = touch; + event.bubbles = true; + node.dispatchEvent(event); + }; + var _touchCancelHandler = function _touchCancelHandler(touch, event) { + var pos = touch.getLocation(); + var node = this.owner; + event.type = EventType.TOUCH_CANCEL; + event.touch = touch; + event.bubbles = true; + node.dispatchEvent(event); + }; + var _mouseDownHandler = function _mouseDownHandler(event) { + var pos = event.getLocation(); + var node = this.owner; + if (node._hitTest(pos, this)) { + event.type = EventType.MOUSE_DOWN; + event.bubbles = true; + node.dispatchEvent(event); + } + }; + var _mouseMoveHandler = function _mouseMoveHandler(event) { + var pos = event.getLocation(); + var node = this.owner; + var hit = node._hitTest(pos, this); + if (hit) { + if (!this._previousIn) { + if (_currentHovered && _currentHovered._mouseListener) { + event.type = EventType.MOUSE_LEAVE; + _currentHovered.dispatchEvent(event); + _currentHovered._mouseListener._previousIn = false; + } + _currentHovered = this.owner; + event.type = EventType.MOUSE_ENTER; + node.dispatchEvent(event); + this._previousIn = true; + } + event.type = EventType.MOUSE_MOVE; + event.bubbles = true; + node.dispatchEvent(event); + } else { + if (!this._previousIn) return; + event.type = EventType.MOUSE_LEAVE; + node.dispatchEvent(event); + this._previousIn = false; + _currentHovered = null; + } + event.stopPropagation(); + }; + var _mouseUpHandler = function _mouseUpHandler(event) { + var pos = event.getLocation(); + var node = this.owner; + if (node._hitTest(pos, this)) { + event.type = EventType.MOUSE_UP; + event.bubbles = true; + node.dispatchEvent(event); + event.stopPropagation(); + } + }; + var _mouseWheelHandler = function _mouseWheelHandler(event) { + var pos = event.getLocation(); + var node = this.owner; + if (node._hitTest(pos, this)) { + event.type = EventType.MOUSE_WHEEL; + event.bubbles = true; + node.dispatchEvent(event); + event.stopPropagation(); + } + }; + function _searchComponentsInParent(node, comp) { + if (comp) { + var index = 0; + var list = null; + for (var curr = node; curr && cc.Node.isNode(curr); curr = curr._parent, ++index) if (curr.getComponent(comp)) { + var next = { + index: index, + node: curr + }; + list ? list.push(next) : list = [ next ]; + } + return list; + } + return null; + } + function _checkListeners(node, events) { + if (!(node._objFlags & Destroying)) { + if (node._bubblingListeners) for (var i = 0, l = events.length; i < l; ++i) if (node._bubblingListeners.hasEventListener(events[i])) return true; + if (node._capturingListeners) for (var _i = 0, _l = events.length; _i < _l; ++_i) if (node._capturingListeners.hasEventListener(events[_i])) return true; + return false; + } + return true; + } + function _doDispatchEvent(owner, event, cachedArray) { + var target, i; + event.target = owner; + cachedArray.length = 0; + owner._getCapturingTargets(event.type, cachedArray); + event.eventPhase = 1; + for (i = cachedArray.length - 1; i >= 0; --i) { + target = cachedArray[i]; + if (target._capturingListeners) { + event.currentTarget = target; + target._capturingListeners.emit(event.type, event, cachedArray); + if (event._propagationStopped) { + cachedArray.length = 0; + return; + } + } + } + cachedArray.length = 0; + event.eventPhase = 2; + event.currentTarget = owner; + owner._capturingListeners && owner._capturingListeners.emit(event.type, event); + !event._propagationImmediateStopped && owner._bubblingListeners && owner._bubblingListeners.emit(event.type, event); + if (!event._propagationStopped && event.bubbles) { + owner._getBubblingTargets(event.type, cachedArray); + event.eventPhase = 3; + for (i = 0; i < cachedArray.length; ++i) { + target = cachedArray[i]; + if (target._bubblingListeners) { + event.currentTarget = target; + target._bubblingListeners.emit(event.type, event); + if (event._propagationStopped) { + cachedArray.length = 0; + return; + } + } + } + } + cachedArray.length = 0; + } + function _getActualGroupIndex(node) { + var groupIndex = node.groupIndex; + 0 === groupIndex && node.parent && (groupIndex = _getActualGroupIndex(node.parent)); + return groupIndex; + } + function _updateCullingMask(node) { + var index = _getActualGroupIndex(node); + node._cullingMask = 1 << index; + false; + for (var i = 0; i < node._children.length; i++) _updateCullingMask(node._children[i]); + } + function updateLocalMatrix3D() { + if (this._localMatDirty & LocalDirtyFlag.TRSS) { + var t = this._matrix; + var tm = t.m; + _valueTypes.Trs.toMat4(t, this._trs); + if (this._skewX || this._skewY) { + var a = tm[0], b = tm[1], c = tm[4], d = tm[5]; + var skx = Math.tan(this._skewX * ONE_DEGREE); + var sky = Math.tan(this._skewY * ONE_DEGREE); + Infinity === skx && (skx = 99999999); + Infinity === sky && (sky = 99999999); + tm[0] = a + c * sky; + tm[1] = b + d * sky; + tm[4] = c + a * skx; + tm[5] = d + b * skx; + } + this._localMatDirty &= ~LocalDirtyFlag.TRSS; + this._worldMatDirty = true; + } + } + function updateLocalMatrix2D() { + var dirtyFlag = this._localMatDirty; + if (!(dirtyFlag & LocalDirtyFlag.TRSS)) return; + var t = this._matrix; + var tm = t.m; + var trs = this._trs; + if (dirtyFlag & (LocalDirtyFlag.RS | LocalDirtyFlag.SKEW)) { + var rotation = -this._eulerAngles.z; + var hasSkew = this._skewX || this._skewY; + var sx = trs[7], sy = trs[8]; + if (rotation || hasSkew) { + var a = 1, b = 0, c = 0, d = 1; + if (rotation) { + var rotationRadians = rotation * ONE_DEGREE; + c = Math.sin(rotationRadians); + d = Math.cos(rotationRadians); + a = d; + b = -c; + } + tm[0] = a *= sx; + tm[1] = b *= sx; + tm[4] = c *= sy; + tm[5] = d *= sy; + if (hasSkew) { + var _a = tm[0], _b = tm[1], _c = tm[4], _d = tm[5]; + var skx = Math.tan(this._skewX * ONE_DEGREE); + var sky = Math.tan(this._skewY * ONE_DEGREE); + Infinity === skx && (skx = 99999999); + Infinity === sky && (sky = 99999999); + tm[0] = _a + _c * sky; + tm[1] = _b + _d * sky; + tm[4] = _c + _a * skx; + tm[5] = _d + _b * skx; + } + } else { + tm[0] = sx; + tm[1] = 0; + tm[4] = 0; + tm[5] = sy; + } + } + tm[12] = trs[0]; + tm[13] = trs[1]; + this._localMatDirty &= ~LocalDirtyFlag.TRSS; + this._worldMatDirty = true; + } + function calculWorldMatrix3D() { + this._localMatDirty & LocalDirtyFlag.TRSS && this._updateLocalMatrix(); + if (this._parent) { + var parentMat = this._parent._worldMatrix; + _valueTypes.Mat4.mul(this._worldMatrix, parentMat, this._matrix); + } else _valueTypes.Mat4.copy(this._worldMatrix, this._matrix); + this._worldMatDirty = false; + } + function calculWorldMatrix2D() { + this._localMatDirty & LocalDirtyFlag.TRSS && this._updateLocalMatrix(); + var parent = this._parent; + parent ? this._mulMat(this._worldMatrix, parent._worldMatrix, this._matrix) : _valueTypes.Mat4.copy(this._worldMatrix, this._matrix); + this._worldMatDirty = false; + } + function mulMat2D(out, a, b) { + var am = a.m, bm = b.m, outm = out.m; + var aa = am[0], ab = am[1], ac = am[4], ad = am[5], atx = am[12], aty = am[13]; + var ba = bm[0], bb = bm[1], bc = bm[4], bd = bm[5], btx = bm[12], bty = bm[13]; + if (0 !== ab || 0 !== ac) { + outm[0] = ba * aa + bb * ac; + outm[1] = ba * ab + bb * ad; + outm[4] = bc * aa + bd * ac; + outm[5] = bc * ab + bd * ad; + outm[12] = aa * btx + ac * bty + atx; + outm[13] = ab * btx + ad * bty + aty; + } else { + outm[0] = ba * aa; + outm[1] = bb * ad; + outm[4] = bc * aa; + outm[5] = bd * ad; + outm[12] = aa * btx + atx; + outm[13] = ad * bty + aty; + } + } + var mulMat3D = _valueTypes.Mat4.mul; + var NodeDefines = { + name: "cc.Node", + extends: BaseNode, + properties: { + _opacity: 255, + _color: cc.Color.WHITE, + _contentSize: cc.Size, + _anchorPoint: cc.v2(.5, .5), + _position: void 0, + _scale: void 0, + _trs: null, + _eulerAngles: cc.Vec3, + _skewX: 0, + _skewY: 0, + _zIndex: { + default: void 0, + type: cc.Integer + }, + _localZOrder: { + default: 0, + serializable: false + }, + _is3DNode: false, + _groupIndex: { + default: 0, + formerlySerializedAs: "groupIndex" + }, + groupIndex: { + get: function get() { + return this._groupIndex; + }, + set: function set(value) { + this._groupIndex = value; + _updateCullingMask(this); + this.emit(EventType.GROUP_CHANGED, this); + } + }, + group: { + get: function get() { + return cc.game.groupList[this.groupIndex] || ""; + }, + set: function set(value) { + this.groupIndex = cc.game.groupList.indexOf(value); + } + }, + x: { + get: function get() { + return this._trs[0]; + }, + set: function set(value) { + var trs = this._trs; + if (value !== trs[0]) { + true; + var oldValue; + false; + trs[0] = value; + this.setLocalDirty(LocalDirtyFlag.ALL_POSITION); + if (this._eventMask & POSITION_ON) { + false; + this.emit(EventType.POSITION_CHANGED); + } + } + } + }, + y: { + get: function get() { + return this._trs[1]; + }, + set: function set(value) { + var trs = this._trs; + if (value !== trs[1]) { + true; + var oldValue; + false; + trs[1] = value; + this.setLocalDirty(LocalDirtyFlag.ALL_POSITION); + if (this._eventMask & POSITION_ON) { + false; + this.emit(EventType.POSITION_CHANGED); + } + } + } + }, + z: { + get: function get() { + return this._trs[2]; + }, + set: function set(value) { + var trs = this._trs; + if (value !== trs[2]) { + true; + var oldValue; + false; + trs[2] = value; + this.setLocalDirty(LocalDirtyFlag.ALL_POSITION); + true, this._renderFlag |= RenderFlow.FLAG_WORLD_TRANSFORM; + if (this._eventMask & POSITION_ON) { + false; + this.emit(EventType.POSITION_CHANGED); + } + } + } + }, + rotation: { + get: function get() { + true; + cc.warn("`cc.Node.rotation` is deprecated since v2.1.0, please use `-angle` instead. (`this.node.rotation` -> `-this.node.angle`)"); + return -this.angle; + }, + set: function set(value) { + true; + cc.warn("`cc.Node.rotation` is deprecated since v2.1.0, please set `-angle` instead. (`this.node.rotation = x` -> `this.node.angle = -x`)"); + this.angle = -value; + } + }, + angle: { + get: function get() { + return this._eulerAngles.z; + }, + set: function set(value) { + _valueTypes.Vec3.set(this._eulerAngles, 0, 0, value); + _valueTypes.Trs.fromAngleZ(this._trs, value); + this.setLocalDirty(LocalDirtyFlag.ALL_ROTATION); + this._eventMask & ROTATION_ON && this.emit(EventType.ROTATION_CHANGED); + } + }, + rotationX: { + get: function get() { + true; + cc.warn("`cc.Node.rotationX` is deprecated since v2.1.0, please use `eulerAngles.x` instead. (`this.node.rotationX` -> `this.node.eulerAngles.x`)"); + return this._eulerAngles.x; + }, + set: function set(value) { + true; + cc.warn("`cc.Node.rotationX` is deprecated since v2.1.0, please set `eulerAngles` instead. (`this.node.rotationX = x` -> `this.node.is3DNode = true; this.node.eulerAngles = cc.v3(x, 0, 0)`"); + if (this._eulerAngles.x !== value) { + this._eulerAngles.x = value; + this._eulerAngles.x === this._eulerAngles.y ? _valueTypes.Trs.fromAngleZ(this._trs, -value) : _valueTypes.Trs.fromEulerNumber(this._trs, value, this._eulerAngles.y, 0); + this.setLocalDirty(LocalDirtyFlag.ALL_ROTATION); + this._eventMask & ROTATION_ON && this.emit(EventType.ROTATION_CHANGED); + } + } + }, + rotationY: { + get: function get() { + true; + cc.warn("`cc.Node.rotationY` is deprecated since v2.1.0, please use `eulerAngles.y` instead. (`this.node.rotationY` -> `this.node.eulerAngles.y`)"); + return this._eulerAngles.y; + }, + set: function set(value) { + true; + cc.warn("`cc.Node.rotationY` is deprecated since v2.1.0, please set `eulerAngles` instead. (`this.node.rotationY = y` -> `this.node.is3DNode = true; this.node.eulerAngles = cc.v3(0, y, 0)`"); + if (this._eulerAngles.y !== value) { + this._eulerAngles.y = value; + this._eulerAngles.x === this._eulerAngles.y ? _valueTypes.Trs.fromAngleZ(this._trs, -value) : _valueTypes.Trs.fromEulerNumber(this._trs, this._eulerAngles.x, value, 0); + this.setLocalDirty(LocalDirtyFlag.ALL_ROTATION); + this._eventMask & ROTATION_ON && this.emit(EventType.ROTATION_CHANGED); + } + } + }, + eulerAngles: { + get: function get() { + false; + return _valueTypes.Trs.toEuler(this._eulerAngles, this._trs); + }, + set: function set(v) { + false; + _valueTypes.Trs.fromEuler(this._trs, v); + this.setLocalDirty(LocalDirtyFlag.ALL_ROTATION); + true, this._renderFlag |= RenderFlow.FLAG_TRANSFORM; + this._eventMask & ROTATION_ON && this.emit(EventType.ROTATION_CHANGED); + } + }, + quat: { + get: function get() { + var trs = this._trs; + return new _valueTypes.Quat(trs[3], trs[4], trs[5], trs[6]); + }, + set: function set(v) { + this.setRotation(v); + } + }, + scale: { + get: function get() { + return this._trs[7]; + }, + set: function set(v) { + this.setScale(v); + } + }, + scaleX: { + get: function get() { + return this._trs[7]; + }, + set: function set(value) { + if (this._trs[7] !== value) { + this._trs[7] = value; + this.setLocalDirty(LocalDirtyFlag.ALL_SCALE); + this._eventMask & SCALE_ON && this.emit(EventType.SCALE_CHANGED); + } + } + }, + scaleY: { + get: function get() { + return this._trs[8]; + }, + set: function set(value) { + if (this._trs[8] !== value) { + this._trs[8] = value; + this.setLocalDirty(LocalDirtyFlag.ALL_SCALE); + this._eventMask & SCALE_ON && this.emit(EventType.SCALE_CHANGED); + } + } + }, + scaleZ: { + get: function get() { + return this._trs[9]; + }, + set: function set(value) { + if (this._trs[9] !== value) { + this._trs[9] = value; + this.setLocalDirty(LocalDirtyFlag.ALL_SCALE); + true, this._renderFlag |= RenderFlow.FLAG_TRANSFORM; + this._eventMask & SCALE_ON && this.emit(EventType.SCALE_CHANGED); + } + } + }, + skewX: { + get: function get() { + return this._skewX; + }, + set: function set(value) { + _skewWarn(value, this); + this._skewX = value; + this.setLocalDirty(LocalDirtyFlag.SKEW); + false; + } + }, + skewY: { + get: function get() { + return this._skewY; + }, + set: function set(value) { + _skewWarn(value, this); + this._skewY = value; + this.setLocalDirty(LocalDirtyFlag.SKEW); + false; + } + }, + opacity: { + get: function get() { + return this._opacity; + }, + set: function set(value) { + value = cc.misc.clampf(value, 0, 255); + if (this._opacity !== value) { + this._opacity = value; + false; + this._renderFlag |= RenderFlow.FLAG_OPACITY_COLOR; + } + }, + range: [ 0, 255 ] + }, + color: { + get: function get() { + return this._color.clone(); + }, + set: function set(value) { + if (!this._color.equals(value)) { + this._color.set(value); + false; + this._renderFlag |= RenderFlow.FLAG_COLOR; + this._eventMask & COLOR_ON && this.emit(EventType.COLOR_CHANGED, value); + } + } + }, + anchorX: { + get: function get() { + return this._anchorPoint.x; + }, + set: function set(value) { + var anchorPoint = this._anchorPoint; + if (anchorPoint.x !== value) { + anchorPoint.x = value; + this._eventMask & ANCHOR_ON && this.emit(EventType.ANCHOR_CHANGED); + } + } + }, + anchorY: { + get: function get() { + return this._anchorPoint.y; + }, + set: function set(value) { + var anchorPoint = this._anchorPoint; + if (anchorPoint.y !== value) { + anchorPoint.y = value; + this._eventMask & ANCHOR_ON && this.emit(EventType.ANCHOR_CHANGED); + } + } + }, + width: { + get: function get() { + return this._contentSize.width; + }, + set: function set(value) { + if (value !== this._contentSize.width) { + var clone; + false; + this._contentSize.width = value; + if (this._eventMask & SIZE_ON) { + false; + this.emit(EventType.SIZE_CHANGED); + } + } + } + }, + height: { + get: function get() { + return this._contentSize.height; + }, + set: function set(value) { + if (value !== this._contentSize.height) { + var clone; + false; + this._contentSize.height = value; + if (this._eventMask & SIZE_ON) { + false; + this.emit(EventType.SIZE_CHANGED); + } + } + } + }, + zIndex: { + get: function get() { + return this._localZOrder >> 16; + }, + set: function set(value) { + if (value > macro.MAX_ZINDEX) { + cc.warnID(1636); + value = macro.MAX_ZINDEX; + } else if (value < macro.MIN_ZINDEX) { + cc.warnID(1637); + value = macro.MIN_ZINDEX; + } + if (this.zIndex !== value) { + this._localZOrder = 65535 & this._localZOrder | value << 16; + this.emit(EventType.SIBLING_ORDER_CHANGED); + this._onSiblingIndexChanged(); + } + } + }, + is3DNode: { + get: function get() { + return this._is3DNode; + }, + set: function set(v) { + if (this._is3DNode === v) return; + this._is3DNode = v; + this._update3DFunction(); + } + }, + up: { + get: function get() { + var _up = _valueTypes.Vec3.transformQuat(_urfVec3, _valueTypes.Vec3.UP, this.getWorldRotation(_urfQuat)); + return _up.clone(); + } + }, + right: { + get: function get() { + var _right = _valueTypes.Vec3.transformQuat(_urfVec3, _valueTypes.Vec3.RIGHT, this.getWorldRotation(_urfQuat)); + return _right.clone(); + } + }, + forward: { + get: function get() { + var _forward = _valueTypes.Vec3.transformQuat(_urfVec3, _valueTypes.Vec3.FORWARD, this.getWorldRotation(_urfQuat)); + return _forward.clone(); + } + } + }, + ctor: function ctor() { + this._reorderChildDirty = false; + this._widget = null; + this._renderComponent = null; + this._capturingListeners = null; + this._bubblingListeners = null; + this._touchListener = null; + this._mouseListener = null; + this._initDataFromPool(); + this._eventMask = 0; + this._cullingMask = 1; + this._childArrivalOrder = 1; + false; + this._renderFlag = RenderFlow.FLAG_TRANSFORM | RenderFlow.FLAG_OPACITY_COLOR; + }, + statics: { + EventType: EventType, + _LocalDirtyFlag: LocalDirtyFlag, + isNode: function isNode(obj) { + return obj instanceof Node && (obj.constructor === Node || !(obj instanceof cc.Scene)); + }, + BuiltinGroupIndex: BuiltinGroupIndex + }, + _onSiblingIndexChanged: function _onSiblingIndexChanged() { + this._parent && this._parent._delaySort(); + }, + _onPreDestroy: function _onPreDestroy() { + var destroyByParent = this._onPreDestroyBase(); + ActionManagerExist && cc.director.getActionManager().removeAllActionsFromTarget(this); + _currentHovered === this && (_currentHovered = null); + this._bubblingListeners && this._bubblingListeners.clear(); + this._capturingListeners && this._capturingListeners.clear(); + if (this._touchListener || this._mouseListener) { + eventManager.removeListeners(this); + if (this._touchListener) { + this._touchListener.owner = null; + this._touchListener.mask = null; + this._touchListener = null; + } + if (this._mouseListener) { + this._mouseListener.owner = null; + this._mouseListener.mask = null; + this._mouseListener = null; + } + } + false; + this._backDataIntoPool(); + this._reorderChildDirty && cc.director.__fastOff(cc.Director.EVENT_AFTER_UPDATE, this.sortAllChildren, this); + destroyByParent || false; + }, + _onPostActivated: function _onPostActivated(active) { + var actionManager = ActionManagerExist ? cc.director.getActionManager() : null; + if (active) { + this._renderFlag |= RenderFlow.FLAG_WORLD_TRANSFORM; + actionManager && actionManager.resumeTarget(this); + eventManager.resumeTarget(this); + this._checkListenerMask(); + } else { + actionManager && actionManager.pauseTarget(this); + eventManager.pauseTarget(this); + } + }, + _onHierarchyChanged: function _onHierarchyChanged(oldParent) { + this._updateOrderOfArrival(); + _updateCullingMask(this); + this._parent && this._parent._delaySort(); + this._renderFlag |= RenderFlow.FLAG_WORLD_TRANSFORM | RenderFlow.FLAG_OPACITY_COLOR; + this._onHierarchyChangedBase(oldParent); + cc._widgetManager && (cc._widgetManager._nodesOrderDirty = true); + oldParent && this._activeInHierarchy && this._checkListenerMask(); + false; + }, + _update3DFunction: function _update3DFunction() { + if (this._is3DNode) { + this._updateLocalMatrix = updateLocalMatrix3D; + this._calculWorldMatrix = calculWorldMatrix3D; + this._mulMat = mulMat3D; + } else { + this._updateLocalMatrix = updateLocalMatrix2D; + this._calculWorldMatrix = calculWorldMatrix2D; + this._mulMat = mulMat2D; + } + this._renderComponent && this._renderComponent._on3DNodeChanged && this._renderComponent._on3DNodeChanged(); + this._renderFlag |= RenderFlow.FLAG_TRANSFORM; + this._localMatDirty = LocalDirtyFlag.ALL; + false; + }, + _initDataFromPool: function _initDataFromPool() { + if (!this._spaceInfo) { + false, false; + this._spaceInfo = nodeMemPool.pop(); + } + var spaceInfo = this._spaceInfo; + this._matrix = cc.mat4(spaceInfo.localMat); + _valueTypes.Mat4.identity(this._matrix); + this._worldMatrix = cc.mat4(spaceInfo.worldMat); + _valueTypes.Mat4.identity(this._worldMatrix); + this._localMatDirty = LocalDirtyFlag.ALL; + this._worldMatDirty = true; + var trs = this._trs = spaceInfo.trs; + trs[0] = 0; + trs[1] = 0; + trs[2] = 0; + trs[3] = 0; + trs[4] = 0; + trs[5] = 0; + trs[6] = 1; + trs[7] = 1; + trs[8] = 1; + trs[9] = 1; + }, + _backDataIntoPool: function _backDataIntoPool() { + if (!(false, false)) { + nodeMemPool.push(this._spaceInfo); + this._matrix = null; + this._worldMatrix = null; + this._trs = null; + this._spaceInfo = null; + } + }, + _toEuler: function _toEuler() { + if (this.is3DNode) _valueTypes.Trs.toEuler(this._eulerAngles, this._trs); else { + var z = Math.asin(this._trs[5]) / ONE_DEGREE * 2; + _valueTypes.Vec3.set(this._eulerAngles, 0, 0, z); + } + }, + _fromEuler: function _fromEuler() { + this.is3DNode ? _valueTypes.Trs.fromEuler(this._trs, this._eulerAngles) : _valueTypes.Trs.fromAngleZ(this._trs, this._eulerAngles.z); + }, + _initProperties: function _initProperties() { + this._is3DNode && this._update3DFunction(); + var trs = this._trs; + if (trs) { + var desTrs = trs; + trs = this._trs = this._spaceInfo.trs; + 11 === desTrs.length ? trs.set(desTrs.subarray(1)) : trs.set(desTrs); + } else trs = this._trs = this._spaceInfo.trs; + var NodeUtils; + false; + this._fromEuler(); + false; + }, + _onBatchCreated: function _onBatchCreated(dontSyncChildPrefab) { + this._initProperties(); + this._cullingMask = 1 << _getActualGroupIndex(this); + false; + if (!this._activeInHierarchy) { + ActionManagerExist && cc.director.getActionManager().pauseTarget(this); + eventManager.pauseTarget(this); + } + var children = this._children; + for (var i = 0, len = children.length; i < len; i++) { + var child = children[i]; + if (!dontSyncChildPrefab) { + var prefabInfo = child._prefab; + prefabInfo && prefabInfo.sync && prefabInfo.root === child && PrefabHelper.syncWithPrefab(child); + child._updateOrderOfArrival(); + } + child._onBatchCreated(dontSyncChildPrefab); + } + children.length > 0 && (this._renderFlag |= RenderFlow.FLAG_CHILDREN); + false; + }, + _checkListenerMask: function _checkListenerMask() { + if (this._touchListener) { + var mask = this._touchListener.mask = _searchComponentsInParent(this, cc.Mask); + this._mouseListener && (this._mouseListener.mask = mask); + } else this._mouseListener && (this._mouseListener.mask = _searchComponentsInParent(this, cc.Mask)); + }, + _checknSetupSysEvent: function _checknSetupSysEvent(type) { + var newAdded = false; + var forDispatch = false; + if (-1 !== _touchEvents.indexOf(type)) { + if (!this._touchListener) { + this._touchListener = cc.EventListener.create({ + event: cc.EventListener.TOUCH_ONE_BY_ONE, + swallowTouches: true, + owner: this, + mask: _searchComponentsInParent(this, cc.Mask), + onTouchBegan: _touchStartHandler, + onTouchMoved: _touchMoveHandler, + onTouchEnded: _touchEndHandler, + onTouchCancelled: _touchCancelHandler + }); + eventManager.addListener(this._touchListener, this); + newAdded = true; + } + forDispatch = true; + } else if (-1 !== _mouseEvents.indexOf(type)) { + if (!this._mouseListener) { + this._mouseListener = cc.EventListener.create({ + event: cc.EventListener.MOUSE, + _previousIn: false, + owner: this, + mask: _searchComponentsInParent(this, cc.Mask), + onMouseDown: _mouseDownHandler, + onMouseMove: _mouseMoveHandler, + onMouseUp: _mouseUpHandler, + onMouseScroll: _mouseWheelHandler + }); + eventManager.addListener(this._mouseListener, this); + newAdded = true; + } + forDispatch = true; + } + newAdded && !this._activeInHierarchy && cc.director.getScheduler().schedule((function() { + this._activeInHierarchy || eventManager.pauseTarget(this); + }), this, 0, 0, 0, false); + return forDispatch; + }, + on: function on(type, callback, target, useCapture) { + var forDispatch = this._checknSetupSysEvent(type); + if (forDispatch) return this._onDispatch(type, callback, target, useCapture); + switch (type) { + case EventType.POSITION_CHANGED: + this._eventMask |= POSITION_ON; + break; + + case EventType.SCALE_CHANGED: + this._eventMask |= SCALE_ON; + break; + + case EventType.ROTATION_CHANGED: + this._eventMask |= ROTATION_ON; + break; + + case EventType.SIZE_CHANGED: + this._eventMask |= SIZE_ON; + break; + + case EventType.ANCHOR_CHANGED: + this._eventMask |= ANCHOR_ON; + break; + + case EventType.COLOR_CHANGED: + this._eventMask |= COLOR_ON; + } + this._bubblingListeners || (this._bubblingListeners = new EventTarget()); + return this._bubblingListeners.on(type, callback, target); + }, + once: function once(type, callback, target, useCapture) { + var _this = this; + var forDispatch = this._checknSetupSysEvent(type); + var listeners = null; + listeners = forDispatch && useCapture ? this._capturingListeners = this._capturingListeners || new EventTarget() : this._bubblingListeners = this._bubblingListeners || new EventTarget(); + listeners.once(type, callback, target); + listeners.once(type, (function() { + _this.off(type, callback, target); + }), void 0); + }, + _onDispatch: function _onDispatch(type, callback, target, useCapture) { + if ("boolean" === typeof target) { + useCapture = target; + target = void 0; + } else useCapture = !!useCapture; + if (!callback) { + cc.errorID(6800); + return; + } + var listeners = null; + listeners = useCapture ? this._capturingListeners = this._capturingListeners || new EventTarget() : this._bubblingListeners = this._bubblingListeners || new EventTarget(); + if (!listeners.hasEventListener(type, callback, target)) { + listeners.on(type, callback, target); + target && target.__eventTargets && target.__eventTargets.push(this); + } + return callback; + }, + off: function off(type, callback, target, useCapture) { + var touchEvent = -1 !== _touchEvents.indexOf(type); + var mouseEvent = !touchEvent && -1 !== _mouseEvents.indexOf(type); + if (touchEvent || mouseEvent) { + this._offDispatch(type, callback, target, useCapture); + if (touchEvent) { + if (this._touchListener && !_checkListeners(this, _touchEvents)) { + eventManager.removeListener(this._touchListener); + this._touchListener = null; + } + } else if (mouseEvent && this._mouseListener && !_checkListeners(this, _mouseEvents)) { + eventManager.removeListener(this._mouseListener); + this._mouseListener = null; + } + } else if (this._bubblingListeners) { + this._bubblingListeners.off(type, callback, target); + var hasListeners = this._bubblingListeners.hasEventListener(type); + if (!hasListeners) switch (type) { + case EventType.POSITION_CHANGED: + this._eventMask &= ~POSITION_ON; + break; + + case EventType.SCALE_CHANGED: + this._eventMask &= ~SCALE_ON; + break; + + case EventType.ROTATION_CHANGED: + this._eventMask &= ~ROTATION_ON; + break; + + case EventType.SIZE_CHANGED: + this._eventMask &= ~SIZE_ON; + break; + + case EventType.ANCHOR_CHANGED: + this._eventMask &= ~ANCHOR_ON; + break; + + case EventType.COLOR_CHANGED: + this._eventMask &= ~COLOR_ON; + } + } + }, + _offDispatch: function _offDispatch(type, callback, target, useCapture) { + if ("boolean" === typeof target) { + useCapture = target; + target = void 0; + } else useCapture = !!useCapture; + if (callback) { + var listeners = useCapture ? this._capturingListeners : this._bubblingListeners; + if (listeners) { + listeners.off(type, callback, target); + target && target.__eventTargets && js.array.fastRemove(target.__eventTargets, this); + } + } else { + this._capturingListeners && this._capturingListeners.removeAll(type); + this._bubblingListeners && this._bubblingListeners.removeAll(type); + } + }, + targetOff: function targetOff(target) { + var listeners = this._bubblingListeners; + if (listeners) { + listeners.targetOff(target); + this._eventMask & POSITION_ON && !listeners.hasEventListener(EventType.POSITION_CHANGED) && (this._eventMask &= ~POSITION_ON); + this._eventMask & SCALE_ON && !listeners.hasEventListener(EventType.SCALE_CHANGED) && (this._eventMask &= ~SCALE_ON); + this._eventMask & ROTATION_ON && !listeners.hasEventListener(EventType.ROTATION_CHANGED) && (this._eventMask &= ~ROTATION_ON); + this._eventMask & SIZE_ON && !listeners.hasEventListener(EventType.SIZE_CHANGED) && (this._eventMask &= ~SIZE_ON); + this._eventMask & ANCHOR_ON && !listeners.hasEventListener(EventType.ANCHOR_CHANGED) && (this._eventMask &= ~ANCHOR_ON); + this._eventMask & COLOR_ON && !listeners.hasEventListener(EventType.COLOR_CHANGED) && (this._eventMask &= ~COLOR_ON); + } + this._capturingListeners && this._capturingListeners.targetOff(target); + target && target.__eventTargets && js.array.fastRemove(target.__eventTargets, this); + if (this._touchListener && !_checkListeners(this, _touchEvents)) { + eventManager.removeListener(this._touchListener); + this._touchListener = null; + } + if (this._mouseListener && !_checkListeners(this, _mouseEvents)) { + eventManager.removeListener(this._mouseListener); + this._mouseListener = null; + } + }, + hasEventListener: function hasEventListener(type) { + var has = false; + this._bubblingListeners && (has = this._bubblingListeners.hasEventListener(type)); + !has && this._capturingListeners && (has = this._capturingListeners.hasEventListener(type)); + return has; + }, + emit: function emit(type, arg1, arg2, arg3, arg4, arg5) { + this._bubblingListeners && this._bubblingListeners.emit(type, arg1, arg2, arg3, arg4, arg5); + }, + dispatchEvent: function dispatchEvent(event) { + var _array = _cachedPool.get(); + _doDispatchEvent(this, event, _array); + _cachedPool.put(_array); + }, + pauseSystemEvents: function pauseSystemEvents(recursive) { + eventManager.pauseTarget(this, recursive); + }, + resumeSystemEvents: function resumeSystemEvents(recursive) { + eventManager.resumeTarget(this, recursive); + }, + _hitTest: function _hitTest(point, listener) { + var w = this._contentSize.width, h = this._contentSize.height, cameraPt = _htVec3a, testPt = _htVec3b; + var camera = cc.Camera.findCamera(this); + camera ? camera.getScreenToWorldPoint(point, cameraPt) : cameraPt.set(point); + this._updateWorldMatrix(); + if (!_valueTypes.Mat4.invert(_mat4_temp, this._worldMatrix)) return false; + _valueTypes.Vec2.transformMat4(testPt, cameraPt, _mat4_temp); + testPt.x += this._anchorPoint.x * w; + testPt.y += this._anchorPoint.y * h; + var hit = false; + if (testPt.x >= 0 && testPt.y >= 0 && testPt.x <= w && testPt.y <= h) { + hit = true; + if (listener && listener.mask) { + var mask = listener.mask; + var parent = this; + var length = mask ? mask.length : 0; + for (var i = 0, j = 0; parent && j < length; ++i, parent = parent.parent) { + var temp = mask[j]; + if (i === temp.index) { + if (parent !== temp.node) { + mask.length = j; + break; + } + var comp = parent.getComponent(cc.Mask); + if (comp && comp._enabled && !comp._hitTest(cameraPt)) { + hit = false; + break; + } + j++; + } else if (i > temp.index) { + mask.length = j; + break; + } + } + } + } + return hit; + }, + _getCapturingTargets: function _getCapturingTargets(type, array) { + var parent = this.parent; + while (parent) { + parent._capturingListeners && parent._capturingListeners.hasEventListener(type) && array.push(parent); + parent = parent.parent; + } + }, + _getBubblingTargets: function _getBubblingTargets(type, array) { + var parent = this.parent; + while (parent) { + parent._bubblingListeners && parent._bubblingListeners.hasEventListener(type) && array.push(parent); + parent = parent.parent; + } + }, + runAction: ActionManagerExist ? function(action) { + if (!this.active) return; + cc.assertID(action, 1618); + var am = cc.director.getActionManager(); + if (!am._suppressDeprecation) { + am._suppressDeprecation = true; + cc.warnID(1639); + } + am.addAction(action, this, false); + return action; + } : emptyFunc, + pauseAllActions: ActionManagerExist ? function() { + cc.director.getActionManager().pauseTarget(this); + } : emptyFunc, + resumeAllActions: ActionManagerExist ? function() { + cc.director.getActionManager().resumeTarget(this); + } : emptyFunc, + stopAllActions: ActionManagerExist ? function() { + cc.director.getActionManager().removeAllActionsFromTarget(this); + } : emptyFunc, + stopAction: ActionManagerExist ? function(action) { + cc.director.getActionManager().removeAction(action); + } : emptyFunc, + stopActionByTag: ActionManagerExist ? function(tag) { + if (tag === cc.Action.TAG_INVALID) { + cc.logID(1612); + return; + } + cc.director.getActionManager().removeActionByTag(tag, this); + } : emptyFunc, + getActionByTag: ActionManagerExist ? function(tag) { + if (tag === cc.Action.TAG_INVALID) { + cc.logID(1613); + return null; + } + return cc.director.getActionManager().getActionByTag(tag, this); + } : function() { + return null; + }, + getNumberOfRunningActions: ActionManagerExist ? function() { + return cc.director.getActionManager().getNumberOfRunningActionsInTarget(this); + } : function() { + return 0; + }, + getPosition: function getPosition(out) { + out = out || new _valueTypes.Vec3(); + return _valueTypes.Trs.toPosition(out, this._trs); + }, + setPosition: function setPosition(newPosOrX, y, z) { + var x; + if (void 0 === y) { + x = newPosOrX.x; + y = newPosOrX.y; + z = newPosOrX.z; + } else x = newPosOrX; + var trs = this._trs; + void 0 === z && (z = trs[2]); + if (trs[0] === x && trs[1] === y && trs[2] === z) return; + var oldPosition; + false; + trs[0] = x; + trs[1] = y; + trs[2] = z; + this.setLocalDirty(LocalDirtyFlag.ALL_POSITION); + true, this._renderFlag |= RenderFlow.FLAG_WORLD_TRANSFORM; + if (this._eventMask & POSITION_ON) { + false; + this.emit(EventType.POSITION_CHANGED); + } + }, + getScale: function getScale(out) { + if (void 0 !== out) return _valueTypes.Trs.toScale(out, this._trs); + cc.errorID(1400, "cc.Node.getScale", "cc.Node.scale or cc.Node.getScale(cc.Vec3)"); + return this._trs[7]; + }, + setScale: function setScale(newScaleOrX, y, z) { + var x; + if (newScaleOrX && "number" !== typeof newScaleOrX) { + x = newScaleOrX.x; + y = newScaleOrX.y; + z = newScaleOrX.z; + } else if (void 0 !== newScaleOrX && void 0 === y) { + x = newScaleOrX; + y = newScaleOrX; + z = newScaleOrX; + } else x = newScaleOrX; + var trs = this._trs; + void 0 === z && (z = trs[9]); + if (trs[7] !== x || trs[8] !== y || trs[9] !== z) { + trs[7] = x; + trs[8] = y; + trs[9] = z; + this.setLocalDirty(LocalDirtyFlag.ALL_SCALE); + true, this._renderFlag |= RenderFlow.FLAG_TRANSFORM; + this._eventMask & SCALE_ON && this.emit(EventType.SCALE_CHANGED); + } + }, + getRotation: function getRotation(out) { + if (out instanceof _valueTypes.Quat) return _valueTypes.Trs.toRotation(out, this._trs); + true; + cc.warn("`cc.Node.getRotation()` is deprecated since v2.1.0, please use `-cc.Node.angle` instead. (`this.node.getRotation()` -> `-this.node.angle`)"); + return -this.angle; + }, + setRotation: function setRotation(rotation, y, z, w) { + if ("number" === typeof rotation && void 0 === y) { + true; + cc.warn("`cc.Node.setRotation(degree)` is deprecated since v2.1.0, please set `-cc.Node.angle` instead. (`this.node.setRotation(x)` -> `this.node.angle = -x`)"); + this.angle = -rotation; + } else { + var x = rotation; + if (void 0 === y) { + x = rotation.x; + y = rotation.y; + z = rotation.z; + w = rotation.w; + } + var trs = this._trs; + if (trs[3] !== x || trs[4] !== y || trs[5] !== z || trs[6] !== w) { + trs[3] = x; + trs[4] = y; + trs[5] = z; + trs[6] = w; + this.setLocalDirty(LocalDirtyFlag.ALL_ROTATION); + this._eventMask & ROTATION_ON && this.emit(EventType.ROTATION_CHANGED); + false; + } + } + }, + getContentSize: function getContentSize() { + return cc.size(this._contentSize.width, this._contentSize.height); + }, + setContentSize: function setContentSize(size, height) { + var locContentSize = this._contentSize; + var clone; + if (void 0 === height) { + if ((0, _utils.approx)(size.width, locContentSize.width) && (0, _utils.approx)(size.height, locContentSize.height)) return; + false; + locContentSize.width = size.width; + locContentSize.height = size.height; + } else { + if ((0, _utils.approx)(size, locContentSize.width) && (0, _utils.approx)(height, locContentSize.height)) return; + false; + locContentSize.width = size; + locContentSize.height = height; + } + if (this._eventMask & SIZE_ON) { + false; + this.emit(EventType.SIZE_CHANGED); + } + }, + getAnchorPoint: function getAnchorPoint() { + return cc.v2(this._anchorPoint); + }, + setAnchorPoint: function setAnchorPoint(point, y) { + var locAnchorPoint = this._anchorPoint; + if (void 0 === y) { + if (point.x === locAnchorPoint.x && point.y === locAnchorPoint.y) return; + locAnchorPoint.x = point.x; + locAnchorPoint.y = point.y; + } else { + if (point === locAnchorPoint.x && y === locAnchorPoint.y) return; + locAnchorPoint.x = point; + locAnchorPoint.y = y; + } + this.setLocalDirty(LocalDirtyFlag.ALL_POSITION); + this._eventMask & ANCHOR_ON && this.emit(EventType.ANCHOR_CHANGED); + }, + _invTransformPoint: function _invTransformPoint(out, pos) { + this._parent ? this._parent._invTransformPoint(out, pos) : _valueTypes.Vec3.copy(out, pos); + var ltrs = this._trs; + _valueTypes.Trs.toPosition(_tpVec3a, ltrs); + _valueTypes.Vec3.sub(out, out, _tpVec3a); + _valueTypes.Trs.toRotation(_tpQuata, ltrs); + _valueTypes.Quat.conjugate(_tpQuatb, _tpQuata); + _valueTypes.Vec3.transformQuat(out, out, _tpQuatb); + _valueTypes.Trs.toScale(_tpVec3a, ltrs); + _valueTypes.Vec3.inverseSafe(_tpVec3b, _tpVec3a); + _valueTypes.Vec3.mul(out, out, _tpVec3b); + return out; + }, + getWorldPosition: function getWorldPosition(out) { + _valueTypes.Trs.toPosition(out, this._trs); + var curr = this._parent; + var ltrs; + while (curr) { + ltrs = curr._trs; + _valueTypes.Trs.toScale(_gwpVec3, ltrs); + _valueTypes.Vec3.mul(out, out, _gwpVec3); + _valueTypes.Trs.toRotation(_gwpQuat, ltrs); + _valueTypes.Vec3.transformQuat(out, out, _gwpQuat); + _valueTypes.Trs.toPosition(_gwpVec3, ltrs); + _valueTypes.Vec3.add(out, out, _gwpVec3); + curr = curr._parent; + } + return out; + }, + setWorldPosition: function setWorldPosition(pos) { + var ltrs = this._trs; + var oldPosition; + false; + this._parent ? this._parent._invTransformPoint(_swpVec3, pos) : _valueTypes.Vec3.copy(_swpVec3, pos); + _valueTypes.Trs.fromPosition(ltrs, _swpVec3); + this.setLocalDirty(LocalDirtyFlag.ALL_POSITION); + if (this._eventMask & POSITION_ON) { + false; + this.emit(EventType.POSITION_CHANGED); + } + }, + getWorldRotation: function getWorldRotation(out) { + _valueTypes.Trs.toRotation(_gwrQuat, this._trs); + _valueTypes.Quat.copy(out, _gwrQuat); + var curr = this._parent; + while (curr) { + _valueTypes.Trs.toRotation(_gwrQuat, curr._trs); + _valueTypes.Quat.mul(out, _gwrQuat, out); + curr = curr._parent; + } + return out; + }, + setWorldRotation: function setWorldRotation(val) { + if (this._parent) { + this._parent.getWorldRotation(_swrQuat); + _valueTypes.Quat.conjugate(_swrQuat, _swrQuat); + _valueTypes.Quat.mul(_swrQuat, _swrQuat, val); + } else _valueTypes.Quat.copy(_swrQuat, val); + _valueTypes.Trs.fromRotation(this._trs, _swrQuat); + false; + this.setLocalDirty(LocalDirtyFlag.ALL_ROTATION); + }, + getWorldScale: function getWorldScale(out) { + _valueTypes.Trs.toScale(_gwsVec3, this._trs); + _valueTypes.Vec3.copy(out, _gwsVec3); + var curr = this._parent; + while (curr) { + _valueTypes.Trs.toScale(_gwsVec3, curr._trs); + _valueTypes.Vec3.mul(out, out, _gwsVec3); + curr = curr._parent; + } + return out; + }, + setWorldScale: function setWorldScale(scale) { + if (this._parent) { + this._parent.getWorldScale(_swsVec3); + _valueTypes.Vec3.div(_swsVec3, scale, _swsVec3); + } else _valueTypes.Vec3.copy(_swsVec3, scale); + _valueTypes.Trs.fromScale(this._trs, _swsVec3); + this.setLocalDirty(LocalDirtyFlag.ALL_SCALE); + }, + getWorldRT: function getWorldRT(out) { + var opos = _gwrtVec3a; + var orot = _gwrtQuata; + var ltrs = this._trs; + _valueTypes.Trs.toPosition(opos, ltrs); + _valueTypes.Trs.toRotation(orot, ltrs); + var curr = this._parent; + while (curr) { + ltrs = curr._trs; + _valueTypes.Trs.toScale(_gwrtVec3b, ltrs); + _valueTypes.Vec3.mul(opos, opos, _gwrtVec3b); + _valueTypes.Trs.toRotation(_gwrtQuatb, ltrs); + _valueTypes.Vec3.transformQuat(opos, opos, _gwrtQuatb); + _valueTypes.Trs.toPosition(_gwrtVec3b, ltrs); + _valueTypes.Vec3.add(opos, opos, _gwrtVec3b); + _valueTypes.Quat.mul(orot, _gwrtQuatb, orot); + curr = curr._parent; + } + _valueTypes.Mat4.fromRT(out, orot, opos); + return out; + }, + lookAt: function lookAt(pos, up) { + this.getWorldPosition(_laVec3); + _valueTypes.Vec3.sub(_laVec3, _laVec3, pos); + _valueTypes.Vec3.normalize(_laVec3, _laVec3); + _valueTypes.Quat.fromViewUp(_laQuat, _laVec3, up); + this.setWorldRotation(_laQuat); + }, + _updateLocalMatrix: updateLocalMatrix2D, + _calculWorldMatrix: function _calculWorldMatrix() { + this._localMatDirty & LocalDirtyFlag.TRSS && this._updateLocalMatrix(); + var parent = this._parent; + parent ? this._mulMat(this._worldMatrix, parent._worldMatrix, this._matrix) : _valueTypes.Mat4.copy(this._worldMatrix, this._matrix); + this._worldMatDirty = false; + }, + _mulMat: mulMat2D, + _updateWorldMatrix: function _updateWorldMatrix() { + this._parent && this._parent._updateWorldMatrix(); + if (this._worldMatDirty) { + this._calculWorldMatrix(); + var children = this._children; + for (var i = 0, l = children.length; i < l; i++) children[i]._worldMatDirty = true; + } + }, + setLocalDirty: function setLocalDirty(flag) { + this._localMatDirty |= flag; + this._worldMatDirty = true; + flag === LocalDirtyFlag.ALL_POSITION || flag === LocalDirtyFlag.POSITION ? this._renderFlag |= RenderFlow.FLAG_WORLD_TRANSFORM : this._renderFlag |= RenderFlow.FLAG_TRANSFORM; + }, + setWorldDirty: function setWorldDirty() { + this._worldMatDirty = true; + }, + getLocalMatrix: function getLocalMatrix(out) { + this._updateLocalMatrix(); + return _valueTypes.Mat4.copy(out, this._matrix); + }, + getWorldMatrix: function getWorldMatrix(out) { + this._updateWorldMatrix(); + return _valueTypes.Mat4.copy(out, this._worldMatrix); + }, + convertToNodeSpaceAR: function convertToNodeSpaceAR(worldPoint, out) { + this._updateWorldMatrix(); + _valueTypes.Mat4.invert(_mat4_temp, this._worldMatrix); + if (worldPoint instanceof cc.Vec2) { + out = out || new cc.Vec2(); + return _valueTypes.Vec2.transformMat4(out, worldPoint, _mat4_temp); + } + out = out || new cc.Vec3(); + return _valueTypes.Vec3.transformMat4(out, worldPoint, _mat4_temp); + }, + convertToWorldSpaceAR: function convertToWorldSpaceAR(nodePoint, out) { + this._updateWorldMatrix(); + if (nodePoint instanceof cc.Vec2) { + out = out || new cc.Vec2(); + return _valueTypes.Vec2.transformMat4(out, nodePoint, this._worldMatrix); + } + out = out || new cc.Vec3(); + return _valueTypes.Vec3.transformMat4(out, nodePoint, this._worldMatrix); + }, + convertToNodeSpace: function convertToNodeSpace(worldPoint) { + this._updateWorldMatrix(); + _valueTypes.Mat4.invert(_mat4_temp, this._worldMatrix); + var out = new cc.Vec2(); + _valueTypes.Vec2.transformMat4(out, worldPoint, _mat4_temp); + out.x += this._anchorPoint.x * this._contentSize.width; + out.y += this._anchorPoint.y * this._contentSize.height; + return out; + }, + convertToWorldSpace: function convertToWorldSpace(nodePoint) { + this._updateWorldMatrix(); + var out = new cc.Vec2(nodePoint.x - this._anchorPoint.x * this._contentSize.width, nodePoint.y - this._anchorPoint.y * this._contentSize.height); + return _valueTypes.Vec2.transformMat4(out, out, this._worldMatrix); + }, + getNodeToParentTransform: function getNodeToParentTransform(out) { + out || (out = AffineTrans.identity()); + this._updateLocalMatrix(); + var contentSize = this._contentSize; + _vec3_temp.x = -this._anchorPoint.x * contentSize.width; + _vec3_temp.y = -this._anchorPoint.y * contentSize.height; + _valueTypes.Mat4.copy(_mat4_temp, this._matrix); + _valueTypes.Mat4.transform(_mat4_temp, _mat4_temp, _vec3_temp); + return AffineTrans.fromMat4(out, _mat4_temp); + }, + getNodeToParentTransformAR: function getNodeToParentTransformAR(out) { + out || (out = AffineTrans.identity()); + this._updateLocalMatrix(); + return AffineTrans.fromMat4(out, this._matrix); + }, + getNodeToWorldTransform: function getNodeToWorldTransform(out) { + out || (out = AffineTrans.identity()); + this._updateWorldMatrix(); + var contentSize = this._contentSize; + _vec3_temp.x = -this._anchorPoint.x * contentSize.width; + _vec3_temp.y = -this._anchorPoint.y * contentSize.height; + _valueTypes.Mat4.copy(_mat4_temp, this._worldMatrix); + _valueTypes.Mat4.transform(_mat4_temp, _mat4_temp, _vec3_temp); + return AffineTrans.fromMat4(out, _mat4_temp); + }, + getNodeToWorldTransformAR: function getNodeToWorldTransformAR(out) { + out || (out = AffineTrans.identity()); + this._updateWorldMatrix(); + return AffineTrans.fromMat4(out, this._worldMatrix); + }, + getParentToNodeTransform: function getParentToNodeTransform(out) { + out || (out = AffineTrans.identity()); + this._updateLocalMatrix(); + _valueTypes.Mat4.invert(_mat4_temp, this._matrix); + return AffineTrans.fromMat4(out, _mat4_temp); + }, + getWorldToNodeTransform: function getWorldToNodeTransform(out) { + out || (out = AffineTrans.identity()); + this._updateWorldMatrix(); + _valueTypes.Mat4.invert(_mat4_temp, this._worldMatrix); + return AffineTrans.fromMat4(out, _mat4_temp); + }, + convertTouchToNodeSpace: function convertTouchToNodeSpace(touch) { + return this.convertToNodeSpace(touch.getLocation()); + }, + convertTouchToNodeSpaceAR: function convertTouchToNodeSpaceAR(touch) { + return this.convertToNodeSpaceAR(touch.getLocation()); + }, + getBoundingBox: function getBoundingBox() { + this._updateLocalMatrix(); + var width = this._contentSize.width; + var height = this._contentSize.height; + var rect = cc.rect(-this._anchorPoint.x * width, -this._anchorPoint.y * height, width, height); + return rect.transformMat4(rect, this._matrix); + }, + getBoundingBoxToWorld: function getBoundingBoxToWorld() { + if (this._parent) { + this._parent._updateWorldMatrix(); + return this._getBoundingBoxTo(); + } + return this.getBoundingBox(); + }, + _getBoundingBoxTo: function _getBoundingBoxTo() { + var width = this._contentSize.width; + var height = this._contentSize.height; + var rect = cc.rect(-this._anchorPoint.x * width, -this._anchorPoint.y * height, width, height); + this._calculWorldMatrix(); + rect.transformMat4(rect, this._worldMatrix); + if (!this._children) return rect; + var locChildren = this._children; + for (var i = 0; i < locChildren.length; i++) { + var child = locChildren[i]; + if (child && child.active) { + var childRect = child._getBoundingBoxTo(); + childRect && rect.union(rect, childRect); + } + } + return rect; + }, + _updateOrderOfArrival: function _updateOrderOfArrival() { + var arrivalOrder = this._parent ? ++this._parent._childArrivalOrder : 0; + this._localZOrder = 4294901760 & this._localZOrder | arrivalOrder; + this.emit(EventType.SIBLING_ORDER_CHANGED); + }, + setSelfGroupIndex: function setSelfGroupIndex(groupIndex) { + this._groupIndex = groupIndex || 0; + this._cullingMask = 1 << groupIndex; + false; + }, + addChild: function addChild(child, zIndex, name) { + false; + cc.assertID(child, 1606); + cc.assertID(null === child._parent, 1605); + child.parent = this; + void 0 !== zIndex && (child.zIndex = zIndex); + void 0 !== name && (child.name = name); + }, + cleanup: function cleanup() { + ActionManagerExist && cc.director.getActionManager().removeAllActionsFromTarget(this); + eventManager.removeListeners(this); + var i, len = this._children.length, node; + for (i = 0; i < len; ++i) { + node = this._children[i]; + node && node.cleanup(); + } + }, + sortAllChildren: function sortAllChildren() { + if (this._reorderChildDirty) { + this._reorderChildDirty = false; + var _children = this._children, child; + this._childArrivalOrder = 1; + for (var i = 0, len = _children.length; i < len; i++) { + child = _children[i]; + child._updateOrderOfArrival(); + } + eventManager._setDirtyForNode(this); + if (_children.length > 1) { + var _child, child2; + for (var _i2 = 1, count = _children.length; _i2 < count; _i2++) { + _child = _children[_i2]; + var j = _i2; + for (;j > 0 && (child2 = _children[j - 1])._localZOrder > _child._localZOrder; j--) _children[j] = child2; + _children[j] = _child; + } + this.emit(EventType.CHILD_REORDER, this); + } + cc.director.__fastOff(cc.Director.EVENT_AFTER_UPDATE, this.sortAllChildren, this); + } + }, + _delaySort: function _delaySort() { + if (!this._reorderChildDirty) { + this._reorderChildDirty = true; + cc.director.__fastOn(cc.Director.EVENT_AFTER_UPDATE, this.sortAllChildren, this); + } + }, + _restoreProperties: false, + onRestore: false + }; + false; + var Node = cc.Class(NodeDefines); + var _p = Node.prototype; + js.getset(_p, "position", _p.getPosition, _p.setPosition, false, true); + var vec3_tmp; + false; + cc.Node = module.exports = Node; + }), { + "./event-manager": 185, + "./event/event": 188, + "./event/event-target": 187, + "./platform/CCMacro": 245, + "./platform/js": 261, + "./renderer/render-flow": 273, + "./utils/affine-transform": 316, + "./utils/base-node": 317, + "./utils/prefab-helper": 328, + "./utils/trans-pool": 334, + "./value-types": 340, + "./value-types/utils": 347 + } ], + 74: [ (function(require, module, exports) { + "use strict"; + function _createForOfIteratorHelperLoose(o, allowArrayLike) { + var it = "undefined" !== typeof Symbol && o[Symbol.iterator] || o["@@iterator"]; + if (it) return (it = it.call(o)).next.bind(it); + if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && "number" === typeof o.length) { + it && (o = it); + var i = 0; + return function() { + if (i >= o.length) return { + done: true + }; + return { + done: false, + value: o[i++] + }; + }; + } + throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + function _unsupportedIterableToArray(o, minLen) { + if (!o) return; + if ("string" === typeof o) return _arrayLikeToArray(o, minLen); + var n = Object.prototype.toString.call(o).slice(8, -1); + "Object" === n && o.constructor && (n = o.constructor.name); + if ("Map" === n || "Set" === n) return Array.from(o); + if ("Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); + } + function _arrayLikeToArray(arr, len) { + (null == len || len > arr.length) && (len = arr.length); + for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; + return arr2; + } + var Node = require("./CCNode"); + var RenderFlow = require("./renderer/render-flow"); + var HideInHierarchy = cc.Object.Flags.HideInHierarchy; + var LocalDirtyFlag = Node._LocalDirtyFlag; + var POSITION_ON = 1; + var PrivateNode = cc.Class({ + name: "cc.PrivateNode", + extends: Node, + properties: { + x: { + get: function get() { + return this._originPos.x; + }, + set: function set(value) { + var localPosition = this._originPos; + if (value !== localPosition.x) { + localPosition.x = value; + this._posDirty(true); + } + }, + override: true + }, + y: { + get: function get() { + return this._originPos.y; + }, + set: function set(value) { + var localPosition = this._originPos; + if (value !== localPosition.y) { + localPosition.y = value; + this._posDirty(true); + } + }, + override: true + }, + zIndex: { + get: function get() { + return cc.macro.MIN_ZINDEX; + }, + set: function set() {}, + override: true + }, + showInEditor: { + default: false, + editorOnly: true, + override: true + } + }, + ctor: function ctor(name) { + this._localZOrder = cc.macro.MIN_ZINDEX << 16; + this._originPos = cc.v2(); + false; + }, + _posDirty: function _posDirty(sendEvent) { + this.setLocalDirty(LocalDirtyFlag.POSITION); + true, this._renderFlag |= RenderFlow.FLAG_TRANSFORM; + true === sendEvent && this._eventMask & POSITION_ON && this.emit(Node.EventType.POSITION_CHANGED); + }, + _updateLocalMatrix: function _updateLocalMatrix() { + if (!this._localMatDirty) return; + var parent = this.parent; + if (parent) { + this._trs[0] = this._originPos.x - (parent._anchorPoint.x - .5) * parent._contentSize.width; + this._trs[1] = this._originPos.y - (parent._anchorPoint.y - .5) * parent._contentSize.height; + } + this._super(); + }, + getPosition: function getPosition() { + return new cc.Vec2(this._originPos); + }, + setPosition: function setPosition(x, y) { + if (void 0 === y) { + x = x.x; + y = x.y; + } + var pos = this._originPos; + if (pos.x === x && pos.y === y) return; + pos.x = x; + pos.y = y; + this._posDirty(true); + }, + setParent: function setParent(value) { + var oldParent = this._parent; + this._super(value); + if (oldParent !== value) { + oldParent && oldParent.off(Node.EventType.ANCHOR_CHANGED, this._posDirty, this); + value && value.on(Node.EventType.ANCHOR_CHANGED, this._posDirty, this); + } + }, + _updateOrderOfArrival: function _updateOrderOfArrival() {} + }); + var proto = PrivateNode.prototype; + cc.js.getset(proto, "parent", proto.getParent, proto.setParent); + cc.js.getset(proto, "position", proto.getPosition, proto.setPosition); + false; + cc.PrivateNode = module.exports = PrivateNode; + }), { + "./CCNode": 73, + "./renderer/render-flow": 273 + } ], + 75: [ (function(require, module, exports) { + "use strict"; + var NIL = function NIL() {}; + cc.Scene = cc.Class({ + name: "cc.Scene", + extends: require("./CCNode"), + properties: { + _is3DNode: { + default: true, + override: true + }, + autoReleaseAssets: false + }, + ctor: function ctor() { + this._anchorPoint.x = 0; + this._anchorPoint.y = 0; + this._activeInHierarchy = false; + this._inited = !cc.game._isCloning; + false; + this.dependAssets = null; + }, + destroy: function destroy() { + if (cc.Object.prototype.destroy.call(this)) { + var children = this._children; + for (var i = 0; i < children.length; ++i) children[i].active = false; + } + this._active = false; + this._activeInHierarchy = false; + }, + _onHierarchyChanged: NIL, + _instantiate: null, + _load: function _load() { + if (!this._inited) { + false; + this._onBatchCreated(false); + this._inited = true; + } + }, + _activate: function _activate(active) { + active = false !== active; + false, false; + cc.director._nodeActivator.activateNode(this, active); + } + }); + module.exports = cc.Scene; + }), { + "./CCNode": 73 + } ], + 76: [ (function(require, module, exports) { + "use strict"; + var js = require("./platform/js"); + var IdGenerater = require("./platform/id-generater"); + var MAX_POOL_SIZE = 20; + var idGenerater = new IdGenerater("Scheduler"); + var ListEntry = function ListEntry(target, priority, paused, markedForDeletion) { + this.target = target; + this.priority = priority; + this.paused = paused; + this.markedForDeletion = markedForDeletion; + }; + var _listEntries = []; + ListEntry.get = function(target, priority, paused, markedForDeletion) { + var result = _listEntries.pop(); + if (result) { + result.target = target; + result.priority = priority; + result.paused = paused; + result.markedForDeletion = markedForDeletion; + } else result = new ListEntry(target, priority, paused, markedForDeletion); + return result; + }; + ListEntry.put = function(entry) { + if (_listEntries.length < MAX_POOL_SIZE) { + entry.target = null; + _listEntries.push(entry); + } + }; + var HashUpdateEntry = function HashUpdateEntry(list, entry, target, callback) { + this.list = list; + this.entry = entry; + this.target = target; + this.callback = callback; + }; + var _hashUpdateEntries = []; + HashUpdateEntry.get = function(list, entry, target, callback) { + var result = _hashUpdateEntries.pop(); + if (result) { + result.list = list; + result.entry = entry; + result.target = target; + result.callback = callback; + } else result = new HashUpdateEntry(list, entry, target, callback); + return result; + }; + HashUpdateEntry.put = function(entry) { + if (_hashUpdateEntries.length < MAX_POOL_SIZE) { + entry.list = entry.entry = entry.target = entry.callback = null; + _hashUpdateEntries.push(entry); + } + }; + var HashTimerEntry = function HashTimerEntry(timers, target, timerIndex, currentTimer, currentTimerSalvaged, paused) { + var _t = this; + _t.timers = timers; + _t.target = target; + _t.timerIndex = timerIndex; + _t.currentTimer = currentTimer; + _t.currentTimerSalvaged = currentTimerSalvaged; + _t.paused = paused; + }; + var _hashTimerEntries = []; + HashTimerEntry.get = function(timers, target, timerIndex, currentTimer, currentTimerSalvaged, paused) { + var result = _hashTimerEntries.pop(); + if (result) { + result.timers = timers; + result.target = target; + result.timerIndex = timerIndex; + result.currentTimer = currentTimer; + result.currentTimerSalvaged = currentTimerSalvaged; + result.paused = paused; + } else result = new HashTimerEntry(timers, target, timerIndex, currentTimer, currentTimerSalvaged, paused); + return result; + }; + HashTimerEntry.put = function(entry) { + if (_hashTimerEntries.length < MAX_POOL_SIZE) { + entry.timers = entry.target = entry.currentTimer = null; + _hashTimerEntries.push(entry); + } + }; + function CallbackTimer() { + this._lock = false; + this._scheduler = null; + this._elapsed = -1; + this._runForever = false; + this._useDelay = false; + this._timesExecuted = 0; + this._repeat = 0; + this._delay = 0; + this._interval = 0; + this._target = null; + this._callback = null; + } + var proto = CallbackTimer.prototype; + proto.initWithCallback = function(scheduler, callback, target, seconds, repeat, delay) { + this._lock = false; + this._scheduler = scheduler; + this._target = target; + this._callback = callback; + this._elapsed = -1; + this._interval = seconds; + this._delay = delay; + this._useDelay = this._delay > 0; + this._repeat = repeat; + this._runForever = this._repeat === cc.macro.REPEAT_FOREVER; + return true; + }; + proto.getInterval = function() { + return this._interval; + }; + proto.setInterval = function(interval) { + this._interval = interval; + }; + proto.update = function(dt) { + if (-1 === this._elapsed) { + this._elapsed = 0; + this._timesExecuted = 0; + } else { + this._elapsed += dt; + if (this._runForever && !this._useDelay) { + if (this._elapsed >= this._interval) { + this.trigger(); + this._elapsed = 0; + } + } else { + if (this._useDelay) { + if (this._elapsed >= this._delay) { + this.trigger(); + this._elapsed -= this._delay; + this._timesExecuted += 1; + this._useDelay = false; + } + } else if (this._elapsed >= this._interval) { + this.trigger(); + this._elapsed = 0; + this._timesExecuted += 1; + } + this._callback && !this._runForever && this._timesExecuted > this._repeat && this.cancel(); + } + } + }; + proto.getCallback = function() { + return this._callback; + }; + proto.trigger = function() { + if (this._target && this._callback) { + this._lock = true; + this._callback.call(this._target, this._elapsed); + this._lock = false; + } + }; + proto.cancel = function() { + this._scheduler.unschedule(this._callback, this._target); + }; + var _timers = []; + CallbackTimer.get = function() { + return _timers.pop() || new CallbackTimer(); + }; + CallbackTimer.put = function(timer) { + if (_timers.length < MAX_POOL_SIZE && !timer._lock) { + timer._scheduler = timer._target = timer._callback = null; + _timers.push(timer); + } + }; + cc.Scheduler = function() { + this._timeScale = 1; + this._updatesNegList = []; + this._updates0List = []; + this._updatesPosList = []; + this._hashForUpdates = js.createMap(true); + this._hashForTimers = js.createMap(true); + this._currentTarget = null; + this._currentTargetSalvaged = false; + this._updateHashLocked = false; + this._arrayForTimers = []; + }; + cc.Scheduler.prototype = { + constructor: cc.Scheduler, + _removeHashElement: function _removeHashElement(element) { + delete this._hashForTimers[element.target._id]; + var arr = this._arrayForTimers; + for (var i = 0, l = arr.length; i < l; i++) if (arr[i] === element) { + arr.splice(i, 1); + break; + } + HashTimerEntry.put(element); + }, + _removeUpdateFromHash: function _removeUpdateFromHash(entry) { + var targetId = entry.target._id; + var self = this, element = self._hashForUpdates[targetId]; + if (element) { + var list = element.list, listEntry = element.entry; + for (var i = 0, l = list.length; i < l; i++) if (list[i] === listEntry) { + list.splice(i, 1); + break; + } + delete self._hashForUpdates[targetId]; + ListEntry.put(listEntry); + HashUpdateEntry.put(element); + } + }, + _priorityIn: function _priorityIn(ppList, listElement, priority) { + for (var i = 0; i < ppList.length; i++) if (priority < ppList[i].priority) { + ppList.splice(i, 0, listElement); + return; + } + ppList.push(listElement); + }, + _appendIn: function _appendIn(ppList, listElement) { + ppList.push(listElement); + }, + enableForTarget: function enableForTarget(target) { + target._id || (target.__instanceId ? cc.warnID(1513) : target._id = idGenerater.getNewId()); + }, + setTimeScale: function setTimeScale(timeScale) { + this._timeScale = timeScale; + }, + getTimeScale: function getTimeScale() { + return this._timeScale; + }, + update: function update(dt) { + this._updateHashLocked = true; + 1 !== this._timeScale && (dt *= this._timeScale); + var i, list, len, entry; + for (i = 0, list = this._updatesNegList, len = list.length; i < len; i++) { + entry = list[i]; + entry.paused || entry.markedForDeletion || entry.target.update(dt); + } + for (i = 0, list = this._updates0List, len = list.length; i < len; i++) { + entry = list[i]; + entry.paused || entry.markedForDeletion || entry.target.update(dt); + } + for (i = 0, list = this._updatesPosList, len = list.length; i < len; i++) { + entry = list[i]; + entry.paused || entry.markedForDeletion || entry.target.update(dt); + } + var elt, arr = this._arrayForTimers; + for (i = 0; i < arr.length; i++) { + elt = arr[i]; + this._currentTarget = elt; + this._currentTargetSalvaged = false; + if (!elt.paused) for (elt.timerIndex = 0; elt.timerIndex < elt.timers.length; ++elt.timerIndex) { + elt.currentTimer = elt.timers[elt.timerIndex]; + elt.currentTimerSalvaged = false; + elt.currentTimer.update(dt); + elt.currentTimer = null; + } + if (this._currentTargetSalvaged && 0 === this._currentTarget.timers.length) { + this._removeHashElement(this._currentTarget); + --i; + } + } + for (i = 0, list = this._updatesNegList; i < list.length; ) { + entry = list[i]; + entry.markedForDeletion ? this._removeUpdateFromHash(entry) : i++; + } + for (i = 0, list = this._updates0List; i < list.length; ) { + entry = list[i]; + entry.markedForDeletion ? this._removeUpdateFromHash(entry) : i++; + } + for (i = 0, list = this._updatesPosList; i < list.length; ) { + entry = list[i]; + entry.markedForDeletion ? this._removeUpdateFromHash(entry) : i++; + } + this._updateHashLocked = false; + this._currentTarget = null; + }, + schedule: function schedule(callback, target, interval, repeat, delay, paused) { + if ("function" !== typeof callback) { + var tmp = callback; + callback = target; + target = tmp; + } + if (4 === arguments.length || 5 === arguments.length) { + paused = !!repeat; + repeat = cc.macro.REPEAT_FOREVER; + delay = 0; + } + cc.assertID(target, 1502); + var targetId = target._id; + if (!targetId) if (target.__instanceId) { + cc.warnID(1513); + targetId = target._id = target.__instanceId; + } else cc.errorID(1510); + var element = this._hashForTimers[targetId]; + if (element) element.paused !== paused && cc.warnID(1511); else { + element = HashTimerEntry.get(null, target, 0, null, null, paused); + this._arrayForTimers.push(element); + this._hashForTimers[targetId] = element; + } + var timer, i; + if (null == element.timers) element.timers = []; else for (i = 0; i < element.timers.length; ++i) { + timer = element.timers[i]; + if (timer && callback === timer._callback) { + cc.logID(1507, timer.getInterval(), interval); + timer._interval = interval; + return; + } + } + timer = CallbackTimer.get(); + timer.initWithCallback(this, callback, target, interval, repeat, delay); + element.timers.push(timer); + this._currentTarget === element && this._currentTargetSalvaged && (this._currentTargetSalvaged = false); + }, + scheduleUpdate: function scheduleUpdate(target, priority, paused) { + var targetId = target._id; + if (!targetId) if (target.__instanceId) { + cc.warnID(1513); + targetId = target._id = target.__instanceId; + } else cc.errorID(1510); + var hashElement = this._hashForUpdates[targetId]; + if (hashElement && hashElement.entry) { + if (hashElement.entry.priority === priority) { + hashElement.entry.markedForDeletion = false; + hashElement.entry.paused = paused; + return; + } + if (this._updateHashLocked) { + cc.logID(1506); + hashElement.entry.markedForDeletion = false; + hashElement.entry.paused = paused; + return; + } + this.unscheduleUpdate(target); + } + var listElement = ListEntry.get(target, priority, paused, false); + var ppList; + if (0 === priority) { + ppList = this._updates0List; + this._appendIn(ppList, listElement); + } else { + ppList = priority < 0 ? this._updatesNegList : this._updatesPosList; + this._priorityIn(ppList, listElement, priority); + } + this._hashForUpdates[targetId] = HashUpdateEntry.get(ppList, listElement, target, null); + }, + unschedule: function unschedule(callback, target) { + if (!target || !callback) return; + var targetId = target._id; + if (!targetId) if (target.__instanceId) { + cc.warnID(1513); + targetId = target._id = target.__instanceId; + } else cc.errorID(1510); + var self = this, element = self._hashForTimers[targetId]; + if (element) { + var timers = element.timers; + for (var i = 0, li = timers.length; i < li; i++) { + var timer = timers[i]; + if (callback === timer._callback) { + timer !== element.currentTimer || element.currentTimerSalvaged || (element.currentTimerSalvaged = true); + timers.splice(i, 1); + CallbackTimer.put(timer); + element.timerIndex >= i && element.timerIndex--; + 0 === timers.length && (self._currentTarget === element ? self._currentTargetSalvaged = true : self._removeHashElement(element)); + return; + } + } + } + }, + unscheduleUpdate: function unscheduleUpdate(target) { + if (!target) return; + var targetId = target._id; + if (!targetId) if (target.__instanceId) { + cc.warnID(1513); + targetId = target._id = target.__instanceId; + } else cc.errorID(1510); + var element = this._hashForUpdates[targetId]; + element && (this._updateHashLocked ? element.entry.markedForDeletion = true : this._removeUpdateFromHash(element.entry)); + }, + unscheduleAllForTarget: function unscheduleAllForTarget(target) { + if (!target) return; + var targetId = target._id; + if (!targetId) if (target.__instanceId) { + cc.warnID(1513); + targetId = target._id = target.__instanceId; + } else cc.errorID(1510); + var element = this._hashForTimers[targetId]; + if (element) { + var timers = element.timers; + timers.indexOf(element.currentTimer) > -1 && !element.currentTimerSalvaged && (element.currentTimerSalvaged = true); + for (var i = 0, l = timers.length; i < l; i++) CallbackTimer.put(timers[i]); + timers.length = 0; + this._currentTarget === element ? this._currentTargetSalvaged = true : this._removeHashElement(element); + } + this.unscheduleUpdate(target); + }, + unscheduleAll: function unscheduleAll() { + this.unscheduleAllWithMinPriority(cc.Scheduler.PRIORITY_SYSTEM); + }, + unscheduleAllWithMinPriority: function unscheduleAllWithMinPriority(minPriority) { + var i, element, arr = this._arrayForTimers; + for (i = arr.length - 1; i >= 0; i--) { + element = arr[i]; + this.unscheduleAllForTarget(element.target); + } + var entry; + var temp_length = 0; + if (minPriority < 0) for (i = 0; i < this._updatesNegList.length; ) { + temp_length = this._updatesNegList.length; + entry = this._updatesNegList[i]; + entry && entry.priority >= minPriority && this.unscheduleUpdate(entry.target); + temp_length == this._updatesNegList.length && i++; + } + if (minPriority <= 0) for (i = 0; i < this._updates0List.length; ) { + temp_length = this._updates0List.length; + entry = this._updates0List[i]; + entry && this.unscheduleUpdate(entry.target); + temp_length == this._updates0List.length && i++; + } + for (i = 0; i < this._updatesPosList.length; ) { + temp_length = this._updatesPosList.length; + entry = this._updatesPosList[i]; + entry && entry.priority >= minPriority && this.unscheduleUpdate(entry.target); + temp_length == this._updatesPosList.length && i++; + } + }, + isScheduled: function isScheduled(callback, target) { + cc.assertID(callback, 1508); + cc.assertID(target, 1509); + var targetId = target._id; + if (!targetId) if (target.__instanceId) { + cc.warnID(1513); + targetId = target._id = target.__instanceId; + } else cc.errorID(1510); + var element = this._hashForTimers[targetId]; + if (!element) return false; + if (null == element.timers) return false; + var timers = element.timers; + for (var i = 0; i < timers.length; ++i) { + var timer = timers[i]; + if (callback === timer._callback) return true; + } + return false; + }, + pauseAllTargets: function pauseAllTargets() { + return this.pauseAllTargetsWithMinPriority(cc.Scheduler.PRIORITY_SYSTEM); + }, + pauseAllTargetsWithMinPriority: function pauseAllTargetsWithMinPriority(minPriority) { + var idsWithSelectors = []; + var self = this, element, locArrayForTimers = self._arrayForTimers; + var i, li; + for (i = 0, li = locArrayForTimers.length; i < li; i++) { + element = locArrayForTimers[i]; + if (element) { + element.paused = true; + idsWithSelectors.push(element.target); + } + } + var entry; + if (minPriority < 0) for (i = 0; i < this._updatesNegList.length; i++) { + entry = this._updatesNegList[i]; + if (entry && entry.priority >= minPriority) { + entry.paused = true; + idsWithSelectors.push(entry.target); + } + } + if (minPriority <= 0) for (i = 0; i < this._updates0List.length; i++) { + entry = this._updates0List[i]; + if (entry) { + entry.paused = true; + idsWithSelectors.push(entry.target); + } + } + for (i = 0; i < this._updatesPosList.length; i++) { + entry = this._updatesPosList[i]; + if (entry && entry.priority >= minPriority) { + entry.paused = true; + idsWithSelectors.push(entry.target); + } + } + return idsWithSelectors; + }, + resumeTargets: function resumeTargets(targetsToResume) { + if (!targetsToResume) return; + for (var i = 0; i < targetsToResume.length; i++) this.resumeTarget(targetsToResume[i]); + }, + pauseTarget: function pauseTarget(target) { + cc.assertID(target, 1503); + var targetId = target._id; + if (!targetId) if (target.__instanceId) { + cc.warnID(1513); + targetId = target._id = target.__instanceId; + } else cc.errorID(1510); + var self = this, element = self._hashForTimers[targetId]; + element && (element.paused = true); + var elementUpdate = self._hashForUpdates[targetId]; + elementUpdate && (elementUpdate.entry.paused = true); + }, + resumeTarget: function resumeTarget(target) { + cc.assertID(target, 1504); + var targetId = target._id; + if (!targetId) if (target.__instanceId) { + cc.warnID(1513); + targetId = target._id = target.__instanceId; + } else cc.errorID(1510); + var self = this, element = self._hashForTimers[targetId]; + element && (element.paused = false); + var elementUpdate = self._hashForUpdates[targetId]; + elementUpdate && (elementUpdate.entry.paused = false); + }, + isTargetPaused: function isTargetPaused(target) { + cc.assertID(target, 1505); + var targetId = target._id; + if (!targetId) if (target.__instanceId) { + cc.warnID(1513); + targetId = target._id = target.__instanceId; + } else cc.errorID(1510); + var element = this._hashForTimers[targetId]; + if (element) return element.paused; + var elementUpdate = this._hashForUpdates[targetId]; + if (elementUpdate) return elementUpdate.entry.paused; + return false; + } + }; + cc.Scheduler.PRIORITY_SYSTEM = 1 << 31; + cc.Scheduler.PRIORITY_NON_SYSTEM = cc.Scheduler.PRIORITY_SYSTEM + 1; + module.exports = cc.Scheduler; + }), { + "./platform/id-generater": 257, + "./platform/js": 261 + } ], + 77: [ (function(require, module, exports) { + "use strict"; + var preprocess = require("./preprocess"); + var fetch = require("./fetch"); + var Cache = require("./cache"); + var helper = require("./helper"); + var releaseManager = require("./releaseManager"); + var dependUtil = require("./depend-util"); + var load = require("./load"); + var Pipeline = require("./pipeline"); + var Task = require("./task"); + var RequestItem = require("./request-item"); + var downloader = require("./downloader"); + var parser = require("./parser"); + var packManager = require("./pack-manager"); + var Bundle = require("./bundle"); + var builtins = require("./builtins"); + var factory = require("./factory"); + var _require = require("./urlTransformer"), parse = _require.parse, combine = _require.combine; + var _require2 = require("./utilities"), parseParameters = _require2.parseParameters, asyncify = _require2.asyncify; + var _require3 = require("./shared"), assets = _require3.assets, files = _require3.files, parsed = _require3.parsed, pipeline = _require3.pipeline, transformPipeline = _require3.transformPipeline, fetchPipeline = _require3.fetchPipeline, RequestType = _require3.RequestType, bundles = _require3.bundles, BuiltinBundleName = _require3.BuiltinBundleName; + function AssetManager() { + this._preprocessPipe = preprocess; + this._fetchPipe = fetch; + this._loadPipe = load; + this.pipeline = pipeline.append(preprocess).append(load); + this.fetchPipeline = fetchPipeline.append(preprocess).append(fetch); + this.transformPipeline = transformPipeline.append(parse).append(combine); + this.bundles = bundles; + this.assets = assets; + this._files = files; + this._parsed = parsed; + this.generalImportBase = ""; + this.generalNativeBase = ""; + this.dependUtil = dependUtil; + this._releaseManager = releaseManager; + this.cacheAsset = true; + this.force = false; + this.utils = helper; + this.downloader = downloader; + this.parser = parser; + this.builtins = builtins; + this.packManager = packManager; + this.factory = factory; + this.cacheManager = null; + this.presets = { + default: { + priority: 0 + }, + preload: { + maxConcurrency: 2, + maxRequestsPerFrame: 2, + priority: -1 + }, + scene: { + maxConcurrency: 8, + maxRequestsPerFrame: 8, + priority: 1 + }, + bundle: { + maxConcurrency: 8, + maxRequestsPerFrame: 8, + priority: 2 + }, + remote: { + maxRetryCount: 4 + }, + script: { + maxConcurrency: 1024, + maxRequestsPerFrame: 1024, + priority: 2 + } + }; + } + AssetManager.Pipeline = Pipeline; + AssetManager.Task = Task; + AssetManager.Cache = Cache; + AssetManager.RequestItem = RequestItem; + AssetManager.Bundle = Bundle; + AssetManager.BuiltinBundleName = BuiltinBundleName; + AssetManager.prototype = { + constructor: AssetManager, + get main() { + return bundles.get(BuiltinBundleName.MAIN); + }, + get resources() { + return bundles.get(BuiltinBundleName.RESOURCES); + }, + get internal() { + return bundles.get(BuiltinBundleName.INTERNAL); + }, + init: function init(options) { + options = options || Object.create(null); + this._files.clear(); + this._parsed.clear(); + this._releaseManager.init(); + this.assets.clear(); + this.bundles.clear(); + this.packManager.init(); + this.downloader.init(options.bundleVers, options.server); + this.parser.init(); + this.dependUtil.init(); + this.generalImportBase = options.importBase; + this.generalNativeBase = options.nativeBase; + }, + getBundle: function getBundle(name) { + return bundles.get(name); + }, + removeBundle: function removeBundle(bundle) { + bundle._destroy(); + bundles.remove(bundle.name); + }, + loadAny: function loadAny(requests, options, onProgress, onComplete) { + var _parseParameters = parseParameters(options, onProgress, onComplete), options = _parseParameters.options, onProgress = _parseParameters.onProgress, onComplete = _parseParameters.onComplete; + options.preset = options.preset || "default"; + requests = Array.isArray(requests) ? requests.concat() : requests; + var task = new Task({ + input: requests, + onProgress: onProgress, + onComplete: asyncify(onComplete), + options: options + }); + pipeline.async(task); + }, + preloadAny: function preloadAny(requests, options, onProgress, onComplete) { + var _parseParameters2 = parseParameters(options, onProgress, onComplete), options = _parseParameters2.options, onProgress = _parseParameters2.onProgress, onComplete = _parseParameters2.onComplete; + options.preset = options.preset || "preload"; + requests = Array.isArray(requests) ? requests.concat() : requests; + var task = new Task({ + input: requests, + onProgress: onProgress, + onComplete: asyncify(onComplete), + options: options + }); + fetchPipeline.async(task); + }, + postLoadNative: function postLoadNative(asset, options, onComplete) { + if (!(asset instanceof cc.Asset)) throw new Error("input is not asset"); + var _parseParameters3 = parseParameters(options, void 0, onComplete), options = _parseParameters3.options, onComplete = _parseParameters3.onComplete; + if (!asset._native || asset._nativeAsset) return asyncify(onComplete)(null); + var depend = dependUtil.getNativeDep(asset._uuid); + if (depend) { + if (!bundles.has(depend.bundle)) { + var bundle = bundles.find((function(bundle) { + return bundle.getAssetInfo(asset._uuid); + })); + bundle && (depend.bundle = bundle.name); + } + this.loadAny(depend, options, (function(err, _native) { + err ? cc.error(err.message, err.stack) : asset.isValid && !asset._nativeAsset && (asset._nativeAsset = _native); + onComplete && onComplete(err); + })); + } + }, + loadRemote: function loadRemote(url, options, onComplete) { + var _parseParameters4 = parseParameters(options, void 0, onComplete), options = _parseParameters4.options, onComplete = _parseParameters4.onComplete; + if (this.assets.has(url)) return asyncify(onComplete)(null, this.assets.get(url)); + options.__isNative__ = true; + options.preset = options.preset || "remote"; + this.loadAny({ + url: url + }, options, null, (function(err, data) { + if (err) { + cc.error(err.message, err.stack); + onComplete && onComplete(err, null); + } else factory.create(url, data, options.ext || cc.path.extname(url), options, (function(err, out) { + onComplete && onComplete(err, out); + })); + })); + }, + loadScript: function loadScript(url, options, onComplete) { + var _parseParameters5 = parseParameters(options, void 0, onComplete), options = _parseParameters5.options, onComplete = _parseParameters5.onComplete; + options.__requestType__ = RequestType.URL; + options.preset = options.preset || "script"; + this.loadAny(url, options, onComplete); + }, + loadBundle: function loadBundle(nameOrUrl, options, onComplete) { + var _parseParameters6 = parseParameters(options, void 0, onComplete), options = _parseParameters6.options, onComplete = _parseParameters6.onComplete; + var bundleName = cc.path.basename(nameOrUrl); + if (this.bundles.has(bundleName)) return asyncify(onComplete)(null, this.getBundle(bundleName)); + options.preset = options.preset || "bundle"; + options.ext = "bundle"; + this.loadRemote(nameOrUrl, options, onComplete); + }, + releaseAsset: function releaseAsset(asset) { + releaseManager.tryRelease(asset, true); + }, + releaseUnusedAssets: function releaseUnusedAssets() { + assets.forEach((function(asset) { + releaseManager.tryRelease(asset); + })); + }, + releaseAll: function releaseAll() { + assets.forEach((function(asset) { + releaseManager.tryRelease(asset, true); + })); + false; + }, + _transform: function _transform(input, options) { + var subTask = Task.create({ + input: input, + options: options + }); + var urls = []; + try { + var result = transformPipeline.sync(subTask); + for (var i = 0, l = result.length; i < l; i++) { + var item = result[i]; + var url = item.url; + item.recycle(); + urls.push(url); + } + } catch (e) { + for (var i = 0, l = subTask.output.length; i < l; i++) subTask.output[i].recycle(); + cc.error(e.message, e.stack); + } + subTask.recycle(); + return urls.length > 1 ? urls : urls[0]; + } + }; + cc.AssetManager = AssetManager; + cc.assetManager = new AssetManager(); + Object.defineProperty(cc, "resources", { + get: function get() { + return bundles.get(BuiltinBundleName.RESOURCES); + } + }); + module.exports = cc.assetManager; + }), { + "./builtins": 78, + "./bundle": 79, + "./cache": 80, + "./depend-util": 82, + "./downloader": 89, + "./factory": 90, + "./fetch": 91, + "./helper": 93, + "./load": 95, + "./pack-manager": 96, + "./parser": 97, + "./pipeline": 98, + "./preprocess": 99, + "./releaseManager": 100, + "./request-item": 101, + "./shared": 102, + "./task": 103, + "./urlTransformer": 104, + "./utilities": 105 + } ], + 78: [ (function(require, module, exports) { + "use strict"; + var Cache = require("./cache"); + var releaseManager = require("./releaseManager"); + var _require = require("./shared"), BuiltinBundleName = _require.BuiltinBundleName; + var builtins = { + _assets: new Cache({ + material: new Cache(), + effect: new Cache() + }), + _loadBuiltins: function _loadBuiltins(name, cb) { + var dirname = name + "s"; + var builtin = this._assets.get(name); + return cc.assetManager.internal.loadDir(dirname, null, null, (function(err, assets) { + if (err) cc.error(err.message, err.stack); else for (var i = 0; i < assets.length; i++) { + var asset = assets[i]; + builtin.add(asset.name, asset.addRef()); + } + cb(); + })); + }, + init: function init(cb) { + var _this = this; + this.clear(); + if (cc.game.renderType === cc.game.RENDER_TYPE_CANVAS || !cc.assetManager.bundles.has(BuiltinBundleName.INTERNAL)) return cb && cb(); + this._loadBuiltins("effect", (function() { + _this._loadBuiltins("material", cb); + })); + }, + getBuiltin: function getBuiltin(type, name) { + return 0 === arguments.length ? this._assets : 1 === arguments.length ? this._assets.get(type) : this._assets.get(type).get(name); + }, + clear: function clear() { + this._assets.forEach((function(assets) { + assets.forEach((function(asset) { + releaseManager.tryRelease(asset, true); + })); + assets.clear(); + })); + } + }; + module.exports = builtins; + }), { + "./cache": 80, + "./releaseManager": 100, + "./shared": 102 + } ], + 79: [ (function(require, module, exports) { + "use strict"; + var Config = require("./config"); + var releaseManager = require("./releaseManager"); + var _require = require("./utilities"), parseParameters = _require.parseParameters, parseLoadResArgs = _require.parseLoadResArgs; + var _require2 = require("./shared"), RequestType = _require2.RequestType, assets = _require2.assets, bundles = _require2.bundles; + function Bundle() { + this._config = new Config(); + } + Bundle.prototype = { + constructor: Bundle, + get name() { + return this._config.name; + }, + get deps() { + return this._config.deps; + }, + get base() { + return this._config.base; + }, + getInfoWithPath: function getInfoWithPath(path, type) { + return this._config.getInfoWithPath(path, type); + }, + getDirWithPath: function getDirWithPath(path, type, out) { + return this._config.getDirWithPath(path, type, out); + }, + getAssetInfo: function getAssetInfo(uuid) { + return this._config.getAssetInfo(uuid); + }, + getSceneInfo: function getSceneInfo(name) { + return this._config.getSceneInfo(name); + }, + init: function init(options) { + this._config.init(options); + bundles.add(options.name, this); + }, + load: function load(paths, type, onProgress, onComplete) { + var _parseLoadResArgs = parseLoadResArgs(type, onProgress, onComplete), type = _parseLoadResArgs.type, onProgress = _parseLoadResArgs.onProgress, onComplete = _parseLoadResArgs.onComplete; + cc.assetManager.loadAny(paths, { + __requestType__: RequestType.PATH, + type: type, + bundle: this.name, + __outputAsArray__: Array.isArray(paths) + }, onProgress, onComplete); + }, + preload: function preload(paths, type, onProgress, onComplete) { + var _parseLoadResArgs2 = parseLoadResArgs(type, onProgress, onComplete), type = _parseLoadResArgs2.type, onProgress = _parseLoadResArgs2.onProgress, onComplete = _parseLoadResArgs2.onComplete; + cc.assetManager.preloadAny(paths, { + __requestType__: RequestType.PATH, + type: type, + bundle: this.name + }, onProgress, onComplete); + }, + loadDir: function loadDir(dir, type, onProgress, onComplete) { + var _parseLoadResArgs3 = parseLoadResArgs(type, onProgress, onComplete), type = _parseLoadResArgs3.type, onProgress = _parseLoadResArgs3.onProgress, onComplete = _parseLoadResArgs3.onComplete; + cc.assetManager.loadAny(dir, { + __requestType__: RequestType.DIR, + type: type, + bundle: this.name, + __outputAsArray__: true + }, onProgress, onComplete); + }, + preloadDir: function preloadDir(dir, type, onProgress, onComplete) { + var _parseLoadResArgs4 = parseLoadResArgs(type, onProgress, onComplete), type = _parseLoadResArgs4.type, onProgress = _parseLoadResArgs4.onProgress, onComplete = _parseLoadResArgs4.onComplete; + cc.assetManager.preloadAny(dir, { + __requestType__: RequestType.DIR, + type: type, + bundle: this.name + }, onProgress, onComplete); + }, + loadScene: function loadScene(sceneName, options, onProgress, onComplete) { + var _parseParameters = parseParameters(options, onProgress, onComplete), options = _parseParameters.options, onProgress = _parseParameters.onProgress, onComplete = _parseParameters.onComplete; + options.preset = options.preset || "scene"; + options.bundle = this.name; + cc.assetManager.loadAny({ + scene: sceneName + }, options, onProgress, (function(err, sceneAsset) { + if (err) { + cc.error(err.message, err.stack); + onComplete && onComplete(err); + } else if (sceneAsset instanceof cc.SceneAsset) { + var scene = sceneAsset.scene; + scene._id = sceneAsset._uuid; + scene._name = sceneAsset._name; + onComplete && onComplete(null, sceneAsset); + } else onComplete && onComplete(new Error("The asset " + sceneAsset._uuid + " is not a scene")); + })); + }, + preloadScene: function preloadScene(sceneName, options, onProgress, onComplete) { + var _parseParameters2 = parseParameters(options, onProgress, onComplete), options = _parseParameters2.options, onProgress = _parseParameters2.onProgress, onComplete = _parseParameters2.onComplete; + options.bundle = this.name; + cc.assetManager.preloadAny({ + scene: sceneName + }, options, onProgress, (function(err) { + err && cc.errorID(1210, sceneName, err.message); + onComplete && onComplete(err); + })); + }, + get: function get(path, type) { + var info = this.getInfoWithPath(path, type); + return assets.get(info && info.uuid); + }, + release: function release(path, type) { + releaseManager.tryRelease(this.get(path, type), true); + }, + releaseUnusedAssets: function releaseUnusedAssets() { + var self = this; + assets.forEach((function(asset) { + var info = self.getAssetInfo(asset._uuid); + info && !info.redirect && releaseManager.tryRelease(asset); + })); + }, + releaseAll: function releaseAll() { + var self = this; + assets.forEach((function(asset) { + var info = self.getAssetInfo(asset._uuid); + info && !info.redirect && releaseManager.tryRelease(asset, true); + })); + }, + _destroy: function _destroy() { + this._config.destroy(); + } + }; + module.exports = Bundle; + }), { + "./config": 81, + "./releaseManager": 100, + "./shared": 102, + "./utilities": 105 + } ], + 80: [ (function(require, module, exports) { + "use strict"; + var js = require("../platform/js"); + function Cache(map) { + if (map) { + this._map = map; + this._count = Object.keys(map).length; + } else { + this._map = js.createMap(true); + this._count = 0; + } + } + Cache.prototype = { + constructor: Cache, + add: function add(key, val) { + key in this._map || this._count++; + return this._map[key] = val; + }, + get: function get(key) { + return this._map[key]; + }, + has: function has(key) { + return key in this._map; + }, + remove: function remove(key) { + var out = this._map[key]; + if (key in this._map) { + delete this._map[key]; + this._count--; + } + return out; + }, + clear: function clear() { + if (0 !== this._count) { + this._map = js.createMap(true); + this._count = 0; + } + }, + forEach: function forEach(func) { + for (var key in this._map) func(this._map[key], key); + }, + find: function find(predicate) { + for (var key in this._map) if (predicate(this._map[key], key)) return this._map[key]; + return null; + }, + get count() { + return this._count; + }, + destroy: function destroy() { + this._map = null; + } + }; + module.exports = Cache; + }), { + "../platform/js": 261 + } ], + 81: [ (function(require, module, exports) { + "use strict"; + var js = require("../platform/js"); + var Cache = require("./cache"); + var _require = require("./helper"), normalize = _require.normalize; + var _require2 = require("./utilities"), processOptions = _require2.processOptions; + function Config() { + this.name = ""; + this.base = ""; + this.importBase = ""; + this.nativeBase = ""; + this.deps = null; + this.assetInfos = new Cache(); + this.scenes = new Cache(); + this.paths = new Cache(); + } + Config.prototype = { + constructor: Config, + init: function init(options) { + processOptions(options); + this.importBase = options.importBase || ""; + this.nativeBase = options.nativeBase || ""; + this.base = options.base || ""; + this.name = options.name || ""; + this.deps = options.deps || []; + this._initUuid(options.uuids); + this._initPath(options.paths); + this._initScene(options.scenes); + this._initPackage(options.packs); + this._initVersion(options.versions); + this._initRedirect(options.redirect); + }, + _initUuid: function _initUuid(uuidList) { + if (!uuidList) return; + this.assetInfos.clear(); + for (var i = 0, l = uuidList.length; i < l; i++) { + var uuid = uuidList[i]; + this.assetInfos.add(uuid, { + uuid: uuid + }); + } + }, + _initPath: function _initPath(pathList) { + if (!pathList) return; + var paths = this.paths; + paths.clear(); + for (var uuid in pathList) { + var info = pathList[uuid]; + var path = info[0]; + var type = info[1]; + var isSubAsset = 3 === info.length; + var assetInfo = this.assetInfos.get(uuid); + assetInfo.path = path; + assetInfo.ctor = js._getClassById(type); + paths.has(path) ? isSubAsset ? paths.get(path).push(assetInfo) : paths.get(path).unshift(assetInfo) : paths.add(path, [ assetInfo ]); + } + }, + _initScene: function _initScene(sceneList) { + if (!sceneList) return; + var scenes = this.scenes; + scenes.clear(); + var assetInfos = this.assetInfos; + for (var sceneName in sceneList) { + var uuid = sceneList[sceneName]; + var assetInfo = assetInfos.get(uuid); + assetInfo.url = sceneName; + scenes.add(sceneName, assetInfo); + } + }, + _initPackage: function _initPackage(packageList) { + if (!packageList) return; + var assetInfos = this.assetInfos; + for (var packUuid in packageList) { + var uuids = packageList[packUuid]; + var pack = { + uuid: packUuid, + packs: uuids, + ext: ".json" + }; + assetInfos.add(packUuid, pack); + for (var i = 0, l = uuids.length; i < l; i++) { + var uuid = uuids[i]; + var assetInfo = assetInfos.get(uuid); + var assetPacks = assetInfo.packs; + assetPacks ? 1 === l ? assetPacks.unshift(pack) : assetPacks.push(pack) : assetInfo.packs = [ pack ]; + } + } + }, + _initVersion: function _initVersion(versions) { + if (!versions) return; + var assetInfos = this.assetInfos; + var entries = versions["import"]; + if (entries) for (var i = 0, l = entries.length; i < l; i += 2) { + var uuid = entries[i]; + var assetInfo = assetInfos.get(uuid); + assetInfo.ver = entries[i + 1]; + } + entries = versions["native"]; + if (entries) for (var i = 0, l = entries.length; i < l; i += 2) { + var uuid = entries[i]; + var assetInfo = assetInfos.get(uuid); + assetInfo.nativeVer = entries[i + 1]; + } + }, + _initRedirect: function _initRedirect(redirect) { + if (!redirect) return; + var assetInfos = this.assetInfos; + for (var i = 0, l = redirect.length; i < l; i += 2) { + var uuid = redirect[i]; + var assetInfo = assetInfos.get(uuid); + assetInfo.redirect = redirect[i + 1]; + } + }, + getInfoWithPath: function getInfoWithPath(path, type) { + if (!path) return null; + path = normalize(path); + var items = this.paths.get(path); + if (items) { + if (!type) return items[0]; + for (var i = 0, l = items.length; i < l; i++) { + var assetInfo = items[i]; + if (js.isChildClassOf(assetInfo.ctor, type)) return assetInfo; + } + } + return null; + }, + getDirWithPath: function getDirWithPath(path, type, out) { + path = normalize(path); + "/" === path[path.length - 1] && (path = path.slice(0, -1)); + var infos = out || []; + function isMatchByWord(path, test) { + if (path.length > test.length) { + var nextAscii = path.charCodeAt(test.length); + return 47 === nextAscii; + } + return true; + } + this.paths.forEach((function(items, p) { + if (p.startsWith(path) && isMatchByWord(p, path) || !path) for (var i = 0, l = items.length; i < l; i++) { + var entry = items[i]; + type && !js.isChildClassOf(entry.ctor, type) || infos.push(entry); + } + })); + return infos; + }, + getAssetInfo: function getAssetInfo(uuid) { + return this.assetInfos.get(uuid); + }, + getSceneInfo: function getSceneInfo(name) { + name.endsWith(".fire") || (name += ".fire"); + "/" === name[0] || name.startsWith("db://") || (name = "/" + name); + var info = this.scenes.find((function(val, key) { + return key.endsWith(name); + })); + return info; + }, + destroy: function destroy() { + this.paths.destroy(); + this.scenes.destroy(); + this.assetInfos.destroy(); + } + }; + false; + module.exports = Config; + }), { + "../platform/js": 261, + "./cache": 80, + "./helper": 93, + "./utilities": 105 + } ], + 82: [ (function(require, module, exports) { + "use strict"; + var _deserializeCompiled = _interopRequireWildcard(require("../platform/deserialize-compiled")); + function _getRequireWildcardCache(nodeInterop) { + if ("function" !== typeof WeakMap) return null; + var cacheBabelInterop = new WeakMap(); + var cacheNodeInterop = new WeakMap(); + return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { + return nodeInterop ? cacheNodeInterop : cacheBabelInterop; + })(nodeInterop); + } + function _interopRequireWildcard(obj, nodeInterop) { + if (!nodeInterop && obj && obj.__esModule) return obj; + if (null === obj || "object" !== typeof obj && "function" !== typeof obj) return { + default: obj + }; + var cache = _getRequireWildcardCache(nodeInterop); + if (cache && cache.has(obj)) return cache.get(obj); + var newObj = {}; + var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; + for (var key in obj) if ("default" !== key && Object.prototype.hasOwnProperty.call(obj, key)) { + var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; + desc && (desc.get || desc.set) ? Object.defineProperty(newObj, key, desc) : newObj[key] = obj[key]; + } + newObj["default"] = obj; + cache && cache.set(obj, newObj); + return newObj; + } + var Cache = require("./cache"); + var deserialize = require("./deserialize"); + var _require = require("./shared"), files = _require.files, parsed = _require.parsed; + var dependUtil = { + _depends: new Cache(), + init: function init() { + this._depends.clear(); + }, + getNativeDep: function getNativeDep(uuid) { + var depend = this._depends.get(uuid); + if (depend) return depend.nativeDep && Object.assign({}, depend.nativeDep); + return null; + }, + getDeps: function getDeps(uuid) { + if (this._depends.has(uuid)) return this._depends.get(uuid).deps; + return []; + }, + getDepsRecursively: function getDepsRecursively(uuid) { + var exclude = Object.create(null), depends = []; + this._descend(uuid, exclude, depends); + return depends; + }, + _descend: function _descend(uuid, exclude, depends) { + var deps = this.getDeps(uuid); + for (var i = 0; i < deps.length; i++) { + var depend = deps[i]; + if (!exclude[depend]) { + exclude[depend] = true; + depends.push(depend); + this._descend(depend, exclude, depends); + } + } + }, + remove: function remove(uuid) { + this._depends.remove(uuid); + }, + parse: function parse(uuid, json) { + var out = null; + if (Array.isArray(json) || json.__type__) { + if (out = this._depends.get(uuid)) return out; + if (Array.isArray(json) && (false, !(0, _deserializeCompiled.hasNativeDep)(json))) out = { + deps: this._parseDepsFromJson(json) + }; else try { + var asset = deserialize(json); + out = this._parseDepsFromAsset(asset); + out.nativeDep && (out.nativeDep.uuid = uuid); + parsed.add(uuid + "@import", asset); + } catch (e) { + files.remove(uuid + "@import"); + out = { + deps: [] + }; + } + } else { + if ((true, out = this._depends.get(uuid)) && out.parsedFromExistAsset) return out; + out = this._parseDepsFromAsset(json); + } + this._depends.add(uuid, out); + return out; + }, + _parseDepsFromAsset: function _parseDepsFromAsset(asset) { + var out = { + deps: [], + parsedFromExistAsset: true, + preventPreloadNativeObject: asset.constructor.preventPreloadNativeObject, + preventDeferredLoadDependents: asset.constructor.preventDeferredLoadDependents + }; + var deps = asset.__depends__; + for (var i = 0, l = deps.length; i < l; i++) { + var dep = deps[i].uuid; + out.deps.push(dep); + } + asset.__nativeDepend__ && (out.nativeDep = asset._nativeDep); + return out; + }, + _parseDepsFromJson: (false, function(json) { + var depends = (0, _deserializeCompiled.getDependUuidList)(json); + depends.forEach((function(uuid, index) { + return depends[index] = cc.assetManager.utils.decodeUuid(uuid); + })); + return depends; + }) + }; + module.exports = dependUtil; + }), { + "../platform/deserialize-compiled": 255, + "./cache": 80, + "./deserialize": 84, + "./shared": 102 + } ], + 83: [ (function(require, module, exports) { + "use strict"; + var js = require("../platform/js"); + require("../CCDirector"); + var utilities = require("./utilities"); + var dependUtil = require("./depend-util"); + var releaseManager = require("./releaseManager"); + var downloader = require("./downloader"); + var factory = require("./factory"); + var helper = require("./helper"); + var ImageFmts = [ ".png", ".jpg", ".bmp", ".jpeg", ".gif", ".ico", ".tiff", ".webp", ".image", ".pvr", ".pkm" ]; + var AudioFmts = [ ".mp3", ".ogg", ".wav", ".m4a" ]; + function GetTrue() { + return true; + } + var md5Pipe = { + transformURL: function transformURL(url) { + var uuid = helper.getUuidFromURL(url); + if (!uuid) return url; + var bundle = cc.assetManager.bundles.find((function(b) { + return !!b.getAssetInfo(uuid); + })); + if (!bundle) return url; + var hashValue = ""; + var info = bundle.getAssetInfo(uuid); + hashValue = url.startsWith(bundle.base + bundle._config.nativeBase) ? info.nativeVer || "" : info.ver || ""; + if (!hashValue || -1 !== url.indexOf(hashValue)) return url; + var hashPatchInFolder = false; + ".ttf" === cc.path.extname(url) && (hashPatchInFolder = true); + if (hashPatchInFolder) { + var dirname = cc.path.dirname(url); + var basename = cc.path.basename(url); + url = dirname + "." + hashValue + "/" + basename; + } else url = url.replace(/.*[/\\][0-9a-fA-F]{2}[/\\]([0-9a-fA-F-]{8,})/, (function(match, uuid) { + return match + "." + hashValue; + })); + return url; + } + }; + var loader = { + onProgress: null, + _autoReleaseSetting: Object.create(null), + get _cache() { + return cc.assetManager.assets._map; + }, + load: function load(resources, progressCallback, completeCallback) { + if (void 0 === completeCallback && void 0 !== progressCallback) { + completeCallback = progressCallback; + progressCallback = null; + } + resources = Array.isArray(resources) ? resources : [ resources ]; + for (var i = 0; i < resources.length; i++) { + var item = resources[i]; + if ("string" === typeof item) resources[i] = { + url: item, + __isNative__: true + }; else { + if (item.type) { + item.ext = "." + item.type; + item.type = void 0; + } + item.url && (item.__isNative__ = true); + } + } + var images = []; + var audios = []; + cc.assetManager.loadAny(resources, null, (function(finish, total, item) { + item.content && (ImageFmts.includes(item.ext) ? images.push(item.content) : AudioFmts.includes(item.ext) && audios.push(item.content)); + progressCallback && progressCallback(finish, total, item); + }), (function(err, _native) { + var res = null; + if (!err) { + _native = Array.isArray(_native) ? _native : [ _native ]; + for (var i = 0; i < _native.length; i++) { + var item = _native[i]; + if (!(item instanceof cc.Asset)) { + var asset = item; + var url = resources[i].url; + images.includes(asset) ? factory.create(url, item, ".png", null, (function(err, image) { + asset = _native[i] = image; + })) : audios.includes(asset) && factory.create(url, item, ".mp3", null, (function(err, audio) { + asset = _native[i] = audio; + })); + cc.assetManager.assets.add(url, asset); + } + } + if (_native.length > 1) { + var map = Object.create(null); + _native.forEach((function(asset) { + map[asset._uuid] = asset; + })); + res = { + isCompleted: GetTrue, + _map: map + }; + } else res = _native[0]; + } + completeCallback && completeCallback(err, res); + })); + }, + getXMLHttpRequest: function getXMLHttpRequest() { + return new XMLHttpRequest(); + }, + _parseLoadResArgs: utilities.parseLoadResArgs, + getItem: function getItem(key) { + return cc.assetManager.assets.has(key) ? { + content: cc.assetManager.assets.get(key) + } : null; + }, + loadRes: function loadRes(url, type, progressCallback, completeCallback) { + var _this$_parseLoadResAr = this._parseLoadResArgs(type, progressCallback, completeCallback), type = _this$_parseLoadResAr.type, onProgress = _this$_parseLoadResAr.onProgress, onComplete = _this$_parseLoadResAr.onComplete; + var extname = cc.path.extname(url); + extname && (url = url.slice(0, -extname.length)); + cc.resources.load(url, type, onProgress, onComplete); + }, + loadResArray: function loadResArray(urls, type, progressCallback, completeCallback) { + var _this$_parseLoadResAr2 = this._parseLoadResArgs(type, progressCallback, completeCallback), type = _this$_parseLoadResAr2.type, onProgress = _this$_parseLoadResAr2.onProgress, onComplete = _this$_parseLoadResAr2.onComplete; + urls.forEach((function(url, i) { + var extname = cc.path.extname(url); + extname && (urls[i] = url.slice(0, -extname.length)); + })); + cc.resources.load(urls, type, onProgress, onComplete); + }, + loadResDir: function loadResDir(url, type, progressCallback, completeCallback) { + var _this$_parseLoadResAr3 = this._parseLoadResArgs(type, progressCallback, completeCallback), type = _this$_parseLoadResAr3.type, onProgress = _this$_parseLoadResAr3.onProgress, onComplete = _this$_parseLoadResAr3.onComplete; + cc.resources.loadDir(url, type, onProgress, (function(err, assets) { + var urls = []; + if (!err) { + var infos = cc.resources.getDirWithPath(url, type); + urls = infos.map((function(info) { + return info.path; + })); + } + onComplete && onComplete(err, assets, urls); + })); + }, + getRes: function getRes(url, type) { + return cc.assetManager.assets.has(url) ? cc.assetManager.assets.get(url) : cc.resources.get(url, type); + }, + getResCount: function getResCount() { + return cc.assetManager.assets.count; + }, + getDependsRecursively: function getDependsRecursively(owner) { + if (!owner) return []; + return dependUtil.getDepsRecursively("string" === typeof owner ? owner : owner._uuid).concat([ owner._uuid ]); + }, + get assetLoader() { + true; + cc.error("cc.loader.assetLoader was removed, assetLoader and md5Pipe were merged into cc.assetManager.transformPipeline"); + }, + get md5Pipe() { + return md5Pipe; + }, + get downloader() { + return cc.assetManager.downloader; + }, + get loader() { + return cc.assetManager.parser; + }, + addDownloadHandlers: function addDownloadHandlers(extMap) { + true; + cc.warn("`cc.loader.addDownloadHandlers` is deprecated, please use `cc.assetManager.downloader.register` instead"); + var handler = Object.create(null); + for (var type in extMap) { + var func = extMap[type]; + handler["." + type] = function(url, options, onComplete) { + func({ + url: url + }, onComplete); + }; + } + cc.assetManager.downloader.register(handler); + }, + addLoadHandlers: function addLoadHandlers(extMap) { + true; + cc.warn("`cc.loader.addLoadHandlers` is deprecated, please use `cc.assetManager.parser.register` instead"); + var handler = Object.create(null); + for (var type in extMap) { + var func = extMap[type]; + handler["." + type] = function(file, options, onComplete) { + func({ + content: file + }, onComplete); + }; + } + cc.assetManager.parser.register(handler); + }, + flowInDeps: function flowInDeps() { + true; + cc.error("cc.loader.flowInDeps was removed"); + }, + release: function release(asset) { + if (Array.isArray(asset)) for (var i = 0; i < asset.length; i++) { + var key = asset[i]; + "string" === typeof key && (key = cc.assetManager.assets.get(key)); + var isBuiltin = cc.assetManager.builtins._assets.find((function(assets) { + return assets.find((function(builtinAsset) { + return builtinAsset === key; + })); + })); + if (isBuiltin) continue; + cc.assetManager.releaseAsset(key); + } else if (asset) { + "string" === typeof asset && (asset = cc.assetManager.assets.get(asset)); + var _isBuiltin = cc.assetManager.builtins._assets.find((function(assets) { + return assets.find((function(builtinAsset) { + return builtinAsset === asset; + })); + })); + if (_isBuiltin) return; + cc.assetManager.releaseAsset(asset); + } + }, + releaseAsset: function releaseAsset(asset) { + cc.assetManager.releaseAsset(asset); + }, + releaseRes: function releaseRes(url, type) { + cc.resources.release(url, type); + }, + releaseResDir: function releaseResDir() { + true; + cc.error("cc.loader.releaseResDir was removed, please use cc.assetManager.releaseAsset instead"); + }, + releaseAll: function releaseAll() { + cc.assetManager.releaseAll(); + cc.assetManager.assets.clear(); + }, + removeItem: function removeItem(key) { + cc.assetManager.assets.remove(key); + }, + setAutoRelease: function setAutoRelease(asset, autoRelease) { + "object" === typeof asset && (asset = asset._uuid); + this._autoReleaseSetting[asset] = !!autoRelease; + }, + setAutoReleaseRecursively: function setAutoReleaseRecursively(asset, autoRelease) { + "object" === typeof asset && (asset = asset._uuid); + autoRelease = !!autoRelease; + this._autoReleaseSetting[asset] = autoRelease; + var depends = dependUtil.getDepsRecursively(asset); + for (var i = 0; i < depends.length; i++) { + var depend = depends[i]; + this._autoReleaseSetting[depend] = autoRelease; + } + }, + isAutoRelease: function isAutoRelease(asset) { + "object" === typeof asset && (asset = asset._uuid); + return !!this._autoReleaseSetting[asset]; + } + }; + downloader.loadSubpackage = function(name, completeCallback) { + cc.assetManager.loadBundle(name, null, completeCallback); + }; + var AssetLibrary = { + init: function init(options) { + options.importBase = options.libraryPath; + options.nativeBase = options.rawAssetsBase; + cc.assetManager.init(options); + if (options.rawAssets) { + var resources = new cc.AssetManager.Bundle(); + resources.init({ + name: cc.AssetManager.BuiltinBundleName.RESOURCES, + importBase: options.importBase, + nativeBase: options.nativeBase, + paths: options.rawAssets.assets, + uuids: Object.keys(options.rawAssets.assets) + }); + } + }, + loadAsset: function loadAsset(uuid, onComplete) { + cc.assetManager.loadAny(uuid, onComplete); + }, + getLibUrlNoExt: function getLibUrlNoExt() { + true; + cc.error("cc.AssetLibrary.getLibUrlNoExt was removed, if you want to transform url, please use cc.assetManager.utils.getUrlWithUuid instead"); + }, + queryAssetInfo: function queryAssetInfo() { + true; + cc.error("cc.AssetLibrary.queryAssetInfo was removed, only available in the editor by using cc.assetManager.editorExtend.queryAssetInfo"); + } + }; + cc.url = { + normalize: function normalize(url) { + cc.warnID(1400, "cc.url.normalize", "cc.assetManager.utils.normalize"); + return cc.assetManager.utils.normalize(url); + }, + raw: function raw(url) { + cc.warnID(1400, "cc.url.raw", "cc.resources.load"); + if (url.startsWith("resources/")) return cc.assetManager._transform({ + path: cc.path.changeExtname(url.substr(10)), + bundle: cc.AssetManager.BuiltinBundleName.RESOURCES, + __isNative__: true, + ext: cc.path.extname(url) + }); + return ""; + } + }; + var onceWarns = { + loader: true, + assetLibrary: true + }; + Object.defineProperties(cc, { + loader: { + get: function get() { + true; + if (onceWarns.loader) { + onceWarns.loader = false; + cc.log("cc.loader is deprecated, use cc.assetManager instead please. See https://docs.cocos.com/creator/manual/zh/release-notes/asset-manager-upgrade-guide.html"); + } + return loader; + } + }, + AssetLibrary: { + get: function get() { + true; + if (onceWarns.assetLibrary) { + onceWarns.assetLibrary = false; + cc.log("cc.AssetLibrary is deprecated, use cc.assetManager instead please. See https://docs.cocos.com/creator/manual/zh/release-notes/asset-manager-upgrade-guide.html"); + } + return AssetLibrary; + } + }, + LoadingItems: { + get: function get() { + cc.warnID(1400, "cc.LoadingItems", "cc.AssetManager.Task"); + return cc.AssetManager.Task; + } + }, + Pipeline: { + get: function get() { + cc.warnID(1400, "cc.Pipeline", "cc.AssetManager.Pipeline"); + return cc.AssetManager.Pipeline; + } + } + }); + js.obsolete(cc, "cc.RawAsset", "cc.Asset"); + js.obsolete(cc.Asset.prototype, "cc.Asset.url", "nativeUrl"); + Object.defineProperties(cc.macro, { + DOWNLOAD_MAX_CONCURRENT: { + get: function get() { + return cc.assetManager.downloader.maxConcurrency; + }, + set: function set(val) { + cc.assetManager.downloader.maxConcurrency = val; + } + } + }); + Object.assign(cc.director, { + _getSceneUuid: function _getSceneUuid(sceneName) { + cc.assetManager.main.getSceneInfo(sceneName); + } + }); + Object.defineProperties(cc.game, { + _sceneInfos: { + get: function get() { + var scenes = []; + cc.assetManager.main._config.scenes.forEach((function(val) { + scenes.push(val); + })); + return scenes; + } + } + }); + var parseParameters = utilities.parseParameters; + utilities.parseParameters = function(options, onProgress, onComplete) { + var result = parseParameters(options, onProgress, onComplete); + result.onProgress = result.onProgress || loader.onProgress; + return result; + }; + var autoRelease = releaseManager._autoRelease; + releaseManager._autoRelease = function() { + autoRelease.apply(this, arguments); + var releaseSettings = loader._autoReleaseSetting; + var keys = Object.keys(releaseSettings); + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; + if (true === releaseSettings[key]) { + var asset = cc.assetManager.assets.get(key); + asset && releaseManager.tryRelease(asset); + } + } + }; + }), { + "../CCDirector": 71, + "../platform/js": 261, + "./depend-util": 82, + "./downloader": 89, + "./factory": 90, + "./helper": 93, + "./releaseManager": 100, + "./utilities": 105 + } ], + 84: [ (function(require, module, exports) { + "use strict"; + var helper = require("./helper"); + var MissingClass = false; + require("../platform/deserialize"); + function deserialize(json, options) { + var classFinder, missingClass; + false; + classFinder = cc._MissingScript.safeFindClass; + var pool = null; + var _require, deserializeForCompiled; + var deserializeForEditor; + true; + pool = cc.deserialize.Details.pool; + var tdInfo = pool.get(); + var asset; + try { + asset = cc.deserialize(json, tdInfo, { + classFinder: classFinder, + customEnv: options + }); + } catch (e) { + pool.put(tdInfo); + throw e; + } + false; + var uuidList = tdInfo.uuidList; + var objList = tdInfo.uuidObjList; + var propList = tdInfo.uuidPropList; + var depends = []; + for (var i = 0; i < uuidList.length; i++) { + var dependUuid = uuidList[i]; + depends[i] = { + uuid: helper.decodeUuid(dependUuid), + owner: objList[i], + prop: propList[i] + }; + } + asset.__depends__ = depends; + asset._native && (asset.__nativeDepend__ = true); + pool.put(tdInfo); + return asset; + } + module.exports = deserialize; + }), { + "../platform/deserialize": 256, + "../platform/deserialize-compiled": 255, + "../platform/deserialize-editor": void 0, + "./helper": 93 + } ], + 85: [ (function(require, module, exports) { + "use strict"; + var __audioSupport = cc.sys.__audioSupport; + var _require = require("./utilities"), parseParameters = _require.parseParameters; + function downloadDomAudio(url, options, onComplete) { + var _parseParameters = parseParameters(options, void 0, onComplete), options = _parseParameters.options, onComplete = _parseParameters.onComplete; + var dom = document.createElement("audio"); + dom.src = url; + var clearEvent = function clearEvent() { + clearTimeout(timer); + dom.removeEventListener("canplaythrough", success, false); + dom.removeEventListener("error", failure, false); + __audioSupport.USE_LOADER_EVENT && dom.removeEventListener(__audioSupport.USE_LOADER_EVENT, success, false); + }; + var timer = setTimeout((function() { + 0 === dom.readyState ? failure() : success(); + }), 8e3); + var success = function success() { + clearEvent(); + onComplete && onComplete(null, dom); + }; + var failure = function failure() { + clearEvent(); + var message = "load audio failure - " + url; + cc.log(message); + onComplete && onComplete(new Error(message)); + }; + dom.addEventListener("canplaythrough", success, false); + dom.addEventListener("error", failure, false); + __audioSupport.USE_LOADER_EVENT && dom.addEventListener(__audioSupport.USE_LOADER_EVENT, success, false); + return dom; + } + module.exports = downloadDomAudio; + }), { + "./utilities": 105 + } ], + 86: [ (function(require, module, exports) { + "use strict"; + var _require = require("./utilities"), parseParameters = _require.parseParameters; + function downloadDomImage(url, options, onComplete) { + var _parseParameters = parseParameters(options, void 0, onComplete), options = _parseParameters.options, onComplete = _parseParameters.onComplete; + var img = new Image(); + "file:" !== window.location.protocol && (img.crossOrigin = "anonymous"); + function loadCallback() { + img.removeEventListener("load", loadCallback); + img.removeEventListener("error", errorCallback); + onComplete && onComplete(null, img); + } + function errorCallback() { + img.removeEventListener("load", loadCallback); + img.removeEventListener("error", errorCallback); + onComplete && onComplete(new Error(cc.debug.getError(4930, url))); + } + img.addEventListener("load", loadCallback); + img.addEventListener("error", errorCallback); + img.src = url; + return img; + } + module.exports = downloadDomImage; + }), { + "./utilities": 105 + } ], + 87: [ (function(require, module, exports) { + "use strict"; + var _require = require("./utilities"), parseParameters = _require.parseParameters; + function downloadFile(url, options, onProgress, onComplete) { + var _parseParameters = parseParameters(options, onProgress, onComplete), options = _parseParameters.options, onProgress = _parseParameters.onProgress, onComplete = _parseParameters.onComplete; + var xhr = new XMLHttpRequest(), errInfo = "download failed: " + url + ", status: "; + xhr.open("GET", url, true); + void 0 !== options.responseType && (xhr.responseType = options.responseType); + void 0 !== options.withCredentials && (xhr.withCredentials = options.withCredentials); + void 0 !== options.mimeType && xhr.overrideMimeType && xhr.overrideMimeType(options.mimeType); + void 0 !== options.timeout && (xhr.timeout = options.timeout); + if (options.header) for (var header in options.header) xhr.setRequestHeader(header, options.header[header]); + xhr.onload = function() { + 200 === xhr.status || 0 === xhr.status ? onComplete && onComplete(null, xhr.response) : onComplete && onComplete(new Error(errInfo + xhr.status + "(no response)")); + }; + onProgress && (xhr.onprogress = function(e) { + e.lengthComputable && onProgress(e.loaded, e.total); + }); + xhr.onerror = function() { + onComplete && onComplete(new Error(errInfo + xhr.status + "(error)")); + }; + xhr.ontimeout = function() { + onComplete && onComplete(new Error(errInfo + xhr.status + "(time out)")); + }; + xhr.onabort = function() { + onComplete && onComplete(new Error(errInfo + xhr.status + "(abort)")); + }; + xhr.send(null); + return xhr; + } + module.exports = downloadFile; + }), { + "./utilities": 105 + } ], + 88: [ (function(require, module, exports) { + "use strict"; + var _require = require("./utilities"), parseParameters = _require.parseParameters; + var downloaded = {}; + function downloadScript(url, options, onComplete) { + var _parseParameters = parseParameters(options, void 0, onComplete), options = _parseParameters.options, onComplete = _parseParameters.onComplete; + if (downloaded[url]) return onComplete && onComplete(null); + var d = document, s = document.createElement("script"); + "file:" !== window.location.protocol && (s.crossOrigin = "anonymous"); + s.async = options.async; + s.src = url; + function loadHandler() { + s.parentNode.removeChild(s); + s.removeEventListener("load", loadHandler, false); + s.removeEventListener("error", errorHandler, false); + downloaded[url] = true; + onComplete && onComplete(null); + } + function errorHandler() { + s.parentNode.removeChild(s); + s.removeEventListener("load", loadHandler, false); + s.removeEventListener("error", errorHandler, false); + onComplete && onComplete(new Error(cc.debug.getError(4928, url))); + } + s.addEventListener("load", loadHandler, false); + s.addEventListener("error", errorHandler, false); + d.body.appendChild(s); + } + module.exports = downloadScript; + }), { + "./utilities": 105 + } ], + 89: [ (function(require, module, exports) { + "use strict"; + var js = require("../platform/js"); + var debug = require("../CCDebug"); + var _require = require("./font-loader"), loadFont = _require.loadFont; + var callInNextTick = require("../platform/utils").callInNextTick; + var downloadDomImage = require("./download-dom-image"); + var downloadDomAudio = require("./download-dom-audio"); + var downloadFile = require("./download-file"); + var downloadScript = require("./download-script.js"); + var Cache = require("./cache"); + var _require2 = require("./shared"), files = _require2.files; + var _require3 = require("../platform/CCSys"), __audioSupport = _require3.__audioSupport, capabilities = _require3.capabilities; + var _require4 = require("./utilities"), urlAppendTimestamp = _require4.urlAppendTimestamp, retry = _require4.retry; + var REGEX = /^(?:\w+:\/\/|\.+\/).+/; + var formatSupport = __audioSupport.format || []; + var unsupported = function unsupported(url, options, onComplete) { + onComplete(new Error(debug.getError(4927))); + }; + var downloadAudio = function downloadAudio(url, options, onComplete) { + options.audioLoadMode !== cc.AudioClip.LoadMode.DOM_AUDIO ? downloadArrayBuffer(url, options, onComplete) : downloadDomAudio(url, options, onComplete); + }; + var downloadAudio = 0 === formatSupport.length ? unsupported : __audioSupport.WEB_AUDIO ? downloadAudio : downloadDomAudio; + var downloadImage = function downloadImage(url, options, onComplete) { + var func = capabilities.imageBitmap && cc.macro.ALLOW_IMAGE_BITMAP ? downloadBlob : downloadDomImage; + func.apply(this, arguments); + }; + var downloadBlob = function downloadBlob(url, options, onComplete) { + options.responseType = "blob"; + downloadFile(url, options, options.onFileProgress, onComplete); + }; + var downloadJson = function downloadJson(url, options, onComplete) { + options.responseType = "json"; + downloadFile(url, options, options.onFileProgress, (function(err, data) { + if (!err && "string" === typeof data) try { + data = JSON.parse(data); + } catch (e) { + err = e; + } + onComplete && onComplete(err, data); + })); + }; + var downloadArrayBuffer = function downloadArrayBuffer(url, options, onComplete) { + options.responseType = "arraybuffer"; + downloadFile(url, options, options.onFileProgress, onComplete); + }; + var downloadText = function downloadText(url, options, onComplete) { + options.responseType = "text"; + downloadFile(url, options, options.onFileProgress, onComplete); + }; + var downloadVideo = function downloadVideo(url, options, onComplete) { + onComplete(null, url); + }; + var downloadBundle = function downloadBundle(nameOrUrl, options, onComplete) { + var bundleName = cc.path.basename(nameOrUrl); + var url = nameOrUrl; + REGEX.test(url) || (url = "assets/" + bundleName); + var version = options.version || downloader.bundleVers[bundleName]; + var count = 0; + var config = url + "/config." + (version ? version + "." : "") + "json"; + var out = null, error = null; + downloadJson(config, options, (function(err, response) { + err && (error = err); + out = response; + out && (out.base = url + "/"); + count++; + 2 === count && onComplete(error, out); + })); + var js = url + "/index." + (version ? version + "." : "") + "js"; + downloadScript(js, options, (function(err) { + err && (error = err); + count++; + 2 === count && onComplete(error, out); + })); + }; + var _downloading = new Cache(); + var _queue = []; + var _queueDirty = false; + var _totalNum = 0; + var _totalNumThisPeriod = 0; + var _lastDate = -1; + var _checkNextPeriod = false; + var updateTime = function updateTime() { + var now = Date.now(); + var interval = cc.director._deltaTime > downloader._maxInterval ? downloader._maxInterval : cc.director._deltaTime; + if (now - _lastDate > 1e3 * interval) { + _totalNumThisPeriod = 0; + _lastDate = now; + } + }; + var handleQueue = function handleQueue(maxConcurrency, maxRequestsPerFrame) { + _checkNextPeriod = false; + updateTime(); + while (_queue.length > 0 && _totalNum < maxConcurrency && _totalNumThisPeriod < maxRequestsPerFrame) { + if (_queueDirty) { + _queue.sort((function(a, b) { + return a.priority - b.priority; + })); + _queueDirty = false; + } + var nextOne = _queue.pop(); + if (!nextOne) break; + _totalNum++; + _totalNumThisPeriod++; + nextOne.invoke(); + } + if (_queue.length > 0 && _totalNum < maxConcurrency) { + callInNextTick(handleQueue, maxConcurrency, maxRequestsPerFrame); + _checkNextPeriod = true; + } + }; + var downloader = { + _remoteServerAddress: "", + _maxInterval: 1 / 30, + get remoteServerAddress() { + return this._remoteServerAddress; + }, + maxConcurrency: 6, + maxRequestsPerFrame: 6, + maxRetryCount: 3, + appendTimeStamp: false, + limited: true, + retryInterval: 2e3, + bundleVers: null, + downloadDomImage: downloadDomImage, + downloadDomAudio: downloadDomAudio, + downloadFile: downloadFile, + downloadScript: downloadScript, + init: function init(bundleVers, remoteServerAddress) { + _downloading.clear(); + _queue.length = 0; + this._remoteServerAddress = remoteServerAddress || ""; + this.bundleVers = bundleVers || Object.create(null); + }, + register: function register(type, handler) { + "object" === typeof type ? js.mixin(downloaders, type) : downloaders[type] = handler; + }, + download: function download(id, url, type, options, onComplete) { + var func = downloaders[type] || downloaders["default"]; + var self = this; + var file, downloadCallbacks; + if (file = files.get(id)) onComplete(null, file); else if (downloadCallbacks = _downloading.get(id)) { + downloadCallbacks.push(onComplete); + for (var i = 0, l = _queue.length; i < l; i++) { + var item = _queue[i]; + if (item.id === id) { + var priority = options.priority || 0; + if (item.priority < priority) { + item.priority = priority; + _queueDirty = true; + } + return; + } + } + } else { + var process = function process(index, callback) { + 0 === index && _downloading.add(id, [ onComplete ]); + if (!self.limited) return func(urlAppendTimestamp(url), options, callback); + updateTime(); + function invoke() { + func(urlAppendTimestamp(url), options, (function() { + _totalNum--; + if (!_checkNextPeriod && _queue.length > 0) { + callInNextTick(handleQueue, maxConcurrency, maxRequestsPerFrame); + _checkNextPeriod = true; + } + callback.apply(this, arguments); + })); + } + if (_totalNum < maxConcurrency && _totalNumThisPeriod < maxRequestsPerFrame) { + invoke(); + _totalNum++; + _totalNumThisPeriod++; + } else { + _queue.push({ + id: id, + priority: options.priority || 0, + invoke: invoke + }); + _queueDirty = true; + if (!_checkNextPeriod && _totalNum < maxConcurrency) { + callInNextTick(handleQueue, maxConcurrency, maxRequestsPerFrame); + _checkNextPeriod = true; + } + } + }; + var finale = function finale(err, result) { + err || files.add(id, result); + var callbacks = _downloading.remove(id); + for (var _i = 0, _l = callbacks.length; _i < _l; _i++) callbacks[_i](err, result); + }; + var maxRetryCount = "undefined" !== typeof options.maxRetryCount ? options.maxRetryCount : this.maxRetryCount; + var maxConcurrency = "undefined" !== typeof options.maxConcurrency ? options.maxConcurrency : this.maxConcurrency; + var maxRequestsPerFrame = "undefined" !== typeof options.maxRequestsPerFrame ? options.maxRequestsPerFrame : this.maxRequestsPerFrame; + retry(process, maxRetryCount, this.retryInterval, finale); + } + } + }; + var downloaders = { + ".png": downloadImage, + ".jpg": downloadImage, + ".bmp": downloadImage, + ".jpeg": downloadImage, + ".gif": downloadImage, + ".ico": downloadImage, + ".tiff": downloadImage, + ".webp": downloadImage, + ".image": downloadImage, + ".pvr": downloadArrayBuffer, + ".pkm": downloadArrayBuffer, + ".mp3": downloadAudio, + ".ogg": downloadAudio, + ".wav": downloadAudio, + ".m4a": downloadAudio, + ".txt": downloadText, + ".xml": downloadText, + ".vsh": downloadText, + ".fsh": downloadText, + ".atlas": downloadText, + ".tmx": downloadText, + ".tsx": downloadText, + ".json": downloadJson, + ".ExportJson": downloadJson, + ".plist": downloadText, + ".fnt": downloadText, + ".font": loadFont, + ".eot": loadFont, + ".ttf": loadFont, + ".woff": loadFont, + ".svg": loadFont, + ".ttc": loadFont, + ".mp4": downloadVideo, + ".avi": downloadVideo, + ".mov": downloadVideo, + ".mpg": downloadVideo, + ".mpeg": downloadVideo, + ".rm": downloadVideo, + ".rmvb": downloadVideo, + ".binary": downloadArrayBuffer, + ".bin": downloadArrayBuffer, + ".dbbin": downloadArrayBuffer, + ".skel": downloadArrayBuffer, + ".js": downloadScript, + bundle: downloadBundle, + default: downloadText + }; + downloader._downloaders = downloaders; + module.exports = downloader; + }), { + "../CCDebug": 70, + "../platform/CCSys": 249, + "../platform/js": 261, + "../platform/utils": 264, + "./cache": 80, + "./download-dom-audio": 85, + "./download-dom-image": 86, + "./download-file": 87, + "./download-script.js": 88, + "./font-loader": 92, + "./shared": 102, + "./utilities": 105 + } ], + 90: [ (function(require, module, exports) { + "use strict"; + var Bundle = require("./bundle"); + var Cache = require("./cache"); + var _require = require("./shared"), assets = _require.assets, bundles = _require.bundles; + var _creating = new Cache(); + function createTexture(id, data, options, onComplete) { + var out = null, err = null; + try { + out = new cc.Texture2D(); + out._nativeUrl = id; + out._nativeAsset = data; + } catch (e) { + err = e; + } + onComplete && onComplete(err, out); + } + function createAudioClip(id, data, options, onComplete) { + var out = new cc.AudioClip(); + out._nativeUrl = id; + out._nativeAsset = data; + out.duration = data.duration; + onComplete && onComplete(null, out); + } + function createVideoClip(id, data, options, onComplete) { + var out = new cc.VideoClip(); + out._nativeUrl = id; + out._nativeAsset = data; + onComplete && onComplete(null, out); + } + function createJsonAsset(id, data, options, onComplete) { + var out = new cc.JsonAsset(); + out.json = data; + onComplete && onComplete(null, out); + } + function createTextAsset(id, data, options, onComplete) { + var out = new cc.TextAsset(); + out.text = data; + onComplete && onComplete(null, out); + } + function createFont(id, data, options, onComplete) { + var out = new cc.TTFFont(); + out._nativeUrl = id; + out._nativeAsset = data; + onComplete && onComplete(null, out); + } + function createBufferAsset(id, data, options, onComplete) { + var out = new cc.BufferAsset(); + out._nativeUrl = id; + out._nativeAsset = data; + onComplete && onComplete(null, out); + } + function createAsset(id, data, options, onComplete) { + var out = new cc.Asset(); + out._nativeUrl = id; + out._nativeAsset = data; + onComplete && onComplete(null, out); + } + function createBundle(id, data, options, onComplete) { + var bundle = bundles.get(data.name); + if (!bundle) { + bundle = new Bundle(); + data.base = data.base || id + "/"; + bundle.init(data); + } + onComplete && onComplete(null, bundle); + } + var factory = { + register: function register(type, handler) { + "object" === typeof type ? cc.js.mixin(producers, type) : producers[type] = handler; + }, + create: function create(id, data, type, options, onComplete) { + var func = producers[type] || producers["default"]; + var asset, creating; + if (asset = assets.get(id)) onComplete(null, asset); else if (creating = _creating.get(id)) creating.push(onComplete); else { + _creating.add(id, [ onComplete ]); + func(id, data, options, (function(err, data) { + if (!err && data instanceof cc.Asset) { + data._uuid = id; + assets.add(id, data); + } + var callbacks = _creating.remove(id); + for (var i = 0, l = callbacks.length; i < l; i++) callbacks[i](err, data); + })); + } + } + }; + var producers = { + ".png": createTexture, + ".jpg": createTexture, + ".bmp": createTexture, + ".jpeg": createTexture, + ".gif": createTexture, + ".ico": createTexture, + ".tiff": createTexture, + ".webp": createTexture, + ".image": createTexture, + ".pvr": createTexture, + ".pkm": createTexture, + ".mp3": createAudioClip, + ".ogg": createAudioClip, + ".wav": createAudioClip, + ".m4a": createAudioClip, + ".mp4": createVideoClip, + ".avi": createVideoClip, + ".mov": createVideoClip, + ".mpg": createVideoClip, + ".mpeg": createVideoClip, + ".rm": createVideoClip, + ".rmvb": createVideoClip, + ".txt": createTextAsset, + ".xml": createTextAsset, + ".vsh": createTextAsset, + ".fsh": createTextAsset, + ".atlas": createTextAsset, + ".tmx": createTextAsset, + ".tsx": createTextAsset, + ".fnt": createTextAsset, + ".json": createJsonAsset, + ".ExportJson": createJsonAsset, + ".font": createFont, + ".eot": createFont, + ".ttf": createFont, + ".woff": createFont, + ".svg": createFont, + ".ttc": createFont, + ".binary": createBufferAsset, + ".bin": createBufferAsset, + ".dbbin": createBufferAsset, + ".skel": createBufferAsset, + bundle: createBundle, + default: createAsset + }; + module.exports = factory; + }), { + "./bundle": 79, + "./cache": 80, + "./shared": 102 + } ], + 91: [ (function(require, module, exports) { + "use strict"; + var packManager = require("./pack-manager"); + var Task = require("./task"); + var _require = require("./utilities"), getDepends = _require.getDepends, clear = _require.clear, forEach = _require.forEach; + var _require2 = require("./shared"), assets = _require2.assets, fetchPipeline = _require2.fetchPipeline; + function fetch(task, done) { + var firstTask = false; + if (!task.progress) { + task.progress = { + finish: 0, + total: task.input.length, + canInvoke: true + }; + firstTask = true; + } + var options = task.options, depends = [], progress = task.progress, total = progress.total; + options.__exclude__ = options.__exclude__ || Object.create(null); + task.output = []; + forEach(task.input, (function(item, cb) { + if (!item.isNative && assets.has(item.uuid)) { + var asset = assets.get(item.uuid); + asset.addRef(); + handle(item, task, asset, null, asset.__asyncLoadAssets__, depends, total, done); + return cb(); + } + packManager.load(item, task.options, (function(err, data) { + if (err) { + if (!task.isFinish) if (!cc.assetManager.force || firstTask) { + cc.error(err.message, err.stack); + progress.canInvoke = false; + done(err); + } else handle(item, task, null, null, false, depends, total, done); + } else task.isFinish || handle(item, task, null, data, !item.isNative, depends, total, done); + cb(); + })); + }), (function() { + if (task.isFinish) { + clear(task, true); + return task.dispatch("error"); + } + if (depends.length > 0) { + var subTask = Task.create({ + name: task.name + " dependencies", + input: depends, + progress: progress, + options: options, + onProgress: task.onProgress, + onError: Task.prototype.recycle, + onComplete: function onComplete(err) { + if (!err) { + task.output.push.apply(task.output, this.output); + subTask.recycle(); + } + firstTask && decreaseRef(task); + done(err); + } + }); + fetchPipeline.async(subTask); + return; + } + firstTask && decreaseRef(task); + done(); + })); + } + function decreaseRef(task) { + var output = task.output; + for (var i = 0, l = output.length; i < l; i++) output[i].content && output[i].content.decRef(false); + } + function handle(item, task, content, file, loadDepends, depends, last, done) { + var exclude = task.options.__exclude__; + var progress = task.progress; + item.content = content; + item.file = file; + task.output.push(item); + if (loadDepends) { + exclude[item.uuid] = true; + getDepends(item.uuid, file || content, exclude, depends, true, false, item.config); + progress.total = last + depends.length; + } + progress.canInvoke && task.dispatch("progress", ++progress.finish, progress.total, item); + } + module.exports = fetch; + }), { + "./pack-manager": 96, + "./shared": 102, + "./task": 103, + "./utilities": 105 + } ], + 92: [ (function(require, module, exports) { + "use strict"; + var textUtils = require("../utils/text-utils"); + var _canvasContext = null; + var _testString = "BES bswy:->@123\u4e01\u3041\u1101"; + var _fontFaces = Object.create(null); + var _intervalId = -1; + var _loadingFonts = []; + var _timeout = 3e3; + var useNativeCheck = (function() { + var nativeCheck = void 0; + return function() { + if (void 0 === nativeCheck) if (!window.FontFace) nativeCheck = false; else { + var match = /Gecko.*Firefox\/(\d+)/.exec(window.navigator.userAgent); + var safari10Match = /OS X.*Version\/10\..*Safari/.exec(window.navigator.userAgent) && /Apple/.exec(window.navigator.vendor); + nativeCheck = match ? parseInt(match[1], 10) > 42 : !safari10Match; + } + return nativeCheck; + }; + })(); + function _checkFontLoaded() { + var allFontsLoaded = true; + var now = Date.now(); + for (var i = _loadingFonts.length - 1; i >= 0; i--) { + var fontLoadHandle = _loadingFonts[i]; + var fontFamily = fontLoadHandle.fontFamilyName; + if (now - fontLoadHandle.startTime > _timeout) { + cc.warnID(4933, fontFamily); + fontLoadHandle.onComplete(null, fontFamily); + _loadingFonts.splice(i, 1); + continue; + } + var oldWidth = fontLoadHandle.refWidth; + var fontDesc = "40px " + fontFamily; + _canvasContext.font = fontDesc; + var newWidth = textUtils.safeMeasureText(_canvasContext, _testString, fontDesc); + if (oldWidth !== newWidth) { + _loadingFonts.splice(i, 1); + fontLoadHandle.onComplete(null, fontFamily); + } else allFontsLoaded = false; + } + if (allFontsLoaded) { + clearInterval(_intervalId); + _intervalId = -1; + } + } + function nativeCheckFontLoaded(start, font, callback) { + var loader = new Promise(function(resolve, reject) { + var check = function check() { + var now = Date.now(); + now - start >= _timeout ? reject() : document.fonts.load("40px " + font).then((function(fonts) { + fonts.length >= 1 ? resolve() : setTimeout(check, 100); + }), (function() { + reject(); + })); + }; + check(); + }); + var timeoutId = null, timer = new Promise(function(resolve, reject) { + timeoutId = setTimeout(reject, _timeout); + }); + Promise.race([ timer, loader ]).then((function() { + if (timeoutId) { + clearTimeout(timeoutId); + timeoutId = null; + } + callback(null, font); + }), (function() { + cc.warnID(4933, font); + callback(null, font); + })); + } + var fontLoader = { + loadFont: function loadFont(url, options, onComplete) { + var fontFamilyName = fontLoader._getFontFamily(url); + if (_fontFaces[fontFamilyName]) return onComplete(null, fontFamilyName); + if (!_canvasContext) { + var labelCanvas = document.createElement("canvas"); + labelCanvas.width = 100; + labelCanvas.height = 100; + _canvasContext = labelCanvas.getContext("2d"); + } + var fontDesc = "40px " + fontFamilyName; + _canvasContext.font = fontDesc; + var refWidth = textUtils.safeMeasureText(_canvasContext, _testString, fontDesc); + var fontStyle = document.createElement("style"); + fontStyle.type = "text/css"; + var fontStr = ""; + isNaN(fontFamilyName - 0) ? fontStr += "@font-face { font-family:" + fontFamilyName + "; src:" : fontStr += "@font-face { font-family:'" + fontFamilyName + "'; src:"; + fontStr += "url('" + url + "');"; + fontStyle.textContent = fontStr + "}"; + document.body.appendChild(fontStyle); + var preloadDiv = document.createElement("div"); + var divStyle = preloadDiv.style; + divStyle.fontFamily = fontFamilyName; + preloadDiv.innerHTML = "."; + divStyle.position = "absolute"; + divStyle.left = "-100px"; + divStyle.top = "-100px"; + document.body.appendChild(preloadDiv); + if (useNativeCheck()) nativeCheckFontLoaded(Date.now(), fontFamilyName, onComplete); else { + var fontLoadHandle = { + fontFamilyName: fontFamilyName, + refWidth: refWidth, + onComplete: onComplete, + startTime: Date.now() + }; + _loadingFonts.push(fontLoadHandle); + -1 === _intervalId && (_intervalId = setInterval(_checkFontLoaded, 100)); + } + _fontFaces[fontFamilyName] = fontStyle; + }, + _getFontFamily: function _getFontFamily(fontHandle) { + var ttfIndex = fontHandle.lastIndexOf(".ttf"); + if (-1 === ttfIndex) return fontHandle; + var slashPos = fontHandle.lastIndexOf("/"); + var fontFamilyName; + fontFamilyName = -1 === slashPos ? fontHandle.substring(0, ttfIndex) + "_LABEL" : fontHandle.substring(slashPos + 1, ttfIndex) + "_LABEL"; + -1 !== fontFamilyName.indexOf(" ") && (fontFamilyName = '"' + fontFamilyName + '"'); + return fontFamilyName; + } + }; + module.exports = fontLoader; + }), { + "../utils/text-utils": 332 + } ], + 93: [ (function(require, module, exports) { + "use strict"; + var _require = require("./shared"), bundles = _require.bundles; + var helper = { + decodeUuid: require("../utils/decode-uuid"), + getUuidFromURL: (function() { + var _uuidRegex = /.*[/\\][0-9a-fA-F]{2}[/\\]([0-9a-fA-F-]{8,})/; + return function(url) { + var matches = url.match(_uuidRegex); + if (matches) return matches[1]; + return ""; + }; + })(), + getUrlWithUuid: function getUrlWithUuid(uuid, options) { + options = options || Object.create(null); + options.__isNative__ = options.isNative; + options.ext = options.nativeExt; + var bundle = bundles.find((function(bundle) { + return bundle.getAssetInfo(uuid); + })); + bundle && (options.bundle = bundle.name); + return cc.assetManager._transform(uuid, options); + }, + isScene: function isScene(asset) { + return asset && (asset.constructor === cc.SceneAsset || asset instanceof cc.Scene); + }, + normalize: function normalize(url) { + url && (46 === url.charCodeAt(0) && 47 === url.charCodeAt(1) ? url = url.slice(2) : 47 === url.charCodeAt(0) && (url = url.slice(1))); + return url; + } + }; + module.exports = helper; + }), { + "../utils/decode-uuid": 320, + "./shared": 102 + } ], + 94: [ (function(require, module, exports) { + "use strict"; + require("./deprecated"); + require("./CCAssetManager"); + }), { + "./CCAssetManager": 77, + "./deprecated": 83 + } ], + 95: [ (function(require, module, exports) { + "use strict"; + var packManager = require("./pack-manager"); + var Pipeline = require("./pipeline"); + var parser = require("./parser"); + var _require = require("./utilities"), getDepends = _require.getDepends, cache = _require.cache, gatherAsset = _require.gatherAsset, setProperties = _require.setProperties, forEach = _require.forEach, clear = _require.clear, checkCircleReference = _require.checkCircleReference; + var _require2 = require("./shared"), assets = _require2.assets, files = _require2.files, parsed = _require2.parsed, pipeline = _require2.pipeline; + var Task = require("./task"); + function load(task, done) { + var firstTask = false; + if (!task.progress) { + task.progress = { + finish: 0, + total: task.input.length, + canInvoke: true + }; + firstTask = true; + } + var options = task.options, progress = task.progress; + options.__exclude__ = options.__exclude__ || Object.create(null); + task.output = []; + forEach(task.input, (function(item, cb) { + var subTask = Task.create({ + input: item, + onProgress: task.onProgress, + options: options, + progress: progress, + onComplete: function onComplete(err, item) { + if (err && !task.isFinish) if (!cc.assetManager.force || firstTask) { + true; + cc.error(err.message, err.stack); + progress.canInvoke = false; + done(err); + } else progress.canInvoke && task.dispatch("progress", ++progress.finish, progress.total, item); + task.output.push(item); + subTask.recycle(); + cb(); + } + }); + loadOneAssetPipeline.async(subTask); + }), (function() { + options.__exclude__ = null; + if (task.isFinish) { + clear(task, true); + return task.dispatch("error"); + } + gatherAsset(task); + clear(task, true); + done(); + })); + } + var loadOneAssetPipeline = new Pipeline("loadOneAsset", [ function fetch(task, done) { + var item = task.output = task.input; + var options = item.options, isNative = item.isNative, uuid = item.uuid, file = item.file; + var reload = options.reload; + if (file || !reload && !isNative && assets.has(uuid)) return done(); + packManager.load(item, task.options, (function(err, data) { + item.file = data; + done(err); + })); + }, function parse(task, done) { + var item = task.output = task.input, progress = task.progress, exclude = task.options.__exclude__; + var id = item.id, file = item.file, options = item.options; + if (item.isNative) parser.parse(id, file, item.ext, options, (function(err, asset) { + if (err) return done(err); + item.content = asset; + progress.canInvoke && task.dispatch("progress", ++progress.finish, progress.total, item); + files.remove(id); + parsed.remove(id); + done(); + })); else { + var uuid = item.uuid; + if (uuid in exclude) { + var _exclude$uuid = exclude[uuid], finish = _exclude$uuid.finish, content = _exclude$uuid.content, err = _exclude$uuid.err, callbacks = _exclude$uuid.callbacks; + progress.canInvoke && task.dispatch("progress", ++progress.finish, progress.total, item); + if (finish || checkCircleReference(uuid, uuid, exclude)) { + content && content.addRef && content.addRef(); + item.content = content; + done(err); + } else callbacks.push({ + done: done, + item: item + }); + } else if (!options.reload && assets.has(uuid)) { + var asset = assets.get(uuid); + if (options.__asyncLoadAssets__ || !asset.__asyncLoadAssets__) { + item.content = asset.addRef(); + progress.canInvoke && task.dispatch("progress", ++progress.finish, progress.total, item); + done(); + } else loadDepends(task, asset, done, false); + } else parser.parse(id, file, "import", options, (function(err, asset) { + if (err) return done(err); + asset._uuid = uuid; + loadDepends(task, asset, done, true); + })); + } + } ]); + function loadDepends(task, asset, done, init) { + var item = task.input, progress = task.progress; + var uuid = item.uuid, id = item.id, options = item.options, config = item.config; + var __asyncLoadAssets__ = options.__asyncLoadAssets__, cacheAsset = options.cacheAsset; + var depends = []; + asset.addRef && asset.addRef(); + getDepends(uuid, asset, Object.create(null), depends, false, __asyncLoadAssets__, config); + progress.canInvoke && task.dispatch("progress", ++progress.finish, progress.total += depends.length, item); + var repeatItem = task.options.__exclude__[uuid] = { + content: asset, + finish: false, + callbacks: [ { + done: done, + item: item + } ] + }; + var subTask = Task.create({ + input: depends, + options: task.options, + onProgress: task.onProgress, + onError: Task.prototype.recycle, + progress: progress, + onComplete: function onComplete(err) { + asset.decRef && asset.decRef(false); + asset.__asyncLoadAssets__ = __asyncLoadAssets__; + repeatItem.finish = true; + repeatItem.err = err; + if (!err) { + var assets = Array.isArray(subTask.output) ? subTask.output : [ subTask.output ]; + var map = Object.create(null); + for (var _i = 0, _l = assets.length; _i < _l; _i++) { + var dependAsset = assets[_i]; + dependAsset && (map[dependAsset instanceof cc.Asset ? dependAsset._uuid + "@import" : uuid + "@native"] = dependAsset); + } + if (init) { + var missingAsset = setProperties(uuid, asset, map); + if (!missingAsset && !asset.__onLoadInvoked__) try { + asset.onLoad && asset.onLoad(); + asset.__onLoadInvoked__ = true; + } catch (e) { + cc.error(e.message, e.stack); + } + files.remove(id); + parsed.remove(id); + cache(uuid, asset, void 0 !== cacheAsset ? cacheAsset : cc.assetManager.cacheAsset); + } else if (asset.__nativeDepend__ && !asset._nativeAsset) { + var missingAsset = setProperties(uuid, asset, map); + if (!missingAsset && !asset.__onLoadInvoked__) try { + asset.onLoad && asset.onLoad(); + asset.__onLoadInvoked__ = true; + } catch (e) { + cc.error(e.message, e.stack); + } + } + subTask.recycle(); + } + var callbacks = repeatItem.callbacks; + for (var i = 0, l = callbacks.length; i < l; i++) { + var cb = callbacks[i]; + asset.addRef && asset.addRef(); + cb.item.content = asset; + cb.done(err); + } + callbacks.length = 0; + } + }); + pipeline.async(subTask); + } + module.exports = load; + }), { + "./pack-manager": 96, + "./parser": 97, + "./pipeline": 98, + "./shared": 102, + "./task": 103, + "./utilities": 105 + } ], + 96: [ (function(require, module, exports) { + "use strict"; + var _deserializeCompiled = require("../platform/deserialize-compiled"); + var downloader = require("./downloader"); + var Cache = require("./cache"); + var js = require("../platform/js"); + var _require = require("./shared"), files = _require.files; + var _loading = new Cache(); + function isLoading(val) { + return _loading.has(val.uuid); + } + var packManager = { + unpackJson: function unpackJson(pack, json, options, onComplete) { + var out = js.createMap(true), err = null; + if (Array.isArray(json)) { + json = (0, _deserializeCompiled.unpackJSONs)(json); + json.length !== pack.length && cc.errorID(4915); + for (var i = 0; i < pack.length; i++) { + var key = pack[i] + "@import"; + out[key] = json[i]; + } + } else { + var textureType = js._getClassId(cc.Texture2D); + if (json.type === textureType) { + if (json.data) { + var datas = json.data.split("|"); + datas.length !== pack.length && cc.errorID(4915); + for (var _i = 0; _i < pack.length; _i++) out[pack[_i] + "@import"] = (0, _deserializeCompiled.packCustomObjData)(textureType, datas[_i], true); + } + } else { + err = new Error("unmatched type pack!"); + out = null; + } + } + onComplete && onComplete(err, out); + }, + init: function init() { + _loading.clear(); + }, + register: function register(type, handler) { + "object" === typeof type ? js.mixin(unpackers, type) : unpackers[type] = handler; + }, + unpack: function unpack(pack, data, type, options, onComplete) { + if (!data) { + onComplete && onComplete(new Error("package data is wrong!")); + return; + } + var unpacker = unpackers[type]; + unpacker(pack, data, options, onComplete); + }, + load: function load(item, options, onComplete) { + if (item.isNative || !item.info || !item.info.packs) return downloader.download(item.id, item.url, item.ext, item.options, onComplete); + if (files.has(item.id)) return onComplete(null, files.get(item.id)); + var packs = item.info.packs; + var pack = packs.find(isLoading); + if (pack) return _loading.get(pack.uuid).push({ + onComplete: onComplete, + id: item.id + }); + pack = packs[0]; + _loading.add(pack.uuid, [ { + onComplete: onComplete, + id: item.id + } ]); + var url = cc.assetManager._transform(pack.uuid, { + ext: pack.ext, + bundle: item.config.name + }); + downloader.download(pack.uuid, url, pack.ext, item.options, (function(err, data) { + files.remove(pack.uuid); + err && cc.error(err.message, err.stack); + packManager.unpack(pack.packs, data, pack.ext, item.options, (function(err, result) { + if (err) err.message = "unpack " + url + " failed! details: " + err.message; else for (var id in result) files.add(id, result[id]); + var callbacks = _loading.remove(pack.uuid); + for (var i = 0, l = callbacks.length; i < l; i++) { + var cb = callbacks[i]; + if (err) { + cb.onComplete(err); + continue; + } + var data = result[cb.id]; + data ? cb.onComplete(null, data) : cb.onComplete(new Error("can not retrieve data from package")); + } + })); + })); + } + }; + var unpackers = { + ".json": packManager.unpackJson + }; + module.exports = packManager; + }), { + "../platform/deserialize-compiled": 255, + "../platform/js": 261, + "./cache": 80, + "./downloader": 89, + "./shared": 102 + } ], + 97: [ (function(require, module, exports) { + "use strict"; + var plistParser = require("../platform/CCSAXParser").plistParser; + var js = require("../platform/js"); + var deserialize = require("./deserialize"); + var Cache = require("./cache"); + var _require = require("./helper"), isScene = _require.isScene; + var _require2 = require("./shared"), parsed = _require2.parsed, files = _require2.files; + var _require3 = require("../platform/CCSys"), __audioSupport = _require3.__audioSupport, capabilities = _require3.capabilities; + var _parsing = new Cache(); + var parser = { + parseImage: function parseImage(file, options, onComplete) { + if (capabilities.imageBitmap && file instanceof Blob) { + var imageOptions = {}; + imageOptions.imageOrientation = options.__flipY__ ? "flipY" : "none"; + imageOptions.premultiplyAlpha = options.__premultiplyAlpha__ ? "premultiply" : "none"; + createImageBitmap(file, imageOptions).then((function(result) { + result.flipY = !!options.__flipY__; + result.premultiplyAlpha = !!options.__premultiplyAlpha__; + onComplete && onComplete(null, result); + }), (function(err) { + onComplete && onComplete(err, null); + })); + } else onComplete && onComplete(null, file); + }, + parseAudio: function parseAudio(file, options, onComplete) { + file instanceof ArrayBuffer ? __audioSupport.context.decodeAudioData(file, (function(buffer) { + onComplete && onComplete(null, buffer); + }), (function(e) { + onComplete && onComplete(e, null); + })) : onComplete && onComplete(null, file); + }, + parsePVRTex: (function() { + var PVR_HEADER_LENGTH = 13; + var PVR_MAGIC = 55727696; + var PVR_HEADER_MAGIC = 0; + var PVR_HEADER_FORMAT = 2; + var PVR_HEADER_HEIGHT = 6; + var PVR_HEADER_WIDTH = 7; + var PVR_HEADER_MIPMAPCOUNT = 11; + var PVR_HEADER_METADATA = 12; + return function(file, options, onComplete) { + var err = null, out = null; + try { + var buffer = file instanceof ArrayBuffer ? file : file.buffer; + var header = new Int32Array(buffer, 0, PVR_HEADER_LENGTH); + if (header[PVR_HEADER_MAGIC] != PVR_MAGIC) throw new Error("Invalid magic number in PVR header"); + var width = header[PVR_HEADER_WIDTH]; + var height = header[PVR_HEADER_HEIGHT]; + var dataOffset = header[PVR_HEADER_METADATA] + 52; + var pvrtcData = new Uint8Array(buffer, dataOffset); + out = { + _data: pvrtcData, + _compressed: true, + width: width, + height: height + }; + } catch (e) { + err = e; + } + onComplete && onComplete(err, out); + }; + })(), + parsePKMTex: (function() { + var ETC_PKM_HEADER_SIZE = 16; + var ETC_PKM_FORMAT_OFFSET = 6; + var ETC_PKM_ENCODED_WIDTH_OFFSET = 8; + var ETC_PKM_ENCODED_HEIGHT_OFFSET = 10; + var ETC_PKM_WIDTH_OFFSET = 12; + var ETC_PKM_HEIGHT_OFFSET = 14; + var ETC1_RGB_NO_MIPMAPS = 0; + var ETC2_RGB_NO_MIPMAPS = 1; + var ETC2_RGBA_NO_MIPMAPS = 3; + function readBEUint16(header, offset) { + return header[offset] << 8 | header[offset + 1]; + } + return function(file, options, onComplete) { + var err = null, out = null; + try { + var buffer = file instanceof ArrayBuffer ? file : file.buffer; + var header = new Uint8Array(buffer); + var format = readBEUint16(header, ETC_PKM_FORMAT_OFFSET); + if (format !== ETC1_RGB_NO_MIPMAPS && format !== ETC2_RGB_NO_MIPMAPS && format !== ETC2_RGBA_NO_MIPMAPS) return new Error("Invalid magic number in ETC header"); + var width = readBEUint16(header, ETC_PKM_WIDTH_OFFSET); + var height = readBEUint16(header, ETC_PKM_HEIGHT_OFFSET); + var encodedWidth = readBEUint16(header, ETC_PKM_ENCODED_WIDTH_OFFSET); + var encodedHeight = readBEUint16(header, ETC_PKM_ENCODED_HEIGHT_OFFSET); + var etcData = new Uint8Array(buffer, ETC_PKM_HEADER_SIZE); + out = { + _data: etcData, + _compressed: true, + width: width, + height: height + }; + } catch (e) { + err = e; + } + onComplete && onComplete(err, out); + }; + })(), + parsePlist: function parsePlist(file, options, onComplete) { + var err = null; + var result = plistParser.parse(file); + result || (err = new Error("parse failed")); + onComplete && onComplete(err, result); + }, + parseImport: function parseImport(file, options, onComplete) { + if (!file) return onComplete && onComplete(new Error("Json is empty")); + var result, err = null; + try { + result = deserialize(file, options); + } catch (e) { + err = e; + } + onComplete && onComplete(err, result); + }, + init: function init() { + _parsing.clear(); + }, + register: function register(type, handler) { + "object" === typeof type ? js.mixin(parsers, type) : parsers[type] = handler; + }, + parse: function parse(id, file, type, options, onComplete) { + var parsedAsset, parsing, parseHandler; + if (parsedAsset = parsed.get(id)) onComplete(null, parsedAsset); else if (parsing = _parsing.get(id)) parsing.push(onComplete); else if (parseHandler = parsers[type]) { + _parsing.add(id, [ onComplete ]); + parseHandler(file, options, (function(err, data) { + err ? files.remove(id) : isScene(data) || parsed.add(id, data); + var callbacks = _parsing.remove(id); + for (var i = 0, l = callbacks.length; i < l; i++) callbacks[i](err, data); + })); + } else onComplete(null, file); + } + }; + var parsers = { + ".png": parser.parseImage, + ".jpg": parser.parseImage, + ".bmp": parser.parseImage, + ".jpeg": parser.parseImage, + ".gif": parser.parseImage, + ".ico": parser.parseImage, + ".tiff": parser.parseImage, + ".webp": parser.parseImage, + ".image": parser.parseImage, + ".pvr": parser.parsePVRTex, + ".pkm": parser.parsePKMTex, + ".mp3": parser.parseAudio, + ".ogg": parser.parseAudio, + ".wav": parser.parseAudio, + ".m4a": parser.parseAudio, + ".plist": parser.parsePlist, + import: parser.parseImport + }; + module.exports = parser; + }), { + "../platform/CCSAXParser": 247, + "../platform/CCSys": 249, + "../platform/js": 261, + "./cache": 80, + "./deserialize": 84, + "./helper": 93, + "./shared": 102 + } ], + 98: [ (function(require, module, exports) { + "use strict"; + var Task = require("./task"); + var _pipelineId = 0; + function Pipeline(name, funcs) { + if (!Array.isArray(funcs)) { + cc.warn("funcs must be an array"); + return; + } + this.id = _pipelineId++; + this.name = name; + this.pipes = []; + for (var i = 0, l = funcs.length; i < l; i++) "function" === typeof funcs[i] && this.pipes.push(funcs[i]); + } + Pipeline.prototype = { + constructor: Pipeline, + insert: function insert(func, index) { + if ("function" !== typeof func || index > this.pipes.length) { + cc.warnID(4921); + return; + } + this.pipes.splice(index, 0, func); + return this; + }, + append: function append(func) { + if ("function" !== typeof func) return; + this.pipes.push(func); + return this; + }, + remove: function remove(index) { + if ("number" !== typeof index) return; + this.pipes.splice(index, 1); + return this; + }, + sync: function sync(task) { + var pipes = this.pipes; + if (!(task instanceof Task) || 0 === pipes.length) return; + if (null != task.output) { + task.input = task.output; + task.output = null; + } + task._isFinish = false; + for (var i = 0, l = pipes.length; i < l; ) { + var pipe = pipes[i]; + var result = pipe(task); + if (result) { + task._isFinish = true; + return result; + } + i++; + if (i !== l) { + task.input = task.output; + task.output = null; + } + } + task._isFinish = true; + return task.output; + }, + async: function async(task) { + var pipes = this.pipes; + if (!(task instanceof Task) || 0 === pipes.length) return; + if (null != task.output) { + task.input = task.output; + task.output = null; + } + task._isFinish = false; + this._flow(0, task); + }, + _flow: function _flow(index, task) { + var self = this; + var pipe = this.pipes[index]; + pipe(task, (function(result) { + if (result) { + task._isFinish = true; + task.onComplete && task.onComplete(result); + } else { + index++; + if (index < self.pipes.length) { + task.input = task.output; + task.output = null; + self._flow(index, task); + } else { + task._isFinish = true; + task.onComplete && task.onComplete(result, task.output); + } + } + })); + } + }; + module.exports = Pipeline; + }), { + "./task": 103 + } ], + 99: [ (function(require, module, exports) { + "use strict"; + var Task = require("./task"); + var _require = require("./shared"), transformPipeline = _require.transformPipeline, RequestType = _require.RequestType; + function preprocess(task, done) { + var options = task.options, subOptions = Object.create(null), leftOptions = Object.create(null); + for (var op in options) switch (op) { + case RequestType.PATH: + case RequestType.UUID: + case RequestType.DIR: + case RequestType.SCENE: + case RequestType.URL: + break; + + case "__requestType__": + case "__isNative__": + case "ext": + case "type": + case "__nativeName__": + case "audioLoadMode": + case "bundle": + subOptions[op] = options[op]; + break; + + case "__exclude__": + case "__outputAsArray__": + leftOptions[op] = options[op]; + break; + + default: + subOptions[op] = options[op]; + leftOptions[op] = options[op]; + } + task.options = leftOptions; + var subTask = Task.create({ + input: task.input, + options: subOptions + }); + var err = null; + try { + task.output = task.source = transformPipeline.sync(subTask); + } catch (e) { + err = e; + for (var i = 0, l = subTask.output.length; i < l; i++) subTask.output[i].recycle(); + } + subTask.recycle(); + done(err); + } + module.exports = preprocess; + }), { + "./shared": 102, + "./task": 103 + } ], + 100: [ (function(require, module, exports) { + "use strict"; + var dependUtil = require("./depend-util"); + var Cache = require("./cache"); + require("../assets/CCAsset"); + var _require = require("./shared"), assets = _require.assets; + var _require2 = require("../platform/utils"), callInNextTick = _require2.callInNextTick; + function visitAsset(asset, deps) { + if (!asset._uuid) return; + deps.push(asset._uuid); + } + function visitComponent(comp, deps) { + var props = Object.getOwnPropertyNames(comp); + for (var i = 0; i < props.length; i++) { + var propName = props[i]; + if ("node" === propName || "__eventTargets" === propName) continue; + var value = comp[propName]; + if ("object" === typeof value && value) if (Array.isArray(value)) for (var j = 0; j < value.length; j++) { + var val = value[j]; + val instanceof cc.Asset && visitAsset(val, deps); + } else if (value.constructor && value.constructor !== Object) value instanceof cc.Asset && visitAsset(value, deps); else { + var keys = Object.getOwnPropertyNames(value); + for (var _j = 0; _j < keys.length; _j++) { + var _val = value[keys[_j]]; + _val instanceof cc.Asset && visitAsset(_val, deps); + } + } + } + } + var _temp = []; + function visitNode(node, deps) { + for (var i = 0; i < node._components.length; i++) visitComponent(node._components[i], deps); + for (var _i = 0; _i < node._children.length; _i++) visitNode(node._children[_i], deps); + } + function descendOpRef(asset, refs, exclude, op) { + exclude.push(asset._uuid); + var depends = dependUtil.getDeps(asset._uuid); + for (var i = 0, l = depends.length; i < l; i++) { + var dependAsset = assets.get(depends[i]); + if (dependAsset) { + var uuid = dependAsset._uuid; + uuid in refs ? refs[uuid] += op : refs[uuid] = dependAsset.refCount + op; + if (exclude.includes(uuid)) continue; + descendOpRef(dependAsset, refs, exclude, op); + } + } + } + function checkCircularReference(asset) { + var refs = Object.create(null); + refs[asset._uuid] = asset.refCount; + descendOpRef(asset, refs, _temp, -1); + _temp.length = 0; + if (0 !== refs[asset._uuid]) return refs[asset._uuid]; + for (var uuid in refs) 0 !== refs[uuid] && descendOpRef(assets.get(uuid), refs, _temp, 1); + _temp.length = 0; + return refs[asset._uuid]; + } + var _persistNodeDeps = new Cache(); + var _toDelete = new Cache(); + var eventListener = false; + function freeAssets() { + eventListener = false; + _toDelete.forEach((function(asset) { + releaseManager._free(asset); + })); + _toDelete.clear(); + } + var releaseManager = { + init: function init() { + _persistNodeDeps.clear(); + _toDelete.clear(); + }, + _addPersistNodeRef: function _addPersistNodeRef(node) { + var deps = []; + visitNode(node, deps); + for (var i = 0, l = deps.length; i < l; i++) { + var dependAsset = assets.get(deps[i]); + dependAsset && dependAsset.addRef(); + } + _persistNodeDeps.add(node.uuid, deps); + }, + _removePersistNodeRef: function _removePersistNodeRef(node) { + if (_persistNodeDeps.has(node.uuid)) { + var deps = _persistNodeDeps.get(node.uuid); + for (var i = 0, l = deps.length; i < l; i++) { + var dependAsset = assets.get(deps[i]); + dependAsset && dependAsset.decRef(); + } + _persistNodeDeps.remove(node.uuid); + } + }, + _autoRelease: function _autoRelease(oldScene, newScene, persistNodes) { + if (oldScene) { + var childs = dependUtil.getDeps(oldScene._id); + for (var i = 0, l = childs.length; i < l; i++) { + var asset = assets.get(childs[i]); + asset && asset.decRef((false, oldScene.autoReleaseAssets)); + } + var dependencies = dependUtil._depends.get(oldScene._id); + if (dependencies && dependencies.persistDeps) { + var persistDeps = dependencies.persistDeps; + for (var _i2 = 0, _l = persistDeps.length; _i2 < _l; _i2++) { + var _asset = assets.get(persistDeps[_i2]); + _asset && _asset.decRef((false, oldScene.autoReleaseAssets)); + } + } + oldScene._id !== newScene._id && dependUtil.remove(oldScene._id); + } + var sceneDeps = dependUtil._depends.get(newScene._id); + sceneDeps && (sceneDeps.persistDeps = []); + for (var key in persistNodes) { + var node = persistNodes[key]; + var deps = _persistNodeDeps.get(node.uuid); + for (var _i3 = 0, _l2 = deps.length; _i3 < _l2; _i3++) { + var dependAsset = assets.get(deps[_i3]); + dependAsset && dependAsset.addRef(); + } + sceneDeps && sceneDeps.persistDeps.push.apply(sceneDeps.persistDeps, deps); + } + }, + _free: function _free(asset, force) { + _toDelete.remove(asset._uuid); + if (!cc.isValid(asset, true)) return; + if (!force && asset.refCount > 0 && checkCircularReference(asset) > 0) return; + assets.remove(asset._uuid); + var depends = dependUtil.getDeps(asset._uuid); + for (var i = 0, l = depends.length; i < l; i++) { + var dependAsset = assets.get(depends[i]); + if (dependAsset) { + dependAsset.decRef(false); + releaseManager._free(dependAsset, false); + } + } + asset.destroy(); + dependUtil.remove(asset._uuid); + }, + tryRelease: function tryRelease(asset, force) { + if (!(asset instanceof cc.Asset)) return; + if (force) releaseManager._free(asset, force); else { + _toDelete.add(asset._uuid, asset); + if (!eventListener) { + eventListener = true; + callInNextTick(freeAssets); + } + } + } + }; + module.exports = releaseManager; + }), { + "../assets/CCAsset": 106, + "../platform/utils": 264, + "./cache": 80, + "./depend-util": 82, + "./shared": 102 + } ], + 101: [ (function(require, module, exports) { + "use strict"; + var MAX_DEAD_NUM = 500; + var _deadPool = []; + function RequestItem() { + this._id = ""; + this.uuid = ""; + this.url = ""; + this.ext = ".json"; + this.content = null; + this.file = null; + this.info = null; + this.config = null; + this.isNative = false; + this.options = Object.create(null); + } + RequestItem.prototype = { + constructor: RequestItem, + get id() { + this._id || (this._id = this.uuid + "@" + (this.isNative ? "native" : "import")); + return this._id; + }, + recycle: function recycle() { + if (_deadPool.length === MAX_DEAD_NUM) return; + this._id = ""; + this.uuid = ""; + this.url = ""; + this.ext = ".json"; + this.content = null; + this.file = null; + this.info = null; + this.config = null; + this.isNative = false; + this.options = Object.create(null); + _deadPool.push(this); + } + }; + RequestItem.create = function() { + var out = null; + out = 0 !== _deadPool.length ? _deadPool.pop() : new RequestItem(); + return out; + }; + module.exports = RequestItem; + }), {} ], + 102: [ (function(require, module, exports) { + "use strict"; + var Cache = require("./cache"); + var Pipeline = require("./pipeline"); + var assets = new Cache(); + var files = new Cache(); + var parsed = new Cache(); + var bundles = new Cache(); + var pipeline = new Pipeline("normal load", []); + var fetchPipeline = new Pipeline("fetch", []); + var transformPipeline = new Pipeline("transform url", []); + var RequestType = { + UUID: "uuid", + PATH: "path", + DIR: "dir", + URL: "url", + SCENE: "scene" + }; + var BuiltinBundleName = { + RESOURCES: "resources", + INTERNAL: "internal", + MAIN: "main", + START_SCENE: "start-scene" + }; + module.exports = { + assets: assets, + files: files, + parsed: parsed, + pipeline: pipeline, + fetchPipeline: fetchPipeline, + transformPipeline: transformPipeline, + RequestType: RequestType, + bundles: bundles, + BuiltinBundleName: BuiltinBundleName + }; + }), { + "./cache": 80, + "./pipeline": 98 + } ], + 103: [ (function(require, module, exports) { + "use strict"; + var _taskId = 0; + var MAX_DEAD_NUM = 500; + var _deadPool = []; + function Task(options) { + this.id = _taskId++; + this._isFinish = true; + this.onComplete = null; + this.onProgress = null; + this.onError = null; + this.source = null; + this.output = null; + this.input = null; + this.progress = null; + this.options = null; + this.set(options); + } + Task.prototype = { + constructor: Task, + set: function set(options) { + options = options || Object.create(null); + this.onComplete = options.onComplete; + this.onProgress = options.onProgress; + this.onError = options.onError; + this.source = this.input = options.input; + this.output = null; + this.progress = options.progress; + this.options = options.options || Object.create(null); + }, + dispatch: function dispatch(event, param1, param2, param3, param4) { + switch (event) { + case "complete": + this.onComplete && this.onComplete(param1, param2, param3, param4); + break; + + case "progress": + this.onProgress && this.onProgress(param1, param2, param3, param4); + break; + + case "error": + this.onError && this.onError(param1, param2, param3, param4); + break; + + default: + var str = "on" + event[0].toUpperCase() + event.substr(1); + "function" === typeof this[str] && this[str](param1, param2, param3, param4); + } + }, + recycle: function recycle() { + if (_deadPool.length === MAX_DEAD_NUM) return; + this.onComplete = null; + this.onProgress = null; + this.onError = null; + this.source = this.output = this.input = null; + this.progress = null; + this.options = null; + _deadPool.push(this); + }, + get isFinish() { + return this._isFinish; + } + }; + Task.create = function(options) { + var out = null; + if (0 !== _deadPool.length) { + out = _deadPool.pop(); + out.set(options); + } else out = new Task(options); + return out; + }; + module.exports = Task; + }), {} ], + 104: [ (function(require, module, exports) { + "use strict"; + var _require = require("./helper"), decodeUuid = _require.decodeUuid; + var RequestItem = require("./request-item"); + var _require2 = require("./shared"), RequestType = _require2.RequestType, bundles = _require2.bundles; + function parse(task) { + var input = task.input, options = task.options; + input = Array.isArray(input) ? input : [ input ]; + task.output = []; + for (var i = 0; i < input.length; i++) { + var item = input[i]; + var out = RequestItem.create(); + if ("string" === typeof item) { + item = Object.create(null); + item[options.__requestType__ || RequestType.UUID] = input[i]; + } + if ("object" === typeof item) { + cc.js.addon(item, options); + item.preset && cc.js.addon(item, cc.assetManager.presets[item.preset]); + for (var key in item) { + switch (key) { + case RequestType.UUID: + var uuid = out.uuid = decodeUuid(item.uuid); + if (bundles.has(item.bundle)) { + var config = bundles.get(item.bundle)._config; + var info = config.getAssetInfo(uuid); + if (info && info.redirect) { + if (!bundles.has(info.redirect)) throw new Error("Please load bundle " + info.redirect + " first"); + config = bundles.get(info.redirect)._config; + info = config.getAssetInfo(uuid); + } + out.config = config; + out.info = info; + } + out.ext = item.ext || ".json"; + break; + + case "__requestType__": + case "ext": + case "bundle": + case "preset": + case "type": + break; + + case RequestType.DIR: + if (bundles.has(item.bundle)) { + var infos = []; + bundles.get(item.bundle)._config.getDirWithPath(item.dir, item.type, infos); + for (var _i = 0, l = infos.length; _i < l; _i++) { + var info = infos[_i]; + input.push({ + uuid: info.uuid, + __isNative__: false, + ext: ".json", + bundle: item.bundle + }); + } + } + out.recycle(); + out = null; + break; + + case RequestType.PATH: + if (bundles.has(item.bundle)) { + var config = bundles.get(item.bundle)._config; + var info = config.getInfoWithPath(item.path, item.type); + if (info && info.redirect) { + if (!bundles.has(info.redirect)) throw new Error("you need to load bundle " + info.redirect + " first"); + config = bundles.get(info.redirect)._config; + info = config.getAssetInfo(info.uuid); + } + if (!info) { + out.recycle(); + throw new Error("Bundle " + item.bundle + " doesn't contain " + item.path); + } + out.config = config; + out.uuid = info.uuid; + out.info = info; + } + out.ext = item.ext || ".json"; + break; + + case RequestType.SCENE: + if (bundles.has(item.bundle)) { + var config = bundles.get(item.bundle)._config; + var info = config.getSceneInfo(item.scene); + if (info && info.redirect) { + if (!bundles.has(info.redirect)) throw new Error("you need to load bundle " + info.redirect + " first"); + config = bundles.get(info.redirect)._config; + info = config.getAssetInfo(info.uuid); + } + if (!info) { + out.recycle(); + throw new Error("Bundle " + config.name + " doesn't contain scene " + item.scene); + } + out.config = config; + out.uuid = info.uuid; + out.info = info; + } + break; + + case "__isNative__": + out.isNative = item.__isNative__; + break; + + case RequestType.URL: + out.url = item.url; + out.uuid = item.uuid || item.url; + out.ext = item.ext || cc.path.extname(item.url); + out.isNative = void 0 === item.__isNative__ || item.__isNative__; + break; + + default: + out.options[key] = item[key]; + } + if (!out) break; + } + } + if (!out) continue; + task.output.push(out); + if (!out.uuid && !out.url) throw new Error("Can not parse this input:" + JSON.stringify(item)); + } + return null; + } + function combine(task) { + var input = task.output = task.input; + for (var i = 0; i < input.length; i++) { + var item = input[i]; + if (item.url) continue; + var url = "", base = ""; + var config = item.config; + base = item.isNative ? config && config.nativeBase ? config.base + config.nativeBase : cc.assetManager.generalNativeBase : config && config.importBase ? config.base + config.importBase : cc.assetManager.generalImportBase; + var uuid = item.uuid; + var ver = ""; + item.info && (ver = item.isNative ? item.info.nativeVer ? "." + item.info.nativeVer : "" : item.info.ver ? "." + item.info.ver : ""); + url = ".ttf" === item.ext ? base + "/" + uuid.slice(0, 2) + "/" + uuid + ver + "/" + item.options.__nativeName__ : base + "/" + uuid.slice(0, 2) + "/" + uuid + ver + item.ext; + item.url = url; + } + return null; + } + module.exports = { + parse: parse, + combine: combine + }; + }), { + "./helper": 93, + "./request-item": 101, + "./shared": 102 + } ], + 105: [ (function(require, module, exports) { + "use strict"; + var dependUtil = require("./depend-util"); + var _require = require("./helper"), isScene = _require.isScene, decodeUuid = _require.decodeUuid; + var _require2 = require("./shared"), assets = _require2.assets; + var _require3 = require("../platform/utils"), callInNextTick = _require3.callInNextTick; + var MissingObjectReporter = false; + require("../assets/CCAsset"); + var utils = { + processOptions: function processOptions(options) { + false; + var uuids = options.uuids; + var paths = options.paths; + var types = options.types; + var bundles = options.deps; + var realEntries = options.paths = Object.create(null); + if (false === options.debug) { + for (var i = 0, l = uuids.length; i < l; i++) uuids[i] = decodeUuid(uuids[i]); + for (var id in paths) { + var entry = paths[id]; + var type = entry[1]; + entry[1] = types[type]; + } + } else { + var out = Object.create(null); + for (var _i = 0, _l = uuids.length; _i < _l; _i++) { + var uuid = uuids[_i]; + uuids[_i] = out[uuid] = decodeUuid(uuid); + } + uuids = out; + } + for (var _id in paths) { + var _entry = paths[_id]; + realEntries[uuids[_id]] = _entry; + } + var scenes = options.scenes; + for (var name in scenes) { + var _uuid = scenes[name]; + scenes[name] = uuids[_uuid]; + } + var packs = options.packs; + for (var packId in packs) { + var packedIds = packs[packId]; + for (var j = 0; j < packedIds.length; ++j) packedIds[j] = uuids[packedIds[j]]; + } + var versions = options.versions; + if (versions) for (var folder in versions) { + var entries = versions[folder]; + for (var _i2 = 0; _i2 < entries.length; _i2 += 2) { + var _uuid2 = entries[_i2]; + entries[_i2] = uuids[_uuid2] || _uuid2; + } + } + var redirect = options.redirect; + if (redirect) for (var _i3 = 0; _i3 < redirect.length; _i3 += 2) { + redirect[_i3] = uuids[redirect[_i3]]; + redirect[_i3 + 1] = bundles[redirect[_i3 + 1]]; + } + }, + clear: function clear(task, clearRef) { + for (var i = 0, l = task.input.length; i < l; i++) { + var item = task.input[i]; + clearRef && !item.isNative && item.content && item.content.decRef && item.content.decRef(false); + item.recycle(); + } + task.input = null; + }, + urlAppendTimestamp: function urlAppendTimestamp(url) { + if (cc.assetManager.downloader.appendTimeStamp && "string" === typeof url) return /\?/.test(url) ? url + "&_t=" + (new Date() - 0) : url + "?_t=" + (new Date() - 0); + return url; + }, + retry: function retry(process, times, wait, onComplete, index) { + index = index || 0; + process(index, (function(err, result) { + index++; + !err || index > times ? onComplete && onComplete(err, result) : setTimeout((function() { + utils.retry(process, times, wait, onComplete, index); + }), wait); + })); + }, + getDepends: function getDepends(uuid, data, exclude, depends, preload, asyncLoadAssets, config) { + try { + var info = dependUtil.parse(uuid, data); + var includeNative = true; + data instanceof cc.Asset && (!data.__nativeDepend__ || data._nativeAsset) && (includeNative = false); + if (preload) { + for (var _i4 = 0, _l2 = info.deps.length; _i4 < _l2; _i4++) { + var _dep = info.deps[_i4]; + if (!(_dep in exclude)) { + exclude[_dep] = true; + depends.push({ + uuid: _dep, + bundle: config && config.name + }); + } + } + if (includeNative && info.nativeDep) { + config && (info.nativeDep.bundle = config.name); + depends.push(Object.assign({}, info.nativeDep)); + } + } else { + asyncLoadAssets = (true, !!data.asyncLoadAssets || asyncLoadAssets && !info.preventDeferredLoadDependents); + for (var i = 0, l = info.deps.length; i < l; i++) { + var dep = info.deps[i]; + if (!(dep in exclude)) { + exclude[dep] = true; + depends.push({ + uuid: dep, + __asyncLoadAssets__: asyncLoadAssets, + bundle: config && config.name + }); + } + } + if (includeNative && !asyncLoadAssets && !info.preventPreloadNativeObject && info.nativeDep) { + config && (info.nativeDep.bundle = config.name); + depends.push(Object.assign({}, info.nativeDep)); + } + } + } catch (e) { + cc.error(e.message, e.stack); + } + }, + cache: function cache(id, asset, cacheAsset) { + if (!asset) return; + var _isScene = isScene(asset); + !_isScene && cacheAsset && assets.add(id, asset); + _isScene && false; + }, + setProperties: function setProperties(uuid, asset, assetsMap) { + var missingAsset = false; + var depends = asset.__depends__; + if (depends) { + var missingAssetReporter = null; + for (var i = 0, l = depends.length; i < l; i++) { + var depend = depends[i]; + var dependAsset = assetsMap[depend.uuid + "@import"]; + if (dependAsset) depend.owner[depend.prop] = dependAsset.addRef(); else { + false; + cc.error("The asset " + depend.uuid + " is missing!"); + missingAsset = true; + } + } + missingAssetReporter && missingAssetReporter.reportByOwner(); + asset.__depends__ = void 0; + } + if (asset.__nativeDepend__) { + if (!asset._nativeAsset) if (assetsMap[uuid + "@native"]) asset._nativeAsset = assetsMap[uuid + "@native"]; else { + missingAsset = true; + false; + } + asset.__nativeDepend__ = void 0; + } + return missingAsset; + }, + gatherAsset: function gatherAsset(task) { + var source = task.source; + if (task.options.__outputAsArray__ || 1 !== source.length) { + var output = task.output = []; + for (var i = 0, l = source.length; i < l; i++) output.push(source[i].content); + } else task.output = source[0].content; + }, + forEach: function forEach(array, process, onComplete) { + var count = 0; + var errs = []; + 0 === array.length && onComplete && onComplete(errs); + for (var i = 0, l = array.length; i < l; i++) process(array[i], (function(err) { + err && errs.push(err); + count++; + count === l && onComplete && onComplete(errs); + })); + }, + parseParameters: function parseParameters(options, onProgress, onComplete) { + if (void 0 === onComplete) { + var isCallback = "function" === typeof options; + if (onProgress) { + onComplete = onProgress; + isCallback || (onProgress = null); + } else if (void 0 === onProgress && isCallback) { + onComplete = options; + options = null; + onProgress = null; + } + if (void 0 !== onProgress && isCallback) { + onProgress = options; + options = null; + } + } + options = options || Object.create(null); + return { + options: options, + onProgress: onProgress, + onComplete: onComplete + }; + }, + parseLoadResArgs: function parseLoadResArgs(type, onProgress, onComplete) { + if (void 0 === onComplete) { + var isValidType = cc.js.isChildClassOf(type, cc.Asset); + if (onProgress) { + onComplete = onProgress; + isValidType && (onProgress = null); + } else if (void 0 === onProgress && !isValidType) { + onComplete = type; + onProgress = null; + type = null; + } + if (void 0 !== onProgress && !isValidType) { + onProgress = type; + type = null; + } + } + return { + type: type, + onProgress: onProgress, + onComplete: onComplete + }; + }, + checkCircleReference: function checkCircleReference(owner, uuid, map, checked) { + checked || (checked = Object.create(null)); + var item = map[uuid]; + if (!item || checked[uuid]) return false; + checked[uuid] = true; + var result = false; + var deps = dependUtil.getDeps(uuid); + if (deps) for (var i = 0, l = deps.length; i < l; i++) { + var dep = deps[i]; + if (dep === owner || utils.checkCircleReference(owner, dep, map, checked)) { + result = true; + break; + } + } + return result; + }, + asyncify: function asyncify(cb) { + return function(p1, p2) { + if (!cb) return; + var refs = []; + Array.isArray(p2) ? p2.forEach((function(x) { + return x instanceof cc.Asset && refs.push(x.addRef()); + })) : p2 instanceof cc.Asset && refs.push(p2.addRef()); + callInNextTick((function() { + refs.forEach((function(x) { + return x.decRef(false); + })); + cb(p1, p2); + })); + }; + } + }; + module.exports = utils; + }), { + "../assets/CCAsset": 106, + "../platform/utils": 264, + "./depend-util": 82, + "./helper": 93, + "./shared": 102 + } ], + 106: [ (function(require, module, exports) { + "use strict"; + var CCObject = require("../platform/CCObject"); + cc.Asset = cc.Class({ + name: "cc.Asset", + extends: CCObject, + ctor: function ctor() { + Object.defineProperty(this, "_uuid", { + value: "", + writable: true + }); + this.loaded = true; + this._nativeUrl = ""; + this._ref = 0; + }, + properties: { + nativeUrl: { + get: function get() { + if (!this._nativeUrl && this._native) { + var name = this._native; + if (47 === name.charCodeAt(0)) return name.slice(1); + 46 === name.charCodeAt(0) ? this._nativeUrl = cc.assetManager.utils.getUrlWithUuid(this._uuid, { + nativeExt: name, + isNative: true + }) : this._nativeUrl = cc.assetManager.utils.getUrlWithUuid(this._uuid, { + __nativeName__: name, + nativeExt: cc.path.extname(name), + isNative: true + }); + } + return this._nativeUrl; + }, + visible: false + }, + refCount: { + get: function get() { + return this._ref; + } + }, + _native: "", + _nativeAsset: { + get: function get() { + return this._$nativeAsset; + }, + set: function set(obj) { + this._$nativeAsset = obj; + } + }, + _nativeDep: { + get: function get() { + if (this._native) return { + __isNative__: true, + uuid: this._uuid, + ext: this._native + }; + } + } + }, + statics: { + deserialize: false, + preventDeferredLoadDependents: false, + preventPreloadNativeObject: false + }, + toString: function toString() { + return this.nativeUrl; + }, + serialize: false, + createNode: null, + _setRawAsset: function _setRawAsset(filename, inLibrary) { + this._native = false !== inLibrary ? filename || void 0 : "/" + filename; + }, + addRef: function addRef() { + this._ref++; + return this; + }, + decRef: function decRef(autoRelease) { + this._ref > 0 && this._ref--; + false !== autoRelease && cc.assetManager._releaseManager.tryRelease(this); + return this; + }, + destroy: function destroy() { + this.loaded = false; + return this._super(); + } + }); + module.exports = cc.Asset; + }), { + "../platform/CCObject": 246 + } ], + 107: [ (function(require, module, exports) { + "use strict"; + var Asset = require("./CCAsset"); + var EventTarget = require("../event/event-target"); + var LoadMode = cc.Enum({ + WEB_AUDIO: 0, + DOM_AUDIO: 1 + }); + var AudioClip = cc.Class({ + name: "cc.AudioClip", + extends: Asset, + mixins: [ EventTarget ], + ctor: function ctor() { + this._loading = false; + this.loaded = false; + this._audio = null; + }, + properties: { + duration: 0, + loadMode: { + default: LoadMode.WEB_AUDIO, + type: LoadMode + }, + _nativeAsset: { + get: function get() { + return this._audio; + }, + set: function set(value) { + value instanceof cc.AudioClip ? this._audio = value._nativeAsset : this._audio = value; + if (this._audio) { + this.loaded = true; + this.emit("load"); + } + }, + override: true + }, + _nativeDep: { + get: function get() { + return { + uuid: this._uuid, + audioLoadMode: this.loadMode, + ext: cc.path.extname(this._native), + __isNative__: true + }; + }, + override: true + } + }, + statics: { + LoadMode: LoadMode, + _loadByUrl: function _loadByUrl(url, callback) { + var audioClip = cc.assetManager.assets.get(url); + audioClip ? callback(null, audioClip) : cc.assetManager.loadRemote(url, (function(error, data) { + if (error) return callback(error); + callback(null, data); + })); + } + }, + _ensureLoaded: function _ensureLoaded(onComplete) { + if (!this.isValid) return; + if (this.loaded) return onComplete && onComplete(); + onComplete && this.once("load", onComplete); + if (!this._loading) { + this._loading = true; + var self = this; + cc.assetManager.postLoadNative(this, (function(err) { + self._loading = false; + })); + } + }, + destroy: function destroy() { + cc.audioEngine.uncache(this); + this._super(); + } + }); + cc.AudioClip = AudioClip; + module.exports = AudioClip; + }), { + "../event/event-target": 187, + "./CCAsset": 106 + } ], + 108: [ (function(require, module, exports) { + "use strict"; + var FontLetterDefinition = function FontLetterDefinition() { + this.u = 0; + this.v = 0; + this.w = 0; + this.h = 0; + this.offsetX = 0; + this.offsetY = 0; + this.textureID = 0; + this.valid = false; + this.xAdvance = 0; + }; + var FontAtlas = function FontAtlas(texture) { + this._letterDefinitions = {}; + this._texture = texture; + }; + FontAtlas.prototype = { + constructor: FontAtlas, + addLetterDefinitions: function addLetterDefinitions(letter, letterDefinition) { + this._letterDefinitions[letter] = letterDefinition; + }, + cloneLetterDefinition: function cloneLetterDefinition() { + var copyLetterDefinitions = {}; + for (var key in this._letterDefinitions) { + var value = new FontLetterDefinition(); + cc.js.mixin(value, this._letterDefinitions[key]); + copyLetterDefinitions[key] = value; + } + return copyLetterDefinitions; + }, + getTexture: function getTexture() { + return this._texture; + }, + getLetter: function getLetter(key) { + return this._letterDefinitions[key]; + }, + getLetterDefinitionForChar: function getLetterDefinitionForChar(_char) { + var key = _char.charCodeAt(0); + var hasKey = this._letterDefinitions.hasOwnProperty(key); + var letter; + letter = hasKey ? this._letterDefinitions[key] : null; + return letter; + }, + clear: function clear() { + this._letterDefinitions = {}; + } + }; + var BitmapFont = cc.Class({ + name: "cc.BitmapFont", + extends: cc.Font, + properties: { + fntDataStr: { + default: "" + }, + spriteFrame: { + default: null, + type: cc.SpriteFrame + }, + fontSize: { + default: -1 + }, + _fntConfig: null, + _fontDefDictionary: null + }, + onLoad: function onLoad() { + var spriteFrame = this.spriteFrame; + if (!this._fontDefDictionary) { + this._fontDefDictionary = new FontAtlas(); + spriteFrame && (this._fontDefDictionary._texture = spriteFrame._texture); + } + var fntConfig = this._fntConfig; + if (!fntConfig) return; + var fontDict = fntConfig.fontDefDictionary; + for (var fontDef in fontDict) { + var letter = new FontLetterDefinition(); + var rect = fontDict[fontDef].rect; + letter.offsetX = fontDict[fontDef].xOffset; + letter.offsetY = fontDict[fontDef].yOffset; + letter.w = rect.width; + letter.h = rect.height; + letter.u = rect.x; + letter.v = rect.y; + letter.textureID = 0; + letter.valid = true; + letter.xAdvance = fontDict[fontDef].xAdvance; + this._fontDefDictionary.addLetterDefinitions(fontDef, letter); + } + } + }); + cc.BitmapFont = BitmapFont; + cc.BitmapFont.FontLetterDefinition = FontLetterDefinition; + cc.BitmapFont.FontAtlas = FontAtlas; + module.exports = BitmapFont; + }), {} ], + 109: [ (function(require, module, exports) { + "use strict"; + var BufferAsset = cc.Class({ + name: "cc.BufferAsset", + extends: cc.Asset, + ctor: function ctor() { + this._buffer = null; + }, + properties: { + _nativeAsset: { + get: function get() { + return this._buffer; + }, + set: function set(bin) { + this._buffer = bin.buffer || bin; + }, + override: true + }, + buffer: function buffer() { + return this._buffer; + } + } + }); + cc.BufferAsset = module.exports = BufferAsset; + }), {} ], + 110: [ (function(require, module, exports) { + "use strict"; + var Font = cc.Class({ + name: "cc.Font", + extends: cc.Asset + }); + cc.Font = module.exports = Font; + }), {} ], + 111: [ (function(require, module, exports) { + "use strict"; + var JsonAsset = cc.Class({ + name: "cc.JsonAsset", + extends: cc.Asset, + properties: { + json: null + } + }); + module.exports = cc.JsonAsset = JsonAsset; + }), {} ], + 112: [ (function(require, module, exports) { + "use strict"; + var LabelAtlas = cc.Class({ + name: "cc.LabelAtlas", + extends: cc.BitmapFont, + onLoad: function onLoad() { + if (!this.spriteFrame) { + cc.warnID(9100, this.name); + return; + } + if (!this._fntConfig) { + cc.warnID(9101, this.name); + return; + } + this._super(); + } + }); + cc.LabelAtlas = LabelAtlas; + module.exports = LabelAtlas; + }), {} ], + 113: [ (function(require, module, exports) { + "use strict"; + var OptimizationPolicy = cc.Enum({ + AUTO: 0, + SINGLE_INSTANCE: 1, + MULTI_INSTANCE: 2 + }); + var Prefab = cc.Class({ + name: "cc.Prefab", + extends: cc.Asset, + ctor: function ctor() { + this._createFunction = null; + this._instantiatedTimes = 0; + }, + properties: { + data: null, + optimizationPolicy: OptimizationPolicy.AUTO, + asyncLoadAssets: false, + readonly: { + default: false, + editorOnly: true + } + }, + statics: { + OptimizationPolicy: OptimizationPolicy, + OptimizationPolicyThreshold: 3 + }, + createNode: false, + compileCreateFunction: function compileCreateFunction() { + var jit = require("../platform/instantiate-jit"); + this._createFunction = jit.compile(this.data); + }, + _doInstantiate: function _doInstantiate(rootToRedirect) { + this.data._prefab || cc.warnID(3700); + this._createFunction || this.compileCreateFunction(); + return this._createFunction(rootToRedirect); + }, + _instantiate: function _instantiate() { + var node, useJit = false; + true; + useJit = this.optimizationPolicy !== OptimizationPolicy.SINGLE_INSTANCE && (this.optimizationPolicy === OptimizationPolicy.MULTI_INSTANCE || this._instantiatedTimes + 1 >= Prefab.OptimizationPolicyThreshold); + if (useJit) { + node = this._doInstantiate(); + this.data._instantiate(node); + } else node = this.data._instantiate(); + ++this._instantiatedTimes; + var PrefabUtils; + false, false; + return node; + }, + destroy: function destroy() { + this.data && this.data.destroy(); + this._super(); + } + }); + cc.Prefab = module.exports = Prefab; + cc.js.obsolete(cc, "cc._Prefab", "Prefab"); + }), { + "../platform/instantiate-jit": 259 + } ], + 114: [ (function(require, module, exports) { + "use strict"; + var _gfx = _interopRequireDefault(require("../../renderer/gfx")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + var renderer = require("../renderer"); + var Texture2D = require("./CCTexture2D"); + var DepthStencilFormat = cc.Enum({ + RB_FMT_D24S8: _gfx["default"].RB_FMT_D24S8, + RB_FMT_S8: _gfx["default"].RB_FMT_S8, + RB_FMT_D16: _gfx["default"].RB_FMT_D16 + }); + var RenderTexture = cc.Class({ + name: "cc.RenderTexture", + extends: Texture2D, + statics: { + DepthStencilFormat: DepthStencilFormat + }, + ctor: function ctor() { + this._framebuffer = null; + }, + initWithSize: function initWithSize(width, height, depthStencilFormat) { + this.width = Math.floor(width || cc.visibleRect.width); + this.height = Math.floor(height || cc.visibleRect.height); + this._resetUnderlyingMipmaps(); + var opts = { + colors: [ this._texture ] + }; + this._depthStencilBuffer && this._depthStencilBuffer.destroy(); + var depthStencilBuffer; + if (depthStencilFormat) { + depthStencilBuffer = new _gfx["default"].RenderBuffer(renderer.device, depthStencilFormat, width, height); + depthStencilFormat === _gfx["default"].RB_FMT_D24S8 ? opts.depthStencil = depthStencilBuffer : depthStencilFormat === _gfx["default"].RB_FMT_S8 ? opts.stencil = depthStencilBuffer : depthStencilFormat === _gfx["default"].RB_FMT_D16 && (opts.depth = depthStencilBuffer); + } + this._depthStencilBuffer = depthStencilBuffer; + this._framebuffer && this._framebuffer.destroy(); + this._framebuffer = new _gfx["default"].FrameBuffer(renderer.device, width, height, opts); + this._packable = false; + this.loaded = true; + this.emit("load"); + }, + updateSize: function updateSize(width, height) { + this.width = Math.floor(width || cc.visibleRect.width); + this.height = Math.floor(height || cc.visibleRect.height); + this._resetUnderlyingMipmaps(); + var rbo = this._depthStencilBuffer; + rbo && rbo.update(this.width, this.height); + this._framebuffer._width = width; + this._framebuffer._height = height; + }, + drawTextureAt: function drawTextureAt(texture, x, y) { + if (!texture._image || 0 === texture._image.width) return; + this._texture.updateSubImage({ + x: x, + y: y, + image: texture._image, + width: texture.width, + height: texture.height, + level: 0, + flipY: false, + premultiplyAlpha: texture._premultiplyAlpha + }); + }, + readPixels: function readPixels(data, x, y, w, h) { + if (!this._framebuffer || !this._texture) return data; + x = x || 0; + y = y || 0; + var width = w || this.width; + var height = h || this.height; + data = data || new Uint8Array(width * height * 4); + var gl = cc.game._renderContext; + var oldFBO = gl.getParameter(gl.FRAMEBUFFER_BINDING); + gl.bindFramebuffer(gl.FRAMEBUFFER, this._framebuffer.getHandle()); + gl.readPixels(x, y, width, height, gl.RGBA, gl.UNSIGNED_BYTE, data); + gl.bindFramebuffer(gl.FRAMEBUFFER, oldFBO); + return data; + }, + destroy: function destroy() { + this._super(); + if (this._framebuffer) { + this._framebuffer.destroy(); + this._framebuffer = null; + } + } + }); + cc.RenderTexture = module.exports = RenderTexture; + }), { + "../../renderer/gfx": 373, + "../renderer": 272, + "./CCTexture2D": 121 + } ], + 115: [ (function(require, module, exports) { + "use strict"; + var Scene = cc.Class({ + name: "cc.SceneAsset", + extends: cc.Asset, + properties: { + scene: null, + asyncLoadAssets: void 0 + } + }); + cc.SceneAsset = Scene; + module.exports = Scene; + }), {} ], + 116: [ (function(require, module, exports) { + "use strict"; + var Script = cc.Class({ + name: "cc.Script", + extends: cc.Asset + }); + cc._Script = Script; + var JavaScript = cc.Class({ + name: "cc.JavaScript", + extends: Script + }); + cc._JavaScript = JavaScript; + var TypeScript = cc.Class({ + name: "cc.TypeScript", + extends: Script + }); + cc._TypeScript = TypeScript; + }), {} ], + 117: [ (function(require, module, exports) { + "use strict"; + var SpriteAtlas = cc.Class({ + name: "cc.SpriteAtlas", + extends: cc.Asset, + properties: { + _spriteFrames: { + default: {} + } + }, + getTexture: function getTexture() { + var keys = Object.keys(this._spriteFrames); + if (keys.length > 0) { + var spriteFrame = this._spriteFrames[keys[0]]; + return spriteFrame ? spriteFrame.getTexture() : null; + } + return null; + }, + getSpriteFrame: function getSpriteFrame(key) { + var sf = this._spriteFrames[key]; + if (!sf) return null; + sf.name || (sf.name = key); + return sf; + }, + getSpriteFrames: function getSpriteFrames() { + var frames = []; + var spriteFrames = this._spriteFrames; + for (var key in spriteFrames) frames.push(this.getSpriteFrame(key)); + return frames; + } + }); + cc.SpriteAtlas = SpriteAtlas; + module.exports = SpriteAtlas; + }), {} ], + 118: [ (function(require, module, exports) { + "use strict"; + var EventTarget = require("../event/event-target"); + var INSET_LEFT = 0; + var INSET_TOP = 1; + var INSET_RIGHT = 2; + var INSET_BOTTOM = 3; + var temp_uvs = [ { + u: 0, + v: 0 + }, { + u: 0, + v: 0 + }, { + u: 0, + v: 0 + }, { + u: 0, + v: 0 + } ]; + var SpriteFrame = cc.Class({ + name: "cc.SpriteFrame", + extends: require("../assets/CCAsset"), + mixins: [ EventTarget ], + properties: { + _textureSetter: { + set: function set(texture) { + if (texture) { + false; + this._texture !== texture && this._refreshTexture(texture); + } + } + }, + insetTop: { + get: function get() { + return this._capInsets[INSET_TOP]; + }, + set: function set(value) { + this._capInsets[INSET_TOP] = value; + this._texture && this._calculateSlicedUV(); + } + }, + insetBottom: { + get: function get() { + return this._capInsets[INSET_BOTTOM]; + }, + set: function set(value) { + this._capInsets[INSET_BOTTOM] = value; + this._texture && this._calculateSlicedUV(); + } + }, + insetLeft: { + get: function get() { + return this._capInsets[INSET_LEFT]; + }, + set: function set(value) { + this._capInsets[INSET_LEFT] = value; + this._texture && this._calculateSlicedUV(); + } + }, + insetRight: { + get: function get() { + return this._capInsets[INSET_RIGHT]; + }, + set: function set(value) { + this._capInsets[INSET_RIGHT] = value; + this._texture && this._calculateSlicedUV(); + } + } + }, + ctor: function ctor() { + EventTarget.call(this); + var filename = arguments[0]; + var rect = arguments[1]; + var rotated = arguments[2]; + var offset = arguments[3]; + var originalSize = arguments[4]; + this._rect = null; + this.uv = []; + this._texture = null; + this._original = null; + this._offset = null; + this._originalSize = null; + this._rotated = false; + this._flipX = false; + this._flipY = false; + this.vertices = null; + this._capInsets = [ 0, 0, 0, 0 ]; + this.uvSliced = []; + false; + void 0 !== filename && this.setTexture(filename, rect, rotated, offset, originalSize); + }, + textureLoaded: function textureLoaded() { + return this._texture && this._texture.loaded; + }, + onTextureLoaded: function onTextureLoaded(callback, target) { + if (!this.textureLoaded()) { + this.once("load", callback, target); + this.ensureLoadTexture(); + return false; + } + callback.call(target); + return true; + }, + isRotated: function isRotated() { + return this._rotated; + }, + setRotated: function setRotated(bRotated) { + this._rotated = bRotated; + this._texture && this._calculateUV(); + }, + isFlipX: function isFlipX() { + return this._flipX; + }, + isFlipY: function isFlipY() { + return this._flipY; + }, + setFlipX: function setFlipX(flipX) { + this._flipX = flipX; + this._texture && this._calculateUV(); + }, + setFlipY: function setFlipY(flipY) { + this._flipY = flipY; + this._texture && this._calculateUV(); + }, + getRect: function getRect() { + return cc.rect(this._rect); + }, + setRect: function setRect(rect) { + this._rect = rect; + this._texture && this._calculateUV(); + }, + getOriginalSize: function getOriginalSize() { + return cc.size(this._originalSize); + }, + setOriginalSize: function setOriginalSize(size) { + if (this._originalSize) { + this._originalSize.width = size.width; + this._originalSize.height = size.height; + } else this._originalSize = cc.size(size); + }, + getTexture: function getTexture() { + return this._texture; + }, + _textureLoadedCallback: function _textureLoadedCallback() { + var self = this; + var texture = this._texture; + if (!texture) return; + var w = texture.width, h = texture.height; + self._rect ? self._checkRect(self._texture) : self._rect = cc.rect(0, 0, w, h); + self._originalSize || self.setOriginalSize(cc.size(w, h)); + self._offset || self.setOffset(cc.v2(0, 0)); + self._calculateUV(); + self.emit("load"); + }, + _refreshTexture: function _refreshTexture(texture) { + this._texture = texture; + texture.loaded ? this._textureLoadedCallback() : texture.once("load", this._textureLoadedCallback, this); + }, + getOffset: function getOffset() { + return cc.v2(this._offset); + }, + setOffset: function setOffset(offsets) { + this._offset = cc.v2(offsets); + }, + clone: function clone() { + return new SpriteFrame(this._texture, this.getRect(), this._rotated, this.getOffset(), this.getOriginalSize()); + }, + setTexture: function setTexture(texture, rect, rotated, offset, originalSize) { + if (1 === arguments.length && texture === this._texture) return; + this._rect = rect || null; + offset ? this.setOffset(offset) : this._offset = null; + originalSize ? this.setOriginalSize(originalSize) : this._originalSize = null; + this._rotated = rotated || false; + if ("string" === typeof texture) { + cc.errorID(3401); + return; + } + texture instanceof cc.Texture2D && this._refreshTexture(texture); + return true; + }, + ensureLoadTexture: function ensureLoadTexture() { + if (this._texture && !this._texture.loaded) { + this._refreshTexture(this._texture); + cc.assetManager.postLoadNative(this._texture); + } + }, + _checkRect: function _checkRect(texture) { + var rect = this._rect; + var maxX = rect.x, maxY = rect.y; + if (this._rotated) { + maxX += rect.height; + maxY += rect.width; + } else { + maxX += rect.width; + maxY += rect.height; + } + maxX > texture.width && cc.errorID(3300, texture.nativeUrl + "/" + this.name, maxX, texture.width); + maxY > texture.height && cc.errorID(3400, texture.nativeUrl + "/" + this.name, maxY, texture.height); + }, + _flipXY: function _flipXY(uvs) { + if (this._flipX) { + var tempVal = uvs[0]; + uvs[0] = uvs[1]; + uvs[1] = tempVal; + tempVal = uvs[2]; + uvs[2] = uvs[3]; + uvs[3] = tempVal; + } + if (this._flipY) { + var _tempVal = uvs[0]; + uvs[0] = uvs[2]; + uvs[2] = _tempVal; + _tempVal = uvs[1]; + uvs[1] = uvs[3]; + uvs[3] = _tempVal; + } + }, + _calculateSlicedUV: function _calculateSlicedUV() { + var rect = this._rect; + var atlasWidth = this._texture.width; + var atlasHeight = this._texture.height; + var leftWidth = this._capInsets[INSET_LEFT]; + var rightWidth = this._capInsets[INSET_RIGHT]; + var centerWidth = rect.width - leftWidth - rightWidth; + var topHeight = this._capInsets[INSET_TOP]; + var bottomHeight = this._capInsets[INSET_BOTTOM]; + var centerHeight = rect.height - topHeight - bottomHeight; + var uvSliced = this.uvSliced; + uvSliced.length = 0; + if (this._rotated) { + temp_uvs[0].u = rect.x / atlasWidth; + temp_uvs[1].u = (rect.x + bottomHeight) / atlasWidth; + temp_uvs[2].u = (rect.x + bottomHeight + centerHeight) / atlasWidth; + temp_uvs[3].u = (rect.x + rect.height) / atlasWidth; + temp_uvs[3].v = rect.y / atlasHeight; + temp_uvs[2].v = (rect.y + leftWidth) / atlasHeight; + temp_uvs[1].v = (rect.y + leftWidth + centerWidth) / atlasHeight; + temp_uvs[0].v = (rect.y + rect.width) / atlasHeight; + this._flipXY(temp_uvs); + for (var row = 0; row < 4; ++row) { + var rowD = temp_uvs[row]; + for (var col = 0; col < 4; ++col) { + var colD = temp_uvs[3 - col]; + uvSliced.push({ + u: rowD.u, + v: colD.v + }); + } + } + } else { + temp_uvs[0].u = rect.x / atlasWidth; + temp_uvs[1].u = (rect.x + leftWidth) / atlasWidth; + temp_uvs[2].u = (rect.x + leftWidth + centerWidth) / atlasWidth; + temp_uvs[3].u = (rect.x + rect.width) / atlasWidth; + temp_uvs[3].v = rect.y / atlasHeight; + temp_uvs[2].v = (rect.y + topHeight) / atlasHeight; + temp_uvs[1].v = (rect.y + topHeight + centerHeight) / atlasHeight; + temp_uvs[0].v = (rect.y + rect.height) / atlasHeight; + this._flipXY(temp_uvs); + for (var _row = 0; _row < 4; ++_row) { + var _rowD = temp_uvs[_row]; + for (var _col = 0; _col < 4; ++_col) { + var _colD = temp_uvs[_col]; + uvSliced.push({ + u: _colD.u, + v: _rowD.v + }); + } + } + } + }, + _setDynamicAtlasFrame: function _setDynamicAtlasFrame(frame) { + if (!frame) return; + this._original = { + _texture: this._texture, + _x: this._rect.x, + _y: this._rect.y + }; + this._texture = frame.texture; + this._rect.x = frame.x; + this._rect.y = frame.y; + this._calculateUV(); + }, + _resetDynamicAtlasFrame: function _resetDynamicAtlasFrame() { + if (!this._original) return; + this._rect.x = this._original._x; + this._rect.y = this._original._y; + this._texture = this._original._texture; + this._original = null; + this._texture.loaded ? this._calculateUV() : this.ensureLoadTexture(); + }, + _calculateUV: function _calculateUV() { + var rect = this._rect, texture = this._texture, uv = this.uv, texw = texture.width, texh = texture.height; + if (this._rotated) { + var l = 0 === texw ? 0 : rect.x / texw; + var r = 0 === texw ? 0 : (rect.x + rect.height) / texw; + var b = 0 === texh ? 0 : (rect.y + rect.width) / texh; + var t = 0 === texh ? 0 : rect.y / texh; + uv[0] = l; + uv[1] = t; + uv[2] = l; + uv[3] = b; + uv[4] = r; + uv[5] = t; + uv[6] = r; + uv[7] = b; + } else { + var _l = 0 === texw ? 0 : rect.x / texw; + var _r = 0 === texw ? 0 : (rect.x + rect.width) / texw; + var _b = 0 === texh ? 0 : (rect.y + rect.height) / texh; + var _t = 0 === texh ? 0 : rect.y / texh; + uv[0] = _l; + uv[1] = _b; + uv[2] = _r; + uv[3] = _b; + uv[4] = _l; + uv[5] = _t; + uv[6] = _r; + uv[7] = _t; + } + if (this._flipX) { + var tempVal = uv[0]; + uv[0] = uv[2]; + uv[2] = tempVal; + tempVal = uv[1]; + uv[1] = uv[3]; + uv[3] = tempVal; + tempVal = uv[4]; + uv[4] = uv[6]; + uv[6] = tempVal; + tempVal = uv[5]; + uv[5] = uv[7]; + uv[7] = tempVal; + } + if (this._flipY) { + var _tempVal2 = uv[0]; + uv[0] = uv[4]; + uv[4] = _tempVal2; + _tempVal2 = uv[1]; + uv[1] = uv[5]; + uv[5] = _tempVal2; + _tempVal2 = uv[2]; + uv[2] = uv[6]; + uv[6] = _tempVal2; + _tempVal2 = uv[3]; + uv[3] = uv[7]; + uv[7] = _tempVal2; + } + var vertices = this.vertices; + if (vertices) { + vertices.nu.length = 0; + vertices.nv.length = 0; + for (var i = 0; i < vertices.u.length; i++) { + vertices.nu[i] = vertices.u[i] / texw; + vertices.nv[i] = vertices.v[i] / texh; + } + } + this._calculateSlicedUV(); + }, + _serialize: (false, false) && function(exporting, ctx) { + var rect = this._rect; + var offset = this._offset; + var size = this._originalSize; + var uuid; + var texture = this._texture; + texture && (uuid = texture._uuid); + if (!uuid) { + var url = this._textureFilename; + url && (uuid = Editor.Utils.UuidCache.urlToUuid(url)); + } + if (uuid && exporting) { + uuid = Editor.Utils.UuidUtils.compressUuid(uuid, true); + ctx.dependsOn("_textureSetter", uuid); + } + var vertices; + this.vertices && (vertices = { + triangles: this.vertices.triangles, + x: this.vertices.x, + y: this.vertices.y, + u: this.vertices.u, + v: this.vertices.v + }); + return { + name: this._name, + texture: !exporting && uuid || void 0, + atlas: exporting ? void 0 : this._atlasUuid, + rect: rect ? [ rect.x, rect.y, rect.width, rect.height ] : void 0, + offset: offset ? [ offset.x, offset.y ] : void 0, + originalSize: size ? [ size.width, size.height ] : void 0, + rotated: this._rotated ? 1 : void 0, + capInsets: this._capInsets, + vertices: vertices + }; + }, + _deserialize: function _deserialize(data, handle) { + var rect = data.rect; + rect && (this._rect = new cc.Rect(rect[0], rect[1], rect[2], rect[3])); + data.offset && this.setOffset(new cc.Vec2(data.offset[0], data.offset[1])); + data.originalSize && this.setOriginalSize(new cc.Size(data.originalSize[0], data.originalSize[1])); + this._rotated = 1 === data.rotated; + this._name = data.name; + var capInsets = data.capInsets; + if (capInsets) { + this._capInsets[INSET_LEFT] = capInsets[INSET_LEFT]; + this._capInsets[INSET_TOP] = capInsets[INSET_TOP]; + this._capInsets[INSET_RIGHT] = capInsets[INSET_RIGHT]; + this._capInsets[INSET_BOTTOM] = capInsets[INSET_BOTTOM]; + } + false; + this.vertices = data.vertices; + if (this.vertices) { + this.vertices.nu = []; + this.vertices.nv = []; + } + var textureUuid; + false; + } + }); + var proto = SpriteFrame.prototype; + proto.copyWithZone = proto.clone; + proto.copy = proto.clone; + proto.initWithTexture = proto.setTexture; + cc.SpriteFrame = SpriteFrame; + module.exports = SpriteFrame; + }), { + "../assets/CCAsset": 106, + "../event/event-target": 187 + } ], + 119: [ (function(require, module, exports) { + "use strict"; + var Font = require("./CCFont"); + var TTFFont = cc.Class({ + name: "cc.TTFFont", + extends: Font, + properties: { + _fontFamily: null, + _nativeAsset: { + type: cc.String, + get: function get() { + return this._fontFamily; + }, + set: function set(value) { + this._fontFamily = value || "Arial"; + }, + override: true + }, + _nativeDep: { + get: function get() { + return { + uuid: this._uuid, + __nativeName__: this._native, + ext: cc.path.extname(this._native), + __isNative__: true + }; + }, + override: true + } + } + }); + cc.TTFFont = module.exports = TTFFont; + }), { + "./CCFont": 110 + } ], + 120: [ (function(require, module, exports) { + "use strict"; + var TextAsset = cc.Class({ + name: "cc.TextAsset", + extends: cc.Asset, + properties: { + text: "" + }, + toString: function toString() { + return this.text; + } + }); + module.exports = cc.TextAsset = TextAsset; + }), {} ], + 121: [ (function(require, module, exports) { + "use strict"; + var _gfx = _interopRequireDefault(require("../../renderer/gfx")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + var EventTarget = require("../event/event-target"); + var renderer = require("../renderer"); + require("../platform/CCClass"); + var GL_NEAREST = 9728; + var GL_LINEAR = 9729; + var GL_REPEAT = 10497; + var GL_CLAMP_TO_EDGE = 33071; + var GL_MIRRORED_REPEAT = 33648; + var GL_RGBA = 6408; + var CHAR_CODE_0 = 48; + var CHAR_CODE_1 = 49; + var idGenerater = new (require("../platform/id-generater"))("Tex"); + var CUSTOM_PIXEL_FORMAT = 1024; + var PixelFormat = cc.Enum({ + RGB565: _gfx["default"].TEXTURE_FMT_R5_G6_B5, + RGB5A1: _gfx["default"].TEXTURE_FMT_R5_G5_B5_A1, + RGBA4444: _gfx["default"].TEXTURE_FMT_R4_G4_B4_A4, + RGB888: _gfx["default"].TEXTURE_FMT_RGB8, + RGBA8888: _gfx["default"].TEXTURE_FMT_RGBA8, + RGBA32F: _gfx["default"].TEXTURE_FMT_RGBA32F, + A8: _gfx["default"].TEXTURE_FMT_A8, + I8: _gfx["default"].TEXTURE_FMT_L8, + AI8: _gfx["default"].TEXTURE_FMT_L8_A8, + RGB_PVRTC_2BPPV1: _gfx["default"].TEXTURE_FMT_RGB_PVRTC_2BPPV1, + RGBA_PVRTC_2BPPV1: _gfx["default"].TEXTURE_FMT_RGBA_PVRTC_2BPPV1, + RGB_A_PVRTC_2BPPV1: CUSTOM_PIXEL_FORMAT++, + RGB_PVRTC_4BPPV1: _gfx["default"].TEXTURE_FMT_RGB_PVRTC_4BPPV1, + RGBA_PVRTC_4BPPV1: _gfx["default"].TEXTURE_FMT_RGBA_PVRTC_4BPPV1, + RGB_A_PVRTC_4BPPV1: CUSTOM_PIXEL_FORMAT++, + RGB_ETC1: _gfx["default"].TEXTURE_FMT_RGB_ETC1, + RGBA_ETC1: CUSTOM_PIXEL_FORMAT++, + RGB_ETC2: _gfx["default"].TEXTURE_FMT_RGB_ETC2, + RGBA_ETC2: _gfx["default"].TEXTURE_FMT_RGBA_ETC2 + }); + var WrapMode = cc.Enum({ + REPEAT: GL_REPEAT, + CLAMP_TO_EDGE: GL_CLAMP_TO_EDGE, + MIRRORED_REPEAT: GL_MIRRORED_REPEAT + }); + var Filter = cc.Enum({ + LINEAR: GL_LINEAR, + NEAREST: GL_NEAREST + }); + var FilterIndex = { + 9728: 0, + 9729: 1 + }; + var _images = []; + var _sharedOpts = { + width: void 0, + height: void 0, + minFilter: void 0, + magFilter: void 0, + wrapS: void 0, + wrapT: void 0, + format: void 0, + genMipmaps: void 0, + images: void 0, + image: void 0, + flipY: void 0, + premultiplyAlpha: void 0 + }; + function _getSharedOptions() { + for (var key in _sharedOpts) _sharedOpts[key] = void 0; + _images.length = 0; + _sharedOpts.images = _images; + return _sharedOpts; + } + var Texture2D = cc.Class({ + name: "cc.Texture2D", + extends: require("../assets/CCAsset"), + mixins: [ EventTarget ], + properties: { + _nativeAsset: { + get: function get() { + return this._image; + }, + set: function set(data) { + data._compressed && data._data ? this.initWithData(data._data, this._format, data.width, data.height) : this.initWithElement(data); + }, + override: true + }, + _format: PixelFormat.RGBA8888, + _premultiplyAlpha: false, + _flipY: false, + _minFilter: Filter.LINEAR, + _magFilter: Filter.LINEAR, + _mipFilter: Filter.LINEAR, + _wrapS: WrapMode.CLAMP_TO_EDGE, + _wrapT: WrapMode.CLAMP_TO_EDGE, + _isAlphaAtlas: false, + _genMipmaps: false, + genMipmaps: { + get: function get() { + return this._genMipmaps; + }, + set: function set(genMipmaps) { + if (this._genMipmaps !== genMipmaps) { + var opts = _getSharedOptions(); + opts.genMipmaps = genMipmaps; + this.update(opts); + } + } + }, + _packable: true, + packable: { + get: function get() { + return this._packable; + }, + set: function set(val) { + this._packable = val; + } + }, + _nativeDep: { + get: function get() { + return { + __isNative__: true, + uuid: this._uuid, + ext: this._native, + __flipY__: this._flipY, + __premultiplyAlpha__: this._premultiplyAlpha + }; + }, + override: true + } + }, + statics: { + PixelFormat: PixelFormat, + WrapMode: WrapMode, + Filter: Filter, + _FilterIndex: FilterIndex, + extnames: [ ".png", ".jpg", ".jpeg", ".bmp", ".webp", ".pvr", ".pkm" ], + _parseExt: function _parseExt(extIdStr, defaultFormat) { + var device = cc.renderer.device; + var extIds = extIdStr.split("_"); + var defaultExt = ""; + var bestExt = ""; + var bestIndex = 999; + var bestFormat = defaultFormat; + var SupportTextureFormats = cc.macro.SUPPORT_TEXTURE_FORMATS; + for (var i = 0; i < extIds.length; i++) { + var extFormat = extIds[i].split("@"); + var tmpExt = extFormat[0]; + tmpExt = Texture2D.extnames[tmpExt.charCodeAt(0) - CHAR_CODE_0] || tmpExt; + var index = SupportTextureFormats.indexOf(tmpExt); + if (-1 !== index && index < bestIndex) { + var tmpFormat = extFormat[1] ? parseInt(extFormat[1]) : defaultFormat; + if (".pvr" === tmpExt && !device.ext("WEBGL_compressed_texture_pvrtc")) continue; + if (!(tmpFormat !== PixelFormat.RGB_ETC1 && tmpFormat !== PixelFormat.RGBA_ETC1 || device.ext("WEBGL_compressed_texture_etc1"))) continue; + if (!(tmpFormat !== PixelFormat.RGB_ETC2 && tmpFormat !== PixelFormat.RGBA_ETC2 || device.ext("WEBGL_compressed_texture_etc"))) continue; + if (".webp" === tmpExt && !cc.sys.capabilities.webp) continue; + bestIndex = index; + bestExt = tmpExt; + bestFormat = tmpFormat; + } else defaultExt || (defaultExt = tmpExt); + } + return { + bestExt: bestExt, + bestFormat: bestFormat, + defaultExt: defaultExt + }; + } + }, + ctor: function ctor() { + this._id = idGenerater.getNewId(); + this.loaded = false; + this.width = 0; + this.height = 0; + this._hashDirty = true; + this._hash = 0; + this._texture = null; + false; + }, + getImpl: function getImpl() { + this._texture || (this._texture = new renderer.Texture2D(renderer.device, {})); + return this._texture; + }, + getId: function getId() { + return this._id; + }, + toString: function toString() { + return this.nativeUrl || ""; + }, + update: function update(options) { + if (options) { + var updateImg = false; + void 0 !== options.width && (this.width = options.width); + void 0 !== options.height && (this.height = options.height); + if (void 0 !== options.minFilter) { + this._minFilter = options.minFilter; + options.minFilter = FilterIndex[options.minFilter]; + } + if (void 0 !== options.magFilter) { + this._magFilter = options.magFilter; + options.magFilter = FilterIndex[options.magFilter]; + } + if (void 0 !== options.mipFilter) { + this._mipFilter = options.mipFilter; + options.mipFilter = FilterIndex[options.mipFilter]; + } + void 0 !== options.wrapS && (this._wrapS = options.wrapS); + void 0 !== options.wrapT && (this._wrapT = options.wrapT); + void 0 !== options.format && (this._format = options.format); + if (void 0 !== options.flipY) { + this._flipY = options.flipY; + updateImg = true; + } + if (void 0 !== options.premultiplyAlpha) { + this._premultiplyAlpha = options.premultiplyAlpha; + updateImg = true; + } + void 0 !== options.genMipmaps && (this._genMipmaps = options.genMipmaps); + cc.sys.capabilities.imageBitmap && this._image instanceof ImageBitmap ? this._checkImageBitmap(this._upload.bind(this, options, updateImg)) : this._upload(options, updateImg); + } + }, + _upload: function _upload(options, updateImg) { + updateImg && this._image && (options.image = this._image); + if (options.images && options.images.length > 0) this._image = options.images[0]; else if (void 0 !== options.image) { + this._image = options.image; + if (!options.images) { + _images.length = 0; + options.images = _images; + } + options.images.push(options.image); + } + this._texture && this._texture.update(options); + this._hashDirty = true; + }, + initWithElement: function initWithElement(element) { + if (!element) return; + this._image = element; + if (element.complete || element instanceof HTMLCanvasElement) this.handleLoadedTexture(); else if (cc.sys.capabilities.imageBitmap && element instanceof ImageBitmap) this._checkImageBitmap(this.handleLoadedTexture.bind(this)); else { + var self = this; + element.addEventListener("load", (function() { + self.handleLoadedTexture(); + })); + element.addEventListener("error", (function(err) { + cc.warnID(3119, err.message); + })); + } + }, + initWithData: function initWithData(data, pixelFormat, pixelsWidth, pixelsHeight) { + var opts = _getSharedOptions(); + opts.image = data; + opts.images = [ opts.image ]; + opts.genMipmaps = this._genMipmaps; + opts.premultiplyAlpha = this._premultiplyAlpha; + opts.flipY = this._flipY; + opts.minFilter = FilterIndex[this._minFilter]; + opts.magFilter = FilterIndex[this._magFilter]; + opts.wrapS = this._wrapS; + opts.wrapT = this._wrapT; + opts.format = this._getGFXPixelFormat(pixelFormat); + opts.width = pixelsWidth; + opts.height = pixelsHeight; + this._texture ? this._texture.update(opts) : this._texture = new renderer.Texture2D(renderer.device, opts); + this.width = pixelsWidth; + this.height = pixelsHeight; + this._updateFormat(); + this._checkPackable(); + this.loaded = true; + this.emit("load"); + return true; + }, + getHtmlElementObj: function getHtmlElementObj() { + return this._image; + }, + destroy: function destroy() { + cc.sys.capabilities.imageBitmap && this._image instanceof ImageBitmap && this._image.close && this._image.close(); + this._packable && cc.dynamicAtlasManager && cc.dynamicAtlasManager.deleteAtlasTexture(this); + this._image = null; + this._texture && this._texture.destroy(); + this._super(); + }, + getPixelFormat: function getPixelFormat() { + return this._format; + }, + hasPremultipliedAlpha: function hasPremultipliedAlpha() { + return this._premultiplyAlpha || false; + }, + isAlphaAtlas: function isAlphaAtlas() { + return this._isAlphaAtlas; + }, + handleLoadedTexture: function handleLoadedTexture() { + if (!this._image || !this._image.width || !this._image.height) return; + this.width = this._image.width; + this.height = this._image.height; + var opts = _getSharedOptions(); + opts.image = this._image; + opts.images = [ opts.image ]; + opts.width = this.width; + opts.height = this.height; + opts.genMipmaps = this._genMipmaps; + opts.format = this._getGFXPixelFormat(this._format); + opts.premultiplyAlpha = this._premultiplyAlpha; + opts.flipY = this._flipY; + opts.minFilter = FilterIndex[this._minFilter]; + opts.magFilter = FilterIndex[this._magFilter]; + opts.wrapS = this._wrapS; + opts.wrapT = this._wrapT; + this._texture ? this._texture.update(opts) : this._texture = new renderer.Texture2D(renderer.device, opts); + this._updateFormat(); + this._checkPackable(); + this.loaded = true; + this.emit("load"); + cc.macro.CLEANUP_IMAGE_CACHE && this._cleanupImageCache(); + }, + _cleanupImageCache: function _cleanupImageCache() { + this._image instanceof HTMLImageElement ? this._clearImage() : cc.sys.capabilities.imageBitmap && this._image instanceof ImageBitmap && this._image.close && this._image.close(); + }, + description: function description() { + return ""; + }, + releaseTexture: function releaseTexture() { + this._image = null; + this._texture && this._texture.destroy(); + }, + setWrapMode: function setWrapMode(wrapS, wrapT) { + if (this._wrapS !== wrapS || this._wrapT !== wrapT) { + var opts = _getSharedOptions(); + opts.wrapS = wrapS; + opts.wrapT = wrapT; + this.update(opts); + } + }, + setFilters: function setFilters(minFilter, magFilter) { + if (this._minFilter !== minFilter || this._magFilter !== magFilter) { + var opts = _getSharedOptions(); + opts.minFilter = minFilter; + opts.magFilter = magFilter; + this.update(opts); + } + }, + setFlipY: function setFlipY(flipY) { + if (this._flipY !== flipY) { + var opts = _getSharedOptions(); + opts.flipY = flipY; + opts.premultiplyAlpha = this._premultiplyAlpha; + this.update(opts); + } + }, + setPremultiplyAlpha: function setPremultiplyAlpha(premultiply) { + if (this._premultiplyAlpha !== premultiply) { + var opts = _getSharedOptions(); + opts.flipY = this._flipY; + opts.premultiplyAlpha = premultiply; + this.update(opts); + } + }, + _updateFormat: function _updateFormat() { + this._isAlphaAtlas = this._format === PixelFormat.RGBA_ETC1 || this._format === PixelFormat.RGB_A_PVRTC_4BPPV1 || this._format === PixelFormat.RGB_A_PVRTC_2BPPV1; + false; + }, + _checkPackable: function _checkPackable() { + var dynamicAtlas = cc.dynamicAtlasManager; + if (!dynamicAtlas) return; + if (this._isCompressed()) { + this._packable = false; + return; + } + var w = this.width, h = this.height; + if (!this._image || w > dynamicAtlas.maxFrameSize || h > dynamicAtlas.maxFrameSize || this._getHash() !== dynamicAtlas.Atlas.DEFAULT_HASH) { + this._packable = false; + return; + } + this._image && this._image instanceof HTMLCanvasElement && (this._packable = true); + }, + _getOpts: function _getOpts() { + var opts = _getSharedOptions(); + opts.width = this.width; + opts.height = this.height; + opts.genMipmaps = this._genMipmaps; + opts.format = this._format; + opts.premultiplyAlpha = this._premultiplyAlpha; + opts.anisotropy = this._anisotropy; + opts.flipY = this._flipY; + opts.minFilter = FilterIndex[this._minFilter]; + opts.magFilter = FilterIndex[this._magFilter]; + opts.mipFilter = FilterIndex[this._mipFilter]; + opts.wrapS = this._wrapS; + opts.wrapT = this._wrapT; + return opts; + }, + _getGFXPixelFormat: function _getGFXPixelFormat(format) { + format === PixelFormat.RGBA_ETC1 ? format = PixelFormat.RGB_ETC1 : format === PixelFormat.RGB_A_PVRTC_4BPPV1 ? format = PixelFormat.RGB_PVRTC_4BPPV1 : format === PixelFormat.RGB_A_PVRTC_2BPPV1 && (format = PixelFormat.RGB_PVRTC_2BPPV1); + return format; + }, + _resetUnderlyingMipmaps: function _resetUnderlyingMipmaps(mipmapSources) { + var opts = this._getOpts(); + opts.images = mipmapSources || [ null ]; + this._texture ? this._texture.update(opts) : this._texture = new renderer.Texture2D(renderer.device, opts); + }, + _serialize: (false, false) && function() { + var extId = ""; + var exportedExts = this._exportedExts; + !exportedExts && this._native && (exportedExts = [ this._native ]); + if (exportedExts) { + var exts = []; + for (var i = 0; i < exportedExts.length; i++) { + var _extId = ""; + var ext = exportedExts[i]; + if (ext) { + var extFormat = ext.split("@"); + _extId = Texture2D.extnames.indexOf(extFormat[0]); + _extId < 0 && (_extId = ext); + extFormat[1] && (_extId += "@" + extFormat[1]); + } + exts.push(_extId); + } + extId = exts.join("_"); + } + var asset = extId + "," + this._minFilter + "," + this._magFilter + "," + this._wrapS + "," + this._wrapT + "," + (this._premultiplyAlpha ? 1 : 0) + "," + (this._genMipmaps ? 1 : 0) + "," + (this._packable ? 1 : 0); + return asset; + }, + _deserialize: function _deserialize(data) { + var fields = data.split(","); + var extIdStr = fields[0]; + if (extIdStr) { + var result = Texture2D._parseExt(extIdStr, this._format); + if (result.bestExt) { + this._setRawAsset(result.bestExt); + this._format = result.bestFormat; + } else { + if (!result.defaultExt) throw new Error(cc.debug.getError(3121)); + this._setRawAsset(result.defaultExt); + cc.warnID(3120, result.defaultExt, result.defaultExt); + } + } + if (8 === fields.length) { + this._minFilter = parseInt(fields[1]); + this._magFilter = parseInt(fields[2]); + this._wrapS = parseInt(fields[3]); + this._wrapT = parseInt(fields[4]); + this._premultiplyAlpha = fields[5].charCodeAt(0) === CHAR_CODE_1; + this._genMipmaps = fields[6].charCodeAt(0) === CHAR_CODE_1; + this._packable = fields[7].charCodeAt(0) === CHAR_CODE_1; + } + }, + _getHash: function _getHash() { + if (!this._hashDirty) return this._hash; + var genMipmaps = this._genMipmaps ? 1 : 0; + var premultiplyAlpha = this._premultiplyAlpha ? 1 : 0; + var flipY = this._flipY ? 1 : 0; + var minFilter = this._minFilter === Filter.LINEAR ? 1 : 2; + var magFilter = this._magFilter === Filter.LINEAR ? 1 : 2; + var wrapS = this._wrapS === WrapMode.REPEAT ? 1 : this._wrapS === WrapMode.CLAMP_TO_EDGE ? 2 : 3; + var wrapT = this._wrapT === WrapMode.REPEAT ? 1 : this._wrapT === WrapMode.CLAMP_TO_EDGE ? 2 : 3; + var pixelFormat = this._format; + var image = this._image; + false; + this._hash = Number("" + minFilter + magFilter + pixelFormat + wrapS + wrapT + genMipmaps + premultiplyAlpha + flipY); + this._hashDirty = false; + return this._hash; + }, + _isCompressed: function _isCompressed() { + return this._format < PixelFormat.A8 || this._format > PixelFormat.RGBA32F; + }, + _clearImage: function _clearImage() { + this._image.src = ""; + }, + _checkImageBitmap: function _checkImageBitmap(cb) { + var _this = this; + var image = this._image; + var flipY = this._flipY; + var premultiplyAlpha = this._premultiplyAlpha; + this._flipY !== image.flipY || this._premultiplyAlpha !== image.premultiplyAlpha ? createImageBitmap(image, { + imageOrientation: flipY !== image.flipY ? "flipY" : "none", + premultiplyAlpha: premultiplyAlpha ? "premultiply" : "none" + }).then((function(result) { + image.close && image.close(); + result.flipY = flipY; + result.premultiplyAlpha = premultiplyAlpha; + _this._image = result; + cb(); + }), (function(err) { + cc.error(err.message); + })) : cb(); + } + }); + cc.Texture2D = module.exports = Texture2D; + }), { + "../../renderer/gfx": 373, + "../assets/CCAsset": 106, + "../event/event-target": 187, + "../platform/CCClass": 240, + "../platform/id-generater": 257, + "../renderer": 272 + } ], + 122: [ (function(require, module, exports) { + "use strict"; + var Asset = require("./CCAsset"); + var EventTarget = require("../event/event-target"); + var VideoClip = cc.Class({ + name: "cc.VideoClip", + extends: Asset, + mixins: [ EventTarget ] + }); + cc.VideoClip = VideoClip; + module.exports = VideoClip; + }), { + "../event/event-target": 187, + "./CCAsset": 106 + } ], + 123: [ (function(require, module, exports) { + "use strict"; + require("./CCAsset"); + require("./CCFont"); + require("./CCPrefab"); + require("./CCAudioClip"); + require("./CCVideoClip"); + require("./CCScripts"); + require("./CCSceneAsset"); + require("./CCSpriteFrame"); + require("./CCTexture2D"); + require("./CCRenderTexture"); + require("./CCTTFFont"); + require("./CCSpriteAtlas"); + require("./CCBitmapFont"); + require("./CCLabelAtlas"); + require("./CCTextAsset"); + require("./CCJsonAsset"); + require("./CCBufferAsset"); + require("./material"); + }), { + "./CCAsset": 106, + "./CCAudioClip": 107, + "./CCBitmapFont": 108, + "./CCBufferAsset": 109, + "./CCFont": 110, + "./CCJsonAsset": 111, + "./CCLabelAtlas": 112, + "./CCPrefab": 113, + "./CCRenderTexture": 114, + "./CCSceneAsset": 115, + "./CCScripts": 116, + "./CCSpriteAtlas": 117, + "./CCSpriteFrame": 118, + "./CCTTFFont": 119, + "./CCTextAsset": 120, + "./CCTexture2D": 121, + "./CCVideoClip": 122, + "./material": 130 + } ], + 124: [ (function(require, module, exports) { + "use strict"; + var _CCAsset = _interopRequireDefault(require("../CCAsset")); + var _effectParser = require("./effect-parser"); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + var EffectAsset = cc.Class({ + name: "cc.EffectAsset", + extends: _CCAsset["default"], + ctor: function ctor() { + this._effect = null; + }, + properties: { + properties: Object, + techniques: [], + shaders: [] + }, + onLoad: function onLoad() { + if (cc.game.renderType === cc.game.RENDER_TYPE_CANVAS) return; + var lib = cc.renderer._forward._programLib; + for (var i = 0; i < this.shaders.length; i++) lib.define(this.shaders[i]); + this._initEffect(); + }, + _initEffect: function _initEffect() { + if (this._effect) return; + this._effect = (0, _effectParser.parseEffect)(this); + Object.freeze(this._effect); + }, + getInstantiatedEffect: function getInstantiatedEffect() { + this._initEffect(); + return this._effect.clone(); + }, + getEffect: function getEffect() { + this._initEffect(); + return this._effect; + } + }); + module.exports = cc.EffectAsset = EffectAsset; + }), { + "../CCAsset": 106, + "./effect-parser": 127 + } ], + 125: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var Asset = require("../CCAsset"); + var Texture = require("../CCTexture2D"); + var PixelFormat = Texture.PixelFormat; + var EffectAsset = require("./CCEffectAsset"); + var textureUtil = require("../../utils/texture-util"); + var gfx = cc.gfx; + var BUILTIN_NAME = cc.Enum({ + SPRITE: "2d-sprite", + GRAY_SPRITE: "2d-gray-sprite", + UNLIT: "unlit" + }); + var Material = cc.Class({ + name: "cc.Material", + extends: Asset, + ctor: function ctor() { + this.loaded = false; + this._manualHash = false; + this._dirty = true; + this._effect = null; + }, + properties: { + _defines: { + default: void 0, + type: Object + }, + _props: { + default: void 0, + type: Object + }, + _effectAsset: { + type: EffectAsset, + default: null + }, + _techniqueIndex: 0, + _techniqueData: Object, + effectName: void 0, + effectAsset: { + get: function get() { + return this._effectAsset; + }, + set: function set(asset) { + if (cc.game.renderType === cc.game.RENDER_TYPE_CANVAS) return; + this._effectAsset = asset; + if (!asset) { + cc.error("Can not set an empty effect asset."); + return; + } + this._effect = this._effectAsset.getInstantiatedEffect(); + } + }, + effect: { + get: function get() { + return this._effect; + } + }, + techniqueIndex: { + get: function get() { + return this._techniqueIndex; + }, + set: function set(v) { + this._techniqueIndex = v; + this._effect.switchTechnique(v); + } + } + }, + statics: { + getBuiltinMaterial: function getBuiltinMaterial(name) { + if (cc.game.renderType === cc.game.RENDER_TYPE_CANVAS) return new cc.Material(); + return cc.assetManager.builtins.getBuiltin("material", "builtin-" + name); + }, + BUILTIN_NAME: BUILTIN_NAME, + createWithBuiltin: function createWithBuiltin(effectName, techniqueIndex) { + void 0 === techniqueIndex && (techniqueIndex = 0); + var effectAsset = cc.assetManager.builtins.getBuiltin("effect", "builtin-" + effectName); + return Material.create(effectAsset, techniqueIndex); + }, + create: function create(effectAsset, techniqueIndex) { + void 0 === techniqueIndex && (techniqueIndex = 0); + if (!effectAsset) return null; + var material = new Material(); + material.effectAsset = effectAsset; + material.techniqueIndex = techniqueIndex; + return material; + } + }, + setProperty: function setProperty(name, val, passIdx, directly) { + if (cc.game.renderType === cc.game.RENDER_TYPE_CANVAS) return; + "string" === typeof passIdx && (passIdx = parseInt(passIdx)); + if (val instanceof Texture) { + var isAlphaAtlas = val.isAlphaAtlas(); + var key = "CC_USE_ALPHA_ATLAS_" + name; + var def = this.getDefine(key, passIdx); + (isAlphaAtlas || def) && this.define(key, isAlphaAtlas); + val.loaded || cc.assetManager.postLoadNative(val); + } + this._effect.setProperty(name, val, passIdx, directly); + }, + getProperty: function getProperty(name, passIdx) { + "string" === typeof passIdx && (passIdx = parseInt(passIdx)); + return this._effect.getProperty(name, passIdx); + }, + define: function define(name, val, passIdx, force) { + if (cc.game.renderType === cc.game.RENDER_TYPE_CANVAS) return; + "string" === typeof passIdx && (passIdx = parseInt(passIdx)); + this._effect.define(name, val, passIdx, force); + }, + getDefine: function getDefine(name, passIdx) { + "string" === typeof passIdx && (passIdx = parseInt(passIdx)); + return this._effect.getDefine(name, passIdx); + }, + setCullMode: function setCullMode(cullMode, passIdx) { + void 0 === cullMode && (cullMode = gfx.CULL_BACK); + this._effect.setCullMode(cullMode, passIdx); + }, + setDepth: function setDepth(depthTest, depthWrite, depthFunc, passIdx) { + void 0 === depthTest && (depthTest = false); + void 0 === depthWrite && (depthWrite = false); + void 0 === depthFunc && (depthFunc = gfx.DS_FUNC_LESS); + this._effect.setDepth(depthTest, depthWrite, depthFunc, passIdx); + }, + setBlend: function setBlend(enabled, blendEq, blendSrc, blendDst, blendAlphaEq, blendSrcAlpha, blendDstAlpha, blendColor, passIdx) { + void 0 === enabled && (enabled = false); + void 0 === blendEq && (blendEq = gfx.BLEND_FUNC_ADD); + void 0 === blendSrc && (blendSrc = gfx.BLEND_SRC_ALPHA); + void 0 === blendDst && (blendDst = gfx.BLEND_ONE_MINUS_SRC_ALPHA); + void 0 === blendAlphaEq && (blendAlphaEq = gfx.BLEND_FUNC_ADD); + void 0 === blendSrcAlpha && (blendSrcAlpha = gfx.BLEND_SRC_ALPHA); + void 0 === blendDstAlpha && (blendDstAlpha = gfx.BLEND_ONE_MINUS_SRC_ALPHA); + void 0 === blendColor && (blendColor = 4294967295); + this._effect.setBlend(enabled, blendEq, blendSrc, blendDst, blendAlphaEq, blendSrcAlpha, blendDstAlpha, blendColor, passIdx); + }, + setStencilEnabled: function setStencilEnabled(stencilTest, passIdx) { + void 0 === stencilTest && (stencilTest = gfx.STENCIL_INHERIT); + this._effect.setStencilEnabled(stencilTest, passIdx); + }, + setStencil: function setStencil(stencilTest, stencilFunc, stencilRef, stencilMask, stencilFailOp, stencilZFailOp, stencilZPassOp, stencilWriteMask, passIdx) { + void 0 === stencilTest && (stencilTest = gfx.STENCIL_INHERIT); + void 0 === stencilFunc && (stencilFunc = gfx.DS_FUNC_ALWAYS); + void 0 === stencilRef && (stencilRef = 0); + void 0 === stencilMask && (stencilMask = 255); + void 0 === stencilFailOp && (stencilFailOp = gfx.STENCIL_OP_KEEP); + void 0 === stencilZFailOp && (stencilZFailOp = gfx.STENCIL_OP_KEEP); + void 0 === stencilZPassOp && (stencilZPassOp = gfx.STENCIL_OP_KEEP); + void 0 === stencilWriteMask && (stencilWriteMask = 255); + this._effect.setStencil(stencilTest, stencilFunc, stencilRef, stencilMask, stencilFailOp, stencilZFailOp, stencilZPassOp, stencilWriteMask, passIdx); + }, + updateHash: function updateHash(hash) { + this._manualHash = hash; + this._effect && this._effect.updateHash(hash); + }, + getHash: function getHash() { + return this._manualHash || this._effect && this._effect.getHash(); + }, + onLoad: function onLoad() { + this.effectAsset = this._effectAsset; + if (!this._effect) return; + this._techniqueIndex && this._effect.switchTechnique(this._techniqueIndex); + this._techniqueData = this._techniqueData || {}; + var passDatas = this._techniqueData; + for (var index in passDatas) { + index = parseInt(index); + var passData = passDatas[index]; + if (!passData) continue; + for (var def in passData.defines) this.define(def, passData.defines[def], index); + for (var prop in passData.props) this.setProperty(prop, passData.props[prop], index); + } + } + }); + var _default = Material; + exports["default"] = _default; + cc.Material = Material; + module.exports = exports["default"]; + }), { + "../../utils/texture-util": 333, + "../CCAsset": 106, + "../CCTexture2D": 121, + "./CCEffectAsset": 124 + } ], + 126: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _pass = _interopRequireDefault(require("../../../renderer/core/pass")); + var _enums = _interopRequireDefault(require("../../../renderer/enums")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + "value" in descriptor && (descriptor.writable = true); + Object.defineProperty(target, descriptor.key, descriptor); + } + } + function _createClass(Constructor, protoProps, staticProps) { + protoProps && _defineProperties(Constructor.prototype, protoProps); + staticProps && _defineProperties(Constructor, staticProps); + return Constructor; + } + var gfx = cc.gfx; + var EffectBase = (function() { + function EffectBase() { + this._dirty = true; + this._name = ""; + this._technique = null; + } + var _proto = EffectBase.prototype; + _proto._createPassProp = function _createPassProp(name, pass) { + var prop = pass._properties[name]; + if (!prop) return; + var uniform = Object.create(null); + uniform.name = name; + uniform.type = prop.type; + prop.value instanceof Float32Array ? uniform.value = new Float32Array(prop.value) : prop.value instanceof Float64Array ? uniform.value = new Float64Array(prop.value) : uniform.value = prop.value; + pass._properties[name] = uniform; + return uniform; + }; + _proto._setPassProperty = function _setPassProperty(name, value, pass, directly) { + var properties = pass._properties; + properties.hasOwnProperty(name) || this._createPassProp(name, pass); + var prop = properties[name]; + var compareValue = value; + prop.type === _enums["default"].PARAM_TEXTURE_2D && (compareValue = value && value.getImpl()); + if (prop.value === compareValue) return true; + this._dirty = true; + return _pass["default"].prototype.setProperty.call(pass, name, value, directly); + }; + _proto.setProperty = function setProperty(name, value, passIdx, directly) { + var success = false; + var passes = this.passes; + var start = 0, end = passes.length; + void 0 !== passIdx && (start = passIdx, end = passIdx + 1); + for (var i = start; i < end; i++) this._setPassProperty(name, value, passes[i], directly) && (success = true); + success || cc.warnID(9103, this.name, name); + }; + _proto.getProperty = function getProperty(name, passIdx) { + var passes = this.passes; + if (passIdx >= passes.length) return; + var start = 0, end = passes.length; + void 0 !== passIdx && (start = passIdx, end = passIdx + 1); + for (var i = start; i < end; i++) { + var value = passes[i].getProperty(name); + if (void 0 !== value) return value; + } + }; + _proto.define = function define(name, value, passIdx, force) { + var success = false; + var passes = this.passes; + var start = 0, end = passes.length; + void 0 !== passIdx && (start = passIdx, end = passIdx + 1); + for (var i = start; i < end; i++) passes[i].define(name, value, force) && (success = true); + success || cc.warnID(9104, this.name, name); + }; + _proto.getDefine = function getDefine(name, passIdx) { + var passes = this.passes; + if (passIdx >= passes.length) return; + var start = 0, end = passes.length; + void 0 !== passIdx && (start = passIdx, end = passIdx + 1); + for (var i = start; i < end; i++) { + var value = passes[i].getDefine(name); + if (void 0 !== value) return value; + } + }; + _proto.setCullMode = function setCullMode(cullMode, passIdx) { + void 0 === cullMode && (cullMode = gfx.CULL_BACK); + var passes = this.passes; + var start = 0, end = passes.length; + void 0 !== passIdx && (start = passIdx, end = passIdx + 1); + for (var i = start; i < end; i++) passes[i].setCullMode(cullMode); + this._dirty = true; + }; + _proto.setDepth = function setDepth(depthTest, depthWrite, depthFunc, passIdx) { + var passes = this.passes; + var start = 0, end = passes.length; + void 0 !== passIdx && (start = passIdx, end = passIdx + 1); + for (var i = start; i < end; i++) passes[i].setDepth(depthTest, depthWrite, depthFunc); + this._dirty = true; + }; + _proto.setBlend = function setBlend(enabled, blendEq, blendSrc, blendDst, blendAlphaEq, blendSrcAlpha, blendDstAlpha, blendColor, passIdx) { + var passes = this.passes; + var start = 0, end = passes.length; + void 0 !== passIdx && (start = passIdx, end = passIdx + 1); + for (var i = start; i < end; i++) passes[i].setBlend(enabled, blendEq, blendSrc, blendDst, blendAlphaEq, blendSrcAlpha, blendDstAlpha, blendColor); + this._dirty = true; + }; + _proto.setStencilEnabled = function setStencilEnabled(stencilTest, passIdx) { + void 0 === stencilTest && (stencilTest = gfx.STENCIL_INHERIT); + var passes = this.passes; + var start = 0, end = passes.length; + void 0 !== passIdx && (start = passIdx, end = passIdx + 1); + for (var i = start; i < end; i++) passes[i].setStencilEnabled(stencilTest); + this._dirty = true; + }; + _proto.setStencil = function setStencil(enabled, stencilFunc, stencilRef, stencilMask, stencilFailOp, stencilZFailOp, stencilZPassOp, stencilWriteMask, passIdx) { + var passes = this.passes; + var start = 0, end = passes.length; + void 0 !== passIdx && (start = passIdx, end = passIdx + 1); + for (var i = start; i < end; i++) { + var pass = passes[i]; + pass.setStencilFront(enabled, stencilFunc, stencilRef, stencilMask, stencilFailOp, stencilZFailOp, stencilZPassOp, stencilWriteMask); + pass.setStencilBack(enabled, stencilFunc, stencilRef, stencilMask, stencilFailOp, stencilZFailOp, stencilZPassOp, stencilWriteMask); + } + this._dirty = true; + }; + _createClass(EffectBase, [ { + key: "name", + get: function get() { + return this._name; + } + }, { + key: "technique", + get: function get() { + return this._technique; + } + }, { + key: "passes", + get: function get() { + return []; + } + } ]); + return EffectBase; + })(); + exports["default"] = EffectBase; + cc.EffectBase = EffectBase; + module.exports = exports["default"]; + }), { + "../../../renderer/core/pass": 364, + "../../../renderer/enums": 368 + } ], + 127: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports.parseEffect = parseEffect; + var _pass = _interopRequireDefault(require("../../../renderer/core/pass")); + var _types = require("../../../renderer/types"); + var _enums = _interopRequireDefault(require("../../../renderer/enums")); + var _effect = _interopRequireDefault(require("./effect")); + var _technique = _interopRequireDefault(require("../../../renderer/core/technique")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function getInvolvedProgram(programName) { + var lib = cc.renderer._forward._programLib; + return lib.getTemplate(programName); + } + function parseProperties(effectAsset, passJson) { + var propertiesJson = passJson.properties || {}; + var program = getInvolvedProgram(passJson.program); + var _loop = function _loop(prop) { + var uniformInfo = program.uniforms.find((function(u) { + return u.name === prop; + })); + if (!uniformInfo) { + cc.warnID(9107, effectAsset.name, prop); + return "continue"; + } + }; + for (var prop in propertiesJson) { + var _ret = _loop(prop); + if ("continue" === _ret) continue; + } + var properties = {}; + program.uniforms.forEach((function(u) { + var name = u.name, prop = properties[name] = Object.assign({}, u), propInfo = propertiesJson[name]; + var value; + value = propInfo ? propInfo.type === _enums["default"].PARAM_TEXTURE_2D ? null : propInfo.type === _enums["default"].PARAM_INT || propInfo.type === _enums["default"].PARAM_FLOAT ? Array.isArray(propInfo.value) ? propInfo.value[0] : propInfo.value : new Float32Array(propInfo.value) : _types.enums2default[u.type]; + void 0 === value && (value = null); + prop.value = value; + })); + return properties; + } + function passDefines(pass) { + var defines = {}; + var program = getInvolvedProgram(pass.program); + program.defines.forEach((function(d) { + defines[d.name] = _types.enums2default[d.type]; + })); + return defines; + } + function parseTechniques(effectAsset) { + var techNum = effectAsset.techniques.length; + var techniques = new Array(techNum); + for (var j = 0; j < techNum; ++j) { + var tech = effectAsset.techniques[j]; + var techName = tech.name || j; + var passNum = tech.passes.length; + var passes = new Array(passNum); + for (var k = 0; k < passNum; ++k) { + var pass = tech.passes[k]; + var passName = pass.name || k; + var detailName = effectAsset.name + "-" + techName + "-" + passName; + var stage = pass.stage || "opaque"; + var properties = parseProperties(effectAsset, pass); + var defines = passDefines(pass); + var newPass = passes[k] = new _pass["default"](passName, detailName, pass.program, stage, properties, defines); + pass.rasterizerState && newPass.setCullMode(pass.rasterizerState.cullMode); + var blendState = pass.blendState && pass.blendState.targets[0]; + blendState && newPass.setBlend(blendState.blend, blendState.blendEq, blendState.blendSrc, blendState.blendDst, blendState.blendAlphaEq, blendState.blendSrcAlpha, blendState.blendDstAlpha, blendState.blendColor); + var depthStencilState = pass.depthStencilState; + if (depthStencilState) { + newPass.setDepth(depthStencilState.depthTest, depthStencilState.depthWrite, depthStencilState.depthFunc); + newPass.setStencilFront(depthStencilState.stencilTest, depthStencilState.stencilFuncFront, depthStencilState.stencilRefFront, depthStencilState.stencilMaskFront, depthStencilState.stencilFailOpFront, depthStencilState.stencilZFailOpFront, depthStencilState.stencilZPassOpFront, depthStencilState.stencilWriteMaskFront); + newPass.setStencilBack(depthStencilState.stencilTest, depthStencilState.stencilFuncBack, depthStencilState.stencilRefBack, depthStencilState.stencilMaskBack, depthStencilState.stencilFailOpBack, depthStencilState.stencilZFailOpBack, depthStencilState.stencilZPassOpBack, depthStencilState.stencilWriteMaskBack); + } + } + techniques[j] = new _technique["default"](techName, passes); + } + return techniques; + } + function parseEffect(effect) { + var techniques = parseTechniques(effect); + return new _effect["default"](effect.name, techniques, 0, effect); + } + false; + }), { + "../../../renderer/core/pass": 364, + "../../../renderer/core/technique": 366, + "../../../renderer/enums": 368, + "../../../renderer/types": 397, + "./effect": 129 + } ], + 128: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _murmurhash2_gc = _interopRequireDefault(require("../../../renderer/murmurhash2_gc")); + var _utils = _interopRequireDefault(require("./utils")); + var _effectBase = _interopRequireDefault(require("./effect-base")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + "value" in descriptor && (descriptor.writable = true); + Object.defineProperty(target, descriptor.key, descriptor); + } + } + function _createClass(Constructor, protoProps, staticProps) { + protoProps && _defineProperties(Constructor.prototype, protoProps); + staticProps && _defineProperties(Constructor, staticProps); + return Constructor; + } + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + _setPrototypeOf(subClass, superClass); + } + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + return _setPrototypeOf(o, p); + } + var gfx = cc.gfx; + var EffectVariant = (function(_EffectBase) { + _inheritsLoose(EffectVariant, _EffectBase); + function EffectVariant(effect) { + var _this; + _this = _EffectBase.call(this) || this; + _this._effect = void 0; + _this._passes = []; + _this._stagePasses = {}; + _this._hash = 0; + _this.init(effect); + return _this; + } + var _proto = EffectVariant.prototype; + _proto._onEffectChanged = function _onEffectChanged() {}; + _proto.init = function init(effect) { + effect instanceof EffectVariant && (effect = effect.effect); + this._effect = effect; + this._dirty = true; + if (effect) { + var passes = effect.passes; + var variantPasses = this._passes; + variantPasses.length = 0; + var stagePasses = this._stagePasses = {}; + for (var i = 0; i < passes.length; i++) { + var variant = variantPasses[i] = Object.setPrototypeOf({}, passes[i]); + variant._properties = Object.setPrototypeOf({}, passes[i]._properties); + variant._defines = Object.setPrototypeOf({}, passes[i]._defines); + stagePasses[variant._stage] || (stagePasses[variant._stage] = []); + stagePasses[variant._stage].push(variant); + } + } + }; + _proto.updateHash = function updateHash(hash) {}; + _proto.getHash = function getHash() { + if (!this._dirty) return this._hash; + this._dirty = false; + var hash = ""; + hash += _utils["default"].serializePasses(this._passes); + var effect = this._effect; + effect && (hash += _utils["default"].serializePasses(effect.passes)); + this._hash = (0, _murmurhash2_gc["default"])(hash, 666); + this.updateHash(this._hash); + return this._hash; + }; + _createClass(EffectVariant, [ { + key: "effect", + get: function get() { + return this._effect; + } + }, { + key: "name", + get: function get() { + return this._effect && this._effect.name + " (variant)"; + } + }, { + key: "passes", + get: function get() { + return this._passes; + } + }, { + key: "stagePasses", + get: function get() { + return this._stagePasses; + } + } ]); + return EffectVariant; + })(_effectBase["default"]); + exports["default"] = EffectVariant; + cc.EffectVariant = EffectVariant; + module.exports = exports["default"]; + }), { + "../../../renderer/murmurhash2_gc": 391, + "./effect-base": 126, + "./utils": 133 + } ], + 129: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _effectBase = _interopRequireDefault(require("./effect-base")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + "value" in descriptor && (descriptor.writable = true); + Object.defineProperty(target, descriptor.key, descriptor); + } + } + function _createClass(Constructor, protoProps, staticProps) { + protoProps && _defineProperties(Constructor.prototype, protoProps); + staticProps && _defineProperties(Constructor, staticProps); + return Constructor; + } + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + _setPrototypeOf(subClass, superClass); + } + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + return _setPrototypeOf(o, p); + } + var Effect = (function(_EffectBase) { + _inheritsLoose(Effect, _EffectBase); + function Effect(name, techniques, techniqueIndex, asset) { + var _this; + _this = _EffectBase.call(this) || this; + _this._techniques = []; + _this._asset = null; + _this.init(name, techniques, techniqueIndex, asset, true); + return _this; + } + var _proto = Effect.prototype; + _proto.init = function init(name, techniques, techniqueIndex, asset, createNative) { + this._name = name; + this._techniques = techniques; + this._technique = techniques[techniqueIndex]; + this._asset = asset; + }; + _proto.switchTechnique = function switchTechnique(index) { + if (index >= this._techniques.length) { + cc.warn("Can not switch to technique with index [" + index + "]"); + return; + } + this._technique = this._techniques[index]; + }; + _proto.clear = function clear() { + this._techniques = []; + }; + _proto.clone = function clone() { + var techniques = []; + for (var i = 0; i < this._techniques.length; i++) techniques.push(this._techniques[i].clone()); + var techniqueIndex = this._techniques.indexOf(this._technique); + return new Effect(this._name, techniques, techniqueIndex, this._asset); + }; + _createClass(Effect, [ { + key: "technique", + get: function get() { + return this._technique; + } + }, { + key: "passes", + get: function get() { + return this._technique.passes; + } + } ]); + return Effect; + })(_effectBase["default"]); + exports["default"] = Effect; + cc.Effect = Effect; + module.exports = exports["default"]; + }), { + "./effect-base": 126 + } ], + 130: [ (function(require, module, exports) { + "use strict"; + require("./CCEffectAsset"); + require("./CCMaterial"); + require("./material-variant"); + }), { + "./CCEffectAsset": 124, + "./CCMaterial": 125, + "./material-variant": 132 + } ], + 131: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _utils = _interopRequireDefault(require("./utils")); + var _pool = _interopRequireDefault(require("../../utils/pool")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + _setPrototypeOf(subClass, superClass); + } + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + return _setPrototypeOf(o, p); + } + var MaterialPool = (function(_Pool) { + _inheritsLoose(MaterialPool, _Pool); + function MaterialPool() { + var _this; + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) args[_key] = arguments[_key]; + _this = _Pool.call.apply(_Pool, [ this ].concat(args)) || this; + _this.enabled = false; + _this._pool = {}; + return _this; + } + var _proto = MaterialPool.prototype; + _proto.get = function get(exampleMat, renderComponent) { + var pool = this._pool; + if (exampleMat instanceof cc.MaterialVariant) { + if (!exampleMat._owner) { + exampleMat._owner = renderComponent; + return exampleMat; + } + if (exampleMat._owner === renderComponent) return exampleMat; + exampleMat = exampleMat.material; + } + var instance; + if (this.enabled) { + var uuid = exampleMat.effectAsset._uuid; + if (pool[uuid]) { + var key = _utils["default"].serializeDefines(exampleMat._effect._defines) + _utils["default"].serializeTechniques(exampleMat._effect._techniques); + instance = pool[uuid][key] && pool[uuid][key].pop(); + } + } + if (instance) this.count--; else { + instance = new cc.MaterialVariant(exampleMat); + instance._name = exampleMat._name + " (Instance)"; + instance._uuid = exampleMat._uuid; + } + instance._owner = renderComponent; + return instance; + }; + _proto.put = function put(mat) { + if (!this.enabled || !mat._owner) return; + var pool = this._pool; + var uuid = mat.effectAsset._uuid; + pool[uuid] || (pool[uuid] = {}); + var key = _utils["default"].serializeDefines(mat._effect._defines) + _utils["default"].serializeTechniques(mat._effect._techniques); + pool[uuid][key] || (pool[uuid][key] = []); + if (this.count > this.maxSize) return; + this._clean(mat); + pool[uuid][key].push(mat); + this.count++; + }; + _proto.clear = function clear() { + this._pool = {}; + this.count = 0; + }; + _proto._clean = function _clean(mat) { + mat._owner = null; + }; + return MaterialPool; + })(_pool["default"]); + var materialPool = new MaterialPool(); + _pool["default"].register("material", materialPool); + var _default = materialPool; + exports["default"] = _default; + module.exports = exports["default"]; + }), { + "../../utils/pool": 327, + "./utils": 133 + } ], + 132: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _CCMaterial = _interopRequireDefault(require("./CCMaterial")); + var _effectVariant = _interopRequireDefault(require("./effect-variant")); + var _materialPool = _interopRequireDefault(require("./material-pool")); + var _dec, _class; + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + "value" in descriptor && (descriptor.writable = true); + Object.defineProperty(target, descriptor.key, descriptor); + } + } + function _createClass(Constructor, protoProps, staticProps) { + protoProps && _defineProperties(Constructor.prototype, protoProps); + staticProps && _defineProperties(Constructor, staticProps); + return Constructor; + } + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + _setPrototypeOf(subClass, superClass); + } + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + return _setPrototypeOf(o, p); + } + var ccclass = cc._decorator.ccclass; + var MaterialVariant = (_dec = ccclass("cc.MaterialVariant"), _dec(_class = (function(_Material) { + _inheritsLoose(MaterialVariant, _Material); + MaterialVariant.createWithBuiltin = function createWithBuiltin(materialName, owner) { + return MaterialVariant.create(_CCMaterial["default"].getBuiltinMaterial(materialName), owner); + }; + MaterialVariant.create = function create(material, owner) { + if (!material) return null; + return _materialPool["default"].get(material, owner); + }; + function MaterialVariant(material) { + var _this; + _this = _Material.call(this) || this; + _this._owner = null; + _this._material = null; + _this.init(material); + return _this; + } + var _proto = MaterialVariant.prototype; + _proto.init = function init(material) { + this._effect = new _effectVariant["default"](material.effect); + this._effectAsset = material._effectAsset; + this._material = material; + }; + _createClass(MaterialVariant, [ { + key: "uuid", + get: function get() { + return this._material._uuid; + } + }, { + key: "owner", + get: function get() { + return this._owner; + } + }, { + key: "material", + get: function get() { + return this._material; + } + } ]); + return MaterialVariant; + })(_CCMaterial["default"])) || _class); + exports["default"] = MaterialVariant; + cc.MaterialVariant = MaterialVariant; + module.exports = exports["default"]; + }), { + "./CCMaterial": 125, + "./effect-variant": 128, + "./material-pool": 131 + } ], + 133: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _enums = _interopRequireDefault(require("../../../renderer/enums")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + var hashArray = []; + function serializeDefines(defines, names) { + var len = names.length; + for (var i = 0; i < len; i++) { + var name = names[i]; + hashArray[i] = name + defines[name]; + } + hashArray.length = len; + return hashArray.join(""); + } + function serializePass(pass, excludeProperties) { + var str = pass._programName + pass._cullMode; + pass._blend && (str += pass._blendEq + pass._blendAlphaEq + pass._blendSrc + pass._blendDst + pass._blendSrcAlpha + pass._blendDstAlpha + pass._blendColor); + pass._depthTest && (str += pass._depthWrite + pass._depthFunc); + pass._stencilTest && (str += pass._stencilFuncFront + pass._stencilRefFront + pass._stencilMaskFront + pass._stencilFailOpFront + pass._stencilZFailOpFront + pass._stencilZPassOpFront + pass._stencilWriteMaskFront + pass._stencilFuncBack + pass._stencilRefBack + pass._stencilMaskBack + pass._stencilFailOpBack + pass._stencilZFailOpBack + pass._stencilZPassOpBack + pass._stencilWriteMaskBack); + excludeProperties || (str += serializeUniforms(pass._properties, pass._propertyNames)); + str += serializeDefines(pass._defines, pass._defineNames); + return str; + } + function serializePasses(passes) { + var hashData = ""; + for (var i = 0; i < passes.length; i++) hashData += serializePass(passes[i]); + return hashData; + } + function serializeUniforms(uniforms, names) { + var index = 0; + for (var i = 0, len = names.length; i < len; i++) { + var param = uniforms[names[i]]; + var prop = param.value; + if (!prop) continue; + param.type === _enums["default"].PARAM_TEXTURE_2D || param.type === _enums["default"].PARAM_TEXTURE_CUBE ? hashArray[index] = prop._id : hashArray[index] = prop.toString(); + index++; + } + hashArray.length = index; + return hashArray.join(";"); + } + var _default = { + serializeDefines: serializeDefines, + serializePasses: serializePasses, + serializeUniforms: serializeUniforms + }; + exports["default"] = _default; + module.exports = exports["default"]; + }), { + "../../../renderer/enums": 368 + } ], + 134: [ (function(require, module, exports) { + "use strict"; + var Event; + true; + Event = require("../CCNode").EventType; + var TOP = 1; + var MID = 2; + var BOT = 4; + var LEFT = 8; + var CENTER = 16; + var RIGHT = 32; + var HORIZONTAL = LEFT | CENTER | RIGHT; + var VERTICAL = TOP | MID | BOT; + var AlignMode = cc.Enum({ + ONCE: 0, + ON_WINDOW_RESIZE: 1, + ALWAYS: 2 + }); + function getReadonlyNodeSize(parent) { + return parent instanceof cc.Scene ? cc.visibleRect : parent._contentSize; + } + function computeInverseTransForTarget(widgetNode, target, out_inverseTranslate, out_inverseScale) { + var scaleX = widgetNode._parent.scaleX; + var scaleY = widgetNode._parent.scaleY; + var translateX = 0; + var translateY = 0; + for (var node = widgetNode._parent; ;) { + translateX += node.x; + translateY += node.y; + node = node._parent; + if (!node) { + out_inverseTranslate.x = out_inverseTranslate.y = 0; + out_inverseScale.x = out_inverseScale.y = 1; + return; + } + if (node === target) break; + var sx = node.scaleX; + var sy = node.scaleY; + translateX *= sx; + translateY *= sy; + scaleX *= sx; + scaleY *= sy; + } + out_inverseScale.x = 0 !== scaleX ? 1 / scaleX : 1; + out_inverseScale.y = 0 !== scaleY ? 1 / scaleY : 1; + out_inverseTranslate.x = -translateX; + out_inverseTranslate.y = -translateY; + } + var tInverseTranslate = cc.Vec2.ZERO; + var tInverseScale = cc.Vec2.ONE; + function align(node, widget) { + var hasTarget = widget._target; + var target; + var inverseTranslate, inverseScale; + if (hasTarget) { + target = hasTarget; + inverseTranslate = tInverseTranslate; + inverseScale = tInverseScale; + computeInverseTransForTarget(node, target, inverseTranslate, inverseScale); + } else target = node._parent; + var targetSize = getReadonlyNodeSize(target); + var targetAnchor = target._anchorPoint; + var isRoot = (true, target instanceof cc.Scene); + var x = node.x, y = node.y; + var anchor = node._anchorPoint; + if (widget._alignFlags & HORIZONTAL) { + var localLeft, localRight, targetWidth = targetSize.width; + if (isRoot) { + localLeft = cc.visibleRect.left.x; + localRight = cc.visibleRect.right.x; + } else { + localLeft = -targetAnchor.x * targetWidth; + localRight = localLeft + targetWidth; + } + localLeft += widget._isAbsLeft ? widget._left : widget._left * targetWidth; + localRight -= widget._isAbsRight ? widget._right : widget._right * targetWidth; + if (hasTarget) { + localLeft += inverseTranslate.x; + localLeft *= inverseScale.x; + localRight += inverseTranslate.x; + localRight *= inverseScale.x; + } + var width, anchorX = anchor.x, scaleX = node.scaleX; + if (scaleX < 0) { + anchorX = 1 - anchorX; + scaleX = -scaleX; + } + if (widget.isStretchWidth) { + width = localRight - localLeft; + 0 !== scaleX && (node.width = width / scaleX); + x = localLeft + anchorX * width; + } else { + width = node.width * scaleX; + if (widget.isAlignHorizontalCenter) { + var localHorizontalCenter = widget._isAbsHorizontalCenter ? widget._horizontalCenter : widget._horizontalCenter * targetWidth; + var targetCenter = (.5 - targetAnchor.x) * targetSize.width; + if (hasTarget) { + localHorizontalCenter *= inverseScale.x; + targetCenter += inverseTranslate.x; + targetCenter *= inverseScale.x; + } + x = targetCenter + (anchorX - .5) * width + localHorizontalCenter; + } else x = widget.isAlignLeft ? localLeft + anchorX * width : localRight + (anchorX - 1) * width; + } + } + if (widget._alignFlags & VERTICAL) { + var localTop, localBottom, targetHeight = targetSize.height; + if (isRoot) { + localBottom = cc.visibleRect.bottom.y; + localTop = cc.visibleRect.top.y; + } else { + localBottom = -targetAnchor.y * targetHeight; + localTop = localBottom + targetHeight; + } + localBottom += widget._isAbsBottom ? widget._bottom : widget._bottom * targetHeight; + localTop -= widget._isAbsTop ? widget._top : widget._top * targetHeight; + if (hasTarget) { + localBottom += inverseTranslate.y; + localBottom *= inverseScale.y; + localTop += inverseTranslate.y; + localTop *= inverseScale.y; + } + var height, anchorY = anchor.y, scaleY = node.scaleY; + if (scaleY < 0) { + anchorY = 1 - anchorY; + scaleY = -scaleY; + } + if (widget.isStretchHeight) { + height = localTop - localBottom; + 0 !== scaleY && (node.height = height / scaleY); + y = localBottom + anchorY * height; + } else { + height = node.height * scaleY; + if (widget.isAlignVerticalCenter) { + var localVerticalCenter = widget._isAbsVerticalCenter ? widget._verticalCenter : widget._verticalCenter * targetHeight; + var targetMiddle = (.5 - targetAnchor.y) * targetSize.height; + if (hasTarget) { + localVerticalCenter *= inverseScale.y; + targetMiddle += inverseTranslate.y; + targetMiddle *= inverseScale.y; + } + y = targetMiddle + (anchorY - .5) * height + localVerticalCenter; + } else y = widget.isAlignBottom ? localBottom + anchorY * height : localTop + (anchorY - 1) * height; + } + } + node.setPosition(x, y); + } + function visitNode(node) { + var widget = node._widget; + if (widget) { + false; + align(node, widget); + true, widget.alignMode !== AlignMode.ALWAYS ? widgetManager.remove(widget) : activeWidgets.push(widget); + } + var children = node._children; + for (var i = 0; i < children.length; i++) { + var child = children[i]; + child._active && visitNode(child); + } + } + var animationState; + false; + function refreshScene() { + var AnimUtils; + var EditMode; + var nowPreviewing; + var component; + var animation; + var _component; + var _animation; + false; + var scene = cc.director.getScene(); + if (scene) { + widgetManager.isAligning = true; + if (widgetManager._nodesOrderDirty) { + activeWidgets.length = 0; + visitNode(scene); + widgetManager._nodesOrderDirty = false; + } else { + var i, widget, iterator = widgetManager._activeWidgetsIterator; + var AnimUtils; + var editingNode; + var node; + false; + for (iterator.i = 0; iterator.i < activeWidgets.length; ++iterator.i) { + widget = activeWidgets[iterator.i]; + align(widget.node, widget); + } + } + widgetManager.isAligning = false; + } + false; + } + var adjustWidgetToAllowMovingInEditor = false; + var adjustWidgetToAllowResizingInEditor = false; + var activeWidgets = []; + function updateAlignment(node) { + var parent = node._parent; + cc.Node.isNode(parent) && updateAlignment(parent); + var widget = node._widget || node.getComponent(cc.Widget); + widget && parent && align(node, widget); + } + var widgetManager = cc._widgetManager = module.exports = { + _AlignFlags: { + TOP: TOP, + MID: MID, + BOT: BOT, + LEFT: LEFT, + CENTER: CENTER, + RIGHT: RIGHT + }, + isAligning: false, + _nodesOrderDirty: false, + _activeWidgetsIterator: new cc.js.array.MutableForwardIterator(activeWidgets), + init: function init(director) { + director.on(cc.Director.EVENT_AFTER_UPDATE, refreshScene); + false; + var thisOnResized = this.onResized.bind(this); + cc.view.on("canvas-resize", thisOnResized); + window.addEventListener("orientationchange", thisOnResized); + }, + add: function add(widget) { + widget.node._widget = widget; + this._nodesOrderDirty = true; + false; + }, + remove: function remove(widget) { + widget.node._widget = null; + this._activeWidgetsIterator.remove(widget); + false; + }, + onResized: function onResized() { + var scene = cc.director.getScene(); + scene && this.refreshWidgetOnResized(scene); + }, + refreshWidgetOnResized: function refreshWidgetOnResized(node) { + var widget = cc.Node.isNode(node) && node.getComponent(cc.Widget); + widget && widget.enabled && widget.alignMode === AlignMode.ON_WINDOW_RESIZE && this.add(widget); + var children = node._children; + for (var i = 0; i < children.length; i++) { + var child = children[i]; + this.refreshWidgetOnResized(child); + } + }, + updateAlignment: updateAlignment, + AlignMode: AlignMode + }; + false; + }), { + "../CCNode": 73 + } ], + 135: [ (function(require, module, exports) { + "use strict"; + var _valueTypes = require("../value-types"); + var _geomUtils = require("../geom-utils"); + var AffineTrans = require("../utils/affine-transform"); + var renderer = require("../renderer/index"); + var RenderFlow = require("../renderer/render-flow"); + var game = require("../CCGame"); + var RendererCamera = null; + false; + RendererCamera = require("../../renderer/scene/camera"); + var _mat4_temp_1 = cc.mat4(); + var _mat4_temp_2 = cc.mat4(); + var _v3_temp_1 = cc.v3(); + var _v3_temp_2 = cc.v3(); + var _v3_temp_3 = cc.v3(); + var _cameras = []; + function updateMainCamera() { + for (var i = 0, minDepth = Number.MAX_VALUE; i < _cameras.length; i++) { + var camera = _cameras[i]; + if (camera._depth < minDepth) { + Camera.main = camera; + minDepth = camera._depth; + } + } + } + var _debugCamera = null; + function repositionDebugCamera() { + if (!_debugCamera) return; + var node = _debugCamera.getNode(); + var canvas = cc.game.canvas; + node.z = canvas.height / 1.1566; + node.x = canvas.width / 2; + node.y = canvas.height / 2; + } + var ClearFlags = cc.Enum({ + COLOR: 1, + DEPTH: 2, + STENCIL: 4 + }); + var StageFlags = cc.Enum({ + OPAQUE: 1, + TRANSPARENT: 2 + }); + var Camera = cc.Class({ + name: "cc.Camera", + extends: cc.Component, + ctor: function ctor() { + if (game.renderType !== game.RENDER_TYPE_CANVAS) { + var camera = new RendererCamera(); + camera.setStages([ "opaque" ]); + camera.dirty = true; + this._inited = false; + this._camera = camera; + } else this._inited = true; + }, + editor: false, + properties: { + _cullingMask: 4294967295, + _clearFlags: ClearFlags.DEPTH | ClearFlags.STENCIL, + _backgroundColor: cc.color(0, 0, 0, 255), + _depth: 0, + _zoomRatio: 1, + _targetTexture: null, + _fov: 60, + _orthoSize: 10, + _nearClip: 1, + _farClip: 4096, + _ortho: true, + _rect: cc.rect(0, 0, 1, 1), + _renderStages: 1, + _alignWithScreen: true, + zoomRatio: { + get: function get() { + return this._zoomRatio; + }, + set: function set(value) { + this._zoomRatio = value; + }, + tooltip: false + }, + fov: { + get: function get() { + return this._fov; + }, + set: function set(v) { + this._fov = v; + }, + tooltip: false + }, + orthoSize: { + get: function get() { + return this._orthoSize; + }, + set: function set(v) { + this._orthoSize = v; + }, + tooltip: false + }, + nearClip: { + get: function get() { + return this._nearClip; + }, + set: function set(v) { + this._nearClip = v; + this._updateClippingpPlanes(); + }, + tooltip: false + }, + farClip: { + get: function get() { + return this._farClip; + }, + set: function set(v) { + this._farClip = v; + this._updateClippingpPlanes(); + }, + tooltip: false + }, + ortho: { + get: function get() { + return this._ortho; + }, + set: function set(v) { + this._ortho = v; + this._updateProjection(); + }, + tooltip: false + }, + rect: { + get: function get() { + return this._rect; + }, + set: function set(v) { + this._rect = v; + this._updateRect(); + }, + tooltip: false + }, + cullingMask: { + get: function get() { + return this._cullingMask; + }, + set: function set(value) { + this._cullingMask = value; + this._updateCameraMask(); + }, + tooltip: false + }, + clearFlags: { + get: function get() { + return this._clearFlags; + }, + set: function set(value) { + this._clearFlags = value; + this._camera && this._camera.setClearFlags(value); + }, + tooltip: false + }, + backgroundColor: { + get: function get() { + return this._backgroundColor; + }, + set: function set(value) { + if (!this._backgroundColor.equals(value)) { + this._backgroundColor.set(value); + this._updateBackgroundColor(); + } + }, + tooltip: false + }, + depth: { + get: function get() { + return this._depth; + }, + set: function set(value) { + Camera.main === this ? this._depth < value && updateMainCamera() : Camera.main && value < Camera.main._depth && _cameras.includes(this) && (Camera.main = this); + this._depth = value; + this._camera && this._camera.setPriority(value); + }, + tooltip: false + }, + targetTexture: { + get: function get() { + return this._targetTexture; + }, + set: function set(value) { + this._targetTexture = value; + this._updateTargetTexture(); + }, + tooltip: false + }, + renderStages: { + get: function get() { + return this._renderStages; + }, + set: function set(val) { + this._renderStages = val; + this._updateStages(); + }, + tooltip: false + }, + alignWithScreen: { + get: function get() { + return this._alignWithScreen; + }, + set: function set(v) { + this._alignWithScreen = v; + } + }, + _is3D: { + get: function get() { + return this.node && this.node._is3DNode; + } + } + }, + statics: { + main: null, + cameras: _cameras, + ClearFlags: ClearFlags, + findCamera: function findCamera(node) { + for (var i = 0, l = _cameras.length; i < l; i++) { + var camera = _cameras[i]; + if (camera.containsNode(node)) return camera; + } + return null; + }, + _findRendererCamera: function _findRendererCamera(node) { + var cameras = renderer.scene._cameras; + for (var i = 0; i < cameras._count; i++) if (cameras._data[i]._cullingMask & node._cullingMask) return cameras._data[i]; + return null; + }, + _setupDebugCamera: function _setupDebugCamera() { + if (_debugCamera) return; + if (game.renderType === game.RENDER_TYPE_CANVAS) return; + var camera = new RendererCamera(); + _debugCamera = camera; + camera.setStages([ "opaque" ]); + camera.setFov(60 * Math.PI / 180); + camera.setNear(.1); + camera.setFar(4096); + camera.dirty = true; + camera.cullingMask = 1 << cc.Node.BuiltinGroupIndex.DEBUG; + camera.setPriority(cc.macro.MAX_ZINDEX); + camera.setClearFlags(0); + camera.setColor(0, 0, 0, 0); + var node = new cc.Node(); + camera.setNode(node); + repositionDebugCamera(); + cc.view.on("design-resolution-changed", repositionDebugCamera); + renderer.scene.addCamera(camera); + } + }, + _updateCameraMask: function _updateCameraMask() { + if (this._camera) { + var mask = this._cullingMask & ~(1 << cc.Node.BuiltinGroupIndex.DEBUG); + this._camera.cullingMask = mask; + } + }, + _updateBackgroundColor: function _updateBackgroundColor() { + if (!this._camera) return; + var color = this._backgroundColor; + this._camera.setColor(color.r / 255, color.g / 255, color.b / 255, color.a / 255); + }, + _updateTargetTexture: function _updateTargetTexture() { + if (!this._camera) return; + var texture = this._targetTexture; + this._camera.setFrameBuffer(texture ? texture._framebuffer : null); + }, + _updateClippingpPlanes: function _updateClippingpPlanes() { + if (!this._camera) return; + this._camera.setNear(this._nearClip); + this._camera.setFar(this._farClip); + }, + _updateProjection: function _updateProjection() { + if (!this._camera) return; + var type = this._ortho ? 1 : 0; + this._camera.setType(type); + }, + _updateRect: function _updateRect() { + if (!this._camera) return; + var rect = this._rect; + this._camera.setRect(rect.x, rect.y, rect.width, rect.height); + }, + _updateStages: function _updateStages() { + var flags = this._renderStages; + var stages = []; + flags & StageFlags.OPAQUE && stages.push("opaque"); + flags & StageFlags.TRANSPARENT && stages.push("transparent"); + this._camera.setStages(stages); + }, + _init: function _init() { + if (this._inited) return; + this._inited = true; + var camera = this._camera; + if (!camera) return; + camera.setNode(this.node); + camera.setClearFlags(this._clearFlags); + camera.setPriority(this._depth); + this._updateBackgroundColor(); + this._updateCameraMask(); + this._updateTargetTexture(); + this._updateClippingpPlanes(); + this._updateProjection(); + this._updateStages(); + this._updateRect(); + true; + this.beforeDraw(); + }, + __preload: function __preload() { + this._init(); + }, + onEnable: function onEnable() { + if (true, game.renderType !== game.RENDER_TYPE_CANVAS) { + cc.director.on(cc.Director.EVENT_BEFORE_DRAW, this.beforeDraw, this); + renderer.scene.addCamera(this._camera); + } + _cameras.push(this); + (!Camera.main || this._depth < Camera.main._depth) && (Camera.main = this); + }, + onDisable: function onDisable() { + if (true, game.renderType !== game.RENDER_TYPE_CANVAS) { + cc.director.off(cc.Director.EVENT_BEFORE_DRAW, this.beforeDraw, this); + renderer.scene.removeCamera(this._camera); + } + cc.js.array.fastRemove(_cameras, this); + if (Camera.main === this) { + Camera.main = null; + updateMainCamera(); + } + }, + getScreenToWorldMatrix2D: function getScreenToWorldMatrix2D(out) { + this.getWorldToScreenMatrix2D(out); + _valueTypes.Mat4.invert(out, out); + return out; + }, + getWorldToScreenMatrix2D: function getWorldToScreenMatrix2D(out) { + this.node.getWorldRT(_mat4_temp_1); + var zoomRatio = this.zoomRatio; + var _mat4_temp_1m = _mat4_temp_1.m; + _mat4_temp_1m[0] *= zoomRatio; + _mat4_temp_1m[1] *= zoomRatio; + _mat4_temp_1m[4] *= zoomRatio; + _mat4_temp_1m[5] *= zoomRatio; + var m12 = _mat4_temp_1m[12]; + var m13 = _mat4_temp_1m[13]; + var center = cc.visibleRect.center; + _mat4_temp_1m[12] = center.x - (_mat4_temp_1m[0] * m12 + _mat4_temp_1m[4] * m13); + _mat4_temp_1m[13] = center.y - (_mat4_temp_1m[1] * m12 + _mat4_temp_1m[5] * m13); + out !== _mat4_temp_1 && _valueTypes.Mat4.copy(out, _mat4_temp_1); + return out; + }, + getScreenToWorldPoint: function getScreenToWorldPoint(screenPosition, out) { + if (this.node.is3DNode) { + out = out || new cc.Vec3(); + this._camera.screenToWorld(out, screenPosition, cc.visibleRect.width, cc.visibleRect.height); + } else { + out = out || new cc.Vec2(); + this.getScreenToWorldMatrix2D(_mat4_temp_1); + _valueTypes.Vec2.transformMat4(out, screenPosition, _mat4_temp_1); + } + return out; + }, + getWorldToScreenPoint: function getWorldToScreenPoint(worldPosition, out) { + if (this.node.is3DNode) { + out = out || new cc.Vec3(); + this._camera.worldToScreen(out, worldPosition, cc.visibleRect.width, cc.visibleRect.height); + } else { + out = out || new cc.Vec2(); + this.getWorldToScreenMatrix2D(_mat4_temp_1); + _valueTypes.Vec2.transformMat4(out, worldPosition, _mat4_temp_1); + } + return out; + }, + getRay: function getRay(screenPos) { + if (!cc.geomUtils) return screenPos; + _valueTypes.Vec3.set(_v3_temp_3, screenPos.x, screenPos.y, 1); + this._camera.screenToWorld(_v3_temp_2, _v3_temp_3, cc.visibleRect.width, cc.visibleRect.height); + if (this.ortho) { + _valueTypes.Vec3.set(_v3_temp_3, screenPos.x, screenPos.y, -1); + this._camera.screenToWorld(_v3_temp_1, _v3_temp_3, cc.visibleRect.width, cc.visibleRect.height); + } else this.node.getWorldPosition(_v3_temp_1); + return _geomUtils.Ray.fromPoints(new _geomUtils.Ray(), _v3_temp_1, _v3_temp_2); + }, + containsNode: function containsNode(node) { + return (node._cullingMask & this.cullingMask) > 0; + }, + render: function render(rootNode) { + rootNode = rootNode || cc.director.getScene(); + if (!rootNode) return null; + this.node.getWorldMatrix(_mat4_temp_1); + this.beforeDraw(); + RenderFlow.renderCamera(this._camera, rootNode); + }, + _onAlignWithScreen: function _onAlignWithScreen() { + var height = cc.game.canvas.height / cc.view._scaleY; + var targetTexture = this._targetTexture; + if (targetTexture) { + false; + height = cc.visibleRect.height; + } + var fov = this._fov * cc.macro.RAD; + this.node.z = height / (2 * Math.tan(fov / 2)); + fov = 2 * Math.atan(Math.tan(fov / 2) / this.zoomRatio); + this._camera.setFov(fov); + this._camera.setOrthoHeight(height / 2 / this.zoomRatio); + this.node.setRotation(0, 0, 0, 1); + }, + beforeDraw: function beforeDraw() { + if (!this._camera) return; + if (this._alignWithScreen) this._onAlignWithScreen(); else { + var fov = this._fov * cc.macro.RAD; + fov = 2 * Math.atan(Math.tan(fov / 2) / this.zoomRatio); + this._camera.setFov(fov); + this._camera.setOrthoHeight(this._orthoSize / this.zoomRatio); + } + this._camera.dirty = true; + } + }); + cc.js.mixin(Camera.prototype, { + getNodeToCameraTransform: function getNodeToCameraTransform(node) { + var out = AffineTrans.identity(); + node.getWorldMatrix(_mat4_temp_2); + if (this.containsNode(node)) { + this.getWorldToCameraMatrix(_mat4_temp_1); + _valueTypes.Mat4.mul(_mat4_temp_2, _mat4_temp_2, _mat4_temp_1); + } + AffineTrans.fromMat4(out, _mat4_temp_2); + return out; + }, + getCameraToWorldPoint: function getCameraToWorldPoint(point, out) { + return this.getScreenToWorldPoint(point, out); + }, + getWorldToCameraPoint: function getWorldToCameraPoint(point, out) { + return this.getWorldToScreenPoint(point, out); + }, + getCameraToWorldMatrix: function getCameraToWorldMatrix(out) { + return this.getScreenToWorldMatrix2D(out); + }, + getWorldToCameraMatrix: function getWorldToCameraMatrix(out) { + return this.getWorldToScreenMatrix2D(out); + } + }); + module.exports = cc.Camera = Camera; + }), { + "../../renderer/scene/camera": 393, + "../CCGame": 72, + "../geom-utils": 195, + "../renderer/index": 272, + "../renderer/render-flow": 273, + "../utils/affine-transform": 316, + "../value-types": 340 + } ], + 136: [ (function(require, module, exports) { + "use strict"; + cc.Collider.Box = cc.Class({ + properties: { + _offset: cc.v2(0, 0), + _size: cc.size(100, 100), + offset: { + tooltip: false, + get: function get() { + return this._offset; + }, + set: function set(value) { + this._offset = value; + }, + type: cc.Vec2 + }, + size: { + tooltip: false, + get: function get() { + return this._size; + }, + set: function set(value) { + this._size.width = value.width < 0 ? 0 : value.width; + this._size.height = value.height < 0 ? 0 : value.height; + }, + type: cc.Size + } + }, + resetInEditor: false + }); + var BoxCollider = cc.Class({ + name: "cc.BoxCollider", + extends: cc.Collider, + mixins: [ cc.Collider.Box ], + editor: false + }); + cc.BoxCollider = module.exports = BoxCollider; + }), {} ], + 137: [ (function(require, module, exports) { + "use strict"; + cc.Collider.Circle = cc.Class({ + properties: { + _offset: cc.v2(0, 0), + _radius: 50, + offset: { + tooltip: false, + get: function get() { + return this._offset; + }, + set: function set(value) { + this._offset = value; + }, + type: cc.Vec2 + }, + radius: { + tooltip: false, + get: function get() { + return this._radius; + }, + set: function set(value) { + this._radius = value < 0 ? 0 : value; + } + } + }, + resetInEditor: false + }); + var CircleCollider = cc.Class({ + name: "cc.CircleCollider", + extends: cc.Collider, + mixins: [ cc.Collider.Circle ], + editor: false + }); + cc.CircleCollider = module.exports = CircleCollider; + }), {} ], + 138: [ (function(require, module, exports) { + "use strict"; + var Collider = cc.Class({ + name: "cc.Collider", + extends: cc.Component, + properties: { + editing: { + default: false, + serializable: false, + tooltip: false + }, + tag: { + tooltip: false, + default: 0, + range: [ 0, 1e7 ], + type: cc.Integer + } + }, + onDisable: function onDisable() { + cc.director.getCollisionManager().removeCollider(this); + }, + onEnable: function onEnable() { + cc.director.getCollisionManager().addCollider(this); + } + }); + cc.Collider = module.exports = Collider; + }), {} ], + 139: [ (function(require, module, exports) { + "use strict"; + var _vec = _interopRequireDefault(require("../value-types/vec2")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + var Contact = require("./CCContact"); + var CollisionType = Contact.CollisionType; + var NodeEvent = require("../CCNode").EventType; + var _vec2 = new _vec["default"](); + function obbApplyMatrix(rect, mat4, out_bl, out_tl, out_tr, out_br) { + var x = rect.x; + var y = rect.y; + var width = rect.width; + var height = rect.height; + var mat4m = mat4.m; + var m00 = mat4m[0], m01 = mat4m[1], m04 = mat4m[4], m05 = mat4m[5]; + var m12 = mat4m[12], m13 = mat4m[13]; + var tx = m00 * x + m04 * y + m12; + var ty = m01 * x + m05 * y + m13; + var xa = m00 * width; + var xb = m01 * width; + var yc = m04 * height; + var yd = m05 * height; + out_tl.x = tx; + out_tl.y = ty; + out_tr.x = xa + tx; + out_tr.y = xb + ty; + out_bl.x = yc + tx; + out_bl.y = yd + ty; + out_br.x = xa + yc + tx; + out_br.y = xb + yd + ty; + } + var CollisionManager = cc.Class({ + mixins: [ cc.EventTarget ], + properties: { + enabled: false, + enabledDrawBoundingBox: false + }, + ctor: function ctor() { + this._contacts = []; + this._colliders = []; + this._debugDrawer = null; + this._enabledDebugDraw = false; + cc.director._scheduler && cc.director._scheduler.enableForTarget(this); + }, + update: function update(dt) { + if (!this.enabled) return; + var i, l; + var colliders = this._colliders; + for (i = 0, l = colliders.length; i < l; i++) this.updateCollider(colliders[i]); + var contacts = this._contacts; + var results = []; + for (i = 0, l = contacts.length; i < l; i++) { + var collisionType = contacts[i].updateState(); + if (collisionType === CollisionType.None) continue; + results.push([ collisionType, contacts[i] ]); + } + for (i = 0, l = results.length; i < l; i++) { + var result = results[i]; + this._doCollide(result[0], result[1]); + } + this.drawColliders(); + }, + _doCollide: function _doCollide(collisionType, contact) { + var contactFunc; + switch (collisionType) { + case CollisionType.CollisionEnter: + contactFunc = "onCollisionEnter"; + break; + + case CollisionType.CollisionStay: + contactFunc = "onCollisionStay"; + break; + + case CollisionType.CollisionExit: + contactFunc = "onCollisionExit"; + } + var collider1 = contact.collider1; + var collider2 = contact.collider2; + var comps1 = collider1.node._components; + var comps2 = collider2.node._components; + var i, l, comp; + for (i = 0, l = comps1.length; i < l; i++) { + comp = comps1[i]; + comp[contactFunc] && comp[contactFunc](collider2, collider1); + } + for (i = 0, l = comps2.length; i < l; i++) { + comp = comps2[i]; + comp[contactFunc] && comp[contactFunc](collider1, collider2); + } + }, + shouldCollide: function shouldCollide(c1, c2) { + var node1 = c1.node, node2 = c2.node; + var collisionMatrix = cc.game.collisionMatrix; + return node1 !== node2 && collisionMatrix[node1.groupIndex][node2.groupIndex]; + }, + initCollider: function initCollider(collider) { + if (!collider.world) { + var world = collider.world = {}; + world.aabb = cc.rect(); + world.preAabb = cc.rect(); + world.matrix = cc.mat4(); + world.radius = 0; + if (collider instanceof cc.BoxCollider) { + world.position = null; + world.points = [ cc.v2(), cc.v2(), cc.v2(), cc.v2() ]; + } else if (collider instanceof cc.PolygonCollider) { + world.position = null; + world.points = collider.points.map((function(p) { + return cc.v2(p.x, p.y); + })); + } else if (collider instanceof cc.CircleCollider) { + world.position = cc.v2(); + world.points = null; + } + } + }, + updateCollider: function updateCollider(collider) { + var offset = collider.offset; + var world = collider.world; + var aabb = world.aabb; + var m = world.matrix; + collider.node.getWorldMatrix(m); + var preAabb = world.preAabb; + preAabb.x = aabb.x; + preAabb.y = aabb.y; + preAabb.width = aabb.width; + preAabb.height = aabb.height; + if (collider instanceof cc.BoxCollider) { + var size = collider.size; + aabb.x = offset.x - size.width / 2; + aabb.y = offset.y - size.height / 2; + aabb.width = size.width; + aabb.height = size.height; + var wps = world.points; + var wp0 = wps[0], wp1 = wps[1], wp2 = wps[2], wp3 = wps[3]; + obbApplyMatrix(aabb, m, wp0, wp1, wp2, wp3); + var minx = Math.min(wp0.x, wp1.x, wp2.x, wp3.x); + var miny = Math.min(wp0.y, wp1.y, wp2.y, wp3.y); + var maxx = Math.max(wp0.x, wp1.x, wp2.x, wp3.x); + var maxy = Math.max(wp0.y, wp1.y, wp2.y, wp3.y); + aabb.x = minx; + aabb.y = miny; + aabb.width = maxx - minx; + aabb.height = maxy - miny; + } else if (collider instanceof cc.CircleCollider) { + _vec["default"].transformMat4(_vec2, collider.offset, m); + world.position.x = _vec2.x; + world.position.y = _vec2.y; + var mm = m.m; + var tempx = mm[12], tempy = mm[13]; + mm[12] = mm[13] = 0; + _vec2.x = collider.radius; + _vec2.y = 0; + _vec["default"].transformMat4(_vec2, _vec2, m); + var d = Math.sqrt(_vec2.x * _vec2.x + _vec2.y * _vec2.y); + world.radius = d; + aabb.x = world.position.x - d; + aabb.y = world.position.y - d; + aabb.width = 2 * d; + aabb.height = 2 * d; + mm[12] = tempx; + mm[13] = tempy; + } else if (collider instanceof cc.PolygonCollider) { + var points = collider.points; + var worldPoints = world.points; + worldPoints.length = points.length; + var _minx = 1e6, _miny = 1e6, _maxx = -1e6, _maxy = -1e6; + for (var i = 0, l = points.length; i < l; i++) { + worldPoints[i] || (worldPoints[i] = cc.v2()); + _vec2.x = points[i].x + offset.x; + _vec2.y = points[i].y + offset.y; + _vec["default"].transformMat4(_vec2, _vec2, m); + var x = _vec2.x; + var y = _vec2.y; + worldPoints[i].x = x; + worldPoints[i].y = y; + x > _maxx && (_maxx = x); + x < _minx && (_minx = x); + y > _maxy && (_maxy = y); + y < _miny && (_miny = y); + } + aabb.x = _minx; + aabb.y = _miny; + aabb.width = _maxx - _minx; + aabb.height = _maxy - _miny; + } + }, + addCollider: function addCollider(collider) { + var colliders = this._colliders; + var index = colliders.indexOf(collider); + if (-1 === index) { + for (var i = 0, l = colliders.length; i < l; i++) { + var other = colliders[i]; + if (this.shouldCollide(collider, other)) { + var contact = new Contact(collider, other); + this._contacts.push(contact); + } + } + colliders.push(collider); + this.initCollider(collider); + } + collider.node.on(NodeEvent.GROUP_CHANGED, this.onNodeGroupChanged, this); + }, + removeCollider: function removeCollider(collider) { + var colliders = this._colliders; + var index = colliders.indexOf(collider); + if (index >= 0) { + colliders.splice(index, 1); + var contacts = this._contacts; + for (var i = contacts.length - 1; i >= 0; i--) { + var contact = contacts[i]; + if (contact.collider1 === collider || contact.collider2 === collider) { + contact.touching && this._doCollide(CollisionType.CollisionExit, contact); + contacts.splice(i, 1); + } + } + collider.node.off(NodeEvent.GROUP_CHANGED, this.onNodeGroupChanged, this); + } else cc.errorID(6600); + }, + onNodeGroupChanged: function onNodeGroupChanged(node) { + var colliders = node.getComponents(cc.Collider); + for (var i = 0, l = colliders.length; i < l; i++) { + var collider = colliders[i]; + if (cc.PhysicsCollider && collider instanceof cc.PhysicsCollider) continue; + this.removeCollider(collider); + this.addCollider(collider); + } + }, + drawColliders: function drawColliders() { + if (!this._enabledDebugDraw) return; + this._checkDebugDrawValid(); + var debugDrawer = this._debugDrawer; + debugDrawer.clear(); + var colliders = this._colliders; + for (var i = 0, l = colliders.length; i < l; i++) { + var collider = colliders[i]; + debugDrawer.strokeColor = cc.Color.WHITE; + if (collider instanceof cc.BoxCollider || collider instanceof cc.PolygonCollider) { + var ps = collider.world.points; + if (ps.length > 0) { + debugDrawer.moveTo(ps[0].x, ps[0].y); + for (var j = 1; j < ps.length; j++) debugDrawer.lineTo(ps[j].x, ps[j].y); + debugDrawer.close(); + debugDrawer.stroke(); + } + } else if (collider instanceof cc.CircleCollider) { + debugDrawer.circle(collider.world.position.x, collider.world.position.y, collider.world.radius); + debugDrawer.stroke(); + } + if (this.enabledDrawBoundingBox) { + var aabb = collider.world.aabb; + debugDrawer.strokeColor = cc.Color.BLUE; + debugDrawer.moveTo(aabb.xMin, aabb.yMin); + debugDrawer.lineTo(aabb.xMin, aabb.yMax); + debugDrawer.lineTo(aabb.xMax, aabb.yMax); + debugDrawer.lineTo(aabb.xMax, aabb.yMin); + debugDrawer.close(); + debugDrawer.stroke(); + } + } + }, + _checkDebugDrawValid: function _checkDebugDrawValid() { + if (!this._debugDrawer || !this._debugDrawer.isValid) { + var node = new cc.Node("COLLISION_MANAGER_DEBUG_DRAW"); + node.zIndex = cc.macro.MAX_ZINDEX; + cc.game.addPersistRootNode(node); + this._debugDrawer = node.addComponent(cc.Graphics); + } + } + }); + cc.js.getset(CollisionManager.prototype, "enabledDebugDraw", (function() { + return this._enabledDebugDraw; + }), (function(value) { + if (value && !this._enabledDebugDraw) { + this._checkDebugDrawValid(); + this._debugDrawer.node.active = true; + } else if (!value && this._enabledDebugDraw) { + this._debugDrawer.clear(true); + this._debugDrawer.node.active = false; + } + this._enabledDebugDraw = value; + })); + cc.CollisionManager = module.exports = CollisionManager; + }), { + "../CCNode": 73, + "../value-types/vec2": 349, + "./CCContact": 140 + } ], + 140: [ (function(require, module, exports) { + "use strict"; + var Intersection = require("./CCIntersection"); + var CollisionType = cc.Enum({ + None: 0, + CollisionEnter: 1, + CollisionStay: 2, + CollisionExit: 3 + }); + function Contact(collider1, collider2) { + this.collider1 = collider1; + this.collider2 = collider2; + this.touching = false; + var isCollider1Polygon = collider1 instanceof cc.BoxCollider || collider1 instanceof cc.PolygonCollider; + var isCollider2Polygon = collider2 instanceof cc.BoxCollider || collider2 instanceof cc.PolygonCollider; + var isCollider1Circle = collider1 instanceof cc.CircleCollider; + var isCollider2Circle = collider2 instanceof cc.CircleCollider; + if (isCollider1Polygon && isCollider2Polygon) this.testFunc = Intersection.polygonPolygon; else if (isCollider1Circle && isCollider2Circle) this.testFunc = Intersection.circleCircle; else if (isCollider1Polygon && isCollider2Circle) this.testFunc = Intersection.polygonCircle; else if (isCollider1Circle && isCollider2Polygon) { + this.testFunc = Intersection.polygonCircle; + this.collider1 = collider2; + this.collider2 = collider1; + } else cc.errorID(6601, cc.js.getClassName(collider1), cc.js.getClassName(collider2)); + } + Contact.prototype.test = function() { + var world1 = this.collider1.world; + var world2 = this.collider2.world; + if (!world1.aabb.intersects(world2.aabb)) return false; + if (this.testFunc === Intersection.polygonPolygon) return this.testFunc(world1.points, world2.points); + if (this.testFunc === Intersection.circleCircle) return this.testFunc(world1, world2); + if (this.testFunc === Intersection.polygonCircle) return this.testFunc(world1.points, world2); + return false; + }; + Contact.prototype.updateState = function() { + var result = this.test(); + var type = CollisionType.None; + if (result && !this.touching) { + this.touching = true; + type = CollisionType.CollisionEnter; + } else if (result && this.touching) type = CollisionType.CollisionStay; else if (!result && this.touching) { + this.touching = false; + type = CollisionType.CollisionExit; + } + return type; + }; + Contact.CollisionType = CollisionType; + module.exports = Contact; + }), { + "./CCIntersection": 141 + } ], + 141: [ (function(require, module, exports) { + "use strict"; + var Intersection = {}; + function lineLine(a1, a2, b1, b2) { + var ua_t = (b2.x - b1.x) * (a1.y - b1.y) - (b2.y - b1.y) * (a1.x - b1.x); + var ub_t = (a2.x - a1.x) * (a1.y - b1.y) - (a2.y - a1.y) * (a1.x - b1.x); + var u_b = (b2.y - b1.y) * (a2.x - a1.x) - (b2.x - b1.x) * (a2.y - a1.y); + if (0 !== u_b) { + var ua = ua_t / u_b; + var ub = ub_t / u_b; + if (0 <= ua && ua <= 1 && 0 <= ub && ub <= 1) return true; + } + return false; + } + Intersection.lineLine = lineLine; + function lineRect(a1, a2, b) { + var r0 = new cc.Vec2(b.x, b.y); + var r1 = new cc.Vec2(b.x, b.yMax); + var r2 = new cc.Vec2(b.xMax, b.yMax); + var r3 = new cc.Vec2(b.xMax, b.y); + if (lineLine(a1, a2, r0, r1)) return true; + if (lineLine(a1, a2, r1, r2)) return true; + if (lineLine(a1, a2, r2, r3)) return true; + if (lineLine(a1, a2, r3, r0)) return true; + return false; + } + Intersection.lineRect = lineRect; + function linePolygon(a1, a2, b) { + var length = b.length; + for (var i = 0; i < length; ++i) { + var b1 = b[i]; + var b2 = b[(i + 1) % length]; + if (lineLine(a1, a2, b1, b2)) return true; + } + return false; + } + Intersection.linePolygon = linePolygon; + function rectRect(a, b) { + var a_min_x = a.x; + var a_min_y = a.y; + var a_max_x = a.x + a.width; + var a_max_y = a.y + a.height; + var b_min_x = b.x; + var b_min_y = b.y; + var b_max_x = b.x + b.width; + var b_max_y = b.y + b.height; + return a_min_x <= b_max_x && a_max_x >= b_min_x && a_min_y <= b_max_y && a_max_y >= b_min_y; + } + Intersection.rectRect = rectRect; + function rectPolygon(a, b) { + var i, l; + var r0 = new cc.Vec2(a.x, a.y); + var r1 = new cc.Vec2(a.x, a.yMax); + var r2 = new cc.Vec2(a.xMax, a.yMax); + var r3 = new cc.Vec2(a.xMax, a.y); + if (linePolygon(r0, r1, b)) return true; + if (linePolygon(r1, r2, b)) return true; + if (linePolygon(r2, r3, b)) return true; + if (linePolygon(r3, r0, b)) return true; + for (i = 0, l = b.length; i < l; ++i) if (pointInPolygon(b[i], a)) return true; + if (pointInPolygon(r0, b)) return true; + if (pointInPolygon(r1, b)) return true; + if (pointInPolygon(r2, b)) return true; + if (pointInPolygon(r3, b)) return true; + return false; + } + Intersection.rectPolygon = rectPolygon; + function polygonPolygon(a, b) { + var i, l; + for (i = 0, l = a.length; i < l; ++i) { + var a1 = a[i]; + var a2 = a[(i + 1) % l]; + if (linePolygon(a1, a2, b)) return true; + } + for (i = 0, l = b.length; i < l; ++i) if (pointInPolygon(b[i], a)) return true; + for (i = 0, l = a.length; i < l; ++i) if (pointInPolygon(a[i], b)) return true; + return false; + } + Intersection.polygonPolygon = polygonPolygon; + function circleCircle(a, b) { + var distance = a.position.sub(b.position).mag(); + return distance < a.radius + b.radius; + } + Intersection.circleCircle = circleCircle; + function polygonCircle(polygon, circle) { + var position = circle.position; + if (pointInPolygon(position, polygon)) return true; + for (var i = 0, l = polygon.length; i < l; i++) { + var start = 0 === i ? polygon[polygon.length - 1] : polygon[i - 1]; + var end = polygon[i]; + if (pointLineDistance(position, start, end, true) < circle.radius) return true; + } + return false; + } + Intersection.polygonCircle = polygonCircle; + function pointInPolygon(point, polygon) { + var inside = false; + var x = point.x; + var y = point.y; + var length = polygon.length; + for (var i = 0, j = length - 1; i < length; j = i++) { + var xi = polygon[i].x, yi = polygon[i].y, xj = polygon[j].x, yj = polygon[j].y, intersect = yi > y !== yj > y && x < (xj - xi) * (y - yi) / (yj - yi) + xi; + intersect && (inside = !inside); + } + return inside; + } + Intersection.pointInPolygon = pointInPolygon; + function pointLineDistance(point, start, end, isSegment) { + var dx = end.x - start.x; + var dy = end.y - start.y; + var d = dx * dx + dy * dy; + var t = ((point.x - start.x) * dx + (point.y - start.y) * dy) / d; + var p; + p = isSegment ? d ? t < 0 ? start : t > 1 ? end : cc.v2(start.x + t * dx, start.y + t * dy) : start : cc.v2(start.x + t * dx, start.y + t * dy); + dx = point.x - p.x; + dy = point.y - p.y; + return Math.sqrt(dx * dx + dy * dy); + } + Intersection.pointLineDistance = pointLineDistance; + cc.Intersection = module.exports = Intersection; + }), {} ], + 142: [ (function(require, module, exports) { + "use strict"; + cc.Collider.Polygon = cc.Class({ + properties: { + threshold: { + default: 1, + serializable: false, + visible: false + }, + _offset: cc.v2(0, 0), + offset: { + get: function get() { + return this._offset; + }, + set: function set(value) { + this._offset = value; + }, + type: cc.Vec2 + }, + points: { + tooltip: false, + default: function _default() { + return [ cc.v2(-50, -50), cc.v2(50, -50), cc.v2(50, 50), cc.v2(-50, 50) ]; + }, + type: [ cc.Vec2 ] + } + }, + resetPointsByContour: false + }); + var PolygonCollider = cc.Class({ + name: "cc.PolygonCollider", + extends: cc.Collider, + mixins: [ cc.Collider.Polygon ], + editor: false + }); + cc.PolygonCollider = module.exports = PolygonCollider; + }), {} ], + 143: [ (function(require, module, exports) { + "use strict"; + require("./CCCollisionManager"); + require("./CCCollider"); + require("./CCBoxCollider"); + require("./CCCircleCollider"); + require("./CCPolygonCollider"); + }), { + "./CCBoxCollider": 136, + "./CCCircleCollider": 137, + "./CCCollider": 138, + "./CCCollisionManager": 139, + "./CCPolygonCollider": 142 + } ], + 144: [ (function(require, module, exports) { + "use strict"; + require("./platform/CCClass"); + var Flags = require("./platform/CCObject").Flags; + var jsArray = require("./platform/js").array; + var IsStartCalled = Flags.IsStartCalled; + var IsOnEnableCalled = Flags.IsOnEnableCalled; + var IsEditorOnEnableCalled = Flags.IsEditorOnEnableCalled; + var callerFunctor = false; + var callOnEnableInTryCatch = false; + var callOnDisableInTryCatch = false; + function sortedIndex(array, comp) { + var order = comp.constructor._executionOrder; + var id = comp._id; + for (var l = 0, h = array.length - 1, m = h >>> 1; l <= h; m = l + h >>> 1) { + var test = array[m]; + var testOrder = test.constructor._executionOrder; + if (testOrder > order) h = m - 1; else if (testOrder < order) l = m + 1; else { + var testId = test._id; + if (testId > id) h = m - 1; else { + if (!(testId < id)) return m; + l = m + 1; + } + } + } + return ~l; + } + function stableRemoveInactive(iterator, flagToClear) { + var array = iterator.array; + var next = iterator.i + 1; + while (next < array.length) { + var comp = array[next]; + if (comp._enabled && comp.node && comp.node._activeInHierarchy) ++next; else { + iterator.removeAt(next); + flagToClear && (comp._objFlags &= ~flagToClear); + } + } + } + var LifeCycleInvoker = cc.Class({ + __ctor__: function __ctor__(invokeFunc) { + var Iterator = jsArray.MutableForwardIterator; + this._zero = new Iterator([]); + this._neg = new Iterator([]); + this._pos = new Iterator([]); + false; + this._invoke = invokeFunc; + }, + statics: { + stableRemoveInactive: stableRemoveInactive + }, + add: null, + remove: null, + invoke: null + }); + function compareOrder(a, b) { + return a.constructor._executionOrder - b.constructor._executionOrder; + } + var OneOffInvoker = cc.Class({ + extends: LifeCycleInvoker, + add: function add(comp) { + var order = comp.constructor._executionOrder; + (0 === order ? this._zero : order < 0 ? this._neg : this._pos).array.push(comp); + }, + remove: function remove(comp) { + var order = comp.constructor._executionOrder; + (0 === order ? this._zero : order < 0 ? this._neg : this._pos).fastRemove(comp); + }, + cancelInactive: function cancelInactive(flagToClear) { + stableRemoveInactive(this._zero, flagToClear); + stableRemoveInactive(this._neg, flagToClear); + stableRemoveInactive(this._pos, flagToClear); + }, + invoke: function invoke() { + var compsNeg = this._neg; + if (compsNeg.array.length > 0) { + compsNeg.array.sort(compareOrder); + this._invoke(compsNeg); + compsNeg.array.length = 0; + } + this._invoke(this._zero); + this._zero.array.length = 0; + var compsPos = this._pos; + if (compsPos.array.length > 0) { + compsPos.array.sort(compareOrder); + this._invoke(compsPos); + compsPos.array.length = 0; + } + } + }); + var ReusableInvoker = cc.Class({ + extends: LifeCycleInvoker, + add: function add(comp) { + var order = comp.constructor._executionOrder; + if (0 === order) this._zero.array.push(comp); else { + var array = order < 0 ? this._neg.array : this._pos.array; + var i = sortedIndex(array, comp); + i < 0 && array.splice(~i, 0, comp); + } + }, + remove: function remove(comp) { + var order = comp.constructor._executionOrder; + if (0 === order) this._zero.fastRemove(comp); else { + var iterator = order < 0 ? this._neg : this._pos; + var i = sortedIndex(iterator.array, comp); + i >= 0 && iterator.removeAt(i); + } + }, + invoke: function invoke(dt) { + this._neg.array.length > 0 && this._invoke(this._neg, dt); + this._invoke(this._zero, dt); + this._pos.array.length > 0 && this._invoke(this._pos, dt); + } + }); + function enableInEditor(comp) { + if (!(comp._objFlags & IsEditorOnEnableCalled)) { + cc.engine.emit("component-enabled", comp.uuid); + comp._objFlags |= IsEditorOnEnableCalled; + } + } + function createInvokeImpl(indiePath, useDt, ensureFlag, fastPath) { + true; + var body = "var a=it.array;for(it.i=0;it.i= 0) { + jsArray.fastRemoveAt(this._deferredComps, index); + return; + } + !comp.start || comp._objFlags & IsStartCalled || this.startInvoker.remove(comp); + comp.update && this.updateInvoker.remove(comp); + comp.lateUpdate && this.lateUpdateInvoker.remove(comp); + }, + enableComp: function(comp, invoker) { + if (!(comp._objFlags & IsOnEnableCalled)) { + if (comp.onEnable) { + if (invoker) { + invoker.add(comp); + return; + } + comp.onEnable(); + var deactivatedDuringOnEnable = !comp.node._activeInHierarchy; + if (deactivatedDuringOnEnable) return; + } + this._onEnabled(comp); + } + }, + disableComp: function(comp) { + if (comp._objFlags & IsOnEnableCalled) { + comp.onDisable && comp.onDisable(); + this._onDisabled(comp); + } + }, + _scheduleImmediate: function _scheduleImmediate(comp) { + "function" !== typeof comp.start || comp._objFlags & IsStartCalled || this.startInvoker.add(comp); + "function" === typeof comp.update && this.updateInvoker.add(comp); + "function" === typeof comp.lateUpdate && this.lateUpdateInvoker.add(comp); + }, + _deferredSchedule: function _deferredSchedule() { + var comps = this._deferredComps; + for (var i = 0, len = comps.length; i < len; i++) this._scheduleImmediate(comps[i]); + comps.length = 0; + }, + _startForNewComps: function _startForNewComps() { + if (this._deferredComps.length > 0) { + this._deferredSchedule(); + this.startInvoker.invoke(); + } + }, + startPhase: function startPhase() { + this._updating = true; + this.startInvoker.invoke(); + this._startForNewComps(); + }, + updatePhase: function updatePhase(dt) { + this.updateInvoker.invoke(dt); + }, + lateUpdatePhase: function lateUpdatePhase(dt) { + this.lateUpdateInvoker.invoke(dt); + this._updating = false; + this._startForNewComps(); + } + }); + module.exports = ComponentScheduler; + }), { + "./platform/CCClass": 240, + "./platform/CCObject": 246, + "./platform/js": 261, + "./utils/misc": 325 + } ], + 145: [ (function(require, module, exports) { + "use strict"; + var AnimationAnimator = require("../../animation/animation-animator"); + var AnimationClip = require("../../animation/animation-clip"); + var EventTarget = require("../event/event-target"); + var js = require("../platform/js"); + var equalClips = function(clip1, clip2) { + return clip1 === clip2; + }; + var EventType = cc.Enum({ + PLAY: "play", + STOP: "stop", + PAUSE: "pause", + RESUME: "resume", + LASTFRAME: "lastframe", + FINISHED: "finished" + }); + var Animation = cc.Class({ + name: "cc.Animation", + extends: require("./CCComponent"), + mixins: [ EventTarget ], + editor: false, + statics: { + EventType: EventType + }, + ctor: function ctor() { + cc.EventTarget.call(this); + this._animator = null; + this._nameToState = js.createMap(true); + this._didInit = false; + this._currentClip = null; + }, + properties: { + _defaultClip: { + default: null, + type: AnimationClip + }, + defaultClip: { + type: AnimationClip, + get: function get() { + return this._defaultClip; + }, + set: function set(value) { + true; + return; + var contain; + }, + tooltip: false + }, + currentClip: { + get: function get() { + return this._currentClip; + }, + set: function set(value) { + this._currentClip = value; + }, + type: AnimationClip, + visible: false + }, + _writableClips: { + get: function get() { + return this._clips; + }, + set: function set(val) { + this._didInit = false; + this._clips = val; + this._init(); + }, + type: [ AnimationClip ] + }, + _clips: { + default: [], + type: [ AnimationClip ], + tooltip: false, + visible: true + }, + playOnLoad: { + default: false, + tooltip: false + } + }, + start: function start() { + if ((true, this.playOnLoad) && this._defaultClip) { + var isPlaying = this._animator && this._animator.isPlaying; + if (!isPlaying) { + var state = this.getAnimationState(this._defaultClip.name); + this._animator.playState(state); + } + } + }, + onEnable: function onEnable() { + this._animator && this._animator.resume(); + }, + onDisable: function onDisable() { + this._animator && this._animator.pause(); + }, + onDestroy: function onDestroy() { + this.stop(); + }, + getClips: function getClips() { + return this._clips; + }, + play: function play(name, startTime) { + var state = this.playAdditive(name, startTime); + this._animator.stopStatesExcept(state); + return state; + }, + playAdditive: function playAdditive(name, startTime) { + this._init(); + var state = this.getAnimationState(name || this._defaultClip && this._defaultClip.name); + if (state) { + this.enabled = true; + var animator = this._animator; + if (animator.isPlaying && state.isPlaying) if (state.isPaused) animator.resumeState(state); else { + animator.stopState(state); + animator.playState(state, startTime); + } else animator.playState(state, startTime); + this.enabledInHierarchy || animator.pause(); + this.currentClip = state.clip; + } + return state; + }, + stop: function stop(name) { + if (!this._didInit) return; + if (name) { + var state = this._nameToState[name]; + state && this._animator.stopState(state); + } else this._animator.stop(); + }, + pause: function pause(name) { + if (!this._didInit) return; + if (name) { + var state = this._nameToState[name]; + state && this._animator.pauseState(state); + } else this.enabled = false; + }, + resume: function resume(name) { + if (!this._didInit) return; + if (name) { + var state = this.getAnimationState(name); + state && this._animator.resumeState(state); + } else this.enabled = true; + }, + setCurrentTime: function setCurrentTime(time, name) { + this._init(); + if (name) { + var state = this.getAnimationState(name); + state && this._animator.setStateTime(state, time); + } else this._animator.setStateTime(time); + }, + getAnimationState: function getAnimationState(name) { + this._init(); + var state = this._nameToState[name]; + false; + state && !state.curveLoaded && this._animator._reloadClip(state); + return state || null; + }, + hasAnimationState: function hasAnimationState(name) { + this._init(); + return !!this._nameToState[name]; + }, + addClip: function addClip(clip, newName) { + if (!clip) { + cc.warnID(3900); + return; + } + this._init(); + cc.js.array.contains(this._clips, clip) || this._clips.push(clip); + newName = newName || clip.name; + var oldState = this._nameToState[newName]; + if (oldState) { + if (oldState.clip === clip) return oldState; + var index = this._clips.indexOf(oldState.clip); + -1 !== index && this._clips.splice(index, 1); + } + var newState = new cc.AnimationState(clip, newName); + this._nameToState[newName] = newState; + return newState; + }, + removeClip: function removeClip(clip, force) { + if (!clip) { + cc.warnID(3901); + return; + } + this._init(); + var state; + for (var name in this._nameToState) { + state = this._nameToState[name]; + if (equalClips(state.clip, clip)) break; + } + if (clip === this._defaultClip) { + if (!force) { + true; + cc.warnID(3902); + return; + } + this._defaultClip = null; + } + if (state && state.isPlaying) { + if (!force) { + true; + cc.warnID(3903); + return; + } + this.stop(state.name); + } + this._clips = this._clips.filter((function(item) { + return !equalClips(item, clip); + })); + state && delete this._nameToState[state.name]; + }, + sample: function sample(name) { + this._init(); + if (name) { + var state = this.getAnimationState(name); + state && state.sample(); + } else this._animator.sample(); + }, + on: function on(type, callback, target, useCapture) { + this._init(); + var ret = this._EventTargetOn(type, callback, target, useCapture); + if ("lastframe" === type) { + var states = this._nameToState; + for (var name in states) states[name]._lastframeEventOn = true; + } + return ret; + }, + off: function off(type, callback, target, useCapture) { + this._init(); + if ("lastframe" === type) { + var states = this._nameToState; + for (var name in states) states[name]._lastframeEventOn = false; + } + this._EventTargetOff(type, callback, target, useCapture); + }, + _init: function _init() { + if (this._didInit) return; + this._didInit = true; + this._animator = new AnimationAnimator(this.node, this); + this._createStates(); + }, + _createStates: function _createStates() { + this._nameToState = js.createMap(true); + var state = null; + var defaultClipState = false; + for (var i = 0; i < this._clips.length; ++i) { + var clip = this._clips[i]; + if (clip) { + state = new cc.AnimationState(clip); + false; + this._nameToState[state.name] = state; + equalClips(this._defaultClip, clip) && (defaultClipState = state); + } + } + if (this._defaultClip && !defaultClipState) { + state = new cc.AnimationState(this._defaultClip); + false; + this._nameToState[state.name] = state; + } + } + }); + Animation.prototype._EventTargetOn = EventTarget.prototype.on; + Animation.prototype._EventTargetOff = EventTarget.prototype.off; + cc.Animation = module.exports = Animation; + }), { + "../../animation/animation-animator": 10, + "../../animation/animation-clip": 11, + "../event/event-target": 187, + "../platform/js": 261, + "./CCComponent": 150 + } ], + 146: [ (function(require, module, exports) { + "use strict"; + var misc = require("../utils/misc"); + var Component = require("./CCComponent"); + var AudioClip = require("../assets/CCAudioClip"); + var AudioSource = cc.Class({ + name: "cc.AudioSource", + extends: Component, + editor: false, + ctor: function ctor() { + this.audio = new cc._Audio(); + }, + properties: { + _clip: { + default: null, + type: AudioClip + }, + _volume: 1, + _mute: false, + _loop: false, + _pausedFlag: { + default: false, + serializable: false + }, + _firstlyEnabled: true, + isPlaying: { + get: function get() { + var state = this.audio.getState(); + return state === cc._Audio.State.PLAYING; + }, + visible: false + }, + clip: { + get: function get() { + return this._clip; + }, + set: function set(value) { + if (value === this._clip) return; + if (!(value instanceof AudioClip)) return cc.error("Wrong type of AudioClip."); + this._clip = value; + this.audio.stop(); + this.audio.src = this._clip; + this.preload && this._clip._ensureLoaded(); + }, + type: AudioClip, + tooltip: false, + animatable: false + }, + volume: { + get: function get() { + return this._volume; + }, + set: function set(value) { + value = misc.clamp01(value); + this._volume = value; + this._mute || this.audio.setVolume(value); + return value; + }, + tooltip: false + }, + mute: { + get: function get() { + return this._mute; + }, + set: function set(value) { + this._mute = value; + this.audio.setVolume(value ? 0 : this._volume); + return value; + }, + animatable: false, + tooltip: false + }, + loop: { + get: function get() { + return this._loop; + }, + set: function set(value) { + this._loop = value; + this.audio.setLoop(value); + return value; + }, + animatable: false, + tooltip: false + }, + playOnLoad: { + default: false, + tooltip: false, + animatable: false + }, + preload: { + default: false, + animatable: false + } + }, + _pausedCallback: function _pausedCallback() { + var state = this.audio.getState(); + if (state === cc._Audio.State.PLAYING) { + this.audio.pause(); + this._pausedFlag = true; + } + }, + _restoreCallback: function _restoreCallback() { + this._pausedFlag && this.audio.resume(); + this._pausedFlag = false; + }, + onLoad: function onLoad() { + this.audio.src || (this.audio.src = this._clip); + this.preload && this._clip._ensureLoaded(); + }, + onEnable: function onEnable() { + if (this.playOnLoad && this._firstlyEnabled) { + this._firstlyEnabled = false; + this.play(); + } + cc.game.on(cc.game.EVENT_HIDE, this._pausedCallback, this); + cc.game.on(cc.game.EVENT_SHOW, this._restoreCallback, this); + }, + onDisable: function onDisable() { + this.stop(); + cc.game.off(cc.game.EVENT_HIDE, this._pausedCallback, this); + cc.game.off(cc.game.EVENT_SHOW, this._restoreCallback, this); + }, + onDestroy: function onDestroy() { + this.audio.destroy(); + }, + play: function play() { + if (false, !this._clip) return; + var audio = this.audio; + audio.setVolume(this._mute ? 0 : this._volume); + audio.setLoop(this._loop); + audio.setCurrentTime(0); + audio.play(); + }, + stop: function stop() { + this.audio.stop(); + }, + pause: function pause() { + this.audio.pause(); + }, + resume: function resume() { + this.audio.resume(); + }, + rewind: function rewind() { + this.audio.setCurrentTime(0); + }, + getCurrentTime: function getCurrentTime() { + return this.audio.getCurrentTime(); + }, + setCurrentTime: function setCurrentTime(time) { + this.audio.setCurrentTime(time); + return time; + }, + getDuration: function getDuration() { + return this.audio.getDuration(); + } + }); + cc.AudioSource = module.exports = AudioSource; + }), { + "../assets/CCAudioClip": 107, + "../utils/misc": 325, + "./CCComponent": 150 + } ], + 147: [ (function(require, module, exports) { + "use strict"; + var BlockEvents = [ "touchstart", "touchmove", "touchend", "mousedown", "mousemove", "mouseup", "mouseenter", "mouseleave", "mousewheel" ]; + function stopPropagation(event) { + event.stopPropagation(); + } + var BlockInputEvents = cc.Class({ + name: "cc.BlockInputEvents", + extends: require("./CCComponent"), + editor: { + menu: "i18n:MAIN_MENU.component.ui/Block Input Events", + inspector: "packages://inspector/inspectors/comps/block-input-events.js", + help: "i18n:COMPONENT.help_url.block_input_events" + }, + onEnable: function onEnable() { + for (var i = 0; i < BlockEvents.length; i++) this.node.on(BlockEvents[i], stopPropagation, this); + }, + onDisable: function onDisable() { + for (var i = 0; i < BlockEvents.length; i++) this.node.off(BlockEvents[i], stopPropagation, this); + } + }); + cc.BlockInputEvents = module.exports = BlockInputEvents; + }), { + "./CCComponent": 150 + } ], + 148: [ (function(require, module, exports) { + "use strict"; + var Component = require("./CCComponent"); + var GraySpriteState = require("../utils/gray-sprite-state"); + var Transition = cc.Enum({ + NONE: 0, + COLOR: 1, + SPRITE: 2, + SCALE: 3 + }); + var State = cc.Enum({ + NORMAL: 0, + HOVER: 1, + PRESSED: 2, + DISABLED: 3 + }); + var Button = cc.Class({ + name: "cc.Button", + extends: Component, + mixins: [ GraySpriteState ], + ctor: function ctor() { + this._pressed = false; + this._hovered = false; + this._fromColor = null; + this._toColor = null; + this._time = 0; + this._transitionFinished = true; + this._fromScale = cc.Vec2.ZERO; + this._toScale = cc.Vec2.ZERO; + this._originalScale = null; + this._graySpriteMaterial = null; + this._spriteMaterial = null; + this._sprite = null; + }, + editor: false, + properties: { + interactable: { + default: true, + tooltip: false, + notify: function notify() { + this._updateState(); + this.interactable || this._resetState(); + }, + animatable: false + }, + _resizeToTarget: { + animatable: false, + set: function set(value) { + value && this._resizeNodeToTargetNode(); + } + }, + enableAutoGrayEffect: { + default: false, + tooltip: false, + notify: function notify() { + this._updateDisabledState(true); + } + }, + transition: { + default: Transition.NONE, + tooltip: false, + type: Transition, + animatable: false, + notify: function notify(oldValue) { + this._updateTransition(oldValue); + }, + formerlySerializedAs: "transition" + }, + normalColor: { + default: cc.Color.WHITE, + displayName: "Normal", + tooltip: false, + notify: function notify() { + this.transition === Transition.Color && this._getButtonState() === State.NORMAL && (this._getTarget().opacity = this.normalColor.a); + this._updateState(); + } + }, + pressedColor: { + default: cc.color(211, 211, 211), + displayName: "Pressed", + tooltip: false, + notify: function notify() { + this.transition === Transition.Color && this._getButtonState() === State.PRESSED && (this._getTarget().opacity = this.pressedColor.a); + this._updateState(); + }, + formerlySerializedAs: "pressedColor" + }, + hoverColor: { + default: cc.Color.WHITE, + displayName: "Hover", + tooltip: false, + notify: function notify() { + this.transition === Transition.Color && this._getButtonState() === State.HOVER && (this._getTarget().opacity = this.hoverColor.a); + this._updateState(); + }, + formerlySerializedAs: "hoverColor" + }, + disabledColor: { + default: cc.color(124, 124, 124), + displayName: "Disabled", + tooltip: false, + notify: function notify() { + this.transition === Transition.Color && this._getButtonState() === State.DISABLED && (this._getTarget().opacity = this.disabledColor.a); + this._updateState(); + } + }, + duration: { + default: .1, + range: [ 0, 10 ], + tooltip: false + }, + zoomScale: { + default: 1.2, + tooltip: false + }, + normalSprite: { + default: null, + type: cc.SpriteFrame, + displayName: "Normal", + tooltip: false, + notify: function notify() { + this._updateState(); + } + }, + pressedSprite: { + default: null, + type: cc.SpriteFrame, + displayName: "Pressed", + tooltip: false, + formerlySerializedAs: "pressedSprite", + notify: function notify() { + this._updateState(); + } + }, + hoverSprite: { + default: null, + type: cc.SpriteFrame, + displayName: "Hover", + tooltip: false, + formerlySerializedAs: "hoverSprite", + notify: function notify() { + this._updateState(); + } + }, + disabledSprite: { + default: null, + type: cc.SpriteFrame, + displayName: "Disabled", + tooltip: false, + notify: function notify() { + this._updateState(); + } + }, + target: { + default: null, + type: cc.Node, + tooltip: false, + notify: function notify(oldValue) { + this._applyTarget(); + oldValue && this.target !== oldValue && this._unregisterTargetEvent(oldValue); + } + }, + clickEvents: { + default: [], + type: cc.Component.EventHandler, + tooltip: false + } + }, + statics: { + Transition: Transition + }, + __preload: function __preload() { + this._applyTarget(); + this._resetState(); + }, + _resetState: function _resetState() { + this._pressed = false; + this._hovered = false; + var target = this._getTarget(); + var transition = this.transition; + var originalScale = this._originalScale; + transition === Transition.COLOR && this.interactable ? this._setTargetColor(this.normalColor) : transition === Transition.SCALE && originalScale && target.setScale(originalScale.x, originalScale.y); + this._transitionFinished = true; + }, + onEnable: function onEnable() { + this.normalSprite && this.normalSprite.ensureLoadTexture(); + this.hoverSprite && this.hoverSprite.ensureLoadTexture(); + this.pressedSprite && this.pressedSprite.ensureLoadTexture(); + this.disabledSprite && this.disabledSprite.ensureLoadTexture(); + true; + this._registerNodeEvent(); + this._updateState(); + }, + onDisable: function onDisable() { + this._resetState(); + true; + this._unregisterNodeEvent(); + }, + _getTarget: function _getTarget() { + return this.target ? this.target : this.node; + }, + _onTargetSpriteFrameChanged: function _onTargetSpriteFrameChanged(comp) { + this.transition === Transition.SPRITE && this._setCurrentStateSprite(comp.spriteFrame); + }, + _onTargetColorChanged: function _onTargetColorChanged(color) { + this.transition === Transition.COLOR && this._setCurrentStateColor(color); + }, + _onTargetScaleChanged: function _onTargetScaleChanged() { + var target = this._getTarget(); + if (this._originalScale && (this.transition !== Transition.SCALE || this._transitionFinished)) { + this._originalScale.x = target.scaleX; + this._originalScale.y = target.scaleY; + } + }, + _setTargetColor: function _setTargetColor(color) { + var target = this._getTarget(); + var cloneColor = color.clone(); + target.opacity = cloneColor.a; + cloneColor.a = 255; + target.color = cloneColor; + }, + _getStateColor: function _getStateColor(state) { + switch (state) { + case State.NORMAL: + return this.normalColor; + + case State.HOVER: + return this.hoverColor; + + case State.PRESSED: + return this.pressedColor; + + case State.DISABLED: + return this.disabledColor; + } + }, + _getStateSprite: function _getStateSprite(state) { + switch (state) { + case State.NORMAL: + return this.normalSprite; + + case State.HOVER: + return this.hoverSprite; + + case State.PRESSED: + return this.pressedSprite; + + case State.DISABLED: + return this.disabledSprite; + } + }, + _setCurrentStateColor: function _setCurrentStateColor(color) { + switch (this._getButtonState()) { + case State.NORMAL: + this.normalColor = color; + break; + + case State.HOVER: + this.hoverColor = color; + break; + + case State.PRESSED: + this.pressedColor = color; + break; + + case State.DISABLED: + this.disabledColor = color; + } + }, + _setCurrentStateSprite: function _setCurrentStateSprite(spriteFrame) { + switch (this._getButtonState()) { + case State.NORMAL: + this.normalSprite = spriteFrame; + break; + + case State.HOVER: + this.hoverSprite = spriteFrame; + break; + + case State.PRESSED: + this.pressedSprite = spriteFrame; + break; + + case State.DISABLED: + this.disabledSprite = spriteFrame; + } + }, + update: function update(dt) { + var target = this._getTarget(); + if (this._transitionFinished) return; + if (this.transition !== Transition.COLOR && this.transition !== Transition.SCALE) return; + this.time += dt; + var ratio = 1; + this.duration > 0 && (ratio = this.time / this.duration); + ratio >= 1 && (ratio = 1); + if (this.transition === Transition.COLOR) { + var color = this._fromColor.lerp(this._toColor, ratio); + this._setTargetColor(color); + } else this.transition === Transition.SCALE && this._originalScale && (target.scale = this._fromScale.lerp(this._toScale, ratio)); + 1 === ratio && (this._transitionFinished = true); + }, + _registerNodeEvent: function _registerNodeEvent() { + this.node.on(cc.Node.EventType.TOUCH_START, this._onTouchBegan, this); + this.node.on(cc.Node.EventType.TOUCH_MOVE, this._onTouchMove, this); + this.node.on(cc.Node.EventType.TOUCH_END, this._onTouchEnded, this); + this.node.on(cc.Node.EventType.TOUCH_CANCEL, this._onTouchCancel, this); + this.node.on(cc.Node.EventType.MOUSE_ENTER, this._onMouseMoveIn, this); + this.node.on(cc.Node.EventType.MOUSE_LEAVE, this._onMouseMoveOut, this); + }, + _unregisterNodeEvent: function _unregisterNodeEvent() { + this.node.off(cc.Node.EventType.TOUCH_START, this._onTouchBegan, this); + this.node.off(cc.Node.EventType.TOUCH_MOVE, this._onTouchMove, this); + this.node.off(cc.Node.EventType.TOUCH_END, this._onTouchEnded, this); + this.node.off(cc.Node.EventType.TOUCH_CANCEL, this._onTouchCancel, this); + this.node.off(cc.Node.EventType.MOUSE_ENTER, this._onMouseMoveIn, this); + this.node.off(cc.Node.EventType.MOUSE_LEAVE, this._onMouseMoveOut, this); + }, + _registerTargetEvent: function _registerTargetEvent(target) { + false; + target.on(cc.Node.EventType.SCALE_CHANGED, this._onTargetScaleChanged, this); + }, + _unregisterTargetEvent: function _unregisterTargetEvent(target) { + false; + target.off(cc.Node.EventType.SCALE_CHANGED, this._onTargetScaleChanged, this); + }, + _getTargetSprite: function _getTargetSprite(target) { + var sprite = null; + target && (sprite = target.getComponent(cc.Sprite)); + return sprite; + }, + _applyTarget: function _applyTarget() { + var target = this._getTarget(); + this._sprite = this._getTargetSprite(target); + this._originalScale || (this._originalScale = cc.Vec2.ZERO); + this._originalScale.x = target.scaleX; + this._originalScale.y = target.scaleY; + this._registerTargetEvent(target); + }, + _onTouchBegan: function _onTouchBegan(event) { + if (!this.interactable || !this.enabledInHierarchy) return; + this._pressed = true; + this._updateState(); + event.stopPropagation(); + }, + _onTouchMove: function _onTouchMove(event) { + if (!this.interactable || !this.enabledInHierarchy || !this._pressed) return; + var touch = event.touch; + var hit = this.node._hitTest(touch.getLocation()); + var target = this._getTarget(); + var originalScale = this._originalScale; + if (this.transition === Transition.SCALE && originalScale) if (hit) { + this._fromScale.x = originalScale.x; + this._fromScale.y = originalScale.y; + this._toScale.x = originalScale.x * this.zoomScale; + this._toScale.y = originalScale.y * this.zoomScale; + this._transitionFinished = false; + } else { + this.time = 0; + this._transitionFinished = true; + target.setScale(originalScale.x, originalScale.y); + } else { + var state; + state = hit ? State.PRESSED : State.NORMAL; + this._applyTransition(state); + } + event.stopPropagation(); + }, + _onTouchEnded: function _onTouchEnded(event) { + if (!this.interactable || !this.enabledInHierarchy) return; + if (this._pressed) { + cc.Component.EventHandler.emitEvents(this.clickEvents, event); + this.node.emit("click", this); + } + this._pressed = false; + this._updateState(); + event.stopPropagation(); + }, + _onTouchCancel: function _onTouchCancel() { + if (!this.interactable || !this.enabledInHierarchy) return; + this._pressed = false; + this._updateState(); + }, + _onMouseMoveIn: function _onMouseMoveIn() { + if (this._pressed || !this.interactable || !this.enabledInHierarchy) return; + if (this.transition === Transition.SPRITE && !this.hoverSprite) return; + if (!this._hovered) { + this._hovered = true; + this._updateState(); + } + }, + _onMouseMoveOut: function _onMouseMoveOut() { + if (this._hovered) { + this._hovered = false; + this._updateState(); + } + }, + _updateState: function _updateState() { + var state = this._getButtonState(); + this._applyTransition(state); + this._updateDisabledState(); + }, + _getButtonState: function _getButtonState() { + var state; + state = this.interactable ? this._pressed ? State.PRESSED : this._hovered ? State.HOVER : State.NORMAL : State.DISABLED; + return state; + }, + _updateColorTransitionImmediately: function _updateColorTransitionImmediately(state) { + var color = this._getStateColor(state); + this._setTargetColor(color); + this._fromColor = color.clone(); + this._toColor = color; + }, + _updateColorTransition: function _updateColorTransition(state) { + if (false, state === State.DISABLED) this._updateColorTransitionImmediately(state); else { + var target = this._getTarget(); + var color = this._getStateColor(state); + this._fromColor = target.color.clone(); + this._toColor = color; + this.time = 0; + this._transitionFinished = false; + } + }, + _updateSpriteTransition: function _updateSpriteTransition(state) { + var sprite = this._getStateSprite(state); + this._sprite && sprite && (this._sprite.spriteFrame = sprite); + }, + _updateScaleTransition: function _updateScaleTransition(state) { + state === State.PRESSED ? this._zoomUp() : this._zoomBack(); + }, + _zoomUp: function _zoomUp() { + if (!this._originalScale) return; + this._fromScale.x = this._originalScale.x; + this._fromScale.y = this._originalScale.y; + this._toScale.x = this._originalScale.x * this.zoomScale; + this._toScale.y = this._originalScale.y * this.zoomScale; + this.time = 0; + this._transitionFinished = false; + }, + _zoomBack: function _zoomBack() { + if (!this._originalScale) return; + var target = this._getTarget(); + this._fromScale.x = target.scaleX; + this._fromScale.y = target.scaleY; + this._toScale.x = this._originalScale.x; + this._toScale.y = this._originalScale.y; + this.time = 0; + this._transitionFinished = false; + }, + _updateTransition: function _updateTransition(oldTransition) { + oldTransition === Transition.COLOR ? this._updateColorTransitionImmediately(State.NORMAL) : oldTransition === Transition.SPRITE && this._updateSpriteTransition(State.NORMAL); + this._updateState(); + }, + _applyTransition: function _applyTransition(state) { + var transition = this.transition; + transition === Transition.COLOR ? this._updateColorTransition(state) : transition === Transition.SPRITE ? this._updateSpriteTransition(state) : transition === Transition.SCALE && this._updateScaleTransition(state); + }, + _resizeNodeToTargetNode: false, + _updateDisabledState: function _updateDisabledState(force) { + if (!this._sprite) return; + if (this.enableAutoGrayEffect || force) { + var useGrayMaterial = false; + this.transition === Transition.SPRITE && this.disabledSprite || (useGrayMaterial = this.enableAutoGrayEffect && !this.interactable); + this._switchGrayMaterial(useGrayMaterial, this._sprite); + } + } + }); + cc.Button = module.exports = Button; + }), { + "../utils/gray-sprite-state": 322, + "./CCComponent": 150 + } ], + 149: [ (function(require, module, exports) { + "use strict"; + var Camera = require("../camera/CCCamera"); + var Component = require("./CCComponent"); + function resetWidgetComponent(canvas) { + var widget = canvas.node.getComponent(cc.Widget); + widget || (widget = canvas.node.addComponent(cc.Widget)); + widget.isAlignTop = true; + widget.isAlignBottom = true; + widget.isAlignLeft = true; + widget.isAlignRight = true; + widget.top = 0; + widget.bottom = 0; + widget.left = 0; + widget.right = 0; + } + var Canvas = cc.Class({ + name: "cc.Canvas", + extends: Component, + editor: false, + resetInEditor: false, + statics: { + instance: null + }, + properties: { + _designResolution: cc.size(960, 640), + designResolution: { + get: function get() { + return cc.size(this._designResolution); + }, + set: function set(value) { + this._designResolution.width = value.width; + this._designResolution.height = value.height; + this.applySettings(); + }, + tooltip: false + }, + _fitWidth: false, + _fitHeight: true, + fitHeight: { + get: function get() { + return this._fitHeight; + }, + set: function set(value) { + if (this._fitHeight !== value) { + this._fitHeight = value; + this.applySettings(); + } + }, + tooltip: false + }, + fitWidth: { + get: function get() { + return this._fitWidth; + }, + set: function set(value) { + if (this._fitWidth !== value) { + this._fitWidth = value; + this.applySettings(); + } + }, + tooltip: false + } + }, + _fitDesignResolution: false, + __preload: function __preload() { + var Flags; + false; + if (Canvas.instance) return cc.warnID(6700, this.node.name, Canvas.instance.node.name); + Canvas.instance = this; + this.applySettings(); + var widget = this.getComponent(cc.Widget); + !!widget && widget.updateAlignment(); + false; + }, + start: function start() { + if (!Camera.main && cc.game.renderType !== cc.game.RENDER_TYPE_CANVAS) { + var cameraNode = new cc.Node("Main Camera"); + cameraNode.parent = this.node; + cameraNode.setSiblingIndex(0); + var camera = cameraNode.addComponent(Camera); + var ClearFlags = Camera.ClearFlags; + camera.clearFlags = ClearFlags.COLOR | ClearFlags.DEPTH | ClearFlags.STENCIL; + camera.depth = -1; + } + }, + onDestroy: function onDestroy() { + false; + Canvas.instance === this && (Canvas.instance = null); + }, + applySettings: function applySettings() { + var ResolutionPolicy = cc.ResolutionPolicy; + var policy; + policy = this.fitHeight && this.fitWidth ? ResolutionPolicy.SHOW_ALL : this.fitHeight || this.fitWidth ? this.fitWidth ? ResolutionPolicy.FIXED_WIDTH : ResolutionPolicy.FIXED_HEIGHT : ResolutionPolicy.NO_BORDER; + var designRes = this._designResolution; + false; + cc.view.setDesignResolutionSize(designRes.width, designRes.height, policy); + } + }); + cc.Canvas = module.exports = Canvas; + }), { + "../camera/CCCamera": 135, + "./CCComponent": 150 + } ], + 150: [ (function(require, module, exports) { + "use strict"; + var CCObject = require("../platform/CCObject"); + var js = require("../platform/js"); + var idGenerater = new (require("../platform/id-generater"))("Comp"); + var IsOnEnableCalled = CCObject.Flags.IsOnEnableCalled; + var IsOnLoadCalled = CCObject.Flags.IsOnLoadCalled; + var ActionManagerExist = !!cc.ActionManager; + var Component = cc.Class({ + name: "cc.Component", + extends: CCObject, + ctor: function() { + this._id = idGenerater.getNewId(); + this.__eventTargets = []; + }, + properties: { + node: { + default: null, + visible: false + }, + name: { + get: function get() { + if (this._name) return this._name; + var className = cc.js.getClassName(this); + var trimLeft = className.lastIndexOf("."); + trimLeft >= 0 && (className = className.slice(trimLeft + 1)); + return this.node.name + "<" + className + ">"; + }, + set: function set(value) { + this._name = value; + }, + visible: false + }, + uuid: { + get: function get() { + return this._id; + }, + visible: false + }, + __scriptAsset: false, + _enabled: true, + enabled: { + get: function get() { + return this._enabled; + }, + set: function set(value) { + if (this._enabled !== value) { + this._enabled = value; + if (this.node._activeInHierarchy) { + var compScheduler = cc.director._compScheduler; + value ? compScheduler.enableComp(this) : compScheduler.disableComp(this); + } + } + }, + visible: false, + animatable: true + }, + enabledInHierarchy: { + get: function get() { + var _this$node, _this$node2, _this$node2$_parent; + false; + return this._enabled && this.node && this.node._activeInHierarchy; + }, + visible: false + }, + _isOnLoadCalled: { + get: function get() { + return this._objFlags & IsOnLoadCalled; + } + } + }, + update: null, + lateUpdate: null, + __preload: null, + onLoad: null, + start: null, + onEnable: null, + onDisable: null, + onDestroy: null, + onFocusInEditor: null, + onLostFocusInEditor: null, + resetInEditor: null, + addComponent: function addComponent(typeOrClassName) { + return this.node.addComponent(typeOrClassName); + }, + getComponent: function getComponent(typeOrClassName) { + return this.node.getComponent(typeOrClassName); + }, + getComponents: function getComponents(typeOrClassName) { + return this.node.getComponents(typeOrClassName); + }, + getComponentInChildren: function getComponentInChildren(typeOrClassName) { + return this.node.getComponentInChildren(typeOrClassName); + }, + getComponentsInChildren: function getComponentsInChildren(typeOrClassName) { + return this.node.getComponentsInChildren(typeOrClassName); + }, + _getLocalBounds: null, + onRestore: null, + destroy: function destroy() { + var depend; + false; + this._super() && this._enabled && this.node._activeInHierarchy && cc.director._compScheduler.disableComp(this); + }, + _onPreDestroy: function _onPreDestroy() { + ActionManagerExist && cc.director.getActionManager().removeAllActionsFromTarget(this); + this.unscheduleAllCallbacks(); + var eventTargets = this.__eventTargets; + for (var i = eventTargets.length - 1; i >= 0; --i) { + var target = eventTargets[i]; + target && target.targetOff(this); + } + eventTargets.length = 0; + false; + cc.director._nodeActivator.destroyComp(this); + this.node._removeComponent(this); + }, + _instantiate: function _instantiate(cloned) { + cloned || (cloned = cc.instantiate._clone(this, this)); + cloned.node = null; + return cloned; + }, + schedule: function schedule(callback, interval, repeat, delay) { + cc.assertID(callback, 1619); + interval = interval || 0; + cc.assertID(interval >= 0, 1620); + repeat = isNaN(repeat) ? cc.macro.REPEAT_FOREVER : repeat; + delay = delay || 0; + var scheduler = cc.director.getScheduler(); + var paused = scheduler.isTargetPaused(this); + scheduler.schedule(callback, this, interval, repeat, delay, paused); + }, + scheduleOnce: function scheduleOnce(callback, delay) { + this.schedule(callback, 0, 0, delay); + }, + unschedule: function unschedule(callback_fn) { + if (!callback_fn) return; + cc.director.getScheduler().unschedule(callback_fn, this); + }, + unscheduleAllCallbacks: function unscheduleAllCallbacks() { + cc.director.getScheduler().unscheduleAllForTarget(this); + } + }); + Component._requireComponent = null; + Component._executionOrder = 0; + false; + false, false; + js.value(Component, "_registerEditorProps", (function(cls, props) { + var reqComp = props.requireComponent; + reqComp && (cls._requireComponent = reqComp); + var order = props.executionOrder; + order && "number" === typeof order && (cls._executionOrder = order); + (false, false) && "disallowMultiple" in props && (cls._disallowMultiple = cls); + var name; + var key; + var val; + var willExecuteInEditMode; + false, false; + })); + Component.prototype.__scriptUuid = ""; + cc.Component = module.exports = Component; + }), { + "../platform/CCObject": 246, + "../platform/id-generater": 257, + "../platform/js": 261 + } ], + 151: [ (function(require, module, exports) { + "use strict"; + cc.Component.EventHandler = cc.Class({ + name: "cc.ClickEvent", + properties: { + target: { + default: null, + type: cc.Node + }, + component: "", + _componentId: "", + _componentName: { + get: function get() { + this._genCompIdIfNeeded(); + return this._compId2Name(this._componentId); + }, + set: function set(value) { + this._componentId = this._compName2Id(value); + } + }, + handler: { + default: "" + }, + customEventData: { + default: "" + } + }, + statics: { + emitEvents: function emitEvents(events) { + var args; + if (arguments.length > 0) { + args = new Array(arguments.length - 1); + for (var i = 0, l = args.length; i < l; i++) args[i] = arguments[i + 1]; + } + for (var _i = 0, _l = events.length; _i < _l; _i++) { + var event = events[_i]; + if (!(event instanceof cc.Component.EventHandler)) continue; + event.emit(args); + } + } + }, + emit: function emit(params) { + var target = this.target; + if (!cc.isValid(target)) return; + this._genCompIdIfNeeded(); + var compType = cc.js._getClassById(this._componentId); + var comp = target.getComponent(compType); + if (!cc.isValid(comp)) return; + var handler = comp[this.handler]; + if ("function" !== typeof handler) return; + if (null != this.customEventData && "" !== this.customEventData) { + params = params.slice(); + params.push(this.customEventData); + } + handler.apply(comp, params); + }, + _compName2Id: function _compName2Id(compName) { + var comp = cc.js.getClassByName(compName); + return cc.js._getClassId(comp); + }, + _compId2Name: function _compId2Name(compId) { + var comp = cc.js._getClassById(compId); + return cc.js.getClassName(comp); + }, + _genCompIdIfNeeded: function _genCompIdIfNeeded() { + if (!this._componentId) { + this._componentName = this.component; + this.component = ""; + } + } + }); + }), {} ], + 152: [ (function(require, module, exports) { + "use strict"; + var macro = require("../platform/CCMacro"); + var RenderComponent = require("./CCRenderComponent"); + var Material = require("../assets/material/CCMaterial"); + var LabelFrame = require("../renderer/utils/label/label-frame"); + var BlendFunc = require("../utils/blend-func"); + var deleteFromDynamicAtlas = require("../renderer/utils/utils").deleteFromDynamicAtlas; + var HorizontalAlign = macro.TextAlignment; + var VerticalAlign = macro.VerticalTextAlignment; + var Overflow = cc.Enum({ + NONE: 0, + CLAMP: 1, + SHRINK: 2, + RESIZE_HEIGHT: 3 + }); + var CacheMode = cc.Enum({ + NONE: 0, + BITMAP: 1, + CHAR: 2 + }); + var BOLD_FLAG = 1; + var ITALIC_FLAG = 2; + var UNDERLINE_FLAG = 4; + var Label = cc.Class({ + name: "cc.Label", + extends: RenderComponent, + mixins: [ BlendFunc ], + ctor: function ctor() { + false; + this._actualFontSize = 0; + this._assemblerData = null; + this._frame = null; + this._ttfTexture = null; + this._letterTexture = null; + cc.game.renderType === cc.game.RENDER_TYPE_CANVAS ? this._updateMaterial = this._updateMaterialCanvas : this._updateMaterial = this._updateMaterialWebgl; + }, + editor: false, + properties: { + _string: { + default: "", + formerlySerializedAs: "_N$string" + }, + string: { + get: function get() { + return this._string; + }, + set: function set(value) { + var oldValue = this._string; + this._string = "" + value; + this.string !== oldValue && this.setVertsDirty(); + this._checkStringEmpty(); + }, + multiline: true, + tooltip: false + }, + horizontalAlign: { + default: HorizontalAlign.LEFT, + type: HorizontalAlign, + tooltip: false, + notify: function notify(oldValue) { + if (this.horizontalAlign === oldValue) return; + this.setVertsDirty(); + }, + animatable: false + }, + verticalAlign: { + default: VerticalAlign.TOP, + type: VerticalAlign, + tooltip: false, + notify: function notify(oldValue) { + if (this.verticalAlign === oldValue) return; + this.setVertsDirty(); + }, + animatable: false + }, + actualFontSize: { + displayName: "Actual Font Size", + animatable: false, + readonly: true, + get: function get() { + return this._actualFontSize; + }, + tooltip: false + }, + _fontSize: 40, + fontSize: { + get: function get() { + return this._fontSize; + }, + set: function set(value) { + if (this._fontSize === value) return; + this._fontSize = value; + this.setVertsDirty(); + }, + range: [ 0, 512 ], + tooltip: false + }, + fontFamily: { + default: "Arial", + tooltip: false, + notify: function notify(oldValue) { + if (this.fontFamily === oldValue) return; + this.setVertsDirty(); + }, + animatable: false + }, + _lineHeight: 40, + lineHeight: { + get: function get() { + return this._lineHeight; + }, + set: function set(value) { + if (this._lineHeight === value) return; + this._lineHeight = value; + this.setVertsDirty(); + }, + tooltip: false + }, + overflow: { + default: Overflow.NONE, + type: Overflow, + tooltip: false, + notify: function notify(oldValue) { + if (this.overflow === oldValue) return; + this.setVertsDirty(); + }, + animatable: false + }, + _enableWrapText: true, + enableWrapText: { + get: function get() { + return this._enableWrapText; + }, + set: function set(value) { + if (this._enableWrapText === value) return; + this._enableWrapText = value; + this.setVertsDirty(); + }, + animatable: false, + tooltip: false + }, + _N$file: null, + font: { + get: function get() { + return this._N$file; + }, + set: function set(value) { + if (this.font === value) return; + value || (this._isSystemFontUsed = true); + false; + this._N$file = value; + value && this._isSystemFontUsed && (this._isSystemFontUsed = false); + if (!this.enabledInHierarchy) return; + this._forceUpdateRenderData(); + }, + type: cc.Font, + tooltip: false, + animatable: false + }, + _isSystemFontUsed: true, + useSystemFont: { + get: function get() { + return this._isSystemFontUsed; + }, + set: function set(value) { + if (this._isSystemFontUsed === value) return; + this._isSystemFontUsed = !!value; + false; + if (value) { + this.font = null; + if (!this.enabledInHierarchy) return; + this._forceUpdateRenderData(); + } + this.markForValidate(); + }, + animatable: false, + tooltip: false + }, + _bmFontOriginalSize: { + displayName: "BMFont Original Size", + get: function get() { + return this._N$file instanceof cc.BitmapFont ? this._N$file.fontSize : -1; + }, + visible: true, + animatable: false + }, + _spacingX: 0, + spacingX: { + get: function get() { + return this._spacingX; + }, + set: function set(value) { + this._spacingX = value; + this.setVertsDirty(); + }, + tooltip: false + }, + _batchAsBitmap: false, + cacheMode: { + default: CacheMode.NONE, + type: CacheMode, + tooltip: false, + notify: function notify(oldValue) { + if (this.cacheMode === oldValue) return; + oldValue !== CacheMode.BITMAP || this.font instanceof cc.BitmapFont || this._frame && this._frame._resetDynamicAtlasFrame(); + oldValue === CacheMode.CHAR && (this._ttfTexture = null); + if (!this.enabledInHierarchy) return; + this._forceUpdateRenderData(); + }, + animatable: false + }, + _styleFlags: 0, + enableBold: { + get: function get() { + return !!(this._styleFlags & BOLD_FLAG); + }, + set: function set(value) { + value ? this._styleFlags |= BOLD_FLAG : this._styleFlags &= ~BOLD_FLAG; + this.setVertsDirty(); + }, + animatable: false, + tooltip: false + }, + enableItalic: { + get: function get() { + return !!(this._styleFlags & ITALIC_FLAG); + }, + set: function set(value) { + value ? this._styleFlags |= ITALIC_FLAG : this._styleFlags &= ~ITALIC_FLAG; + this.setVertsDirty(); + }, + animatable: false, + tooltip: false + }, + enableUnderline: { + get: function get() { + return !!(this._styleFlags & UNDERLINE_FLAG); + }, + set: function set(value) { + value ? this._styleFlags |= UNDERLINE_FLAG : this._styleFlags &= ~UNDERLINE_FLAG; + this.setVertsDirty(); + }, + animatable: false, + tooltip: false + }, + _underlineHeight: 0, + underlineHeight: { + get: function get() { + return this._underlineHeight; + }, + set: function set(value) { + if (this._underlineHeight === value) return; + this._underlineHeight = value; + this.setVertsDirty(); + }, + tooltip: false + } + }, + statics: { + HorizontalAlign: HorizontalAlign, + VerticalAlign: VerticalAlign, + Overflow: Overflow, + CacheMode: CacheMode, + _shareAtlas: null, + clearCharCache: function clearCharCache() { + Label._shareAtlas && Label._shareAtlas.clearAllCache(); + } + }, + onLoad: function onLoad() { + if (this._batchAsBitmap && this.cacheMode === CacheMode.NONE) { + this.cacheMode = CacheMode.BITMAP; + this._batchAsBitmap = false; + } + cc.game.renderType === cc.game.RENDER_TYPE_CANVAS && (this.cacheMode = CacheMode.NONE); + }, + onEnable: function onEnable() { + this._super(); + this.node.on(cc.Node.EventType.SIZE_CHANGED, this._nodeSizeChanged, this); + this.node.on(cc.Node.EventType.ANCHOR_CHANGED, this.setVertsDirty, this); + this.node.on(cc.Node.EventType.COLOR_CHANGED, this._nodeColorChanged, this); + this._forceUpdateRenderData(); + }, + onDisable: function onDisable() { + this._super(); + this.node.off(cc.Node.EventType.SIZE_CHANGED, this._nodeSizeChanged, this); + this.node.off(cc.Node.EventType.ANCHOR_CHANGED, this.setVertsDirty, this); + this.node.off(cc.Node.EventType.COLOR_CHANGED, this._nodeColorChanged, this); + }, + onDestroy: function onDestroy() { + this._assembler && this._assembler._resetAssemblerData && this._assembler._resetAssemblerData(this._assemblerData); + this._assemblerData = null; + this._letterTexture = null; + if (this._ttfTexture) { + this._ttfTexture.destroy(); + this._ttfTexture = null; + } + this._super(); + }, + _nodeSizeChanged: function _nodeSizeChanged() { + (false, this.overflow !== Overflow.NONE) && this.setVertsDirty(); + }, + _nodeColorChanged: function _nodeColorChanged() { + this.font instanceof cc.BitmapFont || this.setVertsDirty(); + }, + setVertsDirty: function setVertsDirty() { + false; + this._super(); + }, + _updateColor: function _updateColor() { + this.font instanceof cc.BitmapFont || this._srcBlendFactor === cc.macro.BlendFactor.SRC_ALPHA && this.node._renderFlag & cc.RenderFlow.FLAG_OPACITY || this.setVertsDirty(); + RenderComponent.prototype._updateColor.call(this); + }, + _validateRender: function _validateRender() { + if (!this.string) { + this.disableRender(); + return; + } + if (this._materials[0]) { + var font = this.font; + if (!(font instanceof cc.BitmapFont)) return; + var spriteFrame = font.spriteFrame; + if (spriteFrame && spriteFrame.textureLoaded() && font._fntConfig) return; + } + this.disableRender(); + }, + _resetAssembler: function _resetAssembler() { + this._resetFrame(); + RenderComponent.prototype._resetAssembler.call(this); + }, + _resetFrame: function _resetFrame() { + if (this._frame && !(this.font instanceof cc.BitmapFont)) { + deleteFromDynamicAtlas(this, this._frame); + this._frame = null; + } + }, + _checkStringEmpty: function _checkStringEmpty() { + this.markForRender(!!this.string); + }, + _on3DNodeChanged: function _on3DNodeChanged() { + this._resetAssembler(); + this._applyFontTexture(); + }, + _onBMFontTextureLoaded: function _onBMFontTextureLoaded() { + this._frame._texture = this.font.spriteFrame._texture; + this.markForRender(true); + this._updateMaterial(); + this._assembler && this._assembler.updateRenderData(this); + }, + _onBlendChanged: function _onBlendChanged() { + if (!this.useSystemFont || !this.enabledInHierarchy) return; + this._forceUpdateRenderData(); + }, + _applyFontTexture: function _applyFontTexture() { + var font = this.font; + if (font instanceof cc.BitmapFont) { + var spriteFrame = font.spriteFrame; + this._frame = spriteFrame; + spriteFrame && spriteFrame.onTextureLoaded(this._onBMFontTextureLoaded, this); + } else { + if (!this._nativeTTF()) { + this._frame || (this._frame = new LabelFrame()); + if (this.cacheMode === CacheMode.CHAR) { + this._letterTexture = this._assembler._getAssemblerData(); + this._frame._refreshTexture(this._letterTexture); + } else if (!this._ttfTexture) { + this._ttfTexture = new cc.Texture2D(); + this._assemblerData = this._assembler._getAssemblerData(); + this._ttfTexture.initWithElement(this._assemblerData.canvas); + } + if (this.cacheMode !== CacheMode.CHAR) { + this._frame._resetDynamicAtlasFrame(); + this._frame._refreshTexture(this._ttfTexture); + this._srcBlendFactor === cc.macro.BlendFactor.ONE && true && this._ttfTexture.setPremultiplyAlpha(true); + } + this._updateMaterial(); + } + this._assembler && this._assembler.updateRenderData(this); + } + this.markForValidate(); + }, + _updateMaterialCanvas: function _updateMaterialCanvas() { + if (!this._frame) return; + this._frame._texture._nativeUrl = this.uuid + "_texture"; + }, + _updateMaterialWebgl: function _updateMaterialWebgl() { + var material = this.getMaterial(0); + if (this._nativeTTF()) { + material && this._assembler._updateTTFMaterial(this); + return; + } + if (!this._frame) return; + material && material.setProperty("texture", this._frame._texture); + BlendFunc.prototype._updateMaterial.call(this); + }, + _forceUseCanvas: false, + _useNativeTTF: function _useNativeTTF() { + return cc.macro.ENABLE_NATIVE_TTF_RENDERER && !this._forceUseCanvas; + }, + _nativeTTF: function _nativeTTF() { + return this._useNativeTTF() && !!this._assembler && !!this._assembler._updateTTFMaterial; + }, + _forceUpdateRenderData: function _forceUpdateRenderData() { + this.setVertsDirty(); + this._resetAssembler(); + this._applyFontTexture(); + }, + _enableBold: function _enableBold(enabled) { + true; + cc.warn("`label._enableBold` is deprecated, use `label.enableBold = true` instead please"); + this.enableBold = !!enabled; + }, + _enableItalics: function _enableItalics(enabled) { + true; + cc.warn("`label._enableItalics` is deprecated, use `label.enableItalics = true` instead please"); + this.enableItalic = !!enabled; + }, + _enableUnderline: function _enableUnderline(enabled) { + true; + cc.warn("`label._enableUnderline` is deprecated, use `label.enableUnderline = true` instead please"); + this.enableUnderline = !!enabled; + } + }); + cc.Label = module.exports = Label; + }), { + "../assets/material/CCMaterial": 125, + "../platform/CCMacro": 245, + "../renderer/utils/label/label-frame": 277, + "../renderer/utils/utils": 280, + "../utils/blend-func": 319, + "./CCRenderComponent": 161 + } ], + 153: [ (function(require, module, exports) { + "use strict"; + var LabelOutline = cc.Class({ + name: "cc.LabelOutline", + extends: require("./CCComponent"), + editor: false, + properties: { + _color: cc.Color.WHITE, + _width: 1, + color: { + tooltip: false, + get: function get() { + return this._color.clone(); + }, + set: function set(value) { + this._color.equals(value) || this._color.set(value); + this._updateRenderData(); + } + }, + width: { + tooltip: false, + get: function get() { + return this._width; + }, + set: function set(value) { + if (this._width === value) return; + this._width = value; + this._updateRenderData(); + }, + range: [ 0, 512 ] + } + }, + onEnable: function onEnable() { + this._updateRenderData(); + }, + onDisable: function onDisable() { + this._updateRenderData(); + }, + _updateRenderData: function _updateRenderData() { + var label = this.node.getComponent(cc.Label); + label && label.setVertsDirty(); + } + }); + cc.LabelOutline = module.exports = LabelOutline; + }), { + "./CCComponent": 150 + } ], + 154: [ (function(require, module, exports) { + "use strict"; + var LabelShadow = cc.Class({ + name: "cc.LabelShadow", + extends: require("./CCComponent"), + editor: false, + properties: { + _color: cc.Color.WHITE, + _offset: cc.v2(2, 2), + _blur: 2, + color: { + tooltip: false, + get: function get() { + return this._color.clone(); + }, + set: function set(value) { + this._color.equals(value) || this._color.set(value); + this._updateRenderData(); + } + }, + offset: { + tooltip: false, + get: function get() { + return this._offset; + }, + set: function set(value) { + this._offset = value; + this._updateRenderData(); + } + }, + blur: { + tooltip: false, + get: function get() { + return this._blur; + }, + set: function set(value) { + this._blur = value; + this._updateRenderData(); + }, + range: [ 0, 1024 ] + } + }, + onEnable: function onEnable() { + this._updateRenderData(); + }, + onDisable: function onDisable() { + this._updateRenderData(); + }, + _updateRenderData: function _updateRenderData() { + var label = this.node.getComponent(cc.Label); + label && label.setVertsDirty(); + } + }); + cc.LabelShadow = module.exports = LabelShadow; + }), { + "./CCComponent": 150 + } ], + 155: [ (function(require, module, exports) { + "use strict"; + var NodeEvent = require("../CCNode").EventType; + var Type = cc.Enum({ + NONE: 0, + HORIZONTAL: 1, + VERTICAL: 2, + GRID: 3 + }); + var ResizeMode = cc.Enum({ + NONE: 0, + CONTAINER: 1, + CHILDREN: 2 + }); + var AxisDirection = cc.Enum({ + HORIZONTAL: 0, + VERTICAL: 1 + }); + var VerticalDirection = cc.Enum({ + BOTTOM_TO_TOP: 0, + TOP_TO_BOTTOM: 1 + }); + var HorizontalDirection = cc.Enum({ + LEFT_TO_RIGHT: 0, + RIGHT_TO_LEFT: 1 + }); + var Layout = cc.Class({ + name: "cc.Layout", + extends: require("./CCComponent"), + editor: false, + properties: { + _layoutSize: cc.size(300, 200), + _layoutDirty: { + default: true, + serializable: false + }, + _resize: ResizeMode.NONE, + _N$layoutType: Type.NONE, + type: { + type: Type, + get: function get() { + return this._N$layoutType; + }, + set: function set(value) { + this._N$layoutType = value; + var reLayouted; + false; + this._doLayoutDirty(); + }, + tooltip: false, + animatable: false + }, + resizeMode: { + type: ResizeMode, + tooltip: false, + animatable: false, + get: function get() { + return this._resize; + }, + set: function set(value) { + if (this.type === Type.NONE && value === ResizeMode.CHILDREN) return; + this._resize = value; + var reLayouted; + false; + this._doLayoutDirty(); + } + }, + cellSize: { + default: cc.size(40, 40), + tooltip: false, + type: cc.Size, + notify: function notify() { + this._doLayoutDirty(); + } + }, + startAxis: { + default: AxisDirection.HORIZONTAL, + tooltip: false, + type: AxisDirection, + notify: function notify() { + var reLayouted; + false; + this._doLayoutDirty(); + }, + animatable: false + }, + paddingLeft: { + default: 0, + tooltip: false, + notify: function notify() { + this._doLayoutDirty(); + } + }, + paddingRight: { + default: 0, + tooltip: false, + notify: function notify() { + this._doLayoutDirty(); + } + }, + paddingTop: { + default: 0, + tooltip: false, + notify: function notify() { + this._doLayoutDirty(); + } + }, + paddingBottom: { + default: 0, + tooltip: false, + notify: function notify() { + this._doLayoutDirty(); + } + }, + spacingX: { + default: 0, + notify: function notify() { + this._doLayoutDirty(); + }, + tooltip: false + }, + spacingY: { + default: 0, + notify: function notify() { + this._doLayoutDirty(); + }, + tooltip: false + }, + verticalDirection: { + default: VerticalDirection.TOP_TO_BOTTOM, + type: VerticalDirection, + notify: function notify() { + this._doLayoutDirty(); + }, + tooltip: false, + animatable: false + }, + horizontalDirection: { + default: HorizontalDirection.LEFT_TO_RIGHT, + type: HorizontalDirection, + notify: function notify() { + this._doLayoutDirty(); + }, + tooltip: false, + animatable: false + }, + affectedByScale: { + default: false, + notify: function notify() { + this._doLayoutDirty(); + }, + animatable: false, + tooltip: false + } + }, + statics: { + Type: Type, + VerticalDirection: VerticalDirection, + HorizontalDirection: HorizontalDirection, + ResizeMode: ResizeMode, + AxisDirection: AxisDirection + }, + onEnable: function onEnable() { + this._addEventListeners(); + this.node.getContentSize().equals(cc.size(0, 0)) && this.node.setContentSize(this._layoutSize); + this._doLayoutDirty(); + }, + onDisable: function onDisable() { + this._removeEventListeners(); + }, + _doLayoutDirty: function _doLayoutDirty() { + this._layoutDirty = true; + }, + _doScaleDirty: function _doScaleDirty() { + this._layoutDirty = this._layoutDirty || this.affectedByScale; + }, + _addEventListeners: function _addEventListeners() { + cc.director.on(cc.Director.EVENT_AFTER_UPDATE, this.updateLayout, this); + this.node.on(NodeEvent.SIZE_CHANGED, this._resized, this); + this.node.on(NodeEvent.ANCHOR_CHANGED, this._doLayoutDirty, this); + this.node.on(NodeEvent.CHILD_ADDED, this._childAdded, this); + this.node.on(NodeEvent.CHILD_REMOVED, this._childRemoved, this); + this.node.on(NodeEvent.CHILD_REORDER, this._doLayoutDirty, this); + this._addChildrenEventListeners(); + }, + _removeEventListeners: function _removeEventListeners() { + cc.director.off(cc.Director.EVENT_AFTER_UPDATE, this.updateLayout, this); + this.node.off(NodeEvent.SIZE_CHANGED, this._resized, this); + this.node.off(NodeEvent.ANCHOR_CHANGED, this._doLayoutDirty, this); + this.node.off(NodeEvent.CHILD_ADDED, this._childAdded, this); + this.node.off(NodeEvent.CHILD_REMOVED, this._childRemoved, this); + this.node.off(NodeEvent.CHILD_REORDER, this._doLayoutDirty, this); + this._removeChildrenEventListeners(); + }, + _addChildrenEventListeners: function _addChildrenEventListeners() { + var children = this.node.children; + for (var i = 0; i < children.length; ++i) { + var child = children[i]; + child.on(NodeEvent.SCALE_CHANGED, this._doScaleDirty, this); + child.on(NodeEvent.SIZE_CHANGED, this._doLayoutDirty, this); + child.on(NodeEvent.POSITION_CHANGED, this._doLayoutDirty, this); + child.on(NodeEvent.ANCHOR_CHANGED, this._doLayoutDirty, this); + child.on("active-in-hierarchy-changed", this._doLayoutDirty, this); + } + }, + _removeChildrenEventListeners: function _removeChildrenEventListeners() { + var children = this.node.children; + for (var i = 0; i < children.length; ++i) { + var child = children[i]; + child.off(NodeEvent.SCALE_CHANGED, this._doScaleDirty, this); + child.off(NodeEvent.SIZE_CHANGED, this._doLayoutDirty, this); + child.off(NodeEvent.POSITION_CHANGED, this._doLayoutDirty, this); + child.off(NodeEvent.ANCHOR_CHANGED, this._doLayoutDirty, this); + child.off("active-in-hierarchy-changed", this._doLayoutDirty, this); + } + }, + _childAdded: function _childAdded(child) { + child.on(NodeEvent.SCALE_CHANGED, this._doScaleDirty, this); + child.on(NodeEvent.SIZE_CHANGED, this._doLayoutDirty, this); + child.on(NodeEvent.POSITION_CHANGED, this._doLayoutDirty, this); + child.on(NodeEvent.ANCHOR_CHANGED, this._doLayoutDirty, this); + child.on("active-in-hierarchy-changed", this._doLayoutDirty, this); + this._doLayoutDirty(); + }, + _childRemoved: function _childRemoved(child) { + child.off(NodeEvent.SCALE_CHANGED, this._doScaleDirty, this); + child.off(NodeEvent.SIZE_CHANGED, this._doLayoutDirty, this); + child.off(NodeEvent.POSITION_CHANGED, this._doLayoutDirty, this); + child.off(NodeEvent.ANCHOR_CHANGED, this._doLayoutDirty, this); + child.off("active-in-hierarchy-changed", this._doLayoutDirty, this); + this._doLayoutDirty(); + }, + _resized: function _resized() { + this._layoutSize = this.node.getContentSize(); + this._doLayoutDirty(); + }, + _doLayoutHorizontally: function _doLayoutHorizontally(baseWidth, rowBreak, fnPositionY, applyChildren) { + var layoutAnchor = this.node.getAnchorPoint(); + var children = this.node.children; + var sign = 1; + var paddingX = this.paddingLeft; + var leftBoundaryOfLayout = -layoutAnchor.x * baseWidth; + if (this.horizontalDirection === HorizontalDirection.RIGHT_TO_LEFT) { + sign = -1; + leftBoundaryOfLayout = (1 - layoutAnchor.x) * baseWidth; + paddingX = this.paddingRight; + } + var nextX = leftBoundaryOfLayout + sign * paddingX - sign * this.spacingX; + var rowMaxHeight = 0; + var tempMaxHeight = 0; + var secondMaxHeight = 0; + var row = 0; + var containerResizeBoundary = 0; + var maxHeightChildAnchorY = 0; + var activeChildCount = 0; + for (var i = 0; i < children.length; ++i) { + var child = children[i]; + child.activeInHierarchy && activeChildCount++; + } + var newChildWidth = this.cellSize.width; + this.type !== Type.GRID && this.resizeMode === ResizeMode.CHILDREN && (newChildWidth = (baseWidth - (this.paddingLeft + this.paddingRight) - (activeChildCount - 1) * this.spacingX) / activeChildCount); + for (var i = 0; i < children.length; ++i) { + var child = children[i]; + var childScaleX = this._getUsedScaleValue(child.scaleX); + var childScaleY = this._getUsedScaleValue(child.scaleY); + if (!child.activeInHierarchy) continue; + if (this._resize === ResizeMode.CHILDREN) { + child.width = newChildWidth / childScaleX; + this.type === Type.GRID && (child.height = this.cellSize.height / childScaleY); + } + var anchorX = child.anchorX; + var childBoundingBoxWidth = child.width * childScaleX; + var childBoundingBoxHeight = child.height * childScaleY; + secondMaxHeight > tempMaxHeight && (tempMaxHeight = secondMaxHeight); + if (childBoundingBoxHeight >= tempMaxHeight) { + secondMaxHeight = tempMaxHeight; + tempMaxHeight = childBoundingBoxHeight; + maxHeightChildAnchorY = child.getAnchorPoint().y; + } + this.horizontalDirection === HorizontalDirection.RIGHT_TO_LEFT && (anchorX = 1 - child.anchorX); + nextX = nextX + sign * anchorX * childBoundingBoxWidth + sign * this.spacingX; + var rightBoundaryOfChild = sign * (1 - anchorX) * childBoundingBoxWidth; + if (rowBreak) { + var rowBreakBoundary = nextX + rightBoundaryOfChild + sign * (sign > 0 ? this.paddingRight : this.paddingLeft); + var leftToRightRowBreak = this.horizontalDirection === HorizontalDirection.LEFT_TO_RIGHT && rowBreakBoundary > (1 - layoutAnchor.x) * baseWidth; + var rightToLeftRowBreak = this.horizontalDirection === HorizontalDirection.RIGHT_TO_LEFT && rowBreakBoundary < -layoutAnchor.x * baseWidth; + if (leftToRightRowBreak || rightToLeftRowBreak) { + if (childBoundingBoxHeight >= tempMaxHeight) { + 0 === secondMaxHeight && (secondMaxHeight = tempMaxHeight); + rowMaxHeight += secondMaxHeight; + secondMaxHeight = tempMaxHeight; + } else { + rowMaxHeight += tempMaxHeight; + secondMaxHeight = childBoundingBoxHeight; + tempMaxHeight = 0; + } + nextX = leftBoundaryOfLayout + sign * (paddingX + anchorX * childBoundingBoxWidth); + row++; + } + } + var finalPositionY = fnPositionY(child, rowMaxHeight, row); + baseWidth >= childBoundingBoxWidth + this.paddingLeft + this.paddingRight && applyChildren && child.setPosition(cc.v2(nextX, finalPositionY)); + var signX = 1; + var tempFinalPositionY; + var topMarign = 0 === tempMaxHeight ? childBoundingBoxHeight : tempMaxHeight; + if (this.verticalDirection === VerticalDirection.TOP_TO_BOTTOM) { + containerResizeBoundary = containerResizeBoundary || this.node._contentSize.height; + signX = -1; + tempFinalPositionY = finalPositionY + signX * (topMarign * maxHeightChildAnchorY + this.paddingBottom); + tempFinalPositionY < containerResizeBoundary && (containerResizeBoundary = tempFinalPositionY); + } else { + containerResizeBoundary = containerResizeBoundary || -this.node._contentSize.height; + tempFinalPositionY = finalPositionY + signX * (topMarign * maxHeightChildAnchorY + this.paddingTop); + tempFinalPositionY > containerResizeBoundary && (containerResizeBoundary = tempFinalPositionY); + } + nextX += rightBoundaryOfChild; + } + return containerResizeBoundary; + }, + _getVerticalBaseHeight: function _getVerticalBaseHeight(children) { + var newHeight = 0; + var activeChildCount = 0; + if (this.resizeMode === ResizeMode.CONTAINER) { + for (var i = 0; i < children.length; ++i) { + var child = children[i]; + if (child.activeInHierarchy) { + activeChildCount++; + newHeight += child.height * this._getUsedScaleValue(child.scaleY); + } + } + newHeight += (activeChildCount - 1) * this.spacingY + this.paddingBottom + this.paddingTop; + } else newHeight = this.node.getContentSize().height; + return newHeight; + }, + _doLayoutVertically: function _doLayoutVertically(baseHeight, columnBreak, fnPositionX, applyChildren) { + var layoutAnchor = this.node.getAnchorPoint(); + var children = this.node.children; + var sign = 1; + var paddingY = this.paddingBottom; + var bottomBoundaryOfLayout = -layoutAnchor.y * baseHeight; + if (this.verticalDirection === VerticalDirection.TOP_TO_BOTTOM) { + sign = -1; + bottomBoundaryOfLayout = (1 - layoutAnchor.y) * baseHeight; + paddingY = this.paddingTop; + } + var nextY = bottomBoundaryOfLayout + sign * paddingY - sign * this.spacingY; + var columnMaxWidth = 0; + var tempMaxWidth = 0; + var secondMaxWidth = 0; + var column = 0; + var containerResizeBoundary = 0; + var maxWidthChildAnchorX = 0; + var activeChildCount = 0; + for (var i = 0; i < children.length; ++i) { + var child = children[i]; + child.activeInHierarchy && activeChildCount++; + } + var newChildHeight = this.cellSize.height; + this.type !== Type.GRID && this.resizeMode === ResizeMode.CHILDREN && (newChildHeight = (baseHeight - (this.paddingTop + this.paddingBottom) - (activeChildCount - 1) * this.spacingY) / activeChildCount); + for (var i = 0; i < children.length; ++i) { + var child = children[i]; + var childScaleX = this._getUsedScaleValue(child.scaleX); + var childScaleY = this._getUsedScaleValue(child.scaleY); + if (!child.activeInHierarchy) continue; + if (this.resizeMode === ResizeMode.CHILDREN) { + child.height = newChildHeight / childScaleY; + this.type === Type.GRID && (child.width = this.cellSize.width / childScaleX); + } + var anchorY = child.anchorY; + var childBoundingBoxWidth = child.width * childScaleX; + var childBoundingBoxHeight = child.height * childScaleY; + secondMaxWidth > tempMaxWidth && (tempMaxWidth = secondMaxWidth); + if (childBoundingBoxWidth >= tempMaxWidth) { + secondMaxWidth = tempMaxWidth; + tempMaxWidth = childBoundingBoxWidth; + maxWidthChildAnchorX = child.getAnchorPoint().x; + } + this.verticalDirection === VerticalDirection.TOP_TO_BOTTOM && (anchorY = 1 - child.anchorY); + nextY = nextY + sign * anchorY * childBoundingBoxHeight + sign * this.spacingY; + var topBoundaryOfChild = sign * (1 - anchorY) * childBoundingBoxHeight; + if (columnBreak) { + var columnBreakBoundary = nextY + topBoundaryOfChild + sign * (sign > 0 ? this.paddingTop : this.paddingBottom); + var bottomToTopColumnBreak = this.verticalDirection === VerticalDirection.BOTTOM_TO_TOP && columnBreakBoundary > (1 - layoutAnchor.y) * baseHeight; + var topToBottomColumnBreak = this.verticalDirection === VerticalDirection.TOP_TO_BOTTOM && columnBreakBoundary < -layoutAnchor.y * baseHeight; + if (bottomToTopColumnBreak || topToBottomColumnBreak) { + if (childBoundingBoxWidth >= tempMaxWidth) { + 0 === secondMaxWidth && (secondMaxWidth = tempMaxWidth); + columnMaxWidth += secondMaxWidth; + secondMaxWidth = tempMaxWidth; + } else { + columnMaxWidth += tempMaxWidth; + secondMaxWidth = childBoundingBoxWidth; + tempMaxWidth = 0; + } + nextY = bottomBoundaryOfLayout + sign * (paddingY + anchorY * childBoundingBoxHeight); + column++; + } + } + var finalPositionX = fnPositionX(child, columnMaxWidth, column); + baseHeight >= childBoundingBoxHeight + (this.paddingTop + this.paddingBottom) && applyChildren && child.setPosition(cc.v2(finalPositionX, nextY)); + var signX = 1; + var tempFinalPositionX; + var rightMarign = 0 === tempMaxWidth ? childBoundingBoxWidth : tempMaxWidth; + if (this.horizontalDirection === HorizontalDirection.RIGHT_TO_LEFT) { + signX = -1; + containerResizeBoundary = containerResizeBoundary || this.node._contentSize.width; + tempFinalPositionX = finalPositionX + signX * (rightMarign * maxWidthChildAnchorX + this.paddingLeft); + tempFinalPositionX < containerResizeBoundary && (containerResizeBoundary = tempFinalPositionX); + } else { + containerResizeBoundary = containerResizeBoundary || -this.node._contentSize.width; + tempFinalPositionX = finalPositionX + signX * (rightMarign * maxWidthChildAnchorX + this.paddingRight); + tempFinalPositionX > containerResizeBoundary && (containerResizeBoundary = tempFinalPositionX); + } + nextY += topBoundaryOfChild; + } + return containerResizeBoundary; + }, + _doLayoutBasic: function _doLayoutBasic() { + var children = this.node.children; + var allChildrenBoundingBox = null; + for (var i = 0; i < children.length; ++i) { + var child = children[i]; + child.activeInHierarchy && (allChildrenBoundingBox ? allChildrenBoundingBox.union(allChildrenBoundingBox, child.getBoundingBoxToWorld()) : allChildrenBoundingBox = child.getBoundingBoxToWorld()); + } + if (allChildrenBoundingBox) { + var leftBottomSpace = this.node.convertToNodeSpaceAR(cc.v2(allChildrenBoundingBox.x, allChildrenBoundingBox.y)); + leftBottomSpace = cc.v2(leftBottomSpace.x - this.paddingLeft, leftBottomSpace.y - this.paddingBottom); + var rightTopSpace = this.node.convertToNodeSpaceAR(cc.v2(allChildrenBoundingBox.xMax, allChildrenBoundingBox.yMax)); + rightTopSpace = cc.v2(rightTopSpace.x + this.paddingRight, rightTopSpace.y + this.paddingTop); + var newSize = rightTopSpace.sub(leftBottomSpace); + newSize = cc.size(parseFloat(newSize.x.toFixed(2)), parseFloat(newSize.y.toFixed(2))); + if (0 !== newSize.width) { + var newAnchorX = -leftBottomSpace.x / newSize.width; + this.node.anchorX = parseFloat(newAnchorX.toFixed(2)); + } + if (0 !== newSize.height) { + var newAnchorY = -leftBottomSpace.y / newSize.height; + this.node.anchorY = parseFloat(newAnchorY.toFixed(2)); + } + this.node.setContentSize(newSize); + } + }, + _doLayoutGridAxisHorizontal: function _doLayoutGridAxisHorizontal(layoutAnchor, layoutSize) { + var baseWidth = layoutSize.width; + var sign = 1; + var bottomBoundaryOfLayout = -layoutAnchor.y * layoutSize.height; + var paddingY = this.paddingBottom; + if (this.verticalDirection === VerticalDirection.TOP_TO_BOTTOM) { + sign = -1; + bottomBoundaryOfLayout = (1 - layoutAnchor.y) * layoutSize.height; + paddingY = this.paddingTop; + } + var fnPositionY = function(child, topOffset, row) { + return bottomBoundaryOfLayout + sign * (topOffset + child.anchorY * child.height * this._getUsedScaleValue(child.scaleY) + paddingY + row * this.spacingY); + }.bind(this); + var newHeight = 0; + if (this.resizeMode === ResizeMode.CONTAINER) { + var boundary = this._doLayoutHorizontally(baseWidth, true, fnPositionY, false); + newHeight = bottomBoundaryOfLayout - boundary; + newHeight < 0 && (newHeight *= -1); + bottomBoundaryOfLayout = -layoutAnchor.y * newHeight; + if (this.verticalDirection === VerticalDirection.TOP_TO_BOTTOM) { + sign = -1; + bottomBoundaryOfLayout = (1 - layoutAnchor.y) * newHeight; + } + } + this._doLayoutHorizontally(baseWidth, true, fnPositionY, true); + this.resizeMode === ResizeMode.CONTAINER && this.node.setContentSize(baseWidth, newHeight); + }, + _doLayoutGridAxisVertical: function _doLayoutGridAxisVertical(layoutAnchor, layoutSize) { + var baseHeight = layoutSize.height; + var sign = 1; + var leftBoundaryOfLayout = -layoutAnchor.x * layoutSize.width; + var paddingX = this.paddingLeft; + if (this.horizontalDirection === HorizontalDirection.RIGHT_TO_LEFT) { + sign = -1; + leftBoundaryOfLayout = (1 - layoutAnchor.x) * layoutSize.width; + paddingX = this.paddingRight; + } + var fnPositionX = function(child, leftOffset, column) { + return leftBoundaryOfLayout + sign * (leftOffset + child.anchorX * child.width * this._getUsedScaleValue(child.scaleX) + paddingX + column * this.spacingX); + }.bind(this); + var newWidth = 0; + if (this.resizeMode === ResizeMode.CONTAINER) { + var boundary = this._doLayoutVertically(baseHeight, true, fnPositionX, false); + newWidth = leftBoundaryOfLayout - boundary; + newWidth < 0 && (newWidth *= -1); + leftBoundaryOfLayout = -layoutAnchor.x * newWidth; + if (this.horizontalDirection === HorizontalDirection.RIGHT_TO_LEFT) { + sign = -1; + leftBoundaryOfLayout = (1 - layoutAnchor.x) * newWidth; + } + } + this._doLayoutVertically(baseHeight, true, fnPositionX, true); + this.resizeMode === ResizeMode.CONTAINER && this.node.setContentSize(newWidth, baseHeight); + }, + _doLayoutGrid: function _doLayoutGrid() { + var layoutAnchor = this.node.getAnchorPoint(); + var layoutSize = this.node.getContentSize(); + this.startAxis === AxisDirection.HORIZONTAL ? this._doLayoutGridAxisHorizontal(layoutAnchor, layoutSize) : this.startAxis === AxisDirection.VERTICAL && this._doLayoutGridAxisVertical(layoutAnchor, layoutSize); + }, + _getHorizontalBaseWidth: function _getHorizontalBaseWidth(children) { + var newWidth = 0; + var activeChildCount = 0; + if (this.resizeMode === ResizeMode.CONTAINER) { + for (var i = 0; i < children.length; ++i) { + var child = children[i]; + if (child.activeInHierarchy) { + activeChildCount++; + newWidth += child.width * this._getUsedScaleValue(child.scaleX); + } + } + newWidth += (activeChildCount - 1) * this.spacingX + this.paddingLeft + this.paddingRight; + } else newWidth = this.node.getContentSize().width; + return newWidth; + }, + _doLayout: function _doLayout() { + if (this.type === Type.HORIZONTAL) { + var newWidth = this._getHorizontalBaseWidth(this.node.children); + var fnPositionY = function fnPositionY(child) { + return child.y; + }; + this._doLayoutHorizontally(newWidth, false, fnPositionY, true); + this.node.width = newWidth; + } else if (this.type === Type.VERTICAL) { + var newHeight = this._getVerticalBaseHeight(this.node.children); + var fnPositionX = function fnPositionX(child) { + return child.x; + }; + this._doLayoutVertically(newHeight, false, fnPositionX, true); + this.node.height = newHeight; + } else this.type === Type.NONE ? this.resizeMode === ResizeMode.CONTAINER && this._doLayoutBasic() : this.type === Type.GRID && this._doLayoutGrid(); + }, + _getUsedScaleValue: function _getUsedScaleValue(value) { + return this.affectedByScale ? Math.abs(value) : 1; + }, + updateLayout: function updateLayout() { + if (this._layoutDirty && this.node.children.length > 0) { + var activeChild = this.node.children.find((function(node) { + return node.activeInHierarchy; + })); + if (activeChild) { + this._doLayout(); + this._layoutDirty = false; + } + } + } + }); + cc.Layout = module.exports = Layout; + }), { + "../CCNode": 73, + "./CCComponent": 150 + } ], + 156: [ (function(require, module, exports) { + "use strict"; + var _gfx = _interopRequireDefault(require("../../renderer/gfx")); + var _mat = _interopRequireDefault(require("../value-types/mat4")); + var _vec = _interopRequireDefault(require("../value-types/vec2")); + var _materialVariant = _interopRequireDefault(require("../assets/material/material-variant")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + var misc = require("../utils/misc"); + var RenderComponent = require("./CCRenderComponent"); + var RenderFlow = require("../renderer/render-flow"); + var Graphics = require("../graphics/graphics"); + var _vec2_temp = new _vec["default"](); + var _mat4_temp = new _mat["default"](); + var _circlepoints = []; + function _calculateCircle(center, radius, segements) { + _circlepoints.length = 0; + var anglePerStep = 2 * Math.PI / segements; + for (var step = 0; step < segements; ++step) _circlepoints.push(cc.v2(radius.x * Math.cos(anglePerStep * step) + center.x, radius.y * Math.sin(anglePerStep * step) + center.y)); + return _circlepoints; + } + var MaskType = cc.Enum({ + RECT: 0, + ELLIPSE: 1, + IMAGE_STENCIL: 2 + }); + var SEGEMENTS_MIN = 3; + var SEGEMENTS_MAX = 1e4; + var Mask = cc.Class({ + name: "cc.Mask", + extends: RenderComponent, + editor: false, + ctor: function ctor() { + this._graphics = null; + this._enableMaterial = null; + this._exitMaterial = null; + this._clearMaterial = null; + }, + properties: { + _spriteFrame: { + default: null, + type: cc.SpriteFrame + }, + _type: MaskType.RECT, + type: { + get: function get() { + return this._type; + }, + set: function set(value) { + this._type !== value && this._resetAssembler(); + this._type = value; + if (this._type !== MaskType.IMAGE_STENCIL) { + this.spriteFrame = null; + this.alphaThreshold = 0; + this._updateGraphics(); + } + this._activateMaterial(); + }, + type: MaskType, + tooltip: false + }, + spriteFrame: { + type: cc.SpriteFrame, + tooltip: false, + get: function get() { + return this._spriteFrame; + }, + set: function set(value) { + var lastSprite = this._spriteFrame; + false; + if (lastSprite === value) return; + lastSprite && lastSprite.off("load", this.setVertsDirty, this); + this._spriteFrame = value; + this.setVertsDirty(); + this._updateMaterial(); + } + }, + alphaThreshold: { + default: .1, + type: cc.Float, + range: [ 0, 1, .1 ], + slide: true, + tooltip: false, + notify: function notify() { + if (cc.game.renderType === cc.game.RENDER_TYPE_CANVAS) { + cc.warnID(4201); + return; + } + this._updateMaterial(); + } + }, + inverted: { + default: false, + type: cc.Boolean, + tooltip: false, + notify: function notify() { + cc.game.renderType === cc.game.RENDER_TYPE_CANVAS && cc.warnID(4202); + } + }, + _segments: 64, + segements: { + get: function get() { + return this._segments; + }, + set: function set(value) { + this._segments = misc.clampf(value, SEGEMENTS_MIN, SEGEMENTS_MAX); + this._updateGraphics(); + }, + type: cc.Integer, + tooltip: false + }, + _resizeToTarget: { + animatable: false, + set: function set(value) { + value && this._resizeNodeToTargetNode(); + } + } + }, + statics: { + Type: MaskType + }, + onRestore: function onRestore() { + this._activateMaterial(); + }, + onEnable: function onEnable() { + this._super(); + this._type !== MaskType.IMAGE_STENCIL ? this._updateGraphics() : this._spriteFrame && this._spriteFrame.once("load", this.setVertsDirty, this); + this.node.on(cc.Node.EventType.POSITION_CHANGED, this._updateGraphics, this); + this.node.on(cc.Node.EventType.ROTATION_CHANGED, this._updateGraphics, this); + this.node.on(cc.Node.EventType.SCALE_CHANGED, this._updateGraphics, this); + this.node.on(cc.Node.EventType.SIZE_CHANGED, this._updateGraphics, this); + this.node.on(cc.Node.EventType.ANCHOR_CHANGED, this._updateGraphics, this); + }, + onDisable: function onDisable() { + this._super(); + this.node.off(cc.Node.EventType.POSITION_CHANGED, this._updateGraphics, this); + this.node.off(cc.Node.EventType.ROTATION_CHANGED, this._updateGraphics, this); + this.node.off(cc.Node.EventType.SCALE_CHANGED, this._updateGraphics, this); + this.node.off(cc.Node.EventType.SIZE_CHANGED, this._updateGraphics, this); + this.node.off(cc.Node.EventType.ANCHOR_CHANGED, this._updateGraphics, this); + this.node._renderFlag &= ~RenderFlow.FLAG_POST_RENDER; + }, + onDestroy: function onDestroy() { + this._super(); + this._removeGraphics(); + this._spriteFrame && this._spriteFrame.off("load", this.setVertsDirty, this); + }, + _resizeNodeToTargetNode: false, + _validateRender: function _validateRender() { + if (this._type !== MaskType.IMAGE_STENCIL) return; + var spriteFrame = this._spriteFrame; + if (spriteFrame && spriteFrame.textureLoaded()) return; + this.disableRender(); + }, + _activateMaterial: function _activateMaterial() { + this._createGraphics(); + var material = this._materials[0]; + material = material ? _materialVariant["default"].create(material, this) : _materialVariant["default"].createWithBuiltin("2d-sprite", this); + material.define("USE_ALPHA_TEST", true); + if (this._type === MaskType.IMAGE_STENCIL) { + material.define("CC_USE_MODEL", false); + material.define("USE_TEXTURE", true); + } else { + material.define("CC_USE_MODEL", true); + material.define("USE_TEXTURE", false); + } + this._enableMaterial || (this._enableMaterial = _materialVariant["default"].createWithBuiltin("2d-sprite", this)); + if (!this._exitMaterial) { + this._exitMaterial = _materialVariant["default"].createWithBuiltin("2d-sprite", this); + this._exitMaterial.setStencilEnabled(_gfx["default"].STENCIL_DISABLE); + } + this._clearMaterial || (this._clearMaterial = _materialVariant["default"].createWithBuiltin("clear-stencil", this)); + this.setMaterial(0, material); + this._graphics._materials[0] = material; + this._updateMaterial(); + }, + _updateMaterial: function _updateMaterial() { + var material = this._materials[0]; + if (!material) return; + if (this._type === MaskType.IMAGE_STENCIL && this.spriteFrame) { + var texture = this.spriteFrame.getTexture(); + material.setProperty("texture", texture); + } + material.setProperty("alphaThreshold", this.alphaThreshold); + }, + _createGraphics: function _createGraphics() { + if (!this._graphics) { + this._graphics = new Graphics(); + cc.Assembler.init(this._graphics); + this._graphics.node = this.node; + this._graphics.lineWidth = 0; + this._graphics.strokeColor = cc.color(0, 0, 0, 0); + } + }, + _updateGraphics: function _updateGraphics() { + if (!this.enabledInHierarchy) return; + var node = this.node; + var graphics = this._graphics; + graphics.clear(false); + var width = node._contentSize.width; + var height = node._contentSize.height; + var x = -width * node._anchorPoint.x; + var y = -height * node._anchorPoint.y; + if (this._type === MaskType.RECT) graphics.rect(x, y, width, height); else if (this._type === MaskType.ELLIPSE) { + var center = cc.v2(x + width / 2, y + height / 2); + var radius = { + x: width / 2, + y: height / 2 + }; + var points = _calculateCircle(center, radius, this._segments); + for (var i = 0; i < points.length; ++i) { + var point = points[i]; + 0 === i ? graphics.moveTo(point.x, point.y) : graphics.lineTo(point.x, point.y); + } + graphics.close(); + } + cc.game.renderType === cc.game.RENDER_TYPE_CANVAS ? graphics.stroke() : graphics.fill(); + this.setVertsDirty(); + }, + _removeGraphics: function _removeGraphics() { + if (this._graphics) { + this._graphics.destroy(); + this._graphics._destroyImmediate(); + this._graphics = null; + } + }, + _hitTest: function _hitTest(cameraPt) { + var node = this.node; + var size = node.getContentSize(), w = size.width, h = size.height, testPt = _vec2_temp; + node._updateWorldMatrix(); + if (!_mat["default"].invert(_mat4_temp, node._worldMatrix)) return false; + _vec["default"].transformMat4(testPt, cameraPt, _mat4_temp); + testPt.x += node._anchorPoint.x * w; + testPt.y += node._anchorPoint.y * h; + var result = false; + if (this.type === MaskType.RECT || this.type === MaskType.IMAGE_STENCIL) result = testPt.x >= 0 && testPt.y >= 0 && testPt.x <= w && testPt.y <= h; else if (this.type === MaskType.ELLIPSE) { + var rx = w / 2, ry = h / 2; + var px = testPt.x - .5 * w, py = testPt.y - .5 * h; + result = px * px / (rx * rx) + py * py / (ry * ry) < 1; + } + this.inverted && (result = !result); + return result; + }, + markForRender: function markForRender(enable) { + var flag = RenderFlow.FLAG_RENDER | RenderFlow.FLAG_UPDATE_RENDER_DATA | RenderFlow.FLAG_POST_RENDER; + if (enable) { + this.node._renderFlag |= flag; + this.markForValidate(); + } else enable || (this.node._renderFlag &= ~flag); + }, + disableRender: function disableRender() { + this.node._renderFlag &= ~(RenderFlow.FLAG_RENDER | RenderFlow.FLAG_UPDATE_RENDER_DATA | RenderFlow.FLAG_POST_RENDER); + } + }); + cc.Mask = module.exports = Mask; + }), { + "../../renderer/gfx": 373, + "../assets/material/material-variant": 132, + "../graphics/graphics": 203, + "../renderer/render-flow": 273, + "../utils/misc": 325, + "../value-types/mat4": 342, + "../value-types/vec2": 349, + "./CCRenderComponent": 161 + } ], + 157: [ (function(require, module, exports) { + "use strict"; + var RenderComponent = require("../components/CCRenderComponent"); + var BlendFunc = require("../../core/utils/blend-func"); + var MotionStreak = cc.Class({ + name: "cc.MotionStreak", + extends: RenderComponent, + mixins: [ BlendFunc ], + editor: false, + ctor: function ctor() { + this._points = []; + this._lastWPos = new cc.Vec2(); + }, + properties: { + preview: { + default: false, + editorOnly: true, + notify: false, + animatable: false + }, + _fadeTime: 1, + fadeTime: { + get: function get() { + return this._fadeTime; + }, + set: function set(value) { + this._fadeTime = value; + this.reset(); + }, + animatable: false, + tooltip: false + }, + _minSeg: 1, + minSeg: { + get: function get() { + return this._minSeg; + }, + set: function set(value) { + this._minSeg = value; + }, + animatable: false, + tooltip: false + }, + _stroke: 64, + stroke: { + get: function get() { + return this._stroke; + }, + set: function set(value) { + this._stroke = value; + }, + animatable: false, + tooltip: false + }, + _texture: { + default: null, + type: cc.Texture2D + }, + texture: { + get: function get() { + return this._texture; + }, + set: function set(value) { + if (this._texture === value) return; + this._texture = value; + this._updateMaterial(); + }, + type: cc.Texture2D, + animatable: false, + tooltip: false + }, + _color: cc.Color.WHITE, + color: { + get: function get() { + return this._color.clone(); + }, + set: function set(value) { + this._color.equals(value) || this._color.set(value); + }, + type: cc.Color, + tooltip: false + }, + _fastMode: false, + fastMode: { + get: function get() { + return this._fastMode; + }, + set: function set(value) { + this._fastMode = value; + }, + animatable: false, + tooltip: false + } + }, + onEnable: function onEnable() { + this._super(); + this.reset(); + }, + _updateMaterial: function _updateMaterial() { + var material = this.getMaterial(0); + material && material.setProperty("texture", this._texture); + BlendFunc.prototype._updateMaterial.call(this); + }, + onFocusInEditor: false, + onLostFocusInEditor: false, + reset: function reset() { + this._points.length = 0; + this._assembler && this._assembler._renderData.clear(); + this._lastWPos.x = 0; + this._lastWPos.y = 0; + false; + }, + lateUpdate: function lateUpdate(dt) { + this._assembler && this._assembler.update(this, dt); + } + }); + cc.MotionStreak = module.exports = MotionStreak; + }), { + "../../core/utils/blend-func": 319, + "../components/CCRenderComponent": 161 + } ], + 158: [ (function(require, module, exports) { + "use strict"; + var SizeMode = cc.Enum({ + Unified: 0, + Free: 1 + }); + var Direction = cc.Enum({ + Horizontal: 0, + Vertical: 1 + }); + var EventType = cc.Enum({ + PAGE_TURNING: 0 + }); + var PageView = cc.Class({ + name: "cc.PageView", + extends: cc.ScrollView, + editor: false, + ctor: function ctor() { + this._curPageIdx = 0; + this._lastPageIdx = 0; + this._pages = []; + this._initContentPos = cc.v2(); + this._scrollCenterOffsetX = []; + this._scrollCenterOffsetY = []; + }, + properties: { + sizeMode: { + default: SizeMode.Unified, + type: SizeMode, + tooltip: false, + notify: function notify() { + this._syncSizeMode(); + } + }, + direction: { + default: Direction.Horizontal, + type: Direction, + tooltip: false, + notify: function notify() { + this._syncScrollDirection(); + } + }, + scrollThreshold: { + default: .5, + type: cc.Float, + slide: true, + range: [ 0, 1, .01 ], + tooltip: false + }, + autoPageTurningThreshold: { + default: 100, + type: cc.Float, + tooltip: false + }, + pageTurningEventTiming: { + default: .1, + type: cc.Float, + range: [ 0, 1, .01 ], + tooltip: false + }, + indicator: { + default: null, + type: cc.PageViewIndicator, + tooltip: false, + notify: function notify() { + this.indicator && this.indicator.setPageView(this); + } + }, + pageTurningSpeed: { + default: .3, + type: cc.Float, + tooltip: false + }, + pageEvents: { + default: [], + type: cc.Component.EventHandler, + tooltip: false + } + }, + statics: { + SizeMode: SizeMode, + Direction: Direction, + EventType: EventType + }, + onEnable: function onEnable() { + this._super(); + this.node.on(cc.Node.EventType.SIZE_CHANGED, this._updateAllPagesSize, this); + true; + this.node.on("scroll-ended-with-threshold", this._dispatchPageTurningEvent, this); + }, + onDisable: function onDisable() { + this._super(); + this.node.off(cc.Node.EventType.SIZE_CHANGED, this._updateAllPagesSize, this); + true; + this.node.off("scroll-ended-with-threshold", this._dispatchPageTurningEvent, this); + }, + onLoad: function onLoad() { + this._initPages(); + this.indicator && this.indicator.setPageView(this); + }, + getCurrentPageIndex: function getCurrentPageIndex() { + return this._curPageIdx; + }, + setCurrentPageIndex: function setCurrentPageIndex(index) { + this.scrollToPage(index, true); + }, + getPages: function getPages() { + return this._pages; + }, + addPage: function addPage(page) { + if (!page || -1 !== this._pages.indexOf(page) || !this.content) return; + this.content.addChild(page); + this._pages.push(page); + this._updatePageView(); + }, + insertPage: function insertPage(page, index) { + if (index < 0 || !page || -1 !== this._pages.indexOf(page) || !this.content) return; + var pageCount = this._pages.length; + if (index >= pageCount) this.addPage(page); else { + this._pages.splice(index, 0, page); + this.content.addChild(page); + this._updatePageView(); + } + }, + removePage: function removePage(page) { + if (!page || !this.content) return; + var index = this._pages.indexOf(page); + if (-1 === index) { + cc.warnID(4300, page.name); + return; + } + this.removePageAtIndex(index); + }, + removePageAtIndex: function removePageAtIndex(index) { + var pageList = this._pages; + if (index < 0 || index >= pageList.length) return; + var page = pageList[index]; + if (!page) return; + this.content.removeChild(page); + pageList.splice(index, 1); + this._updatePageView(); + }, + removeAllPages: function removeAllPages() { + if (!this.content) return; + var locPages = this._pages; + for (var i = 0, len = locPages.length; i < len; i++) this.content.removeChild(locPages[i]); + this._pages.length = 0; + this._updatePageView(); + }, + scrollToPage: function scrollToPage(idx, timeInSecond) { + if (idx < 0 || idx >= this._pages.length) return; + timeInSecond = void 0 !== timeInSecond ? timeInSecond : .3; + this._curPageIdx = idx; + this.scrollToOffset(this._moveOffsetValue(idx), timeInSecond, true); + this.indicator && this.indicator._changedState(); + }, + getScrollEndedEventTiming: function getScrollEndedEventTiming() { + return this.pageTurningEventTiming; + }, + _syncScrollDirection: function _syncScrollDirection() { + this.horizontal = this.direction === Direction.Horizontal; + this.vertical = this.direction === Direction.Vertical; + }, + _syncSizeMode: function _syncSizeMode() { + if (!this.content) return; + var layout = this.content.getComponent(cc.Layout); + if (layout) { + if (this.sizeMode === SizeMode.Free && this._pages.length > 0) { + var lastPage = this._pages[this._pages.length - 1]; + if (this.direction === Direction.Horizontal) { + layout.paddingLeft = (this._view.width - this._pages[0].width) / 2; + layout.paddingRight = (this._view.width - lastPage.width) / 2; + } else if (this.direction === Direction.Vertical) { + layout.paddingTop = (this._view.height - this._pages[0].height) / 2; + layout.paddingBottom = (this._view.height - lastPage.height) / 2; + } + } + layout.updateLayout(); + } + }, + _updatePageView: function _updatePageView() { + var layout = this.content.getComponent(cc.Layout); + layout && layout.enabled && layout.updateLayout(); + var pageCount = this._pages.length; + if (this._curPageIdx >= pageCount) { + this._curPageIdx = 0 === pageCount ? 0 : pageCount - 1; + this._lastPageIdx = this._curPageIdx; + } + var contentPos = this._initContentPos; + for (var i = 0; i < pageCount; ++i) { + var page = this._pages[i]; + page.setSiblingIndex(i); + this.direction === Direction.Horizontal ? this._scrollCenterOffsetX[i] = Math.abs(contentPos.x + page.x) : this._scrollCenterOffsetY[i] = Math.abs(contentPos.y + page.y); + } + this.indicator && this.indicator._refresh(); + }, + _updateAllPagesSize: function _updateAllPagesSize() { + if (this.sizeMode !== SizeMode.Unified || !this._view) return; + var locPages = this._pages; + var selfSize = this._view.getContentSize(); + for (var i = 0, len = locPages.length; i < len; i++) locPages[i].setContentSize(selfSize); + }, + _initPages: function _initPages() { + if (!this.content) return; + this._initContentPos = this.content.position; + var children = this.content.children; + for (var i = 0; i < children.length; ++i) { + var page = children[i]; + if (this._pages.indexOf(page) >= 0) continue; + this._pages.push(page); + } + this._syncScrollDirection(); + this._syncSizeMode(); + this._updatePageView(); + }, + _dispatchPageTurningEvent: function _dispatchPageTurningEvent() { + if (this._lastPageIdx === this._curPageIdx) return; + this._lastPageIdx = this._curPageIdx; + cc.Component.EventHandler.emitEvents(this.pageEvents, this, EventType.PAGE_TURNING); + this.node.emit("page-turning", this); + }, + _isScrollable: function _isScrollable(offset, index, nextIndex) { + if (this.sizeMode === SizeMode.Free) { + var curPageCenter, nextPageCenter; + if (this.direction === Direction.Horizontal) { + curPageCenter = this._scrollCenterOffsetX[index]; + nextPageCenter = this._scrollCenterOffsetX[nextIndex]; + return Math.abs(offset.x) >= Math.abs(curPageCenter - nextPageCenter) * this.scrollThreshold; + } + if (this.direction === Direction.Vertical) { + curPageCenter = this._scrollCenterOffsetY[index]; + nextPageCenter = this._scrollCenterOffsetY[nextIndex]; + return Math.abs(offset.y) >= Math.abs(curPageCenter - nextPageCenter) * this.scrollThreshold; + } + } else { + if (this.direction === Direction.Horizontal) return Math.abs(offset.x) >= this._view.width * this.scrollThreshold; + if (this.direction === Direction.Vertical) return Math.abs(offset.y) >= this._view.height * this.scrollThreshold; + } + }, + _isQuicklyScrollable: function _isQuicklyScrollable(touchMoveVelocity) { + if (this.direction === Direction.Horizontal) { + if (Math.abs(touchMoveVelocity.x) > this.autoPageTurningThreshold) return true; + } else if (this.direction === Direction.Vertical && Math.abs(touchMoveVelocity.y) > this.autoPageTurningThreshold) return true; + return false; + }, + _moveOffsetValue: function _moveOffsetValue(idx) { + var offset = cc.v2(0, 0); + this.sizeMode === SizeMode.Free ? this.direction === Direction.Horizontal ? offset.x = this._scrollCenterOffsetX[idx] : this.direction === Direction.Vertical && (offset.y = this._scrollCenterOffsetY[idx]) : this.direction === Direction.Horizontal ? offset.x = idx * this._view.width : this.direction === Direction.Vertical && (offset.y = idx * this._view.height); + return offset; + }, + _getDragDirection: function _getDragDirection(moveOffset) { + if (this.direction === Direction.Horizontal) { + if (0 === moveOffset.x) return 0; + return moveOffset.x > 0 ? 1 : -1; + } + if (this.direction === Direction.Vertical) { + if (0 === moveOffset.y) return 0; + return moveOffset.y < 0 ? 1 : -1; + } + }, + _handleReleaseLogic: function _handleReleaseLogic(touch) { + this._autoScrollToPage(); + if (this._scrolling) { + this._scrolling = false; + this._autoScrolling || this._dispatchEvent("scroll-ended"); + } + }, + _autoScrollToPage: function _autoScrollToPage() { + var bounceBackStarted = this._startBounceBackIfNeeded(); + if (bounceBackStarted) { + var bounceBackAmount = this._getHowMuchOutOfBoundary(); + bounceBackAmount = this._clampDelta(bounceBackAmount); + (bounceBackAmount.x > 0 || bounceBackAmount.y < 0) && (this._curPageIdx = 0 === this._pages.length ? 0 : this._pages.length - 1); + (bounceBackAmount.x < 0 || bounceBackAmount.y > 0) && (this._curPageIdx = 0); + this.indicator && this.indicator._changedState(); + } else { + var moveOffset = this._touchBeganPosition.sub(this._touchEndPosition); + var index = this._curPageIdx, nextIndex = index + this._getDragDirection(moveOffset); + var timeInSecond = this.pageTurningSpeed * Math.abs(index - nextIndex); + if (nextIndex < this._pages.length) { + if (this._isScrollable(moveOffset, index, nextIndex)) { + this.scrollToPage(nextIndex, timeInSecond); + return; + } + var touchMoveVelocity = this._calculateTouchMoveVelocity(); + if (this._isQuicklyScrollable(touchMoveVelocity)) { + this.scrollToPage(nextIndex, timeInSecond); + return; + } + } + this.scrollToPage(index, timeInSecond); + } + }, + _onTouchBegan: function _onTouchBegan(event, captureListeners) { + this._touchBeganPosition = event.touch.getLocation(); + this._super(event, captureListeners); + }, + _onTouchMoved: function _onTouchMoved(event, captureListeners) { + this._super(event, captureListeners); + }, + _onTouchEnded: function _onTouchEnded(event, captureListeners) { + this._touchEndPosition = event.touch.getLocation(); + this._super(event, captureListeners); + }, + _onTouchCancelled: function _onTouchCancelled(event, captureListeners) { + this._touchEndPosition = event.touch.getLocation(); + this._super(event, captureListeners); + }, + _onMouseWheel: function _onMouseWheel() {} + }); + cc.PageView = module.exports = PageView; + }), {} ], + 159: [ (function(require, module, exports) { + "use strict"; + var Direction = cc.Enum({ + HORIZONTAL: 0, + VERTICAL: 1 + }); + var PageViewIndicator = cc.Class({ + name: "cc.PageViewIndicator", + extends: require("./CCComponent"), + editor: false, + properties: { + _layout: null, + _pageView: null, + _indicators: [], + spriteFrame: { + default: null, + type: cc.SpriteFrame, + tooltip: false + }, + direction: { + default: Direction.HORIZONTAL, + type: Direction, + tooltip: false + }, + cellSize: { + default: cc.size(20, 20), + tooltip: false + }, + spacing: { + default: 0, + tooltip: false + } + }, + statics: { + Direction: Direction + }, + onLoad: function onLoad() { + this._updateLayout(); + }, + setPageView: function setPageView(target) { + this._pageView = target; + this._refresh(); + }, + _updateLayout: function _updateLayout() { + this._layout = this.getComponent(cc.Layout); + this._layout || (this._layout = this.addComponent(cc.Layout)); + if (this.direction === Direction.HORIZONTAL) { + this._layout.type = cc.Layout.Type.HORIZONTAL; + this._layout.spacingX = this.spacing; + } else if (this.direction === Direction.VERTICAL) { + this._layout.type = cc.Layout.Type.VERTICAL; + this._layout.spacingY = this.spacing; + } + this._layout.resizeMode = cc.Layout.ResizeMode.CONTAINER; + }, + _createIndicator: function _createIndicator() { + var node = new cc.Node(); + var sprite = node.addComponent(cc.Sprite); + sprite.spriteFrame = this.spriteFrame; + sprite.sizeMode = cc.Sprite.SizeMode.CUSTOM; + node.parent = this.node; + node.width = this.cellSize.width; + node.height = this.cellSize.height; + return node; + }, + _changedState: function _changedState() { + var indicators = this._indicators; + if (0 === indicators.length) return; + var idx = this._pageView._curPageIdx; + if (idx >= indicators.length) return; + for (var i = 0; i < indicators.length; ++i) { + var node = indicators[i]; + node.opacity = 127.5; + } + indicators[idx].opacity = 255; + }, + _refresh: function _refresh() { + if (!this._pageView) return; + var indicators = this._indicators; + var pages = this._pageView.getPages(); + if (pages.length === indicators.length) return; + var i = 0; + if (pages.length > indicators.length) for (i = 0; i < pages.length; ++i) indicators[i] || (indicators[i] = this._createIndicator()); else { + var count = indicators.length - pages.length; + for (i = count; i > 0; --i) { + var node = indicators[i - 1]; + this.node.removeChild(node); + indicators.splice(i - 1, 1); + } + } + this._layout && this._layout.enabledInHierarchy && this._layout.updateLayout(); + this._changedState(); + } + }); + cc.PageViewIndicator = module.exports = PageViewIndicator; + }), { + "./CCComponent": 150 + } ], + 160: [ (function(require, module, exports) { + "use strict"; + var misc = require("../utils/misc"); + var Component = require("./CCComponent"); + var Mode = cc.Enum({ + HORIZONTAL: 0, + VERTICAL: 1, + FILLED: 2 + }); + var ProgressBar = cc.Class({ + name: "cc.ProgressBar", + extends: Component, + editor: false, + _initBarSprite: function _initBarSprite() { + if (this.barSprite) { + var entity = this.barSprite.node; + if (!entity) return; + var nodeSize = this.node.getContentSize(); + var nodeAnchor = this.node.getAnchorPoint(); + var entitySize = entity.getContentSize(); + entity.parent === this.node && this.node.setContentSize(entitySize); + this.barSprite.fillType === cc.Sprite.FillType.RADIAL && (this.mode = Mode.FILLED); + var barSpriteSize = entity.getContentSize(); + this.mode === Mode.HORIZONTAL ? this.totalLength = barSpriteSize.width : this.mode === Mode.VERTICAL ? this.totalLength = barSpriteSize.height : this.totalLength = this.barSprite.fillRange; + if (entity.parent === this.node) { + var x = -nodeSize.width * nodeAnchor.x; + var y = 0; + entity.setPosition(cc.v2(x, y)); + } + } + }, + _updateBarStatus: function _updateBarStatus() { + if (this.barSprite) { + var entity = this.barSprite.node; + if (!entity) return; + var entityAnchorPoint = entity.getAnchorPoint(); + var entitySize = entity.getContentSize(); + var entityPosition = entity.getPosition(); + var anchorPoint = cc.v2(0, .5); + var progress = misc.clamp01(this.progress); + var actualLenth = this.totalLength * progress; + var finalContentSize; + var totalWidth; + var totalHeight; + switch (this.mode) { + case Mode.HORIZONTAL: + this.reverse && (anchorPoint = cc.v2(1, .5)); + finalContentSize = cc.size(actualLenth, entitySize.height); + totalWidth = this.totalLength; + totalHeight = entitySize.height; + break; + + case Mode.VERTICAL: + anchorPoint = this.reverse ? cc.v2(.5, 1) : cc.v2(.5, 0); + finalContentSize = cc.size(entitySize.width, actualLenth); + totalWidth = entitySize.width; + totalHeight = this.totalLength; + } + if (this.mode === Mode.FILLED) if (this.barSprite.type !== cc.Sprite.Type.FILLED) cc.warn("ProgressBar FILLED mode only works when barSprite's Type is FILLED!"); else { + this.reverse && (actualLenth *= -1); + this.barSprite.fillRange = actualLenth; + } else if (this.barSprite.type !== cc.Sprite.Type.FILLED) { + var anchorOffsetX = anchorPoint.x - entityAnchorPoint.x; + var anchorOffsetY = anchorPoint.y - entityAnchorPoint.y; + var finalPosition = cc.v2(totalWidth * anchorOffsetX, totalHeight * anchorOffsetY); + entity.setPosition(entityPosition.x + finalPosition.x, entityPosition.y + finalPosition.y); + entity.setAnchorPoint(anchorPoint); + entity.setContentSize(finalContentSize); + } else cc.warn("ProgressBar non-FILLED mode only works when barSprite's Type is non-FILLED!"); + } + }, + properties: { + barSprite: { + default: null, + type: cc.Sprite, + tooltip: false, + notify: function notify() { + this._initBarSprite(); + }, + animatable: false + }, + mode: { + default: Mode.HORIZONTAL, + type: Mode, + tooltip: false, + notify: function notify() { + if (this.barSprite) { + var entity = this.barSprite.node; + if (!entity) return; + var entitySize = entity.getContentSize(); + this.mode === Mode.HORIZONTAL ? this.totalLength = entitySize.width : this.mode === Mode.VERTICAL ? this.totalLength = entitySize.height : this.mode === Mode.FILLED && (this.totalLength = this.barSprite.fillRange); + } + }, + animatable: false + }, + _N$totalLength: 1, + totalLength: { + range: [ 0, Number.MAX_VALUE ], + tooltip: false, + get: function get() { + return this._N$totalLength; + }, + set: function set(value) { + this.mode === Mode.FILLED && (value = misc.clamp01(value)); + this._N$totalLength = value; + this._updateBarStatus(); + } + }, + progress: { + default: 1, + type: cc.Float, + range: [ 0, 1, .1 ], + slide: true, + tooltip: false, + notify: function notify() { + this._updateBarStatus(); + } + }, + reverse: { + default: false, + tooltip: false, + notify: function notify() { + this.barSprite && (this.barSprite.fillStart = 1 - this.barSprite.fillStart); + this._updateBarStatus(); + }, + animatable: false + } + }, + statics: { + Mode: Mode + } + }); + cc.ProgressBar = module.exports = ProgressBar; + }), { + "../utils/misc": 325, + "./CCComponent": 150 + } ], + 161: [ (function(require, module, exports) { + "use strict"; + var _assembler = _interopRequireDefault(require("../renderer/assembler")); + var _materialVariant = _interopRequireDefault(require("../assets/material/material-variant")); + var _valueTypes = require("../value-types"); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + var Component = require("./CCComponent"); + var RenderFlow = require("../renderer/render-flow"); + var Material = require("../assets/material/CCMaterial"); + var _temp_color = new _valueTypes.Color(); + var RenderComponent = cc.Class({ + name: "RenderComponent", + extends: Component, + editor: false, + properties: { + _materials: { + default: [], + type: Material + }, + materials: { + get: function get() { + return this._materials; + }, + set: function set(val) { + this._materials = val; + this._activateMaterial(); + }, + type: [ Material ], + displayName: "Materials", + animatable: false + } + }, + ctor: function ctor() { + this._vertsDirty = true; + this._assembler = null; + }, + _resetAssembler: function _resetAssembler() { + _assembler["default"].init(this); + this._updateColor(); + this.setVertsDirty(); + }, + __preload: function __preload() { + this._resetAssembler(); + this._activateMaterial(); + }, + onEnable: function onEnable() { + this.node._renderComponent && (this.node._renderComponent.enabled = false); + this.node._renderComponent = this; + this.node._renderFlag |= RenderFlow.FLAG_OPACITY_COLOR; + this.setVertsDirty(); + }, + onDisable: function onDisable() { + this.node._renderComponent = null; + this.disableRender(); + }, + onDestroy: function onDestroy() { + var materials = this._materials; + for (var i = 0; i < materials.length; i++) cc.pool.material.put(materials[i]); + materials.length = 0; + cc.pool.assembler.put(this._assembler); + this.disableRender(); + }, + setVertsDirty: function setVertsDirty() { + this._vertsDirty = true; + this.markForRender(true); + }, + _on3DNodeChanged: function _on3DNodeChanged() { + this._resetAssembler(); + }, + _validateRender: function _validateRender() {}, + markForValidate: function markForValidate() { + cc.RenderFlow.registerValidate(this); + }, + markForRender: function markForRender(enable) { + var flag = RenderFlow.FLAG_RENDER | RenderFlow.FLAG_UPDATE_RENDER_DATA; + if (enable) { + this.node._renderFlag |= flag; + this.markForValidate(); + } else this.node._renderFlag &= ~flag; + }, + disableRender: function disableRender() { + this.node._renderFlag &= ~(RenderFlow.FLAG_RENDER | RenderFlow.FLAG_UPDATE_RENDER_DATA); + }, + getMaterial: function getMaterial(index) { + if (index < 0 || index >= this._materials.length) return null; + var material = this._materials[index]; + if (!material) return null; + var instantiated = _materialVariant["default"].create(material, this); + instantiated !== material && this.setMaterial(index, instantiated); + return instantiated; + }, + getMaterials: function getMaterials() { + var materials = this._materials; + for (var i = 0; i < materials.length; i++) materials[i] = _materialVariant["default"].create(materials[i], this); + return materials; + }, + setMaterial: function setMaterial(index, material) { + if (material !== this._materials[index]) { + material = _materialVariant["default"].create(material, this); + this._materials[index] = material; + } + this._updateMaterial(); + this.markForRender(true); + return material; + }, + _getDefaultMaterial: function _getDefaultMaterial() { + return Material.getBuiltinMaterial("2d-sprite"); + }, + _activateMaterial: function _activateMaterial() { + var materials = this._materials; + if (!materials[0]) { + var material = this._getDefaultMaterial(); + materials[0] = material; + } + for (var i = 0; i < materials.length; i++) materials[i] = _materialVariant["default"].create(materials[i], this); + this._updateMaterial(); + }, + _updateMaterial: function _updateMaterial() {}, + _updateColor: function _updateColor() { + if (this._assembler.updateColor) { + var premultiply = this.srcBlendFactor === cc.macro.BlendFactor.ONE; + premultiply && _valueTypes.Color.premultiplyAlpha(_temp_color, this.node._color); + var color = premultiply ? _temp_color._val : null; + this._assembler.updateColor(this, color); + } + }, + _checkBacth: function _checkBacth(renderer, cullingMask) { + var material = this._materials[0]; + if (material && material.getHash() !== renderer.material.getHash() || renderer.cullingMask !== cullingMask) { + renderer._flush(); + renderer.node = material.getDefine("CC_USE_MODEL") ? this.node : renderer._dummyNode; + renderer.material = material; + renderer.cullingMask = cullingMask; + } + } + }); + cc.RenderComponent = module.exports = RenderComponent; + }), { + "../assets/material/CCMaterial": 125, + "../assets/material/material-variant": 132, + "../renderer/assembler": 269, + "../renderer/render-flow": 273, + "../value-types": 340, + "./CCComponent": 150 + } ], + 162: [ (function(require, module, exports) { + "use strict"; + var js = require("../platform/js"); + var macro = require("../platform/CCMacro"); + var textUtils = require("../utils/text-utils"); + var HtmlTextParser = require("../utils/html-text-parser"); + var _htmlTextParser = new HtmlTextParser(); + var HorizontalAlign = macro.TextAlignment; + var VerticalAlign = macro.VerticalTextAlignment; + var RichTextChildName = "RICHTEXT_CHILD"; + var RichTextChildImageName = "RICHTEXT_Image_CHILD"; + var CacheMode = cc.Label.CacheMode; + function debounce(func, wait, immediate) { + var timeout; + return function() { + var context = this; + var later = function later() { + timeout = null; + immediate || func.apply(context, arguments); + }; + var callNow = immediate && !timeout; + clearTimeout(timeout); + timeout = setTimeout(later, wait); + callNow && func.apply(context, arguments); + }; + } + var pool = new js.Pool(function(node) { + false; + false; + if (!cc.isValid(node)) return false; + var outline = node.getComponent(cc.LabelOutline); + outline && (outline.width = 0); + return true; + }, 20); + pool.get = function(string, richtext) { + var labelNode = this._get(); + if (!labelNode) { + labelNode = new cc.PrivateNode(RichTextChildName); + labelNode._objFlags |= cc.Object.Flags.DontSave; + } + labelNode.setPosition(0, 0); + labelNode.setAnchorPoint(.5, .5); + labelNode.skewX = 0; + var labelComponent = labelNode.getComponent(cc.Label); + labelComponent || (labelComponent = labelNode.addComponent(cc.Label)); + labelComponent.string = ""; + labelComponent.horizontalAlign = HorizontalAlign.LEFT; + labelComponent.verticalAlign = VerticalAlign.CENTER; + labelComponent._forceUseCanvas = true; + return labelNode; + }; + var RichText = cc.Class({ + name: "cc.RichText", + extends: cc.Component, + ctor: function ctor() { + this._textArray = null; + this._labelSegments = []; + this._labelSegmentsCache = []; + this._linesWidth = []; + false; + this._updateRichTextStatus = this._updateRichText; + }, + editor: false, + properties: { + string: { + default: "RichText", + multiline: true, + tooltip: false, + notify: function notify() { + this._updateRichTextStatus(); + } + }, + horizontalAlign: { + default: HorizontalAlign.LEFT, + type: HorizontalAlign, + tooltip: false, + animatable: false, + notify: function notify(oldValue) { + if (this.horizontalAlign === oldValue) return; + this._layoutDirty = true; + this._updateRichTextStatus(); + } + }, + fontSize: { + default: 40, + tooltip: false, + notify: function notify(oldValue) { + if (this.fontSize === oldValue) return; + this._layoutDirty = true; + this._updateRichTextStatus(); + } + }, + _fontFamily: "Arial", + fontFamily: { + tooltip: false, + get: function get() { + return this._fontFamily; + }, + set: function set(value) { + if (this._fontFamily === value) return; + this._fontFamily = value; + this._layoutDirty = true; + this._updateRichTextStatus(); + }, + animatable: false + }, + font: { + default: null, + type: cc.TTFFont, + tooltip: false, + notify: function notify(oldValue) { + if (this.font === oldValue) return; + this._layoutDirty = true; + if (this.font) { + false; + this.useSystemFont = false; + this._onTTFLoaded(); + } else this.useSystemFont = true; + this._updateRichTextStatus(); + } + }, + _isSystemFontUsed: true, + useSystemFont: { + get: function get() { + return this._isSystemFontUsed; + }, + set: function set(value) { + if (this._isSystemFontUsed === value) return; + this._isSystemFontUsed = value; + false; + this._layoutDirty = true; + this._updateRichTextStatus(); + }, + animatable: false, + tooltip: false + }, + cacheMode: { + default: CacheMode.NONE, + type: CacheMode, + tooltip: false, + notify: function notify(oldValue) { + if (this.cacheMode === oldValue) return; + this._updateRichTextStatus(); + }, + animatable: false + }, + maxWidth: { + default: 0, + tooltip: false, + notify: function notify(oldValue) { + if (this.maxWidth === oldValue) return; + this._layoutDirty = true; + this._updateRichTextStatus(); + } + }, + lineHeight: { + default: 40, + tooltip: false, + notify: function notify(oldValue) { + if (this.lineHeight === oldValue) return; + this._layoutDirty = true; + this._updateRichTextStatus(); + } + }, + imageAtlas: { + default: null, + type: cc.SpriteAtlas, + tooltip: false, + notify: function notify(oldValue) { + if (this.imageAtlas === oldValue) return; + this._layoutDirty = true; + this._updateRichTextStatus(); + } + }, + handleTouchEvent: { + default: true, + tooltip: false, + notify: function notify(oldValue) { + if (this.handleTouchEvent === oldValue) return; + this.enabledInHierarchy && (this.handleTouchEvent ? this._addEventListeners() : this._removeEventListeners()); + } + } + }, + statics: { + HorizontalAlign: HorizontalAlign, + VerticalAlign: VerticalAlign + }, + onEnable: function onEnable() { + this.handleTouchEvent && this._addEventListeners(); + this._onTTFLoaded(); + this._activateChildren(true); + }, + onDisable: function onDisable() { + this.handleTouchEvent && this._removeEventListeners(); + this._activateChildren(false); + }, + _onColorChanged: function _onColorChanged(parentColor) { + var children = this.node.children; + children.forEach((function(childNode) { + childNode.color = parentColor; + })); + }, + _addEventListeners: function _addEventListeners() { + this.node.on(cc.Node.EventType.TOUCH_END, this._onTouchEnded, this); + this.node.on(cc.Node.EventType.COLOR_CHANGED, this._onColorChanged, this); + }, + _removeEventListeners: function _removeEventListeners() { + this.node.off(cc.Node.EventType.TOUCH_END, this._onTouchEnded, this); + this.node.off(cc.Node.EventType.COLOR_CHANGED, this._onColorChanged, this); + }, + _updateLabelSegmentTextAttributes: function _updateLabelSegmentTextAttributes() { + this._labelSegments.forEach(function(item) { + this._applyTextAttribute(item, null, true); + }.bind(this)); + }, + _createFontLabel: function _createFontLabel(string) { + return pool.get(string, this); + }, + _onTTFLoaded: function _onTTFLoaded() { + if (this.font instanceof cc.TTFFont) if (this.font._nativeAsset) { + this._layoutDirty = true; + this._updateRichTextStatus(); + } else { + var self = this; + cc.assetManager.postLoadNative(this.font, (function(err) { + self._layoutDirty = true; + self._updateRichTextStatus(); + })); + } else { + this._layoutDirty = true; + this._updateRichTextStatus(); + } + }, + _measureText: function _measureText(styleIndex, string) { + var self = this; + var func = function func(string) { + var label; + if (0 === self._labelSegmentsCache.length) { + label = self._createFontLabel(string); + self._labelSegmentsCache.push(label); + } else label = self._labelSegmentsCache[0]; + label._styleIndex = styleIndex; + self._applyTextAttribute(label, string, true); + var labelSize = label.getContentSize(); + return labelSize.width; + }; + return string ? func(string) : func; + }, + _onTouchEnded: function _onTouchEnded(event) { + var _this = this; + var components = this.node.getComponents(cc.Component); + var _loop = function _loop(i) { + var labelSegment = _this._labelSegments[i]; + var clickHandler = labelSegment._clickHandler; + var clickParam = labelSegment._clickParam; + if (clickHandler && _this._containsTouchLocation(labelSegment, event.touch.getLocation())) { + components.forEach((function(component) { + component.enabledInHierarchy && component[clickHandler] && component[clickHandler](event, clickParam); + })); + event.stopPropagation(); + } + }; + for (var i = 0; i < this._labelSegments.length; ++i) _loop(i); + }, + _containsTouchLocation: function _containsTouchLocation(label, point) { + var myRect = label.getBoundingBoxToWorld(); + return myRect.contains(point); + }, + _resetState: function _resetState() { + var children = this.node.children; + for (var i = children.length - 1; i >= 0; i--) { + var child = children[i]; + if (child.name === RichTextChildName || child.name === RichTextChildImageName) { + child.parent === this.node ? child.parent = null : children.splice(i, 1); + child.name === RichTextChildName && pool.put(child); + } + } + this._labelSegments.length = 0; + this._labelSegmentsCache.length = 0; + this._linesWidth.length = 0; + this._lineOffsetX = 0; + this._lineCount = 1; + this._labelWidth = 0; + this._labelHeight = 0; + this._layoutDirty = true; + }, + onRestore: false, + _activateChildren: function _activateChildren(active) { + for (var i = this.node.children.length - 1; i >= 0; i--) { + var child = this.node.children[i]; + child.name !== RichTextChildName && child.name !== RichTextChildImageName || (child.active = active); + } + }, + _addLabelSegment: function _addLabelSegment(stringToken, styleIndex) { + var labelSegment; + labelSegment = 0 === this._labelSegmentsCache.length ? this._createFontLabel(stringToken) : this._labelSegmentsCache.pop(); + labelSegment._styleIndex = styleIndex; + labelSegment._lineCount = this._lineCount; + labelSegment.active = this.node.active; + labelSegment.setAnchorPoint(0, 0); + this._applyTextAttribute(labelSegment, stringToken, false); + this.node.addChild(labelSegment); + this._labelSegments.push(labelSegment); + return labelSegment; + }, + _updateRichTextWithMaxWidth: function _updateRichTextWithMaxWidth(labelString, labelWidth, styleIndex) { + var fragmentWidth = labelWidth; + var labelSegment; + if (this._lineOffsetX > 0 && fragmentWidth + this._lineOffsetX > this.maxWidth) { + var checkStartIndex = 0; + while (this._lineOffsetX <= this.maxWidth) { + var checkEndIndex = this._getFirstWordLen(labelString, checkStartIndex, labelString.length); + var checkString = labelString.substr(checkStartIndex, checkEndIndex); + var checkStringWidth = this._measureText(styleIndex, checkString); + if (!(this._lineOffsetX + checkStringWidth <= this.maxWidth)) { + if (checkStartIndex > 0) { + var remainingString = labelString.substr(0, checkStartIndex); + this._addLabelSegment(remainingString, styleIndex); + labelString = labelString.substr(checkStartIndex, labelString.length); + fragmentWidth = this._measureText(styleIndex, labelString); + } + this._updateLineInfo(); + break; + } + this._lineOffsetX += checkStringWidth; + checkStartIndex += checkEndIndex; + } + } + if (fragmentWidth > this.maxWidth) { + var fragments = textUtils.fragmentText(labelString, fragmentWidth, this.maxWidth, this._measureText(styleIndex)); + for (var k = 0; k < fragments.length; ++k) { + var splitString = fragments[k]; + labelSegment = this._addLabelSegment(splitString, styleIndex); + var labelSize = labelSegment.getContentSize(); + this._lineOffsetX += labelSize.width; + fragments.length > 1 && k < fragments.length - 1 && this._updateLineInfo(); + } + } else { + this._lineOffsetX += fragmentWidth; + this._addLabelSegment(labelString, styleIndex); + } + }, + _isLastComponentCR: function _isLastComponentCR(stringToken) { + return stringToken.length - 1 === stringToken.lastIndexOf("\n"); + }, + _updateLineInfo: function _updateLineInfo() { + this._linesWidth.push(this._lineOffsetX); + this._lineOffsetX = 0; + this._lineCount++; + }, + _needsUpdateTextLayout: function _needsUpdateTextLayout(newTextArray) { + if (this._layoutDirty || !this._textArray || !newTextArray) return true; + if (this._textArray.length !== newTextArray.length) return true; + for (var i = 0; i < this._textArray.length; ++i) { + var oldItem = this._textArray[i]; + var newItem = newTextArray[i]; + if (oldItem.text !== newItem.text) return true; + var oldStyle = oldItem.style, newStyle = newItem.style; + if (oldStyle) { + if (newStyle) { + if (!oldStyle.outline !== !newStyle.outline) return true; + if (oldStyle.size !== newStyle.size || !oldStyle.italic !== !newStyle.italic || oldStyle.isImage !== newStyle.isImage) return true; + if (oldStyle.src !== newStyle.src || oldStyle.imageAlign !== newStyle.imageAlign || oldStyle.imageHeight !== newStyle.imageHeight || oldStyle.imageWidth !== newStyle.imageWidth || oldStyle.imageOffset !== newStyle.imageOffset) return true; + } else if (oldStyle.size || oldStyle.italic || oldStyle.isImage || oldStyle.outline) return true; + } else if (newStyle && (newStyle.size || newStyle.italic || newStyle.isImage || newStyle.outline)) return true; + } + return false; + }, + _addRichTextImageElement: function _addRichTextImageElement(richTextElement) { + var spriteFrameName = richTextElement.style.src; + var spriteFrame = this.imageAtlas.getSpriteFrame(spriteFrameName); + if (spriteFrame) { + var spriteNode = new cc.PrivateNode(RichTextChildImageName); + spriteNode._objFlags |= cc.Object.Flags.DontSave; + var spriteComponent = spriteNode.addComponent(cc.Sprite); + switch (richTextElement.style.imageAlign) { + case "top": + spriteNode.setAnchorPoint(0, 1); + break; + + case "center": + spriteNode.setAnchorPoint(0, .5); + break; + + default: + spriteNode.setAnchorPoint(0, 0); + } + richTextElement.style.imageOffset && (spriteNode._imageOffset = richTextElement.style.imageOffset); + spriteComponent.type = cc.Sprite.Type.SLICED; + spriteComponent.sizeMode = cc.Sprite.SizeMode.CUSTOM; + this.node.addChild(spriteNode); + this._labelSegments.push(spriteNode); + var spriteRect = spriteFrame.getRect(); + var scaleFactor = 1; + var spriteWidth = spriteRect.width; + var spriteHeight = spriteRect.height; + var expectWidth = richTextElement.style.imageWidth; + var expectHeight = richTextElement.style.imageHeight; + if (expectHeight > 0) { + scaleFactor = expectHeight / spriteHeight; + spriteWidth *= scaleFactor; + spriteHeight *= scaleFactor; + } else { + scaleFactor = this.lineHeight / spriteHeight; + spriteWidth *= scaleFactor; + spriteHeight *= scaleFactor; + } + expectWidth > 0 && (spriteWidth = expectWidth); + if (this.maxWidth > 0) { + this._lineOffsetX + spriteWidth > this.maxWidth && this._updateLineInfo(); + this._lineOffsetX += spriteWidth; + } else { + this._lineOffsetX += spriteWidth; + this._lineOffsetX > this._labelWidth && (this._labelWidth = this._lineOffsetX); + } + spriteComponent.spriteFrame = spriteFrame; + spriteNode.setContentSize(spriteWidth, spriteHeight); + spriteNode._lineCount = this._lineCount; + if (richTextElement.style.event) { + richTextElement.style.event.click && (spriteNode._clickHandler = richTextElement.style.event.click); + richTextElement.style.event.param ? spriteNode._clickParam = richTextElement.style.event.param : spriteNode._clickParam = ""; + } else spriteNode._clickHandler = null; + } else cc.warnID(4400); + }, + _updateRichText: function _updateRichText() { + if (!this.enabledInHierarchy) return; + var newTextArray = _htmlTextParser.parse(this.string); + if (!this._needsUpdateTextLayout(newTextArray)) { + this._textArray = newTextArray; + this._updateLabelSegmentTextAttributes(); + return; + } + this._textArray = newTextArray; + this._resetState(); + var lastEmptyLine = false; + var label; + var labelSize; + for (var i = 0; i < this._textArray.length; ++i) { + var richTextElement = this._textArray[i]; + var text = richTextElement.text; + if ("" === text) { + if (richTextElement.style && richTextElement.style.newline) { + this._updateLineInfo(); + continue; + } + if (richTextElement.style && richTextElement.style.isImage && this.imageAtlas) { + this._addRichTextImageElement(richTextElement); + continue; + } + } + var multilineTexts = text.split("\n"); + for (var j = 0; j < multilineTexts.length; ++j) { + var labelString = multilineTexts[j]; + if ("" === labelString) { + if (this._isLastComponentCR(text) && j === multilineTexts.length - 1) continue; + this._updateLineInfo(); + lastEmptyLine = true; + continue; + } + lastEmptyLine = false; + if (this.maxWidth > 0) { + var labelWidth = this._measureText(i, labelString); + this._updateRichTextWithMaxWidth(labelString, labelWidth, i); + multilineTexts.length > 1 && j < multilineTexts.length - 1 && this._updateLineInfo(); + } else { + label = this._addLabelSegment(labelString, i); + labelSize = label.getContentSize(); + this._lineOffsetX += labelSize.width; + this._lineOffsetX > this._labelWidth && (this._labelWidth = this._lineOffsetX); + multilineTexts.length > 1 && j < multilineTexts.length - 1 && this._updateLineInfo(); + } + } + } + lastEmptyLine || this._linesWidth.push(this._lineOffsetX); + this.maxWidth > 0 && (this._labelWidth = this.maxWidth); + this._labelHeight = (this._lineCount + textUtils.BASELINE_RATIO) * this.lineHeight; + this.node.setContentSize(this._labelWidth, this._labelHeight); + this._updateRichTextPosition(); + this._layoutDirty = false; + }, + _getFirstWordLen: function _getFirstWordLen(text, startIndex, textLen) { + var character = text.charAt(startIndex); + if (textUtils.isUnicodeCJK(character) || textUtils.isUnicodeSpace(character)) return 1; + var len = 1; + for (var index = startIndex + 1; index < textLen; ++index) { + character = text.charAt(index); + if (textUtils.isUnicodeSpace(character) || textUtils.isUnicodeCJK(character)) break; + len++; + } + return len; + }, + _updateRichTextPosition: function _updateRichTextPosition() { + var nextTokenX = 0; + var nextLineIndex = 1; + var totalLineCount = this._lineCount; + for (var i = 0; i < this._labelSegments.length; ++i) { + var label = this._labelSegments[i]; + var lineCount = label._lineCount; + if (lineCount > nextLineIndex) { + nextTokenX = 0; + nextLineIndex = lineCount; + } + var lineOffsetX = 0; + switch (this.horizontalAlign) { + case HorizontalAlign.LEFT: + lineOffsetX = -this._labelWidth / 2; + break; + + case HorizontalAlign.CENTER: + lineOffsetX = -this._linesWidth[lineCount - 1] / 2; + break; + + case HorizontalAlign.RIGHT: + lineOffsetX = this._labelWidth / 2 - this._linesWidth[lineCount - 1]; + } + label.x = nextTokenX + lineOffsetX; + var labelSize = label.getContentSize(); + label.y = this.lineHeight * (totalLineCount - lineCount) - this._labelHeight / 2; + lineCount === nextLineIndex && (nextTokenX += labelSize.width); + var sprite = label.getComponent(cc.Sprite); + if (sprite) { + var lineHeightSet = this.lineHeight; + var lineHeightReal = this.lineHeight * (1 + textUtils.BASELINE_RATIO); + switch (label.anchorY) { + case 1: + label.y += lineHeightSet + (lineHeightReal - lineHeightSet) / 2; + break; + + case .5: + label.y += lineHeightReal / 2; + break; + + default: + label.y += (lineHeightReal - lineHeightSet) / 2; + } + if (label._imageOffset) { + var offsets = label._imageOffset.split(","); + if (1 === offsets.length && offsets[0]) { + var offsetY = parseFloat(offsets[0]); + Number.isInteger(offsetY) && (label.y += offsetY); + } else if (2 === offsets.length) { + var offsetX = parseFloat(offsets[0]); + var _offsetY = parseFloat(offsets[1]); + Number.isInteger(offsetX) && (label.x += offsetX); + Number.isInteger(_offsetY) && (label.y += _offsetY); + } + } + } + var outline = label.getComponent(cc.LabelOutline); + outline && outline.width && (label.y = label.y - outline.width); + } + }, + _convertLiteralColorValue: function _convertLiteralColorValue(color) { + var colorValue = color.toUpperCase(); + if (cc.Color[colorValue]) return cc.Color[colorValue]; + var out = cc.color(); + return out.fromHEX(color); + }, + _applyTextAttribute: function _applyTextAttribute(labelNode, string, force) { + var labelComponent = labelNode.getComponent(cc.Label); + if (!labelComponent) return; + var index = labelNode._styleIndex; + var textStyle = null; + this._textArray[index] && (textStyle = this._textArray[index].style); + textStyle && textStyle.color ? labelNode.color = this._convertLiteralColorValue(textStyle.color) : labelNode.color = this.node.color; + labelComponent.cacheMode = this.cacheMode; + var isAsset = this.font instanceof cc.Font; + isAsset && !this._isSystemFontUsed ? labelComponent.font = this.font : labelComponent.fontFamily = this.fontFamily; + labelComponent.useSystemFont = this._isSystemFontUsed; + labelComponent.lineHeight = this.lineHeight; + labelComponent.enableBold = textStyle && textStyle.bold; + labelComponent.enableItalics = textStyle && textStyle.italic; + textStyle && textStyle.italic && (labelNode.skewX = 12); + labelComponent.enableUnderline = textStyle && textStyle.underline; + if (textStyle && textStyle.outline) { + var labelOutlineComponent = labelNode.getComponent(cc.LabelOutline); + labelOutlineComponent || (labelOutlineComponent = labelNode.addComponent(cc.LabelOutline)); + labelOutlineComponent.color = this._convertLiteralColorValue(textStyle.outline.color); + labelOutlineComponent.width = textStyle.outline.width; + } + textStyle && textStyle.size ? labelComponent.fontSize = textStyle.size : labelComponent.fontSize = this.fontSize; + if (null !== string) { + "string" !== typeof string && (string = "" + string); + labelComponent.string = string; + } + force && labelComponent._forceUpdateRenderData(); + if (textStyle && textStyle.event) { + textStyle.event.click && (labelNode._clickHandler = textStyle.event.click); + textStyle.event.param ? labelNode._clickParam = textStyle.event.param : labelNode._clickParam = ""; + } else labelNode._clickHandler = null; + }, + onDestroy: function onDestroy() { + for (var i = 0; i < this._labelSegments.length; ++i) { + this._labelSegments[i].removeFromParent(); + pool.put(this._labelSegments[i]); + } + } + }); + cc.RichText = module.exports = RichText; + }), { + "../platform/CCMacro": 245, + "../platform/js": 261, + "../utils/html-text-parser": 323, + "../utils/text-utils": 332 + } ], + 163: [ (function(require, module, exports) { + "use strict"; + var Widget = require("./CCWidget"); + var WidgetManager = require("../base-ui/CCWidgetManager"); + var SafeArea = cc.Class({ + name: "cc.SafeArea", + extends: require("./CCComponent"), + editor: false, + onEnable: function onEnable() { + this.updateArea(); + cc.view.on("canvas-resize", this.updateArea, this); + }, + onDisable: function onDisable() { + cc.view.off("canvas-resize", this.updateArea, this); + }, + updateArea: function updateArea() { + var widget = this.node.getComponent(Widget); + if (!widget) return; + false; + widget.updateAlignment(); + var lastPos = this.node.position; + var lastAnchorPoint = this.node.getAnchorPoint(); + widget.isAlignTop = widget.isAlignBottom = widget.isAlignLeft = widget.isAlignRight = true; + var screenWidth = cc.winSize.width, screenHeight = cc.winSize.height; + var safeArea = cc.sys.getSafeAreaRect(); + widget.top = screenHeight - safeArea.y - safeArea.height; + widget.bottom = safeArea.y; + widget.left = safeArea.x; + widget.right = screenWidth - safeArea.x - safeArea.width; + widget.updateAlignment(); + var curPos = this.node.position; + var anchorX = lastAnchorPoint.x - (curPos.x - lastPos.x) / this.node.width; + var anchorY = lastAnchorPoint.y - (curPos.y - lastPos.y) / this.node.height; + this.node.setAnchorPoint(anchorX, anchorY); + WidgetManager.add(widget); + } + }); + cc.SafeArea = module.exports = SafeArea; + }), { + "../base-ui/CCWidgetManager": 134, + "./CCComponent": 150, + "./CCWidget": 173 + } ], + 164: [ (function(require, module, exports) { + "use strict"; + var misc = require("../utils/misc"); + var Component = require("./CCComponent"); + var GETTINGSHORTERFACTOR = 20; + var Direction = cc.Enum({ + HORIZONTAL: 0, + VERTICAL: 1 + }); + var Scrollbar = cc.Class({ + name: "cc.Scrollbar", + extends: require("./CCComponent"), + editor: false, + properties: { + _scrollView: null, + _touching: false, + _autoHideRemainingTime: { + default: 0, + serializable: false + }, + _opacity: 255, + handle: { + default: null, + type: cc.Sprite, + tooltip: false, + notify: function notify() { + this._onScroll(cc.v2(0, 0)); + }, + animatable: false + }, + direction: { + default: Direction.HORIZONTAL, + type: Direction, + tooltip: false, + notify: function notify() { + this._onScroll(cc.v2(0, 0)); + }, + animatable: false + }, + enableAutoHide: { + default: true, + animatable: false, + tooltip: false + }, + autoHideTime: { + default: 1, + animatable: false, + tooltip: false + } + }, + statics: { + Direction: Direction + }, + setTargetScrollView: function setTargetScrollView(scrollView) { + this._scrollView = scrollView; + }, + _convertToScrollViewSpace: function _convertToScrollViewSpace(content) { + var scrollViewNode = this._scrollView.node; + var worldSpacePos = content.convertToWorldSpaceAR(cc.v2(-content.anchorX * content.width, -content.anchorY * content.height)); + var scrollViewSpacePos = scrollViewNode.convertToNodeSpaceAR(worldSpacePos); + scrollViewSpacePos.x += scrollViewNode.anchorX * scrollViewNode.width; + scrollViewSpacePos.y += scrollViewNode.anchorY * scrollViewNode.height; + return scrollViewSpacePos; + }, + _setOpacity: function _setOpacity(opacity) { + if (this.handle) { + this.node.opacity = opacity; + this.handle.node.opacity = opacity; + } + }, + _onScroll: function _onScroll(outOfBoundary) { + if (this._scrollView) { + var content = this._scrollView.content; + if (content) { + var contentSize = content.getContentSize(); + var scrollViewSize = this._scrollView.node.getContentSize(); + var handleNodeSize = this.node.getContentSize(); + if (this._conditionalDisableScrollBar(contentSize, scrollViewSize)) return; + if (this.enableAutoHide) { + this._autoHideRemainingTime = this.autoHideTime; + this._setOpacity(this._opacity); + } + var contentMeasure = 0; + var scrollViewMeasure = 0; + var outOfBoundaryValue = 0; + var contentPosition = 0; + var handleNodeMeasure = 0; + if (this.direction === Direction.HORIZONTAL) { + contentMeasure = contentSize.width; + scrollViewMeasure = scrollViewSize.width; + handleNodeMeasure = handleNodeSize.width; + outOfBoundaryValue = outOfBoundary.x; + contentPosition = -this._convertToScrollViewSpace(content).x; + } else if (this.direction === Direction.VERTICAL) { + contentMeasure = contentSize.height; + scrollViewMeasure = scrollViewSize.height; + handleNodeMeasure = handleNodeSize.height; + outOfBoundaryValue = outOfBoundary.y; + contentPosition = -this._convertToScrollViewSpace(content).y; + } + var length = this._calculateLength(contentMeasure, scrollViewMeasure, handleNodeMeasure, outOfBoundaryValue); + var position = this._calculatePosition(contentMeasure, scrollViewMeasure, handleNodeMeasure, contentPosition, outOfBoundaryValue, length); + this._updateLength(length); + this._updateHanlderPosition(position); + } + } + }, + _updateHanlderPosition: function _updateHanlderPosition(position) { + if (this.handle) { + var oldPosition = this._fixupHandlerPosition(); + this.handle.node.setPosition(position.x + oldPosition.x, position.y + oldPosition.y); + } + }, + _fixupHandlerPosition: function _fixupHandlerPosition() { + var barSize = this.node.getContentSize(); + var barAnchor = this.node.getAnchorPoint(); + var handleSize = this.handle.node.getContentSize(); + var handleParent = this.handle.node.parent; + var leftBottomWorldPosition = this.node.convertToWorldSpaceAR(cc.v2(-barSize.width * barAnchor.x, -barSize.height * barAnchor.y)); + var fixupPosition = handleParent.convertToNodeSpaceAR(leftBottomWorldPosition); + this.direction === Direction.HORIZONTAL ? fixupPosition = cc.v2(fixupPosition.x, fixupPosition.y + (barSize.height - handleSize.height) / 2) : this.direction === Direction.VERTICAL && (fixupPosition = cc.v2(fixupPosition.x + (barSize.width - handleSize.width) / 2, fixupPosition.y)); + this.handle.node.setPosition(fixupPosition); + return fixupPosition; + }, + _onTouchBegan: function _onTouchBegan() { + if (!this.enableAutoHide) return; + this._touching = true; + }, + _conditionalDisableScrollBar: function _conditionalDisableScrollBar(contentSize, scrollViewSize) { + if (contentSize.width <= scrollViewSize.width && this.direction === Direction.HORIZONTAL) return true; + if (contentSize.height <= scrollViewSize.height && this.direction === Direction.VERTICAL) return true; + return false; + }, + _onTouchEnded: function _onTouchEnded() { + if (!this.enableAutoHide) return; + this._touching = false; + if (this.autoHideTime <= 0) return; + if (this._scrollView) { + var content = this._scrollView.content; + if (content) { + var contentSize = content.getContentSize(); + var scrollViewSize = this._scrollView.node.getContentSize(); + if (this._conditionalDisableScrollBar(contentSize, scrollViewSize)) return; + } + } + this._autoHideRemainingTime = this.autoHideTime; + }, + _calculateLength: function _calculateLength(contentMeasure, scrollViewMeasure, handleNodeMeasure, outOfBoundary) { + var denominatorValue = contentMeasure; + outOfBoundary && (denominatorValue += (outOfBoundary > 0 ? outOfBoundary : -outOfBoundary) * GETTINGSHORTERFACTOR); + var lengthRation = scrollViewMeasure / denominatorValue; + return handleNodeMeasure * lengthRation; + }, + _calculatePosition: function _calculatePosition(contentMeasure, scrollViewMeasure, handleNodeMeasure, contentPosition, outOfBoundary, actualLenth) { + var denominatorValue = contentMeasure - scrollViewMeasure; + outOfBoundary && (denominatorValue += Math.abs(outOfBoundary)); + var positionRatio = 0; + if (denominatorValue) { + positionRatio = contentPosition / denominatorValue; + positionRatio = misc.clamp01(positionRatio); + } + var position = (handleNodeMeasure - actualLenth) * positionRatio; + return this.direction === Direction.VERTICAL ? cc.v2(0, position) : cc.v2(position, 0); + }, + _updateLength: function _updateLength(length) { + if (this.handle) { + var handleNode = this.handle.node; + var handleNodeSize = handleNode.getContentSize(); + handleNode.setAnchorPoint(cc.v2(0, 0)); + this.direction === Direction.HORIZONTAL ? handleNode.setContentSize(length, handleNodeSize.height) : handleNode.setContentSize(handleNodeSize.width, length); + } + }, + _processAutoHide: function _processAutoHide(deltaTime) { + if (!this.enableAutoHide || this._autoHideRemainingTime <= 0) return; + if (this._touching) return; + this._autoHideRemainingTime -= deltaTime; + if (this._autoHideRemainingTime <= this.autoHideTime) { + this._autoHideRemainingTime = Math.max(0, this._autoHideRemainingTime); + var opacity = this._opacity * (this._autoHideRemainingTime / this.autoHideTime); + this._setOpacity(opacity); + } + }, + start: function start() { + this.enableAutoHide && this._setOpacity(0); + }, + hide: function hide() { + this._autoHideRemainingTime = 0; + this._setOpacity(0); + }, + show: function show() { + this._autoHideRemainingTime = this.autoHideTime; + this._setOpacity(this._opacity); + }, + update: function update(dt) { + this._processAutoHide(dt); + } + }); + cc.Scrollbar = module.exports = Scrollbar; + }), { + "../utils/misc": 325, + "./CCComponent": 150 + } ], + 165: [ (function(require, module, exports) { + "use strict"; + var NodeEvent = require("../CCNode").EventType; + var NUMBER_OF_GATHERED_TOUCHES_FOR_MOVE_SPEED = 5; + var OUT_OF_BOUNDARY_BREAKING_FACTOR = .05; + var EPSILON = 1e-4; + var MOVEMENT_FACTOR = .7; + var _tempPoint = cc.v2(); + var _tempPrevPoint = cc.v2(); + var quintEaseOut = function quintEaseOut(time) { + time -= 1; + return time * time * time * time * time + 1; + }; + var getTimeInMilliseconds = function getTimeInMilliseconds() { + var currentTime = new Date(); + return currentTime.getMilliseconds(); + }; + var EventType = cc.Enum({ + SCROLL_TO_TOP: 0, + SCROLL_TO_BOTTOM: 1, + SCROLL_TO_LEFT: 2, + SCROLL_TO_RIGHT: 3, + SCROLLING: 4, + BOUNCE_TOP: 5, + BOUNCE_BOTTOM: 6, + BOUNCE_LEFT: 7, + BOUNCE_RIGHT: 8, + SCROLL_ENDED: 9, + TOUCH_UP: 10, + AUTOSCROLL_ENDED_WITH_THRESHOLD: 11, + SCROLL_BEGAN: 12 + }); + var eventMap = { + "scroll-to-top": EventType.SCROLL_TO_TOP, + "scroll-to-bottom": EventType.SCROLL_TO_BOTTOM, + "scroll-to-left": EventType.SCROLL_TO_LEFT, + "scroll-to-right": EventType.SCROLL_TO_RIGHT, + scrolling: EventType.SCROLLING, + "bounce-bottom": EventType.BOUNCE_BOTTOM, + "bounce-left": EventType.BOUNCE_LEFT, + "bounce-right": EventType.BOUNCE_RIGHT, + "bounce-top": EventType.BOUNCE_TOP, + "scroll-ended": EventType.SCROLL_ENDED, + "touch-up": EventType.TOUCH_UP, + "scroll-ended-with-threshold": EventType.AUTOSCROLL_ENDED_WITH_THRESHOLD, + "scroll-began": EventType.SCROLL_BEGAN + }; + var ScrollView = cc.Class({ + name: "cc.ScrollView", + extends: require("./CCViewGroup"), + editor: false, + ctor: function ctor() { + this._topBoundary = 0; + this._bottomBoundary = 0; + this._leftBoundary = 0; + this._rightBoundary = 0; + this._touchMoveDisplacements = []; + this._touchMoveTimeDeltas = []; + this._touchMovePreviousTimestamp = 0; + this._touchMoved = false; + this._autoScrolling = false; + this._autoScrollAttenuate = false; + this._autoScrollStartPosition = cc.v2(0, 0); + this._autoScrollTargetDelta = cc.v2(0, 0); + this._autoScrollTotalTime = 0; + this._autoScrollAccumulatedTime = 0; + this._autoScrollCurrentlyOutOfBoundary = false; + this._autoScrollBraking = false; + this._autoScrollBrakingStartPosition = cc.v2(0, 0); + this._outOfBoundaryAmount = cc.v2(0, 0); + this._outOfBoundaryAmountDirty = true; + this._stopMouseWheel = false; + this._mouseWheelEventElapsedTime = 0; + this._isScrollEndedWithThresholdEventFired = false; + this._scrollEventEmitMask = 0; + this._isBouncing = false; + this._scrolling = false; + }, + properties: { + content: { + default: void 0, + type: cc.Node, + tooltip: false, + formerlySerializedAs: "content", + notify: function notify(oldValue) { + this._calculateBoundary(); + } + }, + horizontal: { + default: true, + animatable: false, + tooltip: false + }, + vertical: { + default: true, + animatable: false, + tooltip: false + }, + inertia: { + default: true, + tooltip: false + }, + brake: { + default: .5, + type: cc.Float, + range: [ 0, 1, .1 ], + tooltip: false + }, + elastic: { + default: true, + animatable: false, + tooltip: false + }, + bounceDuration: { + default: 1, + range: [ 0, 10 ], + tooltip: false + }, + horizontalScrollBar: { + default: void 0, + type: cc.Scrollbar, + tooltip: false, + notify: function notify() { + if (this.horizontalScrollBar) { + this.horizontalScrollBar.setTargetScrollView(this); + this._updateScrollBar(0); + } + }, + animatable: false + }, + verticalScrollBar: { + default: void 0, + type: cc.Scrollbar, + tooltip: false, + notify: function notify() { + if (this.verticalScrollBar) { + this.verticalScrollBar.setTargetScrollView(this); + this._updateScrollBar(0); + } + }, + animatable: false + }, + scrollEvents: { + default: [], + type: cc.Component.EventHandler, + tooltip: false + }, + cancelInnerEvents: { + default: true, + animatable: false, + tooltip: false + }, + _view: { + get: function get() { + if (this.content) return this.content.parent; + } + } + }, + statics: { + EventType: EventType + }, + scrollToBottom: function scrollToBottom(timeInSecond, attenuated) { + var moveDelta = this._calculateMovePercentDelta({ + anchor: cc.v2(0, 0), + applyToHorizontal: false, + applyToVertical: true + }); + timeInSecond ? this._startAutoScroll(moveDelta, timeInSecond, false !== attenuated) : this._moveContent(moveDelta, true); + }, + scrollToTop: function scrollToTop(timeInSecond, attenuated) { + var moveDelta = this._calculateMovePercentDelta({ + anchor: cc.v2(0, 1), + applyToHorizontal: false, + applyToVertical: true + }); + timeInSecond ? this._startAutoScroll(moveDelta, timeInSecond, false !== attenuated) : this._moveContent(moveDelta); + }, + scrollToLeft: function scrollToLeft(timeInSecond, attenuated) { + var moveDelta = this._calculateMovePercentDelta({ + anchor: cc.v2(0, 0), + applyToHorizontal: true, + applyToVertical: false + }); + timeInSecond ? this._startAutoScroll(moveDelta, timeInSecond, false !== attenuated) : this._moveContent(moveDelta); + }, + scrollToRight: function scrollToRight(timeInSecond, attenuated) { + var moveDelta = this._calculateMovePercentDelta({ + anchor: cc.v2(1, 0), + applyToHorizontal: true, + applyToVertical: false + }); + timeInSecond ? this._startAutoScroll(moveDelta, timeInSecond, false !== attenuated) : this._moveContent(moveDelta); + }, + scrollToTopLeft: function scrollToTopLeft(timeInSecond, attenuated) { + var moveDelta = this._calculateMovePercentDelta({ + anchor: cc.v2(0, 1), + applyToHorizontal: true, + applyToVertical: true + }); + timeInSecond ? this._startAutoScroll(moveDelta, timeInSecond, false !== attenuated) : this._moveContent(moveDelta); + }, + scrollToTopRight: function scrollToTopRight(timeInSecond, attenuated) { + var moveDelta = this._calculateMovePercentDelta({ + anchor: cc.v2(1, 1), + applyToHorizontal: true, + applyToVertical: true + }); + timeInSecond ? this._startAutoScroll(moveDelta, timeInSecond, false !== attenuated) : this._moveContent(moveDelta); + }, + scrollToBottomLeft: function scrollToBottomLeft(timeInSecond, attenuated) { + var moveDelta = this._calculateMovePercentDelta({ + anchor: cc.v2(0, 0), + applyToHorizontal: true, + applyToVertical: true + }); + timeInSecond ? this._startAutoScroll(moveDelta, timeInSecond, false !== attenuated) : this._moveContent(moveDelta); + }, + scrollToBottomRight: function scrollToBottomRight(timeInSecond, attenuated) { + var moveDelta = this._calculateMovePercentDelta({ + anchor: cc.v2(1, 0), + applyToHorizontal: true, + applyToVertical: true + }); + timeInSecond ? this._startAutoScroll(moveDelta, timeInSecond, false !== attenuated) : this._moveContent(moveDelta); + }, + scrollToOffset: function scrollToOffset(offset, timeInSecond, attenuated) { + var maxScrollOffset = this.getMaxScrollOffset(); + var anchor = cc.v2(0, 0); + 0 === maxScrollOffset.x ? anchor.x = 0 : anchor.x = offset.x / maxScrollOffset.x; + 0 === maxScrollOffset.y ? anchor.y = 1 : anchor.y = (maxScrollOffset.y - offset.y) / maxScrollOffset.y; + this.scrollTo(anchor, timeInSecond, attenuated); + }, + getScrollOffset: function getScrollOffset() { + var topDelta = this._getContentTopBoundary() - this._topBoundary; + var leftDeta = this._getContentLeftBoundary() - this._leftBoundary; + return cc.v2(leftDeta, topDelta); + }, + getMaxScrollOffset: function getMaxScrollOffset() { + var viewSize = this._view.getContentSize(); + var contentSize = this.content.getContentSize(); + var horizontalMaximizeOffset = contentSize.width - viewSize.width; + var verticalMaximizeOffset = contentSize.height - viewSize.height; + horizontalMaximizeOffset = horizontalMaximizeOffset >= 0 ? horizontalMaximizeOffset : 0; + verticalMaximizeOffset = verticalMaximizeOffset >= 0 ? verticalMaximizeOffset : 0; + return cc.v2(horizontalMaximizeOffset, verticalMaximizeOffset); + }, + scrollToPercentHorizontal: function scrollToPercentHorizontal(percent, timeInSecond, attenuated) { + var moveDelta = this._calculateMovePercentDelta({ + anchor: cc.v2(percent, 0), + applyToHorizontal: true, + applyToVertical: false + }); + timeInSecond ? this._startAutoScroll(moveDelta, timeInSecond, false !== attenuated) : this._moveContent(moveDelta); + }, + scrollTo: function scrollTo(anchor, timeInSecond, attenuated) { + var moveDelta = this._calculateMovePercentDelta({ + anchor: cc.v2(anchor), + applyToHorizontal: true, + applyToVertical: true + }); + timeInSecond ? this._startAutoScroll(moveDelta, timeInSecond, false !== attenuated) : this._moveContent(moveDelta); + }, + scrollToPercentVertical: function scrollToPercentVertical(percent, timeInSecond, attenuated) { + var moveDelta = this._calculateMovePercentDelta({ + anchor: cc.v2(0, percent), + applyToHorizontal: false, + applyToVertical: true + }); + timeInSecond ? this._startAutoScroll(moveDelta, timeInSecond, false !== attenuated) : this._moveContent(moveDelta); + }, + stopAutoScroll: function stopAutoScroll() { + this._autoScrolling = false; + this._autoScrollAccumulatedTime = this._autoScrollTotalTime; + }, + setContentPosition: function setContentPosition(position) { + if (position.fuzzyEquals(this.getContentPosition(), EPSILON)) return; + this.content.setPosition(position); + this._outOfBoundaryAmountDirty = true; + }, + getContentPosition: function getContentPosition() { + return this.content.getPosition(); + }, + isScrolling: function isScrolling() { + return this._scrolling; + }, + isAutoScrolling: function isAutoScrolling() { + return this._autoScrolling; + }, + _registerEvent: function _registerEvent() { + this.node.on(cc.Node.EventType.TOUCH_START, this._onTouchBegan, this, true); + this.node.on(cc.Node.EventType.TOUCH_MOVE, this._onTouchMoved, this, true); + this.node.on(cc.Node.EventType.TOUCH_END, this._onTouchEnded, this, true); + this.node.on(cc.Node.EventType.TOUCH_CANCEL, this._onTouchCancelled, this, true); + this.node.on(cc.Node.EventType.MOUSE_WHEEL, this._onMouseWheel, this, true); + }, + _unregisterEvent: function _unregisterEvent() { + this.node.off(cc.Node.EventType.TOUCH_START, this._onTouchBegan, this, true); + this.node.off(cc.Node.EventType.TOUCH_MOVE, this._onTouchMoved, this, true); + this.node.off(cc.Node.EventType.TOUCH_END, this._onTouchEnded, this, true); + this.node.off(cc.Node.EventType.TOUCH_CANCEL, this._onTouchCancelled, this, true); + this.node.off(cc.Node.EventType.MOUSE_WHEEL, this._onMouseWheel, this, true); + }, + _onMouseWheel: function _onMouseWheel(event, captureListeners) { + if (!this.enabledInHierarchy) return; + if (this.hasNestedViewGroup(event, captureListeners)) return; + var deltaMove = cc.v2(0, 0); + var wheelPrecision = -.1; + cc.sys.os === cc.sys.OS_WINDOWS && cc.sys.browserType === cc.sys.BROWSER_TYPE_FIREFOX && (wheelPrecision = -.1 / 3); + false, false; + this.vertical ? deltaMove = cc.v2(0, event.getScrollY() * wheelPrecision) : this.horizontal && (deltaMove = cc.v2(event.getScrollY() * wheelPrecision, 0)); + this._mouseWheelEventElapsedTime = 0; + this._processDeltaMove(deltaMove); + if (!this._stopMouseWheel) { + this._handlePressLogic(); + this.schedule(this._checkMouseWheel, 1 / 60); + this._stopMouseWheel = true; + } + this._stopPropagationIfTargetIsMe(event); + }, + _checkMouseWheel: function _checkMouseWheel(dt) { + var currentOutOfBoundary = this._getHowMuchOutOfBoundary(); + var maxElapsedTime = .1; + if (!currentOutOfBoundary.fuzzyEquals(cc.v2(0, 0), EPSILON)) { + this._processInertiaScroll(); + this.unschedule(this._checkMouseWheel); + this._dispatchEvent("scroll-ended"); + this._stopMouseWheel = false; + return; + } + this._mouseWheelEventElapsedTime += dt; + if (this._mouseWheelEventElapsedTime > maxElapsedTime) { + this._onScrollBarTouchEnded(); + this.unschedule(this._checkMouseWheel); + this._dispatchEvent("scroll-ended"); + this._stopMouseWheel = false; + } + }, + _calculateMovePercentDelta: function _calculateMovePercentDelta(options) { + var anchor = options.anchor; + var applyToHorizontal = options.applyToHorizontal; + var applyToVertical = options.applyToVertical; + this._calculateBoundary(); + anchor = anchor.clampf(cc.v2(0, 0), cc.v2(1, 1)); + var scrollSize = this._view.getContentSize(); + var contentSize = this.content.getContentSize(); + var bottomDeta = this._getContentBottomBoundary() - this._bottomBoundary; + bottomDeta = -bottomDeta; + var leftDeta = this._getContentLeftBoundary() - this._leftBoundary; + leftDeta = -leftDeta; + var moveDelta = cc.v2(0, 0); + var totalScrollDelta = 0; + if (applyToHorizontal) { + totalScrollDelta = contentSize.width - scrollSize.width; + moveDelta.x = leftDeta - totalScrollDelta * anchor.x; + } + if (applyToVertical) { + totalScrollDelta = contentSize.height - scrollSize.height; + moveDelta.y = bottomDeta - totalScrollDelta * anchor.y; + } + return moveDelta; + }, + _moveContentToTopLeft: function _moveContentToTopLeft(scrollViewSize) { + var contentSize = this.content.getContentSize(); + var bottomDeta = this._getContentBottomBoundary() - this._bottomBoundary; + bottomDeta = -bottomDeta; + var moveDelta = cc.v2(0, 0); + var totalScrollDelta = 0; + var leftDeta = this._getContentLeftBoundary() - this._leftBoundary; + leftDeta = -leftDeta; + if (contentSize.height < scrollViewSize.height) { + totalScrollDelta = contentSize.height - scrollViewSize.height; + moveDelta.y = bottomDeta - totalScrollDelta; + } + if (contentSize.width < scrollViewSize.width) { + totalScrollDelta = contentSize.width - scrollViewSize.width; + moveDelta.x = leftDeta; + } + this._updateScrollBarState(); + this._moveContent(moveDelta); + this._adjustContentOutOfBoundary(); + }, + _calculateBoundary: function _calculateBoundary() { + if (this.content) { + var layout = this.content.getComponent(cc.Layout); + layout && layout.enabledInHierarchy && layout.updateLayout(); + var viewSize = this._view.getContentSize(); + var anchorX = viewSize.width * this._view.anchorX; + var anchorY = viewSize.height * this._view.anchorY; + this._leftBoundary = -anchorX; + this._bottomBoundary = -anchorY; + this._rightBoundary = this._leftBoundary + viewSize.width; + this._topBoundary = this._bottomBoundary + viewSize.height; + this._moveContentToTopLeft(viewSize); + } + }, + hasNestedViewGroup: function hasNestedViewGroup(event, captureListeners) { + if (event.eventPhase !== cc.Event.CAPTURING_PHASE) return; + if (captureListeners) for (var i = 0; i < captureListeners.length; ++i) { + var item = captureListeners[i]; + if (this.node === item) { + if (event.target.getComponent(cc.ViewGroup)) return true; + return false; + } + if (item.getComponent(cc.ViewGroup)) return true; + } + return false; + }, + _stopPropagationIfTargetIsMe: function _stopPropagationIfTargetIsMe(event) { + event.eventPhase === cc.Event.AT_TARGET && event.target === this.node && event.stopPropagation(); + }, + _onTouchBegan: function _onTouchBegan(event, captureListeners) { + if (!this.enabledInHierarchy) return; + if (this.hasNestedViewGroup(event, captureListeners)) return; + var touch = event.touch; + this.content && this._handlePressLogic(touch); + this._touchMoved = false; + this._stopPropagationIfTargetIsMe(event); + }, + _onTouchMoved: function _onTouchMoved(event, captureListeners) { + if (!this.enabledInHierarchy) return; + if (this.hasNestedViewGroup(event, captureListeners)) return; + var touch = event.touch; + this.content && this._handleMoveLogic(touch); + if (!this.cancelInnerEvents) return; + var deltaMove = touch.getLocation().sub(touch.getStartLocation()); + if (deltaMove.mag() > 7 && !this._touchMoved && event.target !== this.node) { + var cancelEvent = new cc.Event.EventTouch(event.getTouches(), event.bubbles); + cancelEvent.type = cc.Node.EventType.TOUCH_CANCEL; + cancelEvent.touch = event.touch; + cancelEvent.simulate = true; + event.target.dispatchEvent(cancelEvent); + this._touchMoved = true; + } + this._stopPropagationIfTargetIsMe(event); + }, + _onTouchEnded: function _onTouchEnded(event, captureListeners) { + if (!this.enabledInHierarchy) return; + if (this.hasNestedViewGroup(event, captureListeners)) return; + this._dispatchEvent("touch-up"); + var touch = event.touch; + this.content && this._handleReleaseLogic(touch); + this._touchMoved ? event.stopPropagation() : this._stopPropagationIfTargetIsMe(event); + }, + _onTouchCancelled: function _onTouchCancelled(event, captureListeners) { + if (!this.enabledInHierarchy) return; + if (this.hasNestedViewGroup(event, captureListeners)) return; + if (!event.simulate) { + var touch = event.touch; + this.content && this._handleReleaseLogic(touch); + } + this._stopPropagationIfTargetIsMe(event); + }, + _processDeltaMove: function _processDeltaMove(deltaMove) { + this._scrollChildren(deltaMove); + this._gatherTouchMove(deltaMove); + }, + _getLocalAxisAlignDelta: function _getLocalAxisAlignDelta(touch) { + this.node.convertToNodeSpaceAR(touch.getLocation(), _tempPoint); + this.node.convertToNodeSpaceAR(touch.getPreviousLocation(), _tempPrevPoint); + return _tempPoint.sub(_tempPrevPoint); + }, + _handleMoveLogic: function _handleMoveLogic(touch) { + var deltaMove = this._getLocalAxisAlignDelta(touch); + this._processDeltaMove(deltaMove); + }, + _scrollChildren: function _scrollChildren(deltaMove) { + deltaMove = this._clampDelta(deltaMove); + var realMove = deltaMove; + var outOfBoundary; + if (this.elastic) { + outOfBoundary = this._getHowMuchOutOfBoundary(); + realMove.x *= 0 === outOfBoundary.x ? 1 : .5; + realMove.y *= 0 === outOfBoundary.y ? 1 : .5; + } + if (!this.elastic) { + outOfBoundary = this._getHowMuchOutOfBoundary(realMove); + realMove = realMove.add(outOfBoundary); + } + var vertical_scrollEventType = ""; + var horizontal_scrollEventType = ""; + if (this.vertical) if (realMove.y > 0) { + var icBottomPos = this.content.y - this.content.anchorY * this.content.height; + icBottomPos + realMove.y >= this._bottomBoundary && (vertical_scrollEventType = "scroll-to-bottom"); + } else if (realMove.y < 0) { + var icTopPos = this.content.y - this.content.anchorY * this.content.height + this.content.height; + icTopPos + realMove.y <= this._topBoundary && (vertical_scrollEventType = "scroll-to-top"); + } + if (this.horizontal) if (realMove.x < 0) { + var icRightPos = this.content.x - this.content.anchorX * this.content.width + this.content.width; + icRightPos + realMove.x <= this._rightBoundary && (horizontal_scrollEventType = "scroll-to-right"); + } else if (realMove.x > 0) { + var icLeftPos = this.content.x - this.content.anchorX * this.content.width; + icLeftPos + realMove.x >= this._leftBoundary && (horizontal_scrollEventType = "scroll-to-left"); + } + this._moveContent(realMove, false); + if (this.horizontal && 0 !== realMove.x || this.vertical && 0 !== realMove.y) { + if (!this._scrolling) { + this._scrolling = true; + this._dispatchEvent("scroll-began"); + } + this._dispatchEvent("scrolling"); + } + "" !== vertical_scrollEventType && this._dispatchEvent(vertical_scrollEventType); + "" !== horizontal_scrollEventType && this._dispatchEvent(horizontal_scrollEventType); + }, + _handlePressLogic: function _handlePressLogic() { + this._autoScrolling && this._dispatchEvent("scroll-ended"); + this._autoScrolling = false; + this._isBouncing = false; + this._touchMovePreviousTimestamp = getTimeInMilliseconds(); + this._touchMoveDisplacements.length = 0; + this._touchMoveTimeDeltas.length = 0; + this._onScrollBarTouchBegan(); + }, + _clampDelta: function _clampDelta(delta) { + var contentSize = this.content.getContentSize(); + var scrollViewSize = this._view.getContentSize(); + contentSize.width < scrollViewSize.width && (delta.x = 0); + contentSize.height < scrollViewSize.height && (delta.y = 0); + return delta; + }, + _gatherTouchMove: function _gatherTouchMove(delta) { + delta = this._clampDelta(delta); + while (this._touchMoveDisplacements.length >= NUMBER_OF_GATHERED_TOUCHES_FOR_MOVE_SPEED) { + this._touchMoveDisplacements.shift(); + this._touchMoveTimeDeltas.shift(); + } + this._touchMoveDisplacements.push(delta); + var timeStamp = getTimeInMilliseconds(); + this._touchMoveTimeDeltas.push((timeStamp - this._touchMovePreviousTimestamp) / 1e3); + this._touchMovePreviousTimestamp = timeStamp; + }, + _startBounceBackIfNeeded: function _startBounceBackIfNeeded() { + if (!this.elastic) return false; + var bounceBackAmount = this._getHowMuchOutOfBoundary(); + bounceBackAmount = this._clampDelta(bounceBackAmount); + if (bounceBackAmount.fuzzyEquals(cc.v2(0, 0), EPSILON)) return false; + var bounceBackTime = Math.max(this.bounceDuration, 0); + this._startAutoScroll(bounceBackAmount, bounceBackTime, true); + if (!this._isBouncing) { + bounceBackAmount.y > 0 && this._dispatchEvent("bounce-top"); + bounceBackAmount.y < 0 && this._dispatchEvent("bounce-bottom"); + bounceBackAmount.x > 0 && this._dispatchEvent("bounce-right"); + bounceBackAmount.x < 0 && this._dispatchEvent("bounce-left"); + this._isBouncing = true; + } + return true; + }, + _processInertiaScroll: function _processInertiaScroll() { + var bounceBackStarted = this._startBounceBackIfNeeded(); + if (!bounceBackStarted && this.inertia) { + var touchMoveVelocity = this._calculateTouchMoveVelocity(); + !touchMoveVelocity.fuzzyEquals(cc.v2(0, 0), EPSILON) && this.brake < 1 && this._startInertiaScroll(touchMoveVelocity); + } + this._onScrollBarTouchEnded(); + }, + _handleReleaseLogic: function _handleReleaseLogic(touch) { + var delta = this._getLocalAxisAlignDelta(touch); + this._gatherTouchMove(delta); + this._processInertiaScroll(); + if (this._scrolling) { + this._scrolling = false; + this._autoScrolling || this._dispatchEvent("scroll-ended"); + } + }, + _isOutOfBoundary: function _isOutOfBoundary() { + var outOfBoundary = this._getHowMuchOutOfBoundary(); + return !outOfBoundary.fuzzyEquals(cc.v2(0, 0), EPSILON); + }, + _isNecessaryAutoScrollBrake: function _isNecessaryAutoScrollBrake() { + if (this._autoScrollBraking) return true; + if (this._isOutOfBoundary()) { + if (!this._autoScrollCurrentlyOutOfBoundary) { + this._autoScrollCurrentlyOutOfBoundary = true; + this._autoScrollBraking = true; + this._autoScrollBrakingStartPosition = this.getContentPosition(); + return true; + } + } else this._autoScrollCurrentlyOutOfBoundary = false; + return false; + }, + getScrollEndedEventTiming: function getScrollEndedEventTiming() { + return EPSILON; + }, + _processAutoScrolling: function _processAutoScrolling(dt) { + var isAutoScrollBrake = this._isNecessaryAutoScrollBrake(); + var brakingFactor = isAutoScrollBrake ? OUT_OF_BOUNDARY_BREAKING_FACTOR : 1; + this._autoScrollAccumulatedTime += dt * (1 / brakingFactor); + var percentage = Math.min(1, this._autoScrollAccumulatedTime / this._autoScrollTotalTime); + this._autoScrollAttenuate && (percentage = quintEaseOut(percentage)); + var newPosition = this._autoScrollStartPosition.add(this._autoScrollTargetDelta.mul(percentage)); + var reachedEnd = Math.abs(percentage - 1) <= EPSILON; + var fireEvent = Math.abs(percentage - 1) <= this.getScrollEndedEventTiming(); + if (fireEvent && !this._isScrollEndedWithThresholdEventFired) { + this._dispatchEvent("scroll-ended-with-threshold"); + this._isScrollEndedWithThresholdEventFired = true; + } + if (this.elastic) { + var brakeOffsetPosition = newPosition.sub(this._autoScrollBrakingStartPosition); + isAutoScrollBrake && (brakeOffsetPosition = brakeOffsetPosition.mul(brakingFactor)); + newPosition = this._autoScrollBrakingStartPosition.add(brakeOffsetPosition); + } else { + var moveDelta = newPosition.sub(this.getContentPosition()); + var outOfBoundary = this._getHowMuchOutOfBoundary(moveDelta); + if (!outOfBoundary.fuzzyEquals(cc.v2(0, 0), EPSILON)) { + newPosition = newPosition.add(outOfBoundary); + reachedEnd = true; + } + } + reachedEnd && (this._autoScrolling = false); + var deltaMove = newPosition.sub(this.getContentPosition()); + this._moveContent(this._clampDelta(deltaMove), reachedEnd); + this._dispatchEvent("scrolling"); + if (!this._autoScrolling) { + this._isBouncing = false; + this._scrolling = false; + this._dispatchEvent("scroll-ended"); + } + }, + _startInertiaScroll: function _startInertiaScroll(touchMoveVelocity) { + var inertiaTotalMovement = touchMoveVelocity.mul(MOVEMENT_FACTOR); + this._startAttenuatingAutoScroll(inertiaTotalMovement, touchMoveVelocity); + }, + _calculateAttenuatedFactor: function _calculateAttenuatedFactor(distance) { + if (this.brake <= 0) return 1 - this.brake; + return (1 - this.brake) * (1 / (1 + 14e-6 * distance + distance * distance * 8e-9)); + }, + _startAttenuatingAutoScroll: function _startAttenuatingAutoScroll(deltaMove, initialVelocity) { + var time = this._calculateAutoScrollTimeByInitalSpeed(initialVelocity.mag()); + var targetDelta = deltaMove.normalize(); + var contentSize = this.content.getContentSize(); + var scrollviewSize = this._view.getContentSize(); + var totalMoveWidth = contentSize.width - scrollviewSize.width; + var totalMoveHeight = contentSize.height - scrollviewSize.height; + var attenuatedFactorX = this._calculateAttenuatedFactor(totalMoveWidth); + var attenuatedFactorY = this._calculateAttenuatedFactor(totalMoveHeight); + targetDelta = cc.v2(targetDelta.x * totalMoveWidth * (1 - this.brake) * attenuatedFactorX, targetDelta.y * totalMoveHeight * attenuatedFactorY * (1 - this.brake)); + var originalMoveLength = deltaMove.mag(); + var factor = targetDelta.mag() / originalMoveLength; + targetDelta = targetDelta.add(deltaMove); + if (this.brake > 0 && factor > 7) { + factor = Math.sqrt(factor); + targetDelta = deltaMove.mul(factor).add(deltaMove); + } + if (this.brake > 0 && factor > 3) { + factor = 3; + time *= factor; + } + 0 === this.brake && factor > 1 && (time *= factor); + this._startAutoScroll(targetDelta, time, true); + }, + _calculateAutoScrollTimeByInitalSpeed: function _calculateAutoScrollTimeByInitalSpeed(initalSpeed) { + return Math.sqrt(Math.sqrt(initalSpeed / 5)); + }, + _startAutoScroll: function _startAutoScroll(deltaMove, timeInSecond, attenuated) { + var adjustedDeltaMove = this._flattenVectorByDirection(deltaMove); + this._autoScrolling = true; + this._autoScrollTargetDelta = adjustedDeltaMove; + this._autoScrollAttenuate = attenuated; + this._autoScrollStartPosition = this.getContentPosition(); + this._autoScrollTotalTime = timeInSecond; + this._autoScrollAccumulatedTime = 0; + this._autoScrollBraking = false; + this._isScrollEndedWithThresholdEventFired = false; + this._autoScrollBrakingStartPosition = cc.v2(0, 0); + var currentOutOfBoundary = this._getHowMuchOutOfBoundary(); + currentOutOfBoundary.fuzzyEquals(cc.v2(0, 0), EPSILON) || (this._autoScrollCurrentlyOutOfBoundary = true); + }, + _calculateTouchMoveVelocity: function _calculateTouchMoveVelocity() { + var totalTime = 0; + totalTime = this._touchMoveTimeDeltas.reduce((function(a, b) { + return a + b; + }), totalTime); + if (totalTime <= 0 || totalTime >= .5) return cc.v2(0, 0); + var totalMovement = cc.v2(0, 0); + totalMovement = this._touchMoveDisplacements.reduce((function(a, b) { + return a.add(b); + }), totalMovement); + return cc.v2(totalMovement.x * (1 - this.brake) / totalTime, totalMovement.y * (1 - this.brake) / totalTime); + }, + _flattenVectorByDirection: function _flattenVectorByDirection(vector) { + var result = vector; + result.x = this.horizontal ? result.x : 0; + result.y = this.vertical ? result.y : 0; + return result; + }, + _moveContent: function _moveContent(deltaMove, canStartBounceBack) { + var adjustedMove = this._flattenVectorByDirection(deltaMove); + var newPosition = this.getContentPosition().add(adjustedMove); + this.setContentPosition(newPosition); + var outOfBoundary = this._getHowMuchOutOfBoundary(); + this._updateScrollBar(outOfBoundary); + this.elastic && canStartBounceBack && this._startBounceBackIfNeeded(); + }, + _getContentLeftBoundary: function _getContentLeftBoundary() { + var contentPos = this.getContentPosition(); + return contentPos.x - this.content.getAnchorPoint().x * this.content.getContentSize().width; + }, + _getContentRightBoundary: function _getContentRightBoundary() { + var contentSize = this.content.getContentSize(); + return this._getContentLeftBoundary() + contentSize.width; + }, + _getContentTopBoundary: function _getContentTopBoundary() { + var contentSize = this.content.getContentSize(); + return this._getContentBottomBoundary() + contentSize.height; + }, + _getContentBottomBoundary: function _getContentBottomBoundary() { + var contentPos = this.getContentPosition(); + return contentPos.y - this.content.getAnchorPoint().y * this.content.getContentSize().height; + }, + _getHowMuchOutOfBoundary: function _getHowMuchOutOfBoundary(addition) { + addition = addition || cc.v2(0, 0); + if (addition.fuzzyEquals(cc.v2(0, 0), EPSILON) && !this._outOfBoundaryAmountDirty) return this._outOfBoundaryAmount; + var outOfBoundaryAmount = cc.v2(0, 0); + this._getContentLeftBoundary() + addition.x > this._leftBoundary ? outOfBoundaryAmount.x = this._leftBoundary - (this._getContentLeftBoundary() + addition.x) : this._getContentRightBoundary() + addition.x < this._rightBoundary && (outOfBoundaryAmount.x = this._rightBoundary - (this._getContentRightBoundary() + addition.x)); + this._getContentTopBoundary() + addition.y < this._topBoundary ? outOfBoundaryAmount.y = this._topBoundary - (this._getContentTopBoundary() + addition.y) : this._getContentBottomBoundary() + addition.y > this._bottomBoundary && (outOfBoundaryAmount.y = this._bottomBoundary - (this._getContentBottomBoundary() + addition.y)); + if (addition.fuzzyEquals(cc.v2(0, 0), EPSILON)) { + this._outOfBoundaryAmount = outOfBoundaryAmount; + this._outOfBoundaryAmountDirty = false; + } + outOfBoundaryAmount = this._clampDelta(outOfBoundaryAmount); + return outOfBoundaryAmount; + }, + _updateScrollBarState: function _updateScrollBarState() { + if (!this.content) return; + var contentSize = this.content.getContentSize(); + var scrollViewSize = this._view.getContentSize(); + this.verticalScrollBar && (contentSize.height < scrollViewSize.height ? this.verticalScrollBar.hide() : this.verticalScrollBar.show()); + this.horizontalScrollBar && (contentSize.width < scrollViewSize.width ? this.horizontalScrollBar.hide() : this.horizontalScrollBar.show()); + }, + _updateScrollBar: function _updateScrollBar(outOfBoundary) { + this.horizontalScrollBar && this.horizontalScrollBar._onScroll(outOfBoundary); + this.verticalScrollBar && this.verticalScrollBar._onScroll(outOfBoundary); + }, + _onScrollBarTouchBegan: function _onScrollBarTouchBegan() { + this.horizontalScrollBar && this.horizontalScrollBar._onTouchBegan(); + this.verticalScrollBar && this.verticalScrollBar._onTouchBegan(); + }, + _onScrollBarTouchEnded: function _onScrollBarTouchEnded() { + this.horizontalScrollBar && this.horizontalScrollBar._onTouchEnded(); + this.verticalScrollBar && this.verticalScrollBar._onTouchEnded(); + }, + _dispatchEvent: function _dispatchEvent(event) { + if ("scroll-ended" === event) this._scrollEventEmitMask = 0; else if ("scroll-to-top" === event || "scroll-to-bottom" === event || "scroll-to-left" === event || "scroll-to-right" === event) { + var flag = 1 << eventMap[event]; + if (this._scrollEventEmitMask & flag) return; + this._scrollEventEmitMask |= flag; + } + cc.Component.EventHandler.emitEvents(this.scrollEvents, this, eventMap[event]); + this.node.emit(event, this); + }, + _adjustContentOutOfBoundary: function _adjustContentOutOfBoundary() { + this._outOfBoundaryAmountDirty = true; + if (this._isOutOfBoundary()) { + var outOfBoundary = this._getHowMuchOutOfBoundary(cc.v2(0, 0)); + var newPosition = this.getContentPosition().add(outOfBoundary); + if (this.content) { + this.content.setPosition(newPosition); + this._updateScrollBar(0); + } + } + }, + start: function start() { + this._calculateBoundary(); + this.content && cc.director.once(cc.Director.EVENT_BEFORE_DRAW, this._adjustContentOutOfBoundary, this); + }, + _hideScrollbar: function _hideScrollbar() { + this.horizontalScrollBar && this.horizontalScrollBar.hide(); + this.verticalScrollBar && this.verticalScrollBar.hide(); + }, + onDisable: function onDisable() { + true; + this._unregisterEvent(); + if (this.content) { + this.content.off(NodeEvent.SIZE_CHANGED, this._calculateBoundary, this); + this.content.off(NodeEvent.SCALE_CHANGED, this._calculateBoundary, this); + if (this._view) { + this._view.off(NodeEvent.POSITION_CHANGED, this._calculateBoundary, this); + this._view.off(NodeEvent.SCALE_CHANGED, this._calculateBoundary, this); + this._view.off(NodeEvent.SIZE_CHANGED, this._calculateBoundary, this); + } + } + this._hideScrollbar(); + this.stopAutoScroll(); + }, + onEnable: function onEnable() { + true; + this._registerEvent(); + if (this.content) { + this.content.on(NodeEvent.SIZE_CHANGED, this._calculateBoundary, this); + this.content.on(NodeEvent.SCALE_CHANGED, this._calculateBoundary, this); + if (this._view) { + this._view.on(NodeEvent.POSITION_CHANGED, this._calculateBoundary, this); + this._view.on(NodeEvent.SCALE_CHANGED, this._calculateBoundary, this); + this._view.on(NodeEvent.SIZE_CHANGED, this._calculateBoundary, this); + } + } + this._updateScrollBarState(); + }, + update: function update(dt) { + this._autoScrolling && this._processAutoScrolling(dt); + } + }); + cc.ScrollView = module.exports = ScrollView; + }), { + "../CCNode": 73, + "./CCViewGroup": 172 + } ], + 166: [ (function(require, module, exports) { + "use strict"; + var misc = require("../utils/misc"); + var Component = require("./CCComponent"); + var Direction = cc.Enum({ + Horizontal: 0, + Vertical: 1 + }); + var Slider = cc.Class({ + name: "cc.Slider", + extends: Component, + editor: false, + ctor: function ctor() { + this._offset = cc.v2(); + this._touchHandle = false; + this._dragging = false; + }, + properties: { + handle: { + default: null, + type: cc.Button, + tooltip: false, + notify: function notify() { + false; + } + }, + direction: { + default: Direction.Horizontal, + type: Direction, + tooltip: false + }, + progress: { + default: .5, + type: cc.Float, + range: [ 0, 1, .1 ], + slide: true, + tooltip: false, + notify: function notify() { + this._updateHandlePosition(); + } + }, + slideEvents: { + default: [], + type: cc.Component.EventHandler, + tooltip: false + } + }, + statics: { + Direction: Direction + }, + __preload: function __preload() { + this._updateHandlePosition(); + }, + onEnable: function onEnable() { + this.node.on(cc.Node.EventType.TOUCH_START, this._onTouchBegan, this); + this.node.on(cc.Node.EventType.TOUCH_MOVE, this._onTouchMoved, this); + this.node.on(cc.Node.EventType.TOUCH_END, this._onTouchEnded, this); + this.node.on(cc.Node.EventType.TOUCH_CANCEL, this._onTouchCancelled, this); + if (this.handle && this.handle.isValid) { + this.handle.node.on(cc.Node.EventType.TOUCH_START, this._onHandleDragStart, this); + this.handle.node.on(cc.Node.EventType.TOUCH_MOVE, this._onTouchMoved, this); + this.handle.node.on(cc.Node.EventType.TOUCH_END, this._onTouchEnded, this); + } + }, + onDisable: function onDisable() { + this.node.off(cc.Node.EventType.TOUCH_START, this._onTouchBegan, this); + this.node.off(cc.Node.EventType.TOUCH_MOVE, this._onTouchMoved, this); + this.node.off(cc.Node.EventType.TOUCH_END, this._onTouchEnded, this); + this.node.off(cc.Node.EventType.TOUCH_CANCEL, this._onTouchCancelled, this); + if (this.handle && this.handle.isValid) { + this.handle.node.off(cc.Node.EventType.TOUCH_START, this._onHandleDragStart, this); + this.handle.node.off(cc.Node.EventType.TOUCH_MOVE, this._onTouchMoved, this); + this.handle.node.off(cc.Node.EventType.TOUCH_END, this._onTouchEnded, this); + } + }, + _onHandleDragStart: function _onHandleDragStart(event) { + this._dragging = true; + this._touchHandle = true; + this._offset = this.handle.node.convertToNodeSpaceAR(event.touch.getLocation()); + event.stopPropagation(); + }, + _onTouchBegan: function _onTouchBegan(event) { + if (!this.handle) return; + this._dragging = true; + this._touchHandle || this._handleSliderLogic(event.touch); + event.stopPropagation(); + }, + _onTouchMoved: function _onTouchMoved(event) { + if (!this._dragging) return; + this._handleSliderLogic(event.touch); + event.stopPropagation(); + }, + _onTouchEnded: function _onTouchEnded(event) { + this._dragging = false; + this._touchHandle = false; + this._offset = cc.v2(); + event.stopPropagation(); + }, + _onTouchCancelled: function _onTouchCancelled(event) { + this._dragging = false; + event.stopPropagation(); + }, + _handleSliderLogic: function _handleSliderLogic(touch) { + this._updateProgress(touch); + this._emitSlideEvent(); + }, + _emitSlideEvent: function _emitSlideEvent() { + cc.Component.EventHandler.emitEvents(this.slideEvents, this); + this.node.emit("slide", this); + }, + _updateProgress: function _updateProgress(touch) { + if (!this.handle) return; + var node = this.node; + var localTouchPos = node.convertToNodeSpaceAR(touch.getLocation()); + this.direction === Direction.Horizontal ? this.progress = misc.clamp01((localTouchPos.x - this._offset.x + node.anchorX * node.width) / node.width) : this.progress = misc.clamp01((localTouchPos.y - this._offset.y + node.anchorY * node.height) / node.height); + }, + _updateHandlePosition: function _updateHandlePosition() { + if (!this.handle) return; + var handlelocalPos; + handlelocalPos = this.direction === Direction.Horizontal ? cc.v2(-this.node.width * this.node.anchorX + this.progress * this.node.width, 0) : cc.v2(0, -this.node.height * this.node.anchorY + this.progress * this.node.height); + var worldSpacePos = this.node.convertToWorldSpaceAR(handlelocalPos); + this.handle.node.position = this.handle.node.parent.convertToNodeSpaceAR(worldSpacePos); + } + }); + cc.Slider = module.exports = Slider; + }), { + "../utils/misc": 325, + "./CCComponent": 150 + } ], + 167: [ (function(require, module, exports) { + "use strict"; + var misc = require("../utils/misc"); + var NodeEvent = require("../CCNode").EventType; + var RenderComponent = require("./CCRenderComponent"); + var BlendFunc = require("../utils/blend-func"); + var SpriteType = cc.Enum({ + SIMPLE: 0, + SLICED: 1, + TILED: 2, + FILLED: 3, + MESH: 4 + }); + var FillType = cc.Enum({ + HORIZONTAL: 0, + VERTICAL: 1, + RADIAL: 2 + }); + var SizeMode = cc.Enum({ + CUSTOM: 0, + TRIMMED: 1, + RAW: 2 + }); + var State = cc.Enum({ + NORMAL: 0, + GRAY: 1 + }); + var Sprite = cc.Class({ + name: "cc.Sprite", + extends: RenderComponent, + mixins: [ BlendFunc ], + editor: false, + properties: { + _spriteFrame: { + default: null, + type: cc.SpriteFrame + }, + _type: SpriteType.SIMPLE, + _sizeMode: SizeMode.TRIMMED, + _fillType: 0, + _fillCenter: cc.v2(0, 0), + _fillStart: 0, + _fillRange: 0, + _isTrimmedMode: true, + _atlas: { + default: null, + type: cc.SpriteAtlas, + tooltip: false, + editorOnly: true, + visible: true, + animatable: false + }, + spriteFrame: { + get: function get() { + return this._spriteFrame; + }, + set: function set(value, force) { + var lastSprite = this._spriteFrame; + false; + if (lastSprite === value) return; + this._spriteFrame = value; + this._applySpriteFrame(lastSprite); + false; + }, + type: cc.SpriteFrame + }, + type: { + get: function get() { + return this._type; + }, + set: function set(value) { + if (this._type !== value) { + this._type = value; + this.setVertsDirty(); + this._resetAssembler(); + } + }, + type: SpriteType, + animatable: false, + tooltip: false + }, + fillType: { + get: function get() { + return this._fillType; + }, + set: function set(value) { + if (value !== this._fillType) { + this._fillType = value; + this.setVertsDirty(); + this._resetAssembler(); + } + }, + type: FillType, + tooltip: false + }, + fillCenter: { + get: function get() { + return this._fillCenter; + }, + set: function set(value) { + this._fillCenter.x = value.x; + this._fillCenter.y = value.y; + this._type === SpriteType.FILLED && this.setVertsDirty(); + }, + tooltip: false + }, + fillStart: { + get: function get() { + return this._fillStart; + }, + set: function set(value) { + this._fillStart = misc.clampf(value, -1, 1); + this._type === SpriteType.FILLED && this.setVertsDirty(); + }, + tooltip: false + }, + fillRange: { + get: function get() { + return this._fillRange; + }, + set: function set(value) { + this._fillRange = misc.clampf(value, -1, 1); + this._type === SpriteType.FILLED && this.setVertsDirty(); + }, + tooltip: false + }, + trim: { + get: function get() { + return this._isTrimmedMode; + }, + set: function set(value) { + if (this._isTrimmedMode !== value) { + this._isTrimmedMode = value; + this._type !== SpriteType.SIMPLE && this._type !== SpriteType.MESH || this.setVertsDirty(); + false; + } + }, + animatable: false, + tooltip: false + }, + sizeMode: { + get: function get() { + return this._sizeMode; + }, + set: function set(value) { + this._sizeMode = value; + value !== SizeMode.CUSTOM && this._applySpriteSize(); + }, + animatable: false, + type: SizeMode, + tooltip: false + } + }, + statics: { + FillType: FillType, + Type: SpriteType, + SizeMode: SizeMode, + State: State + }, + setVisible: function setVisible(visible) { + this.enabled = visible; + }, + setState: function setState() {}, + getState: function getState() {}, + __preload: function __preload() { + this._super(); + false; + this._applySpriteFrame(); + }, + onEnable: function onEnable() { + this._super(); + this._spriteFrame && this._spriteFrame.isValid && this._spriteFrame.ensureLoadTexture(); + this.node.on(cc.Node.EventType.SIZE_CHANGED, this.setVertsDirty, this); + this.node.on(cc.Node.EventType.ANCHOR_CHANGED, this.setVertsDirty, this); + }, + onDisable: function onDisable() { + this._super(); + this.node.off(cc.Node.EventType.SIZE_CHANGED, this.setVertsDirty, this); + this.node.off(cc.Node.EventType.ANCHOR_CHANGED, this.setVertsDirty, this); + }, + onRestore: false, + _updateMaterial: function _updateMaterial() { + var texture = null; + this._spriteFrame && (texture = this._spriteFrame.getTexture()); + var material = this.getMaterial(0); + if (material) { + var oldDefine = material.getDefine("USE_TEXTURE"); + void 0 === oldDefine || oldDefine || material.define("USE_TEXTURE", true); + var textureImpl = texture && texture.getImpl(); + material.getProperty("texture") !== textureImpl && material.setProperty("texture", texture); + } + BlendFunc.prototype._updateMaterial.call(this); + }, + _applyAtlas: false, + _validateRender: function _validateRender() { + var spriteFrame = this._spriteFrame; + if (this._materials[0] && spriteFrame && spriteFrame.textureLoaded()) return; + this.disableRender(); + }, + _applySpriteSize: function _applySpriteSize() { + if (!this.isValid || !this._spriteFrame || !this._spriteFrame.isValid) return; + if (SizeMode.RAW === this._sizeMode) { + var size = this._spriteFrame._originalSize; + this.node.setContentSize(size); + } else if (SizeMode.TRIMMED === this._sizeMode) { + var rect = this._spriteFrame._rect; + this.node.setContentSize(rect.width, rect.height); + } + this.setVertsDirty(); + }, + _applySpriteFrame: function _applySpriteFrame(oldFrame) { + if (!this.isValid) return; + var oldTexture = oldFrame && oldFrame.isValid && oldFrame.getTexture(); + oldTexture && !oldTexture.loaded && oldFrame.off("load", this._applySpriteSize, this); + var spriteFrame = this._spriteFrame; + var frameValid = spriteFrame && spriteFrame.isValid; + var newTexture = frameValid && spriteFrame.getTexture(); + oldTexture !== newTexture && this._updateMaterial(); + if (newTexture && newTexture.loaded) this._applySpriteSize(); else { + this.disableRender(); + frameValid && spriteFrame.once("load", this._applySpriteSize, this); + } + false; + } + }); + false; + cc.Sprite = module.exports = Sprite; + }), { + "../CCNode": 73, + "../utils/blend-func": 319, + "../utils/misc": 325, + "./CCRenderComponent": 161 + } ], + 168: [ (function(require, module, exports) { + "use strict"; + var ComponentType = cc.Enum({ + NONE: 0, + CHECKBOX: 1, + TEXT_ATLAS: 2, + SLIDER_BAR: 3, + LIST_VIEW: 4, + PAGE_VIEW: 5 + }); + var ListDirection = cc.Enum({ + VERTICAL: 0, + HORIZONTAL: 1 + }); + var VerticalAlign = cc.Enum({ + TOP: 0, + CENTER: 1, + BOTTOM: 2 + }); + var HorizontalAlign = cc.Enum({ + LEFT: 0, + CENTER: 1, + RIGHT: 2 + }); + var StudioComponent = cc.Class({ + name: "cc.StudioComponent", + extends: cc.Component, + editor: false, + properties: false, + statics: { + ComponentType: ComponentType, + ListDirection: ListDirection, + VerticalAlign: VerticalAlign, + HorizontalAlign: HorizontalAlign + } + }); + cc.StudioComponent = module.exports = StudioComponent; + var StudioWidget = cc.Class({ + name: "cc.StudioWidget", + extends: cc.Widget, + editor: false, + _validateTargetInDEV: function _validateTargetInDEV() {} + }); + cc.StudioWidget = module.exports = StudioWidget; + }), {} ], + 169: [ (function(require, module, exports) { + "use strict"; + var GraySpriteState = require("../utils/gray-sprite-state"); + var Toggle = cc.Class({ + name: "cc.Toggle", + extends: require("./CCButton"), + mixins: [ GraySpriteState ], + editor: false, + properties: { + _N$isChecked: true, + isChecked: { + get: function get() { + return this._N$isChecked; + }, + set: function set(value) { + if (value === this._N$isChecked) return; + var group = this.toggleGroup || this._toggleContainer; + if (group && group.enabled && this._N$isChecked && !group.allowSwitchOff) return; + this._N$isChecked = value; + this._updateCheckMark(); + group && group.enabled && group.updateToggles(this); + cc.Toggle._triggerEventInScript_isChecked && this._emitToggleEvents(); + }, + tooltip: false + }, + toggleGroup: { + default: null, + tooltip: false, + type: require("./CCToggleGroup") + }, + checkMark: { + default: null, + type: cc.Sprite, + tooltip: false + }, + checkEvents: { + default: [], + type: cc.Component.EventHandler + }, + _resizeToTarget: { + animatable: false, + set: function set(value) { + value && this._resizeNodeToTargetNode(); + } + } + }, + statics: { + _triggerEventInScript_check: false, + _triggerEventInScript_isChecked: false + }, + onEnable: function onEnable() { + this._super(); + true; + this._registerToggleEvent(); + this.toggleGroup && this.toggleGroup.enabledInHierarchy && this.toggleGroup.addToggle(this); + }, + onDisable: function onDisable() { + this._super(); + true; + this._unregisterToggleEvent(); + this.toggleGroup && this.toggleGroup.enabledInHierarchy && this.toggleGroup.removeToggle(this); + }, + _hideCheckMark: function _hideCheckMark() { + this._N$isChecked = false; + this._updateCheckMark(); + }, + toggle: function toggle(event) { + this.isChecked = !this.isChecked; + cc.Toggle._triggerEventInScript_isChecked || !cc.Toggle._triggerEventInScript_check && !event || this._emitToggleEvents(); + }, + check: function check() { + this.isChecked = true; + !cc.Toggle._triggerEventInScript_isChecked && cc.Toggle._triggerEventInScript_check && this._emitToggleEvents(); + }, + uncheck: function uncheck() { + this.isChecked = false; + !cc.Toggle._triggerEventInScript_isChecked && cc.Toggle._triggerEventInScript_check && this._emitToggleEvents(); + }, + _updateCheckMark: function _updateCheckMark() { + this.checkMark && (this.checkMark.node.active = !!this.isChecked); + }, + _updateDisabledState: function _updateDisabledState() { + this._super(); + if (this.enableAutoGrayEffect && this.checkMark) { + var useGrayMaterial = !this.interactable; + this._switchGrayMaterial(useGrayMaterial, this.checkMark); + } + }, + _registerToggleEvent: function _registerToggleEvent() { + this.node.on("click", this.toggle, this); + }, + _unregisterToggleEvent: function _unregisterToggleEvent() { + this.node.off("click", this.toggle, this); + }, + _emitToggleEvents: function _emitToggleEvents() { + this.node.emit("toggle", this); + this.checkEvents && cc.Component.EventHandler.emitEvents(this.checkEvents, this); + } + }); + cc.Toggle = module.exports = Toggle; + var js = require("../platform/js"); + js.get(Toggle.prototype, "_toggleContainer", (function() { + var parent = this.node.parent; + if (cc.Node.isNode(parent)) return parent.getComponent(cc.ToggleContainer); + return null; + })); + }), { + "../platform/js": 261, + "../utils/gray-sprite-state": 322, + "./CCButton": 148, + "./CCToggleGroup": 171 + } ], + 170: [ (function(require, module, exports) { + "use strict"; + var ToggleContainer = cc.Class({ + name: "cc.ToggleContainer", + extends: cc.Component, + editor: false, + properties: { + allowSwitchOff: { + tooltip: false, + default: false + }, + checkEvents: { + default: [], + type: cc.Component.EventHandler + } + }, + updateToggles: function updateToggles(toggle) { + if (!this.enabledInHierarchy) return; + if (toggle.isChecked) { + this.toggleItems.forEach((function(item) { + item !== toggle && item.isChecked && item.enabled && item._hideCheckMark(); + })); + this.checkEvents && cc.Component.EventHandler.emitEvents(this.checkEvents, toggle); + } + }, + _allowOnlyOneToggleChecked: function _allowOnlyOneToggleChecked() { + var isChecked = false; + this.toggleItems.forEach((function(item) { + isChecked ? item._hideCheckMark() : item.isChecked && (isChecked = true); + })); + return isChecked; + }, + _makeAtLeastOneToggleChecked: function _makeAtLeastOneToggleChecked() { + var isChecked = this._allowOnlyOneToggleChecked(); + if (!isChecked && !this.allowSwitchOff) { + var toggleItems = this.toggleItems; + toggleItems.length > 0 && toggleItems[0].check(); + } + }, + onEnable: function onEnable() { + this._makeAtLeastOneToggleChecked(); + this.node.on("child-added", this._allowOnlyOneToggleChecked, this); + this.node.on("child-removed", this._makeAtLeastOneToggleChecked, this); + }, + onDisable: function onDisable() { + this.node.off("child-added", this._allowOnlyOneToggleChecked, this); + this.node.off("child-removed", this._makeAtLeastOneToggleChecked, this); + } + }); + var js = require("../platform/js"); + js.get(ToggleContainer.prototype, "toggleItems", (function() { + return this.node._children.map((function(item) { + return item.getComponent(cc.Toggle); + })).filter(Boolean); + })); + cc.ToggleContainer = module.exports = ToggleContainer; + }), { + "../platform/js": 261 + } ], + 171: [ (function(require, module, exports) { + "use strict"; + var ToggleGroup = cc.Class({ + name: "cc.ToggleGroup", + extends: cc.Component, + ctor: function ctor() { + this._toggleItems = []; + }, + editor: false, + properties: { + allowSwitchOff: { + tooltip: false, + default: false + }, + toggleItems: { + get: function get() { + return this._toggleItems; + } + } + }, + updateToggles: function updateToggles(toggle) { + if (!this.enabledInHierarchy) return; + this._toggleItems.forEach((function(item) { + toggle.isChecked && item !== toggle && item.isChecked && item.enabled && item._hideCheckMark(); + })); + }, + addToggle: function addToggle(toggle) { + var index = this._toggleItems.indexOf(toggle); + -1 === index && this._toggleItems.push(toggle); + this._allowOnlyOneToggleChecked(); + }, + removeToggle: function removeToggle(toggle) { + var index = this._toggleItems.indexOf(toggle); + index > -1 && this._toggleItems.splice(index, 1); + this._makeAtLeastOneToggleChecked(); + }, + _allowOnlyOneToggleChecked: function _allowOnlyOneToggleChecked() { + var isChecked = false; + this._toggleItems.forEach((function(item) { + isChecked && item.enabled && item._hideCheckMark(); + item.isChecked && item.enabled && (isChecked = true); + })); + return isChecked; + }, + _makeAtLeastOneToggleChecked: function _makeAtLeastOneToggleChecked() { + var isChecked = this._allowOnlyOneToggleChecked(); + isChecked || this.allowSwitchOff || this._toggleItems.length > 0 && (this._toggleItems[0].isChecked = true); + }, + start: function start() { + this._makeAtLeastOneToggleChecked(); + } + }); + var js = require("../platform/js"); + var showed = false; + js.get(cc, "ToggleGroup", (function() { + if (!showed) { + cc.errorID(1405, "cc.ToggleGroup", "cc.ToggleContainer"); + showed = true; + } + return ToggleGroup; + })); + module.exports = ToggleGroup; + }), { + "../platform/js": 261 + } ], + 172: [ (function(require, module, exports) { + "use strict"; + var ViewGroup = cc.Class({ + name: "cc.ViewGroup", + extends: require("./CCComponent") + }); + cc.ViewGroup = module.exports = ViewGroup; + }), { + "./CCComponent": 150 + } ], + 173: [ (function(require, module, exports) { + "use strict"; + var WidgetManager = require("../base-ui/CCWidgetManager"); + var AlignMode = WidgetManager.AlignMode; + var AlignFlags = WidgetManager._AlignFlags; + var TOP = AlignFlags.TOP; + var MID = AlignFlags.MID; + var BOT = AlignFlags.BOT; + var LEFT = AlignFlags.LEFT; + var CENTER = AlignFlags.CENTER; + var RIGHT = AlignFlags.RIGHT; + var TOP_BOT = TOP | BOT; + var LEFT_RIGHT = LEFT | RIGHT; + var Widget = cc.Class({ + name: "cc.Widget", + extends: require("./CCComponent"), + editor: false, + properties: { + target: { + get: function get() { + return this._target; + }, + set: function set(value) { + this._target = value; + false; + }, + type: cc.Node, + tooltip: false + }, + isAlignTop: { + get: function get() { + return (this._alignFlags & TOP) > 0; + }, + set: function set(value) { + this._setAlign(TOP, value); + }, + animatable: false, + tooltip: false + }, + isAlignVerticalCenter: { + get: function get() { + return (this._alignFlags & MID) > 0; + }, + set: function set(value) { + if (value) { + this.isAlignTop = false; + this.isAlignBottom = false; + this._alignFlags |= MID; + } else this._alignFlags &= ~MID; + }, + animatable: false, + tooltip: false + }, + isAlignBottom: { + get: function get() { + return (this._alignFlags & BOT) > 0; + }, + set: function set(value) { + this._setAlign(BOT, value); + }, + animatable: false, + tooltip: false + }, + isAlignLeft: { + get: function get() { + return (this._alignFlags & LEFT) > 0; + }, + set: function set(value) { + this._setAlign(LEFT, value); + }, + animatable: false, + tooltip: false + }, + isAlignHorizontalCenter: { + get: function get() { + return (this._alignFlags & CENTER) > 0; + }, + set: function set(value) { + if (value) { + this.isAlignLeft = false; + this.isAlignRight = false; + this._alignFlags |= CENTER; + } else this._alignFlags &= ~CENTER; + }, + animatable: false, + tooltip: false + }, + isAlignRight: { + get: function get() { + return (this._alignFlags & RIGHT) > 0; + }, + set: function set(value) { + this._setAlign(RIGHT, value); + }, + animatable: false, + tooltip: false + }, + isStretchWidth: { + get: function get() { + return (this._alignFlags & LEFT_RIGHT) === LEFT_RIGHT; + }, + visible: false + }, + isStretchHeight: { + get: function get() { + return (this._alignFlags & TOP_BOT) === TOP_BOT; + }, + visible: false + }, + top: { + get: function get() { + return this._top; + }, + set: function set(value) { + this._top = value; + }, + tooltip: false + }, + bottom: { + get: function get() { + return this._bottom; + }, + set: function set(value) { + this._bottom = value; + }, + tooltip: false + }, + left: { + get: function get() { + return this._left; + }, + set: function set(value) { + this._left = value; + }, + tooltip: false + }, + right: { + get: function get() { + return this._right; + }, + set: function set(value) { + this._right = value; + }, + tooltip: false + }, + horizontalCenter: { + get: function get() { + return this._horizontalCenter; + }, + set: function set(value) { + this._horizontalCenter = value; + }, + tooltip: false + }, + verticalCenter: { + get: function get() { + return this._verticalCenter; + }, + set: function set(value) { + this._verticalCenter = value; + }, + tooltip: false + }, + isAbsoluteHorizontalCenter: { + get: function get() { + return this._isAbsHorizontalCenter; + }, + set: function set(value) { + this._isAbsHorizontalCenter = value; + }, + animatable: false + }, + isAbsoluteVerticalCenter: { + get: function get() { + return this._isAbsVerticalCenter; + }, + set: function set(value) { + this._isAbsVerticalCenter = value; + }, + animatable: false + }, + isAbsoluteTop: { + get: function get() { + return this._isAbsTop; + }, + set: function set(value) { + this._isAbsTop = value; + }, + animatable: false + }, + isAbsoluteBottom: { + get: function get() { + return this._isAbsBottom; + }, + set: function set(value) { + this._isAbsBottom = value; + }, + animatable: false + }, + isAbsoluteLeft: { + get: function get() { + return this._isAbsLeft; + }, + set: function set(value) { + this._isAbsLeft = value; + }, + animatable: false + }, + isAbsoluteRight: { + get: function get() { + return this._isAbsRight; + }, + set: function set(value) { + this._isAbsRight = value; + }, + animatable: false + }, + alignMode: { + default: AlignMode.ON_WINDOW_RESIZE, + type: AlignMode, + tooltip: false + }, + _wasAlignOnce: { + default: void 0, + formerlySerializedAs: "isAlignOnce" + }, + _target: null, + _alignFlags: 0, + _left: 0, + _right: 0, + _top: 0, + _bottom: 0, + _verticalCenter: 0, + _horizontalCenter: 0, + _isAbsLeft: true, + _isAbsRight: true, + _isAbsTop: true, + _isAbsBottom: true, + _isAbsHorizontalCenter: true, + _isAbsVerticalCenter: true, + _originalWidth: 0, + _originalHeight: 0 + }, + statics: { + AlignMode: AlignMode + }, + onLoad: function onLoad() { + if (void 0 !== this._wasAlignOnce) { + this.alignMode = this._wasAlignOnce ? AlignMode.ONCE : AlignMode.ALWAYS; + this._wasAlignOnce = void 0; + } + }, + onEnable: function onEnable() { + WidgetManager.add(this); + }, + onDisable: function onDisable() { + WidgetManager.remove(this); + }, + _validateTargetInDEV: false, + _setAlign: function _setAlign(flag, isAlign) { + var current = (this._alignFlags & flag) > 0; + if (isAlign === current) return; + var isHorizontal = (flag & LEFT_RIGHT) > 0; + if (isAlign) { + this._alignFlags |= flag; + if (isHorizontal) { + this.isAlignHorizontalCenter = false; + if (this.isStretchWidth) { + this._originalWidth = this.node.width; + false; + } + } else { + this.isAlignVerticalCenter = false; + if (this.isStretchHeight) { + this._originalHeight = this.node.height; + false; + } + } + false; + } else { + isHorizontal ? this.isStretchWidth && (this.node.width = this._originalWidth) : this.isStretchHeight && (this.node.height = this._originalHeight); + this._alignFlags &= ~flag; + } + }, + updateAlignment: function updateAlignment() { + WidgetManager.updateAlignment(this.node); + } + }); + Object.defineProperty(Widget.prototype, "isAlignOnce", { + get: function get() { + true; + cc.warn("`widget.isAlignOnce` is deprecated, use `widget.alignMode === cc.Widget.AlignMode.ONCE` instead please."); + return this.alignMode === AlignMode.ONCE; + }, + set: function set(value) { + true; + cc.warn("`widget.isAlignOnce` is deprecated, use `widget.alignMode = cc.Widget.AlignMode.*` instead please."); + this.alignMode = value ? AlignMode.ONCE : AlignMode.ALWAYS; + } + }); + cc.Widget = module.exports = Widget; + }), { + "../base-ui/CCWidgetManager": 134, + "./CCComponent": 150 + } ], + 174: [ (function(require, module, exports) { + "use strict"; + var macro = require("../../platform/CCMacro"); + var EditBoxImplBase = require("../editbox/EditBoxImplBase"); + var Label = require("../CCLabel"); + var Types = require("./types"); + var InputMode = Types.InputMode; + var InputFlag = Types.InputFlag; + var KeyboardReturnType = Types.KeyboardReturnType; + function capitalize(string) { + return string.replace(/(?:^|\s)\S/g, (function(a) { + return a.toUpperCase(); + })); + } + function capitalizeFirstLetter(string) { + return string.charAt(0).toUpperCase() + string.slice(1); + } + var EditBox = cc.Class({ + name: "cc.EditBox", + extends: cc.Component, + editor: false, + properties: { + _string: "", + string: { + tooltip: false, + get: function get() { + return this._string; + }, + set: function set(value) { + value = "" + value; + this.maxLength >= 0 && value.length >= this.maxLength && (value = value.slice(0, this.maxLength)); + this._string = value; + this._updateString(value); + } + }, + textLabel: { + tooltip: false, + default: null, + type: Label, + notify: function notify(oldValue) { + if (this.textLabel && this.textLabel !== oldValue) { + this._updateTextLabel(); + this._updateLabels(); + } + } + }, + placeholderLabel: { + tooltip: false, + default: null, + type: Label, + notify: function notify(oldValue) { + if (this.placeholderLabel && this.placeholderLabel !== oldValue) { + this._updatePlaceholderLabel(); + this._updateLabels(); + } + } + }, + background: { + tooltip: false, + default: null, + type: cc.Sprite, + notify: function notify(oldValue) { + this.background && this.background !== oldValue && this._updateBackgroundSprite(); + } + }, + _N$backgroundImage: { + default: void 0, + type: cc.SpriteFrame + }, + backgroundImage: { + get: function get() { + if (!this.background) return null; + return this.background.spriteFrame; + }, + set: function set(value) { + this.background && (this.background.spriteFrame = value); + } + }, + returnType: { + default: KeyboardReturnType.DEFAULT, + tooltip: false, + displayName: "KeyboardReturnType", + type: KeyboardReturnType + }, + _N$returnType: { + default: void 0, + type: cc.Float + }, + inputFlag: { + tooltip: false, + default: InputFlag.DEFAULT, + type: InputFlag, + notify: function notify() { + this._updateString(this._string); + } + }, + inputMode: { + tooltip: false, + default: InputMode.ANY, + type: InputMode, + notify: function notify(oldValue) { + if (this.inputMode !== oldValue) { + this._updateTextLabel(); + this._updatePlaceholderLabel(); + } + } + }, + fontSize: { + get: function get() { + if (!this.textLabel) return 0; + return this.textLabel.fontSize; + }, + set: function set(value) { + this.textLabel && (this.textLabel.fontSize = value); + } + }, + _N$fontSize: { + default: void 0, + type: cc.Float + }, + lineHeight: { + get: function get() { + if (!this.textLabel) return 0; + return this.textLabel.lineHeight; + }, + set: function set(value) { + this.textLabel && (this.textLabel.lineHeight = value); + } + }, + _N$lineHeight: { + default: void 0, + type: cc.Float + }, + fontColor: { + get: function get() { + if (!this.textLabel) return cc.Color.BLACK; + return this.textLabel.node.color; + }, + set: function set(value) { + if (this.textLabel) { + this.textLabel.node.color = value; + this.textLabel.node.opacity = value.a; + } + } + }, + _N$fontColor: void 0, + placeholder: { + tooltip: false, + get: function get() { + if (!this.placeholderLabel) return ""; + return this.placeholderLabel.string; + }, + set: function set(value) { + this.placeholderLabel && (this.placeholderLabel.string = value); + } + }, + _N$placeholder: { + default: void 0, + type: cc.String + }, + placeholderFontSize: { + get: function get() { + if (!this.placeholderLabel) return 0; + return this.placeholderLabel.fontSize; + }, + set: function set(value) { + this.placeholderLabel && (this.placeholderLabel.fontSize = value); + } + }, + _N$placeholderFontSize: { + default: void 0, + type: cc.Float + }, + placeholderFontColor: { + get: function get() { + if (!this.placeholderLabel) return cc.Color.BLACK; + return this.placeholderLabel.node.color; + }, + set: function set(value) { + if (this.placeholderLabel) { + this.placeholderLabel.node.color = value; + this.placeholderLabel.node.opacity = value.a; + } + } + }, + _N$placeholderFontColor: void 0, + maxLength: { + tooltip: false, + default: 20 + }, + _N$maxLength: { + default: void 0, + type: cc.Float + }, + stayOnTop: { + default: false, + notify: function notify() { + cc.warn("editBox.stayOnTop is removed since v2.1."); + } + }, + _tabIndex: 0, + tabIndex: { + tooltip: false, + get: function get() { + return this._tabIndex; + }, + set: function set(value) { + if (this._tabIndex !== value) { + this._tabIndex = value; + this._impl && this._impl.setTabIndex(value); + } + } + }, + editingDidBegan: { + default: [], + type: cc.Component.EventHandler + }, + textChanged: { + default: [], + type: cc.Component.EventHandler + }, + editingDidEnded: { + default: [], + type: cc.Component.EventHandler + }, + editingReturn: { + default: [], + type: cc.Component.EventHandler + } + }, + statics: { + _ImplClass: EditBoxImplBase, + KeyboardReturnType: KeyboardReturnType, + InputFlag: InputFlag, + InputMode: InputMode + }, + _init: function _init() { + this._upgradeComp(); + this._isLabelVisible = true; + this.node.on(cc.Node.EventType.SIZE_CHANGED, this._syncSize, this); + var impl = this._impl = new EditBox._ImplClass(); + impl.init(this); + this._updateString(this._string); + this._syncSize(); + }, + _updateBackgroundSprite: function _updateBackgroundSprite() { + var background = this.background; + if (!background) { + var node = this.node.getChildByName("BACKGROUND_SPRITE"); + node || (node = new cc.Node("BACKGROUND_SPRITE")); + background = node.getComponent(cc.Sprite); + background || (background = node.addComponent(cc.Sprite)); + node.parent = this.node; + this.background = background; + } + background.type = cc.Sprite.Type.SLICED; + if (void 0 !== this._N$backgroundImage) { + background.spriteFrame = this._N$backgroundImage; + this._N$backgroundImage = void 0; + } + }, + _updateTextLabel: function _updateTextLabel() { + var textLabel = this.textLabel; + if (!textLabel) { + var node = this.node.getChildByName("TEXT_LABEL"); + node || (node = new cc.Node("TEXT_LABEL")); + textLabel = node.getComponent(Label); + textLabel || (textLabel = node.addComponent(Label)); + node.parent = this.node; + this.textLabel = textLabel; + } + textLabel.node.setAnchorPoint(0, 1); + textLabel.overflow = Label.Overflow.CLAMP; + if (this.inputMode === InputMode.ANY) { + textLabel.verticalAlign = macro.VerticalTextAlignment.TOP; + textLabel.enableWrapText = true; + } else { + textLabel.verticalAlign = macro.VerticalTextAlignment.CENTER; + textLabel.enableWrapText = false; + } + textLabel.string = this._updateLabelStringStyle(this._string); + if (void 0 !== this._N$fontColor) { + textLabel.node.color = this._N$fontColor; + textLabel.node.opacity = this._N$fontColor.a; + this._N$fontColor = void 0; + } + if (void 0 !== this._N$fontSize) { + textLabel.fontSize = this._N$fontSize; + this._N$fontSize = void 0; + } + if (void 0 !== this._N$lineHeight) { + textLabel.lineHeight = this._N$lineHeight; + this._N$lineHeight = void 0; + } + }, + _updatePlaceholderLabel: function _updatePlaceholderLabel() { + var placeholderLabel = this.placeholderLabel; + if (!placeholderLabel) { + var node = this.node.getChildByName("PLACEHOLDER_LABEL"); + node || (node = new cc.Node("PLACEHOLDER_LABEL")); + placeholderLabel = node.getComponent(Label); + placeholderLabel || (placeholderLabel = node.addComponent(Label)); + node.parent = this.node; + this.placeholderLabel = placeholderLabel; + } + placeholderLabel.node.setAnchorPoint(0, 1); + placeholderLabel.overflow = Label.Overflow.CLAMP; + if (this.inputMode === InputMode.ANY) { + placeholderLabel.verticalAlign = macro.VerticalTextAlignment.TOP; + placeholderLabel.enableWrapText = true; + } else { + placeholderLabel.verticalAlign = macro.VerticalTextAlignment.CENTER; + placeholderLabel.enableWrapText = false; + } + placeholderLabel.string = this.placeholder; + if (void 0 !== this._N$placeholderFontColor) { + placeholderLabel.node.color = this._N$placeholderFontColor; + placeholderLabel.node.opacity = this._N$placeholderFontColor.a; + this._N$placeholderFontColor = void 0; + } + if (void 0 !== this._N$placeholderFontSize) { + placeholderLabel.fontSize = this._N$placeholderFontSize; + this._N$placeholderFontSize = void 0; + } + }, + _upgradeComp: function _upgradeComp() { + if (void 0 !== this._N$returnType) { + this.returnType = this._N$returnType; + this._N$returnType = void 0; + } + if (void 0 !== this._N$maxLength) { + this.maxLength = this._N$maxLength; + this._N$maxLength = void 0; + } + void 0 !== this._N$backgroundImage && this._updateBackgroundSprite(); + void 0 === this._N$fontColor && void 0 === this._N$fontSize && void 0 === this._N$lineHeight || this._updateTextLabel(); + void 0 === this._N$placeholderFontColor && void 0 === this._N$placeholderFontSize || this._updatePlaceholderLabel(); + if (void 0 !== this._N$placeholder) { + this.placeholder = this._N$placeholder; + this._N$placeholder = void 0; + } + }, + _syncSize: function _syncSize() { + if (this._impl) { + var size = this.node.getContentSize(); + this._impl.setSize(size.width, size.height); + } + }, + _showLabels: function _showLabels() { + this._isLabelVisible = true; + this._updateLabels(); + }, + _hideLabels: function _hideLabels() { + this._isLabelVisible = false; + this.textLabel && (this.textLabel.node.active = false); + this.placeholderLabel && (this.placeholderLabel.node.active = false); + }, + _updateLabels: function _updateLabels() { + if (this._isLabelVisible) { + var content = this._string; + this.textLabel && (this.textLabel.node.active = "" !== content); + this.placeholderLabel && (this.placeholderLabel.node.active = "" === content); + } + }, + _updateString: function _updateString(text) { + var textLabel = this.textLabel; + if (!textLabel) return; + var displayText = text; + displayText && (displayText = this._updateLabelStringStyle(displayText)); + textLabel.string = displayText; + this._updateLabels(); + }, + _updateLabelStringStyle: function _updateLabelStringStyle(text, ignorePassword) { + var inputFlag = this.inputFlag; + if (ignorePassword || inputFlag !== InputFlag.PASSWORD) inputFlag === InputFlag.INITIAL_CAPS_ALL_CHARACTERS ? text = text.toUpperCase() : inputFlag === InputFlag.INITIAL_CAPS_WORD ? text = capitalize(text) : inputFlag === InputFlag.INITIAL_CAPS_SENTENCE && (text = capitalizeFirstLetter(text)); else { + var passwordString = ""; + var len = text.length; + for (var i = 0; i < len; ++i) passwordString += "\u25cf"; + text = passwordString; + } + return text; + }, + editBoxEditingDidBegan: function editBoxEditingDidBegan() { + cc.Component.EventHandler.emitEvents(this.editingDidBegan, this); + this.node.emit("editing-did-began", this); + }, + editBoxEditingDidEnded: function editBoxEditingDidEnded() { + cc.Component.EventHandler.emitEvents(this.editingDidEnded, this); + this.node.emit("editing-did-ended", this); + }, + editBoxTextChanged: function editBoxTextChanged(text) { + text = this._updateLabelStringStyle(text, true); + this.string = text; + cc.Component.EventHandler.emitEvents(this.textChanged, text, this); + this.node.emit("text-changed", this); + }, + editBoxEditingReturn: function editBoxEditingReturn() { + cc.Component.EventHandler.emitEvents(this.editingReturn, this); + this.node.emit("editing-return", this); + }, + onEnable: function onEnable() { + true; + this._registerEvent(); + this._impl && this._impl.enable(); + }, + onDisable: function onDisable() { + true; + this._unregisterEvent(); + this._impl && this._impl.disable(); + }, + onDestroy: function onDestroy() { + this._impl && this._impl.clear(); + }, + __preload: function __preload() { + this._init(); + }, + _registerEvent: function _registerEvent() { + this.node.on(cc.Node.EventType.TOUCH_START, this._onTouchBegan, this); + this.node.on(cc.Node.EventType.TOUCH_END, this._onTouchEnded, this); + }, + _unregisterEvent: function _unregisterEvent() { + this.node.off(cc.Node.EventType.TOUCH_START, this._onTouchBegan, this); + this.node.off(cc.Node.EventType.TOUCH_END, this._onTouchEnded, this); + }, + _onTouchBegan: function _onTouchBegan(event) { + event.stopPropagation(); + }, + _onTouchCancel: function _onTouchCancel(event) { + event.stopPropagation(); + }, + _onTouchEnded: function _onTouchEnded(event) { + this._impl && this._impl.beginEditing(); + event.stopPropagation(); + }, + setFocus: function setFocus() { + cc.errorID(1400, "setFocus()", "focus()"); + this._impl && this._impl.setFocus(true); + }, + focus: function focus() { + this._impl && this._impl.setFocus(true); + }, + blur: function blur() { + this._impl && this._impl.setFocus(false); + }, + isFocused: function isFocused() { + return !!this._impl && this._impl.isFocused(); + }, + update: function update() { + this._impl && this._impl.update(); + } + }); + cc.EditBox = module.exports = EditBox; + cc.sys.isBrowser && require("./WebEditBoxImpl"); + }), { + "../../platform/CCMacro": 245, + "../CCLabel": 152, + "../editbox/EditBoxImplBase": 175, + "./WebEditBoxImpl": 176, + "./types": 178 + } ], + 175: [ (function(require, module, exports) { + "use strict"; + var EditBoxImplBase = cc.Class({ + ctor: function ctor() { + this._delegate = null; + this._editing = false; + }, + init: function init(delegate) {}, + enable: function enable() {}, + disable: function disable() { + this._editing && this.endEditing(); + }, + clear: function clear() {}, + update: function update() {}, + setTabIndex: function setTabIndex(index) {}, + setSize: function setSize(width, height) {}, + setFocus: function setFocus(value) { + value ? this.beginEditing() : this.endEditing(); + }, + isFocused: function isFocused() { + return this._editing; + }, + beginEditing: function beginEditing() {}, + endEditing: function endEditing() {} + }); + module.exports = EditBoxImplBase; + }), {} ], + 176: [ (function(require, module, exports) { + "use strict"; + var _mat = _interopRequireDefault(require("../../value-types/mat4")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + var utils = require("../../platform/utils"); + var macro = require("../../platform/CCMacro"); + var Types = require("./types"); + var Label = require("../CCLabel"); + var tabIndexUtil = require("./tabIndexUtil"); + var EditBox = cc.EditBox; + var js = cc.js; + var InputMode = Types.InputMode; + var InputFlag = Types.InputFlag; + var KeyboardReturnType = Types.KeyboardReturnType; + var polyfill = { + zoomInvalid: false + }; + cc.sys.OS_ANDROID !== cc.sys.os || cc.sys.browserType !== cc.sys.BROWSER_TYPE_SOUGOU && cc.sys.browserType !== cc.sys.BROWSER_TYPE_360 || (polyfill.zoomInvalid = true); + var DELAY_TIME = 800; + var SCROLLY = 100; + var LEFT_PADDING = 2; + var _domCount = 0; + var _vec3 = cc.v3(); + var _currentEditBoxImpl = null; + var _fullscreen = false; + var _autoResize = false; + var BaseClass = EditBox._ImplClass; + function WebEditBoxImpl() { + BaseClass.call(this); + this._domId = "EditBoxId_" + ++_domCount; + this._placeholderStyleSheet = null; + this._elem = null; + this._isTextArea = false; + this._worldMat = new _mat["default"](); + this._cameraMat = new _mat["default"](); + this._m00 = 0; + this._m01 = 0; + this._m04 = 0; + this._m05 = 0; + this._m12 = 0; + this._m13 = 0; + this._w = 0; + this._h = 0; + this._cacheViewportRect = cc.rect(0, 0, 0, 0); + this._inputMode = null; + this._inputFlag = null; + this._returnType = null; + this._eventListeners = {}; + this._textLabelFont = null; + this._textLabelFontSize = null; + this._textLabelFontColor = null; + this._textLabelAlign = null; + this._placeholderLabelFont = null; + this._placeholderLabelFontSize = null; + this._placeholderLabelFontColor = null; + this._placeholderLabelAlign = null; + this._placeholderLineHeight = null; + } + js.extend(WebEditBoxImpl, BaseClass); + EditBox._ImplClass = WebEditBoxImpl; + Object.assign(WebEditBoxImpl.prototype, { + init: function init(delegate) { + if (!delegate) return; + this._delegate = delegate; + delegate.inputMode === InputMode.ANY ? this._createTextArea() : this._createInput(); + tabIndexUtil.add(this); + this.setTabIndex(delegate.tabIndex); + this._initStyleSheet(); + this._registerEventListeners(); + this._addDomToGameContainer(); + _fullscreen = cc.view.isAutoFullScreenEnabled(); + _autoResize = cc.view._resizeWithBrowserSize; + }, + clear: function clear() { + this._removeEventListeners(); + this._removeDomFromGameContainer(); + tabIndexUtil.remove(this); + _currentEditBoxImpl === this && (_currentEditBoxImpl = null); + }, + update: function update() { + this._updateMatrix(); + }, + setTabIndex: function setTabIndex(index) { + this._elem.tabIndex = index; + tabIndexUtil.resort(); + }, + setSize: function setSize(width, height) { + var elem = this._elem; + elem.style.width = width + "px"; + elem.style.height = height + "px"; + }, + beginEditing: function beginEditing() { + _currentEditBoxImpl && _currentEditBoxImpl !== this && _currentEditBoxImpl.setFocus(false); + this._editing = true; + _currentEditBoxImpl = this; + this._delegate.editBoxEditingDidBegan(); + this._showDom(); + this._elem.focus(); + }, + endEditing: function endEditing() { + this._elem && this._elem.blur(); + }, + _createInput: function _createInput() { + this._isTextArea = false; + this._elem = document.createElement("input"); + }, + _createTextArea: function _createTextArea() { + this._isTextArea = true; + this._elem = document.createElement("textarea"); + }, + _addDomToGameContainer: function _addDomToGameContainer() { + cc.game.container.appendChild(this._elem); + document.head.appendChild(this._placeholderStyleSheet); + }, + _removeDomFromGameContainer: function _removeDomFromGameContainer() { + var hasElem = utils.contains(cc.game.container, this._elem); + hasElem && cc.game.container.removeChild(this._elem); + var hasStyleSheet = utils.contains(document.head, this._placeholderStyleSheet); + hasStyleSheet && document.head.removeChild(this._placeholderStyleSheet); + delete this._elem; + delete this._placeholderStyleSheet; + }, + _showDom: function _showDom() { + this._updateMaxLength(); + this._updateInputType(); + this._updateStyleSheet(); + this._elem.style.display = ""; + this._delegate._hideLabels(); + cc.sys.isMobile && this._showDomOnMobile(); + }, + _hideDom: function _hideDom() { + var elem = this._elem; + elem.style.display = "none"; + this._delegate._showLabels(); + cc.sys.isMobile && this._hideDomOnMobile(); + }, + _showDomOnMobile: function _showDomOnMobile() { + if (cc.sys.os !== cc.sys.OS_ANDROID) return; + if (_fullscreen) { + cc.view.enableAutoFullScreen(false); + cc.screen.exitFullScreen(); + } + _autoResize && cc.view.resizeWithBrowserSize(false); + this._adjustWindowScroll(); + }, + _hideDomOnMobile: function _hideDomOnMobile() { + if (cc.sys.os === cc.sys.OS_ANDROID) { + _autoResize && cc.view.resizeWithBrowserSize(true); + setTimeout((function() { + _currentEditBoxImpl || _fullscreen && cc.view.enableAutoFullScreen(true); + }), DELAY_TIME); + } + }, + _adjustWindowScroll: function _adjustWindowScroll() { + var self = this; + setTimeout((function() { + window.scrollY < SCROLLY && self._elem.scrollIntoView({ + block: "start", + inline: "nearest", + behavior: "smooth" + }); + }), DELAY_TIME); + }, + _scrollBackWindow: function _scrollBackWindow() { + setTimeout((function() { + var sys = cc.sys; + if (sys.browserType === sys.BROWSER_TYPE_WECHAT && sys.os === sys.OS_IOS) { + window.top && window.top.scrollTo(0, 0); + return; + } + window.scrollTo(0, 0); + }), DELAY_TIME); + }, + _updateCameraMatrix: function _updateCameraMatrix() { + var node = this._delegate.node; + node.getWorldMatrix(this._worldMat); + var worldMat = this._worldMat; + var nodeContentSize = node._contentSize, nodeAnchorPoint = node._anchorPoint; + _vec3.x = -nodeAnchorPoint.x * nodeContentSize.width; + _vec3.y = -nodeAnchorPoint.y * nodeContentSize.height; + _mat["default"].transform(worldMat, worldMat, _vec3); + false; + var camera = cc.Camera.findCamera(node); + if (!camera) return false; + camera.getWorldToScreenMatrix2D(this._cameraMat); + _mat["default"].mul(this._cameraMat, this._cameraMat, worldMat); + return true; + }, + _updateMatrix: function _updateMatrix() { + if (false, !this._updateCameraMatrix()) return; + var cameraMatm = this._cameraMat.m; + var node = this._delegate.node; + var localView = cc.view; + if (this._m00 === cameraMatm[0] && this._m01 === cameraMatm[1] && this._m04 === cameraMatm[4] && this._m05 === cameraMatm[5] && this._m12 === cameraMatm[12] && this._m13 === cameraMatm[13] && this._w === node._contentSize.width && this._h === node._contentSize.height && this._cacheViewportRect.equals(localView._viewportRect)) return; + this._m00 = cameraMatm[0]; + this._m01 = cameraMatm[1]; + this._m04 = cameraMatm[4]; + this._m05 = cameraMatm[5]; + this._m12 = cameraMatm[12]; + this._m13 = cameraMatm[13]; + this._w = node._contentSize.width; + this._h = node._contentSize.height; + this._cacheViewportRect.set(localView._viewportRect); + var scaleX = localView._scaleX, scaleY = localView._scaleY, viewport = localView._viewportRect, dpr = localView._devicePixelRatio; + scaleX /= dpr; + scaleY /= dpr; + var container = cc.game.container; + var a = cameraMatm[0] * scaleX, b = cameraMatm[1], c = cameraMatm[4], d = cameraMatm[5] * scaleY; + var offsetX = container && container.style.paddingLeft && parseInt(container.style.paddingLeft); + offsetX += viewport.x / dpr; + var offsetY = container && container.style.paddingBottom && parseInt(container.style.paddingBottom); + offsetY += viewport.y / dpr; + var tx = cameraMatm[12] * scaleX + offsetX, ty = cameraMatm[13] * scaleY + offsetY; + if (polyfill.zoomInvalid) { + this.setSize(node.width * a, node.height * d); + a = 1; + d = 1; + } + var elem = this._elem; + var matrix = "matrix(" + a + "," + -b + "," + -c + "," + d + "," + tx + "," + -ty + ")"; + elem.style["transform"] = matrix; + elem.style["-webkit-transform"] = matrix; + elem.style["transform-origin"] = "0px 100% 0px"; + elem.style["-webkit-transform-origin"] = "0px 100% 0px"; + }, + _updateInputType: function _updateInputType() { + var delegate = this._delegate, inputMode = delegate.inputMode, inputFlag = delegate.inputFlag, returnType = delegate.returnType, elem = this._elem; + if (this._inputMode === inputMode && this._inputFlag === inputFlag && this._returnType === returnType) return; + this._inputMode = inputMode; + this._inputFlag = inputFlag; + this._returnType = returnType; + if (this._isTextArea) { + var _textTransform = "none"; + inputFlag === InputFlag.INITIAL_CAPS_ALL_CHARACTERS ? _textTransform = "uppercase" : inputFlag === InputFlag.INITIAL_CAPS_WORD && (_textTransform = "capitalize"); + elem.style.textTransform = _textTransform; + return; + } + if (inputFlag === InputFlag.PASSWORD) { + elem.type = "password"; + elem.style.textTransform = "none"; + return; + } + var type = elem.type; + if (inputMode === InputMode.EMAIL_ADDR) type = "email"; else if (inputMode === InputMode.NUMERIC || inputMode === InputMode.DECIMAL) type = "number"; else if (inputMode === InputMode.PHONE_NUMBER) { + type = "number"; + elem.pattern = "[0-9]*"; + elem.onmousewheel = function() { + return false; + }; + } else if (inputMode === InputMode.URL) type = "url"; else { + type = "text"; + returnType === KeyboardReturnType.SEARCH && (type = "search"); + } + elem.type = type; + try { + elem.autocomplete = "off"; + } catch (error) {} + var textTransform = "none"; + inputFlag === InputFlag.INITIAL_CAPS_ALL_CHARACTERS ? textTransform = "uppercase" : inputFlag === InputFlag.INITIAL_CAPS_WORD && (textTransform = "capitalize"); + elem.style.textTransform = textTransform; + }, + _updateMaxLength: function _updateMaxLength() { + var maxLength = this._delegate.maxLength; + maxLength < 0 && (maxLength = 65535); + this._elem.maxLength = maxLength; + }, + _initStyleSheet: function _initStyleSheet() { + var elem = this._elem; + elem.style.display = "none"; + elem.style.border = 0; + elem.style.background = "transparent"; + elem.style.width = "100%"; + elem.style.height = "100%"; + elem.style.active = 0; + elem.style.outline = "medium"; + elem.style.padding = "0"; + elem.style.textTransform = "none"; + elem.style.position = "absolute"; + elem.style.bottom = "0px"; + elem.style.left = LEFT_PADDING + "px"; + elem.className = "cocosEditBox"; + elem.id = this._domId; + if (this._isTextArea) { + elem.style.resize = "none"; + elem.style.overflow_y = "scroll"; + } else { + elem.type = "text"; + elem.style["-moz-appearance"] = "textfield"; + } + this._placeholderStyleSheet = document.createElement("style"); + }, + _updateStyleSheet: function _updateStyleSheet() { + var delegate = this._delegate, elem = this._elem; + elem.value = delegate.string; + elem.placeholder = delegate.placeholder; + this._updateTextLabel(delegate.textLabel); + this._updatePlaceholderLabel(delegate.placeholderLabel); + }, + _updateTextLabel: function _updateTextLabel(textLabel) { + if (!textLabel) return; + var font = textLabel.font; + font = !font || font instanceof cc.BitmapFont ? textLabel.fontFamily : font._fontFamily; + var fontSize = textLabel.fontSize * textLabel.node.scaleY; + if (this._textLabelFont === font && this._textLabelFontSize === fontSize && this._textLabelFontColor === textLabel.fontColor && this._textLabelAlign === textLabel.horizontalAlign) return; + this._textLabelFont = font; + this._textLabelFontSize = fontSize; + this._textLabelFontColor = textLabel.fontColor; + this._textLabelAlign = textLabel.horizontalAlign; + var elem = this._elem; + elem.style.fontSize = fontSize + "px"; + elem.style.color = textLabel.node.color.toCSS(); + elem.style.fontFamily = font; + switch (textLabel.horizontalAlign) { + case Label.HorizontalAlign.LEFT: + elem.style.textAlign = "left"; + break; + + case Label.HorizontalAlign.CENTER: + elem.style.textAlign = "center"; + break; + + case Label.HorizontalAlign.RIGHT: + elem.style.textAlign = "right"; + } + }, + _updatePlaceholderLabel: function _updatePlaceholderLabel(placeholderLabel) { + if (!placeholderLabel) return; + var font = placeholderLabel.font; + font = !font || font instanceof cc.BitmapFont ? placeholderLabel.fontFamily : placeholderLabel.font._fontFamily; + var fontSize = placeholderLabel.fontSize * placeholderLabel.node.scaleY; + if (this._placeholderLabelFont === font && this._placeholderLabelFontSize === fontSize && this._placeholderLabelFontColor === placeholderLabel.fontColor && this._placeholderLabelAlign === placeholderLabel.horizontalAlign && this._placeholderLineHeight === placeholderLabel.fontSize) return; + this._placeholderLabelFont = font; + this._placeholderLabelFontSize = fontSize; + this._placeholderLabelFontColor = placeholderLabel.fontColor; + this._placeholderLabelAlign = placeholderLabel.horizontalAlign; + this._placeholderLineHeight = placeholderLabel.fontSize; + var styleEl = this._placeholderStyleSheet; + var fontColor = placeholderLabel.node.color.toCSS(); + var lineHeight = placeholderLabel.fontSize; + var horizontalAlign; + switch (placeholderLabel.horizontalAlign) { + case Label.HorizontalAlign.LEFT: + horizontalAlign = "left"; + break; + + case Label.HorizontalAlign.CENTER: + horizontalAlign = "center"; + break; + + case Label.HorizontalAlign.RIGHT: + horizontalAlign = "right"; + } + styleEl.innerHTML = "#" + this._domId + "::-webkit-input-placeholder,#" + this._domId + "::-moz-placeholder,#" + this._domId + ":-ms-input-placeholder{text-transform: initial; font-family: " + font + "; font-size: " + fontSize + "px; color: " + fontColor + "; line-height: " + lineHeight + "px; text-align: " + horizontalAlign + ";}"; + cc.sys.browserType === cc.sys.BROWSER_TYPE_EDGE && (styleEl.innerHTML += "#" + this._domId + "::-ms-clear{display: none;}"); + }, + _registerEventListeners: function _registerEventListeners() { + var impl = this, elem = this._elem, inputLock = false, cbs = this._eventListeners; + cbs.compositionStart = function() { + inputLock = true; + }; + cbs.compositionEnd = function() { + inputLock = false; + impl._delegate.editBoxTextChanged(elem.value); + }; + cbs.onInput = function() { + if (inputLock) return; + var maxLength = impl._delegate.maxLength; + maxLength >= 0 && (elem.value = elem.value.slice(0, maxLength)); + impl._delegate.editBoxTextChanged(elem.value); + }; + cbs.onClick = function(e) { + impl._editing && cc.sys.isMobile && impl._adjustWindowScroll(); + }; + cbs.onKeydown = function(e) { + if (e.keyCode === macro.KEY.enter) { + e.stopPropagation(); + impl._delegate.editBoxEditingReturn(); + impl._isTextArea || elem.blur(); + } else if (e.keyCode === macro.KEY.tab) { + e.stopPropagation(); + e.preventDefault(); + tabIndexUtil.next(impl); + } + }; + cbs.onBlur = function() { + cc.sys.isMobile && inputLock && cbs.compositionEnd(); + impl._editing = false; + _currentEditBoxImpl = null; + impl._hideDom(); + impl._delegate.editBoxEditingDidEnded(); + }; + elem.addEventListener("compositionstart", cbs.compositionStart); + elem.addEventListener("compositionend", cbs.compositionEnd); + elem.addEventListener("input", cbs.onInput); + elem.addEventListener("keydown", cbs.onKeydown); + elem.addEventListener("blur", cbs.onBlur); + elem.addEventListener("touchstart", cbs.onClick); + }, + _removeEventListeners: function _removeEventListeners() { + var elem = this._elem, cbs = this._eventListeners; + elem.removeEventListener("compositionstart", cbs.compositionStart); + elem.removeEventListener("compositionend", cbs.compositionEnd); + elem.removeEventListener("input", cbs.onInput); + elem.removeEventListener("keydown", cbs.onKeydown); + elem.removeEventListener("blur", cbs.onBlur); + elem.removeEventListener("touchstart", cbs.onClick); + cbs.compositionStart = null; + cbs.compositionEnd = null; + cbs.onInput = null; + cbs.onKeydown = null; + cbs.onBlur = null; + cbs.onClick = null; + } + }); + }), { + "../../platform/CCMacro": 245, + "../../platform/utils": 264, + "../../value-types/mat4": 342, + "../CCLabel": 152, + "./tabIndexUtil": 177, + "./types": 178 + } ], + 177: [ (function(require, module, exports) { + "use strict"; + var tabIndexUtil = { + _tabIndexList: [], + add: function add(editBoxImpl) { + var list = this._tabIndexList; + var index = list.indexOf(editBoxImpl); + -1 === index && list.push(editBoxImpl); + }, + remove: function remove(editBoxImpl) { + var list = this._tabIndexList; + var index = list.indexOf(editBoxImpl); + -1 !== index && list.splice(index, 1); + }, + resort: function resort() { + this._tabIndexList.sort((function(a, b) { + return a._delegate._tabIndex - b._delegate._tabIndex; + })); + }, + next: function next(editBoxImpl) { + var list = this._tabIndexList; + var index = list.indexOf(editBoxImpl); + editBoxImpl.setFocus(false); + if (-1 !== index) { + var nextImpl = list[index + 1]; + nextImpl && nextImpl._delegate._tabIndex >= 0 && nextImpl.setFocus(true); + } + } + }; + module.exports = tabIndexUtil; + }), {} ], + 178: [ (function(require, module, exports) { + "use strict"; + var KeyboardReturnType = cc.Enum({ + DEFAULT: 0, + DONE: 1, + SEND: 2, + SEARCH: 3, + GO: 4, + NEXT: 5 + }); + var InputMode = cc.Enum({ + ANY: 0, + EMAIL_ADDR: 1, + NUMERIC: 2, + PHONE_NUMBER: 3, + URL: 4, + DECIMAL: 5, + SINGLE_LINE: 6 + }); + var InputFlag = cc.Enum({ + PASSWORD: 0, + SENSITIVE: 1, + INITIAL_CAPS_WORD: 2, + INITIAL_CAPS_SENTENCE: 3, + INITIAL_CAPS_ALL_CHARACTERS: 4, + DEFAULT: 5 + }); + module.exports = { + KeyboardReturnType: KeyboardReturnType, + InputMode: InputMode, + InputFlag: InputFlag + }; + }), {} ], + 179: [ (function(require, module, exports) { + "use strict"; + require("./CCComponent"); + require("./CCComponentEventHandler"); + require("./missing-script"); + var SubContextView = require("./SubContextView"); + if (!SubContextView) { + SubContextView = cc.Class({ + name: "cc.SubContextView", + extends: cc.Component + }); + cc.SubContextView = cc.WXSubContextView = cc.SwanSubContextView = SubContextView; + } + var components = [ require("./CCSprite"), require("./CCWidget"), require("./CCCanvas"), require("./CCAudioSource"), require("./CCAnimation"), require("./CCButton"), require("./CCLabel"), require("./CCProgressBar"), require("./CCMask"), require("./CCScrollBar"), require("./CCScrollView"), require("./CCPageViewIndicator"), require("./CCPageView"), require("./CCSlider"), require("./CCLayout"), require("./editbox/CCEditBox"), require("./CCLabelOutline"), require("./CCLabelShadow"), require("./CCRichText"), require("./CCToggleContainer"), require("./CCToggleGroup"), require("./CCToggle"), require("./CCBlockInputEvents"), require("./CCMotionStreak"), require("./CCSafeArea"), SubContextView ]; + module.exports = components; + }), { + "./CCAnimation": 145, + "./CCAudioSource": 146, + "./CCBlockInputEvents": 147, + "./CCButton": 148, + "./CCCanvas": 149, + "./CCComponent": 150, + "./CCComponentEventHandler": 151, + "./CCLabel": 152, + "./CCLabelOutline": 153, + "./CCLabelShadow": 154, + "./CCLayout": 155, + "./CCMask": 156, + "./CCMotionStreak": 157, + "./CCPageView": 158, + "./CCPageViewIndicator": 159, + "./CCProgressBar": 160, + "./CCRichText": 162, + "./CCSafeArea": 163, + "./CCScrollBar": 164, + "./CCScrollView": 165, + "./CCSlider": 166, + "./CCSprite": 167, + "./CCToggle": 169, + "./CCToggleContainer": 170, + "./CCToggleGroup": 171, + "./CCWidget": 173, + "./SubContextView": void 0, + "./editbox/CCEditBox": 174, + "./missing-script": 180 + } ], + 180: [ (function(require, module, exports) { + "use strict"; + var js = cc.js; + var MissingScript = cc.Class({ + name: "cc.MissingScript", + extends: cc.Component, + editor: { + inspector: "packages://inspector/inspectors/comps/missing-script.js" + }, + properties: { + compiled: { + default: false, + serializable: false + }, + _$erialized: { + default: null, + visible: false, + editorOnly: true + } + }, + ctor: false, + statics: { + safeFindClass: function safeFindClass(id) { + var cls = js._getClassById(id); + if (cls) return cls; + cc.deserialize.reportMissingClass(id); + return MissingScript; + } + }, + onLoad: function onLoad() { + cc.warnID(4600, this.node.name); + } + }); + cc._MissingScript = module.exports = MissingScript; + }), {} ], + 181: [ (function(require, module, exports) { + "use strict"; + var js = cc.js; + require("../event/event"); + var EventMouse = function EventMouse(eventType, bubbles) { + cc.Event.call(this, cc.Event.MOUSE, bubbles); + this._eventType = eventType; + this._button = 0; + this._x = 0; + this._y = 0; + this._prevX = 0; + this._prevY = 0; + this._scrollX = 0; + this._scrollY = 0; + }; + js.extend(EventMouse, cc.Event); + var proto = EventMouse.prototype; + proto.setScrollData = function(scrollX, scrollY) { + this._scrollX = scrollX; + this._scrollY = scrollY; + }; + proto.getScrollX = function() { + return this._scrollX; + }; + proto.getScrollY = function() { + return this._scrollY; + }; + proto.setLocation = function(x, y) { + this._x = x; + this._y = y; + }; + proto.getLocation = function() { + return cc.v2(this._x, this._y); + }; + proto.getLocationInView = function() { + return cc.v2(this._x, cc.view._designResolutionSize.height - this._y); + }; + proto._setPrevCursor = function(x, y) { + this._prevX = x; + this._prevY = y; + }; + proto.getPreviousLocation = function() { + return cc.v2(this._prevX, this._prevY); + }; + proto.getDelta = function() { + return cc.v2(this._x - this._prevX, this._y - this._prevY); + }; + proto.getDeltaX = function() { + return this._x - this._prevX; + }; + proto.getDeltaY = function() { + return this._y - this._prevY; + }; + proto.setButton = function(button) { + this._button = button; + }; + proto.getButton = function() { + return this._button; + }; + proto.getLocationX = function() { + return this._x; + }; + proto.getLocationY = function() { + return this._y; + }; + EventMouse.NONE = 0; + EventMouse.DOWN = 1; + EventMouse.UP = 2; + EventMouse.MOVE = 3; + EventMouse.SCROLL = 4; + EventMouse.BUTTON_LEFT = 0; + EventMouse.BUTTON_RIGHT = 2; + EventMouse.BUTTON_MIDDLE = 1; + EventMouse.BUTTON_4 = 3; + EventMouse.BUTTON_5 = 4; + EventMouse.BUTTON_6 = 5; + EventMouse.BUTTON_7 = 6; + EventMouse.BUTTON_8 = 7; + var EventTouch = function EventTouch(touchArr, bubbles) { + cc.Event.call(this, cc.Event.TOUCH, bubbles); + this._eventCode = 0; + this._touches = touchArr || []; + this.touch = null; + this.currentTouch = null; + }; + js.extend(EventTouch, cc.Event); + proto = EventTouch.prototype; + proto.getEventCode = function() { + return this._eventCode; + }; + proto.getTouches = function() { + return this._touches; + }; + proto._setEventCode = function(eventCode) { + this._eventCode = eventCode; + }; + proto._setTouches = function(touches) { + this._touches = touches; + }; + proto.setLocation = function(x, y) { + this.touch && this.touch.setTouchInfo(this.touch.getID(), x, y); + }; + proto.getLocation = function() { + return this.touch ? this.touch.getLocation() : cc.v2(); + }; + proto.getLocationInView = function() { + return this.touch ? this.touch.getLocationInView() : cc.v2(); + }; + proto.getPreviousLocation = function() { + return this.touch ? this.touch.getPreviousLocation() : cc.v2(); + }; + proto.getStartLocation = function() { + return this.touch ? this.touch.getStartLocation() : cc.v2(); + }; + proto.getID = function() { + return this.touch ? this.touch.getID() : null; + }; + proto.getDelta = function() { + return this.touch ? this.touch.getDelta() : cc.v2(); + }; + proto.getDeltaX = function() { + return this.touch ? this.touch.getDelta().x : 0; + }; + proto.getDeltaY = function() { + return this.touch ? this.touch.getDelta().y : 0; + }; + proto.getLocationX = function() { + return this.touch ? this.touch.getLocationX() : 0; + }; + proto.getLocationY = function() { + return this.touch ? this.touch.getLocationY() : 0; + }; + EventTouch.MAX_TOUCHES = 5; + EventTouch.BEGAN = 0; + EventTouch.MOVED = 1; + EventTouch.ENDED = 2; + EventTouch.CANCELED = 3; + var EventAcceleration = function EventAcceleration(acc, bubbles) { + cc.Event.call(this, cc.Event.ACCELERATION, bubbles); + this.acc = acc; + }; + js.extend(EventAcceleration, cc.Event); + var EventKeyboard = function EventKeyboard(keyCode, isPressed, bubbles) { + cc.Event.call(this, cc.Event.KEYBOARD, bubbles); + this.keyCode = keyCode; + this.isPressed = isPressed; + }; + js.extend(EventKeyboard, cc.Event); + cc.Event.EventMouse = EventMouse; + cc.Event.EventTouch = EventTouch; + cc.Event.EventAcceleration = EventAcceleration; + cc.Event.EventKeyboard = EventKeyboard; + module.exports = cc.Event; + }), { + "../event/event": 188 + } ], + 182: [ (function(require, module, exports) { + "use strict"; + var js = require("../platform/js"); + cc.EventListener = function(type, listenerID, callback) { + this._onEvent = callback; + this._type = type || 0; + this._listenerID = listenerID || ""; + this._registered = false; + this._fixedPriority = 0; + this._node = null; + this._target = null; + this._paused = true; + this._isEnabled = true; + }; + cc.EventListener.prototype = { + constructor: cc.EventListener, + _setPaused: function _setPaused(paused) { + this._paused = paused; + }, + _isPaused: function _isPaused() { + return this._paused; + }, + _setRegistered: function _setRegistered(registered) { + this._registered = registered; + }, + _isRegistered: function _isRegistered() { + return this._registered; + }, + _getType: function _getType() { + return this._type; + }, + _getListenerID: function _getListenerID() { + return this._listenerID; + }, + _setFixedPriority: function _setFixedPriority(fixedPriority) { + this._fixedPriority = fixedPriority; + }, + _getFixedPriority: function _getFixedPriority() { + return this._fixedPriority; + }, + _setSceneGraphPriority: function _setSceneGraphPriority(node) { + this._target = node; + this._node = node; + }, + _getSceneGraphPriority: function _getSceneGraphPriority() { + return this._node; + }, + checkAvailable: function checkAvailable() { + return null !== this._onEvent; + }, + clone: function clone() { + return null; + }, + setEnabled: function setEnabled(enabled) { + this._isEnabled = enabled; + }, + isEnabled: function isEnabled() { + return this._isEnabled; + }, + retain: function retain() {}, + release: function release() {} + }; + cc.EventListener.UNKNOWN = 0; + cc.EventListener.TOUCH_ONE_BY_ONE = 1; + cc.EventListener.TOUCH_ALL_AT_ONCE = 2; + cc.EventListener.KEYBOARD = 3; + cc.EventListener.MOUSE = 4; + cc.EventListener.ACCELERATION = 6; + cc.EventListener.CUSTOM = 8; + var ListenerID = cc.EventListener.ListenerID = { + MOUSE: "__cc_mouse", + TOUCH_ONE_BY_ONE: "__cc_touch_one_by_one", + TOUCH_ALL_AT_ONCE: "__cc_touch_all_at_once", + KEYBOARD: "__cc_keyboard", + ACCELERATION: "__cc_acceleration" + }; + var Custom = function Custom(listenerId, callback) { + this._onCustomEvent = callback; + cc.EventListener.call(this, cc.EventListener.CUSTOM, listenerId, this._callback); + }; + js.extend(Custom, cc.EventListener); + js.mixin(Custom.prototype, { + _onCustomEvent: null, + _callback: function _callback(event) { + null !== this._onCustomEvent && this._onCustomEvent(event); + }, + checkAvailable: function checkAvailable() { + return cc.EventListener.prototype.checkAvailable.call(this) && null !== this._onCustomEvent; + }, + clone: function clone() { + return new Custom(this._listenerID, this._onCustomEvent); + } + }); + var Mouse = function Mouse() { + cc.EventListener.call(this, cc.EventListener.MOUSE, ListenerID.MOUSE, this._callback); + }; + js.extend(Mouse, cc.EventListener); + js.mixin(Mouse.prototype, { + onMouseDown: null, + onMouseUp: null, + onMouseMove: null, + onMouseScroll: null, + _callback: function _callback(event) { + var eventType = cc.Event.EventMouse; + switch (event._eventType) { + case eventType.DOWN: + this.onMouseDown && this.onMouseDown(event); + break; + + case eventType.UP: + this.onMouseUp && this.onMouseUp(event); + break; + + case eventType.MOVE: + this.onMouseMove && this.onMouseMove(event); + break; + + case eventType.SCROLL: + this.onMouseScroll && this.onMouseScroll(event); + } + }, + clone: function clone() { + var eventListener = new Mouse(); + eventListener.onMouseDown = this.onMouseDown; + eventListener.onMouseUp = this.onMouseUp; + eventListener.onMouseMove = this.onMouseMove; + eventListener.onMouseScroll = this.onMouseScroll; + return eventListener; + }, + checkAvailable: function checkAvailable() { + return true; + } + }); + var TouchOneByOne = function TouchOneByOne() { + cc.EventListener.call(this, cc.EventListener.TOUCH_ONE_BY_ONE, ListenerID.TOUCH_ONE_BY_ONE, null); + this._claimedTouches = []; + }; + js.extend(TouchOneByOne, cc.EventListener); + js.mixin(TouchOneByOne.prototype, { + constructor: TouchOneByOne, + _claimedTouches: null, + swallowTouches: false, + onTouchBegan: null, + onTouchMoved: null, + onTouchEnded: null, + onTouchCancelled: null, + setSwallowTouches: function setSwallowTouches(needSwallow) { + this.swallowTouches = needSwallow; + }, + isSwallowTouches: function isSwallowTouches() { + return this.swallowTouches; + }, + clone: function clone() { + var eventListener = new TouchOneByOne(); + eventListener.onTouchBegan = this.onTouchBegan; + eventListener.onTouchMoved = this.onTouchMoved; + eventListener.onTouchEnded = this.onTouchEnded; + eventListener.onTouchCancelled = this.onTouchCancelled; + eventListener.swallowTouches = this.swallowTouches; + return eventListener; + }, + checkAvailable: function checkAvailable() { + if (!this.onTouchBegan) { + cc.logID(1801); + return false; + } + return true; + } + }); + var TouchAllAtOnce = function TouchAllAtOnce() { + cc.EventListener.call(this, cc.EventListener.TOUCH_ALL_AT_ONCE, ListenerID.TOUCH_ALL_AT_ONCE, null); + }; + js.extend(TouchAllAtOnce, cc.EventListener); + js.mixin(TouchAllAtOnce.prototype, { + constructor: TouchAllAtOnce, + onTouchesBegan: null, + onTouchesMoved: null, + onTouchesEnded: null, + onTouchesCancelled: null, + clone: function clone() { + var eventListener = new TouchAllAtOnce(); + eventListener.onTouchesBegan = this.onTouchesBegan; + eventListener.onTouchesMoved = this.onTouchesMoved; + eventListener.onTouchesEnded = this.onTouchesEnded; + eventListener.onTouchesCancelled = this.onTouchesCancelled; + return eventListener; + }, + checkAvailable: function checkAvailable() { + if (null === this.onTouchesBegan && null === this.onTouchesMoved && null === this.onTouchesEnded && null === this.onTouchesCancelled) { + cc.logID(1802); + return false; + } + return true; + } + }); + var Acceleration = function Acceleration(callback) { + this._onAccelerationEvent = callback; + cc.EventListener.call(this, cc.EventListener.ACCELERATION, ListenerID.ACCELERATION, this._callback); + }; + js.extend(Acceleration, cc.EventListener); + js.mixin(Acceleration.prototype, { + constructor: Acceleration, + _onAccelerationEvent: null, + _callback: function _callback(event) { + this._onAccelerationEvent(event.acc, event); + }, + checkAvailable: function checkAvailable() { + cc.assertID(this._onAccelerationEvent, 1803); + return true; + }, + clone: function clone() { + return new Acceleration(this._onAccelerationEvent); + } + }); + var Keyboard = function Keyboard() { + cc.EventListener.call(this, cc.EventListener.KEYBOARD, ListenerID.KEYBOARD, this._callback); + }; + js.extend(Keyboard, cc.EventListener); + js.mixin(Keyboard.prototype, { + constructor: Keyboard, + onKeyPressed: null, + onKeyReleased: null, + _callback: function _callback(event) { + event.isPressed ? this.onKeyPressed && this.onKeyPressed(event.keyCode, event) : this.onKeyReleased && this.onKeyReleased(event.keyCode, event); + }, + clone: function clone() { + var eventListener = new Keyboard(); + eventListener.onKeyPressed = this.onKeyPressed; + eventListener.onKeyReleased = this.onKeyReleased; + return eventListener; + }, + checkAvailable: function checkAvailable() { + if (null === this.onKeyPressed && null === this.onKeyReleased) { + cc.logID(1800); + return false; + } + return true; + } + }); + cc.EventListener.create = function(argObj) { + cc.assertID(argObj && argObj.event, 1900); + var listenerType = argObj.event; + delete argObj.event; + var listener = null; + if (listenerType === cc.EventListener.TOUCH_ONE_BY_ONE) listener = new TouchOneByOne(); else if (listenerType === cc.EventListener.TOUCH_ALL_AT_ONCE) listener = new TouchAllAtOnce(); else if (listenerType === cc.EventListener.MOUSE) listener = new Mouse(); else if (listenerType === cc.EventListener.CUSTOM) { + listener = new Custom(argObj.eventName, argObj.callback); + delete argObj.eventName; + delete argObj.callback; + } else if (listenerType === cc.EventListener.KEYBOARD) listener = new Keyboard(); else if (listenerType === cc.EventListener.ACCELERATION) { + listener = new Acceleration(argObj.callback); + delete argObj.callback; + } + for (var key in argObj) listener[key] = argObj[key]; + return listener; + }; + module.exports = cc.EventListener; + }), { + "../platform/js": 261 + } ], + 183: [ (function(require, module, exports) { + "use strict"; + var js = require("../platform/js"); + require("./CCEventListener"); + var ListenerID = cc.EventListener.ListenerID; + var _EventListenerVector = function _EventListenerVector() { + this._fixedListeners = []; + this._sceneGraphListeners = []; + this.gt0Index = 0; + }; + _EventListenerVector.prototype = { + constructor: _EventListenerVector, + size: function size() { + return this._fixedListeners.length + this._sceneGraphListeners.length; + }, + empty: function empty() { + return 0 === this._fixedListeners.length && 0 === this._sceneGraphListeners.length; + }, + push: function push(listener) { + 0 === listener._getFixedPriority() ? this._sceneGraphListeners.push(listener) : this._fixedListeners.push(listener); + }, + clearSceneGraphListeners: function clearSceneGraphListeners() { + this._sceneGraphListeners.length = 0; + }, + clearFixedListeners: function clearFixedListeners() { + this._fixedListeners.length = 0; + }, + clear: function clear() { + this._sceneGraphListeners.length = 0; + this._fixedListeners.length = 0; + }, + getFixedPriorityListeners: function getFixedPriorityListeners() { + return this._fixedListeners; + }, + getSceneGraphPriorityListeners: function getSceneGraphPriorityListeners() { + return this._sceneGraphListeners; + } + }; + var __getListenerID = function __getListenerID(event) { + var eventType = cc.Event, type = event.type; + if (type === eventType.ACCELERATION) return ListenerID.ACCELERATION; + if (type === eventType.KEYBOARD) return ListenerID.KEYBOARD; + if (type.startsWith(eventType.MOUSE)) return ListenerID.MOUSE; + type.startsWith(eventType.TOUCH) && cc.logID(2e3); + return ""; + }; + var eventManager = { + DIRTY_NONE: 0, + DIRTY_FIXED_PRIORITY: 1, + DIRTY_SCENE_GRAPH_PRIORITY: 2, + DIRTY_ALL: 3, + _listenersMap: {}, + _priorityDirtyFlagMap: {}, + _nodeListenersMap: {}, + _toAddedListeners: [], + _toRemovedListeners: [], + _dirtyListeners: {}, + _inDispatch: 0, + _isEnabled: false, + _currentTouch: null, + _currentTouchListener: null, + _internalCustomListenerIDs: [], + _setDirtyForNode: function _setDirtyForNode(node) { + var selListeners = this._nodeListenersMap[node._id]; + if (selListeners) for (var j = 0, len = selListeners.length; j < len; j++) { + var selListener = selListeners[j]; + var listenerID = selListener._getListenerID(); + null == this._dirtyListeners[listenerID] && (this._dirtyListeners[listenerID] = true); + } + if (node.childrenCount > 0) { + var children = node._children; + for (var i = 0, _len = children.length; i < _len; i++) this._setDirtyForNode(children[i]); + } + }, + pauseTarget: function pauseTarget(node, recursive) { + if (!(node instanceof cc._BaseNode)) { + cc.warnID(3506); + return; + } + var listeners = this._nodeListenersMap[node._id], i, len; + if (listeners) for (i = 0, len = listeners.length; i < len; i++) { + var listener = listeners[i]; + listener._setPaused(true); + listener._claimedTouches && listener._claimedTouches.includes(this._currentTouch) && this._clearCurTouch(); + } + if (true === recursive) { + var locChildren = node._children; + for (i = 0, len = locChildren ? locChildren.length : 0; i < len; i++) this.pauseTarget(locChildren[i], true); + } + }, + resumeTarget: function resumeTarget(node, recursive) { + if (!(node instanceof cc._BaseNode)) { + cc.warnID(3506); + return; + } + var listeners = this._nodeListenersMap[node._id], i, len; + if (listeners) for (i = 0, len = listeners.length; i < len; i++) listeners[i]._setPaused(false); + this._setDirtyForNode(node); + if (true === recursive) { + var locChildren = node._children; + for (i = 0, len = locChildren ? locChildren.length : 0; i < len; i++) this.resumeTarget(locChildren[i], true); + } + }, + _addListener: function _addListener(listener) { + 0 === this._inDispatch ? this._forceAddEventListener(listener) : this._toAddedListeners.push(listener); + }, + _forceAddEventListener: function _forceAddEventListener(listener) { + var listenerID = listener._getListenerID(); + var listeners = this._listenersMap[listenerID]; + if (!listeners) { + listeners = new _EventListenerVector(); + this._listenersMap[listenerID] = listeners; + } + listeners.push(listener); + if (0 === listener._getFixedPriority()) { + this._setDirty(listenerID, this.DIRTY_SCENE_GRAPH_PRIORITY); + var node = listener._getSceneGraphPriority(); + null === node && cc.logID(3507); + this._associateNodeAndEventListener(node, listener); + node.activeInHierarchy && this.resumeTarget(node); + } else this._setDirty(listenerID, this.DIRTY_FIXED_PRIORITY); + }, + _getListeners: function _getListeners(listenerID) { + return this._listenersMap[listenerID]; + }, + _updateDirtyFlagForSceneGraph: function _updateDirtyFlagForSceneGraph() { + var locDirtyListeners = this._dirtyListeners; + for (var selKey in locDirtyListeners) this._setDirty(selKey, this.DIRTY_SCENE_GRAPH_PRIORITY); + this._dirtyListeners = {}; + }, + _removeAllListenersInVector: function _removeAllListenersInVector(listenerVector) { + if (!listenerVector) return; + var selListener; + for (var i = listenerVector.length - 1; i >= 0; i--) { + selListener = listenerVector[i]; + selListener._setRegistered(false); + if (null != selListener._getSceneGraphPriority()) { + this._dissociateNodeAndEventListener(selListener._getSceneGraphPriority(), selListener); + selListener._setSceneGraphPriority(null); + } + 0 === this._inDispatch && cc.js.array.removeAt(listenerVector, i); + } + }, + _removeListenersForListenerID: function _removeListenersForListenerID(listenerID) { + var listeners = this._listenersMap[listenerID], i; + if (listeners) { + var fixedPriorityListeners = listeners.getFixedPriorityListeners(); + var sceneGraphPriorityListeners = listeners.getSceneGraphPriorityListeners(); + this._removeAllListenersInVector(sceneGraphPriorityListeners); + this._removeAllListenersInVector(fixedPriorityListeners); + delete this._priorityDirtyFlagMap[listenerID]; + if (!this._inDispatch) { + listeners.clear(); + delete this._listenersMap[listenerID]; + } + } + var locToAddedListeners = this._toAddedListeners, listener; + for (i = locToAddedListeners.length - 1; i >= 0; i--) { + listener = locToAddedListeners[i]; + listener && listener._getListenerID() === listenerID && cc.js.array.removeAt(locToAddedListeners, i); + } + }, + _sortEventListeners: function _sortEventListeners(listenerID) { + var dirtyFlag = this.DIRTY_NONE, locFlagMap = this._priorityDirtyFlagMap; + locFlagMap[listenerID] && (dirtyFlag = locFlagMap[listenerID]); + if (dirtyFlag !== this.DIRTY_NONE) { + locFlagMap[listenerID] = this.DIRTY_NONE; + dirtyFlag & this.DIRTY_FIXED_PRIORITY && this._sortListenersOfFixedPriority(listenerID); + if (dirtyFlag & this.DIRTY_SCENE_GRAPH_PRIORITY) { + var rootEntity = cc.director.getScene(); + rootEntity && this._sortListenersOfSceneGraphPriority(listenerID); + } + } + }, + _sortListenersOfSceneGraphPriority: function _sortListenersOfSceneGraphPriority(listenerID) { + var listeners = this._getListeners(listenerID); + if (!listeners) return; + var sceneGraphListener = listeners.getSceneGraphPriorityListeners(); + if (!sceneGraphListener || 0 === sceneGraphListener.length) return; + listeners.getSceneGraphPriorityListeners().sort(this._sortEventListenersOfSceneGraphPriorityDes); + }, + _sortEventListenersOfSceneGraphPriorityDes: function _sortEventListenersOfSceneGraphPriorityDes(l1, l2) { + var node1 = l1._getSceneGraphPriority(), node2 = l2._getSceneGraphPriority(); + if (!(l2 && node2 && node2._activeInHierarchy && null !== node2._parent)) return -1; + if (!l1 || !node1 || !node1._activeInHierarchy || null === node1._parent) return 1; + var p1 = node1, p2 = node2, ex = false; + while (p1._parent._id !== p2._parent._id) { + p1 = null === p1._parent._parent ? (ex = true) && node2 : p1._parent; + p2 = null === p2._parent._parent ? (ex = true) && node1 : p2._parent; + } + if (p1._id === p2._id) { + if (p1._id === node2._id) return -1; + if (p1._id === node1._id) return 1; + } + return ex ? p1._localZOrder - p2._localZOrder : p2._localZOrder - p1._localZOrder; + }, + _sortListenersOfFixedPriority: function _sortListenersOfFixedPriority(listenerID) { + var listeners = this._listenersMap[listenerID]; + if (!listeners) return; + var fixedListeners = listeners.getFixedPriorityListeners(); + if (!fixedListeners || 0 === fixedListeners.length) return; + fixedListeners.sort(this._sortListenersOfFixedPriorityAsc); + var index = 0; + for (var len = fixedListeners.length; index < len; ) { + if (fixedListeners[index]._getFixedPriority() >= 0) break; + ++index; + } + listeners.gt0Index = index; + }, + _sortListenersOfFixedPriorityAsc: function _sortListenersOfFixedPriorityAsc(l1, l2) { + return l1._getFixedPriority() - l2._getFixedPriority(); + }, + _onUpdateListeners: function _onUpdateListeners(listeners) { + var fixedPriorityListeners = listeners.getFixedPriorityListeners(); + var sceneGraphPriorityListeners = listeners.getSceneGraphPriorityListeners(); + var i, selListener, idx, toRemovedListeners = this._toRemovedListeners; + if (sceneGraphPriorityListeners) for (i = sceneGraphPriorityListeners.length - 1; i >= 0; i--) { + selListener = sceneGraphPriorityListeners[i]; + if (!selListener._isRegistered()) { + cc.js.array.removeAt(sceneGraphPriorityListeners, i); + idx = toRemovedListeners.indexOf(selListener); + -1 !== idx && toRemovedListeners.splice(idx, 1); + } + } + if (fixedPriorityListeners) for (i = fixedPriorityListeners.length - 1; i >= 0; i--) { + selListener = fixedPriorityListeners[i]; + if (!selListener._isRegistered()) { + cc.js.array.removeAt(fixedPriorityListeners, i); + idx = toRemovedListeners.indexOf(selListener); + -1 !== idx && toRemovedListeners.splice(idx, 1); + } + } + sceneGraphPriorityListeners && 0 === sceneGraphPriorityListeners.length && listeners.clearSceneGraphListeners(); + fixedPriorityListeners && 0 === fixedPriorityListeners.length && listeners.clearFixedListeners(); + }, + frameUpdateListeners: function frameUpdateListeners() { + var locListenersMap = this._listenersMap, locPriorityDirtyFlagMap = this._priorityDirtyFlagMap; + for (var selKey in locListenersMap) if (locListenersMap[selKey].empty()) { + delete locPriorityDirtyFlagMap[selKey]; + delete locListenersMap[selKey]; + } + var locToAddedListeners = this._toAddedListeners; + if (0 !== locToAddedListeners.length) { + for (var i = 0, len = locToAddedListeners.length; i < len; i++) this._forceAddEventListener(locToAddedListeners[i]); + locToAddedListeners.length = 0; + } + 0 !== this._toRemovedListeners.length && this._cleanToRemovedListeners(); + }, + _updateTouchListeners: function _updateTouchListeners(event) { + var locInDispatch = this._inDispatch; + cc.assertID(locInDispatch > 0, 3508); + if (locInDispatch > 1) return; + var listeners; + listeners = this._listenersMap[ListenerID.TOUCH_ONE_BY_ONE]; + listeners && this._onUpdateListeners(listeners); + listeners = this._listenersMap[ListenerID.TOUCH_ALL_AT_ONCE]; + listeners && this._onUpdateListeners(listeners); + cc.assertID(1 === locInDispatch, 3509); + var locToAddedListeners = this._toAddedListeners; + if (0 !== locToAddedListeners.length) { + for (var i = 0, len = locToAddedListeners.length; i < len; i++) this._forceAddEventListener(locToAddedListeners[i]); + this._toAddedListeners.length = 0; + } + 0 !== this._toRemovedListeners.length && this._cleanToRemovedListeners(); + }, + _cleanToRemovedListeners: function _cleanToRemovedListeners() { + var toRemovedListeners = this._toRemovedListeners; + for (var i = 0; i < toRemovedListeners.length; i++) { + var selListener = toRemovedListeners[i]; + var listeners = this._listenersMap[selListener._getListenerID()]; + if (!listeners) continue; + var idx, fixedPriorityListeners = listeners.getFixedPriorityListeners(), sceneGraphPriorityListeners = listeners.getSceneGraphPriorityListeners(); + if (sceneGraphPriorityListeners) { + idx = sceneGraphPriorityListeners.indexOf(selListener); + -1 !== idx && sceneGraphPriorityListeners.splice(idx, 1); + } + if (fixedPriorityListeners) { + idx = fixedPriorityListeners.indexOf(selListener); + -1 !== idx && fixedPriorityListeners.splice(idx, 1); + } + } + toRemovedListeners.length = 0; + }, + _onTouchEventCallback: function _onTouchEventCallback(listener, argsObj) { + if (!listener._isRegistered()) return false; + var event = argsObj.event, selTouch = event.currentTouch; + event.currentTarget = listener._node; + var isClaimed = false, removedIdx; + var getCode = event.getEventCode(), EventTouch = cc.Event.EventTouch; + if (getCode === EventTouch.BEGAN) { + if (!cc.macro.ENABLE_MULTI_TOUCH && eventManager._currentTouch) { + var node = eventManager._currentTouchListener._node; + if (node && node.activeInHierarchy) return false; + } + if (listener.onTouchBegan) { + isClaimed = listener.onTouchBegan(selTouch, event); + if (isClaimed && listener._registered) { + listener._claimedTouches.push(selTouch); + eventManager._currentTouchListener = listener; + eventManager._currentTouch = selTouch; + } + } + } else if (listener._claimedTouches.length > 0 && -1 !== (removedIdx = listener._claimedTouches.indexOf(selTouch))) { + isClaimed = true; + if (!cc.macro.ENABLE_MULTI_TOUCH && eventManager._currentTouch && eventManager._currentTouch !== selTouch) return false; + if (getCode === EventTouch.MOVED && listener.onTouchMoved) listener.onTouchMoved(selTouch, event); else if (getCode === EventTouch.ENDED) { + listener.onTouchEnded && listener.onTouchEnded(selTouch, event); + listener._registered && listener._claimedTouches.splice(removedIdx, 1); + eventManager._clearCurTouch(); + } else if (getCode === EventTouch.CANCELED) { + listener.onTouchCancelled && listener.onTouchCancelled(selTouch, event); + listener._registered && listener._claimedTouches.splice(removedIdx, 1); + eventManager._clearCurTouch(); + } + } + if (event.isStopped()) { + eventManager._updateTouchListeners(event); + return true; + } + if (isClaimed && listener.swallowTouches) { + argsObj.needsMutableSet && argsObj.touches.splice(selTouch, 1); + return true; + } + return false; + }, + _dispatchTouchEvent: function _dispatchTouchEvent(event) { + this._sortEventListeners(ListenerID.TOUCH_ONE_BY_ONE); + this._sortEventListeners(ListenerID.TOUCH_ALL_AT_ONCE); + var oneByOneListeners = this._getListeners(ListenerID.TOUCH_ONE_BY_ONE); + var allAtOnceListeners = this._getListeners(ListenerID.TOUCH_ALL_AT_ONCE); + if (null === oneByOneListeners && null === allAtOnceListeners) return; + var originalTouches = event.getTouches(), mutableTouches = cc.js.array.copy(originalTouches); + var oneByOneArgsObj = { + event: event, + needsMutableSet: oneByOneListeners && allAtOnceListeners, + touches: mutableTouches, + selTouch: null + }; + if (oneByOneListeners) for (var i = 0; i < originalTouches.length; i++) { + event.currentTouch = originalTouches[i]; + event._propagationStopped = event._propagationImmediateStopped = false; + this._dispatchEventToListeners(oneByOneListeners, this._onTouchEventCallback, oneByOneArgsObj); + } + if (allAtOnceListeners && mutableTouches.length > 0) { + this._dispatchEventToListeners(allAtOnceListeners, this._onTouchesEventCallback, { + event: event, + touches: mutableTouches + }); + if (event.isStopped()) return; + } + this._updateTouchListeners(event); + }, + _onTouchesEventCallback: function _onTouchesEventCallback(listener, callbackParams) { + if (!listener._registered) return false; + var EventTouch = cc.Event.EventTouch, event = callbackParams.event, touches = callbackParams.touches, getCode = event.getEventCode(); + event.currentTarget = listener._node; + getCode === EventTouch.BEGAN && listener.onTouchesBegan ? listener.onTouchesBegan(touches, event) : getCode === EventTouch.MOVED && listener.onTouchesMoved ? listener.onTouchesMoved(touches, event) : getCode === EventTouch.ENDED && listener.onTouchesEnded ? listener.onTouchesEnded(touches, event) : getCode === EventTouch.CANCELED && listener.onTouchesCancelled && listener.onTouchesCancelled(touches, event); + if (event.isStopped()) { + eventManager._updateTouchListeners(event); + return true; + } + return false; + }, + _associateNodeAndEventListener: function _associateNodeAndEventListener(node, listener) { + var listeners = this._nodeListenersMap[node._id]; + if (!listeners) { + listeners = []; + this._nodeListenersMap[node._id] = listeners; + } + listeners.push(listener); + }, + _dissociateNodeAndEventListener: function _dissociateNodeAndEventListener(node, listener) { + var listeners = this._nodeListenersMap[node._id]; + if (listeners) { + cc.js.array.remove(listeners, listener); + 0 === listeners.length && delete this._nodeListenersMap[node._id]; + } + }, + _dispatchEventToListeners: function _dispatchEventToListeners(listeners, onEvent, eventOrArgs) { + var shouldStopPropagation = false; + var fixedPriorityListeners = listeners.getFixedPriorityListeners(); + var sceneGraphPriorityListeners = listeners.getSceneGraphPriorityListeners(); + var i = 0, j, selListener; + if (fixedPriorityListeners && 0 !== fixedPriorityListeners.length) for (;i < listeners.gt0Index; ++i) { + selListener = fixedPriorityListeners[i]; + if (selListener.isEnabled() && !selListener._isPaused() && selListener._isRegistered() && onEvent(selListener, eventOrArgs)) { + shouldStopPropagation = true; + break; + } + } + if (sceneGraphPriorityListeners && !shouldStopPropagation) for (j = 0; j < sceneGraphPriorityListeners.length; j++) { + selListener = sceneGraphPriorityListeners[j]; + if (selListener.isEnabled() && !selListener._isPaused() && selListener._isRegistered() && onEvent(selListener, eventOrArgs)) { + shouldStopPropagation = true; + break; + } + } + if (fixedPriorityListeners && !shouldStopPropagation) for (;i < fixedPriorityListeners.length; ++i) { + selListener = fixedPriorityListeners[i]; + if (selListener.isEnabled() && !selListener._isPaused() && selListener._isRegistered() && onEvent(selListener, eventOrArgs)) { + shouldStopPropagation = true; + break; + } + } + }, + _setDirty: function _setDirty(listenerID, flag) { + var locDirtyFlagMap = this._priorityDirtyFlagMap; + null == locDirtyFlagMap[listenerID] ? locDirtyFlagMap[listenerID] = flag : locDirtyFlagMap[listenerID] = flag | locDirtyFlagMap[listenerID]; + }, + _sortNumberAsc: function _sortNumberAsc(a, b) { + return a - b; + }, + hasEventListener: function hasEventListener(listenerID) { + return !!this._getListeners(listenerID); + }, + addListener: function addListener(listener, nodeOrPriority) { + cc.assertID(listener && nodeOrPriority, 3503); + if (!(cc.js.isNumber(nodeOrPriority) || nodeOrPriority instanceof cc._BaseNode)) { + cc.warnID(3506); + return; + } + if (listener instanceof cc.EventListener) { + if (listener._isRegistered()) { + cc.logID(3505); + return; + } + } else { + cc.assertID(!cc.js.isNumber(nodeOrPriority), 3504); + listener = cc.EventListener.create(listener); + } + if (!listener.checkAvailable()) return; + if (cc.js.isNumber(nodeOrPriority)) { + if (0 === nodeOrPriority) { + cc.logID(3500); + return; + } + listener._setSceneGraphPriority(null); + listener._setFixedPriority(nodeOrPriority); + listener._setRegistered(true); + listener._setPaused(false); + this._addListener(listener); + } else { + listener._setSceneGraphPriority(nodeOrPriority); + listener._setFixedPriority(0); + listener._setRegistered(true); + this._addListener(listener); + } + return listener; + }, + addCustomListener: function addCustomListener(eventName, callback) { + var listener = new cc.EventListener.create({ + event: cc.EventListener.CUSTOM, + eventName: eventName, + callback: callback + }); + this.addListener(listener, 1); + return listener; + }, + removeListener: function removeListener(listener) { + if (null == listener) return; + var isFound, locListener = this._listenersMap; + for (var selKey in locListener) { + var listeners = locListener[selKey]; + var fixedPriorityListeners = listeners.getFixedPriorityListeners(), sceneGraphPriorityListeners = listeners.getSceneGraphPriorityListeners(); + isFound = this._removeListenerInVector(sceneGraphPriorityListeners, listener); + if (isFound) this._setDirty(listener._getListenerID(), this.DIRTY_SCENE_GRAPH_PRIORITY); else { + isFound = this._removeListenerInVector(fixedPriorityListeners, listener); + isFound && this._setDirty(listener._getListenerID(), this.DIRTY_FIXED_PRIORITY); + } + if (listeners.empty()) { + delete this._priorityDirtyFlagMap[listener._getListenerID()]; + delete locListener[selKey]; + } + if (isFound) break; + } + if (!isFound) { + var locToAddedListeners = this._toAddedListeners; + for (var i = locToAddedListeners.length - 1; i >= 0; i--) { + var selListener = locToAddedListeners[i]; + if (selListener === listener) { + cc.js.array.removeAt(locToAddedListeners, i); + selListener._setRegistered(false); + break; + } + } + } + this._currentTouchListener === listener && this._clearCurTouch(); + }, + _clearCurTouch: function _clearCurTouch() { + this._currentTouchListener = null; + this._currentTouch = null; + }, + _removeListenerInCallback: function _removeListenerInCallback(listeners, callback) { + if (null == listeners) return false; + for (var i = listeners.length - 1; i >= 0; i--) { + var selListener = listeners[i]; + if (selListener._onCustomEvent === callback || selListener._onEvent === callback) { + selListener._setRegistered(false); + if (null != selListener._getSceneGraphPriority()) { + this._dissociateNodeAndEventListener(selListener._getSceneGraphPriority(), selListener); + selListener._setSceneGraphPriority(null); + } + 0 === this._inDispatch ? cc.js.array.removeAt(listeners, i) : this._toRemovedListeners.push(selListener); + return true; + } + } + return false; + }, + _removeListenerInVector: function _removeListenerInVector(listeners, listener) { + if (null == listeners) return false; + for (var i = listeners.length - 1; i >= 0; i--) { + var selListener = listeners[i]; + if (selListener === listener) { + selListener._setRegistered(false); + if (null != selListener._getSceneGraphPriority()) { + this._dissociateNodeAndEventListener(selListener._getSceneGraphPriority(), selListener); + selListener._setSceneGraphPriority(null); + } + 0 === this._inDispatch ? cc.js.array.removeAt(listeners, i) : this._toRemovedListeners.push(selListener); + return true; + } + } + return false; + }, + removeListeners: function removeListeners(listenerType, recursive) { + var i, _t = this; + if (!(cc.js.isNumber(listenerType) || listenerType instanceof cc._BaseNode)) { + cc.warnID(3506); + return; + } + if (void 0 !== listenerType._id) { + var listeners = _t._nodeListenersMap[listenerType._id], i; + if (listeners) { + var listenersCopy = cc.js.array.copy(listeners); + for (i = 0; i < listenersCopy.length; i++) _t.removeListener(listenersCopy[i]); + delete _t._nodeListenersMap[listenerType._id]; + } + var locToAddedListeners = _t._toAddedListeners; + for (i = 0; i < locToAddedListeners.length; ) { + var listener = locToAddedListeners[i]; + if (listener._getSceneGraphPriority() === listenerType) { + listener._setSceneGraphPriority(null); + listener._setRegistered(false); + locToAddedListeners.splice(i, 1); + } else ++i; + } + if (true === recursive) { + var locChildren = listenerType.children, len; + for (i = 0, len = locChildren.length; i < len; i++) _t.removeListeners(locChildren[i], true); + } + } else listenerType === cc.EventListener.TOUCH_ONE_BY_ONE ? _t._removeListenersForListenerID(ListenerID.TOUCH_ONE_BY_ONE) : listenerType === cc.EventListener.TOUCH_ALL_AT_ONCE ? _t._removeListenersForListenerID(ListenerID.TOUCH_ALL_AT_ONCE) : listenerType === cc.EventListener.MOUSE ? _t._removeListenersForListenerID(ListenerID.MOUSE) : listenerType === cc.EventListener.ACCELERATION ? _t._removeListenersForListenerID(ListenerID.ACCELERATION) : listenerType === cc.EventListener.KEYBOARD ? _t._removeListenersForListenerID(ListenerID.KEYBOARD) : cc.logID(3501); + }, + removeCustomListeners: function removeCustomListeners(customEventName) { + this._removeListenersForListenerID(customEventName); + }, + removeAllListeners: function removeAllListeners() { + var locListeners = this._listenersMap, locInternalCustomEventIDs = this._internalCustomListenerIDs; + for (var selKey in locListeners) -1 === locInternalCustomEventIDs.indexOf(selKey) && this._removeListenersForListenerID(selKey); + }, + setPriority: function setPriority(listener, fixedPriority) { + if (null == listener) return; + var locListeners = this._listenersMap; + for (var selKey in locListeners) { + var selListeners = locListeners[selKey]; + var fixedPriorityListeners = selListeners.getFixedPriorityListeners(); + if (fixedPriorityListeners) { + var found = fixedPriorityListeners.indexOf(listener); + if (-1 !== found) { + null != listener._getSceneGraphPriority() && cc.logID(3502); + if (listener._getFixedPriority() !== fixedPriority) { + listener._setFixedPriority(fixedPriority); + this._setDirty(listener._getListenerID(), this.DIRTY_FIXED_PRIORITY); + } + return; + } + } + } + }, + setEnabled: function setEnabled(enabled) { + this._isEnabled = enabled; + }, + isEnabled: function isEnabled() { + return this._isEnabled; + }, + dispatchEvent: function dispatchEvent(event) { + if (!this._isEnabled) return; + this._updateDirtyFlagForSceneGraph(); + this._inDispatch++; + if (!event || !event.getType) { + cc.errorID(3511); + return; + } + if (event.getType().startsWith(cc.Event.TOUCH)) { + this._dispatchTouchEvent(event); + this._inDispatch--; + return; + } + var listenerID = __getListenerID(event); + this._sortEventListeners(listenerID); + var selListeners = this._listenersMap[listenerID]; + if (null != selListeners) { + this._dispatchEventToListeners(selListeners, this._onListenerCallback, event); + this._onUpdateListeners(selListeners); + } + this._inDispatch--; + }, + _onListenerCallback: function _onListenerCallback(listener, event) { + event.currentTarget = listener._target; + listener._onEvent(event); + return event.isStopped(); + }, + dispatchCustomEvent: function dispatchCustomEvent(eventName, optionalUserData) { + var ev = new cc.Event.EventCustom(eventName); + ev.setUserData(optionalUserData); + this.dispatchEvent(ev); + } + }; + js.get(cc, "eventManager", (function() { + cc.errorID(1405, "cc.eventManager", "cc.EventTarget or cc.systemEvent"); + return eventManager; + })); + module.exports = cc.internal.eventManager = eventManager; + }), { + "../platform/js": 261, + "./CCEventListener": 182 + } ], + 184: [ (function(require, module, exports) { + "use strict"; + cc.Touch = function(x, y, id) { + this._lastModified = 0; + this.setTouchInfo(id, x, y); + }; + cc.Touch.prototype = { + constructor: cc.Touch, + getLocation: function getLocation() { + return cc.v2(this._point.x, this._point.y); + }, + getLocationX: function getLocationX() { + return this._point.x; + }, + getLocationY: function getLocationY() { + return this._point.y; + }, + getPreviousLocation: function getPreviousLocation() { + return cc.v2(this._prevPoint.x, this._prevPoint.y); + }, + getStartLocation: function getStartLocation() { + return cc.v2(this._startPoint.x, this._startPoint.y); + }, + getDelta: function getDelta() { + return this._point.sub(this._prevPoint); + }, + getLocationInView: function getLocationInView() { + return cc.v2(this._point.x, cc.view._designResolutionSize.height - this._point.y); + }, + getPreviousLocationInView: function getPreviousLocationInView() { + return cc.v2(this._prevPoint.x, cc.view._designResolutionSize.height - this._prevPoint.y); + }, + getStartLocationInView: function getStartLocationInView() { + return cc.v2(this._startPoint.x, cc.view._designResolutionSize.height - this._startPoint.y); + }, + getID: function getID() { + return this._id; + }, + setTouchInfo: function setTouchInfo(id, x, y) { + this._prevPoint = this._point; + this._point = cc.v2(x || 0, y || 0); + this._id = id; + if (!this._startPointCaptured) { + this._startPoint = cc.v2(this._point); + cc.view._convertPointWithScale(this._startPoint); + this._startPointCaptured = true; + } + }, + _setPoint: function _setPoint(x, y) { + if (void 0 === y) { + this._point.x = x.x; + this._point.y = x.y; + } else { + this._point.x = x; + this._point.y = y; + } + }, + _setPrevPoint: function _setPrevPoint(x, y) { + this._prevPoint = void 0 === y ? cc.v2(x.x, x.y) : cc.v2(x || 0, y || 0); + } + }; + }), {} ], + 185: [ (function(require, module, exports) { + "use strict"; + require("./CCEvent"); + require("./CCTouch"); + require("./CCEventListener"); + var eventManager = require("./CCEventManager"); + module.exports = eventManager; + false; + }), { + "./CCEvent": 181, + "./CCEventListener": 182, + "./CCEventManager": 183, + "./CCTouch": 184 + } ], + 186: [ (function(require, module, exports) { + "use strict"; + var js = cc.js; + var CallbacksInvoker = require("../platform/callbacks-invoker"); + function EventListeners() { + CallbacksInvoker.call(this); + } + js.extend(EventListeners, CallbacksInvoker); + EventListeners.prototype.emit = function(event, captureListeners) { + var key = event.type; + var list = this._callbackTable[key]; + if (list) { + var rootInvoker = !list.isInvoking; + list.isInvoking = true; + var infos = list.callbackInfos; + for (var i = 0, len = infos.length; i < len; ++i) { + var info = infos[i]; + if (info && info.callback) { + info.callback.call(info.target, event, captureListeners); + if (event._propagationImmediateStopped) break; + } + } + if (rootInvoker) { + list.isInvoking = false; + list.containCanceled && list.purgeCanceled(); + } + } + }; + module.exports = EventListeners; + false; + }), { + "../platform/callbacks-invoker": 253 + } ], + 187: [ (function(require, module, exports) { + "use strict"; + var js = require("../platform/js"); + var CallbacksInvoker = require("../platform/callbacks-invoker"); + var fastRemove = js.array.fastRemove; + function EventTarget() { + CallbacksInvoker.call(this); + } + js.extend(EventTarget, CallbacksInvoker); + var proto = EventTarget.prototype; + proto.__on = proto.on; + proto.on = function(type, callback, target, once) { + if (!callback) { + cc.errorID(6800); + return; + } + if (!this.hasEventListener(type, callback, target)) { + this.__on(type, callback, target, once); + target && target.__eventTargets && target.__eventTargets.push(this); + } + return callback; + }; + proto.__off = proto.off; + proto.off = function(type, callback, target) { + if (callback) { + this.__off(type, callback, target); + target && target.__eventTargets && fastRemove(target.__eventTargets, this); + } else { + var list = this._callbackTable[type]; + if (!list) return; + var infos = list.callbackInfos; + for (var i = 0; i < infos.length; ++i) { + var _target = infos[i] && infos[i].target; + _target && _target.__eventTargets && fastRemove(_target.__eventTargets, this); + } + this.removeAll(type); + } + }; + proto.targetOff = function(target) { + this.removeAll(target); + target && target.__eventTargets && fastRemove(target.__eventTargets, this); + }; + proto.once = function(type, callback, target) { + this.on(type, callback, target, true); + }; + proto.dispatchEvent = function(event) { + this.emit(event.type, event); + }; + proto.clear = function() { + for (var key in this._callbackTable) { + var list = this._callbackTable[key]; + var infos = list.callbackInfos; + for (var i = infos.length - 1; i >= 0; i--) { + var info = infos[i]; + info && this.off(key, info.callback, info.target); + } + } + }; + cc.EventTarget = module.exports = EventTarget; + }), { + "../platform/callbacks-invoker": 253, + "../platform/js": 261 + } ], + 188: [ (function(require, module, exports) { + "use strict"; + var js = require("../platform/js"); + cc.Event = function(type, bubbles) { + this.type = type; + this.bubbles = !!bubbles; + this.target = null; + this.currentTarget = null; + this.eventPhase = 0; + this._propagationStopped = false; + this._propagationImmediateStopped = false; + }; + cc.Event.prototype = { + constructor: cc.Event, + unuse: function unuse() { + this.type = cc.Event.NO_TYPE; + this.target = null; + this.currentTarget = null; + this.eventPhase = cc.Event.NONE; + this._propagationStopped = false; + this._propagationImmediateStopped = false; + }, + reuse: function reuse(type, bubbles) { + this.type = type; + this.bubbles = bubbles || false; + }, + stopPropagation: function stopPropagation() { + this._propagationStopped = true; + }, + stopPropagationImmediate: function stopPropagationImmediate() { + this._propagationImmediateStopped = true; + }, + isStopped: function isStopped() { + return this._propagationStopped || this._propagationImmediateStopped; + }, + getCurrentTarget: function getCurrentTarget() { + return this.currentTarget; + }, + getType: function getType() { + return this.type; + } + }; + cc.Event.NO_TYPE = "no_type"; + cc.Event.TOUCH = "touch"; + cc.Event.MOUSE = "mouse"; + cc.Event.KEYBOARD = "keyboard"; + cc.Event.ACCELERATION = "acceleration"; + cc.Event.NONE = 0; + cc.Event.CAPTURING_PHASE = 1; + cc.Event.AT_TARGET = 2; + cc.Event.BUBBLING_PHASE = 3; + var EventCustom = function EventCustom(type, bubbles) { + cc.Event.call(this, type, bubbles); + this.detail = null; + }; + js.extend(EventCustom, cc.Event); + EventCustom.prototype.reset = EventCustom; + EventCustom.prototype.setUserData = function(data) { + this.detail = data; + }; + EventCustom.prototype.getUserData = function() { + return this.detail; + }; + EventCustom.prototype.getEventName = cc.Event.prototype.getType; + var MAX_POOL_SIZE = 10; + var _eventPool = new js.Pool(MAX_POOL_SIZE); + EventCustom.put = function(event) { + _eventPool.put(event); + }; + EventCustom.get = function(type, bubbles) { + var event = _eventPool._get(); + event ? event.reset(type, bubbles) : event = new EventCustom(type, bubbles); + return event; + }; + cc.Event.EventCustom = EventCustom; + module.exports = cc.Event; + }), { + "../platform/js": 261 + } ], + 189: [ (function(require, module, exports) { + "use strict"; + require("./event"); + require("./event-listeners"); + require("./event-target"); + require("./system-event"); + }), { + "./event": 188, + "./event-listeners": 186, + "./event-target": 187, + "./system-event": 190 + } ], + 190: [ (function(require, module, exports) { + "use strict"; + var EventTarget = require("../event/event-target"); + var eventManager = require("../event-manager"); + var inputManger = require("../platform/CCInputManager"); + var EventType = cc.Enum({ + KEY_DOWN: "keydown", + KEY_UP: "keyup", + DEVICEMOTION: "devicemotion" + }); + var keyboardListener = null; + var accelerationListener = null; + var SystemEvent = cc.Class({ + name: "SystemEvent", + extends: EventTarget, + statics: { + EventType: EventType + }, + setAccelerometerEnabled: function setAccelerometerEnabled(isEnable) { + false; + isEnable && window.DeviceMotionEvent && "function" === typeof DeviceMotionEvent.requestPermission ? DeviceMotionEvent.requestPermission().then((function(response) { + console.log("Device Motion Event request permission: " + response); + inputManger.setAccelerometerEnabled("granted" === response); + })) : inputManger.setAccelerometerEnabled(isEnable); + }, + setAccelerometerInterval: function setAccelerometerInterval(interval) { + false; + inputManger.setAccelerometerInterval(interval); + }, + on: function on(type, callback, target, once) { + false; + this._super(type, callback, target, once); + if (type === EventType.KEY_DOWN || type === EventType.KEY_UP) { + keyboardListener || (keyboardListener = cc.EventListener.create({ + event: cc.EventListener.KEYBOARD, + onKeyPressed: function onKeyPressed(keyCode, event) { + event.type = EventType.KEY_DOWN; + cc.systemEvent.dispatchEvent(event); + }, + onKeyReleased: function onKeyReleased(keyCode, event) { + event.type = EventType.KEY_UP; + cc.systemEvent.dispatchEvent(event); + } + })); + eventManager.hasEventListener(cc.EventListener.ListenerID.KEYBOARD) || eventManager.addListener(keyboardListener, 1); + } + if (type === EventType.DEVICEMOTION) { + accelerationListener || (accelerationListener = cc.EventListener.create({ + event: cc.EventListener.ACCELERATION, + callback: function callback(acc, event) { + event.type = EventType.DEVICEMOTION; + cc.systemEvent.dispatchEvent(event); + } + })); + eventManager.hasEventListener(cc.EventListener.ListenerID.ACCELERATION) || eventManager.addListener(accelerationListener, 1); + } + }, + off: function off(type, callback, target) { + false; + this._super(type, callback, target); + if (keyboardListener && (type === EventType.KEY_DOWN || type === EventType.KEY_UP)) { + var hasKeyDownEventListener = this.hasEventListener(EventType.KEY_DOWN); + var hasKeyUpEventListener = this.hasEventListener(EventType.KEY_UP); + hasKeyDownEventListener || hasKeyUpEventListener || eventManager.removeListener(keyboardListener); + } + accelerationListener && type === EventType.DEVICEMOTION && eventManager.removeListener(accelerationListener); + } + }); + cc.SystemEvent = module.exports = SystemEvent; + cc.systemEvent = new cc.SystemEvent(); + }), { + "../event-manager": 185, + "../event/event-target": 187, + "../platform/CCInputManager": 244 + } ], + 191: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _vec = _interopRequireDefault(require("../value-types/vec3")); + var _mat = _interopRequireDefault(require("../value-types/mat3")); + var _enums = _interopRequireDefault(require("./enums")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + var _v3_tmp = new _vec["default"](); + var _v3_tmp2 = new _vec["default"](); + var _m3_tmp = new _mat["default"](); + var transform_extent_m4 = function transform_extent_m4(out, extent, m4) { + var _m3_tmpm = _m3_tmp.m, m4m = m4.m; + _m3_tmpm[0] = Math.abs(m4m[0]); + _m3_tmpm[1] = Math.abs(m4m[1]); + _m3_tmpm[2] = Math.abs(m4m[2]); + _m3_tmpm[3] = Math.abs(m4m[4]); + _m3_tmpm[4] = Math.abs(m4m[5]); + _m3_tmpm[5] = Math.abs(m4m[6]); + _m3_tmpm[6] = Math.abs(m4m[8]); + _m3_tmpm[7] = Math.abs(m4m[9]); + _m3_tmpm[8] = Math.abs(m4m[10]); + _vec["default"].transformMat3(out, extent, _m3_tmp); + }; + var aabb = (function() { + aabb.create = function create(px, py, pz, w, h, l) { + return new aabb(px, py, pz, w, h, l); + }; + aabb.clone = function clone(a) { + return new aabb(a.center.x, a.center.y, a.center.z, a.halfExtents.x, a.halfExtents.y, a.halfExtents.z); + }; + aabb.copy = function copy(out, a) { + _vec["default"].copy(out.center, a.center); + _vec["default"].copy(out.halfExtents, a.halfExtents); + return out; + }; + aabb.fromPoints = function fromPoints(out, minPos, maxPos) { + _vec["default"].scale(out.center, _vec["default"].add(_v3_tmp, minPos, maxPos), .5); + _vec["default"].scale(out.halfExtents, _vec["default"].sub(_v3_tmp2, maxPos, minPos), .5); + return out; + }; + aabb.set = function set(out, px, py, pz, w, h, l) { + _vec["default"].set(out.center, px, py, pz); + _vec["default"].set(out.halfExtents, w, h, l); + return out; + }; + function aabb(px, py, pz, w, h, l) { + this.center = void 0; + this.halfExtents = void 0; + this._type = void 0; + this._type = _enums["default"].SHAPE_AABB; + this.center = new _vec["default"](px, py, pz); + this.halfExtents = new _vec["default"](w, h, l); + } + var _proto = aabb.prototype; + _proto.getBoundary = function getBoundary(minPos, maxPos) { + _vec["default"].sub(minPos, this.center, this.halfExtents); + _vec["default"].add(maxPos, this.center, this.halfExtents); + }; + _proto.transform = function transform(m, pos, rot, scale, out) { + out || (out = this); + _vec["default"].transformMat4(out.center, this.center, m); + transform_extent_m4(out.halfExtents, this.halfExtents, m); + }; + return aabb; + })(); + exports["default"] = aabb; + module.exports = exports["default"]; + }), { + "../value-types/mat3": 341, + "../value-types/vec3": 350, + "./enums": 193 + } ], + 192: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports.point_plane = point_plane; + exports.pt_point_aabb = pt_point_aabb; + exports.pt_point_obb = pt_point_obb; + exports.pt_point_plane = pt_point_plane; + var _valueTypes = require("../value-types"); + var X = new _valueTypes.Vec3(); + var Y = new _valueTypes.Vec3(); + var Z = new _valueTypes.Vec3(); + var d = new _valueTypes.Vec3(); + var min = new _valueTypes.Vec3(); + var max = new _valueTypes.Vec3(); + var u = new Array(3); + var e = new Array(3); + function point_plane(point, plane_) { + return _valueTypes.Vec3.dot(plane_.n, point) - plane_.d; + } + function pt_point_plane(out, point, plane_) { + var t = point_plane(point, plane_); + return _valueTypes.Vec3.subtract(out, point, _valueTypes.Vec3.multiplyScalar(out, plane_.n, t)); + } + function pt_point_aabb(out, point, aabb_) { + _valueTypes.Vec3.copy(out, point); + _valueTypes.Vec3.subtract(min, aabb_.center, aabb_.halfExtents); + _valueTypes.Vec3.add(max, aabb_.center, aabb_.halfExtents); + out.x = out.x < min.x ? min.x : out.x; + out.y = out.y < min.x ? min.y : out.y; + out.z = out.z < min.x ? min.z : out.z; + out.x = out.x > max.x ? max.x : out.x; + out.y = out.y > max.x ? max.y : out.y; + out.z = out.z > max.x ? max.z : out.z; + return out; + } + function pt_point_obb(out, point, obb_) { + var obbm = obb_.orientation.m; + _valueTypes.Vec3.set(X, obbm[0], obbm[1], obbm[2]); + _valueTypes.Vec3.set(Y, obbm[3], obbm[4], obbm[5]); + _valueTypes.Vec3.set(Z, obbm[6], obbm[7], obbm[8]); + u[0] = X; + u[1] = Y; + u[2] = Z; + e[0] = obb_.halfExtents.x; + e[1] = obb_.halfExtents.y; + e[2] = obb_.halfExtents.z; + _valueTypes.Vec3.subtract(d, point, obb_.center); + _valueTypes.Vec3.set(out, obb_.center.x, obb_.center.y, obb_.center.z); + for (var i = 0; i < 3; i++) { + var dist = _valueTypes.Vec3.dot(d, u[i]); + dist > e[i] && (dist = e[i]); + dist < -e[i] && (dist = -e[i]); + out.x += dist * u[i].x; + out.y += dist * u[i].y; + out.z += dist * u[i].z; + } + return out; + } + }), { + "../value-types": 340 + } ], + 193: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _default = { + SHAPE_RAY: 1, + SHAPE_LINE: 2, + SHAPE_SPHERE: 4, + SHAPE_AABB: 8, + SHAPE_OBB: 16, + SHAPE_PLANE: 32, + SHAPE_TRIANGLE: 64, + SHAPE_FRUSTUM: 128, + SHAPE_FRUSTUM_ACCURATE: 256 + }; + exports["default"] = _default; + module.exports = exports["default"]; + }), {} ], + 194: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _valueTypes = require("../value-types"); + var _enums = _interopRequireDefault(require("./enums")); + var _plane = _interopRequireDefault(require("./plane")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + "value" in descriptor && (descriptor.writable = true); + Object.defineProperty(target, descriptor.key, descriptor); + } + } + function _createClass(Constructor, protoProps, staticProps) { + protoProps && _defineProperties(Constructor.prototype, protoProps); + staticProps && _defineProperties(Constructor, staticProps); + return Constructor; + } + var _v = new Array(8); + _v[0] = new _valueTypes.Vec3(1, 1, 1); + _v[1] = new _valueTypes.Vec3(-1, 1, 1); + _v[2] = new _valueTypes.Vec3(-1, -1, 1); + _v[3] = new _valueTypes.Vec3(1, -1, 1); + _v[4] = new _valueTypes.Vec3(1, 1, -1); + _v[5] = new _valueTypes.Vec3(-1, 1, -1); + _v[6] = new _valueTypes.Vec3(-1, -1, -1); + _v[7] = new _valueTypes.Vec3(1, -1, -1); + var frustum = (function() { + frustum.create = function create() { + return new frustum(); + }; + frustum.clone = function clone(f) { + return frustum.copy(new frustum(), f); + }; + frustum.copy = function copy(out, f) { + out._type = f._type; + for (var i = 0; i < 6; ++i) _plane["default"].copy(out.planes[i], f.planes[i]); + for (var _i = 0; _i < 8; ++_i) _valueTypes.Vec3.copy(out.vertices[_i], f.vertices[_i]); + return out; + }; + function frustum() { + this.planes = void 0; + this.vertices = void 0; + this._type = void 0; + this._type = _enums["default"].SHAPE_FRUSTUM; + this.planes = new Array(6); + for (var i = 0; i < 6; ++i) this.planes[i] = _plane["default"].create(0, 0, 0, 0); + this.vertices = new Array(8); + for (var _i2 = 0; _i2 < 8; ++_i2) this.vertices[_i2] = new _valueTypes.Vec3(); + } + var _proto = frustum.prototype; + _proto.update = function update(m, inv) { + var mm = m.m; + _valueTypes.Vec3.set(this.planes[0].n, mm[3] + mm[0], mm[7] + mm[4], mm[11] + mm[8]); + this.planes[0].d = -(mm[15] + mm[12]); + _valueTypes.Vec3.set(this.planes[1].n, mm[3] - mm[0], mm[7] - mm[4], mm[11] - mm[8]); + this.planes[1].d = -(mm[15] - mm[12]); + _valueTypes.Vec3.set(this.planes[2].n, mm[3] + mm[1], mm[7] + mm[5], mm[11] + mm[9]); + this.planes[2].d = -(mm[15] + mm[13]); + _valueTypes.Vec3.set(this.planes[3].n, mm[3] - mm[1], mm[7] - mm[5], mm[11] - mm[9]); + this.planes[3].d = -(mm[15] - mm[13]); + _valueTypes.Vec3.set(this.planes[4].n, mm[3] + mm[2], mm[7] + mm[6], mm[11] + mm[10]); + this.planes[4].d = -(mm[15] + mm[14]); + _valueTypes.Vec3.set(this.planes[5].n, mm[3] - mm[2], mm[7] - mm[6], mm[11] - mm[10]); + this.planes[5].d = -(mm[15] - mm[14]); + if (this._type !== _enums["default"].SHAPE_FRUSTUM_ACCURATE) return; + for (var i = 0; i < 6; i++) { + var pl = this.planes[i]; + var invDist = 1 / pl.n.length(); + _valueTypes.Vec3.multiplyScalar(pl.n, pl.n, invDist); + pl.d *= invDist; + } + for (var _i3 = 0; _i3 < 8; _i3++) _valueTypes.Vec3.transformMat4(this.vertices[_i3], _v[_i3], inv); + }; + _proto.transform = function transform(mat) { + if (this._type !== _enums["default"].SHAPE_FRUSTUM_ACCURATE) return; + for (var i = 0; i < 8; i++) _valueTypes.Vec3.transformMat4(this.vertices[i], this.vertices[i], mat); + _plane["default"].fromPoints(this.planes[0], this.vertices[1], this.vertices[5], this.vertices[6]); + _plane["default"].fromPoints(this.planes[1], this.vertices[3], this.vertices[7], this.vertices[4]); + _plane["default"].fromPoints(this.planes[2], this.vertices[6], this.vertices[7], this.vertices[3]); + _plane["default"].fromPoints(this.planes[3], this.vertices[0], this.vertices[4], this.vertices[5]); + _plane["default"].fromPoints(this.planes[4], this.vertices[2], this.vertices[3], this.vertices[0]); + _plane["default"].fromPoints(this.planes[0], this.vertices[7], this.vertices[6], this.vertices[5]); + }; + _createClass(frustum, [ { + key: "accurate", + set: function set(b) { + this._type = b ? _enums["default"].SHAPE_FRUSTUM_ACCURATE : _enums["default"].SHAPE_FRUSTUM; + } + } ]); + return frustum; + })(); + exports["default"] = frustum; + frustum.createOrtho = (function() { + var _temp_v3 = new _valueTypes.Vec3(); + return function(out, width, height, near, far, transform) { + var halfWidth = width / 2; + var halfHeight = height / 2; + _valueTypes.Vec3.set(_temp_v3, halfWidth, halfHeight, near); + _valueTypes.Vec3.transformMat4(out.vertices[0], _temp_v3, transform); + _valueTypes.Vec3.set(_temp_v3, -halfWidth, halfHeight, near); + _valueTypes.Vec3.transformMat4(out.vertices[1], _temp_v3, transform); + _valueTypes.Vec3.set(_temp_v3, -halfWidth, -halfHeight, near); + _valueTypes.Vec3.transformMat4(out.vertices[2], _temp_v3, transform); + _valueTypes.Vec3.set(_temp_v3, halfWidth, -halfHeight, near); + _valueTypes.Vec3.transformMat4(out.vertices[3], _temp_v3, transform); + _valueTypes.Vec3.set(_temp_v3, halfWidth, halfHeight, far); + _valueTypes.Vec3.transformMat4(out.vertices[4], _temp_v3, transform); + _valueTypes.Vec3.set(_temp_v3, -halfWidth, halfHeight, far); + _valueTypes.Vec3.transformMat4(out.vertices[5], _temp_v3, transform); + _valueTypes.Vec3.set(_temp_v3, -halfWidth, -halfHeight, far); + _valueTypes.Vec3.transformMat4(out.vertices[6], _temp_v3, transform); + _valueTypes.Vec3.set(_temp_v3, halfWidth, -halfHeight, far); + _valueTypes.Vec3.transformMat4(out.vertices[7], _temp_v3, transform); + _plane["default"].fromPoints(out.planes[0], out.vertices[1], out.vertices[6], out.vertices[5]); + _plane["default"].fromPoints(out.planes[1], out.vertices[3], out.vertices[4], out.vertices[7]); + _plane["default"].fromPoints(out.planes[2], out.vertices[6], out.vertices[3], out.vertices[7]); + _plane["default"].fromPoints(out.planes[3], out.vertices[0], out.vertices[5], out.vertices[4]); + _plane["default"].fromPoints(out.planes[4], out.vertices[2], out.vertices[0], out.vertices[3]); + _plane["default"].fromPoints(out.planes[0], out.vertices[7], out.vertices[5], out.vertices[6]); + }; + })(); + module.exports = exports["default"]; + }), { + "../value-types": 340, + "./enums": 193, + "./plane": 199 + } ], + 195: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + var _exportNames = { + enums: true, + Triangle: true, + Aabb: true, + Ray: true, + intersect: true, + Sphere: true, + Obb: true, + Frustum: true, + Line: true, + Plane: true + }; + exports.intersect = exports.enums = exports.Triangle = exports.Sphere = exports.Ray = exports.Plane = exports.Obb = exports.Line = exports.Frustum = exports.Aabb = void 0; + var _enums = _interopRequireDefault(require("./enums")); + exports.enums = _enums["default"]; + var _triangle = _interopRequireDefault(require("./triangle")); + exports.Triangle = _triangle["default"]; + var _aabb = _interopRequireDefault(require("./aabb")); + exports.Aabb = _aabb["default"]; + var _ray = _interopRequireDefault(require("./ray")); + exports.Ray = _ray["default"]; + var _intersect = _interopRequireDefault(require("./intersect")); + exports.intersect = _intersect["default"]; + var _sphere = _interopRequireDefault(require("./sphere")); + exports.Sphere = _sphere["default"]; + var _obb = _interopRequireDefault(require("./obb")); + exports.Obb = _obb["default"]; + var _frustum = _interopRequireDefault(require("./frustum")); + exports.Frustum = _frustum["default"]; + var _line = _interopRequireDefault(require("./line")); + exports.Line = _line["default"]; + var _plane = _interopRequireDefault(require("./plane")); + exports.Plane = _plane["default"]; + var _distance = require("./distance"); + Object.keys(_distance).forEach((function(key) { + if ("default" === key || "__esModule" === key) return; + if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; + if (key in exports && exports[key] === _distance[key]) return; + exports[key] = _distance[key]; + })); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + cc.geomUtils = module.exports; + }), { + "./aabb": 191, + "./distance": 192, + "./enums": 193, + "./frustum": 194, + "./intersect": 196, + "./line": 197, + "./obb": 198, + "./plane": 199, + "./ray": 200, + "./sphere": 201, + "./triangle": 202 + } ], + 196: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _gfx = _interopRequireDefault(require("../../renderer/gfx")); + var _recyclePool = _interopRequireDefault(require("../../renderer/memop/recycle-pool")); + var _valueTypes = require("../value-types"); + var _aabb = _interopRequireDefault(require("./aabb")); + var distance = _interopRequireWildcard(require("./distance")); + var _enums = _interopRequireDefault(require("./enums")); + var _ray = _interopRequireDefault(require("./ray")); + var _triangle = _interopRequireDefault(require("./triangle")); + function _getRequireWildcardCache(nodeInterop) { + if ("function" !== typeof WeakMap) return null; + var cacheBabelInterop = new WeakMap(); + var cacheNodeInterop = new WeakMap(); + return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { + return nodeInterop ? cacheNodeInterop : cacheBabelInterop; + })(nodeInterop); + } + function _interopRequireWildcard(obj, nodeInterop) { + if (!nodeInterop && obj && obj.__esModule) return obj; + if (null === obj || "object" !== typeof obj && "function" !== typeof obj) return { + default: obj + }; + var cache = _getRequireWildcardCache(nodeInterop); + if (cache && cache.has(obj)) return cache.get(obj); + var newObj = {}; + var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; + for (var key in obj) if ("default" !== key && Object.prototype.hasOwnProperty.call(obj, key)) { + var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; + desc && (desc.get || desc.set) ? Object.defineProperty(newObj, key, desc) : newObj[key] = obj[key]; + } + newObj["default"] = obj; + cache && cache.set(obj, newObj); + return newObj; + } + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + var ray_mesh = (function() { + var tri = _triangle["default"].create(); + var minDist = Infinity; + function getVec3(out, data, idx, stride) { + _valueTypes.Vec3.set(out, data[idx * stride], data[idx * stride + 1], data[idx * stride + 2]); + } + return function(ray, mesh) { + minDist = Infinity; + var subMeshes = mesh._subMeshes; + for (var i = 0; i < subMeshes.length; i++) { + if (subMeshes[i]._primitiveType !== _gfx["default"].PT_TRIANGLES) continue; + var subData = mesh._subDatas[i] || mesh._subDatas[0]; + var posData = mesh._getAttrMeshData(i, _gfx["default"].ATTR_POSITION); + var iData = subData.getIData(Uint16Array); + var format = subData.vfm; + var fmt = format.element(_gfx["default"].ATTR_POSITION); + var num = fmt.num; + for (var _i = 0; _i < iData.length; _i += 3) { + getVec3(tri.a, posData, iData[_i], num); + getVec3(tri.b, posData, iData[_i + 1], num); + getVec3(tri.c, posData, iData[_i + 2], num); + var dist = ray_triangle(ray, tri); + dist > 0 && dist < minDist && (minDist = dist); + } + } + return minDist; + }; + })(); + var rayMesh = ray_mesh; + var ray_cast = (function() { + function traversal(node, cb) { + var children = node.children; + for (var i = children.length - 1; i >= 0; i--) { + var child = children[i]; + traversal(child, cb); + } + cb(node); + } + function cmp(a, b) { + return a.distance - b.distance; + } + function transformMat4Normal(out, a, m) { + var mm = m.m; + var x = a.x, y = a.y, z = a.z, rhw = mm[3] * x + mm[7] * y + mm[11] * z; + rhw = rhw ? 1 / rhw : 1; + out.x = (mm[0] * x + mm[4] * y + mm[8] * z) * rhw; + out.y = (mm[1] * x + mm[5] * y + mm[9] * z) * rhw; + out.z = (mm[2] * x + mm[6] * y + mm[10] * z) * rhw; + return out; + } + var resultsPool = new _recyclePool["default"](function() { + return { + distance: 0, + node: null + }; + }, 1); + var results = []; + var nodeAabb = _aabb["default"].create(); + var minPos = new _valueTypes.Vec3(); + var maxPos = new _valueTypes.Vec3(); + var modelRay = new _ray["default"](); + var m4_1 = cc.mat4(); + var m4_2 = cc.mat4(); + var d = new _valueTypes.Vec3(); + function distanceValid(distance) { + return distance > 0 && distance < Infinity; + } + return function(root, worldRay, handler, filter) { + resultsPool.reset(); + results.length = 0; + root = root || cc.director.getScene(); + traversal(root, (function(node) { + if (filter && !filter(node)) return; + _valueTypes.Mat4.invert(m4_2, node.getWorldMatrix(m4_1)); + _valueTypes.Vec3.transformMat4(modelRay.o, worldRay.o, m4_2); + _valueTypes.Vec3.normalize(modelRay.d, transformMat4Normal(modelRay.d, worldRay.d, m4_2)); + var distance = Infinity; + var component = node._renderComponent; + if (component instanceof cc.MeshRenderer) distance = ray_aabb(modelRay, component._boundingBox); else if (node.width && node.height) { + _valueTypes.Vec3.set(minPos, -node.width * node.anchorX, -node.height * node.anchorY, node.z); + _valueTypes.Vec3.set(maxPos, node.width * (1 - node.anchorX), node.height * (1 - node.anchorY), node.z); + _aabb["default"].fromPoints(nodeAabb, minPos, maxPos); + distance = ray_aabb(modelRay, nodeAabb); + } + if (!distanceValid(distance)) return; + handler && (distance = handler(modelRay, node, distance)); + if (distanceValid(distance)) { + _valueTypes.Vec3.scale(d, modelRay.d, distance); + transformMat4Normal(d, d, m4_1); + var res = resultsPool.add(); + res.node = node; + res.distance = _valueTypes.Vec3.mag(d); + results.push(res); + } + })); + results.sort(cmp); + return results; + }; + })(); + var raycast = ray_cast; + var ray_plane = (function() { + var pt = new _valueTypes.Vec3(0, 0, 0); + return function(ray, plane) { + var denom = _valueTypes.Vec3.dot(ray.d, plane.n); + if (Math.abs(denom) < Number.EPSILON) return 0; + _valueTypes.Vec3.multiplyScalar(pt, plane.n, plane.d); + var t = _valueTypes.Vec3.dot(_valueTypes.Vec3.subtract(pt, pt, ray.o), plane.n) / denom; + if (t < 0) return 0; + return t; + }; + })(); + var line_plane = (function() { + var ab = new _valueTypes.Vec3(0, 0, 0); + return function(line, plane) { + _valueTypes.Vec3.subtract(ab, line.e, line.s); + var t = (plane.d - _valueTypes.Vec3.dot(line.s, plane.n)) / _valueTypes.Vec3.dot(ab, plane.n); + if (t < 0 || t > 1) return 0; + return t; + }; + })(); + var ray_triangle = (function() { + var ab = new _valueTypes.Vec3(0, 0, 0); + var ac = new _valueTypes.Vec3(0, 0, 0); + var pvec = new _valueTypes.Vec3(0, 0, 0); + var tvec = new _valueTypes.Vec3(0, 0, 0); + var qvec = new _valueTypes.Vec3(0, 0, 0); + return function(ray, triangle, doubleSided) { + _valueTypes.Vec3.subtract(ab, triangle.b, triangle.a); + _valueTypes.Vec3.subtract(ac, triangle.c, triangle.a); + _valueTypes.Vec3.cross(pvec, ray.d, ac); + var det = _valueTypes.Vec3.dot(ab, pvec); + if (det < Number.EPSILON && (!doubleSided || det > -Number.EPSILON)) return 0; + var inv_det = 1 / det; + _valueTypes.Vec3.subtract(tvec, ray.o, triangle.a); + var u = _valueTypes.Vec3.dot(tvec, pvec) * inv_det; + if (u < 0 || u > 1) return 0; + _valueTypes.Vec3.cross(qvec, tvec, ab); + var v = _valueTypes.Vec3.dot(ray.d, qvec) * inv_det; + if (v < 0 || u + v > 1) return 0; + var t = _valueTypes.Vec3.dot(ac, qvec) * inv_det; + return t < 0 ? 0 : t; + }; + })(); + var rayTriangle = ray_triangle; + var line_triangle = (function() { + var ab = new _valueTypes.Vec3(0, 0, 0); + var ac = new _valueTypes.Vec3(0, 0, 0); + var qp = new _valueTypes.Vec3(0, 0, 0); + var ap = new _valueTypes.Vec3(0, 0, 0); + var n = new _valueTypes.Vec3(0, 0, 0); + var e = new _valueTypes.Vec3(0, 0, 0); + return function(line, triangle, outPt) { + _valueTypes.Vec3.subtract(ab, triangle.b, triangle.a); + _valueTypes.Vec3.subtract(ac, triangle.c, triangle.a); + _valueTypes.Vec3.subtract(qp, line.s, line.e); + _valueTypes.Vec3.cross(n, ab, ac); + var det = _valueTypes.Vec3.dot(qp, n); + if (det <= 0) return 0; + _valueTypes.Vec3.subtract(ap, line.s, triangle.a); + var t = _valueTypes.Vec3.dot(ap, n); + if (t < 0 || t > det) return 0; + _valueTypes.Vec3.cross(e, qp, ap); + var v = _valueTypes.Vec3.dot(ac, e); + if (v < 0 || v > det) return 0; + var w = -_valueTypes.Vec3.dot(ab, e); + if (w < 0 || v + w > det) return 0; + if (outPt) { + var invDet = 1 / det; + v *= invDet; + w *= invDet; + var u = 1 - v - w; + _valueTypes.Vec3.set(outPt, triangle.a.x * u + triangle.b.x * v + triangle.c.x * w, triangle.a.y * u + triangle.b.y * v + triangle.c.y * w, triangle.a.z * u + triangle.b.z * v + triangle.c.z * w); + } + return 1; + }; + })(); + var line_quad = (function() { + var pq = new _valueTypes.Vec3(0, 0, 0); + var pa = new _valueTypes.Vec3(0, 0, 0); + var pb = new _valueTypes.Vec3(0, 0, 0); + var pc = new _valueTypes.Vec3(0, 0, 0); + var pd = new _valueTypes.Vec3(0, 0, 0); + var m = new _valueTypes.Vec3(0, 0, 0); + var tmp = new _valueTypes.Vec3(0, 0, 0); + return function(p, q, a, b, c, d, outPt) { + _valueTypes.Vec3.subtract(pq, q, p); + _valueTypes.Vec3.subtract(pa, a, p); + _valueTypes.Vec3.subtract(pb, b, p); + _valueTypes.Vec3.subtract(pc, c, p); + _valueTypes.Vec3.cross(m, pc, pq); + var v = _valueTypes.Vec3.dot(pa, m); + if (v >= 0) { + var u = -_valueTypes.Vec3.dot(pb, m); + if (u < 0) return 0; + var w = _valueTypes.Vec3.dot(_valueTypes.Vec3.cross(tmp, pq, pb), pa); + if (w < 0) return 0; + if (outPt) { + var denom = 1 / (u + v + w); + u *= denom; + v *= denom; + w *= denom; + _valueTypes.Vec3.set(outPt, a.x * u + b.x * v + c.x * w, a.y * u + b.y * v + c.y * w, a.z * u + b.z * v + c.z * w); + } + } else { + _valueTypes.Vec3.subtract(pd, d, p); + var _u = _valueTypes.Vec3.dot(pd, m); + if (_u < 0) return 0; + var _w = _valueTypes.Vec3.dot(_valueTypes.Vec3.cross(tmp, pq, pa), pd); + if (_w < 0) return 0; + if (outPt) { + v = -v; + var _denom = 1 / (_u + v + _w); + _u *= _denom; + v *= _denom; + _w *= _denom; + _valueTypes.Vec3.set(outPt, a.x * _u + d.x * v + c.x * _w, a.y * _u + d.y * v + c.y * _w, a.z * _u + d.z * v + c.z * _w); + } + } + return 1; + }; + })(); + var ray_sphere = (function() { + var e = new _valueTypes.Vec3(0, 0, 0); + return function(ray, sphere) { + var r = sphere.radius; + var c = sphere.center; + var o = ray.o; + var d = ray.d; + var rSq = r * r; + _valueTypes.Vec3.subtract(e, c, o); + var eSq = e.lengthSqr(); + var aLength = _valueTypes.Vec3.dot(e, d); + var fSq = rSq - (eSq - aLength * aLength); + if (fSq < 0) return 0; + var f = Math.sqrt(fSq); + var t = eSq < rSq ? aLength + f : aLength - f; + if (t < 0) return 0; + return t; + }; + })(); + var ray_aabb = (function() { + var min = new _valueTypes.Vec3(); + var max = new _valueTypes.Vec3(); + return function(ray, aabb) { + var o = ray.o, d = ray.d; + var ix = 1 / d.x, iy = 1 / d.y, iz = 1 / d.z; + _valueTypes.Vec3.subtract(min, aabb.center, aabb.halfExtents); + _valueTypes.Vec3.add(max, aabb.center, aabb.halfExtents); + var t1 = (min.x - o.x) * ix; + var t2 = (max.x - o.x) * ix; + var t3 = (min.y - o.y) * iy; + var t4 = (max.y - o.y) * iy; + var t5 = (min.z - o.z) * iz; + var t6 = (max.z - o.z) * iz; + var tmin = Math.max(Math.max(Math.min(t1, t2), Math.min(t3, t4)), Math.min(t5, t6)); + var tmax = Math.min(Math.min(Math.max(t1, t2), Math.max(t3, t4)), Math.max(t5, t6)); + if (tmax < 0 || tmin > tmax) return 0; + return tmin; + }; + })(); + var rayAabb = ray_aabb; + var ray_obb = (function() { + var center = new _valueTypes.Vec3(); + var o = new _valueTypes.Vec3(); + var d = new _valueTypes.Vec3(); + var X = new _valueTypes.Vec3(); + var Y = new _valueTypes.Vec3(); + var Z = new _valueTypes.Vec3(); + var p = new _valueTypes.Vec3(); + var size = new Array(3); + var f = new Array(3); + var e = new Array(3); + var t = new Array(6); + return function(ray, obb) { + size[0] = obb.halfExtents.x; + size[1] = obb.halfExtents.y; + size[2] = obb.halfExtents.z; + center = obb.center; + o = ray.o; + d = ray.d; + var obbm = obb.orientation.m; + _valueTypes.Vec3.set(X, obbm[0], obbm[1], obbm[2]); + _valueTypes.Vec3.set(Y, obbm[3], obbm[4], obbm[5]); + _valueTypes.Vec3.set(Z, obbm[6], obbm[7], obbm[8]); + _valueTypes.Vec3.subtract(p, center, o); + f[0] = _valueTypes.Vec3.dot(X, d); + f[1] = _valueTypes.Vec3.dot(Y, d); + f[2] = _valueTypes.Vec3.dot(Z, d); + e[0] = _valueTypes.Vec3.dot(X, p); + e[1] = _valueTypes.Vec3.dot(Y, p); + e[2] = _valueTypes.Vec3.dot(Z, p); + for (var i = 0; i < 3; ++i) { + if (0 === f[i]) { + if (-e[i] - size[i] > 0 || -e[i] + size[i] < 0) return 0; + f[i] = 1e-7; + } + t[2 * i + 0] = (e[i] + size[i]) / f[i]; + t[2 * i + 1] = (e[i] - size[i]) / f[i]; + } + var tmin = Math.max(Math.max(Math.min(t[0], t[1]), Math.min(t[2], t[3])), Math.min(t[4], t[5])); + var tmax = Math.min(Math.min(Math.max(t[0], t[1]), Math.max(t[2], t[3])), Math.max(t[4], t[5])); + if (tmax < 0 || tmin > tmax || tmin < 0) return 0; + return tmin; + }; + })(); + var aabb_aabb = (function() { + var aMin = new _valueTypes.Vec3(); + var aMax = new _valueTypes.Vec3(); + var bMin = new _valueTypes.Vec3(); + var bMax = new _valueTypes.Vec3(); + return function(aabb1, aabb2) { + _valueTypes.Vec3.subtract(aMin, aabb1.center, aabb1.halfExtents); + _valueTypes.Vec3.add(aMax, aabb1.center, aabb1.halfExtents); + _valueTypes.Vec3.subtract(bMin, aabb2.center, aabb2.halfExtents); + _valueTypes.Vec3.add(bMax, aabb2.center, aabb2.halfExtents); + return aMin.x <= bMax.x && aMax.x >= bMin.x && aMin.y <= bMax.y && aMax.y >= bMin.y && aMin.z <= bMax.z && aMax.z >= bMin.z; + }; + })(); + function getAABBVertices(min, max, out) { + _valueTypes.Vec3.set(out[0], min.x, max.y, max.z); + _valueTypes.Vec3.set(out[1], min.x, max.y, min.z); + _valueTypes.Vec3.set(out[2], min.x, min.y, max.z); + _valueTypes.Vec3.set(out[3], min.x, min.y, min.z); + _valueTypes.Vec3.set(out[4], max.x, max.y, max.z); + _valueTypes.Vec3.set(out[5], max.x, max.y, min.z); + _valueTypes.Vec3.set(out[6], max.x, min.y, max.z); + _valueTypes.Vec3.set(out[7], max.x, min.y, min.z); + } + function getOBBVertices(c, e, a1, a2, a3, out) { + _valueTypes.Vec3.set(out[0], c.x + a1.x * e.x + a2.x * e.y + a3.x * e.z, c.y + a1.y * e.x + a2.y * e.y + a3.y * e.z, c.z + a1.z * e.x + a2.z * e.y + a3.z * e.z); + _valueTypes.Vec3.set(out[1], c.x - a1.x * e.x + a2.x * e.y + a3.x * e.z, c.y - a1.y * e.x + a2.y * e.y + a3.y * e.z, c.z - a1.z * e.x + a2.z * e.y + a3.z * e.z); + _valueTypes.Vec3.set(out[2], c.x + a1.x * e.x - a2.x * e.y + a3.x * e.z, c.y + a1.y * e.x - a2.y * e.y + a3.y * e.z, c.z + a1.z * e.x - a2.z * e.y + a3.z * e.z); + _valueTypes.Vec3.set(out[3], c.x + a1.x * e.x + a2.x * e.y - a3.x * e.z, c.y + a1.y * e.x + a2.y * e.y - a3.y * e.z, c.z + a1.z * e.x + a2.z * e.y - a3.z * e.z); + _valueTypes.Vec3.set(out[4], c.x - a1.x * e.x - a2.x * e.y - a3.x * e.z, c.y - a1.y * e.x - a2.y * e.y - a3.y * e.z, c.z - a1.z * e.x - a2.z * e.y - a3.z * e.z); + _valueTypes.Vec3.set(out[5], c.x + a1.x * e.x - a2.x * e.y - a3.x * e.z, c.y + a1.y * e.x - a2.y * e.y - a3.y * e.z, c.z + a1.z * e.x - a2.z * e.y - a3.z * e.z); + _valueTypes.Vec3.set(out[6], c.x - a1.x * e.x + a2.x * e.y - a3.x * e.z, c.y - a1.y * e.x + a2.y * e.y - a3.y * e.z, c.z - a1.z * e.x + a2.z * e.y - a3.z * e.z); + _valueTypes.Vec3.set(out[7], c.x - a1.x * e.x - a2.x * e.y + a3.x * e.z, c.y - a1.y * e.x - a2.y * e.y + a3.y * e.z, c.z - a1.z * e.x - a2.z * e.y + a3.z * e.z); + } + function getInterval(vertices, axis) { + var min = _valueTypes.Vec3.dot(axis, vertices[0]), max = min; + for (var i = 1; i < 8; ++i) { + var projection = _valueTypes.Vec3.dot(axis, vertices[i]); + min = projection < min ? projection : min; + max = projection > max ? projection : max; + } + return [ min, max ]; + } + var aabb_obb = (function() { + var test = new Array(15); + for (var i = 0; i < 15; i++) test[i] = new _valueTypes.Vec3(0, 0, 0); + var vertices = new Array(8); + var vertices2 = new Array(8); + for (var _i2 = 0; _i2 < 8; _i2++) { + vertices[_i2] = new _valueTypes.Vec3(0, 0, 0); + vertices2[_i2] = new _valueTypes.Vec3(0, 0, 0); + } + var min = new _valueTypes.Vec3(); + var max = new _valueTypes.Vec3(); + return function(aabb, obb) { + var obbm = obb.orientation.m; + _valueTypes.Vec3.set(test[0], 1, 0, 0); + _valueTypes.Vec3.set(test[1], 0, 1, 0); + _valueTypes.Vec3.set(test[2], 0, 0, 1); + _valueTypes.Vec3.set(test[3], obbm[0], obbm[1], obbm[2]); + _valueTypes.Vec3.set(test[4], obbm[3], obbm[4], obbm[5]); + _valueTypes.Vec3.set(test[5], obbm[6], obbm[7], obbm[8]); + for (var _i3 = 0; _i3 < 3; ++_i3) { + _valueTypes.Vec3.cross(test[6 + 3 * _i3 + 0], test[_i3], test[0]); + _valueTypes.Vec3.cross(test[6 + 3 * _i3 + 1], test[_i3], test[1]); + _valueTypes.Vec3.cross(test[6 + 3 * _i3 + 1], test[_i3], test[2]); + } + _valueTypes.Vec3.subtract(min, aabb.center, aabb.halfExtents); + _valueTypes.Vec3.add(max, aabb.center, aabb.halfExtents); + getAABBVertices(min, max, vertices); + getOBBVertices(obb.center, obb.halfExtents, test[3], test[4], test[5], vertices2); + for (var j = 0; j < 15; ++j) { + var a = getInterval(vertices, test[j]); + var b = getInterval(vertices2, test[j]); + if (b[0] > a[1] || a[0] > b[1]) return 0; + } + return 1; + }; + })(); + var aabb_plane = function aabb_plane(aabb, plane) { + var r = aabb.halfExtents.x * Math.abs(plane.n.x) + aabb.halfExtents.y * Math.abs(plane.n.y) + aabb.halfExtents.z * Math.abs(plane.n.z); + var dot = _valueTypes.Vec3.dot(plane.n, aabb.center); + if (dot + r < plane.d) return -1; + if (dot - r > plane.d) return 0; + return 1; + }; + var aabb_frustum = function aabb_frustum(aabb, frustum) { + for (var i = 0; i < frustum.planes.length; i++) if (-1 === aabb_plane(aabb, frustum.planes[i])) return 0; + return 1; + }; + var aabb_frustum_accurate = (function() { + var tmp = new Array(8); + var out1 = 0, out2 = 0; + for (var i = 0; i < tmp.length; i++) tmp[i] = new _valueTypes.Vec3(0, 0, 0); + return function(aabb, frustum) { + var result = 0, intersects = false; + for (var _i4 = 0; _i4 < frustum.planes.length; _i4++) { + result = aabb_plane(aabb, frustum.planes[_i4]); + if (-1 === result) return 0; + 1 === result && (intersects = true); + } + if (!intersects) return 1; + for (var _i5 = 0; _i5 < frustum.vertices.length; _i5++) _valueTypes.Vec3.subtract(tmp[_i5], frustum.vertices[_i5], aabb.center); + out1 = 0, out2 = 0; + for (var _i6 = 0; _i6 < frustum.vertices.length; _i6++) tmp[_i6].x > aabb.halfExtents.x ? out1++ : tmp[_i6].x < -aabb.halfExtents.x && out2++; + if (out1 === frustum.vertices.length || out2 === frustum.vertices.length) return 0; + out1 = 0; + out2 = 0; + for (var _i7 = 0; _i7 < frustum.vertices.length; _i7++) tmp[_i7].y > aabb.halfExtents.y ? out1++ : tmp[_i7].y < -aabb.halfExtents.y && out2++; + if (out1 === frustum.vertices.length || out2 === frustum.vertices.length) return 0; + out1 = 0; + out2 = 0; + for (var _i8 = 0; _i8 < frustum.vertices.length; _i8++) tmp[_i8].z > aabb.halfExtents.z ? out1++ : tmp[_i8].z < -aabb.halfExtents.z && out2++; + if (out1 === frustum.vertices.length || out2 === frustum.vertices.length) return 0; + return 1; + }; + })(); + var obb_point = (function() { + var tmp = new _valueTypes.Vec3(0, 0, 0), m3 = new _valueTypes.Mat3(); + var lessThan = function lessThan(a, b) { + return Math.abs(a.x) < b.x && Math.abs(a.y) < b.y && Math.abs(a.z) < b.z; + }; + return function(obb, point) { + _valueTypes.Vec3.subtract(tmp, point, obb.center); + _valueTypes.Vec3.transformMat3(tmp, tmp, _valueTypes.Mat3.transpose(m3, obb.orientation)); + return lessThan(tmp, obb.halfExtents); + }; + })(); + var obb_plane = (function() { + var absDot = function absDot(n, x, y, z) { + return Math.abs(n.x * x + n.y * y + n.z * z); + }; + return function(obb, plane) { + var obbm = obb.orientation.m; + var r = obb.halfExtents.x * absDot(plane.n, obbm[0], obbm[1], obbm[2]) + obb.halfExtents.y * absDot(plane.n, obbm[3], obbm[4], obbm[5]) + obb.halfExtents.z * absDot(plane.n, obbm[6], obbm[7], obbm[8]); + var dot = _valueTypes.Vec3.dot(plane.n, obb.center); + if (dot + r < plane.d) return -1; + if (dot - r > plane.d) return 0; + return 1; + }; + })(); + var obb_frustum = function obb_frustum(obb, frustum) { + for (var i = 0; i < frustum.planes.length; i++) if (-1 === obb_plane(obb, frustum.planes[i])) return 0; + return 1; + }; + var obb_frustum_accurate = (function() { + var tmp = new Array(8); + var dist = 0, out1 = 0, out2 = 0; + for (var i = 0; i < tmp.length; i++) tmp[i] = new _valueTypes.Vec3(0, 0, 0); + var dot = function dot(n, x, y, z) { + return n.x * x + n.y * y + n.z * z; + }; + return function(obb, frustum) { + var result = 0, intersects = false; + for (var _i9 = 0; _i9 < frustum.planes.length; _i9++) { + result = obb_plane(obb, frustum.planes[_i9]); + if (-1 === result) return 0; + 1 === result && (intersects = true); + } + if (!intersects) return 1; + for (var _i10 = 0; _i10 < frustum.vertices.length; _i10++) _valueTypes.Vec3.subtract(tmp[_i10], frustum.vertices[_i10], obb.center); + out1 = 0, out2 = 0; + var obbm = obb.orientation.m; + for (var _i11 = 0; _i11 < frustum.vertices.length; _i11++) { + dist = dot(tmp[_i11], obbm[0], obbm[1], obbm[2]); + dist > obb.halfExtents.x ? out1++ : dist < -obb.halfExtents.x && out2++; + } + if (out1 === frustum.vertices.length || out2 === frustum.vertices.length) return 0; + out1 = 0; + out2 = 0; + for (var _i12 = 0; _i12 < frustum.vertices.length; _i12++) { + dist = dot(tmp[_i12], obbm[3], obbm[4], obbm[5]); + dist > obb.halfExtents.y ? out1++ : dist < -obb.halfExtents.y && out2++; + } + if (out1 === frustum.vertices.length || out2 === frustum.vertices.length) return 0; + out1 = 0; + out2 = 0; + for (var _i13 = 0; _i13 < frustum.vertices.length; _i13++) { + dist = dot(tmp[_i13], obbm[6], obbm[7], obbm[8]); + dist > obb.halfExtents.z ? out1++ : dist < -obb.halfExtents.z && out2++; + } + if (out1 === frustum.vertices.length || out2 === frustum.vertices.length) return 0; + return 1; + }; + })(); + var obb_obb = (function() { + var test = new Array(15); + for (var i = 0; i < 15; i++) test[i] = new _valueTypes.Vec3(0, 0, 0); + var vertices = new Array(8); + var vertices2 = new Array(8); + for (var _i14 = 0; _i14 < 8; _i14++) { + vertices[_i14] = new _valueTypes.Vec3(0, 0, 0); + vertices2[_i14] = new _valueTypes.Vec3(0, 0, 0); + } + return function(obb1, obb2) { + var obb1m = obb1.orientation.m; + var obb2m = obb2.orientation.m; + _valueTypes.Vec3.set(test[0], obb1m[0], obb1m[1], obb1m[2]); + _valueTypes.Vec3.set(test[1], obb1m[3], obb1m[4], obb1m[5]); + _valueTypes.Vec3.set(test[2], obb1m[6], obb1m[7], obb1m[8]); + _valueTypes.Vec3.set(test[3], obb2m[0], obb2m[1], obb2m[2]); + _valueTypes.Vec3.set(test[4], obb2m[3], obb2m[4], obb2m[5]); + _valueTypes.Vec3.set(test[5], obb2m[6], obb2m[7], obb2m[8]); + for (var _i15 = 0; _i15 < 3; ++_i15) { + _valueTypes.Vec3.cross(test[6 + 3 * _i15 + 0], test[_i15], test[0]); + _valueTypes.Vec3.cross(test[6 + 3 * _i15 + 1], test[_i15], test[1]); + _valueTypes.Vec3.cross(test[6 + 3 * _i15 + 1], test[_i15], test[2]); + } + getOBBVertices(obb1.center, obb1.halfExtents, test[0], test[1], test[2], vertices); + getOBBVertices(obb2.center, obb2.halfExtents, test[3], test[4], test[5], vertices2); + for (var _i16 = 0; _i16 < 15; ++_i16) { + var a = getInterval(vertices, test[_i16]); + var b = getInterval(vertices2, test[_i16]); + if (b[0] > a[1] || a[0] > b[1]) return 0; + } + return 1; + }; + })(); + var sphere_plane = function sphere_plane(sphere, plane) { + var dot = _valueTypes.Vec3.dot(plane.n, sphere.center); + var r = sphere.radius * plane.n.length(); + if (dot + r < plane.d) return -1; + if (dot - r > plane.d) return 0; + return 1; + }; + var sphere_frustum = function sphere_frustum(sphere, frustum) { + for (var i = 0; i < frustum.planes.length; i++) if (-1 === sphere_plane(sphere, frustum.planes[i])) return 0; + return 1; + }; + var sphere_frustum_accurate = (function() { + var pt = new _valueTypes.Vec3(0, 0, 0), map = [ 1, -1, 1, -1, 1, -1 ]; + return function(sphere, frustum) { + for (var i = 0; i < 6; i++) { + var plane = frustum.planes[i]; + var r = sphere.radius, c = sphere.center; + var n = plane.n, d = plane.d; + var dot = _valueTypes.Vec3.dot(n, c); + if (dot + r < d) return 0; + if (dot - r > d) continue; + _valueTypes.Vec3.add(pt, c, _valueTypes.Vec3.multiplyScalar(pt, n, r)); + for (var j = 0; j < 6; j++) { + if (j === i || j === i + map[i]) continue; + var test = frustum.planes[j]; + if (_valueTypes.Vec3.dot(test.n, pt) < test.d) return 0; + } + } + return 1; + }; + })(); + var sphere_sphere = function sphere_sphere(sphere0, sphere1) { + var r = sphere0.radius + sphere1.radius; + return _valueTypes.Vec3.squaredDistance(sphere0.center, sphere1.center) < r * r; + }; + var sphere_aabb = (function() { + var pt = new _valueTypes.Vec3(); + return function(sphere, aabb) { + distance.pt_point_aabb(pt, sphere.center, aabb); + return _valueTypes.Vec3.squaredDistance(sphere.center, pt) < sphere.radius * sphere.radius; + }; + })(); + var sphere_obb = (function() { + var pt = new _valueTypes.Vec3(); + return function(sphere, obb) { + distance.pt_point_obb(pt, sphere.center, obb); + return _valueTypes.Vec3.squaredDistance(sphere.center, pt) < sphere.radius * sphere.radius; + }; + })(); + var intersect = { + rayAabb: rayAabb, + rayMesh: rayMesh, + raycast: raycast, + rayTriangle: rayTriangle, + ray_sphere: ray_sphere, + ray_aabb: ray_aabb, + ray_obb: ray_obb, + ray_plane: ray_plane, + ray_triangle: ray_triangle, + line_plane: line_plane, + line_triangle: line_triangle, + line_quad: line_quad, + sphere_sphere: sphere_sphere, + sphere_aabb: sphere_aabb, + sphere_obb: sphere_obb, + sphere_plane: sphere_plane, + sphere_frustum: sphere_frustum, + sphere_frustum_accurate: sphere_frustum_accurate, + aabb_aabb: aabb_aabb, + aabb_obb: aabb_obb, + aabb_plane: aabb_plane, + aabb_frustum: aabb_frustum, + aabb_frustum_accurate: aabb_frustum_accurate, + obb_obb: obb_obb, + obb_plane: obb_plane, + obb_frustum: obb_frustum, + obb_frustum_accurate: obb_frustum_accurate, + obb_point: obb_point, + resolve: function resolve(g1, g2, outPt) { + void 0 === outPt && (outPt = null); + var type1 = g1._type, type2 = g2._type; + var resolver = this[type1 | type2]; + return type1 < type2 ? resolver(g1, g2, outPt) : resolver(g2, g1, outPt); + } + }; + intersect[_enums["default"].SHAPE_RAY | _enums["default"].SHAPE_SPHERE] = ray_sphere; + intersect[_enums["default"].SHAPE_RAY | _enums["default"].SHAPE_AABB] = ray_aabb; + intersect[_enums["default"].SHAPE_RAY | _enums["default"].SHAPE_OBB] = ray_obb; + intersect[_enums["default"].SHAPE_RAY | _enums["default"].SHAPE_PLANE] = ray_plane; + intersect[_enums["default"].SHAPE_RAY | _enums["default"].SHAPE_TRIANGLE] = ray_triangle; + intersect[_enums["default"].SHAPE_LINE | _enums["default"].SHAPE_PLANE] = line_plane; + intersect[_enums["default"].SHAPE_LINE | _enums["default"].SHAPE_TRIANGLE] = line_triangle; + intersect[_enums["default"].SHAPE_SPHERE] = sphere_sphere; + intersect[_enums["default"].SHAPE_SPHERE | _enums["default"].SHAPE_AABB] = sphere_aabb; + intersect[_enums["default"].SHAPE_SPHERE | _enums["default"].SHAPE_OBB] = sphere_obb; + intersect[_enums["default"].SHAPE_SPHERE | _enums["default"].SHAPE_PLANE] = sphere_plane; + intersect[_enums["default"].SHAPE_SPHERE | _enums["default"].SHAPE_FRUSTUM] = sphere_frustum; + intersect[_enums["default"].SHAPE_SPHERE | _enums["default"].SHAPE_FRUSTUM_ACCURATE] = sphere_frustum_accurate; + intersect[_enums["default"].SHAPE_AABB] = aabb_aabb; + intersect[_enums["default"].SHAPE_AABB | _enums["default"].SHAPE_OBB] = aabb_obb; + intersect[_enums["default"].SHAPE_AABB | _enums["default"].SHAPE_PLANE] = aabb_plane; + intersect[_enums["default"].SHAPE_AABB | _enums["default"].SHAPE_FRUSTUM] = aabb_frustum; + intersect[_enums["default"].SHAPE_AABB | _enums["default"].SHAPE_FRUSTUM_ACCURATE] = aabb_frustum_accurate; + intersect[_enums["default"].SHAPE_OBB] = obb_obb; + intersect[_enums["default"].SHAPE_OBB | _enums["default"].SHAPE_PLANE] = obb_plane; + intersect[_enums["default"].SHAPE_OBB | _enums["default"].SHAPE_FRUSTUM] = obb_frustum; + intersect[_enums["default"].SHAPE_OBB | _enums["default"].SHAPE_FRUSTUM_ACCURATE] = obb_frustum_accurate; + var _default = intersect; + exports["default"] = _default; + module.exports = exports["default"]; + }), { + "../../renderer/gfx": 373, + "../../renderer/memop/recycle-pool": 388, + "../value-types": 340, + "./aabb": 191, + "./distance": 192, + "./enums": 193, + "./ray": 200, + "./triangle": 202 + } ], + 197: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _valueTypes = require("../value-types"); + var _enums = _interopRequireDefault(require("./enums")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + var line = (function() { + line.create = function create(sx, sy, sz, ex, ey, ez) { + return new line(sx, sy, sz, ex, ey, ez); + }; + line.clone = function clone(a) { + return new line(a.s.x, a.s.y, a.s.z, a.e.x, a.e.y, a.e.z); + }; + line.copy = function copy(out, a) { + _valueTypes.Vec3.copy(out.s, a.s); + _valueTypes.Vec3.copy(out.e, a.e); + return out; + }; + line.fromPoints = function fromPoints(out, start, end) { + _valueTypes.Vec3.copy(out.s, start); + _valueTypes.Vec3.copy(out.e, end); + return out; + }; + line.set = function set(out, sx, sy, sz, ex, ey, ez) { + out.s.x = sx; + out.s.y = sy; + out.s.z = sz; + out.e.x = ex; + out.e.y = ey; + out.e.z = ez; + return out; + }; + line.len = function len(a) { + return _valueTypes.Vec3.distance(a.s, a.e); + }; + function line(sx, sy, sz, ex, ey, ez) { + void 0 === sx && (sx = 0); + void 0 === sy && (sy = 0); + void 0 === sz && (sz = 0); + void 0 === ex && (ex = 0); + void 0 === ey && (ey = 0); + void 0 === ez && (ez = -1); + this.s = void 0; + this.e = void 0; + this._type = void 0; + this._type = _enums["default"].SHAPE_LINE; + this.s = new _valueTypes.Vec3(sx, sy, sz); + this.e = new _valueTypes.Vec3(ex, ey, ez); + } + var _proto = line.prototype; + _proto.length = function length() { + return _valueTypes.Vec3.distance(this.s, this.e); + }; + return line; + })(); + exports["default"] = line; + module.exports = exports["default"]; + }), { + "../value-types": 340, + "./enums": 193 + } ], + 198: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _valueTypes = require("../value-types"); + var _enums = _interopRequireDefault(require("./enums")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + "value" in descriptor && (descriptor.writable = true); + Object.defineProperty(target, descriptor.key, descriptor); + } + } + function _createClass(Constructor, protoProps, staticProps) { + protoProps && _defineProperties(Constructor.prototype, protoProps); + staticProps && _defineProperties(Constructor, staticProps); + return Constructor; + } + var _v3_tmp = new _valueTypes.Vec3(); + var _v3_tmp2 = new _valueTypes.Vec3(); + var _m3_tmp = new _valueTypes.Mat3(); + var transform_extent_m3 = function transform_extent_m3(out, extent, m3) { + var m3_tmpm = _m3_tmp.m, m3m = m3.m; + m3_tmpm[0] = Math.abs(m3m[0]); + m3_tmpm[1] = Math.abs(m3m[1]); + m3_tmpm[2] = Math.abs(m3m[2]); + m3_tmpm[3] = Math.abs(m3m[3]); + m3_tmpm[4] = Math.abs(m3m[4]); + m3_tmpm[5] = Math.abs(m3m[5]); + m3_tmpm[6] = Math.abs(m3m[6]); + m3_tmpm[7] = Math.abs(m3m[7]); + m3_tmpm[8] = Math.abs(m3m[8]); + _valueTypes.Vec3.transformMat3(out, extent, _m3_tmp); + }; + var obb = (function() { + obb.create = function create(cx, cy, cz, hw, hh, hl, ox_1, ox_2, ox_3, oy_1, oy_2, oy_3, oz_1, oz_2, oz_3) { + return new obb(cx, cy, cz, hw, hh, hl, ox_1, ox_2, ox_3, oy_1, oy_2, oy_3, oz_1, oz_2, oz_3); + }; + obb.clone = function clone(a) { + var aom = a.orientation.m; + return new obb(a.center.x, a.center.y, a.center.z, a.halfExtents.x, a.halfExtents.y, a.halfExtents.z, aom[0], aom[1], aom[2], aom[3], aom[4], aom[5], aom[6], aom[7], aom[8]); + }; + obb.copy = function copy(out, a) { + _valueTypes.Vec3.copy(out.center, a.center); + _valueTypes.Vec3.copy(out.halfExtents, a.halfExtents); + _valueTypes.Mat3.copy(out.orientation, a.orientation); + return out; + }; + obb.fromPoints = function fromPoints(out, minPos, maxPos) { + _valueTypes.Vec3.multiplyScalar(out.center, _valueTypes.Vec3.add(_v3_tmp, minPos, maxPos), .5); + _valueTypes.Vec3.multiplyScalar(out.halfExtents, _valueTypes.Vec3.subtract(_v3_tmp2, maxPos, minPos), .5); + _valueTypes.Mat3.identity(out.orientation); + return out; + }; + obb.set = function set(out, cx, cy, cz, hw, hh, hl, ox_1, ox_2, ox_3, oy_1, oy_2, oy_3, oz_1, oz_2, oz_3) { + _valueTypes.Vec3.set(out.center, cx, cy, cz); + _valueTypes.Vec3.set(out.halfExtents, hw, hh, hl); + _valueTypes.Mat3.set(out.orientation, ox_1, ox_2, ox_3, oy_1, oy_2, oy_3, oz_1, oz_2, oz_3); + return out; + }; + function obb(cx, cy, cz, hw, hh, hl, ox_1, ox_2, ox_3, oy_1, oy_2, oy_3, oz_1, oz_2, oz_3) { + void 0 === cx && (cx = 0); + void 0 === cy && (cy = 0); + void 0 === cz && (cz = 0); + void 0 === hw && (hw = 1); + void 0 === hh && (hh = 1); + void 0 === hl && (hl = 1); + void 0 === ox_1 && (ox_1 = 1); + void 0 === ox_2 && (ox_2 = 0); + void 0 === ox_3 && (ox_3 = 0); + void 0 === oy_1 && (oy_1 = 0); + void 0 === oy_2 && (oy_2 = 1); + void 0 === oy_3 && (oy_3 = 0); + void 0 === oz_1 && (oz_1 = 0); + void 0 === oz_2 && (oz_2 = 0); + void 0 === oz_3 && (oz_3 = 1); + this.center = void 0; + this.halfExtents = void 0; + this.orientation = void 0; + this._type = void 0; + this._type = _enums["default"].SHAPE_OBB; + this.center = new _valueTypes.Vec3(cx, cy, cz); + this.halfExtents = new _valueTypes.Vec3(hw, hh, hl); + this.orientation = new _valueTypes.Mat3(ox_1, ox_2, ox_3, oy_1, oy_2, oy_3, oz_1, oz_2, oz_3); + } + var _proto = obb.prototype; + _proto.getBoundary = function getBoundary(minPos, maxPos) { + transform_extent_m3(_v3_tmp, this.halfExtents, this.orientation); + _valueTypes.Vec3.subtract(minPos, this.center, _v3_tmp); + _valueTypes.Vec3.add(maxPos, this.center, _v3_tmp); + }; + _proto.transform = function transform(m, pos, rot, scale, out) { + _valueTypes.Vec3.transformMat4(out.center, this.center, m); + _valueTypes.Mat3.fromQuat(out.orientation, rot); + _valueTypes.Vec3.multiply(out.halfExtents, this.halfExtents, scale); + }; + _proto.translateAndRotate = function translateAndRotate(m, rot, out) { + _valueTypes.Vec3.transformMat4(out.center, this.center, m); + _valueTypes.Mat3.fromQuat(out.orientation, rot); + }; + _proto.setScale = function setScale(scale, out) { + _valueTypes.Vec3.multiply(out.halfExtents, this.halfExtents, scale); + }; + _createClass(obb, [ { + key: "type", + get: function get() { + return this._type; + } + } ]); + return obb; + })(); + exports["default"] = obb; + module.exports = exports["default"]; + }), { + "../value-types": 340, + "./enums": 193 + } ], + 199: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _valueTypes = require("../value-types"); + var _enums = _interopRequireDefault(require("./enums")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + var v1 = new _valueTypes.Vec3(0, 0, 0); + var v2 = new _valueTypes.Vec3(0, 0, 0); + var temp_mat = cc.mat4(); + var temp_vec4 = cc.v4(); + var plane = (function() { + plane.create = function create(nx, ny, nz, d) { + return new plane(nx, ny, nz, d); + }; + plane.clone = function clone(p) { + return new plane(p.n.x, p.n.y, p.n.z, p.d); + }; + plane.copy = function copy(out, p) { + _valueTypes.Vec3.copy(out.n, p.n); + out.d = p.d; + return out; + }; + plane.fromPoints = function fromPoints(out, a, b, c) { + _valueTypes.Vec3.subtract(v1, b, a); + _valueTypes.Vec3.subtract(v2, c, a); + _valueTypes.Vec3.normalize(out.n, _valueTypes.Vec3.cross(out.n, v1, v2)); + out.d = _valueTypes.Vec3.dot(out.n, a); + return out; + }; + plane.set = function set(out, nx, ny, nz, d) { + out.n.x = nx; + out.n.y = ny; + out.n.z = nz; + out.d = d; + return out; + }; + plane.fromNormalAndPoint = function fromNormalAndPoint(out, normal, point) { + _valueTypes.Vec3.copy(out.n, normal); + out.d = _valueTypes.Vec3.dot(normal, point); + return out; + }; + plane.normalize = function normalize(out, a) { + var len = a.n.len(); + _valueTypes.Vec3.normalize(out.n, a.n); + len > 0 && (out.d = a.d / len); + return out; + }; + function plane(nx, ny, nz, d) { + void 0 === nx && (nx = 0); + void 0 === ny && (ny = 1); + void 0 === nz && (nz = 0); + void 0 === d && (d = 0); + this.n = void 0; + this.d = void 0; + this._type = void 0; + this._type = _enums["default"].SHAPE_PLANE; + this.n = new _valueTypes.Vec3(nx, ny, nz); + this.d = d; + } + var _proto = plane.prototype; + _proto.transform = function transform(mat) { + _valueTypes.Mat4.invert(temp_mat, mat); + _valueTypes.Mat4.transpose(temp_mat, temp_mat); + _valueTypes.Vec4.set(temp_vec4, this.n.x, this.n.y, this.n.z, this.d); + _valueTypes.Vec4.transformMat4(temp_vec4, temp_vec4, temp_mat); + _valueTypes.Vec3.set(this.n, temp_vec4.x, temp_vec4.y, temp_vec4.z); + this.d = temp_vec4.w; + }; + return plane; + })(); + exports["default"] = plane; + module.exports = exports["default"]; + }), { + "../value-types": 340, + "./enums": 193 + } ], + 200: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _valueTypes = require("../value-types"); + var _enums = _interopRequireDefault(require("./enums")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + var ray = (function() { + ray.create = function create(ox, oy, oz, dx, dy, dz) { + void 0 === ox && (ox = 0); + void 0 === oy && (oy = 0); + void 0 === oz && (oz = 0); + void 0 === dx && (dx = 0); + void 0 === dy && (dy = 0); + void 0 === dz && (dz = 1); + return new ray(ox, oy, oz, dx, dy, dz); + }; + ray.clone = function clone(a) { + return new ray(a.o.x, a.o.y, a.o.z, a.d.x, a.d.y, a.d.z); + }; + ray.copy = function copy(out, a) { + _valueTypes.Vec3.copy(out.o, a.o); + _valueTypes.Vec3.copy(out.d, a.d); + return out; + }; + ray.fromPoints = function fromPoints(out, origin, target) { + _valueTypes.Vec3.copy(out.o, origin); + _valueTypes.Vec3.normalize(out.d, _valueTypes.Vec3.subtract(out.d, target, origin)); + return out; + }; + ray.set = function set(out, ox, oy, oz, dx, dy, dz) { + out.o.x = ox; + out.o.y = oy; + out.o.z = oz; + out.d.x = dx; + out.d.y = dy; + out.d.z = dz; + return out; + }; + function ray(ox, oy, oz, dx, dy, dz) { + void 0 === ox && (ox = 0); + void 0 === oy && (oy = 0); + void 0 === oz && (oz = 0); + void 0 === dx && (dx = 0); + void 0 === dy && (dy = 0); + void 0 === dz && (dz = -1); + this.o = void 0; + this.d = void 0; + this._type = void 0; + this._type = _enums["default"].SHAPE_RAY; + this.o = new _valueTypes.Vec3(ox, oy, oz); + this.d = new _valueTypes.Vec3(dx, dy, dz); + } + var _proto = ray.prototype; + _proto.computeHit = function computeHit(out, distance) { + _valueTypes.Vec3.normalize(out, this.d); + _valueTypes.Vec3.scaleAndAdd(out, this.o, out, distance); + }; + return ray; + })(); + exports["default"] = ray; + module.exports = exports["default"]; + }), { + "../value-types": 340, + "./enums": 193 + } ], + 201: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _valueTypes = require("../value-types"); + var _enums = _interopRequireDefault(require("./enums")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + var _v3_tmp = new _valueTypes.Vec3(); + var sphere = (function() { + sphere.create = function create(cx, cy, cz, r) { + return new sphere(cx, cy, cz, r); + }; + sphere.clone = function clone(p) { + return new sphere(p.center.x, p.center.y, p.center.z, p.radius); + }; + sphere.copy = function copy(out, p) { + _valueTypes.Vec3.copy(out.center, p.center); + out.radius = p.radius; + return out; + }; + sphere.fromPoints = function fromPoints(out, minPos, maxPos) { + _valueTypes.Vec3.multiplyScalar(out.center, _valueTypes.Vec3.add(_v3_tmp, minPos, maxPos), .5); + out.radius = .5 * _valueTypes.Vec3.subtract(_v3_tmp, maxPos, minPos).len(); + return out; + }; + sphere.set = function set(out, cx, cy, cz, r) { + out.center.x = cx; + out.center.y = cy; + out.center.z = cz; + out.radius = r; + return out; + }; + function sphere(cx, cy, cz, r) { + void 0 === cx && (cx = 0); + void 0 === cy && (cy = 0); + void 0 === cz && (cz = 0); + void 0 === r && (r = 1); + this.center = void 0; + this.radius = void 0; + this._type = void 0; + this._type = _enums["default"].SHAPE_SPHERE; + this.center = new _valueTypes.Vec3(cx, cy, cz); + this.radius = r; + } + var _proto = sphere.prototype; + _proto.clone = function clone() { + return sphere.clone(this); + }; + _proto.copy = function copy(a) { + return sphere.copy(this, a); + }; + _proto.getBoundary = function getBoundary(minPos, maxPos) { + _valueTypes.Vec3.set(minPos, this.center.x - this.radius, this.center.y - this.radius, this.center.z - this.radius); + _valueTypes.Vec3.set(maxPos, this.center.x + this.radius, this.center.y + this.radius, this.center.z + this.radius); + }; + _proto.transform = function transform(m, pos, rot, scale, out) { + _valueTypes.Vec3.transformMat4(out.center, this.center, m); + out.radius = this.radius * scale.maxAxis(); + }; + _proto.translateAndRotate = function translateAndRotate(m, rot, out) { + _valueTypes.Vec3.transformMat4(out.center, this.center, m); + }; + _proto.setScale = function setScale(scale, out) { + out.radius = this.radius * scale.maxAxis(); + }; + return sphere; + })(); + exports["default"] = sphere; + module.exports = exports["default"]; + }), { + "../value-types": 340, + "./enums": 193 + } ], + 202: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _vec = _interopRequireDefault(require("../value-types/vec3")); + var _enums = _interopRequireDefault(require("./enums")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + var triangle = (function() { + triangle.create = function create(ax, ay, az, bx, by, bz, cx, cy, cz) { + return new triangle(ax, ay, az, bx, by, bz, cx, cy, cz); + }; + triangle.clone = function clone(t) { + return new triangle(t.a.x, t.a.y, t.a.z, t.b.x, t.b.y, t.b.z, t.c.x, t.c.y, t.c.z); + }; + triangle.copy = function copy(out, t) { + _vec["default"].copy(out.a, t.a); + _vec["default"].copy(out.b, t.b); + _vec["default"].copy(out.c, t.c); + return out; + }; + triangle.fromPoints = function fromPoints(out, a, b, c) { + _vec["default"].copy(out.a, a); + _vec["default"].copy(out.b, b); + _vec["default"].copy(out.c, c); + return out; + }; + triangle.set = function set(out, ax, ay, az, bx, by, bz, cx, cy, cz) { + out.a.x = ax; + out.a.y = ay; + out.a.z = az; + out.b.x = bx; + out.b.y = by; + out.b.z = bz; + out.c.x = cx; + out.c.y = cy; + out.c.z = cz; + return out; + }; + function triangle(ax, ay, az, bx, by, bz, cx, cy, cz) { + this.a = void 0; + this.b = void 0; + this.c = void 0; + this._type = void 0; + this.a = new _vec["default"](ax, ay, az); + this.b = new _vec["default"](bx, by, bz); + this.c = new _vec["default"](cx, cy, cz); + this._type = _enums["default"].SHAPE_TRIANGLE; + } + return triangle; + })(); + exports["default"] = triangle; + module.exports = exports["default"]; + }), { + "../value-types/vec3": 350, + "./enums": 193 + } ], + 203: [ (function(require, module, exports) { + "use strict"; + var RenderComponent = require("../components/CCRenderComponent"); + var Material = require("../assets/material/CCMaterial"); + var Types = require("./types"); + var LineCap = Types.LineCap; + var LineJoin = Types.LineJoin; + var Graphics = cc.Class({ + name: "cc.Graphics", + extends: RenderComponent, + editor: false, + ctor: function ctor() { + this._impl = new Graphics._Impl(this); + }, + properties: { + _lineWidth: 2, + _strokeColor: cc.Color.BLACK, + _lineJoin: LineJoin.MITER, + _lineCap: LineCap.BUTT, + _fillColor: cc.Color.WHITE, + _miterLimit: 10, + lineWidth: { + get: function get() { + return this._lineWidth; + }, + set: function set(value) { + this._lineWidth = value; + this._impl.lineWidth = value; + } + }, + lineJoin: { + get: function get() { + return this._lineJoin; + }, + set: function set(value) { + this._lineJoin = value; + this._impl.lineJoin = value; + }, + type: LineJoin + }, + lineCap: { + get: function get() { + return this._lineCap; + }, + set: function set(value) { + this._lineCap = value; + this._impl.lineCap = value; + }, + type: LineCap + }, + strokeColor: { + get: function get() { + return this._strokeColor; + }, + set: function set(value) { + this._impl.strokeColor = this._strokeColor = cc.color(value); + } + }, + fillColor: { + get: function get() { + return this._fillColor; + }, + set: function set(value) { + this._impl.fillColor = this._fillColor = cc.color(value); + } + }, + miterLimit: { + get: function get() { + return this._miterLimit; + }, + set: function set(value) { + this._miterLimit = value; + this._impl.miterLimit = value; + } + } + }, + statics: { + LineJoin: LineJoin, + LineCap: LineCap + }, + onRestore: function onRestore() { + this._impl || (this._impl = new Graphics._Impl(this)); + }, + onDestroy: function onDestroy() { + this.clear(true); + this._super(); + this._impl = null; + }, + _getDefaultMaterial: function _getDefaultMaterial() { + return Material.getBuiltinMaterial("2d-graphics"); + }, + _updateMaterial: function _updateMaterial() { + var material = this._materials[0]; + if (!material) return; + void 0 !== material.getDefine("CC_USE_MODEL") && material.define("CC_USE_MODEL", true); + void 0 !== material.getDefine("CC_SUPPORT_standard_derivatives") && cc.sys.glExtension("OES_standard_derivatives") && material.define("CC_SUPPORT_standard_derivatives", true); + }, + moveTo: function moveTo(x, y) { + if (true, x instanceof cc.Vec2) { + cc.warn("[moveTo] : Can not pass Vec2 as [x, y] value, please check it."); + return; + } + this._impl.moveTo(x, y); + }, + lineTo: function lineTo(x, y) { + if (true, x instanceof cc.Vec2) { + cc.warn("[moveTo] : Can not pass Vec2 as [x, y] value, please check it."); + return; + } + this._impl.lineTo(x, y); + }, + bezierCurveTo: function bezierCurveTo(c1x, c1y, c2x, c2y, x, y) { + this._impl.bezierCurveTo(c1x, c1y, c2x, c2y, x, y); + }, + quadraticCurveTo: function quadraticCurveTo(cx, cy, x, y) { + this._impl.quadraticCurveTo(cx, cy, x, y); + }, + arc: function arc(cx, cy, r, startAngle, endAngle, counterclockwise) { + this._impl.arc(cx, cy, r, startAngle, endAngle, counterclockwise); + }, + ellipse: function ellipse(cx, cy, rx, ry) { + this._impl.ellipse(cx, cy, rx, ry); + }, + circle: function circle(cx, cy, r) { + this._impl.circle(cx, cy, r); + }, + rect: function rect(x, y, w, h) { + this._impl.rect(x, y, w, h); + }, + roundRect: function roundRect(x, y, w, h, r) { + this._impl.roundRect(x, y, w, h, r); + }, + fillRect: function fillRect(x, y, w, h) { + this.rect(x, y, w, h); + this.fill(); + }, + clear: function clear(clean) { + this._impl.clear(clean); + this._assembler && this._assembler.clear(clean); + }, + close: function close() { + this._impl.close(); + }, + stroke: function stroke() { + this._assembler || this._resetAssembler(); + this._assembler.stroke(this); + }, + fill: function fill() { + this._assembler || this._resetAssembler(); + this._assembler.fill(this); + } + }); + cc.Graphics = module.exports = Graphics; + cc.Graphics.Types = Types; + cc.Graphics.Helper = require("./helper"); + }), { + "../assets/material/CCMaterial": 125, + "../components/CCRenderComponent": 161, + "./helper": 204, + "./types": 206 + } ], + 204: [ (function(require, module, exports) { + "use strict"; + var PointFlags = require("./types").PointFlags; + var PI = Math.PI; + var min = Math.min; + var max = Math.max; + var cos = Math.cos; + var sin = Math.sin; + var abs = Math.abs; + var sign = Math.sign; + var KAPPA90 = .5522847493; + function arc(ctx, cx, cy, r, startAngle, endAngle, counterclockwise) { + counterclockwise = counterclockwise || false; + var a = 0, da = 0, hda = 0, kappa = 0; + var dx = 0, dy = 0, x = 0, y = 0, tanx = 0, tany = 0; + var px = 0, py = 0, ptanx = 0, ptany = 0; + var i, ndivs; + da = endAngle - startAngle; + if (counterclockwise) if (abs(da) >= 2 * PI) da = 2 * PI; else while (da < 0) da += 2 * PI; else if (abs(da) >= 2 * PI) da = 2 * -PI; else while (da > 0) da -= 2 * PI; + ndivs = 0 | max(1, min(abs(da) / (.5 * PI) + .5, 5)); + hda = da / ndivs / 2; + kappa = abs(4 / 3 * (1 - cos(hda)) / sin(hda)); + counterclockwise || (kappa = -kappa); + for (i = 0; i <= ndivs; i++) { + a = startAngle + da * (i / ndivs); + dx = cos(a); + dy = sin(a); + x = cx + dx * r; + y = cy + dy * r; + tanx = -dy * r * kappa; + tany = dx * r * kappa; + 0 === i ? ctx.moveTo(x, y) : ctx.bezierCurveTo(px + ptanx, py + ptany, x - tanx, y - tany, x, y); + px = x; + py = y; + ptanx = tanx; + ptany = tany; + } + } + function ellipse(ctx, cx, cy, rx, ry) { + ctx.moveTo(cx - rx, cy); + ctx.bezierCurveTo(cx - rx, cy + ry * KAPPA90, cx - rx * KAPPA90, cy + ry, cx, cy + ry); + ctx.bezierCurveTo(cx + rx * KAPPA90, cy + ry, cx + rx, cy + ry * KAPPA90, cx + rx, cy); + ctx.bezierCurveTo(cx + rx, cy - ry * KAPPA90, cx + rx * KAPPA90, cy - ry, cx, cy - ry); + ctx.bezierCurveTo(cx - rx * KAPPA90, cy - ry, cx - rx, cy - ry * KAPPA90, cx - rx, cy); + ctx.close(); + } + function roundRect(ctx, x, y, w, h, r) { + if (r < .1) { + ctx.rect(x, y, w, h); + return; + } + var rx = min(r, .5 * abs(w)) * sign(w), ry = min(r, .5 * abs(h)) * sign(h); + ctx.moveTo(x, y + ry); + ctx.lineTo(x, y + h - ry); + ctx.bezierCurveTo(x, y + h - ry * (1 - KAPPA90), x + rx * (1 - KAPPA90), y + h, x + rx, y + h); + ctx.lineTo(x + w - rx, y + h); + ctx.bezierCurveTo(x + w - rx * (1 - KAPPA90), y + h, x + w, y + h - ry * (1 - KAPPA90), x + w, y + h - ry); + ctx.lineTo(x + w, y + ry); + ctx.bezierCurveTo(x + w, y + ry * (1 - KAPPA90), x + w - rx * (1 - KAPPA90), y, x + w - rx, y); + ctx.lineTo(x + rx, y); + ctx.bezierCurveTo(x + rx * (1 - KAPPA90), y, x, y + ry * (1 - KAPPA90), x, y + ry); + ctx.close(); + } + function tesselateBezier(ctx, x1, y1, x2, y2, x3, y3, x4, y4, level, type) { + var x12, y12, x23, y23, x34, y34, x123, y123, x234, y234, x1234, y1234; + var dx, dy, d2, d3; + if (level > 10) return; + x12 = .5 * (x1 + x2); + y12 = .5 * (y1 + y2); + x23 = .5 * (x2 + x3); + y23 = .5 * (y2 + y3); + x34 = .5 * (x3 + x4); + y34 = .5 * (y3 + y4); + x123 = .5 * (x12 + x23); + y123 = .5 * (y12 + y23); + dx = x4 - x1; + dy = y4 - y1; + d2 = abs((x2 - x4) * dy - (y2 - y4) * dx); + d3 = abs((x3 - x4) * dy - (y3 - y4) * dx); + if ((d2 + d3) * (d2 + d3) < ctx._tessTol * (dx * dx + dy * dy)) { + ctx._addPoint(x4, y4, 0 === type ? type | PointFlags.PT_BEVEL : type); + return; + } + x234 = .5 * (x23 + x34); + y234 = .5 * (y23 + y34); + x1234 = .5 * (x123 + x234); + y1234 = .5 * (y123 + y234); + tesselateBezier(ctx, x1, y1, x12, y12, x123, y123, x1234, y1234, level + 1, 0); + tesselateBezier(ctx, x1234, y1234, x234, y234, x34, y34, x4, y4, level + 1, type); + } + module.exports = { + arc: arc, + ellipse: ellipse, + roundRect: roundRect, + tesselateBezier: tesselateBezier + }; + }), { + "./types": 206 + } ], + 205: [ (function(require, module, exports) { + "use strict"; + require("./graphics"); + }), { + "./graphics": 203 + } ], + 206: [ (function(require, module, exports) { + "use strict"; + var LineCap = cc.Enum({ + BUTT: 0, + ROUND: 1, + SQUARE: 2 + }); + var LineJoin = cc.Enum({ + BEVEL: 0, + ROUND: 1, + MITER: 2 + }); + var PointFlags = cc.Enum({ + PT_CORNER: 1, + PT_LEFT: 2, + PT_BEVEL: 4, + PT_INNERBEVEL: 8 + }); + module.exports = { + LineCap: LineCap, + LineJoin: LineJoin, + PointFlags: PointFlags + }; + }), {} ], + 207: [ (function(require, module, exports) { + "use strict"; + require("./platform"); + require("./assets"); + true; + require("./CCNode"); + require("./CCPrivateNode"); + require("./CCScene"); + require("./components"); + require("./graphics"); + require("./collider"); + require("./collider/CCIntersection"); + require("./physics"); + require("./camera/CCCamera"); + require("./geom-utils"); + require("./mesh"); + require("./3d"); + require("./base-ui/CCWidgetManager"); + }), { + "./3d": 30, + "./CCNode": 73, + "./CCPrivateNode": 74, + "./CCScene": 75, + "./assets": 123, + "./base-ui/CCWidgetManager": 134, + "./camera/CCCamera": 135, + "./collider": 143, + "./collider/CCIntersection": 141, + "./components": 179, + "./geom-utils": 195, + "./graphics": 205, + "./mesh": 210, + "./physics": 225, + "./platform": 258 + } ], + 208: [ (function(require, module, exports) { + "use strict"; + var _inputAssembler = _interopRequireDefault(require("../../renderer/core/input-assembler")); + var _gfx = _interopRequireDefault(require("../../renderer/gfx")); + var _meshData = require("./mesh-data"); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + var renderer = require("../renderer"); + var EventTarget = require("../event/event-target"); + function applyColor(data, offset, value) { + data[offset] = value._val; + } + function applyVec2(data, offset, value) { + data[offset] = value.x; + data[offset + 1] = value.y; + } + function applyVec3(data, offset, value) { + data[offset] = value.x; + data[offset + 1] = value.y; + data[offset + 2] = value.z; + } + var _compType2fn = { + 5120: "getInt8", + 5121: "getUint8", + 5122: "getInt16", + 5123: "getUint16", + 5124: "getInt32", + 5125: "getUint32", + 5126: "getFloat32" + }; + var _compType2write = { + 5120: "setInt8", + 5121: "setUint8", + 5122: "setInt16", + 5123: "setUint16", + 5124: "setInt32", + 5125: "setUint32", + 5126: "setFloat32" + }; + var littleEndian = (function() { + var buffer = new ArrayBuffer(2); + new DataView(buffer).setInt16(0, 256, true); + return 256 === new Int16Array(buffer)[0]; + })(); + var Mesh = cc.Class({ + name: "cc.Mesh", + extends: cc.Asset, + mixins: [ EventTarget ], + properties: { + _nativeAsset: { + override: true, + get: function get() { + return this._buffer; + }, + set: function set(bin) { + this._buffer = ArrayBuffer.isView(bin) ? bin.buffer : bin; + this.initWithBuffer(); + } + }, + _vertexBundles: { + default: null, + type: _meshData.VertexBundle + }, + _primitives: { + default: null, + Primitive: _meshData.Primitive + }, + _minPos: cc.v3(), + _maxPos: cc.v3(), + subMeshes: { + get: function get() { + return this._subMeshes; + }, + set: function set(v) { + this._subMeshes = v; + } + }, + subDatas: { + get: function get() { + return this._subDatas; + } + } + }, + ctor: function ctor() { + this._subMeshes = []; + this._subDatas = []; + this.loaded = false; + }, + initWithBuffer: function initWithBuffer() { + this._subMeshes.length = 0; + var primitives = this._primitives; + for (var i = 0; i < primitives.length; i++) { + var primitive = primitives[i]; + var ibrange = primitive.data; + var ibData = new Uint8Array(this._buffer, ibrange.offset, ibrange.length); + var vertexBundle = this._vertexBundles[primitive.vertexBundleIndices[0]]; + var vbRange = vertexBundle.data; + var gfxVFmt = new _gfx["default"].VertexFormat(vertexBundle.formats); + var vbData = new Uint8Array(this._buffer, vbRange.offset, vbRange.length); + var canBatch = this._canVertexFormatBatch(gfxVFmt); + var meshData = new _meshData.MeshData(); + meshData.vData = vbData; + meshData.iData = ibData; + meshData.vfm = gfxVFmt; + meshData.offset = vbRange.offset; + meshData.canBatch = canBatch; + this._subDatas.push(meshData); + false; + var vbBuffer = new _gfx["default"].VertexBuffer(renderer.device, gfxVFmt, _gfx["default"].USAGE_STATIC, vbData); + var ibBuffer = new _gfx["default"].IndexBuffer(renderer.device, primitive.indexUnit, _gfx["default"].USAGE_STATIC, ibData); + this._subMeshes.push(new _inputAssembler["default"](vbBuffer, ibBuffer)); + } + this.loaded = true; + this.emit("load"); + }, + _canVertexFormatBatch: function _canVertexFormatBatch(format) { + var aPosition = format._attr2el[_gfx["default"].ATTR_POSITION]; + var canBatch = !aPosition || aPosition.type === _gfx["default"].ATTR_TYPE_FLOAT32 && format._bytes % 4 === 0; + return canBatch; + }, + init: function init(vertexFormat, vertexCount, dynamic, index) { + void 0 === dynamic && (dynamic = false); + void 0 === index && (index = 0); + var data = new Uint8Array(vertexFormat._bytes * vertexCount); + var meshData = new _meshData.MeshData(); + meshData.vData = data; + meshData.vfm = vertexFormat; + meshData.vDirty = true; + meshData.canBatch = this._canVertexFormatBatch(vertexFormat); + true; + var vb = new _gfx["default"].VertexBuffer(renderer.device, vertexFormat, dynamic ? _gfx["default"].USAGE_DYNAMIC : _gfx["default"].USAGE_STATIC, data); + meshData.vb = vb; + this._subMeshes[index] = new _inputAssembler["default"](meshData.vb); + var oldSubData = this._subDatas[index]; + if (oldSubData) { + oldSubData.vb && oldSubData.vb.destroy(); + oldSubData.ib && oldSubData.ib.destroy(); + } + this._subDatas[index] = meshData; + this.loaded = true; + this.emit("load"); + this.emit("init-format"); + }, + setVertices: function setVertices(name, values, index) { + index = index || 0; + var subData = this._subDatas[index]; + var el = subData.vfm.element(name); + if (!el) return cc.warn("Cannot find " + name + " attribute in vertex defines."); + var isFlatMode = "number" === typeof values[0]; + var elNum = el.num; + var verticesCount = isFlatMode ? values.length / elNum | 0 : values.length; + subData.vData.byteLength < verticesCount * el.stride && subData.setVData(new Uint8Array(verticesCount * subData.vfm._bytes)); + var data; + var bytes = 4; + if (name === _gfx["default"].ATTR_COLOR) if (isFlatMode) { + data = subData.getVData(); + bytes = 1; + } else data = subData.getVData(Uint32Array); else data = subData.getVData(Float32Array); + var stride = el.stride / bytes; + var offset = el.offset / bytes; + if (isFlatMode) for (var i = 0, l = values.length / elNum; i < l; i++) { + var sOffset = i * elNum; + var dOffset = i * stride + offset; + for (var j = 0; j < elNum; j++) data[dOffset + j] = values[sOffset + j]; + } else { + var applyFunc; + applyFunc = name === _gfx["default"].ATTR_COLOR ? applyColor : 2 === elNum ? applyVec2 : applyVec3; + for (var _i = 0, _l = values.length; _i < _l; _i++) { + var v = values[_i]; + var vOffset = _i * stride + offset; + applyFunc(data, vOffset, v); + } + } + subData.vDirty = true; + }, + setIndices: function setIndices(indices, index, dynamic) { + index = index || 0; + var iData = indices; + if (indices instanceof Uint16Array) iData = new Uint8Array(indices.buffer, indices.byteOffset, indices.byteLength); else if (Array.isArray(indices)) { + iData = new Uint16Array(indices); + iData = new Uint8Array(iData.buffer, iData.byteOffset, iData.byteLength); + } + var usage = dynamic ? _gfx["default"].USAGE_DYNAMIC : _gfx["default"].USAGE_STATIC; + var subData = this._subDatas[index]; + if (subData.ib) { + subData.iData = iData; + subData.iDirty = true; + } else { + subData.iData = iData; + true; + var buffer = new _gfx["default"].IndexBuffer(renderer.device, _gfx["default"].INDEX_FMT_UINT16, usage, iData, iData.byteLength / _gfx["default"].IndexBuffer.BYTES_PER_INDEX[_gfx["default"].INDEX_FMT_UINT16]); + subData.ib = buffer; + this._subMeshes[index]._indexBuffer = subData.ib; + } + }, + setPrimitiveType: function setPrimitiveType(type, index) { + index = index || 0; + var subMesh = this._subMeshes[index]; + if (!subMesh) { + cc.warn("Do not have sub mesh at index " + index); + return; + } + this._subMeshes[index]._primitiveType = type; + }, + clear: function clear() { + this._subMeshes.length = 0; + var subDatas = this._subDatas; + for (var i = 0, len = subDatas.length; i < len; i++) { + var vb = subDatas[i].vb; + vb && vb.destroy(); + var ib = subDatas[i].ib; + ib && ib.destroy(); + } + subDatas.length = 0; + }, + setBoundingBox: function setBoundingBox(min, max) { + this._minPos = min; + this._maxPos = max; + }, + destroy: function destroy() { + this.clear(); + }, + _uploadData: function _uploadData() { + var subDatas = this._subDatas; + for (var i = 0, len = subDatas.length; i < len; i++) { + var subData = subDatas[i]; + if (subData.vDirty) { + var buffer = subData.vb, data = subData.vData; + buffer.update(0, data); + subData.vDirty = false; + } + if (subData.iDirty) { + var _buffer = subData.ib, _data = subData.iData; + _buffer.update(0, _data); + subData.iDirty = false; + } + } + }, + _getAttrMeshData: function _getAttrMeshData(subDataIndex, name) { + var subData = this._subDatas[subDataIndex]; + if (!subData) return []; + var format = subData.vfm; + var fmt = format.element(name); + if (!fmt) return []; + subData.attrDatas || (subData.attrDatas = {}); + var attrDatas = subData.attrDatas; + var data = attrDatas[name]; + if (data) return data; + data = attrDatas[name] = []; + var vbData = subData.vData; + var dv = new DataView(vbData.buffer, vbData.byteOffset, vbData.byteLength); + var stride = fmt.stride; + var eleOffset = fmt.offset; + var eleNum = fmt.num; + var eleByte = fmt.bytes / eleNum; + var fn = _compType2fn[fmt.type]; + var vertexCount = vbData.byteLength / format._bytes; + for (var i = 0; i < vertexCount; i++) { + var offset = i * stride + eleOffset; + for (var j = 0; j < eleNum; j++) { + var v = dv[fn](offset + j * eleByte, littleEndian); + data.push(v); + } + } + return data; + }, + copyAttribute: function copyAttribute(primitiveIndex, attributeName, buffer, stride, offset) { + var written = false; + var subData = this._subDatas[primitiveIndex]; + if (!subData) return written; + var format = subData.vfm; + var fmt = format.element(attributeName); + if (!fmt) return written; + var writter = _compType2write[fmt.type]; + if (!writter) return written; + var data = this._getAttrMeshData(primitiveIndex, attributeName); + var vertexCount = subData.vData.byteLength / format._bytes; + var eleByte = fmt.bytes / fmt.num; + if (data.length > 0) { + var outputView = new DataView(buffer, offset); + var outputStride = stride; + var num = fmt.num; + for (var i = 0; i < vertexCount; ++i) { + var index = i * num; + for (var j = 0; j < num; ++j) { + var inputOffset = index + j; + var outputOffset = outputStride * i + eleByte * j; + outputView[writter](outputOffset, data[inputOffset], littleEndian); + } + } + written = true; + } + return written; + }, + copyIndices: function copyIndices(primitiveIndex, outputArray) { + var subData = this._subDatas[primitiveIndex]; + if (!subData) return false; + var iData = subData.iData; + var indexCount = iData.length / 2; + var dv = new DataView(iData.buffer, iData.byteOffset, iData.byteLength); + var fn = _compType2fn[_gfx["default"].INDEX_FMT_UINT8]; + for (var i = 0; i < indexCount; ++i) outputArray[i] = dv[fn](2 * i); + return true; + } + }); + cc.Mesh = module.exports = Mesh; + }), { + "../../renderer/core/input-assembler": 363, + "../../renderer/gfx": 373, + "../event/event-target": 187, + "../renderer": 272, + "./mesh-data": 211 + } ], + 209: [ (function(require, module, exports) { + "use strict"; + var _gfx = _interopRequireDefault(require("../../renderer/gfx")); + var _inputAssembler = _interopRequireDefault(require("../../renderer/core/input-assembler")); + var _aabb = _interopRequireDefault(require("../geom-utils/aabb")); + var _vec = _interopRequireDefault(require("../value-types/vec3")); + var _mat = _interopRequireDefault(require("../value-types/mat4")); + var _materialVariant = _interopRequireDefault(require("../assets/material/material-variant")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + var RenderComponent = require("../components/CCRenderComponent"); + var Mesh = require("./CCMesh"); + var RenderFlow = require("../renderer/render-flow"); + var Renderer = require("../renderer"); + var Material = require("../assets/material/CCMaterial"); + var ShadowCastingMode = cc.Enum({ + OFF: 0, + ON: 1 + }); + var MeshRenderer = cc.Class({ + name: "cc.MeshRenderer", + extends: RenderComponent, + editor: false, + properties: { + _mesh: { + default: null, + type: Mesh + }, + _receiveShadows: false, + _shadowCastingMode: ShadowCastingMode.OFF, + _enableAutoBatch: false, + mesh: { + get: function get() { + return this._mesh; + }, + set: function set(v) { + if (this._mesh === v) return; + this._setMesh(v); + if (!v) { + this.disableRender(); + return; + } + this.markForRender(true); + this.node._renderFlag |= RenderFlow.FLAG_TRANSFORM; + }, + type: Mesh, + animatable: false + }, + textures: { + default: [], + type: cc.Texture2D, + visible: false + }, + receiveShadows: { + get: function get() { + return this._receiveShadows; + }, + set: function set(val) { + this._receiveShadows = val; + this._updateReceiveShadow(); + }, + animatable: false + }, + shadowCastingMode: { + get: function get() { + return this._shadowCastingMode; + }, + set: function set(val) { + this._shadowCastingMode = val; + this._updateCastShadow(); + }, + type: ShadowCastingMode, + animatable: false + }, + enableAutoBatch: { + get: function get() { + return this._enableAutoBatch; + }, + set: function set(val) { + this._enableAutoBatch = val; + } + } + }, + statics: { + ShadowCastingMode: ShadowCastingMode + }, + ctor: function ctor() { + this._boundingBox = cc.geomUtils && new _aabb["default"](); + true; + this._debugDatas = { + wireFrame: [], + normal: [] + }; + }, + onEnable: function onEnable() { + var _this = this; + this._super(); + if (this._mesh && !this._mesh.loaded) { + this.disableRender(); + this._mesh.once("load", (function() { + if (!_this.isValid) return; + _this._setMesh(_this._mesh); + _this.markForRender(true); + })); + cc.assetManager.postLoadNative(this._mesh); + } else this._setMesh(this._mesh); + this._updateRenderNode(); + this._updateMaterial(); + }, + onDestroy: function onDestroy() { + this._setMesh(null); + cc.pool.assembler.put(this._assembler); + }, + _updateRenderNode: function _updateRenderNode() { + this._assembler.setRenderNode(this.node); + }, + _setMesh: function _setMesh(mesh) { + cc.geomUtils && mesh && _aabb["default"].fromPoints(this._boundingBox, mesh._minPos, mesh._maxPos); + this._mesh && this._mesh.off("init-format", this._updateMeshAttribute, this); + mesh && mesh.on("init-format", this._updateMeshAttribute, this); + this._mesh = mesh; + this._assembler && (this._assembler._worldDatas = {}); + this._updateMeshAttribute(); + }, + _getDefaultMaterial: function _getDefaultMaterial() { + return Material.getBuiltinMaterial("unlit"); + }, + _validateRender: function _validateRender() { + var mesh = this._mesh; + if (mesh && mesh._subDatas.length > 0) return; + this.disableRender(); + }, + _updateMaterial: function _updateMaterial() { + var textures = this.textures; + if (textures && textures.length > 0) { + var defaultMaterial = this._getDefaultMaterial(); + for (var i = 0; i < textures.length; i++) { + var material = this._materials[i]; + if (material && material._uuid !== defaultMaterial._uuid) continue; + if (!material) { + material = _materialVariant["default"].create(defaultMaterial, this); + this.setMaterial(i, material); + } + material.setProperty("diffuseTexture", textures[i]); + } + } + this._updateReceiveShadow(); + this._updateCastShadow(); + this._updateMeshAttribute(); + }, + _updateReceiveShadow: function _updateReceiveShadow() { + var materials = this.getMaterials(); + for (var i = 0; i < materials.length; i++) materials[i].define("CC_USE_SHADOW_MAP", this._receiveShadows, void 0, true); + }, + _updateCastShadow: function _updateCastShadow() { + var materials = this.getMaterials(); + for (var i = 0; i < materials.length; i++) materials[i].define("CC_CASTING_SHADOW", this._shadowCastingMode === ShadowCastingMode.ON, void 0, true); + }, + _updateMeshAttribute: function _updateMeshAttribute() { + var subDatas = this._mesh && this._mesh.subDatas; + if (!subDatas) return; + var materials = this.getMaterials(); + for (var i = 0; i < materials.length; i++) { + if (!subDatas[i]) break; + var vfm = subDatas[i].vfm; + var material = materials[i]; + material.define("CC_USE_ATTRIBUTE_COLOR", !!vfm.element(_gfx["default"].ATTR_COLOR), void 0, true); + material.define("CC_USE_ATTRIBUTE_UV0", !!vfm.element(_gfx["default"].ATTR_UV0), void 0, true); + material.define("CC_USE_ATTRIBUTE_NORMAL", !!vfm.element(_gfx["default"].ATTR_NORMAL), void 0, true); + material.define("CC_USE_ATTRIBUTE_TANGENT", !!vfm.element(_gfx["default"].ATTR_TANGENT), void 0, true); + } + true; + for (var name in this._debugDatas) this._debugDatas[name].length = 0; + false; + }, + _checkBacth: function _checkBacth() {} + }); + true; + var BLACK_COLOR = cc.Color.BLACK; + var RED_COLOR = cc.Color.RED; + var v3_tmp = [ cc.v3(), cc.v3() ]; + var mat4_tmp = cc.mat4(); + var createDebugDataFns = { + normal: function normal(comp, ia, subData, subIndex) { + var oldVfm = subData.vfm; + var normalEle = oldVfm.element(_gfx["default"].ATTR_NORMAL); + var posEle = oldVfm.element(_gfx["default"].ATTR_POSITION); + var jointEle = oldVfm.element(_gfx["default"].ATTR_JOINTS); + var weightEle = oldVfm.element(_gfx["default"].ATTR_WEIGHTS); + if (!normalEle || !posEle) return; + var indices = []; + var vbData = []; + var lineLength = 100; + _vec["default"].set(v3_tmp[0], 5, 0, 0); + _mat["default"].invert(mat4_tmp, comp.node._worldMatrix); + _vec["default"].transformMat4Normal(v3_tmp[0], v3_tmp[0], mat4_tmp); + lineLength = v3_tmp[0].mag(); + var mesh = comp.mesh; + var posData = mesh._getAttrMeshData(subIndex, _gfx["default"].ATTR_POSITION); + var normalData = mesh._getAttrMeshData(subIndex, _gfx["default"].ATTR_NORMAL); + var jointData = mesh._getAttrMeshData(subIndex, _gfx["default"].ATTR_JOINTS); + var weightData = mesh._getAttrMeshData(subIndex, _gfx["default"].ATTR_WEIGHTS); + var vertexCount = posData.length / posEle.num; + for (var i = 0; i < vertexCount; i++) { + var normalIndex = i * normalEle.num; + var posIndex = i * posEle.num; + _vec["default"].set(v3_tmp[0], normalData[normalIndex], normalData[normalIndex + 1], normalData[normalIndex + 2]); + _vec["default"].set(v3_tmp[1], posData[posIndex], posData[posIndex + 1], posData[posIndex + 2]); + _vec["default"].scaleAndAdd(v3_tmp[0], v3_tmp[1], v3_tmp[0], lineLength); + for (var lineIndex = 0; lineIndex < 2; lineIndex++) { + vbData.push(v3_tmp[lineIndex].x, v3_tmp[lineIndex].y, v3_tmp[lineIndex].z); + if (jointEle) { + var jointIndex = i * jointEle.num; + for (var j = 0; j < jointEle.num; j++) vbData.push(jointData[jointIndex + j]); + } + if (weightEle) { + var weightIndex = i * weightEle.num; + for (var _j = 0; _j < weightEle.num; _j++) vbData.push(weightData[weightIndex + _j]); + } + } + indices.push(2 * i, 2 * i + 1); + } + var formatOpts = [ { + name: _gfx["default"].ATTR_POSITION, + type: _gfx["default"].ATTR_TYPE_FLOAT32, + num: 3 + } ]; + jointEle && formatOpts.push({ + name: _gfx["default"].ATTR_JOINTS, + type: _gfx["default"].ATTR_TYPE_FLOAT32, + num: jointEle.num + }); + weightEle && formatOpts.push({ + name: _gfx["default"].ATTR_WEIGHTS, + type: _gfx["default"].ATTR_TYPE_FLOAT32, + num: weightEle.num + }); + var gfxVFmt = new _gfx["default"].VertexFormat(formatOpts); + var vb = new _gfx["default"].VertexBuffer(Renderer.device, gfxVFmt, _gfx["default"].USAGE_STATIC, new Float32Array(vbData)); + var ibData = new Uint16Array(indices); + var ib = new _gfx["default"].IndexBuffer(Renderer.device, _gfx["default"].INDEX_FMT_UINT16, _gfx["default"].USAGE_STATIC, ibData, ibData.length); + var m = _materialVariant["default"].createWithBuiltin("unlit"); + m.setProperty("diffuseColor", RED_COLOR); + return { + material: m, + ia: new _inputAssembler["default"](vb, ib, _gfx["default"].PT_LINES) + }; + }, + wireFrame: function wireFrame(comp, ia, subData) { + var oldIbData = subData.getIData(Uint16Array); + var m = _materialVariant["default"].createWithBuiltin("unlit"); + m.setProperty("diffuseColor", BLACK_COLOR); + var indices = []; + for (var i = 0; i < oldIbData.length; i += 3) { + var a = oldIbData[i + 0]; + var b = oldIbData[i + 1]; + var c = oldIbData[i + 2]; + indices.push(a, b, b, c, c, a); + } + var ibData = new Uint16Array(indices); + var ib = new _gfx["default"].IndexBuffer(Renderer.device, _gfx["default"].INDEX_FMT_UINT16, _gfx["default"].USAGE_STATIC, ibData, ibData.length); + return { + material: m, + ia: new _inputAssembler["default"](ia._vertexBuffer, ib, _gfx["default"].PT_LINES) + }; + } + }; + var _proto = MeshRenderer.prototype; + _proto._updateDebugDatas = function() { + var debugDatas = this._debugDatas; + var subMeshes = this._mesh.subMeshes; + var subDatas = this._mesh._subDatas; + for (var name in debugDatas) { + var debugData = debugDatas[name]; + if (debugData.length === subMeshes.length) continue; + if (!cc.macro["SHOW_MESH_" + name.toUpperCase()]) continue; + debugData.length = subMeshes.length; + for (var i = 0; i < subMeshes.length; i++) debugData[i] = createDebugDataFns[name](this, subMeshes[i], subDatas[i], i); + } + }; + cc.MeshRenderer = module.exports = MeshRenderer; + }), { + "../../renderer/core/input-assembler": 363, + "../../renderer/gfx": 373, + "../assets/material/CCMaterial": 125, + "../assets/material/material-variant": 132, + "../components/CCRenderComponent": 161, + "../geom-utils/aabb": 191, + "../renderer": 272, + "../renderer/render-flow": 273, + "../value-types/mat4": 342, + "../value-types/vec3": 350, + "./CCMesh": 208 + } ], + 210: [ (function(require, module, exports) { + "use strict"; + require("./CCMesh"); + true; + require("./CCMeshRenderer"); + require("./mesh-renderer"); + }), { + "./CCMesh": 208, + "./CCMeshRenderer": 209, + "./mesh-renderer": 212 + } ], + 211: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports.BufferRange = void 0; + exports.MeshData = MeshData; + exports.VertexFormat = exports.VertexBundle = exports.Primitive = void 0; + var _gfx = _interopRequireDefault(require("../../renderer/gfx")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + var BufferRange = cc.Class({ + name: "cc.BufferRange", + properties: { + offset: 0, + length: 0 + } + }); + exports.BufferRange = BufferRange; + var VertexFormat = cc.Class({ + name: "cc.mesh.VertexFormat", + properties: { + name: "", + type: -1, + num: -1, + normalize: false + } + }); + exports.VertexFormat = VertexFormat; + var VertexBundle = cc.Class({ + name: "cc.mesh.VertexBundle", + properties: { + data: { + default: null, + type: BufferRange + }, + formats: { + default: [], + type: VertexFormat + }, + verticesCount: 0 + } + }); + exports.VertexBundle = VertexBundle; + var Primitive = cc.Class({ + name: "cc.mesh.Primitive", + properties: { + vertexBundleIndices: { + default: [], + type: cc.Float + }, + data: { + default: null, + type: BufferRange + }, + indexUnit: _gfx["default"].INDEX_FMT_UINT16, + topology: _gfx["default"].PT_TRIANGLES + } + }); + exports.Primitive = Primitive; + function MeshData() { + this.vData = null; + this.float32VData = null; + this.uint32VData = null; + this.iData = null; + this.uint16IData = null; + this.vfm = null; + this.offset = 0; + this.vb = null; + this.ib = null; + this.vDirty = false; + this.iDirty = false; + this.enable = true; + } + MeshData.prototype.setVData = function(data) { + this.vData = data; + this.float32VData = null; + this.uint32VData = null; + }; + MeshData.prototype.getVData = function(format) { + if (format === Float32Array) { + this.float32VData || (this.float32VData = new Float32Array(this.vData.buffer, this.vData.byteOffset, this.vData.byteLength / 4)); + return this.float32VData; + } + if (format === Uint32Array) { + this.uint32VData || (this.uint32VData = new Uint32Array(this.vData.buffer, this.vData.byteOffset, this.vData.byteLength / 4)); + return this.uint32VData; + } + return this.vData; + }; + MeshData.prototype.getIData = function(format) { + if (format === Uint16Array) { + this.uint16IData || (this.uint16IData = new Uint16Array(this.iData.buffer, this.iData.byteOffset, this.iData.byteLength / 2)); + return this.uint16IData; + } + return this.iData; + }; + }), { + "../../renderer/gfx": 373 + } ], + 212: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _assembler = _interopRequireDefault(require("../renderer/assembler")); + var _gfx = _interopRequireDefault(require("../../renderer/gfx")); + var _vec = _interopRequireDefault(require("../value-types/vec3")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + _setPrototypeOf(subClass, superClass); + } + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + return _setPrototypeOf(o, p); + } + var MeshRenderer = require("./CCMeshRenderer"); + var _tmp_vec3 = new _vec["default"](); + var MeshRendererAssembler = (function(_Assembler) { + _inheritsLoose(MeshRendererAssembler, _Assembler); + function MeshRendererAssembler() { + return _Assembler.apply(this, arguments) || this; + } + var _proto = MeshRendererAssembler.prototype; + _proto.init = function init(renderComp) { + _Assembler.prototype.init.call(this, renderComp); + this._worldDatas = {}; + this._renderNode = null; + }; + _proto.setRenderNode = function setRenderNode(node) { + this._renderNode = node; + }; + _proto.fillBuffers = function fillBuffers(comp, renderer) { + if (!comp.mesh) return; + comp.mesh._uploadData(); + var isCullingMaskSame = renderer.cullingMask === comp.node._cullingMask; + var enableAutoBatch = comp.enableAutoBatch; + var materials = comp._materials; + var submeshes = comp.mesh._subMeshes; + var subDatas = comp.mesh.subDatas; + for (var i = 0; i < submeshes.length; i++) { + var ia = submeshes[i]; + var meshData = subDatas[i]; + var material = materials[i] || materials[0]; + if (!enableAutoBatch || !meshData.canBatch || ia._primitiveType !== _gfx["default"].PT_TRIANGLES) { + renderer._flush(); + renderer.material = material; + renderer.cullingMask = comp.node._cullingMask; + renderer.node = this._renderNode; + renderer._flushIA(ia); + continue; + } + isCullingMaskSame && material.getHash() === renderer.material.getHash() || renderer._flush(); + renderer.material = material; + renderer.cullingMask = comp.node._cullingMask; + renderer.node = renderer._dummyNode; + this._fillBuffer(comp, meshData, renderer, i); + } + if ((true, cc.macro.SHOW_MESH_WIREFRAME || cc.macro.SHOW_MESH_NORMAL) && !(comp.node._cullingMask & 1 << cc.Node.BuiltinGroupIndex.DEBUG)) { + renderer._flush(); + renderer.node = this._renderNode; + comp._updateDebugDatas(); + cc.macro.SHOW_MESH_WIREFRAME && this._drawDebugDatas(comp, renderer, "wireFrame"); + cc.macro.SHOW_MESH_NORMAL && this._drawDebugDatas(comp, renderer, "normal"); + } + }; + _proto._fillBuffer = function _fillBuffer(comp, meshData, renderer, dataIndex) { + var vData = meshData.getVData(Float32Array); + var vtxFormat = meshData.vfm; + var vertexCount = vData.byteLength / vtxFormat._bytes | 0; + var indices = meshData.getIData(Uint16Array); + var indicesCount = indices.length; + var buffer = renderer.getBuffer("mesh", vtxFormat); + var offsetInfo = buffer.request(vertexCount, indicesCount); + var indiceOffset = offsetInfo.indiceOffset, vertexOffset = offsetInfo.byteOffset >> 2, vertexId = offsetInfo.vertexOffset, vbuf = buffer._vData, ibuf = buffer._iData; + !renderer.worldMatDirty && this._worldDatas[dataIndex] || this._updateWorldVertices(dataIndex, vertexCount, vData, vtxFormat, comp.node._worldMatrix); + vbuf.set(this._worldDatas[dataIndex], vertexOffset); + for (var i = 0; i < indicesCount; i++) ibuf[indiceOffset + i] = vertexId + indices[i]; + }; + _proto._updateWorldVertices = function _updateWorldVertices(dataIndex, vertexCount, local, vtxFormat, wolrdMatrix) { + var world = this._worldDatas[dataIndex]; + if (!world) { + world = this._worldDatas[dataIndex] = new Float32Array(local.length); + world.set(local); + } + var floatCount = vtxFormat._bytes / 4; + var elements = vtxFormat._elements; + for (var i = 0, n = elements.length; i < n; i++) { + var element = elements[i]; + var attrOffset = element.offset / 4; + if (element.name === _gfx["default"].ATTR_POSITION || element.name === _gfx["default"].ATTR_NORMAL) { + var transformMat4 = element.name === _gfx["default"].ATTR_NORMAL ? _vec["default"].transformMat4Normal : _vec["default"].transformMat4; + for (var j = 0; j < vertexCount; j++) { + var offset = j * floatCount + attrOffset; + _tmp_vec3.x = local[offset]; + _tmp_vec3.y = local[offset + 1]; + _tmp_vec3.z = local[offset + 2]; + transformMat4(_tmp_vec3, _tmp_vec3, wolrdMatrix); + world[offset] = _tmp_vec3.x; + world[offset + 1] = _tmp_vec3.y; + world[offset + 2] = _tmp_vec3.z; + } + } + } + }; + _proto._drawDebugDatas = function _drawDebugDatas(comp, renderer, name) { + var debugDatas = comp._debugDatas[name]; + if (!debugDatas) return; + for (var i = 0; i < debugDatas.length; i++) { + var debugData = debugDatas[i]; + if (!debugData) continue; + var material = debugData.material; + renderer.material = material; + renderer._flushIA(debugData.ia); + } + }; + return MeshRendererAssembler; + })(_assembler["default"]); + exports["default"] = MeshRendererAssembler; + _assembler["default"].register(MeshRenderer, MeshRendererAssembler); + module.exports = exports["default"]; + }), { + "../../renderer/gfx": 373, + "../renderer/assembler": 269, + "../value-types/vec3": 350, + "./CCMeshRenderer": 209 + } ], + 213: [ (function(require, module, exports) { + "use strict"; + var CompScheduler = require("./component-scheduler"); + var Flags = require("./platform/CCObject").Flags; + var js = require("./platform/js"); + var callerFunctor = false; + var MAX_POOL_SIZE = 4; + var IsPreloadStarted = Flags.IsPreloadStarted; + var IsOnLoadStarted = Flags.IsOnLoadStarted; + var IsOnLoadCalled = Flags.IsOnLoadCalled; + var Deactivating = Flags.Deactivating; + var callPreloadInTryCatch = false; + var callOnLoadInTryCatch = false; + var callOnDestroyInTryCatch = false; + var callOnFocusInTryCatch = false; + var callOnLostFocusInTryCatch = false; + var UnsortedInvoker = cc.Class({ + extends: CompScheduler.LifeCycleInvoker, + add: function add(comp) { + this._zero.array.push(comp); + }, + remove: function remove(comp) { + this._zero.fastRemove(comp); + }, + cancelInactive: function cancelInactive(flagToClear) { + CompScheduler.LifeCycleInvoker.stableRemoveInactive(this._zero, flagToClear); + }, + invoke: function invoke() { + this._invoke(this._zero); + this._zero.array.length = 0; + } + }); + var invokePreload = CompScheduler.createInvokeImpl("c.__preload();"); + var invokeOnLoad = CompScheduler.createInvokeImpl("c.onLoad();c._objFlags|=" + IsOnLoadCalled, false, IsOnLoadCalled); + var activateTasksPool = new js.Pool(MAX_POOL_SIZE); + activateTasksPool.get = function getActivateTask() { + var task = this._get() || { + preload: new UnsortedInvoker(invokePreload), + onLoad: new CompScheduler.OneOffInvoker(invokeOnLoad), + onEnable: new CompScheduler.OneOffInvoker(CompScheduler.invokeOnEnable) + }; + task.preload._zero.i = -1; + var invoker = task.onLoad; + invoker._zero.i = -1; + invoker._neg.i = -1; + invoker._pos.i = -1; + invoker = task.onEnable; + invoker._zero.i = -1; + invoker._neg.i = -1; + invoker._pos.i = -1; + return task; + }; + function _componentCorrupted(node, comp, index) { + false; + comp ? node._removeComponent(comp) : js.array.removeAt(node._components, index); + } + function _onLoadInEditor(comp) { + if (comp.onLoad && !cc.engine._isPlaying) { + var focused = Editor.Selection.curActivate("node") === comp.node.uuid; + focused ? comp.onFocusInEditor && callOnFocusInTryCatch(comp) : comp.onLostFocusInEditor && callOnLostFocusInTryCatch(comp); + } + true; + _Scene.AssetsWatcher.start(comp); + } + function ctor() { + this._activatingStack = []; + } + var NodeActivator = cc.Class({ + ctor: ctor, + reset: ctor, + _activateNodeRecursively: function _activateNodeRecursively(node, preloadInvoker, onLoadInvoker, onEnableInvoker) { + if (node._objFlags & Deactivating) { + cc.errorID(3816, node.name); + return; + } + node._activeInHierarchy = true; + var originCount = node._components.length; + for (var i = 0; i < originCount; ++i) { + var component = node._components[i]; + if (component instanceof cc.Component) this.activateComp(component, preloadInvoker, onLoadInvoker, onEnableInvoker); else { + _componentCorrupted(node, component, i); + --i; + --originCount; + } + } + node._childArrivalOrder = node._children.length; + for (var _i = 0, len = node._children.length; _i < len; ++_i) { + var child = node._children[_i]; + child._localZOrder = 4294901760 & child._localZOrder | _i + 1; + child._active && this._activateNodeRecursively(child, preloadInvoker, onLoadInvoker, onEnableInvoker); + } + node._onPostActivated(true); + }, + _deactivateNodeRecursively: function _deactivateNodeRecursively(node) { + false; + node._objFlags |= Deactivating; + node._activeInHierarchy = false; + var originCount = node._components.length; + for (var c = 0; c < originCount; ++c) { + var component = node._components[c]; + if (component._enabled) { + cc.director._compScheduler.disableComp(component); + if (node._activeInHierarchy) { + node._objFlags &= ~Deactivating; + return; + } + } + } + for (var i = 0, len = node._children.length; i < len; ++i) { + var child = node._children[i]; + if (child._activeInHierarchy) { + this._deactivateNodeRecursively(child); + if (node._activeInHierarchy) { + node._objFlags &= ~Deactivating; + return; + } + } + } + node._onPostActivated(false); + node._objFlags &= ~Deactivating; + }, + activateNode: function activateNode(node, active) { + if (active) { + var task = activateTasksPool.get(); + this._activatingStack.push(task); + this._activateNodeRecursively(node, task.preload, task.onLoad, task.onEnable); + task.preload.invoke(); + task.onLoad.invoke(); + task.onEnable.invoke(); + this._activatingStack.pop(); + activateTasksPool.put(task); + } else { + this._deactivateNodeRecursively(node); + var stack = this._activatingStack; + for (var i = 0; i < stack.length; i++) { + var lastTask = stack[i]; + lastTask.preload.cancelInactive(IsPreloadStarted); + lastTask.onLoad.cancelInactive(IsOnLoadStarted); + lastTask.onEnable.cancelInactive(); + } + } + node.emit("active-in-hierarchy-changed", node); + }, + activateComp: function(comp, preloadInvoker, onLoadInvoker, onEnableInvoker) { + if (!cc.isValid(comp, true)) return; + if (!(comp._objFlags & IsPreloadStarted)) { + comp._objFlags |= IsPreloadStarted; + comp.__preload && (preloadInvoker ? preloadInvoker.add(comp) : comp.__preload()); + } + if (!(comp._objFlags & IsOnLoadStarted)) { + comp._objFlags |= IsOnLoadStarted; + if (comp.onLoad) if (onLoadInvoker) onLoadInvoker.add(comp); else { + comp.onLoad(); + comp._objFlags |= IsOnLoadCalled; + } else comp._objFlags |= IsOnLoadCalled; + } + if (comp._enabled) { + var deactivatedOnLoading = !comp.node._activeInHierarchy; + if (deactivatedOnLoading) return; + cc.director._compScheduler.enableComp(comp, onEnableInvoker); + } + }, + destroyComp: function(comp) { + cc.director._compScheduler.disableComp(comp); + comp.onDestroy && comp._objFlags & IsOnLoadCalled && comp.onDestroy(); + }, + resetComp: false + }); + module.exports = NodeActivator; + }), { + "./component-scheduler": 144, + "./platform/CCObject": 246, + "./platform/js": 261, + "./utils/misc": 325 + } ], + 214: [ (function(require, module, exports) { + "use strict"; + var PTM_RATIO = require("./CCPhysicsTypes").PTM_RATIO; + var ContactType = require("./CCPhysicsTypes").ContactType; + var pools = []; + var pointCache = [ cc.v2(), cc.v2() ]; + var b2worldmanifold = new b2.WorldManifold(); + var worldmanifold = { + points: [], + separations: [], + normal: cc.v2() + }; + function ManifoldPoint() { + this.localPoint = cc.v2(); + this.normalImpulse = 0; + this.tangentImpulse = 0; + } + var manifoldPointCache = [ new ManifoldPoint(), new ManifoldPoint() ]; + var b2manifold = new b2.Manifold(); + var manifold = { + type: 0, + localPoint: cc.v2(), + localNormal: cc.v2(), + points: [] + }; + var impulse = { + normalImpulses: [], + tangentImpulses: [] + }; + function PhysicsContact() {} + PhysicsContact.prototype.init = function(b2contact) { + this.colliderA = b2contact.GetFixtureA().collider; + this.colliderB = b2contact.GetFixtureB().collider; + this.disabled = false; + this.disabledOnce = false; + this._impulse = null; + this._inverted = false; + this._b2contact = b2contact; + b2contact._contact = this; + }; + PhysicsContact.prototype.reset = function() { + this.setTangentSpeed(0); + this.resetFriction(); + this.resetRestitution(); + this.colliderA = null; + this.colliderB = null; + this.disabled = false; + this._impulse = null; + this._b2contact._contact = null; + this._b2contact = null; + }; + PhysicsContact.prototype.getWorldManifold = function() { + var points = worldmanifold.points; + var separations = worldmanifold.separations; + var normal = worldmanifold.normal; + this._b2contact.GetWorldManifold(b2worldmanifold); + var b2points = b2worldmanifold.points; + var b2separations = b2worldmanifold.separations; + var count = this._b2contact.GetManifold().pointCount; + points.length = separations.length = count; + for (var i = 0; i < count; i++) { + var p = pointCache[i]; + p.x = b2points[i].x * PTM_RATIO; + p.y = b2points[i].y * PTM_RATIO; + points[i] = p; + separations[i] = b2separations[i] * PTM_RATIO; + } + normal.x = b2worldmanifold.normal.x; + normal.y = b2worldmanifold.normal.y; + if (this._inverted) { + normal.x *= -1; + normal.y *= -1; + } + return worldmanifold; + }; + PhysicsContact.prototype.getManifold = function() { + var points = manifold.points; + var localNormal = manifold.localNormal; + var localPoint = manifold.localPoint; + var b2manifold = this._b2contact.GetManifold(); + var b2points = b2manifold.points; + var count = points.length = b2manifold.pointCount; + for (var i = 0; i < count; i++) { + var p = manifoldPointCache[i]; + var b2p = b2points[i]; + p.localPoint.x = b2p.localPoint.x * PTM_RATIO; + p.localPoint.Y = b2p.localPoint.Y * PTM_RATIO; + p.normalImpulse = b2p.normalImpulse * PTM_RATIO; + p.tangentImpulse = b2p.tangentImpulse; + points[i] = p; + } + localPoint.x = b2manifold.localPoint.x * PTM_RATIO; + localPoint.y = b2manifold.localPoint.y * PTM_RATIO; + localNormal.x = b2manifold.localNormal.x; + localNormal.y = b2manifold.localNormal.y; + manifold.type = b2manifold.type; + if (this._inverted) { + localNormal.x *= -1; + localNormal.y *= -1; + } + return manifold; + }; + PhysicsContact.prototype.getImpulse = function() { + var b2impulse = this._impulse; + if (!b2impulse) return null; + var normalImpulses = impulse.normalImpulses; + var tangentImpulses = impulse.tangentImpulses; + var count = b2impulse.count; + for (var i = 0; i < count; i++) { + normalImpulses[i] = b2impulse.normalImpulses[i] * PTM_RATIO; + tangentImpulses[i] = b2impulse.tangentImpulses[i]; + } + tangentImpulses.length = normalImpulses.length = count; + return impulse; + }; + PhysicsContact.prototype.emit = function(contactType) { + var func; + switch (contactType) { + case ContactType.BEGIN_CONTACT: + func = "onBeginContact"; + break; + + case ContactType.END_CONTACT: + func = "onEndContact"; + break; + + case ContactType.PRE_SOLVE: + func = "onPreSolve"; + break; + + case ContactType.POST_SOLVE: + func = "onPostSolve"; + } + var colliderA = this.colliderA; + var colliderB = this.colliderB; + var bodyA = colliderA.body; + var bodyB = colliderB.body; + var comps; + var i, l, comp; + if (bodyA.enabledContactListener) { + comps = bodyA.node._components; + this._inverted = false; + for (i = 0, l = comps.length; i < l; i++) { + comp = comps[i]; + comp[func] && comp[func](this, colliderA, colliderB); + } + } + if (bodyB.enabledContactListener) { + comps = bodyB.node._components; + this._inverted = true; + for (i = 0, l = comps.length; i < l; i++) { + comp = comps[i]; + comp[func] && comp[func](this, colliderB, colliderA); + } + } + if (this.disabled || this.disabledOnce) { + this.setEnabled(false); + this.disabledOnce = false; + } + }; + PhysicsContact.get = function(b2contact) { + var c; + c = 0 === pools.length ? new cc.PhysicsContact() : pools.pop(); + c.init(b2contact); + return c; + }; + PhysicsContact.put = function(b2contact) { + var c = b2contact._contact; + if (!c) return; + pools.push(c); + c.reset(); + }; + var _p = PhysicsContact.prototype; + _p.setEnabled = function(value) { + this._b2contact.SetEnabled(value); + }; + _p.isTouching = function() { + return this._b2contact.IsTouching(); + }; + _p.setTangentSpeed = function(value) { + this._b2contact.SetTangentSpeed(value / PTM_RATIO); + }; + _p.getTangentSpeed = function() { + return this._b2contact.GetTangentSpeed() * PTM_RATIO; + }; + _p.setFriction = function(value) { + this._b2contact.SetFriction(value); + }; + _p.getFriction = function() { + return this._b2contact.GetFriction(); + }; + _p.resetFriction = function() { + return this._b2contact.ResetFriction(); + }; + _p.setRestitution = function(value) { + this._b2contact.SetRestitution(value); + }; + _p.getRestitution = function() { + return this._b2contact.GetRestitution(); + }; + _p.resetRestitution = function() { + return this._b2contact.ResetRestitution(); + }; + PhysicsContact.ContactType = ContactType; + cc.PhysicsContact = module.exports = PhysicsContact; + }), { + "./CCPhysicsTypes": 216 + } ], + 215: [ (function(require, module, exports) { + "use strict"; + var PhysicsTypes = require("./CCPhysicsTypes"); + var ContactType = PhysicsTypes.ContactType; + var BodyType = PhysicsTypes.BodyType; + var RayCastType = PhysicsTypes.RayCastType; + var DrawBits = PhysicsTypes.DrawBits; + var PTM_RATIO = PhysicsTypes.PTM_RATIO; + var ANGLE_TO_PHYSICS_ANGLE = PhysicsTypes.ANGLE_TO_PHYSICS_ANGLE; + var PHYSICS_ANGLE_TO_ANGLE = PhysicsTypes.PHYSICS_ANGLE_TO_ANGLE; + var convertToNodeRotation = require("./utils").convertToNodeRotation; + var DebugDraw = require("./platform/CCPhysicsDebugDraw"); + var b2_aabb_tmp = new b2.AABB(); + var b2_vec2_tmp1 = new b2.Vec2(); + var b2_vec2_tmp2 = new b2.Vec2(); + var vec2_tmp = cc.v2(); + var PhysicsManager = cc.Class({ + mixins: [ cc.EventTarget ], + statics: { + DrawBits: DrawBits, + PTM_RATIO: PTM_RATIO, + VELOCITY_ITERATIONS: 10, + POSITION_ITERATIONS: 10, + FIXED_TIME_STEP: 1 / 60, + MAX_ACCUMULATOR: .2 + }, + ctor: function ctor() { + this._debugDrawFlags = 0; + this._debugDrawer = null; + this._world = null; + this._bodies = []; + this._joints = []; + this._contactMap = {}; + this._contactID = 0; + this._delayEvents = []; + this._accumulator = 0; + cc.director._scheduler && cc.director._scheduler.enableForTarget(this); + this.enabledAccumulator = false; + }, + pushDelayEvent: function pushDelayEvent(target, func, args) { + this._steping ? this._delayEvents.push({ + target: target, + func: func, + args: args + }) : target[func].apply(target, args); + }, + update: function update(dt) { + var world = this._world; + if (!world || !this.enabled) return; + this.emit("before-step"); + this._steping = true; + var velocityIterations = PhysicsManager.VELOCITY_ITERATIONS; + var positionIterations = PhysicsManager.POSITION_ITERATIONS; + if (this.enabledAccumulator) { + this._accumulator += dt; + var FIXED_TIME_STEP = PhysicsManager.FIXED_TIME_STEP; + var MAX_ACCUMULATOR = PhysicsManager.MAX_ACCUMULATOR; + this._accumulator > MAX_ACCUMULATOR && (this._accumulator = MAX_ACCUMULATOR); + while (this._accumulator > FIXED_TIME_STEP) { + world.Step(FIXED_TIME_STEP, velocityIterations, positionIterations); + this._accumulator -= FIXED_TIME_STEP; + } + } else { + var timeStep = 1 / cc.game.config["frameRate"]; + world.Step(timeStep, velocityIterations, positionIterations); + } + if (this.debugDrawFlags) { + this._checkDebugDrawValid(); + this._debugDrawer.clear(); + world.DrawDebugData(); + } + this._steping = false; + var events = this._delayEvents; + for (var i = 0, l = events.length; i < l; i++) { + var event = events[i]; + event.target[event.func].apply(event.target, event.args); + } + events.length = 0; + this._syncNode(); + }, + testPoint: function testPoint(point) { + var x = b2_vec2_tmp1.x = point.x / PTM_RATIO; + var y = b2_vec2_tmp1.y = point.y / PTM_RATIO; + var d = .2 / PTM_RATIO; + b2_aabb_tmp.lowerBound.x = x - d; + b2_aabb_tmp.lowerBound.y = y - d; + b2_aabb_tmp.upperBound.x = x + d; + b2_aabb_tmp.upperBound.y = y + d; + var callback = this._aabbQueryCallback; + callback.init(b2_vec2_tmp1); + this._world.QueryAABB(callback, b2_aabb_tmp); + var fixture = callback.getFixture(); + if (fixture) return fixture.collider; + return null; + }, + testAABB: function testAABB(rect) { + b2_aabb_tmp.lowerBound.x = rect.xMin / PTM_RATIO; + b2_aabb_tmp.lowerBound.y = rect.yMin / PTM_RATIO; + b2_aabb_tmp.upperBound.x = rect.xMax / PTM_RATIO; + b2_aabb_tmp.upperBound.y = rect.yMax / PTM_RATIO; + var callback = this._aabbQueryCallback; + callback.init(); + this._world.QueryAABB(callback, b2_aabb_tmp); + var fixtures = callback.getFixtures(); + var colliders = fixtures.map((function(fixture) { + return fixture.collider; + })); + return colliders; + }, + rayCast: function rayCast(p1, p2, type) { + if (p1.equals(p2)) return []; + type = type || RayCastType.Closest; + b2_vec2_tmp1.x = p1.x / PTM_RATIO; + b2_vec2_tmp1.y = p1.y / PTM_RATIO; + b2_vec2_tmp2.x = p2.x / PTM_RATIO; + b2_vec2_tmp2.y = p2.y / PTM_RATIO; + var callback = this._raycastQueryCallback; + callback.init(type); + this._world.RayCast(callback, b2_vec2_tmp1, b2_vec2_tmp2); + var fixtures = callback.getFixtures(); + if (fixtures.length > 0) { + var points = callback.getPoints(); + var normals = callback.getNormals(); + var fractions = callback.getFractions(); + var results = []; + for (var i = 0, l = fixtures.length; i < l; i++) { + var fixture = fixtures[i]; + var collider = fixture.collider; + if (type === RayCastType.AllClosest) { + var result = results.find((function(result) { + return result.collider === collider; + })); + if (result) { + if (fractions[i] < result.fraction) { + result.fixtureIndex = collider._getFixtureIndex(fixture); + result.point.x = points[i].x * PTM_RATIO; + result.point.y = points[i].y * PTM_RATIO; + result.normal.x = normals[i].x; + result.normal.y = normals[i].y; + result.fraction = fractions[i]; + } + continue; + } + } + results.push({ + collider: collider, + fixtureIndex: collider._getFixtureIndex(fixture), + point: cc.v2(points[i].x * PTM_RATIO, points[i].y * PTM_RATIO), + normal: cc.v2(normals[i]), + fraction: fractions[i] + }); + } + return results; + } + return []; + }, + syncPosition: function syncPosition() { + var bodies = this._bodies; + for (var i = 0; i < bodies.length; i++) bodies[i].syncPosition(); + }, + syncRotation: function syncRotation() { + var bodies = this._bodies; + for (var i = 0; i < bodies.length; i++) bodies[i].syncRotation(); + }, + _registerContactFixture: function _registerContactFixture(fixture) { + this._contactListener.registerContactFixture(fixture); + }, + _unregisterContactFixture: function _unregisterContactFixture(fixture) { + this._contactListener.unregisterContactFixture(fixture); + }, + _addBody: function _addBody(body, bodyDef) { + var world = this._world; + var node = body.node; + if (!world || !node) return; + body._b2Body = world.CreateBody(bodyDef); + body._b2Body.body = body; + this._bodies.push(body); + }, + _removeBody: function _removeBody(body) { + var world = this._world; + if (!world) return; + body._b2Body.body = null; + world.DestroyBody(body._b2Body); + body._b2Body = null; + cc.js.array.remove(this._bodies, body); + }, + _addJoint: function _addJoint(joint, jointDef) { + var b2joint = this._world.CreateJoint(jointDef); + if (!b2joint) return; + b2joint._joint = joint; + joint._joint = b2joint; + this._joints.push(joint); + }, + _removeJoint: function _removeJoint(joint) { + joint._isValid() && this._world.DestroyJoint(joint._joint); + joint._joint && (joint._joint._joint = null); + cc.js.array.remove(this._joints, joint); + }, + _initCallback: function _initCallback() { + if (!this._world) { + cc.warn("Please init PhysicsManager first"); + return; + } + if (this._contactListener) return; + var listener = new cc.PhysicsContactListener(); + listener.setBeginContact(this._onBeginContact); + listener.setEndContact(this._onEndContact); + listener.setPreSolve(this._onPreSolve); + listener.setPostSolve(this._onPostSolve); + this._world.SetContactListener(listener); + this._contactListener = listener; + this._aabbQueryCallback = new cc.PhysicsAABBQueryCallback(); + this._raycastQueryCallback = new cc.PhysicsRayCastCallback(); + }, + _init: function _init() { + this.enabled = true; + this.debugDrawFlags = DrawBits.e_shapeBit; + }, + _getWorld: function _getWorld() { + return this._world; + }, + _syncNode: function _syncNode() { + var bodies = this._bodies; + for (var i = 0, l = bodies.length; i < l; i++) { + var body = bodies[i]; + var node = body.node; + var b2body = body._b2Body; + var pos = b2body.GetPosition(); + vec2_tmp.x = pos.x * PTM_RATIO; + vec2_tmp.y = pos.y * PTM_RATIO; + var angle = b2body.GetAngle() * PHYSICS_ANGLE_TO_ANGLE; + if (null !== node.parent.parent) { + vec2_tmp = node.parent.convertToNodeSpaceAR(vec2_tmp); + angle = convertToNodeRotation(node.parent, angle); + } + var tempMask = node._eventMask; + node._eventMask = 0; + node.position = vec2_tmp; + node.angle = -angle; + node._eventMask = tempMask; + body.type === BodyType.Animated && body.resetVelocity(); + } + }, + _onBeginContact: function _onBeginContact(b2contact) { + var c = cc.PhysicsContact.get(b2contact); + c.emit(ContactType.BEGIN_CONTACT); + }, + _onEndContact: function _onEndContact(b2contact) { + var c = b2contact._contact; + if (!c) return; + c.emit(ContactType.END_CONTACT); + cc.PhysicsContact.put(b2contact); + }, + _onPreSolve: function _onPreSolve(b2contact) { + var c = b2contact._contact; + if (!c) return; + c.emit(ContactType.PRE_SOLVE); + }, + _onPostSolve: function _onPostSolve(b2contact, impulse) { + var c = b2contact._contact; + if (!c) return; + c._impulse = impulse; + c.emit(ContactType.POST_SOLVE); + c._impulse = null; + }, + _checkDebugDrawValid: function _checkDebugDrawValid() { + if (!this._debugDrawer || !this._debugDrawer.isValid) { + var node = new cc.Node("PHYSICS_MANAGER_DEBUG_DRAW"); + node.zIndex = cc.macro.MAX_ZINDEX; + cc.game.addPersistRootNode(node); + this._debugDrawer = node.addComponent(cc.Graphics); + var debugDraw = new DebugDraw(this._debugDrawer); + debugDraw.SetFlags(this.debugDrawFlags); + this._world.SetDebugDraw(debugDraw); + } + } + }); + cc.js.getset(PhysicsManager.prototype, "enabled", (function() { + return this._enabled; + }), (function(value) { + false; + if (value && !this._world) { + var world = new b2.World(new b2.Vec2(0, -10)); + world.SetAllowSleeping(true); + this._world = world; + this._initCallback(); + } + this._enabled = value; + })); + cc.js.getset(PhysicsManager.prototype, "debugDrawFlags", (function() { + return this._debugDrawFlags; + }), (function(value) { + false; + value && !this._debugDrawFlags ? this._debugDrawer && this._debugDrawer.node && (this._debugDrawer.node.active = true) : !value && this._debugDrawFlags && this._debugDrawer && this._debugDrawer.node && (this._debugDrawer.node.active = false); + if (value) { + this._checkDebugDrawValid(); + this._world.m_debugDraw.SetFlags(value); + } + this._debugDrawFlags = value; + if (value) { + this._checkDebugDrawValid(); + this._world.m_debugDraw.SetFlags(value); + } + })); + cc.js.getset(PhysicsManager.prototype, "gravity", (function() { + if (this._world) { + var g = this._world.GetGravity(); + return cc.v2(g.x * PTM_RATIO, g.y * PTM_RATIO); + } + return cc.v2(); + }), (function(value) { + this._world && this._world.SetGravity(new b2.Vec2(value.x / PTM_RATIO, value.y / PTM_RATIO)); + })); + cc.PhysicsManager = module.exports = PhysicsManager; + }), { + "./CCPhysicsTypes": 216, + "./platform/CCPhysicsDebugDraw": 237, + "./utils": 239 + } ], + 216: [ (function(require, module, exports) { + "use strict"; + var ContactType = { + BEGIN_CONTACT: "begin-contact", + END_CONTACT: "end-contact", + PRE_SOLVE: "pre-solve", + POST_SOLVE: "post-solve" + }; + var BodyType = cc.Enum({ + Static: 0, + Kinematic: 1, + Dynamic: 2, + Animated: 3 + }); + cc.RigidBodyType = BodyType; + var RayCastType = cc.Enum({ + Closest: 0, + Any: 1, + AllClosest: 2, + All: 3 + }); + cc.RayCastType = RayCastType; + module.exports = { + BodyType: BodyType, + ContactType: ContactType, + RayCastType: RayCastType, + DrawBits: b2.DrawFlags, + PTM_RATIO: 32, + ANGLE_TO_PHYSICS_ANGLE: -Math.PI / 180, + PHYSICS_ANGLE_TO_ANGLE: -180 / Math.PI + }; + }), {} ], + 217: [ (function(require, module, exports) { + "use strict"; + function At(i, vertices) { + var s = vertices.length; + return vertices[i < 0 ? s - -i % s : i % s]; + } + function Copy(i, j, vertices) { + var p = []; + while (j < i) j += vertices.length; + for (;i <= j; ++i) p.push(At(i, vertices)); + return p; + } + function ConvexPartition(vertices) { + ForceCounterClockWise(vertices); + var list = []; + var d, lowerDist, upperDist; + var p; + var lowerInt = cc.v2(); + var upperInt = cc.v2(); + var lowerIndex = 0, upperIndex = 0; + var lowerPoly, upperPoly; + for (var i = 0; i < vertices.length; ++i) if (Reflex(i, vertices)) { + lowerDist = upperDist = 1e8; + for (var j = 0; j < vertices.length; ++j) { + if (Left(At(i - 1, vertices), At(i, vertices), At(j, vertices)) && RightOn(At(i - 1, vertices), At(i, vertices), At(j - 1, vertices))) { + p = LineIntersect(At(i - 1, vertices), At(i, vertices), At(j, vertices), At(j - 1, vertices)); + if (Right(At(i + 1, vertices), At(i, vertices), p)) { + d = SquareDist(At(i, vertices), p); + if (d < lowerDist) { + lowerDist = d; + lowerInt = p; + lowerIndex = j; + } + } + } + if (Left(At(i + 1, vertices), At(i, vertices), At(j + 1, vertices)) && RightOn(At(i + 1, vertices), At(i, vertices), At(j, vertices))) { + p = LineIntersect(At(i + 1, vertices), At(i, vertices), At(j, vertices), At(j + 1, vertices)); + if (Left(At(i - 1, vertices), At(i, vertices), p)) { + d = SquareDist(At(i, vertices), p); + if (d < upperDist) { + upperDist = d; + upperIndex = j; + upperInt = p; + } + } + } + } + if (lowerIndex == (upperIndex + 1) % vertices.length) { + var sp = lowerInt.add(upperInt).div(2); + lowerPoly = Copy(i, upperIndex, vertices); + lowerPoly.push(sp); + upperPoly = Copy(lowerIndex, i, vertices); + upperPoly.push(sp); + } else { + var highestScore = 0, bestIndex = lowerIndex; + while (upperIndex < lowerIndex) upperIndex += vertices.length; + for (var j = lowerIndex; j <= upperIndex; ++j) if (CanSee(i, j, vertices)) { + var score = 1 / (SquareDist(At(i, vertices), At(j, vertices)) + 1); + Reflex(j, vertices) ? RightOn(At(j - 1, vertices), At(j, vertices), At(i, vertices)) && LeftOn(At(j + 1, vertices), At(j, vertices), At(i, vertices)) ? score += 3 : score += 2 : score += 1; + if (score > highestScore) { + bestIndex = j; + highestScore = score; + } + } + lowerPoly = Copy(i, bestIndex, vertices); + upperPoly = Copy(bestIndex, i, vertices); + } + list = list.concat(ConvexPartition(lowerPoly)); + list = list.concat(ConvexPartition(upperPoly)); + return list; + } + list.push(vertices); + for (var i = list.length - 1; i >= 0; i--) 0 == list[i].length && list.splice(i, 0); + return list; + } + function CanSee(i, j, vertices) { + if (Reflex(i, vertices)) { + if (LeftOn(At(i, vertices), At(i - 1, vertices), At(j, vertices)) && RightOn(At(i, vertices), At(i + 1, vertices), At(j, vertices))) return false; + } else if (RightOn(At(i, vertices), At(i + 1, vertices), At(j, vertices)) || LeftOn(At(i, vertices), At(i - 1, vertices), At(j, vertices))) return false; + if (Reflex(j, vertices)) { + if (LeftOn(At(j, vertices), At(j - 1, vertices), At(i, vertices)) && RightOn(At(j, vertices), At(j + 1, vertices), At(i, vertices))) return false; + } else if (RightOn(At(j, vertices), At(j + 1, vertices), At(i, vertices)) || LeftOn(At(j, vertices), At(j - 1, vertices), At(i, vertices))) return false; + for (var k = 0; k < vertices.length; ++k) { + if ((k + 1) % vertices.length == i || k == i || (k + 1) % vertices.length == j || k == j) continue; + var intersectionPoint = cc.v2(); + if (LineIntersect2(At(i, vertices), At(j, vertices), At(k, vertices), At(k + 1, vertices), intersectionPoint)) return false; + } + return true; + } + function Reflex(i, vertices) { + return Right(i, vertices); + } + function Right(a, b, c) { + if ("undefined" === typeof c) { + var i = a, vertices = b; + a = At(i - 1, vertices); + b = At(i, vertices); + c = At(i + 1, vertices); + } + return Area(a, b, c) < 0; + } + function Left(a, b, c) { + return Area(a, b, c) > 0; + } + function LeftOn(a, b, c) { + return Area(a, b, c) >= 0; + } + function RightOn(a, b, c) { + return Area(a, b, c) <= 0; + } + function SquareDist(a, b) { + var dx = b.x - a.x; + var dy = b.y - a.y; + return dx * dx + dy * dy; + } + function ForceCounterClockWise(vertices) { + IsCounterClockWise(vertices) || vertices.reverse(); + } + function IsCounterClockWise(vertices) { + if (vertices.length < 3) return true; + return GetSignedArea(vertices) > 0; + } + function GetSignedArea(vertices) { + var i; + var area = 0; + for (i = 0; i < vertices.length; i++) { + var j = (i + 1) % vertices.length; + area += vertices[i].x * vertices[j].y; + area -= vertices[i].y * vertices[j].x; + } + area /= 2; + return area; + } + function LineIntersect(p1, p2, q1, q2) { + var i = cc.v2(); + var a1 = p2.y - p1.y; + var b1 = p1.x - p2.x; + var c1 = a1 * p1.x + b1 * p1.y; + var a2 = q2.y - q1.y; + var b2 = q1.x - q2.x; + var c2 = a2 * q1.x + b2 * q1.y; + var det = a1 * b2 - a2 * b1; + if (!FloatEquals(det, 0)) { + i.x = (b2 * c1 - b1 * c2) / det; + i.y = (a1 * c2 - a2 * c1) / det; + } + return i; + } + function LineIntersect2(a0, a1, b0, b1, intersectionPoint) { + if (a0 == b0 || a0 == b1 || a1 == b0 || a1 == b1) return false; + var x1 = a0.x; + var y1 = a0.y; + var x2 = a1.x; + var y2 = a1.y; + var x3 = b0.x; + var y3 = b0.y; + var x4 = b1.x; + var y4 = b1.y; + if (Math.max(x1, x2) < Math.min(x3, x4) || Math.max(x3, x4) < Math.min(x1, x2)) return false; + if (Math.max(y1, y2) < Math.min(y3, y4) || Math.max(y3, y4) < Math.min(y1, y2)) return false; + var ua = (x4 - x3) * (y1 - y3) - (y4 - y3) * (x1 - x3); + var ub = (x2 - x1) * (y1 - y3) - (y2 - y1) * (x1 - x3); + var denom = (y4 - y3) * (x2 - x1) - (x4 - x3) * (y2 - y1); + if (Math.abs(denom) < 1e-6) return false; + ua /= denom; + ub /= denom; + if (0 < ua && ua < 1 && 0 < ub && ub < 1) { + intersectionPoint.x = x1 + ua * (x2 - x1); + intersectionPoint.y = y1 + ua * (y2 - y1); + return true; + } + return false; + } + function FloatEquals(value1, value2) { + return Math.abs(value1 - value2) <= 1e-6; + } + function Area(a, b, c) { + return a.x * (b.y - c.y) + b.x * (c.y - a.y) + c.x * (a.y - b.y); + } + module.exports = { + ConvexPartition: ConvexPartition, + ForceCounterClockWise: ForceCounterClockWise, + IsCounterClockWise: IsCounterClockWise + }; + }), {} ], + 218: [ (function(require, module, exports) { + "use strict"; + var NodeEvent = require("../CCNode").EventType; + var PTM_RATIO = require("./CCPhysicsTypes").PTM_RATIO; + var ANGLE_TO_PHYSICS_ANGLE = require("./CCPhysicsTypes").ANGLE_TO_PHYSICS_ANGLE; + var PHYSICS_ANGLE_TO_ANGLE = require("./CCPhysicsTypes").PHYSICS_ANGLE_TO_ANGLE; + var getWorldRotation = require("./utils").getWorldRotation; + var BodyType = require("./CCPhysicsTypes").BodyType; + var tempb2Vec21 = new b2.Vec2(); + var tempb2Vec22 = new b2.Vec2(); + var VEC2_ZERO = cc.Vec2.ZERO; + var RigidBody = cc.Class({ + name: "cc.RigidBody", + extends: cc.Component, + editor: false, + properties: { + _type: BodyType.Dynamic, + _allowSleep: true, + _gravityScale: 1, + _linearDamping: 0, + _angularDamping: 0, + _linearVelocity: cc.v2(0, 0), + _angularVelocity: 0, + _fixedRotation: false, + enabled: { + get: function get() { + return this._enabled; + }, + set: function set() { + cc.warnID(8200); + }, + visible: false, + override: true + }, + enabledContactListener: { + default: false, + tooltip: false + }, + bullet: { + default: false, + tooltip: false + }, + type: { + type: BodyType, + tooltip: false, + get: function get() { + return this._type; + }, + set: function set(value) { + this._type = value; + this._b2Body && (value === BodyType.Animated ? this._b2Body.SetType(BodyType.Kinematic) : this._b2Body.SetType(value)); + } + }, + allowSleep: { + tooltip: false, + get: function get() { + if (this._b2Body) return this._b2Body.IsSleepingAllowed(); + return this._allowSleep; + }, + set: function set(value) { + this._allowSleep = value; + this._b2Body && this._b2Body.SetSleepingAllowed(value); + } + }, + gravityScale: { + tooltip: false, + get: function get() { + return this._gravityScale; + }, + set: function set(value) { + this._gravityScale = value; + this._b2Body && this._b2Body.SetGravityScale(value); + } + }, + linearDamping: { + tooltip: false, + get: function get() { + return this._linearDamping; + }, + set: function set(value) { + this._linearDamping = value; + this._b2Body && this._b2Body.SetLinearDamping(this._linearDamping); + } + }, + angularDamping: { + tooltip: false, + get: function get() { + return this._angularDamping; + }, + set: function set(value) { + this._angularDamping = value; + this._b2Body && this._b2Body.SetAngularDamping(value); + } + }, + linearVelocity: { + tooltip: false, + type: cc.Vec2, + get: function get() { + var lv = this._linearVelocity; + if (this._b2Body) { + var velocity = this._b2Body.GetLinearVelocity(); + lv.x = velocity.x * PTM_RATIO; + lv.y = velocity.y * PTM_RATIO; + } + return lv; + }, + set: function set(value) { + this._linearVelocity = value; + var b2body = this._b2Body; + if (b2body) { + var temp = b2body.m_linearVelocity; + temp.Set(value.x / PTM_RATIO, value.y / PTM_RATIO); + b2body.SetLinearVelocity(temp); + } + } + }, + angularVelocity: { + tooltip: false, + get: function get() { + if (this._b2Body) return this._b2Body.GetAngularVelocity() * PHYSICS_ANGLE_TO_ANGLE; + return this._angularVelocity; + }, + set: function set(value) { + this._angularVelocity = value; + this._b2Body && this._b2Body.SetAngularVelocity(value * ANGLE_TO_PHYSICS_ANGLE); + } + }, + fixedRotation: { + tooltip: false, + get: function get() { + return this._fixedRotation; + }, + set: function set(value) { + this._fixedRotation = value; + this._b2Body && this._b2Body.SetFixedRotation(value); + } + }, + awake: { + visible: false, + tooltip: false, + get: function get() { + return !!this._b2Body && this._b2Body.IsAwake(); + }, + set: function set(value) { + this._b2Body && this._b2Body.SetAwake(value); + } + }, + awakeOnLoad: { + default: true, + tooltip: false, + animatable: false + }, + active: { + visible: false, + get: function get() { + return !!this._b2Body && this._b2Body.IsActive(); + }, + set: function set(value) { + this._b2Body && this._b2Body.SetActive(value); + } + } + }, + getLocalPoint: function getLocalPoint(worldPoint, out) { + out = out || cc.v2(); + if (this._b2Body) { + tempb2Vec21.Set(worldPoint.x / PTM_RATIO, worldPoint.y / PTM_RATIO); + var pos = this._b2Body.GetLocalPoint(tempb2Vec21, out); + out.x = pos.x * PTM_RATIO; + out.y = pos.y * PTM_RATIO; + } + return out; + }, + getWorldPoint: function getWorldPoint(localPoint, out) { + out = out || cc.v2(); + if (this._b2Body) { + tempb2Vec21.Set(localPoint.x / PTM_RATIO, localPoint.y / PTM_RATIO); + var pos = this._b2Body.GetWorldPoint(tempb2Vec21, out); + out.x = pos.x * PTM_RATIO; + out.y = pos.y * PTM_RATIO; + } + return out; + }, + getWorldVector: function getWorldVector(localVector, out) { + out = out || cc.v2(); + if (this._b2Body) { + tempb2Vec21.Set(localVector.x / PTM_RATIO, localVector.y / PTM_RATIO); + var vector = this._b2Body.GetWorldVector(tempb2Vec21, out); + out.x = vector.x * PTM_RATIO; + out.y = vector.y * PTM_RATIO; + } + return out; + }, + getLocalVector: function getLocalVector(worldVector, out) { + out = out || cc.v2(); + if (this._b2Body) { + tempb2Vec21.Set(worldVector.x / PTM_RATIO, worldVector.y / PTM_RATIO); + var vector = this._b2Body.GetLocalVector(tempb2Vec21, out); + out.x = vector.x * PTM_RATIO; + out.y = vector.y * PTM_RATIO; + } + return out; + }, + getWorldPosition: function getWorldPosition(out) { + out = out || cc.v2(); + if (this._b2Body) { + var pos = this._b2Body.GetPosition(); + out.x = pos.x * PTM_RATIO; + out.y = pos.y * PTM_RATIO; + } + return out; + }, + getWorldRotation: function getWorldRotation() { + if (this._b2Body) return this._b2Body.GetAngle() * PHYSICS_ANGLE_TO_ANGLE; + return 0; + }, + getLocalCenter: function getLocalCenter(out) { + out = out || cc.v2(); + if (this._b2Body) { + var pos = this._b2Body.GetLocalCenter(); + out.x = pos.x * PTM_RATIO; + out.y = pos.y * PTM_RATIO; + } + return out; + }, + getWorldCenter: function getWorldCenter(out) { + out = out || cc.v2(); + if (this._b2Body) { + var pos = this._b2Body.GetWorldCenter(); + out.x = pos.x * PTM_RATIO; + out.y = pos.y * PTM_RATIO; + } + return out; + }, + getLinearVelocityFromWorldPoint: function getLinearVelocityFromWorldPoint(worldPoint, out) { + out = out || cc.v2(); + if (this._b2Body) { + tempb2Vec21.Set(worldPoint.x / PTM_RATIO, worldPoint.y / PTM_RATIO); + var velocity = this._b2Body.GetLinearVelocityFromWorldPoint(tempb2Vec21, out); + out.x = velocity.x * PTM_RATIO; + out.y = velocity.y * PTM_RATIO; + } + return out; + }, + getMass: function getMass() { + return this._b2Body ? this._b2Body.GetMass() : 0; + }, + getInertia: function getInertia() { + return this._b2Body ? this._b2Body.GetInertia() * PTM_RATIO * PTM_RATIO : 0; + }, + getJointList: function getJointList() { + if (!this._b2Body) return []; + var joints = []; + var list = this._b2Body.GetJointList(); + if (!list) return []; + joints.push(list.joint._joint); + var prev = list.prev; + while (prev) { + joints.push(prev.joint._joint); + prev = prev.prev; + } + var next = list.next; + while (next) { + joints.push(next.joint._joint); + next = next.next; + } + return joints; + }, + applyForce: function applyForce(force, point, wake) { + if (this._b2Body) { + tempb2Vec21.Set(force.x / PTM_RATIO, force.y / PTM_RATIO); + tempb2Vec22.Set(point.x / PTM_RATIO, point.y / PTM_RATIO); + this._b2Body.ApplyForce(tempb2Vec21, tempb2Vec22, wake); + } + }, + applyForceToCenter: function applyForceToCenter(force, wake) { + if (this._b2Body) { + tempb2Vec21.Set(force.x / PTM_RATIO, force.y / PTM_RATIO); + this._b2Body.ApplyForceToCenter(tempb2Vec21, wake); + } + }, + applyTorque: function applyTorque(torque, wake) { + this._b2Body && this._b2Body.ApplyTorque(torque / PTM_RATIO, wake); + }, + applyLinearImpulse: function applyLinearImpulse(impulse, point, wake) { + if (this._b2Body) { + tempb2Vec21.Set(impulse.x / PTM_RATIO, impulse.y / PTM_RATIO); + tempb2Vec22.Set(point.x / PTM_RATIO, point.y / PTM_RATIO); + this._b2Body.ApplyLinearImpulse(tempb2Vec21, tempb2Vec22, wake); + } + }, + applyAngularImpulse: function applyAngularImpulse(impulse, wake) { + this._b2Body && this._b2Body.ApplyAngularImpulse(impulse / PTM_RATIO / PTM_RATIO, wake); + }, + syncPosition: function syncPosition(enableAnimated) { + var b2body = this._b2Body; + if (!b2body) return; + var pos = this.node.convertToWorldSpaceAR(VEC2_ZERO); + var temp; + temp = this.type === BodyType.Animated ? b2body.GetLinearVelocity() : b2body.GetPosition(); + temp.x = pos.x / PTM_RATIO; + temp.y = pos.y / PTM_RATIO; + if (this.type === BodyType.Animated && enableAnimated) { + var b2Pos = b2body.GetPosition(); + var timeStep = cc.game.config["frameRate"]; + temp.x = (temp.x - b2Pos.x) * timeStep; + temp.y = (temp.y - b2Pos.y) * timeStep; + b2body.SetAwake(true); + b2body.SetLinearVelocity(temp); + } else b2body.SetTransformVec(temp, b2body.GetAngle()); + }, + syncRotation: function syncRotation(enableAnimated) { + var b2body = this._b2Body; + if (!b2body) return; + var rotation = ANGLE_TO_PHYSICS_ANGLE * getWorldRotation(this.node); + if (this.type === BodyType.Animated && enableAnimated) { + var b2Rotation = b2body.GetAngle(); + var timeStep = cc.game.config["frameRate"]; + b2body.SetAwake(true); + b2body.SetAngularVelocity((rotation - b2Rotation) * timeStep); + } else b2body.SetTransformVec(b2body.GetPosition(), rotation); + }, + resetVelocity: function resetVelocity() { + var b2body = this._b2Body; + if (!b2body) return; + var temp = b2body.m_linearVelocity; + temp.Set(0, 0); + b2body.SetLinearVelocity(temp); + b2body.SetAngularVelocity(0); + }, + onEnable: function onEnable() { + this._init(); + }, + onDisable: function onDisable() { + this._destroy(); + }, + _registerNodeEvents: function _registerNodeEvents() { + var node = this.node; + node.on(NodeEvent.POSITION_CHANGED, this._onNodePositionChanged, this); + node.on(NodeEvent.ROTATION_CHANGED, this._onNodeRotationChanged, this); + node.on(NodeEvent.SCALE_CHANGED, this._onNodeScaleChanged, this); + }, + _unregisterNodeEvents: function _unregisterNodeEvents() { + var node = this.node; + node.off(NodeEvent.POSITION_CHANGED, this._onNodePositionChanged, this); + node.off(NodeEvent.ROTATION_CHANGED, this._onNodeRotationChanged, this); + node.off(NodeEvent.SCALE_CHANGED, this._onNodeScaleChanged, this); + }, + _onNodePositionChanged: function _onNodePositionChanged() { + this.syncPosition(true); + }, + _onNodeRotationChanged: function _onNodeRotationChanged(event) { + this.syncRotation(true); + }, + _onNodeScaleChanged: function _onNodeScaleChanged(event) { + if (this._b2Body) { + var colliders = this.getComponents(cc.PhysicsCollider); + for (var i = 0; i < colliders.length; i++) colliders[i].apply(); + } + }, + _init: function _init() { + cc.director.getPhysicsManager().pushDelayEvent(this, "__init", []); + }, + _destroy: function _destroy() { + cc.director.getPhysicsManager().pushDelayEvent(this, "__destroy", []); + }, + __init: function __init() { + if (this._inited) return; + this._registerNodeEvents(); + var bodyDef = new b2.BodyDef(); + this.type === BodyType.Animated ? bodyDef.type = BodyType.Kinematic : bodyDef.type = this.type; + bodyDef.allowSleep = this.allowSleep; + bodyDef.gravityScale = this.gravityScale; + bodyDef.linearDamping = this.linearDamping; + bodyDef.angularDamping = this.angularDamping; + var linearVelocity = this.linearVelocity; + bodyDef.linearVelocity = new b2.Vec2(linearVelocity.x / PTM_RATIO, linearVelocity.y / PTM_RATIO); + bodyDef.angularVelocity = this.angularVelocity * ANGLE_TO_PHYSICS_ANGLE; + bodyDef.fixedRotation = this.fixedRotation; + bodyDef.bullet = this.bullet; + var node = this.node; + var pos = node.convertToWorldSpaceAR(VEC2_ZERO); + bodyDef.position = new b2.Vec2(pos.x / PTM_RATIO, pos.y / PTM_RATIO); + bodyDef.angle = -Math.PI / 180 * getWorldRotation(node); + bodyDef.awake = this.awakeOnLoad; + cc.director.getPhysicsManager()._addBody(this, bodyDef); + this._inited = true; + }, + __destroy: function __destroy() { + if (!this._inited) return; + cc.director.getPhysicsManager()._removeBody(this); + this._unregisterNodeEvents(); + this._inited = false; + }, + _getBody: function _getBody() { + return this._b2Body; + } + }); + cc.RigidBody = module.exports = RigidBody; + }), { + "../CCNode": 73, + "./CCPhysicsTypes": 216, + "./utils": 239 + } ], + 219: [ (function(require, module, exports) { + "use strict"; + var box2d = require("../../../external/box2d/box2d"); + window.b2 = {}; + for (var key in box2d) { + if (-1 !== key.indexOf("b2_")) continue; + var newKey = key.replace("b2", ""); + b2[newKey] = box2d[key]; + } + b2.maxPolygonVertices = 8; + }), { + "../../../external/box2d/box2d": 436 + } ], + 220: [ (function(require, module, exports) { + "use strict"; + var PTM_RATIO = require("../CCPhysicsTypes").PTM_RATIO; + var PhysicsBoxCollider = cc.Class({ + name: "cc.PhysicsBoxCollider", + extends: cc.PhysicsCollider, + mixins: [ cc.Collider.Box ], + editor: { + menu: false, + requireComponent: cc.RigidBody + }, + _createShape: function _createShape(scale) { + var scaleX = Math.abs(scale.x); + var scaleY = Math.abs(scale.y); + var width = this.size.width / 2 / PTM_RATIO * scaleX; + var height = this.size.height / 2 / PTM_RATIO * scaleY; + var offsetX = this.offset.x / PTM_RATIO * scaleX; + var offsetY = this.offset.y / PTM_RATIO * scaleY; + var shape = new b2.PolygonShape(); + shape.SetAsBox(width, height, new b2.Vec2(offsetX, offsetY), 0); + return shape; + } + }); + cc.PhysicsBoxCollider = module.exports = PhysicsBoxCollider; + }), { + "../CCPhysicsTypes": 216 + } ], + 221: [ (function(require, module, exports) { + "use strict"; + var PTM_RATIO = require("../CCPhysicsTypes").PTM_RATIO; + var PhysicsChainCollider = cc.Class({ + name: "cc.PhysicsChainCollider", + extends: cc.PhysicsCollider, + editor: { + menu: false, + inspector: false, + requireComponent: cc.RigidBody + }, + properties: { + loop: false, + points: { + default: function _default() { + return [ cc.v2(-50, 0), cc.v2(50, 0) ]; + }, + type: [ cc.Vec2 ] + }, + threshold: { + default: 1, + serializable: false, + visible: false + } + }, + _createShape: function _createShape(scale) { + var shape = new b2.ChainShape(); + var points = this.points; + var vertices = []; + for (var i = 0; i < points.length; i++) { + var p = points[i]; + vertices.push(new b2.Vec2(p.x / PTM_RATIO * scale.x, p.y / PTM_RATIO * scale.y)); + } + this.loop ? shape.CreateLoop(vertices, vertices.length) : shape.CreateChain(vertices, vertices.length); + return shape; + }, + resetInEditor: false, + resetPointsByContour: false + }); + cc.PhysicsChainCollider = module.exports = PhysicsChainCollider; + }), { + "../CCPhysicsTypes": 216 + } ], + 222: [ (function(require, module, exports) { + "use strict"; + var PTM_RATIO = require("../CCPhysicsTypes").PTM_RATIO; + var PhysicsCircleCollider = cc.Class({ + name: "cc.PhysicsCircleCollider", + extends: cc.PhysicsCollider, + mixins: [ cc.Collider.Circle ], + editor: { + menu: false, + requireComponent: cc.RigidBody + }, + _createShape: function _createShape(scale) { + var scaleX = Math.abs(scale.x); + var scaleY = Math.abs(scale.y); + var offsetX = this.offset.x / PTM_RATIO * scaleX; + var offsetY = this.offset.y / PTM_RATIO * scaleY; + var shape = new b2.CircleShape(); + shape.m_radius = this.radius / PTM_RATIO * scaleX; + shape.m_p = new b2.Vec2(offsetX, offsetY); + return shape; + } + }); + cc.PhysicsCircleCollider = module.exports = PhysicsCircleCollider; + }), { + "../CCPhysicsTypes": 216 + } ], + 223: [ (function(require, module, exports) { + "use strict"; + var PTM_RATIO = require("../CCPhysicsTypes").PTM_RATIO; + var getWorldScale = require("../utils").getWorldScale; + var b2_aabb_tmp = new b2.AABB(); + var PhysicsCollider = cc.Class({ + name: "cc.PhysicsCollider", + extends: cc.Collider, + ctor: function ctor() { + this._fixtures = []; + this._shapes = []; + this._inited = false; + this._rect = cc.rect(); + }, + properties: { + _density: 1, + _sensor: false, + _friction: .2, + _restitution: 0, + density: { + tooltip: false, + get: function get() { + return this._density; + }, + set: function set(value) { + this._density = value; + } + }, + sensor: { + tooltip: false, + get: function get() { + return this._sensor; + }, + set: function set(value) { + this._sensor = value; + } + }, + friction: { + tooltip: false, + get: function get() { + return this._friction; + }, + set: function set(value) { + this._friction = value; + } + }, + restitution: { + tooltip: false, + get: function get() { + return this._restitution; + }, + set: function set(value) { + this._restitution = value; + } + }, + body: { + default: null, + type: cc.RigidBody, + visible: false + } + }, + onDisable: function onDisable() { + this._destroy(); + }, + onEnable: function onEnable() { + this._init(); + }, + start: function start() { + this._init(); + }, + _getFixtureIndex: function _getFixtureIndex(fixture) { + return this._fixtures.indexOf(fixture); + }, + _init: function _init() { + cc.director.getPhysicsManager().pushDelayEvent(this, "__init", []); + }, + _destroy: function _destroy() { + cc.director.getPhysicsManager().pushDelayEvent(this, "__destroy", []); + }, + __init: function __init() { + if (this._inited) return; + var body = this.body || this.getComponent(cc.RigidBody); + if (!body) return; + var innerBody = body._getBody(); + if (!innerBody) return; + var node = body.node; + var scale = getWorldScale(node); + this._scale = scale; + var shapes = 0 === scale.x && 0 === scale.y ? [] : this._createShape(scale); + shapes instanceof Array || (shapes = [ shapes ]); + var categoryBits = 1 << node.groupIndex; + var maskBits = 0; + var bits = cc.game.collisionMatrix[node.groupIndex]; + for (var i = 0; i < bits.length; i++) { + if (!bits[i]) continue; + maskBits |= 1 << i; + } + var filter = { + categoryBits: categoryBits, + maskBits: maskBits, + groupIndex: 0 + }; + var manager = cc.director.getPhysicsManager(); + for (var _i = 0; _i < shapes.length; _i++) { + var shape = shapes[_i]; + var fixDef = new b2.FixtureDef(); + fixDef.density = this.density; + fixDef.isSensor = this.sensor; + fixDef.friction = this.friction; + fixDef.restitution = this.restitution; + fixDef.shape = shape; + fixDef.filter = filter; + var fixture = innerBody.CreateFixture(fixDef); + fixture.collider = this; + body.enabledContactListener && manager._registerContactFixture(fixture); + this._shapes.push(shape); + this._fixtures.push(fixture); + } + this.body = body; + this._inited = true; + }, + __destroy: function __destroy() { + if (!this._inited) return; + var fixtures = this._fixtures; + var body = this.body._getBody(); + var manager = cc.director.getPhysicsManager(); + for (var i = fixtures.length - 1; i >= 0; i--) { + var fixture = fixtures[i]; + fixture.collider = null; + manager._unregisterContactFixture(fixture); + body && body.DestroyFixture(fixture); + } + this.body = null; + this._fixtures.length = 0; + this._shapes.length = 0; + this._inited = false; + }, + _createShape: function _createShape() {}, + apply: function apply() { + this._destroy(); + this._init(); + }, + getAABB: function getAABB() { + var MAX = 1e7; + var minX = MAX, minY = MAX; + var maxX = -MAX, maxY = -MAX; + var xf = this.body._getBody().GetTransform(); + var fixtures = this._fixtures; + for (var i = 0; i < fixtures.length; i++) { + var shape = fixtures[i].GetShape(); + var count = shape.GetChildCount(); + for (var j = 0; j < count; j++) { + shape.ComputeAABB(b2_aabb_tmp, xf, j); + b2_aabb_tmp.lowerBound.x < minX && (minX = b2_aabb_tmp.lowerBound.x); + b2_aabb_tmp.lowerBound.y < minY && (minY = b2_aabb_tmp.lowerBound.y); + b2_aabb_tmp.upperBound.x > maxX && (maxX = b2_aabb_tmp.upperBound.x); + b2_aabb_tmp.upperBound.y > maxY && (maxY = b2_aabb_tmp.upperBound.y); + } + } + minX *= PTM_RATIO; + minY *= PTM_RATIO; + maxX *= PTM_RATIO; + maxY *= PTM_RATIO; + var r = this._rect; + r.x = minX; + r.y = minY; + r.width = maxX - minX; + r.height = maxY - minY; + return r; + } + }); + cc.PhysicsCollider = module.exports = PhysicsCollider; + }), { + "../CCPhysicsTypes": 216, + "../utils": 239 + } ], + 224: [ (function(require, module, exports) { + "use strict"; + var PTM_RATIO = require("../CCPhysicsTypes").PTM_RATIO; + var PolygonSeparator = require("../CCPolygonSeparator"); + var PhysicsPolygonCollider = cc.Class({ + name: "cc.PhysicsPolygonCollider", + extends: cc.PhysicsCollider, + mixins: [ cc.Collider.Polygon ], + editor: { + menu: false, + inspector: false, + requireComponent: cc.RigidBody + }, + _createShape: function _createShape(scale) { + var shapes = []; + var points = this.points; + points.length > 0 && points[0].equals(points[points.length - 1]) && (points.length -= 1); + var polys = PolygonSeparator.ConvexPartition(points); + var offset = this.offset; + for (var i = 0; i < polys.length; i++) { + var poly = polys[i]; + var shape = null, vertices = []; + var firstVertice = null; + for (var j = 0, l = poly.length; j < l; j++) { + shape || (shape = new b2.PolygonShape()); + var p = poly[j]; + var x = (p.x + offset.x) / PTM_RATIO * scale.x; + var y = (p.y + offset.y) / PTM_RATIO * scale.y; + var v = new b2.Vec2(x, y); + vertices.push(v); + firstVertice || (firstVertice = v); + if (vertices.length === b2.maxPolygonVertices) { + shape.Set(vertices, vertices.length); + shapes.push(shape); + shape = null; + j < l - 1 && (vertices = [ firstVertice, vertices[vertices.length - 1] ]); + } + } + if (shape) { + shape.Set(vertices, vertices.length); + shapes.push(shape); + } + } + return shapes; + } + }); + cc.PhysicsPolygonCollider = module.exports = PhysicsPolygonCollider; + }), { + "../CCPhysicsTypes": 216, + "../CCPolygonSeparator": 217 + } ], + 225: [ (function(require, module, exports) { + "use strict"; + require("./box2d-adapter"); + require("./CCPhysicsManager"); + require("./CCRigidBody"); + require("./CCPhysicsContact"); + require("./collider/CCPhysicsCollider"); + require("./collider/CCPhysicsChainCollider"); + require("./collider/CCPhysicsCircleCollider"); + require("./collider/CCPhysicsBoxCollider"); + require("./collider/CCPhysicsPolygonCollider"); + require("./joint/CCJoint"); + require("./joint/CCDistanceJoint"); + require("./joint/CCRevoluteJoint"); + require("./joint/CCMouseJoint"); + require("./joint/CCMotorJoint"); + require("./joint/CCPrismaticJoint"); + require("./joint/CCWeldJoint"); + require("./joint/CCWheelJoint"); + require("./joint/CCRopeJoint"); + require("./platform/CCPhysicsContactListner"); + require("./platform/CCPhysicsAABBQueryCallback"); + require("./platform/CCPhysicsRayCastCallback"); + }), { + "./CCPhysicsContact": 214, + "./CCPhysicsManager": 215, + "./CCRigidBody": 218, + "./box2d-adapter": 219, + "./collider/CCPhysicsBoxCollider": 220, + "./collider/CCPhysicsChainCollider": 221, + "./collider/CCPhysicsCircleCollider": 222, + "./collider/CCPhysicsCollider": 223, + "./collider/CCPhysicsPolygonCollider": 224, + "./joint/CCDistanceJoint": 226, + "./joint/CCJoint": 227, + "./joint/CCMotorJoint": 228, + "./joint/CCMouseJoint": 229, + "./joint/CCPrismaticJoint": 230, + "./joint/CCRevoluteJoint": 231, + "./joint/CCRopeJoint": 232, + "./joint/CCWeldJoint": 233, + "./joint/CCWheelJoint": 234, + "./platform/CCPhysicsAABBQueryCallback": 235, + "./platform/CCPhysicsContactListner": 236, + "./platform/CCPhysicsRayCastCallback": 238 + } ], + 226: [ (function(require, module, exports) { + "use strict"; + var PTM_RATIO = require("../CCPhysicsTypes").PTM_RATIO; + var DistanceJoint = cc.Class({ + name: "cc.DistanceJoint", + extends: cc.Joint, + editor: false, + properties: { + _distance: 1, + _frequency: 0, + _dampingRatio: 0, + distance: { + tooltip: false, + get: function get() { + return this._distance; + }, + set: function set(value) { + this._distance = value; + this._joint && this._joint.SetLength(value); + } + }, + frequency: { + tooltip: false, + get: function get() { + return this._frequency; + }, + set: function set(value) { + this._frequency = value; + this._joint && this._joint.SetFrequency(value); + } + }, + dampingRatio: { + tooltip: false, + get: function get() { + return this._dampingRatio; + }, + set: function set(value) { + this._dampingRatio = value; + this._joint && this._joint.SetDampingRatio(value); + } + } + }, + _createJointDef: function _createJointDef() { + var def = new b2.DistanceJointDef(); + def.localAnchorA = new b2.Vec2(this.anchor.x / PTM_RATIO, this.anchor.y / PTM_RATIO); + def.localAnchorB = new b2.Vec2(this.connectedAnchor.x / PTM_RATIO, this.connectedAnchor.y / PTM_RATIO); + def.length = this.distance / PTM_RATIO; + def.dampingRatio = this.dampingRatio; + def.frequencyHz = this.frequency; + return def; + } + }); + cc.DistanceJoint = module.exports = DistanceJoint; + }), { + "../CCPhysicsTypes": 216 + } ], + 227: [ (function(require, module, exports) { + "use strict"; + var PTM_RATIO = require("../CCPhysicsTypes").PTM_RATIO; + var Joint = cc.Class({ + name: "cc.Joint", + extends: cc.Component, + editor: { + requireComponent: cc.RigidBody + }, + properties: { + anchor: { + default: cc.v2(0, 0), + tooltip: false + }, + connectedAnchor: { + default: cc.v2(0, 0), + tooltip: false + }, + connectedBody: { + default: null, + type: cc.RigidBody, + tooltip: false + }, + collideConnected: { + default: false, + tooltip: false + } + }, + onDisable: function onDisable() { + this._destroy(); + }, + onEnable: function onEnable() { + this._init(); + }, + start: function start() { + this._init(); + }, + apply: function apply() { + this._destroy(); + this._init(); + }, + getWorldAnchor: function getWorldAnchor() { + if (this._joint) { + var anchor = this._joint.GetAnchorA(); + return cc.v2(anchor.x * PTM_RATIO, anchor.y * PTM_RATIO); + } + return cc.Vec2.ZERO; + }, + getWorldConnectedAnchor: function getWorldConnectedAnchor() { + if (this._joint) { + var anchor = this._joint.GetAnchorB(); + return cc.v2(anchor.x * PTM_RATIO, anchor.y * PTM_RATIO); + } + return cc.Vec2.ZERO; + }, + getReactionForce: function getReactionForce(timeStep) { + var out = cc.v2(); + if (this._joint) return this._joint.GetReactionForce(timeStep, out); + return out; + }, + getReactionTorque: function getReactionTorque(timeStep) { + if (this._joint) return this._joint.GetReactionTorque(timeStep); + return 0; + }, + _init: function _init() { + cc.director.getPhysicsManager().pushDelayEvent(this, "__init", []); + }, + _destroy: function _destroy() { + cc.director.getPhysicsManager().pushDelayEvent(this, "__destroy", []); + }, + __init: function __init() { + if (this._inited) return; + this.body = this.getComponent(cc.RigidBody); + if (this._isValid()) { + var def = this._createJointDef(); + if (!def) return; + def.bodyA = this.body._getBody(); + def.bodyB = this.connectedBody._getBody(); + def.collideConnected = this.collideConnected; + cc.director.getPhysicsManager()._addJoint(this, def); + this._inited = true; + } + }, + __destroy: function __destroy() { + if (!this._inited) return; + cc.director.getPhysicsManager()._removeJoint(this); + this._joint = null; + this._inited = false; + }, + _createJointDef: function _createJointDef() { + return null; + }, + _isValid: function _isValid() { + return this.body && this.body._getBody() && this.connectedBody && this.connectedBody._getBody(); + } + }); + cc.Joint = module.exports = Joint; + }), { + "../CCPhysicsTypes": 216 + } ], + 228: [ (function(require, module, exports) { + "use strict"; + var PTM_RATIO = require("../CCPhysicsTypes").PTM_RATIO; + var ANGLE_TO_PHYSICS_ANGLE = require("../CCPhysicsTypes").ANGLE_TO_PHYSICS_ANGLE; + var MotorJoint = cc.Class({ + name: "cc.MotorJoint", + extends: cc.Joint, + editor: false, + properties: { + _linearOffset: cc.v2(0, 0), + _angularOffset: 0, + _maxForce: 1, + _maxTorque: 1, + _correctionFactor: .3, + anchor: { + tooltip: false, + default: cc.v2(0, 0), + override: true, + visible: false + }, + connectedAnchor: { + tooltip: false, + default: cc.v2(0, 0), + override: true, + visible: false + }, + linearOffset: { + tooltip: false, + get: function get() { + return this._linearOffset; + }, + set: function set(value) { + this._linearOffset = value; + this._joint && this._joint.SetLinearOffset(new b2.Vec2(value.x / PTM_RATIO, value.y / PTM_RATIO)); + } + }, + angularOffset: { + tooltip: false, + get: function get() { + return this._angularOffset; + }, + set: function set(value) { + this._angularOffset = value; + this._joint && this._joint.SetAngularOffset(value); + } + }, + maxForce: { + tooltip: false, + get: function get() { + return this._maxForce; + }, + set: function set(value) { + this._maxForce = value; + this._joint && this._joint.SetMaxForce(value); + } + }, + maxTorque: { + tooltip: false, + get: function get() { + return this._maxTorque; + }, + set: function set(value) { + this._maxTorque = value; + this._joint && this._joint.SetMaxTorque(value); + } + }, + correctionFactor: { + tooltip: false, + get: function get() { + return this._correctionFactor; + }, + set: function set(value) { + this._correctionFactor = value; + this._joint && this._joint.SetCorrectionFactor(value); + } + } + }, + _createJointDef: function _createJointDef() { + var def = new b2.MotorJointDef(); + def.linearOffset = new b2.Vec2(this.linearOffset.x / PTM_RATIO, this.linearOffset.y / PTM_RATIO); + def.angularOffset = this.angularOffset * ANGLE_TO_PHYSICS_ANGLE; + def.maxForce = this.maxForce; + def.maxTorque = this.maxTorque; + def.correctionFactor = this.correctionFactor; + return def; + } + }); + cc.MotorJoint = module.exports = MotorJoint; + }), { + "../CCPhysicsTypes": 216 + } ], + 229: [ (function(require, module, exports) { + "use strict"; + var PTM_RATIO = require("../CCPhysicsTypes").PTM_RATIO; + var tempB2Vec2 = new b2.Vec2(); + var MouseJoint = cc.Class({ + name: "cc.MouseJoint", + extends: cc.Joint, + editor: false, + properties: { + _target: 1, + _frequency: 5, + _dampingRatio: .7, + _maxForce: 0, + connectedBody: { + default: null, + type: cc.RigidBody, + visible: false, + override: true + }, + collideConnected: { + default: true, + visible: false, + override: true + }, + anchor: { + tooltip: false, + default: cc.v2(0, 0), + override: true, + visible: false + }, + connectedAnchor: { + tooltip: false, + default: cc.v2(0, 0), + override: true, + visible: false + }, + mouseRegion: { + tooltip: false, + default: null, + type: cc.Node + }, + target: { + tooltip: false, + visible: false, + get: function get() { + return this._target; + }, + set: function set(value) { + this._target = value; + if (this._joint) { + tempB2Vec2.x = value.x / PTM_RATIO; + tempB2Vec2.y = value.y / PTM_RATIO; + this._joint.SetTarget(tempB2Vec2); + } + } + }, + frequency: { + tooltip: false, + get: function get() { + return this._frequency; + }, + set: function set(value) { + this._frequency = value; + this._joint && this._joint.SetFrequency(value); + } + }, + dampingRatio: { + tooltip: false, + get: function get() { + return this._dampingRatio; + }, + set: function set(value) { + this._dampingRatio = value; + this._joint && this._joint.SetDampingRatio(value); + } + }, + maxForce: { + tooltip: false, + visible: false, + get: function get() { + return this._maxForce; + }, + set: function set(value) { + this._maxForce = value; + this._joint && this._joint.SetMaxForce(value); + } + } + }, + onLoad: function onLoad() { + var mouseRegion = this.mouseRegion || this.node; + mouseRegion.on(cc.Node.EventType.TOUCH_START, this.onTouchBegan, this); + mouseRegion.on(cc.Node.EventType.TOUCH_MOVE, this.onTouchMove, this); + mouseRegion.on(cc.Node.EventType.TOUCH_END, this.onTouchEnd, this); + mouseRegion.on(cc.Node.EventType.TOUCH_CANCEL, this.onTouchEnd, this); + }, + onEnable: function onEnable() {}, + start: function start() {}, + onTouchBegan: function onTouchBegan(event) { + var manager = cc.director.getPhysicsManager(); + var target = this._pressPoint = event.touch.getLocation(); + cc.Camera && cc.Camera.main && (target = cc.Camera.main.getScreenToWorldPoint(target)); + var collider = manager.testPoint(target); + if (!collider) return; + var body = this.connectedBody = collider.body; + body.awake = true; + this.maxForce = 1e3 * this.connectedBody.getMass(); + this.target = target; + this._init(); + }, + onTouchMove: function onTouchMove(event) { + this._pressPoint = event.touch.getLocation(); + }, + onTouchEnd: function onTouchEnd(event) { + this._destroy(); + this._pressPoint = null; + }, + _createJointDef: function _createJointDef() { + var def = new b2.MouseJointDef(); + tempB2Vec2.x = this.target.x / PTM_RATIO; + tempB2Vec2.y = this.target.y / PTM_RATIO; + def.target = tempB2Vec2; + def.maxForce = this.maxForce; + def.dampingRatio = this.dampingRatio; + def.frequencyHz = this.frequency; + return def; + }, + update: function update() { + if (!this._pressPoint || !this._isValid()) return; + var camera = cc.Camera.findCamera(this.node); + this.target = camera ? camera.getScreenToWorldPoint(this._pressPoint) : this._pressPoint; + } + }); + cc.MouseJoint = module.exports = MouseJoint; + }), { + "../CCPhysicsTypes": 216 + } ], + 230: [ (function(require, module, exports) { + "use strict"; + var PTM_RATIO = require("../CCPhysicsTypes").PTM_RATIO; + var ANGLE_TO_PHYSICS_ANGLE = require("../CCPhysicsTypes").ANGLE_TO_PHYSICS_ANGLE; + var PrismaticJoint = cc.Class({ + name: "cc.PrismaticJoint", + extends: cc.Joint, + editor: false, + properties: { + localAxisA: { + default: cc.v2(1, 0), + tooltip: false + }, + referenceAngle: { + default: 0, + tooltip: false + }, + enableLimit: { + default: false, + tooltip: false + }, + enableMotor: { + default: false, + tooltip: false + }, + lowerLimit: { + default: 0, + tooltip: false + }, + upperLimit: { + default: 0, + tooltip: false + }, + _maxMotorForce: 0, + _motorSpeed: 0, + maxMotorForce: { + tooltip: false, + get: function get() { + return this._maxMotorForce; + }, + set: function set(value) { + this._maxMotorForce = value; + this._joint && this._joint.SetMaxMotorForce(value); + } + }, + motorSpeed: { + tooltip: false, + get: function get() { + return this._motorSpeed; + }, + set: function set(value) { + this._motorSpeed = value; + this._joint && this._joint.SetMotorSpeed(value); + } + } + }, + _createJointDef: function _createJointDef() { + var def = new b2.PrismaticJointDef(); + def.localAnchorA = new b2.Vec2(this.anchor.x / PTM_RATIO, this.anchor.y / PTM_RATIO); + def.localAnchorB = new b2.Vec2(this.connectedAnchor.x / PTM_RATIO, this.connectedAnchor.y / PTM_RATIO); + def.localAxisA = new b2.Vec2(this.localAxisA.x, this.localAxisA.y); + def.referenceAngle = this.referenceAngle * ANGLE_TO_PHYSICS_ANGLE; + def.enableLimit = this.enableLimit; + def.lowerTranslation = this.lowerLimit / PTM_RATIO; + def.upperTranslation = this.upperLimit / PTM_RATIO; + def.enableMotor = this.enableMotor; + def.maxMotorForce = this.maxMotorForce; + def.motorSpeed = this.motorSpeed; + return def; + } + }); + cc.PrismaticJoint = module.exports = PrismaticJoint; + }), { + "../CCPhysicsTypes": 216 + } ], + 231: [ (function(require, module, exports) { + "use strict"; + var PTM_RATIO = require("../CCPhysicsTypes").PTM_RATIO; + var ANGLE_TO_PHYSICS_ANGLE = require("../CCPhysicsTypes").ANGLE_TO_PHYSICS_ANGLE; + var PHYSICS_ANGLE_TO_ANGLE = require("../CCPhysicsTypes").PHYSICS_ANGLE_TO_ANGLE; + var RevoluteJoint = cc.Class({ + name: "cc.RevoluteJoint", + extends: cc.Joint, + editor: false, + properties: { + _maxMotorTorque: 0, + _motorSpeed: 0, + _enableLimit: false, + _enableMotor: false, + referenceAngle: { + default: 0, + tooltip: false + }, + lowerAngle: { + default: 0, + tooltip: false + }, + upperAngle: { + default: 0, + tooltip: false + }, + maxMotorTorque: { + tooltip: false, + get: function get() { + return this._maxMotorTorque; + }, + set: function set(value) { + this._maxMotorTorque = value; + this._joint && this._joint.SetMaxMotorTorque(value); + } + }, + motorSpeed: { + tooltip: false, + get: function get() { + return this._motorSpeed; + }, + set: function set(value) { + this._motorSpeed = value; + this._joint && this._joint.SetMotorSpeed(value * ANGLE_TO_PHYSICS_ANGLE); + } + }, + enableLimit: { + tooltip: false, + get: function get() { + return this._enableLimit; + }, + set: function set(value) { + this._enableLimit = value; + this._joint && this._joint.EnableLimit(value); + } + }, + enableMotor: { + tooltip: false, + get: function get() { + return this._enableMotor; + }, + set: function set(value) { + this._enableMotor = value; + this._joint && this._joint.EnableMotor(value); + } + } + }, + getJointAngle: function getJointAngle() { + if (this._joint) return this._joint.GetJointAngle() * PHYSICS_ANGLE_TO_ANGLE; + return 0; + }, + setLimits: function setLimits(lower, upper) { + if (this._joint) return this._joint.SetLimits(lower * ANGLE_TO_PHYSICS_ANGLE, upper * ANGLE_TO_PHYSICS_ANGLE); + }, + _createJointDef: function _createJointDef() { + var def = new b2.RevoluteJointDef(); + def.localAnchorA = new b2.Vec2(this.anchor.x / PTM_RATIO, this.anchor.y / PTM_RATIO); + def.localAnchorB = new b2.Vec2(this.connectedAnchor.x / PTM_RATIO, this.connectedAnchor.y / PTM_RATIO); + def.lowerAngle = this.upperAngle * ANGLE_TO_PHYSICS_ANGLE; + def.upperAngle = this.lowerAngle * ANGLE_TO_PHYSICS_ANGLE; + def.maxMotorTorque = this.maxMotorTorque; + def.motorSpeed = this.motorSpeed * ANGLE_TO_PHYSICS_ANGLE; + def.enableLimit = this.enableLimit; + def.enableMotor = this.enableMotor; + def.referenceAngle = this.referenceAngle * ANGLE_TO_PHYSICS_ANGLE; + return def; + } + }); + cc.RevoluteJoint = module.exports = RevoluteJoint; + }), { + "../CCPhysicsTypes": 216 + } ], + 232: [ (function(require, module, exports) { + "use strict"; + var PTM_RATIO = require("../CCPhysicsTypes").PTM_RATIO; + var RopeJoint = cc.Class({ + name: "cc.RopeJoint", + extends: cc.Joint, + editor: false, + properties: { + _maxLength: 1, + maxLength: { + tooltip: false, + get: function get() { + return this._maxLength; + }, + set: function set(value) { + this._maxLength = value; + this._joint && this._joint.SetMaxLength(value); + } + } + }, + _createJointDef: function _createJointDef() { + var def = new b2.RopeJointDef(); + def.localAnchorA = new b2.Vec2(this.anchor.x / PTM_RATIO, this.anchor.y / PTM_RATIO); + def.localAnchorB = new b2.Vec2(this.connectedAnchor.x / PTM_RATIO, this.connectedAnchor.y / PTM_RATIO); + def.maxLength = this.maxLength / PTM_RATIO; + return def; + } + }); + cc.RopeJoint = module.exports = RopeJoint; + }), { + "../CCPhysicsTypes": 216 + } ], + 233: [ (function(require, module, exports) { + "use strict"; + var PTM_RATIO = require("../CCPhysicsTypes").PTM_RATIO; + var ANGLE_TO_PHYSICS_ANGLE = require("../CCPhysicsTypes").ANGLE_TO_PHYSICS_ANGLE; + var WeldJoint = cc.Class({ + name: "cc.WeldJoint", + extends: cc.Joint, + editor: false, + properties: { + referenceAngle: { + default: 0, + tooltip: false + }, + _frequency: 0, + _dampingRatio: 0, + frequency: { + tooltip: false, + get: function get() { + return this._frequency; + }, + set: function set(value) { + this._frequency = value; + this._joint && this._joint.SetFrequency(value); + } + }, + dampingRatio: { + tooltip: false, + get: function get() { + return this._dampingRatio; + }, + set: function set(value) { + this._dampingRatio = value; + this._joint && this._joint.SetDampingRatio(value); + } + } + }, + _createJointDef: function _createJointDef() { + var def = new b2.WeldJointDef(); + def.localAnchorA = new b2.Vec2(this.anchor.x / PTM_RATIO, this.anchor.y / PTM_RATIO); + def.localAnchorB = new b2.Vec2(this.connectedAnchor.x / PTM_RATIO, this.connectedAnchor.y / PTM_RATIO); + def.referenceAngle = this.referenceAngle * ANGLE_TO_PHYSICS_ANGLE; + def.frequencyHz = this.frequency; + def.dampingRatio = this.dampingRatio; + return def; + } + }); + cc.WeldJoint = module.exports = WeldJoint; + }), { + "../CCPhysicsTypes": 216 + } ], + 234: [ (function(require, module, exports) { + "use strict"; + var PTM_RATIO = require("../CCPhysicsTypes").PTM_RATIO; + var ANGLE_TO_PHYSICS_ANGLE = require("../CCPhysicsTypes").ANGLE_TO_PHYSICS_ANGLE; + var WheelJoint = cc.Class({ + name: "cc.WheelJoint", + extends: cc.Joint, + editor: false, + properties: { + _maxMotorTorque: 0, + _motorSpeed: 0, + _enableMotor: false, + _frequency: 2, + _dampingRatio: .7, + localAxisA: { + default: cc.v2(1, 0), + tooltip: false + }, + maxMotorTorque: { + tooltip: false, + get: function get() { + return this._maxMotorTorque; + }, + set: function set(value) { + this._maxMotorTorque = value; + this._joint && this._joint.SetMaxMotorTorque(value); + } + }, + motorSpeed: { + tooltip: false, + get: function get() { + return this._motorSpeed; + }, + set: function set(value) { + this._motorSpeed = value; + this._joint && this._joint.SetMotorSpeed(value * ANGLE_TO_PHYSICS_ANGLE); + } + }, + enableMotor: { + tooltip: false, + get: function get() { + return this._enableMotor; + }, + set: function set(value) { + this._enableMotor = value; + this._joint && this._joint.EnableMotor(value); + } + }, + frequency: { + tooltip: false, + get: function get() { + return this._frequency; + }, + set: function set(value) { + this._frequency = value; + this._joint && this._joint.SetSpringFrequencyHz(value); + } + }, + dampingRatio: { + tooltip: false, + get: function get() { + return this._dampingRatio; + }, + set: function set(value) { + this._dampingRatio = value; + this._joint && this._joint.SetDampingRatio(value); + } + } + }, + _createJointDef: function _createJointDef() { + var def = new b2.WheelJointDef(); + def.localAnchorA = new b2.Vec2(this.anchor.x / PTM_RATIO, this.anchor.y / PTM_RATIO); + def.localAnchorB = new b2.Vec2(this.connectedAnchor.x / PTM_RATIO, this.connectedAnchor.y / PTM_RATIO); + def.localAxisA = new b2.Vec2(this.localAxisA.x, this.localAxisA.y); + def.maxMotorTorque = this.maxMotorTorque; + def.motorSpeed = this.motorSpeed * ANGLE_TO_PHYSICS_ANGLE; + def.enableMotor = this.enableMotor; + def.dampingRatio = this.dampingRatio; + def.frequencyHz = this.frequency; + return def; + } + }); + cc.WheelJoint = module.exports = WheelJoint; + }), { + "../CCPhysicsTypes": 216 + } ], + 235: [ (function(require, module, exports) { + "use strict"; + var BodyType = require("../CCPhysicsTypes").BodyType; + function PhysicsAABBQueryCallback() { + this._point = new b2.Vec2(); + this._isPoint = false; + this._fixtures = []; + } + PhysicsAABBQueryCallback.prototype.init = function(point) { + if (point) { + this._isPoint = true; + this._point.x = point.x; + this._point.y = point.y; + } else this._isPoint = false; + this._fixtures.length = 0; + }; + PhysicsAABBQueryCallback.prototype.ReportFixture = function(fixture) { + var body = fixture.GetBody(); + if (body.GetType() === BodyType.Dynamic) if (this._isPoint) { + if (fixture.TestPoint(this._point)) { + this._fixtures.push(fixture); + return false; + } + } else this._fixtures.push(fixture); + return true; + }; + PhysicsAABBQueryCallback.prototype.getFixture = function() { + return this._fixtures[0]; + }; + PhysicsAABBQueryCallback.prototype.getFixtures = function() { + return this._fixtures; + }; + cc.PhysicsAABBQueryCallback = module.exports = PhysicsAABBQueryCallback; + }), { + "../CCPhysicsTypes": 216 + } ], + 236: [ (function(require, module, exports) { + "use strict"; + function PhysicsContactListener() { + this._contactFixtures = []; + } + PhysicsContactListener.prototype.setBeginContact = function(cb) { + this._BeginContact = cb; + }; + PhysicsContactListener.prototype.setEndContact = function(cb) { + this._EndContact = cb; + }; + PhysicsContactListener.prototype.setPreSolve = function(cb) { + this._PreSolve = cb; + }; + PhysicsContactListener.prototype.setPostSolve = function(cb) { + this._PostSolve = cb; + }; + PhysicsContactListener.prototype.BeginContact = function(contact) { + if (!this._BeginContact) return; + var fixtureA = contact.GetFixtureA(); + var fixtureB = contact.GetFixtureB(); + var fixtures = this._contactFixtures; + contact._shouldReport = false; + if (-1 !== fixtures.indexOf(fixtureA) || -1 !== fixtures.indexOf(fixtureB)) { + contact._shouldReport = true; + this._BeginContact(contact); + } + }; + PhysicsContactListener.prototype.EndContact = function(contact) { + if (this._EndContact && contact._shouldReport) { + contact._shouldReport = false; + this._EndContact(contact); + } + }; + PhysicsContactListener.prototype.PreSolve = function(contact, oldManifold) { + this._PreSolve && contact._shouldReport && this._PreSolve(contact, oldManifold); + }; + PhysicsContactListener.prototype.PostSolve = function(contact, impulse) { + this._PostSolve && contact._shouldReport && this._PostSolve(contact, impulse); + }; + PhysicsContactListener.prototype.registerContactFixture = function(fixture) { + this._contactFixtures.push(fixture); + }; + PhysicsContactListener.prototype.unregisterContactFixture = function(fixture) { + cc.js.array.remove(this._contactFixtures, fixture); + }; + cc.PhysicsContactListener = module.exports = PhysicsContactListener; + }), {} ], + 237: [ (function(require, module, exports) { + "use strict"; + var PTM_RATIO = require("../CCPhysicsTypes").PTM_RATIO; + var _tmp_vec2 = cc.v2(); + var GREEN_COLOR = cc.Color.GREEN; + var RED_COLOR = cc.Color.RED; + function PhysicsDebugDraw(drawer) { + b2.Draw.call(this); + this._drawer = drawer; + this._xf = this._dxf = new b2.Transform(); + } + cc.js.extend(PhysicsDebugDraw, b2.Draw); + cc.js.mixin(PhysicsDebugDraw.prototype, { + _DrawPolygon: function _DrawPolygon(vertices, vertexCount) { + var drawer = this._drawer; + for (var i = 0; i < vertexCount; i++) { + b2.Transform.MulXV(this._xf, vertices[i], _tmp_vec2); + var x = _tmp_vec2.x * PTM_RATIO, y = _tmp_vec2.y * PTM_RATIO; + 0 === i ? drawer.moveTo(x, y) : drawer.lineTo(x, y); + } + drawer.close(); + }, + DrawPolygon: function DrawPolygon(vertices, vertexCount, color) { + this._applyStrokeColor(color); + this._DrawPolygon(vertices, vertexCount); + this._drawer.stroke(); + }, + DrawSolidPolygon: function DrawSolidPolygon(vertices, vertexCount, color) { + this._applyFillColor(color); + this._DrawPolygon(vertices, vertexCount); + this._drawer.fill(); + this._drawer.stroke(); + }, + _DrawCircle: function _DrawCircle(center, radius) { + var p = this._xf.p; + this._drawer.circle((center.x + p.x) * PTM_RATIO, (center.y + p.y) * PTM_RATIO, radius * PTM_RATIO); + }, + DrawCircle: function DrawCircle(center, radius, color) { + this._applyStrokeColor(color); + this._DrawCircle(center, radius); + this._drawer.stroke(); + }, + DrawSolidCircle: function DrawSolidCircle(center, radius, axis, color) { + this._applyFillColor(color); + this._DrawCircle(center, radius); + this._drawer.fill(); + }, + DrawSegment: function DrawSegment(p1, p2, color) { + var drawer = this._drawer; + if (p1.x === p2.x && p1.y === p2.y) { + this._applyFillColor(color); + this._DrawCircle(p1, 2 / PTM_RATIO); + drawer.fill(); + return; + } + this._applyStrokeColor(color); + b2.Transform.MulXV(this._xf, p1, _tmp_vec2); + drawer.moveTo(_tmp_vec2.x * PTM_RATIO, _tmp_vec2.y * PTM_RATIO); + b2.Transform.MulXV(this._xf, p2, _tmp_vec2); + drawer.lineTo(_tmp_vec2.x * PTM_RATIO, _tmp_vec2.y * PTM_RATIO); + drawer.stroke(); + }, + DrawTransform: function DrawTransform(xf) { + var drawer = this._drawer; + drawer.strokeColor = RED_COLOR; + _tmp_vec2.x = _tmp_vec2.y = 0; + b2.Transform.MulXV(xf, _tmp_vec2, _tmp_vec2); + drawer.moveTo(_tmp_vec2.x * PTM_RATIO, _tmp_vec2.y * PTM_RATIO); + _tmp_vec2.x = 1; + _tmp_vec2.y = 0; + b2.Transform.MulXV(xf, _tmp_vec2, _tmp_vec2); + drawer.lineTo(_tmp_vec2.x * PTM_RATIO, _tmp_vec2.y * PTM_RATIO); + drawer.stroke(); + drawer.strokeColor = GREEN_COLOR; + _tmp_vec2.x = _tmp_vec2.y = 0; + b2.Transform.MulXV(xf, _tmp_vec2, _tmp_vec2); + drawer.moveTo(_tmp_vec2.x * PTM_RATIO, _tmp_vec2.y * PTM_RATIO); + _tmp_vec2.x = 0; + _tmp_vec2.y = 1; + b2.Transform.MulXV(xf, _tmp_vec2, _tmp_vec2); + drawer.lineTo(_tmp_vec2.x * PTM_RATIO, _tmp_vec2.y * PTM_RATIO); + drawer.stroke(); + }, + DrawPoint: function DrawPoint(center, radius, color) {}, + _applyStrokeColor: function _applyStrokeColor(color) { + var strokeColor = this._drawer.strokeColor; + strokeColor.r = 255 * color.r; + strokeColor.g = 255 * color.g; + strokeColor.b = 255 * color.b; + strokeColor.a = 150; + this._drawer.strokeColor = strokeColor; + }, + _applyFillColor: function _applyFillColor(color) { + var fillColor = this._drawer.fillColor; + fillColor.r = 255 * color.r; + fillColor.g = 255 * color.g; + fillColor.b = 255 * color.b; + fillColor.a = 150; + this._drawer.fillColor = fillColor; + }, + PushTransform: function PushTransform(xf) { + this._xf = xf; + }, + PopTransform: function PopTransform() { + this._xf = this._dxf; + } + }); + module.exports = PhysicsDebugDraw; + }), { + "../CCPhysicsTypes": 216 + } ], + 238: [ (function(require, module, exports) { + "use strict"; + function PhysicsRayCastCallback() { + this._type = 0; + this._fixtures = []; + this._points = []; + this._normals = []; + this._fractions = []; + } + PhysicsRayCastCallback.prototype.init = function(type) { + this._type = type; + this._fixtures.length = 0; + this._points.length = 0; + this._normals.length = 0; + this._fractions.length = 0; + }; + PhysicsRayCastCallback.prototype.ReportFixture = function(fixture, point, normal, fraction) { + if (0 === this._type) { + this._fixtures[0] = fixture; + this._points[0] = point; + this._normals[0] = normal; + this._fractions[0] = fraction; + return fraction; + } + this._fixtures.push(fixture); + this._points.push(cc.v2(point)); + this._normals.push(cc.v2(normal)); + this._fractions.push(fraction); + if (1 === this._type) return 0; + if (this._type >= 2) return 1; + return fraction; + }; + PhysicsRayCastCallback.prototype.getFixtures = function() { + return this._fixtures; + }; + PhysicsRayCastCallback.prototype.getPoints = function() { + return this._points; + }; + PhysicsRayCastCallback.prototype.getNormals = function() { + return this._normals; + }; + PhysicsRayCastCallback.prototype.getFractions = function() { + return this._fractions; + }; + cc.PhysicsRayCastCallback = module.exports = PhysicsRayCastCallback; + }), {} ], + 239: [ (function(require, module, exports) { + "use strict"; + function getWorldRotation(node) { + var rot = node.angle; + var parent = node.parent; + while (parent.parent) { + rot += parent.angle; + parent = parent.parent; + } + return -rot; + } + function getWorldScale(node) { + var scaleX = node.scaleX; + var scaleY = node.scaleY; + var parent = node.parent; + while (parent.parent) { + scaleX *= parent.scaleX; + scaleY *= parent.scaleY; + parent = parent.parent; + } + return cc.v2(scaleX, scaleY); + } + function convertToNodeRotation(node, rotation) { + rotation -= -node.angle; + var parent = node.parent; + while (parent.parent) { + rotation -= -parent.angle; + parent = parent.parent; + } + return rotation; + } + module.exports = { + getWorldRotation: getWorldRotation, + getWorldScale: getWorldScale, + convertToNodeRotation: convertToNodeRotation + }; + }), {} ], + 240: [ (function(require, module, exports) { + "use strict"; + var js = require("./js"); + var Enum = require("./CCEnum"); + var utils = require("./utils"); + var _isPlainEmptyObj_DEV = utils.isPlainEmptyObj_DEV; + var _cloneable_DEV = utils.cloneable_DEV; + var Attr = require("./attribute"); + var DELIMETER = Attr.DELIMETER; + var preprocess = require("./preprocess-class"); + require("./requiring-frame"); + var BUILTIN_ENTRIES = [ "name", "extends", "mixins", "ctor", "__ctor__", "properties", "statics", "editor", "__ES6__" ]; + var INVALID_STATICS_DEV = false; + function pushUnique(array, item) { + array.indexOf(item) < 0 && array.push(item); + } + var deferredInitializer = { + datas: null, + push: function push(data) { + if (this.datas) this.datas.push(data); else { + this.datas = [ data ]; + var self = this; + setTimeout((function() { + self.init(); + }), 0); + } + }, + init: function init() { + var datas = this.datas; + if (datas) { + for (var i = 0; i < datas.length; ++i) { + var data = datas[i]; + var cls = data.cls; + var properties = data.props; + "function" === typeof properties && (properties = properties()); + var name = js.getClassName(cls); + properties ? declareProperties(cls, name, properties, cls.$super, data.mixins) : cc.errorID(3633, name); + } + this.datas = null; + } + } + }; + function appendProp(cls, name) { + false; + pushUnique(cls.__props__, name); + } + function defineProp(cls, className, propName, val, es6) { + var defaultValue = val["default"]; + false; + Attr.setClassAttr(cls, propName, "default", defaultValue); + appendProp(cls, propName); + parseAttributes(cls, val, className, propName, false); + var i; + false, false; + } + function defineGetSet(cls, name, propName, val, es6) { + var getter = val.get; + var setter = val.set; + var proto = cls.prototype; + var d = Object.getOwnPropertyDescriptor(proto, propName); + var setterUndefined = !d; + if (getter) { + false; + parseAttributes(cls, val, name, propName, true); + false, false; + Attr.setClassAttr(cls, propName, "serializable", false); + false; + es6 || js.get(proto, propName, getter, setterUndefined, setterUndefined); + false, false; + } + if (setter) { + if (!es6) { + false; + js.set(proto, propName, setter, setterUndefined, setterUndefined); + } + false, false; + } + } + function getDefault(defaultVal) { + if ("function" === typeof defaultVal) { + false; + return defaultVal(); + } + return defaultVal; + } + function mixinWithInherited(dest, src, filter) { + for (var prop in src) dest.hasOwnProperty(prop) || filter && !filter(prop) || Object.defineProperty(dest, prop, js.getPropertyDescriptor(src, prop)); + } + function doDefine(className, baseClass, mixins, options) { + var shouldAddProtoCtor; + var __ctor__ = options.__ctor__; + var ctor = options.ctor; + var __es6__ = options.__ES6__; + var ctorToUse; + false; + var ctors; + var fireClass; + if (__es6__) { + ctors = [ ctor ]; + fireClass = ctor; + } else { + ctors = __ctor__ ? [ __ctor__ ] : _getAllCtors(baseClass, mixins, options); + fireClass = _createCtor(ctors, baseClass, className, options); + js.value(fireClass, "extend", (function(options) { + options["extends"] = this; + return CCClass(options); + }), true); + } + js.value(fireClass, "__ctors__", ctors.length > 0 ? ctors : null, true); + var prototype = fireClass.prototype; + if (baseClass) { + if (!__es6__) { + js.extend(fireClass, baseClass); + prototype = fireClass.prototype; + } + fireClass.$super = baseClass; + false; + } + if (mixins) { + for (var m = mixins.length - 1; m >= 0; m--) { + var mixin = mixins[m]; + mixinWithInherited(prototype, mixin.prototype); + mixinWithInherited(fireClass, mixin, (function(prop) { + return mixin.hasOwnProperty(prop) && true; + })); + CCClass._isCCClass(mixin) && mixinWithInherited(Attr.getClassAttrs(fireClass), Attr.getClassAttrs(mixin)); + } + prototype.constructor = fireClass; + } + __es6__ || (prototype.__initProps__ = compileProps); + js.setClassName(className, fireClass); + return fireClass; + } + function define(className, baseClass, mixins, options) { + var Component = cc.Component; + var frame = cc._RF.peek(); + if (frame && js.isChildClassOf(baseClass, Component)) { + if (js.isChildClassOf(frame.cls, Component)) { + cc.errorID(3615); + return null; + } + false; + className = className || frame.script; + } + var cls = doDefine(className, baseClass, mixins, options); + if (frame) if (js.isChildClassOf(baseClass, Component)) { + var uuid = frame.uuid; + if (uuid) { + js._setClassId(uuid, cls); + false; + } + frame.cls = cls; + } else js.isChildClassOf(frame.cls, Component) || (frame.cls = cls); + return cls; + } + function normalizeClassName_DEV(className) { + var DefaultName = "CCClass"; + if (className) { + className = className.replace(/^[^$A-Za-z_]/, "_").replace(/[^0-9A-Za-z_$]/g, "_"); + try { + Function("function " + className + "(){}")(); + return className; + } catch (e) {} + } + return DefaultName; + } + function getNewValueTypeCodeJit(value) { + var clsName = js.getClassName(value); + var type = value.constructor; + var res = "new " + clsName + "("; + for (var i = 0; i < type.__props__.length; i++) { + var prop = type.__props__[i]; + var propVal = value[prop]; + false; + res += propVal; + i < type.__props__.length - 1 && (res += ","); + } + return res + ")"; + } + function escapeForJS(s) { + return JSON.stringify(s).replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029"); + } + function getInitPropsJit(attrs, propList) { + var F = []; + var func = ""; + for (var i = 0; i < propList.length; i++) { + var prop = propList[i]; + var attrKey = prop + DELIMETER + "default"; + if (attrKey in attrs) { + var statement; + statement = IDENTIFIER_RE.test(prop) ? "this." + prop + "=" : "this[" + escapeForJS(prop) + "]="; + var expression; + var def = attrs[attrKey]; + if ("object" === typeof def && def) expression = def instanceof cc.ValueType ? getNewValueTypeCodeJit(def) : Array.isArray(def) ? "[]" : "{}"; else if ("function" === typeof def) { + var index = F.length; + F.push(def); + expression = "F[" + index + "]()"; + false; + } else expression = "string" === typeof def ? escapeForJS(def) : def; + statement = statement + expression + ";\n"; + func += statement; + } + } + var initProps; + initProps = 0 === F.length ? Function(func) : Function("F", "return (function(){\n" + func + "})")(F); + return initProps; + } + function getInitProps(attrs, propList) { + var props = null; + var simpleEnd = 0; + var valueTypeEnd = 0; + (function() { + var simples = null; + var valueTypes = null; + var advanceds = null; + for (var i = 0; i < propList.length; ++i) { + var prop = propList[i]; + var attrKey = prop + DELIMETER + "default"; + if (attrKey in attrs) { + var def = attrs[attrKey]; + if ("object" === typeof def && def || "function" === typeof def) if (def instanceof cc.ValueType) { + valueTypes || (valueTypes = []); + valueTypes.push(prop, def); + } else { + advanceds || (advanceds = []); + advanceds.push(prop, def); + } else { + simples || (simples = []); + simples.push(prop, def); + } + } + } + simpleEnd = simples ? simples.length : 0; + valueTypeEnd = simpleEnd + (valueTypes ? valueTypes.length : 0); + var totalLength = valueTypeEnd + (advanceds ? advanceds.length : 0); + props = new Array(totalLength); + for (var _i = 0; _i < simpleEnd; ++_i) props[_i] = simples[_i]; + for (var _i2 = simpleEnd; _i2 < valueTypeEnd; ++_i2) props[_i2] = valueTypes[_i2 - simpleEnd]; + for (var _i3 = valueTypeEnd; _i3 < totalLength; ++_i3) props[_i3] = advanceds[_i3 - valueTypeEnd]; + })(); + return function() { + var i = 0; + for (;i < simpleEnd; i += 2) this[props[i]] = props[i + 1]; + for (;i < valueTypeEnd; i += 2) this[props[i]] = props[i + 1].clone(); + for (;i < props.length; i += 2) { + var def = props[i + 1]; + if (Array.isArray(def)) this[props[i]] = []; else { + var value; + if ("object" === typeof def) value = {}; else { + false; + value = def(); + } + this[props[i]] = value; + } + } + }; + } + var IDENTIFIER_RE = /^[A-Za-z_$][0-9A-Za-z_$]*$/; + function compileProps(actualClass) { + var attrs = Attr.getClassAttrs(actualClass); + var propList = actualClass.__props__; + if (null === propList) { + deferredInitializer.init(); + propList = actualClass.__props__; + } + var initProps = getInitPropsJit(attrs, propList); + actualClass.prototype.__initProps__ = initProps; + initProps.call(this); + } + var _createCtor = function(ctors, baseClass, className, options) { + var superCallBounded = baseClass && boundSuperCalls(baseClass, options, className); + var ctorName = "CCClass"; + var body = "return function " + ctorName + "(){\n"; + superCallBounded && (body += "this._super=null;\n"); + body += "this.__initProps__(" + ctorName + ");\n"; + var ctorLen = ctors.length; + if (ctorLen > 0) { + var useTryCatch = false; + useTryCatch && (body += "try{\n"); + var SNIPPET = "].apply(this,arguments);\n"; + if (1 === ctorLen) body += ctorName + ".__ctors__[0" + SNIPPET; else { + body += "var cs=" + ctorName + ".__ctors__;\n"; + for (var i = 0; i < ctorLen; i++) body += "cs[" + i + SNIPPET; + } + useTryCatch && (body += "}catch(e){\ncc._throw(e);\n}\n"); + } + body += "}"; + return Function(body)(); + }; + function _validateCtor_DEV(ctor, baseClass, className, options) { + var originCtor; + false; + !(ctor.length > 0) || className && className.startsWith("cc.") || cc.warnID(3617, className); + return ctor; + } + function _getAllCtors(baseClass, mixins, options) { + function getCtors(cls) { + return CCClass._isCCClass(cls) ? cls.__ctors__ || [] : [ cls ]; + } + var ctors = []; + var baseOrMixins = [ baseClass ].concat(mixins); + for (var b = 0; b < baseOrMixins.length; b++) { + var baseOrMixin = baseOrMixins[b]; + if (baseOrMixin) { + var baseCtors = getCtors(baseOrMixin); + for (var c = 0; c < baseCtors.length; c++) pushUnique(ctors, baseCtors[c]); + } + } + var ctor = options.ctor; + ctor && ctors.push(ctor); + return ctors; + } + var SuperCallReg = /xyz/.test((function() { + xyz; + })) ? /\b\._super\b/ : /.*/; + var SuperCallRegStrict = /xyz/.test((function() { + xyz; + })) ? /this\._super\s*\(/ : /(NONE){99}/; + function boundSuperCalls(baseClass, options, className) { + var hasSuperCall = false; + for (var funcName in options) { + if (BUILTIN_ENTRIES.indexOf(funcName) >= 0) continue; + var func = options[funcName]; + if ("function" !== typeof func) continue; + var pd = js.getPropertyDescriptor(baseClass.prototype, funcName); + if (pd) { + var superFunc = pd.value; + if ("function" === typeof superFunc) { + if (SuperCallReg.test(func)) { + hasSuperCall = true; + options[funcName] = (function(superFunc, func) { + return function() { + var tmp = this._super; + this._super = superFunc; + var ret = func.apply(this, arguments); + this._super = tmp; + return ret; + }; + })(superFunc, func); + } + continue; + } + } + false; + } + return hasSuperCall; + } + function declareProperties(cls, className, properties, baseClass, mixins, es6) { + cls.__props__ = []; + baseClass && baseClass.__props__ && (cls.__props__ = baseClass.__props__.slice()); + if (mixins) for (var m = 0; m < mixins.length; ++m) { + var mixin = mixins[m]; + mixin.__props__ && (cls.__props__ = cls.__props__.concat(mixin.__props__.filter((function(x) { + return cls.__props__.indexOf(x) < 0; + })))); + } + if (properties) { + preprocess.preprocessAttrs(properties, className, cls, es6); + for (var propName in properties) { + var val = properties[propName]; + "default" in val ? defineProp(cls, className, propName, val, es6) : defineGetSet(cls, className, propName, val, es6); + } + } + var attrs = Attr.getClassAttrs(cls); + cls.__values__ = cls.__props__.filter((function(prop) { + return false !== attrs[prop + DELIMETER + "serializable"]; + })); + } + function CCClass(options) { + options = options || {}; + var name = options.name; + var base = options["extends"]; + var mixins = options.mixins; + var cls = define(name, base, mixins, options); + name || (name = cc.js.getClassName(cls)); + cls._sealed = true; + base && (base._sealed = false); + var properties = options.properties; + if ("function" === typeof properties || base && null === base.__props__ || mixins && mixins.some((function(x) { + return null === x.__props__; + }))) { + false; + deferredInitializer.push({ + cls: cls, + props: properties, + mixins: mixins + }); + cls.__props__ = cls.__values__ = null; + } else declareProperties(cls, name, properties, base, options.mixins, options.__ES6__); + var statics = options.statics; + if (statics) { + var staticPropName; + false; + for (staticPropName in statics) cls[staticPropName] = statics[staticPropName]; + } + for (var funcName in options) { + if (BUILTIN_ENTRIES.indexOf(funcName) >= 0) continue; + var func = options[funcName]; + if (!preprocess.validateMethodWithProps(func, funcName, name, cls, base)) continue; + js.value(cls.prototype, funcName, func, true, true); + } + var editor = options.editor; + editor && cc.Component._registerEditorProps(cls, editor); + return cls; + } + CCClass._isCCClass = function(constructor) { + return constructor && constructor.hasOwnProperty("__ctors__"); + }; + CCClass._fastDefine = function(className, constructor, serializableFields) { + js.setClassName(className, constructor); + var props = constructor.__props__ = constructor.__values__ = Object.keys(serializableFields); + var attrs = Attr.getClassAttrs(constructor); + for (var i = 0; i < props.length; i++) { + var key = props[i]; + attrs[key + DELIMETER + "visible"] = false; + attrs[key + DELIMETER + "default"] = serializableFields[key]; + } + }; + CCClass.Attr = Attr; + CCClass.attr = Attr.attr; + CCClass.getInheritanceChain = function(klass) { + var chain = []; + for (;;) { + klass = js.getSuper(klass); + if (!klass) break; + klass !== Object && chain.push(klass); + } + return chain; + }; + var PrimitiveTypes = { + Integer: "Number", + Float: "Number", + Boolean: "Boolean", + String: "String" + }; + var onAfterProps_ET = []; + function parseAttributes(cls, attributes, className, propName, usedInGetter) { + var ERR_Type = ""; + var attrs = null; + var propNamePrefix = ""; + function initAttrs() { + propNamePrefix = propName + DELIMETER; + return attrs = Attr.getClassAttrs(cls); + } + false, false; + var type = attributes.type; + if (type) { + var primitiveType = PrimitiveTypes[type]; + if (primitiveType) { + (attrs || initAttrs())[propNamePrefix + "type"] = type; + (false, false) && !attributes._short && onAfterProps_ET.push(Attr.getTypeChecker_ET(primitiveType, "cc." + type)); + } else if ("Object" === type) false; else if (type === Attr.ScriptUuid) { + (attrs || initAttrs())[propNamePrefix + "type"] = "Script"; + attrs[propNamePrefix + "ctor"] = cc.ScriptAsset; + } else if ("object" === typeof type) if (Enum.isEnum(type)) { + (attrs || initAttrs())[propNamePrefix + "type"] = "Enum"; + attrs[propNamePrefix + "enumList"] = Enum.getList(type); + } else false; else if ("function" === typeof type) { + (attrs || initAttrs())[propNamePrefix + "type"] = "Object"; + attrs[propNamePrefix + "ctor"] = type; + (false, false) && !attributes._short && onAfterProps_ET.push(Attr.getObjTypeChecker_ET(type)); + } else false; + } + function parseSimpleAttr(attrName, expectType) { + if (attrName in attributes) { + var val = attributes[attrName]; + typeof val === expectType && ((attrs || initAttrs())[propNamePrefix + attrName] = val); + } + } + if (attributes.editorOnly) { + false; + (attrs || initAttrs())[propNamePrefix + "editorOnly"] = true; + } + false; + if (false === attributes.serializable) { + false; + (attrs || initAttrs())[propNamePrefix + "serializable"] = false; + } + parseSimpleAttr("formerlySerializedAs", "string"); + false; + var visible; + var startsWithUS; + false; + var range = attributes.range; + if (range) if (Array.isArray(range)) if (range.length >= 2) { + (attrs || initAttrs())[propNamePrefix + "min"] = range[0]; + attrs[propNamePrefix + "max"] = range[1]; + range.length > 2 && (attrs[propNamePrefix + "step"] = range[2]); + } else false; else false; + parseSimpleAttr("min", "number"); + parseSimpleAttr("max", "number"); + parseSimpleAttr("step", "number"); + parseSimpleAttr("userData", "object"); + } + cc.Class = CCClass; + module.exports = { + isArray: function isArray(defaultVal) { + defaultVal = getDefault(defaultVal); + return Array.isArray(defaultVal); + }, + fastDefine: CCClass._fastDefine, + getNewValueTypeCode: (true, getNewValueTypeCodeJit), + IDENTIFIER_RE: IDENTIFIER_RE, + escapeForJS: escapeForJS, + getDefault: getDefault + }; + false; + }), { + "./CCEnum": 242, + "./attribute": 252, + "./js": 261, + "./preprocess-class": 262, + "./requiring-frame": 263, + "./utils": 264 + } ], + 241: [ (function(require, module, exports) { + "use strict"; + require("./CCClass"); + var Preprocess = require("./preprocess-class"); + var js = require("./js"); + var isPlainEmptyObj_DEV = false; + var CACHE_KEY = "__ccclassCache__"; + function fNOP(ctor) { + return ctor; + } + function getSubDict(obj, key) { + return obj[key] || (obj[key] = {}); + } + function checkCtorArgument(decorate) { + return function(target) { + if ("function" === typeof target) return decorate(target); + return function(ctor) { + return decorate(ctor, target); + }; + }; + } + function _checkNormalArgument(validator_DEV, decorate, decoratorName) { + return function(target) { + false; + return function(ctor) { + return decorate(ctor, target); + }; + }; + } + var checkCompArgument = _checkNormalArgument.bind(null, false); + function _argumentChecker(type) { + return _checkNormalArgument.bind(null, false); + } + var checkStringArgument = _argumentChecker("string"); + var checkNumberArgument = _argumentChecker("number"); + function getClassCache(ctor, decoratorName) { + false; + return getSubDict(ctor, CACHE_KEY); + } + function getDefaultFromInitializer(initializer) { + var value; + try { + value = initializer(); + } catch (e) { + return initializer; + } + return "object" !== typeof value || null === value ? value : initializer; + } + function extractActualDefaultValues(ctor) { + var dummyObj; + try { + dummyObj = new ctor(); + } catch (e) { + false; + return {}; + } + return dummyObj; + } + function genProperty(ctor, properties, propName, options, desc, cache) { + var fullOptions; + var isGetset = desc && (desc.get || desc.set); + options && (fullOptions = Preprocess.getFullFormOfProperty(options, isGetset)); + var existsProperty = properties[propName]; + var prop = js.mixin(existsProperty || {}, fullOptions || options || {}); + if (isGetset) { + var errorProps; + false; + desc.get && (prop.get = desc.get); + desc.set && (prop.set = desc.set); + } else { + false; + var defaultValue = void 0; + var isDefaultValueSpecified = false; + if (desc) { + if (desc.initializer) { + defaultValue = getDefaultFromInitializer(desc.initializer); + isDefaultValueSpecified = true; + } + } else { + var actualDefaultValues = cache["default"] || (cache["default"] = extractActualDefaultValues(ctor)); + if (actualDefaultValues.hasOwnProperty(propName)) { + defaultValue = actualDefaultValues[propName]; + isDefaultValueSpecified = true; + } + } + false, false; + prop["default"] = defaultValue; + } + properties[propName] = prop; + } + var ccclass = checkCtorArgument((function(ctor, name) { + var base = js.getSuper(ctor); + base === Object && (base = null); + var proto = { + name: name, + extends: base, + ctor: ctor, + __ES6__: true + }; + var cache = ctor[CACHE_KEY]; + if (cache) { + var decoratedProto = cache.proto; + decoratedProto && js.mixin(proto, decoratedProto); + ctor[CACHE_KEY] = void 0; + } + var res = cc.Class(proto); + var propNames; + var i; + var prop; + var desc; + var func; + false; + return res; + })); + function property(ctorProtoOrOptions, propName, desc) { + var options = null; + function normalized(ctorProto, propName, desc) { + var cache = getClassCache(ctorProto.constructor); + if (cache) { + var ccclassProto = getSubDict(cache, "proto"); + var properties = getSubDict(ccclassProto, "properties"); + genProperty(ctorProto.constructor, properties, propName, options, desc, cache); + } + } + if ("undefined" === typeof propName) { + options = ctorProtoOrOptions; + return normalized; + } + normalized(ctorProtoOrOptions, propName, desc); + } + function createEditorDecorator(argCheckFunc, editorPropName, staticValue) { + return argCheckFunc((function(ctor, decoratedValue) { + var cache = getClassCache(ctor, editorPropName); + if (cache) { + var value = void 0 !== staticValue ? staticValue : decoratedValue; + var proto = getSubDict(cache, "proto"); + getSubDict(proto, "editor")[editorPropName] = value; + } + }), editorPropName); + } + function createDummyDecorator(argCheckFunc) { + return argCheckFunc(fNOP); + } + var executeInEditMode = createDummyDecorator(checkCtorArgument, "executeInEditMode", true); + var requireComponent = createEditorDecorator(checkCompArgument, "requireComponent"); + var menu = createDummyDecorator(checkStringArgument, "menu"); + var executionOrder = createEditorDecorator(checkNumberArgument, "executionOrder"); + var disallowMultiple = createDummyDecorator(checkCtorArgument, "disallowMultiple"); + var playOnFocus = createDummyDecorator(checkCtorArgument, "playOnFocus", true); + var inspector = createDummyDecorator(checkStringArgument, "inspector"); + var icon = createDummyDecorator(checkStringArgument, "icon"); + var help = createDummyDecorator(checkStringArgument, "help"); + function mixins() { + var mixins = []; + for (var i = 0; i < arguments.length; i++) mixins[i] = arguments[i]; + return function(ctor) { + var cache = getClassCache(ctor, "mixins"); + cache && (getSubDict(cache, "proto").mixins = mixins); + }; + } + cc._decorator = module.exports = { + ccclass: ccclass, + property: property, + executeInEditMode: executeInEditMode, + requireComponent: requireComponent, + menu: menu, + executionOrder: executionOrder, + disallowMultiple: disallowMultiple, + playOnFocus: playOnFocus, + inspector: inspector, + icon: icon, + help: help, + mixins: mixins + }; + }), { + "./CCClass": 240, + "./js": 261, + "./preprocess-class": 262, + "./utils": 264 + } ], + 242: [ (function(require, module, exports) { + "use strict"; + var js = require("./js"); + function Enum(obj) { + if ("__enums__" in obj) return obj; + js.value(obj, "__enums__", null, true); + var lastIndex = -1; + var keys = Object.keys(obj); + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; + var val = obj[key]; + if (-1 === val) { + val = ++lastIndex; + obj[key] = val; + } else if ("number" === typeof val) lastIndex = val; else if ("string" === typeof val && Number.isInteger(parseFloat(key))) continue; + var reverseKey = "" + val; + if (key !== reverseKey) { + if ((false, false) && reverseKey in obj && obj[reverseKey] !== key) { + cc.errorID(7100, reverseKey); + continue; + } + js.value(obj, reverseKey, key); + } + } + return obj; + } + Enum.isEnum = function(enumType) { + return enumType && enumType.hasOwnProperty("__enums__"); + }; + Enum.getList = function(enumDef) { + if (enumDef.__enums__) return enumDef.__enums__; + var enums = enumDef.__enums__ = []; + for (var name in enumDef) { + var value = enumDef[name]; + Number.isInteger(value) && enums.push({ + name: name, + value: value + }); + } + enums.sort((function(a, b) { + return a.value - b.value; + })); + return enums; + }; + var _TestEnum; + false; + module.exports = cc.Enum = Enum; + }), { + "./js": 261 + } ], + 243: [ (function(require, module, exports) { + "use strict"; + var eventManager = require("../event-manager"); + var inputManager = require("./CCInputManager"); + var PORTRAIT = 0; + var LANDSCAPE_LEFT = -90; + var PORTRAIT_UPSIDE_DOWN = 180; + var LANDSCAPE_RIGHT = 90; + var _didAccelerateFun; + cc.Acceleration = function(x, y, z, timestamp) { + this.x = x || 0; + this.y = y || 0; + this.z = z || 0; + this.timestamp = timestamp || 0; + }; + inputManager.setAccelerometerEnabled = function(isEnable) { + var _t = this; + if (_t._accelEnabled === isEnable) return; + _t._accelEnabled = isEnable; + var scheduler = cc.director.getScheduler(); + scheduler.enableForTarget(_t); + if (_t._accelEnabled) { + _t._registerAccelerometerEvent(); + _t._accelCurTime = 0; + scheduler.scheduleUpdate(_t); + } else { + _t._unregisterAccelerometerEvent(); + _t._accelCurTime = 0; + scheduler.unscheduleUpdate(_t); + } + false, false; + }; + inputManager.setAccelerometerInterval = function(interval) { + if (this._accelInterval !== interval) { + this._accelInterval = interval; + false, false; + } + }; + inputManager._registerKeyboardEvent = function() { + cc.game.canvas.addEventListener("keydown", (function(e) { + eventManager.dispatchEvent(new cc.Event.EventKeyboard(e.keyCode, true)); + e.stopPropagation(); + e.preventDefault(); + }), false); + cc.game.canvas.addEventListener("keyup", (function(e) { + eventManager.dispatchEvent(new cc.Event.EventKeyboard(e.keyCode, false)); + e.stopPropagation(); + e.preventDefault(); + }), false); + }; + inputManager._registerAccelerometerEvent = function() { + var w = window, _t = this; + _t._acceleration = new cc.Acceleration(); + _t._accelDeviceEvent = w.DeviceMotionEvent || w.DeviceOrientationEvent; + cc.sys.browserType === cc.sys.BROWSER_TYPE_MOBILE_QQ && (_t._accelDeviceEvent = window.DeviceOrientationEvent); + var _deviceEventType = _t._accelDeviceEvent === w.DeviceMotionEvent ? "devicemotion" : "deviceorientation"; + var ua = navigator.userAgent; + (/Android/.test(ua) || /Adr/.test(ua) && cc.sys.browserType === cc.BROWSER_TYPE_UC) && (_t._minus = -1); + _didAccelerateFun = _t.didAccelerate.bind(_t); + w.addEventListener(_deviceEventType, _didAccelerateFun, false); + }; + inputManager._unregisterAccelerometerEvent = function() { + var w = window, _t = this; + var _deviceEventType = _t._accelDeviceEvent === w.DeviceMotionEvent ? "devicemotion" : "deviceorientation"; + _didAccelerateFun && w.removeEventListener(_deviceEventType, _didAccelerateFun, false); + }; + inputManager.didAccelerate = function(eventData) { + var _t = this, w = window; + if (!_t._accelEnabled) return; + var mAcceleration = _t._acceleration; + var x, y, z; + if (_t._accelDeviceEvent === window.DeviceMotionEvent) { + var eventAcceleration = eventData["accelerationIncludingGravity"]; + x = _t._accelMinus * eventAcceleration.x * .1; + y = _t._accelMinus * eventAcceleration.y * .1; + z = .1 * eventAcceleration.z; + } else { + x = eventData["gamma"] / 90 * .981; + y = -eventData["beta"] / 90 * .981; + z = eventData["alpha"] / 90 * .981; + } + if (cc.view._isRotated) { + var tmp = x; + x = -y; + y = tmp; + } + mAcceleration.x = x; + mAcceleration.y = y; + mAcceleration.z = z; + mAcceleration.timestamp = eventData.timeStamp || Date.now(); + var tmpX = mAcceleration.x; + if (w.orientation === LANDSCAPE_RIGHT) { + mAcceleration.x = -mAcceleration.y; + mAcceleration.y = tmpX; + } else if (w.orientation === LANDSCAPE_LEFT) { + mAcceleration.x = mAcceleration.y; + mAcceleration.y = -tmpX; + } else if (w.orientation === PORTRAIT_UPSIDE_DOWN) { + mAcceleration.x = -mAcceleration.x; + mAcceleration.y = -mAcceleration.y; + } + if (cc.sys.os === cc.sys.OS_ANDROID && cc.sys.browserType !== cc.sys.BROWSER_TYPE_MOBILE_QQ) { + mAcceleration.x = -mAcceleration.x; + mAcceleration.y = -mAcceleration.y; + } + }; + }), { + "../event-manager": 185, + "./CCInputManager": 244 + } ], + 244: [ (function(require, module, exports) { + "use strict"; + var macro = require("./CCMacro"); + var sys = require("./CCSys"); + var eventManager = require("../event-manager"); + var _vec2 = cc.v2(); + var inputManager = { + _mousePressed: false, + _isRegisterEvent: false, + _preTouchPoint: cc.v2(0, 0), + _prevMousePoint: cc.v2(0, 0), + _preTouchPool: [], + _preTouchPoolPointer: 0, + _touches: [], + _maxTouches: 10, + _touchesIntegerDict: {}, + _indexBitsUsed: 0, + _touchesCache: {}, + _touchCount: 0, + _accelEnabled: false, + _accelInterval: .2, + _accelMinus: 1, + _accelCurTime: 0, + _acceleration: null, + _accelDeviceEvent: null, + _canvasBoundingRect: { + left: 0, + top: 0, + adjustedLeft: 0, + adjustedTop: 0, + width: 0, + height: 0 + }, + _getUnUsedIndex: function _getUnUsedIndex() { + var now = cc.sys.now(); + var timeout = macro.TOUCH_TIMEOUT; + var temp = this._indexBitsUsed; + var unused = -1; + var locTouches = this._touches; + var locTouchesIntDict = this._touchesIntegerDict; + var locTouchesCache = this._touchesCache; + for (var i = 0; i < this._maxTouches; i++) { + if (1 & temp) { + var ccTouch = locTouches[i]; + if (ccTouch && now - ccTouch._lastModified > timeout) { + var touchID = ccTouch.getID(); + delete locTouchesIntDict[touchID]; + delete locTouchesCache[touchID]; + this._touchCount--; + if (-1 === unused) { + unused = i; + this._indexBitsUsed |= 1 << i; + } else this._indexBitsUsed &= ~(1 << i); + } + } else if (-1 === unused) { + unused = i; + this._indexBitsUsed |= 1 << i; + } + temp >>= 1; + } + return unused; + }, + _glView: null, + _updateCanvasBoundingRect: function _updateCanvasBoundingRect() { + var element = cc.game.canvas; + var canvasBoundingRect = this._canvasBoundingRect; + var docElem = document.documentElement; + var leftOffset = window.pageXOffset - docElem.clientLeft; + var topOffset = window.pageYOffset - docElem.clientTop; + if (element.getBoundingClientRect) { + var box = element.getBoundingClientRect(); + canvasBoundingRect.left = box.left + leftOffset; + canvasBoundingRect.top = box.top + topOffset; + canvasBoundingRect.width = box.width; + canvasBoundingRect.height = box.height; + } else if (element instanceof HTMLCanvasElement) { + canvasBoundingRect.left = leftOffset; + canvasBoundingRect.top = topOffset; + canvasBoundingRect.width = element.width; + canvasBoundingRect.height = element.height; + } else { + canvasBoundingRect.left = leftOffset; + canvasBoundingRect.top = topOffset; + canvasBoundingRect.width = parseInt(element.style.width); + canvasBoundingRect.height = parseInt(element.style.height); + } + }, + handleTouchesBegin: function handleTouchesBegin(touches) { + var now = sys.now(); + var selTouch, index, touchID, handleTouches = []; + var locTouches = this._touches; + var locTouchesIntDict = this._touchesIntegerDict; + var locTouchesCache = this._touchesCache; + for (var i = 0, len = touches.length; i < len; i++) { + selTouch = touches[i]; + touchID = selTouch.getID(); + index = locTouchesIntDict[touchID]; + if (void 0 === index) { + var unusedIndex = this._getUnUsedIndex(); + if (-1 === unusedIndex) { + cc.logID(2300, unusedIndex); + continue; + } + var ccTouch = new cc.Touch(selTouch._point.x, selTouch._point.y, touchID); + ccTouch._setPrevPoint(selTouch._prevPoint); + ccTouch._lastModified = now; + locTouches[unusedIndex] = ccTouch; + locTouchesIntDict[touchID] = unusedIndex; + locTouchesCache[touchID] = ccTouch; + this._touchCount++; + handleTouches.push(ccTouch); + } + } + if (handleTouches.length > 0) { + this._glView._convertTouchesWithScale(handleTouches); + var touchEvent = new cc.Event.EventTouch(handleTouches); + touchEvent._eventCode = cc.Event.EventTouch.BEGAN; + eventManager.dispatchEvent(touchEvent); + } + }, + handleTouchesMove: function handleTouchesMove(touches) { + var now = sys.now(); + var selTouch, index, touchID, handleTouches = []; + var locTouches = this._touches; + var locTouchesIntDict = this._touchesIntegerDict; + for (var i = 0, len = touches.length; i < len; i++) { + selTouch = touches[i]; + touchID = selTouch.getID(); + index = locTouchesIntDict[touchID]; + if (void 0 === index) continue; + var ccTouch = locTouches[index]; + if (ccTouch) { + ccTouch._setPoint(selTouch._point); + ccTouch._setPrevPoint(selTouch._prevPoint); + ccTouch._lastModified = now; + handleTouches.push(ccTouch); + } + } + if (handleTouches.length > 0) { + this._glView._convertTouchesWithScale(handleTouches); + var touchEvent = new cc.Event.EventTouch(handleTouches); + touchEvent._eventCode = cc.Event.EventTouch.MOVED; + eventManager.dispatchEvent(touchEvent); + } + }, + handleTouchesEnd: function handleTouchesEnd(touches) { + var handleTouches = this.getSetOfTouchesEndOrCancel(touches); + if (handleTouches.length > 0) { + this._glView._convertTouchesWithScale(handleTouches); + var touchEvent = new cc.Event.EventTouch(handleTouches); + touchEvent._eventCode = cc.Event.EventTouch.ENDED; + eventManager.dispatchEvent(touchEvent); + } + this._preTouchPool.length = 0; + }, + handleTouchesCancel: function handleTouchesCancel(touches) { + var handleTouches = this.getSetOfTouchesEndOrCancel(touches); + if (handleTouches.length > 0) { + this._glView._convertTouchesWithScale(handleTouches); + var touchEvent = new cc.Event.EventTouch(handleTouches); + touchEvent._eventCode = cc.Event.EventTouch.CANCELED; + eventManager.dispatchEvent(touchEvent); + } + this._preTouchPool.length = 0; + }, + getSetOfTouchesEndOrCancel: function getSetOfTouchesEndOrCancel(touches) { + var selTouch, index, touchID, handleTouches = []; + var locTouches = this._touches; + var locTouchesIntDict = this._touchesIntegerDict; + var locTouchesCache = this._touchesCache; + for (var i = 0, len = touches.length; i < len; i++) { + selTouch = touches[i]; + touchID = selTouch.getID(); + index = locTouchesIntDict[touchID]; + if (void 0 === index) continue; + var ccTouch = locTouches[index]; + if (ccTouch) { + ccTouch._setPoint(selTouch._point); + ccTouch._setPrevPoint(selTouch._prevPoint); + handleTouches.push(ccTouch); + delete locTouchesIntDict[touchID]; + delete locTouchesCache[touchID]; + this._touchCount--; + this._indexBitsUsed &= ~(1 << index); + } + } + return handleTouches; + }, + getGlobalTouchCount: function getGlobalTouchCount() { + return this._touchCount; + }, + getGlobalTouches: function getGlobalTouches() { + return this._touchesCache; + }, + getPreTouch: function getPreTouch(touch) { + var preTouch = null; + var locPreTouchPool = this._preTouchPool; + var id = touch.getID(); + for (var i = locPreTouchPool.length - 1; i >= 0; i--) if (locPreTouchPool[i].getID() === id) { + preTouch = locPreTouchPool[i]; + break; + } + preTouch || (preTouch = touch); + return preTouch; + }, + setPreTouch: function setPreTouch(touch) { + var find = false; + var locPreTouchPool = this._preTouchPool; + var id = touch.getID(); + for (var i = locPreTouchPool.length - 1; i >= 0; i--) if (locPreTouchPool[i].getID() === id) { + locPreTouchPool[i] = touch; + find = true; + break; + } + if (!find) if (locPreTouchPool.length <= 50) locPreTouchPool.push(touch); else { + locPreTouchPool[this._preTouchPoolPointer] = touch; + this._preTouchPoolPointer = (this._preTouchPoolPointer + 1) % 50; + } + }, + getTouchByXY: function getTouchByXY(tx, ty, pos) { + var locPreTouch = this._preTouchPoint; + var location = this._glView.convertToLocationInView(tx, ty, pos); + var touch = new cc.Touch(location.x, location.y, 0); + touch._setPrevPoint(locPreTouch.x, locPreTouch.y); + locPreTouch.x = location.x; + locPreTouch.y = location.y; + return touch; + }, + getMouseEvent: function getMouseEvent(location, pos, eventType) { + var locPreMouse = this._prevMousePoint; + var mouseEvent = new cc.Event.EventMouse(eventType); + mouseEvent._setPrevCursor(locPreMouse.x, locPreMouse.y); + locPreMouse.x = location.x; + locPreMouse.y = location.y; + this._glView._convertMouseToLocationInView(locPreMouse, pos); + mouseEvent.setLocation(locPreMouse.x, locPreMouse.y); + return mouseEvent; + }, + getPointByEvent: function getPointByEvent(event, pos) { + cc.sys.browserType !== cc.sys.BROWSER_TYPE_QQ && cc.sys.browserType !== cc.sys.BROWSER_TYPE_UC && cc.sys.browserType !== cc.sys.BROWSER_TYPE_SAFARI || this._updateCanvasBoundingRect(); + if (null != event.pageX) return { + x: event.pageX, + y: event.pageY + }; + pos.left -= document.body.scrollLeft; + pos.top -= document.body.scrollTop; + return { + x: event.clientX, + y: event.clientY + }; + }, + getTouchesByEvent: function getTouchesByEvent(event, pos) { + var touchArr = [], locView = this._glView; + var touch_event, touch, preLocation; + var locPreTouch = this._preTouchPoint; + var length = event.changedTouches.length; + for (var i = 0; i < length; i++) { + touch_event = event.changedTouches[i]; + if (touch_event) { + var location = void 0; + location = sys.BROWSER_TYPE_FIREFOX === sys.browserType ? locView.convertToLocationInView(touch_event.pageX, touch_event.pageY, pos, _vec2) : locView.convertToLocationInView(touch_event.clientX, touch_event.clientY, pos, _vec2); + if (null != touch_event.identifier) { + touch = new cc.Touch(location.x, location.y, touch_event.identifier); + preLocation = this.getPreTouch(touch).getLocation(); + touch._setPrevPoint(preLocation.x, preLocation.y); + this.setPreTouch(touch); + } else { + touch = new cc.Touch(location.x, location.y); + touch._setPrevPoint(locPreTouch.x, locPreTouch.y); + } + locPreTouch.x = location.x; + locPreTouch.y = location.y; + touchArr.push(touch); + } + } + return touchArr; + }, + registerSystemEvent: function registerSystemEvent(element) { + if (this._isRegisterEvent) return; + this._glView = cc.view; + var selfPointer = this; + var canvasBoundingRect = this._canvasBoundingRect; + window.addEventListener("resize", this._updateCanvasBoundingRect.bind(this)); + var prohibition = sys.isMobile; + var supportMouse = "mouse" in sys.capabilities; + var supportTouches = "touches" in sys.capabilities; + if (supportMouse) { + if (!prohibition) { + window.addEventListener("mousedown", (function() { + selfPointer._mousePressed = true; + }), false); + window.addEventListener("mouseup", (function(event) { + if (!selfPointer._mousePressed) return; + selfPointer._mousePressed = false; + var location = selfPointer.getPointByEvent(event, canvasBoundingRect); + if (!cc.rect(canvasBoundingRect.left, canvasBoundingRect.top, canvasBoundingRect.width, canvasBoundingRect.height).contains(location)) { + selfPointer.handleTouchesEnd([ selfPointer.getTouchByXY(location.x, location.y, canvasBoundingRect) ]); + var mouseEvent = selfPointer.getMouseEvent(location, canvasBoundingRect, cc.Event.EventMouse.UP); + mouseEvent.setButton(event.button); + eventManager.dispatchEvent(mouseEvent); + } + }), false); + } + var EventMouse = cc.Event.EventMouse; + var _mouseEventsOnElement = [ !prohibition && [ "mousedown", EventMouse.DOWN, function(event, mouseEvent, location, canvasBoundingRect) { + selfPointer._mousePressed = true; + selfPointer.handleTouchesBegin([ selfPointer.getTouchByXY(location.x, location.y, canvasBoundingRect) ]); + element.focus(); + } ], !prohibition && [ "mouseup", EventMouse.UP, function(event, mouseEvent, location, canvasBoundingRect) { + selfPointer._mousePressed = false; + selfPointer.handleTouchesEnd([ selfPointer.getTouchByXY(location.x, location.y, canvasBoundingRect) ]); + } ], !prohibition && [ "mousemove", EventMouse.MOVE, function(event, mouseEvent, location, canvasBoundingRect) { + selfPointer.handleTouchesMove([ selfPointer.getTouchByXY(location.x, location.y, canvasBoundingRect) ]); + selfPointer._mousePressed || mouseEvent.setButton(null); + } ], [ "mousewheel", EventMouse.SCROLL, function(event, mouseEvent) { + mouseEvent.setScrollData(0, event.wheelDelta); + } ], [ "DOMMouseScroll", EventMouse.SCROLL, function(event, mouseEvent) { + mouseEvent.setScrollData(0, -120 * event.detail); + } ] ]; + for (var i = 0; i < _mouseEventsOnElement.length; ++i) { + var entry = _mouseEventsOnElement[i]; + entry && (function() { + var name = entry[0]; + var type = entry[1]; + var handler = entry[2]; + element.addEventListener(name, (function(event) { + var location = selfPointer.getPointByEvent(event, canvasBoundingRect); + var mouseEvent = selfPointer.getMouseEvent(location, canvasBoundingRect, type); + mouseEvent.setButton(event.button); + handler(event, mouseEvent, location, canvasBoundingRect); + eventManager.dispatchEvent(mouseEvent); + event.stopPropagation(); + event.preventDefault(); + }), false); + })(); + } + } + if (window.navigator.msPointerEnabled) { + var _pointerEventsMap = { + MSPointerDown: selfPointer.handleTouchesBegin, + MSPointerMove: selfPointer.handleTouchesMove, + MSPointerUp: selfPointer.handleTouchesEnd, + MSPointerCancel: selfPointer.handleTouchesCancel + }; + var _loop = function _loop(eventName) { + var touchEvent = _pointerEventsMap[eventName]; + element.addEventListener(eventName, (function(event) { + var documentElement = document.documentElement; + canvasBoundingRect.adjustedLeft = canvasBoundingRect.left - documentElement.scrollLeft; + canvasBoundingRect.adjustedTop = canvasBoundingRect.top - documentElement.scrollTop; + touchEvent.call(selfPointer, [ selfPointer.getTouchByXY(event.clientX, event.clientY, canvasBoundingRect) ]); + event.stopPropagation(); + }), false); + }; + for (var eventName in _pointerEventsMap) _loop(eventName); + } + if (supportTouches) { + var _touchEventsMap = { + touchstart: function touchstart(touchesToHandle) { + selfPointer.handleTouchesBegin(touchesToHandle); + element.focus(); + }, + touchmove: function touchmove(touchesToHandle) { + selfPointer.handleTouchesMove(touchesToHandle); + }, + touchend: function touchend(touchesToHandle) { + selfPointer.handleTouchesEnd(touchesToHandle); + }, + touchcancel: function touchcancel(touchesToHandle) { + selfPointer.handleTouchesCancel(touchesToHandle); + } + }; + var registerTouchEvent = function registerTouchEvent(eventName) { + var handler = _touchEventsMap[eventName]; + element.addEventListener(eventName, (function(event) { + if (!event.changedTouches) return; + var body = document.body; + canvasBoundingRect.adjustedLeft = canvasBoundingRect.left - (body.scrollLeft || window.scrollX || 0); + canvasBoundingRect.adjustedTop = canvasBoundingRect.top - (body.scrollTop || window.scrollY || 0); + handler(selfPointer.getTouchesByEvent(event, canvasBoundingRect)); + event.stopPropagation(); + event.preventDefault(); + }), false); + }; + for (var _eventName in _touchEventsMap) registerTouchEvent(_eventName); + } + this._registerKeyboardEvent(); + this._isRegisterEvent = true; + }, + _registerKeyboardEvent: function _registerKeyboardEvent() {}, + _registerAccelerometerEvent: function _registerAccelerometerEvent() {}, + update: function update(dt) { + if (this._accelCurTime > this._accelInterval) { + this._accelCurTime -= this._accelInterval; + eventManager.dispatchEvent(new cc.Event.EventAcceleration(this._acceleration)); + } + this._accelCurTime += dt; + } + }; + module.exports = cc.internal.inputManager = inputManager; + }), { + "../event-manager": 185, + "./CCMacro": 245, + "./CCSys": 249 + } ], + 245: [ (function(require, module, exports) { + "use strict"; + cc.macro = { + RAD: Math.PI / 180, + DEG: 180 / Math.PI, + REPEAT_FOREVER: Number.MAX_VALUE - 1, + FLT_EPSILON: 1.192092896e-7, + MIN_ZINDEX: -Math.pow(2, 15), + MAX_ZINDEX: Math.pow(2, 15) - 1, + ONE: 1, + ZERO: 0, + SRC_ALPHA: 770, + SRC_ALPHA_SATURATE: 776, + SRC_COLOR: 768, + DST_ALPHA: 772, + DST_COLOR: 774, + ONE_MINUS_SRC_ALPHA: 771, + ONE_MINUS_SRC_COLOR: 769, + ONE_MINUS_DST_ALPHA: 773, + ONE_MINUS_DST_COLOR: 775, + ONE_MINUS_CONSTANT_ALPHA: 32772, + ONE_MINUS_CONSTANT_COLOR: 32770, + ORIENTATION_PORTRAIT: 1, + ORIENTATION_LANDSCAPE: 2, + ORIENTATION_AUTO: 3, + DENSITYDPI_DEVICE: "device-dpi", + DENSITYDPI_HIGH: "high-dpi", + DENSITYDPI_MEDIUM: "medium-dpi", + DENSITYDPI_LOW: "low-dpi", + FIX_ARTIFACTS_BY_STRECHING_TEXEL_TMX: true, + DIRECTOR_STATS_POSITION: cc.v2(0, 0), + ENABLE_STACKABLE_ACTIONS: true, + TOUCH_TIMEOUT: 5e3, + BATCH_VERTEX_COUNT: 2e4, + ENABLE_TILEDMAP_CULLING: true, + ENABLE_TRANSPARENT_CANVAS: false, + ENABLE_WEBGL_ANTIALIAS: false, + ENABLE_CULLING: false, + CLEANUP_IMAGE_CACHE: false, + SHOW_MESH_WIREFRAME: false, + SHOW_MESH_NORMAL: false, + ENABLE_MULTI_TOUCH: true, + ALLOW_IMAGE_BITMAP: !cc.sys.isMobile, + ENABLE_NATIVE_TTF_RENDERER: true + }; + Object.defineProperty(cc.macro, "ROTATE_ACTION_CCW", { + set: function set(value) { + cc.RotateTo && cc.RotateBy && (cc.RotateTo._reverse = cc.RotateBy._reverse = value); + } + }); + var SUPPORT_TEXTURE_FORMATS = [ ".pkm", ".pvr", ".webp", ".jpg", ".jpeg", ".bmp", ".png" ]; + cc.macro.SUPPORT_TEXTURE_FORMATS = SUPPORT_TEXTURE_FORMATS; + cc.macro.KEY = { + none: 0, + back: 6, + menu: 18, + backspace: 8, + tab: 9, + enter: 13, + shift: 16, + ctrl: 17, + alt: 18, + pause: 19, + capslock: 20, + escape: 27, + space: 32, + pageup: 33, + pagedown: 34, + end: 35, + home: 36, + left: 37, + up: 38, + right: 39, + down: 40, + select: 41, + insert: 45, + Delete: 46, + 0: 48, + 1: 49, + 2: 50, + 3: 51, + 4: 52, + 5: 53, + 6: 54, + 7: 55, + 8: 56, + 9: 57, + a: 65, + b: 66, + c: 67, + d: 68, + e: 69, + f: 70, + g: 71, + h: 72, + i: 73, + j: 74, + k: 75, + l: 76, + m: 77, + n: 78, + o: 79, + p: 80, + q: 81, + r: 82, + s: 83, + t: 84, + u: 85, + v: 86, + w: 87, + x: 88, + y: 89, + z: 90, + num0: 96, + num1: 97, + num2: 98, + num3: 99, + num4: 100, + num5: 101, + num6: 102, + num7: 103, + num8: 104, + num9: 105, + "*": 106, + "+": 107, + "-": 109, + numdel: 110, + "/": 111, + f1: 112, + f2: 113, + f3: 114, + f4: 115, + f5: 116, + f6: 117, + f7: 118, + f8: 119, + f9: 120, + f10: 121, + f11: 122, + f12: 123, + numlock: 144, + scrolllock: 145, + ";": 186, + semicolon: 186, + equal: 187, + "=": 187, + ",": 188, + comma: 188, + dash: 189, + ".": 190, + period: 190, + forwardslash: 191, + grave: 192, + "[": 219, + openbracket: 219, + backslash: 220, + "]": 221, + closebracket: 221, + quote: 222, + dpadLeft: 1e3, + dpadRight: 1001, + dpadUp: 1003, + dpadDown: 1004, + dpadCenter: 1005 + }; + cc.macro.ImageFormat = cc.Enum({ + JPG: 0, + PNG: 1, + TIFF: 2, + WEBP: 3, + PVR: 4, + ETC: 5, + S3TC: 6, + ATITC: 7, + TGA: 8, + RAWDATA: 9, + UNKNOWN: 10 + }); + cc.macro.BlendFactor = cc.Enum({ + ONE: 1, + ZERO: 0, + SRC_ALPHA: 770, + SRC_COLOR: 768, + DST_ALPHA: 772, + DST_COLOR: 774, + ONE_MINUS_SRC_ALPHA: 771, + ONE_MINUS_SRC_COLOR: 769, + ONE_MINUS_DST_ALPHA: 773, + ONE_MINUS_DST_COLOR: 775 + }); + cc.macro.TextAlignment = cc.Enum({ + LEFT: 0, + CENTER: 1, + RIGHT: 2 + }); + cc.macro.VerticalTextAlignment = cc.Enum({ + TOP: 0, + CENTER: 1, + BOTTOM: 2 + }); + module.exports = cc.macro; + }), {} ], + 246: [ (function(require, module, exports) { + "use strict"; + var js = require("./js"); + var CCClass = require("./CCClass"); + var Destroyed = 1; + var RealDestroyed = 2; + var ToDestroy = 4; + var DontSave = 8; + var EditorOnly = 16; + var Dirty = 32; + var DontDestroy = 64; + var Destroying = 128; + var Deactivating = 256; + var LockedInEditor = 512; + var HideInHierarchy = 1024; + var IsOnEnableCalled = 2048; + var IsEditorOnEnableCalled = 4096; + var IsPreloadStarted = 8192; + var IsOnLoadCalled = 16384; + var IsOnLoadStarted = 32768; + var IsStartCalled = 65536; + var IsRotationLocked = 1 << 17; + var IsScaleLocked = 1 << 18; + var IsAnchorLocked = 1 << 19; + var IsSizeLocked = 1 << 20; + var IsPositionLocked = 1 << 21; + var PersistentMask = ~(ToDestroy | Dirty | Destroying | DontDestroy | Deactivating | IsPreloadStarted | IsOnLoadStarted | IsOnLoadCalled | IsStartCalled | IsOnEnableCalled | IsEditorOnEnableCalled | IsRotationLocked | IsScaleLocked | IsAnchorLocked | IsSizeLocked | IsPositionLocked); + function CCObject() { + this._name = ""; + this._objFlags = 0; + } + CCClass.fastDefine("cc.Object", CCObject, { + _name: "", + _objFlags: 0 + }); + js.value(CCObject, "Flags", { + Destroyed: Destroyed, + DontSave: DontSave, + EditorOnly: EditorOnly, + Dirty: Dirty, + DontDestroy: DontDestroy, + PersistentMask: PersistentMask, + Destroying: Destroying, + Deactivating: Deactivating, + LockedInEditor: LockedInEditor, + HideInHierarchy: HideInHierarchy, + IsPreloadStarted: IsPreloadStarted, + IsOnLoadStarted: IsOnLoadStarted, + IsOnLoadCalled: IsOnLoadCalled, + IsOnEnableCalled: IsOnEnableCalled, + IsStartCalled: IsStartCalled, + IsEditorOnEnableCalled: IsEditorOnEnableCalled, + IsPositionLocked: IsPositionLocked, + IsRotationLocked: IsRotationLocked, + IsScaleLocked: IsScaleLocked, + IsAnchorLocked: IsAnchorLocked, + IsSizeLocked: IsSizeLocked + }); + var objectsToDestroy = []; + function deferredDestroy() { + var deleteCount = objectsToDestroy.length; + for (var i = 0; i < deleteCount; ++i) { + var obj = objectsToDestroy[i]; + obj._objFlags & Destroyed || obj._destroyImmediate(); + } + deleteCount === objectsToDestroy.length ? objectsToDestroy.length = 0 : objectsToDestroy.splice(0, deleteCount); + false; + } + js.value(CCObject, "_deferredDestroy", deferredDestroy); + false; + var prototype = CCObject.prototype; + js.getset(prototype, "name", (function() { + return this._name; + }), (function(value) { + this._name = value; + }), true); + js.get(prototype, "isValid", (function() { + return !(this._objFlags & Destroyed); + }), true); + false, false; + var deferredDestroyTimer = null; + prototype.destroy = function() { + if (this._objFlags & Destroyed) { + cc.warnID(5e3); + return false; + } + if (this._objFlags & ToDestroy) return false; + this._objFlags |= ToDestroy; + objectsToDestroy.push(this); + false; + return true; + }; + false, false; + function compileDestruct(obj, ctor) { + var shouldSkipId = obj instanceof cc._BaseNode || obj instanceof cc.Component; + var idToSkip = shouldSkipId ? "_id" : null; + var key, propsToReset = {}; + for (key in obj) if (obj.hasOwnProperty(key)) { + if (key === idToSkip) continue; + switch (typeof obj[key]) { + case "string": + propsToReset[key] = ""; + break; + + case "object": + case "function": + propsToReset[key] = null; + } + } + if (cc.Class._isCCClass(ctor)) { + var attrs = cc.Class.Attr.getClassAttrs(ctor); + var propList = ctor.__props__; + for (var i = 0; i < propList.length; i++) { + key = propList[i]; + var attrKey = key + cc.Class.Attr.DELIMETER + "default"; + if (attrKey in attrs) { + if (shouldSkipId && "_id" === key) continue; + switch (typeof attrs[attrKey]) { + case "string": + propsToReset[key] = ""; + break; + + case "object": + case "function": + propsToReset[key] = null; + break; + + case "undefined": + propsToReset[key] = void 0; + } + } + } + } + true; + var func = ""; + for (key in propsToReset) { + var statement; + statement = CCClass.IDENTIFIER_RE.test(key) ? "o." + key + "=" : "o[" + CCClass.escapeForJS(key) + "]="; + var val = propsToReset[key]; + "" === val && (val = '""'); + func += statement + val + ";\n"; + } + return Function("o", func); + } + prototype._destruct = function() { + var ctor = this.constructor; + var destruct = ctor.__destruct__; + if (!destruct) { + destruct = compileDestruct(this, ctor); + js.value(ctor, "__destruct__", destruct, true); + } + destruct(this); + }; + prototype._onPreDestroy = null; + prototype._destroyImmediate = function() { + if (this._objFlags & Destroyed) { + cc.errorID(5e3); + return; + } + this._onPreDestroy && this._onPreDestroy(); + true; + this._destruct(); + this._objFlags |= Destroyed; + }; + false; + prototype._deserialize = null; + cc.isValid = function(value, strictMode) { + return "object" === typeof value ? !!value && !(value._objFlags & (strictMode ? Destroyed | ToDestroy : Destroyed)) : "undefined" !== typeof value; + }; + false, false; + cc.Object = module.exports = CCObject; + }), { + "./CCClass": 240, + "./js": 261 + } ], + 247: [ (function(require, module, exports) { + "use strict"; + var js = require("../platform/js"); + cc.SAXParser = function() { + if (true, window.DOMParser) { + this._isSupportDOMParser = true; + this._parser = new DOMParser(); + } else { + this._isSupportDOMParser = false; + this._parser = null; + } + }; + cc.SAXParser.prototype = { + constructor: cc.SAXParser, + parse: function parse(xmlTxt) { + return this._parseXML(xmlTxt); + }, + _parseXML: function _parseXML(textxml) { + var xmlDoc; + if (this._isSupportDOMParser) xmlDoc = this._parser.parseFromString(textxml, "text/xml"); else { + xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); + xmlDoc.async = "false"; + xmlDoc.loadXML(textxml); + } + return xmlDoc; + } + }; + cc.PlistParser = function() { + cc.SAXParser.call(this); + }; + js.extend(cc.PlistParser, cc.SAXParser); + js.mixin(cc.PlistParser.prototype, { + parse: function parse(xmlTxt) { + var xmlDoc = this._parseXML(xmlTxt); + var plist = xmlDoc.documentElement; + if ("plist" !== plist.tagName) { + cc.warnID(5100); + return {}; + } + var node = null; + for (var i = 0, len = plist.childNodes.length; i < len; i++) { + node = plist.childNodes[i]; + if (1 === node.nodeType) break; + } + xmlDoc = null; + return this._parseNode(node); + }, + _parseNode: function _parseNode(node) { + var data = null, tagName = node.tagName; + if ("dict" === tagName) data = this._parseDict(node); else if ("array" === tagName) data = this._parseArray(node); else if ("string" === tagName) if (1 === node.childNodes.length) data = node.firstChild.nodeValue; else { + data = ""; + for (var i = 0; i < node.childNodes.length; i++) data += node.childNodes[i].nodeValue; + } else "false" === tagName ? data = false : "true" === tagName ? data = true : "real" === tagName ? data = parseFloat(node.firstChild.nodeValue) : "integer" === tagName && (data = parseInt(node.firstChild.nodeValue, 10)); + return data; + }, + _parseArray: function _parseArray(node) { + var data = []; + for (var i = 0, len = node.childNodes.length; i < len; i++) { + var child = node.childNodes[i]; + if (1 !== child.nodeType) continue; + data.push(this._parseNode(child)); + } + return data; + }, + _parseDict: function _parseDict(node) { + var data = {}; + var key = null; + for (var i = 0, len = node.childNodes.length; i < len; i++) { + var child = node.childNodes[i]; + if (1 !== child.nodeType) continue; + "key" === child.tagName ? key = child.firstChild.nodeValue : data[key] = this._parseNode(child); + } + return data; + } + }); + cc.saxParser = new cc.SAXParser(); + cc.plistParser = new cc.PlistParser(); + module.exports = { + saxParser: cc.saxParser, + plistParser: cc.plistParser + }; + }), { + "../platform/js": 261 + } ], + 248: [ (function(require, module, exports) { + "use strict"; + cc.screen = { + _supportsFullScreen: false, + _onfullscreenchange: null, + _onfullscreenerror: null, + _preOnFullScreenChange: null, + _preOnFullScreenError: null, + _preOnTouch: null, + _touchEvent: "", + _fn: null, + _fnMap: [ [ "requestFullscreen", "exitFullscreen", "fullscreenchange", "fullscreenEnabled", "fullscreenElement", "fullscreenerror" ], [ "requestFullScreen", "exitFullScreen", "fullScreenchange", "fullScreenEnabled", "fullScreenElement", "fullscreenerror" ], [ "webkitRequestFullScreen", "webkitCancelFullScreen", "webkitfullscreenchange", "webkitIsFullScreen", "webkitCurrentFullScreenElement", "webkitfullscreenerror" ], [ "mozRequestFullScreen", "mozCancelFullScreen", "mozfullscreenchange", "mozFullScreen", "mozFullScreenElement", "mozfullscreenerror" ], [ "msRequestFullscreen", "msExitFullscreen", "MSFullscreenChange", "msFullscreenEnabled", "msFullscreenElement", "msfullscreenerror" ] ], + init: function init() { + this._fn = {}; + var i, l, val, map = this._fnMap, valL; + for (i = 0, l = map.length; i < l; i++) { + val = map[i]; + if (val && "undefined" !== typeof document[val[1]]) { + for (i = 0, valL = val.length; i < valL; i++) this._fn[map[0][i]] = val[i]; + break; + } + } + this._supportsFullScreen = void 0 !== this._fn.requestFullscreen; + this._touchEvent = "ontouchend" in window ? "touchend" : "mousedown"; + }, + fullScreen: function fullScreen() { + return !!this._supportsFullScreen && !!(document[this._fn.fullscreenElement] || document[this._fn.webkitFullscreenElement] || document[this._fn.mozFullScreenElement]); + }, + requestFullScreen: function requestFullScreen(element, onFullScreenChange, onFullScreenError) { + if (element && "video" === element.tagName.toLowerCase()) { + if (cc.sys.os === cc.sys.OS_IOS && cc.sys.isBrowser && element.readyState > 0) { + element.webkitEnterFullscreen && element.webkitEnterFullscreen(); + return; + } + element.setAttribute("x5-video-player-fullscreen", "true"); + } + if (!this._supportsFullScreen) return; + element = element || document.documentElement; + if (onFullScreenChange) { + var eventName = this._fn.fullscreenchange; + this._onfullscreenchange && document.removeEventListener(eventName, this._onfullscreenchange); + this._onfullscreenchange = onFullScreenChange; + document.addEventListener(eventName, onFullScreenChange, false); + } + if (onFullScreenError) { + var _eventName = this._fn.fullscreenerror; + this._onfullscreenerror && document.removeEventListener(_eventName, this._onfullscreenerror); + this._onfullscreenerror = onFullScreenError; + document.addEventListener(_eventName, onFullScreenError, { + once: true + }); + } + var requestPromise = element[this._fn.requestFullscreen](); + "undefined" === typeof document[this._fn.fullscreenerror] && window.Promise && requestPromise instanceof Promise && requestPromise["catch"]((function(err) {})); + }, + exitFullScreen: function exitFullScreen(element) { + if (element && "video" === element.tagName.toLowerCase()) { + if (cc.sys.os === cc.sys.OS_IOS && cc.sys.isBrowser) { + element.webkitExitFullscreen && element.webkitExitFullscreen(); + return; + } + element.setAttribute("x5-video-player-fullscreen", "false"); + } + return !this._supportsFullScreen || document[this._fn.exitFullscreen](); + }, + autoFullScreen: function autoFullScreen(element, onFullScreenChange) { + element = element || document.body; + this._ensureFullScreen(element, onFullScreenChange); + this.requestFullScreen(element, onFullScreenChange); + }, + disableAutoFullScreen: function disableAutoFullScreen(element) { + var touchTarget = cc.game.canvas || element; + var touchEventName = this._touchEvent; + if (this._preOnTouch) { + touchTarget.removeEventListener(touchEventName, this._preOnTouch); + this._preOnTouch = null; + } + }, + _ensureFullScreen: function _ensureFullScreen(element, onFullScreenChange) { + var self = this; + var touchTarget = cc.game.canvas || element; + var fullScreenErrorEventName = this._fn.fullscreenerror; + var touchEventName = this._touchEvent; + function onFullScreenError() { + self._preOnFullScreenError = null; + function onTouch() { + self._preOnTouch = null; + self.requestFullScreen(element, onFullScreenChange); + } + self._preOnTouch && touchTarget.removeEventListener(touchEventName, self._preOnTouch); + self._preOnTouch = onTouch; + touchTarget.addEventListener(touchEventName, self._preOnTouch, { + once: true + }); + } + this._preOnFullScreenError && element.removeEventListener(fullScreenErrorEventName, this._preOnFullScreenError); + this._preOnFullScreenError = onFullScreenError; + element.addEventListener(fullScreenErrorEventName, onFullScreenError, { + once: true + }); + } + }; + cc.screen.init(); + }), {} ], + 249: [ (function(require, module, exports) { + "use strict"; + var settingPlatform; + true; + settingPlatform = window._CCSettings ? _CCSettings.platform : void 0; + var isVivoGame = "qgame" === settingPlatform; + var isOppoGame = "quickgame" === settingPlatform; + var isHuaweiGame = "huawei" === settingPlatform; + var isJKWGame = "jkw-game" === settingPlatform; + var isQttGame = "qtt-game" === settingPlatform; + var isLinkSure = "link-sure" === settingPlatform; + var _global = "undefined" === typeof window ? global : window; + function initSys() { + cc.sys = {}; + var sys = cc.sys; + sys.LANGUAGE_ENGLISH = "en"; + sys.LANGUAGE_CHINESE = "zh"; + sys.LANGUAGE_FRENCH = "fr"; + sys.LANGUAGE_ITALIAN = "it"; + sys.LANGUAGE_GERMAN = "de"; + sys.LANGUAGE_SPANISH = "es"; + sys.LANGUAGE_DUTCH = "du"; + sys.LANGUAGE_RUSSIAN = "ru"; + sys.LANGUAGE_KOREAN = "ko"; + sys.LANGUAGE_JAPANESE = "ja"; + sys.LANGUAGE_HUNGARIAN = "hu"; + sys.LANGUAGE_PORTUGUESE = "pt"; + sys.LANGUAGE_ARABIC = "ar"; + sys.LANGUAGE_NORWEGIAN = "no"; + sys.LANGUAGE_POLISH = "pl"; + sys.LANGUAGE_TURKISH = "tr"; + sys.LANGUAGE_UKRAINIAN = "uk"; + sys.LANGUAGE_ROMANIAN = "ro"; + sys.LANGUAGE_BULGARIAN = "bg"; + sys.LANGUAGE_UNKNOWN = "unknown"; + sys.OS_IOS = "iOS"; + sys.OS_ANDROID = "Android"; + sys.OS_WINDOWS = "Windows"; + sys.OS_MARMALADE = "Marmalade"; + sys.OS_LINUX = "Linux"; + sys.OS_BADA = "Bada"; + sys.OS_BLACKBERRY = "Blackberry"; + sys.OS_OSX = "OS X"; + sys.OS_WP8 = "WP8"; + sys.OS_WINRT = "WINRT"; + sys.OS_UNKNOWN = "Unknown"; + sys.UNKNOWN = -1; + sys.WIN32 = 0; + sys.LINUX = 1; + sys.MACOS = 2; + sys.ANDROID = 3; + sys.IPHONE = 4; + sys.IPAD = 5; + sys.BLACKBERRY = 6; + sys.NACL = 7; + sys.EMSCRIPTEN = 8; + sys.TIZEN = 9; + sys.WINRT = 10; + sys.WP8 = 11; + sys.MOBILE_BROWSER = 100; + sys.DESKTOP_BROWSER = 101; + sys.EDITOR_PAGE = 102; + sys.EDITOR_CORE = 103; + sys.WECHAT_GAME = 104; + sys.QQ_PLAY = 105; + sys.FB_PLAYABLE_ADS = 106; + sys.BAIDU_GAME = 107; + sys.VIVO_GAME = 108; + sys.OPPO_GAME = 109; + sys.HUAWEI_GAME = 110; + sys.XIAOMI_GAME = 111; + sys.JKW_GAME = 112; + sys.ALIPAY_GAME = 113; + sys.WECHAT_GAME_SUB = 114; + sys.BAIDU_GAME_SUB = 115; + sys.QTT_GAME = 116; + sys.BYTEDANCE_GAME = 117; + sys.BYTEDANCE_GAME_SUB = 118; + sys.LINKSURE = 119; + sys.TAOBAO = 120; + sys.BROWSER_TYPE_WECHAT = "wechat"; + sys.BROWSER_TYPE_ANDROID = "androidbrowser"; + sys.BROWSER_TYPE_IE = "ie"; + sys.BROWSER_TYPE_EDGE = "edge"; + sys.BROWSER_TYPE_QQ = "qqbrowser"; + sys.BROWSER_TYPE_MOBILE_QQ = "mqqbrowser"; + sys.BROWSER_TYPE_UC = "ucbrowser"; + sys.BROWSER_TYPE_UCBS = "ucbs"; + sys.BROWSER_TYPE_360 = "360browser"; + sys.BROWSER_TYPE_BAIDU_APP = "baiduboxapp"; + sys.BROWSER_TYPE_BAIDU = "baidubrowser"; + sys.BROWSER_TYPE_MAXTHON = "maxthon"; + sys.BROWSER_TYPE_OPERA = "opera"; + sys.BROWSER_TYPE_OUPENG = "oupeng"; + sys.BROWSER_TYPE_MIUI = "miuibrowser"; + sys.BROWSER_TYPE_FIREFOX = "firefox"; + sys.BROWSER_TYPE_SAFARI = "safari"; + sys.BROWSER_TYPE_CHROME = "chrome"; + sys.BROWSER_TYPE_LIEBAO = "liebao"; + sys.BROWSER_TYPE_QZONE = "qzone"; + sys.BROWSER_TYPE_SOUGOU = "sogou"; + sys.BROWSER_TYPE_HUAWEI = "huawei"; + sys.BROWSER_TYPE_UNKNOWN = "unknown"; + sys.isNative = false; + sys.isBrowser = "object" === typeof window && "object" === typeof document && true; + sys.glExtension = function(name) { + return !!cc.renderer.device.ext(name); + }; + sys.getMaxJointMatrixSize = function() { + if (!sys._maxJointMatrixSize) { + var JOINT_MATRICES_SIZE = 50; + var LEFT_UNIFORM_SIZE = 10; + var gl = cc.game._renderContext; + var maxUniforms = Math.floor(gl.getParameter(gl.MAX_VERTEX_UNIFORM_VECTORS) / 4) - LEFT_UNIFORM_SIZE; + sys._maxJointMatrixSize = maxUniforms < JOINT_MATRICES_SIZE ? 0 : JOINT_MATRICES_SIZE; + } + return sys._maxJointMatrixSize; + }; + sys.getSafeAreaRect = function() { + var visibleSize = cc.view.getVisibleSize(); + return cc.rect(0, 0, visibleSize.width, visibleSize.height); + }; + if (_global.__globalAdapter && _global.__globalAdapter.adaptSys) _global.__globalAdapter.adaptSys(sys); else { + false; + var platform; + var languageCode; + var w; + var h; + var ratio; + var capabilities; + false, false; + var win = window, nav = win.navigator, doc = document, docEle = doc.documentElement; + var ua = nav.userAgent.toLowerCase(); + false; + sys.isMobile = /mobile|android|iphone|ipad/.test(ua); + "undefined" !== typeof FbPlayableAd ? sys.platform = sys.FB_PLAYABLE_ADS : sys.platform = sys.isMobile ? sys.MOBILE_BROWSER : sys.DESKTOP_BROWSER; + var currLanguage = nav.language; + currLanguage = currLanguage || nav.browserLanguage; + sys.languageCode = currLanguage.toLowerCase(); + currLanguage = currLanguage ? currLanguage.split("-")[0] : sys.LANGUAGE_ENGLISH; + sys.language = currLanguage; + var isAndroid = false, iOS = false, osVersion = "", osMainVersion = 0; + var uaResult = /android\s*(\d+(?:\.\d+)*)/i.exec(ua) || /android\s*(\d+(?:\.\d+)*)/i.exec(nav.platform); + if (uaResult) { + isAndroid = true; + osVersion = uaResult[1] || ""; + osMainVersion = parseInt(osVersion) || 0; + } + uaResult = /(iPad|iPhone|iPod).*OS ((\d+_?){2,3})/i.exec(ua); + if (uaResult) { + iOS = true; + osVersion = uaResult[2] || ""; + osMainVersion = parseInt(osVersion) || 0; + } else if (/(iPhone|iPad|iPod)/.exec(nav.platform) || "MacIntel" === nav.platform && nav.maxTouchPoints && nav.maxTouchPoints > 1) { + iOS = true; + osVersion = ""; + osMainVersion = 0; + } + var osName = sys.OS_UNKNOWN; + -1 !== nav.appVersion.indexOf("Win") ? osName = sys.OS_WINDOWS : iOS ? osName = sys.OS_IOS : -1 !== nav.appVersion.indexOf("Mac") ? osName = sys.OS_OSX : -1 !== nav.appVersion.indexOf("X11") && -1 === nav.appVersion.indexOf("Linux") ? osName = sys.OS_UNIX : isAndroid ? osName = sys.OS_ANDROID : -1 === nav.appVersion.indexOf("Linux") && -1 === ua.indexOf("ubuntu") || (osName = sys.OS_LINUX); + sys.os = osName; + sys.osVersion = osVersion; + sys.osMainVersion = osMainVersion; + sys.browserType = sys.BROWSER_TYPE_UNKNOWN; + (function() { + var typeReg1 = /mqqbrowser|micromessenger|qqbrowser|sogou|qzone|liebao|maxthon|ucbs|360 aphone|360browser|baiduboxapp|baidubrowser|maxthon|mxbrowser|miuibrowser/i; + var typeReg2 = /qq|ucbrowser|ubrowser|edge|HuaweiBrowser/i; + var typeReg3 = /chrome|safari|firefox|trident|opera|opr\/|oupeng/i; + var browserTypes = typeReg1.exec(ua) || typeReg2.exec(ua) || typeReg3.exec(ua); + var browserType = browserTypes ? browserTypes[0].toLowerCase() : sys.BROWSER_TYPE_UNKNOWN; + "safari" === browserType && isAndroid ? browserType = sys.BROWSER_TYPE_ANDROID : "qq" === browserType && ua.match(/android.*applewebkit/i) && (browserType = sys.BROWSER_TYPE_ANDROID); + var typeMap = { + micromessenger: sys.BROWSER_TYPE_WECHAT, + trident: sys.BROWSER_TYPE_IE, + edge: sys.BROWSER_TYPE_EDGE, + "360 aphone": sys.BROWSER_TYPE_360, + mxbrowser: sys.BROWSER_TYPE_MAXTHON, + "opr/": sys.BROWSER_TYPE_OPERA, + ubrowser: sys.BROWSER_TYPE_UC, + huaweibrowser: sys.BROWSER_TYPE_HUAWEI + }; + "qqbrowser" !== browserType && "mqqbrowser" !== browserType || ua.match(/wechat|micromessenger/i) && (browserType = sys.BROWSER_TYPE_WECHAT); + sys.browserType = typeMap[browserType] || browserType; + })(); + sys.browserVersion = ""; + (function() { + var versionReg1 = /(mqqbrowser|micromessenger|qqbrowser|sogou|qzone|liebao|maxthon|uc|ucbs|360 aphone|360|baiduboxapp|baidu|maxthon|mxbrowser|miui(?:.hybrid)?)(mobile)?(browser)?\/?([\d.]+)/i; + var versionReg2 = /(qq|chrome|safari|firefox|trident|opera|opr\/|oupeng)(mobile)?(browser)?\/?([\d.]+)/i; + var tmp = ua.match(versionReg1); + tmp || (tmp = ua.match(versionReg2)); + sys.browserVersion = tmp ? tmp[4] : ""; + })(); + var w = window.innerWidth || document.documentElement.clientWidth; + var h = window.innerHeight || document.documentElement.clientHeight; + var ratio = window.devicePixelRatio || 1; + sys.windowPixelResolution = { + width: ratio * w, + height: ratio * h + }; + sys._checkWebGLRenderMode = function() { + if (cc.game.renderType !== cc.game.RENDER_TYPE_WEBGL) throw new Error("This feature supports WebGL render mode only."); + }; + var _tmpCanvas1 = document.createElement("canvas"); + var create3DContext = function create3DContext(canvas, opt_attribs, opt_contextType) { + if (!opt_contextType) return create3DContext(canvas, opt_attribs, "webgl") || create3DContext(canvas, opt_attribs, "experimental-webgl") || create3DContext(canvas, opt_attribs, "webkit-3d") || create3DContext(canvas, opt_attribs, "moz-webgl") || null; + try { + return canvas.getContext(opt_contextType, opt_attribs); + } catch (e) { + return null; + } + }; + try { + var localStorage = sys.localStorage = win.localStorage; + localStorage.setItem("storage", ""); + localStorage.removeItem("storage"); + localStorage = null; + } catch (e) { + var warn = function warn() { + cc.warnID(5200); + }; + sys.localStorage = { + getItem: warn, + setItem: warn, + removeItem: warn, + clear: warn + }; + } + var _supportWebp = _tmpCanvas1.toDataURL("image/webp").startsWith("data:image/webp"); + var _supportCanvas = !!_tmpCanvas1.getContext("2d"); + var _supportWebGL = false; + false; + win.WebGLRenderingContext && (_supportWebGL = true); + var capabilities = sys.capabilities = { + canvas: _supportCanvas, + opengl: _supportWebGL, + webp: _supportWebp, + imageBitmap: false + }; + if ("undefined" !== typeof createImageBitmap && "undefined" !== typeof Blob) { + _tmpCanvas1.width = _tmpCanvas1.height = 2; + createImageBitmap(_tmpCanvas1, {}).then((function(imageBitmap) { + capabilities.imageBitmap = true; + imageBitmap.close && imageBitmap.close(); + }))["catch"]((function(err) {})); + } + (void 0 !== docEle["ontouchstart"] || void 0 !== doc["ontouchstart"] || nav.msPointerEnabled) && (capabilities["touches"] = true); + void 0 !== docEle["onmouseup"] && (capabilities["mouse"] = true); + void 0 !== docEle["onkeyup"] && (capabilities["keyboard"] = true); + (win.DeviceMotionEvent || win.DeviceOrientationEvent) && (capabilities["accelerometer"] = true); + var __audioSupport; + (function() { + var DEBUG = false; + var version = sys.browserVersion; + var supportWebAudio = !!(window.AudioContext || window.webkitAudioContext || window.mozAudioContext); + __audioSupport = { + ONLY_ONE: false, + WEB_AUDIO: supportWebAudio, + DELAY_CREATE_CTX: false + }; + sys.os === sys.OS_IOS && (__audioSupport.USE_LOADER_EVENT = "loadedmetadata"); + if (sys.browserType === sys.BROWSER_TYPE_FIREFOX) { + __audioSupport.DELAY_CREATE_CTX = true; + __audioSupport.USE_LOADER_EVENT = "canplay"; + } + sys.os === sys.OS_ANDROID && sys.browserType === sys.BROWSER_TYPE_UC && (__audioSupport.ONE_SOURCE = true); + DEBUG && setTimeout((function() { + cc.log("browse type: " + sys.browserType); + cc.log("browse version: " + version); + cc.log("MULTI_CHANNEL: " + __audioSupport.MULTI_CHANNEL); + cc.log("WEB_AUDIO: " + __audioSupport.WEB_AUDIO); + cc.log("AUTOPLAY: " + __audioSupport.AUTOPLAY); + }), 0); + })(); + try { + if (__audioSupport.WEB_AUDIO) { + __audioSupport.context = new (window.AudioContext || window.webkitAudioContext || window.mozAudioContext)(); + __audioSupport.DELAY_CREATE_CTX && setTimeout((function() { + __audioSupport.context = new (window.AudioContext || window.webkitAudioContext || window.mozAudioContext)(); + }), 0); + } + } catch (error) { + __audioSupport.WEB_AUDIO = false; + cc.logID(5201); + } + var formatSupport = []; + (function() { + var audio = document.createElement("audio"); + if (audio.canPlayType) { + var ogg = audio.canPlayType('audio/ogg; codecs="vorbis"'); + ogg && formatSupport.push(".ogg"); + var mp3 = audio.canPlayType("audio/mpeg"); + mp3 && formatSupport.push(".mp3"); + var wav = audio.canPlayType('audio/wav; codecs="1"'); + wav && formatSupport.push(".wav"); + var mp4 = audio.canPlayType("audio/mp4"); + mp4 && formatSupport.push(".mp4"); + var m4a = audio.canPlayType("audio/x-m4a"); + m4a && formatSupport.push(".m4a"); + } + })(); + __audioSupport.format = formatSupport; + sys.__audioSupport = __audioSupport; + } + sys.NetworkType = { + NONE: 0, + LAN: 1, + WWAN: 2 + }; + sys.getNetworkType = function() { + return sys.NetworkType.LAN; + }; + sys.getBatteryLevel = function() { + return 1; + }; + sys.garbageCollect = function() {}; + sys.restartVM = function() {}; + sys.isObjectValid = function(obj) { + if (obj) return true; + return false; + }; + sys.dump = function() { + var self = this; + var str = ""; + str += "isMobile : " + self.isMobile + "\r\n"; + str += "language : " + self.language + "\r\n"; + str += "browserType : " + self.browserType + "\r\n"; + str += "browserVersion : " + self.browserVersion + "\r\n"; + str += "capabilities : " + JSON.stringify(self.capabilities) + "\r\n"; + str += "os : " + self.os + "\r\n"; + str += "osVersion : " + self.osVersion + "\r\n"; + str += "platform : " + self.platform + "\r\n"; + str += "Using " + (cc.game.renderType === cc.game.RENDER_TYPE_WEBGL ? "WEBGL" : "CANVAS") + " renderer.\r\n"; + cc.log(str); + }; + sys.openURL = function(url) { + false, false; + window.open(url); + }; + sys.now = function() { + return Date.now ? Date.now() : +new Date(); + }; + return sys; + } + var sys = cc && cc.sys ? cc.sys : initSys(); + module.exports = sys; + }), {} ], + 250: [ (function(require, module, exports) { + "use strict"; + var EventTarget = require("../event/event-target"); + var js = require("../platform/js"); + var renderer = require("../renderer"); + require("../platform/CCClass"); + var __BrowserGetter = { + init: function init() { + this.html = document.getElementsByTagName("html")[0]; + }, + availWidth: function availWidth(frame) { + return frame && frame !== this.html ? frame.clientWidth : window.innerWidth; + }, + availHeight: function availHeight(frame) { + return frame && frame !== this.html ? frame.clientHeight : window.innerHeight; + }, + meta: { + width: "device-width" + }, + adaptationType: cc.sys.browserType + }; + cc.sys.os === cc.sys.OS_IOS && (__BrowserGetter.adaptationType = cc.sys.BROWSER_TYPE_SAFARI); + switch (__BrowserGetter.adaptationType) { + case cc.sys.BROWSER_TYPE_SAFARI: + case cc.sys.BROWSER_TYPE_SOUGOU: + case cc.sys.BROWSER_TYPE_UC: + __BrowserGetter.meta["minimal-ui"] = "true"; + __BrowserGetter.availWidth = function(frame) { + return frame.clientWidth; + }; + __BrowserGetter.availHeight = function(frame) { + return frame.clientHeight; + }; + } + var _scissorRect = null; + var View = function View() { + EventTarget.call(this); + var _t = this, _strategyer = cc.ContainerStrategy, _strategy = cc.ContentStrategy; + __BrowserGetter.init(this); + _t._frameSize = cc.size(0, 0); + _t._designResolutionSize = cc.size(0, 0); + _t._originalDesignResolutionSize = cc.size(0, 0); + _t._scaleX = 1; + _t._scaleY = 1; + _t._viewportRect = cc.rect(0, 0, 0, 0); + _t._visibleRect = cc.rect(0, 0, 0, 0); + _t._autoFullScreen = false; + _t._devicePixelRatio = 1; + false; + _t._maxPixelRatio = 2; + _t._retinaEnabled = false; + _t._resizeCallback = null; + _t._resizing = false; + _t._resizeWithBrowserSize = false; + _t._orientationChanging = true; + _t._isRotated = false; + _t._orientation = cc.macro.ORIENTATION_AUTO; + _t._isAdjustViewport = true; + _t._antiAliasEnabled = false; + _t._resolutionPolicy = null; + _t._rpExactFit = new cc.ResolutionPolicy(_strategyer.EQUAL_TO_FRAME, _strategy.EXACT_FIT); + _t._rpShowAll = new cc.ResolutionPolicy(_strategyer.EQUAL_TO_FRAME, _strategy.SHOW_ALL); + _t._rpNoBorder = new cc.ResolutionPolicy(_strategyer.EQUAL_TO_FRAME, _strategy.NO_BORDER); + _t._rpFixedHeight = new cc.ResolutionPolicy(_strategyer.EQUAL_TO_FRAME, _strategy.FIXED_HEIGHT); + _t._rpFixedWidth = new cc.ResolutionPolicy(_strategyer.EQUAL_TO_FRAME, _strategy.FIXED_WIDTH); + cc.game.once(cc.game.EVENT_ENGINE_INITED, this.init, this); + }; + cc.js.extend(View, EventTarget); + cc.js.mixin(View.prototype, { + init: function init() { + this._initFrameSize(); + var w = cc.game.canvas.width, h = cc.game.canvas.height; + this._designResolutionSize.width = w; + this._designResolutionSize.height = h; + this._originalDesignResolutionSize.width = w; + this._originalDesignResolutionSize.height = h; + this._viewportRect.width = w; + this._viewportRect.height = h; + this._visibleRect.width = w; + this._visibleRect.height = h; + cc.winSize.width = this._visibleRect.width; + cc.winSize.height = this._visibleRect.height; + cc.visibleRect && cc.visibleRect.init(this._visibleRect); + }, + _resizeEvent: function _resizeEvent(forceOrEvent) { + var view; + view = this.setDesignResolutionSize ? this : cc.view; + var sys = cc.sys; + if (sys.browserType === sys.BROWSER_TYPE_UC && sys.os === sys.OS_IOS) { + setTimeout((function() { + view._resizeEvent(forceOrEvent); + }), 0); + return; + } + var prevFrameW = view._frameSize.width, prevFrameH = view._frameSize.height, prevRotated = view._isRotated; + if (cc.sys.isMobile) { + var containerStyle = cc.game.container.style, margin = containerStyle.margin; + containerStyle.margin = "0"; + containerStyle.display = "none"; + view._initFrameSize(); + containerStyle.margin = margin; + containerStyle.display = "block"; + } else view._initFrameSize(); + if (true !== forceOrEvent && view._isRotated === prevRotated && view._frameSize.width === prevFrameW && view._frameSize.height === prevFrameH) return; + var width = view._originalDesignResolutionSize.width; + var height = view._originalDesignResolutionSize.height; + view._resizing = true; + width > 0 && view.setDesignResolutionSize(width, height, view._resolutionPolicy); + view._resizing = false; + view.emit("canvas-resize"); + view._resizeCallback && view._resizeCallback.call(); + }, + _orientationChange: function _orientationChange() { + cc.view._orientationChanging = true; + cc.view._resizeEvent(); + cc.sys.browserType === cc.sys.BROWSER_TYPE_SAFARI && cc.sys.isMobile && setTimeout((function() { + window.innerHeight > window.innerWidth && window.scrollTo(0, 1); + }), 500); + }, + _resize: function _resize() { + cc.view._resizeEvent(false); + }, + resizeWithBrowserSize: function resizeWithBrowserSize(enabled) { + if (enabled) { + if (!this._resizeWithBrowserSize) { + this._resizeWithBrowserSize = true; + window.addEventListener("resize", this._resize); + window.addEventListener("orientationchange", this._orientationChange); + } + } else if (this._resizeWithBrowserSize) { + this._resizeWithBrowserSize = false; + window.removeEventListener("resize", this._resize); + window.removeEventListener("orientationchange", this._orientationChange); + } + }, + setResizeCallback: function setResizeCallback(callback) { + false; + "function" !== typeof callback && null != callback || (this._resizeCallback = callback); + }, + setOrientation: function setOrientation(orientation) { + orientation &= cc.macro.ORIENTATION_AUTO; + if (orientation && this._orientation !== orientation) { + this._orientation = orientation; + var designWidth = this._originalDesignResolutionSize.width; + var designHeight = this._originalDesignResolutionSize.height; + this.setDesignResolutionSize(designWidth, designHeight, this._resolutionPolicy); + } + }, + _initFrameSize: function _initFrameSize() { + var locFrameSize = this._frameSize; + var w = __BrowserGetter.availWidth(cc.game.frame); + var h = __BrowserGetter.availHeight(cc.game.frame); + var isLandscape = w >= h; + if ((false, !cc.sys.isMobile) || isLandscape && this._orientation & cc.macro.ORIENTATION_LANDSCAPE || !isLandscape && this._orientation & cc.macro.ORIENTATION_PORTRAIT) { + locFrameSize.width = w; + locFrameSize.height = h; + cc.game.container.style["-webkit-transform"] = "rotate(0deg)"; + cc.game.container.style.transform = "rotate(0deg)"; + this._isRotated = false; + } else { + locFrameSize.width = h; + locFrameSize.height = w; + cc.game.container.style["-webkit-transform"] = "rotate(90deg)"; + cc.game.container.style.transform = "rotate(90deg)"; + cc.game.container.style["-webkit-transform-origin"] = "0px 0px 0px"; + cc.game.container.style.transformOrigin = "0px 0px 0px"; + this._isRotated = true; + } + this._orientationChanging && setTimeout((function() { + cc.view._orientationChanging = false; + }), 1e3); + }, + _setViewportMeta: function _setViewportMeta(metas, overwrite) { + var vp = document.getElementById("cocosMetaElement"); + vp && overwrite && document.head.removeChild(vp); + var elems = document.getElementsByName("viewport"), currentVP = elems ? elems[0] : null, content, key, pattern; + content = currentVP ? currentVP.content : ""; + vp = vp || document.createElement("meta"); + vp.id = "cocosMetaElement"; + vp.name = "viewport"; + vp.content = ""; + for (key in metas) if (-1 == content.indexOf(key)) content += "," + key + "=" + metas[key]; else if (overwrite) { + pattern = new RegExp(key + "s*=s*[^,]+"); + content = content.replace(pattern, key + "=" + metas[key]); + } + /^,/.test(content) && (content = content.substr(1)); + vp.content = content; + currentVP && (currentVP.content = content); + document.head.appendChild(vp); + }, + _adjustViewportMeta: function _adjustViewportMeta() { + if (this._isAdjustViewport && true) { + this._setViewportMeta(__BrowserGetter.meta, false); + this._isAdjustViewport = false; + } + }, + adjustViewportMeta: function adjustViewportMeta(enabled) { + this._isAdjustViewport = enabled; + }, + enableRetina: function enableRetina(enabled) { + this._retinaEnabled = !!enabled; + }, + isRetinaEnabled: function isRetinaEnabled() { + return this._retinaEnabled; + }, + enableAntiAlias: function enableAntiAlias(enabled) { + cc.warnID(9200); + if (this._antiAliasEnabled === enabled) return; + this._antiAliasEnabled = enabled; + if (cc.game.renderType === cc.game.RENDER_TYPE_WEBGL) { + var cache = cc.assetManager.assets; + cache.forEach((function(asset) { + if (asset instanceof cc.Texture2D) { + var Filter = cc.Texture2D.Filter; + enabled ? asset.setFilters(Filter.LINEAR, Filter.LINEAR) : asset.setFilters(Filter.NEAREST, Filter.NEAREST); + } + })); + } else if (cc.game.renderType === cc.game.RENDER_TYPE_CANVAS) { + var ctx = cc.game.canvas.getContext("2d"); + ctx.imageSmoothingEnabled = enabled; + ctx.mozImageSmoothingEnabled = enabled; + } + }, + isAntiAliasEnabled: function isAntiAliasEnabled() { + return this._antiAliasEnabled; + }, + enableAutoFullScreen: function enableAutoFullScreen(enabled) { + if (enabled && enabled !== this._autoFullScreen && cc.sys.isMobile) { + this._autoFullScreen = true; + cc.screen.autoFullScreen(cc.game.frame); + } else { + this._autoFullScreen = false; + cc.screen.disableAutoFullScreen(cc.game.frame); + } + }, + isAutoFullScreenEnabled: function isAutoFullScreenEnabled() { + return this._autoFullScreen; + }, + setCanvasSize: function setCanvasSize(width, height) { + var canvas = cc.game.canvas; + var container = cc.game.container; + canvas.width = width * this._devicePixelRatio; + canvas.height = height * this._devicePixelRatio; + canvas.style.width = width + "px"; + canvas.style.height = height + "px"; + container.style.width = width + "px"; + container.style.height = height + "px"; + this._resizeEvent(); + }, + getCanvasSize: function getCanvasSize() { + return cc.size(cc.game.canvas.width, cc.game.canvas.height); + }, + getFrameSize: function getFrameSize() { + return cc.size(this._frameSize.width, this._frameSize.height); + }, + setFrameSize: function setFrameSize(width, height) { + this._frameSize.width = width; + this._frameSize.height = height; + cc.game.frame.style.width = width + "px"; + cc.game.frame.style.height = height + "px"; + this._resizeEvent(true); + }, + getVisibleSize: function getVisibleSize() { + return cc.size(this._visibleRect.width, this._visibleRect.height); + }, + getVisibleSizeInPixel: function getVisibleSizeInPixel() { + return cc.size(this._visibleRect.width * this._scaleX, this._visibleRect.height * this._scaleY); + }, + getVisibleOrigin: function getVisibleOrigin() { + return cc.v2(this._visibleRect.x, this._visibleRect.y); + }, + getVisibleOriginInPixel: function getVisibleOriginInPixel() { + return cc.v2(this._visibleRect.x * this._scaleX, this._visibleRect.y * this._scaleY); + }, + getResolutionPolicy: function getResolutionPolicy() { + return this._resolutionPolicy; + }, + setResolutionPolicy: function setResolutionPolicy(resolutionPolicy) { + var _t = this; + if (resolutionPolicy instanceof cc.ResolutionPolicy) _t._resolutionPolicy = resolutionPolicy; else { + var _locPolicy = cc.ResolutionPolicy; + resolutionPolicy === _locPolicy.EXACT_FIT && (_t._resolutionPolicy = _t._rpExactFit); + resolutionPolicy === _locPolicy.SHOW_ALL && (_t._resolutionPolicy = _t._rpShowAll); + resolutionPolicy === _locPolicy.NO_BORDER && (_t._resolutionPolicy = _t._rpNoBorder); + resolutionPolicy === _locPolicy.FIXED_HEIGHT && (_t._resolutionPolicy = _t._rpFixedHeight); + resolutionPolicy === _locPolicy.FIXED_WIDTH && (_t._resolutionPolicy = _t._rpFixedWidth); + } + }, + setDesignResolutionSize: function setDesignResolutionSize(width, height, resolutionPolicy) { + if (!(width > 0 && height > 0)) { + cc.errorID(2200); + return; + } + this.setResolutionPolicy(resolutionPolicy); + var policy = this._resolutionPolicy; + policy && policy.preApply(this); + cc.sys.isMobile && this._adjustViewportMeta(); + this._orientationChanging = true; + this._resizing || this._initFrameSize(); + if (!policy) { + cc.logID(2201); + return; + } + this._originalDesignResolutionSize.width = this._designResolutionSize.width = width; + this._originalDesignResolutionSize.height = this._designResolutionSize.height = height; + var result = policy.apply(this, this._designResolutionSize); + if (result.scale && 2 === result.scale.length) { + this._scaleX = result.scale[0]; + this._scaleY = result.scale[1]; + } + if (result.viewport) { + var vp = this._viewportRect, vb = this._visibleRect, rv = result.viewport; + vp.x = rv.x; + vp.y = rv.y; + vp.width = rv.width; + vp.height = rv.height; + vb.x = 0; + vb.y = 0; + vb.width = rv.width / this._scaleX; + vb.height = rv.height / this._scaleY; + } + policy.postApply(this); + cc.winSize.width = this._visibleRect.width; + cc.winSize.height = this._visibleRect.height; + cc.visibleRect && cc.visibleRect.init(this._visibleRect); + renderer.updateCameraViewport(); + cc.internal.inputManager._updateCanvasBoundingRect(); + this.emit("design-resolution-changed"); + }, + getDesignResolutionSize: function getDesignResolutionSize() { + return cc.size(this._designResolutionSize.width, this._designResolutionSize.height); + }, + setRealPixelResolution: function setRealPixelResolution(width, height, resolutionPolicy) { + true, true; + this._setViewportMeta({ + width: width + }, true); + document.documentElement.style.width = width + "px"; + document.body.style.width = width + "px"; + document.body.style.left = "0px"; + document.body.style.top = "0px"; + this.setDesignResolutionSize(width, height, resolutionPolicy); + }, + setViewportInPoints: function setViewportInPoints(x, y, w, h) { + var locScaleX = this._scaleX, locScaleY = this._scaleY; + cc.game._renderContext.viewport(x * locScaleX + this._viewportRect.x, y * locScaleY + this._viewportRect.y, w * locScaleX, h * locScaleY); + }, + setScissorInPoints: function setScissorInPoints(x, y, w, h) { + var scaleX = this._scaleX, scaleY = this._scaleY; + var sx = Math.ceil(x * scaleX + this._viewportRect.x); + var sy = Math.ceil(y * scaleY + this._viewportRect.y); + var sw = Math.ceil(w * scaleX); + var sh = Math.ceil(h * scaleY); + var gl = cc.game._renderContext; + if (!_scissorRect) { + var boxArr = gl.getParameter(gl.SCISSOR_BOX); + _scissorRect = cc.rect(boxArr[0], boxArr[1], boxArr[2], boxArr[3]); + } + if (_scissorRect.x !== sx || _scissorRect.y !== sy || _scissorRect.width !== sw || _scissorRect.height !== sh) { + _scissorRect.x = sx; + _scissorRect.y = sy; + _scissorRect.width = sw; + _scissorRect.height = sh; + gl.scissor(sx, sy, sw, sh); + } + }, + isScissorEnabled: function isScissorEnabled() { + return cc.game._renderContext.isEnabled(gl.SCISSOR_TEST); + }, + getScissorRect: function getScissorRect() { + if (!_scissorRect) { + var boxArr = gl.getParameter(gl.SCISSOR_BOX); + _scissorRect = cc.rect(boxArr[0], boxArr[1], boxArr[2], boxArr[3]); + } + var scaleXFactor = 1 / this._scaleX; + var scaleYFactor = 1 / this._scaleY; + return cc.rect((_scissorRect.x - this._viewportRect.x) * scaleXFactor, (_scissorRect.y - this._viewportRect.y) * scaleYFactor, _scissorRect.width * scaleXFactor, _scissorRect.height * scaleYFactor); + }, + getViewportRect: function getViewportRect() { + return this._viewportRect; + }, + getScaleX: function getScaleX() { + return this._scaleX; + }, + getScaleY: function getScaleY() { + return this._scaleY; + }, + getDevicePixelRatio: function getDevicePixelRatio() { + return this._devicePixelRatio; + }, + convertToLocationInView: function convertToLocationInView(tx, ty, relatedPos, out) { + var result = out || cc.v2(); + var posLeft = relatedPos.adjustedLeft ? relatedPos.adjustedLeft : relatedPos.left; + var posTop = relatedPos.adjustedTop ? relatedPos.adjustedTop : relatedPos.top; + var x = this._devicePixelRatio * (tx - posLeft); + var y = this._devicePixelRatio * (posTop + relatedPos.height - ty); + if (this._isRotated) { + result.x = cc.game.canvas.width - y; + result.y = x; + } else { + result.x = x; + result.y = y; + } + return result; + }, + _convertMouseToLocationInView: function _convertMouseToLocationInView(in_out_point, relatedPos) { + var viewport = this._viewportRect, _t = this; + in_out_point.x = (_t._devicePixelRatio * (in_out_point.x - relatedPos.left) - viewport.x) / _t._scaleX; + in_out_point.y = (_t._devicePixelRatio * (relatedPos.top + relatedPos.height - in_out_point.y) - viewport.y) / _t._scaleY; + }, + _convertPointWithScale: function _convertPointWithScale(point) { + var viewport = this._viewportRect; + point.x = (point.x - viewport.x) / this._scaleX; + point.y = (point.y - viewport.y) / this._scaleY; + }, + _convertTouchesWithScale: function _convertTouchesWithScale(touches) { + var viewport = this._viewportRect, scaleX = this._scaleX, scaleY = this._scaleY, selTouch, selPoint, selPrePoint; + for (var i = 0; i < touches.length; i++) { + selTouch = touches[i]; + selPoint = selTouch._point; + selPrePoint = selTouch._prevPoint; + selPoint.x = (selPoint.x - viewport.x) / scaleX; + selPoint.y = (selPoint.y - viewport.y) / scaleY; + selPrePoint.x = (selPrePoint.x - viewport.x) / scaleX; + selPrePoint.y = (selPrePoint.y - viewport.y) / scaleY; + } + } + }); + cc.ContainerStrategy = cc.Class({ + name: "ContainerStrategy", + preApply: function preApply(view) {}, + apply: function apply(view, designedResolution) {}, + postApply: function postApply(view) {}, + _setupContainer: function _setupContainer(view, w, h) { + var locCanvas = cc.game.canvas; + this._setupStyle(view, w, h); + var devicePixelRatio = view._devicePixelRatio = 1; + false; + view.isRetinaEnabled() && (devicePixelRatio = view._devicePixelRatio = Math.min(view._maxPixelRatio, window.devicePixelRatio || 1)); + locCanvas.width = w * devicePixelRatio; + locCanvas.height = h * devicePixelRatio; + }, + _setupStyle: function _setupStyle(view, w, h) { + var locCanvas = cc.game.canvas; + var locContainer = cc.game.container; + if (cc.sys.os === cc.sys.OS_ANDROID) { + document.body.style.width = (view._isRotated ? h : w) + "px"; + document.body.style.height = (view._isRotated ? w : h) + "px"; + } + locContainer.style.width = locCanvas.style.width = w + "px"; + locContainer.style.height = locCanvas.style.height = h + "px"; + }, + _fixContainer: function _fixContainer() { + document.body.insertBefore(cc.game.container, document.body.firstChild); + var bs = document.body.style; + bs.width = window.innerWidth + "px"; + bs.height = window.innerHeight + "px"; + bs.overflow = "hidden"; + var contStyle = cc.game.container.style; + contStyle.position = "fixed"; + contStyle.left = contStyle.top = "0px"; + document.body.scrollTop = 0; + } + }); + cc.ContentStrategy = cc.Class({ + name: "ContentStrategy", + ctor: function ctor() { + this._result = { + scale: [ 1, 1 ], + viewport: null + }; + }, + _buildResult: function _buildResult(containerW, containerH, contentW, contentH, scaleX, scaleY) { + Math.abs(containerW - contentW) < 2 && (contentW = containerW); + Math.abs(containerH - contentH) < 2 && (contentH = containerH); + var viewport = cc.rect((containerW - contentW) / 2, (containerH - contentH) / 2, contentW, contentH); + cc.game.renderType === cc.game.RENDER_TYPE_CANVAS; + this._result.scale = [ scaleX, scaleY ]; + this._result.viewport = viewport; + return this._result; + }, + preApply: function preApply(view) {}, + apply: function apply(view, designedResolution) { + return { + scale: [ 1, 1 ] + }; + }, + postApply: function postApply(view) {} + }); + (function() { + var EqualToFrame = cc.Class({ + name: "EqualToFrame", + extends: cc.ContainerStrategy, + apply: function apply(view) { + var frameH = view._frameSize.height, containerStyle = cc.game.container.style; + this._setupContainer(view, view._frameSize.width, view._frameSize.height); + view._isRotated ? containerStyle.margin = "0 0 0 " + frameH + "px" : containerStyle.margin = "0px"; + containerStyle.padding = "0px"; + } + }); + var ProportionalToFrame = cc.Class({ + name: "ProportionalToFrame", + extends: cc.ContainerStrategy, + apply: function apply(view, designedResolution) { + var frameW = view._frameSize.width, frameH = view._frameSize.height, containerStyle = cc.game.container.style, designW = designedResolution.width, designH = designedResolution.height, scaleX = frameW / designW, scaleY = frameH / designH, containerW, containerH; + scaleX < scaleY ? (containerW = frameW, containerH = designH * scaleX) : (containerW = designW * scaleY, + containerH = frameH); + var offx = Math.round((frameW - containerW) / 2); + var offy = Math.round((frameH - containerH) / 2); + containerW = frameW - 2 * offx; + containerH = frameH - 2 * offy; + this._setupContainer(view, containerW, containerH); + true; + view._isRotated ? containerStyle.margin = "0 0 0 " + frameH + "px" : containerStyle.margin = "0px"; + containerStyle.paddingLeft = offx + "px"; + containerStyle.paddingRight = offx + "px"; + containerStyle.paddingTop = offy + "px"; + containerStyle.paddingBottom = offy + "px"; + } + }); + var EqualToWindow = cc.Class({ + name: "EqualToWindow", + extends: EqualToFrame, + preApply: function preApply(view) { + this._super(view); + cc.game.frame = document.documentElement; + }, + apply: function apply(view) { + this._super(view); + this._fixContainer(); + } + }); + var ProportionalToWindow = cc.Class({ + name: "ProportionalToWindow", + extends: ProportionalToFrame, + preApply: function preApply(view) { + this._super(view); + cc.game.frame = document.documentElement; + }, + apply: function apply(view, designedResolution) { + this._super(view, designedResolution); + this._fixContainer(); + } + }); + var OriginalContainer = cc.Class({ + name: "OriginalContainer", + extends: cc.ContainerStrategy, + apply: function apply(view) { + this._setupContainer(view, cc.game.canvas.width, cc.game.canvas.height); + } + }); + var _global = "undefined" === typeof window ? global : window; + var globalAdapter = _global.__globalAdapter; + if (globalAdapter) { + globalAdapter.adaptContainerStrategy && globalAdapter.adaptContainerStrategy(cc.ContainerStrategy.prototype); + globalAdapter.adaptView && globalAdapter.adaptView(View.prototype); + } + cc.ContainerStrategy.EQUAL_TO_FRAME = new EqualToFrame(); + cc.ContainerStrategy.PROPORTION_TO_FRAME = new ProportionalToFrame(); + cc.ContainerStrategy.ORIGINAL_CONTAINER = new OriginalContainer(); + var ExactFit = cc.Class({ + name: "ExactFit", + extends: cc.ContentStrategy, + apply: function apply(view, designedResolution) { + var containerW = cc.game.canvas.width, containerH = cc.game.canvas.height, scaleX = containerW / designedResolution.width, scaleY = containerH / designedResolution.height; + return this._buildResult(containerW, containerH, containerW, containerH, scaleX, scaleY); + } + }); + var ShowAll = cc.Class({ + name: "ShowAll", + extends: cc.ContentStrategy, + apply: function apply(view, designedResolution) { + var containerW = cc.game.canvas.width, containerH = cc.game.canvas.height, designW = designedResolution.width, designH = designedResolution.height, scaleX = containerW / designW, scaleY = containerH / designH, scale = 0, contentW, contentH; + scaleX < scaleY ? (scale = scaleX, contentW = containerW, contentH = designH * scale) : (scale = scaleY, + contentW = designW * scale, contentH = containerH); + return this._buildResult(containerW, containerH, contentW, contentH, scale, scale); + } + }); + var NoBorder = cc.Class({ + name: "NoBorder", + extends: cc.ContentStrategy, + apply: function apply(view, designedResolution) { + var containerW = cc.game.canvas.width, containerH = cc.game.canvas.height, designW = designedResolution.width, designH = designedResolution.height, scaleX = containerW / designW, scaleY = containerH / designH, scale, contentW, contentH; + scaleX < scaleY ? (scale = scaleY, contentW = designW * scale, contentH = containerH) : (scale = scaleX, + contentW = containerW, contentH = designH * scale); + return this._buildResult(containerW, containerH, contentW, contentH, scale, scale); + } + }); + var FixedHeight = cc.Class({ + name: "FixedHeight", + extends: cc.ContentStrategy, + apply: function apply(view, designedResolution) { + var containerW = cc.game.canvas.width, containerH = cc.game.canvas.height, designH = designedResolution.height, scale = containerH / designH, contentW = containerW, contentH = containerH; + return this._buildResult(containerW, containerH, contentW, contentH, scale, scale); + } + }); + var FixedWidth = cc.Class({ + name: "FixedWidth", + extends: cc.ContentStrategy, + apply: function apply(view, designedResolution) { + var containerW = cc.game.canvas.width, containerH = cc.game.canvas.height, designW = designedResolution.width, scale = containerW / designW, contentW = containerW, contentH = containerH; + return this._buildResult(containerW, containerH, contentW, contentH, scale, scale); + } + }); + cc.ContentStrategy.EXACT_FIT = new ExactFit(); + cc.ContentStrategy.SHOW_ALL = new ShowAll(); + cc.ContentStrategy.NO_BORDER = new NoBorder(); + cc.ContentStrategy.FIXED_HEIGHT = new FixedHeight(); + cc.ContentStrategy.FIXED_WIDTH = new FixedWidth(); + })(); + cc.ResolutionPolicy = cc.Class({ + name: "cc.ResolutionPolicy", + ctor: function ctor(containerStg, contentStg) { + this._containerStrategy = null; + this._contentStrategy = null; + this.setContainerStrategy(containerStg); + this.setContentStrategy(contentStg); + }, + preApply: function preApply(view) { + this._containerStrategy.preApply(view); + this._contentStrategy.preApply(view); + }, + apply: function apply(view, designedResolution) { + this._containerStrategy.apply(view, designedResolution); + return this._contentStrategy.apply(view, designedResolution); + }, + postApply: function postApply(view) { + this._containerStrategy.postApply(view); + this._contentStrategy.postApply(view); + }, + setContainerStrategy: function setContainerStrategy(containerStg) { + containerStg instanceof cc.ContainerStrategy && (this._containerStrategy = containerStg); + }, + setContentStrategy: function setContentStrategy(contentStg) { + contentStg instanceof cc.ContentStrategy && (this._contentStrategy = contentStg); + } + }); + js.get(cc.ResolutionPolicy.prototype, "canvasSize", (function() { + return cc.v2(cc.game.canvas.width, cc.game.canvas.height); + })); + cc.ResolutionPolicy.EXACT_FIT = 0; + cc.ResolutionPolicy.NO_BORDER = 1; + cc.ResolutionPolicy.SHOW_ALL = 2; + cc.ResolutionPolicy.FIXED_HEIGHT = 3; + cc.ResolutionPolicy.FIXED_WIDTH = 4; + cc.ResolutionPolicy.UNKNOWN = 5; + cc.view = new View(); + cc.winSize = cc.size(); + module.exports = cc.view; + }), { + "../event/event-target": 187, + "../platform/CCClass": 240, + "../platform/js": 261, + "../renderer": 272 + } ], + 251: [ (function(require, module, exports) { + "use strict"; + cc.visibleRect = { + topLeft: cc.v2(0, 0), + topRight: cc.v2(0, 0), + top: cc.v2(0, 0), + bottomLeft: cc.v2(0, 0), + bottomRight: cc.v2(0, 0), + bottom: cc.v2(0, 0), + center: cc.v2(0, 0), + left: cc.v2(0, 0), + right: cc.v2(0, 0), + width: 0, + height: 0, + init: function init(visibleRect) { + var w = this.width = visibleRect.width; + var h = this.height = visibleRect.height; + var l = visibleRect.x, b = visibleRect.y, t = b + h, r = l + w; + this.topLeft.x = l; + this.topLeft.y = t; + this.topRight.x = r; + this.topRight.y = t; + this.top.x = l + w / 2; + this.top.y = t; + this.bottomLeft.x = l; + this.bottomLeft.y = b; + this.bottomRight.x = r; + this.bottomRight.y = b; + this.bottom.x = l + w / 2; + this.bottom.y = b; + this.center.x = l + w / 2; + this.center.y = b + h / 2; + this.left.x = l; + this.left.y = b + h / 2; + this.right.x = r; + this.right.y = b + h / 2; + } + }; + }), {} ], + 252: [ (function(require, module, exports) { + "use strict"; + var js = require("./js"); + var isPlainEmptyObj = require("./utils").isPlainEmptyObj_DEV; + var DELIMETER = "$_$"; + function createAttrsSingle(owner, superAttrs) { + var attrs = superAttrs ? Object.create(superAttrs) : {}; + js.value(owner, "__attrs__", attrs); + return attrs; + } + function createAttrs(subclass) { + if ("function" !== typeof subclass) { + var instance = subclass; + return createAttrsSingle(instance, getClassAttrs(instance.constructor)); + } + var superClass; + var chains = cc.Class.getInheritanceChain(subclass); + for (var i = chains.length - 1; i >= 0; i--) { + var cls = chains[i]; + var attrs = cls.hasOwnProperty("__attrs__") && cls.__attrs__; + if (!attrs) { + superClass = chains[i + 1]; + createAttrsSingle(cls, superClass && superClass.__attrs__); + } + } + superClass = chains[0]; + createAttrsSingle(subclass, superClass && superClass.__attrs__); + return subclass.__attrs__; + } + function attr(ctor, propName, newAttrs) { + var attrs = getClassAttrs(ctor); + var _key; + true; + var prefix = propName + DELIMETER; + var ret = {}; + for (var key in attrs) key.startsWith(prefix) && (ret[key.slice(prefix.length)] = attrs[key]); + return ret; + } + function getClassAttrs(ctor) { + return ctor.hasOwnProperty("__attrs__") && ctor.__attrs__ || createAttrs(ctor); + } + function setClassAttr(ctor, propName, key, value) { + getClassAttrs(ctor)[propName + DELIMETER + key] = value; + } + function PrimitiveType(name, def) { + this.name = name; + this["default"] = def; + } + PrimitiveType.prototype.toString = function() { + return this.name; + }; + cc.Integer = new PrimitiveType("Integer", 0); + cc.Float = new PrimitiveType("Float", 0); + false; + cc.Boolean = new PrimitiveType("Boolean", false); + cc.String = new PrimitiveType("String", ""); + function getTypeChecker(type, attrName) { + return function(constructor, mainPropName) { + var propInfo = '"' + js.getClassName(constructor) + "." + mainPropName + '"'; + var mainPropAttrs = attr(constructor, mainPropName); + var mainPropAttrsType = mainPropAttrs.type; + mainPropAttrsType === cc.Integer || mainPropAttrsType === cc.Float ? mainPropAttrsType = "Number" : mainPropAttrsType !== cc.String && mainPropAttrsType !== cc.Boolean || (mainPropAttrsType = "" + mainPropAttrsType); + if (mainPropAttrsType !== type) { + cc.warnID(3604, propInfo); + return; + } + if (!mainPropAttrs.hasOwnProperty("default")) return; + var defaultVal = mainPropAttrs["default"]; + if ("undefined" === typeof defaultVal) return; + var isContainer = Array.isArray(defaultVal) || isPlainEmptyObj(defaultVal); + if (isContainer) return; + var defaultType = typeof defaultVal; + var type_lowerCase = type.toLowerCase(); + if (defaultType === type_lowerCase) if ("object" === type_lowerCase) { + if (!defaultVal || defaultVal instanceof mainPropAttrs.ctor) return; + cc.warnID(3605, propInfo, js.getClassName(mainPropAttrs.ctor)); + } else "Number" !== type && cc.warnID(3606, attrName, propInfo, type); else { + if ("function" === defaultType) return; + type === cc.String && null == defaultVal ? cc.warnID(3607, propInfo) : cc.warnID(3611, attrName, propInfo, defaultType); + } + delete mainPropAttrs.type; + }; + } + function getObjTypeChecker(typeCtor) { + return function(classCtor, mainPropName) { + getTypeChecker("Object", "type")(classCtor, mainPropName); + var defaultDef = getClassAttrs(classCtor)[mainPropName + DELIMETER + "default"]; + var defaultVal = require("./CCClass").getDefault(defaultDef); + if (!Array.isArray(defaultVal) && js.isChildClassOf(typeCtor, cc.ValueType)) { + var typename = js.getClassName(typeCtor); + var info = cc.js.formatStr('No need to specify the "type" of "%s.%s" because %s is a child class of ValueType.', js.getClassName(classCtor), mainPropName, typename); + defaultDef ? cc.log(info) : cc.warnID(3612, info, typename, js.getClassName(classCtor), mainPropName, typename); + } + }; + } + module.exports = { + PrimitiveType: PrimitiveType, + attr: attr, + getClassAttrs: getClassAttrs, + setClassAttr: setClassAttr, + DELIMETER: DELIMETER, + getTypeChecker_ET: (false, false) && getTypeChecker, + getObjTypeChecker_ET: (false, false) && getObjTypeChecker, + ScriptUuid: {} + }; + }), { + "./CCClass": 240, + "./js": 261, + "./utils": 264 + } ], + 253: [ (function(require, module, exports) { + "use strict"; + var js = require("./js"); + var fastRemoveAt = js.array.fastRemoveAt; + function empty() {} + function CallbackInfo() { + this.callback = empty; + this.target = void 0; + this.once = false; + } + CallbackInfo.prototype.set = function(callback, target, once) { + this.callback = callback; + this.target = target; + this.once = !!once; + }; + var callbackInfoPool = new js.Pool(function(info) { + info.callback = empty; + info.target = void 0; + info.once = false; + return true; + }, 32); + callbackInfoPool.get = function() { + return this._get() || new CallbackInfo(); + }; + function CallbackList() { + this.callbackInfos = []; + this.isInvoking = false; + this.containCanceled = false; + } + var proto = CallbackList.prototype; + proto.removeByCallback = function(cb) { + for (var i = 0; i < this.callbackInfos.length; ++i) { + var info = this.callbackInfos[i]; + if (info && info.callback === cb) { + callbackInfoPool.put(info); + fastRemoveAt(this.callbackInfos, i); + --i; + } + } + }; + proto.removeByTarget = function(target) { + for (var i = 0; i < this.callbackInfos.length; ++i) { + var info = this.callbackInfos[i]; + if (info && info.target === target) { + callbackInfoPool.put(info); + fastRemoveAt(this.callbackInfos, i); + --i; + } + } + }; + proto.cancel = function(index) { + var info = this.callbackInfos[index]; + if (info) { + callbackInfoPool.put(info); + this.callbackInfos[index] = null; + } + this.containCanceled = true; + }; + proto.cancelAll = function() { + for (var i = 0; i < this.callbackInfos.length; i++) { + var info = this.callbackInfos[i]; + if (info) { + callbackInfoPool.put(info); + this.callbackInfos[i] = null; + } + } + this.containCanceled = true; + }; + proto.purgeCanceled = function() { + for (var i = this.callbackInfos.length - 1; i >= 0; --i) { + var info = this.callbackInfos[i]; + info || fastRemoveAt(this.callbackInfos, i); + } + this.containCanceled = false; + }; + proto.clear = function() { + this.cancelAll(); + this.callbackInfos.length = 0; + this.isInvoking = false; + this.containCanceled = false; + }; + var MAX_SIZE = 16; + var callbackListPool = new js.Pool(function(info) { + info.callbackInfos = []; + info.isInvoking = false; + info.containCanceled = false; + return true; + }, MAX_SIZE); + callbackListPool.get = function() { + return this._get() || new CallbackList(); + }; + function CallbacksInvoker() { + this._callbackTable = js.createMap(true); + } + proto = CallbacksInvoker.prototype; + proto.on = function(key, callback, target, once) { + var list = this._callbackTable[key]; + list || (list = this._callbackTable[key] = callbackListPool.get()); + var info = callbackInfoPool.get(); + info.set(callback, target, once); + list.callbackInfos.push(info); + }; + proto.hasEventListener = function(key, callback, target) { + var list = this._callbackTable[key]; + if (!list) return false; + var infos = list.callbackInfos; + if (!callback) { + if (list.isInvoking) { + for (var i = 0; i < infos.length; ++i) if (infos[i]) return true; + return false; + } + return infos.length > 0; + } + for (var _i = 0; _i < infos.length; ++_i) { + var info = infos[_i]; + if (info && info.callback === callback && info.target === target) return true; + } + return false; + }; + proto.removeAll = function(keyOrTarget) { + if ("string" === typeof keyOrTarget) { + var list = this._callbackTable[keyOrTarget]; + if (list) if (list.isInvoking) list.cancelAll(); else { + list.clear(); + callbackListPool.put(list); + delete this._callbackTable[keyOrTarget]; + } + } else if (keyOrTarget) for (var key in this._callbackTable) { + var _list = this._callbackTable[key]; + if (_list.isInvoking) { + var infos = _list.callbackInfos; + for (var i = 0; i < infos.length; ++i) { + var info = infos[i]; + info && info.target === keyOrTarget && _list.cancel(i); + } + } else _list.removeByTarget(keyOrTarget); + } + }; + proto.off = function(key, callback, target) { + var list = this._callbackTable[key]; + if (list) { + var infos = list.callbackInfos; + for (var i = 0; i < infos.length; ++i) { + var info = infos[i]; + if (info && info.callback === callback && info.target === target) { + if (list.isInvoking) list.cancel(i); else { + fastRemoveAt(infos, i); + callbackInfoPool.put(info); + } + break; + } + } + } + }; + proto.emit = function(key, arg1, arg2, arg3, arg4, arg5) { + var list = this._callbackTable[key]; + if (list) { + var rootInvoker = !list.isInvoking; + list.isInvoking = true; + var infos = list.callbackInfos; + for (var i = 0, len = infos.length; i < len; ++i) { + var info = infos[i]; + if (info) { + var target = info.target; + var callback = info.callback; + info.once && this.off(key, callback, target); + target ? callback.call(target, arg1, arg2, arg3, arg4, arg5) : callback(arg1, arg2, arg3, arg4, arg5); + } + } + if (rootInvoker) { + list.isInvoking = false; + list.containCanceled && list.purgeCanceled(); + } + } + }; + false; + module.exports = CallbacksInvoker; + }), { + "./js": 261 + } ], + 254: [ (function(require, module, exports) { + "use strict"; + function deepFlatten(strList, array) { + for (var i = 0; i < array.length; i++) { + var item = array[i]; + Array.isArray(item) ? deepFlatten(strList, item) : strList.push(item); + } + } + function flattenCodeArray(array) { + var separator = ""; + var strList = []; + deepFlatten(strList, array); + return strList.join(separator); + } + module.exports = { + flattenCodeArray: flattenCodeArray + }; + }), {} ], + 255: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = deserialize; + exports.getDependUuidList = getDependUuidList; + exports.hasNativeDep = hasNativeDep; + exports.packCustomObjData = packCustomObjData; + exports.unpackJSONs = unpackJSONs; + var _js = _interopRequireDefault(require("./js")); + var _vec = _interopRequireDefault(require("../value-types/vec2")); + var _vec2 = _interopRequireDefault(require("../value-types/vec3")); + var _vec3 = _interopRequireDefault(require("../value-types/vec4")); + var _color = _interopRequireDefault(require("../value-types/color")); + var _size = _interopRequireDefault(require("../value-types/size")); + var _rect = _interopRequireDefault(require("../value-types/rect")); + var _quat = _interopRequireDefault(require("../value-types/quat")); + var _mat = _interopRequireDefault(require("../value-types/mat4")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + var SUPPORT_MIN_FORMAT_VERSION = 1; + var EMPTY_PLACEHOLDER = 0; + var BuiltinValueTypes = [ _vec["default"], _vec2["default"], _vec3["default"], _quat["default"], _color["default"], _size["default"], _rect["default"], _mat["default"] ]; + function BuiltinValueTypeParsers_xyzw(obj, data) { + obj.x = data[1]; + obj.y = data[2]; + obj.z = data[3]; + obj.w = data[4]; + } + var BuiltinValueTypeSetters = [ function(obj, data) { + obj.x = data[1]; + obj.y = data[2]; + }, function(obj, data) { + obj.x = data[1]; + obj.y = data[2]; + obj.z = data[3]; + }, BuiltinValueTypeParsers_xyzw, BuiltinValueTypeParsers_xyzw, function(obj, data) { + obj._val = data[1]; + }, function(obj, data) { + obj.width = data[1]; + obj.height = data[2]; + }, function(obj, data) { + obj.x = data[1]; + obj.y = data[2]; + obj.width = data[3]; + obj.height = data[4]; + }, function(obj, data) { + _mat["default"].fromArray(obj, data, 1); + } ]; + function serializeBuiltinValueTypes(obj) { + var ctor = obj.constructor; + var typeId = BuiltinValueTypes.indexOf(ctor); + switch (ctor) { + case _vec["default"]: + return [ typeId, obj.x, obj.y ]; + + case _vec2["default"]: + return [ typeId, obj.x, obj.y, obj.z ]; + + case _vec3["default"]: + case _quat["default"]: + return [ typeId, obj.x, obj.y, obj.z, obj.w ]; + + case _color["default"]: + return [ typeId, obj._val ]; + + case _size["default"]: + return [ typeId, obj.width, obj.height ]; + + case _rect["default"]: + return [ typeId, obj.x, obj.y, obj.width, obj.height ]; + + case _mat["default"]: + var res = new Array(17); + res[VALUETYPE_SETTER] = typeId; + _mat["default"].toArray(res, obj, 1); + return res; + + default: + return null; + } + } + var DataTypeID = { + SimpleType: 0, + InstanceRef: 1, + Array_InstanceRef: 2, + Array_AssetRefByInnerObj: 3, + Class: 4, + ValueTypeCreated: 5, + AssetRefByInnerObj: 6, + TRS: 7, + ValueType: 8, + Array_Class: 9, + CustomizedClass: 10, + Dict: 11, + Array: 12, + ARRAY_LENGTH: 13 + }; + var CLASS_TYPE = 0; + var CLASS_KEYS = 1; + var CLASS_PROP_TYPE_OFFSET = 2; + var MASK_CLASS = 0; + var OBJ_DATA_MASK = 0; + var CUSTOM_OBJ_DATA_CLASS = 0; + var CUSTOM_OBJ_DATA_CONTENT = 1; + var VALUETYPE_SETTER = 0; + var DICT_JSON_LAYOUT = 0; + var ARRAY_ITEM_VALUES = 0; + var Refs = { + EACH_RECORD_LENGTH: 3, + OWNER_OFFSET: 0, + KEY_OFFSET: 1, + TARGET_OFFSET: 2 + }; + var File = { + Version: 0, + Context: 0, + SharedUuids: 1, + SharedStrings: 2, + SharedClasses: 3, + SharedMasks: 4, + Instances: 5, + InstanceTypes: 6, + Refs: 7, + DependObjs: 8, + DependKeys: 9, + DependUuidIndices: 10, + ARRAY_LENGTH: 11 + }; + var PACKED_SECTIONS = 5; + var Details = (function() { + function Details() { + this.uuidObjList = null; + this.uuidPropList = null; + this.uuidList = null; + } + var _proto = Details.prototype; + _proto.init = function init(data) { + this.uuidObjList = data[8]; + this.uuidPropList = data[9]; + this.uuidList = data[10]; + }; + _proto.reset = function reset() { + this.uuidList = null; + this.uuidObjList = null; + this.uuidPropList = null; + }; + _proto.push = function push(obj, propName, uuid) { + this.uuidObjList.push(obj); + this.uuidPropList.push(propName); + this.uuidList.push(uuid); + }; + return Details; + })(); + Details.pool = new _js["default"].Pool(function(obj) { + obj.reset(); + }, 5); + Details.pool.get = function() { + return this._get() || new Details(); + }; + false, false; + function dereference(refs, instances, strings) { + var dataLength = refs.length - 1; + var i = 0; + var instanceOffset = 3 * refs[dataLength]; + for (;i < instanceOffset; i += 3) { + var _owner = refs[i]; + var target = instances[refs[i + 2]]; + var keyIndex = refs[i + 1]; + keyIndex >= 0 ? _owner[strings[keyIndex]] = target : _owner[~keyIndex] = target; + } + for (;i < dataLength; i += 3) { + var _owner2 = instances[refs[i]]; + var _target = instances[refs[i + 2]]; + var _keyIndex = refs[i + 1]; + _keyIndex >= 0 ? _owner2[strings[_keyIndex]] = _target : _owner2[~_keyIndex] = _target; + } + } + function deserializeCCObject(data, objectData) { + var mask = data[4][objectData[0]]; + var clazz = mask[0]; + var ctor = clazz[0]; + var obj = new ctor(); + var keys = clazz[1]; + var classTypeOffset = clazz[2]; + var maskTypeOffset = mask[mask.length - 1]; + var i = 1; + for (;i < maskTypeOffset; ++i) { + var _key = keys[mask[i]]; + obj[_key] = objectData[i]; + } + for (;i < objectData.length; ++i) { + var _key2 = keys[mask[i]]; + var _type = clazz[mask[i] + classTypeOffset]; + var op = ASSIGNMENTS[_type]; + op(data, obj, _key2, objectData[i]); + } + return obj; + } + function deserializeCustomCCObject(data, ctor, value) { + var obj = new ctor(); + obj._deserialize ? obj._deserialize(value, data[0]) : cc.errorID(5303, _js["default"].getClassName(ctor)); + return obj; + } + function assignSimple(data, owner, key, value) { + owner[key] = value; + } + function assignInstanceRef(data, owner, key, value) { + value >= 0 ? owner[key] = data[5][value] : data[7][3 * ~value] = owner; + } + function genArrayParser(parser) { + return function(data, owner, key, value) { + owner[key] = value; + for (var i = 0; i < value.length; ++i) parser(data, value, i, value[i]); + }; + } + function parseAssetRefByInnerObj(data, owner, key, value) { + owner[key] = null; + data[8][value] = owner; + } + function parseClass(data, owner, key, value) { + owner[key] = deserializeCCObject(data, value); + } + function parseCustomClass(data, owner, key, value) { + var ctor = data[3][value[0]]; + owner[key] = deserializeCustomCCObject(data, ctor, value[1]); + } + function parseValueTypeCreated(data, owner, key, value) { + BuiltinValueTypeSetters[value[0]](owner[key], value); + } + function parseValueType(data, owner, key, value) { + var val = new BuiltinValueTypes[value[0]](); + BuiltinValueTypeSetters[value[0]](val, value); + owner[key] = val; + } + function parseTRS(data, owner, key, value) { + var typedArray = owner[key]; + typedArray.set(value); + } + function parseDict(data, owner, key, value) { + var dict = value[0]; + owner[key] = dict; + for (var i = 1; i < value.length; i += 3) { + var _key3 = value[i]; + var _type2 = value[i + 1]; + var subValue = value[i + 2]; + var op = ASSIGNMENTS[_type2]; + op(data, dict, _key3, subValue); + } + } + function parseArray(data, owner, key, value) { + var array = value[0]; + owner[key] = array; + for (var i = 0; i < array.length; ++i) { + var subValue = array[i]; + var _type3 = value[i + 1]; + if (0 !== _type3) { + var op = ASSIGNMENTS[_type3]; + op(data, array, i, subValue); + } + } + } + var ASSIGNMENTS = new Array(13); + ASSIGNMENTS[0] = assignSimple; + ASSIGNMENTS[1] = assignInstanceRef; + ASSIGNMENTS[2] = genArrayParser(assignInstanceRef); + ASSIGNMENTS[3] = genArrayParser(parseAssetRefByInnerObj); + ASSIGNMENTS[4] = parseClass; + ASSIGNMENTS[5] = parseValueTypeCreated; + ASSIGNMENTS[6] = parseAssetRefByInnerObj; + ASSIGNMENTS[7] = parseTRS; + ASSIGNMENTS[8] = parseValueType; + ASSIGNMENTS[9] = genArrayParser(parseClass); + ASSIGNMENTS[10] = parseCustomClass; + ASSIGNMENTS[11] = parseDict; + ASSIGNMENTS[12] = parseArray; + function parseInstances(data) { + var instances = data[5]; + var instanceTypes = data[6]; + var instanceTypesLen = instanceTypes === EMPTY_PLACEHOLDER ? 0 : instanceTypes.length; + var rootIndex = instances[instances.length - 1]; + var normalObjectCount = instances.length - instanceTypesLen; + if ("number" !== typeof rootIndex) rootIndex = 0; else { + rootIndex < 0 && (rootIndex = ~rootIndex); + --normalObjectCount; + } + var insIndex = 0; + for (;insIndex < normalObjectCount; ++insIndex) instances[insIndex] = deserializeCCObject(data, instances[insIndex]); + var classes = data[3]; + for (var typeIndex = 0; typeIndex < instanceTypesLen; ++typeIndex, ++insIndex) { + var _type4 = instanceTypes[typeIndex]; + var eachData = instances[insIndex]; + if (_type4 >= 0) { + var ctor = classes[_type4]; + instances[insIndex] = deserializeCustomCCObject(data, ctor, eachData); + } else { + _type4 = ~_type4; + var op = ASSIGNMENTS[_type4]; + op(data, instances, insIndex, eachData); + } + } + return rootIndex; + } + function getMissingClass(hasCustomFinder, type) { + hasCustomFinder || deserialize.reportMissingClass(type); + return Object; + } + function doLookupClass(classFinder, type, container, index, silent, hasCustomFinder) { + var klass = classFinder(type); + if (!klass) { + if (silent) { + container[index] = (function(container, index, type) { + return function proxy() { + var klass = classFinder(type) || getMissingClass(hasCustomFinder, type); + container[index] = klass; + return new klass(); + }; + })(container, index, type); + return; + } + klass = getMissingClass(hasCustomFinder, type); + } + container[index] = klass; + } + function lookupClasses(data, silent, customFinder) { + var classFinder = customFinder || _js["default"]._getClassById; + var classes = data[3]; + for (var i = 0; i < classes.length; ++i) { + var klassLayout = classes[i]; + if ("string" !== typeof klassLayout) { + true; + if ("function" === typeof klassLayout[0]) throw new Error("Can not deserialize the same JSON data again."); + var _type5 = klassLayout[0]; + doLookupClass(classFinder, _type5, klassLayout, CLASS_TYPE, silent, customFinder); + } else doLookupClass(classFinder, klassLayout, classes, i, silent, customFinder); + } + } + function cacheMasks(data) { + var masks = data[4]; + if (masks) { + var classes = data[3]; + for (var i = 0; i < masks.length; ++i) { + var mask = masks[i]; + mask[0] = classes[mask[0]]; + } + } + } + function parseResult(data) { + var instances = data[5]; + var sharedStrings = data[2]; + var dependSharedUuids = data[1]; + var dependObjs = data[8]; + var dependKeys = data[9]; + var dependUuids = data[10]; + for (var i = 0; i < dependObjs.length; ++i) { + var _obj = dependObjs[i]; + "number" === typeof _obj && (dependObjs[i] = instances[_obj]); + var _key4 = dependKeys[i]; + if ("number" === typeof _key4) { + _key4 = _key4 >= 0 ? sharedStrings[_key4] : ~_key4; + dependKeys[i] = _key4; + } + var uuid = dependUuids[i]; + "number" === typeof uuid && (dependUuids[i] = dependSharedUuids[uuid]); + } + } + function deserialize(data, details, options) { + false; + "string" === typeof data && (data = JSON.parse(data)); + var borrowDetails = !details; + details = details || Details.pool.get(); + details.init(data); + options = options || {}; + var version = data[0]; + var preprocessed = false; + if ("object" === typeof version) { + preprocessed = version.preprocessed; + version = version.version; + } + if (version < SUPPORT_MIN_FORMAT_VERSION) throw new Error(cc.debug.getError(5304, version)); + options._version = version; + options.result = details; + data[0] = options; + if (!preprocessed) { + lookupClasses(data, false, options.classFinder); + cacheMasks(data); + } + cc.game._isCloning = true; + var instances = data[5]; + var rootIndex = parseInstances(data); + cc.game._isCloning = false; + data[7] && dereference(data[7], instances, data[2]); + parseResult(data); + borrowDetails && Details.pool.put(details); + return instances[rootIndex]; + } + deserialize.Details = Details; + var FileInfo = function FileInfo(version) { + this.preprocessed = true; + this.version = version; + }; + function unpackJSONs(data, classFinder) { + if (data[0] < SUPPORT_MIN_FORMAT_VERSION) throw new Error(cc.debug.getError(5304, data[0])); + lookupClasses(data, true, classFinder); + cacheMasks(data); + var version = new FileInfo(data[0]); + var sharedUuids = data[1]; + var sharedStrings = data[2]; + var sharedClasses = data[3]; + var sharedMasks = data[4]; + var sections = data[PACKED_SECTIONS]; + for (var i = 0; i < sections.length; ++i) sections[i].unshift(version, sharedUuids, sharedStrings, sharedClasses, sharedMasks); + return sections; + } + function packCustomObjData(type, data, hasNativeDep) { + return [ SUPPORT_MIN_FORMAT_VERSION, EMPTY_PLACEHOLDER, EMPTY_PLACEHOLDER, [ type ], EMPTY_PLACEHOLDER, hasNativeDep ? [ data, -1 ] : [ data ], [ 0 ], EMPTY_PLACEHOLDER, [], [], [] ]; + } + function hasNativeDep(data) { + var instances = data[5]; + var rootInfo = instances[instances.length - 1]; + return "number" === typeof rootInfo && rootInfo < 0; + } + false; + function getDependUuidList(json) { + var sharedUuids = json[1]; + return json[10].map((function(index) { + return sharedUuids[index]; + })); + } + false, false; + false; + }), { + "../value-types/color": 339, + "../value-types/mat4": 342, + "../value-types/quat": 343, + "../value-types/rect": 344, + "../value-types/size": 345, + "../value-types/vec2": 349, + "../value-types/vec3": 350, + "../value-types/vec4": 351, + "./js": 261 + } ], + 256: [ (function(require, module, exports) { + "use strict"; + var _deserializeCompiled = _interopRequireDefault(require("./deserialize-compiled")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + _deserializeCompiled["default"].reportMissingClass = function(id) { + false; + cc.warnID(5302, id); + }; + var deserializeForEditor; + true; + cc.deserialize = _deserializeCompiled["default"]; + }), { + "./deserialize-compiled": 255, + "./deserialize-editor": void 0 + } ], + 257: [ (function(require, module, exports) { + "use strict"; + var NonUuidMark = "."; + function IdGenerater(category) { + this.id = 0 | 998 * Math.random(); + this.prefix = category ? category + NonUuidMark : ""; + } + IdGenerater.prototype.getNewId = function() { + return this.prefix + ++this.id; + }; + IdGenerater.global = new IdGenerater("global"); + module.exports = IdGenerater; + }), {} ], + 258: [ (function(require, module, exports) { + "use strict"; + require("./js"); + require("./CCClass"); + require("./CCClassDecorator"); + require("./CCEnum"); + require("./CCObject"); + require("./callbacks-invoker"); + require("./deserialize"); + require("./instantiate"); + require("./instantiate-jit"); + require("./requiring-frame"); + require("./CCSys"); + require("./CCMacro"); + true; + require("./CCVisibleRect"); + }), { + "./CCClass": 240, + "./CCClassDecorator": 241, + "./CCEnum": 242, + "./CCMacro": 245, + "./CCObject": 246, + "./CCSys": 249, + "./CCVisibleRect": 251, + "./callbacks-invoker": 253, + "./deserialize": 256, + "./instantiate": 260, + "./instantiate-jit": 259, + "./js": 261, + "./requiring-frame": 263 + } ], + 259: [ (function(require, module, exports) { + "use strict"; + var CCObject = require("./CCObject"); + var Destroyed = CCObject.Flags.Destroyed; + var PersistentMask = CCObject.Flags.PersistentMask; + var Attr = require("./attribute"); + var js = require("./js"); + var CCClass = require("./CCClass"); + var Compiler = require("./compiler"); + var DEFAULT = Attr.DELIMETER + "default"; + var IDENTIFIER_RE = CCClass.IDENTIFIER_RE; + var escapeForJS = CCClass.escapeForJS; + var VAR = "var "; + var LOCAL_OBJ = "o"; + var LOCAL_TEMP_OBJ = "t"; + var LOCAL_ARRAY = "a"; + var LINE_INDEX_OF_NEW_OBJ = 0; + var DEFAULT_MODULE_CACHE = { + "cc.Node": "cc.Node", + "cc.Sprite": "cc.Sprite", + "cc.Label": "cc.Label", + "cc.Button": "cc.Button", + "cc.Widget": "cc.Widget", + "cc.Animation": "cc.Animation", + "cc.ClickEvent": false, + "cc.PrefabInfo": false + }; + try { + !Float32Array.name && (Float32Array.name = "Float32Array"); + !Float64Array.name && (Float64Array.name = "Float64Array"); + !Int8Array.name && (Int8Array.name = "Int8Array"); + !Int16Array.name && (Int16Array.name = "Int16Array"); + !Int32Array.name && (Int32Array.name = "Int32Array"); + !Uint8Array.name && (Uint8Array.name = "Uint8Array"); + !Uint16Array.name && (Uint16Array.name = "Uint16Array"); + !Uint32Array.name && (Uint32Array.name = "Uint32Array"); + !Uint8ClampedArray.name && (Uint8ClampedArray.name = "Uint8ClampedArray"); + } catch (e) {} + function getTypedArrayName(constructor) { + if (constructor === Float32Array) return "Float32Array"; + if (constructor === Float64Array) return "Float64Array"; + if (constructor === Int8Array) return "Int8Array"; + if (constructor === Int16Array) return "Int16Array"; + if (constructor === Int32Array) return "Int32Array"; + if (constructor === Uint8Array) return "Uint8Array"; + if (constructor === Uint16Array) return "Uint16Array"; + if (constructor === Uint32Array) return "Uint32Array"; + if (constructor === Uint8ClampedArray) return "Uint8ClampedArray"; + throw new Error("Unknown TypedArray to instantiate: " + constructor); + } + function Declaration(varName, expression) { + this.varName = varName; + this.expression = expression; + } + Declaration.prototype.toString = function() { + return VAR + this.varName + "=" + this.expression + ";"; + }; + function mergeDeclaration(statement, expression) { + return expression instanceof Declaration ? new Declaration(expression.varName, statement + expression.expression) : statement + expression; + } + function writeAssignment(codeArray, statement, expression) { + if (Array.isArray(expression)) { + expression[0] = mergeDeclaration(statement, expression[0]); + codeArray.push(expression); + } else codeArray.push(mergeDeclaration(statement, expression) + ";"); + } + function Assignments(targetExpression) { + this._exps = []; + this._targetExp = targetExpression; + } + Assignments.prototype.append = function(key, expression) { + this._exps.push([ key, expression ]); + }; + Assignments.prototype.writeCode = function(codeArray) { + var targetVar; + if (this._exps.length > 1) { + codeArray.push(LOCAL_TEMP_OBJ + "=" + this._targetExp + ";"); + targetVar = LOCAL_TEMP_OBJ; + } else { + if (1 !== this._exps.length) return; + targetVar = this._targetExp; + } + for (var i = 0; i < this._exps.length; i++) { + var pair = this._exps[i]; + writeAssignment(codeArray, targetVar + getPropAccessor(pair[0]) + "=", pair[1]); + } + }; + Assignments.pool = new js.Pool(function(obj) { + obj._exps.length = 0; + obj._targetExp = null; + }, 1); + Assignments.pool.get = function(targetExpression) { + var cache = this._get() || new Assignments(); + cache._targetExp = targetExpression; + return cache; + }; + function equalsToDefault(def, value) { + if ("function" === typeof def) try { + def = def(); + } catch (e) { + return false; + } + if (def === value) return true; + if (def && value && "object" === typeof def && "object" === typeof value && def.constructor === value.constructor) if (def instanceof cc.ValueType) { + if (def.equals(value)) return true; + } else { + if (Array.isArray(def)) return 0 === def.length && 0 === value.length; + if (def.constructor === Object) return js.isEmptyObject(def) && js.isEmptyObject(value); + } + return false; + } + function getPropAccessor(key) { + return IDENTIFIER_RE.test(key) ? "." + key : "[" + escapeForJS(key) + "]"; + } + function Parser(obj, parent) { + this.parent = parent; + this.objsToClear_iN$t = []; + this.codeArray = []; + this.objs = []; + this.funcs = []; + this.funcModuleCache = js.createMap(); + js.mixin(this.funcModuleCache, DEFAULT_MODULE_CACHE); + this.globalVariables = []; + this.globalVariableId = 0; + this.localVariableId = 0; + this.codeArray.push(VAR + LOCAL_OBJ + "," + LOCAL_TEMP_OBJ + ";", "if(R){", LOCAL_OBJ + "=R;", "}else{", LOCAL_OBJ + "=R=new " + this.getFuncModule(obj.constructor, true) + "();", "}"); + js.value(obj, "_iN$t", { + globalVar: "R" + }, true); + this.objsToClear_iN$t.push(obj); + this.enumerateObject(this.codeArray, obj); + var globalVariablesDeclaration; + this.globalVariables.length > 0 && (globalVariablesDeclaration = VAR + this.globalVariables.join(",") + ";"); + var code = Compiler.flattenCodeArray([ "return (function(R){", globalVariablesDeclaration || [], this.codeArray, "return o;", "})" ]); + this.result = Function("O", "F", code)(this.objs, this.funcs); + for (var i = 0, len = this.objsToClear_iN$t.length; i < len; ++i) this.objsToClear_iN$t[i]._iN$t = null; + this.objsToClear_iN$t.length = 0; + } + var proto = Parser.prototype; + proto.getFuncModule = function(func, usedInNew) { + var clsName = js.getClassName(func); + if (clsName) { + var cache = this.funcModuleCache[clsName]; + if (cache) return cache; + if (void 0 === cache) { + var clsNameIsModule = -1 !== clsName.indexOf("."); + if (clsNameIsModule) try { + clsNameIsModule = func === Function("return " + clsName)(); + if (clsNameIsModule) { + this.funcModuleCache[clsName] = clsName; + return clsName; + } + } catch (e) {} + } + } + var index = this.funcs.indexOf(func); + if (index < 0) { + index = this.funcs.length; + this.funcs.push(func); + } + var res = "F[" + index + "]"; + usedInNew && (res = "(" + res + ")"); + this.funcModuleCache[clsName] = res; + return res; + }; + proto.getObjRef = function(obj) { + var index = this.objs.indexOf(obj); + if (index < 0) { + index = this.objs.length; + this.objs.push(obj); + } + return "O[" + index + "]"; + }; + proto.setValueType = function(codeArray, defaultValue, srcValue, targetExpression) { + var assignments = Assignments.pool.get(targetExpression); + var fastDefinedProps = defaultValue.constructor.__props__; + fastDefinedProps || (fastDefinedProps = Object.keys(defaultValue)); + for (var i = 0; i < fastDefinedProps.length; i++) { + var propName = fastDefinedProps[i]; + var prop = srcValue[propName]; + if (defaultValue[propName] === prop) continue; + var expression = this.enumerateField(srcValue, propName, prop); + assignments.append(propName, expression); + } + assignments.writeCode(codeArray); + Assignments.pool.put(assignments); + }; + proto.enumerateCCClass = function(codeArray, obj, klass) { + var props = klass.__values__; + var attrs = Attr.getClassAttrs(klass); + for (var p = 0; p < props.length; p++) { + var key = props[p]; + var val = obj[key]; + var defaultValue = attrs[key + DEFAULT]; + if (equalsToDefault(defaultValue, val)) continue; + if ("object" === typeof val && val instanceof cc.ValueType) { + defaultValue = CCClass.getDefault(defaultValue); + if (defaultValue && defaultValue.constructor === val.constructor) { + var targetExpression = LOCAL_OBJ + getPropAccessor(key); + this.setValueType(codeArray, defaultValue, val, targetExpression); + continue; + } + } + this.setObjProp(codeArray, obj, key, val); + } + }; + proto.instantiateArray = function(value) { + if (0 === value.length) return "[]"; + var arrayVar = LOCAL_ARRAY + ++this.localVariableId; + var declaration = new Declaration(arrayVar, "new Array(" + value.length + ")"); + var codeArray = [ declaration ]; + js.value(value, "_iN$t", { + globalVar: "", + source: codeArray + }, true); + this.objsToClear_iN$t.push(value); + for (var i = 0; i < value.length; ++i) { + var statement = arrayVar + "[" + i + "]="; + var expression = this.enumerateField(value, i, value[i]); + writeAssignment(codeArray, statement, expression); + } + return codeArray; + }; + proto.instantiateTypedArray = function(value) { + var type = value.constructor.name || getTypedArrayName(value.constructor); + if (0 === value.length) return "new " + type; + var arrayVar = LOCAL_ARRAY + ++this.localVariableId; + var declaration = new Declaration(arrayVar, "new " + type + "(" + value.length + ")"); + var codeArray = [ declaration ]; + value._iN$t = { + globalVar: "", + source: codeArray + }; + this.objsToClear_iN$t.push(value); + for (var i = 0; i < value.length; ++i) if (0 !== value[i]) { + var statement = arrayVar + "[" + i + "]="; + writeAssignment(codeArray, statement, value[i]); + } + return codeArray; + }; + proto.enumerateField = function(obj, key, value) { + if ("object" === typeof value && value) { + var _iN$t = value._iN$t; + if (_iN$t) { + var globalVar = _iN$t.globalVar; + if (!globalVar) { + globalVar = _iN$t.globalVar = "v" + ++this.globalVariableId; + this.globalVariables.push(globalVar); + var line = _iN$t.source[LINE_INDEX_OF_NEW_OBJ]; + _iN$t.source[LINE_INDEX_OF_NEW_OBJ] = mergeDeclaration(globalVar + "=", line); + } + return globalVar; + } + return ArrayBuffer.isView(value) ? this.instantiateTypedArray(value) : Array.isArray(value) ? this.instantiateArray(value) : this.instantiateObj(value); + } + if ("function" === typeof value) return this.getFuncModule(value); + if ("string" === typeof value) return escapeForJS(value); + "_objFlags" === key && obj instanceof CCObject && (value &= PersistentMask); + return value; + }; + proto.setObjProp = function(codeArray, obj, key, value) { + var statement = LOCAL_OBJ + getPropAccessor(key) + "="; + var expression = this.enumerateField(obj, key, value); + writeAssignment(codeArray, statement, expression); + }; + proto.enumerateObject = function(codeArray, obj) { + var klass = obj.constructor; + if (cc.Class._isCCClass(klass)) this.enumerateCCClass(codeArray, obj, klass); else for (var key in obj) { + if (!obj.hasOwnProperty(key) || 95 === key.charCodeAt(0) && 95 === key.charCodeAt(1) && "__type__" !== key) continue; + var value = obj[key]; + if ("object" === typeof value && value && value === obj._iN$t) continue; + this.setObjProp(codeArray, obj, key, value); + } + }; + proto.instantiateObj = function(obj) { + if (obj instanceof cc.ValueType) return CCClass.getNewValueTypeCode(obj); + if (obj instanceof cc.Asset) return this.getObjRef(obj); + if (obj._objFlags & Destroyed) return null; + var createCode; + var ctor = obj.constructor; + if (cc.Class._isCCClass(ctor)) { + if (this.parent) if (this.parent instanceof cc.Component) { + if (obj instanceof cc._BaseNode || obj instanceof cc.Component) return this.getObjRef(obj); + } else if (this.parent instanceof cc._BaseNode) if (obj instanceof cc._BaseNode) { + if (!obj.isChildOf(this.parent)) return this.getObjRef(obj); + } else if (obj instanceof cc.Component) { + var _obj$node; + if (!(null != (_obj$node = obj.node) && _obj$node.isChildOf(this.parent))) return this.getObjRef(obj); + } + createCode = new Declaration(LOCAL_OBJ, "new " + this.getFuncModule(ctor, true) + "()"); + } else if (ctor === Object) createCode = new Declaration(LOCAL_OBJ, "{}"); else { + if (ctor) return this.getObjRef(obj); + createCode = new Declaration(LOCAL_OBJ, "Object.create(null)"); + } + var codeArray = [ createCode ]; + js.value(obj, "_iN$t", { + globalVar: "", + source: codeArray + }, true); + this.objsToClear_iN$t.push(obj); + this.enumerateObject(codeArray, obj); + return [ "(function(){", codeArray, "return o;})();" ]; + }; + function compile(node) { + var root = node instanceof cc._BaseNode && node; + var parser = new Parser(node, root); + return parser.result; + } + module.exports = { + compile: compile, + equalsToDefault: equalsToDefault + }; + false; + }), { + "./CCClass": 240, + "./CCObject": 246, + "./attribute": 252, + "./compiler": 254, + "./js": 261 + } ], + 260: [ (function(require, module, exports) { + "use strict"; + var CCObject = require("./CCObject"); + var CCValueType = require("../value-types/value-type"); + var Destroyed = CCObject.Flags.Destroyed; + var PersistentMask = CCObject.Flags.PersistentMask; + var _isDomNode = require("./utils").isDomNode; + var js = require("./js"); + function instantiate(original, internal_force) { + if (!internal_force) { + if ("object" !== typeof original || Array.isArray(original)) { + false; + return null; + } + if (!original) { + false; + return null; + } + if (!cc.isValid(original)) { + false; + return null; + } + false; + } + var clone; + if (original instanceof CCObject) { + if (original._instantiate) { + cc.game._isCloning = true; + clone = original._instantiate(null, true); + cc.game._isCloning = false; + return clone; + } + if (original instanceof cc.Asset) { + false; + return null; + } + } + cc.game._isCloning = true; + clone = doInstantiate(original); + cc.game._isCloning = false; + return clone; + } + var objsToClearTmpVar = []; + function doInstantiate(obj, parent) { + if (Array.isArray(obj)) { + false; + return null; + } + if (_isDomNode && _isDomNode(obj)) { + false; + return null; + } + var clone; + if (obj._iN$t) clone = obj._iN$t; else if (obj.constructor) { + var klass = obj.constructor; + clone = new klass(); + } else clone = Object.create(null); + enumerateObject(obj, clone, parent); + for (var i = 0, len = objsToClearTmpVar.length; i < len; ++i) objsToClearTmpVar[i]._iN$t = null; + objsToClearTmpVar.length = 0; + return clone; + } + function enumerateCCClass(klass, obj, clone, parent) { + var props = klass.__values__; + for (var p = 0; p < props.length; p++) { + var key = props[p]; + var value = obj[key]; + if ("object" === typeof value && value) { + var initValue = clone[key]; + initValue instanceof CCValueType && initValue.constructor === value.constructor ? initValue.set(value) : clone[key] = value._iN$t || instantiateObj(value, parent); + } else clone[key] = value; + } + } + function enumerateObject(obj, clone, parent) { + js.value(obj, "_iN$t", clone, true); + objsToClearTmpVar.push(obj); + var klass = obj.constructor; + if (cc.Class._isCCClass(klass)) enumerateCCClass(klass, obj, clone, parent); else for (var key in obj) { + if (!obj.hasOwnProperty(key) || 95 === key.charCodeAt(0) && 95 === key.charCodeAt(1) && "__type__" !== key) continue; + var value = obj[key]; + if ("object" === typeof value && value) { + if (value === clone) continue; + clone[key] = value._iN$t || instantiateObj(value, parent); + } else clone[key] = value; + } + obj instanceof CCObject && (clone._objFlags &= PersistentMask); + } + function instantiateObj(obj, parent) { + if (obj instanceof CCValueType) return obj.clone(); + if (obj instanceof cc.Asset) return obj; + var clone; + if (ArrayBuffer.isView(obj)) { + var len = obj.length; + clone = new obj.constructor(len); + obj._iN$t = clone; + objsToClearTmpVar.push(obj); + for (var i = 0; i < len; ++i) clone[i] = obj[i]; + return clone; + } + if (Array.isArray(obj)) { + var _len = obj.length; + clone = new Array(_len); + js.value(obj, "_iN$t", clone, true); + objsToClearTmpVar.push(obj); + for (var _i = 0; _i < _len; ++_i) { + var value = obj[_i]; + clone[_i] = "object" === typeof value && value ? value._iN$t || instantiateObj(value, parent) : value; + } + return clone; + } + if (obj._objFlags & Destroyed) return null; + var ctor = obj.constructor; + if (cc.Class._isCCClass(ctor)) { + if (parent) if (parent instanceof cc.Component) { + if (obj instanceof cc._BaseNode || obj instanceof cc.Component) return obj; + } else if (parent instanceof cc._BaseNode) if (obj instanceof cc._BaseNode) { + if (!obj.isChildOf(parent)) return obj; + } else if (obj instanceof cc.Component) { + var _obj$node; + if (!(null != (_obj$node = obj.node) && _obj$node.isChildOf(parent))) return obj; + } + clone = new ctor(); + } else if (ctor === Object) clone = {}; else { + if (ctor) return obj; + clone = Object.create(null); + } + enumerateObject(obj, clone, parent); + return clone; + } + instantiate._clone = doInstantiate; + cc.instantiate = instantiate; + module.exports = instantiate; + }), { + "../value-types/value-type": 348, + "./CCObject": 246, + "./js": 261, + "./utils": 264 + } ], + 261: [ (function(require, module, exports) { + "use strict"; + var tempCIDGenerater = new (require("./id-generater"))("TmpCId."); + function _getPropertyDescriptor(obj, name) { + while (obj) { + var pd = Object.getOwnPropertyDescriptor(obj, name); + if (pd) return pd; + obj = Object.getPrototypeOf(obj); + } + return null; + } + function _copyprop(name, source, target) { + var pd = _getPropertyDescriptor(source, name); + Object.defineProperty(target, name, pd); + } + var js = { + isNumber: function isNumber(obj) { + return "number" === typeof obj || obj instanceof Number; + }, + isString: function isString(obj) { + return "string" === typeof obj || obj instanceof String; + }, + addon: function addon(obj) { + obj = obj || {}; + for (var i = 1, length = arguments.length; i < length; i++) { + var source = arguments[i]; + if (source) { + if ("object" !== typeof source) { + cc.errorID(5402, source); + continue; + } + for (var name in source) name in obj || _copyprop(name, source, obj); + } + } + return obj; + }, + mixin: function mixin(obj) { + obj = obj || {}; + for (var i = 1, length = arguments.length; i < length; i++) { + var source = arguments[i]; + if (source) { + if ("object" !== typeof source) { + cc.errorID(5403, source); + continue; + } + for (var name in source) _copyprop(name, source, obj); + } + } + return obj; + }, + extend: function extend(cls, base) { + false; + for (var p in base) base.hasOwnProperty(p) && (cls[p] = base[p]); + cls.prototype = Object.create(base.prototype, { + constructor: { + value: cls, + writable: true, + configurable: true + } + }); + return cls; + }, + getSuper: function getSuper(ctor) { + var proto = ctor.prototype; + var dunderProto = proto && Object.getPrototypeOf(proto); + return dunderProto && dunderProto.constructor; + }, + isChildClassOf: function isChildClassOf(subclass, superclass) { + if (subclass && superclass) { + if ("function" !== typeof subclass) return false; + if ("function" !== typeof superclass) { + false; + return false; + } + if (subclass === superclass) return true; + for (;;) { + subclass = js.getSuper(subclass); + if (!subclass) return false; + if (subclass === superclass) return true; + } + } + return false; + }, + clear: function clear(obj) { + var keys = Object.keys(obj); + for (var i = 0; i < keys.length; i++) delete obj[keys[i]]; + }, + isEmptyObject: function isEmptyObject(obj) { + for (var key in obj) return false; + return true; + }, + getPropertyDescriptor: _getPropertyDescriptor + }; + var tmpValueDesc = { + value: void 0, + enumerable: false, + writable: false, + configurable: true + }; + js.value = function(obj, prop, value, writable, enumerable) { + tmpValueDesc.value = value; + tmpValueDesc.writable = writable; + tmpValueDesc.enumerable = enumerable; + Object.defineProperty(obj, prop, tmpValueDesc); + tmpValueDesc.value = void 0; + }; + var tmpGetSetDesc = { + get: null, + set: null, + enumerable: false + }; + js.getset = function(obj, prop, getter, setter, enumerable, configurable) { + if ("function" !== typeof setter) { + enumerable = setter; + setter = void 0; + } + tmpGetSetDesc.get = getter; + tmpGetSetDesc.set = setter; + tmpGetSetDesc.enumerable = enumerable; + tmpGetSetDesc.configurable = configurable; + Object.defineProperty(obj, prop, tmpGetSetDesc); + tmpGetSetDesc.get = null; + tmpGetSetDesc.set = null; + }; + var tmpGetDesc = { + get: null, + enumerable: false, + configurable: false + }; + js.get = function(obj, prop, getter, enumerable, configurable) { + tmpGetDesc.get = getter; + tmpGetDesc.enumerable = enumerable; + tmpGetDesc.configurable = configurable; + Object.defineProperty(obj, prop, tmpGetDesc); + tmpGetDesc.get = null; + }; + var tmpSetDesc = { + set: null, + enumerable: false, + configurable: false + }; + js.set = function(obj, prop, setter, enumerable, configurable) { + tmpSetDesc.set = setter; + tmpSetDesc.enumerable = enumerable; + tmpSetDesc.configurable = configurable; + Object.defineProperty(obj, prop, tmpSetDesc); + tmpSetDesc.set = null; + }; + js.getClassName = function(objOrCtor) { + if ("function" === typeof objOrCtor) { + var prototype = objOrCtor.prototype; + if (prototype && prototype.hasOwnProperty("__classname__") && prototype.__classname__) return prototype.__classname__; + var retval = ""; + objOrCtor.name && (retval = objOrCtor.name); + if (objOrCtor.toString) { + var arr, str = objOrCtor.toString(); + arr = "[" === str.charAt(0) ? str.match(/\[\w+\s*(\w+)\]/) : str.match(/function\s*(\w+)/); + arr && 2 === arr.length && (retval = arr[1]); + } + return "Object" !== retval ? retval : ""; + } + if (objOrCtor && objOrCtor.constructor) return js.getClassName(objOrCtor.constructor); + return ""; + }; + function isTempClassId(id) { + return "string" !== typeof id || id.startsWith(tempCIDGenerater.prefix); + } + (function() { + var _idToClass = {}; + var _nameToClass = {}; + function setup(key, publicName, table) { + js.getset(js, publicName, (function() { + return Object.assign({}, table); + }), (function(value) { + js.clear(table); + Object.assign(table, value); + })); + return function(id, constructor) { + constructor.prototype.hasOwnProperty(key) && delete table[constructor.prototype[key]]; + js.value(constructor.prototype, key, id); + if (id) { + var registered = table[id]; + if (registered && registered !== constructor) { + var error = "A Class already exists with the same " + key + ' : "' + id + '".'; + false; + cc.error(error); + } else table[id] = constructor; + } + }; + } + js._setClassId = setup("__cid__", "_registeredClassIds", _idToClass); + var doSetClassName = setup("__classname__", "_registeredClassNames", _nameToClass); + js.setClassName = function(className, constructor) { + doSetClassName(className, constructor); + if (!constructor.prototype.hasOwnProperty("__cid__")) { + var id = className || tempCIDGenerater.getNewId(); + id && js._setClassId(id, constructor); + } + }; + js.unregisterClass = function() { + for (var i = 0; i < arguments.length; i++) { + var p = arguments[i].prototype; + var classId = p.__cid__; + classId && delete _idToClass[classId]; + var classname = p.__classname__; + classname && delete _nameToClass[classname]; + } + }; + js._getClassById = function(classId) { + return _idToClass[classId]; + }; + js.getClassByName = function(classname) { + return _nameToClass[classname]; + }; + js._getClassId = function(obj, allowTempId) { + allowTempId = "undefined" === typeof allowTempId || allowTempId; + var res; + if ("function" === typeof obj && obj.prototype.hasOwnProperty("__cid__")) { + res = obj.prototype.__cid__; + if (!allowTempId && (false, false) && isTempClassId(res)) return ""; + return res; + } + if (obj && obj.constructor) { + var prototype = obj.constructor.prototype; + if (prototype && prototype.hasOwnProperty("__cid__")) { + res = obj.__cid__; + if (!allowTempId && (false, false) && isTempClassId(res)) return ""; + return res; + } + } + return ""; + }; + })(); + js.obsolete = function(obj, obsoleted, newExpr, writable) { + var extractPropName = /([^.]+)$/; + var oldProp = extractPropName.exec(obsoleted)[0]; + var newProp = extractPropName.exec(newExpr)[0]; + function get() { + false; + return this[newProp]; + } + writable ? js.getset(obj, oldProp, get, (function(value) { + false; + this[newProp] = value; + })) : js.get(obj, oldProp, get); + }; + js.obsoletes = function(obj, objName, props, writable) { + for (var obsoleted in props) { + var newName = props[obsoleted]; + js.obsolete(obj, objName + "." + obsoleted, newName, writable); + } + }; + var REGEXP_NUM_OR_STR = /(%d)|(%s)/; + var REGEXP_STR = /%s/; + js.formatStr = function() { + var argLen = arguments.length; + if (0 === argLen) return ""; + var msg = arguments[0]; + if (1 === argLen) return "" + msg; + var hasSubstitution = "string" === typeof msg && REGEXP_NUM_OR_STR.test(msg); + if (hasSubstitution) for (var i = 1; i < argLen; ++i) { + var arg = arguments[i]; + var regExpToTest = "number" === typeof arg ? REGEXP_NUM_OR_STR : REGEXP_STR; + if (regExpToTest.test(msg)) { + var notReplaceFunction = "" + arg; + msg = msg.replace(regExpToTest, notReplaceFunction); + } else msg += " " + arg; + } else for (var _i = 1; _i < argLen; ++_i) msg += " " + arguments[_i]; + return msg; + }; + js.shiftArguments = function() { + var len = arguments.length - 1; + var args = new Array(len); + for (var i = 0; i < len; ++i) args[i] = arguments[i + 1]; + return args; + }; + js.createMap = function(forceDictMode) { + var map = Object.create(null); + if (forceDictMode) { + var INVALID_IDENTIFIER_1 = "."; + var INVALID_IDENTIFIER_2 = "/"; + map[INVALID_IDENTIFIER_1] = true; + map[INVALID_IDENTIFIER_2] = true; + delete map[INVALID_IDENTIFIER_1]; + delete map[INVALID_IDENTIFIER_2]; + } + return map; + }; + function removeAt(array, index) { + array.splice(index, 1); + } + function fastRemoveAt(array, index) { + var length = array.length; + if (index < 0 || index >= length) return; + array[index] = array[length - 1]; + array.length = length - 1; + } + function remove(array, value) { + var index = array.indexOf(value); + if (index >= 0) { + removeAt(array, index); + return true; + } + return false; + } + function fastRemove(array, value) { + var index = array.indexOf(value); + if (index >= 0) { + array[index] = array[array.length - 1]; + --array.length; + } + } + function verifyType(array, type) { + if (array && array.length > 0) for (var i = 0; i < array.length; i++) if (!(array[i] instanceof type)) { + cc.logID(1300); + return false; + } + return true; + } + function removeArray(array, minusArr) { + for (var i = 0, l = minusArr.length; i < l; i++) remove(array, minusArr[i]); + } + function appendObjectsAt(array, addObjs, index) { + array.splice.apply(array, [ index, 0 ].concat(addObjs)); + return array; + } + function contains(array, value) { + return array.indexOf(value) >= 0; + } + function copy(array) { + var i, len = array.length, arr_clone = new Array(len); + for (i = 0; i < len; i += 1) arr_clone[i] = array[i]; + return arr_clone; + } + js.array = { + remove: remove, + fastRemove: fastRemove, + removeAt: removeAt, + fastRemoveAt: fastRemoveAt, + contains: contains, + verifyType: verifyType, + removeArray: removeArray, + appendObjectsAt: appendObjectsAt, + copy: copy, + MutableForwardIterator: require("../utils/mutable-forward-iterator") + }; + function Pool(cleanupFunc, size) { + if (void 0 === size) { + size = cleanupFunc; + cleanupFunc = null; + } + this.get = null; + this.count = 0; + this._pool = new Array(size); + this._cleanup = cleanupFunc; + } + Pool.prototype._get = function() { + if (this.count > 0) { + --this.count; + var cache = this._pool[this.count]; + this._pool[this.count] = null; + return cache; + } + return null; + }; + Pool.prototype.put = function(obj) { + var pool = this._pool; + if (this.count < pool.length) { + if (this._cleanup && false === this._cleanup(obj)) return; + pool[this.count] = obj; + ++this.count; + } + }; + Pool.prototype.resize = function(length) { + if (length >= 0) { + this._pool.length = length; + this.count > length && (this.count = length); + } + }; + js.Pool = Pool; + cc.js = js; + module.exports = js; + }), { + "../utils/mutable-forward-iterator": 326, + "./id-generater": 257 + } ], + 262: [ (function(require, module, exports) { + "use strict"; + var js = require("./js"); + var Attrs = require("./attribute"); + var SerializableAttrs = { + default: {}, + serializable: {}, + editorOnly: {}, + formerlySerializedAs: {} + }; + var TYPO_TO_CORRECT_DEV = false; + function parseNotify(val, propName, notify, properties) { + if (val.get || val.set) { + false; + return; + } + if (val.hasOwnProperty("default")) { + var newKey = "_N$" + propName; + val.get = function() { + return this[newKey]; + }; + val.set = function(value) { + var oldValue = this[newKey]; + this[newKey] = value; + notify.call(this, oldValue); + }; + false; + var newValue = {}; + properties[newKey] = newValue; + for (var attr in SerializableAttrs) { + var v = SerializableAttrs[attr]; + if (val.hasOwnProperty(attr)) { + newValue[attr] = val[attr]; + v.canUsedInGet || delete val[attr]; + } + } + } else false; + } + function parseType(val, type, className, propName) { + var STATIC_CHECK = (false, false); + if (Array.isArray(type)) { + if (STATIC_CHECK && "default" in val) { + var isArray = require("./CCClass").isArray; + isArray(val["default"]) || cc.warnID(5507, className, propName); + } + if (!(type.length > 0)) return cc.errorID(5508, className, propName); + val.type = type = type[0]; + } + if ("function" === typeof type) { + if (type === String) { + val.type = cc.String; + STATIC_CHECK && cc.warnID(3608, '"' + className + "." + propName + '"'); + } else if (type === Boolean) { + val.type = cc.Boolean; + STATIC_CHECK && cc.warnID(3609, '"' + className + "." + propName + '"'); + } else if (type === Number) { + val.type = cc.Float; + STATIC_CHECK && cc.warnID(3610, '"' + className + "." + propName + '"'); + } + } else if (STATIC_CHECK) switch (type) { + case "Number": + cc.warnID(5510, className, propName); + break; + + case "String": + cc.warn('The type of "' + className + "." + propName + '" must be cc.String, not "String".'); + break; + + case "Boolean": + cc.warn('The type of "' + className + "." + propName + '" must be cc.Boolean, not "Boolean".'); + break; + + case "Float": + cc.warn('The type of "' + className + "." + propName + '" must be cc.Float, not "Float".'); + break; + + case "Integer": + cc.warn('The type of "' + className + "." + propName + '" must be cc.Integer, not "Integer".'); + break; + + case null: + cc.warnID(5511, className, propName); + } + false; + } + function getBaseClassWherePropertyDefined_DEV(propName, cls) { + var res; + false; + } + function _wrapOptions(isES6Getset, _default, type) { + var res = isES6Getset ? { + _short: true + } : { + _short: true, + default: _default + }; + type && (res.type = type); + return res; + } + exports.getFullFormOfProperty = function(options, isES6Getset) { + var isLiteral = options && options.constructor === Object; + if (isLiteral) return null; + return Array.isArray(options) && options.length > 0 ? _wrapOptions(isES6Getset, [], options) : "function" === typeof options ? _wrapOptions(isES6Getset, js.isChildClassOf(options, cc.ValueType) ? new options() : null, options) : options instanceof Attrs.PrimitiveType ? _wrapOptions(isES6Getset, options["default"]) : _wrapOptions(isES6Getset, options); + }; + exports.preprocessAttrs = function(properties, className, cls, es6) { + for (var propName in properties) { + var val = properties[propName]; + var fullForm = exports.getFullFormOfProperty(val, false); + fullForm && (val = properties[propName] = fullForm); + if (val) { + var maybeTypeScript; + false; + var baseClass; + false; + var notify = val.notify; + if (notify) { + false; + parseNotify(val, propName, notify, properties); + } + "type" in val && parseType(val, val.type, className, propName); + } + } + }; + var CALL_SUPER_DESTROY_REG_DEV; + false; + exports.validateMethodWithProps = function(func, funcName, className, cls, base) { + false; + if ("function" !== typeof func && null !== func) { + var overrided; + var baseFuc; + var subFuc; + var correct; + false; + return false; + } + false; + return true; + }; + }), { + "./CCClass": 240, + "./attribute": 252, + "./js": 261 + } ], + 263: [ (function(require, module, exports) { + "use strict"; + var requiringFrames = []; + cc._RF = { + push: function push(module, uuid, script) { + if (void 0 === script) { + script = uuid; + uuid = ""; + } + requiringFrames.push({ + uuid: uuid, + script: script, + module: module, + exports: module.exports, + beh: null + }); + }, + pop: function pop() { + var frameInfo = requiringFrames.pop(); + var module = frameInfo.module; + var exports = module.exports; + if (exports === frameInfo.exports) { + for (var anyKey in exports) return; + module.exports = exports = frameInfo.cls; + } + }, + peek: function peek() { + return requiringFrames[requiringFrames.length - 1]; + } + }; + false; + }), {} ], + 264: [ (function(require, module, exports) { + "use strict"; + var js = require("./js"); + module.exports = { + contains: function contains(refNode, otherNode) { + if ("function" == typeof refNode.contains) return refNode.contains(otherNode); + if ("function" == typeof refNode.compareDocumentPosition) return !!(16 & refNode.compareDocumentPosition(otherNode)); + var node = otherNode.parentNode; + if (node) do { + if (node === refNode) return true; + node = node.parentNode; + } while (null !== node); + return false; + }, + isDomNode: "object" === typeof window && ("function" === typeof Node ? function(obj) { + return obj instanceof Node; + } : function(obj) { + return obj && "object" === typeof obj && "number" === typeof obj.nodeType && "string" === typeof obj.nodeName; + }), + callInNextTick: function(callback, p1, p2) { + callback && setTimeout((function() { + callback(p1, p2); + }), 0); + } + }; + false; + false; + }), { + "./js": 261 + } ], + 265: [ (function(require, module, exports) { + "use strict"; + require("./platform/js"); + require("./value-types"); + require("./utils"); + require("./platform/CCInputManager"); + require("./platform/CCInputExtension"); + require("./event"); + require("./platform/CCSys"); + require("./platform/CCMacro"); + require("./asset-manager"); + require("./CCDirector"); + require("./renderer"); + true; + require("./platform/CCView"); + require("./platform/CCScreen"); + require("./CCScheduler"); + require("./event-manager"); + }), { + "./CCDirector": 71, + "./CCScheduler": 76, + "./asset-manager": 94, + "./event": 189, + "./event-manager": 185, + "./platform/CCInputExtension": 243, + "./platform/CCInputManager": 244, + "./platform/CCMacro": 245, + "./platform/CCScreen": 248, + "./platform/CCSys": 249, + "./platform/CCView": 250, + "./platform/js": 261, + "./renderer": 272, + "./utils": 324, + "./value-types": 340 + } ], + 266: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _assembler = _interopRequireDefault(require("./assembler")); + var _manager = _interopRequireDefault(require("./utils/dynamic-atlas/manager")); + var _renderData = _interopRequireDefault(require("./webgl/render-data")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + "value" in descriptor && (descriptor.writable = true); + Object.defineProperty(target, descriptor.key, descriptor); + } + } + function _createClass(Constructor, protoProps, staticProps) { + protoProps && _defineProperties(Constructor.prototype, protoProps); + staticProps && _defineProperties(Constructor, staticProps); + return Constructor; + } + function _assertThisInitialized(self) { + if (void 0 === self) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + return self; + } + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + _setPrototypeOf(subClass, superClass); + } + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + return _setPrototypeOf(o, p); + } + var Assembler2D = (function(_Assembler) { + _inheritsLoose(Assembler2D, _Assembler); + function Assembler2D() { + var _this; + _this = _Assembler.call(this) || this; + _this._renderData = new _renderData["default"](); + _this._renderData.init(_assertThisInitialized(_this)); + _this.initData(); + _this.initLocal(); + return _this; + } + var _proto = Assembler2D.prototype; + _proto.initData = function initData() { + var data = this._renderData; + data.createQuadData(0, this.verticesFloats, this.indicesCount); + }; + _proto.initLocal = function initLocal() { + this._local = []; + this._local.length = 4; + }; + _proto.updateColor = function updateColor(comp, color) { + var uintVerts = this._renderData.uintVDatas[0]; + if (!uintVerts) return; + color = null != color ? color : comp.node.color._val; + var floatsPerVert = this.floatsPerVert; + var colorOffset = this.colorOffset; + for (var i = colorOffset, l = uintVerts.length; i < l; i += floatsPerVert) uintVerts[i] = color; + }; + _proto.getBuffer = function getBuffer() { + return cc.renderer._handle._meshBuffer; + }; + _proto.updateWorldVerts = function updateWorldVerts(comp) { + var local = this._local; + var verts = this._renderData.vDatas[0]; + var matrix = comp.node._worldMatrix; + var matrixm = matrix.m, a = matrixm[0], b = matrixm[1], c = matrixm[4], d = matrixm[5], tx = matrixm[12], ty = matrixm[13]; + var vl = local[0], vr = local[2], vb = local[1], vt = local[3]; + var floatsPerVert = this.floatsPerVert; + var vertexOffset = 0; + var justTranslate = 1 === a && 0 === b && 0 === c && 1 === d; + if (justTranslate) { + verts[vertexOffset] = vl + tx; + verts[vertexOffset + 1] = vb + ty; + vertexOffset += floatsPerVert; + verts[vertexOffset] = vr + tx; + verts[vertexOffset + 1] = vb + ty; + vertexOffset += floatsPerVert; + verts[vertexOffset] = vl + tx; + verts[vertexOffset + 1] = vt + ty; + vertexOffset += floatsPerVert; + verts[vertexOffset] = vr + tx; + verts[vertexOffset + 1] = vt + ty; + } else { + var al = a * vl, ar = a * vr, bl = b * vl, br = b * vr, cb = c * vb, ct = c * vt, db = d * vb, dt = d * vt; + verts[vertexOffset] = al + cb + tx; + verts[vertexOffset + 1] = bl + db + ty; + vertexOffset += floatsPerVert; + verts[vertexOffset] = ar + cb + tx; + verts[vertexOffset + 1] = br + db + ty; + vertexOffset += floatsPerVert; + verts[vertexOffset] = al + ct + tx; + verts[vertexOffset + 1] = bl + dt + ty; + vertexOffset += floatsPerVert; + verts[vertexOffset] = ar + ct + tx; + verts[vertexOffset + 1] = br + dt + ty; + } + }; + _proto.fillBuffers = function fillBuffers(comp, renderer) { + renderer.worldMatDirty && this.updateWorldVerts(comp); + var renderData = this._renderData; + var vData = renderData.vDatas[0]; + var iData = renderData.iDatas[0]; + var buffer = this.getBuffer(renderer); + var offsetInfo = buffer.request(this.verticesCount, this.indicesCount); + var vertexOffset = offsetInfo.byteOffset >> 2, vbuf = buffer._vData; + vData.length + vertexOffset > vbuf.length ? vbuf.set(vData.subarray(0, vbuf.length - vertexOffset), vertexOffset) : vbuf.set(vData, vertexOffset); + var ibuf = buffer._iData, indiceOffset = offsetInfo.indiceOffset, vertexId = offsetInfo.vertexOffset; + for (var i = 0, l = iData.length; i < l; i++) ibuf[indiceOffset++] = vertexId + iData[i]; + }; + _proto.packToDynamicAtlas = function packToDynamicAtlas(comp, frame) { + false; + if (!frame._original && _manager["default"] && frame._texture.packable && frame._texture.loaded) { + var packedFrame = _manager["default"].insertSpriteFrame(frame); + packedFrame && frame._setDynamicAtlasFrame(packedFrame); + } + var material = comp._materials[0]; + if (!material) return; + if (material.getProperty("texture") !== frame._texture._texture) { + comp._vertsDirty = true; + comp._updateMaterial(); + } + }; + _createClass(Assembler2D, [ { + key: "verticesFloats", + get: function get() { + return this.verticesCount * this.floatsPerVert; + } + } ]); + return Assembler2D; + })(_assembler["default"]); + exports["default"] = Assembler2D; + cc.js.addon(Assembler2D.prototype, { + floatsPerVert: 5, + verticesCount: 4, + indicesCount: 6, + uvOffset: 2, + colorOffset: 4 + }); + cc.Assembler2D = Assembler2D; + module.exports = exports["default"]; + }), { + "./assembler": 269, + "./utils/dynamic-atlas/manager": 275, + "./webgl/render-data": 312 + } ], + 267: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _vertexFormat = require("./webgl/vertex-format"); + var _vec = _interopRequireDefault(require("../value-types/vec3")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + var vec3_temps = []; + for (var i = 0; i < 4; i++) vec3_temps.push(cc.v3()); + var Assembler3D = { + floatsPerVert: 6, + uvOffset: 3, + colorOffset: 5, + getBuffer: function getBuffer(renderer) { + return renderer._meshBuffer3D; + }, + getVfmt: function getVfmt() { + return _vertexFormat.vfmt3D; + }, + updateWorldVerts: function updateWorldVerts(comp) { + var matrix = comp.node._worldMatrix; + var local = this._local; + var world = this._renderData.vDatas[0]; + _vec["default"].set(vec3_temps[0], local[0], local[1], 0); + _vec["default"].set(vec3_temps[1], local[2], local[1], 0); + _vec["default"].set(vec3_temps[2], local[0], local[3], 0); + _vec["default"].set(vec3_temps[3], local[2], local[3], 0); + var floatsPerVert = this.floatsPerVert; + for (var _i = 0; _i < 4; _i++) { + var vertex = vec3_temps[_i]; + _vec["default"].transformMat4(vertex, vertex, matrix); + var dstOffset = floatsPerVert * _i; + world[dstOffset] = vertex.x; + world[dstOffset + 1] = vertex.y; + world[dstOffset + 2] = vertex.z; + } + } + }; + cc.Assembler3D = Assembler3D; + var _default = Assembler3D; + exports["default"] = _default; + module.exports = exports["default"]; + }), { + "../value-types/vec3": 350, + "./webgl/vertex-format": 314 + } ], + 268: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _pool3 = _interopRequireDefault(require("../utils/pool")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + _setPrototypeOf(subClass, superClass); + } + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + return _setPrototypeOf(o, p); + } + var _assemblerId = 0; + function getAssemblerId(assemblerCtor) { + Object.getOwnPropertyDescriptor(assemblerCtor, "__assemblerId__") || (assemblerCtor.__assemblerId__ = ++_assemblerId); + return assemblerCtor.__assemblerId__; + } + var AssemblerPool = (function(_Pool) { + _inheritsLoose(AssemblerPool, _Pool); + function AssemblerPool() { + var _this; + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) args[_key] = arguments[_key]; + _this = _Pool.call.apply(_Pool, [ this ].concat(args)) || this; + _this._pool = {}; + return _this; + } + var _proto = AssemblerPool.prototype; + _proto.put = function put(assembler) { + if (!assembler) return; + if (!this.enabled) { + false; + return; + } + var id = getAssemblerId(assembler.constructor); + var pool = this._pool; + pool[id] || (pool[id] = []); + if (this.count > this.maxSize) return; + this._clean(assembler); + pool[id].push(assembler); + this.count++; + }; + _proto.get = function get(assemblerCtor) { + var assembler; + if (this.enabled) { + var _pool = this._pool; + var id = getAssemblerId(assemblerCtor); + assembler = _pool[id] && _pool[id].pop(); + } + assembler ? this.count-- : assembler = new assemblerCtor(); + return assembler; + }; + _proto.clear = function clear() { + var _pool2; + var name; + var assemblers; + var i; + false; + this._pool = {}; + this.count = 0; + }; + _proto._clean = function _clean(assembler) { + false; + assembler._renderComp = null; + }; + return AssemblerPool; + })(_pool3["default"]); + var pool = new AssemblerPool(); + _pool3["default"].register("assembler", pool); + var _default = pool; + exports["default"] = _default; + module.exports = exports["default"]; + }), { + "../utils/pool": 327 + } ], + 269: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _vertexFormat = require("./webgl/vertex-format"); + var _assemblerPool = _interopRequireDefault(require("./assembler-pool")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + var Assembler = (function() { + function Assembler() { + this._extendNative && this._extendNative(); + } + var _proto = Assembler.prototype; + _proto.init = function init(renderComp) { + this._renderComp = renderComp; + }; + _proto.updateRenderData = function updateRenderData(comp) {}; + _proto.fillBuffers = function fillBuffers(comp, renderer) {}; + _proto.getVfmt = function getVfmt() { + return _vertexFormat.vfmtPosUvColor; + }; + return Assembler; + })(); + exports["default"] = Assembler; + Assembler.register = function(renderCompCtor, assembler) { + renderCompCtor.__assembler__ = assembler; + }; + Assembler.init = function(renderComp) { + var renderCompCtor = renderComp.constructor; + var assemblerCtor = renderCompCtor.__assembler__; + while (!assemblerCtor) { + renderCompCtor = renderCompCtor.$super; + if (!renderCompCtor) { + cc.warn("Can not find assembler for render component : [" + cc.js.getClassName(renderComp) + "]"); + return; + } + assemblerCtor = renderCompCtor.__assembler__; + } + assemblerCtor.getConstructor && (assemblerCtor = assemblerCtor.getConstructor(renderComp)); + if (!renderComp._assembler || renderComp._assembler.constructor !== assemblerCtor) { + var assembler = _assemblerPool["default"].get(assemblerCtor); + assembler.init(renderComp); + renderComp._assembler = assembler; + } + }; + cc.Assembler = Assembler; + module.exports = exports["default"]; + }), { + "./assembler-pool": 268, + "./webgl/vertex-format": 314 + } ], + 270: [ (function(require, module, exports) { + "use strict"; + var Device = function Device(canvasEL) { + var ctx; + try { + ctx = canvasEL.getContext("2d"); + } catch (err) { + console.error(err); + return; + } + this._canvas = canvasEL; + this._ctx = ctx; + this._caps = {}; + this._stats = { + drawcalls: 0 + }; + this._vx = this._vy = this._vw = this._vh = 0; + this._sx = this._sy = this._sw = this._sh = 0; + }; + Device.prototype._restoreTexture = function _restoreTexture(unit) {}; + Device.prototype.setViewport = function setViewport(x, y, w, h) { + if (this._vx !== x || this._vy !== y || this._vw !== w || this._vh !== h) { + this._vx = x; + this._vy = y; + this._vw = w; + this._vh = h; + } + }; + Device.prototype.setScissor = function setScissor(x, y, w, h) { + if (this._sx !== x || this._sy !== y || this._sw !== w || this._sh !== h) { + this._sx = x; + this._sy = y; + this._sw = w; + this._sh = h; + } + }; + Device.prototype.clear = function clear(color) { + var ctx = this._ctx; + ctx.clearRect(this._vx, this._vy, this._vw, this._vh); + if (color && (0 !== color[0] || 0 !== color[1] || 0 !== color[2])) { + ctx.fillStyle = "rgb(" + color[0] + "," + color[1] + "," + color[2] + ")"; + ctx.globalAlpha = color[3]; + ctx.fillRect(this._vx, this._vy, this._vw, this._vh); + } + }; + Device.prototype.resetDrawCalls = function() { + this._stats.drawcalls = 0; + }; + Device.prototype.getDrawCalls = function() { + return this._stats.drawcalls; + }; + module.exports = Device; + }), {} ], + 271: [ (function(require, module, exports) { + "use strict"; + var Texture2D = function Texture2D(device, options) { + this._device = device; + this._width = 4; + this._height = 4; + this._image = null; + if (options) { + void 0 !== options.width && (this._width = options.width); + void 0 !== options.height && (this._height = options.height); + this.updateImage(options); + } + }; + Texture2D.prototype.update = function update(options) { + this.updateImage(options); + }; + Texture2D.prototype.updateImage = function updateImage(options) { + if (options.images && options.images[0]) { + var image = options.images[0]; + image && image !== this._image && (this._image = image); + } + }; + Texture2D.prototype.destroy = function destroy() { + this._image = null; + }; + module.exports = Texture2D; + }), {} ], + 272: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _gfx = _interopRequireDefault(require("../../renderer/gfx")); + var _inputAssembler = _interopRequireDefault(require("../../renderer/core/input-assembler")); + var _pass = _interopRequireDefault(require("../../renderer/core/pass")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _initBuiltins(device) { + var defaultTexture = new _gfx["default"].Texture2D(device, { + images: [], + width: 128, + height: 128, + wrapS: _gfx["default"].WRAP_REPEAT, + wrapT: _gfx["default"].WRAP_REPEAT, + format: _gfx["default"].TEXTURE_FMT_RGB8, + genMipmaps: false + }); + return { + defaultTexture: defaultTexture, + programTemplates: [], + programChunks: {} + }; + } + var _default = cc.renderer = { + Texture2D: null, + InputAssembler: _inputAssembler["default"], + Pass: _pass["default"], + renderEngine: null, + canvas: null, + device: null, + scene: null, + drawCalls: 0, + _handle: null, + _cameraNode: null, + _camera: null, + _forward: null, + _flow: null, + initWebGL: function initWebGL(canvas, opts) { + require("./webgl/assemblers"); + var ModelBatcher = require("./webgl/model-batcher"); + this.Texture2D = _gfx["default"].Texture2D; + this.canvas = canvas; + this._flow = cc.RenderFlow; + var builtins; + var nativeFlow; + false; + var Scene = require("../../renderer/scene/scene"); + var ForwardRenderer = require("../../renderer/renderers/forward-renderer"); + this.device = new _gfx["default"].Device(canvas, opts); + this.scene = new Scene(); + var _builtins = _initBuiltins(this.device); + this._forward = new ForwardRenderer(this.device, _builtins); + this._handle = new ModelBatcher(this.device, this.scene); + this._flow.init(this._handle, this._forward); + }, + initCanvas: function initCanvas(canvas) { + var canvasRenderer = require("./canvas"); + var Texture2D = require("./canvas/Texture2D"); + var Device = require("./canvas/Device"); + this.Device = Device; + this.Texture2D = Texture2D; + this.canvas = canvas; + this.device = new Device(canvas); + this._camera = { + a: 1, + b: 0, + c: 0, + d: 1, + tx: 0, + ty: 0 + }; + this._handle = new canvasRenderer.RenderComponentHandle(this.device, this._camera); + this._forward = new canvasRenderer.ForwardRenderer(); + this._flow = cc.RenderFlow; + this._flow.init(this._handle, this._forward); + }, + updateCameraViewport: function updateCameraViewport() { + if (true, cc.director) { + var ecScene = cc.director.getScene(); + ecScene && ecScene.setScale(1, 1, 1); + } + if (cc.game.renderType === cc.game.RENDER_TYPE_CANVAS) { + var vp = cc.view.getViewportRect(); + this.device.setViewport(vp.x, vp.y, vp.width, vp.height); + this._camera.a = cc.view.getScaleX(); + this._camera.d = cc.view.getScaleY(); + this._camera.tx = vp.x; + this._camera.ty = vp.y + vp.height; + } + }, + render: function render(ecScene, dt) { + this.device.resetDrawCalls(); + if (ecScene) { + this._flow.render(ecScene, dt); + this.drawCalls = this.device.getDrawCalls(); + } + }, + clear: function clear() { + this._handle.reset(); + this._forward.clear(); + } + }; + exports["default"] = _default; + module.exports = exports["default"]; + }), { + "../../renderer/core/input-assembler": 363, + "../../renderer/core/pass": 364, + "../../renderer/gfx": 373, + "../../renderer/renderers/forward-renderer": 392, + "../../renderer/scene/scene": 396, + "./canvas": void 0, + "./canvas/Device": 270, + "./canvas/Texture2D": 271, + "./webgl/assemblers": 284, + "./webgl/model-batcher": 310 + } ], + 273: [ (function(require, module, exports) { + "use strict"; + var FlagOfset = 0; + var DONOTHING = 1 << FlagOfset++; + var BREAK_FLOW = 1 << FlagOfset++; + var LOCAL_TRANSFORM = 1 << FlagOfset++; + var WORLD_TRANSFORM = 1 << FlagOfset++; + var TRANSFORM = LOCAL_TRANSFORM | WORLD_TRANSFORM; + var UPDATE_RENDER_DATA = 1 << FlagOfset++; + var OPACITY = 1 << FlagOfset++; + var COLOR = 1 << FlagOfset++; + var OPACITY_COLOR = OPACITY | COLOR; + var RENDER = 1 << FlagOfset++; + var CHILDREN = 1 << FlagOfset++; + var POST_RENDER = 1 << FlagOfset++; + var FINAL = 1 << FlagOfset++; + var _batcher, _forward; + var _cullingMask = 0; + function RenderFlow() { + this._func = init; + this._next = null; + } + var _proto = RenderFlow.prototype; + _proto._doNothing = function() {}; + _proto._localTransform = function(node) { + node._updateLocalMatrix(); + node._renderFlag &= ~LOCAL_TRANSFORM; + this._next._func(node); + }; + _proto._worldTransform = function(node) { + _batcher.worldMatDirty++; + var t = node._matrix; + var trs = node._trs; + var tm = t.m; + tm[12] = trs[0]; + tm[13] = trs[1]; + tm[14] = trs[2]; + node._mulMat(node._worldMatrix, node._parent._worldMatrix, t); + node._renderFlag &= ~WORLD_TRANSFORM; + this._next._func(node); + _batcher.worldMatDirty--; + }; + _proto._updateRenderData = function(node) { + var comp = node._renderComponent; + comp._assembler.updateRenderData(comp); + node._renderFlag &= ~UPDATE_RENDER_DATA; + this._next._func(node); + }; + _proto._opacity = function(node) { + _batcher.parentOpacityDirty++; + this._next._func(node); + node._renderFlag &= ~OPACITY; + _batcher.parentOpacityDirty--; + }; + _proto._color = function(node) { + var comp = node._renderComponent; + comp && comp._updateColor(); + node._renderFlag &= ~COLOR; + this._next._func(node); + }; + _proto._render = function(node) { + var comp = node._renderComponent; + comp._checkBacth(_batcher, node._cullingMask); + comp._assembler.fillBuffers(comp, _batcher); + this._next._func(node); + }; + _proto._children = function(node) { + var cullingMask = _cullingMask; + var batcher = _batcher; + var parentOpacity = batcher.parentOpacity; + var opacity = batcher.parentOpacity *= node._opacity / 255; + var worldTransformFlag = batcher.worldMatDirty ? WORLD_TRANSFORM : 0; + var worldOpacityFlag = batcher.parentOpacityDirty ? OPACITY_COLOR : 0; + var worldDirtyFlag = worldTransformFlag | worldOpacityFlag; + var children = node._children; + for (var i = 0, l = children.length; i < l; i++) { + var c = children[i]; + c._renderFlag |= worldDirtyFlag; + if (!c._activeInHierarchy || 0 === c._opacity) continue; + _cullingMask = c._cullingMask = 0 === c.groupIndex ? cullingMask : 1 << c.groupIndex; + var colorVal = c._color._val; + c._color._fastSetA(c._opacity * opacity); + flows[c._renderFlag]._func(c); + c._color._val = colorVal; + } + batcher.parentOpacity = parentOpacity; + this._next._func(node); + }; + _proto._postRender = function(node) { + var comp = node._renderComponent; + comp._checkBacth(_batcher, node._cullingMask); + comp._assembler.postFillBuffers(comp, _batcher); + this._next._func(node); + }; + var EMPTY_FLOW = new RenderFlow(); + EMPTY_FLOW._func = EMPTY_FLOW._doNothing; + EMPTY_FLOW._next = EMPTY_FLOW; + var flows = {}; + function createFlow(flag, next) { + if (flag === DONOTHING || flag === BREAK_FLOW) return EMPTY_FLOW; + var flow = new RenderFlow(); + flow._next = next || EMPTY_FLOW; + switch (flag) { + case LOCAL_TRANSFORM: + flow._func = flow._localTransform; + break; + + case WORLD_TRANSFORM: + flow._func = flow._worldTransform; + break; + + case UPDATE_RENDER_DATA: + flow._func = flow._updateRenderData; + break; + + case OPACITY: + flow._func = flow._opacity; + break; + + case COLOR: + flow._func = flow._color; + break; + + case RENDER: + flow._func = flow._render; + break; + + case CHILDREN: + flow._func = flow._children; + break; + + case POST_RENDER: + flow._func = flow._postRender; + } + return flow; + } + function getFlow(flag) { + var flow = null; + var tFlag = FINAL; + while (tFlag > 0) { + tFlag & flag && (flow = createFlow(tFlag, flow)); + tFlag >>= 1; + } + return flow; + } + function init(node) { + var flag = node._renderFlag; + var r = flows[flag] = getFlow(flag); + r._func(node); + } + RenderFlow.flows = flows; + RenderFlow.createFlow = createFlow; + var _validateList = []; + RenderFlow.registerValidate = function(renderComp) { + if (renderComp._inValidateList) return; + _validateList.push(renderComp); + renderComp._inValidateList = true; + }; + RenderFlow.validateRenderers = function() { + for (var i = 0, l = _validateList.length; i < l; i++) { + var renderComp = _validateList[i]; + if (!renderComp.isValid) continue; + renderComp.enabledInHierarchy ? renderComp._validateRender() : renderComp.disableRender(); + renderComp._inValidateList = false; + } + _validateList.length = 0; + }; + RenderFlow.visitRootNode = function(rootNode) { + RenderFlow.validateRenderers(); + var preCullingMask = _cullingMask; + _cullingMask = rootNode._cullingMask; + if (rootNode._renderFlag & WORLD_TRANSFORM) { + _batcher.worldMatDirty++; + rootNode._calculWorldMatrix(); + rootNode._renderFlag &= ~WORLD_TRANSFORM; + flows[rootNode._renderFlag]._func(rootNode); + _batcher.worldMatDirty--; + } else flows[rootNode._renderFlag]._func(rootNode); + _cullingMask = preCullingMask; + }; + RenderFlow.render = function(rootNode, dt) { + _batcher.reset(); + _batcher.walking = true; + RenderFlow.visitRootNode(rootNode); + _batcher.terminate(); + _batcher.walking = false; + _forward.render(_batcher._renderScene, dt); + }; + RenderFlow.renderCamera = function(camera, rootNode) { + _batcher.reset(); + _batcher.walking = true; + RenderFlow.visitRootNode(rootNode); + _batcher.terminate(); + _batcher.walking = false; + _forward.renderCamera(camera, _batcher._renderScene); + }; + RenderFlow.init = function(batcher, forwardRenderer) { + _batcher = batcher; + _forward = forwardRenderer; + flows[0] = EMPTY_FLOW; + for (var i = 1; i < FINAL; i++) flows[i] = new RenderFlow(); + }; + RenderFlow.getBachther = function() { + return _batcher; + }; + RenderFlow.FLAG_DONOTHING = DONOTHING; + RenderFlow.FLAG_BREAK_FLOW = BREAK_FLOW; + RenderFlow.FLAG_LOCAL_TRANSFORM = LOCAL_TRANSFORM; + RenderFlow.FLAG_WORLD_TRANSFORM = WORLD_TRANSFORM; + RenderFlow.FLAG_TRANSFORM = TRANSFORM; + RenderFlow.FLAG_UPDATE_RENDER_DATA = UPDATE_RENDER_DATA; + RenderFlow.FLAG_OPACITY = OPACITY; + RenderFlow.FLAG_COLOR = COLOR; + RenderFlow.FLAG_OPACITY_COLOR = OPACITY_COLOR; + RenderFlow.FLAG_RENDER = RENDER; + RenderFlow.FLAG_CHILDREN = CHILDREN; + RenderFlow.FLAG_POST_RENDER = POST_RENDER; + RenderFlow.FLAG_FINAL = FINAL; + module.exports = cc.RenderFlow = RenderFlow; + }), {} ], + 274: [ (function(require, module, exports) { + "use strict"; + var RenderTexture = require("../../../assets/CCRenderTexture"); + var space = 2; + function Atlas(width, height) { + var texture = new RenderTexture(); + texture.initWithSize(width, height); + texture.update(); + this._texture = texture; + this._x = space; + this._y = space; + this._nexty = space; + this._width = width; + this._height = height; + this._innerTextureInfos = {}; + this._innerSpriteFrames = []; + this._count = 0; + } + Atlas.DEFAULT_HASH = new RenderTexture()._getHash(); + cc.js.mixin(Atlas.prototype, { + insertSpriteFrame: function insertSpriteFrame(spriteFrame) { + var rect = spriteFrame._rect, texture = spriteFrame._texture, info = this._innerTextureInfos[texture._id]; + var sx = rect.x, sy = rect.y; + if (info) { + sx += info.x; + sy += info.y; + } else { + var width = texture.width, height = texture.height; + if (this._x + width + space > this._width) { + this._x = space; + this._y = this._nexty; + } + this._y + height + space > this._nexty && (this._nexty = this._y + height + space); + if (this._nexty > this._height) return null; + if (cc.dynamicAtlasManager.textureBleeding) { + if (width <= 8 || height <= 8) { + this._texture.drawTextureAt(texture, this._x - 1, this._y - 1); + this._texture.drawTextureAt(texture, this._x - 1, this._y + 1); + this._texture.drawTextureAt(texture, this._x + 1, this._y - 1); + this._texture.drawTextureAt(texture, this._x + 1, this._y + 1); + } + this._texture.drawTextureAt(texture, this._x - 1, this._y); + this._texture.drawTextureAt(texture, this._x + 1, this._y); + this._texture.drawTextureAt(texture, this._x, this._y - 1); + this._texture.drawTextureAt(texture, this._x, this._y + 1); + } + this._texture.drawTextureAt(texture, this._x, this._y); + this._innerTextureInfos[texture._id] = { + x: this._x, + y: this._y, + texture: texture + }; + this._count++; + sx += this._x; + sy += this._y; + this._x += width + space; + this._dirty = true; + } + var frame = { + x: sx, + y: sy, + texture: this._texture + }; + this._innerSpriteFrames.push(spriteFrame); + return frame; + }, + update: function update() { + if (!this._dirty) return; + this._texture.update(); + this._dirty = false; + }, + deleteInnerTexture: function deleteInnerTexture(texture) { + if (texture && this._innerTextureInfos[texture._id]) { + delete this._innerTextureInfos[texture._id]; + this._count--; + } + }, + isEmpty: function isEmpty() { + return this._count <= 0; + }, + reset: function reset() { + this._x = space; + this._y = space; + this._nexty = space; + var frames = this._innerSpriteFrames; + for (var i = 0, l = frames.length; i < l; i++) { + var frame = frames[i]; + if (!frame.isValid) continue; + frame._resetDynamicAtlasFrame(); + } + this._innerSpriteFrames.length = 0; + this._innerTextureInfos = {}; + }, + destroy: function destroy() { + this.reset(); + this._texture.destroy(); + } + }); + module.exports = Atlas; + }), { + "../../../assets/CCRenderTexture": 114 + } ], + 275: [ (function(require, module, exports) { + "use strict"; + var Atlas = require("./atlas"); + var _atlases = []; + var _atlasIndex = -1; + var _maxAtlasCount = 5; + var _textureSize = 2048; + var _maxFrameSize = 512; + var _textureBleeding = true; + var _debugNode = null; + function newAtlas() { + var atlas = _atlases[++_atlasIndex]; + if (!atlas) { + atlas = new Atlas(_textureSize, _textureSize); + _atlases.push(atlas); + } + return atlas; + } + function beforeSceneLoad() { + dynamicAtlasManager.reset(); + } + var _enabled = false; + var dynamicAtlasManager = { + Atlas: Atlas, + get enabled() { + return _enabled; + }, + set enabled(value) { + if (_enabled === value) return; + if (value) { + this.reset(); + cc.director.on(cc.Director.EVENT_BEFORE_SCENE_LAUNCH, beforeSceneLoad); + } else cc.director.off(cc.Director.EVENT_BEFORE_SCENE_LAUNCH, beforeSceneLoad); + _enabled = value; + }, + get maxAtlasCount() { + return _maxAtlasCount; + }, + set maxAtlasCount(value) { + _maxAtlasCount = value; + }, + get atlasCount() { + return _atlases.length; + }, + get textureBleeding() { + return _textureBleeding; + }, + set textureBleeding(enable) { + _textureBleeding = enable; + }, + get textureSize() { + return _textureSize; + }, + set textureSize(value) { + _textureSize = value; + }, + get maxFrameSize() { + return _maxFrameSize; + }, + set maxFrameSize(value) { + _maxFrameSize = value; + }, + insertSpriteFrame: function insertSpriteFrame(spriteFrame) { + false; + if (!_enabled || _atlasIndex === _maxAtlasCount || !spriteFrame || spriteFrame._original) return null; + if (!spriteFrame._texture.packable) return null; + var atlas = _atlases[_atlasIndex]; + atlas || (atlas = newAtlas()); + var frame = atlas.insertSpriteFrame(spriteFrame); + if (!frame && _atlasIndex !== _maxAtlasCount) { + atlas = newAtlas(); + return atlas.insertSpriteFrame(spriteFrame); + } + return frame; + }, + reset: function reset() { + for (var i = 0, l = _atlases.length; i < l; i++) _atlases[i].destroy(); + _atlases.length = 0; + _atlasIndex = -1; + }, + deleteAtlasSpriteFrame: function deleteAtlasSpriteFrame(spriteFrame) { + if (!spriteFrame._original) return; + var texture = spriteFrame._original._texture; + this.deleteAtlasTexture(texture); + }, + deleteAtlasTexture: function deleteAtlasTexture(texture) { + if (texture) for (var i = _atlases.length - 1; i >= 0; i--) { + _atlases[i].deleteInnerTexture(texture); + if (_atlases[i].isEmpty()) { + _atlases[i].destroy(); + _atlases.splice(i, 1); + _atlasIndex--; + } + } + }, + showDebug: function showDebug(show) { + if (show) { + if (!_debugNode || !_debugNode.isValid) { + var width = cc.visibleRect.width; + var height = cc.visibleRect.height; + _debugNode = new cc.Node("DYNAMIC_ATLAS_DEBUG_NODE"); + _debugNode.width = width; + _debugNode.height = height; + _debugNode.x = width / 2; + _debugNode.y = height / 2; + _debugNode.zIndex = cc.macro.MAX_ZINDEX; + _debugNode.parent = cc.director.getScene(); + _debugNode.groupIndex = cc.Node.BuiltinGroupIndex.DEBUG; + cc.Camera._setupDebugCamera(); + var scroll = _debugNode.addComponent(cc.ScrollView); + var content = new cc.Node("CONTENT"); + var layout = content.addComponent(cc.Layout); + layout.type = cc.Layout.Type.VERTICAL; + layout.resizeMode = cc.Layout.ResizeMode.CONTAINER; + content.parent = _debugNode; + content.width = _textureSize; + content.anchorY = 1; + content.x = _textureSize; + scroll.content = content; + for (var i = 0; i <= _atlasIndex; i++) { + var node = new cc.Node("ATLAS"); + var texture = _atlases[i]._texture; + var spriteFrame = new cc.SpriteFrame(); + spriteFrame.setTexture(_atlases[i]._texture); + var sprite = node.addComponent(cc.Sprite); + sprite.spriteFrame = spriteFrame; + node.parent = content; + } + } + return _debugNode; + } + if (_debugNode) { + _debugNode.parent = null; + _debugNode = null; + } + }, + update: function update() { + if (!this.enabled) return; + for (var i = 0; i <= _atlasIndex; i++) _atlases[i].update(); + } + }; + module.exports = cc.dynamicAtlasManager = dynamicAtlasManager; + }), { + "./atlas": 274 + } ], + 276: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _assembler2d = _interopRequireDefault(require("../../assembler-2d")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + _setPrototypeOf(subClass, superClass); + } + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + return _setPrototypeOf(o, p); + } + var textUtils = require("../../../utils/text-utils"); + var macro = require("../../../platform/CCMacro"); + var Label = require("../../../components/CCLabel"); + var Overflow = Label.Overflow; + var shareLabelInfo = require("../utils").shareLabelInfo; + var LetterInfo = function LetterInfo() { + this["char"] = ""; + this.valid = true; + this.x = 0; + this.y = 0; + this.line = 0; + this.hash = ""; + }; + var _tmpRect = cc.rect(); + var _comp = null; + var _horizontalKernings = []; + var _lettersInfo = []; + var _linesWidth = []; + var _linesOffsetX = []; + var _fntConfig = null; + var _numberOfLines = 0; + var _textDesiredHeight = 0; + var _letterOffsetY = 0; + var _tailoredTopY = 0; + var _tailoredBottomY = 0; + var _bmfontScale = 1; + var _lineBreakWithoutSpaces = false; + var _spriteFrame = null; + var _lineSpacing = 0; + var _contentSize = cc.size(); + var _string = ""; + var _fontSize = 0; + var _originFontSize = 0; + var _hAlign = 0; + var _vAlign = 0; + var _spacingX = 0; + var _lineHeight = 0; + var _overflow = 0; + var _isWrapText = false; + var _labelWidth = 0; + var _labelHeight = 0; + var _maxLineWidth = 0; + var BmfontAssembler = (function(_Assembler2D) { + _inheritsLoose(BmfontAssembler, _Assembler2D); + function BmfontAssembler() { + return _Assembler2D.apply(this, arguments) || this; + } + var _proto = BmfontAssembler.prototype; + _proto.updateRenderData = function updateRenderData(comp) { + if (!comp._vertsDirty) return; + if (_comp === comp) return; + _comp = comp; + this._reserveQuads(comp, comp.string.toString().length); + this._updateFontFamily(comp); + this._updateProperties(comp); + this._updateLabelInfo(comp); + this._updateContent(); + this.updateWorldVerts(comp); + _comp._actualFontSize = _fontSize; + _comp.node.setContentSize(_contentSize); + _comp._vertsDirty = false; + _comp = null; + this._resetProperties(); + }; + _proto._updateFontScale = function _updateFontScale() { + _bmfontScale = _fontSize / _originFontSize; + }; + _proto._updateFontFamily = function _updateFontFamily(comp) { + var fontAsset = comp.font; + _spriteFrame = fontAsset.spriteFrame; + _fntConfig = fontAsset._fntConfig; + shareLabelInfo.fontAtlas = fontAsset._fontDefDictionary; + this.packToDynamicAtlas(comp, _spriteFrame); + }; + _proto._updateLabelInfo = function _updateLabelInfo() { + shareLabelInfo.hash = ""; + shareLabelInfo.margin = 0; + }; + _proto._updateProperties = function _updateProperties(comp) { + _string = comp.string.toString(); + _fontSize = comp.fontSize; + _originFontSize = _fntConfig ? _fntConfig.fontSize : comp.fontSize; + _hAlign = comp.horizontalAlign; + _vAlign = comp.verticalAlign; + _spacingX = comp.spacingX; + _overflow = comp.overflow; + _lineHeight = comp._lineHeight; + _contentSize.width = comp.node.width; + _contentSize.height = comp.node.height; + if (_overflow === Overflow.NONE) { + _isWrapText = false; + _contentSize.width += 2 * shareLabelInfo.margin; + _contentSize.height += 2 * shareLabelInfo.margin; + } else if (_overflow === Overflow.RESIZE_HEIGHT) { + _isWrapText = true; + _contentSize.height += 2 * shareLabelInfo.margin; + } else _isWrapText = comp.enableWrapText; + shareLabelInfo.lineHeight = _lineHeight; + shareLabelInfo.fontSize = _fontSize; + this._setupBMFontOverflowMetrics(); + }; + _proto._resetProperties = function _resetProperties() { + _fntConfig = null; + _spriteFrame = null; + shareLabelInfo.hash = ""; + shareLabelInfo.margin = 0; + }; + _proto._updateContent = function _updateContent() { + this._updateFontScale(); + this._computeHorizontalKerningForText(); + this._alignText(); + }; + _proto._computeHorizontalKerningForText = function _computeHorizontalKerningForText() { + var string = _string; + var stringLen = string.length; + var horizontalKernings = _horizontalKernings; + var kerningDict; + _fntConfig && (kerningDict = _fntConfig.kerningDict); + if (kerningDict && !cc.js.isEmptyObject(kerningDict)) { + var prev = -1; + for (var i = 0; i < stringLen; ++i) { + var key = string.charCodeAt(i); + var kerningAmount = kerningDict[prev << 16 | 65535 & key] || 0; + horizontalKernings[i] = i < stringLen - 1 ? kerningAmount : 0; + prev = key; + } + } else horizontalKernings.length = 0; + }; + _proto._multilineTextWrap = function _multilineTextWrap(nextTokenFunc) { + var textLen = _string.length; + var lineIndex = 0; + var nextTokenX = 0; + var nextTokenY = 0; + var longestLine = 0; + var letterRight = 0; + var highestY = 0; + var lowestY = 0; + var letterDef = null; + var letterPosition = cc.v2(0, 0); + for (var index = 0; index < textLen; ) { + var character = _string.charAt(index); + if ("\n" === character) { + _linesWidth.push(letterRight); + letterRight = 0; + lineIndex++; + nextTokenX = 0; + nextTokenY -= _lineHeight * this._getFontScale() + _lineSpacing; + this._recordPlaceholderInfo(index, character); + index++; + continue; + } + var tokenLen = nextTokenFunc(_string, index, textLen); + var tokenHighestY = highestY; + var tokenLowestY = lowestY; + var tokenRight = letterRight; + var nextLetterX = nextTokenX; + var newLine = false; + for (var tmp = 0; tmp < tokenLen; ++tmp) { + var letterIndex = index + tmp; + character = _string.charAt(letterIndex); + if ("\r" === character) { + this._recordPlaceholderInfo(letterIndex, character); + continue; + } + letterDef = shareLabelInfo.fontAtlas.getLetterDefinitionForChar(character, shareLabelInfo); + if (!letterDef) { + this._recordPlaceholderInfo(letterIndex, character); + var atlasName = ""; + _fntConfig && (atlasName = _fntConfig.atlasName); + console.log("Can't find letter definition in texture atlas " + atlasName + " for letter:" + character); + continue; + } + var letterX = nextLetterX + letterDef.offsetX * _bmfontScale - shareLabelInfo.margin; + if (_isWrapText && _maxLineWidth > 0 && nextTokenX > 0 && letterX + letterDef.w * _bmfontScale > _maxLineWidth && !textUtils.isUnicodeSpace(character)) { + _linesWidth.push(letterRight); + letterRight = 0; + lineIndex++; + nextTokenX = 0; + nextTokenY -= _lineHeight * this._getFontScale() + _lineSpacing; + newLine = true; + break; + } + letterPosition.x = letterX; + letterPosition.y = nextTokenY - letterDef.offsetY * _bmfontScale + shareLabelInfo.margin; + this._recordLetterInfo(letterPosition, character, letterIndex, lineIndex); + letterIndex + 1 < _horizontalKernings.length && letterIndex < textLen - 1 && (nextLetterX += _horizontalKernings[letterIndex + 1]); + nextLetterX += letterDef.xAdvance * _bmfontScale + _spacingX - 2 * shareLabelInfo.margin; + tokenRight = letterPosition.x + letterDef.w * _bmfontScale - shareLabelInfo.margin; + tokenHighestY < letterPosition.y && (tokenHighestY = letterPosition.y); + tokenLowestY > letterPosition.y - letterDef.h * _bmfontScale && (tokenLowestY = letterPosition.y - letterDef.h * _bmfontScale); + } + if (newLine) continue; + nextTokenX = nextLetterX; + letterRight = tokenRight; + highestY < tokenHighestY && (highestY = tokenHighestY); + lowestY > tokenLowestY && (lowestY = tokenLowestY); + longestLine < letterRight && (longestLine = letterRight); + index += tokenLen; + } + _linesWidth.push(letterRight); + _numberOfLines = lineIndex + 1; + _textDesiredHeight = _numberOfLines * _lineHeight * this._getFontScale(); + _numberOfLines > 1 && (_textDesiredHeight += (_numberOfLines - 1) * _lineSpacing); + _contentSize.width = _labelWidth; + _contentSize.height = _labelHeight; + _labelWidth <= 0 && (_contentSize.width = parseFloat(longestLine.toFixed(2)) + 2 * shareLabelInfo.margin); + _labelHeight <= 0 && (_contentSize.height = parseFloat(_textDesiredHeight.toFixed(2)) + 2 * shareLabelInfo.margin); + _tailoredTopY = _contentSize.height; + _tailoredBottomY = 0; + if (_overflow !== Overflow.CLAMP) { + highestY > 0 && (_tailoredTopY = _contentSize.height + highestY); + lowestY < -_textDesiredHeight && (_tailoredBottomY = _textDesiredHeight + lowestY); + } + return true; + }; + _proto._getFirstCharLen = function _getFirstCharLen() { + return 1; + }; + _proto._getFontScale = function _getFontScale() { + return _overflow === Overflow.SHRINK ? _bmfontScale : 1; + }; + _proto._getFirstWordLen = function _getFirstWordLen(text, startIndex, textLen) { + var character = text.charAt(startIndex); + if (textUtils.isUnicodeCJK(character) || "\n" === character || textUtils.isUnicodeSpace(character)) return 1; + var len = 1; + var letterDef = shareLabelInfo.fontAtlas.getLetterDefinitionForChar(character, shareLabelInfo); + if (!letterDef) return len; + var nextLetterX = letterDef.xAdvance * _bmfontScale + _spacingX; + var letterX; + for (var index = startIndex + 1; index < textLen; ++index) { + character = text.charAt(index); + letterDef = shareLabelInfo.fontAtlas.getLetterDefinitionForChar(character, shareLabelInfo); + if (!letterDef) break; + letterX = nextLetterX + letterDef.offsetX * _bmfontScale; + if (letterX + letterDef.w * _bmfontScale > _maxLineWidth && !textUtils.isUnicodeSpace(character) && _maxLineWidth > 0) return len; + nextLetterX += letterDef.xAdvance * _bmfontScale + _spacingX; + if ("\n" === character || textUtils.isUnicodeSpace(character) || textUtils.isUnicodeCJK(character)) break; + len++; + } + return len; + }; + _proto._multilineTextWrapByWord = function _multilineTextWrapByWord() { + return this._multilineTextWrap(this._getFirstWordLen); + }; + _proto._multilineTextWrapByChar = function _multilineTextWrapByChar() { + return this._multilineTextWrap(this._getFirstCharLen); + }; + _proto._recordPlaceholderInfo = function _recordPlaceholderInfo(letterIndex, _char) { + if (letterIndex >= _lettersInfo.length) { + var tmpInfo = new LetterInfo(); + _lettersInfo.push(tmpInfo); + } + _lettersInfo[letterIndex]["char"] = _char; + _lettersInfo[letterIndex].hash = _char.charCodeAt(0) + shareLabelInfo.hash; + _lettersInfo[letterIndex].valid = false; + }; + _proto._recordLetterInfo = function _recordLetterInfo(letterPosition, character, letterIndex, lineIndex) { + if (letterIndex >= _lettersInfo.length) { + var tmpInfo = new LetterInfo(); + _lettersInfo.push(tmpInfo); + } + var _char2 = character.charCodeAt(0); + var key = _char2 + shareLabelInfo.hash; + _lettersInfo[letterIndex].line = lineIndex; + _lettersInfo[letterIndex]["char"] = character; + _lettersInfo[letterIndex].hash = key; + _lettersInfo[letterIndex].valid = shareLabelInfo.fontAtlas.getLetter(key).valid; + _lettersInfo[letterIndex].x = letterPosition.x; + _lettersInfo[letterIndex].y = letterPosition.y; + }; + _proto._alignText = function _alignText() { + _textDesiredHeight = 0; + _linesWidth.length = 0; + _lineBreakWithoutSpaces ? this._multilineTextWrapByChar() : this._multilineTextWrapByWord(); + this._computeAlignmentOffset(); + _overflow === Overflow.SHRINK && _fontSize > 0 && this._isVerticalClamp() && this._shrinkLabelToContentSize(this._isVerticalClamp); + this._updateQuads() || _overflow === Overflow.SHRINK && this._shrinkLabelToContentSize(this._isHorizontalClamp); + }; + _proto._scaleFontSizeDown = function _scaleFontSizeDown(fontSize) { + var shouldUpdateContent = true; + if (!fontSize) { + fontSize = .1; + shouldUpdateContent = false; + } + _fontSize = fontSize; + shouldUpdateContent && this._updateContent(); + }; + _proto._shrinkLabelToContentSize = function _shrinkLabelToContentSize(lambda) { + var fontSize = _fontSize; + var left = 0, right = 0 | fontSize, mid = 0; + while (left < right) { + mid = left + right + 1 >> 1; + var newFontSize = mid; + if (newFontSize <= 0) break; + _bmfontScale = newFontSize / _originFontSize; + _lineBreakWithoutSpaces ? this._multilineTextWrapByChar() : this._multilineTextWrapByWord(); + this._computeAlignmentOffset(); + lambda() ? right = mid - 1 : left = mid; + } + var actualFontSize = left; + actualFontSize >= 0 && this._scaleFontSizeDown(actualFontSize); + }; + _proto._isVerticalClamp = function _isVerticalClamp() { + return _textDesiredHeight > _contentSize.height; + }; + _proto._isHorizontalClamp = function _isHorizontalClamp() { + var letterClamp = false; + for (var ctr = 0, l = _string.length; ctr < l; ++ctr) { + var letterInfo = _lettersInfo[ctr]; + if (letterInfo.valid) { + var letterDef = shareLabelInfo.fontAtlas.getLetter(letterInfo.hash); + var px = letterInfo.x + letterDef.w * _bmfontScale; + var lineIndex = letterInfo.line; + if (_labelWidth > 0) if (_isWrapText) { + var wordWidth = _linesWidth[lineIndex]; + if (wordWidth > _contentSize.width && (px > _contentSize.width || px < 0)) { + letterClamp = true; + break; + } + } else if (px > _contentSize.width) { + letterClamp = true; + break; + } + } + } + return letterClamp; + }; + _proto._isHorizontalClamped = function _isHorizontalClamped(px, lineIndex) { + var wordWidth = _linesWidth[lineIndex]; + var letterOverClamp = px > _contentSize.width || px < 0; + return _isWrapText ? wordWidth > _contentSize.width && letterOverClamp : letterOverClamp; + }; + _proto._updateQuads = function _updateQuads() { + var texture = _spriteFrame ? _spriteFrame._texture : shareLabelInfo.fontAtlas.getTexture(); + var node = _comp.node; + this.verticesCount = this.indicesCount = 0; + this._renderData && (this._renderData.dataLength = 0); + var contentSize = _contentSize, appx = node._anchorPoint.x * contentSize.width, appy = node._anchorPoint.y * contentSize.height; + var ret = true; + for (var ctr = 0, l = _string.length; ctr < l; ++ctr) { + var letterInfo = _lettersInfo[ctr]; + if (!letterInfo.valid) continue; + var letterDef = shareLabelInfo.fontAtlas.getLetter(letterInfo.hash); + _tmpRect.height = letterDef.h; + _tmpRect.width = letterDef.w; + _tmpRect.x = letterDef.u; + _tmpRect.y = letterDef.v; + var py = letterInfo.y + _letterOffsetY; + if (_labelHeight > 0) { + if (py > _tailoredTopY) { + var clipTop = py - _tailoredTopY; + _tmpRect.y += clipTop; + _tmpRect.height -= clipTop; + py -= clipTop; + } + py - letterDef.h * _bmfontScale < _tailoredBottomY && _overflow === Overflow.CLAMP && (_tmpRect.height = py < _tailoredBottomY ? 0 : (py - _tailoredBottomY) / _bmfontScale); + } + var lineIndex = letterInfo.line; + var px = letterInfo.x + letterDef.w / 2 * _bmfontScale + _linesOffsetX[lineIndex]; + if (_labelWidth > 0 && this._isHorizontalClamped(px, lineIndex)) if (_overflow === Overflow.CLAMP) _tmpRect.width = 0; else if (_overflow === Overflow.SHRINK) { + if (_contentSize.width > letterDef.w) { + ret = false; + break; + } + _tmpRect.width = 0; + } + if (_tmpRect.height > 0 && _tmpRect.width > 0) { + var isRotated = this._determineRect(_tmpRect); + var letterPositionX = letterInfo.x + _linesOffsetX[letterInfo.line]; + this.appendQuad(_comp, texture, _tmpRect, isRotated, letterPositionX - appx, py - appy, _bmfontScale); + } + } + this._quadsUpdated(_comp); + return ret; + }; + _proto._determineRect = function _determineRect(tempRect) { + var isRotated = _spriteFrame.isRotated(); + var originalSize = _spriteFrame._originalSize; + var rect = _spriteFrame._rect; + var offset = _spriteFrame._offset; + var trimmedLeft = offset.x + (originalSize.width - rect.width) / 2; + var trimmedTop = offset.y - (originalSize.height - rect.height) / 2; + if (isRotated) { + var originalX = tempRect.x; + tempRect.x = rect.x + rect.height - tempRect.y - tempRect.height - trimmedTop; + tempRect.y = originalX + rect.y - trimmedLeft; + tempRect.y < 0 && (tempRect.height = tempRect.height + trimmedTop); + } else { + tempRect.x += rect.x - trimmedLeft; + tempRect.y += rect.y + trimmedTop; + } + return isRotated; + }; + _proto._computeAlignmentOffset = function _computeAlignmentOffset() { + _linesOffsetX.length = 0; + switch (_hAlign) { + case macro.TextAlignment.LEFT: + for (var i = 0; i < _numberOfLines; ++i) _linesOffsetX.push(0); + break; + + case macro.TextAlignment.CENTER: + for (var _i = 0, l = _linesWidth.length; _i < l; _i++) _linesOffsetX.push((_contentSize.width - _linesWidth[_i]) / 2); + break; + + case macro.TextAlignment.RIGHT: + for (var _i2 = 0, _l = _linesWidth.length; _i2 < _l; _i2++) _linesOffsetX.push(_contentSize.width - _linesWidth[_i2]); + } + _letterOffsetY = _contentSize.height; + if (_vAlign !== macro.VerticalTextAlignment.TOP) { + var blank = _contentSize.height - _textDesiredHeight + _lineHeight * this._getFontScale() - _originFontSize * _bmfontScale; + _vAlign === macro.VerticalTextAlignment.BOTTOM ? _letterOffsetY -= blank : _letterOffsetY -= blank / 2; + } + }; + _proto._setupBMFontOverflowMetrics = function _setupBMFontOverflowMetrics() { + var newWidth = _contentSize.width, newHeight = _contentSize.height; + _overflow === Overflow.RESIZE_HEIGHT && (newHeight = 0); + if (_overflow === Overflow.NONE) { + newWidth = 0; + newHeight = 0; + } + _labelWidth = newWidth; + _labelHeight = newHeight; + _maxLineWidth = newWidth; + }; + _proto.updateWorldVerts = function updateWorldVerts() {}; + _proto.appendQuad = function appendQuad(comp, texture, rect, rotated, x, y, scale) {}; + _proto._quadsUpdated = function _quadsUpdated(comp) {}; + _proto._reserveQuads = function _reserveQuads() {}; + return BmfontAssembler; + })(_assembler2d["default"]); + exports["default"] = BmfontAssembler; + module.exports = exports["default"]; + }), { + "../../../components/CCLabel": 152, + "../../../platform/CCMacro": 245, + "../../../utils/text-utils": 332, + "../../assembler-2d": 266, + "../utils": 280 + } ], + 277: [ (function(require, module, exports) { + "use strict"; + function LabelFrame() { + this._rect = null; + this.uv = []; + this._texture = null; + this._original = null; + } + LabelFrame.prototype = { + constructor: LabelFrame, + getRect: function getRect() { + return cc.rect(this._rect); + }, + setRect: function setRect(rect) { + this._rect = rect; + this._texture && this._calculateUV(); + }, + _setDynamicAtlasFrame: function _setDynamicAtlasFrame(frame) { + if (!frame) return; + this._original = { + _texture: this._texture, + _x: this._rect.x, + _y: this._rect.y + }; + this._texture = frame.texture; + this._rect.x = frame.x; + this._rect.y = frame.y; + this._calculateUV(); + }, + _resetDynamicAtlasFrame: function _resetDynamicAtlasFrame() { + if (!this._original) return; + this._rect.x = this._original._x; + this._rect.y = this._original._y; + this._texture = this._original._texture; + this._original = null; + this._calculateUV(); + }, + _refreshTexture: function _refreshTexture(texture) { + this._texture = texture; + this._rect = cc.rect(0, 0, texture.width, texture.height); + this._calculateUV(); + }, + _calculateUV: function _calculateUV() { + var rect = this._rect, texture = this._texture, uv = this.uv, texw = texture.width, texh = texture.height; + var l = 0 === texw ? 0 : rect.x / texw; + var r = 0 === texw ? 0 : (rect.x + rect.width) / texw; + var b = 0 === texh ? 0 : (rect.y + rect.height) / texh; + var t = 0 === texh ? 0 : rect.y / texh; + uv[0] = l; + uv[1] = b; + uv[2] = r; + uv[3] = b; + uv[4] = l; + uv[5] = t; + uv[6] = r; + uv[7] = t; + } + }; + module.exports = LabelFrame; + }), {} ], + 278: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _bmfont = _interopRequireDefault(require("../../webgl/assemblers/label/2d/bmfont")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + _setPrototypeOf(subClass, superClass); + } + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + return _setPrototypeOf(o, p); + } + var Label = require("../../../components/CCLabel"); + var LabelOutline = require("../../../components/CCLabelOutline"); + var textUtils = require("../../../utils/text-utils"); + var Component = require("../../../components/CCComponent"); + var RenderTexture = require("../../../assets/CCRenderTexture"); + var OUTLINE_SUPPORTED = cc.js.isChildClassOf(LabelOutline, Component); + var getFontFamily = require("../utils").getFontFamily; + var shareLabelInfo = require("../utils").shareLabelInfo; + var FontLetterDefinition = cc.BitmapFont.FontLetterDefinition; + var FontAtlas = cc.BitmapFont.FontAtlas; + var WHITE = cc.Color.WHITE; + var space = 0; + var bleed = 2; + var _invisibleAlpha = (1 / 255).toFixed(3); + function LetterTexture(_char, labelInfo) { + this._texture = null; + this._labelInfo = labelInfo; + this._char = _char; + this._hash = null; + this._data = null; + this._canvas = null; + this._context = null; + this._width = 0; + this._height = 0; + this._offsetY = 0; + this._hash = _char.charCodeAt(0) + labelInfo.hash; + } + LetterTexture.prototype = { + constructor: LetterTexture, + updateRenderData: function updateRenderData() { + this._updateProperties(); + this._updateTexture(); + }, + _updateProperties: function _updateProperties() { + this._texture = new cc.Texture2D(); + this._data = Label._canvasPool.get(); + this._canvas = this._data.canvas; + this._context = this._data.context; + this._context.font = this._labelInfo.fontDesc; + var width = textUtils.safeMeasureText(this._context, this._char, this._labelInfo.fontDesc); + var blank = 2 * this._labelInfo.margin + bleed; + this._width = parseFloat(width.toFixed(2)) + blank; + this._height = (1 + textUtils.BASELINE_RATIO) * this._labelInfo.fontSize + blank; + this._offsetY = -this._labelInfo.fontSize * textUtils.BASELINE_RATIO / 2; + this._canvas.width !== this._width && (this._canvas.width = this._width); + this._canvas.height !== this._height && (this._canvas.height = this._height); + this._texture.initWithElement(this._canvas); + }, + _updateTexture: function _updateTexture() { + var context = this._context; + var labelInfo = this._labelInfo, width = this._canvas.width, height = this._canvas.height; + var fontSize = this._labelInfo.fontSize; + var startX = width / 2; + var startY = height / 2 + fontSize * textUtils.MIDDLE_RATIO + fontSize * textUtils.BASELINE_OFFSET; + var color = labelInfo.color; + context.lineJoin = "round"; + context.textAlign = "center"; + context.clearRect(0, 0, width, height); + context.fillStyle = "rgba(" + color.r + ", " + color.g + ", " + color.b + ", " + _invisibleAlpha + ")"; + context.fillRect(0, 0, width, height); + context.font = labelInfo.fontDesc; + context.fillStyle = "rgba(" + color.r + ", " + color.g + ", " + color.b + ", 1)"; + if (labelInfo.isOutlined && labelInfo.margin > 0) { + var strokeColor = labelInfo.out || WHITE; + context.strokeStyle = "rgba(" + strokeColor.r + ", " + strokeColor.g + ", " + strokeColor.b + ", " + strokeColor.a / 255 + ")"; + context.lineWidth = 2 * labelInfo.margin; + context.strokeText(this._char, startX, startY); + } + context.fillText(this._char, startX, startY); + this._texture.handleLoadedTexture(); + }, + destroy: function destroy() { + this._texture.destroy(); + this._texture = null; + Label._canvasPool.put(this._data); + } + }; + function LetterAtlas(width, height) { + var texture = new RenderTexture(); + texture.initWithSize(width, height); + texture.update(); + this._fontDefDictionary = new FontAtlas(texture); + this._x = space; + this._y = space; + this._nexty = space; + this._width = width; + this._height = height; + cc.director.on(cc.Director.EVENT_BEFORE_SCENE_LAUNCH, this.beforeSceneLoad, this); + } + cc.js.mixin(LetterAtlas.prototype, { + insertLetterTexture: function insertLetterTexture(letterTexture) { + var texture = letterTexture._texture; + var width = texture.width, height = texture.height; + if (this._x + width + space > this._width) { + this._x = space; + this._y = this._nexty; + } + this._y + height > this._nexty && (this._nexty = this._y + height + space); + if (this._nexty > this._height) return null; + this._fontDefDictionary._texture.drawTextureAt(texture, this._x, this._y); + this._dirty = true; + var letter = new FontLetterDefinition(); + letter.u = this._x + bleed / 2; + letter.v = this._y + bleed / 2; + letter.texture = this._fontDefDictionary._texture; + letter.valid = true; + letter.w = letterTexture._width - bleed; + letter.h = letterTexture._height - bleed; + letter.xAdvance = letter.w; + letter.offsetY = letterTexture._offsetY; + this._x += width + space; + this._fontDefDictionary.addLetterDefinitions(letterTexture._hash, letter); + return letter; + }, + update: function update() { + if (!this._dirty) return; + this._fontDefDictionary._texture.update(); + this._dirty = false; + }, + reset: function reset() { + this._x = space; + this._y = space; + this._nexty = space; + var chars = this._fontDefDictionary._letterDefinitions; + for (var i = 0, l = chars.length; i < l; i++) { + var _char2 = chars[i]; + if (!_char2.isValid) continue; + _char2.destroy(); + } + this._fontDefDictionary.clear(); + }, + destroy: function destroy() { + this.reset(); + this._fontDefDictionary._texture.destroy(); + this._fontDefDictionary._texture = null; + }, + beforeSceneLoad: function beforeSceneLoad() { + this.clearAllCache(); + }, + clearAllCache: function clearAllCache() { + this.destroy(); + var texture = new RenderTexture(); + texture.initWithSize(this._width, this._height); + texture.update(); + this._fontDefDictionary._texture = texture; + }, + getLetter: function getLetter(key) { + return this._fontDefDictionary._letterDefinitions[key]; + }, + getTexture: function getTexture() { + return this._fontDefDictionary.getTexture(); + }, + getLetterDefinitionForChar: function getLetterDefinitionForChar(_char3, labelInfo) { + var hash = _char3.charCodeAt(0) + labelInfo.hash; + var letter = this._fontDefDictionary._letterDefinitions[hash]; + if (!letter) { + var temp = new LetterTexture(_char3, labelInfo); + temp.updateRenderData(); + letter = this.insertLetterTexture(temp); + temp.destroy(); + } + return letter; + } + }); + function computeHash(labelInfo) { + var hashData = ""; + var color = labelInfo.color.toHEX(); + var out = ""; + labelInfo.isOutlined && labelInfo.margin > 0 && (out = out + labelInfo.margin + labelInfo.out.toHEX()); + return hashData + labelInfo.fontSize + labelInfo.fontFamily + color + out; + } + var _shareAtlas = null; + var _atlasWidth = 2048; + var _atlasHeight = 2048; + var _isBold = false; + var LetterFontAssembler = (function(_WebglBmfontAssembler) { + _inheritsLoose(LetterFontAssembler, _WebglBmfontAssembler); + function LetterFontAssembler() { + return _WebglBmfontAssembler.apply(this, arguments) || this; + } + var _proto = LetterFontAssembler.prototype; + _proto._getAssemblerData = function _getAssemblerData() { + if (!_shareAtlas) { + _shareAtlas = new LetterAtlas(_atlasWidth, _atlasHeight); + cc.Label._shareAtlas = _shareAtlas; + } + return _shareAtlas.getTexture(); + }; + _proto._updateFontFamily = function _updateFontFamily(comp) { + shareLabelInfo.fontAtlas = _shareAtlas; + shareLabelInfo.fontFamily = getFontFamily(comp); + var outline = OUTLINE_SUPPORTED && comp.getComponent(LabelOutline); + if (outline && outline.enabled) { + shareLabelInfo.isOutlined = true; + shareLabelInfo.margin = outline.width; + shareLabelInfo.out = outline.color.clone(); + shareLabelInfo.out.a = outline.color.a * comp.node.color.a / 255; + } else { + shareLabelInfo.isOutlined = false; + shareLabelInfo.margin = 0; + } + }; + _proto._updateLabelInfo = function _updateLabelInfo(comp) { + shareLabelInfo.fontDesc = this._getFontDesc(); + shareLabelInfo.color = comp.node.color; + shareLabelInfo.hash = computeHash(shareLabelInfo); + }; + _proto._getFontDesc = function _getFontDesc() { + var fontDesc = shareLabelInfo.fontSize.toString() + "px "; + fontDesc += shareLabelInfo.fontFamily; + _isBold && (fontDesc = "bold " + fontDesc); + return fontDesc; + }; + _proto._computeHorizontalKerningForText = function _computeHorizontalKerningForText() {}; + _proto._determineRect = function _determineRect(tempRect) { + return false; + }; + return LetterFontAssembler; + })(_bmfont["default"]); + exports["default"] = LetterFontAssembler; + module.exports = exports["default"]; + }), { + "../../../assets/CCRenderTexture": 114, + "../../../components/CCComponent": 150, + "../../../components/CCLabel": 152, + "../../../components/CCLabelOutline": 153, + "../../../utils/text-utils": 332, + "../../webgl/assemblers/label/2d/bmfont": 285, + "../utils": 280 + } ], + 279: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _assembler2d = _interopRequireDefault(require("../../assembler-2d")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + _setPrototypeOf(subClass, superClass); + } + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + return _setPrototypeOf(o, p); + } + var textUtils = require("../../../utils/text-utils"); + var macro = require("../../../platform/CCMacro"); + var Label = require("../../../components/CCLabel"); + var LabelOutline = require("../../../components/CCLabelOutline"); + var LabelShadow = require("../../../components/CCLabelShadow"); + var Overflow = Label.Overflow; + var deleteFromDynamicAtlas = require("../utils").deleteFromDynamicAtlas; + var getFontFamily = require("../utils").getFontFamily; + var _invisibleAlpha = (1 / 255).toFixed(3); + var MAX_SIZE = 2048; + var _context = null; + var _canvas = null; + var _texture = null; + var _fontDesc = ""; + var _string = ""; + var _fontSize = 0; + var _drawFontSize = 0; + var _splitedStrings = []; + var _canvasSize = cc.Size.ZERO; + var _lineHeight = 0; + var _hAlign = 0; + var _vAlign = 0; + var _color = null; + var _fontFamily = ""; + var _overflow = Overflow.NONE; + var _isWrapText = false; + var _premultiply = false; + var _outlineComp = null; + var _outlineColor = cc.Color.WHITE; + var _shadowComp = null; + var _shadowColor = cc.Color.BLACK; + var _canvasPadding = cc.rect(); + var _contentSizeExtend = cc.Size.ZERO; + var _nodeContentSize = cc.Size.ZERO; + var _enableBold = false; + var _enableItalic = false; + var _enableUnderline = false; + var _underlineThickness = 0; + var _drawUnderlinePos = cc.Vec2.ZERO; + var _drawUnderlineWidth = 0; + var _sharedLabelData; + var Alignment = [ "left", "center", "right" ]; + var TTFAssembler = (function(_Assembler2D) { + _inheritsLoose(TTFAssembler, _Assembler2D); + function TTFAssembler() { + return _Assembler2D.apply(this, arguments) || this; + } + var _proto = TTFAssembler.prototype; + _proto._getAssemblerData = function _getAssemblerData() { + _sharedLabelData = Label._canvasPool.get(); + _sharedLabelData.canvas.width = _sharedLabelData.canvas.height = 1; + return _sharedLabelData; + }; + _proto._resetAssemblerData = function _resetAssemblerData(assemblerData) { + assemblerData && Label._canvasPool.put(assemblerData); + }; + _proto.updateRenderData = function updateRenderData(comp) { + _Assembler2D.prototype.updateRenderData.call(this, comp); + if (!comp._vertsDirty) return; + this._updateProperties(comp); + this._calculateLabelFont(); + this._updateLabelDimensions(); + this._updateTexture(comp); + this._calDynamicAtlas(comp); + comp._actualFontSize = _fontSize; + comp.node.setContentSize(_nodeContentSize); + this.updateVerts(comp); + comp._vertsDirty = false; + _context = null; + _canvas = null; + _texture = null; + }; + _proto.updateVerts = function updateVerts() {}; + _proto._updatePaddingRect = function _updatePaddingRect() { + var top = 0, bottom = 0, left = 0, right = 0; + var outlineWidth = 0; + _contentSizeExtend.width = _contentSizeExtend.height = 0; + if (_outlineComp) { + outlineWidth = _outlineComp.width; + top = bottom = left = right = outlineWidth; + _contentSizeExtend.width = _contentSizeExtend.height = 2 * outlineWidth; + } + if (_shadowComp) { + var shadowWidth = _shadowComp.blur + outlineWidth; + left = Math.max(left, -_shadowComp._offset.x + shadowWidth); + right = Math.max(right, _shadowComp._offset.x + shadowWidth); + top = Math.max(top, _shadowComp._offset.y + shadowWidth); + bottom = Math.max(bottom, -_shadowComp._offset.y + shadowWidth); + } + if (_enableItalic) { + var offset = _drawFontSize * Math.tan(.20943951); + right += offset; + _contentSizeExtend.width += offset; + } + _canvasPadding.x = left; + _canvasPadding.y = top; + _canvasPadding.width = left + right; + _canvasPadding.height = top + bottom; + }; + _proto._updateProperties = function _updateProperties(comp) { + var assemblerData = comp._assemblerData; + _context = assemblerData.context; + _canvas = assemblerData.canvas; + _texture = comp._frame._original ? comp._frame._original._texture : comp._frame._texture; + _string = comp.string.toString(); + _fontSize = comp._fontSize; + _drawFontSize = _fontSize; + _underlineThickness = comp.underlineHeight || _drawFontSize / 8; + _overflow = comp.overflow; + _canvasSize.width = comp.node.width; + _canvasSize.height = comp.node.height; + _nodeContentSize = comp.node.getContentSize(); + _lineHeight = comp._lineHeight; + _hAlign = comp.horizontalAlign; + _vAlign = comp.verticalAlign; + _color = comp.node.color; + _enableBold = comp.enableBold; + _enableItalic = comp.enableItalic; + _enableUnderline = comp.enableUnderline; + _fontFamily = getFontFamily(comp); + _premultiply = comp.srcBlendFactor === cc.macro.BlendFactor.ONE; + false; + _isWrapText = _overflow !== Overflow.NONE && (_overflow === Overflow.RESIZE_HEIGHT || comp.enableWrapText); + _outlineComp = LabelOutline && comp.getComponent(LabelOutline); + _outlineComp = _outlineComp && _outlineComp.enabled && _outlineComp.width > 0 ? _outlineComp : null; + _outlineComp && _outlineColor.set(_outlineComp.color); + _shadowComp = LabelShadow && comp.getComponent(LabelShadow); + _shadowComp = _shadowComp && _shadowComp.enabled ? _shadowComp : null; + if (_shadowComp) { + _shadowColor.set(_shadowComp.color); + _shadowColor.a = _shadowColor.a * comp.node.color.a / 255; + } + this._updatePaddingRect(); + }; + _proto._calculateFillTextStartPosition = function _calculateFillTextStartPosition() { + var labelX = 0; + _hAlign === macro.TextAlignment.RIGHT ? labelX = _canvasSize.width - _canvasPadding.width : _hAlign === macro.TextAlignment.CENTER && (labelX = (_canvasSize.width - _canvasPadding.width) / 2); + var lineHeight = this._getLineHeight(); + var drawStartY = lineHeight * (_splitedStrings.length - 1); + var firstLinelabelY = _fontSize * (1 - textUtils.BASELINE_RATIO / 2); + if (_vAlign !== macro.VerticalTextAlignment.TOP) { + var blank = drawStartY + _canvasPadding.height + _fontSize - _canvasSize.height; + if (_vAlign === macro.VerticalTextAlignment.BOTTOM) { + blank += textUtils.BASELINE_RATIO / 2 * _fontSize; + firstLinelabelY -= blank; + } else firstLinelabelY -= blank / 2; + } + firstLinelabelY += textUtils.BASELINE_OFFSET * _fontSize; + return cc.v2(labelX + _canvasPadding.x, firstLinelabelY + _canvasPadding.y); + }; + _proto._setupOutline = function _setupOutline() { + _context.strokeStyle = "rgba(" + _outlineColor.r + ", " + _outlineColor.g + ", " + _outlineColor.b + ", " + _outlineColor.a / 255 + ")"; + _context.lineWidth = 2 * _outlineComp.width; + }; + _proto._setupShadow = function _setupShadow() { + _context.shadowColor = "rgba(" + _shadowColor.r + ", " + _shadowColor.g + ", " + _shadowColor.b + ", " + _shadowColor.a / 255 + ")"; + _context.shadowBlur = _shadowComp.blur; + _context.shadowOffsetX = _shadowComp.offset.x; + _context.shadowOffsetY = -_shadowComp.offset.y; + }; + _proto._drawTextEffect = function _drawTextEffect(startPosition, lineHeight) { + if (!_shadowComp && !_outlineComp && !_enableUnderline) return; + var isMultiple = _splitedStrings.length > 1 && _shadowComp; + var measureText = this._measureText(_context, _fontDesc); + var drawTextPosX = 0, drawTextPosY = 0; + _shadowComp && this._setupShadow(); + _outlineComp && this._setupOutline(); + for (var i = 0; i < _splitedStrings.length; ++i) { + drawTextPosX = startPosition.x; + drawTextPosY = startPosition.y + i * lineHeight; + if (isMultiple) { + _outlineComp && _context.strokeText(_splitedStrings[i], drawTextPosX, drawTextPosY); + _context.fillText(_splitedStrings[i], drawTextPosX, drawTextPosY); + } + if (_enableUnderline) { + _drawUnderlineWidth = measureText(_splitedStrings[i]); + _hAlign === macro.TextAlignment.RIGHT ? _drawUnderlinePos.x = startPosition.x - _drawUnderlineWidth : _hAlign === macro.TextAlignment.CENTER ? _drawUnderlinePos.x = startPosition.x - _drawUnderlineWidth / 2 : _drawUnderlinePos.x = startPosition.x; + _drawUnderlinePos.y = drawTextPosY + _drawFontSize / 8; + _context.fillRect(_drawUnderlinePos.x, _drawUnderlinePos.y, _drawUnderlineWidth, _underlineThickness); + } + } + isMultiple && (_context.shadowColor = "transparent"); + }; + _proto._updateTexture = function _updateTexture() { + _context.clearRect(0, 0, _canvas.width, _canvas.height); + _context.lineJoin = "round"; + if (_premultiply) _context.fillStyle = "rgba(" + _color.r + ", " + _color.g + ", " + _color.b + ", " + _color.a / 255 + ")"; else { + var _fillColor = _outlineComp ? _outlineColor : _color; + _context.fillStyle = "rgba(" + _fillColor.r + ", " + _fillColor.g + ", " + _fillColor.b + ", " + _invisibleAlpha + ")"; + _context.fillRect(0, 0, _canvas.width, _canvas.height); + _context.fillStyle = "rgba(" + _color.r + ", " + _color.g + ", " + _color.b + ", 1)"; + } + var startPosition = this._calculateFillTextStartPosition(); + var lineHeight = this._getLineHeight(); + var drawTextPosX = startPosition.x, drawTextPosY = 0; + this._drawTextEffect(startPosition, lineHeight); + for (var i = 0; i < _splitedStrings.length; ++i) { + drawTextPosY = startPosition.y + i * lineHeight; + _outlineComp && _context.strokeText(_splitedStrings[i], drawTextPosX, drawTextPosY); + _context.fillText(_splitedStrings[i], drawTextPosX, drawTextPosY); + } + _shadowComp && (_context.shadowColor = "transparent"); + _texture.handleLoadedTexture(); + }; + _proto._calDynamicAtlas = function _calDynamicAtlas(comp) { + if (comp.cacheMode !== Label.CacheMode.BITMAP) return; + var frame = comp._frame; + deleteFromDynamicAtlas(comp, frame); + frame._original || frame.setRect(cc.rect(0, 0, _canvas.width, _canvas.height)); + this.packToDynamicAtlas(comp, frame); + }; + _proto._updateLabelDimensions = function _updateLabelDimensions() { + var maxTextureSize = cc.renderer.device.caps ? cc.renderer.device.caps.maxTextureSize : MAX_SIZE; + (_canvasSize.width > maxTextureSize || _canvasSize.height > maxTextureSize) && cc.warn("The maximum texture size supported by the device is " + maxTextureSize); + _canvasSize.width = Math.min(_canvasSize.width, maxTextureSize); + _canvasSize.height = Math.min(_canvasSize.height, maxTextureSize); + var recreate = false; + if (_canvas.width !== _canvasSize.width) { + _canvas.width = _canvasSize.width; + recreate = true; + } + if (_canvas.height !== _canvasSize.height) { + _canvas.height = _canvasSize.height; + recreate = true; + } + recreate && (_context.font = _fontDesc); + _context.textAlign = Alignment[_hAlign]; + }; + _proto._getFontDesc = function _getFontDesc() { + var fontDesc = _fontSize.toString() + "px "; + fontDesc += _fontFamily; + _enableBold && (fontDesc = "bold " + fontDesc); + _enableItalic && (fontDesc = "italic " + fontDesc); + return fontDesc; + }; + _proto._getLineHeight = function _getLineHeight() { + var nodeSpacingY = _lineHeight; + nodeSpacingY = 0 === nodeSpacingY ? _fontSize : nodeSpacingY * _fontSize / _drawFontSize; + return 0 | nodeSpacingY; + }; + _proto._calculateParagraphLength = function _calculateParagraphLength(paragraphedStrings, ctx) { + var paragraphLength = []; + for (var i = 0; i < paragraphedStrings.length; ++i) { + var width = textUtils.safeMeasureText(ctx, paragraphedStrings[i], _fontDesc); + paragraphLength.push(width); + } + return paragraphLength; + }; + _proto._measureText = function _measureText(ctx, fontDesc) { + return function(string) { + return textUtils.safeMeasureText(ctx, string, fontDesc); + }; + }; + _proto._calculateShrinkFont = function _calculateShrinkFont(paragraphedStrings) { + var paragraphLength = this._calculateParagraphLength(paragraphedStrings, _context); + var i = 0; + var totalHeight = 0; + var maxLength = 0; + if (_isWrapText) { + var canvasWidthNoMargin = _nodeContentSize.width; + var canvasHeightNoMargin = _nodeContentSize.height; + if (canvasWidthNoMargin < 0 || canvasHeightNoMargin < 0) return; + totalHeight = canvasHeightNoMargin + 1; + var actualFontSize = _fontSize + 1; + var textFragment = ""; + var left = 0, right = 0 | actualFontSize, mid = 0; + while (left < right) { + mid = left + right + 1 >> 1; + if (mid <= 0) { + cc.logID(4003); + break; + } + _fontSize = mid; + _fontDesc = this._getFontDesc(); + _context.font = _fontDesc; + var lineHeight = this._getLineHeight(); + totalHeight = 0; + for (i = 0; i < paragraphedStrings.length; ++i) { + var allWidth = textUtils.safeMeasureText(_context, paragraphedStrings[i], _fontDesc); + textFragment = textUtils.fragmentText(paragraphedStrings[i], allWidth, canvasWidthNoMargin, this._measureText(_context, _fontDesc)); + totalHeight += textFragment.length * lineHeight; + } + totalHeight > canvasHeightNoMargin ? right = mid - 1 : left = mid; + } + if (0 === left) cc.logID(4003); else { + _fontSize = left; + _fontDesc = this._getFontDesc(); + _context.font = _fontDesc; + } + } else { + totalHeight = paragraphedStrings.length * this._getLineHeight(); + for (i = 0; i < paragraphedStrings.length; ++i) maxLength < paragraphLength[i] && (maxLength = paragraphLength[i]); + var scaleX = (_canvasSize.width - _canvasPadding.width) / maxLength; + var scaleY = _canvasSize.height / totalHeight; + _fontSize = _drawFontSize * Math.min(1, scaleX, scaleY) | 0; + _fontDesc = this._getFontDesc(); + _context.font = _fontDesc; + } + }; + _proto._calculateWrapText = function _calculateWrapText(paragraphedStrings) { + if (!_isWrapText) return; + _splitedStrings = []; + var canvasWidthNoMargin = _nodeContentSize.width; + for (var i = 0; i < paragraphedStrings.length; ++i) { + var allWidth = textUtils.safeMeasureText(_context, paragraphedStrings[i], _fontDesc); + var textFragment = textUtils.fragmentText(paragraphedStrings[i], allWidth, canvasWidthNoMargin, this._measureText(_context, _fontDesc)); + _splitedStrings = _splitedStrings.concat(textFragment); + } + }; + _proto._calculateLabelFont = function _calculateLabelFont() { + var paragraphedStrings = _string.split("\n"); + _splitedStrings = paragraphedStrings; + _fontDesc = this._getFontDesc(); + _context.font = _fontDesc; + switch (_overflow) { + case Overflow.NONE: + var canvasSizeX = 0; + var canvasSizeY = 0; + for (var i = 0; i < paragraphedStrings.length; ++i) { + var paraLength = textUtils.safeMeasureText(_context, paragraphedStrings[i], _fontDesc); + canvasSizeX = canvasSizeX > paraLength ? canvasSizeX : paraLength; + } + canvasSizeY = (_splitedStrings.length + textUtils.BASELINE_RATIO) * this._getLineHeight(); + var rawWidth = parseFloat(canvasSizeX.toFixed(2)); + var rawHeight = parseFloat(canvasSizeY.toFixed(2)); + _canvasSize.width = rawWidth + _canvasPadding.width; + _canvasSize.height = rawHeight + _canvasPadding.height; + _nodeContentSize.width = rawWidth + _contentSizeExtend.width; + _nodeContentSize.height = rawHeight + _contentSizeExtend.height; + break; + + case Overflow.SHRINK: + this._calculateShrinkFont(paragraphedStrings); + this._calculateWrapText(paragraphedStrings); + break; + + case Overflow.CLAMP: + this._calculateWrapText(paragraphedStrings); + break; + + case Overflow.RESIZE_HEIGHT: + this._calculateWrapText(paragraphedStrings); + var _rawHeight = (_splitedStrings.length + textUtils.BASELINE_RATIO) * this._getLineHeight(); + _canvasSize.height = _rawHeight + _canvasPadding.height; + _nodeContentSize.height = _rawHeight + _contentSizeExtend.height; + } + }; + return TTFAssembler; + })(_assembler2d["default"]); + exports["default"] = TTFAssembler; + module.exports = exports["default"]; + }), { + "../../../components/CCLabel": 152, + "../../../components/CCLabelOutline": 153, + "../../../components/CCLabelShadow": 154, + "../../../platform/CCMacro": 245, + "../../../utils/text-utils": 332, + "../../assembler-2d": 266, + "../utils": 280 + } ], + 280: [ (function(require, module, exports) { + "use strict"; + var dynamicAtlasManager = require("./dynamic-atlas/manager"); + var WHITE = cc.Color.WHITE; + var shareLabelInfo = { + fontAtlas: null, + fontSize: 0, + lineHeight: 0, + hAlign: 0, + vAlign: 0, + hash: "", + fontFamily: "", + fontDesc: "Arial", + color: WHITE, + isOutlined: false, + out: WHITE, + margin: 0 + }; + module.exports = { + deleteFromDynamicAtlas: function deleteFromDynamicAtlas(comp, frame) { + if (frame && true && frame._original && dynamicAtlasManager) { + dynamicAtlasManager.deleteAtlasSpriteFrame(frame); + frame._resetDynamicAtlasFrame(); + } + }, + getFontFamily: function getFontFamily(comp) { + if (comp.useSystemFont) return comp.fontFamily || "Arial"; + if (comp.font) { + if (comp.font._nativeAsset) return comp.font._nativeAsset; + cc.assetManager.postLoadNative(comp.font, (function(err) { + comp.isValid && comp.setVertsDirty(); + })); + return "Arial"; + } + return "Arial"; + }, + shareLabelInfo: shareLabelInfo + }; + }), { + "./dynamic-atlas/manager": 275 + } ], + 281: [ (function(require, module, exports) { + "use strict"; + cc.Graphics.earcut = module.exports = earcut; + function earcut(data, holeIndices, dim) { + dim = dim || 2; + var hasHoles = holeIndices && holeIndices.length, outerLen = hasHoles ? holeIndices[0] * dim : data.length, outerNode = linkedList(data, 0, outerLen, dim, true), triangles = []; + if (!outerNode) return triangles; + var minX, minY, maxX, maxY, x, y, size; + hasHoles && (outerNode = eliminateHoles(data, holeIndices, outerNode, dim)); + if (data.length > 80 * dim) { + minX = maxX = data[0]; + minY = maxY = data[1]; + for (var i = dim; i < outerLen; i += dim) { + x = data[i]; + y = data[i + 1]; + x < minX && (minX = x); + y < minY && (minY = y); + x > maxX && (maxX = x); + y > maxY && (maxY = y); + } + size = Math.max(maxX - minX, maxY - minY); + } + earcutLinked(outerNode, triangles, dim, minX, minY, size); + return triangles; + } + function linkedList(data, start, end, dim, clockwise) { + var i, last; + if (clockwise === signedArea(data, start, end, dim) > 0) for (i = start; i < end; i += dim) last = insertNode(i, data[i], data[i + 1], last); else for (i = end - dim; i >= start; i -= dim) last = insertNode(i, data[i], data[i + 1], last); + if (last && equals(last, last.next)) { + removeNode(last); + last = last.next; + } + return last; + } + function filterPoints(start, end) { + if (!start) return start; + end || (end = start); + var p = start, again; + do { + again = false; + if (p.steiner || !equals(p, p.next) && 0 !== area(p.prev, p, p.next)) p = p.next; else { + removeNode(p); + p = end = p.prev; + if (p === p.next) return null; + again = true; + } + } while (again || p !== end); + return end; + } + function earcutLinked(ear, triangles, dim, minX, minY, size, pass) { + if (!ear) return; + !pass && size && indexCurve(ear, minX, minY, size); + var stop = ear, prev, next; + while (ear.prev !== ear.next) { + prev = ear.prev; + next = ear.next; + if (size ? isEarHashed(ear, minX, minY, size) : isEar(ear)) { + triangles.push(prev.i / dim); + triangles.push(ear.i / dim); + triangles.push(next.i / dim); + removeNode(ear); + ear = next.next; + stop = next.next; + continue; + } + ear = next; + if (ear === stop) { + if (pass) if (1 === pass) { + ear = cureLocalIntersections(ear, triangles, dim); + earcutLinked(ear, triangles, dim, minX, minY, size, 2); + } else 2 === pass && splitEarcut(ear, triangles, dim, minX, minY, size); else earcutLinked(filterPoints(ear), triangles, dim, minX, minY, size, 1); + break; + } + } + } + function isEar(ear) { + var a = ear.prev, b = ear, c = ear.next; + if (area(a, b, c) >= 0) return false; + var p = ear.next.next; + while (p !== ear.prev) { + if (pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false; + p = p.next; + } + return true; + } + function isEarHashed(ear, minX, minY, size) { + var a = ear.prev, b = ear, c = ear.next; + if (area(a, b, c) >= 0) return false; + var minTX = a.x < b.x ? a.x < c.x ? a.x : c.x : b.x < c.x ? b.x : c.x, minTY = a.y < b.y ? a.y < c.y ? a.y : c.y : b.y < c.y ? b.y : c.y, maxTX = a.x > b.x ? a.x > c.x ? a.x : c.x : b.x > c.x ? b.x : c.x, maxTY = a.y > b.y ? a.y > c.y ? a.y : c.y : b.y > c.y ? b.y : c.y; + var minZ = zOrder(minTX, minTY, minX, minY, size), maxZ = zOrder(maxTX, maxTY, minX, minY, size); + var p = ear.nextZ; + while (p && p.z <= maxZ) { + if (p !== ear.prev && p !== ear.next && pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false; + p = p.nextZ; + } + p = ear.prevZ; + while (p && p.z >= minZ) { + if (p !== ear.prev && p !== ear.next && pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false; + p = p.prevZ; + } + return true; + } + function cureLocalIntersections(start, triangles, dim) { + var p = start; + do { + var a = p.prev, b = p.next.next; + if (!equals(a, b) && intersects(a, p, p.next, b) && locallyInside(a, b) && locallyInside(b, a)) { + triangles.push(a.i / dim); + triangles.push(p.i / dim); + triangles.push(b.i / dim); + removeNode(p); + removeNode(p.next); + p = start = b; + } + p = p.next; + } while (p !== start); + return p; + } + function splitEarcut(start, triangles, dim, minX, minY, size) { + var a = start; + do { + var b = a.next.next; + while (b !== a.prev) { + if (a.i !== b.i && isValidDiagonal(a, b)) { + var c = splitPolygon(a, b); + a = filterPoints(a, a.next); + c = filterPoints(c, c.next); + earcutLinked(a, triangles, dim, minX, minY, size); + earcutLinked(c, triangles, dim, minX, minY, size); + return; + } + b = b.next; + } + a = a.next; + } while (a !== start); + } + function eliminateHoles(data, holeIndices, outerNode, dim) { + var queue = [], i, len, start, end, list; + for (i = 0, len = holeIndices.length; i < len; i++) { + start = holeIndices[i] * dim; + end = i < len - 1 ? holeIndices[i + 1] * dim : data.length; + list = linkedList(data, start, end, dim, false); + list === list.next && (list.steiner = true); + queue.push(getLeftmost(list)); + } + queue.sort(compareX); + for (i = 0; i < queue.length; i++) { + eliminateHole(queue[i], outerNode); + outerNode = filterPoints(outerNode, outerNode.next); + } + return outerNode; + } + function compareX(a, b) { + return a.x - b.x; + } + function eliminateHole(hole, outerNode) { + outerNode = findHoleBridge(hole, outerNode); + if (outerNode) { + var b = splitPolygon(outerNode, hole); + filterPoints(b, b.next); + } + } + function findHoleBridge(hole, outerNode) { + var p = outerNode, hx = hole.x, hy = hole.y, qx = -Infinity, m; + do { + if (hy <= p.y && hy >= p.next.y) { + var x = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y); + if (x <= hx && x > qx) { + qx = x; + if (x === hx) { + if (hy === p.y) return p; + if (hy === p.next.y) return p.next; + } + m = p.x < p.next.x ? p : p.next; + } + } + p = p.next; + } while (p !== outerNode); + if (!m) return null; + if (hx === qx) return m.prev; + var stop = m, mx = m.x, my = m.y, tanMin = Infinity, tan; + p = m.next; + while (p !== stop) { + if (hx >= p.x && p.x >= mx && pointInTriangle(hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p.x, p.y)) { + tan = Math.abs(hy - p.y) / (hx - p.x); + if ((tan < tanMin || tan === tanMin && p.x > m.x) && locallyInside(p, hole)) { + m = p; + tanMin = tan; + } + } + p = p.next; + } + return m; + } + function indexCurve(start, minX, minY, size) { + var p = start; + do { + null === p.z && (p.z = zOrder(p.x, p.y, minX, minY, size)); + p.prevZ = p.prev; + p.nextZ = p.next; + p = p.next; + } while (p !== start); + p.prevZ.nextZ = null; + p.prevZ = null; + sortLinked(p); + } + function sortLinked(list) { + var i, p, q, e, tail, numMerges, pSize, qSize, inSize = 1; + do { + p = list; + list = null; + tail = null; + numMerges = 0; + while (p) { + numMerges++; + q = p; + pSize = 0; + for (i = 0; i < inSize; i++) { + pSize++; + q = q.nextZ; + if (!q) break; + } + qSize = inSize; + while (pSize > 0 || qSize > 0 && q) { + if (0 === pSize) { + e = q; + q = q.nextZ; + qSize--; + } else if (0 !== qSize && q) if (p.z <= q.z) { + e = p; + p = p.nextZ; + pSize--; + } else { + e = q; + q = q.nextZ; + qSize--; + } else { + e = p; + p = p.nextZ; + pSize--; + } + tail ? tail.nextZ = e : list = e; + e.prevZ = tail; + tail = e; + } + p = q; + } + tail.nextZ = null; + inSize *= 2; + } while (numMerges > 1); + return list; + } + function zOrder(x, y, minX, minY, size) { + x = 32767 * (x - minX) / size; + y = 32767 * (y - minY) / size; + x = 16711935 & (x | x << 8); + x = 252645135 & (x | x << 4); + x = 858993459 & (x | x << 2); + x = 1431655765 & (x | x << 1); + y = 16711935 & (y | y << 8); + y = 252645135 & (y | y << 4); + y = 858993459 & (y | y << 2); + y = 1431655765 & (y | y << 1); + return x | y << 1; + } + function getLeftmost(start) { + var p = start, leftmost = start; + do { + p.x < leftmost.x && (leftmost = p); + p = p.next; + } while (p !== start); + return leftmost; + } + function pointInTriangle(ax, ay, bx, by, cx, cy, px, py) { + return (cx - px) * (ay - py) - (ax - px) * (cy - py) >= 0 && (ax - px) * (by - py) - (bx - px) * (ay - py) >= 0 && (bx - px) * (cy - py) - (cx - px) * (by - py) >= 0; + } + function isValidDiagonal(a, b) { + return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) && locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b); + } + function area(p, q, r) { + return (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y); + } + function equals(p1, p2) { + return p1.x === p2.x && p1.y === p2.y; + } + function intersects(p1, q1, p2, q2) { + if (equals(p1, q1) && equals(p2, q2) || equals(p1, q2) && equals(p2, q1)) return true; + return area(p1, q1, p2) > 0 !== area(p1, q1, q2) > 0 && area(p2, q2, p1) > 0 !== area(p2, q2, q1) > 0; + } + function intersectsPolygon(a, b) { + var p = a; + do { + if (p.i !== a.i && p.next.i !== a.i && p.i !== b.i && p.next.i !== b.i && intersects(p, p.next, a, b)) return true; + p = p.next; + } while (p !== a); + return false; + } + function locallyInside(a, b) { + return area(a.prev, a, a.next) < 0 ? area(a, b, a.next) >= 0 && area(a, a.prev, b) >= 0 : area(a, b, a.prev) < 0 || area(a, a.next, b) < 0; + } + function middleInside(a, b) { + var p = a, inside = false, px = (a.x + b.x) / 2, py = (a.y + b.y) / 2; + do { + p.y > py !== p.next.y > py && px < (p.next.x - p.x) * (py - p.y) / (p.next.y - p.y) + p.x && (inside = !inside); + p = p.next; + } while (p !== a); + return inside; + } + function splitPolygon(a, b) { + var a2 = new Node(a.i, a.x, a.y), b2 = new Node(b.i, b.x, b.y), an = a.next, bp = b.prev; + a.next = b; + b.prev = a; + a2.next = an; + an.prev = a2; + b2.next = a2; + a2.prev = b2; + bp.next = b2; + b2.prev = bp; + return b2; + } + function insertNode(i, x, y, last) { + var p = new Node(i, x, y); + if (last) { + p.next = last.next; + p.prev = last; + last.next.prev = p; + last.next = p; + } else { + p.prev = p; + p.next = p; + } + return p; + } + function removeNode(p) { + p.next.prev = p.prev; + p.prev.next = p.next; + p.prevZ && (p.prevZ.nextZ = p.nextZ); + p.nextZ && (p.nextZ.prevZ = p.prevZ); + } + function Node(i, x, y) { + this.i = i; + this.x = x; + this.y = y; + this.prev = null; + this.next = null; + this.z = null; + this.prevZ = null; + this.nextZ = null; + this.steiner = false; + } + earcut.deviation = function(data, holeIndices, dim, triangles) { + var hasHoles = holeIndices && holeIndices.length; + var outerLen = hasHoles ? holeIndices[0] * dim : data.length; + var polygonArea = Math.abs(signedArea(data, 0, outerLen, dim)); + if (hasHoles) for (var i = 0, len = holeIndices.length; i < len; i++) { + var start = holeIndices[i] * dim; + var end = i < len - 1 ? holeIndices[i + 1] * dim : data.length; + polygonArea -= Math.abs(signedArea(data, start, end, dim)); + } + var trianglesArea = 0; + for (i = 0; i < triangles.length; i += 3) { + var a = triangles[i] * dim; + var b = triangles[i + 1] * dim; + var c = triangles[i + 2] * dim; + trianglesArea += Math.abs((data[a] - data[c]) * (data[b + 1] - data[a + 1]) - (data[a] - data[b]) * (data[c + 1] - data[a + 1])); + } + return 0 === polygonArea && 0 === trianglesArea ? 0 : Math.abs((trianglesArea - polygonArea) / polygonArea); + }; + function signedArea(data, start, end, dim) { + var sum = 0; + for (var i = start, j = end - dim; i < end; i += dim) { + sum += (data[j] - data[i]) * (data[i + 1] + data[j + 1]); + j = i; + } + return sum; + } + earcut.flatten = function(data) { + var dim = data[0][0].length, result = { + vertices: [], + holes: [], + dimensions: dim + }, holeIndex = 0; + for (var i = 0; i < data.length; i++) { + for (var j = 0; j < data[i].length; j++) for (var d = 0; d < dim; d++) result.vertices.push(data[i][j][d]); + if (i > 0) { + holeIndex += data[i - 1].length; + result.holes.push(holeIndex); + } + } + return result; + }; + }), {} ], + 282: [ (function(require, module, exports) { + "use strict"; + var Helper = require("../../../../graphics/helper"); + var PointFlags = require("../../../../graphics/types").PointFlags; + var Point = cc.Graphics.Point = cc.Class({ + name: "cc.GraphicsPoint", + extends: cc.Vec2, + ctor: function ctor(x, y) { + this.reset(); + }, + reset: function reset() { + this.dx = 0; + this.dy = 0; + this.dmx = 0; + this.dmy = 0; + this.flags = 0; + this.len = 0; + } + }); + function Path() { + this.reset(); + } + cc.js.mixin(Path.prototype, { + reset: function reset() { + this.closed = false; + this.nbevel = 0; + this.complex = true; + this.points ? this.points.length = 0 : this.points = []; + } + }); + function Impl(graphics) { + this._tessTol = .25; + this._distTol = .01; + this._updatePathOffset = false; + this._paths = null; + this._pathLength = 0; + this._pathOffset = 0; + this._points = null; + this._pointsOffset = 0; + this._commandx = 0; + this._commandy = 0; + this._paths = []; + this._points = []; + } + cc.js.mixin(Impl.prototype, { + moveTo: function moveTo(x, y) { + if (this._updatePathOffset) { + this._pathOffset = this._pathLength; + this._updatePathOffset = false; + } + this._addPath(); + this._addPoint(x, y, PointFlags.PT_CORNER); + this._commandx = x; + this._commandy = y; + }, + lineTo: function lineTo(x, y) { + this._addPoint(x, y, PointFlags.PT_CORNER); + this._commandx = x; + this._commandy = y; + }, + bezierCurveTo: function bezierCurveTo(c1x, c1y, c2x, c2y, x, y) { + var path = this._curPath; + var last = path.points[path.points.length - 1]; + if (last.x === c1x && last.y === c1y && c2x === x && c2y === y) { + this.lineTo(x, y); + return; + } + Helper.tesselateBezier(this, last.x, last.y, c1x, c1y, c2x, c2y, x, y, 0, PointFlags.PT_CORNER); + this._commandx = x; + this._commandy = y; + }, + quadraticCurveTo: function quadraticCurveTo(cx, cy, x, y) { + var x0 = this._commandx; + var y0 = this._commandy; + this.bezierCurveTo(x0 + 2 / 3 * (cx - x0), y0 + 2 / 3 * (cy - y0), x + 2 / 3 * (cx - x), y + 2 / 3 * (cy - y), x, y); + }, + arc: function arc(cx, cy, r, startAngle, endAngle, counterclockwise) { + Helper.arc(this, cx, cy, r, startAngle, endAngle, counterclockwise); + }, + ellipse: function ellipse(cx, cy, rx, ry) { + Helper.ellipse(this, cx, cy, rx, ry); + this._curPath.complex = false; + }, + circle: function circle(cx, cy, r) { + Helper.ellipse(this, cx, cy, r, r); + this._curPath.complex = false; + }, + rect: function rect(x, y, w, h) { + this.moveTo(x, y); + this.lineTo(x, y + h); + this.lineTo(x + w, y + h); + this.lineTo(x + w, y); + this.close(); + this._curPath.complex = false; + }, + roundRect: function roundRect(x, y, w, h, r) { + Helper.roundRect(this, x, y, w, h, r); + this._curPath.complex = false; + }, + clear: function clear(clean) { + this._pathLength = 0; + this._pathOffset = 0; + this._pointsOffset = 0; + this._curPath = null; + if (clean) { + this._paths.length = 0; + this._points.length = 0; + } + }, + close: function close() { + this._curPath.closed = true; + }, + _addPath: function _addPath() { + var offset = this._pathLength; + var path = this._paths[offset]; + if (path) path.reset(); else { + path = new Path(); + this._paths.push(path); + } + this._pathLength++; + this._curPath = path; + return path; + }, + _addPoint: function _addPoint(x, y, flags) { + var path = this._curPath; + if (!path) return; + var pt; + var points = this._points; + var pathPoints = path.points; + var offset = this._pointsOffset++; + pt = points[offset]; + if (pt) { + pt.x = x; + pt.y = y; + } else { + pt = new Point(x, y); + points.push(pt); + } + pt.flags = flags; + pathPoints.push(pt); + } + }); + cc.Graphics._Impl = Impl; + module.exports = Impl; + }), { + "../../../../graphics/helper": 204, + "../../../../graphics/types": 206 + } ], + 283: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _assembler = _interopRequireDefault(require("../../../assembler")); + var _inputAssembler = _interopRequireDefault(require("../../../../../renderer/core/input-assembler")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + _setPrototypeOf(subClass, superClass); + } + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + return _setPrototypeOf(o, p); + } + var MeshBuffer = require("../../mesh-buffer"); + var renderer = require("../../../index"); + var Graphics = require("../../../../graphics/graphics"); + var PointFlags = require("../../../../graphics/types").PointFlags; + var LineJoin = Graphics.LineJoin; + var LineCap = Graphics.LineCap; + var Earcut = require("./earcut"); + require("./impl"); + var MAX_VERTEX = 65535; + var MAX_INDICE = 2 * MAX_VERTEX; + var PI = Math.PI; + var min = Math.min; + var max = Math.max; + var ceil = Math.ceil; + var acos = Math.acos; + var cos = Math.cos; + var sin = Math.sin; + var atan2 = Math.atan2; + function curveDivs(r, arc, tol) { + var da = 2 * acos(r / (r + tol)); + return max(2, ceil(arc / da)); + } + function clamp(v, min, max) { + if (v < min) return min; + if (v > max) return max; + return v; + } + var gfx = cc.gfx; + var vfmtPosColorSdf = new gfx.VertexFormat([ { + name: gfx.ATTR_POSITION, + type: gfx.ATTR_TYPE_FLOAT32, + num: 2 + }, { + name: gfx.ATTR_COLOR, + type: gfx.ATTR_TYPE_UINT8, + num: 4, + normalize: true + }, { + name: "a_dist", + type: gfx.ATTR_TYPE_FLOAT32, + num: 1 + } ]); + vfmtPosColorSdf.name = "vfmtPosColorSdf"; + var GraphicsAssembler = (function(_Assembler) { + _inheritsLoose(GraphicsAssembler, _Assembler); + function GraphicsAssembler(graphics) { + var _this; + _this = _Assembler.call(this, graphics) || this; + _this._buffer = null; + _this._buffers = []; + _this._bufferOffset = 0; + return _this; + } + var _proto = GraphicsAssembler.prototype; + _proto.getVfmt = function getVfmt() { + return vfmtPosColorSdf; + }; + _proto.getVfmtFloatCount = function getVfmtFloatCount() { + return 4; + }; + _proto.requestBuffer = function requestBuffer() { + var buffer = { + indiceStart: 0, + vertexStart: 0 + }; + var meshbuffer = new MeshBuffer(renderer._handle, this.getVfmt()); + buffer.meshbuffer = meshbuffer; + var ia = new _inputAssembler["default"](meshbuffer._vb, meshbuffer._ib); + buffer.ia = ia; + this._buffers.push(buffer); + return buffer; + }; + _proto.getBuffers = function getBuffers() { + 0 === this._buffers.length && this.requestBuffer(); + return this._buffers; + }; + _proto.clear = function clear(clean) { + this._bufferOffset = 0; + var datas = this._buffers; + if (clean) { + for (var i = 0, l = datas.length; i < l; i++) { + var data = datas[i]; + data.meshbuffer.destroy(); + data.meshbuffer = null; + } + datas.length = 0; + } else for (var _i = 0, _l = datas.length; _i < _l; _i++) { + var _data = datas[_i]; + _data.indiceStart = 0; + _data.vertexStart = 0; + var meshbuffer = _data.meshbuffer; + meshbuffer.reset(); + } + }; + _proto.fillBuffers = function fillBuffers(graphics, renderer) { + renderer._flush(); + renderer.node = graphics.node; + renderer.material = graphics._materials[0]; + var buffers = this.getBuffers(); + for (var index = 0, length = buffers.length; index < length; index++) { + var buffer = buffers[index]; + var meshbuffer = buffer.meshbuffer; + buffer.ia._count = buffer.indiceStart; + renderer._flushIA(buffer.ia); + meshbuffer.uploadData(); + } + }; + _proto.genBuffer = function genBuffer(graphics, cverts) { + var buffers = this.getBuffers(); + var buffer = buffers[this._bufferOffset]; + var meshbuffer = buffer.meshbuffer; + var maxVertsCount = buffer.vertexStart + cverts; + if (maxVertsCount > MAX_VERTEX || 3 * maxVertsCount > MAX_INDICE) { + ++this._bufferOffset; + maxVertsCount = cverts; + if (this._bufferOffset < buffers.length) buffer = buffers[this._bufferOffset]; else { + buffer = this.requestBuffer(graphics); + buffers[this._bufferOffset] = buffer; + } + meshbuffer = buffer.meshbuffer; + } + maxVertsCount > meshbuffer.vertexOffset && meshbuffer.requestStatic(cverts, 3 * cverts); + this._buffer = buffer; + return buffer; + }; + _proto.stroke = function stroke(graphics) { + this._curColor = graphics._strokeColor._val; + this._flattenPaths(graphics._impl); + this._expandStroke(graphics); + graphics._impl._updatePathOffset = true; + }; + _proto.fill = function fill(graphics) { + this._curColor = graphics._fillColor._val; + this._expandFill(graphics); + graphics._impl._updatePathOffset = true; + }; + _proto._expandStroke = function _expandStroke(graphics) { + var w = .5 * graphics.lineWidth, lineCap = graphics.lineCap, lineJoin = graphics.lineJoin, miterLimit = graphics.miterLimit; + var impl = graphics._impl; + var ncap = curveDivs(w, PI, impl._tessTol); + this._calculateJoins(impl, w, lineJoin, miterLimit); + var paths = impl._paths; + var cverts = 0; + for (var i = impl._pathOffset, l = impl._pathLength; i < l; i++) { + var path = paths[i]; + var pointsLength = path.points.length; + lineJoin === LineJoin.ROUND ? cverts += 2 * (pointsLength + path.nbevel * (ncap + 2) + 1) : cverts += 2 * (pointsLength + 5 * path.nbevel + 1); + path.closed || (lineCap === LineCap.ROUND ? cverts += 2 * (2 * ncap + 2) : cverts += 12); + } + var buffer = this.genBuffer(graphics, cverts), meshbuffer = buffer.meshbuffer, vData = meshbuffer._vData, iData = meshbuffer._iData; + for (var _i2 = impl._pathOffset, _l2 = impl._pathLength; _i2 < _l2; _i2++) { + var _path = paths[_i2]; + var pts = _path.points; + var _pointsLength = pts.length; + var offset = buffer.vertexStart; + var p0 = void 0, p1 = void 0; + var start = void 0, end = void 0, loop = void 0; + loop = _path.closed; + if (loop) { + p0 = pts[_pointsLength - 1]; + p1 = pts[0]; + start = 0; + end = _pointsLength; + } else { + p0 = pts[0]; + p1 = pts[1]; + start = 1; + end = _pointsLength - 1; + } + p1 = p1 || p0; + if (!loop) { + var dPos = p1.sub(p0); + dPos.normalizeSelf(); + var dx = dPos.x; + var dy = dPos.y; + lineCap === LineCap.BUTT ? this._buttCapStart(p0, dx, dy, w, 0) : lineCap === LineCap.SQUARE ? this._buttCapStart(p0, dx, dy, w, w) : lineCap === LineCap.ROUND && this._roundCapStart(p0, dx, dy, w, ncap); + } + for (var j = start; j < end; ++j) { + if (lineJoin === LineJoin.ROUND) this._roundJoin(p0, p1, w, w, ncap); else if (0 !== (p1.flags & (PointFlags.PT_BEVEL | PointFlags.PT_INNERBEVEL))) this._bevelJoin(p0, p1, w, w); else { + this._vset(p1.x + p1.dmx * w, p1.y + p1.dmy * w, 1); + this._vset(p1.x - p1.dmx * w, p1.y - p1.dmy * w, -1); + } + p0 = p1; + p1 = pts[j + 1]; + } + if (loop) { + var floatCount = this.getVfmtFloatCount(); + var vDataoOfset = offset * floatCount; + this._vset(vData[vDataoOfset], vData[vDataoOfset + 1], 1); + this._vset(vData[vDataoOfset + floatCount], vData[vDataoOfset + floatCount + 1], -1); + } else { + var _dPos = p1.sub(p0); + _dPos.normalizeSelf(); + var _dx = _dPos.x; + var _dy = _dPos.y; + lineCap === LineCap.BUTT ? this._buttCapEnd(p1, _dx, _dy, w, 0) : lineCap === LineCap.SQUARE ? this._buttCapEnd(p1, _dx, _dy, w, w) : lineCap === LineCap.ROUND && this._roundCapEnd(p1, _dx, _dy, w, ncap); + } + var indicesOffset = buffer.indiceStart; + for (var _start = offset + 2, _end = buffer.vertexStart; _start < _end; _start++) { + iData[indicesOffset++] = _start - 2; + iData[indicesOffset++] = _start - 1; + iData[indicesOffset++] = _start; + } + buffer.indiceStart = indicesOffset; + } + }; + _proto._expandFill = function _expandFill(graphics) { + var impl = graphics._impl; + var paths = impl._paths; + var cverts = 0; + for (var i = impl._pathOffset, l = impl._pathLength; i < l; i++) { + var path = paths[i]; + var pointsLength = path.points.length; + cverts += pointsLength; + } + var buffer = this.genBuffer(graphics, cverts), meshbuffer = buffer.meshbuffer, vData = meshbuffer._vData, iData = meshbuffer._iData; + for (var _i3 = impl._pathOffset, _l3 = impl._pathLength; _i3 < _l3; _i3++) { + var _path2 = paths[_i3]; + var pts = _path2.points; + var _pointsLength2 = pts.length; + if (0 === _pointsLength2) continue; + var offset = buffer.vertexStart; + for (var j = 0; j < _pointsLength2; ++j) this._vset(pts[j].x, pts[j].y); + var indicesOffset = buffer.indiceStart; + if (_path2.complex) { + var earcutData = []; + var floatCount = this.getVfmtFloatCount(); + for (var _j = offset, end = buffer.vertexStart; _j < end; _j++) { + var vDataOffset = _j * floatCount; + earcutData.push(vData[vDataOffset]); + earcutData.push(vData[vDataOffset + 1]); + } + var newIndices = Earcut(earcutData, null, 2); + if (!newIndices || 0 === newIndices.length) continue; + for (var _j2 = 0, nIndices = newIndices.length; _j2 < nIndices; _j2++) iData[indicesOffset++] = newIndices[_j2] + offset; + } else { + var first = offset; + for (var start = offset + 2, _end2 = buffer.vertexStart; start < _end2; start++) { + iData[indicesOffset++] = first; + iData[indicesOffset++] = start - 1; + iData[indicesOffset++] = start; + } + } + buffer.indiceStart = indicesOffset; + } + }; + _proto._calculateJoins = function _calculateJoins(impl, w, lineJoin, miterLimit) { + var iw = 0; + var w2 = w * w; + w > 0 && (iw = 1 / w); + var paths = impl._paths; + for (var i = impl._pathOffset, l = impl._pathLength; i < l; i++) { + var path = paths[i]; + var pts = path.points; + var ptsLength = pts.length; + var p0 = pts[ptsLength - 1]; + var p1 = pts[0]; + var nleft = 0; + path.nbevel = 0; + for (var j = 0; j < ptsLength; j++) { + var dmr2 = void 0, cross = void 0, limit = void 0; + var dlx0 = p0.dy; + var dly0 = -p0.dx; + var dlx1 = p1.dy; + var dly1 = -p1.dx; + p1.dmx = .5 * (dlx0 + dlx1); + p1.dmy = .5 * (dly0 + dly1); + dmr2 = p1.dmx * p1.dmx + p1.dmy * p1.dmy; + if (dmr2 > 1e-6) { + var scale = 1 / dmr2; + scale > 600 && (scale = 600); + p1.dmx *= scale; + p1.dmy *= scale; + } + cross = p1.dx * p0.dy - p0.dx * p1.dy; + if (cross > 0) { + nleft++; + p1.flags |= PointFlags.PT_LEFT; + } + limit = max(11, min(p0.len, p1.len) * iw); + dmr2 * limit * limit < 1 && (p1.flags |= PointFlags.PT_INNERBEVEL); + var dmwx = p1.dmx * w; + var dmwy = p1.dmy * w; + var dmlen2 = dmwx * dmwx + dmwy * dmwy; + dmlen2 > p1.len * p1.len + w2 && dmlen2 > p0.len * p0.len + w2 && (p1.flags |= PointFlags.PT_INNERBEVEL); + p1.flags & PointFlags.PT_CORNER && (dmr2 * miterLimit * miterLimit < 1 || lineJoin === LineJoin.BEVEL || lineJoin === LineJoin.ROUND) && (p1.flags |= PointFlags.PT_BEVEL); + 0 !== (p1.flags & (PointFlags.PT_BEVEL | PointFlags.PT_INNERBEVEL)) && path.nbevel++; + p0 = p1; + p1 = pts[j + 1]; + } + } + }; + _proto._flattenPaths = function _flattenPaths(impl) { + var paths = impl._paths; + for (var i = impl._pathOffset, l = impl._pathLength; i < l; i++) { + var path = paths[i]; + var pts = path.points; + var p0 = pts[pts.length - 1]; + var p1 = pts[0]; + if (pts.length > 2 && p0.equals(p1)) { + path.closed = true; + pts.pop(); + p0 = pts[pts.length - 1]; + } + for (var j = 0, size = pts.length; j < size; j++) { + var dPos = p1.sub(p0); + p0.len = dPos.mag(); + (dPos.x || dPos.y) && dPos.normalizeSelf(); + p0.dx = dPos.x; + p0.dy = dPos.y; + p0 = p1; + p1 = pts[j + 1]; + } + } + }; + _proto._chooseBevel = function _chooseBevel(bevel, p0, p1, w) { + var x = p1.x; + var y = p1.y; + var x0, y0, x1, y1; + if (0 !== bevel) { + x0 = x + p0.dy * w; + y0 = y - p0.dx * w; + x1 = x + p1.dy * w; + y1 = y - p1.dx * w; + } else { + x0 = x1 = x + p1.dmx * w; + y0 = y1 = y + p1.dmy * w; + } + return [ x0, y0, x1, y1 ]; + }; + _proto._buttCapStart = function _buttCapStart(p, dx, dy, w, d) { + var px = p.x - dx * d; + var py = p.y - dy * d; + var dlx = dy; + var dly = -dx; + this._vset(px + dlx * w, py + dly * w, 1); + this._vset(px - dlx * w, py - dly * w, -1); + }; + _proto._buttCapEnd = function _buttCapEnd(p, dx, dy, w, d) { + var px = p.x + dx * d; + var py = p.y + dy * d; + var dlx = dy; + var dly = -dx; + this._vset(px + dlx * w, py + dly * w, 1); + this._vset(px - dlx * w, py - dly * w, -1); + }; + _proto._roundCapStart = function _roundCapStart(p, dx, dy, w, ncap) { + var px = p.x; + var py = p.y; + var dlx = dy; + var dly = -dx; + for (var i = 0; i < ncap; i++) { + var a = i / (ncap - 1) * PI; + var ax = cos(a) * w, ay = sin(a) * w; + this._vset(px - dlx * ax - dx * ay, py - dly * ax - dy * ay, 1); + this._vset(px, py, 0); + } + this._vset(px + dlx * w, py + dly * w, 1); + this._vset(px - dlx * w, py - dly * w, -1); + }; + _proto._roundCapEnd = function _roundCapEnd(p, dx, dy, w, ncap) { + var px = p.x; + var py = p.y; + var dlx = dy; + var dly = -dx; + this._vset(px + dlx * w, py + dly * w, 1); + this._vset(px - dlx * w, py - dly * w, -1); + for (var i = 0; i < ncap; i++) { + var a = i / (ncap - 1) * PI; + var ax = cos(a) * w, ay = sin(a) * w; + this._vset(px, py, 0); + this._vset(px - dlx * ax + dx * ay, py - dly * ax + dy * ay, 1); + } + }; + _proto._roundJoin = function _roundJoin(p0, p1, lw, rw, ncap) { + var dlx0 = p0.dy; + var dly0 = -p0.dx; + var dlx1 = p1.dy; + var dly1 = -p1.dx; + var p1x = p1.x; + var p1y = p1.y; + if (0 !== (p1.flags & PointFlags.PT_LEFT)) { + var out = this._chooseBevel(p1.flags & PointFlags.PT_INNERBEVEL, p0, p1, lw); + var lx0 = out[0]; + var ly0 = out[1]; + var lx1 = out[2]; + var ly1 = out[3]; + var a0 = atan2(-dly0, -dlx0); + var a1 = atan2(-dly1, -dlx1); + a1 > a0 && (a1 -= 2 * PI); + this._vset(lx0, ly0, 1); + this._vset(p1x - dlx0 * rw, p1.y - dly0 * rw, -1); + var n = clamp(ceil((a0 - a1) / PI) * ncap, 2, ncap); + for (var i = 0; i < n; i++) { + var u = i / (n - 1); + var a = a0 + u * (a1 - a0); + var rx = p1x + cos(a) * rw; + var ry = p1y + sin(a) * rw; + this._vset(p1x, p1y, 0); + this._vset(rx, ry, -1); + } + this._vset(lx1, ly1, 1); + this._vset(p1x - dlx1 * rw, p1y - dly1 * rw, -1); + } else { + var _out = this._chooseBevel(p1.flags & PointFlags.PT_INNERBEVEL, p0, p1, -rw); + var rx0 = _out[0]; + var ry0 = _out[1]; + var rx1 = _out[2]; + var ry1 = _out[3]; + var _a = atan2(dly0, dlx0); + var _a2 = atan2(dly1, dlx1); + _a2 < _a && (_a2 += 2 * PI); + this._vset(p1x + dlx0 * rw, p1y + dly0 * rw, 1); + this._vset(rx0, ry0, -1); + var _n = clamp(ceil((_a2 - _a) / PI) * ncap, 2, ncap); + for (var _i4 = 0; _i4 < _n; _i4++) { + var _u = _i4 / (_n - 1); + var _a3 = _a + _u * (_a2 - _a); + var lx = p1x + cos(_a3) * lw; + var ly = p1y + sin(_a3) * lw; + this._vset(lx, ly, 1); + this._vset(p1x, p1y, 0); + } + this._vset(p1x + dlx1 * rw, p1y + dly1 * rw, 1); + this._vset(rx1, ry1, -1); + } + }; + _proto._bevelJoin = function _bevelJoin(p0, p1, lw, rw) { + var rx0, ry0, rx1, ry1; + var lx0, ly0, lx1, ly1; + var dlx0 = p0.dy; + var dly0 = -p0.dx; + var dlx1 = p1.dy; + var dly1 = -p1.dx; + if (p1.flags & PointFlags.PT_LEFT) { + var out = this._chooseBevel(p1.flags & PointFlags.PT_INNERBEVEL, p0, p1, lw); + lx0 = out[0]; + ly0 = out[1]; + lx1 = out[2]; + ly1 = out[3]; + this._vset(lx0, ly0, 1); + this._vset(p1.x - dlx0 * rw, p1.y - dly0 * rw, -1); + this._vset(lx1, ly1, 1); + this._vset(p1.x - dlx1 * rw, p1.y - dly1 * rw, -1); + } else { + var _out2 = this._chooseBevel(p1.flags & PointFlags.PT_INNERBEVEL, p0, p1, -rw); + rx0 = _out2[0]; + ry0 = _out2[1]; + rx1 = _out2[2]; + ry1 = _out2[3]; + this._vset(p1.x + dlx0 * lw, p1.y + dly0 * lw, 1); + this._vset(rx0, ry0, -1); + this._vset(p1.x + dlx1 * lw, p1.y + dly1 * lw, 1); + this._vset(rx1, ry1, -1); + } + }; + _proto._vset = function _vset(x, y, distance) { + void 0 === distance && (distance = 0); + var buffer = this._buffer; + var meshbuffer = buffer.meshbuffer; + var dataOffset = buffer.vertexStart * this.getVfmtFloatCount(); + var vData = meshbuffer._vData; + var uintVData = meshbuffer._uintVData; + vData[dataOffset] = x; + vData[dataOffset + 1] = y; + uintVData[dataOffset + 2] = this._curColor; + vData[dataOffset + 3] = distance; + buffer.vertexStart++; + meshbuffer._dirty = true; + }; + return GraphicsAssembler; + })(_assembler["default"]); + exports["default"] = GraphicsAssembler; + _assembler["default"].register(cc.Graphics, GraphicsAssembler); + module.exports = exports["default"]; + }), { + "../../../../../renderer/core/input-assembler": 363, + "../../../../graphics/graphics": 203, + "../../../../graphics/types": 206, + "../../../assembler": 269, + "../../../index": 272, + "../../mesh-buffer": 309, + "./earcut": 281, + "./impl": 282 + } ], + 284: [ (function(require, module, exports) { + "use strict"; + cc.assemblers = {}; + require("./sprite"); + require("./mask-assembler"); + require("./graphics"); + require("./label"); + require("./motion-streak"); + }), { + "./graphics": 283, + "./label": 292, + "./mask-assembler": 293, + "./motion-streak": 294, + "./sprite": 307 + } ], + 285: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _bmfont = _interopRequireDefault(require("../../../../utils/label/bmfont")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + _setPrototypeOf(subClass, superClass); + } + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + return _setPrototypeOf(o, p); + } + var _dataOffset = 0; + var WebglBmfontAssembler = (function(_BmfontAssembler) { + _inheritsLoose(WebglBmfontAssembler, _BmfontAssembler); + function WebglBmfontAssembler() { + return _BmfontAssembler.apply(this, arguments) || this; + } + var _proto = WebglBmfontAssembler.prototype; + _proto.initData = function initData() { + this._renderData.createFlexData(0, 4, 6, this.getVfmt()); + }; + _proto._reserveQuads = function _reserveQuads(comp, count) { + var verticesCount = 4 * count; + var indicesCount = 6 * count; + var flexBuffer = this._renderData._flexBuffer; + flexBuffer.reserve(verticesCount, indicesCount); + flexBuffer.used(verticesCount, indicesCount); + var iData = this._renderData.iDatas[0]; + for (var i = 0, vid = 0, l = indicesCount; i < l; i += 6, vid += 4) { + iData[i] = vid; + iData[i + 1] = vid + 1; + iData[i + 2] = vid + 2; + iData[i + 3] = vid + 1; + iData[i + 4] = vid + 3; + iData[i + 5] = vid + 2; + } + _dataOffset = 0; + }; + _proto._quadsUpdated = function _quadsUpdated(comp) { + _dataOffset = 0; + var flexBuffer = this._renderData._flexBuffer; + flexBuffer.used(this.verticesCount, this.indicesCount); + }; + _proto._getColor = function _getColor(comp) { + return comp.node._color._val; + }; + _proto.appendQuad = function appendQuad(comp, texture, rect, rotated, x, y, scale) { + var renderData = this._renderData; + var verts = renderData.vDatas[0], uintVerts = renderData.uintVDatas[0]; + this.verticesCount += 4; + this.indicesCount = this.verticesCount / 2 * 3; + var texw = texture.width, texh = texture.height, rectWidth = rect.width, rectHeight = rect.height, color = this._getColor(comp); + var l, b, r, t; + var floatsPerVert = this.floatsPerVert; + var uvDataOffset = _dataOffset + this.uvOffset; + if (rotated) { + l = rect.x / texw; + r = (rect.x + rectHeight) / texw; + b = (rect.y + rectWidth) / texh; + t = rect.y / texh; + verts[uvDataOffset] = l; + verts[uvDataOffset + 1] = t; + uvDataOffset += floatsPerVert; + verts[uvDataOffset] = l; + verts[uvDataOffset + 1] = b; + uvDataOffset += floatsPerVert; + verts[uvDataOffset] = r; + verts[uvDataOffset + 1] = t; + uvDataOffset += floatsPerVert; + verts[uvDataOffset] = r; + verts[uvDataOffset + 1] = b; + } else { + l = rect.x / texw; + r = (rect.x + rectWidth) / texw; + b = (rect.y + rectHeight) / texh; + t = rect.y / texh; + verts[uvDataOffset] = l; + verts[uvDataOffset + 1] = b; + uvDataOffset += floatsPerVert; + verts[uvDataOffset] = r; + verts[uvDataOffset + 1] = b; + uvDataOffset += floatsPerVert; + verts[uvDataOffset] = l; + verts[uvDataOffset + 1] = t; + uvDataOffset += floatsPerVert; + verts[uvDataOffset] = r; + verts[uvDataOffset + 1] = t; + } + l = x; + r = x + rectWidth * scale; + b = y - rectHeight * scale; + t = y; + this.appendVerts(comp, _dataOffset, l, r, b, t); + var colorOffset = _dataOffset + this.colorOffset; + for (var i = 0; i < 4; i++) { + uintVerts[colorOffset] = color; + colorOffset += floatsPerVert; + } + _dataOffset += 4 * this.floatsPerVert; + }; + _proto.appendVerts = function appendVerts(comp, offset, l, r, b, t) { + var local = this._local; + var floatsPerVert = this.floatsPerVert; + local[offset] = l; + local[offset + 1] = b; + offset += floatsPerVert; + local[offset] = r; + local[offset + 1] = b; + offset += floatsPerVert; + local[offset] = l; + local[offset + 1] = t; + offset += floatsPerVert; + local[offset] = r; + local[offset + 1] = t; + }; + _proto.updateWorldVerts = function updateWorldVerts(comp) { + var node = comp.node; + var matrix = node._worldMatrix; + var matrixm = matrix.m, a = matrixm[0], b = matrixm[1], c = matrixm[4], d = matrixm[5], tx = matrixm[12], ty = matrixm[13]; + var local = this._local; + var world = this._renderData.vDatas[0]; + var floatsPerVert = this.floatsPerVert; + for (var offset = 0; offset < local.length; offset += floatsPerVert) { + var x = local[offset]; + var y = local[offset + 1]; + world[offset] = x * a + y * c + tx; + world[offset + 1] = x * b + y * d + ty; + } + }; + return WebglBmfontAssembler; + })(_bmfont["default"]); + exports["default"] = WebglBmfontAssembler; + module.exports = exports["default"]; + }), { + "../../../../utils/label/bmfont": 276 + } ], + 286: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + _setPrototypeOf(subClass, superClass); + } + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + return _setPrototypeOf(o, p); + } + var js = require("../../../../../platform/js"); + var WebglBmfontAssembler = require("./bmfont"); + var LetterFontAssembler = require("../../../../utils/label/letter-font"); + var WHITE = cc.color(255, 255, 255, 255); + var WebglLetterFontAssembler = (function(_LetterFontAssembler) { + _inheritsLoose(WebglLetterFontAssembler, _LetterFontAssembler); + function WebglLetterFontAssembler() { + return _LetterFontAssembler.apply(this, arguments) || this; + } + var _proto = WebglLetterFontAssembler.prototype; + _proto.createData = function createData(comp) { + return comp.requestRenderData(); + }; + _proto._getColor = function _getColor(comp) { + WHITE._fastSetA(comp.node._color.a); + return WHITE._val; + }; + _proto.updateColor = function updateColor(comp) { + var color = this._getColor(comp); + _LetterFontAssembler.prototype.updateColor.call(this, comp, color); + }; + return WebglLetterFontAssembler; + })(LetterFontAssembler); + exports["default"] = WebglLetterFontAssembler; + module.exports = exports["default"]; + }), { + "../../../../../platform/js": 261, + "../../../../utils/label/letter-font": 278, + "./bmfont": 285 + } ], + 287: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _materialVariant = _interopRequireDefault(require("../../../../../assets/material/material-variant")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + var Label = require("../../../../../components/CCLabel"); + var LabelShadow = require("../../../../../components/CCLabelShadow"); + var LabelOutline = require("../../../../../components/CCLabelOutline"); + var Material = require("../../../../../assets/material/CCMaterial"); + var UPDATE_CONTENT = 1; + var UPDATE_FONT = 2; + var UPDATE_EFFECT = 4; + var NativeTTF = (function() { + function NativeTTF() {} + var _proto = NativeTTF.prototype; + _proto.init = function init(comp) { + this.labelMaterial = null; + this._label = this._renderComp = comp; + renderer.CustomAssembler.prototype.ctor.call(this); + comp.node._proxy.setAssembler(this); + this._layout = new jsb.LabelRenderer(); + this._layout.init(comp); + this._cfg = new DataView(this._layout._cfg); + this._layoutInfo = new DataView(this._layout._layout); + this._cfgFields = jsb.LabelRenderer._cfgFields; + this._layoutFields = jsb.LabelRenderer._layoutFields; + this._layout.bindNodeProxy(comp.node._proxy); + this._bindMaterial(comp); + }; + _proto._setBufferFlag = function _setBufferFlag(dv, offset, size, type, flag) { + if ("int8" == type && 1 == size) { + var v = dv.getInt8(offset); + dv.setInt8(offset, flag | v); + } else if ("int32" == type && 4 == size) { + var _v = dv.getInt32(offset, jsb.__isLittleEndian__); + dv.setInt32(offset, flag | _v, jsb.__isLittleEndian__); + } else cc.warn("flag storage type should be int8/int32 only, type/size -> " + type + "/" + size + "."); + }; + _proto._updateCfgFlag = function _updateCfgFlag(flag) { + var field = this._cfgFields.updateFlags; + this._setBufferFlag(this._cfg, field.offset, field.size, field.type, flag); + }; + _proto._setBufferValue = function _setBufferValue(dv, offset, size, type, value) { + if ("float" == type && 4 == size) dv.setFloat32(offset, value, jsb.__isLittleEndian__); else if ("int32" == type && 4 == size) dv.setInt32(offset, value, jsb.__isLittleEndian__); else if ("bool" == type && 1 == size) dv.setInt8(offset, !value ? 0 : 1, jsb.__isLittleEndian__); else if ("Color4B" == type && 4 == size) { + dv.setUint8(offset, value.r); + dv.setUint8(offset + 1, value.g); + dv.setUint8(offset + 2, value.b); + dv.setUint8(offset + 3, value.a); + } else "int8" == type && 1 == size ? dv.setUint8(offset, value) : cc.warn("dont know how to set value to buffer, type/size -> " + type + "/" + size + "."); + }; + _proto._setFieldValue = function _setFieldValue(dv, desc, field_name, value) { + var field = desc[field_name]; + this._setBufferValue(dv, field.offset, field.size, field.type, value); + }; + _proto._getBufferValue = function _getBufferValue(dv, offset, size, type) { + if ("float" == type && 4 == size) return dv.getFloat32(offset, jsb.__isLittleEndian__); + if ("int32" == type && 4 == size) return dv.getInt32(offset, jsb.__isLittleEndian__); + if ("bool" == type && 1 == size) return 0 != dv.getInt8(offset, jsb.__isLittleEndian__); + if ("Color4B" == type && 4 == size) { + var r = dv.getUint8(offset); + var g = dv.getUint8(offset + 1); + var b = dv.getUint8(offset + 2); + var a = dv.getUint8(offset + 3); + return { + r: r, + g: g, + b: b, + a: a + }; + } + if ("int8" == type && 1 == size) return dv.getUint8(offset); + cc.warn("dont know how to get value from buffer, type/size -> " + type + "/" + size + "."); + return; + }; + _proto._getFieldValue = function _getFieldValue(dv, desc, field_name) { + var field = desc[field_name]; + return this._getBufferValue(dv, field.offset, field.size, field.type); + }; + _proto._getLayoutValue = function _getLayoutValue(field_name) { + return this._getFieldValue(this._layoutInfo, this._layoutFields, field_name); + }; + _proto._setLayoutValue = function _setLayoutValue(field_name, value) { + return this._setFieldValue(this._layoutInfo, this._layoutFields, field_name, value); + }; + _proto._updateCfgFlag_Content = function _updateCfgFlag_Content() { + this._updateCfgFlag(UPDATE_CONTENT); + }; + _proto._updateCfgFlag_Font = function _updateCfgFlag_Font() { + this._updateCfgFlag(UPDATE_FONT); + }; + _proto._colorEqual = function _colorEqual(a, b) { + return a.r == b.r && a.g == b.g && a.b == b.b && a.a == b.a; + }; + _proto._colorToObj = function _colorToObj(r, g, b, a) { + return { + r: r, + g: g, + b: b, + a: a + }; + }; + _proto.setString = function setString(str) { + if (str != this._layout.string) { + this._layout.string = str; + this._updateCfgFlag_Content(); + } + }; + _proto.setFontPath = function setFontPath(path) { + if (path != this._layout.fontPath) { + this._layout.fontPath = path; + this._updateCfgFlag_Font(); + } + }; + _proto.setFontSize = function setFontSize(fontSize, fontSizeRetina) { + var oldfontsize = this._getFieldValue(this._cfg, this._cfgFields, "fontSize"); + if (oldfontsize != fontSize) { + this._setFieldValue(this._cfg, this._cfgFields, "fontSize", fontSize); + this._setFieldValue(this._cfg, this._cfgFields, "fontSizeRetina", fontSizeRetina); + this._updateCfgFlag_Font(); + } + }; + _proto.setOutline = function setOutline(outline) { + var oldOutline = this._getLayoutValue("outlineSize"); + oldOutline > 0 != outline > 0 && this._updateCfgFlag_Font(); + if (oldOutline != outline) { + this._updateCfgFlag_Content(); + this._setLayoutValue("outlineSize", outline); + } + }; + _proto.setOutlineColor = function setOutlineColor(color) { + var oldColor = this._getLayoutValue("outlineColor"); + if (!this._colorEqual(oldColor, color)) { + this._setLayoutValue("outlineColor", color); + this._updateCfgFlag_Content(); + } + }; + _proto.setLineHeight = function setLineHeight(lineHeight) { + var oldLineHeight = this._getLayoutValue("lineHeight"); + if (oldLineHeight != lineHeight) { + this._setLayoutValue("lineHeight", lineHeight); + this._updateCfgFlag_Content(); + } + }; + _proto.setOverFlow = function setOverFlow(overflow) { + var oldValue = this._getLayoutValue("overflow"); + if (oldValue != overflow) { + this._setLayoutValue("overflow", overflow); + this._updateCfgFlag_Content(); + } + }; + _proto.setEnableWrap = function setEnableWrap(value) { + var oldValue = this._getLayoutValue("wrap"); + if (oldValue != value) { + this._setLayoutValue("wrap", value); + this._updateCfgFlag_Content(); + } + }; + _proto.setVerticalAlign = function setVerticalAlign(value) { + var oldValue = this._getLayoutValue("valign"); + if (oldValue != value) { + this._setLayoutValue("valign", value); + this._updateCfgFlag_Content(); + } + }; + _proto.setHorizontalAlign = function setHorizontalAlign(value) { + var oldValue = this._getLayoutValue("halign"); + if (oldValue != value) { + this._setLayoutValue("halign", value); + this._updateCfgFlag_Content(); + } + }; + _proto.setContentSize = function setContentSize(width, height) { + var oldWidth = this._getLayoutValue("width"); + var oldHeight = this._getLayoutValue("height"); + if (oldWidth != width || oldHeight != height) { + this._setLayoutValue("height", height); + this._setLayoutValue("width", width); + this._updateCfgFlag_Content(); + } + }; + _proto.setAnchorPoint = function setAnchorPoint(x, y) { + var oldX = this._getLayoutValue("anchorX"); + var oldY = this._getLayoutValue("anchorY"); + if (oldX != x || oldY != y) { + this._setLayoutValue("anchorX", x); + this._setLayoutValue("anchorY", y); + this._updateCfgFlag_Content(); + } + }; + _proto.setColor = function setColor(color) { + var oldColor = this._getLayoutValue("color"); + if (!this._colorEqual(oldColor, color)) { + this._setLayoutValue("color", color); + this._updateCfgFlag_Content(); + } + }; + _proto.setShadow = function setShadow(x, y, blur) { + var oldBlur = this._getLayoutValue("shadowBlur"); + var oldX = this._getLayoutValue("shadowX"); + var oldY = this._getLayoutValue("shadowY"); + oldBlur > 0 != blur > 0 && this._updateCfgFlag_Font(); + var updateContent = false; + if (oldBlur != blur) { + this._setLayoutValue("shadowBlur", blur); + updateContent = true; + } + if (oldX != x) { + this._setLayoutValue("shadowX", x); + updateContent = true; + } + if (oldY != y) { + this._setLayoutValue("shadowY", y); + updateContent = true; + } + updateContent && this._updateCfgFlag_Content(); + }; + _proto.setShadowColor = function setShadowColor(color) { + var oldColor = this._getLayoutValue("shadowColor"); + if (!this._colorEqual(oldColor, color)) { + this._setLayoutValue("shadowColor", color); + this._updateCfgFlag_Content(); + } + }; + _proto.setItalic = function setItalic(enabled) { + var oldItalic = this._getLayoutValue("italic"); + if (oldItalic != enabled) { + this._setLayoutValue("italic", enabled); + this._updateCfgFlag_Content(); + } + }; + _proto.setBold = function setBold(bold) { + var oldBold = this._getLayoutValue("bold"); + if (oldBold != bold) { + this._setLayoutValue("bold", bold); + this._updateCfgFlag_Content(); + this._updateCfgFlag_Font(); + } + }; + _proto.setUnderline = function setUnderline(underline) { + var oldBold = this._getLayoutValue("underline"); + if (oldBold != underline) { + this._setLayoutValue("underline", underline); + this._updateCfgFlag_Content(); + } + }; + _proto.setSpacingX = function setSpacingX(x) { + var oldX = this._getLayoutValue("spaceX"); + if (oldX != x && "number" == typeof x && !isNaN(x)) { + this._setLayoutValue("spaceX", x); + this._updateCfgFlag_Content(); + } + }; + _proto.updateRenderData = function updateRenderData(comp) { + if (!comp._vertsDirty) return; + comp.font && comp.font.nativeUrl && this.setFontPath(cc.assetManager.cacheManager.getCache(comp.font.nativeUrl) || comp.font.nativeUrl); + var layout = this._layout; + var c = comp.node.color; + var node = comp.node; + var retinaSize = comp.fontSize; + this.setString(comp.string); + this.setFontSize(comp.fontSize, retinaSize / 72 * comp.fontSize); + this.setLineHeight(comp.lineHeight); + this.setEnableWrap(comp.enableWrapText); + this.setItalic(comp.enableItalic); + this.setUnderline(comp.enableUnderline); + this.setBold(comp.enableBold); + this.setOverFlow(comp.overflow); + this.setVerticalAlign(comp.verticalAlign); + this.setHorizontalAlign(comp.horizontalAlign); + this.setSpacingX(comp.spacingX); + this.setContentSize(node.getContentSize().width, node.getContentSize().height); + this.setAnchorPoint(node.anchorX, node.anchorY); + this.setColor(this._colorToObj(c.getR(), c.getG(), c.getB(), Math.ceil(c.getA() * node.opacity / 255))); + var shadow = node.getComponent(cc.LabelShadow); + if (shadow && shadow.enabled) { + var shadowColor = shadow.color; + this.setShadow(shadow.offset.x, shadow.offset.y, shadow.blur); + this.setShadowColor(this._colorToObj(shadowColor.getR(), shadowColor.getG(), shadowColor.getB(), Math.ceil(shadowColor.getA() * node.opacity / 255))); + } else this.setShadow(0, 0, -1); + this._updateTTFMaterial(comp); + layout.render(); + }; + _proto._bindMaterial = function _bindMaterial(comp) { + var material = this.labelMaterial; + if (!material) { + material = _materialVariant["default"].createWithBuiltin("2d-label", comp); + this.labelMaterial = material; + } + return material; + }; + _proto._updateTTFMaterial = function _updateTTFMaterial(comp) { + var material = this._bindMaterial(comp); + var node = this._label.node; + var layout = this._layout; + var outline = node.getComponent(cc.LabelOutline); + var outlineSize = 0; + if (outline && outline.enabled && outline.width > 0) { + outlineSize = Math.max(Math.min(outline.width / 10, .4), .1); + var c = outline.color; + this.setOutlineColor(this._colorToObj(c.getR(), c.getG(), c.getB(), Math.ceil(c.getA() * node.opacity / 255))); + } + this.setOutline(outlineSize); + material.define("CC_USE_MODEL", true); + material.define("USE_TEXTURE_ALPHAONLY", true); + material.define("USE_SDF", outlineSize > 0 || comp.enableBold); + material.define("USE_SDF_EXTEND", comp.enableBold ? 1 : 0); + void 0 !== material.getDefine("CC_SUPPORT_standard_derivatives") && cc.sys.glExtension("OES_standard_derivatives") && material.define("CC_SUPPORT_standard_derivatives", true); + layout.setEffect(material.effect._nativeObj); + }; + _proto.fillBuffers = function fillBuffers(comp, renderer) { + this._layout.render(); + }; + _proto.getVfmt = function getVfmt() {}; + return NativeTTF; + })(); + exports["default"] = NativeTTF; + module.exports = exports["default"]; + }), { + "../../../../../assets/material/CCMaterial": 125, + "../../../../../assets/material/material-variant": 132, + "../../../../../components/CCLabel": 152, + "../../../../../components/CCLabelOutline": 153, + "../../../../../components/CCLabelShadow": 154 + } ], + 288: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _ttf = _interopRequireDefault(require("../../../../utils/label/ttf")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + _setPrototypeOf(subClass, superClass); + } + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + return _setPrototypeOf(o, p); + } + var LabelShadow = require("../../../../../components/CCLabelShadow"); + var WHITE = cc.color(255, 255, 255, 255); + var WebglTTFAssembler = (function(_TTFAssembler) { + _inheritsLoose(WebglTTFAssembler, _TTFAssembler); + function WebglTTFAssembler() { + return _TTFAssembler.apply(this, arguments) || this; + } + var _proto = WebglTTFAssembler.prototype; + _proto.updateUVs = function updateUVs(comp) { + var verts = this._renderData.vDatas[0]; + var uv = comp._frame.uv; + var uvOffset = this.uvOffset; + var floatsPerVert = this.floatsPerVert; + for (var i = 0; i < 4; i++) { + var srcOffset = 2 * i; + var dstOffset = floatsPerVert * i + uvOffset; + verts[dstOffset] = uv[srcOffset]; + verts[dstOffset + 1] = uv[srcOffset + 1]; + } + }; + _proto.updateColor = function updateColor(comp) { + WHITE._fastSetA(comp.node._color.a); + var color = WHITE._val; + _TTFAssembler.prototype.updateColor.call(this, comp, color); + }; + _proto.updateVerts = function updateVerts(comp) { + var node = comp.node, canvasWidth = comp._ttfTexture.width, canvasHeight = comp._ttfTexture.height, appx = node.anchorX * node.width, appy = node.anchorY * node.height; + var shadow = LabelShadow && comp.getComponent(LabelShadow); + if (shadow && shadow._enabled) { + var offsetX = (canvasWidth - node.width) / 2; + var offsetY = (canvasHeight - node.height) / 2; + var shadowOffset = shadow.offset; + -shadowOffset.x > offsetX ? appx += canvasWidth - node.width : offsetX > shadowOffset.x && (appx += offsetX - shadowOffset.x); + -shadowOffset.y > offsetY ? appy += canvasHeight - node.height : offsetY > shadowOffset.y && (appy += offsetY - shadowOffset.y); + } + var local = this._local; + local[0] = -appx; + local[1] = -appy; + local[2] = canvasWidth - appx; + local[3] = canvasHeight - appy; + this.updateUVs(comp); + this.updateWorldVerts(comp); + }; + return WebglTTFAssembler; + })(_ttf["default"]); + exports["default"] = WebglTTFAssembler; + module.exports = exports["default"]; + }), { + "../../../../../components/CCLabelShadow": 154, + "../../../../utils/label/ttf": 279 + } ], + 289: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _vec = _interopRequireDefault(require("../../../../../value-types/vec3")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + _setPrototypeOf(subClass, superClass); + } + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + return _setPrototypeOf(o, p); + } + var Assembler3D = require("../../../../assembler-3d"); + var WebglBmfontAssembler = require("../2d/bmfont"); + var vec3_temp_local = new _vec["default"](); + var vec3_temp_world = new _vec["default"](); + var WebglBmfontAssembler3D = (function(_WebglBmfontAssembler) { + _inheritsLoose(WebglBmfontAssembler3D, _WebglBmfontAssembler); + function WebglBmfontAssembler3D() { + return _WebglBmfontAssembler.apply(this, arguments) || this; + } + return WebglBmfontAssembler3D; + })(WebglBmfontAssembler); + exports["default"] = WebglBmfontAssembler3D; + cc.js.mixin(WebglBmfontAssembler3D.prototype, Assembler3D, { + updateWorldVerts: function updateWorldVerts(comp) { + var matrix = comp.node._worldMatrix; + var local = this._local; + var world = this._renderData.vDatas[0]; + var floatsPerVert = this.floatsPerVert; + for (var offset = 0; offset < world.length; offset += floatsPerVert) { + _vec["default"].set(vec3_temp_local, local[offset], local[offset + 1], 0); + _vec["default"].transformMat4(vec3_temp_world, vec3_temp_local, matrix); + world[offset] = vec3_temp_world.x; + world[offset + 1] = vec3_temp_world.y; + world[offset + 2] = vec3_temp_world.z; + } + } + }); + module.exports = exports["default"]; + }), { + "../../../../../value-types/vec3": 350, + "../../../../assembler-3d": 267, + "../2d/bmfont": 285 + } ], + 290: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _vec = _interopRequireDefault(require("../../../../../value-types/vec3")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + _setPrototypeOf(subClass, superClass); + } + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + return _setPrototypeOf(o, p); + } + var Assembler3D = require("../../../../assembler-3d"); + var WebglLetterFontAssembler = require("../2d/letter"); + var vec3_temp_local = new _vec["default"](); + var vec3_temp_world = new _vec["default"](); + var WebglLetterFontAssembler3D = (function(_WebglLetterFontAssem) { + _inheritsLoose(WebglLetterFontAssembler3D, _WebglLetterFontAssem); + function WebglLetterFontAssembler3D() { + return _WebglLetterFontAssem.apply(this, arguments) || this; + } + return WebglLetterFontAssembler3D; + })(WebglLetterFontAssembler); + exports["default"] = WebglLetterFontAssembler3D; + cc.js.mixin(WebglLetterFontAssembler3D.prototype, Assembler3D, { + updateWorldVerts: function updateWorldVerts(comp) { + var matrix = comp.node._worldMatrix; + var local = this._local; + var world = this._renderData.vDatas[0]; + var floatsPerVert = this.floatsPerVert; + for (var offset = 0; offset < world.length; offset += floatsPerVert) { + _vec["default"].set(vec3_temp_local, local[offset], local[offset + 1], 0); + _vec["default"].transformMat4(vec3_temp_world, vec3_temp_local, matrix); + world[offset] = vec3_temp_world.x; + world[offset + 1] = vec3_temp_world.y; + world[offset + 2] = vec3_temp_world.z; + } + } + }); + module.exports = exports["default"]; + }), { + "../../../../../value-types/vec3": 350, + "../../../../assembler-3d": 267, + "../2d/letter": 286 + } ], + 291: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + _setPrototypeOf(subClass, superClass); + } + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + return _setPrototypeOf(o, p); + } + var Assembler3D = require("../../../../assembler-3d"); + var WebglTTFAssembler = require("../2d/ttf"); + var WebglTTFAssembler3D = (function(_WebglTTFAssembler) { + _inheritsLoose(WebglTTFAssembler3D, _WebglTTFAssembler); + function WebglTTFAssembler3D() { + return _WebglTTFAssembler.apply(this, arguments) || this; + } + return WebglTTFAssembler3D; + })(WebglTTFAssembler); + exports["default"] = WebglTTFAssembler3D; + cc.js.mixin(WebglTTFAssembler3D.prototype, Assembler3D); + module.exports = exports["default"]; + }), { + "../../../../assembler-3d": 267, + "../2d/ttf": 288 + } ], + 292: [ (function(require, module, exports) { + "use strict"; + var _assembler = _interopRequireDefault(require("../../../assembler")); + var _CCLabel = _interopRequireDefault(require("../../../../components/CCLabel")); + var _ttf = _interopRequireDefault(require("./2d/ttf")); + var _bmfont = _interopRequireDefault(require("./2d/bmfont")); + var _letter = _interopRequireDefault(require("./2d/letter")); + var _ttf2 = _interopRequireDefault(require("./3d/ttf")); + var _bmfont2 = _interopRequireDefault(require("./3d/bmfont")); + var _letter2 = _interopRequireDefault(require("./3d/letter")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + var NativeTTF = void 0; + false; + _CCLabel["default"]._canvasPool = { + pool: [], + get: function get() { + var data = this.pool.pop(); + if (!data) { + var canvas = document.createElement("canvas"); + var context = canvas.getContext("2d"); + data = { + canvas: canvas, + context: context + }; + context.textBaseline = "alphabetic"; + } + return data; + }, + put: function put(canvas) { + if (this.pool.length >= 32) return; + this.pool.push(canvas); + } + }; + _assembler["default"].register(cc.Label, { + getConstructor: function getConstructor(label) { + var is3DNode = label.node.is3DNode; + var ctor = is3DNode ? _ttf2["default"] : _ttf["default"]; + if (label.font instanceof cc.BitmapFont) ctor = is3DNode ? _bmfont2["default"] : _bmfont["default"]; else if (label.cacheMode === _CCLabel["default"].CacheMode.CHAR) { + false; + cc.sys.platform === cc.sys.WECHAT_GAME_SUB ? cc.warn("sorry, subdomain does not support CHAR mode currently!") : ctor = is3DNode ? _letter2["default"] : _letter["default"]; + } + return ctor; + }, + TTF: _ttf["default"], + Bmfont: _bmfont["default"], + Letter: _letter["default"], + TTF3D: _ttf2["default"], + Bmfont3D: _bmfont2["default"], + Letter3D: _letter2["default"], + NativeTTF: NativeTTF + }); + }), { + "../../../../components/CCLabel": 152, + "../../../assembler": 269, + "./2d/bmfont": 285, + "./2d/letter": 286, + "./2d/nativeTTF": 287, + "./2d/ttf": 288, + "./3d/bmfont": 289, + "./3d/letter": 290, + "./3d/ttf": 291 + } ], + 293: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports.MaskAssembler = void 0; + var _assembler = _interopRequireDefault(require("../../assembler")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + _setPrototypeOf(subClass, superClass); + } + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + return _setPrototypeOf(o, p); + } + var Mask = require("../../../components/CCMask"); + var RenderFlow = require("../../render-flow"); + var SimpleSpriteAssembler = require("./sprite/2d/simple"); + var GraphicsAssembler = require("./graphics"); + var gfx = require("../../../../renderer/gfx"); + var vfmtPos = require("../vertex-format").vfmtPos; + var _maxLevel = 8; + var _maskStack = []; + function getWriteMask() { + return 1 << _maskStack.length - 1; + } + function getStencilRef() { + var result = 0; + for (var i = 0; i < _maskStack.length; ++i) result += 1 << i; + return result; + } + function applyStencil(material, func, failOp, ref, stencilMask, writeMask) { + var effect = material.effect; + var zFailOp = gfx.STENCIL_OP_KEEP, zPassOp = gfx.STENCIL_OP_KEEP; + effect.setStencil(gfx.STENCIL_ENABLE, func, ref, stencilMask, failOp, zFailOp, zPassOp, writeMask); + } + function pushMask(mask) { + _maskStack.length + 1 > _maxLevel && cc.errorID(9e3, _maxLevel); + _maskStack.push(mask); + } + function exitMask(mask, renderer) { + 0 === _maskStack.length && cc.errorID(9001); + _maskStack.pop(); + 0 === _maskStack.length ? renderer._flushMaterial(mask._exitMaterial) : enableMask(renderer); + } + function applyClearMask(mask, renderer) { + var func = gfx.DS_FUNC_NEVER; + var ref = getWriteMask(); + var stencilMask = ref; + var writeMask = ref; + var failOp = mask.inverted ? gfx.STENCIL_OP_REPLACE : gfx.STENCIL_OP_ZERO; + applyStencil(mask._clearMaterial, func, failOp, ref, stencilMask, writeMask); + var buffer = renderer.getBuffer("mesh", vfmtPos); + var offsetInfo = buffer.request(4, 6); + var indiceOffset = offsetInfo.indiceOffset, vertexOffset = offsetInfo.byteOffset >> 2, vertexId = offsetInfo.vertexOffset, vbuf = buffer._vData, ibuf = buffer._iData; + vbuf[vertexOffset++] = -1; + vbuf[vertexOffset++] = -1; + vbuf[vertexOffset++] = -1; + vbuf[vertexOffset++] = 1; + vbuf[vertexOffset++] = 1; + vbuf[vertexOffset++] = 1; + vbuf[vertexOffset++] = 1; + vbuf[vertexOffset++] = -1; + ibuf[indiceOffset++] = vertexId; + ibuf[indiceOffset++] = vertexId + 3; + ibuf[indiceOffset++] = vertexId + 1; + ibuf[indiceOffset++] = vertexId + 1; + ibuf[indiceOffset++] = vertexId + 3; + ibuf[indiceOffset++] = vertexId + 2; + renderer.node = renderer._dummyNode; + renderer.material = mask._clearMaterial; + renderer._flush(); + } + function applyAreaMask(mask, renderer) { + var func = gfx.DS_FUNC_NEVER; + var ref = getWriteMask(); + var stencilMask = ref; + var writeMask = ref; + var failOp = mask.inverted ? gfx.STENCIL_OP_ZERO : gfx.STENCIL_OP_REPLACE; + applyStencil(mask._materials[0], func, failOp, ref, stencilMask, writeMask); + renderer.material = mask._materials[0]; + if (mask._type === Mask.Type.IMAGE_STENCIL) { + renderer.node = renderer._dummyNode; + SimpleSpriteAssembler.prototype.fillBuffers.call(mask._assembler, mask, renderer); + renderer._flush(); + } else { + renderer.node = mask.node; + GraphicsAssembler.prototype.fillBuffers.call(mask._graphics._assembler, mask._graphics, renderer); + } + } + function enableMask(renderer) { + var func = gfx.DS_FUNC_EQUAL; + var failOp = gfx.STENCIL_OP_KEEP; + var ref = getStencilRef(); + var stencilMask = ref; + var writeMask = getWriteMask(); + var mask = _maskStack[_maskStack.length - 1]; + applyStencil(mask._enableMaterial, func, failOp, ref, stencilMask, writeMask); + renderer._flushMaterial(mask._enableMaterial); + } + var MaskAssembler = (function(_SimpleSpriteAssemble) { + _inheritsLoose(MaskAssembler, _SimpleSpriteAssemble); + function MaskAssembler() { + return _SimpleSpriteAssemble.apply(this, arguments) || this; + } + var _proto = MaskAssembler.prototype; + _proto.updateRenderData = function updateRenderData(mask) { + if (mask._type === Mask.Type.IMAGE_STENCIL) mask.spriteFrame ? SimpleSpriteAssembler.prototype.updateRenderData.call(this, mask) : mask.setMaterial(0, null); else { + mask._graphics.setMaterial(0, mask._materials[0]); + GraphicsAssembler.prototype.updateRenderData.call(mask._graphics._assembler, mask._graphics, mask._graphics); + } + }; + _proto.fillBuffers = function fillBuffers(mask, renderer) { + if (mask._type !== Mask.Type.IMAGE_STENCIL || mask.spriteFrame) { + pushMask(mask); + applyClearMask(mask, renderer); + applyAreaMask(mask, renderer); + enableMask(renderer); + } + mask.node._renderFlag |= RenderFlow.FLAG_UPDATE_RENDER_DATA; + }; + _proto.postFillBuffers = function postFillBuffers(mask, renderer) { + (mask._type !== Mask.Type.IMAGE_STENCIL || mask.spriteFrame) && exitMask(mask, renderer); + mask.node._renderFlag |= RenderFlow.FLAG_UPDATE_RENDER_DATA; + }; + return MaskAssembler; + })(SimpleSpriteAssembler); + exports.MaskAssembler = MaskAssembler; + _assembler["default"].register(Mask, MaskAssembler); + }), { + "../../../../renderer/gfx": 373, + "../../../components/CCMask": 156, + "../../assembler": 269, + "../../render-flow": 273, + "../vertex-format": 314, + "./graphics": 283, + "./sprite/2d/simple": 298 + } ], + 294: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _assembler2d = _interopRequireDefault(require("../../assembler-2d")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + _setPrototypeOf(subClass, superClass); + } + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + return _setPrototypeOf(o, p); + } + var MotionStreak = require("../../../components/CCMotionStreak"); + var RenderFlow = require("../../render-flow"); + function Point(point, dir) { + this.point = point || cc.v2(); + this.dir = dir || cc.v2(); + this.distance = 0; + this.time = 0; + } + Point.prototype.setPoint = function(x, y) { + this.point.x = x; + this.point.y = y; + }; + Point.prototype.setDir = function(x, y) { + this.dir.x = x; + this.dir.y = y; + }; + var _tangent = cc.v2(); + var _miter = cc.v2(); + var _normal = cc.v2(); + var _vec2 = cc.v2(); + function normal(out, dir) { + out.x = -dir.y; + out.y = dir.x; + return out; + } + function computeMiter(miter, lineA, lineB, halfThick, maxMultiple) { + lineA.add(lineB, _tangent); + _tangent.normalizeSelf(); + miter.x = -_tangent.y; + miter.y = _tangent.x; + _vec2.x = -lineA.y; + _vec2.y = lineA.x; + var multiple = 1 / miter.dot(_vec2); + maxMultiple && (multiple = Math.min(multiple, maxMultiple)); + return halfThick * multiple; + } + var MotionStreakAssembler = (function(_Assembler2D) { + _inheritsLoose(MotionStreakAssembler, _Assembler2D); + function MotionStreakAssembler() { + var _this; + _this = _Assembler2D.call(this) || this; + _this._tailShortenTime = 0; + return _this; + } + var _proto = MotionStreakAssembler.prototype; + _proto.initData = function initData() { + this._renderData.createFlexData(0, 16, 42); + }; + _proto.update = function update(comp, dt) { + false; + var stroke = comp._stroke / 2; + var node = comp.node; + var matrix = node._worldMatrix.m; + var tx = matrix[12], ty = matrix[13]; + var points = comp._points; + var lastPos = comp._lastWPos; + var fadeTime = comp._fadeTime; + var moved = lastPos.x !== tx || lastPos.y !== ty; + if (moved) { + var cur; + var newHead = false; + if (0 === points.length) { + var _prev = new Point(); + _prev.setPoint(lastPos.x, lastPos.y); + this._tailShortenTime = _prev.time = fadeTime; + points.push(_prev); + cur = new Point(); + points.unshift(cur); + } else { + cur = points[0]; + var _prev2 = points[1]; + var difx = _prev2.point.x - tx; + var dify = _prev2.point.y - ty; + newHead = difx * difx + dify * dify >= comp.minSeg * comp.minSeg; + } + cur.setPoint(tx, ty); + cur.time = fadeTime + dt; + var prev = points[1]; + cur.distance = cur.point.sub(prev.point, _vec2).mag(); + _vec2.normalizeSelf(); + cur.setDir(_vec2.x, _vec2.y); + var prevIsTail = 2 === points.length; + prevIsTail && prev.setDir(_vec2.x, _vec2.y); + if (newHead) { + var point = new Point(cur.point.clone(), cur.dir.clone()); + point.distance = cur.distance; + point.time = cur.time; + points.unshift(point); + } + } + lastPos.x = tx; + lastPos.y = ty; + if (points.length < 2) return; + var color = comp._color, ca = color.a; + var crgb = color.b << 16 | color.g << 8 | color.r; + var verticesCount = 0; + var indicesCount = 0; + var flexBuffer = this._renderData._flexBuffer; + flexBuffer.reserve(2 * points.length, 6 * (points.length - 1)); + var vData = flexBuffer.vData; + var uintVData = flexBuffer.uintVData; + var vertsOffset = 5; + for (var i = points.length - 1; i >= 0; i--) { + var p = points[i]; + var _point = p.point; + var dir = p.dir; + p.time -= dt; + var isLast = i === points.length - 1; + if (p.time <= 0) { + isLast && i - 1 >= 0 && (this._tailShortenTime = points[i - 1].time - dt); + points.splice(i, 1); + continue; + } + var progress = p.time / fadeTime; + if (isLast) { + var next = points[i - 1]; + if (!next) { + points.splice(i, 1); + continue; + } + var nextIsStatic = points.length >= 3; + if (nextIsStatic) { + var segmentProgress = p.time / this._tailShortenTime; + if (segmentProgress <= 1) { + _point.x = next.point.x - next.distance * next.dir.x * segmentProgress; + _point.y = next.point.y - next.distance * next.dir.y * segmentProgress; + } + } else this._tailShortenTime = p.time; + } + normal(_normal, dir); + var da = progress * ca; + var c = da << 24 >>> 0 | crgb; + var offset = verticesCount * vertsOffset; + vData[offset] = _point.x + _normal.x * stroke; + vData[offset + 1] = _point.y + _normal.y * stroke; + vData[offset + 2] = 1; + vData[offset + 3] = progress; + uintVData[offset + 4] = c; + offset += vertsOffset; + vData[offset] = _point.x - _normal.x * stroke; + vData[offset + 1] = _point.y - _normal.y * stroke; + vData[offset + 2] = 0; + vData[offset + 3] = progress; + uintVData[offset + 4] = c; + verticesCount += 2; + } + indicesCount = verticesCount <= 2 ? 0 : 3 * (verticesCount - 2); + flexBuffer.used(verticesCount, indicesCount); + }; + _proto.fillBuffers = function fillBuffers(comp, renderer) { + var _this$_renderData$_fl = this._renderData._flexBuffer, vData = _this$_renderData$_fl.vData, usedVertices = _this$_renderData$_fl.usedVertices, usedIndices = _this$_renderData$_fl.usedIndices, usedVerticesFloats = _this$_renderData$_fl.usedVerticesFloats; + var buffer = renderer._meshBuffer; + var offsetInfo = buffer.request(usedVertices, usedIndices); + var vertexOffset = offsetInfo.byteOffset >> 2, vbuf = buffer._vData; + vData.length + vertexOffset > vbuf.length ? vbuf.set(vData.subarray(0, usedVerticesFloats), vertexOffset) : vbuf.set(vData, vertexOffset); + var ibuf = buffer._iData, indiceOffset = offsetInfo.indiceOffset, vertexId = offsetInfo.vertexOffset; + for (var i = 0, l = usedVertices; i < l; i += 2) { + var start = vertexId + i; + ibuf[indiceOffset++] = start; + ibuf[indiceOffset++] = start + 2; + ibuf[indiceOffset++] = start + 1; + ibuf[indiceOffset++] = start + 1; + ibuf[indiceOffset++] = start + 2; + ibuf[indiceOffset++] = start + 3; + } + comp.node._renderFlag |= RenderFlow.FLAG_UPDATE_RENDER_DATA; + }; + return MotionStreakAssembler; + })(_assembler2d["default"]); + exports["default"] = MotionStreakAssembler; + MotionStreakAssembler.register(MotionStreak, MotionStreakAssembler); + module.exports = exports["default"]; + }), { + "../../../components/CCMotionStreak": 157, + "../../assembler-2d": 266, + "../../render-flow": 273 + } ], + 295: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _assembler2d = _interopRequireDefault(require("../../../../assembler-2d")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + _setPrototypeOf(subClass, superClass); + } + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + return _setPrototypeOf(o, p); + } + var Sprite = require("../../../../../components/CCSprite"); + var FillType = Sprite.FillType; + var BarFilledAssembler = (function(_Assembler2D) { + _inheritsLoose(BarFilledAssembler, _Assembler2D); + function BarFilledAssembler() { + return _Assembler2D.apply(this, arguments) || this; + } + var _proto = BarFilledAssembler.prototype; + _proto.updateRenderData = function updateRenderData(sprite) { + var frame = sprite._spriteFrame; + this.packToDynamicAtlas(sprite, frame); + if (!sprite._vertsDirty) return; + var fillStart = sprite._fillStart; + var fillRange = sprite._fillRange; + if (fillRange < 0) { + fillStart += fillRange; + fillRange = -fillRange; + } + fillRange = fillStart + fillRange; + fillStart = fillStart > 1 ? 1 : fillStart; + fillStart = fillStart < 0 ? 0 : fillStart; + fillRange = fillRange > 1 ? 1 : fillRange; + fillRange = fillRange < 0 ? 0 : fillRange; + fillRange -= fillStart; + fillRange = fillRange < 0 ? 0 : fillRange; + var fillEnd = fillStart + fillRange; + fillEnd = fillEnd > 1 ? 1 : fillEnd; + this.updateUVs(sprite, fillStart, fillEnd); + this.updateVerts(sprite, fillStart, fillEnd); + sprite._vertsDirty = false; + }; + _proto.updateUVs = function updateUVs(sprite, fillStart, fillEnd) { + var spriteFrame = sprite._spriteFrame; + var atlasWidth = spriteFrame._texture.width; + var atlasHeight = spriteFrame._texture.height; + var textureRect = spriteFrame._rect; + var ul, vb, ur, vt; + var quadUV0, quadUV1, quadUV2, quadUV3, quadUV4, quadUV5, quadUV6, quadUV7; + if (spriteFrame._rotated) { + ul = textureRect.x / atlasWidth; + vb = (textureRect.y + textureRect.width) / atlasHeight; + ur = (textureRect.x + textureRect.height) / atlasWidth; + vt = textureRect.y / atlasHeight; + quadUV0 = quadUV2 = ul; + quadUV4 = quadUV6 = ur; + quadUV3 = quadUV7 = vb; + quadUV1 = quadUV5 = vt; + } else { + ul = textureRect.x / atlasWidth; + vb = (textureRect.y + textureRect.height) / atlasHeight; + ur = (textureRect.x + textureRect.width) / atlasWidth; + vt = textureRect.y / atlasHeight; + quadUV0 = quadUV4 = ul; + quadUV2 = quadUV6 = ur; + quadUV1 = quadUV3 = vb; + quadUV5 = quadUV7 = vt; + } + var verts = this._renderData.vDatas[0]; + var uvOffset = this.uvOffset; + var floatsPerVert = this.floatsPerVert; + switch (sprite._fillType) { + case FillType.HORIZONTAL: + verts[uvOffset] = quadUV0 + (quadUV2 - quadUV0) * fillStart; + verts[uvOffset + 1] = quadUV1 + (quadUV3 - quadUV1) * fillStart; + verts[uvOffset + floatsPerVert] = quadUV0 + (quadUV2 - quadUV0) * fillEnd; + verts[uvOffset + floatsPerVert + 1] = quadUV1 + (quadUV3 - quadUV1) * fillEnd; + verts[uvOffset + 2 * floatsPerVert] = quadUV4 + (quadUV6 - quadUV4) * fillStart; + verts[uvOffset + 2 * floatsPerVert + 1] = quadUV5 + (quadUV7 - quadUV5) * fillStart; + verts[uvOffset + 3 * floatsPerVert] = quadUV4 + (quadUV6 - quadUV4) * fillEnd; + verts[uvOffset + 3 * floatsPerVert + 1] = quadUV5 + (quadUV7 - quadUV5) * fillEnd; + break; + + case FillType.VERTICAL: + verts[uvOffset] = quadUV0 + (quadUV4 - quadUV0) * fillStart; + verts[uvOffset + 1] = quadUV1 + (quadUV5 - quadUV1) * fillStart; + verts[uvOffset + floatsPerVert] = quadUV2 + (quadUV6 - quadUV2) * fillStart; + verts[uvOffset + floatsPerVert + 1] = quadUV3 + (quadUV7 - quadUV3) * fillStart; + verts[uvOffset + 2 * floatsPerVert] = quadUV0 + (quadUV4 - quadUV0) * fillEnd; + verts[uvOffset + 2 * floatsPerVert + 1] = quadUV1 + (quadUV5 - quadUV1) * fillEnd; + verts[uvOffset + 3 * floatsPerVert] = quadUV2 + (quadUV6 - quadUV2) * fillEnd; + verts[uvOffset + 3 * floatsPerVert + 1] = quadUV3 + (quadUV7 - quadUV3) * fillEnd; + break; + + default: + cc.errorID(2626); + } + }; + _proto.updateVerts = function updateVerts(sprite, fillStart, fillEnd) { + var node = sprite.node, width = node.width, height = node.height, appx = node.anchorX * width, appy = node.anchorY * height; + var l = -appx, b = -appy, r = width - appx, t = height - appy; + var progressStart, progressEnd; + switch (sprite._fillType) { + case FillType.HORIZONTAL: + progressStart = l + (r - l) * fillStart; + progressEnd = l + (r - l) * fillEnd; + l = progressStart; + r = progressEnd; + break; + + case FillType.VERTICAL: + progressStart = b + (t - b) * fillStart; + progressEnd = b + (t - b) * fillEnd; + b = progressStart; + t = progressEnd; + break; + + default: + cc.errorID(2626); + } + var local = this._local; + local[0] = l; + local[1] = b; + local[2] = r; + local[3] = t; + this.updateWorldVerts(sprite); + }; + return BarFilledAssembler; + })(_assembler2d["default"]); + exports["default"] = BarFilledAssembler; + module.exports = exports["default"]; + }), { + "../../../../../components/CCSprite": 167, + "../../../../assembler-2d": 266 + } ], + 296: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _assembler2d = _interopRequireDefault(require("../../../../assembler-2d")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + _setPrototypeOf(subClass, superClass); + } + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + return _setPrototypeOf(o, p); + } + var MeshSpriteAssembler = (function(_Assembler2D) { + _inheritsLoose(MeshSpriteAssembler, _Assembler2D); + function MeshSpriteAssembler() { + return _Assembler2D.apply(this, arguments) || this; + } + var _proto = MeshSpriteAssembler.prototype; + _proto.initData = function initData(sprite) { + this._renderData.createFlexData(0, 4, 6, this.getVfmt()); + }; + _proto.updateRenderData = function updateRenderData(sprite) { + this.packToDynamicAtlas(sprite, sprite._spriteFrame); + var frame = sprite.spriteFrame; + if (frame) { + var vertices = frame.vertices; + if (vertices) { + this.verticesCount = vertices.x.length; + this.indicesCount = vertices.triangles.length; + var renderData = this._renderData; + var flexBuffer = renderData._flexBuffer; + if (flexBuffer.reserve(this.verticesCount, this.indicesCount)) { + this.updateColor(sprite); + sprite._vertsDirty = true; + } + flexBuffer.used(this.verticesCount, this.indicesCount); + this.updateIndices(vertices.triangles); + if (sprite._vertsDirty) { + this.updateUVs(sprite); + this.updateVerts(sprite); + this.updateWorldVerts(sprite); + sprite._vertsDirty = false; + } + } + } + }; + _proto.updateIndices = function updateIndices(triangles) { + this._renderData.iDatas[0].set(triangles); + }; + _proto.updateUVs = function updateUVs(sprite) { + var vertices = sprite.spriteFrame.vertices, u = vertices.nu, v = vertices.nv; + var uvOffset = this.uvOffset; + var floatsPerVert = this.floatsPerVert; + var verts = this._renderData.vDatas[0]; + for (var i = 0; i < u.length; i++) { + var dstOffset = floatsPerVert * i + uvOffset; + verts[dstOffset] = u[i]; + verts[dstOffset + 1] = v[i]; + } + }; + _proto.updateVerts = function updateVerts(sprite) { + var node = sprite.node, contentWidth = Math.abs(node.width), contentHeight = Math.abs(node.height), appx = node.anchorX * contentWidth, appy = node.anchorY * contentHeight; + var frame = sprite.spriteFrame, vertices = frame.vertices, x = vertices.x, y = vertices.y, originalWidth = frame._originalSize.width, originalHeight = frame._originalSize.height, rectWidth = frame._rect.width, rectHeight = frame._rect.height, offsetX = frame._offset.x, offsetY = frame._offset.y, trimX = offsetX + (originalWidth - rectWidth) / 2, trimY = offsetY + (originalHeight - rectHeight) / 2; + var scaleX = contentWidth / (sprite.trim ? rectWidth : originalWidth), scaleY = contentHeight / (sprite.trim ? rectHeight : originalHeight); + var local = this._local; + if (sprite.trim) for (var _i = 0, _l = x.length; _i < _l; _i++) { + var _offset = 2 * _i; + local[_offset] = (x[_i] - trimX) * scaleX - appx; + local[_offset + 1] = (originalHeight - y[_i] - trimY) * scaleY - appy; + } else for (var i = 0, l = x.length; i < l; i++) { + var offset = 2 * i; + local[offset] = x[i] * scaleX - appx; + local[offset + 1] = (originalHeight - y[i]) * scaleY - appy; + } + if (frame._flipX) for (var _i2 = 0, _l2 = this.verticesCount; _i2 < _l2; _i2++) local[2 * _i2] = contentWidth - local[2 * _i2] - 2 * appx; + if (frame._flipY) for (var _i3 = 0, _l3 = this.verticesCount; _i3 < _l3; _i3++) local[2 * _i3 + 1] = contentHeight - local[2 * _i3 + 1] - 2 * appy; + }; + _proto.updateWorldVerts = function updateWorldVerts(sprite) { + var node = sprite.node; + var matrix = node._worldMatrix; + var matrixm = matrix.m; + var a = matrixm[0], b = matrixm[1], c = matrixm[4], d = matrixm[5], tx = matrixm[12], ty = matrixm[13]; + var local = this._local; + var world = this._renderData.vDatas[0]; + var floatsPerVert = this.floatsPerVert; + for (var i = 0, l = this.verticesCount; i < l; i++) { + var lx = local[2 * i]; + var ly = local[2 * i + 1]; + world[floatsPerVert * i] = lx * a + ly * c + tx; + world[floatsPerVert * i + 1] = lx * b + ly * d + ty; + } + }; + return MeshSpriteAssembler; + })(_assembler2d["default"]); + exports["default"] = MeshSpriteAssembler; + module.exports = exports["default"]; + }), { + "../../../../assembler-2d": 266 + } ], + 297: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _assembler2d = _interopRequireDefault(require("../../../../assembler-2d")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + _setPrototypeOf(subClass, superClass); + } + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + return _setPrototypeOf(o, p); + } + var PI_2 = 2 * Math.PI; + var _vertPos = [ cc.v2(0, 0), cc.v2(0, 0), cc.v2(0, 0), cc.v2(0, 0) ]; + var _vertices = [ 0, 0, 0, 0 ]; + var _uvs = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; + var _intersectPoint_1 = [ cc.v2(0, 0), cc.v2(0, 0), cc.v2(0, 0), cc.v2(0, 0) ]; + var _intersectPoint_2 = [ cc.v2(0, 0), cc.v2(0, 0), cc.v2(0, 0), cc.v2(0, 0) ]; + var _center = cc.v2(0, 0); + var _triangles = []; + function _calcInsectedPoints(left, right, bottom, top, center, angle, intersectPoints) { + var sinAngle = Math.sin(angle); + var cosAngle = Math.cos(angle); + var tanAngle, cotAngle; + if (0 !== Math.cos(angle)) { + tanAngle = sinAngle / cosAngle; + if ((left - center.x) * cosAngle > 0) { + var yleft = center.y + tanAngle * (left - center.x); + intersectPoints[0].x = left; + intersectPoints[0].y = yleft; + } + if ((right - center.x) * cosAngle > 0) { + var yright = center.y + tanAngle * (right - center.x); + intersectPoints[2].x = right; + intersectPoints[2].y = yright; + } + } + if (0 !== Math.sin(angle)) { + cotAngle = cosAngle / sinAngle; + if ((top - center.y) * sinAngle > 0) { + var xtop = center.x + cotAngle * (top - center.y); + intersectPoints[3].x = xtop; + intersectPoints[3].y = top; + } + if ((bottom - center.y) * sinAngle > 0) { + var xbottom = center.x + cotAngle * (bottom - center.y); + intersectPoints[1].x = xbottom; + intersectPoints[1].y = bottom; + } + } + } + function _calculateVertices(sprite) { + var node = sprite.node, width = node.width, height = node.height, appx = node.anchorX * width, appy = node.anchorY * height; + var l = -appx, b = -appy, r = width - appx, t = height - appy; + var vertices = _vertices; + vertices[0] = l; + vertices[1] = b; + vertices[2] = r; + vertices[3] = t; + var fillCenter = sprite._fillCenter, cx = _center.x = Math.min(Math.max(0, fillCenter.x), 1) * (r - l) + l, cy = _center.y = Math.min(Math.max(0, fillCenter.y), 1) * (t - b) + b; + _vertPos[0].x = _vertPos[3].x = l; + _vertPos[1].x = _vertPos[2].x = r; + _vertPos[0].y = _vertPos[1].y = b; + _vertPos[2].y = _vertPos[3].y = t; + _triangles.length = 0; + cx !== vertices[0] && (_triangles[0] = [ 3, 0 ]); + cx !== vertices[2] && (_triangles[2] = [ 1, 2 ]); + cy !== vertices[1] && (_triangles[1] = [ 0, 1 ]); + cy !== vertices[3] && (_triangles[3] = [ 2, 3 ]); + } + function _calculateUVs(spriteFrame) { + var atlasWidth = spriteFrame._texture.width; + var atlasHeight = spriteFrame._texture.height; + var textureRect = spriteFrame._rect; + var u0, u1, v0, v1; + var uvs = _uvs; + if (spriteFrame._rotated) { + u0 = textureRect.x / atlasWidth; + u1 = (textureRect.x + textureRect.height) / atlasWidth; + v0 = textureRect.y / atlasHeight; + v1 = (textureRect.y + textureRect.width) / atlasHeight; + uvs[0] = uvs[2] = u0; + uvs[4] = uvs[6] = u1; + uvs[3] = uvs[7] = v1; + uvs[1] = uvs[5] = v0; + } else { + u0 = textureRect.x / atlasWidth; + u1 = (textureRect.x + textureRect.width) / atlasWidth; + v0 = textureRect.y / atlasHeight; + v1 = (textureRect.y + textureRect.height) / atlasHeight; + uvs[0] = uvs[4] = u0; + uvs[2] = uvs[6] = u1; + uvs[1] = uvs[3] = v1; + uvs[5] = uvs[7] = v0; + } + } + function _getVertAngle(start, end) { + var placementX, placementY; + placementX = end.x - start.x; + placementY = end.y - start.y; + if (0 === placementX && 0 === placementY) return; + if (0 === placementX) return placementY > 0 ? .5 * Math.PI : 1.5 * Math.PI; + var angle = Math.atan(placementY / placementX); + placementX < 0 && (angle += Math.PI); + return angle; + } + var RadialFilledAssembler = (function(_Assembler2D) { + _inheritsLoose(RadialFilledAssembler, _Assembler2D); + function RadialFilledAssembler() { + return _Assembler2D.apply(this, arguments) || this; + } + var _proto = RadialFilledAssembler.prototype; + _proto.initData = function initData(sprite) { + this._renderData.createFlexData(0, 4, 6, this.getVfmt()); + this.updateIndices(); + }; + _proto.updateRenderData = function updateRenderData(sprite) { + _Assembler2D.prototype.updateRenderData.call(this, sprite); + var frame = sprite.spriteFrame; + this.packToDynamicAtlas(sprite, frame); + if (sprite._vertsDirty) { + var fillStart = sprite._fillStart; + var fillRange = sprite._fillRange; + if (fillRange < 0) { + fillStart += fillRange; + fillRange = -fillRange; + } + while (fillStart >= 1) fillStart -= 1; + while (fillStart < 0) fillStart += 1; + fillStart *= PI_2; + fillRange *= PI_2; + _calculateVertices(sprite); + _calculateUVs(frame); + _calcInsectedPoints(_vertices[0], _vertices[2], _vertices[1], _vertices[3], _center, fillStart, _intersectPoint_1); + _calcInsectedPoints(_vertices[0], _vertices[2], _vertices[1], _vertices[3], _center, fillStart + fillRange, _intersectPoint_2); + this.updateVerts(sprite, fillStart, fillRange); + sprite._vertsDirty = false; + } + }; + _proto.updateVerts = function updateVerts(sprite, fillStart, fillRange) { + var fillEnd = fillStart + fillRange; + var local = this._local; + local.length = 0; + var offset = 0; + var floatsPerTriangle = 3 * this.floatsPerVert; + for (var triangleIndex = 0; triangleIndex < 4; ++triangleIndex) { + var triangle = _triangles[triangleIndex]; + if (!triangle) continue; + if (fillRange >= PI_2) { + local.length = offset + floatsPerTriangle; + this._generateTriangle(local, offset, _center, _vertPos[triangle[0]], _vertPos[triangle[1]]); + offset += floatsPerTriangle; + continue; + } + var startAngle = _getVertAngle(_center, _vertPos[triangle[0]]); + var endAngle = _getVertAngle(_center, _vertPos[triangle[1]]); + endAngle < startAngle && (endAngle += PI_2); + startAngle -= PI_2; + endAngle -= PI_2; + for (var testIndex = 0; testIndex < 3; ++testIndex) { + if (startAngle >= fillEnd) ; else if (startAngle >= fillStart) { + local.length = offset + floatsPerTriangle; + endAngle >= fillEnd ? this._generateTriangle(local, offset, _center, _vertPos[triangle[0]], _intersectPoint_2[triangleIndex]) : this._generateTriangle(local, offset, _center, _vertPos[triangle[0]], _vertPos[triangle[1]]); + offset += floatsPerTriangle; + } else if (endAngle <= fillStart) ; else if (endAngle <= fillEnd) { + local.length = offset + floatsPerTriangle; + this._generateTriangle(local, offset, _center, _intersectPoint_1[triangleIndex], _vertPos[triangle[1]]); + offset += floatsPerTriangle; + } else { + local.length = offset + floatsPerTriangle; + this._generateTriangle(local, offset, _center, _intersectPoint_1[triangleIndex], _intersectPoint_2[triangleIndex]); + offset += floatsPerTriangle; + } + startAngle += PI_2; + endAngle += PI_2; + } + } + this.allocWorldVerts(sprite); + this.updateWorldVerts(sprite); + }; + _proto.allocWorldVerts = function allocWorldVerts(sprite) { + var color = sprite.node._color._val; + var renderData = this._renderData; + var floatsPerVert = this.floatsPerVert; + var local = this._local; + var verticesCount = local.length / floatsPerVert; + this.verticesCount = this.indicesCount = verticesCount; + var flexBuffer = renderData._flexBuffer; + flexBuffer.reserve(verticesCount, verticesCount) && this.updateIndices(); + flexBuffer.used(this.verticesCount, this.indicesCount); + var verts = renderData.vDatas[0], uintVerts = renderData.uintVDatas[0]; + var uvOffset = this.uvOffset; + for (var offset = 0; offset < local.length; offset += floatsPerVert) { + var start = offset + uvOffset; + verts[start] = local[start]; + verts[start + 1] = local[start + 1]; + uintVerts[start + 2] = color; + } + }; + _proto.updateIndices = function updateIndices() { + var iData = this._renderData.iDatas[0]; + for (var i = 0; i < iData.length; i++) iData[i] = i; + }; + _proto.updateWorldVerts = function updateWorldVerts(sprite) { + var node = sprite.node; + var matrix = node._worldMatrix; + var matrixm = matrix.m, a = matrixm[0], b = matrixm[1], c = matrixm[4], d = matrixm[5], tx = matrixm[12], ty = matrixm[13]; + var local = this._local; + var world = this._renderData.vDatas[0]; + var floatsPerVert = this.floatsPerVert; + for (var offset = 0; offset < local.length; offset += floatsPerVert) { + var x = local[offset]; + var y = local[offset + 1]; + world[offset] = x * a + y * c + tx; + world[offset + 1] = x * b + y * d + ty; + } + }; + _proto._generateTriangle = function _generateTriangle(verts, offset, vert0, vert1, vert2) { + var vertices = _vertices; + var v0x = vertices[0]; + var v0y = vertices[1]; + var v1x = vertices[2]; + var v1y = vertices[3]; + var floatsPerVert = this.floatsPerVert; + verts[offset] = vert0.x; + verts[offset + 1] = vert0.y; + verts[offset + floatsPerVert] = vert1.x; + verts[offset + floatsPerVert + 1] = vert1.y; + verts[offset + 2 * floatsPerVert] = vert2.x; + verts[offset + 2 * floatsPerVert + 1] = vert2.y; + var uvOffset = this.uvOffset; + var progressX, progressY; + progressX = (vert0.x - v0x) / (v1x - v0x); + progressY = (vert0.y - v0y) / (v1y - v0y); + this._generateUV(progressX, progressY, verts, offset + uvOffset); + progressX = (vert1.x - v0x) / (v1x - v0x); + progressY = (vert1.y - v0y) / (v1y - v0y); + this._generateUV(progressX, progressY, verts, offset + floatsPerVert + uvOffset); + progressX = (vert2.x - v0x) / (v1x - v0x); + progressY = (vert2.y - v0y) / (v1y - v0y); + this._generateUV(progressX, progressY, verts, offset + 2 * floatsPerVert + uvOffset); + }; + _proto._generateUV = function _generateUV(progressX, progressY, verts, offset) { + var uvs = _uvs; + var px1 = uvs[0] + (uvs[2] - uvs[0]) * progressX; + var px2 = uvs[4] + (uvs[6] - uvs[4]) * progressX; + var py1 = uvs[1] + (uvs[3] - uvs[1]) * progressX; + var py2 = uvs[5] + (uvs[7] - uvs[5]) * progressX; + verts[offset] = px1 + (px2 - px1) * progressY; + verts[offset + 1] = py1 + (py2 - py1) * progressY; + }; + return RadialFilledAssembler; + })(_assembler2d["default"]); + exports["default"] = RadialFilledAssembler; + module.exports = exports["default"]; + }), { + "../../../../assembler-2d": 266 + } ], + 298: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _assembler2d = _interopRequireDefault(require("../../../../assembler-2d")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + _setPrototypeOf(subClass, superClass); + } + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + return _setPrototypeOf(o, p); + } + var SimpleSpriteAssembler = (function(_Assembler2D) { + _inheritsLoose(SimpleSpriteAssembler, _Assembler2D); + function SimpleSpriteAssembler() { + return _Assembler2D.apply(this, arguments) || this; + } + var _proto = SimpleSpriteAssembler.prototype; + _proto.updateRenderData = function updateRenderData(sprite) { + this.packToDynamicAtlas(sprite, sprite._spriteFrame); + if (sprite._vertsDirty) { + this.updateUVs(sprite); + this.updateVerts(sprite); + sprite._vertsDirty = false; + } + }; + _proto.updateUVs = function updateUVs(sprite) { + var uv = sprite._spriteFrame.uv; + var uvOffset = this.uvOffset; + var floatsPerVert = this.floatsPerVert; + var verts = this._renderData.vDatas[0]; + for (var i = 0; i < 4; i++) { + var srcOffset = 2 * i; + var dstOffset = floatsPerVert * i + uvOffset; + verts[dstOffset] = uv[srcOffset]; + verts[dstOffset + 1] = uv[srcOffset + 1]; + } + }; + _proto.updateVerts = function updateVerts(sprite) { + var node = sprite.node, cw = node.width, ch = node.height, appx = node.anchorX * cw, appy = node.anchorY * ch, l, b, r, t; + if (sprite.trim) { + l = -appx; + b = -appy; + r = cw - appx; + t = ch - appy; + } else { + var frame = sprite.spriteFrame, ow = frame._originalSize.width, oh = frame._originalSize.height, rw = frame._rect.width, rh = frame._rect.height, offset = frame._offset, scaleX = cw / ow, scaleY = ch / oh; + var trimLeft = offset.x + (ow - rw) / 2; + var trimRight = offset.x - (ow - rw) / 2; + var trimBottom = offset.y + (oh - rh) / 2; + var trimTop = offset.y - (oh - rh) / 2; + l = trimLeft * scaleX - appx; + b = trimBottom * scaleY - appy; + r = cw + trimRight * scaleX - appx; + t = ch + trimTop * scaleY - appy; + } + var local = this._local; + local[0] = l; + local[1] = b; + local[2] = r; + local[3] = t; + this.updateWorldVerts(sprite); + }; + return SimpleSpriteAssembler; + })(_assembler2d["default"]); + exports["default"] = SimpleSpriteAssembler; + module.exports = exports["default"]; + }), { + "../../../../assembler-2d": 266 + } ], + 299: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _assembler2d = _interopRequireDefault(require("../../../../assembler-2d")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + _setPrototypeOf(subClass, superClass); + } + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + return _setPrototypeOf(o, p); + } + var SlicedAssembler = (function(_Assembler2D) { + _inheritsLoose(SlicedAssembler, _Assembler2D); + function SlicedAssembler() { + return _Assembler2D.apply(this, arguments) || this; + } + var _proto = SlicedAssembler.prototype; + _proto.initData = function initData(sprite) { + if (this._renderData.meshCount > 0) return; + this._renderData.createData(0, this.verticesFloats, this.indicesCount); + var indices = this._renderData.iDatas[0]; + var indexOffset = 0; + for (var r = 0; r < 3; ++r) for (var c = 0; c < 3; ++c) { + var start = 4 * r + c; + indices[indexOffset++] = start; + indices[indexOffset++] = start + 1; + indices[indexOffset++] = start + 4; + indices[indexOffset++] = start + 1; + indices[indexOffset++] = start + 5; + indices[indexOffset++] = start + 4; + } + }; + _proto.initLocal = function initLocal() { + this._local = []; + this._local.length = 8; + }; + _proto.updateRenderData = function updateRenderData(sprite) { + var frame = sprite._spriteFrame; + this.packToDynamicAtlas(sprite, frame); + if (sprite._vertsDirty) { + this.updateUVs(sprite); + this.updateVerts(sprite); + sprite._vertsDirty = false; + } + }; + _proto.updateVerts = function updateVerts(sprite) { + var node = sprite.node, width = node.width, height = node.height, appx = node.anchorX * width, appy = node.anchorY * height; + var frame = sprite.spriteFrame; + var leftWidth = frame.insetLeft; + var rightWidth = frame.insetRight; + var topHeight = frame.insetTop; + var bottomHeight = frame.insetBottom; + var sizableWidth = width - leftWidth - rightWidth; + var sizableHeight = height - topHeight - bottomHeight; + var xScale = width / (leftWidth + rightWidth); + var yScale = height / (topHeight + bottomHeight); + xScale = isNaN(xScale) || xScale > 1 ? 1 : xScale; + yScale = isNaN(yScale) || yScale > 1 ? 1 : yScale; + sizableWidth = sizableWidth < 0 ? 0 : sizableWidth; + sizableHeight = sizableHeight < 0 ? 0 : sizableHeight; + var local = this._local; + local[0] = -appx; + local[1] = -appy; + local[2] = leftWidth * xScale - appx; + local[3] = bottomHeight * yScale - appy; + local[4] = local[2] + sizableWidth; + local[5] = local[3] + sizableHeight; + local[6] = width - appx; + local[7] = height - appy; + this.updateWorldVerts(sprite); + }; + _proto.updateUVs = function updateUVs(sprite) { + var verts = this._renderData.vDatas[0]; + var uvSliced = sprite.spriteFrame.uvSliced; + var uvOffset = this.uvOffset; + var floatsPerVert = this.floatsPerVert; + for (var row = 0; row < 4; ++row) for (var col = 0; col < 4; ++col) { + var vid = 4 * row + col; + var uv = uvSliced[vid]; + var voffset = vid * floatsPerVert; + verts[voffset + uvOffset] = uv.u; + verts[voffset + uvOffset + 1] = uv.v; + } + }; + _proto.updateWorldVerts = function updateWorldVerts(sprite) { + var matrix = sprite.node._worldMatrix; + var matrixm = matrix.m, a = matrixm[0], b = matrixm[1], c = matrixm[4], d = matrixm[5], tx = matrixm[12], ty = matrixm[13]; + var local = this._local; + var world = this._renderData.vDatas[0]; + var floatsPerVert = this.floatsPerVert; + for (var row = 0; row < 4; ++row) { + var localRowY = local[2 * row + 1]; + for (var col = 0; col < 4; ++col) { + var localColX = local[2 * col]; + var worldIndex = (4 * row + col) * floatsPerVert; + world[worldIndex] = localColX * a + localRowY * c + tx; + world[worldIndex + 1] = localColX * b + localRowY * d + ty; + } + } + }; + return SlicedAssembler; + })(_assembler2d["default"]); + exports["default"] = SlicedAssembler; + Object.assign(SlicedAssembler.prototype, { + verticesCount: 16, + indicesCount: 54 + }); + module.exports = exports["default"]; + }), { + "../../../../assembler-2d": 266 + } ], + 300: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _assembler2d = _interopRequireDefault(require("../../../../assembler-2d")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + _setPrototypeOf(subClass, superClass); + } + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + return _setPrototypeOf(o, p); + } + var TiledAssembler = (function(_Assembler2D) { + _inheritsLoose(TiledAssembler, _Assembler2D); + function TiledAssembler() { + return _Assembler2D.apply(this, arguments) || this; + } + var _proto = TiledAssembler.prototype; + _proto.initData = function initData(sprite) { + this.verticesCount = 0; + this.contentWidth = 0; + this.contentHeight = 0; + this.rectWidth = 0; + this.rectHeight = 0; + this.hRepeat = 0; + this.vRepeat = 0; + this.row = 0; + this.col = 0; + this._renderData.createFlexData(0, 4, 6, this.getVfmt()); + this._updateIndices(); + }; + _proto.initLocal = function initLocal() { + this._local = { + x: [], + y: [] + }; + }; + _proto._updateIndices = function _updateIndices() { + var iData = this._renderData.iDatas[0]; + for (var i = 0, vid = 0, l = iData.length; i < l; i += 6, vid += 4) { + iData[i] = vid; + iData[i + 1] = vid + 1; + iData[i + 2] = vid + 2; + iData[i + 3] = vid + 1; + iData[i + 4] = vid + 3; + iData[i + 5] = vid + 2; + } + }; + _proto.updateRenderData = function updateRenderData(sprite) { + var frame = sprite._spriteFrame; + this.packToDynamicAtlas(sprite, frame); + var node = sprite.node; + var contentWidth = this.contentWidth = Math.abs(node.width); + var contentHeight = this.contentHeight = Math.abs(node.height); + var rect = frame._rect; + var leftWidth = frame.insetLeft, rightWidth = frame.insetRight, centerWidth = rect.width - leftWidth - rightWidth, topHeight = frame.insetTop, bottomHeight = frame.insetBottom, centerHeight = rect.height - topHeight - bottomHeight; + this.sizableWidth = contentWidth - leftWidth - rightWidth; + this.sizableHeight = contentHeight - topHeight - bottomHeight; + this.sizableWidth = this.sizableWidth > 0 ? this.sizableWidth : 0; + this.sizableHeight = this.sizableHeight > 0 ? this.sizableHeight : 0; + var hRepeat = this.hRepeat = 0 === centerWidth ? this.sizableWidth : this.sizableWidth / centerWidth; + var vRepeat = this.vRepeat = 0 === centerHeight ? this.sizableHeight : this.sizableHeight / centerHeight; + var row = this.row = Math.ceil(vRepeat + 2); + var col = this.col = Math.ceil(hRepeat + 2); + var count = row * col; + this.verticesCount = 4 * count; + this.indicesCount = 6 * count; + var renderData = this._renderData; + var flexBuffer = renderData._flexBuffer; + if (flexBuffer.reserve(this.verticesCount, this.indicesCount)) { + this._updateIndices(); + this.updateColor(sprite); + } + flexBuffer.used(this.verticesCount, this.indicesCount); + if (sprite._vertsDirty) { + this.updateUVs(sprite); + this.updateVerts(sprite); + sprite._vertsDirty = false; + } + }; + _proto.updateVerts = function updateVerts(sprite) { + var frame = sprite._spriteFrame; + var rect = frame._rect; + var node = sprite.node, appx = node.anchorX * node.width, appy = node.anchorY * node.height; + var row = this.row, col = this.col, contentWidth = this.contentWidth, contentHeight = this.contentHeight; + var _this$_local = this._local, x = _this$_local.x, y = _this$_local.y; + x.length = y.length = 0; + var leftWidth = frame.insetLeft, rightWidth = frame.insetRight, centerWidth = rect.width - leftWidth - rightWidth, topHeight = frame.insetTop, bottomHeight = frame.insetBottom, centerHeight = rect.height - topHeight - bottomHeight; + var xScale = node.width / (leftWidth + rightWidth) > 1 ? 1 : node.width / (leftWidth + rightWidth); + var yScale = node.height / (topHeight + bottomHeight) > 1 ? 1 : node.height / (topHeight + bottomHeight); + var offsetWidth = 0, offsetHeight = 0; + offsetWidth = centerWidth > 0 ? Math.floor(1e3 * this.sizableWidth) / 1e3 % centerWidth === 0 ? centerWidth : this.sizableWidth % centerWidth : this.sizableWidth; + offsetHeight = centerHeight > 0 ? Math.floor(1e3 * this.sizableHeight) / 1e3 % centerHeight === 0 ? centerHeight : this.sizableHeight % centerHeight : this.sizableHeight; + for (var i = 0; i <= col; i++) 0 === i ? x[i] = -appx : i > 0 && i < col ? x[i] = 1 === i ? leftWidth * xScale + Math.min(centerWidth, this.sizableWidth) - appx : centerWidth > 0 ? i === col - 1 ? leftWidth + offsetWidth + centerWidth * (i - 2) - appx : leftWidth + Math.min(centerWidth, this.sizableWidth) + centerWidth * (i - 2) - appx : leftWidth + this.sizableWidth - appx : i === col && (x[i] = Math.min(leftWidth + this.sizableWidth + rightWidth, contentWidth) - appx); + for (var _i = 0; _i <= row; _i++) 0 === _i ? y[_i] = -appy : _i > 0 && _i < row ? y[_i] = 1 === _i ? bottomHeight * yScale + Math.min(centerHeight, this.sizableHeight) - appy : centerHeight > 0 ? _i === row - 1 ? bottomHeight + offsetHeight + (_i - 2) * centerHeight - appy : bottomHeight + Math.min(centerHeight, this.sizableHeight) + (_i - 2) * centerHeight - appy : bottomHeight + this.sizableHeight - appy : _i === row && (y[_i] = Math.min(bottomHeight + this.sizableHeight + topHeight, contentHeight) - appy); + this.updateWorldVerts(sprite); + }; + _proto.updateWorldVerts = function updateWorldVerts(sprite) { + var renderData = this._renderData; + var local = this._local; + var localX = local.x, localY = local.y; + var world = renderData.vDatas[0]; + var row = this.row, col = this.col; + var matrix = sprite.node._worldMatrix; + var matrixm = matrix.m; + var a = matrixm[0], b = matrixm[1], c = matrixm[4], d = matrixm[5], tx = matrixm[12], ty = matrixm[13]; + var x, x1, y, y1; + var floatsPerVert = this.floatsPerVert; + var vertexOffset = 0; + for (var yindex = 0, ylength = row; yindex < ylength; ++yindex) { + y = localY[yindex]; + y1 = localY[yindex + 1]; + for (var xindex = 0, xlength = col; xindex < xlength; ++xindex) { + x = localX[xindex]; + x1 = localX[xindex + 1]; + world[vertexOffset] = x * a + y * c + tx; + world[vertexOffset + 1] = x * b + y * d + ty; + vertexOffset += floatsPerVert; + world[vertexOffset] = x1 * a + y * c + tx; + world[vertexOffset + 1] = x1 * b + y * d + ty; + vertexOffset += floatsPerVert; + world[vertexOffset] = x * a + y1 * c + tx; + world[vertexOffset + 1] = x * b + y1 * d + ty; + vertexOffset += floatsPerVert; + world[vertexOffset] = x1 * a + y1 * c + tx; + world[vertexOffset + 1] = x1 * b + y1 * d + ty; + vertexOffset += floatsPerVert; + } + } + }; + _proto.updateUVs = function updateUVs(sprite) { + var verts = this._renderData.vDatas[0]; + if (!verts) return; + var frame = sprite._spriteFrame; + var rect = frame._rect; + var leftWidth = frame.insetLeft, rightWidth = frame.insetRight, centerWidth = rect.width - leftWidth - rightWidth, topHeight = frame.insetTop, bottomHeight = frame.insetBottom, centerHeight = rect.height - topHeight - bottomHeight; + var row = this.row, col = this.col, hRepeat = this.hRepeat, vRepeat = this.vRepeat; + var coefu = 0, coefv = 0; + var uv = sprite.spriteFrame.uv; + var uvSliced = sprite.spriteFrame.uvSliced; + var rotated = sprite.spriteFrame._rotated; + var floatsPerVert = this.floatsPerVert, uvOffset = this.uvOffset; + var tempXVerts = [], tempYVerts = []; + for (var yindex = 0, ylength = row; yindex < ylength; ++yindex) { + coefv = this.sizableHeight > centerHeight ? this.sizableHeight >= yindex * centerHeight ? 1 : vRepeat % 1 : vRepeat; + for (var xindex = 0, xlength = col; xindex < xlength; ++xindex) { + coefu = this.sizableWidth > centerWidth ? this.sizableWidth >= xindex * centerWidth ? 1 : hRepeat % 1 : hRepeat; + if (rotated) { + if (0 === yindex) { + tempXVerts[0] = uvSliced[0].u; + tempXVerts[1] = uvSliced[0].u; + tempXVerts[2] = uvSliced[4].u + (uvSliced[8].u - uvSliced[4].u) * coefv; + } else if (yindex < row - 1) { + tempXVerts[0] = uvSliced[4].u; + tempXVerts[1] = uvSliced[4].u; + tempXVerts[2] = uvSliced[4].u + (uvSliced[8].u - uvSliced[4].u) * coefv; + } else if (yindex === row - 1) { + tempXVerts[0] = uvSliced[8].u; + tempXVerts[1] = uvSliced[8].u; + tempXVerts[2] = uvSliced[12].u; + } + if (0 === xindex) { + tempYVerts[0] = uvSliced[0].v; + tempYVerts[1] = uvSliced[1].v + (uvSliced[2].v - uvSliced[1].v) * coefu; + tempYVerts[2] = uvSliced[0].v; + } else if (xindex < col - 1) { + tempYVerts[0] = uvSliced[1].v; + tempYVerts[1] = uvSliced[1].v + (uvSliced[2].v - uvSliced[1].v) * coefu; + tempYVerts[2] = uvSliced[1].v; + } else if (xindex === col - 1) { + tempYVerts[0] = uvSliced[2].v; + tempYVerts[1] = uvSliced[3].v; + tempYVerts[2] = uvSliced[2].v; + } + tempXVerts[3] = tempXVerts[2]; + tempYVerts[3] = tempYVerts[1]; + } else { + if (0 === xindex) { + tempXVerts[0] = uvSliced[0].u; + tempXVerts[1] = uvSliced[1].u + (uvSliced[2].u - uvSliced[1].u) * coefu; + tempXVerts[2] = uv[0]; + } else if (xindex < col - 1) { + tempXVerts[0] = uvSliced[1].u; + tempXVerts[1] = uvSliced[1].u + (uvSliced[2].u - uvSliced[1].u) * coefu; + tempXVerts[2] = uvSliced[1].u; + } else if (xindex === col - 1) { + tempXVerts[0] = uvSliced[2].u; + tempXVerts[1] = uvSliced[3].u; + tempXVerts[2] = uvSliced[2].u; + } + if (0 === yindex) { + tempYVerts[0] = uvSliced[0].v; + tempYVerts[1] = uvSliced[0].v; + tempYVerts[2] = uvSliced[4].v + (uvSliced[8].v - uvSliced[4].v) * coefv; + } else if (yindex < row - 1) { + tempYVerts[0] = uvSliced[4].v; + tempYVerts[1] = uvSliced[4].v; + tempYVerts[2] = uvSliced[4].v + (uvSliced[8].v - uvSliced[4].v) * coefv; + } else if (yindex === row - 1) { + tempYVerts[0] = uvSliced[8].v; + tempYVerts[1] = uvSliced[8].v; + tempYVerts[2] = uvSliced[12].v; + } + tempXVerts[3] = tempXVerts[1]; + tempYVerts[3] = tempYVerts[2]; + } + verts[uvOffset] = tempXVerts[0]; + verts[uvOffset + 1] = tempYVerts[0]; + uvOffset += floatsPerVert; + verts[uvOffset] = tempXVerts[1]; + verts[uvOffset + 1] = tempYVerts[1]; + uvOffset += floatsPerVert; + verts[uvOffset] = tempXVerts[2]; + verts[uvOffset + 1] = tempYVerts[2]; + uvOffset += floatsPerVert; + verts[uvOffset] = tempXVerts[3]; + verts[uvOffset + 1] = tempYVerts[3]; + uvOffset += floatsPerVert; + } + } + }; + return TiledAssembler; + })(_assembler2d["default"]); + exports["default"] = TiledAssembler; + module.exports = exports["default"]; + }), { + "../../../../assembler-2d": 266 + } ], + 301: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + _setPrototypeOf(subClass, superClass); + } + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + return _setPrototypeOf(o, p); + } + var Assembler3D = require("../../../../assembler-3d"); + var BarFilledAssembler = require("../2d/bar-filled"); + var BarFilledAssembler3D = (function(_BarFilledAssembler) { + _inheritsLoose(BarFilledAssembler3D, _BarFilledAssembler); + function BarFilledAssembler3D() { + return _BarFilledAssembler.apply(this, arguments) || this; + } + return BarFilledAssembler3D; + })(BarFilledAssembler); + exports["default"] = BarFilledAssembler3D; + cc.js.mixin(BarFilledAssembler3D.prototype, Assembler3D); + module.exports = exports["default"]; + }), { + "../../../../assembler-3d": 267, + "../2d/bar-filled": 295 + } ], + 302: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _vec = _interopRequireDefault(require("../../../../../value-types/vec3")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + _setPrototypeOf(subClass, superClass); + } + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + return _setPrototypeOf(o, p); + } + var Assembler3D = require("../../../../assembler-3d"); + var MeshAssembler = require("../2d/mesh"); + var vec3_temp = new _vec["default"](); + var MeshAssembler3D = (function(_MeshAssembler) { + _inheritsLoose(MeshAssembler3D, _MeshAssembler); + function MeshAssembler3D() { + return _MeshAssembler.apply(this, arguments) || this; + } + return MeshAssembler3D; + })(MeshAssembler); + exports["default"] = MeshAssembler3D; + cc.js.mixin(MeshAssembler3D.prototype, Assembler3D, { + updateWorldVerts: function updateWorldVerts(comp) { + var matrix = comp.node._worldMatrix; + var local = this._local; + var world = this._renderData.vDatas[0]; + var floatsPerVert = this.floatsPerVert; + for (var i = 0, l = local.length / 2; i < l; i++) { + _vec["default"].set(vec3_temp, local[2 * i], local[2 * i + 1], 0); + _vec["default"].transformMat4(vec3_temp, vec3_temp, matrix); + var dstOffset = floatsPerVert * i; + world[dstOffset] = vec3_temp.x; + world[dstOffset + 1] = vec3_temp.y; + world[dstOffset + 2] = vec3_temp.z; + } + } + }); + module.exports = exports["default"]; + }), { + "../../../../../value-types/vec3": 350, + "../../../../assembler-3d": 267, + "../2d/mesh": 296 + } ], + 303: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _vec = _interopRequireDefault(require("../../../../../value-types/vec3")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + _setPrototypeOf(subClass, superClass); + } + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + return _setPrototypeOf(o, p); + } + var Assembler3D = require("../../../../assembler-3d"); + var RadialFilledAssembler = require("../2d/radial-filled"); + var vec3_temp_local = new _vec["default"](); + var vec3_temp_world = new _vec["default"](); + var RadialFilledAssembler3D = (function(_RadialFilledAssemble) { + _inheritsLoose(RadialFilledAssembler3D, _RadialFilledAssemble); + function RadialFilledAssembler3D() { + return _RadialFilledAssemble.apply(this, arguments) || this; + } + return RadialFilledAssembler3D; + })(RadialFilledAssembler); + exports["default"] = RadialFilledAssembler3D; + cc.js.mixin(RadialFilledAssembler3D.prototype, Assembler3D, { + updateWorldVerts: function updateWorldVerts(sprite) { + var matrix = sprite.node._worldMatrix; + var local = this._local; + var world = this._renderData.vDatas[0]; + var floatsPerVert = this.floatsPerVert; + for (var offset = 0; offset < world.length; offset += floatsPerVert) { + _vec["default"].set(vec3_temp_local, local[offset], local[offset + 1], 0); + _vec["default"].transformMat4(vec3_temp_world, vec3_temp_local, matrix); + world[offset] = vec3_temp_world.x; + world[offset + 1] = vec3_temp_world.y; + world[offset + 2] = vec3_temp_world.z; + } + } + }); + module.exports = exports["default"]; + }), { + "../../../../../value-types/vec3": 350, + "../../../../assembler-3d": 267, + "../2d/radial-filled": 297 + } ], + 304: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + _setPrototypeOf(subClass, superClass); + } + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + return _setPrototypeOf(o, p); + } + var Assembler3D = require("../../../../assembler-3d"); + var SimpleAssembler = require("../2d/simple"); + var SimpleAssembler3D = (function(_SimpleAssembler) { + _inheritsLoose(SimpleAssembler3D, _SimpleAssembler); + function SimpleAssembler3D() { + return _SimpleAssembler.apply(this, arguments) || this; + } + return SimpleAssembler3D; + })(SimpleAssembler); + exports["default"] = SimpleAssembler3D; + cc.js.mixin(SimpleAssembler3D.prototype, Assembler3D); + module.exports = exports["default"]; + }), { + "../../../../assembler-3d": 267, + "../2d/simple": 298 + } ], + 305: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _vec = _interopRequireDefault(require("../../../../../value-types/vec3")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + _setPrototypeOf(subClass, superClass); + } + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + return _setPrototypeOf(o, p); + } + var Assembler3D = require("../../../../assembler-3d"); + var SlicedAssembler = require("../2d/sliced"); + var vec3_temp_local = new _vec["default"](); + var vec3_temp_world = new _vec["default"](); + var SlicedAssembler3D = (function(_SlicedAssembler) { + _inheritsLoose(SlicedAssembler3D, _SlicedAssembler); + function SlicedAssembler3D() { + return _SlicedAssembler.apply(this, arguments) || this; + } + return SlicedAssembler3D; + })(SlicedAssembler); + exports["default"] = SlicedAssembler3D; + cc.js.mixin(SlicedAssembler3D.prototype, Assembler3D, { + updateWorldVerts: function updateWorldVerts(sprite) { + var matrix = sprite.node._worldMatrix; + var local = this._local; + var world = this._renderData.vDatas[0]; + var floatsPerVert = this.floatsPerVert; + for (var row = 0; row < 4; ++row) { + var localRowY = local[2 * row + 1]; + for (var col = 0; col < 4; ++col) { + var localColX = local[2 * col]; + _vec["default"].set(vec3_temp_local, localColX, localRowY, 0); + _vec["default"].transformMat4(vec3_temp_world, vec3_temp_local, matrix); + var worldIndex = (4 * row + col) * floatsPerVert; + world[worldIndex] = vec3_temp_world.x; + world[worldIndex + 1] = vec3_temp_world.y; + world[worldIndex + 2] = vec3_temp_world.z; + } + } + } + }); + module.exports = exports["default"]; + }), { + "../../../../../value-types/vec3": 350, + "../../../../assembler-3d": 267, + "../2d/sliced": 299 + } ], + 306: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _vec = _interopRequireDefault(require("../../../../../value-types/vec3")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + _setPrototypeOf(subClass, superClass); + } + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + return _setPrototypeOf(o, p); + } + var Assembler3D = require("../../../../assembler-3d"); + var TiledAssembler = require("../2d/tiled"); + var vec3_temps = []; + for (var i = 0; i < 4; i++) vec3_temps.push(new _vec["default"]()); + var TiledAssembler3D = (function(_TiledAssembler) { + _inheritsLoose(TiledAssembler3D, _TiledAssembler); + function TiledAssembler3D() { + return _TiledAssembler.apply(this, arguments) || this; + } + return TiledAssembler3D; + })(TiledAssembler); + exports["default"] = TiledAssembler3D; + cc.js.mixin(TiledAssembler3D.prototype, Assembler3D, { + updateWorldVerts: function updateWorldVerts(sprite) { + var local = this._local; + var localX = local.x, localY = local.y; + var world = this._renderData.vDatas[0]; + var row = this.row, col = this.col; + var matrix = sprite.node._worldMatrix; + var x, x1, y, y1; + var vertexOffset = 0; + for (var yindex = 0, ylength = row; yindex < ylength; ++yindex) { + y = localY[yindex]; + y1 = localY[yindex + 1]; + for (var xindex = 0, xlength = col; xindex < xlength; ++xindex) { + x = localX[xindex]; + x1 = localX[xindex + 1]; + _vec["default"].set(vec3_temps[0], x, y, 0); + _vec["default"].set(vec3_temps[1], x1, y, 0); + _vec["default"].set(vec3_temps[2], x, y1, 0); + _vec["default"].set(vec3_temps[3], x1, y1, 0); + for (var _i = 0; _i < 4; _i++) { + var vec3_temp = vec3_temps[_i]; + _vec["default"].transformMat4(vec3_temp, vec3_temp, matrix); + var offset = 6 * _i; + world[vertexOffset + offset] = vec3_temp.x; + world[vertexOffset + offset + 1] = vec3_temp.y; + world[vertexOffset + offset + 2] = vec3_temp.z; + } + vertexOffset += 24; + } + } + } + }); + module.exports = exports["default"]; + }), { + "../../../../../value-types/vec3": 350, + "../../../../assembler-3d": 267, + "../2d/tiled": 300 + } ], + 307: [ (function(require, module, exports) { + "use strict"; + var _assembler = _interopRequireDefault(require("../../../assembler")); + var _CCSprite = require("../../../../components/CCSprite"); + var _simple = _interopRequireDefault(require("./2d/simple")); + var _sliced = _interopRequireDefault(require("./2d/sliced")); + var _tiled = _interopRequireDefault(require("./2d/tiled")); + var _radialFilled = _interopRequireDefault(require("./2d/radial-filled")); + var _barFilled = _interopRequireDefault(require("./2d/bar-filled")); + var _mesh = _interopRequireDefault(require("./2d/mesh")); + var _simple2 = _interopRequireDefault(require("./3d/simple")); + var _sliced2 = _interopRequireDefault(require("./3d/sliced")); + var _tiled2 = _interopRequireDefault(require("./3d/tiled")); + var _radialFilled2 = _interopRequireDefault(require("./3d/radial-filled")); + var _barFilled2 = _interopRequireDefault(require("./3d/bar-filled")); + var _mesh2 = _interopRequireDefault(require("./3d/mesh")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + var ctor = { + getConstructor: function getConstructor(sprite) { + var is3DNode = sprite.node.is3DNode; + var ctor = is3DNode ? _simple2["default"] : _simple["default"]; + switch (sprite.type) { + case _CCSprite.Type.SLICED: + ctor = is3DNode ? _sliced2["default"] : _sliced["default"]; + break; + + case _CCSprite.Type.TILED: + ctor = is3DNode ? _tiled2["default"] : _tiled["default"]; + break; + + case _CCSprite.Type.FILLED: + ctor = sprite._fillType === _CCSprite.FillType.RADIAL ? is3DNode ? _radialFilled2["default"] : _radialFilled["default"] : is3DNode ? _barFilled2["default"] : _barFilled["default"]; + break; + + case _CCSprite.Type.MESH: + ctor = is3DNode ? _mesh2["default"] : _mesh["default"]; + } + return ctor; + }, + Simple: _simple["default"], + Sliced: _sliced["default"], + Tiled: _tiled["default"], + RadialFilled: _radialFilled["default"], + BarFilled: _barFilled["default"], + Mesh: _mesh["default"], + Simple3D: _simple2["default"], + Sliced3D: _sliced2["default"], + Tiled3D: _tiled2["default"], + RadialFilled3D: _radialFilled2["default"], + BarFilled3D: _barFilled2["default"], + Mesh3D: _mesh2["default"] + }; + _assembler["default"].register(cc.Sprite, ctor); + }), { + "../../../../components/CCSprite": 167, + "../../../assembler": 269, + "./2d/bar-filled": 295, + "./2d/mesh": 296, + "./2d/radial-filled": 297, + "./2d/simple": 298, + "./2d/sliced": 299, + "./2d/tiled": 300, + "./3d/bar-filled": 301, + "./3d/mesh": 302, + "./3d/radial-filled": 303, + "./3d/simple": 304, + "./3d/sliced": 305, + "./3d/tiled": 306 + } ], + 308: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var FlexBuffer = (function() { + function FlexBuffer(handler, index, verticesCount, indicesCount, vfmt) { + this._handler = handler; + this._index = index; + this._vfmt = vfmt; + this._verticesBytes = vfmt._bytes; + this._initVerticesCount = verticesCount; + this._initIndicesCount = indicesCount; + this.reset(); + } + var _proto = FlexBuffer.prototype; + _proto._reallocVData = function _reallocVData(floatsCount, oldData) { + this.vData = new Float32Array(floatsCount); + this.uintVData = new Uint32Array(this.vData.buffer); + oldData && this.vData.set(oldData); + this._handler.updateMesh(this._index, this.vData, this.iData); + }; + _proto._reallocIData = function _reallocIData(indicesCount, oldData) { + this.iData = new Uint16Array(indicesCount); + oldData && this.iData.set(oldData); + this._handler.updateMesh(this._index, this.vData, this.iData); + }; + _proto.reserve = function reserve(verticesCount, indicesCount) { + var floatsCount = verticesCount * this._verticesBytes >> 2; + var newFloatsCount = this.vData.length; + var realloced = false; + if (floatsCount > newFloatsCount) { + while (newFloatsCount < floatsCount) newFloatsCount *= 2; + this._reallocVData(newFloatsCount, this.vData); + realloced = true; + } + var newIndicesCount = this.iData.length; + if (indicesCount > newIndicesCount) { + while (newIndicesCount < indicesCount) newIndicesCount *= 2; + this._reallocIData(indicesCount, this.iData); + realloced = true; + } + return realloced; + }; + _proto.used = function used(verticesCount, indicesCount) { + this.usedVertices = verticesCount; + this.usedIndices = indicesCount; + this.usedVerticesFloats = verticesCount * this._verticesBytes >> 2; + this._handler.updateMeshRange(verticesCount, indicesCount); + }; + _proto.reset = function reset() { + var floatsCount = this._initVerticesCount * this._verticesBytes >> 2; + this._reallocVData(floatsCount); + this._reallocIData(this._initIndicesCount); + this.usedVertices = 0; + this.usedVerticesFloats = 0; + this.usedIndices = 0; + }; + return FlexBuffer; + })(); + exports["default"] = FlexBuffer; + cc.FlexBuffer = FlexBuffer; + module.exports = exports["default"]; + }), {} ], + 309: [ (function(require, module, exports) { + "use strict"; + var _gfx = _interopRequireDefault(require("../../../renderer/gfx")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + var FIX_IOS14_BUFFER; + if (cc.sys.platform === cc.sys.WECHAT_GAME) { + var _GameGlobal; + FIX_IOS14_BUFFER = (cc.sys.os === cc.sys.OS_IOS || cc.sys.os === cc.sys.OS_OSX) && (null == (_GameGlobal = GameGlobal) ? void 0 : _GameGlobal.isIOSHighPerformanceMode) && /(OS 1[4-9])|(Version\/1[4-9])/.test(window.navigator.userAgent); + } else FIX_IOS14_BUFFER = (cc.sys.os === cc.sys.OS_IOS || cc.sys.os === cc.sys.OS_OSX) && cc.sys.isBrowser && /(OS 1[4-9])|(Version\/1[4-9])/.test(window.navigator.userAgent); + var MeshBuffer = cc.Class({ + name: "cc.MeshBuffer", + ctor: function ctor(batcher, vertexFormat) { + this.init(batcher, vertexFormat); + }, + init: function init(batcher, vertexFormat) { + this.byteOffset = 0; + this.indiceOffset = 0; + this.vertexOffset = 0; + this.indiceStart = 0; + this._dirty = false; + this._vertexFormat = vertexFormat; + this._vertexBytes = this._vertexFormat._bytes; + this._arrOffset = 0; + this._vbArr = []; + this._vb = new _gfx["default"].VertexBuffer(batcher._device, vertexFormat, _gfx["default"].USAGE_DYNAMIC, new ArrayBuffer(), 0); + this._vbArr[0] = this._vb; + this._ibArr = []; + this._ib = new _gfx["default"].IndexBuffer(batcher._device, _gfx["default"].INDEX_FMT_UINT16, _gfx["default"].USAGE_STATIC, new ArrayBuffer(), 0); + this._ibArr[0] = this._ib; + this._vData = null; + this._uintVData = null; + this._iData = null; + this._batcher = batcher; + this._initVDataCount = 256 * vertexFormat._bytes; + this._initIDataCount = 1536; + this._offsetInfo = { + byteOffset: 0, + vertexOffset: 0, + indiceOffset: 0 + }; + this._reallocBuffer(); + }, + uploadData: function uploadData() { + if (0 === this.byteOffset || !this._dirty) return; + var vertexsData = new Float32Array(this._vData.buffer, 0, this.byteOffset >> 2); + var indicesData = new Uint16Array(this._iData.buffer, 0, this.indiceOffset); + var vb = this._vb; + vb.update(0, vertexsData); + var ib = this._ib; + ib.update(0, indicesData); + this._dirty = false; + }, + switchBuffer: function switchBuffer() { + var offset = ++this._arrOffset; + this.byteOffset = 0; + this.vertexOffset = 0; + this.indiceOffset = 0; + this.indiceStart = 0; + if (offset < this._vbArr.length) { + this._vb = this._vbArr[offset]; + this._ib = this._ibArr[offset]; + } else { + this._vb = new _gfx["default"].VertexBuffer(this._batcher._device, this._vertexFormat, _gfx["default"].USAGE_DYNAMIC, new ArrayBuffer(), 0); + this._vbArr[offset] = this._vb; + this._ib = new _gfx["default"].IndexBuffer(this._batcher._device, _gfx["default"].INDEX_FMT_UINT16, _gfx["default"].USAGE_STATIC, new ArrayBuffer(), 0); + this._ibArr[offset] = this._ib; + } + }, + checkAndSwitchBuffer: function checkAndSwitchBuffer(vertexCount) { + if (this.vertexOffset + vertexCount > 65535) { + this.uploadData(); + this._batcher._flush(); + this.switchBuffer(); + } + }, + requestStatic: function requestStatic(vertexCount, indiceCount) { + this.checkAndSwitchBuffer(vertexCount); + var byteOffset = this.byteOffset + vertexCount * this._vertexBytes; + var indiceOffset = this.indiceOffset + indiceCount; + var byteLength = this._vData.byteLength; + var indiceLength = this._iData.length; + if (byteOffset > byteLength || indiceOffset > indiceLength) { + while (byteLength < byteOffset || indiceLength < indiceOffset) { + this._initVDataCount *= 2; + this._initIDataCount *= 2; + byteLength = 4 * this._initVDataCount; + indiceLength = this._initIDataCount; + } + this._reallocBuffer(); + } + this._updateOffset(vertexCount, indiceCount, byteOffset); + }, + _updateOffset: function _updateOffset(vertexCount, indiceCount, byteOffset) { + var offsetInfo = this._offsetInfo; + offsetInfo.vertexOffset = this.vertexOffset; + this.vertexOffset += vertexCount; + offsetInfo.indiceOffset = this.indiceOffset; + this.indiceOffset += indiceCount; + offsetInfo.byteOffset = this.byteOffset; + this.byteOffset = byteOffset; + this._dirty = true; + }, + request: function request(vertexCount, indiceCount) { + if (this._batcher._buffer !== this) { + this._batcher._flush(); + this._batcher._buffer = this; + } + this.requestStatic(vertexCount, indiceCount); + return this._offsetInfo; + }, + _reallocBuffer: function _reallocBuffer() { + this._reallocVData(true); + this._reallocIData(true); + }, + _reallocVData: function _reallocVData(copyOldData) { + var oldVData; + this._vData && (oldVData = new Uint8Array(this._vData.buffer)); + this._vData = new Float32Array(this._initVDataCount); + this._uintVData = new Uint32Array(this._vData.buffer); + var newData = new Uint8Array(this._uintVData.buffer); + if (oldVData && copyOldData) for (var i = 0, l = oldVData.length; i < l; i++) newData[i] = oldVData[i]; + }, + _reallocIData: function _reallocIData(copyOldData) { + var oldIData = this._iData; + this._iData = new Uint16Array(this._initIDataCount); + if (oldIData && copyOldData) { + var iData = this._iData; + for (var i = 0, l = oldIData.length; i < l; i++) iData[i] = oldIData[i]; + } + }, + reset: function reset() { + this._arrOffset = 0; + this._vb = this._vbArr[0]; + this._ib = this._ibArr[0]; + this.byteOffset = 0; + this.indiceOffset = 0; + this.vertexOffset = 0; + this.indiceStart = 0; + this._dirty = false; + }, + destroy: function destroy() { + this.reset(); + for (var i = 0; i < this._vbArr.length; i++) { + var vb = this._vbArr[i]; + vb.destroy(); + } + this._vbArr = null; + for (var _i = 0; _i < this._ibArr.length; _i++) { + var ib = this._ibArr[_i]; + ib.destroy(); + } + this._ibArr = null; + this._ib = null; + this._vb = null; + }, + forwardIndiceStartToOffset: function forwardIndiceStartToOffset() { + this.indiceStart = this.indiceOffset; + } + }); + if (FIX_IOS14_BUFFER) { + MeshBuffer.prototype.checkAndSwitchBuffer = function(vertexCount) { + if (this.vertexOffset + vertexCount > 65535) { + this.uploadData(); + this._batcher._flush(); + } + }; + MeshBuffer.prototype.forwardIndiceStartToOffset = function() { + this.uploadData(); + this.switchBuffer(); + }; + } + cc.MeshBuffer = module.exports = MeshBuffer; + }), { + "../../../renderer/gfx": 373 + } ], + 310: [ (function(require, module, exports) { + "use strict"; + var _inputAssembler = _interopRequireDefault(require("../../../renderer/core/input-assembler")); + var _recyclePool = _interopRequireDefault(require("../../../renderer/memop/recycle-pool")); + var _model = _interopRequireDefault(require("../../../renderer/scene/model")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + var _require = require("./vertex-format"), vfmtPosUvColor = _require.vfmtPosUvColor, vfmt3D = _require.vfmt3D; + var QuadBuffer = require("./quad-buffer"); + var MeshBuffer = require("./mesh-buffer"); + var SpineBuffer = require("./spine-buffer"); + var Material = require("../../assets/material/CCMaterial"); + var idGenerater = new (require("../../platform/id-generater"))("VertextFormat"); + var _buffers = {}; + var empty_material = new Material(); + var empty_ia = new _inputAssembler["default"](); + empty_ia._count = 0; + var ModelBatcher = function ModelBatcher(device, renderScene) { + this._renderScene = renderScene; + this._device = device; + this.walking = false; + this.material = empty_material; + this.cullingMask = 1; + this._iaPool = new _recyclePool["default"](function() { + return new _inputAssembler["default"](); + }, 16); + this._modelPool = new _recyclePool["default"](function() { + return new _model["default"](); + }, 16); + this._quadBuffer = this.getBuffer("quad", vfmtPosUvColor); + this._meshBuffer = this.getBuffer("mesh", vfmtPosUvColor); + this._quadBuffer3D = this.getBuffer("quad", vfmt3D); + this._meshBuffer3D = this.getBuffer("mesh", vfmt3D); + this._buffer = this._meshBuffer; + this._batchedModels = []; + this._dummyNode = new cc.Node(); + this._sortKey = 0; + this.node = this._dummyNode; + this.parentOpacity = 1; + this.parentOpacityDirty = 0; + this.worldMatDirty = 0; + }; + ModelBatcher.prototype = { + constructor: ModelBatcher, + reset: function reset() { + this._iaPool.reset(); + var scene = this._renderScene; + var models = this._batchedModels; + for (var i = 0; i < models.length; ++i) { + models[i].setInputAssembler(null); + models[i].setEffect(null); + scene.removeModel(models[i]); + } + this._modelPool.reset(); + models.length = 0; + this._sortKey = 0; + for (var key in _buffers) _buffers[key].reset(); + this._buffer = this._meshBuffer; + this.node = this._dummyNode; + this.material = empty_material; + this.cullingMask = 1; + this.parentOpacity = 1; + this.parentOpacityDirty = 0; + this.worldMatDirty = 0; + }, + _flushMaterial: function _flushMaterial(material) { + if (!material) return; + this.material = material; + var effect = material.effect; + if (!effect) return; + var model = this._modelPool.add(); + this._batchedModels.push(model); + model.sortKey = this._sortKey++; + model._cullingMask = this.cullingMask; + model.setNode(this.node); + model.setEffect(effect, null); + model.setInputAssembler(empty_ia); + this._renderScene.addModel(model); + }, + _flush: function _flush() { + var material = this.material, buffer = this._buffer, indiceCount = buffer.indiceOffset - buffer.indiceStart; + if (!this.walking || !material || indiceCount <= 0) return; + var effect = material.effect; + if (!effect) return; + var ia = this._iaPool.add(); + ia._vertexBuffer = buffer._vb; + ia._indexBuffer = buffer._ib; + ia._start = buffer.indiceStart; + ia._count = indiceCount; + var model = this._modelPool.add(); + this._batchedModels.push(model); + model.sortKey = this._sortKey++; + model._cullingMask = this.cullingMask; + model.setNode(this.node); + model.setEffect(effect); + model.setInputAssembler(ia); + this._renderScene.addModel(model); + buffer.forwardIndiceStartToOffset(); + }, + _flushIA: function _flushIA(ia) { + if (!ia) return; + var material = this.material; + var effect = material.effect; + if (!effect) return; + var model = this._modelPool.add(); + this._batchedModels.push(model); + model.sortKey = this._sortKey++; + model._cullingMask = this.cullingMask; + model.setNode(this.node); + model.setEffect(effect); + model.setInputAssembler(ia); + this._renderScene.addModel(model); + }, + terminate: function terminate() { + cc.dynamicAtlasManager && cc.dynamicAtlasManager.enabled && cc.dynamicAtlasManager.update(); + this._flush(); + for (var key in _buffers) _buffers[key].uploadData(); + this.walking = false; + }, + getBuffer: function getBuffer(type, vertextFormat) { + var key = type + vertextFormat.getHash(); + var buffer = _buffers[key]; + if (!buffer) { + if ("mesh" === type) buffer = new MeshBuffer(this, vertextFormat); else if ("quad" === type) buffer = new QuadBuffer(this, vertextFormat); else { + if ("spine" !== type) { + cc.error("Not support buffer type [" + type + "]"); + return null; + } + buffer = new SpineBuffer(this, vertextFormat); + } + _buffers[key] = buffer; + } + return buffer; + } + }; + module.exports = ModelBatcher; + }), { + "../../../renderer/core/input-assembler": 363, + "../../../renderer/memop/recycle-pool": 388, + "../../../renderer/scene/model": 395, + "../../assets/material/CCMaterial": 125, + "../../platform/id-generater": 257, + "./mesh-buffer": 309, + "./quad-buffer": 311, + "./spine-buffer": 313, + "./vertex-format": 314 + } ], + 311: [ (function(require, module, exports) { + "use strict"; + var MeshBuffer = require("./mesh-buffer"); + var QuadBuffer = cc.Class({ + name: "cc.QuadBuffer", + extends: MeshBuffer, + _fillQuadBuffer: function _fillQuadBuffer() { + var count = this._initIDataCount / 6; + var buffer = this._iData; + for (var i = 0, idx = 0; i < count; i++) { + var vertextID = 4 * i; + buffer[idx++] = vertextID; + buffer[idx++] = vertextID + 1; + buffer[idx++] = vertextID + 2; + buffer[idx++] = vertextID + 1; + buffer[idx++] = vertextID + 3; + buffer[idx++] = vertextID + 2; + } + var indicesData = new Uint16Array(this._iData.buffer, 0, 6 * count); + this._ib.update(0, indicesData); + }, + uploadData: function uploadData() { + if (0 === this.byteOffset || !this._dirty) return; + var vertexsData = new Float32Array(this._vData.buffer, 0, this.byteOffset >> 2); + this._vb.update(0, vertexsData); + this._dirty = false; + }, + switchBuffer: function switchBuffer() { + this._super(); + var indicesData = new Uint16Array(this._iData.buffer, 0, this._initIDataCount); + this._ib.update(0, indicesData); + }, + _reallocBuffer: function _reallocBuffer() { + this._reallocVData(true); + this._reallocIData(); + this._fillQuadBuffer(); + } + }); + cc.QuadBuffer = module.exports = QuadBuffer; + }), { + "./mesh-buffer": 309 + } ], + 312: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = RenderData; + var _flexBuffer = _interopRequireDefault(require("./flex-buffer")); + var _vertexFormat = require("./vertex-format"); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function RenderData() { + this.vDatas = []; + this.uintVDatas = []; + this.iDatas = []; + this.meshCount = 0; + this._infos = null; + this._flexBuffer = null; + } + cc.js.mixin(RenderData.prototype, { + init: function init(assembler) {}, + clear: function clear() { + this.vDatas.length = 0; + this.iDatas.length = 0; + this.uintVDatas.length = 0; + this.meshCount = 0; + this._infos = null; + this._flexBuffer && this._flexBuffer.reset(); + }, + updateMesh: function updateMesh(index, vertices, indices) { + this.vDatas[index] = vertices; + this.uintVDatas[index] = new Uint32Array(vertices.buffer, 0, vertices.length); + this.iDatas[index] = indices; + this.meshCount = this.vDatas.length; + }, + updateMeshRange: function updateMeshRange(verticesCount, indicesCount) {}, + createData: function createData(index, verticesFloats, indicesCount) { + var vertices = new Float32Array(verticesFloats); + var indices = new Uint16Array(indicesCount); + this.updateMesh(index, vertices, indices); + }, + createQuadData: function createQuadData(index, verticesFloats, indicesCount) { + this.createData(index, verticesFloats, indicesCount); + this.initQuadIndices(this.iDatas[index]); + }, + createFlexData: function createFlexData(index, verticesFloats, indicesCount, vfmt) { + vfmt = vfmt || _vertexFormat.vfmtPosUvColor; + this._flexBuffer = new _flexBuffer["default"](this, index, verticesFloats, indicesCount, vfmt); + }, + initQuadIndices: function initQuadIndices(indices) { + var count = indices.length / 6; + for (var i = 0, idx = 0; i < count; i++) { + var vertextID = 4 * i; + indices[idx++] = vertextID; + indices[idx++] = vertextID + 1; + indices[idx++] = vertextID + 2; + indices[idx++] = vertextID + 1; + indices[idx++] = vertextID + 3; + indices[idx++] = vertextID + 2; + } + } + }); + cc.RenderData = RenderData; + module.exports = exports["default"]; + }), { + "./flex-buffer": 308, + "./vertex-format": 314 + } ], + 313: [ (function(require, module, exports) { + "use strict"; + var SpineBuffer = cc.Class({ + name: "cc.SpineBuffer", + extends: require("./mesh-buffer"), + requestStatic: function requestStatic(vertexCount, indiceCount) { + this.checkAndSwitchBuffer(vertexCount); + var byteOffset = this.byteOffset + vertexCount * this._vertexBytes; + var indiceOffset = this.indiceOffset + indiceCount; + var byteLength = this._vData.byteLength; + var indiceLength = this._iData.length; + if (byteOffset > byteLength || indiceOffset > indiceLength) { + while (byteLength < byteOffset || indiceLength < indiceOffset) { + this._initVDataCount *= 2; + this._initIDataCount *= 2; + byteLength = 4 * this._initVDataCount; + indiceLength = this._initIDataCount; + } + this._reallocBuffer(); + } + var offsetInfo = this._offsetInfo; + offsetInfo.vertexOffset = this.vertexOffset; + offsetInfo.indiceOffset = this.indiceOffset; + offsetInfo.byteOffset = this.byteOffset; + }, + adjust: function adjust(vertexCount, indiceCount) { + this.vertexOffset += vertexCount; + this.indiceOffset += indiceCount; + this.byteOffset = this.byteOffset + vertexCount * this._vertexBytes; + this._dirty = true; + } + }); + cc.SpineBuffer = module.exports = SpineBuffer; + }), { + "./mesh-buffer": 309 + } ], + 314: [ (function(require, module, exports) { + "use strict"; + var _gfx = _interopRequireDefault(require("../../../renderer/gfx")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + var vfmt3D = new _gfx["default"].VertexFormat([ { + name: _gfx["default"].ATTR_POSITION, + type: _gfx["default"].ATTR_TYPE_FLOAT32, + num: 3 + }, { + name: _gfx["default"].ATTR_UV0, + type: _gfx["default"].ATTR_TYPE_FLOAT32, + num: 2 + }, { + name: _gfx["default"].ATTR_COLOR, + type: _gfx["default"].ATTR_TYPE_UINT8, + num: 4, + normalize: true + } ]); + vfmt3D.name = "vfmt3D"; + _gfx["default"].VertexFormat.XYZ_UV_Color = vfmt3D; + var vfmtPosUvColor = new _gfx["default"].VertexFormat([ { + name: _gfx["default"].ATTR_POSITION, + type: _gfx["default"].ATTR_TYPE_FLOAT32, + num: 2 + }, { + name: _gfx["default"].ATTR_UV0, + type: _gfx["default"].ATTR_TYPE_FLOAT32, + num: 2 + }, { + name: _gfx["default"].ATTR_COLOR, + type: _gfx["default"].ATTR_TYPE_UINT8, + num: 4, + normalize: true + } ]); + vfmtPosUvColor.name = "vfmtPosUvColor"; + _gfx["default"].VertexFormat.XY_UV_Color = vfmtPosUvColor; + var vfmtPosUvTwoColor = new _gfx["default"].VertexFormat([ { + name: _gfx["default"].ATTR_POSITION, + type: _gfx["default"].ATTR_TYPE_FLOAT32, + num: 2 + }, { + name: _gfx["default"].ATTR_UV0, + type: _gfx["default"].ATTR_TYPE_FLOAT32, + num: 2 + }, { + name: _gfx["default"].ATTR_COLOR, + type: _gfx["default"].ATTR_TYPE_UINT8, + num: 4, + normalize: true + }, { + name: _gfx["default"].ATTR_COLOR0, + type: _gfx["default"].ATTR_TYPE_UINT8, + num: 4, + normalize: true + } ]); + vfmtPosUvTwoColor.name = "vfmtPosUvTwoColor"; + _gfx["default"].VertexFormat.XY_UV_Two_Color = vfmtPosUvTwoColor; + var vfmtPosUv = new _gfx["default"].VertexFormat([ { + name: _gfx["default"].ATTR_POSITION, + type: _gfx["default"].ATTR_TYPE_FLOAT32, + num: 2 + }, { + name: _gfx["default"].ATTR_UV0, + type: _gfx["default"].ATTR_TYPE_FLOAT32, + num: 2 + } ]); + vfmtPosUv.name = "vfmtPosUv"; + _gfx["default"].VertexFormat.XY_UV = vfmtPosUv; + var vfmtPosColor = new _gfx["default"].VertexFormat([ { + name: _gfx["default"].ATTR_POSITION, + type: _gfx["default"].ATTR_TYPE_FLOAT32, + num: 2 + }, { + name: _gfx["default"].ATTR_COLOR, + type: _gfx["default"].ATTR_TYPE_UINT8, + num: 4, + normalize: true + } ]); + vfmtPosColor.name = "vfmtPosColor"; + _gfx["default"].VertexFormat.XY_Color = vfmtPosColor; + var vfmtPos = new _gfx["default"].VertexFormat([ { + name: _gfx["default"].ATTR_POSITION, + type: _gfx["default"].ATTR_TYPE_FLOAT32, + num: 2 + } ]); + vfmtPos.name = "vfmtPos"; + _gfx["default"].VertexFormat.XY = vfmtPos; + module.exports = { + vfmt3D: vfmt3D, + vfmtPosUvColor: vfmtPosUvColor, + vfmtPosUvTwoColor: vfmtPosUvTwoColor, + vfmtPosUv: vfmtPosUv, + vfmtPosColor: vfmtPosColor, + vfmtPos: vfmtPos + }; + }), { + "../../../renderer/gfx": 373 + } ], + 315: [ (function(require, module, exports) { + "use strict"; + require("../platform/CCSys"); + var EXTNAME_RE = /(\.[^\.\/\?\\]*)(\?.*)?$/; + var DIRNAME_RE = /((.*)(\/|\\|\\\\))?(.*?\..*$)?/; + var NORMALIZE_RE = /[^\.\/]+\/\.\.\//; + cc.path = { + join: function join() { + var l = arguments.length; + var result = ""; + for (var i = 0; i < l; i++) result = (result + ("" === result ? "" : "/") + arguments[i]).replace(/(\/|\\\\)$/, ""); + return result; + }, + extname: function extname(pathStr) { + var temp = EXTNAME_RE.exec(pathStr); + return temp ? temp[1] : ""; + }, + mainFileName: function mainFileName(fileName) { + if (fileName) { + var idx = fileName.lastIndexOf("."); + if (-1 !== idx) return fileName.substring(0, idx); + } + return fileName; + }, + basename: function basename(pathStr, extname) { + var index = pathStr.indexOf("?"); + index > 0 && (pathStr = pathStr.substring(0, index)); + var reg = /(\/|\\)([^\/\\]+)$/g; + var result = reg.exec(pathStr.replace(/(\/|\\)$/, "")); + if (!result) return pathStr; + var baseName = result[2]; + if (extname && pathStr.substring(pathStr.length - extname.length).toLowerCase() === extname.toLowerCase()) return baseName.substring(0, baseName.length - extname.length); + return baseName; + }, + dirname: function dirname(pathStr) { + var temp = DIRNAME_RE.exec(pathStr); + return temp ? temp[2] : ""; + }, + changeExtname: function changeExtname(pathStr, extname) { + extname = extname || ""; + var index = pathStr.indexOf("?"); + var tempStr = ""; + if (index > 0) { + tempStr = pathStr.substring(index); + pathStr = pathStr.substring(0, index); + } + index = pathStr.lastIndexOf("."); + if (index < 0) return pathStr + extname + tempStr; + return pathStr.substring(0, index) + extname + tempStr; + }, + changeBasename: function changeBasename(pathStr, basename, isSameExt) { + if (0 === basename.indexOf(".")) return this.changeExtname(pathStr, basename); + var index = pathStr.indexOf("?"); + var tempStr = ""; + var ext = isSameExt ? this.extname(pathStr) : ""; + if (index > 0) { + tempStr = pathStr.substring(index); + pathStr = pathStr.substring(0, index); + } + index = pathStr.lastIndexOf("/"); + index = index <= 0 ? 0 : index + 1; + return pathStr.substring(0, index) + basename + ext + tempStr; + }, + _normalize: function _normalize(url) { + var oldUrl = url = String(url); + do { + oldUrl = url; + url = url.replace(NORMALIZE_RE, ""); + } while (oldUrl.length !== url.length); + return url; + }, + sep: cc.sys.os === cc.sys.OS_WINDOWS ? "\\" : "/", + stripSep: function stripSep(path) { + return path.replace(/[\/\\]$/, ""); + } + }; + module.exports = cc.path; + }), { + "../platform/CCSys": 249 + } ], + 316: [ (function(require, module, exports) { + "use strict"; + var AffineTransform = function AffineTransform(a, b, c, d, tx, ty) { + this.a = a; + this.b = b; + this.c = c; + this.d = d; + this.tx = tx; + this.ty = ty; + }; + AffineTransform.create = function(a, b, c, d, tx, ty) { + return { + a: a, + b: b, + c: c, + d: d, + tx: tx, + ty: ty + }; + }; + AffineTransform.identity = function() { + return { + a: 1, + b: 0, + c: 0, + d: 1, + tx: 0, + ty: 0 + }; + }; + AffineTransform.clone = function(t) { + return { + a: t.a, + b: t.b, + c: t.c, + d: t.d, + tx: t.tx, + ty: t.ty + }; + }; + AffineTransform.concat = function(out, t1, t2) { + var a = t1.a, b = t1.b, c = t1.c, d = t1.d, tx = t1.tx, ty = t1.ty; + out.a = a * t2.a + b * t2.c; + out.b = a * t2.b + b * t2.d; + out.c = c * t2.a + d * t2.c; + out.d = c * t2.b + d * t2.d; + out.tx = tx * t2.a + ty * t2.c + t2.tx; + out.ty = tx * t2.b + ty * t2.d + t2.ty; + return out; + }; + AffineTransform.invert = function(out, t) { + var a = t.a, b = t.b, c = t.c, d = t.d; + var determinant = 1 / (a * d - b * c); + var tx = t.tx, ty = t.ty; + out.a = determinant * d; + out.b = -determinant * b; + out.c = -determinant * c; + out.d = determinant * a; + out.tx = determinant * (c * ty - d * tx); + out.ty = determinant * (b * tx - a * ty); + return out; + }; + AffineTransform.fromMat4 = function(out, mat) { + var matm = mat.m; + out.a = matm[0]; + out.b = matm[1]; + out.c = matm[4]; + out.d = matm[5]; + out.tx = matm[12]; + out.ty = matm[13]; + return out; + }; + AffineTransform.transformVec2 = function(out, point, transOrY, t) { + var x, y; + if (void 0 === t) { + t = transOrY; + x = point.x; + y = point.y; + } else { + x = point; + y = transOrY; + } + out.x = t.a * x + t.c * y + t.tx; + out.y = t.b * x + t.d * y + t.ty; + return out; + }; + AffineTransform.transformSize = function(out, size, t) { + out.width = t.a * size.width + t.c * size.height; + out.height = t.b * size.width + t.d * size.height; + return out; + }; + AffineTransform.transformRect = function(out, rect, t) { + var ol = rect.x; + var ob = rect.y; + var or = ol + rect.width; + var ot = ob + rect.height; + var lbx = t.a * ol + t.c * ob + t.tx; + var lby = t.b * ol + t.d * ob + t.ty; + var rbx = t.a * or + t.c * ob + t.tx; + var rby = t.b * or + t.d * ob + t.ty; + var ltx = t.a * ol + t.c * ot + t.tx; + var lty = t.b * ol + t.d * ot + t.ty; + var rtx = t.a * or + t.c * ot + t.tx; + var rty = t.b * or + t.d * ot + t.ty; + var minX = Math.min(lbx, rbx, ltx, rtx); + var maxX = Math.max(lbx, rbx, ltx, rtx); + var minY = Math.min(lby, rby, lty, rty); + var maxY = Math.max(lby, rby, lty, rty); + out.x = minX; + out.y = minY; + out.width = maxX - minX; + out.height = maxY - minY; + return out; + }; + AffineTransform.transformObb = function(out_bl, out_tl, out_tr, out_br, rect, anAffineTransform) { + var x = rect.x; + var y = rect.y; + var width = rect.width; + var height = rect.height; + var tx = anAffineTransform.a * x + anAffineTransform.c * y + anAffineTransform.tx; + var ty = anAffineTransform.b * x + anAffineTransform.d * y + anAffineTransform.ty; + var xa = anAffineTransform.a * width; + var xb = anAffineTransform.b * width; + var yc = anAffineTransform.c * height; + var yd = anAffineTransform.d * height; + out_tl.x = tx; + out_tl.y = ty; + out_tr.x = xa + tx; + out_tr.y = xb + ty; + out_bl.x = yc + tx; + out_bl.y = yd + ty; + out_br.x = xa + yc + tx; + out_br.y = xb + yd + ty; + }; + cc.AffineTransform = module.exports = AffineTransform; + }), {} ], + 317: [ (function(require, module, exports) { + "use strict"; + var Flags = require("../platform/CCObject").Flags; + var misc = require("./misc"); + var js = require("../platform/js"); + var IdGenerater = require("../platform/id-generater"); + var eventManager = require("../event-manager"); + var RenderFlow = require("../renderer/render-flow"); + var Destroying = Flags.Destroying; + var DontDestroy = Flags.DontDestroy; + var Deactivating = Flags.Deactivating; + var CHILD_ADDED = "child-added"; + var CHILD_REMOVED = "child-removed"; + var idGenerater = new IdGenerater("Node"); + function getConstructor(typeOrClassName) { + if (!typeOrClassName) { + cc.errorID(3804); + return null; + } + if ("string" === typeof typeOrClassName) return js.getClassByName(typeOrClassName); + return typeOrClassName; + } + function findComponent(node, constructor) { + if (constructor._sealed) for (var i = 0; i < node._components.length; ++i) { + var comp = node._components[i]; + if (comp.constructor === constructor) return comp; + } else for (var _i = 0; _i < node._components.length; ++_i) { + var _comp = node._components[_i]; + if (_comp instanceof constructor) return _comp; + } + return null; + } + function findComponents(node, constructor, components) { + if (constructor._sealed) for (var i = 0; i < node._components.length; ++i) { + var comp = node._components[i]; + comp.constructor === constructor && components.push(comp); + } else for (var _i2 = 0; _i2 < node._components.length; ++_i2) { + var _comp2 = node._components[_i2]; + _comp2 instanceof constructor && components.push(_comp2); + } + } + function findChildComponent(children, constructor) { + for (var i = 0; i < children.length; ++i) { + var node = children[i]; + var comp = findComponent(node, constructor); + if (comp) return comp; + if (node._children.length > 0) { + comp = findChildComponent(node._children, constructor); + if (comp) return comp; + } + } + return null; + } + function findChildComponents(children, constructor, components) { + for (var i = 0; i < children.length; ++i) { + var node = children[i]; + findComponents(node, constructor, components); + node._children.length > 0 && findChildComponents(node._children, constructor, components); + } + } + var BaseNode = cc.Class({ + name: "cc._BaseNode", + extends: cc.Object, + properties: { + _parent: null, + _children: [], + _active: true, + _components: [], + _prefab: null, + _persistNode: { + get: function get() { + return (this._objFlags & DontDestroy) > 0; + }, + set: function set(value) { + value ? this._objFlags |= DontDestroy : this._objFlags &= ~DontDestroy; + } + }, + name: { + get: function get() { + return this._name; + }, + set: function set(value) { + false; + this._name = value; + false; + } + }, + uuid: { + get: function get() { + return this._id; + } + }, + children: { + get: function get() { + return this._children; + } + }, + childrenCount: { + get: function get() { + return this._children.length; + } + }, + active: { + get: function get() { + return this._active; + }, + set: function set(value) { + value = !!value; + if (this._active !== value) { + this._active = value; + var parent = this._parent; + if (parent) { + var couldActiveInScene = parent._activeInHierarchy; + couldActiveInScene && cc.director._nodeActivator.activateNode(this, value); + } + } + } + }, + activeInHierarchy: { + get: function get() { + return this._activeInHierarchy; + } + } + }, + ctor: function ctor(name) { + this._name = void 0 !== name ? name : "New Node"; + this._activeInHierarchy = false; + this._id = idGenerater.getNewId(); + cc.director._scheduler && cc.director._scheduler.enableForTarget(this); + this.__eventTargets = []; + }, + getParent: function getParent() { + return this._parent; + }, + setParent: function setParent(value) { + if (this._parent === value) return; + false; + var oldParent = this._parent; + (true, oldParent) && oldParent._objFlags & Deactivating && cc.errorID(3821); + this._parent = value || null; + this._onSetParent(value); + if (value) { + (true, value._objFlags & Deactivating) && cc.errorID(3821); + eventManager._setDirtyForNode(this); + value._children.push(this); + value.emit && value.emit(CHILD_ADDED, this); + value._renderFlag |= RenderFlow.FLAG_CHILDREN; + } + if (oldParent) { + if (!(oldParent._objFlags & Destroying)) { + var removeAt = oldParent._children.indexOf(this); + false; + oldParent._children.splice(removeAt, 1); + oldParent.emit && oldParent.emit(CHILD_REMOVED, this); + this._onHierarchyChanged(oldParent); + 0 === oldParent._children.length && (oldParent._renderFlag &= ~RenderFlow.FLAG_CHILDREN); + } + } else value && this._onHierarchyChanged(null); + }, + attr: function attr(attrs) { + js.mixin(this, attrs); + }, + getChildByUuid: function getChildByUuid(uuid) { + if (!uuid) { + cc.log("Invalid uuid"); + return null; + } + var locChildren = this._children; + for (var i = 0, len = locChildren.length; i < len; i++) if (locChildren[i]._id === uuid) return locChildren[i]; + return null; + }, + getChildByName: function getChildByName(name) { + if (!name) { + cc.log("Invalid name"); + return null; + } + var locChildren = this._children; + for (var i = 0, len = locChildren.length; i < len; i++) if (locChildren[i]._name === name) return locChildren[i]; + return null; + }, + addChild: function addChild(child) { + false; + cc.assertID(child, 1606); + cc.assertID(null === child._parent, 1605); + child.setParent(this); + }, + insertChild: function insertChild(child, siblingIndex) { + child.parent = this; + child.setSiblingIndex(siblingIndex); + }, + getSiblingIndex: function getSiblingIndex() { + return this._parent ? this._parent._children.indexOf(this) : 0; + }, + setSiblingIndex: function setSiblingIndex(index) { + if (!this._parent) return; + if (this._parent._objFlags & Deactivating) { + cc.errorID(3821); + return; + } + var siblings = this._parent._children; + index = -1 !== index ? index : siblings.length - 1; + var oldIndex = siblings.indexOf(this); + if (index !== oldIndex) { + siblings.splice(oldIndex, 1); + index < siblings.length ? siblings.splice(index, 0, this) : siblings.push(this); + this._onSiblingIndexChanged && this._onSiblingIndexChanged(index); + } + }, + walk: function walk(prefunc, postfunc) { + var BaseNode = cc._BaseNode; + var index = 1; + var children, child, curr, i, afterChildren; + var stack = BaseNode._stacks[BaseNode._stackId]; + if (!stack) { + stack = []; + BaseNode._stacks.push(stack); + } + BaseNode._stackId++; + stack.length = 0; + stack[0] = this; + var parent = null; + afterChildren = false; + while (index) { + index--; + curr = stack[index]; + if (!curr) continue; + !afterChildren && prefunc ? prefunc(curr) : afterChildren && postfunc && postfunc(curr); + stack[index] = null; + if (!afterChildren) { + if (curr._children.length > 0) { + parent = curr; + children = curr._children; + i = 0; + stack[index] = children[i]; + index++; + } else { + stack[index] = curr; + index++; + afterChildren = true; + } + continue; + } + if (parent === this._parent) break; + afterChildren = false; + if (children) { + i++; + if (children[i]) { + stack[index] = children[i]; + index++; + } else if (parent) { + stack[index] = parent; + index++; + afterChildren = true; + if (parent._parent) { + children = parent._parent._children; + i = children.indexOf(parent); + parent = parent._parent; + } else { + parent = null; + children = null; + } + if (i < 0) break; + } + } + } + stack.length = 0; + BaseNode._stackId--; + }, + cleanup: function cleanup() {}, + removeFromParent: function removeFromParent(cleanup) { + if (this._parent) { + void 0 === cleanup && (cleanup = true); + this._parent.removeChild(this, cleanup); + } + }, + removeChild: function removeChild(child, cleanup) { + if (this._children.indexOf(child) > -1) { + (cleanup || void 0 === cleanup) && child.cleanup(); + child.parent = null; + } + }, + removeAllChildren: function removeAllChildren(cleanup) { + var children = this._children; + void 0 === cleanup && (cleanup = true); + for (var i = children.length - 1; i >= 0; i--) { + var node = children[i]; + if (node) { + cleanup && node.cleanup(); + node.parent = null; + } + } + this._children.length = 0; + }, + isChildOf: function isChildOf(parent) { + var child = this; + do { + if (child === parent) return true; + child = child._parent; + } while (child); + return false; + }, + getComponent: function getComponent(typeOrClassName) { + var constructor = getConstructor(typeOrClassName); + if (constructor) return findComponent(this, constructor); + return null; + }, + getComponents: function getComponents(typeOrClassName) { + var constructor = getConstructor(typeOrClassName), components = []; + constructor && findComponents(this, constructor, components); + return components; + }, + getComponentInChildren: function getComponentInChildren(typeOrClassName) { + var constructor = getConstructor(typeOrClassName); + if (constructor) return findChildComponent(this._children, constructor); + return null; + }, + getComponentsInChildren: function getComponentsInChildren(typeOrClassName) { + var constructor = getConstructor(typeOrClassName), components = []; + if (constructor) { + findComponents(this, constructor, components); + findChildComponents(this._children, constructor, components); + } + return components; + }, + _checkMultipleComp: (false, false) && function(ctor) { + var existing = this.getComponent(ctor._disallowMultiple); + if (existing) { + existing.constructor === ctor ? cc.errorID(3805, js.getClassName(ctor), this._name) : cc.errorID(3806, js.getClassName(ctor), this._name, js.getClassName(existing)); + return false; + } + return true; + }, + addComponent: function addComponent(typeOrClassName) { + false; + var constructor; + if ("string" === typeof typeOrClassName) { + constructor = js.getClassByName(typeOrClassName); + if (!constructor) { + cc.errorID(3807, typeOrClassName); + cc._RFpeek() && cc.errorID(3808, typeOrClassName); + return null; + } + } else { + if (!typeOrClassName) { + cc.errorID(3804); + return null; + } + constructor = typeOrClassName; + } + if ("function" !== typeof constructor) { + cc.errorID(3809); + return null; + } + if (!js.isChildClassOf(constructor, cc.Component)) { + cc.errorID(3810); + return null; + } + if ((false, false) && constructor._disallowMultiple && !this._checkMultipleComp(constructor)) return null; + var ReqComp = constructor._requireComponent; + if (ReqComp && !this.getComponent(ReqComp)) { + var depended = this.addComponent(ReqComp); + if (!depended) return null; + } + var component = new constructor(); + component.node = this; + this._components.push(component); + (false, false) && cc.engine && this._id in cc.engine.attachedObjsForEditor && (cc.engine.attachedObjsForEditor[component._id] = component); + this._activeInHierarchy && cc.director._nodeActivator.activateComp(component); + return component; + }, + _addComponentAt: false, + removeComponent: function removeComponent(component) { + if (!component) { + cc.errorID(3813); + return; + } + component instanceof cc.Component || (component = this.getComponent(component)); + component && component.destroy(); + }, + _getDependComponent: false, + _removeComponent: function _removeComponent(component) { + if (!component) { + cc.errorID(3814); + return; + } + if (!(this._objFlags & Destroying)) { + var i = this._components.indexOf(component); + if (-1 !== i) { + this._components.splice(i, 1); + (false, false) && cc.engine && delete cc.engine.attachedObjsForEditor[component._id]; + } else component.node !== this && cc.errorID(3815); + } + }, + destroy: function destroy() { + cc.Object.prototype.destroy.call(this) && (this.active = false); + }, + destroyAllChildren: function destroyAllChildren() { + var children = this._children; + for (var i = 0; i < children.length; ++i) children[i].destroy(); + }, + _onSetParent: function _onSetParent(value) {}, + _onPostActivated: function _onPostActivated() {}, + _onBatchCreated: function _onBatchCreated(dontSyncChildPrefab) {}, + _onHierarchyChanged: function _onHierarchyChanged(oldParent) { + var newParent = this._parent; + if (this._persistNode && !(newParent instanceof cc.Scene)) { + cc.game.removePersistRootNode(this); + false; + } + var scene; + var inCurrentSceneBefore; + var inCurrentSceneNow; + var newPrefabRoot; + var myPrefabInfo; + var PrefabUtils; + false, false; + var shouldActiveNow = this._active && !!(newParent && newParent._activeInHierarchy); + this._activeInHierarchy !== shouldActiveNow && cc.director._nodeActivator.activateNode(this, shouldActiveNow); + }, + _instantiate: function _instantiate(cloned, isSyncedNode) { + cloned || (cloned = cc.instantiate._clone(this, this)); + var newPrefabInfo = cloned._prefab; + var PrefabUtils; + false; + var syncing; + false; + cloned._parent = null; + cloned._onBatchCreated(isSyncedNode); + return cloned; + }, + _registerIfAttached: (false, false) && function(register) { + var attachedObjsForEditor = cc.engine.attachedObjsForEditor; + if (register) { + attachedObjsForEditor[this._id] = this; + for (var i = 0; i < this._components.length; i++) { + var comp = this._components[i]; + attachedObjsForEditor[comp._id] = comp; + } + cc.engine.emit("node-attach-to-scene", this); + } else { + cc.engine.emit("node-detach-from-scene", this); + delete attachedObjsForEditor[this._id]; + for (var _i3 = 0; _i3 < this._components.length; _i3++) { + var _comp3 = this._components[_i3]; + delete attachedObjsForEditor[_comp3._id]; + } + } + var children = this._children; + for (var _i4 = 0, len = children.length; _i4 < len; ++_i4) { + var child = children[_i4]; + child._registerIfAttached(register); + } + }, + _onPreDestroy: function _onPreDestroy() { + var i, len; + this._objFlags |= Destroying; + var parent = this._parent; + var destroyByParent = parent && parent._objFlags & Destroying; + !destroyByParent && (false, false) && this._registerIfAttached(false); + var children = this._children; + for (i = 0, len = children.length; i < len; ++i) children[i]._destroyImmediate(); + for (i = 0, len = this._components.length; i < len; ++i) { + var component = this._components[i]; + component._destroyImmediate(); + } + var eventTargets = this.__eventTargets; + for (i = 0, len = eventTargets.length; i < len; ++i) { + var target = eventTargets[i]; + target && target.targetOff(this); + } + eventTargets.length = 0; + this._persistNode && cc.game.removePersistRootNode(this); + if (!destroyByParent && parent) { + var childIndex = parent._children.indexOf(this); + parent._children.splice(childIndex, 1); + parent.emit && parent.emit("child-removed", this); + } + return destroyByParent; + }, + onRestore: false + }); + BaseNode.idGenerater = idGenerater; + BaseNode._stacks = [ [] ]; + BaseNode._stackId = 0; + BaseNode.prototype._onPreDestroyBase = BaseNode.prototype._onPreDestroy; + false; + BaseNode.prototype._onHierarchyChangedBase = BaseNode.prototype._onHierarchyChanged; + false; + var SameNameGetSets = [ "parent", "name", "children", "childrenCount" ]; + misc.propertyDefine(BaseNode, SameNameGetSets, {}); + false; + cc._BaseNode = module.exports = BaseNode; + }), { + "../event-manager": 185, + "../platform/CCObject": 246, + "../platform/id-generater": 257, + "../platform/js": 261, + "../renderer/render-flow": 273, + "./misc": 325 + } ], + 318: [ (function(require, module, exports) { + "use strict"; + var EPSILON = 1e-6; + function binarySearchEpsilon(array, value) { + for (var l = 0, h = array.length - 1, m = h >>> 1; l <= h; m = l + h >>> 1) { + var test = array[m]; + if (test > value + EPSILON) h = m - 1; else { + if (!(test < value - EPSILON)) return m; + l = m + 1; + } + } + return ~l; + } + module.exports = { + binarySearchEpsilon: binarySearchEpsilon + }; + }), {} ], + 319: [ (function(require, module, exports) { + "use strict"; + var RenderComponent = require("../components/CCRenderComponent"); + var BlendFactor = require("../platform/CCMacro").BlendFactor; + var gfx = require("../../renderer/gfx"); + var BlendFunc = cc.Class({ + properties: { + _srcBlendFactor: BlendFactor.SRC_ALPHA, + _dstBlendFactor: BlendFactor.ONE_MINUS_SRC_ALPHA, + srcBlendFactor: { + get: function get() { + return this._srcBlendFactor; + }, + set: function set(value) { + if (this._srcBlendFactor === value) return; + this._srcBlendFactor = value; + this._updateBlendFunc(true); + this._onBlendChanged && this._onBlendChanged(); + }, + animatable: false, + type: BlendFactor, + tooltip: false, + visible: true + }, + dstBlendFactor: { + get: function get() { + return this._dstBlendFactor; + }, + set: function set(value) { + if (this._dstBlendFactor === value) return; + this._dstBlendFactor = value; + this._updateBlendFunc(true); + }, + animatable: false, + type: BlendFactor, + tooltip: false, + visible: true + } + }, + setMaterial: function setMaterial(index, material) { + var materialVar = RenderComponent.prototype.setMaterial.call(this, index, material); + this._srcBlendFactor === BlendFactor.SRC_ALPHA && this._dstBlendFactor === BlendFactor.ONE_MINUS_SRC_ALPHA || this._updateMaterialBlendFunc(materialVar); + return materialVar; + }, + _updateMaterial: function _updateMaterial() { + this._updateBlendFunc(); + }, + _updateBlendFunc: function _updateBlendFunc(force) { + if (!force && this._srcBlendFactor === BlendFactor.SRC_ALPHA && this._dstBlendFactor === BlendFactor.ONE_MINUS_SRC_ALPHA) return; + var materials = this.getMaterials(); + for (var i = 0; i < materials.length; i++) { + var material = materials[i]; + this._updateMaterialBlendFunc(material); + } + }, + _updateMaterialBlendFunc: function _updateMaterialBlendFunc(material) { + material.setBlend(true, gfx.BLEND_FUNC_ADD, this._srcBlendFactor, this._dstBlendFactor, gfx.BLEND_FUNC_ADD, this._srcBlendFactor, this._dstBlendFactor); + false; + } + }); + module.exports = cc.BlendFunc = BlendFunc; + }), { + "../../renderer/gfx": 373, + "../components/CCRenderComponent": 161, + "../platform/CCMacro": 245 + } ], + 320: [ (function(require, module, exports) { + "use strict"; + var Base64Values = require("./misc").BASE64_VALUES; + var HexChars = "0123456789abcdef".split(""); + var _t = [ "", "", "", "" ]; + var UuidTemplate = _t.concat(_t, "-", _t, "-", _t, "-", _t, "-", _t, _t, _t); + var Indices = UuidTemplate.map((function(x, i) { + return "-" === x ? NaN : i; + })).filter(isFinite); + module.exports = function(base64) { + if (22 !== base64.length) return base64; + UuidTemplate[0] = base64[0]; + UuidTemplate[1] = base64[1]; + for (var i = 2, j = 2; i < 22; i += 2) { + var lhs = Base64Values[base64.charCodeAt(i)]; + var rhs = Base64Values[base64.charCodeAt(i + 1)]; + UuidTemplate[Indices[j++]] = HexChars[lhs >> 2]; + UuidTemplate[Indices[j++]] = HexChars[(3 & lhs) << 2 | rhs >> 4]; + UuidTemplate[Indices[j++]] = HexChars[15 & rhs]; + } + return UuidTemplate.join(""); + }; + false; + }), { + "./misc": 325 + } ], + 321: [ (function(require, module, exports) { + "use strict"; + cc.find = module.exports = function(path, referenceNode) { + if (null == path) { + cc.errorID(3814); + return null; + } + if (referenceNode) false; else { + var scene = cc.director.getScene(); + if (!scene) { + false; + return null; + } + false; + referenceNode = scene; + } + var match = referenceNode; + var startIndex = "/" !== path[0] ? 0 : 1; + var nameList = path.split("/"); + for (var n = startIndex; n < nameList.length; n++) { + var name = nameList[n]; + var children = match._children; + match = null; + for (var t = 0, len = children.length; t < len; ++t) { + var subChild = children[t]; + if (subChild.name === name) { + match = subChild; + break; + } + } + if (!match) return null; + } + return match; + }; + }), {} ], + 322: [ (function(require, module, exports) { + "use strict"; + var _materialVariant = _interopRequireDefault(require("../assets/material/material-variant")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + var Material = require("../assets/material/CCMaterial"); + var GraySpriteState = cc.Class({ + properties: { + _normalMaterial: null, + normalMaterial: { + get: function get() { + return this._normalMaterial; + }, + set: function set(val) { + this._normalMaterial = val; + this._updateDisabledState && this._updateDisabledState(); + }, + type: Material, + tooltip: false, + animatable: false + }, + _grayMaterial: null, + grayMaterial: { + get: function get() { + return this._grayMaterial; + }, + set: function set(val) { + this._grayMaterial = val; + this._updateDisabledState && this._updateDisabledState(); + }, + type: Material, + tooltip: false, + animatable: false + } + }, + _switchGrayMaterial: function _switchGrayMaterial(useGrayMaterial, renderComp) { + var material; + if (useGrayMaterial) { + material = this._grayMaterial; + material || (material = Material.getBuiltinMaterial("2d-gray-sprite")); + material = this._grayMaterial = _materialVariant["default"].create(material, renderComp); + } else { + material = this._normalMaterial; + material || (material = Material.getBuiltinMaterial("2d-sprite", renderComp)); + material = this._normalMaterial = _materialVariant["default"].create(material, renderComp); + } + renderComp.setMaterial(0, material); + } + }); + module.exports = GraySpriteState; + }), { + "../assets/material/CCMaterial": 125, + "../assets/material/material-variant": 132 + } ], + 323: [ (function(require, module, exports) { + "use strict"; + var eventRegx = /^(click)(\s)*=|(param)(\s)*=/; + var imageAttrReg = /(\s)*src(\s)*=|(\s)*height(\s)*=|(\s)*width(\s)*=|(\s)*align(\s)*=|(\s)*offset(\s)*=|(\s)*click(\s)*=|(\s)*param(\s)*=/; + var HtmlTextParser = function HtmlTextParser() { + this._parsedObject = {}; + this._specialSymbolArray = []; + this._specialSymbolArray.push([ /</g, "<" ]); + this._specialSymbolArray.push([ />/g, ">" ]); + this._specialSymbolArray.push([ /&/g, "&" ]); + this._specialSymbolArray.push([ /"/g, '"' ]); + this._specialSymbolArray.push([ /'/g, "'" ]); + this._specialSymbolArray.push([ / /g, " " ]); + }; + HtmlTextParser.prototype = { + constructor: HtmlTextParser, + parse: function parse(htmlString) { + this._resultObjectArray = []; + if (!htmlString) return this._resultObjectArray; + this._stack = []; + var startIndex = 0; + var length = htmlString.length; + while (startIndex < length) { + var tagEndIndex = htmlString.indexOf(">", startIndex); + var tagBeginIndex = -1; + if (tagEndIndex >= 0) { + tagBeginIndex = htmlString.lastIndexOf("<", tagEndIndex); + var noTagBegin = tagBeginIndex < startIndex - 1; + if (noTagBegin) { + tagBeginIndex = htmlString.indexOf("<", tagEndIndex + 1); + tagEndIndex = htmlString.indexOf(">", tagBeginIndex + 1); + } + } + if (tagBeginIndex < 0) { + this._stack.pop(); + this._processResult(htmlString.substring(startIndex)); + startIndex = length; + } else { + var newStr = htmlString.substring(startIndex, tagBeginIndex); + var tagStr = htmlString.substring(tagBeginIndex + 1, tagEndIndex); + "" === tagStr && (newStr = htmlString.substring(startIndex, tagEndIndex + 1)); + this._processResult(newStr); + -1 === tagEndIndex ? tagEndIndex = tagBeginIndex : "/" === htmlString.charAt(tagBeginIndex + 1) ? this._stack.pop() : this._addToStack(tagStr); + startIndex = tagEndIndex + 1; + } + } + return this._resultObjectArray; + }, + _attributeToObject: function _attributeToObject(attribute) { + attribute = attribute.trim(); + var obj = {}; + var header = attribute.match(/^(color|size)(\s)*=/); + var tagName; + var nextSpace; + var eventObj; + var eventHanlderString; + if (header) { + tagName = header[0]; + attribute = attribute.substring(tagName.length).trim(); + if ("" === attribute) return obj; + nextSpace = attribute.indexOf(" "); + switch (tagName[0]) { + case "c": + obj.color = nextSpace > -1 ? attribute.substring(0, nextSpace).trim() : attribute; + break; + + case "s": + obj.size = parseInt(attribute); + } + if (nextSpace > -1) { + eventHanlderString = attribute.substring(nextSpace + 1).trim(); + eventObj = this._processEventHandler(eventHanlderString); + obj.event = eventObj; + } + return obj; + } + header = attribute.match(/^(br(\s)*\/)/); + if (header && header[0].length > 0) { + tagName = header[0].trim(); + if (tagName.startsWith("br") && "/" === tagName[tagName.length - 1]) { + obj.isNewLine = true; + this._resultObjectArray.push({ + text: "", + style: { + newline: true + } + }); + return obj; + } + } + header = attribute.match(/^(img(\s)*src(\s)*=[^>]+\/)/); + if (header && header[0].length > 0) { + tagName = header[0].trim(); + if (tagName.startsWith("img") && "/" === tagName[tagName.length - 1]) { + header = attribute.match(imageAttrReg); + var tagValue; + var remainingArgument; + var isValidImageTag = false; + while (header) { + attribute = attribute.substring(attribute.indexOf(header[0])); + tagName = attribute.substr(0, header[0].length); + remainingArgument = attribute.substring(tagName.length).trim(); + nextSpace = remainingArgument.indexOf(" "); + tagValue = nextSpace > -1 ? remainingArgument.substr(0, nextSpace) : remainingArgument; + tagName = tagName.replace(/[^a-zA-Z]/g, "").trim(); + tagName = tagName.toLocaleLowerCase(); + attribute = remainingArgument.substring(nextSpace).trim(); + tagValue.endsWith("/") && (tagValue = tagValue.slice(0, -1)); + if ("src" === tagName) { + switch (tagValue.charCodeAt(0)) { + case 34: + case 39: + isValidImageTag = true; + tagValue = tagValue.slice(1, -1); + } + obj.isImage = true; + obj.src = tagValue; + } else if ("height" === tagName) obj.imageHeight = parseInt(tagValue); else if ("width" === tagName) obj.imageWidth = parseInt(tagValue); else if ("align" === tagName) { + switch (tagValue.charCodeAt(0)) { + case 34: + case 39: + tagValue = tagValue.slice(1, -1); + } + obj.imageAlign = tagValue.toLocaleLowerCase(); + } else "offset" === tagName ? obj.imageOffset = tagValue : "click" === tagName && (obj.event = this._processEventHandler(tagName + "=" + tagValue)); + obj.event && "param" === tagName && (obj.event.param = tagValue.replace(/^\"|\"$/g, "")); + header = attribute.match(imageAttrReg); + } + isValidImageTag && obj.isImage && this._resultObjectArray.push({ + text: "", + style: obj + }); + return {}; + } + } + header = attribute.match(/^(outline(\s)*[^>]*)/); + if (header) { + attribute = header[0].substring("outline".length).trim(); + var defaultOutlineObject = { + color: "#ffffff", + width: 1 + }; + if (attribute) { + var outlineAttrReg = /(\s)*color(\s)*=|(\s)*width(\s)*=|(\s)*click(\s)*=|(\s)*param(\s)*=/; + header = attribute.match(outlineAttrReg); + var tagValue; + while (header) { + attribute = attribute.substring(attribute.indexOf(header[0])); + tagName = attribute.substr(0, header[0].length); + remainingArgument = attribute.substring(tagName.length).trim(); + nextSpace = remainingArgument.indexOf(" "); + tagValue = nextSpace > -1 ? remainingArgument.substr(0, nextSpace) : remainingArgument; + tagName = tagName.replace(/[^a-zA-Z]/g, "").trim(); + tagName = tagName.toLocaleLowerCase(); + attribute = remainingArgument.substring(nextSpace).trim(); + "click" === tagName ? obj.event = this._processEventHandler(tagName + "=" + tagValue) : "color" === tagName ? defaultOutlineObject.color = tagValue : "width" === tagName && (defaultOutlineObject.width = parseInt(tagValue)); + obj.event && "param" === tagName && (obj.event.param = tagValue.replace(/^\"|\"$/g, "")); + header = attribute.match(outlineAttrReg); + } + } + obj.outline = defaultOutlineObject; + } + header = attribute.match(/^(on|u|b|i)(\s)*/); + if (header && header[0].length > 0) { + tagName = header[0]; + attribute = attribute.substring(tagName.length).trim(); + switch (tagName[0]) { + case "u": + obj.underline = true; + break; + + case "i": + obj.italic = true; + break; + + case "b": + obj.bold = true; + } + if ("" === attribute) return obj; + eventObj = this._processEventHandler(attribute); + obj.event = eventObj; + } + return obj; + }, + _processEventHandler: function _processEventHandler(eventString) { + var index = 0; + var obj = {}; + var eventNames = eventString.match(eventRegx); + var isValidTag = false; + while (eventNames) { + var eventName = eventNames[0]; + var eventValue = ""; + isValidTag = false; + eventString = eventString.substring(eventName.length).trim(); + if ('"' === eventString.charAt(0)) { + index = eventString.indexOf('"', 1); + if (index > -1) { + eventValue = eventString.substring(1, index).trim(); + isValidTag = true; + } + index++; + } else if ("'" === eventString.charAt(0)) { + index = eventString.indexOf("'", 1); + if (index > -1) { + eventValue = eventString.substring(1, index).trim(); + isValidTag = true; + } + index++; + } else { + var match = eventString.match(/(\S)+/); + eventValue = match ? match[0] : ""; + index = eventValue.length; + } + if (isValidTag) { + eventName = eventName.substring(0, eventName.length - 1).trim(); + obj[eventName] = eventValue; + } + eventString = eventString.substring(index).trim(); + eventNames = eventString.match(eventRegx); + } + return obj; + }, + _addToStack: function _addToStack(attribute) { + var obj = this._attributeToObject(attribute); + if (0 === this._stack.length) this._stack.push(obj); else { + if (obj.isNewLine || obj.isImage) return; + var previousTagObj = this._stack[this._stack.length - 1]; + for (var key in previousTagObj) obj[key] || (obj[key] = previousTagObj[key]); + this._stack.push(obj); + } + }, + _processResult: function _processResult(value) { + if ("" === value) return; + value = this._escapeSpecialSymbol(value); + this._stack.length > 0 ? this._resultObjectArray.push({ + text: value, + style: this._stack[this._stack.length - 1] + }) : this._resultObjectArray.push({ + text: value + }); + }, + _escapeSpecialSymbol: function _escapeSpecialSymbol(str) { + for (var i = 0; i < this._specialSymbolArray.length; ++i) { + var key = this._specialSymbolArray[i][0]; + var value = this._specialSymbolArray[i][1]; + str = str.replace(key, value); + } + return str; + } + }; + false; + module.exports = HtmlTextParser; + }), {} ], + 324: [ (function(require, module, exports) { + "use strict"; + require("./CCPath"); + true; + require("./profiler/CCProfiler"); + require("./find"); + require("./mutable-forward-iterator"); + }), { + "./CCPath": 315, + "./find": 321, + "./mutable-forward-iterator": 326, + "./profiler/CCProfiler": 329 + } ], + 325: [ (function(require, module, exports) { + "use strict"; + var js = require("../platform/js"); + var misc = {}; + misc.propertyDefine = function(ctor, sameNameGetSets, diffNameGetSets) { + function define(np, propName, getter, setter) { + var pd = Object.getOwnPropertyDescriptor(np, propName); + if (pd) { + pd.get && (np[getter] = pd.get); + pd.set && setter && (np[setter] = pd.set); + } else { + var getterFunc = np[getter]; + var clsName; + false; + js.getset(np, propName, getterFunc, np[setter]); + } + } + var propName, np = ctor.prototype; + for (var i = 0; i < sameNameGetSets.length; i++) { + propName = sameNameGetSets[i]; + var suffix = propName[0].toUpperCase() + propName.slice(1); + define(np, propName, "get" + suffix, "set" + suffix); + } + for (propName in diffNameGetSets) { + var getset = diffNameGetSets[propName]; + define(np, propName, getset[0], getset[1]); + } + }; + misc.NextPOT = function(x) { + x -= 1; + x |= x >> 1; + x |= x >> 2; + x |= x >> 4; + x |= x >> 8; + x |= x >> 16; + return x + 1; + }; + false; + misc.BUILTIN_CLASSID_RE = /^(?:cc|dragonBones|sp|ccsg)\..+/; + var BASE64_KEYS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; + var BASE64_VALUES = new Array(123); + for (var i = 0; i < 123; ++i) BASE64_VALUES[i] = 64; + for (var _i = 0; _i < 64; ++_i) BASE64_VALUES[BASE64_KEYS.charCodeAt(_i)] = _i; + misc.BASE64_VALUES = BASE64_VALUES; + misc.pushToMap = function(map, key, value, pushFront) { + var exists = map[key]; + if (exists) if (Array.isArray(exists)) if (pushFront) { + exists.push(exists[0]); + exists[0] = value; + } else exists.push(value); else map[key] = pushFront ? [ value, exists ] : [ exists, value ]; else map[key] = value; + }; + misc.clampf = function(value, min_inclusive, max_inclusive) { + if (min_inclusive > max_inclusive) { + var temp = min_inclusive; + min_inclusive = max_inclusive; + max_inclusive = temp; + } + return value < min_inclusive ? min_inclusive : value < max_inclusive ? value : max_inclusive; + }; + misc.clamp01 = function(value) { + return value < 0 ? 0 : value < 1 ? value : 1; + }; + misc.lerp = function(a, b, r) { + return a + (b - a) * r; + }; + misc.degreesToRadians = function(angle) { + return angle * cc.macro.RAD; + }; + misc.radiansToDegrees = function(angle) { + return angle * cc.macro.DEG; + }; + cc.misc = module.exports = misc; + }), { + "../platform/js": 261 + } ], + 326: [ (function(require, module, exports) { + "use strict"; + function MutableForwardIterator(array) { + this.i = 0; + this.array = array; + } + var proto = MutableForwardIterator.prototype; + proto.remove = function(value) { + var index = this.array.indexOf(value); + index >= 0 && this.removeAt(index); + }; + proto.removeAt = function(i) { + this.array.splice(i, 1); + i <= this.i && --this.i; + }; + proto.fastRemove = function(value) { + var index = this.array.indexOf(value); + index >= 0 && this.fastRemoveAt(index); + }; + proto.fastRemoveAt = function(i) { + var array = this.array; + array[i] = array[array.length - 1]; + --array.length; + i <= this.i && --this.i; + }; + proto.push = function(item) { + this.array.push(item); + }; + module.exports = MutableForwardIterator; + }), {} ], + 327: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var Pool = (function() { + function Pool() { + this.enabled = false; + this.count = 0; + this.maxSize = 1024; + } + var _proto = Pool.prototype; + _proto.get = function get() {}; + _proto.put = function put() {}; + _proto.clear = function clear() {}; + return Pool; + })(); + exports["default"] = Pool; + cc.pool = {}; + Pool.register = function(name, pool) { + cc.pool[name] = pool; + }; + module.exports = exports["default"]; + }), {} ], + 328: [ (function(require, module, exports) { + "use strict"; + cc._PrefabInfo = cc.Class({ + name: "cc.PrefabInfo", + properties: { + root: null, + asset: null, + fileId: "", + sync: false + } + }); + module.exports = { + syncWithPrefab: function syncWithPrefab(node) { + var _prefab = node._prefab; + if (!_prefab.asset) { + var NodeUtils; + var PrefabUtils; + false; + cc.errorID(3701, node.name); + node._prefab = null; + return; + } + var _objFlags = node._objFlags; + var _parent = node._parent; + var _id = node._id; + var _name = node._name; + var _active = node._active; + var eulerAnglesX = node._eulerAngles.x; + var eulerAnglesY = node._eulerAngles.y; + var eulerAnglesZ = node._eulerAngles.z; + var _localZOrder = node._localZOrder; + var trs = node._trs; + var x = trs[0]; + var y = trs[1]; + var z = trs[2]; + cc.game._isCloning = true; + var prefabRoot; + true; + _prefab.asset._doInstantiate(node); + cc.game._isCloning = false; + node._objFlags = _objFlags; + node._parent = _parent; + node._id = _id; + node._prefab = _prefab; + node._name = _name; + node._active = _active; + node._localZOrder = _localZOrder; + trs = node._trs; + trs[0] = x; + trs[1] = y; + trs[2] = z; + node._eulerAngles.x = eulerAnglesX; + node._eulerAngles.y = eulerAnglesY; + node._eulerAngles.z = eulerAnglesZ; + } + }; + }), {} ], + 329: [ (function(require, module, exports) { + "use strict"; + var macro = require("../../platform/CCMacro"); + var PerfCounter = require("./perf-counter"); + var _showFPS = false; + var _fontSize = 15; + var _stats = null; + var _rootNode = null; + var _label = null; + function generateStats() { + if (_stats) return; + _stats = { + fps: { + desc: "Framerate (FPS)", + below: 30, + average: 500 + }, + draws: { + desc: "Draw Call" + }, + frame: { + desc: "Frame time (ms)", + min: 0, + max: 50, + average: 500 + }, + logic: { + desc: "Game Logic (ms)", + min: 0, + max: 50, + average: 500, + color: "#080" + }, + render: { + desc: "Renderer (ms)", + min: 0, + max: 50, + average: 500, + color: "#f90" + }, + mode: { + desc: cc.game.renderType === cc.game.RENDER_TYPE_WEBGL ? "WebGL" : "Canvas", + min: 1 + } + }; + var now = performance.now(); + for (var id in _stats) _stats[id]._counter = new PerfCounter(id, _stats[id], now); + } + function generateNode() { + if (_rootNode && _rootNode.isValid) return; + _rootNode = new cc.Node("PROFILER-NODE"); + _rootNode.x = _rootNode.y = 10; + _rootNode.groupIndex = cc.Node.BuiltinGroupIndex.DEBUG; + cc.Camera._setupDebugCamera(); + _rootNode.zIndex = macro.MAX_ZINDEX; + cc.game.addPersistRootNode(_rootNode); + var left = new cc.Node("LEFT-PANEL"); + left.anchorX = left.anchorY = 0; + var leftLabel = left.addComponent(cc.Label); + leftLabel.fontSize = _fontSize; + leftLabel.lineHeight = _fontSize; + left.parent = _rootNode; + var right = new cc.Node("RIGHT-PANEL"); + right.anchorX = 1; + right.anchorY = 0; + right.x = 200; + var rightLabel = right.addComponent(cc.Label); + rightLabel.horizontalAlign = cc.Label.HorizontalAlign.RIGHT; + rightLabel.fontSize = _fontSize; + rightLabel.lineHeight = _fontSize; + right.parent = _rootNode; + if (cc.sys.platform !== cc.sys.BAIDU_GAME_SUB && cc.sys.platform !== cc.sys.WECHAT_GAME_SUB) { + leftLabel.cacheMode = cc.Label.CacheMode.CHAR; + rightLabel.cacheMode = cc.Label.CacheMode.CHAR; + } + _label = { + left: leftLabel, + right: rightLabel + }; + } + function beforeUpdate() { + generateNode(); + var now = cc.director._lastUpdate; + _stats["frame"]._counter.start(now); + _stats["logic"]._counter.start(now); + } + function afterUpdate() { + var now = performance.now(); + cc.director.isPaused() ? _stats["frame"]._counter.start(now) : _stats["logic"]._counter.end(now); + _stats["render"]._counter.start(now); + } + function updateLabel(stat) { + var length = 20; + var desc = stat.desc; + var value = stat._counter.human() + ""; + stat.label.string = stat.desc + " " + stat._counter.human(); + } + function afterDraw() { + var now = performance.now(); + _stats["render"]._counter.end(now); + _stats["draws"]._counter.value = cc.renderer.drawCalls; + _stats["frame"]._counter.end(now); + _stats["fps"]._counter.frame(now); + var left = ""; + var right = ""; + for (var id in _stats) { + var stat = _stats[id]; + stat._counter.sample(now); + left += stat.desc + "\n"; + right += stat._counter.human() + "\n"; + } + if (_label) { + _label.left.string = left; + _label.right.string = right; + } + } + cc.profiler = module.exports = { + isShowingStats: function isShowingStats() { + return _showFPS; + }, + hideStats: function hideStats() { + if (_showFPS) { + _rootNode && (_rootNode.active = false); + cc.director.off(cc.Director.EVENT_BEFORE_UPDATE, beforeUpdate); + cc.director.off(cc.Director.EVENT_AFTER_UPDATE, afterUpdate); + cc.director.off(cc.Director.EVENT_AFTER_DRAW, afterDraw); + _showFPS = false; + } + }, + showStats: function showStats() { + if (!_showFPS) { + generateStats(); + _rootNode && (_rootNode.active = true); + cc.director.on(cc.Director.EVENT_BEFORE_UPDATE, beforeUpdate); + cc.director.on(cc.Director.EVENT_AFTER_UPDATE, afterUpdate); + cc.director.on(cc.Director.EVENT_AFTER_DRAW, afterDraw); + _showFPS = true; + } + } + }; + }), { + "../../platform/CCMacro": 245, + "./perf-counter": 331 + } ], + 330: [ (function(require, module, exports) { + "use strict"; + var Counter = cc.Class({ + name: "cc.Counter", + ctor: function ctor(id, opts, now) { + this._id = id; + this._opts = opts || {}; + this._value = 0; + this._total = 0; + this._averageValue = 0; + this._accumValue = 0; + this._accumSamples = 0; + this._accumStart = now; + }, + properties: { + value: { + get: function get() { + return this._value; + }, + set: function set(v) { + this._value = v; + } + } + }, + _average: function _average(v, now) { + if (this._opts.average) { + this._accumValue += v; + ++this._accumSamples; + var t = now; + if (t - this._accumStart >= this._opts.average) { + this._averageValue = this._accumValue / this._accumSamples; + this._accumValue = 0; + this._accumStart = t; + this._accumSamples = 0; + } + } + }, + sample: function sample(now) { + this._average(this._value, now); + }, + human: function human() { + var v = this._opts.average ? this._averageValue : this._value; + return Math.round(100 * v) / 100; + }, + alarm: function alarm() { + return this._opts.below && this._value < this._opts.below || this._opts.over && this._value > this._opts.over; + } + }); + module.exports = Counter; + }), {} ], + 331: [ (function(require, module, exports) { + "use strict"; + var Counter = require("./counter"); + var PerfCounter = cc.Class({ + name: "cc.PerfCounter", + extends: Counter, + ctor: function ctor(id, opts, now) { + this._time = now; + }, + start: function start(now) { + this._time = now; + }, + end: function end(now) { + this._value = now - this._time; + this._average(this._value); + }, + tick: function tick() { + this.end(); + this.start(); + }, + frame: function frame(now) { + var t = now; + var e = t - this._time; + this._total++; + var avg = this._opts.average || 1e3; + if (e > avg) { + this._value = 1e3 * this._total / e; + this._total = 0; + this._time = t; + this._average(this._value); + } + } + }); + module.exports = PerfCounter; + }), { + "./counter": 330 + } ], + 332: [ (function(require, module, exports) { + "use strict"; + var _js = _interopRequireDefault(require("../platform/js")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + var _BASELINE_RATIO = .26; + var _BASELINE_OFFSET = 0; + false; + var MAX_CACHE_SIZE = 100; + var pool = new _js["default"].Pool(2); + pool.get = function() { + var node = this._get() || { + key: null, + value: null, + prev: null, + next: null + }; + return node; + }; + function LRUCache(size) { + this.count = 0; + this.limit = size; + this.datas = {}; + this.head = null; + this.tail = null; + } + LRUCache.prototype.moveToHead = function(node) { + node.next = this.head; + node.prev = null; + null !== this.head && (this.head.prev = node); + this.head = node; + null === this.tail && (this.tail = node); + this.count++; + this.datas[node.key] = node; + }; + LRUCache.prototype.put = function(key, value) { + var node = pool.get(); + node.key = key; + node.value = value; + if (this.count >= this.limit) { + var discard = this.tail; + delete this.datas[discard.key]; + this.count--; + this.tail = discard.prev; + this.tail.next = null; + discard.prev = null; + discard.next = null; + pool.put(discard); + } + this.moveToHead(node); + }; + LRUCache.prototype.remove = function(node) { + null !== node.prev ? node.prev.next = node.next : this.head = node.next; + null !== node.next ? node.next.prev = node.prev : this.tail = node.prev; + delete this.datas[node.key]; + this.count--; + }; + LRUCache.prototype.get = function(key) { + var node = this.datas[key]; + if (node) { + this.remove(node); + this.moveToHead(node); + return node.value; + } + return null; + }; + LRUCache.prototype.clear = function() { + this.count = 0; + this.datas = {}; + this.head = null; + this.tail = null; + }; + LRUCache.prototype.has = function(key) { + return !!this.datas[key]; + }; + LRUCache.prototype["delete"] = function(key) { + var node = this.datas[key]; + this.remove(node); + }; + var measureCache = new LRUCache(MAX_CACHE_SIZE); + var textUtils = { + BASELINE_RATIO: _BASELINE_RATIO, + MIDDLE_RATIO: (_BASELINE_RATIO + 1) / 2 - _BASELINE_RATIO, + BASELINE_OFFSET: _BASELINE_OFFSET, + label_wordRex: /([a-zA-Z0-9\xc4\xd6\xdc\xe4\xf6\xfc\xdf\xe9\xe8\xe7\xe0\xf9\xea\xe2\xee\xf4\xfb\u0430-\u044f\u0410-\u042f\u0401\u0451]+|\S)/, + label_symbolRex: /^[!,.:;'}\]%\?>\u3001\u2018\u201c\u300b\uff1f\u3002\uff0c\uff01]/, + label_lastWordRex: /([a-zA-Z0-9\xc4\xd6\xdc\xe4\xf6\xfc\xdf\xe9\xe8\xe7\xe0\xf9\xea\xe2\xee\xf4\xfb\u0430\xed\xec\xcd\xcc\xef\xc1\xc0\xe1\xe0\xc9\xc8\xd2\xd3\xf2\xf3\u0150\u0151\xd9\xda\u0170\xfa\u0171\xf1\xd1\xe6\xc6\u0153\u0152\xc3\xc2\xe3\xd4\xf5\u011b\u0161\u010d\u0159\u017e\xfd\xe1\xed\xe9\xf3\xfa\u016f\u0165\u010f\u0148\u011a\u0160\u010c\u0158\u017d\xc1\xcd\xc9\xd3\xda\u0164\u017c\u017a\u015b\xf3\u0144\u0142\u0119\u0107\u0105\u017b\u0179\u015a\xd3\u0143\u0141\u0118\u0106\u0104-\u044f\u0410-\u042f\u0401\u0451]+|\S)$/, + label_lastEnglish: /[a-zA-Z0-9\xc4\xd6\xdc\xe4\xf6\xfc\xdf\xe9\xe8\xe7\xe0\xf9\xea\xe2\xee\xf4\xfb\u0430\xed\xec\xcd\xcc\xef\xc1\xc0\xe1\xe0\xc9\xc8\xd2\xd3\xf2\xf3\u0150\u0151\xd9\xda\u0170\xfa\u0171\xf1\xd1\xe6\xc6\u0153\u0152\xc3\xc2\xe3\xd4\xf5\u011b\u0161\u010d\u0159\u017e\xfd\xe1\xed\xe9\xf3\xfa\u016f\u0165\u010f\u0148\u011a\u0160\u010c\u0158\u017d\xc1\xcd\xc9\xd3\xda\u0164\u017c\u017a\u015b\xf3\u0144\u0142\u0119\u0107\u0105\u017b\u0179\u015a\xd3\u0143\u0141\u0118\u0106\u0104-\u044f\u0410-\u042f\u0401\u0451]+$/, + label_firstEnglish: /^[a-zA-Z0-9\xc4\xd6\xdc\xe4\xf6\xfc\xdf\xe9\xe8\xe7\xe0\xf9\xea\xe2\xee\xf4\xfb\u0430\xed\xec\xcd\xcc\xef\xc1\xc0\xe1\xe0\xc9\xc8\xd2\xd3\xf2\xf3\u0150\u0151\xd9\xda\u0170\xfa\u0171\xf1\xd1\xe6\xc6\u0153\u0152\xc3\xc2\xe3\xd4\xf5\u011b\u0161\u010d\u0159\u017e\xfd\xe1\xed\xe9\xf3\xfa\u016f\u0165\u010f\u0148\u011a\u0160\u010c\u0158\u017d\xc1\xcd\xc9\xd3\xda\u0164\u017c\u017a\u015b\xf3\u0144\u0142\u0119\u0107\u0105\u017b\u0179\u015a\xd3\u0143\u0141\u0118\u0106\u0104-\u044f\u0410-\u042f\u0401\u0451]/, + highSurrogateRex: /[\uD800-\uDBFF]/, + lowSurrogateRex: /[\uDC00-\uDFFF]/, + label_wrapinspection: true, + __CHINESE_REG: /^[\u4E00-\u9FFF\u3400-\u4DFF]+$/, + __JAPANESE_REG: /[\u3000-\u303F]|[\u3040-\u309F]|[\u30A0-\u30FF]|[\uFF00-\uFFEF]|[\u4E00-\u9FAF]|[\u2605-\u2606]|[\u2190-\u2195]|\u203B/g, + __KOREAN_REG: /^[\u1100-\u11FF]|[\u3130-\u318F]|[\uA960-\uA97F]|[\uAC00-\uD7AF]|[\uD7B0-\uD7FF]+$/, + isUnicodeCJK: function isUnicodeCJK(ch) { + return this.__CHINESE_REG.test(ch) || this.__JAPANESE_REG.test(ch) || this.__KOREAN_REG.test(ch); + }, + isUnicodeSpace: function isUnicodeSpace(ch) { + ch = ch.charCodeAt(0); + return ch >= 9 && ch <= 13 || 32 === ch || 133 === ch || 160 === ch || 5760 === ch || ch >= 8192 && ch <= 8202 || 8232 === ch || 8233 === ch || 8239 === ch || 8287 === ch || 12288 === ch; + }, + safeMeasureText: function safeMeasureText(ctx, string, desc) { + var font = desc || ctx.font; + var key = font + "\ud83c\udfae" + string; + var cache = measureCache.get(key); + if (null !== cache) return cache; + var metric = ctx.measureText(string); + var width = metric && metric.width || 0; + measureCache.put(key, width); + return width; + }, + _safeSubstring: function _safeSubstring(targetString, startIndex, endIndex) { + var newStartIndex = startIndex, newEndIndex = endIndex; + var startChar = targetString[startIndex]; + this.lowSurrogateRex.test(startChar) && newStartIndex--; + if (void 0 !== endIndex) if (endIndex - 1 !== startIndex) { + var endChar = targetString[endIndex - 1]; + this.highSurrogateRex.test(endChar) && newEndIndex--; + } else this.highSurrogateRex.test(startChar) && newEndIndex++; + return targetString.substring(newStartIndex, newEndIndex); + }, + fragmentText: function fragmentText(stringToken, allWidth, maxWidth, measureText) { + var wrappedWords = []; + if (0 === stringToken.length || maxWidth < 0) { + wrappedWords.push(""); + return wrappedWords; + } + var text = stringToken; + while (allWidth > maxWidth && text.length > 1) { + var fuzzyLen = text.length * (maxWidth / allWidth) | 0; + var tmpText = this._safeSubstring(text, fuzzyLen); + var width = allWidth - measureText(tmpText); + var sLine = tmpText; + var pushNum = 0; + var checkWhile = 0; + var checkCount = 10; + while (width > maxWidth && checkWhile++ < checkCount) { + fuzzyLen *= maxWidth / width; + fuzzyLen |= 0; + tmpText = this._safeSubstring(text, fuzzyLen); + width = allWidth - measureText(tmpText); + } + checkWhile = 0; + while (width <= maxWidth && checkWhile++ < checkCount) { + if (tmpText) { + var exec = this.label_wordRex.exec(tmpText); + pushNum = exec ? exec[0].length : 1; + sLine = tmpText; + } + fuzzyLen += pushNum; + tmpText = this._safeSubstring(text, fuzzyLen); + width = allWidth - measureText(tmpText); + } + fuzzyLen -= pushNum; + if (0 === fuzzyLen) { + fuzzyLen = 1; + sLine = this._safeSubstring(text, 1); + } else if (1 === fuzzyLen && this.highSurrogateRex.test(text[0])) { + fuzzyLen = 2; + sLine = this._safeSubstring(text, 2); + } + var sText = this._safeSubstring(text, 0, fuzzyLen), result; + if (this.label_wrapinspection && this.label_symbolRex.test(sLine || tmpText)) { + result = this.label_lastWordRex.exec(sText); + fuzzyLen -= result ? result[0].length : 0; + 0 === fuzzyLen && (fuzzyLen = 1); + sLine = this._safeSubstring(text, fuzzyLen); + sText = this._safeSubstring(text, 0, fuzzyLen); + } + if (this.label_firstEnglish.test(sLine)) { + result = this.label_lastEnglish.exec(sText); + if (result && sText !== result[0]) { + fuzzyLen -= result[0].length; + sLine = this._safeSubstring(text, fuzzyLen); + sText = this._safeSubstring(text, 0, fuzzyLen); + } + } + if (0 === wrappedWords.length) wrappedWords.push(sText); else { + sText = sText.trimLeft(); + sText.length > 0 && wrappedWords.push(sText); + } + text = sLine || tmpText; + allWidth = measureText(text); + } + if (0 === wrappedWords.length) wrappedWords.push(text); else { + text = text.trimLeft(); + text.length > 0 && wrappedWords.push(text); + } + return wrappedWords; + } + }; + cc.textUtils = module.exports = textUtils; + }), { + "../platform/js": 261 + } ], + 333: [ (function(require, module, exports) { + "use strict"; + var Texture2D = require("../assets/CCTexture2D"); + var textureUtil = { + loadImage: function loadImage(url, cb, target) { + cc.assertID(url, 3103); + var tex = cc.assetManager.assets.get(url); + if (tex) { + if (tex.loaded) { + cb && cb.call(target, null, tex); + return tex; + } + tex.once("load", (function() { + cb && cb.call(target, null, tex); + }), target); + return tex; + } + cc.assetManager.loadRemote(url, (function(err, texture) { + cb && cb.call(target, err, texture); + })); + }, + cacheImage: function cacheImage(url, image) { + if (url && image) { + var tex = new Texture2D(); + tex.initWithElement(image); + cc.assetManager.assets.add(url, tex); + return tex; + } + }, + postLoadTexture: function postLoadTexture(texture, callback) { + if (texture.loaded) { + callback && callback(); + return; + } + if (!texture.nativeUrl) { + callback && callback(); + return; + } + cc.assetManager.postLoadNative(texture, callback); + } + }; + module.exports = textureUtil; + }), { + "../assets/CCTexture2D": 121 + } ], + 334: [ (function(require, module, exports) { + "use strict"; + var NodeUnit = require("./node-unit"); + var NodeMemPool = require("./node-mem-pool"); + module.exports = { + NodeMemPool: new NodeMemPool(NodeUnit) + }; + }), { + "./node-mem-pool": 336, + "./node-unit": 337 + } ], + 335: [ (function(require, module, exports) { + "use strict"; + var MemPool = function MemPool(unitClass) { + this._unitClass = unitClass; + this._pool = []; + this._findOrder = []; + false; + }; + var proto = MemPool.prototype; + proto._initNative = function() { + this._nativeMemPool = new renderer.MemPool(); + }; + proto._buildUnit = function(unitID) { + var unit = new this._unitClass(unitID, this); + false; + return unit; + }; + proto._destroyUnit = function(unitID) { + this._pool[unitID] = null; + for (var idx = 0, n = this._findOrder.length; idx < n; idx++) { + var unit = this._findOrder[idx]; + if (unit && unit.unitID == unitID) { + this._findOrder.splice(idx, 1); + break; + } + } + false; + }; + proto._findUnitID = function() { + var unitID = 0; + var pool = this._pool; + while (pool[unitID]) unitID++; + return unitID; + }; + proto.pop = function() { + var findUnit = null; + var idx = 0; + var findOrder = this._findOrder; + var pool = this._pool; + for (var n = findOrder.length; idx < n; idx++) { + var unit = findOrder[idx]; + if (unit && unit.hasSpace()) { + findUnit = unit; + break; + } + } + if (!findUnit) { + var unitID = this._findUnitID(); + findUnit = this._buildUnit(unitID); + pool[unitID] = findUnit; + findOrder.push(findUnit); + idx = findOrder.length - 1; + } + var firstUnit = findOrder[0]; + if (firstUnit !== findUnit) { + findOrder[0] = findUnit; + findOrder[idx] = firstUnit; + } + return findUnit.pop(); + }; + proto.push = function(info) { + var unit = this._pool[info.unitID]; + unit.push(info.index); + this._findOrder.length > 1 && unit.isAllFree() && this._destroyUnit(info.unitID); + return unit; + }; + module.exports = MemPool; + }), {} ], + 336: [ (function(require, module, exports) { + "use strict"; + var MemPool = require("./mem-pool"); + var NodeMemPool = function NodeMemPool(unitClass) { + MemPool.call(this, unitClass); + }; + (function() { + var Super = function Super() {}; + Super.prototype = MemPool.prototype; + NodeMemPool.prototype = new Super(); + })(); + var proto = NodeMemPool.prototype; + proto._initNative = function() { + this._nativeMemPool = new renderer.NodeMemPool(); + }; + proto._destroyUnit = function(unitID) { + MemPool.prototype._destroyUnit.call(this, unitID); + false; + }; + module.exports = NodeMemPool; + }), { + "./mem-pool": 335 + } ], + 337: [ (function(require, module, exports) { + "use strict"; + var _utils = require("../../value-types/utils"); + var Uint32_Bytes = 4; + var Uint8_Bytes = 1; + var Dirty_Type = Uint32Array; + var Dirty_Members = 1; + var Dirty_Stride = Dirty_Members * Uint32_Bytes; + var TRS_Members = 10; + var TRS_Stride = TRS_Members * _utils.FLOAT_BYTES; + var LocalMatrix_Members = 16; + var LocalMatrix_Stride = LocalMatrix_Members * _utils.FLOAT_BYTES; + var WorldMatrix_Members = 16; + var WorldMatrix_Stride = WorldMatrix_Members * _utils.FLOAT_BYTES; + var Parent_Type = Uint32Array; + var Parent_Members = 2; + var Parent_Stride = Parent_Members * Uint32_Bytes; + var ZOrder_Type = Uint32Array; + var ZOrder_Members = 1; + var ZOrder_Stride = ZOrder_Members * Uint32_Bytes; + var CullingMask_Type = Int32Array; + var CullingMask_Members = 1; + var CullingMask_Stride = CullingMask_Members * Uint32_Bytes; + var Opacity_Type = Uint8Array; + var Opacity_Members = 1; + var Opacity_Stride = Opacity_Members * Uint8_Bytes; + var Is3D_Type = Uint8Array; + var Is3D_Members = 1; + var Is3D_Stride = Is3D_Members * Uint8_Bytes; + var Node_Type = Uint32Array; + var Node_Members = 2; + var Skew_Members = 2; + var Skew_Stride = Skew_Members * _utils.FLOAT_BYTES; + var UnitBase = require("./unit-base"); + var NodeUnit = function NodeUnit(unitID, memPool) { + UnitBase.call(this, unitID, memPool); + var contentNum = this._contentNum; + this.trsList = new _utils.FLOAT_ARRAY_TYPE(contentNum * TRS_Members); + this.localMatList = new _utils.FLOAT_ARRAY_TYPE(contentNum * LocalMatrix_Members); + this.worldMatList = new _utils.FLOAT_ARRAY_TYPE(contentNum * WorldMatrix_Members); + false; + for (var i = 0; i < contentNum; i++) { + var space = this._spacesData[i]; + space.trs = new _utils.FLOAT_ARRAY_TYPE(this.trsList.buffer, i * TRS_Stride, TRS_Members); + space.localMat = new _utils.FLOAT_ARRAY_TYPE(this.localMatList.buffer, i * LocalMatrix_Stride, LocalMatrix_Members); + space.worldMat = new _utils.FLOAT_ARRAY_TYPE(this.worldMatList.buffer, i * WorldMatrix_Stride, WorldMatrix_Members); + false; + } + }; + (function() { + var Super = function Super() {}; + Super.prototype = UnitBase.prototype; + NodeUnit.prototype = new Super(); + })(); + module.exports = NodeUnit; + }), { + "../../value-types/utils": 347, + "./unit-base": 338 + } ], + 338: [ (function(require, module, exports) { + "use strict"; + var POINTER_INVALID_FLAG = 65535; + var SPACE_FREE_FLAG = 0; + var SPACE_USE_FLAG = 1; + var POS_NEXT_FREE = 0; + var POS_FREE_FLAG = 1; + var UnitBase = function UnitBase(unitID, memPool, contentNum) { + contentNum = contentNum || 128; + this.unitID = unitID; + this._memPool = memPool; + this._data = new Uint16Array(2); + this._data[0] = 0; + this._data[1] = 0; + this._contentNum = contentNum; + this._signData = new Uint16Array(2 * this._contentNum); + this._spacesData = []; + for (var i = 0; i < contentNum; i++) { + var signIndex = 2 * i; + this._signData[signIndex + POS_NEXT_FREE] = i + 1; + this._signData[signIndex + POS_FREE_FLAG] = SPACE_FREE_FLAG; + this._spacesData[i] = { + index: i, + unitID: unitID + }; + } + this._signData[2 * (contentNum - 1)] = POINTER_INVALID_FLAG; + }; + var UnitBaseProto = UnitBase.prototype; + UnitBaseProto.hasSpace = function() { + return this._data[0] !== POINTER_INVALID_FLAG; + }; + UnitBaseProto.isAllFree = function() { + return 0 == this._data[1]; + }; + UnitBaseProto.pop = function() { + var headFreeIndex = this._data[0]; + if (headFreeIndex === POINTER_INVALID_FLAG) return null; + var index = headFreeIndex; + var signIndex = 2 * index; + var space = this._spacesData[index]; + this._signData[signIndex + POS_FREE_FLAG] = SPACE_USE_FLAG; + this._data[0] = this._signData[signIndex + POS_NEXT_FREE]; + this._data[1]++; + return space; + }; + UnitBaseProto.push = function(index) { + var signIndex = 2 * index; + this._signData[signIndex + POS_FREE_FLAG] = SPACE_FREE_FLAG; + this._signData[signIndex + POS_NEXT_FREE] = this._data[0]; + this._data[0] = index; + this._data[1]--; + }; + UnitBaseProto.dump = function() { + var spaceNum = 0; + var index = this._data[0]; + var freeStr = ""; + while (index != POINTER_INVALID_FLAG) { + spaceNum++; + freeStr += index + "->"; + index = this._signData[2 * index + POS_NEXT_FREE]; + } + var usingNum = 0; + var usingStr = ""; + var contentNum = this._contentNum; + for (var i = 0; i < contentNum; i++) { + var freeFlag = this._signData[2 * i + POS_FREE_FLAG]; + if (freeFlag == SPACE_USE_FLAG) { + usingNum++; + usingStr += i + "->"; + } + } + var totalNum = spaceNum + usingNum; + console.log("unitID:", this.unitID, "spaceNum:", spaceNum, "calc using num:", usingNum, "store using num:", this._data[1], "calc total num:", totalNum, "actually total num:", this._contentNum); + console.log("free info:", freeStr); + console.log("using info:", usingStr); + usingNum != this._data[1] && cc.error("using num error", "calc using num:", usingNum, "store using num:", this._data[1]); + spaceNum + usingNum != this._contentNum && cc.error("total num error", "calc total num:", totalNum, "actually total num:", this._contentNum); + }; + module.exports = UnitBase; + }), {} ], + 339: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _valueType = _interopRequireDefault(require("./value-type")); + var _CCClass = _interopRequireDefault(require("../platform/CCClass")); + var _misc = _interopRequireDefault(require("../utils/misc")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + "value" in descriptor && (descriptor.writable = true); + Object.defineProperty(target, descriptor.key, descriptor); + } + } + function _createClass(Constructor, protoProps, staticProps) { + protoProps && _defineProperties(Constructor.prototype, protoProps); + staticProps && _defineProperties(Constructor, staticProps); + return Constructor; + } + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + _setPrototypeOf(subClass, superClass); + } + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + return _setPrototypeOf(o, p); + } + var Color = (function(_ValueType) { + _inheritsLoose(Color, _ValueType); + Color.copy = function copy(out, a) { + out.r = a.r; + out.g = a.g; + out.b = a.b; + out.a = a.a; + return out; + }; + Color.clone = function clone(a) { + return new Color(a.r, a.g, a.b, a.a); + }; + Color.set = function set(out, r, g, b, a) { + void 0 === r && (r = 255); + void 0 === g && (g = 255); + void 0 === b && (b = 255); + void 0 === a && (a = 255); + out.r = r; + out.g = g; + out.b = b; + out.a = a; + return out; + }; + Color.fromHex = function fromHex(out, hex) { + var r = hex >> 24 & 255; + var g = hex >> 16 & 255; + var b = hex >> 8 & 255; + var a = 255 & hex; + out.r = r; + out.g = g; + out.b = b; + out.a = a; + return out; + }; + Color.fromHEX = function fromHEX(out, hexString) { + hexString = 0 === hexString.indexOf("#") ? hexString.substring(1) : hexString; + out.r = parseInt(hexString.substr(0, 2), 16) || 0; + out.g = parseInt(hexString.substr(2, 2), 16) || 0; + out.b = parseInt(hexString.substr(4, 2), 16) || 0; + out.a = parseInt(hexString.substr(6, 2), 16) || 255; + out._val = (out.a << 24 >>> 0) + (out.b << 16) + (out.g << 8) + out.r; + return out; + }; + Color.add = function add(out, a, b) { + out.r = a.r + b.r; + out.g = a.g + b.g; + out.b = a.b + b.b; + out.a = a.a + b.a; + return out; + }; + Color.subtract = function subtract(out, a, b) { + out.r = a.r - b.r; + out.g = a.g - b.g; + out.b = a.b - b.b; + out.a = a.a - b.a; + return out; + }; + Color.multiply = function multiply(out, a, b) { + out.r = a.r * b.r; + out.g = a.g * b.g; + out.b = a.b * b.b; + out.a = a.a * b.a; + return out; + }; + Color.divide = function divide(out, a, b) { + out.r = a.r / b.r; + out.g = a.g / b.g; + out.b = a.b / b.b; + out.a = a.a / b.a; + return out; + }; + Color.scale = function scale(out, a, b) { + out.r = a.r * b; + out.g = a.g * b; + out.b = a.b * b; + out.a = a.a * b; + return out; + }; + Color.lerp = function lerp(out, a, b, t) { + var ar = a.r, ag = a.g, ab = a.b, aa = a.a; + out.r = ar + t * (b.r - ar); + out.g = ag + t * (b.g - ag); + out.b = ab + t * (b.b - ab); + out.a = aa + t * (b.a - aa); + return out; + }; + Color.toArray = function toArray(out, a, ofs) { + void 0 === ofs && (ofs = 0); + var scale = a instanceof Color || a.a > 1 ? 1 / 255 : 1; + out[ofs + 0] = a.r * scale; + out[ofs + 1] = a.g * scale; + out[ofs + 2] = a.b * scale; + out[ofs + 3] = a.a * scale; + return out; + }; + Color.fromArray = function fromArray(arr, out, ofs) { + void 0 === ofs && (ofs = 0); + out.r = 255 * arr[ofs + 0]; + out.g = 255 * arr[ofs + 1]; + out.b = 255 * arr[ofs + 2]; + out.a = 255 * arr[ofs + 3]; + return out; + }; + Color.premultiplyAlpha = function premultiplyAlpha(out, color) { + var alpha = color.a / 255; + out.r = color.r * alpha; + out.g = color.g * alpha; + out.b = color.b * alpha; + out._fastSetA(color.a); + return out; + }; + function Color(r, g, b, a) { + var _this; + void 0 === r && (r = 0); + void 0 === g && (g = 0); + void 0 === b && (b = 0); + void 0 === a && (a = 255); + _this = _ValueType.call(this) || this; + _this._val = 0; + if ("object" === typeof r) { + g = r.g; + b = r.b; + a = r.a; + r = r.r; + } + _this._val = (a << 24 >>> 0) + (b << 16) + (g << 8) + (0 | r); + return _this; + } + var _proto = Color.prototype; + _proto.clone = function clone() { + var ret = new Color(); + ret._val = this._val; + return ret; + }; + _proto.equals = function equals(other) { + return other && this._val === other._val; + }; + _proto.lerp = function lerp(to, ratio, out) { + out = out || new Color(); + var r = this.r; + var g = this.g; + var b = this.b; + var a = this.a; + out.r = r + (to.r - r) * ratio; + out.g = g + (to.g - g) * ratio; + out.b = b + (to.b - b) * ratio; + out.a = a + (to.a - a) * ratio; + return out; + }; + _proto.toString = function toString() { + return "rgba(" + this.r.toFixed() + ", " + this.g.toFixed() + ", " + this.b.toFixed() + ", " + this.a.toFixed() + ")"; + }; + _proto.getR = function getR() { + return 255 & this._val; + }; + _proto.setR = function setR(red) { + red = ~~_misc["default"].clampf(red, 0, 255); + this._val = (4294967040 & this._val | red) >>> 0; + return this; + }; + _proto.getG = function getG() { + return (65280 & this._val) >> 8; + }; + _proto.setG = function setG(green) { + green = ~~_misc["default"].clampf(green, 0, 255); + this._val = (4294902015 & this._val | green << 8) >>> 0; + return this; + }; + _proto.getB = function getB() { + return (16711680 & this._val) >> 16; + }; + _proto.setB = function setB(blue) { + blue = ~~_misc["default"].clampf(blue, 0, 255); + this._val = (4278255615 & this._val | blue << 16) >>> 0; + return this; + }; + _proto.getA = function getA() { + return (4278190080 & this._val) >>> 24; + }; + _proto.setA = function setA(alpha) { + alpha = ~~_misc["default"].clampf(alpha, 0, 255); + this._val = (16777215 & this._val | alpha << 24) >>> 0; + return this; + }; + _proto.toCSS = function toCSS(opt) { + return opt && "rgba" !== opt ? "rgb" === opt ? "rgb(" + this.r + "," + this.g + "," + this.b + ")" : "#" + this.toHEX(opt) : "rgba(" + this.r + "," + this.g + "," + this.b + "," + (this.a / 255).toFixed(2) + ")"; + }; + _proto.fromHEX = function fromHEX(hexString) { + hexString = 0 === hexString.indexOf("#") ? hexString.substring(1) : hexString; + var r = parseInt(hexString.substr(0, 2), 16) || 0; + var g = parseInt(hexString.substr(2, 2), 16) || 0; + var b = parseInt(hexString.substr(4, 2), 16) || 0; + var a = parseInt(hexString.substr(6, 2), 16) || 255; + this._val = (a << 24 >>> 0) + (b << 16) + (g << 8) + r; + return this; + }; + _proto.toHEX = function toHEX(fmt) { + var prefix = "0"; + var hex = [ (this.r < 16 ? prefix : "") + this.r.toString(16), (this.g < 16 ? prefix : "") + this.g.toString(16), (this.b < 16 ? prefix : "") + this.b.toString(16) ]; + if ("#rgb" === fmt) { + hex[0] = hex[0][0]; + hex[1] = hex[1][0]; + hex[2] = hex[2][0]; + } else "#rrggbbaa" === fmt && hex.push((this.a < 16 ? prefix : "") + this.a.toString(16)); + return hex.join(""); + }; + _proto.toRGBValue = function toRGBValue() { + return 16777215 & this._val; + }; + _proto.fromHSV = function fromHSV(h, s, v) { + var r, g, b; + if (0 === s) r = g = b = v; else if (0 === v) r = g = b = 0; else { + 1 === h && (h = 0); + h *= 6; + var i = Math.floor(h); + var f = h - i; + var p = v * (1 - s); + var q = v * (1 - s * f); + var t = v * (1 - s * (1 - f)); + switch (i) { + case 0: + r = v; + g = t; + b = p; + break; + + case 1: + r = q; + g = v; + b = p; + break; + + case 2: + r = p; + g = v; + b = t; + break; + + case 3: + r = p; + g = q; + b = v; + break; + + case 4: + r = t; + g = p; + b = v; + break; + + case 5: + r = v; + g = p; + b = q; + } + } + r *= 255; + g *= 255; + b *= 255; + this._val = (this.a << 24 >>> 0) + (b << 16) + (g << 8) + (0 | r); + return this; + }; + _proto.toHSV = function toHSV() { + var r = this.r / 255; + var g = this.g / 255; + var b = this.b / 255; + var hsv = { + h: 0, + s: 0, + v: 0 + }; + var max = Math.max(r, g, b); + var min = Math.min(r, g, b); + var delta = 0; + hsv.v = max; + hsv.s = max ? (max - min) / max : 0; + if (hsv.s) { + delta = max - min; + hsv.h = r === max ? (g - b) / delta : g === max ? 2 + (b - r) / delta : 4 + (r - g) / delta; + hsv.h /= 6; + hsv.h < 0 && (hsv.h += 1); + } else hsv.h = 0; + return hsv; + }; + _proto.set = function set(color) { + if (color._val) this._val = color._val; else { + this.r = color.r; + this.g = color.g; + this.b = color.b; + this.a = color.a; + } + return this; + }; + _proto._fastSetA = function _fastSetA(alpha) { + this._val = (16777215 & this._val | alpha << 24) >>> 0; + }; + _proto.multiply = function multiply(other) { + var r = (255 & this._val) * other.r >> 8; + var g = (65280 & this._val) * other.g >> 8; + var b = (16711680 & this._val) * other.b >> 8; + var a = ((4278190080 & this._val) >>> 8) * other.a; + this._val = 4278190080 & a | 16711680 & b | 65280 & g | 255 & r; + return this; + }; + _createClass(Color, [ { + key: "r", + get: function get() { + return this.getR(); + }, + set: function set(v) { + this.setR(v); + } + }, { + key: "g", + get: function get() { + return this.getG(); + }, + set: function set(v) { + this.setG(v); + } + }, { + key: "b", + get: function get() { + return this.getB(); + }, + set: function set(v) { + this.setB(v); + } + }, { + key: "a", + get: function get() { + return this.getA(); + }, + set: function set(v) { + this.setA(v); + } + } ], [ { + key: "WHITE", + get: function get() { + return new Color(255, 255, 255, 255); + } + }, { + key: "BLACK", + get: function get() { + return new Color(0, 0, 0, 255); + } + }, { + key: "TRANSPARENT", + get: function get() { + return new Color(0, 0, 0, 0); + } + }, { + key: "GRAY", + get: function get() { + return new Color(127.5, 127.5, 127.5); + } + }, { + key: "RED", + get: function get() { + return new Color(255, 0, 0); + } + }, { + key: "GREEN", + get: function get() { + return new Color(0, 255, 0); + } + }, { + key: "BLUE", + get: function get() { + return new Color(0, 0, 255); + } + }, { + key: "YELLOW", + get: function get() { + return new Color(255, 235, 4); + } + }, { + key: "ORANGE", + get: function get() { + return new Color(255, 127, 0); + } + }, { + key: "CYAN", + get: function get() { + return new Color(0, 255, 255); + } + }, { + key: "MAGENTA", + get: function get() { + return new Color(255, 0, 255); + } + } ]); + return Color; + })(_valueType["default"]); + exports["default"] = Color; + Color.div = Color.divide; + Color.sub = Color.subtract; + Color.mul = Color.multiply; + Color.WHITE_R = Color.WHITE; + Color.BLACK_R = Color.BLACK; + Color.TRANSPARENT_R = Color.TRANSPARENT; + Color.GRAY_R = Color.GRAY; + Color.RED_R = Color.RED; + Color.GREEN_R = Color.GREEN; + Color.BLUE_R = Color.BLUE; + Color.YELLOW_R = Color.YELLOW; + Color.ORANGE_R = Color.ORANGE; + Color.CYAN_R = Color.CYAN; + Color.MAGENTA_R = Color.MAGENTA; + _CCClass["default"].fastDefine("cc.Color", Color, { + r: 0, + g: 0, + b: 0, + a: 255 + }); + cc.Color = Color; + cc.color = function color(r, g, b, a) { + if ("string" === typeof r) { + var result = new Color(); + return result.fromHEX(r); + } + if ("object" === typeof r) return new Color(r.r, r.g, r.b, r.a); + return new Color(r, g, b, a); + }; + module.exports = exports["default"]; + }), { + "../platform/CCClass": 240, + "../utils/misc": 325, + "./value-type": 348 + } ], + 340: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + var _exportNames = { + Vec2: true, + Vec3: true, + Vec4: true, + Mat4: true, + Mat3: true, + Rect: true, + Size: true, + Color: true, + Quat: true, + Trs: true + }; + exports.Vec4 = exports.Vec3 = exports.Vec2 = exports.Trs = exports.Size = exports.Rect = exports.Quat = exports.Mat4 = exports.Mat3 = exports.Color = void 0; + var _vec = _interopRequireDefault(require("./vec2")); + exports.Vec2 = _vec["default"]; + var _vec2 = _interopRequireDefault(require("./vec3")); + exports.Vec3 = _vec2["default"]; + var _vec3 = _interopRequireDefault(require("./vec4")); + exports.Vec4 = _vec3["default"]; + var _mat = _interopRequireDefault(require("./mat4")); + exports.Mat4 = _mat["default"]; + var _mat2 = _interopRequireDefault(require("./mat3")); + exports.Mat3 = _mat2["default"]; + var _rect = _interopRequireDefault(require("./rect")); + exports.Rect = _rect["default"]; + var _size = _interopRequireDefault(require("./size")); + exports.Size = _size["default"]; + var _color = _interopRequireDefault(require("./color")); + exports.Color = _color["default"]; + var _quat = _interopRequireDefault(require("./quat")); + exports.Quat = _quat["default"]; + var _trs = _interopRequireDefault(require("./trs")); + exports.Trs = _trs["default"]; + var _utils = require("./utils"); + Object.keys(_utils).forEach((function(key) { + if ("default" === key || "__esModule" === key) return; + if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; + if (key in exports && exports[key] === _utils[key]) return; + exports[key] = _utils[key]; + })); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + cc.math = module.exports; + }), { + "./color": 339, + "./mat3": 341, + "./mat4": 342, + "./quat": 343, + "./rect": 344, + "./size": 345, + "./trs": 346, + "./utils": 347, + "./vec2": 349, + "./vec3": 350, + "./vec4": 351 + } ], + 341: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _utils = require("../value-types/utils"); + var _vec = _interopRequireDefault(require("./vec3")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + var Mat3 = (function() { + Mat3.create = function create(m00, m01, m02, m03, m04, m05, m06, m07, m08) { + void 0 === m00 && (m00 = 1); + void 0 === m01 && (m01 = 0); + void 0 === m02 && (m02 = 0); + void 0 === m03 && (m03 = 0); + void 0 === m04 && (m04 = 1); + void 0 === m05 && (m05 = 0); + void 0 === m06 && (m06 = 0); + void 0 === m07 && (m07 = 0); + void 0 === m08 && (m08 = 1); + return new Mat3(m00, m01, m02, m03, m04, m05, m06, m07, m08); + }; + Mat3.clone = function clone(a) { + var am = a.m; + return new Mat3(am[0], am[1], am[2], am[3], am[4], am[5], am[6], am[7], am[8]); + }; + Mat3.copy = function copy(out, a) { + out.m.set(a.m); + return out; + }; + Mat3.set = function set(out, m00, m01, m02, m10, m11, m12, m20, m21, m22) { + var outm = out.m; + outm[0] = m00; + outm[1] = m01; + outm[2] = m02; + outm[3] = m10; + outm[4] = m11; + outm[5] = m12; + outm[6] = m20; + outm[7] = m21; + outm[8] = m22; + return out; + }; + Mat3.identity = function identity(out) { + var outm = out.m; + outm[0] = 1; + outm[1] = 0; + outm[2] = 0; + outm[3] = 0; + outm[4] = 1; + outm[5] = 0; + outm[6] = 0; + outm[7] = 0; + outm[8] = 1; + return out; + }; + Mat3.transpose = function transpose(out, a) { + var am = a.m, outm = out.m; + if (out === a) { + var a01 = am[1], a02 = am[2], a12 = am[5]; + outm[1] = am[3]; + outm[2] = am[6]; + outm[3] = a01; + outm[5] = am[7]; + outm[6] = a02; + outm[7] = a12; + } else { + outm[0] = am[0]; + outm[1] = am[3]; + outm[2] = am[6]; + outm[3] = am[1]; + outm[4] = am[4]; + outm[5] = am[7]; + outm[6] = am[2]; + outm[7] = am[5]; + outm[8] = am[8]; + } + return out; + }; + Mat3.invert = function invert(out, a) { + var am = a.m, outm = out.m; + var a00 = am[0], a01 = am[1], a02 = am[2], a10 = am[3], a11 = am[4], a12 = am[5], a20 = am[6], a21 = am[7], a22 = am[8]; + var b01 = a22 * a11 - a12 * a21; + var b11 = -a22 * a10 + a12 * a20; + var b21 = a21 * a10 - a11 * a20; + var det = a00 * b01 + a01 * b11 + a02 * b21; + if (!det) return out; + det = 1 / det; + outm[0] = b01 * det; + outm[1] = (-a22 * a01 + a02 * a21) * det; + outm[2] = (a12 * a01 - a02 * a11) * det; + outm[3] = b11 * det; + outm[4] = (a22 * a00 - a02 * a20) * det; + outm[5] = (-a12 * a00 + a02 * a10) * det; + outm[6] = b21 * det; + outm[7] = (-a21 * a00 + a01 * a20) * det; + outm[8] = (a11 * a00 - a01 * a10) * det; + return out; + }; + Mat3.adjoint = function adjoint(out, a) { + var am = a.m, outm = out.m; + var a00 = am[0], a01 = am[1], a02 = am[2], a10 = am[3], a11 = am[4], a12 = am[5], a20 = am[6], a21 = am[7], a22 = am[8]; + outm[0] = a11 * a22 - a12 * a21; + outm[1] = a02 * a21 - a01 * a22; + outm[2] = a01 * a12 - a02 * a11; + outm[3] = a12 * a20 - a10 * a22; + outm[4] = a00 * a22 - a02 * a20; + outm[5] = a02 * a10 - a00 * a12; + outm[6] = a10 * a21 - a11 * a20; + outm[7] = a01 * a20 - a00 * a21; + outm[8] = a00 * a11 - a01 * a10; + return out; + }; + Mat3.determinant = function determinant(a) { + var am = a.m; + var a00 = am[0], a01 = am[1], a02 = am[2], a10 = am[3], a11 = am[4], a12 = am[5], a20 = am[6], a21 = am[7], a22 = am[8]; + return a00 * (a22 * a11 - a12 * a21) + a01 * (-a22 * a10 + a12 * a20) + a02 * (a21 * a10 - a11 * a20); + }; + Mat3.multiply = function multiply(out, a, b) { + var am = a.m, bm = b.m, outm = out.m; + var a00 = am[0], a01 = am[1], a02 = am[2], a10 = am[3], a11 = am[4], a12 = am[5], a20 = am[6], a21 = am[7], a22 = am[8]; + var b00 = bm[0], b01 = bm[1], b02 = bm[2]; + var b10 = bm[3], b11 = bm[4], b12 = bm[5]; + var b20 = bm[6], b21 = bm[7], b22 = bm[8]; + outm[0] = b00 * a00 + b01 * a10 + b02 * a20; + outm[1] = b00 * a01 + b01 * a11 + b02 * a21; + outm[2] = b00 * a02 + b01 * a12 + b02 * a22; + outm[3] = b10 * a00 + b11 * a10 + b12 * a20; + outm[4] = b10 * a01 + b11 * a11 + b12 * a21; + outm[5] = b10 * a02 + b11 * a12 + b12 * a22; + outm[6] = b20 * a00 + b21 * a10 + b22 * a20; + outm[7] = b20 * a01 + b21 * a11 + b22 * a21; + outm[8] = b20 * a02 + b21 * a12 + b22 * a22; + return out; + }; + Mat3.multiplyMat4 = function multiplyMat4(out, a, b) { + var am = a.m, bm = b.m, outm = out.m; + var a00 = am[0], a01 = am[1], a02 = am[2], a10 = am[3], a11 = am[4], a12 = am[5], a20 = am[6], a21 = am[7], a22 = am[8]; + var b00 = bm[0], b01 = bm[1], b02 = bm[2]; + var b10 = bm[4], b11 = bm[5], b12 = bm[6]; + var b20 = bm[8], b21 = bm[9], b22 = bm[10]; + outm[0] = b00 * a00 + b01 * a10 + b02 * a20; + outm[1] = b00 * a01 + b01 * a11 + b02 * a21; + outm[2] = b00 * a02 + b01 * a12 + b02 * a22; + outm[3] = b10 * a00 + b11 * a10 + b12 * a20; + outm[4] = b10 * a01 + b11 * a11 + b12 * a21; + outm[5] = b10 * a02 + b11 * a12 + b12 * a22; + outm[6] = b20 * a00 + b21 * a10 + b22 * a20; + outm[7] = b20 * a01 + b21 * a11 + b22 * a21; + outm[8] = b20 * a02 + b21 * a12 + b22 * a22; + return out; + }; + Mat3.translate = function translate(out, a, v) { + var am = a.m, outm = out.m; + var a00 = am[0], a01 = am[1], a02 = am[2], a10 = am[3], a11 = am[4], a12 = am[5], a20 = am[6], a21 = am[7], a22 = am[8]; + var x = v.x, y = v.y; + outm[0] = a00; + outm[1] = a01; + outm[2] = a02; + outm[3] = a10; + outm[4] = a11; + outm[5] = a12; + outm[6] = x * a00 + y * a10 + a20; + outm[7] = x * a01 + y * a11 + a21; + outm[8] = x * a02 + y * a12 + a22; + return out; + }; + Mat3.rotate = function rotate(out, a, rad) { + var am = a.m, outm = out.m; + var a00 = am[0], a01 = am[1], a02 = am[2], a10 = am[3], a11 = am[4], a12 = am[5], a20 = am[6], a21 = am[7], a22 = am[8]; + var s = Math.sin(rad); + var c = Math.cos(rad); + outm[0] = c * a00 + s * a10; + outm[1] = c * a01 + s * a11; + outm[2] = c * a02 + s * a12; + outm[3] = c * a10 - s * a00; + outm[4] = c * a11 - s * a01; + outm[5] = c * a12 - s * a02; + outm[6] = a20; + outm[7] = a21; + outm[8] = a22; + return out; + }; + Mat3.scale = function scale(out, a, v) { + var x = v.x, y = v.y; + var am = a.m, outm = out.m; + outm[0] = x * am[0]; + outm[1] = x * am[1]; + outm[2] = x * am[2]; + outm[3] = y * am[3]; + outm[4] = y * am[4]; + outm[5] = y * am[5]; + outm[6] = am[6]; + outm[7] = am[7]; + outm[8] = am[8]; + return out; + }; + Mat3.fromMat4 = function fromMat4(out, a) { + var am = a.m, outm = out.m; + outm[0] = am[0]; + outm[1] = am[1]; + outm[2] = am[2]; + outm[3] = am[4]; + outm[4] = am[5]; + outm[5] = am[6]; + outm[6] = am[8]; + outm[7] = am[9]; + outm[8] = am[10]; + return out; + }; + Mat3.fromTranslation = function fromTranslation(out, v) { + var outm = out.m; + outm[0] = 1; + outm[1] = 0; + outm[2] = 0; + outm[3] = 0; + outm[4] = 1; + outm[5] = 0; + outm[6] = v.x; + outm[7] = v.y; + outm[8] = 1; + return out; + }; + Mat3.fromRotation = function fromRotation(out, rad) { + var s = Math.sin(rad), c = Math.cos(rad); + var outm = out.m; + outm[0] = c; + outm[1] = s; + outm[2] = 0; + outm[3] = -s; + outm[4] = c; + outm[5] = 0; + outm[6] = 0; + outm[7] = 0; + outm[8] = 1; + return out; + }; + Mat3.fromScaling = function fromScaling(out, v) { + var outm = out.m; + outm[0] = v.x; + outm[1] = 0; + outm[2] = 0; + outm[3] = 0; + outm[4] = v.y; + outm[5] = 0; + outm[6] = 0; + outm[7] = 0; + outm[8] = 1; + return out; + }; + Mat3.fromQuat = function fromQuat(out, q) { + var outm = out.m; + var x = q.x, y = q.y, z = q.z, w = q.w; + var x2 = x + x; + var y2 = y + y; + var z2 = z + z; + var xx = x * x2; + var yx = y * x2; + var yy = y * y2; + var zx = z * x2; + var zy = z * y2; + var zz = z * z2; + var wx = w * x2; + var wy = w * y2; + var wz = w * z2; + outm[0] = 1 - yy - zz; + outm[3] = yx - wz; + outm[6] = zx + wy; + outm[1] = yx + wz; + outm[4] = 1 - xx - zz; + outm[7] = zy - wx; + outm[2] = zx - wy; + outm[5] = zy + wx; + outm[8] = 1 - xx - yy; + return out; + }; + Mat3.fromViewUp = function fromViewUp(out, view, up) { + var _fromViewUpIIFE = (function() { + var default_up = new _vec["default"](0, 1, 0); + var x = new _vec["default"](); + var y = new _vec["default"](); + return function(out, view, up) { + if (_vec["default"].lengthSqr(view) < _utils.EPSILON * _utils.EPSILON) { + Mat3.identity(out); + return out; + } + up = up || default_up; + _vec["default"].normalize(x, _vec["default"].cross(x, up, view)); + if (_vec["default"].lengthSqr(x) < _utils.EPSILON * _utils.EPSILON) { + Mat3.identity(out); + return out; + } + _vec["default"].cross(y, view, x); + Mat3.set(out, x.x, x.y, x.z, y.x, y.y, y.z, view.x, view.y, view.z); + return out; + }; + })(); + return _fromViewUpIIFE(out, view, up); + }; + Mat3.normalFromMat4 = function normalFromMat4(out, a) { + var am = a.m, outm = out.m; + var a00 = am[0], a01 = am[1], a02 = am[2], a03 = am[3], a10 = am[4], a11 = am[5], a12 = am[6], a13 = am[7], a20 = am[8], a21 = am[9], a22 = am[10], a23 = am[11], a30 = am[12], a31 = am[13], a32 = am[14], a33 = am[15]; + var b00 = a00 * a11 - a01 * a10; + var b01 = a00 * a12 - a02 * a10; + var b02 = a00 * a13 - a03 * a10; + var b03 = a01 * a12 - a02 * a11; + var b04 = a01 * a13 - a03 * a11; + var b05 = a02 * a13 - a03 * a12; + var b06 = a20 * a31 - a21 * a30; + var b07 = a20 * a32 - a22 * a30; + var b08 = a20 * a33 - a23 * a30; + var b09 = a21 * a32 - a22 * a31; + var b10 = a21 * a33 - a23 * a31; + var b11 = a22 * a33 - a23 * a32; + var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; + if (!det) return out; + det = 1 / det; + outm[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det; + outm[1] = (a12 * b08 - a10 * b11 - a13 * b07) * det; + outm[2] = (a10 * b10 - a11 * b08 + a13 * b06) * det; + outm[3] = (a02 * b10 - a01 * b11 - a03 * b09) * det; + outm[4] = (a00 * b11 - a02 * b08 + a03 * b07) * det; + outm[5] = (a01 * b08 - a00 * b10 - a03 * b06) * det; + outm[6] = (a31 * b05 - a32 * b04 + a33 * b03) * det; + outm[7] = (a32 * b02 - a30 * b05 - a33 * b01) * det; + outm[8] = (a30 * b04 - a31 * b02 + a33 * b00) * det; + return out; + }; + Mat3.frob = function frob(a) { + var am = a.m; + return Math.sqrt(Math.pow(am[0], 2) + Math.pow(am[1], 2) + Math.pow(am[2], 2) + Math.pow(am[3], 2) + Math.pow(am[4], 2) + Math.pow(am[5], 2) + Math.pow(am[6], 2) + Math.pow(am[7], 2) + Math.pow(am[8], 2)); + }; + Mat3.add = function add(out, a, b) { + var am = a.m, bm = b.m, outm = out.m; + outm[0] = am[0] + bm[0]; + outm[1] = am[1] + bm[1]; + outm[2] = am[2] + bm[2]; + outm[3] = am[3] + bm[3]; + outm[4] = am[4] + bm[4]; + outm[5] = am[5] + bm[5]; + outm[6] = am[6] + bm[6]; + outm[7] = am[7] + bm[7]; + outm[8] = am[8] + bm[8]; + return out; + }; + Mat3.subtract = function subtract(out, a, b) { + var am = a.m, bm = b.m, outm = out.m; + outm[0] = am[0] - bm[0]; + outm[1] = am[1] - bm[1]; + outm[2] = am[2] - bm[2]; + outm[3] = am[3] - bm[3]; + outm[4] = am[4] - bm[4]; + outm[5] = am[5] - bm[5]; + outm[6] = am[6] - bm[6]; + outm[7] = am[7] - bm[7]; + outm[8] = am[8] - bm[8]; + return out; + }; + Mat3.multiplyScalar = function multiplyScalar(out, a, b) { + var am = a.m, outm = out.m; + outm[0] = am[0] * b; + outm[1] = am[1] * b; + outm[2] = am[2] * b; + outm[3] = am[3] * b; + outm[4] = am[4] * b; + outm[5] = am[5] * b; + outm[6] = am[6] * b; + outm[7] = am[7] * b; + outm[8] = am[8] * b; + return out; + }; + Mat3.multiplyScalarAndAdd = function multiplyScalarAndAdd(out, a, b, scale) { + var am = a.m, bm = b.m, outm = out.m; + outm[0] = am[0] + bm[0] * scale; + outm[1] = am[1] + bm[1] * scale; + outm[2] = am[2] + bm[2] * scale; + outm[3] = am[3] + bm[3] * scale; + outm[4] = am[4] + bm[4] * scale; + outm[5] = am[5] + bm[5] * scale; + outm[6] = am[6] + bm[6] * scale; + outm[7] = am[7] + bm[7] * scale; + outm[8] = am[8] + bm[8] * scale; + return out; + }; + Mat3.exactEquals = function exactEquals(a, b) { + var am = a.m, bm = b.m; + return am[0] === bm[0] && am[1] === bm[1] && am[2] === bm[2] && am[3] === bm[3] && am[4] === bm[4] && am[5] === bm[5] && am[6] === bm[6] && am[7] === bm[7] && am[8] === bm[8]; + }; + Mat3.equals = function equals(a, b) { + var am = a.m, bm = b.m; + var a0 = am[0], a1 = am[1], a2 = am[2], a3 = am[3], a4 = am[4], a5 = am[5], a6 = am[6], a7 = am[7], a8 = am[8]; + var b0 = bm[0], b1 = bm[1], b2 = bm[2], b3 = bm[3], b4 = bm[4], b5 = bm[5], b6 = bm[6], b7 = bm[7], b8 = bm[8]; + return Math.abs(a0 - b0) <= _utils.EPSILON * Math.max(1, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= _utils.EPSILON * Math.max(1, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= _utils.EPSILON * Math.max(1, Math.abs(a2), Math.abs(b2)) && Math.abs(a3 - b3) <= _utils.EPSILON * Math.max(1, Math.abs(a3), Math.abs(b3)) && Math.abs(a4 - b4) <= _utils.EPSILON * Math.max(1, Math.abs(a4), Math.abs(b4)) && Math.abs(a5 - b5) <= _utils.EPSILON * Math.max(1, Math.abs(a5), Math.abs(b5)) && Math.abs(a6 - b6) <= _utils.EPSILON * Math.max(1, Math.abs(a6), Math.abs(b6)) && Math.abs(a7 - b7) <= _utils.EPSILON * Math.max(1, Math.abs(a7), Math.abs(b7)) && Math.abs(a8 - b8) <= _utils.EPSILON * Math.max(1, Math.abs(a8), Math.abs(b8)); + }; + Mat3.toArray = function toArray(out, mat, ofs) { + void 0 === ofs && (ofs = 0); + var m = mat.m; + for (var i = 0; i < 9; i++) out[ofs + i] = m[i]; + return out; + }; + Mat3.fromArray = function fromArray(out, arr, ofs) { + void 0 === ofs && (ofs = 0); + var m = out.m; + for (var i = 0; i < 9; i++) m[i] = arr[ofs + i]; + return out; + }; + function Mat3(m00, m01, m02, m03, m04, m05, m06, m07, m08) { + void 0 === m00 && (m00 = 1); + void 0 === m01 && (m01 = 0); + void 0 === m02 && (m02 = 0); + void 0 === m03 && (m03 = 0); + void 0 === m04 && (m04 = 1); + void 0 === m05 && (m05 = 0); + void 0 === m06 && (m06 = 0); + void 0 === m07 && (m07 = 0); + void 0 === m08 && (m08 = 1); + this.m = void 0; + if (m00 instanceof _utils.FLOAT_ARRAY_TYPE) this.m = m00; else { + this.m = new _utils.FLOAT_ARRAY_TYPE(9); + var m = this.m; + m[0] = m00; + m[1] = m01; + m[2] = m02; + m[3] = m03; + m[4] = m04; + m[5] = m05; + m[6] = m06; + m[7] = m07; + m[8] = m08; + } + } + var _proto = Mat3.prototype; + _proto.toString = function toString() { + var am = this.m; + return "mat3(" + am[0] + ", " + am[1] + ", " + am[2] + ", " + am[3] + ", " + am[4] + ", " + am[5] + ", " + am[6] + ", " + am[7] + ", " + am[8] + ")"; + }; + return Mat3; + })(); + exports["default"] = Mat3; + Mat3.sub = Mat3.subtract; + Mat3.mul = Mat3.multiply; + Mat3.IDENTITY = Object.freeze(new Mat3()); + cc.Mat3 = Mat3; + module.exports = exports["default"]; + }), { + "../value-types/utils": 347, + "./vec3": 350 + } ], + 342: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _valueType = _interopRequireDefault(require("./value-type")); + var _CCClass = _interopRequireDefault(require("../platform/CCClass")); + var _vec = _interopRequireDefault(require("./vec3")); + var _quat = _interopRequireDefault(require("./quat")); + var _utils = require("./utils"); + var _mat = _interopRequireDefault(require("./mat3")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + _setPrototypeOf(subClass, superClass); + } + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + return _setPrototypeOf(o, p); + } + var _a00 = 0; + var _a01 = 0; + var _a02 = 0; + var _a03 = 0; + var _a10 = 0; + var _a11 = 0; + var _a12 = 0; + var _a13 = 0; + var _a20 = 0; + var _a21 = 0; + var _a22 = 0; + var _a23 = 0; + var _a30 = 0; + var _a31 = 0; + var _a32 = 0; + var _a33 = 0; + var Mat4 = (function(_ValueType) { + _inheritsLoose(Mat4, _ValueType); + var _proto = Mat4.prototype; + _proto.mul = function mul(m, out) { + return Mat4.multiply(out || new Mat4(), this, m); + }; + _proto.mulScalar = function mulScalar(num, out) { + Mat4.multiplyScalar(out || new Mat4(), this, num); + }; + _proto.sub = function sub(m, out) { + Mat4.subtract(out || new Mat4(), this, m); + }; + Mat4.clone = function clone(a) { + var m = a.m; + return new Mat4(m[0], m[1], m[2], m[3], m[4], m[5], m[6], m[7], m[8], m[9], m[10], m[11], m[12], m[13], m[14], m[15]); + }; + Mat4.copy = function copy(out, a) { + var m = out.m, am = a.m; + m[0] = am[0]; + m[1] = am[1]; + m[2] = am[2]; + m[3] = am[3]; + m[4] = am[4]; + m[5] = am[5]; + m[6] = am[6]; + m[7] = am[7]; + m[8] = am[8]; + m[9] = am[9]; + m[10] = am[10]; + m[11] = am[11]; + m[12] = am[12]; + m[13] = am[13]; + m[14] = am[14]; + m[15] = am[15]; + return out; + }; + Mat4.set = function set(out, m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) { + var m = out.m; + m[0] = m00; + m[1] = m01; + m[2] = m02; + m[3] = m03; + m[4] = m10; + m[5] = m11; + m[6] = m12; + m[7] = m13; + m[8] = m20; + m[9] = m21; + m[10] = m22; + m[11] = m23; + m[12] = m30; + m[13] = m31; + m[14] = m32; + m[15] = m33; + return out; + }; + Mat4.identity = function identity(out) { + var m = out.m; + m[0] = 1; + m[1] = 0; + m[2] = 0; + m[3] = 0; + m[4] = 0; + m[5] = 1; + m[6] = 0; + m[7] = 0; + m[8] = 0; + m[9] = 0; + m[10] = 1; + m[11] = 0; + m[12] = 0; + m[13] = 0; + m[14] = 0; + m[15] = 1; + return out; + }; + Mat4.transpose = function transpose(out, a) { + var m = out.m, am = a.m; + if (out === a) { + var a01 = am[1], a02 = am[2], a03 = am[3], a12 = am[6], a13 = am[7], a23 = am[11]; + m[1] = am[4]; + m[2] = am[8]; + m[3] = am[12]; + m[4] = a01; + m[6] = am[9]; + m[7] = am[13]; + m[8] = a02; + m[9] = a12; + m[11] = am[14]; + m[12] = a03; + m[13] = a13; + m[14] = a23; + } else { + m[0] = am[0]; + m[1] = am[4]; + m[2] = am[8]; + m[3] = am[12]; + m[4] = am[1]; + m[5] = am[5]; + m[6] = am[9]; + m[7] = am[13]; + m[8] = am[2]; + m[9] = am[6]; + m[10] = am[10]; + m[11] = am[14]; + m[12] = am[3]; + m[13] = am[7]; + m[14] = am[11]; + m[15] = am[15]; + } + return out; + }; + Mat4.invert = function invert(out, a) { + var am = a.m; + _a00 = am[0]; + _a01 = am[1]; + _a02 = am[2]; + _a03 = am[3]; + _a10 = am[4]; + _a11 = am[5]; + _a12 = am[6]; + _a13 = am[7]; + _a20 = am[8]; + _a21 = am[9]; + _a22 = am[10]; + _a23 = am[11]; + _a30 = am[12]; + _a31 = am[13]; + _a32 = am[14]; + _a33 = am[15]; + var b00 = _a00 * _a11 - _a01 * _a10; + var b01 = _a00 * _a12 - _a02 * _a10; + var b02 = _a00 * _a13 - _a03 * _a10; + var b03 = _a01 * _a12 - _a02 * _a11; + var b04 = _a01 * _a13 - _a03 * _a11; + var b05 = _a02 * _a13 - _a03 * _a12; + var b06 = _a20 * _a31 - _a21 * _a30; + var b07 = _a20 * _a32 - _a22 * _a30; + var b08 = _a20 * _a33 - _a23 * _a30; + var b09 = _a21 * _a32 - _a22 * _a31; + var b10 = _a21 * _a33 - _a23 * _a31; + var b11 = _a22 * _a33 - _a23 * _a32; + var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; + if (0 === det) return null; + det = 1 / det; + var m = out.m; + m[0] = (_a11 * b11 - _a12 * b10 + _a13 * b09) * det; + m[1] = (_a02 * b10 - _a01 * b11 - _a03 * b09) * det; + m[2] = (_a31 * b05 - _a32 * b04 + _a33 * b03) * det; + m[3] = (_a22 * b04 - _a21 * b05 - _a23 * b03) * det; + m[4] = (_a12 * b08 - _a10 * b11 - _a13 * b07) * det; + m[5] = (_a00 * b11 - _a02 * b08 + _a03 * b07) * det; + m[6] = (_a32 * b02 - _a30 * b05 - _a33 * b01) * det; + m[7] = (_a20 * b05 - _a22 * b02 + _a23 * b01) * det; + m[8] = (_a10 * b10 - _a11 * b08 + _a13 * b06) * det; + m[9] = (_a01 * b08 - _a00 * b10 - _a03 * b06) * det; + m[10] = (_a30 * b04 - _a31 * b02 + _a33 * b00) * det; + m[11] = (_a21 * b02 - _a20 * b04 - _a23 * b00) * det; + m[12] = (_a11 * b07 - _a10 * b09 - _a12 * b06) * det; + m[13] = (_a00 * b09 - _a01 * b07 + _a02 * b06) * det; + m[14] = (_a31 * b01 - _a30 * b03 - _a32 * b00) * det; + m[15] = (_a20 * b03 - _a21 * b01 + _a22 * b00) * det; + return out; + }; + Mat4.determinant = function determinant(a) { + var m = a.m; + _a00 = m[0]; + _a01 = m[1]; + _a02 = m[2]; + _a03 = m[3]; + _a10 = m[4]; + _a11 = m[5]; + _a12 = m[6]; + _a13 = m[7]; + _a20 = m[8]; + _a21 = m[9]; + _a22 = m[10]; + _a23 = m[11]; + _a30 = m[12]; + _a31 = m[13]; + _a32 = m[14]; + _a33 = m[15]; + var b00 = _a00 * _a11 - _a01 * _a10; + var b01 = _a00 * _a12 - _a02 * _a10; + var b02 = _a00 * _a13 - _a03 * _a10; + var b03 = _a01 * _a12 - _a02 * _a11; + var b04 = _a01 * _a13 - _a03 * _a11; + var b05 = _a02 * _a13 - _a03 * _a12; + var b06 = _a20 * _a31 - _a21 * _a30; + var b07 = _a20 * _a32 - _a22 * _a30; + var b08 = _a20 * _a33 - _a23 * _a30; + var b09 = _a21 * _a32 - _a22 * _a31; + var b10 = _a21 * _a33 - _a23 * _a31; + var b11 = _a22 * _a33 - _a23 * _a32; + return b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; + }; + Mat4.multiply = function multiply(out, a, b) { + var m = out.m, am = a.m, bm = b.m; + _a00 = am[0]; + _a01 = am[1]; + _a02 = am[2]; + _a03 = am[3]; + _a10 = am[4]; + _a11 = am[5]; + _a12 = am[6]; + _a13 = am[7]; + _a20 = am[8]; + _a21 = am[9]; + _a22 = am[10]; + _a23 = am[11]; + _a30 = am[12]; + _a31 = am[13]; + _a32 = am[14]; + _a33 = am[15]; + var b0 = bm[0], b1 = bm[1], b2 = bm[2], b3 = bm[3]; + m[0] = b0 * _a00 + b1 * _a10 + b2 * _a20 + b3 * _a30; + m[1] = b0 * _a01 + b1 * _a11 + b2 * _a21 + b3 * _a31; + m[2] = b0 * _a02 + b1 * _a12 + b2 * _a22 + b3 * _a32; + m[3] = b0 * _a03 + b1 * _a13 + b2 * _a23 + b3 * _a33; + b0 = bm[4]; + b1 = bm[5]; + b2 = bm[6]; + b3 = bm[7]; + m[4] = b0 * _a00 + b1 * _a10 + b2 * _a20 + b3 * _a30; + m[5] = b0 * _a01 + b1 * _a11 + b2 * _a21 + b3 * _a31; + m[6] = b0 * _a02 + b1 * _a12 + b2 * _a22 + b3 * _a32; + m[7] = b0 * _a03 + b1 * _a13 + b2 * _a23 + b3 * _a33; + b0 = bm[8]; + b1 = bm[9]; + b2 = bm[10]; + b3 = bm[11]; + m[8] = b0 * _a00 + b1 * _a10 + b2 * _a20 + b3 * _a30; + m[9] = b0 * _a01 + b1 * _a11 + b2 * _a21 + b3 * _a31; + m[10] = b0 * _a02 + b1 * _a12 + b2 * _a22 + b3 * _a32; + m[11] = b0 * _a03 + b1 * _a13 + b2 * _a23 + b3 * _a33; + b0 = bm[12]; + b1 = bm[13]; + b2 = bm[14]; + b3 = bm[15]; + m[12] = b0 * _a00 + b1 * _a10 + b2 * _a20 + b3 * _a30; + m[13] = b0 * _a01 + b1 * _a11 + b2 * _a21 + b3 * _a31; + m[14] = b0 * _a02 + b1 * _a12 + b2 * _a22 + b3 * _a32; + m[15] = b0 * _a03 + b1 * _a13 + b2 * _a23 + b3 * _a33; + return out; + }; + Mat4.transform = function transform(out, a, v) { + var x = v.x, y = v.y, z = v.z; + var m = out.m, am = a.m; + if (a === out) { + m[12] = am[0] * x + am[4] * y + am[8] * z + am[12]; + m[13] = am[1] * x + am[5] * y + am[9] * z + am[13]; + m[14] = am[2] * x + am[6] * y + am[10] * z + am[14]; + m[15] = am[3] * x + am[7] * y + am[11] * z + am[15]; + } else { + _a00 = am[0]; + _a01 = am[1]; + _a02 = am[2]; + _a03 = am[3]; + _a10 = am[4]; + _a11 = am[5]; + _a12 = am[6]; + _a13 = am[7]; + _a20 = am[8]; + _a21 = am[9]; + _a22 = am[10]; + _a23 = am[11]; + _a30 = am[12]; + _a31 = am[13]; + _a32 = am[14]; + _a33 = am[15]; + m[0] = _a00; + m[1] = _a01; + m[2] = _a02; + m[3] = _a03; + m[4] = _a10; + m[5] = _a11; + m[6] = _a12; + m[7] = _a13; + m[8] = _a20; + m[9] = _a21; + m[10] = _a22; + m[11] = _a23; + m[12] = _a00 * x + _a10 * y + _a20 * z + am[12]; + m[13] = _a01 * x + _a11 * y + _a21 * z + am[13]; + m[14] = _a02 * x + _a12 * y + _a22 * z + am[14]; + m[15] = _a03 * x + _a13 * y + _a23 * z + am[15]; + } + return out; + }; + Mat4.translate = function translate(out, a, v) { + var m = out.m, am = a.m; + if (a === out) { + m[12] += v.x; + m[13] += v.y; + m[14] += v.z; + } else { + m[0] = am[0]; + m[1] = am[1]; + m[2] = am[2]; + m[3] = am[3]; + m[4] = am[4]; + m[5] = am[5]; + m[6] = am[6]; + m[7] = am[7]; + m[8] = am[8]; + m[9] = am[9]; + m[10] = am[10]; + m[11] = am[11]; + m[12] += v.x; + m[13] += v.y; + m[14] += v.z; + m[15] = am[15]; + } + return out; + }; + Mat4.scale = function scale(out, a, v) { + var x = v.x, y = v.y, z = v.z; + var m = out.m, am = a.m; + m[0] = am[0] * x; + m[1] = am[1] * x; + m[2] = am[2] * x; + m[3] = am[3] * x; + m[4] = am[4] * y; + m[5] = am[5] * y; + m[6] = am[6] * y; + m[7] = am[7] * y; + m[8] = am[8] * z; + m[9] = am[9] * z; + m[10] = am[10] * z; + m[11] = am[11] * z; + m[12] = am[12]; + m[13] = am[13]; + m[14] = am[14]; + m[15] = am[15]; + return out; + }; + Mat4.rotate = function rotate(out, a, rad, axis) { + var x = axis.x, y = axis.y, z = axis.z; + var len = Math.sqrt(x * x + y * y + z * z); + if (Math.abs(len) < _utils.EPSILON) return null; + len = 1 / len; + x *= len; + y *= len; + z *= len; + var s = Math.sin(rad); + var c = Math.cos(rad); + var t = 1 - c; + var am = a.m; + _a00 = am[0]; + _a01 = am[1]; + _a02 = am[2]; + _a03 = am[3]; + _a10 = am[4]; + _a11 = am[5]; + _a12 = am[6]; + _a13 = am[7]; + _a20 = am[8]; + _a21 = am[9]; + _a22 = am[10]; + _a23 = am[11]; + var b00 = x * x * t + c, b01 = y * x * t + z * s, b02 = z * x * t - y * s; + var b10 = x * y * t - z * s, b11 = y * y * t + c, b12 = z * y * t + x * s; + var b20 = x * z * t + y * s, b21 = y * z * t - x * s, b22 = z * z * t + c; + var m = out.m; + m[0] = _a00 * b00 + _a10 * b01 + _a20 * b02; + m[1] = _a01 * b00 + _a11 * b01 + _a21 * b02; + m[2] = _a02 * b00 + _a12 * b01 + _a22 * b02; + m[3] = _a03 * b00 + _a13 * b01 + _a23 * b02; + m[4] = _a00 * b10 + _a10 * b11 + _a20 * b12; + m[5] = _a01 * b10 + _a11 * b11 + _a21 * b12; + m[6] = _a02 * b10 + _a12 * b11 + _a22 * b12; + m[7] = _a03 * b10 + _a13 * b11 + _a23 * b12; + m[8] = _a00 * b20 + _a10 * b21 + _a20 * b22; + m[9] = _a01 * b20 + _a11 * b21 + _a21 * b22; + m[10] = _a02 * b20 + _a12 * b21 + _a22 * b22; + m[11] = _a03 * b20 + _a13 * b21 + _a23 * b22; + if (a !== out) { + m[12] = am[12]; + m[13] = am[13]; + m[14] = am[14]; + m[15] = am[15]; + } + return out; + }; + Mat4.rotateX = function rotateX(out, a, rad) { + var m = out.m, am = a.m; + var s = Math.sin(rad), c = Math.cos(rad), a10 = am[4], a11 = am[5], a12 = am[6], a13 = am[7], a20 = am[8], a21 = am[9], a22 = am[10], a23 = am[11]; + if (a !== out) { + m[0] = am[0]; + m[1] = am[1]; + m[2] = am[2]; + m[3] = am[3]; + m[12] = am[12]; + m[13] = am[13]; + m[14] = am[14]; + m[15] = am[15]; + } + m[4] = a10 * c + a20 * s; + m[5] = a11 * c + a21 * s; + m[6] = a12 * c + a22 * s; + m[7] = a13 * c + a23 * s; + m[8] = a20 * c - a10 * s; + m[9] = a21 * c - a11 * s; + m[10] = a22 * c - a12 * s; + m[11] = a23 * c - a13 * s; + return out; + }; + Mat4.rotateY = function rotateY(out, a, rad) { + var m = out.m, am = a.m; + var s = Math.sin(rad), c = Math.cos(rad), a00 = am[0], a01 = am[1], a02 = am[2], a03 = am[3], a20 = am[8], a21 = am[9], a22 = am[10], a23 = am[11]; + if (a !== out) { + m[4] = am[4]; + m[5] = am[5]; + m[6] = am[6]; + m[7] = am[7]; + m[12] = am[12]; + m[13] = am[13]; + m[14] = am[14]; + m[15] = am[15]; + } + m[0] = a00 * c - a20 * s; + m[1] = a01 * c - a21 * s; + m[2] = a02 * c - a22 * s; + m[3] = a03 * c - a23 * s; + m[8] = a00 * s + a20 * c; + m[9] = a01 * s + a21 * c; + m[10] = a02 * s + a22 * c; + m[11] = a03 * s + a23 * c; + return out; + }; + Mat4.rotateZ = function rotateZ(out, a, rad) { + var am = a.m; + var m = out.m; + var s = Math.sin(rad), c = Math.cos(rad), a00 = a.m[0], a01 = a.m[1], a02 = a.m[2], a03 = a.m[3], a10 = a.m[4], a11 = a.m[5], a12 = a.m[6], a13 = a.m[7]; + if (a !== out) { + m[8] = am[8]; + m[9] = am[9]; + m[10] = am[10]; + m[11] = am[11]; + m[12] = am[12]; + m[13] = am[13]; + m[14] = am[14]; + m[15] = am[15]; + } + m[0] = a00 * c + a10 * s; + m[1] = a01 * c + a11 * s; + m[2] = a02 * c + a12 * s; + m[3] = a03 * c + a13 * s; + m[4] = a10 * c - a00 * s; + m[5] = a11 * c - a01 * s; + m[6] = a12 * c - a02 * s; + m[7] = a13 * c - a03 * s; + return out; + }; + Mat4.fromTranslation = function fromTranslation(out, v) { + var m = out.m; + m[0] = 1; + m[1] = 0; + m[2] = 0; + m[3] = 0; + m[4] = 0; + m[5] = 1; + m[6] = 0; + m[7] = 0; + m[8] = 0; + m[9] = 0; + m[10] = 1; + m[11] = 0; + m[12] = v.x; + m[13] = v.y; + m[14] = v.z; + m[15] = 1; + return out; + }; + Mat4.fromScaling = function fromScaling(out, v) { + var m = out.m; + m[0] = v.x; + m[1] = 0; + m[2] = 0; + m[3] = 0; + m[4] = 0; + m[5] = v.y; + m[6] = 0; + m[7] = 0; + m[8] = 0; + m[9] = 0; + m[10] = v.z; + m[11] = 0; + m[12] = 0; + m[13] = 0; + m[14] = 0; + m[15] = 1; + return out; + }; + Mat4.fromRotation = function fromRotation(out, rad, axis) { + var x = axis.x, y = axis.y, z = axis.z; + var len = Math.sqrt(x * x + y * y + z * z); + if (Math.abs(len) < _utils.EPSILON) return null; + len = 1 / len; + x *= len; + y *= len; + z *= len; + var s = Math.sin(rad); + var c = Math.cos(rad); + var t = 1 - c; + var m = out.m; + m[0] = x * x * t + c; + m[1] = y * x * t + z * s; + m[2] = z * x * t - y * s; + m[3] = 0; + m[4] = x * y * t - z * s; + m[5] = y * y * t + c; + m[6] = z * y * t + x * s; + m[7] = 0; + m[8] = x * z * t + y * s; + m[9] = y * z * t - x * s; + m[10] = z * z * t + c; + m[11] = 0; + m[12] = 0; + m[13] = 0; + m[14] = 0; + m[15] = 1; + return out; + }; + Mat4.fromXRotation = function fromXRotation(out, rad) { + var s = Math.sin(rad), c = Math.cos(rad); + var m = out.m; + m[0] = 1; + m[1] = 0; + m[2] = 0; + m[3] = 0; + m[4] = 0; + m[5] = c; + m[6] = s; + m[7] = 0; + m[8] = 0; + m[9] = -s; + m[10] = c; + m[11] = 0; + m[12] = 0; + m[13] = 0; + m[14] = 0; + m[15] = 1; + return out; + }; + Mat4.fromYRotation = function fromYRotation(out, rad) { + var s = Math.sin(rad), c = Math.cos(rad); + var m = out.m; + m[0] = c; + m[1] = 0; + m[2] = -s; + m[3] = 0; + m[4] = 0; + m[5] = 1; + m[6] = 0; + m[7] = 0; + m[8] = s; + m[9] = 0; + m[10] = c; + m[11] = 0; + m[12] = 0; + m[13] = 0; + m[14] = 0; + m[15] = 1; + return out; + }; + Mat4.fromZRotation = function fromZRotation(out, rad) { + var s = Math.sin(rad), c = Math.cos(rad); + var m = out.m; + m[0] = c; + m[1] = s; + m[2] = 0; + m[3] = 0; + m[4] = -s; + m[5] = c; + m[6] = 0; + m[7] = 0; + m[8] = 0; + m[9] = 0; + m[10] = 1; + m[11] = 0; + m[12] = 0; + m[13] = 0; + m[14] = 0; + m[15] = 1; + return out; + }; + Mat4.fromRT = function fromRT(out, q, v) { + var x = q.x, y = q.y, z = q.z, w = q.w; + var x2 = x + x; + var y2 = y + y; + var z2 = z + z; + var xx = x * x2; + var xy = x * y2; + var xz = x * z2; + var yy = y * y2; + var yz = y * z2; + var zz = z * z2; + var wx = w * x2; + var wy = w * y2; + var wz = w * z2; + var m = out.m; + m[0] = 1 - (yy + zz); + m[1] = xy + wz; + m[2] = xz - wy; + m[3] = 0; + m[4] = xy - wz; + m[5] = 1 - (xx + zz); + m[6] = yz + wx; + m[7] = 0; + m[8] = xz + wy; + m[9] = yz - wx; + m[10] = 1 - (xx + yy); + m[11] = 0; + m[12] = v.x; + m[13] = v.y; + m[14] = v.z; + m[15] = 1; + return out; + }; + Mat4.getTranslation = function getTranslation(out, mat) { + var m = mat.m; + out.x = m[12]; + out.y = m[13]; + out.z = m[14]; + return out; + }; + Mat4.getScaling = function getScaling(out, mat) { + var m = mat.m; + var m3 = m3_1.m; + var m00 = m3[0] = m[0]; + var m01 = m3[1] = m[1]; + var m02 = m3[2] = m[2]; + var m04 = m3[3] = m[4]; + var m05 = m3[4] = m[5]; + var m06 = m3[5] = m[6]; + var m08 = m3[6] = m[8]; + var m09 = m3[7] = m[9]; + var m10 = m3[8] = m[10]; + out.x = Math.sqrt(m00 * m00 + m01 * m01 + m02 * m02); + out.y = Math.sqrt(m04 * m04 + m05 * m05 + m06 * m06); + out.z = Math.sqrt(m08 * m08 + m09 * m09 + m10 * m10); + _mat["default"].determinant(m3_1) < 0 && (out.x *= -1); + return out; + }; + Mat4.getRotation = function getRotation(out, mat) { + var m = mat.m; + var trace = m[0] + m[5] + m[10]; + var S = 0; + if (trace > 0) { + S = 2 * Math.sqrt(trace + 1); + out.w = .25 * S; + out.x = (m[6] - m[9]) / S; + out.y = (m[8] - m[2]) / S; + out.z = (m[1] - m[4]) / S; + } else if (m[0] > m[5] && m[0] > m[10]) { + S = 2 * Math.sqrt(1 + m[0] - m[5] - m[10]); + out.w = (m[6] - m[9]) / S; + out.x = .25 * S; + out.y = (m[1] + m[4]) / S; + out.z = (m[8] + m[2]) / S; + } else if (m[5] > m[10]) { + S = 2 * Math.sqrt(1 + m[5] - m[0] - m[10]); + out.w = (m[8] - m[2]) / S; + out.x = (m[1] + m[4]) / S; + out.y = .25 * S; + out.z = (m[6] + m[9]) / S; + } else { + S = 2 * Math.sqrt(1 + m[10] - m[0] - m[5]); + out.w = (m[1] - m[4]) / S; + out.x = (m[8] + m[2]) / S; + out.y = (m[6] + m[9]) / S; + out.z = .25 * S; + } + return out; + }; + Mat4.toRTS = function toRTS(mat, q, v, s) { + var m = mat.m; + var m3 = m3_1.m; + s.x = _vec["default"].set(v3_1, m[0], m[1], m[2]).mag(); + m3[0] = m[0] / s.x; + m3[1] = m[1] / s.x; + m3[2] = m[2] / s.x; + s.y = _vec["default"].set(v3_1, m[4], m[5], m[6]).mag(); + m3[3] = m[4] / s.y; + m3[4] = m[5] / s.y; + m3[5] = m[6] / s.y; + s.z = _vec["default"].set(v3_1, m[8], m[9], m[10]).mag(); + m3[6] = m[8] / s.z; + m3[7] = m[9] / s.z; + m3[8] = m[10] / s.z; + var det = _mat["default"].determinant(m3_1); + if (det < 0) { + s.x *= -1; + m3[0] *= -1; + m3[1] *= -1; + m3[2] *= -1; + } + _quat["default"].fromMat3(q, m3_1); + _vec["default"].set(v, m[12], m[13], m[14]); + }; + Mat4.fromRTS = function fromRTS(out, q, v, s) { + var x = q.x, y = q.y, z = q.z, w = q.w; + var x2 = x + x; + var y2 = y + y; + var z2 = z + z; + var xx = x * x2; + var xy = x * y2; + var xz = x * z2; + var yy = y * y2; + var yz = y * z2; + var zz = z * z2; + var wx = w * x2; + var wy = w * y2; + var wz = w * z2; + var sx = s.x; + var sy = s.y; + var sz = s.z; + var m = out.m; + m[0] = (1 - (yy + zz)) * sx; + m[1] = (xy + wz) * sx; + m[2] = (xz - wy) * sx; + m[3] = 0; + m[4] = (xy - wz) * sy; + m[5] = (1 - (xx + zz)) * sy; + m[6] = (yz + wx) * sy; + m[7] = 0; + m[8] = (xz + wy) * sz; + m[9] = (yz - wx) * sz; + m[10] = (1 - (xx + yy)) * sz; + m[11] = 0; + m[12] = v.x; + m[13] = v.y; + m[14] = v.z; + m[15] = 1; + return out; + }; + Mat4.fromRTSOrigin = function fromRTSOrigin(out, q, v, s, o) { + var x = q.x, y = q.y, z = q.z, w = q.w; + var x2 = x + x; + var y2 = y + y; + var z2 = z + z; + var xx = x * x2; + var xy = x * y2; + var xz = x * z2; + var yy = y * y2; + var yz = y * z2; + var zz = z * z2; + var wx = w * x2; + var wy = w * y2; + var wz = w * z2; + var sx = s.x; + var sy = s.y; + var sz = s.z; + var ox = o.x; + var oy = o.y; + var oz = o.z; + var m = out.m; + m[0] = (1 - (yy + zz)) * sx; + m[1] = (xy + wz) * sx; + m[2] = (xz - wy) * sx; + m[3] = 0; + m[4] = (xy - wz) * sy; + m[5] = (1 - (xx + zz)) * sy; + m[6] = (yz + wx) * sy; + m[7] = 0; + m[8] = (xz + wy) * sz; + m[9] = (yz - wx) * sz; + m[10] = (1 - (xx + yy)) * sz; + m[11] = 0; + m[12] = v.x + ox - (m[0] * ox + m[4] * oy + m[8] * oz); + m[13] = v.y + oy - (m[1] * ox + m[5] * oy + m[9] * oz); + m[14] = v.z + oz - (m[2] * ox + m[6] * oy + m[10] * oz); + m[15] = 1; + return out; + }; + Mat4.fromQuat = function fromQuat(out, q) { + var x = q.x, y = q.y, z = q.z, w = q.w; + var x2 = x + x; + var y2 = y + y; + var z2 = z + z; + var xx = x * x2; + var yx = y * x2; + var yy = y * y2; + var zx = z * x2; + var zy = z * y2; + var zz = z * z2; + var wx = w * x2; + var wy = w * y2; + var wz = w * z2; + var m = out.m; + m[0] = 1 - yy - zz; + m[1] = yx + wz; + m[2] = zx - wy; + m[3] = 0; + m[4] = yx - wz; + m[5] = 1 - xx - zz; + m[6] = zy + wx; + m[7] = 0; + m[8] = zx + wy; + m[9] = zy - wx; + m[10] = 1 - xx - yy; + m[11] = 0; + m[12] = 0; + m[13] = 0; + m[14] = 0; + m[15] = 1; + return out; + }; + Mat4.frustum = function frustum(out, left, right, bottom, top, near, far) { + var rl = 1 / (right - left); + var tb = 1 / (top - bottom); + var nf = 1 / (near - far); + var m = out.m; + m[0] = 2 * near * rl; + m[1] = 0; + m[2] = 0; + m[3] = 0; + m[4] = 0; + m[5] = 2 * near * tb; + m[6] = 0; + m[7] = 0; + m[8] = (right + left) * rl; + m[9] = (top + bottom) * tb; + m[10] = (far + near) * nf; + m[11] = -1; + m[12] = 0; + m[13] = 0; + m[14] = far * near * 2 * nf; + m[15] = 0; + return out; + }; + Mat4.perspective = function perspective(out, fovy, aspect, near, far) { + var f = 1 / Math.tan(fovy / 2); + var nf = 1 / (near - far); + var m = out.m; + m[0] = f / aspect; + m[1] = 0; + m[2] = 0; + m[3] = 0; + m[4] = 0; + m[5] = f; + m[6] = 0; + m[7] = 0; + m[8] = 0; + m[9] = 0; + m[10] = (far + near) * nf; + m[11] = -1; + m[12] = 0; + m[13] = 0; + m[14] = 2 * far * near * nf; + m[15] = 0; + return out; + }; + Mat4.ortho = function ortho(out, left, right, bottom, top, near, far) { + var lr = 1 / (left - right); + var bt = 1 / (bottom - top); + var nf = 1 / (near - far); + var m = out.m; + m[0] = -2 * lr; + m[1] = 0; + m[2] = 0; + m[3] = 0; + m[4] = 0; + m[5] = -2 * bt; + m[6] = 0; + m[7] = 0; + m[8] = 0; + m[9] = 0; + m[10] = 2 * nf; + m[11] = 0; + m[12] = (left + right) * lr; + m[13] = (top + bottom) * bt; + m[14] = (far + near) * nf; + m[15] = 1; + return out; + }; + Mat4.lookAt = function lookAt(out, eye, center, up) { + var eyex = eye.x; + var eyey = eye.y; + var eyez = eye.z; + var upx = up.x; + var upy = up.y; + var upz = up.z; + var centerx = center.x; + var centery = center.y; + var centerz = center.z; + var z0 = eyex - centerx; + var z1 = eyey - centery; + var z2 = eyez - centerz; + var len = 1 / Math.sqrt(z0 * z0 + z1 * z1 + z2 * z2); + z0 *= len; + z1 *= len; + z2 *= len; + var x0 = upy * z2 - upz * z1; + var x1 = upz * z0 - upx * z2; + var x2 = upx * z1 - upy * z0; + len = 1 / Math.sqrt(x0 * x0 + x1 * x1 + x2 * x2); + x0 *= len; + x1 *= len; + x2 *= len; + var y0 = z1 * x2 - z2 * x1; + var y1 = z2 * x0 - z0 * x2; + var y2 = z0 * x1 - z1 * x0; + var m = out.m; + m[0] = x0; + m[1] = y0; + m[2] = z0; + m[3] = 0; + m[4] = x1; + m[5] = y1; + m[6] = z1; + m[7] = 0; + m[8] = x2; + m[9] = y2; + m[10] = z2; + m[11] = 0; + m[12] = -(x0 * eyex + x1 * eyey + x2 * eyez); + m[13] = -(y0 * eyex + y1 * eyey + y2 * eyez); + m[14] = -(z0 * eyex + z1 * eyey + z2 * eyez); + m[15] = 1; + return out; + }; + Mat4.inverseTranspose = function inverseTranspose(out, a) { + var m = a.m; + _a00 = m[0]; + _a01 = m[1]; + _a02 = m[2]; + _a03 = m[3]; + _a10 = m[4]; + _a11 = m[5]; + _a12 = m[6]; + _a13 = m[7]; + _a20 = m[8]; + _a21 = m[9]; + _a22 = m[10]; + _a23 = m[11]; + _a30 = m[12]; + _a31 = m[13]; + _a32 = m[14]; + _a33 = m[15]; + var b00 = _a00 * _a11 - _a01 * _a10; + var b01 = _a00 * _a12 - _a02 * _a10; + var b02 = _a00 * _a13 - _a03 * _a10; + var b03 = _a01 * _a12 - _a02 * _a11; + var b04 = _a01 * _a13 - _a03 * _a11; + var b05 = _a02 * _a13 - _a03 * _a12; + var b06 = _a20 * _a31 - _a21 * _a30; + var b07 = _a20 * _a32 - _a22 * _a30; + var b08 = _a20 * _a33 - _a23 * _a30; + var b09 = _a21 * _a32 - _a22 * _a31; + var b10 = _a21 * _a33 - _a23 * _a31; + var b11 = _a22 * _a33 - _a23 * _a32; + var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; + if (!det) return null; + det = 1 / det; + m = out.m; + m[0] = (_a11 * b11 - _a12 * b10 + _a13 * b09) * det; + m[1] = (_a12 * b08 - _a10 * b11 - _a13 * b07) * det; + m[2] = (_a10 * b10 - _a11 * b08 + _a13 * b06) * det; + m[3] = 0; + m[4] = (_a02 * b10 - _a01 * b11 - _a03 * b09) * det; + m[5] = (_a00 * b11 - _a02 * b08 + _a03 * b07) * det; + m[6] = (_a01 * b08 - _a00 * b10 - _a03 * b06) * det; + m[7] = 0; + m[8] = (_a31 * b05 - _a32 * b04 + _a33 * b03) * det; + m[9] = (_a32 * b02 - _a30 * b05 - _a33 * b01) * det; + m[10] = (_a30 * b04 - _a31 * b02 + _a33 * b00) * det; + m[11] = 0; + m[12] = 0; + m[13] = 0; + m[14] = 0; + m[15] = 1; + return out; + }; + Mat4.add = function add(out, a, b) { + var m = out.m, am = a.m, bm = b.m; + m[0] = am[0] + bm[0]; + m[1] = am[1] + bm[1]; + m[2] = am[2] + bm[2]; + m[3] = am[3] + bm[3]; + m[4] = am[4] + bm[4]; + m[5] = am[5] + bm[5]; + m[6] = am[6] + bm[6]; + m[7] = am[7] + bm[7]; + m[8] = am[8] + bm[8]; + m[9] = am[9] + bm[9]; + m[10] = am[10] + bm[10]; + m[11] = am[11] + bm[11]; + m[12] = am[12] + bm[12]; + m[13] = am[13] + bm[13]; + m[14] = am[14] + bm[14]; + m[15] = am[15] + bm[15]; + return out; + }; + Mat4.subtract = function subtract(out, a, b) { + var m = out.m, am = a.m, bm = b.m; + m[0] = am[0] - bm[0]; + m[1] = am[1] - bm[1]; + m[2] = am[2] - bm[2]; + m[3] = am[3] - bm[3]; + m[4] = am[4] - bm[4]; + m[5] = am[5] - bm[5]; + m[6] = am[6] - bm[6]; + m[7] = am[7] - bm[7]; + m[8] = am[8] - bm[8]; + m[9] = am[9] - bm[9]; + m[10] = am[10] - bm[10]; + m[11] = am[11] - bm[11]; + m[12] = am[12] - bm[12]; + m[13] = am[13] - bm[13]; + m[14] = am[14] - bm[14]; + m[15] = am[15] - bm[15]; + return out; + }; + Mat4.multiplyScalar = function multiplyScalar(out, a, b) { + var m = out.m, am = a.m; + m[0] = am[0] * b; + m[1] = am[1] * b; + m[2] = am[2] * b; + m[3] = am[3] * b; + m[4] = am[4] * b; + m[5] = am[5] * b; + m[6] = am[6] * b; + m[7] = am[7] * b; + m[8] = am[8] * b; + m[9] = am[9] * b; + m[10] = am[10] * b; + m[11] = am[11] * b; + m[12] = am[12] * b; + m[13] = am[13] * b; + m[14] = am[14] * b; + m[15] = am[15] * b; + return out; + }; + Mat4.multiplyScalarAndAdd = function multiplyScalarAndAdd(out, a, b, scale) { + var m = out.m, am = a.m, bm = b.m; + m[0] = am[0] + bm[0] * scale; + m[1] = am[1] + bm[1] * scale; + m[2] = am[2] + bm[2] * scale; + m[3] = am[3] + bm[3] * scale; + m[4] = am[4] + bm[4] * scale; + m[5] = am[5] + bm[5] * scale; + m[6] = am[6] + bm[6] * scale; + m[7] = am[7] + bm[7] * scale; + m[8] = am[8] + bm[8] * scale; + m[9] = am[9] + bm[9] * scale; + m[10] = am[10] + bm[10] * scale; + m[11] = am[11] + bm[11] * scale; + m[12] = am[12] + bm[12] * scale; + m[13] = am[13] + bm[13] * scale; + m[14] = am[14] + bm[14] * scale; + m[15] = am[15] + bm[15] * scale; + return out; + }; + Mat4.strictEquals = function strictEquals(a, b) { + var am = a.m, bm = b.m; + return am[0] === bm[0] && am[1] === bm[1] && am[2] === bm[2] && am[3] === bm[3] && am[4] === bm[4] && am[5] === bm[5] && am[6] === bm[6] && am[7] === bm[7] && am[8] === bm[8] && am[9] === bm[9] && am[10] === bm[10] && am[11] === bm[11] && am[12] === bm[12] && am[13] === bm[13] && am[14] === bm[14] && am[15] === bm[15]; + }; + Mat4.equals = function equals(a, b, epsilon) { + void 0 === epsilon && (epsilon = _utils.EPSILON); + var am = a.m, bm = b.m; + return Math.abs(am[0] - bm[0]) <= epsilon * Math.max(1, Math.abs(am[0]), Math.abs(bm[0])) && Math.abs(am[1] - bm[1]) <= epsilon * Math.max(1, Math.abs(am[1]), Math.abs(bm[1])) && Math.abs(am[2] - bm[2]) <= epsilon * Math.max(1, Math.abs(am[2]), Math.abs(bm[2])) && Math.abs(am[3] - bm[3]) <= epsilon * Math.max(1, Math.abs(am[3]), Math.abs(bm[3])) && Math.abs(am[4] - bm[4]) <= epsilon * Math.max(1, Math.abs(am[4]), Math.abs(bm[4])) && Math.abs(am[5] - bm[5]) <= epsilon * Math.max(1, Math.abs(am[5]), Math.abs(bm[5])) && Math.abs(am[6] - bm[6]) <= epsilon * Math.max(1, Math.abs(am[6]), Math.abs(bm[6])) && Math.abs(am[7] - bm[7]) <= epsilon * Math.max(1, Math.abs(am[7]), Math.abs(bm[7])) && Math.abs(am[8] - bm[8]) <= epsilon * Math.max(1, Math.abs(am[8]), Math.abs(bm[8])) && Math.abs(am[9] - bm[9]) <= epsilon * Math.max(1, Math.abs(am[9]), Math.abs(bm[9])) && Math.abs(am[10] - bm[10]) <= epsilon * Math.max(1, Math.abs(am[10]), Math.abs(bm[10])) && Math.abs(am[11] - bm[11]) <= epsilon * Math.max(1, Math.abs(am[11]), Math.abs(bm[11])) && Math.abs(am[12] - bm[12]) <= epsilon * Math.max(1, Math.abs(am[12]), Math.abs(bm[12])) && Math.abs(am[13] - bm[13]) <= epsilon * Math.max(1, Math.abs(am[13]), Math.abs(bm[13])) && Math.abs(am[14] - bm[14]) <= epsilon * Math.max(1, Math.abs(am[14]), Math.abs(bm[14])) && Math.abs(am[15] - bm[15]) <= epsilon * Math.max(1, Math.abs(am[15]), Math.abs(bm[15])); + }; + Mat4.adjoint = function adjoint(out, a) { + var am = a.m, outm = out.m; + var a00 = am[0], a01 = am[1], a02 = am[2], a03 = am[3], a10 = am[4], a11 = am[5], a12 = am[6], a13 = am[7], a20 = am[8], a21 = am[9], a22 = am[10], a23 = am[11], a30 = am[12], a31 = am[13], a32 = am[14], a33 = am[15]; + outm[0] = a11 * (a22 * a33 - a23 * a32) - a21 * (a12 * a33 - a13 * a32) + a31 * (a12 * a23 - a13 * a22); + outm[1] = -(a01 * (a22 * a33 - a23 * a32) - a21 * (a02 * a33 - a03 * a32) + a31 * (a02 * a23 - a03 * a22)); + outm[2] = a01 * (a12 * a33 - a13 * a32) - a11 * (a02 * a33 - a03 * a32) + a31 * (a02 * a13 - a03 * a12); + outm[3] = -(a01 * (a12 * a23 - a13 * a22) - a11 * (a02 * a23 - a03 * a22) + a21 * (a02 * a13 - a03 * a12)); + outm[4] = -(a10 * (a22 * a33 - a23 * a32) - a20 * (a12 * a33 - a13 * a32) + a30 * (a12 * a23 - a13 * a22)); + outm[5] = a00 * (a22 * a33 - a23 * a32) - a20 * (a02 * a33 - a03 * a32) + a30 * (a02 * a23 - a03 * a22); + outm[6] = -(a00 * (a12 * a33 - a13 * a32) - a10 * (a02 * a33 - a03 * a32) + a30 * (a02 * a13 - a03 * a12)); + outm[7] = a00 * (a12 * a23 - a13 * a22) - a10 * (a02 * a23 - a03 * a22) + a20 * (a02 * a13 - a03 * a12); + outm[8] = a10 * (a21 * a33 - a23 * a31) - a20 * (a11 * a33 - a13 * a31) + a30 * (a11 * a23 - a13 * a21); + outm[9] = -(a00 * (a21 * a33 - a23 * a31) - a20 * (a01 * a33 - a03 * a31) + a30 * (a01 * a23 - a03 * a21)); + outm[10] = a00 * (a11 * a33 - a13 * a31) - a10 * (a01 * a33 - a03 * a31) + a30 * (a01 * a13 - a03 * a11); + outm[11] = -(a00 * (a11 * a23 - a13 * a21) - a10 * (a01 * a23 - a03 * a21) + a20 * (a01 * a13 - a03 * a11)); + outm[12] = -(a10 * (a21 * a32 - a22 * a31) - a20 * (a11 * a32 - a12 * a31) + a30 * (a11 * a22 - a12 * a21)); + outm[13] = a00 * (a21 * a32 - a22 * a31) - a20 * (a01 * a32 - a02 * a31) + a30 * (a01 * a22 - a02 * a21); + outm[14] = -(a00 * (a11 * a32 - a12 * a31) - a10 * (a01 * a32 - a02 * a31) + a30 * (a01 * a12 - a02 * a11)); + outm[15] = a00 * (a11 * a22 - a12 * a21) - a10 * (a01 * a22 - a02 * a21) + a20 * (a01 * a12 - a02 * a11); + return out; + }; + Mat4.toArray = function toArray(out, mat, ofs) { + void 0 === ofs && (ofs = 0); + var m = mat.m; + for (var i = 0; i < 16; i++) out[ofs + i] = m[i]; + return out; + }; + Mat4.fromArray = function fromArray(out, arr, ofs) { + void 0 === ofs && (ofs = 0); + var m = out.m; + for (var i = 0; i < 16; i++) m[i] = arr[ofs + i]; + return out; + }; + function Mat4(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) { + var _this; + void 0 === m00 && (m00 = 1); + void 0 === m01 && (m01 = 0); + void 0 === m02 && (m02 = 0); + void 0 === m03 && (m03 = 0); + void 0 === m10 && (m10 = 0); + void 0 === m11 && (m11 = 1); + void 0 === m12 && (m12 = 0); + void 0 === m13 && (m13 = 0); + void 0 === m20 && (m20 = 0); + void 0 === m21 && (m21 = 0); + void 0 === m22 && (m22 = 1); + void 0 === m23 && (m23 = 0); + void 0 === m30 && (m30 = 0); + void 0 === m31 && (m31 = 0); + void 0 === m32 && (m32 = 0); + void 0 === m33 && (m33 = 1); + _this = _ValueType.call(this) || this; + _this.m = void 0; + if (m00 instanceof _utils.FLOAT_ARRAY_TYPE) _this.m = m00; else { + _this.m = new _utils.FLOAT_ARRAY_TYPE(16); + var tm = _this.m; + tm[0] = m00; + tm[1] = m01; + tm[2] = m02; + tm[3] = m03; + tm[4] = m10; + tm[5] = m11; + tm[6] = m12; + tm[7] = m13; + tm[8] = m20; + tm[9] = m21; + tm[10] = m22; + tm[11] = m23; + tm[12] = m30; + tm[13] = m31; + tm[14] = m32; + tm[15] = m33; + } + return _this; + } + _proto.clone = function clone() { + var t = this; + var tm = t.m; + return new Mat4(tm[0], tm[1], tm[2], tm[3], tm[4], tm[5], tm[6], tm[7], tm[8], tm[9], tm[10], tm[11], tm[12], tm[13], tm[14], tm[15]); + }; + _proto.set = function set(s) { + var t = this; + var tm = t.m, sm = s.m; + tm[0] = sm[0]; + tm[1] = sm[1]; + tm[2] = sm[2]; + tm[3] = sm[3]; + tm[4] = sm[4]; + tm[5] = sm[5]; + tm[6] = sm[6]; + tm[7] = sm[7]; + tm[8] = sm[8]; + tm[9] = sm[9]; + tm[10] = sm[10]; + tm[11] = sm[11]; + tm[12] = sm[12]; + tm[13] = sm[13]; + tm[14] = sm[14]; + tm[15] = sm[15]; + return this; + }; + _proto.equals = function equals(other) { + return Mat4.strictEquals(this, other); + }; + _proto.fuzzyEquals = function fuzzyEquals(other) { + return Mat4.equals(this, other); + }; + _proto.toString = function toString() { + var tm = this.m; + return tm ? "[\n" + tm[0] + ", " + tm[1] + ", " + tm[2] + ", " + tm[3] + ",\n" + tm[4] + ", " + tm[5] + ", " + tm[6] + ", " + tm[7] + ",\n" + tm[8] + ", " + tm[9] + ", " + tm[10] + ", " + tm[11] + ",\n" + tm[12] + ", " + tm[13] + ", " + tm[14] + ", " + tm[15] + "\n]" : "[\n1, 0, 0, 0\n0, 1, 0, 0\n0, 0, 1, 0\n0, 0, 0, 1\n]"; + }; + _proto.identity = function identity() { + return Mat4.identity(this); + }; + _proto.transpose = function transpose(out) { + out = out || new Mat4(); + return Mat4.transpose(out, this); + }; + _proto.invert = function invert(out) { + out = out || new Mat4(); + return Mat4.invert(out, this); + }; + _proto.adjoint = function adjoint(out) { + out = out || new Mat4(); + return Mat4.adjoint(out, this); + }; + _proto.determinant = function determinant() { + return Mat4.determinant(this); + }; + _proto.add = function add(other, out) { + out = out || new Mat4(); + return Mat4.add(out, this, other); + }; + _proto.subtract = function subtract(other) { + return Mat4.subtract(this, this, other); + }; + _proto.multiply = function multiply(other) { + return Mat4.multiply(this, this, other); + }; + _proto.multiplyScalar = function multiplyScalar(number) { + return Mat4.multiplyScalar(this, this, number); + }; + _proto.translate = function translate(v, out) { + out = out || new Mat4(); + return Mat4.translate(out, this, v); + }; + _proto.scale = function scale(v, out) { + out = out || new Mat4(); + return Mat4.scale(out, this, v); + }; + _proto.rotate = function rotate(rad, axis, out) { + out = out || new Mat4(); + return Mat4.rotate(out, this, rad, axis); + }; + _proto.getTranslation = function getTranslation(out) { + out = out || new _vec["default"](); + return Mat4.getTranslation(out, this); + }; + _proto.getScale = function getScale(out) { + out = out || new _vec["default"](); + return Mat4.getScaling(out, this); + }; + _proto.getRotation = function getRotation(out) { + out = out || new _quat["default"](); + return Mat4.getRotation(out, this); + }; + _proto.fromRTS = function fromRTS(q, v, s) { + return Mat4.fromRTS(this, q, v, s); + }; + _proto.fromQuat = function fromQuat(quat) { + return Mat4.fromQuat(this, quat); + }; + return Mat4; + })(_valueType["default"]); + exports["default"] = Mat4; + Mat4.mul = Mat4.multiply; + Mat4.sub = Mat4.subtract; + Mat4.IDENTITY = Object.freeze(new Mat4()); + var v3_1 = new _vec["default"](); + var m3_1 = new _mat["default"](); + _CCClass["default"].fastDefine("cc.Mat4", Mat4, { + m00: 1, + m01: 0, + m02: 0, + m03: 0, + m04: 0, + m05: 1, + m06: 0, + m07: 0, + m08: 0, + m09: 0, + m10: 1, + m11: 0, + m12: 0, + m13: 0, + m14: 0, + m15: 1 + }); + var _loop = function _loop(i) { + Object.defineProperty(Mat4.prototype, "m" + i, { + get: function get() { + return this.m[i]; + }, + set: function set(value) { + this.m[i] = value; + } + }); + }; + for (var i = 0; i < 16; i++) _loop(i); + cc.mat4 = function(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) { + var mat = new Mat4(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33); + void 0 === m00 && Mat4.identity(mat); + return mat; + }; + cc.Mat4 = Mat4; + module.exports = exports["default"]; + }), { + "../platform/CCClass": 240, + "./mat3": 341, + "./quat": 343, + "./utils": 347, + "./value-type": 348, + "./vec3": 350 + } ], + 343: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _valueType = _interopRequireDefault(require("./value-type")); + var _CCClass = _interopRequireDefault(require("../platform/CCClass")); + var _vec = _interopRequireDefault(require("./vec3")); + var _mat = _interopRequireDefault(require("./mat3")); + var _utils = require("./utils"); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + _setPrototypeOf(subClass, superClass); + } + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + return _setPrototypeOf(o, p); + } + var _x = 0; + var _y = 0; + var _z = 0; + var _w = 0; + var Quat = (function(_ValueType) { + _inheritsLoose(Quat, _ValueType); + var _proto = Quat.prototype; + _proto.mul = function mul(other, out) { + return Quat.multiply(out || new Quat(), this, other); + }; + Quat.clone = function clone(a) { + return new Quat(a.x, a.y, a.z, a.w); + }; + Quat.copy = function copy(out, a) { + out.x = a.x; + out.y = a.y; + out.z = a.z; + out.w = a.w; + return out; + }; + Quat.set = function set(out, x, y, z, w) { + out.x = x; + out.y = y; + out.z = z; + out.w = w; + return out; + }; + Quat.identity = function identity(out) { + out.x = 0; + out.y = 0; + out.z = 0; + out.w = 1; + return out; + }; + Quat.rotationTo = function rotationTo(out, a, b) { + var dot = _vec["default"].dot(a, b); + if (dot < -.999999) { + _vec["default"].cross(v3_1, _vec["default"].RIGHT, a); + v3_1.mag() < 1e-6 && _vec["default"].cross(v3_1, _vec["default"].UP, a); + _vec["default"].normalize(v3_1, v3_1); + Quat.fromAxisAngle(out, v3_1, Math.PI); + return out; + } + if (dot > .999999) { + out.x = 0; + out.y = 0; + out.z = 0; + out.w = 1; + return out; + } + _vec["default"].cross(v3_1, a, b); + out.x = v3_1.x; + out.y = v3_1.y; + out.z = v3_1.z; + out.w = 1 + dot; + return Quat.normalize(out, out); + }; + Quat.getAxisAngle = function getAxisAngle(outAxis, q) { + var rad = 2 * Math.acos(q.w); + var s = Math.sin(rad / 2); + if (0 !== s) { + outAxis.x = q.x / s; + outAxis.y = q.y / s; + outAxis.z = q.z / s; + } else { + outAxis.x = 1; + outAxis.y = 0; + outAxis.z = 0; + } + return rad; + }; + Quat.multiply = function multiply(out, a, b) { + _x = a.x * b.w + a.w * b.x + a.y * b.z - a.z * b.y; + _y = a.y * b.w + a.w * b.y + a.z * b.x - a.x * b.z; + _z = a.z * b.w + a.w * b.z + a.x * b.y - a.y * b.x; + _w = a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z; + out.x = _x; + out.y = _y; + out.z = _z; + out.w = _w; + return out; + }; + Quat.multiplyScalar = function multiplyScalar(out, a, b) { + out.x = a.x * b; + out.y = a.y * b; + out.z = a.z * b; + out.w = a.w * b; + return out; + }; + Quat.scaleAndAdd = function scaleAndAdd(out, a, b, scale) { + out.x = a.x + b.x * scale; + out.y = a.y + b.y * scale; + out.z = a.z + b.z * scale; + out.w = a.w + b.w * scale; + return out; + }; + Quat.rotateX = function rotateX(out, a, rad) { + rad *= .5; + var bx = Math.sin(rad); + var bw = Math.cos(rad); + _x = a.x * bw + a.w * bx; + _y = a.y * bw + a.z * bx; + _z = a.z * bw - a.y * bx; + _w = a.w * bw - a.x * bx; + out.x = _x; + out.y = _y; + out.z = _z; + out.w = _w; + return out; + }; + Quat.rotateY = function rotateY(out, a, rad) { + rad *= .5; + var by = Math.sin(rad); + var bw = Math.cos(rad); + _x = a.x * bw - a.z * by; + _y = a.y * bw + a.w * by; + _z = a.z * bw + a.x * by; + _w = a.w * bw - a.y * by; + out.x = _x; + out.y = _y; + out.z = _z; + out.w = _w; + return out; + }; + Quat.rotateZ = function rotateZ(out, a, rad) { + rad *= .5; + var bz = Math.sin(rad); + var bw = Math.cos(rad); + _x = a.x * bw + a.y * bz; + _y = a.y * bw - a.x * bz; + _z = a.z * bw + a.w * bz; + _w = a.w * bw - a.z * bz; + out.x = _x; + out.y = _y; + out.z = _z; + out.w = _w; + return out; + }; + Quat.rotateAround = function rotateAround(out, rot, axis, rad) { + Quat.invert(qt_1, rot); + _vec["default"].transformQuat(v3_1, axis, qt_1); + Quat.fromAxisAngle(qt_1, v3_1, rad); + Quat.multiply(out, rot, qt_1); + return out; + }; + Quat.rotateAroundLocal = function rotateAroundLocal(out, rot, axis, rad) { + Quat.fromAxisAngle(qt_1, axis, rad); + Quat.multiply(out, rot, qt_1); + return out; + }; + Quat.calculateW = function calculateW(out, a) { + out.x = a.x; + out.y = a.y; + out.z = a.z; + out.w = Math.sqrt(Math.abs(1 - a.x * a.x - a.y * a.y - a.z * a.z)); + return out; + }; + Quat.dot = function dot(a, b) { + return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w; + }; + Quat.lerp = function lerp(out, a, b, t) { + out.x = a.x + t * (b.x - a.x); + out.y = a.y + t * (b.y - a.y); + out.z = a.z + t * (b.z - a.z); + out.w = a.w + t * (b.w - a.w); + return out; + }; + Quat.slerp = function slerp(out, a, b, t) { + var scale0 = 0; + var scale1 = 0; + var cosom = a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w; + if (cosom < 0) { + cosom = -cosom; + b.x = -b.x; + b.y = -b.y; + b.z = -b.z; + b.w = -b.w; + } + if (1 - cosom > 1e-6) { + var omega = Math.acos(cosom); + var sinom = Math.sin(omega); + scale0 = Math.sin((1 - t) * omega) / sinom; + scale1 = Math.sin(t * omega) / sinom; + } else { + scale0 = 1 - t; + scale1 = t; + } + out.x = scale0 * a.x + scale1 * b.x; + out.y = scale0 * a.y + scale1 * b.y; + out.z = scale0 * a.z + scale1 * b.z; + out.w = scale0 * a.w + scale1 * b.w; + return out; + }; + Quat.sqlerp = function sqlerp(out, a, b, c, d, t) { + Quat.slerp(qt_1, a, d, t); + Quat.slerp(qt_2, b, c, t); + Quat.slerp(out, qt_1, qt_2, 2 * t * (1 - t)); + return out; + }; + Quat.invert = function invert(out, a) { + var dot = a.x * a.x + a.y * a.y + a.z * a.z + a.w * a.w; + var invDot = dot ? 1 / dot : 0; + out.x = -a.x * invDot; + out.y = -a.y * invDot; + out.z = -a.z * invDot; + out.w = a.w * invDot; + return out; + }; + Quat.conjugate = function conjugate(out, a) { + out.x = -a.x; + out.y = -a.y; + out.z = -a.z; + out.w = a.w; + return out; + }; + Quat.len = function len(a) { + return Math.sqrt(a.x * a.x + a.y * a.y + a.z * a.z + a.w * a.w); + }; + Quat.lengthSqr = function lengthSqr(a) { + return a.x * a.x + a.y * a.y + a.z * a.z + a.w * a.w; + }; + Quat.normalize = function normalize(out, a) { + var len = a.x * a.x + a.y * a.y + a.z * a.z + a.w * a.w; + if (len > 0) { + len = 1 / Math.sqrt(len); + out.x = a.x * len; + out.y = a.y * len; + out.z = a.z * len; + out.w = a.w * len; + } + return out; + }; + Quat.fromAxes = function fromAxes(out, xAxis, yAxis, zAxis) { + _mat["default"].set(m3_1, xAxis.x, xAxis.y, xAxis.z, yAxis.x, yAxis.y, yAxis.z, zAxis.x, zAxis.y, zAxis.z); + return Quat.normalize(out, Quat.fromMat3(out, m3_1)); + }; + Quat.fromViewUp = function fromViewUp(out, view, up) { + _mat["default"].fromViewUp(m3_1, view, up); + return Quat.normalize(out, Quat.fromMat3(out, m3_1)); + }; + Quat.fromAxisAngle = function fromAxisAngle(out, axis, rad) { + rad *= .5; + var s = Math.sin(rad); + out.x = s * axis.x; + out.y = s * axis.y; + out.z = s * axis.z; + out.w = Math.cos(rad); + return out; + }; + Quat.fromAngleZ = function fromAngleZ(out, z) { + z *= halfToRad; + out.x = out.y = 0; + out.z = Math.sin(z); + out.w = Math.cos(z); + return out; + }; + Quat.fromMat3 = function fromMat3(out, mat) { + var m = mat.m; + var m00 = m[0], m10 = m[1], m20 = m[2], m01 = m[3], m11 = m[4], m21 = m[5], m02 = m[6], m12 = m[7], m22 = m[8]; + var trace = m00 + m11 + m22; + if (trace > 0) { + var s = .5 / Math.sqrt(trace + 1); + out.w = .25 / s; + out.x = (m21 - m12) * s; + out.y = (m02 - m20) * s; + out.z = (m10 - m01) * s; + } else if (m00 > m11 && m00 > m22) { + var _s = 2 * Math.sqrt(1 + m00 - m11 - m22); + out.w = (m21 - m12) / _s; + out.x = .25 * _s; + out.y = (m01 + m10) / _s; + out.z = (m02 + m20) / _s; + } else if (m11 > m22) { + var _s2 = 2 * Math.sqrt(1 + m11 - m00 - m22); + out.w = (m02 - m20) / _s2; + out.x = (m01 + m10) / _s2; + out.y = .25 * _s2; + out.z = (m12 + m21) / _s2; + } else { + var _s3 = 2 * Math.sqrt(1 + m22 - m00 - m11); + out.w = (m10 - m01) / _s3; + out.x = (m02 + m20) / _s3; + out.y = (m12 + m21) / _s3; + out.z = .25 * _s3; + } + return out; + }; + Quat.fromEuler = function fromEuler(out, x, y, z) { + x *= halfToRad; + y *= halfToRad; + z *= halfToRad; + var sx = Math.sin(x); + var cx = Math.cos(x); + var sy = Math.sin(y); + var cy = Math.cos(y); + var sz = Math.sin(z); + var cz = Math.cos(z); + out.x = sx * cy * cz + cx * sy * sz; + out.y = cx * sy * cz + sx * cy * sz; + out.z = cx * cy * sz - sx * sy * cz; + out.w = cx * cy * cz - sx * sy * sz; + return out; + }; + Quat.toAxisX = function toAxisX(out, q) { + var fy = 2 * q.y; + var fz = 2 * q.z; + out.x = 1 - fy * q.y - fz * q.z; + out.y = fy * q.x + fz * q.w; + out.z = fz * q.x + fy * q.w; + return out; + }; + Quat.toAxisY = function toAxisY(out, q) { + var fx = 2 * q.x; + var fy = 2 * q.y; + var fz = 2 * q.z; + out.x = fy * q.x - fz * q.w; + out.y = 1 - fx * q.x - fz * q.z; + out.z = fz * q.y + fx * q.w; + return out; + }; + Quat.toAxisZ = function toAxisZ(out, q) { + var fx = 2 * q.x; + var fy = 2 * q.y; + var fz = 2 * q.z; + out.x = fz * q.x - fy * q.w; + out.y = fz * q.y - fx * q.w; + out.z = 1 - fx * q.x - fy * q.y; + return out; + }; + Quat.toEuler = function toEuler(out, q, outerZ) { + var x = q.x, y = q.y, z = q.z, w = q.w; + var bank = 0; + var heading = 0; + var attitude = 0; + var test = x * y + z * w; + if (test > .499999) { + bank = 0; + heading = (0, _utils.toDegree)(2 * Math.atan2(x, w)); + attitude = 90; + } else if (test < -.499999) { + bank = 0; + heading = -(0, _utils.toDegree)(2 * Math.atan2(x, w)); + attitude = -90; + } else { + var sqx = x * x; + var sqy = y * y; + var sqz = z * z; + bank = (0, _utils.toDegree)(Math.atan2(2 * x * w - 2 * y * z, 1 - 2 * sqx - 2 * sqz)); + heading = (0, _utils.toDegree)(Math.atan2(2 * y * w - 2 * x * z, 1 - 2 * sqy - 2 * sqz)); + attitude = (0, _utils.toDegree)(Math.asin(2 * test)); + if (outerZ) { + bank = -180 * Math.sign(bank + 1e-6) + bank; + heading = -180 * Math.sign(heading + 1e-6) + heading; + attitude = 180 * Math.sign(attitude + 1e-6) - attitude; + } + } + out.x = bank; + out.y = heading; + out.z = attitude; + return out; + }; + Quat.strictEquals = function strictEquals(a, b) { + return a.x === b.x && a.y === b.y && a.z === b.z && a.w === b.w; + }; + Quat.equals = function equals(a, b, epsilon) { + void 0 === epsilon && (epsilon = _utils.EPSILON); + return Math.abs(a.x - b.x) <= epsilon * Math.max(1, Math.abs(a.x), Math.abs(b.x)) && Math.abs(a.y - b.y) <= epsilon * Math.max(1, Math.abs(a.y), Math.abs(b.y)) && Math.abs(a.z - b.z) <= epsilon * Math.max(1, Math.abs(a.z), Math.abs(b.z)) && Math.abs(a.w - b.w) <= epsilon * Math.max(1, Math.abs(a.w), Math.abs(b.w)); + }; + Quat.toArray = function toArray(out, q, ofs) { + void 0 === ofs && (ofs = 0); + out[ofs + 0] = q.x; + out[ofs + 1] = q.y; + out[ofs + 2] = q.z; + out[ofs + 3] = q.w; + return out; + }; + Quat.fromArray = function fromArray(out, arr, ofs) { + void 0 === ofs && (ofs = 0); + out.x = arr[ofs + 0]; + out.y = arr[ofs + 1]; + out.z = arr[ofs + 2]; + out.w = arr[ofs + 3]; + return out; + }; + function Quat(x, y, z, w) { + var _this; + void 0 === x && (x = 0); + void 0 === y && (y = 0); + void 0 === z && (z = 0); + void 0 === w && (w = 1); + _this = _ValueType.call(this) || this; + _this.x = void 0; + _this.y = void 0; + _this.z = void 0; + _this.w = void 0; + if (x && "object" === typeof x) { + _this.x = x.x; + _this.y = x.y; + _this.z = x.z; + _this.w = x.w; + } else { + _this.x = x; + _this.y = y; + _this.z = z; + _this.w = w; + } + return _this; + } + _proto.clone = function clone() { + return new Quat(this.x, this.y, this.z, this.w); + }; + _proto.set = function set(newValue) { + this.x = newValue.x; + this.y = newValue.y; + this.z = newValue.z; + this.w = newValue.w; + return this; + }; + _proto.equals = function equals(other) { + return other && this.x === other.x && this.y === other.y && this.z === other.z && this.w === other.w; + }; + _proto.toEuler = function toEuler(out) { + return Quat.toEuler(out, this); + }; + _proto.fromEuler = function fromEuler(euler) { + return Quat.fromEuler(this, euler.x, euler.y, euler.z); + }; + _proto.lerp = function lerp(to, ratio, out) { + out = out || new Quat(); + Quat.slerp(out, this, to, ratio); + return out; + }; + _proto.multiply = function multiply(other) { + return Quat.multiply(this, this, other); + }; + _proto.rotateAround = function rotateAround(rot, axis, rad, out) { + out = out || new Quat(); + return Quat.rotateAround(out, rot, axis, rad); + }; + return Quat; + })(_valueType["default"]); + exports["default"] = Quat; + Quat.mul = Quat.multiply; + Quat.scale = Quat.multiplyScalar; + Quat.mag = Quat.len; + Quat.IDENTITY = Object.freeze(new Quat()); + var qt_1 = new Quat(); + var qt_2 = new Quat(); + var v3_1 = new _vec["default"](); + var m3_1 = new _mat["default"](); + var halfToRad = .5 * Math.PI / 180; + _CCClass["default"].fastDefine("cc.Quat", Quat, { + x: 0, + y: 0, + z: 0, + w: 1 + }); + cc.quat = function quat(x, y, z, w) { + return new Quat(x, y, z, w); + }; + cc.Quat = Quat; + module.exports = exports["default"]; + }), { + "../platform/CCClass": 240, + "./mat3": 341, + "./utils": 347, + "./value-type": 348, + "./vec3": 350 + } ], + 344: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _valueType = _interopRequireDefault(require("./value-type")); + var _CCClass = _interopRequireDefault(require("../platform/CCClass")); + var _vec = _interopRequireDefault(require("./vec2")); + var _size = _interopRequireDefault(require("./size")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + "value" in descriptor && (descriptor.writable = true); + Object.defineProperty(target, descriptor.key, descriptor); + } + } + function _createClass(Constructor, protoProps, staticProps) { + protoProps && _defineProperties(Constructor.prototype, protoProps); + staticProps && _defineProperties(Constructor, staticProps); + return Constructor; + } + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + _setPrototypeOf(subClass, superClass); + } + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + return _setPrototypeOf(o, p); + } + var Rect = (function(_ValueType) { + _inheritsLoose(Rect, _ValueType); + Rect.fromMinMax = function fromMinMax(v1, v2) { + var min_x = Math.min(v1.x, v2.x); + var min_y = Math.min(v1.y, v2.y); + var max_x = Math.max(v1.x, v2.x); + var max_y = Math.max(v1.y, v2.y); + return new Rect(min_x, min_y, max_x - min_x, max_y - min_y); + }; + function Rect(x, y, w, h) { + var _this; + void 0 === x && (x = 0); + void 0 === y && (y = 0); + void 0 === w && (w = 0); + void 0 === h && (h = 0); + _this = _ValueType.call(this) || this; + _this.x = void 0; + _this.y = void 0; + _this.width = void 0; + _this.height = void 0; + if (x && "object" === typeof x) { + y = x.y; + w = x.width; + h = x.height; + x = x.x; + } + _this.x = x || 0; + _this.y = y || 0; + _this.width = w || 0; + _this.height = h || 0; + return _this; + } + var _proto = Rect.prototype; + _proto.clone = function clone() { + return new Rect(this.x, this.y, this.width, this.height); + }; + _proto.equals = function equals(other) { + return other && this.x === other.x && this.y === other.y && this.width === other.width && this.height === other.height; + }; + _proto.lerp = function lerp(to, ratio, out) { + out = out || new Rect(); + var x = this.x; + var y = this.y; + var width = this.width; + var height = this.height; + out.x = x + (to.x - x) * ratio; + out.y = y + (to.y - y) * ratio; + out.width = width + (to.width - width) * ratio; + out.height = height + (to.height - height) * ratio; + return out; + }; + _proto.set = function set(source) { + this.x = source.x; + this.y = source.y; + this.width = source.width; + this.height = source.height; + return this; + }; + _proto.intersects = function intersects(rect) { + var maxax = this.x + this.width, maxay = this.y + this.height, maxbx = rect.x + rect.width, maxby = rect.y + rect.height; + return !(maxax < rect.x || maxbx < this.x || maxay < rect.y || maxby < this.y); + }; + _proto.intersection = function intersection(out, rectB) { + var axMin = this.x, ayMin = this.y, axMax = this.x + this.width, ayMax = this.y + this.height; + var bxMin = rectB.x, byMin = rectB.y, bxMax = rectB.x + rectB.width, byMax = rectB.y + rectB.height; + out.x = Math.max(axMin, bxMin); + out.y = Math.max(ayMin, byMin); + out.width = Math.min(axMax, bxMax) - out.x; + out.height = Math.min(ayMax, byMax) - out.y; + return out; + }; + _proto.contains = function contains(point) { + return this.x <= point.x && this.x + this.width >= point.x && this.y <= point.y && this.y + this.height >= point.y; + }; + _proto.containsRect = function containsRect(rect) { + return this.x <= rect.x && this.x + this.width >= rect.x + rect.width && this.y <= rect.y && this.y + this.height >= rect.y + rect.height; + }; + _proto.union = function union(out, rectB) { + var ax = this.x, ay = this.y, aw = this.width, ah = this.height; + var bx = rectB.x, by = rectB.y, bw = rectB.width, bh = rectB.height; + out.x = Math.min(ax, bx); + out.y = Math.min(ay, by); + out.width = Math.max(ax + aw, bx + bw) - out.x; + out.height = Math.max(ay + ah, by + bh) - out.y; + return out; + }; + _proto.transformMat4 = function transformMat4(out, mat) { + var ol = this.x; + var ob = this.y; + var or = ol + this.width; + var ot = ob + this.height; + var matm = mat.m; + var lbx = matm[0] * ol + matm[4] * ob + matm[12]; + var lby = matm[1] * ol + matm[5] * ob + matm[13]; + var rbx = matm[0] * or + matm[4] * ob + matm[12]; + var rby = matm[1] * or + matm[5] * ob + matm[13]; + var ltx = matm[0] * ol + matm[4] * ot + matm[12]; + var lty = matm[1] * ol + matm[5] * ot + matm[13]; + var rtx = matm[0] * or + matm[4] * ot + matm[12]; + var rty = matm[1] * or + matm[5] * ot + matm[13]; + var minX = Math.min(lbx, rbx, ltx, rtx); + var maxX = Math.max(lbx, rbx, ltx, rtx); + var minY = Math.min(lby, rby, lty, rty); + var maxY = Math.max(lby, rby, lty, rty); + out.x = minX; + out.y = minY; + out.width = maxX - minX; + out.height = maxY - minY; + return out; + }; + _proto.toString = function toString() { + return "(" + this.x.toFixed(2) + ", " + this.y.toFixed(2) + ", " + this.width.toFixed(2) + ", " + this.height.toFixed(2) + ")"; + }; + _createClass(Rect, [ { + key: "xMin", + get: function get() { + return this.x; + }, + set: function set(v) { + this.width += this.x - v; + this.x = v; + } + }, { + key: "yMin", + get: function get() { + return this.y; + }, + set: function set(v) { + this.height += this.y - v; + this.y = v; + } + }, { + key: "xMax", + get: function get() { + return this.x + this.width; + }, + set: function set(value) { + this.width = value - this.x; + } + }, { + key: "yMax", + get: function get() { + return this.y + this.height; + }, + set: function set(value) { + this.height = value - this.y; + } + }, { + key: "center", + get: function get() { + return new _vec["default"](this.x + .5 * this.width, this.y + .5 * this.height); + }, + set: function set(value) { + this.x = value.x - .5 * this.width; + this.y = value.y - .5 * this.height; + } + }, { + key: "origin", + get: function get() { + return new _vec["default"](this.x, this.y); + }, + set: function set(value) { + this.x = value.x; + this.y = value.y; + } + }, { + key: "size", + get: function get() { + return new _size["default"](this.width, this.height); + }, + set: function set(value) { + this.width = value.width; + this.height = value.height; + } + } ]); + return Rect; + })(_valueType["default"]); + exports["default"] = Rect; + _CCClass["default"].fastDefine("cc.Rect", Rect, { + x: 0, + y: 0, + width: 0, + height: 0 + }); + cc.Rect = Rect; + cc.rect = function rect(x, y, w, h) { + return new Rect(x, y, w, h); + }; + module.exports = exports["default"]; + }), { + "../platform/CCClass": 240, + "./size": 345, + "./value-type": 348, + "./vec2": 349 + } ], + 345: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _valueType = _interopRequireDefault(require("./value-type")); + var _CCClass = _interopRequireDefault(require("../platform/CCClass")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + "value" in descriptor && (descriptor.writable = true); + Object.defineProperty(target, descriptor.key, descriptor); + } + } + function _createClass(Constructor, protoProps, staticProps) { + protoProps && _defineProperties(Constructor.prototype, protoProps); + staticProps && _defineProperties(Constructor, staticProps); + return Constructor; + } + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + _setPrototypeOf(subClass, superClass); + } + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + return _setPrototypeOf(o, p); + } + var Size = (function(_ValueType) { + _inheritsLoose(Size, _ValueType); + function Size(width, height) { + var _this; + void 0 === width && (width = 0); + void 0 === height && (height = 0); + _this = _ValueType.call(this) || this; + _this.width = void 0; + _this.height = void 0; + if (width && "object" === typeof width) { + _this.width = width.width; + _this.height = width.height; + } else { + _this.width = width || 0; + _this.height = height || 0; + } + return _this; + } + var _proto = Size.prototype; + _proto.clone = function clone() { + return new Size(this.width, this.height); + }; + _proto.equals = function equals(other) { + return other && this.width === other.width && this.height === other.height; + }; + _proto.lerp = function lerp(to, ratio, out) { + out = out || new Size(); + var width = this.width; + var height = this.height; + out.width = width + (to.width - width) * ratio; + out.height = height + (to.height - height) * ratio; + return out; + }; + _proto.set = function set(source) { + this.width = source.width; + this.height = source.height; + return this; + }; + _proto.toString = function toString() { + return "(" + this.width.toFixed(2) + ", " + this.height.toFixed(2) + ")"; + }; + _createClass(Size, null, [ { + key: "ZERO", + get: function get() { + return new Size(); + } + } ]); + return Size; + })(_valueType["default"]); + exports["default"] = Size; + Size.ZERO_R = Size.ZERO; + _CCClass["default"].fastDefine("cc.Size", Size, { + width: 0, + height: 0 + }); + cc.size = function(w, h) { + return new Size(w, h); + }; + cc.Size = Size; + module.exports = exports["default"]; + }), { + "../platform/CCClass": 240, + "./value-type": 348 + } ], + 346: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _quat = _interopRequireDefault(require("./quat")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + var tmp_quat = new _quat["default"](); + var Trs = (function() { + function Trs() {} + Trs.toRotation = function toRotation(out, a) { + out.x = a[3]; + out.y = a[4]; + out.z = a[5]; + out.w = a[6]; + return out; + }; + Trs.fromRotation = function fromRotation(out, a) { + out[3] = a.x; + out[4] = a.y; + out[5] = a.z; + out[6] = a.w; + return out; + }; + Trs.toEuler = function toEuler(out, a) { + Trs.toRotation(tmp_quat, a); + _quat["default"].toEuler(out, tmp_quat); + return out; + }; + Trs.fromEuler = function fromEuler(out, a) { + _quat["default"].fromEuler(tmp_quat, a.x, a.y, a.z); + Trs.fromRotation(out, tmp_quat); + return out; + }; + Trs.fromEulerNumber = function fromEulerNumber(out, x, y, z) { + _quat["default"].fromEuler(tmp_quat, x, y, z); + Trs.fromRotation(out, tmp_quat); + return out; + }; + Trs.toScale = function toScale(out, a) { + out.x = a[7]; + out.y = a[8]; + out.z = a[9]; + return out; + }; + Trs.fromScale = function fromScale(out, a) { + out[7] = a.x; + out[8] = a.y; + out[9] = a.z; + return out; + }; + Trs.toPosition = function toPosition(out, a) { + out.x = a[0]; + out.y = a[1]; + out.z = a[2]; + return out; + }; + Trs.fromPosition = function fromPosition(out, a) { + out[0] = a.x; + out[1] = a.y; + out[2] = a.z; + return out; + }; + Trs.fromAngleZ = function fromAngleZ(out, a) { + _quat["default"].fromAngleZ(tmp_quat, a); + Trs.fromRotation(out, tmp_quat); + return out; + }; + Trs.toMat4 = function toMat4(out, trs) { + var x = trs[3], y = trs[4], z = trs[5], w = trs[6]; + var x2 = x + x; + var y2 = y + y; + var z2 = z + z; + var xx = x * x2; + var xy = x * y2; + var xz = x * z2; + var yy = y * y2; + var yz = y * z2; + var zz = z * z2; + var wx = w * x2; + var wy = w * y2; + var wz = w * z2; + var sx = trs[7]; + var sy = trs[8]; + var sz = trs[9]; + var m = out.m; + m[0] = (1 - (yy + zz)) * sx; + m[1] = (xy + wz) * sx; + m[2] = (xz - wy) * sx; + m[3] = 0; + m[4] = (xy - wz) * sy; + m[5] = (1 - (xx + zz)) * sy; + m[6] = (yz + wx) * sy; + m[7] = 0; + m[8] = (xz + wy) * sz; + m[9] = (yz - wx) * sz; + m[10] = (1 - (xx + yy)) * sz; + m[11] = 0; + m[12] = trs[0]; + m[13] = trs[1]; + m[14] = trs[2]; + m[15] = 1; + return out; + }; + return Trs; + })(); + exports["default"] = Trs; + cc.Trs = Trs; + module.exports = exports["default"]; + }), { + "./quat": 343 + } ], + 347: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports.INT_MIN = exports.INT_MAX = exports.INT_BITS = exports.FLOAT_BYTES = exports.FLOAT_ARRAY_TYPE = exports.EPSILON = void 0; + exports.approx = approx; + exports.clamp = clamp; + exports.clamp01 = clamp01; + exports.equals = equals; + exports.inverseLerp = inverseLerp; + exports.lerp = lerp; + exports.nextPow2 = nextPow2; + exports.pingPong = pingPong; + exports.pseudoRandom = pseudoRandom; + exports.pseudoRandomRange = pseudoRandomRange; + exports.pseudoRandomRangeInt = pseudoRandomRangeInt; + exports.random = void 0; + exports.randomRange = randomRange; + exports.randomRangeInt = randomRangeInt; + exports.repeat = repeat; + exports.sign = sign; + exports.toDegree = toDegree; + exports.toRadian = toRadian; + var _d2r = Math.PI / 180; + var _r2d = 180 / Math.PI; + var EPSILON = 1e-6; + exports.EPSILON = EPSILON; + var INT_BITS = 32; + exports.INT_BITS = INT_BITS; + var INT_MAX = 2147483647; + exports.INT_MAX = INT_MAX; + var INT_MIN = -1 << INT_BITS - 1; + exports.INT_MIN = INT_MIN; + var FLOAT_ARRAY_TYPE = Float64Array; + exports.FLOAT_ARRAY_TYPE = FLOAT_ARRAY_TYPE; + var FLOAT_BYTES = 8; + exports.FLOAT_BYTES = FLOAT_BYTES; + function equals(a, b) { + return Math.abs(a - b) <= EPSILON * Math.max(1, Math.abs(a), Math.abs(b)); + } + function approx(a, b, maxDiff) { + maxDiff = maxDiff || EPSILON; + return Math.abs(a - b) <= maxDiff; + } + function clamp(val, min, max) { + return val < min ? min : val > max ? max : val; + } + function clamp01(val) { + return val < 0 ? 0 : val > 1 ? 1 : val; + } + function lerp(from, to, ratio) { + return from + (to - from) * ratio; + } + function toRadian(a) { + return a * _d2r; + } + function toDegree(a) { + return a * _r2d; + } + var random = Math.random; + exports.random = random; + function randomRange(min, max) { + return Math.random() * (max - min) + min; + } + function randomRangeInt(min, max) { + return Math.floor(randomRange(min, max)); + } + function pseudoRandom(seed) { + seed = (9301 * seed + 49297) % 233280; + return seed / 233280; + } + function pseudoRandomRange(seed, min, max) { + return pseudoRandom(seed) * (max - min) + min; + } + function pseudoRandomRangeInt(seed, min, max) { + return Math.floor(pseudoRandomRange(seed, min, max)); + } + function nextPow2(val) { + --val; + val |= val >> 1; + val |= val >> 2; + val |= val >> 4; + val |= val >> 8; + val |= val >> 16; + ++val; + return val; + } + function repeat(t, length) { + return t - Math.floor(t / length) * length; + } + function pingPong(t, length) { + t = repeat(t, 2 * length); + t = length - Math.abs(t - length); + return t; + } + function inverseLerp(from, to, value) { + return (value - from) / (to - from); + } + function sign(v) { + return (v > 0) - (v < 0); + } + }), {} ], + 348: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _js = _interopRequireDefault(require("../platform/js")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + var ValueType = (function() { + function ValueType() {} + var _proto = ValueType.prototype; + _proto.clone = function clone() { + cc.errorID("0100", _js["default"].getClassName(this) + ".clone"); + return null; + }; + _proto.equals = function equals(other) { + cc.errorID("0100", _js["default"].getClassName(this) + ".equals"); + return false; + }; + _proto.lerp = function lerp(to, ratio) { + cc.errorID("0100", _js["default"].getClassName(this) + ".lerp"); + return this.clone(); + }; + _proto.set = function set(source) { + cc.errorID("0100", _js["default"].getClassName(this) + ".set"); + }; + _proto.toString = function toString() { + return "" + {}; + }; + return ValueType; + })(); + exports["default"] = ValueType; + _js["default"].setClassName("cc.ValueType", ValueType); + cc.ValueType = ValueType; + module.exports = exports["default"]; + }), { + "../platform/js": 261 + } ], + 349: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _valueType = _interopRequireDefault(require("./value-type")); + var _CCClass = _interopRequireDefault(require("../platform/CCClass")); + var _misc = _interopRequireDefault(require("../utils/misc")); + var _utils = require("./utils"); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + "value" in descriptor && (descriptor.writable = true); + Object.defineProperty(target, descriptor.key, descriptor); + } + } + function _createClass(Constructor, protoProps, staticProps) { + protoProps && _defineProperties(Constructor.prototype, protoProps); + staticProps && _defineProperties(Constructor, staticProps); + return Constructor; + } + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + _setPrototypeOf(subClass, superClass); + } + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + return _setPrototypeOf(o, p); + } + var _x = 0; + var _y = 0; + var Vec2 = (function(_ValueType) { + _inheritsLoose(Vec2, _ValueType); + var _proto = Vec2.prototype; + _proto.sub = function sub(vector, out) { + return Vec2.subtract(out || new Vec2(), this, vector); + }; + _proto.mul = function mul(num, out) { + return Vec2.multiplyScalar(out || new Vec2(), this, num); + }; + _proto.div = function div(num, out) { + return Vec2.multiplyScalar(out || new Vec2(), this, 1 / num); + }; + _proto.scale = function scale(vector, out) { + return Vec2.multiply(out || new Vec2(), this, vector); + }; + _proto.neg = function neg(out) { + return Vec2.negate(out || new Vec2(), this); + }; + Vec2.clone = function clone(a) { + return new Vec2(a.x, a.y); + }; + Vec2.copy = function copy(out, a) { + out.x = a.x; + out.y = a.y; + return out; + }; + Vec2.set = function set(out, x, y) { + out.x = x; + out.y = y; + return out; + }; + Vec2.add = function add(out, a, b) { + out.x = a.x + b.x; + out.y = a.y + b.y; + return out; + }; + Vec2.subtract = function subtract(out, a, b) { + out.x = a.x - b.x; + out.y = a.y - b.y; + return out; + }; + Vec2.multiply = function multiply(out, a, b) { + out.x = a.x * b.x; + out.y = a.y * b.y; + return out; + }; + Vec2.divide = function divide(out, a, b) { + out.x = a.x / b.x; + out.y = a.y / b.y; + return out; + }; + Vec2.ceil = function ceil(out, a) { + out.x = Math.ceil(a.x); + out.y = Math.ceil(a.y); + return out; + }; + Vec2.floor = function floor(out, a) { + out.x = Math.floor(a.x); + out.y = Math.floor(a.y); + return out; + }; + Vec2.min = function min(out, a, b) { + out.x = Math.min(a.x, b.x); + out.y = Math.min(a.y, b.y); + return out; + }; + Vec2.max = function max(out, a, b) { + out.x = Math.max(a.x, b.x); + out.y = Math.max(a.y, b.y); + return out; + }; + Vec2.round = function round(out, a) { + out.x = Math.round(a.x); + out.y = Math.round(a.y); + return out; + }; + Vec2.multiplyScalar = function multiplyScalar(out, a, b) { + out.x = a.x * b; + out.y = a.y * b; + return out; + }; + Vec2.scaleAndAdd = function scaleAndAdd(out, a, b, scale) { + out.x = a.x + b.x * scale; + out.y = a.y + b.y * scale; + return out; + }; + Vec2.distance = function distance(a, b) { + _x = b.x - a.x; + _y = b.y - a.y; + return Math.sqrt(_x * _x + _y * _y); + }; + Vec2.squaredDistance = function squaredDistance(a, b) { + _x = b.x - a.x; + _y = b.y - a.y; + return _x * _x + _y * _y; + }; + Vec2.len = function len(a) { + _x = a.x; + _y = a.y; + return Math.sqrt(_x * _x + _y * _y); + }; + Vec2.lengthSqr = function lengthSqr(a) { + _x = a.x; + _y = a.y; + return _x * _x + _y * _y; + }; + Vec2.negate = function negate(out, a) { + out.x = -a.x; + out.y = -a.y; + return out; + }; + Vec2.inverse = function inverse(out, a) { + out.x = 1 / a.x; + out.y = 1 / a.y; + return out; + }; + Vec2.inverseSafe = function inverseSafe(out, a) { + _x = a.x; + _y = a.y; + Math.abs(_x) < _utils.EPSILON ? out.x = 0 : out.x = 1 / _x; + Math.abs(_y) < _utils.EPSILON ? out.y = 0 : out.y = 1 / _y; + return out; + }; + Vec2.normalize = function normalize(out, a) { + _x = a.x; + _y = a.y; + var len = _x * _x + _y * _y; + if (len > 0) { + len = 1 / Math.sqrt(len); + out.x = _x * len; + out.y = _y * len; + } + return out; + }; + Vec2.dot = function dot(a, b) { + return a.x * b.x + a.y * b.y; + }; + Vec2.cross = function cross(out, a, b) { + out.x = out.y = 0; + out.z = a.x * b.y - a.y * b.x; + return out; + }; + Vec2.lerp = function lerp(out, a, b, t) { + _x = a.x; + _y = a.y; + out.x = _x + t * (b.x - _x); + out.y = _y + t * (b.y - _y); + return out; + }; + Vec2.random = function random(out, scale) { + scale = scale || 1; + var r = 2 * (0, _utils.random)() * Math.PI; + out.x = Math.cos(r) * scale; + out.y = Math.sin(r) * scale; + return out; + }; + Vec2.transformMat3 = function transformMat3(out, a, mat) { + _x = a.x; + _y = a.y; + var m = mat.m; + out.x = m[0] * _x + m[3] * _y + m[6]; + out.y = m[1] * _x + m[4] * _y + m[7]; + return out; + }; + Vec2.transformMat4 = function transformMat4(out, a, mat) { + _x = a.x; + _y = a.y; + var m = mat.m; + out.x = m[0] * _x + m[4] * _y + m[12]; + out.y = m[1] * _x + m[5] * _y + m[13]; + return out; + }; + Vec2.strictEquals = function strictEquals(a, b) { + return a.x === b.x && a.y === b.y; + }; + Vec2.equals = function equals(a, b, epsilon) { + void 0 === epsilon && (epsilon = _utils.EPSILON); + return Math.abs(a.x - b.x) <= epsilon * Math.max(1, Math.abs(a.x), Math.abs(b.x)) && Math.abs(a.y - b.y) <= epsilon * Math.max(1, Math.abs(a.y), Math.abs(b.y)); + }; + Vec2.angle = function angle(a, b) { + Vec2.normalize(v2_1, a); + Vec2.normalize(v2_2, b); + var cosine = Vec2.dot(v2_1, v2_2); + if (cosine > 1) return 0; + if (cosine < -1) return Math.PI; + return Math.acos(cosine); + }; + Vec2.toArray = function toArray(out, v, ofs) { + void 0 === ofs && (ofs = 0); + out[ofs + 0] = v.x; + out[ofs + 1] = v.y; + return out; + }; + Vec2.fromArray = function fromArray(out, arr, ofs) { + void 0 === ofs && (ofs = 0); + out.x = arr[ofs + 0]; + out.y = arr[ofs + 1]; + return out; + }; + function Vec2(x, y) { + var _this; + void 0 === x && (x = 0); + void 0 === y && (y = 0); + _this = _ValueType.call(this) || this; + _this.mag = Vec2.prototype.len; + _this.magSqr = Vec2.prototype.lengthSqr; + _this.subSelf = Vec2.prototype.subtract; + _this.mulSelf = Vec2.prototype.multiplyScalar; + _this.divSelf = Vec2.prototype.divide; + _this.scaleSelf = Vec2.prototype.multiply; + _this.negSelf = Vec2.prototype.negate; + _this.x = void 0; + _this.y = void 0; + _this.z = 0; + if (x && "object" === typeof x) { + _this.x = x.x || 0; + _this.y = x.y || 0; + } else { + _this.x = x || 0; + _this.y = y || 0; + } + return _this; + } + _proto.clone = function clone() { + return new Vec2(this.x, this.y); + }; + _proto.set = function set(newValue) { + this.x = newValue.x; + this.y = newValue.y; + return this; + }; + _proto.equals = function equals(other) { + return other && this.x === other.x && this.y === other.y; + }; + _proto.fuzzyEquals = function fuzzyEquals(other, variance) { + if (this.x - variance <= other.x && other.x <= this.x + variance && this.y - variance <= other.y && other.y <= this.y + variance) return true; + return false; + }; + _proto.toString = function toString() { + return "(" + this.x.toFixed(2) + ", " + this.y.toFixed(2) + ")"; + }; + _proto.lerp = function lerp(to, ratio, out) { + out = out || new Vec2(); + var x = this.x; + var y = this.y; + out.x = x + (to.x - x) * ratio; + out.y = y + (to.y - y) * ratio; + return out; + }; + _proto.clampf = function clampf(min_inclusive, max_inclusive) { + this.x = _misc["default"].clampf(this.x, min_inclusive.x, max_inclusive.x); + this.y = _misc["default"].clampf(this.y, min_inclusive.y, max_inclusive.y); + return this; + }; + _proto.add = function add(vector, out) { + out = out || new Vec2(); + out.x = this.x + vector.x; + out.y = this.y + vector.y; + return out; + }; + _proto.addSelf = function addSelf(vector) { + this.x += vector.x; + this.y += vector.y; + return this; + }; + _proto.subtract = function subtract(vector) { + this.x -= vector.x; + this.y -= vector.y; + return this; + }; + _proto.multiplyScalar = function multiplyScalar(num) { + this.x *= num; + this.y *= num; + return this; + }; + _proto.multiply = function multiply(vector) { + this.x *= vector.x; + this.y *= vector.y; + return this; + }; + _proto.divide = function divide(num) { + this.x /= num; + this.y /= num; + return this; + }; + _proto.negate = function negate() { + this.x = -this.x; + this.y = -this.y; + return this; + }; + _proto.dot = function dot(vector) { + return this.x * vector.x + this.y * vector.y; + }; + _proto.cross = function cross(vector) { + return this.x * vector.y - this.y * vector.x; + }; + _proto.len = function len() { + return Math.sqrt(this.x * this.x + this.y * this.y); + }; + _proto.lengthSqr = function lengthSqr() { + return this.x * this.x + this.y * this.y; + }; + _proto.normalizeSelf = function normalizeSelf() { + var magSqr = this.x * this.x + this.y * this.y; + if (1 === magSqr) return this; + if (0 === magSqr) return this; + var invsqrt = 1 / Math.sqrt(magSqr); + this.x *= invsqrt; + this.y *= invsqrt; + return this; + }; + _proto.normalize = function normalize(out) { + out = out || new Vec2(); + out.x = this.x; + out.y = this.y; + out.normalizeSelf(); + return out; + }; + _proto.angle = function angle(vector) { + var magSqr1 = this.magSqr(); + var magSqr2 = vector.magSqr(); + if (0 === magSqr1 || 0 === magSqr2) { + console.warn("Can't get angle between zero vector"); + return 0; + } + var dot = this.dot(vector); + var theta = dot / Math.sqrt(magSqr1 * magSqr2); + theta = _misc["default"].clampf(theta, -1, 1); + return Math.acos(theta); + }; + _proto.signAngle = function signAngle(vector) { + var angle = this.angle(vector); + return this.cross(vector) < 0 ? -angle : angle; + }; + _proto.rotate = function rotate(radians, out) { + out = out || new Vec2(); + out.x = this.x; + out.y = this.y; + return out.rotateSelf(radians); + }; + _proto.rotateSelf = function rotateSelf(radians) { + var sin = Math.sin(radians); + var cos = Math.cos(radians); + var x = this.x; + this.x = cos * x - sin * this.y; + this.y = sin * x + cos * this.y; + return this; + }; + _proto.project = function project(vector) { + return vector.multiplyScalar(this.dot(vector) / vector.dot(vector)); + }; + _proto.transformMat4 = function transformMat4(m, out) { + out = out || new Vec2(); + Vec2.transformMat4(out, this, m); + return out; + }; + _proto.maxAxis = function maxAxis() { + return Math.max(this.x, this.y); + }; + _createClass(Vec2, null, [ { + key: "ONE", + get: function get() { + return new Vec2(1, 1); + } + }, { + key: "ZERO", + get: function get() { + return new Vec2(0, 0); + } + }, { + key: "UP", + get: function get() { + return new Vec2(0, 1); + } + }, { + key: "RIGHT", + get: function get() { + return new Vec2(1, 0); + } + } ]); + return Vec2; + })(_valueType["default"]); + exports["default"] = Vec2; + Vec2.sub = Vec2.subtract; + Vec2.mul = Vec2.multiply; + Vec2.scale = Vec2.multiplyScalar; + Vec2.mag = Vec2.len; + Vec2.squaredMagnitude = Vec2.lengthSqr; + Vec2.div = Vec2.divide; + Vec2.ONE_R = Vec2.ONE; + Vec2.ZERO_R = Vec2.ZERO; + Vec2.UP_R = Vec2.UP; + Vec2.RIGHT_R = Vec2.RIGHT; + var v2_1 = new Vec2(); + var v2_2 = new Vec2(); + _CCClass["default"].fastDefine("cc.Vec2", Vec2, { + x: 0, + y: 0 + }); + cc.v2 = function v2(x, y) { + return new Vec2(x, y); + }; + cc.Vec2 = Vec2; + module.exports = exports["default"]; + }), { + "../platform/CCClass": 240, + "../utils/misc": 325, + "./utils": 347, + "./value-type": 348 + } ], + 350: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _valueType = _interopRequireDefault(require("./value-type")); + var _CCClass = _interopRequireDefault(require("../platform/CCClass")); + var _misc = _interopRequireDefault(require("../utils/misc")); + var _vec = _interopRequireDefault(require("./vec2")); + var _utils = require("./utils"); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + "value" in descriptor && (descriptor.writable = true); + Object.defineProperty(target, descriptor.key, descriptor); + } + } + function _createClass(Constructor, protoProps, staticProps) { + protoProps && _defineProperties(Constructor.prototype, protoProps); + staticProps && _defineProperties(Constructor, staticProps); + return Constructor; + } + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + _setPrototypeOf(subClass, superClass); + } + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + return _setPrototypeOf(o, p); + } + var _x = 0; + var _y = 0; + var _z = 0; + var Vec3 = (function(_ValueType) { + _inheritsLoose(Vec3, _ValueType); + var _proto = Vec3.prototype; + _proto.sub = function sub(vector, out) { + return Vec3.subtract(out || new Vec3(), this, vector); + }; + _proto.mul = function mul(num, out) { + return Vec3.multiplyScalar(out || new Vec3(), this, num); + }; + _proto.div = function div(num, out) { + return Vec3.multiplyScalar(out || new Vec3(), this, 1 / num); + }; + _proto.scale = function scale(vector, out) { + return Vec3.multiply(out || new Vec3(), this, vector); + }; + _proto.neg = function neg(out) { + return Vec3.negate(out || new Vec3(), this); + }; + Vec3.zero = function zero(out) { + out.x = 0; + out.y = 0; + out.z = 0; + return out; + }; + Vec3.clone = function clone(a) { + return new Vec3(a.x, a.y, a.z); + }; + Vec3.copy = function copy(out, a) { + out.x = a.x; + out.y = a.y; + out.z = a.z; + return out; + }; + Vec3.set = function set(out, x, y, z) { + out.x = x; + out.y = y; + out.z = z; + return out; + }; + Vec3.add = function add(out, a, b) { + out.x = a.x + b.x; + out.y = a.y + b.y; + out.z = a.z + b.z; + return out; + }; + Vec3.subtract = function subtract(out, a, b) { + out.x = a.x - b.x; + out.y = a.y - b.y; + out.z = a.z - b.z; + return out; + }; + Vec3.multiply = function multiply(out, a, b) { + out.x = a.x * b.x; + out.y = a.y * b.y; + out.z = a.z * b.z; + return out; + }; + Vec3.divide = function divide(out, a, b) { + out.x = a.x / b.x; + out.y = a.y / b.y; + out.z = a.z / b.z; + return out; + }; + Vec3.ceil = function ceil(out, a) { + out.x = Math.ceil(a.x); + out.y = Math.ceil(a.y); + out.z = Math.ceil(a.z); + return out; + }; + Vec3.floor = function floor(out, a) { + out.x = Math.floor(a.x); + out.y = Math.floor(a.y); + out.z = Math.floor(a.z); + return out; + }; + Vec3.min = function min(out, a, b) { + out.x = Math.min(a.x, b.x); + out.y = Math.min(a.y, b.y); + out.z = Math.min(a.z, b.z); + return out; + }; + Vec3.max = function max(out, a, b) { + out.x = Math.max(a.x, b.x); + out.y = Math.max(a.y, b.y); + out.z = Math.max(a.z, b.z); + return out; + }; + Vec3.round = function round(out, a) { + out.x = Math.round(a.x); + out.y = Math.round(a.y); + out.z = Math.round(a.z); + return out; + }; + Vec3.multiplyScalar = function multiplyScalar(out, a, b) { + out.x = a.x * b; + out.y = a.y * b; + out.z = a.z * b; + return out; + }; + Vec3.scaleAndAdd = function scaleAndAdd(out, a, b, scale) { + out.x = a.x + b.x * scale; + out.y = a.y + b.y * scale; + out.z = a.z + b.z * scale; + return out; + }; + Vec3.distance = function distance(a, b) { + _x = b.x - a.x; + _y = b.y - a.y; + _z = b.z - a.z; + return Math.sqrt(_x * _x + _y * _y + _z * _z); + }; + Vec3.squaredDistance = function squaredDistance(a, b) { + _x = b.x - a.x; + _y = b.y - a.y; + _z = b.z - a.z; + return _x * _x + _y * _y + _z * _z; + }; + Vec3.len = function len(a) { + _x = a.x; + _y = a.y; + _z = a.z; + return Math.sqrt(_x * _x + _y * _y + _z * _z); + }; + Vec3.lengthSqr = function lengthSqr(a) { + _x = a.x; + _y = a.y; + _z = a.z; + return _x * _x + _y * _y + _z * _z; + }; + Vec3.negate = function negate(out, a) { + out.x = -a.x; + out.y = -a.y; + out.z = -a.z; + return out; + }; + Vec3.inverse = function inverse(out, a) { + out.x = 1 / a.x; + out.y = 1 / a.y; + out.z = 1 / a.z; + return out; + }; + Vec3.inverseSafe = function inverseSafe(out, a) { + _x = a.x; + _y = a.y; + _z = a.z; + Math.abs(_x) < _utils.EPSILON ? out.x = 0 : out.x = 1 / _x; + Math.abs(_y) < _utils.EPSILON ? out.y = 0 : out.y = 1 / _y; + Math.abs(_z) < _utils.EPSILON ? out.z = 0 : out.z = 1 / _z; + return out; + }; + Vec3.normalize = function normalize(out, a) { + _x = a.x; + _y = a.y; + _z = a.z; + var len = _x * _x + _y * _y + _z * _z; + if (len > 0) { + len = 1 / Math.sqrt(len); + out.x = _x * len; + out.y = _y * len; + out.z = _z * len; + } + return out; + }; + Vec3.dot = function dot(a, b) { + return a.x * b.x + a.y * b.y + a.z * b.z; + }; + Vec3.cross = function cross(out, a, b) { + var ax = a.x, ay = a.y, az = a.z; + var bx = b.x, by = b.y, bz = b.z; + out.x = ay * bz - az * by; + out.y = az * bx - ax * bz; + out.z = ax * by - ay * bx; + return out; + }; + Vec3.lerp = function lerp(out, a, b, t) { + out.x = a.x + t * (b.x - a.x); + out.y = a.y + t * (b.y - a.y); + out.z = a.z + t * (b.z - a.z); + return out; + }; + Vec3.random = function random(out, scale) { + scale = scale || 1; + var phi = 2 * (0, _utils.random)() * Math.PI; + var cosTheta = 2 * (0, _utils.random)() - 1; + var sinTheta = Math.sqrt(1 - cosTheta * cosTheta); + out.x = sinTheta * Math.cos(phi) * scale; + out.y = sinTheta * Math.sin(phi) * scale; + out.z = cosTheta * scale; + return out; + }; + Vec3.transformMat4 = function transformMat4(out, a, mat) { + _x = a.x; + _y = a.y; + _z = a.z; + var m = mat.m; + var rhw = m[3] * _x + m[7] * _y + m[11] * _z + m[15]; + rhw = rhw ? 1 / rhw : 1; + out.x = (m[0] * _x + m[4] * _y + m[8] * _z + m[12]) * rhw; + out.y = (m[1] * _x + m[5] * _y + m[9] * _z + m[13]) * rhw; + out.z = (m[2] * _x + m[6] * _y + m[10] * _z + m[14]) * rhw; + return out; + }; + Vec3.transformMat4Normal = function transformMat4Normal(out, a, mat) { + _x = a.x; + _y = a.y; + _z = a.z; + var m = mat.m; + var rhw = m[3] * _x + m[7] * _y + m[11] * _z; + rhw = rhw ? 1 / rhw : 1; + out.x = (m[0] * _x + m[4] * _y + m[8] * _z) * rhw; + out.y = (m[1] * _x + m[5] * _y + m[9] * _z) * rhw; + out.z = (m[2] * _x + m[6] * _y + m[10] * _z) * rhw; + return out; + }; + Vec3.transformMat3 = function transformMat3(out, a, mat) { + _x = a.x; + _y = a.y; + _z = a.z; + var m = mat.m; + out.x = _x * m[0] + _y * m[3] + _z * m[6]; + out.y = _x * m[1] + _y * m[4] + _z * m[7]; + out.z = _x * m[2] + _y * m[5] + _z * m[8]; + return out; + }; + Vec3.transformAffine = function transformAffine(out, v, mat) { + _x = v.x; + _y = v.y; + _z = v.z; + var m = mat.m; + out.x = m[0] * _x + m[1] * _y + m[2] * _z + m[3]; + out.y = m[4] * _x + m[5] * _y + m[6] * _z + m[7]; + out.x = m[8] * _x + m[9] * _y + m[10] * _z + m[11]; + return out; + }; + Vec3.transformQuat = function transformQuat(out, a, q) { + var ix = q.w * a.x + q.y * a.z - q.z * a.y; + var iy = q.w * a.y + q.z * a.x - q.x * a.z; + var iz = q.w * a.z + q.x * a.y - q.y * a.x; + var iw = -q.x * a.x - q.y * a.y - q.z * a.z; + out.x = ix * q.w + iw * -q.x + iy * -q.z - iz * -q.y; + out.y = iy * q.w + iw * -q.y + iz * -q.x - ix * -q.z; + out.z = iz * q.w + iw * -q.z + ix * -q.y - iy * -q.x; + return out; + }; + Vec3.transformRTS = function transformRTS(out, a, r, t, s) { + var x = a.x * s.x; + var y = a.y * s.y; + var z = a.z * s.z; + var ix = r.w * x + r.y * z - r.z * y; + var iy = r.w * y + r.z * x - r.x * z; + var iz = r.w * z + r.x * y - r.y * x; + var iw = -r.x * x - r.y * y - r.z * z; + out.x = ix * r.w + iw * -r.x + iy * -r.z - iz * -r.y + t.x; + out.y = iy * r.w + iw * -r.y + iz * -r.x - ix * -r.z + t.y; + out.z = iz * r.w + iw * -r.z + ix * -r.y - iy * -r.x + t.z; + return out; + }; + Vec3.transformInverseRTS = function transformInverseRTS(out, a, r, t, s) { + var x = a.x - t.x; + var y = a.y - t.y; + var z = a.z - t.z; + var ix = r.w * x - r.y * z + r.z * y; + var iy = r.w * y - r.z * x + r.x * z; + var iz = r.w * z - r.x * y + r.y * x; + var iw = r.x * x + r.y * y + r.z * z; + out.x = (ix * r.w + iw * r.x + iy * r.z - iz * r.y) / s.x; + out.y = (iy * r.w + iw * r.y + iz * r.x - ix * r.z) / s.y; + out.z = (iz * r.w + iw * r.z + ix * r.y - iy * r.x) / s.z; + return out; + }; + Vec3.rotateX = function rotateX(out, v, o, a) { + _x = v.x - o.x; + _y = v.y - o.y; + _z = v.z - o.z; + var cos = Math.cos(a); + var sin = Math.sin(a); + var rx = _x; + var ry = _y * cos - _z * sin; + var rz = _y * sin + _z * cos; + out.x = rx + o.x; + out.y = ry + o.y; + out.z = rz + o.z; + return out; + }; + Vec3.rotateY = function rotateY(out, v, o, a) { + _x = v.x - o.x; + _y = v.y - o.y; + _z = v.z - o.z; + var cos = Math.cos(a); + var sin = Math.sin(a); + var rx = _z * sin + _x * cos; + var ry = _y; + var rz = _z * cos - _x * sin; + out.x = rx + o.x; + out.y = ry + o.y; + out.z = rz + o.z; + return out; + }; + Vec3.rotateZ = function rotateZ(out, v, o, a) { + _x = v.x - o.x; + _y = v.y - o.y; + _z = v.z - o.z; + var cos = Math.cos(a); + var sin = Math.sin(a); + var rx = _x * cos - _y * sin; + var ry = _x * sin + _y * cos; + var rz = _z; + out.x = rx + o.x; + out.y = ry + o.y; + out.z = rz + o.z; + return out; + }; + Vec3.strictEquals = function strictEquals(a, b) { + return a.x === b.x && a.y === b.y && a.z === b.z; + }; + Vec3.equals = function equals(a, b, epsilon) { + void 0 === epsilon && (epsilon = _utils.EPSILON); + var a0 = a.x, a1 = a.y, a2 = a.z; + var b0 = b.x, b1 = b.y, b2 = b.z; + return Math.abs(a0 - b0) <= epsilon * Math.max(1, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= epsilon * Math.max(1, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= epsilon * Math.max(1, Math.abs(a2), Math.abs(b2)); + }; + Vec3.angle = function angle(a, b) { + Vec3.normalize(v3_1, a); + Vec3.normalize(v3_2, b); + var cosine = Vec3.dot(v3_1, v3_2); + if (cosine > 1) return 0; + if (cosine < -1) return Math.PI; + return Math.acos(cosine); + }; + Vec3.projectOnPlane = function projectOnPlane(out, a, n) { + return Vec3.subtract(out, a, Vec3.project(out, a, n)); + }; + Vec3.project = function project(out, a, b) { + var sqrLen = Vec3.lengthSqr(b); + return sqrLen < 1e-6 ? Vec3.set(out, 0, 0, 0) : Vec3.multiplyScalar(out, b, Vec3.dot(a, b) / sqrLen); + }; + Vec3.toArray = function toArray(out, v, ofs) { + void 0 === ofs && (ofs = 0); + out[ofs + 0] = v.x; + out[ofs + 1] = v.y; + out[ofs + 2] = v.z; + return out; + }; + Vec3.fromArray = function fromArray(out, arr, ofs) { + void 0 === ofs && (ofs = 0); + out.x = arr[ofs + 0]; + out.y = arr[ofs + 1]; + out.z = arr[ofs + 2]; + return out; + }; + function Vec3(x, y, z) { + var _this; + void 0 === x && (x = 0); + void 0 === y && (y = 0); + void 0 === z && (z = 0); + _this = _ValueType.call(this) || this; + _this.mag = Vec3.prototype.len; + _this.magSqr = Vec3.prototype.lengthSqr; + _this.subSelf = Vec3.prototype.subtract; + _this.mulSelf = Vec3.prototype.multiplyScalar; + _this.divSelf = Vec3.prototype.divide; + _this.scaleSelf = Vec3.prototype.multiply; + _this.negSelf = Vec3.prototype.negate; + _this.x = void 0; + _this.y = void 0; + _this.z = void 0; + _this.angle = _vec["default"].prototype.angle; + _this.project = _vec["default"].prototype.project; + if (x && "object" === typeof x) { + _this.x = x.x; + _this.y = x.y; + _this.z = x.z; + } else { + _this.x = x; + _this.y = y; + _this.z = z; + } + return _this; + } + _proto.clone = function clone() { + return new Vec3(this.x, this.y, this.z); + }; + _proto.set = function set(newValue) { + this.x = newValue.x; + this.y = newValue.y; + this.z = newValue.z; + return this; + }; + _proto.equals = function equals(other) { + return other && this.x === other.x && this.y === other.y && this.z === other.z; + }; + _proto.fuzzyEquals = function fuzzyEquals(other, variance) { + if (this.x - variance <= other.x && other.x <= this.x + variance && this.y - variance <= other.y && other.y <= this.y + variance && this.z - variance <= other.z && other.z <= this.z + variance) return true; + return false; + }; + _proto.toString = function toString() { + return "(" + this.x.toFixed(2) + ", " + this.y.toFixed(2) + ", " + this.z.toFixed(2) + ")"; + }; + _proto.lerp = function lerp(to, ratio, out) { + out = out || new Vec3(); + Vec3.lerp(out, this, to, ratio); + return out; + }; + _proto.clampf = function clampf(min_inclusive, max_inclusive) { + this.x = _misc["default"].clampf(this.x, min_inclusive.x, max_inclusive.x); + this.y = _misc["default"].clampf(this.y, min_inclusive.y, max_inclusive.y); + this.z = _misc["default"].clampf(this.z, min_inclusive.z, max_inclusive.z); + return this; + }; + _proto.addSelf = function addSelf(vector) { + this.x += vector.x; + this.y += vector.y; + this.z += vector.z; + return this; + }; + _proto.add = function add(vector, out) { + out = out || new Vec3(); + out.x = this.x + vector.x; + out.y = this.y + vector.y; + out.z = this.z + vector.z; + return out; + }; + _proto.subtract = function subtract(vector) { + this.x -= vector.x; + this.y -= vector.y; + this.z -= vector.z; + return this; + }; + _proto.multiplyScalar = function multiplyScalar(num) { + this.x *= num; + this.y *= num; + this.z *= num; + return this; + }; + _proto.multiply = function multiply(vector) { + this.x *= vector.x; + this.y *= vector.y; + this.z *= vector.z; + return this; + }; + _proto.divide = function divide(num) { + this.x /= num; + this.y /= num; + this.z /= num; + return this; + }; + _proto.negate = function negate() { + this.x = -this.x; + this.y = -this.y; + this.z = -this.z; + return this; + }; + _proto.dot = function dot(vector) { + return this.x * vector.x + this.y * vector.y + this.z * vector.z; + }; + _proto.cross = function cross(vector, out) { + out = out || new Vec3(); + Vec3.cross(out, this, vector); + return out; + }; + _proto.len = function len() { + return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z); + }; + _proto.lengthSqr = function lengthSqr() { + return this.x * this.x + this.y * this.y + this.z * this.z; + }; + _proto.normalizeSelf = function normalizeSelf() { + Vec3.normalize(this, this); + return this; + }; + _proto.normalize = function normalize(out) { + out = out || new Vec3(); + Vec3.normalize(out, this); + return out; + }; + _proto.transformMat4 = function transformMat4(m, out) { + out = out || new Vec3(); + Vec3.transformMat4(out, this, m); + return out; + }; + _proto.maxAxis = function maxAxis() { + return Math.max(this.x, this.y, this.z); + }; + _proto.signAngle = function signAngle(vector) { + cc.warnID(1408, "vec3.signAngle", "v2.1", "cc.v2(selfVector).signAngle(vector)"); + var vec1 = new _vec["default"](this.x, this.y); + var vec2 = new _vec["default"](vector.x, vector.y); + return vec1.signAngle(vec2); + }; + _proto.rotate = function rotate(radians, out) { + cc.warnID(1408, "vec3.rotate", "v2.1", "cc.v2(selfVector).rotate(radians, out)"); + return _vec["default"].prototype.rotate.call(this, radians, out); + }; + _proto.rotateSelf = function rotateSelf(radians) { + cc.warnID(1408, "vec3.rotateSelf", "v2.1", "cc.v2(selfVector).rotateSelf(radians)"); + return _vec["default"].prototype.rotateSelf.call(this, radians); + }; + _createClass(Vec3, null, [ { + key: "ONE", + get: function get() { + return new Vec3(1, 1, 1); + } + }, { + key: "ZERO", + get: function get() { + return new Vec3(); + } + }, { + key: "UP", + get: function get() { + return new Vec3(0, 1, 0); + } + }, { + key: "RIGHT", + get: function get() { + return new Vec3(1, 0, 0); + } + }, { + key: "FORWARD", + get: function get() { + return new Vec3(0, 0, 1); + } + } ]); + return Vec3; + })(_valueType["default"]); + exports["default"] = Vec3; + Vec3.sub = Vec3.subtract; + Vec3.mul = Vec3.multiply; + Vec3.scale = Vec3.multiplyScalar; + Vec3.mag = Vec3.len; + Vec3.squaredMagnitude = Vec3.lengthSqr; + Vec3.div = Vec3.divide; + Vec3.ONE_R = Vec3.ONE; + Vec3.ZERO_R = Vec3.ZERO; + Vec3.UP_R = Vec3.UP; + Vec3.RIGHT_R = Vec3.RIGHT; + Vec3.FRONT_R = Vec3.FORWARD; + var v3_1 = new Vec3(); + var v3_2 = new Vec3(); + _CCClass["default"].fastDefine("cc.Vec3", Vec3, { + x: 0, + y: 0, + z: 0 + }); + cc.v3 = function v3(x, y, z) { + return new Vec3(x, y, z); + }; + cc.Vec3 = Vec3; + module.exports = exports["default"]; + }), { + "../platform/CCClass": 240, + "../utils/misc": 325, + "./utils": 347, + "./value-type": 348, + "./vec2": 349 + } ], + 351: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + exports.v4 = v4; + var _CCClass = _interopRequireDefault(require("../platform/CCClass")); + var _valueType = _interopRequireDefault(require("./value-type")); + var _utils = require("./utils"); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + "value" in descriptor && (descriptor.writable = true); + Object.defineProperty(target, descriptor.key, descriptor); + } + } + function _createClass(Constructor, protoProps, staticProps) { + protoProps && _defineProperties(Constructor.prototype, protoProps); + staticProps && _defineProperties(Constructor, staticProps); + return Constructor; + } + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + _setPrototypeOf(subClass, superClass); + } + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + return _setPrototypeOf(o, p); + } + var _x = 0; + var _y = 0; + var _z = 0; + var _w = 0; + var Vec4 = (function(_ValueType) { + _inheritsLoose(Vec4, _ValueType); + var _proto = Vec4.prototype; + _proto.sub = function sub(vector, out) { + return Vec4.subtract(out || new Vec4(), this, vector); + }; + _proto.mul = function mul(num, out) { + return Vec4.multiplyScalar(out || new Vec4(), this, num); + }; + _proto.div = function div(num, out) { + return Vec4.multiplyScalar(out || new Vec4(), this, 1 / num); + }; + _proto.scale = function scale(vector, out) { + return Vec4.multiply(out || new Vec4(), this, vector); + }; + _proto.neg = function neg(out) { + return Vec4.negate(out || new Vec4(), this); + }; + Vec4.clone = function clone(a) { + return new Vec4(a.x, a.y, a.z, a.w); + }; + Vec4.copy = function copy(out, a) { + out.x = a.x; + out.y = a.y; + out.z = a.z; + out.w = a.w; + return out; + }; + Vec4.set = function set(out, x, y, z, w) { + out.x = x; + out.y = y; + out.z = z; + out.w = w; + return out; + }; + Vec4.add = function add(out, a, b) { + out.x = a.x + b.x; + out.y = a.y + b.y; + out.z = a.z + b.z; + out.w = a.w + b.w; + return out; + }; + Vec4.subtract = function subtract(out, a, b) { + out.x = a.x - b.x; + out.y = a.y - b.y; + out.z = a.z - b.z; + out.w = a.w - b.w; + return out; + }; + Vec4.multiply = function multiply(out, a, b) { + out.x = a.x * b.x; + out.y = a.y * b.y; + out.z = a.z * b.z; + out.w = a.w * b.w; + return out; + }; + Vec4.divide = function divide(out, a, b) { + out.x = a.x / b.x; + out.y = a.y / b.y; + out.z = a.z / b.z; + out.w = a.w / b.w; + return out; + }; + Vec4.ceil = function ceil(out, a) { + out.x = Math.ceil(a.x); + out.y = Math.ceil(a.y); + out.z = Math.ceil(a.z); + out.w = Math.ceil(a.w); + return out; + }; + Vec4.floor = function floor(out, a) { + out.x = Math.floor(a.x); + out.y = Math.floor(a.y); + out.z = Math.floor(a.z); + out.w = Math.floor(a.w); + return out; + }; + Vec4.min = function min(out, a, b) { + out.x = Math.min(a.x, b.x); + out.y = Math.min(a.y, b.y); + out.z = Math.min(a.z, b.z); + out.w = Math.min(a.w, b.w); + return out; + }; + Vec4.max = function max(out, a, b) { + out.x = Math.max(a.x, b.x); + out.y = Math.max(a.y, b.y); + out.z = Math.max(a.z, b.z); + out.w = Math.max(a.w, b.w); + return out; + }; + Vec4.round = function round(out, a) { + out.x = Math.round(a.x); + out.y = Math.round(a.y); + out.z = Math.round(a.z); + out.w = Math.round(a.w); + return out; + }; + Vec4.multiplyScalar = function multiplyScalar(out, a, b) { + out.x = a.x * b; + out.y = a.y * b; + out.z = a.z * b; + out.w = a.w * b; + return out; + }; + Vec4.scaleAndAdd = function scaleAndAdd(out, a, b, scale) { + out.x = a.x + b.x * scale; + out.y = a.y + b.y * scale; + out.z = a.z + b.z * scale; + out.w = a.w + b.w * scale; + return out; + }; + Vec4.distance = function distance(a, b) { + var x = b.x - a.x; + var y = b.y - a.y; + var z = b.z - a.z; + var w = b.w - a.w; + return Math.sqrt(x * x + y * y + z * z + w * w); + }; + Vec4.squaredDistance = function squaredDistance(a, b) { + var x = b.x - a.x; + var y = b.y - a.y; + var z = b.z - a.z; + var w = b.w - a.w; + return x * x + y * y + z * z + w * w; + }; + Vec4.len = function len(a) { + _x = a.x; + _y = a.y; + _z = a.z; + _w = a.w; + return Math.sqrt(_x * _x + _y * _y + _z * _z + _w * _w); + }; + Vec4.lengthSqr = function lengthSqr(a) { + _x = a.x; + _y = a.y; + _z = a.z; + _w = a.w; + return _x * _x + _y * _y + _z * _z + _w * _w; + }; + Vec4.negate = function negate(out, a) { + out.x = -a.x; + out.y = -a.y; + out.z = -a.z; + out.w = -a.w; + return out; + }; + Vec4.inverse = function inverse(out, a) { + out.x = 1 / a.x; + out.y = 1 / a.y; + out.z = 1 / a.z; + out.w = 1 / a.w; + return out; + }; + Vec4.inverseSafe = function inverseSafe(out, a) { + _x = a.x; + _y = a.y; + _z = a.z; + _w = a.w; + Math.abs(_x) < _utils.EPSILON ? out.x = 0 : out.x = 1 / _x; + Math.abs(_y) < _utils.EPSILON ? out.y = 0 : out.y = 1 / _y; + Math.abs(_z) < _utils.EPSILON ? out.z = 0 : out.z = 1 / _z; + Math.abs(_w) < _utils.EPSILON ? out.w = 0 : out.w = 1 / _w; + return out; + }; + Vec4.normalize = function normalize(out, a) { + _x = a.x; + _y = a.y; + _z = a.z; + _w = a.w; + var len = _x * _x + _y * _y + _z * _z + _w * _w; + if (len > 0) { + len = 1 / Math.sqrt(len); + out.x = _x * len; + out.y = _y * len; + out.z = _z * len; + out.w = _w * len; + } + return out; + }; + Vec4.dot = function dot(a, b) { + return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w; + }; + Vec4.lerp = function lerp(out, a, b, t) { + out.x = a.x + t * (b.x - a.x); + out.y = a.y + t * (b.y - a.y); + out.z = a.z + t * (b.z - a.z); + out.w = a.w + t * (b.w - a.w); + return out; + }; + Vec4.random = function random(out, scale) { + scale = scale || 1; + var phi = 2 * (0, _utils.random)() * Math.PI; + var cosTheta = 2 * (0, _utils.random)() - 1; + var sinTheta = Math.sqrt(1 - cosTheta * cosTheta); + out.x = sinTheta * Math.cos(phi) * scale; + out.y = sinTheta * Math.sin(phi) * scale; + out.z = cosTheta * scale; + out.w = 0; + return out; + }; + Vec4.transformMat4 = function transformMat4(out, a, mat) { + _x = a.x; + _y = a.y; + _z = a.z; + _w = a.w; + var m = mat.m; + out.x = m[0] * _x + m[4] * _y + m[8] * _z + m[12] * _w; + out.y = m[1] * _x + m[5] * _y + m[9] * _z + m[13] * _w; + out.z = m[2] * _x + m[6] * _y + m[10] * _z + m[14] * _w; + out.w = m[3] * _x + m[7] * _y + m[11] * _z + m[15] * _w; + return out; + }; + Vec4.transformAffine = function transformAffine(out, v, mat) { + _x = v.x; + _y = v.y; + _z = v.z; + _w = v.w; + var m = mat.m; + out.x = m[0] * _x + m[1] * _y + m[2] * _z + m[3] * _w; + out.y = m[4] * _x + m[5] * _y + m[6] * _z + m[7] * _w; + out.x = m[8] * _x + m[9] * _y + m[10] * _z + m[11] * _w; + out.w = v.w; + return out; + }; + Vec4.transformQuat = function transformQuat(out, a, q) { + var x = a.x, y = a.y, z = a.z; + _x = q.x; + _y = q.y; + _z = q.z; + _w = q.w; + var ix = _w * x + _y * z - _z * y; + var iy = _w * y + _z * x - _x * z; + var iz = _w * z + _x * y - _y * x; + var iw = -_x * x - _y * y - _z * z; + out.x = ix * _w + iw * -_x + iy * -_z - iz * -_y; + out.y = iy * _w + iw * -_y + iz * -_x - ix * -_z; + out.z = iz * _w + iw * -_z + ix * -_y - iy * -_x; + out.w = a.w; + return out; + }; + Vec4.strictEquals = function strictEquals(a, b) { + return a.x === b.x && a.y === b.y && a.z === b.z && a.w === b.w; + }; + Vec4.equals = function equals(a, b, epsilon) { + void 0 === epsilon && (epsilon = _utils.EPSILON); + return Math.abs(a.x - b.x) <= epsilon * Math.max(1, Math.abs(a.x), Math.abs(b.x)) && Math.abs(a.y - b.y) <= epsilon * Math.max(1, Math.abs(a.y), Math.abs(b.y)) && Math.abs(a.z - b.z) <= epsilon * Math.max(1, Math.abs(a.z), Math.abs(b.z)) && Math.abs(a.w - b.w) <= epsilon * Math.max(1, Math.abs(a.w), Math.abs(b.w)); + }; + Vec4.toArray = function toArray(out, v, ofs) { + void 0 === ofs && (ofs = 0); + out[ofs + 0] = v.x; + out[ofs + 1] = v.y; + out[ofs + 2] = v.z; + out[ofs + 3] = v.w; + return out; + }; + Vec4.fromArray = function fromArray(out, arr, ofs) { + void 0 === ofs && (ofs = 0); + out.x = arr[ofs + 0]; + out.y = arr[ofs + 1]; + out.z = arr[ofs + 2]; + out.w = arr[ofs + 3]; + return out; + }; + function Vec4(x, y, z, w) { + var _this; + void 0 === x && (x = 0); + void 0 === y && (y = 0); + void 0 === z && (z = 0); + void 0 === w && (w = 0); + _this = _ValueType.call(this) || this; + _this.mag = Vec4.prototype.len; + _this.magSqr = Vec4.prototype.lengthSqr; + _this.subSelf = Vec4.prototype.subtract; + _this.mulSelf = Vec4.prototype.multiplyScalar; + _this.divSelf = Vec4.prototype.divide; + _this.scaleSelf = Vec4.prototype.multiply; + _this.negSelf = Vec4.prototype.negate; + _this.x = void 0; + _this.y = void 0; + _this.z = void 0; + _this.w = void 0; + if (x && "object" === typeof x) { + _this.x = x.x; + _this.y = x.y; + _this.z = x.z; + _this.w = x.w; + } else { + _this.x = x; + _this.y = y; + _this.z = z; + _this.w = w; + } + return _this; + } + _proto.clone = function clone() { + return new Vec4(this.x, this.y, this.z, this.w); + }; + _proto.set = function set(x, y, z, w) { + if (x && "object" === typeof x) { + this.x = x.x; + this.y = x.y; + this.z = x.z; + this.w = x.w; + } else { + this.x = x || 0; + this.y = y || 0; + this.z = z || 0; + this.w = w || 0; + } + return this; + }; + _proto.equals = function equals(other, epsilon) { + void 0 === epsilon && (epsilon = _utils.EPSILON); + return Math.abs(this.x - other.x) <= epsilon * Math.max(1, Math.abs(this.x), Math.abs(other.x)) && Math.abs(this.y - other.y) <= epsilon * Math.max(1, Math.abs(this.y), Math.abs(other.y)) && Math.abs(this.z - other.z) <= epsilon * Math.max(1, Math.abs(this.z), Math.abs(other.z)) && Math.abs(this.w - other.w) <= epsilon * Math.max(1, Math.abs(this.w), Math.abs(other.w)); + }; + _proto.equals4f = function equals4f(x, y, z, w, epsilon) { + void 0 === epsilon && (epsilon = _utils.EPSILON); + return Math.abs(this.x - x) <= epsilon * Math.max(1, Math.abs(this.x), Math.abs(x)) && Math.abs(this.y - y) <= epsilon * Math.max(1, Math.abs(this.y), Math.abs(y)) && Math.abs(this.z - z) <= epsilon * Math.max(1, Math.abs(this.z), Math.abs(z)) && Math.abs(this.w - w) <= epsilon * Math.max(1, Math.abs(this.w), Math.abs(w)); + }; + _proto.strictEquals = function strictEquals(other) { + return this.x === other.x && this.y === other.y && this.z === other.z && this.w === other.w; + }; + _proto.strictEquals4f = function strictEquals4f(x, y, z, w) { + return this.x === x && this.y === y && this.z === z && this.w === w; + }; + _proto.lerp = function lerp(to, ratio) { + _x = this.x; + _y = this.y; + _z = this.z; + _w = this.w; + this.x = _x + ratio * (to.x - _x); + this.y = _y + ratio * (to.y - _y); + this.z = _z + ratio * (to.z - _z); + this.w = _w + ratio * (to.w - _w); + return this; + }; + _proto.toString = function toString() { + return "(" + this.x.toFixed(2) + ", " + this.y.toFixed(2) + ", " + this.z.toFixed(2) + ", " + this.w.toFixed(2) + ")"; + }; + _proto.clampf = function clampf(minInclusive, maxInclusive) { + this.x = (0, _utils.clamp)(this.x, minInclusive.x, maxInclusive.x); + this.y = (0, _utils.clamp)(this.y, minInclusive.y, maxInclusive.y); + this.z = (0, _utils.clamp)(this.z, minInclusive.z, maxInclusive.z); + this.w = (0, _utils.clamp)(this.w, minInclusive.w, maxInclusive.w); + return this; + }; + _proto.addSelf = function addSelf(vector) { + this.x += vector.x; + this.y += vector.y; + this.z += vector.z; + this.w += vector.w; + return this; + }; + _proto.add = function add(vector, out) { + out = out || new Vec4(); + out.x = this.x + vector.x; + out.y = this.y + vector.y; + out.z = this.z + vector.z; + out.w = this.w + vector.w; + return out; + }; + _proto.subtract = function subtract(vector, out) { + out = out || new Vec4(); + out.x = this.x - vector.x; + out.y = this.y - vector.y; + out.z = this.z - vector.z; + out.w = this.w - vector.w; + return out; + }; + _proto.multiplyScalar = function multiplyScalar(num) { + this.x *= num; + this.y *= num; + this.z *= num; + this.w *= num; + return this; + }; + _proto.multiply = function multiply(vector) { + this.x *= vector.x; + this.y *= vector.y; + this.z *= vector.z; + this.w *= vector.w; + return this; + }; + _proto.divide = function divide(num) { + this.x /= num; + this.y /= num; + this.z /= num; + this.w /= num; + return this; + }; + _proto.negate = function negate() { + this.x = -this.x; + this.y = -this.y; + this.z = -this.z; + this.w = -this.w; + return this; + }; + _proto.dot = function dot(vector) { + return this.x * vector.x + this.y * vector.y + this.z * vector.z + this.w * vector.w; + }; + _proto.cross = function cross(vector, out) { + out = out || new Vec4(); + var ax = this.x, ay = this.y, az = this.z; + var bx = vector.x, by = vector.y, bz = vector.z; + out.x = ay * bz - az * by; + out.y = az * bx - ax * bz; + out.z = ax * by - ay * bx; + return out; + }; + _proto.len = function len() { + var x = this.x, y = this.y, z = this.z, w = this.w; + return Math.sqrt(x * x + y * y + z * z + w * w); + }; + _proto.lengthSqr = function lengthSqr() { + var x = this.x, y = this.y, z = this.z, w = this.w; + return x * x + y * y + z * z + w * w; + }; + _proto.normalizeSelf = function normalizeSelf() { + this.normalize(this); + return this; + }; + _proto.normalize = function normalize(out) { + out = out || new Vec4(); + _x = this.x; + _y = this.y; + _z = this.z; + _w = this.w; + var len = _x * _x + _y * _y + _z * _z + _w * _w; + if (len > 0) { + len = 1 / Math.sqrt(len); + out.x = _x * len; + out.y = _y * len; + out.z = _z * len; + out.w = _w * len; + } + return out; + }; + _proto.transformMat4 = function transformMat4(matrix, out) { + out = out || new Vec4(); + _x = this.x; + _y = this.y; + _z = this.z; + _w = this.w; + var m = matrix.m; + out.x = m[0] * _x + m[4] * _y + m[8] * _z + m[12] * _w; + out.y = m[1] * _x + m[5] * _y + m[9] * _z + m[13] * _w; + out.z = m[2] * _x + m[6] * _y + m[10] * _z + m[14] * _w; + out.w = m[3] * _x + m[7] * _y + m[11] * _z + m[15] * _w; + return out; + }; + _proto.maxAxis = function maxAxis() { + return Math.max(this.x, this.y, this.z, this.w); + }; + _createClass(Vec4, null, [ { + key: "ZERO", + get: function get() { + return new Vec4(0, 0, 0, 0); + } + }, { + key: "ONE", + get: function get() { + return new Vec4(1, 1, 1, 1); + } + }, { + key: "NEG_ONE", + get: function get() { + return new Vec4(-1, -1, -1, -1); + } + } ]); + return Vec4; + })(_valueType["default"]); + exports["default"] = Vec4; + Vec4.sub = Vec4.subtract; + Vec4.mul = Vec4.multiply; + Vec4.div = Vec4.divide; + Vec4.scale = Vec4.multiplyScalar; + Vec4.mag = Vec4.len; + Vec4.squaredMagnitude = Vec4.lengthSqr; + Vec4.ZERO_R = Vec4.ZERO; + Vec4.ONE_R = Vec4.ONE; + Vec4.NEG_ONE_R = Vec4.NEG_ONE; + _CCClass["default"].fastDefine("cc.Vec4", Vec4, { + x: 0, + y: 0, + z: 0, + w: 0 + }); + function v4(x, y, z, w) { + return new Vec4(x, y, z, w); + } + cc.v4 = v4; + cc.Vec4 = Vec4; + }), { + "../platform/CCClass": 240, + "./utils": 347, + "./value-type": 348 + } ], + 352: [ (function(require, module, exports) { + "use strict"; + var js = cc.js; + true; + var deprecateEnum = function deprecateEnum(obj, oldPath, newPath, hasTypePrefixBefore) { + false; + hasTypePrefixBefore = false !== hasTypePrefixBefore; + var enumDef = Function("return " + newPath)(); + var entries = cc.Enum.getList(enumDef); + var delimiter = hasTypePrefixBefore ? "_" : "."; + for (var i = 0; i < entries.length; i++) { + var entry = entries[i].name; + var oldPropName; + if (hasTypePrefixBefore) { + var oldTypeName = oldPath.split(".").slice(-1)[0]; + oldPropName = oldTypeName + "_" + entry; + } else oldPropName = entry; + js.get(obj, oldPropName, function(entry) { + cc.errorID(1400, oldPath + delimiter + entry, newPath + "." + entry); + return enumDef[entry]; + }.bind(null, entry)); + } + }; + var markAsRemoved = function markAsRemoved(ownerCtor, removedProps, ownerName) { + if (!ownerCtor) return; + ownerName = ownerName || js.getClassName(ownerCtor); + removedProps.forEach((function(prop) { + function error() { + cc.errorID(1406, ownerName, prop); + } + js.getset(ownerCtor.prototype, prop, error, error); + })); + }; + var markAsDeprecated = function markAsDeprecated(ownerCtor, deprecatedProps, ownerName) { + if (!ownerCtor) return; + ownerName = ownerName || js.getClassName(ownerCtor); + var descriptors = Object.getOwnPropertyDescriptors(ownerCtor.prototype); + deprecatedProps.forEach((function(prop) { + var deprecatedProp = prop[0]; + var newProp = prop[1]; + var descriptor = descriptors[deprecatedProp]; + js.getset(ownerCtor.prototype, deprecatedProp, (function() { + cc.warnID(1400, ownerName + "." + deprecatedProp, ownerName + "." + newProp); + return descriptor.get.call(this); + }), (function(v) { + cc.warnID(1400, ownerName + "." + deprecatedProp, ownerName + "." + newProp); + descriptor.set.call(this, v); + })); + })); + }; + var markAsRemovedInObject = function markAsRemovedInObject(ownerObj, removedProps, ownerName) { + if (!ownerObj) return; + removedProps.forEach((function(prop) { + function error() { + cc.errorID(1406, ownerName, prop); + } + js.getset(ownerObj, prop, error); + })); + }; + var provideClearError = function provideClearError(owner, obj, ownerName) { + if (!owner) return; + var className = ownerName || cc.js.getClassName(owner); + var Info = "Sorry, " + className + ".%s is removed, please use %s instead."; + var _loop = function _loop() { + function define(prop, getset) { + function accessor(newProp) { + cc.error(Info, prop, newProp); + } + Array.isArray(getset) || (getset = getset.split(",").map((function(x) { + return x.trim(); + }))); + try { + js.getset(owner, prop, accessor.bind(null, getset[0]), getset[1] && accessor.bind(null, getset[1])); + } catch (e) {} + } + getset = obj[prop]; + if ("*" === prop[0]) { + etProp = prop.slice(1); + define("g" + etProp, getset); + define("s" + etProp, getset); + } else prop.split(",").map((function(x) { + return x.trim(); + })).forEach((function(x) { + define(x, getset); + })); + }; + for (var prop in obj) { + var getset; + var etProp; + _loop(); + } + }; + var markFunctionWarning = function markFunctionWarning(ownerCtor, obj, ownerName) { + if (!ownerCtor) return; + ownerName = ownerName || js.getClassName(ownerCtor); + for (var prop in obj) (function() { + var propName = prop; + var originFunc = ownerCtor[propName]; + if (!originFunc) return; + function warn() { + cc.warn("Sorry, %s.%s is deprecated. Please use %s instead", ownerName, propName, obj[propName]); + return originFunc.apply(this, arguments); + } + ownerCtor[propName] = warn; + })(); + }; + js.get(cc, "info", (function() { + cc.errorID(1400, "cc.info", "cc.log"); + return cc.log; + })); + js.get(cc, "spriteFrameCache", (function() { + cc.errorID(1404); + })); + js.get(cc, "vmath", (function() { + cc.warnID(1400, "cc.vmath", "cc.math"); + return cc.math; + })); + js.get(cc.math, "vec2", (function() { + cc.warnID(1400, "cc.vmath.vec2", "cc.Vec2"); + return cc.Vec2; + })); + js.get(cc.math, "vec3", (function() { + cc.warnID(1400, "cc.vmath.vec3", "cc.Vec3"); + return cc.Vec3; + })); + js.get(cc.math, "vec4", (function() { + cc.warnID(1400, "cc.vmath.vec4", "cc.Vec4"); + return cc.Vec4; + })); + js.get(cc.math, "mat4", (function() { + cc.warnID(1400, "cc.vmath.mat4", "cc.Mat4"); + return cc.Mat4; + })); + js.get(cc.math, "mat3", (function() { + cc.warnID(1400, "cc.vmath.mat3", "cc.Mat3"); + return cc.Mat3; + })); + js.get(cc.math, "quat", (function() { + cc.warnID(1400, "cc.vmath.quat", "cc.Quat"); + return cc.Quat; + })); + js.get(cc.SpriteFrame.prototype, "_textureLoaded", (function() { + cc.errorID(1400, "spriteFrame._textureLoaded", "spriteFrame.textureLoaded()"); + return this.textureLoaded(); + })); + markAsRemoved(cc.SpriteFrame, [ "addLoadedEventListener" ]); + markFunctionWarning(cc.Sprite.prototype, { + setState: "cc.Sprite.setMaterial", + getState: "cc.Sprite.getMaterial" + }, "cc.Sprite"); + js.get(cc.SpriteFrame.prototype, "clearTexture", (function() { + cc.errorID(1406, "cc.SpriteFrame", "clearTexture"); + return function() {}; + })); + js.get(cc, "textureCache", (function() { + cc.errorID(1406, "cc", "textureCache"); + })); + var Texture2D = cc.Texture2D; + js.get(Texture2D.prototype, "releaseTexture", (function() { + cc.errorID(1400, "texture.releaseTexture()", "texture.destroy()"); + return this.destroy; + })); + js.get(Texture2D.prototype, "getName", (function() { + cc.errorID(1400, "texture.getName()", "texture._glID"); + return function() { + return this._glID || null; + }; + })); + js.get(Texture2D.prototype, "isLoaded", (function() { + cc.errorID(1400, "texture.isLoaded function", "texture.loaded property"); + return function() { + return this.loaded; + }; + })); + js.get(Texture2D.prototype, "setAntiAliasTexParameters", (function() { + cc.errorID(1400, "texture.setAntiAliasTexParameters()", "texture.setFilters(cc.Texture2D.Filter.LINEAR, cc.Texture2D.Filter.LINEAR)"); + return function() { + this.setFilters(Texture2D.Filter.LINEAR, Texture2D.Filter.LINEAR); + }; + })); + js.get(Texture2D.prototype, "setAliasTexParameters", (function() { + cc.errorID(1400, "texture.setAntiAliasTexParameters()", "texture.setFilters(cc.Texture2D.Filter.NEAREST, cc.Texture2D.Filter.NEAREST)"); + return function() { + this.setFilters(Texture2D.Filter.NEAREST, Texture2D.Filter.NEAREST); + }; + })); + markAsRemovedInObject(cc.macro, [ "ENABLE_GL_STATE_CACHE", "FIX_ARTIFACTS_BY_STRECHING_TEXEL" ], "cc.macro"); + provideClearError(cc.macro, { + PI: "Math.PI", + PI2: "Math.PI * 2", + FLT_MAX: "Number.MAX_VALUE", + FLT_MIN: "Number.MIN_VALUE", + UINT_MAX: "Number.MAX_SAFE_INTEGER" + }, "cc.macro"); + markAsRemovedInObject(cc.game, [ "CONFIG_KEY" ], "cc.game"); + markAsRemovedInObject(cc.sys, [ "dumpRoot", "cleanScript", "BROWSER_TYPE_WECHAT_GAME", "BROWSER_TYPE_WECHAT_GAME_SUB", "BROWSER_TYPE_BAIDU_GAME", "BROWSER_TYPE_BAIDU_GAME_SUB", "BROWSER_TYPE_XIAOMI_GAME", "BROWSER_TYPE_ALIPAY_GAME" ], "cc.sys"); + provideClearError(cc.Director, { + EVENT_PROJECTION_CHANGED: "", + EVENT_BEFORE_VISIT: "EVENT_AFTER_UPDATE", + EVENT_AFTER_VISIT: "EVENT_BEFORE_DRAW" + }, "cc.Director"); + markFunctionWarning(cc.Director.prototype, { + convertToGL: "cc.view.convertToLocationInView", + convertToUI: "", + getWinSize: "cc.winSize", + getWinSizeInPixels: "cc.winSize", + getVisibleSize: "cc.view.getVisibleSize", + getVisibleOrigin: "cc.view.getVisibleOrigin", + purgeCachedData: "cc.assetManager.releaseAll", + setDepthTest: "cc.Camera.main.depth", + setClearColor: "cc.Camera.main.backgroundColor", + getRunningScene: "cc.director.getScene", + getAnimationInterval: "cc.game.getFrameRate", + setAnimationInterval: "cc.game.setFrameRate", + isDisplayStats: "cc.debug.isDisplayStats", + setDisplayStats: "cc.debug.setDisplayStats", + stopAnimation: "cc.game.pause", + startAnimation: "cc.game.resume" + }, "cc.Director"); + markAsRemoved(cc.Director, [ "pushScene", "popScene", "popToRootScene", "popToSceneStackLevel", "setProjection", "getProjection" ], "cc.Director"); + provideClearError(cc.Scheduler, { + scheduleCallbackForTarget: "schedule", + scheduleUpdateForTarget: "scheduleUpdate", + unscheduleCallbackForTarget: "unschedule", + unscheduleUpdateForTarget: "unscheduleUpdate", + unscheduleAllCallbacksForTarget: "unscheduleAllForTarget", + unscheduleAllCallbacks: "unscheduleAll", + unscheduleAllCallbacksWithMinPriority: "unscheduleAllWithMinPriority" + }, "cc.Scheduler"); + provideClearError(cc.view, { + adjustViewPort: "adjustViewportMeta", + setViewPortInPoints: "setViewportInPoints", + getViewPortRect: "getViewportRect" + }, "cc.view"); + markAsRemovedInObject(cc.view, [ "isViewReady", "setTargetDensityDPI", "getTargetDensityDPI", "setFrameZoomFactor", "canSetContentScaleFactor", "setContentTranslateLeftTop", "getContentTranslateLeftTop", "setViewName", "getViewName" ], "cc.view"); + markAsRemoved(cc.PhysicsManager, [ "attachDebugDrawToCamera", "detachDebugDrawFromCamera" ]); + markAsRemoved(cc.CollisionManager, [ "attachDebugDrawToCamera", "detachDebugDrawFromCamera" ]); + provideClearError(cc._BaseNode.prototype, { + tag: "name", + getTag: "name", + setTag: "name", + getChildByTag: "getChildByName", + removeChildByTag: "getChildByName(name).destroy()" + }); + markAsRemoved(cc.Node, [ "_cascadeColorEnabled", "cascadeColor", "isCascadeColorEnabled", "setCascadeColorEnabled", "_cascadeOpacityEnabled", "cascadeOpacity", "isCascadeOpacityEnabled", "setCascadeOpacityEnabled", "opacityModifyRGB", "isOpacityModifyRGB", "setOpacityModifyRGB", "ignoreAnchor", "isIgnoreAnchorPointForPosition", "ignoreAnchorPointForPosition", "isRunning", "_sgNode" ]); + markFunctionWarning(cc.Node.prototype, { + getNodeToParentTransform: "getLocalMatrix", + getNodeToParentTransformAR: "getLocalMatrix", + getNodeToWorldTransform: "getWorldMatrix", + getNodeToWorldTransformAR: "getWorldMatrix", + getParentToNodeTransform: "getLocalMatrix", + getWorldToNodeTransform: "getWorldMatrix", + convertTouchToNodeSpace: "convertToNodeSpaceAR", + convertTouchToNodeSpaceAR: "convertToNodeSpaceAR", + convertToWorldSpace: "convertToWorldSpaceAR", + convertToNodeSpace: "convertToNodeSpaceAR" + }); + provideClearError(cc.Node.prototype, { + getRotationX: "rotationX", + setRotationX: "rotationX", + getRotationY: "rotationY", + setRotationY: "rotationY", + getPositionX: "x", + setPositionX: "x", + getPositionY: "y", + setPositionY: "y", + getSkewX: "skewX", + setSkewX: "skewX", + getSkewY: "skewY", + setSkewY: "skewY", + getScaleX: "scaleX", + setScaleX: "scaleX", + getScaleY: "scaleY", + setScaleY: "scaleY", + getOpacity: "opacity", + setOpacity: "opacity", + getColor: "color", + setColor: "color", + getLocalZOrder: "zIndex", + setLocalZOrder: "zIndex" + }); + provideClearError(cc.Sprite.prototype, { + setInsetLeft: "cc.SpriteFrame insetLeft", + setInsetRight: "cc.SpriteFrame insetRight", + setInsetTop: "cc.SpriteFrame insetTop", + setInsetBottom: "cc.SpriteFrame insetBottom" + }); + cc.Material.getInstantiatedBuiltinMaterial = cc.MaterialVariant.createWithBuiltin; + cc.Material.getInstantiatedMaterial = cc.MaterialVariant.create; + markFunctionWarning(cc.Material, { + getInstantiatedBuiltinMaterial: "cc.MaterialVariant.createWithBuiltin", + getInstantiatedMaterial: "cc.MaterialVariant.create" + }); + cc.js.getset(cc.RenderComponent.prototype, "sharedMaterials", (function() { + cc.warnID(1400, "sharedMaterials", "getMaterials"); + return this.materials; + }), (function(v) { + cc.warnID(1400, "sharedMaterials", "setMaterial"); + this.materials = v; + })); + markFunctionWarning(cc.Follow.prototype, { + setBoudarySet: "cc.Follow.setBoundarySet" + }); + markFunctionWarning(cc.Camera.prototype, { + getNodeToCameraTransform: "getWorldToScreenMatrix2D", + getCameraToWorldPoint: "getScreenToWorldPoint", + getWorldToCameraPoint: "getWorldToScreenPoint", + getCameraToWorldMatrix: "getScreenToWorldMatrix2D", + getWorldToCameraMatrix: "getWorldToScreenMatrix2D" + }); + markAsRemoved(cc.Camera, [ "addTarget", "removeTarget", "getTargets" ]); + var ERR = '"%s" is not defined in the Scene, it is only defined in normal nodes.'; + false, Object.defineProperties(cc.Scene.prototype, { + active: { + get: function get() { + cc.error(ERR, "active"); + return true; + }, + set: function set() { + cc.error(ERR, "active"); + } + }, + activeInHierarchy: { + get: function get() { + cc.error(ERR, "activeInHierarchy"); + return true; + } + }, + getComponent: { + get: function get() { + cc.error(ERR, "getComponent"); + return function() { + return null; + }; + } + }, + addComponent: { + get: function get() { + cc.error(ERR, "addComponent"); + return function() { + return null; + }; + } + } + }); + markAsRemovedInObject(cc.dynamicAtlasManager, [ "minFrameSize" ], "cc.dynamicAtlasManager"); + cc.Light && markAsRemovedInObject(cc.Light.prototype, [ "shadowDepthScale" ], "cc.Light.prototype"); + provideClearError(cc, { + affineTransformMake: "cc.AffineTransform.create", + affineTransformMakeIdentity: "cc.AffineTransform.identity", + affineTransformClone: "cc.AffineTransform.clone", + affineTransformConcat: "cc.AffineTransform.concat", + affineTransformConcatIn: "cc.AffineTransform.concat", + affineTransformInvert: "cc.AffineTransform.invert", + affineTransformInvertIn: "cc.AffineTransform.invert", + affineTransformInvertOut: "cc.AffineTransform.invert", + affineTransformEqualToTransform: "cc.AffineTransform.equal", + pointApplyAffineTransform: "cc.AffineTransform.transformVec2", + sizeApplyAffineTransform: "cc.AffineTransform.transformSize", + rectApplyAffineTransform: "cc.AffineTransform.transformRect", + obbApplyAffineTransform: "cc.AffineTransform.transformObb", + pointEqualToPoint: "cc.Vec2 equals", + sizeEqualToSize: "cc.Size equals", + rectEqualToRect: "rectA.equals(rectB)", + rectContainsRect: "rectA.containsRect(rectB)", + rectContainsPoint: "rect.contains(vec2)", + rectOverlapsRect: "rectA.intersects(rectB)", + rectIntersectsRect: "rectA.intersects(rectB)", + rectIntersection: "rectA.intersection(intersection, rectB)", + rectUnion: "rectA.union(union, rectB)", + rectGetMaxX: "rect.xMax", + rectGetMidX: "rect.center.x", + rectGetMinX: "rect.xMin", + rectGetMaxY: "rect.yMax", + rectGetMidY: "rect.center.y", + rectGetMinY: "rect.yMin", + colorEqual: "colorA.equals(colorB)", + hexToColor: "color.fromHEX(hexColor)", + colorToHex: "color.toHEX()", + TextAlignment: "cc.macro.TextAlignment", + VerticalTextAlignment: "cc.macro.VerticalTextAlignment", + pNeg: "p.neg()", + pAdd: "p1.add(p2)", + pSub: "p1.sub(p2)", + pMult: "p.mul(factor)", + pMidpoint: "p1.add(p2).mul(0.5)", + pDot: "p1.dot(p2)", + pCross: "p1.cross(p2)", + pPerp: "p.rotate(-90 * Math.PI / 180)", + pRPerp: "p.rotate(90 * Math.PI / 180)", + pProject: "p1.project(p2)", + pLengthSQ: "p.magSqr()", + pDistanceSQ: "p1.sub(p2).magSqr()", + pLength: "p.mag()", + pDistance: "p1.sub(p2).mag()", + pNormalize: "p.normalize()", + pForAngle: "cc.v2(Math.cos(a), Math.sin(a))", + pToAngle: "Math.atan2(v.y, v.x)", + pZeroIn: "p.x = p.y = 0", + pIn: "p1.set(p2)", + pMultIn: "p.mulSelf(factor)", + pSubIn: "p1.subSelf(p2)", + pAddIn: "p1.addSelf(p2)", + pNormalizeIn: "p.normalizeSelf()", + pSameAs: "p1.equals(p2)", + pAngle: "v1.angle(v2)", + pAngleSigned: "v1.signAngle(v2)", + pRotateByAngle: "p.rotate(radians)", + pCompMult: "v1.multiply(v2)", + pFuzzyEqual: "v1.fuzzyEquals(v2, tolerance)", + pLerp: "p.lerp(endPoint, ratio)", + pClamp: "p.clampf(min_inclusive, max_inclusive)", + rand: "Math.random() * 0xffffff", + randomMinus1To1: "(Math.random() - 0.5) * 2", + container: "cc.game.container", + _canvas: "cc.game.canvas", + _renderType: "cc.game.renderType", + _getError: "cc.debug.getError", + _initDebugSetting: "cc.debug._resetDebugSetting", + DebugMode: "cc.debug.DebugMode" + }, "cc"); + markAsRemovedInObject(cc, [ "blendFuncDisable", "pFromSize", "pCompOp", "pIntersectPoint", "pSegmentIntersect", "pLineIntersect", "obbApplyMatrix", "getImageFormatByData", "initEngine" ], "cc"); + markFunctionWarning(cc, { + p: "cc.v2" + }, "cc"); + provideClearError(cc.Rect, { + contain: "rectA.contains(rectB)", + transformMat4: "rect.transformMat4(out, mat4)" + }); + provideClearError(cc.Color, { + rgb2hsv: "color.toHSV()", + hsv2rgb: "color.fromHSV(h, s, v)" + }); + markFunctionWarning(cc.Color, { + fromHex: "cc.Color.fromHEX" + }); + js.get(cc, "lerp", (function() { + cc.errorID(1400, "cc.lerp", "cc.misc.lerp"); + return cc.misc.lerp; + })); + js.get(cc, "random0To1", (function() { + cc.errorID(1400, "cc.random0To1", "Math.random"); + return Math.random; + })); + js.get(cc, "degreesToRadians", (function() { + cc.errorID(1400, "cc.degreesToRadians", "cc.misc.degreesToRadians"); + return cc.misc.degreesToRadians; + })); + js.get(cc, "radiansToDegrees", (function() { + cc.errorID(1400, "cc.radiansToDegrees", "cc.misc.radiansToDegrees"); + return cc.misc.radiansToDegrees; + })); + js.get(cc, "clampf", (function() { + cc.errorID(1400, "cc.clampf", "cc.misc.clampf"); + return cc.misc.clampf; + })); + js.get(cc, "clamp01", (function() { + cc.errorID(1400, "cc.clamp01", "cc.misc.clamp01"); + return cc.misc.clamp01; + })); + js.get(cc, "ImageFormat", (function() { + cc.errorID(1400, "cc.ImageFormat", "cc.macro.ImageFormat"); + return cc.macro.ImageFormat; + })); + js.get(cc, "KEY", (function() { + cc.errorID(1400, "cc.KEY", "cc.macro.KEY"); + return cc.macro.KEY; + })); + js.get(cc, "Easing", (function() { + cc.errorID(1400, "cc.Easing", "cc.easing"); + return cc.easing; + })); + js.get(cc, "isChildClassOf", (function() { + cc.errorID(1400, "cc.isChildClassOf", "cc.js.isChildClassOf"); + return cc.js.isChildClassOf; + })); + "object" === typeof dragonBones && "undefined" !== typeof dragonBones.CCFactory && js.get(dragonBones.CCFactory, "getFactory", (function() { + cc.errorID(1400, "dragonBones.CCFactory.getFactory", "dragonBones.CCFactory.getInstance"); + return dragonBones.CCFactory.getInstance; + })); + cc.renderer.renderEngine = { + get gfx() { + cc.warnID(1400, "cc.renderer.renderEngine.gfx", "cc.gfx"); + return cc.gfx; + }, + get math() { + cc.warnID(1400, "cc.renderer.renderEngine.math", "cc.math"); + return cc.vmath; + }, + get InputAssembler() { + cc.warnID(1400, "cc.renderer.renderEngine.InputAssembler", "cc.renderer.InputAssembler"); + return cc.renderer.InputAssembler; + } + }; + markAsRemovedInObject(cc.audioEngine, [ "getProfile", "preload", "setMaxWebAudioSize" ], "cc.audioEngine"); + }), {} ], + 353: [ (function(require, module, exports) { + "use strict"; + require("./core/CCGame"); + require("./actions"); + }), { + "./actions": 8, + "./core/CCGame": 72 + } ], + 354: [ (function(require, module, exports) { + "use strict"; + var zlib = require("../compression/zlib.min"); + var debug = require("../core/CCDebug"); + var PNGReader = function PNGReader(data) { + var chunkSize, colors, delayDen, delayNum, frame, i, index, key, section, ccshort, text, _i, _j, _ref; + this.data = data; + this.pos = 8; + this.palette = []; + this.imgData = []; + this.transparency = {}; + this.animation = null; + this.text = {}; + frame = null; + while (true) { + chunkSize = this.readUInt32(); + section = function() { + var _i, _results; + _results = []; + for (i = _i = 0; _i < 4; i = ++_i) _results.push(String.fromCharCode(this.data[this.pos++])); + return _results; + }.call(this).join(""); + switch (section) { + case "IHDR": + this.width = this.readUInt32(); + this.height = this.readUInt32(); + this.bits = this.data[this.pos++]; + this.colorType = this.data[this.pos++]; + this.compressionMethod = this.data[this.pos++]; + this.filterMethod = this.data[this.pos++]; + this.interlaceMethod = this.data[this.pos++]; + break; + + case "acTL": + this.animation = { + numFrames: this.readUInt32(), + numPlays: this.readUInt32() || Infinity, + frames: [] + }; + break; + + case "PLTE": + this.palette = this.read(chunkSize); + break; + + case "fcTL": + frame && this.animation.frames.push(frame); + this.pos += 4; + frame = { + width: this.readUInt32(), + height: this.readUInt32(), + xOffset: this.readUInt32(), + yOffset: this.readUInt32() + }; + delayNum = this.readUInt16(); + delayDen = this.readUInt16() || 100; + frame.delay = 1e3 * delayNum / delayDen; + frame.disposeOp = this.data[this.pos++]; + frame.blendOp = this.data[this.pos++]; + frame.data = []; + break; + + case "IDAT": + case "fdAT": + if ("fdAT" === section) { + this.pos += 4; + chunkSize -= 4; + } + data = (null != frame ? frame.data : void 0) || this.imgData; + for (i = _i = 0; 0 <= chunkSize ? _i < chunkSize : _i > chunkSize; i = 0 <= chunkSize ? ++_i : --_i) data.push(this.data[this.pos++]); + break; + + case "tRNS": + this.transparency = {}; + switch (this.colorType) { + case 3: + this.transparency.indexed = this.read(chunkSize); + ccshort = 255 - this.transparency.indexed.length; + if (ccshort > 0) for (i = _j = 0; 0 <= ccshort ? _j < ccshort : _j > ccshort; i = 0 <= ccshort ? ++_j : --_j) this.transparency.indexed.push(255); + break; + + case 0: + this.transparency.grayscale = this.read(chunkSize)[0]; + break; + + case 2: + this.transparency.rgb = this.read(chunkSize); + } + break; + + case "tEXt": + text = this.read(chunkSize); + index = text.indexOf(0); + key = String.fromCharCode.apply(String, text.slice(0, index)); + this.text[key] = String.fromCharCode.apply(String, text.slice(index + 1)); + break; + + case "IEND": + frame && this.animation.frames.push(frame); + this.colors = function() { + switch (this.colorType) { + case 0: + case 3: + case 4: + return 1; + + case 2: + case 6: + return 3; + } + }.call(this); + this.hasAlphaChannel = 4 === (_ref = this.colorType) || 6 === _ref; + colors = this.colors + (this.hasAlphaChannel ? 1 : 0); + this.pixelBitlength = this.bits * colors; + this.colorSpace = function() { + switch (this.colors) { + case 1: + return "DeviceGray"; + + case 3: + return "DeviceRGB"; + } + }.call(this); + Uint8Array != Array && (this.imgData = new Uint8Array(this.imgData)); + return; + + default: + this.pos += chunkSize; + } + this.pos += 4; + if (this.pos > this.data.length) throw new Error(debug.getError(6017)); + } + }; + PNGReader.prototype = { + constructor: PNGReader, + read: function read(bytes) { + var i, _i, _results; + _results = []; + for (i = _i = 0; 0 <= bytes ? _i < bytes : _i > bytes; i = 0 <= bytes ? ++_i : --_i) _results.push(this.data[this.pos++]); + return _results; + }, + readUInt32: function readUInt32() { + var b1, b2, b3, b4; + b1 = this.data[this.pos++] << 24; + b2 = this.data[this.pos++] << 16; + b3 = this.data[this.pos++] << 8; + b4 = this.data[this.pos++]; + return b1 | b2 | b3 | b4; + }, + readUInt16: function readUInt16() { + var b1, b2; + b1 = this.data[this.pos++] << 8; + b2 = this.data[this.pos++]; + return b1 | b2; + }, + decodePixels: function decodePixels(data) { + var ccbyte, c, col, i, left, length, p, pa, paeth, pb, pc, pixelBytes, pixels, pos, row, scanlineLength, upper, upperLeft, _i, _j, _k, _l, _m; + null == data && (data = this.imgData); + if (0 === data.length) return new Uint8Array(0); + var inflate = new zlib.Inflate(data, { + index: 0, + verify: false + }); + data = inflate.decompress(); + pixelBytes = this.pixelBitlength / 8; + scanlineLength = pixelBytes * this.width; + pixels = new Uint8Array(scanlineLength * this.height); + length = data.length; + row = 0; + pos = 0; + c = 0; + while (pos < length) { + switch (data[pos++]) { + case 0: + for (i = _i = 0; _i < scanlineLength; i = _i += 1) pixels[c++] = data[pos++]; + break; + + case 1: + for (i = _j = 0; _j < scanlineLength; i = _j += 1) { + ccbyte = data[pos++]; + left = i < pixelBytes ? 0 : pixels[c - pixelBytes]; + pixels[c++] = (ccbyte + left) % 256; + } + break; + + case 2: + for (i = _k = 0; _k < scanlineLength; i = _k += 1) { + ccbyte = data[pos++]; + col = (i - i % pixelBytes) / pixelBytes; + upper = row && pixels[(row - 1) * scanlineLength + col * pixelBytes + i % pixelBytes]; + pixels[c++] = (upper + ccbyte) % 256; + } + break; + + case 3: + for (i = _l = 0; _l < scanlineLength; i = _l += 1) { + ccbyte = data[pos++]; + col = (i - i % pixelBytes) / pixelBytes; + left = i < pixelBytes ? 0 : pixels[c - pixelBytes]; + upper = row && pixels[(row - 1) * scanlineLength + col * pixelBytes + i % pixelBytes]; + pixels[c++] = (ccbyte + Math.floor((left + upper) / 2)) % 256; + } + break; + + case 4: + for (i = _m = 0; _m < scanlineLength; i = _m += 1) { + ccbyte = data[pos++]; + col = (i - i % pixelBytes) / pixelBytes; + left = i < pixelBytes ? 0 : pixels[c - pixelBytes]; + if (0 === row) upper = upperLeft = 0; else { + upper = pixels[(row - 1) * scanlineLength + col * pixelBytes + i % pixelBytes]; + upperLeft = col && pixels[(row - 1) * scanlineLength + (col - 1) * pixelBytes + i % pixelBytes]; + } + p = left + upper - upperLeft; + pa = Math.abs(p - left); + pb = Math.abs(p - upper); + pc = Math.abs(p - upperLeft); + paeth = pa <= pb && pa <= pc ? left : pb <= pc ? upper : upperLeft; + pixels[c++] = (ccbyte + paeth) % 256; + } + break; + + default: + throw new Error(debug.getError(6018, data[pos - 1])); + } + row++; + } + return pixels; + }, + copyToImageData: function copyToImageData(imageData, pixels) { + var alpha, colors, data, i, input, j, k, length, palette, v, _ref; + colors = this.colors; + palette = null; + alpha = this.hasAlphaChannel; + if (this.palette.length) { + palette = null != (_ref = this._decodedPalette) ? _ref : this._decodedPalette = this.decodePalette(); + colors = 4; + alpha = true; + } + data = imageData.data || imageData; + length = data.length; + input = palette || pixels; + i = j = 0; + if (1 === colors) while (i < length) { + k = palette ? 4 * pixels[i / 4] : j; + v = input[k++]; + data[i++] = v; + data[i++] = v; + data[i++] = v; + data[i++] = alpha ? input[k++] : 255; + j = k; + } else while (i < length) { + k = palette ? 4 * pixels[i / 4] : j; + data[i++] = input[k++]; + data[i++] = input[k++]; + data[i++] = input[k++]; + data[i++] = alpha ? input[k++] : 255; + j = k; + } + }, + decodePalette: function decodePalette() { + var c, i, palette, pos, ret, transparency, _i, _ref, _ref1; + palette = this.palette; + transparency = this.transparency.indexed || []; + ret = new Uint8Array((transparency.length || 0) + palette.length); + pos = 0; + c = 0; + for (i = _i = 0, _ref = palette.length; _i < _ref; i = _i += 3) { + ret[pos++] = palette[i]; + ret[pos++] = palette[i + 1]; + ret[pos++] = palette[i + 2]; + ret[pos++] = null != (_ref1 = transparency[c++]) ? _ref1 : 255; + } + return ret; + }, + render: function render(canvas) { + var ctx, data; + canvas.width = this.width; + canvas.height = this.height; + ctx = canvas.getContext("2d"); + data = ctx.createImageData(this.width, this.height); + this.copyToImageData(data, this.decodePixels()); + return ctx.putImageData(data, 0, 0); + } + }; + module.exports = PNGReader; + }), { + "../compression/zlib.min": 26, + "../core/CCDebug": 70 + } ], + 355: [ (function(require, module, exports) { + "use strict"; + var Asset = require("../core/assets/CCAsset"); + var CCSpriteFrame = require("../core/assets/CCSpriteFrame"); + var ParticleAsset = cc.Class({ + name: "cc.ParticleAsset", + extends: Asset, + properties: { + spriteFrame: { + default: null, + type: CCSpriteFrame + } + } + }); + cc.ParticleAsset = module.exports = ParticleAsset; + }), { + "../core/assets/CCAsset": 106, + "../core/assets/CCSpriteFrame": 118 + } ], + 356: [ (function(require, module, exports) { + "use strict"; + var macro = require("../core/platform/CCMacro"); + var ParticleAsset = require("./CCParticleAsset"); + var RenderComponent = require("../core/components/CCRenderComponent"); + var codec = require("../compression/ZipUtils"); + var PNGReader = require("./CCPNGReader"); + var tiffReader = require("./CCTIFFReader"); + var textureUtil = require("../core/utils/texture-util"); + var RenderFlow = require("../core/renderer/render-flow"); + var ParticleSimulator = require("./particle-simulator"); + var Material = require("../core/assets/material/CCMaterial"); + var BlendFunc = require("../core/utils/blend-func"); + function getImageFormatByData(imgData) { + if (imgData.length > 8 && 137 === imgData[0] && 80 === imgData[1] && 78 === imgData[2] && 71 === imgData[3] && 13 === imgData[4] && 10 === imgData[5] && 26 === imgData[6] && 10 === imgData[7]) return macro.ImageFormat.PNG; + if (imgData.length > 2 && (73 === imgData[0] && 73 === imgData[1] || 77 === imgData[0] && 77 === imgData[1] || 255 === imgData[0] && 216 === imgData[1])) return macro.ImageFormat.TIFF; + return macro.ImageFormat.UNKNOWN; + } + function getParticleComponents(node) { + var parent = node.parent, comp = node.getComponent(cc.ParticleSystem); + if (!parent || !comp) return node.getComponentsInChildren(cc.ParticleSystem); + return getParticleComponents(parent); + } + var EmitterMode = cc.Enum({ + GRAVITY: 0, + RADIUS: 1 + }); + var PositionType = cc.Enum({ + FREE: 0, + RELATIVE: 1, + GROUPED: 2 + }); + var properties = { + preview: { + default: true, + editorOnly: true, + notify: false, + animatable: false, + tooltip: false + }, + _custom: false, + custom: { + get: function get() { + return this._custom; + }, + set: function set(value) { + false; + if (this._custom !== value) { + this._custom = value; + this._applyFile(); + false; + } + }, + animatable: false, + tooltip: false + }, + _file: { + default: null, + type: ParticleAsset + }, + file: { + get: function get() { + return this._file; + }, + set: function set(value, force) { + if (this._file !== value || false) { + this._file = value; + if (value) { + this._applyFile(); + false; + } else this.custom = true; + } + }, + animatable: false, + type: ParticleAsset, + tooltip: false + }, + _spriteFrame: { + default: null, + type: cc.SpriteFrame + }, + spriteFrame: { + get: function get() { + return this._spriteFrame; + }, + set: function set(value, force) { + var lastSprite = this._renderSpriteFrame; + false; + if (lastSprite === value) return; + this._renderSpriteFrame = value; + value && !value._uuid || (this._spriteFrame = value); + this._applySpriteFrame(lastSprite); + false; + }, + type: cc.SpriteFrame, + tooltip: false + }, + _texture: { + default: null, + type: cc.Texture2D, + editorOnly: true + }, + texture: { + get: function get() { + return this._getTexture(); + }, + set: function set(value) { + value && cc.warnID(6017); + }, + type: cc.Texture2D, + tooltip: false, + readonly: true, + visible: false, + animatable: false + }, + particleCount: { + visible: false, + get: function get() { + return this._simulator.particles.length; + }, + readonly: true + }, + _stopped: true, + stopped: { + get: function get() { + return this._stopped; + }, + animatable: false, + visible: false + }, + playOnLoad: true, + autoRemoveOnFinish: { + default: false, + animatable: false, + tooltip: false + }, + active: { + get: function get() { + return this._simulator.active; + }, + visible: false + }, + totalParticles: 150, + duration: -1, + emissionRate: 10, + life: 1, + lifeVar: 0, + _startColor: null, + startColor: { + type: cc.Color, + get: function get() { + return this._startColor; + }, + set: function set(val) { + this._startColor.r = val.r; + this._startColor.g = val.g; + this._startColor.b = val.b; + this._startColor.a = val.a; + } + }, + _startColorVar: null, + startColorVar: { + type: cc.Color, + get: function get() { + return this._startColorVar; + }, + set: function set(val) { + this._startColorVar.r = val.r; + this._startColorVar.g = val.g; + this._startColorVar.b = val.b; + this._startColorVar.a = val.a; + } + }, + _endColor: null, + endColor: { + type: cc.Color, + get: function get() { + return this._endColor; + }, + set: function set(val) { + this._endColor.r = val.r; + this._endColor.g = val.g; + this._endColor.b = val.b; + this._endColor.a = val.a; + } + }, + _endColorVar: null, + endColorVar: { + type: cc.Color, + get: function get() { + return this._endColorVar; + }, + set: function set(val) { + this._endColorVar.r = val.r; + this._endColorVar.g = val.g; + this._endColorVar.b = val.b; + this._endColorVar.a = val.a; + } + }, + angle: 90, + angleVar: 20, + startSize: 50, + startSizeVar: 0, + endSize: 0, + endSizeVar: 0, + startSpin: 0, + startSpinVar: 0, + endSpin: 0, + endSpinVar: 0, + sourcePos: cc.Vec2.ZERO, + posVar: cc.Vec2.ZERO, + _positionType: { + default: PositionType.FREE, + formerlySerializedAs: "positionType" + }, + positionType: { + type: PositionType, + get: function get() { + return this._positionType; + }, + set: function set(val) { + this._positionType = val; + this._updateMaterial(); + } + }, + emitterMode: { + default: EmitterMode.GRAVITY, + type: EmitterMode + }, + gravity: cc.Vec2.ZERO, + speed: 180, + speedVar: 50, + tangentialAccel: 80, + tangentialAccelVar: 0, + radialAccel: 0, + radialAccelVar: 0, + rotationIsDir: false, + startRadius: 0, + startRadiusVar: 0, + endRadius: 0, + endRadiusVar: 0, + rotatePerS: 0, + rotatePerSVar: 0 + }; + var ParticleSystem = cc.Class({ + name: "cc.ParticleSystem", + extends: RenderComponent, + mixins: [ BlendFunc ], + editor: false, + ctor: function ctor() { + this.initProperties(); + }, + initProperties: function initProperties() { + this._previewTimer = null; + this._focused = false; + this._aspectRatio = 1; + this._simulator = new ParticleSimulator(this); + this._startColor = cc.color(255, 255, 255, 255); + this._startColorVar = cc.color(0, 0, 0, 0); + this._endColor = cc.color(255, 255, 255, 0); + this._endColorVar = cc.color(0, 0, 0, 0); + this._renderSpriteFrame = null; + }, + properties: properties, + statics: { + DURATION_INFINITY: -1, + START_SIZE_EQUAL_TO_END_SIZE: -1, + START_RADIUS_EQUAL_TO_END_RADIUS: -1, + EmitterMode: EmitterMode, + PositionType: PositionType, + _PNGReader: PNGReader, + _TIFFReader: tiffReader + }, + onFocusInEditor: false, + onLostFocusInEditor: false, + _startPreview: false, + _stopPreview: false, + _convertTextureToSpriteFrame: false, + __preload: function __preload() { + this._super(); + false; + if (this._custom && this.spriteFrame && !this._renderSpriteFrame) this._applySpriteFrame(this.spriteFrame); else if (this._file) if (this._custom) { + var missCustomTexture = !this._getTexture(); + missCustomTexture && this._applyFile(); + } else this._applyFile(); + true; + this.playOnLoad && this.resetSystem(); + false; + }, + onDestroy: function onDestroy() { + this.autoRemoveOnFinish && (this.autoRemoveOnFinish = false); + if (this._buffer) { + this._buffer.destroy(); + this._buffer = null; + } + this._simulator._uvFilled = 0; + this._super(); + }, + lateUpdate: function lateUpdate(dt) { + this._simulator.finished || this._simulator.step(dt); + }, + addParticle: function addParticle() {}, + stopSystem: function stopSystem() { + this._stopped = true; + this._simulator.stop(); + }, + resetSystem: function resetSystem() { + this._stopped = false; + this._simulator.reset(); + this.markForRender(true); + }, + isFull: function isFull() { + return this.particleCount >= this.totalParticles; + }, + setTextureWithRect: function setTextureWithRect(texture, rect) { + texture instanceof cc.Texture2D && (this.spriteFrame = new cc.SpriteFrame(texture, rect)); + }, + _applyFile: function _applyFile() { + var file = this._file; + if (file) { + var self = this; + cc.assetManager.postLoadNative(file, (function(err) { + if (err || !file._nativeAsset) { + cc.errorID(6029); + return; + } + if (!self.isValid) return; + self._plistFile = file.nativeUrl; + if (!self._custom) { + var isDiffFrame = self._spriteFrame !== file.spriteFrame; + isDiffFrame && (self.spriteFrame = file.spriteFrame); + self._initWithDictionary(file._nativeAsset); + } + self._spriteFrame ? !self._renderSpriteFrame && self._spriteFrame && self._applySpriteFrame(self.spriteFrame) : file.spriteFrame ? self.spriteFrame = file.spriteFrame : self._custom && self._initTextureWithDictionary(file._nativeAsset); + })); + } + }, + _initTextureWithDictionary: function _initTextureWithDictionary(dict) { + var imgPath = cc.path.changeBasename(this._plistFile, dict["textureFileName"] || ""); + if (dict["textureFileName"]) textureUtil.loadImage(imgPath, (function(error, texture) { + if (error) { + dict["textureFileName"] = void 0; + this._initTextureWithDictionary(dict); + } else { + cc.assetManager.assets.add(imgPath, texture); + this.spriteFrame = new cc.SpriteFrame(texture); + } + }), this); else if (dict["textureImageData"]) { + var textureData = dict["textureImageData"]; + if (!(textureData && textureData.length > 0)) return false; + var tex = cc.assetManager.assets.get(imgPath); + if (!tex) { + var buffer = codec.unzipBase64AsArray(textureData, 1); + if (!buffer) { + cc.warnID(6030, this._file.name); + return false; + } + var imageFormat = getImageFormatByData(buffer); + if (imageFormat !== macro.ImageFormat.TIFF && imageFormat !== macro.ImageFormat.PNG) { + cc.warnID(6031, this._file.name); + return false; + } + var canvasObj = document.createElement("canvas"); + if (imageFormat === macro.ImageFormat.PNG) { + var myPngObj = new PNGReader(buffer); + myPngObj.render(canvasObj); + } else tiffReader.parseTIFF(buffer, canvasObj); + tex = textureUtil.cacheImage(imgPath, canvasObj); + } + tex || cc.warnID(6032, this._file.name); + this.spriteFrame = new cc.SpriteFrame(tex); + } + return true; + }, + _initWithDictionary: function _initWithDictionary(dict) { + this.totalParticles = parseInt(dict["maxParticles"] || 0); + this.life = parseFloat(dict["particleLifespan"] || 0); + this.lifeVar = parseFloat(dict["particleLifespanVariance"] || 0); + var _tempEmissionRate = dict["emissionRate"]; + this.emissionRate = _tempEmissionRate || Math.min(this.totalParticles / this.life, Number.MAX_VALUE); + this.duration = parseFloat(dict["duration"] || 0); + this.srcBlendFactor = parseInt(dict["blendFuncSource"] || macro.SRC_ALPHA); + this.dstBlendFactor = parseInt(dict["blendFuncDestination"] || macro.ONE_MINUS_SRC_ALPHA); + var locStartColor = this._startColor; + locStartColor.r = 255 * parseFloat(dict["startColorRed"] || 0); + locStartColor.g = 255 * parseFloat(dict["startColorGreen"] || 0); + locStartColor.b = 255 * parseFloat(dict["startColorBlue"] || 0); + locStartColor.a = 255 * parseFloat(dict["startColorAlpha"] || 0); + var locStartColorVar = this._startColorVar; + locStartColorVar.r = 255 * parseFloat(dict["startColorVarianceRed"] || 0); + locStartColorVar.g = 255 * parseFloat(dict["startColorVarianceGreen"] || 0); + locStartColorVar.b = 255 * parseFloat(dict["startColorVarianceBlue"] || 0); + locStartColorVar.a = 255 * parseFloat(dict["startColorVarianceAlpha"] || 0); + var locEndColor = this._endColor; + locEndColor.r = 255 * parseFloat(dict["finishColorRed"] || 0); + locEndColor.g = 255 * parseFloat(dict["finishColorGreen"] || 0); + locEndColor.b = 255 * parseFloat(dict["finishColorBlue"] || 0); + locEndColor.a = 255 * parseFloat(dict["finishColorAlpha"] || 0); + var locEndColorVar = this._endColorVar; + locEndColorVar.r = 255 * parseFloat(dict["finishColorVarianceRed"] || 0); + locEndColorVar.g = 255 * parseFloat(dict["finishColorVarianceGreen"] || 0); + locEndColorVar.b = 255 * parseFloat(dict["finishColorVarianceBlue"] || 0); + locEndColorVar.a = 255 * parseFloat(dict["finishColorVarianceAlpha"] || 0); + this.startSize = parseFloat(dict["startParticleSize"] || 0); + this.startSizeVar = parseFloat(dict["startParticleSizeVariance"] || 0); + this.endSize = parseFloat(dict["finishParticleSize"] || 0); + this.endSizeVar = parseFloat(dict["finishParticleSizeVariance"] || 0); + this.positionType = parseFloat(void 0 !== dict["positionType"] ? dict["positionType"] : PositionType.RELATIVE); + this.sourcePos.x = 0; + this.sourcePos.y = 0; + this.posVar.x = parseFloat(dict["sourcePositionVariancex"] || 0); + this.posVar.y = parseFloat(dict["sourcePositionVariancey"] || 0); + this.angle = parseFloat(dict["angle"] || 0); + this.angleVar = parseFloat(dict["angleVariance"] || 0); + this.startSpin = parseFloat(dict["rotationStart"] || 0); + this.startSpinVar = parseFloat(dict["rotationStartVariance"] || 0); + this.endSpin = parseFloat(dict["rotationEnd"] || 0); + this.endSpinVar = parseFloat(dict["rotationEndVariance"] || 0); + this.emitterMode = parseInt(dict["emitterType"] || EmitterMode.GRAVITY); + if (this.emitterMode === EmitterMode.GRAVITY) { + this.gravity.x = parseFloat(dict["gravityx"] || 0); + this.gravity.y = parseFloat(dict["gravityy"] || 0); + this.speed = parseFloat(dict["speed"] || 0); + this.speedVar = parseFloat(dict["speedVariance"] || 0); + this.radialAccel = parseFloat(dict["radialAcceleration"] || 0); + this.radialAccelVar = parseFloat(dict["radialAccelVariance"] || 0); + this.tangentialAccel = parseFloat(dict["tangentialAcceleration"] || 0); + this.tangentialAccelVar = parseFloat(dict["tangentialAccelVariance"] || 0); + var locRotationIsDir = dict["rotationIsDir"] || ""; + if (null !== locRotationIsDir) { + locRotationIsDir = locRotationIsDir.toString().toLowerCase(); + this.rotationIsDir = "true" === locRotationIsDir || "1" === locRotationIsDir; + } else this.rotationIsDir = false; + } else { + if (this.emitterMode !== EmitterMode.RADIUS) { + cc.warnID(6009); + return false; + } + this.startRadius = parseFloat(dict["maxRadius"] || 0); + this.startRadiusVar = parseFloat(dict["maxRadiusVariance"] || 0); + this.endRadius = parseFloat(dict["minRadius"] || 0); + this.endRadiusVar = parseFloat(dict["minRadiusVariance"] || 0); + this.rotatePerS = parseFloat(dict["rotatePerSecond"] || 0); + this.rotatePerSVar = parseFloat(dict["rotatePerSecondVariance"] || 0); + } + this._initTextureWithDictionary(dict); + return true; + }, + _validateRender: function _validateRender() { + var texture = this._getTexture(); + if (!texture || !texture.loaded) { + this.disableRender(); + return; + } + this._super(); + }, + _onTextureLoaded: function _onTextureLoaded() { + this._simulator.updateUVs(true); + this._syncAspect(); + this._updateMaterial(); + this.markForRender(true); + }, + _syncAspect: function _syncAspect() { + var frameRect = this._renderSpriteFrame._rect; + this._aspectRatio = frameRect.width / frameRect.height; + }, + _applySpriteFrame: function _applySpriteFrame() { + this._renderSpriteFrame = this._renderSpriteFrame || this._spriteFrame; + this._renderSpriteFrame && (this._renderSpriteFrame.textureLoaded() ? this._onTextureLoaded() : this._renderSpriteFrame.onTextureLoaded(this._onTextureLoaded, this)); + }, + _getTexture: function _getTexture() { + return this._renderSpriteFrame && this._renderSpriteFrame.getTexture() || this._texture; + }, + _updateMaterial: function _updateMaterial() { + var material = this.getMaterial(0); + if (!material) return; + material.define("CC_USE_MODEL", this._positionType !== PositionType.FREE); + material.setProperty("texture", this._getTexture()); + BlendFunc.prototype._updateMaterial.call(this); + }, + _finishedSimulation: function _finishedSimulation() { + false; + this.resetSystem(); + this.stopSystem(); + this.disableRender(); + this.autoRemoveOnFinish && this._stopped && this.node.destroy(); + } + }); + cc.ParticleSystem = module.exports = ParticleSystem; + }), { + "../compression/ZipUtils": 23, + "../core/assets/material/CCMaterial": 125, + "../core/components/CCRenderComponent": 161, + "../core/platform/CCMacro": 245, + "../core/renderer/render-flow": 273, + "../core/utils/blend-func": 319, + "../core/utils/texture-util": 333, + "./CCPNGReader": 354, + "./CCParticleAsset": 355, + "./CCTIFFReader": 357, + "./particle-simulator": 359, + "fire-url": void 0 + } ], + 357: [ (function(require, module, exports) { + "use strict"; + var debug = require("../core/CCDebug"); + var tiffReader = { + _littleEndian: false, + _tiffData: null, + _fileDirectories: [], + getUint8: function getUint8(offset) { + return this._tiffData[offset]; + }, + getUint16: function getUint16(offset) { + return this._littleEndian ? this._tiffData[offset + 1] << 8 | this._tiffData[offset] : this._tiffData[offset] << 8 | this._tiffData[offset + 1]; + }, + getUint32: function getUint32(offset) { + var a = this._tiffData; + return this._littleEndian ? a[offset + 3] << 24 | a[offset + 2] << 16 | a[offset + 1] << 8 | a[offset] : a[offset] << 24 | a[offset + 1] << 16 | a[offset + 2] << 8 | a[offset + 3]; + }, + checkLittleEndian: function checkLittleEndian() { + var BOM = this.getUint16(0); + if (18761 === BOM) this.littleEndian = true; else { + if (19789 !== BOM) { + console.log(BOM); + throw TypeError(debug.getError(6019)); + } + this.littleEndian = false; + } + return this.littleEndian; + }, + hasTowel: function hasTowel() { + if (42 !== this.getUint16(2)) throw RangeError(debug.getError(6020)); + return true; + }, + getFieldTypeName: function getFieldTypeName(fieldType) { + var typeNames = this.fieldTypeNames; + if (fieldType in typeNames) return typeNames[fieldType]; + return null; + }, + getFieldTagName: function getFieldTagName(fieldTag) { + var tagNames = this.fieldTagNames; + if (fieldTag in tagNames) return tagNames[fieldTag]; + cc.logID(6021, fieldTag); + return "Tag" + fieldTag; + }, + getFieldTypeLength: function getFieldTypeLength(fieldTypeName) { + if (-1 !== [ "BYTE", "ASCII", "SBYTE", "UNDEFINED" ].indexOf(fieldTypeName)) return 1; + if (-1 !== [ "SHORT", "SSHORT" ].indexOf(fieldTypeName)) return 2; + if (-1 !== [ "LONG", "SLONG", "FLOAT" ].indexOf(fieldTypeName)) return 4; + if (-1 !== [ "RATIONAL", "SRATIONAL", "DOUBLE" ].indexOf(fieldTypeName)) return 8; + return null; + }, + getFieldValues: function getFieldValues(fieldTagName, fieldTypeName, typeCount, valueOffset) { + var fieldValues = []; + var fieldTypeLength = this.getFieldTypeLength(fieldTypeName); + var fieldValueSize = fieldTypeLength * typeCount; + if (fieldValueSize <= 4) false === this.littleEndian ? fieldValues.push(valueOffset >>> 8 * (4 - fieldTypeLength)) : fieldValues.push(valueOffset); else for (var i = 0; i < typeCount; i++) { + var indexOffset = fieldTypeLength * i; + if (fieldTypeLength >= 8) if (-1 !== [ "RATIONAL", "SRATIONAL" ].indexOf(fieldTypeName)) { + fieldValues.push(this.getUint32(valueOffset + indexOffset)); + fieldValues.push(this.getUint32(valueOffset + indexOffset + 4)); + } else cc.logID(8e3); else fieldValues.push(this.getBytes(fieldTypeLength, valueOffset + indexOffset)); + } + "ASCII" === fieldTypeName && fieldValues.forEach((function(e, i, a) { + a[i] = String.fromCharCode(e); + })); + return fieldValues; + }, + getBytes: function getBytes(numBytes, offset) { + if (numBytes <= 0) cc.logID(8001); else { + if (numBytes <= 1) return this.getUint8(offset); + if (numBytes <= 2) return this.getUint16(offset); + if (numBytes <= 3) return this.getUint32(offset) >>> 8; + if (numBytes <= 4) return this.getUint32(offset); + cc.logID(8002); + } + }, + getBits: function getBits(numBits, byteOffset, bitOffset) { + bitOffset = bitOffset || 0; + var extraBytes = Math.floor(bitOffset / 8); + var newByteOffset = byteOffset + extraBytes; + var totalBits = bitOffset + numBits; + var shiftRight = 32 - numBits; + var shiftLeft, rawBits; + if (totalBits <= 0) cc.logID(6023); else if (totalBits <= 8) { + shiftLeft = 24 + bitOffset; + rawBits = this.getUint8(newByteOffset); + } else if (totalBits <= 16) { + shiftLeft = 16 + bitOffset; + rawBits = this.getUint16(newByteOffset); + } else if (totalBits <= 32) { + shiftLeft = bitOffset; + rawBits = this.getUint32(newByteOffset); + } else cc.logID(6022); + return { + bits: rawBits << shiftLeft >>> shiftRight, + byteOffset: newByteOffset + Math.floor(totalBits / 8), + bitOffset: totalBits % 8 + }; + }, + parseFileDirectory: function parseFileDirectory(byteOffset) { + var numDirEntries = this.getUint16(byteOffset); + var tiffFields = []; + for (var i = byteOffset + 2, entryCount = 0; entryCount < numDirEntries; i += 12, + entryCount++) { + var fieldTag = this.getUint16(i); + var fieldType = this.getUint16(i + 2); + var typeCount = this.getUint32(i + 4); + var valueOffset = this.getUint32(i + 8); + var fieldTagName = this.getFieldTagName(fieldTag); + var fieldTypeName = this.getFieldTypeName(fieldType); + var fieldValues = this.getFieldValues(fieldTagName, fieldTypeName, typeCount, valueOffset); + tiffFields[fieldTagName] = { + type: fieldTypeName, + values: fieldValues + }; + } + this._fileDirectories.push(tiffFields); + var nextIFDByteOffset = this.getUint32(i); + 0 !== nextIFDByteOffset && this.parseFileDirectory(nextIFDByteOffset); + }, + clampColorSample: function clampColorSample(colorSample, bitsPerSample) { + var multiplier = Math.pow(2, 8 - bitsPerSample); + return Math.floor(colorSample * multiplier + (multiplier - 1)); + }, + parseTIFF: function parseTIFF(tiffData, canvas) { + canvas = canvas || document.createElement("canvas"); + this._tiffData = tiffData; + this.canvas = canvas; + this.checkLittleEndian(); + if (!this.hasTowel()) return; + var firstIFDByteOffset = this.getUint32(4); + this._fileDirectories.length = 0; + this.parseFileDirectory(firstIFDByteOffset); + var fileDirectory = this._fileDirectories[0]; + var imageWidth = fileDirectory["ImageWidth"].values[0]; + var imageLength = fileDirectory["ImageLength"].values[0]; + this.canvas.width = imageWidth; + this.canvas.height = imageLength; + var strips = []; + var compression = fileDirectory["Compression"] ? fileDirectory["Compression"].values[0] : 1; + var samplesPerPixel = fileDirectory["SamplesPerPixel"].values[0]; + var sampleProperties = []; + var bitsPerPixel = 0; + var hasBytesPerPixel = false; + fileDirectory["BitsPerSample"].values.forEach((function(bitsPerSample, i, bitsPerSampleValues) { + sampleProperties[i] = { + bitsPerSample: bitsPerSample, + hasBytesPerSample: false, + bytesPerSample: void 0 + }; + if (bitsPerSample % 8 === 0) { + sampleProperties[i].hasBytesPerSample = true; + sampleProperties[i].bytesPerSample = bitsPerSample / 8; + } + bitsPerPixel += bitsPerSample; + }), this); + if (bitsPerPixel % 8 === 0) { + hasBytesPerPixel = true; + var bytesPerPixel = bitsPerPixel / 8; + } + var stripOffsetValues = fileDirectory["StripOffsets"].values; + var numStripOffsetValues = stripOffsetValues.length; + if (fileDirectory["StripByteCounts"]) var stripByteCountValues = fileDirectory["StripByteCounts"].values; else { + cc.logID(8003); + if (1 !== numStripOffsetValues) throw Error(debug.getError(6024)); + var stripByteCountValues = [ Math.ceil(imageWidth * imageLength * bitsPerPixel / 8) ]; + } + for (var i = 0; i < numStripOffsetValues; i++) { + var stripOffset = stripOffsetValues[i]; + strips[i] = []; + var stripByteCount = stripByteCountValues[i]; + for (var byteOffset = 0, bitOffset = 0, jIncrement = 1, getHeader = true, pixel = [], numBytes = 0, sample = 0, currentSample = 0; byteOffset < stripByteCount; byteOffset += jIncrement) switch (compression) { + case 1: + for (var m = 0, pixel = []; m < samplesPerPixel; m++) { + if (!sampleProperties[m].hasBytesPerSample) { + var sampleInfo = this.getBits(sampleProperties[m].bitsPerSample, stripOffset + byteOffset, bitOffset); + pixel.push(sampleInfo.bits); + byteOffset = sampleInfo.byteOffset - stripOffset; + bitOffset = sampleInfo.bitOffset; + throw RangeError(debug.getError(6025)); + } + var sampleOffset = sampleProperties[m].bytesPerSample * m; + pixel.push(this.getBytes(sampleProperties[m].bytesPerSample, stripOffset + byteOffset + sampleOffset)); + } + strips[i].push(pixel); + if (!hasBytesPerPixel) { + jIncrement = 0; + throw RangeError(debug.getError(6026)); + } + jIncrement = bytesPerPixel; + break; + + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + break; + + case 32773: + if (getHeader) { + getHeader = false; + var blockLength = 1; + var iterations = 1; + var header = this.getInt8(stripOffset + byteOffset); + header >= 0 && header <= 127 ? blockLength = header + 1 : header >= -127 && header <= -1 ? iterations = 1 - header : getHeader = true; + } else { + var currentByte = this.getUint8(stripOffset + byteOffset); + for (var m = 0; m < iterations; m++) { + if (!sampleProperties[sample].hasBytesPerSample) throw RangeError(debug.getError(6025)); + currentSample = currentSample << 8 * numBytes | currentByte; + numBytes++; + if (numBytes === sampleProperties[sample].bytesPerSample) { + pixel.push(currentSample); + currentSample = numBytes = 0; + sample++; + } + if (sample === samplesPerPixel) { + strips[i].push(pixel); + pixel = []; + sample = 0; + } + } + blockLength--; + 0 === blockLength && (getHeader = true); + } + jIncrement = 1; + } + } + if (canvas.getContext) { + var ctx = this.canvas.getContext("2d"); + ctx.fillStyle = "rgba(255, 255, 255, 0)"; + var rowsPerStrip = fileDirectory["RowsPerStrip"] ? fileDirectory["RowsPerStrip"].values[0] : imageLength; + var numStrips = strips.length; + var imageLengthModRowsPerStrip = imageLength % rowsPerStrip; + var rowsInLastStrip = 0 === imageLengthModRowsPerStrip ? rowsPerStrip : imageLengthModRowsPerStrip; + var numRowsInStrip = rowsPerStrip; + var numRowsInPreviousStrip = 0; + var photometricInterpretation = fileDirectory["PhotometricInterpretation"].values[0]; + var extraSamplesValues = []; + var numExtraSamples = 0; + if (fileDirectory["ExtraSamples"]) { + extraSamplesValues = fileDirectory["ExtraSamples"].values; + numExtraSamples = extraSamplesValues.length; + } + if (fileDirectory["ColorMap"]) { + var colorMapValues = fileDirectory["ColorMap"].values; + var colorMapSampleSize = Math.pow(2, sampleProperties[0].bitsPerSample); + } + for (var i = 0; i < numStrips; i++) { + i + 1 === numStrips && (numRowsInStrip = rowsInLastStrip); + var numPixels = strips[i].length; + var yPadding = numRowsInPreviousStrip * i; + for (var y = 0, j = 0; y < numRowsInStrip, j < numPixels; y++) for (var x = 0; x < imageWidth; x++, + j++) { + var pixelSamples = strips[i][j]; + var red = 0; + var green = 0; + var blue = 0; + var opacity = 1; + if (numExtraSamples > 0) for (var k = 0; k < numExtraSamples; k++) if (1 === extraSamplesValues[k] || 2 === extraSamplesValues[k]) { + opacity = pixelSamples[3 + k] / 256; + break; + } + switch (photometricInterpretation) { + case 0: + if (sampleProperties[0].hasBytesPerSample) var invertValue = Math.pow(16, 2 * sampleProperties[0].bytesPerSample); + pixelSamples.forEach((function(sample, index, samples) { + samples[index] = invertValue - sample; + })); + + case 1: + red = green = blue = this.clampColorSample(pixelSamples[0], sampleProperties[0].bitsPerSample); + break; + + case 2: + red = this.clampColorSample(pixelSamples[0], sampleProperties[0].bitsPerSample); + green = this.clampColorSample(pixelSamples[1], sampleProperties[1].bitsPerSample); + blue = this.clampColorSample(pixelSamples[2], sampleProperties[2].bitsPerSample); + break; + + case 3: + if (void 0 === colorMapValues) throw Error(debug.getError(6027)); + var colorMapIndex = pixelSamples[0]; + red = this.clampColorSample(colorMapValues[colorMapIndex], 16); + green = this.clampColorSample(colorMapValues[colorMapSampleSize + colorMapIndex], 16); + blue = this.clampColorSample(colorMapValues[2 * colorMapSampleSize + colorMapIndex], 16); + break; + + default: + throw RangeError(debug.getError(6028, photometricInterpretation)); + } + ctx.fillStyle = "rgba(" + red + ", " + green + ", " + blue + ", " + opacity + ")"; + ctx.fillRect(x, yPadding + y, 1, 1); + } + numRowsInPreviousStrip = numRowsInStrip; + } + } + return this.canvas; + }, + fieldTagNames: { + 315: "Artist", + 258: "BitsPerSample", + 265: "CellLength", + 264: "CellWidth", + 320: "ColorMap", + 259: "Compression", + 33432: "Copyright", + 306: "DateTime", + 338: "ExtraSamples", + 266: "FillOrder", + 289: "FreeByteCounts", + 288: "FreeOffsets", + 291: "GrayResponseCurve", + 290: "GrayResponseUnit", + 316: "HostComputer", + 270: "ImageDescription", + 257: "ImageLength", + 256: "ImageWidth", + 271: "Make", + 281: "MaxSampleValue", + 280: "MinSampleValue", + 272: "Model", + 254: "NewSubfileType", + 274: "Orientation", + 262: "PhotometricInterpretation", + 284: "PlanarConfiguration", + 296: "ResolutionUnit", + 278: "RowsPerStrip", + 277: "SamplesPerPixel", + 305: "Software", + 279: "StripByteCounts", + 273: "StripOffsets", + 255: "SubfileType", + 263: "Threshholding", + 282: "XResolution", + 283: "YResolution", + 326: "BadFaxLines", + 327: "CleanFaxData", + 343: "ClipPath", + 328: "ConsecutiveBadFaxLines", + 433: "Decode", + 434: "DefaultImageColor", + 269: "DocumentName", + 336: "DotRange", + 321: "HalftoneHints", + 346: "Indexed", + 347: "JPEGTables", + 285: "PageName", + 297: "PageNumber", + 317: "Predictor", + 319: "PrimaryChromaticities", + 532: "ReferenceBlackWhite", + 339: "SampleFormat", + 559: "StripRowCounts", + 330: "SubIFDs", + 292: "T4Options", + 293: "T6Options", + 325: "TileByteCounts", + 323: "TileLength", + 324: "TileOffsets", + 322: "TileWidth", + 301: "TransferFunction", + 318: "WhitePoint", + 344: "XClipPathUnits", + 286: "XPosition", + 529: "YCbCrCoefficients", + 531: "YCbCrPositioning", + 530: "YCbCrSubSampling", + 345: "YClipPathUnits", + 287: "YPosition", + 37378: "ApertureValue", + 40961: "ColorSpace", + 36868: "DateTimeDigitized", + 36867: "DateTimeOriginal", + 34665: "Exif IFD", + 36864: "ExifVersion", + 33434: "ExposureTime", + 41728: "FileSource", + 37385: "Flash", + 40960: "FlashpixVersion", + 33437: "FNumber", + 42016: "ImageUniqueID", + 37384: "LightSource", + 37500: "MakerNote", + 37377: "ShutterSpeedValue", + 37510: "UserComment", + 33723: "IPTC", + 34675: "ICC Profile", + 700: "XMP", + 42112: "GDAL_METADATA", + 42113: "GDAL_NODATA", + 34377: "Photoshop" + }, + fieldTypeNames: { + 1: "BYTE", + 2: "ASCII", + 3: "SHORT", + 4: "LONG", + 5: "RATIONAL", + 6: "SBYTE", + 7: "UNDEFINED", + 8: "SSHORT", + 9: "SLONG", + 10: "SRATIONAL", + 11: "FLOAT", + 12: "DOUBLE" + } + }; + module.exports = tiffReader; + }), { + "../core/CCDebug": 70 + } ], + 358: [ (function(require, module, exports) { + "use strict"; + require("./CCParticleAsset"); + require("./CCParticleSystem"); + require("./particle-simulator"); + require("./particle-system-assembler"); + }), { + "./CCParticleAsset": 355, + "./CCParticleSystem": 356, + "./particle-simulator": 359, + "./particle-system-assembler": 360 + } ], + 359: [ (function(require, module, exports) { + "use strict"; + var js = require("../core/platform/js"); + var misc = require("../core/utils/misc"); + var ZERO_VEC2 = cc.v2(0, 0); + var _pos = cc.v2(); + var _tpa = cc.v2(); + var _tpb = cc.v2(); + var _tpc = cc.v2(); + var Particle = function Particle() { + this.pos = cc.v2(0, 0); + this.startPos = cc.v2(0, 0); + this.color = cc.color(0, 0, 0, 255); + this.deltaColor = { + r: 0, + g: 0, + b: 0, + a: 255 + }; + this.preciseColor = { + r: 0, + g: 0, + b: 0, + a: 255 + }; + this.size = 0; + this.deltaSize = 0; + this.rotation = 0; + this.deltaRotation = 0; + this.timeToLive = 0; + this.drawPos = cc.v2(0, 0); + this.aspectRatio = 1; + this.dir = cc.v2(0, 0); + this.radialAccel = 0; + this.tangentialAccel = 0; + this.angle = 0; + this.degreesPerSecond = 0; + this.radius = 0; + this.deltaRadius = 0; + }; + var pool = new js.Pool(function(par) { + par.pos.set(ZERO_VEC2); + par.startPos.set(ZERO_VEC2); + par.color._val = 4278190080; + par.deltaColor.r = par.deltaColor.g = par.deltaColor.b = 0; + par.deltaColor.a = 255; + par.size = 0; + par.deltaSize = 0; + par.rotation = 0; + par.deltaRotation = 0; + par.timeToLive = 0; + par.drawPos.set(ZERO_VEC2); + par.aspectRatio = 1; + par.dir.set(ZERO_VEC2); + par.radialAccel = 0; + par.tangentialAccel = 0; + par.angle = 0; + par.degreesPerSecond = 0; + par.radius = 0; + par.deltaRadius = 0; + }, 1024); + pool.get = function() { + return this._get() || new Particle(); + }; + var Simulator = function Simulator(system) { + this.sys = system; + this.particles = []; + this.active = false; + this.readyToPlay = true; + this.finished = false; + this.elapsed = 0; + this.emitCounter = 0; + this._uvFilled = 0; + this._worldRotation = 0; + }; + Simulator.prototype.stop = function() { + this.active = false; + this.readyToPlay = false; + this.elapsed = this.sys.duration; + this.emitCounter = 0; + }; + Simulator.prototype.reset = function() { + this.active = true; + this.readyToPlay = true; + this.elapsed = 0; + this.emitCounter = 0; + this.finished = false; + var particles = this.particles; + for (var id = 0; id < particles.length; ++id) pool.put(particles[id]); + particles.length = 0; + var assembler = this.sys._assembler; + assembler && assembler._ia && (assembler._ia._count = 0); + }; + Simulator.prototype.emitParticle = function(pos) { + var psys = this.sys; + var clampf = misc.clampf; + var particle = pool.get(); + this.particles.push(particle); + particle.timeToLive = psys.life + psys.lifeVar * (Math.random() - .5) * 2; + var timeToLive = particle.timeToLive = Math.max(0, particle.timeToLive); + particle.pos.x = psys.sourcePos.x + psys.posVar.x * (Math.random() - .5) * 2; + particle.pos.y = psys.sourcePos.y + psys.posVar.y * (Math.random() - .5) * 2; + var sr, sg, sb, sa; + var startColor = psys._startColor, startColorVar = psys._startColorVar; + var endColor = psys._endColor, endColorVar = psys._endColorVar; + particle.color.r = sr = clampf(startColor.r + startColorVar.r * (Math.random() - .5) * 2, 0, 255); + particle.color.g = sg = clampf(startColor.g + startColorVar.g * (Math.random() - .5) * 2, 0, 255); + particle.color.b = sb = clampf(startColor.b + startColorVar.b * (Math.random() - .5) * 2, 0, 255); + particle.color.a = sa = clampf(startColor.a + startColorVar.a * (Math.random() - .5) * 2, 0, 255); + var color = particle.color; + var preciseColor = particle.preciseColor; + preciseColor.r = color.r; + preciseColor.g = color.g; + preciseColor.b = color.b; + preciseColor.a = color.a; + particle.deltaColor.r = (clampf(endColor.r + endColorVar.r * (Math.random() - .5) * 2, 0, 255) - sr) / timeToLive; + particle.deltaColor.g = (clampf(endColor.g + endColorVar.g * (Math.random() - .5) * 2, 0, 255) - sg) / timeToLive; + particle.deltaColor.b = (clampf(endColor.b + endColorVar.b * (Math.random() - .5) * 2, 0, 255) - sb) / timeToLive; + particle.deltaColor.a = (clampf(endColor.a + endColorVar.a * (Math.random() - .5) * 2, 0, 255) - sa) / timeToLive; + var startS = psys.startSize + psys.startSizeVar * (Math.random() - .5) * 2; + startS = Math.max(0, startS); + particle.size = startS; + if (psys.endSize === cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE) particle.deltaSize = 0; else { + var endS = psys.endSize + psys.endSizeVar * (Math.random() - .5) * 2; + endS = Math.max(0, endS); + particle.deltaSize = (endS - startS) / timeToLive; + } + var startA = psys.startSpin + psys.startSpinVar * (Math.random() - .5) * 2; + var endA = psys.endSpin + psys.endSpinVar * (Math.random() - .5) * 2; + particle.rotation = startA; + particle.deltaRotation = (endA - startA) / timeToLive; + particle.startPos.x = pos.x; + particle.startPos.y = pos.y; + particle.aspectRatio = psys._aspectRatio || 1; + var a = misc.degreesToRadians(psys.angle + this._worldRotation + psys.angleVar * (Math.random() - .5) * 2); + if (psys.emitterMode === cc.ParticleSystem.EmitterMode.GRAVITY) { + var s = psys.speed + psys.speedVar * (Math.random() - .5) * 2; + particle.dir.x = Math.cos(a); + particle.dir.y = Math.sin(a); + particle.dir.mulSelf(s); + particle.radialAccel = psys.radialAccel + psys.radialAccelVar * (Math.random() - .5) * 2; + particle.tangentialAccel = psys.tangentialAccel + psys.tangentialAccelVar * (Math.random() - .5) * 2; + psys.rotationIsDir && (particle.rotation = -misc.radiansToDegrees(Math.atan2(particle.dir.y, particle.dir.x))); + } else { + var startRadius = psys.startRadius + psys.startRadiusVar * (Math.random() - .5) * 2; + var endRadius = psys.endRadius + psys.endRadiusVar * (Math.random() - .5) * 2; + particle.radius = startRadius; + particle.deltaRadius = psys.endRadius === cc.ParticleSystem.START_RADIUS_EQUAL_TO_END_RADIUS ? 0 : (endRadius - startRadius) / timeToLive; + particle.angle = a; + particle.degreesPerSecond = misc.degreesToRadians(psys.rotatePerS + psys.rotatePerSVar * (Math.random() - .5) * 2); + } + }; + function getWorldRotation(node) { + var rotation = 0; + var tempNode = node; + while (tempNode) { + rotation += tempNode.angle; + tempNode = tempNode.parent; + } + return rotation; + } + Simulator.prototype.updateUVs = function(force) { + var assembler = this.sys._assembler; + if (!assembler) return; + var buffer = assembler.getBuffer(); + if (buffer && this.sys._renderSpriteFrame) { + var FLOAT_PER_PARTICLE = 4 * assembler._vfmt._bytes / 4; + var vbuf = buffer._vData; + var uv = this.sys._renderSpriteFrame.uv; + var start = force ? 0 : this._uvFilled; + var particleCount = this.particles.length; + for (var i = start; i < particleCount; i++) { + var offset = i * FLOAT_PER_PARTICLE; + vbuf[offset + 2] = uv[0]; + vbuf[offset + 3] = uv[1]; + vbuf[offset + 7] = uv[2]; + vbuf[offset + 8] = uv[3]; + vbuf[offset + 12] = uv[4]; + vbuf[offset + 13] = uv[5]; + vbuf[offset + 17] = uv[6]; + vbuf[offset + 18] = uv[7]; + } + this._uvFilled = particleCount; + } + }; + Simulator.prototype.updateParticleBuffer = function(particle, pos, buffer, offset) { + var vbuf = buffer._vData; + var uintbuf = buffer._uintVData; + var x = pos.x, y = pos.y; + var width = particle.size; + var height = width; + var aspectRatio = particle.aspectRatio; + aspectRatio > 1 ? height = width / aspectRatio : width = height * aspectRatio; + var halfWidth = width / 2; + var halfHeight = height / 2; + if (particle.rotation) { + var x1 = -halfWidth, y1 = -halfHeight; + var x2 = halfWidth, y2 = halfHeight; + var rad = -misc.degreesToRadians(particle.rotation); + var cr = Math.cos(rad), sr = Math.sin(rad); + vbuf[offset] = x1 * cr - y1 * sr + x; + vbuf[offset + 1] = x1 * sr + y1 * cr + y; + vbuf[offset + 5] = x2 * cr - y1 * sr + x; + vbuf[offset + 6] = x2 * sr + y1 * cr + y; + vbuf[offset + 10] = x1 * cr - y2 * sr + x; + vbuf[offset + 11] = x1 * sr + y2 * cr + y; + vbuf[offset + 15] = x2 * cr - y2 * sr + x; + vbuf[offset + 16] = x2 * sr + y2 * cr + y; + } else { + vbuf[offset] = x - halfWidth; + vbuf[offset + 1] = y - halfHeight; + vbuf[offset + 5] = x + halfWidth; + vbuf[offset + 6] = y - halfHeight; + vbuf[offset + 10] = x - halfWidth; + vbuf[offset + 11] = y + halfHeight; + vbuf[offset + 15] = x + halfWidth; + vbuf[offset + 16] = y + halfHeight; + } + uintbuf[offset + 4] = particle.color._val; + uintbuf[offset + 9] = particle.color._val; + uintbuf[offset + 14] = particle.color._val; + uintbuf[offset + 19] = particle.color._val; + }; + Simulator.prototype.step = function(dt) { + dt = dt > cc.director._maxParticleDeltaTime ? cc.director._maxParticleDeltaTime : dt; + var psys = this.sys; + var node = psys.node; + var particles = this.particles; + var FLOAT_PER_PARTICLE = 4 * this.sys._assembler._vfmt._bytes / 4; + var PositionType = cc.ParticleSystem.PositionType; + node._updateWorldMatrix(); + if (psys.positionType === PositionType.FREE) { + this._worldRotation = getWorldRotation(node); + var m = node._worldMatrix.m; + _pos.x = m[12]; + _pos.y = m[13]; + } else if (psys.positionType === PositionType.RELATIVE) { + this._worldRotation = node.angle; + _pos.x = node.x; + _pos.y = node.y; + } else this._worldRotation = 0; + if (this.active && psys.emissionRate) { + var rate = 1 / psys.emissionRate; + particles.length < psys.totalParticles && (this.emitCounter += dt); + while (particles.length < psys.totalParticles && this.emitCounter > rate) { + this.emitParticle(_pos); + this.emitCounter -= rate; + } + this.elapsed += dt; + -1 !== psys.duration && psys.duration < this.elapsed && psys.stopSystem(); + } + var buffer = psys._assembler.getBuffer(); + var particleCount = particles.length; + buffer.reset(); + buffer.request(4 * particleCount, 6 * particleCount); + particleCount > this._uvFilled && this.updateUVs(); + var particleIdx = 0; + while (particleIdx < particles.length) { + _tpa.x = _tpa.y = _tpb.x = _tpb.y = _tpc.x = _tpc.y = 0; + var particle = particles[particleIdx]; + particle.timeToLive -= dt; + if (particle.timeToLive > 0) { + if (psys.emitterMode === cc.ParticleSystem.EmitterMode.GRAVITY) { + var tmp = _tpc, radial = _tpa, tangential = _tpb; + if (particle.pos.x || particle.pos.y) { + radial.set(particle.pos); + radial.normalizeSelf(); + } + tangential.set(radial); + radial.mulSelf(particle.radialAccel); + var newy = tangential.x; + tangential.x = -tangential.y; + tangential.y = newy; + tangential.mulSelf(particle.tangentialAccel); + tmp.set(radial); + tmp.addSelf(tangential); + tmp.addSelf(psys.gravity); + tmp.mulSelf(dt); + particle.dir.addSelf(tmp); + tmp.set(particle.dir); + tmp.mulSelf(dt); + particle.pos.addSelf(tmp); + } else { + particle.angle += particle.degreesPerSecond * dt; + particle.radius += particle.deltaRadius * dt; + particle.pos.x = -Math.cos(particle.angle) * particle.radius; + particle.pos.y = -Math.sin(particle.angle) * particle.radius; + } + var preciseColor = particle.preciseColor; + var deltaColor = particle.deltaColor; + preciseColor.r += deltaColor.r * dt; + preciseColor.g += deltaColor.g * dt; + preciseColor.b += deltaColor.b * dt; + preciseColor.a += deltaColor.a * dt; + var color = particle.color; + color.r = preciseColor.r; + color.g = preciseColor.g; + color.b = preciseColor.b; + color.a = preciseColor.a; + particle.size += particle.deltaSize * dt; + particle.size < 0 && (particle.size = 0); + particle.rotation += particle.deltaRotation * dt; + var newPos = _tpa; + newPos.set(particle.pos); + psys.positionType !== PositionType.GROUPED && newPos.addSelf(particle.startPos); + var offset = FLOAT_PER_PARTICLE * particleIdx; + this.updateParticleBuffer(particle, newPos, buffer, offset); + ++particleIdx; + } else { + var deadParticle = particles[particleIdx]; + particleIdx !== particles.length - 1 && (particles[particleIdx] = particles[particles.length - 1]); + pool.put(deadParticle); + particles.length--; + } + } + psys._assembler._ia._count = 6 * particles.length; + if (particles.length > 0) buffer.uploadData(); else if (!this.active && !this.readyToPlay) { + this.finished = true; + psys._finishedSimulation(); + } + }; + module.exports = Simulator; + }), { + "../core/platform/js": 261, + "../core/utils/misc": 325 + } ], + 360: [ (function(require, module, exports) { + "use strict"; + var _assembler = _interopRequireDefault(require("../core/renderer/assembler")); + var _inputAssembler = _interopRequireDefault(require("../renderer/core/input-assembler")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + _setPrototypeOf(subClass, superClass); + } + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + return _setPrototypeOf(o, p); + } + var ParticleSystem = require("./CCParticleSystem"); + var renderer = require("../core/renderer/"); + var QuadBuffer = require("../core/renderer/webgl/quad-buffer"); + var vfmtPosUvColor = require("../core/renderer/webgl/vertex-format").vfmtPosUvColor; + var ParticleAssembler = (function(_Assembler) { + _inheritsLoose(ParticleAssembler, _Assembler); + function ParticleAssembler(comp) { + var _this; + _this = _Assembler.call(this, comp) || this; + _this._buffer = null; + _this._ia = null; + _this._vfmt = vfmtPosUvColor; + return _this; + } + var _proto = ParticleAssembler.prototype; + _proto.getBuffer = function getBuffer() { + if (!this._buffer) { + this._buffer = new QuadBuffer(renderer._handle, vfmtPosUvColor); + this._ia = new _inputAssembler["default"](); + this._ia._vertexBuffer = this._buffer._vb; + this._ia._indexBuffer = this._buffer._ib; + this._ia._start = 0; + this._ia._count = 0; + } + return this._buffer; + }; + _proto.fillBuffers = function fillBuffers(comp, renderer) { + if (!this._ia) return; + var PositionType = cc.ParticleSystem.PositionType; + comp.positionType === PositionType.RELATIVE ? renderer.node = comp.node.parent : renderer.node = comp.node; + renderer.material = comp._materials[0]; + renderer._flushIA(this._ia); + }; + return ParticleAssembler; + })(_assembler["default"]); + _assembler["default"].register(ParticleSystem, ParticleAssembler); + module.exports = ParticleAssembler; + }), { + "../core/renderer/": 272, + "../core/renderer/assembler": 269, + "../core/renderer/webgl/quad-buffer": 311, + "../core/renderer/webgl/vertex-format": 314, + "../renderer/core/input-assembler": 363, + "./CCParticleSystem": 356 + } ], + 361: [ (function(require, module, exports) { + "use strict"; + var enums = { + USAGE_STATIC: 35044, + USAGE_DYNAMIC: 35048, + USAGE_STREAM: 35040, + INDEX_FMT_UINT8: 5121, + INDEX_FMT_UINT16: 5123, + INDEX_FMT_UINT32: 5125, + ATTR_POSITION: "a_position", + ATTR_NORMAL: "a_normal", + ATTR_TANGENT: "a_tangent", + ATTR_BITANGENT: "a_bitangent", + ATTR_WEIGHTS: "a_weights", + ATTR_JOINTS: "a_joints", + ATTR_COLOR: "a_color", + ATTR_COLOR0: "a_color0", + ATTR_COLOR1: "a_color1", + ATTR_UV: "a_uv", + ATTR_UV0: "a_uv0", + ATTR_UV1: "a_uv1", + ATTR_UV2: "a_uv2", + ATTR_UV3: "a_uv3", + ATTR_UV4: "a_uv4", + ATTR_UV5: "a_uv5", + ATTR_UV6: "a_uv6", + ATTR_UV7: "a_uv7", + ATTR_TYPE_INT8: 5120, + ATTR_TYPE_UINT8: 5121, + ATTR_TYPE_INT16: 5122, + ATTR_TYPE_UINT16: 5123, + ATTR_TYPE_INT32: 5124, + ATTR_TYPE_UINT32: 5125, + ATTR_TYPE_FLOAT32: 5126, + FILTER_NEAREST: 0, + FILTER_LINEAR: 1, + WRAP_REPEAT: 10497, + WRAP_CLAMP: 33071, + WRAP_MIRROR: 33648, + TEXTURE_FMT_RGB_DXT1: 0, + TEXTURE_FMT_RGBA_DXT1: 1, + TEXTURE_FMT_RGBA_DXT3: 2, + TEXTURE_FMT_RGBA_DXT5: 3, + TEXTURE_FMT_RGB_ETC1: 4, + TEXTURE_FMT_RGB_PVRTC_2BPPV1: 5, + TEXTURE_FMT_RGBA_PVRTC_2BPPV1: 6, + TEXTURE_FMT_RGB_PVRTC_4BPPV1: 7, + TEXTURE_FMT_RGBA_PVRTC_4BPPV1: 8, + TEXTURE_FMT_A8: 9, + TEXTURE_FMT_L8: 10, + TEXTURE_FMT_L8_A8: 11, + TEXTURE_FMT_R5_G6_B5: 12, + TEXTURE_FMT_R5_G5_B5_A1: 13, + TEXTURE_FMT_R4_G4_B4_A4: 14, + TEXTURE_FMT_RGB8: 15, + TEXTURE_FMT_RGBA8: 16, + TEXTURE_FMT_RGB16F: 17, + TEXTURE_FMT_RGBA16F: 18, + TEXTURE_FMT_RGB32F: 19, + TEXTURE_FMT_RGBA32F: 20, + TEXTURE_FMT_R32F: 21, + TEXTURE_FMT_111110F: 22, + TEXTURE_FMT_SRGB: 23, + TEXTURE_FMT_SRGBA: 24, + TEXTURE_FMT_D16: 25, + TEXTURE_FMT_D32: 26, + TEXTURE_FMT_D24S8: 27, + TEXTURE_FMT_RGB_ETC2: 28, + TEXTURE_FMT_RGBA_ETC2: 29, + DS_FUNC_NEVER: 512, + DS_FUNC_LESS: 513, + DS_FUNC_EQUAL: 514, + DS_FUNC_LEQUAL: 515, + DS_FUNC_GREATER: 516, + DS_FUNC_NOTEQUAL: 517, + DS_FUNC_GEQUAL: 518, + DS_FUNC_ALWAYS: 519, + RB_FMT_RGBA4: 32854, + RB_FMT_RGB5_A1: 32855, + RB_FMT_RGB565: 36194, + RB_FMT_D16: 33189, + RB_FMT_S8: 36168, + RB_FMT_D24S8: 34041, + BLEND_FUNC_ADD: 32774, + BLEND_FUNC_SUBTRACT: 32778, + BLEND_FUNC_REVERSE_SUBTRACT: 32779, + BLEND_ZERO: 0, + BLEND_ONE: 1, + BLEND_SRC_COLOR: 768, + BLEND_ONE_MINUS_SRC_COLOR: 769, + BLEND_DST_COLOR: 774, + BLEND_ONE_MINUS_DST_COLOR: 775, + BLEND_SRC_ALPHA: 770, + BLEND_ONE_MINUS_SRC_ALPHA: 771, + BLEND_DST_ALPHA: 772, + BLEND_ONE_MINUS_DST_ALPHA: 773, + BLEND_CONSTANT_COLOR: 32769, + BLEND_ONE_MINUS_CONSTANT_COLOR: 32770, + BLEND_CONSTANT_ALPHA: 32771, + BLEND_ONE_MINUS_CONSTANT_ALPHA: 32772, + BLEND_SRC_ALPHA_SATURATE: 776, + STENCIL_DISABLE: 0, + STENCIL_ENABLE: 1, + STENCIL_INHERIT: 2, + STENCIL_OP_KEEP: 7680, + STENCIL_OP_ZERO: 0, + STENCIL_OP_REPLACE: 7681, + STENCIL_OP_INCR: 7682, + STENCIL_OP_INCR_WRAP: 34055, + STENCIL_OP_DECR: 7683, + STENCIL_OP_DECR_WRAP: 34056, + STENCIL_OP_INVERT: 5386, + CULL_NONE: 0, + CULL_FRONT: 1028, + CULL_BACK: 1029, + CULL_FRONT_AND_BACK: 1032, + PT_POINTS: 0, + PT_LINES: 1, + PT_LINE_LOOP: 2, + PT_LINE_STRIP: 3, + PT_TRIANGLES: 4, + PT_TRIANGLE_STRIP: 5, + PT_TRIANGLE_FAN: 6 + }; + var RenderQueue = { + OPAQUE: 0, + TRANSPARENT: 1, + OVERLAY: 2 + }; + function murmurhash2_32_gc(str, seed) { + var l = str.length, h = seed ^ l, i = 0, k; + while (l >= 4) { + k = 255 & str.charCodeAt(i) | (255 & str.charCodeAt(++i)) << 8 | (255 & str.charCodeAt(++i)) << 16 | (255 & str.charCodeAt(++i)) << 24; + k = 1540483477 * (65535 & k) + ((1540483477 * (k >>> 16) & 65535) << 16); + k ^= k >>> 24; + k = 1540483477 * (65535 & k) + ((1540483477 * (k >>> 16) & 65535) << 16); + h = 1540483477 * (65535 & h) + ((1540483477 * (h >>> 16) & 65535) << 16) ^ k; + l -= 4; + ++i; + } + switch (l) { + case 3: + h ^= (255 & str.charCodeAt(i + 2)) << 16; + + case 2: + h ^= (255 & str.charCodeAt(i + 1)) << 8; + + case 1: + h ^= 255 & str.charCodeAt(i); + h = 1540483477 * (65535 & h) + ((1540483477 * (h >>> 16) & 65535) << 16); + } + h ^= h >>> 13; + h = 1540483477 * (65535 & h) + ((1540483477 * (h >>> 16) & 65535) << 16); + h ^= h >>> 15; + return h >>> 0; + } + var WebGLEXT; + (function(WebGLEXT) { + WebGLEXT[WebGLEXT["COMPRESSED_RGB_S3TC_DXT1_EXT"] = 33776] = "COMPRESSED_RGB_S3TC_DXT1_EXT"; + WebGLEXT[WebGLEXT["COMPRESSED_RGBA_S3TC_DXT1_EXT"] = 33777] = "COMPRESSED_RGBA_S3TC_DXT1_EXT"; + WebGLEXT[WebGLEXT["COMPRESSED_RGBA_S3TC_DXT3_EXT"] = 33778] = "COMPRESSED_RGBA_S3TC_DXT3_EXT"; + WebGLEXT[WebGLEXT["COMPRESSED_RGBA_S3TC_DXT5_EXT"] = 33779] = "COMPRESSED_RGBA_S3TC_DXT5_EXT"; + WebGLEXT[WebGLEXT["COMPRESSED_SRGB_S3TC_DXT1_EXT"] = 35916] = "COMPRESSED_SRGB_S3TC_DXT1_EXT"; + WebGLEXT[WebGLEXT["COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT"] = 35917] = "COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT"; + WebGLEXT[WebGLEXT["COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT"] = 35918] = "COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT"; + WebGLEXT[WebGLEXT["COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT"] = 35919] = "COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT"; + WebGLEXT[WebGLEXT["COMPRESSED_RGB_PVRTC_4BPPV1_IMG"] = 35840] = "COMPRESSED_RGB_PVRTC_4BPPV1_IMG"; + WebGLEXT[WebGLEXT["COMPRESSED_RGB_PVRTC_2BPPV1_IMG"] = 35841] = "COMPRESSED_RGB_PVRTC_2BPPV1_IMG"; + WebGLEXT[WebGLEXT["COMPRESSED_RGBA_PVRTC_4BPPV1_IMG"] = 35842] = "COMPRESSED_RGBA_PVRTC_4BPPV1_IMG"; + WebGLEXT[WebGLEXT["COMPRESSED_RGBA_PVRTC_2BPPV1_IMG"] = 35843] = "COMPRESSED_RGBA_PVRTC_2BPPV1_IMG"; + WebGLEXT[WebGLEXT["COMPRESSED_RGB_ETC1_WEBGL"] = 36196] = "COMPRESSED_RGB_ETC1_WEBGL"; + })(WebGLEXT || (WebGLEXT = {})); + var GFXObjectType; + (function(GFXObjectType) { + GFXObjectType[GFXObjectType["UNKNOWN"] = 0] = "UNKNOWN"; + GFXObjectType[GFXObjectType["BUFFER"] = 1] = "BUFFER"; + GFXObjectType[GFXObjectType["TEXTURE"] = 2] = "TEXTURE"; + GFXObjectType[GFXObjectType["TEXTURE_VIEW"] = 3] = "TEXTURE_VIEW"; + GFXObjectType[GFXObjectType["RENDER_PASS"] = 4] = "RENDER_PASS"; + GFXObjectType[GFXObjectType["FRAMEBUFFER"] = 5] = "FRAMEBUFFER"; + GFXObjectType[GFXObjectType["SAMPLER"] = 6] = "SAMPLER"; + GFXObjectType[GFXObjectType["SHADER"] = 7] = "SHADER"; + GFXObjectType[GFXObjectType["PIPELINE_LAYOUT"] = 8] = "PIPELINE_LAYOUT"; + GFXObjectType[GFXObjectType["PIPELINE_STATE"] = 9] = "PIPELINE_STATE"; + GFXObjectType[GFXObjectType["BINDING_LAYOUT"] = 10] = "BINDING_LAYOUT"; + GFXObjectType[GFXObjectType["INPUT_ASSEMBLER"] = 11] = "INPUT_ASSEMBLER"; + GFXObjectType[GFXObjectType["COMMAND_ALLOCATOR"] = 12] = "COMMAND_ALLOCATOR"; + GFXObjectType[GFXObjectType["COMMAND_BUFFER"] = 13] = "COMMAND_BUFFER"; + GFXObjectType[GFXObjectType["QUEUE"] = 14] = "QUEUE"; + GFXObjectType[GFXObjectType["WINDOW"] = 15] = "WINDOW"; + })(GFXObjectType || (GFXObjectType = {})); + var GFXStatus; + (function(GFXStatus) { + GFXStatus[GFXStatus["UNREADY"] = 0] = "UNREADY"; + GFXStatus[GFXStatus["FAILED"] = 1] = "FAILED"; + GFXStatus[GFXStatus["SUCCESS"] = 2] = "SUCCESS"; + })(GFXStatus || (GFXStatus = {})); + var GFXObject = (function() { + function GFXObject(gfxType) { + this._gfxType = GFXObjectType.UNKNOWN; + this._status = GFXStatus.UNREADY; + this._gfxType = gfxType; + } + Object.defineProperty(GFXObject.prototype, "gfxType", { + get: function get() { + return this._gfxType; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(GFXObject.prototype, "status", { + get: function get() { + return this._status; + }, + enumerable: true, + configurable: true + }); + return GFXObject; + })(); + var GFXAttributeName; + (function(GFXAttributeName) { + GFXAttributeName["ATTR_POSITION"] = "a_position"; + GFXAttributeName["ATTR_NORMAL"] = "a_normal"; + GFXAttributeName["ATTR_TANGENT"] = "a_tangent"; + GFXAttributeName["ATTR_BITANGENT"] = "a_bitangent"; + GFXAttributeName["ATTR_WEIGHTS"] = "a_weights"; + GFXAttributeName["ATTR_JOINTS"] = "a_joints"; + GFXAttributeName["ATTR_COLOR"] = "a_color"; + GFXAttributeName["ATTR_COLOR1"] = "a_color1"; + GFXAttributeName["ATTR_COLOR2"] = "a_color2"; + GFXAttributeName["ATTR_TEX_COORD"] = "a_texCoord"; + GFXAttributeName["ATTR_TEX_COORD1"] = "a_texCoord1"; + GFXAttributeName["ATTR_TEX_COORD2"] = "a_texCoord2"; + GFXAttributeName["ATTR_TEX_COORD3"] = "a_texCoord3"; + GFXAttributeName["ATTR_TEX_COORD4"] = "a_texCoord4"; + GFXAttributeName["ATTR_TEX_COORD5"] = "a_texCoord5"; + GFXAttributeName["ATTR_TEX_COORD6"] = "a_texCoord6"; + GFXAttributeName["ATTR_TEX_COORD7"] = "a_texCoord7"; + GFXAttributeName["ATTR_TEX_COORD8"] = "a_texCoord8"; + })(GFXAttributeName || (GFXAttributeName = {})); + var GFXType; + (function(GFXType) { + GFXType[GFXType["UNKNOWN"] = 0] = "UNKNOWN"; + GFXType[GFXType["BOOL"] = 1] = "BOOL"; + GFXType[GFXType["BOOL2"] = 2] = "BOOL2"; + GFXType[GFXType["BOOL3"] = 3] = "BOOL3"; + GFXType[GFXType["BOOL4"] = 4] = "BOOL4"; + GFXType[GFXType["INT"] = 5] = "INT"; + GFXType[GFXType["INT2"] = 6] = "INT2"; + GFXType[GFXType["INT3"] = 7] = "INT3"; + GFXType[GFXType["INT4"] = 8] = "INT4"; + GFXType[GFXType["UINT"] = 9] = "UINT"; + GFXType[GFXType["UINT2"] = 10] = "UINT2"; + GFXType[GFXType["UINT3"] = 11] = "UINT3"; + GFXType[GFXType["UINT4"] = 12] = "UINT4"; + GFXType[GFXType["FLOAT"] = 13] = "FLOAT"; + GFXType[GFXType["FLOAT2"] = 14] = "FLOAT2"; + GFXType[GFXType["FLOAT3"] = 15] = "FLOAT3"; + GFXType[GFXType["FLOAT4"] = 16] = "FLOAT4"; + GFXType[GFXType["COLOR4"] = 17] = "COLOR4"; + GFXType[GFXType["MAT2"] = 18] = "MAT2"; + GFXType[GFXType["MAT2X3"] = 19] = "MAT2X3"; + GFXType[GFXType["MAT2X4"] = 20] = "MAT2X4"; + GFXType[GFXType["MAT3X2"] = 21] = "MAT3X2"; + GFXType[GFXType["MAT3"] = 22] = "MAT3"; + GFXType[GFXType["MAT3X4"] = 23] = "MAT3X4"; + GFXType[GFXType["MAT4X2"] = 24] = "MAT4X2"; + GFXType[GFXType["MAT4X3"] = 25] = "MAT4X3"; + GFXType[GFXType["MAT4"] = 26] = "MAT4"; + GFXType[GFXType["SAMPLER1D"] = 27] = "SAMPLER1D"; + GFXType[GFXType["SAMPLER1D_ARRAY"] = 28] = "SAMPLER1D_ARRAY"; + GFXType[GFXType["SAMPLER2D"] = 29] = "SAMPLER2D"; + GFXType[GFXType["SAMPLER2D_ARRAY"] = 30] = "SAMPLER2D_ARRAY"; + GFXType[GFXType["SAMPLER3D"] = 31] = "SAMPLER3D"; + GFXType[GFXType["SAMPLER_CUBE"] = 32] = "SAMPLER_CUBE"; + GFXType[GFXType["COUNT"] = 33] = "COUNT"; + })(GFXType || (GFXType = {})); + var GFXFormat; + (function(GFXFormat) { + GFXFormat[GFXFormat["UNKNOWN"] = 0] = "UNKNOWN"; + GFXFormat[GFXFormat["A8"] = 1] = "A8"; + GFXFormat[GFXFormat["L8"] = 2] = "L8"; + GFXFormat[GFXFormat["LA8"] = 3] = "LA8"; + GFXFormat[GFXFormat["R8"] = 4] = "R8"; + GFXFormat[GFXFormat["R8SN"] = 5] = "R8SN"; + GFXFormat[GFXFormat["R8UI"] = 6] = "R8UI"; + GFXFormat[GFXFormat["R8I"] = 7] = "R8I"; + GFXFormat[GFXFormat["R16F"] = 8] = "R16F"; + GFXFormat[GFXFormat["R16UI"] = 9] = "R16UI"; + GFXFormat[GFXFormat["R16I"] = 10] = "R16I"; + GFXFormat[GFXFormat["R32F"] = 11] = "R32F"; + GFXFormat[GFXFormat["R32UI"] = 12] = "R32UI"; + GFXFormat[GFXFormat["R32I"] = 13] = "R32I"; + GFXFormat[GFXFormat["RG8"] = 14] = "RG8"; + GFXFormat[GFXFormat["RG8SN"] = 15] = "RG8SN"; + GFXFormat[GFXFormat["RG8UI"] = 16] = "RG8UI"; + GFXFormat[GFXFormat["RG8I"] = 17] = "RG8I"; + GFXFormat[GFXFormat["RG16F"] = 18] = "RG16F"; + GFXFormat[GFXFormat["RG16UI"] = 19] = "RG16UI"; + GFXFormat[GFXFormat["RG16I"] = 20] = "RG16I"; + GFXFormat[GFXFormat["RG32F"] = 21] = "RG32F"; + GFXFormat[GFXFormat["RG32UI"] = 22] = "RG32UI"; + GFXFormat[GFXFormat["RG32I"] = 23] = "RG32I"; + GFXFormat[GFXFormat["RGB8"] = 24] = "RGB8"; + GFXFormat[GFXFormat["SRGB8"] = 25] = "SRGB8"; + GFXFormat[GFXFormat["RGB8SN"] = 26] = "RGB8SN"; + GFXFormat[GFXFormat["RGB8UI"] = 27] = "RGB8UI"; + GFXFormat[GFXFormat["RGB8I"] = 28] = "RGB8I"; + GFXFormat[GFXFormat["RGB16F"] = 29] = "RGB16F"; + GFXFormat[GFXFormat["RGB16UI"] = 30] = "RGB16UI"; + GFXFormat[GFXFormat["RGB16I"] = 31] = "RGB16I"; + GFXFormat[GFXFormat["RGB32F"] = 32] = "RGB32F"; + GFXFormat[GFXFormat["RGB32UI"] = 33] = "RGB32UI"; + GFXFormat[GFXFormat["RGB32I"] = 34] = "RGB32I"; + GFXFormat[GFXFormat["RGBA8"] = 35] = "RGBA8"; + GFXFormat[GFXFormat["SRGB8_A8"] = 36] = "SRGB8_A8"; + GFXFormat[GFXFormat["RGBA8SN"] = 37] = "RGBA8SN"; + GFXFormat[GFXFormat["RGBA8UI"] = 38] = "RGBA8UI"; + GFXFormat[GFXFormat["RGBA8I"] = 39] = "RGBA8I"; + GFXFormat[GFXFormat["RGBA16F"] = 40] = "RGBA16F"; + GFXFormat[GFXFormat["RGBA16UI"] = 41] = "RGBA16UI"; + GFXFormat[GFXFormat["RGBA16I"] = 42] = "RGBA16I"; + GFXFormat[GFXFormat["RGBA32F"] = 43] = "RGBA32F"; + GFXFormat[GFXFormat["RGBA32UI"] = 44] = "RGBA32UI"; + GFXFormat[GFXFormat["RGBA32I"] = 45] = "RGBA32I"; + GFXFormat[GFXFormat["R5G6B5"] = 46] = "R5G6B5"; + GFXFormat[GFXFormat["R11G11B10F"] = 47] = "R11G11B10F"; + GFXFormat[GFXFormat["RGB5A1"] = 48] = "RGB5A1"; + GFXFormat[GFXFormat["RGBA4"] = 49] = "RGBA4"; + GFXFormat[GFXFormat["RGB10A2"] = 50] = "RGB10A2"; + GFXFormat[GFXFormat["RGB10A2UI"] = 51] = "RGB10A2UI"; + GFXFormat[GFXFormat["RGB9E5"] = 52] = "RGB9E5"; + GFXFormat[GFXFormat["D16"] = 53] = "D16"; + GFXFormat[GFXFormat["D16S8"] = 54] = "D16S8"; + GFXFormat[GFXFormat["D24"] = 55] = "D24"; + GFXFormat[GFXFormat["D24S8"] = 56] = "D24S8"; + GFXFormat[GFXFormat["D32F"] = 57] = "D32F"; + GFXFormat[GFXFormat["D32F_S8"] = 58] = "D32F_S8"; + GFXFormat[GFXFormat["BC1"] = 59] = "BC1"; + GFXFormat[GFXFormat["BC1_ALPHA"] = 60] = "BC1_ALPHA"; + GFXFormat[GFXFormat["BC1_SRGB"] = 61] = "BC1_SRGB"; + GFXFormat[GFXFormat["BC1_SRGB_ALPHA"] = 62] = "BC1_SRGB_ALPHA"; + GFXFormat[GFXFormat["BC2"] = 63] = "BC2"; + GFXFormat[GFXFormat["BC2_SRGB"] = 64] = "BC2_SRGB"; + GFXFormat[GFXFormat["BC3"] = 65] = "BC3"; + GFXFormat[GFXFormat["BC3_SRGB"] = 66] = "BC3_SRGB"; + GFXFormat[GFXFormat["BC4"] = 67] = "BC4"; + GFXFormat[GFXFormat["BC4_SNORM"] = 68] = "BC4_SNORM"; + GFXFormat[GFXFormat["BC5"] = 69] = "BC5"; + GFXFormat[GFXFormat["BC5_SNORM"] = 70] = "BC5_SNORM"; + GFXFormat[GFXFormat["BC6H_UF16"] = 71] = "BC6H_UF16"; + GFXFormat[GFXFormat["BC6H_SF16"] = 72] = "BC6H_SF16"; + GFXFormat[GFXFormat["BC7"] = 73] = "BC7"; + GFXFormat[GFXFormat["BC7_SRGB"] = 74] = "BC7_SRGB"; + GFXFormat[GFXFormat["ETC_RGB8"] = 75] = "ETC_RGB8"; + GFXFormat[GFXFormat["ETC2_RGB8"] = 76] = "ETC2_RGB8"; + GFXFormat[GFXFormat["ETC2_SRGB8"] = 77] = "ETC2_SRGB8"; + GFXFormat[GFXFormat["ETC2_RGB8_A1"] = 78] = "ETC2_RGB8_A1"; + GFXFormat[GFXFormat["ETC2_SRGB8_A1"] = 79] = "ETC2_SRGB8_A1"; + GFXFormat[GFXFormat["ETC2_RGBA8"] = 80] = "ETC2_RGBA8"; + GFXFormat[GFXFormat["ETC2_SRGB8_A8"] = 81] = "ETC2_SRGB8_A8"; + GFXFormat[GFXFormat["EAC_R11"] = 82] = "EAC_R11"; + GFXFormat[GFXFormat["EAC_R11SN"] = 83] = "EAC_R11SN"; + GFXFormat[GFXFormat["EAC_RG11"] = 84] = "EAC_RG11"; + GFXFormat[GFXFormat["EAC_RG11SN"] = 85] = "EAC_RG11SN"; + GFXFormat[GFXFormat["PVRTC_RGB2"] = 86] = "PVRTC_RGB2"; + GFXFormat[GFXFormat["PVRTC_RGBA2"] = 87] = "PVRTC_RGBA2"; + GFXFormat[GFXFormat["PVRTC_RGB4"] = 88] = "PVRTC_RGB4"; + GFXFormat[GFXFormat["PVRTC_RGBA4"] = 89] = "PVRTC_RGBA4"; + GFXFormat[GFXFormat["PVRTC2_2BPP"] = 90] = "PVRTC2_2BPP"; + GFXFormat[GFXFormat["PVRTC2_4BPP"] = 91] = "PVRTC2_4BPP"; + })(GFXFormat || (GFXFormat = {})); + var GFXBufferUsageBit; + (function(GFXBufferUsageBit) { + GFXBufferUsageBit[GFXBufferUsageBit["NONE"] = 0] = "NONE"; + GFXBufferUsageBit[GFXBufferUsageBit["TRANSFER_SRC"] = 1] = "TRANSFER_SRC"; + GFXBufferUsageBit[GFXBufferUsageBit["TRANSFER_DST"] = 2] = "TRANSFER_DST"; + GFXBufferUsageBit[GFXBufferUsageBit["INDEX"] = 4] = "INDEX"; + GFXBufferUsageBit[GFXBufferUsageBit["VERTEX"] = 8] = "VERTEX"; + GFXBufferUsageBit[GFXBufferUsageBit["UNIFORM"] = 16] = "UNIFORM"; + GFXBufferUsageBit[GFXBufferUsageBit["STORAGE"] = 32] = "STORAGE"; + GFXBufferUsageBit[GFXBufferUsageBit["INDIRECT"] = 64] = "INDIRECT"; + })(GFXBufferUsageBit || (GFXBufferUsageBit = {})); + var GFXMemoryUsageBit; + (function(GFXMemoryUsageBit) { + GFXMemoryUsageBit[GFXMemoryUsageBit["NONE"] = 0] = "NONE"; + GFXMemoryUsageBit[GFXMemoryUsageBit["DEVICE"] = 1] = "DEVICE"; + GFXMemoryUsageBit[GFXMemoryUsageBit["HOST"] = 2] = "HOST"; + })(GFXMemoryUsageBit || (GFXMemoryUsageBit = {})); + var GFXBufferAccessBit; + (function(GFXBufferAccessBit) { + GFXBufferAccessBit[GFXBufferAccessBit["NONE"] = 0] = "NONE"; + GFXBufferAccessBit[GFXBufferAccessBit["READ"] = 1] = "READ"; + GFXBufferAccessBit[GFXBufferAccessBit["WRITE"] = 2] = "WRITE"; + })(GFXBufferAccessBit || (GFXBufferAccessBit = {})); + var GFXPrimitiveMode; + (function(GFXPrimitiveMode) { + GFXPrimitiveMode[GFXPrimitiveMode["POINT_LIST"] = 0] = "POINT_LIST"; + GFXPrimitiveMode[GFXPrimitiveMode["LINE_LIST"] = 1] = "LINE_LIST"; + GFXPrimitiveMode[GFXPrimitiveMode["LINE_STRIP"] = 2] = "LINE_STRIP"; + GFXPrimitiveMode[GFXPrimitiveMode["LINE_LOOP"] = 3] = "LINE_LOOP"; + GFXPrimitiveMode[GFXPrimitiveMode["LINE_LIST_ADJACENCY"] = 4] = "LINE_LIST_ADJACENCY"; + GFXPrimitiveMode[GFXPrimitiveMode["LINE_STRIP_ADJACENCY"] = 5] = "LINE_STRIP_ADJACENCY"; + GFXPrimitiveMode[GFXPrimitiveMode["ISO_LINE_LIST"] = 6] = "ISO_LINE_LIST"; + GFXPrimitiveMode[GFXPrimitiveMode["TRIANGLE_LIST"] = 7] = "TRIANGLE_LIST"; + GFXPrimitiveMode[GFXPrimitiveMode["TRIANGLE_STRIP"] = 8] = "TRIANGLE_STRIP"; + GFXPrimitiveMode[GFXPrimitiveMode["TRIANGLE_FAN"] = 9] = "TRIANGLE_FAN"; + GFXPrimitiveMode[GFXPrimitiveMode["TRIANGLE_LIST_ADJACENCY"] = 10] = "TRIANGLE_LIST_ADJACENCY"; + GFXPrimitiveMode[GFXPrimitiveMode["TRIANGLE_STRIP_ADJACENCY"] = 11] = "TRIANGLE_STRIP_ADJACENCY"; + GFXPrimitiveMode[GFXPrimitiveMode["TRIANGLE_PATCH_ADJACENCY"] = 12] = "TRIANGLE_PATCH_ADJACENCY"; + GFXPrimitiveMode[GFXPrimitiveMode["QUAD_PATCH_LIST"] = 13] = "QUAD_PATCH_LIST"; + })(GFXPrimitiveMode || (GFXPrimitiveMode = {})); + var GFXPolygonMode; + (function(GFXPolygonMode) { + GFXPolygonMode[GFXPolygonMode["FILL"] = 0] = "FILL"; + GFXPolygonMode[GFXPolygonMode["POINT"] = 1] = "POINT"; + GFXPolygonMode[GFXPolygonMode["LINE"] = 2] = "LINE"; + })(GFXPolygonMode || (GFXPolygonMode = {})); + var GFXShadeModel; + (function(GFXShadeModel) { + GFXShadeModel[GFXShadeModel["GOURAND"] = 0] = "GOURAND"; + GFXShadeModel[GFXShadeModel["FLAT"] = 1] = "FLAT"; + })(GFXShadeModel || (GFXShadeModel = {})); + var GFXCullMode; + (function(GFXCullMode) { + GFXCullMode[GFXCullMode["NONE"] = 0] = "NONE"; + GFXCullMode[GFXCullMode["FRONT"] = 1] = "FRONT"; + GFXCullMode[GFXCullMode["BACK"] = 2] = "BACK"; + })(GFXCullMode || (GFXCullMode = {})); + var GFXComparisonFunc; + (function(GFXComparisonFunc) { + GFXComparisonFunc[GFXComparisonFunc["NEVER"] = 0] = "NEVER"; + GFXComparisonFunc[GFXComparisonFunc["LESS"] = 1] = "LESS"; + GFXComparisonFunc[GFXComparisonFunc["EQUAL"] = 2] = "EQUAL"; + GFXComparisonFunc[GFXComparisonFunc["LESS_EQUAL"] = 3] = "LESS_EQUAL"; + GFXComparisonFunc[GFXComparisonFunc["GREATER"] = 4] = "GREATER"; + GFXComparisonFunc[GFXComparisonFunc["NOT_EQUAL"] = 5] = "NOT_EQUAL"; + GFXComparisonFunc[GFXComparisonFunc["GREATER_EQUAL"] = 6] = "GREATER_EQUAL"; + GFXComparisonFunc[GFXComparisonFunc["ALWAYS"] = 7] = "ALWAYS"; + })(GFXComparisonFunc || (GFXComparisonFunc = {})); + var GFXStencilOp; + (function(GFXStencilOp) { + GFXStencilOp[GFXStencilOp["ZERO"] = 0] = "ZERO"; + GFXStencilOp[GFXStencilOp["KEEP"] = 1] = "KEEP"; + GFXStencilOp[GFXStencilOp["REPLACE"] = 2] = "REPLACE"; + GFXStencilOp[GFXStencilOp["INCR"] = 3] = "INCR"; + GFXStencilOp[GFXStencilOp["DECR"] = 4] = "DECR"; + GFXStencilOp[GFXStencilOp["INVERT"] = 5] = "INVERT"; + GFXStencilOp[GFXStencilOp["INCR_WRAP"] = 6] = "INCR_WRAP"; + GFXStencilOp[GFXStencilOp["DECR_WRAP"] = 7] = "DECR_WRAP"; + })(GFXStencilOp || (GFXStencilOp = {})); + var GFXBlendOp; + (function(GFXBlendOp) { + GFXBlendOp[GFXBlendOp["ADD"] = 0] = "ADD"; + GFXBlendOp[GFXBlendOp["SUB"] = 1] = "SUB"; + GFXBlendOp[GFXBlendOp["REV_SUB"] = 2] = "REV_SUB"; + GFXBlendOp[GFXBlendOp["MIN"] = 3] = "MIN"; + GFXBlendOp[GFXBlendOp["MAX"] = 4] = "MAX"; + })(GFXBlendOp || (GFXBlendOp = {})); + var GFXBlendFactor; + (function(GFXBlendFactor) { + GFXBlendFactor[GFXBlendFactor["ZERO"] = 0] = "ZERO"; + GFXBlendFactor[GFXBlendFactor["ONE"] = 1] = "ONE"; + GFXBlendFactor[GFXBlendFactor["SRC_ALPHA"] = 2] = "SRC_ALPHA"; + GFXBlendFactor[GFXBlendFactor["DST_ALPHA"] = 3] = "DST_ALPHA"; + GFXBlendFactor[GFXBlendFactor["ONE_MINUS_SRC_ALPHA"] = 4] = "ONE_MINUS_SRC_ALPHA"; + GFXBlendFactor[GFXBlendFactor["ONE_MINUS_DST_ALPHA"] = 5] = "ONE_MINUS_DST_ALPHA"; + GFXBlendFactor[GFXBlendFactor["SRC_COLOR"] = 6] = "SRC_COLOR"; + GFXBlendFactor[GFXBlendFactor["DST_COLOR"] = 7] = "DST_COLOR"; + GFXBlendFactor[GFXBlendFactor["ONE_MINUS_SRC_COLOR"] = 8] = "ONE_MINUS_SRC_COLOR"; + GFXBlendFactor[GFXBlendFactor["ONE_MINUS_DST_COLOR"] = 9] = "ONE_MINUS_DST_COLOR"; + GFXBlendFactor[GFXBlendFactor["SRC_ALPHA_SATURATE"] = 10] = "SRC_ALPHA_SATURATE"; + GFXBlendFactor[GFXBlendFactor["CONSTANT_COLOR"] = 11] = "CONSTANT_COLOR"; + GFXBlendFactor[GFXBlendFactor["ONE_MINUS_CONSTANT_COLOR"] = 12] = "ONE_MINUS_CONSTANT_COLOR"; + GFXBlendFactor[GFXBlendFactor["CONSTANT_ALPHA"] = 13] = "CONSTANT_ALPHA"; + GFXBlendFactor[GFXBlendFactor["ONE_MINUS_CONSTANT_ALPHA"] = 14] = "ONE_MINUS_CONSTANT_ALPHA"; + })(GFXBlendFactor || (GFXBlendFactor = {})); + var GFXColorMask; + (function(GFXColorMask) { + GFXColorMask[GFXColorMask["NONE"] = 0] = "NONE"; + GFXColorMask[GFXColorMask["R"] = 1] = "R"; + GFXColorMask[GFXColorMask["G"] = 2] = "G"; + GFXColorMask[GFXColorMask["B"] = 4] = "B"; + GFXColorMask[GFXColorMask["A"] = 8] = "A"; + GFXColorMask[GFXColorMask["ALL"] = 15] = "ALL"; + })(GFXColorMask || (GFXColorMask = {})); + var GFXFilter; + (function(GFXFilter) { + GFXFilter[GFXFilter["NONE"] = 0] = "NONE"; + GFXFilter[GFXFilter["POINT"] = 1] = "POINT"; + GFXFilter[GFXFilter["LINEAR"] = 2] = "LINEAR"; + GFXFilter[GFXFilter["ANISOTROPIC"] = 3] = "ANISOTROPIC"; + })(GFXFilter || (GFXFilter = {})); + var GFXAddress; + (function(GFXAddress) { + GFXAddress[GFXAddress["WRAP"] = 0] = "WRAP"; + GFXAddress[GFXAddress["MIRROR"] = 1] = "MIRROR"; + GFXAddress[GFXAddress["CLAMP"] = 2] = "CLAMP"; + GFXAddress[GFXAddress["BORDER"] = 3] = "BORDER"; + })(GFXAddress || (GFXAddress = {})); + var GFXTextureType; + (function(GFXTextureType) { + GFXTextureType[GFXTextureType["TEX1D"] = 0] = "TEX1D"; + GFXTextureType[GFXTextureType["TEX2D"] = 1] = "TEX2D"; + GFXTextureType[GFXTextureType["TEX3D"] = 2] = "TEX3D"; + })(GFXTextureType || (GFXTextureType = {})); + var GFXTextureUsageBit; + (function(GFXTextureUsageBit) { + GFXTextureUsageBit[GFXTextureUsageBit["NONE"] = 0] = "NONE"; + GFXTextureUsageBit[GFXTextureUsageBit["TRANSFER_SRC"] = 1] = "TRANSFER_SRC"; + GFXTextureUsageBit[GFXTextureUsageBit["TRANSFER_DST"] = 2] = "TRANSFER_DST"; + GFXTextureUsageBit[GFXTextureUsageBit["SAMPLED"] = 4] = "SAMPLED"; + GFXTextureUsageBit[GFXTextureUsageBit["STORAGE"] = 8] = "STORAGE"; + GFXTextureUsageBit[GFXTextureUsageBit["COLOR_ATTACHMENT"] = 16] = "COLOR_ATTACHMENT"; + GFXTextureUsageBit[GFXTextureUsageBit["DEPTH_STENCIL_ATTACHMENT"] = 32] = "DEPTH_STENCIL_ATTACHMENT"; + GFXTextureUsageBit[GFXTextureUsageBit["TRANSIENT_ATTACHMENT"] = 64] = "TRANSIENT_ATTACHMENT"; + GFXTextureUsageBit[GFXTextureUsageBit["INPUT_ATTACHMENT"] = 128] = "INPUT_ATTACHMENT"; + })(GFXTextureUsageBit || (GFXTextureUsageBit = {})); + var GFXSampleCount; + (function(GFXSampleCount) { + GFXSampleCount[GFXSampleCount["X1"] = 0] = "X1"; + GFXSampleCount[GFXSampleCount["X2"] = 1] = "X2"; + GFXSampleCount[GFXSampleCount["X4"] = 2] = "X4"; + GFXSampleCount[GFXSampleCount["X8"] = 3] = "X8"; + GFXSampleCount[GFXSampleCount["X16"] = 4] = "X16"; + GFXSampleCount[GFXSampleCount["X32"] = 5] = "X32"; + GFXSampleCount[GFXSampleCount["X64"] = 6] = "X64"; + })(GFXSampleCount || (GFXSampleCount = {})); + var GFXTextureFlagBit; + (function(GFXTextureFlagBit) { + GFXTextureFlagBit[GFXTextureFlagBit["NONE"] = 0] = "NONE"; + GFXTextureFlagBit[GFXTextureFlagBit["GEN_MIPMAP"] = 1] = "GEN_MIPMAP"; + GFXTextureFlagBit[GFXTextureFlagBit["CUBEMAP"] = 2] = "CUBEMAP"; + GFXTextureFlagBit[GFXTextureFlagBit["BAKUP_BUFFER"] = 4] = "BAKUP_BUFFER"; + })(GFXTextureFlagBit || (GFXTextureFlagBit = {})); + var GFXTextureViewType; + (function(GFXTextureViewType) { + GFXTextureViewType[GFXTextureViewType["TV1D"] = 0] = "TV1D"; + GFXTextureViewType[GFXTextureViewType["TV2D"] = 1] = "TV2D"; + GFXTextureViewType[GFXTextureViewType["TV3D"] = 2] = "TV3D"; + GFXTextureViewType[GFXTextureViewType["CUBE"] = 3] = "CUBE"; + GFXTextureViewType[GFXTextureViewType["TV1D_ARRAY"] = 4] = "TV1D_ARRAY"; + GFXTextureViewType[GFXTextureViewType["TV2D_ARRAY"] = 5] = "TV2D_ARRAY"; + })(GFXTextureViewType || (GFXTextureViewType = {})); + var GFXShaderType; + (function(GFXShaderType) { + GFXShaderType[GFXShaderType["VERTEX"] = 0] = "VERTEX"; + GFXShaderType[GFXShaderType["HULL"] = 1] = "HULL"; + GFXShaderType[GFXShaderType["DOMAIN"] = 2] = "DOMAIN"; + GFXShaderType[GFXShaderType["GEOMETRY"] = 3] = "GEOMETRY"; + GFXShaderType[GFXShaderType["FRAGMENT"] = 4] = "FRAGMENT"; + GFXShaderType[GFXShaderType["COMPUTE"] = 5] = "COMPUTE"; + GFXShaderType[GFXShaderType["COUNT"] = 6] = "COUNT"; + })(GFXShaderType || (GFXShaderType = {})); + var GFXBindingType; + (function(GFXBindingType) { + GFXBindingType[GFXBindingType["UNKNOWN"] = 0] = "UNKNOWN"; + GFXBindingType[GFXBindingType["UNIFORM_BUFFER"] = 1] = "UNIFORM_BUFFER"; + GFXBindingType[GFXBindingType["SAMPLER"] = 2] = "SAMPLER"; + GFXBindingType[GFXBindingType["STORAGE_BUFFER"] = 3] = "STORAGE_BUFFER"; + })(GFXBindingType || (GFXBindingType = {})); + var GFXCommandBufferType; + (function(GFXCommandBufferType) { + GFXCommandBufferType[GFXCommandBufferType["PRIMARY"] = 0] = "PRIMARY"; + GFXCommandBufferType[GFXCommandBufferType["SECONDARY"] = 1] = "SECONDARY"; + })(GFXCommandBufferType || (GFXCommandBufferType = {})); + var GFXLoadOp; + (function(GFXLoadOp) { + GFXLoadOp[GFXLoadOp["LOAD"] = 0] = "LOAD"; + GFXLoadOp[GFXLoadOp["CLEAR"] = 1] = "CLEAR"; + GFXLoadOp[GFXLoadOp["DISCARD"] = 2] = "DISCARD"; + })(GFXLoadOp || (GFXLoadOp = {})); + var GFXStoreOp; + (function(GFXStoreOp) { + GFXStoreOp[GFXStoreOp["STORE"] = 0] = "STORE"; + GFXStoreOp[GFXStoreOp["DISCARD"] = 1] = "DISCARD"; + })(GFXStoreOp || (GFXStoreOp = {})); + var GFXTextureLayout; + (function(GFXTextureLayout) { + GFXTextureLayout[GFXTextureLayout["UNDEFINED"] = 0] = "UNDEFINED"; + GFXTextureLayout[GFXTextureLayout["GENERAL"] = 1] = "GENERAL"; + GFXTextureLayout[GFXTextureLayout["COLOR_ATTACHMENT_OPTIMAL"] = 2] = "COLOR_ATTACHMENT_OPTIMAL"; + GFXTextureLayout[GFXTextureLayout["DEPTH_STENCIL_ATTACHMENT_OPTIMAL"] = 3] = "DEPTH_STENCIL_ATTACHMENT_OPTIMAL"; + GFXTextureLayout[GFXTextureLayout["DEPTH_STENCIL_READONLY_OPTIMAL"] = 4] = "DEPTH_STENCIL_READONLY_OPTIMAL"; + GFXTextureLayout[GFXTextureLayout["SHADER_READONLY_OPTIMAL"] = 5] = "SHADER_READONLY_OPTIMAL"; + GFXTextureLayout[GFXTextureLayout["TRANSFER_SRC_OPTIMAL"] = 6] = "TRANSFER_SRC_OPTIMAL"; + GFXTextureLayout[GFXTextureLayout["TRANSFER_DST_OPTIMAL"] = 7] = "TRANSFER_DST_OPTIMAL"; + GFXTextureLayout[GFXTextureLayout["PREINITIALIZED"] = 8] = "PREINITIALIZED"; + GFXTextureLayout[GFXTextureLayout["PRESENT_SRC"] = 9] = "PRESENT_SRC"; + })(GFXTextureLayout || (GFXTextureLayout = {})); + var GFXPipelineBindPoint; + (function(GFXPipelineBindPoint) { + GFXPipelineBindPoint[GFXPipelineBindPoint["GRAPHICS"] = 0] = "GRAPHICS"; + GFXPipelineBindPoint[GFXPipelineBindPoint["COMPUTE"] = 1] = "COMPUTE"; + GFXPipelineBindPoint[GFXPipelineBindPoint["RAY_TRACING"] = 2] = "RAY_TRACING"; + })(GFXPipelineBindPoint || (GFXPipelineBindPoint = {})); + var GFXDynamicState; + (function(GFXDynamicState) { + GFXDynamicState[GFXDynamicState["VIEWPORT"] = 0] = "VIEWPORT"; + GFXDynamicState[GFXDynamicState["SCISSOR"] = 1] = "SCISSOR"; + GFXDynamicState[GFXDynamicState["LINE_WIDTH"] = 2] = "LINE_WIDTH"; + GFXDynamicState[GFXDynamicState["DEPTH_BIAS"] = 3] = "DEPTH_BIAS"; + GFXDynamicState[GFXDynamicState["BLEND_CONSTANTS"] = 4] = "BLEND_CONSTANTS"; + GFXDynamicState[GFXDynamicState["DEPTH_BOUNDS"] = 5] = "DEPTH_BOUNDS"; + GFXDynamicState[GFXDynamicState["STENCIL_WRITE_MASK"] = 6] = "STENCIL_WRITE_MASK"; + GFXDynamicState[GFXDynamicState["STENCIL_COMPARE_MASK"] = 7] = "STENCIL_COMPARE_MASK"; + })(GFXDynamicState || (GFXDynamicState = {})); + var GFXStencilFace; + (function(GFXStencilFace) { + GFXStencilFace[GFXStencilFace["FRONT"] = 0] = "FRONT"; + GFXStencilFace[GFXStencilFace["BACK"] = 1] = "BACK"; + GFXStencilFace[GFXStencilFace["ALL"] = 2] = "ALL"; + })(GFXStencilFace || (GFXStencilFace = {})); + var GFXQueueType; + (function(GFXQueueType) { + GFXQueueType[GFXQueueType["GRAPHICS"] = 0] = "GRAPHICS"; + GFXQueueType[GFXQueueType["COMPUTE"] = 1] = "COMPUTE"; + GFXQueueType[GFXQueueType["TRANSFER"] = 2] = "TRANSFER"; + })(GFXQueueType || (GFXQueueType = {})); + var GFXClearFlag; + (function(GFXClearFlag) { + GFXClearFlag[GFXClearFlag["NONE"] = 0] = "NONE"; + GFXClearFlag[GFXClearFlag["COLOR"] = 1] = "COLOR"; + GFXClearFlag[GFXClearFlag["DEPTH"] = 2] = "DEPTH"; + GFXClearFlag[GFXClearFlag["STENCIL"] = 4] = "STENCIL"; + GFXClearFlag[GFXClearFlag["DEPTH_STENCIL"] = 6] = "DEPTH_STENCIL"; + GFXClearFlag[GFXClearFlag["ALL"] = 7] = "ALL"; + })(GFXClearFlag || (GFXClearFlag = {})); + function GFXGetTypeSize(type) { + switch (type) { + case GFXType.BOOL: + case GFXType.INT: + case GFXType.UINT: + case GFXType.FLOAT: + return 4; + + case GFXType.BOOL2: + case GFXType.INT2: + case GFXType.UINT2: + case GFXType.FLOAT2: + return 8; + + case GFXType.BOOL3: + case GFXType.INT3: + case GFXType.UINT3: + case GFXType.FLOAT3: + return 12; + + case GFXType.BOOL4: + case GFXType.INT4: + case GFXType.UINT4: + case GFXType.FLOAT4: + case GFXType.MAT2: + return 16; + + case GFXType.MAT2X3: + return 24; + + case GFXType.MAT2X4: + return 32; + + case GFXType.MAT3X2: + return 24; + + case GFXType.MAT3: + return 36; + + case GFXType.MAT3X4: + return 48; + + case GFXType.MAT4X2: + case GFXType.MAT4X2: + return 32; + + case GFXType.MAT4: + return 64; + + case GFXType.SAMPLER1D: + case GFXType.SAMPLER1D_ARRAY: + case GFXType.SAMPLER2D: + case GFXType.SAMPLER2D_ARRAY: + case GFXType.SAMPLER3D: + case GFXType.SAMPLER_CUBE: + return 4; + + default: + return 0; + } + } + var RenderPassStage; + (function(RenderPassStage) { + RenderPassStage[RenderPassStage["DEFAULT"] = 100] = "DEFAULT"; + })(RenderPassStage || (RenderPassStage = {})); + var RenderPriority; + (function(RenderPriority) { + RenderPriority[RenderPriority["MIN"] = 0] = "MIN"; + RenderPriority[RenderPriority["MAX"] = 255] = "MAX"; + RenderPriority[RenderPriority["DEFAULT"] = 128] = "DEFAULT"; + })(RenderPriority || (RenderPriority = {})); + var MAX_BINDING_SUPPORTED = 24; + var UniformBinding; + (function(UniformBinding) { + UniformBinding[UniformBinding["UBO_GLOBAL"] = MAX_BINDING_SUPPORTED - 1] = "UBO_GLOBAL"; + UniformBinding[UniformBinding["UBO_SHADOW"] = MAX_BINDING_SUPPORTED - 2] = "UBO_SHADOW"; + UniformBinding[UniformBinding["UBO_LOCAL"] = MAX_BINDING_SUPPORTED - 3] = "UBO_LOCAL"; + UniformBinding[UniformBinding["UBO_FORWARD_LIGHTS"] = MAX_BINDING_SUPPORTED - 4] = "UBO_FORWARD_LIGHTS"; + UniformBinding[UniformBinding["UBO_SKINNING"] = MAX_BINDING_SUPPORTED - 5] = "UBO_SKINNING"; + UniformBinding[UniformBinding["UBO_SKINNING_TEXTURE"] = MAX_BINDING_SUPPORTED - 6] = "UBO_SKINNING_TEXTURE"; + UniformBinding[UniformBinding["UBO_UI"] = MAX_BINDING_SUPPORTED - 7] = "UBO_UI"; + UniformBinding[UniformBinding["SAMPLER_JOINTS"] = MAX_BINDING_SUPPORTED + 1] = "SAMPLER_JOINTS"; + UniformBinding[UniformBinding["SAMPLER_ENVIRONMENT"] = MAX_BINDING_SUPPORTED + 2] = "SAMPLER_ENVIRONMENT"; + UniformBinding[UniformBinding["CUSTUM_UBO_BINDING_END_POINT"] = MAX_BINDING_SUPPORTED - 7] = "CUSTUM_UBO_BINDING_END_POINT"; + UniformBinding[UniformBinding["CUSTOM_SAMPLER_BINDING_START_POINT"] = MAX_BINDING_SUPPORTED + 6] = "CUSTOM_SAMPLER_BINDING_START_POINT"; + })(UniformBinding || (UniformBinding = {})); + var _a, _b; + var SamplerInfoIndex; + (function(SamplerInfoIndex) { + SamplerInfoIndex[SamplerInfoIndex["minFilter"] = 0] = "minFilter"; + SamplerInfoIndex[SamplerInfoIndex["magFilter"] = 1] = "magFilter"; + SamplerInfoIndex[SamplerInfoIndex["mipFilter"] = 2] = "mipFilter"; + SamplerInfoIndex[SamplerInfoIndex["addressU"] = 3] = "addressU"; + SamplerInfoIndex[SamplerInfoIndex["addressV"] = 4] = "addressV"; + SamplerInfoIndex[SamplerInfoIndex["addressW"] = 5] = "addressW"; + SamplerInfoIndex[SamplerInfoIndex["maxAnisotropy"] = 6] = "maxAnisotropy"; + SamplerInfoIndex[SamplerInfoIndex["cmpFunc"] = 7] = "cmpFunc"; + SamplerInfoIndex[SamplerInfoIndex["minLOD"] = 8] = "minLOD"; + SamplerInfoIndex[SamplerInfoIndex["maxLOD"] = 9] = "maxLOD"; + SamplerInfoIndex[SamplerInfoIndex["mipLODBias"] = 10] = "mipLODBias"; + SamplerInfoIndex[SamplerInfoIndex["borderColor"] = 11] = "borderColor"; + SamplerInfoIndex[SamplerInfoIndex["total"] = 15] = "total"; + })(SamplerInfoIndex || (SamplerInfoIndex = {})); + var typeMap = {}; + typeMap[typeMap["bool"] = GFXType.BOOL] = "bool"; + typeMap[typeMap["int"] = GFXType.INT] = "int"; + typeMap[typeMap["ivec2"] = GFXType.INT2] = "ivec2invTypeParams"; + typeMap[typeMap["ivec3"] = GFXType.INT3] = "ivec3"; + typeMap[typeMap["ivec4"] = GFXType.INT4] = "ivec4"; + typeMap[typeMap["float"] = GFXType.FLOAT] = "float"; + typeMap[typeMap["vec2"] = GFXType.FLOAT2] = "vec2"; + typeMap[typeMap["vec3"] = GFXType.FLOAT3] = "vec3"; + typeMap[typeMap["vec4"] = GFXType.FLOAT4] = "vec4"; + typeMap[typeMap["mat2"] = GFXType.MAT2] = "mat2"; + typeMap[typeMap["mat3"] = GFXType.MAT3] = "mat3"; + typeMap[typeMap["mat4"] = GFXType.MAT4] = "mat4"; + typeMap[typeMap["sampler2D"] = GFXType.SAMPLER2D] = "sampler2D"; + typeMap[typeMap["samplerCube"] = GFXType.SAMPLER_CUBE] = "samplerCube"; + var sizeMap = (_a = {}, _a[GFXType.BOOL] = 4, _a[GFXType.INT] = 4, _a[GFXType.INT2] = 8, + _a[GFXType.INT3] = 12, _a[GFXType.INT4] = 16, _a[GFXType.FLOAT] = 4, _a[GFXType.FLOAT2] = 8, + _a[GFXType.FLOAT3] = 12, _a[GFXType.FLOAT4] = 16, _a[GFXType.MAT2] = 16, _a[GFXType.MAT3] = 36, + _a[GFXType.MAT4] = 64, _a[GFXType.SAMPLER2D] = 4, _a[GFXType.SAMPLER_CUBE] = 4, + _a); + var formatMap = (_b = {}, _b[GFXType.BOOL] = GFXFormat.R32I, _b[GFXType.INT] = GFXFormat.R32I, + _b[GFXType.INT2] = GFXFormat.RG32I, _b[GFXType.INT3] = GFXFormat.RGB32I, _b[GFXType.INT4] = GFXFormat.RGBA32I, + _b[GFXType.FLOAT] = GFXFormat.R32F, _b[GFXType.FLOAT2] = GFXFormat.RG32F, _b[GFXType.FLOAT3] = GFXFormat.RGB32F, + _b[GFXType.FLOAT4] = GFXFormat.RGBA32F, _b); + var passParams = { + BACK: enums.CULL_BACK, + FRONT: enums.CULL_FRONT, + NONE: enums.CULL_NONE, + ADD: enums.BLEND_FUNC_ADD, + SUB: enums.BLEND_FUNC_SUBTRACT, + REV_SUB: enums.BLEND_FUNC_REVERSE_SUBTRACT, + ZERO: enums.BLEND_ZERO, + ONE: enums.BLEND_ONE, + SRC_COLOR: enums.BLEND_SRC_COLOR, + ONE_MINUS_SRC_COLOR: enums.BLEND_ONE_MINUS_SRC_COLOR, + DST_COLOR: enums.BLEND_DST_COLOR, + ONE_MINUS_DST_COLOR: enums.BLEND_ONE_MINUS_DST_COLOR, + SRC_ALPHA: enums.BLEND_SRC_ALPHA, + ONE_MINUS_SRC_ALPHA: enums.BLEND_ONE_MINUS_SRC_ALPHA, + DST_ALPHA: enums.BLEND_DST_ALPHA, + ONE_MINUS_DST_ALPHA: enums.BLEND_ONE_MINUS_DST_ALPHA, + CONSTANT_COLOR: enums.BLEND_CONSTANT_COLOR, + ONE_MINUS_CONSTANT_COLOR: enums.BLEND_ONE_MINUS_CONSTANT_COLOR, + CONSTANT_ALPHA: enums.BLEND_CONSTANT_ALPHA, + ONE_MINUS_CONSTANT_ALPHA: enums.BLEND_ONE_MINUS_CONSTANT_ALPHA, + SRC_ALPHA_SATURATE: enums.BLEND_SRC_ALPHA_SATURATE, + NEVER: enums.DS_FUNC_NEVER, + LESS: enums.DS_FUNC_LESS, + EQUAL: enums.DS_FUNC_EQUAL, + LEQUAL: enums.DS_FUNC_LEQUAL, + GREATER: enums.DS_FUNC_GREATER, + NOTEQUAL: enums.DS_FUNC_NOTEQUAL, + GEQUAL: enums.DS_FUNC_GEQUAL, + ALWAYS: enums.DS_FUNC_ALWAYS, + KEEP: enums.STENCIL_OP_KEEP, + REPLACE: enums.STENCIL_OP_REPLACE, + INCR: enums.STENCIL_OP_INCR, + INCR_WRAP: enums.STENCIL_OP_INCR_WRAP, + DECR: enums.STENCIL_OP_DECR, + DECR_WRAP: enums.STENCIL_OP_DECR_WRAP, + INVERT: enums.STENCIL_OP_INVERT + }; + Object.assign(passParams, RenderPassStage); + var effectStructure = { + $techniques: [ { + $passes: [ { + depthStencilState: {}, + rasterizerState: {}, + blendState: { + targets: [ {} ] + }, + properties: { + any: { + sampler: {}, + inspector: {} + } + } + } ] + } ] + }; + var mappings = { + murmurhash2_32_gc: murmurhash2_32_gc, + SamplerInfoIndex: SamplerInfoIndex, + effectStructure: effectStructure, + typeMap: typeMap, + sizeMap: sizeMap, + formatMap: formatMap, + passParams: passParams, + RenderQueue: RenderQueue, + RenderPriority: RenderPriority, + GFXGetTypeSize: GFXGetTypeSize, + UniformBinding: UniformBinding + }; + module.exports = mappings; + }), {} ], + 362: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _memop = require("../memop"); + var _enums = _interopRequireDefault(require("../enums")); + var _valueTypes = require("../../core/value-types"); + var _programLib = _interopRequireDefault(require("./program-lib")); + var _view = _interopRequireDefault(require("./view")); + var _gfx = _interopRequireDefault(require("../gfx")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + var _m4_tmp = new _valueTypes.Mat4(); + var _stageInfos = new _memop.RecyclePool(function() { + return { + stage: null, + items: null + }; + }, 8); + var _float2_pool = new _memop.RecyclePool(function() { + return new Float32Array(2); + }, 8); + var _float3_pool = new _memop.RecyclePool(function() { + return new Float32Array(3); + }, 8); + var _float4_pool = new _memop.RecyclePool(function() { + return new Float32Array(4); + }, 8); + var _float9_pool = new _memop.RecyclePool(function() { + return new Float32Array(9); + }, 8); + var _float16_pool = new _memop.RecyclePool(function() { + return new Float32Array(16); + }, 8); + var _float64_pool = new _memop.RecyclePool(function() { + return new Float32Array(64); + }, 8); + var _int2_pool = new _memop.RecyclePool(function() { + return new Int32Array(2); + }, 8); + var _int3_pool = new _memop.RecyclePool(function() { + return new Int32Array(3); + }, 8); + var _int4_pool = new _memop.RecyclePool(function() { + return new Int32Array(4); + }, 8); + var _int64_pool = new _memop.RecyclePool(function() { + return new Int32Array(64); + }, 8); + var Base = (function() { + function Base(device, opts) { + var _this$_type2defaultVa; + this._device = device; + this._programLib = new _programLib["default"](device); + this._opts = opts; + this._type2defaultValue = (_this$_type2defaultVa = {}, _this$_type2defaultVa[_enums["default"].PARAM_INT] = 0, + _this$_type2defaultVa[_enums["default"].PARAM_INT2] = new _valueTypes.Vec2(0, 0), + _this$_type2defaultVa[_enums["default"].PARAM_INT3] = new _valueTypes.Vec3(0, 0, 0), + _this$_type2defaultVa[_enums["default"].PARAM_INT4] = new _valueTypes.Vec4(0, 0, 0, 0), + _this$_type2defaultVa[_enums["default"].PARAM_FLOAT] = 0, _this$_type2defaultVa[_enums["default"].PARAM_FLOAT2] = new _valueTypes.Vec2(0, 0), + _this$_type2defaultVa[_enums["default"].PARAM_FLOAT3] = new _valueTypes.Vec3(0, 0, 0), + _this$_type2defaultVa[_enums["default"].PARAM_FLOAT4] = new _valueTypes.Vec4(0, 0, 0, 0), + _this$_type2defaultVa[_enums["default"].PARAM_COLOR4] = new _valueTypes.Color(0, 0, 0, 1), + _this$_type2defaultVa[_enums["default"].PARAM_MAT3] = new _valueTypes.Mat3(), _this$_type2defaultVa[_enums["default"].PARAM_MAT4] = new _valueTypes.Mat4(), + _this$_type2defaultVa[_enums["default"].PARAM_TEXTURE_2D] = opts.defaultTexture, + _this$_type2defaultVa[_enums["default"].PARAM_TEXTURE_CUBE] = opts.defaultTextureCube, + _this$_type2defaultVa); + this._stage2fn = {}; + this._usedTextureUnits = 0; + this._viewPools = new _memop.RecyclePool(function() { + return new _view["default"](); + }, 8); + this._drawItemsPools = new _memop.RecyclePool(function() { + return { + model: null, + node: null, + ia: null, + effect: null, + defines: null, + uniforms: null + }; + }, 100); + this._stageItemsPools = new _memop.RecyclePool(function() { + return new _memop.RecyclePool(function() { + return { + model: null, + node: null, + ia: null, + effect: null, + defines: null, + passes: [], + sortKey: -1, + uniforms: null + }; + }, 100); + }, 16); + this._definesChanged = false; + } + var _proto = Base.prototype; + _proto._resetTextuerUnit = function _resetTextuerUnit() { + this._usedTextureUnits = 0; + }; + _proto._allocTextureUnit = function _allocTextureUnit() { + var device = this._device; + var unit = this._usedTextureUnits; + unit >= device._caps.maxTextureUnits && console.warn("Trying to use " + unit + " texture units while this GPU supports only " + device._caps.maxTextureUnits); + this._usedTextureUnits += 1; + return unit; + }; + _proto._registerStage = function _registerStage(name, fn) { + this._stage2fn[name] = fn; + }; + _proto.clear = function clear() { + this._programLib.clear(); + this.reset(); + }; + _proto.reset = function reset() { + this._viewPools.reset(); + this._stageItemsPools.reset(); + this._definesChanged = false; + }; + _proto._requestView = function _requestView() { + return this._viewPools.add(); + }; + _proto._render = function _render(view, scene) { + var device = this._device; + device.setFrameBuffer(view._framebuffer); + device.setViewport(view._rect.x, view._rect.y, view._rect.w, view._rect.h); + var clearOpts = {}; + view._clearFlags & _enums["default"].CLEAR_COLOR && (clearOpts.color = _valueTypes.Vec4.toArray([], view._color)); + view._clearFlags & _enums["default"].CLEAR_DEPTH && (clearOpts.depth = view._depth); + view._clearFlags & _enums["default"].CLEAR_STENCIL && (clearOpts.stencil = view._stencil); + device.clear(clearOpts); + this._drawItemsPools.reset(); + for (var i = 0; i < scene._models.length; ++i) { + var model = scene._models.data[i]; + if (0 === (model._cullingMask & view._cullingMask)) continue; + var drawItem = this._drawItemsPools.add(); + model.extractDrawItem(drawItem); + } + _stageInfos.reset(); + for (var _i = 0; _i < view._stages.length; ++_i) { + var stage = view._stages[_i]; + var stageItems = this._stageItemsPools.add(); + stageItems.reset(); + for (var j = 0; j < this._drawItemsPools.length; ++j) { + var _drawItem = this._drawItemsPools.data[j]; + var passes = _drawItem.effect.stagePasses[stage]; + if (!passes || 0 === passes.length) continue; + var stageItem = stageItems.add(); + stageItem.passes = passes; + stageItem.model = _drawItem.model; + stageItem.node = _drawItem.node; + stageItem.ia = _drawItem.ia; + stageItem.effect = _drawItem.effect; + stageItem.defines = _drawItem.defines; + stageItem.sortKey = -1; + stageItem.uniforms = _drawItem.uniforms; + } + var stageInfo = _stageInfos.add(); + stageInfo.stage = stage; + stageInfo.items = stageItems; + } + for (var _i2 = 0; _i2 < _stageInfos.length; ++_i2) { + var info = _stageInfos.data[_i2]; + var fn = this._stage2fn[info.stage]; + fn(view, info.items); + } + }; + _proto._setProperty = function _setProperty(prop) { + var device = this._device; + var param = prop.value; + void 0 === param && (param = prop.val); + void 0 === param && (param = this._type2defaultValue[prop.type]); + if (void 0 === param) { + console.warn("Failed to set technique property " + prop.name + ", value not found."); + return; + } + if (prop.type === _enums["default"].PARAM_TEXTURE_2D || prop.type === _enums["default"].PARAM_TEXTURE_CUBE) if (Array.isArray(param)) { + if (param.length > prop.count) { + console.error("Failed to set property [" + prop.name + "] : The length of texture array [" + param.length + "] is bigger than [" + prop.count + "]."); + return; + } + var slots = _int64_pool.add(); + for (var index = 0; index < param.length; ++index) slots[index] = this._allocTextureUnit(); + device.setTextureArray(prop.name, param, slots); + } else device.setTexture(prop.name, param, this._allocTextureUnit()); else prop.directly ? device.setUniformDirectly(prop.name, param) : device.setUniform(prop.name, param); + }; + _proto._draw = function _draw(item) { + var device = this._device; + var programLib = this._programLib; + var node = item.node, ia = item.ia, passes = item.passes, effect = item.effect; + _float2_pool.reset(); + _float3_pool.reset(); + _float4_pool.reset(); + _float9_pool.reset(); + _float16_pool.reset(); + _float64_pool.reset(); + _int2_pool.reset(); + _int3_pool.reset(); + _int4_pool.reset(); + _int64_pool.reset(); + node.getWorldMatrix(_m4_tmp); + device.setUniform("cc_matWorld", _valueTypes.Mat4.toArray(_float16_pool.add(), _m4_tmp)); + _valueTypes.Mat4.invert(_m4_tmp, _m4_tmp); + _valueTypes.Mat4.transpose(_m4_tmp, _m4_tmp); + device.setUniform("cc_matWorldIT", _valueTypes.Mat4.toArray(_float16_pool.add(), _m4_tmp)); + var defines = this._defines; + for (var i = 0; i < passes.length; ++i) { + var pass = passes[i]; + this._definesChanged && (pass._programKey = null); + var count = ia.count; + ia._vertexBuffer && device.setVertexBuffer(0, ia._vertexBuffer); + ia._indexBuffer && device.setIndexBuffer(ia._indexBuffer); + device.setPrimitiveType(ia._primitiveType); + Object.setPrototypeOf(defines, pass._defines); + var program = programLib.getProgram(pass, defines, effect.name); + device.setProgram(program); + var uniforms = program._uniforms; + var variants = pass._properties; + for (var j = 0; j < uniforms.length; j++) { + var prop = variants[uniforms[j].name]; + void 0 !== prop && this._setProperty(prop); + } + device.setCullMode(pass._cullMode); + if (pass._blend) { + device.enableBlend(); + device.setBlendFuncSep(pass._blendSrc, pass._blendDst, pass._blendSrcAlpha, pass._blendDstAlpha); + device.setBlendEqSep(pass._blendEq, pass._blendAlphaEq); + device.setBlendColor32(pass._blendColor); + } + if (pass._depthTest) { + device.enableDepthTest(); + device.setDepthFunc(pass._depthFunc); + } + pass._depthWrite && device.enableDepthWrite(); + device.setStencilTest(pass._stencilTest); + if (pass._stencilTest === _gfx["default"].STENCIL_ENABLE) { + device.setStencilFuncFront(pass._stencilFuncFront, pass._stencilRefFront, pass._stencilMaskFront); + device.setStencilOpFront(pass._stencilFailOpFront, pass._stencilZFailOpFront, pass._stencilZPassOpFront, pass._stencilWriteMaskFront); + device.setStencilFuncBack(pass._stencilFuncBack, pass._stencilRefBack, pass._stencilMaskBack); + device.setStencilOpBack(pass._stencilFailOpBack, pass._stencilZFailOpBack, pass._stencilZPassOpBack, pass._stencilWriteMaskBack); + } + device.draw(ia._start, count); + this._resetTextuerUnit(); + } + }; + return Base; + })(); + exports["default"] = Base; + module.exports = exports["default"]; + }), { + "../../core/value-types": 340, + "../enums": 368, + "../gfx": 373, + "../memop": 385, + "./program-lib": 365, + "./view": 367 + } ], + 363: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _gfx = _interopRequireDefault(require("../gfx")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + "value" in descriptor && (descriptor.writable = true); + Object.defineProperty(target, descriptor.key, descriptor); + } + } + function _createClass(Constructor, protoProps, staticProps) { + protoProps && _defineProperties(Constructor.prototype, protoProps); + staticProps && _defineProperties(Constructor, staticProps); + return Constructor; + } + var InputAssembler = (function() { + function InputAssembler(vb, ib, pt) { + void 0 === pt && (pt = _gfx["default"].PT_TRIANGLES); + this._vertexBuffer = vb; + this._indexBuffer = ib; + this._primitiveType = pt; + this._start = 0; + this._count = -1; + } + _createClass(InputAssembler, [ { + key: "count", + get: function get() { + if (-1 !== this._count) return this._count; + if (this._indexBuffer) return this._indexBuffer.count; + if (this._vertexBuffer) return this._vertexBuffer.count; + return 0; + } + } ]); + return InputAssembler; + })(); + exports["default"] = InputAssembler; + module.exports = exports["default"]; + }), { + "../gfx": 373 + } ], + 364: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _gfx = _interopRequireDefault(require("../gfx")); + var _enums = _interopRequireDefault(require("../enums")); + var _valueType = _interopRequireDefault(require("../../core/value-types/value-type")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + var Pass = (function() { + function Pass(name, detailName, programName, stage, properties, defines) { + void 0 === properties && (properties = {}); + void 0 === defines && (defines = {}); + this._name = name; + this._detailName = detailName; + this._programName = programName; + this._programKey = null; + this._stage = stage; + this._properties = properties; + this._defines = defines; + this._propertyNames = Object.keys(properties); + this._defineNames = Object.keys(defines); + this._cullMode = _gfx["default"].CULL_BACK; + this._blend = false; + this._blendEq = _gfx["default"].BLEND_FUNC_ADD; + this._blendAlphaEq = _gfx["default"].BLEND_FUNC_ADD; + this._blendSrc = _gfx["default"].BLEND_SRC_ALPHA; + this._blendDst = _gfx["default"].BLEND_ONE_MINUS_SRC_ALPHA; + this._blendSrcAlpha = _gfx["default"].BLEND_SRC_ALPHA; + this._blendDstAlpha = _gfx["default"].BLEND_ONE_MINUS_SRC_ALPHA; + this._blendColor = 4294967295; + this._depthTest = false; + this._depthWrite = false; + this._depthFunc = _gfx["default"].DS_FUNC_LESS, this._stencilTest = _gfx["default"].STENCIL_INHERIT; + this._stencilFuncFront = _gfx["default"].DS_FUNC_ALWAYS; + this._stencilRefFront = 0; + this._stencilMaskFront = 255; + this._stencilFailOpFront = _gfx["default"].STENCIL_OP_KEEP; + this._stencilZFailOpFront = _gfx["default"].STENCIL_OP_KEEP; + this._stencilZPassOpFront = _gfx["default"].STENCIL_OP_KEEP; + this._stencilWriteMaskFront = 255; + this._stencilFuncBack = _gfx["default"].DS_FUNC_ALWAYS; + this._stencilRefBack = 0; + this._stencilMaskBack = 255; + this._stencilFailOpBack = _gfx["default"].STENCIL_OP_KEEP; + this._stencilZFailOpBack = _gfx["default"].STENCIL_OP_KEEP; + this._stencilZPassOpBack = _gfx["default"].STENCIL_OP_KEEP; + this._stencilWriteMaskBack = 255; + } + var _proto = Pass.prototype; + _proto.setCullMode = function setCullMode(cullMode) { + void 0 === cullMode && (cullMode = _gfx["default"].CULL_BACK); + this._cullMode = cullMode; + }; + _proto.setBlend = function setBlend(enabled, blendEq, blendSrc, blendDst, blendAlphaEq, blendSrcAlpha, blendDstAlpha, blendColor) { + void 0 === enabled && (enabled = false); + void 0 === blendEq && (blendEq = _gfx["default"].BLEND_FUNC_ADD); + void 0 === blendSrc && (blendSrc = _gfx["default"].BLEND_SRC_ALPHA); + void 0 === blendDst && (blendDst = _gfx["default"].BLEND_ONE_MINUS_SRC_ALPHA); + void 0 === blendAlphaEq && (blendAlphaEq = _gfx["default"].BLEND_FUNC_ADD); + void 0 === blendSrcAlpha && (blendSrcAlpha = _gfx["default"].BLEND_SRC_ALPHA); + void 0 === blendDstAlpha && (blendDstAlpha = _gfx["default"].BLEND_ONE_MINUS_SRC_ALPHA); + void 0 === blendColor && (blendColor = 4294967295); + this._blend = enabled; + this._blendEq = blendEq; + this._blendSrc = blendSrc; + this._blendDst = blendDst; + this._blendAlphaEq = blendAlphaEq; + this._blendSrcAlpha = blendSrcAlpha; + this._blendDstAlpha = blendDstAlpha; + this._blendColor = blendColor; + }; + _proto.setDepth = function setDepth(depthTest, depthWrite, depthFunc) { + void 0 === depthTest && (depthTest = false); + void 0 === depthWrite && (depthWrite = false); + void 0 === depthFunc && (depthFunc = _gfx["default"].DS_FUNC_LESS); + this._depthTest = depthTest; + this._depthWrite = depthWrite; + this._depthFunc = depthFunc; + }; + _proto.setStencilFront = function setStencilFront(enabled, stencilFunc, stencilRef, stencilMask, stencilFailOp, stencilZFailOp, stencilZPassOp, stencilWriteMask) { + void 0 === enabled && (enabled = _gfx["default"].STENCIL_INHERIT); + void 0 === stencilFunc && (stencilFunc = _gfx["default"].DS_FUNC_ALWAYS); + void 0 === stencilRef && (stencilRef = 0); + void 0 === stencilMask && (stencilMask = 255); + void 0 === stencilFailOp && (stencilFailOp = _gfx["default"].STENCIL_OP_KEEP); + void 0 === stencilZFailOp && (stencilZFailOp = _gfx["default"].STENCIL_OP_KEEP); + void 0 === stencilZPassOp && (stencilZPassOp = _gfx["default"].STENCIL_OP_KEEP); + void 0 === stencilWriteMask && (stencilWriteMask = 255); + this._stencilTest = enabled; + this._stencilFuncFront = stencilFunc; + this._stencilRefFront = stencilRef; + this._stencilMaskFront = stencilMask; + this._stencilFailOpFront = stencilFailOp; + this._stencilZFailOpFront = stencilZFailOp; + this._stencilZPassOpFront = stencilZPassOp; + this._stencilWriteMaskFront = stencilWriteMask; + }; + _proto.setStencilEnabled = function setStencilEnabled(stencilTest) { + void 0 === stencilTest && (stencilTest = _gfx["default"].STENCIL_INHERIT); + this._stencilTest = stencilTest; + }; + _proto.setStencilBack = function setStencilBack(stencilTest, stencilFunc, stencilRef, stencilMask, stencilFailOp, stencilZFailOp, stencilZPassOp, stencilWriteMask) { + void 0 === stencilTest && (stencilTest = _gfx["default"].STENCIL_INHERIT); + void 0 === stencilFunc && (stencilFunc = _gfx["default"].DS_FUNC_ALWAYS); + void 0 === stencilRef && (stencilRef = 0); + void 0 === stencilMask && (stencilMask = 255); + void 0 === stencilFailOp && (stencilFailOp = _gfx["default"].STENCIL_OP_KEEP); + void 0 === stencilZFailOp && (stencilZFailOp = _gfx["default"].STENCIL_OP_KEEP); + void 0 === stencilZPassOp && (stencilZPassOp = _gfx["default"].STENCIL_OP_KEEP); + void 0 === stencilWriteMask && (stencilWriteMask = 255); + this._stencilTest = stencilTest; + this._stencilFuncBack = stencilFunc; + this._stencilRefBack = stencilRef; + this._stencilMaskBack = stencilMask; + this._stencilFailOpBack = stencilFailOp; + this._stencilZFailOpBack = stencilZFailOp; + this._stencilZPassOpBack = stencilZPassOp; + this._stencilWriteMaskBack = stencilWriteMask; + }; + _proto.setStage = function setStage(stage) { + this._stage = stage; + }; + _proto.setProperties = function setProperties(properties) { + this._properties = properties; + }; + _proto.getProperty = function getProperty(name) { + if (!this._properties[name]) return; + return this._properties[name].value; + }; + _proto.setProperty = function setProperty(name, value, directly) { + var prop = this._properties[name]; + if (!prop) return false; + prop.directly = directly; + if (Array.isArray(value)) { + var array = prop.value; + if (array.length !== value.length) { + cc.warnID(9105, this._name, name); + return; + } + for (var i = 0; i < value.length; i++) array[i] = value[i]; + } else if (value && !ArrayBuffer.isView(value)) if (prop.type === _enums["default"].PARAM_TEXTURE_2D) prop.value = value.getImpl(); else if (value instanceof _valueType["default"]) value.constructor.toArray(prop.value, value); else { + "object" === typeof value && cc.warnID(9106, this._name, name); + prop.value = value; + } else prop.value = value; + return true; + }; + _proto.getDefine = function getDefine(name) { + return this._defines[name]; + }; + _proto.define = function define(name, value, force) { + var oldValue = this._defines[name]; + if (!force && void 0 === oldValue) return false; + if (oldValue !== value) { + this._defines[name] = value; + this._programKey = null; + } + return true; + }; + _proto.clone = function clone() { + var pass = new Pass(this._programName); + Object.assign(pass, this); + var newProperties = {}; + var properties = this._properties; + for (var name in properties) { + var prop = properties[name]; + var newProp = newProperties[name] = {}; + var value = prop.value; + Array.isArray(value) ? newProp.value = value.concat() : ArrayBuffer.isView(value) ? newProp.value = new value.__proto__.constructor(value) : newProp.value = value; + for (var _name in prop) { + if ("value" === _name) continue; + newProp[_name] = prop[_name]; + } + } + pass._properties = newProperties; + pass._defines = Object.assign({}, this._defines); + pass._propertyNames = this._propertyNames; + pass._defineNames = this._defineNames; + return pass; + }; + return Pass; + })(); + exports["default"] = Pass; + module.exports = exports["default"]; + }), { + "../../core/value-types/value-type": 348, + "../enums": 368, + "../gfx": 373 + } ], + 365: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _gfx = _interopRequireDefault(require("../gfx")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + var _shdID = 0; + function _generateDefines(tmpDefines, defines) { + var results = []; + for (var i = 0; i < tmpDefines.length; i++) { + var name = tmpDefines[i].name; + var value = defines[name]; + "number" !== typeof value && (value = value ? 1 : 0); + results.push("#define " + name + " " + value); + } + return results.join("\n") + "\n"; + } + function _replaceMacroNums(string, tmpDefines, defines) { + var tmp = string; + for (var i = 0; i < tmpDefines.length; i++) { + var name = tmpDefines[i].name; + var value = defines[name]; + if (Number.isInteger(value)) { + var reg = new RegExp(name, "g"); + tmp = tmp.replace(reg, value); + } + } + return tmp; + } + function _unrollLoops(string) { + var pattern = /#pragma for (\w+) in range\(\s*(\d+)\s*,\s*(\d+)\s*\)([\s\S]+?)#pragma endFor/g; + function replace(match, index, begin, end, snippet) { + var unroll = ""; + var parsedBegin = parseInt(begin); + var parsedEnd = parseInt(end); + (parsedBegin.isNaN || parsedEnd.isNaN) && console.error("Unroll For Loops Error: begin and end of range must be an int num."); + for (var i = parsedBegin; i < parsedEnd; ++i) unroll += snippet.replace(new RegExp("{" + index + "}", "g"), i); + return unroll; + } + return string.replace(pattern, replace); + } + function _replaceHighp(string) { + return string.replace(/\bhighp\b/g, "mediump"); + } + var ProgramLib = (function() { + function ProgramLib(device) { + this._device = device; + this._templates = {}; + this._cache = {}; + this._checkPrecision(); + } + var _proto = ProgramLib.prototype; + _proto.clear = function clear() { + this._templates = {}; + this._cache = {}; + }; + _proto.define = function define(prog) { + var name = prog.name, defines = prog.defines, glsl1 = prog.glsl1; + var _ref = glsl1 || prog, vert = _ref.vert, frag = _ref.frag; + if (this._templates[name]) return; + var id = ++_shdID; + var offset = 0; + for (var i = 0; i < defines.length; ++i) { + var def = defines[i]; + var cnt = 1; + if ("number" === def.type) { + var range = def.range || []; + def.min = range[0] || 0; + def.max = range[1] || 4; + cnt = Math.ceil(Math.log2(def.max - def.min)); + def._map = function(value) { + return value - this.min << this._offset; + }.bind(def); + } else def._map = function(value) { + if (value) return 1 << this._offset; + return 0; + }.bind(def); + def._offset = offset; + offset += cnt; + } + var uniforms = prog.uniforms || []; + if (prog.samplers) for (var _i = 0; _i < prog.samplers.length; _i++) uniforms.push(prog.samplers[_i]); + if (prog.blocks) for (var _i2 = 0; _i2 < prog.blocks.length; _i2++) { + var _defines = prog.blocks[_i2].defines; + var members = prog.blocks[_i2].members; + for (var j = 0; j < members.length; j++) uniforms.push({ + defines: _defines, + name: members[j].name, + type: members[j].type + }); + } + this._templates[name] = { + id: id, + name: name, + vert: vert, + frag: frag, + defines: defines, + attributes: prog.attributes, + uniforms: uniforms, + extensions: prog.extensions + }; + }; + _proto.getTemplate = function getTemplate(name) { + return this._templates[name]; + }; + _proto.hasProgram = function hasProgram(name) { + return void 0 !== this._templates[name]; + }; + _proto.getKey = function getKey(name, defines) { + var tmpl = this._templates[name]; + var key = 0; + for (var i = 0; i < tmpl.defines.length; ++i) { + var tmplDefs = tmpl.defines[i]; + var value = defines[tmplDefs.name]; + if (void 0 === value) continue; + key |= tmplDefs._map(value); + } + return tmpl.id + ":" + key; + }; + _proto.getProgram = function getProgram(pass, defines, errPrefix) { + var key = pass._programKey = pass._programKey || this.getKey(pass._programName, defines); + var program = this._cache[key]; + if (program) return program; + var tmpl = this._templates[pass._programName]; + var customDef = _generateDefines(tmpl.defines, defines); + var vert = _replaceMacroNums(tmpl.vert, tmpl.defines, defines); + vert = customDef + _unrollLoops(vert); + this._highpSupported || (vert = _replaceHighp(vert)); + var frag = _replaceMacroNums(tmpl.frag, tmpl.defines, defines); + frag = customDef + _unrollLoops(frag); + this._highpSupported || (frag = _replaceHighp(frag)); + program = new _gfx["default"].Program(this._device, { + vert: vert, + frag: frag + }); + var errors = program.link(); + if (errors) { + var vertLines = vert.split("\n"); + var fragLines = frag.split("\n"); + var defineLength = tmpl.defines.length; + errors.forEach((function(err) { + var line = err.line - 1; + var originLine = err.line - defineLength; + var lines = "vs" === err.type ? vertLines : fragLines; + var source = lines[line]; + var info = err.info || "Failed to compile " + err.type + " " + err.fileID + " (ln " + originLine + "): \n " + err.message + ": \n " + source; + cc.error(errPrefix + " : " + info); + })); + } + this._cache[key] = program; + return program; + }; + _proto._checkPrecision = function _checkPrecision() { + var gl = this._device._gl; + var highpSupported = false; + if (gl.getShaderPrecisionFormat) { + var vertHighp = gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.HIGH_FLOAT); + var fragHighp = gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.HIGH_FLOAT); + highpSupported = vertHighp && vertHighp.precision > 0 && fragHighp && fragHighp.precision > 0; + } + highpSupported || cc.warnID(9102); + this._highpSupported = highpSupported; + }; + return ProgramLib; + })(); + exports["default"] = ProgramLib; + module.exports = exports["default"]; + }), { + "../gfx": 373 + } ], + 366: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + "value" in descriptor && (descriptor.writable = true); + Object.defineProperty(target, descriptor.key, descriptor); + } + } + function _createClass(Constructor, protoProps, staticProps) { + protoProps && _defineProperties(Constructor.prototype, protoProps); + staticProps && _defineProperties(Constructor, staticProps); + return Constructor; + } + var Technique = (function() { + function Technique(name, passes) { + this._name = name; + this._passes = passes; + } + var _proto = Technique.prototype; + _proto.clone = function clone() { + var passes = []; + for (var i = 0; i < this._passes.length; i++) passes.push(this._passes[i].clone()); + return new Technique(this._name, passes); + }; + _createClass(Technique, [ { + key: "name", + get: function get() { + return this._name; + } + }, { + key: "passes", + get: function get() { + return this._passes; + } + } ]); + return Technique; + })(); + exports["default"] = Technique; + module.exports = exports["default"]; + }), {} ], + 367: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _valueTypes = require("../../core/value-types"); + var _enums = _interopRequireDefault(require("../enums")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + var _m4_tmp = new _valueTypes.Mat4(); + var _genID = 0; + var View = (function() { + function View() { + this._id = _genID++; + this._priority = 0; + this._rect = { + x: 0, + y: 0, + w: 1, + h: 1 + }; + this._color = new _valueTypes.Vec4(.3, .3, .3, 1); + this._depth = 1; + this._stencil = 0; + this._clearFlags = _enums["default"].CLEAR_COLOR | _enums["default"].CLEAR_DEPTH; + this._clearModel = null; + this._matView = cc.mat4(); + this._matViewInv = cc.mat4(); + this._matProj = cc.mat4(); + this._matViewProj = cc.mat4(); + this._matInvViewProj = cc.mat4(); + this._stages = []; + this._cullingByID = false; + this._framebuffer = null; + this._shadowLight = null; + this._cullingMask = 4294967295; + } + var _proto = View.prototype; + _proto.getForward = function getForward(out) { + var m = this._matView.m; + return _valueTypes.Vec3.set(out, -m[2], -m[6], -m[10]); + }; + _proto.getPosition = function getPosition(out) { + _valueTypes.Mat4.invert(_m4_tmp, this._matView); + return _valueTypes.Mat4.getTranslation(out, _m4_tmp); + }; + return View; + })(); + exports["default"] = View; + module.exports = exports["default"]; + }), { + "../../core/value-types": 340, + "../enums": 368 + } ], + 368: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _mappings = require("./build/mappings"); + var _default = { + PROJ_PERSPECTIVE: 0, + PROJ_ORTHO: 1, + LIGHT_DIRECTIONAL: 0, + LIGHT_POINT: 1, + LIGHT_SPOT: 2, + LIGHT_AMBIENT: 3, + SHADOW_NONE: 0, + SHADOW_HARD: 1, + SHADOW_SOFT: 2, + PARAM_INT: _mappings.typeMap["int"], + PARAM_INT2: _mappings.typeMap.ivec2, + PARAM_INT3: _mappings.typeMap.ivec3, + PARAM_INT4: _mappings.typeMap.ivec4, + PARAM_FLOAT: _mappings.typeMap["float"], + PARAM_FLOAT2: _mappings.typeMap.vec2, + PARAM_FLOAT3: _mappings.typeMap.vec3, + PARAM_FLOAT4: _mappings.typeMap.vec4, + PARAM_MAT2: _mappings.typeMap.mat2, + PARAM_MAT3: _mappings.typeMap.mat3, + PARAM_MAT4: _mappings.typeMap.mat4, + PARAM_TEXTURE_2D: _mappings.typeMap.sampler2D, + PARAM_TEXTURE_CUBE: _mappings.typeMap.samplerCube, + CLEAR_COLOR: 1, + CLEAR_DEPTH: 2, + CLEAR_STENCIL: 4, + CLEAR_SKYBOX: 8, + BUFFER_VIEW_INT8: 0, + BUFFER_VIEW_UINT8: 1, + BUFFER_VIEW_INT16: 2, + BUFFER_VIEW_UINT16: 3, + BUFFER_VIEW_INT32: 4, + BUFFER_VIEW_UINT32: 5, + BUFFER_VIEW_FLOAT32: 6 + }; + exports["default"] = _default; + module.exports = exports["default"]; + }), { + "./build/mappings": 361 + } ], + 369: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _state = _interopRequireDefault(require("./state")); + var _enums = require("./enums"); + var _texture2d = _interopRequireDefault(require("./texture-2d")); + var _textureCube = _interopRequireDefault(require("./texture-cube")); + var _type2uniformCommit2, _type2uniformArrayCom; + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + "value" in descriptor && (descriptor.writable = true); + Object.defineProperty(target, descriptor.key, descriptor); + } + } + function _createClass(Constructor, protoProps, staticProps) { + protoProps && _defineProperties(Constructor.prototype, protoProps); + staticProps && _defineProperties(Constructor, staticProps); + return Constructor; + } + var GL_INT = 5124; + var GL_FLOAT = 5126; + var GL_FLOAT_VEC2 = 35664; + var GL_FLOAT_VEC3 = 35665; + var GL_FLOAT_VEC4 = 35666; + var GL_INT_VEC2 = 35667; + var GL_INT_VEC3 = 35668; + var GL_INT_VEC4 = 35669; + var GL_BOOL = 35670; + var GL_BOOL_VEC2 = 35671; + var GL_BOOL_VEC3 = 35672; + var GL_BOOL_VEC4 = 35673; + var GL_FLOAT_MAT2 = 35674; + var GL_FLOAT_MAT3 = 35675; + var GL_FLOAT_MAT4 = 35676; + var GL_SAMPLER_2D = 35678; + var GL_SAMPLER_CUBE = 35680; + var _type2uniformCommit = (_type2uniformCommit2 = {}, _type2uniformCommit2[GL_INT] = function(gl, id, value) { + gl.uniform1i(id, value); + }, _type2uniformCommit2[GL_FLOAT] = function(gl, id, value) { + gl.uniform1f(id, value); + }, _type2uniformCommit2[GL_FLOAT_VEC2] = function(gl, id, value) { + gl.uniform2fv(id, value); + }, _type2uniformCommit2[GL_FLOAT_VEC3] = function(gl, id, value) { + gl.uniform3fv(id, value); + }, _type2uniformCommit2[GL_FLOAT_VEC4] = function(gl, id, value) { + gl.uniform4fv(id, value); + }, _type2uniformCommit2[GL_INT_VEC2] = function(gl, id, value) { + gl.uniform2iv(id, value); + }, _type2uniformCommit2[GL_INT_VEC3] = function(gl, id, value) { + gl.uniform3iv(id, value); + }, _type2uniformCommit2[GL_INT_VEC4] = function(gl, id, value) { + gl.uniform4iv(id, value); + }, _type2uniformCommit2[GL_BOOL] = function(gl, id, value) { + gl.uniform1i(id, value); + }, _type2uniformCommit2[GL_BOOL_VEC2] = function(gl, id, value) { + gl.uniform2iv(id, value); + }, _type2uniformCommit2[GL_BOOL_VEC3] = function(gl, id, value) { + gl.uniform3iv(id, value); + }, _type2uniformCommit2[GL_BOOL_VEC4] = function(gl, id, value) { + gl.uniform4iv(id, value); + }, _type2uniformCommit2[GL_FLOAT_MAT2] = function(gl, id, value) { + gl.uniformMatrix2fv(id, false, value); + }, _type2uniformCommit2[GL_FLOAT_MAT3] = function(gl, id, value) { + gl.uniformMatrix3fv(id, false, value); + }, _type2uniformCommit2[GL_FLOAT_MAT4] = function(gl, id, value) { + gl.uniformMatrix4fv(id, false, value); + }, _type2uniformCommit2[GL_SAMPLER_2D] = function(gl, id, value) { + gl.uniform1i(id, value); + }, _type2uniformCommit2[GL_SAMPLER_CUBE] = function(gl, id, value) { + gl.uniform1i(id, value); + }, _type2uniformCommit2); + var _type2uniformArrayCommit = (_type2uniformArrayCom = {}, _type2uniformArrayCom[GL_INT] = function(gl, id, value) { + gl.uniform1iv(id, value); + }, _type2uniformArrayCom[GL_FLOAT] = function(gl, id, value) { + gl.uniform1fv(id, value); + }, _type2uniformArrayCom[GL_FLOAT_VEC2] = function(gl, id, value) { + gl.uniform2fv(id, value); + }, _type2uniformArrayCom[GL_FLOAT_VEC3] = function(gl, id, value) { + gl.uniform3fv(id, value); + }, _type2uniformArrayCom[GL_FLOAT_VEC4] = function(gl, id, value) { + gl.uniform4fv(id, value); + }, _type2uniformArrayCom[GL_INT_VEC2] = function(gl, id, value) { + gl.uniform2iv(id, value); + }, _type2uniformArrayCom[GL_INT_VEC3] = function(gl, id, value) { + gl.uniform3iv(id, value); + }, _type2uniformArrayCom[GL_INT_VEC4] = function(gl, id, value) { + gl.uniform4iv(id, value); + }, _type2uniformArrayCom[GL_BOOL] = function(gl, id, value) { + gl.uniform1iv(id, value); + }, _type2uniformArrayCom[GL_BOOL_VEC2] = function(gl, id, value) { + gl.uniform2iv(id, value); + }, _type2uniformArrayCom[GL_BOOL_VEC3] = function(gl, id, value) { + gl.uniform3iv(id, value); + }, _type2uniformArrayCom[GL_BOOL_VEC4] = function(gl, id, value) { + gl.uniform4iv(id, value); + }, _type2uniformArrayCom[GL_FLOAT_MAT2] = function(gl, id, value) { + gl.uniformMatrix2fv(id, false, value); + }, _type2uniformArrayCom[GL_FLOAT_MAT3] = function(gl, id, value) { + gl.uniformMatrix3fv(id, false, value); + }, _type2uniformArrayCom[GL_FLOAT_MAT4] = function(gl, id, value) { + gl.uniformMatrix4fv(id, false, value); + }, _type2uniformArrayCom[GL_SAMPLER_2D] = function(gl, id, value) { + gl.uniform1iv(id, value); + }, _type2uniformArrayCom[GL_SAMPLER_CUBE] = function(gl, id, value) { + gl.uniform1iv(id, value); + }, _type2uniformArrayCom); + function _commitBlendStates(gl, cur, next) { + if (cur.blend !== next.blend) { + if (!next.blend) { + gl.disable(gl.BLEND); + return; + } + gl.enable(gl.BLEND); + next.blendSrc !== _enums.enums.BLEND_CONSTANT_COLOR && next.blendSrc !== _enums.enums.BLEND_ONE_MINUS_CONSTANT_COLOR && next.blendDst !== _enums.enums.BLEND_CONSTANT_COLOR && next.blendDst !== _enums.enums.BLEND_ONE_MINUS_CONSTANT_COLOR || gl.blendColor((next.blendColor >> 24) / 255, (next.blendColor >> 16 & 255) / 255, (next.blendColor >> 8 & 255) / 255, (255 & next.blendColor) / 255); + if (next.blendSep) { + gl.blendFuncSeparate(next.blendSrc, next.blendDst, next.blendSrcAlpha, next.blendDstAlpha); + gl.blendEquationSeparate(next.blendEq, next.blendAlphaEq); + } else { + gl.blendFunc(next.blendSrc, next.blendDst); + gl.blendEquation(next.blendEq); + } + return; + } + if (false === next.blend) return; + cur.blendColor !== next.blendColor && gl.blendColor((next.blendColor >> 24) / 255, (next.blendColor >> 16 & 255) / 255, (next.blendColor >> 8 & 255) / 255, (255 & next.blendColor) / 255); + if (cur.blendSep !== next.blendSep) { + if (next.blendSep) { + gl.blendFuncSeparate(next.blendSrc, next.blendDst, next.blendSrcAlpha, next.blendDstAlpha); + gl.blendEquationSeparate(next.blendEq, next.blendAlphaEq); + } else { + gl.blendFunc(next.blendSrc, next.blendDst); + gl.blendEquation(next.blendEq); + } + return; + } + if (next.blendSep) { + cur.blendSrc === next.blendSrc && cur.blendDst === next.blendDst && cur.blendSrcAlpha === next.blendSrcAlpha && cur.blendDstAlpha === next.blendDstAlpha || gl.blendFuncSeparate(next.blendSrc, next.blendDst, next.blendSrcAlpha, next.blendDstAlpha); + cur.blendEq === next.blendEq && cur.blendAlphaEq === next.blendAlphaEq || gl.blendEquationSeparate(next.blendEq, next.blendAlphaEq); + } else { + cur.blendSrc === next.blendSrc && cur.blendDst === next.blendDst || gl.blendFunc(next.blendSrc, next.blendDst); + cur.blendEq !== next.blendEq && gl.blendEquation(next.blendEq); + } + } + function _commitDepthStates(gl, cur, next) { + if (cur.depthTest !== next.depthTest) { + if (!next.depthTest) { + gl.disable(gl.DEPTH_TEST); + return; + } + gl.enable(gl.DEPTH_TEST); + gl.depthFunc(next.depthFunc); + gl.depthMask(next.depthWrite); + return; + } + cur.depthWrite !== next.depthWrite && gl.depthMask(next.depthWrite); + if (false === next.depthTest) { + if (next.depthWrite) { + next.depthTest = true; + next.depthFunc = _enums.enums.DS_FUNC_ALWAYS; + gl.enable(gl.DEPTH_TEST); + gl.depthFunc(next.depthFunc); + } + return; + } + cur.depthFunc !== next.depthFunc && gl.depthFunc(next.depthFunc); + } + function _commitStencilStates(gl, cur, next) { + if (next.stencilTest === _enums.enums.STENCIL_INHERIT) return; + if (next.stencilTest !== cur.stencilTest) { + if (next.stencilTest === _enums.enums.STENCIL_DISABLE) { + gl.disable(gl.STENCIL_TEST); + return; + } + gl.enable(gl.STENCIL_TEST); + if (next.stencilSep) { + gl.stencilFuncSeparate(gl.FRONT, next.stencilFuncFront, next.stencilRefFront, next.stencilMaskFront); + gl.stencilMaskSeparate(gl.FRONT, next.stencilWriteMaskFront); + gl.stencilOpSeparate(gl.FRONT, next.stencilFailOpFront, next.stencilZFailOpFront, next.stencilZPassOpFront); + gl.stencilFuncSeparate(gl.BACK, next.stencilFuncBack, next.stencilRefBack, next.stencilMaskBack); + gl.stencilMaskSeparate(gl.BACK, next.stencilWriteMaskBack); + gl.stencilOpSeparate(gl.BACK, next.stencilFailOpBack, next.stencilZFailOpBack, next.stencilZPassOpBack); + } else { + gl.stencilFunc(next.stencilFuncFront, next.stencilRefFront, next.stencilMaskFront); + gl.stencilMask(next.stencilWriteMaskFront); + gl.stencilOp(next.stencilFailOpFront, next.stencilZFailOpFront, next.stencilZPassOpFront); + } + return; + } + if (next.stencilTest === _enums.enums.STENCIL_DISABLE) return; + if (cur.stencilSep !== next.stencilSep) { + if (next.stencilSep) { + gl.stencilFuncSeparate(gl.FRONT, next.stencilFuncFront, next.stencilRefFront, next.stencilMaskFront); + gl.stencilMaskSeparate(gl.FRONT, next.stencilWriteMaskFront); + gl.stencilOpSeparate(gl.FRONT, next.stencilFailOpFront, next.stencilZFailOpFront, next.stencilZPassOpFront); + gl.stencilFuncSeparate(gl.BACK, next.stencilFuncBack, next.stencilRefBack, next.stencilMaskBack); + gl.stencilMaskSeparate(gl.BACK, next.stencilWriteMaskBack); + gl.stencilOpSeparate(gl.BACK, next.stencilFailOpBack, next.stencilZFailOpBack, next.stencilZPassOpBack); + } else { + gl.stencilFunc(next.stencilFuncFront, next.stencilRefFront, next.stencilMaskFront); + gl.stencilMask(next.stencilWriteMaskFront); + gl.stencilOp(next.stencilFailOpFront, next.stencilZFailOpFront, next.stencilZPassOpFront); + } + return; + } + if (next.stencilSep) { + cur.stencilFuncFront === next.stencilFuncFront && cur.stencilRefFront === next.stencilRefFront && cur.stencilMaskFront === next.stencilMaskFront || gl.stencilFuncSeparate(gl.FRONT, next.stencilFuncFront, next.stencilRefFront, next.stencilMaskFront); + cur.stencilWriteMaskFront !== next.stencilWriteMaskFront && gl.stencilMaskSeparate(gl.FRONT, next.stencilWriteMaskFront); + cur.stencilFailOpFront === next.stencilFailOpFront && cur.stencilZFailOpFront === next.stencilZFailOpFront && cur.stencilZPassOpFront === next.stencilZPassOpFront || gl.stencilOpSeparate(gl.FRONT, next.stencilFailOpFront, next.stencilZFailOpFront, next.stencilZPassOpFront); + cur.stencilFuncBack === next.stencilFuncBack && cur.stencilRefBack === next.stencilRefBack && cur.stencilMaskBack === next.stencilMaskBack || gl.stencilFuncSeparate(gl.BACK, next.stencilFuncBack, next.stencilRefBack, next.stencilMaskBack); + cur.stencilWriteMaskBack !== next.stencilWriteMaskBack && gl.stencilMaskSeparate(gl.BACK, next.stencilWriteMaskBack); + cur.stencilFailOpBack === next.stencilFailOpBack && cur.stencilZFailOpBack === next.stencilZFailOpBack && cur.stencilZPassOpBack === next.stencilZPassOpBack || gl.stencilOpSeparate(gl.BACK, next.stencilFailOpBack, next.stencilZFailOpBack, next.stencilZPassOpBack); + } else { + cur.stencilFuncFront === next.stencilFuncFront && cur.stencilRefFront === next.stencilRefFront && cur.stencilMaskFront === next.stencilMaskFront || gl.stencilFunc(next.stencilFuncFront, next.stencilRefFront, next.stencilMaskFront); + cur.stencilWriteMaskFront !== next.stencilWriteMaskFront && gl.stencilMask(next.stencilWriteMaskFront); + cur.stencilFailOpFront === next.stencilFailOpFront && cur.stencilZFailOpFront === next.stencilZFailOpFront && cur.stencilZPassOpFront === next.stencilZPassOpFront || gl.stencilOp(next.stencilFailOpFront, next.stencilZFailOpFront, next.stencilZPassOpFront); + } + } + function _commitCullMode(gl, cur, next) { + if (cur.cullMode === next.cullMode) return; + if (next.cullMode === _enums.enums.CULL_NONE) { + gl.disable(gl.CULL_FACE); + return; + } + gl.enable(gl.CULL_FACE); + gl.cullFace(next.cullMode); + } + function _commitVertexBuffers(device, gl, cur, next) { + var attrsDirty = false; + if (-1 === next.maxStream) return; + if (cur.maxStream !== next.maxStream) attrsDirty = true; else if (cur.program !== next.program) attrsDirty = true; else for (var i = 0; i < next.maxStream + 1; ++i) if (cur.vertexBuffers[i] !== next.vertexBuffers[i] || cur.vertexBufferOffsets[i] !== next.vertexBufferOffsets[i]) { + attrsDirty = true; + break; + } + if (attrsDirty) { + for (var _i = 0; _i < device._caps.maxVertexAttribs; ++_i) device._newAttributes[_i] = 0; + for (var _i2 = 0; _i2 < next.maxStream + 1; ++_i2) { + var vb = next.vertexBuffers[_i2]; + var vbOffset = next.vertexBufferOffsets[_i2]; + if (!vb || -1 === vb._glID) continue; + gl.bindBuffer(gl.ARRAY_BUFFER, vb._glID); + for (var j = 0; j < next.program._attributes.length; ++j) { + var attr = next.program._attributes[j]; + var el = vb._format.element(attr.name); + if (!el) { + console.warn("Can not find vertex attribute: " + attr.name); + continue; + } + if (0 === device._enabledAttributes[attr.location]) { + gl.enableVertexAttribArray(attr.location); + device._enabledAttributes[attr.location] = 1; + } + device._newAttributes[attr.location] = 1; + gl.vertexAttribPointer(attr.location, el.num, el.type, el.normalize, el.stride, el.offset + vbOffset * el.stride); + } + } + for (var _i3 = 0; _i3 < device._caps.maxVertexAttribs; ++_i3) if (device._enabledAttributes[_i3] !== device._newAttributes[_i3]) { + gl.disableVertexAttribArray(_i3); + device._enabledAttributes[_i3] = 0; + } + } + } + function _commitTextures(gl, cur, next) { + for (var i = 0; i < next.maxTextureSlot + 1; ++i) if (cur.textureUnits[i] !== next.textureUnits[i]) { + var texture = next.textureUnits[i]; + if (texture && -1 !== texture._glID) { + gl.activeTexture(gl.TEXTURE0 + i); + gl.bindTexture(texture._target, texture._glID); + } + } + } + function _attach(gl, location, attachment, face) { + void 0 === face && (face = 0); + attachment instanceof _texture2d["default"] ? gl.framebufferTexture2D(gl.FRAMEBUFFER, location, gl.TEXTURE_2D, attachment._glID, 0) : attachment instanceof _textureCube["default"] ? gl.framebufferTexture2D(gl.FRAMEBUFFER, location, gl.TEXTURE_CUBE_MAP_POSITIVE_X + face, attachment._glID, 0) : gl.framebufferRenderbuffer(gl.FRAMEBUFFER, location, gl.RENDERBUFFER, attachment._glID); + } + var Device = (function() { + function Device(canvasEL, opts) { + var gl; + opts = opts || {}; + void 0 === opts.alpha && (opts.alpha = false); + void 0 === opts.stencil && (opts.stencil = true); + void 0 === opts.depth && (opts.depth = true); + void 0 === opts.antialias && (opts.antialias = false); + void 0 === opts.preserveDrawingBuffer && (opts.preserveDrawingBuffer = false); + try { + gl = canvasEL.getContext("webgl", opts) || canvasEL.getContext("experimental-webgl", opts) || canvasEL.getContext("webkit-3d", opts) || canvasEL.getContext("moz-webgl", opts); + } catch (err) { + console.error(err); + return; + } + gl || console.error("This device does not support webgl"); + this._gl = gl; + this._extensions = {}; + this._caps = {}; + this._stats = { + texture: 0, + vb: 0, + ib: 0, + drawcalls: 0 + }; + this._initExtensions([ "EXT_texture_filter_anisotropic", "EXT_shader_texture_lod", "OES_standard_derivatives", "OES_texture_float", "OES_texture_float_linear", "OES_texture_half_float", "OES_texture_half_float_linear", "OES_vertex_array_object", "WEBGL_compressed_texture_atc", "WEBGL_compressed_texture_etc", "WEBGL_compressed_texture_etc1", "WEBGL_compressed_texture_pvrtc", "WEBGL_compressed_texture_s3tc", "WEBGL_depth_texture", "WEBGL_draw_buffers" ]); + this._initCaps(); + this._initStates(); + _state["default"].initDefault(this); + this._current = new _state["default"](this); + this._next = new _state["default"](this); + this._uniforms = {}; + this._vx = this._vy = this._vw = this._vh = 0; + this._sx = this._sy = this._sw = this._sh = 0; + this._framebuffer = null; + this._enabledAttributes = new Array(this._caps.maxVertexAttribs); + this._newAttributes = new Array(this._caps.maxVertexAttribs); + for (var i = 0; i < this._caps.maxVertexAttribs; ++i) { + this._enabledAttributes[i] = 0; + this._newAttributes[i] = 0; + } + } + var _proto = Device.prototype; + _proto._initExtensions = function _initExtensions(extensions) { + var gl = this._gl; + for (var i = 0; i < extensions.length; ++i) { + var name = extensions[i]; + var vendorPrefixes = [ "", "WEBKIT_", "MOZ_" ]; + for (var j = 0; j < vendorPrefixes.length; j++) try { + var ext = gl.getExtension(vendorPrefixes[j] + name); + if (ext) { + this._extensions[name] = ext; + break; + } + } catch (e) { + console.error(e); + } + } + }; + _proto._initCaps = function _initCaps() { + var gl = this._gl; + var extDrawBuffers = this.ext("WEBGL_draw_buffers"); + this._caps.maxVertexStreams = 4; + this._caps.maxVertexTextures = gl.getParameter(gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS); + this._caps.maxFragUniforms = gl.getParameter(gl.MAX_FRAGMENT_UNIFORM_VECTORS); + this._caps.maxTextureUnits = gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS); + this._caps.maxVertexAttribs = gl.getParameter(gl.MAX_VERTEX_ATTRIBS); + this._caps.maxTextureSize = gl.getParameter(gl.MAX_TEXTURE_SIZE); + this._caps.maxDrawBuffers = extDrawBuffers ? gl.getParameter(extDrawBuffers.MAX_DRAW_BUFFERS_WEBGL) : 1; + this._caps.maxColorAttachments = extDrawBuffers ? gl.getParameter(extDrawBuffers.MAX_COLOR_ATTACHMENTS_WEBGL) : 1; + }; + _proto._initStates = function _initStates() { + var gl = this._gl; + gl.disable(gl.BLEND); + gl.blendFunc(gl.ONE, gl.ZERO); + gl.blendEquation(gl.FUNC_ADD); + gl.blendColor(1, 1, 1, 1); + gl.colorMask(true, true, true, true); + gl.enable(gl.CULL_FACE); + gl.cullFace(gl.BACK); + gl.disable(gl.DEPTH_TEST); + gl.depthFunc(gl.LESS); + gl.depthMask(false); + gl.disable(gl.POLYGON_OFFSET_FILL); + gl.depthRange(0, 1); + gl.disable(gl.STENCIL_TEST); + gl.stencilFunc(gl.ALWAYS, 0, 255); + gl.stencilMask(255); + gl.stencilOp(gl.KEEP, gl.KEEP, gl.KEEP); + gl.clearDepth(1); + gl.clearColor(0, 0, 0, 0); + gl.clearStencil(0); + gl.disable(gl.SCISSOR_TEST); + }; + _proto._restoreTexture = function _restoreTexture(unit) { + var gl = this._gl; + var texture = this._current.textureUnits[unit]; + texture && -1 !== texture._glID ? gl.bindTexture(texture._target, texture._glID) : gl.bindTexture(gl.TEXTURE_2D, null); + }; + _proto._restoreIndexBuffer = function _restoreIndexBuffer() { + var gl = this._gl; + var ib = this._current.indexBuffer; + ib && -1 !== ib._glID ? gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, ib._glID) : gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null); + }; + _proto.ext = function ext(name) { + return this._extensions[name]; + }; + _proto.allowFloatTexture = function allowFloatTexture() { + return null != this.ext("OES_texture_float"); + }; + _proto.setFrameBuffer = function setFrameBuffer(fb) { + if (this._framebuffer === fb) return; + this._framebuffer = fb; + var gl = this._gl; + if (!fb) { + gl.bindFramebuffer(gl.FRAMEBUFFER, null); + return; + } + gl.bindFramebuffer(gl.FRAMEBUFFER, fb._glID); + var numColors = fb._colors.length; + for (var i = 0; i < numColors; ++i) { + var colorBuffer = fb._colors[i]; + _attach(gl, gl.COLOR_ATTACHMENT0 + i, colorBuffer); + } + for (var _i4 = numColors; _i4 < this._caps.maxColorAttachments; ++_i4) gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0 + _i4, gl.TEXTURE_2D, null, 0); + fb._depth && _attach(gl, gl.DEPTH_ATTACHMENT, fb._depth); + fb._stencil && _attach(gl, gl.STENCIL_ATTACHMENT, fb._stencil); + fb._depthStencil && _attach(gl, gl.DEPTH_STENCIL_ATTACHMENT, fb._depthStencil); + }; + _proto.setViewport = function setViewport(x, y, w, h) { + if (this._vx !== x || this._vy !== y || this._vw !== w || this._vh !== h) { + this._gl.viewport(x, y, w, h); + this._vx = x; + this._vy = y; + this._vw = w; + this._vh = h; + } + }; + _proto.setScissor = function setScissor(x, y, w, h) { + if (this._sx !== x || this._sy !== y || this._sw !== w || this._sh !== h) { + this._gl.scissor(x, y, w, h); + this._sx = x; + this._sy = y; + this._sw = w; + this._sh = h; + } + }; + _proto.clear = function clear(opts) { + if (void 0 === opts.color && void 0 === opts.depth && void 0 === opts.stencil) return; + var gl = this._gl; + var flags = 0; + if (void 0 !== opts.color) { + flags |= gl.COLOR_BUFFER_BIT; + gl.clearColor(opts.color[0], opts.color[1], opts.color[2], opts.color[3]); + } + if (void 0 !== opts.depth) { + flags |= gl.DEPTH_BUFFER_BIT; + gl.clearDepth(opts.depth); + gl.enable(gl.DEPTH_TEST); + gl.depthMask(true); + gl.depthFunc(gl.ALWAYS); + } + if (void 0 !== opts.stencil) { + flags |= gl.STENCIL_BUFFER_BIT; + gl.clearStencil(opts.stencil); + } + gl.clear(flags); + if (void 0 !== opts.depth) if (false === this._current.depthTest) gl.disable(gl.DEPTH_TEST); else { + false === this._current.depthWrite && gl.depthMask(false); + this._current.depthFunc !== _enums.enums.DS_FUNC_ALWAYS && gl.depthFunc(this._current.depthFunc); + } + }; + _proto.enableBlend = function enableBlend() { + this._next.blend = true; + }; + _proto.enableDepthTest = function enableDepthTest() { + this._next.depthTest = true; + }; + _proto.enableDepthWrite = function enableDepthWrite() { + this._next.depthWrite = true; + }; + _proto.setStencilTest = function setStencilTest(stencilTest) { + this._next.stencilTest = stencilTest; + }; + _proto.setStencilFunc = function setStencilFunc(func, ref, mask) { + this._next.stencilSep = false; + this._next.stencilFuncFront = this._next.stencilFuncBack = func; + this._next.stencilRefFront = this._next.stencilRefBack = ref; + this._next.stencilMaskFront = this._next.stencilMaskBack = mask; + }; + _proto.setStencilFuncFront = function setStencilFuncFront(func, ref, mask) { + this._next.stencilSep = true; + this._next.stencilFuncFront = func; + this._next.stencilRefFront = ref; + this._next.stencilMaskFront = mask; + }; + _proto.setStencilFuncBack = function setStencilFuncBack(func, ref, mask) { + this._next.stencilSep = true; + this._next.stencilFuncBack = func; + this._next.stencilRefBack = ref; + this._next.stencilMaskBack = mask; + }; + _proto.setStencilOp = function setStencilOp(failOp, zFailOp, zPassOp, writeMask) { + this._next.stencilFailOpFront = this._next.stencilFailOpBack = failOp; + this._next.stencilZFailOpFront = this._next.stencilZFailOpBack = zFailOp; + this._next.stencilZPassOpFront = this._next.stencilZPassOpBack = zPassOp; + this._next.stencilWriteMaskFront = this._next.stencilWriteMaskBack = writeMask; + }; + _proto.setStencilOpFront = function setStencilOpFront(failOp, zFailOp, zPassOp, writeMask) { + this._next.stencilSep = true; + this._next.stencilFailOpFront = failOp; + this._next.stencilZFailOpFront = zFailOp; + this._next.stencilZPassOpFront = zPassOp; + this._next.stencilWriteMaskFront = writeMask; + }; + _proto.setStencilOpBack = function setStencilOpBack(failOp, zFailOp, zPassOp, writeMask) { + this._next.stencilSep = true; + this._next.stencilFailOpBack = failOp; + this._next.stencilZFailOpBack = zFailOp; + this._next.stencilZPassOpBack = zPassOp; + this._next.stencilWriteMaskBack = writeMask; + }; + _proto.setDepthFunc = function setDepthFunc(depthFunc) { + this._next.depthFunc = depthFunc; + }; + _proto.setBlendColor32 = function setBlendColor32(rgba) { + this._next.blendColor = rgba; + }; + _proto.setBlendColor = function setBlendColor(r, g, b, a) { + this._next.blendColor = (255 * r << 24 | 255 * g << 16 | 255 * b << 8 | 255 * a) >>> 0; + }; + _proto.setBlendFunc = function setBlendFunc(src, dst) { + this._next.blendSep = false; + this._next.blendSrc = src; + this._next.blendDst = dst; + }; + _proto.setBlendFuncSep = function setBlendFuncSep(src, dst, srcAlpha, dstAlpha) { + this._next.blendSep = true; + this._next.blendSrc = src; + this._next.blendDst = dst; + this._next.blendSrcAlpha = srcAlpha; + this._next.blendDstAlpha = dstAlpha; + }; + _proto.setBlendEq = function setBlendEq(eq) { + this._next.blendSep = false; + this._next.blendEq = eq; + }; + _proto.setBlendEqSep = function setBlendEqSep(eq, alphaEq) { + this._next.blendSep = true; + this._next.blendEq = eq; + this._next.blendAlphaEq = alphaEq; + }; + _proto.setCullMode = function setCullMode(mode) { + this._next.cullMode = mode; + }; + _proto.setVertexBuffer = function setVertexBuffer(stream, buffer, start) { + void 0 === start && (start = 0); + this._next.vertexBuffers[stream] = buffer; + this._next.vertexBufferOffsets[stream] = start; + this._next.maxStream < stream && (this._next.maxStream = stream); + }; + _proto.setIndexBuffer = function setIndexBuffer(buffer) { + this._next.indexBuffer = buffer; + }; + _proto.setProgram = function setProgram(program) { + this._next.program = program; + }; + _proto.setTexture = function setTexture(name, texture, slot) { + if (slot >= this._caps.maxTextureUnits) { + console.warn("Can not set texture " + name + " at stage " + slot + ", max texture exceed: " + this._caps.maxTextureUnits); + return; + } + this._next.textureUnits[slot] = texture; + this.setUniform(name, slot); + this._next.maxTextureSlot < slot && (this._next.maxTextureSlot = slot); + }; + _proto.setTextureArray = function setTextureArray(name, textures, slots) { + var len = textures.length; + if (len >= this._caps.maxTextureUnits) { + console.warn("Can not set " + len + " textures for " + name + ", max texture exceed: " + this._caps.maxTextureUnits); + return; + } + for (var i = 0; i < len; ++i) { + var slot = slots[i]; + this._next.textureUnits[slot] = textures[i]; + this._next.maxTextureSlot < slot && (this._next.maxTextureSlot = slot); + } + this.setUniform(name, slots); + }; + _proto.setUniform = function setUniform(name, value) { + var uniform = this._uniforms[name]; + var sameType = false; + var isArray = false, isFloat32Array = false, isInt32Array = false; + do { + if (!uniform) break; + isFloat32Array = Array.isArray(value) || value instanceof Float32Array; + isInt32Array = value instanceof Int32Array; + isArray = isFloat32Array || isInt32Array; + if (uniform.isArray !== isArray) break; + if (uniform.isArray && uniform.value.length !== value.length) break; + sameType = true; + } while (false); + if (sameType) { + var oldValue = uniform.value; + var dirty = false; + if (uniform.isArray) { + for (var i = 0, l = oldValue.length; i < l; i++) if (oldValue[i] !== value[i]) { + dirty = true; + oldValue[i] = value[i]; + } + } else if (oldValue !== value) { + dirty = true; + uniform.value = value; + } + dirty && (uniform.dirty = true); + } else { + var newValue = value; + isFloat32Array ? newValue = new Float32Array(value) : isInt32Array && (newValue = new Int32Array(value)); + uniform = { + dirty: true, + value: newValue, + isArray: isArray + }; + } + this._uniforms[name] = uniform; + }; + _proto.setUniformDirectly = function setUniformDirectly(name, value) { + var uniform = this._uniforms[name]; + uniform || (this._uniforms[name] = uniform = {}); + uniform.dirty = true; + uniform.value = value; + }; + _proto.setPrimitiveType = function setPrimitiveType(type) { + this._next.primitiveType = type; + }; + _proto.resetDrawCalls = function resetDrawCalls() { + this._stats.drawcalls = 0; + }; + _proto.getDrawCalls = function getDrawCalls() { + return this._stats.drawcalls; + }; + _proto.draw = function draw(base, count) { + var gl = this._gl; + var cur = this._current; + var next = this._next; + _commitBlendStates(gl, cur, next); + _commitDepthStates(gl, cur, next); + _commitStencilStates(gl, cur, next); + _commitCullMode(gl, cur, next); + _commitVertexBuffers(this, gl, cur, next); + cur.indexBuffer !== next.indexBuffer && gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, next.indexBuffer && -1 !== next.indexBuffer._glID ? next.indexBuffer._glID : null); + var programDirty = false; + if (cur.program !== next.program) { + next.program._linked ? gl.useProgram(next.program._glID) : console.warn("Failed to use program: has not linked yet."); + programDirty = true; + } + _commitTextures(gl, cur, next); + for (var i = 0; i < next.program._uniforms.length; ++i) { + var uniformInfo = next.program._uniforms[i]; + var uniform = this._uniforms[uniformInfo.name]; + if (!uniform) continue; + if (!programDirty && !uniform.dirty) continue; + uniform.dirty = false; + var commitFunc = void 0 === uniformInfo.size ? _type2uniformCommit[uniformInfo.type] : _type2uniformArrayCommit[uniformInfo.type]; + if (!commitFunc) { + console.warn("Can not find commit function for uniform " + uniformInfo.name); + continue; + } + commitFunc(gl, uniformInfo.location, uniform.value); + } + if (count) { + next.indexBuffer ? gl.drawElements(this._next.primitiveType, count, next.indexBuffer._format, base * next.indexBuffer._bytesPerIndex) : gl.drawArrays(this._next.primitiveType, base, count); + this._stats.drawcalls++; + } + cur.set(next); + next.reset(); + }; + _createClass(Device, [ { + key: "caps", + get: function get() { + return this._caps; + } + } ]); + return Device; + })(); + exports["default"] = Device; + module.exports = exports["default"]; + }), { + "./enums": 370, + "./state": 377, + "./texture-2d": 378, + "./texture-cube": 379 + } ], + 370: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports.attrTypeBytes = attrTypeBytes; + exports.enums = void 0; + exports.glFilter = glFilter; + exports.glTextureFmt = glTextureFmt; + var GL_NEAREST = 9728; + var GL_LINEAR = 9729; + var GL_NEAREST_MIPMAP_NEAREST = 9984; + var GL_LINEAR_MIPMAP_NEAREST = 9985; + var GL_NEAREST_MIPMAP_LINEAR = 9986; + var GL_LINEAR_MIPMAP_LINEAR = 9987; + var GL_UNSIGNED_BYTE = 5121; + var GL_UNSIGNED_SHORT = 5123; + var GL_UNSIGNED_INT = 5125; + var GL_FLOAT = 5126; + var GL_UNSIGNED_SHORT_5_6_5 = 33635; + var GL_UNSIGNED_SHORT_4_4_4_4 = 32819; + var GL_UNSIGNED_SHORT_5_5_5_1 = 32820; + var GL_HALF_FLOAT_OES = 36193; + var GL_DEPTH_COMPONENT = 6402; + var GL_ALPHA = 6406; + var GL_RGB = 6407; + var GL_RGBA = 6408; + var GL_LUMINANCE = 6409; + var GL_LUMINANCE_ALPHA = 6410; + var GL_COMPRESSED_RGB_S3TC_DXT1_EXT = 33776; + var GL_COMPRESSED_RGBA_S3TC_DXT1_EXT = 33777; + var GL_COMPRESSED_RGBA_S3TC_DXT3_EXT = 33778; + var GL_COMPRESSED_RGBA_S3TC_DXT5_EXT = 33779; + var GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG = 35840; + var GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG = 35841; + var GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG = 35842; + var GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG = 35843; + var GL_COMPRESSED_RGB_ETC1_WEBGL = 36196; + var GL_COMPRESSED_RGB8_ETC2 = 37492; + var GL_COMPRESSED_RGBA8_ETC2_EAC = 37496; + var _filterGL = [ [ GL_NEAREST, GL_NEAREST_MIPMAP_NEAREST, GL_NEAREST_MIPMAP_LINEAR ], [ GL_LINEAR, GL_LINEAR_MIPMAP_NEAREST, GL_LINEAR_MIPMAP_LINEAR ] ]; + var _textureFmtGL = [ { + format: GL_RGB, + internalFormat: GL_COMPRESSED_RGB_S3TC_DXT1_EXT, + pixelType: null + }, { + format: GL_RGBA, + internalFormat: GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, + pixelType: null + }, { + format: GL_RGBA, + internalFormat: GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, + pixelType: null + }, { + format: GL_RGBA, + internalFormat: GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, + pixelType: null + }, { + format: GL_RGB, + internalFormat: GL_COMPRESSED_RGB_ETC1_WEBGL, + pixelType: null + }, { + format: GL_RGB, + internalFormat: GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG, + pixelType: null + }, { + format: GL_RGBA, + internalFormat: GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG, + pixelType: null + }, { + format: GL_RGB, + internalFormat: GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG, + pixelType: null + }, { + format: GL_RGBA, + internalFormat: GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG, + pixelType: null + }, { + format: GL_ALPHA, + internalFormat: GL_ALPHA, + pixelType: GL_UNSIGNED_BYTE + }, { + format: GL_LUMINANCE, + internalFormat: GL_LUMINANCE, + pixelType: GL_UNSIGNED_BYTE + }, { + format: GL_LUMINANCE_ALPHA, + internalFormat: GL_LUMINANCE_ALPHA, + pixelType: GL_UNSIGNED_BYTE + }, { + format: GL_RGB, + internalFormat: GL_RGB, + pixelType: GL_UNSIGNED_SHORT_5_6_5 + }, { + format: GL_RGBA, + internalFormat: GL_RGBA, + pixelType: GL_UNSIGNED_SHORT_5_5_5_1 + }, { + format: GL_RGBA, + internalFormat: GL_RGBA, + pixelType: GL_UNSIGNED_SHORT_4_4_4_4 + }, { + format: GL_RGB, + internalFormat: GL_RGB, + pixelType: GL_UNSIGNED_BYTE + }, { + format: GL_RGBA, + internalFormat: GL_RGBA, + pixelType: GL_UNSIGNED_BYTE + }, { + format: GL_RGB, + internalFormat: GL_RGB, + pixelType: GL_HALF_FLOAT_OES + }, { + format: GL_RGBA, + internalFormat: GL_RGBA, + pixelType: GL_HALF_FLOAT_OES + }, { + format: GL_RGB, + internalFormat: GL_RGB, + pixelType: GL_FLOAT + }, { + format: GL_RGBA, + internalFormat: GL_RGBA, + pixelType: GL_FLOAT + }, { + format: null, + internalFormat: null, + pixelType: null + }, { + format: null, + internalFormat: null, + pixelType: null + }, { + format: null, + internalFormat: null, + pixelType: null + }, { + format: null, + internalFormat: null, + pixelType: null + }, { + format: GL_DEPTH_COMPONENT, + internalFormat: GL_DEPTH_COMPONENT, + pixelType: GL_UNSIGNED_SHORT + }, { + format: GL_DEPTH_COMPONENT, + internalFormat: GL_DEPTH_COMPONENT, + pixelType: GL_UNSIGNED_INT + }, { + format: GL_DEPTH_COMPONENT, + internalFormat: GL_DEPTH_COMPONENT, + pixelType: GL_UNSIGNED_INT + }, { + format: GL_RGB, + internalFormat: GL_COMPRESSED_RGB8_ETC2, + pixelType: null + }, { + format: GL_RGBA, + internalFormat: GL_COMPRESSED_RGBA8_ETC2_EAC, + pixelType: null + } ]; + var enums = { + USAGE_STATIC: 35044, + USAGE_DYNAMIC: 35048, + USAGE_STREAM: 35040, + INDEX_FMT_UINT8: 5121, + INDEX_FMT_UINT16: 5123, + INDEX_FMT_UINT32: 5125, + ATTR_POSITION: "a_position", + ATTR_NORMAL: "a_normal", + ATTR_TANGENT: "a_tangent", + ATTR_BITANGENT: "a_bitangent", + ATTR_WEIGHTS: "a_weights", + ATTR_JOINTS: "a_joints", + ATTR_COLOR: "a_color", + ATTR_COLOR0: "a_color0", + ATTR_COLOR1: "a_color1", + ATTR_UV: "a_uv", + ATTR_UV0: "a_uv0", + ATTR_UV1: "a_uv1", + ATTR_UV2: "a_uv2", + ATTR_UV3: "a_uv3", + ATTR_UV4: "a_uv4", + ATTR_UV5: "a_uv5", + ATTR_UV6: "a_uv6", + ATTR_UV7: "a_uv7", + ATTR_TEX_COORD: "a_texCoord", + ATTR_TEX_COORD1: "a_texCoord1", + ATTR_TEX_COORD2: "a_texCoord2", + ATTR_TEX_COORD3: "a_texCoord3", + ATTR_TEX_COORD4: "a_texCoord4", + ATTR_TEX_COORD5: "a_texCoord5", + ATTR_TEX_COORD6: "a_texCoord6", + ATTR_TEX_COORD7: "a_texCoord7", + ATTR_TEX_COORD8: "a_texCoord8", + ATTR_TYPE_INT8: 5120, + ATTR_TYPE_UINT8: 5121, + ATTR_TYPE_INT16: 5122, + ATTR_TYPE_UINT16: 5123, + ATTR_TYPE_INT32: 5124, + ATTR_TYPE_UINT32: 5125, + ATTR_TYPE_FLOAT32: 5126, + FILTER_NEAREST: 0, + FILTER_LINEAR: 1, + WRAP_REPEAT: 10497, + WRAP_CLAMP: 33071, + WRAP_MIRROR: 33648, + TEXTURE_FMT_RGB_DXT1: 0, + TEXTURE_FMT_RGBA_DXT1: 1, + TEXTURE_FMT_RGBA_DXT3: 2, + TEXTURE_FMT_RGBA_DXT5: 3, + TEXTURE_FMT_RGB_ETC1: 4, + TEXTURE_FMT_RGB_PVRTC_2BPPV1: 5, + TEXTURE_FMT_RGBA_PVRTC_2BPPV1: 6, + TEXTURE_FMT_RGB_PVRTC_4BPPV1: 7, + TEXTURE_FMT_RGBA_PVRTC_4BPPV1: 8, + TEXTURE_FMT_A8: 9, + TEXTURE_FMT_L8: 10, + TEXTURE_FMT_L8_A8: 11, + TEXTURE_FMT_R5_G6_B5: 12, + TEXTURE_FMT_R5_G5_B5_A1: 13, + TEXTURE_FMT_R4_G4_B4_A4: 14, + TEXTURE_FMT_RGB8: 15, + TEXTURE_FMT_RGBA8: 16, + TEXTURE_FMT_RGB16F: 17, + TEXTURE_FMT_RGBA16F: 18, + TEXTURE_FMT_RGB32F: 19, + TEXTURE_FMT_RGBA32F: 20, + TEXTURE_FMT_R32F: 21, + TEXTURE_FMT_111110F: 22, + TEXTURE_FMT_SRGB: 23, + TEXTURE_FMT_SRGBA: 24, + TEXTURE_FMT_D16: 25, + TEXTURE_FMT_D32: 26, + TEXTURE_FMT_D24S8: 27, + TEXTURE_FMT_RGB_ETC2: 28, + TEXTURE_FMT_RGBA_ETC2: 29, + DS_FUNC_NEVER: 512, + DS_FUNC_LESS: 513, + DS_FUNC_EQUAL: 514, + DS_FUNC_LEQUAL: 515, + DS_FUNC_GREATER: 516, + DS_FUNC_NOTEQUAL: 517, + DS_FUNC_GEQUAL: 518, + DS_FUNC_ALWAYS: 519, + RB_FMT_RGBA4: 32854, + RB_FMT_RGB5_A1: 32855, + RB_FMT_RGB565: 36194, + RB_FMT_D16: 33189, + RB_FMT_S8: 36168, + RB_FMT_D24S8: 34041, + BLEND_FUNC_ADD: 32774, + BLEND_FUNC_SUBTRACT: 32778, + BLEND_FUNC_REVERSE_SUBTRACT: 32779, + BLEND_ZERO: 0, + BLEND_ONE: 1, + BLEND_SRC_COLOR: 768, + BLEND_ONE_MINUS_SRC_COLOR: 769, + BLEND_DST_COLOR: 774, + BLEND_ONE_MINUS_DST_COLOR: 775, + BLEND_SRC_ALPHA: 770, + BLEND_ONE_MINUS_SRC_ALPHA: 771, + BLEND_DST_ALPHA: 772, + BLEND_ONE_MINUS_DST_ALPHA: 773, + BLEND_CONSTANT_COLOR: 32769, + BLEND_ONE_MINUS_CONSTANT_COLOR: 32770, + BLEND_CONSTANT_ALPHA: 32771, + BLEND_ONE_MINUS_CONSTANT_ALPHA: 32772, + BLEND_SRC_ALPHA_SATURATE: 776, + STENCIL_DISABLE: 0, + STENCIL_ENABLE: 1, + STENCIL_INHERIT: 2, + STENCIL_OP_KEEP: 7680, + STENCIL_OP_ZERO: 0, + STENCIL_OP_REPLACE: 7681, + STENCIL_OP_INCR: 7682, + STENCIL_OP_INCR_WRAP: 34055, + STENCIL_OP_DECR: 7683, + STENCIL_OP_DECR_WRAP: 34056, + STENCIL_OP_INVERT: 5386, + CULL_NONE: 0, + CULL_FRONT: 1028, + CULL_BACK: 1029, + CULL_FRONT_AND_BACK: 1032, + PT_POINTS: 0, + PT_LINES: 1, + PT_LINE_LOOP: 2, + PT_LINE_STRIP: 3, + PT_TRIANGLES: 4, + PT_TRIANGLE_STRIP: 5, + PT_TRIANGLE_FAN: 6 + }; + exports.enums = enums; + function attrTypeBytes(attrType) { + if (attrType === enums.ATTR_TYPE_INT8) return 1; + if (attrType === enums.ATTR_TYPE_UINT8) return 1; + if (attrType === enums.ATTR_TYPE_INT16) return 2; + if (attrType === enums.ATTR_TYPE_UINT16) return 2; + if (attrType === enums.ATTR_TYPE_INT32) return 4; + if (attrType === enums.ATTR_TYPE_UINT32) return 4; + if (attrType === enums.ATTR_TYPE_FLOAT32) return 4; + console.warn("Unknown ATTR_TYPE: " + attrType); + return 0; + } + function glFilter(gl, filter, mipFilter) { + void 0 === mipFilter && (mipFilter = -1); + var result = _filterGL[filter][mipFilter + 1]; + if (void 0 === result) { + console.warn("Unknown FILTER: " + filter); + return -1 === mipFilter ? gl.LINEAR : gl.LINEAR_MIPMAP_LINEAR; + } + return result; + } + function glTextureFmt(fmt) { + var result = _textureFmtGL[fmt]; + if (void 0 === result) { + console.warn("Unknown TEXTURE_FMT: " + fmt); + return _textureFmtGL[enums.TEXTURE_FMT_RGBA8]; + } + return result; + } + }), {} ], + 371: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var FrameBuffer = (function() { + function FrameBuffer(device, width, height, options) { + this._device = device; + this._width = width; + this._height = height; + this._colors = options.colors || []; + this._depth = options.depth || null; + this._stencil = options.stencil || null; + this._depthStencil = options.depthStencil || null; + this._glID = device._gl.createFramebuffer(); + } + var _proto = FrameBuffer.prototype; + _proto.destroy = function destroy() { + if (null === this._glID) { + console.error("The frame-buffer already destroyed"); + return; + } + var gl = this._device._gl; + gl.deleteFramebuffer(this._glID); + this._glID = null; + }; + _proto.getHandle = function getHandle() { + return this._glID; + }; + return FrameBuffer; + })(); + exports["default"] = FrameBuffer; + module.exports = exports["default"]; + }), {} ], + 372: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _enums = require("./enums"); + var _BYTES_PER_INDEX; + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + "value" in descriptor && (descriptor.writable = true); + Object.defineProperty(target, descriptor.key, descriptor); + } + } + function _createClass(Constructor, protoProps, staticProps) { + protoProps && _defineProperties(Constructor.prototype, protoProps); + staticProps && _defineProperties(Constructor, staticProps); + return Constructor; + } + var BYTES_PER_INDEX = (_BYTES_PER_INDEX = {}, _BYTES_PER_INDEX[_enums.enums.INDEX_FMT_UINT8] = 1, + _BYTES_PER_INDEX[_enums.enums.INDEX_FMT_UINT16] = 2, _BYTES_PER_INDEX[_enums.enums.INDEX_FMT_UINT32] = 4, + _BYTES_PER_INDEX); + var IndexBuffer = (function() { + function IndexBuffer(device, format, usage, data) { + this._device = device; + this._format = format; + this._usage = usage; + this._bytesPerIndex = BYTES_PER_INDEX[format]; + this._bytes = data.byteLength; + this._numIndices = this._bytes / this._bytesPerIndex; + this._needExpandDataStore = true; + this._glID = device._gl.createBuffer(); + this.update(0, data); + device._stats.ib += this._bytes; + } + var _proto = IndexBuffer.prototype; + _proto.destroy = function destroy() { + if (-1 === this._glID) { + console.error("The buffer already destroyed"); + return; + } + var gl = this._device._gl; + gl.deleteBuffer(this._glID); + this._device._stats.ib -= this.bytes; + this._glID = -1; + }; + _proto.update = function update(byteOffset, data) { + if (-1 === this._glID) { + console.error("The buffer is destroyed"); + return; + } + if (0 === data.byteLength) return; + if (byteOffset + data.byteLength > this._bytes) { + if (byteOffset) { + console.error("Failed to update data, bytes exceed."); + return; + } + this._needExpandDataStore = true; + this._bytes = byteOffset + data.byteLength; + this._numIndices = this._bytes / this._bytesPerIndex; + } + var gl = this._device._gl; + var glUsage = this._usage; + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._glID); + if (this._needExpandDataStore) { + gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, data, glUsage); + this._needExpandDataStore = false; + } else gl.bufferSubData(gl.ELEMENT_ARRAY_BUFFER, byteOffset, data); + this._device._restoreIndexBuffer(); + }; + _proto.setUsage = function setUsage(usage) { + this._usage = usage; + }; + _createClass(IndexBuffer, [ { + key: "count", + get: function get() { + return this._numIndices; + } + } ]); + return IndexBuffer; + })(); + IndexBuffer.BYTES_PER_INDEX = BYTES_PER_INDEX; + var _default = IndexBuffer; + exports["default"] = _default; + module.exports = exports["default"]; + }), { + "./enums": 370 + } ], + 373: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _enums = require("./enums"); + var gfx = null; + false; + var VertexFormat = require("./vertex-format"); + var IndexBuffer = require("./index-buffer"); + var VertexBuffer = require("./vertex-buffer"); + var Program = require("./program"); + var Texture = require("./texture"); + var Texture2D = require("./texture-2d"); + var TextureCube = require("./texture-cube"); + var RenderBuffer = require("./render-buffer"); + var FrameBuffer = require("./frame-buffer"); + var Device = require("./device"); + gfx = { + VertexFormat: VertexFormat, + IndexBuffer: IndexBuffer, + VertexBuffer: VertexBuffer, + Program: Program, + Texture: Texture, + Texture2D: Texture2D, + TextureCube: TextureCube, + RenderBuffer: RenderBuffer, + FrameBuffer: FrameBuffer, + Device: Device, + attrTypeBytes: _enums.attrTypeBytes, + glFilter: _enums.glFilter, + glTextureFmt: _enums.glTextureFmt + }; + Object.assign(gfx, _enums.enums); + var _default = gfx; + exports["default"] = _default; + cc.gfx = gfx; + module.exports = exports["default"]; + }), { + "./device": 369, + "./enums": 370, + "./frame-buffer": 371, + "./index-buffer": 372, + "./program": 375, + "./render-buffer": 376, + "./texture": 380, + "./texture-2d": 378, + "./texture-cube": 379, + "./vertex-buffer": 381, + "./vertex-format": 382 + } ], + 374: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports.isPow2 = isPow2; + function isPow2(v) { + return !(v & v - 1) && !!v; + } + }), {} ], + 375: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + "value" in descriptor && (descriptor.writable = true); + Object.defineProperty(target, descriptor.key, descriptor); + } + } + function _createClass(Constructor, protoProps, staticProps) { + protoProps && _defineProperties(Constructor.prototype, protoProps); + staticProps && _defineProperties(Constructor, staticProps); + return Constructor; + } + var _genID = 0; + function _parseError(out, type, errorLog) { + if (!errorLog) return; + errorLog.split("\n").forEach((function(msg) { + if (msg.length < 5) return; + var parts = /^ERROR:\s+(\d+):(\d+):\s*(.*)$/.exec(msg); + parts ? out.push({ + type: type, + fileID: 0 | parts[1], + line: 0 | parts[2], + message: parts[3].trim() + }) : msg.length > 0 && out.push({ + type: type, + fileID: -1, + line: 0, + message: msg + }); + })); + } + var Program = (function() { + function Program(device, options) { + this._device = device; + this._attributes = []; + this._uniforms = []; + this._samplers = []; + this._errors = []; + this._linked = false; + this._vertSource = options.vert; + this._fragSource = options.frag; + this._glID = null; + this._id = _genID++; + } + var _proto = Program.prototype; + _proto.link = function link() { + if (this._linked) return; + var gl = this._device._gl; + var vertShader = _createShader(gl, gl.VERTEX_SHADER, this._vertSource); + var fragShader = _createShader(gl, gl.FRAGMENT_SHADER, this._fragSource); + var program = gl.createProgram(); + gl.attachShader(program, vertShader); + gl.attachShader(program, fragShader); + gl.linkProgram(program); + var failed = false; + var errors = this._errors; + if (!gl.getShaderParameter(vertShader, gl.COMPILE_STATUS)) { + _parseError(errors, "vs", gl.getShaderInfoLog(vertShader)); + failed = true; + } + if (!gl.getShaderParameter(fragShader, gl.COMPILE_STATUS)) { + _parseError(errors, "fs", gl.getShaderInfoLog(fragShader)); + failed = true; + } + gl.deleteShader(vertShader); + gl.deleteShader(fragShader); + if (failed) return errors; + if (!gl.getProgramParameter(program, gl.LINK_STATUS)) { + errors.push({ + info: "Failed to link shader program: " + gl.getProgramInfoLog(program) + }); + return errors; + } + this._glID = program; + var numAttributes = gl.getProgramParameter(program, gl.ACTIVE_ATTRIBUTES); + for (var i = 0; i < numAttributes; ++i) { + var info = gl.getActiveAttrib(program, i); + var location = gl.getAttribLocation(program, info.name); + this._attributes.push({ + name: info.name, + location: location, + type: info.type + }); + } + var numUniforms = gl.getProgramParameter(program, gl.ACTIVE_UNIFORMS); + for (var _i = 0; _i < numUniforms; ++_i) { + var _info = gl.getActiveUniform(program, _i); + var name = _info.name; + var _location = gl.getUniformLocation(program, name); + var isArray = "[0]" === name.substr(name.length - 3); + isArray && (name = name.substr(0, name.length - 3)); + var uniform = { + name: name, + location: _location, + type: _info.type, + size: isArray ? _info.size : void 0 + }; + this._uniforms.push(uniform); + } + this._linked = true; + }; + _proto.destroy = function destroy() { + var gl = this._device._gl; + gl.deleteProgram(this._glID); + this._linked = false; + this._glID = null; + this._attributes = []; + this._uniforms = []; + this._samplers = []; + }; + _createClass(Program, [ { + key: "id", + get: function get() { + return this._id; + } + } ]); + return Program; + })(); + exports["default"] = Program; + function _createShader(gl, type, src) { + var shader = gl.createShader(type); + gl.shaderSource(shader, src); + gl.compileShader(shader); + return shader; + } + module.exports = exports["default"]; + }), {} ], + 376: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var RenderBuffer = (function() { + function RenderBuffer(device, format, width, height) { + this._device = device; + this._format = format; + this._glID = device._gl.createRenderbuffer(); + this.update(width, height); + } + var _proto = RenderBuffer.prototype; + _proto.update = function update(width, height) { + this._width = width; + this._height = height; + var gl = this._device._gl; + gl.bindRenderbuffer(gl.RENDERBUFFER, this._glID); + gl.renderbufferStorage(gl.RENDERBUFFER, this._format, width, height); + gl.bindRenderbuffer(gl.RENDERBUFFER, null); + }; + _proto.destroy = function destroy() { + if (null === this._glID) { + console.error("The render-buffer already destroyed"); + return; + } + var gl = this._device._gl; + gl.bindRenderbuffer(gl.RENDERBUFFER, null); + gl.deleteRenderbuffer(this._glID); + this._glID = null; + }; + return RenderBuffer; + })(); + exports["default"] = RenderBuffer; + module.exports = exports["default"]; + }), {} ], + 377: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _enums = require("./enums"); + var _default = { + blend: false, + blendSep: false, + blendColor: 4294967295, + blendEq: _enums.enums.BLEND_FUNC_ADD, + blendAlphaEq: _enums.enums.BLEND_FUNC_ADD, + blendSrc: _enums.enums.BLEND_ONE, + blendDst: _enums.enums.BLEND_ZERO, + blendSrcAlpha: _enums.enums.BLEND_ONE, + blendDstAlpha: _enums.enums.BLEND_ZERO, + depthTest: false, + depthWrite: false, + depthFunc: _enums.enums.DS_FUNC_LESS, + stencilTest: false, + stencilSep: false, + stencilFuncFront: _enums.enums.DS_FUNC_ALWAYS, + stencilRefFront: 0, + stencilMaskFront: 255, + stencilFailOpFront: _enums.enums.STENCIL_OP_KEEP, + stencilZFailOpFront: _enums.enums.STENCIL_OP_KEEP, + stencilZPassOpFront: _enums.enums.STENCIL_OP_KEEP, + stencilWriteMaskFront: 255, + stencilFuncBack: _enums.enums.DS_FUNC_ALWAYS, + stencilRefBack: 0, + stencilMaskBack: 255, + stencilFailOpBack: _enums.enums.STENCIL_OP_KEEP, + stencilZFailOpBack: _enums.enums.STENCIL_OP_KEEP, + stencilZPassOpBack: _enums.enums.STENCIL_OP_KEEP, + stencilWriteMaskBack: 255, + cullMode: _enums.enums.CULL_BACK, + primitiveType: _enums.enums.PT_TRIANGLES, + maxStream: -1, + vertexBuffers: [], + vertexBufferOffsets: [], + indexBuffer: null, + maxTextureSlot: -1, + textureUnits: [], + program: null + }; + var State = (function() { + function State(device) { + this.vertexBuffers = new Array(device._caps.maxVertexStreams); + this.vertexBufferOffsets = new Array(device._caps.maxVertexStreams); + this.textureUnits = new Array(device._caps.maxTextureUnits); + this.set(_default); + } + State.initDefault = function initDefault(device) { + _default.vertexBuffers = new Array(device._caps.maxVertexStreams); + _default.vertexBufferOffsets = new Array(device._caps.maxVertexStreams); + _default.textureUnits = new Array(device._caps.maxTextureUnits); + }; + var _proto = State.prototype; + _proto.reset = function reset() { + this.set(_default); + }; + _proto.set = function set(cpy) { + this.blend = cpy.blend; + this.blendSep = cpy.blendSep; + this.blendColor = cpy.blendColor; + this.blendEq = cpy.blendEq; + this.blendAlphaEq = cpy.blendAlphaEq; + this.blendSrc = cpy.blendSrc; + this.blendDst = cpy.blendDst; + this.blendSrcAlpha = cpy.blendSrcAlpha; + this.blendDstAlpha = cpy.blendDstAlpha; + this.depthTest = cpy.depthTest; + this.depthWrite = cpy.depthWrite; + this.depthFunc = cpy.depthFunc; + this.stencilTest = cpy.stencilTest; + this.stencilSep = cpy.stencilSep; + this.stencilFuncFront = cpy.stencilFuncFront; + this.stencilRefFront = cpy.stencilRefFront; + this.stencilMaskFront = cpy.stencilMaskFront; + this.stencilFailOpFront = cpy.stencilFailOpFront; + this.stencilZFailOpFront = cpy.stencilZFailOpFront; + this.stencilZPassOpFront = cpy.stencilZPassOpFront; + this.stencilWriteMaskFront = cpy.stencilWriteMaskFront; + this.stencilFuncBack = cpy.stencilFuncBack; + this.stencilRefBack = cpy.stencilRefBack; + this.stencilMaskBack = cpy.stencilMaskBack; + this.stencilFailOpBack = cpy.stencilFailOpBack; + this.stencilZFailOpBack = cpy.stencilZFailOpBack; + this.stencilZPassOpBack = cpy.stencilZPassOpBack; + this.stencilWriteMaskBack = cpy.stencilWriteMaskBack; + this.cullMode = cpy.cullMode; + this.primitiveType = cpy.primitiveType; + this.maxStream = cpy.maxStream; + for (var i = 0; i < cpy.vertexBuffers.length; ++i) this.vertexBuffers[i] = cpy.vertexBuffers[i]; + for (var _i = 0; _i < cpy.vertexBufferOffsets.length; ++_i) this.vertexBufferOffsets[_i] = cpy.vertexBufferOffsets[_i]; + this.indexBuffer = cpy.indexBuffer; + this.maxTextureSlot = cpy.maxTextureSlot; + for (var _i2 = 0; _i2 < cpy.textureUnits.length; ++_i2) this.textureUnits[_i2] = cpy.textureUnits[_i2]; + this.program = cpy.program; + }; + return State; + })(); + exports["default"] = State; + module.exports = exports["default"]; + }), { + "./enums": 370 + } ], + 378: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _texture = _interopRequireDefault(require("./texture")); + var _enums = require("./enums"); + var _misc = require("./misc"); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + _setPrototypeOf(subClass, superClass); + } + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + return _setPrototypeOf(o, p); + } + var Texture2D = (function(_Texture) { + _inheritsLoose(Texture2D, _Texture); + function Texture2D(device, options) { + var _this; + _this = _Texture.call(this, device) || this; + var gl = _this._device._gl; + _this._target = gl.TEXTURE_2D; + _this._glID = gl.createTexture(); + options.images = options.images || [ null ]; + _this.update(options); + return _this; + } + var _proto = Texture2D.prototype; + _proto.update = function update(options) { + var gl = this._device._gl; + var genMipmaps = this._genMipmap; + if (options) { + void 0 !== options.width && (this._width = options.width); + void 0 !== options.height && (this._height = options.height); + void 0 !== options.anisotropy && (this._anisotropy = options.anisotropy); + void 0 !== options.minFilter && (this._minFilter = options.minFilter); + void 0 !== options.magFilter && (this._magFilter = options.magFilter); + void 0 !== options.mipFilter && (this._mipFilter = options.mipFilter); + void 0 !== options.wrapS && (this._wrapS = options.wrapS); + void 0 !== options.wrapT && (this._wrapT = options.wrapT); + if (void 0 !== options.format) { + this._format = options.format; + this._compressed = this._format >= _enums.enums.TEXTURE_FMT_RGB_DXT1 && this._format <= _enums.enums.TEXTURE_FMT_RGBA_PVRTC_4BPPV1 || this._format >= _enums.enums.TEXTURE_FMT_RGB_ETC2 && this._format <= _enums.enums.TEXTURE_FMT_RGBA_ETC2; + } + if (void 0 !== options.genMipmaps) { + this._genMipmap = options.genMipmaps; + genMipmaps = options.genMipmaps; + } + var maxSize = this._device.caps.maxTextureSize || Number.MAX_VALUE; + var textureMaxSize = Math.max(options.width || 0, options.height || 0); + maxSize < textureMaxSize && console.warn("The current texture size " + textureMaxSize + " exceeds the maximum size [" + maxSize + "] supported on the device."); + if (void 0 !== options.images && options.images.length > 1) { + genMipmaps = false; + var maxLength = options.width > options.height ? options.width : options.height; + maxLength >> options.images.length - 1 !== 1 && console.error("texture-2d mipmap is invalid, should have a 1x1 mipmap."); + } + } + var pot = (0, _misc.isPow2)(this._width) && (0, _misc.isPow2)(this._height); + pot || (genMipmaps = false); + gl.activeTexture(gl.TEXTURE0); + gl.bindTexture(gl.TEXTURE_2D, this._glID); + if (void 0 !== options.images && options.images.length > 0) { + this._setMipmap(options.images, options.flipY, options.premultiplyAlpha); + options.images.length > 1 && (this._genMipmap = true); + } + if (genMipmaps) { + gl.hint(gl.GENERATE_MIPMAP_HINT, gl.NICEST); + gl.generateMipmap(gl.TEXTURE_2D); + this._genMipmap = true; + } + this._setTexInfo(); + this._device._restoreTexture(0); + }; + _proto.updateSubImage = function updateSubImage(options) { + var gl = this._device._gl; + var glFmt = (0, _enums.glTextureFmt)(this._format); + gl.activeTexture(gl.TEXTURE0); + gl.bindTexture(gl.TEXTURE_2D, this._glID); + this._setSubImage(glFmt, options); + this._device._restoreTexture(0); + }; + _proto.updateImage = function updateImage(options) { + var gl = this._device._gl; + var glFmt = (0, _enums.glTextureFmt)(this._format); + gl.activeTexture(gl.TEXTURE0); + gl.bindTexture(gl.TEXTURE_2D, this._glID); + this._setImage(glFmt, options); + this._device._restoreTexture(0); + }; + _proto._setSubImage = function _setSubImage(glFmt, options) { + var gl = this._device._gl; + var flipY = options.flipY; + var premultiplyAlpha = options.premultiplyAlpha; + var img = options.image; + if (!img || ArrayBuffer.isView(img) || img instanceof ArrayBuffer) { + void 0 === flipY ? gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false) : gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, flipY); + void 0 === premultiplyAlpha ? gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false) : gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, premultiplyAlpha); + this._compressed ? gl.compressedTexSubImage2D(gl.TEXTURE_2D, options.level, options.x, options.y, options.width, options.height, glFmt.format, img) : gl.texSubImage2D(gl.TEXTURE_2D, options.level, options.x, options.y, options.width, options.height, glFmt.format, glFmt.pixelType, img); + } else { + void 0 === flipY ? gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true) : gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, flipY); + void 0 === premultiplyAlpha ? gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false) : gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, premultiplyAlpha); + gl.texSubImage2D(gl.TEXTURE_2D, options.level, options.x, options.y, glFmt.format, glFmt.pixelType, img); + } + }; + _proto._setImage = function _setImage(glFmt, options) { + var gl = this._device._gl; + var flipY = options.flipY; + var premultiplyAlpha = options.premultiplyAlpha; + var img = options.image; + if (!img || ArrayBuffer.isView(img) || img instanceof ArrayBuffer) { + void 0 === flipY ? gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false) : gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, flipY); + void 0 === premultiplyAlpha ? gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false) : gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, premultiplyAlpha); + this._compressed ? gl.compressedTexImage2D(gl.TEXTURE_2D, options.level, glFmt.internalFormat, options.width, options.height, 0, img) : gl.texImage2D(gl.TEXTURE_2D, options.level, glFmt.internalFormat, options.width, options.height, 0, glFmt.format, glFmt.pixelType, img); + } else { + void 0 === flipY ? gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true) : gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, flipY); + void 0 === premultiplyAlpha ? gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false) : gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, premultiplyAlpha); + gl.texImage2D(gl.TEXTURE_2D, options.level, glFmt.internalFormat, glFmt.format, glFmt.pixelType, img); + } + }; + _proto._setMipmap = function _setMipmap(images, flipY, premultiplyAlpha) { + var glFmt = (0, _enums.glTextureFmt)(this._format); + var options = { + width: this._width, + height: this._height, + flipY: flipY, + premultiplyAlpha: premultiplyAlpha, + level: 0, + image: null + }; + for (var i = 0; i < images.length; ++i) { + options.level = i; + options.width = this._width >> i; + options.height = this._height >> i; + options.image = images[i]; + this._setImage(glFmt, options); + } + }; + _proto._setTexInfo = function _setTexInfo() { + var gl = this._device._gl; + var pot = (0, _misc.isPow2)(this._width) && (0, _misc.isPow2)(this._height); + if (!pot && (this._wrapS !== _enums.enums.WRAP_CLAMP || this._wrapT !== _enums.enums.WRAP_CLAMP)) { + console.warn("WebGL1 doesn't support all wrap modes with NPOT textures"); + this._wrapS = _enums.enums.WRAP_CLAMP; + this._wrapT = _enums.enums.WRAP_CLAMP; + } + var mipFilter = this._genMipmap ? this._mipFilter : -1; + if (!pot && -1 !== mipFilter) { + console.warn("NPOT textures do not support mipmap filter"); + mipFilter = -1; + } + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, (0, _enums.glFilter)(gl, this._minFilter, mipFilter)); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, (0, _enums.glFilter)(gl, this._magFilter, -1)); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, this._wrapS); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, this._wrapT); + var ext = this._device.ext("EXT_texture_filter_anisotropic"); + ext && gl.texParameteri(gl.TEXTURE_2D, ext.TEXTURE_MAX_ANISOTROPY_EXT, this._anisotropy); + }; + return Texture2D; + })(_texture["default"]); + exports["default"] = Texture2D; + module.exports = exports["default"]; + }), { + "./enums": 370, + "./misc": 374, + "./texture": 380 + } ], + 379: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _texture = _interopRequireDefault(require("./texture")); + var _enums = require("./enums"); + var _misc = require("./misc"); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + _setPrototypeOf(subClass, superClass); + } + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + return _setPrototypeOf(o, p); + } + var TextureCube = (function(_Texture) { + _inheritsLoose(TextureCube, _Texture); + function TextureCube(device, options) { + var _this; + _this = _Texture.call(this, device) || this; + var gl = _this._device._gl; + _this._target = gl.TEXTURE_CUBE_MAP; + _this._glID = gl.createTexture(); + _this.update(options); + return _this; + } + var _proto = TextureCube.prototype; + _proto.update = function update(options) { + var gl = this._device._gl; + var genMipmaps = this._genMipmaps; + if (options) { + void 0 !== options.width && (this._width = options.width); + void 0 !== options.height && (this._height = options.height); + void 0 !== options.anisotropy && (this._anisotropy = options.anisotropy); + void 0 !== options.minFilter && (this._minFilter = options.minFilter); + void 0 !== options.magFilter && (this._magFilter = options.magFilter); + void 0 !== options.mipFilter && (this._mipFilter = options.mipFilter); + void 0 !== options.wrapS && (this._wrapS = options.wrapS); + void 0 !== options.wrapT && (this._wrapT = options.wrapT); + if (void 0 !== options.format) { + this._format = options.format; + this._compressed = this._format >= _enums.enums.TEXTURE_FMT_RGB_DXT1 && this._format <= _enums.enums.TEXTURE_FMT_RGBA_PVRTC_4BPPV1 || this._format >= _enums.enums.TEXTURE_FMT_RGB_ETC2 && this._format <= _enums.enums.TEXTURE_FMT_RGBA_ETC2; + } + if (void 0 !== options.genMipmaps) { + this._genMipmaps = options.genMipmaps; + genMipmaps = options.genMipmaps; + } + if (void 0 !== options.images && options.images.length > 1) { + genMipmaps = false; + options.width !== options.height && console.warn("texture-cube width and height should be identical."); + options.width >> options.images.length - 1 !== 1 && console.error("texture-cube mipmap is invalid. please set mipmap as 1x1, 2x2, 4x4 ... nxn"); + } + } + var pot = (0, _misc.isPow2)(this._width) && (0, _misc.isPow2)(this._height); + pot || (genMipmaps = false); + gl.activeTexture(gl.TEXTURE0); + gl.bindTexture(gl.TEXTURE_CUBE_MAP, this._glID); + if (void 0 !== options.images && options.images.length > 0) { + this._setMipmap(options.images, options.flipY, options.premultiplyAlpha); + options.images.length > 1 && (this._genMipmaps = true); + } + if (genMipmaps) { + gl.hint(gl.GENERATE_MIPMAP_HINT, gl.NICEST); + gl.generateMipmap(gl.TEXTURE_CUBE_MAP); + this._genMipmaps = true; + } + this._setTexInfo(); + this._device._restoreTexture(0); + }; + _proto.updateSubImage = function updateSubImage(options) { + var gl = this._device._gl; + var glFmt = (0, _enums.glTextureFmt)(this._format); + gl.activeTexture(gl.TEXTURE0); + gl.bindTexture(gl.TEXTURE_CUBE_MAP, this._glID); + this._setSubImage(glFmt, options); + this._device._restoreTexture(0); + }; + _proto.updateImage = function updateImage(options) { + var gl = this._device._gl; + var glFmt = (0, _enums.glTextureFmt)(this._format); + gl.activeTexture(gl.TEXTURE0); + gl.bindTexture(gl.TEXTURE_CUBE_MAP, this._glID); + this._setImage(glFmt, options); + this._device._restoreTexture(0); + }; + _proto._setSubImage = function _setSubImage(glFmt, options) { + var gl = this._device._gl; + var flipY = options.flipY; + var premultiplyAlpha = options.premultiplyAlpha; + var faceIndex = options.faceIndex; + var img = options.image; + void 0 === flipY ? gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false) : gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, flipY); + void 0 === premultiplyAlpha ? gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false) : gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, premultiplyAlpha); + !img || ArrayBuffer.isView(img) || img instanceof ArrayBuffer ? this._compressed ? gl.compressedTexSubImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, options.level, options.x, options.y, options.width, options.height, glFmt.format, img) : gl.texSubImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, options.level, options.x, options.y, options.width, options.height, glFmt.format, glFmt.pixelType, img) : gl.texSubImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, options.level, options.x, options.y, glFmt.format, glFmt.pixelType, img); + }; + _proto._setImage = function _setImage(glFmt, options) { + var gl = this._device._gl; + var flipY = options.flipY; + var premultiplyAlpha = options.premultiplyAlpha; + var faceIndex = options.faceIndex; + var img = options.image; + void 0 === flipY ? gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false) : gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, flipY); + void 0 === premultiplyAlpha ? gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false) : gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, premultiplyAlpha); + !img || ArrayBuffer.isView(img) || img instanceof ArrayBuffer ? this._compressed ? gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, options.level, glFmt.internalFormat, options.width, options.height, 0, img) : gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, options.level, glFmt.internalFormat, options.width, options.height, 0, glFmt.format, glFmt.pixelType, img) : gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, options.level, glFmt.internalFormat, glFmt.format, glFmt.pixelType, img); + }; + _proto._setMipmap = function _setMipmap(images, flipY, premultiplyAlpha) { + var glFmt = (0, _enums.glTextureFmt)(this._format); + var options = { + width: this._width, + height: this._height, + faceIndex: 0, + flipY: flipY, + premultiplyAlpha: premultiplyAlpha, + level: 0, + image: null + }; + for (var i = 0; i < images.length; ++i) { + var levelImages = images[i]; + options.level = i; + options.width = this._width >> i; + options.height = this._height >> i; + for (var face = 0; face < 6; ++face) { + options.faceIndex = face; + options.image = levelImages[face]; + this._setImage(glFmt, options); + } + } + }; + _proto._setTexInfo = function _setTexInfo() { + var gl = this._device._gl; + var pot = (0, _misc.isPow2)(this._width) && (0, _misc.isPow2)(this._height); + if (!pot && (this._wrapS !== _enums.enums.WRAP_CLAMP || this._wrapT !== _enums.enums.WRAP_CLAMP)) { + console.warn("WebGL1 doesn't support all wrap modes with NPOT textures"); + this._wrapS = _enums.enums.WRAP_CLAMP; + this._wrapT = _enums.enums.WRAP_CLAMP; + } + var mipFilter = this._genMipmaps ? this._mipFilter : -1; + if (!pot && -1 !== mipFilter) { + console.warn("NPOT textures do not support mipmap filter"); + mipFilter = -1; + } + gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, (0, _enums.glFilter)(gl, this._minFilter, mipFilter)); + gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, (0, _enums.glFilter)(gl, this._magFilter, -1)); + gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, this._wrapS); + gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, this._wrapT); + var ext = this._device.ext("EXT_texture_filter_anisotropic"); + ext && gl.texParameteri(gl.TEXTURE_CUBE_MAP, ext.TEXTURE_MAX_ANISOTROPY_EXT, this._anisotropy); + }; + return TextureCube; + })(_texture["default"]); + exports["default"] = TextureCube; + module.exports = exports["default"]; + }), { + "./enums": 370, + "./misc": 374, + "./texture": 380 + } ], + 380: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _enums = require("./enums"); + var _nullWebGLTexture = null; + var _textureID = 0; + var Texture = (function() { + function Texture(device) { + this._device = device; + this._width = 4; + this._height = 4; + this._genMipmaps = false; + this._compressed = false; + this._anisotropy = 1; + this._minFilter = _enums.enums.FILTER_LINEAR; + this._magFilter = _enums.enums.FILTER_LINEAR; + this._mipFilter = _enums.enums.FILTER_LINEAR; + this._wrapS = _enums.enums.WRAP_REPEAT; + this._wrapT = _enums.enums.WRAP_REPEAT; + this._format = _enums.enums.TEXTURE_FMT_RGBA8; + this._target = -1; + this._id = _textureID++; + } + var _proto = Texture.prototype; + _proto.destroy = function destroy() { + if (this._glID === _nullWebGLTexture) { + console.error("The texture already destroyed"); + return; + } + var gl = this._device._gl; + gl.deleteTexture(this._glID); + this._device._stats.tex -= this.bytes; + this._glID = _nullWebGLTexture; + }; + return Texture; + })(); + exports["default"] = Texture; + module.exports = exports["default"]; + }), { + "./enums": 370 + } ], + 381: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _enums = require("./enums"); + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + "value" in descriptor && (descriptor.writable = true); + Object.defineProperty(target, descriptor.key, descriptor); + } + } + function _createClass(Constructor, protoProps, staticProps) { + protoProps && _defineProperties(Constructor.prototype, protoProps); + staticProps && _defineProperties(Constructor, staticProps); + return Constructor; + } + var VertexBuffer = (function() { + function VertexBuffer(device, format, usage, data) { + this._device = device; + this._format = format; + this._usage = usage; + this._bytesPerVertex = this._format._bytes; + this._bytes = data.byteLength; + this._numVertices = this._bytes / this._bytesPerVertex; + this._needExpandDataStore = true; + this._glID = device._gl.createBuffer(); + this.update(0, data); + device._stats.vb += this._bytes; + } + var _proto = VertexBuffer.prototype; + _proto.destroy = function destroy() { + if (-1 === this._glID) { + console.error("The buffer already destroyed"); + return; + } + var gl = this._device._gl; + gl.deleteBuffer(this._glID); + this._device._stats.vb -= this.bytes; + this._glID = -1; + }; + _proto.update = function update(byteOffset, data) { + if (-1 === this._glID) { + console.error("The buffer is destroyed"); + return; + } + if (0 === data.byteLength) return; + if (byteOffset + data.byteLength > this._bytes) { + if (byteOffset) { + console.error("Failed to update data, bytes exceed."); + return; + } + this._needExpandDataStore = true; + this._bytes = byteOffset + data.byteLength; + this._numVertices = this._bytes / this._bytesPerVertex; + } + var gl = this._device._gl; + var glUsage = this._usage; + gl.bindBuffer(gl.ARRAY_BUFFER, this._glID); + if (this._needExpandDataStore) { + gl.bufferData(gl.ARRAY_BUFFER, data, glUsage); + this._needExpandDataStore = false; + } else gl.bufferSubData(gl.ARRAY_BUFFER, byteOffset, data); + gl.bindBuffer(gl.ARRAY_BUFFER, null); + }; + _proto.getFormat = function getFormat(name) { + return this._format.element(name); + }; + _proto.setUsage = function setUsage(usage) { + this._usage = usage; + }; + _createClass(VertexBuffer, [ { + key: "count", + get: function get() { + return this._numVertices; + } + } ]); + return VertexBuffer; + })(); + var _default = VertexBuffer; + exports["default"] = _default; + module.exports = exports["default"]; + }), { + "./enums": 370 + } ], + 382: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _enums = require("./enums"); + var _murmurhash2_gc = _interopRequireDefault(require("../murmurhash2_gc")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + var VertexFormat = (function() { + function VertexFormat(infos) { + this._attr2el = {}; + this._elements = []; + this._bytes = 0; + var hash = ""; + for (var i = 0, len = infos.length; i < len; ++i) { + var info = infos[i]; + var el = { + name: info.name, + offset: this._bytes, + stride: 0, + stream: -1, + type: info.type, + num: info.num, + normalize: void 0 !== info.normalize && info.normalize, + bytes: info.num * (0, _enums.attrTypeBytes)(info.type) + }; + this._attr2el[el.name] = el; + this._elements.push(el); + this._bytes += el.bytes; + hash += el.name + ":" + el.num + ":" + el.type + ":" + el.normalize; + } + for (var _i = 0, _len = this._elements.length; _i < _len; ++_i) { + var _el = this._elements[_i]; + _el.stride = this._bytes; + } + this._hash = (0, _murmurhash2_gc["default"])(hash, 666); + } + var _proto = VertexFormat.prototype; + _proto.element = function element(attrName) { + return this._attr2el[attrName]; + }; + _proto.getHash = function getHash() { + return this._hash; + }; + return VertexFormat; + })(); + exports["default"] = VertexFormat; + module.exports = exports["default"]; + }), { + "../murmurhash2_gc": 391, + "./enums": 370 + } ], + 383: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var CircularPool = (function() { + function CircularPool(fn, size) { + this._cursor = 0; + this._data = new Array(size); + for (var i = 0; i < size; ++i) this._data[i] = fn(); + } + var _proto = CircularPool.prototype; + _proto.request = function request() { + var item = this._data[this._cursor]; + this._cursor = (this._cursor + 1) % this._data.length; + return item; + }; + return CircularPool; + })(); + exports["default"] = CircularPool; + module.exports = exports["default"]; + }), {} ], + 384: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _timsort = _interopRequireDefault(require("./timsort")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + "value" in descriptor && (descriptor.writable = true); + Object.defineProperty(target, descriptor.key, descriptor); + } + } + function _createClass(Constructor, protoProps, staticProps) { + protoProps && _defineProperties(Constructor.prototype, protoProps); + staticProps && _defineProperties(Constructor, staticProps); + return Constructor; + } + var FixedArray = (function() { + function FixedArray(size) { + this._count = 0; + this._data = new Array(size); + } + var _proto = FixedArray.prototype; + _proto._resize = function _resize(size) { + if (size > this._data.length) for (var i = this._data.length; i < size; ++i) this._data[i] = void 0; + }; + _proto.reset = function reset() { + for (var i = 0; i < this._count; ++i) this._data[i] = void 0; + this._count = 0; + }; + _proto.push = function push(val) { + this._count >= this._data.length && this._resize(2 * this._data.length); + this._data[this._count] = val; + ++this._count; + }; + _proto.pop = function pop() { + --this._count; + this._count < 0 && (this._count = 0); + var ret = this._data[this._count]; + this._data[this._count] = void 0; + return ret; + }; + _proto.fastRemove = function fastRemove(idx) { + if (idx >= this._count || idx < 0) return; + var last = this._count - 1; + this._data[idx] = this._data[last]; + this._data[last] = void 0; + this._count -= 1; + }; + _proto.indexOf = function indexOf(val) { + return this._data.indexOf(val); + }; + _proto.sort = function sort(cmp) { + return (0, _timsort["default"])(this._data, 0, this._count, cmp); + }; + _createClass(FixedArray, [ { + key: "length", + get: function get() { + return this._count; + } + }, { + key: "data", + get: function get() { + return this._data; + } + } ]); + return FixedArray; + })(); + exports["default"] = FixedArray; + module.exports = exports["default"]; + }), { + "./timsort": 389 + } ], + 385: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports.TypedArrayPool = exports.RecyclePool = exports.Pool = exports.LinkedArray = exports.FixedArray = exports.CircularPool = void 0; + var _circularPool = _interopRequireDefault(require("./circular-pool")); + exports.CircularPool = _circularPool["default"]; + var _fixedArray = _interopRequireDefault(require("./fixed-array")); + exports.FixedArray = _fixedArray["default"]; + var _linkedArray = _interopRequireDefault(require("./linked-array")); + exports.LinkedArray = _linkedArray["default"]; + var _pool = _interopRequireDefault(require("./pool")); + exports.Pool = _pool["default"]; + var _recyclePool = _interopRequireDefault(require("./recycle-pool")); + exports.RecyclePool = _recyclePool["default"]; + var _typedArrayPool = _interopRequireDefault(require("./typed-array-pool")); + exports.TypedArrayPool = _typedArrayPool["default"]; + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + }), { + "./circular-pool": 383, + "./fixed-array": 384, + "./linked-array": 386, + "./pool": 387, + "./recycle-pool": 388, + "./typed-array-pool": 390 + } ], + 386: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _pool = _interopRequireDefault(require("./pool")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + "value" in descriptor && (descriptor.writable = true); + Object.defineProperty(target, descriptor.key, descriptor); + } + } + function _createClass(Constructor, protoProps, staticProps) { + protoProps && _defineProperties(Constructor.prototype, protoProps); + staticProps && _defineProperties(Constructor, staticProps); + return Constructor; + } + var LinkedArray = (function() { + function LinkedArray(fn, size) { + this._fn = fn; + this._count = 0; + this._head = null; + this._tail = null; + this._pool = new _pool["default"](fn, size); + } + var _proto = LinkedArray.prototype; + _proto.add = function add() { + var node = this._pool.alloc(); + if (this._tail) { + this._tail._next = node; + node._prev = this._tail; + } else this._head = node; + this._tail = node; + this._count += 1; + return node; + }; + _proto.remove = function remove(node) { + node._prev ? node._prev._next = node._next : this._head = node._next; + node._next ? node._next._prev = node._prev : this._tail = node._prev; + node._next = null; + node._prev = null; + this._pool.free(node); + this._count -= 1; + }; + _proto.forEach = function forEach(fn, binder) { + var cursor = this._head; + if (!cursor) return; + binder && (fn = fn.bind(binder)); + var idx = 0; + var next = cursor; + while (cursor) { + next = cursor._next; + fn(cursor, idx, this); + cursor = next; + ++idx; + } + }; + _createClass(LinkedArray, [ { + key: "head", + get: function get() { + return this._head; + } + }, { + key: "tail", + get: function get() { + return this._tail; + } + }, { + key: "length", + get: function get() { + return this._count; + } + } ]); + return LinkedArray; + })(); + exports["default"] = LinkedArray; + module.exports = exports["default"]; + }), { + "./pool": 387 + } ], + 387: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var Pool = (function() { + function Pool(fn, size) { + this._fn = fn; + this._idx = size - 1; + this._frees = new Array(size); + for (var i = 0; i < size; ++i) this._frees[i] = fn(); + } + var _proto = Pool.prototype; + _proto._expand = function _expand(size) { + var old = this._frees; + this._frees = new Array(size); + var len = size - old.length; + for (var i = 0; i < len; ++i) this._frees[i] = this._fn(); + for (var _i = len, j = 0; _i < size; ++_i, ++j) this._frees[_i] = old[j]; + this._idx += len; + }; + _proto.alloc = function alloc() { + this._idx < 0 && this._expand(Math.round(1.2 * this._frees.length) + 1); + var ret = this._frees[this._idx]; + this._frees[this._idx] = null; + --this._idx; + return ret; + }; + _proto.free = function free(obj) { + ++this._idx; + this._frees[this._idx] = obj; + }; + _proto.clear = function clear(fn) { + for (var i = 0; i <= this._idx; i++) fn && fn(this._frees[i]); + this._frees.length = 0; + this._idx = -1; + }; + return Pool; + })(); + exports["default"] = Pool; + module.exports = exports["default"]; + }), {} ], + 388: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _timsort = _interopRequireDefault(require("./timsort")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + "value" in descriptor && (descriptor.writable = true); + Object.defineProperty(target, descriptor.key, descriptor); + } + } + function _createClass(Constructor, protoProps, staticProps) { + protoProps && _defineProperties(Constructor.prototype, protoProps); + staticProps && _defineProperties(Constructor, staticProps); + return Constructor; + } + var RecyclePool = (function() { + function RecyclePool(fn, size) { + this._fn = fn; + this._count = 0; + this._data = new Array(size); + for (var i = 0; i < size; ++i) this._data[i] = fn(); + } + var _proto = RecyclePool.prototype; + _proto.reset = function reset() { + this._count = 0; + }; + _proto.resize = function resize(size) { + if (size > this._data.length) for (var i = this._data.length; i < size; ++i) this._data[i] = this._fn(); + }; + _proto.add = function add() { + this._count >= this._data.length && this.resize(2 * this._data.length); + return this._data[this._count++]; + }; + _proto.remove = function remove(idx) { + if (idx >= this._count) return; + var last = this._count - 1; + var tmp = this._data[idx]; + this._data[idx] = this._data[last]; + this._data[last] = tmp; + this._count -= 1; + }; + _proto.sort = function sort(cmp) { + return (0, _timsort["default"])(this._data, 0, this._count, cmp); + }; + _createClass(RecyclePool, [ { + key: "length", + get: function get() { + return this._count; + } + }, { + key: "data", + get: function get() { + return this._data; + } + } ]); + return RecyclePool; + })(); + exports["default"] = RecyclePool; + cc.RecyclePool = RecyclePool; + module.exports = exports["default"]; + }), { + "./timsort": 389 + } ], + 389: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = _default; + var DEFAULT_MIN_MERGE = 32; + var DEFAULT_MIN_GALLOPING = 7; + var DEFAULT_TMP_STORAGE_LENGTH = 256; + var POWERS_OF_TEN = [ 1, 10, 100, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9 ]; + function log10(x) { + if (x < 1e5) { + if (x < 100) return x < 10 ? 0 : 1; + if (x < 1e4) return x < 1e3 ? 2 : 3; + return 4; + } + if (x < 1e7) return x < 1e6 ? 5 : 6; + if (x < 1e9) return x < 1e8 ? 7 : 8; + return 9; + } + function alphabeticalCompare(a, b) { + if (a === b) return 0; + if (~~a === a && ~~b === b) { + if (0 === a || 0 === b) return a < b ? -1 : 1; + if (a < 0 || b < 0) { + if (b >= 0) return -1; + if (a >= 0) return 1; + a = -a; + b = -b; + } + var al = log10(a); + var bl = log10(b); + var t = 0; + if (al < bl) { + a *= POWERS_OF_TEN[bl - al - 1]; + b /= 10; + t = -1; + } else if (al > bl) { + b *= POWERS_OF_TEN[al - bl - 1]; + a /= 10; + t = 1; + } + if (a === b) return t; + return a < b ? -1 : 1; + } + var aStr = String(a); + var bStr = String(b); + if (aStr === bStr) return 0; + return aStr < bStr ? -1 : 1; + } + function minRunLength(n) { + var r = 0; + while (n >= DEFAULT_MIN_MERGE) { + r |= 1 & n; + n >>= 1; + } + return n + r; + } + function makeAscendingRun(array, lo, hi, compare) { + var runHi = lo + 1; + if (runHi === hi) return 1; + if (compare(array[runHi++], array[lo]) < 0) { + while (runHi < hi && compare(array[runHi], array[runHi - 1]) < 0) runHi++; + reverseRun(array, lo, runHi); + } else while (runHi < hi && compare(array[runHi], array[runHi - 1]) >= 0) runHi++; + return runHi - lo; + } + function reverseRun(array, lo, hi) { + hi--; + while (lo < hi) { + var t = array[lo]; + array[lo++] = array[hi]; + array[hi--] = t; + } + } + function binaryInsertionSort(array, lo, hi, start, compare) { + start === lo && start++; + for (;start < hi; start++) { + var pivot = array[start]; + var left = lo; + var right = start; + while (left < right) { + var mid = left + right >>> 1; + compare(pivot, array[mid]) < 0 ? right = mid : left = mid + 1; + } + var n = start - left; + switch (n) { + case 3: + array[left + 3] = array[left + 2]; + + case 2: + array[left + 2] = array[left + 1]; + + case 1: + array[left + 1] = array[left]; + break; + + default: + while (n > 0) { + array[left + n] = array[left + n - 1]; + n--; + } + } + array[left] = pivot; + } + } + function gallopLeft(value, array, start, length, hint, compare) { + var lastOffset = 0; + var maxOffset = 0; + var offset = 1; + if (compare(value, array[start + hint]) > 0) { + maxOffset = length - hint; + while (offset < maxOffset && compare(value, array[start + hint + offset]) > 0) { + lastOffset = offset; + offset = 1 + (offset << 1); + offset <= 0 && (offset = maxOffset); + } + offset > maxOffset && (offset = maxOffset); + lastOffset += hint; + offset += hint; + } else { + maxOffset = hint + 1; + while (offset < maxOffset && compare(value, array[start + hint - offset]) <= 0) { + lastOffset = offset; + offset = 1 + (offset << 1); + offset <= 0 && (offset = maxOffset); + } + offset > maxOffset && (offset = maxOffset); + var tmp = lastOffset; + lastOffset = hint - offset; + offset = hint - tmp; + } + lastOffset++; + while (lastOffset < offset) { + var m = lastOffset + (offset - lastOffset >>> 1); + compare(value, array[start + m]) > 0 ? lastOffset = m + 1 : offset = m; + } + return offset; + } + function gallopRight(value, array, start, length, hint, compare) { + var lastOffset = 0; + var maxOffset = 0; + var offset = 1; + if (compare(value, array[start + hint]) < 0) { + maxOffset = hint + 1; + while (offset < maxOffset && compare(value, array[start + hint - offset]) < 0) { + lastOffset = offset; + offset = 1 + (offset << 1); + offset <= 0 && (offset = maxOffset); + } + offset > maxOffset && (offset = maxOffset); + var tmp = lastOffset; + lastOffset = hint - offset; + offset = hint - tmp; + } else { + maxOffset = length - hint; + while (offset < maxOffset && compare(value, array[start + hint + offset]) >= 0) { + lastOffset = offset; + offset = 1 + (offset << 1); + offset <= 0 && (offset = maxOffset); + } + offset > maxOffset && (offset = maxOffset); + lastOffset += hint; + offset += hint; + } + lastOffset++; + while (lastOffset < offset) { + var m = lastOffset + (offset - lastOffset >>> 1); + compare(value, array[start + m]) < 0 ? offset = m : lastOffset = m + 1; + } + return offset; + } + var TimSort = (function() { + function TimSort(array, compare) { + this.array = array; + this.compare = compare; + this.minGallop = DEFAULT_MIN_GALLOPING; + this.length = array.length; + this.tmpStorageLength = DEFAULT_TMP_STORAGE_LENGTH; + this.length < 2 * DEFAULT_TMP_STORAGE_LENGTH && (this.tmpStorageLength = this.length >>> 1); + this.tmp = new Array(this.tmpStorageLength); + this.stackLength = this.length < 120 ? 5 : this.length < 1542 ? 10 : this.length < 119151 ? 19 : 40; + this.runStart = new Array(this.stackLength); + this.runLength = new Array(this.stackLength); + this.stackSize = 0; + } + var _proto = TimSort.prototype; + _proto.pushRun = function pushRun(runStart, runLength) { + this.runStart[this.stackSize] = runStart; + this.runLength[this.stackSize] = runLength; + this.stackSize += 1; + }; + _proto.mergeRuns = function mergeRuns() { + while (this.stackSize > 1) { + var n = this.stackSize - 2; + if (n >= 1 && this.runLength[n - 1] <= this.runLength[n] + this.runLength[n + 1] || n >= 2 && this.runLength[n - 2] <= this.runLength[n] + this.runLength[n - 1]) this.runLength[n - 1] < this.runLength[n + 1] && n--; else if (this.runLength[n] > this.runLength[n + 1]) break; + this.mergeAt(n); + } + }; + _proto.forceMergeRuns = function forceMergeRuns() { + while (this.stackSize > 1) { + var n = this.stackSize - 2; + n > 0 && this.runLength[n - 1] < this.runLength[n + 1] && n--; + this.mergeAt(n); + } + }; + _proto.mergeAt = function mergeAt(i) { + var compare = this.compare; + var array = this.array; + var start1 = this.runStart[i]; + var length1 = this.runLength[i]; + var start2 = this.runStart[i + 1]; + var length2 = this.runLength[i + 1]; + this.runLength[i] = length1 + length2; + if (i === this.stackSize - 3) { + this.runStart[i + 1] = this.runStart[i + 2]; + this.runLength[i + 1] = this.runLength[i + 2]; + } + this.stackSize--; + var k = gallopRight(array[start2], array, start1, length1, 0, compare); + start1 += k; + length1 -= k; + if (0 === length1) return; + length2 = gallopLeft(array[start1 + length1 - 1], array, start2, length2, length2 - 1, compare); + if (0 === length2) return; + length1 <= length2 ? this.mergeLow(start1, length1, start2, length2) : this.mergeHigh(start1, length1, start2, length2); + }; + _proto.mergeLow = function mergeLow(start1, length1, start2, length2) { + var compare = this.compare; + var array = this.array; + var tmp = this.tmp; + var i = 0; + for (i = 0; i < length1; i++) tmp[i] = array[start1 + i]; + var cursor1 = 0; + var cursor2 = start2; + var dest = start1; + array[dest++] = array[cursor2++]; + if (0 === --length2) { + for (i = 0; i < length1; i++) array[dest + i] = tmp[cursor1 + i]; + return; + } + if (1 === length1) { + for (i = 0; i < length2; i++) array[dest + i] = array[cursor2 + i]; + array[dest + length2] = tmp[cursor1]; + return; + } + var minGallop = this.minGallop; + while (true) { + var count1 = 0; + var count2 = 0; + var exit = false; + do { + if (compare(array[cursor2], tmp[cursor1]) < 0) { + array[dest++] = array[cursor2++]; + count2++; + count1 = 0; + if (0 === --length2) { + exit = true; + break; + } + } else { + array[dest++] = tmp[cursor1++]; + count1++; + count2 = 0; + if (1 === --length1) { + exit = true; + break; + } + } + } while ((count1 | count2) < minGallop); + if (exit) break; + do { + count1 = gallopRight(array[cursor2], tmp, cursor1, length1, 0, compare); + if (0 !== count1) { + for (i = 0; i < count1; i++) array[dest + i] = tmp[cursor1 + i]; + dest += count1; + cursor1 += count1; + length1 -= count1; + if (length1 <= 1) { + exit = true; + break; + } + } + array[dest++] = array[cursor2++]; + if (0 === --length2) { + exit = true; + break; + } + count2 = gallopLeft(tmp[cursor1], array, cursor2, length2, 0, compare); + if (0 !== count2) { + for (i = 0; i < count2; i++) array[dest + i] = array[cursor2 + i]; + dest += count2; + cursor2 += count2; + length2 -= count2; + if (0 === length2) { + exit = true; + break; + } + } + array[dest++] = tmp[cursor1++]; + if (1 === --length1) { + exit = true; + break; + } + minGallop--; + } while (count1 >= DEFAULT_MIN_GALLOPING || count2 >= DEFAULT_MIN_GALLOPING); + if (exit) break; + minGallop < 0 && (minGallop = 0); + minGallop += 2; + } + this.minGallop = minGallop; + minGallop < 1 && (this.minGallop = 1); + if (1 === length1) { + for (i = 0; i < length2; i++) array[dest + i] = array[cursor2 + i]; + array[dest + length2] = tmp[cursor1]; + } else { + if (0 === length1) throw new Error("mergeLow preconditions were not respected"); + for (i = 0; i < length1; i++) array[dest + i] = tmp[cursor1 + i]; + } + }; + _proto.mergeHigh = function mergeHigh(start1, length1, start2, length2) { + var compare = this.compare; + var array = this.array; + var tmp = this.tmp; + var i = 0; + for (i = 0; i < length2; i++) tmp[i] = array[start2 + i]; + var cursor1 = start1 + length1 - 1; + var cursor2 = length2 - 1; + var dest = start2 + length2 - 1; + var customCursor = 0; + var customDest = 0; + array[dest--] = array[cursor1--]; + if (0 === --length1) { + customCursor = dest - (length2 - 1); + for (i = 0; i < length2; i++) array[customCursor + i] = tmp[i]; + return; + } + if (1 === length2) { + dest -= length1; + cursor1 -= length1; + customDest = dest + 1; + customCursor = cursor1 + 1; + for (i = length1 - 1; i >= 0; i--) array[customDest + i] = array[customCursor + i]; + array[dest] = tmp[cursor2]; + return; + } + var minGallop = this.minGallop; + while (true) { + var count1 = 0; + var count2 = 0; + var exit = false; + do { + if (compare(tmp[cursor2], array[cursor1]) < 0) { + array[dest--] = array[cursor1--]; + count1++; + count2 = 0; + if (0 === --length1) { + exit = true; + break; + } + } else { + array[dest--] = tmp[cursor2--]; + count2++; + count1 = 0; + if (1 === --length2) { + exit = true; + break; + } + } + } while ((count1 | count2) < minGallop); + if (exit) break; + do { + count1 = length1 - gallopRight(tmp[cursor2], array, start1, length1, length1 - 1, compare); + if (0 !== count1) { + dest -= count1; + cursor1 -= count1; + length1 -= count1; + customDest = dest + 1; + customCursor = cursor1 + 1; + for (i = count1 - 1; i >= 0; i--) array[customDest + i] = array[customCursor + i]; + if (0 === length1) { + exit = true; + break; + } + } + array[dest--] = tmp[cursor2--]; + if (1 === --length2) { + exit = true; + break; + } + count2 = length2 - gallopLeft(array[cursor1], tmp, 0, length2, length2 - 1, compare); + if (0 !== count2) { + dest -= count2; + cursor2 -= count2; + length2 -= count2; + customDest = dest + 1; + customCursor = cursor2 + 1; + for (i = 0; i < count2; i++) array[customDest + i] = tmp[customCursor + i]; + if (length2 <= 1) { + exit = true; + break; + } + } + array[dest--] = array[cursor1--]; + if (0 === --length1) { + exit = true; + break; + } + minGallop--; + } while (count1 >= DEFAULT_MIN_GALLOPING || count2 >= DEFAULT_MIN_GALLOPING); + if (exit) break; + minGallop < 0 && (minGallop = 0); + minGallop += 2; + } + this.minGallop = minGallop; + minGallop < 1 && (this.minGallop = 1); + if (1 === length2) { + dest -= length1; + cursor1 -= length1; + customDest = dest + 1; + customCursor = cursor1 + 1; + for (i = length1 - 1; i >= 0; i--) array[customDest + i] = array[customCursor + i]; + array[dest] = tmp[cursor2]; + } else { + if (0 === length2) throw new Error("mergeHigh preconditions were not respected"); + customCursor = dest - (length2 - 1); + for (i = 0; i < length2; i++) array[customCursor + i] = tmp[i]; + } + }; + return TimSort; + })(); + function _default(array, lo, hi, compare) { + if (!Array.isArray(array)) throw new TypeError("Can only sort arrays"); + void 0 === lo && (lo = 0); + void 0 === hi && (hi = array.length); + void 0 === compare && (compare = alphabeticalCompare); + var remaining = hi - lo; + if (remaining < 2) return; + var runLength = 0; + if (remaining < DEFAULT_MIN_MERGE) { + runLength = makeAscendingRun(array, lo, hi, compare); + binaryInsertionSort(array, lo, hi, lo + runLength, compare); + return; + } + var ts = new TimSort(array, compare); + var minRun = minRunLength(remaining); + do { + runLength = makeAscendingRun(array, lo, hi, compare); + if (runLength < minRun) { + var force = remaining; + force > minRun && (force = minRun); + binaryInsertionSort(array, lo, lo + force, lo + runLength, compare); + runLength = force; + } + ts.pushRun(lo, runLength); + ts.mergeRuns(); + remaining -= runLength; + lo += runLength; + } while (0 !== remaining); + ts.forceMergeRuns(); + } + module.exports = exports["default"]; + }), {} ], + 390: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _bufferPools = Array(8); + for (var i = 0; i < 8; ++i) _bufferPools[i] = []; + function _nextPow16(v) { + for (var _i = 16; _i <= 1 << 28; _i *= 16) if (v <= _i) return _i; + return 0; + } + function _log2(v) { + var r, shift; + r = (v > 65535) << 4; + v >>>= r; + shift = (v > 255) << 3; + v >>>= shift; + r |= shift; + shift = (v > 15) << 2; + v >>>= shift; + r |= shift; + shift = (v > 3) << 1; + v >>>= shift; + r |= shift; + return r | v >> 1; + } + function _alloc(n) { + var sz = _nextPow16(n); + var bin = _bufferPools[_log2(sz) >> 2]; + if (bin.length > 0) return bin.pop(); + return new ArrayBuffer(sz); + } + function _free(buf) { + _bufferPools[_log2(buf.byteLength) >> 2].push(buf); + } + var _default = { + alloc_int8: function alloc_int8(n) { + var result = new Int8Array(_alloc(n), 0, n); + if (result.length !== n) return result.subarray(0, n); + return result; + }, + alloc_uint8: function alloc_uint8(n) { + var result = new Uint8Array(_alloc(n), 0, n); + if (result.length !== n) return result.subarray(0, n); + return result; + }, + alloc_int16: function alloc_int16(n) { + var result = new Int16Array(_alloc(2 * n), 0, n); + if (result.length !== n) return result.subarray(0, n); + return result; + }, + alloc_uint16: function alloc_uint16(n) { + var result = new Uint16Array(_alloc(2 * n), 0, n); + if (result.length !== n) return result.subarray(0, n); + return result; + }, + alloc_int32: function alloc_int32(n) { + var result = new Int32Array(_alloc(4 * n), 0, n); + if (result.length !== n) return result.subarray(0, n); + return result; + }, + alloc_uint32: function alloc_uint32(n) { + var result = new Uint32Array(_alloc(4 * n), 0, n); + if (result.length !== n) return result.subarray(0, n); + return result; + }, + alloc_float32: function alloc_float32(n) { + var result = new Float32Array(_alloc(4 * n), 0, n); + if (result.length !== n) return result.subarray(0, n); + return result; + }, + alloc_float64: function alloc_float64(n) { + var result = new Float64Array(_alloc(8 * n), 0, n); + if (result.length !== n) return result.subarray(0, n); + return result; + }, + alloc_dataview: function alloc_dataview(n) { + var result = new DataView(_alloc(n), 0, n); + if (result.length !== n) return result.subarray(0, n); + return result; + }, + free: function free(array) { + _free(array.buffer); + }, + reset: function reset() { + var _bufferPools = Array(8); + for (var _i2 = 0; _i2 < 8; ++_i2) _bufferPools[_i2] = []; + } + }; + exports["default"] = _default; + module.exports = exports["default"]; + }), {} ], + 391: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = murmurhash2_32_gc; + function murmurhash2_32_gc(str, seed) { + var l = str.length, h = seed ^ l, i = 0, k; + while (l >= 4) { + k = 255 & str.charCodeAt(i) | (255 & str.charCodeAt(++i)) << 8 | (255 & str.charCodeAt(++i)) << 16 | (255 & str.charCodeAt(++i)) << 24; + k = 1540483477 * (65535 & k) + ((1540483477 * (k >>> 16) & 65535) << 16); + k ^= k >>> 24; + k = 1540483477 * (65535 & k) + ((1540483477 * (k >>> 16) & 65535) << 16); + h = 1540483477 * (65535 & h) + ((1540483477 * (h >>> 16) & 65535) << 16) ^ k; + l -= 4; + ++i; + } + switch (l) { + case 3: + h ^= (255 & str.charCodeAt(i + 2)) << 16; + + case 2: + h ^= (255 & str.charCodeAt(i + 1)) << 8; + + case 1: + h ^= 255 & str.charCodeAt(i); + h = 1540483477 * (65535 & h) + ((1540483477 * (h >>> 16) & 65535) << 16); + } + h ^= h >>> 13; + h = 1540483477 * (65535 & h) + ((1540483477 * (h >>> 16) & 65535) << 16); + h ^= h >>> 15; + return h >>> 0; + } + module.exports = exports["default"]; + }), {} ], + 392: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _valueTypes = require("../../core/value-types"); + var _baseRenderer = _interopRequireDefault(require("../core/base-renderer")); + var _enums = _interopRequireDefault(require("../enums")); + var _memop = require("../memop"); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _assertThisInitialized(self) { + if (void 0 === self) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + return self; + } + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + _setPrototypeOf(subClass, superClass); + } + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + return _setPrototypeOf(o, p); + } + var _a16_view = new Float32Array(16); + var _a16_view_inv = new Float32Array(16); + var _a16_proj = new Float32Array(16); + var _a16_viewProj = new Float32Array(16); + var _a4_camPos = new Float32Array(4); + var _a64_shadow_lightViewProj = new Float32Array(64); + var _a16_shadow_lightViewProjs = []; + var _a4_shadow_info = new Float32Array(4); + var _camPos = new _valueTypes.Vec4(0, 0, 0, 0); + var _camFwd = new _valueTypes.Vec3(0, 0, 0); + var _v3_tmp1 = new _valueTypes.Vec3(0, 0, 0); + var CC_MAX_LIGHTS = 4; + var CC_MAX_SHADOW_LIGHTS = 2; + var _float16_pool = new _memop.RecyclePool(function() { + return new Float32Array(16); + }, 8); + function sortView(a, b) { + return a._priority - b._priority; + } + var ForwardRenderer = (function(_BaseRenderer) { + _inheritsLoose(ForwardRenderer, _BaseRenderer); + function ForwardRenderer(device, builtin) { + var _this; + _this = _BaseRenderer.call(this, device, builtin) || this; + _this._time = new Float32Array(4); + _this._lights = []; + _this._shadowLights = []; + _this._numLights = 0; + _this._defines = {}; + _this._registerStage("shadowcast", _this._shadowStage.bind(_assertThisInitialized(_this))); + _this._registerStage("opaque", _this._opaqueStage.bind(_assertThisInitialized(_this))); + _this._registerStage("transparent", _this._transparentStage.bind(_assertThisInitialized(_this))); + return _this; + } + var _proto = ForwardRenderer.prototype; + _proto.reset = function reset() { + _float16_pool.reset(); + _BaseRenderer.prototype.reset.call(this); + }; + _proto.render = function render(scene, dt) { + this.reset(); + true; + if (dt) { + this._time[0] += dt; + this._time[1] = dt; + this._time[2]++; + } + this._device.setUniform("cc_time", this._time); + this._updateLights(scene); + var canvas = this._device._gl.canvas; + for (var i = 0; i < scene._cameras.length; ++i) { + var view = this._requestView(); + var width = canvas.width; + var height = canvas.height; + var camera = scene._cameras.data[i]; + camera.extractView(view, width, height); + } + this._viewPools.sort(sortView); + for (var _i = 0; _i < this._viewPools.length; ++_i) { + var _view = this._viewPools.data[_i]; + this._render(_view, scene); + } + }; + _proto.renderCamera = function renderCamera(camera, scene) { + this.reset(); + this._updateLights(scene); + var canvas = this._device._gl.canvas; + var width = canvas.width; + var height = canvas.height; + var view = this._requestView(); + camera.extractView(view, width, height); + this._viewPools.sort(sortView); + for (var i = 0; i < this._viewPools.length; ++i) { + var _view2 = this._viewPools.data[i]; + this._render(_view2, scene); + } + }; + _proto._updateLights = function _updateLights(scene) { + this._lights.length = 0; + this._shadowLights.length = 0; + var lights = scene._lights; + for (var i = 0; i < lights.length; ++i) { + var light = lights.data[i]; + light.update(this._device); + if (light.shadowType !== _enums["default"].SHADOW_NONE) { + this._shadowLights.length < CC_MAX_SHADOW_LIGHTS && this._shadowLights.unshift(light); + var view = this._requestView(); + light.extractView(view, [ "shadowcast" ]); + this._lights.splice(0, 0, light); + } else this._lights.push(light); + } + this._updateLightDefines(); + this._numLights = lights._count; + }; + _proto._updateLightDefines = function _updateLightDefines() { + var defines = this._defines; + for (var i = 0; i < this._lights.length; ++i) { + var light = this._lights[i]; + var lightKey = "CC_LIGHT_" + i + "_TYPE"; + var shadowKey = "CC_SHADOW_" + i + "_TYPE"; + if (defines[lightKey] !== light._type) { + defines[lightKey] = light._type; + this._definesChanged = true; + } + if (defines[shadowKey] !== light._shadowType) { + defines[shadowKey] = light._shadowType; + this._definesChanged = true; + } + } + var newCount = Math.min(CC_MAX_LIGHTS, this._lights.length); + if (defines.CC_NUM_LIGHTS !== newCount) { + defines.CC_NUM_LIGHTS = newCount; + this._definesChanged = true; + } + newCount = Math.min(CC_MAX_LIGHTS, this._shadowLights.length); + if (defines.CC_NUM_SHADOW_LIGHTS !== newCount) { + defines.CC_NUM_SHADOW_LIGHTS = newCount; + this._definesChanged = true; + } + }; + _proto._submitLightsUniforms = function _submitLightsUniforms() { + var device = this._device; + if (this._lights.length > 0) { + var positionAndRanges = _float16_pool.add(); + var directions = _float16_pool.add(); + var colors = _float16_pool.add(); + var lightNum = Math.min(CC_MAX_LIGHTS, this._lights.length); + for (var i = 0; i < lightNum; ++i) { + var light = this._lights[i]; + var index = 4 * i; + colors.set(light._colorUniform, index); + directions.set(light._directionUniform, index); + positionAndRanges.set(light._positionUniform, index); + positionAndRanges[index + 3] = light._range; + if (light._type === _enums["default"].LIGHT_SPOT) { + directions[index + 3] = light._spotUniform[0]; + colors[index + 3] = light._spotUniform[1]; + } else { + directions[index + 3] = 0; + colors[index + 3] = 0; + } + } + device.setUniform("cc_lightDirection", directions); + device.setUniform("cc_lightColor", colors); + device.setUniform("cc_lightPositionAndRange", positionAndRanges); + } + }; + _proto._submitShadowStageUniforms = function _submitShadowStageUniforms(view) { + var light = view._shadowLight; + var shadowInfo = _a4_shadow_info; + shadowInfo[0] = light.shadowMinDepth; + shadowInfo[1] = light.shadowMaxDepth; + shadowInfo[2] = light.shadowDepthScale; + shadowInfo[3] = light.shadowDarkness; + this._device.setUniform("cc_shadow_map_lightViewProjMatrix", _valueTypes.Mat4.toArray(_a16_viewProj, view._matViewProj)); + this._device.setUniform("cc_shadow_map_info", shadowInfo); + this._device.setUniform("cc_shadow_map_bias", light.shadowBias); + this._defines.CC_SHADOW_TYPE = light._shadowType; + }; + _proto._submitOtherStagesUniforms = function _submitOtherStagesUniforms() { + var shadowInfo = _float16_pool.add(); + for (var i = 0; i < this._shadowLights.length; ++i) { + var light = this._shadowLights[i]; + var view = _a16_shadow_lightViewProjs[i]; + view || (view = _a16_shadow_lightViewProjs[i] = new Float32Array(_a64_shadow_lightViewProj.buffer, 64 * i, 16)); + _valueTypes.Mat4.toArray(view, light.viewProjMatrix); + var index = 4 * i; + shadowInfo[index] = light.shadowMinDepth; + shadowInfo[index + 1] = light.shadowMaxDepth; + shadowInfo[index + 2] = light._shadowResolution; + shadowInfo[index + 3] = light.shadowDarkness; + } + this._device.setUniform("cc_shadow_lightViewProjMatrix", _a64_shadow_lightViewProj); + this._device.setUniform("cc_shadow_info", shadowInfo); + }; + _proto._sortItems = function _sortItems(items) { + items.sort((function(a, b) { + if (a.passes.length !== b.passes.length) return a.passes.length - b.passes.length; + return a.sortKey - b.sortKey; + })); + }; + _proto._shadowStage = function _shadowStage(view, items) { + this._submitShadowStageUniforms(view); + for (var i = 0; i < items.length; ++i) { + var item = items.data[i]; + item.effect.getDefine("CC_CASTING_SHADOW") && this._draw(item); + } + }; + _proto._drawItems = function _drawItems(view, items) { + var shadowLights = this._shadowLights; + if (0 === shadowLights.length && 0 === this._numLights) for (var i = 0; i < items.length; ++i) { + var item = items.data[i]; + this._draw(item); + } else for (var _i2 = 0; _i2 < items.length; ++_i2) { + var _item = items.data[_i2]; + for (var shadowIdx = 0; shadowIdx < shadowLights.length; ++shadowIdx) this._device.setTexture("cc_shadow_map_" + shadowIdx, shadowLights[shadowIdx].shadowMap, this._allocTextureUnit()); + this._draw(_item); + } + }; + _proto._opaqueStage = function _opaqueStage(view, items) { + view.getPosition(_camPos); + this._device.setUniform("cc_matView", _valueTypes.Mat4.toArray(_a16_view, view._matView)); + this._device.setUniform("cc_matViewInv", _valueTypes.Mat4.toArray(_a16_view_inv, view._matViewInv)); + this._device.setUniform("cc_matProj", _valueTypes.Mat4.toArray(_a16_proj, view._matProj)); + this._device.setUniform("cc_matViewProj", _valueTypes.Mat4.toArray(_a16_viewProj, view._matViewProj)); + this._device.setUniform("cc_cameraPos", _valueTypes.Vec4.toArray(_a4_camPos, _camPos)); + this._submitLightsUniforms(); + this._submitOtherStagesUniforms(); + this._drawItems(view, items); + }; + _proto._transparentStage = function _transparentStage(view, items) { + view.getPosition(_camPos); + view.getForward(_camFwd); + this._device.setUniform("cc_matView", _valueTypes.Mat4.toArray(_a16_view, view._matView)); + this._device.setUniform("cc_matViewInv", _valueTypes.Mat4.toArray(_a16_view_inv, view._matViewInv)); + this._device.setUniform("cc_matProj", _valueTypes.Mat4.toArray(_a16_proj, view._matProj)); + this._device.setUniform("cc_matViewProj", _valueTypes.Mat4.toArray(_a16_viewProj, view._matViewProj)); + this._device.setUniform("cc_cameraPos", _valueTypes.Vec4.toArray(_a4_camPos, _camPos)); + this._submitLightsUniforms(); + this._submitOtherStagesUniforms(); + for (var i = 0; i < items.length; ++i) { + var item = items.data[i]; + item.node.getWorldPosition(_v3_tmp1); + _valueTypes.Vec3.sub(_v3_tmp1, _v3_tmp1, _camPos); + item.sortKey = -_valueTypes.Vec3.dot(_v3_tmp1, _camFwd); + } + this._sortItems(items); + this._drawItems(view, items); + }; + return ForwardRenderer; + })(_baseRenderer["default"]); + exports["default"] = ForwardRenderer; + module.exports = exports["default"]; + }), { + "../../core/value-types": 340, + "../core/base-renderer": 362, + "../enums": 368, + "../memop": 385 + } ], + 393: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _valueTypes = require("../../core/value-types"); + var _geomUtils = require("../../core/geom-utils"); + var _enums = _interopRequireDefault(require("../enums")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + "value" in descriptor && (descriptor.writable = true); + Object.defineProperty(target, descriptor.key, descriptor); + } + } + function _createClass(Constructor, protoProps, staticProps) { + protoProps && _defineProperties(Constructor.prototype, protoProps); + staticProps && _defineProperties(Constructor, staticProps); + return Constructor; + } + var _tmp_mat4 = new _valueTypes.Mat4(); + var _matView = new _valueTypes.Mat4(); + var _matViewInv = new _valueTypes.Mat4(); + var _matProj = new _valueTypes.Mat4(); + var _matViewProj = new _valueTypes.Mat4(); + var _matInvViewProj = new _valueTypes.Mat4(); + var _tmp_v3 = new _valueTypes.Vec3(); + var _tmp2_v3 = new _valueTypes.Vec3(); + var Camera = (function() { + function Camera() { + this._poolID = -1; + this._node = null; + this._projection = _enums["default"].PROJ_PERSPECTIVE; + this._priority = 0; + this._color = new _valueTypes.Vec4(.2, .3, .47, 1); + this._depth = 1; + this._stencil = 0; + this._clearFlags = _enums["default"].CLEAR_COLOR | _enums["default"].CLEAR_DEPTH; + this._clearModel = null; + this._stages = []; + this._framebuffer = null; + this._near = .01; + this._far = 1e3; + this._fov = Math.PI / 4; + this._rect = { + x: 0, + y: 0, + w: 1, + h: 1 + }; + this._orthoHeight = 10; + this._cullingMask = 4294967295; + } + var _proto = Camera.prototype; + _proto.setCullingMask = function setCullingMask(mask) { + this._cullingMask = mask; + }; + _proto.getNode = function getNode() { + return this._node; + }; + _proto.setNode = function setNode(node) { + this._node = node; + }; + _proto.getType = function getType() { + return this._projection; + }; + _proto.setType = function setType(type) { + this._projection = type; + }; + _proto.getPriority = function getPriority() { + return this._priority; + }; + _proto.setPriority = function setPriority(priority) { + this._priority = priority; + }; + _proto.getOrthoHeight = function getOrthoHeight() { + return this._orthoHeight; + }; + _proto.setOrthoHeight = function setOrthoHeight(val) { + this._orthoHeight = val; + }; + _proto.getFov = function getFov() { + return this._fov; + }; + _proto.setFov = function setFov(fov) { + this._fov = fov; + }; + _proto.getNear = function getNear() { + return this._near; + }; + _proto.setNear = function setNear(near) { + this._near = near; + }; + _proto.getFar = function getFar() { + return this._far; + }; + _proto.setFar = function setFar(far) { + this._far = far; + }; + _proto.getColor = function getColor(out) { + return _valueTypes.Vec4.copy(out, this._color); + }; + _proto.setColor = function setColor(r, g, b, a) { + _valueTypes.Vec4.set(this._color, r, g, b, a); + }; + _proto.getDepth = function getDepth() { + return this._depth; + }; + _proto.setDepth = function setDepth(depth) { + this._depth = depth; + }; + _proto.getStencil = function getStencil() { + return this._stencil; + }; + _proto.setStencil = function setStencil(stencil) { + this._stencil = stencil; + }; + _proto.getClearFlags = function getClearFlags() { + return this._clearFlags; + }; + _proto.setClearFlags = function setClearFlags(flags) { + this._clearFlags = flags; + }; + _proto.getRect = function getRect(out) { + out.x = this._rect.x; + out.y = this._rect.y; + out.w = this._rect.w; + out.h = this._rect.h; + return out; + }; + _proto.setRect = function setRect(x, y, w, h) { + this._rect.x = x; + this._rect.y = y; + this._rect.w = w; + this._rect.h = h; + }; + _proto.getStages = function getStages() { + return this._stages; + }; + _proto.setStages = function setStages(stages) { + this._stages = stages; + }; + _proto.getFramebuffer = function getFramebuffer() { + return this._framebuffer; + }; + _proto.setFrameBuffer = function setFrameBuffer(framebuffer) { + this._framebuffer = framebuffer; + }; + _proto._calcMatrices = function _calcMatrices(width, height) { + this._node.getWorldRT(_matViewInv); + _valueTypes.Mat4.invert(_matView, _matViewInv); + var aspect = width / height; + if (this._projection === _enums["default"].PROJ_PERSPECTIVE) _valueTypes.Mat4.perspective(_matProj, this._fov, aspect, this._near, this._far); else { + var x = this._orthoHeight * aspect; + var y = this._orthoHeight; + _valueTypes.Mat4.ortho(_matProj, -x, x, -y, y, this._near, this._far); + } + _valueTypes.Mat4.mul(_matViewProj, _matProj, _matView); + _valueTypes.Mat4.invert(_matInvViewProj, _matViewProj); + }; + _proto.extractView = function extractView(out, width, height) { + if (this._framebuffer) { + width = this._framebuffer._width; + height = this._framebuffer._height; + } + out._priority = this._priority; + out._rect.x = this._rect.x * width; + out._rect.y = this._rect.y * height; + out._rect.w = this._rect.w * width; + out._rect.h = this._rect.h * height; + this.getColor(out._color); + out._depth = this._depth; + out._stencil = this._stencil; + out._clearFlags = this._clearFlags; + out._clearModel = this._clearModel; + out._stages = this._stages; + out._framebuffer = this._framebuffer; + this._calcMatrices(width, height); + _valueTypes.Mat4.copy(out._matView, _matView); + _valueTypes.Mat4.copy(out._matViewInv, _matViewInv); + _valueTypes.Mat4.copy(out._matProj, _matProj); + _valueTypes.Mat4.copy(out._matViewProj, _matViewProj); + _valueTypes.Mat4.copy(out._matInvViewProj, _matInvViewProj); + out._cullingMask = this._cullingMask; + }; + _proto.screenPointToRay = function screenPointToRay(x, y, width, height, out) { + if (!cc.geomUtils) return out; + out = out || new _geomUtils.Ray(); + this._calcMatrices(width, height); + var cx = this._rect.x * width; + var cy = this._rect.y * height; + var cw = this._rect.w * width; + var ch = this._rect.h * height; + _valueTypes.Vec3.set(_tmp2_v3, (x - cx) / cw * 2 - 1, (y - cy) / ch * 2 - 1, 1); + _valueTypes.Vec3.transformMat4(_tmp2_v3, _tmp2_v3, _matInvViewProj); + if (this._projection === _enums["default"].PROJ_PERSPECTIVE) this._node.getWorldPosition(_tmp_v3); else { + _valueTypes.Vec3.set(_tmp_v3, (x - cx) / cw * 2 - 1, (y - cy) / ch * 2 - 1, -1); + _valueTypes.Vec3.transformMat4(_tmp_v3, _tmp_v3, _matInvViewProj); + } + return _geomUtils.Ray.fromPoints(out, _tmp_v3, _tmp2_v3); + }; + _proto.screenToWorld = function screenToWorld(out, screenPos, width, height) { + this._calcMatrices(width, height); + var cx = this._rect.x * width; + var cy = this._rect.y * height; + var cw = this._rect.w * width; + var ch = this._rect.h * height; + if (this._projection === _enums["default"].PROJ_PERSPECTIVE) { + _valueTypes.Vec3.set(out, (screenPos.x - cx) / cw * 2 - 1, (screenPos.y - cy) / ch * 2 - 1, .9999); + _valueTypes.Vec3.transformMat4(out, out, _matInvViewProj); + this._node.getWorldPosition(_tmp_v3); + _valueTypes.Vec3.lerp(out, _tmp_v3, out, (0, _valueTypes.lerp)(this._near / this._far, 1, screenPos.z)); + } else { + _valueTypes.Vec3.set(out, (screenPos.x - cx) / cw * 2 - 1, (screenPos.y - cy) / ch * 2 - 1, 2 * screenPos.z - 1); + _valueTypes.Vec3.transformMat4(out, out, _matInvViewProj); + } + return out; + }; + _proto.worldToScreen = function worldToScreen(out, worldPos, width, height) { + this._calcMatrices(width, height); + var cx = this._rect.x * width; + var cy = this._rect.y * height; + var cw = this._rect.w * width; + var ch = this._rect.h * height; + _valueTypes.Vec3.transformMat4(out, worldPos, _matViewProj); + out.x = cx + .5 * (out.x + 1) * cw; + out.y = cy + .5 * (out.y + 1) * ch; + out.z = .5 * out.z + .5; + return out; + }; + _proto.worldMatrixToScreen = function worldMatrixToScreen(out, worldMatrix, width, height) { + this._calcMatrices(width, height); + _valueTypes.Mat4.mul(out, _matViewProj, worldMatrix); + var halfWidth = width / 2; + var halfHeight = height / 2; + _valueTypes.Mat4.identity(_tmp_mat4); + _valueTypes.Mat4.transform(_tmp_mat4, _tmp_mat4, _valueTypes.Vec3.set(_tmp_v3, halfWidth, halfHeight, 0)); + _valueTypes.Mat4.scale(_tmp_mat4, _tmp_mat4, _valueTypes.Vec3.set(_tmp_v3, halfWidth, halfHeight, 1)); + _valueTypes.Mat4.mul(out, _tmp_mat4, out); + return out; + }; + _createClass(Camera, [ { + key: "cullingMask", + get: function get() { + return this._cullingMask; + }, + set: function set(mask) { + this._cullingMask = mask; + } + } ]); + return Camera; + })(); + exports["default"] = Camera; + module.exports = exports["default"]; + }), { + "../../core/geom-utils": 195, + "../../core/value-types": 340, + "../enums": 368 + } ], + 394: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _valueTypes = require("../../core/value-types"); + var _gfx = _interopRequireDefault(require("../gfx")); + var _enums = _interopRequireDefault(require("../enums")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + "value" in descriptor && (descriptor.writable = true); + Object.defineProperty(target, descriptor.key, descriptor); + } + } + function _createClass(Constructor, protoProps, staticProps) { + protoProps && _defineProperties(Constructor.prototype, protoProps); + staticProps && _defineProperties(Constructor, staticProps); + return Constructor; + } + var _forward = cc.v3(0, 0, -1); + var _m4_tmp = cc.mat4(); + var _m3_tmp = _valueTypes.Mat3.create(); + var _transformedLightDirection = cc.v3(0, 0, 0); + function _computeSpotLightViewProjMatrix(light, outView, outProj) { + light._node.getWorldRT(outView); + _valueTypes.Mat4.invert(outView, outView); + _valueTypes.Mat4.perspective(outProj, light._spotAngle * light._spotAngleScale, 1, light._shadowMinDepth, light._shadowMaxDepth); + } + function _computeDirectionalLightViewProjMatrix(light, outView, outProj) { + light._node.getWorldRT(outView); + _valueTypes.Mat4.invert(outView, outView); + var halfSize = light._shadowFrustumSize / 2; + _valueTypes.Mat4.ortho(outProj, -halfSize, halfSize, -halfSize, halfSize, light._shadowMinDepth, light._shadowMaxDepth); + } + function _computePointLightViewProjMatrix(light, outView, outProj) { + light._node.getWorldRT(outView); + _valueTypes.Mat4.invert(outView, outView); + _valueTypes.Mat4.perspective(outProj, (0, _valueTypes.toRadian)(179), 1, light._shadowMinDepth, light._shadowMaxDepth); + } + var Light = (function() { + function Light() { + this._poolID = -1; + this._node = null; + this._type = _enums["default"].LIGHT_DIRECTIONAL; + this._color = new _valueTypes.Vec3(1, 1, 1); + this._intensity = 1; + this._range = 1; + this._spotAngle = (0, _valueTypes.toRadian)(60); + this._spotExp = 1; + this._directionUniform = new Float32Array(3); + this._positionUniform = new Float32Array(3); + this._colorUniform = new Float32Array([ this._color.x * this._intensity, this._color.y * this._intensity, this._color.z * this._intensity ]); + this._spotUniform = new Float32Array([ Math.cos(.5 * this._spotAngle), this._spotExp ]); + this._shadowType = _enums["default"].SHADOW_NONE; + this._shadowFrameBuffer = null; + this._shadowMap = null; + this._shadowMapDirty = false; + this._shadowDepthBuffer = null; + this._shadowResolution = 1024; + this._shadowBias = 5e-4; + this._shadowDarkness = 1; + this._shadowMinDepth = 1; + this._shadowMaxDepth = 1e3; + this._frustumEdgeFalloff = 0; + this._viewProjMatrix = cc.mat4(); + this._spotAngleScale = 1; + this._shadowFrustumSize = 50; + } + var _proto = Light.prototype; + _proto.getNode = function getNode() { + return this._node; + }; + _proto.setNode = function setNode(node) { + this._node = node; + }; + _proto.setColor = function setColor(r, g, b) { + _valueTypes.Vec3.set(this._color, r, g, b); + this._colorUniform[0] = r * this._intensity; + this._colorUniform[1] = g * this._intensity; + this._colorUniform[2] = b * this._intensity; + }; + _proto.setIntensity = function setIntensity(val) { + this._intensity = val; + this._colorUniform[0] = val * this._color.x; + this._colorUniform[1] = val * this._color.y; + this._colorUniform[2] = val * this._color.z; + }; + _proto.setType = function setType(type) { + this._type = type; + }; + _proto.setSpotAngle = function setSpotAngle(val) { + this._spotAngle = val; + this._spotUniform[0] = Math.cos(.5 * this._spotAngle); + }; + _proto.setSpotExp = function setSpotExp(val) { + this._spotExp = val; + this._spotUniform[1] = val; + }; + _proto.setRange = function setRange(val) { + this._range = val; + }; + _proto.setShadowType = function setShadowType(type) { + this._shadowType === _enums["default"].SHADOW_NONE && type !== _enums["default"].SHADOW_NONE && (this._shadowMapDirty = true); + this._shadowType = type; + }; + _proto.setShadowResolution = function setShadowResolution(val) { + this._shadowResolution !== val && (this._shadowMapDirty = true); + this._shadowResolution = val; + }; + _proto.setShadowBias = function setShadowBias(val) { + this._shadowBias = val; + }; + _proto.setShadowDarkness = function setShadowDarkness(val) { + this._shadowDarkness = val; + }; + _proto.setShadowMinDepth = function setShadowMinDepth(val) { + this._shadowMinDepth = val; + }; + _proto.setShadowMaxDepth = function setShadowMaxDepth(val) { + this._shadowMaxDepth = val; + }; + _proto.setFrustumEdgeFalloff = function setFrustumEdgeFalloff(val) { + this._frustumEdgeFalloff = val; + }; + _proto.setShadowFrustumSize = function setShadowFrustumSize(val) { + this._shadowFrustumSize = val; + }; + _proto.extractView = function extractView(out, stages) { + out._shadowLight = this; + out._priority = -1; + out._rect.x = 0; + out._rect.y = 0; + out._rect.w = this._shadowResolution; + out._rect.h = this._shadowResolution; + _valueTypes.Vec3.set(out._color, 1, 1, 1); + out._depth = 1; + out._stencil = 1; + out._clearFlags = _enums["default"].CLEAR_COLOR | _enums["default"].CLEAR_DEPTH; + out._stages = stages; + out._framebuffer = this._shadowFrameBuffer; + switch (this._type) { + case _enums["default"].LIGHT_SPOT: + _computeSpotLightViewProjMatrix(this, out._matView, out._matProj); + break; + + case _enums["default"].LIGHT_DIRECTIONAL: + _computeDirectionalLightViewProjMatrix(this, out._matView, out._matProj); + break; + + case _enums["default"].LIGHT_POINT: + _computePointLightViewProjMatrix(this, out._matView, out._matProj); + break; + + case _enums["default"].LIGHT_AMBIENT: + break; + + default: + console.warn("shadow of this light type is not supported"); + } + _valueTypes.Mat4.mul(out._matViewProj, out._matProj, out._matView); + this._viewProjMatrix = out._matViewProj; + _valueTypes.Mat4.invert(out._matInvViewProj, out._matViewProj); + out._cullingMask = 4294967295; + }; + _proto._updateLightPositionAndDirection = function _updateLightPositionAndDirection() { + this._node.getWorldMatrix(_m4_tmp); + _valueTypes.Mat3.fromMat4(_m3_tmp, _m4_tmp); + _valueTypes.Vec3.transformMat3(_transformedLightDirection, _forward, _m3_tmp); + _valueTypes.Vec3.toArray(this._directionUniform, _transformedLightDirection); + var pos = this._positionUniform; + var m = _m4_tmp.m; + pos[0] = m[12]; + pos[1] = m[13]; + pos[2] = m[14]; + }; + _proto._generateShadowMap = function _generateShadowMap(device) { + this._shadowMap = new _gfx["default"].Texture2D(device, { + width: this._shadowResolution, + height: this._shadowResolution, + format: _gfx["default"].TEXTURE_FMT_RGBA8, + wrapS: _gfx["default"].WRAP_CLAMP, + wrapT: _gfx["default"].WRAP_CLAMP + }); + this._shadowDepthBuffer = new _gfx["default"].RenderBuffer(device, _gfx["default"].RB_FMT_D16, this._shadowResolution, this._shadowResolution); + this._shadowFrameBuffer = new _gfx["default"].FrameBuffer(device, this._shadowResolution, this._shadowResolution, { + colors: [ this._shadowMap ], + depth: this._shadowDepthBuffer + }); + }; + _proto._destroyShadowMap = function _destroyShadowMap() { + if (this._shadowMap) { + this._shadowMap.destroy(); + this._shadowDepthBuffer.destroy(); + this._shadowFrameBuffer.destroy(); + this._shadowMap = null; + this._shadowDepthBuffer = null; + this._shadowFrameBuffer = null; + } + }; + _proto.update = function update(device) { + this._updateLightPositionAndDirection(); + if (this._shadowType === _enums["default"].SHADOW_NONE) this._destroyShadowMap(); else if (this._shadowMapDirty) { + this._destroyShadowMap(); + this._generateShadowMap(device); + this._shadowMapDirty = false; + } + }; + _createClass(Light, [ { + key: "color", + get: function get() { + return this._color; + } + }, { + key: "intensity", + get: function get() { + return this._intensity; + } + }, { + key: "type", + get: function get() { + return this._type; + } + }, { + key: "spotAngle", + get: function get() { + return this._spotAngle; + } + }, { + key: "spotExp", + get: function get() { + return this._spotExp; + } + }, { + key: "range", + get: function get() { + return this._range; + } + }, { + key: "shadowType", + get: function get() { + return this._shadowType; + } + }, { + key: "shadowMap", + get: function get() { + return this._shadowMap; + } + }, { + key: "viewProjMatrix", + get: function get() { + return this._viewProjMatrix; + } + }, { + key: "shadowResolution", + get: function get() { + return this._shadowResolution; + } + }, { + key: "shadowBias", + get: function get() { + return this._shadowBias; + } + }, { + key: "shadowDarkness", + get: function get() { + return this._shadowDarkness; + } + }, { + key: "shadowMinDepth", + get: function get() { + if (this._type === _enums["default"].LIGHT_DIRECTIONAL) return 1; + return this._shadowMinDepth; + } + }, { + key: "shadowMaxDepth", + get: function get() { + if (this._type === _enums["default"].LIGHT_DIRECTIONAL) return 1; + return this._shadowMaxDepth; + } + }, { + key: "frustumEdgeFalloff", + get: function get() { + return this._frustumEdgeFalloff; + } + }, { + key: "shadowFrustumSize", + get: function get() { + return this._shadowFrustumSize; + } + } ]); + return Light; + })(); + exports["default"] = Light; + module.exports = exports["default"]; + }), { + "../../core/value-types": 340, + "../enums": 368, + "../gfx": 373 + } ], + 395: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var Model = (function() { + function Model() { + this._type = "default"; + this._poolID = -1; + this._node = null; + this._inputAssembler = null; + this._effect = null; + this._viewID = -1; + this._cameraID = -1; + this._userKey = -1; + this._castShadow = false; + this._boundingShape = null; + } + var _proto = Model.prototype; + _proto.setNode = function setNode(node) { + this._node = node; + }; + _proto.setInputAssembler = function setInputAssembler(ia) { + this._inputAssembler = ia; + }; + _proto.setEffect = function setEffect(effect) { + this._effect = effect; + }; + _proto.setUserKey = function setUserKey(key) { + this._userKey = key; + }; + _proto.extractDrawItem = function extractDrawItem(out) { + out.model = this; + out.node = this._node; + out.ia = this._inputAssembler; + out.effect = this._effect; + }; + return Model; + })(); + exports["default"] = Model; + module.exports = exports["default"]; + }), {} ], + 396: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _memop = require("../memop"); + var Scene = (function() { + function Scene(app) { + this._lights = new _memop.FixedArray(16); + this._models = new _memop.FixedArray(16); + this._cameras = new _memop.FixedArray(16); + this._debugCamera = null; + this._app = app; + this._views = []; + } + var _proto = Scene.prototype; + _proto._add = function _add(pool, item) { + if (-1 !== item._poolID) return; + pool.push(item); + item._poolID = pool.length - 1; + }; + _proto._remove = function _remove(pool, item) { + if (-1 === item._poolID) return; + pool.data[pool.length - 1]._poolID = item._poolID; + pool.fastRemove(item._poolID); + item._poolID = -1; + }; + _proto.reset = function reset() { + for (var i = 0; i < this._models.length; ++i) { + var model = this._models.data[i]; + model._viewID = -1; + } + }; + _proto.setDebugCamera = function setDebugCamera(cam) { + this._debugCamera = cam; + }; + _proto.getCameraCount = function getCameraCount() { + return this._cameras.length; + }; + _proto.getCamera = function getCamera(idx) { + return this._cameras.data[idx]; + }; + _proto.addCamera = function addCamera(camera) { + this._add(this._cameras, camera); + }; + _proto.removeCamera = function removeCamera(camera) { + this._remove(this._cameras, camera); + }; + _proto.getModelCount = function getModelCount() { + return this._models.length; + }; + _proto.getModel = function getModel(idx) { + return this._models.data[idx]; + }; + _proto.addModel = function addModel(model) { + this._add(this._models, model); + }; + _proto.removeModel = function removeModel(model) { + this._remove(this._models, model); + }; + _proto.getLightCount = function getLightCount() { + return this._lights.length; + }; + _proto.getLight = function getLight(idx) { + return this._lights.data[idx]; + }; + _proto.addLight = function addLight(light) { + this._add(this._lights, light); + }; + _proto.removeLight = function removeLight(light) { + this._remove(this._lights, light); + }; + _proto.addView = function addView(view) { + -1 === this._views.indexOf(view) && this._views.push(view); + }; + _proto.removeView = function removeView(view) { + var idx = this._views.indexOf(view); + -1 !== idx && this._views.splice(idx, 1); + }; + return Scene; + })(); + var _default = Scene; + exports["default"] = _default; + module.exports = exports["default"]; + }), { + "../memop": 385 + } ], + 397: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports.getClassName = exports.enums2default = exports.ctor2enums = void 0; + exports.getInspectorProps = getInspectorProps; + exports.getInstanceType = exports.getInstanceCtor = void 0; + var _enums = _interopRequireDefault(require("./enums")); + var _valueTypes = require("../core/value-types"); + var _CCTexture2D = _interopRequireDefault(require("../core/assets/CCTexture2D")); + var _ctor2default, _enums2ctor, _ctor2enums, _enums2default; + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + var gfxTexture2D = null, gfxTextureCube = null; + false; + gfxTexture2D = require("./gfx/texture-2d"); + var CCObject = cc.Object; + var ctor2default = (_ctor2default = {}, _ctor2default[Boolean] = function(v) { + return v || false; + }, _ctor2default[Number] = function(v) { + return v ? ArrayBuffer.isView(v) ? v[0] : v : 0; + }, _ctor2default[_valueTypes.Vec2] = function(v) { + return v ? cc.v2(v[0], v[1]) : cc.v2(); + }, _ctor2default[_valueTypes.Vec3] = function(v) { + return v ? cc.v3(v[0], v[1], v[2]) : cc.v3(); + }, _ctor2default[_valueTypes.Vec4] = function(v) { + return v ? cc.v4(v[0], v[1], v[2], v[3]) : cc.v4(); + }, _ctor2default[_valueTypes.Color] = function(v) { + return v ? cc.color(255 * v[0], 255 * v[1], 255 * v[2], 255 * (v[3] || 1)) : cc.color(); + }, _ctor2default[_valueTypes.Mat4] = function(v) { + return v ? cc.mat4(v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7], v[8], v[9], v[10], v[11], v[12], v[13], v[14], v[15]) : cc.mat4(); + }, _ctor2default[_CCTexture2D["default"]] = function() { + return null; + }, _ctor2default[CCObject] = function() { + return null; + }, _ctor2default); + var enums2ctor = (_enums2ctor = {}, _enums2ctor[_enums["default"].PARAM_INT] = Number, + _enums2ctor[_enums["default"].PARAM_INT2] = _valueTypes.Vec2, _enums2ctor[_enums["default"].PARAM_INT3] = _valueTypes.Vec3, + _enums2ctor[_enums["default"].PARAM_INT4] = _valueTypes.Vec4, _enums2ctor[_enums["default"].PARAM_FLOAT] = Number, + _enums2ctor[_enums["default"].PARAM_FLOAT2] = _valueTypes.Vec2, _enums2ctor[_enums["default"].PARAM_FLOAT3] = _valueTypes.Vec3, + _enums2ctor[_enums["default"].PARAM_FLOAT4] = _valueTypes.Vec4, _enums2ctor[_enums["default"].PARAM_MAT4] = _valueTypes.Mat4, + _enums2ctor[_enums["default"].PARAM_TEXTURE_2D] = _CCTexture2D["default"], _enums2ctor.color = _valueTypes.Color, + _enums2ctor.number = Number, _enums2ctor["boolean"] = Boolean, _enums2ctor["default"] = CCObject, + _enums2ctor); + var ctor2enums = (_ctor2enums = {}, _ctor2enums[Number] = _enums["default"].PARAM_FLOAT, + _ctor2enums[_valueTypes.Vec2] = _enums["default"].PARAM_FLOAT2, _ctor2enums[_valueTypes.Vec3] = _enums["default"].PARAM_FLOAT3, + _ctor2enums[_valueTypes.Vec4] = _enums["default"].PARAM_FLOAT4, _ctor2enums[_valueTypes.Color] = _enums["default"].PARAM_COLOR3, + _ctor2enums[_valueTypes.Color] = _enums["default"].PARAM_COLOR4, _ctor2enums[_valueTypes.Mat4] = _enums["default"].PARAM_MAT4, + _ctor2enums[_CCTexture2D["default"]] = _enums["default"].PARAM_TEXTURE_2D, _ctor2enums[gfxTexture2D] = _enums["default"].PARAM_TEXTURE_2D, + _ctor2enums); + exports.ctor2enums = ctor2enums; + var enums2default = (_enums2default = {}, _enums2default[_enums["default"].PARAM_INT] = new Uint32Array([ 0 ]), + _enums2default[_enums["default"].PARAM_INT2] = new Uint32Array([ 0, 0 ]), _enums2default[_enums["default"].PARAM_INT3] = new Uint32Array([ 0, 0, 0 ]), + _enums2default[_enums["default"].PARAM_INT4] = new Uint32Array([ 0, 0, 0, 0 ]), + _enums2default[_enums["default"].PARAM_FLOAT] = new Float32Array([ 0 ]), _enums2default[_enums["default"].PARAM_FLOAT2] = new Float32Array([ 0, 0 ]), + _enums2default[_enums["default"].PARAM_FLOAT3] = new Float32Array([ 0, 0, 0 ]), + _enums2default[_enums["default"].PARAM_FLOAT4] = new Float32Array([ 0, 0, 0, 0 ]), + _enums2default[_enums["default"].PARAM_MAT4] = new Float32Array([ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]), + _enums2default[_enums["default"].PARAM_TEXTURE_2D] = null, _enums2default.number = 0, + _enums2default["boolean"] = false, _enums2default); + exports.enums2default = enums2default; + var getInstanceType = function getInstanceType(t) { + return enums2ctor[t] || enums2ctor["default"]; + }; + exports.getInstanceType = getInstanceType; + var getInstanceCtor = function getInstanceCtor(t) { + return ctor2default[getInstanceType(t)]; + }; + exports.getInstanceCtor = getInstanceCtor; + var getClassName = function getClassName(t) { + return cc.js.getClassName(getInstanceType(t)); + }; + exports.getClassName = getClassName; + var className2InspectorName = { + Number: "number", + Boolean: "boolean" + }; + function getInspectorProps(prop) { + var editor = { + type: prop.type + }; + Object.assign(editor, prop.editor || prop.inspector); + editor.defines = prop.defines; + editor.value = getInstanceCtor(editor.type)(prop.value); + prop.range && (editor.range = prop.range); + var className = getClassName(editor.type); + editor.typeName = className2InspectorName[className] || className; + editor.valueCtor = enums2ctor[editor.type]; + if ("cc.Texture2D" == editor.typeName) { + editor.typeName = "cc.Asset"; + editor.assetType = "cc.Texture2D"; + } + return editor; + } + }), { + "../core/assets/CCTexture2D": 121, + "../core/value-types": 340, + "./enums": 368, + "./gfx/texture-2d": 378 + } ], + 398: [ (function(require, module, exports) { + "use strict"; + var codec = require("../compression/ZipUtils"); + var zlib = require("../compression/zlib.min"); + var js = require("../core/platform/js"); + require("../core/platform/CCSAXParser"); + function uint8ArrayToUint32Array(uint8Arr) { + if (uint8Arr.length % 4 !== 0) return null; + var arrLen = uint8Arr.length / 4; + var retArr = window.Uint32Array ? new Uint32Array(arrLen) : []; + for (var i = 0; i < arrLen; i++) { + var offset = 4 * i; + retArr[i] = uint8Arr[offset] + 256 * uint8Arr[offset + 1] + 65536 * uint8Arr[offset + 2] + uint8Arr[offset + 3] * (1 << 24); + } + return retArr; + } + cc.TMXLayerInfo = function() { + this.properties = {}; + this.name = ""; + this._layerSize = null; + this._tiles = []; + this.visible = true; + this._opacity = 0; + this.ownTiles = true; + this._minGID = 1e5; + this._maxGID = 0; + this.offset = cc.v2(0, 0); + }; + cc.TMXLayerInfo.prototype = { + constructor: cc.TMXLayerInfo, + getProperties: function getProperties() { + return this.properties; + }, + setProperties: function setProperties(value) { + this.properties = value; + } + }; + cc.TMXImageLayerInfo = function() { + this.name = ""; + this.visible = true; + this.width = 0; + this.height = 0; + this.offset = cc.v2(0, 0); + this._opacity = 0; + this._trans = new cc.Color(255, 255, 255, 255); + this.sourceImage = null; + }; + cc.TMXObjectGroupInfo = function() { + this.properties = {}; + this.name = ""; + this._objects = []; + this.visible = true; + this._opacity = 0; + this._color = new cc.Color(255, 255, 255, 255); + this.offset = cc.v2(0, 0); + this._draworder = "topdown"; + }; + cc.TMXObjectGroupInfo.prototype = { + constructor: cc.TMXObjectGroupInfo, + getProperties: function getProperties() { + return this.properties; + }, + setProperties: function setProperties(value) { + this.properties = value; + } + }; + cc.TMXTilesetInfo = function() { + this.name = ""; + this.firstGid = 0; + this.spacing = 0; + this.margin = 0; + this.sourceImage = null; + this.imageSize = cc.size(0, 0); + this.tileOffset = cc.v2(0, 0); + this._tileSize = cc.size(0, 0); + }; + cc.TMXTilesetInfo.prototype = { + constructor: cc.TMXTilesetInfo, + rectForGID: function rectForGID(gid, result) { + var rect = result || cc.rect(0, 0, 0, 0); + rect.width = this._tileSize.width; + rect.height = this._tileSize.height; + gid &= cc.TiledMap.TileFlag.FLIPPED_MASK; + gid -= parseInt(this.firstGid, 10); + var max_x = parseInt((this.imageSize.width - 2 * this.margin + this.spacing) / (this._tileSize.width + this.spacing), 10); + rect.x = parseInt(gid % max_x * (this._tileSize.width + this.spacing) + this.margin, 10); + rect.y = parseInt(parseInt(gid / max_x, 10) * (this._tileSize.height + this.spacing) + this.margin, 10); + return rect; + } + }; + function strToHAlign(value) { + var hAlign = cc.Label.HorizontalAlign; + switch (value) { + case "center": + return hAlign.CENTER; + + case "right": + return hAlign.RIGHT; + + default: + return hAlign.LEFT; + } + } + function strToVAlign(value) { + var vAlign = cc.Label.VerticalAlign; + switch (value) { + case "center": + return vAlign.CENTER; + + case "bottom": + return vAlign.BOTTOM; + + default: + return vAlign.TOP; + } + } + function strToColor(value) { + if (!value) return cc.color(0, 0, 0, 255); + value = -1 !== value.indexOf("#") ? value.substring(1) : value; + if (8 === value.length) { + var a = parseInt(value.substr(0, 2), 16) || 255; + var r = parseInt(value.substr(2, 2), 16) || 0; + var g = parseInt(value.substr(4, 2), 16) || 0; + var b = parseInt(value.substr(6, 2), 16) || 0; + return cc.color(r, g, b, a); + } + var _r = parseInt(value.substr(0, 2), 16) || 0; + var _g = parseInt(value.substr(2, 2), 16) || 0; + var _b = parseInt(value.substr(4, 2), 16) || 0; + return cc.color(_r, _g, _b, 255); + } + function getPropertyList(node, map) { + var res = []; + var properties = node.getElementsByTagName("properties"); + for (var i = 0; i < properties.length; ++i) { + var property = properties[i].getElementsByTagName("property"); + for (var j = 0; j < property.length; ++j) res.push(property[j]); + } + map = map || {}; + for (var _i = 0; _i < res.length; _i++) { + var element = res[_i]; + var name = element.getAttribute("name"); + var type = element.getAttribute("type") || "string"; + var value = element.getAttribute("value"); + "int" === type ? value = parseInt(value) : "float" === type ? value = parseFloat(value) : "bool" === type ? value = "true" === value : "color" === type && (value = strToColor(value)); + map[name] = value; + } + return map; + } + cc.TMXMapInfo = function(tmxFile, tsxMap, textures, textureSizes, imageLayerTextures) { + this.properties = []; + this.orientation = null; + this.parentElement = null; + this.parentGID = null; + this.layerAttrs = 0; + this.storingCharacters = false; + this.currentString = null; + this.renderOrder = cc.TiledMap.RenderOrder.RightDown; + this._supportVersion = [ 1, 2, 0 ]; + this._parser = new cc.SAXParser(); + this._objectGroups = []; + this._allChildren = []; + this._mapSize = cc.size(0, 0); + this._tileSize = cc.size(0, 0); + this._layers = []; + this._tilesets = []; + this._imageLayers = []; + this._tileProperties = {}; + this._tileAnimations = {}; + this._tsxMap = null; + this._textures = null; + this._staggerAxis = null; + this._staggerIndex = null; + this._hexSideLength = 0; + this._imageLayerTextures = null; + this.initWithXML(tmxFile, tsxMap, textures, textureSizes, imageLayerTextures); + }; + cc.TMXMapInfo.prototype = { + constructor: cc.TMXMapInfo, + getOrientation: function getOrientation() { + return this.orientation; + }, + setOrientation: function setOrientation(value) { + this.orientation = value; + }, + getStaggerAxis: function getStaggerAxis() { + return this._staggerAxis; + }, + setStaggerAxis: function setStaggerAxis(value) { + this._staggerAxis = value; + }, + getStaggerIndex: function getStaggerIndex() { + return this._staggerIndex; + }, + setStaggerIndex: function setStaggerIndex(value) { + this._staggerIndex = value; + }, + getHexSideLength: function getHexSideLength() { + return this._hexSideLength; + }, + setHexSideLength: function setHexSideLength(value) { + this._hexSideLength = value; + }, + getMapSize: function getMapSize() { + return cc.size(this._mapSize.width, this._mapSize.height); + }, + setMapSize: function setMapSize(value) { + this._mapSize.width = value.width; + this._mapSize.height = value.height; + }, + _getMapWidth: function _getMapWidth() { + return this._mapSize.width; + }, + _setMapWidth: function _setMapWidth(width) { + this._mapSize.width = width; + }, + _getMapHeight: function _getMapHeight() { + return this._mapSize.height; + }, + _setMapHeight: function _setMapHeight(height) { + this._mapSize.height = height; + }, + getTileSize: function getTileSize() { + return cc.size(this._tileSize.width, this._tileSize.height); + }, + setTileSize: function setTileSize(value) { + this._tileSize.width = value.width; + this._tileSize.height = value.height; + }, + _getTileWidth: function _getTileWidth() { + return this._tileSize.width; + }, + _setTileWidth: function _setTileWidth(width) { + this._tileSize.width = width; + }, + _getTileHeight: function _getTileHeight() { + return this._tileSize.height; + }, + _setTileHeight: function _setTileHeight(height) { + this._tileSize.height = height; + }, + getLayers: function getLayers() { + return this._layers; + }, + setLayers: function setLayers(value) { + this._allChildren.push(value); + this._layers.push(value); + }, + getImageLayers: function getImageLayers() { + return this._imageLayers; + }, + setImageLayers: function setImageLayers(value) { + this._allChildren.push(value); + this._imageLayers.push(value); + }, + getTilesets: function getTilesets() { + return this._tilesets; + }, + setTilesets: function setTilesets(value) { + this._tilesets.push(value); + }, + getObjectGroups: function getObjectGroups() { + return this._objectGroups; + }, + setObjectGroups: function setObjectGroups(value) { + this._allChildren.push(value); + this._objectGroups.push(value); + }, + getAllChildren: function getAllChildren() { + return this._allChildren; + }, + getParentElement: function getParentElement() { + return this.parentElement; + }, + setParentElement: function setParentElement(value) { + this.parentElement = value; + }, + getParentGID: function getParentGID() { + return this.parentGID; + }, + setParentGID: function setParentGID(value) { + this.parentGID = value; + }, + getLayerAttribs: function getLayerAttribs() { + return this.layerAttrs; + }, + setLayerAttribs: function setLayerAttribs(value) { + this.layerAttrs = value; + }, + getStoringCharacters: function getStoringCharacters() { + return this.storingCharacters; + }, + setStoringCharacters: function setStoringCharacters(value) { + this.storingCharacters = value; + }, + getProperties: function getProperties() { + return this.properties; + }, + setProperties: function setProperties(value) { + this.properties = value; + }, + initWithXML: function initWithXML(tmxString, tsxMap, textures, textureSizes, imageLayerTextures) { + this._tilesets.length = 0; + this._layers.length = 0; + this._imageLayers.length = 0; + this._tsxMap = tsxMap; + this._textures = textures; + this._imageLayerTextures = imageLayerTextures; + this._textureSizes = textureSizes; + this._objectGroups.length = 0; + this._allChildren.length = 0; + this.properties.length = 0; + this._tileProperties = {}; + this._tileAnimations = {}; + this.currentString = ""; + this.storingCharacters = false; + this.layerAttrs = cc.TMXLayerInfo.ATTRIB_NONE; + this.parentElement = cc.TiledMap.NONE; + return this.parseXMLString(tmxString); + }, + parseXMLString: function parseXMLString(xmlStr, tilesetFirstGid) { + var mapXML = this._parser._parseXML(xmlStr); + var i; + var map = mapXML.documentElement; + var orientationStr = map.getAttribute("orientation"); + var staggerAxisStr = map.getAttribute("staggeraxis"); + var staggerIndexStr = map.getAttribute("staggerindex"); + var hexSideLengthStr = map.getAttribute("hexsidelength"); + var renderorderStr = map.getAttribute("renderorder"); + var version = map.getAttribute("version") || "1.0.0"; + if ("map" === map.nodeName) { + var versionArr = version.split("."); + var supportVersion = this._supportVersion; + for (var _i2 = 0; _i2 < supportVersion.length; _i2++) { + var v = parseInt(versionArr[_i2]) || 0; + var sv = supportVersion[_i2]; + if (sv < v) { + cc.logID(7216, version); + break; + } + } + "orthogonal" === orientationStr ? this.orientation = cc.TiledMap.Orientation.ORTHO : "isometric" === orientationStr ? this.orientation = cc.TiledMap.Orientation.ISO : "hexagonal" === orientationStr ? this.orientation = cc.TiledMap.Orientation.HEX : null !== orientationStr && cc.logID(7217, orientationStr); + this.renderOrder = "right-up" === renderorderStr ? cc.TiledMap.RenderOrder.RightUp : "left-up" === renderorderStr ? cc.TiledMap.RenderOrder.LeftUp : "left-down" === renderorderStr ? cc.TiledMap.RenderOrder.LeftDown : cc.TiledMap.RenderOrder.RightDown; + "x" === staggerAxisStr ? this.setStaggerAxis(cc.TiledMap.StaggerAxis.STAGGERAXIS_X) : "y" === staggerAxisStr && this.setStaggerAxis(cc.TiledMap.StaggerAxis.STAGGERAXIS_Y); + "odd" === staggerIndexStr ? this.setStaggerIndex(cc.TiledMap.StaggerIndex.STAGGERINDEX_ODD) : "even" === staggerIndexStr && this.setStaggerIndex(cc.TiledMap.StaggerIndex.STAGGERINDEX_EVEN); + hexSideLengthStr && this.setHexSideLength(parseFloat(hexSideLengthStr)); + var mapSize = cc.size(0, 0); + mapSize.width = parseFloat(map.getAttribute("width")); + mapSize.height = parseFloat(map.getAttribute("height")); + this.setMapSize(mapSize); + mapSize = cc.size(0, 0); + mapSize.width = parseFloat(map.getAttribute("tilewidth")); + mapSize.height = parseFloat(map.getAttribute("tileheight")); + this.setTileSize(mapSize); + this.properties = getPropertyList(map); + } + var tilesets = map.getElementsByTagName("tileset"); + if ("map" !== map.nodeName) { + tilesets = []; + tilesets.push(map); + } + for (i = 0; i < tilesets.length; i++) { + var selTileset = tilesets[i]; + var tsxName = selTileset.getAttribute("source"); + if (tsxName) { + var currentFirstGID = parseInt(selTileset.getAttribute("firstgid")); + var tsxXmlString = this._tsxMap[tsxName]; + tsxXmlString && this.parseXMLString(tsxXmlString, currentFirstGID); + } else { + var images = selTileset.getElementsByTagName("image"); + var multiTextures = images.length > 1; + var image = images[0]; + var firstImageName = image.getAttribute("source"); + firstImageName = firstImageName.replace(/\\/g, "/"); + var tiles = selTileset.getElementsByTagName("tile"); + var tileCount = tiles && tiles.length || 1; + var tile = null; + var tilesetName = selTileset.getAttribute("name") || ""; + var tilesetSpacing = parseInt(selTileset.getAttribute("spacing")) || 0; + var tilesetMargin = parseInt(selTileset.getAttribute("margin")) || 0; + var fgid = parseInt(tilesetFirstGid); + fgid || (fgid = parseInt(selTileset.getAttribute("firstgid")) || 0); + var tilesetSize = cc.size(0, 0); + tilesetSize.width = parseFloat(selTileset.getAttribute("tilewidth")); + tilesetSize.height = parseFloat(selTileset.getAttribute("tileheight")); + var offset = selTileset.getElementsByTagName("tileoffset")[0]; + var tileOffset = cc.v2(0, 0); + if (offset) { + tileOffset.x = parseFloat(offset.getAttribute("x")); + tileOffset.y = parseFloat(offset.getAttribute("y")); + } + var tileset = null; + for (var tileIdx = 0; tileIdx < tileCount; tileIdx++) { + if (!tileset || multiTextures) { + tileset = new cc.TMXTilesetInfo(); + tileset.name = tilesetName; + tileset.firstGid = fgid; + tileset.spacing = tilesetSpacing; + tileset.margin = tilesetMargin; + tileset._tileSize = tilesetSize; + tileset.tileOffset = tileOffset; + tileset.sourceImage = this._textures[firstImageName]; + tileset.imageSize = this._textureSizes[firstImageName] || tileset.imageSize; + tileset.sourceImage || cc.errorID(7221, firstImageName); + this.setTilesets(tileset); + } + tile = tiles && tiles[tileIdx]; + if (!tile) continue; + this.parentGID = parseInt(fgid) + parseInt(tile.getAttribute("id") || 0); + var tileImages = tile.getElementsByTagName("image"); + if (tileImages && tileImages.length > 0) { + image = tileImages[0]; + var imageName = image.getAttribute("source"); + imageName = imageName.replace(/\\/g, "/"); + tileset.sourceImage = this._textures[imageName]; + tileset.sourceImage || cc.errorID(7221, imageName); + var tileSize = cc.size(0, 0); + tileSize.width = parseFloat(image.getAttribute("width")); + tileSize.height = parseFloat(image.getAttribute("height")); + tileset._tileSize = tileSize; + tileset.firstGid = this.parentGID; + } + this._tileProperties[this.parentGID] = getPropertyList(tile); + var animations = tile.getElementsByTagName("animation"); + if (animations && animations.length > 0) { + var animation = animations[0]; + var framesData = animation.getElementsByTagName("frame"); + var animationProp = { + frames: [], + dt: 0, + frameIdx: 0 + }; + this._tileAnimations[this.parentGID] = animationProp; + var frames = animationProp.frames; + for (var frameIdx = 0; frameIdx < framesData.length; frameIdx++) { + var frame = framesData[frameIdx]; + var tileid = parseInt(fgid) + parseInt(frame.getAttribute("tileid")); + var duration = parseFloat(frame.getAttribute("duration")); + frames.push({ + tileid: tileid, + duration: duration / 1e3, + grid: null + }); + } + } + } + } + } + var childNodes = map.childNodes; + for (i = 0; i < childNodes.length; i++) { + var childNode = childNodes[i]; + if (this._shouldIgnoreNode(childNode)) continue; + if ("imagelayer" === childNode.nodeName) { + var imageLayer = this._parseImageLayer(childNode); + imageLayer && this.setImageLayers(imageLayer); + } + if ("layer" === childNode.nodeName) { + var layer = this._parseLayer(childNode); + this.setLayers(layer); + } + if ("objectgroup" === childNode.nodeName) { + var objectGroup = this._parseObjectGroup(childNode); + this.setObjectGroups(objectGroup); + } + } + return map; + }, + _shouldIgnoreNode: function _shouldIgnoreNode(node) { + return 3 === node.nodeType || 8 === node.nodeType || 4 === node.nodeType; + }, + _parseImageLayer: function _parseImageLayer(selLayer) { + var datas = selLayer.getElementsByTagName("image"); + if (!datas || 0 == datas.length) return null; + var imageLayer = new cc.TMXImageLayerInfo(); + imageLayer.name = selLayer.getAttribute("name"); + imageLayer.offset.x = parseFloat(selLayer.getAttribute("offsetx")) || 0; + imageLayer.offset.y = parseFloat(selLayer.getAttribute("offsety")) || 0; + var visible = selLayer.getAttribute("visible"); + imageLayer.visible = !("0" === visible); + var opacity = selLayer.getAttribute("opacity") || 1; + imageLayer.opacity = parseInt(255 * parseFloat(opacity)) || 255; + var data = datas[0]; + var source = data.getAttribute("source"); + imageLayer.sourceImage = this._imageLayerTextures[source]; + imageLayer.width = parseInt(data.getAttribute("width")) || 0; + imageLayer.height = parseInt(data.getAttribute("height")) || 0; + imageLayer.trans = strToColor(data.getAttribute("trans")); + if (!imageLayer.sourceImage) { + cc.errorID(7221, source); + return null; + } + return imageLayer; + }, + _parseLayer: function _parseLayer(selLayer) { + var data = selLayer.getElementsByTagName("data")[0]; + var layer = new cc.TMXLayerInfo(); + layer.name = selLayer.getAttribute("name"); + var layerSize = cc.size(0, 0); + layerSize.width = parseFloat(selLayer.getAttribute("width")); + layerSize.height = parseFloat(selLayer.getAttribute("height")); + layer._layerSize = layerSize; + var visible = selLayer.getAttribute("visible"); + layer.visible = !("0" === visible); + var opacity = selLayer.getAttribute("opacity") || 1; + layer._opacity = opacity ? parseInt(255 * parseFloat(opacity)) : 255; + layer.offset = cc.v2(parseFloat(selLayer.getAttribute("offsetx")) || 0, parseFloat(selLayer.getAttribute("offsety")) || 0); + var nodeValue = ""; + for (var j = 0; j < data.childNodes.length; j++) nodeValue += data.childNodes[j].nodeValue; + nodeValue = nodeValue.trim(); + var compression = data.getAttribute("compression"); + var encoding = data.getAttribute("encoding"); + if (compression && "gzip" !== compression && "zlib" !== compression) { + cc.logID(7218); + return null; + } + var tiles; + switch (compression) { + case "gzip": + tiles = codec.unzipBase64AsArray(nodeValue, 4); + break; + + case "zlib": + var inflator = new zlib.Inflate(codec.Base64.decodeAsArray(nodeValue, 1)); + tiles = uint8ArrayToUint32Array(inflator.decompress()); + break; + + case null: + case "": + if ("base64" === encoding) tiles = codec.Base64.decodeAsArray(nodeValue, 4); else if ("csv" === encoding) { + tiles = []; + var csvTiles = nodeValue.split(","); + for (var csvIdx = 0; csvIdx < csvTiles.length; csvIdx++) tiles.push(parseInt(csvTiles[csvIdx])); + } else { + var selDataTiles = data.getElementsByTagName("tile"); + tiles = []; + for (var xmlIdx = 0; xmlIdx < selDataTiles.length; xmlIdx++) tiles.push(parseInt(selDataTiles[xmlIdx].getAttribute("gid"))); + } + break; + + default: + this.layerAttrs === cc.TMXLayerInfo.ATTRIB_NONE && cc.logID(7219); + } + tiles && (layer._tiles = new Uint32Array(tiles)); + layer.properties = getPropertyList(selLayer); + return layer; + }, + _parseObjectGroup: function _parseObjectGroup(selGroup) { + var objectGroup = new cc.TMXObjectGroupInfo(); + objectGroup.name = selGroup.getAttribute("name") || ""; + objectGroup.offset = cc.v2(parseFloat(selGroup.getAttribute("offsetx")), parseFloat(selGroup.getAttribute("offsety"))); + var opacity = selGroup.getAttribute("opacity") || 1; + objectGroup._opacity = opacity ? parseInt(255 * parseFloat(opacity)) : 255; + var visible = selGroup.getAttribute("visible"); + visible && 0 === parseInt(visible) && (objectGroup.visible = false); + var color = selGroup.getAttribute("color"); + color && objectGroup._color.fromHEX(color); + var draworder = selGroup.getAttribute("draworder"); + draworder && (objectGroup._draworder = draworder); + objectGroup.setProperties(getPropertyList(selGroup)); + var objects = selGroup.getElementsByTagName("object"); + if (objects) { + for (var j = 0; j < objects.length; j++) { + var selObj = objects[j]; + var objectProp = {}; + objectProp["id"] = selObj.getAttribute("id") || j; + objectProp["name"] = selObj.getAttribute("name") || ""; + objectProp["width"] = parseFloat(selObj.getAttribute("width")) || 0; + objectProp["height"] = parseFloat(selObj.getAttribute("height")) || 0; + objectProp["x"] = parseFloat(selObj.getAttribute("x")) || 0; + objectProp["y"] = parseFloat(selObj.getAttribute("y")) || 0; + objectProp["rotation"] = parseFloat(selObj.getAttribute("rotation")) || 0; + getPropertyList(selObj, objectProp); + var visibleAttr = selObj.getAttribute("visible"); + objectProp["visible"] = !(visibleAttr && 0 === parseInt(visibleAttr)); + var texts = selObj.getElementsByTagName("text"); + if (texts && texts.length > 0) { + var text = texts[0]; + objectProp["type"] = cc.TiledMap.TMXObjectType.TEXT; + objectProp["wrap"] = "1" == text.getAttribute("wrap"); + objectProp["color"] = strToColor(text.getAttribute("color")); + objectProp["halign"] = strToHAlign(text.getAttribute("halign")); + objectProp["valign"] = strToVAlign(text.getAttribute("valign")); + objectProp["pixelsize"] = parseInt(text.getAttribute("pixelsize")) || 16; + objectProp["text"] = text.childNodes[0].nodeValue; + } + var gid = selObj.getAttribute("gid"); + if (gid) { + objectProp["gid"] = parseInt(gid); + objectProp["type"] = cc.TiledMap.TMXObjectType.IMAGE; + } + var ellipse = selObj.getElementsByTagName("ellipse"); + ellipse && ellipse.length > 0 && (objectProp["type"] = cc.TiledMap.TMXObjectType.ELLIPSE); + var polygonProps = selObj.getElementsByTagName("polygon"); + if (polygonProps && polygonProps.length > 0) { + objectProp["type"] = cc.TiledMap.TMXObjectType.POLYGON; + var selPgPointStr = polygonProps[0].getAttribute("points"); + selPgPointStr && (objectProp["points"] = this._parsePointsString(selPgPointStr)); + } + var polylineProps = selObj.getElementsByTagName("polyline"); + if (polylineProps && polylineProps.length > 0) { + objectProp["type"] = cc.TiledMap.TMXObjectType.POLYLINE; + var selPlPointStr = polylineProps[0].getAttribute("points"); + selPlPointStr && (objectProp["polylinePoints"] = this._parsePointsString(selPlPointStr)); + } + objectProp["type"] || (objectProp["type"] = cc.TiledMap.TMXObjectType.RECT); + objectGroup._objects.push(objectProp); + } + "index" !== draworder && objectGroup._objects.sort((function(a, b) { + return a.y - b.y; + })); + } + return objectGroup; + }, + _parsePointsString: function _parsePointsString(pointsString) { + if (!pointsString) return null; + var points = []; + var pointsStr = pointsString.split(" "); + for (var i = 0; i < pointsStr.length; i++) { + var selPointStr = pointsStr[i].split(","); + points.push({ + x: parseFloat(selPointStr[0]), + y: parseFloat(selPointStr[1]) + }); + } + return points; + }, + setTileAnimations: function setTileAnimations(animations) { + this._tileAnimations = animations; + }, + getTileAnimations: function getTileAnimations() { + return this._tileAnimations; + }, + getTileProperties: function getTileProperties() { + return this._tileProperties; + }, + setTileProperties: function setTileProperties(tileProperties) { + this._tileProperties = tileProperties; + }, + getCurrentString: function getCurrentString() { + return this.currentString; + }, + setCurrentString: function setCurrentString(currentString) { + this.currentString = currentString; + } + }; + var _p = cc.TMXMapInfo.prototype; + js.getset(_p, "mapWidth", _p._getMapWidth, _p._setMapWidth); + js.getset(_p, "mapHeight", _p._getMapHeight, _p._setMapHeight); + js.getset(_p, "tileWidth", _p._getTileWidth, _p._setTileWidth); + js.getset(_p, "tileHeight", _p._getTileHeight, _p._setTileHeight); + cc.TMXLayerInfo.ATTRIB_NONE = 1; + cc.TMXLayerInfo.ATTRIB_BASE64 = 2; + cc.TMXLayerInfo.ATTRIB_GZIP = 4; + cc.TMXLayerInfo.ATTRIB_ZLIB = 8; + }), { + "../compression/ZipUtils": 23, + "../compression/zlib.min": 26, + "../core/platform/CCSAXParser": 247, + "../core/platform/js": 261 + } ], + 399: [ (function(require, module, exports) { + "use strict"; + var _valueTypes = require("../core/value-types"); + var _materialVariant = _interopRequireDefault(require("../core/assets/material/material-variant")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + var RenderComponent = require("../core/components/CCRenderComponent"); + var Material = require("../core/assets/material/CCMaterial"); + var RenderFlow = require("../core/renderer/render-flow"); + var _mat4_temp = cc.mat4(); + var _vec2_temp = cc.v2(); + var _vec2_temp2 = cc.v2(); + var _vec2_temp3 = cc.v2(); + var _tempRowCol = { + row: 0, + col: 0 + }; + var TiledUserNodeData = cc.Class({ + name: "cc.TiledUserNodeData", + extends: cc.Component, + ctor: function ctor() { + this._index = -1; + this._row = -1; + this._col = -1; + this._tiledLayer = null; + } + }); + var TiledLayer = cc.Class({ + name: "cc.TiledLayer", + extends: RenderComponent, + editor: { + inspector: "packages://inspector/inspectors/comps/tiled-layer.js" + }, + ctor: function ctor() { + this._userNodeGrid = {}; + this._userNodeMap = {}; + this._userNodeDirty = false; + this._tiledTiles = []; + this._tilesetIndexArr = []; + this._tilesetIndexToArrIndex = {}; + this._texIdToMatIndex = {}; + this._viewPort = { + x: -1, + y: -1, + width: -1, + height: -1 + }; + this._cullingRect = { + leftDown: { + row: -1, + col: -1 + }, + rightTop: { + row: -1, + col: -1 + } + }; + this._cullingDirty = true; + this._rightTop = { + row: -1, + col: -1 + }; + this._layerInfo = null; + this._mapInfo = null; + this._topOffset = 0; + this._downOffset = 0; + this._leftOffset = 0; + this._rightOffset = 0; + this._tiles = []; + this._vertices = []; + this._verticesDirty = true; + this._layerName = ""; + this._layerOrientation = null; + this._texGrids = null; + this._textures = null; + this._tilesets = null; + this._leftDownToCenterX = 0; + this._leftDownToCenterY = 0; + this._hasTiledNodeGrid = false; + this._hasAniGrid = false; + this._animations = null; + this._enableCulling = cc.macro.ENABLE_TILEDMAP_CULLING; + }, + _hasTiledNode: function _hasTiledNode() { + return this._hasTiledNodeGrid; + }, + _hasAnimation: function _hasAnimation() { + return this._hasAniGrid; + }, + enableCulling: function enableCulling(value) { + if (this._enableCulling != value) { + this._enableCulling = value; + this._cullingDirty = true; + } + }, + addUserNode: function addUserNode(node) { + var dataComp = node.getComponent(TiledUserNodeData); + if (dataComp) { + cc.warn("CCTiledLayer:addUserNode node has been added"); + return false; + } + dataComp = node.addComponent(TiledUserNodeData); + node.parent = this.node; + node._renderFlag |= RenderFlow.FLAG_BREAK_FLOW; + this._userNodeMap[node._id] = dataComp; + dataComp._row = -1; + dataComp._col = -1; + dataComp._tiledLayer = this; + this._nodeLocalPosToLayerPos(node, _vec2_temp); + this._positionToRowCol(_vec2_temp.x, _vec2_temp.y, _tempRowCol); + this._addUserNodeToGrid(dataComp, _tempRowCol); + this._updateCullingOffsetByUserNode(node); + node.on(cc.Node.EventType.POSITION_CHANGED, this._userNodePosChange, dataComp); + node.on(cc.Node.EventType.SIZE_CHANGED, this._userNodeSizeChange, dataComp); + return true; + }, + removeUserNode: function removeUserNode(node) { + var dataComp = node.getComponent(TiledUserNodeData); + if (!dataComp) { + cc.warn("CCTiledLayer:removeUserNode node is not exist"); + return false; + } + node.off(cc.Node.EventType.POSITION_CHANGED, this._userNodePosChange, dataComp); + node.off(cc.Node.EventType.SIZE_CHANGED, this._userNodeSizeChange, dataComp); + this._removeUserNodeFromGrid(dataComp); + delete this._userNodeMap[node._id]; + node._removeComponent(dataComp); + dataComp.destroy(); + node.removeFromParent(true); + node._renderFlag &= ~RenderFlow.FLAG_BREAK_FLOW; + return true; + }, + destroyUserNode: function destroyUserNode(node) { + this.removeUserNode(node); + node.destroy(); + }, + _nodeLocalPosToLayerPos: function _nodeLocalPosToLayerPos(nodePos, out) { + out.x = nodePos.x + this._leftDownToCenterX; + out.y = nodePos.y + this._leftDownToCenterY; + }, + _getNodesByRowCol: function _getNodesByRowCol(row, col) { + var rowData = this._userNodeGrid[row]; + if (!rowData) return null; + return rowData[col]; + }, + _getNodesCountByRow: function _getNodesCountByRow(row) { + var rowData = this._userNodeGrid[row]; + if (!rowData) return 0; + return rowData.count; + }, + _updateAllUserNode: function _updateAllUserNode() { + this._userNodeGrid = {}; + for (var dataId in this._userNodeMap) { + var dataComp = this._userNodeMap[dataId]; + this._nodeLocalPosToLayerPos(dataComp.node, _vec2_temp); + this._positionToRowCol(_vec2_temp.x, _vec2_temp.y, _tempRowCol); + this._addUserNodeToGrid(dataComp, _tempRowCol); + this._updateCullingOffsetByUserNode(dataComp.node); + } + }, + _updateCullingOffsetByUserNode: function _updateCullingOffsetByUserNode(node) { + this._topOffset < node.height && (this._topOffset = node.height); + this._downOffset < node.height && (this._downOffset = node.height); + this._leftOffset < node.width && (this._leftOffset = node.width); + this._rightOffset < node.width && (this._rightOffset = node.width); + }, + _userNodeSizeChange: function _userNodeSizeChange() { + var dataComp = this; + var node = dataComp.node; + var self = dataComp._tiledLayer; + self._updateCullingOffsetByUserNode(node); + }, + _userNodePosChange: function _userNodePosChange() { + var dataComp = this; + var node = dataComp.node; + var self = dataComp._tiledLayer; + self._nodeLocalPosToLayerPos(node, _vec2_temp); + self._positionToRowCol(_vec2_temp.x, _vec2_temp.y, _tempRowCol); + self._limitInLayer(_tempRowCol); + if (_tempRowCol.row === dataComp._row && _tempRowCol.col === dataComp._col) return; + self._removeUserNodeFromGrid(dataComp); + self._addUserNodeToGrid(dataComp, _tempRowCol); + }, + _removeUserNodeFromGrid: function _removeUserNodeFromGrid(dataComp) { + var row = dataComp._row; + var col = dataComp._col; + var index = dataComp._index; + var rowData = this._userNodeGrid[row]; + var colData = rowData && rowData[col]; + if (colData) { + rowData.count--; + colData.count--; + colData.list[index] = null; + if (colData.count <= 0) { + colData.list.length = 0; + colData.count = 0; + } + } + dataComp._row = -1; + dataComp._col = -1; + dataComp._index = -1; + this._userNodeDirty = true; + }, + _limitInLayer: function _limitInLayer(rowCol) { + var row = rowCol.row; + var col = rowCol.col; + row < 0 && (rowCol.row = 0); + row > this._rightTop.row && (rowCol.row = this._rightTop.row); + col < 0 && (rowCol.col = 0); + col > this._rightTop.col && (rowCol.col = this._rightTop.col); + }, + _addUserNodeToGrid: function _addUserNodeToGrid(dataComp, tempRowCol) { + var row = tempRowCol.row; + var col = tempRowCol.col; + var rowData = this._userNodeGrid[row] = this._userNodeGrid[row] || { + count: 0 + }; + var colData = rowData[col] = rowData[col] || { + count: 0, + list: [] + }; + dataComp._row = row; + dataComp._col = col; + dataComp._index = colData.list.length; + rowData.count++; + colData.count++; + colData.list.push(dataComp); + this._userNodeDirty = true; + }, + _isUserNodeDirty: function _isUserNodeDirty() { + return this._userNodeDirty; + }, + _setUserNodeDirty: function _setUserNodeDirty(value) { + this._userNodeDirty = value; + }, + onEnable: function onEnable() { + this._super(); + this.node.on(cc.Node.EventType.ANCHOR_CHANGED, this._syncAnchorPoint, this); + this._activateMaterial(); + }, + onDisable: function onDisable() { + this._super(); + this.node.off(cc.Node.EventType.ANCHOR_CHANGED, this._syncAnchorPoint, this); + }, + _syncAnchorPoint: function _syncAnchorPoint() { + var node = this.node; + this._leftDownToCenterX = node.width * node.anchorX * node.scaleX; + this._leftDownToCenterY = node.height * node.anchorY * node.scaleY; + this._cullingDirty = true; + }, + onDestroy: function onDestroy() { + this._super(); + if (this._buffer) { + this._buffer.destroy(); + this._buffer = null; + } + this._renderDataList = null; + }, + getLayerName: function getLayerName() { + return this._layerName; + }, + setLayerName: function setLayerName(layerName) { + this._layerName = layerName; + }, + getProperty: function getProperty(propertyName) { + return this._properties[propertyName]; + }, + getPositionAt: function getPositionAt(pos, y) { + var x; + if (void 0 !== y) { + x = Math.floor(pos); + y = Math.floor(y); + } else { + x = Math.floor(pos.x); + y = Math.floor(pos.y); + } + var ret; + switch (this._layerOrientation) { + case cc.TiledMap.Orientation.ORTHO: + ret = this._positionForOrthoAt(x, y); + break; + + case cc.TiledMap.Orientation.ISO: + ret = this._positionForIsoAt(x, y); + break; + + case cc.TiledMap.Orientation.HEX: + ret = this._positionForHexAt(x, y); + } + return ret; + }, + _isInvalidPosition: function _isInvalidPosition(x, y) { + if (x && "object" === typeof x) { + var pos = x; + y = pos.y; + x = pos.x; + } + return x >= this._layerSize.width || y >= this._layerSize.height || x < 0 || y < 0; + }, + _positionForIsoAt: function _positionForIsoAt(x, y) { + var offsetX = 0, offsetY = 0; + var index = Math.floor(x) + Math.floor(y) * this._layerSize.width; + var gidAndFlags = this._tiles[index]; + if (gidAndFlags) { + var gid = (gidAndFlags & cc.TiledMap.TileFlag.FLIPPED_MASK) >>> 0; + var tileset = this._texGrids[gid].tileset; + var offset = tileset.tileOffset; + offsetX = offset.x; + offsetY = offset.y; + } + return cc.v2(.5 * this._mapTileSize.width * (this._layerSize.height + x - y - 1) + offsetX, .5 * this._mapTileSize.height * (this._layerSize.width - x + this._layerSize.height - y - 2) - offsetY); + }, + _positionForOrthoAt: function _positionForOrthoAt(x, y) { + var offsetX = 0, offsetY = 0; + var index = Math.floor(x) + Math.floor(y) * this._layerSize.width; + var gidAndFlags = this._tiles[index]; + if (gidAndFlags) { + var gid = (gidAndFlags & cc.TiledMap.TileFlag.FLIPPED_MASK) >>> 0; + var tileset = this._texGrids[gid].tileset; + var offset = tileset.tileOffset; + offsetX = offset.x; + offsetY = offset.y; + } + return cc.v2(x * this._mapTileSize.width + offsetX, (this._layerSize.height - y - 1) * this._mapTileSize.height - offsetY); + }, + _positionForHexAt: function _positionForHexAt(col, row) { + var tileWidth = this._mapTileSize.width; + var tileHeight = this._mapTileSize.height; + var rows = this._layerSize.height; + var index = Math.floor(col) + Math.floor(row) * this._layerSize.width; + var gid = this._tiles[index]; + var offset; + offset = this._texGrids[gid] ? this._texGrids[gid].tileset.tileOffset : { + x: 0, + y: 0 + }; + var odd_even = this._staggerIndex === cc.TiledMap.StaggerIndex.STAGGERINDEX_ODD ? 1 : -1; + var x = 0, y = 0; + var diffX = 0; + var diffY = 0; + switch (this._staggerAxis) { + case cc.TiledMap.StaggerAxis.STAGGERAXIS_Y: + diffX = 0; + row % 2 === 1 && (diffX = tileWidth / 2 * odd_even); + x = col * tileWidth + diffX + offset.x; + y = (rows - row - 1) * (tileHeight - (tileHeight - this._hexSideLength) / 2) - offset.y; + break; + + case cc.TiledMap.StaggerAxis.STAGGERAXIS_X: + diffY = 0; + col % 2 === 1 && (diffY = tileHeight / 2 * -odd_even); + x = col * (tileWidth - (tileWidth - this._hexSideLength) / 2) + offset.x; + y = (rows - row - 1) * tileHeight + diffY - offset.y; + } + return cc.v2(x, y); + }, + setTilesGIDAt: function setTilesGIDAt(gids, beginCol, beginRow, totalCols) { + if (!gids || 0 === gids.length || totalCols <= 0) return; + beginRow < 0 && (beginRow = 0); + beginCol < 0 && (beginCol = 0); + var gidsIdx = 0; + var endCol = beginCol + totalCols; + for (var row = beginRow; ;row++) for (var col = beginCol; col < endCol; col++) { + if (gidsIdx >= gids.length) return; + this._updateTileForGID(gids[gidsIdx], col, row); + gidsIdx++; + } + }, + setTileGIDAt: function setTileGIDAt(gid, posOrX, flagsOrY, flags) { + if (void 0 === posOrX) throw new Error("cc.TiledLayer.setTileGIDAt(): pos should be non-null"); + var pos; + if (void 0 === flags && posOrX instanceof cc.Vec2) { + pos = posOrX; + flags = flagsOrY; + } else { + _vec2_temp3.x = posOrX; + _vec2_temp3.y = flagsOrY; + pos = _vec2_temp3; + } + var ugid = gid & cc.TiledMap.TileFlag.FLIPPED_MASK; + pos.x = Math.floor(pos.x); + pos.y = Math.floor(pos.y); + if (this._isInvalidPosition(pos)) throw new Error("cc.TiledLayer.setTileGIDAt(): invalid position"); + if (!this._tiles || !this._tilesets || 0 == this._tilesets.length) { + cc.logID(7238); + return; + } + if (0 !== ugid && ugid < this._tilesets[0].firstGid) { + cc.logID(7239, gid); + return; + } + flags = flags || 0; + this._updateTileForGID((gid | flags) >>> 0, pos.x, pos.y); + }, + _updateTileForGID: function _updateTileForGID(gidAndFlags, x, y) { + var idx = 0 | x + y * this._layerSize.width; + if (idx >= this._tiles.length) return; + var oldGIDAndFlags = this._tiles[idx]; + if (gidAndFlags === oldGIDAndFlags) return; + var gid = (gidAndFlags & cc.TiledMap.TileFlag.FLIPPED_MASK) >>> 0; + var grid = this._texGrids[gid]; + var tilesetIdx = grid && grid.texId; + if (grid) { + this._tiles[idx] = gidAndFlags; + this._updateVertex(x, y); + this._buildMaterial(tilesetIdx); + } else this._tiles[idx] = 0; + this._cullingDirty = true; + }, + getTiles: function getTiles() { + return this._tiles; + }, + getTileGIDAt: function getTileGIDAt(pos, y) { + if (void 0 === pos) throw new Error("cc.TiledLayer.getTileGIDAt(): pos should be non-null"); + var x = pos; + if (void 0 === y) { + x = pos.x; + y = pos.y; + } + if (this._isInvalidPosition(x, y)) throw new Error("cc.TiledLayer.getTileGIDAt(): invalid position"); + if (!this._tiles) { + cc.logID(7237); + return null; + } + var index = Math.floor(x) + Math.floor(y) * this._layerSize.width; + var tile = this._tiles[index]; + return (tile & cc.TiledMap.TileFlag.FLIPPED_MASK) >>> 0; + }, + getTileFlagsAt: function getTileFlagsAt(pos, y) { + if (!pos) throw new Error("TiledLayer.getTileFlagsAt: pos should be non-null"); + void 0 !== y && (pos = cc.v2(pos, y)); + if (this._isInvalidPosition(pos)) throw new Error("TiledLayer.getTileFlagsAt: invalid position"); + if (!this._tiles) { + cc.logID(7240); + return null; + } + var idx = Math.floor(pos.x) + Math.floor(pos.y) * this._layerSize.width; + var tile = this._tiles[idx]; + return (tile & cc.TiledMap.TileFlag.FLIPPED_ALL) >>> 0; + }, + _setCullingDirty: function _setCullingDirty(value) { + this._cullingDirty = value; + }, + _isCullingDirty: function _isCullingDirty() { + return this._cullingDirty; + }, + _updateViewPort: function _updateViewPort(x, y, width, height) { + if (this._viewPort.width === width && this._viewPort.height === height && this._viewPort.x === x && this._viewPort.y === y) return; + this._viewPort.x = x; + this._viewPort.y = y; + this._viewPort.width = width; + this._viewPort.height = height; + var reserveLine = 1; + this._layerOrientation === cc.TiledMap.Orientation.ISO && (reserveLine = 2); + var vpx = this._viewPort.x - this._offset.x + this._leftDownToCenterX; + var vpy = this._viewPort.y - this._offset.y + this._leftDownToCenterY; + var leftDownX = vpx - this._leftOffset; + var leftDownY = vpy - this._downOffset; + var rightTopX = vpx + width + this._rightOffset; + var rightTopY = vpy + height + this._topOffset; + var leftDown = this._cullingRect.leftDown; + var rightTop = this._cullingRect.rightTop; + leftDownX < 0 && (leftDownX = 0); + leftDownY < 0 && (leftDownY = 0); + this._positionToRowCol(leftDownX, leftDownY, _tempRowCol); + _tempRowCol.row -= reserveLine; + _tempRowCol.col -= reserveLine; + _tempRowCol.row = _tempRowCol.row > 0 ? _tempRowCol.row : 0; + _tempRowCol.col = _tempRowCol.col > 0 ? _tempRowCol.col : 0; + if (_tempRowCol.row !== leftDown.row || _tempRowCol.col !== leftDown.col) { + leftDown.row = _tempRowCol.row; + leftDown.col = _tempRowCol.col; + this._cullingDirty = true; + } + if (rightTopX < 0 || rightTopY < 0) { + _tempRowCol.row = -1; + _tempRowCol.col = -1; + } else { + this._positionToRowCol(rightTopX, rightTopY, _tempRowCol); + _tempRowCol.row++; + _tempRowCol.col++; + } + _tempRowCol.row > this._rightTop.row && (_tempRowCol.row = this._rightTop.row); + _tempRowCol.col > this._rightTop.col && (_tempRowCol.col = this._rightTop.col); + if (_tempRowCol.row !== rightTop.row || _tempRowCol.col !== rightTop.col) { + rightTop.row = _tempRowCol.row; + rightTop.col = _tempRowCol.col; + this._cullingDirty = true; + } + }, + _positionToRowCol: function _positionToRowCol(x, y, result) { + var TiledMap = cc.TiledMap; + var Orientation = TiledMap.Orientation; + var StaggerAxis = TiledMap.StaggerAxis; + var maptw = this._mapTileSize.width, mapth = this._mapTileSize.height, maptw2 = .5 * maptw, mapth2 = .5 * mapth; + var row = 0, col = 0, diffX2 = 0, diffY2 = 0, axis = this._staggerAxis; + var cols = this._layerSize.width; + switch (this._layerOrientation) { + case Orientation.ORTHO: + col = Math.floor(x / maptw); + row = Math.floor(y / mapth); + break; + + case Orientation.ISO: + col = Math.floor(x / maptw2); + row = Math.floor(y / mapth2); + break; + + case Orientation.HEX: + if (axis === StaggerAxis.STAGGERAXIS_Y) { + row = Math.floor(y / (mapth - this._diffY1)); + diffX2 = row % 2 === 1 ? maptw2 * this._odd_even : 0; + col = Math.floor((x - diffX2) / maptw); + } else { + col = Math.floor(x / (maptw - this._diffX1)); + diffY2 = col % 2 === 1 ? mapth2 * -this._odd_even : 0; + row = Math.floor((y - diffY2) / mapth); + } + } + result.row = row; + result.col = col; + return result; + }, + _updateCulling: function _updateCulling() { + false; + if (this._enableCulling) { + this.node._updateWorldMatrix(); + _valueTypes.Mat4.invert(_mat4_temp, this.node._worldMatrix); + var rect = cc.visibleRect; + var camera = cc.Camera.findCamera(this.node); + if (camera) { + _vec2_temp.x = 0; + _vec2_temp.y = 0; + _vec2_temp2.x = _vec2_temp.x + rect.width; + _vec2_temp2.y = _vec2_temp.y + rect.height; + camera.getScreenToWorldPoint(_vec2_temp, _vec2_temp); + camera.getScreenToWorldPoint(_vec2_temp2, _vec2_temp2); + _valueTypes.Vec2.transformMat4(_vec2_temp, _vec2_temp, _mat4_temp); + _valueTypes.Vec2.transformMat4(_vec2_temp2, _vec2_temp2, _mat4_temp); + this._updateViewPort(_vec2_temp.x, _vec2_temp.y, _vec2_temp2.x - _vec2_temp.x, _vec2_temp2.y - _vec2_temp.y); + } + } + }, + getLayerOrientation: function getLayerOrientation() { + return this._layerOrientation; + }, + getProperties: function getProperties() { + return this._properties; + }, + _updateVertex: function _updateVertex(col, row) { + var TiledMap = cc.TiledMap; + var TileFlag = TiledMap.TileFlag; + var FLIPPED_MASK = TileFlag.FLIPPED_MASK; + var StaggerAxis = TiledMap.StaggerAxis; + var Orientation = TiledMap.Orientation; + var vertices = this._vertices; + var layerOrientation = this._layerOrientation, tiles = this._tiles; + if (!tiles) return; + var rightTop = this._rightTop; + var maptw = this._mapTileSize.width, mapth = this._mapTileSize.height, maptw2 = .5 * maptw, mapth2 = .5 * mapth, rows = this._layerSize.height, cols = this._layerSize.width, grids = this._texGrids; + var gid, grid, left, bottom, axis, diffX1, diffY1, odd_even, diffX2, diffY2; + if (layerOrientation === Orientation.HEX) { + axis = this._staggerAxis; + diffX1 = this._diffX1; + diffY1 = this._diffY1; + odd_even = this._odd_even; + } + var cullingCol = 0, cullingRow = 0; + var tileOffset = null, gridGID = 0; + var topBorder = 0, downBorder = 0, leftBorder = 0, rightBorder = 0; + var index = row * cols + col; + gid = tiles[index]; + gridGID = (gid & FLIPPED_MASK) >>> 0; + grid = grids[gridGID]; + if (!grid) return; + this._animations[gridGID] && (this._hasAniGrid = this._hasAniGrid || true); + switch (layerOrientation) { + case Orientation.ORTHO: + cullingCol = col; + cullingRow = rows - row - 1; + left = cullingCol * maptw; + bottom = cullingRow * mapth; + break; + + case Orientation.ISO: + cullingCol = rows + col - row - 1; + cullingRow = rows + cols - col - row - 2; + left = maptw2 * cullingCol; + bottom = mapth2 * cullingRow; + break; + + case Orientation.HEX: + diffX2 = axis === StaggerAxis.STAGGERAXIS_Y && row % 2 === 1 ? maptw2 * odd_even : 0; + diffY2 = axis === StaggerAxis.STAGGERAXIS_X && col % 2 === 1 ? mapth2 * -odd_even : 0; + left = col * (maptw - diffX1) + diffX2; + bottom = (rows - row - 1) * (mapth - diffY1) + diffY2; + cullingCol = col; + cullingRow = rows - row - 1; + } + var rowData = vertices[cullingRow] = vertices[cullingRow] || { + minCol: 0, + maxCol: 0 + }; + var colData = rowData[cullingCol] = rowData[cullingCol] || {}; + rowData.minCol > cullingCol && (rowData.minCol = cullingCol); + rowData.maxCol < cullingCol && (rowData.maxCol = cullingCol); + rightTop.row < cullingRow && (rightTop.row = cullingRow); + rightTop.col < cullingCol && (rightTop.col = cullingCol); + tileOffset = grid.tileset.tileOffset; + left += this._offset.x + tileOffset.x; + bottom += this._offset.y - tileOffset.y; + topBorder = -tileOffset.y + grid.tileset._tileSize.height - mapth; + topBorder = topBorder < 0 ? 0 : topBorder; + downBorder = tileOffset.y < 0 ? 0 : tileOffset.y; + leftBorder = -tileOffset.x < 0 ? 0 : -tileOffset.x; + rightBorder = tileOffset.x + grid.tileset._tileSize.width - maptw; + rightBorder = rightBorder < 0 ? 0 : rightBorder; + this._rightOffset < leftBorder && (this._rightOffset = leftBorder); + this._leftOffset < rightBorder && (this._leftOffset = rightBorder); + this._topOffset < downBorder && (this._topOffset = downBorder); + this._downOffset < topBorder && (this._downOffset = topBorder); + colData.left = left; + colData.bottom = bottom; + colData.index = index; + this._cullingDirty = true; + }, + _updateVertices: function _updateVertices() { + var vertices = this._vertices; + vertices.length = 0; + var tiles = this._tiles; + if (!tiles) return; + var rightTop = this._rightTop; + rightTop.row = -1; + rightTop.col = -1; + var rows = this._layerSize.height, cols = this._layerSize.width; + this._topOffset = 0; + this._downOffset = 0; + this._leftOffset = 0; + this._rightOffset = 0; + this._hasAniGrid = false; + for (var row = 0; row < rows; ++row) for (var col = 0; col < cols; ++col) this._updateVertex(col, row); + this._verticesDirty = false; + }, + getTiledTileAt: function getTiledTileAt(x, y, forceCreate) { + if (this._isInvalidPosition(x, y)) throw new Error("TiledLayer.getTiledTileAt: invalid position"); + if (!this._tiles) { + cc.logID(7236); + return null; + } + var index = Math.floor(x) + Math.floor(y) * this._layerSize.width; + var tile = this._tiledTiles[index]; + if (!tile && forceCreate) { + var node = new cc.Node(); + tile = node.addComponent(cc.TiledTile); + tile._x = x; + tile._y = y; + tile._layer = this; + tile._updateInfo(); + node.parent = this.node; + return tile; + } + return tile; + }, + setTiledTileAt: function setTiledTileAt(x, y, tiledTile) { + if (this._isInvalidPosition(x, y)) throw new Error("TiledLayer.setTiledTileAt: invalid position"); + if (!this._tiles) { + cc.logID(7236); + return null; + } + var index = Math.floor(x) + Math.floor(y) * this._layerSize.width; + this._tiledTiles[index] = tiledTile; + this._cullingDirty = true; + this._hasTiledNodeGrid = !!tiledTile || this._tiledTiles.some((function(tiledNode, index) { + return !!tiledNode; + })); + return tiledTile; + }, + getTexture: function getTexture(index) { + index = index || 0; + if (this._textures && index >= 0 && this._textures.length > index) return this._textures[index]; + return null; + }, + getTextures: function getTextures() { + return this._textures; + }, + setTexture: function setTexture(texture) { + this.setTextures([ texture ]); + }, + setTextures: function setTextures(textures) { + this._textures = textures; + this._activateMaterial(); + }, + getLayerSize: function getLayerSize() { + return this._layerSize; + }, + getMapTileSize: function getMapTileSize() { + return this._mapTileSize; + }, + getTileSet: function getTileSet(index) { + index = index || 0; + if (this._tilesets && index >= 0 && this._tilesets.length > index) return this._tilesets[index]; + return null; + }, + getTileSets: function getTileSets() { + return this._tilesets; + }, + setTileSet: function setTileSet(tileset) { + this.setTileSets([ tileset ]); + }, + setTileSets: function setTileSets(tilesets) { + this._tilesets = tilesets; + var textures = this._textures = []; + var texGrids = this._texGrids = []; + for (var i = 0; i < tilesets.length; i++) { + var tileset = tilesets[i]; + tileset && (textures[i] = tileset.sourceImage); + } + cc.TiledMap.loadAllTextures(textures, function() { + for (var _i = 0, l = tilesets.length; _i < l; ++_i) { + var tilesetInfo = tilesets[_i]; + if (!tilesetInfo) continue; + cc.TiledMap.fillTextureGrids(tilesetInfo, texGrids, _i); + } + this._prepareToRender(); + }.bind(this)); + }, + _traverseAllGrid: function _traverseAllGrid() { + var tiles = this._tiles; + var texGrids = this._texGrids; + var tilesetIndexArr = this._tilesetIndexArr; + var tilesetIndexToArrIndex = this._tilesetIndexToArrIndex = {}; + var TiledMap = cc.TiledMap; + var TileFlag = TiledMap.TileFlag; + var FLIPPED_MASK = TileFlag.FLIPPED_MASK; + tilesetIndexArr.length = 0; + for (var i = 0; i < tiles.length; i++) { + var gid = tiles[i]; + if (0 === gid) continue; + gid = (gid & FLIPPED_MASK) >>> 0; + var grid = texGrids[gid]; + if (!grid) { + cc.error("CCTiledLayer:_traverseAllGrid grid is null, gid is:", gid); + continue; + } + var tilesetIdx = grid.texId; + if (void 0 !== tilesetIndexToArrIndex[tilesetIdx]) continue; + tilesetIndexToArrIndex[tilesetIdx] = tilesetIndexArr.length; + tilesetIndexArr.push(tilesetIdx); + } + }, + _init: function _init(layerInfo, mapInfo, tilesets, textures, texGrids) { + this._cullingDirty = true; + this._layerInfo = layerInfo; + this._mapInfo = mapInfo; + var size = layerInfo._layerSize; + this._layerName = layerInfo.name; + this._tiles = layerInfo._tiles; + this._properties = layerInfo.properties; + this._layerSize = size; + this._minGID = layerInfo._minGID; + this._maxGID = layerInfo._maxGID; + this._opacity = layerInfo._opacity; + this._renderOrder = mapInfo.renderOrder; + this._staggerAxis = mapInfo.getStaggerAxis(); + this._staggerIndex = mapInfo.getStaggerIndex(); + this._hexSideLength = mapInfo.getHexSideLength(); + this._animations = mapInfo.getTileAnimations(); + this._tilesets = tilesets; + this._textures = textures; + this._texGrids = texGrids; + this._layerOrientation = mapInfo.orientation; + this._mapTileSize = mapInfo.getTileSize(); + var maptw = this._mapTileSize.width; + var mapth = this._mapTileSize.height; + var layerW = this._layerSize.width; + var layerH = this._layerSize.height; + if (this._layerOrientation === cc.TiledMap.Orientation.HEX) { + var TiledMap = cc.TiledMap; + var StaggerAxis = TiledMap.StaggerAxis; + var StaggerIndex = TiledMap.StaggerIndex; + var width = 0, height = 0; + this._odd_even = this._staggerIndex === StaggerIndex.STAGGERINDEX_ODD ? 1 : -1; + if (this._staggerAxis === StaggerAxis.STAGGERAXIS_X) { + this._diffX1 = (maptw - this._hexSideLength) / 2; + this._diffY1 = 0; + height = mapth * (layerH + .5); + width = (maptw + this._hexSideLength) * Math.floor(layerW / 2) + maptw * (layerW % 2); + } else { + this._diffX1 = 0; + this._diffY1 = (mapth - this._hexSideLength) / 2; + width = maptw * (layerW + .5); + height = (mapth + this._hexSideLength) * Math.floor(layerH / 2) + mapth * (layerH % 2); + } + this.node.setContentSize(width, height); + } else if (this._layerOrientation === cc.TiledMap.Orientation.ISO) { + var wh = layerW + layerH; + this.node.setContentSize(.5 * maptw * wh, .5 * mapth * wh); + } else this.node.setContentSize(layerW * maptw, layerH * mapth); + this._offset = cc.v2(layerInfo.offset.x, -layerInfo.offset.y); + this._useAutomaticVertexZ = false; + this._vertexZvalue = 0; + this._syncAnchorPoint(); + this._prepareToRender(); + }, + _prepareToRender: function _prepareToRender() { + this._updateVertices(); + this._traverseAllGrid(); + this._updateAllUserNode(); + this._activateMaterial(); + }, + _buildMaterial: function _buildMaterial(tilesetIdx) { + var texIdMatIdx = this._texIdToMatIndex; + if (void 0 !== texIdMatIdx[tilesetIdx]) return null; + var tilesetIndexArr = this._tilesetIndexArr; + var tilesetIndexToArrIndex = this._tilesetIndexToArrIndex; + var index = tilesetIndexToArrIndex[tilesetIdx]; + if (void 0 === index) { + tilesetIndexToArrIndex[tilesetIdx] = index = tilesetIndexArr.length; + tilesetIndexArr.push(tilesetIdx); + } + var texture = this._textures[tilesetIdx]; + var material = this._materials[index]; + material || (material = Material.getBuiltinMaterial("2d-sprite")); + material = _materialVariant["default"].create(material, this); + material.define("CC_USE_MODEL", true); + material.setProperty("texture", texture); + this._materials[index] = material; + texIdMatIdx[tilesetIdx] = index; + return material; + }, + _activateMaterial: function _activateMaterial() { + var tilesetIndexArr = this._tilesetIndexArr; + if (0 === tilesetIndexArr.length) { + this.disableRender(); + return; + } + var matLen = tilesetIndexArr.length; + for (var i = 0; i < matLen; i++) this._buildMaterial(tilesetIndexArr[i]); + this._materials.length = matLen; + this.markForRender(true); + } + }); + cc.TiledLayer = module.exports = TiledLayer; + }), { + "../core/assets/material/CCMaterial": 125, + "../core/assets/material/material-variant": 132, + "../core/components/CCRenderComponent": 161, + "../core/renderer/render-flow": 273, + "../core/value-types": 340 + } ], + 400: [ (function(require, module, exports) { + "use strict"; + require("./CCTMXXMLParser"); + require("./CCTiledMapAsset"); + require("./CCTiledLayer"); + require("./CCTiledTile"); + require("./CCTiledObjectGroup"); + var Orientation = cc.Enum({ + ORTHO: 0, + HEX: 1, + ISO: 2 + }); + var Property = cc.Enum({ + NONE: 0, + MAP: 1, + LAYER: 2, + OBJECTGROUP: 3, + OBJECT: 4, + TILE: 5 + }); + var TileFlag = cc.Enum({ + HORIZONTAL: 2147483648, + VERTICAL: 1073741824, + DIAGONAL: 536870912, + FLIPPED_ALL: 4026531840, + FLIPPED_MASK: 268435455 + }); + var StaggerAxis = cc.Enum({ + STAGGERAXIS_X: 0, + STAGGERAXIS_Y: 1 + }); + var StaggerIndex = cc.Enum({ + STAGGERINDEX_ODD: 0, + STAGGERINDEX_EVEN: 1 + }); + var RenderOrder = cc.Enum({ + RightDown: 0, + RightUp: 1, + LeftDown: 2, + LeftUp: 3 + }); + var TMXObjectType = cc.Enum({ + RECT: 0, + ELLIPSE: 1, + POLYGON: 2, + POLYLINE: 3, + IMAGE: 4, + TEXT: 5 + }); + var TiledMap = cc.Class({ + name: "cc.TiledMap", + extends: cc.Component, + editor: false, + ctor: function ctor() { + this._texGrids = []; + this._textures = []; + this._tilesets = []; + this._animations = []; + this._imageLayers = []; + this._layers = []; + this._groups = []; + this._images = []; + this._properties = []; + this._tileProperties = []; + this._mapSize = cc.size(0, 0); + this._tileSize = cc.size(0, 0); + }, + statics: { + Orientation: Orientation, + Property: Property, + TileFlag: TileFlag, + StaggerAxis: StaggerAxis, + StaggerIndex: StaggerIndex, + TMXObjectType: TMXObjectType, + RenderOrder: RenderOrder + }, + properties: { + _tmxFile: { + default: null, + type: cc.TiledMapAsset + }, + tmxAsset: { + get: function get() { + return this._tmxFile; + }, + set: function set(value, force) { + if (this._tmxFile !== value || false) { + this._tmxFile = value; + this._applyFile(); + } + }, + type: cc.TiledMapAsset + } + }, + getMapSize: function getMapSize() { + return this._mapSize; + }, + getTileSize: function getTileSize() { + return this._tileSize; + }, + getMapOrientation: function getMapOrientation() { + return this._mapOrientation; + }, + getObjectGroups: function getObjectGroups() { + return this._groups; + }, + getObjectGroup: function getObjectGroup(groupName) { + var groups = this._groups; + for (var i = 0, l = groups.length; i < l; i++) { + var group = groups[i]; + if (group && group.getGroupName() === groupName) return group; + } + return null; + }, + enableCulling: function enableCulling(value) { + var layers = this._layers; + for (var i = 0; i < layers.length; ++i) layers[i].enableCulling(value); + }, + getProperties: function getProperties() { + return this._properties; + }, + getLayers: function getLayers() { + return this._layers; + }, + getLayer: function getLayer(layerName) { + var layers = this._layers; + for (var i = 0, l = layers.length; i < l; i++) { + var layer = layers[i]; + if (layer && layer.getLayerName() === layerName) return layer; + } + return null; + }, + _changeLayer: function _changeLayer(layerName, replaceLayer) { + var layers = this._layers; + for (var i = 0, l = layers.length; i < l; i++) { + var layer = layers[i]; + if (layer && layer.getLayerName() === layerName) { + layers[i] = replaceLayer; + return; + } + } + }, + getProperty: function getProperty(propertyName) { + return this._properties[propertyName.toString()]; + }, + getPropertiesForGID: function getPropertiesForGID(GID) { + return this._tileProperties[GID]; + }, + __preload: function __preload() { + this._tmxFile && this._applyFile(); + }, + onEnable: function onEnable() { + this.node.on(cc.Node.EventType.ANCHOR_CHANGED, this._syncAnchorPoint, this); + }, + onDisable: function onDisable() { + this.node.off(cc.Node.EventType.ANCHOR_CHANGED, this._syncAnchorPoint, this); + }, + _applyFile: function _applyFile() { + var file = this._tmxFile; + if (file) { + var texValues = file.textures; + var texKeys = file.textureNames; + var texSizes = file.textureSizes; + var textures = {}; + var textureSizes = {}; + for (var i = 0; i < texValues.length; ++i) { + var texName = texKeys[i]; + textures[texName] = texValues[i]; + textureSizes[texName] = texSizes[i]; + } + var imageLayerTextures = {}; + texValues = file.imageLayerTextures; + texKeys = file.imageLayerTextureNames; + for (var _i = 0; _i < texValues.length; ++_i) imageLayerTextures[texKeys[_i]] = texValues[_i]; + var tsxFileNames = file.tsxFileNames; + var tsxFiles = file.tsxFiles; + var tsxMap = {}; + for (var _i2 = 0; _i2 < tsxFileNames.length; ++_i2) tsxFileNames[_i2].length > 0 && (tsxMap[tsxFileNames[_i2]] = tsxFiles[_i2].text); + var mapInfo = new cc.TMXMapInfo(file.tmxXmlStr, tsxMap, textures, textureSizes, imageLayerTextures); + var tilesets = mapInfo.getTilesets(); + tilesets && 0 !== tilesets.length || cc.logID(7241); + this._buildWithMapInfo(mapInfo); + } else this._releaseMapInfo(); + }, + _releaseMapInfo: function _releaseMapInfo() { + var layers = this._layers; + for (var i = 0, l = layers.length; i < l; i++) { + layers[i].node.removeFromParent(true); + layers[i].node.destroy(); + } + layers.length = 0; + var groups = this._groups; + for (var _i3 = 0, _l = groups.length; _i3 < _l; _i3++) { + groups[_i3].node.removeFromParent(true); + groups[_i3].node.destroy(); + } + groups.length = 0; + var images = this._images; + for (var _i4 = 0, _l2 = images.length; _i4 < _l2; _i4++) { + images[_i4].removeFromParent(true); + images[_i4].destroy(); + } + images.length = 0; + }, + _syncAnchorPoint: function _syncAnchorPoint() { + var anchor = this.node.getAnchorPoint(); + var leftTopX = this.node.width * anchor.x; + var leftTopY = this.node.height * (1 - anchor.y); + var i, l; + for (i = 0, l = this._layers.length; i < l; i++) { + var layerInfo = this._layers[i]; + var layerNode = layerInfo.node; + layerNode.setAnchorPoint(anchor); + } + for (i = 0, l = this._groups.length; i < l; i++) { + var groupInfo = this._groups[i]; + var groupNode = groupInfo.node; + groupNode.anchorX = .5; + groupNode.anchorY = .5; + groupNode.x = groupInfo._offset.x - leftTopX + groupNode.width * groupNode.anchorX; + groupNode.y = groupInfo._offset.y + leftTopY - groupNode.height * groupNode.anchorY; + } + for (i = 0, l = this._images.length; i < l; i++) { + var image = this._images[i]; + image.anchorX = .5; + image.anchorY = .5; + image.x = image._offset.x - leftTopX + image.width * image.anchorX; + image.y = image._offset.y + leftTopY - image.height * image.anchorY; + } + }, + _fillAniGrids: function _fillAniGrids(texGrids, animations) { + for (var i in animations) { + var animation = animations[i]; + if (!animation) continue; + var frames = animation.frames; + for (var j = 0; j < frames.length; j++) { + var frame = frames[j]; + frame.grid = texGrids[frame.tileid]; + } + } + }, + _buildLayerAndGroup: function _buildLayerAndGroup() { + var tilesets = this._tilesets; + var texGrids = this._texGrids; + var animations = this._animations; + texGrids.length = 0; + for (var i = 0, l = tilesets.length; i < l; ++i) { + var tilesetInfo = tilesets[i]; + if (!tilesetInfo) continue; + cc.TiledMap.fillTextureGrids(tilesetInfo, texGrids, i); + } + this._fillAniGrids(texGrids, animations); + var layers = this._layers; + var groups = this._groups; + var images = this._images; + var oldNodeNames = {}; + for (var _i5 = 0, n = layers.length; _i5 < n; _i5++) oldNodeNames[layers[_i5].node._name] = true; + for (var _i6 = 0, _n = groups.length; _i6 < _n; _i6++) oldNodeNames[groups[_i6].node._name] = true; + for (var _i7 = 0, _n2 = images.length; _i7 < _n2; _i7++) oldNodeNames[images[_i7]._name] = true; + layers = this._layers = []; + groups = this._groups = []; + images = this._images = []; + var mapInfo = this._mapInfo; + var node = this.node; + var layerInfos = mapInfo.getAllChildren(); + var textures = this._textures; + var maxWidth = 0; + var maxHeight = 0; + if (layerInfos && layerInfos.length > 0) for (var _i8 = 0, len = layerInfos.length; _i8 < len; _i8++) { + var layerInfo = layerInfos[_i8]; + var name = layerInfo.name; + var child = this.node.getChildByName(name); + oldNodeNames[name] = false; + if (!child) { + child = new cc.Node(); + child.name = name; + node.addChild(child); + } + child.setSiblingIndex(_i8); + child.active = layerInfo.visible; + if (layerInfo instanceof cc.TMXLayerInfo) { + var layer = child.getComponent(cc.TiledLayer); + layer || (layer = child.addComponent(cc.TiledLayer)); + layer._init(layerInfo, mapInfo, tilesets, textures, texGrids); + layerInfo.ownTiles = false; + layers.push(layer); + } else if (layerInfo instanceof cc.TMXObjectGroupInfo) { + var group = child.getComponent(cc.TiledObjectGroup); + group || (group = child.addComponent(cc.TiledObjectGroup)); + group._init(layerInfo, mapInfo, texGrids); + groups.push(group); + } else if (layerInfo instanceof cc.TMXImageLayerInfo) { + var texture = layerInfo.sourceImage; + child.opacity = layerInfo.opacity; + child.layerInfo = layerInfo; + child._offset = cc.v2(layerInfo.offset.x, -layerInfo.offset.y); + var image = child.getComponent(cc.Sprite); + image || (image = child.addComponent(cc.Sprite)); + var spf = image.spriteFrame || new cc.SpriteFrame(); + spf.setTexture(texture); + image.spriteFrame = spf; + child.width = texture.width; + child.height = texture.height; + images.push(child); + } + maxWidth = Math.max(maxWidth, child.width); + maxHeight = Math.max(maxHeight, child.height); + } + var children = node.children; + for (var _i9 = 0, _n3 = children.length; _i9 < _n3; _i9++) { + var c = children[_i9]; + oldNodeNames[c._name] && c.destroy(); + } + this.node.width = maxWidth; + this.node.height = maxHeight; + this._syncAnchorPoint(); + }, + _buildWithMapInfo: function _buildWithMapInfo(mapInfo) { + this._mapInfo = mapInfo; + this._mapSize = mapInfo.getMapSize(); + this._tileSize = mapInfo.getTileSize(); + this._mapOrientation = mapInfo.orientation; + this._properties = mapInfo.properties; + this._tileProperties = mapInfo.getTileProperties(); + this._imageLayers = mapInfo.getImageLayers(); + this._animations = mapInfo.getTileAnimations(); + this._tilesets = mapInfo.getTilesets(); + var tilesets = this._tilesets; + this._textures.length = 0; + var totalTextures = []; + for (var i = 0, l = tilesets.length; i < l; ++i) { + var tilesetInfo = tilesets[i]; + if (!tilesetInfo || !tilesetInfo.sourceImage) continue; + this._textures[i] = tilesetInfo.sourceImage; + totalTextures.push(tilesetInfo.sourceImage); + } + for (var _i10 = 0; _i10 < this._imageLayers.length; _i10++) { + var imageLayer = this._imageLayers[_i10]; + if (!imageLayer || !imageLayer.sourceImage) continue; + totalTextures.push(imageLayer.sourceImage); + } + cc.TiledMap.loadAllTextures(totalTextures, function() { + this._buildLayerAndGroup(); + }.bind(this)); + }, + update: function update(dt) { + var animations = this._animations; + var texGrids = this._texGrids; + for (var aniGID in animations) { + var animation = animations[aniGID]; + var frames = animation.frames; + var frame = frames[animation.frameIdx]; + animation.dt += dt; + if (frame.duration < animation.dt) { + animation.dt = 0; + animation.frameIdx++; + animation.frameIdx >= frames.length && (animation.frameIdx = 0); + frame = frames[animation.frameIdx]; + } + texGrids[aniGID] = frame.grid; + } + } + }); + cc.TiledMap = module.exports = TiledMap; + cc.TiledMap.loadAllTextures = function(textures, loadedCallback) { + var totalNum = textures.length; + if (0 === totalNum) { + loadedCallback(); + return; + } + var curNum = 0; + var itemCallback = function itemCallback() { + curNum++; + curNum >= totalNum && loadedCallback(); + }; + for (var i = 0; i < totalNum; i++) { + var tex = textures[i]; + tex.loaded ? itemCallback() : tex.once("load", (function() { + itemCallback(); + })); + } + }; + cc.TiledMap.fillTextureGrids = function(tileset, texGrids, texId) { + var tex = tileset.sourceImage; + if (!tileset.imageSize.width || !tileset.imageSize.height) { + tileset.imageSize.width = tex.width; + tileset.imageSize.height = tex.height; + } + var tw = tileset._tileSize.width, th = tileset._tileSize.height, imageW = tex.width, imageH = tex.height, spacing = tileset.spacing, margin = tileset.margin, cols = Math.floor((imageW - 2 * margin + spacing) / (tw + spacing)), rows = Math.floor((imageH - 2 * margin + spacing) / (th + spacing)), count = rows * cols, gid = tileset.firstGid, grid = null, override = !!texGrids[gid], texelCorrect = cc.macro.FIX_ARTIFACTS_BY_STRECHING_TEXEL_TMX ? .5 : 0; + count <= 0 && (count = 1); + var maxGid = tileset.firstGid + count; + for (;gid < maxGid; ++gid) { + override && !texGrids[gid] && (override = false); + if (!override && texGrids[gid]) break; + grid = { + texId: texId, + tileset: tileset, + x: 0, + y: 0, + width: tw, + height: th, + t: 0, + l: 0, + r: 0, + b: 0, + gid: gid + }; + tileset.rectForGID(gid, grid); + grid.x += texelCorrect; + grid.y += texelCorrect; + grid.width -= 2 * texelCorrect; + grid.height -= 2 * texelCorrect; + grid.t = grid.y / imageH; + grid.l = grid.x / imageW; + grid.r = (grid.x + grid.width) / imageW; + grid.b = (grid.y + grid.height) / imageH; + texGrids[gid] = grid; + } + }; + cc.js.obsolete(cc.TiledMap.prototype, "cc.TiledMap.tmxFile", "tmxAsset", true); + cc.js.get(cc.TiledMap.prototype, "mapLoaded", (function() { + cc.errorID(7203); + return []; + }), false); + }), { + "./CCTMXXMLParser": 398, + "./CCTiledLayer": 399, + "./CCTiledMapAsset": 401, + "./CCTiledObjectGroup": 403, + "./CCTiledTile": 404 + } ], + 401: [ (function(require, module, exports) { + "use strict"; + var TiledMapAsset = cc.Class({ + name: "cc.TiledMapAsset", + extends: cc.Asset, + properties: { + tmxXmlStr: "", + textures: { + default: [], + type: [ cc.Texture2D ] + }, + textureNames: [ cc.String ], + textureSizes: { + default: [], + type: [ cc.Size ] + }, + imageLayerTextures: { + default: [], + type: [ cc.Texture2D ] + }, + imageLayerTextureNames: [ cc.String ], + tsxFiles: [ cc.TextAsset ], + tsxFileNames: [ cc.String ] + }, + statics: { + preventDeferredLoadDependents: true + }, + createNode: false + }); + cc.TiledMapAsset = TiledMapAsset; + module.exports = TiledMapAsset; + }), {} ], + 402: [ (function(require, module, exports) { + "use strict"; + var _inputAssembler = _interopRequireDefault(require("../renderer/core/input-assembler")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + var TiledMapRenderDataList = cc.Class({ + name: "cc.TiledMapRenderDataList", + ctor: function ctor() { + this._dataList = []; + this._offset = 0; + }, + _pushRenderData: function _pushRenderData() { + var renderData = {}; + renderData.ia = new _inputAssembler["default"](); + renderData.nodesRenderList = []; + this._dataList.push(renderData); + }, + popRenderData: function popRenderData(buffer) { + this._offset >= this._dataList.length && this._pushRenderData(); + var renderData = this._dataList[this._offset]; + renderData.nodesRenderList.length = 0; + var ia = renderData.ia; + ia._vertexBuffer = buffer._vb; + ia._indexBuffer = buffer._ib; + ia._start = buffer.indiceOffset; + ia._count = 0; + this._offset++; + return renderData; + }, + pushNodesList: function pushNodesList(renderData, nodesList) { + renderData.nodesRenderList.push(nodesList); + }, + reset: function reset() { + this._offset = 0; + } + }); + cc.TiledMapRenderDataList = module.exports = TiledMapRenderDataList; + }), { + "../renderer/core/input-assembler": 363 + } ], + 403: [ (function(require, module, exports) { + "use strict"; + var TiledObjectGroup = cc.Class({ + name: "cc.TiledObjectGroup", + extends: cc.Component, + getPositionOffset: function getPositionOffset() { + return this._positionOffset; + }, + getProperties: function getProperties() { + return this._properties; + }, + getGroupName: function getGroupName() { + return this._groupName; + }, + getProperty: function getProperty(propertyName) { + return this._properties[propertyName.toString()]; + }, + getObject: function getObject(objectName) { + for (var i = 0, len = this._objects.length; i < len; i++) { + var obj = this._objects[i]; + if (obj && obj.name === objectName) return obj; + } + return null; + }, + getObjects: function getObjects() { + return this._objects; + }, + _init: function _init(groupInfo, mapInfo, texGrids) { + var TiledMap = cc.TiledMap; + var TMXObjectType = TiledMap.TMXObjectType; + var Orientation = TiledMap.Orientation; + var StaggerAxis = TiledMap.StaggerAxis; + var TileFlag = TiledMap.TileFlag; + var FLIPPED_MASK = TileFlag.FLIPPED_MASK; + var FLAG_HORIZONTAL = TileFlag.HORIZONTAL; + var FLAG_VERTICAL = TileFlag.VERTICAL; + this._groupName = groupInfo.name; + this._positionOffset = groupInfo.offset; + this._mapInfo = mapInfo; + this._properties = groupInfo.getProperties(); + this._offset = cc.v2(groupInfo.offset.x, -groupInfo.offset.y); + this._opacity = groupInfo._opacity; + var mapSize = mapInfo._mapSize; + var tileSize = mapInfo._tileSize; + var width = 0, height = 0; + if (mapInfo.orientation === Orientation.HEX) if (mapInfo.getStaggerAxis() === StaggerAxis.STAGGERAXIS_X) { + height = tileSize.height * (mapSize.height + .5); + width = (tileSize.width + mapInfo.getHexSideLength()) * Math.floor(mapSize.width / 2) + tileSize.width * (mapSize.width % 2); + } else { + width = tileSize.width * (mapSize.width + .5); + height = (tileSize.height + mapInfo.getHexSideLength()) * Math.floor(mapSize.height / 2) + tileSize.height * (mapSize.height % 2); + } else if (mapInfo.orientation === Orientation.ISO) { + var wh = mapSize.width + mapSize.height; + width = .5 * tileSize.width * wh; + height = .5 * tileSize.height * wh; + } else { + width = mapSize.width * tileSize.width; + height = mapSize.height * tileSize.height; + } + this.node.setContentSize(width, height); + var leftTopX = width * this.node.anchorX; + var leftTopY = height * (1 - this.node.anchorY); + var objects = groupInfo._objects; + var aliveNodes = {}; + for (var i = 0, l = objects.length; i < l; i++) { + var object = objects[i]; + var objType = object.type; + object.offset = cc.v2(object.x, object.y); + var points = object.points || object.polylinePoints; + if (points) for (var pi = 0; pi < points.length; pi++) points[pi].y *= -1; + if (Orientation.ISO !== mapInfo.orientation) object.y = height - object.y; else { + var posIdxX = object.x / tileSize.height; + var posIdxY = object.y / tileSize.height; + object.x = .5 * tileSize.width * (mapSize.height + posIdxX - posIdxY); + object.y = .5 * tileSize.height * (mapSize.width + mapSize.height - posIdxX - posIdxY); + } + if (objType === TMXObjectType.TEXT) { + var textName = "text" + object.id; + aliveNodes[textName] = true; + var textNode = this.node.getChildByName(textName); + textNode || (textNode = new cc.Node()); + textNode.active = object.visible; + textNode.anchorX = 0; + textNode.anchorY = 1; + textNode.angle = -object.rotation; + textNode.x = object.x - leftTopX; + textNode.y = object.y - leftTopY; + textNode.name = textName; + textNode.parent = this.node; + textNode.color = object.color; + textNode.opacity = this._opacity; + textNode.setSiblingIndex(i); + var label = textNode.getComponent(cc.Label); + label || (label = textNode.addComponent(cc.Label)); + label.overflow = cc.Label.Overflow.SHRINK; + label.lineHeight = object.height; + label.string = object.text; + label.horizontalAlign = object.halign; + label.verticalAlign = object.valign; + label.fontSize = object.pixelsize; + textNode.width = object.width; + textNode.height = object.height; + } + if (objType === TMXObjectType.IMAGE) { + var gid = object.gid; + var grid = texGrids[(gid & FLIPPED_MASK) >>> 0]; + if (!grid) continue; + var tileset = grid.tileset; + var imgName = "img" + object.id; + aliveNodes[imgName] = true; + var imgNode = this.node.getChildByName(imgName); + var imgWidth = object.width || grid.width; + var imgHeight = object.height || grid.height; + var tileOffsetX = tileset.tileOffset.x; + var tileOffsetY = tileset.tileOffset.y; + if (imgNode instanceof cc.PrivateNode) { + imgNode.removeFromParent(); + imgNode.destroy(); + imgNode = null; + } + imgNode || (imgNode = new cc.Node()); + if (Orientation.ISO == mapInfo.orientation) { + imgNode.anchorX = .5 + tileOffsetX / imgWidth; + imgNode.anchorY = tileOffsetY / imgHeight; + } else { + imgNode.anchorX = tileOffsetX / imgWidth; + imgNode.anchorY = tileOffsetY / imgHeight; + } + imgNode.active = object.visible; + imgNode.angle = -object.rotation; + imgNode.x = object.x - leftTopX; + imgNode.y = object.y - leftTopY; + imgNode.name = imgName; + imgNode.parent = this.node; + imgNode.opacity = this._opacity; + imgNode.setSiblingIndex(i); + var sp = imgNode.getComponent(cc.Sprite); + sp || (sp = imgNode.addComponent(cc.Sprite)); + var spf = sp.spriteFrame; + spf || (spf = new cc.SpriteFrame()); + (gid & FLAG_HORIZONTAL) >>> 0 ? spf.setFlipX(true) : spf.setFlipX(false); + (gid & FLAG_VERTICAL) >>> 0 ? spf.setFlipY(true) : spf.setFlipY(false); + spf.setTexture(grid.tileset.sourceImage, cc.rect(grid)); + sp.spriteFrame = spf; + sp.setVertsDirty(); + imgNode.width = imgWidth; + imgNode.height = imgHeight; + } + } + this._objects = objects; + var children = this.node.children; + var uselessExp = /^(?:img|text)\d+$/; + for (var _i = 0, n = children.length; _i < n; _i++) { + var c = children[_i]; + var cName = c._name; + var isUseless = uselessExp.test(cName); + isUseless && !aliveNodes[cName] && c.destroy(); + } + } + }); + cc.TiledObjectGroup = module.exports = TiledObjectGroup; + }), {} ], + 404: [ (function(require, module, exports) { + "use strict"; + var TiledTile = cc.Class({ + name: "cc.TiledTile", + extends: cc.Component, + editor: false, + ctor: function ctor() { + this._layer = null; + }, + properties: { + _x: 0, + _y: 0, + x: { + get: function get() { + return this._x; + }, + set: function set(value) { + if (value === this._x) return; + if (this._layer && this._layer._isInvalidPosition(value, this._y)) { + cc.warn("Invalid x, the valid value is between [%s] ~ [%s]", 0, this._layer._layerSize.width); + return; + } + this._resetTile(); + this._x = value; + this._updateInfo(); + }, + type: cc.Integer + }, + y: { + get: function get() { + return this._y; + }, + set: function set(value) { + if (value === this._y) return; + if (this._layer && this._layer._isInvalidPosition(this._x, value)) { + cc.warn("Invalid y, the valid value is between [%s] ~ [%s]", 0, this._layer._layerSize.height); + return; + } + this._resetTile(); + this._y = value; + this._updateInfo(); + }, + type: cc.Integer + }, + gid: { + get: function get() { + if (this._layer) return this._layer.getTileGIDAt(this._x, this._y); + return 0; + }, + set: function set(value) { + this._layer && this._layer.setTileGIDAt(value, this._x, this._y); + }, + type: cc.Integer + } + }, + onEnable: function onEnable() { + var parent = this.node.parent; + this._layer = parent.getComponent(cc.TiledLayer); + this._resetTile(); + this._updateInfo(); + }, + onDisable: function onDisable() { + this._resetTile(); + }, + _resetTile: function _resetTile() { + this._layer && this._layer.getTiledTileAt(this._x, this._y) === this && this._layer.setTiledTileAt(this._x, this._y, null); + }, + _updateInfo: function _updateInfo() { + if (!this._layer) return; + var x = this._x, y = this._y; + if (this._layer.getTiledTileAt(x, y)) { + cc.warn("There is already a TiledTile at [%s, %s]", x, y); + return; + } + this.node.setPosition(this._layer.getPositionAt(x, y)); + this._layer.setTiledTileAt(x, y, this); + } + }); + cc.TiledTile = module.exports = TiledTile; + }), {} ], + 405: [ (function(require, module, exports) { + "use strict"; + require("./CCTiledMap"); + require("./CCTiledMapRenderDataList"); + require("./tiledmap-buffer"); + require("./tmx-layer-assembler"); + }), { + "./CCTiledMap": 400, + "./CCTiledMapRenderDataList": 402, + "./tiledmap-buffer": 406, + "./tmx-layer-assembler": 407 + } ], + 406: [ (function(require, module, exports) { + "use strict"; + var TiledMapBuffer = cc.Class({ + name: "cc.TiledMapBuffer", + extends: require("../core/renderer/webgl/quad-buffer"), + _updateOffset: function _updateOffset() { + var offsetInfo = this._offsetInfo; + offsetInfo.vertexOffset = this.vertexOffset; + offsetInfo.indiceOffset = this.indiceOffset; + offsetInfo.byteOffset = this.byteOffset; + }, + adjust: function adjust(vertexCount, indiceCount) { + this.vertexOffset += vertexCount; + this.indiceOffset += indiceCount; + this.indiceStart = this.indiceOffset; + this.byteOffset = this.byteOffset + vertexCount * this._vertexBytes; + this._dirty = true; + } + }); + cc.TiledMapBuffer = module.exports = TiledMapBuffer; + }), { + "../core/renderer/webgl/quad-buffer": 311 + } ], + 407: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _assembler = _interopRequireDefault(require("../core/renderer/assembler")); + var _valueTypes = require("../core/value-types"); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + _setPrototypeOf(subClass, superClass); + } + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + return _setPrototypeOf(o, p); + } + var TiledLayer = require("./CCTiledLayer"); + var TiledMap = require("./CCTiledMap"); + var TileFlag = TiledMap.TileFlag; + var FLIPPED_MASK = TileFlag.FLIPPED_MASK; + var renderer = require("../core/renderer/"); + var vfmtPosUvColor = require("../core/renderer/webgl/vertex-format").vfmtPosUvColor; + var MaxGridsLimit = parseInt(10922.5); + var RenderOrder = TiledMap.RenderOrder; + var RenderFlow = require("../core/renderer/render-flow"); + var _mat4_temp = cc.mat4(); + var _vec3_temp = cc.v3(); + var _leftDown = { + row: 0, + col: 0 + }; + var _uva = { + x: 0, + y: 0 + }; + var _uvb = { + x: 0, + y: 0 + }; + var _uvc = { + x: 0, + y: 0 + }; + var _uvd = { + x: 0, + y: 0 + }; + var _renderData = null, _ia = null, _fillGrids = 0, _vfOffset = 0, _moveX = 0, _moveY = 0, _layerMat = null, _renderer = null, _renderDataList = null, _buffer = null, _curMaterial = null, _comp = null, _vbuf = null, _uintbuf = null; + function _visitUserNode(userNode) { + false; + userNode._updateLocalMatrix(); + _valueTypes.Mat4.mul(userNode._worldMatrix, _layerMat, userNode._matrix); + userNode._renderFlag &= ~(RenderFlow.FLAG_TRANSFORM | RenderFlow.FLAG_BREAK_FLOW); + RenderFlow.visitRootNode(userNode); + userNode._renderFlag |= RenderFlow.FLAG_BREAK_FLOW; + } + function _flush() { + if (0 === _ia._count) return; + _renderer.material = _renderData.material; + _renderer.node = _comp.node; + _renderer._flushIA(_renderData.ia); + var needSwitchBuffer = _fillGrids >= MaxGridsLimit; + if (needSwitchBuffer) { + _buffer.uploadData(); + _buffer.switchBuffer(); + _vbuf = _buffer._vData; + _uintbuf = _buffer._uintVData; + _renderData = _renderDataList.popRenderData(_buffer); + _ia = _renderData.ia; + _vfOffset = 0; + _fillGrids = 0; + } else { + _renderData = _renderDataList.popRenderData(_buffer); + _ia = _renderData.ia; + } + _renderData.material = _curMaterial; + } + function _renderNodes(nodeRow, nodeCol) { + var nodesInfo = _comp._getNodesByRowCol(nodeRow, nodeCol); + if (!nodesInfo || 0 == nodesInfo.count) return; + var nodesList = nodesInfo.list; + var newIdx = 0, oldIdx = 0; + _flush(); + _renderer.worldMatDirty++; + for (;newIdx < nodesInfo.count; ) { + var dataComp = nodesList[oldIdx]; + oldIdx++; + if (!dataComp) continue; + _visitUserNode(dataComp.node); + if (newIdx !== oldIdx) { + nodesList[newIdx] = dataComp; + dataComp._index = newIdx; + } + newIdx++; + } + nodesList.length = newIdx; + _renderer.worldMatDirty--; + _renderDataList.pushNodesList(_renderData, nodesList); + _renderer._flush(); + _renderer.node = _comp.node; + } + function _flipTexture(inGrid, gid) { + _uva.x = inGrid.l; + _uva.y = inGrid.t; + _uvb.x = inGrid.r; + _uvb.y = inGrid.t; + _uvc.x = inGrid.l; + _uvc.y = inGrid.b; + _uvd.x = inGrid.r; + _uvd.y = inGrid.b; + var tempVal = null; + if ((gid & TileFlag.DIAGONAL) >>> 0) { + tempVal = _uvb; + _uvb = _uvc; + _uvc = tempVal; + } + if ((gid & TileFlag.HORIZONTAL) >>> 0) { + tempVal = _uva; + _uva = _uvb; + _uvb = tempVal; + tempVal = _uvc; + _uvc = _uvd; + _uvd = tempVal; + } + if ((gid & TileFlag.VERTICAL) >>> 0) { + tempVal = _uva; + _uva = _uvc; + _uvc = tempVal; + tempVal = _uvb; + _uvb = _uvd; + _uvd = tempVal; + } + } + var TmxAssembler = (function(_Assembler) { + _inheritsLoose(TmxAssembler, _Assembler); + function TmxAssembler() { + return _Assembler.apply(this, arguments) || this; + } + var _proto = TmxAssembler.prototype; + _proto.updateRenderData = function updateRenderData(comp) { + if (!comp._renderDataList) { + comp._buffer = new cc.TiledMapBuffer(renderer._handle, vfmtPosUvColor); + comp._renderDataList = new cc.TiledMapRenderDataList(); + } + }; + _proto.fillBuffers = function fillBuffers(comp, renderer) { + var vertices = comp._vertices; + if (0 === vertices.length) return; + comp._updateCulling(); + var layerNode = comp.node; + _moveX = comp._leftDownToCenterX; + _moveY = comp._leftDownToCenterY; + _layerMat = layerNode._worldMatrix; + _renderer = renderer; + _comp = comp; + _renderDataList = comp._renderDataList; + _buffer = comp._buffer; + if (comp._isCullingDirty() || comp._isUserNodeDirty() || comp._hasAnimation() || comp._hasTiledNode()) { + _buffer.reset(); + var leftDown, rightTop; + if (comp._enableCulling) { + var cullingRect = comp._cullingRect; + leftDown = cullingRect.leftDown; + rightTop = cullingRect.rightTop; + } else { + leftDown = _leftDown; + rightTop = comp._rightTop; + } + var maxRows = rightTop.row - leftDown.row + 1; + var maxCols = rightTop.col - leftDown.col + 1; + var maxGrids = maxRows * maxCols; + maxGrids > MaxGridsLimit && (maxGrids = MaxGridsLimit); + _buffer.request(4 * maxGrids, 6 * maxGrids); + switch (comp._renderOrder) { + case RenderOrder.RightDown: + this.traverseGrids(leftDown, rightTop, -1, 1); + break; + + case RenderOrder.LeftDown: + this.traverseGrids(leftDown, rightTop, -1, -1); + break; + + case RenderOrder.RightUp: + this.traverseGrids(leftDown, rightTop, 1, 1); + break; + + case RenderOrder.LeftUp: + this.traverseGrids(leftDown, rightTop, 1, -1); + } + comp._setCullingDirty(false); + comp._setUserNodeDirty(false); + } else { + true; + var renderData = null; + var nodesRenderList = null; + var nodesList = null; + for (var i = 0; i < _renderDataList._offset; i++) { + renderData = _renderDataList._dataList[i]; + nodesRenderList = renderData.nodesRenderList; + if (nodesRenderList.length > 0) { + renderer.worldMatDirty++; + for (var j = 0; j < nodesRenderList.length; j++) { + nodesList = nodesRenderList[j]; + if (!nodesList) continue; + for (var idx = 0; idx < nodesList.length; idx++) { + var dataComp = nodesList[idx]; + if (!dataComp) continue; + _visitUserNode(dataComp.node); + } + } + renderer.worldMatDirty--; + renderer._flush(); + } + if (renderData.ia._count > 0) { + renderer.material = renderData.material; + renderer.node = layerNode; + renderer._flushIA(renderData.ia); + } + } + } + _renderData = null; + _ia = null; + _layerMat = null; + _renderer = null; + _renderDataList = null; + _buffer = null; + _curMaterial = null; + _comp = null; + _vbuf = null; + _uintbuf = null; + }; + _proto.traverseGrids = function traverseGrids(leftDown, rightTop, rowMoveDir, colMoveDir) { + _renderDataList.reset(); + if (rightTop.row < 0 || rightTop.col < 0) return; + _renderData = _renderDataList.popRenderData(_buffer); + _ia = _renderData.ia; + _vbuf = _buffer._vData; + _uintbuf = _buffer._uintVData; + _fillGrids = 0; + _vfOffset = 0; + _curMaterial = null; + var layerNode = _comp.node; + var pOpacity = layerNode.parent ? layerNode.parent._opacity / 255 : 1; + var opacity = pOpacity * layerNode._opacity; + layerNode._color._fastSetA(opacity); + var color = layerNode._color._val; + var tiledTiles = _comp._tiledTiles; + var texGrids = _comp._texGrids; + var tiles = _comp._tiles; + var texIdToMatIdx = _comp._texIdToMatIndex; + var mats = _comp._materials; + var vertices = _comp._vertices; + var rowData, col, cols, row, rows, colData, tileSize, grid = null, gid = 0; + var left = 0, bottom = 0, right = 0, top = 0; + var tiledNode = null, curTexIdx = -1, matIdx; + var colNodesCount = 0, checkColRange = true; + if (-1 == rowMoveDir) { + row = rightTop.row; + rows = leftDown.row; + } else { + row = leftDown.row; + rows = rightTop.row; + } + for (;(rows - row) * rowMoveDir >= 0; row += rowMoveDir) { + rowData = vertices[row]; + colNodesCount = _comp._getNodesCountByRow(row); + checkColRange = 0 == colNodesCount && void 0 != rowData; + if (1 == colMoveDir) { + col = checkColRange && leftDown.col < rowData.minCol ? rowData.minCol : leftDown.col; + cols = checkColRange && rightTop.col > rowData.maxCol ? rowData.maxCol : rightTop.col; + } else { + col = checkColRange && rightTop.col > rowData.maxCol ? rowData.maxCol : rightTop.col; + cols = checkColRange && leftDown.col < rowData.minCol ? rowData.minCol : leftDown.col; + } + for (;(cols - col) * colMoveDir >= 0; col += colMoveDir) { + colData = rowData && rowData[col]; + if (!colData) { + colNodesCount > 0 && _renderNodes(row, col); + continue; + } + gid = tiles[colData.index]; + grid = texGrids[(gid & FLIPPED_MASK) >>> 0]; + if (!grid) continue; + if (curTexIdx !== grid.texId) { + -1 !== curTexIdx && _flush(); + curTexIdx = grid.texId; + matIdx = texIdToMatIdx[curTexIdx]; + _curMaterial = mats[matIdx]; + _renderData.material = _curMaterial; + } + if (!_curMaterial) continue; + left = colData.left - _moveX; + bottom = colData.bottom - _moveY; + tileSize = grid.tileset._tileSize; + right = left + tileSize.width; + top = bottom + tileSize.height; + tiledNode = tiledTiles[colData.index]; + if (tiledNode) { + if (tiledNode.node.active) { + tiledNode.node._color._fastSetA(tiledNode.node._opacity * opacity / 255); + this.fillByTiledNode(tiledNode.node, _vbuf, _uintbuf, left, right, top, bottom); + } + } else { + _vbuf[_vfOffset] = left; + _vbuf[_vfOffset + 1] = top; + _uintbuf[_vfOffset + 4] = color; + _vbuf[_vfOffset + 5] = left; + _vbuf[_vfOffset + 6] = bottom; + _uintbuf[_vfOffset + 9] = color; + _vbuf[_vfOffset + 10] = right; + _vbuf[_vfOffset + 11] = top; + _uintbuf[_vfOffset + 14] = color; + _vbuf[_vfOffset + 15] = right; + _vbuf[_vfOffset + 16] = bottom; + _uintbuf[_vfOffset + 19] = color; + } + _flipTexture(grid, gid); + _vbuf[_vfOffset + 2] = _uva.x; + _vbuf[_vfOffset + 3] = _uva.y; + _vbuf[_vfOffset + 7] = _uvc.x; + _vbuf[_vfOffset + 8] = _uvc.y; + _vbuf[_vfOffset + 12] = _uvb.x; + _vbuf[_vfOffset + 13] = _uvb.y; + _vbuf[_vfOffset + 17] = _uvd.x; + _vbuf[_vfOffset + 18] = _uvd.y; + _vfOffset += 20; + _buffer.adjust(4, 6); + _ia._count += 6; + _fillGrids++; + colNodesCount > 0 && _renderNodes(row, col); + _fillGrids >= MaxGridsLimit && _flush(); + } + } + _buffer.uploadData(); + if (_ia._count > 0) { + _renderer.material = _renderData.material; + _renderer.node = _comp.node; + _renderer._flushIA(_renderData.ia); + } + }; + _proto.fillByTiledNode = function fillByTiledNode(tiledNode, vbuf, uintbuf, left, right, top, bottom) { + tiledNode._updateLocalMatrix(); + _valueTypes.Mat4.copy(_mat4_temp, tiledNode._matrix); + _valueTypes.Vec3.set(_vec3_temp, -(left + _moveX), -(bottom + _moveY), 0); + _valueTypes.Mat4.transform(_mat4_temp, _mat4_temp, _vec3_temp); + var m = _mat4_temp.m; + var a = m[0]; + var b = m[1]; + var c = m[4]; + var d = m[5]; + var tx = m[12]; + var ty = m[13]; + var color = tiledNode._color._val; + vbuf[_vfOffset] = left * a + top * c + tx; + vbuf[_vfOffset + 1] = left * b + top * d + ty; + uintbuf[_vfOffset + 4] = color; + vbuf[_vfOffset + 5] = left * a + bottom * c + tx; + vbuf[_vfOffset + 6] = left * b + bottom * d + ty; + uintbuf[_vfOffset + 9] = color; + vbuf[_vfOffset + 10] = right * a + top * c + tx; + vbuf[_vfOffset + 11] = right * b + top * d + ty; + uintbuf[_vfOffset + 14] = color; + vbuf[_vfOffset + 15] = right * a + bottom * c + tx; + vbuf[_vfOffset + 16] = right * b + bottom * d + ty; + uintbuf[_vfOffset + 19] = color; + }; + return TmxAssembler; + })(_assembler["default"]); + exports["default"] = TmxAssembler; + _assembler["default"].register(TiledLayer, TmxAssembler); + module.exports = exports["default"]; + }), { + "../core/renderer/": 272, + "../core/renderer/assembler": 269, + "../core/renderer/render-flow": 273, + "../core/renderer/webgl/vertex-format": 314, + "../core/value-types": 340, + "./CCTiledLayer": 399, + "./CCTiledMap": 400 + } ], + 408: [ (function(require, module, exports) { + "use strict"; + var VideoPlayerImpl = require("./video-player-impl"); + var EventType = VideoPlayerImpl.EventType; + var ResourceType = cc.Enum({ + REMOTE: 0, + LOCAL: 1 + }); + var VideoPlayer = cc.Class({ + name: "cc.VideoPlayer", + extends: cc.Component, + editor: false, + properties: { + _resourceType: ResourceType.REMOTE, + resourceType: { + tooltip: false, + type: ResourceType, + set: function set(value) { + this._resourceType = value; + this._updateVideoSource(); + }, + get: function get() { + return this._resourceType; + } + }, + _remoteURL: "", + remoteURL: { + tooltip: false, + type: cc.String, + set: function set(url) { + this._remoteURL = url; + this._updateVideoSource(); + }, + get: function get() { + return this._remoteURL; + } + }, + _clip: { + default: null, + type: cc.VideoClip + }, + clip: { + tooltip: false, + get: function get() { + return this._clip; + }, + set: function set(value) { + this._clip = value; + this._updateVideoSource(); + }, + type: cc.VideoClip + }, + currentTime: { + tooltip: false, + type: cc.Float, + set: function set(time) { + this._impl && this._impl.seekTo(time); + }, + get: function get() { + if (this._impl) { + if (this._currentStatus === EventType.NONE || this._currentStatus === EventType.STOPPED || this._currentStatus === EventType.META_LOADED || this._currentStatus === EventType.READY_TO_PLAY) return 0; + if (this._currentStatus === EventType.COMPLETED) return this._impl.duration(); + return this._impl.currentTime(); + } + return -1; + } + }, + _volume: 1, + volume: { + get: function get() { + return this._volume; + }, + set: function set(value) { + this._volume = value; + this.isPlaying() && !this._mute && this._syncVolume(); + }, + range: [ 0, 1 ], + type: cc.Float, + tooltip: false + }, + _mute: false, + mute: { + get: function get() { + return this._mute; + }, + set: function set(value) { + this._mute = value; + this._syncVolume(); + }, + tooltip: false + }, + keepAspectRatio: { + tooltip: false, + default: true, + type: cc.Boolean, + notify: function notify() { + this._impl && this._impl.setKeepAspectRatioEnabled(this.keepAspectRatio); + } + }, + _isFullscreen: { + default: false, + formerlySerializedAs: "_N$isFullscreen" + }, + isFullscreen: { + get: function get() { + true; + this._isFullscreen = this._impl && this._impl.isFullScreenEnabled(); + return this._isFullscreen; + }, + set: function set(enable) { + this._isFullscreen = enable; + true; + this._impl && this._impl.setFullScreenEnabled(enable); + }, + animatable: false, + tooltip: false + }, + _stayOnBottom: false, + stayOnBottom: { + get: function get() { + return this._stayOnBottom; + }, + set: function set(enable) { + this._stayOnBottom = enable; + this._impl && this._impl.setStayOnBottom(enable); + }, + animatable: false, + tooltip: false + }, + videoPlayerEvent: { + default: [], + type: cc.Component.EventHandler + } + }, + statics: { + EventType: EventType, + ResourceType: ResourceType, + Impl: VideoPlayerImpl + }, + ctor: function ctor() { + this._impl = new VideoPlayerImpl(); + this._currentStatus = EventType.NONE; + }, + _syncVolume: function _syncVolume() { + var impl = this._impl; + if (impl) { + var volume = this._mute ? 0 : this._volume; + impl.setVolume(volume); + } + }, + _updateVideoSource: function _updateVideoSource() { + var url = ""; + this.resourceType === ResourceType.REMOTE ? url = this.remoteURL : this._clip && (url = this._clip.nativeUrl); + this._impl.setURL(url, this._mute || 0 === this._volume); + this._impl.setKeepAspectRatioEnabled(this.keepAspectRatio); + }, + onLoad: function onLoad() { + var impl = this._impl; + if (impl) { + impl.createDomElementIfNeeded(this._mute || 0 === this._volume); + impl.setStayOnBottom(this._stayOnBottom); + this._updateVideoSource(); + true; + impl.seekTo(this.currentTime); + impl.setFullScreenEnabled(this._isFullscreen); + this.pause(); + impl.setEventListener(EventType.PLAYING, this.onPlaying.bind(this)); + impl.setEventListener(EventType.PAUSED, this.onPasued.bind(this)); + impl.setEventListener(EventType.STOPPED, this.onStopped.bind(this)); + impl.setEventListener(EventType.COMPLETED, this.onCompleted.bind(this)); + impl.setEventListener(EventType.META_LOADED, this.onMetaLoaded.bind(this)); + impl.setEventListener(EventType.CLICKED, this.onClicked.bind(this)); + impl.setEventListener(EventType.READY_TO_PLAY, this.onReadyToPlay.bind(this)); + } + }, + onRestore: function onRestore() { + this._impl || (this._impl = new VideoPlayerImpl()); + }, + onEnable: function onEnable() { + this._impl && this._impl.enable(); + }, + onDisable: function onDisable() { + this._impl && this._impl.disable(); + }, + onDestroy: function onDestroy() { + if (this._impl) { + this._impl.destroy(); + this._impl = null; + } + }, + update: function update(dt) { + this._impl && this._impl.updateMatrix(this.node); + }, + onReadyToPlay: function onReadyToPlay() { + this._currentStatus = EventType.READY_TO_PLAY; + cc.Component.EventHandler.emitEvents(this.videoPlayerEvent, this, EventType.READY_TO_PLAY); + this.node.emit("ready-to-play", this); + }, + onMetaLoaded: function onMetaLoaded() { + this._currentStatus = EventType.META_LOADED; + cc.Component.EventHandler.emitEvents(this.videoPlayerEvent, this, EventType.META_LOADED); + this.node.emit("meta-loaded", this); + }, + onClicked: function onClicked() { + this._currentStatus = EventType.CLICKED; + cc.Component.EventHandler.emitEvents(this.videoPlayerEvent, this, EventType.CLICKED); + this.node.emit("clicked", this); + }, + onPlaying: function onPlaying() { + this._currentStatus = EventType.PLAYING; + cc.Component.EventHandler.emitEvents(this.videoPlayerEvent, this, EventType.PLAYING); + this.node.emit("playing", this); + }, + onPasued: function onPasued() { + this._currentStatus = EventType.PAUSED; + cc.Component.EventHandler.emitEvents(this.videoPlayerEvent, this, EventType.PAUSED); + this.node.emit("paused", this); + }, + onStopped: function onStopped() { + this._currentStatus = EventType.STOPPED; + cc.Component.EventHandler.emitEvents(this.videoPlayerEvent, this, EventType.STOPPED); + this.node.emit("stopped", this); + }, + onCompleted: function onCompleted() { + this._currentStatus = EventType.COMPLETED; + cc.Component.EventHandler.emitEvents(this.videoPlayerEvent, this, EventType.COMPLETED); + this.node.emit("completed", this); + }, + play: function play() { + if (this._impl) { + this._syncVolume(); + this._impl.play(); + } + }, + resume: function resume() { + if (this._impl) { + this._syncVolume(); + this._impl.resume(); + } + }, + pause: function pause() { + this._impl && this._impl.pause(); + }, + stop: function stop() { + this._impl && this._impl.stop(); + }, + getDuration: function getDuration() { + if (this._impl) return this._impl.duration(); + return -1; + }, + isPlaying: function isPlaying() { + if (this._impl) return this._impl.isPlaying(); + return false; + } + }); + cc.VideoPlayer = module.exports = VideoPlayer; + }), { + "./video-player-impl": 409 + } ], + 409: [ (function(require, module, exports) { + "use strict"; + var utils = require("../core/platform/utils"); + var sys = require("../core/platform/CCSys"); + var macro = require("../core/platform/CCMacro"); + var READY_STATE = { + HAVE_NOTHING: 0, + HAVE_METADATA: 1, + HAVE_CURRENT_DATA: 2, + HAVE_FUTURE_DATA: 3, + HAVE_ENOUGH_DATA: 4 + }; + var _mat4_temp = cc.mat4(); + var VideoPlayerImpl = cc.Class({ + name: "VideoPlayerImpl", + ctor: function ctor() { + this._EventList = {}; + this._video = null; + this._url = ""; + this._waitingFullscreen = false; + this._fullScreenEnabled = false; + this._stayOnBottom = false; + this._loadedmeta = false; + this._loaded = false; + this._visible = false; + this._playing = false; + this._ignorePause = false; + this._forceUpdate = false; + this._m00 = 0; + this._m01 = 0; + this._m04 = 0; + this._m05 = 0; + this._m12 = 0; + this._m13 = 0; + this._w = 0; + this._h = 0; + this.__eventListeners = {}; + }, + _bindEvent: function _bindEvent() { + var video = this._video, self = this; + var cbs = this.__eventListeners; + cbs.loadedmetadata = function() { + self._loadedmeta = true; + self._forceUpdate = true; + if (self._waitingFullscreen) { + self._waitingFullscreen = false; + self._toggleFullscreen(true); + } + self._dispatchEvent(VideoPlayerImpl.EventType.META_LOADED); + }; + cbs.ended = function() { + if (self._video !== video) return; + self._playing = false; + self._dispatchEvent(VideoPlayerImpl.EventType.COMPLETED); + }; + cbs.play = function() { + if (self._video !== video) return; + self._playing = true; + self._updateVisibility(); + self._dispatchEvent(VideoPlayerImpl.EventType.PLAYING); + }; + cbs.pause = function() { + if (self._video !== video) return; + self._playing = false; + self._ignorePause || self._dispatchEvent(VideoPlayerImpl.EventType.PAUSED); + }; + cbs.click = function() { + self._dispatchEvent(VideoPlayerImpl.EventType.CLICKED); + }; + video.addEventListener("loadedmetadata", cbs.loadedmetadata); + video.addEventListener("ended", cbs.ended); + video.addEventListener("play", cbs.play); + video.addEventListener("pause", cbs.pause); + video.addEventListener("click", cbs.click); + function onCanPlay() { + if (self._loaded || self._playing) return; + var video = self._video; + if (video.readyState === READY_STATE.HAVE_ENOUGH_DATA || video.readyState === READY_STATE.HAVE_METADATA) { + video.currentTime = 0; + self._loaded = true; + self._forceUpdate = true; + self._dispatchEvent(VideoPlayerImpl.EventType.READY_TO_PLAY); + self._updateVisibility(); + } + } + cbs.onCanPlay = onCanPlay; + video.addEventListener("canplay", cbs.onCanPlay); + video.addEventListener("canplaythrough", cbs.onCanPlay); + video.addEventListener("suspend", cbs.onCanPlay); + }, + _updateVisibility: function _updateVisibility() { + var video = this._video; + if (!video) return; + if (this._visible) video.style.visibility = "visible"; else { + video.style.visibility = "hidden"; + video.pause(); + this._playing = false; + } + }, + _updateSize: function _updateSize(width, height) { + var video = this._video; + if (!video) return; + video.style.width = width + "px"; + video.style.height = height + "px"; + }, + _createDom: function _createDom(muted) { + var video = document.createElement("video"); + video.style.position = "absolute"; + video.style.bottom = "0px"; + video.style.left = "0px"; + video.style["z-index"] = this._stayOnBottom ? macro.MIN_ZINDEX : 0; + video.className = "cocosVideo"; + video.setAttribute("preload", "auto"); + video.setAttribute("webkit-playsinline", ""); + video.setAttribute("x5-playsinline", ""); + video.setAttribute("playsinline", ""); + muted && video.setAttribute("muted", ""); + this._video = video; + cc.game.container.appendChild(video); + }, + createDomElementIfNeeded: function createDomElementIfNeeded(muted) { + this._video || this._createDom(muted); + }, + removeDom: function removeDom() { + var video = this._video; + if (video) { + var hasChild = utils.contains(cc.game.container, video); + hasChild && cc.game.container.removeChild(video); + var cbs = this.__eventListeners; + video.removeEventListener("loadedmetadata", cbs.loadedmetadata); + video.removeEventListener("ended", cbs.ended); + video.removeEventListener("play", cbs.play); + video.removeEventListener("pause", cbs.pause); + video.removeEventListener("click", cbs.click); + video.removeEventListener("canplay", cbs.onCanPlay); + video.removeEventListener("canplaythrough", cbs.onCanPlay); + video.removeEventListener("suspend", cbs.onCanPlay); + cbs.loadedmetadata = null; + cbs.ended = null; + cbs.play = null; + cbs.pause = null; + cbs.click = null; + cbs.onCanPlay = null; + } + this._video = null; + this._url = ""; + }, + setURL: function setURL(path, muted) { + var source, extname; + if (this._url === path) return; + this.removeDom(); + this._url = path; + this.createDomElementIfNeeded(muted); + this._bindEvent(); + var video = this._video; + video.style["visibility"] = "hidden"; + this._loaded = false; + this._playing = false; + this._loadedmeta = false; + source = document.createElement("source"); + source.src = path; + video.appendChild(source); + extname = cc.path.extname(path); + var polyfill = VideoPlayerImpl._polyfill; + for (var i = 0; i < polyfill.canPlayType.length; i++) if (extname !== polyfill.canPlayType[i]) { + source = document.createElement("source"); + source.src = path.replace(extname, polyfill.canPlayType[i]); + video.appendChild(source); + } + }, + getURL: function getURL() { + return this._url; + }, + play: function play() { + var video = this._video; + if (!video || !this._visible || this._playing) return; + video.play(); + }, + pause: function pause() { + var video = this._video; + if (!this._playing || !video) return; + video.pause(); + }, + resume: function resume() { + this.play(); + }, + stop: function stop() { + var video = this._video; + if (!video || !this._visible) return; + this._ignorePause = true; + video.currentTime = 0; + video.pause(); + setTimeout(function() { + this._dispatchEvent(VideoPlayerImpl.EventType.STOPPED); + this._ignorePause = false; + }.bind(this), 0); + }, + setVolume: function setVolume(volume) { + var video = this._video; + video && (video.volume = volume); + }, + seekTo: function seekTo(time) { + var video = this._video; + if (!video) return; + if (this._loaded) video.currentTime = time; else { + var cb = function cb() { + video.currentTime = time; + video.removeEventListener(VideoPlayerImpl._polyfill.event, cb); + }; + video.addEventListener(VideoPlayerImpl._polyfill.event, cb); + } + }, + isPlaying: function isPlaying() { + return this._playing; + }, + duration: function duration() { + var video = this._video; + var duration = -1; + if (!video) return duration; + duration = video.duration; + duration <= 0 && cc.logID(7702); + return duration; + }, + currentTime: function currentTime() { + var video = this._video; + if (!video) return -1; + return video.currentTime; + }, + setKeepAspectRatioEnabled: function setKeepAspectRatioEnabled() { + false; + cc.logID(7700); + }, + isKeepAspectRatioEnabled: function isKeepAspectRatioEnabled() { + return true; + }, + _toggleFullscreen: function _toggleFullscreen(enable) { + var self = this, video = this._video; + if (!video) return; + function handleFullscreenChange(event) { + var fullscreenElement = sys.browserType === sys.BROWSER_TYPE_IE ? document.msFullscreenElement : document.fullscreenElement; + self._fullScreenEnabled = fullscreenElement === video; + } + function handleFullScreenError(event) { + self._fullScreenEnabled = false; + } + if (enable) { + sys.browserType === sys.BROWSER_TYPE_IE && (video.style["transform"] = ""); + cc.screen.requestFullScreen(video, handleFullscreenChange, handleFullScreenError); + } else cc.screen.fullScreen() && cc.screen.exitFullScreen(video); + }, + setStayOnBottom: function setStayOnBottom(enabled) { + this._stayOnBottom = enabled; + if (!this._video) return; + this._video.style["z-index"] = enabled ? macro.MIN_ZINDEX : 0; + }, + setFullScreenEnabled: function setFullScreenEnabled(enable) { + !this._loadedmeta && enable ? this._waitingFullscreen = true : this._toggleFullscreen(enable); + }, + isFullScreenEnabled: function isFullScreenEnabled() { + return this._fullScreenEnabled; + }, + setEventListener: function setEventListener(event, callback) { + this._EventList[event] = callback; + }, + removeEventListener: function removeEventListener(event) { + this._EventList[event] = null; + }, + _dispatchEvent: function _dispatchEvent(event) { + var callback = this._EventList[event]; + callback && callback.call(this, this, this._video.src); + }, + onPlayEvent: function onPlayEvent() { + var callback = this._EventList[VideoPlayerImpl.EventType.PLAYING]; + callback.call(this, this, this._video.src); + }, + enable: function enable() { + var list = VideoPlayerImpl.elements; + -1 === list.indexOf(this) && list.push(this); + this.setVisible(true); + }, + disable: function disable() { + var list = VideoPlayerImpl.elements; + var index = list.indexOf(this); + -1 !== index && list.splice(index, 1); + this.setVisible(false); + }, + destroy: function destroy() { + this.disable(); + this.removeDom(); + }, + setVisible: function setVisible(visible) { + if (this._visible !== visible) { + this._visible = !!visible; + this._updateVisibility(); + } + }, + updateMatrix: function updateMatrix(node) { + if (!this._video || !this._visible || this._fullScreenEnabled) return; + node.getWorldMatrix(_mat4_temp); + var renderCamera = cc.Camera._findRendererCamera(node); + renderCamera && renderCamera.worldMatrixToScreen(_mat4_temp, _mat4_temp, cc.game.canvas.width, cc.game.canvas.height); + var _mat4_tempm = _mat4_temp.m; + if (!this._forceUpdate && this._m00 === _mat4_tempm[0] && this._m01 === _mat4_tempm[1] && this._m04 === _mat4_tempm[4] && this._m05 === _mat4_tempm[5] && this._m12 === _mat4_tempm[12] && this._m13 === _mat4_tempm[13] && this._w === node._contentSize.width && this._h === node._contentSize.height) return; + this._m00 = _mat4_tempm[0]; + this._m01 = _mat4_tempm[1]; + this._m04 = _mat4_tempm[4]; + this._m05 = _mat4_tempm[5]; + this._m12 = _mat4_tempm[12]; + this._m13 = _mat4_tempm[13]; + this._w = node._contentSize.width; + this._h = node._contentSize.height; + var dpr = cc.view._devicePixelRatio; + var scaleX = 1 / dpr; + var scaleY = 1 / dpr; + var container = cc.game.container; + var a = _mat4_tempm[0] * scaleX, b = _mat4_tempm[1], c = _mat4_tempm[4], d = _mat4_tempm[5] * scaleY; + var offsetX = container && container.style.paddingLeft ? parseInt(container.style.paddingLeft) : 0; + var offsetY = container && container.style.paddingBottom ? parseInt(container.style.paddingBottom) : 0; + var w, h; + if (VideoPlayerImpl._polyfill.zoomInvalid) { + this._updateSize(this._w * a, this._h * d); + a = 1; + d = 1; + w = this._w * scaleX; + h = this._h * scaleY; + } else { + w = this._w * scaleX; + h = this._h * scaleY; + this._updateSize(this._w, this._h); + } + var appx = w * _mat4_tempm[0] * node._anchorPoint.x; + var appy = h * _mat4_tempm[5] * node._anchorPoint.y; + var tx = _mat4_tempm[12] * scaleX - appx + offsetX, ty = _mat4_tempm[13] * scaleY - appy + offsetY; + var matrix = "matrix(" + a + "," + -b + "," + -c + "," + d + "," + tx + "," + -ty + ")"; + this._video.style["transform"] = matrix; + this._video.style["-webkit-transform"] = matrix; + this._video.style["transform-origin"] = "0px 100% 0px"; + this._video.style["-webkit-transform-origin"] = "0px 100% 0px"; + sys.browserType !== sys.BROWSER_TYPE_IE && (this._forceUpdate = false); + } + }); + VideoPlayerImpl.EventType = { + NONE: -1, + PLAYING: 0, + PAUSED: 1, + STOPPED: 2, + COMPLETED: 3, + META_LOADED: 4, + CLICKED: 5, + READY_TO_PLAY: 6 + }; + VideoPlayerImpl.elements = []; + VideoPlayerImpl.pauseElements = []; + cc.game.on(cc.game.EVENT_HIDE, (function() { + var list = VideoPlayerImpl.elements; + for (var element, i = 0; i < list.length; i++) { + element = list[i]; + if (element.isPlaying()) { + element.pause(); + VideoPlayerImpl.pauseElements.push(element); + } + } + })); + cc.game.on(cc.game.EVENT_SHOW, (function() { + var list = VideoPlayerImpl.pauseElements; + var element = list.pop(); + while (element) { + element.play(); + element = list.pop(); + } + })); + VideoPlayerImpl._polyfill = { + devicePixelRatio: false, + event: "canplay", + canPlayType: [] + }; + var dom = document.createElement("video"); + if (dom.canPlayType) { + if (dom.canPlayType("video/ogg")) { + VideoPlayerImpl._polyfill.canPlayType.push(".ogg"); + VideoPlayerImpl._polyfill.canPlayType.push(".ogv"); + } + dom.canPlayType("video/mp4") && VideoPlayerImpl._polyfill.canPlayType.push(".mp4"); + dom.canPlayType("video/webm") && VideoPlayerImpl._polyfill.canPlayType.push(".webm"); + } + sys.OS_ANDROID !== sys.os || sys.browserType !== sys.BROWSER_TYPE_SOUGOU && sys.browserType !== sys.BROWSER_TYPE_360 || (VideoPlayerImpl._polyfill.zoomInvalid = true); + var style = document.createElement("style"); + style.innerHTML = ".cocosVideo:-moz-full-screen{transform:matrix(1,0,0,1,0,0) !important;}.cocosVideo:full-screen{transform:matrix(1,0,0,1,0,0) !important;}.cocosVideo:-webkit-full-screen{transform:matrix(1,0,0,1,0,0) !important;}"; + document.head.appendChild(style); + module.exports = VideoPlayerImpl; + }), { + "../core/platform/CCMacro": 245, + "../core/platform/CCSys": 249, + "../core/platform/utils": 264 + } ], + 410: [ (function(require, module, exports) { + "use strict"; + var WebViewImpl = require("./webview-impl"); + var EventType = WebViewImpl.EventType; + function emptyCallback() {} + var WebView = cc.Class({ + name: "cc.WebView", + extends: cc.Component, + editor: false, + properties: { + _url: "", + url: { + type: cc.String, + tooltip: false, + get: function get() { + return this._url; + }, + set: function set(url) { + this._url = url; + var impl = this._impl; + impl && impl.loadURL(url); + } + }, + webviewEvents: { + default: [], + type: cc.Component.EventHandler + } + }, + statics: { + EventType: EventType, + Impl: WebViewImpl + }, + ctor: function ctor() { + this._impl = new WebView.Impl(); + }, + onRestore: function onRestore() { + this._impl || (this._impl = new WebView.Impl()); + }, + onEnable: function onEnable() { + var impl = this._impl; + impl.createDomElementIfNeeded(this.node.width, this.node.height); + true; + impl.setEventListener(EventType.LOADED, this._onWebViewLoaded.bind(this)); + impl.setEventListener(EventType.LOADING, this._onWebViewLoading.bind(this)); + impl.setEventListener(EventType.ERROR, this._onWebViewLoadError.bind(this)); + impl.loadURL(this._url); + impl.setVisible(true); + }, + onDisable: function onDisable() { + var impl = this._impl; + impl.setVisible(false); + true; + impl.setEventListener(EventType.LOADED, emptyCallback); + impl.setEventListener(EventType.LOADING, emptyCallback); + impl.setEventListener(EventType.ERROR, emptyCallback); + }, + onDestroy: function onDestroy() { + if (this._impl) { + this._impl.destroy(); + this._impl = null; + } + }, + update: function update(dt) { + this._impl && this._impl.updateMatrix(this.node); + }, + _onWebViewLoaded: function _onWebViewLoaded() { + cc.Component.EventHandler.emitEvents(this.webviewEvents, this, EventType.LOADED); + this.node.emit("loaded", this); + }, + _onWebViewLoading: function _onWebViewLoading() { + cc.Component.EventHandler.emitEvents(this.webviewEvents, this, EventType.LOADING); + this.node.emit("loading", this); + return true; + }, + _onWebViewLoadError: function _onWebViewLoadError() { + cc.Component.EventHandler.emitEvents(this.webviewEvents, this, EventType.ERROR); + this.node.emit("error", this); + }, + setJavascriptInterfaceScheme: function setJavascriptInterfaceScheme(scheme) { + this._impl && this._impl.setJavascriptInterfaceScheme(scheme); + }, + setOnJSCallback: function setOnJSCallback(callback) { + this._impl && this._impl.setOnJSCallback(callback); + }, + evaluateJS: function evaluateJS(str) { + this._impl && this._impl.evaluateJS(str); + } + }); + cc.WebView = module.exports = WebView; + }), { + "./webview-impl": 411 + } ], + 411: [ (function(require, module, exports) { + "use strict"; + var utils = require("../core/platform/utils"); + var sys = require("../core/platform/CCSys"); + var _mat4_temp = cc.mat4(); + var WebViewImpl = cc.Class({ + name: "WebViewImpl", + ctor: function ctor() { + this._EventList = {}; + this._visible = false; + this._parent = null; + this._div = null; + this._iframe = null; + this._listener = null; + this._forceUpdate = false; + this._m00 = 0; + this._m01 = 0; + this._m04 = 0; + this._m05 = 0; + this._m12 = 0; + this._m13 = 0; + this._w = 0; + this._h = 0; + this.__eventListeners = {}; + }, + _updateVisibility: function _updateVisibility() { + if (!this._div) return; + var div = this._div; + this._visible ? div.style.visibility = "visible" : div.style.visibility = "hidden"; + }, + _updateSize: function _updateSize(w, h) { + var div = this._div; + if (div) { + div.style.width = w + "px"; + div.style.height = h + "px"; + } + }, + _initEvent: function _initEvent() { + var iframe = this._iframe; + if (iframe) { + var cbs = this.__eventListeners, self = this; + cbs.load = function() { + self._forceUpdate = true; + self._dispatchEvent(WebViewImpl.EventType.LOADED); + }; + cbs.error = function() { + self._dispatchEvent(WebViewImpl.EventType.ERROR); + }; + iframe.addEventListener("load", cbs.load); + iframe.addEventListener("error", cbs.error); + } + }, + _initStyle: function _initStyle() { + if (!this._div) return; + var div = this._div; + div.style.position = "absolute"; + div.style.bottom = "0px"; + div.style.left = "0px"; + }, + _setOpacity: function _setOpacity(opacity) { + var iframe = this._iframe; + iframe && iframe.style && (iframe.style.opacity = opacity / 255); + }, + _createDom: function _createDom(w, h) { + if (WebViewImpl._polyfill.enableDiv) { + this._div = document.createElement("div"); + this._div.style["-webkit-overflow"] = "auto"; + this._div.style["-webkit-overflow-scrolling"] = "touch"; + this._iframe = document.createElement("iframe"); + this._div.appendChild(this._iframe); + this._iframe.style.width = "100%"; + this._iframe.style.height = "100%"; + } else this._div = this._iframe = document.createElement("iframe"); + WebViewImpl._polyfill.enableBG && (this._div.style["background"] = "#FFF"); + this._div.style.height = h + "px"; + this._div.style.width = w + "px"; + this._div.style.overflow = "scroll"; + this._iframe.style.border = "none"; + cc.game.container.appendChild(this._div); + this._updateVisibility(); + }, + _createNativeControl: function _createNativeControl(w, h) { + this._createDom(w, h); + this._initStyle(); + this._initEvent(); + }, + createDomElementIfNeeded: function(w, h) { + this._div ? this._updateSize(w, h) : this._createNativeControl(w, h); + }, + removeDom: function removeDom() { + var div = this._div; + if (div) { + var hasChild = utils.contains(cc.game.container, div); + hasChild && cc.game.container.removeChild(div); + this._div = null; + } + var iframe = this._iframe; + if (iframe) { + var cbs = this.__eventListeners; + iframe.removeEventListener("load", cbs.load); + iframe.removeEventListener("error", cbs.error); + cbs.load = null; + cbs.error = null; + this._iframe = null; + } + }, + setOnJSCallback: function setOnJSCallback(callback) {}, + setJavascriptInterfaceScheme: function setJavascriptInterfaceScheme(scheme) {}, + loadData: function loadData(data, MIMEType, encoding, baseURL) {}, + loadHTMLString: function loadHTMLString(string, baseURL) {}, + loadURL: function(url) { + var iframe = this._iframe; + if (iframe) { + iframe.src = url; + var self = this; + var cb = function cb() { + self._loaded = true; + self._updateVisibility(); + iframe.removeEventListener("load", cb); + }; + iframe.addEventListener("load", cb); + this._dispatchEvent(WebViewImpl.EventType.LOADING); + } + }, + stopLoading: function stopLoading() { + cc.logID(7800); + }, + reload: function reload() { + var iframe = this._iframe; + if (iframe) { + var win = iframe.contentWindow; + win && win.location && win.location.reload(); + } + }, + canGoBack: function canGoBack() { + cc.logID(7801); + return true; + }, + canGoForward: function canGoForward() { + cc.logID(7802); + return true; + }, + goBack: function goBack() { + try { + if (WebViewImpl._polyfill.closeHistory) return cc.logID(7803); + var iframe = this._iframe; + if (iframe) { + var win = iframe.contentWindow; + win && win.location && win.history.back.call(win); + } + } catch (err) { + cc.log(err); + } + }, + goForward: function goForward() { + try { + if (WebViewImpl._polyfill.closeHistory) return cc.logID(7804); + var iframe = this._iframe; + if (iframe) { + var win = iframe.contentWindow; + win && win.location && win.history.forward.call(win); + } + } catch (err) { + cc.log(err); + } + }, + evaluateJS: function evaluateJS(str) { + var iframe = this._iframe; + if (iframe) { + var win = iframe.contentWindow; + try { + win.eval(str); + this._dispatchEvent(WebViewImpl.EventType.JS_EVALUATED); + } catch (err) { + console.error(err); + } + } + }, + setScalesPageToFit: function setScalesPageToFit() { + cc.logID(7805); + }, + setEventListener: function setEventListener(event, callback) { + this._EventList[event] = callback; + }, + removeEventListener: function removeEventListener(event) { + this._EventList[event] = null; + }, + _dispatchEvent: function _dispatchEvent(event) { + var callback = this._EventList[event]; + callback && callback.call(this, this, this._iframe.src); + }, + _createRenderCmd: function _createRenderCmd() { + return new WebViewImpl.RenderCmd(this); + }, + destroy: function destroy() { + this.removeDom(); + }, + setVisible: function setVisible(visible) { + if (this._visible !== visible) { + this._visible = !!visible; + this._updateVisibility(); + } + }, + updateMatrix: function updateMatrix(node) { + if (!this._div || !this._visible) return; + node.getWorldMatrix(_mat4_temp); + var renderCamera = cc.Camera._findRendererCamera(node); + renderCamera && renderCamera.worldMatrixToScreen(_mat4_temp, _mat4_temp, cc.game.canvas.width, cc.game.canvas.height); + var _mat4_tempm = _mat4_temp.m; + if (!this._forceUpdate && this._m00 === _mat4_tempm[0] && this._m01 === _mat4_tempm[1] && this._m04 === _mat4_tempm[4] && this._m05 === _mat4_tempm[5] && this._m12 === _mat4_tempm[12] && this._m13 === _mat4_tempm[13] && this._w === node._contentSize.width && this._h === node._contentSize.height) return; + this._m00 = _mat4_tempm[0]; + this._m01 = _mat4_tempm[1]; + this._m04 = _mat4_tempm[4]; + this._m05 = _mat4_tempm[5]; + this._m12 = _mat4_tempm[12]; + this._m13 = _mat4_tempm[13]; + this._w = node._contentSize.width; + this._h = node._contentSize.height; + var dpr = cc.view._devicePixelRatio; + var scaleX = 1 / dpr; + var scaleY = 1 / dpr; + var container = cc.game.container; + var a = _mat4_tempm[0] * scaleX, b = _mat4_tempm[1], c = _mat4_tempm[4], d = _mat4_tempm[5] * scaleY; + var offsetX = container && container.style.paddingLeft ? parseInt(container.style.paddingLeft) : 0; + var offsetY = container && container.style.paddingBottom ? parseInt(container.style.paddingBottom) : 0; + this._updateSize(this._w, this._h); + var w = this._w * scaleX; + var h = this._h * scaleY; + var appx = w * _mat4_tempm[0] * node._anchorPoint.x; + var appy = h * _mat4_tempm[5] * node._anchorPoint.y; + var tx = _mat4_tempm[12] * scaleX - appx + offsetX, ty = _mat4_tempm[13] * scaleY - appy + offsetY; + var matrix = "matrix(" + a + "," + -b + "," + -c + "," + d + "," + tx + "," + -ty + ")"; + this._div.style["transform"] = matrix; + this._div.style["-webkit-transform"] = matrix; + this._div.style["transform-origin"] = "0px 100% 0px"; + this._div.style["-webkit-transform-origin"] = "0px 100% 0px"; + this._setOpacity(node.opacity); + this._forceUpdate = false; + } + }); + WebViewImpl.EventType = { + LOADING: 0, + LOADED: 1, + ERROR: 2, + JS_EVALUATED: 3 + }; + var polyfill = WebViewImpl._polyfill = { + devicePixelRatio: false, + enableDiv: false + }; + sys.os === sys.OS_IOS && (polyfill.enableDiv = true); + sys.isMobile ? sys.browserType === sys.BROWSER_TYPE_FIREFOX && (polyfill.enableBG = true) : sys.browserType === sys.BROWSER_TYPE_IE && (polyfill.closeHistory = true); + module.exports = WebViewImpl; + }), { + "../core/platform/CCSys": 249, + "../core/platform/utils": 264 + } ], + 412: [ (function(require, module, exports) { + "use strict"; + require("./cocos2d/core"); + require("./cocos2d/animation"); + false; + require("./cocos2d/particle"); + require("./cocos2d/tilemap"); + require("./cocos2d/videoplayer/CCVideoPlayer"); + require("./cocos2d/webview/CCWebView"); + require("./cocos2d/core/components/CCStudioComponent"); + require("./extensions/ccpool/CCNodePool"); + require("./cocos2d/actions"); + require("./extensions/spine"); + require("./extensions/dragonbones"); + true; + require("./cocos2d/deprecated"); + }), { + "./cocos2d/actions": 8, + "./cocos2d/animation": 17, + "./cocos2d/core": 207, + "./cocos2d/core/components/CCStudioComponent": 168, + "./cocos2d/deprecated": 352, + "./cocos2d/particle": 358, + "./cocos2d/particle/CCParticleAsset": 355, + "./cocos2d/tilemap": 405, + "./cocos2d/tilemap/CCTiledMapAsset": 401, + "./cocos2d/videoplayer/CCVideoPlayer": 408, + "./cocos2d/webview/CCWebView": 410, + "./extensions/ccpool/CCNodePool": 413, + "./extensions/dragonbones": 423, + "./extensions/spine": 428 + } ], + 413: [ (function(require, module, exports) { + "use strict"; + cc.NodePool = function(poolHandlerComp) { + this.poolHandlerComp = poolHandlerComp; + this._pool = []; + }; + cc.NodePool.prototype = { + constructor: cc.NodePool, + size: function size() { + return this._pool.length; + }, + clear: function clear() { + var count = this._pool.length; + for (var i = 0; i < count; ++i) this._pool[i].destroy(); + this._pool.length = 0; + }, + put: function put(obj) { + if (obj && -1 === this._pool.indexOf(obj)) { + obj.removeFromParent(false); + var handler = this.poolHandlerComp ? obj.getComponent(this.poolHandlerComp) : null; + handler && handler.unuse && handler.unuse(); + this._pool.push(obj); + } + }, + get: function get() { + var last = this._pool.length - 1; + if (last < 0) return null; + var obj = this._pool[last]; + this._pool.length = last; + var handler = this.poolHandlerComp ? obj.getComponent(this.poolHandlerComp) : null; + handler && handler.reuse && handler.reuse.apply(handler, arguments); + return obj; + } + }; + module.exports = cc.NodePool; + }), {} ], + 414: [ (function(require, module, exports) { + "use strict"; + var MaxCacheTime = 30; + var FrameTime = 1 / 60; + var _vertices = []; + var _indices = []; + var _boneInfoOffset = 0; + var _vertexOffset = 0; + var _indexOffset = 0; + var _vfOffset = 0; + var _preTexUrl = null; + var _preBlendMode = null; + var _segVCount = 0; + var _segICount = 0; + var _segOffset = 0; + var _colorOffset = 0; + var _preColor = null; + var _x, _y; + var AnimationCache = cc.Class({ + ctor: function ctor() { + this._privateMode = false; + this._inited = false; + this._invalid = true; + this._enableCacheAttachedInfo = false; + this.frames = []; + this.totalTime = 0; + this.isCompleted = false; + this._frameIdx = -1; + this._armatureInfo = null; + this._animationName = null; + this._tempSegments = null; + this._tempColors = null; + this._tempBoneInfos = null; + }, + init: function init(armatureInfo, animationName) { + this._inited = true; + this._armatureInfo = armatureInfo; + this._animationName = animationName; + }, + clear: function clear() { + this._inited = false; + for (var i = 0, n = this.frames.length; i < n; i++) { + var frame = this.frames[i]; + frame.segments.length = 0; + } + this.invalidAllFrame(); + }, + begin: function begin() { + if (!this._invalid) return; + var armatureInfo = this._armatureInfo; + var curAnimationCache = armatureInfo.curAnimationCache; + curAnimationCache && curAnimationCache != this && (this._privateMode ? curAnimationCache.invalidAllFrame() : curAnimationCache.updateToFrame()); + var armature = armatureInfo.armature; + var animation = armature.animation; + animation.play(this._animationName, 1); + armatureInfo.curAnimationCache = this; + this._invalid = false; + this._frameIdx = -1; + this.totalTime = 0; + this.isCompleted = false; + }, + end: function end() { + if (!this._needToUpdate()) { + this._armatureInfo.curAnimationCache = null; + this.frames.length = this._frameIdx + 1; + this.isCompleted = true; + } + }, + _needToUpdate: function _needToUpdate(toFrameIdx) { + var armatureInfo = this._armatureInfo; + var armature = armatureInfo.armature; + var animation = armature.animation; + return !animation.isCompleted && this.totalTime < MaxCacheTime && (void 0 == toFrameIdx || this._frameIdx < toFrameIdx); + }, + updateToFrame: function updateToFrame(toFrameIdx) { + if (!this._inited) return; + this.begin(); + if (!this._needToUpdate(toFrameIdx)) return; + var armatureInfo = this._armatureInfo; + var armature = armatureInfo.armature; + do { + armature.advanceTime(FrameTime); + this._frameIdx++; + this._updateFrame(armature, this._frameIdx); + this.totalTime += FrameTime; + } while (this._needToUpdate(toFrameIdx)); + this.end(); + }, + isInited: function isInited() { + return this._inited; + }, + isInvalid: function isInvalid() { + return this._invalid; + }, + invalidAllFrame: function invalidAllFrame() { + this.isCompleted = false; + this._invalid = true; + }, + updateAllFrame: function updateAllFrame() { + this.invalidAllFrame(); + this.updateToFrame(); + }, + enableCacheAttachedInfo: function enableCacheAttachedInfo() { + if (!this._enableCacheAttachedInfo) { + this._enableCacheAttachedInfo = true; + this.invalidAllFrame(); + } + }, + _updateFrame: function _updateFrame(armature, index) { + _vfOffset = 0; + _boneInfoOffset = 0; + _indexOffset = 0; + _vertexOffset = 0; + _preTexUrl = null; + _preBlendMode = null; + _segVCount = 0; + _segICount = 0; + _segOffset = 0; + _colorOffset = 0; + _preColor = null; + this.frames[index] = this.frames[index] || { + segments: [], + colors: [], + boneInfos: [], + vertices: null, + uintVert: null, + indices: null + }; + var frame = this.frames[index]; + var segments = this._tempSegments = frame.segments; + var colors = this._tempColors = frame.colors; + var boneInfos = this._tempBoneInfos = frame.boneInfos; + this._traverseArmature(armature, 1); + _colorOffset > 0 && (colors[_colorOffset - 1].vfOffset = _vfOffset); + colors.length = _colorOffset; + boneInfos.length = _boneInfoOffset; + var preSegOffset = _segOffset - 1; + if (preSegOffset >= 0) if (_segICount > 0) { + var preSegInfo = segments[preSegOffset]; + preSegInfo.indexCount = _segICount; + preSegInfo.vfCount = 5 * _segVCount; + preSegInfo.vertexCount = _segVCount; + segments.length = _segOffset; + } else segments.length = _segOffset - 1; + if (0 === segments.length) return; + var vertices = frame.vertices; + var uintVert = frame.uintVert; + if (!vertices || vertices.length < _vfOffset) { + vertices = frame.vertices = new Float32Array(_vfOffset); + uintVert = frame.uintVert = new Uint32Array(vertices.buffer); + } + for (var i = 0, j = 0; i < _vfOffset; ) { + vertices[i++] = _vertices[j++]; + vertices[i++] = _vertices[j++]; + vertices[i++] = _vertices[j++]; + vertices[i++] = _vertices[j++]; + uintVert[i++] = _vertices[j++]; + } + var indices = frame.indices; + (!indices || indices.length < _indexOffset) && (indices = frame.indices = new Uint16Array(_indexOffset)); + for (var _i = 0; _i < _indexOffset; _i++) indices[_i] = _indices[_i]; + frame.vertices = vertices; + frame.uintVert = uintVert; + frame.indices = indices; + }, + _traverseArmature: function _traverseArmature(armature, parentOpacity) { + var colors = this._tempColors; + var segments = this._tempSegments; + var boneInfos = this._tempBoneInfos; + var gVertices = _vertices; + var gIndices = _indices; + var slotVertices, slotIndices; + var slots = armature._slots, slot, slotMatrix, slotMatrixm, slotColor, colorVal; + var texture; + var preSegOffset, preSegInfo; + var bones = armature._bones; + if (this._enableCacheAttachedInfo) for (var i = 0, l = bones.length; i < l; i++, + _boneInfoOffset++) { + var bone = bones[i]; + var boneInfo = boneInfos[_boneInfoOffset]; + boneInfo || (boneInfo = boneInfos[_boneInfoOffset] = { + globalTransformMatrix: new dragonBones.Matrix() + }); + var boneMat = bone.globalTransformMatrix; + var cacheBoneMat = boneInfo.globalTransformMatrix; + cacheBoneMat.copyFrom(boneMat); + } + for (var _i2 = 0, _l = slots.length; _i2 < _l; _i2++) { + slot = slots[_i2]; + if (!slot._visible || !slot._displayData) continue; + slot.updateWorldMatrix(); + slotColor = slot._color; + if (slot.childArmature) { + this._traverseArmature(slot.childArmature, parentOpacity * slotColor.a / 255); + continue; + } + texture = slot.getTexture(); + if (!texture) continue; + if (_preTexUrl !== texture.nativeUrl || _preBlendMode !== slot._blendMode) { + _preTexUrl = texture.nativeUrl; + _preBlendMode = slot._blendMode; + preSegOffset = _segOffset - 1; + if (preSegOffset >= 0) if (_segICount > 0) { + preSegInfo = segments[preSegOffset]; + preSegInfo.indexCount = _segICount; + preSegInfo.vertexCount = _segVCount; + preSegInfo.vfCount = 5 * _segVCount; + } else _segOffset--; + segments[_segOffset] = { + tex: texture, + blendMode: slot._blendMode, + indexCount: 0, + vertexCount: 0, + vfCount: 0 + }; + _segOffset++; + _segICount = 0; + _segVCount = 0; + } + colorVal = (slotColor.a * parentOpacity << 24 >>> 0) + (slotColor.b << 16) + (slotColor.g << 8) + slotColor.r; + if (_preColor !== colorVal) { + _preColor = colorVal; + _colorOffset > 0 && (colors[_colorOffset - 1].vfOffset = _vfOffset); + colors[_colorOffset++] = { + r: slotColor.r, + g: slotColor.g, + b: slotColor.b, + a: slotColor.a * parentOpacity, + vfOffset: 0 + }; + } + slotVertices = slot._localVertices; + slotIndices = slot._indices; + slotMatrix = slot._worldMatrix; + slotMatrixm = slotMatrix.m; + for (var j = 0, vl = slotVertices.length; j < vl; ) { + _x = slotVertices[j++]; + _y = slotVertices[j++]; + gVertices[_vfOffset++] = _x * slotMatrixm[0] + _y * slotMatrixm[4] + slotMatrixm[12]; + gVertices[_vfOffset++] = _x * slotMatrixm[1] + _y * slotMatrixm[5] + slotMatrixm[13]; + gVertices[_vfOffset++] = slotVertices[j++]; + gVertices[_vfOffset++] = slotVertices[j++]; + gVertices[_vfOffset++] = colorVal; + } + for (var ii = 0, il = slotIndices.length; ii < il; ii++) gIndices[_indexOffset++] = _segVCount + slotIndices[ii]; + _vertexOffset = _vfOffset / 5; + _segICount += slotIndices.length; + _segVCount += slotVertices.length / 4; + } + } + }); + var ArmatureCache = cc.Class({ + ctor: function ctor() { + this._privateMode = false; + this._animationPool = {}; + this._armatureCache = {}; + }, + enablePrivateMode: function enablePrivateMode() { + this._privateMode = true; + }, + dispose: function dispose() { + for (var key in this._armatureCache) { + var armatureInfo = this._armatureCache[key]; + if (armatureInfo) { + var armature = armatureInfo.armature; + armature && armature.dispose(); + } + } + this._armatureCache = null; + this._animationPool = null; + }, + _removeArmature: function _removeArmature(armatureKey) { + var armatureInfo = this._armatureCache[armatureKey]; + var animationsCache = armatureInfo.animationsCache; + for (var aniKey in animationsCache) { + var animationCache = animationsCache[aniKey]; + if (!animationCache) continue; + this._animationPool[armatureKey + "#" + aniKey] = animationCache; + animationCache.clear(); + } + var armature = armatureInfo.armature; + armature && armature.dispose(); + delete this._armatureCache[armatureKey]; + }, + resetArmature: function resetArmature(uuid) { + for (var armatureKey in this._armatureCache) { + if (-1 == armatureKey.indexOf(uuid)) continue; + this._removeArmature(armatureKey); + } + }, + getArmatureCache: function getArmatureCache(armatureName, armatureKey, atlasUUID) { + var armatureInfo = this._armatureCache[armatureKey]; + var armature; + if (armatureInfo) armature = armatureInfo.armature; else { + var factory = dragonBones.CCFactory.getInstance(); + var proxy = factory.buildArmatureDisplay(armatureName, armatureKey, "", atlasUUID); + if (!proxy || !proxy._armature) return; + armature = proxy._armature; + if (!ArmatureCache.canCache(armature)) { + armature.dispose(); + return; + } + this._armatureCache[armatureKey] = { + armature: armature, + animationsCache: {}, + curAnimationCache: null + }; + } + return armature; + }, + getAnimationCache: function getAnimationCache(armatureKey, animationName) { + var armatureInfo = this._armatureCache[armatureKey]; + if (!armatureInfo) return null; + var animationsCache = armatureInfo.animationsCache; + return animationsCache[animationName]; + }, + initAnimationCache: function initAnimationCache(armatureKey, animationName) { + if (!animationName) return null; + var armatureInfo = this._armatureCache[armatureKey]; + var armature = armatureInfo && armatureInfo.armature; + if (!armature) return null; + var animation = armature.animation; + var hasAni = animation.hasAnimation(animationName); + if (!hasAni) return null; + var animationsCache = armatureInfo.animationsCache; + var animationCache = animationsCache[animationName]; + if (!animationCache) { + var poolKey = armatureKey + "#" + animationName; + animationCache = this._animationPool[poolKey]; + if (animationCache) delete this._animationPool[poolKey]; else { + animationCache = new AnimationCache(); + animationCache._privateMode = this._privateMode; + } + animationCache.init(armatureInfo, animationName); + animationsCache[animationName] = animationCache; + } + return animationCache; + }, + invalidAnimationCache: function invalidAnimationCache(armatureKey) { + var armatureInfo = this._armatureCache[armatureKey]; + var armature = armatureInfo && armatureInfo.armature; + if (!armature) return null; + var animationsCache = armatureInfo.animationsCache; + for (var aniKey in animationsCache) { + var animationCache = animationsCache[aniKey]; + animationCache.invalidAllFrame(); + } + }, + updateAnimationCache: function updateAnimationCache(armatureKey, animationName) { + if (animationName) { + var animationCache = this.initAnimationCache(armatureKey, animationName); + if (!animationCache) return; + animationCache.updateAllFrame(); + } else { + var armatureInfo = this._armatureCache[armatureKey]; + var armature = armatureInfo && armatureInfo.armature; + if (!armature) return null; + var animationsCache = armatureInfo.animationsCache; + for (var aniKey in animationsCache) { + var _animationCache = animationsCache[aniKey]; + _animationCache.updateAllFrame(); + } + } + } + }); + ArmatureCache.FrameTime = FrameTime; + ArmatureCache.sharedCache = new ArmatureCache(); + ArmatureCache.canCache = function(armature) { + var slots = armature._slots; + for (var i = 0, l = slots.length; i < l; i++) { + var slot = slots[i]; + if (slot.childArmature) return false; + } + return true; + }, module.exports = ArmatureCache; + }), {} ], + 415: [ (function(require, module, exports) { + "use strict"; + var RenderComponent = require("../../cocos2d/core/components/CCRenderComponent"); + var EventTarget = require("../../cocos2d/core/event/event-target"); + var Graphics = require("../../cocos2d/core/graphics/graphics"); + var RenderFlow = require("../../cocos2d/core/renderer/render-flow"); + var FLAG_POST_RENDER = RenderFlow.FLAG_POST_RENDER; + var ArmatureCache = require("./ArmatureCache"); + var AttachUtil = require("./AttachUtil"); + var DefaultArmaturesEnum = cc.Enum({ + default: -1 + }); + var DefaultAnimsEnum = cc.Enum({ + "": 0 + }); + var DefaultCacheMode = cc.Enum({ + REALTIME: 0 + }); + var AnimationCacheMode = cc.Enum({ + REALTIME: 0, + SHARED_CACHE: 1, + PRIVATE_CACHE: 2 + }); + function setEnumAttr(obj, propName, enumDef) { + cc.Class.Attr.setClassAttr(obj, propName, "type", "Enum"); + cc.Class.Attr.setClassAttr(obj, propName, "enumList", cc.Enum.getList(enumDef)); + } + var ArmatureDisplay = cc.Class({ + name: "dragonBones.ArmatureDisplay", + extends: RenderComponent, + editor: false, + statics: { + AnimationCacheMode: AnimationCacheMode + }, + properties: { + _factory: { + default: null, + type: dragonBones.CCFactory, + serializable: false + }, + dragonAsset: { + default: null, + type: dragonBones.DragonBonesAsset, + notify: function notify() { + this._refresh(); + false; + }, + tooltip: false + }, + dragonAtlasAsset: { + default: null, + type: dragonBones.DragonBonesAtlasAsset, + notify: function notify() { + this._parseDragonAtlasAsset(); + this._refresh(); + }, + tooltip: false + }, + _armatureName: "", + armatureName: { + get: function get() { + return this._armatureName; + }, + set: function set(value) { + this._armatureName = value; + var animNames = this.getAnimationNames(this._armatureName); + if (!this.animationName || animNames.indexOf(this.animationName) < 0) { + false; + this.animationName = ""; + } + this._armature && !this.isAnimationCached() && this._factory._dragonBones.clock.remove(this._armature); + this._refresh(); + this._armature && !this.isAnimationCached() && this._factory._dragonBones.clock.add(this._armature); + }, + visible: false + }, + _animationName: "", + animationName: { + get: function get() { + return this._animationName; + }, + set: function set(value) { + this._animationName = value; + }, + visible: false + }, + _defaultArmatureIndex: { + default: 0, + notify: function notify() { + var armatureName = ""; + if (this.dragonAsset) { + var armaturesEnum; + this.dragonAsset && (armaturesEnum = this.dragonAsset.getArmatureEnum()); + if (!armaturesEnum) return cc.errorID(7400, this.name); + armatureName = armaturesEnum[this._defaultArmatureIndex]; + } + void 0 !== armatureName ? this.armatureName = armatureName : cc.errorID(7401, this.name); + }, + type: DefaultArmaturesEnum, + visible: true, + editorOnly: true, + animatable: false, + displayName: "Armature", + tooltip: false + }, + _animationIndex: { + default: 0, + notify: function notify() { + if (0 === this._animationIndex) { + this.animationName = ""; + return; + } + var animsEnum; + this.dragonAsset && (animsEnum = this.dragonAsset.getAnimsEnum(this.armatureName)); + if (!animsEnum) return; + var animName = animsEnum[this._animationIndex]; + void 0 !== animName ? this.playAnimation(animName, this.playTimes) : cc.errorID(7402, this.name); + }, + type: DefaultAnimsEnum, + visible: true, + editorOnly: true, + animatable: false, + displayName: "Animation", + tooltip: false + }, + _preCacheMode: -1, + _cacheMode: AnimationCacheMode.REALTIME, + _defaultCacheMode: { + default: 0, + type: AnimationCacheMode, + notify: function notify() { + if (this._defaultCacheMode !== AnimationCacheMode.REALTIME && this._armature && !ArmatureCache.canCache(this._armature)) { + this._defaultCacheMode = AnimationCacheMode.REALTIME; + cc.warn("Animation cache mode doesn't support skeletal nesting"); + return; + } + this.setAnimationCacheMode(this._defaultCacheMode); + }, + editorOnly: true, + visible: true, + animatable: false, + displayName: "Animation Cache Mode", + tooltip: false + }, + timeScale: { + default: 1, + notify: function notify() { + this._armature && !this.isAnimationCached() && (this._armature.animation.timeScale = this.timeScale); + }, + tooltip: false + }, + playTimes: { + default: -1, + tooltip: false + }, + premultipliedAlpha: { + default: false, + tooltip: false + }, + debugBones: { + default: false, + notify: function notify() { + this._updateDebugDraw(); + }, + tooltip: false + }, + enableBatch: { + default: false, + notify: function notify() { + this._updateBatch(); + }, + tooltip: false + }, + _armatureKey: "", + _accTime: 0, + _playCount: 0, + _frameCache: null, + _curFrame: null, + _playing: false, + _armatureCache: null + }, + ctor: function ctor() { + this._eventTarget = new EventTarget(); + this._materialCache = {}; + this._inited = false; + this.attachUtil = new AttachUtil(); + this._factory = dragonBones.CCFactory.getInstance(); + }, + onLoad: function onLoad() { + var children = this.node.children; + for (var i = 0, n = children.length; i < n; i++) { + var child = children[i]; + var pos = child._name && child._name.search("CHILD_ARMATURE-"); + 0 === pos && child.destroy(); + } + }, + _updateBatch: function _updateBatch() { + var baseMaterial = this.getMaterial(0); + baseMaterial && baseMaterial.define("CC_USE_MODEL", !this.enableBatch); + this._materialCache = {}; + }, + _updateMaterial: function _updateMaterial() { + var baseMaterial = this.getMaterial(0); + if (baseMaterial) { + baseMaterial.define("CC_USE_MODEL", !this.enableBatch); + baseMaterial.define("USE_TEXTURE", true); + var srcBlendFactor = this.premultipliedAlpha ? cc.gfx.BLEND_ONE : cc.gfx.BLEND_SRC_ALPHA; + var dstBlendFactor = cc.gfx.BLEND_ONE_MINUS_SRC_ALPHA; + baseMaterial.setBlend(true, cc.gfx.BLEND_FUNC_ADD, srcBlendFactor, srcBlendFactor, cc.gfx.BLEND_FUNC_ADD, dstBlendFactor, dstBlendFactor); + } + this._materialCache = {}; + }, + disableRender: function disableRender() { + this._super(); + this.node._renderFlag &= ~FLAG_POST_RENDER; + }, + markForRender: function markForRender(enable) { + this._super(enable); + enable ? this.node._renderFlag |= FLAG_POST_RENDER : this.node._renderFlag &= ~FLAG_POST_RENDER; + }, + _validateRender: function _validateRender() { + var texture = this.dragonAtlasAsset && this.dragonAtlasAsset.texture; + if (!texture || !texture.loaded) { + this.disableRender(); + return; + } + this._super(); + }, + __preload: function __preload() { + this._init(); + }, + _init: function _init() { + if (this._inited) return; + this._inited = true; + this._resetAssembler(); + this._activateMaterial(); + this._parseDragonAtlasAsset(); + this._refresh(); + var children = this.node.children; + for (var i = 0, n = children.length; i < n; i++) { + var child = children[i]; + child && "DEBUG_DRAW_NODE" === child._name && child.destroy(); + } + this._updateDebugDraw(); + }, + getArmatureKey: function getArmatureKey() { + return this._armatureKey; + }, + setAnimationCacheMode: function setAnimationCacheMode(cacheMode) { + if (this._preCacheMode !== cacheMode) { + this._cacheMode = cacheMode; + this._buildArmature(); + this._armature && !this.isAnimationCached() && this._factory._dragonBones.clock.add(this._armature); + } + }, + isAnimationCached: function isAnimationCached() { + false; + return this._cacheMode !== AnimationCacheMode.REALTIME; + }, + onEnable: function onEnable() { + this._super(); + this._armature && !this.isAnimationCached() && this._factory._dragonBones.clock.add(this._armature); + }, + onDisable: function onDisable() { + this._super(); + this._armature && !this.isAnimationCached() && this._factory._dragonBones.clock.remove(this._armature); + }, + _emitCacheCompleteEvent: function _emitCacheCompleteEvent() { + this._eventTarget.emit(dragonBones.EventObject.LOOP_COMPLETE); + this._eventTarget.emit(dragonBones.EventObject.COMPLETE); + }, + update: function update(dt) { + if (!this.isAnimationCached()) return; + if (!this._frameCache) return; + var frameCache = this._frameCache; + if (!frameCache.isInited()) return; + var frames = frameCache.frames; + if (!this._playing) { + if (frameCache.isInvalid()) { + frameCache.updateToFrame(); + this._curFrame = frames[frames.length - 1]; + } + return; + } + var frameTime = ArmatureCache.FrameTime; + 0 == this._accTime && 0 == this._playCount && this._eventTarget.emit(dragonBones.EventObject.START); + var globalTimeScale = dragonBones.timeScale; + this._accTime += dt * this.timeScale * globalTimeScale; + var frameIdx = Math.floor(this._accTime / frameTime); + frameCache.isCompleted || frameCache.updateToFrame(frameIdx); + if (frameCache.isCompleted && frameIdx >= frames.length) { + this._playCount++; + if (this.playTimes > 0 && this._playCount >= this.playTimes) { + this._curFrame = frames[frames.length - 1]; + this._accTime = 0; + this._playing = false; + this._playCount = 0; + this._emitCacheCompleteEvent(); + return; + } + this._accTime = 0; + frameIdx = 0; + this._emitCacheCompleteEvent(); + } + this._curFrame = frames[frameIdx]; + }, + onDestroy: function onDestroy() { + this._super(); + this._inited = false; + true; + if (this._cacheMode === AnimationCacheMode.PRIVATE_CACHE) { + this._armatureCache.dispose(); + this._armatureCache = null; + this._armature = null; + } else if (this._cacheMode === AnimationCacheMode.SHARED_CACHE) { + this._armatureCache = null; + this._armature = null; + } else if (this._armature) { + this._armature.dispose(); + this._armature = null; + } + }, + _updateDebugDraw: function _updateDebugDraw() { + if (this.debugBones) { + if (!this._debugDraw) { + var debugDrawNode = new cc.PrivateNode(); + debugDrawNode.name = "DEBUG_DRAW_NODE"; + var debugDraw = debugDrawNode.addComponent(Graphics); + debugDraw.lineWidth = 1; + debugDraw.strokeColor = cc.color(255, 0, 0, 255); + this._debugDraw = debugDraw; + } + this._debugDraw.node.parent = this.node; + } else this._debugDraw && (this._debugDraw.node.parent = null); + }, + _buildArmature: function _buildArmature() { + if (!this.dragonAsset || !this.dragonAtlasAsset || !this.armatureName) return; + if (this._armature) { + true; + this._preCacheMode === AnimationCacheMode.PRIVATE_CACHE ? this._armatureCache.dispose() : this._preCacheMode === AnimationCacheMode.REALTIME && this._armature.dispose(); + this._armatureCache = null; + this._armature = null; + this._displayProxy = null; + this._frameCache = null; + this._curFrame = null; + this._playing = false; + this._preCacheMode = null; + } + true; + if (this._cacheMode === AnimationCacheMode.SHARED_CACHE) this._armatureCache = ArmatureCache.sharedCache; else if (this._cacheMode === AnimationCacheMode.PRIVATE_CACHE) { + this._armatureCache = new ArmatureCache(); + this._armatureCache.enablePrivateMode(); + } + var atlasUUID = this.dragonAtlasAsset._uuid; + this._armatureKey = this.dragonAsset.init(this._factory, atlasUUID); + if (this.isAnimationCached()) { + this._armature = this._armatureCache.getArmatureCache(this.armatureName, this._armatureKey, atlasUUID); + this._armature || (this._cacheMode = AnimationCacheMode.REALTIME); + } + this._preCacheMode = this._cacheMode; + if (false, this._cacheMode === AnimationCacheMode.REALTIME) { + this._displayProxy = this._factory.buildArmatureDisplay(this.armatureName, this._armatureKey, "", atlasUUID); + if (!this._displayProxy) return; + this._displayProxy._ccNode = this.node; + this._displayProxy.setEventTarget(this._eventTarget); + this._armature = this._displayProxy._armature; + this._armature.animation.timeScale = this.timeScale; + } + this._cacheMode !== AnimationCacheMode.REALTIME && this.debugBones && cc.warn("Debug bones is invalid in cached mode"); + if (this._armature) { + var armatureData = this._armature.armatureData; + var aabb = armatureData.aabb; + this.node.setContentSize(aabb.width, aabb.height); + } + this._updateBatch(); + this.attachUtil.init(this); + this.attachUtil._associateAttachedNode(); + this.animationName && this.playAnimation(this.animationName, this.playTimes); + this.markForRender(true); + }, + _parseDragonAtlasAsset: function _parseDragonAtlasAsset() { + this.dragonAtlasAsset && this.dragonAtlasAsset.init(this._factory); + }, + _refresh: function _refresh() { + this._buildArmature(); + false; + }, + _updateCacheModeEnum: false, + _updateAnimEnum: false, + _updateArmatureEnum: false, + playAnimation: function playAnimation(animName, playTimes) { + this.playTimes = void 0 === playTimes ? -1 : playTimes; + this.animationName = animName; + if (this.isAnimationCached()) { + var cache = this._armatureCache.getAnimationCache(this._armatureKey, animName); + cache || (cache = this._armatureCache.initAnimationCache(this._armatureKey, animName)); + if (cache) { + this._accTime = 0; + this._playCount = 0; + this._frameCache = cache; + this.attachUtil._hasAttachedNode() && this._frameCache.enableCacheAttachedInfo(); + this._frameCache.updateToFrame(0); + this._playing = true; + this._curFrame = this._frameCache.frames[0]; + } + } else if (this._armature) return this._armature.animation.play(animName, this.playTimes); + }, + updateAnimationCache: function updateAnimationCache(animName) { + if (!this.isAnimationCached()) return; + this._armatureCache.updateAnimationCache(this._armatureKey, animName); + }, + invalidAnimationCache: function invalidAnimationCache() { + if (!this.isAnimationCached()) return; + this._armatureCache.invalidAnimationCache(this._armatureKey); + }, + getArmatureNames: function getArmatureNames() { + var dragonBonesData = this._factory.getDragonBonesData(this._armatureKey); + return dragonBonesData && dragonBonesData.armatureNames || []; + }, + getAnimationNames: function getAnimationNames(armatureName) { + var ret = []; + var dragonBonesData = this._factory.getDragonBonesData(this._armatureKey); + if (dragonBonesData) { + var armatureData = dragonBonesData.getArmature(armatureName); + if (armatureData) for (var animName in armatureData.animations) armatureData.animations.hasOwnProperty(animName) && ret.push(animName); + } + return ret; + }, + on: function on(eventType, listener, target) { + this.addEventListener(eventType, listener, target); + }, + off: function off(eventType, listener, target) { + this.removeEventListener(eventType, listener, target); + }, + once: function once(eventType, listener, target) { + this._eventTarget.once(eventType, listener, target); + }, + addEventListener: function addEventListener(eventType, listener, target) { + this._eventTarget.on(eventType, listener, target); + }, + removeEventListener: function removeEventListener(eventType, listener, target) { + this._eventTarget.off(eventType, listener, target); + }, + buildArmature: function buildArmature(armatureName, node) { + return this._factory.createArmatureNode(this, armatureName, node); + }, + armature: function armature() { + return this._armature; + } + }); + module.exports = dragonBones.ArmatureDisplay = ArmatureDisplay; + }), { + "../../cocos2d/core/components/CCRenderComponent": 161, + "../../cocos2d/core/event/event-target": 187, + "../../cocos2d/core/graphics/graphics": 203, + "../../cocos2d/core/renderer/render-flow": 273, + "./ArmatureCache": 414, + "./AttachUtil": 416 + } ], + 416: [ (function(require, module, exports) { + "use strict"; + var _mat = _interopRequireDefault(require("../../cocos2d/core/value-types/mat4")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + var RenderFlow = require("../../cocos2d/core/renderer/render-flow"); + var FLAG_TRANSFORM = RenderFlow.FLAG_TRANSFORM; + var EmptyHandle = function EmptyHandle() {}; + var ATTACHED_ROOT_NAME = "ATTACHED_NODE_TREE"; + var ATTACHED_PRE_NAME = "ATTACHED_NODE:"; + var limitNode = function limitNode(node) { + Object.defineProperty(node, "_worldMatDirty", { + get: function get() { + return true; + }, + set: function set(value) {} + }); + node._calculWorldMatrix = EmptyHandle; + node._mulMat = EmptyHandle; + }; + var _tempMat4 = new _mat["default"](); + var AttachUtil = cc.Class({ + name: "dragonBones.AttachUtil", + ctor: function ctor() { + this._inited = false; + this._armature = null; + this._armatureNode = null; + this._armatureDisplay = null; + this._attachedRootNode = null; + this._attachedNodeArray = []; + this._boneIndexToNode = {}; + }, + init: function init(armatureDisplay) { + this._inited = true; + this._armature = armatureDisplay._armature; + this._armatureNode = armatureDisplay.node; + this._armatureDisplay = armatureDisplay; + }, + reset: function reset() { + this._inited = false; + this._armature = null; + this._armatureNode = null; + this._armatureDisplay = null; + }, + _prepareAttachNode: function _prepareAttachNode() { + var armature = this._armature; + if (!armature) return; + var rootNode = this._armatureNode.getChildByName(ATTACHED_ROOT_NAME); + if (!rootNode || !rootNode.isValid) { + rootNode = new cc.Node(ATTACHED_ROOT_NAME); + limitNode(rootNode); + this._armatureNode.addChild(rootNode); + } + var isCached = this._armatureDisplay.isAnimationCached(); + isCached && this._armatureDisplay._frameCache && this._armatureDisplay._frameCache.enableCacheAttachedInfo(); + this._attachedRootNode = rootNode; + return rootNode; + }, + _buildBoneAttachedNode: function _buildBoneAttachedNode(bone, boneIndex) { + var boneNodeName = ATTACHED_PRE_NAME + bone.name; + var boneNode = new cc.Node(boneNodeName); + this._buildBoneRelation(boneNode, bone, boneIndex); + return boneNode; + }, + _buildBoneRelation: function _buildBoneRelation(boneNode, bone, boneIndex) { + limitNode(boneNode); + boneNode._bone = bone; + boneNode._boneIndex = boneIndex; + this._attachedNodeArray.push(boneNode); + this._boneIndexToNode[boneIndex] = boneNode; + }, + getAttachedRootNode: function getAttachedRootNode() { + return this._attachedRootNode; + }, + getAttachedNodes: function getAttachedNodes(boneName) { + var nodeArray = this._attachedNodeArray; + var res = []; + if (!this._inited) return res; + for (var i = 0, n = nodeArray.length; i < n; i++) { + var boneNode = nodeArray[i]; + if (!boneNode || !boneNode.isValid) continue; + boneNode.name === ATTACHED_PRE_NAME + boneName && res.push(boneNode); + } + return res; + }, + _rebuildNodeArray: function _rebuildNodeArray() { + var findMap = this._boneIndexToNode = {}; + var oldNodeArray = this._attachedNodeArray; + var nodeArray = this._attachedNodeArray = []; + for (var i = 0, n = oldNodeArray.length; i < n; i++) { + var boneNode = oldNodeArray[i]; + if (!boneNode || !boneNode.isValid || boneNode._toRemove) continue; + nodeArray.push(boneNode); + findMap[boneNode._boneIndex] = boneNode; + } + }, + _sortNodeArray: function _sortNodeArray() { + var nodeArray = this._attachedNodeArray; + nodeArray.sort((function(a, b) { + return a._boneIndex < b._boneIndex ? -1 : 1; + })); + }, + _getNodeByBoneIndex: function _getNodeByBoneIndex(boneIndex) { + var findMap = this._boneIndexToNode; + var boneNode = findMap[boneIndex]; + if (!boneNode || !boneNode.isValid) return null; + return boneNode; + }, + destroyAttachedNodes: function destroyAttachedNodes(boneName) { + if (!this._inited) return; + var nodeArray = this._attachedNodeArray; + var markTree = function markTree(rootNode) { + var children = rootNode.children; + for (var i = 0, n = children.length; i < n; i++) { + var c = children[i]; + c && markTree(c); + } + rootNode._toRemove = true; + }; + for (var i = 0, n = nodeArray.length; i < n; i++) { + var boneNode = nodeArray[i]; + if (!boneNode || !boneNode.isValid) continue; + var delName = boneNode.name.split(ATTACHED_PRE_NAME)[1]; + if (delName === boneName) { + markTree(boneNode); + boneNode.removeFromParent(true); + boneNode.destroy(); + nodeArray[i] = null; + } + } + this._rebuildNodeArray(); + }, + generateAttachedNodes: function generateAttachedNodes(boneName) { + var targetNodes = []; + if (!this._inited) return targetNodes; + var rootNode = this._prepareAttachNode(); + if (!rootNode) return targetNodes; + var boneIndex = 0; + var res = []; + var attachedTraverse = function(armature) { + if (!armature) return; + var bones = armature.getBones(), bone; + for (var i = 0, l = bones.length; i < l; i++) { + bone = bones[i]; + bone._boneIndex = boneIndex++; + boneName === bone.name && res.push(bone); + } + var slots = armature.getSlots(), slot; + for (var _i = 0, _l = slots.length; _i < _l; _i++) { + slot = slots[_i]; + slot.childArmature && attachedTraverse(slot.childArmature); + } + }.bind(this); + attachedTraverse(this._armature); + var buildBoneTree = function(bone) { + if (!bone) return; + var boneNode = this._getNodeByBoneIndex(bone._boneIndex); + if (boneNode) return boneNode; + boneNode = this._buildBoneAttachedNode(bone, bone._boneIndex); + var subArmatureParentBone = null; + if (bone.armature.parent) { + var parentSlot = bone.armature.parent; + subArmatureParentBone = parentSlot.parent; + } + var parentBoneNode = buildBoneTree(bone.parent || subArmatureParentBone) || rootNode; + boneNode.parent = parentBoneNode; + bone.parent ? boneNode._rootNode = parentBoneNode._rootNode : boneNode._rootNode = parentBoneNode; + return boneNode; + }.bind(this); + for (var i = 0, n = res.length; i < n; i++) { + var targetNode = buildBoneTree(res[i]); + targetNode && targetNodes.push(targetNode); + } + this._sortNodeArray(); + return targetNodes; + }, + destroyAllAttachedNodes: function destroyAllAttachedNodes() { + this._attachedRootNode = null; + this._attachedNodeArray.length = 0; + this._boneIndexToNode = {}; + if (!this._inited) return; + var rootNode = this._armatureNode.getChildByName(ATTACHED_ROOT_NAME); + if (rootNode) { + rootNode.removeFromParent(true); + rootNode.destroy(); + rootNode = null; + } + }, + generateAllAttachedNodes: function generateAllAttachedNodes() { + if (!this._inited) return; + this._boneIndexToNode = {}; + this._attachedNodeArray.length = 0; + var rootNode = this._prepareAttachNode(); + if (!rootNode) return; + var boneIndex = 0; + var attachedTraverse = function(armature) { + if (!armature) return; + var subArmatureParentNode = rootNode; + if (armature.parent) { + var parentSlot = armature.parent; + var parentBone = parentSlot.parent; + subArmatureParentNode = parentBone._attachedNode; + } + var bones = armature.getBones(), bone; + for (var i = 0, l = bones.length; i < l; i++) { + var curBoneIndex = boneIndex++; + bone = bones[i]; + bone._attachedNode = null; + var parentNode = null; + parentNode = bone.parent ? bone.parent._attachedNode : subArmatureParentNode; + if (parentNode) { + var boneNode = parentNode.getChildByName(ATTACHED_PRE_NAME + bone.name); + if (boneNode && boneNode.isValid) this._buildBoneRelation(boneNode, bone, curBoneIndex); else { + boneNode = this._buildBoneAttachedNode(bone, curBoneIndex); + parentNode.addChild(boneNode); + } + boneNode._rootNode = subArmatureParentNode; + bone._attachedNode = boneNode; + } + } + var slots = armature.getSlots(), slot; + for (var _i2 = 0, _l2 = slots.length; _i2 < _l2; _i2++) { + slot = slots[_i2]; + slot.childArmature && attachedTraverse(slot.childArmature); + } + }.bind(this); + attachedTraverse(this._armature); + return rootNode; + }, + _hasAttachedNode: function _hasAttachedNode() { + if (!this._inited) return false; + var attachedRootNode = this._armatureNode.getChildByName(ATTACHED_ROOT_NAME); + return !!attachedRootNode; + }, + _associateAttachedNode: function _associateAttachedNode() { + if (!this._inited) return; + var rootNode = this._armatureNode.getChildByName(ATTACHED_ROOT_NAME); + if (!rootNode || !rootNode.isValid) return; + this._attachedRootNode = rootNode; + this._boneIndexToNode = {}; + var nodeArray = this._attachedNodeArray; + nodeArray.length = 0; + var armature = this._armature; + if (!armature) return; + limitNode(rootNode); + true; + var isCached = this._armatureDisplay.isAnimationCached(); + isCached && this._armatureDisplay._frameCache && this._armatureDisplay._frameCache.enableCacheAttachedInfo(); + var boneIndex = 0; + var attachedTraverse = function(armature) { + if (!armature) return; + var subArmatureParentNode = rootNode; + if (armature.parent) { + var parentSlot = armature.parent; + var parentBone = parentSlot.parent; + subArmatureParentNode = parentBone._attachedNode; + } + var bones = armature.getBones(), bone; + for (var i = 0, l = bones.length; i < l; i++) { + var curBoneIndex = boneIndex++; + bone = bones[i]; + bone._attachedNode = null; + var parentNode = null; + parentNode = bone.parent ? bone.parent._attachedNode : subArmatureParentNode; + if (parentNode) { + var boneNode = parentNode.getChildByName(ATTACHED_PRE_NAME + bone.name); + if (boneNode && boneNode.isValid) { + this._buildBoneRelation(boneNode, bone, curBoneIndex); + boneNode._rootNode = subArmatureParentNode; + bone._attachedNode = boneNode; + } + } + } + var slots = armature.getSlots(), slot; + for (var _i3 = 0, _l3 = slots.length; _i3 < _l3; _i3++) { + slot = slots[_i3]; + slot.childArmature && attachedTraverse(slot.childArmature); + } + }.bind(this); + attachedTraverse(armature); + }, + _syncAttachedNode: function _syncAttachedNode() { + if (!this._inited) return; + var rootNode = this._attachedRootNode; + var nodeArray = this._attachedNodeArray; + if (!rootNode || !rootNode.isValid) { + this._attachedRootNode = null; + nodeArray.length = 0; + return; + } + var rootMatrix = this._armatureNode._worldMatrix; + _mat["default"].copy(rootNode._worldMatrix, rootMatrix); + rootNode._renderFlag &= ~FLAG_TRANSFORM; + var boneInfos = null; + var isCached = this._armatureDisplay.isAnimationCached(); + if (isCached) { + boneInfos = this._armatureDisplay._curFrame && this._armatureDisplay._curFrame.boneInfos; + if (!boneInfos) return; + } + var mulMat = this._armatureNode._mulMat; + var matrixHandle = function matrixHandle(nodeMat, parentMat, boneMat) { + var tm = _tempMat4.m; + tm[0] = boneMat.a; + tm[1] = boneMat.b; + tm[4] = -boneMat.c; + tm[5] = -boneMat.d; + tm[12] = boneMat.tx; + tm[13] = boneMat.ty; + mulMat(nodeMat, parentMat, _tempMat4); + }; + var nodeArrayDirty = false; + for (var i = 0, n = nodeArray.length; i < n; i++) { + var boneNode = nodeArray[i]; + if (!boneNode || !boneNode.isValid) { + nodeArray[i] = null; + nodeArrayDirty = true; + continue; + } + var bone = isCached ? boneInfos[boneNode._boneIndex] : boneNode._bone; + if (!bone || bone._isInPool) { + boneNode.removeFromParent(true); + boneNode.destroy(); + nodeArray[i] = null; + nodeArrayDirty = true; + continue; + } + matrixHandle(boneNode._worldMatrix, boneNode._rootNode._worldMatrix, bone.globalTransformMatrix); + boneNode._renderFlag &= ~FLAG_TRANSFORM; + } + nodeArrayDirty && this._rebuildNodeArray(); + } + }); + module.exports = dragonBones.AttachUtil = AttachUtil; + }), { + "../../cocos2d/core/renderer/render-flow": 273, + "../../cocos2d/core/value-types/mat4": 342 + } ], + 417: [ (function(require, module, exports) { + "use strict"; + var EventTarget = require("../../cocos2d/core/event/event-target"); + dragonBones.CCArmatureDisplay = cc.Class({ + name: "dragonBones.CCArmatureDisplay", + properties: { + node: { + get: function get() { + return this; + } + } + }, + ctor: function ctor() { + this._eventTarget = new EventTarget(); + }, + setEventTarget: function setEventTarget(eventTarget) { + this._eventTarget = eventTarget; + }, + getRootDisplay: function getRootDisplay() { + var parentSlot = this._armature._parent; + if (!parentSlot) return this; + var slot; + while (parentSlot) { + slot = parentSlot; + parentSlot = parentSlot._armature._parent; + } + return slot._armature.getDisplay(); + }, + convertToRootSpace: function convertToRootSpace(pos) { + var slot = this._armature._parent; + if (!slot) return pos; + slot.updateWorldMatrix(); + var worldMatrix = slot._worldMatrix; + var worldMatrixm = worldMatrix.m; + var newPos = cc.v2(0, 0); + newPos.x = pos.x * worldMatrixm[0] + pos.y * worldMatrixm[4] + worldMatrixm[12]; + newPos.y = pos.x * worldMatrixm[1] + pos.y * worldMatrixm[5] + worldMatrixm[13]; + return newPos; + }, + convertToWorldSpace: function convertToWorldSpace(point) { + var newPos = this.convertToRootSpace(point); + var ccNode = this.getRootNode(); + var finalPos = ccNode.convertToWorldSpaceAR(newPos); + return finalPos; + }, + getRootNode: function getRootNode() { + var rootDisplay = this.getRootDisplay(); + return rootDisplay && rootDisplay._ccNode; + }, + dbInit: function dbInit(armature) { + this._armature = armature; + }, + dbClear: function dbClear() { + this._armature = null; + }, + dbUpdate: function dbUpdate() {}, + advanceTimeBySelf: function advanceTimeBySelf(on) { + this.shouldAdvanced = !!on; + }, + hasDBEventListener: function hasDBEventListener(type) { + return this._eventTarget.hasEventListener(type); + }, + addDBEventListener: function addDBEventListener(type, listener, target) { + this._eventTarget.on(type, listener, target); + }, + removeDBEventListener: function removeDBEventListener(type, listener, target) { + this._eventTarget.off(type, listener, target); + }, + dispatchDBEvent: function dispatchDBEvent(type, eventObject) { + this._eventTarget.emit(type, eventObject); + } + }); + }), { + "../../cocos2d/core/event/event-target": 187 + } ], + 418: [ (function(require, module, exports) { + "use strict"; + var BaseObject = dragonBones.BaseObject, BaseFactory = dragonBones.BaseFactory; + var CCFactory = dragonBones.CCFactory = cc.Class({ + name: "dragonBones.CCFactory", + extends: BaseFactory, + statics: { + _factory: null, + getInstance: function getInstance() { + CCFactory._factory || (CCFactory._factory = new CCFactory()); + return CCFactory._factory; + } + }, + ctor: function ctor() { + var eventManager = new dragonBones.CCArmatureDisplay(); + this._dragonBones = new dragonBones.DragonBones(eventManager); + if ((true, true) && cc.director._scheduler) { + cc.game.on(cc.game.EVENT_RESTART, this.initUpdate, this); + this.initUpdate(); + } + }, + initUpdate: function initUpdate(dt) { + cc.director._scheduler.enableForTarget(this); + cc.director._scheduler.scheduleUpdate(this, cc.Scheduler.PRIORITY_SYSTEM, false); + }, + update: function update(dt) { + this._dragonBones.advanceTime(dt); + }, + getDragonBonesDataByRawData: function getDragonBonesDataByRawData(rawData) { + var dataParser = rawData instanceof ArrayBuffer ? BaseFactory._binaryParser : this._dataParser; + return dataParser.parseDragonBonesData(rawData, 1); + }, + buildArmatureDisplay: function buildArmatureDisplay(armatureName, dragonBonesName, skinName, textureAtlasName) { + var armature = this.buildArmature(armatureName, dragonBonesName, skinName, textureAtlasName); + return armature && armature._display; + }, + createArmatureNode: function createArmatureNode(comp, armatureName, node) { + node = node || new cc.Node(); + var display = node.getComponent(dragonBones.ArmatureDisplay); + display || (display = node.addComponent(dragonBones.ArmatureDisplay)); + node.name = armatureName; + display._armatureName = armatureName; + display._N$dragonAsset = comp.dragonAsset; + display._N$dragonAtlasAsset = comp.dragonAtlasAsset; + display._init(); + return display; + }, + _buildTextureAtlasData: function _buildTextureAtlasData(textureAtlasData, textureAtlas) { + textureAtlasData ? textureAtlasData.renderTexture = textureAtlas : textureAtlasData = BaseObject.borrowObject(dragonBones.CCTextureAtlasData); + return textureAtlasData; + }, + _sortSlots: function _sortSlots() { + var slots = this._slots; + var sortedSlots = []; + for (var i = 0, l = slots.length; i < l; i++) { + var slot = slots[i]; + var zOrder = slot._zOrder; + var inserted = false; + for (var j = sortedSlots.length - 1; j >= 0; j--) if (zOrder >= sortedSlots[j]._zOrder) { + sortedSlots.splice(j + 1, 0, slot); + inserted = true; + break; + } + inserted || sortedSlots.unshift(slot); + } + this._slots = sortedSlots; + }, + _buildArmature: function _buildArmature(dataPackage) { + var armature = BaseObject.borrowObject(dragonBones.Armature); + armature._skinData = dataPackage.skin; + armature._animation = BaseObject.borrowObject(dragonBones.Animation); + armature._animation._armature = armature; + armature._animation.animations = dataPackage.armature.animations; + armature._isChildArmature = false; + var display = new dragonBones.CCArmatureDisplay(); + armature.init(dataPackage.armature, display, display, this._dragonBones); + return armature; + }, + _buildSlot: function _buildSlot(dataPackage, slotData, displays) { + var slot = BaseObject.borrowObject(dragonBones.CCSlot); + var display = slot; + slot.init(slotData, displays, display, display); + return slot; + }, + getDragonBonesDataByUUID: function getDragonBonesDataByUUID(uuid) { + for (var name in this._dragonBonesDataMap) if (-1 != name.indexOf(uuid)) return this._dragonBonesDataMap[name]; + return null; + }, + removeDragonBonesDataByUUID: function removeDragonBonesDataByUUID(uuid, disposeData) { + void 0 === disposeData && (disposeData = true); + for (var name in this._dragonBonesDataMap) { + if (-1 === name.indexOf(uuid)) continue; + disposeData && this._dragonBones.bufferObject(this._dragonBonesDataMap[name]); + delete this._dragonBonesDataMap[name]; + } + } + }); + }), {} ], + 419: [ (function(require, module, exports) { + "use strict"; + var _mat = _interopRequireDefault(require("../../cocos2d/core/value-types/mat4")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + var BinaryOffset = dragonBones.BinaryOffset; + var BoneType = dragonBones.BoneType; + dragonBones.CCSlot = cc.Class({ + name: "dragonBones.CCSlot", + extends: dragonBones.Slot, + ctor: function ctor() { + this._localVertices = []; + this._indices = []; + this._matrix = cc.mat4(); + this._worldMatrix = cc.mat4(); + this._worldMatrixDirty = true; + this._visible = false; + this._color = cc.color(); + }, + _onClear: function _onClear() { + this._super(); + this._localVertices.length = 0; + this._indices.length = 0; + _mat["default"].identity(this._matrix); + _mat["default"].identity(this._worldMatrix); + this._worldMatrixDirty = true; + this._color = cc.color(); + this._visible = false; + }, + statics: { + toString: function toString() { + return "[class dragonBones.CCSlot]"; + } + }, + _onUpdateDisplay: function _onUpdateDisplay() {}, + _initDisplay: function _initDisplay(value) {}, + _addDisplay: function _addDisplay() { + this._visible = true; + }, + _replaceDisplay: function _replaceDisplay(value) {}, + _removeDisplay: function _removeDisplay() { + this._visible = false; + }, + _disposeDisplay: function _disposeDisplay(object) {}, + _updateVisible: function _updateVisible() { + this._visible = this.parent._visible; + }, + _updateZOrder: function _updateZOrder() {}, + _updateBlendMode: function _updateBlendMode() { + if (this._childArmature) { + var childSlots = this._childArmature.getSlots(); + for (var i = 0, l = childSlots.length; i < l; i++) { + var slot = childSlots[i]; + slot._blendMode = this._blendMode; + slot._updateBlendMode(); + } + } + }, + _updateColor: function _updateColor() { + var c = this._color; + c.r = 255 * this._colorTransform.redMultiplier; + c.g = 255 * this._colorTransform.greenMultiplier; + c.b = 255 * this._colorTransform.blueMultiplier; + c.a = 255 * this._colorTransform.alphaMultiplier; + }, + getTexture: function getTexture() { + return this._textureData && this._textureData.spriteFrame && this._textureData.spriteFrame.getTexture(); + }, + _updateFrame: function _updateFrame() { + this._indices.length = 0; + var indices = this._indices, localVertices = this._localVertices; + var indexOffset = 0, vfOffset = 0; + var currentTextureData = this._textureData; + if (!this._display || this._displayIndex < 0 || !currentTextureData || !currentTextureData.spriteFrame) return; + var texture = currentTextureData.spriteFrame.getTexture(); + var textureAtlasWidth = texture.width; + var textureAtlasHeight = texture.height; + var region = currentTextureData.region; + var currentVerticesData = null !== this._deformVertices && this._display === this._meshDisplay ? this._deformVertices.verticesData : null; + if (currentVerticesData) { + var data = currentVerticesData.data; + var intArray = data.intArray; + var floatArray = data.floatArray; + var vertexCount = intArray[currentVerticesData.offset + BinaryOffset.MeshVertexCount]; + var triangleCount = intArray[currentVerticesData.offset + BinaryOffset.MeshTriangleCount]; + var vertexOffset = intArray[currentVerticesData.offset + BinaryOffset.MeshFloatOffset]; + vertexOffset < 0 && (vertexOffset += 65536); + var uvOffset = vertexOffset + 2 * vertexCount; + var scale = this._armature._armatureData.scale; + for (var i = 0, l = 2 * vertexCount; i < l; i += 2) { + localVertices[vfOffset++] = floatArray[vertexOffset + i] * scale; + localVertices[vfOffset++] = -floatArray[vertexOffset + i + 1] * scale; + if (currentVerticesData.rotated) { + localVertices[vfOffset++] = (region.x + (1 - floatArray[uvOffset + i]) * region.width) / textureAtlasWidth; + localVertices[vfOffset++] = (region.y + floatArray[uvOffset + i + 1] * region.height) / textureAtlasHeight; + } else { + localVertices[vfOffset++] = (region.x + floatArray[uvOffset + i] * region.width) / textureAtlasWidth; + localVertices[vfOffset++] = (region.y + floatArray[uvOffset + i + 1] * region.height) / textureAtlasHeight; + } + } + for (var _i = 0; _i < 3 * triangleCount; ++_i) indices[indexOffset++] = intArray[currentVerticesData.offset + BinaryOffset.MeshVertexIndices + _i]; + localVertices.length = vfOffset; + indices.length = indexOffset; + var isSkinned = !!currentVerticesData.weight; + isSkinned && this._identityTransform(); + } else { + var _l = region.x / textureAtlasWidth; + var b = (region.y + region.height) / textureAtlasHeight; + var r = (region.x + region.width) / textureAtlasWidth; + var t = region.y / textureAtlasHeight; + localVertices[vfOffset++] = 0; + localVertices[vfOffset++] = 0; + localVertices[vfOffset++] = _l; + localVertices[vfOffset++] = b; + localVertices[vfOffset++] = region.width; + localVertices[vfOffset++] = 0; + localVertices[vfOffset++] = r; + localVertices[vfOffset++] = b; + localVertices[vfOffset++] = 0; + localVertices[vfOffset++] = region.height; + localVertices[vfOffset++] = _l; + localVertices[vfOffset++] = t; + localVertices[vfOffset++] = region.width; + localVertices[vfOffset++] = region.height; + localVertices[vfOffset++] = r; + localVertices[vfOffset++] = t; + indices[0] = 0; + indices[1] = 1; + indices[2] = 2; + indices[3] = 1; + indices[4] = 3; + indices[5] = 2; + localVertices.length = vfOffset; + indices.length = 6; + } + this._visibleDirty = true; + this._blendModeDirty = true; + this._colorDirty = true; + }, + _updateMesh: function _updateMesh() { + var scale = this._armature._armatureData.scale; + var deformVertices = this._deformVertices.vertices; + var bones = this._deformVertices.bones; + var verticesData = this._deformVertices.verticesData; + var weightData = verticesData.weight; + var hasDeform = deformVertices.length > 0 && verticesData.inheritDeform; + var localVertices = this._localVertices; + if (weightData) { + var data = verticesData.data; + var intArray = data.intArray; + var floatArray = data.floatArray; + var vertexCount = intArray[verticesData.offset + BinaryOffset.MeshVertexCount]; + var weightFloatOffset = intArray[weightData.offset + BinaryOffset.WeigthFloatOffset]; + weightFloatOffset < 0 && (weightFloatOffset += 65536); + for (var i = 0, iB = weightData.offset + BinaryOffset.WeigthBoneIndices + bones.length, iV = weightFloatOffset, iF = 0, lvi = 0; i < vertexCount; i++, + lvi += 4) { + var boneCount = intArray[iB++]; + var xG = 0, yG = 0; + for (var j = 0; j < boneCount; ++j) { + var boneIndex = intArray[iB++]; + var bone = bones[boneIndex]; + if (null !== bone) { + var matrix = bone.globalTransformMatrix; + var weight = floatArray[iV++]; + var xL = floatArray[iV++] * scale; + var yL = floatArray[iV++] * scale; + if (hasDeform) { + xL += deformVertices[iF++]; + yL += deformVertices[iF++]; + } + xG += (matrix.a * xL + matrix.c * yL + matrix.tx) * weight; + yG += (matrix.b * xL + matrix.d * yL + matrix.ty) * weight; + } + } + localVertices[lvi] = xG; + localVertices[lvi + 1] = -yG; + } + } else if (hasDeform) { + var isSurface = this._parent._boneData.type !== BoneType.Bone; + var _data = verticesData.data; + var _intArray = _data.intArray; + var _floatArray = _data.floatArray; + var _vertexCount = _intArray[verticesData.offset + BinaryOffset.MeshVertexCount]; + var vertexOffset = _intArray[verticesData.offset + BinaryOffset.MeshFloatOffset]; + vertexOffset < 0 && (vertexOffset += 65536); + for (var _i2 = 0, l = _vertexCount, _lvi = 0; _i2 < l; _i2++, _lvi += 4) { + var x = _floatArray[vertexOffset + 2 * _i2] * scale + deformVertices[2 * _i2]; + var y = _floatArray[vertexOffset + 2 * _i2 + 1] * scale + deformVertices[2 * _i2 + 1]; + if (isSurface) { + var _matrix = this._parent._getGlobalTransformMatrix(x, y); + localVertices[_lvi] = _matrix.a * x + _matrix.c * y + _matrix.tx; + localVertices[_lvi + 1] = -_matrix.b * x + _matrix.d * y + _matrix.ty; + } else { + localVertices[_lvi] = x; + localVertices[_lvi + 1] = -y; + } + } + } + weightData && this._identityTransform(); + }, + _identityTransform: function _identityTransform() { + var m = this._matrix.m; + m[0] = 1; + m[1] = 0; + m[4] = -0; + m[5] = -1; + m[12] = 0; + m[13] = 0; + this._worldMatrixDirty = true; + }, + _updateTransform: function _updateTransform() { + var t = this._matrix; + var tm = t.m; + tm[0] = this.globalTransformMatrix.a; + tm[1] = this.globalTransformMatrix.b; + tm[4] = -this.globalTransformMatrix.c; + tm[5] = -this.globalTransformMatrix.d; + if (this._childArmature) { + tm[12] = this.globalTransformMatrix.tx; + tm[13] = this.globalTransformMatrix.ty; + } else { + tm[12] = this.globalTransformMatrix.tx - (this.globalTransformMatrix.a * this._pivotX - this.globalTransformMatrix.c * this._pivotY); + tm[13] = this.globalTransformMatrix.ty - (this.globalTransformMatrix.b * this._pivotX - this.globalTransformMatrix.d * this._pivotY); + } + this._worldMatrixDirty = true; + }, + updateWorldMatrix: function updateWorldMatrix() { + if (!this._armature) return; + var parentSlot = this._armature._parent; + parentSlot && parentSlot.updateWorldMatrix(); + if (this._worldMatrixDirty) { + this.calculWorldMatrix(); + var childArmature = this.childArmature; + if (!childArmature) return; + var slots = childArmature.getSlots(); + for (var i = 0, n = slots.length; i < n; i++) { + var slot = slots[i]; + slot && (slot._worldMatrixDirty = true); + } + } + }, + _mulMat: function _mulMat(out, a, b) { + var am = a.m, bm = b.m, outm = out.m; + var aa = am[0], ab = am[1], ac = am[4], ad = am[5], atx = am[12], aty = am[13]; + var ba = bm[0], bb = bm[1], bc = bm[4], bd = bm[5], btx = bm[12], bty = bm[13]; + if (0 !== ab || 0 !== ac) { + outm[0] = ba * aa + bb * ac; + outm[1] = ba * ab + bb * ad; + outm[4] = bc * aa + bd * ac; + outm[5] = bc * ab + bd * ad; + outm[12] = aa * btx + ac * bty + atx; + outm[13] = ab * btx + ad * bty + aty; + } else { + outm[0] = ba * aa; + outm[1] = bb * ad; + outm[4] = bc * aa; + outm[5] = bd * ad; + outm[12] = aa * btx + atx; + outm[13] = ad * bty + aty; + } + }, + calculWorldMatrix: function calculWorldMatrix() { + var parent = this._armature._parent; + parent ? this._mulMat(this._worldMatrix, parent._worldMatrix, this._matrix) : _mat["default"].copy(this._worldMatrix, this._matrix); + this._worldMatrixDirty = false; + } + }); + }), { + "../../cocos2d/core/value-types/mat4": 342 + } ], + 420: [ (function(require, module, exports) { + "use strict"; + dragonBones.CCTextureAtlasData = cc.Class({ + extends: dragonBones.TextureAtlasData, + name: "dragonBones.CCTextureAtlasData", + properties: { + _renderTexture: { + default: null, + serializable: false + }, + renderTexture: { + get: function get() { + return this._renderTexture; + }, + set: function set(value) { + this._renderTexture = value; + if (value) for (var k in this.textures) { + var textureData = this.textures[k]; + if (!textureData.spriteFrame) { + var rect = null; + rect = textureData.rotated ? cc.rect(textureData.region.x, textureData.region.y, textureData.region.height, textureData.region.width) : cc.rect(textureData.region.x, textureData.region.y, textureData.region.width, textureData.region.height); + var offset = cc.v2(0, 0); + var size = cc.size(rect.width, rect.height); + textureData.spriteFrame = new cc.SpriteFrame(); + textureData.spriteFrame.setTexture(value, rect, false, offset, size); + } + } else for (var _k in this.textures) { + var _textureData = this.textures[_k]; + _textureData.spriteFrame = null; + } + } + } + }, + statics: { + toString: function toString() { + return "[class dragonBones.CCTextureAtlasData]"; + } + }, + _onClear: function _onClear() { + dragonBones.TextureAtlasData.prototype._onClear.call(this); + this.renderTexture = null; + }, + createTexture: function createTexture() { + return dragonBones.BaseObject.borrowObject(dragonBones.CCTextureData); + } + }); + dragonBones.CCTextureData = cc.Class({ + extends: dragonBones.TextureData, + name: "dragonBones.CCTextureData", + properties: { + spriteFrame: { + default: null, + serializable: false + } + }, + statics: { + toString: function toString() { + return "[class dragonBones.CCTextureData]"; + } + }, + _onClear: function _onClear() { + dragonBones.TextureData.prototype._onClear.call(this); + this.spriteFrame = null; + } + }); + }), {} ], + 421: [ (function(require, module, exports) { + "use strict"; + var ArmatureCache = (true, require("./ArmatureCache").sharedCache); + var DragonBonesAsset = cc.Class({ + name: "dragonBones.DragonBonesAsset", + extends: cc.Asset, + ctor: function ctor() { + this.reset(); + }, + properties: { + _dragonBonesJson: "", + dragonBonesJson: { + get: function get() { + return this._dragonBonesJson; + }, + set: function set(value) { + this._dragonBonesJson = value; + this._dragonBonesJsonData = JSON.parse(value); + this.reset(); + } + }, + _nativeAsset: { + get: function get() { + return this._buffer; + }, + set: function set(bin) { + this._buffer = bin.buffer || bin; + this.reset(); + }, + override: true + } + }, + statics: { + preventDeferredLoadDependents: true + }, + createNode: false, + reset: function reset() { + this._clear(); + false; + }, + init: function init(factory, atlasUUID) { + false; + this._factory = factory; + !this._dragonBonesJsonData && this.dragonBonesJson && (this._dragonBonesJsonData = JSON.parse(this.dragonBonesJson)); + var rawData = null; + rawData = this._dragonBonesJsonData ? this._dragonBonesJsonData : this._nativeAsset; + if (!this._uuid) { + var dbData = this._factory.getDragonBonesDataByRawData(rawData); + dbData ? this._uuid = dbData.name : cc.warn("dragonbones name is empty"); + } + var armatureKey = this._uuid + "#" + atlasUUID; + var dragonBonesData = this._factory.getDragonBonesData(armatureKey); + if (dragonBonesData) return armatureKey; + this._factory.parseDragonBonesData(rawData, armatureKey); + return armatureKey; + }, + getArmatureEnum: false, + getAnimsEnum: false, + _clear: function _clear() { + if (this._factory) { + ArmatureCache.resetArmature(this._uuid); + this._factory.removeDragonBonesDataByUUID(this._uuid, true); + } + }, + destroy: function destroy() { + this._clear(); + this._super(); + } + }); + dragonBones.DragonBonesAsset = module.exports = DragonBonesAsset; + }), { + "./ArmatureCache": 414 + } ], + 422: [ (function(require, module, exports) { + "use strict"; + var ArmatureCache = (true, require("./ArmatureCache").sharedCache); + var DragonBonesAtlasAsset = cc.Class({ + name: "dragonBones.DragonBonesAtlasAsset", + extends: cc.Asset, + ctor: function ctor() { + this._clear(); + }, + properties: { + _atlasJson: "", + atlasJson: { + get: function get() { + return this._atlasJson; + }, + set: function set(value) { + this._atlasJson = value; + this._atlasJsonData = JSON.parse(this.atlasJson); + this._clear(); + } + }, + _texture: { + default: null, + type: cc.Texture2D, + formerlySerializedAs: "texture" + }, + texture: { + get: function get() { + return this._texture; + }, + set: function set(value) { + this._texture = value; + this._clear(); + } + }, + _textureAtlasData: null + }, + statics: { + preventDeferredLoadDependents: true + }, + createNode: false, + init: function init(factory) { + this._factory = factory; + this._atlasJsonData || (this._atlasJsonData = JSON.parse(this.atlasJson)); + var atlasJsonObj = this._atlasJsonData; + this._uuid = this._uuid || atlasJsonObj.name; + this._textureAtlasData ? factory.addTextureAtlasData(this._textureAtlasData, this._uuid) : this._textureAtlasData = factory.parseTextureAtlasData(atlasJsonObj, this.texture, this._uuid); + }, + _clear: function _clear() { + false; + if (this._factory) { + ArmatureCache.resetArmature(this._uuid); + this._factory.removeTextureAtlasData(this._uuid, true); + this._factory.removeDragonBonesDataByUUID(this._uuid, true); + } + this._textureAtlasData = null; + }, + destroy: function destroy() { + this._clear(); + this._super(); + } + }); + dragonBones.DragonBonesAtlasAsset = module.exports = DragonBonesAtlasAsset; + }), { + "./ArmatureCache": 414 + } ], + 423: [ (function(require, module, exports) { + "use strict"; + var _global = "undefined" === typeof window ? global : window; + true; + _global.dragonBones = require("./lib/dragonBones"); + if (void 0 !== _global.dragonBones) { + dragonBones._timeScale = 1; + Object.defineProperty(dragonBones, "timeScale", { + get: function get() { + return this._timeScale; + }, + set: function set(value) { + this._timeScale = value; + var factory = this.CCFactory.getInstance(); + factory._dragonBones.clock.timeScale = value; + }, + configurable: true + }); + dragonBones.DisplayType = { + Image: 0, + Armature: 1, + Mesh: 2 + }; + dragonBones.ArmatureType = { + Armature: 0, + MovieClip: 1, + Stage: 2 + }; + dragonBones.ExtensionType = { + FFD: 0, + AdjustColor: 10, + BevelFilter: 11, + BlurFilter: 12, + DropShadowFilter: 13, + GlowFilter: 14, + GradientBevelFilter: 15, + GradientGlowFilter: 16 + }; + dragonBones.EventType = { + Frame: 0, + Sound: 1 + }; + dragonBones.ActionType = { + Play: 0, + Stop: 1, + GotoAndPlay: 2, + GotoAndStop: 3, + FadeIn: 4, + FadeOut: 5 + }; + dragonBones.AnimationFadeOutMode = { + None: 0, + SameLayer: 1, + SameGroup: 2, + SameLayerAndGroup: 3, + All: 4 + }; + dragonBones.BinaryOffset = { + WeigthBoneCount: 0, + WeigthFloatOffset: 1, + WeigthBoneIndices: 2, + MeshVertexCount: 0, + MeshTriangleCount: 1, + MeshFloatOffset: 2, + MeshWeightOffset: 3, + MeshVertexIndices: 4, + TimelineScale: 0, + TimelineOffset: 1, + TimelineKeyFrameCount: 2, + TimelineFrameValueCount: 3, + TimelineFrameValueOffset: 4, + TimelineFrameOffset: 5, + FramePosition: 0, + FrameTweenType: 1, + FrameTweenEasingOrCurveSampleCount: 2, + FrameCurveSamples: 3, + DeformMeshOffset: 0, + DeformCount: 1, + DeformValueCount: 2, + DeformValueOffset: 3, + DeformFloatOffset: 4 + }; + dragonBones.BoneType = { + Bone: 0, + Surface: 1 + }; + true; + true; + require("./CCFactory"); + require("./CCSlot"); + require("./CCTextureData"); + require("./CCArmatureDisplay"); + require("./ArmatureCache"); + require("./DragonBonesAsset"); + require("./DragonBonesAtlasAsset"); + require("./ArmatureDisplay"); + require("./webgl-assembler"); + } + }), { + "./ArmatureCache": 414, + "./ArmatureDisplay": 415, + "./CCArmatureDisplay": 417, + "./CCFactory": 418, + "./CCSlot": 419, + "./CCTextureData": 420, + "./DragonBonesAsset": 421, + "./DragonBonesAtlasAsset": 422, + "./lib/dragonBones": 424, + "./webgl-assembler": 425 + } ], + 424: [ (function(require, module, exports) { + "use strict"; + var __extends = (void 0, (function() { + var extendStatics = Object.setPrototypeOf || { + __proto__: [] + } instanceof Array && function(d, b) { + d.__proto__ = b; + } || function(d, b) { + for (var p in b) b.hasOwnProperty(p) && (d[p] = b[p]); + }; + return function(d, b) { + extendStatics(d, b); + function __() { + this.constructor = d; + } + d.prototype = null === b ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + })()); + var dragonBones; + (function(dragonBones) {})(dragonBones || (dragonBones = {})); + var dragonBones; + (function(dragonBones) { + var DragonBones = (function() { + function DragonBones(eventManager) { + this._clock = new dragonBones.WorldClock(); + this._events = []; + this._objects = []; + this._eventManager = null; + this._eventManager = eventManager; + console.info("DragonBones: " + DragonBones.VERSION + "\nWebsite: http://dragonbones.com/\nSource and Demo: https://github.com/DragonBones/"); + } + DragonBones.prototype.advanceTime = function(passedTime) { + if (this._objects.length > 0) { + for (var _i = 0, _a = this._objects; _i < _a.length; _i++) { + var object = _a[_i]; + object.returnToPool(); + } + this._objects.length = 0; + } + this._clock.advanceTime(passedTime); + if (this._events.length > 0) { + for (var i = 0; i < this._events.length; ++i) { + var eventObject = this._events[i]; + var armature = eventObject.armature; + if (null !== armature._armatureData) { + armature.eventDispatcher.dispatchDBEvent(eventObject.type, eventObject); + eventObject.type === dragonBones.EventObject.SOUND_EVENT && this._eventManager.dispatchDBEvent(eventObject.type, eventObject); + } + this.bufferObject(eventObject); + } + this._events.length = 0; + } + }; + DragonBones.prototype.bufferEvent = function(value) { + this._events.indexOf(value) < 0 && this._events.push(value); + }; + DragonBones.prototype.bufferObject = function(object) { + this._objects.indexOf(object) < 0 && this._objects.push(object); + }; + Object.defineProperty(DragonBones.prototype, "clock", { + get: function get() { + return this._clock; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(DragonBones.prototype, "eventManager", { + get: function get() { + return this._eventManager; + }, + enumerable: true, + configurable: true + }); + DragonBones.VERSION = "5.6.300"; + DragonBones.yDown = false; + DragonBones.debug = false; + DragonBones.debugDraw = false; + DragonBones.webAssembly = false; + return DragonBones; + })(); + dragonBones.DragonBones = DragonBones; + })(dragonBones || (dragonBones = {})); + console.warn || (console.warn = function() {}); + console.assert || (console.assert = function() {}); + Date.now || (Date.now = function now() { + return new Date().getTime(); + }); + var __extends = function __extends(t, e) { + function r() { + this.constructor = t; + } + for (var i in e) e.hasOwnProperty(i) && (t[i] = e[i]); + r.prototype = e.prototype, t.prototype = new r(); + }; + var dragonBones; + (function(dragonBones) { + var BaseObject = (function() { + function BaseObject() { + this.hashCode = BaseObject._hashCode++; + this._isInPool = false; + } + BaseObject._returnObject = function(object) { + var classType = String(object.constructor); + var maxCount = classType in BaseObject._maxCountMap ? BaseObject._maxCountMap[classType] : BaseObject._defaultMaxCount; + var pool = BaseObject._poolsMap[classType] = BaseObject._poolsMap[classType] || []; + if (pool.length < maxCount) if (object._isInPool) console.warn("The object is already in the pool."); else { + object._isInPool = true; + pool.push(object); + } + }; + BaseObject.toString = function() { + throw new Error(); + }; + BaseObject.setMaxCount = function(objectConstructor, maxCount) { + (maxCount < 0 || maxCount !== maxCount) && (maxCount = 0); + if (null !== objectConstructor) { + var classType = String(objectConstructor); + var pool = classType in BaseObject._poolsMap ? BaseObject._poolsMap[classType] : null; + null !== pool && pool.length > maxCount && (pool.length = maxCount); + BaseObject._maxCountMap[classType] = maxCount; + } else { + BaseObject._defaultMaxCount = maxCount; + for (var classType in BaseObject._poolsMap) { + var pool = BaseObject._poolsMap[classType]; + pool.length > maxCount && (pool.length = maxCount); + classType in BaseObject._maxCountMap && (BaseObject._maxCountMap[classType] = maxCount); + } + } + }; + BaseObject.clearPool = function(objectConstructor) { + void 0 === objectConstructor && (objectConstructor = null); + if (null !== objectConstructor) { + var classType = String(objectConstructor); + var pool = classType in BaseObject._poolsMap ? BaseObject._poolsMap[classType] : null; + null !== pool && pool.length > 0 && (pool.length = 0); + } else for (var k in BaseObject._poolsMap) { + var pool = BaseObject._poolsMap[k]; + pool.length = 0; + } + }; + BaseObject.borrowObject = function(objectConstructor) { + var classType = String(objectConstructor); + var pool = classType in BaseObject._poolsMap ? BaseObject._poolsMap[classType] : null; + if (null !== pool && pool.length > 0) { + var object_1 = pool.pop(); + object_1._isInPool = false; + return object_1; + } + var object = new objectConstructor(); + object._onClear(); + return object; + }; + BaseObject.prototype.returnToPool = function() { + this._onClear(); + BaseObject._returnObject(this); + }; + BaseObject._hashCode = 0; + BaseObject._defaultMaxCount = 3e3; + BaseObject._maxCountMap = {}; + BaseObject._poolsMap = {}; + return BaseObject; + })(); + dragonBones.BaseObject = BaseObject; + })(dragonBones || (dragonBones = {})); + var dragonBones; + (function(dragonBones) { + var Matrix = (function() { + function Matrix(a, b, c, d, tx, ty) { + void 0 === a && (a = 1); + void 0 === b && (b = 0); + void 0 === c && (c = 0); + void 0 === d && (d = 1); + void 0 === tx && (tx = 0); + void 0 === ty && (ty = 0); + this.a = a; + this.b = b; + this.c = c; + this.d = d; + this.tx = tx; + this.ty = ty; + } + Matrix.prototype.toString = function() { + return "[object dragonBones.Matrix] a:" + this.a + " b:" + this.b + " c:" + this.c + " d:" + this.d + " tx:" + this.tx + " ty:" + this.ty; + }; + Matrix.prototype.copyFrom = function(value) { + this.a = value.a; + this.b = value.b; + this.c = value.c; + this.d = value.d; + this.tx = value.tx; + this.ty = value.ty; + return this; + }; + Matrix.prototype.copyFromArray = function(value, offset) { + void 0 === offset && (offset = 0); + this.a = value[offset]; + this.b = value[offset + 1]; + this.c = value[offset + 2]; + this.d = value[offset + 3]; + this.tx = value[offset + 4]; + this.ty = value[offset + 5]; + return this; + }; + Matrix.prototype.identity = function() { + this.a = this.d = 1; + this.b = this.c = 0; + this.tx = this.ty = 0; + return this; + }; + Matrix.prototype.concat = function(value) { + var aA = this.a * value.a; + var bA = 0; + var cA = 0; + var dA = this.d * value.d; + var txA = this.tx * value.a + value.tx; + var tyA = this.ty * value.d + value.ty; + if (0 !== this.b || 0 !== this.c) { + aA += this.b * value.c; + bA += this.b * value.d; + cA += this.c * value.a; + dA += this.c * value.b; + } + if (0 !== value.b || 0 !== value.c) { + bA += this.a * value.b; + cA += this.d * value.c; + txA += this.ty * value.c; + tyA += this.tx * value.b; + } + this.a = aA; + this.b = bA; + this.c = cA; + this.d = dA; + this.tx = txA; + this.ty = tyA; + return this; + }; + Matrix.prototype.invert = function() { + var aA = this.a; + var bA = this.b; + var cA = this.c; + var dA = this.d; + var txA = this.tx; + var tyA = this.ty; + if (0 === bA && 0 === cA) { + this.b = this.c = 0; + if (0 === aA || 0 === dA) this.a = this.b = this.tx = this.ty = 0; else { + aA = this.a = 1 / aA; + dA = this.d = 1 / dA; + this.tx = -aA * txA; + this.ty = -dA * tyA; + } + return this; + } + var determinant = aA * dA - bA * cA; + if (0 === determinant) { + this.a = this.d = 1; + this.b = this.c = 0; + this.tx = this.ty = 0; + return this; + } + determinant = 1 / determinant; + var k = this.a = dA * determinant; + bA = this.b = -bA * determinant; + cA = this.c = -cA * determinant; + dA = this.d = aA * determinant; + this.tx = -(k * txA + cA * tyA); + this.ty = -(bA * txA + dA * tyA); + return this; + }; + Matrix.prototype.transformPoint = function(x, y, result, delta) { + void 0 === delta && (delta = false); + result.x = this.a * x + this.c * y; + result.y = this.b * x + this.d * y; + if (!delta) { + result.x += this.tx; + result.y += this.ty; + } + }; + Matrix.prototype.transformRectangle = function(rectangle, delta) { + void 0 === delta && (delta = false); + var a = this.a; + var b = this.b; + var c = this.c; + var d = this.d; + var tx = delta ? 0 : this.tx; + var ty = delta ? 0 : this.ty; + var x = rectangle.x; + var y = rectangle.y; + var xMax = x + rectangle.width; + var yMax = y + rectangle.height; + var x0 = a * x + c * y + tx; + var y0 = b * x + d * y + ty; + var x1 = a * xMax + c * y + tx; + var y1 = b * xMax + d * y + ty; + var x2 = a * xMax + c * yMax + tx; + var y2 = b * xMax + d * yMax + ty; + var x3 = a * x + c * yMax + tx; + var y3 = b * x + d * yMax + ty; + var tmp = 0; + if (x0 > x1) { + tmp = x0; + x0 = x1; + x1 = tmp; + } + if (x2 > x3) { + tmp = x2; + x2 = x3; + x3 = tmp; + } + rectangle.x = Math.floor(x0 < x2 ? x0 : x2); + rectangle.width = Math.ceil((x1 > x3 ? x1 : x3) - rectangle.x); + if (y0 > y1) { + tmp = y0; + y0 = y1; + y1 = tmp; + } + if (y2 > y3) { + tmp = y2; + y2 = y3; + y3 = tmp; + } + rectangle.y = Math.floor(y0 < y2 ? y0 : y2); + rectangle.height = Math.ceil((y1 > y3 ? y1 : y3) - rectangle.y); + }; + return Matrix; + })(); + dragonBones.Matrix = Matrix; + })(dragonBones || (dragonBones = {})); + var dragonBones; + (function(dragonBones) { + var Transform = (function() { + function Transform(x, y, skew, rotation, scaleX, scaleY) { + void 0 === x && (x = 0); + void 0 === y && (y = 0); + void 0 === skew && (skew = 0); + void 0 === rotation && (rotation = 0); + void 0 === scaleX && (scaleX = 1); + void 0 === scaleY && (scaleY = 1); + this.x = x; + this.y = y; + this.skew = skew; + this.rotation = rotation; + this.scaleX = scaleX; + this.scaleY = scaleY; + } + Transform.normalizeRadian = function(value) { + value = (value + Math.PI) % (2 * Math.PI); + value += value > 0 ? -Math.PI : Math.PI; + return value; + }; + Transform.prototype.toString = function() { + return "[object dragonBones.Transform] x:" + this.x + " y:" + this.y + " skewX:" + 180 * this.skew / Math.PI + " skewY:" + 180 * this.rotation / Math.PI + " scaleX:" + this.scaleX + " scaleY:" + this.scaleY; + }; + Transform.prototype.copyFrom = function(value) { + this.x = value.x; + this.y = value.y; + this.skew = value.skew; + this.rotation = value.rotation; + this.scaleX = value.scaleX; + this.scaleY = value.scaleY; + return this; + }; + Transform.prototype.identity = function() { + this.x = this.y = 0; + this.skew = this.rotation = 0; + this.scaleX = this.scaleY = 1; + return this; + }; + Transform.prototype.add = function(value) { + this.x += value.x; + this.y += value.y; + this.skew += value.skew; + this.rotation += value.rotation; + this.scaleX *= value.scaleX; + this.scaleY *= value.scaleY; + return this; + }; + Transform.prototype.minus = function(value) { + this.x -= value.x; + this.y -= value.y; + this.skew -= value.skew; + this.rotation -= value.rotation; + this.scaleX /= value.scaleX; + this.scaleY /= value.scaleY; + return this; + }; + Transform.prototype.fromMatrix = function(matrix) { + var backupScaleX = this.scaleX, backupScaleY = this.scaleY; + var PI_Q = Transform.PI_Q; + this.x = matrix.tx; + this.y = matrix.ty; + this.rotation = Math.atan(matrix.b / matrix.a); + var skewX = Math.atan(-matrix.c / matrix.d); + this.scaleX = this.rotation > -PI_Q && this.rotation < PI_Q ? matrix.a / Math.cos(this.rotation) : matrix.b / Math.sin(this.rotation); + this.scaleY = skewX > -PI_Q && skewX < PI_Q ? matrix.d / Math.cos(skewX) : -matrix.c / Math.sin(skewX); + if (backupScaleX >= 0 && this.scaleX < 0) { + this.scaleX = -this.scaleX; + this.rotation = this.rotation - Math.PI; + } + if (backupScaleY >= 0 && this.scaleY < 0) { + this.scaleY = -this.scaleY; + skewX -= Math.PI; + } + this.skew = skewX - this.rotation; + return this; + }; + Transform.prototype.toMatrix = function(matrix) { + if (0 === this.rotation) { + matrix.a = 1; + matrix.b = 0; + } else { + matrix.a = Math.cos(this.rotation); + matrix.b = Math.sin(this.rotation); + } + if (0 === this.skew) { + matrix.c = -matrix.b; + matrix.d = matrix.a; + } else { + matrix.c = -Math.sin(this.skew + this.rotation); + matrix.d = Math.cos(this.skew + this.rotation); + } + if (1 !== this.scaleX) { + matrix.a *= this.scaleX; + matrix.b *= this.scaleX; + } + if (1 !== this.scaleY) { + matrix.c *= this.scaleY; + matrix.d *= this.scaleY; + } + matrix.tx = this.x; + matrix.ty = this.y; + return this; + }; + Transform.PI = Math.PI; + Transform.PI_D = 2 * Math.PI; + Transform.PI_H = Math.PI / 2; + Transform.PI_Q = Math.PI / 4; + Transform.RAD_DEG = 180 / Math.PI; + Transform.DEG_RAD = Math.PI / 180; + return Transform; + })(); + dragonBones.Transform = Transform; + })(dragonBones || (dragonBones = {})); + var dragonBones; + (function(dragonBones) { + var ColorTransform = (function() { + function ColorTransform(alphaMultiplier, redMultiplier, greenMultiplier, blueMultiplier, alphaOffset, redOffset, greenOffset, blueOffset) { + void 0 === alphaMultiplier && (alphaMultiplier = 1); + void 0 === redMultiplier && (redMultiplier = 1); + void 0 === greenMultiplier && (greenMultiplier = 1); + void 0 === blueMultiplier && (blueMultiplier = 1); + void 0 === alphaOffset && (alphaOffset = 0); + void 0 === redOffset && (redOffset = 0); + void 0 === greenOffset && (greenOffset = 0); + void 0 === blueOffset && (blueOffset = 0); + this.alphaMultiplier = alphaMultiplier; + this.redMultiplier = redMultiplier; + this.greenMultiplier = greenMultiplier; + this.blueMultiplier = blueMultiplier; + this.alphaOffset = alphaOffset; + this.redOffset = redOffset; + this.greenOffset = greenOffset; + this.blueOffset = blueOffset; + } + ColorTransform.prototype.copyFrom = function(value) { + this.alphaMultiplier = value.alphaMultiplier; + this.redMultiplier = value.redMultiplier; + this.greenMultiplier = value.greenMultiplier; + this.blueMultiplier = value.blueMultiplier; + this.alphaOffset = value.alphaOffset; + this.redOffset = value.redOffset; + this.greenOffset = value.greenOffset; + this.blueOffset = value.blueOffset; + }; + ColorTransform.prototype.identity = function() { + this.alphaMultiplier = this.redMultiplier = this.greenMultiplier = this.blueMultiplier = 1; + this.alphaOffset = this.redOffset = this.greenOffset = this.blueOffset = 0; + }; + return ColorTransform; + })(); + dragonBones.ColorTransform = ColorTransform; + })(dragonBones || (dragonBones = {})); + var dragonBones; + (function(dragonBones) { + var Point = (function() { + function Point(x, y) { + void 0 === x && (x = 0); + void 0 === y && (y = 0); + this.x = x; + this.y = y; + } + Point.prototype.copyFrom = function(value) { + this.x = value.x; + this.y = value.y; + }; + Point.prototype.clear = function() { + this.x = this.y = 0; + }; + return Point; + })(); + dragonBones.Point = Point; + })(dragonBones || (dragonBones = {})); + var dragonBones; + (function(dragonBones) { + var Rectangle = (function() { + function Rectangle(x, y, width, height) { + void 0 === x && (x = 0); + void 0 === y && (y = 0); + void 0 === width && (width = 0); + void 0 === height && (height = 0); + this.x = x; + this.y = y; + this.width = width; + this.height = height; + } + Rectangle.prototype.copyFrom = function(value) { + this.x = value.x; + this.y = value.y; + this.width = value.width; + this.height = value.height; + }; + Rectangle.prototype.clear = function() { + this.x = this.y = 0; + this.width = this.height = 0; + }; + return Rectangle; + })(); + dragonBones.Rectangle = Rectangle; + })(dragonBones || (dragonBones = {})); + var dragonBones; + (function(dragonBones) { + var UserData = (function(_super) { + __extends(UserData, _super); + function UserData() { + var _this = null !== _super && _super.apply(this, arguments) || this; + _this.ints = []; + _this.floats = []; + _this.strings = []; + return _this; + } + UserData.toString = function() { + return "[class dragonBones.UserData]"; + }; + UserData.prototype._onClear = function() { + this.ints.length = 0; + this.floats.length = 0; + this.strings.length = 0; + }; + UserData.prototype.addInt = function(value) { + this.ints.push(value); + }; + UserData.prototype.addFloat = function(value) { + this.floats.push(value); + }; + UserData.prototype.addString = function(value) { + this.strings.push(value); + }; + UserData.prototype.getInt = function(index) { + void 0 === index && (index = 0); + return index >= 0 && index < this.ints.length ? this.ints[index] : 0; + }; + UserData.prototype.getFloat = function(index) { + void 0 === index && (index = 0); + return index >= 0 && index < this.floats.length ? this.floats[index] : 0; + }; + UserData.prototype.getString = function(index) { + void 0 === index && (index = 0); + return index >= 0 && index < this.strings.length ? this.strings[index] : ""; + }; + return UserData; + })(dragonBones.BaseObject); + dragonBones.UserData = UserData; + var ActionData = (function(_super) { + __extends(ActionData, _super); + function ActionData() { + var _this = null !== _super && _super.apply(this, arguments) || this; + _this.data = null; + return _this; + } + ActionData.toString = function() { + return "[class dragonBones.ActionData]"; + }; + ActionData.prototype._onClear = function() { + null !== this.data && this.data.returnToPool(); + this.type = 0; + this.name = ""; + this.bone = null; + this.slot = null; + this.data = null; + }; + return ActionData; + })(dragonBones.BaseObject); + dragonBones.ActionData = ActionData; + })(dragonBones || (dragonBones = {})); + var dragonBones; + (function(dragonBones) { + var DragonBonesData = (function(_super) { + __extends(DragonBonesData, _super); + function DragonBonesData() { + var _this = null !== _super && _super.apply(this, arguments) || this; + _this.frameIndices = []; + _this.cachedFrames = []; + _this.armatureNames = []; + _this.armatures = {}; + _this.userData = null; + return _this; + } + DragonBonesData.toString = function() { + return "[class dragonBones.DragonBonesData]"; + }; + DragonBonesData.prototype._onClear = function() { + for (var k in this.armatures) { + this.armatures[k].returnToPool(); + delete this.armatures[k]; + } + null !== this.userData && this.userData.returnToPool(); + this.autoSearch = false; + this.frameRate = 0; + this.version = ""; + this.name = ""; + this.stage = null; + this.frameIndices.length = 0; + this.cachedFrames.length = 0; + this.armatureNames.length = 0; + this.binary = null; + this.intArray = null; + this.floatArray = null; + this.frameIntArray = null; + this.frameFloatArray = null; + this.frameArray = null; + this.timelineArray = null; + this.userData = null; + }; + DragonBonesData.prototype.addArmature = function(value) { + if (value.name in this.armatures) { + console.warn("Same armature: " + value.name); + return; + } + value.parent = this; + this.armatures[value.name] = value; + this.armatureNames.push(value.name); + }; + DragonBonesData.prototype.getArmature = function(armatureName) { + return armatureName in this.armatures ? this.armatures[armatureName] : null; + }; + DragonBonesData.prototype.dispose = function() { + console.warn("\u5df2\u5e9f\u5f03"); + this.returnToPool(); + }; + return DragonBonesData; + })(dragonBones.BaseObject); + dragonBones.DragonBonesData = DragonBonesData; + })(dragonBones || (dragonBones = {})); + var dragonBones; + (function(dragonBones) { + var ArmatureData = (function(_super) { + __extends(ArmatureData, _super); + function ArmatureData() { + var _this = null !== _super && _super.apply(this, arguments) || this; + _this.aabb = new dragonBones.Rectangle(); + _this.animationNames = []; + _this.sortedBones = []; + _this.sortedSlots = []; + _this.defaultActions = []; + _this.actions = []; + _this.bones = {}; + _this.slots = {}; + _this.constraints = {}; + _this.skins = {}; + _this.animations = {}; + _this.canvas = null; + _this.userData = null; + return _this; + } + ArmatureData.toString = function() { + return "[class dragonBones.ArmatureData]"; + }; + ArmatureData.prototype._onClear = function() { + for (var _i = 0, _a = this.defaultActions; _i < _a.length; _i++) { + var action = _a[_i]; + action.returnToPool(); + } + for (var _b = 0, _c = this.actions; _b < _c.length; _b++) { + var action = _c[_b]; + action.returnToPool(); + } + for (var k in this.bones) { + this.bones[k].returnToPool(); + delete this.bones[k]; + } + for (var k in this.slots) { + this.slots[k].returnToPool(); + delete this.slots[k]; + } + for (var k in this.constraints) { + this.constraints[k].returnToPool(); + delete this.constraints[k]; + } + for (var k in this.skins) { + this.skins[k].returnToPool(); + delete this.skins[k]; + } + for (var k in this.animations) { + this.animations[k].returnToPool(); + delete this.animations[k]; + } + null !== this.canvas && this.canvas.returnToPool(); + null !== this.userData && this.userData.returnToPool(); + this.type = 0; + this.frameRate = 0; + this.cacheFrameRate = 0; + this.scale = 1; + this.name = ""; + this.aabb.clear(); + this.animationNames.length = 0; + this.sortedBones.length = 0; + this.sortedSlots.length = 0; + this.defaultActions.length = 0; + this.actions.length = 0; + this.defaultSkin = null; + this.defaultAnimation = null; + this.canvas = null; + this.userData = null; + this.parent = null; + }; + ArmatureData.prototype.sortBones = function() { + var total = this.sortedBones.length; + if (total <= 0) return; + var sortHelper = this.sortedBones.concat(); + var index = 0; + var count = 0; + this.sortedBones.length = 0; + while (count < total) { + var bone = sortHelper[index++]; + index >= total && (index = 0); + if (this.sortedBones.indexOf(bone) >= 0) continue; + var flag = false; + for (var k in this.constraints) { + var constraint = this.constraints[k]; + if (constraint.root === bone && this.sortedBones.indexOf(constraint.target) < 0) { + flag = true; + break; + } + } + if (flag) continue; + if (null !== bone.parent && this.sortedBones.indexOf(bone.parent) < 0) continue; + this.sortedBones.push(bone); + count++; + } + }; + ArmatureData.prototype.cacheFrames = function(frameRate) { + if (this.cacheFrameRate > 0) return; + this.cacheFrameRate = frameRate; + for (var k in this.animations) this.animations[k].cacheFrames(this.cacheFrameRate); + }; + ArmatureData.prototype.setCacheFrame = function(globalTransformMatrix, transform) { + var dataArray = this.parent.cachedFrames; + var arrayOffset = dataArray.length; + dataArray.length += 10; + dataArray[arrayOffset] = globalTransformMatrix.a; + dataArray[arrayOffset + 1] = globalTransformMatrix.b; + dataArray[arrayOffset + 2] = globalTransformMatrix.c; + dataArray[arrayOffset + 3] = globalTransformMatrix.d; + dataArray[arrayOffset + 4] = globalTransformMatrix.tx; + dataArray[arrayOffset + 5] = globalTransformMatrix.ty; + dataArray[arrayOffset + 6] = transform.rotation; + dataArray[arrayOffset + 7] = transform.skew; + dataArray[arrayOffset + 8] = transform.scaleX; + dataArray[arrayOffset + 9] = transform.scaleY; + return arrayOffset; + }; + ArmatureData.prototype.getCacheFrame = function(globalTransformMatrix, transform, arrayOffset) { + var dataArray = this.parent.cachedFrames; + globalTransformMatrix.a = dataArray[arrayOffset]; + globalTransformMatrix.b = dataArray[arrayOffset + 1]; + globalTransformMatrix.c = dataArray[arrayOffset + 2]; + globalTransformMatrix.d = dataArray[arrayOffset + 3]; + globalTransformMatrix.tx = dataArray[arrayOffset + 4]; + globalTransformMatrix.ty = dataArray[arrayOffset + 5]; + transform.rotation = dataArray[arrayOffset + 6]; + transform.skew = dataArray[arrayOffset + 7]; + transform.scaleX = dataArray[arrayOffset + 8]; + transform.scaleY = dataArray[arrayOffset + 9]; + transform.x = globalTransformMatrix.tx; + transform.y = globalTransformMatrix.ty; + }; + ArmatureData.prototype.addBone = function(value) { + if (value.name in this.bones) { + console.warn("Same bone: " + value.name); + return; + } + this.bones[value.name] = value; + this.sortedBones.push(value); + }; + ArmatureData.prototype.addSlot = function(value) { + if (value.name in this.slots) { + console.warn("Same slot: " + value.name); + return; + } + this.slots[value.name] = value; + this.sortedSlots.push(value); + }; + ArmatureData.prototype.addConstraint = function(value) { + if (value.name in this.constraints) { + console.warn("Same constraint: " + value.name); + return; + } + this.constraints[value.name] = value; + }; + ArmatureData.prototype.addSkin = function(value) { + if (value.name in this.skins) { + console.warn("Same skin: " + value.name); + return; + } + value.parent = this; + this.skins[value.name] = value; + null === this.defaultSkin && (this.defaultSkin = value); + "default" === value.name && (this.defaultSkin = value); + }; + ArmatureData.prototype.addAnimation = function(value) { + if (value.name in this.animations) { + console.warn("Same animation: " + value.name); + return; + } + value.parent = this; + this.animations[value.name] = value; + this.animationNames.push(value.name); + null === this.defaultAnimation && (this.defaultAnimation = value); + }; + ArmatureData.prototype.addAction = function(value, isDefault) { + isDefault ? this.defaultActions.push(value) : this.actions.push(value); + }; + ArmatureData.prototype.getBone = function(boneName) { + return boneName in this.bones ? this.bones[boneName] : null; + }; + ArmatureData.prototype.getSlot = function(slotName) { + return slotName in this.slots ? this.slots[slotName] : null; + }; + ArmatureData.prototype.getConstraint = function(constraintName) { + return constraintName in this.constraints ? this.constraints[constraintName] : null; + }; + ArmatureData.prototype.getSkin = function(skinName) { + return skinName in this.skins ? this.skins[skinName] : null; + }; + ArmatureData.prototype.getMesh = function(skinName, slotName, meshName) { + var skin = this.getSkin(skinName); + if (null === skin) return null; + return skin.getDisplay(slotName, meshName); + }; + ArmatureData.prototype.getAnimation = function(animationName) { + return animationName in this.animations ? this.animations[animationName] : null; + }; + return ArmatureData; + })(dragonBones.BaseObject); + dragonBones.ArmatureData = ArmatureData; + var BoneData = (function(_super) { + __extends(BoneData, _super); + function BoneData() { + var _this = null !== _super && _super.apply(this, arguments) || this; + _this.transform = new dragonBones.Transform(); + _this.userData = null; + return _this; + } + BoneData.toString = function() { + return "[class dragonBones.BoneData]"; + }; + BoneData.prototype._onClear = function() { + null !== this.userData && this.userData.returnToPool(); + this.inheritTranslation = false; + this.inheritRotation = false; + this.inheritScale = false; + this.inheritReflection = false; + this.type = 0; + this.length = 0; + this.name = ""; + this.transform.identity(); + this.userData = null; + this.parent = null; + }; + return BoneData; + })(dragonBones.BaseObject); + dragonBones.BoneData = BoneData; + var SurfaceData = (function(_super) { + __extends(SurfaceData, _super); + function SurfaceData() { + var _this = null !== _super && _super.apply(this, arguments) || this; + _this.vertices = []; + return _this; + } + SurfaceData.toString = function() { + return "[class dragonBones.SurfaceData]"; + }; + SurfaceData.prototype._onClear = function() { + _super.prototype._onClear.call(this); + this.type = 1; + this.segmentX = 0; + this.segmentY = 0; + this.vertices.length = 0; + }; + return SurfaceData; + })(BoneData); + dragonBones.SurfaceData = SurfaceData; + var SlotData = (function(_super) { + __extends(SlotData, _super); + function SlotData() { + var _this = null !== _super && _super.apply(this, arguments) || this; + _this.color = null; + _this.userData = null; + return _this; + } + SlotData.createColor = function() { + return new dragonBones.ColorTransform(); + }; + SlotData.toString = function() { + return "[class dragonBones.SlotData]"; + }; + SlotData.prototype._onClear = function() { + null !== this.userData && this.userData.returnToPool(); + this.blendMode = 0; + this.displayIndex = 0; + this.zOrder = 0; + this.name = ""; + this.color = null; + this.userData = null; + this.parent = null; + }; + SlotData.DEFAULT_COLOR = new dragonBones.ColorTransform(); + return SlotData; + })(dragonBones.BaseObject); + dragonBones.SlotData = SlotData; + })(dragonBones || (dragonBones = {})); + var dragonBones; + (function(dragonBones) { + var ConstraintData = (function(_super) { + __extends(ConstraintData, _super); + function ConstraintData() { + return null !== _super && _super.apply(this, arguments) || this; + } + ConstraintData.prototype._onClear = function() { + this.order = 0; + this.name = ""; + this.type = 0; + this.target = null; + this.root = null; + this.bone = null; + }; + return ConstraintData; + })(dragonBones.BaseObject); + dragonBones.ConstraintData = ConstraintData; + var IKConstraintData = (function(_super) { + __extends(IKConstraintData, _super); + function IKConstraintData() { + return null !== _super && _super.apply(this, arguments) || this; + } + IKConstraintData.toString = function() { + return "[class dragonBones.IKConstraintData]"; + }; + IKConstraintData.prototype._onClear = function() { + _super.prototype._onClear.call(this); + this.scaleEnabled = false; + this.bendPositive = false; + this.weight = 1; + }; + return IKConstraintData; + })(ConstraintData); + dragonBones.IKConstraintData = IKConstraintData; + var PathConstraintData = (function(_super) { + __extends(PathConstraintData, _super); + function PathConstraintData() { + var _this = null !== _super && _super.apply(this, arguments) || this; + _this.bones = []; + return _this; + } + PathConstraintData.toString = function() { + return "[class dragonBones.PathConstraintData]"; + }; + PathConstraintData.prototype._onClear = function() { + _super.prototype._onClear.call(this); + this.pathSlot = null; + this.pathDisplayData = null; + this.bones.length = 0; + this.positionMode = 0; + this.spacingMode = 1; + this.rotateMode = 1; + this.position = 0; + this.spacing = 0; + this.rotateOffset = 0; + this.rotateMix = 0; + this.translateMix = 0; + }; + PathConstraintData.prototype.AddBone = function(value) { + this.bones.push(value); + }; + return PathConstraintData; + })(ConstraintData); + dragonBones.PathConstraintData = PathConstraintData; + })(dragonBones || (dragonBones = {})); + var dragonBones; + (function(dragonBones) { + var CanvasData = (function(_super) { + __extends(CanvasData, _super); + function CanvasData() { + return null !== _super && _super.apply(this, arguments) || this; + } + CanvasData.toString = function() { + return "[class dragonBones.CanvasData]"; + }; + CanvasData.prototype._onClear = function() { + this.hasBackground = false; + this.color = 0; + this.x = 0; + this.y = 0; + this.width = 0; + this.height = 0; + }; + return CanvasData; + })(dragonBones.BaseObject); + dragonBones.CanvasData = CanvasData; + })(dragonBones || (dragonBones = {})); + var dragonBones; + (function(dragonBones) { + var SkinData = (function(_super) { + __extends(SkinData, _super); + function SkinData() { + var _this = null !== _super && _super.apply(this, arguments) || this; + _this.displays = {}; + return _this; + } + SkinData.toString = function() { + return "[class dragonBones.SkinData]"; + }; + SkinData.prototype._onClear = function() { + for (var k in this.displays) { + var slotDisplays = this.displays[k]; + for (var _i = 0, slotDisplays_1 = slotDisplays; _i < slotDisplays_1.length; _i++) { + var display = slotDisplays_1[_i]; + null !== display && display.returnToPool(); + } + delete this.displays[k]; + } + this.name = ""; + this.parent = null; + }; + SkinData.prototype.addDisplay = function(slotName, value) { + slotName in this.displays || (this.displays[slotName] = []); + null !== value && (value.parent = this); + var slotDisplays = this.displays[slotName]; + slotDisplays.push(value); + }; + SkinData.prototype.getDisplay = function(slotName, displayName) { + var slotDisplays = this.getDisplays(slotName); + if (null !== slotDisplays) for (var _i = 0, slotDisplays_2 = slotDisplays; _i < slotDisplays_2.length; _i++) { + var display = slotDisplays_2[_i]; + if (null !== display && display.name === displayName) return display; + } + return null; + }; + SkinData.prototype.getDisplays = function(slotName) { + if (!(slotName in this.displays)) return null; + return this.displays[slotName]; + }; + return SkinData; + })(dragonBones.BaseObject); + dragonBones.SkinData = SkinData; + })(dragonBones || (dragonBones = {})); + var dragonBones; + (function(dragonBones) { + var VerticesData = (function() { + function VerticesData() { + this.weight = null; + } + VerticesData.prototype.clear = function() { + this.isShared || null === this.weight || this.weight.returnToPool(); + this.isShared = false; + this.inheritDeform = false; + this.offset = 0; + this.data = null; + this.weight = null; + }; + VerticesData.prototype.shareFrom = function(value) { + this.isShared = true; + this.offset = value.offset; + this.weight = value.weight; + }; + return VerticesData; + })(); + dragonBones.VerticesData = VerticesData; + var DisplayData = (function(_super) { + __extends(DisplayData, _super); + function DisplayData() { + var _this = null !== _super && _super.apply(this, arguments) || this; + _this.transform = new dragonBones.Transform(); + return _this; + } + DisplayData.prototype._onClear = function() { + this.name = ""; + this.path = ""; + this.transform.identity(); + this.parent = null; + }; + return DisplayData; + })(dragonBones.BaseObject); + dragonBones.DisplayData = DisplayData; + var ImageDisplayData = (function(_super) { + __extends(ImageDisplayData, _super); + function ImageDisplayData() { + var _this = null !== _super && _super.apply(this, arguments) || this; + _this.pivot = new dragonBones.Point(); + return _this; + } + ImageDisplayData.toString = function() { + return "[class dragonBones.ImageDisplayData]"; + }; + ImageDisplayData.prototype._onClear = function() { + _super.prototype._onClear.call(this); + this.type = 0; + this.pivot.clear(); + this.texture = null; + }; + return ImageDisplayData; + })(DisplayData); + dragonBones.ImageDisplayData = ImageDisplayData; + var ArmatureDisplayData = (function(_super) { + __extends(ArmatureDisplayData, _super); + function ArmatureDisplayData() { + var _this = null !== _super && _super.apply(this, arguments) || this; + _this.actions = []; + return _this; + } + ArmatureDisplayData.toString = function() { + return "[class dragonBones.ArmatureDisplayData]"; + }; + ArmatureDisplayData.prototype._onClear = function() { + _super.prototype._onClear.call(this); + for (var _i = 0, _a = this.actions; _i < _a.length; _i++) { + var action = _a[_i]; + action.returnToPool(); + } + this.type = 1; + this.inheritAnimation = false; + this.actions.length = 0; + this.armature = null; + }; + ArmatureDisplayData.prototype.addAction = function(value) { + this.actions.push(value); + }; + return ArmatureDisplayData; + })(DisplayData); + dragonBones.ArmatureDisplayData = ArmatureDisplayData; + var MeshDisplayData = (function(_super) { + __extends(MeshDisplayData, _super); + function MeshDisplayData() { + var _this = null !== _super && _super.apply(this, arguments) || this; + _this.vertices = new VerticesData(); + return _this; + } + MeshDisplayData.toString = function() { + return "[class dragonBones.MeshDisplayData]"; + }; + MeshDisplayData.prototype._onClear = function() { + _super.prototype._onClear.call(this); + this.type = 2; + this.vertices.clear(); + this.texture = null; + }; + return MeshDisplayData; + })(DisplayData); + dragonBones.MeshDisplayData = MeshDisplayData; + var BoundingBoxDisplayData = (function(_super) { + __extends(BoundingBoxDisplayData, _super); + function BoundingBoxDisplayData() { + var _this = null !== _super && _super.apply(this, arguments) || this; + _this.boundingBox = null; + return _this; + } + BoundingBoxDisplayData.toString = function() { + return "[class dragonBones.BoundingBoxDisplayData]"; + }; + BoundingBoxDisplayData.prototype._onClear = function() { + _super.prototype._onClear.call(this); + null !== this.boundingBox && this.boundingBox.returnToPool(); + this.type = 3; + this.boundingBox = null; + }; + return BoundingBoxDisplayData; + })(DisplayData); + dragonBones.BoundingBoxDisplayData = BoundingBoxDisplayData; + var PathDisplayData = (function(_super) { + __extends(PathDisplayData, _super); + function PathDisplayData() { + var _this = null !== _super && _super.apply(this, arguments) || this; + _this.vertices = new VerticesData(); + _this.curveLengths = []; + return _this; + } + PathDisplayData.toString = function() { + return "[class dragonBones.PathDisplayData]"; + }; + PathDisplayData.prototype._onClear = function() { + _super.prototype._onClear.call(this); + this.type = 4; + this.closed = false; + this.constantSpeed = false; + this.vertices.clear(); + this.curveLengths.length = 0; + }; + return PathDisplayData; + })(DisplayData); + dragonBones.PathDisplayData = PathDisplayData; + var WeightData = (function(_super) { + __extends(WeightData, _super); + function WeightData() { + var _this = null !== _super && _super.apply(this, arguments) || this; + _this.bones = []; + return _this; + } + WeightData.toString = function() { + return "[class dragonBones.WeightData]"; + }; + WeightData.prototype._onClear = function() { + this.count = 0; + this.offset = 0; + this.bones.length = 0; + }; + WeightData.prototype.addBone = function(value) { + this.bones.push(value); + }; + return WeightData; + })(dragonBones.BaseObject); + dragonBones.WeightData = WeightData; + })(dragonBones || (dragonBones = {})); + var dragonBones; + (function(dragonBones) { + var BoundingBoxData = (function(_super) { + __extends(BoundingBoxData, _super); + function BoundingBoxData() { + return null !== _super && _super.apply(this, arguments) || this; + } + BoundingBoxData.prototype._onClear = function() { + this.color = 0; + this.width = 0; + this.height = 0; + }; + return BoundingBoxData; + })(dragonBones.BaseObject); + dragonBones.BoundingBoxData = BoundingBoxData; + var RectangleBoundingBoxData = (function(_super) { + __extends(RectangleBoundingBoxData, _super); + function RectangleBoundingBoxData() { + return null !== _super && _super.apply(this, arguments) || this; + } + RectangleBoundingBoxData.toString = function() { + return "[class dragonBones.RectangleBoundingBoxData]"; + }; + RectangleBoundingBoxData._computeOutCode = function(x, y, xMin, yMin, xMax, yMax) { + var code = 0; + x < xMin ? code |= 1 : x > xMax && (code |= 2); + y < yMin ? code |= 4 : y > yMax && (code |= 8); + return code; + }; + RectangleBoundingBoxData.rectangleIntersectsSegment = function(xA, yA, xB, yB, xMin, yMin, xMax, yMax, intersectionPointA, intersectionPointB, normalRadians) { + void 0 === intersectionPointA && (intersectionPointA = null); + void 0 === intersectionPointB && (intersectionPointB = null); + void 0 === normalRadians && (normalRadians = null); + var inSideA = xA > xMin && xA < xMax && yA > yMin && yA < yMax; + var inSideB = xB > xMin && xB < xMax && yB > yMin && yB < yMax; + if (inSideA && inSideB) return -1; + var intersectionCount = 0; + var outcode0 = RectangleBoundingBoxData._computeOutCode(xA, yA, xMin, yMin, xMax, yMax); + var outcode1 = RectangleBoundingBoxData._computeOutCode(xB, yB, xMin, yMin, xMax, yMax); + while (true) { + if (0 === (outcode0 | outcode1)) { + intersectionCount = 2; + break; + } + if (0 !== (outcode0 & outcode1)) break; + var x = 0; + var y = 0; + var normalRadian = 0; + var outcodeOut = 0 !== outcode0 ? outcode0 : outcode1; + if (0 !== (4 & outcodeOut)) { + x = xA + (xB - xA) * (yMin - yA) / (yB - yA); + y = yMin; + null !== normalRadians && (normalRadian = .5 * -Math.PI); + } else if (0 !== (8 & outcodeOut)) { + x = xA + (xB - xA) * (yMax - yA) / (yB - yA); + y = yMax; + null !== normalRadians && (normalRadian = .5 * Math.PI); + } else if (0 !== (2 & outcodeOut)) { + y = yA + (yB - yA) * (xMax - xA) / (xB - xA); + x = xMax; + null !== normalRadians && (normalRadian = 0); + } else if (0 !== (1 & outcodeOut)) { + y = yA + (yB - yA) * (xMin - xA) / (xB - xA); + x = xMin; + null !== normalRadians && (normalRadian = Math.PI); + } + if (outcodeOut === outcode0) { + xA = x; + yA = y; + outcode0 = RectangleBoundingBoxData._computeOutCode(xA, yA, xMin, yMin, xMax, yMax); + null !== normalRadians && (normalRadians.x = normalRadian); + } else { + xB = x; + yB = y; + outcode1 = RectangleBoundingBoxData._computeOutCode(xB, yB, xMin, yMin, xMax, yMax); + null !== normalRadians && (normalRadians.y = normalRadian); + } + } + if (intersectionCount) if (inSideA) { + intersectionCount = 2; + if (null !== intersectionPointA) { + intersectionPointA.x = xB; + intersectionPointA.y = yB; + } + if (null !== intersectionPointB) { + intersectionPointB.x = xB; + intersectionPointB.y = xB; + } + null !== normalRadians && (normalRadians.x = normalRadians.y + Math.PI); + } else if (inSideB) { + intersectionCount = 1; + if (null !== intersectionPointA) { + intersectionPointA.x = xA; + intersectionPointA.y = yA; + } + if (null !== intersectionPointB) { + intersectionPointB.x = xA; + intersectionPointB.y = yA; + } + null !== normalRadians && (normalRadians.y = normalRadians.x + Math.PI); + } else { + intersectionCount = 3; + if (null !== intersectionPointA) { + intersectionPointA.x = xA; + intersectionPointA.y = yA; + } + if (null !== intersectionPointB) { + intersectionPointB.x = xB; + intersectionPointB.y = yB; + } + } + return intersectionCount; + }; + RectangleBoundingBoxData.prototype._onClear = function() { + _super.prototype._onClear.call(this); + this.type = 0; + }; + RectangleBoundingBoxData.prototype.containsPoint = function(pX, pY) { + var widthH = .5 * this.width; + if (pX >= -widthH && pX <= widthH) { + var heightH = .5 * this.height; + if (pY >= -heightH && pY <= heightH) return true; + } + return false; + }; + RectangleBoundingBoxData.prototype.intersectsSegment = function(xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians) { + void 0 === intersectionPointA && (intersectionPointA = null); + void 0 === intersectionPointB && (intersectionPointB = null); + void 0 === normalRadians && (normalRadians = null); + var widthH = .5 * this.width; + var heightH = .5 * this.height; + var intersectionCount = RectangleBoundingBoxData.rectangleIntersectsSegment(xA, yA, xB, yB, -widthH, -heightH, widthH, heightH, intersectionPointA, intersectionPointB, normalRadians); + return intersectionCount; + }; + return RectangleBoundingBoxData; + })(BoundingBoxData); + dragonBones.RectangleBoundingBoxData = RectangleBoundingBoxData; + var EllipseBoundingBoxData = (function(_super) { + __extends(EllipseBoundingBoxData, _super); + function EllipseBoundingBoxData() { + return null !== _super && _super.apply(this, arguments) || this; + } + EllipseBoundingBoxData.toString = function() { + return "[class dragonBones.EllipseData]"; + }; + EllipseBoundingBoxData.ellipseIntersectsSegment = function(xA, yA, xB, yB, xC, yC, widthH, heightH, intersectionPointA, intersectionPointB, normalRadians) { + void 0 === intersectionPointA && (intersectionPointA = null); + void 0 === intersectionPointB && (intersectionPointB = null); + void 0 === normalRadians && (normalRadians = null); + var d = widthH / heightH; + var dd = d * d; + yA *= d; + yB *= d; + var dX = xB - xA; + var dY = yB - yA; + var lAB = Math.sqrt(dX * dX + dY * dY); + var xD = dX / lAB; + var yD = dY / lAB; + var a = (xC - xA) * xD + (yC - yA) * yD; + var aa = a * a; + var ee = xA * xA + yA * yA; + var rr = widthH * widthH; + var dR = rr - ee + aa; + var intersectionCount = 0; + if (dR >= 0) { + var dT = Math.sqrt(dR); + var sA = a - dT; + var sB = a + dT; + var inSideA = sA < 0 ? -1 : sA <= lAB ? 0 : 1; + var inSideB = sB < 0 ? -1 : sB <= lAB ? 0 : 1; + var sideAB = inSideA * inSideB; + if (sideAB < 0) return -1; + if (0 === sideAB) if (-1 === inSideA) { + intersectionCount = 2; + xB = xA + sB * xD; + yB = (yA + sB * yD) / d; + if (null !== intersectionPointA) { + intersectionPointA.x = xB; + intersectionPointA.y = yB; + } + if (null !== intersectionPointB) { + intersectionPointB.x = xB; + intersectionPointB.y = yB; + } + if (null !== normalRadians) { + normalRadians.x = Math.atan2(yB / rr * dd, xB / rr); + normalRadians.y = normalRadians.x + Math.PI; + } + } else if (1 === inSideB) { + intersectionCount = 1; + xA += sA * xD; + yA = (yA + sA * yD) / d; + if (null !== intersectionPointA) { + intersectionPointA.x = xA; + intersectionPointA.y = yA; + } + if (null !== intersectionPointB) { + intersectionPointB.x = xA; + intersectionPointB.y = yA; + } + if (null !== normalRadians) { + normalRadians.x = Math.atan2(yA / rr * dd, xA / rr); + normalRadians.y = normalRadians.x + Math.PI; + } + } else { + intersectionCount = 3; + if (null !== intersectionPointA) { + intersectionPointA.x = xA + sA * xD; + intersectionPointA.y = (yA + sA * yD) / d; + null !== normalRadians && (normalRadians.x = Math.atan2(intersectionPointA.y / rr * dd, intersectionPointA.x / rr)); + } + if (null !== intersectionPointB) { + intersectionPointB.x = xA + sB * xD; + intersectionPointB.y = (yA + sB * yD) / d; + null !== normalRadians && (normalRadians.y = Math.atan2(intersectionPointB.y / rr * dd, intersectionPointB.x / rr)); + } + } + } + return intersectionCount; + }; + EllipseBoundingBoxData.prototype._onClear = function() { + _super.prototype._onClear.call(this); + this.type = 1; + }; + EllipseBoundingBoxData.prototype.containsPoint = function(pX, pY) { + var widthH = .5 * this.width; + if (pX >= -widthH && pX <= widthH) { + var heightH = .5 * this.height; + if (pY >= -heightH && pY <= heightH) { + pY *= widthH / heightH; + return Math.sqrt(pX * pX + pY * pY) <= widthH; + } + } + return false; + }; + EllipseBoundingBoxData.prototype.intersectsSegment = function(xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians) { + void 0 === intersectionPointA && (intersectionPointA = null); + void 0 === intersectionPointB && (intersectionPointB = null); + void 0 === normalRadians && (normalRadians = null); + var intersectionCount = EllipseBoundingBoxData.ellipseIntersectsSegment(xA, yA, xB, yB, 0, 0, .5 * this.width, .5 * this.height, intersectionPointA, intersectionPointB, normalRadians); + return intersectionCount; + }; + return EllipseBoundingBoxData; + })(BoundingBoxData); + dragonBones.EllipseBoundingBoxData = EllipseBoundingBoxData; + var PolygonBoundingBoxData = (function(_super) { + __extends(PolygonBoundingBoxData, _super); + function PolygonBoundingBoxData() { + var _this = null !== _super && _super.apply(this, arguments) || this; + _this.vertices = []; + return _this; + } + PolygonBoundingBoxData.toString = function() { + return "[class dragonBones.PolygonBoundingBoxData]"; + }; + PolygonBoundingBoxData.polygonIntersectsSegment = function(xA, yA, xB, yB, vertices, intersectionPointA, intersectionPointB, normalRadians) { + void 0 === intersectionPointA && (intersectionPointA = null); + void 0 === intersectionPointB && (intersectionPointB = null); + void 0 === normalRadians && (normalRadians = null); + xA === xB && (xA = xB + 1e-6); + yA === yB && (yA = yB + 1e-6); + var count = vertices.length; + var dXAB = xA - xB; + var dYAB = yA - yB; + var llAB = xA * yB - yA * xB; + var intersectionCount = 0; + var xC = vertices[count - 2]; + var yC = vertices[count - 1]; + var dMin = 0; + var dMax = 0; + var xMin = 0; + var yMin = 0; + var xMax = 0; + var yMax = 0; + for (var i = 0; i < count; i += 2) { + var xD = vertices[i]; + var yD = vertices[i + 1]; + xC === xD && (xC = xD + 1e-4); + yC === yD && (yC = yD + 1e-4); + var dXCD = xC - xD; + var dYCD = yC - yD; + var llCD = xC * yD - yC * xD; + var ll = dXAB * dYCD - dYAB * dXCD; + var x = (llAB * dXCD - dXAB * llCD) / ll; + if ((x >= xC && x <= xD || x >= xD && x <= xC) && (0 === dXAB || x >= xA && x <= xB || x >= xB && x <= xA)) { + var y = (llAB * dYCD - dYAB * llCD) / ll; + if ((y >= yC && y <= yD || y >= yD && y <= yC) && (0 === dYAB || y >= yA && y <= yB || y >= yB && y <= yA)) { + if (null === intersectionPointB) { + xMin = x; + yMin = y; + xMax = x; + yMax = y; + intersectionCount++; + if (null !== normalRadians) { + normalRadians.x = Math.atan2(yD - yC, xD - xC) - .5 * Math.PI; + normalRadians.y = normalRadians.x; + } + break; + } + var d = x - xA; + d < 0 && (d = -d); + if (0 === intersectionCount) { + dMin = d; + dMax = d; + xMin = x; + yMin = y; + xMax = x; + yMax = y; + if (null !== normalRadians) { + normalRadians.x = Math.atan2(yD - yC, xD - xC) - .5 * Math.PI; + normalRadians.y = normalRadians.x; + } + } else { + if (d < dMin) { + dMin = d; + xMin = x; + yMin = y; + null !== normalRadians && (normalRadians.x = Math.atan2(yD - yC, xD - xC) - .5 * Math.PI); + } + if (d > dMax) { + dMax = d; + xMax = x; + yMax = y; + null !== normalRadians && (normalRadians.y = Math.atan2(yD - yC, xD - xC) - .5 * Math.PI); + } + } + intersectionCount++; + } + } + xC = xD; + yC = yD; + } + if (1 === intersectionCount) { + if (null !== intersectionPointA) { + intersectionPointA.x = xMin; + intersectionPointA.y = yMin; + } + if (null !== intersectionPointB) { + intersectionPointB.x = xMin; + intersectionPointB.y = yMin; + } + null !== normalRadians && (normalRadians.y = normalRadians.x + Math.PI); + } else if (intersectionCount > 1) { + intersectionCount++; + if (null !== intersectionPointA) { + intersectionPointA.x = xMin; + intersectionPointA.y = yMin; + } + if (null !== intersectionPointB) { + intersectionPointB.x = xMax; + intersectionPointB.y = yMax; + } + } + return intersectionCount; + }; + PolygonBoundingBoxData.prototype._onClear = function() { + _super.prototype._onClear.call(this); + this.type = 2; + this.x = 0; + this.y = 0; + this.vertices.length = 0; + }; + PolygonBoundingBoxData.prototype.containsPoint = function(pX, pY) { + var isInSide = false; + if (pX >= this.x && pX <= this.width && pY >= this.y && pY <= this.height) for (var i = 0, l = this.vertices.length, iP = l - 2; i < l; i += 2) { + var yA = this.vertices[iP + 1]; + var yB = this.vertices[i + 1]; + if (yB < pY && yA >= pY || yA < pY && yB >= pY) { + var xA = this.vertices[iP]; + var xB = this.vertices[i]; + (pY - yB) * (xA - xB) / (yA - yB) + xB < pX && (isInSide = !isInSide); + } + iP = i; + } + return isInSide; + }; + PolygonBoundingBoxData.prototype.intersectsSegment = function(xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians) { + void 0 === intersectionPointA && (intersectionPointA = null); + void 0 === intersectionPointB && (intersectionPointB = null); + void 0 === normalRadians && (normalRadians = null); + var intersectionCount = 0; + 0 !== RectangleBoundingBoxData.rectangleIntersectsSegment(xA, yA, xB, yB, this.x, this.y, this.x + this.width, this.y + this.height, null, null, null) && (intersectionCount = PolygonBoundingBoxData.polygonIntersectsSegment(xA, yA, xB, yB, this.vertices, intersectionPointA, intersectionPointB, normalRadians)); + return intersectionCount; + }; + return PolygonBoundingBoxData; + })(BoundingBoxData); + dragonBones.PolygonBoundingBoxData = PolygonBoundingBoxData; + })(dragonBones || (dragonBones = {})); + var dragonBones; + (function(dragonBones) { + var AnimationData = (function(_super) { + __extends(AnimationData, _super); + function AnimationData() { + var _this = null !== _super && _super.apply(this, arguments) || this; + _this.cachedFrames = []; + _this.boneTimelines = {}; + _this.surfaceTimelines = {}; + _this.slotTimelines = {}; + _this.constraintTimelines = {}; + _this.animationTimelines = {}; + _this.boneCachedFrameIndices = {}; + _this.slotCachedFrameIndices = {}; + _this.actionTimeline = null; + _this.zOrderTimeline = null; + return _this; + } + AnimationData.toString = function() { + return "[class dragonBones.AnimationData]"; + }; + AnimationData.prototype._onClear = function() { + for (var k in this.boneTimelines) { + for (var _i = 0, _a = this.boneTimelines[k]; _i < _a.length; _i++) { + var timeline = _a[_i]; + timeline.returnToPool(); + } + delete this.boneTimelines[k]; + } + for (var k in this.surfaceTimelines) { + for (var _b = 0, _c = this.surfaceTimelines[k]; _b < _c.length; _b++) { + var timeline = _c[_b]; + timeline.returnToPool(); + } + delete this.surfaceTimelines[k]; + } + for (var k in this.slotTimelines) { + for (var _d = 0, _e = this.slotTimelines[k]; _d < _e.length; _d++) { + var timeline = _e[_d]; + timeline.returnToPool(); + } + delete this.slotTimelines[k]; + } + for (var k in this.constraintTimelines) { + for (var _f = 0, _g = this.constraintTimelines[k]; _f < _g.length; _f++) { + var timeline = _g[_f]; + timeline.returnToPool(); + } + delete this.constraintTimelines[k]; + } + for (var k in this.animationTimelines) { + for (var _h = 0, _j = this.animationTimelines[k]; _h < _j.length; _h++) { + var timeline = _j[_h]; + timeline.returnToPool(); + } + delete this.animationTimelines[k]; + } + for (var k in this.boneCachedFrameIndices) delete this.boneCachedFrameIndices[k]; + for (var k in this.slotCachedFrameIndices) delete this.slotCachedFrameIndices[k]; + null !== this.actionTimeline && this.actionTimeline.returnToPool(); + null !== this.zOrderTimeline && this.zOrderTimeline.returnToPool(); + this.frameIntOffset = 0; + this.frameFloatOffset = 0; + this.frameOffset = 0; + this.frameCount = 0; + this.playTimes = 0; + this.duration = 0; + this.scale = 1; + this.fadeInTime = 0; + this.cacheFrameRate = 0; + this.name = ""; + this.cachedFrames.length = 0; + this.actionTimeline = null; + this.zOrderTimeline = null; + this.parent = null; + }; + AnimationData.prototype.cacheFrames = function(frameRate) { + if (this.cacheFrameRate > 0) return; + this.cacheFrameRate = Math.max(Math.ceil(frameRate * this.scale), 1); + var cacheFrameCount = Math.ceil(this.cacheFrameRate * this.duration) + 1; + this.cachedFrames.length = cacheFrameCount; + for (var i = 0, l = this.cacheFrames.length; i < l; ++i) this.cachedFrames[i] = false; + for (var _i = 0, _a = this.parent.sortedBones; _i < _a.length; _i++) { + var bone = _a[_i]; + var indices = new Array(cacheFrameCount); + for (var i = 0, l = indices.length; i < l; ++i) indices[i] = -1; + this.boneCachedFrameIndices[bone.name] = indices; + } + for (var _b = 0, _c = this.parent.sortedSlots; _b < _c.length; _b++) { + var slot = _c[_b]; + var indices = new Array(cacheFrameCount); + for (var i = 0, l = indices.length; i < l; ++i) indices[i] = -1; + this.slotCachedFrameIndices[slot.name] = indices; + } + }; + AnimationData.prototype.addBoneTimeline = function(bone, timeline) { + var timelines = bone.name in this.boneTimelines ? this.boneTimelines[bone.name] : this.boneTimelines[bone.name] = []; + timelines.indexOf(timeline) < 0 && timelines.push(timeline); + }; + AnimationData.prototype.addSurfaceTimeline = function(surface, timeline) { + var timelines = surface.name in this.surfaceTimelines ? this.surfaceTimelines[surface.name] : this.surfaceTimelines[surface.name] = []; + timelines.indexOf(timeline) < 0 && timelines.push(timeline); + }; + AnimationData.prototype.addSlotTimeline = function(slot, timeline) { + var timelines = slot.name in this.slotTimelines ? this.slotTimelines[slot.name] : this.slotTimelines[slot.name] = []; + timelines.indexOf(timeline) < 0 && timelines.push(timeline); + }; + AnimationData.prototype.addConstraintTimeline = function(constraint, timeline) { + var timelines = constraint.name in this.constraintTimelines ? this.constraintTimelines[constraint.name] : this.constraintTimelines[constraint.name] = []; + timelines.indexOf(timeline) < 0 && timelines.push(timeline); + }; + AnimationData.prototype.addAnimationTimeline = function(timelineName, timeline) { + var timelines = timelineName in this.animationTimelines ? this.animationTimelines[timelineName] : this.animationTimelines[timelineName] = []; + timelines.indexOf(timeline) < 0 && timelines.push(timeline); + }; + AnimationData.prototype.getBoneTimelines = function(timelineName) { + return timelineName in this.boneTimelines ? this.boneTimelines[timelineName] : null; + }; + AnimationData.prototype.getSurfaceTimelines = function(timelineName) { + return timelineName in this.surfaceTimelines ? this.surfaceTimelines[timelineName] : null; + }; + AnimationData.prototype.getSlotTimelines = function(timelineName) { + return timelineName in this.slotTimelines ? this.slotTimelines[timelineName] : null; + }; + AnimationData.prototype.getConstraintTimelines = function(timelineName) { + return timelineName in this.constraintTimelines ? this.constraintTimelines[timelineName] : null; + }; + AnimationData.prototype.getAnimationTimelines = function(timelineName) { + return timelineName in this.animationTimelines ? this.animationTimelines[timelineName] : null; + }; + AnimationData.prototype.getBoneCachedFrameIndices = function(boneName) { + return boneName in this.boneCachedFrameIndices ? this.boneCachedFrameIndices[boneName] : null; + }; + AnimationData.prototype.getSlotCachedFrameIndices = function(slotName) { + return slotName in this.slotCachedFrameIndices ? this.slotCachedFrameIndices[slotName] : null; + }; + return AnimationData; + })(dragonBones.BaseObject); + dragonBones.AnimationData = AnimationData; + var TimelineData = (function(_super) { + __extends(TimelineData, _super); + function TimelineData() { + return null !== _super && _super.apply(this, arguments) || this; + } + TimelineData.toString = function() { + return "[class dragonBones.TimelineData]"; + }; + TimelineData.prototype._onClear = function() { + this.type = 10; + this.offset = 0; + this.frameIndicesOffset = -1; + }; + return TimelineData; + })(dragonBones.BaseObject); + dragonBones.TimelineData = TimelineData; + })(dragonBones || (dragonBones = {})); + var dragonBones; + (function(dragonBones) { + var AnimationConfig = (function(_super) { + __extends(AnimationConfig, _super); + function AnimationConfig() { + var _this = null !== _super && _super.apply(this, arguments) || this; + _this.boneMask = []; + return _this; + } + AnimationConfig.toString = function() { + return "[class dragonBones.AnimationConfig]"; + }; + AnimationConfig.prototype._onClear = function() { + this.pauseFadeOut = true; + this.fadeOutMode = 4; + this.fadeOutTweenType = 1; + this.fadeOutTime = -1; + this.actionEnabled = true; + this.additiveBlending = false; + this.displayControl = true; + this.pauseFadeIn = true; + this.resetToPose = true; + this.fadeInTweenType = 1; + this.playTimes = -1; + this.layer = 0; + this.position = 0; + this.duration = -1; + this.timeScale = -100; + this.weight = 1; + this.fadeInTime = -1; + this.autoFadeOutTime = -1; + this.name = ""; + this.animation = ""; + this.group = ""; + this.boneMask.length = 0; + }; + AnimationConfig.prototype.clear = function() { + this._onClear(); + }; + AnimationConfig.prototype.copyFrom = function(value) { + this.pauseFadeOut = value.pauseFadeOut; + this.fadeOutMode = value.fadeOutMode; + this.autoFadeOutTime = value.autoFadeOutTime; + this.fadeOutTweenType = value.fadeOutTweenType; + this.actionEnabled = value.actionEnabled; + this.additiveBlending = value.additiveBlending; + this.displayControl = value.displayControl; + this.pauseFadeIn = value.pauseFadeIn; + this.resetToPose = value.resetToPose; + this.playTimes = value.playTimes; + this.layer = value.layer; + this.position = value.position; + this.duration = value.duration; + this.timeScale = value.timeScale; + this.fadeInTime = value.fadeInTime; + this.fadeOutTime = value.fadeOutTime; + this.fadeInTweenType = value.fadeInTweenType; + this.weight = value.weight; + this.name = value.name; + this.animation = value.animation; + this.group = value.group; + this.boneMask.length = value.boneMask.length; + for (var i = 0, l = this.boneMask.length; i < l; ++i) this.boneMask[i] = value.boneMask[i]; + }; + AnimationConfig.prototype.containsBoneMask = function(boneName) { + return 0 === this.boneMask.length || this.boneMask.indexOf(boneName) >= 0; + }; + AnimationConfig.prototype.addBoneMask = function(armature, boneName, recursive) { + void 0 === recursive && (recursive = true); + var currentBone = armature.getBone(boneName); + if (null === currentBone) return; + this.boneMask.indexOf(boneName) < 0 && this.boneMask.push(boneName); + if (recursive) for (var _i = 0, _a = armature.getBones(); _i < _a.length; _i++) { + var bone = _a[_i]; + this.boneMask.indexOf(bone.name) < 0 && currentBone.contains(bone) && this.boneMask.push(bone.name); + } + }; + AnimationConfig.prototype.removeBoneMask = function(armature, boneName, recursive) { + void 0 === recursive && (recursive = true); + var index = this.boneMask.indexOf(boneName); + index >= 0 && this.boneMask.splice(index, 1); + if (recursive) { + var currentBone = armature.getBone(boneName); + if (null !== currentBone) if (this.boneMask.length > 0) for (var _i = 0, _a = armature.getBones(); _i < _a.length; _i++) { + var bone = _a[_i]; + var index_1 = this.boneMask.indexOf(bone.name); + index_1 >= 0 && currentBone.contains(bone) && this.boneMask.splice(index_1, 1); + } else for (var _b = 0, _c = armature.getBones(); _b < _c.length; _b++) { + var bone = _c[_b]; + if (bone === currentBone) continue; + currentBone.contains(bone) || this.boneMask.push(bone.name); + } + } + }; + return AnimationConfig; + })(dragonBones.BaseObject); + dragonBones.AnimationConfig = AnimationConfig; + })(dragonBones || (dragonBones = {})); + var dragonBones; + (function(dragonBones) { + var TextureAtlasData = (function(_super) { + __extends(TextureAtlasData, _super); + function TextureAtlasData() { + var _this = null !== _super && _super.apply(this, arguments) || this; + _this.textures = {}; + return _this; + } + TextureAtlasData.prototype._onClear = function() { + for (var k in this.textures) { + this.textures[k].returnToPool(); + delete this.textures[k]; + } + this.autoSearch = false; + this.width = 0; + this.height = 0; + this.scale = 1; + this.name = ""; + this.imagePath = ""; + }; + TextureAtlasData.prototype.copyFrom = function(value) { + this.autoSearch = value.autoSearch; + this.scale = value.scale; + this.width = value.width; + this.height = value.height; + this.name = value.name; + this.imagePath = value.imagePath; + for (var k in this.textures) { + this.textures[k].returnToPool(); + delete this.textures[k]; + } + for (var k in value.textures) { + var texture = this.createTexture(); + texture.copyFrom(value.textures[k]); + this.textures[k] = texture; + } + }; + TextureAtlasData.prototype.addTexture = function(value) { + if (value.name in this.textures) { + console.warn("Same texture: " + value.name); + return; + } + value.parent = this; + this.textures[value.name] = value; + }; + TextureAtlasData.prototype.getTexture = function(textureName) { + return textureName in this.textures ? this.textures[textureName] : null; + }; + return TextureAtlasData; + })(dragonBones.BaseObject); + dragonBones.TextureAtlasData = TextureAtlasData; + var TextureData = (function(_super) { + __extends(TextureData, _super); + function TextureData() { + var _this = null !== _super && _super.apply(this, arguments) || this; + _this.region = new dragonBones.Rectangle(); + _this.frame = null; + return _this; + } + TextureData.createRectangle = function() { + return new dragonBones.Rectangle(); + }; + TextureData.prototype._onClear = function() { + this.rotated = false; + this.name = ""; + this.region.clear(); + this.parent = null; + this.frame = null; + }; + TextureData.prototype.copyFrom = function(value) { + this.rotated = value.rotated; + this.name = value.name; + this.region.copyFrom(value.region); + this.parent = value.parent; + null === this.frame && null !== value.frame ? this.frame = TextureData.createRectangle() : null !== this.frame && null === value.frame && (this.frame = null); + null !== this.frame && null !== value.frame && this.frame.copyFrom(value.frame); + }; + return TextureData; + })(dragonBones.BaseObject); + dragonBones.TextureData = TextureData; + })(dragonBones || (dragonBones = {})); + var dragonBones; + (function(dragonBones) { + var DeformVertices = (function(_super) { + __extends(DeformVertices, _super); + function DeformVertices() { + var _this = null !== _super && _super.apply(this, arguments) || this; + _this.vertices = []; + _this.bones = []; + return _this; + } + DeformVertices.toString = function() { + return "[class dragonBones.DeformVertices]"; + }; + DeformVertices.prototype._onClear = function() { + this.verticesDirty = false; + this.vertices.length = 0; + this.bones.length = 0; + this.verticesData = null; + }; + DeformVertices.prototype.init = function(verticesDataValue, armature) { + this.verticesData = verticesDataValue; + if (null !== this.verticesData) { + var vertexCount = 0; + vertexCount = null !== this.verticesData.weight ? 2 * this.verticesData.weight.count : 2 * this.verticesData.data.intArray[this.verticesData.offset + 0]; + this.verticesDirty = true; + this.vertices.length = vertexCount; + this.bones.length = 0; + for (var i = 0, l = this.vertices.length; i < l; ++i) this.vertices[i] = 0; + if (null !== this.verticesData.weight) for (var i = 0, l = this.verticesData.weight.bones.length; i < l; ++i) { + var bone = armature.getBone(this.verticesData.weight.bones[i].name); + this.bones.push(bone); + } + } else { + this.verticesDirty = false; + this.vertices.length = 0; + this.bones.length = 0; + this.verticesData = null; + } + }; + DeformVertices.prototype.isBonesUpdate = function() { + for (var _i = 0, _a = this.bones; _i < _a.length; _i++) { + var bone = _a[_i]; + if (null !== bone && bone._childrenTransformDirty) return true; + } + return false; + }; + return DeformVertices; + })(dragonBones.BaseObject); + dragonBones.DeformVertices = DeformVertices; + })(dragonBones || (dragonBones = {})); + var dragonBones; + (function(dragonBones_1) { + var Armature = (function(_super) { + __extends(Armature, _super); + function Armature() { + var _this = null !== _super && _super.apply(this, arguments) || this; + _this._bones = []; + _this._slots = []; + _this._constraints = []; + _this._actions = []; + _this._animation = null; + _this._proxy = null; + _this._replaceTextureAtlasData = null; + _this._clock = null; + return _this; + } + Armature.toString = function() { + return "[class dragonBones.Armature]"; + }; + Armature._onSortSlots = function(a, b) { + return a._zOrder > b._zOrder ? 1 : -1; + }; + Armature.prototype._onClear = function() { + null !== this._clock && this._clock.remove(this); + for (var _i = 0, _a = this._bones; _i < _a.length; _i++) { + var bone = _a[_i]; + bone.returnToPool(); + } + for (var _b = 0, _c = this._slots; _b < _c.length; _b++) { + var slot = _c[_b]; + slot.returnToPool(); + } + for (var _d = 0, _e = this._constraints; _d < _e.length; _d++) { + var constraint = _e[_d]; + constraint.returnToPool(); + } + for (var _f = 0, _g = this._actions; _f < _g.length; _f++) { + var action = _g[_f]; + action.returnToPool(); + } + null !== this._animation && this._animation.returnToPool(); + null !== this._proxy && this._proxy.dbClear(); + null !== this._replaceTextureAtlasData && this._replaceTextureAtlasData.returnToPool(); + this.inheritAnimation = true; + this.userData = null; + this._lockUpdate = false; + this._slotsDirty = true; + this._zOrderDirty = false; + this._flipX = false; + this._flipY = false; + this._cacheFrameIndex = -1; + this._bones.length = 0; + this._slots.length = 0; + this._constraints.length = 0; + this._actions.length = 0; + this._armatureData = null; + this._animation = null; + this._proxy = null; + this._display = null; + this._replaceTextureAtlasData = null; + this._replacedTexture = null; + this._dragonBones = null; + this._clock = null; + this._parent = null; + }; + Armature.prototype._sortZOrder = function(slotIndices, offset) { + var slotDatas = this._armatureData.sortedSlots; + var isOriginal = null === slotIndices; + if (this._zOrderDirty || !isOriginal) { + for (var i = 0, l = slotDatas.length; i < l; ++i) { + var slotIndex = isOriginal ? i : slotIndices[offset + i]; + if (slotIndex < 0 || slotIndex >= l) continue; + var slotData = slotDatas[slotIndex]; + var slot = this.getSlot(slotData.name); + null !== slot && slot._setZorder(i); + } + this._slotsDirty = true; + this._zOrderDirty = !isOriginal; + } + }; + Armature.prototype._addBone = function(value) { + this._bones.indexOf(value) < 0 && this._bones.push(value); + }; + Armature.prototype._addSlot = function(value) { + this._slots.indexOf(value) < 0 && this._slots.push(value); + }; + Armature.prototype._addConstraint = function(value) { + this._constraints.indexOf(value) < 0 && this._constraints.push(value); + }; + Armature.prototype._bufferAction = function(action, append) { + this._actions.indexOf(action) < 0 && (append ? this._actions.push(action) : this._actions.unshift(action)); + }; + Armature.prototype.dispose = function() { + if (null !== this._armatureData) { + this._lockUpdate = true; + this._dragonBones.bufferObject(this); + } + }; + Armature.prototype.init = function(armatureData, proxy, display, dragonBones) { + if (null !== this._armatureData) return; + this._armatureData = armatureData; + this._animation = dragonBones_1.BaseObject.borrowObject(dragonBones_1.Animation); + this._proxy = proxy; + this._display = display; + this._dragonBones = dragonBones; + this._proxy.dbInit(this); + this._animation.init(this); + this._animation.animations = this._armatureData.animations; + }; + Armature.prototype.advanceTime = function(passedTime) { + if (this._lockUpdate) return; + if (null === this._armatureData) { + console.warn("The armature has been disposed."); + return; + } + if (null === this._armatureData.parent) { + console.warn("The armature data has been disposed.\nPlease make sure dispose armature before call factory.clear()."); + return; + } + var prevCacheFrameIndex = this._cacheFrameIndex; + this._animation.advanceTime(passedTime); + if (this._slotsDirty) { + this._slotsDirty = false; + this._slots.sort(Armature._onSortSlots); + } + if (this._cacheFrameIndex < 0 || this._cacheFrameIndex !== prevCacheFrameIndex) { + var i = 0, l = 0; + for (i = 0, l = this._bones.length; i < l; ++i) this._bones[i].update(this._cacheFrameIndex); + for (i = 0, l = this._slots.length; i < l; ++i) this._slots[i].update(this._cacheFrameIndex); + } + if (this._actions.length > 0) { + this._lockUpdate = true; + for (var _i = 0, _a = this._actions; _i < _a.length; _i++) { + var action = _a[_i]; + var actionData = action.actionData; + if (null !== actionData && 0 === actionData.type) if (null !== action.slot) { + var childArmature = action.slot.childArmature; + null !== childArmature && childArmature.animation.fadeIn(actionData.name); + } else if (null !== action.bone) for (var _b = 0, _c = this.getSlots(); _b < _c.length; _b++) { + var slot = _c[_b]; + if (slot.parent === action.bone) { + var childArmature = slot.childArmature; + null !== childArmature && childArmature.animation.fadeIn(actionData.name); + } + } else this._animation.fadeIn(actionData.name); + action.returnToPool(); + } + this._actions.length = 0; + this._lockUpdate = false; + } + this._proxy.dbUpdate(); + }; + Armature.prototype.invalidUpdate = function(boneName, updateSlot) { + void 0 === boneName && (boneName = null); + void 0 === updateSlot && (updateSlot = false); + if (null !== boneName && boneName.length > 0) { + var bone = this.getBone(boneName); + if (null !== bone) { + bone.invalidUpdate(); + if (updateSlot) for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { + var slot = _a[_i]; + slot.parent === bone && slot.invalidUpdate(); + } + } + } else { + for (var _b = 0, _c = this._bones; _b < _c.length; _b++) { + var bone = _c[_b]; + bone.invalidUpdate(); + } + if (updateSlot) for (var _d = 0, _e = this._slots; _d < _e.length; _d++) { + var slot = _e[_d]; + slot.invalidUpdate(); + } + } + }; + Armature.prototype.containsPoint = function(x, y) { + for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { + var slot = _a[_i]; + if (slot.containsPoint(x, y)) return slot; + } + return null; + }; + Armature.prototype.intersectsSegment = function(xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians) { + void 0 === intersectionPointA && (intersectionPointA = null); + void 0 === intersectionPointB && (intersectionPointB = null); + void 0 === normalRadians && (normalRadians = null); + var isV = xA === xB; + var dMin = 0; + var dMax = 0; + var intXA = 0; + var intYA = 0; + var intXB = 0; + var intYB = 0; + var intAN = 0; + var intBN = 0; + var intSlotA = null; + var intSlotB = null; + for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { + var slot = _a[_i]; + var intersectionCount = slot.intersectsSegment(xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians); + if (intersectionCount > 0) { + if (null === intersectionPointA && null === intersectionPointB) { + intSlotA = slot; + break; + } + if (null !== intersectionPointA) { + var d = isV ? intersectionPointA.y - yA : intersectionPointA.x - xA; + d < 0 && (d = -d); + if (null === intSlotA || d < dMin) { + dMin = d; + intXA = intersectionPointA.x; + intYA = intersectionPointA.y; + intSlotA = slot; + normalRadians && (intAN = normalRadians.x); + } + } + if (null !== intersectionPointB) { + var d = intersectionPointB.x - xA; + d < 0 && (d = -d); + if (null === intSlotB || d > dMax) { + dMax = d; + intXB = intersectionPointB.x; + intYB = intersectionPointB.y; + intSlotB = slot; + null !== normalRadians && (intBN = normalRadians.y); + } + } + } + } + if (null !== intSlotA && null !== intersectionPointA) { + intersectionPointA.x = intXA; + intersectionPointA.y = intYA; + null !== normalRadians && (normalRadians.x = intAN); + } + if (null !== intSlotB && null !== intersectionPointB) { + intersectionPointB.x = intXB; + intersectionPointB.y = intYB; + null !== normalRadians && (normalRadians.y = intBN); + } + return intSlotA; + }; + Armature.prototype.getBone = function(name) { + for (var _i = 0, _a = this._bones; _i < _a.length; _i++) { + var bone = _a[_i]; + if (bone.name === name) return bone; + } + return null; + }; + Armature.prototype.getBoneByDisplay = function(display) { + var slot = this.getSlotByDisplay(display); + return null !== slot ? slot.parent : null; + }; + Armature.prototype.getSlot = function(name) { + for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { + var slot = _a[_i]; + if (slot.name === name) return slot; + } + return null; + }; + Armature.prototype.getSlotByDisplay = function(display) { + if (null !== display) for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { + var slot = _a[_i]; + if (slot.display === display) return slot; + } + return null; + }; + Armature.prototype.getBones = function() { + return this._bones; + }; + Armature.prototype.getSlots = function() { + return this._slots; + }; + Object.defineProperty(Armature.prototype, "flipX", { + get: function get() { + return this._flipX; + }, + set: function set(value) { + if (this._flipX === value) return; + this._flipX = value; + this.invalidUpdate(); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Armature.prototype, "flipY", { + get: function get() { + return this._flipY; + }, + set: function set(value) { + if (this._flipY === value) return; + this._flipY = value; + this.invalidUpdate(); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Armature.prototype, "cacheFrameRate", { + get: function get() { + return this._armatureData.cacheFrameRate; + }, + set: function set(value) { + if (this._armatureData.cacheFrameRate !== value) { + this._armatureData.cacheFrames(value); + for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { + var slot = _a[_i]; + var childArmature = slot.childArmature; + null !== childArmature && (childArmature.cacheFrameRate = value); + } + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Armature.prototype, "name", { + get: function get() { + return this._armatureData.name; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Armature.prototype, "armatureData", { + get: function get() { + return this._armatureData; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Armature.prototype, "animation", { + get: function get() { + return this._animation; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Armature.prototype, "proxy", { + get: function get() { + return this._proxy; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Armature.prototype, "eventDispatcher", { + get: function get() { + return this._proxy; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Armature.prototype, "display", { + get: function get() { + return this._display; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Armature.prototype, "replacedTexture", { + get: function get() { + return this._replacedTexture; + }, + set: function set(value) { + if (this._replacedTexture === value) return; + if (null !== this._replaceTextureAtlasData) { + this._replaceTextureAtlasData.returnToPool(); + this._replaceTextureAtlasData = null; + } + this._replacedTexture = value; + for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { + var slot = _a[_i]; + slot.invalidUpdate(); + slot.update(-1); + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Armature.prototype, "clock", { + get: function get() { + return this._clock; + }, + set: function set(value) { + if (this._clock === value) return; + null !== this._clock && this._clock.remove(this); + this._clock = value; + this._clock && this._clock.add(this); + for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { + var slot = _a[_i]; + var childArmature = slot.childArmature; + null !== childArmature && (childArmature.clock = this._clock); + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Armature.prototype, "parent", { + get: function get() { + return this._parent; + }, + enumerable: true, + configurable: true + }); + Armature.prototype.replaceTexture = function(texture) { + this.replacedTexture = texture; + }; + Armature.prototype.hasEventListener = function(type) { + return this._proxy.hasDBEventListener(type); + }; + Armature.prototype.addEventListener = function(type, listener, target) { + this._proxy.addDBEventListener(type, listener, target); + }; + Armature.prototype.removeEventListener = function(type, listener, target) { + this._proxy.removeDBEventListener(type, listener, target); + }; + Armature.prototype.enableAnimationCache = function(frameRate) { + console.warn("Deprecated."); + this.cacheFrameRate = frameRate; + }; + Armature.prototype.getDisplay = function() { + return this._display; + }; + return Armature; + })(dragonBones_1.BaseObject); + dragonBones_1.Armature = Armature; + })(dragonBones || (dragonBones = {})); + var dragonBones; + (function(dragonBones) { + var TransformObject = (function(_super) { + __extends(TransformObject, _super); + function TransformObject() { + var _this = null !== _super && _super.apply(this, arguments) || this; + _this.globalTransformMatrix = new dragonBones.Matrix(); + _this.global = new dragonBones.Transform(); + _this.offset = new dragonBones.Transform(); + return _this; + } + TransformObject.prototype._onClear = function() { + this.globalTransformMatrix.identity(); + this.global.identity(); + this.offset.identity(); + this.origin = null; + this.userData = null; + this._globalDirty = false; + this._armature = null; + }; + TransformObject.prototype.updateGlobalTransform = function() { + if (this._globalDirty) { + this._globalDirty = false; + this.global.fromMatrix(this.globalTransformMatrix); + } + }; + Object.defineProperty(TransformObject.prototype, "armature", { + get: function get() { + return this._armature; + }, + enumerable: true, + configurable: true + }); + TransformObject._helpMatrix = new dragonBones.Matrix(); + TransformObject._helpTransform = new dragonBones.Transform(); + TransformObject._helpPoint = new dragonBones.Point(); + return TransformObject; + })(dragonBones.BaseObject); + dragonBones.TransformObject = TransformObject; + })(dragonBones || (dragonBones = {})); + var dragonBones; + (function(dragonBones) { + var Bone = (function(_super) { + __extends(Bone, _super); + function Bone() { + var _this = null !== _super && _super.apply(this, arguments) || this; + _this.animationPose = new dragonBones.Transform(); + _this._blendState = new dragonBones.BlendState(); + return _this; + } + Bone.toString = function() { + return "[class dragonBones.Bone]"; + }; + Bone.prototype._onClear = function() { + _super.prototype._onClear.call(this); + this.offsetMode = 1; + this.animationPose.identity(); + this._transformDirty = false; + this._childrenTransformDirty = false; + this._localDirty = true; + this._hasConstraint = false; + this._visible = true; + this._cachedFrameIndex = -1; + this._blendState.clear(); + this._boneData = null; + this._parent = null; + this._cachedFrameIndices = null; + }; + Bone.prototype._updateGlobalTransformMatrix = function(isCache) { + var boneData = this._boneData; + var global = this.global; + var globalTransformMatrix = this.globalTransformMatrix; + var origin = this.origin; + var offset = this.offset; + var animationPose = this.animationPose; + var parent = this._parent; + var flipX = this._armature.flipX; + var flipY = this._armature.flipY === dragonBones.DragonBones.yDown; + var inherit = null !== parent; + var rotation = 0; + if (1 === this.offsetMode) if (null !== origin) { + global.x = origin.x + offset.x + animationPose.x; + global.scaleX = origin.scaleX * offset.scaleX * animationPose.scaleX; + global.scaleY = origin.scaleY * offset.scaleY * animationPose.scaleY; + if (dragonBones.DragonBones.yDown) { + global.y = origin.y + offset.y + animationPose.y; + global.skew = origin.skew + offset.skew + animationPose.skew; + global.rotation = origin.rotation + offset.rotation + animationPose.rotation; + } else { + global.y = origin.y - offset.y + animationPose.y; + global.skew = origin.skew - offset.skew + animationPose.skew; + global.rotation = origin.rotation - offset.rotation + animationPose.rotation; + } + } else { + global.copyFrom(offset); + if (!dragonBones.DragonBones.yDown) { + global.y = -global.y; + global.skew = -global.skew; + global.rotation = -global.rotation; + } + global.add(animationPose); + } else if (0 === this.offsetMode) null !== origin ? global.copyFrom(origin).add(animationPose) : global.copyFrom(animationPose); else { + inherit = false; + global.copyFrom(offset); + if (!dragonBones.DragonBones.yDown) { + global.y = -global.y; + global.skew = -global.skew; + global.rotation = -global.rotation; + } + } + if (inherit) { + var parentMatrix = 0 === parent._boneData.type ? parent.globalTransformMatrix : parent._getGlobalTransformMatrix(global.x, global.y); + if (boneData.inheritScale) { + if (!boneData.inheritRotation) { + parent.updateGlobalTransform(); + rotation = flipX && flipY ? global.rotation - (parent.global.rotation + Math.PI) : flipX ? global.rotation + parent.global.rotation + Math.PI : flipY ? global.rotation + parent.global.rotation : global.rotation - parent.global.rotation; + global.rotation = rotation; + } + global.toMatrix(globalTransformMatrix); + globalTransformMatrix.concat(parentMatrix); + if (boneData.inheritTranslation) { + global.x = globalTransformMatrix.tx; + global.y = globalTransformMatrix.ty; + } else { + globalTransformMatrix.tx = global.x; + globalTransformMatrix.ty = global.y; + } + isCache ? global.fromMatrix(globalTransformMatrix) : this._globalDirty = true; + } else { + if (boneData.inheritTranslation) { + var x = global.x; + var y = global.y; + global.x = parentMatrix.a * x + parentMatrix.c * y + parentMatrix.tx; + global.y = parentMatrix.b * x + parentMatrix.d * y + parentMatrix.ty; + } else { + flipX && (global.x = -global.x); + flipY && (global.y = -global.y); + } + if (boneData.inheritRotation) { + parent.updateGlobalTransform(); + rotation = parent.global.scaleX < 0 ? global.rotation + parent.global.rotation + Math.PI : global.rotation + parent.global.rotation; + if (parentMatrix.a * parentMatrix.d - parentMatrix.b * parentMatrix.c < 0) { + rotation -= 2 * global.rotation; + (flipX !== flipY || boneData.inheritReflection) && (global.skew += Math.PI); + dragonBones.DragonBones.yDown || (global.skew = -global.skew); + } + global.rotation = rotation; + } else if (flipX || flipY) { + if (flipX && flipY) rotation = global.rotation + Math.PI; else { + rotation = flipX ? Math.PI - global.rotation : -global.rotation; + global.skew += Math.PI; + } + global.rotation = rotation; + } + global.toMatrix(globalTransformMatrix); + } + } else { + if (flipX || flipY) { + flipX && (global.x = -global.x); + flipY && (global.y = -global.y); + if (flipX && flipY) rotation = global.rotation + Math.PI; else { + rotation = flipX ? Math.PI - global.rotation : -global.rotation; + global.skew += Math.PI; + } + global.rotation = rotation; + } + global.toMatrix(globalTransformMatrix); + } + }; + Bone.prototype.init = function(boneData, armatureValue) { + if (null !== this._boneData) return; + this._boneData = boneData; + this._armature = armatureValue; + null !== this._boneData.parent && (this._parent = this._armature.getBone(this._boneData.parent.name)); + this._armature._addBone(this); + this.origin = this._boneData.transform; + }; + Bone.prototype.update = function(cacheFrameIndex) { + this._blendState.dirty = false; + if (cacheFrameIndex >= 0 && null !== this._cachedFrameIndices) { + var cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex]; + if (cachedFrameIndex >= 0 && this._cachedFrameIndex === cachedFrameIndex) this._transformDirty = false; else if (cachedFrameIndex >= 0) { + this._transformDirty = true; + this._cachedFrameIndex = cachedFrameIndex; + } else { + if (this._hasConstraint) for (var _i = 0, _a = this._armature._constraints; _i < _a.length; _i++) { + var constraint = _a[_i]; + constraint._root === this && constraint.update(); + } + if (this._transformDirty || null !== this._parent && this._parent._childrenTransformDirty) { + this._transformDirty = true; + this._cachedFrameIndex = -1; + } else if (this._cachedFrameIndex >= 0) { + this._transformDirty = false; + this._cachedFrameIndices[cacheFrameIndex] = this._cachedFrameIndex; + } else { + this._transformDirty = true; + this._cachedFrameIndex = -1; + } + } + } else { + if (this._hasConstraint) for (var _b = 0, _c = this._armature._constraints; _b < _c.length; _b++) { + var constraint = _c[_b]; + constraint._root === this && constraint.update(); + } + if (this._transformDirty || null !== this._parent && this._parent._childrenTransformDirty) { + cacheFrameIndex = -1; + this._transformDirty = true; + this._cachedFrameIndex = -1; + } + } + if (this._transformDirty) { + this._transformDirty = false; + this._childrenTransformDirty = true; + if (this._cachedFrameIndex < 0) { + var isCache = cacheFrameIndex >= 0; + this._localDirty && this._updateGlobalTransformMatrix(isCache); + isCache && null !== this._cachedFrameIndices && (this._cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex] = this._armature._armatureData.setCacheFrame(this.globalTransformMatrix, this.global)); + } else this._armature._armatureData.getCacheFrame(this.globalTransformMatrix, this.global, this._cachedFrameIndex); + } else this._childrenTransformDirty && (this._childrenTransformDirty = false); + this._localDirty = true; + }; + Bone.prototype.updateByConstraint = function() { + if (this._localDirty) { + this._localDirty = false; + (this._transformDirty || null !== this._parent && this._parent._childrenTransformDirty) && this._updateGlobalTransformMatrix(true); + this._transformDirty = true; + } + }; + Bone.prototype.invalidUpdate = function() { + this._transformDirty = true; + }; + Bone.prototype.contains = function(value) { + if (value === this) return false; + var ancestor = value; + while (ancestor !== this && null !== ancestor) ancestor = ancestor.parent; + return ancestor === this; + }; + Object.defineProperty(Bone.prototype, "boneData", { + get: function get() { + return this._boneData; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Bone.prototype, "visible", { + get: function get() { + return this._visible; + }, + set: function set(value) { + if (this._visible === value) return; + this._visible = value; + for (var _i = 0, _a = this._armature.getSlots(); _i < _a.length; _i++) { + var slot = _a[_i]; + slot.parent === this && slot._updateVisible(); + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Bone.prototype, "name", { + get: function get() { + return this._boneData.name; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Bone.prototype, "parent", { + get: function get() { + return this._parent; + }, + enumerable: true, + configurable: true + }); + Bone.prototype.getBones = function() { + console.warn("Deprecated."); + var bones = new Array(); + for (var _i = 0, _a = this._armature.getBones(); _i < _a.length; _i++) { + var bone = _a[_i]; + bone.parent === this && bones.push(bone); + } + return bones; + }; + Bone.prototype.getSlots = function() { + console.warn("Deprecated."); + var slots = new Array(); + for (var _i = 0, _a = this._armature.getSlots(); _i < _a.length; _i++) { + var slot = _a[_i]; + slot.parent === this && slots.push(slot); + } + return slots; + }; + Object.defineProperty(Bone.prototype, "slot", { + get: function get() { + console.warn("Deprecated."); + for (var _i = 0, _a = this._armature.getSlots(); _i < _a.length; _i++) { + var slot = _a[_i]; + if (slot.parent === this) return slot; + } + return null; + }, + enumerable: true, + configurable: true + }); + return Bone; + })(dragonBones.TransformObject); + dragonBones.Bone = Bone; + })(dragonBones || (dragonBones = {})); + var dragonBones; + (function(dragonBones) { + var Surface = (function(_super) { + __extends(Surface, _super); + function Surface() { + var _this = null !== _super && _super.apply(this, arguments) || this; + _this._vertices = []; + _this._deformVertices = []; + _this._hullCache = []; + _this._matrixCahce = []; + return _this; + } + Surface.toString = function() { + return "[class dragonBones.Surface]"; + }; + Surface.prototype._onClear = function() { + _super.prototype._onClear.call(this); + this._dX = 0; + this._dY = 0; + this._k = 0; + this._kX = 0; + this._kY = 0; + this._vertices.length = 0; + this._deformVertices.length = 0; + this._matrixCahce.length = 0; + this._hullCache.length = 0; + }; + Surface.prototype._getAffineTransform = function(x, y, lX, lY, aX, aY, bX, bY, cX, cY, transform, matrix, isDown) { + var dabX = bX - aX; + var dabY = bY - aY; + var dacX = cX - aX; + var dacY = cY - aY; + transform.rotation = Math.atan2(dabY, dabX); + transform.skew = Math.atan2(dacY, dacX) - .5 * Math.PI - transform.rotation; + isDown && (transform.rotation += Math.PI); + transform.scaleX = Math.sqrt(dabX * dabX + dabY * dabY) / lX; + transform.scaleY = Math.sqrt(dacX * dacX + dacY * dacY) / lY; + transform.toMatrix(matrix); + transform.x = matrix.tx = aX - (matrix.a * x + matrix.c * y); + transform.y = matrix.ty = aY - (matrix.b * x + matrix.d * y); + }; + Surface.prototype._updateVertices = function() { + var originalVertices = this._boneData.vertices; + var vertices = this._vertices; + var animationVertices = this._deformVertices; + if (null !== this._parent) if (1 === this._parent._boneData.type) for (var i = 0, l = originalVertices.length; i < l; i += 2) { + var x = originalVertices[i] + animationVertices[i]; + var y = originalVertices[i + 1] + animationVertices[i]; + var matrix = this._parent._getGlobalTransformMatrix(x, y); + vertices[i] = matrix.a * x + matrix.c * y + matrix.tx; + vertices[i + 1] = matrix.b * x + matrix.d * y + matrix.ty; + } else { + var parentMatrix = this._parent.globalTransformMatrix; + for (var i = 0, l = originalVertices.length; i < l; i += 2) { + var x = originalVertices[i] + animationVertices[i]; + var y = originalVertices[i + 1] + animationVertices[i + 1]; + vertices[i] = parentMatrix.a * x + parentMatrix.c * y + parentMatrix.tx; + vertices[i + 1] = parentMatrix.b * x + parentMatrix.d * y + parentMatrix.ty; + } + } else for (var i = 0, l = originalVertices.length; i < l; i += 2) { + vertices[i] = originalVertices[i] + animationVertices[i]; + vertices[i + 1] = originalVertices[i + 1] + animationVertices[i + 1]; + } + }; + Surface.prototype._updateGlobalTransformMatrix = function(isCache) { + isCache; + var segmentXD = 2 * this._boneData.segmentX; + var lastIndex = this._vertices.length - 2; + var lA = 200; + var raX = this._vertices[0]; + var raY = this._vertices[1]; + var rbX = this._vertices[segmentXD]; + var rbY = this._vertices[segmentXD + 1]; + var rcX = this._vertices[lastIndex]; + var rcY = this._vertices[lastIndex + 1]; + var rdX = this._vertices[lastIndex - segmentXD]; + var rdY = this._vertices[lastIndex - segmentXD + 1]; + var dacX = raX + .5 * (rcX - raX); + var dacY = raY + .5 * (rcY - raY); + var dbdX = rbX + .5 * (rdX - rbX); + var dbdY = rbY + .5 * (rdY - rbY); + var aX = dacX + .5 * (dbdX - dacX); + var aY = dacY + .5 * (dbdY - dacY); + var bX = rbX + .5 * (rcX - rbX); + var bY = rbY + .5 * (rcY - rbY); + var cX = rdX + .5 * (rcX - rdX); + var cY = rdY + .5 * (rcY - rdY); + this._globalDirty = false; + this._getAffineTransform(0, 0, lA, lA, aX, aY, bX, bY, cX, cY, this.global, this.globalTransformMatrix, false); + }; + Surface.prototype._getGlobalTransformMatrix = function(x, y) { + var lB = 1e3; + if (x < -lB || lB < x || y < -lB || lB < y) return this.globalTransformMatrix; + var isDown = false; + var lA = 200; + var surfaceData = this._boneData; + var segmentX = surfaceData.segmentX; + var segmentY = surfaceData.segmentY; + var segmentXD = 2 * surfaceData.segmentX; + var dX = this._dX; + var dY = this._dY; + var indexX = Math.floor((x + lA) / dX); + var indexY = Math.floor((y + lA) / dY); + var matrixIndex = 0; + var pX = indexX * dX - lA; + var pY = indexY * dY - lA; + var matrices = this._matrixCahce; + var helpMatrix = Surface._helpMatrix; + if (x < -lA) { + if (y < -lA || y >= lA) return this.globalTransformMatrix; + isDown = y > this._kX * (x + lA) + pY; + matrixIndex = 7 * (2 * (segmentX * (segmentY + 1) + 2 * segmentX + segmentY + indexY) + (isDown ? 1 : 0)); + if (this._matrixCahce[matrixIndex] > 0) helpMatrix.copyFromArray(matrices, matrixIndex + 1); else { + var vertexIndex = indexY * (segmentXD + 2); + var ddX = this._hullCache[4]; + var ddY = this._hullCache[5]; + var sX = this._hullCache[2] - (segmentY - indexY) * ddX; + var sY = this._hullCache[3] - (segmentY - indexY) * ddY; + var vertices = this._vertices; + isDown ? this._getAffineTransform(-lA, pY + dY, lB - lA, dY, vertices[vertexIndex + segmentXD + 2], vertices[vertexIndex + segmentXD + 3], sX + ddX, sY + ddY, vertices[vertexIndex], vertices[vertexIndex + 1], Surface._helpTransform, helpMatrix, true) : this._getAffineTransform(-lB, pY, lB - lA, dY, sX, sY, vertices[vertexIndex], vertices[vertexIndex + 1], sX + ddX, sY + ddY, Surface._helpTransform, helpMatrix, false); + matrices[matrixIndex] = 1; + matrices[matrixIndex + 1] = helpMatrix.a; + matrices[matrixIndex + 2] = helpMatrix.b; + matrices[matrixIndex + 3] = helpMatrix.c; + matrices[matrixIndex + 4] = helpMatrix.d; + matrices[matrixIndex + 5] = helpMatrix.tx; + matrices[matrixIndex + 6] = helpMatrix.ty; + } + } else if (x >= lA) { + if (y < -lA || y >= lA) return this.globalTransformMatrix; + isDown = y > this._kX * (x - lB) + pY; + matrixIndex = 7 * (2 * (segmentX * (segmentY + 1) + segmentX + indexY) + (isDown ? 1 : 0)); + if (this._matrixCahce[matrixIndex] > 0) helpMatrix.copyFromArray(matrices, matrixIndex + 1); else { + var vertexIndex = (indexY + 1) * (segmentXD + 2) - 2; + var ddX = this._hullCache[4]; + var ddY = this._hullCache[5]; + var sX = this._hullCache[0] + indexY * ddX; + var sY = this._hullCache[1] + indexY * ddY; + var vertices = this._vertices; + isDown ? this._getAffineTransform(lB, pY + dY, lB - lA, dY, sX + ddX, sY + ddY, vertices[vertexIndex + segmentXD + 2], vertices[vertexIndex + segmentXD + 3], sX, sY, Surface._helpTransform, helpMatrix, true) : this._getAffineTransform(lA, pY, lB - lA, dY, vertices[vertexIndex], vertices[vertexIndex + 1], sX, sY, vertices[vertexIndex + segmentXD + 2], vertices[vertexIndex + segmentXD + 3], Surface._helpTransform, helpMatrix, false); + matrices[matrixIndex] = 1; + matrices[matrixIndex + 1] = helpMatrix.a; + matrices[matrixIndex + 2] = helpMatrix.b; + matrices[matrixIndex + 3] = helpMatrix.c; + matrices[matrixIndex + 4] = helpMatrix.d; + matrices[matrixIndex + 5] = helpMatrix.tx; + matrices[matrixIndex + 6] = helpMatrix.ty; + } + } else if (y < -lA) { + if (x < -lA || x >= lA) return this.globalTransformMatrix; + isDown = y > this._kY * (x - pX - dX) - lB; + matrixIndex = 7 * (segmentX * (segmentY + 1) + 2 * indexX + (isDown ? 1 : 0)); + if (this._matrixCahce[matrixIndex] > 0) helpMatrix.copyFromArray(matrices, matrixIndex + 1); else { + var vertexIndex = 2 * indexX; + var ddX = this._hullCache[10]; + var ddY = this._hullCache[11]; + var sX = this._hullCache[8] + indexX * ddX; + var sY = this._hullCache[9] + indexX * ddY; + var vertices = this._vertices; + isDown ? this._getAffineTransform(pX + dX, -lA, dX, lB - lA, vertices[vertexIndex + 2], vertices[vertexIndex + 3], vertices[vertexIndex], vertices[vertexIndex + 1], sX + ddX, sY + ddY, Surface._helpTransform, helpMatrix, true) : this._getAffineTransform(pX, -lB, dX, lB - lA, sX, sY, sX + ddX, sY + ddY, vertices[vertexIndex], vertices[vertexIndex + 1], Surface._helpTransform, helpMatrix, false); + matrices[matrixIndex] = 1; + matrices[matrixIndex + 1] = helpMatrix.a; + matrices[matrixIndex + 2] = helpMatrix.b; + matrices[matrixIndex + 3] = helpMatrix.c; + matrices[matrixIndex + 4] = helpMatrix.d; + matrices[matrixIndex + 5] = helpMatrix.tx; + matrices[matrixIndex + 6] = helpMatrix.ty; + } + } else if (y >= lA) { + if (x < -lA || x >= lA) return this.globalTransformMatrix; + isDown = y > this._kY * (x - pX - dX) + lA; + matrixIndex = 7 * (2 * (segmentX * (segmentY + 1) + segmentX + segmentY + indexY) + (isDown ? 1 : 0)); + if (this._matrixCahce[matrixIndex] > 0) helpMatrix.copyFromArray(matrices, matrixIndex + 1); else { + var vertexIndex = segmentY * (segmentXD + 2) + 2 * indexX; + var ddX = this._hullCache[10]; + var ddY = this._hullCache[11]; + var sX = this._hullCache[6] - (segmentX - indexX) * ddX; + var sY = this._hullCache[7] - (segmentX - indexX) * ddY; + var vertices = this._vertices; + isDown ? this._getAffineTransform(pX + dX, lB, dX, lB - lA, sX + ddX, sY + ddY, sX, sY, vertices[vertexIndex + 2], vertices[vertexIndex + 3], Surface._helpTransform, helpMatrix, true) : this._getAffineTransform(pX, lA, dX, lB - lA, vertices[vertexIndex], vertices[vertexIndex + 1], vertices[vertexIndex + 2], vertices[vertexIndex + 3], sX, sY, Surface._helpTransform, helpMatrix, false); + matrices[matrixIndex] = 1; + matrices[matrixIndex + 1] = helpMatrix.a; + matrices[matrixIndex + 2] = helpMatrix.b; + matrices[matrixIndex + 3] = helpMatrix.c; + matrices[matrixIndex + 4] = helpMatrix.d; + matrices[matrixIndex + 5] = helpMatrix.tx; + matrices[matrixIndex + 6] = helpMatrix.ty; + } + } else { + isDown = y > this._k * (x - pX - dX) + pY; + matrixIndex = 7 * (2 * (segmentX * indexY + indexX) + (isDown ? 1 : 0)); + if (this._matrixCahce[matrixIndex] > 0) helpMatrix.copyFromArray(matrices, matrixIndex + 1); else { + var vertexIndex = 2 * indexX + indexY * (segmentXD + 2); + var vertices = this._vertices; + isDown ? this._getAffineTransform(pX + dX, pY + dY, dX, dY, vertices[vertexIndex + segmentXD + 4], vertices[vertexIndex + segmentXD + 5], vertices[vertexIndex + segmentXD + 2], vertices[vertexIndex + segmentXD + 3], vertices[vertexIndex + 2], vertices[vertexIndex + 3], Surface._helpTransform, helpMatrix, true) : this._getAffineTransform(pX, pY, dX, dY, vertices[vertexIndex], vertices[vertexIndex + 1], vertices[vertexIndex + 2], vertices[vertexIndex + 3], vertices[vertexIndex + segmentXD + 2], vertices[vertexIndex + segmentXD + 3], Surface._helpTransform, helpMatrix, false); + matrices[matrixIndex] = 1; + matrices[matrixIndex + 1] = helpMatrix.a; + matrices[matrixIndex + 2] = helpMatrix.b; + matrices[matrixIndex + 3] = helpMatrix.c; + matrices[matrixIndex + 4] = helpMatrix.d; + matrices[matrixIndex + 5] = helpMatrix.tx; + matrices[matrixIndex + 6] = helpMatrix.ty; + } + } + return helpMatrix; + }; + Surface.prototype.init = function(surfaceData, armatureValue) { + if (null !== this._boneData) return; + _super.prototype.init.call(this, surfaceData, armatureValue); + var segmentX = surfaceData.segmentX; + var segmentY = surfaceData.segmentY; + var vertexCount = surfaceData.vertices.length; + var lB = 1e3; + var lA = 200; + this._dX = 2 * lA / segmentX; + this._dY = 2 * lA / segmentY; + this._k = -this._dY / this._dX; + this._kX = -this._dY / (lB - lA); + this._kY = -(lB - lA) / this._dX; + this._vertices.length = vertexCount; + this._deformVertices.length = vertexCount; + this._matrixCahce.length = 2 * (segmentX * segmentY + 2 * segmentX + 2 * segmentY) * 7; + this._hullCache.length = 10; + for (var i = 0; i < vertexCount; ++i) this._deformVertices[i] = 0; + }; + Surface.prototype.update = function(cacheFrameIndex) { + this._blendState.dirty = false; + if (cacheFrameIndex >= 0 && null !== this._cachedFrameIndices) { + var cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex]; + if (cachedFrameIndex >= 0 && this._cachedFrameIndex === cachedFrameIndex) this._transformDirty = false; else if (cachedFrameIndex >= 0) { + this._transformDirty = true; + this._cachedFrameIndex = cachedFrameIndex; + } else { + if (this._hasConstraint) for (var _i = 0, _a = this._armature._constraints; _i < _a.length; _i++) { + var constraint = _a[_i]; + constraint._root === this && constraint.update(); + } + if (this._transformDirty || null !== this._parent && this._parent._childrenTransformDirty) { + this._transformDirty = true; + this._cachedFrameIndex = -1; + } else if (this._cachedFrameIndex >= 0) { + this._transformDirty = false; + this._cachedFrameIndices[cacheFrameIndex] = this._cachedFrameIndex; + } else { + this._transformDirty = true; + this._cachedFrameIndex = -1; + } + } + } else { + if (this._hasConstraint) for (var _b = 0, _c = this._armature._constraints; _b < _c.length; _b++) { + var constraint = _c[_b]; + constraint._root === this && constraint.update(); + } + if (this._transformDirty || null !== this._parent && this._parent._childrenTransformDirty) { + cacheFrameIndex = -1; + this._transformDirty = true; + this._cachedFrameIndex = -1; + } + } + if (this._transformDirty) { + this._transformDirty = false; + this._childrenTransformDirty = true; + for (var i = 0, l = this._matrixCahce.length; i < l; i += 7) this._matrixCahce[i] = -1; + this._updateVertices(); + if (this._cachedFrameIndex < 0) { + var isCache = cacheFrameIndex >= 0; + this._localDirty && this._updateGlobalTransformMatrix(isCache); + isCache && null !== this._cachedFrameIndices && (this._cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex] = this._armature._armatureData.setCacheFrame(this.globalTransformMatrix, this.global)); + } else this._armature._armatureData.getCacheFrame(this.globalTransformMatrix, this.global, this._cachedFrameIndex); + var lB = 1e3; + var lA = 200; + var ddX = 2 * this.global.x; + var ddY = 2 * this.global.y; + var helpPoint = Surface._helpPoint; + this.globalTransformMatrix.transformPoint(lB, -lA, helpPoint); + this._hullCache[0] = helpPoint.x; + this._hullCache[1] = helpPoint.y; + this._hullCache[2] = ddX - helpPoint.x; + this._hullCache[3] = ddY - helpPoint.y; + this.globalTransformMatrix.transformPoint(0, this._dY, helpPoint, true); + this._hullCache[4] = helpPoint.x; + this._hullCache[5] = helpPoint.y; + this.globalTransformMatrix.transformPoint(lA, lB, helpPoint); + this._hullCache[6] = helpPoint.x; + this._hullCache[7] = helpPoint.y; + this._hullCache[8] = ddX - helpPoint.x; + this._hullCache[9] = ddY - helpPoint.y; + this.globalTransformMatrix.transformPoint(this._dX, 0, helpPoint, true); + this._hullCache[10] = helpPoint.x; + this._hullCache[11] = helpPoint.y; + } else this._childrenTransformDirty && (this._childrenTransformDirty = false); + this._localDirty = true; + }; + return Surface; + })(dragonBones.Bone); + dragonBones.Surface = Surface; + })(dragonBones || (dragonBones = {})); + var dragonBones; + (function(dragonBones) { + var Slot = (function(_super) { + __extends(Slot, _super); + function Slot() { + var _this = null !== _super && _super.apply(this, arguments) || this; + _this._localMatrix = new dragonBones.Matrix(); + _this._colorTransform = new dragonBones.ColorTransform(); + _this._displayDatas = []; + _this._displayList = []; + _this._deformVertices = null; + _this._rawDisplay = null; + _this._meshDisplay = null; + return _this; + } + Slot.prototype._onClear = function() { + _super.prototype._onClear.call(this); + var disposeDisplayList = []; + for (var _i = 0, _a = this._displayList; _i < _a.length; _i++) { + var eachDisplay = _a[_i]; + null !== eachDisplay && eachDisplay !== this._rawDisplay && eachDisplay !== this._meshDisplay && disposeDisplayList.indexOf(eachDisplay) < 0 && disposeDisplayList.push(eachDisplay); + } + for (var _b = 0, disposeDisplayList_1 = disposeDisplayList; _b < disposeDisplayList_1.length; _b++) { + var eachDisplay = disposeDisplayList_1[_b]; + eachDisplay instanceof dragonBones.Armature ? eachDisplay.dispose() : this._disposeDisplay(eachDisplay, true); + } + null !== this._deformVertices && this._deformVertices.returnToPool(); + null !== this._meshDisplay && this._meshDisplay !== this._rawDisplay && this._disposeDisplay(this._meshDisplay, false); + null !== this._rawDisplay && this._disposeDisplay(this._rawDisplay, false); + this.displayController = null; + this._displayDirty = false; + this._zOrderDirty = false; + this._blendModeDirty = false; + this._colorDirty = false; + this._transformDirty = false; + this._visible = true; + this._blendMode = 0; + this._displayIndex = -1; + this._animationDisplayIndex = -1; + this._zOrder = 0; + this._cachedFrameIndex = -1; + this._pivotX = 0; + this._pivotY = 0; + this._localMatrix.identity(); + this._colorTransform.identity(); + this._displayList.length = 0; + this._displayDatas.length = 0; + this._slotData = null; + this._rawDisplayDatas = null; + this._displayData = null; + this._boundingBoxData = null; + this._textureData = null; + this._deformVertices = null; + this._rawDisplay = null; + this._meshDisplay = null; + this._display = null; + this._childArmature = null; + this._parent = null; + this._cachedFrameIndices = null; + }; + Slot.prototype._getDefaultRawDisplayData = function(displayIndex) { + var defaultSkin = this._armature._armatureData.defaultSkin; + if (null !== defaultSkin) { + var defaultRawDisplayDatas = defaultSkin.getDisplays(this._slotData.name); + if (null !== defaultRawDisplayDatas) return displayIndex < defaultRawDisplayDatas.length ? defaultRawDisplayDatas[displayIndex] : null; + } + return null; + }; + Slot.prototype._updateDisplayData = function() { + var prevDisplayData = this._displayData; + var prevVerticesData = null !== this._deformVertices ? this._deformVertices.verticesData : null; + var prevTextureData = this._textureData; + var rawDisplayData = null; + var currentVerticesData = null; + this._displayData = null; + this._boundingBoxData = null; + this._textureData = null; + if (this._displayIndex >= 0) { + null !== this._rawDisplayDatas && (rawDisplayData = this._displayIndex < this._rawDisplayDatas.length ? this._rawDisplayDatas[this._displayIndex] : null); + null === rawDisplayData && (rawDisplayData = this._getDefaultRawDisplayData(this._displayIndex)); + this._displayIndex < this._displayDatas.length && (this._displayData = this._displayDatas[this._displayIndex]); + } + if (null !== this._displayData) { + 2 === this._displayData.type ? currentVerticesData = this._displayData.vertices : 4 === this._displayData.type ? currentVerticesData = this._displayData.vertices : null !== rawDisplayData && (2 === rawDisplayData.type ? currentVerticesData = rawDisplayData.vertices : 4 === rawDisplayData.type && (currentVerticesData = rawDisplayData.vertices)); + 3 === this._displayData.type ? this._boundingBoxData = this._displayData.boundingBox : null !== rawDisplayData && 3 === rawDisplayData.type && (this._boundingBoxData = rawDisplayData.boundingBox); + 0 === this._displayData.type ? this._textureData = this._displayData.texture : 2 === this._displayData.type && (this._textureData = this._displayData.texture); + } + if (this._displayData !== prevDisplayData || currentVerticesData !== prevVerticesData || this._textureData !== prevTextureData) { + if (null === currentVerticesData && null !== this._textureData) { + var imageDisplayData = this._displayData; + var scale = this._textureData.parent.scale * this._armature._armatureData.scale; + var frame = this._textureData.frame; + this._pivotX = imageDisplayData.pivot.x; + this._pivotY = imageDisplayData.pivot.y; + var rect = null !== frame ? frame : this._textureData.region; + var width = rect.width; + var height = rect.height; + if (this._textureData.rotated && null === frame) { + width = rect.height; + height = rect.width; + } + this._pivotX *= width * scale; + this._pivotY *= height * scale; + if (null !== frame) { + this._pivotX += frame.x * scale; + this._pivotY += frame.y * scale; + } + if (null !== this._displayData && null !== rawDisplayData && this._displayData !== rawDisplayData) { + rawDisplayData.transform.toMatrix(Slot._helpMatrix); + Slot._helpMatrix.invert(); + Slot._helpMatrix.transformPoint(0, 0, Slot._helpPoint); + this._pivotX -= Slot._helpPoint.x; + this._pivotY -= Slot._helpPoint.y; + this._displayData.transform.toMatrix(Slot._helpMatrix); + Slot._helpMatrix.invert(); + Slot._helpMatrix.transformPoint(0, 0, Slot._helpPoint); + this._pivotX += Slot._helpPoint.x; + this._pivotY += Slot._helpPoint.y; + } + dragonBones.DragonBones.yDown || (this._pivotY = (this._textureData.rotated ? this._textureData.region.width : this._textureData.region.height) * scale - this._pivotY); + } else { + this._pivotX = 0; + this._pivotY = 0; + } + null !== rawDisplayData ? this.origin = rawDisplayData.transform : null !== this._displayData ? this.origin = this._displayData.transform : this.origin = null; + if (currentVerticesData !== prevVerticesData) { + null === this._deformVertices && (this._deformVertices = dragonBones.BaseObject.borrowObject(dragonBones.DeformVertices)); + this._deformVertices.init(currentVerticesData, this._armature); + } else null !== this._deformVertices && this._textureData !== prevTextureData && (this._deformVertices.verticesDirty = true); + this._displayDirty = true; + this._transformDirty = true; + } + }; + Slot.prototype._updateDisplay = function() { + var prevDisplay = null !== this._display ? this._display : this._rawDisplay; + var prevChildArmature = this._childArmature; + if (this._displayIndex >= 0 && this._displayIndex < this._displayList.length) { + this._display = this._displayList[this._displayIndex]; + if (null !== this._display && this._display instanceof dragonBones.Armature) { + this._childArmature = this._display; + this._display = this._childArmature.display; + } else this._childArmature = null; + } else { + this._display = null; + this._childArmature = null; + } + var currentDisplay = null !== this._display ? this._display : this._rawDisplay; + if (currentDisplay !== prevDisplay) { + this._onUpdateDisplay(); + this._replaceDisplay(prevDisplay); + this._transformDirty = true; + this._visibleDirty = true; + this._blendModeDirty = true; + this._colorDirty = true; + } + currentDisplay !== this._rawDisplay && currentDisplay !== this._meshDisplay || this._updateFrame(); + if (this._childArmature !== prevChildArmature) { + if (null !== prevChildArmature) { + prevChildArmature._parent = null; + prevChildArmature.clock = null; + prevChildArmature.inheritAnimation && prevChildArmature.animation.reset(); + } + if (null !== this._childArmature) { + this._childArmature._parent = this; + this._childArmature.clock = this._armature.clock; + if (this._childArmature.inheritAnimation) { + if (0 === this._childArmature.cacheFrameRate) { + var cacheFrameRate = this._armature.cacheFrameRate; + 0 !== cacheFrameRate && (this._childArmature.cacheFrameRate = cacheFrameRate); + } + var actions = null; + if (null !== this._displayData && 1 === this._displayData.type) actions = this._displayData.actions; else if (this._displayIndex >= 0 && null !== this._rawDisplayDatas) { + var rawDisplayData = this._displayIndex < this._rawDisplayDatas.length ? this._rawDisplayDatas[this._displayIndex] : null; + null === rawDisplayData && (rawDisplayData = this._getDefaultRawDisplayData(this._displayIndex)); + null !== rawDisplayData && 1 === rawDisplayData.type && (actions = rawDisplayData.actions); + } + if (null !== actions && actions.length > 0) for (var _i = 0, actions_1 = actions; _i < actions_1.length; _i++) { + var action = actions_1[_i]; + var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); + dragonBones.EventObject.actionDataToInstance(action, eventObject, this._armature); + eventObject.slot = this; + this._armature._bufferAction(eventObject, false); + } else this._childArmature.animation.play(); + } + } + } + }; + Slot.prototype._updateGlobalTransformMatrix = function(isCache) { + var parentMatrix = 0 === this._parent._boneData.type ? this._parent.globalTransformMatrix : this._parent._getGlobalTransformMatrix(this.global.x, this.global.y); + this.globalTransformMatrix.copyFrom(this._localMatrix); + this.globalTransformMatrix.concat(parentMatrix); + isCache ? this.global.fromMatrix(this.globalTransformMatrix) : this._globalDirty = true; + }; + Slot.prototype._setDisplayIndex = function(value, isAnimation) { + void 0 === isAnimation && (isAnimation = false); + if (isAnimation) { + if (this._animationDisplayIndex === value) return false; + this._animationDisplayIndex = value; + } + if (this._displayIndex === value) return false; + this._displayIndex = value; + this._displayDirty = true; + this._updateDisplayData(); + return this._displayDirty; + }; + Slot.prototype._setZorder = function(value) { + this._zOrder === value; + this._zOrder = value; + this._zOrderDirty = true; + return this._zOrderDirty; + }; + Slot.prototype._setColor = function(value) { + this._colorTransform.copyFrom(value); + this._colorDirty = true; + return this._colorDirty; + }; + Slot.prototype._setDisplayList = function(value) { + if (null !== value && value.length > 0) { + this._displayList.length !== value.length && (this._displayList.length = value.length); + for (var i = 0, l = value.length; i < l; ++i) { + var eachDisplay = value[i]; + null !== eachDisplay && eachDisplay !== this._rawDisplay && eachDisplay !== this._meshDisplay && !(eachDisplay instanceof dragonBones.Armature) && this._displayList.indexOf(eachDisplay) < 0 && this._initDisplay(eachDisplay, true); + this._displayList[i] = eachDisplay; + } + } else this._displayList.length > 0 && (this._displayList.length = 0); + this._displayIndex >= 0 && this._displayIndex < this._displayList.length ? this._displayDirty = this._display !== this._displayList[this._displayIndex] : this._displayDirty = null !== this._display; + this._updateDisplayData(); + return this._displayDirty; + }; + Slot.prototype.init = function(slotData, armatureValue, rawDisplay, meshDisplay) { + if (null !== this._slotData) return; + this._slotData = slotData; + this._isFromCache = false; + this._visibleDirty = true; + this._blendModeDirty = true; + this._colorDirty = true; + this._blendMode = this._slotData.blendMode; + this._zOrder = this._slotData.zOrder; + this._colorTransform.copyFrom(this._slotData.color); + this._rawDisplay = rawDisplay; + this._meshDisplay = meshDisplay; + this._armature = armatureValue; + var slotParent = this._armature.getBone(this._slotData.parent.name); + null !== slotParent && (this._parent = slotParent); + this._armature._addSlot(this); + this._initDisplay(this._rawDisplay, false); + this._rawDisplay !== this._meshDisplay && this._initDisplay(this._meshDisplay, false); + this._onUpdateDisplay(); + this._addDisplay(); + }; + Slot.prototype.update = function(cacheFrameIndex) { + this._isFromCache = false; + if (this._displayDirty) { + this._displayDirty = false; + this._updateDisplay(); + this._transformDirty && (null !== this.origin ? this.global.copyFrom(this.origin).add(this.offset).toMatrix(this._localMatrix) : this.global.copyFrom(this.offset).toMatrix(this._localMatrix)); + } + if (this._zOrderDirty) { + this._zOrderDirty = false; + this._updateZOrder(); + } + if (cacheFrameIndex >= 0 && null !== this._cachedFrameIndices) { + var cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex]; + if (cachedFrameIndex >= 0 && this._cachedFrameIndex === cachedFrameIndex) this._transformDirty = false; else if (cachedFrameIndex >= 0) { + this._transformDirty = true; + this._cachedFrameIndex = cachedFrameIndex; + } else if (this._transformDirty || this._parent._childrenTransformDirty) { + this._transformDirty = true; + this._cachedFrameIndex = -1; + } else if (this._cachedFrameIndex >= 0) { + this._transformDirty = false; + this._cachedFrameIndices[cacheFrameIndex] = this._cachedFrameIndex; + } else { + this._transformDirty = true; + this._cachedFrameIndex = -1; + } + } else if (this._transformDirty || this._parent._childrenTransformDirty) { + cacheFrameIndex = -1; + this._transformDirty = true; + this._cachedFrameIndex = -1; + } + if (null === this._display) return; + if (this._visibleDirty) { + this._visibleDirty = false; + this._updateVisible(); + } + if (this._blendModeDirty) { + this._blendModeDirty = false; + this._updateBlendMode(); + } + if (this._colorDirty) { + this._colorDirty = false; + this._updateColor(); + } + if (null !== this._deformVertices && null !== this._deformVertices.verticesData && this._display === this._meshDisplay) { + var isSkinned = null !== this._deformVertices.verticesData.weight; + var isSurface = 0 !== this._parent._boneData.type; + if (this._deformVertices.verticesDirty || isSkinned && this._deformVertices.isBonesUpdate() || isSurface && this._parent._childrenTransformDirty) { + this._deformVertices.verticesDirty = false; + this._updateMesh(); + } + if (isSkinned || isSurface) return; + } + if (this._transformDirty) { + this._transformDirty = false; + if (this._cachedFrameIndex < 0) { + var isCache = cacheFrameIndex >= 0; + this._updateGlobalTransformMatrix(isCache); + isCache && null !== this._cachedFrameIndices && (this._cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex] = this._armature._armatureData.setCacheFrame(this.globalTransformMatrix, this.global)); + } else { + this._isFromCache = true; + this._armature._armatureData.getCacheFrame(this.globalTransformMatrix, this.global, this._cachedFrameIndex); + } + this._updateTransform(); + } + }; + Slot.prototype.updateTransformAndMatrix = function() { + if (this._transformDirty) { + this._transformDirty = false; + this._updateGlobalTransformMatrix(false); + } + }; + Slot.prototype.replaceDisplayData = function(value, displayIndex) { + void 0 === displayIndex && (displayIndex = -1); + displayIndex < 0 && (displayIndex = this._displayIndex < 0 ? 0 : this._displayIndex); + if (this._displayDatas.length <= displayIndex) { + this._displayDatas.length = displayIndex + 1; + for (var i = 0, l = this._displayDatas.length; i < l; ++i) this._displayDatas[i] || (this._displayDatas[i] = null); + } + this._displayDatas[displayIndex] = value; + }; + Slot.prototype.containsPoint = function(x, y) { + if (null === this._boundingBoxData) return false; + this.updateTransformAndMatrix(); + Slot._helpMatrix.copyFrom(this.globalTransformMatrix); + Slot._helpMatrix.invert(); + Slot._helpMatrix.transformPoint(x, y, Slot._helpPoint); + return this._boundingBoxData.containsPoint(Slot._helpPoint.x, Slot._helpPoint.y); + }; + Slot.prototype.intersectsSegment = function(xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians) { + void 0 === intersectionPointA && (intersectionPointA = null); + void 0 === intersectionPointB && (intersectionPointB = null); + void 0 === normalRadians && (normalRadians = null); + if (null === this._boundingBoxData) return 0; + this.updateTransformAndMatrix(); + Slot._helpMatrix.copyFrom(this.globalTransformMatrix); + Slot._helpMatrix.invert(); + Slot._helpMatrix.transformPoint(xA, yA, Slot._helpPoint); + xA = Slot._helpPoint.x; + yA = Slot._helpPoint.y; + Slot._helpMatrix.transformPoint(xB, yB, Slot._helpPoint); + xB = Slot._helpPoint.x; + yB = Slot._helpPoint.y; + var intersectionCount = this._boundingBoxData.intersectsSegment(xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians); + if (intersectionCount > 0) { + if (1 === intersectionCount || 2 === intersectionCount) if (null !== intersectionPointA) { + this.globalTransformMatrix.transformPoint(intersectionPointA.x, intersectionPointA.y, intersectionPointA); + if (null !== intersectionPointB) { + intersectionPointB.x = intersectionPointA.x; + intersectionPointB.y = intersectionPointA.y; + } + } else null !== intersectionPointB && this.globalTransformMatrix.transformPoint(intersectionPointB.x, intersectionPointB.y, intersectionPointB); else { + null !== intersectionPointA && this.globalTransformMatrix.transformPoint(intersectionPointA.x, intersectionPointA.y, intersectionPointA); + null !== intersectionPointB && this.globalTransformMatrix.transformPoint(intersectionPointB.x, intersectionPointB.y, intersectionPointB); + } + if (null !== normalRadians) { + this.globalTransformMatrix.transformPoint(Math.cos(normalRadians.x), Math.sin(normalRadians.x), Slot._helpPoint, true); + normalRadians.x = Math.atan2(Slot._helpPoint.y, Slot._helpPoint.x); + this.globalTransformMatrix.transformPoint(Math.cos(normalRadians.y), Math.sin(normalRadians.y), Slot._helpPoint, true); + normalRadians.y = Math.atan2(Slot._helpPoint.y, Slot._helpPoint.x); + } + } + return intersectionCount; + }; + Slot.prototype.invalidUpdate = function() { + this._displayDirty = true; + this._transformDirty = true; + }; + Object.defineProperty(Slot.prototype, "visible", { + get: function get() { + return this._visible; + }, + set: function set(value) { + if (this._visible === value) return; + this._visible = value; + this._updateVisible(); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Slot.prototype, "displayIndex", { + get: function get() { + return this._displayIndex; + }, + set: function set(value) { + this._setDisplayIndex(value) && this.update(-1); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Slot.prototype, "name", { + get: function get() { + return this._slotData.name; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Slot.prototype, "displayList", { + get: function get() { + return this._displayList.concat(); + }, + set: function set(value) { + var backupDisplayList = this._displayList.concat(); + var disposeDisplayList = new Array(); + this._setDisplayList(value) && this.update(-1); + for (var _i = 0, backupDisplayList_1 = backupDisplayList; _i < backupDisplayList_1.length; _i++) { + var eachDisplay = backupDisplayList_1[_i]; + null !== eachDisplay && eachDisplay !== this._rawDisplay && eachDisplay !== this._meshDisplay && this._displayList.indexOf(eachDisplay) < 0 && disposeDisplayList.indexOf(eachDisplay) < 0 && disposeDisplayList.push(eachDisplay); + } + for (var _a = 0, disposeDisplayList_2 = disposeDisplayList; _a < disposeDisplayList_2.length; _a++) { + var eachDisplay = disposeDisplayList_2[_a]; + eachDisplay instanceof dragonBones.Armature || this._disposeDisplay(eachDisplay, true); + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Slot.prototype, "slotData", { + get: function get() { + return this._slotData; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Slot.prototype, "rawDisplayDatas", { + get: function get() { + return this._rawDisplayDatas; + }, + set: function set(value) { + if (this._rawDisplayDatas === value) return; + this._displayDirty = true; + this._rawDisplayDatas = value; + if (null !== this._rawDisplayDatas) { + this._displayDatas.length = this._rawDisplayDatas.length; + for (var i = 0, l = this._displayDatas.length; i < l; ++i) { + var rawDisplayData = this._rawDisplayDatas[i]; + null === rawDisplayData && (rawDisplayData = this._getDefaultRawDisplayData(i)); + this._displayDatas[i] = rawDisplayData; + } + } else this._displayDatas.length = 0; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Slot.prototype, "displayData", { + get: function get() { + return this._displayData; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Slot.prototype, "boundingBoxData", { + get: function get() { + return this._boundingBoxData; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Slot.prototype, "rawDisplay", { + get: function get() { + return this._rawDisplay; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Slot.prototype, "meshDisplay", { + get: function get() { + return this._meshDisplay; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Slot.prototype, "display", { + get: function get() { + return this._display; + }, + set: function set(value) { + if (this._display === value) return; + var displayListLength = this._displayList.length; + this._displayIndex < 0 && 0 === displayListLength && (this._displayIndex = 0); + if (this._displayIndex < 0) return; + var replaceDisplayList = this.displayList; + displayListLength <= this._displayIndex && (replaceDisplayList.length = this._displayIndex + 1); + replaceDisplayList[this._displayIndex] = value; + this.displayList = replaceDisplayList; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Slot.prototype, "childArmature", { + get: function get() { + return this._childArmature; + }, + set: function set(value) { + if (this._childArmature === value) return; + this.display = value; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Slot.prototype, "parent", { + get: function get() { + return this._parent; + }, + enumerable: true, + configurable: true + }); + Slot.prototype.getDisplay = function() { + return this._display; + }; + Slot.prototype.setDisplay = function(value) { + this.display = value; + }; + return Slot; + })(dragonBones.TransformObject); + dragonBones.Slot = Slot; + })(dragonBones || (dragonBones = {})); + var dragonBones; + (function(dragonBones) { + var Constraint = (function(_super) { + __extends(Constraint, _super); + function Constraint() { + return null !== _super && _super.apply(this, arguments) || this; + } + Constraint.prototype._onClear = function() { + this._armature = null; + this._target = null; + this._root = null; + this._bone = null; + }; + Object.defineProperty(Constraint.prototype, "name", { + get: function get() { + return this._constraintData.name; + }, + enumerable: true, + configurable: true + }); + Constraint._helpMatrix = new dragonBones.Matrix(); + Constraint._helpTransform = new dragonBones.Transform(); + Constraint._helpPoint = new dragonBones.Point(); + return Constraint; + })(dragonBones.BaseObject); + dragonBones.Constraint = Constraint; + var IKConstraint = (function(_super) { + __extends(IKConstraint, _super); + function IKConstraint() { + return null !== _super && _super.apply(this, arguments) || this; + } + IKConstraint.toString = function() { + return "[class dragonBones.IKConstraint]"; + }; + IKConstraint.prototype._onClear = function() { + _super.prototype._onClear.call(this); + this._scaleEnabled = false; + this._bendPositive = false; + this._weight = 1; + this._constraintData = null; + }; + IKConstraint.prototype._computeA = function() { + var ikGlobal = this._target.global; + var global = this._root.global; + var globalTransformMatrix = this._root.globalTransformMatrix; + var radian = Math.atan2(ikGlobal.y - global.y, ikGlobal.x - global.x); + global.scaleX < 0 && (radian += Math.PI); + global.rotation += dragonBones.Transform.normalizeRadian(radian - global.rotation) * this._weight; + global.toMatrix(globalTransformMatrix); + }; + IKConstraint.prototype._computeB = function() { + var boneLength = this._bone._boneData.length; + var parent = this._root; + var ikGlobal = this._target.global; + var parentGlobal = parent.global; + var global = this._bone.global; + var globalTransformMatrix = this._bone.globalTransformMatrix; + var x = globalTransformMatrix.a * boneLength; + var y = globalTransformMatrix.b * boneLength; + var lLL = x * x + y * y; + var lL = Math.sqrt(lLL); + var dX = global.x - parentGlobal.x; + var dY = global.y - parentGlobal.y; + var lPP = dX * dX + dY * dY; + var lP = Math.sqrt(lPP); + var rawRadian = global.rotation; + var rawParentRadian = parentGlobal.rotation; + var rawRadianA = Math.atan2(dY, dX); + dX = ikGlobal.x - parentGlobal.x; + dY = ikGlobal.y - parentGlobal.y; + var lTT = dX * dX + dY * dY; + var lT = Math.sqrt(lTT); + var radianA = 0; + if (lL + lP <= lT || lT + lL <= lP || lT + lP <= lL) { + radianA = Math.atan2(ikGlobal.y - parentGlobal.y, ikGlobal.x - parentGlobal.x); + lL + lP <= lT || lP < lL && (radianA += Math.PI); + } else { + var h = (lPP - lLL + lTT) / (2 * lTT); + var r = Math.sqrt(lPP - h * h * lTT) / lT; + var hX = parentGlobal.x + dX * h; + var hY = parentGlobal.y + dY * h; + var rX = -dY * r; + var rY = dX * r; + var isPPR = false; + var parentParent = parent.parent; + if (null !== parentParent) { + var parentParentMatrix = parentParent.globalTransformMatrix; + isPPR = parentParentMatrix.a * parentParentMatrix.d - parentParentMatrix.b * parentParentMatrix.c < 0; + } + if (isPPR !== this._bendPositive) { + global.x = hX - rX; + global.y = hY - rY; + } else { + global.x = hX + rX; + global.y = hY + rY; + } + radianA = Math.atan2(global.y - parentGlobal.y, global.x - parentGlobal.x); + } + var dR = dragonBones.Transform.normalizeRadian(radianA - rawRadianA); + parentGlobal.rotation = rawParentRadian + dR * this._weight; + parentGlobal.toMatrix(parent.globalTransformMatrix); + var currentRadianA = rawRadianA + dR * this._weight; + global.x = parentGlobal.x + Math.cos(currentRadianA) * lP; + global.y = parentGlobal.y + Math.sin(currentRadianA) * lP; + var radianB = Math.atan2(ikGlobal.y - global.y, ikGlobal.x - global.x); + global.scaleX < 0 && (radianB += Math.PI); + global.rotation = parentGlobal.rotation + rawRadian - rawParentRadian + dragonBones.Transform.normalizeRadian(radianB - dR - rawRadian) * this._weight; + global.toMatrix(globalTransformMatrix); + }; + IKConstraint.prototype.init = function(constraintData, armature) { + if (null !== this._constraintData) return; + this._constraintData = constraintData; + this._armature = armature; + this._target = this._armature.getBone(this._constraintData.target.name); + this._root = this._armature.getBone(this._constraintData.root.name); + this._bone = null !== this._constraintData.bone ? this._armature.getBone(this._constraintData.bone.name) : null; + var ikConstraintData = this._constraintData; + this._scaleEnabled = ikConstraintData.scaleEnabled; + this._bendPositive = ikConstraintData.bendPositive; + this._weight = ikConstraintData.weight; + this._root._hasConstraint = true; + }; + IKConstraint.prototype.update = function() { + this._root.updateByConstraint(); + if (null !== this._bone) { + this._bone.updateByConstraint(); + this._computeB(); + } else this._computeA(); + }; + IKConstraint.prototype.invalidUpdate = function() { + this._root.invalidUpdate(); + null !== this._bone && this._bone.invalidUpdate(); + }; + return IKConstraint; + })(Constraint); + dragonBones.IKConstraint = IKConstraint; + var PathConstraint = (function(_super) { + __extends(PathConstraint, _super); + function PathConstraint() { + var _this = null !== _super && _super.apply(this, arguments) || this; + _this._bones = []; + _this._spaces = []; + _this._positions = []; + _this._curves = []; + _this._boneLengths = []; + _this._pathGlobalVertices = []; + _this._segments = [ 10 ]; + return _this; + } + PathConstraint.toString = function() { + return "[class dragonBones.PathConstraint]"; + }; + PathConstraint.prototype._onClear = function() { + _super.prototype._onClear.call(this); + this.dirty = false; + this.pathOffset = 0; + this.position = 0; + this.spacing = 0; + this.rotateOffset = 0; + this.rotateMix = 1; + this.translateMix = 1; + this._pathSlot = null; + this._bones.length = 0; + this._spaces.length = 0; + this._positions.length = 0; + this._curves.length = 0; + this._boneLengths.length = 0; + this._pathGlobalVertices.length = 0; + }; + PathConstraint.prototype._updatePathVertices = function(verticesData) { + var armature = this._armature; + var dragonBonesData = armature.armatureData.parent; + var scale = armature.armatureData.scale; + var intArray = dragonBonesData.intArray; + var floatArray = dragonBonesData.floatArray; + var pathOffset = verticesData.offset; + var pathVertexCount = intArray[pathOffset + 0]; + var pathVertexOffset = intArray[pathOffset + 2]; + this._pathGlobalVertices.length = 2 * pathVertexCount; + var weightData = verticesData.weight; + if (null === weightData) { + var parentBone = this._pathSlot.parent; + parentBone.updateByConstraint(); + var matrix = parentBone.globalTransformMatrix; + for (var i = 0, iV_1 = pathVertexOffset; i < pathVertexCount; i += 2) { + var vx = floatArray[iV_1++] * scale; + var vy = floatArray[iV_1++] * scale; + var x = matrix.a * vx + matrix.c * vy + matrix.tx; + var y = matrix.b * vx + matrix.d * vy + matrix.ty; + this._pathGlobalVertices[i] = x; + this._pathGlobalVertices[i + 1] = y; + } + return; + } + var bones = this._pathSlot._deformVertices.bones; + var weightBoneCount = weightData.bones.length; + var weightOffset = weightData.offset; + var floatOffset = intArray[weightOffset + 1]; + var iV = floatOffset; + var iB = weightOffset + 2 + weightBoneCount; + for (var i = 0, iW = 0; i < pathVertexCount; i++) { + var vertexBoneCount = intArray[iB++]; + var xG = 0, yG = 0; + for (var ii = 0, ll = vertexBoneCount; ii < ll; ii++) { + var boneIndex = intArray[iB++]; + var bone = bones[boneIndex]; + if (null === bone) continue; + bone.updateByConstraint(); + var matrix = bone.globalTransformMatrix; + var weight = floatArray[iV++]; + var vx = floatArray[iV++] * scale; + var vy = floatArray[iV++] * scale; + xG += (matrix.a * vx + matrix.c * vy + matrix.tx) * weight; + yG += (matrix.b * vx + matrix.d * vy + matrix.ty) * weight; + } + this._pathGlobalVertices[iW++] = xG; + this._pathGlobalVertices[iW++] = yG; + } + }; + PathConstraint.prototype._computeVertices = function(start, count, offset, out) { + for (var i = offset, iW = start; i < count; i += 2) { + out[i] = this._pathGlobalVertices[iW++]; + out[i + 1] = this._pathGlobalVertices[iW++]; + } + }; + PathConstraint.prototype._computeBezierCurve = function(pathDisplayDta, spaceCount, tangents, percentPosition, percentSpacing) { + var armature = this._armature; + var intArray = armature.armatureData.parent.intArray; + var vertexCount = intArray[pathDisplayDta.vertices.offset + 0]; + var positions = this._positions; + var spaces = this._spaces; + var isClosed = pathDisplayDta.closed; + var curveVertices = Array(); + var verticesLength = 2 * vertexCount; + var curveCount = verticesLength / 6; + var preCurve = -1; + var position = this.position; + positions.length = 3 * spaceCount + 2; + var pathLength = 0; + if (!pathDisplayDta.constantSpeed) { + var lenghts = pathDisplayDta.curveLengths; + curveCount -= isClosed ? 1 : 2; + pathLength = lenghts[curveCount]; + percentPosition && (position *= pathLength); + if (percentSpacing) for (var i = 0; i < spaceCount; i++) spaces[i] *= pathLength; + curveVertices.length = 8; + for (var i = 0, o = 0, curve = 0; i < spaceCount; i++, o += 3) { + var space = spaces[i]; + position += space; + if (isClosed) { + position %= pathLength; + position < 0 && (position += pathLength); + curve = 0; + } else { + if (position < 0) continue; + if (position > pathLength) continue; + } + var percent = 0; + for (;;curve++) { + var len = lenghts[curve]; + if (position > len) continue; + if (0 === curve) percent = position / len; else { + var preLen = lenghts[curve - 1]; + percent = (position - preLen) / (len - preLen); + } + break; + } + if (curve !== preCurve) { + preCurve = curve; + if (isClosed && curve === curveCount) { + this._computeVertices(verticesLength - 4, 4, 0, curveVertices); + this._computeVertices(0, 4, 4, curveVertices); + } else this._computeVertices(6 * curve + 2, 8, 0, curveVertices); + } + this.addCurvePosition(percent, curveVertices[0], curveVertices[1], curveVertices[2], curveVertices[3], curveVertices[4], curveVertices[5], curveVertices[6], curveVertices[7], positions, o, tangents); + } + return; + } + if (isClosed) { + verticesLength += 2; + curveVertices.length = vertexCount; + this._computeVertices(2, verticesLength - 4, 0, curveVertices); + this._computeVertices(0, 2, verticesLength - 4, curveVertices); + curveVertices[verticesLength - 2] = curveVertices[0]; + curveVertices[verticesLength - 1] = curveVertices[1]; + } else { + curveCount--; + verticesLength -= 4; + curveVertices.length = verticesLength; + this._computeVertices(2, verticesLength, 0, curveVertices); + } + var curves = new Array(curveCount); + pathLength = 0; + var x1 = curveVertices[0], y1 = curveVertices[1], cx1 = 0, cy1 = 0, cx2 = 0, cy2 = 0, x2 = 0, y2 = 0; + var tmpx, tmpy, dddfx, dddfy, ddfx, ddfy, dfx, dfy; + for (var i = 0, w = 2; i < curveCount; i++, w += 6) { + cx1 = curveVertices[w]; + cy1 = curveVertices[w + 1]; + cx2 = curveVertices[w + 2]; + cy2 = curveVertices[w + 3]; + x2 = curveVertices[w + 4]; + y2 = curveVertices[w + 5]; + tmpx = .1875 * (x1 - 2 * cx1 + cx2); + tmpy = .1875 * (y1 - 2 * cy1 + cy2); + dddfx = .09375 * (3 * (cx1 - cx2) - x1 + x2); + dddfy = .09375 * (3 * (cy1 - cy2) - y1 + y2); + ddfx = 2 * tmpx + dddfx; + ddfy = 2 * tmpy + dddfy; + dfx = .75 * (cx1 - x1) + tmpx + .16666667 * dddfx; + dfy = .75 * (cy1 - y1) + tmpy + .16666667 * dddfy; + pathLength += Math.sqrt(dfx * dfx + dfy * dfy); + dfx += ddfx; + dfy += ddfy; + ddfx += dddfx; + ddfy += dddfy; + pathLength += Math.sqrt(dfx * dfx + dfy * dfy); + dfx += ddfx; + dfy += ddfy; + pathLength += Math.sqrt(dfx * dfx + dfy * dfy); + dfx += ddfx + dddfx; + dfy += ddfy + dddfy; + pathLength += Math.sqrt(dfx * dfx + dfy * dfy); + curves[i] = pathLength; + x1 = x2; + y1 = y2; + } + percentPosition && (position *= pathLength); + if (percentSpacing) for (var i = 0; i < spaceCount; i++) spaces[i] *= pathLength; + var segments = this._segments; + var curveLength = 0; + for (var i = 0, o = 0, curve = 0, segment = 0; i < spaceCount; i++, o += 3) { + var space = spaces[i]; + position += space; + var p = position; + if (isClosed) { + p %= pathLength; + p < 0 && (p += pathLength); + curve = 0; + } else { + if (p < 0) continue; + if (p > pathLength) continue; + } + for (;;curve++) { + var length_1 = curves[curve]; + if (p > length_1) continue; + if (0 === curve) p /= length_1; else { + var prev = curves[curve - 1]; + p = (p - prev) / (length_1 - prev); + } + break; + } + if (curve !== preCurve) { + preCurve = curve; + var ii = 6 * curve; + x1 = curveVertices[ii]; + y1 = curveVertices[ii + 1]; + cx1 = curveVertices[ii + 2]; + cy1 = curveVertices[ii + 3]; + cx2 = curveVertices[ii + 4]; + cy2 = curveVertices[ii + 5]; + x2 = curveVertices[ii + 6]; + y2 = curveVertices[ii + 7]; + tmpx = .03 * (x1 - 2 * cx1 + cx2); + tmpy = .03 * (y1 - 2 * cy1 + cy2); + dddfx = .006 * (3 * (cx1 - cx2) - x1 + x2); + dddfy = .006 * (3 * (cy1 - cy2) - y1 + y2); + ddfx = 2 * tmpx + dddfx; + ddfy = 2 * tmpy + dddfy; + dfx = .3 * (cx1 - x1) + tmpx + .16666667 * dddfx; + dfy = .3 * (cy1 - y1) + tmpy + .16666667 * dddfy; + curveLength = Math.sqrt(dfx * dfx + dfy * dfy); + segments[0] = curveLength; + for (ii = 1; ii < 8; ii++) { + dfx += ddfx; + dfy += ddfy; + ddfx += dddfx; + ddfy += dddfy; + curveLength += Math.sqrt(dfx * dfx + dfy * dfy); + segments[ii] = curveLength; + } + dfx += ddfx; + dfy += ddfy; + curveLength += Math.sqrt(dfx * dfx + dfy * dfy); + segments[8] = curveLength; + dfx += ddfx + dddfx; + dfy += ddfy + dddfy; + curveLength += Math.sqrt(dfx * dfx + dfy * dfy); + segments[9] = curveLength; + segment = 0; + } + p *= curveLength; + for (;;segment++) { + var length_2 = segments[segment]; + if (p > length_2) continue; + if (0 === segment) p /= length_2; else { + var prev = segments[segment - 1]; + p = segment + (p - prev) / (length_2 - prev); + } + break; + } + this.addCurvePosition(.1 * p, x1, y1, cx1, cy1, cx2, cy2, x2, y2, positions, o, tangents); + } + }; + PathConstraint.prototype.addCurvePosition = function(t, x1, y1, cx1, cy1, cx2, cy2, x2, y2, out, offset, tangents) { + if (0 === t) { + out[offset] = x1; + out[offset + 1] = y1; + out[offset + 2] = 0; + return; + } + if (1 === t) { + out[offset] = x2; + out[offset + 1] = y2; + out[offset + 2] = 0; + return; + } + var mt = 1 - t; + var mt2 = mt * mt; + var t2 = t * t; + var a = mt2 * mt; + var b = mt2 * t * 3; + var c = mt * t2 * 3; + var d = t * t2; + var x = a * x1 + b * cx1 + c * cx2 + d * x2; + var y = a * y1 + b * cy1 + c * cy2 + d * y2; + out[offset] = x; + out[offset + 1] = y; + out[offset + 2] = tangents ? Math.atan2(y - (a * y1 + b * cy1 + c * cy2), x - (a * x1 + b * cx1 + c * cx2)) : 0; + }; + PathConstraint.prototype.init = function(constraintData, armature) { + this._constraintData = constraintData; + this._armature = armature; + var data = constraintData; + this.pathOffset = data.pathDisplayData.vertices.offset; + this.position = data.position; + this.spacing = data.spacing; + this.rotateOffset = data.rotateOffset; + this.rotateMix = data.rotateMix; + this.translateMix = data.translateMix; + this._root = this._armature.getBone(data.root.name); + this._target = this._armature.getBone(data.target.name); + this._pathSlot = this._armature.getSlot(data.pathSlot.name); + for (var i = 0, l = data.bones.length; i < l; i++) { + var bone = this._armature.getBone(data.bones[i].name); + null !== bone && this._bones.push(bone); + } + 2 === data.rotateMode && (this._boneLengths.length = this._bones.length); + this._root._hasConstraint = true; + }; + PathConstraint.prototype.update = function() { + var pathSlot = this._pathSlot; + if (null === pathSlot._deformVertices || null === pathSlot._deformVertices.verticesData || pathSlot._deformVertices.verticesData.offset !== this.pathOffset) return; + var constraintData = this._constraintData; + var pathDisplayData = pathSlot._displayData; + var isPathVerticeDirty = false; + var deformVertices = pathSlot._deformVertices; + if (this._root._childrenTransformDirty) { + this._updatePathVertices(pathDisplayData.vertices); + isPathVerticeDirty = true; + } else if (null !== deformVertices && (deformVertices.verticesDirty || deformVertices.isBonesUpdate())) { + this._updatePathVertices(pathDisplayData.vertices); + deformVertices.verticesDirty = false; + isPathVerticeDirty = true; + } + if (!isPathVerticeDirty && !this.dirty) return; + var positionMode = constraintData.positionMode; + var spacingMode = constraintData.spacingMode; + var rotateMode = constraintData.rotateMode; + var bones = this._bones; + var isLengthMode = 0 === spacingMode; + var isChainScaleMode = 2 === rotateMode; + var isTangentMode = 0 === rotateMode; + var boneCount = bones.length; + var spacesCount = isTangentMode ? boneCount : boneCount + 1; + var spacing = this.spacing; + var spaces = this._spaces; + spaces.length = spacesCount; + if (isChainScaleMode || isLengthMode) { + spaces[0] = 0; + for (var i = 0, l = spacesCount - 1; i < l; i++) { + var bone = bones[i]; + bone.updateByConstraint(); + var boneLength = bone._boneData.length; + var matrix = bone.globalTransformMatrix; + var x = boneLength * matrix.a; + var y = boneLength * matrix.b; + var len = Math.sqrt(x * x + y * y); + isChainScaleMode && (this._boneLengths[i] = len); + spaces[i + 1] = (boneLength + spacing) * len / boneLength; + } + } else for (var i = 0; i < spacesCount; i++) spaces[i] = spacing; + this._computeBezierCurve(pathDisplayData, spacesCount, isTangentMode, 1 === positionMode, 2 === spacingMode); + var positions = this._positions; + var rotateOffset = this.rotateOffset; + var boneX = positions[0], boneY = positions[1]; + var tip; + if (0 === rotateOffset) tip = 1 === rotateMode; else { + tip = false; + var bone = pathSlot.parent; + if (null !== bone) { + var matrix = bone.globalTransformMatrix; + rotateOffset *= matrix.a * matrix.d - matrix.b * matrix.c > 0 ? dragonBones.Transform.DEG_RAD : -dragonBones.Transform.DEG_RAD; + } + } + var rotateMix = this.rotateMix; + var translateMix = this.translateMix; + for (var i = 0, p = 3; i < boneCount; i++, p += 3) { + var bone = bones[i]; + bone.updateByConstraint(); + var matrix = bone.globalTransformMatrix; + matrix.tx += (boneX - matrix.tx) * translateMix; + matrix.ty += (boneY - matrix.ty) * translateMix; + var x = positions[p], y = positions[p + 1]; + var dx = x - boneX, dy = y - boneY; + if (isChainScaleMode) { + var lenght = this._boneLengths[i]; + var s = (Math.sqrt(dx * dx + dy * dy) / lenght - 1) * rotateMix + 1; + matrix.a *= s; + matrix.b *= s; + } + boneX = x; + boneY = y; + if (rotateMix > 0) { + var a = matrix.a, b = matrix.b, c = matrix.c, d = matrix.d, r = void 0, cos = void 0, sin = void 0; + r = isTangentMode ? positions[p - 1] : Math.atan2(dy, dx); + r -= Math.atan2(b, a); + if (tip) { + cos = Math.cos(r); + sin = Math.sin(r); + var length_3 = bone._boneData.length; + boneX += (length_3 * (cos * a - sin * b) - dx) * rotateMix; + boneY += (length_3 * (sin * a + cos * b) - dy) * rotateMix; + } else r += rotateOffset; + r > dragonBones.Transform.PI ? r -= dragonBones.Transform.PI_D : r < -dragonBones.Transform.PI && (r += dragonBones.Transform.PI_D); + r *= rotateMix; + cos = Math.cos(r); + sin = Math.sin(r); + matrix.a = cos * a - sin * b; + matrix.b = sin * a + cos * b; + matrix.c = cos * c - sin * d; + matrix.d = sin * c + cos * d; + } + bone.global.fromMatrix(matrix); + } + this.dirty = false; + }; + PathConstraint.prototype.invalidUpdate = function() {}; + return PathConstraint; + })(Constraint); + dragonBones.PathConstraint = PathConstraint; + })(dragonBones || (dragonBones = {})); + var dragonBones; + (function(dragonBones) { + var WorldClock = (function() { + function WorldClock(time) { + void 0 === time && (time = 0); + this.time = 0; + this.timeScale = 1; + this._systemTime = 0; + this._animatebles = []; + this._clock = null; + this.time = time; + this._systemTime = .001 * new Date().getTime(); + } + WorldClock.prototype.advanceTime = function(passedTime) { + passedTime !== passedTime && (passedTime = 0); + var currentTime = .001 * Date.now(); + passedTime < 0 && (passedTime = currentTime - this._systemTime); + this._systemTime = currentTime; + 1 !== this.timeScale && (passedTime *= this.timeScale); + if (0 === passedTime) return; + passedTime < 0 ? this.time -= passedTime : this.time += passedTime; + var i = 0, r = 0, l = this._animatebles.length; + for (;i < l; ++i) { + var animatable = this._animatebles[i]; + if (null !== animatable) { + if (r > 0) { + this._animatebles[i - r] = animatable; + this._animatebles[i] = null; + } + animatable.advanceTime(passedTime); + } else r++; + } + if (r > 0) { + l = this._animatebles.length; + for (;i < l; ++i) { + var animateble = this._animatebles[i]; + null !== animateble ? this._animatebles[i - r] = animateble : r++; + } + this._animatebles.length -= r; + } + }; + WorldClock.prototype.contains = function(value) { + if (value === this) return false; + var ancestor = value; + while (ancestor !== this && null !== ancestor) ancestor = ancestor.clock; + return ancestor === this; + }; + WorldClock.prototype.add = function(value) { + if (this._animatebles.indexOf(value) < 0) { + this._animatebles.push(value); + value.clock = this; + } + }; + WorldClock.prototype.remove = function(value) { + var index = this._animatebles.indexOf(value); + if (index >= 0) { + this._animatebles[index] = null; + value.clock = null; + } + }; + WorldClock.prototype.clear = function() { + for (var _i = 0, _a = this._animatebles; _i < _a.length; _i++) { + var animatable = _a[_i]; + null !== animatable && (animatable.clock = null); + } + }; + Object.defineProperty(WorldClock.prototype, "clock", { + get: function get() { + return this._clock; + }, + set: function set(value) { + if (this._clock === value) return; + null !== this._clock && this._clock.remove(this); + this._clock = value; + null !== this._clock && this._clock.add(this); + }, + enumerable: true, + configurable: true + }); + WorldClock.clock = new WorldClock(); + return WorldClock; + })(); + dragonBones.WorldClock = WorldClock; + })(dragonBones || (dragonBones = {})); + var dragonBones; + (function(dragonBones) { + var Animation = (function(_super) { + __extends(Animation, _super); + function Animation() { + var _this = null !== _super && _super.apply(this, arguments) || this; + _this._animationNames = []; + _this._animationStates = []; + _this._animations = {}; + _this._animationConfig = null; + return _this; + } + Animation.toString = function() { + return "[class dragonBones.Animation]"; + }; + Animation.prototype._onClear = function() { + for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { + var animationState = _a[_i]; + animationState.returnToPool(); + } + for (var k in this._animations) delete this._animations[k]; + null !== this._animationConfig && this._animationConfig.returnToPool(); + this.timeScale = 1; + this._lockUpdate = false; + this._animationDirty = false; + this._inheritTimeScale = 1; + this._animationNames.length = 0; + this._animationStates.length = 0; + this._armature = null; + this._animationConfig = null; + this._lastAnimationState = null; + }; + Animation.prototype._fadeOut = function(animationConfig) { + switch (animationConfig.fadeOutMode) { + case 1: + for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { + var animationState = _a[_i]; + if (null !== animationState._parent) continue; + animationState.layer === animationConfig.layer && animationState.fadeOut(animationConfig.fadeOutTime, animationConfig.pauseFadeOut); + } + break; + + case 2: + for (var _b = 0, _c = this._animationStates; _b < _c.length; _b++) { + var animationState = _c[_b]; + if (null !== animationState._parent) continue; + animationState.group === animationConfig.group && animationState.fadeOut(animationConfig.fadeOutTime, animationConfig.pauseFadeOut); + } + break; + + case 3: + for (var _d = 0, _e = this._animationStates; _d < _e.length; _d++) { + var animationState = _e[_d]; + if (null !== animationState._parent) continue; + animationState.layer === animationConfig.layer && animationState.group === animationConfig.group && animationState.fadeOut(animationConfig.fadeOutTime, animationConfig.pauseFadeOut); + } + break; + + case 4: + for (var _f = 0, _g = this._animationStates; _f < _g.length; _f++) { + var animationState = _g[_f]; + if (null !== animationState._parent) continue; + animationState.fadeOut(animationConfig.fadeOutTime, animationConfig.pauseFadeOut); + } + } + }; + Animation.prototype.init = function(armature) { + if (null !== this._armature) return; + this._armature = armature; + this._animationConfig = dragonBones.BaseObject.borrowObject(dragonBones.AnimationConfig); + }; + Animation.prototype.advanceTime = function(passedTime) { + passedTime < 0 && (passedTime = -passedTime); + this._armature.inheritAnimation && null !== this._armature._parent ? this._inheritTimeScale = this._armature._parent._armature.animation._inheritTimeScale * this.timeScale : this._inheritTimeScale = this.timeScale; + 1 !== this._inheritTimeScale && (passedTime *= this._inheritTimeScale); + var animationStateCount = this._animationStates.length; + if (1 === animationStateCount) { + var animationState = this._animationStates[0]; + if (animationState._fadeState > 0 && animationState._subFadeState > 0) { + this._armature._dragonBones.bufferObject(animationState); + this._animationStates.length = 0; + this._lastAnimationState = null; + } else { + var animationData = animationState._animationData; + var cacheFrameRate = animationData.cacheFrameRate; + if (this._animationDirty && cacheFrameRate > 0) { + this._animationDirty = false; + for (var _i = 0, _a = this._armature.getBones(); _i < _a.length; _i++) { + var bone = _a[_i]; + bone._cachedFrameIndices = animationData.getBoneCachedFrameIndices(bone.name); + } + for (var _b = 0, _c = this._armature.getSlots(); _b < _c.length; _b++) { + var slot = _c[_b]; + var rawDisplayDatas = slot.rawDisplayDatas; + if (null !== rawDisplayDatas && rawDisplayDatas.length > 0) { + var rawDsplayData = rawDisplayDatas[0]; + if (null !== rawDsplayData && rawDsplayData.parent === this._armature.armatureData.defaultSkin) { + slot._cachedFrameIndices = animationData.getSlotCachedFrameIndices(slot.name); + continue; + } + } + slot._cachedFrameIndices = null; + } + } + animationState.advanceTime(passedTime, cacheFrameRate); + } + } else if (animationStateCount > 1) { + for (var i = 0, r = 0; i < animationStateCount; ++i) { + var animationState = this._animationStates[i]; + if (animationState._fadeState > 0 && animationState._subFadeState > 0) { + r++; + this._armature._dragonBones.bufferObject(animationState); + this._animationDirty = true; + this._lastAnimationState === animationState && (this._lastAnimationState = null); + } else { + r > 0 && (this._animationStates[i - r] = animationState); + animationState.advanceTime(passedTime, 0); + } + if (i === animationStateCount - 1 && r > 0) { + this._animationStates.length -= r; + null === this._lastAnimationState && this._animationStates.length > 0 && (this._lastAnimationState = this._animationStates[this._animationStates.length - 1]); + } + } + this._armature._cacheFrameIndex = -1; + } else this._armature._cacheFrameIndex = -1; + }; + Animation.prototype.reset = function() { + for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { + var animationState = _a[_i]; + animationState.returnToPool(); + } + this._animationDirty = false; + this._animationConfig.clear(); + this._animationStates.length = 0; + this._lastAnimationState = null; + }; + Animation.prototype.stop = function(animationName) { + void 0 === animationName && (animationName = null); + if (null !== animationName) { + var animationState = this.getState(animationName); + null !== animationState && animationState.stop(); + } else for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { + var animationState = _a[_i]; + animationState.stop(); + } + }; + Animation.prototype.playConfig = function(animationConfig) { + var animationName = animationConfig.animation; + if (!(animationName in this._animations)) { + console.warn("Non-existent animation.\n", "DragonBones name: " + this._armature.armatureData.parent.name, "Armature name: " + this._armature.name, "Animation name: " + animationName); + return null; + } + var animationData = this._animations[animationName]; + if (5 === animationConfig.fadeOutMode) for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { + var animationState_1 = _a[_i]; + if (animationState_1._animationData === animationData) return animationState_1; + } + 0 === this._animationStates.length ? animationConfig.fadeInTime = 0 : animationConfig.fadeInTime < 0 && (animationConfig.fadeInTime = animationData.fadeInTime); + animationConfig.fadeOutTime < 0 && (animationConfig.fadeOutTime = animationConfig.fadeInTime); + animationConfig.timeScale <= -100 && (animationConfig.timeScale = 1 / animationData.scale); + if (animationData.frameCount > 1) { + if (animationConfig.position < 0) { + animationConfig.position %= animationData.duration; + animationConfig.position = animationData.duration - animationConfig.position; + } else animationConfig.position === animationData.duration ? animationConfig.position -= 1e-6 : animationConfig.position > animationData.duration && (animationConfig.position %= animationData.duration); + animationConfig.duration > 0 && animationConfig.position + animationConfig.duration > animationData.duration && (animationConfig.duration = animationData.duration - animationConfig.position); + animationConfig.playTimes < 0 && (animationConfig.playTimes = animationData.playTimes); + } else { + animationConfig.playTimes = 1; + animationConfig.position = 0; + animationConfig.duration > 0 && (animationConfig.duration = 0); + } + 0 === animationConfig.duration && (animationConfig.duration = -1); + this._fadeOut(animationConfig); + var animationState = dragonBones.BaseObject.borrowObject(dragonBones.AnimationState); + animationState.init(this._armature, animationData, animationConfig); + this._animationDirty = true; + this._armature._cacheFrameIndex = -1; + if (this._animationStates.length > 0) { + var added = false; + for (var i = 0, l = this._animationStates.length; i < l; ++i) { + if (animationState.layer > this._animationStates[i].layer) { + added = true; + this._animationStates.splice(i, 0, animationState); + break; + } + if (i !== l - 1 && animationState.layer > this._animationStates[i + 1].layer) { + added = true; + this._animationStates.splice(i + 1, 0, animationState); + break; + } + } + added || this._animationStates.push(animationState); + } else this._animationStates.push(animationState); + for (var _b = 0, _c = this._armature.getSlots(); _b < _c.length; _b++) { + var slot = _c[_b]; + var childArmature = slot.childArmature; + null !== childArmature && childArmature.inheritAnimation && childArmature.animation.hasAnimation(animationName) && null === childArmature.animation.getState(animationName) && childArmature.animation.fadeIn(animationName); + } + var isLocked = false; + for (var k in animationData.animationTimelines) { + if (!this._lockUpdate) { + isLocked = true; + this._lockUpdate = true; + } + var childAnimatiionState = this.fadeIn(k, animationConfig.fadeInTime, 1, animationState.layer, null, 0); + if (null !== childAnimatiionState) { + childAnimatiionState.resetToPose = false; + childAnimatiionState._parent = animationState; + childAnimatiionState.stop(); + } + } + isLocked && (this._lockUpdate = false); + if (!this._lockUpdate) { + animationConfig.fadeInTime <= 0 && this._armature.advanceTime(0); + this._lastAnimationState = animationState; + } + return animationState; + }; + Animation.prototype.play = function(animationName, playTimes) { + void 0 === animationName && (animationName = null); + void 0 === playTimes && (playTimes = -1); + this._animationConfig.clear(); + this._animationConfig.resetToPose = true; + this._animationConfig.playTimes = playTimes; + this._animationConfig.fadeInTime = 0; + this._animationConfig.animation = null !== animationName ? animationName : ""; + if (null !== animationName && animationName.length > 0) this.playConfig(this._animationConfig); else if (null === this._lastAnimationState) { + var defaultAnimation = this._armature.armatureData.defaultAnimation; + if (null !== defaultAnimation) { + this._animationConfig.animation = defaultAnimation.name; + this.playConfig(this._animationConfig); + } + } else if (this._lastAnimationState.isPlaying || this._lastAnimationState.isCompleted) { + this._animationConfig.animation = this._lastAnimationState.name; + this.playConfig(this._animationConfig); + } else this._lastAnimationState.play(); + return this._lastAnimationState; + }; + Animation.prototype.fadeIn = function(animationName, fadeInTime, playTimes, layer, group, fadeOutMode) { + void 0 === fadeInTime && (fadeInTime = -1); + void 0 === playTimes && (playTimes = -1); + void 0 === layer && (layer = 0); + void 0 === group && (group = null); + void 0 === fadeOutMode && (fadeOutMode = 3); + this._animationConfig.clear(); + this._animationConfig.fadeOutMode = fadeOutMode; + this._animationConfig.playTimes = playTimes; + this._animationConfig.layer = layer; + this._animationConfig.fadeInTime = fadeInTime; + this._animationConfig.animation = animationName; + this._animationConfig.group = null !== group ? group : ""; + return this.playConfig(this._animationConfig); + }; + Animation.prototype.gotoAndPlayByTime = function(animationName, time, playTimes) { + void 0 === time && (time = 0); + void 0 === playTimes && (playTimes = -1); + this._animationConfig.clear(); + this._animationConfig.resetToPose = true; + this._animationConfig.playTimes = playTimes; + this._animationConfig.position = time; + this._animationConfig.fadeInTime = 0; + this._animationConfig.animation = animationName; + return this.playConfig(this._animationConfig); + }; + Animation.prototype.gotoAndPlayByFrame = function(animationName, frame, playTimes) { + void 0 === frame && (frame = 0); + void 0 === playTimes && (playTimes = -1); + this._animationConfig.clear(); + this._animationConfig.resetToPose = true; + this._animationConfig.playTimes = playTimes; + this._animationConfig.fadeInTime = 0; + this._animationConfig.animation = animationName; + var animationData = animationName in this._animations ? this._animations[animationName] : null; + null !== animationData && (this._animationConfig.position = animationData.duration * frame / animationData.frameCount); + return this.playConfig(this._animationConfig); + }; + Animation.prototype.gotoAndPlayByProgress = function(animationName, progress, playTimes) { + void 0 === progress && (progress = 0); + void 0 === playTimes && (playTimes = -1); + this._animationConfig.clear(); + this._animationConfig.resetToPose = true; + this._animationConfig.playTimes = playTimes; + this._animationConfig.fadeInTime = 0; + this._animationConfig.animation = animationName; + var animationData = animationName in this._animations ? this._animations[animationName] : null; + null !== animationData && (this._animationConfig.position = animationData.duration * (progress > 0 ? progress : 0)); + return this.playConfig(this._animationConfig); + }; + Animation.prototype.gotoAndStopByTime = function(animationName, time) { + void 0 === time && (time = 0); + var animationState = this.gotoAndPlayByTime(animationName, time, 1); + null !== animationState && animationState.stop(); + return animationState; + }; + Animation.prototype.gotoAndStopByFrame = function(animationName, frame) { + void 0 === frame && (frame = 0); + var animationState = this.gotoAndPlayByFrame(animationName, frame, 1); + null !== animationState && animationState.stop(); + return animationState; + }; + Animation.prototype.gotoAndStopByProgress = function(animationName, progress) { + void 0 === progress && (progress = 0); + var animationState = this.gotoAndPlayByProgress(animationName, progress, 1); + null !== animationState && animationState.stop(); + return animationState; + }; + Animation.prototype.getState = function(animationName) { + var i = this._animationStates.length; + while (i--) { + var animationState = this._animationStates[i]; + if (animationState.name === animationName) return animationState; + } + return null; + }; + Animation.prototype.hasAnimation = function(animationName) { + return animationName in this._animations; + }; + Animation.prototype.getStates = function() { + return this._animationStates; + }; + Object.defineProperty(Animation.prototype, "isPlaying", { + get: function get() { + for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { + var animationState = _a[_i]; + if (animationState.isPlaying) return true; + } + return false; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Animation.prototype, "isCompleted", { + get: function get() { + for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { + var animationState = _a[_i]; + if (!animationState.isCompleted) return false; + } + return this._animationStates.length > 0; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Animation.prototype, "lastAnimationName", { + get: function get() { + return null !== this._lastAnimationState ? this._lastAnimationState.name : ""; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Animation.prototype, "animationNames", { + get: function get() { + return this._animationNames; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Animation.prototype, "animations", { + get: function get() { + return this._animations; + }, + set: function set(value) { + if (this._animations === value) return; + this._animationNames.length = 0; + for (var k in this._animations) delete this._animations[k]; + for (var k in value) { + this._animationNames.push(k); + this._animations[k] = value[k]; + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Animation.prototype, "animationConfig", { + get: function get() { + this._animationConfig.clear(); + return this._animationConfig; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Animation.prototype, "lastAnimationState", { + get: function get() { + return this._lastAnimationState; + }, + enumerable: true, + configurable: true + }); + Animation.prototype.gotoAndPlay = function(animationName, fadeInTime, duration, playTimes, layer, group, fadeOutMode, pauseFadeOut, pauseFadeIn) { + void 0 === fadeInTime && (fadeInTime = -1); + void 0 === duration && (duration = -1); + void 0 === playTimes && (playTimes = -1); + void 0 === layer && (layer = 0); + void 0 === group && (group = null); + void 0 === fadeOutMode && (fadeOutMode = 3); + void 0 === pauseFadeOut && (pauseFadeOut = true); + void 0 === pauseFadeIn && (pauseFadeIn = true); + console.warn("Deprecated."); + pauseFadeOut; + pauseFadeIn; + this._animationConfig.clear(); + this._animationConfig.resetToPose = true; + this._animationConfig.fadeOutMode = fadeOutMode; + this._animationConfig.playTimes = playTimes; + this._animationConfig.layer = layer; + this._animationConfig.fadeInTime = fadeInTime; + this._animationConfig.animation = animationName; + this._animationConfig.group = null !== group ? group : ""; + var animationData = this._animations[animationName]; + animationData && duration > 0 && (this._animationConfig.timeScale = animationData.duration / duration); + return this.playConfig(this._animationConfig); + }; + Animation.prototype.gotoAndStop = function(animationName, time) { + void 0 === time && (time = 0); + console.warn("Deprecated."); + return this.gotoAndStopByTime(animationName, time); + }; + Object.defineProperty(Animation.prototype, "animationList", { + get: function get() { + console.warn("Deprecated."); + return this._animationNames; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Animation.prototype, "animationDataList", { + get: function get() { + console.warn("Deprecated."); + var list = []; + for (var i = 0, l = this._animationNames.length; i < l; ++i) list.push(this._animations[this._animationNames[i]]); + return list; + }, + enumerable: true, + configurable: true + }); + return Animation; + })(dragonBones.BaseObject); + dragonBones.Animation = Animation; + })(dragonBones || (dragonBones = {})); + var dragonBones; + (function(dragonBones) { + var AnimationState = (function(_super) { + __extends(AnimationState, _super); + function AnimationState() { + var _this = null !== _super && _super.apply(this, arguments) || this; + _this._blendState = new BlendState(); + _this._boneMask = []; + _this._boneTimelines = []; + _this._surfaceTimelines = []; + _this._slotTimelines = []; + _this._constraintTimelines = []; + _this._animationTimelines = []; + _this._poseTimelines = []; + _this._bonePoses = {}; + _this._actionTimeline = null; + _this._zOrderTimeline = null; + _this._parent = null; + return _this; + } + AnimationState.toString = function() { + return "[class dragonBones.AnimationState]"; + }; + AnimationState.prototype._onClear = function() { + for (var _i = 0, _a = this._boneTimelines; _i < _a.length; _i++) { + var timeline = _a[_i]; + timeline.returnToPool(); + } + for (var _b = 0, _c = this._surfaceTimelines; _b < _c.length; _b++) { + var timeline = _c[_b]; + timeline.returnToPool(); + } + for (var _d = 0, _e = this._slotTimelines; _d < _e.length; _d++) { + var timeline = _e[_d]; + timeline.returnToPool(); + } + for (var _f = 0, _g = this._constraintTimelines; _f < _g.length; _f++) { + var timeline = _g[_f]; + timeline.returnToPool(); + } + for (var _h = 0, _j = this._animationTimelines; _h < _j.length; _h++) { + var timeline = _j[_h]; + timeline.returnToPool(); + } + for (var k in this._bonePoses) { + this._bonePoses[k].returnToPool(); + delete this._bonePoses[k]; + } + null !== this._actionTimeline && this._actionTimeline.returnToPool(); + null !== this._zOrderTimeline && this._zOrderTimeline.returnToPool(); + this.actionEnabled = false; + this.additiveBlending = false; + this.displayControl = false; + this.resetToPose = false; + this.playTimes = 1; + this.layer = 0; + this.timeScale = 1; + this.weight = 1; + this.autoFadeOutTime = 0; + this.fadeTotalTime = 0; + this.name = ""; + this.group = ""; + this._timelineDirty = 2; + this._playheadState = 0; + this._fadeState = -1; + this._subFadeState = -1; + this._position = 0; + this._duration = 0; + this._fadeTime = 0; + this._time = 0; + this._fadeProgress = 0; + this._weightResult = 0; + this._blendState.clear(); + this._boneMask.length = 0; + this._boneTimelines.length = 0; + this._surfaceTimelines.length = 0; + this._slotTimelines.length = 0; + this._constraintTimelines.length = 0; + this._animationTimelines.length = 0; + this._poseTimelines.length = 0; + this._animationData = null; + this._armature = null; + this._actionTimeline = null; + this._zOrderTimeline = null; + this._parent = null; + }; + AnimationState.prototype._updateTimelines = function() { + for (var _i = 0, _a = this._armature._constraints; _i < _a.length; _i++) { + var constraint = _a[_i]; + var timelineDatas = this._animationData.getConstraintTimelines(constraint.name); + if (null !== timelineDatas) for (var _b = 0, timelineDatas_1 = timelineDatas; _b < timelineDatas_1.length; _b++) { + var timelineData = timelineDatas_1[_b]; + switch (timelineData.type) { + case 30: + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.IKConstraintTimelineState); + timeline.constraint = constraint; + timeline.init(this._armature, this, timelineData); + this._constraintTimelines.push(timeline); + } + } else if (this.resetToPose) { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.IKConstraintTimelineState); + timeline.constraint = constraint; + timeline.init(this._armature, this, null); + this._constraintTimelines.push(timeline); + this._poseTimelines.push(timeline); + } + } + for (var _c = 0, _d = this._armature.animation.getStates(); _c < _d.length; _c++) { + var animationState = _d[_c]; + if (animationState._parent !== this) continue; + var timelineDatas = this._animationData.getAnimationTimelines(animationState.name); + if (null === timelineDatas) continue; + for (var _e = 0, timelineDatas_2 = timelineDatas; _e < timelineDatas_2.length; _e++) { + var timelineData = timelineDatas_2[_e]; + switch (timelineData.type) { + case 40: + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.AnimationTimelineState); + timeline.animationState = animationState; + timeline.init(this._armature, this, timelineData); + this._animationTimelines.push(timeline); + } + } + } + }; + AnimationState.prototype._updateBoneAndSlotTimelines = function() { + var boneTimelines = {}; + for (var _i = 0, _a = this._boneTimelines; _i < _a.length; _i++) { + var timeline = _a[_i]; + var timelineName = timeline.bone.name; + timelineName in boneTimelines || (boneTimelines[timelineName] = []); + boneTimelines[timelineName].push(timeline); + } + for (var _b = 0, _c = this._armature.getBones(); _b < _c.length; _b++) { + var bone = _c[_b]; + var timelineName = bone.name; + if (!this.containsBoneMask(timelineName)) continue; + if (timelineName in boneTimelines) delete boneTimelines[timelineName]; else if (0 === bone._boneData.type) { + var timelineDatas = this._animationData.getBoneTimelines(timelineName); + var bonePose = timelineName in this._bonePoses ? this._bonePoses[timelineName] : this._bonePoses[timelineName] = dragonBones.BaseObject.borrowObject(BonePose); + if (null !== timelineDatas) for (var _d = 0, timelineDatas_3 = timelineDatas; _d < timelineDatas_3.length; _d++) { + var timelineData = timelineDatas_3[_d]; + switch (timelineData.type) { + case 10: + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.BoneAllTimelineState); + timeline.bone = bone; + timeline.bonePose = bonePose; + timeline.init(this._armature, this, timelineData); + this._boneTimelines.push(timeline); + break; + + case 11: + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.BoneTranslateTimelineState); + timeline.bone = bone; + timeline.bonePose = bonePose; + timeline.init(this._armature, this, timelineData); + this._boneTimelines.push(timeline); + break; + + case 12: + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.BoneRotateTimelineState); + timeline.bone = bone; + timeline.bonePose = bonePose; + timeline.init(this._armature, this, timelineData); + this._boneTimelines.push(timeline); + break; + + case 13: + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.BoneScaleTimelineState); + timeline.bone = bone; + timeline.bonePose = bonePose; + timeline.init(this._armature, this, timelineData); + this._boneTimelines.push(timeline); + } + } else if (this.resetToPose) { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.BoneAllTimelineState); + timeline.bone = bone; + timeline.bonePose = bonePose; + timeline.init(this._armature, this, null); + this._boneTimelines.push(timeline); + this._poseTimelines.push(timeline); + } + } else if (1 === bone._boneData.type) { + var timelineDatas = this._animationData.getSurfaceTimelines(timelineName); + if (null !== timelineDatas) for (var _e = 0, timelineDatas_4 = timelineDatas; _e < timelineDatas_4.length; _e++) { + var timelineData = timelineDatas_4[_e]; + switch (timelineData.type) { + case 50: + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SurfaceTimelineState); + timeline.surface = bone; + timeline.init(this._armature, this, timelineData); + this._surfaceTimelines.push(timeline); + } + } else if (this.resetToPose) { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SurfaceTimelineState); + timeline.surface = bone; + timeline.init(this._armature, this, null); + this._surfaceTimelines.push(timeline); + this._poseTimelines.push(timeline); + } + } + } + for (var k in boneTimelines) for (var _f = 0, _g = boneTimelines[k]; _f < _g.length; _f++) { + var timeline = _g[_f]; + this._boneTimelines.splice(this._boneTimelines.indexOf(timeline), 1); + timeline.returnToPool(); + } + var slotTimelines = {}; + var ffdFlags = []; + for (var _h = 0, _j = this._slotTimelines; _h < _j.length; _h++) { + var timeline = _j[_h]; + var timelineName = timeline.slot.name; + timelineName in slotTimelines || (slotTimelines[timelineName] = []); + slotTimelines[timelineName].push(timeline); + } + for (var _k = 0, _l = this._armature.getSlots(); _k < _l.length; _k++) { + var slot = _l[_k]; + var boneName = slot.parent.name; + if (!this.containsBoneMask(boneName)) continue; + var timelineName = slot.name; + var timelineDatas = this._animationData.getSlotTimelines(timelineName); + if (timelineName in slotTimelines) delete slotTimelines[timelineName]; else { + var displayIndexFlag = false; + var colorFlag = false; + ffdFlags.length = 0; + if (null !== timelineDatas) for (var _m = 0, timelineDatas_5 = timelineDatas; _m < timelineDatas_5.length; _m++) { + var timelineData = timelineDatas_5[_m]; + switch (timelineData.type) { + case 20: + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotDislayTimelineState); + timeline.slot = slot; + timeline.init(this._armature, this, timelineData); + this._slotTimelines.push(timeline); + displayIndexFlag = true; + break; + + case 21: + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotColorTimelineState); + timeline.slot = slot; + timeline.init(this._armature, this, timelineData); + this._slotTimelines.push(timeline); + colorFlag = true; + break; + + case 22: + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.DeformTimelineState); + timeline.slot = slot; + timeline.init(this._armature, this, timelineData); + this._slotTimelines.push(timeline); + ffdFlags.push(timeline.vertexOffset); + } + } + if (this.resetToPose) { + if (!displayIndexFlag) { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotDislayTimelineState); + timeline.slot = slot; + timeline.init(this._armature, this, null); + this._slotTimelines.push(timeline); + this._poseTimelines.push(timeline); + } + if (!colorFlag) { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotColorTimelineState); + timeline.slot = slot; + timeline.init(this._armature, this, null); + this._slotTimelines.push(timeline); + this._poseTimelines.push(timeline); + } + if (null !== slot.rawDisplayDatas) for (var _o = 0, _p = slot.rawDisplayDatas; _o < _p.length; _o++) { + var displayData = _p[_o]; + if (null !== displayData && 2 === displayData.type) { + var meshOffset = displayData.vertices.offset; + if (ffdFlags.indexOf(meshOffset) < 0) { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.DeformTimelineState); + timeline.vertexOffset = meshOffset; + timeline.slot = slot; + timeline.init(this._armature, this, null); + this._slotTimelines.push(timeline); + this._poseTimelines.push(timeline); + } + } + } + } + } + } + for (var k in slotTimelines) for (var _q = 0, _r = slotTimelines[k]; _q < _r.length; _q++) { + var timeline = _r[_q]; + this._slotTimelines.splice(this._slotTimelines.indexOf(timeline), 1); + timeline.returnToPool(); + } + }; + AnimationState.prototype._advanceFadeTime = function(passedTime) { + var isFadeOut = this._fadeState > 0; + if (this._subFadeState < 0) { + this._subFadeState = 0; + var eventType = isFadeOut ? dragonBones.EventObject.FADE_OUT : dragonBones.EventObject.FADE_IN; + if (this._armature.eventDispatcher.hasDBEventListener(eventType)) { + var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); + eventObject.type = eventType; + eventObject.armature = this._armature; + eventObject.animationState = this; + this._armature._dragonBones.bufferEvent(eventObject); + } + } + passedTime < 0 && (passedTime = -passedTime); + this._fadeTime += passedTime; + if (this._fadeTime >= this.fadeTotalTime) { + this._subFadeState = 1; + this._fadeProgress = isFadeOut ? 0 : 1; + } else this._fadeTime > 0 ? this._fadeProgress = isFadeOut ? 1 - this._fadeTime / this.fadeTotalTime : this._fadeTime / this.fadeTotalTime : this._fadeProgress = isFadeOut ? 1 : 0; + if (this._subFadeState > 0) { + if (!isFadeOut) { + this._playheadState |= 1; + this._fadeState = 0; + } + var eventType = isFadeOut ? dragonBones.EventObject.FADE_OUT_COMPLETE : dragonBones.EventObject.FADE_IN_COMPLETE; + if (this._armature.eventDispatcher.hasDBEventListener(eventType)) { + var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); + eventObject.type = eventType; + eventObject.armature = this._armature; + eventObject.animationState = this; + this._armature._dragonBones.bufferEvent(eventObject); + } + } + }; + AnimationState.prototype.init = function(armature, animationData, animationConfig) { + if (null !== this._armature) return; + this._armature = armature; + this._animationData = animationData; + this.resetToPose = animationConfig.resetToPose; + this.additiveBlending = animationConfig.additiveBlending; + this.displayControl = animationConfig.displayControl; + this.actionEnabled = animationConfig.actionEnabled; + this.layer = animationConfig.layer; + this.playTimes = animationConfig.playTimes; + this.timeScale = animationConfig.timeScale; + this.fadeTotalTime = animationConfig.fadeInTime; + this.autoFadeOutTime = animationConfig.autoFadeOutTime; + this.weight = animationConfig.weight; + this.name = animationConfig.name.length > 0 ? animationConfig.name : animationConfig.animation; + this.group = animationConfig.group; + animationConfig.pauseFadeIn ? this._playheadState = 2 : this._playheadState = 3; + if (animationConfig.duration < 0) { + this._position = 0; + this._duration = this._animationData.duration; + 0 !== animationConfig.position ? this.timeScale >= 0 ? this._time = animationConfig.position : this._time = animationConfig.position - this._duration : this._time = 0; + } else { + this._position = animationConfig.position; + this._duration = animationConfig.duration; + this._time = 0; + } + this.timeScale < 0 && 0 === this._time && (this._time = -1e-6); + this.fadeTotalTime <= 0 && (this._fadeProgress = .999999); + if (animationConfig.boneMask.length > 0) { + this._boneMask.length = animationConfig.boneMask.length; + for (var i = 0, l = this._boneMask.length; i < l; ++i) this._boneMask[i] = animationConfig.boneMask[i]; + } + this._actionTimeline = dragonBones.BaseObject.borrowObject(dragonBones.ActionTimelineState); + this._actionTimeline.init(this._armature, this, this._animationData.actionTimeline); + this._actionTimeline.currentTime = this._time; + this._actionTimeline.currentTime < 0 && (this._actionTimeline.currentTime = this._duration - this._actionTimeline.currentTime); + if (null !== this._animationData.zOrderTimeline) { + this._zOrderTimeline = dragonBones.BaseObject.borrowObject(dragonBones.ZOrderTimelineState); + this._zOrderTimeline.init(this._armature, this, this._animationData.zOrderTimeline); + } + }; + AnimationState.prototype.advanceTime = function(passedTime, cacheFrameRate) { + this._blendState.dirty = false; + 0 === this._fadeState && 0 === this._subFadeState || this._advanceFadeTime(passedTime); + if (3 === this._playheadState) { + 1 !== this.timeScale && (passedTime *= this.timeScale); + this._time += passedTime; + } + if (0 !== this._timelineDirty) { + 2 === this._timelineDirty && this._updateTimelines(); + this._timelineDirty = 0; + this._updateBoneAndSlotTimelines(); + } + if (0 === this.weight) return; + var isCacheEnabled = 0 === this._fadeState && cacheFrameRate > 0; + var isUpdateTimeline = true; + var isUpdateBoneTimeline = true; + var time = this._time; + this._weightResult = this.weight * this._fadeProgress; + null !== this._parent && (this._weightResult *= this._parent._weightResult / this._parent._fadeProgress); + this._actionTimeline.playState <= 0 && this._actionTimeline.update(time); + if (isCacheEnabled) { + var internval = 2 * cacheFrameRate; + this._actionTimeline.currentTime = Math.floor(this._actionTimeline.currentTime * internval) / internval; + } + null !== this._zOrderTimeline && this._zOrderTimeline.playState <= 0 && this._zOrderTimeline.update(time); + if (isCacheEnabled) { + var cacheFrameIndex = Math.floor(this._actionTimeline.currentTime * cacheFrameRate); + if (this._armature._cacheFrameIndex === cacheFrameIndex) { + isUpdateTimeline = false; + isUpdateBoneTimeline = false; + } else { + this._armature._cacheFrameIndex = cacheFrameIndex; + this._animationData.cachedFrames[cacheFrameIndex] ? isUpdateBoneTimeline = false : this._animationData.cachedFrames[cacheFrameIndex] = true; + } + } + if (isUpdateTimeline) { + if (isUpdateBoneTimeline) for (var i = 0, l = this._boneTimelines.length; i < l; ++i) { + var timeline = this._boneTimelines[i]; + timeline.playState <= 0 && timeline.update(time); + if (i === l - 1 || timeline.bone !== this._boneTimelines[i + 1].bone) { + var state = timeline.bone._blendState.update(this._weightResult, this.layer); + 0 !== state && timeline.blend(state); + } + } + for (var i = 0, l = this._surfaceTimelines.length; i < l; ++i) { + var timeline = this._surfaceTimelines[i]; + var state = timeline.surface._blendState.update(this._weightResult, this.layer); + timeline.playState <= 0 && timeline.update(time); + 0 !== state && timeline.blend(state); + } + if (this.displayControl) for (var i = 0, l = this._slotTimelines.length; i < l; ++i) { + var timeline = this._slotTimelines[i]; + var displayController = timeline.slot.displayController; + null !== displayController && displayController !== this.name && displayController !== this.group || timeline.playState <= 0 && timeline.update(time); + } + for (var i = 0, l = this._constraintTimelines.length; i < l; ++i) { + var timeline = this._constraintTimelines[i]; + timeline.playState <= 0 && timeline.update(time); + } + for (var i = 0, l = this._animationTimelines.length; i < l; ++i) { + var timeline = this._animationTimelines[i]; + var state = timeline.animationState._blendState.update(this._weightResult, this.layer); + timeline.playState <= 0 && timeline.update(time); + 0 !== state && timeline.blend(state); + } + } + if (0 === this._fadeState) { + if (this._subFadeState > 0) { + this._subFadeState = 0; + if (this._poseTimelines.length > 0) { + for (var _i = 0, _a = this._poseTimelines; _i < _a.length; _i++) { + var timeline = _a[_i]; + timeline instanceof dragonBones.BoneTimelineState ? this._boneTimelines.splice(this._boneTimelines.indexOf(timeline), 1) : timeline instanceof dragonBones.SurfaceTimelineState ? this._surfaceTimelines.splice(this._surfaceTimelines.indexOf(timeline), 1) : timeline instanceof dragonBones.SlotTimelineState ? this._slotTimelines.splice(this._slotTimelines.indexOf(timeline), 1) : timeline instanceof dragonBones.ConstraintTimelineState && this._constraintTimelines.splice(this._constraintTimelines.indexOf(timeline), 1); + timeline.returnToPool(); + } + this._poseTimelines.length = 0; + } + } + this._actionTimeline.playState > 0 && this.autoFadeOutTime >= 0 && this.fadeOut(this.autoFadeOutTime); + } + }; + AnimationState.prototype.play = function() { + this._playheadState = 3; + }; + AnimationState.prototype.stop = function() { + this._playheadState &= 1; + }; + AnimationState.prototype.fadeOut = function(fadeOutTime, pausePlayhead) { + void 0 === pausePlayhead && (pausePlayhead = true); + fadeOutTime < 0 && (fadeOutTime = 0); + pausePlayhead && (this._playheadState &= 2); + if (this._fadeState > 0) { + if (fadeOutTime > this.fadeTotalTime - this._fadeTime) return; + } else { + this._fadeState = 1; + this._subFadeState = -1; + (fadeOutTime <= 0 || this._fadeProgress <= 0) && (this._fadeProgress = 1e-6); + for (var _i = 0, _a = this._boneTimelines; _i < _a.length; _i++) { + var timeline = _a[_i]; + timeline.fadeOut(); + } + for (var _b = 0, _c = this._surfaceTimelines; _b < _c.length; _b++) { + var timeline = _c[_b]; + timeline.fadeOut(); + } + for (var _d = 0, _e = this._slotTimelines; _d < _e.length; _d++) { + var timeline = _e[_d]; + timeline.fadeOut(); + } + for (var _f = 0, _g = this._constraintTimelines; _f < _g.length; _f++) { + var timeline = _g[_f]; + timeline.fadeOut(); + } + for (var _h = 0, _j = this._animationTimelines; _h < _j.length; _h++) { + var timeline = _j[_h]; + timeline.animationState.fadeOut(fadeOutTime, pausePlayhead); + timeline.fadeOut(); + } + } + this.displayControl = false; + this.fadeTotalTime = this._fadeProgress > 1e-6 ? fadeOutTime / this._fadeProgress : 0; + this._fadeTime = this.fadeTotalTime * (1 - this._fadeProgress); + }; + AnimationState.prototype.containsBoneMask = function(boneName) { + return 0 === this._boneMask.length || this._boneMask.indexOf(boneName) >= 0; + }; + AnimationState.prototype.addBoneMask = function(boneName, recursive) { + void 0 === recursive && (recursive = true); + var currentBone = this._armature.getBone(boneName); + if (null === currentBone) return; + this._boneMask.indexOf(boneName) < 0 && this._boneMask.push(boneName); + if (recursive) for (var _i = 0, _a = this._armature.getBones(); _i < _a.length; _i++) { + var bone = _a[_i]; + this._boneMask.indexOf(bone.name) < 0 && currentBone.contains(bone) && this._boneMask.push(bone.name); + } + this._timelineDirty = 1; + }; + AnimationState.prototype.removeBoneMask = function(boneName, recursive) { + void 0 === recursive && (recursive = true); + var index = this._boneMask.indexOf(boneName); + index >= 0 && this._boneMask.splice(index, 1); + if (recursive) { + var currentBone = this._armature.getBone(boneName); + if (null !== currentBone) { + var bones = this._armature.getBones(); + if (this._boneMask.length > 0) for (var _i = 0, bones_1 = bones; _i < bones_1.length; _i++) { + var bone = bones_1[_i]; + var index_2 = this._boneMask.indexOf(bone.name); + index_2 >= 0 && currentBone.contains(bone) && this._boneMask.splice(index_2, 1); + } else for (var _a = 0, bones_2 = bones; _a < bones_2.length; _a++) { + var bone = bones_2[_a]; + if (bone === currentBone) continue; + currentBone.contains(bone) || this._boneMask.push(bone.name); + } + } + } + this._timelineDirty = 1; + }; + AnimationState.prototype.removeAllBoneMask = function() { + this._boneMask.length = 0; + this._timelineDirty = 1; + }; + Object.defineProperty(AnimationState.prototype, "isFadeIn", { + get: function get() { + return this._fadeState < 0; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "isFadeOut", { + get: function get() { + return this._fadeState > 0; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "isFadeComplete", { + get: function get() { + return 0 === this._fadeState; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "isPlaying", { + get: function get() { + return 0 !== (2 & this._playheadState) && this._actionTimeline.playState <= 0; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "isCompleted", { + get: function get() { + return this._actionTimeline.playState > 0; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "currentPlayTimes", { + get: function get() { + return this._actionTimeline.currentPlayTimes; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "totalTime", { + get: function get() { + return this._duration; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "currentTime", { + get: function get() { + return this._actionTimeline.currentTime; + }, + set: function set(value) { + var currentPlayTimes = this._actionTimeline.currentPlayTimes - (this._actionTimeline.playState > 0 ? 1 : 0); + if (value < 0 || this._duration < value) { + value = value % this._duration + currentPlayTimes * this._duration; + value < 0 && (value += this._duration); + } + this.playTimes > 0 && currentPlayTimes === this.playTimes - 1 && value === this._duration && (value = this._duration - 1e-6); + if (this._time === value) return; + this._time = value; + this._actionTimeline.setCurrentTime(this._time); + null !== this._zOrderTimeline && (this._zOrderTimeline.playState = -1); + for (var _i = 0, _a = this._boneTimelines; _i < _a.length; _i++) { + var timeline = _a[_i]; + timeline.playState = -1; + } + for (var _b = 0, _c = this._slotTimelines; _b < _c.length; _b++) { + var timeline = _c[_b]; + timeline.playState = -1; + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "animationData", { + get: function get() { + return this._animationData; + }, + enumerable: true, + configurable: true + }); + return AnimationState; + })(dragonBones.BaseObject); + dragonBones.AnimationState = AnimationState; + var BonePose = (function(_super) { + __extends(BonePose, _super); + function BonePose() { + var _this = null !== _super && _super.apply(this, arguments) || this; + _this.current = new dragonBones.Transform(); + _this.delta = new dragonBones.Transform(); + _this.result = new dragonBones.Transform(); + return _this; + } + BonePose.toString = function() { + return "[class dragonBones.BonePose]"; + }; + BonePose.prototype._onClear = function() { + this.current.identity(); + this.delta.identity(); + this.result.identity(); + }; + return BonePose; + })(dragonBones.BaseObject); + dragonBones.BonePose = BonePose; + var BlendState = (function() { + function BlendState() {} + BlendState.prototype.update = function(weight, p_layer) { + if (this.dirty) { + if (!(this.leftWeight > 0)) return 0; + if (this.layer !== p_layer) { + if (this.layerWeight >= this.leftWeight) { + this.leftWeight = 0; + return 0; + } + this.layer = p_layer; + this.leftWeight -= this.layerWeight; + this.layerWeight = 0; + } + weight *= this.leftWeight; + this.layerWeight += weight; + this.blendWeight = weight; + return 2; + } + this.dirty = true; + this.layer = p_layer; + this.layerWeight = weight; + this.leftWeight = 1; + this.blendWeight = weight; + return 1; + }; + BlendState.prototype.clear = function() { + this.dirty = false; + this.layer = 0; + this.leftWeight = 0; + this.layerWeight = 0; + this.blendWeight = 0; + }; + return BlendState; + })(); + dragonBones.BlendState = BlendState; + })(dragonBones || (dragonBones = {})); + var dragonBones; + (function(dragonBones) { + var TimelineState = (function(_super) { + __extends(TimelineState, _super); + function TimelineState() { + return null !== _super && _super.apply(this, arguments) || this; + } + TimelineState.prototype._onClear = function() { + this.playState = -1; + this.currentPlayTimes = -1; + this.currentTime = -1; + this._tweenState = 0; + this._frameRate = 0; + this._frameValueOffset = 0; + this._frameCount = 0; + this._frameOffset = 0; + this._frameIndex = -1; + this._frameRateR = 0; + this._position = 0; + this._duration = 0; + this._timeScale = 1; + this._timeOffset = 0; + this._dragonBonesData = null; + this._animationData = null; + this._timelineData = null; + this._armature = null; + this._animationState = null; + this._actionTimeline = null; + this._frameArray = null; + this._frameIntArray = null; + this._frameFloatArray = null; + this._timelineArray = null; + this._frameIndices = null; + }; + TimelineState.prototype._setCurrentTime = function(passedTime) { + var prevState = this.playState; + var prevPlayTimes = this.currentPlayTimes; + var prevTime = this.currentTime; + if (null !== this._actionTimeline && this._frameCount <= 1) { + this.playState = this._actionTimeline.playState >= 0 ? 1 : -1; + this.currentPlayTimes = 1; + this.currentTime = this._actionTimeline.currentTime; + } else if (null === this._actionTimeline || 1 !== this._timeScale || 0 !== this._timeOffset) { + var playTimes = this._animationState.playTimes; + var totalTime = playTimes * this._duration; + passedTime *= this._timeScale; + 0 !== this._timeOffset && (passedTime += this._timeOffset * this._animationData.duration); + if (playTimes > 0 && (passedTime >= totalTime || passedTime <= -totalTime)) { + this.playState <= 0 && 3 === this._animationState._playheadState && (this.playState = 1); + this.currentPlayTimes = playTimes; + this.currentTime = passedTime < 0 ? 0 : this._duration + 1e-6; + } else { + 0 !== this.playState && 3 === this._animationState._playheadState && (this.playState = 0); + if (passedTime < 0) { + passedTime = -passedTime; + this.currentPlayTimes = Math.floor(passedTime / this._duration); + this.currentTime = this._duration - passedTime % this._duration; + } else { + this.currentPlayTimes = Math.floor(passedTime / this._duration); + this.currentTime = passedTime % this._duration; + } + } + this.currentTime += this._position; + } else { + this.playState = this._actionTimeline.playState; + this.currentPlayTimes = this._actionTimeline.currentPlayTimes; + this.currentTime = this._actionTimeline.currentTime; + } + if (this.currentPlayTimes === prevPlayTimes && this.currentTime === prevTime) return false; + (prevState < 0 && this.playState !== prevState || this.playState <= 0 && this.currentPlayTimes !== prevPlayTimes) && (this._frameIndex = -1); + return true; + }; + TimelineState.prototype.init = function(armature, animationState, timelineData) { + this._armature = armature; + this._animationState = animationState; + this._timelineData = timelineData; + this._actionTimeline = this._animationState._actionTimeline; + this === this._actionTimeline && (this._actionTimeline = null); + this._animationData = this._animationState._animationData; + this._frameRate = this._animationData.parent.frameRate; + this._frameRateR = 1 / this._frameRate; + this._position = this._animationState._position; + this._duration = this._animationState._duration; + this._dragonBonesData = this._animationData.parent.parent; + if (null !== this._timelineData) { + this._frameIntArray = this._dragonBonesData.frameIntArray; + this._frameFloatArray = this._dragonBonesData.frameFloatArray; + this._frameArray = this._dragonBonesData.frameArray; + this._timelineArray = this._dragonBonesData.timelineArray; + this._frameIndices = this._dragonBonesData.frameIndices; + this._frameCount = this._timelineArray[this._timelineData.offset + 2]; + this._frameValueOffset = this._timelineArray[this._timelineData.offset + 4]; + this._timeScale = 100 / this._timelineArray[this._timelineData.offset + 0]; + this._timeOffset = .01 * this._timelineArray[this._timelineData.offset + 1]; + } + }; + TimelineState.prototype.fadeOut = function() {}; + TimelineState.prototype.update = function(passedTime) { + if (this._setCurrentTime(passedTime)) { + if (this._frameCount > 1) { + var timelineFrameIndex = Math.floor(this.currentTime * this._frameRate); + var frameIndex = this._frameIndices[this._timelineData.frameIndicesOffset + timelineFrameIndex]; + if (this._frameIndex !== frameIndex) { + this._frameIndex = frameIndex; + this._frameOffset = this._animationData.frameOffset + this._timelineArray[this._timelineData.offset + 5 + this._frameIndex]; + this._onArriveAtFrame(); + } + } else if (this._frameIndex < 0) { + this._frameIndex = 0; + null !== this._timelineData && (this._frameOffset = this._animationData.frameOffset + this._timelineArray[this._timelineData.offset + 5]); + this._onArriveAtFrame(); + } + 0 !== this._tweenState && this._onUpdateFrame(); + } + }; + return TimelineState; + })(dragonBones.BaseObject); + dragonBones.TimelineState = TimelineState; + var TweenTimelineState = (function(_super) { + __extends(TweenTimelineState, _super); + function TweenTimelineState() { + return null !== _super && _super.apply(this, arguments) || this; + } + TweenTimelineState._getEasingValue = function(tweenType, progress, easing) { + var value = progress; + switch (tweenType) { + case 3: + value = Math.pow(progress, 2); + break; + + case 4: + value = 1 - Math.pow(1 - progress, 2); + break; + + case 5: + value = .5 * (1 - Math.cos(progress * Math.PI)); + } + return (value - progress) * easing + progress; + }; + TweenTimelineState._getEasingCurveValue = function(progress, samples, count, offset) { + if (progress <= 0) return 0; + if (progress >= 1) return 1; + var segmentCount = count + 1; + var valueIndex = Math.floor(progress * segmentCount); + var fromValue = 0 === valueIndex ? 0 : samples[offset + valueIndex - 1]; + var toValue = valueIndex === segmentCount - 1 ? 1e4 : samples[offset + valueIndex]; + return 1e-4 * (fromValue + (toValue - fromValue) * (progress * segmentCount - valueIndex)); + }; + TweenTimelineState.prototype._onClear = function() { + _super.prototype._onClear.call(this); + this._tweenType = 0; + this._curveCount = 0; + this._framePosition = 0; + this._frameDurationR = 0; + this._tweenProgress = 0; + this._tweenEasing = 0; + }; + TweenTimelineState.prototype._onArriveAtFrame = function() { + if (this._frameCount > 1 && (this._frameIndex !== this._frameCount - 1 || 0 === this._animationState.playTimes || this._animationState.currentPlayTimes < this._animationState.playTimes - 1)) { + this._tweenType = this._frameArray[this._frameOffset + 1]; + this._tweenState = 0 === this._tweenType ? 1 : 2; + 2 === this._tweenType ? this._curveCount = this._frameArray[this._frameOffset + 2] : 0 !== this._tweenType && 1 !== this._tweenType && (this._tweenEasing = .01 * this._frameArray[this._frameOffset + 2]); + this._framePosition = this._frameArray[this._frameOffset] * this._frameRateR; + if (this._frameIndex === this._frameCount - 1) this._frameDurationR = 1 / (this._animationData.duration - this._framePosition); else { + var nextFrameOffset = this._animationData.frameOffset + this._timelineArray[this._timelineData.offset + 5 + this._frameIndex + 1]; + var frameDuration = this._frameArray[nextFrameOffset] * this._frameRateR - this._framePosition; + this._frameDurationR = frameDuration > 0 ? 1 / frameDuration : 0; + } + } else this._tweenState = 1; + }; + TweenTimelineState.prototype._onUpdateFrame = function() { + if (2 === this._tweenState) { + this._tweenProgress = (this.currentTime - this._framePosition) * this._frameDurationR; + 2 === this._tweenType ? this._tweenProgress = TweenTimelineState._getEasingCurveValue(this._tweenProgress, this._frameArray, this._curveCount, this._frameOffset + 3) : 1 !== this._tweenType && (this._tweenProgress = TweenTimelineState._getEasingValue(this._tweenType, this._tweenProgress, this._tweenEasing)); + } else this._tweenProgress = 0; + }; + return TweenTimelineState; + })(TimelineState); + dragonBones.TweenTimelineState = TweenTimelineState; + var BoneTimelineState = (function(_super) { + __extends(BoneTimelineState, _super); + function BoneTimelineState() { + return null !== _super && _super.apply(this, arguments) || this; + } + BoneTimelineState.prototype._onClear = function() { + _super.prototype._onClear.call(this); + this.bone = null; + this.bonePose = null; + }; + BoneTimelineState.prototype.blend = function(state) { + var blendWeight = this.bone._blendState.blendWeight; + var animationPose = this.bone.animationPose; + var result = this.bonePose.result; + if (2 === state) { + animationPose.x += result.x * blendWeight; + animationPose.y += result.y * blendWeight; + animationPose.rotation += result.rotation * blendWeight; + animationPose.skew += result.skew * blendWeight; + animationPose.scaleX += (result.scaleX - 1) * blendWeight; + animationPose.scaleY += (result.scaleY - 1) * blendWeight; + } else if (1 !== blendWeight) { + animationPose.x = result.x * blendWeight; + animationPose.y = result.y * blendWeight; + animationPose.rotation = result.rotation * blendWeight; + animationPose.skew = result.skew * blendWeight; + animationPose.scaleX = (result.scaleX - 1) * blendWeight + 1; + animationPose.scaleY = (result.scaleY - 1) * blendWeight + 1; + } else { + animationPose.x = result.x; + animationPose.y = result.y; + animationPose.rotation = result.rotation; + animationPose.skew = result.skew; + animationPose.scaleX = result.scaleX; + animationPose.scaleY = result.scaleY; + } + 0 === this._animationState._fadeState && 0 === this._animationState._subFadeState || (this.bone._transformDirty = true); + }; + return BoneTimelineState; + })(TweenTimelineState); + dragonBones.BoneTimelineState = BoneTimelineState; + var SlotTimelineState = (function(_super) { + __extends(SlotTimelineState, _super); + function SlotTimelineState() { + return null !== _super && _super.apply(this, arguments) || this; + } + SlotTimelineState.prototype._onClear = function() { + _super.prototype._onClear.call(this); + this.slot = null; + }; + return SlotTimelineState; + })(TweenTimelineState); + dragonBones.SlotTimelineState = SlotTimelineState; + var ConstraintTimelineState = (function(_super) { + __extends(ConstraintTimelineState, _super); + function ConstraintTimelineState() { + return null !== _super && _super.apply(this, arguments) || this; + } + ConstraintTimelineState.prototype._onClear = function() { + _super.prototype._onClear.call(this); + this.constraint = null; + }; + return ConstraintTimelineState; + })(TweenTimelineState); + dragonBones.ConstraintTimelineState = ConstraintTimelineState; + })(dragonBones || (dragonBones = {})); + var dragonBones; + (function(dragonBones) { + var ActionTimelineState = (function(_super) { + __extends(ActionTimelineState, _super); + function ActionTimelineState() { + return null !== _super && _super.apply(this, arguments) || this; + } + ActionTimelineState.toString = function() { + return "[class dragonBones.ActionTimelineState]"; + }; + ActionTimelineState.prototype._onCrossFrame = function(frameIndex) { + var eventDispatcher = this._armature.eventDispatcher; + if (this._animationState.actionEnabled) { + var frameOffset = this._animationData.frameOffset + this._timelineArray[this._timelineData.offset + 5 + frameIndex]; + var actionCount = this._frameArray[frameOffset + 1]; + var actions = this._animationData.parent.actions; + for (var i = 0; i < actionCount; ++i) { + var actionIndex = this._frameArray[frameOffset + 2 + i]; + var action = actions[actionIndex]; + if (0 === action.type) { + var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); + eventObject.time = this._frameArray[frameOffset] / this._frameRate; + eventObject.animationState = this._animationState; + dragonBones.EventObject.actionDataToInstance(action, eventObject, this._armature); + this._armature._bufferAction(eventObject, true); + } else { + var eventType = 10 === action.type ? dragonBones.EventObject.FRAME_EVENT : dragonBones.EventObject.SOUND_EVENT; + if (11 === action.type || eventDispatcher.hasDBEventListener(eventType)) { + var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); + eventObject.time = this._frameArray[frameOffset] / this._frameRate; + eventObject.animationState = this._animationState; + dragonBones.EventObject.actionDataToInstance(action, eventObject, this._armature); + this._armature._dragonBones.bufferEvent(eventObject); + } + } + } + } + }; + ActionTimelineState.prototype._onArriveAtFrame = function() {}; + ActionTimelineState.prototype._onUpdateFrame = function() {}; + ActionTimelineState.prototype.update = function(passedTime) { + var prevState = this.playState; + var prevPlayTimes = this.currentPlayTimes; + var prevTime = this.currentTime; + if (this._setCurrentTime(passedTime)) { + var eventDispatcher = this._armature.eventDispatcher; + if (prevState < 0) { + if (this.playState === prevState) return; + this._animationState.displayControl && this._animationState.resetToPose && this._armature._sortZOrder(null, 0); + prevPlayTimes = this.currentPlayTimes; + if (eventDispatcher.hasDBEventListener(dragonBones.EventObject.START)) { + var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); + eventObject.type = dragonBones.EventObject.START; + eventObject.armature = this._armature; + eventObject.animationState = this._animationState; + this._armature._dragonBones.bufferEvent(eventObject); + } + } + var isReverse = this._animationState.timeScale < 0; + var loopCompleteEvent = null; + var completeEvent = null; + if (this.currentPlayTimes !== prevPlayTimes) { + if (eventDispatcher.hasDBEventListener(dragonBones.EventObject.LOOP_COMPLETE)) { + loopCompleteEvent = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); + loopCompleteEvent.type = dragonBones.EventObject.LOOP_COMPLETE; + loopCompleteEvent.armature = this._armature; + loopCompleteEvent.animationState = this._animationState; + } + if (this.playState > 0 && eventDispatcher.hasDBEventListener(dragonBones.EventObject.COMPLETE)) { + completeEvent = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); + completeEvent.type = dragonBones.EventObject.COMPLETE; + completeEvent.armature = this._armature; + completeEvent.animationState = this._animationState; + } + } + if (this._frameCount > 1) { + var timelineData = this._timelineData; + var timelineFrameIndex = Math.floor(this.currentTime * this._frameRate); + var frameIndex = this._frameIndices[timelineData.frameIndicesOffset + timelineFrameIndex]; + if (this._frameIndex !== frameIndex) { + var crossedFrameIndex = this._frameIndex; + this._frameIndex = frameIndex; + if (null !== this._timelineArray) { + this._frameOffset = this._animationData.frameOffset + this._timelineArray[timelineData.offset + 5 + this._frameIndex]; + if (isReverse) { + if (crossedFrameIndex < 0) { + var prevFrameIndex = Math.floor(prevTime * this._frameRate); + crossedFrameIndex = this._frameIndices[timelineData.frameIndicesOffset + prevFrameIndex]; + this.currentPlayTimes === prevPlayTimes && crossedFrameIndex === frameIndex && (crossedFrameIndex = -1); + } + while (crossedFrameIndex >= 0) { + var frameOffset = this._animationData.frameOffset + this._timelineArray[timelineData.offset + 5 + crossedFrameIndex]; + var framePosition = this._frameArray[frameOffset] / this._frameRate; + this._position <= framePosition && framePosition <= this._position + this._duration && this._onCrossFrame(crossedFrameIndex); + if (null !== loopCompleteEvent && 0 === crossedFrameIndex) { + this._armature._dragonBones.bufferEvent(loopCompleteEvent); + loopCompleteEvent = null; + } + crossedFrameIndex > 0 ? crossedFrameIndex-- : crossedFrameIndex = this._frameCount - 1; + if (crossedFrameIndex === frameIndex) break; + } + } else { + if (crossedFrameIndex < 0) { + var prevFrameIndex = Math.floor(prevTime * this._frameRate); + crossedFrameIndex = this._frameIndices[timelineData.frameIndicesOffset + prevFrameIndex]; + var frameOffset = this._animationData.frameOffset + this._timelineArray[timelineData.offset + 5 + crossedFrameIndex]; + var framePosition = this._frameArray[frameOffset] / this._frameRate; + this.currentPlayTimes === prevPlayTimes && (prevTime <= framePosition ? crossedFrameIndex > 0 ? crossedFrameIndex-- : crossedFrameIndex = this._frameCount - 1 : crossedFrameIndex === frameIndex && (crossedFrameIndex = -1)); + } + while (crossedFrameIndex >= 0) { + crossedFrameIndex < this._frameCount - 1 ? crossedFrameIndex++ : crossedFrameIndex = 0; + var frameOffset = this._animationData.frameOffset + this._timelineArray[timelineData.offset + 5 + crossedFrameIndex]; + var framePosition = this._frameArray[frameOffset] / this._frameRate; + this._position <= framePosition && framePosition <= this._position + this._duration && this._onCrossFrame(crossedFrameIndex); + if (null !== loopCompleteEvent && 0 === crossedFrameIndex) { + this._armature._dragonBones.bufferEvent(loopCompleteEvent); + loopCompleteEvent = null; + } + if (crossedFrameIndex === frameIndex) break; + } + } + } + } + } else if (this._frameIndex < 0) { + this._frameIndex = 0; + if (null !== this._timelineData) { + this._frameOffset = this._animationData.frameOffset + this._timelineArray[this._timelineData.offset + 5]; + var framePosition = this._frameArray[this._frameOffset] / this._frameRate; + if (this.currentPlayTimes === prevPlayTimes) prevTime <= framePosition && this._onCrossFrame(this._frameIndex); else if (this._position <= framePosition) { + if (!isReverse && null !== loopCompleteEvent) { + this._armature._dragonBones.bufferEvent(loopCompleteEvent); + loopCompleteEvent = null; + } + this._onCrossFrame(this._frameIndex); + } + } + } + null !== loopCompleteEvent && this._armature._dragonBones.bufferEvent(loopCompleteEvent); + null !== completeEvent && this._armature._dragonBones.bufferEvent(completeEvent); + } + }; + ActionTimelineState.prototype.setCurrentTime = function(value) { + this._setCurrentTime(value); + this._frameIndex = -1; + }; + return ActionTimelineState; + })(dragonBones.TimelineState); + dragonBones.ActionTimelineState = ActionTimelineState; + var ZOrderTimelineState = (function(_super) { + __extends(ZOrderTimelineState, _super); + function ZOrderTimelineState() { + return null !== _super && _super.apply(this, arguments) || this; + } + ZOrderTimelineState.toString = function() { + return "[class dragonBones.ZOrderTimelineState]"; + }; + ZOrderTimelineState.prototype._onArriveAtFrame = function() { + if (this.playState >= 0) { + var count = this._frameArray[this._frameOffset + 1]; + count > 0 ? this._armature._sortZOrder(this._frameArray, this._frameOffset + 2) : this._armature._sortZOrder(null, 0); + } + }; + ZOrderTimelineState.prototype._onUpdateFrame = function() {}; + return ZOrderTimelineState; + })(dragonBones.TimelineState); + dragonBones.ZOrderTimelineState = ZOrderTimelineState; + var BoneAllTimelineState = (function(_super) { + __extends(BoneAllTimelineState, _super); + function BoneAllTimelineState() { + return null !== _super && _super.apply(this, arguments) || this; + } + BoneAllTimelineState.toString = function() { + return "[class dragonBones.BoneAllTimelineState]"; + }; + BoneAllTimelineState.prototype._onArriveAtFrame = function() { + _super.prototype._onArriveAtFrame.call(this); + if (null !== this._timelineData) { + var valueOffset = this._animationData.frameFloatOffset + this._frameValueOffset + 6 * this._frameIndex; + var scale = this._armature._armatureData.scale; + var frameFloatArray = this._frameFloatArray; + var current = this.bonePose.current; + var delta = this.bonePose.delta; + current.x = frameFloatArray[valueOffset++] * scale; + current.y = frameFloatArray[valueOffset++] * scale; + current.rotation = frameFloatArray[valueOffset++]; + current.skew = frameFloatArray[valueOffset++]; + current.scaleX = frameFloatArray[valueOffset++]; + current.scaleY = frameFloatArray[valueOffset++]; + if (2 === this._tweenState) { + this._frameIndex === this._frameCount - 1 && (valueOffset = this._animationData.frameFloatOffset + this._frameValueOffset); + delta.x = frameFloatArray[valueOffset++] * scale - current.x; + delta.y = frameFloatArray[valueOffset++] * scale - current.y; + delta.rotation = frameFloatArray[valueOffset++] - current.rotation; + delta.skew = frameFloatArray[valueOffset++] - current.skew; + delta.scaleX = frameFloatArray[valueOffset++] - current.scaleX; + delta.scaleY = frameFloatArray[valueOffset++] - current.scaleY; + } else { + delta.x = 0; + delta.y = 0; + delta.rotation = 0; + delta.skew = 0; + delta.scaleX = 0; + delta.scaleY = 0; + } + } else { + var current = this.bonePose.current; + var delta = this.bonePose.delta; + current.x = 0; + current.y = 0; + current.rotation = 0; + current.skew = 0; + current.scaleX = 1; + current.scaleY = 1; + delta.x = 0; + delta.y = 0; + delta.rotation = 0; + delta.skew = 0; + delta.scaleX = 0; + delta.scaleY = 0; + } + }; + BoneAllTimelineState.prototype._onUpdateFrame = function() { + _super.prototype._onUpdateFrame.call(this); + var current = this.bonePose.current; + var delta = this.bonePose.delta; + var result = this.bonePose.result; + this.bone._transformDirty = true; + 2 !== this._tweenState && (this._tweenState = 0); + result.x = current.x + delta.x * this._tweenProgress; + result.y = current.y + delta.y * this._tweenProgress; + result.rotation = current.rotation + delta.rotation * this._tweenProgress; + result.skew = current.skew + delta.skew * this._tweenProgress; + result.scaleX = current.scaleX + delta.scaleX * this._tweenProgress; + result.scaleY = current.scaleY + delta.scaleY * this._tweenProgress; + }; + BoneAllTimelineState.prototype.fadeOut = function() { + var result = this.bonePose.result; + result.rotation = dragonBones.Transform.normalizeRadian(result.rotation); + result.skew = dragonBones.Transform.normalizeRadian(result.skew); + }; + return BoneAllTimelineState; + })(dragonBones.BoneTimelineState); + dragonBones.BoneAllTimelineState = BoneAllTimelineState; + var BoneTranslateTimelineState = (function(_super) { + __extends(BoneTranslateTimelineState, _super); + function BoneTranslateTimelineState() { + return null !== _super && _super.apply(this, arguments) || this; + } + BoneTranslateTimelineState.toString = function() { + return "[class dragonBones.BoneTranslateTimelineState]"; + }; + BoneTranslateTimelineState.prototype._onArriveAtFrame = function() { + _super.prototype._onArriveAtFrame.call(this); + if (null !== this._timelineData) { + var valueOffset = this._animationData.frameFloatOffset + this._frameValueOffset + 2 * this._frameIndex; + var scale = this._armature._armatureData.scale; + var frameFloatArray = this._frameFloatArray; + var current = this.bonePose.current; + var delta = this.bonePose.delta; + current.x = frameFloatArray[valueOffset++] * scale; + current.y = frameFloatArray[valueOffset++] * scale; + if (2 === this._tweenState) { + this._frameIndex === this._frameCount - 1 && (valueOffset = this._animationData.frameFloatOffset + this._frameValueOffset); + delta.x = frameFloatArray[valueOffset++] * scale - current.x; + delta.y = frameFloatArray[valueOffset++] * scale - current.y; + } else { + delta.x = 0; + delta.y = 0; + } + } else { + var current = this.bonePose.current; + var delta = this.bonePose.delta; + current.x = 0; + current.y = 0; + delta.x = 0; + delta.y = 0; + } + }; + BoneTranslateTimelineState.prototype._onUpdateFrame = function() { + _super.prototype._onUpdateFrame.call(this); + var current = this.bonePose.current; + var delta = this.bonePose.delta; + var result = this.bonePose.result; + this.bone._transformDirty = true; + 2 !== this._tweenState && (this._tweenState = 0); + result.x = current.x + delta.x * this._tweenProgress; + result.y = current.y + delta.y * this._tweenProgress; + }; + return BoneTranslateTimelineState; + })(dragonBones.BoneTimelineState); + dragonBones.BoneTranslateTimelineState = BoneTranslateTimelineState; + var BoneRotateTimelineState = (function(_super) { + __extends(BoneRotateTimelineState, _super); + function BoneRotateTimelineState() { + return null !== _super && _super.apply(this, arguments) || this; + } + BoneRotateTimelineState.toString = function() { + return "[class dragonBones.BoneRotateTimelineState]"; + }; + BoneRotateTimelineState.prototype._onArriveAtFrame = function() { + _super.prototype._onArriveAtFrame.call(this); + if (null !== this._timelineData) { + var valueOffset = this._animationData.frameFloatOffset + this._frameValueOffset + 2 * this._frameIndex; + var frameFloatArray = this._frameFloatArray; + var current = this.bonePose.current; + var delta = this.bonePose.delta; + current.rotation = frameFloatArray[valueOffset++]; + current.skew = frameFloatArray[valueOffset++]; + if (2 === this._tweenState) { + if (this._frameIndex === this._frameCount - 1) { + valueOffset = this._animationData.frameFloatOffset + this._frameValueOffset; + delta.rotation = dragonBones.Transform.normalizeRadian(frameFloatArray[valueOffset++] - current.rotation); + } else delta.rotation = frameFloatArray[valueOffset++] - current.rotation; + delta.skew = frameFloatArray[valueOffset++] - current.skew; + } else { + delta.rotation = 0; + delta.skew = 0; + } + } else { + var current = this.bonePose.current; + var delta = this.bonePose.delta; + current.rotation = 0; + current.skew = 0; + delta.rotation = 0; + delta.skew = 0; + } + }; + BoneRotateTimelineState.prototype._onUpdateFrame = function() { + _super.prototype._onUpdateFrame.call(this); + var current = this.bonePose.current; + var delta = this.bonePose.delta; + var result = this.bonePose.result; + this.bone._transformDirty = true; + 2 !== this._tweenState && (this._tweenState = 0); + result.rotation = current.rotation + delta.rotation * this._tweenProgress; + result.skew = current.skew + delta.skew * this._tweenProgress; + }; + BoneRotateTimelineState.prototype.fadeOut = function() { + var result = this.bonePose.result; + result.rotation = dragonBones.Transform.normalizeRadian(result.rotation); + result.skew = dragonBones.Transform.normalizeRadian(result.skew); + }; + return BoneRotateTimelineState; + })(dragonBones.BoneTimelineState); + dragonBones.BoneRotateTimelineState = BoneRotateTimelineState; + var BoneScaleTimelineState = (function(_super) { + __extends(BoneScaleTimelineState, _super); + function BoneScaleTimelineState() { + return null !== _super && _super.apply(this, arguments) || this; + } + BoneScaleTimelineState.toString = function() { + return "[class dragonBones.BoneScaleTimelineState]"; + }; + BoneScaleTimelineState.prototype._onArriveAtFrame = function() { + _super.prototype._onArriveAtFrame.call(this); + if (null !== this._timelineData) { + var valueOffset = this._animationData.frameFloatOffset + this._frameValueOffset + 2 * this._frameIndex; + var frameFloatArray = this._frameFloatArray; + var current = this.bonePose.current; + var delta = this.bonePose.delta; + current.scaleX = frameFloatArray[valueOffset++]; + current.scaleY = frameFloatArray[valueOffset++]; + if (2 === this._tweenState) { + this._frameIndex === this._frameCount - 1 && (valueOffset = this._animationData.frameFloatOffset + this._frameValueOffset); + delta.scaleX = frameFloatArray[valueOffset++] - current.scaleX; + delta.scaleY = frameFloatArray[valueOffset++] - current.scaleY; + } else { + delta.scaleX = 0; + delta.scaleY = 0; + } + } else { + var current = this.bonePose.current; + var delta = this.bonePose.delta; + current.scaleX = 1; + current.scaleY = 1; + delta.scaleX = 0; + delta.scaleY = 0; + } + }; + BoneScaleTimelineState.prototype._onUpdateFrame = function() { + _super.prototype._onUpdateFrame.call(this); + var current = this.bonePose.current; + var delta = this.bonePose.delta; + var result = this.bonePose.result; + this.bone._transformDirty = true; + 2 !== this._tweenState && (this._tweenState = 0); + result.scaleX = current.scaleX + delta.scaleX * this._tweenProgress; + result.scaleY = current.scaleY + delta.scaleY * this._tweenProgress; + }; + return BoneScaleTimelineState; + })(dragonBones.BoneTimelineState); + dragonBones.BoneScaleTimelineState = BoneScaleTimelineState; + var SurfaceTimelineState = (function(_super) { + __extends(SurfaceTimelineState, _super); + function SurfaceTimelineState() { + var _this = null !== _super && _super.apply(this, arguments) || this; + _this._current = []; + _this._delta = []; + _this._result = []; + return _this; + } + SurfaceTimelineState.toString = function() { + return "[class dragonBones.SurfaceTimelineState]"; + }; + SurfaceTimelineState.prototype._onClear = function() { + _super.prototype._onClear.call(this); + this.surface = null; + this._frameFloatOffset = 0; + this._valueCount = 0; + this._deformCount = 0; + this._valueOffset = 0; + this._current.length = 0; + this._delta.length = 0; + this._result.length = 0; + }; + SurfaceTimelineState.prototype._onArriveAtFrame = function() { + _super.prototype._onArriveAtFrame.call(this); + if (null !== this._timelineData) { + var valueOffset = this._animationData.frameFloatOffset + this._frameValueOffset + this._frameIndex * this._valueCount; + var scale = this._armature._armatureData.scale; + var frameFloatArray = this._frameFloatArray; + if (2 === this._tweenState) { + var nextValueOffset = valueOffset + this._valueCount; + this._frameIndex === this._frameCount - 1 && (nextValueOffset = this._animationData.frameFloatOffset + this._frameValueOffset); + for (var i = 0; i < this._valueCount; ++i) this._delta[i] = frameFloatArray[nextValueOffset + i] * scale - (this._current[i] = frameFloatArray[valueOffset + i] * scale); + } else for (var i = 0; i < this._valueCount; ++i) this._current[i] = frameFloatArray[valueOffset + i] * scale; + } else for (var i = 0; i < this._valueCount; ++i) this._current[i] = 0; + }; + SurfaceTimelineState.prototype._onUpdateFrame = function() { + _super.prototype._onUpdateFrame.call(this); + this.surface._transformDirty = true; + 2 !== this._tweenState && (this._tweenState = 0); + for (var i = 0; i < this._valueCount; ++i) this._result[i] = this._current[i] + this._delta[i] * this._tweenProgress; + }; + SurfaceTimelineState.prototype.init = function(armature, animationState, timelineData) { + _super.prototype.init.call(this, armature, animationState, timelineData); + if (null !== this._timelineData) { + var frameIntOffset = this._animationData.frameIntOffset + this._timelineArray[this._timelineData.offset + 3]; + this._deformCount = this._frameIntArray[frameIntOffset + 1]; + this._valueCount = this._frameIntArray[frameIntOffset + 2]; + this._valueOffset = this._frameIntArray[frameIntOffset + 3]; + this._frameFloatOffset = this._frameIntArray[frameIntOffset + 4] + this._animationData.frameFloatOffset; + } else { + this._deformCount = this.surface._deformVertices.length; + this._valueCount = this._deformCount; + this._valueOffset = 0; + this._frameFloatOffset = 0; + } + this._current.length = this._valueCount; + this._delta.length = this._valueCount; + this._result.length = this._valueCount; + for (var i = 0; i < this._valueCount; ++i) this._delta[i] = 0; + }; + SurfaceTimelineState.prototype.blend = function(state) { + var blendWeight = this.surface._blendState.blendWeight; + var result = this.surface._deformVertices; + for (var i = 0; i < this._deformCount; ++i) { + var value = 0; + value = i < this._valueOffset ? this._frameFloatArray[this._frameFloatOffset + i] : i < this._valueOffset + this._valueCount ? this._result[i - this._valueOffset] : this._frameFloatArray[this._frameFloatOffset + i - this._valueCount]; + 2 === state ? result[i] += value * blendWeight : result[i] = 1 !== blendWeight ? value * blendWeight : value; + } + 0 === this._animationState._fadeState && 0 === this._animationState._subFadeState || (this.surface._transformDirty = true); + }; + return SurfaceTimelineState; + })(dragonBones.TweenTimelineState); + dragonBones.SurfaceTimelineState = SurfaceTimelineState; + var SlotDislayTimelineState = (function(_super) { + __extends(SlotDislayTimelineState, _super); + function SlotDislayTimelineState() { + return null !== _super && _super.apply(this, arguments) || this; + } + SlotDislayTimelineState.toString = function() { + return "[class dragonBones.SlotDislayTimelineState]"; + }; + SlotDislayTimelineState.prototype._onArriveAtFrame = function() { + if (this.playState >= 0) { + var displayIndex = null !== this._timelineData ? this._frameArray[this._frameOffset + 1] : this.slot._slotData.displayIndex; + this.slot.displayIndex !== displayIndex && this.slot._setDisplayIndex(displayIndex, true); + } + }; + return SlotDislayTimelineState; + })(dragonBones.SlotTimelineState); + dragonBones.SlotDislayTimelineState = SlotDislayTimelineState; + var SlotColorTimelineState = (function(_super) { + __extends(SlotColorTimelineState, _super); + function SlotColorTimelineState() { + var _this = null !== _super && _super.apply(this, arguments) || this; + _this._current = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; + _this._delta = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; + _this._result = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; + return _this; + } + SlotColorTimelineState.toString = function() { + return "[class dragonBones.SlotColorTimelineState]"; + }; + SlotColorTimelineState.prototype._onClear = function() { + _super.prototype._onClear.call(this); + this._dirty = false; + }; + SlotColorTimelineState.prototype._onArriveAtFrame = function() { + _super.prototype._onArriveAtFrame.call(this); + if (null !== this._timelineData) { + var intArray = this._dragonBonesData.intArray; + var frameIntArray = this._frameIntArray; + var valueOffset = this._animationData.frameIntOffset + this._frameValueOffset + 1 * this._frameIndex; + var colorOffset = frameIntArray[valueOffset]; + colorOffset < 0 && (colorOffset += 65536); + this._current[0] = intArray[colorOffset++]; + this._current[1] = intArray[colorOffset++]; + this._current[2] = intArray[colorOffset++]; + this._current[3] = intArray[colorOffset++]; + this._current[4] = intArray[colorOffset++]; + this._current[5] = intArray[colorOffset++]; + this._current[6] = intArray[colorOffset++]; + this._current[7] = intArray[colorOffset++]; + if (2 === this._tweenState) { + colorOffset = this._frameIndex === this._frameCount - 1 ? frameIntArray[this._animationData.frameIntOffset + this._frameValueOffset] : frameIntArray[valueOffset + 1]; + colorOffset < 0 && (colorOffset += 65536); + this._delta[0] = intArray[colorOffset++] - this._current[0]; + this._delta[1] = intArray[colorOffset++] - this._current[1]; + this._delta[2] = intArray[colorOffset++] - this._current[2]; + this._delta[3] = intArray[colorOffset++] - this._current[3]; + this._delta[4] = intArray[colorOffset++] - this._current[4]; + this._delta[5] = intArray[colorOffset++] - this._current[5]; + this._delta[6] = intArray[colorOffset++] - this._current[6]; + this._delta[7] = intArray[colorOffset++] - this._current[7]; + } + } else { + var color = this.slot._slotData.color; + this._current[0] = 100 * color.alphaMultiplier; + this._current[1] = 100 * color.redMultiplier; + this._current[2] = 100 * color.greenMultiplier; + this._current[3] = 100 * color.blueMultiplier; + this._current[4] = color.alphaOffset; + this._current[5] = color.redOffset; + this._current[6] = color.greenOffset; + this._current[7] = color.blueOffset; + } + }; + SlotColorTimelineState.prototype._onUpdateFrame = function() { + _super.prototype._onUpdateFrame.call(this); + this._dirty = true; + 2 !== this._tweenState && (this._tweenState = 0); + this._result[0] = .01 * (this._current[0] + this._delta[0] * this._tweenProgress); + this._result[1] = .01 * (this._current[1] + this._delta[1] * this._tweenProgress); + this._result[2] = .01 * (this._current[2] + this._delta[2] * this._tweenProgress); + this._result[3] = .01 * (this._current[3] + this._delta[3] * this._tweenProgress); + this._result[4] = this._current[4] + this._delta[4] * this._tweenProgress; + this._result[5] = this._current[5] + this._delta[5] * this._tweenProgress; + this._result[6] = this._current[6] + this._delta[6] * this._tweenProgress; + this._result[7] = this._current[7] + this._delta[7] * this._tweenProgress; + }; + SlotColorTimelineState.prototype.fadeOut = function() { + this._tweenState = 0; + this._dirty = false; + }; + SlotColorTimelineState.prototype.update = function(passedTime) { + _super.prototype.update.call(this, passedTime); + if (0 !== this._tweenState || this._dirty) { + var result = this.slot._colorTransform; + if (0 !== this._animationState._fadeState || 0 !== this._animationState._subFadeState) { + if (result.alphaMultiplier !== this._result[0] || result.redMultiplier !== this._result[1] || result.greenMultiplier !== this._result[2] || result.blueMultiplier !== this._result[3] || result.alphaOffset !== this._result[4] || result.redOffset !== this._result[5] || result.greenOffset !== this._result[6] || result.blueOffset !== this._result[7]) { + var fadeProgress = Math.pow(this._animationState._fadeProgress, 4); + result.alphaMultiplier += (this._result[0] - result.alphaMultiplier) * fadeProgress; + result.redMultiplier += (this._result[1] - result.redMultiplier) * fadeProgress; + result.greenMultiplier += (this._result[2] - result.greenMultiplier) * fadeProgress; + result.blueMultiplier += (this._result[3] - result.blueMultiplier) * fadeProgress; + result.alphaOffset += (this._result[4] - result.alphaOffset) * fadeProgress; + result.redOffset += (this._result[5] - result.redOffset) * fadeProgress; + result.greenOffset += (this._result[6] - result.greenOffset) * fadeProgress; + result.blueOffset += (this._result[7] - result.blueOffset) * fadeProgress; + this.slot._colorDirty = true; + } + } else if (this._dirty) { + this._dirty = false; + if (result.alphaMultiplier !== this._result[0] || result.redMultiplier !== this._result[1] || result.greenMultiplier !== this._result[2] || result.blueMultiplier !== this._result[3] || result.alphaOffset !== this._result[4] || result.redOffset !== this._result[5] || result.greenOffset !== this._result[6] || result.blueOffset !== this._result[7]) { + result.alphaMultiplier = this._result[0]; + result.redMultiplier = this._result[1]; + result.greenMultiplier = this._result[2]; + result.blueMultiplier = this._result[3]; + result.alphaOffset = this._result[4]; + result.redOffset = this._result[5]; + result.greenOffset = this._result[6]; + result.blueOffset = this._result[7]; + this.slot._colorDirty = true; + } + } + } + }; + return SlotColorTimelineState; + })(dragonBones.SlotTimelineState); + dragonBones.SlotColorTimelineState = SlotColorTimelineState; + var DeformTimelineState = (function(_super) { + __extends(DeformTimelineState, _super); + function DeformTimelineState() { + var _this = null !== _super && _super.apply(this, arguments) || this; + _this._current = []; + _this._delta = []; + _this._result = []; + return _this; + } + DeformTimelineState.toString = function() { + return "[class dragonBones.DeformTimelineState]"; + }; + DeformTimelineState.prototype._onClear = function() { + _super.prototype._onClear.call(this); + this.vertexOffset = 0; + this._dirty = false; + this._frameFloatOffset = 0; + this._valueCount = 0; + this._deformCount = 0; + this._valueOffset = 0; + this._current.length = 0; + this._delta.length = 0; + this._result.length = 0; + }; + DeformTimelineState.prototype._onArriveAtFrame = function() { + _super.prototype._onArriveAtFrame.call(this); + if (null !== this._timelineData) { + var valueOffset = this._animationData.frameFloatOffset + this._frameValueOffset + this._frameIndex * this._valueCount; + var scale = this._armature._armatureData.scale; + var frameFloatArray = this._frameFloatArray; + if (2 === this._tweenState) { + var nextValueOffset = valueOffset + this._valueCount; + this._frameIndex === this._frameCount - 1 && (nextValueOffset = this._animationData.frameFloatOffset + this._frameValueOffset); + for (var i = 0; i < this._valueCount; ++i) this._delta[i] = frameFloatArray[nextValueOffset + i] * scale - (this._current[i] = frameFloatArray[valueOffset + i] * scale); + } else for (var i = 0; i < this._valueCount; ++i) this._current[i] = frameFloatArray[valueOffset + i] * scale; + } else for (var i = 0; i < this._valueCount; ++i) this._current[i] = 0; + }; + DeformTimelineState.prototype._onUpdateFrame = function() { + _super.prototype._onUpdateFrame.call(this); + this._dirty = true; + 2 !== this._tweenState && (this._tweenState = 0); + for (var i = 0; i < this._valueCount; ++i) this._result[i] = this._current[i] + this._delta[i] * this._tweenProgress; + }; + DeformTimelineState.prototype.init = function(armature, animationState, timelineData) { + _super.prototype.init.call(this, armature, animationState, timelineData); + if (null !== this._timelineData) { + var frameIntOffset = this._animationData.frameIntOffset + this._timelineArray[this._timelineData.offset + 3]; + this.vertexOffset = this._frameIntArray[frameIntOffset + 0]; + this.vertexOffset < 0 && (this.vertexOffset += 65536); + this._deformCount = this._frameIntArray[frameIntOffset + 1]; + this._valueCount = this._frameIntArray[frameIntOffset + 2]; + this._valueOffset = this._frameIntArray[frameIntOffset + 3]; + this._frameFloatOffset = this._frameIntArray[frameIntOffset + 4] + this._animationData.frameFloatOffset; + } else { + var deformVertices = this.slot._deformVertices; + this._deformCount = null !== deformVertices ? deformVertices.vertices.length : 0; + this._valueCount = this._deformCount; + this._valueOffset = 0; + this._frameFloatOffset = 0; + } + this._current.length = this._valueCount; + this._delta.length = this._valueCount; + this._result.length = this._valueCount; + for (var i = 0; i < this._valueCount; ++i) this._delta[i] = 0; + }; + DeformTimelineState.prototype.fadeOut = function() { + this._tweenState = 0; + this._dirty = false; + }; + DeformTimelineState.prototype.update = function(passedTime) { + var deformVertices = this.slot._deformVertices; + if (null === deformVertices || null === deformVertices.verticesData || deformVertices.verticesData.offset !== this.vertexOffset) return; + _super.prototype.update.call(this, passedTime); + if (0 !== this._tweenState || this._dirty) { + var result = deformVertices.vertices; + if (0 !== this._animationState._fadeState || 0 !== this._animationState._subFadeState) { + var fadeProgress = Math.pow(this._animationState._fadeProgress, 2); + for (var i = 0; i < this._deformCount; ++i) i < this._valueOffset ? result[i] += (this._frameFloatArray[this._frameFloatOffset + i] - result[i]) * fadeProgress : i < this._valueOffset + this._valueCount ? result[i] += (this._result[i - this._valueOffset] - result[i]) * fadeProgress : result[i] += (this._frameFloatArray[this._frameFloatOffset + i - this._valueCount] - result[i]) * fadeProgress; + deformVertices.verticesDirty = true; + } else if (this._dirty) { + this._dirty = false; + for (var i = 0; i < this._deformCount; ++i) i < this._valueOffset ? result[i] = this._frameFloatArray[this._frameFloatOffset + i] : i < this._valueOffset + this._valueCount ? result[i] = this._result[i - this._valueOffset] : result[i] = this._frameFloatArray[this._frameFloatOffset + i - this._valueCount]; + deformVertices.verticesDirty = true; + } + } + }; + return DeformTimelineState; + })(dragonBones.SlotTimelineState); + dragonBones.DeformTimelineState = DeformTimelineState; + var IKConstraintTimelineState = (function(_super) { + __extends(IKConstraintTimelineState, _super); + function IKConstraintTimelineState() { + return null !== _super && _super.apply(this, arguments) || this; + } + IKConstraintTimelineState.toString = function() { + return "[class dragonBones.IKConstraintTimelineState]"; + }; + IKConstraintTimelineState.prototype._onClear = function() { + _super.prototype._onClear.call(this); + this._current = 0; + this._delta = 0; + }; + IKConstraintTimelineState.prototype._onArriveAtFrame = function() { + _super.prototype._onArriveAtFrame.call(this); + var ikConstraint = this.constraint; + if (null !== this._timelineData) { + var valueOffset = this._animationData.frameIntOffset + this._frameValueOffset + 2 * this._frameIndex; + var frameIntArray = this._frameIntArray; + var bendPositive = 0 !== frameIntArray[valueOffset++]; + this._current = .01 * frameIntArray[valueOffset++]; + if (2 === this._tweenState) { + this._frameIndex === this._frameCount - 1 && (valueOffset = this._animationData.frameIntOffset + this._frameValueOffset); + this._delta = .01 * frameIntArray[valueOffset + 1] - this._current; + } else this._delta = 0; + ikConstraint._bendPositive = bendPositive; + } else { + var ikConstraintData = ikConstraint._constraintData; + this._current = ikConstraintData.weight; + this._delta = 0; + ikConstraint._bendPositive = ikConstraintData.bendPositive; + } + ikConstraint.invalidUpdate(); + }; + IKConstraintTimelineState.prototype._onUpdateFrame = function() { + _super.prototype._onUpdateFrame.call(this); + 2 !== this._tweenState && (this._tweenState = 0); + var ikConstraint = this.constraint; + ikConstraint._weight = this._current + this._delta * this._tweenProgress; + ikConstraint.invalidUpdate(); + }; + return IKConstraintTimelineState; + })(dragonBones.ConstraintTimelineState); + dragonBones.IKConstraintTimelineState = IKConstraintTimelineState; + var AnimationTimelineState = (function(_super) { + __extends(AnimationTimelineState, _super); + function AnimationTimelineState() { + var _this = null !== _super && _super.apply(this, arguments) || this; + _this._floats = [ 0, 0, 0, 0, 0, 0 ]; + return _this; + } + AnimationTimelineState.toString = function() { + return "[class dragonBones.AnimationTimelineState]"; + }; + AnimationTimelineState.prototype._onClear = function() { + _super.prototype._onClear.call(this); + this.animationState = null; + }; + AnimationTimelineState.prototype._onArriveAtFrame = function() { + _super.prototype._onArriveAtFrame.call(this); + if (null === this._timelineData) return; + var valueOffset = this._animationData.frameIntOffset + this._frameValueOffset + 2 * this._frameIndex; + var frameRateR = 1 / this.animationState._animationData.parent.frameRate; + var frameIntArray = this._frameIntArray; + this._floats[0] = frameIntArray[valueOffset++] * frameRateR; + this._floats[3] = .01 * frameIntArray[valueOffset++]; + if (2 === this._tweenState) { + this._frameIndex === this._frameCount - 1 && (valueOffset = this._animationData.frameIntOffset + this._frameValueOffset); + this._floats[1] = frameIntArray[valueOffset++] * frameRateR - this._floats[0]; + this._floats[4] = .01 * frameIntArray[valueOffset++] - this._floats[3]; + } else { + this._floats[1] = 0; + this._floats[4] = 0; + } + }; + AnimationTimelineState.prototype._onUpdateFrame = function() { + _super.prototype._onUpdateFrame.call(this); + 2 !== this._tweenState && (this._tweenState = 0); + this._floats[0] >= 0 && (this._floats[2] = this._floats[0] + this._floats[1] * this._tweenProgress); + this._floats[5] = this._floats[3] + this._floats[4] * this._tweenProgress; + }; + AnimationTimelineState.prototype.blend = function(state) { + var animationState = this.animationState; + var blendWeight = animationState._blendState.blendWeight; + if (2 === state) { + animationState.weight += this._floats[5] * blendWeight; + animationState.currentTime += this._floats[2] * blendWeight; + } else { + animationState.weight = this._floats[5] * blendWeight; + animationState.currentTime = this._floats[2] * blendWeight; + } + }; + return AnimationTimelineState; + })(dragonBones.TweenTimelineState); + dragonBones.AnimationTimelineState = AnimationTimelineState; + })(dragonBones || (dragonBones = {})); + var dragonBones; + (function(dragonBones) { + var EventObject = (function(_super) { + __extends(EventObject, _super); + function EventObject() { + return null !== _super && _super.apply(this, arguments) || this; + } + EventObject.actionDataToInstance = function(data, instance, armature) { + 0 === data.type ? instance.type = EventObject.FRAME_EVENT : instance.type = 10 === data.type ? EventObject.FRAME_EVENT : EventObject.SOUND_EVENT; + instance.name = data.name; + instance.armature = armature; + instance.actionData = data; + instance.data = data.data; + null !== data.bone && (instance.bone = armature.getBone(data.bone.name)); + null !== data.slot && (instance.slot = armature.getSlot(data.slot.name)); + }; + EventObject.toString = function() { + return "[class dragonBones.EventObject]"; + }; + EventObject.prototype._onClear = function() { + this.time = 0; + this.type = ""; + this.name = ""; + this.armature = null; + this.bone = null; + this.slot = null; + this.animationState = null; + this.actionData = null; + this.data = null; + }; + EventObject.START = "start"; + EventObject.LOOP_COMPLETE = "loopComplete"; + EventObject.COMPLETE = "complete"; + EventObject.FADE_IN = "fadeIn"; + EventObject.FADE_IN_COMPLETE = "fadeInComplete"; + EventObject.FADE_OUT = "fadeOut"; + EventObject.FADE_OUT_COMPLETE = "fadeOutComplete"; + EventObject.FRAME_EVENT = "frameEvent"; + EventObject.SOUND_EVENT = "soundEvent"; + return EventObject; + })(dragonBones.BaseObject); + dragonBones.EventObject = EventObject; + })(dragonBones || (dragonBones = {})); + var dragonBones; + (function(dragonBones) { + var DataParser = (function() { + function DataParser() {} + DataParser._getArmatureType = function(value) { + switch (value.toLowerCase()) { + case "stage": + return 2; + + case "armature": + return 0; + + case "movieclip": + return 1; + + default: + return 0; + } + }; + DataParser._getBoneType = function(value) { + switch (value.toLowerCase()) { + case "bone": + return 0; + + case "surface": + return 1; + + default: + return 0; + } + }; + DataParser._getDisplayType = function(value) { + switch (value.toLowerCase()) { + case "image": + return 0; + + case "mesh": + return 2; + + case "armature": + return 1; + + case "boundingbox": + return 3; + + case "path": + return 4; + + default: + return 0; + } + }; + DataParser._getBoundingBoxType = function(value) { + switch (value.toLowerCase()) { + case "rectangle": + return 0; + + case "ellipse": + return 1; + + case "polygon": + return 2; + + default: + return 0; + } + }; + DataParser._getActionType = function(value) { + switch (value.toLowerCase()) { + case "play": + return 0; + + case "frame": + return 10; + + case "sound": + return 11; + + default: + return 0; + } + }; + DataParser._getBlendMode = function(value) { + switch (value.toLowerCase()) { + case "normal": + return 0; + + case "add": + return 1; + + case "alpha": + return 2; + + case "darken": + return 3; + + case "difference": + return 4; + + case "erase": + return 5; + + case "hardlight": + return 6; + + case "invert": + return 7; + + case "layer": + return 8; + + case "lighten": + return 9; + + case "multiply": + return 10; + + case "overlay": + return 11; + + case "screen": + return 12; + + case "subtract": + return 13; + + default: + return 0; + } + }; + DataParser._getPositionMode = function(value) { + switch (value.toLocaleLowerCase()) { + case "percent": + return 1; + + case "fixed": + return 0; + + default: + return 1; + } + }; + DataParser._getSpacingMode = function(value) { + switch (value.toLocaleLowerCase()) { + case "length": + return 0; + + case "percent": + return 2; + + case "fixed": + return 1; + + default: + return 0; + } + }; + DataParser._getRotateMode = function(value) { + switch (value.toLocaleLowerCase()) { + case "tangent": + return 0; + + case "chain": + return 1; + + case "chainscale": + return 2; + + default: + return 0; + } + }; + DataParser.parseDragonBonesData = function(rawData) { + console.warn("Deprecated."); + return rawData instanceof ArrayBuffer ? dragonBones.BinaryDataParser.getInstance().parseDragonBonesData(rawData) : dragonBones.ObjectDataParser.getInstance().parseDragonBonesData(rawData); + }; + DataParser.parseTextureAtlasData = function(rawData, scale) { + void 0 === scale && (scale = 1); + console.warn("\u5df2\u5e9f\u5f03"); + var textureAtlasData = {}; + var subTextureList = rawData[DataParser.SUB_TEXTURE]; + for (var i = 0, len = subTextureList.length; i < len; i++) { + var subTextureObject = subTextureList[i]; + var subTextureName = subTextureObject[DataParser.NAME]; + var subTextureRegion = new dragonBones.Rectangle(); + var subTextureFrame = null; + subTextureRegion.x = subTextureObject[DataParser.X] / scale; + subTextureRegion.y = subTextureObject[DataParser.Y] / scale; + subTextureRegion.width = subTextureObject[DataParser.WIDTH] / scale; + subTextureRegion.height = subTextureObject[DataParser.HEIGHT] / scale; + if (DataParser.FRAME_WIDTH in subTextureObject) { + subTextureFrame = new dragonBones.Rectangle(); + subTextureFrame.x = subTextureObject[DataParser.FRAME_X] / scale; + subTextureFrame.y = subTextureObject[DataParser.FRAME_Y] / scale; + subTextureFrame.width = subTextureObject[DataParser.FRAME_WIDTH] / scale; + subTextureFrame.height = subTextureObject[DataParser.FRAME_HEIGHT] / scale; + } + textureAtlasData[subTextureName] = { + region: subTextureRegion, + frame: subTextureFrame, + rotated: false + }; + } + return textureAtlasData; + }; + DataParser.DATA_VERSION_2_3 = "2.3"; + DataParser.DATA_VERSION_3_0 = "3.0"; + DataParser.DATA_VERSION_4_0 = "4.0"; + DataParser.DATA_VERSION_4_5 = "4.5"; + DataParser.DATA_VERSION_5_0 = "5.0"; + DataParser.DATA_VERSION_5_5 = "5.5"; + DataParser.DATA_VERSION = DataParser.DATA_VERSION_5_5; + DataParser.DATA_VERSIONS = [ DataParser.DATA_VERSION_4_0, DataParser.DATA_VERSION_4_5, DataParser.DATA_VERSION_5_0, DataParser.DATA_VERSION_5_5 ]; + DataParser.TEXTURE_ATLAS = "textureAtlas"; + DataParser.SUB_TEXTURE = "SubTexture"; + DataParser.FORMAT = "format"; + DataParser.IMAGE_PATH = "imagePath"; + DataParser.WIDTH = "width"; + DataParser.HEIGHT = "height"; + DataParser.ROTATED = "rotated"; + DataParser.FRAME_X = "frameX"; + DataParser.FRAME_Y = "frameY"; + DataParser.FRAME_WIDTH = "frameWidth"; + DataParser.FRAME_HEIGHT = "frameHeight"; + DataParser.DRADON_BONES = "dragonBones"; + DataParser.USER_DATA = "userData"; + DataParser.ARMATURE = "armature"; + DataParser.BONE = "bone"; + DataParser.SURFACE = "surface"; + DataParser.SLOT = "slot"; + DataParser.CONSTRAINT = "constraint"; + DataParser.IK = "ik"; + DataParser.PATH_CONSTRAINT = "path"; + DataParser.SKIN = "skin"; + DataParser.DISPLAY = "display"; + DataParser.ANIMATION = "animation"; + DataParser.Z_ORDER = "zOrder"; + DataParser.FFD = "ffd"; + DataParser.FRAME = "frame"; + DataParser.TRANSLATE_FRAME = "translateFrame"; + DataParser.ROTATE_FRAME = "rotateFrame"; + DataParser.SCALE_FRAME = "scaleFrame"; + DataParser.DISPLAY_FRAME = "displayFrame"; + DataParser.COLOR_FRAME = "colorFrame"; + DataParser.DEFAULT_ACTIONS = "defaultActions"; + DataParser.ACTIONS = "actions"; + DataParser.EVENTS = "events"; + DataParser.INTS = "ints"; + DataParser.FLOATS = "floats"; + DataParser.STRINGS = "strings"; + DataParser.CANVAS = "canvas"; + DataParser.TRANSFORM = "transform"; + DataParser.PIVOT = "pivot"; + DataParser.AABB = "aabb"; + DataParser.COLOR = "color"; + DataParser.VERSION = "version"; + DataParser.COMPATIBLE_VERSION = "compatibleVersion"; + DataParser.FRAME_RATE = "frameRate"; + DataParser.TYPE = "type"; + DataParser.SUB_TYPE = "subType"; + DataParser.NAME = "name"; + DataParser.PARENT = "parent"; + DataParser.TARGET = "target"; + DataParser.STAGE = "stage"; + DataParser.SHARE = "share"; + DataParser.PATH = "path"; + DataParser.LENGTH = "length"; + DataParser.DISPLAY_INDEX = "displayIndex"; + DataParser.BLEND_MODE = "blendMode"; + DataParser.INHERIT_TRANSLATION = "inheritTranslation"; + DataParser.INHERIT_ROTATION = "inheritRotation"; + DataParser.INHERIT_SCALE = "inheritScale"; + DataParser.INHERIT_REFLECTION = "inheritReflection"; + DataParser.INHERIT_ANIMATION = "inheritAnimation"; + DataParser.INHERIT_DEFORM = "inheritDeform"; + DataParser.SEGMENT_X = "segmentX"; + DataParser.SEGMENT_Y = "segmentY"; + DataParser.BEND_POSITIVE = "bendPositive"; + DataParser.CHAIN = "chain"; + DataParser.WEIGHT = "weight"; + DataParser.FADE_IN_TIME = "fadeInTime"; + DataParser.PLAY_TIMES = "playTimes"; + DataParser.SCALE = "scale"; + DataParser.OFFSET = "offset"; + DataParser.POSITION = "position"; + DataParser.DURATION = "duration"; + DataParser.TWEEN_EASING = "tweenEasing"; + DataParser.TWEEN_ROTATE = "tweenRotate"; + DataParser.TWEEN_SCALE = "tweenScale"; + DataParser.CLOCK_WISE = "clockwise"; + DataParser.CURVE = "curve"; + DataParser.SOUND = "sound"; + DataParser.EVENT = "event"; + DataParser.ACTION = "action"; + DataParser.X = "x"; + DataParser.Y = "y"; + DataParser.SKEW_X = "skX"; + DataParser.SKEW_Y = "skY"; + DataParser.SCALE_X = "scX"; + DataParser.SCALE_Y = "scY"; + DataParser.VALUE = "value"; + DataParser.ROTATE = "rotate"; + DataParser.SKEW = "skew"; + DataParser.ALPHA_OFFSET = "aO"; + DataParser.RED_OFFSET = "rO"; + DataParser.GREEN_OFFSET = "gO"; + DataParser.BLUE_OFFSET = "bO"; + DataParser.ALPHA_MULTIPLIER = "aM"; + DataParser.RED_MULTIPLIER = "rM"; + DataParser.GREEN_MULTIPLIER = "gM"; + DataParser.BLUE_MULTIPLIER = "bM"; + DataParser.UVS = "uvs"; + DataParser.VERTICES = "vertices"; + DataParser.TRIANGLES = "triangles"; + DataParser.WEIGHTS = "weights"; + DataParser.SLOT_POSE = "slotPose"; + DataParser.BONE_POSE = "bonePose"; + DataParser.GLUE_WEIGHTS = "glueWeights"; + DataParser.GLUE_MESHES = "glueMeshes"; + DataParser.BONES = "bones"; + DataParser.POSITION_MODE = "positionMode"; + DataParser.SPACING_MODE = "spacingMode"; + DataParser.ROTATE_MODE = "rotateMode"; + DataParser.SPACING = "spacing"; + DataParser.ROTATE_OFFSET = "rotateOffset"; + DataParser.ROTATE_MIX = "rotateMix"; + DataParser.TRANSLATE_MIX = "translateMix"; + DataParser.TARGET_DISPLAY = "targetDisplay"; + DataParser.CLOSED = "closed"; + DataParser.CONSTANT_SPEED = "constantSpeed"; + DataParser.VERTEX_COUNT = "vertexCount"; + DataParser.LENGTHS = "lengths"; + DataParser.GOTO_AND_PLAY = "gotoAndPlay"; + DataParser.DEFAULT_NAME = "default"; + return DataParser; + })(); + dragonBones.DataParser = DataParser; + })(dragonBones || (dragonBones = {})); + var dragonBones; + (function(dragonBones) { + var ObjectDataParser = (function(_super) { + __extends(ObjectDataParser, _super); + function ObjectDataParser() { + var _this = null !== _super && _super.apply(this, arguments) || this; + _this._rawTextureAtlasIndex = 0; + _this._rawBones = []; + _this._data = null; + _this._armature = null; + _this._bone = null; + _this._surface = null; + _this._slot = null; + _this._skin = null; + _this._mesh = null; + _this._animation = null; + _this._timeline = null; + _this._rawTextureAtlases = null; + _this._defaultColorOffset = -1; + _this._prevClockwise = 0; + _this._prevRotation = 0; + _this._helpMatrixA = new dragonBones.Matrix(); + _this._helpMatrixB = new dragonBones.Matrix(); + _this._helpTransform = new dragonBones.Transform(); + _this._helpColorTransform = new dragonBones.ColorTransform(); + _this._helpPoint = new dragonBones.Point(); + _this._helpArray = []; + _this._intArray = []; + _this._floatArray = []; + _this._frameIntArray = []; + _this._frameFloatArray = []; + _this._frameArray = []; + _this._timelineArray = []; + _this._cacheRawMeshes = []; + _this._cacheMeshes = []; + _this._actionFrames = []; + _this._weightSlotPose = {}; + _this._weightBonePoses = {}; + _this._cacheBones = {}; + _this._slotChildActions = {}; + return _this; + } + ObjectDataParser._getBoolean = function(rawData, key, defaultValue) { + if (key in rawData) { + var value = rawData[key]; + var type = typeof value; + if ("boolean" === type) return value; + if ("string" !== type) return !!value; + switch (value) { + case "0": + case "NaN": + case "": + case "false": + case "null": + case "undefined": + return false; + + default: + return true; + } + } + return defaultValue; + }; + ObjectDataParser._getNumber = function(rawData, key, defaultValue) { + if (key in rawData) { + var value = rawData[key]; + if (null === value || "NaN" === value) return defaultValue; + return +value || 0; + } + return defaultValue; + }; + ObjectDataParser._getString = function(rawData, key, defaultValue) { + if (key in rawData) { + var value = rawData[key]; + var type = typeof value; + if ("string" === type) { + if (dragonBones.DragonBones.webAssembly) for (var i = 0, l = value.length; i < l; ++i) if (value.charCodeAt(i) > 255) return encodeURI(value); + return value; + } + return String(value); + } + return defaultValue; + }; + ObjectDataParser.prototype._getCurvePoint = function(x1, y1, x2, y2, x3, y3, x4, y4, t, result) { + var l_t = 1 - t; + var powA = l_t * l_t; + var powB = t * t; + var kA = l_t * powA; + var kB = 3 * t * powA; + var kC = 3 * l_t * powB; + var kD = t * powB; + result.x = kA * x1 + kB * x2 + kC * x3 + kD * x4; + result.y = kA * y1 + kB * y2 + kC * y3 + kD * y4; + }; + ObjectDataParser.prototype._samplingEasingCurve = function(curve, samples) { + var curveCount = curve.length; + var stepIndex = -2; + for (var i = 0, l = samples.length; i < l; ++i) { + var t = (i + 1) / (l + 1); + while ((stepIndex + 6 < curveCount ? curve[stepIndex + 6] : 1) < t) stepIndex += 6; + var isInCurve = stepIndex >= 0 && stepIndex + 6 < curveCount; + var x1 = isInCurve ? curve[stepIndex] : 0; + var y1 = isInCurve ? curve[stepIndex + 1] : 0; + var x2 = curve[stepIndex + 2]; + var y2 = curve[stepIndex + 3]; + var x3 = curve[stepIndex + 4]; + var y3 = curve[stepIndex + 5]; + var x4 = isInCurve ? curve[stepIndex + 6] : 1; + var y4 = isInCurve ? curve[stepIndex + 7] : 1; + var lower = 0; + var higher = 1; + while (higher - lower > 1e-4) { + var percentage = .5 * (higher + lower); + this._getCurvePoint(x1, y1, x2, y2, x3, y3, x4, y4, percentage, this._helpPoint); + t - this._helpPoint.x > 0 ? lower = percentage : higher = percentage; + } + samples[i] = this._helpPoint.y; + } + }; + ObjectDataParser.prototype._parseActionDataInFrame = function(rawData, frameStart, bone, slot) { + dragonBones.DataParser.EVENT in rawData && this._mergeActionFrame(rawData[dragonBones.DataParser.EVENT], frameStart, 10, bone, slot); + dragonBones.DataParser.SOUND in rawData && this._mergeActionFrame(rawData[dragonBones.DataParser.SOUND], frameStart, 11, bone, slot); + dragonBones.DataParser.ACTION in rawData && this._mergeActionFrame(rawData[dragonBones.DataParser.ACTION], frameStart, 0, bone, slot); + dragonBones.DataParser.EVENTS in rawData && this._mergeActionFrame(rawData[dragonBones.DataParser.EVENTS], frameStart, 10, bone, slot); + dragonBones.DataParser.ACTIONS in rawData && this._mergeActionFrame(rawData[dragonBones.DataParser.ACTIONS], frameStart, 0, bone, slot); + }; + ObjectDataParser.prototype._mergeActionFrame = function(rawData, frameStart, type, bone, slot) { + var actionOffset = dragonBones.DragonBones.webAssembly ? this._armature.actions.size() : this._armature.actions.length; + var actions = this._parseActionData(rawData, type, bone, slot); + var frameIndex = 0; + var frame = null; + for (var _i = 0, actions_2 = actions; _i < actions_2.length; _i++) { + var action = actions_2[_i]; + this._armature.addAction(action, false); + } + if (0 === this._actionFrames.length) { + frame = new ActionFrame(); + frame.frameStart = 0; + this._actionFrames.push(frame); + frame = null; + } + for (var _a = 0, _b = this._actionFrames; _a < _b.length; _a++) { + var eachFrame = _b[_a]; + if (eachFrame.frameStart === frameStart) { + frame = eachFrame; + break; + } + if (eachFrame.frameStart > frameStart) break; + frameIndex++; + } + if (null === frame) { + frame = new ActionFrame(); + frame.frameStart = frameStart; + this._actionFrames.splice(frameIndex + 1, 0, frame); + } + for (var i = 0; i < actions.length; ++i) frame.actions.push(actionOffset + i); + }; + ObjectDataParser.prototype._parseArmature = function(rawData, scale) { + var armature = dragonBones.BaseObject.borrowObject(dragonBones.ArmatureData); + armature.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); + armature.frameRate = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.FRAME_RATE, this._data.frameRate); + armature.scale = scale; + dragonBones.DataParser.TYPE in rawData && "string" === typeof rawData[dragonBones.DataParser.TYPE] ? armature.type = dragonBones.DataParser._getArmatureType(rawData[dragonBones.DataParser.TYPE]) : armature.type = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.TYPE, 0); + 0 === armature.frameRate && (armature.frameRate = 24); + this._armature = armature; + if (dragonBones.DataParser.CANVAS in rawData) { + var rawCanvas = rawData[dragonBones.DataParser.CANVAS]; + var canvas = dragonBones.BaseObject.borrowObject(dragonBones.CanvasData); + dragonBones.DataParser.COLOR in rawCanvas ? canvas.hasBackground = true : canvas.hasBackground = false; + canvas.color = ObjectDataParser._getNumber(rawCanvas, dragonBones.DataParser.COLOR, 0); + canvas.x = ObjectDataParser._getNumber(rawCanvas, dragonBones.DataParser.X, 0) * armature.scale; + canvas.y = ObjectDataParser._getNumber(rawCanvas, dragonBones.DataParser.Y, 0) * armature.scale; + canvas.width = ObjectDataParser._getNumber(rawCanvas, dragonBones.DataParser.WIDTH, 0) * armature.scale; + canvas.height = ObjectDataParser._getNumber(rawCanvas, dragonBones.DataParser.HEIGHT, 0) * armature.scale; + armature.canvas = canvas; + } + if (dragonBones.DataParser.AABB in rawData) { + var rawAABB = rawData[dragonBones.DataParser.AABB]; + armature.aabb.x = ObjectDataParser._getNumber(rawAABB, dragonBones.DataParser.X, 0) * armature.scale; + armature.aabb.y = ObjectDataParser._getNumber(rawAABB, dragonBones.DataParser.Y, 0) * armature.scale; + armature.aabb.width = ObjectDataParser._getNumber(rawAABB, dragonBones.DataParser.WIDTH, 0) * armature.scale; + armature.aabb.height = ObjectDataParser._getNumber(rawAABB, dragonBones.DataParser.HEIGHT, 0) * armature.scale; + } + if (dragonBones.DataParser.BONE in rawData) { + var rawBones = rawData[dragonBones.DataParser.BONE]; + for (var _i = 0, rawBones_1 = rawBones; _i < rawBones_1.length; _i++) { + var rawBone = rawBones_1[_i]; + var parentName = ObjectDataParser._getString(rawBone, dragonBones.DataParser.PARENT, ""); + var bone = this._parseBone(rawBone); + if (parentName.length > 0) { + var parent_1 = armature.getBone(parentName); + if (null !== parent_1) bone.parent = parent_1; else { + parentName in this._cacheBones || (this._cacheBones[parentName] = []); + this._cacheBones[parentName].push(bone); + } + } + if (bone.name in this._cacheBones) { + for (var _a = 0, _b = this._cacheBones[bone.name]; _a < _b.length; _a++) { + var child = _b[_a]; + child.parent = bone; + } + delete this._cacheBones[bone.name]; + } + armature.addBone(bone); + this._rawBones.push(bone); + } + } + if (dragonBones.DataParser.IK in rawData) { + var rawIKS = rawData[dragonBones.DataParser.IK]; + for (var _c = 0, rawIKS_1 = rawIKS; _c < rawIKS_1.length; _c++) { + var rawIK = rawIKS_1[_c]; + var constraint = this._parseIKConstraint(rawIK); + constraint && armature.addConstraint(constraint); + } + } + armature.sortBones(); + if (dragonBones.DataParser.SLOT in rawData) { + var zOrder = 0; + var rawSlots = rawData[dragonBones.DataParser.SLOT]; + for (var _d = 0, rawSlots_1 = rawSlots; _d < rawSlots_1.length; _d++) { + var rawSlot = rawSlots_1[_d]; + armature.addSlot(this._parseSlot(rawSlot, zOrder++)); + } + } + if (dragonBones.DataParser.SKIN in rawData) { + var rawSkins = rawData[dragonBones.DataParser.SKIN]; + for (var _e = 0, rawSkins_1 = rawSkins; _e < rawSkins_1.length; _e++) { + var rawSkin = rawSkins_1[_e]; + armature.addSkin(this._parseSkin(rawSkin)); + } + } + if (dragonBones.DataParser.PATH_CONSTRAINT in rawData) { + var rawPaths = rawData[dragonBones.DataParser.PATH_CONSTRAINT]; + for (var _f = 0, rawPaths_1 = rawPaths; _f < rawPaths_1.length; _f++) { + var rawPath = rawPaths_1[_f]; + var constraint = this._parsePathConstraint(rawPath); + constraint && armature.addConstraint(constraint); + } + } + for (var i = 0, l = this._cacheRawMeshes.length; i < l; ++i) { + var rawMeshData = this._cacheRawMeshes[i]; + if (!(dragonBones.DataParser.GLUE_WEIGHTS in rawMeshData) || !(dragonBones.DataParser.GLUE_MESHES in rawMeshData)) continue; + this._parseMeshGlue(rawMeshData, this._cacheMeshes[i]); + } + for (var i = 0, l = this._cacheRawMeshes.length; i < l; ++i) { + var rawData_1 = this._cacheRawMeshes[i]; + var shareName = ObjectDataParser._getString(rawData_1, dragonBones.DataParser.SHARE, ""); + if (0 === shareName.length) continue; + var skinName = ObjectDataParser._getString(rawData_1, dragonBones.DataParser.SKIN, dragonBones.DataParser.DEFAULT_NAME); + 0 === skinName.length && (skinName = dragonBones.DataParser.DEFAULT_NAME); + var shareMesh = armature.getMesh(skinName, "", shareName); + if (null === shareMesh) continue; + var mesh = this._cacheMeshes[i]; + mesh.vertices.shareFrom(shareMesh.vertices); + } + if (dragonBones.DataParser.ANIMATION in rawData) { + var rawAnimations = rawData[dragonBones.DataParser.ANIMATION]; + for (var _g = 0, rawAnimations_1 = rawAnimations; _g < rawAnimations_1.length; _g++) { + var rawAnimation = rawAnimations_1[_g]; + var animation = this._parseAnimation(rawAnimation); + armature.addAnimation(animation); + } + } + if (dragonBones.DataParser.DEFAULT_ACTIONS in rawData) { + var actions = this._parseActionData(rawData[dragonBones.DataParser.DEFAULT_ACTIONS], 0, null, null); + for (var _h = 0, actions_3 = actions; _h < actions_3.length; _h++) { + var action = actions_3[_h]; + armature.addAction(action, true); + if (0 === action.type) { + var animation = armature.getAnimation(action.name); + null !== animation && (armature.defaultAnimation = animation); + } + } + } + if (dragonBones.DataParser.ACTIONS in rawData) { + var actions = this._parseActionData(rawData[dragonBones.DataParser.ACTIONS], 0, null, null); + for (var _j = 0, actions_4 = actions; _j < actions_4.length; _j++) { + var action = actions_4[_j]; + armature.addAction(action, false); + } + } + this._rawBones.length = 0; + this._cacheRawMeshes.length = 0; + this._cacheMeshes.length = 0; + this._armature = null; + for (var k in this._weightSlotPose) delete this._weightSlotPose[k]; + for (var k in this._weightBonePoses) delete this._weightBonePoses[k]; + for (var k in this._cacheBones) delete this._cacheBones[k]; + for (var k in this._slotChildActions) delete this._slotChildActions[k]; + return armature; + }; + ObjectDataParser.prototype._parseBone = function(rawData) { + var type = 0; + var scale = this._armature.scale; + type = dragonBones.DataParser.TYPE in rawData && "string" === typeof rawData[dragonBones.DataParser.TYPE] ? dragonBones.DataParser._getBoneType(rawData[dragonBones.DataParser.TYPE]) : ObjectDataParser._getNumber(rawData, dragonBones.DataParser.TYPE, 0); + if (0 === type) { + var bone = dragonBones.BaseObject.borrowObject(dragonBones.BoneData); + bone.inheritTranslation = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.INHERIT_TRANSLATION, true); + bone.inheritRotation = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.INHERIT_ROTATION, true); + bone.inheritScale = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.INHERIT_SCALE, true); + bone.inheritReflection = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.INHERIT_REFLECTION, true); + bone.length = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.LENGTH, 0) * scale; + bone.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); + dragonBones.DataParser.TRANSFORM in rawData && this._parseTransform(rawData[dragonBones.DataParser.TRANSFORM], bone.transform, scale); + return bone; + } + var surface = dragonBones.BaseObject.borrowObject(dragonBones.SurfaceData); + surface.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); + surface.segmentX = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SEGMENT_X, 0); + surface.segmentY = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SEGMENT_Y, 0); + surface.vertices.length = (surface.segmentX + 1) * (surface.segmentY + 1) * 2; + if (dragonBones.DataParser.VERTICES in rawData) { + var rawVertices = rawData[dragonBones.DataParser.VERTICES]; + for (var i = 0, l = surface.vertices.length; i < l; ++i) i < rawVertices.length ? surface.vertices[i] = rawVertices[i] * scale : surface.vertices[i] = 0; + } + return surface; + }; + ObjectDataParser.prototype._parseIKConstraint = function(rawData) { + var bone = this._armature.getBone(ObjectDataParser._getString(rawData, dragonBones.DataParser.BONE, "")); + if (null === bone) return null; + var target = this._armature.getBone(ObjectDataParser._getString(rawData, dragonBones.DataParser.TARGET, "")); + if (null === target) return null; + var constraint = dragonBones.BaseObject.borrowObject(dragonBones.IKConstraintData); + constraint.scaleEnabled = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.SCALE, false); + constraint.bendPositive = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.BEND_POSITIVE, true); + constraint.weight = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.WEIGHT, 1); + constraint.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); + constraint.type = 0; + constraint.target = target; + var chain = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.CHAIN, 0); + if (chain > 0 && null !== bone.parent) { + constraint.root = bone.parent; + constraint.bone = bone; + } else { + constraint.root = bone; + constraint.bone = null; + } + return constraint; + }; + ObjectDataParser.prototype._parsePathConstraint = function(rawData) { + var target = this._armature.getSlot(ObjectDataParser._getString(rawData, dragonBones.DataParser.TARGET, "")); + if (null === target) return null; + var defaultSkin = this._armature.defaultSkin; + if (null === defaultSkin) return null; + var targetDisplay = defaultSkin.getDisplay(target.name, ObjectDataParser._getString(rawData, dragonBones.DataParser.TARGET_DISPLAY, target.name)); + if (null === targetDisplay || !(targetDisplay instanceof dragonBones.PathDisplayData)) return null; + var bones = rawData[dragonBones.DataParser.BONES]; + if (null === bones || 0 === bones.length) return null; + var constraint = dragonBones.BaseObject.borrowObject(dragonBones.PathConstraintData); + constraint.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); + constraint.type = 1; + constraint.pathSlot = target; + constraint.pathDisplayData = targetDisplay; + constraint.target = target.parent; + constraint.positionMode = dragonBones.DataParser._getPositionMode(ObjectDataParser._getString(rawData, dragonBones.DataParser.POSITION_MODE, "")); + constraint.spacingMode = dragonBones.DataParser._getSpacingMode(ObjectDataParser._getString(rawData, dragonBones.DataParser.SPACING_MODE, "")); + constraint.rotateMode = dragonBones.DataParser._getRotateMode(ObjectDataParser._getString(rawData, dragonBones.DataParser.ROTATE_MODE, "")); + constraint.position = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.POSITION, 0); + constraint.spacing = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SPACING, 0); + constraint.rotateOffset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ROTATE_OFFSET, 0); + constraint.rotateMix = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ROTATE_MIX, 1); + constraint.translateMix = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.TRANSLATE_MIX, 1); + for (var _i = 0, bones_3 = bones; _i < bones_3.length; _i++) { + var boneName = bones_3[_i]; + var bone = this._armature.getBone(boneName); + if (null !== bone) { + constraint.AddBone(bone); + null === constraint.root && (constraint.root = bone); + } + } + return constraint; + }; + ObjectDataParser.prototype._parseSlot = function(rawData, zOrder) { + var slot = dragonBones.BaseObject.borrowObject(dragonBones.SlotData); + slot.displayIndex = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.DISPLAY_INDEX, 0); + slot.zOrder = zOrder; + slot.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); + slot.parent = this._armature.getBone(ObjectDataParser._getString(rawData, dragonBones.DataParser.PARENT, "")); + dragonBones.DataParser.BLEND_MODE in rawData && "string" === typeof rawData[dragonBones.DataParser.BLEND_MODE] ? slot.blendMode = dragonBones.DataParser._getBlendMode(rawData[dragonBones.DataParser.BLEND_MODE]) : slot.blendMode = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.BLEND_MODE, 0); + if (dragonBones.DataParser.COLOR in rawData) { + slot.color = dragonBones.SlotData.createColor(); + this._parseColorTransform(rawData[dragonBones.DataParser.COLOR], slot.color); + } else slot.color = dragonBones.SlotData.DEFAULT_COLOR; + dragonBones.DataParser.ACTIONS in rawData && (this._slotChildActions[slot.name] = this._parseActionData(rawData[dragonBones.DataParser.ACTIONS], 0, null, null)); + return slot; + }; + ObjectDataParser.prototype._parseSkin = function(rawData) { + var skin = dragonBones.BaseObject.borrowObject(dragonBones.SkinData); + skin.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, dragonBones.DataParser.DEFAULT_NAME); + 0 === skin.name.length && (skin.name = dragonBones.DataParser.DEFAULT_NAME); + if (dragonBones.DataParser.SLOT in rawData) { + var rawSlots = rawData[dragonBones.DataParser.SLOT]; + this._skin = skin; + for (var _i = 0, rawSlots_2 = rawSlots; _i < rawSlots_2.length; _i++) { + var rawSlot = rawSlots_2[_i]; + var slotName = ObjectDataParser._getString(rawSlot, dragonBones.DataParser.NAME, ""); + var slot = this._armature.getSlot(slotName); + if (null !== slot) { + this._slot = slot; + if (dragonBones.DataParser.DISPLAY in rawSlot) { + var rawDisplays = rawSlot[dragonBones.DataParser.DISPLAY]; + for (var _a = 0, rawDisplays_1 = rawDisplays; _a < rawDisplays_1.length; _a++) { + var rawDisplay = rawDisplays_1[_a]; + rawDisplay ? skin.addDisplay(slotName, this._parseDisplay(rawDisplay)) : skin.addDisplay(slotName, null); + } + } + this._slot = null; + } + } + this._skin = null; + } + return skin; + }; + ObjectDataParser.prototype._parseDisplay = function(rawData) { + var name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); + var path = ObjectDataParser._getString(rawData, dragonBones.DataParser.PATH, ""); + var type = 0; + var display = null; + type = dragonBones.DataParser.TYPE in rawData && "string" === typeof rawData[dragonBones.DataParser.TYPE] ? dragonBones.DataParser._getDisplayType(rawData[dragonBones.DataParser.TYPE]) : ObjectDataParser._getNumber(rawData, dragonBones.DataParser.TYPE, type); + switch (type) { + case 0: + var imageDisplay = display = dragonBones.BaseObject.borrowObject(dragonBones.ImageDisplayData); + imageDisplay.name = name; + imageDisplay.path = path.length > 0 ? path : name; + this._parsePivot(rawData, imageDisplay); + break; + + case 1: + var armatureDisplay = display = dragonBones.BaseObject.borrowObject(dragonBones.ArmatureDisplayData); + armatureDisplay.name = name; + armatureDisplay.path = path.length > 0 ? path : name; + armatureDisplay.inheritAnimation = true; + if (dragonBones.DataParser.ACTIONS in rawData) { + var actions = this._parseActionData(rawData[dragonBones.DataParser.ACTIONS], 0, null, null); + for (var _i = 0, actions_5 = actions; _i < actions_5.length; _i++) { + var action = actions_5[_i]; + armatureDisplay.addAction(action); + } + } else if (this._slot.name in this._slotChildActions) { + var displays = this._skin.getDisplays(this._slot.name); + if (null === displays ? 0 === this._slot.displayIndex : this._slot.displayIndex === displays.length) { + for (var _a = 0, _b = this._slotChildActions[this._slot.name]; _a < _b.length; _a++) { + var action = _b[_a]; + armatureDisplay.addAction(action); + } + delete this._slotChildActions[this._slot.name]; + } + } + break; + + case 2: + var meshDisplay = display = dragonBones.BaseObject.borrowObject(dragonBones.MeshDisplayData); + meshDisplay.vertices.inheritDeform = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.INHERIT_DEFORM, true); + meshDisplay.name = name; + meshDisplay.path = path.length > 0 ? path : name; + meshDisplay.vertices.data = this._data; + if (dragonBones.DataParser.SHARE in rawData) { + this._cacheRawMeshes.push(rawData); + this._cacheMeshes.push(meshDisplay); + } else this._parseMesh(rawData, meshDisplay); + if (dragonBones.DataParser.GLUE_WEIGHTS in rawData && dragonBones.DataParser.GLUE_MESHES in rawData) { + this._cacheRawMeshes.push(rawData); + this._cacheMeshes.push(meshDisplay); + } + break; + + case 3: + var boundingBox = this._parseBoundingBox(rawData); + if (null !== boundingBox) { + var boundingBoxDisplay = display = dragonBones.BaseObject.borrowObject(dragonBones.BoundingBoxDisplayData); + boundingBoxDisplay.name = name; + boundingBoxDisplay.path = path.length > 0 ? path : name; + boundingBoxDisplay.boundingBox = boundingBox; + } + break; + + case 4: + var rawCurveLengths = rawData[dragonBones.DataParser.LENGTHS]; + var pathDisplay = display = dragonBones.BaseObject.borrowObject(dragonBones.PathDisplayData); + pathDisplay.closed = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.CLOSED, false); + pathDisplay.constantSpeed = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.CONSTANT_SPEED, false); + pathDisplay.name = name; + pathDisplay.path = path.length > 0 ? path : name; + pathDisplay.vertices.data = this._data; + pathDisplay.curveLengths.length = rawCurveLengths.length; + for (var i = 0, l = rawCurveLengths.length; i < l; ++i) pathDisplay.curveLengths[i] = rawCurveLengths[i]; + this._parsePath(rawData, pathDisplay); + } + null !== display && dragonBones.DataParser.TRANSFORM in rawData && this._parseTransform(rawData[dragonBones.DataParser.TRANSFORM], display.transform, this._armature.scale); + return display; + }; + ObjectDataParser.prototype._parsePath = function(rawData, display) { + var rawVertices = rawData[dragonBones.DataParser.VERTICES]; + var vertexCount = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.VERTEX_COUNT, 0); + var vertexOffset = this._floatArray.length; + var pathOffset = this._intArray.length; + display.vertices.offset = pathOffset; + this._intArray.length += 2; + this._intArray[pathOffset + 0] = vertexCount; + this._intArray[pathOffset + 2] = vertexOffset; + if (dragonBones.DataParser.WEIGHTS in rawData) { + var rawWeights = rawData[dragonBones.DataParser.WEIGHTS]; + var rawBones = rawData[dragonBones.DataParser.BONES]; + var weightBoneCount = rawBones.length; + var weightCount = Math.floor(rawWeights.length - vertexCount) / 2; + var weightOffset = this._intArray.length; + var floatOffset = this._floatArray.length; + var sortedBones = this._armature.sortedBones; + var weight = dragonBones.BaseObject.borrowObject(dragonBones.WeightData); + weight.count = weightCount; + weight.offset = weightOffset; + this._intArray.length += 2 + weightBoneCount + vertexCount + weightCount; + this._intArray[weightOffset + 0] = weightBoneCount; + this._intArray[weightOffset + 1] = floatOffset; + for (var i = 0; i < weightBoneCount; i++) { + var rawBoneIndex = rawBones[i]; + var bone = this._rawBones[rawBoneIndex]; + weight.addBone(bone); + this._intArray[weightOffset + 2 + i] = sortedBones.indexOf(bone); + } + this._floatArray.length += 3 * weightCount; + for (var i = 0, iW = 0, iV = 0, iB = weightOffset + 2 + weightBoneCount, iF = floatOffset; i < weightCount; i++) { + var boneCount = rawWeights[iW++]; + this._intArray[iB++] = boneCount; + for (var j = 0; j < boneCount; j++) { + var boneIndex = rawWeights[iW++]; + var boneWeight = rawWeights[iW++]; + var x = rawVertices[iV++]; + var y = rawVertices[iV++]; + this._intArray[iB++] = rawBones.indexOf(boneIndex); + this._floatArray[iF++] = boneWeight; + this._floatArray[iF++] = x; + this._floatArray[iF++] = y; + } + } + display.vertices.weight = weight; + } else { + this._floatArray.length += rawVertices.length; + for (var i = 0, l = rawVertices.length; i < l; ++i) this._floatArray[vertexOffset + i] = rawVertices[i]; + } + }; + ObjectDataParser.prototype._parsePivot = function(rawData, display) { + if (dragonBones.DataParser.PIVOT in rawData) { + var rawPivot = rawData[dragonBones.DataParser.PIVOT]; + display.pivot.x = ObjectDataParser._getNumber(rawPivot, dragonBones.DataParser.X, 0); + display.pivot.y = ObjectDataParser._getNumber(rawPivot, dragonBones.DataParser.Y, 0); + } else { + display.pivot.x = .5; + display.pivot.y = .5; + } + }; + ObjectDataParser.prototype._parseMesh = function(rawData, mesh) { + var rawVertices = rawData[dragonBones.DataParser.VERTICES]; + var rawUVs = rawData[dragonBones.DataParser.UVS]; + var rawTriangles = rawData[dragonBones.DataParser.TRIANGLES]; + var vertexCount = Math.floor(rawVertices.length / 2); + var triangleCount = Math.floor(rawTriangles.length / 3); + var vertexOffset = this._floatArray.length; + var uvOffset = vertexOffset + 2 * vertexCount; + var meshOffset = this._intArray.length; + var meshName = this._skin.name + "_" + this._slot.name + "_" + mesh.name; + mesh.vertices.offset = meshOffset; + this._intArray.length += 4 + 3 * triangleCount; + this._intArray[meshOffset + 0] = vertexCount; + this._intArray[meshOffset + 1] = triangleCount; + this._intArray[meshOffset + 2] = vertexOffset; + for (var i = 0, l = 3 * triangleCount; i < l; ++i) this._intArray[meshOffset + 4 + i] = rawTriangles[i]; + this._floatArray.length += 2 * vertexCount + 2 * vertexCount; + for (var i = 0, l = 2 * vertexCount; i < l; ++i) { + this._floatArray[vertexOffset + i] = rawVertices[i]; + this._floatArray[uvOffset + i] = rawUVs[i]; + } + if (dragonBones.DataParser.WEIGHTS in rawData) { + var rawWeights = rawData[dragonBones.DataParser.WEIGHTS]; + var rawSlotPose = rawData[dragonBones.DataParser.SLOT_POSE]; + var rawBonePoses = rawData[dragonBones.DataParser.BONE_POSE]; + var sortedBones = this._armature.sortedBones; + var weightBoneIndices = new Array(); + var weightBoneCount = Math.floor(rawBonePoses.length / 7); + var floatOffset = this._floatArray.length; + var weightCount = Math.floor(rawWeights.length - vertexCount) / 2; + var weightOffset = this._intArray.length; + var weight = dragonBones.BaseObject.borrowObject(dragonBones.WeightData); + weight.count = weightCount; + weight.offset = weightOffset; + weightBoneIndices.length = weightBoneCount; + this._intArray.length += 2 + weightBoneCount + vertexCount + weightCount; + this._intArray[weightOffset + 1] = floatOffset; + for (var i = 0; i < weightBoneCount; ++i) { + var rawBoneIndex = rawBonePoses[7 * i]; + var bone = this._rawBones[rawBoneIndex]; + weight.addBone(bone); + weightBoneIndices[i] = rawBoneIndex; + this._intArray[weightOffset + 2 + i] = sortedBones.indexOf(bone); + } + this._floatArray.length += 3 * weightCount; + this._helpMatrixA.copyFromArray(rawSlotPose, 0); + for (var i = 0, iW = 0, iB = weightOffset + 2 + weightBoneCount, iV = floatOffset; i < vertexCount; ++i) { + var iD = 2 * i; + var vertexBoneCount = this._intArray[iB++] = rawWeights[iW++]; + var x = this._floatArray[vertexOffset + iD]; + var y = this._floatArray[vertexOffset + iD + 1]; + this._helpMatrixA.transformPoint(x, y, this._helpPoint); + x = this._helpPoint.x; + y = this._helpPoint.y; + for (var j = 0; j < vertexBoneCount; ++j) { + var rawBoneIndex = rawWeights[iW++]; + var boneIndex = weightBoneIndices.indexOf(rawBoneIndex); + this._helpMatrixB.copyFromArray(rawBonePoses, 7 * boneIndex + 1); + this._helpMatrixB.invert(); + this._helpMatrixB.transformPoint(x, y, this._helpPoint); + this._intArray[iB++] = boneIndex; + this._floatArray[iV++] = rawWeights[iW++]; + this._floatArray[iV++] = this._helpPoint.x; + this._floatArray[iV++] = this._helpPoint.y; + } + } + mesh.vertices.weight = weight; + this._weightSlotPose[meshName] = rawSlotPose; + this._weightBonePoses[meshName] = rawBonePoses; + } + }; + ObjectDataParser.prototype._parseMeshGlue = function(rawData, mesh) { + rawData; + mesh; + }; + ObjectDataParser.prototype._parseBoundingBox = function(rawData) { + var boundingBox = null; + var type = 0; + type = dragonBones.DataParser.SUB_TYPE in rawData && "string" === typeof rawData[dragonBones.DataParser.SUB_TYPE] ? dragonBones.DataParser._getBoundingBoxType(rawData[dragonBones.DataParser.SUB_TYPE]) : ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SUB_TYPE, type); + switch (type) { + case 0: + boundingBox = dragonBones.BaseObject.borrowObject(dragonBones.RectangleBoundingBoxData); + break; + + case 1: + boundingBox = dragonBones.BaseObject.borrowObject(dragonBones.EllipseBoundingBoxData); + break; + + case 2: + boundingBox = this._parsePolygonBoundingBox(rawData); + } + if (null !== boundingBox) { + boundingBox.color = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.COLOR, 0); + if (0 === boundingBox.type || 1 === boundingBox.type) { + boundingBox.width = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.WIDTH, 0); + boundingBox.height = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.HEIGHT, 0); + } + } + return boundingBox; + }; + ObjectDataParser.prototype._parsePolygonBoundingBox = function(rawData) { + var polygonBoundingBox = dragonBones.BaseObject.borrowObject(dragonBones.PolygonBoundingBoxData); + if (dragonBones.DataParser.VERTICES in rawData) { + var scale = this._armature.scale; + var rawVertices = rawData[dragonBones.DataParser.VERTICES]; + var vertices = polygonBoundingBox.vertices; + dragonBones.DragonBones.webAssembly ? vertices.resize(rawVertices.length, 0) : vertices.length = rawVertices.length; + for (var i = 0, l = rawVertices.length; i < l; i += 2) { + var x = rawVertices[i] * scale; + var y = rawVertices[i + 1] * scale; + if (dragonBones.DragonBones.webAssembly) { + vertices.set(i, x); + vertices.set(i + 1, y); + } else { + vertices[i] = x; + vertices[i + 1] = y; + } + if (0 === i) { + polygonBoundingBox.x = x; + polygonBoundingBox.y = y; + polygonBoundingBox.width = x; + polygonBoundingBox.height = y; + } else { + x < polygonBoundingBox.x ? polygonBoundingBox.x = x : x > polygonBoundingBox.width && (polygonBoundingBox.width = x); + y < polygonBoundingBox.y ? polygonBoundingBox.y = y : y > polygonBoundingBox.height && (polygonBoundingBox.height = y); + } + } + polygonBoundingBox.width -= polygonBoundingBox.x; + polygonBoundingBox.height -= polygonBoundingBox.y; + } else console.warn("Data error.\n Please reexport DragonBones Data to fixed the bug."); + return polygonBoundingBox; + }; + ObjectDataParser.prototype._parseAnimation = function(rawData) { + var animation = dragonBones.BaseObject.borrowObject(dragonBones.AnimationData); + animation.frameCount = Math.max(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.DURATION, 1), 1); + animation.playTimes = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.PLAY_TIMES, 1); + animation.duration = animation.frameCount / this._armature.frameRate; + animation.fadeInTime = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.FADE_IN_TIME, 0); + animation.scale = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SCALE, 1); + animation.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, dragonBones.DataParser.DEFAULT_NAME); + 0 === animation.name.length && (animation.name = dragonBones.DataParser.DEFAULT_NAME); + animation.frameIntOffset = this._frameIntArray.length; + animation.frameFloatOffset = this._frameFloatArray.length; + animation.frameOffset = this._frameArray.length; + this._animation = animation; + if (dragonBones.DataParser.FRAME in rawData) { + var rawFrames = rawData[dragonBones.DataParser.FRAME]; + var keyFrameCount = rawFrames.length; + if (keyFrameCount > 0) for (var i = 0, frameStart = 0; i < keyFrameCount; ++i) { + var rawFrame = rawFrames[i]; + this._parseActionDataInFrame(rawFrame, frameStart, null, null); + frameStart += ObjectDataParser._getNumber(rawFrame, dragonBones.DataParser.DURATION, 1); + } + } + dragonBones.DataParser.Z_ORDER in rawData && (this._animation.zOrderTimeline = this._parseTimeline(rawData[dragonBones.DataParser.Z_ORDER], null, dragonBones.DataParser.FRAME, 1, false, false, 0, this._parseZOrderFrame)); + if (dragonBones.DataParser.BONE in rawData) { + var rawTimelines = rawData[dragonBones.DataParser.BONE]; + for (var _i = 0, rawTimelines_1 = rawTimelines; _i < rawTimelines_1.length; _i++) { + var rawTimeline = rawTimelines_1[_i]; + this._parseBoneTimeline(rawTimeline); + } + } + if (dragonBones.DataParser.SURFACE in rawData) { + var rawTimelines = rawData[dragonBones.DataParser.SURFACE]; + for (var _a = 0, rawTimelines_2 = rawTimelines; _a < rawTimelines_2.length; _a++) { + var rawTimeline = rawTimelines_2[_a]; + var surfaceName = ObjectDataParser._getString(rawTimeline, dragonBones.DataParser.NAME, ""); + this._surface = this._armature.getBone(surfaceName); + if (null === this._surface) continue; + var timeline = this._parseTimeline(rawTimeline, null, dragonBones.DataParser.FRAME, 50, false, true, 0, this._parseSurfaceFrame); + null !== timeline && this._animation.addSurfaceTimeline(this._surface, timeline); + this._surface = null; + } + } + if (dragonBones.DataParser.SLOT in rawData) { + var rawTimelines = rawData[dragonBones.DataParser.SLOT]; + for (var _b = 0, rawTimelines_3 = rawTimelines; _b < rawTimelines_3.length; _b++) { + var rawTimeline = rawTimelines_3[_b]; + this._parseSlotTimeline(rawTimeline); + } + } + if (dragonBones.DataParser.FFD in rawData) { + var rawTimelines = rawData[dragonBones.DataParser.FFD]; + for (var _c = 0, rawTimelines_4 = rawTimelines; _c < rawTimelines_4.length; _c++) { + var rawTimeline = rawTimelines_4[_c]; + var skinName = ObjectDataParser._getString(rawTimeline, dragonBones.DataParser.SKIN, dragonBones.DataParser.DEFAULT_NAME); + var slotName = ObjectDataParser._getString(rawTimeline, dragonBones.DataParser.SLOT, ""); + var displayName = ObjectDataParser._getString(rawTimeline, dragonBones.DataParser.NAME, ""); + 0 === skinName.length && (skinName = dragonBones.DataParser.DEFAULT_NAME); + this._slot = this._armature.getSlot(slotName); + this._mesh = this._armature.getMesh(skinName, slotName, displayName); + if (null === this._slot || null === this._mesh) continue; + var timeline = this._parseTimeline(rawTimeline, null, dragonBones.DataParser.FRAME, 22, false, true, 0, this._parseSlotFFDFrame); + null !== timeline && this._animation.addSlotTimeline(this._slot, timeline); + this._slot = null; + this._mesh = null; + } + } + if (dragonBones.DataParser.IK in rawData) { + var rawTimelines = rawData[dragonBones.DataParser.IK]; + for (var _d = 0, rawTimelines_5 = rawTimelines; _d < rawTimelines_5.length; _d++) { + var rawTimeline = rawTimelines_5[_d]; + var constraintName = ObjectDataParser._getString(rawTimeline, dragonBones.DataParser.NAME, ""); + var constraint = this._armature.getConstraint(constraintName); + if (null === constraint) continue; + var timeline = this._parseTimeline(rawTimeline, null, dragonBones.DataParser.FRAME, 30, true, false, 2, this._parseIKConstraintFrame); + null !== timeline && this._animation.addConstraintTimeline(constraint, timeline); + } + } + if (dragonBones.DataParser.ANIMATION in rawData) { + var rawTimelines = rawData[dragonBones.DataParser.ANIMATION]; + for (var _e = 0, rawTimelines_6 = rawTimelines; _e < rawTimelines_6.length; _e++) { + var rawTimeline = rawTimelines_6[_e]; + var animationName = ObjectDataParser._getString(rawTimeline, dragonBones.DataParser.NAME, ""); + var timeline = this._parseTimeline(rawTimeline, null, dragonBones.DataParser.FRAME, 40, true, false, 2, this._parseAnimationFrame); + null !== timeline && this._animation.addAnimationTimeline(animationName, timeline); + } + } + if (this._actionFrames.length > 0) { + this._animation.actionTimeline = this._parseTimeline(null, this._actionFrames, "", 0, false, false, 0, this._parseActionFrame); + this._actionFrames.length = 0; + } + this._animation = null; + return animation; + }; + ObjectDataParser.prototype._parseTimeline = function(rawData, rawFrames, framesKey, type, addIntOffset, addFloatOffset, frameValueCount, frameParser) { + null !== rawData && framesKey.length > 0 && framesKey in rawData && (rawFrames = rawData[framesKey]); + if (null === rawFrames) return null; + var keyFrameCount = rawFrames.length; + if (0 === keyFrameCount) return null; + var frameIntArrayLength = this._frameIntArray.length; + var frameFloatArrayLength = this._frameFloatArray.length; + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.TimelineData); + var timelineOffset = this._timelineArray.length; + this._timelineArray.length += 5 + keyFrameCount; + if (null !== rawData) { + this._timelineArray[timelineOffset + 0] = Math.round(100 * ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SCALE, 1)); + this._timelineArray[timelineOffset + 1] = Math.round(100 * ObjectDataParser._getNumber(rawData, dragonBones.DataParser.OFFSET, 0)); + } else { + this._timelineArray[timelineOffset + 0] = 100; + this._timelineArray[timelineOffset + 1] = 0; + } + this._timelineArray[timelineOffset + 2] = keyFrameCount; + this._timelineArray[timelineOffset + 3] = frameValueCount; + this._timelineArray[timelineOffset + 4] = addIntOffset ? frameIntArrayLength - this._animation.frameIntOffset : addFloatOffset ? frameFloatArrayLength - this._animation.frameFloatOffset : 0; + this._timeline = timeline; + timeline.type = type; + timeline.offset = timelineOffset; + if (1 === keyFrameCount) { + timeline.frameIndicesOffset = -1; + this._timelineArray[timelineOffset + 5 + 0] = frameParser.call(this, rawFrames[0], 0, 0) - this._animation.frameOffset; + } else { + var totalFrameCount = this._animation.frameCount + 1; + var frameIndices = this._data.frameIndices; + var frameIndicesOffset = 0; + if (dragonBones.DragonBones.webAssembly) { + frameIndicesOffset = frameIndices.size(); + frameIndices.resize(frameIndicesOffset + totalFrameCount, 0); + } else { + frameIndicesOffset = frameIndices.length; + frameIndices.length += totalFrameCount; + } + timeline.frameIndicesOffset = frameIndicesOffset; + for (var i = 0, iK = 0, frameStart = 0, frameCount = 0; i < totalFrameCount; ++i) { + if (frameStart + frameCount <= i && iK < keyFrameCount) { + var rawFrame = rawFrames[iK]; + frameStart = i; + frameCount = iK === keyFrameCount - 1 ? this._animation.frameCount - frameStart : rawFrame instanceof ActionFrame ? this._actionFrames[iK + 1].frameStart - frameStart : ObjectDataParser._getNumber(rawFrame, dragonBones.DataParser.DURATION, 1); + this._timelineArray[timelineOffset + 5 + iK] = frameParser.call(this, rawFrame, frameStart, frameCount) - this._animation.frameOffset; + iK++; + } + dragonBones.DragonBones.webAssembly ? frameIndices.set(frameIndicesOffset + i, iK - 1) : frameIndices[frameIndicesOffset + i] = iK - 1; + } + } + this._timeline = null; + return timeline; + }; + ObjectDataParser.prototype._parseBoneTimeline = function(rawData) { + var bone = this._armature.getBone(ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, "")); + if (null === bone) return; + this._bone = bone; + this._slot = this._armature.getSlot(this._bone.name); + if (dragonBones.DataParser.TRANSLATE_FRAME in rawData) { + var timeline = this._parseTimeline(rawData, null, dragonBones.DataParser.TRANSLATE_FRAME, 11, false, true, 2, this._parseBoneTranslateFrame); + null !== timeline && this._animation.addBoneTimeline(bone, timeline); + } + if (dragonBones.DataParser.ROTATE_FRAME in rawData) { + var timeline = this._parseTimeline(rawData, null, dragonBones.DataParser.ROTATE_FRAME, 12, false, true, 2, this._parseBoneRotateFrame); + null !== timeline && this._animation.addBoneTimeline(bone, timeline); + } + if (dragonBones.DataParser.SCALE_FRAME in rawData) { + var timeline = this._parseTimeline(rawData, null, dragonBones.DataParser.SCALE_FRAME, 13, false, true, 2, this._parseBoneScaleFrame); + null !== timeline && this._animation.addBoneTimeline(bone, timeline); + } + if (dragonBones.DataParser.FRAME in rawData) { + var timeline = this._parseTimeline(rawData, null, dragonBones.DataParser.FRAME, 10, false, true, 6, this._parseBoneAllFrame); + null !== timeline && this._animation.addBoneTimeline(bone, timeline); + } + this._bone = null; + this._slot = null; + }; + ObjectDataParser.prototype._parseSlotTimeline = function(rawData) { + var slot = this._armature.getSlot(ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, "")); + if (null === slot) return; + this._slot = slot; + var displayTimeline = null; + displayTimeline = dragonBones.DataParser.DISPLAY_FRAME in rawData ? this._parseTimeline(rawData, null, dragonBones.DataParser.DISPLAY_FRAME, 20, false, false, 0, this._parseSlotDisplayFrame) : this._parseTimeline(rawData, null, dragonBones.DataParser.FRAME, 20, false, false, 0, this._parseSlotDisplayFrame); + null !== displayTimeline && this._animation.addSlotTimeline(slot, displayTimeline); + var colorTimeline = null; + colorTimeline = dragonBones.DataParser.COLOR_FRAME in rawData ? this._parseTimeline(rawData, null, dragonBones.DataParser.COLOR_FRAME, 21, true, false, 1, this._parseSlotColorFrame) : this._parseTimeline(rawData, null, dragonBones.DataParser.FRAME, 21, true, false, 1, this._parseSlotColorFrame); + null !== colorTimeline && this._animation.addSlotTimeline(slot, colorTimeline); + this._slot = null; + }; + ObjectDataParser.prototype._parseFrame = function(rawData, frameStart, frameCount) { + rawData; + frameCount; + var frameOffset = this._frameArray.length; + this._frameArray.length += 1; + this._frameArray[frameOffset + 0] = frameStart; + return frameOffset; + }; + ObjectDataParser.prototype._parseTweenFrame = function(rawData, frameStart, frameCount) { + var frameOffset = this._parseFrame(rawData, frameStart, frameCount); + if (frameCount > 0) if (dragonBones.DataParser.CURVE in rawData) { + var sampleCount = frameCount + 1; + this._helpArray.length = sampleCount; + this._samplingEasingCurve(rawData[dragonBones.DataParser.CURVE], this._helpArray); + this._frameArray.length += 2 + this._helpArray.length; + this._frameArray[frameOffset + 1] = 2; + this._frameArray[frameOffset + 2] = sampleCount; + for (var i = 0; i < sampleCount; ++i) this._frameArray[frameOffset + 3 + i] = Math.round(1e4 * this._helpArray[i]); + } else { + var noTween = -2; + var tweenEasing = noTween; + dragonBones.DataParser.TWEEN_EASING in rawData && (tweenEasing = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.TWEEN_EASING, noTween)); + if (tweenEasing === noTween) { + this._frameArray.length += 1; + this._frameArray[frameOffset + 1] = 0; + } else if (0 === tweenEasing) { + this._frameArray.length += 1; + this._frameArray[frameOffset + 1] = 1; + } else if (tweenEasing < 0) { + this._frameArray.length += 2; + this._frameArray[frameOffset + 1] = 3; + this._frameArray[frameOffset + 2] = Math.round(100 * -tweenEasing); + } else if (tweenEasing <= 1) { + this._frameArray.length += 2; + this._frameArray[frameOffset + 1] = 4; + this._frameArray[frameOffset + 2] = Math.round(100 * tweenEasing); + } else { + this._frameArray.length += 2; + this._frameArray[frameOffset + 1] = 5; + this._frameArray[frameOffset + 2] = Math.round(100 * tweenEasing - 100); + } + } else { + this._frameArray.length += 1; + this._frameArray[frameOffset + 1] = 0; + } + return frameOffset; + }; + ObjectDataParser.prototype._parseActionFrame = function(frame, frameStart, frameCount) { + frameCount; + var frameOffset = this._frameArray.length; + var actionCount = frame.actions.length; + this._frameArray.length += 2 + actionCount; + this._frameArray[frameOffset + 0] = frameStart; + this._frameArray[frameOffset + 0 + 1] = actionCount; + for (var i = 0; i < actionCount; ++i) this._frameArray[frameOffset + 0 + 2 + i] = frame.actions[i]; + return frameOffset; + }; + ObjectDataParser.prototype._parseZOrderFrame = function(rawData, frameStart, frameCount) { + var frameOffset = this._parseFrame(rawData, frameStart, frameCount); + if (dragonBones.DataParser.Z_ORDER in rawData) { + var rawZOrder = rawData[dragonBones.DataParser.Z_ORDER]; + if (rawZOrder.length > 0) { + var slotCount = this._armature.sortedSlots.length; + var unchanged = new Array(slotCount - rawZOrder.length / 2); + var zOrders = new Array(slotCount); + for (var i_1 = 0; i_1 < unchanged.length; ++i_1) unchanged[i_1] = 0; + for (var i_2 = 0; i_2 < slotCount; ++i_2) zOrders[i_2] = -1; + var originalIndex = 0; + var unchangedIndex = 0; + for (var i_3 = 0, l = rawZOrder.length; i_3 < l; i_3 += 2) { + var slotIndex = rawZOrder[i_3]; + var zOrderOffset = rawZOrder[i_3 + 1]; + while (originalIndex !== slotIndex) unchanged[unchangedIndex++] = originalIndex++; + var index = originalIndex + zOrderOffset; + zOrders[index] = originalIndex++; + } + while (originalIndex < slotCount) unchanged[unchangedIndex++] = originalIndex++; + this._frameArray.length += 1 + slotCount; + this._frameArray[frameOffset + 1] = slotCount; + var i = slotCount; + while (i--) -1 === zOrders[i] ? this._frameArray[frameOffset + 2 + i] = unchanged[--unchangedIndex] || 0 : this._frameArray[frameOffset + 2 + i] = zOrders[i] || 0; + return frameOffset; + } + } + this._frameArray.length += 1; + this._frameArray[frameOffset + 1] = 0; + return frameOffset; + }; + ObjectDataParser.prototype._parseBoneAllFrame = function(rawData, frameStart, frameCount) { + this._helpTransform.identity(); + dragonBones.DataParser.TRANSFORM in rawData && this._parseTransform(rawData[dragonBones.DataParser.TRANSFORM], this._helpTransform, 1); + var rotation = this._helpTransform.rotation; + if (0 !== frameStart) if (0 === this._prevClockwise) rotation = this._prevRotation + dragonBones.Transform.normalizeRadian(rotation - this._prevRotation); else { + (this._prevClockwise > 0 ? rotation >= this._prevRotation : rotation <= this._prevRotation) && (this._prevClockwise = this._prevClockwise > 0 ? this._prevClockwise - 1 : this._prevClockwise + 1); + rotation = this._prevRotation + rotation - this._prevRotation + dragonBones.Transform.PI_D * this._prevClockwise; + } + this._prevClockwise = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.TWEEN_ROTATE, 0); + this._prevRotation = rotation; + var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); + var frameFloatOffset = this._frameFloatArray.length; + this._frameFloatArray.length += 6; + this._frameFloatArray[frameFloatOffset++] = this._helpTransform.x; + this._frameFloatArray[frameFloatOffset++] = this._helpTransform.y; + this._frameFloatArray[frameFloatOffset++] = rotation; + this._frameFloatArray[frameFloatOffset++] = this._helpTransform.skew; + this._frameFloatArray[frameFloatOffset++] = this._helpTransform.scaleX; + this._frameFloatArray[frameFloatOffset++] = this._helpTransform.scaleY; + this._parseActionDataInFrame(rawData, frameStart, this._bone, this._slot); + return frameOffset; + }; + ObjectDataParser.prototype._parseBoneTranslateFrame = function(rawData, frameStart, frameCount) { + var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); + var frameFloatOffset = this._frameFloatArray.length; + this._frameFloatArray.length += 2; + this._frameFloatArray[frameFloatOffset++] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.X, 0); + this._frameFloatArray[frameFloatOffset++] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.Y, 0); + return frameOffset; + }; + ObjectDataParser.prototype._parseBoneRotateFrame = function(rawData, frameStart, frameCount) { + var rotation = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ROTATE, 0) * dragonBones.Transform.DEG_RAD; + if (0 !== frameStart) if (0 === this._prevClockwise) rotation = this._prevRotation + dragonBones.Transform.normalizeRadian(rotation - this._prevRotation); else { + (this._prevClockwise > 0 ? rotation >= this._prevRotation : rotation <= this._prevRotation) && (this._prevClockwise = this._prevClockwise > 0 ? this._prevClockwise - 1 : this._prevClockwise + 1); + rotation = this._prevRotation + rotation - this._prevRotation + dragonBones.Transform.PI_D * this._prevClockwise; + } + this._prevClockwise = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.CLOCK_WISE, 0); + this._prevRotation = rotation; + var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); + var frameFloatOffset = this._frameFloatArray.length; + this._frameFloatArray.length += 2; + this._frameFloatArray[frameFloatOffset++] = rotation; + this._frameFloatArray[frameFloatOffset++] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SKEW, 0) * dragonBones.Transform.DEG_RAD; + return frameOffset; + }; + ObjectDataParser.prototype._parseBoneScaleFrame = function(rawData, frameStart, frameCount) { + var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); + var frameFloatOffset = this._frameFloatArray.length; + this._frameFloatArray.length += 2; + this._frameFloatArray[frameFloatOffset++] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.X, 1); + this._frameFloatArray[frameFloatOffset++] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.Y, 1); + return frameOffset; + }; + ObjectDataParser.prototype._parseSurfaceFrame = function(rawData, frameStart, frameCount) { + var frameFloatOffset = this._frameFloatArray.length; + var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); + var rawVertices = rawData[dragonBones.DataParser.VERTICES]; + var offset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.OFFSET, 0); + var vertexCount = this._surface.vertices.length / 2; + var x = 0; + var y = 0; + this._frameFloatArray.length += 2 * vertexCount; + for (var i = 0; i < 2 * vertexCount; i += 2) { + x = i < offset || i - offset >= rawVertices.length ? 0 : rawVertices[i - offset]; + y = i + 1 < offset || i + 1 - offset >= rawVertices.length ? 0 : rawVertices[i + 1 - offset]; + this._frameFloatArray[frameFloatOffset + i] = x; + this._frameFloatArray[frameFloatOffset + i + 1] = y; + } + if (0 === frameStart) { + var frameIntOffset = this._frameIntArray.length; + this._frameIntArray.length += 5; + this._frameIntArray[frameIntOffset + 0] = 0; + this._frameIntArray[frameIntOffset + 1] = this._frameFloatArray.length - frameFloatOffset; + this._frameIntArray[frameIntOffset + 2] = this._frameFloatArray.length - frameFloatOffset; + this._frameIntArray[frameIntOffset + 3] = 0; + this._frameIntArray[frameIntOffset + 4] = frameFloatOffset - this._animation.frameFloatOffset; + this._timelineArray[this._timeline.offset + 3] = frameIntOffset - this._animation.frameIntOffset; + } + return frameOffset; + }; + ObjectDataParser.prototype._parseSlotDisplayFrame = function(rawData, frameStart, frameCount) { + var frameOffset = this._parseFrame(rawData, frameStart, frameCount); + this._frameArray.length += 1; + dragonBones.DataParser.VALUE in rawData ? this._frameArray[frameOffset + 1] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.VALUE, 0) : this._frameArray[frameOffset + 1] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.DISPLAY_INDEX, 0); + this._parseActionDataInFrame(rawData, frameStart, this._slot.parent, this._slot); + return frameOffset; + }; + ObjectDataParser.prototype._parseSlotColorFrame = function(rawData, frameStart, frameCount) { + var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); + var colorOffset = -1; + if (dragonBones.DataParser.VALUE in rawData || dragonBones.DataParser.COLOR in rawData) { + var rawColor = dragonBones.DataParser.VALUE in rawData ? rawData[dragonBones.DataParser.VALUE] : rawData[dragonBones.DataParser.COLOR]; + for (var k in rawColor) { + k; + this._parseColorTransform(rawColor, this._helpColorTransform); + colorOffset = this._intArray.length; + this._intArray.length += 8; + this._intArray[colorOffset++] = Math.round(100 * this._helpColorTransform.alphaMultiplier); + this._intArray[colorOffset++] = Math.round(100 * this._helpColorTransform.redMultiplier); + this._intArray[colorOffset++] = Math.round(100 * this._helpColorTransform.greenMultiplier); + this._intArray[colorOffset++] = Math.round(100 * this._helpColorTransform.blueMultiplier); + this._intArray[colorOffset++] = Math.round(this._helpColorTransform.alphaOffset); + this._intArray[colorOffset++] = Math.round(this._helpColorTransform.redOffset); + this._intArray[colorOffset++] = Math.round(this._helpColorTransform.greenOffset); + this._intArray[colorOffset++] = Math.round(this._helpColorTransform.blueOffset); + colorOffset -= 8; + break; + } + } + if (colorOffset < 0) { + if (this._defaultColorOffset < 0) { + this._defaultColorOffset = colorOffset = this._intArray.length; + this._intArray.length += 8; + this._intArray[colorOffset++] = 100; + this._intArray[colorOffset++] = 100; + this._intArray[colorOffset++] = 100; + this._intArray[colorOffset++] = 100; + this._intArray[colorOffset++] = 0; + this._intArray[colorOffset++] = 0; + this._intArray[colorOffset++] = 0; + this._intArray[colorOffset++] = 0; + } + colorOffset = this._defaultColorOffset; + } + var frameIntOffset = this._frameIntArray.length; + this._frameIntArray.length += 1; + this._frameIntArray[frameIntOffset] = colorOffset; + return frameOffset; + }; + ObjectDataParser.prototype._parseSlotFFDFrame = function(rawData, frameStart, frameCount) { + var frameFloatOffset = this._frameFloatArray.length; + var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); + var rawVertices = dragonBones.DataParser.VERTICES in rawData ? rawData[dragonBones.DataParser.VERTICES] : null; + var offset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.OFFSET, 0); + var vertexCount = this._intArray[this._mesh.vertices.offset + 0]; + var meshName = this._mesh.parent.name + "_" + this._slot.name + "_" + this._mesh.name; + var weight = this._mesh.vertices.weight; + var x = 0; + var y = 0; + var iB = 0; + var iV = 0; + if (null !== weight) { + var rawSlotPose = this._weightSlotPose[meshName]; + this._helpMatrixA.copyFromArray(rawSlotPose, 0); + this._frameFloatArray.length += 2 * weight.count; + iB = weight.offset + 2 + weight.bones.length; + } else this._frameFloatArray.length += 2 * vertexCount; + for (var i = 0; i < 2 * vertexCount; i += 2) { + if (null === rawVertices) { + x = 0; + y = 0; + } else { + x = i < offset || i - offset >= rawVertices.length ? 0 : rawVertices[i - offset]; + y = i + 1 < offset || i + 1 - offset >= rawVertices.length ? 0 : rawVertices[i + 1 - offset]; + } + if (null !== weight) { + var rawBonePoses = this._weightBonePoses[meshName]; + var vertexBoneCount = this._intArray[iB++]; + this._helpMatrixA.transformPoint(x, y, this._helpPoint, true); + x = this._helpPoint.x; + y = this._helpPoint.y; + for (var j = 0; j < vertexBoneCount; ++j) { + var boneIndex = this._intArray[iB++]; + this._helpMatrixB.copyFromArray(rawBonePoses, 7 * boneIndex + 1); + this._helpMatrixB.invert(); + this._helpMatrixB.transformPoint(x, y, this._helpPoint, true); + this._frameFloatArray[frameFloatOffset + iV++] = this._helpPoint.x; + this._frameFloatArray[frameFloatOffset + iV++] = this._helpPoint.y; + } + } else { + this._frameFloatArray[frameFloatOffset + i] = x; + this._frameFloatArray[frameFloatOffset + i + 1] = y; + } + } + if (0 === frameStart) { + var frameIntOffset = this._frameIntArray.length; + this._frameIntArray.length += 5; + this._frameIntArray[frameIntOffset + 0] = this._mesh.vertices.offset; + this._frameIntArray[frameIntOffset + 1] = this._frameFloatArray.length - frameFloatOffset; + this._frameIntArray[frameIntOffset + 2] = this._frameFloatArray.length - frameFloatOffset; + this._frameIntArray[frameIntOffset + 3] = 0; + this._frameIntArray[frameIntOffset + 4] = frameFloatOffset - this._animation.frameFloatOffset; + this._timelineArray[this._timeline.offset + 3] = frameIntOffset - this._animation.frameIntOffset; + } + return frameOffset; + }; + ObjectDataParser.prototype._parseIKConstraintFrame = function(rawData, frameStart, frameCount) { + var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); + var frameIntOffset = this._frameIntArray.length; + this._frameIntArray.length += 2; + this._frameIntArray[frameIntOffset++] = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.BEND_POSITIVE, true) ? 1 : 0; + this._frameIntArray[frameIntOffset++] = Math.round(100 * ObjectDataParser._getNumber(rawData, dragonBones.DataParser.WEIGHT, 1)); + return frameOffset; + }; + ObjectDataParser.prototype._parseAnimationFrame = function(rawData, frameStart, frameCount) { + var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); + var frameIntOffset = this._frameIntArray.length; + this._frameIntArray.length += 2; + this._frameIntArray[frameIntOffset++] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.VALUE, 0); + this._frameIntArray[frameIntOffset++] = Math.round(100 * ObjectDataParser._getNumber(rawData, dragonBones.DataParser.WEIGHT, 1)); + return frameOffset; + }; + ObjectDataParser.prototype._parseActionData = function(rawData, type, bone, slot) { + var actions = new Array(); + if ("string" === typeof rawData) { + var action = dragonBones.BaseObject.borrowObject(dragonBones.ActionData); + action.type = type; + action.name = rawData; + action.bone = bone; + action.slot = slot; + actions.push(action); + } else if (rawData instanceof Array) for (var _i = 0, rawData_2 = rawData; _i < rawData_2.length; _i++) { + var rawAction = rawData_2[_i]; + var action = dragonBones.BaseObject.borrowObject(dragonBones.ActionData); + if (dragonBones.DataParser.GOTO_AND_PLAY in rawAction) { + action.type = 0; + action.name = ObjectDataParser._getString(rawAction, dragonBones.DataParser.GOTO_AND_PLAY, ""); + } else { + dragonBones.DataParser.TYPE in rawAction && "string" === typeof rawAction[dragonBones.DataParser.TYPE] ? action.type = dragonBones.DataParser._getActionType(rawAction[dragonBones.DataParser.TYPE]) : action.type = ObjectDataParser._getNumber(rawAction, dragonBones.DataParser.TYPE, type); + action.name = ObjectDataParser._getString(rawAction, dragonBones.DataParser.NAME, ""); + } + if (dragonBones.DataParser.BONE in rawAction) { + var boneName = ObjectDataParser._getString(rawAction, dragonBones.DataParser.BONE, ""); + action.bone = this._armature.getBone(boneName); + } else action.bone = bone; + if (dragonBones.DataParser.SLOT in rawAction) { + var slotName = ObjectDataParser._getString(rawAction, dragonBones.DataParser.SLOT, ""); + action.slot = this._armature.getSlot(slotName); + } else action.slot = slot; + var userData = null; + if (dragonBones.DataParser.INTS in rawAction) { + null === userData && (userData = dragonBones.BaseObject.borrowObject(dragonBones.UserData)); + var rawInts = rawAction[dragonBones.DataParser.INTS]; + for (var _a = 0, rawInts_1 = rawInts; _a < rawInts_1.length; _a++) { + var rawValue = rawInts_1[_a]; + userData.addInt(rawValue); + } + } + if (dragonBones.DataParser.FLOATS in rawAction) { + null === userData && (userData = dragonBones.BaseObject.borrowObject(dragonBones.UserData)); + var rawFloats = rawAction[dragonBones.DataParser.FLOATS]; + for (var _b = 0, rawFloats_1 = rawFloats; _b < rawFloats_1.length; _b++) { + var rawValue = rawFloats_1[_b]; + userData.addFloat(rawValue); + } + } + if (dragonBones.DataParser.STRINGS in rawAction) { + null === userData && (userData = dragonBones.BaseObject.borrowObject(dragonBones.UserData)); + var rawStrings = rawAction[dragonBones.DataParser.STRINGS]; + for (var _c = 0, rawStrings_1 = rawStrings; _c < rawStrings_1.length; _c++) { + var rawValue = rawStrings_1[_c]; + userData.addString(rawValue); + } + } + action.data = userData; + actions.push(action); + } + return actions; + }; + ObjectDataParser.prototype._parseTransform = function(rawData, transform, scale) { + transform.x = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.X, 0) * scale; + transform.y = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.Y, 0) * scale; + if (dragonBones.DataParser.ROTATE in rawData || dragonBones.DataParser.SKEW in rawData) { + transform.rotation = dragonBones.Transform.normalizeRadian(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ROTATE, 0) * dragonBones.Transform.DEG_RAD); + transform.skew = dragonBones.Transform.normalizeRadian(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SKEW, 0) * dragonBones.Transform.DEG_RAD); + } else if (dragonBones.DataParser.SKEW_X in rawData || dragonBones.DataParser.SKEW_Y in rawData) { + transform.rotation = dragonBones.Transform.normalizeRadian(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SKEW_Y, 0) * dragonBones.Transform.DEG_RAD); + transform.skew = dragonBones.Transform.normalizeRadian(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SKEW_X, 0) * dragonBones.Transform.DEG_RAD) - transform.rotation; + } + transform.scaleX = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SCALE_X, 1); + transform.scaleY = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SCALE_Y, 1); + }; + ObjectDataParser.prototype._parseColorTransform = function(rawData, color) { + color.alphaMultiplier = .01 * ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ALPHA_MULTIPLIER, 100); + color.redMultiplier = .01 * ObjectDataParser._getNumber(rawData, dragonBones.DataParser.RED_MULTIPLIER, 100); + color.greenMultiplier = .01 * ObjectDataParser._getNumber(rawData, dragonBones.DataParser.GREEN_MULTIPLIER, 100); + color.blueMultiplier = .01 * ObjectDataParser._getNumber(rawData, dragonBones.DataParser.BLUE_MULTIPLIER, 100); + color.alphaOffset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ALPHA_OFFSET, 0); + color.redOffset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.RED_OFFSET, 0); + color.greenOffset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.GREEN_OFFSET, 0); + color.blueOffset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.BLUE_OFFSET, 0); + }; + ObjectDataParser.prototype._parseArray = function(rawData) { + rawData; + this._intArray.length = 0; + this._floatArray.length = 0; + this._frameIntArray.length = 0; + this._frameFloatArray.length = 0; + this._frameArray.length = 0; + this._timelineArray.length = 0; + }; + ObjectDataParser.prototype._modifyArray = function() { + this._intArray.length % Int16Array.BYTES_PER_ELEMENT !== 0 && this._intArray.push(0); + this._frameIntArray.length % Int16Array.BYTES_PER_ELEMENT !== 0 && this._frameIntArray.push(0); + this._frameArray.length % Int16Array.BYTES_PER_ELEMENT !== 0 && this._frameArray.push(0); + this._timelineArray.length % Uint16Array.BYTES_PER_ELEMENT !== 0 && this._timelineArray.push(0); + var l1 = this._intArray.length * Int16Array.BYTES_PER_ELEMENT; + var l2 = this._floatArray.length * Float32Array.BYTES_PER_ELEMENT; + var l3 = this._frameIntArray.length * Int16Array.BYTES_PER_ELEMENT; + var l4 = this._frameFloatArray.length * Float32Array.BYTES_PER_ELEMENT; + var l5 = this._frameArray.length * Int16Array.BYTES_PER_ELEMENT; + var l6 = this._timelineArray.length * Uint16Array.BYTES_PER_ELEMENT; + var lTotal = l1 + l2 + l3 + l4 + l5 + l6; + if (dragonBones.DragonBones.webAssembly) { + var shareBuffer = dragonBones.webAssemblyModule.HEAP16.buffer; + var bufferPointer = dragonBones.webAssemblyModule._malloc(lTotal); + var intArray = new Int16Array(shareBuffer, bufferPointer, this._intArray.length); + var floatArray = new Float32Array(shareBuffer, bufferPointer + l1, this._floatArray.length); + var frameIntArray = new Int16Array(shareBuffer, bufferPointer + l1 + l2, this._frameIntArray.length); + var frameFloatArray = new Float32Array(shareBuffer, bufferPointer + l1 + l2 + l3, this._frameFloatArray.length); + var frameArray = new Int16Array(shareBuffer, bufferPointer + l1 + l2 + l3 + l4, this._frameArray.length); + var timelineArray = new Uint16Array(shareBuffer, bufferPointer + l1 + l2 + l3 + l4 + l5, this._timelineArray.length); + for (var i = 0, l = this._intArray.length; i < l; ++i) intArray[i] = this._intArray[i]; + for (var i = 0, l = this._floatArray.length; i < l; ++i) floatArray[i] = this._floatArray[i]; + for (var i = 0, l = this._frameIntArray.length; i < l; ++i) frameIntArray[i] = this._frameIntArray[i]; + for (var i = 0, l = this._frameFloatArray.length; i < l; ++i) frameFloatArray[i] = this._frameFloatArray[i]; + for (var i = 0, l = this._frameArray.length; i < l; ++i) frameArray[i] = this._frameArray[i]; + for (var i = 0, l = this._timelineArray.length; i < l; ++i) timelineArray[i] = this._timelineArray[i]; + dragonBones.webAssemblyModule.setDataBinary(this._data, bufferPointer, l1, l2, l3, l4, l5, l6); + } else { + var binary = new ArrayBuffer(lTotal); + var intArray = new Int16Array(binary, 0, this._intArray.length); + var floatArray = new Float32Array(binary, l1, this._floatArray.length); + var frameIntArray = new Int16Array(binary, l1 + l2, this._frameIntArray.length); + var frameFloatArray = new Float32Array(binary, l1 + l2 + l3, this._frameFloatArray.length); + var frameArray = new Int16Array(binary, l1 + l2 + l3 + l4, this._frameArray.length); + var timelineArray = new Uint16Array(binary, l1 + l2 + l3 + l4 + l5, this._timelineArray.length); + for (var i = 0, l = this._intArray.length; i < l; ++i) intArray[i] = this._intArray[i]; + for (var i = 0, l = this._floatArray.length; i < l; ++i) floatArray[i] = this._floatArray[i]; + for (var i = 0, l = this._frameIntArray.length; i < l; ++i) frameIntArray[i] = this._frameIntArray[i]; + for (var i = 0, l = this._frameFloatArray.length; i < l; ++i) frameFloatArray[i] = this._frameFloatArray[i]; + for (var i = 0, l = this._frameArray.length; i < l; ++i) frameArray[i] = this._frameArray[i]; + for (var i = 0, l = this._timelineArray.length; i < l; ++i) timelineArray[i] = this._timelineArray[i]; + this._data.binary = binary; + this._data.intArray = intArray; + this._data.floatArray = floatArray; + this._data.frameIntArray = frameIntArray; + this._data.frameFloatArray = frameFloatArray; + this._data.frameArray = frameArray; + this._data.timelineArray = timelineArray; + } + this._defaultColorOffset = -1; + }; + ObjectDataParser.prototype.parseDragonBonesData = function(rawData, scale) { + void 0 === scale && (scale = 1); + console.assert(null !== rawData && void 0 !== rawData, "Data error."); + var version = ObjectDataParser._getString(rawData, dragonBones.DataParser.VERSION, ""); + var compatibleVersion = ObjectDataParser._getString(rawData, dragonBones.DataParser.COMPATIBLE_VERSION, ""); + if (dragonBones.DataParser.DATA_VERSIONS.indexOf(version) >= 0 || dragonBones.DataParser.DATA_VERSIONS.indexOf(compatibleVersion) >= 0) { + var data = dragonBones.BaseObject.borrowObject(dragonBones.DragonBonesData); + data.version = version; + data.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); + data.frameRate = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.FRAME_RATE, 24); + 0 === data.frameRate && (data.frameRate = 24); + if (dragonBones.DataParser.ARMATURE in rawData) { + this._data = data; + this._parseArray(rawData); + var rawArmatures = rawData[dragonBones.DataParser.ARMATURE]; + for (var _i = 0, rawArmatures_1 = rawArmatures; _i < rawArmatures_1.length; _i++) { + var rawArmature = rawArmatures_1[_i]; + data.addArmature(this._parseArmature(rawArmature, scale)); + } + this._data.binary || this._modifyArray(); + dragonBones.DataParser.STAGE in rawData ? data.stage = data.getArmature(ObjectDataParser._getString(rawData, dragonBones.DataParser.STAGE, "")) : data.armatureNames.length > 0 && (data.stage = data.getArmature(data.armatureNames[0])); + this._data = null; + } + dragonBones.DataParser.TEXTURE_ATLAS in rawData && (this._rawTextureAtlases = rawData[dragonBones.DataParser.TEXTURE_ATLAS]); + return data; + } + console.assert(false, "Nonsupport data version: " + version + "\nPlease convert DragonBones data to support version.\nRead more: https://github.com/DragonBones/Tools/"); + return null; + }; + ObjectDataParser.prototype.parseTextureAtlasData = function(rawData, textureAtlasData, scale) { + void 0 === scale && (scale = 1); + console.assert(void 0 !== rawData); + if (null === rawData) { + if (null === this._rawTextureAtlases || 0 === this._rawTextureAtlases.length) return false; + var rawTextureAtlas = this._rawTextureAtlases[this._rawTextureAtlasIndex++]; + this.parseTextureAtlasData(rawTextureAtlas, textureAtlasData, scale); + if (this._rawTextureAtlasIndex >= this._rawTextureAtlases.length) { + this._rawTextureAtlasIndex = 0; + this._rawTextureAtlases = null; + } + return true; + } + textureAtlasData.width = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.WIDTH, 0); + textureAtlasData.height = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.HEIGHT, 0); + textureAtlasData.scale = 1 === scale ? 1 / ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SCALE, 1) : scale; + textureAtlasData.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); + textureAtlasData.imagePath = ObjectDataParser._getString(rawData, dragonBones.DataParser.IMAGE_PATH, ""); + if (dragonBones.DataParser.SUB_TEXTURE in rawData) { + var rawTextures = rawData[dragonBones.DataParser.SUB_TEXTURE]; + for (var i = 0, l = rawTextures.length; i < l; ++i) { + var rawTexture = rawTextures[i]; + var textureData = textureAtlasData.createTexture(); + textureData.rotated = ObjectDataParser._getBoolean(rawTexture, dragonBones.DataParser.ROTATED, false); + textureData.name = ObjectDataParser._getString(rawTexture, dragonBones.DataParser.NAME, ""); + textureData.region.x = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.X, 0); + textureData.region.y = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.Y, 0); + textureData.region.width = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.WIDTH, 0); + textureData.region.height = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.HEIGHT, 0); + var frameWidth = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.FRAME_WIDTH, -1); + var frameHeight = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.FRAME_HEIGHT, -1); + if (frameWidth > 0 && frameHeight > 0) { + textureData.frame = dragonBones.TextureData.createRectangle(); + textureData.frame.x = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.FRAME_X, 0); + textureData.frame.y = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.FRAME_Y, 0); + textureData.frame.width = frameWidth; + textureData.frame.height = frameHeight; + } + textureAtlasData.addTexture(textureData); + } + } + return true; + }; + ObjectDataParser.getInstance = function() { + null === ObjectDataParser._objectDataParserInstance && (ObjectDataParser._objectDataParserInstance = new ObjectDataParser()); + return ObjectDataParser._objectDataParserInstance; + }; + ObjectDataParser._objectDataParserInstance = null; + return ObjectDataParser; + })(dragonBones.DataParser); + dragonBones.ObjectDataParser = ObjectDataParser; + var ActionFrame = (function() { + function ActionFrame() { + this.frameStart = 0; + this.actions = []; + } + return ActionFrame; + })(); + dragonBones.ActionFrame = ActionFrame; + })(dragonBones || (dragonBones = {})); + var dragonBones; + (function(dragonBones) { + var BinaryDataParser = (function(_super) { + __extends(BinaryDataParser, _super); + function BinaryDataParser() { + return null !== _super && _super.apply(this, arguments) || this; + } + BinaryDataParser.prototype._inRange = function(a, min, max) { + return min <= a && a <= max; + }; + BinaryDataParser.prototype._decodeUTF8 = function(data) { + var EOF_byte = -1; + var EOF_code_point = -1; + var FATAL_POINT = 65533; + var pos = 0; + var result = ""; + var code_point; + var utf8_code_point = 0; + var utf8_bytes_needed = 0; + var utf8_bytes_seen = 0; + var utf8_lower_boundary = 0; + while (data.length > pos) { + var _byte = data[pos++]; + if (_byte === EOF_byte) code_point = 0 !== utf8_bytes_needed ? FATAL_POINT : EOF_code_point; else if (0 === utf8_bytes_needed) if (this._inRange(_byte, 0, 127)) code_point = _byte; else { + if (this._inRange(_byte, 194, 223)) { + utf8_bytes_needed = 1; + utf8_lower_boundary = 128; + utf8_code_point = _byte - 192; + } else if (this._inRange(_byte, 224, 239)) { + utf8_bytes_needed = 2; + utf8_lower_boundary = 2048; + utf8_code_point = _byte - 224; + } else if (this._inRange(_byte, 240, 244)) { + utf8_bytes_needed = 3; + utf8_lower_boundary = 65536; + utf8_code_point = _byte - 240; + } + utf8_code_point *= Math.pow(64, utf8_bytes_needed); + code_point = null; + } else if (this._inRange(_byte, 128, 191)) { + utf8_bytes_seen += 1; + utf8_code_point += (_byte - 128) * Math.pow(64, utf8_bytes_needed - utf8_bytes_seen); + if (utf8_bytes_seen !== utf8_bytes_needed) code_point = null; else { + var cp = utf8_code_point; + var lower_boundary = utf8_lower_boundary; + utf8_code_point = 0; + utf8_bytes_needed = 0; + utf8_bytes_seen = 0; + utf8_lower_boundary = 0; + code_point = this._inRange(cp, lower_boundary, 1114111) && !this._inRange(cp, 55296, 57343) ? cp : _byte; + } + } else { + utf8_code_point = 0; + utf8_bytes_needed = 0; + utf8_bytes_seen = 0; + utf8_lower_boundary = 0; + pos--; + code_point = _byte; + } + if (null !== code_point && code_point !== EOF_code_point) if (code_point <= 65535) code_point > 0 && (result += String.fromCharCode(code_point)); else { + code_point -= 65536; + result += String.fromCharCode(55296 + (code_point >> 10 & 1023)); + result += String.fromCharCode(56320 + (1023 & code_point)); + } + } + return result; + }; + BinaryDataParser.prototype._getUTF16Key = function(value) { + for (var i = 0, l = value.length; i < l; ++i) if (value.charCodeAt(i) > 255) return encodeURI(value); + return value; + }; + BinaryDataParser.prototype._parseBinaryTimeline = function(type, offset, timelineData) { + void 0 === timelineData && (timelineData = null); + var timeline = null !== timelineData ? timelineData : dragonBones.BaseObject.borrowObject(dragonBones.TimelineData); + timeline.type = type; + timeline.offset = offset; + this._timeline = timeline; + var keyFrameCount = this._timelineArrayBuffer[timeline.offset + 2]; + if (1 === keyFrameCount) timeline.frameIndicesOffset = -1; else { + var frameIndicesOffset = 0; + var totalFrameCount = this._animation.frameCount + 1; + var frameIndices = this._data.frameIndices; + if (dragonBones.DragonBones.webAssembly) { + frameIndicesOffset = frameIndices.size(); + frameIndices.resize(frameIndicesOffset + totalFrameCount, 0); + } else { + frameIndicesOffset = frameIndices.length; + frameIndices.length += totalFrameCount; + } + timeline.frameIndicesOffset = frameIndicesOffset; + for (var i = 0, iK = 0, frameStart = 0, frameCount = 0; i < totalFrameCount; ++i) { + if (frameStart + frameCount <= i && iK < keyFrameCount) { + frameStart = this._frameArrayBuffer[this._animation.frameOffset + this._timelineArrayBuffer[timeline.offset + 5 + iK]]; + frameCount = iK === keyFrameCount - 1 ? this._animation.frameCount - frameStart : this._frameArrayBuffer[this._animation.frameOffset + this._timelineArrayBuffer[timeline.offset + 5 + iK + 1]] - frameStart; + iK++; + } + dragonBones.DragonBones.webAssembly ? frameIndices.set(frameIndicesOffset + i, iK - 1) : frameIndices[frameIndicesOffset + i] = iK - 1; + } + } + this._timeline = null; + return timeline; + }; + BinaryDataParser.prototype._parseVertices = function(rawData, vertices) { + vertices.offset = rawData[dragonBones.DataParser.OFFSET]; + var weightOffset = this._intArrayBuffer[vertices.offset + 3]; + if (weightOffset >= 0) { + var weight = dragonBones.BaseObject.borrowObject(dragonBones.WeightData); + var vertexCount = this._intArrayBuffer[vertices.offset + 0]; + var boneCount = this._intArrayBuffer[weightOffset + 0]; + weight.offset = weightOffset; + for (var i = 0; i < boneCount; ++i) { + var boneIndex = this._intArrayBuffer[weightOffset + 2 + i]; + weight.addBone(this._rawBones[boneIndex]); + } + var boneIndicesOffset = weightOffset + 2 + boneCount; + var weightCount = 0; + for (var i = 0, l = vertexCount; i < l; ++i) { + var vertexBoneCount = this._intArrayBuffer[boneIndicesOffset++]; + weightCount += vertexBoneCount; + boneIndicesOffset += vertexBoneCount; + } + weight.count = weightCount; + vertices.weight = weight; + } + }; + BinaryDataParser.prototype._parseMesh = function(rawData, mesh) { + this._parseVertices(rawData, mesh.vertices); + }; + BinaryDataParser.prototype._parsePath = function(rawData, path) { + this._parseVertices(rawData, path.vertices); + }; + BinaryDataParser.prototype._parseAnimation = function(rawData) { + var animation = dragonBones.BaseObject.borrowObject(dragonBones.AnimationData); + animation.frameCount = Math.max(dragonBones.ObjectDataParser._getNumber(rawData, dragonBones.DataParser.DURATION, 1), 1); + animation.playTimes = dragonBones.ObjectDataParser._getNumber(rawData, dragonBones.DataParser.PLAY_TIMES, 1); + animation.duration = animation.frameCount / this._armature.frameRate; + animation.fadeInTime = dragonBones.ObjectDataParser._getNumber(rawData, dragonBones.DataParser.FADE_IN_TIME, 0); + animation.scale = dragonBones.ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SCALE, 1); + animation.name = dragonBones.ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, dragonBones.DataParser.DEFAULT_NAME); + 0 === animation.name.length && (animation.name = dragonBones.DataParser.DEFAULT_NAME); + var offsets = rawData[dragonBones.DataParser.OFFSET]; + animation.frameIntOffset = offsets[0]; + animation.frameFloatOffset = offsets[1]; + animation.frameOffset = offsets[2]; + this._animation = animation; + dragonBones.DataParser.ACTION in rawData && (animation.actionTimeline = this._parseBinaryTimeline(0, rawData[dragonBones.DataParser.ACTION])); + dragonBones.DataParser.Z_ORDER in rawData && (animation.zOrderTimeline = this._parseBinaryTimeline(1, rawData[dragonBones.DataParser.Z_ORDER])); + if (dragonBones.DataParser.BONE in rawData) { + var rawTimeliness = rawData[dragonBones.DataParser.BONE]; + for (var k in rawTimeliness) { + var rawTimelines = rawTimeliness[k]; + dragonBones.DragonBones.webAssembly && (k = this._getUTF16Key(k)); + var bone = this._armature.getBone(k); + if (null === bone) continue; + for (var i = 0, l = rawTimelines.length; i < l; i += 2) { + var timelineType = rawTimelines[i]; + var timelineOffset = rawTimelines[i + 1]; + var timeline = this._parseBinaryTimeline(timelineType, timelineOffset); + this._animation.addBoneTimeline(bone, timeline); + } + } + } + if (dragonBones.DataParser.SURFACE in rawData) { + var rawTimeliness = rawData[dragonBones.DataParser.SURFACE]; + for (var k in rawTimeliness) { + var rawTimelines = rawTimeliness[k]; + dragonBones.DragonBones.webAssembly && (k = this._getUTF16Key(k)); + var surface = this._armature.getBone(k); + if (null === surface) continue; + for (var i = 0, l = rawTimelines.length; i < l; i += 2) { + var timelineType = rawTimelines[i]; + var timelineOffset = rawTimelines[i + 1]; + var timeline = this._parseBinaryTimeline(timelineType, timelineOffset); + this._animation.addSurfaceTimeline(surface, timeline); + } + } + } + if (dragonBones.DataParser.SLOT in rawData) { + var rawTimeliness = rawData[dragonBones.DataParser.SLOT]; + for (var k in rawTimeliness) { + var rawTimelines = rawTimeliness[k]; + dragonBones.DragonBones.webAssembly && (k = this._getUTF16Key(k)); + var slot = this._armature.getSlot(k); + if (null === slot) continue; + for (var i = 0, l = rawTimelines.length; i < l; i += 2) { + var timelineType = rawTimelines[i]; + var timelineOffset = rawTimelines[i + 1]; + var timeline = this._parseBinaryTimeline(timelineType, timelineOffset); + this._animation.addSlotTimeline(slot, timeline); + } + } + } + if (dragonBones.DataParser.CONSTRAINT in rawData) { + var rawTimeliness = rawData[dragonBones.DataParser.CONSTRAINT]; + for (var k in rawTimeliness) { + var rawTimelines = rawTimeliness[k]; + dragonBones.DragonBones.webAssembly && (k = this._getUTF16Key(k)); + var constraint = this._armature.getConstraint(k); + if (null === constraint) continue; + for (var i = 0, l = rawTimelines.length; i < l; i += 2) { + var timelineType = rawTimelines[i]; + var timelineOffset = rawTimelines[i + 1]; + var timeline = this._parseBinaryTimeline(timelineType, timelineOffset); + this._animation.addConstraintTimeline(constraint, timeline); + } + } + } + if (dragonBones.DataParser.ANIMATION in rawData) { + var rawTimeliness = rawData[dragonBones.DataParser.ANIMATION]; + for (var k in rawTimeliness) { + var rawTimelines = rawTimeliness[k]; + dragonBones.DragonBones.webAssembly && (k = this._getUTF16Key(k)); + for (var i = 0, l = rawTimelines.length; i < l; i += 2) { + var timelineType = rawTimelines[i]; + var timelineOffset = rawTimelines[i + 1]; + var timeline = this._parseBinaryTimeline(timelineType, timelineOffset); + this._animation.addAnimationTimeline(k, timeline); + } + } + } + this._animation = null; + return animation; + }; + BinaryDataParser.prototype._parseArray = function(rawData) { + var offsets = rawData[dragonBones.DataParser.OFFSET]; + var l1 = offsets[1]; + var l2 = offsets[3]; + var l3 = offsets[5]; + var l4 = offsets[7]; + var l5 = offsets[9]; + var l6 = offsets[11]; + var intArray = new Int16Array(this._binary, this._binaryOffset + offsets[0], l1 / Int16Array.BYTES_PER_ELEMENT); + var floatArray = new Float32Array(this._binary, this._binaryOffset + offsets[2], l2 / Float32Array.BYTES_PER_ELEMENT); + var frameIntArray = new Int16Array(this._binary, this._binaryOffset + offsets[4], l3 / Int16Array.BYTES_PER_ELEMENT); + var frameFloatArray = new Float32Array(this._binary, this._binaryOffset + offsets[6], l4 / Float32Array.BYTES_PER_ELEMENT); + var frameArray = new Int16Array(this._binary, this._binaryOffset + offsets[8], l5 / Int16Array.BYTES_PER_ELEMENT); + var timelineArray = new Uint16Array(this._binary, this._binaryOffset + offsets[10], l6 / Uint16Array.BYTES_PER_ELEMENT); + if (dragonBones.DragonBones.webAssembly) { + var lTotal = l1 + l2 + l3 + l4 + l5 + l6; + var bufferPointer = dragonBones.webAssemblyModule._malloc(lTotal); + var rawArray = new Uint8Array(this._binary, this._binaryOffset, lTotal / Uint8Array.BYTES_PER_ELEMENT); + var copyArray = new Uint8Array(dragonBones.webAssemblyModule.HEAP16.buffer, bufferPointer, rawArray.length); + for (var i = 0, l = rawArray.length; i < l; ++i) copyArray[i] = rawArray[i]; + dragonBones.webAssemblyModule.setDataBinary(this._data, bufferPointer, l1, l2, l3, l4, l5, l6); + this._intArrayBuffer = intArray; + this._floatArrayBuffer = floatArray; + this._frameIntArrayBuffer = frameIntArray; + this._frameFloatArrayBuffer = frameFloatArray; + this._frameArrayBuffer = frameArray; + this._timelineArrayBuffer = timelineArray; + } else { + this._data.binary = this._binary; + this._data.intArray = this._intArrayBuffer = intArray; + this._data.floatArray = this._floatArrayBuffer = floatArray; + this._data.frameIntArray = this._frameIntArrayBuffer = frameIntArray; + this._data.frameFloatArray = this._frameFloatArrayBuffer = frameFloatArray; + this._data.frameArray = this._frameArrayBuffer = frameArray; + this._data.timelineArray = this._timelineArrayBuffer = timelineArray; + } + }; + BinaryDataParser.prototype.parseDragonBonesData = function(rawData, scale) { + void 0 === scale && (scale = 1); + console.assert(null !== rawData && void 0 !== rawData && rawData instanceof ArrayBuffer, "Data error."); + var tag = new Uint8Array(rawData, 0, 8); + if (tag[0] !== "D".charCodeAt(0) || tag[1] !== "B".charCodeAt(0) || tag[2] !== "D".charCodeAt(0) || tag[3] !== "T".charCodeAt(0)) { + console.assert(false, "Nonsupport data."); + return null; + } + var headerLength = new Uint32Array(rawData, 8, 1)[0]; + var headerBytes = new Uint8Array(rawData, 12, headerLength); + var headerString = this._decodeUTF8(headerBytes); + var header = JSON.parse(headerString); + this._binaryOffset = 12 + headerLength; + this._binary = rawData; + return _super.prototype.parseDragonBonesData.call(this, header, scale); + }; + BinaryDataParser.getInstance = function() { + null === BinaryDataParser._binaryDataParserInstance && (BinaryDataParser._binaryDataParserInstance = new BinaryDataParser()); + return BinaryDataParser._binaryDataParserInstance; + }; + BinaryDataParser._binaryDataParserInstance = null; + return BinaryDataParser; + })(dragonBones.ObjectDataParser); + dragonBones.BinaryDataParser = BinaryDataParser; + })(dragonBones || (dragonBones = {})); + var dragonBones; + (function(dragonBones) { + var BaseFactory = (function() { + function BaseFactory(dataParser) { + void 0 === dataParser && (dataParser = null); + this.autoSearch = false; + this._dragonBonesDataMap = {}; + this._textureAtlasDataMap = {}; + this._dragonBones = null; + this._dataParser = null; + null === BaseFactory._objectParser && (BaseFactory._objectParser = new dragonBones.ObjectDataParser()); + null === BaseFactory._binaryParser && (BaseFactory._binaryParser = new dragonBones.BinaryDataParser()); + this._dataParser = null !== dataParser ? dataParser : BaseFactory._objectParser; + } + BaseFactory.prototype._isSupportMesh = function() { + return true; + }; + BaseFactory.prototype._getTextureData = function(textureAtlasName, textureName) { + if (textureAtlasName in this._textureAtlasDataMap) for (var _i = 0, _a = this._textureAtlasDataMap[textureAtlasName]; _i < _a.length; _i++) { + var textureAtlasData = _a[_i]; + var textureData = textureAtlasData.getTexture(textureName); + if (null !== textureData) return textureData; + } + if (this.autoSearch) for (var k in this._textureAtlasDataMap) for (var _b = 0, _c = this._textureAtlasDataMap[k]; _b < _c.length; _b++) { + var textureAtlasData = _c[_b]; + if (textureAtlasData.autoSearch) { + var textureData = textureAtlasData.getTexture(textureName); + if (null !== textureData) return textureData; + } + } + return null; + }; + BaseFactory.prototype._fillBuildArmaturePackage = function(dataPackage, dragonBonesName, armatureName, skinName, textureAtlasName) { + var dragonBonesData = null; + var armatureData = null; + if (dragonBonesName.length > 0 && dragonBonesName in this._dragonBonesDataMap) { + dragonBonesData = this._dragonBonesDataMap[dragonBonesName]; + armatureData = dragonBonesData.getArmature(armatureName); + } + if (null === armatureData && (0 === dragonBonesName.length || this.autoSearch)) for (var k in this._dragonBonesDataMap) { + dragonBonesData = this._dragonBonesDataMap[k]; + if (0 === dragonBonesName.length || dragonBonesData.autoSearch) { + armatureData = dragonBonesData.getArmature(armatureName); + if (null !== armatureData) { + dragonBonesName = k; + break; + } + } + } + if (null !== armatureData) { + dataPackage.dataName = dragonBonesName; + dataPackage.textureAtlasName = textureAtlasName; + dataPackage.data = dragonBonesData; + dataPackage.armature = armatureData; + dataPackage.skin = null; + if (skinName.length > 0) { + dataPackage.skin = armatureData.getSkin(skinName); + if (null === dataPackage.skin && this.autoSearch) for (var k in this._dragonBonesDataMap) { + var skinDragonBonesData = this._dragonBonesDataMap[k]; + var skinArmatureData = skinDragonBonesData.getArmature(skinName); + if (null !== skinArmatureData) { + dataPackage.skin = skinArmatureData.defaultSkin; + break; + } + } + } + null === dataPackage.skin && (dataPackage.skin = armatureData.defaultSkin); + return true; + } + return false; + }; + BaseFactory.prototype._buildBones = function(dataPackage, armature) { + for (var _i = 0, _a = dataPackage.armature.sortedBones; _i < _a.length; _i++) { + var boneData = _a[_i]; + var bone = dragonBones.BaseObject.borrowObject(0 === boneData.type ? dragonBones.Bone : dragonBones.Surface); + bone.init(boneData, armature); + } + }; + BaseFactory.prototype._buildSlots = function(dataPackage, armature) { + var currentSkin = dataPackage.skin; + var defaultSkin = dataPackage.armature.defaultSkin; + if (null === currentSkin || null === defaultSkin) return; + var skinSlots = {}; + for (var k in defaultSkin.displays) { + var displays = defaultSkin.getDisplays(k); + skinSlots[k] = displays; + } + if (currentSkin !== defaultSkin) for (var k in currentSkin.displays) { + var displays = currentSkin.getDisplays(k); + skinSlots[k] = displays; + } + for (var _i = 0, _a = dataPackage.armature.sortedSlots; _i < _a.length; _i++) { + var slotData = _a[_i]; + var displayDatas = slotData.name in skinSlots ? skinSlots[slotData.name] : null; + var slot = this._buildSlot(dataPackage, slotData, armature); + slot.rawDisplayDatas = displayDatas; + if (null !== displayDatas) { + var displayList = new Array(); + for (var i = 0, l = dragonBones.DragonBones.webAssembly ? displayDatas.size() : displayDatas.length; i < l; ++i) { + var displayData = dragonBones.DragonBones.webAssembly ? displayDatas.get(i) : displayDatas[i]; + null !== displayData ? displayList.push(this._getSlotDisplay(dataPackage, displayData, null, slot)) : displayList.push(null); + } + slot._setDisplayList(displayList); + } + slot._setDisplayIndex(slotData.displayIndex, true); + } + }; + BaseFactory.prototype._buildConstraints = function(dataPackage, armature) { + var constraints = dataPackage.armature.constraints; + for (var k in constraints) { + var constraintData = constraints[k]; + switch (constraintData.type) { + case 0: + var ikConstraint = dragonBones.BaseObject.borrowObject(dragonBones.IKConstraint); + ikConstraint.init(constraintData, armature); + armature._addConstraint(ikConstraint); + break; + + case 1: + var pathConstraint = dragonBones.BaseObject.borrowObject(dragonBones.PathConstraint); + pathConstraint.init(constraintData, armature); + armature._addConstraint(pathConstraint); + break; + + default: + var constraint = dragonBones.BaseObject.borrowObject(dragonBones.IKConstraint); + constraint.init(constraintData, armature); + armature._addConstraint(constraint); + } + } + }; + BaseFactory.prototype._buildChildArmature = function(dataPackage, slot, displayData) { + slot; + return this.buildArmature(displayData.path, null !== dataPackage ? dataPackage.dataName : "", "", null !== dataPackage ? dataPackage.textureAtlasName : ""); + }; + BaseFactory.prototype._getSlotDisplay = function(dataPackage, displayData, rawDisplayData, slot) { + var dataName = null !== dataPackage ? dataPackage.dataName : displayData.parent.parent.parent.name; + var display = null; + switch (displayData.type) { + case 0: + var imageDisplayData = displayData; + null !== dataPackage && dataPackage.textureAtlasName.length > 0 && (imageDisplayData.texture = this._getTextureData(dataPackage.textureAtlasName, displayData.path)); + null === imageDisplayData.texture && (imageDisplayData.texture = this._getTextureData(dataName, displayData.path)); + display = null !== rawDisplayData && 2 === rawDisplayData.type && this._isSupportMesh() ? slot.meshDisplay : slot.rawDisplay; + break; + + case 2: + var meshDisplayData = displayData; + null !== dataPackage && dataPackage.textureAtlasName.length > 0 && (meshDisplayData.texture = this._getTextureData(dataPackage.textureAtlasName, meshDisplayData.path)); + null === meshDisplayData.texture && (meshDisplayData.texture = this._getTextureData(dataName, meshDisplayData.path)); + display = this._isSupportMesh() ? slot.meshDisplay : slot.rawDisplay; + break; + + case 1: + var armatureDisplayData = displayData; + var childArmature = this._buildChildArmature(dataPackage, slot, displayData); + if (null !== childArmature) { + childArmature.inheritAnimation = armatureDisplayData.inheritAnimation; + if (!childArmature.inheritAnimation) { + var actions = armatureDisplayData.actions.length > 0 ? armatureDisplayData.actions : childArmature.armatureData.defaultActions; + if (actions.length > 0) for (var _i = 0, actions_6 = actions; _i < actions_6.length; _i++) { + var action = actions_6[_i]; + var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); + dragonBones.EventObject.actionDataToInstance(action, eventObject, slot.armature); + eventObject.slot = slot; + slot.armature._bufferAction(eventObject, false); + } else childArmature.animation.play(); + } + armatureDisplayData.armature = childArmature.armatureData; + } + display = childArmature; + } + return display; + }; + BaseFactory.prototype.parseDragonBonesData = function(rawData, name, scale) { + void 0 === name && (name = null); + void 0 === scale && (scale = 1); + var dataParser = rawData instanceof ArrayBuffer ? BaseFactory._binaryParser : this._dataParser; + var dragonBonesData = dataParser.parseDragonBonesData(rawData, scale); + while (true) { + var textureAtlasData = this._buildTextureAtlasData(null, null); + if (!dataParser.parseTextureAtlasData(null, textureAtlasData, scale)) { + textureAtlasData.returnToPool(); + break; + } + this.addTextureAtlasData(textureAtlasData, name); + } + null !== dragonBonesData && this.addDragonBonesData(dragonBonesData, name); + return dragonBonesData; + }; + BaseFactory.prototype.parseTextureAtlasData = function(rawData, textureAtlas, name, scale) { + void 0 === name && (name = null); + void 0 === scale && (scale = 1); + var textureAtlasData = this._buildTextureAtlasData(null, null); + this._dataParser.parseTextureAtlasData(rawData, textureAtlasData, scale); + this._buildTextureAtlasData(textureAtlasData, textureAtlas || null); + this.addTextureAtlasData(textureAtlasData, name); + return textureAtlasData; + }; + BaseFactory.prototype.updateTextureAtlasData = function(name, textureAtlases) { + var textureAtlasDatas = this.getTextureAtlasData(name); + if (null !== textureAtlasDatas) for (var i = 0, l = textureAtlasDatas.length; i < l; ++i) i < textureAtlases.length && this._buildTextureAtlasData(textureAtlasDatas[i], textureAtlases[i]); + }; + BaseFactory.prototype.getDragonBonesData = function(name) { + return name in this._dragonBonesDataMap ? this._dragonBonesDataMap[name] : null; + }; + BaseFactory.prototype.addDragonBonesData = function(data, name) { + void 0 === name && (name = null); + name = null !== name ? name : data.name; + if (name in this._dragonBonesDataMap) { + if (this._dragonBonesDataMap[name] === data) return; + console.warn("Can not add same name data: " + name); + return; + } + this._dragonBonesDataMap[name] = data; + }; + BaseFactory.prototype.removeDragonBonesData = function(name, disposeData) { + void 0 === disposeData && (disposeData = true); + if (name in this._dragonBonesDataMap) { + disposeData && this._dragonBones.bufferObject(this._dragonBonesDataMap[name]); + delete this._dragonBonesDataMap[name]; + } + }; + BaseFactory.prototype.getTextureAtlasData = function(name) { + return name in this._textureAtlasDataMap ? this._textureAtlasDataMap[name] : null; + }; + BaseFactory.prototype.addTextureAtlasData = function(data, name) { + void 0 === name && (name = null); + name = null !== name ? name : data.name; + var textureAtlasList = name in this._textureAtlasDataMap ? this._textureAtlasDataMap[name] : this._textureAtlasDataMap[name] = []; + textureAtlasList.indexOf(data) < 0 && textureAtlasList.push(data); + }; + BaseFactory.prototype.removeTextureAtlasData = function(name, disposeData) { + void 0 === disposeData && (disposeData = true); + if (name in this._textureAtlasDataMap) { + var textureAtlasDataList = this._textureAtlasDataMap[name]; + if (disposeData) for (var _i = 0, textureAtlasDataList_1 = textureAtlasDataList; _i < textureAtlasDataList_1.length; _i++) { + var textureAtlasData = textureAtlasDataList_1[_i]; + this._dragonBones.bufferObject(textureAtlasData); + } + delete this._textureAtlasDataMap[name]; + } + }; + BaseFactory.prototype.getArmatureData = function(name, dragonBonesName) { + void 0 === dragonBonesName && (dragonBonesName = ""); + var dataPackage = new BuildArmaturePackage(); + if (!this._fillBuildArmaturePackage(dataPackage, dragonBonesName, name, "", "")) return null; + return dataPackage.armature; + }; + BaseFactory.prototype.clear = function(disposeData) { + void 0 === disposeData && (disposeData = true); + for (var k in this._dragonBonesDataMap) { + disposeData && this._dragonBones.bufferObject(this._dragonBonesDataMap[k]); + delete this._dragonBonesDataMap[k]; + } + for (var k in this._textureAtlasDataMap) { + if (disposeData) { + var textureAtlasDataList = this._textureAtlasDataMap[k]; + for (var _i = 0, textureAtlasDataList_2 = textureAtlasDataList; _i < textureAtlasDataList_2.length; _i++) { + var textureAtlasData = textureAtlasDataList_2[_i]; + this._dragonBones.bufferObject(textureAtlasData); + } + } + delete this._textureAtlasDataMap[k]; + } + }; + BaseFactory.prototype.buildArmature = function(armatureName, dragonBonesName, skinName, textureAtlasName) { + void 0 === dragonBonesName && (dragonBonesName = ""); + void 0 === skinName && (skinName = ""); + void 0 === textureAtlasName && (textureAtlasName = ""); + var dataPackage = new BuildArmaturePackage(); + if (!this._fillBuildArmaturePackage(dataPackage, dragonBonesName || "", armatureName, skinName || "", textureAtlasName || "")) { + console.warn("No armature data: " + armatureName + ", " + (null !== dragonBonesName ? dragonBonesName : "")); + return null; + } + var armature = this._buildArmature(dataPackage); + this._buildBones(dataPackage, armature); + this._buildSlots(dataPackage, armature); + this._buildConstraints(dataPackage, armature); + armature.invalidUpdate(null, true); + armature.advanceTime(0); + return armature; + }; + BaseFactory.prototype.replaceDisplay = function(slot, displayData, displayIndex) { + void 0 === displayIndex && (displayIndex = -1); + displayIndex < 0 && (displayIndex = slot.displayIndex); + displayIndex < 0 && (displayIndex = 0); + slot.replaceDisplayData(displayData, displayIndex); + var displayList = slot.displayList; + if (displayList.length <= displayIndex) { + displayList.length = displayIndex + 1; + for (var i = 0, l = displayList.length; i < l; ++i) displayList[i] || (displayList[i] = null); + } + if (null !== displayData) { + var rawDisplayDatas = slot.rawDisplayDatas; + var rawDisplayData = null; + rawDisplayDatas && (dragonBones.DragonBones.webAssembly ? displayIndex < rawDisplayDatas.size() && (rawDisplayData = rawDisplayDatas.get(displayIndex)) : displayIndex < rawDisplayDatas.length && (rawDisplayData = rawDisplayDatas[displayIndex])); + displayList[displayIndex] = this._getSlotDisplay(null, displayData, rawDisplayData, slot); + } else displayList[displayIndex] = null; + slot.displayList = displayList; + }; + BaseFactory.prototype.replaceSlotDisplay = function(dragonBonesName, armatureName, slotName, displayName, slot, displayIndex) { + void 0 === displayIndex && (displayIndex = -1); + var armatureData = this.getArmatureData(armatureName, dragonBonesName || ""); + if (!armatureData || !armatureData.defaultSkin) return false; + var displayData = armatureData.defaultSkin.getDisplay(slotName, displayName); + if (!displayData) return false; + this.replaceDisplay(slot, displayData, displayIndex); + return true; + }; + BaseFactory.prototype.replaceSlotDisplayList = function(dragonBonesName, armatureName, slotName, slot) { + var armatureData = this.getArmatureData(armatureName, dragonBonesName || ""); + if (!armatureData || !armatureData.defaultSkin) return false; + var displays = armatureData.defaultSkin.getDisplays(slotName); + if (!displays) return false; + var displayIndex = 0; + for (var i = 0, l = dragonBones.DragonBones.webAssembly ? displays.size() : displays.length; i < l; ++i) { + var displayData = dragonBones.DragonBones.webAssembly ? displays.get(i) : displays[i]; + this.replaceDisplay(slot, displayData, displayIndex++); + } + return true; + }; + BaseFactory.prototype.replaceSkin = function(armature, skin, isOverride, exclude) { + void 0 === isOverride && (isOverride = false); + void 0 === exclude && (exclude = null); + var success = false; + var defaultSkin = skin.parent.defaultSkin; + for (var _i = 0, _a = armature.getSlots(); _i < _a.length; _i++) { + var slot = _a[_i]; + if (null !== exclude && exclude.indexOf(slot.name) >= 0) continue; + var displays = skin.getDisplays(slot.name); + if (!displays) { + null !== defaultSkin && skin !== defaultSkin && (displays = defaultSkin.getDisplays(slot.name)); + if (!displays) { + if (isOverride) { + slot.rawDisplayDatas = null; + slot.displayList = []; + } + continue; + } + } + var displayCount = dragonBones.DragonBones.webAssembly ? displays.size() : displays.length; + var displayList = slot.displayList; + displayList.length = displayCount; + for (var i = 0, l = displayCount; i < l; ++i) { + var displayData = dragonBones.DragonBones.webAssembly ? displays.get(i) : displays[i]; + displayList[i] = null !== displayData ? this._getSlotDisplay(null, displayData, null, slot) : null; + } + success = true; + slot.rawDisplayDatas = displays; + slot.displayList = displayList; + } + return success; + }; + BaseFactory.prototype.replaceAnimation = function(armature, armatureData, isOverride) { + void 0 === isOverride && (isOverride = true); + var skinData = armatureData.defaultSkin; + if (null === skinData) return false; + if (isOverride) armature.animation.animations = armatureData.animations; else { + var rawAnimations = armature.animation.animations; + var animations = {}; + for (var k in rawAnimations) animations[k] = rawAnimations[k]; + for (var k in armatureData.animations) animations[k] = armatureData.animations[k]; + armature.animation.animations = animations; + } + for (var _i = 0, _a = armature.getSlots(); _i < _a.length; _i++) { + var slot = _a[_i]; + var index = 0; + for (var _b = 0, _c = slot.displayList; _b < _c.length; _b++) { + var display = _c[_b]; + if (display instanceof dragonBones.Armature) { + var displayDatas = skinData.getDisplays(slot.name); + if (null !== displayDatas && index < (dragonBones.DragonBones.webAssembly ? displayDatas.size() : displayDatas.length)) { + var displayData = dragonBones.DragonBones.webAssembly ? displayDatas.get(index) : displayDatas[index]; + if (null !== displayData && 1 === displayData.type) { + var childArmatureData = this.getArmatureData(displayData.path, displayData.parent.parent.parent.name); + childArmatureData && this.replaceAnimation(display, childArmatureData, isOverride); + } + } + } + index++; + } + } + return true; + }; + BaseFactory.prototype.getAllDragonBonesData = function() { + return this._dragonBonesDataMap; + }; + BaseFactory.prototype.getAllTextureAtlasData = function() { + return this._textureAtlasDataMap; + }; + Object.defineProperty(BaseFactory.prototype, "clock", { + get: function get() { + return this._dragonBones.clock; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(BaseFactory.prototype, "dragonBones", { + get: function get() { + return this._dragonBones; + }, + enumerable: true, + configurable: true + }); + BaseFactory.prototype.changeSkin = function(armature, skin, exclude) { + void 0 === exclude && (exclude = null); + return this.replaceSkin(armature, skin, false, exclude); + }; + BaseFactory.prototype.copyAnimationsToArmature = function(toArmature, fromArmatreName, fromSkinName, fromDragonBonesDataName, replaceOriginalAnimation) { + void 0 === fromSkinName && (fromSkinName = ""); + void 0 === fromDragonBonesDataName && (fromDragonBonesDataName = ""); + void 0 === replaceOriginalAnimation && (replaceOriginalAnimation = true); + fromSkinName; + var armatureData = this.getArmatureData(fromArmatreName, fromDragonBonesDataName); + if (!armatureData) return false; + return this.replaceAnimation(toArmature, armatureData, replaceOriginalAnimation); + }; + BaseFactory._objectParser = null; + BaseFactory._binaryParser = null; + return BaseFactory; + })(); + dragonBones.BaseFactory = BaseFactory; + var BuildArmaturePackage = (function() { + function BuildArmaturePackage() { + this.dataName = ""; + this.textureAtlasName = ""; + this.skin = null; + } + return BuildArmaturePackage; + })(); + dragonBones.BuildArmaturePackage = BuildArmaturePackage; + })(dragonBones || (dragonBones = {})); + module.exports = dragonBones; + }), {} ], + 425: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _assembler = _interopRequireDefault(require("../../cocos2d/core/renderer/assembler")); + var _mat = _interopRequireDefault(require("../../cocos2d/core/value-types/mat4")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + _setPrototypeOf(subClass, superClass); + } + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + return _setPrototypeOf(o, p); + } + var Armature = require("./ArmatureDisplay"); + var RenderFlow = require("../../cocos2d/core/renderer/render-flow"); + var gfx = cc.gfx; + var NEED_COLOR = 1; + var NEED_BATCH = 16; + var _boneColor = cc.color(255, 0, 0, 255); + var _slotColor = cc.color(0, 0, 255, 255); + var _originColor = cc.color(0, 255, 0, 255); + var _nodeR, _nodeG, _nodeB, _nodeA, _premultipliedAlpha, _multiply, _mustFlush, _buffer, _node, _renderer, _comp, _vfOffset, _indexOffset, _vertexOffset, _vertexCount, _indexCount, _x, _y, _c, _r, _g, _b, _a, _handleVal, _m00, _m04, _m12, _m01, _m05, _m13; + function _getSlotMaterial(tex, blendMode) { + if (!tex) return null; + var src, dst; + switch (blendMode) { + case 1: + src = _premultipliedAlpha ? cc.macro.ONE : cc.macro.SRC_ALPHA; + dst = cc.macro.ONE; + break; + + case 10: + src = cc.macro.DST_COLOR; + dst = cc.macro.ONE_MINUS_SRC_ALPHA; + break; + + case 12: + src = cc.macro.ONE; + dst = cc.macro.ONE_MINUS_SRC_COLOR; + break; + + case 0: + default: + src = _premultipliedAlpha ? cc.macro.ONE : cc.macro.SRC_ALPHA; + dst = cc.macro.ONE_MINUS_SRC_ALPHA; + } + var useModel = !_comp.enableBatch; + var baseMaterial = _comp._materials[0]; + if (!baseMaterial) return null; + var materialCache = _comp._materialCache; + var key = tex.getId() + src + dst + useModel; + var material = materialCache[key]; + if (!material) { + if (materialCache.baseMaterial) material = cc.MaterialVariant.create(baseMaterial); else { + material = baseMaterial; + materialCache.baseMaterial = baseMaterial; + } + material.define("CC_USE_MODEL", useModel); + material.setProperty("texture", tex); + material.setBlend(true, gfx.BLEND_FUNC_ADD, src, dst, gfx.BLEND_FUNC_ADD, src, dst); + materialCache[key] = material; + } + return material; + } + function _handleColor(color, parentOpacity) { + _a = color.a * parentOpacity * _nodeA; + _multiply = _premultipliedAlpha ? _a / 255 : 1; + _r = color.r * _nodeR * _multiply; + _g = color.g * _nodeG * _multiply; + _b = color.b * _nodeB * _multiply; + _c = (_a << 24 >>> 0) + (_b << 16) + (_g << 8) + _r; + } + var ArmatureAssembler = (function(_Assembler) { + _inheritsLoose(ArmatureAssembler, _Assembler); + function ArmatureAssembler() { + return _Assembler.apply(this, arguments) || this; + } + var _proto = ArmatureAssembler.prototype; + _proto.updateRenderData = function updateRenderData(comp, batchData) {}; + _proto.realTimeTraverse = function realTimeTraverse(armature, parentMat, parentOpacity) { + var slots = armature._slots; + var vbuf, ibuf, uintbuf; + var material; + var vertices, indices; + var slotColor; + var slot; + var slotMat; + var slotMatm; + var offsetInfo; + for (var i = 0, l = slots.length; i < l; i++) { + slot = slots[i]; + slotColor = slot._color; + if (!slot._visible || !slot._displayData) continue; + parentMat ? slot._mulMat(slot._worldMatrix, parentMat, slot._matrix) : _mat["default"].copy(slot._worldMatrix, slot._matrix); + if (slot.childArmature) { + this.realTimeTraverse(slot.childArmature, slot._worldMatrix, parentOpacity * slotColor.a / 255); + continue; + } + material = _getSlotMaterial(slot.getTexture(), slot._blendMode); + if (!material) continue; + if (_mustFlush || material.getHash() !== _renderer.material.getHash()) { + _mustFlush = false; + _renderer._flush(); + _renderer.node = _node; + _renderer.material = material; + } + _handleColor(slotColor, parentOpacity); + slotMat = slot._worldMatrix; + slotMatm = slotMat.m; + vertices = slot._localVertices; + _vertexCount = vertices.length >> 2; + indices = slot._indices; + _indexCount = indices.length; + offsetInfo = _buffer.request(_vertexCount, _indexCount); + _indexOffset = offsetInfo.indiceOffset; + _vfOffset = offsetInfo.byteOffset >> 2; + _vertexOffset = offsetInfo.vertexOffset; + vbuf = _buffer._vData; + ibuf = _buffer._iData; + uintbuf = _buffer._uintVData; + _m00 = slotMatm[0]; + _m04 = slotMatm[4]; + _m12 = slotMatm[12]; + _m01 = slotMatm[1]; + _m05 = slotMatm[5]; + _m13 = slotMatm[13]; + for (var vi = 0, vl = vertices.length; vi < vl; ) { + _x = vertices[vi++]; + _y = vertices[vi++]; + vbuf[_vfOffset++] = _x * _m00 + _y * _m04 + _m12; + vbuf[_vfOffset++] = _x * _m01 + _y * _m05 + _m13; + vbuf[_vfOffset++] = vertices[vi++]; + vbuf[_vfOffset++] = vertices[vi++]; + uintbuf[_vfOffset++] = _c; + } + for (var ii = 0, il = indices.length; ii < il; ii++) ibuf[_indexOffset++] = _vertexOffset + indices[ii]; + } + }; + _proto.cacheTraverse = function cacheTraverse(frame, parentMat) { + if (!frame) return; + var segments = frame.segments; + if (0 == segments.length) return; + var vbuf, ibuf, uintbuf; + var material; + var offsetInfo; + var vertices = frame.vertices; + var indices = frame.indices; + var frameVFOffset = 0, frameIndexOffset = 0, segVFCount = 0; + if (parentMat) { + var parentMatm = parentMat.m; + _m00 = parentMatm[0]; + _m01 = parentMatm[1]; + _m04 = parentMatm[4]; + _m05 = parentMatm[5]; + _m12 = parentMatm[12]; + _m13 = parentMatm[13]; + } + var justTranslate = 1 === _m00 && 0 === _m01 && 0 === _m04 && 1 === _m05; + var needBatch = _handleVal & NEED_BATCH; + var calcTranslate = needBatch && justTranslate; + var colorOffset = 0; + var colors = frame.colors; + var nowColor = colors[colorOffset++]; + var maxVFOffset = nowColor.vfOffset; + _handleColor(nowColor, 1); + for (var i = 0, n = segments.length; i < n; i++) { + var segInfo = segments[i]; + material = _getSlotMaterial(segInfo.tex, segInfo.blendMode); + if (_mustFlush || material.getHash() !== _renderer.material.getHash()) { + _mustFlush = false; + _renderer._flush(); + _renderer.node = _node; + _renderer.material = material; + } + _vertexCount = segInfo.vertexCount; + _indexCount = segInfo.indexCount; + offsetInfo = _buffer.request(_vertexCount, _indexCount); + _indexOffset = offsetInfo.indiceOffset; + _vertexOffset = offsetInfo.vertexOffset; + _vfOffset = offsetInfo.byteOffset >> 2; + vbuf = _buffer._vData; + ibuf = _buffer._iData; + uintbuf = _buffer._uintVData; + for (var ii = _indexOffset, il = _indexOffset + _indexCount; ii < il; ii++) ibuf[ii] = _vertexOffset + indices[frameIndexOffset++]; + segVFCount = segInfo.vfCount; + vbuf.set(vertices.subarray(frameVFOffset, frameVFOffset + segVFCount), _vfOffset); + frameVFOffset += segVFCount; + if (calcTranslate) for (var _ii = _vfOffset, _il = _vfOffset + segVFCount; _ii < _il; _ii += 5) { + vbuf[_ii] += _m12; + vbuf[_ii + 1] += _m13; + } else if (needBatch) for (var _ii2 = _vfOffset, _il2 = _vfOffset + segVFCount; _ii2 < _il2; _ii2 += 5) { + _x = vbuf[_ii2]; + _y = vbuf[_ii2 + 1]; + vbuf[_ii2] = _x * _m00 + _y * _m04 + _m12; + vbuf[_ii2 + 1] = _x * _m01 + _y * _m05 + _m13; + } + if (!(_handleVal & NEED_COLOR)) continue; + var frameColorOffset = frameVFOffset - segVFCount; + for (var _ii3 = _vfOffset + 4, _il3 = _vfOffset + 4 + segVFCount; _ii3 < _il3; _ii3 += 5, + frameColorOffset += 5) { + if (frameColorOffset >= maxVFOffset) { + nowColor = colors[colorOffset++]; + _handleColor(nowColor, 1); + maxVFOffset = nowColor.vfOffset; + } + uintbuf[_ii3] = _c; + } + } + }; + _proto.fillBuffers = function fillBuffers(comp, renderer) { + comp.node._renderFlag |= RenderFlow.FLAG_UPDATE_RENDER_DATA; + var armature = comp._armature; + if (!armature) return; + _mustFlush = true; + _premultipliedAlpha = comp.premultipliedAlpha; + _node = comp.node; + _buffer = renderer._meshBuffer; + _renderer = renderer; + _comp = comp; + _handleVal = 0; + var nodeColor = _node._color; + _nodeR = nodeColor.r / 255; + _nodeG = nodeColor.g / 255; + _nodeB = nodeColor.b / 255; + _nodeA = nodeColor.a / 255; + 4294967295 !== nodeColor._val && (_handleVal |= NEED_COLOR); + var worldMat = void 0; + if (_comp.enableBatch) { + worldMat = _node._worldMatrix; + _mustFlush = false; + _handleVal |= NEED_BATCH; + } + if (comp.isAnimationCached()) this.cacheTraverse(comp._curFrame, worldMat); else { + this.realTimeTraverse(armature, worldMat, 1); + var graphics = comp._debugDraw; + if (comp.debugBones && graphics) { + graphics.clear(); + graphics.lineWidth = 5; + graphics.strokeColor = _boneColor; + graphics.fillColor = _slotColor; + var bones = armature.getBones(); + for (var i = 0, l = bones.length; i < l; i++) { + var bone = bones[i]; + var boneLength = Math.max(bone.boneData.length, 5); + var startX = bone.globalTransformMatrix.tx; + var startY = bone.globalTransformMatrix.ty; + var endX = startX + bone.globalTransformMatrix.a * boneLength; + var endY = startY + bone.globalTransformMatrix.b * boneLength; + graphics.moveTo(startX, startY); + graphics.lineTo(endX, endY); + graphics.stroke(); + graphics.circle(startX, startY, 2 * Math.PI); + graphics.fill(); + 0 === i && (graphics.fillColor = _originColor); + } + } + } + renderer.worldMatDirty++; + comp.attachUtil._syncAttachedNode(); + _node = void 0; + _buffer = void 0; + _renderer = void 0; + _comp = void 0; + }; + _proto.postFillBuffers = function postFillBuffers(comp, renderer) { + renderer.worldMatDirty--; + }; + return ArmatureAssembler; + })(_assembler["default"]); + exports["default"] = ArmatureAssembler; + _assembler["default"].register(Armature, ArmatureAssembler); + module.exports = exports["default"]; + }), { + "../../cocos2d/core/renderer/assembler": 269, + "../../cocos2d/core/renderer/render-flow": 273, + "../../cocos2d/core/value-types/mat4": 342, + "./ArmatureDisplay": 415 + } ], + 426: [ (function(require, module, exports) { + "use strict"; + var _mat = _interopRequireDefault(require("../../cocos2d/core/value-types/mat4")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + var RenderFlow = require("../../cocos2d/core/renderer/render-flow"); + var FLAG_TRANSFORM = RenderFlow.FLAG_TRANSFORM; + var EmptyHandle = function EmptyHandle() {}; + var ATTACHED_ROOT_NAME = "ATTACHED_NODE_TREE"; + var ATTACHED_PRE_NAME = "ATTACHED_NODE:"; + var limitNode = function limitNode(node) { + Object.defineProperty(node, "_worldMatDirty", { + get: function get() { + return true; + }, + set: function set(value) {} + }); + node._calculWorldMatrix = EmptyHandle; + node._mulMat = EmptyHandle; + }; + var _tempMat4 = new _mat["default"](); + var AttachUtil = cc.Class({ + name: "sp.AttachUtil", + ctor: function ctor() { + this._inited = false; + this._skeleton = null; + this._skeletonNode = null; + this._skeletonComp = null; + this._attachedRootNode = null; + this._attachedNodeArray = []; + this._boneIndexToNode = {}; + }, + init: function init(skeletonComp) { + this._inited = true; + this._skeleton = skeletonComp._skeleton; + this._skeletonNode = skeletonComp.node; + this._skeletonComp = skeletonComp; + }, + reset: function reset() { + this._inited = false; + this._skeleton = null; + this._skeletonNode = null; + this._skeletonComp = null; + }, + _prepareAttachNode: function _prepareAttachNode() { + var armature = this._skeleton; + if (!armature) return; + var rootNode = this._skeletonNode.getChildByName(ATTACHED_ROOT_NAME); + if (!rootNode || !rootNode.isValid) { + rootNode = new cc.Node(ATTACHED_ROOT_NAME); + limitNode(rootNode); + this._skeletonNode.addChild(rootNode); + } + var isCached = this._skeletonComp.isAnimationCached(); + isCached && this._skeletonComp._frameCache && this._skeletonComp._frameCache.enableCacheAttachedInfo(); + this._attachedRootNode = rootNode; + return rootNode; + }, + _buildBoneAttachedNode: function _buildBoneAttachedNode(bone, boneIndex) { + var boneNodeName = ATTACHED_PRE_NAME + bone.data.name; + var boneNode = new cc.Node(boneNodeName); + this._buildBoneRelation(boneNode, bone, boneIndex); + return boneNode; + }, + _buildBoneRelation: function _buildBoneRelation(boneNode, bone, boneIndex) { + limitNode(boneNode); + boneNode._bone = bone; + boneNode._boneIndex = boneIndex; + this._attachedNodeArray.push(boneNode); + this._boneIndexToNode[boneIndex] = boneNode; + }, + getAttachedRootNode: function getAttachedRootNode() { + return this._attachedRootNode; + }, + getAttachedNodes: function getAttachedNodes(boneName) { + var nodeArray = this._attachedNodeArray; + var res = []; + if (!this._inited) return res; + for (var i = 0, n = nodeArray.length; i < n; i++) { + var boneNode = nodeArray[i]; + if (!boneNode || !boneNode.isValid) continue; + boneNode.name === ATTACHED_PRE_NAME + boneName && res.push(boneNode); + } + return res; + }, + _rebuildNodeArray: function _rebuildNodeArray() { + var findMap = this._boneIndexToNode = {}; + var oldNodeArray = this._attachedNodeArray; + var nodeArray = this._attachedNodeArray = []; + for (var i = 0, n = oldNodeArray.length; i < n; i++) { + var boneNode = oldNodeArray[i]; + if (!boneNode || !boneNode.isValid || boneNode._toRemove) continue; + nodeArray.push(boneNode); + findMap[boneNode._boneIndex] = boneNode; + } + }, + _sortNodeArray: function _sortNodeArray() { + var nodeArray = this._attachedNodeArray; + nodeArray.sort((function(a, b) { + return a._boneIndex < b._boneIndex ? -1 : 1; + })); + }, + _getNodeByBoneIndex: function _getNodeByBoneIndex(boneIndex) { + var findMap = this._boneIndexToNode; + var boneNode = findMap[boneIndex]; + if (!boneNode || !boneNode.isValid) return null; + return boneNode; + }, + destroyAttachedNodes: function destroyAttachedNodes(boneName) { + if (!this._inited) return; + var nodeArray = this._attachedNodeArray; + var markTree = function markTree(rootNode) { + var children = rootNode.children; + for (var i = 0, n = children.length; i < n; i++) { + var c = children[i]; + c && markTree(c); + } + rootNode._toRemove = true; + }; + for (var i = 0, n = nodeArray.length; i < n; i++) { + var boneNode = nodeArray[i]; + if (!boneNode || !boneNode.isValid) continue; + var delName = boneNode.name.split(ATTACHED_PRE_NAME)[1]; + if (delName === boneName) { + markTree(boneNode); + boneNode.removeFromParent(true); + boneNode.destroy(); + nodeArray[i] = null; + } + } + this._rebuildNodeArray(); + }, + generateAttachedNodes: function generateAttachedNodes(boneName) { + var targetNodes = []; + if (!this._inited) return targetNodes; + var rootNode = this._prepareAttachNode(); + if (!rootNode) return targetNodes; + var res = []; + var bones = this._skeleton.bones; + for (var i = 0, n = bones.length; i < n; i++) { + var bone = bones[i]; + var boneData = bone.data; + boneData.name == boneName && res.push(bone); + } + var buildBoneTree = function(bone) { + if (!bone) return; + var boneData = bone.data; + var boneNode = this._getNodeByBoneIndex(boneData.index); + if (boneNode) return boneNode; + boneNode = this._buildBoneAttachedNode(bone, boneData.index); + var parentBoneNode = buildBoneTree(bone.parent) || rootNode; + boneNode.parent = parentBoneNode; + return boneNode; + }.bind(this); + for (var _i = 0, _n = res.length; _i < _n; _i++) { + var targetNode = buildBoneTree(res[_i]); + targetNodes.push(targetNode); + } + this._sortNodeArray(); + return targetNodes; + }, + destroyAllAttachedNodes: function destroyAllAttachedNodes() { + this._attachedRootNode = null; + this._attachedNodeArray.length = 0; + this._boneIndexToNode = {}; + if (!this._inited) return; + var rootNode = this._skeletonNode.getChildByName(ATTACHED_ROOT_NAME); + if (rootNode) { + rootNode.removeFromParent(true); + rootNode.destroy(); + rootNode = null; + } + }, + generateAllAttachedNodes: function generateAllAttachedNodes() { + if (!this._inited) return; + this._boneIndexToNode = {}; + this._attachedNodeArray.length = 0; + var rootNode = this._prepareAttachNode(); + if (!rootNode) return; + var bones = this._skeleton.bones; + for (var i = 0, n = bones.length; i < n; i++) { + var bone = bones[i]; + var boneData = bone.data; + var parentNode = null; + if (bone.parent) { + var parentIndex = bone.parent.data.index; + parentNode = this._boneIndexToNode[parentIndex]; + } else parentNode = rootNode; + if (parentNode) { + var boneNode = parentNode.getChildByName(ATTACHED_PRE_NAME + boneData.name); + if (boneNode && boneNode.isValid) this._buildBoneRelation(boneNode, bone, boneData.index); else { + boneNode = this._buildBoneAttachedNode(bone, boneData.index); + parentNode.addChild(boneNode); + } + } + } + return rootNode; + }, + _hasAttachedNode: function _hasAttachedNode() { + if (!this._inited) return false; + var attachedRootNode = this._skeletonNode.getChildByName(ATTACHED_ROOT_NAME); + return !!attachedRootNode; + }, + _associateAttachedNode: function _associateAttachedNode() { + if (!this._inited) return; + var rootNode = this._skeletonNode.getChildByName(ATTACHED_ROOT_NAME); + if (!rootNode || !rootNode.isValid) return; + this._attachedRootNode = rootNode; + this._boneIndexToNode = {}; + var nodeArray = this._attachedNodeArray; + nodeArray.length = 0; + limitNode(rootNode); + true; + var isCached = this._skeletonComp.isAnimationCached(); + isCached && this._skeletonComp._frameCache && this._skeletonComp._frameCache.enableCacheAttachedInfo(); + var bones = this._skeleton.bones; + for (var i = 0, n = bones.length; i < n; i++) { + var bone = bones[i]; + var boneData = bone.data; + var parentNode = null; + if (bone.parent) { + var parentIndex = bone.parent.data.index; + parentNode = this._boneIndexToNode[parentIndex]; + } else parentNode = rootNode; + if (parentNode) { + var boneNode = parentNode.getChildByName(ATTACHED_PRE_NAME + boneData.name); + boneNode && boneNode.isValid && this._buildBoneRelation(boneNode, bone, boneData.index); + } + } + }, + _syncAttachedNode: function _syncAttachedNode() { + if (!this._inited) return; + var rootNode = this._attachedRootNode; + var nodeArray = this._attachedNodeArray; + if (!rootNode || !rootNode.isValid) { + this._attachedRootNode = null; + nodeArray.length = 0; + return; + } + var rootMatrix = this._skeletonNode._worldMatrix; + _mat["default"].copy(rootNode._worldMatrix, rootMatrix); + rootNode._renderFlag &= ~FLAG_TRANSFORM; + var boneInfos = null; + var isCached = this._skeletonComp.isAnimationCached(); + boneInfos = isCached ? this._skeletonComp._curFrame && this._skeletonComp._curFrame.boneInfos : this._skeleton.bones; + if (!boneInfos) return; + var mulMat = this._skeletonNode._mulMat; + var matrixHandle = function matrixHandle(nodeMat, parentMat, bone) { + var tm = _tempMat4.m; + tm[0] = bone.a; + tm[1] = bone.c; + tm[4] = bone.b; + tm[5] = bone.d; + tm[12] = bone.worldX; + tm[13] = bone.worldY; + mulMat(nodeMat, parentMat, _tempMat4); + }; + var nodeArrayDirty = false; + for (var i = 0, n = nodeArray.length; i < n; i++) { + var boneNode = nodeArray[i]; + if (!boneNode || !boneNode.isValid) { + nodeArray[i] = null; + nodeArrayDirty = true; + continue; + } + var bone = boneInfos[boneNode._boneIndex]; + if (!bone) { + boneNode.removeFromParent(true); + boneNode.destroy(); + nodeArray[i] = null; + nodeArrayDirty = true; + continue; + } + matrixHandle(boneNode._worldMatrix, rootNode._worldMatrix, bone); + boneNode._renderFlag &= ~FLAG_TRANSFORM; + } + nodeArrayDirty && this._rebuildNodeArray(); + } + }); + module.exports = sp.AttachUtil = AttachUtil; + }), { + "../../cocos2d/core/renderer/render-flow": 273, + "../../cocos2d/core/value-types/mat4": 342 + } ], + 427: [ (function(require, module, exports) { + "use strict"; + var TrackEntryListeners = require("./track-entry-listeners"); + var RenderComponent = require("../../cocos2d/core/components/CCRenderComponent"); + var spine = require("./lib/spine"); + var Graphics = require("../../cocos2d/core/graphics/graphics"); + var RenderFlow = require("../../cocos2d/core/renderer/render-flow"); + var FLAG_POST_RENDER = RenderFlow.FLAG_POST_RENDER; + var SkeletonCache = require("./skeleton-cache"); + var AttachUtil = require("./AttachUtil"); + var DefaultSkinsEnum = cc.Enum({ + default: -1 + }); + var DefaultAnimsEnum = cc.Enum({ + "": 0 + }); + var AnimationCacheMode = cc.Enum({ + REALTIME: 0, + SHARED_CACHE: 1, + PRIVATE_CACHE: 2 + }); + function setEnumAttr(obj, propName, enumDef) { + cc.Class.Attr.setClassAttr(obj, propName, "type", "Enum"); + cc.Class.Attr.setClassAttr(obj, propName, "enumList", cc.Enum.getList(enumDef)); + } + sp.Skeleton = cc.Class({ + name: "sp.Skeleton", + extends: RenderComponent, + editor: false, + statics: { + AnimationCacheMode: AnimationCacheMode + }, + properties: { + paused: { + default: false, + visible: false + }, + skeletonData: { + default: null, + type: sp.SkeletonData, + notify: function notify() { + false; + this.defaultSkin = ""; + this.defaultAnimation = ""; + this._updateSkeletonData(); + }, + tooltip: false + }, + defaultSkin: { + default: "", + visible: false + }, + defaultAnimation: { + default: "", + visible: false + }, + animation: { + get: function get() { + if (this.isAnimationCached()) return this._animationName; + var entry = this.getCurrent(0); + return entry && entry.animation.name || ""; + }, + set: function set(value) { + this.defaultAnimation = value; + if (value) this.setAnimation(0, value, this.loop); else if (!this.isAnimationCached()) { + this.clearTrack(0); + this.setToSetupPose(); + } + }, + visible: false + }, + _defaultSkinIndex: { + get: function get() { + if (this.skeletonData) { + var skinsEnum = this.skeletonData.getSkinsEnum(); + if (skinsEnum) if ("" === this.defaultSkin) { + if (skinsEnum.hasOwnProperty(0)) { + this._defaultSkinIndex = 0; + return 0; + } + } else { + var skinIndex = skinsEnum[this.defaultSkin]; + if (void 0 !== skinIndex) return skinIndex; + } + } + return 0; + }, + set: function set(value) { + var skinsEnum; + this.skeletonData && (skinsEnum = this.skeletonData.getSkinsEnum()); + if (!skinsEnum) return cc.errorID("", this.name); + var skinName = skinsEnum[value]; + if (void 0 !== skinName) { + this.defaultSkin = skinName; + this.setSkin(this.defaultSkin); + false; + } else cc.errorID(7501, this.name); + }, + type: DefaultSkinsEnum, + visible: true, + animatable: false, + displayName: "Default Skin", + tooltip: false + }, + _animationIndex: { + get: function get() { + var animationName = this.animation; + if (this.skeletonData && animationName) { + var animsEnum = this.skeletonData.getAnimsEnum(); + if (animsEnum) { + var animIndex = animsEnum[animationName]; + if (void 0 !== animIndex) return animIndex; + } + } + return 0; + }, + set: function set(value) { + if (0 === value) { + this.animation = ""; + return; + } + var animsEnum; + this.skeletonData && (animsEnum = this.skeletonData.getAnimsEnum()); + if (!animsEnum) return cc.errorID(7502, this.name); + var animName = animsEnum[value]; + void 0 !== animName ? this.animation = animName : cc.errorID(7503, this.name); + }, + type: DefaultAnimsEnum, + visible: true, + animatable: false, + displayName: "Animation", + tooltip: false + }, + _preCacheMode: -1, + _cacheMode: AnimationCacheMode.REALTIME, + _defaultCacheMode: { + default: 0, + type: AnimationCacheMode, + notify: function notify() { + this.setAnimationCacheMode(this._defaultCacheMode); + }, + editorOnly: true, + visible: true, + animatable: false, + displayName: "Animation Cache Mode", + tooltip: false + }, + loop: { + default: true, + tooltip: false + }, + premultipliedAlpha: { + default: true, + tooltip: false + }, + timeScale: { + default: 1, + tooltip: false + }, + debugSlots: { + default: false, + editorOnly: true, + tooltip: false, + notify: function notify() { + this._updateDebugDraw(); + } + }, + debugBones: { + default: false, + editorOnly: true, + tooltip: false, + notify: function notify() { + this._updateDebugDraw(); + } + }, + debugMesh: { + default: false, + editorOnly: true, + tooltip: false, + notify: function notify() { + this._updateDebugDraw(); + } + }, + useTint: { + default: false, + tooltip: false, + notify: function notify() { + this._updateUseTint(); + } + }, + enableBatch: { + default: false, + notify: function notify() { + this._updateBatch(); + }, + tooltip: false + }, + _accTime: 0, + _playCount: 0, + _frameCache: null, + _curFrame: null, + _skeletonCache: null, + _animationName: "", + _animationQueue: [], + _headAniInfo: null, + _playTimes: 0, + _isAniComplete: true + }, + ctor: function ctor() { + this._effectDelegate = null; + this._skeleton = null; + this._rootBone = null; + this._listener = null; + this._materialCache = {}; + this._debugRenderer = null; + this._startSlotIndex = -1; + this._endSlotIndex = -1; + this._startEntry = { + animation: { + name: "" + }, + trackIndex: 0 + }; + this._endEntry = { + animation: { + name: "" + }, + trackIndex: 0 + }; + this.attachUtil = new AttachUtil(); + }, + _getDefaultMaterial: function _getDefaultMaterial() { + return cc.Material.getBuiltinMaterial("2d-spine"); + }, + _updateMaterial: function _updateMaterial() { + var useTint = this.useTint || this.isAnimationCached() && true; + var baseMaterial = this.getMaterial(0); + if (baseMaterial) { + baseMaterial.define("USE_TINT", useTint); + baseMaterial.define("CC_USE_MODEL", !this.enableBatch); + var srcBlendFactor = this.premultipliedAlpha ? cc.gfx.BLEND_ONE : cc.gfx.BLEND_SRC_ALPHA; + var dstBlendFactor = cc.gfx.BLEND_ONE_MINUS_SRC_ALPHA; + baseMaterial.setBlend(true, cc.gfx.BLEND_FUNC_ADD, srcBlendFactor, srcBlendFactor, cc.gfx.BLEND_FUNC_ADD, dstBlendFactor, dstBlendFactor); + } + this._materialCache = {}; + }, + disableRender: function disableRender() { + this._super(); + this.node._renderFlag &= ~FLAG_POST_RENDER; + }, + markForRender: function markForRender(enable) { + this._super(enable); + enable ? this.node._renderFlag |= FLAG_POST_RENDER : this.node._renderFlag &= ~FLAG_POST_RENDER; + }, + _updateUseTint: function _updateUseTint() { + var baseMaterial = this.getMaterial(0); + if (baseMaterial) { + var useTint = this.useTint || this.isAnimationCached() && true; + baseMaterial.define("USE_TINT", useTint); + } + this._materialCache = {}; + }, + _updateBatch: function _updateBatch() { + var baseMaterial = this.getMaterial(0); + baseMaterial && baseMaterial.define("CC_USE_MODEL", !this.enableBatch); + this._materialCache = {}; + }, + _validateRender: function _validateRender() { + var skeletonData = this.skeletonData; + if (!skeletonData || !skeletonData.isTexturesLoaded()) { + this.disableRender(); + return; + } + this._super(); + }, + setSkeletonData: function setSkeletonData(skeletonData) { + null != skeletonData.width && null != skeletonData.height && this.node.setContentSize(skeletonData.width, skeletonData.height); + true; + if (this._cacheMode === AnimationCacheMode.SHARED_CACHE) this._skeletonCache = SkeletonCache.sharedCache; else if (this._cacheMode === AnimationCacheMode.PRIVATE_CACHE) { + this._skeletonCache = new SkeletonCache(); + this._skeletonCache.enablePrivateMode(); + } + if (this.isAnimationCached()) { + (this.debugBones || this.debugSlots) && cc.warn("Debug bones or slots is invalid in cached mode"); + var skeletonInfo = this._skeletonCache.getSkeletonCache(this.skeletonData._uuid, skeletonData); + this._skeleton = skeletonInfo.skeleton; + this._clipper = skeletonInfo.clipper; + this._rootBone = this._skeleton.getRootBone(); + } else { + this._skeleton = new spine.Skeleton(skeletonData); + this._clipper = new spine.SkeletonClipping(); + this._rootBone = this._skeleton.getRootBone(); + } + this.markForRender(true); + }, + setSlotsRange: function setSlotsRange(startSlotIndex, endSlotIndex) { + if (this.isAnimationCached()) cc.warn("Slots visible range can not be modified in cached mode."); else { + this._startSlotIndex = startSlotIndex; + this._endSlotIndex = endSlotIndex; + } + }, + setAnimationStateData: function setAnimationStateData(stateData) { + if (this.isAnimationCached()) cc.warn("'setAnimationStateData' interface can not be invoked in cached mode."); else { + var state = new spine.AnimationState(stateData); + if (this._listener) { + this._state && this._state.removeListener(this._listener); + state.addListener(this._listener); + } + this._state = state; + } + }, + __preload: function __preload() { + this._super(); + var Flags; + false; + var children = this.node.children; + for (var i = 0, n = children.length; i < n; i++) { + var child = children[i]; + child && "DEBUG_DRAW_NODE" === child._name && child.destroy(); + } + this._updateSkeletonData(); + this._updateDebugDraw(); + this._updateUseTint(); + this._updateBatch(); + }, + setAnimationCacheMode: function setAnimationCacheMode(cacheMode) { + if (this._preCacheMode !== cacheMode) { + this._cacheMode = cacheMode; + this._updateSkeletonData(); + this._updateUseTint(); + } + }, + isAnimationCached: function isAnimationCached() { + false; + return this._cacheMode !== AnimationCacheMode.REALTIME; + }, + update: function update(dt) { + false; + if (this.paused) return; + dt *= this.timeScale * sp.timeScale; + if (this.isAnimationCached()) { + if (this._isAniComplete) { + if (0 === this._animationQueue.length && !this._headAniInfo) { + var frameCache = this._frameCache; + if (frameCache && frameCache.isInvalid()) { + frameCache.updateToFrame(); + var frames = frameCache.frames; + this._curFrame = frames[frames.length - 1]; + } + return; + } + this._headAniInfo || (this._headAniInfo = this._animationQueue.shift()); + this._accTime += dt; + if (this._accTime > this._headAniInfo.delay) { + var aniInfo = this._headAniInfo; + this._headAniInfo = null; + this.setAnimation(0, aniInfo.animationName, aniInfo.loop); + } + return; + } + this._updateCache(dt); + } else this._updateRealtime(dt); + }, + _emitCacheCompleteEvent: function _emitCacheCompleteEvent() { + if (!this._listener) return; + this._endEntry.animation.name = this._animationName; + this._listener.complete && this._listener.complete(this._endEntry); + this._listener.end && this._listener.end(this._endEntry); + }, + _updateCache: function _updateCache(dt) { + var frameCache = this._frameCache; + if (!frameCache.isInited()) return; + var frames = frameCache.frames; + var frameTime = SkeletonCache.FrameTime; + if (0 == this._accTime && 0 == this._playCount) { + this._startEntry.animation.name = this._animationName; + this._listener && this._listener.start && this._listener.start(this._startEntry); + } + this._accTime += dt; + var frameIdx = Math.floor(this._accTime / frameTime); + frameCache.isCompleted || frameCache.updateToFrame(frameIdx); + if (frameCache.isCompleted && frameIdx >= frames.length) { + this._playCount++; + if (this._playTimes > 0 && this._playCount >= this._playTimes) { + this._curFrame = frames[frames.length - 1]; + this._accTime = 0; + this._playCount = 0; + this._isAniComplete = true; + this._emitCacheCompleteEvent(); + return; + } + this._accTime = 0; + frameIdx = 0; + this._emitCacheCompleteEvent(); + } + this._curFrame = frames[frameIdx]; + }, + _updateRealtime: function _updateRealtime(dt) { + var skeleton = this._skeleton; + var state = this._state; + if (skeleton) { + skeleton.update(dt); + if (state) { + state.update(dt); + state.apply(skeleton); + } + } + }, + setVertexEffectDelegate: function setVertexEffectDelegate(effectDelegate) { + this._effectDelegate = effectDelegate; + }, + updateWorldTransform: function updateWorldTransform() { + if (!this.isAnimationCached()) return; + this._skeleton && this._skeleton.updateWorldTransform(); + }, + setToSetupPose: function setToSetupPose() { + this._skeleton && this._skeleton.setToSetupPose(); + }, + setBonesToSetupPose: function setBonesToSetupPose() { + this._skeleton && this._skeleton.setBonesToSetupPose(); + }, + setSlotsToSetupPose: function setSlotsToSetupPose() { + this._skeleton && this._skeleton.setSlotsToSetupPose(); + }, + updateAnimationCache: function updateAnimationCache(animName) { + if (!this.isAnimationCached()) return; + var uuid = this.skeletonData._uuid; + this._skeletonCache && this._skeletonCache.updateAnimationCache(uuid, animName); + }, + invalidAnimationCache: function invalidAnimationCache() { + if (!this.isAnimationCached()) return; + this._skeletonCache && this._skeletonCache.invalidAnimationCache(this.skeletonData._uuid); + }, + findBone: function findBone(boneName) { + if (this._skeleton) return this._skeleton.findBone(boneName); + return null; + }, + findSlot: function findSlot(slotName) { + if (this._skeleton) return this._skeleton.findSlot(slotName); + return null; + }, + setSkin: function setSkin(skinName) { + if (this._skeleton) { + this._skeleton.setSkinByName(skinName); + this._skeleton.setSlotsToSetupPose(); + } + this.invalidAnimationCache(); + }, + getAttachment: function getAttachment(slotName, attachmentName) { + if (this._skeleton) return this._skeleton.getAttachmentByName(slotName, attachmentName); + return null; + }, + setAttachment: function setAttachment(slotName, attachmentName) { + this._skeleton && this._skeleton.setAttachment(slotName, attachmentName); + this.invalidAnimationCache(); + }, + getTextureAtlas: function getTextureAtlas(regionAttachment) { + return regionAttachment.region; + }, + setMix: function setMix(fromAnimation, toAnimation, duration) { + this._state && this._state.data.setMix(fromAnimation, toAnimation, duration); + }, + setAnimation: function setAnimation(trackIndex, name, loop) { + this._playTimes = loop ? 0 : 1; + this._animationName = name; + if (this.isAnimationCached()) { + 0 !== trackIndex && cc.warn("Track index can not greater than 0 in cached mode."); + if (!this._skeletonCache) return null; + var cache = this._skeletonCache.getAnimationCache(this.skeletonData._uuid, name); + cache || (cache = this._skeletonCache.initAnimationCache(this.skeletonData._uuid, name)); + if (cache) { + this._isAniComplete = false; + this._accTime = 0; + this._playCount = 0; + this._frameCache = cache; + this.attachUtil._hasAttachedNode() && this._frameCache.enableCacheAttachedInfo(); + this._frameCache.updateToFrame(0); + this._curFrame = this._frameCache.frames[0]; + } + } else if (this._skeleton) { + var animation = this._skeleton.data.findAnimation(name); + if (!animation) { + cc.logID(7509, name); + return null; + } + var res = this._state.setAnimationWith(trackIndex, animation, loop); + this._state.apply(this._skeleton); + return res; + } + return null; + }, + addAnimation: function addAnimation(trackIndex, name, loop, delay) { + delay = delay || 0; + if (this.isAnimationCached()) { + 0 !== trackIndex && cc.warn("Track index can not greater than 0 in cached mode."); + this._animationQueue.push({ + animationName: name, + loop: loop, + delay: delay + }); + } else if (this._skeleton) { + var animation = this._skeleton.data.findAnimation(name); + if (!animation) { + cc.logID(7510, name); + return null; + } + return this._state.addAnimationWith(trackIndex, animation, loop, delay); + } + return null; + }, + findAnimation: function findAnimation(name) { + if (this._skeleton) return this._skeleton.data.findAnimation(name); + return null; + }, + getCurrent: function getCurrent(trackIndex) { + if (this.isAnimationCached()) cc.warn("'getCurrent' interface can not be invoked in cached mode."); else if (this._state) return this._state.getCurrent(trackIndex); + return null; + }, + clearTracks: function clearTracks() { + this.isAnimationCached() ? cc.warn("'clearTracks' interface can not be invoked in cached mode.") : this._state && this._state.clearTracks(); + }, + clearTrack: function clearTrack(trackIndex) { + if (this.isAnimationCached()) cc.warn("'clearTrack' interface can not be invoked in cached mode."); else if (this._state) { + this._state.clearTrack(trackIndex); + false; + } + }, + setStartListener: function setStartListener(listener) { + this._ensureListener(); + this._listener.start = listener; + }, + setInterruptListener: function setInterruptListener(listener) { + this._ensureListener(); + this._listener.interrupt = listener; + }, + setEndListener: function setEndListener(listener) { + this._ensureListener(); + this._listener.end = listener; + }, + setDisposeListener: function setDisposeListener(listener) { + this._ensureListener(); + this._listener.dispose = listener; + }, + setCompleteListener: function setCompleteListener(listener) { + this._ensureListener(); + this._listener.complete = listener; + }, + setEventListener: function setEventListener(listener) { + this._ensureListener(); + this._listener.event = listener; + }, + setTrackStartListener: function setTrackStartListener(entry, listener) { + TrackEntryListeners.getListeners(entry).start = listener; + }, + setTrackInterruptListener: function setTrackInterruptListener(entry, listener) { + TrackEntryListeners.getListeners(entry).interrupt = listener; + }, + setTrackEndListener: function setTrackEndListener(entry, listener) { + TrackEntryListeners.getListeners(entry).end = listener; + }, + setTrackDisposeListener: function setTrackDisposeListener(entry, listener) { + TrackEntryListeners.getListeners(entry).dispose = listener; + }, + setTrackCompleteListener: function setTrackCompleteListener(entry, listener) { + TrackEntryListeners.getListeners(entry).complete = function(trackEntry) { + var loopCount = Math.floor(trackEntry.trackTime / trackEntry.animationEnd); + listener(trackEntry, loopCount); + }; + }, + setTrackEventListener: function setTrackEventListener(entry, listener) { + TrackEntryListeners.getListeners(entry).event = listener; + }, + getState: function getState() { + return this._state; + }, + _resetDefaultAnim: false, + _resetDefaultSkin: false, + _updateAnimEnum: false, + _updateSkinEnum: false, + _ensureListener: function _ensureListener() { + if (!this._listener) { + this._listener = new TrackEntryListeners(); + this._state && this._state.addListener(this._listener); + } + }, + _updateSkeletonData: function _updateSkeletonData() { + if (!this.skeletonData) { + this.disableRender(); + return; + } + var data = this.skeletonData.getRuntimeData(); + if (!data) { + this.disableRender(); + return; + } + try { + this.setSkeletonData(data); + this.isAnimationCached() || this.setAnimationStateData(new spine.AnimationStateData(this._skeleton.data)); + this.defaultSkin && this.setSkin(this.defaultSkin); + } catch (e) { + cc.warn(e); + } + this.attachUtil.init(this); + this.attachUtil._associateAttachedNode(); + this._preCacheMode = this._cacheMode; + this.animation = this.defaultAnimation; + }, + _refreshInspector: function _refreshInspector() { + this._updateAnimEnum(); + this._updateSkinEnum(); + Editor.Utils.refreshSelectedInspector("node", this.node.uuid); + }, + _updateDebugDraw: function _updateDebugDraw() { + if (this.debugBones || this.debugSlots) { + if (!this._debugRenderer) { + var debugDrawNode = new cc.PrivateNode(); + debugDrawNode.name = "DEBUG_DRAW_NODE"; + var debugDraw = debugDrawNode.addComponent(Graphics); + debugDraw.lineWidth = 1; + debugDraw.strokeColor = cc.color(255, 0, 0, 255); + this._debugRenderer = debugDraw; + } + this._debugRenderer.node.parent = this.node; + this.isAnimationCached() && cc.warn("Debug bones or slots is invalid in cached mode"); + } else this._debugRenderer && (this._debugRenderer.node.parent = null); + } + }); + module.exports = sp.Skeleton; + }), { + "../../cocos2d/core/components/CCRenderComponent": 161, + "../../cocos2d/core/graphics/graphics": 203, + "../../cocos2d/core/renderer/render-flow": 273, + "./AttachUtil": 426, + "./lib/spine": 429, + "./skeleton-cache": 430, + "./track-entry-listeners": 434 + } ], + 428: [ (function(require, module, exports) { + "use strict"; + var _global = "undefined" === typeof window ? global : window; + var _isUseSpine = true; + true; + _global.spine = require("./lib/spine"); + if (_isUseSpine) { + _global.sp = _global.sp || {}; + sp._timeScale = 1; + Object.defineProperty(sp, "timeScale", { + get: function get() { + return this._timeScale; + }, + set: function set(value) { + this._timeScale = value; + }, + configurable: true + }); + sp.ATTACHMENT_TYPE = { + REGION: 0, + BOUNDING_BOX: 1, + MESH: 2, + SKINNED_MESH: 3 + }; + sp.AnimationEventType = cc.Enum({ + START: 0, + INTERRUPT: 1, + END: 2, + DISPOSE: 3, + COMPLETE: 4, + EVENT: 5 + }); + true; + sp.spine = _global.spine; + true; + require("./skeleton-texture"); + require("./skeleton-data"); + require("./vertex-effect-delegate"); + require("./Skeleton"); + require("./spine-assembler"); + } + }), { + "./Skeleton": 427, + "./lib/spine": 429, + "./skeleton-data": 431, + "./skeleton-texture": 432, + "./spine-assembler": 433, + "./vertex-effect-delegate": 435 + } ], + 429: [ (function(require, module, exports) { + "use strict"; + var __extends = (void 0, (function() { + var _extendStatics = function extendStatics(d, b) { + _extendStatics = Object.setPrototypeOf || { + __proto__: [] + } instanceof Array && function(d, b) { + d.__proto__ = b; + } || function(d, b) { + for (var p in b) b.hasOwnProperty(p) && (d[p] = b[p]); + }; + return _extendStatics(d, b); + }; + return function(d, b) { + _extendStatics(d, b); + function __() { + this.constructor = d; + } + d.prototype = null === b ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + })()); + var spine; + (function(spine) { + var Animation = (function() { + function Animation(name, timelines, duration) { + if (null == name) throw new Error("name cannot be null."); + if (null == timelines) throw new Error("timelines cannot be null."); + this.name = name; + this.timelines = timelines; + this.timelineIds = []; + for (var i = 0; i < timelines.length; i++) this.timelineIds[timelines[i].getPropertyId()] = true; + this.duration = duration; + } + Animation.prototype.hasTimeline = function(id) { + return true == this.timelineIds[id]; + }; + Animation.prototype.apply = function(skeleton, lastTime, time, loop, events, alpha, blend, direction) { + if (null == skeleton) throw new Error("skeleton cannot be null."); + if (loop && 0 != this.duration) { + time %= this.duration; + lastTime > 0 && (lastTime %= this.duration); + } + var timelines = this.timelines; + for (var i = 0, n = timelines.length; i < n; i++) timelines[i].apply(skeleton, lastTime, time, events, alpha, blend, direction); + }; + Animation.binarySearch = function(values, target, step) { + void 0 === step && (step = 1); + var low = 0; + var high = values.length / step - 2; + if (0 == high) return step; + var current = high >>> 1; + while (true) { + values[(current + 1) * step] <= target ? low = current + 1 : high = current; + if (low == high) return (low + 1) * step; + current = low + high >>> 1; + } + }; + Animation.linearSearch = function(values, target, step) { + for (var i = 0, last = values.length - step; i <= last; i += step) if (values[i] > target) return i; + return -1; + }; + return Animation; + })(); + spine.Animation = Animation; + var MixBlend; + (function(MixBlend) { + MixBlend[MixBlend["setup"] = 0] = "setup"; + MixBlend[MixBlend["first"] = 1] = "first"; + MixBlend[MixBlend["replace"] = 2] = "replace"; + MixBlend[MixBlend["add"] = 3] = "add"; + })(MixBlend = spine.MixBlend || (spine.MixBlend = {})); + var MixDirection; + (function(MixDirection) { + MixDirection[MixDirection["mixIn"] = 0] = "mixIn"; + MixDirection[MixDirection["mixOut"] = 1] = "mixOut"; + })(MixDirection = spine.MixDirection || (spine.MixDirection = {})); + var TimelineType; + (function(TimelineType) { + TimelineType[TimelineType["rotate"] = 0] = "rotate"; + TimelineType[TimelineType["translate"] = 1] = "translate"; + TimelineType[TimelineType["scale"] = 2] = "scale"; + TimelineType[TimelineType["shear"] = 3] = "shear"; + TimelineType[TimelineType["attachment"] = 4] = "attachment"; + TimelineType[TimelineType["color"] = 5] = "color"; + TimelineType[TimelineType["deform"] = 6] = "deform"; + TimelineType[TimelineType["event"] = 7] = "event"; + TimelineType[TimelineType["drawOrder"] = 8] = "drawOrder"; + TimelineType[TimelineType["ikConstraint"] = 9] = "ikConstraint"; + TimelineType[TimelineType["transformConstraint"] = 10] = "transformConstraint"; + TimelineType[TimelineType["pathConstraintPosition"] = 11] = "pathConstraintPosition"; + TimelineType[TimelineType["pathConstraintSpacing"] = 12] = "pathConstraintSpacing"; + TimelineType[TimelineType["pathConstraintMix"] = 13] = "pathConstraintMix"; + TimelineType[TimelineType["twoColor"] = 14] = "twoColor"; + })(TimelineType = spine.TimelineType || (spine.TimelineType = {})); + var CurveTimeline = (function() { + function CurveTimeline(frameCount) { + if (frameCount <= 0) throw new Error("frameCount must be > 0: " + frameCount); + this.curves = spine.Utils.newFloatArray((frameCount - 1) * CurveTimeline.BEZIER_SIZE); + } + CurveTimeline.prototype.getFrameCount = function() { + return this.curves.length / CurveTimeline.BEZIER_SIZE + 1; + }; + CurveTimeline.prototype.setLinear = function(frameIndex) { + this.curves[frameIndex * CurveTimeline.BEZIER_SIZE] = CurveTimeline.LINEAR; + }; + CurveTimeline.prototype.setStepped = function(frameIndex) { + this.curves[frameIndex * CurveTimeline.BEZIER_SIZE] = CurveTimeline.STEPPED; + }; + CurveTimeline.prototype.getCurveType = function(frameIndex) { + var index = frameIndex * CurveTimeline.BEZIER_SIZE; + if (index == this.curves.length) return CurveTimeline.LINEAR; + var type = this.curves[index]; + if (type == CurveTimeline.LINEAR) return CurveTimeline.LINEAR; + if (type == CurveTimeline.STEPPED) return CurveTimeline.STEPPED; + return CurveTimeline.BEZIER; + }; + CurveTimeline.prototype.setCurve = function(frameIndex, cx1, cy1, cx2, cy2) { + var tmpx = .03 * (2 * -cx1 + cx2), tmpy = .03 * (2 * -cy1 + cy2); + var dddfx = .006 * (3 * (cx1 - cx2) + 1), dddfy = .006 * (3 * (cy1 - cy2) + 1); + var ddfx = 2 * tmpx + dddfx, ddfy = 2 * tmpy + dddfy; + var dfx = .3 * cx1 + tmpx + .16666667 * dddfx, dfy = .3 * cy1 + tmpy + .16666667 * dddfy; + var i = frameIndex * CurveTimeline.BEZIER_SIZE; + var curves = this.curves; + curves[i++] = CurveTimeline.BEZIER; + var x = dfx, y = dfy; + for (var n = i + CurveTimeline.BEZIER_SIZE - 1; i < n; i += 2) { + curves[i] = x; + curves[i + 1] = y; + dfx += ddfx; + dfy += ddfy; + ddfx += dddfx; + ddfy += dddfy; + x += dfx; + y += dfy; + } + }; + CurveTimeline.prototype.getCurvePercent = function(frameIndex, percent) { + percent = spine.MathUtils.clamp(percent, 0, 1); + var curves = this.curves; + var i = frameIndex * CurveTimeline.BEZIER_SIZE; + var type = curves[i]; + if (type == CurveTimeline.LINEAR) return percent; + if (type == CurveTimeline.STEPPED) return 0; + i++; + var x = 0; + for (var start = i, n = i + CurveTimeline.BEZIER_SIZE - 1; i < n; i += 2) { + x = curves[i]; + if (x >= percent) { + var prevX = void 0, prevY = void 0; + if (i == start) { + prevX = 0; + prevY = 0; + } else { + prevX = curves[i - 2]; + prevY = curves[i - 1]; + } + return prevY + (curves[i + 1] - prevY) * (percent - prevX) / (x - prevX); + } + } + var y = curves[i - 1]; + return y + (1 - y) * (percent - x) / (1 - x); + }; + CurveTimeline.LINEAR = 0; + CurveTimeline.STEPPED = 1; + CurveTimeline.BEZIER = 2; + CurveTimeline.BEZIER_SIZE = 19; + return CurveTimeline; + })(); + spine.CurveTimeline = CurveTimeline; + var RotateTimeline = (function(_super) { + __extends(RotateTimeline, _super); + function RotateTimeline(frameCount) { + var _this = _super.call(this, frameCount) || this; + _this.frames = spine.Utils.newFloatArray(frameCount << 1); + return _this; + } + RotateTimeline.prototype.getPropertyId = function() { + return (TimelineType.rotate << 24) + this.boneIndex; + }; + RotateTimeline.prototype.setFrame = function(frameIndex, time, degrees) { + frameIndex <<= 1; + this.frames[frameIndex] = time; + this.frames[frameIndex + RotateTimeline.ROTATION] = degrees; + }; + RotateTimeline.prototype.apply = function(skeleton, lastTime, time, events, alpha, blend, direction) { + var frames = this.frames; + var bone = skeleton.bones[this.boneIndex]; + if (!bone.active) return; + if (time < frames[0]) { + switch (blend) { + case MixBlend.setup: + bone.rotation = bone.data.rotation; + return; + + case MixBlend.first: + var r_1 = bone.data.rotation - bone.rotation; + bone.rotation += (r_1 - 360 * (16384 - (16384.499999999996 - r_1 / 360 | 0))) * alpha; + } + return; + } + if (time >= frames[frames.length - RotateTimeline.ENTRIES]) { + var r_2 = frames[frames.length + RotateTimeline.PREV_ROTATION]; + switch (blend) { + case MixBlend.setup: + bone.rotation = bone.data.rotation + r_2 * alpha; + break; + + case MixBlend.first: + case MixBlend.replace: + r_2 += bone.data.rotation - bone.rotation; + r_2 -= 360 * (16384 - (16384.499999999996 - r_2 / 360 | 0)); + + case MixBlend.add: + bone.rotation += r_2 * alpha; + } + return; + } + var frame = Animation.binarySearch(frames, time, RotateTimeline.ENTRIES); + var prevRotation = frames[frame + RotateTimeline.PREV_ROTATION]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent((frame >> 1) - 1, 1 - (time - frameTime) / (frames[frame + RotateTimeline.PREV_TIME] - frameTime)); + var r = frames[frame + RotateTimeline.ROTATION] - prevRotation; + r = prevRotation + (r - 360 * (16384 - (16384.499999999996 - r / 360 | 0))) * percent; + switch (blend) { + case MixBlend.setup: + bone.rotation = bone.data.rotation + (r - 360 * (16384 - (16384.499999999996 - r / 360 | 0))) * alpha; + break; + + case MixBlend.first: + case MixBlend.replace: + r += bone.data.rotation - bone.rotation; + + case MixBlend.add: + bone.rotation += (r - 360 * (16384 - (16384.499999999996 - r / 360 | 0))) * alpha; + } + }; + RotateTimeline.ENTRIES = 2; + RotateTimeline.PREV_TIME = -2; + RotateTimeline.PREV_ROTATION = -1; + RotateTimeline.ROTATION = 1; + return RotateTimeline; + })(CurveTimeline); + spine.RotateTimeline = RotateTimeline; + var TranslateTimeline = (function(_super) { + __extends(TranslateTimeline, _super); + function TranslateTimeline(frameCount) { + var _this = _super.call(this, frameCount) || this; + _this.frames = spine.Utils.newFloatArray(frameCount * TranslateTimeline.ENTRIES); + return _this; + } + TranslateTimeline.prototype.getPropertyId = function() { + return (TimelineType.translate << 24) + this.boneIndex; + }; + TranslateTimeline.prototype.setFrame = function(frameIndex, time, x, y) { + frameIndex *= TranslateTimeline.ENTRIES; + this.frames[frameIndex] = time; + this.frames[frameIndex + TranslateTimeline.X] = x; + this.frames[frameIndex + TranslateTimeline.Y] = y; + }; + TranslateTimeline.prototype.apply = function(skeleton, lastTime, time, events, alpha, blend, direction) { + var frames = this.frames; + var bone = skeleton.bones[this.boneIndex]; + if (!bone.active) return; + if (time < frames[0]) { + switch (blend) { + case MixBlend.setup: + bone.x = bone.data.x; + bone.y = bone.data.y; + return; + + case MixBlend.first: + bone.x += (bone.data.x - bone.x) * alpha; + bone.y += (bone.data.y - bone.y) * alpha; + } + return; + } + var x = 0, y = 0; + if (time >= frames[frames.length - TranslateTimeline.ENTRIES]) { + x = frames[frames.length + TranslateTimeline.PREV_X]; + y = frames[frames.length + TranslateTimeline.PREV_Y]; + } else { + var frame = Animation.binarySearch(frames, time, TranslateTimeline.ENTRIES); + x = frames[frame + TranslateTimeline.PREV_X]; + y = frames[frame + TranslateTimeline.PREV_Y]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent(frame / TranslateTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + TranslateTimeline.PREV_TIME] - frameTime)); + x += (frames[frame + TranslateTimeline.X] - x) * percent; + y += (frames[frame + TranslateTimeline.Y] - y) * percent; + } + switch (blend) { + case MixBlend.setup: + bone.x = bone.data.x + x * alpha; + bone.y = bone.data.y + y * alpha; + break; + + case MixBlend.first: + case MixBlend.replace: + bone.x += (bone.data.x + x - bone.x) * alpha; + bone.y += (bone.data.y + y - bone.y) * alpha; + break; + + case MixBlend.add: + bone.x += x * alpha; + bone.y += y * alpha; + } + }; + TranslateTimeline.ENTRIES = 3; + TranslateTimeline.PREV_TIME = -3; + TranslateTimeline.PREV_X = -2; + TranslateTimeline.PREV_Y = -1; + TranslateTimeline.X = 1; + TranslateTimeline.Y = 2; + return TranslateTimeline; + })(CurveTimeline); + spine.TranslateTimeline = TranslateTimeline; + var ScaleTimeline = (function(_super) { + __extends(ScaleTimeline, _super); + function ScaleTimeline(frameCount) { + return _super.call(this, frameCount) || this; + } + ScaleTimeline.prototype.getPropertyId = function() { + return (TimelineType.scale << 24) + this.boneIndex; + }; + ScaleTimeline.prototype.apply = function(skeleton, lastTime, time, events, alpha, blend, direction) { + var frames = this.frames; + var bone = skeleton.bones[this.boneIndex]; + if (!bone.active) return; + if (time < frames[0]) { + switch (blend) { + case MixBlend.setup: + bone.scaleX = bone.data.scaleX; + bone.scaleY = bone.data.scaleY; + return; + + case MixBlend.first: + bone.scaleX += (bone.data.scaleX - bone.scaleX) * alpha; + bone.scaleY += (bone.data.scaleY - bone.scaleY) * alpha; + } + return; + } + var x = 0, y = 0; + if (time >= frames[frames.length - ScaleTimeline.ENTRIES]) { + x = frames[frames.length + ScaleTimeline.PREV_X] * bone.data.scaleX; + y = frames[frames.length + ScaleTimeline.PREV_Y] * bone.data.scaleY; + } else { + var frame = Animation.binarySearch(frames, time, ScaleTimeline.ENTRIES); + x = frames[frame + ScaleTimeline.PREV_X]; + y = frames[frame + ScaleTimeline.PREV_Y]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent(frame / ScaleTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + ScaleTimeline.PREV_TIME] - frameTime)); + x = (x + (frames[frame + ScaleTimeline.X] - x) * percent) * bone.data.scaleX; + y = (y + (frames[frame + ScaleTimeline.Y] - y) * percent) * bone.data.scaleY; + } + if (1 == alpha) if (blend == MixBlend.add) { + bone.scaleX += x - bone.data.scaleX; + bone.scaleY += y - bone.data.scaleY; + } else { + bone.scaleX = x; + bone.scaleY = y; + } else { + var bx = 0, by = 0; + if (direction == MixDirection.mixOut) switch (blend) { + case MixBlend.setup: + bx = bone.data.scaleX; + by = bone.data.scaleY; + bone.scaleX = bx + (Math.abs(x) * spine.MathUtils.signum(bx) - bx) * alpha; + bone.scaleY = by + (Math.abs(y) * spine.MathUtils.signum(by) - by) * alpha; + break; + + case MixBlend.first: + case MixBlend.replace: + bx = bone.scaleX; + by = bone.scaleY; + bone.scaleX = bx + (Math.abs(x) * spine.MathUtils.signum(bx) - bx) * alpha; + bone.scaleY = by + (Math.abs(y) * spine.MathUtils.signum(by) - by) * alpha; + break; + + case MixBlend.add: + bx = bone.scaleX; + by = bone.scaleY; + bone.scaleX = bx + (Math.abs(x) * spine.MathUtils.signum(bx) - bone.data.scaleX) * alpha; + bone.scaleY = by + (Math.abs(y) * spine.MathUtils.signum(by) - bone.data.scaleY) * alpha; + } else switch (blend) { + case MixBlend.setup: + bx = Math.abs(bone.data.scaleX) * spine.MathUtils.signum(x); + by = Math.abs(bone.data.scaleY) * spine.MathUtils.signum(y); + bone.scaleX = bx + (x - bx) * alpha; + bone.scaleY = by + (y - by) * alpha; + break; + + case MixBlend.first: + case MixBlend.replace: + bx = Math.abs(bone.scaleX) * spine.MathUtils.signum(x); + by = Math.abs(bone.scaleY) * spine.MathUtils.signum(y); + bone.scaleX = bx + (x - bx) * alpha; + bone.scaleY = by + (y - by) * alpha; + break; + + case MixBlend.add: + bx = spine.MathUtils.signum(x); + by = spine.MathUtils.signum(y); + bone.scaleX = Math.abs(bone.scaleX) * bx + (x - Math.abs(bone.data.scaleX) * bx) * alpha; + bone.scaleY = Math.abs(bone.scaleY) * by + (y - Math.abs(bone.data.scaleY) * by) * alpha; + } + } + }; + return ScaleTimeline; + })(TranslateTimeline); + spine.ScaleTimeline = ScaleTimeline; + var ShearTimeline = (function(_super) { + __extends(ShearTimeline, _super); + function ShearTimeline(frameCount) { + return _super.call(this, frameCount) || this; + } + ShearTimeline.prototype.getPropertyId = function() { + return (TimelineType.shear << 24) + this.boneIndex; + }; + ShearTimeline.prototype.apply = function(skeleton, lastTime, time, events, alpha, blend, direction) { + var frames = this.frames; + var bone = skeleton.bones[this.boneIndex]; + if (!bone.active) return; + if (time < frames[0]) { + switch (blend) { + case MixBlend.setup: + bone.shearX = bone.data.shearX; + bone.shearY = bone.data.shearY; + return; + + case MixBlend.first: + bone.shearX += (bone.data.shearX - bone.shearX) * alpha; + bone.shearY += (bone.data.shearY - bone.shearY) * alpha; + } + return; + } + var x = 0, y = 0; + if (time >= frames[frames.length - ShearTimeline.ENTRIES]) { + x = frames[frames.length + ShearTimeline.PREV_X]; + y = frames[frames.length + ShearTimeline.PREV_Y]; + } else { + var frame = Animation.binarySearch(frames, time, ShearTimeline.ENTRIES); + x = frames[frame + ShearTimeline.PREV_X]; + y = frames[frame + ShearTimeline.PREV_Y]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent(frame / ShearTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + ShearTimeline.PREV_TIME] - frameTime)); + x += (frames[frame + ShearTimeline.X] - x) * percent; + y += (frames[frame + ShearTimeline.Y] - y) * percent; + } + switch (blend) { + case MixBlend.setup: + bone.shearX = bone.data.shearX + x * alpha; + bone.shearY = bone.data.shearY + y * alpha; + break; + + case MixBlend.first: + case MixBlend.replace: + bone.shearX += (bone.data.shearX + x - bone.shearX) * alpha; + bone.shearY += (bone.data.shearY + y - bone.shearY) * alpha; + break; + + case MixBlend.add: + bone.shearX += x * alpha; + bone.shearY += y * alpha; + } + }; + return ShearTimeline; + })(TranslateTimeline); + spine.ShearTimeline = ShearTimeline; + var ColorTimeline = (function(_super) { + __extends(ColorTimeline, _super); + function ColorTimeline(frameCount) { + var _this = _super.call(this, frameCount) || this; + _this.frames = spine.Utils.newFloatArray(frameCount * ColorTimeline.ENTRIES); + return _this; + } + ColorTimeline.prototype.getPropertyId = function() { + return (TimelineType.color << 24) + this.slotIndex; + }; + ColorTimeline.prototype.setFrame = function(frameIndex, time, r, g, b, a) { + frameIndex *= ColorTimeline.ENTRIES; + this.frames[frameIndex] = time; + this.frames[frameIndex + ColorTimeline.R] = r; + this.frames[frameIndex + ColorTimeline.G] = g; + this.frames[frameIndex + ColorTimeline.B] = b; + this.frames[frameIndex + ColorTimeline.A] = a; + }; + ColorTimeline.prototype.apply = function(skeleton, lastTime, time, events, alpha, blend, direction) { + var slot = skeleton.slots[this.slotIndex]; + if (!slot.bone.active) return; + var frames = this.frames; + if (time < frames[0]) { + switch (blend) { + case MixBlend.setup: + slot.color.setFromColor(slot.data.color); + return; + + case MixBlend.first: + var color = slot.color, setup = slot.data.color; + color.add((setup.r - color.r) * alpha, (setup.g - color.g) * alpha, (setup.b - color.b) * alpha, (setup.a - color.a) * alpha); + } + return; + } + var r = 0, g = 0, b = 0, a = 0; + if (time >= frames[frames.length - ColorTimeline.ENTRIES]) { + var i = frames.length; + r = frames[i + ColorTimeline.PREV_R]; + g = frames[i + ColorTimeline.PREV_G]; + b = frames[i + ColorTimeline.PREV_B]; + a = frames[i + ColorTimeline.PREV_A]; + } else { + var frame = Animation.binarySearch(frames, time, ColorTimeline.ENTRIES); + r = frames[frame + ColorTimeline.PREV_R]; + g = frames[frame + ColorTimeline.PREV_G]; + b = frames[frame + ColorTimeline.PREV_B]; + a = frames[frame + ColorTimeline.PREV_A]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent(frame / ColorTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + ColorTimeline.PREV_TIME] - frameTime)); + r += (frames[frame + ColorTimeline.R] - r) * percent; + g += (frames[frame + ColorTimeline.G] - g) * percent; + b += (frames[frame + ColorTimeline.B] - b) * percent; + a += (frames[frame + ColorTimeline.A] - a) * percent; + } + if (1 == alpha) slot.color.set(r, g, b, a); else { + var color = slot.color; + blend == MixBlend.setup && color.setFromColor(slot.data.color); + color.add((r - color.r) * alpha, (g - color.g) * alpha, (b - color.b) * alpha, (a - color.a) * alpha); + } + }; + ColorTimeline.ENTRIES = 5; + ColorTimeline.PREV_TIME = -5; + ColorTimeline.PREV_R = -4; + ColorTimeline.PREV_G = -3; + ColorTimeline.PREV_B = -2; + ColorTimeline.PREV_A = -1; + ColorTimeline.R = 1; + ColorTimeline.G = 2; + ColorTimeline.B = 3; + ColorTimeline.A = 4; + return ColorTimeline; + })(CurveTimeline); + spine.ColorTimeline = ColorTimeline; + var TwoColorTimeline = (function(_super) { + __extends(TwoColorTimeline, _super); + function TwoColorTimeline(frameCount) { + var _this = _super.call(this, frameCount) || this; + _this.frames = spine.Utils.newFloatArray(frameCount * TwoColorTimeline.ENTRIES); + return _this; + } + TwoColorTimeline.prototype.getPropertyId = function() { + return (TimelineType.twoColor << 24) + this.slotIndex; + }; + TwoColorTimeline.prototype.setFrame = function(frameIndex, time, r, g, b, a, r2, g2, b2) { + frameIndex *= TwoColorTimeline.ENTRIES; + this.frames[frameIndex] = time; + this.frames[frameIndex + TwoColorTimeline.R] = r; + this.frames[frameIndex + TwoColorTimeline.G] = g; + this.frames[frameIndex + TwoColorTimeline.B] = b; + this.frames[frameIndex + TwoColorTimeline.A] = a; + this.frames[frameIndex + TwoColorTimeline.R2] = r2; + this.frames[frameIndex + TwoColorTimeline.G2] = g2; + this.frames[frameIndex + TwoColorTimeline.B2] = b2; + }; + TwoColorTimeline.prototype.apply = function(skeleton, lastTime, time, events, alpha, blend, direction) { + var slot = skeleton.slots[this.slotIndex]; + if (!slot.bone.active) return; + var frames = this.frames; + if (time < frames[0]) { + switch (blend) { + case MixBlend.setup: + slot.color.setFromColor(slot.data.color); + slot.darkColor.setFromColor(slot.data.darkColor); + return; + + case MixBlend.first: + var light = slot.color, dark = slot.darkColor, setupLight = slot.data.color, setupDark = slot.data.darkColor; + light.add((setupLight.r - light.r) * alpha, (setupLight.g - light.g) * alpha, (setupLight.b - light.b) * alpha, (setupLight.a - light.a) * alpha); + dark.add((setupDark.r - dark.r) * alpha, (setupDark.g - dark.g) * alpha, (setupDark.b - dark.b) * alpha, 0); + } + return; + } + var r = 0, g = 0, b = 0, a = 0, r2 = 0, g2 = 0, b2 = 0; + if (time >= frames[frames.length - TwoColorTimeline.ENTRIES]) { + var i = frames.length; + r = frames[i + TwoColorTimeline.PREV_R]; + g = frames[i + TwoColorTimeline.PREV_G]; + b = frames[i + TwoColorTimeline.PREV_B]; + a = frames[i + TwoColorTimeline.PREV_A]; + r2 = frames[i + TwoColorTimeline.PREV_R2]; + g2 = frames[i + TwoColorTimeline.PREV_G2]; + b2 = frames[i + TwoColorTimeline.PREV_B2]; + } else { + var frame = Animation.binarySearch(frames, time, TwoColorTimeline.ENTRIES); + r = frames[frame + TwoColorTimeline.PREV_R]; + g = frames[frame + TwoColorTimeline.PREV_G]; + b = frames[frame + TwoColorTimeline.PREV_B]; + a = frames[frame + TwoColorTimeline.PREV_A]; + r2 = frames[frame + TwoColorTimeline.PREV_R2]; + g2 = frames[frame + TwoColorTimeline.PREV_G2]; + b2 = frames[frame + TwoColorTimeline.PREV_B2]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent(frame / TwoColorTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + TwoColorTimeline.PREV_TIME] - frameTime)); + r += (frames[frame + TwoColorTimeline.R] - r) * percent; + g += (frames[frame + TwoColorTimeline.G] - g) * percent; + b += (frames[frame + TwoColorTimeline.B] - b) * percent; + a += (frames[frame + TwoColorTimeline.A] - a) * percent; + r2 += (frames[frame + TwoColorTimeline.R2] - r2) * percent; + g2 += (frames[frame + TwoColorTimeline.G2] - g2) * percent; + b2 += (frames[frame + TwoColorTimeline.B2] - b2) * percent; + } + if (1 == alpha) { + slot.color.set(r, g, b, a); + slot.darkColor.set(r2, g2, b2, 1); + } else { + var light = slot.color, dark = slot.darkColor; + if (blend == MixBlend.setup) { + light.setFromColor(slot.data.color); + dark.setFromColor(slot.data.darkColor); + } + light.add((r - light.r) * alpha, (g - light.g) * alpha, (b - light.b) * alpha, (a - light.a) * alpha); + dark.add((r2 - dark.r) * alpha, (g2 - dark.g) * alpha, (b2 - dark.b) * alpha, 0); + } + }; + TwoColorTimeline.ENTRIES = 8; + TwoColorTimeline.PREV_TIME = -8; + TwoColorTimeline.PREV_R = -7; + TwoColorTimeline.PREV_G = -6; + TwoColorTimeline.PREV_B = -5; + TwoColorTimeline.PREV_A = -4; + TwoColorTimeline.PREV_R2 = -3; + TwoColorTimeline.PREV_G2 = -2; + TwoColorTimeline.PREV_B2 = -1; + TwoColorTimeline.R = 1; + TwoColorTimeline.G = 2; + TwoColorTimeline.B = 3; + TwoColorTimeline.A = 4; + TwoColorTimeline.R2 = 5; + TwoColorTimeline.G2 = 6; + TwoColorTimeline.B2 = 7; + return TwoColorTimeline; + })(CurveTimeline); + spine.TwoColorTimeline = TwoColorTimeline; + var AttachmentTimeline = (function() { + function AttachmentTimeline(frameCount) { + this.frames = spine.Utils.newFloatArray(frameCount); + this.attachmentNames = new Array(frameCount); + } + AttachmentTimeline.prototype.getPropertyId = function() { + return (TimelineType.attachment << 24) + this.slotIndex; + }; + AttachmentTimeline.prototype.getFrameCount = function() { + return this.frames.length; + }; + AttachmentTimeline.prototype.setFrame = function(frameIndex, time, attachmentName) { + this.frames[frameIndex] = time; + this.attachmentNames[frameIndex] = attachmentName; + }; + AttachmentTimeline.prototype.apply = function(skeleton, lastTime, time, events, alpha, blend, direction) { + var slot = skeleton.slots[this.slotIndex]; + if (!slot.bone.active) return; + if (direction == MixDirection.mixOut && blend == MixBlend.setup) { + var attachmentName_1 = slot.data.attachmentName; + slot.setAttachment(null == attachmentName_1 ? null : skeleton.getAttachment(this.slotIndex, attachmentName_1)); + return; + } + var frames = this.frames; + if (time < frames[0]) { + if (blend == MixBlend.setup || blend == MixBlend.first) { + var attachmentName_2 = slot.data.attachmentName; + slot.setAttachment(null == attachmentName_2 ? null : skeleton.getAttachment(this.slotIndex, attachmentName_2)); + } + return; + } + var frameIndex = 0; + frameIndex = time >= frames[frames.length - 1] ? frames.length - 1 : Animation.binarySearch(frames, time, 1) - 1; + var attachmentName = this.attachmentNames[frameIndex]; + skeleton.slots[this.slotIndex].setAttachment(null == attachmentName ? null : skeleton.getAttachment(this.slotIndex, attachmentName)); + }; + return AttachmentTimeline; + })(); + spine.AttachmentTimeline = AttachmentTimeline; + var zeros = null; + var DeformTimeline = (function(_super) { + __extends(DeformTimeline, _super); + function DeformTimeline(frameCount) { + var _this = _super.call(this, frameCount) || this; + _this.frames = spine.Utils.newFloatArray(frameCount); + _this.frameVertices = new Array(frameCount); + null == zeros && (zeros = spine.Utils.newFloatArray(64)); + return _this; + } + DeformTimeline.prototype.getPropertyId = function() { + return (TimelineType.deform << 27) + +this.attachment.id + this.slotIndex; + }; + DeformTimeline.prototype.setFrame = function(frameIndex, time, vertices) { + this.frames[frameIndex] = time; + this.frameVertices[frameIndex] = vertices; + }; + DeformTimeline.prototype.apply = function(skeleton, lastTime, time, firedEvents, alpha, blend, direction) { + var slot = skeleton.slots[this.slotIndex]; + if (!slot.bone.active) return; + var slotAttachment = slot.getAttachment(); + if (!(slotAttachment instanceof spine.VertexAttachment) || !(slotAttachment.deformAttachment == this.attachment)) return; + var deformArray = slot.deform; + 0 == deformArray.length && (blend = MixBlend.setup); + var frameVertices = this.frameVertices; + var vertexCount = frameVertices[0].length; + var frames = this.frames; + if (time < frames[0]) { + var vertexAttachment = slotAttachment; + switch (blend) { + case MixBlend.setup: + deformArray.length = 0; + return; + + case MixBlend.first: + if (1 == alpha) { + deformArray.length = 0; + break; + } + var deform_1 = spine.Utils.setArraySize(deformArray, vertexCount); + if (null == vertexAttachment.bones) { + var setupVertices = vertexAttachment.vertices; + for (var i = 0; i < vertexCount; i++) deform_1[i] += (setupVertices[i] - deform_1[i]) * alpha; + } else { + alpha = 1 - alpha; + for (var i = 0; i < vertexCount; i++) deform_1[i] *= alpha; + } + } + return; + } + var deform = spine.Utils.setArraySize(deformArray, vertexCount); + if (time >= frames[frames.length - 1]) { + var lastVertices = frameVertices[frames.length - 1]; + if (1 == alpha) if (blend == MixBlend.add) { + var vertexAttachment = slotAttachment; + if (null == vertexAttachment.bones) { + var setupVertices = vertexAttachment.vertices; + for (var i_1 = 0; i_1 < vertexCount; i_1++) deform[i_1] += lastVertices[i_1] - setupVertices[i_1]; + } else for (var i_2 = 0; i_2 < vertexCount; i_2++) deform[i_2] += lastVertices[i_2]; + } else spine.Utils.arrayCopy(lastVertices, 0, deform, 0, vertexCount); else switch (blend) { + case MixBlend.setup: + var vertexAttachment_1 = slotAttachment; + if (null == vertexAttachment_1.bones) { + var setupVertices = vertexAttachment_1.vertices; + for (var i_3 = 0; i_3 < vertexCount; i_3++) { + var setup = setupVertices[i_3]; + deform[i_3] = setup + (lastVertices[i_3] - setup) * alpha; + } + } else for (var i_4 = 0; i_4 < vertexCount; i_4++) deform[i_4] = lastVertices[i_4] * alpha; + break; + + case MixBlend.first: + case MixBlend.replace: + for (var i_5 = 0; i_5 < vertexCount; i_5++) deform[i_5] += (lastVertices[i_5] - deform[i_5]) * alpha; + + case MixBlend.add: + var vertexAttachment = slotAttachment; + if (null == vertexAttachment.bones) { + var setupVertices = vertexAttachment.vertices; + for (var i_6 = 0; i_6 < vertexCount; i_6++) deform[i_6] += (lastVertices[i_6] - setupVertices[i_6]) * alpha; + } else for (var i_7 = 0; i_7 < vertexCount; i_7++) deform[i_7] += lastVertices[i_7] * alpha; + } + return; + } + var frame = Animation.binarySearch(frames, time); + var prevVertices = frameVertices[frame - 1]; + var nextVertices = frameVertices[frame]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent(frame - 1, 1 - (time - frameTime) / (frames[frame - 1] - frameTime)); + if (1 == alpha) if (blend == MixBlend.add) { + var vertexAttachment = slotAttachment; + if (null == vertexAttachment.bones) { + var setupVertices = vertexAttachment.vertices; + for (var i_8 = 0; i_8 < vertexCount; i_8++) { + var prev = prevVertices[i_8]; + deform[i_8] += prev + (nextVertices[i_8] - prev) * percent - setupVertices[i_8]; + } + } else for (var i_9 = 0; i_9 < vertexCount; i_9++) { + var prev = prevVertices[i_9]; + deform[i_9] += prev + (nextVertices[i_9] - prev) * percent; + } + } else for (var i_10 = 0; i_10 < vertexCount; i_10++) { + var prev = prevVertices[i_10]; + deform[i_10] = prev + (nextVertices[i_10] - prev) * percent; + } else switch (blend) { + case MixBlend.setup: + var vertexAttachment_2 = slotAttachment; + if (null == vertexAttachment_2.bones) { + var setupVertices = vertexAttachment_2.vertices; + for (var i_11 = 0; i_11 < vertexCount; i_11++) { + var prev = prevVertices[i_11], setup = setupVertices[i_11]; + deform[i_11] = setup + (prev + (nextVertices[i_11] - prev) * percent - setup) * alpha; + } + } else for (var i_12 = 0; i_12 < vertexCount; i_12++) { + var prev = prevVertices[i_12]; + deform[i_12] = (prev + (nextVertices[i_12] - prev) * percent) * alpha; + } + break; + + case MixBlend.first: + case MixBlend.replace: + for (var i_13 = 0; i_13 < vertexCount; i_13++) { + var prev = prevVertices[i_13]; + deform[i_13] += (prev + (nextVertices[i_13] - prev) * percent - deform[i_13]) * alpha; + } + break; + + case MixBlend.add: + var vertexAttachment = slotAttachment; + if (null == vertexAttachment.bones) { + var setupVertices = vertexAttachment.vertices; + for (var i_14 = 0; i_14 < vertexCount; i_14++) { + var prev = prevVertices[i_14]; + deform[i_14] += (prev + (nextVertices[i_14] - prev) * percent - setupVertices[i_14]) * alpha; + } + } else for (var i_15 = 0; i_15 < vertexCount; i_15++) { + var prev = prevVertices[i_15]; + deform[i_15] += (prev + (nextVertices[i_15] - prev) * percent) * alpha; + } + } + }; + return DeformTimeline; + })(CurveTimeline); + spine.DeformTimeline = DeformTimeline; + var EventTimeline = (function() { + function EventTimeline(frameCount) { + this.frames = spine.Utils.newFloatArray(frameCount); + this.events = new Array(frameCount); + } + EventTimeline.prototype.getPropertyId = function() { + return TimelineType.event << 24; + }; + EventTimeline.prototype.getFrameCount = function() { + return this.frames.length; + }; + EventTimeline.prototype.setFrame = function(frameIndex, event) { + this.frames[frameIndex] = event.time; + this.events[frameIndex] = event; + }; + EventTimeline.prototype.apply = function(skeleton, lastTime, time, firedEvents, alpha, blend, direction) { + if (null == firedEvents) return; + var frames = this.frames; + var frameCount = this.frames.length; + if (lastTime > time) { + this.apply(skeleton, lastTime, Number.MAX_VALUE, firedEvents, alpha, blend, direction); + lastTime = -1; + } else if (lastTime >= frames[frameCount - 1]) return; + if (time < frames[0]) return; + var frame = 0; + if (lastTime < frames[0]) frame = 0; else { + frame = Animation.binarySearch(frames, lastTime); + var frameTime = frames[frame]; + while (frame > 0) { + if (frames[frame - 1] != frameTime) break; + frame--; + } + } + for (;frame < frameCount && time >= frames[frame]; frame++) firedEvents.push(this.events[frame]); + }; + return EventTimeline; + })(); + spine.EventTimeline = EventTimeline; + var DrawOrderTimeline = (function() { + function DrawOrderTimeline(frameCount) { + this.frames = spine.Utils.newFloatArray(frameCount); + this.drawOrders = new Array(frameCount); + } + DrawOrderTimeline.prototype.getPropertyId = function() { + return TimelineType.drawOrder << 24; + }; + DrawOrderTimeline.prototype.getFrameCount = function() { + return this.frames.length; + }; + DrawOrderTimeline.prototype.setFrame = function(frameIndex, time, drawOrder) { + this.frames[frameIndex] = time; + this.drawOrders[frameIndex] = drawOrder; + }; + DrawOrderTimeline.prototype.apply = function(skeleton, lastTime, time, firedEvents, alpha, blend, direction) { + var drawOrder = skeleton.drawOrder; + var slots = skeleton.slots; + if (direction == MixDirection.mixOut && blend == MixBlend.setup) { + spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length); + return; + } + var frames = this.frames; + if (time < frames[0]) { + blend != MixBlend.setup && blend != MixBlend.first || spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length); + return; + } + var frame = 0; + frame = time >= frames[frames.length - 1] ? frames.length - 1 : Animation.binarySearch(frames, time) - 1; + var drawOrderToSetupIndex = this.drawOrders[frame]; + if (null == drawOrderToSetupIndex) spine.Utils.arrayCopy(slots, 0, drawOrder, 0, slots.length); else for (var i = 0, n = drawOrderToSetupIndex.length; i < n; i++) drawOrder[i] = slots[drawOrderToSetupIndex[i]]; + }; + return DrawOrderTimeline; + })(); + spine.DrawOrderTimeline = DrawOrderTimeline; + var IkConstraintTimeline = (function(_super) { + __extends(IkConstraintTimeline, _super); + function IkConstraintTimeline(frameCount) { + var _this = _super.call(this, frameCount) || this; + _this.frames = spine.Utils.newFloatArray(frameCount * IkConstraintTimeline.ENTRIES); + return _this; + } + IkConstraintTimeline.prototype.getPropertyId = function() { + return (TimelineType.ikConstraint << 24) + this.ikConstraintIndex; + }; + IkConstraintTimeline.prototype.setFrame = function(frameIndex, time, mix, softness, bendDirection, compress, stretch) { + frameIndex *= IkConstraintTimeline.ENTRIES; + this.frames[frameIndex] = time; + this.frames[frameIndex + IkConstraintTimeline.MIX] = mix; + this.frames[frameIndex + IkConstraintTimeline.SOFTNESS] = softness; + this.frames[frameIndex + IkConstraintTimeline.BEND_DIRECTION] = bendDirection; + this.frames[frameIndex + IkConstraintTimeline.COMPRESS] = compress ? 1 : 0; + this.frames[frameIndex + IkConstraintTimeline.STRETCH] = stretch ? 1 : 0; + }; + IkConstraintTimeline.prototype.apply = function(skeleton, lastTime, time, firedEvents, alpha, blend, direction) { + var frames = this.frames; + var constraint = skeleton.ikConstraints[this.ikConstraintIndex]; + if (!constraint.active) return; + if (time < frames[0]) { + switch (blend) { + case MixBlend.setup: + constraint.mix = constraint.data.mix; + constraint.softness = constraint.data.softness; + constraint.bendDirection = constraint.data.bendDirection; + constraint.compress = constraint.data.compress; + constraint.stretch = constraint.data.stretch; + return; + + case MixBlend.first: + constraint.mix += (constraint.data.mix - constraint.mix) * alpha; + constraint.softness += (constraint.data.softness - constraint.softness) * alpha; + constraint.bendDirection = constraint.data.bendDirection; + constraint.compress = constraint.data.compress; + constraint.stretch = constraint.data.stretch; + } + return; + } + if (time >= frames[frames.length - IkConstraintTimeline.ENTRIES]) { + if (blend == MixBlend.setup) { + constraint.mix = constraint.data.mix + (frames[frames.length + IkConstraintTimeline.PREV_MIX] - constraint.data.mix) * alpha; + constraint.softness = constraint.data.softness + (frames[frames.length + IkConstraintTimeline.PREV_SOFTNESS] - constraint.data.softness) * alpha; + if (direction == MixDirection.mixOut) { + constraint.bendDirection = constraint.data.bendDirection; + constraint.compress = constraint.data.compress; + constraint.stretch = constraint.data.stretch; + } else { + constraint.bendDirection = frames[frames.length + IkConstraintTimeline.PREV_BEND_DIRECTION]; + constraint.compress = 0 != frames[frames.length + IkConstraintTimeline.PREV_COMPRESS]; + constraint.stretch = 0 != frames[frames.length + IkConstraintTimeline.PREV_STRETCH]; + } + } else { + constraint.mix += (frames[frames.length + IkConstraintTimeline.PREV_MIX] - constraint.mix) * alpha; + constraint.softness += (frames[frames.length + IkConstraintTimeline.PREV_SOFTNESS] - constraint.softness) * alpha; + if (direction == MixDirection.mixIn) { + constraint.bendDirection = frames[frames.length + IkConstraintTimeline.PREV_BEND_DIRECTION]; + constraint.compress = 0 != frames[frames.length + IkConstraintTimeline.PREV_COMPRESS]; + constraint.stretch = 0 != frames[frames.length + IkConstraintTimeline.PREV_STRETCH]; + } + } + return; + } + var frame = Animation.binarySearch(frames, time, IkConstraintTimeline.ENTRIES); + var mix = frames[frame + IkConstraintTimeline.PREV_MIX]; + var softness = frames[frame + IkConstraintTimeline.PREV_SOFTNESS]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent(frame / IkConstraintTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + IkConstraintTimeline.PREV_TIME] - frameTime)); + if (blend == MixBlend.setup) { + constraint.mix = constraint.data.mix + (mix + (frames[frame + IkConstraintTimeline.MIX] - mix) * percent - constraint.data.mix) * alpha; + constraint.softness = constraint.data.softness + (softness + (frames[frame + IkConstraintTimeline.SOFTNESS] - softness) * percent - constraint.data.softness) * alpha; + if (direction == MixDirection.mixOut) { + constraint.bendDirection = constraint.data.bendDirection; + constraint.compress = constraint.data.compress; + constraint.stretch = constraint.data.stretch; + } else { + constraint.bendDirection = frames[frame + IkConstraintTimeline.PREV_BEND_DIRECTION]; + constraint.compress = 0 != frames[frame + IkConstraintTimeline.PREV_COMPRESS]; + constraint.stretch = 0 != frames[frame + IkConstraintTimeline.PREV_STRETCH]; + } + } else { + constraint.mix += (mix + (frames[frame + IkConstraintTimeline.MIX] - mix) * percent - constraint.mix) * alpha; + constraint.softness += (softness + (frames[frame + IkConstraintTimeline.SOFTNESS] - softness) * percent - constraint.softness) * alpha; + if (direction == MixDirection.mixIn) { + constraint.bendDirection = frames[frame + IkConstraintTimeline.PREV_BEND_DIRECTION]; + constraint.compress = 0 != frames[frame + IkConstraintTimeline.PREV_COMPRESS]; + constraint.stretch = 0 != frames[frame + IkConstraintTimeline.PREV_STRETCH]; + } + } + }; + IkConstraintTimeline.ENTRIES = 6; + IkConstraintTimeline.PREV_TIME = -6; + IkConstraintTimeline.PREV_MIX = -5; + IkConstraintTimeline.PREV_SOFTNESS = -4; + IkConstraintTimeline.PREV_BEND_DIRECTION = -3; + IkConstraintTimeline.PREV_COMPRESS = -2; + IkConstraintTimeline.PREV_STRETCH = -1; + IkConstraintTimeline.MIX = 1; + IkConstraintTimeline.SOFTNESS = 2; + IkConstraintTimeline.BEND_DIRECTION = 3; + IkConstraintTimeline.COMPRESS = 4; + IkConstraintTimeline.STRETCH = 5; + return IkConstraintTimeline; + })(CurveTimeline); + spine.IkConstraintTimeline = IkConstraintTimeline; + var TransformConstraintTimeline = (function(_super) { + __extends(TransformConstraintTimeline, _super); + function TransformConstraintTimeline(frameCount) { + var _this = _super.call(this, frameCount) || this; + _this.frames = spine.Utils.newFloatArray(frameCount * TransformConstraintTimeline.ENTRIES); + return _this; + } + TransformConstraintTimeline.prototype.getPropertyId = function() { + return (TimelineType.transformConstraint << 24) + this.transformConstraintIndex; + }; + TransformConstraintTimeline.prototype.setFrame = function(frameIndex, time, rotateMix, translateMix, scaleMix, shearMix) { + frameIndex *= TransformConstraintTimeline.ENTRIES; + this.frames[frameIndex] = time; + this.frames[frameIndex + TransformConstraintTimeline.ROTATE] = rotateMix; + this.frames[frameIndex + TransformConstraintTimeline.TRANSLATE] = translateMix; + this.frames[frameIndex + TransformConstraintTimeline.SCALE] = scaleMix; + this.frames[frameIndex + TransformConstraintTimeline.SHEAR] = shearMix; + }; + TransformConstraintTimeline.prototype.apply = function(skeleton, lastTime, time, firedEvents, alpha, blend, direction) { + var frames = this.frames; + var constraint = skeleton.transformConstraints[this.transformConstraintIndex]; + if (!constraint.active) return; + if (time < frames[0]) { + var data = constraint.data; + switch (blend) { + case MixBlend.setup: + constraint.rotateMix = data.rotateMix; + constraint.translateMix = data.translateMix; + constraint.scaleMix = data.scaleMix; + constraint.shearMix = data.shearMix; + return; + + case MixBlend.first: + constraint.rotateMix += (data.rotateMix - constraint.rotateMix) * alpha; + constraint.translateMix += (data.translateMix - constraint.translateMix) * alpha; + constraint.scaleMix += (data.scaleMix - constraint.scaleMix) * alpha; + constraint.shearMix += (data.shearMix - constraint.shearMix) * alpha; + } + return; + } + var rotate = 0, translate = 0, scale = 0, shear = 0; + if (time >= frames[frames.length - TransformConstraintTimeline.ENTRIES]) { + var i = frames.length; + rotate = frames[i + TransformConstraintTimeline.PREV_ROTATE]; + translate = frames[i + TransformConstraintTimeline.PREV_TRANSLATE]; + scale = frames[i + TransformConstraintTimeline.PREV_SCALE]; + shear = frames[i + TransformConstraintTimeline.PREV_SHEAR]; + } else { + var frame = Animation.binarySearch(frames, time, TransformConstraintTimeline.ENTRIES); + rotate = frames[frame + TransformConstraintTimeline.PREV_ROTATE]; + translate = frames[frame + TransformConstraintTimeline.PREV_TRANSLATE]; + scale = frames[frame + TransformConstraintTimeline.PREV_SCALE]; + shear = frames[frame + TransformConstraintTimeline.PREV_SHEAR]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent(frame / TransformConstraintTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + TransformConstraintTimeline.PREV_TIME] - frameTime)); + rotate += (frames[frame + TransformConstraintTimeline.ROTATE] - rotate) * percent; + translate += (frames[frame + TransformConstraintTimeline.TRANSLATE] - translate) * percent; + scale += (frames[frame + TransformConstraintTimeline.SCALE] - scale) * percent; + shear += (frames[frame + TransformConstraintTimeline.SHEAR] - shear) * percent; + } + if (blend == MixBlend.setup) { + var data = constraint.data; + constraint.rotateMix = data.rotateMix + (rotate - data.rotateMix) * alpha; + constraint.translateMix = data.translateMix + (translate - data.translateMix) * alpha; + constraint.scaleMix = data.scaleMix + (scale - data.scaleMix) * alpha; + constraint.shearMix = data.shearMix + (shear - data.shearMix) * alpha; + } else { + constraint.rotateMix += (rotate - constraint.rotateMix) * alpha; + constraint.translateMix += (translate - constraint.translateMix) * alpha; + constraint.scaleMix += (scale - constraint.scaleMix) * alpha; + constraint.shearMix += (shear - constraint.shearMix) * alpha; + } + }; + TransformConstraintTimeline.ENTRIES = 5; + TransformConstraintTimeline.PREV_TIME = -5; + TransformConstraintTimeline.PREV_ROTATE = -4; + TransformConstraintTimeline.PREV_TRANSLATE = -3; + TransformConstraintTimeline.PREV_SCALE = -2; + TransformConstraintTimeline.PREV_SHEAR = -1; + TransformConstraintTimeline.ROTATE = 1; + TransformConstraintTimeline.TRANSLATE = 2; + TransformConstraintTimeline.SCALE = 3; + TransformConstraintTimeline.SHEAR = 4; + return TransformConstraintTimeline; + })(CurveTimeline); + spine.TransformConstraintTimeline = TransformConstraintTimeline; + var PathConstraintPositionTimeline = (function(_super) { + __extends(PathConstraintPositionTimeline, _super); + function PathConstraintPositionTimeline(frameCount) { + var _this = _super.call(this, frameCount) || this; + _this.frames = spine.Utils.newFloatArray(frameCount * PathConstraintPositionTimeline.ENTRIES); + return _this; + } + PathConstraintPositionTimeline.prototype.getPropertyId = function() { + return (TimelineType.pathConstraintPosition << 24) + this.pathConstraintIndex; + }; + PathConstraintPositionTimeline.prototype.setFrame = function(frameIndex, time, value) { + frameIndex *= PathConstraintPositionTimeline.ENTRIES; + this.frames[frameIndex] = time; + this.frames[frameIndex + PathConstraintPositionTimeline.VALUE] = value; + }; + PathConstraintPositionTimeline.prototype.apply = function(skeleton, lastTime, time, firedEvents, alpha, blend, direction) { + var frames = this.frames; + var constraint = skeleton.pathConstraints[this.pathConstraintIndex]; + if (!constraint.active) return; + if (time < frames[0]) { + switch (blend) { + case MixBlend.setup: + constraint.position = constraint.data.position; + return; + + case MixBlend.first: + constraint.position += (constraint.data.position - constraint.position) * alpha; + } + return; + } + var position = 0; + if (time >= frames[frames.length - PathConstraintPositionTimeline.ENTRIES]) position = frames[frames.length + PathConstraintPositionTimeline.PREV_VALUE]; else { + var frame = Animation.binarySearch(frames, time, PathConstraintPositionTimeline.ENTRIES); + position = frames[frame + PathConstraintPositionTimeline.PREV_VALUE]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent(frame / PathConstraintPositionTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PathConstraintPositionTimeline.PREV_TIME] - frameTime)); + position += (frames[frame + PathConstraintPositionTimeline.VALUE] - position) * percent; + } + blend == MixBlend.setup ? constraint.position = constraint.data.position + (position - constraint.data.position) * alpha : constraint.position += (position - constraint.position) * alpha; + }; + PathConstraintPositionTimeline.ENTRIES = 2; + PathConstraintPositionTimeline.PREV_TIME = -2; + PathConstraintPositionTimeline.PREV_VALUE = -1; + PathConstraintPositionTimeline.VALUE = 1; + return PathConstraintPositionTimeline; + })(CurveTimeline); + spine.PathConstraintPositionTimeline = PathConstraintPositionTimeline; + var PathConstraintSpacingTimeline = (function(_super) { + __extends(PathConstraintSpacingTimeline, _super); + function PathConstraintSpacingTimeline(frameCount) { + return _super.call(this, frameCount) || this; + } + PathConstraintSpacingTimeline.prototype.getPropertyId = function() { + return (TimelineType.pathConstraintSpacing << 24) + this.pathConstraintIndex; + }; + PathConstraintSpacingTimeline.prototype.apply = function(skeleton, lastTime, time, firedEvents, alpha, blend, direction) { + var frames = this.frames; + var constraint = skeleton.pathConstraints[this.pathConstraintIndex]; + if (!constraint.active) return; + if (time < frames[0]) { + switch (blend) { + case MixBlend.setup: + constraint.spacing = constraint.data.spacing; + return; + + case MixBlend.first: + constraint.spacing += (constraint.data.spacing - constraint.spacing) * alpha; + } + return; + } + var spacing = 0; + if (time >= frames[frames.length - PathConstraintSpacingTimeline.ENTRIES]) spacing = frames[frames.length + PathConstraintSpacingTimeline.PREV_VALUE]; else { + var frame = Animation.binarySearch(frames, time, PathConstraintSpacingTimeline.ENTRIES); + spacing = frames[frame + PathConstraintSpacingTimeline.PREV_VALUE]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent(frame / PathConstraintSpacingTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PathConstraintSpacingTimeline.PREV_TIME] - frameTime)); + spacing += (frames[frame + PathConstraintSpacingTimeline.VALUE] - spacing) * percent; + } + blend == MixBlend.setup ? constraint.spacing = constraint.data.spacing + (spacing - constraint.data.spacing) * alpha : constraint.spacing += (spacing - constraint.spacing) * alpha; + }; + return PathConstraintSpacingTimeline; + })(PathConstraintPositionTimeline); + spine.PathConstraintSpacingTimeline = PathConstraintSpacingTimeline; + var PathConstraintMixTimeline = (function(_super) { + __extends(PathConstraintMixTimeline, _super); + function PathConstraintMixTimeline(frameCount) { + var _this = _super.call(this, frameCount) || this; + _this.frames = spine.Utils.newFloatArray(frameCount * PathConstraintMixTimeline.ENTRIES); + return _this; + } + PathConstraintMixTimeline.prototype.getPropertyId = function() { + return (TimelineType.pathConstraintMix << 24) + this.pathConstraintIndex; + }; + PathConstraintMixTimeline.prototype.setFrame = function(frameIndex, time, rotateMix, translateMix) { + frameIndex *= PathConstraintMixTimeline.ENTRIES; + this.frames[frameIndex] = time; + this.frames[frameIndex + PathConstraintMixTimeline.ROTATE] = rotateMix; + this.frames[frameIndex + PathConstraintMixTimeline.TRANSLATE] = translateMix; + }; + PathConstraintMixTimeline.prototype.apply = function(skeleton, lastTime, time, firedEvents, alpha, blend, direction) { + var frames = this.frames; + var constraint = skeleton.pathConstraints[this.pathConstraintIndex]; + if (!constraint.active) return; + if (time < frames[0]) { + switch (blend) { + case MixBlend.setup: + constraint.rotateMix = constraint.data.rotateMix; + constraint.translateMix = constraint.data.translateMix; + return; + + case MixBlend.first: + constraint.rotateMix += (constraint.data.rotateMix - constraint.rotateMix) * alpha; + constraint.translateMix += (constraint.data.translateMix - constraint.translateMix) * alpha; + } + return; + } + var rotate = 0, translate = 0; + if (time >= frames[frames.length - PathConstraintMixTimeline.ENTRIES]) { + rotate = frames[frames.length + PathConstraintMixTimeline.PREV_ROTATE]; + translate = frames[frames.length + PathConstraintMixTimeline.PREV_TRANSLATE]; + } else { + var frame = Animation.binarySearch(frames, time, PathConstraintMixTimeline.ENTRIES); + rotate = frames[frame + PathConstraintMixTimeline.PREV_ROTATE]; + translate = frames[frame + PathConstraintMixTimeline.PREV_TRANSLATE]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent(frame / PathConstraintMixTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PathConstraintMixTimeline.PREV_TIME] - frameTime)); + rotate += (frames[frame + PathConstraintMixTimeline.ROTATE] - rotate) * percent; + translate += (frames[frame + PathConstraintMixTimeline.TRANSLATE] - translate) * percent; + } + if (blend == MixBlend.setup) { + constraint.rotateMix = constraint.data.rotateMix + (rotate - constraint.data.rotateMix) * alpha; + constraint.translateMix = constraint.data.translateMix + (translate - constraint.data.translateMix) * alpha; + } else { + constraint.rotateMix += (rotate - constraint.rotateMix) * alpha; + constraint.translateMix += (translate - constraint.translateMix) * alpha; + } + }; + PathConstraintMixTimeline.ENTRIES = 3; + PathConstraintMixTimeline.PREV_TIME = -3; + PathConstraintMixTimeline.PREV_ROTATE = -2; + PathConstraintMixTimeline.PREV_TRANSLATE = -1; + PathConstraintMixTimeline.ROTATE = 1; + PathConstraintMixTimeline.TRANSLATE = 2; + return PathConstraintMixTimeline; + })(CurveTimeline); + spine.PathConstraintMixTimeline = PathConstraintMixTimeline; + })(spine || (spine = {})); + var spine; + (function(spine) { + var AnimationState = (function() { + function AnimationState(data) { + this.tracks = new Array(); + this.timeScale = 1; + this.events = new Array(); + this.listeners = new Array(); + this.queue = new EventQueue(this); + this.propertyIDs = new spine.IntSet(); + this.animationsChanged = false; + this.trackEntryPool = new spine.Pool(function() { + return new TrackEntry(); + }); + this.data = data; + } + AnimationState.prototype.update = function(delta) { + delta *= this.timeScale; + var tracks = this.tracks; + for (var i = 0, n = tracks.length; i < n; i++) { + var current = tracks[i]; + if (null == current) continue; + current.animationLast = current.nextAnimationLast; + current.trackLast = current.nextTrackLast; + var currentDelta = delta * current.timeScale; + if (current.delay > 0) { + current.delay -= currentDelta; + if (current.delay > 0) continue; + currentDelta = -current.delay; + current.delay = 0; + } + var next = current.next; + if (null != next) { + var nextTime = current.trackLast - next.delay; + if (nextTime >= 0) { + next.delay = 0; + next.trackTime += 0 == current.timeScale ? 0 : (nextTime / current.timeScale + delta) * next.timeScale; + current.trackTime += currentDelta; + this.setCurrent(i, next, true); + while (null != next.mixingFrom) { + next.mixTime += delta; + next = next.mixingFrom; + } + continue; + } + } else if (current.trackLast >= current.trackEnd && null == current.mixingFrom) { + tracks[i] = null; + this.queue.end(current); + this.disposeNext(current); + continue; + } + if (null != current.mixingFrom && this.updateMixingFrom(current, delta)) { + var from = current.mixingFrom; + current.mixingFrom = null; + null != from && (from.mixingTo = null); + while (null != from) { + this.queue.end(from); + from = from.mixingFrom; + } + } + current.trackTime += currentDelta; + } + this.queue.drain(); + }; + AnimationState.prototype.updateMixingFrom = function(to, delta) { + var from = to.mixingFrom; + if (null == from) return true; + var finished = this.updateMixingFrom(from, delta); + from.animationLast = from.nextAnimationLast; + from.trackLast = from.nextTrackLast; + if (to.mixTime > 0 && to.mixTime >= to.mixDuration) { + if (0 == from.totalAlpha || 0 == to.mixDuration) { + to.mixingFrom = from.mixingFrom; + null != from.mixingFrom && (from.mixingFrom.mixingTo = to); + to.interruptAlpha = from.interruptAlpha; + this.queue.end(from); + } + return finished; + } + from.trackTime += delta * from.timeScale; + to.mixTime += delta; + return false; + }; + AnimationState.prototype.apply = function(skeleton) { + if (null == skeleton) throw new Error("skeleton cannot be null."); + this.animationsChanged && this._animationsChanged(); + var events = this.events; + var tracks = this.tracks; + var applied = false; + for (var i = 0, n = tracks.length; i < n; i++) { + var current = tracks[i]; + if (null == current || current.delay > 0) continue; + applied = true; + var blend = 0 == i ? spine.MixBlend.first : current.mixBlend; + var mix = current.alpha; + null != current.mixingFrom ? mix *= this.applyMixingFrom(current, skeleton, blend) : current.trackTime >= current.trackEnd && null == current.next && (mix = 0); + var animationLast = current.animationLast, animationTime = current.getAnimationTime(); + var timelineCount = current.animation.timelines.length; + var timelines = current.animation.timelines; + if (0 == i && 1 == mix || blend == spine.MixBlend.add) for (var ii = 0; ii < timelineCount; ii++) { + spine.Utils.webkit602BugfixHelper(mix, blend); + timelines[ii].apply(skeleton, animationLast, animationTime, events, mix, blend, spine.MixDirection.mixIn); + } else { + var timelineMode = current.timelineMode; + var firstFrame = 0 == current.timelinesRotation.length; + firstFrame && spine.Utils.setArraySize(current.timelinesRotation, timelineCount << 1, null); + var timelinesRotation = current.timelinesRotation; + for (var ii = 0; ii < timelineCount; ii++) { + var timeline = timelines[ii]; + var timelineBlend = (timelineMode[ii] & AnimationState.NOT_LAST - 1) == AnimationState.SUBSEQUENT ? blend : spine.MixBlend.setup; + if (timeline instanceof spine.RotateTimeline) this.applyRotateTimeline(timeline, skeleton, animationTime, mix, timelineBlend, timelinesRotation, ii << 1, firstFrame); else { + spine.Utils.webkit602BugfixHelper(mix, blend); + timeline.apply(skeleton, animationLast, animationTime, events, mix, timelineBlend, spine.MixDirection.mixIn); + } + } + } + this.queueEvents(current, animationTime); + events.length = 0; + current.nextAnimationLast = animationTime; + current.nextTrackLast = current.trackTime; + } + this.queue.drain(); + return applied; + }; + AnimationState.prototype.applyMixingFrom = function(to, skeleton, blend) { + var from = to.mixingFrom; + null != from.mixingFrom && this.applyMixingFrom(from, skeleton, blend); + var mix = 0; + if (0 == to.mixDuration) { + mix = 1; + blend == spine.MixBlend.first && (blend = spine.MixBlend.setup); + } else { + mix = to.mixTime / to.mixDuration; + mix > 1 && (mix = 1); + blend != spine.MixBlend.first && (blend = from.mixBlend); + } + var events = mix < from.eventThreshold ? this.events : null; + var attachments = mix < from.attachmentThreshold, drawOrder = mix < from.drawOrderThreshold; + var animationLast = from.animationLast, animationTime = from.getAnimationTime(); + var timelineCount = from.animation.timelines.length; + var timelines = from.animation.timelines; + var alphaHold = from.alpha * to.interruptAlpha, alphaMix = alphaHold * (1 - mix); + if (blend == spine.MixBlend.add) for (var i = 0; i < timelineCount; i++) timelines[i].apply(skeleton, animationLast, animationTime, events, alphaMix, blend, spine.MixDirection.mixOut); else { + var timelineMode = from.timelineMode; + var timelineHoldMix = from.timelineHoldMix; + var firstFrame = 0 == from.timelinesRotation.length; + firstFrame && spine.Utils.setArraySize(from.timelinesRotation, timelineCount << 1, null); + var timelinesRotation = from.timelinesRotation; + from.totalAlpha = 0; + for (var i = 0; i < timelineCount; i++) { + var timeline = timelines[i]; + var direction = spine.MixDirection.mixOut; + var timelineBlend = void 0; + var alpha = 0; + switch (timelineMode[i] & AnimationState.NOT_LAST - 1) { + case AnimationState.SUBSEQUENT: + timelineBlend = blend; + if (!attachments && timeline instanceof spine.AttachmentTimeline) { + if ((timelineMode[i] & AnimationState.NOT_LAST) == AnimationState.NOT_LAST) continue; + timelineBlend = spine.MixBlend.setup; + } + if (!drawOrder && timeline instanceof spine.DrawOrderTimeline) continue; + alpha = alphaMix; + break; + + case AnimationState.FIRST: + timelineBlend = spine.MixBlend.setup; + alpha = alphaMix; + break; + + case AnimationState.HOLD: + timelineBlend = spine.MixBlend.setup; + alpha = alphaHold; + break; + + default: + timelineBlend = spine.MixBlend.setup; + var holdMix = timelineHoldMix[i]; + alpha = alphaHold * Math.max(0, 1 - holdMix.mixTime / holdMix.mixDuration); + } + from.totalAlpha += alpha; + if (timeline instanceof spine.RotateTimeline) this.applyRotateTimeline(timeline, skeleton, animationTime, alpha, timelineBlend, timelinesRotation, i << 1, firstFrame); else { + spine.Utils.webkit602BugfixHelper(alpha, blend); + timelineBlend == spine.MixBlend.setup && (timeline instanceof spine.AttachmentTimeline ? (attachments || (timelineMode[i] & AnimationState.NOT_LAST) == AnimationState.NOT_LAST) && (direction = spine.MixDirection.mixIn) : timeline instanceof spine.DrawOrderTimeline && drawOrder && (direction = spine.MixDirection.mixIn)); + timeline.apply(skeleton, animationLast, animationTime, events, alpha, timelineBlend, direction); + } + } + } + to.mixDuration > 0 && this.queueEvents(from, animationTime); + this.events.length = 0; + from.nextAnimationLast = animationTime; + from.nextTrackLast = from.trackTime; + return mix; + }; + AnimationState.prototype.applyRotateTimeline = function(timeline, skeleton, time, alpha, blend, timelinesRotation, i, firstFrame) { + firstFrame && (timelinesRotation[i] = 0); + if (1 == alpha) { + timeline.apply(skeleton, 0, time, null, 1, blend, spine.MixDirection.mixIn); + return; + } + var rotateTimeline = timeline; + var frames = rotateTimeline.frames; + var bone = skeleton.bones[rotateTimeline.boneIndex]; + if (!bone.active) return; + var r1 = 0, r2 = 0; + if (time < frames[0]) switch (blend) { + case spine.MixBlend.setup: + bone.rotation = bone.data.rotation; + + default: + return; + + case spine.MixBlend.first: + r1 = bone.rotation; + r2 = bone.data.rotation; + } else { + r1 = blend == spine.MixBlend.setup ? bone.data.rotation : bone.rotation; + if (time >= frames[frames.length - spine.RotateTimeline.ENTRIES]) r2 = bone.data.rotation + frames[frames.length + spine.RotateTimeline.PREV_ROTATION]; else { + var frame = spine.Animation.binarySearch(frames, time, spine.RotateTimeline.ENTRIES); + var prevRotation = frames[frame + spine.RotateTimeline.PREV_ROTATION]; + var frameTime = frames[frame]; + var percent = rotateTimeline.getCurvePercent((frame >> 1) - 1, 1 - (time - frameTime) / (frames[frame + spine.RotateTimeline.PREV_TIME] - frameTime)); + r2 = frames[frame + spine.RotateTimeline.ROTATION] - prevRotation; + r2 -= 360 * (16384 - (16384.499999999996 - r2 / 360 | 0)); + r2 = prevRotation + r2 * percent + bone.data.rotation; + r2 -= 360 * (16384 - (16384.499999999996 - r2 / 360 | 0)); + } + } + var total = 0, diff = r2 - r1; + diff -= 360 * (16384 - (16384.499999999996 - diff / 360 | 0)); + if (0 == diff) total = timelinesRotation[i]; else { + var lastTotal = 0, lastDiff = 0; + if (firstFrame) { + lastTotal = 0; + lastDiff = diff; + } else { + lastTotal = timelinesRotation[i]; + lastDiff = timelinesRotation[i + 1]; + } + var current = diff > 0, dir = lastTotal >= 0; + if (spine.MathUtils.signum(lastDiff) != spine.MathUtils.signum(diff) && Math.abs(lastDiff) <= 90) { + Math.abs(lastTotal) > 180 && (lastTotal += 360 * spine.MathUtils.signum(lastTotal)); + dir = current; + } + total = diff + lastTotal - lastTotal % 360; + dir != current && (total += 360 * spine.MathUtils.signum(lastTotal)); + timelinesRotation[i] = total; + } + timelinesRotation[i + 1] = diff; + r1 += total * alpha; + bone.rotation = r1 - 360 * (16384 - (16384.499999999996 - r1 / 360 | 0)); + }; + AnimationState.prototype.queueEvents = function(entry, animationTime) { + var animationStart = entry.animationStart, animationEnd = entry.animationEnd; + var duration = animationEnd - animationStart; + var trackLastWrapped = entry.trackLast % duration; + var events = this.events; + var i = 0, n = events.length; + for (;i < n; i++) { + var event_1 = events[i]; + if (event_1.time < trackLastWrapped) break; + if (event_1.time > animationEnd) continue; + this.queue.event(entry, event_1); + } + var complete = false; + complete = entry.loop ? 0 == duration || trackLastWrapped > entry.trackTime % duration : animationTime >= animationEnd && entry.animationLast < animationEnd; + complete && this.queue.complete(entry); + for (;i < n; i++) { + var event_2 = events[i]; + if (event_2.time < animationStart) continue; + this.queue.event(entry, events[i]); + } + }; + AnimationState.prototype.clearTracks = function() { + var oldDrainDisabled = this.queue.drainDisabled; + this.queue.drainDisabled = true; + for (var i = 0, n = this.tracks.length; i < n; i++) this.clearTrack(i); + this.tracks.length = 0; + this.queue.drainDisabled = oldDrainDisabled; + this.queue.drain(); + }; + AnimationState.prototype.clearTrack = function(trackIndex) { + if (trackIndex >= this.tracks.length) return; + var current = this.tracks[trackIndex]; + if (null == current) return; + this.queue.end(current); + this.disposeNext(current); + var entry = current; + while (true) { + var from = entry.mixingFrom; + if (null == from) break; + this.queue.end(from); + entry.mixingFrom = null; + entry.mixingTo = null; + entry = from; + } + this.tracks[current.trackIndex] = null; + this.queue.drain(); + }; + AnimationState.prototype.setCurrent = function(index, current, interrupt) { + var from = this.expandToIndex(index); + this.tracks[index] = current; + if (null != from) { + interrupt && this.queue.interrupt(from); + current.mixingFrom = from; + from.mixingTo = current; + current.mixTime = 0; + null != from.mixingFrom && from.mixDuration > 0 && (current.interruptAlpha *= Math.min(1, from.mixTime / from.mixDuration)); + from.timelinesRotation.length = 0; + } + this.queue.start(current); + }; + AnimationState.prototype.setAnimation = function(trackIndex, animationName, loop) { + var animation = this.data.skeletonData.findAnimation(animationName); + if (null == animation) throw new Error("Animation not found: " + animationName); + return this.setAnimationWith(trackIndex, animation, loop); + }; + AnimationState.prototype.setAnimationWith = function(trackIndex, animation, loop) { + if (null == animation) throw new Error("animation cannot be null."); + var interrupt = true; + var current = this.expandToIndex(trackIndex); + if (null != current) if (-1 == current.nextTrackLast) { + this.tracks[trackIndex] = current.mixingFrom; + this.queue.interrupt(current); + this.queue.end(current); + this.disposeNext(current); + current = current.mixingFrom; + interrupt = false; + } else this.disposeNext(current); + var entry = this.trackEntry(trackIndex, animation, loop, current); + this.setCurrent(trackIndex, entry, interrupt); + this.queue.drain(); + return entry; + }; + AnimationState.prototype.addAnimation = function(trackIndex, animationName, loop, delay) { + var animation = this.data.skeletonData.findAnimation(animationName); + if (null == animation) throw new Error("Animation not found: " + animationName); + return this.addAnimationWith(trackIndex, animation, loop, delay); + }; + AnimationState.prototype.addAnimationWith = function(trackIndex, animation, loop, delay) { + if (null == animation) throw new Error("animation cannot be null."); + var last = this.expandToIndex(trackIndex); + if (null != last) while (null != last.next) last = last.next; + var entry = this.trackEntry(trackIndex, animation, loop, last); + if (null == last) { + this.setCurrent(trackIndex, entry, true); + this.queue.drain(); + } else { + last.next = entry; + if (delay <= 0) { + var duration = last.animationEnd - last.animationStart; + if (0 != duration) { + last.loop ? delay += duration * (1 + (last.trackTime / duration | 0)) : delay += Math.max(duration, last.trackTime); + delay -= this.data.getMix(last.animation, animation); + } else delay = last.trackTime; + } + } + entry.delay = delay; + return entry; + }; + AnimationState.prototype.setEmptyAnimation = function(trackIndex, mixDuration) { + var entry = this.setAnimationWith(trackIndex, AnimationState.emptyAnimation, false); + entry.mixDuration = mixDuration; + entry.trackEnd = mixDuration; + return entry; + }; + AnimationState.prototype.addEmptyAnimation = function(trackIndex, mixDuration, delay) { + delay <= 0 && (delay -= mixDuration); + var entry = this.addAnimationWith(trackIndex, AnimationState.emptyAnimation, false, delay); + entry.mixDuration = mixDuration; + entry.trackEnd = mixDuration; + return entry; + }; + AnimationState.prototype.setEmptyAnimations = function(mixDuration) { + var oldDrainDisabled = this.queue.drainDisabled; + this.queue.drainDisabled = true; + for (var i = 0, n = this.tracks.length; i < n; i++) { + var current = this.tracks[i]; + null != current && this.setEmptyAnimation(current.trackIndex, mixDuration); + } + this.queue.drainDisabled = oldDrainDisabled; + this.queue.drain(); + }; + AnimationState.prototype.expandToIndex = function(index) { + if (index < this.tracks.length) return this.tracks[index]; + spine.Utils.ensureArrayCapacity(this.tracks, index + 1, null); + this.tracks.length = index + 1; + return null; + }; + AnimationState.prototype.trackEntry = function(trackIndex, animation, loop, last) { + var entry = this.trackEntryPool.obtain(); + entry.trackIndex = trackIndex; + entry.animation = animation; + entry.loop = loop; + entry.holdPrevious = false; + entry.eventThreshold = 0; + entry.attachmentThreshold = 0; + entry.drawOrderThreshold = 0; + entry.animationStart = 0; + entry.animationEnd = animation.duration; + entry.animationLast = -1; + entry.nextAnimationLast = -1; + entry.delay = 0; + entry.trackTime = 0; + entry.trackLast = -1; + entry.nextTrackLast = -1; + entry.trackEnd = Number.MAX_VALUE; + entry.timeScale = 1; + entry.alpha = 1; + entry.interruptAlpha = 1; + entry.mixTime = 0; + entry.mixDuration = null == last ? 0 : this.data.getMix(last.animation, animation); + return entry; + }; + AnimationState.prototype.disposeNext = function(entry) { + var next = entry.next; + while (null != next) { + this.queue.dispose(next); + next = next.next; + } + entry.next = null; + }; + AnimationState.prototype._animationsChanged = function() { + this.animationsChanged = false; + this.propertyIDs.clear(); + for (var i = 0, n = this.tracks.length; i < n; i++) { + var entry = this.tracks[i]; + if (null == entry) continue; + while (null != entry.mixingFrom) entry = entry.mixingFrom; + do { + null != entry.mixingFrom && entry.mixBlend == spine.MixBlend.add || this.computeHold(entry); + entry = entry.mixingTo; + } while (null != entry); + } + this.propertyIDs.clear(); + for (var i = this.tracks.length - 1; i >= 0; i--) { + var entry = this.tracks[i]; + while (null != entry) { + this.computeNotLast(entry); + entry = entry.mixingFrom; + } + } + }; + AnimationState.prototype.computeHold = function(entry) { + var to = entry.mixingTo; + var timelines = entry.animation.timelines; + var timelinesCount = entry.animation.timelines.length; + var timelineMode = spine.Utils.setArraySize(entry.timelineMode, timelinesCount); + entry.timelineHoldMix.length = 0; + var timelineDipMix = spine.Utils.setArraySize(entry.timelineHoldMix, timelinesCount); + var propertyIDs = this.propertyIDs; + if (null != to && to.holdPrevious) { + for (var i = 0; i < timelinesCount; i++) { + propertyIDs.add(timelines[i].getPropertyId()); + timelineMode[i] = AnimationState.HOLD; + } + return; + } + outer: for (var i = 0; i < timelinesCount; i++) { + var timeline = timelines[i]; + var id = timeline.getPropertyId(); + if (propertyIDs.add(id)) if (null == to || timeline instanceof spine.AttachmentTimeline || timeline instanceof spine.DrawOrderTimeline || timeline instanceof spine.EventTimeline || !to.animation.hasTimeline(id)) timelineMode[i] = AnimationState.FIRST; else { + for (var next = to.mixingTo; null != next; next = next.mixingTo) { + if (next.animation.hasTimeline(id)) continue; + if (entry.mixDuration > 0) { + timelineMode[i] = AnimationState.HOLD_MIX; + timelineDipMix[i] = next; + continue outer; + } + break; + } + timelineMode[i] = AnimationState.HOLD; + } else timelineMode[i] = AnimationState.SUBSEQUENT; + } + }; + AnimationState.prototype.computeNotLast = function(entry) { + var timelines = entry.animation.timelines; + var timelinesCount = entry.animation.timelines.length; + var timelineMode = entry.timelineMode; + var propertyIDs = this.propertyIDs; + for (var i = 0; i < timelinesCount; i++) if (timelines[i] instanceof spine.AttachmentTimeline) { + var timeline = timelines[i]; + propertyIDs.add(timeline.slotIndex) || (timelineMode[i] |= AnimationState.NOT_LAST); + } + }; + AnimationState.prototype.getCurrent = function(trackIndex) { + if (trackIndex >= this.tracks.length) return null; + return this.tracks[trackIndex]; + }; + AnimationState.prototype.addListener = function(listener) { + if (null == listener) throw new Error("listener cannot be null."); + this.listeners.push(listener); + }; + AnimationState.prototype.removeListener = function(listener) { + var index = this.listeners.indexOf(listener); + index >= 0 && this.listeners.splice(index, 1); + }; + AnimationState.prototype.clearListeners = function() { + this.listeners.length = 0; + }; + AnimationState.prototype.clearListenerNotifications = function() { + this.queue.clear(); + }; + AnimationState.emptyAnimation = new spine.Animation("", [], 0); + AnimationState.SUBSEQUENT = 0; + AnimationState.FIRST = 1; + AnimationState.HOLD = 2; + AnimationState.HOLD_MIX = 3; + AnimationState.NOT_LAST = 4; + return AnimationState; + })(); + spine.AnimationState = AnimationState; + var TrackEntry = (function() { + function TrackEntry() { + this.mixBlend = spine.MixBlend.replace; + this.timelineMode = new Array(); + this.timelineHoldMix = new Array(); + this.timelinesRotation = new Array(); + } + TrackEntry.prototype.reset = function() { + this.next = null; + this.mixingFrom = null; + this.mixingTo = null; + this.animation = null; + this.listener = null; + this.timelineMode.length = 0; + this.timelineHoldMix.length = 0; + this.timelinesRotation.length = 0; + }; + TrackEntry.prototype.getAnimationTime = function() { + if (this.loop) { + var duration = this.animationEnd - this.animationStart; + if (0 == duration) return this.animationStart; + return this.trackTime % duration + this.animationStart; + } + return Math.min(this.trackTime + this.animationStart, this.animationEnd); + }; + TrackEntry.prototype.setAnimationLast = function(animationLast) { + this.animationLast = animationLast; + this.nextAnimationLast = animationLast; + }; + TrackEntry.prototype.isComplete = function() { + return this.trackTime >= this.animationEnd - this.animationStart; + }; + TrackEntry.prototype.resetRotationDirections = function() { + this.timelinesRotation.length = 0; + }; + return TrackEntry; + })(); + spine.TrackEntry = TrackEntry; + var EventQueue = (function() { + function EventQueue(animState) { + this.objects = []; + this.drainDisabled = false; + this.animState = animState; + } + EventQueue.prototype.start = function(entry) { + this.objects.push(EventType.start); + this.objects.push(entry); + this.animState.animationsChanged = true; + }; + EventQueue.prototype.interrupt = function(entry) { + this.objects.push(EventType.interrupt); + this.objects.push(entry); + }; + EventQueue.prototype.end = function(entry) { + this.objects.push(EventType.end); + this.objects.push(entry); + this.animState.animationsChanged = true; + }; + EventQueue.prototype.dispose = function(entry) { + this.objects.push(EventType.dispose); + this.objects.push(entry); + }; + EventQueue.prototype.complete = function(entry) { + this.objects.push(EventType.complete); + this.objects.push(entry); + }; + EventQueue.prototype.event = function(entry, event) { + this.objects.push(EventType.event); + this.objects.push(entry); + this.objects.push(event); + }; + EventQueue.prototype.drain = function() { + if (this.drainDisabled) return; + this.drainDisabled = true; + var objects = this.objects; + var listeners = this.animState.listeners; + for (var i = 0; i < objects.length; i += 2) { + var type = objects[i]; + var entry = objects[i + 1]; + switch (type) { + case EventType.start: + null != entry.listener && entry.listener.start && entry.listener.start(entry); + for (var ii = 0; ii < listeners.length; ii++) listeners[ii].start && listeners[ii].start(entry); + break; + + case EventType.interrupt: + null != entry.listener && entry.listener.interrupt && entry.listener.interrupt(entry); + for (var ii = 0; ii < listeners.length; ii++) listeners[ii].interrupt && listeners[ii].interrupt(entry); + break; + + case EventType.end: + null != entry.listener && entry.listener.end && entry.listener.end(entry); + for (var ii = 0; ii < listeners.length; ii++) listeners[ii].end && listeners[ii].end(entry); + + case EventType.dispose: + null != entry.listener && entry.listener.dispose && entry.listener.dispose(entry); + for (var ii = 0; ii < listeners.length; ii++) listeners[ii].dispose && listeners[ii].dispose(entry); + this.animState.trackEntryPool.free(entry); + break; + + case EventType.complete: + null != entry.listener && entry.listener.complete && entry.listener.complete(entry); + for (var ii = 0; ii < listeners.length; ii++) listeners[ii].complete && listeners[ii].complete(entry); + break; + + case EventType.event: + var event_3 = objects[2 + i++]; + null != entry.listener && entry.listener.event && entry.listener.event(entry, event_3); + for (var ii = 0; ii < listeners.length; ii++) listeners[ii].event && listeners[ii].event(entry, event_3); + } + } + this.clear(); + this.drainDisabled = false; + }; + EventQueue.prototype.clear = function() { + this.objects.length = 0; + }; + return EventQueue; + })(); + spine.EventQueue = EventQueue; + var EventType; + (function(EventType) { + EventType[EventType["start"] = 0] = "start"; + EventType[EventType["interrupt"] = 1] = "interrupt"; + EventType[EventType["end"] = 2] = "end"; + EventType[EventType["dispose"] = 3] = "dispose"; + EventType[EventType["complete"] = 4] = "complete"; + EventType[EventType["event"] = 5] = "event"; + })(EventType = spine.EventType || (spine.EventType = {})); + var AnimationStateAdapter = (function() { + function AnimationStateAdapter() {} + AnimationStateAdapter.prototype.start = function(entry) {}; + AnimationStateAdapter.prototype.interrupt = function(entry) {}; + AnimationStateAdapter.prototype.end = function(entry) {}; + AnimationStateAdapter.prototype.dispose = function(entry) {}; + AnimationStateAdapter.prototype.complete = function(entry) {}; + AnimationStateAdapter.prototype.event = function(entry, event) {}; + return AnimationStateAdapter; + })(); + spine.AnimationStateAdapter = AnimationStateAdapter; + })(spine || (spine = {})); + var spine; + (function(spine) { + var AnimationStateData = (function() { + function AnimationStateData(skeletonData) { + this.animationToMixTime = {}; + this.defaultMix = 0; + if (null == skeletonData) throw new Error("skeletonData cannot be null."); + this.skeletonData = skeletonData; + } + AnimationStateData.prototype.setMix = function(fromName, toName, duration) { + var from = this.skeletonData.findAnimation(fromName); + if (null == from) throw new Error("Animation not found: " + fromName); + var to = this.skeletonData.findAnimation(toName); + if (null == to) throw new Error("Animation not found: " + toName); + this.setMixWith(from, to, duration); + }; + AnimationStateData.prototype.setMixWith = function(from, to, duration) { + if (null == from) throw new Error("from cannot be null."); + if (null == to) throw new Error("to cannot be null."); + var key = from.name + "." + to.name; + this.animationToMixTime[key] = duration; + }; + AnimationStateData.prototype.getMix = function(from, to) { + var key = from.name + "." + to.name; + var value = this.animationToMixTime[key]; + return void 0 === value ? this.defaultMix : value; + }; + return AnimationStateData; + })(); + spine.AnimationStateData = AnimationStateData; + })(spine || (spine = {})); + var spine; + (function(spine) { + var AssetManager = (function() { + function AssetManager(textureLoader, pathPrefix) { + void 0 === pathPrefix && (pathPrefix = ""); + this.assets = {}; + this.errors = {}; + this.toLoad = 0; + this.loaded = 0; + this.textureLoader = textureLoader; + this.pathPrefix = pathPrefix; + } + AssetManager.downloadText = function(url, success, error) { + var request = new XMLHttpRequest(); + request.open("GET", url, true); + request.onload = function() { + 200 == request.status ? success(request.responseText) : error(request.status, request.responseText); + }; + request.onerror = function() { + error(request.status, request.responseText); + }; + request.send(); + }; + AssetManager.downloadBinary = function(url, success, error) { + var request = new XMLHttpRequest(); + request.open("GET", url, true); + request.responseType = "arraybuffer"; + request.onload = function() { + 200 == request.status ? success(new Uint8Array(request.response)) : error(request.status, request.responseText); + }; + request.onerror = function() { + error(request.status, request.responseText); + }; + request.send(); + }; + AssetManager.prototype.loadBinary = function(path, success, error) { + var _this = this; + void 0 === success && (success = null); + void 0 === error && (error = null); + path = this.pathPrefix + path; + this.toLoad++; + AssetManager.downloadBinary(path, (function(data) { + _this.assets[path] = data; + success && success(path, data); + _this.toLoad--; + _this.loaded++; + }), (function(state, responseText) { + _this.errors[path] = "Couldn't load binary " + path + ": status " + status + ", " + responseText; + error && error(path, "Couldn't load binary " + path + ": status " + status + ", " + responseText); + _this.toLoad--; + _this.loaded++; + })); + }; + AssetManager.prototype.loadText = function(path, success, error) { + var _this = this; + void 0 === success && (success = null); + void 0 === error && (error = null); + path = this.pathPrefix + path; + this.toLoad++; + AssetManager.downloadText(path, (function(data) { + _this.assets[path] = data; + success && success(path, data); + _this.toLoad--; + _this.loaded++; + }), (function(state, responseText) { + _this.errors[path] = "Couldn't load text " + path + ": status " + status + ", " + responseText; + error && error(path, "Couldn't load text " + path + ": status " + status + ", " + responseText); + _this.toLoad--; + _this.loaded++; + })); + }; + AssetManager.prototype.loadTexture = function(path, success, error) { + var _this = this; + void 0 === success && (success = null); + void 0 === error && (error = null); + path = this.pathPrefix + path; + this.toLoad++; + var img = new Image(); + img.crossOrigin = "anonymous"; + img.onload = function(ev) { + var texture = _this.textureLoader(img); + _this.assets[path] = texture; + _this.toLoad--; + _this.loaded++; + success && success(path, img); + }; + img.onerror = function(ev) { + _this.errors[path] = "Couldn't load image " + path; + _this.toLoad--; + _this.loaded++; + error && error(path, "Couldn't load image " + path); + }; + img.src = path; + }; + AssetManager.prototype.loadTextureData = function(path, data, success, error) { + var _this = this; + void 0 === success && (success = null); + void 0 === error && (error = null); + path = this.pathPrefix + path; + this.toLoad++; + var img = new Image(); + img.onload = function(ev) { + var texture = _this.textureLoader(img); + _this.assets[path] = texture; + _this.toLoad--; + _this.loaded++; + success && success(path, img); + }; + img.onerror = function(ev) { + _this.errors[path] = "Couldn't load image " + path; + _this.toLoad--; + _this.loaded++; + error && error(path, "Couldn't load image " + path); + }; + img.src = data; + }; + AssetManager.prototype.loadTextureAtlas = function(path, success, error) { + var _this = this; + void 0 === success && (success = null); + void 0 === error && (error = null); + var parent = path.lastIndexOf("/") >= 0 ? path.substring(0, path.lastIndexOf("/")) : ""; + path = this.pathPrefix + path; + this.toLoad++; + AssetManager.downloadText(path, (function(atlasData) { + var pagesLoaded = { + count: 0 + }; + var atlasPages = new Array(); + try { + var atlas = new spine.TextureAtlas(atlasData, function(path) { + atlasPages.push(parent + "/" + path); + var image = document.createElement("img"); + image.width = 16; + image.height = 16; + return new spine.FakeTexture(image); + }); + } catch (e) { + var ex = e; + _this.errors[path] = "Couldn't load texture atlas " + path + ": " + ex.message; + error && error(path, "Couldn't load texture atlas " + path + ": " + ex.message); + _this.toLoad--; + _this.loaded++; + return; + } + var _loop_1 = function _loop_1(atlasPage) { + var pageLoadError = false; + _this.loadTexture(atlasPage, (function(imagePath, image) { + pagesLoaded.count++; + if (pagesLoaded.count == atlasPages.length) if (pageLoadError) { + _this.errors[path] = "Couldn't load texture atlas page " + imagePath + "} of atlas " + path; + error && error(path, "Couldn't load texture atlas page " + imagePath + " of atlas " + path); + _this.toLoad--; + _this.loaded++; + } else try { + var atlas = new spine.TextureAtlas(atlasData, function(path) { + return _this.get(parent + "/" + path); + }); + _this.assets[path] = atlas; + success && success(path, atlas); + _this.toLoad--; + _this.loaded++; + } catch (e) { + var ex = e; + _this.errors[path] = "Couldn't load texture atlas " + path + ": " + ex.message; + error && error(path, "Couldn't load texture atlas " + path + ": " + ex.message); + _this.toLoad--; + _this.loaded++; + } + }), (function(imagePath, errorMessage) { + pageLoadError = true; + pagesLoaded.count++; + if (pagesLoaded.count == atlasPages.length) { + _this.errors[path] = "Couldn't load texture atlas page " + imagePath + "} of atlas " + path; + error && error(path, "Couldn't load texture atlas page " + imagePath + " of atlas " + path); + _this.toLoad--; + _this.loaded++; + } + })); + }; + for (var _i = 0, atlasPages_1 = atlasPages; _i < atlasPages_1.length; _i++) { + var atlasPage = atlasPages_1[_i]; + _loop_1(atlasPage); + } + }), (function(state, responseText) { + _this.errors[path] = "Couldn't load texture atlas " + path + ": status " + status + ", " + responseText; + error && error(path, "Couldn't load texture atlas " + path + ": status " + status + ", " + responseText); + _this.toLoad--; + _this.loaded++; + })); + }; + AssetManager.prototype.get = function(path) { + path = this.pathPrefix + path; + return this.assets[path]; + }; + AssetManager.prototype.remove = function(path) { + path = this.pathPrefix + path; + var asset = this.assets[path]; + asset.dispose && asset.dispose(); + this.assets[path] = null; + }; + AssetManager.prototype.removeAll = function() { + for (var key in this.assets) { + var asset = this.assets[key]; + asset.dispose && asset.dispose(); + } + this.assets = {}; + }; + AssetManager.prototype.isLoadingComplete = function() { + return 0 == this.toLoad; + }; + AssetManager.prototype.getToLoad = function() { + return this.toLoad; + }; + AssetManager.prototype.getLoaded = function() { + return this.loaded; + }; + AssetManager.prototype.dispose = function() { + this.removeAll(); + }; + AssetManager.prototype.hasErrors = function() { + return Object.keys(this.errors).length > 0; + }; + AssetManager.prototype.getErrors = function() { + return this.errors; + }; + return AssetManager; + })(); + spine.AssetManager = AssetManager; + })(spine || (spine = {})); + var spine; + (function(spine) { + var AtlasAttachmentLoader = (function() { + function AtlasAttachmentLoader(atlas) { + this.atlas = atlas; + } + AtlasAttachmentLoader.prototype.newRegionAttachment = function(skin, name, path) { + var region = this.atlas.findRegion(path); + if (null == region) return null; + region.renderObject = region; + var attachment = new spine.RegionAttachment(name); + attachment.setRegion(region); + return attachment; + }; + AtlasAttachmentLoader.prototype.newMeshAttachment = function(skin, name, path) { + var region = this.atlas.findRegion(path); + if (null == region) return null; + region.renderObject = region; + var attachment = new spine.MeshAttachment(name); + attachment.region = region; + return attachment; + }; + AtlasAttachmentLoader.prototype.newBoundingBoxAttachment = function(skin, name) { + return new spine.BoundingBoxAttachment(name); + }; + AtlasAttachmentLoader.prototype.newPathAttachment = function(skin, name) { + return new spine.PathAttachment(name); + }; + AtlasAttachmentLoader.prototype.newPointAttachment = function(skin, name) { + return new spine.PointAttachment(name); + }; + AtlasAttachmentLoader.prototype.newClippingAttachment = function(skin, name) { + return new spine.ClippingAttachment(name); + }; + return AtlasAttachmentLoader; + })(); + spine.AtlasAttachmentLoader = AtlasAttachmentLoader; + })(spine || (spine = {})); + var spine; + (function(spine) { + var BlendMode; + (function(BlendMode) { + BlendMode[BlendMode["Normal"] = 0] = "Normal"; + BlendMode[BlendMode["Additive"] = 1] = "Additive"; + BlendMode[BlendMode["Multiply"] = 2] = "Multiply"; + BlendMode[BlendMode["Screen"] = 3] = "Screen"; + })(BlendMode = spine.BlendMode || (spine.BlendMode = {})); + })(spine || (spine = {})); + var spine; + (function(spine) { + var Bone = (function() { + function Bone(data, skeleton, parent) { + this.children = new Array(); + this.x = 0; + this.y = 0; + this.rotation = 0; + this.scaleX = 0; + this.scaleY = 0; + this.shearX = 0; + this.shearY = 0; + this.ax = 0; + this.ay = 0; + this.arotation = 0; + this.ascaleX = 0; + this.ascaleY = 0; + this.ashearX = 0; + this.ashearY = 0; + this.appliedValid = false; + this.a = 0; + this.b = 0; + this.c = 0; + this.d = 0; + this.worldY = 0; + this.worldX = 0; + this.sorted = false; + this.active = false; + if (null == data) throw new Error("data cannot be null."); + if (null == skeleton) throw new Error("skeleton cannot be null."); + this.data = data; + this.skeleton = skeleton; + this.parent = parent; + this.setToSetupPose(); + } + Bone.prototype.isActive = function() { + return this.active; + }; + Bone.prototype.update = function() { + this.updateWorldTransformWith(this.x, this.y, this.rotation, this.scaleX, this.scaleY, this.shearX, this.shearY); + }; + Bone.prototype.updateWorldTransform = function() { + this.updateWorldTransformWith(this.x, this.y, this.rotation, this.scaleX, this.scaleY, this.shearX, this.shearY); + }; + Bone.prototype.updateWorldTransformWith = function(x, y, rotation, scaleX, scaleY, shearX, shearY) { + this.ax = x; + this.ay = y; + this.arotation = rotation; + this.ascaleX = scaleX; + this.ascaleY = scaleY; + this.ashearX = shearX; + this.ashearY = shearY; + this.appliedValid = true; + var parent = this.parent; + if (null == parent) { + var skeleton = this.skeleton; + var rotationY = rotation + 90 + shearY; + var sx = skeleton.scaleX; + var sy = skeleton.scaleY; + this.a = spine.MathUtils.cosDeg(rotation + shearX) * scaleX * sx; + this.b = spine.MathUtils.cosDeg(rotationY) * scaleY * sx; + this.c = spine.MathUtils.sinDeg(rotation + shearX) * scaleX * sy; + this.d = spine.MathUtils.sinDeg(rotationY) * scaleY * sy; + this.worldX = x * sx + skeleton.x; + this.worldY = y * sy + skeleton.y; + return; + } + var pa = parent.a, pb = parent.b, pc = parent.c, pd = parent.d; + this.worldX = pa * x + pb * y + parent.worldX; + this.worldY = pc * x + pd * y + parent.worldY; + switch (this.data.transformMode) { + case spine.TransformMode.Normal: + var rotationY = rotation + 90 + shearY; + var la = spine.MathUtils.cosDeg(rotation + shearX) * scaleX; + var lb = spine.MathUtils.cosDeg(rotationY) * scaleY; + var lc = spine.MathUtils.sinDeg(rotation + shearX) * scaleX; + var ld = spine.MathUtils.sinDeg(rotationY) * scaleY; + this.a = pa * la + pb * lc; + this.b = pa * lb + pb * ld; + this.c = pc * la + pd * lc; + this.d = pc * lb + pd * ld; + return; + + case spine.TransformMode.OnlyTranslation: + var rotationY = rotation + 90 + shearY; + this.a = spine.MathUtils.cosDeg(rotation + shearX) * scaleX; + this.b = spine.MathUtils.cosDeg(rotationY) * scaleY; + this.c = spine.MathUtils.sinDeg(rotation + shearX) * scaleX; + this.d = spine.MathUtils.sinDeg(rotationY) * scaleY; + break; + + case spine.TransformMode.NoRotationOrReflection: + var s = pa * pa + pc * pc; + var prx = 0; + if (s > 1e-4) { + s = Math.abs(pa * pd - pb * pc) / s; + pb = pc * s; + pd = pa * s; + prx = Math.atan2(pc, pa) * spine.MathUtils.radDeg; + } else { + pa = 0; + pc = 0; + prx = 90 - Math.atan2(pd, pb) * spine.MathUtils.radDeg; + } + var rx = rotation + shearX - prx; + var ry = rotation + shearY - prx + 90; + var la = spine.MathUtils.cosDeg(rx) * scaleX; + var lb = spine.MathUtils.cosDeg(ry) * scaleY; + var lc = spine.MathUtils.sinDeg(rx) * scaleX; + var ld = spine.MathUtils.sinDeg(ry) * scaleY; + this.a = pa * la - pb * lc; + this.b = pa * lb - pb * ld; + this.c = pc * la + pd * lc; + this.d = pc * lb + pd * ld; + break; + + case spine.TransformMode.NoScale: + case spine.TransformMode.NoScaleOrReflection: + var cos = spine.MathUtils.cosDeg(rotation); + var sin = spine.MathUtils.sinDeg(rotation); + var za = (pa * cos + pb * sin) / this.skeleton.scaleX; + var zc = (pc * cos + pd * sin) / this.skeleton.scaleY; + var s = Math.sqrt(za * za + zc * zc); + s > 1e-5 && (s = 1 / s); + za *= s; + zc *= s; + s = Math.sqrt(za * za + zc * zc); + this.data.transformMode == spine.TransformMode.NoScale && pa * pd - pb * pc < 0 != (this.skeleton.scaleX < 0 != this.skeleton.scaleY < 0) && (s = -s); + var r = Math.PI / 2 + Math.atan2(zc, za); + var zb = Math.cos(r) * s; + var zd = Math.sin(r) * s; + var la = spine.MathUtils.cosDeg(shearX) * scaleX; + var lb = spine.MathUtils.cosDeg(90 + shearY) * scaleY; + var lc = spine.MathUtils.sinDeg(shearX) * scaleX; + var ld = spine.MathUtils.sinDeg(90 + shearY) * scaleY; + this.a = za * la + zb * lc; + this.b = za * lb + zb * ld; + this.c = zc * la + zd * lc; + this.d = zc * lb + zd * ld; + } + this.a *= this.skeleton.scaleX; + this.b *= this.skeleton.scaleX; + this.c *= this.skeleton.scaleY; + this.d *= this.skeleton.scaleY; + }; + Bone.prototype.setToSetupPose = function() { + var data = this.data; + this.x = data.x; + this.y = data.y; + this.rotation = data.rotation; + this.scaleX = data.scaleX; + this.scaleY = data.scaleY; + this.shearX = data.shearX; + this.shearY = data.shearY; + }; + Bone.prototype.getWorldRotationX = function() { + return Math.atan2(this.c, this.a) * spine.MathUtils.radDeg; + }; + Bone.prototype.getWorldRotationY = function() { + return Math.atan2(this.d, this.b) * spine.MathUtils.radDeg; + }; + Bone.prototype.getWorldScaleX = function() { + return Math.sqrt(this.a * this.a + this.c * this.c); + }; + Bone.prototype.getWorldScaleY = function() { + return Math.sqrt(this.b * this.b + this.d * this.d); + }; + Bone.prototype.updateAppliedTransform = function() { + this.appliedValid = true; + var parent = this.parent; + if (null == parent) { + this.ax = this.worldX; + this.ay = this.worldY; + this.arotation = Math.atan2(this.c, this.a) * spine.MathUtils.radDeg; + this.ascaleX = Math.sqrt(this.a * this.a + this.c * this.c); + this.ascaleY = Math.sqrt(this.b * this.b + this.d * this.d); + this.ashearX = 0; + this.ashearY = Math.atan2(this.a * this.b + this.c * this.d, this.a * this.d - this.b * this.c) * spine.MathUtils.radDeg; + return; + } + var pa = parent.a, pb = parent.b, pc = parent.c, pd = parent.d; + var pid = 1 / (pa * pd - pb * pc); + var dx = this.worldX - parent.worldX, dy = this.worldY - parent.worldY; + this.ax = dx * pd * pid - dy * pb * pid; + this.ay = dy * pa * pid - dx * pc * pid; + var ia = pid * pd; + var id = pid * pa; + var ib = pid * pb; + var ic = pid * pc; + var ra = ia * this.a - ib * this.c; + var rb = ia * this.b - ib * this.d; + var rc = id * this.c - ic * this.a; + var rd = id * this.d - ic * this.b; + this.ashearX = 0; + this.ascaleX = Math.sqrt(ra * ra + rc * rc); + if (this.ascaleX > 1e-4) { + var det = ra * rd - rb * rc; + this.ascaleY = det / this.ascaleX; + this.ashearY = Math.atan2(ra * rb + rc * rd, det) * spine.MathUtils.radDeg; + this.arotation = Math.atan2(rc, ra) * spine.MathUtils.radDeg; + } else { + this.ascaleX = 0; + this.ascaleY = Math.sqrt(rb * rb + rd * rd); + this.ashearY = 0; + this.arotation = 90 - Math.atan2(rd, rb) * spine.MathUtils.radDeg; + } + }; + Bone.prototype.worldToLocal = function(world) { + var a = this.a, b = this.b, c = this.c, d = this.d; + var invDet = 1 / (a * d - b * c); + var x = world.x - this.worldX, y = world.y - this.worldY; + world.x = x * d * invDet - y * b * invDet; + world.y = y * a * invDet - x * c * invDet; + return world; + }; + Bone.prototype.localToWorld = function(local) { + var x = local.x, y = local.y; + local.x = x * this.a + y * this.b + this.worldX; + local.y = x * this.c + y * this.d + this.worldY; + return local; + }; + Bone.prototype.worldToLocalRotation = function(worldRotation) { + var sin = spine.MathUtils.sinDeg(worldRotation), cos = spine.MathUtils.cosDeg(worldRotation); + return Math.atan2(this.a * sin - this.c * cos, this.d * cos - this.b * sin) * spine.MathUtils.radDeg + this.rotation - this.shearX; + }; + Bone.prototype.localToWorldRotation = function(localRotation) { + localRotation -= this.rotation - this.shearX; + var sin = spine.MathUtils.sinDeg(localRotation), cos = spine.MathUtils.cosDeg(localRotation); + return Math.atan2(cos * this.c + sin * this.d, cos * this.a + sin * this.b) * spine.MathUtils.radDeg; + }; + Bone.prototype.rotateWorld = function(degrees) { + var a = this.a, b = this.b, c = this.c, d = this.d; + var cos = spine.MathUtils.cosDeg(degrees), sin = spine.MathUtils.sinDeg(degrees); + this.a = cos * a - sin * c; + this.b = cos * b - sin * d; + this.c = sin * a + cos * c; + this.d = sin * b + cos * d; + this.appliedValid = false; + }; + return Bone; + })(); + spine.Bone = Bone; + })(spine || (spine = {})); + var spine; + (function(spine) { + var BoneData = (function() { + function BoneData(index, name, parent) { + this.x = 0; + this.y = 0; + this.rotation = 0; + this.scaleX = 1; + this.scaleY = 1; + this.shearX = 0; + this.shearY = 0; + this.transformMode = TransformMode.Normal; + this.skinRequired = false; + this.color = new spine.Color(); + if (index < 0) throw new Error("index must be >= 0."); + if (null == name) throw new Error("name cannot be null."); + this.index = index; + this.name = name; + this.parent = parent; + } + return BoneData; + })(); + spine.BoneData = BoneData; + var TransformMode; + (function(TransformMode) { + TransformMode[TransformMode["Normal"] = 0] = "Normal"; + TransformMode[TransformMode["OnlyTranslation"] = 1] = "OnlyTranslation"; + TransformMode[TransformMode["NoRotationOrReflection"] = 2] = "NoRotationOrReflection"; + TransformMode[TransformMode["NoScale"] = 3] = "NoScale"; + TransformMode[TransformMode["NoScaleOrReflection"] = 4] = "NoScaleOrReflection"; + })(TransformMode = spine.TransformMode || (spine.TransformMode = {})); + })(spine || (spine = {})); + var spine; + (function(spine) { + var ConstraintData = (function() { + function ConstraintData(name, order, skinRequired) { + this.name = name; + this.order = order; + this.skinRequired = skinRequired; + } + return ConstraintData; + })(); + spine.ConstraintData = ConstraintData; + })(spine || (spine = {})); + var spine; + (function(spine) { + var Event = (function() { + function Event(time, data) { + if (null == data) throw new Error("data cannot be null."); + this.time = time; + this.data = data; + } + return Event; + })(); + spine.Event = Event; + })(spine || (spine = {})); + var spine; + (function(spine) { + var EventData = (function() { + function EventData(name) { + this.name = name; + } + return EventData; + })(); + spine.EventData = EventData; + })(spine || (spine = {})); + var spine; + (function(spine) { + var IkConstraint = (function() { + function IkConstraint(data, skeleton) { + this.bendDirection = 0; + this.compress = false; + this.stretch = false; + this.mix = 1; + this.softness = 0; + this.active = false; + if (null == data) throw new Error("data cannot be null."); + if (null == skeleton) throw new Error("skeleton cannot be null."); + this.data = data; + this.mix = data.mix; + this.softness = data.softness; + this.bendDirection = data.bendDirection; + this.compress = data.compress; + this.stretch = data.stretch; + this.bones = new Array(); + for (var i = 0; i < data.bones.length; i++) this.bones.push(skeleton.findBone(data.bones[i].name)); + this.target = skeleton.findBone(data.target.name); + } + IkConstraint.prototype.isActive = function() { + return this.active; + }; + IkConstraint.prototype.apply = function() { + this.update(); + }; + IkConstraint.prototype.update = function() { + var target = this.target; + var bones = this.bones; + switch (bones.length) { + case 1: + this.apply1(bones[0], target.worldX, target.worldY, this.compress, this.stretch, this.data.uniform, this.mix); + break; + + case 2: + this.apply2(bones[0], bones[1], target.worldX, target.worldY, this.bendDirection, this.stretch, this.softness, this.mix); + } + }; + IkConstraint.prototype.apply1 = function(bone, targetX, targetY, compress, stretch, uniform, alpha) { + bone.appliedValid || bone.updateAppliedTransform(); + var p = bone.parent; + var id = 1 / (p.a * p.d - p.b * p.c); + var x = targetX - p.worldX, y = targetY - p.worldY; + var tx = (x * p.d - y * p.b) * id - bone.ax, ty = (y * p.a - x * p.c) * id - bone.ay; + var rotationIK = Math.atan2(ty, tx) * spine.MathUtils.radDeg - bone.ashearX - bone.arotation; + bone.ascaleX < 0 && (rotationIK += 180); + rotationIK > 180 ? rotationIK -= 360 : rotationIK < -180 && (rotationIK += 360); + var sx = bone.ascaleX, sy = bone.ascaleY; + if (compress || stretch) { + var b = bone.data.length * sx, dd = Math.sqrt(tx * tx + ty * ty); + if (compress && dd < b || stretch && dd > b && b > 1e-4) { + var s = (dd / b - 1) * alpha + 1; + sx *= s; + uniform && (sy *= s); + } + } + bone.updateWorldTransformWith(bone.ax, bone.ay, bone.arotation + rotationIK * alpha, sx, sy, bone.ashearX, bone.ashearY); + }; + IkConstraint.prototype.apply2 = function(parent, child, targetX, targetY, bendDir, stretch, softness, alpha) { + if (0 == alpha) { + child.updateWorldTransform(); + return; + } + parent.appliedValid || parent.updateAppliedTransform(); + child.appliedValid || child.updateAppliedTransform(); + var px = parent.ax, py = parent.ay, psx = parent.ascaleX, sx = psx, psy = parent.ascaleY, csx = child.ascaleX; + var os1 = 0, os2 = 0, s2 = 0; + if (psx < 0) { + psx = -psx; + os1 = 180; + s2 = -1; + } else { + os1 = 0; + s2 = 1; + } + if (psy < 0) { + psy = -psy; + s2 = -s2; + } + if (csx < 0) { + csx = -csx; + os2 = 180; + } else os2 = 0; + var cx = child.ax, cy = 0, cwx = 0, cwy = 0, a = parent.a, b = parent.b, c = parent.c, d = parent.d; + var u = Math.abs(psx - psy) <= 1e-4; + if (u) { + cy = child.ay; + cwx = a * cx + b * cy + parent.worldX; + cwy = c * cx + d * cy + parent.worldY; + } else { + cy = 0; + cwx = a * cx + parent.worldX; + cwy = c * cx + parent.worldY; + } + var pp = parent.parent; + a = pp.a; + b = pp.b; + c = pp.c; + d = pp.d; + var id = 1 / (a * d - b * c), x = cwx - pp.worldX, y = cwy - pp.worldY; + var dx = (x * d - y * b) * id - px, dy = (y * a - x * c) * id - py; + var l1 = Math.sqrt(dx * dx + dy * dy), l2 = child.data.length * csx, a1, a2; + if (l1 < 1e-4) { + this.apply1(parent, targetX, targetY, false, stretch, false, alpha); + child.updateWorldTransformWith(cx, cy, 0, child.ascaleX, child.ascaleY, child.ashearX, child.ashearY); + return; + } + x = targetX - pp.worldX; + y = targetY - pp.worldY; + var tx = (x * d - y * b) * id - px, ty = (y * a - x * c) * id - py; + var dd = tx * tx + ty * ty; + if (0 != softness) { + softness *= psx * (csx + 1) / 2; + var td = Math.sqrt(dd), sd = td - l1 - l2 * psx + softness; + if (sd > 0) { + var p = Math.min(1, sd / (2 * softness)) - 1; + p = (sd - softness * (1 - p * p)) / td; + tx -= p * tx; + ty -= p * ty; + dd = tx * tx + ty * ty; + } + } + outer: if (u) { + l2 *= psx; + var cos = (dd - l1 * l1 - l2 * l2) / (2 * l1 * l2); + if (cos < -1) cos = -1; else if (cos > 1) { + cos = 1; + stretch && (sx *= (Math.sqrt(dd) / (l1 + l2) - 1) * alpha + 1); + } + a2 = Math.acos(cos) * bendDir; + a = l1 + l2 * cos; + b = l2 * Math.sin(a2); + a1 = Math.atan2(ty * a - tx * b, tx * a + ty * b); + } else { + a = psx * l2; + b = psy * l2; + var aa = a * a, bb = b * b, ta = Math.atan2(ty, tx); + c = bb * l1 * l1 + aa * dd - aa * bb; + var c1 = -2 * bb * l1, c2 = bb - aa; + d = c1 * c1 - 4 * c2 * c; + if (d >= 0) { + var q = Math.sqrt(d); + c1 < 0 && (q = -q); + q = -(c1 + q) / 2; + var r0 = q / c2, r1 = c / q; + var r = Math.abs(r0) < Math.abs(r1) ? r0 : r1; + if (r * r <= dd) { + y = Math.sqrt(dd - r * r) * bendDir; + a1 = ta - Math.atan2(y, r); + a2 = Math.atan2(y / psy, (r - l1) / psx); + break outer; + } + } + var minAngle = spine.MathUtils.PI, minX = l1 - a, minDist = minX * minX, minY = 0; + var maxAngle = 0, maxX = l1 + a, maxDist = maxX * maxX, maxY = 0; + c = -a * l1 / (aa - bb); + if (c >= -1 && c <= 1) { + c = Math.acos(c); + x = a * Math.cos(c) + l1; + y = b * Math.sin(c); + d = x * x + y * y; + if (d < minDist) { + minAngle = c; + minDist = d; + minX = x; + minY = y; + } + if (d > maxDist) { + maxAngle = c; + maxDist = d; + maxX = x; + maxY = y; + } + } + if (dd <= (minDist + maxDist) / 2) { + a1 = ta - Math.atan2(minY * bendDir, minX); + a2 = minAngle * bendDir; + } else { + a1 = ta - Math.atan2(maxY * bendDir, maxX); + a2 = maxAngle * bendDir; + } + } + var os = Math.atan2(cy, cx) * s2; + var rotation = parent.arotation; + a1 = (a1 - os) * spine.MathUtils.radDeg + os1 - rotation; + a1 > 180 ? a1 -= 360 : a1 < -180 && (a1 += 360); + parent.updateWorldTransformWith(px, py, rotation + a1 * alpha, sx, parent.ascaleY, 0, 0); + rotation = child.arotation; + a2 = ((a2 + os) * spine.MathUtils.radDeg - child.ashearX) * s2 + os2 - rotation; + a2 > 180 ? a2 -= 360 : a2 < -180 && (a2 += 360); + child.updateWorldTransformWith(cx, cy, rotation + a2 * alpha, child.ascaleX, child.ascaleY, child.ashearX, child.ashearY); + }; + return IkConstraint; + })(); + spine.IkConstraint = IkConstraint; + })(spine || (spine = {})); + var spine; + (function(spine) { + var IkConstraintData = (function(_super) { + __extends(IkConstraintData, _super); + function IkConstraintData(name) { + var _this = _super.call(this, name, 0, false) || this; + _this.bones = new Array(); + _this.bendDirection = 1; + _this.compress = false; + _this.stretch = false; + _this.uniform = false; + _this.mix = 1; + _this.softness = 0; + return _this; + } + return IkConstraintData; + })(spine.ConstraintData); + spine.IkConstraintData = IkConstraintData; + })(spine || (spine = {})); + var spine; + (function(spine) { + var PathConstraint = (function() { + function PathConstraint(data, skeleton) { + this.position = 0; + this.spacing = 0; + this.rotateMix = 0; + this.translateMix = 0; + this.spaces = new Array(); + this.positions = new Array(); + this.world = new Array(); + this.curves = new Array(); + this.lengths = new Array(); + this.segments = new Array(); + this.active = false; + if (null == data) throw new Error("data cannot be null."); + if (null == skeleton) throw new Error("skeleton cannot be null."); + this.data = data; + this.bones = new Array(); + for (var i = 0, n = data.bones.length; i < n; i++) this.bones.push(skeleton.findBone(data.bones[i].name)); + this.target = skeleton.findSlot(data.target.name); + this.position = data.position; + this.spacing = data.spacing; + this.rotateMix = data.rotateMix; + this.translateMix = data.translateMix; + } + PathConstraint.prototype.isActive = function() { + return this.active; + }; + PathConstraint.prototype.apply = function() { + this.update(); + }; + PathConstraint.prototype.update = function() { + var attachment = this.target.getAttachment(); + if (!(attachment instanceof spine.PathAttachment)) return; + var rotateMix = this.rotateMix, translateMix = this.translateMix; + var translate = translateMix > 0, rotate = rotateMix > 0; + if (!translate && !rotate) return; + var data = this.data; + var percentSpacing = data.spacingMode == spine.SpacingMode.Percent; + var rotateMode = data.rotateMode; + var tangents = rotateMode == spine.RotateMode.Tangent, scale = rotateMode == spine.RotateMode.ChainScale; + var boneCount = this.bones.length, spacesCount = tangents ? boneCount : boneCount + 1; + var bones = this.bones; + var spaces = spine.Utils.setArraySize(this.spaces, spacesCount), lengths = null; + var spacing = this.spacing; + if (scale || !percentSpacing) { + scale && (lengths = spine.Utils.setArraySize(this.lengths, boneCount)); + var lengthSpacing = data.spacingMode == spine.SpacingMode.Length; + for (var i = 0, n = spacesCount - 1; i < n; ) { + var bone = bones[i]; + var setupLength = bone.data.length; + if (setupLength < PathConstraint.epsilon) { + scale && (lengths[i] = 0); + spaces[++i] = 0; + } else if (percentSpacing) { + if (scale) { + var x = setupLength * bone.a, y = setupLength * bone.c; + var length_1 = Math.sqrt(x * x + y * y); + lengths[i] = length_1; + } + spaces[++i] = spacing; + } else { + var x = setupLength * bone.a, y = setupLength * bone.c; + var length_2 = Math.sqrt(x * x + y * y); + scale && (lengths[i] = length_2); + spaces[++i] = (lengthSpacing ? setupLength + spacing : spacing) * length_2 / setupLength; + } + } + } else for (var i = 1; i < spacesCount; i++) spaces[i] = spacing; + var positions = this.computeWorldPositions(attachment, spacesCount, tangents, data.positionMode == spine.PositionMode.Percent, percentSpacing); + var boneX = positions[0], boneY = positions[1], offsetRotation = data.offsetRotation; + var tip = false; + if (0 == offsetRotation) tip = rotateMode == spine.RotateMode.Chain; else { + tip = false; + var p = this.target.bone; + offsetRotation *= p.a * p.d - p.b * p.c > 0 ? spine.MathUtils.degRad : -spine.MathUtils.degRad; + } + for (var i = 0, p = 3; i < boneCount; i++, p += 3) { + var bone = bones[i]; + bone.worldX += (boneX - bone.worldX) * translateMix; + bone.worldY += (boneY - bone.worldY) * translateMix; + var x = positions[p], y = positions[p + 1], dx = x - boneX, dy = y - boneY; + if (scale) { + var length_3 = lengths[i]; + if (0 != length_3) { + var s = (Math.sqrt(dx * dx + dy * dy) / length_3 - 1) * rotateMix + 1; + bone.a *= s; + bone.c *= s; + } + } + boneX = x; + boneY = y; + if (rotate) { + var a = bone.a, b = bone.b, c = bone.c, d = bone.d, r = 0, cos = 0, sin = 0; + r = tangents ? positions[p - 1] : 0 == spaces[i + 1] ? positions[p + 2] : Math.atan2(dy, dx); + r -= Math.atan2(c, a); + if (tip) { + cos = Math.cos(r); + sin = Math.sin(r); + var length_4 = bone.data.length; + boneX += (length_4 * (cos * a - sin * c) - dx) * rotateMix; + boneY += (length_4 * (sin * a + cos * c) - dy) * rotateMix; + } else r += offsetRotation; + r > spine.MathUtils.PI ? r -= spine.MathUtils.PI2 : r < -spine.MathUtils.PI && (r += spine.MathUtils.PI2); + r *= rotateMix; + cos = Math.cos(r); + sin = Math.sin(r); + bone.a = cos * a - sin * c; + bone.b = cos * b - sin * d; + bone.c = sin * a + cos * c; + bone.d = sin * b + cos * d; + } + bone.appliedValid = false; + } + }; + PathConstraint.prototype.computeWorldPositions = function(path, spacesCount, tangents, percentPosition, percentSpacing) { + var target = this.target; + var position = this.position; + var spaces = this.spaces, out = spine.Utils.setArraySize(this.positions, 3 * spacesCount + 2), world = null; + var closed = path.closed; + var verticesLength = path.worldVerticesLength, curveCount = verticesLength / 6, prevCurve = PathConstraint.NONE; + if (!path.constantSpeed) { + var lengths = path.lengths; + curveCount -= closed ? 1 : 2; + var pathLength_1 = lengths[curveCount]; + percentPosition && (position *= pathLength_1); + if (percentSpacing) for (var i = 1; i < spacesCount; i++) spaces[i] *= pathLength_1; + world = spine.Utils.setArraySize(this.world, 8); + for (var i = 0, o = 0, curve = 0; i < spacesCount; i++, o += 3) { + var space = spaces[i]; + position += space; + var p = position; + if (closed) { + p %= pathLength_1; + p < 0 && (p += pathLength_1); + curve = 0; + } else { + if (p < 0) { + if (prevCurve != PathConstraint.BEFORE) { + prevCurve = PathConstraint.BEFORE; + path.computeWorldVertices(target, 2, 4, world, 0, 2); + } + this.addBeforePosition(p, world, 0, out, o); + continue; + } + if (p > pathLength_1) { + if (prevCurve != PathConstraint.AFTER) { + prevCurve = PathConstraint.AFTER; + path.computeWorldVertices(target, verticesLength - 6, 4, world, 0, 2); + } + this.addAfterPosition(p - pathLength_1, world, 0, out, o); + continue; + } + } + for (;;curve++) { + var length_5 = lengths[curve]; + if (p > length_5) continue; + if (0 == curve) p /= length_5; else { + var prev = lengths[curve - 1]; + p = (p - prev) / (length_5 - prev); + } + break; + } + if (curve != prevCurve) { + prevCurve = curve; + if (closed && curve == curveCount) { + path.computeWorldVertices(target, verticesLength - 4, 4, world, 0, 2); + path.computeWorldVertices(target, 0, 4, world, 4, 2); + } else path.computeWorldVertices(target, 6 * curve + 2, 8, world, 0, 2); + } + this.addCurvePosition(p, world[0], world[1], world[2], world[3], world[4], world[5], world[6], world[7], out, o, tangents || i > 0 && 0 == space); + } + return out; + } + if (closed) { + verticesLength += 2; + world = spine.Utils.setArraySize(this.world, verticesLength); + path.computeWorldVertices(target, 2, verticesLength - 4, world, 0, 2); + path.computeWorldVertices(target, 0, 2, world, verticesLength - 4, 2); + world[verticesLength - 2] = world[0]; + world[verticesLength - 1] = world[1]; + } else { + curveCount--; + verticesLength -= 4; + world = spine.Utils.setArraySize(this.world, verticesLength); + path.computeWorldVertices(target, 2, verticesLength, world, 0, 2); + } + var curves = spine.Utils.setArraySize(this.curves, curveCount); + var pathLength = 0; + var x1 = world[0], y1 = world[1], cx1 = 0, cy1 = 0, cx2 = 0, cy2 = 0, x2 = 0, y2 = 0; + var tmpx = 0, tmpy = 0, dddfx = 0, dddfy = 0, ddfx = 0, ddfy = 0, dfx = 0, dfy = 0; + for (var i = 0, w = 2; i < curveCount; i++, w += 6) { + cx1 = world[w]; + cy1 = world[w + 1]; + cx2 = world[w + 2]; + cy2 = world[w + 3]; + x2 = world[w + 4]; + y2 = world[w + 5]; + tmpx = .1875 * (x1 - 2 * cx1 + cx2); + tmpy = .1875 * (y1 - 2 * cy1 + cy2); + dddfx = .09375 * (3 * (cx1 - cx2) - x1 + x2); + dddfy = .09375 * (3 * (cy1 - cy2) - y1 + y2); + ddfx = 2 * tmpx + dddfx; + ddfy = 2 * tmpy + dddfy; + dfx = .75 * (cx1 - x1) + tmpx + .16666667 * dddfx; + dfy = .75 * (cy1 - y1) + tmpy + .16666667 * dddfy; + pathLength += Math.sqrt(dfx * dfx + dfy * dfy); + dfx += ddfx; + dfy += ddfy; + ddfx += dddfx; + ddfy += dddfy; + pathLength += Math.sqrt(dfx * dfx + dfy * dfy); + dfx += ddfx; + dfy += ddfy; + pathLength += Math.sqrt(dfx * dfx + dfy * dfy); + dfx += ddfx + dddfx; + dfy += ddfy + dddfy; + pathLength += Math.sqrt(dfx * dfx + dfy * dfy); + curves[i] = pathLength; + x1 = x2; + y1 = y2; + } + position *= percentPosition ? pathLength : pathLength / path.lengths[curveCount - 1]; + if (percentSpacing) for (var i = 1; i < spacesCount; i++) spaces[i] *= pathLength; + var segments = this.segments; + var curveLength = 0; + for (var i = 0, o = 0, curve = 0, segment = 0; i < spacesCount; i++, o += 3) { + var space = spaces[i]; + position += space; + var p = position; + if (closed) { + p %= pathLength; + p < 0 && (p += pathLength); + curve = 0; + } else { + if (p < 0) { + this.addBeforePosition(p, world, 0, out, o); + continue; + } + if (p > pathLength) { + this.addAfterPosition(p - pathLength, world, verticesLength - 4, out, o); + continue; + } + } + for (;;curve++) { + var length_6 = curves[curve]; + if (p > length_6) continue; + if (0 == curve) p /= length_6; else { + var prev = curves[curve - 1]; + p = (p - prev) / (length_6 - prev); + } + break; + } + if (curve != prevCurve) { + prevCurve = curve; + var ii = 6 * curve; + x1 = world[ii]; + y1 = world[ii + 1]; + cx1 = world[ii + 2]; + cy1 = world[ii + 3]; + cx2 = world[ii + 4]; + cy2 = world[ii + 5]; + x2 = world[ii + 6]; + y2 = world[ii + 7]; + tmpx = .03 * (x1 - 2 * cx1 + cx2); + tmpy = .03 * (y1 - 2 * cy1 + cy2); + dddfx = .006 * (3 * (cx1 - cx2) - x1 + x2); + dddfy = .006 * (3 * (cy1 - cy2) - y1 + y2); + ddfx = 2 * tmpx + dddfx; + ddfy = 2 * tmpy + dddfy; + dfx = .3 * (cx1 - x1) + tmpx + .16666667 * dddfx; + dfy = .3 * (cy1 - y1) + tmpy + .16666667 * dddfy; + curveLength = Math.sqrt(dfx * dfx + dfy * dfy); + segments[0] = curveLength; + for (ii = 1; ii < 8; ii++) { + dfx += ddfx; + dfy += ddfy; + ddfx += dddfx; + ddfy += dddfy; + curveLength += Math.sqrt(dfx * dfx + dfy * dfy); + segments[ii] = curveLength; + } + dfx += ddfx; + dfy += ddfy; + curveLength += Math.sqrt(dfx * dfx + dfy * dfy); + segments[8] = curveLength; + dfx += ddfx + dddfx; + dfy += ddfy + dddfy; + curveLength += Math.sqrt(dfx * dfx + dfy * dfy); + segments[9] = curveLength; + segment = 0; + } + p *= curveLength; + for (;;segment++) { + var length_7 = segments[segment]; + if (p > length_7) continue; + if (0 == segment) p /= length_7; else { + var prev = segments[segment - 1]; + p = segment + (p - prev) / (length_7 - prev); + } + break; + } + this.addCurvePosition(.1 * p, x1, y1, cx1, cy1, cx2, cy2, x2, y2, out, o, tangents || i > 0 && 0 == space); + } + return out; + }; + PathConstraint.prototype.addBeforePosition = function(p, temp, i, out, o) { + var x1 = temp[i], y1 = temp[i + 1], dx = temp[i + 2] - x1, dy = temp[i + 3] - y1, r = Math.atan2(dy, dx); + out[o] = x1 + p * Math.cos(r); + out[o + 1] = y1 + p * Math.sin(r); + out[o + 2] = r; + }; + PathConstraint.prototype.addAfterPosition = function(p, temp, i, out, o) { + var x1 = temp[i + 2], y1 = temp[i + 3], dx = x1 - temp[i], dy = y1 - temp[i + 1], r = Math.atan2(dy, dx); + out[o] = x1 + p * Math.cos(r); + out[o + 1] = y1 + p * Math.sin(r); + out[o + 2] = r; + }; + PathConstraint.prototype.addCurvePosition = function(p, x1, y1, cx1, cy1, cx2, cy2, x2, y2, out, o, tangents) { + if (0 == p || isNaN(p)) { + out[o] = x1; + out[o + 1] = y1; + out[o + 2] = Math.atan2(cy1 - y1, cx1 - x1); + return; + } + var tt = p * p, ttt = tt * p, u = 1 - p, uu = u * u, uuu = uu * u; + var ut = u * p, ut3 = 3 * ut, uut3 = u * ut3, utt3 = ut3 * p; + var x = x1 * uuu + cx1 * uut3 + cx2 * utt3 + x2 * ttt, y = y1 * uuu + cy1 * uut3 + cy2 * utt3 + y2 * ttt; + out[o] = x; + out[o + 1] = y; + tangents && (out[o + 2] = p < .001 ? Math.atan2(cy1 - y1, cx1 - x1) : Math.atan2(y - (y1 * uu + cy1 * ut * 2 + cy2 * tt), x - (x1 * uu + cx1 * ut * 2 + cx2 * tt))); + }; + PathConstraint.NONE = -1; + PathConstraint.BEFORE = -2; + PathConstraint.AFTER = -3; + PathConstraint.epsilon = 1e-5; + return PathConstraint; + })(); + spine.PathConstraint = PathConstraint; + })(spine || (spine = {})); + var spine; + (function(spine) { + var PathConstraintData = (function(_super) { + __extends(PathConstraintData, _super); + function PathConstraintData(name) { + var _this = _super.call(this, name, 0, false) || this; + _this.bones = new Array(); + return _this; + } + return PathConstraintData; + })(spine.ConstraintData); + spine.PathConstraintData = PathConstraintData; + var PositionMode; + (function(PositionMode) { + PositionMode[PositionMode["Fixed"] = 0] = "Fixed"; + PositionMode[PositionMode["Percent"] = 1] = "Percent"; + })(PositionMode = spine.PositionMode || (spine.PositionMode = {})); + var SpacingMode; + (function(SpacingMode) { + SpacingMode[SpacingMode["Length"] = 0] = "Length"; + SpacingMode[SpacingMode["Fixed"] = 1] = "Fixed"; + SpacingMode[SpacingMode["Percent"] = 2] = "Percent"; + })(SpacingMode = spine.SpacingMode || (spine.SpacingMode = {})); + var RotateMode; + (function(RotateMode) { + RotateMode[RotateMode["Tangent"] = 0] = "Tangent"; + RotateMode[RotateMode["Chain"] = 1] = "Chain"; + RotateMode[RotateMode["ChainScale"] = 2] = "ChainScale"; + })(RotateMode = spine.RotateMode || (spine.RotateMode = {})); + })(spine || (spine = {})); + var spine; + (function(spine) { + var Assets = (function() { + function Assets(clientId) { + this.toLoad = new Array(); + this.assets = {}; + this.clientId = clientId; + } + Assets.prototype.loaded = function() { + var i = 0; + for (var v in this.assets) i++; + return i; + }; + return Assets; + })(); + var SharedAssetManager = (function() { + function SharedAssetManager(pathPrefix) { + void 0 === pathPrefix && (pathPrefix = ""); + this.clientAssets = {}; + this.queuedAssets = {}; + this.rawAssets = {}; + this.errors = {}; + this.pathPrefix = pathPrefix; + } + SharedAssetManager.prototype.queueAsset = function(clientId, textureLoader, path) { + var clientAssets = this.clientAssets[clientId]; + if (null === clientAssets || void 0 === clientAssets) { + clientAssets = new Assets(clientId); + this.clientAssets[clientId] = clientAssets; + } + null !== textureLoader && (clientAssets.textureLoader = textureLoader); + clientAssets.toLoad.push(path); + if (this.queuedAssets[path] === path) return false; + this.queuedAssets[path] = path; + return true; + }; + SharedAssetManager.prototype.loadText = function(clientId, path) { + var _this = this; + path = this.pathPrefix + path; + if (!this.queueAsset(clientId, null, path)) return; + var request = new XMLHttpRequest(); + request.onreadystatechange = function() { + request.readyState == XMLHttpRequest.DONE && (request.status >= 200 && request.status < 300 ? _this.rawAssets[path] = request.responseText : _this.errors[path] = "Couldn't load text " + path + ": status " + request.status + ", " + request.responseText); + }; + request.open("GET", path, true); + request.send(); + }; + SharedAssetManager.prototype.loadJson = function(clientId, path) { + var _this = this; + path = this.pathPrefix + path; + if (!this.queueAsset(clientId, null, path)) return; + var request = new XMLHttpRequest(); + request.onreadystatechange = function() { + request.readyState == XMLHttpRequest.DONE && (request.status >= 200 && request.status < 300 ? _this.rawAssets[path] = JSON.parse(request.responseText) : _this.errors[path] = "Couldn't load text " + path + ": status " + request.status + ", " + request.responseText); + }; + request.open("GET", path, true); + request.send(); + }; + SharedAssetManager.prototype.loadTexture = function(clientId, textureLoader, path) { + var _this = this; + path = this.pathPrefix + path; + if (!this.queueAsset(clientId, textureLoader, path)) return; + var img = new Image(); + img.src = path; + img.crossOrigin = "anonymous"; + img.onload = function(ev) { + _this.rawAssets[path] = img; + }; + img.onerror = function(ev) { + _this.errors[path] = "Couldn't load image " + path; + }; + }; + SharedAssetManager.prototype.get = function(clientId, path) { + path = this.pathPrefix + path; + var clientAssets = this.clientAssets[clientId]; + if (null === clientAssets || void 0 === clientAssets) return true; + return clientAssets.assets[path]; + }; + SharedAssetManager.prototype.updateClientAssets = function(clientAssets) { + for (var i = 0; i < clientAssets.toLoad.length; i++) { + var path = clientAssets.toLoad[i]; + var asset = clientAssets.assets[path]; + if (null === asset || void 0 === asset) { + var rawAsset = this.rawAssets[path]; + if (null === rawAsset || void 0 === rawAsset) continue; + rawAsset instanceof HTMLImageElement ? clientAssets.assets[path] = clientAssets.textureLoader(rawAsset) : clientAssets.assets[path] = rawAsset; + } + } + }; + SharedAssetManager.prototype.isLoadingComplete = function(clientId) { + var clientAssets = this.clientAssets[clientId]; + if (null === clientAssets || void 0 === clientAssets) return true; + this.updateClientAssets(clientAssets); + return clientAssets.toLoad.length == clientAssets.loaded(); + }; + SharedAssetManager.prototype.dispose = function() {}; + SharedAssetManager.prototype.hasErrors = function() { + return Object.keys(this.errors).length > 0; + }; + SharedAssetManager.prototype.getErrors = function() { + return this.errors; + }; + return SharedAssetManager; + })(); + spine.SharedAssetManager = SharedAssetManager; + })(spine || (spine = {})); + var spine; + (function(spine) { + var Skeleton = (function() { + function Skeleton(data) { + this._updateCache = new Array(); + this.updateCacheReset = new Array(); + this.time = 0; + this.scaleX = 1; + this.scaleY = 1; + this.x = 0; + this.y = 0; + if (null == data) throw new Error("data cannot be null."); + this.data = data; + this.bones = new Array(); + for (var i = 0; i < data.bones.length; i++) { + var boneData = data.bones[i]; + var bone = void 0; + if (null == boneData.parent) bone = new spine.Bone(boneData, this, null); else { + var parent_1 = this.bones[boneData.parent.index]; + bone = new spine.Bone(boneData, this, parent_1); + parent_1.children.push(bone); + } + this.bones.push(bone); + } + this.slots = new Array(); + this.drawOrder = new Array(); + for (var i = 0; i < data.slots.length; i++) { + var slotData = data.slots[i]; + var bone = this.bones[slotData.boneData.index]; + var slot = new spine.Slot(slotData, bone); + this.slots.push(slot); + this.drawOrder.push(slot); + } + this.ikConstraints = new Array(); + for (var i = 0; i < data.ikConstraints.length; i++) { + var ikConstraintData = data.ikConstraints[i]; + this.ikConstraints.push(new spine.IkConstraint(ikConstraintData, this)); + } + this.transformConstraints = new Array(); + for (var i = 0; i < data.transformConstraints.length; i++) { + var transformConstraintData = data.transformConstraints[i]; + this.transformConstraints.push(new spine.TransformConstraint(transformConstraintData, this)); + } + this.pathConstraints = new Array(); + for (var i = 0; i < data.pathConstraints.length; i++) { + var pathConstraintData = data.pathConstraints[i]; + this.pathConstraints.push(new spine.PathConstraint(pathConstraintData, this)); + } + this.color = new spine.Color(1, 1, 1, 1); + this.updateCache(); + } + Skeleton.prototype.updateCache = function() { + var updateCache = this._updateCache; + updateCache.length = 0; + this.updateCacheReset.length = 0; + var bones = this.bones; + for (var i = 0, n = bones.length; i < n; i++) { + var bone = bones[i]; + bone.sorted = bone.data.skinRequired; + bone.active = !bone.sorted; + } + if (null != this.skin) { + var skinBones = this.skin.bones; + for (var i = 0, n = this.skin.bones.length; i < n; i++) { + var bone = this.bones[skinBones[i].index]; + do { + bone.sorted = false; + bone.active = true; + bone = bone.parent; + } while (null != bone); + } + } + var ikConstraints = this.ikConstraints; + var transformConstraints = this.transformConstraints; + var pathConstraints = this.pathConstraints; + var ikCount = ikConstraints.length, transformCount = transformConstraints.length, pathCount = pathConstraints.length; + var constraintCount = ikCount + transformCount + pathCount; + outer: for (var i = 0; i < constraintCount; i++) { + for (var ii = 0; ii < ikCount; ii++) { + var constraint = ikConstraints[ii]; + if (constraint.data.order == i) { + this.sortIkConstraint(constraint); + continue outer; + } + } + for (var ii = 0; ii < transformCount; ii++) { + var constraint = transformConstraints[ii]; + if (constraint.data.order == i) { + this.sortTransformConstraint(constraint); + continue outer; + } + } + for (var ii = 0; ii < pathCount; ii++) { + var constraint = pathConstraints[ii]; + if (constraint.data.order == i) { + this.sortPathConstraint(constraint); + continue outer; + } + } + } + for (var i = 0, n = bones.length; i < n; i++) this.sortBone(bones[i]); + }; + Skeleton.prototype.sortIkConstraint = function(constraint) { + constraint.active = constraint.target.isActive() && (!constraint.data.skinRequired || null != this.skin && spine.Utils.contains(this.skin.constraints, constraint.data, true)); + if (!constraint.active) return; + var target = constraint.target; + this.sortBone(target); + var constrained = constraint.bones; + var parent = constrained[0]; + this.sortBone(parent); + if (constrained.length > 1) { + var child = constrained[constrained.length - 1]; + this._updateCache.indexOf(child) > -1 || this.updateCacheReset.push(child); + } + this._updateCache.push(constraint); + this.sortReset(parent.children); + constrained[constrained.length - 1].sorted = true; + }; + Skeleton.prototype.sortPathConstraint = function(constraint) { + constraint.active = constraint.target.bone.isActive() && (!constraint.data.skinRequired || null != this.skin && spine.Utils.contains(this.skin.constraints, constraint.data, true)); + if (!constraint.active) return; + var slot = constraint.target; + var slotIndex = slot.data.index; + var slotBone = slot.bone; + null != this.skin && this.sortPathConstraintAttachment(this.skin, slotIndex, slotBone); + null != this.data.defaultSkin && this.data.defaultSkin != this.skin && this.sortPathConstraintAttachment(this.data.defaultSkin, slotIndex, slotBone); + for (var i = 0, n = this.data.skins.length; i < n; i++) this.sortPathConstraintAttachment(this.data.skins[i], slotIndex, slotBone); + var attachment = slot.getAttachment(); + attachment instanceof spine.PathAttachment && this.sortPathConstraintAttachmentWith(attachment, slotBone); + var constrained = constraint.bones; + var boneCount = constrained.length; + for (var i = 0; i < boneCount; i++) this.sortBone(constrained[i]); + this._updateCache.push(constraint); + for (var i = 0; i < boneCount; i++) this.sortReset(constrained[i].children); + for (var i = 0; i < boneCount; i++) constrained[i].sorted = true; + }; + Skeleton.prototype.sortTransformConstraint = function(constraint) { + constraint.active = constraint.target.isActive() && (!constraint.data.skinRequired || null != this.skin && spine.Utils.contains(this.skin.constraints, constraint.data, true)); + if (!constraint.active) return; + this.sortBone(constraint.target); + var constrained = constraint.bones; + var boneCount = constrained.length; + if (constraint.data.local) for (var i = 0; i < boneCount; i++) { + var child = constrained[i]; + this.sortBone(child.parent); + this._updateCache.indexOf(child) > -1 || this.updateCacheReset.push(child); + } else for (var i = 0; i < boneCount; i++) this.sortBone(constrained[i]); + this._updateCache.push(constraint); + for (var ii = 0; ii < boneCount; ii++) this.sortReset(constrained[ii].children); + for (var ii = 0; ii < boneCount; ii++) constrained[ii].sorted = true; + }; + Skeleton.prototype.sortPathConstraintAttachment = function(skin, slotIndex, slotBone) { + var attachments = skin.attachments[slotIndex]; + if (!attachments) return; + for (var key in attachments) this.sortPathConstraintAttachmentWith(attachments[key], slotBone); + }; + Skeleton.prototype.sortPathConstraintAttachmentWith = function(attachment, slotBone) { + if (!(attachment instanceof spine.PathAttachment)) return; + var pathBones = attachment.bones; + if (null == pathBones) this.sortBone(slotBone); else { + var bones = this.bones; + var i = 0; + while (i < pathBones.length) { + var boneCount = pathBones[i++]; + for (var n = i + boneCount; i < n; i++) { + var boneIndex = pathBones[i]; + this.sortBone(bones[boneIndex]); + } + } + } + }; + Skeleton.prototype.sortBone = function(bone) { + if (bone.sorted) return; + var parent = bone.parent; + null != parent && this.sortBone(parent); + bone.sorted = true; + this._updateCache.push(bone); + }; + Skeleton.prototype.sortReset = function(bones) { + for (var i = 0, n = bones.length; i < n; i++) { + var bone = bones[i]; + if (!bone.active) continue; + bone.sorted && this.sortReset(bone.children); + bone.sorted = false; + } + }; + Skeleton.prototype.updateWorldTransform = function() { + var updateCacheReset = this.updateCacheReset; + for (var i = 0, n = updateCacheReset.length; i < n; i++) { + var bone = updateCacheReset[i]; + bone.ax = bone.x; + bone.ay = bone.y; + bone.arotation = bone.rotation; + bone.ascaleX = bone.scaleX; + bone.ascaleY = bone.scaleY; + bone.ashearX = bone.shearX; + bone.ashearY = bone.shearY; + bone.appliedValid = true; + } + var updateCache = this._updateCache; + for (var i = 0, n = updateCache.length; i < n; i++) updateCache[i].update(); + }; + Skeleton.prototype.setToSetupPose = function() { + this.setBonesToSetupPose(); + this.setSlotsToSetupPose(); + }; + Skeleton.prototype.setBonesToSetupPose = function() { + var bones = this.bones; + for (var i = 0, n = bones.length; i < n; i++) bones[i].setToSetupPose(); + var ikConstraints = this.ikConstraints; + for (var i = 0, n = ikConstraints.length; i < n; i++) { + var constraint = ikConstraints[i]; + constraint.mix = constraint.data.mix; + constraint.softness = constraint.data.softness; + constraint.bendDirection = constraint.data.bendDirection; + constraint.compress = constraint.data.compress; + constraint.stretch = constraint.data.stretch; + } + var transformConstraints = this.transformConstraints; + for (var i = 0, n = transformConstraints.length; i < n; i++) { + var constraint = transformConstraints[i]; + var data = constraint.data; + constraint.rotateMix = data.rotateMix; + constraint.translateMix = data.translateMix; + constraint.scaleMix = data.scaleMix; + constraint.shearMix = data.shearMix; + } + var pathConstraints = this.pathConstraints; + for (var i = 0, n = pathConstraints.length; i < n; i++) { + var constraint = pathConstraints[i]; + var data = constraint.data; + constraint.position = data.position; + constraint.spacing = data.spacing; + constraint.rotateMix = data.rotateMix; + constraint.translateMix = data.translateMix; + } + }; + Skeleton.prototype.setSlotsToSetupPose = function() { + var slots = this.slots; + spine.Utils.arrayCopy(slots, 0, this.drawOrder, 0, slots.length); + for (var i = 0, n = slots.length; i < n; i++) slots[i].setToSetupPose(); + }; + Skeleton.prototype.getRootBone = function() { + if (0 == this.bones.length) return null; + return this.bones[0]; + }; + Skeleton.prototype.findBone = function(boneName) { + if (null == boneName) throw new Error("boneName cannot be null."); + var bones = this.bones; + for (var i = 0, n = bones.length; i < n; i++) { + var bone = bones[i]; + if (bone.data.name == boneName) return bone; + } + return null; + }; + Skeleton.prototype.findBoneIndex = function(boneName) { + if (null == boneName) throw new Error("boneName cannot be null."); + var bones = this.bones; + for (var i = 0, n = bones.length; i < n; i++) if (bones[i].data.name == boneName) return i; + return -1; + }; + Skeleton.prototype.findSlot = function(slotName) { + if (null == slotName) throw new Error("slotName cannot be null."); + var slots = this.slots; + for (var i = 0, n = slots.length; i < n; i++) { + var slot = slots[i]; + if (slot.data.name == slotName) return slot; + } + return null; + }; + Skeleton.prototype.findSlotIndex = function(slotName) { + if (null == slotName) throw new Error("slotName cannot be null."); + var slots = this.slots; + for (var i = 0, n = slots.length; i < n; i++) if (slots[i].data.name == slotName) return i; + return -1; + }; + Skeleton.prototype.setSkinByName = function(skinName) { + var skin = this.data.findSkin(skinName); + if (null == skin) throw new Error("Skin not found: " + skinName); + this.setSkin(skin); + }; + Skeleton.prototype.setSkin = function(newSkin) { + if (newSkin == this.skin) return; + if (null != newSkin) if (null != this.skin) newSkin.attachAll(this, this.skin); else { + var slots = this.slots; + for (var i = 0, n = slots.length; i < n; i++) { + var slot = slots[i]; + var name_1 = slot.data.attachmentName; + if (null != name_1) { + var attachment = newSkin.getAttachment(i, name_1); + null != attachment && slot.setAttachment(attachment); + } + } + } + this.skin = newSkin; + this.updateCache(); + }; + Skeleton.prototype.getAttachmentByName = function(slotName, attachmentName) { + return this.getAttachment(this.data.findSlotIndex(slotName), attachmentName); + }; + Skeleton.prototype.getAttachment = function(slotIndex, attachmentName) { + if (null == attachmentName) throw new Error("attachmentName cannot be null."); + if (null != this.skin) { + var attachment = this.skin.getAttachment(slotIndex, attachmentName); + if (null != attachment) return attachment; + } + if (null != this.data.defaultSkin) return this.data.defaultSkin.getAttachment(slotIndex, attachmentName); + return null; + }; + Skeleton.prototype.setAttachment = function(slotName, attachmentName) { + if (null == slotName) throw new Error("slotName cannot be null."); + var slots = this.slots; + for (var i = 0, n = slots.length; i < n; i++) { + var slot = slots[i]; + if (slot.data.name == slotName) { + var attachment = null; + if (null != attachmentName) { + attachment = this.getAttachment(i, attachmentName); + if (null == attachment) throw new Error("Attachment not found: " + attachmentName + ", for slot: " + slotName); + } + slot.setAttachment(attachment); + return; + } + } + throw new Error("Slot not found: " + slotName); + }; + Skeleton.prototype.findIkConstraint = function(constraintName) { + if (null == constraintName) throw new Error("constraintName cannot be null."); + var ikConstraints = this.ikConstraints; + for (var i = 0, n = ikConstraints.length; i < n; i++) { + var ikConstraint = ikConstraints[i]; + if (ikConstraint.data.name == constraintName) return ikConstraint; + } + return null; + }; + Skeleton.prototype.findTransformConstraint = function(constraintName) { + if (null == constraintName) throw new Error("constraintName cannot be null."); + var transformConstraints = this.transformConstraints; + for (var i = 0, n = transformConstraints.length; i < n; i++) { + var constraint = transformConstraints[i]; + if (constraint.data.name == constraintName) return constraint; + } + return null; + }; + Skeleton.prototype.findPathConstraint = function(constraintName) { + if (null == constraintName) throw new Error("constraintName cannot be null."); + var pathConstraints = this.pathConstraints; + for (var i = 0, n = pathConstraints.length; i < n; i++) { + var constraint = pathConstraints[i]; + if (constraint.data.name == constraintName) return constraint; + } + return null; + }; + Skeleton.prototype.getBounds = function(offset, size, temp) { + void 0 === temp && (temp = new Array(2)); + if (null == offset) throw new Error("offset cannot be null."); + if (null == size) throw new Error("size cannot be null."); + var drawOrder = this.drawOrder; + var minX = Number.POSITIVE_INFINITY, minY = Number.POSITIVE_INFINITY, maxX = Number.NEGATIVE_INFINITY, maxY = Number.NEGATIVE_INFINITY; + for (var i = 0, n = drawOrder.length; i < n; i++) { + var slot = drawOrder[i]; + if (!slot.bone.active) continue; + var verticesLength = 0; + var vertices = null; + var attachment = slot.getAttachment(); + if (attachment instanceof spine.RegionAttachment) { + verticesLength = 8; + vertices = spine.Utils.setArraySize(temp, verticesLength, 0); + attachment.computeWorldVertices(slot.bone, vertices, 0, 2); + } else if (attachment instanceof spine.MeshAttachment) { + var mesh = attachment; + verticesLength = mesh.worldVerticesLength; + vertices = spine.Utils.setArraySize(temp, verticesLength, 0); + mesh.computeWorldVertices(slot, 0, verticesLength, vertices, 0, 2); + } + if (null != vertices) for (var ii = 0, nn = vertices.length; ii < nn; ii += 2) { + var x = vertices[ii], y = vertices[ii + 1]; + minX = Math.min(minX, x); + minY = Math.min(minY, y); + maxX = Math.max(maxX, x); + maxY = Math.max(maxY, y); + } + } + offset.set(minX, minY); + size.set(maxX - minX, maxY - minY); + }; + Skeleton.prototype.update = function(delta) { + this.time += delta; + }; + return Skeleton; + })(); + spine.Skeleton = Skeleton; + })(spine || (spine = {})); + var spine; + (function(spine) { + var SkeletonBinary = (function() { + function SkeletonBinary(attachmentLoader) { + this.scale = 1; + this.linkedMeshes = new Array(); + this.attachmentLoader = attachmentLoader; + } + SkeletonBinary.prototype.readSkeletonData = function(binary) { + var scale = this.scale; + var skeletonData = new spine.SkeletonData(); + skeletonData.name = ""; + var input = new BinaryInput(binary); + skeletonData.hash = input.readString(); + skeletonData.version = input.readString(); + skeletonData.x = input.readFloat(); + skeletonData.y = input.readFloat(); + skeletonData.width = input.readFloat(); + skeletonData.height = input.readFloat(); + var nonessential = input.readBoolean(); + if (nonessential) { + skeletonData.fps = input.readFloat(); + skeletonData.imagesPath = input.readString(); + skeletonData.audioPath = input.readString(); + } + var n = 0; + n = input.readInt(true); + for (var i = 0; i < n; i++) input.strings.push(input.readString()); + n = input.readInt(true); + for (var i = 0; i < n; i++) { + var name_2 = input.readString(); + var parent_2 = 0 == i ? null : skeletonData.bones[input.readInt(true)]; + var data = new spine.BoneData(i, name_2, parent_2); + data.rotation = input.readFloat(); + data.x = input.readFloat() * scale; + data.y = input.readFloat() * scale; + data.scaleX = input.readFloat(); + data.scaleY = input.readFloat(); + data.shearX = input.readFloat(); + data.shearY = input.readFloat(); + data.length = input.readFloat() * scale; + data.transformMode = SkeletonBinary.TransformModeValues[input.readInt(true)]; + data.skinRequired = input.readBoolean(); + nonessential && spine.Color.rgba8888ToColor(data.color, input.readInt32()); + skeletonData.bones.push(data); + } + n = input.readInt(true); + for (var i = 0; i < n; i++) { + var slotName = input.readString(); + var boneData = skeletonData.bones[input.readInt(true)]; + var data = new spine.SlotData(i, slotName, boneData); + spine.Color.rgba8888ToColor(data.color, input.readInt32()); + var darkColor = input.readInt32(); + -1 != darkColor && spine.Color.rgb888ToColor(data.darkColor = new spine.Color(), darkColor); + data.attachmentName = input.readStringRef(); + data.blendMode = SkeletonBinary.BlendModeValues[input.readInt(true)]; + skeletonData.slots.push(data); + } + n = input.readInt(true); + for (var i = 0, nn = void 0; i < n; i++) { + var data = new spine.IkConstraintData(input.readString()); + data.order = input.readInt(true); + data.skinRequired = input.readBoolean(); + nn = input.readInt(true); + for (var ii = 0; ii < nn; ii++) data.bones.push(skeletonData.bones[input.readInt(true)]); + data.target = skeletonData.bones[input.readInt(true)]; + data.mix = input.readFloat(); + data.softness = input.readFloat() * scale; + data.bendDirection = input.readByte(); + data.compress = input.readBoolean(); + data.stretch = input.readBoolean(); + data.uniform = input.readBoolean(); + skeletonData.ikConstraints.push(data); + } + n = input.readInt(true); + for (var i = 0, nn = void 0; i < n; i++) { + var data = new spine.TransformConstraintData(input.readString()); + data.order = input.readInt(true); + data.skinRequired = input.readBoolean(); + nn = input.readInt(true); + for (var ii = 0; ii < nn; ii++) data.bones.push(skeletonData.bones[input.readInt(true)]); + data.target = skeletonData.bones[input.readInt(true)]; + data.local = input.readBoolean(); + data.relative = input.readBoolean(); + data.offsetRotation = input.readFloat(); + data.offsetX = input.readFloat() * scale; + data.offsetY = input.readFloat() * scale; + data.offsetScaleX = input.readFloat(); + data.offsetScaleY = input.readFloat(); + data.offsetShearY = input.readFloat(); + data.rotateMix = input.readFloat(); + data.translateMix = input.readFloat(); + data.scaleMix = input.readFloat(); + data.shearMix = input.readFloat(); + skeletonData.transformConstraints.push(data); + } + n = input.readInt(true); + for (var i = 0, nn = void 0; i < n; i++) { + var data = new spine.PathConstraintData(input.readString()); + data.order = input.readInt(true); + data.skinRequired = input.readBoolean(); + nn = input.readInt(true); + for (var ii = 0; ii < nn; ii++) data.bones.push(skeletonData.bones[input.readInt(true)]); + data.target = skeletonData.slots[input.readInt(true)]; + data.positionMode = SkeletonBinary.PositionModeValues[input.readInt(true)]; + data.spacingMode = SkeletonBinary.SpacingModeValues[input.readInt(true)]; + data.rotateMode = SkeletonBinary.RotateModeValues[input.readInt(true)]; + data.offsetRotation = input.readFloat(); + data.position = input.readFloat(); + data.positionMode == spine.PositionMode.Fixed && (data.position *= scale); + data.spacing = input.readFloat(); + data.spacingMode != spine.SpacingMode.Length && data.spacingMode != spine.SpacingMode.Fixed || (data.spacing *= scale); + data.rotateMix = input.readFloat(); + data.translateMix = input.readFloat(); + skeletonData.pathConstraints.push(data); + } + var defaultSkin = this.readSkin(input, skeletonData, true, nonessential); + if (null != defaultSkin) { + skeletonData.defaultSkin = defaultSkin; + skeletonData.skins.push(defaultSkin); + } + var i = skeletonData.skins.length; + spine.Utils.setArraySize(skeletonData.skins, n = i + input.readInt(true)); + for (;i < n; i++) skeletonData.skins[i] = this.readSkin(input, skeletonData, false, nonessential); + n = this.linkedMeshes.length; + for (var i = 0; i < n; i++) { + var linkedMesh = this.linkedMeshes[i]; + var skin = null == linkedMesh.skin ? skeletonData.defaultSkin : skeletonData.findSkin(linkedMesh.skin); + if (null == skin) throw new Error("Skin not found: " + linkedMesh.skin); + var parent_3 = skin.getAttachment(linkedMesh.slotIndex, linkedMesh.parent); + if (null == parent_3) throw new Error("Parent mesh not found: " + linkedMesh.parent); + linkedMesh.mesh.deformAttachment = linkedMesh.inheritDeform ? parent_3 : linkedMesh.mesh; + linkedMesh.mesh.setParentMesh(parent_3); + linkedMesh.mesh.updateUVs(); + } + this.linkedMeshes.length = 0; + n = input.readInt(true); + for (var i = 0; i < n; i++) { + var data = new spine.EventData(input.readStringRef()); + data.intValue = input.readInt(false); + data.floatValue = input.readFloat(); + data.stringValue = input.readString(); + data.audioPath = input.readString(); + if (null != data.audioPath) { + data.volume = input.readFloat(); + data.balance = input.readFloat(); + } + skeletonData.events.push(data); + } + n = input.readInt(true); + for (var i = 0; i < n; i++) skeletonData.animations.push(this.readAnimation(input, input.readString(), skeletonData)); + return skeletonData; + }; + SkeletonBinary.prototype.readSkin = function(input, skeletonData, defaultSkin, nonessential) { + var skin = null; + var slotCount = 0; + if (defaultSkin) { + slotCount = input.readInt(true); + if (0 == slotCount) return null; + skin = new spine.Skin("default"); + } else { + skin = new spine.Skin(input.readStringRef()); + skin.bones.length = input.readInt(true); + for (var i = 0, n = skin.bones.length; i < n; i++) skin.bones[i] = skeletonData.bones[input.readInt(true)]; + for (var i = 0, n = input.readInt(true); i < n; i++) skin.constraints.push(skeletonData.ikConstraints[input.readInt(true)]); + for (var i = 0, n = input.readInt(true); i < n; i++) skin.constraints.push(skeletonData.transformConstraints[input.readInt(true)]); + for (var i = 0, n = input.readInt(true); i < n; i++) skin.constraints.push(skeletonData.pathConstraints[input.readInt(true)]); + slotCount = input.readInt(true); + } + for (var i = 0; i < slotCount; i++) { + var slotIndex = input.readInt(true); + for (var ii = 0, nn = input.readInt(true); ii < nn; ii++) { + var name_3 = input.readStringRef(); + var attachment = this.readAttachment(input, skeletonData, skin, slotIndex, name_3, nonessential); + null != attachment && skin.setAttachment(slotIndex, name_3, attachment); + } + } + return skin; + }; + SkeletonBinary.prototype.readAttachment = function(input, skeletonData, skin, slotIndex, attachmentName, nonessential) { + var scale = this.scale; + var name = input.readStringRef(); + null == name && (name = attachmentName); + var typeIndex = input.readByte(); + var type = SkeletonBinary.AttachmentTypeValues[typeIndex]; + switch (type) { + case spine.AttachmentType.Region: + var path = input.readStringRef(); + var rotation = input.readFloat(); + var x = input.readFloat(); + var y = input.readFloat(); + var scaleX = input.readFloat(); + var scaleY = input.readFloat(); + var width = input.readFloat(); + var height = input.readFloat(); + var color = input.readInt32(); + null == path && (path = name); + var region = this.attachmentLoader.newRegionAttachment(skin, name, path); + if (null == region) return null; + region.path = path; + region.x = x * scale; + region.y = y * scale; + region.scaleX = scaleX; + region.scaleY = scaleY; + region.rotation = rotation; + region.width = width * scale; + region.height = height * scale; + spine.Color.rgba8888ToColor(region.color, color); + region.updateOffset(); + return region; + + case spine.AttachmentType.BoundingBox: + var vertexCount = input.readInt(true); + var vertices = this.readVertices(input, vertexCount); + var color = nonessential ? input.readInt32() : 0; + var box = this.attachmentLoader.newBoundingBoxAttachment(skin, name); + if (null == box) return null; + box.worldVerticesLength = vertexCount << 1; + box.vertices = vertices.vertices; + box.bones = vertices.bones; + nonessential && spine.Color.rgba8888ToColor(box.color, color); + return box; + + case spine.AttachmentType.Mesh: + var path = input.readStringRef(); + var color = input.readInt32(); + var vertexCount = input.readInt(true); + var uvs = this.readFloatArray(input, vertexCount << 1, 1); + var triangles = this.readShortArray(input); + var vertices = this.readVertices(input, vertexCount); + var hullLength = input.readInt(true); + var edges = null; + var width = 0, height = 0; + if (nonessential) { + edges = this.readShortArray(input); + width = input.readFloat(); + height = input.readFloat(); + } + null == path && (path = name); + var mesh = this.attachmentLoader.newMeshAttachment(skin, name, path); + if (null == mesh) return null; + mesh.path = path; + spine.Color.rgba8888ToColor(mesh.color, color); + mesh.bones = vertices.bones; + mesh.vertices = vertices.vertices; + mesh.worldVerticesLength = vertexCount << 1; + mesh.triangles = triangles; + mesh.regionUVs = uvs; + mesh.updateUVs(); + mesh.hullLength = hullLength << 1; + if (nonessential) { + mesh.edges = edges; + mesh.width = width * scale; + mesh.height = height * scale; + } + return mesh; + + case spine.AttachmentType.LinkedMesh: + var path = input.readStringRef(); + var color = input.readInt32(); + var skinName = input.readStringRef(); + var parent_4 = input.readStringRef(); + var inheritDeform = input.readBoolean(); + var width = 0, height = 0; + if (nonessential) { + width = input.readFloat(); + height = input.readFloat(); + } + null == path && (path = name); + var mesh = this.attachmentLoader.newMeshAttachment(skin, name, path); + if (null == mesh) return null; + mesh.path = path; + spine.Color.rgba8888ToColor(mesh.color, color); + if (nonessential) { + mesh.width = width * scale; + mesh.height = height * scale; + } + this.linkedMeshes.push(new LinkedMesh(mesh, skinName, slotIndex, parent_4, inheritDeform)); + return mesh; + + case spine.AttachmentType.Path: + var closed_1 = input.readBoolean(); + var constantSpeed = input.readBoolean(); + var vertexCount = input.readInt(true); + var vertices = this.readVertices(input, vertexCount); + var lengths = spine.Utils.newArray(vertexCount / 3, 0); + for (var i = 0, n = lengths.length; i < n; i++) lengths[i] = input.readFloat() * scale; + var color = nonessential ? input.readInt32() : 0; + var path = this.attachmentLoader.newPathAttachment(skin, name); + if (null == path) return null; + path.closed = closed_1; + path.constantSpeed = constantSpeed; + path.worldVerticesLength = vertexCount << 1; + path.vertices = vertices.vertices; + path.bones = vertices.bones; + path.lengths = lengths; + nonessential && spine.Color.rgba8888ToColor(path.color, color); + return path; + + case spine.AttachmentType.Point: + var rotation = input.readFloat(); + var x = input.readFloat(); + var y = input.readFloat(); + var color = nonessential ? input.readInt32() : 0; + var point = this.attachmentLoader.newPointAttachment(skin, name); + if (null == point) return null; + point.x = x * scale; + point.y = y * scale; + point.rotation = rotation; + nonessential && spine.Color.rgba8888ToColor(point.color, color); + return point; + + case spine.AttachmentType.Clipping: + var endSlotIndex = input.readInt(true); + var vertexCount = input.readInt(true); + var vertices = this.readVertices(input, vertexCount); + var color = nonessential ? input.readInt32() : 0; + var clip = this.attachmentLoader.newClippingAttachment(skin, name); + if (null == clip) return null; + clip.endSlot = skeletonData.slots[endSlotIndex]; + clip.worldVerticesLength = vertexCount << 1; + clip.vertices = vertices.vertices; + clip.bones = vertices.bones; + nonessential && spine.Color.rgba8888ToColor(clip.color, color); + return clip; + } + return null; + }; + SkeletonBinary.prototype.readVertices = function(input, vertexCount) { + var verticesLength = vertexCount << 1; + var vertices = new Vertices(); + var scale = this.scale; + if (!input.readBoolean()) { + vertices.vertices = this.readFloatArray(input, verticesLength, scale); + return vertices; + } + var weights = new Array(); + var bonesArray = new Array(); + for (var i = 0; i < vertexCount; i++) { + var boneCount = input.readInt(true); + bonesArray.push(boneCount); + for (var ii = 0; ii < boneCount; ii++) { + bonesArray.push(input.readInt(true)); + weights.push(input.readFloat() * scale); + weights.push(input.readFloat() * scale); + weights.push(input.readFloat()); + } + } + vertices.vertices = spine.Utils.toFloatArray(weights); + vertices.bones = bonesArray; + return vertices; + }; + SkeletonBinary.prototype.readFloatArray = function(input, n, scale) { + var array = new Array(n); + if (1 == scale) for (var i = 0; i < n; i++) array[i] = input.readFloat(); else for (var i = 0; i < n; i++) array[i] = input.readFloat() * scale; + return array; + }; + SkeletonBinary.prototype.readShortArray = function(input) { + var n = input.readInt(true); + var array = new Array(n); + for (var i = 0; i < n; i++) array[i] = input.readShort(); + return array; + }; + SkeletonBinary.prototype.readAnimation = function(input, name, skeletonData) { + var timelines = new Array(); + var scale = this.scale; + var duration = 0; + var tempColor1 = new spine.Color(); + var tempColor2 = new spine.Color(); + for (var i = 0, n = input.readInt(true); i < n; i++) { + var slotIndex = input.readInt(true); + for (var ii = 0, nn = input.readInt(true); ii < nn; ii++) { + var timelineType = input.readByte(); + var frameCount = input.readInt(true); + switch (timelineType) { + case SkeletonBinary.SLOT_ATTACHMENT: + var timeline = new spine.AttachmentTimeline(frameCount); + timeline.slotIndex = slotIndex; + for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) timeline.setFrame(frameIndex, input.readFloat(), input.readStringRef()); + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[frameCount - 1]); + break; + + case SkeletonBinary.SLOT_COLOR: + var timeline = new spine.ColorTimeline(frameCount); + timeline.slotIndex = slotIndex; + for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) { + var time = input.readFloat(); + spine.Color.rgba8888ToColor(tempColor1, input.readInt32()); + timeline.setFrame(frameIndex, time, tempColor1.r, tempColor1.g, tempColor1.b, tempColor1.a); + frameIndex < frameCount - 1 && this.readCurve(input, frameIndex, timeline); + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[(frameCount - 1) * spine.ColorTimeline.ENTRIES]); + break; + + case SkeletonBinary.SLOT_TWO_COLOR: + var timeline = new spine.TwoColorTimeline(frameCount); + timeline.slotIndex = slotIndex; + for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) { + var time = input.readFloat(); + spine.Color.rgba8888ToColor(tempColor1, input.readInt32()); + spine.Color.rgb888ToColor(tempColor2, input.readInt32()); + timeline.setFrame(frameIndex, time, tempColor1.r, tempColor1.g, tempColor1.b, tempColor1.a, tempColor2.r, tempColor2.g, tempColor2.b); + frameIndex < frameCount - 1 && this.readCurve(input, frameIndex, timeline); + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[(frameCount - 1) * spine.TwoColorTimeline.ENTRIES]); + } + } + } + for (var i = 0, n = input.readInt(true); i < n; i++) { + var boneIndex = input.readInt(true); + for (var ii = 0, nn = input.readInt(true); ii < nn; ii++) { + var timelineType = input.readByte(); + var frameCount = input.readInt(true); + switch (timelineType) { + case SkeletonBinary.BONE_ROTATE: + var timeline = new spine.RotateTimeline(frameCount); + timeline.boneIndex = boneIndex; + for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) { + timeline.setFrame(frameIndex, input.readFloat(), input.readFloat()); + frameIndex < frameCount - 1 && this.readCurve(input, frameIndex, timeline); + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[(frameCount - 1) * spine.RotateTimeline.ENTRIES]); + break; + + case SkeletonBinary.BONE_TRANSLATE: + case SkeletonBinary.BONE_SCALE: + case SkeletonBinary.BONE_SHEAR: + var timeline = void 0; + var timelineScale = 1; + if (timelineType == SkeletonBinary.BONE_SCALE) timeline = new spine.ScaleTimeline(frameCount); else if (timelineType == SkeletonBinary.BONE_SHEAR) timeline = new spine.ShearTimeline(frameCount); else { + timeline = new spine.TranslateTimeline(frameCount); + timelineScale = scale; + } + timeline.boneIndex = boneIndex; + for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) { + timeline.setFrame(frameIndex, input.readFloat(), input.readFloat() * timelineScale, input.readFloat() * timelineScale); + frameIndex < frameCount - 1 && this.readCurve(input, frameIndex, timeline); + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[(frameCount - 1) * spine.TranslateTimeline.ENTRIES]); + } + } + } + for (var i = 0, n = input.readInt(true); i < n; i++) { + var index = input.readInt(true); + var frameCount = input.readInt(true); + var timeline = new spine.IkConstraintTimeline(frameCount); + timeline.ikConstraintIndex = index; + for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) { + timeline.setFrame(frameIndex, input.readFloat(), input.readFloat(), input.readFloat() * scale, input.readByte(), input.readBoolean(), input.readBoolean()); + frameIndex < frameCount - 1 && this.readCurve(input, frameIndex, timeline); + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[(frameCount - 1) * spine.IkConstraintTimeline.ENTRIES]); + } + for (var i = 0, n = input.readInt(true); i < n; i++) { + var index = input.readInt(true); + var frameCount = input.readInt(true); + var timeline = new spine.TransformConstraintTimeline(frameCount); + timeline.transformConstraintIndex = index; + for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) { + timeline.setFrame(frameIndex, input.readFloat(), input.readFloat(), input.readFloat(), input.readFloat(), input.readFloat()); + frameIndex < frameCount - 1 && this.readCurve(input, frameIndex, timeline); + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[(frameCount - 1) * spine.TransformConstraintTimeline.ENTRIES]); + } + for (var i = 0, n = input.readInt(true); i < n; i++) { + var index = input.readInt(true); + var data = skeletonData.pathConstraints[index]; + for (var ii = 0, nn = input.readInt(true); ii < nn; ii++) { + var timelineType = input.readByte(); + var frameCount = input.readInt(true); + switch (timelineType) { + case SkeletonBinary.PATH_POSITION: + case SkeletonBinary.PATH_SPACING: + var timeline = void 0; + var timelineScale = 1; + if (timelineType == SkeletonBinary.PATH_SPACING) { + timeline = new spine.PathConstraintSpacingTimeline(frameCount); + data.spacingMode != spine.SpacingMode.Length && data.spacingMode != spine.SpacingMode.Fixed || (timelineScale = scale); + } else { + timeline = new spine.PathConstraintPositionTimeline(frameCount); + data.positionMode == spine.PositionMode.Fixed && (timelineScale = scale); + } + timeline.pathConstraintIndex = index; + for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) { + timeline.setFrame(frameIndex, input.readFloat(), input.readFloat() * timelineScale); + frameIndex < frameCount - 1 && this.readCurve(input, frameIndex, timeline); + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[(frameCount - 1) * spine.PathConstraintPositionTimeline.ENTRIES]); + break; + + case SkeletonBinary.PATH_MIX: + var timeline = new spine.PathConstraintMixTimeline(frameCount); + timeline.pathConstraintIndex = index; + for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) { + timeline.setFrame(frameIndex, input.readFloat(), input.readFloat(), input.readFloat()); + frameIndex < frameCount - 1 && this.readCurve(input, frameIndex, timeline); + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[(frameCount - 1) * spine.PathConstraintMixTimeline.ENTRIES]); + } + } + } + for (var i = 0, n = input.readInt(true); i < n; i++) { + var skin = skeletonData.skins[input.readInt(true)]; + for (var ii = 0, nn = input.readInt(true); ii < nn; ii++) { + var slotIndex = input.readInt(true); + for (var iii = 0, nnn = input.readInt(true); iii < nnn; iii++) { + var attachment = skin.getAttachment(slotIndex, input.readStringRef()); + var weighted = null != attachment.bones; + var vertices = attachment.vertices; + var deformLength = weighted ? vertices.length / 3 * 2 : vertices.length; + var frameCount = input.readInt(true); + var timeline = new spine.DeformTimeline(frameCount); + timeline.slotIndex = slotIndex; + timeline.attachment = attachment; + for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) { + var time = input.readFloat(); + var deform = void 0; + var end = input.readInt(true); + if (0 == end) deform = weighted ? spine.Utils.newFloatArray(deformLength) : vertices; else { + deform = spine.Utils.newFloatArray(deformLength); + var start = input.readInt(true); + end += start; + if (1 == scale) for (var v = start; v < end; v++) deform[v] = input.readFloat(); else for (var v = start; v < end; v++) deform[v] = input.readFloat() * scale; + if (!weighted) for (var v = 0, vn = deform.length; v < vn; v++) deform[v] += vertices[v]; + } + timeline.setFrame(frameIndex, time, deform); + frameIndex < frameCount - 1 && this.readCurve(input, frameIndex, timeline); + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[frameCount - 1]); + } + } + } + var drawOrderCount = input.readInt(true); + if (drawOrderCount > 0) { + var timeline = new spine.DrawOrderTimeline(drawOrderCount); + var slotCount = skeletonData.slots.length; + for (var i = 0; i < drawOrderCount; i++) { + var time = input.readFloat(); + var offsetCount = input.readInt(true); + var drawOrder = spine.Utils.newArray(slotCount, 0); + for (var ii = slotCount - 1; ii >= 0; ii--) drawOrder[ii] = -1; + var unchanged = spine.Utils.newArray(slotCount - offsetCount, 0); + var originalIndex = 0, unchangedIndex = 0; + for (var ii = 0; ii < offsetCount; ii++) { + var slotIndex = input.readInt(true); + while (originalIndex != slotIndex) unchanged[unchangedIndex++] = originalIndex++; + drawOrder[originalIndex + input.readInt(true)] = originalIndex++; + } + while (originalIndex < slotCount) unchanged[unchangedIndex++] = originalIndex++; + for (var ii = slotCount - 1; ii >= 0; ii--) -1 == drawOrder[ii] && (drawOrder[ii] = unchanged[--unchangedIndex]); + timeline.setFrame(i, time, drawOrder); + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[drawOrderCount - 1]); + } + var eventCount = input.readInt(true); + if (eventCount > 0) { + var timeline = new spine.EventTimeline(eventCount); + for (var i = 0; i < eventCount; i++) { + var time = input.readFloat(); + var eventData = skeletonData.events[input.readInt(true)]; + var event_4 = new spine.Event(time, eventData); + event_4.intValue = input.readInt(false); + event_4.floatValue = input.readFloat(); + event_4.stringValue = input.readBoolean() ? input.readString() : eventData.stringValue; + if (null != event_4.data.audioPath) { + event_4.volume = input.readFloat(); + event_4.balance = input.readFloat(); + } + timeline.setFrame(i, event_4); + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[eventCount - 1]); + } + return new spine.Animation(name, timelines, duration); + }; + SkeletonBinary.prototype.readCurve = function(input, frameIndex, timeline) { + switch (input.readByte()) { + case SkeletonBinary.CURVE_STEPPED: + timeline.setStepped(frameIndex); + break; + + case SkeletonBinary.CURVE_BEZIER: + this.setCurve(timeline, frameIndex, input.readFloat(), input.readFloat(), input.readFloat(), input.readFloat()); + } + }; + SkeletonBinary.prototype.setCurve = function(timeline, frameIndex, cx1, cy1, cx2, cy2) { + timeline.setCurve(frameIndex, cx1, cy1, cx2, cy2); + }; + SkeletonBinary.AttachmentTypeValues = [ 0, 1, 2, 3, 4, 5, 6 ]; + SkeletonBinary.TransformModeValues = [ spine.TransformMode.Normal, spine.TransformMode.OnlyTranslation, spine.TransformMode.NoRotationOrReflection, spine.TransformMode.NoScale, spine.TransformMode.NoScaleOrReflection ]; + SkeletonBinary.PositionModeValues = [ spine.PositionMode.Fixed, spine.PositionMode.Percent ]; + SkeletonBinary.SpacingModeValues = [ spine.SpacingMode.Length, spine.SpacingMode.Fixed, spine.SpacingMode.Percent ]; + SkeletonBinary.RotateModeValues = [ spine.RotateMode.Tangent, spine.RotateMode.Chain, spine.RotateMode.ChainScale ]; + SkeletonBinary.BlendModeValues = [ spine.BlendMode.Normal, spine.BlendMode.Additive, spine.BlendMode.Multiply, spine.BlendMode.Screen ]; + SkeletonBinary.BONE_ROTATE = 0; + SkeletonBinary.BONE_TRANSLATE = 1; + SkeletonBinary.BONE_SCALE = 2; + SkeletonBinary.BONE_SHEAR = 3; + SkeletonBinary.SLOT_ATTACHMENT = 0; + SkeletonBinary.SLOT_COLOR = 1; + SkeletonBinary.SLOT_TWO_COLOR = 2; + SkeletonBinary.PATH_POSITION = 0; + SkeletonBinary.PATH_SPACING = 1; + SkeletonBinary.PATH_MIX = 2; + SkeletonBinary.CURVE_LINEAR = 0; + SkeletonBinary.CURVE_STEPPED = 1; + SkeletonBinary.CURVE_BEZIER = 2; + return SkeletonBinary; + })(); + spine.SkeletonBinary = SkeletonBinary; + var BinaryInput = (function() { + function BinaryInput(data, strings, index, buffer) { + void 0 === strings && (strings = new Array()); + void 0 === index && (index = 0); + void 0 === buffer && (buffer = new DataView(data.buffer)); + this.strings = strings; + this.index = index; + this.buffer = buffer; + } + BinaryInput.prototype.readByte = function() { + return this.buffer.getInt8(this.index++); + }; + BinaryInput.prototype.readShort = function() { + var value = this.buffer.getInt16(this.index); + this.index += 2; + return value; + }; + BinaryInput.prototype.readInt32 = function() { + var value = this.buffer.getInt32(this.index); + this.index += 4; + return value; + }; + BinaryInput.prototype.readInt = function(optimizePositive) { + var b = this.readByte(); + var result = 127 & b; + if (0 != (128 & b)) { + b = this.readByte(); + result |= (127 & b) << 7; + if (0 != (128 & b)) { + b = this.readByte(); + result |= (127 & b) << 14; + if (0 != (128 & b)) { + b = this.readByte(); + result |= (127 & b) << 21; + if (0 != (128 & b)) { + b = this.readByte(); + result |= (127 & b) << 28; + } + } + } + } + return optimizePositive ? result : result >>> 1 ^ -(1 & result); + }; + BinaryInput.prototype.readStringRef = function() { + var index = this.readInt(true); + return 0 == index ? null : this.strings[index - 1]; + }; + BinaryInput.prototype.readString = function() { + var byteCount = this.readInt(true); + switch (byteCount) { + case 0: + return null; + + case 1: + return ""; + } + byteCount--; + var chars = ""; + var charCount = 0; + for (var i = 0; i < byteCount; ) { + var b = this.readByte(); + switch (b >> 4) { + case 12: + case 13: + chars += String.fromCharCode((31 & b) << 6 | 63 & this.readByte()); + i += 2; + break; + + case 14: + chars += String.fromCharCode((15 & b) << 12 | (63 & this.readByte()) << 6 | 63 & this.readByte()); + i += 3; + break; + + default: + chars += String.fromCharCode(b); + i++; + } + } + return chars; + }; + BinaryInput.prototype.readFloat = function() { + var value = this.buffer.getFloat32(this.index); + this.index += 4; + return value; + }; + BinaryInput.prototype.readBoolean = function() { + return 0 != this.readByte(); + }; + return BinaryInput; + })(); + var LinkedMesh = (function() { + function LinkedMesh(mesh, skin, slotIndex, parent, inheritDeform) { + this.mesh = mesh; + this.skin = skin; + this.slotIndex = slotIndex; + this.parent = parent; + this.inheritDeform = inheritDeform; + } + return LinkedMesh; + })(); + var Vertices = (function() { + function Vertices(bones, vertices) { + void 0 === bones && (bones = null); + void 0 === vertices && (vertices = null); + this.bones = bones; + this.vertices = vertices; + } + return Vertices; + })(); + })(spine || (spine = {})); + var spine; + (function(spine) { + var SkeletonBounds = (function() { + function SkeletonBounds() { + this.minX = 0; + this.minY = 0; + this.maxX = 0; + this.maxY = 0; + this.boundingBoxes = new Array(); + this.polygons = new Array(); + this.polygonPool = new spine.Pool(function() { + return spine.Utils.newFloatArray(16); + }); + } + SkeletonBounds.prototype.update = function(skeleton, updateAabb) { + if (null == skeleton) throw new Error("skeleton cannot be null."); + var boundingBoxes = this.boundingBoxes; + var polygons = this.polygons; + var polygonPool = this.polygonPool; + var slots = skeleton.slots; + var slotCount = slots.length; + boundingBoxes.length = 0; + polygonPool.freeAll(polygons); + polygons.length = 0; + for (var i = 0; i < slotCount; i++) { + var slot = slots[i]; + if (!slot.bone.active) continue; + var attachment = slot.getAttachment(); + if (attachment instanceof spine.BoundingBoxAttachment) { + var boundingBox = attachment; + boundingBoxes.push(boundingBox); + var polygon = polygonPool.obtain(); + polygon.length != boundingBox.worldVerticesLength && (polygon = spine.Utils.newFloatArray(boundingBox.worldVerticesLength)); + polygons.push(polygon); + boundingBox.computeWorldVertices(slot, 0, boundingBox.worldVerticesLength, polygon, 0, 2); + } + } + if (updateAabb) this.aabbCompute(); else { + this.minX = Number.POSITIVE_INFINITY; + this.minY = Number.POSITIVE_INFINITY; + this.maxX = Number.NEGATIVE_INFINITY; + this.maxY = Number.NEGATIVE_INFINITY; + } + }; + SkeletonBounds.prototype.aabbCompute = function() { + var minX = Number.POSITIVE_INFINITY, minY = Number.POSITIVE_INFINITY, maxX = Number.NEGATIVE_INFINITY, maxY = Number.NEGATIVE_INFINITY; + var polygons = this.polygons; + for (var i = 0, n = polygons.length; i < n; i++) { + var polygon = polygons[i]; + var vertices = polygon; + for (var ii = 0, nn = polygon.length; ii < nn; ii += 2) { + var x = vertices[ii]; + var y = vertices[ii + 1]; + minX = Math.min(minX, x); + minY = Math.min(minY, y); + maxX = Math.max(maxX, x); + maxY = Math.max(maxY, y); + } + } + this.minX = minX; + this.minY = minY; + this.maxX = maxX; + this.maxY = maxY; + }; + SkeletonBounds.prototype.aabbContainsPoint = function(x, y) { + return x >= this.minX && x <= this.maxX && y >= this.minY && y <= this.maxY; + }; + SkeletonBounds.prototype.aabbIntersectsSegment = function(x1, y1, x2, y2) { + var minX = this.minX; + var minY = this.minY; + var maxX = this.maxX; + var maxY = this.maxY; + if (x1 <= minX && x2 <= minX || y1 <= minY && y2 <= minY || x1 >= maxX && x2 >= maxX || y1 >= maxY && y2 >= maxY) return false; + var m = (y2 - y1) / (x2 - x1); + var y = m * (minX - x1) + y1; + if (y > minY && y < maxY) return true; + y = m * (maxX - x1) + y1; + if (y > minY && y < maxY) return true; + var x = (minY - y1) / m + x1; + if (x > minX && x < maxX) return true; + x = (maxY - y1) / m + x1; + if (x > minX && x < maxX) return true; + return false; + }; + SkeletonBounds.prototype.aabbIntersectsSkeleton = function(bounds) { + return this.minX < bounds.maxX && this.maxX > bounds.minX && this.minY < bounds.maxY && this.maxY > bounds.minY; + }; + SkeletonBounds.prototype.containsPoint = function(x, y) { + var polygons = this.polygons; + for (var i = 0, n = polygons.length; i < n; i++) if (this.containsPointPolygon(polygons[i], x, y)) return this.boundingBoxes[i]; + return null; + }; + SkeletonBounds.prototype.containsPointPolygon = function(polygon, x, y) { + var vertices = polygon; + var nn = polygon.length; + var prevIndex = nn - 2; + var inside = false; + for (var ii = 0; ii < nn; ii += 2) { + var vertexY = vertices[ii + 1]; + var prevY = vertices[prevIndex + 1]; + if (vertexY < y && prevY >= y || prevY < y && vertexY >= y) { + var vertexX = vertices[ii]; + vertexX + (y - vertexY) / (prevY - vertexY) * (vertices[prevIndex] - vertexX) < x && (inside = !inside); + } + prevIndex = ii; + } + return inside; + }; + SkeletonBounds.prototype.intersectsSegment = function(x1, y1, x2, y2) { + var polygons = this.polygons; + for (var i = 0, n = polygons.length; i < n; i++) if (this.intersectsSegmentPolygon(polygons[i], x1, y1, x2, y2)) return this.boundingBoxes[i]; + return null; + }; + SkeletonBounds.prototype.intersectsSegmentPolygon = function(polygon, x1, y1, x2, y2) { + var vertices = polygon; + var nn = polygon.length; + var width12 = x1 - x2, height12 = y1 - y2; + var det1 = x1 * y2 - y1 * x2; + var x3 = vertices[nn - 2], y3 = vertices[nn - 1]; + for (var ii = 0; ii < nn; ii += 2) { + var x4 = vertices[ii], y4 = vertices[ii + 1]; + var det2 = x3 * y4 - y3 * x4; + var width34 = x3 - x4, height34 = y3 - y4; + var det3 = width12 * height34 - height12 * width34; + var x = (det1 * width34 - width12 * det2) / det3; + if ((x >= x3 && x <= x4 || x >= x4 && x <= x3) && (x >= x1 && x <= x2 || x >= x2 && x <= x1)) { + var y = (det1 * height34 - height12 * det2) / det3; + if ((y >= y3 && y <= y4 || y >= y4 && y <= y3) && (y >= y1 && y <= y2 || y >= y2 && y <= y1)) return true; + } + x3 = x4; + y3 = y4; + } + return false; + }; + SkeletonBounds.prototype.getPolygon = function(boundingBox) { + if (null == boundingBox) throw new Error("boundingBox cannot be null."); + var index = this.boundingBoxes.indexOf(boundingBox); + return -1 == index ? null : this.polygons[index]; + }; + SkeletonBounds.prototype.getWidth = function() { + return this.maxX - this.minX; + }; + SkeletonBounds.prototype.getHeight = function() { + return this.maxY - this.minY; + }; + return SkeletonBounds; + })(); + spine.SkeletonBounds = SkeletonBounds; + })(spine || (spine = {})); + var spine; + (function(spine) { + var SkeletonClipping = (function() { + function SkeletonClipping() { + this.triangulator = new spine.Triangulator(); + this.clippingPolygon = new Array(); + this.clipOutput = new Array(); + this.clippedVertices = new Array(); + this.clippedTriangles = new Array(); + this.scratch = new Array(); + } + SkeletonClipping.prototype.clipStart = function(slot, clip) { + if (null != this.clipAttachment) return 0; + this.clipAttachment = clip; + var n = clip.worldVerticesLength; + var vertices = spine.Utils.setArraySize(this.clippingPolygon, n); + clip.computeWorldVertices(slot, 0, n, vertices, 0, 2); + var clippingPolygon = this.clippingPolygon; + SkeletonClipping.makeClockwise(clippingPolygon); + var clippingPolygons = this.clippingPolygons = this.triangulator.decompose(clippingPolygon, this.triangulator.triangulate(clippingPolygon)); + for (var i = 0, n_1 = clippingPolygons.length; i < n_1; i++) { + var polygon = clippingPolygons[i]; + SkeletonClipping.makeClockwise(polygon); + polygon.push(polygon[0]); + polygon.push(polygon[1]); + } + return clippingPolygons.length; + }; + SkeletonClipping.prototype.clipEndWithSlot = function(slot) { + null != this.clipAttachment && this.clipAttachment.endSlot == slot.data && this.clipEnd(); + }; + SkeletonClipping.prototype.clipEnd = function() { + if (null == this.clipAttachment) return; + this.clipAttachment = null; + this.clippingPolygons = null; + this.clippedVertices.length = 0; + this.clippedTriangles.length = 0; + this.clippingPolygon.length = 0; + }; + SkeletonClipping.prototype.isClipping = function() { + return null != this.clipAttachment; + }; + SkeletonClipping.prototype.clipTriangles = function(vertices, verticesLength, triangles, trianglesLength, uvs, light, dark, twoColor, stride, originIndexOffset, originVertOffset, originUVSOffset) { + var clipOutput = this.clipOutput, clippedVertices = this.clippedVertices; + var clippedTriangles = this.clippedTriangles; + var polygons = this.clippingPolygons; + var polygonsCount = this.clippingPolygons.length; + var vertexSize = twoColor ? 12 : 8; + var index = 0; + originIndexOffset = originIndexOffset || 0; + originVertOffset = originVertOffset || 0; + originUVSOffset = originUVSOffset || 0; + clippedVertices.length = 0; + clippedTriangles.length = 0; + outer: for (var i = originIndexOffset, n = originIndexOffset + trianglesLength; i < n; i += 3) { + var vertexOffset = triangles[i] * stride; + var xyOffset = vertexOffset + originVertOffset; + var uvOffset = vertexOffset + originUVSOffset; + var x1 = vertices[xyOffset], y1 = vertices[xyOffset + 1]; + var u1 = uvs[uvOffset], v1 = uvs[uvOffset + 1]; + vertexOffset = triangles[i + 1] * stride; + xyOffset = vertexOffset + originVertOffset; + uvOffset = vertexOffset + originUVSOffset; + var x2 = vertices[xyOffset], y2 = vertices[xyOffset + 1]; + var u2 = uvs[uvOffset], v2 = uvs[uvOffset + 1]; + vertexOffset = triangles[i + 2] * stride; + xyOffset = vertexOffset + originVertOffset; + uvOffset = vertexOffset + originUVSOffset; + var x3 = vertices[xyOffset], y3 = vertices[xyOffset + 1]; + var u3 = uvs[uvOffset], v3 = uvs[uvOffset + 1]; + for (var p = 0; p < polygonsCount; p++) { + var s = clippedVertices.length; + if (!this.clip(x1, y1, x2, y2, x3, y3, polygons[p], clipOutput)) { + var clippedVerticesItems = spine.Utils.setArraySize(clippedVertices, s + 3 * vertexSize); + clippedVerticesItems[s] = x1; + clippedVerticesItems[s + 1] = y1; + clippedVerticesItems[s + 2] = light.r; + clippedVerticesItems[s + 3] = light.g; + clippedVerticesItems[s + 4] = light.b; + clippedVerticesItems[s + 5] = light.a; + if (twoColor) { + clippedVerticesItems[s + 6] = u1; + clippedVerticesItems[s + 7] = v1; + clippedVerticesItems[s + 8] = dark.r; + clippedVerticesItems[s + 9] = dark.g; + clippedVerticesItems[s + 10] = dark.b; + clippedVerticesItems[s + 11] = dark.a; + clippedVerticesItems[s + 12] = x2; + clippedVerticesItems[s + 13] = y2; + clippedVerticesItems[s + 14] = light.r; + clippedVerticesItems[s + 15] = light.g; + clippedVerticesItems[s + 16] = light.b; + clippedVerticesItems[s + 17] = light.a; + clippedVerticesItems[s + 18] = u2; + clippedVerticesItems[s + 19] = v2; + clippedVerticesItems[s + 20] = dark.r; + clippedVerticesItems[s + 21] = dark.g; + clippedVerticesItems[s + 22] = dark.b; + clippedVerticesItems[s + 23] = dark.a; + clippedVerticesItems[s + 24] = x3; + clippedVerticesItems[s + 25] = y3; + clippedVerticesItems[s + 26] = light.r; + clippedVerticesItems[s + 27] = light.g; + clippedVerticesItems[s + 28] = light.b; + clippedVerticesItems[s + 29] = light.a; + clippedVerticesItems[s + 30] = u3; + clippedVerticesItems[s + 31] = v3; + clippedVerticesItems[s + 32] = dark.r; + clippedVerticesItems[s + 33] = dark.g; + clippedVerticesItems[s + 34] = dark.b; + clippedVerticesItems[s + 35] = dark.a; + } else { + clippedVerticesItems[s + 6] = u1; + clippedVerticesItems[s + 7] = v1; + clippedVerticesItems[s + 8] = x2; + clippedVerticesItems[s + 9] = y2; + clippedVerticesItems[s + 10] = light.r; + clippedVerticesItems[s + 11] = light.g; + clippedVerticesItems[s + 12] = light.b; + clippedVerticesItems[s + 13] = light.a; + clippedVerticesItems[s + 14] = u2; + clippedVerticesItems[s + 15] = v2; + clippedVerticesItems[s + 16] = x3; + clippedVerticesItems[s + 17] = y3; + clippedVerticesItems[s + 18] = light.r; + clippedVerticesItems[s + 19] = light.g; + clippedVerticesItems[s + 20] = light.b; + clippedVerticesItems[s + 21] = light.a; + clippedVerticesItems[s + 22] = u3; + clippedVerticesItems[s + 23] = v3; + } + s = clippedTriangles.length; + var clippedTrianglesItems = spine.Utils.setArraySize(clippedTriangles, s + 3); + clippedTrianglesItems[s] = index; + clippedTrianglesItems[s + 1] = index + 1; + clippedTrianglesItems[s + 2] = index + 2; + index += 3; + continue outer; + } + var clipOutputLength = clipOutput.length; + if (0 == clipOutputLength) continue; + var d0 = y2 - y3, d1 = x3 - x2, d2 = x1 - x3, d4 = y3 - y1; + var d = 1 / (d0 * d2 + d1 * (y1 - y3)); + var clipOutputCount = clipOutputLength >> 1; + var clipOutputItems = this.clipOutput; + var clippedVerticesItems = spine.Utils.setArraySize(clippedVertices, s + clipOutputCount * vertexSize); + for (var ii = 0; ii < clipOutputLength; ii += 2) { + var x = clipOutputItems[ii], y = clipOutputItems[ii + 1]; + clippedVerticesItems[s] = x; + clippedVerticesItems[s + 1] = y; + clippedVerticesItems[s + 2] = light.r; + clippedVerticesItems[s + 3] = light.g; + clippedVerticesItems[s + 4] = light.b; + clippedVerticesItems[s + 5] = light.a; + var c0 = x - x3, c1 = y - y3; + var a = (d0 * c0 + d1 * c1) * d; + var b = (d4 * c0 + d2 * c1) * d; + var c = 1 - a - b; + clippedVerticesItems[s + 6] = u1 * a + u2 * b + u3 * c; + clippedVerticesItems[s + 7] = v1 * a + v2 * b + v3 * c; + if (twoColor) { + clippedVerticesItems[s + 8] = dark.r; + clippedVerticesItems[s + 9] = dark.g; + clippedVerticesItems[s + 10] = dark.b; + clippedVerticesItems[s + 11] = dark.a; + } + s += vertexSize; + } + s = clippedTriangles.length; + var clippedTrianglesItems = spine.Utils.setArraySize(clippedTriangles, s + 3 * (clipOutputCount - 2)); + clipOutputCount--; + for (var ii = 1; ii < clipOutputCount; ii++) { + clippedTrianglesItems[s] = index; + clippedTrianglesItems[s + 1] = index + ii; + clippedTrianglesItems[s + 2] = index + ii + 1; + s += 3; + } + index += clipOutputCount + 1; + } + } + }; + SkeletonClipping.prototype.clip = function(x1, y1, x2, y2, x3, y3, clippingArea, output) { + var originalOutput = output; + var clipped = false; + var input = null; + if (clippingArea.length % 4 >= 2) { + input = output; + output = this.scratch; + } else input = this.scratch; + input.length = 0; + input.push(x1); + input.push(y1); + input.push(x2); + input.push(y2); + input.push(x3); + input.push(y3); + input.push(x1); + input.push(y1); + output.length = 0; + var clippingVertices = clippingArea; + var clippingVerticesLast = clippingArea.length - 4; + for (var i = 0; ;i += 2) { + var edgeX = clippingVertices[i], edgeY = clippingVertices[i + 1]; + var edgeX2 = clippingVertices[i + 2], edgeY2 = clippingVertices[i + 3]; + var deltaX = edgeX - edgeX2, deltaY = edgeY - edgeY2; + var inputVertices = input; + var inputVerticesLength = input.length - 2, outputStart = output.length; + for (var ii = 0; ii < inputVerticesLength; ii += 2) { + var inputX = inputVertices[ii], inputY = inputVertices[ii + 1]; + var inputX2 = inputVertices[ii + 2], inputY2 = inputVertices[ii + 3]; + var side2 = deltaX * (inputY2 - edgeY2) - deltaY * (inputX2 - edgeX2) > 0; + if (deltaX * (inputY - edgeY2) - deltaY * (inputX - edgeX2) > 0) { + if (side2) { + output.push(inputX2); + output.push(inputY2); + continue; + } + var c0 = inputY2 - inputY, c2 = inputX2 - inputX; + var s = c0 * (edgeX2 - edgeX) - c2 * (edgeY2 - edgeY); + if (Math.abs(s) > 1e-6) { + var ua = (c2 * (edgeY - inputY) - c0 * (edgeX - inputX)) / s; + output.push(edgeX + (edgeX2 - edgeX) * ua); + output.push(edgeY + (edgeY2 - edgeY) * ua); + } else { + output.push(edgeX); + output.push(edgeY); + } + } else if (side2) { + var c0 = inputY2 - inputY, c2 = inputX2 - inputX; + var s = c0 * (edgeX2 - edgeX) - c2 * (edgeY2 - edgeY); + if (Math.abs(s) > 1e-6) { + var ua = (c2 * (edgeY - inputY) - c0 * (edgeX - inputX)) / s; + output.push(edgeX + (edgeX2 - edgeX) * ua); + output.push(edgeY + (edgeY2 - edgeY) * ua); + } else { + output.push(edgeX); + output.push(edgeY); + } + output.push(inputX2); + output.push(inputY2); + } + clipped = true; + } + if (outputStart == output.length) { + originalOutput.length = 0; + return true; + } + output.push(output[0]); + output.push(output[1]); + if (i == clippingVerticesLast) break; + var temp = output; + output = input; + output.length = 0; + input = temp; + } + if (originalOutput != output) { + originalOutput.length = 0; + for (var i = 0, n = output.length - 2; i < n; i++) originalOutput[i] = output[i]; + } else originalOutput.length = originalOutput.length - 2; + return clipped; + }; + SkeletonClipping.makeClockwise = function(polygon) { + var vertices = polygon; + var verticeslength = polygon.length; + var area = vertices[verticeslength - 2] * vertices[1] - vertices[0] * vertices[verticeslength - 1], p1x = 0, p1y = 0, p2x = 0, p2y = 0; + for (var i = 0, n = verticeslength - 3; i < n; i += 2) { + p1x = vertices[i]; + p1y = vertices[i + 1]; + p2x = vertices[i + 2]; + p2y = vertices[i + 3]; + area += p1x * p2y - p2x * p1y; + } + if (area < 0) return; + for (var i = 0, lastX = verticeslength - 2, n = verticeslength >> 1; i < n; i += 2) { + var x = vertices[i], y = vertices[i + 1]; + var other = lastX - i; + vertices[i] = vertices[other]; + vertices[i + 1] = vertices[other + 1]; + vertices[other] = x; + vertices[other + 1] = y; + } + }; + return SkeletonClipping; + })(); + spine.SkeletonClipping = SkeletonClipping; + })(spine || (spine = {})); + var spine; + (function(spine) { + var SkeletonData = (function() { + function SkeletonData() { + this.bones = new Array(); + this.slots = new Array(); + this.skins = new Array(); + this.events = new Array(); + this.animations = new Array(); + this.ikConstraints = new Array(); + this.transformConstraints = new Array(); + this.pathConstraints = new Array(); + this.fps = 0; + } + SkeletonData.prototype.findBone = function(boneName) { + if (null == boneName) throw new Error("boneName cannot be null."); + var bones = this.bones; + for (var i = 0, n = bones.length; i < n; i++) { + var bone = bones[i]; + if (bone.name == boneName) return bone; + } + return null; + }; + SkeletonData.prototype.findBoneIndex = function(boneName) { + if (null == boneName) throw new Error("boneName cannot be null."); + var bones = this.bones; + for (var i = 0, n = bones.length; i < n; i++) if (bones[i].name == boneName) return i; + return -1; + }; + SkeletonData.prototype.findSlot = function(slotName) { + if (null == slotName) throw new Error("slotName cannot be null."); + var slots = this.slots; + for (var i = 0, n = slots.length; i < n; i++) { + var slot = slots[i]; + if (slot.name == slotName) return slot; + } + return null; + }; + SkeletonData.prototype.findSlotIndex = function(slotName) { + if (null == slotName) throw new Error("slotName cannot be null."); + var slots = this.slots; + for (var i = 0, n = slots.length; i < n; i++) if (slots[i].name == slotName) return i; + return -1; + }; + SkeletonData.prototype.findSkin = function(skinName) { + if (null == skinName) throw new Error("skinName cannot be null."); + var skins = this.skins; + for (var i = 0, n = skins.length; i < n; i++) { + var skin = skins[i]; + if (skin.name == skinName) return skin; + } + return null; + }; + SkeletonData.prototype.findEvent = function(eventDataName) { + if (null == eventDataName) throw new Error("eventDataName cannot be null."); + var events = this.events; + for (var i = 0, n = events.length; i < n; i++) { + var event_5 = events[i]; + if (event_5.name == eventDataName) return event_5; + } + return null; + }; + SkeletonData.prototype.findAnimation = function(animationName) { + if (null == animationName) throw new Error("animationName cannot be null."); + var animations = this.animations; + for (var i = 0, n = animations.length; i < n; i++) { + var animation = animations[i]; + if (animation.name == animationName) return animation; + } + return null; + }; + SkeletonData.prototype.findIkConstraint = function(constraintName) { + if (null == constraintName) throw new Error("constraintName cannot be null."); + var ikConstraints = this.ikConstraints; + for (var i = 0, n = ikConstraints.length; i < n; i++) { + var constraint = ikConstraints[i]; + if (constraint.name == constraintName) return constraint; + } + return null; + }; + SkeletonData.prototype.findTransformConstraint = function(constraintName) { + if (null == constraintName) throw new Error("constraintName cannot be null."); + var transformConstraints = this.transformConstraints; + for (var i = 0, n = transformConstraints.length; i < n; i++) { + var constraint = transformConstraints[i]; + if (constraint.name == constraintName) return constraint; + } + return null; + }; + SkeletonData.prototype.findPathConstraint = function(constraintName) { + if (null == constraintName) throw new Error("constraintName cannot be null."); + var pathConstraints = this.pathConstraints; + for (var i = 0, n = pathConstraints.length; i < n; i++) { + var constraint = pathConstraints[i]; + if (constraint.name == constraintName) return constraint; + } + return null; + }; + SkeletonData.prototype.findPathConstraintIndex = function(pathConstraintName) { + if (null == pathConstraintName) throw new Error("pathConstraintName cannot be null."); + var pathConstraints = this.pathConstraints; + for (var i = 0, n = pathConstraints.length; i < n; i++) if (pathConstraints[i].name == pathConstraintName) return i; + return -1; + }; + return SkeletonData; + })(); + spine.SkeletonData = SkeletonData; + })(spine || (spine = {})); + var spine; + (function(spine) { + var SkeletonJson = (function() { + function SkeletonJson(attachmentLoader) { + this.scale = 1; + this.linkedMeshes = new Array(); + this.attachmentLoader = attachmentLoader; + } + SkeletonJson.prototype.readSkeletonData = function(json) { + var scale = this.scale; + var skeletonData = new spine.SkeletonData(); + var root = "string" === typeof json ? JSON.parse(json) : json; + var skeletonMap = root.skeleton; + if (null != skeletonMap) { + skeletonData.hash = skeletonMap.hash; + skeletonData.version = skeletonMap.spine; + skeletonData.x = skeletonMap.x; + skeletonData.y = skeletonMap.y; + skeletonData.width = skeletonMap.width; + skeletonData.height = skeletonMap.height; + skeletonData.fps = skeletonMap.fps; + skeletonData.imagesPath = skeletonMap.images; + } + if (root.bones) for (var i = 0; i < root.bones.length; i++) { + var boneMap = root.bones[i]; + var parent_5 = null; + var parentName = this.getValue(boneMap, "parent", null); + if (null != parentName) { + parent_5 = skeletonData.findBone(parentName); + if (null == parent_5) throw new Error("Parent bone not found: " + parentName); + } + var data = new spine.BoneData(skeletonData.bones.length, boneMap.name, parent_5); + data.length = this.getValue(boneMap, "length", 0) * scale; + data.x = this.getValue(boneMap, "x", 0) * scale; + data.y = this.getValue(boneMap, "y", 0) * scale; + data.rotation = this.getValue(boneMap, "rotation", 0); + data.scaleX = this.getValue(boneMap, "scaleX", 1); + data.scaleY = this.getValue(boneMap, "scaleY", 1); + data.shearX = this.getValue(boneMap, "shearX", 0); + data.shearY = this.getValue(boneMap, "shearY", 0); + data.transformMode = SkeletonJson.transformModeFromString(this.getValue(boneMap, "transform", "normal")); + data.skinRequired = this.getValue(boneMap, "skin", false); + skeletonData.bones.push(data); + } + if (root.slots) for (var i = 0; i < root.slots.length; i++) { + var slotMap = root.slots[i]; + var slotName = slotMap.name; + var boneName = slotMap.bone; + var boneData = skeletonData.findBone(boneName); + if (null == boneData) throw new Error("Slot bone not found: " + boneName); + var data = new spine.SlotData(skeletonData.slots.length, slotName, boneData); + var color = this.getValue(slotMap, "color", null); + null != color && data.color.setFromString(color); + var dark = this.getValue(slotMap, "dark", null); + if (null != dark) { + data.darkColor = new spine.Color(1, 1, 1, 1); + data.darkColor.setFromString(dark); + } + data.attachmentName = this.getValue(slotMap, "attachment", null); + data.blendMode = SkeletonJson.blendModeFromString(this.getValue(slotMap, "blend", "normal")); + skeletonData.slots.push(data); + } + if (root.ik) for (var i = 0; i < root.ik.length; i++) { + var constraintMap = root.ik[i]; + var data = new spine.IkConstraintData(constraintMap.name); + data.order = this.getValue(constraintMap, "order", 0); + data.skinRequired = this.getValue(constraintMap, "skin", false); + for (var j = 0; j < constraintMap.bones.length; j++) { + var boneName = constraintMap.bones[j]; + var bone = skeletonData.findBone(boneName); + if (null == bone) throw new Error("IK bone not found: " + boneName); + data.bones.push(bone); + } + var targetName = constraintMap.target; + data.target = skeletonData.findBone(targetName); + if (null == data.target) throw new Error("IK target bone not found: " + targetName); + data.mix = this.getValue(constraintMap, "mix", 1); + data.softness = this.getValue(constraintMap, "softness", 0) * scale; + data.bendDirection = this.getValue(constraintMap, "bendPositive", true) ? 1 : -1; + data.compress = this.getValue(constraintMap, "compress", false); + data.stretch = this.getValue(constraintMap, "stretch", false); + data.uniform = this.getValue(constraintMap, "uniform", false); + skeletonData.ikConstraints.push(data); + } + if (root.transform) for (var i = 0; i < root.transform.length; i++) { + var constraintMap = root.transform[i]; + var data = new spine.TransformConstraintData(constraintMap.name); + data.order = this.getValue(constraintMap, "order", 0); + data.skinRequired = this.getValue(constraintMap, "skin", false); + for (var j = 0; j < constraintMap.bones.length; j++) { + var boneName = constraintMap.bones[j]; + var bone = skeletonData.findBone(boneName); + if (null == bone) throw new Error("Transform constraint bone not found: " + boneName); + data.bones.push(bone); + } + var targetName = constraintMap.target; + data.target = skeletonData.findBone(targetName); + if (null == data.target) throw new Error("Transform constraint target bone not found: " + targetName); + data.local = this.getValue(constraintMap, "local", false); + data.relative = this.getValue(constraintMap, "relative", false); + data.offsetRotation = this.getValue(constraintMap, "rotation", 0); + data.offsetX = this.getValue(constraintMap, "x", 0) * scale; + data.offsetY = this.getValue(constraintMap, "y", 0) * scale; + data.offsetScaleX = this.getValue(constraintMap, "scaleX", 0); + data.offsetScaleY = this.getValue(constraintMap, "scaleY", 0); + data.offsetShearY = this.getValue(constraintMap, "shearY", 0); + data.rotateMix = this.getValue(constraintMap, "rotateMix", 1); + data.translateMix = this.getValue(constraintMap, "translateMix", 1); + data.scaleMix = this.getValue(constraintMap, "scaleMix", 1); + data.shearMix = this.getValue(constraintMap, "shearMix", 1); + skeletonData.transformConstraints.push(data); + } + if (root.path) for (var i = 0; i < root.path.length; i++) { + var constraintMap = root.path[i]; + var data = new spine.PathConstraintData(constraintMap.name); + data.order = this.getValue(constraintMap, "order", 0); + data.skinRequired = this.getValue(constraintMap, "skin", false); + for (var j = 0; j < constraintMap.bones.length; j++) { + var boneName = constraintMap.bones[j]; + var bone = skeletonData.findBone(boneName); + if (null == bone) throw new Error("Transform constraint bone not found: " + boneName); + data.bones.push(bone); + } + var targetName = constraintMap.target; + data.target = skeletonData.findSlot(targetName); + if (null == data.target) throw new Error("Path target slot not found: " + targetName); + data.positionMode = SkeletonJson.positionModeFromString(this.getValue(constraintMap, "positionMode", "percent")); + data.spacingMode = SkeletonJson.spacingModeFromString(this.getValue(constraintMap, "spacingMode", "length")); + data.rotateMode = SkeletonJson.rotateModeFromString(this.getValue(constraintMap, "rotateMode", "tangent")); + data.offsetRotation = this.getValue(constraintMap, "rotation", 0); + data.position = this.getValue(constraintMap, "position", 0); + data.positionMode == spine.PositionMode.Fixed && (data.position *= scale); + data.spacing = this.getValue(constraintMap, "spacing", 0); + data.spacingMode != spine.SpacingMode.Length && data.spacingMode != spine.SpacingMode.Fixed || (data.spacing *= scale); + data.rotateMix = this.getValue(constraintMap, "rotateMix", 1); + data.translateMix = this.getValue(constraintMap, "translateMix", 1); + skeletonData.pathConstraints.push(data); + } + if (root.skins) { + var skins = root.skins; + var isArray = skins instanceof Array; + if (!isArray) { + var skinArr = []; + for (var skinName in skins) skinArr.push({ + name: skinName, + attachments: skins[skinName] + }); + skins = skinArr; + } + for (var i = 0; i < skins.length; i++) { + var skinMap = skins[i]; + var skin = new spine.Skin(skinMap.name); + if (skinMap.bones) for (var ii = 0; ii < skinMap.bones.length; ii++) { + var bone = skeletonData.findBone(skinMap.bones[ii]); + if (null == bone) throw new Error("Skin bone not found: " + skinMap.bones[i]); + skin.bones.push(bone); + } + if (skinMap.ik) for (var ii = 0; ii < skinMap.ik.length; ii++) { + var constraint = skeletonData.findIkConstraint(skinMap.ik[ii]); + if (null == constraint) throw new Error("Skin IK constraint not found: " + skinMap.ik[i]); + skin.constraints.push(constraint); + } + if (skinMap.transform) for (var ii = 0; ii < skinMap.transform.length; ii++) { + var constraint = skeletonData.findTransformConstraint(skinMap.transform[ii]); + if (null == constraint) throw new Error("Skin transform constraint not found: " + skinMap.transform[i]); + skin.constraints.push(constraint); + } + if (skinMap.path) for (var ii = 0; ii < skinMap.path.length; ii++) { + var constraint = skeletonData.findPathConstraint(skinMap.path[ii]); + if (null == constraint) throw new Error("Skin path constraint not found: " + skinMap.path[i]); + skin.constraints.push(constraint); + } + for (var slotName in skinMap.attachments) { + var slot = skeletonData.findSlot(slotName); + if (null == slot) throw new Error("Slot not found: " + slotName); + var slotMap = skinMap.attachments[slotName]; + for (var entryName in slotMap) { + var attachment = this.readAttachment(slotMap[entryName], skin, slot.index, entryName, skeletonData); + null != attachment && skin.setAttachment(slot.index, entryName, attachment); + } + } + skeletonData.skins.push(skin); + "default" == skin.name && (skeletonData.defaultSkin = skin); + } + } + for (var i = 0, n = this.linkedMeshes.length; i < n; i++) { + var linkedMesh = this.linkedMeshes[i]; + var skin = null == linkedMesh.skin ? skeletonData.defaultSkin : skeletonData.findSkin(linkedMesh.skin); + if (null == skin) throw new Error("Skin not found: " + linkedMesh.skin); + var parent_6 = skin.getAttachment(linkedMesh.slotIndex, linkedMesh.parent); + if (null == parent_6) throw new Error("Parent mesh not found: " + linkedMesh.parent); + linkedMesh.mesh.deformAttachment = linkedMesh.inheritDeform ? parent_6 : linkedMesh.mesh; + linkedMesh.mesh.setParentMesh(parent_6); + linkedMesh.mesh.updateUVs(); + } + this.linkedMeshes.length = 0; + if (root.events) for (var eventName in root.events) { + var eventMap = root.events[eventName]; + var data = new spine.EventData(eventName); + data.intValue = this.getValue(eventMap, "int", 0); + data.floatValue = this.getValue(eventMap, "float", 0); + data.stringValue = this.getValue(eventMap, "string", ""); + data.audioPath = this.getValue(eventMap, "audio", null); + if (null != data.audioPath) { + data.volume = this.getValue(eventMap, "volume", 1); + data.balance = this.getValue(eventMap, "balance", 0); + } + skeletonData.events.push(data); + } + if (root.animations) for (var animationName in root.animations) { + var animationMap = root.animations[animationName]; + this.readAnimation(animationMap, animationName, skeletonData); + } + return skeletonData; + }; + SkeletonJson.prototype.readAttachment = function(map, skin, slotIndex, name, skeletonData) { + var scale = this.scale; + name = this.getValue(map, "name", name); + var type = this.getValue(map, "type", "region"); + switch (type) { + case "region": + var path = this.getValue(map, "path", name); + var region = this.attachmentLoader.newRegionAttachment(skin, name, path); + if (null == region) return null; + region.path = path; + region.x = this.getValue(map, "x", 0) * scale; + region.y = this.getValue(map, "y", 0) * scale; + region.scaleX = this.getValue(map, "scaleX", 1); + region.scaleY = this.getValue(map, "scaleY", 1); + region.rotation = this.getValue(map, "rotation", 0); + region.width = map.width * scale; + region.height = map.height * scale; + var color = this.getValue(map, "color", null); + null != color && region.color.setFromString(color); + region.updateOffset(); + return region; + + case "boundingbox": + var box = this.attachmentLoader.newBoundingBoxAttachment(skin, name); + if (null == box) return null; + this.readVertices(map, box, map.vertexCount << 1); + var color = this.getValue(map, "color", null); + null != color && box.color.setFromString(color); + return box; + + case "mesh": + case "linkedmesh": + var path = this.getValue(map, "path", name); + var mesh = this.attachmentLoader.newMeshAttachment(skin, name, path); + if (null == mesh) return null; + mesh.path = path; + var color = this.getValue(map, "color", null); + null != color && mesh.color.setFromString(color); + mesh.width = this.getValue(map, "width", 0) * scale; + mesh.height = this.getValue(map, "height", 0) * scale; + var parent_7 = this.getValue(map, "parent", null); + if (null != parent_7) { + this.linkedMeshes.push(new LinkedMesh(mesh, this.getValue(map, "skin", null), slotIndex, parent_7, this.getValue(map, "deform", true))); + return mesh; + } + var uvs = map.uvs; + this.readVertices(map, mesh, uvs.length); + mesh.triangles = map.triangles; + mesh.regionUVs = uvs; + mesh.updateUVs(); + mesh.edges = this.getValue(map, "edges", null); + mesh.hullLength = 2 * this.getValue(map, "hull", 0); + return mesh; + + case "path": + var path = this.attachmentLoader.newPathAttachment(skin, name); + if (null == path) return null; + path.closed = this.getValue(map, "closed", false); + path.constantSpeed = this.getValue(map, "constantSpeed", true); + var vertexCount = map.vertexCount; + this.readVertices(map, path, vertexCount << 1); + var lengths = spine.Utils.newArray(vertexCount / 3, 0); + for (var i = 0; i < map.lengths.length; i++) lengths[i] = map.lengths[i] * scale; + path.lengths = lengths; + var color = this.getValue(map, "color", null); + null != color && path.color.setFromString(color); + return path; + + case "point": + var point = this.attachmentLoader.newPointAttachment(skin, name); + if (null == point) return null; + point.x = this.getValue(map, "x", 0) * scale; + point.y = this.getValue(map, "y", 0) * scale; + point.rotation = this.getValue(map, "rotation", 0); + var color = this.getValue(map, "color", null); + null != color && point.color.setFromString(color); + return point; + + case "clipping": + var clip = this.attachmentLoader.newClippingAttachment(skin, name); + if (null == clip) return null; + var end = this.getValue(map, "end", null); + if (null != end) { + var slot = skeletonData.findSlot(end); + if (null == slot) throw new Error("Clipping end slot not found: " + end); + clip.endSlot = slot; + } + var vertexCount = map.vertexCount; + this.readVertices(map, clip, vertexCount << 1); + var color = this.getValue(map, "color", null); + null != color && clip.color.setFromString(color); + return clip; + } + return null; + }; + SkeletonJson.prototype.readVertices = function(map, attachment, verticesLength) { + var scale = this.scale; + attachment.worldVerticesLength = verticesLength; + var vertices = map.vertices; + if (verticesLength == vertices.length) { + var scaledVertices = spine.Utils.toFloatArray(vertices); + if (1 != scale) for (var i = 0, n = vertices.length; i < n; i++) scaledVertices[i] *= scale; + attachment.vertices = scaledVertices; + return; + } + var weights = new Array(); + var bones = new Array(); + for (var i = 0, n = vertices.length; i < n; ) { + var boneCount = vertices[i++]; + bones.push(boneCount); + for (var nn = i + 4 * boneCount; i < nn; i += 4) { + bones.push(vertices[i]); + weights.push(vertices[i + 1] * scale); + weights.push(vertices[i + 2] * scale); + weights.push(vertices[i + 3]); + } + } + attachment.bones = bones; + attachment.vertices = spine.Utils.toFloatArray(weights); + }; + SkeletonJson.prototype.readAnimation = function(map, name, skeletonData) { + var scale = this.scale; + var timelines = new Array(); + var duration = 0; + if (map.slots) for (var slotName in map.slots) { + var slotMap = map.slots[slotName]; + var slotIndex = skeletonData.findSlotIndex(slotName); + if (-1 == slotIndex) throw new Error("Slot not found: " + slotName); + for (var timelineName in slotMap) { + var timelineMap = slotMap[timelineName]; + if ("attachment" == timelineName) { + var timeline = new spine.AttachmentTimeline(timelineMap.length); + timeline.slotIndex = slotIndex; + var frameIndex = 0; + for (var i = 0; i < timelineMap.length; i++) { + var valueMap = timelineMap[i]; + timeline.setFrame(frameIndex++, this.getValue(valueMap, "time", 0), valueMap.name); + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[timeline.getFrameCount() - 1]); + } else if ("color" == timelineName) { + var timeline = new spine.ColorTimeline(timelineMap.length); + timeline.slotIndex = slotIndex; + var frameIndex = 0; + for (var i = 0; i < timelineMap.length; i++) { + var valueMap = timelineMap[i]; + var color = new spine.Color(); + color.setFromString(valueMap.color); + timeline.setFrame(frameIndex, this.getValue(valueMap, "time", 0), color.r, color.g, color.b, color.a); + this.readCurve(valueMap, timeline, frameIndex); + frameIndex++; + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * spine.ColorTimeline.ENTRIES]); + } else { + if ("twoColor" != timelineName) throw new Error("Invalid timeline type for a slot: " + timelineName + " (" + slotName + ")"); + var timeline = new spine.TwoColorTimeline(timelineMap.length); + timeline.slotIndex = slotIndex; + var frameIndex = 0; + for (var i = 0; i < timelineMap.length; i++) { + var valueMap = timelineMap[i]; + var light = new spine.Color(); + var dark = new spine.Color(); + light.setFromString(valueMap.light); + dark.setFromString(valueMap.dark); + timeline.setFrame(frameIndex, this.getValue(valueMap, "time", 0), light.r, light.g, light.b, light.a, dark.r, dark.g, dark.b); + this.readCurve(valueMap, timeline, frameIndex); + frameIndex++; + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * spine.TwoColorTimeline.ENTRIES]); + } + } + } + if (map.bones) for (var boneName in map.bones) { + var boneMap = map.bones[boneName]; + var boneIndex = skeletonData.findBoneIndex(boneName); + if (-1 == boneIndex) throw new Error("Bone not found: " + boneName); + for (var timelineName in boneMap) { + var timelineMap = boneMap[timelineName]; + if ("rotate" === timelineName) { + var timeline = new spine.RotateTimeline(timelineMap.length); + timeline.boneIndex = boneIndex; + var frameIndex = 0; + for (var i = 0; i < timelineMap.length; i++) { + var valueMap = timelineMap[i]; + timeline.setFrame(frameIndex, this.getValue(valueMap, "time", 0), this.getValue(valueMap, "angle", 0)); + this.readCurve(valueMap, timeline, frameIndex); + frameIndex++; + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * spine.RotateTimeline.ENTRIES]); + } else { + if ("translate" !== timelineName && "scale" !== timelineName && "shear" !== timelineName) throw new Error("Invalid timeline type for a bone: " + timelineName + " (" + boneName + ")"); + var timeline = null; + var timelineScale = 1, defaultValue = 0; + if ("scale" === timelineName) { + timeline = new spine.ScaleTimeline(timelineMap.length); + defaultValue = 1; + } else if ("shear" === timelineName) timeline = new spine.ShearTimeline(timelineMap.length); else { + timeline = new spine.TranslateTimeline(timelineMap.length); + timelineScale = scale; + } + timeline.boneIndex = boneIndex; + var frameIndex = 0; + for (var i = 0; i < timelineMap.length; i++) { + var valueMap = timelineMap[i]; + var x = this.getValue(valueMap, "x", defaultValue), y = this.getValue(valueMap, "y", defaultValue); + timeline.setFrame(frameIndex, this.getValue(valueMap, "time", 0), x * timelineScale, y * timelineScale); + this.readCurve(valueMap, timeline, frameIndex); + frameIndex++; + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * spine.TranslateTimeline.ENTRIES]); + } + } + } + if (map.ik) for (var constraintName in map.ik) { + var constraintMap = map.ik[constraintName]; + var constraint = skeletonData.findIkConstraint(constraintName); + var timeline = new spine.IkConstraintTimeline(constraintMap.length); + timeline.ikConstraintIndex = skeletonData.ikConstraints.indexOf(constraint); + var frameIndex = 0; + for (var i = 0; i < constraintMap.length; i++) { + var valueMap = constraintMap[i]; + timeline.setFrame(frameIndex, this.getValue(valueMap, "time", 0), this.getValue(valueMap, "mix", 1), this.getValue(valueMap, "softness", 0) * scale, this.getValue(valueMap, "bendPositive", true) ? 1 : -1, this.getValue(valueMap, "compress", false), this.getValue(valueMap, "stretch", false)); + this.readCurve(valueMap, timeline, frameIndex); + frameIndex++; + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * spine.IkConstraintTimeline.ENTRIES]); + } + if (map.transform) for (var constraintName in map.transform) { + var constraintMap = map.transform[constraintName]; + var constraint = skeletonData.findTransformConstraint(constraintName); + var timeline = new spine.TransformConstraintTimeline(constraintMap.length); + timeline.transformConstraintIndex = skeletonData.transformConstraints.indexOf(constraint); + var frameIndex = 0; + for (var i = 0; i < constraintMap.length; i++) { + var valueMap = constraintMap[i]; + timeline.setFrame(frameIndex, this.getValue(valueMap, "time", 0), this.getValue(valueMap, "rotateMix", 1), this.getValue(valueMap, "translateMix", 1), this.getValue(valueMap, "scaleMix", 1), this.getValue(valueMap, "shearMix", 1)); + this.readCurve(valueMap, timeline, frameIndex); + frameIndex++; + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * spine.TransformConstraintTimeline.ENTRIES]); + } + var mapPath = map.path || map.paths; + if (mapPath) for (var constraintName in mapPath) { + var constraintMap = mapPath[constraintName]; + var index = skeletonData.findPathConstraintIndex(constraintName); + if (-1 == index) throw new Error("Path constraint not found: " + constraintName); + var data = skeletonData.pathConstraints[index]; + for (var timelineName in constraintMap) { + var timelineMap = constraintMap[timelineName]; + if ("position" === timelineName || "spacing" === timelineName) { + var timeline = null; + var timelineScale = 1; + if ("spacing" === timelineName) { + timeline = new spine.PathConstraintSpacingTimeline(timelineMap.length); + data.spacingMode != spine.SpacingMode.Length && data.spacingMode != spine.SpacingMode.Fixed || (timelineScale = scale); + } else { + timeline = new spine.PathConstraintPositionTimeline(timelineMap.length); + data.positionMode == spine.PositionMode.Fixed && (timelineScale = scale); + } + timeline.pathConstraintIndex = index; + var frameIndex = 0; + for (var i = 0; i < timelineMap.length; i++) { + var valueMap = timelineMap[i]; + timeline.setFrame(frameIndex, this.getValue(valueMap, "time", 0), this.getValue(valueMap, timelineName, 0) * timelineScale); + this.readCurve(valueMap, timeline, frameIndex); + frameIndex++; + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * spine.PathConstraintPositionTimeline.ENTRIES]); + } else if ("mix" === timelineName) { + var timeline = new spine.PathConstraintMixTimeline(timelineMap.length); + timeline.pathConstraintIndex = index; + var frameIndex = 0; + for (var i = 0; i < timelineMap.length; i++) { + var valueMap = timelineMap[i]; + timeline.setFrame(frameIndex, this.getValue(valueMap, "time", 0), this.getValue(valueMap, "rotateMix", 1), this.getValue(valueMap, "translateMix", 1)); + this.readCurve(valueMap, timeline, frameIndex); + frameIndex++; + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * spine.PathConstraintMixTimeline.ENTRIES]); + } + } + } + if (map.deform) for (var deformName in map.deform) { + var deformMap = map.deform[deformName]; + var skin = skeletonData.findSkin(deformName); + if (null == skin) throw new Error("Skin not found: " + deformName); + for (var slotName in deformMap) { + var slotMap = deformMap[slotName]; + var slotIndex = skeletonData.findSlotIndex(slotName); + if (-1 == slotIndex) throw new Error("Slot not found: " + slotMap.name); + for (var timelineName in slotMap) { + var timelineMap = slotMap[timelineName]; + var attachment = skin.getAttachment(slotIndex, timelineName); + if (null == attachment) continue; + var weighted = null != attachment.bones; + var vertices = attachment.vertices; + var deformLength = weighted ? vertices.length / 3 * 2 : vertices.length; + var timeline = new spine.DeformTimeline(timelineMap.length); + timeline.slotIndex = slotIndex; + timeline.attachment = attachment; + var frameIndex = 0; + for (var j = 0; j < timelineMap.length; j++) { + var valueMap = timelineMap[j]; + var deform = void 0; + var verticesValue = this.getValue(valueMap, "vertices", null); + if (null == verticesValue) deform = weighted ? spine.Utils.newFloatArray(deformLength) : vertices; else { + deform = spine.Utils.newFloatArray(deformLength); + var start = this.getValue(valueMap, "offset", 0); + spine.Utils.arrayCopy(verticesValue, 0, deform, start, verticesValue.length); + if (1 != scale) for (var i = start, n = i + verticesValue.length; i < n; i++) deform[i] *= scale; + if (!weighted) for (var i = 0; i < deformLength; i++) deform[i] += vertices[i]; + } + timeline.setFrame(frameIndex, this.getValue(valueMap, "time", 0), deform); + this.readCurve(valueMap, timeline, frameIndex); + frameIndex++; + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[timeline.getFrameCount() - 1]); + } + } + } + var drawOrderNode = map.drawOrder; + null == drawOrderNode && (drawOrderNode = map.draworder); + if (null != drawOrderNode) { + var timeline = new spine.DrawOrderTimeline(drawOrderNode.length); + var slotCount = skeletonData.slots.length; + var frameIndex = 0; + for (var j = 0; j < drawOrderNode.length; j++) { + var drawOrderMap = drawOrderNode[j]; + var drawOrder = null; + var offsets = this.getValue(drawOrderMap, "offsets", null); + if (null != offsets) { + drawOrder = spine.Utils.newArray(slotCount, -1); + var unchanged = spine.Utils.newArray(slotCount - offsets.length, 0); + var originalIndex = 0, unchangedIndex = 0; + for (var i = 0; i < offsets.length; i++) { + var offsetMap = offsets[i]; + var slotIndex = skeletonData.findSlotIndex(offsetMap.slot); + if (-1 == slotIndex) throw new Error("Slot not found: " + offsetMap.slot); + while (originalIndex != slotIndex) unchanged[unchangedIndex++] = originalIndex++; + drawOrder[originalIndex + offsetMap.offset] = originalIndex++; + } + while (originalIndex < slotCount) unchanged[unchangedIndex++] = originalIndex++; + for (var i = slotCount - 1; i >= 0; i--) -1 == drawOrder[i] && (drawOrder[i] = unchanged[--unchangedIndex]); + } + timeline.setFrame(frameIndex++, this.getValue(drawOrderMap, "time", 0), drawOrder); + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[timeline.getFrameCount() - 1]); + } + if (map.events) { + var timeline = new spine.EventTimeline(map.events.length); + var frameIndex = 0; + for (var i = 0; i < map.events.length; i++) { + var eventMap = map.events[i]; + var eventData = skeletonData.findEvent(eventMap.name); + if (null == eventData) throw new Error("Event not found: " + eventMap.name); + var event_6 = new spine.Event(spine.Utils.toSinglePrecision(this.getValue(eventMap, "time", 0)), eventData); + event_6.intValue = this.getValue(eventMap, "int", eventData.intValue); + event_6.floatValue = this.getValue(eventMap, "float", eventData.floatValue); + event_6.stringValue = this.getValue(eventMap, "string", eventData.stringValue); + if (null != event_6.data.audioPath) { + event_6.volume = this.getValue(eventMap, "volume", 1); + event_6.balance = this.getValue(eventMap, "balance", 0); + } + timeline.setFrame(frameIndex++, event_6); + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[timeline.getFrameCount() - 1]); + } + if (isNaN(duration)) throw new Error("Error while parsing animation, duration is NaN"); + skeletonData.animations.push(new spine.Animation(name, timelines, duration)); + }; + SkeletonJson.prototype.readCurve = function(map, timeline, frameIndex) { + var curve = map.curve; + if (!curve) return; + "stepped" == curve ? timeline.setStepped(frameIndex) : "[object Array]" === Object.prototype.toString.call(curve) ? timeline.setCurve(frameIndex, curve[0], curve[1], curve[2], curve[3]) : timeline.setCurve(frameIndex, curve, this.getValue(map, "c2", 0), this.getValue(map, "c3", 1), this.getValue(map, "c4", 1)); + }; + SkeletonJson.prototype.getValue = function(map, prop, defaultValue) { + return void 0 !== map[prop] ? map[prop] : defaultValue; + }; + SkeletonJson.blendModeFromString = function(str) { + str = str.toLowerCase(); + if ("normal" == str) return spine.BlendMode.Normal; + if ("additive" == str) return spine.BlendMode.Additive; + if ("multiply" == str) return spine.BlendMode.Multiply; + if ("screen" == str) return spine.BlendMode.Screen; + throw new Error("Unknown blend mode: " + str); + }; + SkeletonJson.positionModeFromString = function(str) { + str = str.toLowerCase(); + if ("fixed" == str) return spine.PositionMode.Fixed; + if ("percent" == str) return spine.PositionMode.Percent; + throw new Error("Unknown position mode: " + str); + }; + SkeletonJson.spacingModeFromString = function(str) { + str = str.toLowerCase(); + if ("length" == str) return spine.SpacingMode.Length; + if ("fixed" == str) return spine.SpacingMode.Fixed; + if ("percent" == str) return spine.SpacingMode.Percent; + throw new Error("Unknown position mode: " + str); + }; + SkeletonJson.rotateModeFromString = function(str) { + str = str.toLowerCase(); + if ("tangent" == str) return spine.RotateMode.Tangent; + if ("chain" == str) return spine.RotateMode.Chain; + if ("chainscale" == str) return spine.RotateMode.ChainScale; + throw new Error("Unknown rotate mode: " + str); + }; + SkeletonJson.transformModeFromString = function(str) { + str = str.toLowerCase(); + if ("normal" == str) return spine.TransformMode.Normal; + if ("onlytranslation" == str) return spine.TransformMode.OnlyTranslation; + if ("norotationorreflection" == str) return spine.TransformMode.NoRotationOrReflection; + if ("noscale" == str) return spine.TransformMode.NoScale; + if ("noscaleorreflection" == str) return spine.TransformMode.NoScaleOrReflection; + throw new Error("Unknown transform mode: " + str); + }; + return SkeletonJson; + })(); + spine.SkeletonJson = SkeletonJson; + var LinkedMesh = (function() { + function LinkedMesh(mesh, skin, slotIndex, parent, inheritDeform) { + this.mesh = mesh; + this.skin = skin; + this.slotIndex = slotIndex; + this.parent = parent; + this.inheritDeform = inheritDeform; + } + return LinkedMesh; + })(); + })(spine || (spine = {})); + var spine; + (function(spine) { + var SkinEntry = (function() { + function SkinEntry(slotIndex, name, attachment) { + this.slotIndex = slotIndex; + this.name = name; + this.attachment = attachment; + } + return SkinEntry; + })(); + spine.SkinEntry = SkinEntry; + var Skin = (function() { + function Skin(name) { + this.attachments = new Array(); + this.bones = Array(); + this.constraints = new Array(); + if (null == name) throw new Error("name cannot be null."); + this.name = name; + } + Skin.prototype.setAttachment = function(slotIndex, name, attachment) { + if (null == attachment) throw new Error("attachment cannot be null."); + var attachments = this.attachments; + slotIndex >= attachments.length && (attachments.length = slotIndex + 1); + attachments[slotIndex] || (attachments[slotIndex] = {}); + attachments[slotIndex][name] = attachment; + }; + Skin.prototype.addSkin = function(skin) { + for (var i = 0; i < skin.bones.length; i++) { + var bone = skin.bones[i]; + var contained = false; + for (var j = 0; j < this.bones.length; j++) if (this.bones[j] == bone) { + contained = true; + break; + } + contained || this.bones.push(bone); + } + for (var i = 0; i < skin.constraints.length; i++) { + var constraint = skin.constraints[i]; + var contained = false; + for (var j = 0; j < this.constraints.length; j++) if (this.constraints[j] == constraint) { + contained = true; + break; + } + contained || this.constraints.push(constraint); + } + var attachments = skin.getAttachments(); + for (var i = 0; i < attachments.length; i++) { + var attachment = attachments[i]; + this.setAttachment(attachment.slotIndex, attachment.name, attachment.attachment); + } + }; + Skin.prototype.copySkin = function(skin) { + for (var i = 0; i < skin.bones.length; i++) { + var bone = skin.bones[i]; + var contained = false; + for (var j = 0; j < this.bones.length; j++) if (this.bones[j] == bone) { + contained = true; + break; + } + contained || this.bones.push(bone); + } + for (var i = 0; i < skin.constraints.length; i++) { + var constraint = skin.constraints[i]; + var contained = false; + for (var j = 0; j < this.constraints.length; j++) if (this.constraints[j] == constraint) { + contained = true; + break; + } + contained || this.constraints.push(constraint); + } + var attachments = skin.getAttachments(); + for (var i = 0; i < attachments.length; i++) { + var attachment = attachments[i]; + if (null == attachment.attachment) continue; + if (attachment.attachment instanceof spine.MeshAttachment) { + attachment.attachment = attachment.attachment.newLinkedMesh(); + this.setAttachment(attachment.slotIndex, attachment.name, attachment.attachment); + } else { + attachment.attachment = attachment.attachment.copy(); + this.setAttachment(attachment.slotIndex, attachment.name, attachment.attachment); + } + } + }; + Skin.prototype.getAttachment = function(slotIndex, name) { + var dictionary = this.attachments[slotIndex]; + return dictionary ? dictionary[name] : null; + }; + Skin.prototype.removeAttachment = function(slotIndex, name) { + var dictionary = this.attachments[slotIndex]; + dictionary && (dictionary[name] = null); + }; + Skin.prototype.getAttachments = function() { + var entries = new Array(); + for (var i = 0; i < this.attachments.length; i++) { + var slotAttachments = this.attachments[i]; + if (slotAttachments) for (var name_4 in slotAttachments) { + var attachment = slotAttachments[name_4]; + attachment && entries.push(new SkinEntry(i, name_4, attachment)); + } + } + return entries; + }; + Skin.prototype.getAttachmentsForSlot = function(slotIndex, attachments) { + var slotAttachments = this.attachments[slotIndex]; + if (slotAttachments) for (var name_5 in slotAttachments) { + var attachment = slotAttachments[name_5]; + attachment && attachments.push(new SkinEntry(slotIndex, name_5, attachment)); + } + }; + Skin.prototype.clear = function() { + this.attachments.length = 0; + this.bones.length = 0; + this.constraints.length = 0; + }; + Skin.prototype.attachAll = function(skeleton, oldSkin) { + var slotIndex = 0; + for (var i = 0; i < skeleton.slots.length; i++) { + var slot = skeleton.slots[i]; + var slotAttachment = slot.getAttachment(); + if (slotAttachment && slotIndex < oldSkin.attachments.length) { + var dictionary = oldSkin.attachments[slotIndex]; + for (var key in dictionary) { + var skinAttachment = dictionary[key]; + if (slotAttachment == skinAttachment) { + var attachment = this.getAttachment(slotIndex, key); + null != attachment && slot.setAttachment(attachment); + break; + } + } + } + slotIndex++; + } + }; + return Skin; + })(); + spine.Skin = Skin; + })(spine || (spine = {})); + var spine; + (function(spine) { + var Slot = (function() { + function Slot(data, bone) { + this.deform = new Array(); + if (null == data) throw new Error("data cannot be null."); + if (null == bone) throw new Error("bone cannot be null."); + this.data = data; + this.bone = bone; + this.color = new spine.Color(); + this.darkColor = null == data.darkColor ? null : new spine.Color(); + this.setToSetupPose(); + } + Slot.prototype.getSkeleton = function() { + return this.bone.skeleton; + }; + Slot.prototype.getAttachment = function() { + return this.attachment; + }; + Slot.prototype.setAttachment = function(attachment) { + if (this.attachment == attachment) return; + this.attachment = attachment; + this.attachmentTime = this.bone.skeleton.time; + this.deform.length = 0; + }; + Slot.prototype.setAttachmentTime = function(time) { + this.attachmentTime = this.bone.skeleton.time - time; + }; + Slot.prototype.getAttachmentTime = function() { + return this.bone.skeleton.time - this.attachmentTime; + }; + Slot.prototype.setToSetupPose = function() { + this.color.setFromColor(this.data.color); + null != this.darkColor && this.darkColor.setFromColor(this.data.darkColor); + if (null == this.data.attachmentName) this.attachment = null; else { + this.attachment = null; + this.setAttachment(this.bone.skeleton.getAttachment(this.data.index, this.data.attachmentName)); + } + }; + return Slot; + })(); + spine.Slot = Slot; + })(spine || (spine = {})); + var spine; + (function(spine) { + var SlotData = (function() { + function SlotData(index, name, boneData) { + this.color = new spine.Color(1, 1, 1, 1); + if (index < 0) throw new Error("index must be >= 0."); + if (null == name) throw new Error("name cannot be null."); + if (null == boneData) throw new Error("boneData cannot be null."); + this.index = index; + this.name = name; + this.boneData = boneData; + } + return SlotData; + })(); + spine.SlotData = SlotData; + })(spine || (spine = {})); + var spine; + (function(spine) { + var Texture = (function() { + function Texture(image) { + this._image = image; + } + Texture.prototype.getImage = function() { + return this._image; + }; + Texture.filterFromString = function(text) { + switch (text.toLowerCase()) { + case "nearest": + return TextureFilter.Nearest; + + case "linear": + return TextureFilter.Linear; + + case "mipmap": + return TextureFilter.MipMap; + + case "mipmapnearestnearest": + return TextureFilter.MipMapNearestNearest; + + case "mipmaplinearnearest": + return TextureFilter.MipMapLinearNearest; + + case "mipmapnearestlinear": + return TextureFilter.MipMapNearestLinear; + + case "mipmaplinearlinear": + return TextureFilter.MipMapLinearLinear; + + default: + throw new Error("Unknown texture filter " + text); + } + }; + Texture.wrapFromString = function(text) { + switch (text.toLowerCase()) { + case "mirroredtepeat": + return TextureWrap.MirroredRepeat; + + case "clamptoedge": + return TextureWrap.ClampToEdge; + + case "repeat": + return TextureWrap.Repeat; + + default: + throw new Error("Unknown texture wrap " + text); + } + }; + return Texture; + })(); + spine.Texture = Texture; + var TextureFilter; + (function(TextureFilter) { + TextureFilter[TextureFilter["Nearest"] = 9728] = "Nearest"; + TextureFilter[TextureFilter["Linear"] = 9729] = "Linear"; + TextureFilter[TextureFilter["MipMap"] = 9987] = "MipMap"; + TextureFilter[TextureFilter["MipMapNearestNearest"] = 9984] = "MipMapNearestNearest"; + TextureFilter[TextureFilter["MipMapLinearNearest"] = 9985] = "MipMapLinearNearest"; + TextureFilter[TextureFilter["MipMapNearestLinear"] = 9986] = "MipMapNearestLinear"; + TextureFilter[TextureFilter["MipMapLinearLinear"] = 9987] = "MipMapLinearLinear"; + })(TextureFilter = spine.TextureFilter || (spine.TextureFilter = {})); + var TextureWrap; + (function(TextureWrap) { + TextureWrap[TextureWrap["MirroredRepeat"] = 33648] = "MirroredRepeat"; + TextureWrap[TextureWrap["ClampToEdge"] = 33071] = "ClampToEdge"; + TextureWrap[TextureWrap["Repeat"] = 10497] = "Repeat"; + })(TextureWrap = spine.TextureWrap || (spine.TextureWrap = {})); + var TextureRegion = (function() { + function TextureRegion() { + this.u = 0; + this.v = 0; + this.u2 = 0; + this.v2 = 0; + this.width = 0; + this.height = 0; + this.rotate = false; + this.offsetX = 0; + this.offsetY = 0; + this.originalWidth = 0; + this.originalHeight = 0; + } + return TextureRegion; + })(); + spine.TextureRegion = TextureRegion; + var FakeTexture = (function(_super) { + __extends(FakeTexture, _super); + function FakeTexture() { + return null !== _super && _super.apply(this, arguments) || this; + } + FakeTexture.prototype.setFilters = function(minFilter, magFilter) {}; + FakeTexture.prototype.setWraps = function(uWrap, vWrap) {}; + FakeTexture.prototype.dispose = function() {}; + return FakeTexture; + })(Texture); + spine.FakeTexture = FakeTexture; + })(spine || (spine = {})); + var spine; + (function(spine) { + var TextureAtlas = (function() { + function TextureAtlas(atlasText, textureLoader) { + this.pages = new Array(); + this.regions = new Array(); + this.load(atlasText, textureLoader); + } + TextureAtlas.prototype.load = function(atlasText, textureLoader) { + if (null == textureLoader) throw new Error("textureLoader cannot be null."); + var reader = new TextureAtlasReader(atlasText); + var tuple = new Array(4); + var page = null; + while (true) { + var line = reader.readLine(); + if (null == line) break; + line = line.trim(); + if (0 == line.length) page = null; else if (page) { + var region = new TextureAtlasRegion(); + region.name = line; + region.page = page; + var rotateValue = reader.readValue(); + "true" == rotateValue.toLocaleLowerCase() ? region.degrees = 90 : "false" == rotateValue.toLocaleLowerCase() ? region.degrees = 0 : region.degrees = parseFloat(rotateValue); + region.rotate = 90 == region.degrees; + reader.readTuple(tuple); + var x = parseInt(tuple[0]); + var y = parseInt(tuple[1]); + reader.readTuple(tuple); + var width = parseInt(tuple[0]); + var height = parseInt(tuple[1]); + region.u = x / page.width; + region.v = y / page.height; + if (region.rotate) { + region.u2 = (x + height) / page.width; + region.v2 = (y + width) / page.height; + } else { + region.u2 = (x + width) / page.width; + region.v2 = (y + height) / page.height; + } + region.x = x; + region.y = y; + region.width = Math.abs(width); + region.height = Math.abs(height); + 4 == reader.readTuple(tuple) && 4 == reader.readTuple(tuple) && reader.readTuple(tuple); + region.originalWidth = parseInt(tuple[0]); + region.originalHeight = parseInt(tuple[1]); + reader.readTuple(tuple); + region.offsetX = parseInt(tuple[0]); + region.offsetY = parseInt(tuple[1]); + region.index = parseInt(reader.readValue()); + region.texture = page.texture; + this.regions.push(region); + } else { + page = new TextureAtlasPage(); + page.name = line; + if (2 == reader.readTuple(tuple)) { + page.width = parseInt(tuple[0]); + page.height = parseInt(tuple[1]); + reader.readTuple(tuple); + } + reader.readTuple(tuple); + page.minFilter = spine.Texture.filterFromString(tuple[0]); + page.magFilter = spine.Texture.filterFromString(tuple[1]); + var direction = reader.readValue(); + page.uWrap = spine.TextureWrap.ClampToEdge; + page.vWrap = spine.TextureWrap.ClampToEdge; + "x" == direction ? page.uWrap = spine.TextureWrap.Repeat : "y" == direction ? page.vWrap = spine.TextureWrap.Repeat : "xy" == direction && (page.uWrap = page.vWrap = spine.TextureWrap.Repeat); + page.texture = textureLoader(line); + page.texture.setFilters(page.minFilter, page.magFilter); + page.texture.setWraps(page.uWrap, page.vWrap); + page.width = page.texture.getImage().width; + page.height = page.texture.getImage().height; + this.pages.push(page); + } + } + }; + TextureAtlas.prototype.findRegion = function(name) { + for (var i = 0; i < this.regions.length; i++) if (this.regions[i].name == name) return this.regions[i]; + return null; + }; + TextureAtlas.prototype.dispose = function() { + for (var i = 0; i < this.pages.length; i++) this.pages[i].texture.dispose(); + }; + return TextureAtlas; + })(); + spine.TextureAtlas = TextureAtlas; + var TextureAtlasReader = (function() { + function TextureAtlasReader(text) { + this.index = 0; + this.lines = text.split(/\r\n|\r|\n/); + } + TextureAtlasReader.prototype.readLine = function() { + if (this.index >= this.lines.length) return null; + return this.lines[this.index++]; + }; + TextureAtlasReader.prototype.readValue = function() { + var line = this.readLine(); + var colon = line.indexOf(":"); + if (-1 == colon) throw new Error("Invalid line: " + line); + return line.substring(colon + 1).trim(); + }; + TextureAtlasReader.prototype.readTuple = function(tuple) { + var line = this.readLine(); + var colon = line.indexOf(":"); + if (-1 == colon) throw new Error("Invalid line: " + line); + var i = 0, lastMatch = colon + 1; + for (;i < 3; i++) { + var comma = line.indexOf(",", lastMatch); + if (-1 == comma) break; + tuple[i] = line.substr(lastMatch, comma - lastMatch).trim(); + lastMatch = comma + 1; + } + tuple[i] = line.substring(lastMatch).trim(); + return i + 1; + }; + return TextureAtlasReader; + })(); + var TextureAtlasPage = (function() { + function TextureAtlasPage() {} + return TextureAtlasPage; + })(); + spine.TextureAtlasPage = TextureAtlasPage; + var TextureAtlasRegion = (function(_super) { + __extends(TextureAtlasRegion, _super); + function TextureAtlasRegion() { + return null !== _super && _super.apply(this, arguments) || this; + } + return TextureAtlasRegion; + })(spine.TextureRegion); + spine.TextureAtlasRegion = TextureAtlasRegion; + })(spine || (spine = {})); + var spine; + (function(spine) { + var TransformConstraint = (function() { + function TransformConstraint(data, skeleton) { + this.rotateMix = 0; + this.translateMix = 0; + this.scaleMix = 0; + this.shearMix = 0; + this.temp = new spine.Vector2(); + this.active = false; + if (null == data) throw new Error("data cannot be null."); + if (null == skeleton) throw new Error("skeleton cannot be null."); + this.data = data; + this.rotateMix = data.rotateMix; + this.translateMix = data.translateMix; + this.scaleMix = data.scaleMix; + this.shearMix = data.shearMix; + this.bones = new Array(); + for (var i = 0; i < data.bones.length; i++) this.bones.push(skeleton.findBone(data.bones[i].name)); + this.target = skeleton.findBone(data.target.name); + } + TransformConstraint.prototype.isActive = function() { + return this.active; + }; + TransformConstraint.prototype.apply = function() { + this.update(); + }; + TransformConstraint.prototype.update = function() { + this.data.local ? this.data.relative ? this.applyRelativeLocal() : this.applyAbsoluteLocal() : this.data.relative ? this.applyRelativeWorld() : this.applyAbsoluteWorld(); + }; + TransformConstraint.prototype.applyAbsoluteWorld = function() { + var rotateMix = this.rotateMix, translateMix = this.translateMix, scaleMix = this.scaleMix, shearMix = this.shearMix; + var target = this.target; + var ta = target.a, tb = target.b, tc = target.c, td = target.d; + var degRadReflect = ta * td - tb * tc > 0 ? spine.MathUtils.degRad : -spine.MathUtils.degRad; + var offsetRotation = this.data.offsetRotation * degRadReflect; + var offsetShearY = this.data.offsetShearY * degRadReflect; + var bones = this.bones; + for (var i = 0, n = bones.length; i < n; i++) { + var bone = bones[i]; + var modified = false; + if (0 != rotateMix) { + var a = bone.a, b = bone.b, c = bone.c, d = bone.d; + var r = Math.atan2(tc, ta) - Math.atan2(c, a) + offsetRotation; + r > spine.MathUtils.PI ? r -= spine.MathUtils.PI2 : r < -spine.MathUtils.PI && (r += spine.MathUtils.PI2); + r *= rotateMix; + var cos = Math.cos(r), sin = Math.sin(r); + bone.a = cos * a - sin * c; + bone.b = cos * b - sin * d; + bone.c = sin * a + cos * c; + bone.d = sin * b + cos * d; + modified = true; + } + if (0 != translateMix) { + var temp = this.temp; + target.localToWorld(temp.set(this.data.offsetX, this.data.offsetY)); + bone.worldX += (temp.x - bone.worldX) * translateMix; + bone.worldY += (temp.y - bone.worldY) * translateMix; + modified = true; + } + if (scaleMix > 0) { + var s = Math.sqrt(bone.a * bone.a + bone.c * bone.c); + var ts = Math.sqrt(ta * ta + tc * tc); + s > 1e-5 && (s = (s + (ts - s + this.data.offsetScaleX) * scaleMix) / s); + bone.a *= s; + bone.c *= s; + s = Math.sqrt(bone.b * bone.b + bone.d * bone.d); + ts = Math.sqrt(tb * tb + td * td); + s > 1e-5 && (s = (s + (ts - s + this.data.offsetScaleY) * scaleMix) / s); + bone.b *= s; + bone.d *= s; + modified = true; + } + if (shearMix > 0) { + var b = bone.b, d = bone.d; + var by = Math.atan2(d, b); + var r = Math.atan2(td, tb) - Math.atan2(tc, ta) - (by - Math.atan2(bone.c, bone.a)); + r > spine.MathUtils.PI ? r -= spine.MathUtils.PI2 : r < -spine.MathUtils.PI && (r += spine.MathUtils.PI2); + r = by + (r + offsetShearY) * shearMix; + var s = Math.sqrt(b * b + d * d); + bone.b = Math.cos(r) * s; + bone.d = Math.sin(r) * s; + modified = true; + } + modified && (bone.appliedValid = false); + } + }; + TransformConstraint.prototype.applyRelativeWorld = function() { + var rotateMix = this.rotateMix, translateMix = this.translateMix, scaleMix = this.scaleMix, shearMix = this.shearMix; + var target = this.target; + var ta = target.a, tb = target.b, tc = target.c, td = target.d; + var degRadReflect = ta * td - tb * tc > 0 ? spine.MathUtils.degRad : -spine.MathUtils.degRad; + var offsetRotation = this.data.offsetRotation * degRadReflect, offsetShearY = this.data.offsetShearY * degRadReflect; + var bones = this.bones; + for (var i = 0, n = bones.length; i < n; i++) { + var bone = bones[i]; + var modified = false; + if (0 != rotateMix) { + var a = bone.a, b = bone.b, c = bone.c, d = bone.d; + var r = Math.atan2(tc, ta) + offsetRotation; + r > spine.MathUtils.PI ? r -= spine.MathUtils.PI2 : r < -spine.MathUtils.PI && (r += spine.MathUtils.PI2); + r *= rotateMix; + var cos = Math.cos(r), sin = Math.sin(r); + bone.a = cos * a - sin * c; + bone.b = cos * b - sin * d; + bone.c = sin * a + cos * c; + bone.d = sin * b + cos * d; + modified = true; + } + if (0 != translateMix) { + var temp = this.temp; + target.localToWorld(temp.set(this.data.offsetX, this.data.offsetY)); + bone.worldX += temp.x * translateMix; + bone.worldY += temp.y * translateMix; + modified = true; + } + if (scaleMix > 0) { + var s = (Math.sqrt(ta * ta + tc * tc) - 1 + this.data.offsetScaleX) * scaleMix + 1; + bone.a *= s; + bone.c *= s; + s = (Math.sqrt(tb * tb + td * td) - 1 + this.data.offsetScaleY) * scaleMix + 1; + bone.b *= s; + bone.d *= s; + modified = true; + } + if (shearMix > 0) { + var r = Math.atan2(td, tb) - Math.atan2(tc, ta); + r > spine.MathUtils.PI ? r -= spine.MathUtils.PI2 : r < -spine.MathUtils.PI && (r += spine.MathUtils.PI2); + var b = bone.b, d = bone.d; + r = Math.atan2(d, b) + (r - spine.MathUtils.PI / 2 + offsetShearY) * shearMix; + var s = Math.sqrt(b * b + d * d); + bone.b = Math.cos(r) * s; + bone.d = Math.sin(r) * s; + modified = true; + } + modified && (bone.appliedValid = false); + } + }; + TransformConstraint.prototype.applyAbsoluteLocal = function() { + var rotateMix = this.rotateMix, translateMix = this.translateMix, scaleMix = this.scaleMix, shearMix = this.shearMix; + var target = this.target; + target.appliedValid || target.updateAppliedTransform(); + var bones = this.bones; + for (var i = 0, n = bones.length; i < n; i++) { + var bone = bones[i]; + bone.appliedValid || bone.updateAppliedTransform(); + var rotation = bone.arotation; + if (0 != rotateMix) { + var r = target.arotation - rotation + this.data.offsetRotation; + r -= 360 * (16384 - (16384.499999999996 - r / 360 | 0)); + rotation += r * rotateMix; + } + var x = bone.ax, y = bone.ay; + if (0 != translateMix) { + x += (target.ax - x + this.data.offsetX) * translateMix; + y += (target.ay - y + this.data.offsetY) * translateMix; + } + var scaleX = bone.ascaleX, scaleY = bone.ascaleY; + if (0 != scaleMix) { + scaleX > 1e-5 && (scaleX = (scaleX + (target.ascaleX - scaleX + this.data.offsetScaleX) * scaleMix) / scaleX); + scaleY > 1e-5 && (scaleY = (scaleY + (target.ascaleY - scaleY + this.data.offsetScaleY) * scaleMix) / scaleY); + } + var shearY = bone.ashearY; + if (0 != shearMix) { + var r = target.ashearY - shearY + this.data.offsetShearY; + r -= 360 * (16384 - (16384.499999999996 - r / 360 | 0)); + bone.shearY += r * shearMix; + } + bone.updateWorldTransformWith(x, y, rotation, scaleX, scaleY, bone.ashearX, shearY); + } + }; + TransformConstraint.prototype.applyRelativeLocal = function() { + var rotateMix = this.rotateMix, translateMix = this.translateMix, scaleMix = this.scaleMix, shearMix = this.shearMix; + var target = this.target; + target.appliedValid || target.updateAppliedTransform(); + var bones = this.bones; + for (var i = 0, n = bones.length; i < n; i++) { + var bone = bones[i]; + bone.appliedValid || bone.updateAppliedTransform(); + var rotation = bone.arotation; + 0 != rotateMix && (rotation += (target.arotation + this.data.offsetRotation) * rotateMix); + var x = bone.ax, y = bone.ay; + if (0 != translateMix) { + x += (target.ax + this.data.offsetX) * translateMix; + y += (target.ay + this.data.offsetY) * translateMix; + } + var scaleX = bone.ascaleX, scaleY = bone.ascaleY; + if (0 != scaleMix) { + scaleX > 1e-5 && (scaleX *= (target.ascaleX - 1 + this.data.offsetScaleX) * scaleMix + 1); + scaleY > 1e-5 && (scaleY *= (target.ascaleY - 1 + this.data.offsetScaleY) * scaleMix + 1); + } + var shearY = bone.ashearY; + 0 != shearMix && (shearY += (target.ashearY + this.data.offsetShearY) * shearMix); + bone.updateWorldTransformWith(x, y, rotation, scaleX, scaleY, bone.ashearX, shearY); + } + }; + return TransformConstraint; + })(); + spine.TransformConstraint = TransformConstraint; + })(spine || (spine = {})); + var spine; + (function(spine) { + var TransformConstraintData = (function(_super) { + __extends(TransformConstraintData, _super); + function TransformConstraintData(name) { + var _this = _super.call(this, name, 0, false) || this; + _this.bones = new Array(); + _this.rotateMix = 0; + _this.translateMix = 0; + _this.scaleMix = 0; + _this.shearMix = 0; + _this.offsetRotation = 0; + _this.offsetX = 0; + _this.offsetY = 0; + _this.offsetScaleX = 0; + _this.offsetScaleY = 0; + _this.offsetShearY = 0; + _this.relative = false; + _this.local = false; + return _this; + } + return TransformConstraintData; + })(spine.ConstraintData); + spine.TransformConstraintData = TransformConstraintData; + })(spine || (spine = {})); + var spine; + (function(spine) { + var Triangulator = (function() { + function Triangulator() { + this.convexPolygons = new Array(); + this.convexPolygonsIndices = new Array(); + this.indicesArray = new Array(); + this.isConcaveArray = new Array(); + this.triangles = new Array(); + this.polygonPool = new spine.Pool(function() { + return new Array(); + }); + this.polygonIndicesPool = new spine.Pool(function() { + return new Array(); + }); + } + Triangulator.prototype.triangulate = function(verticesArray) { + var vertices = verticesArray; + var vertexCount = verticesArray.length >> 1; + var indices = this.indicesArray; + indices.length = 0; + for (var i = 0; i < vertexCount; i++) indices[i] = i; + var isConcave = this.isConcaveArray; + isConcave.length = 0; + for (var i = 0, n = vertexCount; i < n; ++i) isConcave[i] = Triangulator.isConcave(i, vertexCount, vertices, indices); + var triangles = this.triangles; + triangles.length = 0; + while (vertexCount > 3) { + var previous = vertexCount - 1, i = 0, next = 1; + while (true) { + outer: if (!isConcave[i]) { + var p1 = indices[previous] << 1, p2 = indices[i] << 1, p3 = indices[next] << 1; + var p1x = vertices[p1], p1y = vertices[p1 + 1]; + var p2x = vertices[p2], p2y = vertices[p2 + 1]; + var p3x = vertices[p3], p3y = vertices[p3 + 1]; + for (var ii = (next + 1) % vertexCount; ii != previous; ii = (ii + 1) % vertexCount) { + if (!isConcave[ii]) continue; + var v = indices[ii] << 1; + var vx = vertices[v], vy = vertices[v + 1]; + if (Triangulator.positiveArea(p3x, p3y, p1x, p1y, vx, vy) && Triangulator.positiveArea(p1x, p1y, p2x, p2y, vx, vy) && Triangulator.positiveArea(p2x, p2y, p3x, p3y, vx, vy)) break outer; + } + break; + } + if (0 == next) { + do { + if (!isConcave[i]) break; + i--; + } while (i > 0); + break; + } + previous = i; + i = next; + next = (next + 1) % vertexCount; + } + triangles.push(indices[(vertexCount + i - 1) % vertexCount]); + triangles.push(indices[i]); + triangles.push(indices[(i + 1) % vertexCount]); + indices.splice(i, 1); + isConcave.splice(i, 1); + vertexCount--; + var previousIndex = (vertexCount + i - 1) % vertexCount; + var nextIndex = i == vertexCount ? 0 : i; + isConcave[previousIndex] = Triangulator.isConcave(previousIndex, vertexCount, vertices, indices); + isConcave[nextIndex] = Triangulator.isConcave(nextIndex, vertexCount, vertices, indices); + } + if (3 == vertexCount) { + triangles.push(indices[2]); + triangles.push(indices[0]); + triangles.push(indices[1]); + } + return triangles; + }; + Triangulator.prototype.decompose = function(verticesArray, triangles) { + var vertices = verticesArray; + var convexPolygons = this.convexPolygons; + this.polygonPool.freeAll(convexPolygons); + convexPolygons.length = 0; + var convexPolygonsIndices = this.convexPolygonsIndices; + this.polygonIndicesPool.freeAll(convexPolygonsIndices); + convexPolygonsIndices.length = 0; + var polygonIndices = this.polygonIndicesPool.obtain(); + polygonIndices.length = 0; + var polygon = this.polygonPool.obtain(); + polygon.length = 0; + var fanBaseIndex = -1, lastWinding = 0; + for (var i = 0, n = triangles.length; i < n; i += 3) { + var t1 = triangles[i] << 1, t2 = triangles[i + 1] << 1, t3 = triangles[i + 2] << 1; + var x1 = vertices[t1], y1 = vertices[t1 + 1]; + var x2 = vertices[t2], y2 = vertices[t2 + 1]; + var x3 = vertices[t3], y3 = vertices[t3 + 1]; + var merged = false; + if (fanBaseIndex == t1) { + var o = polygon.length - 4; + var winding1 = Triangulator.winding(polygon[o], polygon[o + 1], polygon[o + 2], polygon[o + 3], x3, y3); + var winding2 = Triangulator.winding(x3, y3, polygon[0], polygon[1], polygon[2], polygon[3]); + if (winding1 == lastWinding && winding2 == lastWinding) { + polygon.push(x3); + polygon.push(y3); + polygonIndices.push(t3); + merged = true; + } + } + if (!merged) { + if (polygon.length > 0) { + convexPolygons.push(polygon); + convexPolygonsIndices.push(polygonIndices); + } else { + this.polygonPool.free(polygon); + this.polygonIndicesPool.free(polygonIndices); + } + polygon = this.polygonPool.obtain(); + polygon.length = 0; + polygon.push(x1); + polygon.push(y1); + polygon.push(x2); + polygon.push(y2); + polygon.push(x3); + polygon.push(y3); + polygonIndices = this.polygonIndicesPool.obtain(); + polygonIndices.length = 0; + polygonIndices.push(t1); + polygonIndices.push(t2); + polygonIndices.push(t3); + lastWinding = Triangulator.winding(x1, y1, x2, y2, x3, y3); + fanBaseIndex = t1; + } + } + if (polygon.length > 0) { + convexPolygons.push(polygon); + convexPolygonsIndices.push(polygonIndices); + } + for (var i = 0, n = convexPolygons.length; i < n; i++) { + polygonIndices = convexPolygonsIndices[i]; + if (0 == polygonIndices.length) continue; + var firstIndex = polygonIndices[0]; + var lastIndex = polygonIndices[polygonIndices.length - 1]; + polygon = convexPolygons[i]; + var o = polygon.length - 4; + var prevPrevX = polygon[o], prevPrevY = polygon[o + 1]; + var prevX = polygon[o + 2], prevY = polygon[o + 3]; + var firstX = polygon[0], firstY = polygon[1]; + var secondX = polygon[2], secondY = polygon[3]; + var winding = Triangulator.winding(prevPrevX, prevPrevY, prevX, prevY, firstX, firstY); + for (var ii = 0; ii < n; ii++) { + if (ii == i) continue; + var otherIndices = convexPolygonsIndices[ii]; + if (3 != otherIndices.length) continue; + var otherFirstIndex = otherIndices[0]; + var otherSecondIndex = otherIndices[1]; + var otherLastIndex = otherIndices[2]; + var otherPoly = convexPolygons[ii]; + var x3 = otherPoly[otherPoly.length - 2], y3 = otherPoly[otherPoly.length - 1]; + if (otherFirstIndex != firstIndex || otherSecondIndex != lastIndex) continue; + var winding1 = Triangulator.winding(prevPrevX, prevPrevY, prevX, prevY, x3, y3); + var winding2 = Triangulator.winding(x3, y3, firstX, firstY, secondX, secondY); + if (winding1 == winding && winding2 == winding) { + otherPoly.length = 0; + otherIndices.length = 0; + polygon.push(x3); + polygon.push(y3); + polygonIndices.push(otherLastIndex); + prevPrevX = prevX; + prevPrevY = prevY; + prevX = x3; + prevY = y3; + ii = 0; + } + } + } + for (var i = convexPolygons.length - 1; i >= 0; i--) { + polygon = convexPolygons[i]; + if (0 == polygon.length) { + convexPolygons.splice(i, 1); + this.polygonPool.free(polygon); + polygonIndices = convexPolygonsIndices[i]; + convexPolygonsIndices.splice(i, 1); + this.polygonIndicesPool.free(polygonIndices); + } + } + return convexPolygons; + }; + Triangulator.isConcave = function(index, vertexCount, vertices, indices) { + var previous = indices[(vertexCount + index - 1) % vertexCount] << 1; + var current = indices[index] << 1; + var next = indices[(index + 1) % vertexCount] << 1; + return !this.positiveArea(vertices[previous], vertices[previous + 1], vertices[current], vertices[current + 1], vertices[next], vertices[next + 1]); + }; + Triangulator.positiveArea = function(p1x, p1y, p2x, p2y, p3x, p3y) { + return p1x * (p3y - p2y) + p2x * (p1y - p3y) + p3x * (p2y - p1y) >= 0; + }; + Triangulator.winding = function(p1x, p1y, p2x, p2y, p3x, p3y) { + var px = p2x - p1x, py = p2y - p1y; + return p3x * py - p3y * px + px * p1y - p1x * py >= 0 ? 1 : -1; + }; + return Triangulator; + })(); + spine.Triangulator = Triangulator; + })(spine || (spine = {})); + var spine; + (function(spine) { + var IntSet = (function() { + function IntSet() { + this.array = new Array(); + } + IntSet.prototype.add = function(value) { + var contains = this.contains(value); + this.array[0 | value] = 0 | value; + return !contains; + }; + IntSet.prototype.contains = function(value) { + return void 0 != this.array[0 | value]; + }; + IntSet.prototype.remove = function(value) { + this.array[0 | value] = void 0; + }; + IntSet.prototype.clear = function() { + this.array.length = 0; + }; + return IntSet; + })(); + spine.IntSet = IntSet; + var Color = (function() { + function Color(r, g, b, a) { + void 0 === r && (r = 0); + void 0 === g && (g = 0); + void 0 === b && (b = 0); + void 0 === a && (a = 0); + this.r = r; + this.g = g; + this.b = b; + this.a = a; + } + Color.prototype.set = function(r, g, b, a) { + this.r = r; + this.g = g; + this.b = b; + this.a = a; + this.clamp(); + return this; + }; + Color.prototype.setFromColor = function(c) { + this.r = c.r; + this.g = c.g; + this.b = c.b; + this.a = c.a; + return this; + }; + Color.prototype.setFromString = function(hex) { + hex = "#" == hex.charAt(0) ? hex.substr(1) : hex; + this.r = parseInt(hex.substr(0, 2), 16) / 255; + this.g = parseInt(hex.substr(2, 2), 16) / 255; + this.b = parseInt(hex.substr(4, 2), 16) / 255; + this.a = (8 != hex.length ? 255 : parseInt(hex.substr(6, 2), 16)) / 255; + return this; + }; + Color.prototype.add = function(r, g, b, a) { + this.r += r; + this.g += g; + this.b += b; + this.a += a; + this.clamp(); + return this; + }; + Color.prototype.clamp = function() { + this.r < 0 ? this.r = 0 : this.r > 1 && (this.r = 1); + this.g < 0 ? this.g = 0 : this.g > 1 && (this.g = 1); + this.b < 0 ? this.b = 0 : this.b > 1 && (this.b = 1); + this.a < 0 ? this.a = 0 : this.a > 1 && (this.a = 1); + return this; + }; + Color.rgba8888ToColor = function(color, value) { + color.r = ((4278190080 & value) >>> 24) / 255; + color.g = ((16711680 & value) >>> 16) / 255; + color.b = ((65280 & value) >>> 8) / 255; + color.a = (255 & value) / 255; + }; + Color.rgb888ToColor = function(color, value) { + color.r = ((16711680 & value) >>> 16) / 255; + color.g = ((65280 & value) >>> 8) / 255; + color.b = (255 & value) / 255; + }; + Color.WHITE = new Color(1, 1, 1, 1); + Color.RED = new Color(1, 0, 0, 1); + Color.GREEN = new Color(0, 1, 0, 1); + Color.BLUE = new Color(0, 0, 1, 1); + Color.MAGENTA = new Color(1, 0, 1, 1); + return Color; + })(); + spine.Color = Color; + var MathUtils = (function() { + function MathUtils() {} + MathUtils.clamp = function(value, min, max) { + if (value < min) return min; + if (value > max) return max; + return value; + }; + MathUtils.cosDeg = function(degrees) { + return Math.cos(degrees * MathUtils.degRad); + }; + MathUtils.sinDeg = function(degrees) { + return Math.sin(degrees * MathUtils.degRad); + }; + MathUtils.signum = function(value) { + return value > 0 ? 1 : value < 0 ? -1 : 0; + }; + MathUtils.toInt = function(x) { + return x > 0 ? Math.floor(x) : Math.ceil(x); + }; + MathUtils.cbrt = function(x) { + var y = Math.pow(Math.abs(x), 1 / 3); + return x < 0 ? -y : y; + }; + MathUtils.randomTriangular = function(min, max) { + return MathUtils.randomTriangularWith(min, max, .5 * (min + max)); + }; + MathUtils.randomTriangularWith = function(min, max, mode) { + var u = Math.random(); + var d = max - min; + if (u <= (mode - min) / d) return min + Math.sqrt(u * d * (mode - min)); + return max - Math.sqrt((1 - u) * d * (max - mode)); + }; + MathUtils.PI = 3.1415927; + MathUtils.PI2 = 2 * MathUtils.PI; + MathUtils.radiansToDegrees = 180 / MathUtils.PI; + MathUtils.radDeg = MathUtils.radiansToDegrees; + MathUtils.degreesToRadians = MathUtils.PI / 180; + MathUtils.degRad = MathUtils.degreesToRadians; + return MathUtils; + })(); + spine.MathUtils = MathUtils; + var Interpolation = (function() { + function Interpolation() {} + Interpolation.prototype.apply = function(start, end, a) { + return start + (end - start) * this.applyInternal(a); + }; + return Interpolation; + })(); + spine.Interpolation = Interpolation; + var Pow = (function(_super) { + __extends(Pow, _super); + function Pow(power) { + var _this = _super.call(this) || this; + _this.power = 2; + _this.power = power; + return _this; + } + Pow.prototype.applyInternal = function(a) { + if (a <= .5) return Math.pow(2 * a, this.power) / 2; + return Math.pow(2 * (a - 1), this.power) / (this.power % 2 == 0 ? -2 : 2) + 1; + }; + return Pow; + })(Interpolation); + spine.Pow = Pow; + var PowOut = (function(_super) { + __extends(PowOut, _super); + function PowOut(power) { + return _super.call(this, power) || this; + } + PowOut.prototype.applyInternal = function(a) { + return Math.pow(a - 1, this.power) * (this.power % 2 == 0 ? -1 : 1) + 1; + }; + return PowOut; + })(Pow); + spine.PowOut = PowOut; + var Utils = (function() { + function Utils() {} + Utils.arrayCopy = function(source, sourceStart, dest, destStart, numElements) { + for (var i = sourceStart, j = destStart; i < sourceStart + numElements; i++, j++) dest[j] = source[i]; + }; + Utils.setArraySize = function(array, size, value) { + void 0 === value && (value = 0); + var oldSize = array.length; + if (oldSize == size) return array; + array.length = size; + if (oldSize < size) for (var i = oldSize; i < size; i++) array[i] = value; + return array; + }; + Utils.ensureArrayCapacity = function(array, size, value) { + void 0 === value && (value = 0); + if (array.length >= size) return array; + return Utils.setArraySize(array, size, value); + }; + Utils.newArray = function(size, defaultValue) { + var array = new Array(size); + for (var i = 0; i < size; i++) array[i] = defaultValue; + return array; + }; + Utils.newFloatArray = function(size) { + if (Utils.SUPPORTS_TYPED_ARRAYS) return new Float32Array(size); + var array = new Array(size); + for (var i = 0; i < array.length; i++) array[i] = 0; + return array; + }; + Utils.newShortArray = function(size) { + if (Utils.SUPPORTS_TYPED_ARRAYS) return new Int16Array(size); + var array = new Array(size); + for (var i = 0; i < array.length; i++) array[i] = 0; + return array; + }; + Utils.toFloatArray = function(array) { + return Utils.SUPPORTS_TYPED_ARRAYS ? new Float32Array(array) : array; + }; + Utils.toSinglePrecision = function(value) { + return Utils.SUPPORTS_TYPED_ARRAYS ? Math.fround(value) : value; + }; + Utils.webkit602BugfixHelper = function(alpha, blend) {}; + Utils.contains = function(array, element, identity) { + void 0 === identity && (identity = true); + for (var i = 0; i < array.length; i++) if (array[i] == element) return true; + return false; + }; + Utils.SUPPORTS_TYPED_ARRAYS = "undefined" !== typeof Float32Array; + return Utils; + })(); + spine.Utils = Utils; + var DebugUtils = (function() { + function DebugUtils() {} + DebugUtils.logBones = function(skeleton) { + for (var i = 0; i < skeleton.bones.length; i++) { + var bone = skeleton.bones[i]; + console.log(bone.data.name + ", " + bone.a + ", " + bone.b + ", " + bone.c + ", " + bone.d + ", " + bone.worldX + ", " + bone.worldY); + } + }; + return DebugUtils; + })(); + spine.DebugUtils = DebugUtils; + var Pool = (function() { + function Pool(instantiator) { + this.items = new Array(); + this.instantiator = instantiator; + } + Pool.prototype.obtain = function() { + return this.items.length > 0 ? this.items.pop() : this.instantiator(); + }; + Pool.prototype.free = function(item) { + item.reset && item.reset(); + this.items.push(item); + }; + Pool.prototype.freeAll = function(items) { + for (var i = 0; i < items.length; i++) { + items[i].reset && items[i].reset(); + this.items[i] = items[i]; + } + }; + Pool.prototype.clear = function() { + this.items.length = 0; + }; + return Pool; + })(); + spine.Pool = Pool; + var Vector2 = (function() { + function Vector2(x, y) { + void 0 === x && (x = 0); + void 0 === y && (y = 0); + this.x = x; + this.y = y; + } + Vector2.prototype.set = function(x, y) { + this.x = x; + this.y = y; + return this; + }; + Vector2.prototype.length = function() { + var x = this.x; + var y = this.y; + return Math.sqrt(x * x + y * y); + }; + Vector2.prototype.normalize = function() { + var len = this.length(); + if (0 != len) { + this.x /= len; + this.y /= len; + } + return this; + }; + return Vector2; + })(); + spine.Vector2 = Vector2; + var TimeKeeper = (function() { + function TimeKeeper() { + this.maxDelta = .064; + this.framesPerSecond = 0; + this.delta = 0; + this.totalTime = 0; + this.lastTime = Date.now() / 1e3; + this.frameCount = 0; + this.frameTime = 0; + } + TimeKeeper.prototype.update = function() { + var now = Date.now() / 1e3; + this.delta = now - this.lastTime; + this.frameTime += this.delta; + this.totalTime += this.delta; + this.delta > this.maxDelta && (this.delta = this.maxDelta); + this.lastTime = now; + this.frameCount++; + if (this.frameTime > 1) { + this.framesPerSecond = this.frameCount / this.frameTime; + this.frameTime = 0; + this.frameCount = 0; + } + }; + return TimeKeeper; + })(); + spine.TimeKeeper = TimeKeeper; + var WindowedMean = (function() { + function WindowedMean(windowSize) { + void 0 === windowSize && (windowSize = 32); + this.addedValues = 0; + this.lastValue = 0; + this.mean = 0; + this.dirty = true; + this.values = new Array(windowSize); + } + WindowedMean.prototype.hasEnoughData = function() { + return this.addedValues >= this.values.length; + }; + WindowedMean.prototype.addValue = function(value) { + this.addedValues < this.values.length && this.addedValues++; + this.values[this.lastValue++] = value; + this.lastValue > this.values.length - 1 && (this.lastValue = 0); + this.dirty = true; + }; + WindowedMean.prototype.getMean = function() { + if (this.hasEnoughData()) { + if (this.dirty) { + var mean = 0; + for (var i = 0; i < this.values.length; i++) mean += this.values[i]; + this.mean = mean / this.values.length; + this.dirty = false; + } + return this.mean; + } + return 0; + }; + return WindowedMean; + })(); + spine.WindowedMean = WindowedMean; + })(spine || (spine = {})); + (function() { + Math.fround || (Math.fround = (function(array) { + return function(x) { + return array[0] = x, array[0]; + }; + })(new Float32Array(1))); + })(); + var spine; + (function(spine) { + var Attachment = (function() { + function Attachment(name) { + if (null == name) throw new Error("name cannot be null."); + this.name = name; + } + return Attachment; + })(); + spine.Attachment = Attachment; + var VertexAttachment = (function(_super) { + __extends(VertexAttachment, _super); + function VertexAttachment(name) { + var _this = _super.call(this, name) || this; + _this.id = (65535 & VertexAttachment.nextID++) << 11; + _this.worldVerticesLength = 0; + _this.deformAttachment = _this; + return _this; + } + VertexAttachment.prototype.computeWorldVertices = function(slot, start, count, worldVertices, offset, stride) { + count = offset + (count >> 1) * stride; + var skeleton = slot.bone.skeleton; + var deformArray = slot.deform; + var vertices = this.vertices; + var bones = this.bones; + if (null == bones) { + deformArray.length > 0 && (vertices = deformArray); + var bone = slot.bone; + var x = bone.worldX; + var y = bone.worldY; + var a = bone.a, b = bone.b, c = bone.c, d = bone.d; + for (var v_1 = start, w = offset; w < count; v_1 += 2, w += stride) { + var vx = vertices[v_1], vy = vertices[v_1 + 1]; + worldVertices[w] = vx * a + vy * b + x; + worldVertices[w + 1] = vx * c + vy * d + y; + } + return; + } + var v = 0, skip = 0; + for (var i = 0; i < start; i += 2) { + var n = bones[v]; + v += n + 1; + skip += n; + } + var skeletonBones = skeleton.bones; + if (0 == deformArray.length) for (var w = offset, b = 3 * skip; w < count; w += stride) { + var wx = 0, wy = 0; + var n = bones[v++]; + n += v; + for (;v < n; v++, b += 3) { + var bone = skeletonBones[bones[v]]; + var vx = vertices[b], vy = vertices[b + 1], weight = vertices[b + 2]; + wx += (vx * bone.a + vy * bone.b + bone.worldX) * weight; + wy += (vx * bone.c + vy * bone.d + bone.worldY) * weight; + } + worldVertices[w] = wx; + worldVertices[w + 1] = wy; + } else { + var deform = deformArray; + for (var w = offset, b = 3 * skip, f = skip << 1; w < count; w += stride) { + var wx = 0, wy = 0; + var n = bones[v++]; + n += v; + for (;v < n; v++, b += 3, f += 2) { + var bone = skeletonBones[bones[v]]; + var vx = vertices[b] + deform[f], vy = vertices[b + 1] + deform[f + 1], weight = vertices[b + 2]; + wx += (vx * bone.a + vy * bone.b + bone.worldX) * weight; + wy += (vx * bone.c + vy * bone.d + bone.worldY) * weight; + } + worldVertices[w] = wx; + worldVertices[w + 1] = wy; + } + } + }; + VertexAttachment.prototype.copyTo = function(attachment) { + if (null != this.bones) { + attachment.bones = new Array(this.bones.length); + spine.Utils.arrayCopy(this.bones, 0, attachment.bones, 0, this.bones.length); + } else attachment.bones = null; + if (null != this.vertices) { + attachment.vertices = spine.Utils.newFloatArray(this.vertices.length); + spine.Utils.arrayCopy(this.vertices, 0, attachment.vertices, 0, this.vertices.length); + } else attachment.vertices = null; + attachment.worldVerticesLength = this.worldVerticesLength; + attachment.deformAttachment = this.deformAttachment; + }; + VertexAttachment.nextID = 0; + return VertexAttachment; + })(Attachment); + spine.VertexAttachment = VertexAttachment; + })(spine || (spine = {})); + var spine; + (function(spine) { + var AttachmentType; + (function(AttachmentType) { + AttachmentType[AttachmentType["Region"] = 0] = "Region"; + AttachmentType[AttachmentType["BoundingBox"] = 1] = "BoundingBox"; + AttachmentType[AttachmentType["Mesh"] = 2] = "Mesh"; + AttachmentType[AttachmentType["LinkedMesh"] = 3] = "LinkedMesh"; + AttachmentType[AttachmentType["Path"] = 4] = "Path"; + AttachmentType[AttachmentType["Point"] = 5] = "Point"; + AttachmentType[AttachmentType["Clipping"] = 6] = "Clipping"; + })(AttachmentType = spine.AttachmentType || (spine.AttachmentType = {})); + })(spine || (spine = {})); + var spine; + (function(spine) { + var BoundingBoxAttachment = (function(_super) { + __extends(BoundingBoxAttachment, _super); + function BoundingBoxAttachment(name) { + var _this = _super.call(this, name) || this; + _this.color = new spine.Color(1, 1, 1, 1); + return _this; + } + BoundingBoxAttachment.prototype.copy = function() { + var copy = new BoundingBoxAttachment(name); + this.copyTo(copy); + copy.color.setFromColor(this.color); + return copy; + }; + return BoundingBoxAttachment; + })(spine.VertexAttachment); + spine.BoundingBoxAttachment = BoundingBoxAttachment; + })(spine || (spine = {})); + var spine; + (function(spine) { + var ClippingAttachment = (function(_super) { + __extends(ClippingAttachment, _super); + function ClippingAttachment(name) { + var _this = _super.call(this, name) || this; + _this.color = new spine.Color(.2275, .2275, .8078, 1); + return _this; + } + ClippingAttachment.prototype.copy = function() { + var copy = new ClippingAttachment(name); + this.copyTo(copy); + copy.endSlot = this.endSlot; + copy.color.setFromColor(this.color); + return copy; + }; + return ClippingAttachment; + })(spine.VertexAttachment); + spine.ClippingAttachment = ClippingAttachment; + })(spine || (spine = {})); + var spine; + (function(spine) { + var MeshAttachment = (function(_super) { + __extends(MeshAttachment, _super); + function MeshAttachment(name) { + var _this = _super.call(this, name) || this; + _this.color = new spine.Color(1, 1, 1, 1); + _this.tempColor = new spine.Color(0, 0, 0, 0); + return _this; + } + MeshAttachment.prototype.updateUVs = function() { + var regionUVs = this.regionUVs; + null != this.uvs && this.uvs.length == regionUVs.length || (this.uvs = spine.Utils.newFloatArray(regionUVs.length)); + var uvs = this.uvs; + var n = this.uvs.length; + var u = this.region.u, v = this.region.v, width = 0, height = 0; + if (this.region instanceof spine.TextureAtlasRegion) { + var region = this.region; + var textureWidth = region.texture.getImage().width, textureHeight = region.texture.getImage().height; + switch (region.degrees) { + case 90: + u -= (region.originalHeight - region.offsetY - region.height) / textureWidth; + v -= (region.originalWidth - region.offsetX - region.width) / textureHeight; + width = region.originalHeight / textureWidth; + height = region.originalWidth / textureHeight; + for (var i = 0; i < n; i += 2) { + uvs[i] = u + regionUVs[i + 1] * width; + uvs[i + 1] = v + (1 - regionUVs[i]) * height; + } + return; + + case 180: + u -= (region.originalWidth - region.offsetX - region.width) / textureWidth; + v -= region.offsetY / textureHeight; + width = region.originalWidth / textureWidth; + height = region.originalHeight / textureHeight; + for (var i = 0; i < n; i += 2) { + uvs[i] = u + (1 - regionUVs[i]) * width; + uvs[i + 1] = v + (1 - regionUVs[i + 1]) * height; + } + return; + + case 270: + u -= region.offsetY / textureWidth; + v -= region.offsetX / textureHeight; + width = region.originalHeight / textureWidth; + height = region.originalWidth / textureHeight; + for (var i = 0; i < n; i += 2) { + uvs[i] = u + (1 - regionUVs[i + 1]) * width; + uvs[i + 1] = v + regionUVs[i] * height; + } + return; + } + u -= region.offsetX / textureWidth; + v -= (region.originalHeight - region.offsetY - region.height) / textureHeight; + width = region.originalWidth / textureWidth; + height = region.originalHeight / textureHeight; + } else if (null == this.region) { + u = v = 0; + width = height = 1; + } else { + width = this.region.u2 - u; + height = this.region.v2 - v; + } + for (var i = 0; i < n; i += 2) { + uvs[i] = u + regionUVs[i] * width; + uvs[i + 1] = v + regionUVs[i + 1] * height; + } + }; + MeshAttachment.prototype.getParentMesh = function() { + return this.parentMesh; + }; + MeshAttachment.prototype.setParentMesh = function(parentMesh) { + this.parentMesh = parentMesh; + if (null != parentMesh) { + this.bones = parentMesh.bones; + this.vertices = parentMesh.vertices; + this.worldVerticesLength = parentMesh.worldVerticesLength; + this.regionUVs = parentMesh.regionUVs; + this.triangles = parentMesh.triangles; + this.hullLength = parentMesh.hullLength; + this.worldVerticesLength = parentMesh.worldVerticesLength; + } + }; + MeshAttachment.prototype.copy = function() { + if (null != this.parentMesh) return this.newLinkedMesh(); + var copy = new MeshAttachment(this.name); + copy.region = this.region; + copy.path = this.path; + copy.color.setFromColor(this.color); + this.copyTo(copy); + copy.regionUVs = new Array(this.regionUVs.length); + spine.Utils.arrayCopy(this.regionUVs, 0, copy.regionUVs, 0, this.regionUVs.length); + copy.uvs = new Array(this.uvs.length); + spine.Utils.arrayCopy(this.uvs, 0, copy.uvs, 0, this.uvs.length); + copy.triangles = new Array(this.triangles.length); + spine.Utils.arrayCopy(this.triangles, 0, copy.triangles, 0, this.triangles.length); + copy.hullLength = this.hullLength; + if (null != this.edges) { + copy.edges = new Array(this.edges.length); + spine.Utils.arrayCopy(this.edges, 0, copy.edges, 0, this.edges.length); + } + copy.width = this.width; + copy.height = this.height; + return copy; + }; + MeshAttachment.prototype.newLinkedMesh = function() { + var copy = new MeshAttachment(this.name); + copy.region = this.region; + copy.path = this.path; + copy.color.setFromColor(this.color); + copy.deformAttachment = this.deformAttachment; + copy.setParentMesh(null != this.parentMesh ? this.parentMesh : this); + copy.updateUVs(); + return copy; + }; + return MeshAttachment; + })(spine.VertexAttachment); + spine.MeshAttachment = MeshAttachment; + })(spine || (spine = {})); + var spine; + (function(spine) { + var PathAttachment = (function(_super) { + __extends(PathAttachment, _super); + function PathAttachment(name) { + var _this = _super.call(this, name) || this; + _this.closed = false; + _this.constantSpeed = false; + _this.color = new spine.Color(1, 1, 1, 1); + return _this; + } + PathAttachment.prototype.copy = function() { + var copy = new PathAttachment(name); + this.copyTo(copy); + copy.lengths = new Array(this.lengths.length); + spine.Utils.arrayCopy(this.lengths, 0, copy.lengths, 0, this.lengths.length); + copy.closed = closed; + copy.constantSpeed = this.constantSpeed; + copy.color.setFromColor(this.color); + return copy; + }; + return PathAttachment; + })(spine.VertexAttachment); + spine.PathAttachment = PathAttachment; + })(spine || (spine = {})); + var spine; + (function(spine) { + var PointAttachment = (function(_super) { + __extends(PointAttachment, _super); + function PointAttachment(name) { + var _this = _super.call(this, name) || this; + _this.color = new spine.Color(.38, .94, 0, 1); + return _this; + } + PointAttachment.prototype.computeWorldPosition = function(bone, point) { + point.x = this.x * bone.a + this.y * bone.b + bone.worldX; + point.y = this.x * bone.c + this.y * bone.d + bone.worldY; + return point; + }; + PointAttachment.prototype.computeWorldRotation = function(bone) { + var cos = spine.MathUtils.cosDeg(this.rotation), sin = spine.MathUtils.sinDeg(this.rotation); + var x = cos * bone.a + sin * bone.b; + var y = cos * bone.c + sin * bone.d; + return Math.atan2(y, x) * spine.MathUtils.radDeg; + }; + PointAttachment.prototype.copy = function() { + var copy = new PointAttachment(name); + copy.x = this.x; + copy.y = this.y; + copy.rotation = this.rotation; + copy.color.setFromColor(this.color); + return copy; + }; + return PointAttachment; + })(spine.VertexAttachment); + spine.PointAttachment = PointAttachment; + })(spine || (spine = {})); + var spine; + (function(spine) { + var RegionAttachment = (function(_super) { + __extends(RegionAttachment, _super); + function RegionAttachment(name) { + var _this = _super.call(this, name) || this; + _this.x = 0; + _this.y = 0; + _this.scaleX = 1; + _this.scaleY = 1; + _this.rotation = 0; + _this.width = 0; + _this.height = 0; + _this.color = new spine.Color(1, 1, 1, 1); + _this.offset = spine.Utils.newFloatArray(8); + _this.uvs = spine.Utils.newFloatArray(8); + _this.tempColor = new spine.Color(1, 1, 1, 1); + return _this; + } + RegionAttachment.prototype.updateOffset = function() { + var regionScaleX = this.width / this.region.originalWidth * this.scaleX; + var regionScaleY = this.height / this.region.originalHeight * this.scaleY; + var localX = -this.width / 2 * this.scaleX + this.region.offsetX * regionScaleX; + var localY = -this.height / 2 * this.scaleY + this.region.offsetY * regionScaleY; + var localX2 = localX + this.region.width * regionScaleX; + var localY2 = localY + this.region.height * regionScaleY; + var radians = this.rotation * Math.PI / 180; + var cos = Math.cos(radians); + var sin = Math.sin(radians); + var localXCos = localX * cos + this.x; + var localXSin = localX * sin; + var localYCos = localY * cos + this.y; + var localYSin = localY * sin; + var localX2Cos = localX2 * cos + this.x; + var localX2Sin = localX2 * sin; + var localY2Cos = localY2 * cos + this.y; + var localY2Sin = localY2 * sin; + var offset = this.offset; + offset[RegionAttachment.OX1] = localXCos - localYSin; + offset[RegionAttachment.OY1] = localYCos + localXSin; + offset[RegionAttachment.OX2] = localXCos - localY2Sin; + offset[RegionAttachment.OY2] = localY2Cos + localXSin; + offset[RegionAttachment.OX3] = localX2Cos - localY2Sin; + offset[RegionAttachment.OY3] = localY2Cos + localX2Sin; + offset[RegionAttachment.OX4] = localX2Cos - localYSin; + offset[RegionAttachment.OY4] = localYCos + localX2Sin; + }; + RegionAttachment.prototype.setRegion = function(region) { + this.region = region; + var uvs = this.uvs; + if (region.rotate) { + uvs[2] = region.u; + uvs[3] = region.v2; + uvs[4] = region.u; + uvs[5] = region.v; + uvs[6] = region.u2; + uvs[7] = region.v; + uvs[0] = region.u2; + uvs[1] = region.v2; + } else { + uvs[0] = region.u; + uvs[1] = region.v2; + uvs[2] = region.u; + uvs[3] = region.v; + uvs[4] = region.u2; + uvs[5] = region.v; + uvs[6] = region.u2; + uvs[7] = region.v2; + } + }; + RegionAttachment.prototype.computeWorldVertices = function(bone, worldVertices, offset, stride) { + var vertexOffset = this.offset; + var x = bone.worldX, y = bone.worldY; + var a = bone.a, b = bone.b, c = bone.c, d = bone.d; + var offsetX = 0, offsetY = 0; + offsetX = vertexOffset[RegionAttachment.OX1]; + offsetY = vertexOffset[RegionAttachment.OY1]; + worldVertices[offset] = offsetX * a + offsetY * b + x; + worldVertices[offset + 1] = offsetX * c + offsetY * d + y; + offset += stride; + offsetX = vertexOffset[RegionAttachment.OX2]; + offsetY = vertexOffset[RegionAttachment.OY2]; + worldVertices[offset] = offsetX * a + offsetY * b + x; + worldVertices[offset + 1] = offsetX * c + offsetY * d + y; + offset += stride; + offsetX = vertexOffset[RegionAttachment.OX3]; + offsetY = vertexOffset[RegionAttachment.OY3]; + worldVertices[offset] = offsetX * a + offsetY * b + x; + worldVertices[offset + 1] = offsetX * c + offsetY * d + y; + offset += stride; + offsetX = vertexOffset[RegionAttachment.OX4]; + offsetY = vertexOffset[RegionAttachment.OY4]; + worldVertices[offset] = offsetX * a + offsetY * b + x; + worldVertices[offset + 1] = offsetX * c + offsetY * d + y; + }; + RegionAttachment.prototype.copy = function() { + var copy = new RegionAttachment(name); + copy.region = this.region; + copy.rendererObject = this.rendererObject; + copy.path = this.path; + copy.x = this.x; + copy.y = this.y; + copy.scaleX = this.scaleX; + copy.scaleY = this.scaleY; + copy.rotation = this.rotation; + copy.width = this.width; + copy.height = this.height; + spine.Utils.arrayCopy(this.uvs, 0, copy.uvs, 0, 8); + spine.Utils.arrayCopy(this.offset, 0, copy.offset, 0, 8); + copy.color.setFromColor(this.color); + return copy; + }; + RegionAttachment.OX1 = 0; + RegionAttachment.OY1 = 1; + RegionAttachment.OX2 = 2; + RegionAttachment.OY2 = 3; + RegionAttachment.OX3 = 4; + RegionAttachment.OY3 = 5; + RegionAttachment.OX4 = 6; + RegionAttachment.OY4 = 7; + RegionAttachment.X1 = 0; + RegionAttachment.Y1 = 1; + RegionAttachment.C1R = 2; + RegionAttachment.C1G = 3; + RegionAttachment.C1B = 4; + RegionAttachment.C1A = 5; + RegionAttachment.U1 = 6; + RegionAttachment.V1 = 7; + RegionAttachment.X2 = 8; + RegionAttachment.Y2 = 9; + RegionAttachment.C2R = 10; + RegionAttachment.C2G = 11; + RegionAttachment.C2B = 12; + RegionAttachment.C2A = 13; + RegionAttachment.U2 = 14; + RegionAttachment.V2 = 15; + RegionAttachment.X3 = 16; + RegionAttachment.Y3 = 17; + RegionAttachment.C3R = 18; + RegionAttachment.C3G = 19; + RegionAttachment.C3B = 20; + RegionAttachment.C3A = 21; + RegionAttachment.U3 = 22; + RegionAttachment.V3 = 23; + RegionAttachment.X4 = 24; + RegionAttachment.Y4 = 25; + RegionAttachment.C4R = 26; + RegionAttachment.C4G = 27; + RegionAttachment.C4B = 28; + RegionAttachment.C4A = 29; + RegionAttachment.U4 = 30; + RegionAttachment.V4 = 31; + return RegionAttachment; + })(spine.Attachment); + spine.RegionAttachment = RegionAttachment; + })(spine || (spine = {})); + var spine; + (function(spine) { + var JitterEffect = (function() { + function JitterEffect(jitterX, jitterY) { + this.jitterX = 0; + this.jitterY = 0; + this.jitterX = jitterX; + this.jitterY = jitterY; + } + JitterEffect.prototype.begin = function(skeleton) {}; + JitterEffect.prototype.transform = function(position, uv, light, dark) { + position.x += spine.MathUtils.randomTriangular(-this.jitterX, this.jitterY); + position.y += spine.MathUtils.randomTriangular(-this.jitterX, this.jitterY); + }; + JitterEffect.prototype.end = function() {}; + return JitterEffect; + })(); + spine.JitterEffect = JitterEffect; + })(spine || (spine = {})); + var spine; + (function(spine) { + var SwirlEffect = (function() { + function SwirlEffect(radius, interpolation) { + this.centerX = 0; + this.centerY = 0; + this.radius = 0; + this.angle = 0; + this.worldX = 0; + this.worldY = 0; + this.radius = radius; + this.interpolation = interpolation; + } + SwirlEffect.prototype.begin = function(skeleton) { + this.worldX = skeleton.x + this.centerX; + this.worldY = skeleton.y + this.centerY; + }; + SwirlEffect.prototype.transform = function(position, uv, light, dark) { + var radAngle = this.angle * spine.MathUtils.degreesToRadians; + var x = position.x - this.worldX; + var y = position.y - this.worldY; + var dist = Math.sqrt(x * x + y * y); + if (dist < this.radius) { + var theta = this.interpolation.apply(0, radAngle, (this.radius - dist) / this.radius); + var cos = Math.cos(theta); + var sin = Math.sin(theta); + position.x = cos * x - sin * y + this.worldX; + position.y = sin * x + cos * y + this.worldY; + } + }; + SwirlEffect.prototype.end = function() {}; + SwirlEffect.interpolation = new spine.PowOut(2); + return SwirlEffect; + })(); + spine.SwirlEffect = SwirlEffect; + })(spine || (spine = {})); + module.exports = spine; + }), {} ], + 430: [ (function(require, module, exports) { + "use strict"; + var TrackEntryListeners = require("./track-entry-listeners"); + var spine = require("./lib/spine"); + var MaxCacheTime = 30; + var FrameTime = 1 / 60; + var _vertices = []; + var _indices = []; + var _boneInfoOffset = 0; + var _vertexOffset = 0; + var _indexOffset = 0; + var _vfOffset = 0; + var _preTexUrl = null; + var _preBlendMode = null; + var _segVCount = 0; + var _segICount = 0; + var _segOffset = 0; + var _colorOffset = 0; + var _preFinalColor = null; + var _preDarkColor = null; + var _perVertexSize = 6; + var _perClipVertexSize = 12; + var _vfCount = 0, _indexCount = 0; + var _tempr, _tempg, _tempb, _tempa; + var _finalColor32, _darkColor32; + var _finalColor = new spine.Color(1, 1, 1, 1); + var _darkColor = new spine.Color(1, 1, 1, 1); + var _quadTriangles = [ 0, 1, 2, 2, 3, 0 ]; + var AnimationCache = cc.Class({ + ctor: function ctor() { + this._privateMode = false; + this._inited = false; + this._invalid = true; + this._enableCacheAttachedInfo = false; + this.frames = []; + this.totalTime = 0; + this._frameIdx = -1; + this.isCompleted = false; + this._skeletonInfo = null; + this._animationName = null; + this._tempSegments = null; + this._tempColors = null; + this._tempBoneInfos = null; + }, + init: function init(skeletonInfo, animationName) { + this._inited = true; + this._animationName = animationName; + this._skeletonInfo = skeletonInfo; + }, + clear: function clear() { + this._inited = false; + for (var i = 0, n = this.frames.length; i < n; i++) { + var frame = this.frames[i]; + frame.segments.length = 0; + } + this.invalidAllFrame(); + }, + bind: function bind(listener) { + var completeHandle = function(entry) { + entry && entry.animation.name === this._animationName && (this.isCompleted = true); + }.bind(this); + listener.complete = completeHandle; + }, + unbind: function unbind(listener) { + listener.complete = null; + }, + begin: function begin() { + if (!this._invalid) return; + var skeletonInfo = this._skeletonInfo; + var preAnimationCache = skeletonInfo.curAnimationCache; + preAnimationCache && preAnimationCache !== this && (this._privateMode ? preAnimationCache.invalidAllFrame() : preAnimationCache.updateToFrame()); + var skeleton = skeletonInfo.skeleton; + var listener = skeletonInfo.listener; + var state = skeletonInfo.state; + var animation = skeleton.data.findAnimation(this._animationName); + state.setAnimationWith(0, animation, false); + this.bind(listener); + skeletonInfo.curAnimationCache = this; + this._frameIdx = -1; + this.isCompleted = false; + this.totalTime = 0; + this._invalid = false; + }, + end: function end() { + if (!this._needToUpdate()) { + this._skeletonInfo.curAnimationCache = null; + this.frames.length = this._frameIdx + 1; + this.isCompleted = true; + this.unbind(this._skeletonInfo.listener); + } + }, + _needToUpdate: function _needToUpdate(toFrameIdx) { + return !this.isCompleted && this.totalTime < MaxCacheTime && (void 0 == toFrameIdx || this._frameIdx < toFrameIdx); + }, + updateToFrame: function updateToFrame(toFrameIdx) { + if (!this._inited) return; + this.begin(); + if (!this._needToUpdate(toFrameIdx)) return; + var skeletonInfo = this._skeletonInfo; + var skeleton = skeletonInfo.skeleton; + var clipper = skeletonInfo.clipper; + var state = skeletonInfo.state; + do { + skeleton.update(FrameTime); + state.update(FrameTime); + state.apply(skeleton); + skeleton.updateWorldTransform(); + this._frameIdx++; + this._updateFrame(skeleton, clipper, this._frameIdx); + this.totalTime += FrameTime; + } while (this._needToUpdate(toFrameIdx)); + this.end(); + }, + isInited: function isInited() { + return this._inited; + }, + isInvalid: function isInvalid() { + return this._invalid; + }, + invalidAllFrame: function invalidAllFrame() { + this.isCompleted = false; + this._invalid = true; + }, + updateAllFrame: function updateAllFrame() { + this.invalidAllFrame(); + this.updateToFrame(); + }, + enableCacheAttachedInfo: function enableCacheAttachedInfo() { + if (!this._enableCacheAttachedInfo) { + this._enableCacheAttachedInfo = true; + this.invalidAllFrame(); + } + }, + _updateFrame: function _updateFrame(skeleton, clipper, index) { + _vfOffset = 0; + _boneInfoOffset = 0; + _indexOffset = 0; + _vertexOffset = 0; + _preTexUrl = null; + _preBlendMode = null; + _segVCount = 0; + _segICount = 0; + _segOffset = 0; + _colorOffset = 0; + _preFinalColor = null; + _preDarkColor = null; + this.frames[index] = this.frames[index] || { + segments: [], + colors: [], + boneInfos: [], + vertices: null, + uintVert: null, + indices: null + }; + var frame = this.frames[index]; + var segments = this._tempSegments = frame.segments; + var colors = this._tempColors = frame.colors; + var boneInfos = this._tempBoneInfos = frame.boneInfos; + this._traverseSkeleton(skeleton, clipper); + _colorOffset > 0 && (colors[_colorOffset - 1].vfOffset = _vfOffset); + colors.length = _colorOffset; + boneInfos.length = _boneInfoOffset; + var preSegOffset = _segOffset - 1; + if (preSegOffset >= 0) if (_segICount > 0) { + var preSegInfo = segments[preSegOffset]; + preSegInfo.indexCount = _segICount; + preSegInfo.vfCount = _segVCount * _perVertexSize; + preSegInfo.vertexCount = _segVCount; + segments.length = _segOffset; + } else segments.length = _segOffset - 1; + if (0 == segments.length) return; + var vertices = frame.vertices; + var uintVert = frame.uintVert; + if (!vertices || vertices.length < _vfOffset) { + vertices = frame.vertices = new Float32Array(_vfOffset); + uintVert = frame.uintVert = new Uint32Array(vertices.buffer); + } + for (var i = 0, j = 0; i < _vfOffset; ) { + vertices[i++] = _vertices[j++]; + vertices[i++] = _vertices[j++]; + vertices[i++] = _vertices[j++]; + vertices[i++] = _vertices[j++]; + uintVert[i++] = _vertices[j++]; + uintVert[i++] = _vertices[j++]; + } + var indices = frame.indices; + (!indices || indices.length < _indexOffset) && (indices = frame.indices = new Uint16Array(_indexOffset)); + for (var _i = 0; _i < _indexOffset; _i++) indices[_i] = _indices[_i]; + frame.vertices = vertices; + frame.uintVert = uintVert; + frame.indices = indices; + }, + fillVertices: function fillVertices(skeletonColor, attachmentColor, slotColor, clipper, slot) { + _tempa = slotColor.a * attachmentColor.a * skeletonColor.a * 255; + _tempr = attachmentColor.r * skeletonColor.r * 255; + _tempg = attachmentColor.g * skeletonColor.g * 255; + _tempb = attachmentColor.b * skeletonColor.b * 255; + _finalColor.r = _tempr * slotColor.r; + _finalColor.g = _tempg * slotColor.g; + _finalColor.b = _tempb * slotColor.b; + _finalColor.a = _tempa; + if (null == slot.darkColor) _darkColor.set(0, 0, 0, 1); else { + _darkColor.r = slot.darkColor.r * _tempr; + _darkColor.g = slot.darkColor.g * _tempg; + _darkColor.b = slot.darkColor.b * _tempb; + } + _darkColor.a = 0; + _finalColor32 = (_finalColor.a << 24 >>> 0) + (_finalColor.b << 16) + (_finalColor.g << 8) + _finalColor.r; + _darkColor32 = (_darkColor.a << 24 >>> 0) + (_darkColor.b << 16) + (_darkColor.g << 8) + _darkColor.r; + if (_preFinalColor !== _finalColor32 || _preDarkColor !== _darkColor32) { + var colors = this._tempColors; + _preFinalColor = _finalColor32; + _preDarkColor = _darkColor32; + _colorOffset > 0 && (colors[_colorOffset - 1].vfOffset = _vfOffset); + colors[_colorOffset++] = { + fr: _finalColor.r, + fg: _finalColor.g, + fb: _finalColor.b, + fa: _finalColor.a, + dr: _darkColor.r, + dg: _darkColor.g, + db: _darkColor.b, + da: _darkColor.a, + vfOffset: 0 + }; + } + if (clipper.isClipping()) { + clipper.clipTriangles(_vertices, _vfCount, _indices, _indexCount, _vertices, _finalColor, _darkColor, true, _perVertexSize, _indexOffset, _vfOffset, _vfOffset + 2); + var clippedVertices = clipper.clippedVertices; + var clippedTriangles = clipper.clippedTriangles; + _indexCount = clippedTriangles.length; + _vfCount = clippedVertices.length / _perClipVertexSize * _perVertexSize; + for (var ii = 0, jj = _indexOffset, nn = clippedTriangles.length; ii < nn; ) _indices[jj++] = clippedTriangles[ii++]; + for (var _v = 0, _n = clippedVertices.length, offset = _vfOffset; _v < _n; _v += 12, + offset += _perVertexSize) { + _vertices[offset] = clippedVertices[_v]; + _vertices[offset + 1] = clippedVertices[_v + 1]; + _vertices[offset + 2] = clippedVertices[_v + 6]; + _vertices[offset + 3] = clippedVertices[_v + 7]; + _vertices[offset + 4] = _finalColor32; + _vertices[offset + 5] = _darkColor32; + } + } else for (var v = _vfOffset, n = _vfOffset + _vfCount; v < n; v += _perVertexSize) { + _vertices[v + 4] = _finalColor32; + _vertices[v + 5] = _darkColor32; + } + }, + _traverseSkeleton: function _traverseSkeleton(skeleton, clipper) { + var segments = this._tempSegments; + var boneInfos = this._tempBoneInfos; + var skeletonColor = skeleton.color; + var attachment, attachmentColor, slotColor, uvs, triangles; + var isRegion, isMesh, isClip; + var texture; + var preSegOffset, preSegInfo; + var blendMode; + var slot; + var bones = skeleton.bones; + if (this._enableCacheAttachedInfo) for (var i = 0, l = bones.length; i < l; i++, + _boneInfoOffset++) { + var bone = bones[i]; + var boneInfo = boneInfos[_boneInfoOffset]; + boneInfo || (boneInfo = boneInfos[_boneInfoOffset] = {}); + boneInfo.a = bone.a; + boneInfo.b = bone.b; + boneInfo.c = bone.c; + boneInfo.d = bone.d; + boneInfo.worldX = bone.worldX; + boneInfo.worldY = bone.worldY; + } + for (var slotIdx = 0, slotCount = skeleton.drawOrder.length; slotIdx < slotCount; slotIdx++) { + slot = skeleton.drawOrder[slotIdx]; + if (!slot.bone.active) continue; + _vfCount = 0; + _indexCount = 0; + attachment = slot.getAttachment(); + if (!attachment) { + clipper.clipEndWithSlot(slot); + continue; + } + isRegion = attachment instanceof spine.RegionAttachment; + isMesh = attachment instanceof spine.MeshAttachment; + isClip = attachment instanceof spine.ClippingAttachment; + if (isClip) { + clipper.clipStart(slot, attachment); + continue; + } + if (!isRegion && !isMesh) { + clipper.clipEndWithSlot(slot); + continue; + } + texture = attachment.region.texture._texture; + if (!texture) { + clipper.clipEndWithSlot(slot); + continue; + } + blendMode = slot.data.blendMode; + if (_preTexUrl !== texture.nativeUrl || _preBlendMode !== blendMode) { + _preTexUrl = texture.nativeUrl; + _preBlendMode = blendMode; + preSegOffset = _segOffset - 1; + if (preSegOffset >= 0) if (_segICount > 0) { + preSegInfo = segments[preSegOffset]; + preSegInfo.indexCount = _segICount; + preSegInfo.vertexCount = _segVCount; + preSegInfo.vfCount = _segVCount * _perVertexSize; + } else _segOffset--; + segments[_segOffset] = { + tex: texture, + blendMode: blendMode, + indexCount: 0, + vertexCount: 0, + vfCount: 0 + }; + _segOffset++; + _segICount = 0; + _segVCount = 0; + } + if (isRegion) { + triangles = _quadTriangles; + _vfCount = 4 * _perVertexSize; + _indexCount = 6; + attachment.computeWorldVertices(slot.bone, _vertices, _vfOffset, _perVertexSize); + } else if (isMesh) { + triangles = attachment.triangles; + _vfCount = (attachment.worldVerticesLength >> 1) * _perVertexSize; + _indexCount = triangles.length; + attachment.computeWorldVertices(slot, 0, attachment.worldVerticesLength, _vertices, _vfOffset, _perVertexSize); + } + if (0 == _vfCount || 0 == _indexCount) { + clipper.clipEndWithSlot(slot); + continue; + } + for (var ii = 0, jj = _indexOffset, nn = triangles.length; ii < nn; ) _indices[jj++] = triangles[ii++]; + uvs = attachment.uvs; + for (var v = _vfOffset, n = _vfOffset + _vfCount, u = 0; v < n; v += _perVertexSize, + u += 2) { + _vertices[v + 2] = uvs[u]; + _vertices[v + 3] = uvs[u + 1]; + } + attachmentColor = attachment.color; + slotColor = slot.color; + this.fillVertices(skeletonColor, attachmentColor, slotColor, clipper, slot); + if (_indexCount > 0) { + for (var _ii = _indexOffset, _nn = _indexOffset + _indexCount; _ii < _nn; _ii++) _indices[_ii] += _segVCount; + _indexOffset += _indexCount; + _vfOffset += _vfCount; + _vertexOffset = _vfOffset / _perVertexSize; + _segICount += _indexCount; + _segVCount += _vfCount / _perVertexSize; + } + clipper.clipEndWithSlot(slot); + } + clipper.clipEnd(); + } + }); + var SkeletonCache = cc.Class({ + ctor: function ctor() { + this._privateMode = false; + this._animationPool = {}; + this._skeletonCache = {}; + }, + enablePrivateMode: function enablePrivateMode() { + this._privateMode = true; + }, + clear: function clear() { + this._animationPool = {}; + this._skeletonCache = {}; + }, + removeSkeleton: function removeSkeleton(uuid) { + var skeletonInfo = this._skeletonCache[uuid]; + if (!skeletonInfo) return; + var animationsCache = skeletonInfo.animationsCache; + for (var aniKey in animationsCache) { + var animationCache = animationsCache[aniKey]; + if (!animationCache) continue; + this._animationPool[uuid + "#" + aniKey] = animationCache; + animationCache.clear(); + } + delete this._skeletonCache[uuid]; + }, + getSkeletonCache: function getSkeletonCache(uuid, skeletonData) { + var skeletonInfo = this._skeletonCache[uuid]; + if (!skeletonInfo) { + var skeleton = new spine.Skeleton(skeletonData); + var clipper = new spine.SkeletonClipping(); + var stateData = new spine.AnimationStateData(skeleton.data); + var state = new spine.AnimationState(stateData); + var listener = new TrackEntryListeners(); + state.addListener(listener); + this._skeletonCache[uuid] = skeletonInfo = { + skeleton: skeleton, + clipper: clipper, + state: state, + listener: listener, + animationsCache: {}, + curAnimationCache: null + }; + } + return skeletonInfo; + }, + getAnimationCache: function getAnimationCache(uuid, animationName) { + var skeletonInfo = this._skeletonCache[uuid]; + if (!skeletonInfo) return null; + var animationsCache = skeletonInfo.animationsCache; + return animationsCache[animationName]; + }, + invalidAnimationCache: function invalidAnimationCache(uuid) { + var skeletonInfo = this._skeletonCache[uuid]; + var skeleton = skeletonInfo && skeletonInfo.skeleton; + if (!skeleton) return; + var animationsCache = skeletonInfo.animationsCache; + for (var aniKey in animationsCache) { + var animationCache = animationsCache[aniKey]; + animationCache.invalidAllFrame(); + } + }, + initAnimationCache: function initAnimationCache(uuid, animationName) { + if (!animationName) return null; + var skeletonInfo = this._skeletonCache[uuid]; + var skeleton = skeletonInfo && skeletonInfo.skeleton; + if (!skeleton) return null; + var animation = skeleton.data.findAnimation(animationName); + if (!animation) return null; + var animationsCache = skeletonInfo.animationsCache; + var animationCache = animationsCache[animationName]; + if (!animationCache) { + var poolKey = uuid + "#" + animationName; + animationCache = this._animationPool[poolKey]; + if (animationCache) delete this._animationPool[poolKey]; else { + animationCache = new AnimationCache(); + animationCache._privateMode = this._privateMode; + } + animationCache.init(skeletonInfo, animationName); + animationsCache[animationName] = animationCache; + } + return animationCache; + }, + updateAnimationCache: function updateAnimationCache(uuid, animationName) { + if (animationName) { + var animationCache = this.initAnimationCache(uuid, animationName); + if (!animationCache) return null; + animationCache.updateAllFrame(); + } else { + var skeletonInfo = this._skeletonCache[uuid]; + var skeleton = skeletonInfo && skeletonInfo.skeleton; + if (!skeleton) return; + var animationsCache = skeletonInfo.animationsCache; + for (var aniKey in animationsCache) { + var _animationCache = animationsCache[aniKey]; + _animationCache.updateAllFrame(); + } + } + } + }); + SkeletonCache.FrameTime = FrameTime; + SkeletonCache.sharedCache = new SkeletonCache(); + module.exports = SkeletonCache; + }), { + "./lib/spine": 429, + "./track-entry-listeners": 434 + } ], + 431: [ (function(require, module, exports) { + "use strict"; + var SkeletonCache = (true, require("./skeleton-cache").sharedCache); + var SkeletonData = cc.Class({ + name: "sp.SkeletonData", + extends: cc.Asset, + ctor: function ctor() { + this.reset(); + }, + properties: { + _skeletonJson: null, + skeletonJsonStr: { + get: function get() { + return this._skeletonJson ? JSON.stringify(this._skeletonJson) : ""; + } + }, + skeletonJson: { + get: function get() { + return this._skeletonJson; + }, + set: function set(value) { + this.reset(); + this._skeletonJson = "string" == typeof value ? JSON.parse(value) : value; + !this._uuid && value.skeleton && (this._uuid = value.skeleton.hash); + } + }, + _atlasText: "", + atlasText: { + get: function get() { + return this._atlasText; + }, + set: function set(value) { + this._atlasText = value; + this.reset(); + } + }, + textures: { + default: [], + type: [ cc.Texture2D ] + }, + textureNames: { + default: [], + type: [ cc.String ] + }, + scale: 1, + _nativeAsset: { + get: function get() { + return this._buffer; + }, + set: function set(bin) { + this._buffer = bin.buffer || bin; + this.reset(); + }, + override: true + } + }, + statics: { + preventDeferredLoadDependents: true + }, + createNode: false, + reset: function reset() { + this._skeletonCache = null; + this._atlasCache = null; + false; + }, + ensureTexturesLoaded: function ensureTexturesLoaded(loaded, caller) { + var textures = this.textures; + var texsLen = textures.length; + if (0 == texsLen) { + loaded.call(caller, false); + return; + } + var loadedCount = 0; + var loadedItem = function loadedItem() { + loadedCount++; + if (loadedCount >= texsLen) { + loaded && loaded.call(caller, true); + loaded = null; + } + }; + for (var i = 0; i < texsLen; i++) { + var tex = textures[i]; + tex.loaded ? loadedItem() : tex.once("load", loadedItem); + } + }, + isTexturesLoaded: function isTexturesLoaded() { + var textures = this.textures; + var texsLen = textures.length; + for (var i = 0; i < texsLen; i++) { + var tex = textures[i]; + if (!tex.loaded) return false; + } + return true; + }, + getRuntimeData: function getRuntimeData(quiet) { + if (this._skeletonCache) return this._skeletonCache; + if (!(this.textures && this.textures.length > 0) && this.textureNames && this.textureNames.length > 0) { + quiet || cc.errorID(7507, this.name); + return null; + } + var atlas = this._getAtlas(quiet); + if (!atlas) return null; + var attachmentLoader = new sp.spine.AtlasAttachmentLoader(atlas); + var resData = null; + var reader = null; + if (this.skeletonJson) { + reader = new sp.spine.SkeletonJson(attachmentLoader); + resData = this.skeletonJson; + } else { + reader = new sp.spine.SkeletonBinary(attachmentLoader); + resData = new Uint8Array(this._nativeAsset); + } + reader.scale = this.scale; + this._skeletonCache = reader.readSkeletonData(resData); + atlas.dispose(); + return this._skeletonCache; + }, + getSkinsEnum: false, + getAnimsEnum: false, + _getTexture: function _getTexture(line) { + var names = this.textureNames; + for (var i = 0; i < names.length; i++) if (names[i] === line) { + var texture = this.textures[i]; + var tex = new sp.SkeletonTexture({ + width: texture.width, + height: texture.height + }); + tex.setRealTexture(texture); + return tex; + } + cc.errorID(7506, line); + return null; + }, + _getAtlas: function _getAtlas(quiet) { + if (this._atlasCache) return this._atlasCache; + if (!this.atlasText) { + quiet || cc.errorID(7508, this.name); + return null; + } + return this._atlasCache = new sp.spine.TextureAtlas(this.atlasText, this._getTexture.bind(this)); + }, + destroy: function destroy() { + SkeletonCache.removeSkeleton(this._uuid); + this._super(); + } + }); + sp.SkeletonData = module.exports = SkeletonData; + }), { + "./skeleton-cache": 430 + } ], + 432: [ (function(require, module, exports) { + "use strict"; + sp.SkeletonTexture = cc.Class({ + name: "sp.SkeletonTexture", + extends: sp.spine.Texture, + _texture: null, + _material: null, + setRealTexture: function setRealTexture(tex) { + this._texture = tex; + }, + getRealTexture: function getRealTexture() { + return this._texture; + }, + setFilters: function setFilters(minFilter, magFilter) { + this._texture && this._texture.setFilters(minFilter, magFilter); + }, + setWraps: function setWraps(uWrap, vWrap) { + this._texture && this._texture.setWrapMode(uWrap, vWrap); + }, + dispose: function dispose() {} + }); + }), {} ], + 433: [ (function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports["default"] = void 0; + var _assembler = _interopRequireDefault(require("../../cocos2d/core/renderer/assembler")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + _setPrototypeOf(subClass, superClass); + } + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + return _setPrototypeOf(o, p); + } + var Skeleton = require("./Skeleton"); + var spine = require("./lib/spine"); + var RenderFlow = require("../../cocos2d/core/renderer/render-flow"); + var VertexFormat = require("../../cocos2d/core/renderer/webgl/vertex-format"); + var VFOneColor = VertexFormat.vfmtPosUvColor; + var VFTwoColor = VertexFormat.vfmtPosUvTwoColor; + var gfx = cc.gfx; + var FLAG_BATCH = 16; + var FLAG_TWO_COLOR = 1; + var _handleVal = 0; + var _quadTriangles = [ 0, 1, 2, 2, 3, 0 ]; + var _slotColor = cc.color(0, 0, 255, 255); + var _boneColor = cc.color(255, 0, 0, 255); + var _originColor = cc.color(0, 255, 0, 255); + var _meshColor = cc.color(255, 255, 0, 255); + var _finalColor = null; + var _darkColor = null; + var _tempPos = null, _tempUv = null; + true; + _finalColor = new spine.Color(1, 1, 1, 1); + _darkColor = new spine.Color(1, 1, 1, 1); + _tempPos = new spine.Vector2(); + _tempUv = new spine.Vector2(); + var _premultipliedAlpha; + var _multiplier; + var _slotRangeStart; + var _slotRangeEnd; + var _useTint; + var _debugSlots; + var _debugBones; + var _debugMesh; + var _nodeR, _nodeG, _nodeB, _nodeA; + var _finalColor32, _darkColor32; + var _vertexFormat; + var _perVertexSize; + var _perClipVertexSize; + var _vertexFloatCount = 0, _vertexCount = 0, _vertexFloatOffset = 0, _vertexOffset = 0, _indexCount = 0, _indexOffset = 0, _vfOffset = 0; + var _tempr, _tempg, _tempb; + var _inRange; + var _mustFlush; + var _x, _y, _m00, _m04, _m12, _m01, _m05, _m13; + var _r, _g, _b, _fr, _fg, _fb, _fa, _dr, _dg, _db, _da; + var _comp, _buffer, _renderer, _node, _needColor, _vertexEffect; + function _getSlotMaterial(tex, blendMode) { + var src, dst; + switch (blendMode) { + case spine.BlendMode.Additive: + src = _premultipliedAlpha ? cc.macro.ONE : cc.macro.SRC_ALPHA; + dst = cc.macro.ONE; + break; + + case spine.BlendMode.Multiply: + src = cc.macro.DST_COLOR; + dst = cc.macro.ONE_MINUS_SRC_ALPHA; + break; + + case spine.BlendMode.Screen: + src = cc.macro.ONE; + dst = cc.macro.ONE_MINUS_SRC_COLOR; + break; + + case spine.BlendMode.Normal: + default: + src = _premultipliedAlpha ? cc.macro.ONE : cc.macro.SRC_ALPHA; + dst = cc.macro.ONE_MINUS_SRC_ALPHA; + } + var useModel = !_comp.enableBatch; + var baseMaterial = _comp._materials[0]; + if (!baseMaterial) return null; + var key = tex.getId() + src + dst + _useTint + useModel; + var materialCache = _comp._materialCache; + var material = materialCache[key]; + if (!material) { + if (materialCache.baseMaterial) material = cc.MaterialVariant.create(baseMaterial); else { + material = baseMaterial; + materialCache.baseMaterial = baseMaterial; + } + material.define("CC_USE_MODEL", useModel); + material.define("USE_TINT", _useTint); + material.setProperty("texture", tex); + material.setBlend(true, gfx.BLEND_FUNC_ADD, src, dst, gfx.BLEND_FUNC_ADD, src, dst); + materialCache[key] = material; + } + return material; + } + function _handleColor(color) { + _fa = color.fa * _nodeA; + _multiplier = _premultipliedAlpha ? _fa / 255 : 1; + _r = _nodeR * _multiplier; + _g = _nodeG * _multiplier; + _b = _nodeB * _multiplier; + _fr = color.fr * _r; + _fg = color.fg * _g; + _fb = color.fb * _b; + _finalColor32 = (_fa << 24 >>> 0) + (_fb << 16) + (_fg << 8) + _fr; + _dr = color.dr * _r; + _dg = color.dg * _g; + _db = color.db * _b; + _da = _premultipliedAlpha ? 255 : 0; + _darkColor32 = (_da << 24 >>> 0) + (_db << 16) + (_dg << 8) + _dr; + } + function _spineColorToInt32(spineColor) { + return (spineColor.a << 24 >>> 0) + (spineColor.b << 16) + (spineColor.g << 8) + spineColor.r; + } + var SpineAssembler = (function(_Assembler) { + _inheritsLoose(SpineAssembler, _Assembler); + function SpineAssembler() { + return _Assembler.apply(this, arguments) || this; + } + var _proto = SpineAssembler.prototype; + _proto.updateRenderData = function updateRenderData(comp) { + if (comp.isAnimationCached()) return; + var skeleton = comp._skeleton; + skeleton && skeleton.updateWorldTransform(); + }; + _proto.fillVertices = function fillVertices(skeletonColor, attachmentColor, slotColor, clipper, slot) { + var vbuf = _buffer._vData, ibuf = _buffer._iData, uintVData = _buffer._uintVData; + var offsetInfo; + _finalColor.a = slotColor.a * attachmentColor.a * skeletonColor.a * _nodeA * 255; + _multiplier = _premultipliedAlpha ? _finalColor.a : 255; + _tempr = _nodeR * attachmentColor.r * skeletonColor.r * _multiplier; + _tempg = _nodeG * attachmentColor.g * skeletonColor.g * _multiplier; + _tempb = _nodeB * attachmentColor.b * skeletonColor.b * _multiplier; + _finalColor.r = _tempr * slotColor.r; + _finalColor.g = _tempg * slotColor.g; + _finalColor.b = _tempb * slotColor.b; + if (null == slot.darkColor) _darkColor.set(0, 0, 0, 1); else { + _darkColor.r = slot.darkColor.r * _tempr; + _darkColor.g = slot.darkColor.g * _tempg; + _darkColor.b = slot.darkColor.b * _tempb; + } + _darkColor.a = _premultipliedAlpha ? 255 : 0; + if (clipper.isClipping()) { + var uvs = vbuf.subarray(_vertexFloatOffset + 2); + clipper.clipTriangles(vbuf.subarray(_vertexFloatOffset), _vertexFloatCount, ibuf.subarray(_indexOffset), _indexCount, uvs, _finalColor, _darkColor, _useTint, _perVertexSize); + var clippedVertices = new Float32Array(clipper.clippedVertices); + var clippedTriangles = clipper.clippedTriangles; + _indexCount = clippedTriangles.length; + _vertexFloatCount = clippedVertices.length / _perClipVertexSize * _perVertexSize; + offsetInfo = _buffer.request(_vertexFloatCount / _perVertexSize, _indexCount); + _indexOffset = offsetInfo.indiceOffset, _vertexOffset = offsetInfo.vertexOffset, + _vertexFloatOffset = offsetInfo.byteOffset >> 2; + vbuf = _buffer._vData, ibuf = _buffer._iData; + uintVData = _buffer._uintVData; + ibuf.set(clippedTriangles, _indexOffset); + if (_vertexEffect) for (var _v2 = 0, _n2 = clippedVertices.length, offset = _vertexFloatOffset; _v2 < _n2; _v2 += _perClipVertexSize, + offset += _perVertexSize) { + _tempPos.x = clippedVertices[_v2]; + _tempPos.y = clippedVertices[_v2 + 1]; + _finalColor.set(clippedVertices[_v2 + 2], clippedVertices[_v2 + 3], clippedVertices[_v2 + 4], clippedVertices[_v2 + 5]); + _tempUv.x = clippedVertices[_v2 + 6]; + _tempUv.y = clippedVertices[_v2 + 7]; + _useTint ? _darkColor.set(clippedVertices[_v2 + 8], clippedVertices[_v2 + 9], clippedVertices[_v2 + 10], clippedVertices[_v2 + 11]) : _darkColor.set(0, 0, 0, 0); + _vertexEffect.transform(_tempPos, _tempUv, _finalColor, _darkColor); + vbuf[offset] = _tempPos.x; + vbuf[offset + 1] = _tempPos.y; + vbuf[offset + 2] = _tempUv.x; + vbuf[offset + 3] = _tempUv.y; + uintVData[offset + 4] = _spineColorToInt32(_finalColor); + _useTint && (uintVData[offset + 5] = _spineColorToInt32(_darkColor)); + } else for (var _v3 = 0, _n3 = clippedVertices.length, _offset = _vertexFloatOffset; _v3 < _n3; _v3 += _perClipVertexSize, + _offset += _perVertexSize) { + vbuf[_offset] = clippedVertices[_v3]; + vbuf[_offset + 1] = clippedVertices[_v3 + 1]; + vbuf[_offset + 2] = clippedVertices[_v3 + 6]; + vbuf[_offset + 3] = clippedVertices[_v3 + 7]; + _finalColor32 = (clippedVertices[_v3 + 5] << 24 >>> 0) + (clippedVertices[_v3 + 4] << 16) + (clippedVertices[_v3 + 3] << 8) + clippedVertices[_v3 + 2]; + uintVData[_offset + 4] = _finalColor32; + if (_useTint) { + _darkColor32 = (clippedVertices[_v3 + 11] << 24 >>> 0) + (clippedVertices[_v3 + 10] << 16) + (clippedVertices[_v3 + 9] << 8) + clippedVertices[_v3 + 8]; + uintVData[_offset + 5] = _darkColor32; + } + } + } else if (_vertexEffect) for (var v = _vertexFloatOffset, n = _vertexFloatOffset + _vertexFloatCount; v < n; v += _perVertexSize) { + _tempPos.x = vbuf[v]; + _tempPos.y = vbuf[v + 1]; + _tempUv.x = vbuf[v + 2]; + _tempUv.y = vbuf[v + 3]; + _vertexEffect.transform(_tempPos, _tempUv, _finalColor, _darkColor); + vbuf[v] = _tempPos.x; + vbuf[v + 1] = _tempPos.y; + vbuf[v + 2] = _tempUv.x; + vbuf[v + 3] = _tempUv.y; + uintVData[v + 4] = _spineColorToInt32(_finalColor); + _useTint && (uintVData[v + 5] = _spineColorToInt32(_darkColor)); + } else { + _finalColor32 = _spineColorToInt32(_finalColor); + _darkColor32 = _spineColorToInt32(_darkColor); + for (var _v = _vertexFloatOffset, _n = _vertexFloatOffset + _vertexFloatCount; _v < _n; _v += _perVertexSize) { + uintVData[_v + 4] = _finalColor32; + _useTint && (uintVData[_v + 5] = _darkColor32); + } + } + }; + _proto.realTimeTraverse = function realTimeTraverse(worldMat) { + var vbuf; + var ibuf; + var locSkeleton = _comp._skeleton; + var skeletonColor = locSkeleton.color; + var graphics = _comp._debugRenderer; + var clipper = _comp._clipper; + var material = null; + var attachment, attachmentColor, slotColor, uvs, triangles; + var isRegion, isMesh, isClip; + var offsetInfo; + var slot; + var worldMatm; + _slotRangeStart = _comp._startSlotIndex; + _slotRangeEnd = _comp._endSlotIndex; + _inRange = false; + -1 == _slotRangeStart && (_inRange = true); + _debugSlots = _comp.debugSlots; + _debugBones = _comp.debugBones; + _debugMesh = _comp.debugMesh; + if (graphics && (_debugBones || _debugSlots || _debugMesh)) { + graphics.clear(); + graphics.lineWidth = 2; + } + _perClipVertexSize = _useTint ? 12 : 8; + _vertexFloatCount = 0; + _vertexFloatOffset = 0; + _vertexOffset = 0; + _indexCount = 0; + _indexOffset = 0; + for (var slotIdx = 0, slotCount = locSkeleton.drawOrder.length; slotIdx < slotCount; slotIdx++) { + slot = locSkeleton.drawOrder[slotIdx]; + if (void 0 == slot || !slot.bone.active) continue; + _slotRangeStart >= 0 && _slotRangeStart == slot.data.index && (_inRange = true); + if (!_inRange) { + clipper.clipEndWithSlot(slot); + continue; + } + _slotRangeEnd >= 0 && _slotRangeEnd == slot.data.index && (_inRange = false); + _vertexFloatCount = 0; + _indexCount = 0; + attachment = slot.getAttachment(); + if (!attachment) { + clipper.clipEndWithSlot(slot); + continue; + } + isRegion = attachment instanceof spine.RegionAttachment; + isMesh = attachment instanceof spine.MeshAttachment; + isClip = attachment instanceof spine.ClippingAttachment; + if (isClip) { + clipper.clipStart(slot, attachment); + continue; + } + if (!isRegion && !isMesh) { + clipper.clipEndWithSlot(slot); + continue; + } + material = _getSlotMaterial(attachment.region.texture._texture, slot.data.blendMode); + if (!material) { + clipper.clipEndWithSlot(slot); + continue; + } + if (_mustFlush || material.getHash() !== _renderer.material.getHash()) { + _mustFlush = false; + _renderer._flush(); + _renderer.node = _node; + _renderer.material = material; + } + if (isRegion) { + triangles = _quadTriangles; + _vertexFloatCount = 4 * _perVertexSize; + _indexCount = 6; + offsetInfo = _buffer.request(4, 6); + _indexOffset = offsetInfo.indiceOffset, _vertexOffset = offsetInfo.vertexOffset, + _vertexFloatOffset = offsetInfo.byteOffset >> 2; + vbuf = _buffer._vData, ibuf = _buffer._iData; + attachment.computeWorldVertices(slot.bone, vbuf, _vertexFloatOffset, _perVertexSize); + if (graphics && _debugSlots) { + graphics.strokeColor = _slotColor; + graphics.moveTo(vbuf[_vertexFloatOffset], vbuf[_vertexFloatOffset + 1]); + for (var ii = _vertexFloatOffset + _perVertexSize, nn = _vertexFloatOffset + _vertexFloatCount; ii < nn; ii += _perVertexSize) graphics.lineTo(vbuf[ii], vbuf[ii + 1]); + graphics.close(); + graphics.stroke(); + } + } else if (isMesh) { + triangles = attachment.triangles; + _vertexFloatCount = (attachment.worldVerticesLength >> 1) * _perVertexSize; + _indexCount = triangles.length; + offsetInfo = _buffer.request(_vertexFloatCount / _perVertexSize, _indexCount); + _indexOffset = offsetInfo.indiceOffset, _vertexOffset = offsetInfo.vertexOffset, + _vertexFloatOffset = offsetInfo.byteOffset >> 2; + vbuf = _buffer._vData, ibuf = _buffer._iData; + attachment.computeWorldVertices(slot, 0, attachment.worldVerticesLength, vbuf, _vertexFloatOffset, _perVertexSize); + if (graphics && _debugMesh) { + graphics.strokeColor = _meshColor; + for (var _ii = 0, _nn = triangles.length; _ii < _nn; _ii += 3) { + var v1 = triangles[_ii] * _perVertexSize + _vertexFloatOffset; + var v2 = triangles[_ii + 1] * _perVertexSize + _vertexFloatOffset; + var v3 = triangles[_ii + 2] * _perVertexSize + _vertexFloatOffset; + graphics.moveTo(vbuf[v1], vbuf[v1 + 1]); + graphics.lineTo(vbuf[v2], vbuf[v2 + 1]); + graphics.lineTo(vbuf[v3], vbuf[v3 + 1]); + graphics.close(); + graphics.stroke(); + } + } + } + if (0 == _vertexFloatCount || 0 == _indexCount) { + clipper.clipEndWithSlot(slot); + continue; + } + ibuf.set(triangles, _indexOffset); + uvs = attachment.uvs; + for (var v = _vertexFloatOffset, n = _vertexFloatOffset + _vertexFloatCount, u = 0; v < n; v += _perVertexSize, + u += 2) { + vbuf[v + 2] = uvs[u]; + vbuf[v + 3] = uvs[u + 1]; + } + attachmentColor = attachment.color, slotColor = slot.color; + this.fillVertices(skeletonColor, attachmentColor, slotColor, clipper, slot); + vbuf = _buffer._vData, ibuf = _buffer._iData; + if (_indexCount > 0) { + for (var _ii2 = _indexOffset, _nn2 = _indexOffset + _indexCount; _ii2 < _nn2; _ii2++) ibuf[_ii2] += _vertexOffset; + if (worldMat) { + worldMatm = worldMat.m; + _m00 = worldMatm[0]; + _m04 = worldMatm[4]; + _m12 = worldMatm[12]; + _m01 = worldMatm[1]; + _m05 = worldMatm[5]; + _m13 = worldMatm[13]; + for (var _ii3 = _vertexFloatOffset, _nn3 = _vertexFloatOffset + _vertexFloatCount; _ii3 < _nn3; _ii3 += _perVertexSize) { + _x = vbuf[_ii3]; + _y = vbuf[_ii3 + 1]; + vbuf[_ii3] = _x * _m00 + _y * _m04 + _m12; + vbuf[_ii3 + 1] = _x * _m01 + _y * _m05 + _m13; + } + } + _buffer.adjust(_vertexFloatCount / _perVertexSize, _indexCount); + } + clipper.clipEndWithSlot(slot); + } + clipper.clipEnd(); + if (graphics && _debugBones) { + var bone; + graphics.strokeColor = _boneColor; + graphics.fillColor = _slotColor; + for (var i = 0, _n4 = locSkeleton.bones.length; i < _n4; i++) { + bone = locSkeleton.bones[i]; + var x = bone.data.length * bone.a + bone.worldX; + var y = bone.data.length * bone.c + bone.worldY; + graphics.moveTo(bone.worldX, bone.worldY); + graphics.lineTo(x, y); + graphics.stroke(); + graphics.circle(bone.worldX, bone.worldY, 1.5 * Math.PI); + graphics.fill(); + 0 === i && (graphics.fillColor = _originColor); + } + } + }; + _proto.cacheTraverse = function cacheTraverse(worldMat) { + var frame = _comp._curFrame; + if (!frame) return; + var segments = frame.segments; + if (0 == segments.length) return; + var vbuf, ibuf, uintbuf; + var material; + var offsetInfo; + var vertices = frame.vertices; + var indices = frame.indices; + var worldMatm; + var frameVFOffset = 0, frameIndexOffset = 0, segVFCount = 0; + if (worldMat) { + worldMatm = worldMat.m; + _m00 = worldMatm[0]; + _m01 = worldMatm[1]; + _m04 = worldMatm[4]; + _m05 = worldMatm[5]; + _m12 = worldMatm[12]; + _m13 = worldMatm[13]; + } + var justTranslate = 1 === _m00 && 0 === _m01 && 0 === _m04 && 1 === _m05; + var needBatch = _handleVal & FLAG_BATCH; + var calcTranslate = needBatch && justTranslate; + var colorOffset = 0; + var colors = frame.colors; + var nowColor = colors[colorOffset++]; + var maxVFOffset = nowColor.vfOffset; + _handleColor(nowColor); + for (var i = 0, n = segments.length; i < n; i++) { + var segInfo = segments[i]; + material = _getSlotMaterial(segInfo.tex, segInfo.blendMode); + if (!material) continue; + if (_mustFlush || material.getHash() !== _renderer.material.getHash()) { + _mustFlush = false; + _renderer._flush(); + _renderer.node = _node; + _renderer.material = material; + } + _vertexCount = segInfo.vertexCount; + _indexCount = segInfo.indexCount; + offsetInfo = _buffer.request(_vertexCount, _indexCount); + _indexOffset = offsetInfo.indiceOffset; + _vertexOffset = offsetInfo.vertexOffset; + _vfOffset = offsetInfo.byteOffset >> 2; + vbuf = _buffer._vData; + ibuf = _buffer._iData; + uintbuf = _buffer._uintVData; + for (var ii = _indexOffset, il = _indexOffset + _indexCount; ii < il; ii++) ibuf[ii] = _vertexOffset + indices[frameIndexOffset++]; + segVFCount = segInfo.vfCount; + vbuf.set(vertices.subarray(frameVFOffset, frameVFOffset + segVFCount), _vfOffset); + frameVFOffset += segVFCount; + if (calcTranslate) for (var _ii4 = _vfOffset, _il = _vfOffset + segVFCount; _ii4 < _il; _ii4 += 6) { + vbuf[_ii4] += _m12; + vbuf[_ii4 + 1] += _m13; + } else if (needBatch) for (var _ii5 = _vfOffset, _il2 = _vfOffset + segVFCount; _ii5 < _il2; _ii5 += 6) { + _x = vbuf[_ii5]; + _y = vbuf[_ii5 + 1]; + vbuf[_ii5] = _x * _m00 + _y * _m04 + _m12; + vbuf[_ii5 + 1] = _x * _m01 + _y * _m05 + _m13; + } + _buffer.adjust(_vertexCount, _indexCount); + if (!_needColor) continue; + var frameColorOffset = frameVFOffset - segVFCount; + for (var _ii6 = _vfOffset + 4, _il3 = _vfOffset + 4 + segVFCount; _ii6 < _il3; _ii6 += 6, + frameColorOffset += 6) { + if (frameColorOffset >= maxVFOffset) { + nowColor = colors[colorOffset++]; + _handleColor(nowColor); + maxVFOffset = nowColor.vfOffset; + } + uintbuf[_ii6] = _finalColor32; + uintbuf[_ii6 + 1] = _darkColor32; + } + } + }; + _proto.fillBuffers = function fillBuffers(comp, renderer) { + var node = comp.node; + node._renderFlag |= RenderFlow.FLAG_UPDATE_RENDER_DATA; + if (!comp._skeleton) return; + var nodeColor = node._color; + _nodeR = nodeColor.r / 255; + _nodeG = nodeColor.g / 255; + _nodeB = nodeColor.b / 255; + _nodeA = nodeColor.a / 255; + _useTint = comp.useTint || comp.isAnimationCached(); + _vertexFormat = _useTint ? VFTwoColor : VFOneColor; + _perVertexSize = _useTint ? 6 : 5; + _node = comp.node; + _buffer = renderer.getBuffer("spine", _vertexFormat); + _renderer = renderer; + _comp = comp; + _mustFlush = true; + _premultipliedAlpha = comp.premultipliedAlpha; + _multiplier = 1; + _handleVal = 0; + _needColor = false; + _vertexEffect = comp._effectDelegate && comp._effectDelegate._vertexEffect; + (4294967295 !== nodeColor._val || _premultipliedAlpha) && (_needColor = true); + _useTint && (_handleVal |= FLAG_TWO_COLOR); + var worldMat = void 0; + if (_comp.enableBatch) { + worldMat = _node._worldMatrix; + _mustFlush = false; + _handleVal |= FLAG_BATCH; + } + if (comp.isAnimationCached()) this.cacheTraverse(worldMat); else { + _vertexEffect && _vertexEffect.begin(comp._skeleton); + this.realTimeTraverse(worldMat); + _vertexEffect && _vertexEffect.end(); + } + renderer.worldMatDirty++; + comp.attachUtil._syncAttachedNode(); + _node = void 0; + _buffer = void 0; + _renderer = void 0; + _comp = void 0; + _vertexEffect = null; + }; + _proto.postFillBuffers = function postFillBuffers(comp, renderer) { + renderer.worldMatDirty--; + }; + return SpineAssembler; + })(_assembler["default"]); + exports["default"] = SpineAssembler; + _assembler["default"].register(Skeleton, SpineAssembler); + module.exports = exports["default"]; + }), { + "../../cocos2d/core/renderer/assembler": 269, + "../../cocos2d/core/renderer/render-flow": 273, + "../../cocos2d/core/renderer/webgl/vertex-format": 314, + "./Skeleton": 427, + "./lib/spine": 429 + } ], + 434: [ (function(require, module, exports) { + "use strict"; + var TrackEntryListeners = function TrackEntryListeners() { + this.start = null; + this.end = null; + this.complete = null; + this.event = null; + this.interrupt = null; + this.dispose = null; + }; + TrackEntryListeners.getListeners = function(entry) { + entry.listener || (entry.listener = new TrackEntryListeners()); + return entry.listener; + }; + module.exports = TrackEntryListeners; + }), {} ], + 435: [ (function(require, module, exports) { + "use strict"; + var spine = require("./lib/spine"); + sp.VertexEffectDelegate = cc.Class({ + name: "sp.VertexEffectDelegate", + ctor: function ctor() { + this._vertexEffect = null; + this._interpolation = null; + this._effectType = "none"; + }, + clear: function clear() { + this._vertexEffect = null; + this._interpolation = null; + this._effectType = "none"; + }, + initJitter: function initJitter(jitterX, jitterY) { + this._effectType = "jitter"; + this._vertexEffect = new spine.JitterEffect(jitterX, jitterY); + return this._vertexEffect; + }, + initSwirlWithPow: function initSwirlWithPow(radius, power) { + this._interpolation = new spine.Pow(power); + this._vertexEffect = new spine.SwirlEffect(radius, this._interpolation); + return this._vertexEffect; + }, + initSwirlWithPowOut: function initSwirlWithPowOut(radius, power) { + this._interpolation = new spine.PowOut(power); + this._vertexEffect = new spine.SwirlEffect(radius, this._interpolation); + return this._vertexEffect; + }, + getJitterVertexEffect: function getJitterVertexEffect() { + return this._vertexEffect; + }, + getSwirlVertexEffect: function getSwirlVertexEffect() { + return this._vertexEffect; + }, + getVertexEffect: function getVertexEffect() { + return this._vertexEffect; + }, + getEffectType: function getEffectType() { + return this._effectType; + } + }); + module.exports = sp.VertexEffectDelegate; + }), { + "./lib/spine": 429 + } ], + 436: [ (function(require, module, exports) { + "use strict"; + (function(global, factory) { + "object" === typeof exports && "undefined" !== typeof module ? factory(exports) : "function" === typeof define && define.amd ? define([ "exports" ], factory) : factory(global.box2d = {}); + })(void 0, (function(exports) { + function b2Assert(condition) { + var args = []; + for (var _i = 1; _i < arguments.length; _i++) args[_i - 1] = arguments[_i]; + if (!condition) throw new (Error.bind.apply(Error, [ void 0 ].concat(args)))(); + } + function b2Maybe(value, def) { + return void 0 !== value ? value : def; + } + var b2_maxFloat = 1e37; + var b2_epsilon = 1e-5; + var b2_epsilon_sq = b2_epsilon * b2_epsilon; + var b2_pi = 3.14159265359; + var b2_maxManifoldPoints = 2; + var b2_maxPolygonVertices = 8; + var b2_aabbExtension = .1; + var b2_aabbMultiplier = 2; + var b2_linearSlop = .008; + var b2_angularSlop = 2 / 180 * b2_pi; + var b2_polygonRadius = 2 * b2_linearSlop; + var b2_maxSubSteps = 8; + var b2_maxTOIContacts = 32; + var b2_velocityThreshold = 1; + var b2_maxLinearCorrection = .2; + var b2_maxAngularCorrection = 8 / 180 * b2_pi; + var b2_maxTranslation = 2; + var b2_maxTranslationSquared = b2_maxTranslation * b2_maxTranslation; + var b2_maxRotation = .5 * b2_pi; + var b2_maxRotationSquared = b2_maxRotation * b2_maxRotation; + var b2_baumgarte = .2; + var b2_toiBaumgarte = .75; + var b2_invalidParticleIndex = -1; + var b2_maxParticleIndex = 2147483647; + var b2_particleStride = .75; + var b2_minParticleWeight = 1; + var b2_maxParticlePressure = .25; + var b2_maxParticleForce = .5; + var b2_maxTriadDistance = 2; + var b2_maxTriadDistanceSquared = b2_maxTriadDistance * b2_maxTriadDistance; + var b2_minParticleSystemBufferCapacity = 256; + var b2_barrierCollisionTime = 2.5; + var b2_timeToSleep = .5; + var b2_linearSleepTolerance = .01; + var b2_angularSleepTolerance = 2 / 180 * b2_pi; + function b2Alloc(size) { + return null; + } + function b2Free(mem) {} + function b2Log(message) { + var args = []; + for (var _i = 1; _i < arguments.length; _i++) args[_i - 1] = arguments[_i]; + } + var b2Version = (function() { + function b2Version(major, minor, revision) { + void 0 === major && (major = 0); + void 0 === minor && (minor = 0); + void 0 === revision && (revision = 0); + this.major = 0; + this.minor = 0; + this.revision = 0; + this.major = major; + this.minor = minor; + this.revision = revision; + } + b2Version.prototype.toString = function() { + return this.major + "." + this.minor + "." + this.revision; + }; + return b2Version; + })(); + var b2_version = new b2Version(2, 3, 2); + var b2_branch = "master"; + var b2_commit = "fbf51801d80fc389d43dc46524520e89043b6faf"; + function b2ParseInt(v) { + return parseInt(v, 10); + } + function b2ParseUInt(v) { + return Math.abs(parseInt(v, 10)); + } + function b2MakeArray(length, init) { + var a = []; + for (var i = 0; i < length; ++i) a.push(init(i)); + return a; + } + function b2MakeNullArray(length) { + var a = []; + for (var i = 0; i < length; ++i) a.push(null); + return a; + } + function b2MakeNumberArray(length, init) { + void 0 === init && (init = 0); + var a = []; + for (var i = 0; i < length; ++i) a.push(init); + return a; + } + var b2_pi_over_180 = b2_pi / 180; + var b2_180_over_pi = 180 / b2_pi; + var b2_two_pi = 2 * b2_pi; + var b2Abs = Math.abs; + var b2Min = Math.min; + var b2Max = Math.max; + function b2Clamp(a, lo, hi) { + return a < lo ? lo : a > hi ? hi : a; + } + function b2Swap(a, b) { + var tmp = a[0]; + a[0] = b[0]; + b[0] = tmp; + } + var b2IsValid = isFinite; + function b2Sq(n) { + return n * n; + } + function b2InvSqrt(n) { + return 1 / Math.sqrt(n); + } + var b2Sqrt = Math.sqrt; + var b2Pow = Math.pow; + function b2DegToRad(degrees) { + return degrees * b2_pi_over_180; + } + function b2RadToDeg(radians) { + return radians * b2_180_over_pi; + } + var b2Cos = Math.cos; + var b2Sin = Math.sin; + var b2Acos = Math.acos; + var b2Asin = Math.asin; + var b2Atan2 = Math.atan2; + function b2NextPowerOfTwo(x) { + x |= x >> 1 & 2147483647; + x |= x >> 2 & 1073741823; + x |= x >> 4 & 268435455; + x |= x >> 8 & 16777215; + x |= x >> 16 & 65535; + return x + 1; + } + function b2IsPowerOfTwo(x) { + return x > 0 && 0 === (x & x - 1); + } + function b2Random() { + return 2 * Math.random() - 1; + } + function b2RandomRange(lo, hi) { + return (hi - lo) * Math.random() + lo; + } + var b2Vec2 = (function() { + function b2Vec2(x, y) { + void 0 === x && (x = 0); + void 0 === y && (y = 0); + this.x = x; + this.y = y; + } + b2Vec2.prototype.Clone = function() { + return new b2Vec2(this.x, this.y); + }; + b2Vec2.prototype.SetZero = function() { + this.x = 0; + this.y = 0; + return this; + }; + b2Vec2.prototype.Set = function(x, y) { + this.x = x; + this.y = y; + return this; + }; + b2Vec2.prototype.Copy = function(other) { + this.x = other.x; + this.y = other.y; + return this; + }; + b2Vec2.prototype.SelfAdd = function(v) { + this.x += v.x; + this.y += v.y; + return this; + }; + b2Vec2.prototype.SelfAddXY = function(x, y) { + this.x += x; + this.y += y; + return this; + }; + b2Vec2.prototype.SelfSub = function(v) { + this.x -= v.x; + this.y -= v.y; + return this; + }; + b2Vec2.prototype.SelfSubXY = function(x, y) { + this.x -= x; + this.y -= y; + return this; + }; + b2Vec2.prototype.SelfMul = function(s) { + this.x *= s; + this.y *= s; + return this; + }; + b2Vec2.prototype.SelfMulAdd = function(s, v) { + this.x += s * v.x; + this.y += s * v.y; + return this; + }; + b2Vec2.prototype.SelfMulSub = function(s, v) { + this.x -= s * v.x; + this.y -= s * v.y; + return this; + }; + b2Vec2.prototype.Dot = function(v) { + return this.x * v.x + this.y * v.y; + }; + b2Vec2.prototype.Cross = function(v) { + return this.x * v.y - this.y * v.x; + }; + b2Vec2.prototype.Length = function() { + var x = this.x, y = this.y; + return Math.sqrt(x * x + y * y); + }; + b2Vec2.prototype.LengthSquared = function() { + var x = this.x, y = this.y; + return x * x + y * y; + }; + b2Vec2.prototype.Normalize = function() { + var length = this.Length(); + if (length >= b2_epsilon) { + var inv_length = 1 / length; + this.x *= inv_length; + this.y *= inv_length; + } + return length; + }; + b2Vec2.prototype.SelfNormalize = function() { + var length = this.Length(); + if (length >= b2_epsilon) { + var inv_length = 1 / length; + this.x *= inv_length; + this.y *= inv_length; + } + return this; + }; + b2Vec2.prototype.SelfRotate = function(radians) { + var c = Math.cos(radians); + var s = Math.sin(radians); + var x = this.x; + this.x = c * x - s * this.y; + this.y = s * x + c * this.y; + return this; + }; + b2Vec2.prototype.IsValid = function() { + return isFinite(this.x) && isFinite(this.y); + }; + b2Vec2.prototype.SelfCrossVS = function(s) { + var x = this.x; + this.x = s * this.y; + this.y = -s * x; + return this; + }; + b2Vec2.prototype.SelfCrossSV = function(s) { + var x = this.x; + this.x = -s * this.y; + this.y = s * x; + return this; + }; + b2Vec2.prototype.SelfMinV = function(v) { + this.x = b2Min(this.x, v.x); + this.y = b2Min(this.y, v.y); + return this; + }; + b2Vec2.prototype.SelfMaxV = function(v) { + this.x = b2Max(this.x, v.x); + this.y = b2Max(this.y, v.y); + return this; + }; + b2Vec2.prototype.SelfAbs = function() { + this.x = b2Abs(this.x); + this.y = b2Abs(this.y); + return this; + }; + b2Vec2.prototype.SelfNeg = function() { + this.x = -this.x; + this.y = -this.y; + return this; + }; + b2Vec2.prototype.SelfSkew = function() { + var x = this.x; + this.x = -this.y; + this.y = x; + return this; + }; + b2Vec2.MakeArray = function(length) { + return b2MakeArray(length, (function(i) { + return new b2Vec2(); + })); + }; + b2Vec2.AbsV = function(v, out) { + out.x = b2Abs(v.x); + out.y = b2Abs(v.y); + return out; + }; + b2Vec2.MinV = function(a, b, out) { + out.x = b2Min(a.x, b.x); + out.y = b2Min(a.y, b.y); + return out; + }; + b2Vec2.MaxV = function(a, b, out) { + out.x = b2Max(a.x, b.x); + out.y = b2Max(a.y, b.y); + return out; + }; + b2Vec2.ClampV = function(v, lo, hi, out) { + out.x = b2Clamp(v.x, lo.x, hi.x); + out.y = b2Clamp(v.y, lo.y, hi.y); + return out; + }; + b2Vec2.RotateV = function(v, radians, out) { + var v_x = v.x, v_y = v.y; + var c = Math.cos(radians); + var s = Math.sin(radians); + out.x = c * v_x - s * v_y; + out.y = s * v_x + c * v_y; + return out; + }; + b2Vec2.DotVV = function(a, b) { + return a.x * b.x + a.y * b.y; + }; + b2Vec2.CrossVV = function(a, b) { + return a.x * b.y - a.y * b.x; + }; + b2Vec2.CrossVS = function(v, s, out) { + var v_x = v.x; + out.x = s * v.y; + out.y = -s * v_x; + return out; + }; + b2Vec2.CrossVOne = function(v, out) { + var v_x = v.x; + out.x = v.y; + out.y = -v_x; + return out; + }; + b2Vec2.CrossSV = function(s, v, out) { + var v_x = v.x; + out.x = -s * v.y; + out.y = s * v_x; + return out; + }; + b2Vec2.CrossOneV = function(v, out) { + var v_x = v.x; + out.x = -v.y; + out.y = v_x; + return out; + }; + b2Vec2.AddVV = function(a, b, out) { + out.x = a.x + b.x; + out.y = a.y + b.y; + return out; + }; + b2Vec2.SubVV = function(a, b, out) { + out.x = a.x - b.x; + out.y = a.y - b.y; + return out; + }; + b2Vec2.MulSV = function(s, v, out) { + out.x = v.x * s; + out.y = v.y * s; + return out; + }; + b2Vec2.MulVS = function(v, s, out) { + out.x = v.x * s; + out.y = v.y * s; + return out; + }; + b2Vec2.AddVMulSV = function(a, s, b, out) { + out.x = a.x + s * b.x; + out.y = a.y + s * b.y; + return out; + }; + b2Vec2.SubVMulSV = function(a, s, b, out) { + out.x = a.x - s * b.x; + out.y = a.y - s * b.y; + return out; + }; + b2Vec2.AddVCrossSV = function(a, s, v, out) { + var v_x = v.x; + out.x = a.x - s * v.y; + out.y = a.y + s * v_x; + return out; + }; + b2Vec2.MidVV = function(a, b, out) { + out.x = .5 * (a.x + b.x); + out.y = .5 * (a.y + b.y); + return out; + }; + b2Vec2.ExtVV = function(a, b, out) { + out.x = .5 * (b.x - a.x); + out.y = .5 * (b.y - a.y); + return out; + }; + b2Vec2.IsEqualToV = function(a, b) { + return a.x === b.x && a.y === b.y; + }; + b2Vec2.DistanceVV = function(a, b) { + var c_x = a.x - b.x; + var c_y = a.y - b.y; + return Math.sqrt(c_x * c_x + c_y * c_y); + }; + b2Vec2.DistanceSquaredVV = function(a, b) { + var c_x = a.x - b.x; + var c_y = a.y - b.y; + return c_x * c_x + c_y * c_y; + }; + b2Vec2.NegV = function(v, out) { + out.x = -v.x; + out.y = -v.y; + return out; + }; + b2Vec2.ZERO = new b2Vec2(0, 0); + b2Vec2.UNITX = new b2Vec2(1, 0); + b2Vec2.UNITY = new b2Vec2(0, 1); + b2Vec2.s_t0 = new b2Vec2(); + b2Vec2.s_t1 = new b2Vec2(); + b2Vec2.s_t2 = new b2Vec2(); + b2Vec2.s_t3 = new b2Vec2(); + return b2Vec2; + })(); + var b2Vec2_zero = new b2Vec2(0, 0); + var b2Vec3 = (function() { + function b2Vec3(x, y, z) { + void 0 === x && (x = 0); + void 0 === y && (y = 0); + void 0 === z && (z = 0); + this.x = x; + this.y = y; + this.z = z; + } + b2Vec3.prototype.Clone = function() { + return new b2Vec3(this.x, this.y, this.z); + }; + b2Vec3.prototype.SetZero = function() { + this.x = 0; + this.y = 0; + this.z = 0; + return this; + }; + b2Vec3.prototype.SetXYZ = function(x, y, z) { + this.x = x; + this.y = y; + this.z = z; + return this; + }; + b2Vec3.prototype.Copy = function(other) { + this.x = other.x; + this.y = other.y; + this.z = other.z; + return this; + }; + b2Vec3.prototype.SelfNeg = function() { + this.x = -this.x; + this.y = -this.y; + this.z = -this.z; + return this; + }; + b2Vec3.prototype.SelfAdd = function(v) { + this.x += v.x; + this.y += v.y; + this.z += v.z; + return this; + }; + b2Vec3.prototype.SelfAddXYZ = function(x, y, z) { + this.x += x; + this.y += y; + this.z += z; + return this; + }; + b2Vec3.prototype.SelfSub = function(v) { + this.x -= v.x; + this.y -= v.y; + this.z -= v.z; + return this; + }; + b2Vec3.prototype.SelfSubXYZ = function(x, y, z) { + this.x -= x; + this.y -= y; + this.z -= z; + return this; + }; + b2Vec3.prototype.SelfMul = function(s) { + this.x *= s; + this.y *= s; + this.z *= s; + return this; + }; + b2Vec3.DotV3V3 = function(a, b) { + return a.x * b.x + a.y * b.y + a.z * b.z; + }; + b2Vec3.CrossV3V3 = function(a, b, out) { + var a_x = a.x, a_y = a.y, a_z = a.z; + var b_x = b.x, b_y = b.y, b_z = b.z; + out.x = a_y * b_z - a_z * b_y; + out.y = a_z * b_x - a_x * b_z; + out.z = a_x * b_y - a_y * b_x; + return out; + }; + b2Vec3.ZERO = new b2Vec3(0, 0, 0); + b2Vec3.s_t0 = new b2Vec3(); + return b2Vec3; + })(); + var b2Mat22 = (function() { + function b2Mat22() { + this.ex = new b2Vec2(1, 0); + this.ey = new b2Vec2(0, 1); + } + b2Mat22.prototype.Clone = function() { + return new b2Mat22().Copy(this); + }; + b2Mat22.FromVV = function(c1, c2) { + return new b2Mat22().SetVV(c1, c2); + }; + b2Mat22.FromSSSS = function(r1c1, r1c2, r2c1, r2c2) { + return new b2Mat22().SetSSSS(r1c1, r1c2, r2c1, r2c2); + }; + b2Mat22.FromAngle = function(radians) { + return new b2Mat22().SetAngle(radians); + }; + b2Mat22.prototype.SetSSSS = function(r1c1, r1c2, r2c1, r2c2) { + this.ex.Set(r1c1, r2c1); + this.ey.Set(r1c2, r2c2); + return this; + }; + b2Mat22.prototype.SetVV = function(c1, c2) { + this.ex.Copy(c1); + this.ey.Copy(c2); + return this; + }; + b2Mat22.prototype.SetAngle = function(radians) { + var c = Math.cos(radians); + var s = Math.sin(radians); + this.ex.Set(c, s); + this.ey.Set(-s, c); + return this; + }; + b2Mat22.prototype.Copy = function(other) { + this.ex.Copy(other.ex); + this.ey.Copy(other.ey); + return this; + }; + b2Mat22.prototype.SetIdentity = function() { + this.ex.Set(1, 0); + this.ey.Set(0, 1); + return this; + }; + b2Mat22.prototype.SetZero = function() { + this.ex.SetZero(); + this.ey.SetZero(); + return this; + }; + b2Mat22.prototype.GetAngle = function() { + return Math.atan2(this.ex.y, this.ex.x); + }; + b2Mat22.prototype.GetInverse = function(out) { + var a = this.ex.x; + var b = this.ey.x; + var c = this.ex.y; + var d = this.ey.y; + var det = a * d - b * c; + 0 !== det && (det = 1 / det); + out.ex.x = det * d; + out.ey.x = -det * b; + out.ex.y = -det * c; + out.ey.y = det * a; + return out; + }; + b2Mat22.prototype.Solve = function(b_x, b_y, out) { + var a11 = this.ex.x, a12 = this.ey.x; + var a21 = this.ex.y, a22 = this.ey.y; + var det = a11 * a22 - a12 * a21; + 0 !== det && (det = 1 / det); + out.x = det * (a22 * b_x - a12 * b_y); + out.y = det * (a11 * b_y - a21 * b_x); + return out; + }; + b2Mat22.prototype.SelfAbs = function() { + this.ex.SelfAbs(); + this.ey.SelfAbs(); + return this; + }; + b2Mat22.prototype.SelfInv = function() { + this.GetInverse(this); + return this; + }; + b2Mat22.prototype.SelfAddM = function(M) { + this.ex.SelfAdd(M.ex); + this.ey.SelfAdd(M.ey); + return this; + }; + b2Mat22.prototype.SelfSubM = function(M) { + this.ex.SelfSub(M.ex); + this.ey.SelfSub(M.ey); + return this; + }; + b2Mat22.AbsM = function(M, out) { + var M_ex = M.ex, M_ey = M.ey; + out.ex.x = b2Abs(M_ex.x); + out.ex.y = b2Abs(M_ex.y); + out.ey.x = b2Abs(M_ey.x); + out.ey.y = b2Abs(M_ey.y); + return out; + }; + b2Mat22.MulMV = function(M, v, out) { + var M_ex = M.ex, M_ey = M.ey; + var v_x = v.x, v_y = v.y; + out.x = M_ex.x * v_x + M_ey.x * v_y; + out.y = M_ex.y * v_x + M_ey.y * v_y; + return out; + }; + b2Mat22.MulTMV = function(M, v, out) { + var M_ex = M.ex, M_ey = M.ey; + var v_x = v.x, v_y = v.y; + out.x = M_ex.x * v_x + M_ex.y * v_y; + out.y = M_ey.x * v_x + M_ey.y * v_y; + return out; + }; + b2Mat22.AddMM = function(A, B, out) { + var A_ex = A.ex, A_ey = A.ey; + var B_ex = B.ex, B_ey = B.ey; + out.ex.x = A_ex.x + B_ex.x; + out.ex.y = A_ex.y + B_ex.y; + out.ey.x = A_ey.x + B_ey.x; + out.ey.y = A_ey.y + B_ey.y; + return out; + }; + b2Mat22.MulMM = function(A, B, out) { + var A_ex_x = A.ex.x, A_ex_y = A.ex.y; + var A_ey_x = A.ey.x, A_ey_y = A.ey.y; + var B_ex_x = B.ex.x, B_ex_y = B.ex.y; + var B_ey_x = B.ey.x, B_ey_y = B.ey.y; + out.ex.x = A_ex_x * B_ex_x + A_ey_x * B_ex_y; + out.ex.y = A_ex_y * B_ex_x + A_ey_y * B_ex_y; + out.ey.x = A_ex_x * B_ey_x + A_ey_x * B_ey_y; + out.ey.y = A_ex_y * B_ey_x + A_ey_y * B_ey_y; + return out; + }; + b2Mat22.MulTMM = function(A, B, out) { + var A_ex_x = A.ex.x, A_ex_y = A.ex.y; + var A_ey_x = A.ey.x, A_ey_y = A.ey.y; + var B_ex_x = B.ex.x, B_ex_y = B.ex.y; + var B_ey_x = B.ey.x, B_ey_y = B.ey.y; + out.ex.x = A_ex_x * B_ex_x + A_ex_y * B_ex_y; + out.ex.y = A_ey_x * B_ex_x + A_ey_y * B_ex_y; + out.ey.x = A_ex_x * B_ey_x + A_ex_y * B_ey_y; + out.ey.y = A_ey_x * B_ey_x + A_ey_y * B_ey_y; + return out; + }; + b2Mat22.IDENTITY = new b2Mat22(); + return b2Mat22; + })(); + var b2Mat33 = (function() { + function b2Mat33() { + this.ex = new b2Vec3(1, 0, 0); + this.ey = new b2Vec3(0, 1, 0); + this.ez = new b2Vec3(0, 0, 1); + } + b2Mat33.prototype.Clone = function() { + return new b2Mat33().Copy(this); + }; + b2Mat33.prototype.SetVVV = function(c1, c2, c3) { + this.ex.Copy(c1); + this.ey.Copy(c2); + this.ez.Copy(c3); + return this; + }; + b2Mat33.prototype.Copy = function(other) { + this.ex.Copy(other.ex); + this.ey.Copy(other.ey); + this.ez.Copy(other.ez); + return this; + }; + b2Mat33.prototype.SetIdentity = function() { + this.ex.SetXYZ(1, 0, 0); + this.ey.SetXYZ(0, 1, 0); + this.ez.SetXYZ(0, 0, 1); + return this; + }; + b2Mat33.prototype.SetZero = function() { + this.ex.SetZero(); + this.ey.SetZero(); + this.ez.SetZero(); + return this; + }; + b2Mat33.prototype.SelfAddM = function(M) { + this.ex.SelfAdd(M.ex); + this.ey.SelfAdd(M.ey); + this.ez.SelfAdd(M.ez); + return this; + }; + b2Mat33.prototype.Solve33 = function(b_x, b_y, b_z, out) { + var a11 = this.ex.x, a21 = this.ex.y, a31 = this.ex.z; + var a12 = this.ey.x, a22 = this.ey.y, a32 = this.ey.z; + var a13 = this.ez.x, a23 = this.ez.y, a33 = this.ez.z; + var det = a11 * (a22 * a33 - a32 * a23) + a21 * (a32 * a13 - a12 * a33) + a31 * (a12 * a23 - a22 * a13); + 0 !== det && (det = 1 / det); + out.x = det * (b_x * (a22 * a33 - a32 * a23) + b_y * (a32 * a13 - a12 * a33) + b_z * (a12 * a23 - a22 * a13)); + out.y = det * (a11 * (b_y * a33 - b_z * a23) + a21 * (b_z * a13 - b_x * a33) + a31 * (b_x * a23 - b_y * a13)); + out.z = det * (a11 * (a22 * b_z - a32 * b_y) + a21 * (a32 * b_x - a12 * b_z) + a31 * (a12 * b_y - a22 * b_x)); + return out; + }; + b2Mat33.prototype.Solve22 = function(b_x, b_y, out) { + var a11 = this.ex.x, a12 = this.ey.x; + var a21 = this.ex.y, a22 = this.ey.y; + var det = a11 * a22 - a12 * a21; + 0 !== det && (det = 1 / det); + out.x = det * (a22 * b_x - a12 * b_y); + out.y = det * (a11 * b_y - a21 * b_x); + return out; + }; + b2Mat33.prototype.GetInverse22 = function(M) { + var a = this.ex.x, b = this.ey.x, c = this.ex.y, d = this.ey.y; + var det = a * d - b * c; + 0 !== det && (det = 1 / det); + M.ex.x = det * d; + M.ey.x = -det * b; + M.ex.z = 0; + M.ex.y = -det * c; + M.ey.y = det * a; + M.ey.z = 0; + M.ez.x = 0; + M.ez.y = 0; + M.ez.z = 0; + }; + b2Mat33.prototype.GetSymInverse33 = function(M) { + var det = b2Vec3.DotV3V3(this.ex, b2Vec3.CrossV3V3(this.ey, this.ez, b2Vec3.s_t0)); + 0 !== det && (det = 1 / det); + var a11 = this.ex.x, a12 = this.ey.x, a13 = this.ez.x; + var a22 = this.ey.y, a23 = this.ez.y; + var a33 = this.ez.z; + M.ex.x = det * (a22 * a33 - a23 * a23); + M.ex.y = det * (a13 * a23 - a12 * a33); + M.ex.z = det * (a12 * a23 - a13 * a22); + M.ey.x = M.ex.y; + M.ey.y = det * (a11 * a33 - a13 * a13); + M.ey.z = det * (a13 * a12 - a11 * a23); + M.ez.x = M.ex.z; + M.ez.y = M.ey.z; + M.ez.z = det * (a11 * a22 - a12 * a12); + }; + b2Mat33.MulM33V3 = function(A, v, out) { + var v_x = v.x, v_y = v.y, v_z = v.z; + out.x = A.ex.x * v_x + A.ey.x * v_y + A.ez.x * v_z; + out.y = A.ex.y * v_x + A.ey.y * v_y + A.ez.y * v_z; + out.z = A.ex.z * v_x + A.ey.z * v_y + A.ez.z * v_z; + return out; + }; + b2Mat33.MulM33XYZ = function(A, x, y, z, out) { + out.x = A.ex.x * x + A.ey.x * y + A.ez.x * z; + out.y = A.ex.y * x + A.ey.y * y + A.ez.y * z; + out.z = A.ex.z * x + A.ey.z * y + A.ez.z * z; + return out; + }; + b2Mat33.MulM33V2 = function(A, v, out) { + var v_x = v.x, v_y = v.y; + out.x = A.ex.x * v_x + A.ey.x * v_y; + out.y = A.ex.y * v_x + A.ey.y * v_y; + return out; + }; + b2Mat33.MulM33XY = function(A, x, y, out) { + out.x = A.ex.x * x + A.ey.x * y; + out.y = A.ex.y * x + A.ey.y * y; + return out; + }; + b2Mat33.IDENTITY = new b2Mat33(); + return b2Mat33; + })(); + var b2Rot = (function() { + function b2Rot(angle) { + void 0 === angle && (angle = 0); + this.s = 0; + this.c = 1; + if (angle) { + this.s = Math.sin(angle); + this.c = Math.cos(angle); + } + } + b2Rot.prototype.Clone = function() { + return new b2Rot().Copy(this); + }; + b2Rot.prototype.Copy = function(other) { + this.s = other.s; + this.c = other.c; + return this; + }; + b2Rot.prototype.SetAngle = function(angle) { + this.s = Math.sin(angle); + this.c = Math.cos(angle); + return this; + }; + b2Rot.prototype.SetIdentity = function() { + this.s = 0; + this.c = 1; + return this; + }; + b2Rot.prototype.GetAngle = function() { + return Math.atan2(this.s, this.c); + }; + b2Rot.prototype.GetXAxis = function(out) { + out.x = this.c; + out.y = this.s; + return out; + }; + b2Rot.prototype.GetYAxis = function(out) { + out.x = -this.s; + out.y = this.c; + return out; + }; + b2Rot.MulRR = function(q, r, out) { + var q_c = q.c, q_s = q.s; + var r_c = r.c, r_s = r.s; + out.s = q_s * r_c + q_c * r_s; + out.c = q_c * r_c - q_s * r_s; + return out; + }; + b2Rot.MulTRR = function(q, r, out) { + var q_c = q.c, q_s = q.s; + var r_c = r.c, r_s = r.s; + out.s = q_c * r_s - q_s * r_c; + out.c = q_c * r_c + q_s * r_s; + return out; + }; + b2Rot.MulRV = function(q, v, out) { + var q_c = q.c, q_s = q.s; + var v_x = v.x, v_y = v.y; + out.x = q_c * v_x - q_s * v_y; + out.y = q_s * v_x + q_c * v_y; + return out; + }; + b2Rot.MulTRV = function(q, v, out) { + var q_c = q.c, q_s = q.s; + var v_x = v.x, v_y = v.y; + out.x = q_c * v_x + q_s * v_y; + out.y = -q_s * v_x + q_c * v_y; + return out; + }; + b2Rot.IDENTITY = new b2Rot(); + return b2Rot; + })(); + var b2Transform = (function() { + function b2Transform() { + this.p = new b2Vec2(); + this.q = new b2Rot(); + } + b2Transform.prototype.Clone = function() { + return new b2Transform().Copy(this); + }; + b2Transform.prototype.Copy = function(other) { + this.p.Copy(other.p); + this.q.Copy(other.q); + return this; + }; + b2Transform.prototype.SetIdentity = function() { + this.p.SetZero(); + this.q.SetIdentity(); + return this; + }; + b2Transform.prototype.SetPositionRotation = function(position, q) { + this.p.Copy(position); + this.q.Copy(q); + return this; + }; + b2Transform.prototype.SetPositionAngle = function(pos, a) { + this.p.Copy(pos); + this.q.SetAngle(a); + return this; + }; + b2Transform.prototype.SetPosition = function(position) { + this.p.Copy(position); + return this; + }; + b2Transform.prototype.SetPositionXY = function(x, y) { + this.p.Set(x, y); + return this; + }; + b2Transform.prototype.SetRotation = function(rotation) { + this.q.Copy(rotation); + return this; + }; + b2Transform.prototype.SetRotationAngle = function(radians) { + this.q.SetAngle(radians); + return this; + }; + b2Transform.prototype.GetPosition = function() { + return this.p; + }; + b2Transform.prototype.GetRotation = function() { + return this.q; + }; + b2Transform.prototype.GetRotationAngle = function() { + return this.q.GetAngle(); + }; + b2Transform.prototype.GetAngle = function() { + return this.q.GetAngle(); + }; + b2Transform.MulXV = function(T, v, out) { + var T_q_c = T.q.c, T_q_s = T.q.s; + var v_x = v.x, v_y = v.y; + out.x = T_q_c * v_x - T_q_s * v_y + T.p.x; + out.y = T_q_s * v_x + T_q_c * v_y + T.p.y; + return out; + }; + b2Transform.MulTXV = function(T, v, out) { + var T_q_c = T.q.c, T_q_s = T.q.s; + var p_x = v.x - T.p.x; + var p_y = v.y - T.p.y; + out.x = T_q_c * p_x + T_q_s * p_y; + out.y = -T_q_s * p_x + T_q_c * p_y; + return out; + }; + b2Transform.MulXX = function(A, B, out) { + b2Rot.MulRR(A.q, B.q, out.q); + b2Vec2.AddVV(b2Rot.MulRV(A.q, B.p, out.p), A.p, out.p); + return out; + }; + b2Transform.MulTXX = function(A, B, out) { + b2Rot.MulTRR(A.q, B.q, out.q); + b2Rot.MulTRV(A.q, b2Vec2.SubVV(B.p, A.p, out.p), out.p); + return out; + }; + b2Transform.IDENTITY = new b2Transform(); + return b2Transform; + })(); + var b2Sweep = (function() { + function b2Sweep() { + this.localCenter = new b2Vec2(); + this.c0 = new b2Vec2(); + this.c = new b2Vec2(); + this.a0 = 0; + this.a = 0; + this.alpha0 = 0; + } + b2Sweep.prototype.Clone = function() { + return new b2Sweep().Copy(this); + }; + b2Sweep.prototype.Copy = function(other) { + this.localCenter.Copy(other.localCenter); + this.c0.Copy(other.c0); + this.c.Copy(other.c); + this.a0 = other.a0; + this.a = other.a; + this.alpha0 = other.alpha0; + return this; + }; + b2Sweep.prototype.GetTransform = function(xf, beta) { + var one_minus_beta = 1 - beta; + xf.p.x = one_minus_beta * this.c0.x + beta * this.c.x; + xf.p.y = one_minus_beta * this.c0.y + beta * this.c.y; + var angle = one_minus_beta * this.a0 + beta * this.a; + xf.q.SetAngle(angle); + xf.p.SelfSub(b2Rot.MulRV(xf.q, this.localCenter, b2Vec2.s_t0)); + return xf; + }; + b2Sweep.prototype.Advance = function(alpha) { + var beta = (alpha - this.alpha0) / (1 - this.alpha0); + var one_minus_beta = 1 - beta; + this.c0.x = one_minus_beta * this.c0.x + beta * this.c.x; + this.c0.y = one_minus_beta * this.c0.y + beta * this.c.y; + this.a0 = one_minus_beta * this.a0 + beta * this.a; + this.alpha0 = alpha; + }; + b2Sweep.prototype.Normalize = function() { + var d = b2_two_pi * Math.floor(this.a0 / b2_two_pi); + this.a0 -= d; + this.a -= d; + }; + return b2Sweep; + })(); + var b2Color = (function() { + function b2Color(rr, gg, bb, aa) { + void 0 === rr && (rr = .5); + void 0 === gg && (gg = .5); + void 0 === bb && (bb = .5); + void 0 === aa && (aa = 1); + this.r = rr; + this.g = gg; + this.b = bb; + this.a = aa; + } + b2Color.prototype.Clone = function() { + return new b2Color().Copy(this); + }; + b2Color.prototype.Copy = function(other) { + this.r = other.r; + this.g = other.g; + this.b = other.b; + this.a = other.a; + return this; + }; + b2Color.prototype.IsEqual = function(color) { + return this.r === color.r && this.g === color.g && this.b === color.b && this.a === color.a; + }; + b2Color.prototype.IsZero = function() { + return 0 === this.r && 0 === this.g && 0 === this.b && 0 === this.a; + }; + b2Color.prototype.Set = function(r, g, b, a) { + void 0 === a && (a = this.a); + this.SetRGBA(r, g, b, a); + }; + b2Color.prototype.SetByteRGB = function(r, g, b) { + this.r = r / 255; + this.g = g / 255; + this.b = b / 255; + return this; + }; + b2Color.prototype.SetByteRGBA = function(r, g, b, a) { + this.r = r / 255; + this.g = g / 255; + this.b = b / 255; + this.a = a / 255; + return this; + }; + b2Color.prototype.SetRGB = function(rr, gg, bb) { + this.r = rr; + this.g = gg; + this.b = bb; + return this; + }; + b2Color.prototype.SetRGBA = function(rr, gg, bb, aa) { + this.r = rr; + this.g = gg; + this.b = bb; + this.a = aa; + return this; + }; + b2Color.prototype.SelfAdd = function(color) { + this.r += color.r; + this.g += color.g; + this.b += color.b; + this.a += color.a; + return this; + }; + b2Color.prototype.Add = function(color, out) { + out.r = this.r + color.r; + out.g = this.g + color.g; + out.b = this.b + color.b; + out.a = this.a + color.a; + return out; + }; + b2Color.prototype.SelfSub = function(color) { + this.r -= color.r; + this.g -= color.g; + this.b -= color.b; + this.a -= color.a; + return this; + }; + b2Color.prototype.Sub = function(color, out) { + out.r = this.r - color.r; + out.g = this.g - color.g; + out.b = this.b - color.b; + out.a = this.a - color.a; + return out; + }; + b2Color.prototype.SelfMul = function(s) { + this.r *= s; + this.g *= s; + this.b *= s; + this.a *= s; + return this; + }; + b2Color.prototype.Mul = function(s, out) { + out.r = this.r * s; + out.g = this.g * s; + out.b = this.b * s; + out.a = this.a * s; + return out; + }; + b2Color.prototype.Mix = function(mixColor, strength) { + b2Color.MixColors(this, mixColor, strength); + }; + b2Color.MixColors = function(colorA, colorB, strength) { + var dr = strength * (colorB.r - colorA.r); + var dg = strength * (colorB.g - colorA.g); + var db = strength * (colorB.b - colorA.b); + var da = strength * (colorB.a - colorA.a); + colorA.r += dr; + colorA.g += dg; + colorA.b += db; + colorA.a += da; + colorB.r -= dr; + colorB.g -= dg; + colorB.b -= db; + colorB.a -= da; + }; + b2Color.prototype.MakeStyleString = function(alpha) { + void 0 === alpha && (alpha = this.a); + return b2Color.MakeStyleString(this.r, this.g, this.b, alpha); + }; + b2Color.MakeStyleString = function(r, g, b, a) { + void 0 === a && (a = 1); + r *= 255; + g *= 255; + b *= 255; + return a < 1 ? "rgba(" + r + "," + g + "," + b + "," + a + ")" : "rgb(" + r + "," + g + "," + b + ")"; + }; + b2Color.ZERO = new b2Color(0, 0, 0, 0); + b2Color.RED = new b2Color(1, 0, 0); + b2Color.GREEN = new b2Color(0, 1, 0); + b2Color.BLUE = new b2Color(0, 0, 1); + return b2Color; + })(); + (function(b2DrawFlags) { + b2DrawFlags[b2DrawFlags["e_none"] = 0] = "e_none"; + b2DrawFlags[b2DrawFlags["e_shapeBit"] = 1] = "e_shapeBit"; + b2DrawFlags[b2DrawFlags["e_jointBit"] = 2] = "e_jointBit"; + b2DrawFlags[b2DrawFlags["e_aabbBit"] = 4] = "e_aabbBit"; + b2DrawFlags[b2DrawFlags["e_pairBit"] = 8] = "e_pairBit"; + b2DrawFlags[b2DrawFlags["e_centerOfMassBit"] = 16] = "e_centerOfMassBit"; + b2DrawFlags[b2DrawFlags["e_particleBit"] = 32] = "e_particleBit"; + b2DrawFlags[b2DrawFlags["e_controllerBit"] = 64] = "e_controllerBit"; + b2DrawFlags[b2DrawFlags["e_all"] = 63] = "e_all"; + })(exports.b2DrawFlags || (exports.b2DrawFlags = {})); + var b2Draw = (function() { + function b2Draw() { + this.m_drawFlags = 0; + } + b2Draw.prototype.SetFlags = function(flags) { + this.m_drawFlags = flags; + }; + b2Draw.prototype.GetFlags = function() { + return this.m_drawFlags; + }; + b2Draw.prototype.AppendFlags = function(flags) { + this.m_drawFlags |= flags; + }; + b2Draw.prototype.ClearFlags = function(flags) { + this.m_drawFlags &= ~flags; + }; + return b2Draw; + })(); + var b2Timer = (function() { + function b2Timer() { + this.m_start = Date.now(); + } + b2Timer.prototype.Reset = function() { + this.m_start = Date.now(); + return this; + }; + b2Timer.prototype.GetMilliseconds = function() { + return Date.now() - this.m_start; + }; + return b2Timer; + })(); + var b2Counter = (function() { + function b2Counter() { + this.m_count = 0; + this.m_min_count = 0; + this.m_max_count = 0; + } + b2Counter.prototype.GetCount = function() { + return this.m_count; + }; + b2Counter.prototype.GetMinCount = function() { + return this.m_min_count; + }; + b2Counter.prototype.GetMaxCount = function() { + return this.m_max_count; + }; + b2Counter.prototype.ResetCount = function() { + var count = this.m_count; + this.m_count = 0; + return count; + }; + b2Counter.prototype.ResetMinCount = function() { + this.m_min_count = 0; + }; + b2Counter.prototype.ResetMaxCount = function() { + this.m_max_count = 0; + }; + b2Counter.prototype.Increment = function() { + this.m_count++; + this.m_max_count < this.m_count && (this.m_max_count = this.m_count); + }; + b2Counter.prototype.Decrement = function() { + this.m_count--; + this.m_min_count > this.m_count && (this.m_min_count = this.m_count); + }; + return b2Counter; + })(); + var b2GrowableStack = (function() { + function b2GrowableStack(N) { + this.m_stack = []; + this.m_count = 0; + this.m_stack = b2MakeArray(N, (function(index) { + return null; + })); + this.m_count = 0; + } + b2GrowableStack.prototype.Reset = function() { + this.m_count = 0; + return this; + }; + b2GrowableStack.prototype.Push = function(element) { + this.m_stack[this.m_count] = element; + this.m_count++; + }; + b2GrowableStack.prototype.Pop = function() { + this.m_count--; + var element = this.m_stack[this.m_count]; + this.m_stack[this.m_count] = null; + if (null === element) throw new Error(); + return element; + }; + b2GrowableStack.prototype.GetCount = function() { + return this.m_count; + }; + return b2GrowableStack; + })(); + var b2BlockAllocator = (function() { + function b2BlockAllocator() {} + return b2BlockAllocator; + })(); + var b2StackAllocator = (function() { + function b2StackAllocator() {} + return b2StackAllocator; + })(); + var b2DistanceProxy = (function() { + function b2DistanceProxy() { + this.m_buffer = b2Vec2.MakeArray(2); + this.m_vertices = this.m_buffer; + this.m_count = 0; + this.m_radius = 0; + } + b2DistanceProxy.prototype.Copy = function(other) { + if (other.m_vertices === other.m_buffer) { + this.m_vertices = this.m_buffer; + this.m_buffer[0].Copy(other.m_buffer[0]); + this.m_buffer[1].Copy(other.m_buffer[1]); + } else this.m_vertices = other.m_vertices; + this.m_count = other.m_count; + this.m_radius = other.m_radius; + return this; + }; + b2DistanceProxy.prototype.Reset = function() { + this.m_vertices = this.m_buffer; + this.m_count = 0; + this.m_radius = 0; + return this; + }; + b2DistanceProxy.prototype.SetShape = function(shape, index) { + shape.SetupDistanceProxy(this, index); + }; + b2DistanceProxy.prototype.SetVerticesRadius = function(vertices, count, radius) { + this.m_vertices = vertices; + this.m_count = count; + this.m_radius = radius; + }; + b2DistanceProxy.prototype.GetSupport = function(d) { + var bestIndex = 0; + var bestValue = b2Vec2.DotVV(this.m_vertices[0], d); + for (var i = 1; i < this.m_count; ++i) { + var value = b2Vec2.DotVV(this.m_vertices[i], d); + if (value > bestValue) { + bestIndex = i; + bestValue = value; + } + } + return bestIndex; + }; + b2DistanceProxy.prototype.GetSupportVertex = function(d) { + var bestIndex = 0; + var bestValue = b2Vec2.DotVV(this.m_vertices[0], d); + for (var i = 1; i < this.m_count; ++i) { + var value = b2Vec2.DotVV(this.m_vertices[i], d); + if (value > bestValue) { + bestIndex = i; + bestValue = value; + } + } + return this.m_vertices[bestIndex]; + }; + b2DistanceProxy.prototype.GetVertexCount = function() { + return this.m_count; + }; + b2DistanceProxy.prototype.GetVertex = function(index) { + return this.m_vertices[index]; + }; + return b2DistanceProxy; + })(); + var b2SimplexCache = (function() { + function b2SimplexCache() { + this.metric = 0; + this.count = 0; + this.indexA = [ 0, 0, 0 ]; + this.indexB = [ 0, 0, 0 ]; + } + b2SimplexCache.prototype.Reset = function() { + this.metric = 0; + this.count = 0; + return this; + }; + return b2SimplexCache; + })(); + var b2DistanceInput = (function() { + function b2DistanceInput() { + this.proxyA = new b2DistanceProxy(); + this.proxyB = new b2DistanceProxy(); + this.transformA = new b2Transform(); + this.transformB = new b2Transform(); + this.useRadii = false; + } + b2DistanceInput.prototype.Reset = function() { + this.proxyA.Reset(); + this.proxyB.Reset(); + this.transformA.SetIdentity(); + this.transformB.SetIdentity(); + this.useRadii = false; + return this; + }; + return b2DistanceInput; + })(); + var b2DistanceOutput = (function() { + function b2DistanceOutput() { + this.pointA = new b2Vec2(); + this.pointB = new b2Vec2(); + this.distance = 0; + this.iterations = 0; + } + b2DistanceOutput.prototype.Reset = function() { + this.pointA.SetZero(); + this.pointB.SetZero(); + this.distance = 0; + this.iterations = 0; + return this; + }; + return b2DistanceOutput; + })(); + var b2ShapeCastInput = (function() { + function b2ShapeCastInput() { + this.proxyA = new b2DistanceProxy(); + this.proxyB = new b2DistanceProxy(); + this.transformA = new b2Transform(); + this.transformB = new b2Transform(); + this.translationB = new b2Vec2(); + } + return b2ShapeCastInput; + })(); + var b2ShapeCastOutput = (function() { + function b2ShapeCastOutput() { + this.point = new b2Vec2(); + this.normal = new b2Vec2(); + this.lambda = 0; + this.iterations = 0; + } + return b2ShapeCastOutput; + })(); + exports.b2_gjkCalls = 0; + exports.b2_gjkIters = 0; + exports.b2_gjkMaxIters = 0; + function b2_gjk_reset() { + exports.b2_gjkCalls = 0; + exports.b2_gjkIters = 0; + exports.b2_gjkMaxIters = 0; + } + var b2SimplexVertex = (function() { + function b2SimplexVertex() { + this.wA = new b2Vec2(); + this.wB = new b2Vec2(); + this.w = new b2Vec2(); + this.a = 0; + this.indexA = 0; + this.indexB = 0; + } + b2SimplexVertex.prototype.Copy = function(other) { + this.wA.Copy(other.wA); + this.wB.Copy(other.wB); + this.w.Copy(other.w); + this.a = other.a; + this.indexA = other.indexA; + this.indexB = other.indexB; + return this; + }; + return b2SimplexVertex; + })(); + var b2Simplex = (function() { + function b2Simplex() { + this.m_v1 = new b2SimplexVertex(); + this.m_v2 = new b2SimplexVertex(); + this.m_v3 = new b2SimplexVertex(); + this.m_vertices = []; + this.m_count = 0; + this.m_vertices[0] = this.m_v1; + this.m_vertices[1] = this.m_v2; + this.m_vertices[2] = this.m_v3; + } + b2Simplex.prototype.ReadCache = function(cache, proxyA, transformA, proxyB, transformB) { + this.m_count = cache.count; + var vertices = this.m_vertices; + for (var i = 0; i < this.m_count; ++i) { + var v = vertices[i]; + v.indexA = cache.indexA[i]; + v.indexB = cache.indexB[i]; + var wALocal = proxyA.GetVertex(v.indexA); + var wBLocal = proxyB.GetVertex(v.indexB); + b2Transform.MulXV(transformA, wALocal, v.wA); + b2Transform.MulXV(transformB, wBLocal, v.wB); + b2Vec2.SubVV(v.wB, v.wA, v.w); + v.a = 0; + } + if (this.m_count > 1) { + var metric1 = cache.metric; + var metric2 = this.GetMetric(); + (metric2 < .5 * metric1 || 2 * metric1 < metric2 || metric2 < b2_epsilon) && (this.m_count = 0); + } + if (0 === this.m_count) { + var v = vertices[0]; + v.indexA = 0; + v.indexB = 0; + var wALocal = proxyA.GetVertex(0); + var wBLocal = proxyB.GetVertex(0); + b2Transform.MulXV(transformA, wALocal, v.wA); + b2Transform.MulXV(transformB, wBLocal, v.wB); + b2Vec2.SubVV(v.wB, v.wA, v.w); + v.a = 1; + this.m_count = 1; + } + }; + b2Simplex.prototype.WriteCache = function(cache) { + cache.metric = this.GetMetric(); + cache.count = this.m_count; + var vertices = this.m_vertices; + for (var i = 0; i < this.m_count; ++i) { + cache.indexA[i] = vertices[i].indexA; + cache.indexB[i] = vertices[i].indexB; + } + }; + b2Simplex.prototype.GetSearchDirection = function(out) { + switch (this.m_count) { + case 1: + return b2Vec2.NegV(this.m_v1.w, out); + + case 2: + var e12 = b2Vec2.SubVV(this.m_v2.w, this.m_v1.w, out); + var sgn = b2Vec2.CrossVV(e12, b2Vec2.NegV(this.m_v1.w, b2Vec2.s_t0)); + return sgn > 0 ? b2Vec2.CrossOneV(e12, out) : b2Vec2.CrossVOne(e12, out); + + default: + return out.SetZero(); + } + }; + b2Simplex.prototype.GetClosestPoint = function(out) { + switch (this.m_count) { + case 0: + return out.SetZero(); + + case 1: + return out.Copy(this.m_v1.w); + + case 2: + return out.Set(this.m_v1.a * this.m_v1.w.x + this.m_v2.a * this.m_v2.w.x, this.m_v1.a * this.m_v1.w.y + this.m_v2.a * this.m_v2.w.y); + + case 3: + default: + return out.SetZero(); + } + }; + b2Simplex.prototype.GetWitnessPoints = function(pA, pB) { + switch (this.m_count) { + case 0: + break; + + case 1: + pA.Copy(this.m_v1.wA); + pB.Copy(this.m_v1.wB); + break; + + case 2: + pA.x = this.m_v1.a * this.m_v1.wA.x + this.m_v2.a * this.m_v2.wA.x; + pA.y = this.m_v1.a * this.m_v1.wA.y + this.m_v2.a * this.m_v2.wA.y; + pB.x = this.m_v1.a * this.m_v1.wB.x + this.m_v2.a * this.m_v2.wB.x; + pB.y = this.m_v1.a * this.m_v1.wB.y + this.m_v2.a * this.m_v2.wB.y; + break; + + case 3: + pB.x = pA.x = this.m_v1.a * this.m_v1.wA.x + this.m_v2.a * this.m_v2.wA.x + this.m_v3.a * this.m_v3.wA.x; + pB.y = pA.y = this.m_v1.a * this.m_v1.wA.y + this.m_v2.a * this.m_v2.wA.y + this.m_v3.a * this.m_v3.wA.y; + } + }; + b2Simplex.prototype.GetMetric = function() { + switch (this.m_count) { + case 0: + case 1: + return 0; + + case 2: + return b2Vec2.DistanceVV(this.m_v1.w, this.m_v2.w); + + case 3: + return b2Vec2.CrossVV(b2Vec2.SubVV(this.m_v2.w, this.m_v1.w, b2Vec2.s_t0), b2Vec2.SubVV(this.m_v3.w, this.m_v1.w, b2Vec2.s_t1)); + + default: + return 0; + } + }; + b2Simplex.prototype.Solve2 = function() { + var w1 = this.m_v1.w; + var w2 = this.m_v2.w; + var e12 = b2Vec2.SubVV(w2, w1, b2Simplex.s_e12); + var d12_2 = -b2Vec2.DotVV(w1, e12); + if (d12_2 <= 0) { + this.m_v1.a = 1; + this.m_count = 1; + return; + } + var d12_1 = b2Vec2.DotVV(w2, e12); + if (d12_1 <= 0) { + this.m_v2.a = 1; + this.m_count = 1; + this.m_v1.Copy(this.m_v2); + return; + } + var inv_d12 = 1 / (d12_1 + d12_2); + this.m_v1.a = d12_1 * inv_d12; + this.m_v2.a = d12_2 * inv_d12; + this.m_count = 2; + }; + b2Simplex.prototype.Solve3 = function() { + var w1 = this.m_v1.w; + var w2 = this.m_v2.w; + var w3 = this.m_v3.w; + var e12 = b2Vec2.SubVV(w2, w1, b2Simplex.s_e12); + var w1e12 = b2Vec2.DotVV(w1, e12); + var w2e12 = b2Vec2.DotVV(w2, e12); + var d12_1 = w2e12; + var d12_2 = -w1e12; + var e13 = b2Vec2.SubVV(w3, w1, b2Simplex.s_e13); + var w1e13 = b2Vec2.DotVV(w1, e13); + var w3e13 = b2Vec2.DotVV(w3, e13); + var d13_1 = w3e13; + var d13_2 = -w1e13; + var e23 = b2Vec2.SubVV(w3, w2, b2Simplex.s_e23); + var w2e23 = b2Vec2.DotVV(w2, e23); + var w3e23 = b2Vec2.DotVV(w3, e23); + var d23_1 = w3e23; + var d23_2 = -w2e23; + var n123 = b2Vec2.CrossVV(e12, e13); + var d123_1 = n123 * b2Vec2.CrossVV(w2, w3); + var d123_2 = n123 * b2Vec2.CrossVV(w3, w1); + var d123_3 = n123 * b2Vec2.CrossVV(w1, w2); + if (d12_2 <= 0 && d13_2 <= 0) { + this.m_v1.a = 1; + this.m_count = 1; + return; + } + if (d12_1 > 0 && d12_2 > 0 && d123_3 <= 0) { + var inv_d12 = 1 / (d12_1 + d12_2); + this.m_v1.a = d12_1 * inv_d12; + this.m_v2.a = d12_2 * inv_d12; + this.m_count = 2; + return; + } + if (d13_1 > 0 && d13_2 > 0 && d123_2 <= 0) { + var inv_d13 = 1 / (d13_1 + d13_2); + this.m_v1.a = d13_1 * inv_d13; + this.m_v3.a = d13_2 * inv_d13; + this.m_count = 2; + this.m_v2.Copy(this.m_v3); + return; + } + if (d12_1 <= 0 && d23_2 <= 0) { + this.m_v2.a = 1; + this.m_count = 1; + this.m_v1.Copy(this.m_v2); + return; + } + if (d13_1 <= 0 && d23_1 <= 0) { + this.m_v3.a = 1; + this.m_count = 1; + this.m_v1.Copy(this.m_v3); + return; + } + if (d23_1 > 0 && d23_2 > 0 && d123_1 <= 0) { + var inv_d23 = 1 / (d23_1 + d23_2); + this.m_v2.a = d23_1 * inv_d23; + this.m_v3.a = d23_2 * inv_d23; + this.m_count = 2; + this.m_v1.Copy(this.m_v3); + return; + } + var inv_d123 = 1 / (d123_1 + d123_2 + d123_3); + this.m_v1.a = d123_1 * inv_d123; + this.m_v2.a = d123_2 * inv_d123; + this.m_v3.a = d123_3 * inv_d123; + this.m_count = 3; + }; + b2Simplex.s_e12 = new b2Vec2(); + b2Simplex.s_e13 = new b2Vec2(); + b2Simplex.s_e23 = new b2Vec2(); + return b2Simplex; + })(); + var b2Distance_s_simplex = new b2Simplex(); + var b2Distance_s_saveA = [ 0, 0, 0 ]; + var b2Distance_s_saveB = [ 0, 0, 0 ]; + var b2Distance_s_p = new b2Vec2(); + var b2Distance_s_d = new b2Vec2(); + var b2Distance_s_normal = new b2Vec2(); + var b2Distance_s_supportA = new b2Vec2(); + var b2Distance_s_supportB = new b2Vec2(); + function b2Distance(output, cache, input) { + ++exports.b2_gjkCalls; + var proxyA = input.proxyA; + var proxyB = input.proxyB; + var transformA = input.transformA; + var transformB = input.transformB; + var simplex = b2Distance_s_simplex; + simplex.ReadCache(cache, proxyA, transformA, proxyB, transformB); + var vertices = simplex.m_vertices; + var k_maxIters = 20; + var saveA = b2Distance_s_saveA; + var saveB = b2Distance_s_saveB; + var saveCount = 0; + var iter = 0; + while (iter < k_maxIters) { + saveCount = simplex.m_count; + for (var i = 0; i < saveCount; ++i) { + saveA[i] = vertices[i].indexA; + saveB[i] = vertices[i].indexB; + } + switch (simplex.m_count) { + case 1: + break; + + case 2: + simplex.Solve2(); + break; + + case 3: + simplex.Solve3(); + } + if (3 === simplex.m_count) break; + var d = simplex.GetSearchDirection(b2Distance_s_d); + if (d.LengthSquared() < b2_epsilon_sq) break; + var vertex = vertices[simplex.m_count]; + vertex.indexA = proxyA.GetSupport(b2Rot.MulTRV(transformA.q, b2Vec2.NegV(d, b2Vec2.s_t0), b2Distance_s_supportA)); + b2Transform.MulXV(transformA, proxyA.GetVertex(vertex.indexA), vertex.wA); + vertex.indexB = proxyB.GetSupport(b2Rot.MulTRV(transformB.q, d, b2Distance_s_supportB)); + b2Transform.MulXV(transformB, proxyB.GetVertex(vertex.indexB), vertex.wB); + b2Vec2.SubVV(vertex.wB, vertex.wA, vertex.w); + ++iter; + ++exports.b2_gjkIters; + var duplicate = false; + for (var i = 0; i < saveCount; ++i) if (vertex.indexA === saveA[i] && vertex.indexB === saveB[i]) { + duplicate = true; + break; + } + if (duplicate) break; + ++simplex.m_count; + } + exports.b2_gjkMaxIters = b2Max(exports.b2_gjkMaxIters, iter); + simplex.GetWitnessPoints(output.pointA, output.pointB); + output.distance = b2Vec2.DistanceVV(output.pointA, output.pointB); + output.iterations = iter; + simplex.WriteCache(cache); + if (input.useRadii) { + var rA = proxyA.m_radius; + var rB = proxyB.m_radius; + if (output.distance > rA + rB && output.distance > b2_epsilon) { + output.distance -= rA + rB; + var normal = b2Vec2.SubVV(output.pointB, output.pointA, b2Distance_s_normal); + normal.Normalize(); + output.pointA.SelfMulAdd(rA, normal); + output.pointB.SelfMulSub(rB, normal); + } else { + var p = b2Vec2.MidVV(output.pointA, output.pointB, b2Distance_s_p); + output.pointA.Copy(p); + output.pointB.Copy(p); + output.distance = 0; + } + } + } + var b2ShapeCast_s_n = new b2Vec2(); + var b2ShapeCast_s_simplex = new b2Simplex(); + var b2ShapeCast_s_wA = new b2Vec2(); + var b2ShapeCast_s_wB = new b2Vec2(); + var b2ShapeCast_s_v = new b2Vec2(); + var b2ShapeCast_s_p = new b2Vec2(); + var b2ShapeCast_s_pointA = new b2Vec2(); + var b2ShapeCast_s_pointB = new b2Vec2(); + function b2ShapeCast(output, input) { + output.iterations = 0; + output.lambda = 1; + output.normal.SetZero(); + output.point.SetZero(); + var proxyA = input.proxyA; + var proxyB = input.proxyB; + var radiusA = b2Max(proxyA.m_radius, b2_polygonRadius); + var radiusB = b2Max(proxyB.m_radius, b2_polygonRadius); + var radius = radiusA + radiusB; + var xfA = input.transformA; + var xfB = input.transformB; + var r = input.translationB; + var n = b2ShapeCast_s_n.Set(0, 0); + var lambda = 0; + var simplex = b2ShapeCast_s_simplex; + simplex.m_count = 0; + var vertices = simplex.m_vertices; + var indexA = proxyA.GetSupport(b2Rot.MulTRV(xfA.q, b2Vec2.NegV(r, b2Vec2.s_t1), b2Vec2.s_t0)); + var wA = b2Transform.MulXV(xfA, proxyA.GetVertex(indexA), b2ShapeCast_s_wA); + var indexB = proxyB.GetSupport(b2Rot.MulTRV(xfB.q, r, b2Vec2.s_t0)); + var wB = b2Transform.MulXV(xfB, proxyB.GetVertex(indexB), b2ShapeCast_s_wB); + var v = b2Vec2.SubVV(wA, wB, b2ShapeCast_s_v); + var sigma = b2Max(b2_polygonRadius, radius - b2_polygonRadius); + var tolerance = .5 * b2_linearSlop; + var k_maxIters = 20; + var iter = 0; + while (iter < k_maxIters && b2Abs(v.Length() - sigma) > tolerance) { + output.iterations += 1; + indexA = proxyA.GetSupport(b2Rot.MulTRV(xfA.q, b2Vec2.NegV(v, b2Vec2.s_t1), b2Vec2.s_t0)); + wA = b2Transform.MulXV(xfA, proxyA.GetVertex(indexA), b2ShapeCast_s_wA); + indexB = proxyB.GetSupport(b2Rot.MulTRV(xfB.q, v, b2Vec2.s_t0)); + wB = b2Transform.MulXV(xfB, proxyB.GetVertex(indexB), b2ShapeCast_s_wB); + var p = b2Vec2.SubVV(wA, wB, b2ShapeCast_s_p); + v.Normalize(); + var vp = b2Vec2.DotVV(v, p); + var vr = b2Vec2.DotVV(v, r); + if (vp - sigma > lambda * vr) { + if (vr <= 0) return false; + lambda = (vp - sigma) / vr; + if (lambda > 1) return false; + n.Copy(v).SelfNeg(); + simplex.m_count = 0; + } + var vertex = vertices[simplex.m_count]; + vertex.indexA = indexB; + vertex.wA.Copy(wB).SelfMulAdd(lambda, r); + vertex.indexB = indexA; + vertex.wB.Copy(wA); + vertex.w.Copy(vertex.wB).SelfSub(vertex.wA); + vertex.a = 1; + simplex.m_count += 1; + switch (simplex.m_count) { + case 1: + break; + + case 2: + simplex.Solve2(); + break; + + case 3: + simplex.Solve3(); + } + if (3 === simplex.m_count) return false; + simplex.GetClosestPoint(v); + ++iter; + } + var pointA = b2ShapeCast_s_pointA; + var pointB = b2ShapeCast_s_pointB; + simplex.GetWitnessPoints(pointA, pointB); + if (v.LengthSquared() > 0) { + n.Copy(v).SelfNeg(); + n.Normalize(); + } + output.normal.Copy(n); + output.lambda = lambda; + output.iterations = iter; + return true; + } + (function(b2ContactFeatureType) { + b2ContactFeatureType[b2ContactFeatureType["e_vertex"] = 0] = "e_vertex"; + b2ContactFeatureType[b2ContactFeatureType["e_face"] = 1] = "e_face"; + })(exports.b2ContactFeatureType || (exports.b2ContactFeatureType = {})); + var b2ContactFeature = (function() { + function b2ContactFeature() { + this._key = 0; + this._key_invalid = false; + this._indexA = 0; + this._indexB = 0; + this._typeA = 0; + this._typeB = 0; + } + Object.defineProperty(b2ContactFeature.prototype, "key", { + get: function get() { + if (this._key_invalid) { + this._key_invalid = false; + this._key = this._indexA | this._indexB << 8 | this._typeA << 16 | this._typeB << 24; + } + return this._key; + }, + set: function set(value) { + this._key = value; + this._key_invalid = false; + this._indexA = 255 & this._key; + this._indexB = this._key >> 8 & 255; + this._typeA = this._key >> 16 & 255; + this._typeB = this._key >> 24 & 255; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(b2ContactFeature.prototype, "indexA", { + get: function get() { + return this._indexA; + }, + set: function set(value) { + this._indexA = value; + this._key_invalid = true; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(b2ContactFeature.prototype, "indexB", { + get: function get() { + return this._indexB; + }, + set: function set(value) { + this._indexB = value; + this._key_invalid = true; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(b2ContactFeature.prototype, "typeA", { + get: function get() { + return this._typeA; + }, + set: function set(value) { + this._typeA = value; + this._key_invalid = true; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(b2ContactFeature.prototype, "typeB", { + get: function get() { + return this._typeB; + }, + set: function set(value) { + this._typeB = value; + this._key_invalid = true; + }, + enumerable: true, + configurable: true + }); + return b2ContactFeature; + })(); + var b2ContactID = (function() { + function b2ContactID() { + this.cf = new b2ContactFeature(); + } + b2ContactID.prototype.Copy = function(o) { + this.key = o.key; + return this; + }; + b2ContactID.prototype.Clone = function() { + return new b2ContactID().Copy(this); + }; + Object.defineProperty(b2ContactID.prototype, "key", { + get: function get() { + return this.cf.key; + }, + set: function set(value) { + this.cf.key = value; + }, + enumerable: true, + configurable: true + }); + return b2ContactID; + })(); + var b2ManifoldPoint = (function() { + function b2ManifoldPoint() { + this.localPoint = new b2Vec2(); + this.normalImpulse = 0; + this.tangentImpulse = 0; + this.id = new b2ContactID(); + } + b2ManifoldPoint.MakeArray = function(length) { + return b2MakeArray(length, (function(i) { + return new b2ManifoldPoint(); + })); + }; + b2ManifoldPoint.prototype.Reset = function() { + this.localPoint.SetZero(); + this.normalImpulse = 0; + this.tangentImpulse = 0; + this.id.key = 0; + }; + b2ManifoldPoint.prototype.Copy = function(o) { + this.localPoint.Copy(o.localPoint); + this.normalImpulse = o.normalImpulse; + this.tangentImpulse = o.tangentImpulse; + this.id.Copy(o.id); + return this; + }; + return b2ManifoldPoint; + })(); + (function(b2ManifoldType) { + b2ManifoldType[b2ManifoldType["e_unknown"] = -1] = "e_unknown"; + b2ManifoldType[b2ManifoldType["e_circles"] = 0] = "e_circles"; + b2ManifoldType[b2ManifoldType["e_faceA"] = 1] = "e_faceA"; + b2ManifoldType[b2ManifoldType["e_faceB"] = 2] = "e_faceB"; + })(exports.b2ManifoldType || (exports.b2ManifoldType = {})); + var b2Manifold = (function() { + function b2Manifold() { + this.points = b2ManifoldPoint.MakeArray(b2_maxManifoldPoints); + this.localNormal = new b2Vec2(); + this.localPoint = new b2Vec2(); + this.type = exports.b2ManifoldType.e_unknown; + this.pointCount = 0; + } + b2Manifold.prototype.Reset = function() { + for (var i = 0; i < b2_maxManifoldPoints; ++i) this.points[i].Reset(); + this.localNormal.SetZero(); + this.localPoint.SetZero(); + this.type = exports.b2ManifoldType.e_unknown; + this.pointCount = 0; + }; + b2Manifold.prototype.Copy = function(o) { + this.pointCount = o.pointCount; + for (var i = 0; i < b2_maxManifoldPoints; ++i) this.points[i].Copy(o.points[i]); + this.localNormal.Copy(o.localNormal); + this.localPoint.Copy(o.localPoint); + this.type = o.type; + return this; + }; + b2Manifold.prototype.Clone = function() { + return new b2Manifold().Copy(this); + }; + return b2Manifold; + })(); + var b2WorldManifold = (function() { + function b2WorldManifold() { + this.normal = new b2Vec2(); + this.points = b2Vec2.MakeArray(b2_maxManifoldPoints); + this.separations = b2MakeNumberArray(b2_maxManifoldPoints); + } + b2WorldManifold.prototype.Initialize = function(manifold, xfA, radiusA, xfB, radiusB) { + if (0 === manifold.pointCount) return; + switch (manifold.type) { + case exports.b2ManifoldType.e_circles: + this.normal.Set(1, 0); + var pointA = b2Transform.MulXV(xfA, manifold.localPoint, b2WorldManifold.Initialize_s_pointA); + var pointB = b2Transform.MulXV(xfB, manifold.points[0].localPoint, b2WorldManifold.Initialize_s_pointB); + b2Vec2.DistanceSquaredVV(pointA, pointB) > b2_epsilon_sq && b2Vec2.SubVV(pointB, pointA, this.normal).SelfNormalize(); + var cA = b2Vec2.AddVMulSV(pointA, radiusA, this.normal, b2WorldManifold.Initialize_s_cA); + var cB = b2Vec2.SubVMulSV(pointB, radiusB, this.normal, b2WorldManifold.Initialize_s_cB); + b2Vec2.MidVV(cA, cB, this.points[0]); + this.separations[0] = b2Vec2.DotVV(b2Vec2.SubVV(cB, cA, b2Vec2.s_t0), this.normal); + break; + + case exports.b2ManifoldType.e_faceA: + b2Rot.MulRV(xfA.q, manifold.localNormal, this.normal); + var planePoint = b2Transform.MulXV(xfA, manifold.localPoint, b2WorldManifold.Initialize_s_planePoint); + for (var i = 0; i < manifold.pointCount; ++i) { + var clipPoint = b2Transform.MulXV(xfB, manifold.points[i].localPoint, b2WorldManifold.Initialize_s_clipPoint); + var s = radiusA - b2Vec2.DotVV(b2Vec2.SubVV(clipPoint, planePoint, b2Vec2.s_t0), this.normal); + var cA = b2Vec2.AddVMulSV(clipPoint, s, this.normal, b2WorldManifold.Initialize_s_cA); + var cB = b2Vec2.SubVMulSV(clipPoint, radiusB, this.normal, b2WorldManifold.Initialize_s_cB); + b2Vec2.MidVV(cA, cB, this.points[i]); + this.separations[i] = b2Vec2.DotVV(b2Vec2.SubVV(cB, cA, b2Vec2.s_t0), this.normal); + } + break; + + case exports.b2ManifoldType.e_faceB: + b2Rot.MulRV(xfB.q, manifold.localNormal, this.normal); + var planePoint = b2Transform.MulXV(xfB, manifold.localPoint, b2WorldManifold.Initialize_s_planePoint); + for (var i = 0; i < manifold.pointCount; ++i) { + var clipPoint = b2Transform.MulXV(xfA, manifold.points[i].localPoint, b2WorldManifold.Initialize_s_clipPoint); + var s = radiusB - b2Vec2.DotVV(b2Vec2.SubVV(clipPoint, planePoint, b2Vec2.s_t0), this.normal); + var cB = b2Vec2.AddVMulSV(clipPoint, s, this.normal, b2WorldManifold.Initialize_s_cB); + var cA = b2Vec2.SubVMulSV(clipPoint, radiusA, this.normal, b2WorldManifold.Initialize_s_cA); + b2Vec2.MidVV(cA, cB, this.points[i]); + this.separations[i] = b2Vec2.DotVV(b2Vec2.SubVV(cA, cB, b2Vec2.s_t0), this.normal); + } + this.normal.SelfNeg(); + } + }; + b2WorldManifold.Initialize_s_pointA = new b2Vec2(); + b2WorldManifold.Initialize_s_pointB = new b2Vec2(); + b2WorldManifold.Initialize_s_cA = new b2Vec2(); + b2WorldManifold.Initialize_s_cB = new b2Vec2(); + b2WorldManifold.Initialize_s_planePoint = new b2Vec2(); + b2WorldManifold.Initialize_s_clipPoint = new b2Vec2(); + return b2WorldManifold; + })(); + (function(b2PointState) { + b2PointState[b2PointState["b2_nullState"] = 0] = "b2_nullState"; + b2PointState[b2PointState["b2_addState"] = 1] = "b2_addState"; + b2PointState[b2PointState["b2_persistState"] = 2] = "b2_persistState"; + b2PointState[b2PointState["b2_removeState"] = 3] = "b2_removeState"; + })(exports.b2PointState || (exports.b2PointState = {})); + function b2GetPointStates(state1, state2, manifold1, manifold2) { + var i; + for (i = 0; i < manifold1.pointCount; ++i) { + var id = manifold1.points[i].id; + var key = id.key; + state1[i] = exports.b2PointState.b2_removeState; + for (var j = 0, jct = manifold2.pointCount; j < jct; ++j) if (manifold2.points[j].id.key === key) { + state1[i] = exports.b2PointState.b2_persistState; + break; + } + } + for (;i < b2_maxManifoldPoints; ++i) state1[i] = exports.b2PointState.b2_nullState; + for (i = 0; i < manifold2.pointCount; ++i) { + var id = manifold2.points[i].id; + var key = id.key; + state2[i] = exports.b2PointState.b2_addState; + for (var j = 0, jct = manifold1.pointCount; j < jct; ++j) if (manifold1.points[j].id.key === key) { + state2[i] = exports.b2PointState.b2_persistState; + break; + } + } + for (;i < b2_maxManifoldPoints; ++i) state2[i] = exports.b2PointState.b2_nullState; + } + var b2ClipVertex = (function() { + function b2ClipVertex() { + this.v = new b2Vec2(); + this.id = new b2ContactID(); + } + b2ClipVertex.MakeArray = function(length) { + return b2MakeArray(length, (function(i) { + return new b2ClipVertex(); + })); + }; + b2ClipVertex.prototype.Copy = function(other) { + this.v.Copy(other.v); + this.id.Copy(other.id); + return this; + }; + return b2ClipVertex; + })(); + var b2RayCastInput = (function() { + function b2RayCastInput() { + this.p1 = new b2Vec2(); + this.p2 = new b2Vec2(); + this.maxFraction = 1; + } + b2RayCastInput.prototype.Copy = function(o) { + this.p1.Copy(o.p1); + this.p2.Copy(o.p2); + this.maxFraction = o.maxFraction; + return this; + }; + return b2RayCastInput; + })(); + var b2RayCastOutput = (function() { + function b2RayCastOutput() { + this.normal = new b2Vec2(); + this.fraction = 0; + } + b2RayCastOutput.prototype.Copy = function(o) { + this.normal.Copy(o.normal); + this.fraction = o.fraction; + return this; + }; + return b2RayCastOutput; + })(); + var b2AABB = (function() { + function b2AABB() { + this.lowerBound = new b2Vec2(); + this.upperBound = new b2Vec2(); + this.m_cache_center = new b2Vec2(); + this.m_cache_extent = new b2Vec2(); + } + b2AABB.prototype.Copy = function(o) { + this.lowerBound.Copy(o.lowerBound); + this.upperBound.Copy(o.upperBound); + return this; + }; + b2AABB.prototype.IsValid = function() { + var d_x = this.upperBound.x - this.lowerBound.x; + var d_y = this.upperBound.y - this.lowerBound.y; + var valid = d_x >= 0 && d_y >= 0; + valid = valid && this.lowerBound.IsValid() && this.upperBound.IsValid(); + return valid; + }; + b2AABB.prototype.GetCenter = function() { + return b2Vec2.MidVV(this.lowerBound, this.upperBound, this.m_cache_center); + }; + b2AABB.prototype.GetExtents = function() { + return b2Vec2.ExtVV(this.lowerBound, this.upperBound, this.m_cache_extent); + }; + b2AABB.prototype.GetPerimeter = function() { + var wx = this.upperBound.x - this.lowerBound.x; + var wy = this.upperBound.y - this.lowerBound.y; + return 2 * (wx + wy); + }; + b2AABB.prototype.Combine1 = function(aabb) { + this.lowerBound.x = b2Min(this.lowerBound.x, aabb.lowerBound.x); + this.lowerBound.y = b2Min(this.lowerBound.y, aabb.lowerBound.y); + this.upperBound.x = b2Max(this.upperBound.x, aabb.upperBound.x); + this.upperBound.y = b2Max(this.upperBound.y, aabb.upperBound.y); + return this; + }; + b2AABB.prototype.Combine2 = function(aabb1, aabb2) { + this.lowerBound.x = b2Min(aabb1.lowerBound.x, aabb2.lowerBound.x); + this.lowerBound.y = b2Min(aabb1.lowerBound.y, aabb2.lowerBound.y); + this.upperBound.x = b2Max(aabb1.upperBound.x, aabb2.upperBound.x); + this.upperBound.y = b2Max(aabb1.upperBound.y, aabb2.upperBound.y); + return this; + }; + b2AABB.Combine = function(aabb1, aabb2, out) { + out.Combine2(aabb1, aabb2); + return out; + }; + b2AABB.prototype.Contains = function(aabb) { + var result = true; + result = result && this.lowerBound.x <= aabb.lowerBound.x; + result = result && this.lowerBound.y <= aabb.lowerBound.y; + result = result && aabb.upperBound.x <= this.upperBound.x; + result = result && aabb.upperBound.y <= this.upperBound.y; + return result; + }; + b2AABB.prototype.RayCast = function(output, input) { + var tmin = -b2_maxFloat; + var tmax = b2_maxFloat; + var p_x = input.p1.x; + var p_y = input.p1.y; + var d_x = input.p2.x - input.p1.x; + var d_y = input.p2.y - input.p1.y; + var absD_x = b2Abs(d_x); + var absD_y = b2Abs(d_y); + var normal = output.normal; + if (absD_x < b2_epsilon) { + if (p_x < this.lowerBound.x || this.upperBound.x < p_x) return false; + } else { + var inv_d = 1 / d_x; + var t1 = (this.lowerBound.x - p_x) * inv_d; + var t2 = (this.upperBound.x - p_x) * inv_d; + var s = -1; + if (t1 > t2) { + var t3 = t1; + t1 = t2; + t2 = t3; + s = 1; + } + if (t1 > tmin) { + normal.x = s; + normal.y = 0; + tmin = t1; + } + tmax = b2Min(tmax, t2); + if (tmin > tmax) return false; + } + if (absD_y < b2_epsilon) { + if (p_y < this.lowerBound.y || this.upperBound.y < p_y) return false; + } else { + var inv_d = 1 / d_y; + var t1 = (this.lowerBound.y - p_y) * inv_d; + var t2 = (this.upperBound.y - p_y) * inv_d; + var s = -1; + if (t1 > t2) { + var t3 = t1; + t1 = t2; + t2 = t3; + s = 1; + } + if (t1 > tmin) { + normal.x = 0; + normal.y = s; + tmin = t1; + } + tmax = b2Min(tmax, t2); + if (tmin > tmax) return false; + } + if (tmin < 0 || input.maxFraction < tmin) return false; + output.fraction = tmin; + return true; + }; + b2AABB.prototype.TestContain = function(point) { + if (point.x < this.lowerBound.x || this.upperBound.x < point.x) return false; + if (point.y < this.lowerBound.y || this.upperBound.y < point.y) return false; + return true; + }; + b2AABB.prototype.TestOverlap = function(other) { + var d1_x = other.lowerBound.x - this.upperBound.x; + var d1_y = other.lowerBound.y - this.upperBound.y; + var d2_x = this.lowerBound.x - other.upperBound.x; + var d2_y = this.lowerBound.y - other.upperBound.y; + if (d1_x > 0 || d1_y > 0) return false; + if (d2_x > 0 || d2_y > 0) return false; + return true; + }; + return b2AABB; + })(); + function b2TestOverlapAABB(a, b) { + var d1_x = b.lowerBound.x - a.upperBound.x; + var d1_y = b.lowerBound.y - a.upperBound.y; + var d2_x = a.lowerBound.x - b.upperBound.x; + var d2_y = a.lowerBound.y - b.upperBound.y; + if (d1_x > 0 || d1_y > 0) return false; + if (d2_x > 0 || d2_y > 0) return false; + return true; + } + function b2ClipSegmentToLine(vOut, vIn, normal, offset, vertexIndexA) { + var numOut = 0; + var vIn0 = vIn[0]; + var vIn1 = vIn[1]; + var distance0 = b2Vec2.DotVV(normal, vIn0.v) - offset; + var distance1 = b2Vec2.DotVV(normal, vIn1.v) - offset; + distance0 <= 0 && vOut[numOut++].Copy(vIn0); + distance1 <= 0 && vOut[numOut++].Copy(vIn1); + if (distance0 * distance1 < 0) { + var interp = distance0 / (distance0 - distance1); + var v = vOut[numOut].v; + v.x = vIn0.v.x + interp * (vIn1.v.x - vIn0.v.x); + v.y = vIn0.v.y + interp * (vIn1.v.y - vIn0.v.y); + var id = vOut[numOut].id; + id.cf.indexA = vertexIndexA; + id.cf.indexB = vIn0.id.cf.indexB; + id.cf.typeA = exports.b2ContactFeatureType.e_vertex; + id.cf.typeB = exports.b2ContactFeatureType.e_face; + ++numOut; + } + return numOut; + } + var b2TestOverlapShape_s_input = new b2DistanceInput(); + var b2TestOverlapShape_s_simplexCache = new b2SimplexCache(); + var b2TestOverlapShape_s_output = new b2DistanceOutput(); + function b2TestOverlapShape(shapeA, indexA, shapeB, indexB, xfA, xfB) { + var input = b2TestOverlapShape_s_input.Reset(); + input.proxyA.SetShape(shapeA, indexA); + input.proxyB.SetShape(shapeB, indexB); + input.transformA.Copy(xfA); + input.transformB.Copy(xfB); + input.useRadii = true; + var simplexCache = b2TestOverlapShape_s_simplexCache.Reset(); + simplexCache.count = 0; + var output = b2TestOverlapShape_s_output.Reset(); + b2Distance(output, simplexCache, input); + return output.distance < 10 * b2_epsilon; + } + function verify(value) { + if (null === value) throw new Error(); + return value; + } + var b2TreeNode = (function() { + function b2TreeNode(id) { + void 0 === id && (id = 0); + this.m_id = 0; + this.aabb = new b2AABB(); + this.parent = null; + this.child1 = null; + this.child2 = null; + this.height = 0; + this.m_id = id; + } + b2TreeNode.prototype.IsLeaf = function() { + return null === this.child1; + }; + return b2TreeNode; + })(); + var b2DynamicTree = (function() { + function b2DynamicTree() { + this.m_root = null; + this.m_freeList = null; + this.m_path = 0; + this.m_insertionCount = 0; + this.m_stack = new b2GrowableStack(256); + } + b2DynamicTree.prototype.Query = function(aabb, callback) { + if (null === this.m_root) return; + var stack = this.m_stack.Reset(); + stack.Push(this.m_root); + while (stack.GetCount() > 0) { + var node = stack.Pop(); + if (node.aabb.TestOverlap(aabb)) if (node.IsLeaf()) { + var proceed = callback(node); + if (!proceed) return; + } else { + stack.Push(verify(node.child1)); + stack.Push(verify(node.child2)); + } + } + }; + b2DynamicTree.prototype.QueryPoint = function(point, callback) { + if (null === this.m_root) return; + var stack = this.m_stack.Reset(); + stack.Push(this.m_root); + while (stack.GetCount() > 0) { + var node = stack.Pop(); + if (node.aabb.TestContain(point)) if (node.IsLeaf()) { + var proceed = callback(node); + if (!proceed) return; + } else { + stack.Push(verify(node.child1)); + stack.Push(verify(node.child2)); + } + } + }; + b2DynamicTree.prototype.RayCast = function(input, callback) { + if (null === this.m_root) return; + var p1 = input.p1; + var p2 = input.p2; + var r = b2Vec2.SubVV(p2, p1, b2DynamicTree.s_r); + r.Normalize(); + var v = b2Vec2.CrossOneV(r, b2DynamicTree.s_v); + var abs_v = b2Vec2.AbsV(v, b2DynamicTree.s_abs_v); + var maxFraction = input.maxFraction; + var segmentAABB = b2DynamicTree.s_segmentAABB; + var t_x = p1.x + maxFraction * (p2.x - p1.x); + var t_y = p1.y + maxFraction * (p2.y - p1.y); + segmentAABB.lowerBound.x = b2Min(p1.x, t_x); + segmentAABB.lowerBound.y = b2Min(p1.y, t_y); + segmentAABB.upperBound.x = b2Max(p1.x, t_x); + segmentAABB.upperBound.y = b2Max(p1.y, t_y); + var stack = this.m_stack.Reset(); + stack.Push(this.m_root); + while (stack.GetCount() > 0) { + var node = stack.Pop(); + if (!b2TestOverlapAABB(node.aabb, segmentAABB)) continue; + var c = node.aabb.GetCenter(); + var h = node.aabb.GetExtents(); + var separation = b2Abs(b2Vec2.DotVV(v, b2Vec2.SubVV(p1, c, b2Vec2.s_t0))) - b2Vec2.DotVV(abs_v, h); + if (separation > 0) continue; + if (node.IsLeaf()) { + var subInput = b2DynamicTree.s_subInput; + subInput.p1.Copy(input.p1); + subInput.p2.Copy(input.p2); + subInput.maxFraction = maxFraction; + var value = callback(subInput, node); + if (0 === value) return; + if (value > 0) { + maxFraction = value; + t_x = p1.x + maxFraction * (p2.x - p1.x); + t_y = p1.y + maxFraction * (p2.y - p1.y); + segmentAABB.lowerBound.x = b2Min(p1.x, t_x); + segmentAABB.lowerBound.y = b2Min(p1.y, t_y); + segmentAABB.upperBound.x = b2Max(p1.x, t_x); + segmentAABB.upperBound.y = b2Max(p1.y, t_y); + } + } else { + stack.Push(verify(node.child1)); + stack.Push(verify(node.child2)); + } + } + }; + b2DynamicTree.prototype.AllocateNode = function() { + if (this.m_freeList) { + var node = this.m_freeList; + this.m_freeList = node.parent; + node.parent = null; + node.child1 = null; + node.child2 = null; + node.height = 0; + delete node.userData; + return node; + } + return new b2TreeNode(b2DynamicTree.s_node_id++); + }; + b2DynamicTree.prototype.FreeNode = function(node) { + node.parent = this.m_freeList; + node.child1 = null; + node.child2 = null; + node.height = -1; + delete node.userData; + this.m_freeList = node; + }; + b2DynamicTree.prototype.CreateProxy = function(aabb, userData) { + var node = this.AllocateNode(); + var r_x = b2_aabbExtension; + var r_y = b2_aabbExtension; + node.aabb.lowerBound.x = aabb.lowerBound.x - r_x; + node.aabb.lowerBound.y = aabb.lowerBound.y - r_y; + node.aabb.upperBound.x = aabb.upperBound.x + r_x; + node.aabb.upperBound.y = aabb.upperBound.y + r_y; + node.userData = userData; + node.height = 0; + this.InsertLeaf(node); + return node; + }; + b2DynamicTree.prototype.DestroyProxy = function(proxy) { + this.RemoveLeaf(proxy); + this.FreeNode(proxy); + }; + b2DynamicTree.prototype.MoveProxy = function(proxy, aabb, displacement) { + if (proxy.aabb.Contains(aabb)) return false; + this.RemoveLeaf(proxy); + var r_x = b2_aabbExtension + b2_aabbMultiplier * (displacement.x > 0 ? displacement.x : -displacement.x); + var r_y = b2_aabbExtension + b2_aabbMultiplier * (displacement.y > 0 ? displacement.y : -displacement.y); + proxy.aabb.lowerBound.x = aabb.lowerBound.x - r_x; + proxy.aabb.lowerBound.y = aabb.lowerBound.y - r_y; + proxy.aabb.upperBound.x = aabb.upperBound.x + r_x; + proxy.aabb.upperBound.y = aabb.upperBound.y + r_y; + this.InsertLeaf(proxy); + return true; + }; + b2DynamicTree.prototype.InsertLeaf = function(leaf) { + ++this.m_insertionCount; + if (null === this.m_root) { + this.m_root = leaf; + this.m_root.parent = null; + return; + } + var leafAABB = leaf.aabb; + var index = this.m_root; + while (!index.IsLeaf()) { + var child1 = verify(index.child1); + var child2 = verify(index.child2); + var area = index.aabb.GetPerimeter(); + var combinedAABB = b2DynamicTree.s_combinedAABB; + combinedAABB.Combine2(index.aabb, leafAABB); + var combinedArea = combinedAABB.GetPerimeter(); + var cost = 2 * combinedArea; + var inheritanceCost = 2 * (combinedArea - area); + var cost1 = void 0; + var aabb = b2DynamicTree.s_aabb; + var oldArea = void 0; + var newArea = void 0; + if (child1.IsLeaf()) { + aabb.Combine2(leafAABB, child1.aabb); + cost1 = aabb.GetPerimeter() + inheritanceCost; + } else { + aabb.Combine2(leafAABB, child1.aabb); + oldArea = child1.aabb.GetPerimeter(); + newArea = aabb.GetPerimeter(); + cost1 = newArea - oldArea + inheritanceCost; + } + var cost2 = void 0; + if (child2.IsLeaf()) { + aabb.Combine2(leafAABB, child2.aabb); + cost2 = aabb.GetPerimeter() + inheritanceCost; + } else { + aabb.Combine2(leafAABB, child2.aabb); + oldArea = child2.aabb.GetPerimeter(); + newArea = aabb.GetPerimeter(); + cost2 = newArea - oldArea + inheritanceCost; + } + if (cost < cost1 && cost < cost2) break; + index = cost1 < cost2 ? child1 : child2; + } + var sibling = index; + var oldParent = sibling.parent; + var newParent = this.AllocateNode(); + newParent.parent = oldParent; + delete newParent.userData; + newParent.aabb.Combine2(leafAABB, sibling.aabb); + newParent.height = sibling.height + 1; + if (oldParent) { + oldParent.child1 === sibling ? oldParent.child1 = newParent : oldParent.child2 = newParent; + newParent.child1 = sibling; + newParent.child2 = leaf; + sibling.parent = newParent; + leaf.parent = newParent; + } else { + newParent.child1 = sibling; + newParent.child2 = leaf; + sibling.parent = newParent; + leaf.parent = newParent; + this.m_root = newParent; + } + var index2 = leaf.parent; + while (null !== index2) { + index2 = this.Balance(index2); + var child1 = verify(index2.child1); + var child2 = verify(index2.child2); + index2.height = 1 + b2Max(child1.height, child2.height); + index2.aabb.Combine2(child1.aabb, child2.aabb); + index2 = index2.parent; + } + }; + b2DynamicTree.prototype.RemoveLeaf = function(leaf) { + if (leaf === this.m_root) { + this.m_root = null; + return; + } + var parent = verify(leaf.parent); + var grandParent = parent && parent.parent; + var sibling; + sibling = parent.child1 === leaf ? verify(parent.child2) : verify(parent.child1); + if (grandParent) { + grandParent.child1 === parent ? grandParent.child1 = sibling : grandParent.child2 = sibling; + sibling.parent = grandParent; + this.FreeNode(parent); + var index = grandParent; + while (index) { + index = this.Balance(index); + var child1 = verify(index.child1); + var child2 = verify(index.child2); + index.aabb.Combine2(child1.aabb, child2.aabb); + index.height = 1 + b2Max(child1.height, child2.height); + index = index.parent; + } + } else { + this.m_root = sibling; + sibling.parent = null; + this.FreeNode(parent); + } + }; + b2DynamicTree.prototype.Balance = function(A) { + if (A.IsLeaf() || A.height < 2) return A; + var B = verify(A.child1); + var C = verify(A.child2); + var balance = C.height - B.height; + if (balance > 1) { + var F = verify(C.child1); + var G = verify(C.child2); + C.child1 = A; + C.parent = A.parent; + A.parent = C; + null !== C.parent ? C.parent.child1 === A ? C.parent.child1 = C : C.parent.child2 = C : this.m_root = C; + if (F.height > G.height) { + C.child2 = F; + A.child2 = G; + G.parent = A; + A.aabb.Combine2(B.aabb, G.aabb); + C.aabb.Combine2(A.aabb, F.aabb); + A.height = 1 + b2Max(B.height, G.height); + C.height = 1 + b2Max(A.height, F.height); + } else { + C.child2 = G; + A.child2 = F; + F.parent = A; + A.aabb.Combine2(B.aabb, F.aabb); + C.aabb.Combine2(A.aabb, G.aabb); + A.height = 1 + b2Max(B.height, F.height); + C.height = 1 + b2Max(A.height, G.height); + } + return C; + } + if (balance < -1) { + var D = verify(B.child1); + var E = verify(B.child2); + B.child1 = A; + B.parent = A.parent; + A.parent = B; + null !== B.parent ? B.parent.child1 === A ? B.parent.child1 = B : B.parent.child2 = B : this.m_root = B; + if (D.height > E.height) { + B.child2 = D; + A.child1 = E; + E.parent = A; + A.aabb.Combine2(C.aabb, E.aabb); + B.aabb.Combine2(A.aabb, D.aabb); + A.height = 1 + b2Max(C.height, E.height); + B.height = 1 + b2Max(A.height, D.height); + } else { + B.child2 = E; + A.child1 = D; + D.parent = A; + A.aabb.Combine2(C.aabb, D.aabb); + B.aabb.Combine2(A.aabb, E.aabb); + A.height = 1 + b2Max(C.height, D.height); + B.height = 1 + b2Max(A.height, E.height); + } + return B; + } + return A; + }; + b2DynamicTree.prototype.GetHeight = function() { + if (null === this.m_root) return 0; + return this.m_root.height; + }; + b2DynamicTree.GetAreaNode = function(node) { + if (null === node) return 0; + if (node.IsLeaf()) return 0; + var area = node.aabb.GetPerimeter(); + area += b2DynamicTree.GetAreaNode(node.child1); + area += b2DynamicTree.GetAreaNode(node.child2); + return area; + }; + b2DynamicTree.prototype.GetAreaRatio = function() { + if (null === this.m_root) return 0; + var root = this.m_root; + var rootArea = root.aabb.GetPerimeter(); + var totalArea = b2DynamicTree.GetAreaNode(this.m_root); + return totalArea / rootArea; + }; + b2DynamicTree.prototype.ComputeHeightNode = function(node) { + if (!node || node.IsLeaf()) return 0; + var height1 = this.ComputeHeightNode(node.child1); + var height2 = this.ComputeHeightNode(node.child2); + return 1 + b2Max(height1, height2); + }; + b2DynamicTree.prototype.ComputeHeight = function() { + var height = this.ComputeHeightNode(this.m_root); + return height; + }; + b2DynamicTree.prototype.ValidateStructure = function(index) { + if (null === index) return; + index === this.m_root; + var node = index; + if (node.IsLeaf()) return; + var child1 = verify(node.child1); + var child2 = verify(node.child2); + this.ValidateStructure(child1); + this.ValidateStructure(child2); + }; + b2DynamicTree.prototype.ValidateMetrics = function(index) { + if (null === index) return; + var node = index; + if (node.IsLeaf()) return; + var child1 = verify(node.child1); + var child2 = verify(node.child2); + var aabb = b2DynamicTree.s_aabb; + aabb.Combine2(child1.aabb, child2.aabb); + this.ValidateMetrics(child1); + this.ValidateMetrics(child2); + }; + b2DynamicTree.prototype.Validate = function() {}; + b2DynamicTree.GetMaxBalanceNode = function(node, maxBalance) { + if (null === node) return maxBalance; + if (node.height <= 1) return maxBalance; + var child1 = verify(node.child1); + var child2 = verify(node.child2); + var balance = b2Abs(child2.height - child1.height); + return b2Max(maxBalance, balance); + }; + b2DynamicTree.prototype.GetMaxBalance = function() { + var maxBalance = b2DynamicTree.GetMaxBalanceNode(this.m_root, 0); + return maxBalance; + }; + b2DynamicTree.prototype.RebuildBottomUp = function() { + this.Validate(); + }; + b2DynamicTree.ShiftOriginNode = function(node, newOrigin) { + if (null === node) return; + if (node.height <= 1) return; + var child1 = node.child1; + var child2 = node.child2; + b2DynamicTree.ShiftOriginNode(child1, newOrigin); + b2DynamicTree.ShiftOriginNode(child2, newOrigin); + node.aabb.lowerBound.SelfSub(newOrigin); + node.aabb.upperBound.SelfSub(newOrigin); + }; + b2DynamicTree.prototype.ShiftOrigin = function(newOrigin) { + b2DynamicTree.ShiftOriginNode(this.m_root, newOrigin); + }; + b2DynamicTree.s_r = new b2Vec2(); + b2DynamicTree.s_v = new b2Vec2(); + b2DynamicTree.s_abs_v = new b2Vec2(); + b2DynamicTree.s_segmentAABB = new b2AABB(); + b2DynamicTree.s_subInput = new b2RayCastInput(); + b2DynamicTree.s_combinedAABB = new b2AABB(); + b2DynamicTree.s_aabb = new b2AABB(); + b2DynamicTree.s_node_id = 0; + return b2DynamicTree; + })(); + var b2Pair = (function() { + function b2Pair(proxyA, proxyB) { + this.proxyA = proxyA; + this.proxyB = proxyB; + } + return b2Pair; + })(); + var b2BroadPhase = (function() { + function b2BroadPhase() { + this.m_tree = new b2DynamicTree(); + this.m_proxyCount = 0; + this.m_moveCount = 0; + this.m_moveBuffer = []; + this.m_pairCount = 0; + this.m_pairBuffer = []; + } + b2BroadPhase.prototype.CreateProxy = function(aabb, userData) { + var proxy = this.m_tree.CreateProxy(aabb, userData); + ++this.m_proxyCount; + this.BufferMove(proxy); + return proxy; + }; + b2BroadPhase.prototype.DestroyProxy = function(proxy) { + this.UnBufferMove(proxy); + --this.m_proxyCount; + this.m_tree.DestroyProxy(proxy); + }; + b2BroadPhase.prototype.MoveProxy = function(proxy, aabb, displacement) { + var buffer = this.m_tree.MoveProxy(proxy, aabb, displacement); + buffer && this.BufferMove(proxy); + }; + b2BroadPhase.prototype.TouchProxy = function(proxy) { + this.BufferMove(proxy); + }; + b2BroadPhase.prototype.GetProxyCount = function() { + return this.m_proxyCount; + }; + b2BroadPhase.prototype.UpdatePairs = function(callback) { + var _this = this; + this.m_pairCount = 0; + var _loop_1 = function _loop_1(i_1) { + var queryProxy = this_1.m_moveBuffer[i_1]; + if (null === queryProxy) return "continue"; + var fatAABB = queryProxy.aabb; + this_1.m_tree.Query(fatAABB, (function(proxy) { + if (proxy.m_id === queryProxy.m_id) return true; + var proxyA; + var proxyB; + if (proxy.m_id < queryProxy.m_id) { + proxyA = proxy; + proxyB = queryProxy; + } else { + proxyA = queryProxy; + proxyB = proxy; + } + if (_this.m_pairCount === _this.m_pairBuffer.length) _this.m_pairBuffer[_this.m_pairCount] = new b2Pair(proxyA, proxyB); else { + var pair = _this.m_pairBuffer[_this.m_pairCount]; + pair.proxyA = proxyA; + pair.proxyB = proxyB; + } + ++_this.m_pairCount; + return true; + })); + }; + var this_1 = this; + for (var i_1 = 0; i_1 < this.m_moveCount; ++i_1) _loop_1(i_1); + this.m_moveCount = 0; + this.m_pairBuffer.length = this.m_pairCount; + this.m_pairBuffer.sort(b2PairLessThan); + var i = 0; + while (i < this.m_pairCount) { + var primaryPair = this.m_pairBuffer[i]; + var userDataA = primaryPair.proxyA.userData; + var userDataB = primaryPair.proxyB.userData; + userDataA && userDataB && callback(userDataA, userDataB); + ++i; + while (i < this.m_pairCount) { + var pair = this.m_pairBuffer[i]; + if (pair.proxyA.m_id !== primaryPair.proxyA.m_id || pair.proxyB.m_id !== primaryPair.proxyB.m_id) break; + ++i; + } + } + }; + b2BroadPhase.prototype.Query = function(aabb, callback) { + this.m_tree.Query(aabb, callback); + }; + b2BroadPhase.prototype.QueryPoint = function(point, callback) { + this.m_tree.QueryPoint(point, callback); + }; + b2BroadPhase.prototype.RayCast = function(input, callback) { + this.m_tree.RayCast(input, callback); + }; + b2BroadPhase.prototype.GetTreeHeight = function() { + return this.m_tree.GetHeight(); + }; + b2BroadPhase.prototype.GetTreeBalance = function() { + return this.m_tree.GetMaxBalance(); + }; + b2BroadPhase.prototype.GetTreeQuality = function() { + return this.m_tree.GetAreaRatio(); + }; + b2BroadPhase.prototype.ShiftOrigin = function(newOrigin) { + this.m_tree.ShiftOrigin(newOrigin); + }; + b2BroadPhase.prototype.BufferMove = function(proxy) { + this.m_moveBuffer[this.m_moveCount] = proxy; + ++this.m_moveCount; + }; + b2BroadPhase.prototype.UnBufferMove = function(proxy) { + var i = this.m_moveBuffer.indexOf(proxy); + this.m_moveBuffer[i] = null; + }; + return b2BroadPhase; + })(); + function b2PairLessThan(pair1, pair2) { + if (pair1.proxyA.m_id === pair2.proxyA.m_id) return pair1.proxyB.m_id - pair2.proxyB.m_id; + return pair1.proxyA.m_id - pair2.proxyA.m_id; + } + exports.b2_toiTime = 0; + exports.b2_toiMaxTime = 0; + exports.b2_toiCalls = 0; + exports.b2_toiIters = 0; + exports.b2_toiMaxIters = 0; + exports.b2_toiRootIters = 0; + exports.b2_toiMaxRootIters = 0; + function b2_toi_reset() { + exports.b2_toiTime = 0; + exports.b2_toiMaxTime = 0; + exports.b2_toiCalls = 0; + exports.b2_toiIters = 0; + exports.b2_toiMaxIters = 0; + exports.b2_toiRootIters = 0; + exports.b2_toiMaxRootIters = 0; + } + var b2TimeOfImpact_s_xfA = new b2Transform(); + var b2TimeOfImpact_s_xfB = new b2Transform(); + var b2TimeOfImpact_s_pointA = new b2Vec2(); + var b2TimeOfImpact_s_pointB = new b2Vec2(); + var b2TimeOfImpact_s_normal = new b2Vec2(); + var b2TimeOfImpact_s_axisA = new b2Vec2(); + var b2TimeOfImpact_s_axisB = new b2Vec2(); + var b2TOIInput = (function() { + function b2TOIInput() { + this.proxyA = new b2DistanceProxy(); + this.proxyB = new b2DistanceProxy(); + this.sweepA = new b2Sweep(); + this.sweepB = new b2Sweep(); + this.tMax = 0; + } + return b2TOIInput; + })(); + (function(b2TOIOutputState) { + b2TOIOutputState[b2TOIOutputState["e_unknown"] = 0] = "e_unknown"; + b2TOIOutputState[b2TOIOutputState["e_failed"] = 1] = "e_failed"; + b2TOIOutputState[b2TOIOutputState["e_overlapped"] = 2] = "e_overlapped"; + b2TOIOutputState[b2TOIOutputState["e_touching"] = 3] = "e_touching"; + b2TOIOutputState[b2TOIOutputState["e_separated"] = 4] = "e_separated"; + })(exports.b2TOIOutputState || (exports.b2TOIOutputState = {})); + var b2TOIOutput = (function() { + function b2TOIOutput() { + this.state = exports.b2TOIOutputState.e_unknown; + this.t = 0; + } + return b2TOIOutput; + })(); + (function(b2SeparationFunctionType) { + b2SeparationFunctionType[b2SeparationFunctionType["e_unknown"] = -1] = "e_unknown"; + b2SeparationFunctionType[b2SeparationFunctionType["e_points"] = 0] = "e_points"; + b2SeparationFunctionType[b2SeparationFunctionType["e_faceA"] = 1] = "e_faceA"; + b2SeparationFunctionType[b2SeparationFunctionType["e_faceB"] = 2] = "e_faceB"; + })(exports.b2SeparationFunctionType || (exports.b2SeparationFunctionType = {})); + var b2SeparationFunction = (function() { + function b2SeparationFunction() { + this.m_sweepA = new b2Sweep(); + this.m_sweepB = new b2Sweep(); + this.m_type = exports.b2SeparationFunctionType.e_unknown; + this.m_localPoint = new b2Vec2(); + this.m_axis = new b2Vec2(); + } + b2SeparationFunction.prototype.Initialize = function(cache, proxyA, sweepA, proxyB, sweepB, t1) { + this.m_proxyA = proxyA; + this.m_proxyB = proxyB; + var count = cache.count; + this.m_sweepA.Copy(sweepA); + this.m_sweepB.Copy(sweepB); + var xfA = b2TimeOfImpact_s_xfA; + var xfB = b2TimeOfImpact_s_xfB; + this.m_sweepA.GetTransform(xfA, t1); + this.m_sweepB.GetTransform(xfB, t1); + if (1 === count) { + this.m_type = exports.b2SeparationFunctionType.e_points; + var localPointA = this.m_proxyA.GetVertex(cache.indexA[0]); + var localPointB = this.m_proxyB.GetVertex(cache.indexB[0]); + var pointA = b2Transform.MulXV(xfA, localPointA, b2TimeOfImpact_s_pointA); + var pointB = b2Transform.MulXV(xfB, localPointB, b2TimeOfImpact_s_pointB); + b2Vec2.SubVV(pointB, pointA, this.m_axis); + var s = this.m_axis.Normalize(); + this.m_localPoint.SetZero(); + return s; + } + if (cache.indexA[0] === cache.indexA[1]) { + this.m_type = exports.b2SeparationFunctionType.e_faceB; + var localPointB1 = this.m_proxyB.GetVertex(cache.indexB[0]); + var localPointB2 = this.m_proxyB.GetVertex(cache.indexB[1]); + b2Vec2.CrossVOne(b2Vec2.SubVV(localPointB2, localPointB1, b2Vec2.s_t0), this.m_axis).SelfNormalize(); + var normal = b2Rot.MulRV(xfB.q, this.m_axis, b2TimeOfImpact_s_normal); + b2Vec2.MidVV(localPointB1, localPointB2, this.m_localPoint); + var pointB = b2Transform.MulXV(xfB, this.m_localPoint, b2TimeOfImpact_s_pointB); + var localPointA = this.m_proxyA.GetVertex(cache.indexA[0]); + var pointA = b2Transform.MulXV(xfA, localPointA, b2TimeOfImpact_s_pointA); + var s = b2Vec2.DotVV(b2Vec2.SubVV(pointA, pointB, b2Vec2.s_t0), normal); + if (s < 0) { + this.m_axis.SelfNeg(); + s = -s; + } + return s; + } + this.m_type = exports.b2SeparationFunctionType.e_faceA; + var localPointA1 = this.m_proxyA.GetVertex(cache.indexA[0]); + var localPointA2 = this.m_proxyA.GetVertex(cache.indexA[1]); + b2Vec2.CrossVOne(b2Vec2.SubVV(localPointA2, localPointA1, b2Vec2.s_t0), this.m_axis).SelfNormalize(); + var normal = b2Rot.MulRV(xfA.q, this.m_axis, b2TimeOfImpact_s_normal); + b2Vec2.MidVV(localPointA1, localPointA2, this.m_localPoint); + var pointA = b2Transform.MulXV(xfA, this.m_localPoint, b2TimeOfImpact_s_pointA); + var localPointB = this.m_proxyB.GetVertex(cache.indexB[0]); + var pointB = b2Transform.MulXV(xfB, localPointB, b2TimeOfImpact_s_pointB); + var s = b2Vec2.DotVV(b2Vec2.SubVV(pointB, pointA, b2Vec2.s_t0), normal); + if (s < 0) { + this.m_axis.SelfNeg(); + s = -s; + } + return s; + }; + b2SeparationFunction.prototype.FindMinSeparation = function(indexA, indexB, t) { + var xfA = b2TimeOfImpact_s_xfA; + var xfB = b2TimeOfImpact_s_xfB; + this.m_sweepA.GetTransform(xfA, t); + this.m_sweepB.GetTransform(xfB, t); + switch (this.m_type) { + case exports.b2SeparationFunctionType.e_points: + var axisA = b2Rot.MulTRV(xfA.q, this.m_axis, b2TimeOfImpact_s_axisA); + var axisB = b2Rot.MulTRV(xfB.q, b2Vec2.NegV(this.m_axis, b2Vec2.s_t0), b2TimeOfImpact_s_axisB); + indexA[0] = this.m_proxyA.GetSupport(axisA); + indexB[0] = this.m_proxyB.GetSupport(axisB); + var localPointA = this.m_proxyA.GetVertex(indexA[0]); + var localPointB = this.m_proxyB.GetVertex(indexB[0]); + var pointA = b2Transform.MulXV(xfA, localPointA, b2TimeOfImpact_s_pointA); + var pointB = b2Transform.MulXV(xfB, localPointB, b2TimeOfImpact_s_pointB); + var separation = b2Vec2.DotVV(b2Vec2.SubVV(pointB, pointA, b2Vec2.s_t0), this.m_axis); + return separation; + + case exports.b2SeparationFunctionType.e_faceA: + var normal = b2Rot.MulRV(xfA.q, this.m_axis, b2TimeOfImpact_s_normal); + var pointA = b2Transform.MulXV(xfA, this.m_localPoint, b2TimeOfImpact_s_pointA); + var axisB = b2Rot.MulTRV(xfB.q, b2Vec2.NegV(normal, b2Vec2.s_t0), b2TimeOfImpact_s_axisB); + indexA[0] = -1; + indexB[0] = this.m_proxyB.GetSupport(axisB); + var localPointB = this.m_proxyB.GetVertex(indexB[0]); + var pointB = b2Transform.MulXV(xfB, localPointB, b2TimeOfImpact_s_pointB); + var separation = b2Vec2.DotVV(b2Vec2.SubVV(pointB, pointA, b2Vec2.s_t0), normal); + return separation; + + case exports.b2SeparationFunctionType.e_faceB: + var normal = b2Rot.MulRV(xfB.q, this.m_axis, b2TimeOfImpact_s_normal); + var pointB = b2Transform.MulXV(xfB, this.m_localPoint, b2TimeOfImpact_s_pointB); + var axisA = b2Rot.MulTRV(xfA.q, b2Vec2.NegV(normal, b2Vec2.s_t0), b2TimeOfImpact_s_axisA); + indexB[0] = -1; + indexA[0] = this.m_proxyA.GetSupport(axisA); + var localPointA = this.m_proxyA.GetVertex(indexA[0]); + var pointA = b2Transform.MulXV(xfA, localPointA, b2TimeOfImpact_s_pointA); + var separation = b2Vec2.DotVV(b2Vec2.SubVV(pointA, pointB, b2Vec2.s_t0), normal); + return separation; + + default: + indexA[0] = -1; + indexB[0] = -1; + return 0; + } + }; + b2SeparationFunction.prototype.Evaluate = function(indexA, indexB, t) { + var xfA = b2TimeOfImpact_s_xfA; + var xfB = b2TimeOfImpact_s_xfB; + this.m_sweepA.GetTransform(xfA, t); + this.m_sweepB.GetTransform(xfB, t); + switch (this.m_type) { + case exports.b2SeparationFunctionType.e_points: + var localPointA = this.m_proxyA.GetVertex(indexA); + var localPointB = this.m_proxyB.GetVertex(indexB); + var pointA = b2Transform.MulXV(xfA, localPointA, b2TimeOfImpact_s_pointA); + var pointB = b2Transform.MulXV(xfB, localPointB, b2TimeOfImpact_s_pointB); + var separation = b2Vec2.DotVV(b2Vec2.SubVV(pointB, pointA, b2Vec2.s_t0), this.m_axis); + return separation; + + case exports.b2SeparationFunctionType.e_faceA: + var normal = b2Rot.MulRV(xfA.q, this.m_axis, b2TimeOfImpact_s_normal); + var pointA = b2Transform.MulXV(xfA, this.m_localPoint, b2TimeOfImpact_s_pointA); + var localPointB = this.m_proxyB.GetVertex(indexB); + var pointB = b2Transform.MulXV(xfB, localPointB, b2TimeOfImpact_s_pointB); + var separation = b2Vec2.DotVV(b2Vec2.SubVV(pointB, pointA, b2Vec2.s_t0), normal); + return separation; + + case exports.b2SeparationFunctionType.e_faceB: + var normal = b2Rot.MulRV(xfB.q, this.m_axis, b2TimeOfImpact_s_normal); + var pointB = b2Transform.MulXV(xfB, this.m_localPoint, b2TimeOfImpact_s_pointB); + var localPointA = this.m_proxyA.GetVertex(indexA); + var pointA = b2Transform.MulXV(xfA, localPointA, b2TimeOfImpact_s_pointA); + var separation = b2Vec2.DotVV(b2Vec2.SubVV(pointA, pointB, b2Vec2.s_t0), normal); + return separation; + + default: + return 0; + } + }; + return b2SeparationFunction; + })(); + var b2TimeOfImpact_s_timer = new b2Timer(); + var b2TimeOfImpact_s_cache = new b2SimplexCache(); + var b2TimeOfImpact_s_distanceInput = new b2DistanceInput(); + var b2TimeOfImpact_s_distanceOutput = new b2DistanceOutput(); + var b2TimeOfImpact_s_fcn = new b2SeparationFunction(); + var b2TimeOfImpact_s_indexA = [ 0 ]; + var b2TimeOfImpact_s_indexB = [ 0 ]; + var b2TimeOfImpact_s_sweepA = new b2Sweep(); + var b2TimeOfImpact_s_sweepB = new b2Sweep(); + function b2TimeOfImpact(output, input) { + var timer = b2TimeOfImpact_s_timer.Reset(); + ++exports.b2_toiCalls; + output.state = exports.b2TOIOutputState.e_unknown; + output.t = input.tMax; + var proxyA = input.proxyA; + var proxyB = input.proxyB; + var sweepA = b2TimeOfImpact_s_sweepA.Copy(input.sweepA); + var sweepB = b2TimeOfImpact_s_sweepB.Copy(input.sweepB); + sweepA.Normalize(); + sweepB.Normalize(); + var tMax = input.tMax; + var totalRadius = proxyA.m_radius + proxyB.m_radius; + var target = b2Max(b2_linearSlop, totalRadius - 3 * b2_linearSlop); + var tolerance = .25 * b2_linearSlop; + var t1 = 0; + var k_maxIterations = 20; + var iter = 0; + var cache = b2TimeOfImpact_s_cache; + cache.count = 0; + var distanceInput = b2TimeOfImpact_s_distanceInput; + distanceInput.proxyA.Copy(input.proxyA); + distanceInput.proxyB.Copy(input.proxyB); + distanceInput.useRadii = false; + for (;;) { + var xfA = b2TimeOfImpact_s_xfA; + var xfB = b2TimeOfImpact_s_xfB; + sweepA.GetTransform(xfA, t1); + sweepB.GetTransform(xfB, t1); + distanceInput.transformA.Copy(xfA); + distanceInput.transformB.Copy(xfB); + var distanceOutput = b2TimeOfImpact_s_distanceOutput; + b2Distance(distanceOutput, cache, distanceInput); + if (distanceOutput.distance <= 0) { + output.state = exports.b2TOIOutputState.e_overlapped; + output.t = 0; + break; + } + if (distanceOutput.distance < target + tolerance) { + output.state = exports.b2TOIOutputState.e_touching; + output.t = t1; + break; + } + var fcn = b2TimeOfImpact_s_fcn; + fcn.Initialize(cache, proxyA, sweepA, proxyB, sweepB, t1); + var done = false; + var t2 = tMax; + var pushBackIter = 0; + for (;;) { + var indexA = b2TimeOfImpact_s_indexA; + var indexB = b2TimeOfImpact_s_indexB; + var s2 = fcn.FindMinSeparation(indexA, indexB, t2); + if (s2 > target + tolerance) { + output.state = exports.b2TOIOutputState.e_separated; + output.t = tMax; + done = true; + break; + } + if (s2 > target - tolerance) { + t1 = t2; + break; + } + var s1 = fcn.Evaluate(indexA[0], indexB[0], t1); + if (s1 < target - tolerance) { + output.state = exports.b2TOIOutputState.e_failed; + output.t = t1; + done = true; + break; + } + if (s1 <= target + tolerance) { + output.state = exports.b2TOIOutputState.e_touching; + output.t = t1; + done = true; + break; + } + var rootIterCount = 0; + var a1 = t1; + var a2 = t2; + for (;;) { + var t = 0; + t = 1 & rootIterCount ? a1 + (target - s1) * (a2 - a1) / (s2 - s1) : .5 * (a1 + a2); + ++rootIterCount; + ++exports.b2_toiRootIters; + var s = fcn.Evaluate(indexA[0], indexB[0], t); + if (b2Abs(s - target) < tolerance) { + t2 = t; + break; + } + if (s > target) { + a1 = t; + s1 = s; + } else { + a2 = t; + s2 = s; + } + if (50 === rootIterCount) break; + } + exports.b2_toiMaxRootIters = b2Max(exports.b2_toiMaxRootIters, rootIterCount); + ++pushBackIter; + if (pushBackIter === b2_maxPolygonVertices) break; + } + ++iter; + ++exports.b2_toiIters; + if (done) break; + if (iter === k_maxIterations) { + output.state = exports.b2TOIOutputState.e_failed; + output.t = t1; + break; + } + } + exports.b2_toiMaxIters = b2Max(exports.b2_toiMaxIters, iter); + var time = timer.GetMilliseconds(); + exports.b2_toiMaxTime = b2Max(exports.b2_toiMaxTime, time); + exports.b2_toiTime += time; + } + var b2CollideCircles_s_pA = new b2Vec2(); + var b2CollideCircles_s_pB = new b2Vec2(); + function b2CollideCircles(manifold, circleA, xfA, circleB, xfB) { + manifold.pointCount = 0; + var pA = b2Transform.MulXV(xfA, circleA.m_p, b2CollideCircles_s_pA); + var pB = b2Transform.MulXV(xfB, circleB.m_p, b2CollideCircles_s_pB); + var distSqr = b2Vec2.DistanceSquaredVV(pA, pB); + var radius = circleA.m_radius + circleB.m_radius; + if (distSqr > radius * radius) return; + manifold.type = exports.b2ManifoldType.e_circles; + manifold.localPoint.Copy(circleA.m_p); + manifold.localNormal.SetZero(); + manifold.pointCount = 1; + manifold.points[0].localPoint.Copy(circleB.m_p); + manifold.points[0].id.key = 0; + } + var b2CollidePolygonAndCircle_s_c = new b2Vec2(); + var b2CollidePolygonAndCircle_s_cLocal = new b2Vec2(); + var b2CollidePolygonAndCircle_s_faceCenter = new b2Vec2(); + function b2CollidePolygonAndCircle(manifold, polygonA, xfA, circleB, xfB) { + manifold.pointCount = 0; + var c = b2Transform.MulXV(xfB, circleB.m_p, b2CollidePolygonAndCircle_s_c); + var cLocal = b2Transform.MulTXV(xfA, c, b2CollidePolygonAndCircle_s_cLocal); + var normalIndex = 0; + var separation = -b2_maxFloat; + var radius = polygonA.m_radius + circleB.m_radius; + var vertexCount = polygonA.m_count; + var vertices = polygonA.m_vertices; + var normals = polygonA.m_normals; + for (var i = 0; i < vertexCount; ++i) { + var s = b2Vec2.DotVV(normals[i], b2Vec2.SubVV(cLocal, vertices[i], b2Vec2.s_t0)); + if (s > radius) return; + if (s > separation) { + separation = s; + normalIndex = i; + } + } + var vertIndex1 = normalIndex; + var vertIndex2 = (vertIndex1 + 1) % vertexCount; + var v1 = vertices[vertIndex1]; + var v2 = vertices[vertIndex2]; + if (separation < b2_epsilon) { + manifold.pointCount = 1; + manifold.type = exports.b2ManifoldType.e_faceA; + manifold.localNormal.Copy(normals[normalIndex]); + b2Vec2.MidVV(v1, v2, manifold.localPoint); + manifold.points[0].localPoint.Copy(circleB.m_p); + manifold.points[0].id.key = 0; + return; + } + var u1 = b2Vec2.DotVV(b2Vec2.SubVV(cLocal, v1, b2Vec2.s_t0), b2Vec2.SubVV(v2, v1, b2Vec2.s_t1)); + var u2 = b2Vec2.DotVV(b2Vec2.SubVV(cLocal, v2, b2Vec2.s_t0), b2Vec2.SubVV(v1, v2, b2Vec2.s_t1)); + if (u1 <= 0) { + if (b2Vec2.DistanceSquaredVV(cLocal, v1) > radius * radius) return; + manifold.pointCount = 1; + manifold.type = exports.b2ManifoldType.e_faceA; + b2Vec2.SubVV(cLocal, v1, manifold.localNormal).SelfNormalize(); + manifold.localPoint.Copy(v1); + manifold.points[0].localPoint.Copy(circleB.m_p); + manifold.points[0].id.key = 0; + } else if (u2 <= 0) { + if (b2Vec2.DistanceSquaredVV(cLocal, v2) > radius * radius) return; + manifold.pointCount = 1; + manifold.type = exports.b2ManifoldType.e_faceA; + b2Vec2.SubVV(cLocal, v2, manifold.localNormal).SelfNormalize(); + manifold.localPoint.Copy(v2); + manifold.points[0].localPoint.Copy(circleB.m_p); + manifold.points[0].id.key = 0; + } else { + var faceCenter = b2Vec2.MidVV(v1, v2, b2CollidePolygonAndCircle_s_faceCenter); + var separation_1 = b2Vec2.DotVV(b2Vec2.SubVV(cLocal, faceCenter, b2Vec2.s_t1), normals[vertIndex1]); + if (separation_1 > radius) return; + manifold.pointCount = 1; + manifold.type = exports.b2ManifoldType.e_faceA; + manifold.localNormal.Copy(normals[vertIndex1]).SelfNormalize(); + manifold.localPoint.Copy(faceCenter); + manifold.points[0].localPoint.Copy(circleB.m_p); + manifold.points[0].id.key = 0; + } + } + var b2EdgeSeparation_s_normal1World = new b2Vec2(); + var b2EdgeSeparation_s_normal1 = new b2Vec2(); + var b2EdgeSeparation_s_v1 = new b2Vec2(); + var b2EdgeSeparation_s_v2 = new b2Vec2(); + function b2EdgeSeparation(poly1, xf1, edge1, poly2, xf2) { + var vertices1 = poly1.m_vertices; + var normals1 = poly1.m_normals; + var count2 = poly2.m_count; + var vertices2 = poly2.m_vertices; + var normal1World = b2Rot.MulRV(xf1.q, normals1[edge1], b2EdgeSeparation_s_normal1World); + var normal1 = b2Rot.MulTRV(xf2.q, normal1World, b2EdgeSeparation_s_normal1); + var index = 0; + var minDot = b2_maxFloat; + for (var i = 0; i < count2; ++i) { + var dot = b2Vec2.DotVV(vertices2[i], normal1); + if (dot < minDot) { + minDot = dot; + index = i; + } + } + var v1 = b2Transform.MulXV(xf1, vertices1[edge1], b2EdgeSeparation_s_v1); + var v2 = b2Transform.MulXV(xf2, vertices2[index], b2EdgeSeparation_s_v2); + var separation = b2Vec2.DotVV(b2Vec2.SubVV(v2, v1, b2Vec2.s_t0), normal1World); + return separation; + } + var b2FindMaxSeparation_s_d = new b2Vec2(); + var b2FindMaxSeparation_s_dLocal1 = new b2Vec2(); + function b2FindMaxSeparation(edgeIndex, poly1, xf1, poly2, xf2) { + var count1 = poly1.m_count; + var normals1 = poly1.m_normals; + var d = b2Vec2.SubVV(b2Transform.MulXV(xf2, poly2.m_centroid, b2Vec2.s_t0), b2Transform.MulXV(xf1, poly1.m_centroid, b2Vec2.s_t1), b2FindMaxSeparation_s_d); + var dLocal1 = b2Rot.MulTRV(xf1.q, d, b2FindMaxSeparation_s_dLocal1); + var edge = 0; + var maxDot = -b2_maxFloat; + for (var i = 0; i < count1; ++i) { + var dot = b2Vec2.DotVV(normals1[i], dLocal1); + if (dot > maxDot) { + maxDot = dot; + edge = i; + } + } + var s = b2EdgeSeparation(poly1, xf1, edge, poly2, xf2); + var prevEdge = (edge + count1 - 1) % count1; + var sPrev = b2EdgeSeparation(poly1, xf1, prevEdge, poly2, xf2); + var nextEdge = (edge + 1) % count1; + var sNext = b2EdgeSeparation(poly1, xf1, nextEdge, poly2, xf2); + var bestEdge = 0; + var bestSeparation = 0; + var increment = 0; + if (sPrev > s && sPrev > sNext) { + increment = -1; + bestEdge = prevEdge; + bestSeparation = sPrev; + } else { + if (!(sNext > s)) { + edgeIndex[0] = edge; + return s; + } + increment = 1; + bestEdge = nextEdge; + bestSeparation = sNext; + } + while (true) { + edge = -1 === increment ? (bestEdge + count1 - 1) % count1 : (bestEdge + 1) % count1; + s = b2EdgeSeparation(poly1, xf1, edge, poly2, xf2); + if (!(s > bestSeparation)) break; + bestEdge = edge; + bestSeparation = s; + } + edgeIndex[0] = bestEdge; + return bestSeparation; + } + var b2FindIncidentEdge_s_normal1 = new b2Vec2(); + function b2FindIncidentEdge(c, poly1, xf1, edge1, poly2, xf2) { + var normals1 = poly1.m_normals; + var count2 = poly2.m_count; + var vertices2 = poly2.m_vertices; + var normals2 = poly2.m_normals; + var normal1 = b2Rot.MulTRV(xf2.q, b2Rot.MulRV(xf1.q, normals1[edge1], b2Vec2.s_t0), b2FindIncidentEdge_s_normal1); + var index = 0; + var minDot = b2_maxFloat; + for (var i = 0; i < count2; ++i) { + var dot = b2Vec2.DotVV(normal1, normals2[i]); + if (dot < minDot) { + minDot = dot; + index = i; + } + } + var i1 = index; + var i2 = (i1 + 1) % count2; + var c0 = c[0]; + b2Transform.MulXV(xf2, vertices2[i1], c0.v); + var cf0 = c0.id.cf; + cf0.indexA = edge1; + cf0.indexB = i1; + cf0.typeA = exports.b2ContactFeatureType.e_face; + cf0.typeB = exports.b2ContactFeatureType.e_vertex; + var c1 = c[1]; + b2Transform.MulXV(xf2, vertices2[i2], c1.v); + var cf1 = c1.id.cf; + cf1.indexA = edge1; + cf1.indexB = i2; + cf1.typeA = exports.b2ContactFeatureType.e_face; + cf1.typeB = exports.b2ContactFeatureType.e_vertex; + } + var b2CollidePolygons_s_incidentEdge = b2ClipVertex.MakeArray(2); + var b2CollidePolygons_s_clipPoints1 = b2ClipVertex.MakeArray(2); + var b2CollidePolygons_s_clipPoints2 = b2ClipVertex.MakeArray(2); + var b2CollidePolygons_s_edgeA = [ 0 ]; + var b2CollidePolygons_s_edgeB = [ 0 ]; + var b2CollidePolygons_s_localTangent = new b2Vec2(); + var b2CollidePolygons_s_localNormal = new b2Vec2(); + var b2CollidePolygons_s_planePoint = new b2Vec2(); + var b2CollidePolygons_s_normal = new b2Vec2(); + var b2CollidePolygons_s_tangent = new b2Vec2(); + var b2CollidePolygons_s_ntangent = new b2Vec2(); + var b2CollidePolygons_s_v11 = new b2Vec2(); + var b2CollidePolygons_s_v12 = new b2Vec2(); + function b2CollidePolygons(manifold, polyA, xfA, polyB, xfB) { + manifold.pointCount = 0; + var totalRadius = polyA.m_radius + polyB.m_radius; + var edgeA = b2CollidePolygons_s_edgeA; + edgeA[0] = 0; + var separationA = b2FindMaxSeparation(edgeA, polyA, xfA, polyB, xfB); + if (separationA > totalRadius) return; + var edgeB = b2CollidePolygons_s_edgeB; + edgeB[0] = 0; + var separationB = b2FindMaxSeparation(edgeB, polyB, xfB, polyA, xfA); + if (separationB > totalRadius) return; + var poly1; + var poly2; + var xf1, xf2; + var edge1 = 0; + var flip = 0; + var k_relativeTol = .98; + var k_absoluteTol = .001; + if (separationB > k_relativeTol * separationA + k_absoluteTol) { + poly1 = polyB; + poly2 = polyA; + xf1 = xfB; + xf2 = xfA; + edge1 = edgeB[0]; + manifold.type = exports.b2ManifoldType.e_faceB; + flip = 1; + } else { + poly1 = polyA; + poly2 = polyB; + xf1 = xfA; + xf2 = xfB; + edge1 = edgeA[0]; + manifold.type = exports.b2ManifoldType.e_faceA; + flip = 0; + } + var incidentEdge = b2CollidePolygons_s_incidentEdge; + b2FindIncidentEdge(incidentEdge, poly1, xf1, edge1, poly2, xf2); + var count1 = poly1.m_count; + var vertices1 = poly1.m_vertices; + var iv1 = edge1; + var iv2 = (edge1 + 1) % count1; + var local_v11 = vertices1[iv1]; + var local_v12 = vertices1[iv2]; + var localTangent = b2Vec2.SubVV(local_v12, local_v11, b2CollidePolygons_s_localTangent); + localTangent.Normalize(); + var localNormal = b2Vec2.CrossVOne(localTangent, b2CollidePolygons_s_localNormal); + var planePoint = b2Vec2.MidVV(local_v11, local_v12, b2CollidePolygons_s_planePoint); + var tangent = b2Rot.MulRV(xf1.q, localTangent, b2CollidePolygons_s_tangent); + var normal = b2Vec2.CrossVOne(tangent, b2CollidePolygons_s_normal); + var v11 = b2Transform.MulXV(xf1, local_v11, b2CollidePolygons_s_v11); + var v12 = b2Transform.MulXV(xf1, local_v12, b2CollidePolygons_s_v12); + var frontOffset = b2Vec2.DotVV(normal, v11); + var sideOffset1 = -b2Vec2.DotVV(tangent, v11) + totalRadius; + var sideOffset2 = b2Vec2.DotVV(tangent, v12) + totalRadius; + var clipPoints1 = b2CollidePolygons_s_clipPoints1; + var clipPoints2 = b2CollidePolygons_s_clipPoints2; + var np; + var ntangent = b2Vec2.NegV(tangent, b2CollidePolygons_s_ntangent); + np = b2ClipSegmentToLine(clipPoints1, incidentEdge, ntangent, sideOffset1, iv1); + if (np < 2) return; + np = b2ClipSegmentToLine(clipPoints2, clipPoints1, tangent, sideOffset2, iv2); + if (np < 2) return; + manifold.localNormal.Copy(localNormal); + manifold.localPoint.Copy(planePoint); + var pointCount = 0; + for (var i = 0; i < b2_maxManifoldPoints; ++i) { + var cv = clipPoints2[i]; + var separation = b2Vec2.DotVV(normal, cv.v) - frontOffset; + if (separation <= totalRadius) { + var cp = manifold.points[pointCount]; + b2Transform.MulTXV(xf2, cv.v, cp.localPoint); + cp.id.Copy(cv.id); + if (flip) { + var cf = cp.id.cf; + cp.id.cf.indexA = cf.indexB; + cp.id.cf.indexB = cf.indexA; + cp.id.cf.typeA = cf.typeB; + cp.id.cf.typeB = cf.typeA; + } + ++pointCount; + } + } + manifold.pointCount = pointCount; + } + var b2CollideEdgeAndCircle_s_Q = new b2Vec2(); + var b2CollideEdgeAndCircle_s_e = new b2Vec2(); + var b2CollideEdgeAndCircle_s_d = new b2Vec2(); + var b2CollideEdgeAndCircle_s_e1 = new b2Vec2(); + var b2CollideEdgeAndCircle_s_e2 = new b2Vec2(); + var b2CollideEdgeAndCircle_s_P = new b2Vec2(); + var b2CollideEdgeAndCircle_s_n = new b2Vec2(); + var b2CollideEdgeAndCircle_s_id = new b2ContactID(); + function b2CollideEdgeAndCircle(manifold, edgeA, xfA, circleB, xfB) { + manifold.pointCount = 0; + var Q = b2Transform.MulTXV(xfA, b2Transform.MulXV(xfB, circleB.m_p, b2Vec2.s_t0), b2CollideEdgeAndCircle_s_Q); + var A = edgeA.m_vertex1; + var B = edgeA.m_vertex2; + var e = b2Vec2.SubVV(B, A, b2CollideEdgeAndCircle_s_e); + var u = b2Vec2.DotVV(e, b2Vec2.SubVV(B, Q, b2Vec2.s_t0)); + var v = b2Vec2.DotVV(e, b2Vec2.SubVV(Q, A, b2Vec2.s_t0)); + var radius = edgeA.m_radius + circleB.m_radius; + var id = b2CollideEdgeAndCircle_s_id; + id.cf.indexB = 0; + id.cf.typeB = exports.b2ContactFeatureType.e_vertex; + if (v <= 0) { + var P_1 = A; + var d_1 = b2Vec2.SubVV(Q, P_1, b2CollideEdgeAndCircle_s_d); + var dd_1 = b2Vec2.DotVV(d_1, d_1); + if (dd_1 > radius * radius) return; + if (edgeA.m_hasVertex0) { + var A1 = edgeA.m_vertex0; + var B1 = A; + var e1 = b2Vec2.SubVV(B1, A1, b2CollideEdgeAndCircle_s_e1); + var u1 = b2Vec2.DotVV(e1, b2Vec2.SubVV(B1, Q, b2Vec2.s_t0)); + if (u1 > 0) return; + } + id.cf.indexA = 0; + id.cf.typeA = exports.b2ContactFeatureType.e_vertex; + manifold.pointCount = 1; + manifold.type = exports.b2ManifoldType.e_circles; + manifold.localNormal.SetZero(); + manifold.localPoint.Copy(P_1); + manifold.points[0].id.Copy(id); + manifold.points[0].localPoint.Copy(circleB.m_p); + return; + } + if (u <= 0) { + var P_2 = B; + var d_2 = b2Vec2.SubVV(Q, P_2, b2CollideEdgeAndCircle_s_d); + var dd_2 = b2Vec2.DotVV(d_2, d_2); + if (dd_2 > radius * radius) return; + if (edgeA.m_hasVertex3) { + var B2 = edgeA.m_vertex3; + var A2 = B; + var e2 = b2Vec2.SubVV(B2, A2, b2CollideEdgeAndCircle_s_e2); + var v2 = b2Vec2.DotVV(e2, b2Vec2.SubVV(Q, A2, b2Vec2.s_t0)); + if (v2 > 0) return; + } + id.cf.indexA = 1; + id.cf.typeA = exports.b2ContactFeatureType.e_vertex; + manifold.pointCount = 1; + manifold.type = exports.b2ManifoldType.e_circles; + manifold.localNormal.SetZero(); + manifold.localPoint.Copy(P_2); + manifold.points[0].id.Copy(id); + manifold.points[0].localPoint.Copy(circleB.m_p); + return; + } + var den = b2Vec2.DotVV(e, e); + var P = b2CollideEdgeAndCircle_s_P; + P.x = 1 / den * (u * A.x + v * B.x); + P.y = 1 / den * (u * A.y + v * B.y); + var d = b2Vec2.SubVV(Q, P, b2CollideEdgeAndCircle_s_d); + var dd = b2Vec2.DotVV(d, d); + if (dd > radius * radius) return; + var n = b2CollideEdgeAndCircle_s_n.Set(-e.y, e.x); + b2Vec2.DotVV(n, b2Vec2.SubVV(Q, A, b2Vec2.s_t0)) < 0 && n.Set(-n.x, -n.y); + n.Normalize(); + id.cf.indexA = 0; + id.cf.typeA = exports.b2ContactFeatureType.e_face; + manifold.pointCount = 1; + manifold.type = exports.b2ManifoldType.e_faceA; + manifold.localNormal.Copy(n); + manifold.localPoint.Copy(A); + manifold.points[0].id.Copy(id); + manifold.points[0].localPoint.Copy(circleB.m_p); + } + var b2EPAxis = (function() { + function b2EPAxis() { + this.type = 0; + this.index = 0; + this.separation = 0; + } + return b2EPAxis; + })(); + var b2TempPolygon = (function() { + function b2TempPolygon() { + this.vertices = b2Vec2.MakeArray(b2_maxPolygonVertices); + this.normals = b2Vec2.MakeArray(b2_maxPolygonVertices); + this.count = 0; + } + return b2TempPolygon; + })(); + var b2ReferenceFace = (function() { + function b2ReferenceFace() { + this.i1 = 0; + this.i2 = 0; + this.v1 = new b2Vec2(); + this.v2 = new b2Vec2(); + this.normal = new b2Vec2(); + this.sideNormal1 = new b2Vec2(); + this.sideOffset1 = 0; + this.sideNormal2 = new b2Vec2(); + this.sideOffset2 = 0; + } + return b2ReferenceFace; + })(); + var b2EPCollider = (function() { + function b2EPCollider() { + this.m_polygonB = new b2TempPolygon(); + this.m_xf = new b2Transform(); + this.m_centroidB = new b2Vec2(); + this.m_v0 = new b2Vec2(); + this.m_v1 = new b2Vec2(); + this.m_v2 = new b2Vec2(); + this.m_v3 = new b2Vec2(); + this.m_normal0 = new b2Vec2(); + this.m_normal1 = new b2Vec2(); + this.m_normal2 = new b2Vec2(); + this.m_normal = new b2Vec2(); + this.m_type1 = 0; + this.m_type2 = 0; + this.m_lowerLimit = new b2Vec2(); + this.m_upperLimit = new b2Vec2(); + this.m_radius = 0; + this.m_front = false; + } + b2EPCollider.prototype.Collide = function(manifold, edgeA, xfA, polygonB, xfB) { + b2Transform.MulTXX(xfA, xfB, this.m_xf); + b2Transform.MulXV(this.m_xf, polygonB.m_centroid, this.m_centroidB); + this.m_v0.Copy(edgeA.m_vertex0); + this.m_v1.Copy(edgeA.m_vertex1); + this.m_v2.Copy(edgeA.m_vertex2); + this.m_v3.Copy(edgeA.m_vertex3); + var hasVertex0 = edgeA.m_hasVertex0; + var hasVertex3 = edgeA.m_hasVertex3; + var edge1 = b2Vec2.SubVV(this.m_v2, this.m_v1, b2EPCollider.s_edge1); + edge1.Normalize(); + this.m_normal1.Set(edge1.y, -edge1.x); + var offset1 = b2Vec2.DotVV(this.m_normal1, b2Vec2.SubVV(this.m_centroidB, this.m_v1, b2Vec2.s_t0)); + var offset0 = 0; + var offset2 = 0; + var convex1 = false; + var convex2 = false; + if (hasVertex0) { + var edge0 = b2Vec2.SubVV(this.m_v1, this.m_v0, b2EPCollider.s_edge0); + edge0.Normalize(); + this.m_normal0.Set(edge0.y, -edge0.x); + convex1 = b2Vec2.CrossVV(edge0, edge1) >= 0; + offset0 = b2Vec2.DotVV(this.m_normal0, b2Vec2.SubVV(this.m_centroidB, this.m_v0, b2Vec2.s_t0)); + } + if (hasVertex3) { + var edge2 = b2Vec2.SubVV(this.m_v3, this.m_v2, b2EPCollider.s_edge2); + edge2.Normalize(); + this.m_normal2.Set(edge2.y, -edge2.x); + convex2 = b2Vec2.CrossVV(edge1, edge2) > 0; + offset2 = b2Vec2.DotVV(this.m_normal2, b2Vec2.SubVV(this.m_centroidB, this.m_v2, b2Vec2.s_t0)); + } + if (hasVertex0 && hasVertex3) if (convex1 && convex2) { + this.m_front = offset0 >= 0 || offset1 >= 0 || offset2 >= 0; + if (this.m_front) { + this.m_normal.Copy(this.m_normal1); + this.m_lowerLimit.Copy(this.m_normal0); + this.m_upperLimit.Copy(this.m_normal2); + } else { + this.m_normal.Copy(this.m_normal1).SelfNeg(); + this.m_lowerLimit.Copy(this.m_normal1).SelfNeg(); + this.m_upperLimit.Copy(this.m_normal1).SelfNeg(); + } + } else if (convex1) { + this.m_front = offset0 >= 0 || offset1 >= 0 && offset2 >= 0; + if (this.m_front) { + this.m_normal.Copy(this.m_normal1); + this.m_lowerLimit.Copy(this.m_normal0); + this.m_upperLimit.Copy(this.m_normal1); + } else { + this.m_normal.Copy(this.m_normal1).SelfNeg(); + this.m_lowerLimit.Copy(this.m_normal2).SelfNeg(); + this.m_upperLimit.Copy(this.m_normal1).SelfNeg(); + } + } else if (convex2) { + this.m_front = offset2 >= 0 || offset0 >= 0 && offset1 >= 0; + if (this.m_front) { + this.m_normal.Copy(this.m_normal1); + this.m_lowerLimit.Copy(this.m_normal1); + this.m_upperLimit.Copy(this.m_normal2); + } else { + this.m_normal.Copy(this.m_normal1).SelfNeg(); + this.m_lowerLimit.Copy(this.m_normal1).SelfNeg(); + this.m_upperLimit.Copy(this.m_normal0).SelfNeg(); + } + } else { + this.m_front = offset0 >= 0 && offset1 >= 0 && offset2 >= 0; + if (this.m_front) { + this.m_normal.Copy(this.m_normal1); + this.m_lowerLimit.Copy(this.m_normal1); + this.m_upperLimit.Copy(this.m_normal1); + } else { + this.m_normal.Copy(this.m_normal1).SelfNeg(); + this.m_lowerLimit.Copy(this.m_normal2).SelfNeg(); + this.m_upperLimit.Copy(this.m_normal0).SelfNeg(); + } + } else if (hasVertex0) if (convex1) { + this.m_front = offset0 >= 0 || offset1 >= 0; + if (this.m_front) { + this.m_normal.Copy(this.m_normal1); + this.m_lowerLimit.Copy(this.m_normal0); + this.m_upperLimit.Copy(this.m_normal1).SelfNeg(); + } else { + this.m_normal.Copy(this.m_normal1).SelfNeg(); + this.m_lowerLimit.Copy(this.m_normal1); + this.m_upperLimit.Copy(this.m_normal1).SelfNeg(); + } + } else { + this.m_front = offset0 >= 0 && offset1 >= 0; + if (this.m_front) { + this.m_normal.Copy(this.m_normal1); + this.m_lowerLimit.Copy(this.m_normal1); + this.m_upperLimit.Copy(this.m_normal1).SelfNeg(); + } else { + this.m_normal.Copy(this.m_normal1).SelfNeg(); + this.m_lowerLimit.Copy(this.m_normal1); + this.m_upperLimit.Copy(this.m_normal0).SelfNeg(); + } + } else if (hasVertex3) if (convex2) { + this.m_front = offset1 >= 0 || offset2 >= 0; + if (this.m_front) { + this.m_normal.Copy(this.m_normal1); + this.m_lowerLimit.Copy(this.m_normal1).SelfNeg(); + this.m_upperLimit.Copy(this.m_normal2); + } else { + this.m_normal.Copy(this.m_normal1).SelfNeg(); + this.m_lowerLimit.Copy(this.m_normal1).SelfNeg(); + this.m_upperLimit.Copy(this.m_normal1); + } + } else { + this.m_front = offset1 >= 0 && offset2 >= 0; + if (this.m_front) { + this.m_normal.Copy(this.m_normal1); + this.m_lowerLimit.Copy(this.m_normal1).SelfNeg(); + this.m_upperLimit.Copy(this.m_normal1); + } else { + this.m_normal.Copy(this.m_normal1).SelfNeg(); + this.m_lowerLimit.Copy(this.m_normal2).SelfNeg(); + this.m_upperLimit.Copy(this.m_normal1); + } + } else { + this.m_front = offset1 >= 0; + if (this.m_front) { + this.m_normal.Copy(this.m_normal1); + this.m_lowerLimit.Copy(this.m_normal1).SelfNeg(); + this.m_upperLimit.Copy(this.m_normal1).SelfNeg(); + } else { + this.m_normal.Copy(this.m_normal1).SelfNeg(); + this.m_lowerLimit.Copy(this.m_normal1); + this.m_upperLimit.Copy(this.m_normal1); + } + } + this.m_polygonB.count = polygonB.m_count; + for (var i = 0; i < polygonB.m_count; ++i) { + b2Transform.MulXV(this.m_xf, polygonB.m_vertices[i], this.m_polygonB.vertices[i]); + b2Rot.MulRV(this.m_xf.q, polygonB.m_normals[i], this.m_polygonB.normals[i]); + } + this.m_radius = polygonB.m_radius + edgeA.m_radius; + manifold.pointCount = 0; + var edgeAxis = this.ComputeEdgeSeparation(b2EPCollider.s_edgeAxis); + if (0 === edgeAxis.type) return; + if (edgeAxis.separation > this.m_radius) return; + var polygonAxis = this.ComputePolygonSeparation(b2EPCollider.s_polygonAxis); + if (0 !== polygonAxis.type && polygonAxis.separation > this.m_radius) return; + var k_relativeTol = .98; + var k_absoluteTol = .001; + var primaryAxis; + primaryAxis = 0 === polygonAxis.type ? edgeAxis : polygonAxis.separation > k_relativeTol * edgeAxis.separation + k_absoluteTol ? polygonAxis : edgeAxis; + var ie = b2EPCollider.s_ie; + var rf = b2EPCollider.s_rf; + if (1 === primaryAxis.type) { + manifold.type = exports.b2ManifoldType.e_faceA; + var bestIndex = 0; + var bestValue = b2Vec2.DotVV(this.m_normal, this.m_polygonB.normals[0]); + for (var i = 1; i < this.m_polygonB.count; ++i) { + var value = b2Vec2.DotVV(this.m_normal, this.m_polygonB.normals[i]); + if (value < bestValue) { + bestValue = value; + bestIndex = i; + } + } + var i1 = bestIndex; + var i2 = (i1 + 1) % this.m_polygonB.count; + var ie0 = ie[0]; + ie0.v.Copy(this.m_polygonB.vertices[i1]); + ie0.id.cf.indexA = 0; + ie0.id.cf.indexB = i1; + ie0.id.cf.typeA = exports.b2ContactFeatureType.e_face; + ie0.id.cf.typeB = exports.b2ContactFeatureType.e_vertex; + var ie1 = ie[1]; + ie1.v.Copy(this.m_polygonB.vertices[i2]); + ie1.id.cf.indexA = 0; + ie1.id.cf.indexB = i2; + ie1.id.cf.typeA = exports.b2ContactFeatureType.e_face; + ie1.id.cf.typeB = exports.b2ContactFeatureType.e_vertex; + if (this.m_front) { + rf.i1 = 0; + rf.i2 = 1; + rf.v1.Copy(this.m_v1); + rf.v2.Copy(this.m_v2); + rf.normal.Copy(this.m_normal1); + } else { + rf.i1 = 1; + rf.i2 = 0; + rf.v1.Copy(this.m_v2); + rf.v2.Copy(this.m_v1); + rf.normal.Copy(this.m_normal1).SelfNeg(); + } + } else { + manifold.type = exports.b2ManifoldType.e_faceB; + var ie0 = ie[0]; + ie0.v.Copy(this.m_v1); + ie0.id.cf.indexA = 0; + ie0.id.cf.indexB = primaryAxis.index; + ie0.id.cf.typeA = exports.b2ContactFeatureType.e_vertex; + ie0.id.cf.typeB = exports.b2ContactFeatureType.e_face; + var ie1 = ie[1]; + ie1.v.Copy(this.m_v2); + ie1.id.cf.indexA = 0; + ie1.id.cf.indexB = primaryAxis.index; + ie1.id.cf.typeA = exports.b2ContactFeatureType.e_vertex; + ie1.id.cf.typeB = exports.b2ContactFeatureType.e_face; + rf.i1 = primaryAxis.index; + rf.i2 = (rf.i1 + 1) % this.m_polygonB.count; + rf.v1.Copy(this.m_polygonB.vertices[rf.i1]); + rf.v2.Copy(this.m_polygonB.vertices[rf.i2]); + rf.normal.Copy(this.m_polygonB.normals[rf.i1]); + } + rf.sideNormal1.Set(rf.normal.y, -rf.normal.x); + rf.sideNormal2.Copy(rf.sideNormal1).SelfNeg(); + rf.sideOffset1 = b2Vec2.DotVV(rf.sideNormal1, rf.v1); + rf.sideOffset2 = b2Vec2.DotVV(rf.sideNormal2, rf.v2); + var clipPoints1 = b2EPCollider.s_clipPoints1; + var clipPoints2 = b2EPCollider.s_clipPoints2; + var np = 0; + np = b2ClipSegmentToLine(clipPoints1, ie, rf.sideNormal1, rf.sideOffset1, rf.i1); + if (np < b2_maxManifoldPoints) return; + np = b2ClipSegmentToLine(clipPoints2, clipPoints1, rf.sideNormal2, rf.sideOffset2, rf.i2); + if (np < b2_maxManifoldPoints) return; + if (1 === primaryAxis.type) { + manifold.localNormal.Copy(rf.normal); + manifold.localPoint.Copy(rf.v1); + } else { + manifold.localNormal.Copy(polygonB.m_normals[rf.i1]); + manifold.localPoint.Copy(polygonB.m_vertices[rf.i1]); + } + var pointCount = 0; + for (var i = 0; i < b2_maxManifoldPoints; ++i) { + var separation = void 0; + separation = b2Vec2.DotVV(rf.normal, b2Vec2.SubVV(clipPoints2[i].v, rf.v1, b2Vec2.s_t0)); + if (separation <= this.m_radius) { + var cp = manifold.points[pointCount]; + if (1 === primaryAxis.type) { + b2Transform.MulTXV(this.m_xf, clipPoints2[i].v, cp.localPoint); + cp.id = clipPoints2[i].id; + } else { + cp.localPoint.Copy(clipPoints2[i].v); + cp.id.cf.typeA = clipPoints2[i].id.cf.typeB; + cp.id.cf.typeB = clipPoints2[i].id.cf.typeA; + cp.id.cf.indexA = clipPoints2[i].id.cf.indexB; + cp.id.cf.indexB = clipPoints2[i].id.cf.indexA; + } + ++pointCount; + } + } + manifold.pointCount = pointCount; + }; + b2EPCollider.prototype.ComputeEdgeSeparation = function(out) { + var axis = out; + axis.type = 1; + axis.index = this.m_front ? 0 : 1; + axis.separation = b2_maxFloat; + for (var i = 0; i < this.m_polygonB.count; ++i) { + var s = b2Vec2.DotVV(this.m_normal, b2Vec2.SubVV(this.m_polygonB.vertices[i], this.m_v1, b2Vec2.s_t0)); + s < axis.separation && (axis.separation = s); + } + return axis; + }; + b2EPCollider.prototype.ComputePolygonSeparation = function(out) { + var axis = out; + axis.type = 0; + axis.index = -1; + axis.separation = -b2_maxFloat; + var perp = b2EPCollider.s_perp.Set(-this.m_normal.y, this.m_normal.x); + for (var i = 0; i < this.m_polygonB.count; ++i) { + var n = b2Vec2.NegV(this.m_polygonB.normals[i], b2EPCollider.s_n); + var s1 = b2Vec2.DotVV(n, b2Vec2.SubVV(this.m_polygonB.vertices[i], this.m_v1, b2Vec2.s_t0)); + var s2 = b2Vec2.DotVV(n, b2Vec2.SubVV(this.m_polygonB.vertices[i], this.m_v2, b2Vec2.s_t0)); + var s = b2Min(s1, s2); + if (s > this.m_radius) { + axis.type = 2; + axis.index = i; + axis.separation = s; + return axis; + } + if (b2Vec2.DotVV(n, perp) >= 0) { + if (b2Vec2.DotVV(b2Vec2.SubVV(n, this.m_upperLimit, b2Vec2.s_t0), this.m_normal) < -b2_angularSlop) continue; + } else if (b2Vec2.DotVV(b2Vec2.SubVV(n, this.m_lowerLimit, b2Vec2.s_t0), this.m_normal) < -b2_angularSlop) continue; + if (s > axis.separation) { + axis.type = 2; + axis.index = i; + axis.separation = s; + } + } + return axis; + }; + b2EPCollider.s_edge1 = new b2Vec2(); + b2EPCollider.s_edge0 = new b2Vec2(); + b2EPCollider.s_edge2 = new b2Vec2(); + b2EPCollider.s_ie = b2ClipVertex.MakeArray(2); + b2EPCollider.s_rf = new b2ReferenceFace(); + b2EPCollider.s_clipPoints1 = b2ClipVertex.MakeArray(2); + b2EPCollider.s_clipPoints2 = b2ClipVertex.MakeArray(2); + b2EPCollider.s_edgeAxis = new b2EPAxis(); + b2EPCollider.s_polygonAxis = new b2EPAxis(); + b2EPCollider.s_n = new b2Vec2(); + b2EPCollider.s_perp = new b2Vec2(); + return b2EPCollider; + })(); + var b2CollideEdgeAndPolygon_s_collider = new b2EPCollider(); + function b2CollideEdgeAndPolygon(manifold, edgeA, xfA, polygonB, xfB) { + var collider = b2CollideEdgeAndPolygon_s_collider; + collider.Collide(manifold, edgeA, xfA, polygonB, xfB); + } + var b2MassData = (function() { + function b2MassData() { + this.mass = 0; + this.center = new b2Vec2(0, 0); + this.I = 0; + } + return b2MassData; + })(); + (function(b2ShapeType) { + b2ShapeType[b2ShapeType["e_unknown"] = -1] = "e_unknown"; + b2ShapeType[b2ShapeType["e_circleShape"] = 0] = "e_circleShape"; + b2ShapeType[b2ShapeType["e_edgeShape"] = 1] = "e_edgeShape"; + b2ShapeType[b2ShapeType["e_polygonShape"] = 2] = "e_polygonShape"; + b2ShapeType[b2ShapeType["e_chainShape"] = 3] = "e_chainShape"; + b2ShapeType[b2ShapeType["e_shapeTypeCount"] = 4] = "e_shapeTypeCount"; + })(exports.b2ShapeType || (exports.b2ShapeType = {})); + var b2Shape = (function() { + function b2Shape(type, radius) { + this.m_type = exports.b2ShapeType.e_unknown; + this.m_radius = 0; + this.m_type = type; + this.m_radius = radius; + } + b2Shape.prototype.Copy = function(other) { + this.m_radius = other.m_radius; + return this; + }; + b2Shape.prototype.GetType = function() { + return this.m_type; + }; + return b2Shape; + })(); + var extendStatics = Object.setPrototypeOf || { + __proto__: [] + } instanceof Array && function(d, b) { + d.__proto__ = b; + } || function(d, b) { + for (var p in b) b.hasOwnProperty(p) && (d[p] = b[p]); + }; + function __extends(d, b) { + extendStatics(d, b); + function __() { + this.constructor = d; + } + d.prototype = null === b ? Object.create(b) : (__.prototype = b.prototype, new __()); + } + var b2CircleShape = (function(_super) { + __extends(b2CircleShape, _super); + function b2CircleShape(radius) { + void 0 === radius && (radius = 0); + var _this = _super.call(this, exports.b2ShapeType.e_circleShape, radius) || this; + _this.m_p = new b2Vec2(); + return _this; + } + b2CircleShape.prototype.Set = function(position, radius) { + void 0 === radius && (radius = this.m_radius); + this.m_p.Copy(position); + this.m_radius = radius; + return this; + }; + b2CircleShape.prototype.Clone = function() { + return new b2CircleShape().Copy(this); + }; + b2CircleShape.prototype.Copy = function(other) { + _super.prototype.Copy.call(this, other); + this.m_p.Copy(other.m_p); + return this; + }; + b2CircleShape.prototype.GetChildCount = function() { + return 1; + }; + b2CircleShape.prototype.TestPoint = function(transform, p) { + var center = b2Transform.MulXV(transform, this.m_p, b2CircleShape.TestPoint_s_center); + var d = b2Vec2.SubVV(p, center, b2CircleShape.TestPoint_s_d); + return b2Vec2.DotVV(d, d) <= b2Sq(this.m_radius); + }; + b2CircleShape.prototype.ComputeDistance = function(xf, p, normal, childIndex) { + var center = b2Transform.MulXV(xf, this.m_p, b2CircleShape.ComputeDistance_s_center); + b2Vec2.SubVV(p, center, normal); + return normal.Normalize() - this.m_radius; + }; + b2CircleShape.prototype.RayCast = function(output, input, transform, childIndex) { + var position = b2Transform.MulXV(transform, this.m_p, b2CircleShape.RayCast_s_position); + var s = b2Vec2.SubVV(input.p1, position, b2CircleShape.RayCast_s_s); + var b = b2Vec2.DotVV(s, s) - b2Sq(this.m_radius); + var r = b2Vec2.SubVV(input.p2, input.p1, b2CircleShape.RayCast_s_r); + var c = b2Vec2.DotVV(s, r); + var rr = b2Vec2.DotVV(r, r); + var sigma = c * c - rr * b; + if (sigma < 0 || rr < b2_epsilon) return false; + var a = -(c + b2Sqrt(sigma)); + if (0 <= a && a <= input.maxFraction * rr) { + a /= rr; + output.fraction = a; + b2Vec2.AddVMulSV(s, a, r, output.normal).SelfNormalize(); + return true; + } + return false; + }; + b2CircleShape.prototype.ComputeAABB = function(aabb, transform, childIndex) { + var p = b2Transform.MulXV(transform, this.m_p, b2CircleShape.ComputeAABB_s_p); + aabb.lowerBound.Set(p.x - this.m_radius, p.y - this.m_radius); + aabb.upperBound.Set(p.x + this.m_radius, p.y + this.m_radius); + }; + b2CircleShape.prototype.ComputeMass = function(massData, density) { + var radius_sq = b2Sq(this.m_radius); + massData.mass = density * b2_pi * radius_sq; + massData.center.Copy(this.m_p); + massData.I = massData.mass * (.5 * radius_sq + b2Vec2.DotVV(this.m_p, this.m_p)); + }; + b2CircleShape.prototype.SetupDistanceProxy = function(proxy, index) { + proxy.m_vertices = proxy.m_buffer; + proxy.m_vertices[0].Copy(this.m_p); + proxy.m_count = 1; + proxy.m_radius = this.m_radius; + }; + b2CircleShape.prototype.ComputeSubmergedArea = function(normal, offset, xf, c) { + var p = b2Transform.MulXV(xf, this.m_p, new b2Vec2()); + var l = -(b2Vec2.DotVV(normal, p) - offset); + if (l < -this.m_radius + b2_epsilon) return 0; + if (l > this.m_radius) { + c.Copy(p); + return b2_pi * this.m_radius * this.m_radius; + } + var r2 = this.m_radius * this.m_radius; + var l2 = l * l; + var area = r2 * (b2Asin(l / this.m_radius) + b2_pi / 2) + l * b2Sqrt(r2 - l2); + var com = -2 / 3 * b2Pow(r2 - l2, 1.5) / area; + c.x = p.x + normal.x * com; + c.y = p.y + normal.y * com; + return area; + }; + b2CircleShape.prototype.Dump = function(log) { + log(" const shape: b2CircleShape = new b2CircleShape();\n"); + log(" shape.m_radius = %.15f;\n", this.m_radius); + log(" shape.m_p.Set(%.15f, %.15f);\n", this.m_p.x, this.m_p.y); + }; + b2CircleShape.TestPoint_s_center = new b2Vec2(); + b2CircleShape.TestPoint_s_d = new b2Vec2(); + b2CircleShape.ComputeDistance_s_center = new b2Vec2(); + b2CircleShape.RayCast_s_position = new b2Vec2(); + b2CircleShape.RayCast_s_s = new b2Vec2(); + b2CircleShape.RayCast_s_r = new b2Vec2(); + b2CircleShape.ComputeAABB_s_p = new b2Vec2(); + return b2CircleShape; + })(b2Shape); + var b2PolygonShape = (function(_super) { + __extends(b2PolygonShape, _super); + function b2PolygonShape() { + var _this = _super.call(this, exports.b2ShapeType.e_polygonShape, b2_polygonRadius) || this; + _this.m_centroid = new b2Vec2(0, 0); + _this.m_vertices = []; + _this.m_normals = []; + _this.m_count = 0; + return _this; + } + b2PolygonShape.prototype.Clone = function() { + return new b2PolygonShape().Copy(this); + }; + b2PolygonShape.prototype.Copy = function(other) { + _super.prototype.Copy.call(this, other); + this.m_centroid.Copy(other.m_centroid); + this.m_count = other.m_count; + this.m_vertices = b2Vec2.MakeArray(this.m_count); + this.m_normals = b2Vec2.MakeArray(this.m_count); + for (var i = 0; i < this.m_count; ++i) { + this.m_vertices[i].Copy(other.m_vertices[i]); + this.m_normals[i].Copy(other.m_normals[i]); + } + return this; + }; + b2PolygonShape.prototype.GetChildCount = function() { + return 1; + }; + b2PolygonShape.prototype.Set = function(vertices, count, start) { + void 0 === count && (count = vertices.length); + void 0 === start && (start = 0); + if (count < 3) return this.SetAsBox(1, 1); + var n = b2Min(count, b2_maxPolygonVertices); + var ps = b2PolygonShape.Set_s_ps; + var tempCount = 0; + for (var i = 0; i < n; ++i) { + var v = vertices[start + i]; + var unique = true; + for (var j = 0; j < tempCount; ++j) if (b2Vec2.DistanceSquaredVV(v, ps[j]) < .5 * b2_linearSlop * (.5 * b2_linearSlop)) { + unique = false; + break; + } + unique && ps[tempCount++].Copy(v); + } + n = tempCount; + if (n < 3) return this.SetAsBox(1, 1); + var i0 = 0; + var x0 = ps[0].x; + for (var i = 1; i < n; ++i) { + var x = ps[i].x; + if (x > x0 || x === x0 && ps[i].y < ps[i0].y) { + i0 = i; + x0 = x; + } + } + var hull = b2PolygonShape.Set_s_hull; + var m = 0; + var ih = i0; + for (;;) { + hull[m] = ih; + var ie = 0; + for (var j = 1; j < n; ++j) { + if (ie === ih) { + ie = j; + continue; + } + var r = b2Vec2.SubVV(ps[ie], ps[hull[m]], b2PolygonShape.Set_s_r); + var v = b2Vec2.SubVV(ps[j], ps[hull[m]], b2PolygonShape.Set_s_v); + var c = b2Vec2.CrossVV(r, v); + c < 0 && (ie = j); + 0 === c && v.LengthSquared() > r.LengthSquared() && (ie = j); + } + ++m; + ih = ie; + if (ie === i0) break; + } + this.m_count = m; + this.m_vertices = b2Vec2.MakeArray(this.m_count); + this.m_normals = b2Vec2.MakeArray(this.m_count); + for (var i = 0; i < m; ++i) this.m_vertices[i].Copy(ps[hull[i]]); + for (var i = 0; i < m; ++i) { + var vertexi1 = this.m_vertices[i]; + var vertexi2 = this.m_vertices[(i + 1) % m]; + var edge = b2Vec2.SubVV(vertexi2, vertexi1, b2Vec2.s_t0); + b2Vec2.CrossVOne(edge, this.m_normals[i]).SelfNormalize(); + } + b2PolygonShape.ComputeCentroid(this.m_vertices, m, this.m_centroid); + return this; + }; + b2PolygonShape.prototype.SetAsArray = function(vertices, count) { + void 0 === count && (count = vertices.length); + return this.Set(vertices, count); + }; + b2PolygonShape.prototype.SetAsBox = function(hx, hy, center, angle) { + void 0 === angle && (angle = 0); + this.m_count = 4; + this.m_vertices = b2Vec2.MakeArray(this.m_count); + this.m_normals = b2Vec2.MakeArray(this.m_count); + this.m_vertices[0].Set(-hx, -hy); + this.m_vertices[1].Set(hx, -hy); + this.m_vertices[2].Set(hx, hy); + this.m_vertices[3].Set(-hx, hy); + this.m_normals[0].Set(0, -1); + this.m_normals[1].Set(1, 0); + this.m_normals[2].Set(0, 1); + this.m_normals[3].Set(-1, 0); + this.m_centroid.SetZero(); + if (center) { + this.m_centroid.Copy(center); + var xf = new b2Transform(); + xf.SetPosition(center); + xf.SetRotationAngle(angle); + for (var i = 0; i < this.m_count; ++i) { + b2Transform.MulXV(xf, this.m_vertices[i], this.m_vertices[i]); + b2Rot.MulRV(xf.q, this.m_normals[i], this.m_normals[i]); + } + } + return this; + }; + b2PolygonShape.prototype.TestPoint = function(xf, p) { + var pLocal = b2Transform.MulTXV(xf, p, b2PolygonShape.TestPoint_s_pLocal); + for (var i = 0; i < this.m_count; ++i) { + var dot = b2Vec2.DotVV(this.m_normals[i], b2Vec2.SubVV(pLocal, this.m_vertices[i], b2Vec2.s_t0)); + if (dot > 0) return false; + } + return true; + }; + b2PolygonShape.prototype.ComputeDistance = function(xf, p, normal, childIndex) { + var pLocal = b2Transform.MulTXV(xf, p, b2PolygonShape.ComputeDistance_s_pLocal); + var maxDistance = -b2_maxFloat; + var normalForMaxDistance = b2PolygonShape.ComputeDistance_s_normalForMaxDistance.Copy(pLocal); + for (var i = 0; i < this.m_count; ++i) { + var dot = b2Vec2.DotVV(this.m_normals[i], b2Vec2.SubVV(pLocal, this.m_vertices[i], b2Vec2.s_t0)); + if (dot > maxDistance) { + maxDistance = dot; + normalForMaxDistance.Copy(this.m_normals[i]); + } + } + if (maxDistance > 0) { + var minDistance = b2PolygonShape.ComputeDistance_s_minDistance.Copy(normalForMaxDistance); + var minDistance2 = maxDistance * maxDistance; + for (var i = 0; i < this.m_count; ++i) { + var distance = b2Vec2.SubVV(pLocal, this.m_vertices[i], b2PolygonShape.ComputeDistance_s_distance); + var distance2 = distance.LengthSquared(); + if (minDistance2 > distance2) { + minDistance.Copy(distance); + minDistance2 = distance2; + } + } + b2Rot.MulRV(xf.q, minDistance, normal); + normal.Normalize(); + return Math.sqrt(minDistance2); + } + b2Rot.MulRV(xf.q, normalForMaxDistance, normal); + return maxDistance; + }; + b2PolygonShape.prototype.RayCast = function(output, input, xf, childIndex) { + var p1 = b2Transform.MulTXV(xf, input.p1, b2PolygonShape.RayCast_s_p1); + var p2 = b2Transform.MulTXV(xf, input.p2, b2PolygonShape.RayCast_s_p2); + var d = b2Vec2.SubVV(p2, p1, b2PolygonShape.RayCast_s_d); + var lower = 0, upper = input.maxFraction; + var index = -1; + for (var i = 0; i < this.m_count; ++i) { + var numerator = b2Vec2.DotVV(this.m_normals[i], b2Vec2.SubVV(this.m_vertices[i], p1, b2Vec2.s_t0)); + var denominator = b2Vec2.DotVV(this.m_normals[i], d); + if (0 === denominator) { + if (numerator < 0) return false; + } else if (denominator < 0 && numerator < lower * denominator) { + lower = numerator / denominator; + index = i; + } else denominator > 0 && numerator < upper * denominator && (upper = numerator / denominator); + if (upper < lower) return false; + } + if (index >= 0) { + output.fraction = lower; + b2Rot.MulRV(xf.q, this.m_normals[index], output.normal); + return true; + } + return false; + }; + b2PolygonShape.prototype.ComputeAABB = function(aabb, xf, childIndex) { + var lower = b2Transform.MulXV(xf, this.m_vertices[0], aabb.lowerBound); + var upper = aabb.upperBound.Copy(lower); + for (var i = 0; i < this.m_count; ++i) { + var v = b2Transform.MulXV(xf, this.m_vertices[i], b2PolygonShape.ComputeAABB_s_v); + b2Vec2.MinV(v, lower, lower); + b2Vec2.MaxV(v, upper, upper); + } + var r = this.m_radius; + lower.SelfSubXY(r, r); + upper.SelfAddXY(r, r); + }; + b2PolygonShape.prototype.ComputeMass = function(massData, density) { + var center = b2PolygonShape.ComputeMass_s_center.SetZero(); + var area = 0; + var I = 0; + var s = b2PolygonShape.ComputeMass_s_s.SetZero(); + for (var i = 0; i < this.m_count; ++i) s.SelfAdd(this.m_vertices[i]); + s.SelfMul(1 / this.m_count); + var k_inv3 = 1 / 3; + for (var i = 0; i < this.m_count; ++i) { + var e1 = b2Vec2.SubVV(this.m_vertices[i], s, b2PolygonShape.ComputeMass_s_e1); + var e2 = b2Vec2.SubVV(this.m_vertices[(i + 1) % this.m_count], s, b2PolygonShape.ComputeMass_s_e2); + var D = b2Vec2.CrossVV(e1, e2); + var triangleArea = .5 * D; + area += triangleArea; + center.SelfAdd(b2Vec2.MulSV(triangleArea * k_inv3, b2Vec2.AddVV(e1, e2, b2Vec2.s_t0), b2Vec2.s_t1)); + var ex1 = e1.x; + var ey1 = e1.y; + var ex2 = e2.x; + var ey2 = e2.y; + var intx2 = ex1 * ex1 + ex2 * ex1 + ex2 * ex2; + var inty2 = ey1 * ey1 + ey2 * ey1 + ey2 * ey2; + I += .25 * k_inv3 * D * (intx2 + inty2); + } + massData.mass = density * area; + center.SelfMul(1 / area); + b2Vec2.AddVV(center, s, massData.center); + massData.I = density * I; + massData.I += massData.mass * (b2Vec2.DotVV(massData.center, massData.center) - b2Vec2.DotVV(center, center)); + }; + b2PolygonShape.prototype.Validate = function() { + for (var i = 0; i < this.m_count; ++i) { + var i1 = i; + var i2 = (i + 1) % this.m_count; + var p = this.m_vertices[i1]; + var e = b2Vec2.SubVV(this.m_vertices[i2], p, b2PolygonShape.Validate_s_e); + for (var j = 0; j < this.m_count; ++j) { + if (j === i1 || j === i2) continue; + var v = b2Vec2.SubVV(this.m_vertices[j], p, b2PolygonShape.Validate_s_v); + var c = b2Vec2.CrossVV(e, v); + if (c < 0) return false; + } + } + return true; + }; + b2PolygonShape.prototype.SetupDistanceProxy = function(proxy, index) { + proxy.m_vertices = this.m_vertices; + proxy.m_count = this.m_count; + proxy.m_radius = this.m_radius; + }; + b2PolygonShape.prototype.ComputeSubmergedArea = function(normal, offset, xf, c) { + var normalL = b2Rot.MulTRV(xf.q, normal, b2PolygonShape.ComputeSubmergedArea_s_normalL); + var offsetL = offset - b2Vec2.DotVV(normal, xf.p); + var depths = b2PolygonShape.ComputeSubmergedArea_s_depths; + var diveCount = 0; + var intoIndex = -1; + var outoIndex = -1; + var lastSubmerged = false; + for (var i_1 = 0; i_1 < this.m_count; ++i_1) { + depths[i_1] = b2Vec2.DotVV(normalL, this.m_vertices[i_1]) - offsetL; + var isSubmerged = depths[i_1] < -b2_epsilon; + if (i_1 > 0) if (isSubmerged) { + if (!lastSubmerged) { + intoIndex = i_1 - 1; + diveCount++; + } + } else if (lastSubmerged) { + outoIndex = i_1 - 1; + diveCount++; + } + lastSubmerged = isSubmerged; + } + switch (diveCount) { + case 0: + if (lastSubmerged) { + var md = b2PolygonShape.ComputeSubmergedArea_s_md; + this.ComputeMass(md, 1); + b2Transform.MulXV(xf, md.center, c); + return md.mass; + } + return 0; + + case 1: + -1 === intoIndex ? intoIndex = this.m_count - 1 : outoIndex = this.m_count - 1; + } + var intoIndex2 = (intoIndex + 1) % this.m_count; + var outoIndex2 = (outoIndex + 1) % this.m_count; + var intoLamdda = (0 - depths[intoIndex]) / (depths[intoIndex2] - depths[intoIndex]); + var outoLamdda = (0 - depths[outoIndex]) / (depths[outoIndex2] - depths[outoIndex]); + var intoVec = b2PolygonShape.ComputeSubmergedArea_s_intoVec.Set(this.m_vertices[intoIndex].x * (1 - intoLamdda) + this.m_vertices[intoIndex2].x * intoLamdda, this.m_vertices[intoIndex].y * (1 - intoLamdda) + this.m_vertices[intoIndex2].y * intoLamdda); + var outoVec = b2PolygonShape.ComputeSubmergedArea_s_outoVec.Set(this.m_vertices[outoIndex].x * (1 - outoLamdda) + this.m_vertices[outoIndex2].x * outoLamdda, this.m_vertices[outoIndex].y * (1 - outoLamdda) + this.m_vertices[outoIndex2].y * outoLamdda); + var area = 0; + var center = b2PolygonShape.ComputeSubmergedArea_s_center.SetZero(); + var p2 = this.m_vertices[intoIndex2]; + var p3; + var i = intoIndex2; + while (i !== outoIndex2) { + i = (i + 1) % this.m_count; + p3 = i === outoIndex2 ? outoVec : this.m_vertices[i]; + var triangleArea = .5 * ((p2.x - intoVec.x) * (p3.y - intoVec.y) - (p2.y - intoVec.y) * (p3.x - intoVec.x)); + area += triangleArea; + center.x += triangleArea * (intoVec.x + p2.x + p3.x) / 3; + center.y += triangleArea * (intoVec.y + p2.y + p3.y) / 3; + p2 = p3; + } + center.SelfMul(1 / area); + b2Transform.MulXV(xf, center, c); + return area; + }; + b2PolygonShape.prototype.Dump = function(log) { + log(" const shape: b2PolygonShape = new b2PolygonShape();\n"); + log(" const vs: b2Vec2[] = b2Vec2.MakeArray(%d);\n", b2_maxPolygonVertices); + for (var i = 0; i < this.m_count; ++i) log(" vs[%d].Set(%.15f, %.15f);\n", i, this.m_vertices[i].x, this.m_vertices[i].y); + log(" shape.Set(vs, %d);\n", this.m_count); + }; + b2PolygonShape.ComputeCentroid = function(vs, count, out) { + var c = out; + c.SetZero(); + var area = 0; + var pRef = b2PolygonShape.ComputeCentroid_s_pRef.SetZero(); + var inv3 = 1 / 3; + for (var i = 0; i < count; ++i) { + var p1 = pRef; + var p2 = vs[i]; + var p3 = vs[(i + 1) % count]; + var e1 = b2Vec2.SubVV(p2, p1, b2PolygonShape.ComputeCentroid_s_e1); + var e2 = b2Vec2.SubVV(p3, p1, b2PolygonShape.ComputeCentroid_s_e2); + var D = b2Vec2.CrossVV(e1, e2); + var triangleArea = .5 * D; + area += triangleArea; + c.x += triangleArea * inv3 * (p1.x + p2.x + p3.x); + c.y += triangleArea * inv3 * (p1.y + p2.y + p3.y); + } + c.SelfMul(1 / area); + return c; + }; + b2PolygonShape.Set_s_ps = b2Vec2.MakeArray(b2_maxPolygonVertices); + b2PolygonShape.Set_s_hull = b2MakeNumberArray(b2_maxPolygonVertices); + b2PolygonShape.Set_s_r = new b2Vec2(); + b2PolygonShape.Set_s_v = new b2Vec2(); + b2PolygonShape.TestPoint_s_pLocal = new b2Vec2(); + b2PolygonShape.ComputeDistance_s_pLocal = new b2Vec2(); + b2PolygonShape.ComputeDistance_s_normalForMaxDistance = new b2Vec2(); + b2PolygonShape.ComputeDistance_s_minDistance = new b2Vec2(); + b2PolygonShape.ComputeDistance_s_distance = new b2Vec2(); + b2PolygonShape.RayCast_s_p1 = new b2Vec2(); + b2PolygonShape.RayCast_s_p2 = new b2Vec2(); + b2PolygonShape.RayCast_s_d = new b2Vec2(); + b2PolygonShape.ComputeAABB_s_v = new b2Vec2(); + b2PolygonShape.ComputeMass_s_center = new b2Vec2(); + b2PolygonShape.ComputeMass_s_s = new b2Vec2(); + b2PolygonShape.ComputeMass_s_e1 = new b2Vec2(); + b2PolygonShape.ComputeMass_s_e2 = new b2Vec2(); + b2PolygonShape.Validate_s_e = new b2Vec2(); + b2PolygonShape.Validate_s_v = new b2Vec2(); + b2PolygonShape.ComputeSubmergedArea_s_normalL = new b2Vec2(); + b2PolygonShape.ComputeSubmergedArea_s_depths = b2MakeNumberArray(b2_maxPolygonVertices); + b2PolygonShape.ComputeSubmergedArea_s_md = new b2MassData(); + b2PolygonShape.ComputeSubmergedArea_s_intoVec = new b2Vec2(); + b2PolygonShape.ComputeSubmergedArea_s_outoVec = new b2Vec2(); + b2PolygonShape.ComputeSubmergedArea_s_center = new b2Vec2(); + b2PolygonShape.ComputeCentroid_s_pRef = new b2Vec2(); + b2PolygonShape.ComputeCentroid_s_e1 = new b2Vec2(); + b2PolygonShape.ComputeCentroid_s_e2 = new b2Vec2(); + return b2PolygonShape; + })(b2Shape); + var b2EdgeShape = (function(_super) { + __extends(b2EdgeShape, _super); + function b2EdgeShape() { + var _this = _super.call(this, exports.b2ShapeType.e_edgeShape, b2_polygonRadius) || this; + _this.m_vertex1 = new b2Vec2(); + _this.m_vertex2 = new b2Vec2(); + _this.m_vertex0 = new b2Vec2(); + _this.m_vertex3 = new b2Vec2(); + _this.m_hasVertex0 = false; + _this.m_hasVertex3 = false; + return _this; + } + b2EdgeShape.prototype.Set = function(v1, v2) { + this.m_vertex1.Copy(v1); + this.m_vertex2.Copy(v2); + this.m_hasVertex0 = false; + this.m_hasVertex3 = false; + return this; + }; + b2EdgeShape.prototype.Clone = function() { + return new b2EdgeShape().Copy(this); + }; + b2EdgeShape.prototype.Copy = function(other) { + _super.prototype.Copy.call(this, other); + this.m_vertex1.Copy(other.m_vertex1); + this.m_vertex2.Copy(other.m_vertex2); + this.m_vertex0.Copy(other.m_vertex0); + this.m_vertex3.Copy(other.m_vertex3); + this.m_hasVertex0 = other.m_hasVertex0; + this.m_hasVertex3 = other.m_hasVertex3; + return this; + }; + b2EdgeShape.prototype.GetChildCount = function() { + return 1; + }; + b2EdgeShape.prototype.TestPoint = function(xf, p) { + return false; + }; + b2EdgeShape.prototype.ComputeDistance = function(xf, p, normal, childIndex) { + var v1 = b2Transform.MulXV(xf, this.m_vertex1, b2EdgeShape.ComputeDistance_s_v1); + var v2 = b2Transform.MulXV(xf, this.m_vertex2, b2EdgeShape.ComputeDistance_s_v2); + var d = b2Vec2.SubVV(p, v1, b2EdgeShape.ComputeDistance_s_d); + var s = b2Vec2.SubVV(v2, v1, b2EdgeShape.ComputeDistance_s_s); + var ds = b2Vec2.DotVV(d, s); + if (ds > 0) { + var s2 = b2Vec2.DotVV(s, s); + ds > s2 ? b2Vec2.SubVV(p, v2, d) : d.SelfMulSub(ds / s2, s); + } + normal.Copy(d); + return normal.Normalize(); + }; + b2EdgeShape.prototype.RayCast = function(output, input, xf, childIndex) { + var p1 = b2Transform.MulTXV(xf, input.p1, b2EdgeShape.RayCast_s_p1); + var p2 = b2Transform.MulTXV(xf, input.p2, b2EdgeShape.RayCast_s_p2); + var d = b2Vec2.SubVV(p2, p1, b2EdgeShape.RayCast_s_d); + var v1 = this.m_vertex1; + var v2 = this.m_vertex2; + var e = b2Vec2.SubVV(v2, v1, b2EdgeShape.RayCast_s_e); + var normal = output.normal.Set(e.y, -e.x).SelfNormalize(); + var numerator = b2Vec2.DotVV(normal, b2Vec2.SubVV(v1, p1, b2Vec2.s_t0)); + var denominator = b2Vec2.DotVV(normal, d); + if (0 === denominator) return false; + var t = numerator / denominator; + if (t < 0 || input.maxFraction < t) return false; + var q = b2Vec2.AddVMulSV(p1, t, d, b2EdgeShape.RayCast_s_q); + var r = b2Vec2.SubVV(v2, v1, b2EdgeShape.RayCast_s_r); + var rr = b2Vec2.DotVV(r, r); + if (0 === rr) return false; + var s = b2Vec2.DotVV(b2Vec2.SubVV(q, v1, b2Vec2.s_t0), r) / rr; + if (s < 0 || 1 < s) return false; + output.fraction = t; + b2Rot.MulRV(xf.q, output.normal, output.normal); + numerator > 0 && output.normal.SelfNeg(); + return true; + }; + b2EdgeShape.prototype.ComputeAABB = function(aabb, xf, childIndex) { + var v1 = b2Transform.MulXV(xf, this.m_vertex1, b2EdgeShape.ComputeAABB_s_v1); + var v2 = b2Transform.MulXV(xf, this.m_vertex2, b2EdgeShape.ComputeAABB_s_v2); + b2Vec2.MinV(v1, v2, aabb.lowerBound); + b2Vec2.MaxV(v1, v2, aabb.upperBound); + var r = this.m_radius; + aabb.lowerBound.SelfSubXY(r, r); + aabb.upperBound.SelfAddXY(r, r); + }; + b2EdgeShape.prototype.ComputeMass = function(massData, density) { + massData.mass = 0; + b2Vec2.MidVV(this.m_vertex1, this.m_vertex2, massData.center); + massData.I = 0; + }; + b2EdgeShape.prototype.SetupDistanceProxy = function(proxy, index) { + proxy.m_vertices = proxy.m_buffer; + proxy.m_vertices[0].Copy(this.m_vertex1); + proxy.m_vertices[1].Copy(this.m_vertex2); + proxy.m_count = 2; + proxy.m_radius = this.m_radius; + }; + b2EdgeShape.prototype.ComputeSubmergedArea = function(normal, offset, xf, c) { + c.SetZero(); + return 0; + }; + b2EdgeShape.prototype.Dump = function(log) { + log(" const shape: b2EdgeShape = new b2EdgeShape();\n"); + log(" shape.m_radius = %.15f;\n", this.m_radius); + log(" shape.m_vertex0.Set(%.15f, %.15f);\n", this.m_vertex0.x, this.m_vertex0.y); + log(" shape.m_vertex1.Set(%.15f, %.15f);\n", this.m_vertex1.x, this.m_vertex1.y); + log(" shape.m_vertex2.Set(%.15f, %.15f);\n", this.m_vertex2.x, this.m_vertex2.y); + log(" shape.m_vertex3.Set(%.15f, %.15f);\n", this.m_vertex3.x, this.m_vertex3.y); + log(" shape.m_hasVertex0 = %s;\n", this.m_hasVertex0); + log(" shape.m_hasVertex3 = %s;\n", this.m_hasVertex3); + }; + b2EdgeShape.ComputeDistance_s_v1 = new b2Vec2(); + b2EdgeShape.ComputeDistance_s_v2 = new b2Vec2(); + b2EdgeShape.ComputeDistance_s_d = new b2Vec2(); + b2EdgeShape.ComputeDistance_s_s = new b2Vec2(); + b2EdgeShape.RayCast_s_p1 = new b2Vec2(); + b2EdgeShape.RayCast_s_p2 = new b2Vec2(); + b2EdgeShape.RayCast_s_d = new b2Vec2(); + b2EdgeShape.RayCast_s_e = new b2Vec2(); + b2EdgeShape.RayCast_s_q = new b2Vec2(); + b2EdgeShape.RayCast_s_r = new b2Vec2(); + b2EdgeShape.ComputeAABB_s_v1 = new b2Vec2(); + b2EdgeShape.ComputeAABB_s_v2 = new b2Vec2(); + return b2EdgeShape; + })(b2Shape); + var b2ChainShape = (function(_super) { + __extends(b2ChainShape, _super); + function b2ChainShape() { + var _this = _super.call(this, exports.b2ShapeType.e_chainShape, b2_polygonRadius) || this; + _this.m_vertices = []; + _this.m_count = 0; + _this.m_prevVertex = new b2Vec2(); + _this.m_nextVertex = new b2Vec2(); + _this.m_hasPrevVertex = false; + _this.m_hasNextVertex = false; + return _this; + } + b2ChainShape.prototype.CreateLoop = function(vertices, count, start) { + void 0 === count && (count = vertices.length); + void 0 === start && (start = 0); + if (count < 3) return this; + this.m_count = count + 1; + this.m_vertices = b2Vec2.MakeArray(this.m_count); + for (var i = 0; i < count; ++i) this.m_vertices[i].Copy(vertices[start + i]); + this.m_vertices[count].Copy(this.m_vertices[0]); + this.m_prevVertex.Copy(this.m_vertices[this.m_count - 2]); + this.m_nextVertex.Copy(this.m_vertices[1]); + this.m_hasPrevVertex = true; + this.m_hasNextVertex = true; + return this; + }; + b2ChainShape.prototype.CreateChain = function(vertices, count, start) { + void 0 === count && (count = vertices.length); + void 0 === start && (start = 0); + this.m_count = count; + this.m_vertices = b2Vec2.MakeArray(count); + for (var i = 0; i < count; ++i) this.m_vertices[i].Copy(vertices[start + i]); + this.m_hasPrevVertex = false; + this.m_hasNextVertex = false; + this.m_prevVertex.SetZero(); + this.m_nextVertex.SetZero(); + return this; + }; + b2ChainShape.prototype.SetPrevVertex = function(prevVertex) { + this.m_prevVertex.Copy(prevVertex); + this.m_hasPrevVertex = true; + return this; + }; + b2ChainShape.prototype.SetNextVertex = function(nextVertex) { + this.m_nextVertex.Copy(nextVertex); + this.m_hasNextVertex = true; + return this; + }; + b2ChainShape.prototype.Clone = function() { + return new b2ChainShape().Copy(this); + }; + b2ChainShape.prototype.Copy = function(other) { + _super.prototype.Copy.call(this, other); + this.CreateChain(other.m_vertices, other.m_count); + this.m_prevVertex.Copy(other.m_prevVertex); + this.m_nextVertex.Copy(other.m_nextVertex); + this.m_hasPrevVertex = other.m_hasPrevVertex; + this.m_hasNextVertex = other.m_hasNextVertex; + return this; + }; + b2ChainShape.prototype.GetChildCount = function() { + return this.m_count - 1; + }; + b2ChainShape.prototype.GetChildEdge = function(edge, index) { + edge.m_type = exports.b2ShapeType.e_edgeShape; + edge.m_radius = this.m_radius; + edge.m_vertex1.Copy(this.m_vertices[index]); + edge.m_vertex2.Copy(this.m_vertices[index + 1]); + if (index > 0) { + edge.m_vertex0.Copy(this.m_vertices[index - 1]); + edge.m_hasVertex0 = true; + } else { + edge.m_vertex0.Copy(this.m_prevVertex); + edge.m_hasVertex0 = this.m_hasPrevVertex; + } + if (index < this.m_count - 2) { + edge.m_vertex3.Copy(this.m_vertices[index + 2]); + edge.m_hasVertex3 = true; + } else { + edge.m_vertex3.Copy(this.m_nextVertex); + edge.m_hasVertex3 = this.m_hasNextVertex; + } + }; + b2ChainShape.prototype.TestPoint = function(xf, p) { + return false; + }; + b2ChainShape.prototype.ComputeDistance = function(xf, p, normal, childIndex) { + var edge = b2ChainShape.ComputeDistance_s_edgeShape; + this.GetChildEdge(edge, childIndex); + return edge.ComputeDistance(xf, p, normal, 0); + }; + b2ChainShape.prototype.RayCast = function(output, input, xf, childIndex) { + var edgeShape = b2ChainShape.RayCast_s_edgeShape; + edgeShape.m_vertex1.Copy(this.m_vertices[childIndex]); + edgeShape.m_vertex2.Copy(this.m_vertices[(childIndex + 1) % this.m_count]); + return edgeShape.RayCast(output, input, xf, 0); + }; + b2ChainShape.prototype.ComputeAABB = function(aabb, xf, childIndex) { + var vertexi1 = this.m_vertices[childIndex]; + var vertexi2 = this.m_vertices[(childIndex + 1) % this.m_count]; + var v1 = b2Transform.MulXV(xf, vertexi1, b2ChainShape.ComputeAABB_s_v1); + var v2 = b2Transform.MulXV(xf, vertexi2, b2ChainShape.ComputeAABB_s_v2); + b2Vec2.MinV(v1, v2, aabb.lowerBound); + b2Vec2.MaxV(v1, v2, aabb.upperBound); + }; + b2ChainShape.prototype.ComputeMass = function(massData, density) { + massData.mass = 0; + massData.center.SetZero(); + massData.I = 0; + }; + b2ChainShape.prototype.SetupDistanceProxy = function(proxy, index) { + proxy.m_vertices = proxy.m_buffer; + proxy.m_vertices[0].Copy(this.m_vertices[index]); + index + 1 < this.m_count ? proxy.m_vertices[1].Copy(this.m_vertices[index + 1]) : proxy.m_vertices[1].Copy(this.m_vertices[0]); + proxy.m_count = 2; + proxy.m_radius = this.m_radius; + }; + b2ChainShape.prototype.ComputeSubmergedArea = function(normal, offset, xf, c) { + c.SetZero(); + return 0; + }; + b2ChainShape.prototype.Dump = function(log) { + log(" const shape: b2ChainShape = new b2ChainShape();\n"); + log(" const vs: b2Vec2[] = b2Vec2.MakeArray(%d);\n", b2_maxPolygonVertices); + for (var i = 0; i < this.m_count; ++i) log(" vs[%d].Set(%.15f, %.15f);\n", i, this.m_vertices[i].x, this.m_vertices[i].y); + log(" shape.CreateChain(vs, %d);\n", this.m_count); + log(" shape.m_prevVertex.Set(%.15f, %.15f);\n", this.m_prevVertex.x, this.m_prevVertex.y); + log(" shape.m_nextVertex.Set(%.15f, %.15f);\n", this.m_nextVertex.x, this.m_nextVertex.y); + log(" shape.m_hasPrevVertex = %s;\n", this.m_hasPrevVertex ? "true" : "false"); + log(" shape.m_hasNextVertex = %s;\n", this.m_hasNextVertex ? "true" : "false"); + }; + b2ChainShape.ComputeDistance_s_edgeShape = new b2EdgeShape(); + b2ChainShape.RayCast_s_edgeShape = new b2EdgeShape(); + b2ChainShape.ComputeAABB_s_v1 = new b2Vec2(); + b2ChainShape.ComputeAABB_s_v2 = new b2Vec2(); + return b2ChainShape; + })(b2Shape); + var b2Filter = (function() { + function b2Filter() { + this.categoryBits = 1; + this.maskBits = 65535; + this.groupIndex = 0; + } + b2Filter.prototype.Clone = function() { + return new b2Filter().Copy(this); + }; + b2Filter.prototype.Copy = function(other) { + this.categoryBits = other.categoryBits; + this.maskBits = other.maskBits; + this.groupIndex = other.groupIndex || 0; + return this; + }; + b2Filter.DEFAULT = new b2Filter(); + return b2Filter; + })(); + var b2FixtureDef = (function() { + function b2FixtureDef() { + this.userData = null; + this.friction = .2; + this.restitution = 0; + this.density = 0; + this.isSensor = false; + this.filter = new b2Filter(); + } + return b2FixtureDef; + })(); + var b2FixtureProxy = (function() { + function b2FixtureProxy(fixture) { + this.aabb = new b2AABB(); + this.childIndex = 0; + this.fixture = fixture; + } + return b2FixtureProxy; + })(); + var b2Fixture = (function() { + function b2Fixture(def, body) { + this.m_density = 0; + this.m_next = null; + this.m_friction = 0; + this.m_restitution = 0; + this.m_proxies = []; + this.m_proxyCount = 0; + this.m_filter = new b2Filter(); + this.m_isSensor = false; + this.m_userData = null; + this.m_body = body; + this.m_shape = def.shape.Clone(); + } + b2Fixture.prototype.GetType = function() { + return this.m_shape.GetType(); + }; + b2Fixture.prototype.GetShape = function() { + return this.m_shape; + }; + b2Fixture.prototype.SetSensor = function(sensor) { + if (sensor !== this.m_isSensor) { + this.m_body.SetAwake(true); + this.m_isSensor = sensor; + } + }; + b2Fixture.prototype.IsSensor = function() { + return this.m_isSensor; + }; + b2Fixture.prototype.SetFilterData = function(filter) { + this.m_filter.Copy(filter); + this.Refilter(); + }; + b2Fixture.prototype.GetFilterData = function() { + return this.m_filter; + }; + b2Fixture.prototype.Refilter = function() { + var edge = this.m_body.GetContactList(); + while (edge) { + var contact = edge.contact; + var fixtureA = contact.GetFixtureA(); + var fixtureB = contact.GetFixtureB(); + fixtureA !== this && fixtureB !== this || contact.FlagForFiltering(); + edge = edge.next; + } + var world = this.m_body.GetWorld(); + if (null === world) return; + var broadPhase = world.m_contactManager.m_broadPhase; + for (var i = 0; i < this.m_proxyCount; ++i) broadPhase.TouchProxy(this.m_proxies[i].treeNode); + }; + b2Fixture.prototype.GetBody = function() { + return this.m_body; + }; + b2Fixture.prototype.GetNext = function() { + return this.m_next; + }; + b2Fixture.prototype.GetUserData = function() { + return this.m_userData; + }; + b2Fixture.prototype.SetUserData = function(data) { + this.m_userData = data; + }; + b2Fixture.prototype.TestPoint = function(p) { + return this.m_shape.TestPoint(this.m_body.GetTransform(), p); + }; + b2Fixture.prototype.ComputeDistance = function(p, normal, childIndex) { + return this.m_shape.ComputeDistance(this.m_body.GetTransform(), p, normal, childIndex); + }; + b2Fixture.prototype.RayCast = function(output, input, childIndex) { + return this.m_shape.RayCast(output, input, this.m_body.GetTransform(), childIndex); + }; + b2Fixture.prototype.GetMassData = function(massData) { + void 0 === massData && (massData = new b2MassData()); + this.m_shape.ComputeMass(massData, this.m_density); + return massData; + }; + b2Fixture.prototype.SetDensity = function(density) { + this.m_density = density; + }; + b2Fixture.prototype.GetDensity = function() { + return this.m_density; + }; + b2Fixture.prototype.GetFriction = function() { + return this.m_friction; + }; + b2Fixture.prototype.SetFriction = function(friction) { + this.m_friction = friction; + }; + b2Fixture.prototype.GetRestitution = function() { + return this.m_restitution; + }; + b2Fixture.prototype.SetRestitution = function(restitution) { + this.m_restitution = restitution; + }; + b2Fixture.prototype.GetAABB = function(childIndex) { + return this.m_proxies[childIndex].aabb; + }; + b2Fixture.prototype.Dump = function(log, bodyIndex) { + log(" const fd: b2FixtureDef = new b2FixtureDef();\n"); + log(" fd.friction = %.15f;\n", this.m_friction); + log(" fd.restitution = %.15f;\n", this.m_restitution); + log(" fd.density = %.15f;\n", this.m_density); + log(" fd.isSensor = %s;\n", this.m_isSensor ? "true" : "false"); + log(" fd.filter.categoryBits = %d;\n", this.m_filter.categoryBits); + log(" fd.filter.maskBits = %d;\n", this.m_filter.maskBits); + log(" fd.filter.groupIndex = %d;\n", this.m_filter.groupIndex); + this.m_shape.Dump(log); + log("\n"); + log(" fd.shape = shape;\n"); + log("\n"); + log(" bodies[%d].CreateFixture(fd);\n", bodyIndex); + }; + b2Fixture.prototype.Create = function(def) { + var _this = this; + this.m_userData = def.userData; + this.m_friction = b2Maybe(def.friction, .2); + this.m_restitution = b2Maybe(def.restitution, 0); + this.m_next = null; + this.m_filter.Copy(b2Maybe(def.filter, b2Filter.DEFAULT)); + this.m_isSensor = b2Maybe(def.isSensor, false); + this.m_proxies = b2MakeArray(this.m_shape.GetChildCount(), (function(i) { + return new b2FixtureProxy(_this); + })); + this.m_proxyCount = 0; + this.m_density = b2Maybe(def.density, 0); + }; + b2Fixture.prototype.Destroy = function() {}; + b2Fixture.prototype.CreateProxies = function(xf) { + var broadPhase = this.m_body.m_world.m_contactManager.m_broadPhase; + this.m_proxyCount = this.m_shape.GetChildCount(); + for (var i = 0; i < this.m_proxyCount; ++i) { + var proxy = this.m_proxies[i] = new b2FixtureProxy(this); + this.m_shape.ComputeAABB(proxy.aabb, xf, i); + proxy.treeNode = broadPhase.CreateProxy(proxy.aabb, proxy); + proxy.childIndex = i; + } + }; + b2Fixture.prototype.DestroyProxies = function() { + var broadPhase = this.m_body.m_world.m_contactManager.m_broadPhase; + for (var i = 0; i < this.m_proxyCount; ++i) { + var proxy = this.m_proxies[i]; + delete proxy.treeNode.userData; + broadPhase.DestroyProxy(proxy.treeNode); + delete proxy.treeNode; + } + this.m_proxyCount = 0; + }; + b2Fixture.prototype.TouchProxies = function() { + var broadPhase = this.m_body.m_world.m_contactManager.m_broadPhase; + var proxyCount = this.m_proxyCount; + for (var i = 0; i < proxyCount; ++i) broadPhase.TouchProxy(this.m_proxies[i].treeNode); + }; + b2Fixture.prototype.Synchronize = function(transform1, transform2) { + if (0 === this.m_proxyCount) return; + var broadPhase = this.m_body.m_world.m_contactManager.m_broadPhase; + for (var i = 0; i < this.m_proxyCount; ++i) { + var proxy = this.m_proxies[i]; + var aabb1 = b2Fixture.Synchronize_s_aabb1; + var aabb2 = b2Fixture.Synchronize_s_aabb2; + this.m_shape.ComputeAABB(aabb1, transform1, i); + this.m_shape.ComputeAABB(aabb2, transform2, i); + proxy.aabb.Combine2(aabb1, aabb2); + var displacement = b2Vec2.SubVV(transform2.p, transform1.p, b2Fixture.Synchronize_s_displacement); + broadPhase.MoveProxy(proxy.treeNode, proxy.aabb, displacement); + } + }; + b2Fixture.Synchronize_s_aabb1 = new b2AABB(); + b2Fixture.Synchronize_s_aabb2 = new b2AABB(); + b2Fixture.Synchronize_s_displacement = new b2Vec2(); + return b2Fixture; + })(); + (function(b2BodyType) { + b2BodyType[b2BodyType["b2_unknown"] = -1] = "b2_unknown"; + b2BodyType[b2BodyType["b2_staticBody"] = 0] = "b2_staticBody"; + b2BodyType[b2BodyType["b2_kinematicBody"] = 1] = "b2_kinematicBody"; + b2BodyType[b2BodyType["b2_dynamicBody"] = 2] = "b2_dynamicBody"; + })(exports.b2BodyType || (exports.b2BodyType = {})); + var b2BodyDef = (function() { + function b2BodyDef() { + this.type = exports.b2BodyType.b2_staticBody; + this.position = new b2Vec2(0, 0); + this.angle = 0; + this.linearVelocity = new b2Vec2(0, 0); + this.angularVelocity = 0; + this.linearDamping = 0; + this.angularDamping = 0; + this.allowSleep = true; + this.awake = true; + this.fixedRotation = false; + this.bullet = false; + this.active = true; + this.userData = null; + this.gravityScale = 1; + } + return b2BodyDef; + })(); + var b2Body = (function() { + function b2Body(bd, world) { + this.m_type = exports.b2BodyType.b2_staticBody; + this.m_islandFlag = false; + this.m_awakeFlag = false; + this.m_autoSleepFlag = false; + this.m_bulletFlag = false; + this.m_fixedRotationFlag = false; + this.m_activeFlag = false; + this.m_toiFlag = false; + this.m_islandIndex = 0; + this.m_xf = new b2Transform(); + this.m_xf0 = new b2Transform(); + this.m_sweep = new b2Sweep(); + this.m_linearVelocity = new b2Vec2(); + this.m_angularVelocity = 0; + this.m_force = new b2Vec2(); + this.m_torque = 0; + this.m_prev = null; + this.m_next = null; + this.m_fixtureList = null; + this.m_fixtureCount = 0; + this.m_jointList = null; + this.m_contactList = null; + this.m_mass = 1; + this.m_invMass = 1; + this.m_I = 0; + this.m_invI = 0; + this.m_linearDamping = 0; + this.m_angularDamping = 0; + this.m_gravityScale = 1; + this.m_sleepTime = 0; + this.m_userData = null; + this.m_controllerList = null; + this.m_controllerCount = 0; + this.m_bulletFlag = b2Maybe(bd.bullet, false); + this.m_fixedRotationFlag = b2Maybe(bd.fixedRotation, false); + this.m_autoSleepFlag = b2Maybe(bd.allowSleep, true); + this.m_awakeFlag = b2Maybe(bd.awake, true); + this.m_activeFlag = b2Maybe(bd.active, true); + this.m_world = world; + this.m_xf.p.Copy(b2Maybe(bd.position, b2Vec2.ZERO)); + this.m_xf.q.SetAngle(b2Maybe(bd.angle, 0)); + this.m_xf0.Copy(this.m_xf); + this.m_sweep.localCenter.SetZero(); + this.m_sweep.c0.Copy(this.m_xf.p); + this.m_sweep.c.Copy(this.m_xf.p); + this.m_sweep.a0 = this.m_sweep.a = this.m_xf.q.GetAngle(); + this.m_sweep.alpha0 = 0; + this.m_linearVelocity.Copy(b2Maybe(bd.linearVelocity, b2Vec2.ZERO)); + this.m_angularVelocity = b2Maybe(bd.angularVelocity, 0); + this.m_linearDamping = b2Maybe(bd.linearDamping, 0); + this.m_angularDamping = b2Maybe(bd.angularDamping, 0); + this.m_gravityScale = b2Maybe(bd.gravityScale, 1); + this.m_force.SetZero(); + this.m_torque = 0; + this.m_sleepTime = 0; + this.m_type = b2Maybe(bd.type, exports.b2BodyType.b2_staticBody); + if (bd.type === exports.b2BodyType.b2_dynamicBody) { + this.m_mass = 1; + this.m_invMass = 1; + } else { + this.m_mass = 0; + this.m_invMass = 0; + } + this.m_I = 0; + this.m_invI = 0; + this.m_userData = bd.userData; + this.m_fixtureList = null; + this.m_fixtureCount = 0; + this.m_controllerList = null; + this.m_controllerCount = 0; + } + b2Body.prototype.CreateFixture = function(a, b) { + void 0 === b && (b = 0); + return a instanceof b2Shape ? this.CreateFixtureShapeDensity(a, b) : this.CreateFixtureDef(a); + }; + b2Body.prototype.CreateFixtureDef = function(def) { + if (this.m_world.IsLocked()) throw new Error(); + var fixture = new b2Fixture(def, this); + fixture.Create(def); + this.m_activeFlag && fixture.CreateProxies(this.m_xf); + fixture.m_next = this.m_fixtureList; + this.m_fixtureList = fixture; + ++this.m_fixtureCount; + fixture.m_density > 0 && this.ResetMassData(); + this.m_world.m_newFixture = true; + return fixture; + }; + b2Body.prototype.CreateFixtureShapeDensity = function(shape, density) { + void 0 === density && (density = 0); + var def = b2Body.CreateFixtureShapeDensity_s_def; + def.shape = shape; + def.density = density; + return this.CreateFixtureDef(def); + }; + b2Body.prototype.DestroyFixture = function(fixture) { + if (this.m_world.IsLocked()) throw new Error(); + var node = this.m_fixtureList; + var ppF = null; + while (null !== node) { + if (node === fixture) { + ppF ? ppF.m_next = fixture.m_next : this.m_fixtureList = fixture.m_next; + break; + } + ppF = node; + node = node.m_next; + } + var edge = this.m_contactList; + while (edge) { + var c = edge.contact; + edge = edge.next; + var fixtureA = c.GetFixtureA(); + var fixtureB = c.GetFixtureB(); + fixture !== fixtureA && fixture !== fixtureB || this.m_world.m_contactManager.Destroy(c); + } + this.m_activeFlag && fixture.DestroyProxies(); + fixture.m_next = null; + fixture.Destroy(); + --this.m_fixtureCount; + this.ResetMassData(); + }; + b2Body.prototype.SetTransformVec = function(position, angle) { + this.SetTransformXY(position.x, position.y, angle); + }; + b2Body.prototype.SetTransformXY = function(x, y, angle) { + if (this.m_world.IsLocked()) throw new Error(); + this.m_xf.q.SetAngle(angle); + this.m_xf.p.Set(x, y); + this.m_xf0.Copy(this.m_xf); + b2Transform.MulXV(this.m_xf, this.m_sweep.localCenter, this.m_sweep.c); + this.m_sweep.a = angle; + this.m_sweep.c0.Copy(this.m_sweep.c); + this.m_sweep.a0 = angle; + for (var f = this.m_fixtureList; f; f = f.m_next) f.Synchronize(this.m_xf, this.m_xf); + this.m_world.m_contactManager.FindNewContacts(); + }; + b2Body.prototype.SetTransform = function(xf) { + this.SetTransformVec(xf.p, xf.GetAngle()); + }; + b2Body.prototype.GetTransform = function() { + return this.m_xf; + }; + b2Body.prototype.GetPosition = function() { + return this.m_xf.p; + }; + b2Body.prototype.SetPosition = function(position) { + this.SetTransformVec(position, this.GetAngle()); + }; + b2Body.prototype.SetPositionXY = function(x, y) { + this.SetTransformXY(x, y, this.GetAngle()); + }; + b2Body.prototype.GetAngle = function() { + return this.m_sweep.a; + }; + b2Body.prototype.SetAngle = function(angle) { + this.SetTransformVec(this.GetPosition(), angle); + }; + b2Body.prototype.GetWorldCenter = function() { + return this.m_sweep.c; + }; + b2Body.prototype.GetLocalCenter = function() { + return this.m_sweep.localCenter; + }; + b2Body.prototype.SetLinearVelocity = function(v) { + if (this.m_type === exports.b2BodyType.b2_staticBody) return; + b2Vec2.DotVV(v, v) > 0 && this.SetAwake(true); + this.m_linearVelocity.Copy(v); + }; + b2Body.prototype.GetLinearVelocity = function() { + return this.m_linearVelocity; + }; + b2Body.prototype.SetAngularVelocity = function(w) { + if (this.m_type === exports.b2BodyType.b2_staticBody) return; + w * w > 0 && this.SetAwake(true); + this.m_angularVelocity = w; + }; + b2Body.prototype.GetAngularVelocity = function() { + return this.m_angularVelocity; + }; + b2Body.prototype.GetDefinition = function(bd) { + bd.type = this.GetType(); + bd.allowSleep = this.m_autoSleepFlag; + bd.angle = this.GetAngle(); + bd.angularDamping = this.m_angularDamping; + bd.gravityScale = this.m_gravityScale; + bd.angularVelocity = this.m_angularVelocity; + bd.fixedRotation = this.m_fixedRotationFlag; + bd.bullet = this.m_bulletFlag; + bd.awake = this.m_awakeFlag; + bd.linearDamping = this.m_linearDamping; + bd.linearVelocity.Copy(this.GetLinearVelocity()); + bd.position.Copy(this.GetPosition()); + bd.userData = this.GetUserData(); + return bd; + }; + b2Body.prototype.ApplyForce = function(force, point, wake) { + void 0 === wake && (wake = true); + if (this.m_type !== exports.b2BodyType.b2_dynamicBody) return; + wake && !this.m_awakeFlag && this.SetAwake(true); + if (this.m_awakeFlag) { + this.m_force.x += force.x; + this.m_force.y += force.y; + this.m_torque += (point.x - this.m_sweep.c.x) * force.y - (point.y - this.m_sweep.c.y) * force.x; + } + }; + b2Body.prototype.ApplyForceToCenter = function(force, wake) { + void 0 === wake && (wake = true); + if (this.m_type !== exports.b2BodyType.b2_dynamicBody) return; + wake && !this.m_awakeFlag && this.SetAwake(true); + if (this.m_awakeFlag) { + this.m_force.x += force.x; + this.m_force.y += force.y; + } + }; + b2Body.prototype.ApplyTorque = function(torque, wake) { + void 0 === wake && (wake = true); + if (this.m_type !== exports.b2BodyType.b2_dynamicBody) return; + wake && !this.m_awakeFlag && this.SetAwake(true); + this.m_awakeFlag && (this.m_torque += torque); + }; + b2Body.prototype.ApplyLinearImpulse = function(impulse, point, wake) { + void 0 === wake && (wake = true); + if (this.m_type !== exports.b2BodyType.b2_dynamicBody) return; + wake && !this.m_awakeFlag && this.SetAwake(true); + if (this.m_awakeFlag) { + this.m_linearVelocity.x += this.m_invMass * impulse.x; + this.m_linearVelocity.y += this.m_invMass * impulse.y; + this.m_angularVelocity += this.m_invI * ((point.x - this.m_sweep.c.x) * impulse.y - (point.y - this.m_sweep.c.y) * impulse.x); + } + }; + b2Body.prototype.ApplyLinearImpulseToCenter = function(impulse, wake) { + void 0 === wake && (wake = true); + if (this.m_type !== exports.b2BodyType.b2_dynamicBody) return; + wake && !this.m_awakeFlag && this.SetAwake(true); + if (this.m_awakeFlag) { + this.m_linearVelocity.x += this.m_invMass * impulse.x; + this.m_linearVelocity.y += this.m_invMass * impulse.y; + } + }; + b2Body.prototype.ApplyAngularImpulse = function(impulse, wake) { + void 0 === wake && (wake = true); + if (this.m_type !== exports.b2BodyType.b2_dynamicBody) return; + wake && !this.m_awakeFlag && this.SetAwake(true); + this.m_awakeFlag && (this.m_angularVelocity += this.m_invI * impulse); + }; + b2Body.prototype.GetMass = function() { + return this.m_mass; + }; + b2Body.prototype.GetInertia = function() { + return this.m_I + this.m_mass * b2Vec2.DotVV(this.m_sweep.localCenter, this.m_sweep.localCenter); + }; + b2Body.prototype.GetMassData = function(data) { + data.mass = this.m_mass; + data.I = this.m_I + this.m_mass * b2Vec2.DotVV(this.m_sweep.localCenter, this.m_sweep.localCenter); + data.center.Copy(this.m_sweep.localCenter); + return data; + }; + b2Body.prototype.SetMassData = function(massData) { + if (this.m_world.IsLocked()) throw new Error(); + if (this.m_type !== exports.b2BodyType.b2_dynamicBody) return; + this.m_invMass = 0; + this.m_I = 0; + this.m_invI = 0; + this.m_mass = massData.mass; + this.m_mass <= 0 && (this.m_mass = 1); + this.m_invMass = 1 / this.m_mass; + if (massData.I > 0 && !this.m_fixedRotationFlag) { + this.m_I = massData.I - this.m_mass * b2Vec2.DotVV(massData.center, massData.center); + this.m_invI = 1 / this.m_I; + } + var oldCenter = b2Body.SetMassData_s_oldCenter.Copy(this.m_sweep.c); + this.m_sweep.localCenter.Copy(massData.center); + b2Transform.MulXV(this.m_xf, this.m_sweep.localCenter, this.m_sweep.c); + this.m_sweep.c0.Copy(this.m_sweep.c); + b2Vec2.AddVCrossSV(this.m_linearVelocity, this.m_angularVelocity, b2Vec2.SubVV(this.m_sweep.c, oldCenter, b2Vec2.s_t0), this.m_linearVelocity); + }; + b2Body.prototype.ResetMassData = function() { + this.m_mass = 0; + this.m_invMass = 0; + this.m_I = 0; + this.m_invI = 0; + this.m_sweep.localCenter.SetZero(); + if (this.m_type === exports.b2BodyType.b2_staticBody || this.m_type === exports.b2BodyType.b2_kinematicBody) { + this.m_sweep.c0.Copy(this.m_xf.p); + this.m_sweep.c.Copy(this.m_xf.p); + this.m_sweep.a0 = this.m_sweep.a; + return; + } + var localCenter = b2Body.ResetMassData_s_localCenter.SetZero(); + for (var f = this.m_fixtureList; f; f = f.m_next) { + if (0 === f.m_density) continue; + var massData = f.GetMassData(b2Body.ResetMassData_s_massData); + this.m_mass += massData.mass; + localCenter.x += massData.center.x * massData.mass; + localCenter.y += massData.center.y * massData.mass; + this.m_I += massData.I; + } + if (this.m_mass > 0) { + this.m_invMass = 1 / this.m_mass; + localCenter.x *= this.m_invMass; + localCenter.y *= this.m_invMass; + } else { + this.m_mass = 1; + this.m_invMass = 1; + } + if (this.m_I > 0 && !this.m_fixedRotationFlag) { + this.m_I -= this.m_mass * b2Vec2.DotVV(localCenter, localCenter); + this.m_invI = 1 / this.m_I; + } else { + this.m_I = 0; + this.m_invI = 0; + } + var oldCenter = b2Body.ResetMassData_s_oldCenter.Copy(this.m_sweep.c); + this.m_sweep.localCenter.Copy(localCenter); + b2Transform.MulXV(this.m_xf, this.m_sweep.localCenter, this.m_sweep.c); + this.m_sweep.c0.Copy(this.m_sweep.c); + b2Vec2.AddVCrossSV(this.m_linearVelocity, this.m_angularVelocity, b2Vec2.SubVV(this.m_sweep.c, oldCenter, b2Vec2.s_t0), this.m_linearVelocity); + }; + b2Body.prototype.GetWorldPoint = function(localPoint, out) { + return b2Transform.MulXV(this.m_xf, localPoint, out); + }; + b2Body.prototype.GetWorldVector = function(localVector, out) { + return b2Rot.MulRV(this.m_xf.q, localVector, out); + }; + b2Body.prototype.GetLocalPoint = function(worldPoint, out) { + return b2Transform.MulTXV(this.m_xf, worldPoint, out); + }; + b2Body.prototype.GetLocalVector = function(worldVector, out) { + return b2Rot.MulTRV(this.m_xf.q, worldVector, out); + }; + b2Body.prototype.GetLinearVelocityFromWorldPoint = function(worldPoint, out) { + return b2Vec2.AddVCrossSV(this.m_linearVelocity, this.m_angularVelocity, b2Vec2.SubVV(worldPoint, this.m_sweep.c, b2Vec2.s_t0), out); + }; + b2Body.prototype.GetLinearVelocityFromLocalPoint = function(localPoint, out) { + return this.GetLinearVelocityFromWorldPoint(this.GetWorldPoint(localPoint, out), out); + }; + b2Body.prototype.GetLinearDamping = function() { + return this.m_linearDamping; + }; + b2Body.prototype.SetLinearDamping = function(linearDamping) { + this.m_linearDamping = linearDamping; + }; + b2Body.prototype.GetAngularDamping = function() { + return this.m_angularDamping; + }; + b2Body.prototype.SetAngularDamping = function(angularDamping) { + this.m_angularDamping = angularDamping; + }; + b2Body.prototype.GetGravityScale = function() { + return this.m_gravityScale; + }; + b2Body.prototype.SetGravityScale = function(scale) { + this.m_gravityScale = scale; + }; + b2Body.prototype.SetType = function(type) { + if (this.m_world.IsLocked()) throw new Error(); + if (this.m_type === type) return; + this.m_type = type; + this.ResetMassData(); + if (this.m_type === exports.b2BodyType.b2_staticBody) { + this.m_linearVelocity.SetZero(); + this.m_angularVelocity = 0; + this.m_sweep.a0 = this.m_sweep.a; + this.m_sweep.c0.Copy(this.m_sweep.c); + this.SynchronizeFixtures(); + } + this.SetAwake(true); + this.m_force.SetZero(); + this.m_torque = 0; + var ce = this.m_contactList; + while (ce) { + var ce0 = ce; + ce = ce.next; + this.m_world.m_contactManager.Destroy(ce0.contact); + } + this.m_contactList = null; + for (var f = this.m_fixtureList; f; f = f.m_next) f.TouchProxies(); + }; + b2Body.prototype.GetType = function() { + return this.m_type; + }; + b2Body.prototype.SetBullet = function(flag) { + this.m_bulletFlag = flag; + }; + b2Body.prototype.IsBullet = function() { + return this.m_bulletFlag; + }; + b2Body.prototype.SetSleepingAllowed = function(flag) { + this.m_autoSleepFlag = flag; + flag || this.SetAwake(true); + }; + b2Body.prototype.IsSleepingAllowed = function() { + return this.m_autoSleepFlag; + }; + b2Body.prototype.SetAwake = function(flag) { + if (flag) { + this.m_awakeFlag = true; + this.m_sleepTime = 0; + } else { + this.m_awakeFlag = false; + this.m_sleepTime = 0; + this.m_linearVelocity.SetZero(); + this.m_angularVelocity = 0; + this.m_force.SetZero(); + this.m_torque = 0; + } + }; + b2Body.prototype.IsAwake = function() { + return this.m_awakeFlag; + }; + b2Body.prototype.SetActive = function(flag) { + if (this.m_world.IsLocked()) throw new Error(); + if (flag === this.IsActive()) return; + this.m_activeFlag = flag; + if (flag) for (var f = this.m_fixtureList; f; f = f.m_next) f.CreateProxies(this.m_xf); else { + for (var f = this.m_fixtureList; f; f = f.m_next) f.DestroyProxies(); + var ce = this.m_contactList; + while (ce) { + var ce0 = ce; + ce = ce.next; + this.m_world.m_contactManager.Destroy(ce0.contact); + } + this.m_contactList = null; + } + }; + b2Body.prototype.IsActive = function() { + return this.m_activeFlag; + }; + b2Body.prototype.SetFixedRotation = function(flag) { + if (this.m_fixedRotationFlag === flag) return; + this.m_fixedRotationFlag = flag; + this.m_angularVelocity = 0; + this.ResetMassData(); + }; + b2Body.prototype.IsFixedRotation = function() { + return this.m_fixedRotationFlag; + }; + b2Body.prototype.GetFixtureList = function() { + return this.m_fixtureList; + }; + b2Body.prototype.GetJointList = function() { + return this.m_jointList; + }; + b2Body.prototype.GetContactList = function() { + return this.m_contactList; + }; + b2Body.prototype.GetNext = function() { + return this.m_next; + }; + b2Body.prototype.GetUserData = function() { + return this.m_userData; + }; + b2Body.prototype.SetUserData = function(data) { + this.m_userData = data; + }; + b2Body.prototype.GetWorld = function() { + return this.m_world; + }; + b2Body.prototype.Dump = function(log) { + var bodyIndex = this.m_islandIndex; + log("{\n"); + log(" const bd: b2BodyDef = new b2BodyDef();\n"); + var type_str = ""; + switch (this.m_type) { + case exports.b2BodyType.b2_staticBody: + type_str = "b2BodyType.b2_staticBody"; + break; + + case exports.b2BodyType.b2_kinematicBody: + type_str = "b2BodyType.b2_kinematicBody"; + break; + + case exports.b2BodyType.b2_dynamicBody: + type_str = "b2BodyType.b2_dynamicBody"; + } + log(" bd.type = %s;\n", type_str); + log(" bd.position.Set(%.15f, %.15f);\n", this.m_xf.p.x, this.m_xf.p.y); + log(" bd.angle = %.15f;\n", this.m_sweep.a); + log(" bd.linearVelocity.Set(%.15f, %.15f);\n", this.m_linearVelocity.x, this.m_linearVelocity.y); + log(" bd.angularVelocity = %.15f;\n", this.m_angularVelocity); + log(" bd.linearDamping = %.15f;\n", this.m_linearDamping); + log(" bd.angularDamping = %.15f;\n", this.m_angularDamping); + log(" bd.allowSleep = %s;\n", this.m_autoSleepFlag ? "true" : "false"); + log(" bd.awake = %s;\n", this.m_awakeFlag ? "true" : "false"); + log(" bd.fixedRotation = %s;\n", this.m_fixedRotationFlag ? "true" : "false"); + log(" bd.bullet = %s;\n", this.m_bulletFlag ? "true" : "false"); + log(" bd.active = %s;\n", this.m_activeFlag ? "true" : "false"); + log(" bd.gravityScale = %.15f;\n", this.m_gravityScale); + log("\n"); + log(" bodies[%d] = this.m_world.CreateBody(bd);\n", this.m_islandIndex); + log("\n"); + for (var f = this.m_fixtureList; f; f = f.m_next) { + log(" {\n"); + f.Dump(log, bodyIndex); + log(" }\n"); + } + log("}\n"); + }; + b2Body.prototype.SynchronizeFixtures = function() { + var xf1 = b2Body.SynchronizeFixtures_s_xf1; + xf1.q.SetAngle(this.m_sweep.a0); + b2Rot.MulRV(xf1.q, this.m_sweep.localCenter, xf1.p); + b2Vec2.SubVV(this.m_sweep.c0, xf1.p, xf1.p); + for (var f = this.m_fixtureList; f; f = f.m_next) f.Synchronize(xf1, this.m_xf); + }; + b2Body.prototype.SynchronizeTransform = function() { + this.m_xf.q.SetAngle(this.m_sweep.a); + b2Rot.MulRV(this.m_xf.q, this.m_sweep.localCenter, this.m_xf.p); + b2Vec2.SubVV(this.m_sweep.c, this.m_xf.p, this.m_xf.p); + }; + b2Body.prototype.ShouldCollide = function(other) { + if (this.m_type === exports.b2BodyType.b2_staticBody && other.m_type === exports.b2BodyType.b2_staticBody) return false; + return this.ShouldCollideConnected(other); + }; + b2Body.prototype.ShouldCollideConnected = function(other) { + for (var jn = this.m_jointList; jn; jn = jn.next) if (jn.other === other && !jn.joint.m_collideConnected) return false; + return true; + }; + b2Body.prototype.Advance = function(alpha) { + this.m_sweep.Advance(alpha); + this.m_sweep.c.Copy(this.m_sweep.c0); + this.m_sweep.a = this.m_sweep.a0; + this.m_xf.q.SetAngle(this.m_sweep.a); + b2Rot.MulRV(this.m_xf.q, this.m_sweep.localCenter, this.m_xf.p); + b2Vec2.SubVV(this.m_sweep.c, this.m_xf.p, this.m_xf.p); + }; + b2Body.prototype.GetControllerList = function() { + return this.m_controllerList; + }; + b2Body.prototype.GetControllerCount = function() { + return this.m_controllerCount; + }; + b2Body.CreateFixtureShapeDensity_s_def = new b2FixtureDef(); + b2Body.SetMassData_s_oldCenter = new b2Vec2(); + b2Body.ResetMassData_s_localCenter = new b2Vec2(); + b2Body.ResetMassData_s_oldCenter = new b2Vec2(); + b2Body.ResetMassData_s_massData = new b2MassData(); + b2Body.SynchronizeFixtures_s_xf1 = new b2Transform(); + return b2Body; + })(); + (function(b2JointType) { + b2JointType[b2JointType["e_unknownJoint"] = 0] = "e_unknownJoint"; + b2JointType[b2JointType["e_revoluteJoint"] = 1] = "e_revoluteJoint"; + b2JointType[b2JointType["e_prismaticJoint"] = 2] = "e_prismaticJoint"; + b2JointType[b2JointType["e_distanceJoint"] = 3] = "e_distanceJoint"; + b2JointType[b2JointType["e_pulleyJoint"] = 4] = "e_pulleyJoint"; + b2JointType[b2JointType["e_mouseJoint"] = 5] = "e_mouseJoint"; + b2JointType[b2JointType["e_gearJoint"] = 6] = "e_gearJoint"; + b2JointType[b2JointType["e_wheelJoint"] = 7] = "e_wheelJoint"; + b2JointType[b2JointType["e_weldJoint"] = 8] = "e_weldJoint"; + b2JointType[b2JointType["e_frictionJoint"] = 9] = "e_frictionJoint"; + b2JointType[b2JointType["e_ropeJoint"] = 10] = "e_ropeJoint"; + b2JointType[b2JointType["e_motorJoint"] = 11] = "e_motorJoint"; + b2JointType[b2JointType["e_areaJoint"] = 12] = "e_areaJoint"; + })(exports.b2JointType || (exports.b2JointType = {})); + (function(b2LimitState) { + b2LimitState[b2LimitState["e_inactiveLimit"] = 0] = "e_inactiveLimit"; + b2LimitState[b2LimitState["e_atLowerLimit"] = 1] = "e_atLowerLimit"; + b2LimitState[b2LimitState["e_atUpperLimit"] = 2] = "e_atUpperLimit"; + b2LimitState[b2LimitState["e_equalLimits"] = 3] = "e_equalLimits"; + })(exports.b2LimitState || (exports.b2LimitState = {})); + var b2Jacobian = (function() { + function b2Jacobian() { + this.linear = new b2Vec2(); + this.angularA = 0; + this.angularB = 0; + } + b2Jacobian.prototype.SetZero = function() { + this.linear.SetZero(); + this.angularA = 0; + this.angularB = 0; + return this; + }; + b2Jacobian.prototype.Set = function(x, a1, a2) { + this.linear.Copy(x); + this.angularA = a1; + this.angularB = a2; + return this; + }; + return b2Jacobian; + })(); + var b2JointEdge = (function() { + function b2JointEdge(joint, other) { + this.prev = null; + this.next = null; + this.joint = joint; + this.other = other; + } + return b2JointEdge; + })(); + var b2JointDef = (function() { + function b2JointDef(type) { + this.type = exports.b2JointType.e_unknownJoint; + this.userData = null; + this.collideConnected = false; + this.type = type; + } + return b2JointDef; + })(); + var b2Joint = (function() { + function b2Joint(def) { + this.m_type = exports.b2JointType.e_unknownJoint; + this.m_prev = null; + this.m_next = null; + this.m_index = 0; + this.m_islandFlag = false; + this.m_collideConnected = false; + this.m_userData = null; + this.m_type = def.type; + this.m_edgeA = new b2JointEdge(this, def.bodyB); + this.m_edgeB = new b2JointEdge(this, def.bodyA); + this.m_bodyA = def.bodyA; + this.m_bodyB = def.bodyB; + this.m_collideConnected = b2Maybe(def.collideConnected, false); + this.m_userData = def.userData; + } + b2Joint.prototype.GetType = function() { + return this.m_type; + }; + b2Joint.prototype.GetBodyA = function() { + return this.m_bodyA; + }; + b2Joint.prototype.GetBodyB = function() { + return this.m_bodyB; + }; + b2Joint.prototype.GetNext = function() { + return this.m_next; + }; + b2Joint.prototype.GetUserData = function() { + return this.m_userData; + }; + b2Joint.prototype.SetUserData = function(data) { + this.m_userData = data; + }; + b2Joint.prototype.IsActive = function() { + return this.m_bodyA.IsActive() && this.m_bodyB.IsActive(); + }; + b2Joint.prototype.GetCollideConnected = function() { + return this.m_collideConnected; + }; + b2Joint.prototype.Dump = function(log) { + log("// Dump is not supported for this joint type.\n"); + }; + b2Joint.prototype.ShiftOrigin = function(newOrigin) {}; + return b2Joint; + })(); + var b2DistanceJointDef = (function(_super) { + __extends(b2DistanceJointDef, _super); + function b2DistanceJointDef() { + var _this = _super.call(this, exports.b2JointType.e_distanceJoint) || this; + _this.localAnchorA = new b2Vec2(); + _this.localAnchorB = new b2Vec2(); + _this.length = 1; + _this.frequencyHz = 0; + _this.dampingRatio = 0; + return _this; + } + b2DistanceJointDef.prototype.Initialize = function(b1, b2, anchor1, anchor2) { + this.bodyA = b1; + this.bodyB = b2; + this.bodyA.GetLocalPoint(anchor1, this.localAnchorA); + this.bodyB.GetLocalPoint(anchor2, this.localAnchorB); + this.length = b2Vec2.DistanceVV(anchor1, anchor2); + this.frequencyHz = 0; + this.dampingRatio = 0; + }; + return b2DistanceJointDef; + })(b2JointDef); + var b2DistanceJoint = (function(_super) { + __extends(b2DistanceJoint, _super); + function b2DistanceJoint(def) { + var _this = _super.call(this, def) || this; + _this.m_frequencyHz = 0; + _this.m_dampingRatio = 0; + _this.m_bias = 0; + _this.m_localAnchorA = new b2Vec2(); + _this.m_localAnchorB = new b2Vec2(); + _this.m_gamma = 0; + _this.m_impulse = 0; + _this.m_length = 0; + _this.m_indexA = 0; + _this.m_indexB = 0; + _this.m_u = new b2Vec2(); + _this.m_rA = new b2Vec2(); + _this.m_rB = new b2Vec2(); + _this.m_localCenterA = new b2Vec2(); + _this.m_localCenterB = new b2Vec2(); + _this.m_invMassA = 0; + _this.m_invMassB = 0; + _this.m_invIA = 0; + _this.m_invIB = 0; + _this.m_mass = 0; + _this.m_qA = new b2Rot(); + _this.m_qB = new b2Rot(); + _this.m_lalcA = new b2Vec2(); + _this.m_lalcB = new b2Vec2(); + _this.m_frequencyHz = b2Maybe(def.frequencyHz, 0); + _this.m_dampingRatio = b2Maybe(def.dampingRatio, 0); + _this.m_localAnchorA.Copy(def.localAnchorA); + _this.m_localAnchorB.Copy(def.localAnchorB); + _this.m_length = def.length; + return _this; + } + b2DistanceJoint.prototype.GetAnchorA = function(out) { + return this.m_bodyA.GetWorldPoint(this.m_localAnchorA, out); + }; + b2DistanceJoint.prototype.GetAnchorB = function(out) { + return this.m_bodyB.GetWorldPoint(this.m_localAnchorB, out); + }; + b2DistanceJoint.prototype.GetReactionForce = function(inv_dt, out) { + out.x = inv_dt * this.m_impulse * this.m_u.x; + out.y = inv_dt * this.m_impulse * this.m_u.y; + return out; + }; + b2DistanceJoint.prototype.GetReactionTorque = function(inv_dt) { + return 0; + }; + b2DistanceJoint.prototype.GetLocalAnchorA = function() { + return this.m_localAnchorA; + }; + b2DistanceJoint.prototype.GetLocalAnchorB = function() { + return this.m_localAnchorB; + }; + b2DistanceJoint.prototype.SetLength = function(length) { + this.m_length = length; + }; + b2DistanceJoint.prototype.Length = function() { + return this.m_length; + }; + b2DistanceJoint.prototype.SetFrequency = function(hz) { + this.m_frequencyHz = hz; + }; + b2DistanceJoint.prototype.GetFrequency = function() { + return this.m_frequencyHz; + }; + b2DistanceJoint.prototype.SetDampingRatio = function(ratio) { + this.m_dampingRatio = ratio; + }; + b2DistanceJoint.prototype.GetDampingRatio = function() { + return this.m_dampingRatio; + }; + b2DistanceJoint.prototype.Dump = function(log) { + var indexA = this.m_bodyA.m_islandIndex; + var indexB = this.m_bodyB.m_islandIndex; + log(" const jd: b2DistanceJointDef = new b2DistanceJointDef();\n"); + log(" jd.bodyA = bodies[%d];\n", indexA); + log(" jd.bodyB = bodies[%d];\n", indexB); + log(" jd.collideConnected = %s;\n", this.m_collideConnected ? "true" : "false"); + log(" jd.localAnchorA.Set(%.15f, %.15f);\n", this.m_localAnchorA.x, this.m_localAnchorA.y); + log(" jd.localAnchorB.Set(%.15f, %.15f);\n", this.m_localAnchorB.x, this.m_localAnchorB.y); + log(" jd.length = %.15f;\n", this.m_length); + log(" jd.frequencyHz = %.15f;\n", this.m_frequencyHz); + log(" jd.dampingRatio = %.15f;\n", this.m_dampingRatio); + log(" joints[%d] = this.m_world.CreateJoint(jd);\n", this.m_index); + }; + b2DistanceJoint.prototype.InitVelocityConstraints = function(data) { + this.m_indexA = this.m_bodyA.m_islandIndex; + this.m_indexB = this.m_bodyB.m_islandIndex; + this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter); + this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter); + this.m_invMassA = this.m_bodyA.m_invMass; + this.m_invMassB = this.m_bodyB.m_invMass; + this.m_invIA = this.m_bodyA.m_invI; + this.m_invIB = this.m_bodyB.m_invI; + var cA = data.positions[this.m_indexA].c; + var aA = data.positions[this.m_indexA].a; + var vA = data.velocities[this.m_indexA].v; + var wA = data.velocities[this.m_indexA].w; + var cB = data.positions[this.m_indexB].c; + var aB = data.positions[this.m_indexB].a; + var vB = data.velocities[this.m_indexB].v; + var wB = data.velocities[this.m_indexB].w; + var qA = this.m_qA.SetAngle(aA), qB = this.m_qB.SetAngle(aB); + b2Vec2.SubVV(this.m_localAnchorA, this.m_localCenterA, this.m_lalcA); + b2Rot.MulRV(qA, this.m_lalcA, this.m_rA); + b2Vec2.SubVV(this.m_localAnchorB, this.m_localCenterB, this.m_lalcB); + b2Rot.MulRV(qB, this.m_lalcB, this.m_rB); + this.m_u.x = cB.x + this.m_rB.x - cA.x - this.m_rA.x; + this.m_u.y = cB.y + this.m_rB.y - cA.y - this.m_rA.y; + var length = this.m_u.Length(); + length > b2_linearSlop ? this.m_u.SelfMul(1 / length) : this.m_u.SetZero(); + var crAu = b2Vec2.CrossVV(this.m_rA, this.m_u); + var crBu = b2Vec2.CrossVV(this.m_rB, this.m_u); + var invMass = this.m_invMassA + this.m_invIA * crAu * crAu + this.m_invMassB + this.m_invIB * crBu * crBu; + this.m_mass = 0 !== invMass ? 1 / invMass : 0; + if (this.m_frequencyHz > 0) { + var C = length - this.m_length; + var omega = 2 * b2_pi * this.m_frequencyHz; + var d = 2 * this.m_mass * this.m_dampingRatio * omega; + var k = this.m_mass * omega * omega; + var h = data.step.dt; + this.m_gamma = h * (d + h * k); + this.m_gamma = 0 !== this.m_gamma ? 1 / this.m_gamma : 0; + this.m_bias = C * h * k * this.m_gamma; + invMass += this.m_gamma; + this.m_mass = 0 !== invMass ? 1 / invMass : 0; + } else { + this.m_gamma = 0; + this.m_bias = 0; + } + if (data.step.warmStarting) { + this.m_impulse *= data.step.dtRatio; + var P = b2Vec2.MulSV(this.m_impulse, this.m_u, b2DistanceJoint.InitVelocityConstraints_s_P); + vA.SelfMulSub(this.m_invMassA, P); + wA -= this.m_invIA * b2Vec2.CrossVV(this.m_rA, P); + vB.SelfMulAdd(this.m_invMassB, P); + wB += this.m_invIB * b2Vec2.CrossVV(this.m_rB, P); + } else this.m_impulse = 0; + data.velocities[this.m_indexA].w = wA; + data.velocities[this.m_indexB].w = wB; + }; + b2DistanceJoint.prototype.SolveVelocityConstraints = function(data) { + var vA = data.velocities[this.m_indexA].v; + var wA = data.velocities[this.m_indexA].w; + var vB = data.velocities[this.m_indexB].v; + var wB = data.velocities[this.m_indexB].w; + var vpA = b2Vec2.AddVCrossSV(vA, wA, this.m_rA, b2DistanceJoint.SolveVelocityConstraints_s_vpA); + var vpB = b2Vec2.AddVCrossSV(vB, wB, this.m_rB, b2DistanceJoint.SolveVelocityConstraints_s_vpB); + var Cdot = b2Vec2.DotVV(this.m_u, b2Vec2.SubVV(vpB, vpA, b2Vec2.s_t0)); + var impulse = -this.m_mass * (Cdot + this.m_bias + this.m_gamma * this.m_impulse); + this.m_impulse += impulse; + var P = b2Vec2.MulSV(impulse, this.m_u, b2DistanceJoint.SolveVelocityConstraints_s_P); + vA.SelfMulSub(this.m_invMassA, P); + wA -= this.m_invIA * b2Vec2.CrossVV(this.m_rA, P); + vB.SelfMulAdd(this.m_invMassB, P); + wB += this.m_invIB * b2Vec2.CrossVV(this.m_rB, P); + data.velocities[this.m_indexA].w = wA; + data.velocities[this.m_indexB].w = wB; + }; + b2DistanceJoint.prototype.SolvePositionConstraints = function(data) { + if (this.m_frequencyHz > 0) return true; + var cA = data.positions[this.m_indexA].c; + var aA = data.positions[this.m_indexA].a; + var cB = data.positions[this.m_indexB].c; + var aB = data.positions[this.m_indexB].a; + var qA = this.m_qA.SetAngle(aA), qB = this.m_qB.SetAngle(aB); + var rA = b2Rot.MulRV(qA, this.m_lalcA, this.m_rA); + var rB = b2Rot.MulRV(qB, this.m_lalcB, this.m_rB); + var u = this.m_u; + u.x = cB.x + rB.x - cA.x - rA.x; + u.y = cB.y + rB.y - cA.y - rA.y; + var length = this.m_u.Normalize(); + var C = length - this.m_length; + C = b2Clamp(C, -b2_maxLinearCorrection, b2_maxLinearCorrection); + var impulse = -this.m_mass * C; + var P = b2Vec2.MulSV(impulse, u, b2DistanceJoint.SolvePositionConstraints_s_P); + cA.SelfMulSub(this.m_invMassA, P); + aA -= this.m_invIA * b2Vec2.CrossVV(rA, P); + cB.SelfMulAdd(this.m_invMassB, P); + aB += this.m_invIB * b2Vec2.CrossVV(rB, P); + data.positions[this.m_indexA].a = aA; + data.positions[this.m_indexB].a = aB; + return b2Abs(C) < b2_linearSlop; + }; + b2DistanceJoint.InitVelocityConstraints_s_P = new b2Vec2(); + b2DistanceJoint.SolveVelocityConstraints_s_vpA = new b2Vec2(); + b2DistanceJoint.SolveVelocityConstraints_s_vpB = new b2Vec2(); + b2DistanceJoint.SolveVelocityConstraints_s_P = new b2Vec2(); + b2DistanceJoint.SolvePositionConstraints_s_P = new b2Vec2(); + return b2DistanceJoint; + })(b2Joint); + var b2AreaJointDef = (function(_super) { + __extends(b2AreaJointDef, _super); + function b2AreaJointDef() { + var _this = _super.call(this, exports.b2JointType.e_areaJoint) || this; + _this.bodies = []; + _this.frequencyHz = 0; + _this.dampingRatio = 0; + return _this; + } + b2AreaJointDef.prototype.AddBody = function(body) { + this.bodies.push(body); + 1 === this.bodies.length ? this.bodyA = body : 2 === this.bodies.length && (this.bodyB = body); + }; + return b2AreaJointDef; + })(b2JointDef); + var b2AreaJoint = (function(_super) { + __extends(b2AreaJoint, _super); + function b2AreaJoint(def) { + var _this = _super.call(this, def) || this; + _this.m_frequencyHz = 0; + _this.m_dampingRatio = 0; + _this.m_impulse = 0; + _this.m_targetArea = 0; + _this.m_bodies = def.bodies; + _this.m_frequencyHz = b2Maybe(def.frequencyHz, 0); + _this.m_dampingRatio = b2Maybe(def.dampingRatio, 0); + _this.m_targetLengths = b2MakeNumberArray(def.bodies.length); + _this.m_normals = b2Vec2.MakeArray(def.bodies.length); + _this.m_joints = []; + _this.m_deltas = b2Vec2.MakeArray(def.bodies.length); + _this.m_delta = new b2Vec2(); + var djd = new b2DistanceJointDef(); + djd.frequencyHz = _this.m_frequencyHz; + djd.dampingRatio = _this.m_dampingRatio; + _this.m_targetArea = 0; + for (var i = 0; i < _this.m_bodies.length; ++i) { + var body = _this.m_bodies[i]; + var next = _this.m_bodies[(i + 1) % _this.m_bodies.length]; + var body_c = body.GetWorldCenter(); + var next_c = next.GetWorldCenter(); + _this.m_targetLengths[i] = b2Vec2.DistanceVV(body_c, next_c); + _this.m_targetArea += b2Vec2.CrossVV(body_c, next_c); + djd.Initialize(body, next, body_c, next_c); + _this.m_joints[i] = body.GetWorld().CreateJoint(djd); + } + _this.m_targetArea *= .5; + return _this; + } + b2AreaJoint.prototype.GetAnchorA = function(out) { + return out; + }; + b2AreaJoint.prototype.GetAnchorB = function(out) { + return out; + }; + b2AreaJoint.prototype.GetReactionForce = function(inv_dt, out) { + return out; + }; + b2AreaJoint.prototype.GetReactionTorque = function(inv_dt) { + return 0; + }; + b2AreaJoint.prototype.SetFrequency = function(hz) { + this.m_frequencyHz = hz; + for (var i = 0; i < this.m_joints.length; ++i) this.m_joints[i].SetFrequency(hz); + }; + b2AreaJoint.prototype.GetFrequency = function() { + return this.m_frequencyHz; + }; + b2AreaJoint.prototype.SetDampingRatio = function(ratio) { + this.m_dampingRatio = ratio; + for (var i = 0; i < this.m_joints.length; ++i) this.m_joints[i].SetDampingRatio(ratio); + }; + b2AreaJoint.prototype.GetDampingRatio = function() { + return this.m_dampingRatio; + }; + b2AreaJoint.prototype.Dump = function(log) { + log("Area joint dumping is not supported.\n"); + }; + b2AreaJoint.prototype.InitVelocityConstraints = function(data) { + for (var i = 0; i < this.m_bodies.length; ++i) { + var prev = this.m_bodies[(i + this.m_bodies.length - 1) % this.m_bodies.length]; + var next = this.m_bodies[(i + 1) % this.m_bodies.length]; + var prev_c = data.positions[prev.m_islandIndex].c; + var next_c = data.positions[next.m_islandIndex].c; + var delta = this.m_deltas[i]; + b2Vec2.SubVV(next_c, prev_c, delta); + } + if (data.step.warmStarting) { + this.m_impulse *= data.step.dtRatio; + for (var i = 0; i < this.m_bodies.length; ++i) { + var body = this.m_bodies[i]; + var body_v = data.velocities[body.m_islandIndex].v; + var delta = this.m_deltas[i]; + body_v.x += body.m_invMass * delta.y * .5 * this.m_impulse; + body_v.y += body.m_invMass * -delta.x * .5 * this.m_impulse; + } + } else this.m_impulse = 0; + }; + b2AreaJoint.prototype.SolveVelocityConstraints = function(data) { + var dotMassSum = 0; + var crossMassSum = 0; + for (var i = 0; i < this.m_bodies.length; ++i) { + var body = this.m_bodies[i]; + var body_v = data.velocities[body.m_islandIndex].v; + var delta = this.m_deltas[i]; + dotMassSum += delta.LengthSquared() / body.GetMass(); + crossMassSum += b2Vec2.CrossVV(body_v, delta); + } + var lambda = -2 * crossMassSum / dotMassSum; + this.m_impulse += lambda; + for (var i = 0; i < this.m_bodies.length; ++i) { + var body = this.m_bodies[i]; + var body_v = data.velocities[body.m_islandIndex].v; + var delta = this.m_deltas[i]; + body_v.x += body.m_invMass * delta.y * .5 * lambda; + body_v.y += body.m_invMass * -delta.x * .5 * lambda; + } + }; + b2AreaJoint.prototype.SolvePositionConstraints = function(data) { + var perimeter = 0; + var area = 0; + for (var i = 0; i < this.m_bodies.length; ++i) { + var body = this.m_bodies[i]; + var next = this.m_bodies[(i + 1) % this.m_bodies.length]; + var body_c = data.positions[body.m_islandIndex].c; + var next_c = data.positions[next.m_islandIndex].c; + var delta = b2Vec2.SubVV(next_c, body_c, this.m_delta); + var dist = delta.Length(); + dist < b2_epsilon && (dist = 1); + this.m_normals[i].x = delta.y / dist; + this.m_normals[i].y = -delta.x / dist; + perimeter += dist; + area += b2Vec2.CrossVV(body_c, next_c); + } + area *= .5; + var deltaArea = this.m_targetArea - area; + var toExtrude = .5 * deltaArea / perimeter; + var done = true; + for (var i = 0; i < this.m_bodies.length; ++i) { + var body = this.m_bodies[i]; + var body_c = data.positions[body.m_islandIndex].c; + var next_i = (i + 1) % this.m_bodies.length; + var delta = b2Vec2.AddVV(this.m_normals[i], this.m_normals[next_i], this.m_delta); + delta.SelfMul(toExtrude); + var norm_sq = delta.LengthSquared(); + norm_sq > b2Sq(b2_maxLinearCorrection) && delta.SelfMul(b2_maxLinearCorrection / b2Sqrt(norm_sq)); + norm_sq > b2Sq(b2_linearSlop) && (done = false); + body_c.x += delta.x; + body_c.y += delta.y; + } + return done; + }; + return b2AreaJoint; + })(b2Joint); + var b2FrictionJointDef = (function(_super) { + __extends(b2FrictionJointDef, _super); + function b2FrictionJointDef() { + var _this = _super.call(this, exports.b2JointType.e_frictionJoint) || this; + _this.localAnchorA = new b2Vec2(); + _this.localAnchorB = new b2Vec2(); + _this.maxForce = 0; + _this.maxTorque = 0; + return _this; + } + b2FrictionJointDef.prototype.Initialize = function(bA, bB, anchor) { + this.bodyA = bA; + this.bodyB = bB; + this.bodyA.GetLocalPoint(anchor, this.localAnchorA); + this.bodyB.GetLocalPoint(anchor, this.localAnchorB); + }; + return b2FrictionJointDef; + })(b2JointDef); + var b2FrictionJoint = (function(_super) { + __extends(b2FrictionJoint, _super); + function b2FrictionJoint(def) { + var _this = _super.call(this, def) || this; + _this.m_localAnchorA = new b2Vec2(); + _this.m_localAnchorB = new b2Vec2(); + _this.m_linearImpulse = new b2Vec2(); + _this.m_angularImpulse = 0; + _this.m_maxForce = 0; + _this.m_maxTorque = 0; + _this.m_indexA = 0; + _this.m_indexB = 0; + _this.m_rA = new b2Vec2(); + _this.m_rB = new b2Vec2(); + _this.m_localCenterA = new b2Vec2(); + _this.m_localCenterB = new b2Vec2(); + _this.m_invMassA = 0; + _this.m_invMassB = 0; + _this.m_invIA = 0; + _this.m_invIB = 0; + _this.m_linearMass = new b2Mat22(); + _this.m_angularMass = 0; + _this.m_qA = new b2Rot(); + _this.m_qB = new b2Rot(); + _this.m_lalcA = new b2Vec2(); + _this.m_lalcB = new b2Vec2(); + _this.m_K = new b2Mat22(); + _this.m_localAnchorA.Copy(def.localAnchorA); + _this.m_localAnchorB.Copy(def.localAnchorB); + _this.m_linearImpulse.SetZero(); + _this.m_maxForce = b2Maybe(def.maxForce, 0); + _this.m_maxTorque = b2Maybe(def.maxTorque, 0); + _this.m_linearMass.SetZero(); + return _this; + } + b2FrictionJoint.prototype.InitVelocityConstraints = function(data) { + this.m_indexA = this.m_bodyA.m_islandIndex; + this.m_indexB = this.m_bodyB.m_islandIndex; + this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter); + this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter); + this.m_invMassA = this.m_bodyA.m_invMass; + this.m_invMassB = this.m_bodyB.m_invMass; + this.m_invIA = this.m_bodyA.m_invI; + this.m_invIB = this.m_bodyB.m_invI; + var aA = data.positions[this.m_indexA].a; + var vA = data.velocities[this.m_indexA].v; + var wA = data.velocities[this.m_indexA].w; + var aB = data.positions[this.m_indexB].a; + var vB = data.velocities[this.m_indexB].v; + var wB = data.velocities[this.m_indexB].w; + var qA = this.m_qA.SetAngle(aA), qB = this.m_qB.SetAngle(aB); + b2Vec2.SubVV(this.m_localAnchorA, this.m_localCenterA, this.m_lalcA); + var rA = b2Rot.MulRV(qA, this.m_lalcA, this.m_rA); + b2Vec2.SubVV(this.m_localAnchorB, this.m_localCenterB, this.m_lalcB); + var rB = b2Rot.MulRV(qB, this.m_lalcB, this.m_rB); + var mA = this.m_invMassA, mB = this.m_invMassB; + var iA = this.m_invIA, iB = this.m_invIB; + var K = this.m_K; + K.ex.x = mA + mB + iA * rA.y * rA.y + iB * rB.y * rB.y; + K.ex.y = -iA * rA.x * rA.y - iB * rB.x * rB.y; + K.ey.x = K.ex.y; + K.ey.y = mA + mB + iA * rA.x * rA.x + iB * rB.x * rB.x; + K.GetInverse(this.m_linearMass); + this.m_angularMass = iA + iB; + this.m_angularMass > 0 && (this.m_angularMass = 1 / this.m_angularMass); + if (data.step.warmStarting) { + this.m_linearImpulse.SelfMul(data.step.dtRatio); + this.m_angularImpulse *= data.step.dtRatio; + var P = this.m_linearImpulse; + vA.SelfMulSub(mA, P); + wA -= iA * (b2Vec2.CrossVV(this.m_rA, P) + this.m_angularImpulse); + vB.SelfMulAdd(mB, P); + wB += iB * (b2Vec2.CrossVV(this.m_rB, P) + this.m_angularImpulse); + } else { + this.m_linearImpulse.SetZero(); + this.m_angularImpulse = 0; + } + data.velocities[this.m_indexA].w = wA; + data.velocities[this.m_indexB].w = wB; + }; + b2FrictionJoint.prototype.SolveVelocityConstraints = function(data) { + var vA = data.velocities[this.m_indexA].v; + var wA = data.velocities[this.m_indexA].w; + var vB = data.velocities[this.m_indexB].v; + var wB = data.velocities[this.m_indexB].w; + var mA = this.m_invMassA, mB = this.m_invMassB; + var iA = this.m_invIA, iB = this.m_invIB; + var h = data.step.dt; + var Cdot = wB - wA; + var impulse = -this.m_angularMass * Cdot; + var oldImpulse = this.m_angularImpulse; + var maxImpulse = h * this.m_maxTorque; + this.m_angularImpulse = b2Clamp(this.m_angularImpulse + impulse, -maxImpulse, maxImpulse); + impulse = this.m_angularImpulse - oldImpulse; + wA -= iA * impulse; + wB += iB * impulse; + var Cdot_v2 = b2Vec2.SubVV(b2Vec2.AddVCrossSV(vB, wB, this.m_rB, b2Vec2.s_t0), b2Vec2.AddVCrossSV(vA, wA, this.m_rA, b2Vec2.s_t1), b2FrictionJoint.SolveVelocityConstraints_s_Cdot_v2); + var impulseV = b2Mat22.MulMV(this.m_linearMass, Cdot_v2, b2FrictionJoint.SolveVelocityConstraints_s_impulseV).SelfNeg(); + var oldImpulseV = b2FrictionJoint.SolveVelocityConstraints_s_oldImpulseV.Copy(this.m_linearImpulse); + this.m_linearImpulse.SelfAdd(impulseV); + var maxImpulse = h * this.m_maxForce; + if (this.m_linearImpulse.LengthSquared() > maxImpulse * maxImpulse) { + this.m_linearImpulse.Normalize(); + this.m_linearImpulse.SelfMul(maxImpulse); + } + b2Vec2.SubVV(this.m_linearImpulse, oldImpulseV, impulseV); + vA.SelfMulSub(mA, impulseV); + wA -= iA * b2Vec2.CrossVV(this.m_rA, impulseV); + vB.SelfMulAdd(mB, impulseV); + wB += iB * b2Vec2.CrossVV(this.m_rB, impulseV); + data.velocities[this.m_indexA].w = wA; + data.velocities[this.m_indexB].w = wB; + }; + b2FrictionJoint.prototype.SolvePositionConstraints = function(data) { + return true; + }; + b2FrictionJoint.prototype.GetAnchorA = function(out) { + return this.m_bodyA.GetWorldPoint(this.m_localAnchorA, out); + }; + b2FrictionJoint.prototype.GetAnchorB = function(out) { + return this.m_bodyB.GetWorldPoint(this.m_localAnchorB, out); + }; + b2FrictionJoint.prototype.GetReactionForce = function(inv_dt, out) { + out.x = inv_dt * this.m_linearImpulse.x; + out.y = inv_dt * this.m_linearImpulse.y; + return out; + }; + b2FrictionJoint.prototype.GetReactionTorque = function(inv_dt) { + return inv_dt * this.m_angularImpulse; + }; + b2FrictionJoint.prototype.GetLocalAnchorA = function() { + return this.m_localAnchorA; + }; + b2FrictionJoint.prototype.GetLocalAnchorB = function() { + return this.m_localAnchorB; + }; + b2FrictionJoint.prototype.SetMaxForce = function(force) { + this.m_maxForce = force; + }; + b2FrictionJoint.prototype.GetMaxForce = function() { + return this.m_maxForce; + }; + b2FrictionJoint.prototype.SetMaxTorque = function(torque) { + this.m_maxTorque = torque; + }; + b2FrictionJoint.prototype.GetMaxTorque = function() { + return this.m_maxTorque; + }; + b2FrictionJoint.prototype.Dump = function(log) { + var indexA = this.m_bodyA.m_islandIndex; + var indexB = this.m_bodyB.m_islandIndex; + log(" const jd: b2FrictionJointDef = new b2FrictionJointDef();\n"); + log(" jd.bodyA = bodies[%d];\n", indexA); + log(" jd.bodyB = bodies[%d];\n", indexB); + log(" jd.collideConnected = %s;\n", this.m_collideConnected ? "true" : "false"); + log(" jd.localAnchorA.Set(%.15f, %.15f);\n", this.m_localAnchorA.x, this.m_localAnchorA.y); + log(" jd.localAnchorB.Set(%.15f, %.15f);\n", this.m_localAnchorB.x, this.m_localAnchorB.y); + log(" jd.maxForce = %.15f;\n", this.m_maxForce); + log(" jd.maxTorque = %.15f;\n", this.m_maxTorque); + log(" joints[%d] = this.m_world.CreateJoint(jd);\n", this.m_index); + }; + b2FrictionJoint.SolveVelocityConstraints_s_Cdot_v2 = new b2Vec2(); + b2FrictionJoint.SolveVelocityConstraints_s_impulseV = new b2Vec2(); + b2FrictionJoint.SolveVelocityConstraints_s_oldImpulseV = new b2Vec2(); + return b2FrictionJoint; + })(b2Joint); + var b2GearJointDef = (function(_super) { + __extends(b2GearJointDef, _super); + function b2GearJointDef() { + var _this = _super.call(this, exports.b2JointType.e_gearJoint) || this; + _this.ratio = 1; + return _this; + } + return b2GearJointDef; + })(b2JointDef); + var b2GearJoint = (function(_super) { + __extends(b2GearJoint, _super); + function b2GearJoint(def) { + var _this = _super.call(this, def) || this; + _this.m_typeA = exports.b2JointType.e_unknownJoint; + _this.m_typeB = exports.b2JointType.e_unknownJoint; + _this.m_localAnchorA = new b2Vec2(); + _this.m_localAnchorB = new b2Vec2(); + _this.m_localAnchorC = new b2Vec2(); + _this.m_localAnchorD = new b2Vec2(); + _this.m_localAxisC = new b2Vec2(); + _this.m_localAxisD = new b2Vec2(); + _this.m_referenceAngleA = 0; + _this.m_referenceAngleB = 0; + _this.m_constant = 0; + _this.m_ratio = 0; + _this.m_impulse = 0; + _this.m_indexA = 0; + _this.m_indexB = 0; + _this.m_indexC = 0; + _this.m_indexD = 0; + _this.m_lcA = new b2Vec2(); + _this.m_lcB = new b2Vec2(); + _this.m_lcC = new b2Vec2(); + _this.m_lcD = new b2Vec2(); + _this.m_mA = 0; + _this.m_mB = 0; + _this.m_mC = 0; + _this.m_mD = 0; + _this.m_iA = 0; + _this.m_iB = 0; + _this.m_iC = 0; + _this.m_iD = 0; + _this.m_JvAC = new b2Vec2(); + _this.m_JvBD = new b2Vec2(); + _this.m_JwA = 0; + _this.m_JwB = 0; + _this.m_JwC = 0; + _this.m_JwD = 0; + _this.m_mass = 0; + _this.m_qA = new b2Rot(); + _this.m_qB = new b2Rot(); + _this.m_qC = new b2Rot(); + _this.m_qD = new b2Rot(); + _this.m_lalcA = new b2Vec2(); + _this.m_lalcB = new b2Vec2(); + _this.m_lalcC = new b2Vec2(); + _this.m_lalcD = new b2Vec2(); + _this.m_joint1 = def.joint1; + _this.m_joint2 = def.joint2; + _this.m_typeA = _this.m_joint1.GetType(); + _this.m_typeB = _this.m_joint2.GetType(); + var coordinateA, coordinateB; + _this.m_bodyC = _this.m_joint1.GetBodyA(); + _this.m_bodyA = _this.m_joint1.GetBodyB(); + var xfA = _this.m_bodyA.m_xf; + var aA = _this.m_bodyA.m_sweep.a; + var xfC = _this.m_bodyC.m_xf; + var aC = _this.m_bodyC.m_sweep.a; + if (_this.m_typeA === exports.b2JointType.e_revoluteJoint) { + var revolute = def.joint1; + _this.m_localAnchorC.Copy(revolute.m_localAnchorA); + _this.m_localAnchorA.Copy(revolute.m_localAnchorB); + _this.m_referenceAngleA = revolute.m_referenceAngle; + _this.m_localAxisC.SetZero(); + coordinateA = aA - aC - _this.m_referenceAngleA; + } else { + var prismatic = def.joint1; + _this.m_localAnchorC.Copy(prismatic.m_localAnchorA); + _this.m_localAnchorA.Copy(prismatic.m_localAnchorB); + _this.m_referenceAngleA = prismatic.m_referenceAngle; + _this.m_localAxisC.Copy(prismatic.m_localXAxisA); + var pC = _this.m_localAnchorC; + var pA = b2Rot.MulTRV(xfC.q, b2Vec2.AddVV(b2Rot.MulRV(xfA.q, _this.m_localAnchorA, b2Vec2.s_t0), b2Vec2.SubVV(xfA.p, xfC.p, b2Vec2.s_t1), b2Vec2.s_t0), b2Vec2.s_t0); + coordinateA = b2Vec2.DotVV(b2Vec2.SubVV(pA, pC, b2Vec2.s_t0), _this.m_localAxisC); + } + _this.m_bodyD = _this.m_joint2.GetBodyA(); + _this.m_bodyB = _this.m_joint2.GetBodyB(); + var xfB = _this.m_bodyB.m_xf; + var aB = _this.m_bodyB.m_sweep.a; + var xfD = _this.m_bodyD.m_xf; + var aD = _this.m_bodyD.m_sweep.a; + if (_this.m_typeB === exports.b2JointType.e_revoluteJoint) { + var revolute = def.joint2; + _this.m_localAnchorD.Copy(revolute.m_localAnchorA); + _this.m_localAnchorB.Copy(revolute.m_localAnchorB); + _this.m_referenceAngleB = revolute.m_referenceAngle; + _this.m_localAxisD.SetZero(); + coordinateB = aB - aD - _this.m_referenceAngleB; + } else { + var prismatic = def.joint2; + _this.m_localAnchorD.Copy(prismatic.m_localAnchorA); + _this.m_localAnchorB.Copy(prismatic.m_localAnchorB); + _this.m_referenceAngleB = prismatic.m_referenceAngle; + _this.m_localAxisD.Copy(prismatic.m_localXAxisA); + var pD = _this.m_localAnchorD; + var pB = b2Rot.MulTRV(xfD.q, b2Vec2.AddVV(b2Rot.MulRV(xfB.q, _this.m_localAnchorB, b2Vec2.s_t0), b2Vec2.SubVV(xfB.p, xfD.p, b2Vec2.s_t1), b2Vec2.s_t0), b2Vec2.s_t0); + coordinateB = b2Vec2.DotVV(b2Vec2.SubVV(pB, pD, b2Vec2.s_t0), _this.m_localAxisD); + } + _this.m_ratio = b2Maybe(def.ratio, 1); + _this.m_constant = coordinateA + _this.m_ratio * coordinateB; + _this.m_impulse = 0; + return _this; + } + b2GearJoint.prototype.InitVelocityConstraints = function(data) { + this.m_indexA = this.m_bodyA.m_islandIndex; + this.m_indexB = this.m_bodyB.m_islandIndex; + this.m_indexC = this.m_bodyC.m_islandIndex; + this.m_indexD = this.m_bodyD.m_islandIndex; + this.m_lcA.Copy(this.m_bodyA.m_sweep.localCenter); + this.m_lcB.Copy(this.m_bodyB.m_sweep.localCenter); + this.m_lcC.Copy(this.m_bodyC.m_sweep.localCenter); + this.m_lcD.Copy(this.m_bodyD.m_sweep.localCenter); + this.m_mA = this.m_bodyA.m_invMass; + this.m_mB = this.m_bodyB.m_invMass; + this.m_mC = this.m_bodyC.m_invMass; + this.m_mD = this.m_bodyD.m_invMass; + this.m_iA = this.m_bodyA.m_invI; + this.m_iB = this.m_bodyB.m_invI; + this.m_iC = this.m_bodyC.m_invI; + this.m_iD = this.m_bodyD.m_invI; + var aA = data.positions[this.m_indexA].a; + var vA = data.velocities[this.m_indexA].v; + var wA = data.velocities[this.m_indexA].w; + var aB = data.positions[this.m_indexB].a; + var vB = data.velocities[this.m_indexB].v; + var wB = data.velocities[this.m_indexB].w; + var aC = data.positions[this.m_indexC].a; + var vC = data.velocities[this.m_indexC].v; + var wC = data.velocities[this.m_indexC].w; + var aD = data.positions[this.m_indexD].a; + var vD = data.velocities[this.m_indexD].v; + var wD = data.velocities[this.m_indexD].w; + var qA = this.m_qA.SetAngle(aA), qB = this.m_qB.SetAngle(aB), qC = this.m_qC.SetAngle(aC), qD = this.m_qD.SetAngle(aD); + this.m_mass = 0; + if (this.m_typeA === exports.b2JointType.e_revoluteJoint) { + this.m_JvAC.SetZero(); + this.m_JwA = 1; + this.m_JwC = 1; + this.m_mass += this.m_iA + this.m_iC; + } else { + var u = b2Rot.MulRV(qC, this.m_localAxisC, b2GearJoint.InitVelocityConstraints_s_u); + b2Vec2.SubVV(this.m_localAnchorC, this.m_lcC, this.m_lalcC); + var rC = b2Rot.MulRV(qC, this.m_lalcC, b2GearJoint.InitVelocityConstraints_s_rC); + b2Vec2.SubVV(this.m_localAnchorA, this.m_lcA, this.m_lalcA); + var rA = b2Rot.MulRV(qA, this.m_lalcA, b2GearJoint.InitVelocityConstraints_s_rA); + this.m_JvAC.Copy(u); + this.m_JwC = b2Vec2.CrossVV(rC, u); + this.m_JwA = b2Vec2.CrossVV(rA, u); + this.m_mass += this.m_mC + this.m_mA + this.m_iC * this.m_JwC * this.m_JwC + this.m_iA * this.m_JwA * this.m_JwA; + } + if (this.m_typeB === exports.b2JointType.e_revoluteJoint) { + this.m_JvBD.SetZero(); + this.m_JwB = this.m_ratio; + this.m_JwD = this.m_ratio; + this.m_mass += this.m_ratio * this.m_ratio * (this.m_iB + this.m_iD); + } else { + var u = b2Rot.MulRV(qD, this.m_localAxisD, b2GearJoint.InitVelocityConstraints_s_u); + b2Vec2.SubVV(this.m_localAnchorD, this.m_lcD, this.m_lalcD); + var rD = b2Rot.MulRV(qD, this.m_lalcD, b2GearJoint.InitVelocityConstraints_s_rD); + b2Vec2.SubVV(this.m_localAnchorB, this.m_lcB, this.m_lalcB); + var rB = b2Rot.MulRV(qB, this.m_lalcB, b2GearJoint.InitVelocityConstraints_s_rB); + b2Vec2.MulSV(this.m_ratio, u, this.m_JvBD); + this.m_JwD = this.m_ratio * b2Vec2.CrossVV(rD, u); + this.m_JwB = this.m_ratio * b2Vec2.CrossVV(rB, u); + this.m_mass += this.m_ratio * this.m_ratio * (this.m_mD + this.m_mB) + this.m_iD * this.m_JwD * this.m_JwD + this.m_iB * this.m_JwB * this.m_JwB; + } + this.m_mass = this.m_mass > 0 ? 1 / this.m_mass : 0; + if (data.step.warmStarting) { + vA.SelfMulAdd(this.m_mA * this.m_impulse, this.m_JvAC); + wA += this.m_iA * this.m_impulse * this.m_JwA; + vB.SelfMulAdd(this.m_mB * this.m_impulse, this.m_JvBD); + wB += this.m_iB * this.m_impulse * this.m_JwB; + vC.SelfMulSub(this.m_mC * this.m_impulse, this.m_JvAC); + wC -= this.m_iC * this.m_impulse * this.m_JwC; + vD.SelfMulSub(this.m_mD * this.m_impulse, this.m_JvBD); + wD -= this.m_iD * this.m_impulse * this.m_JwD; + } else this.m_impulse = 0; + data.velocities[this.m_indexA].w = wA; + data.velocities[this.m_indexB].w = wB; + data.velocities[this.m_indexC].w = wC; + data.velocities[this.m_indexD].w = wD; + }; + b2GearJoint.prototype.SolveVelocityConstraints = function(data) { + var vA = data.velocities[this.m_indexA].v; + var wA = data.velocities[this.m_indexA].w; + var vB = data.velocities[this.m_indexB].v; + var wB = data.velocities[this.m_indexB].w; + var vC = data.velocities[this.m_indexC].v; + var wC = data.velocities[this.m_indexC].w; + var vD = data.velocities[this.m_indexD].v; + var wD = data.velocities[this.m_indexD].w; + var Cdot = b2Vec2.DotVV(this.m_JvAC, b2Vec2.SubVV(vA, vC, b2Vec2.s_t0)) + b2Vec2.DotVV(this.m_JvBD, b2Vec2.SubVV(vB, vD, b2Vec2.s_t0)); + Cdot += this.m_JwA * wA - this.m_JwC * wC + (this.m_JwB * wB - this.m_JwD * wD); + var impulse = -this.m_mass * Cdot; + this.m_impulse += impulse; + vA.SelfMulAdd(this.m_mA * impulse, this.m_JvAC); + wA += this.m_iA * impulse * this.m_JwA; + vB.SelfMulAdd(this.m_mB * impulse, this.m_JvBD); + wB += this.m_iB * impulse * this.m_JwB; + vC.SelfMulSub(this.m_mC * impulse, this.m_JvAC); + wC -= this.m_iC * impulse * this.m_JwC; + vD.SelfMulSub(this.m_mD * impulse, this.m_JvBD); + wD -= this.m_iD * impulse * this.m_JwD; + data.velocities[this.m_indexA].w = wA; + data.velocities[this.m_indexB].w = wB; + data.velocities[this.m_indexC].w = wC; + data.velocities[this.m_indexD].w = wD; + }; + b2GearJoint.prototype.SolvePositionConstraints = function(data) { + var cA = data.positions[this.m_indexA].c; + var aA = data.positions[this.m_indexA].a; + var cB = data.positions[this.m_indexB].c; + var aB = data.positions[this.m_indexB].a; + var cC = data.positions[this.m_indexC].c; + var aC = data.positions[this.m_indexC].a; + var cD = data.positions[this.m_indexD].c; + var aD = data.positions[this.m_indexD].a; + var qA = this.m_qA.SetAngle(aA), qB = this.m_qB.SetAngle(aB), qC = this.m_qC.SetAngle(aC), qD = this.m_qD.SetAngle(aD); + var linearError = 0; + var coordinateA, coordinateB; + var JvAC = this.m_JvAC, JvBD = this.m_JvBD; + var JwA, JwB, JwC, JwD; + var mass = 0; + if (this.m_typeA === exports.b2JointType.e_revoluteJoint) { + JvAC.SetZero(); + JwA = 1; + JwC = 1; + mass += this.m_iA + this.m_iC; + coordinateA = aA - aC - this.m_referenceAngleA; + } else { + var u = b2Rot.MulRV(qC, this.m_localAxisC, b2GearJoint.SolvePositionConstraints_s_u); + var rC = b2Rot.MulRV(qC, this.m_lalcC, b2GearJoint.SolvePositionConstraints_s_rC); + var rA = b2Rot.MulRV(qA, this.m_lalcA, b2GearJoint.SolvePositionConstraints_s_rA); + JvAC.Copy(u); + JwC = b2Vec2.CrossVV(rC, u); + JwA = b2Vec2.CrossVV(rA, u); + mass += this.m_mC + this.m_mA + this.m_iC * JwC * JwC + this.m_iA * JwA * JwA; + var pC = this.m_lalcC; + var pA = b2Rot.MulTRV(qC, b2Vec2.AddVV(rA, b2Vec2.SubVV(cA, cC, b2Vec2.s_t0), b2Vec2.s_t0), b2Vec2.s_t0); + coordinateA = b2Vec2.DotVV(b2Vec2.SubVV(pA, pC, b2Vec2.s_t0), this.m_localAxisC); + } + if (this.m_typeB === exports.b2JointType.e_revoluteJoint) { + JvBD.SetZero(); + JwB = this.m_ratio; + JwD = this.m_ratio; + mass += this.m_ratio * this.m_ratio * (this.m_iB + this.m_iD); + coordinateB = aB - aD - this.m_referenceAngleB; + } else { + var u = b2Rot.MulRV(qD, this.m_localAxisD, b2GearJoint.SolvePositionConstraints_s_u); + var rD = b2Rot.MulRV(qD, this.m_lalcD, b2GearJoint.SolvePositionConstraints_s_rD); + var rB = b2Rot.MulRV(qB, this.m_lalcB, b2GearJoint.SolvePositionConstraints_s_rB); + b2Vec2.MulSV(this.m_ratio, u, JvBD); + JwD = this.m_ratio * b2Vec2.CrossVV(rD, u); + JwB = this.m_ratio * b2Vec2.CrossVV(rB, u); + mass += this.m_ratio * this.m_ratio * (this.m_mD + this.m_mB) + this.m_iD * JwD * JwD + this.m_iB * JwB * JwB; + var pD = this.m_lalcD; + var pB = b2Rot.MulTRV(qD, b2Vec2.AddVV(rB, b2Vec2.SubVV(cB, cD, b2Vec2.s_t0), b2Vec2.s_t0), b2Vec2.s_t0); + coordinateB = b2Vec2.DotVV(b2Vec2.SubVV(pB, pD, b2Vec2.s_t0), this.m_localAxisD); + } + var C = coordinateA + this.m_ratio * coordinateB - this.m_constant; + var impulse = 0; + mass > 0 && (impulse = -C / mass); + cA.SelfMulAdd(this.m_mA * impulse, JvAC); + aA += this.m_iA * impulse * JwA; + cB.SelfMulAdd(this.m_mB * impulse, JvBD); + aB += this.m_iB * impulse * JwB; + cC.SelfMulSub(this.m_mC * impulse, JvAC); + aC -= this.m_iC * impulse * JwC; + cD.SelfMulSub(this.m_mD * impulse, JvBD); + aD -= this.m_iD * impulse * JwD; + data.positions[this.m_indexA].a = aA; + data.positions[this.m_indexB].a = aB; + data.positions[this.m_indexC].a = aC; + data.positions[this.m_indexD].a = aD; + return linearError < b2_linearSlop; + }; + b2GearJoint.prototype.GetAnchorA = function(out) { + return this.m_bodyA.GetWorldPoint(this.m_localAnchorA, out); + }; + b2GearJoint.prototype.GetAnchorB = function(out) { + return this.m_bodyB.GetWorldPoint(this.m_localAnchorB, out); + }; + b2GearJoint.prototype.GetReactionForce = function(inv_dt, out) { + return b2Vec2.MulSV(inv_dt * this.m_impulse, this.m_JvAC, out); + }; + b2GearJoint.prototype.GetReactionTorque = function(inv_dt) { + return inv_dt * this.m_impulse * this.m_JwA; + }; + b2GearJoint.prototype.GetJoint1 = function() { + return this.m_joint1; + }; + b2GearJoint.prototype.GetJoint2 = function() { + return this.m_joint2; + }; + b2GearJoint.prototype.GetRatio = function() { + return this.m_ratio; + }; + b2GearJoint.prototype.SetRatio = function(ratio) { + this.m_ratio = ratio; + }; + b2GearJoint.prototype.Dump = function(log) { + var indexA = this.m_bodyA.m_islandIndex; + var indexB = this.m_bodyB.m_islandIndex; + var index1 = this.m_joint1.m_index; + var index2 = this.m_joint2.m_index; + log(" const jd: b2GearJointDef = new b2GearJointDef();\n"); + log(" jd.bodyA = bodies[%d];\n", indexA); + log(" jd.bodyB = bodies[%d];\n", indexB); + log(" jd.collideConnected = %s;\n", this.m_collideConnected ? "true" : "false"); + log(" jd.joint1 = joints[%d];\n", index1); + log(" jd.joint2 = joints[%d];\n", index2); + log(" jd.ratio = %.15f;\n", this.m_ratio); + log(" joints[%d] = this.m_world.CreateJoint(jd);\n", this.m_index); + }; + b2GearJoint.InitVelocityConstraints_s_u = new b2Vec2(); + b2GearJoint.InitVelocityConstraints_s_rA = new b2Vec2(); + b2GearJoint.InitVelocityConstraints_s_rB = new b2Vec2(); + b2GearJoint.InitVelocityConstraints_s_rC = new b2Vec2(); + b2GearJoint.InitVelocityConstraints_s_rD = new b2Vec2(); + b2GearJoint.SolvePositionConstraints_s_u = new b2Vec2(); + b2GearJoint.SolvePositionConstraints_s_rA = new b2Vec2(); + b2GearJoint.SolvePositionConstraints_s_rB = new b2Vec2(); + b2GearJoint.SolvePositionConstraints_s_rC = new b2Vec2(); + b2GearJoint.SolvePositionConstraints_s_rD = new b2Vec2(); + return b2GearJoint; + })(b2Joint); + var b2MotorJointDef = (function(_super) { + __extends(b2MotorJointDef, _super); + function b2MotorJointDef() { + var _this = _super.call(this, exports.b2JointType.e_motorJoint) || this; + _this.linearOffset = new b2Vec2(0, 0); + _this.angularOffset = 0; + _this.maxForce = 1; + _this.maxTorque = 1; + _this.correctionFactor = .3; + return _this; + } + b2MotorJointDef.prototype.Initialize = function(bA, bB) { + this.bodyA = bA; + this.bodyB = bB; + this.bodyA.GetLocalPoint(this.bodyB.GetPosition(), this.linearOffset); + var angleA = this.bodyA.GetAngle(); + var angleB = this.bodyB.GetAngle(); + this.angularOffset = angleB - angleA; + }; + return b2MotorJointDef; + })(b2JointDef); + var b2MotorJoint = (function(_super) { + __extends(b2MotorJoint, _super); + function b2MotorJoint(def) { + var _this = _super.call(this, def) || this; + _this.m_linearOffset = new b2Vec2(); + _this.m_angularOffset = 0; + _this.m_linearImpulse = new b2Vec2(); + _this.m_angularImpulse = 0; + _this.m_maxForce = 0; + _this.m_maxTorque = 0; + _this.m_correctionFactor = .3; + _this.m_indexA = 0; + _this.m_indexB = 0; + _this.m_rA = new b2Vec2(); + _this.m_rB = new b2Vec2(); + _this.m_localCenterA = new b2Vec2(); + _this.m_localCenterB = new b2Vec2(); + _this.m_linearError = new b2Vec2(); + _this.m_angularError = 0; + _this.m_invMassA = 0; + _this.m_invMassB = 0; + _this.m_invIA = 0; + _this.m_invIB = 0; + _this.m_linearMass = new b2Mat22(); + _this.m_angularMass = 0; + _this.m_qA = new b2Rot(); + _this.m_qB = new b2Rot(); + _this.m_K = new b2Mat22(); + _this.m_linearOffset.Copy(b2Maybe(def.linearOffset, b2Vec2.ZERO)); + _this.m_linearImpulse.SetZero(); + _this.m_maxForce = b2Maybe(def.maxForce, 0); + _this.m_maxTorque = b2Maybe(def.maxTorque, 0); + _this.m_correctionFactor = b2Maybe(def.correctionFactor, .3); + return _this; + } + b2MotorJoint.prototype.GetAnchorA = function(out) { + var pos = this.m_bodyA.GetPosition(); + out.x = pos.x; + out.y = pos.y; + return out; + }; + b2MotorJoint.prototype.GetAnchorB = function(out) { + var pos = this.m_bodyB.GetPosition(); + out.x = pos.x; + out.y = pos.y; + return out; + }; + b2MotorJoint.prototype.GetReactionForce = function(inv_dt, out) { + return b2Vec2.MulSV(inv_dt, this.m_linearImpulse, out); + }; + b2MotorJoint.prototype.GetReactionTorque = function(inv_dt) { + return inv_dt * this.m_angularImpulse; + }; + b2MotorJoint.prototype.SetLinearOffset = function(linearOffset) { + if (!b2Vec2.IsEqualToV(linearOffset, this.m_linearOffset)) { + this.m_bodyA.SetAwake(true); + this.m_bodyB.SetAwake(true); + this.m_linearOffset.Copy(linearOffset); + } + }; + b2MotorJoint.prototype.GetLinearOffset = function() { + return this.m_linearOffset; + }; + b2MotorJoint.prototype.SetAngularOffset = function(angularOffset) { + if (angularOffset !== this.m_angularOffset) { + this.m_bodyA.SetAwake(true); + this.m_bodyB.SetAwake(true); + this.m_angularOffset = angularOffset; + } + }; + b2MotorJoint.prototype.GetAngularOffset = function() { + return this.m_angularOffset; + }; + b2MotorJoint.prototype.SetMaxForce = function(force) { + this.m_maxForce = force; + }; + b2MotorJoint.prototype.GetMaxForce = function() { + return this.m_maxForce; + }; + b2MotorJoint.prototype.SetMaxTorque = function(torque) { + this.m_maxTorque = torque; + }; + b2MotorJoint.prototype.GetMaxTorque = function() { + return this.m_maxTorque; + }; + b2MotorJoint.prototype.InitVelocityConstraints = function(data) { + this.m_indexA = this.m_bodyA.m_islandIndex; + this.m_indexB = this.m_bodyB.m_islandIndex; + this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter); + this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter); + this.m_invMassA = this.m_bodyA.m_invMass; + this.m_invMassB = this.m_bodyB.m_invMass; + this.m_invIA = this.m_bodyA.m_invI; + this.m_invIB = this.m_bodyB.m_invI; + var cA = data.positions[this.m_indexA].c; + var aA = data.positions[this.m_indexA].a; + var vA = data.velocities[this.m_indexA].v; + var wA = data.velocities[this.m_indexA].w; + var cB = data.positions[this.m_indexB].c; + var aB = data.positions[this.m_indexB].a; + var vB = data.velocities[this.m_indexB].v; + var wB = data.velocities[this.m_indexB].w; + var qA = this.m_qA.SetAngle(aA), qB = this.m_qB.SetAngle(aB); + var rA = b2Rot.MulRV(qA, b2Vec2.SubVV(this.m_linearOffset, this.m_localCenterA, b2Vec2.s_t0), this.m_rA); + var rB = b2Rot.MulRV(qB, b2Vec2.NegV(this.m_localCenterB, b2Vec2.s_t0), this.m_rB); + var mA = this.m_invMassA, mB = this.m_invMassB; + var iA = this.m_invIA, iB = this.m_invIB; + var K = this.m_K; + K.ex.x = mA + mB + iA * rA.y * rA.y + iB * rB.y * rB.y; + K.ex.y = -iA * rA.x * rA.y - iB * rB.x * rB.y; + K.ey.x = K.ex.y; + K.ey.y = mA + mB + iA * rA.x * rA.x + iB * rB.x * rB.x; + K.GetInverse(this.m_linearMass); + this.m_angularMass = iA + iB; + this.m_angularMass > 0 && (this.m_angularMass = 1 / this.m_angularMass); + b2Vec2.SubVV(b2Vec2.AddVV(cB, rB, b2Vec2.s_t0), b2Vec2.AddVV(cA, rA, b2Vec2.s_t1), this.m_linearError); + this.m_angularError = aB - aA - this.m_angularOffset; + if (data.step.warmStarting) { + this.m_linearImpulse.SelfMul(data.step.dtRatio); + this.m_angularImpulse *= data.step.dtRatio; + var P = this.m_linearImpulse; + vA.SelfMulSub(mA, P); + wA -= iA * (b2Vec2.CrossVV(rA, P) + this.m_angularImpulse); + vB.SelfMulAdd(mB, P); + wB += iB * (b2Vec2.CrossVV(rB, P) + this.m_angularImpulse); + } else { + this.m_linearImpulse.SetZero(); + this.m_angularImpulse = 0; + } + data.velocities[this.m_indexA].w = wA; + data.velocities[this.m_indexB].w = wB; + }; + b2MotorJoint.prototype.SolveVelocityConstraints = function(data) { + var vA = data.velocities[this.m_indexA].v; + var wA = data.velocities[this.m_indexA].w; + var vB = data.velocities[this.m_indexB].v; + var wB = data.velocities[this.m_indexB].w; + var mA = this.m_invMassA, mB = this.m_invMassB; + var iA = this.m_invIA, iB = this.m_invIB; + var h = data.step.dt; + var inv_h = data.step.inv_dt; + var Cdot = wB - wA + inv_h * this.m_correctionFactor * this.m_angularError; + var impulse = -this.m_angularMass * Cdot; + var oldImpulse = this.m_angularImpulse; + var maxImpulse = h * this.m_maxTorque; + this.m_angularImpulse = b2Clamp(this.m_angularImpulse + impulse, -maxImpulse, maxImpulse); + impulse = this.m_angularImpulse - oldImpulse; + wA -= iA * impulse; + wB += iB * impulse; + var rA = this.m_rA; + var rB = this.m_rB; + var Cdot_v2 = b2Vec2.AddVV(b2Vec2.SubVV(b2Vec2.AddVV(vB, b2Vec2.CrossSV(wB, rB, b2Vec2.s_t0), b2Vec2.s_t0), b2Vec2.AddVV(vA, b2Vec2.CrossSV(wA, rA, b2Vec2.s_t1), b2Vec2.s_t1), b2Vec2.s_t2), b2Vec2.MulSV(inv_h * this.m_correctionFactor, this.m_linearError, b2Vec2.s_t3), b2MotorJoint.SolveVelocityConstraints_s_Cdot_v2); + var impulse_v2 = b2Mat22.MulMV(this.m_linearMass, Cdot_v2, b2MotorJoint.SolveVelocityConstraints_s_impulse_v2).SelfNeg(); + var oldImpulse_v2 = b2MotorJoint.SolveVelocityConstraints_s_oldImpulse_v2.Copy(this.m_linearImpulse); + this.m_linearImpulse.SelfAdd(impulse_v2); + var maxImpulse = h * this.m_maxForce; + if (this.m_linearImpulse.LengthSquared() > maxImpulse * maxImpulse) { + this.m_linearImpulse.Normalize(); + this.m_linearImpulse.SelfMul(maxImpulse); + } + b2Vec2.SubVV(this.m_linearImpulse, oldImpulse_v2, impulse_v2); + vA.SelfMulSub(mA, impulse_v2); + wA -= iA * b2Vec2.CrossVV(rA, impulse_v2); + vB.SelfMulAdd(mB, impulse_v2); + wB += iB * b2Vec2.CrossVV(rB, impulse_v2); + data.velocities[this.m_indexA].w = wA; + data.velocities[this.m_indexB].w = wB; + }; + b2MotorJoint.prototype.SolvePositionConstraints = function(data) { + return true; + }; + b2MotorJoint.prototype.Dump = function(log) { + var indexA = this.m_bodyA.m_islandIndex; + var indexB = this.m_bodyB.m_islandIndex; + log(" const jd: b2MotorJointDef = new b2MotorJointDef();\n"); + log(" jd.bodyA = bodies[%d];\n", indexA); + log(" jd.bodyB = bodies[%d];\n", indexB); + log(" jd.collideConnected = %s;\n", this.m_collideConnected ? "true" : "false"); + log(" jd.linearOffset.Set(%.15f, %.15f);\n", this.m_linearOffset.x, this.m_linearOffset.y); + log(" jd.angularOffset = %.15f;\n", this.m_angularOffset); + log(" jd.maxForce = %.15f;\n", this.m_maxForce); + log(" jd.maxTorque = %.15f;\n", this.m_maxTorque); + log(" jd.correctionFactor = %.15f;\n", this.m_correctionFactor); + log(" joints[%d] = this.m_world.CreateJoint(jd);\n", this.m_index); + }; + b2MotorJoint.SolveVelocityConstraints_s_Cdot_v2 = new b2Vec2(); + b2MotorJoint.SolveVelocityConstraints_s_impulse_v2 = new b2Vec2(); + b2MotorJoint.SolveVelocityConstraints_s_oldImpulse_v2 = new b2Vec2(); + return b2MotorJoint; + })(b2Joint); + var b2MouseJointDef = (function(_super) { + __extends(b2MouseJointDef, _super); + function b2MouseJointDef() { + var _this = _super.call(this, exports.b2JointType.e_mouseJoint) || this; + _this.target = new b2Vec2(); + _this.maxForce = 0; + _this.frequencyHz = 5; + _this.dampingRatio = .7; + return _this; + } + return b2MouseJointDef; + })(b2JointDef); + var b2MouseJoint = (function(_super) { + __extends(b2MouseJoint, _super); + function b2MouseJoint(def) { + var _this = _super.call(this, def) || this; + _this.m_localAnchorB = new b2Vec2(); + _this.m_targetA = new b2Vec2(); + _this.m_frequencyHz = 0; + _this.m_dampingRatio = 0; + _this.m_beta = 0; + _this.m_impulse = new b2Vec2(); + _this.m_maxForce = 0; + _this.m_gamma = 0; + _this.m_indexA = 0; + _this.m_indexB = 0; + _this.m_rB = new b2Vec2(); + _this.m_localCenterB = new b2Vec2(); + _this.m_invMassB = 0; + _this.m_invIB = 0; + _this.m_mass = new b2Mat22(); + _this.m_C = new b2Vec2(); + _this.m_qB = new b2Rot(); + _this.m_lalcB = new b2Vec2(); + _this.m_K = new b2Mat22(); + _this.m_targetA.Copy(b2Maybe(def.target, b2Vec2.ZERO)); + b2Transform.MulTXV(_this.m_bodyB.GetTransform(), _this.m_targetA, _this.m_localAnchorB); + _this.m_maxForce = b2Maybe(def.maxForce, 0); + _this.m_impulse.SetZero(); + _this.m_frequencyHz = b2Maybe(def.frequencyHz, 0); + _this.m_dampingRatio = b2Maybe(def.dampingRatio, 0); + _this.m_beta = 0; + _this.m_gamma = 0; + return _this; + } + b2MouseJoint.prototype.SetTarget = function(target) { + this.m_bodyB.IsAwake() || this.m_bodyB.SetAwake(true); + this.m_targetA.Copy(target); + }; + b2MouseJoint.prototype.GetTarget = function() { + return this.m_targetA; + }; + b2MouseJoint.prototype.SetMaxForce = function(maxForce) { + this.m_maxForce = maxForce; + }; + b2MouseJoint.prototype.GetMaxForce = function() { + return this.m_maxForce; + }; + b2MouseJoint.prototype.SetFrequency = function(hz) { + this.m_frequencyHz = hz; + }; + b2MouseJoint.prototype.GetFrequency = function() { + return this.m_frequencyHz; + }; + b2MouseJoint.prototype.SetDampingRatio = function(ratio) { + this.m_dampingRatio = ratio; + }; + b2MouseJoint.prototype.GetDampingRatio = function() { + return this.m_dampingRatio; + }; + b2MouseJoint.prototype.InitVelocityConstraints = function(data) { + this.m_indexB = this.m_bodyB.m_islandIndex; + this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter); + this.m_invMassB = this.m_bodyB.m_invMass; + this.m_invIB = this.m_bodyB.m_invI; + var cB = data.positions[this.m_indexB].c; + var aB = data.positions[this.m_indexB].a; + var vB = data.velocities[this.m_indexB].v; + var wB = data.velocities[this.m_indexB].w; + var qB = this.m_qB.SetAngle(aB); + var mass = this.m_bodyB.GetMass(); + var omega = 2 * b2_pi * this.m_frequencyHz; + var d = 2 * mass * this.m_dampingRatio * omega; + var k = mass * (omega * omega); + var h = data.step.dt; + this.m_gamma = h * (d + h * k); + 0 !== this.m_gamma && (this.m_gamma = 1 / this.m_gamma); + this.m_beta = h * k * this.m_gamma; + b2Vec2.SubVV(this.m_localAnchorB, this.m_localCenterB, this.m_lalcB); + b2Rot.MulRV(qB, this.m_lalcB, this.m_rB); + var K = this.m_K; + K.ex.x = this.m_invMassB + this.m_invIB * this.m_rB.y * this.m_rB.y + this.m_gamma; + K.ex.y = -this.m_invIB * this.m_rB.x * this.m_rB.y; + K.ey.x = K.ex.y; + K.ey.y = this.m_invMassB + this.m_invIB * this.m_rB.x * this.m_rB.x + this.m_gamma; + K.GetInverse(this.m_mass); + this.m_C.x = cB.x + this.m_rB.x - this.m_targetA.x; + this.m_C.y = cB.y + this.m_rB.y - this.m_targetA.y; + this.m_C.SelfMul(this.m_beta); + wB *= .98; + if (data.step.warmStarting) { + this.m_impulse.SelfMul(data.step.dtRatio); + vB.x += this.m_invMassB * this.m_impulse.x; + vB.y += this.m_invMassB * this.m_impulse.y; + wB += this.m_invIB * b2Vec2.CrossVV(this.m_rB, this.m_impulse); + } else this.m_impulse.SetZero(); + data.velocities[this.m_indexB].w = wB; + }; + b2MouseJoint.prototype.SolveVelocityConstraints = function(data) { + var vB = data.velocities[this.m_indexB].v; + var wB = data.velocities[this.m_indexB].w; + var Cdot = b2Vec2.AddVCrossSV(vB, wB, this.m_rB, b2MouseJoint.SolveVelocityConstraints_s_Cdot); + var impulse = b2Mat22.MulMV(this.m_mass, b2Vec2.AddVV(Cdot, b2Vec2.AddVV(this.m_C, b2Vec2.MulSV(this.m_gamma, this.m_impulse, b2Vec2.s_t0), b2Vec2.s_t0), b2Vec2.s_t0).SelfNeg(), b2MouseJoint.SolveVelocityConstraints_s_impulse); + var oldImpulse = b2MouseJoint.SolveVelocityConstraints_s_oldImpulse.Copy(this.m_impulse); + this.m_impulse.SelfAdd(impulse); + var maxImpulse = data.step.dt * this.m_maxForce; + this.m_impulse.LengthSquared() > maxImpulse * maxImpulse && this.m_impulse.SelfMul(maxImpulse / this.m_impulse.Length()); + b2Vec2.SubVV(this.m_impulse, oldImpulse, impulse); + vB.SelfMulAdd(this.m_invMassB, impulse); + wB += this.m_invIB * b2Vec2.CrossVV(this.m_rB, impulse); + data.velocities[this.m_indexB].w = wB; + }; + b2MouseJoint.prototype.SolvePositionConstraints = function(data) { + return true; + }; + b2MouseJoint.prototype.GetAnchorA = function(out) { + out.x = this.m_targetA.x; + out.y = this.m_targetA.y; + return out; + }; + b2MouseJoint.prototype.GetAnchorB = function(out) { + return this.m_bodyB.GetWorldPoint(this.m_localAnchorB, out); + }; + b2MouseJoint.prototype.GetReactionForce = function(inv_dt, out) { + return b2Vec2.MulSV(inv_dt, this.m_impulse, out); + }; + b2MouseJoint.prototype.GetReactionTorque = function(inv_dt) { + return 0; + }; + b2MouseJoint.prototype.Dump = function(log) { + log("Mouse joint dumping is not supported.\n"); + }; + b2MouseJoint.prototype.ShiftOrigin = function(newOrigin) { + this.m_targetA.SelfSub(newOrigin); + }; + b2MouseJoint.SolveVelocityConstraints_s_Cdot = new b2Vec2(); + b2MouseJoint.SolveVelocityConstraints_s_impulse = new b2Vec2(); + b2MouseJoint.SolveVelocityConstraints_s_oldImpulse = new b2Vec2(); + return b2MouseJoint; + })(b2Joint); + var b2PrismaticJointDef = (function(_super) { + __extends(b2PrismaticJointDef, _super); + function b2PrismaticJointDef() { + var _this = _super.call(this, exports.b2JointType.e_prismaticJoint) || this; + _this.localAnchorA = new b2Vec2(); + _this.localAnchorB = new b2Vec2(); + _this.localAxisA = new b2Vec2(1, 0); + _this.referenceAngle = 0; + _this.enableLimit = false; + _this.lowerTranslation = 0; + _this.upperTranslation = 0; + _this.enableMotor = false; + _this.maxMotorForce = 0; + _this.motorSpeed = 0; + return _this; + } + b2PrismaticJointDef.prototype.Initialize = function(bA, bB, anchor, axis) { + this.bodyA = bA; + this.bodyB = bB; + this.bodyA.GetLocalPoint(anchor, this.localAnchorA); + this.bodyB.GetLocalPoint(anchor, this.localAnchorB); + this.bodyA.GetLocalVector(axis, this.localAxisA); + this.referenceAngle = this.bodyB.GetAngle() - this.bodyA.GetAngle(); + }; + return b2PrismaticJointDef; + })(b2JointDef); + var b2PrismaticJoint = (function(_super) { + __extends(b2PrismaticJoint, _super); + function b2PrismaticJoint(def) { + var _this = _super.call(this, def) || this; + _this.m_localAnchorA = new b2Vec2(); + _this.m_localAnchorB = new b2Vec2(); + _this.m_localXAxisA = new b2Vec2(); + _this.m_localYAxisA = new b2Vec2(); + _this.m_referenceAngle = 0; + _this.m_impulse = new b2Vec3(0, 0, 0); + _this.m_motorImpulse = 0; + _this.m_lowerTranslation = 0; + _this.m_upperTranslation = 0; + _this.m_maxMotorForce = 0; + _this.m_motorSpeed = 0; + _this.m_enableLimit = false; + _this.m_enableMotor = false; + _this.m_limitState = exports.b2LimitState.e_inactiveLimit; + _this.m_indexA = 0; + _this.m_indexB = 0; + _this.m_localCenterA = new b2Vec2(); + _this.m_localCenterB = new b2Vec2(); + _this.m_invMassA = 0; + _this.m_invMassB = 0; + _this.m_invIA = 0; + _this.m_invIB = 0; + _this.m_axis = new b2Vec2(0, 0); + _this.m_perp = new b2Vec2(0, 0); + _this.m_s1 = 0; + _this.m_s2 = 0; + _this.m_a1 = 0; + _this.m_a2 = 0; + _this.m_K = new b2Mat33(); + _this.m_K3 = new b2Mat33(); + _this.m_K2 = new b2Mat22(); + _this.m_motorMass = 0; + _this.m_qA = new b2Rot(); + _this.m_qB = new b2Rot(); + _this.m_lalcA = new b2Vec2(); + _this.m_lalcB = new b2Vec2(); + _this.m_rA = new b2Vec2(); + _this.m_rB = new b2Vec2(); + _this.m_localAnchorA.Copy(b2Maybe(def.localAnchorA, b2Vec2.ZERO)); + _this.m_localAnchorB.Copy(b2Maybe(def.localAnchorB, b2Vec2.ZERO)); + _this.m_localXAxisA.Copy(b2Maybe(def.localAxisA, new b2Vec2(1, 0))).SelfNormalize(); + b2Vec2.CrossOneV(_this.m_localXAxisA, _this.m_localYAxisA); + _this.m_referenceAngle = b2Maybe(def.referenceAngle, 0); + _this.m_lowerTranslation = b2Maybe(def.lowerTranslation, 0); + _this.m_upperTranslation = b2Maybe(def.upperTranslation, 0); + _this.m_maxMotorForce = b2Maybe(def.maxMotorForce, 0); + _this.m_motorSpeed = b2Maybe(def.motorSpeed, 0); + _this.m_enableLimit = b2Maybe(def.enableLimit, false); + _this.m_enableMotor = b2Maybe(def.enableMotor, false); + return _this; + } + b2PrismaticJoint.prototype.InitVelocityConstraints = function(data) { + this.m_indexA = this.m_bodyA.m_islandIndex; + this.m_indexB = this.m_bodyB.m_islandIndex; + this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter); + this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter); + this.m_invMassA = this.m_bodyA.m_invMass; + this.m_invMassB = this.m_bodyB.m_invMass; + this.m_invIA = this.m_bodyA.m_invI; + this.m_invIB = this.m_bodyB.m_invI; + var cA = data.positions[this.m_indexA].c; + var aA = data.positions[this.m_indexA].a; + var vA = data.velocities[this.m_indexA].v; + var wA = data.velocities[this.m_indexA].w; + var cB = data.positions[this.m_indexB].c; + var aB = data.positions[this.m_indexB].a; + var vB = data.velocities[this.m_indexB].v; + var wB = data.velocities[this.m_indexB].w; + var qA = this.m_qA.SetAngle(aA), qB = this.m_qB.SetAngle(aB); + b2Vec2.SubVV(this.m_localAnchorA, this.m_localCenterA, this.m_lalcA); + var rA = b2Rot.MulRV(qA, this.m_lalcA, this.m_rA); + b2Vec2.SubVV(this.m_localAnchorB, this.m_localCenterB, this.m_lalcB); + var rB = b2Rot.MulRV(qB, this.m_lalcB, this.m_rB); + var d = b2Vec2.AddVV(b2Vec2.SubVV(cB, cA, b2Vec2.s_t0), b2Vec2.SubVV(rB, rA, b2Vec2.s_t1), b2PrismaticJoint.InitVelocityConstraints_s_d); + var mA = this.m_invMassA, mB = this.m_invMassB; + var iA = this.m_invIA, iB = this.m_invIB; + b2Rot.MulRV(qA, this.m_localXAxisA, this.m_axis); + this.m_a1 = b2Vec2.CrossVV(b2Vec2.AddVV(d, rA, b2Vec2.s_t0), this.m_axis); + this.m_a2 = b2Vec2.CrossVV(rB, this.m_axis); + this.m_motorMass = mA + mB + iA * this.m_a1 * this.m_a1 + iB * this.m_a2 * this.m_a2; + this.m_motorMass > 0 && (this.m_motorMass = 1 / this.m_motorMass); + b2Rot.MulRV(qA, this.m_localYAxisA, this.m_perp); + this.m_s1 = b2Vec2.CrossVV(b2Vec2.AddVV(d, rA, b2Vec2.s_t0), this.m_perp); + this.m_s2 = b2Vec2.CrossVV(rB, this.m_perp); + this.m_K.ex.x = mA + mB + iA * this.m_s1 * this.m_s1 + iB * this.m_s2 * this.m_s2; + this.m_K.ex.y = iA * this.m_s1 + iB * this.m_s2; + this.m_K.ex.z = iA * this.m_s1 * this.m_a1 + iB * this.m_s2 * this.m_a2; + this.m_K.ey.x = this.m_K.ex.y; + this.m_K.ey.y = iA + iB; + 0 === this.m_K.ey.y && (this.m_K.ey.y = 1); + this.m_K.ey.z = iA * this.m_a1 + iB * this.m_a2; + this.m_K.ez.x = this.m_K.ex.z; + this.m_K.ez.y = this.m_K.ey.z; + this.m_K.ez.z = mA + mB + iA * this.m_a1 * this.m_a1 + iB * this.m_a2 * this.m_a2; + if (this.m_enableLimit) { + var jointTranslation = b2Vec2.DotVV(this.m_axis, d); + if (b2Abs(this.m_upperTranslation - this.m_lowerTranslation) < 2 * b2_linearSlop) this.m_limitState = exports.b2LimitState.e_equalLimits; else if (jointTranslation <= this.m_lowerTranslation) { + if (this.m_limitState !== exports.b2LimitState.e_atLowerLimit) { + this.m_limitState = exports.b2LimitState.e_atLowerLimit; + this.m_impulse.z = 0; + } + } else if (jointTranslation >= this.m_upperTranslation) { + if (this.m_limitState !== exports.b2LimitState.e_atUpperLimit) { + this.m_limitState = exports.b2LimitState.e_atUpperLimit; + this.m_impulse.z = 0; + } + } else { + this.m_limitState = exports.b2LimitState.e_inactiveLimit; + this.m_impulse.z = 0; + } + } else { + this.m_limitState = exports.b2LimitState.e_inactiveLimit; + this.m_impulse.z = 0; + } + this.m_enableMotor || (this.m_motorImpulse = 0); + if (data.step.warmStarting) { + this.m_impulse.SelfMul(data.step.dtRatio); + this.m_motorImpulse *= data.step.dtRatio; + var P = b2Vec2.AddVV(b2Vec2.MulSV(this.m_impulse.x, this.m_perp, b2Vec2.s_t0), b2Vec2.MulSV(this.m_motorImpulse + this.m_impulse.z, this.m_axis, b2Vec2.s_t1), b2PrismaticJoint.InitVelocityConstraints_s_P); + var LA = this.m_impulse.x * this.m_s1 + this.m_impulse.y + (this.m_motorImpulse + this.m_impulse.z) * this.m_a1; + var LB = this.m_impulse.x * this.m_s2 + this.m_impulse.y + (this.m_motorImpulse + this.m_impulse.z) * this.m_a2; + vA.SelfMulSub(mA, P); + wA -= iA * LA; + vB.SelfMulAdd(mB, P); + wB += iB * LB; + } else { + this.m_impulse.SetZero(); + this.m_motorImpulse = 0; + } + data.velocities[this.m_indexA].w = wA; + data.velocities[this.m_indexB].w = wB; + }; + b2PrismaticJoint.prototype.SolveVelocityConstraints = function(data) { + var vA = data.velocities[this.m_indexA].v; + var wA = data.velocities[this.m_indexA].w; + var vB = data.velocities[this.m_indexB].v; + var wB = data.velocities[this.m_indexB].w; + var mA = this.m_invMassA, mB = this.m_invMassB; + var iA = this.m_invIA, iB = this.m_invIB; + if (this.m_enableMotor && this.m_limitState !== exports.b2LimitState.e_equalLimits) { + var Cdot = b2Vec2.DotVV(this.m_axis, b2Vec2.SubVV(vB, vA, b2Vec2.s_t0)) + this.m_a2 * wB - this.m_a1 * wA; + var impulse = this.m_motorMass * (this.m_motorSpeed - Cdot); + var oldImpulse = this.m_motorImpulse; + var maxImpulse = data.step.dt * this.m_maxMotorForce; + this.m_motorImpulse = b2Clamp(this.m_motorImpulse + impulse, -maxImpulse, maxImpulse); + impulse = this.m_motorImpulse - oldImpulse; + var P = b2Vec2.MulSV(impulse, this.m_axis, b2PrismaticJoint.SolveVelocityConstraints_s_P); + var LA = impulse * this.m_a1; + var LB = impulse * this.m_a2; + vA.SelfMulSub(mA, P); + wA -= iA * LA; + vB.SelfMulAdd(mB, P); + wB += iB * LB; + } + var Cdot1_x = b2Vec2.DotVV(this.m_perp, b2Vec2.SubVV(vB, vA, b2Vec2.s_t0)) + this.m_s2 * wB - this.m_s1 * wA; + var Cdot1_y = wB - wA; + if (this.m_enableLimit && this.m_limitState !== exports.b2LimitState.e_inactiveLimit) { + var Cdot2 = b2Vec2.DotVV(this.m_axis, b2Vec2.SubVV(vB, vA, b2Vec2.s_t0)) + this.m_a2 * wB - this.m_a1 * wA; + var f1 = b2PrismaticJoint.SolveVelocityConstraints_s_f1.Copy(this.m_impulse); + var df3 = this.m_K.Solve33(-Cdot1_x, -Cdot1_y, -Cdot2, b2PrismaticJoint.SolveVelocityConstraints_s_df3); + this.m_impulse.SelfAdd(df3); + this.m_limitState === exports.b2LimitState.e_atLowerLimit ? this.m_impulse.z = b2Max(this.m_impulse.z, 0) : this.m_limitState === exports.b2LimitState.e_atUpperLimit && (this.m_impulse.z = b2Min(this.m_impulse.z, 0)); + var b_x = -Cdot1_x - (this.m_impulse.z - f1.z) * this.m_K.ez.x; + var b_y = -Cdot1_y - (this.m_impulse.z - f1.z) * this.m_K.ez.y; + var f2r = this.m_K.Solve22(b_x, b_y, b2PrismaticJoint.SolveVelocityConstraints_s_f2r); + f2r.x += f1.x; + f2r.y += f1.y; + this.m_impulse.x = f2r.x; + this.m_impulse.y = f2r.y; + df3.x = this.m_impulse.x - f1.x; + df3.y = this.m_impulse.y - f1.y; + df3.z = this.m_impulse.z - f1.z; + var P = b2Vec2.AddVV(b2Vec2.MulSV(df3.x, this.m_perp, b2Vec2.s_t0), b2Vec2.MulSV(df3.z, this.m_axis, b2Vec2.s_t1), b2PrismaticJoint.SolveVelocityConstraints_s_P); + var LA = df3.x * this.m_s1 + df3.y + df3.z * this.m_a1; + var LB = df3.x * this.m_s2 + df3.y + df3.z * this.m_a2; + vA.SelfMulSub(mA, P); + wA -= iA * LA; + vB.SelfMulAdd(mB, P); + wB += iB * LB; + } else { + var df2 = this.m_K.Solve22(-Cdot1_x, -Cdot1_y, b2PrismaticJoint.SolveVelocityConstraints_s_df2); + this.m_impulse.x += df2.x; + this.m_impulse.y += df2.y; + var P = b2Vec2.MulSV(df2.x, this.m_perp, b2PrismaticJoint.SolveVelocityConstraints_s_P); + var LA = df2.x * this.m_s1 + df2.y; + var LB = df2.x * this.m_s2 + df2.y; + vA.SelfMulSub(mA, P); + wA -= iA * LA; + vB.SelfMulAdd(mB, P); + wB += iB * LB; + } + data.velocities[this.m_indexA].w = wA; + data.velocities[this.m_indexB].w = wB; + }; + b2PrismaticJoint.prototype.SolvePositionConstraints = function(data) { + var cA = data.positions[this.m_indexA].c; + var aA = data.positions[this.m_indexA].a; + var cB = data.positions[this.m_indexB].c; + var aB = data.positions[this.m_indexB].a; + var qA = this.m_qA.SetAngle(aA), qB = this.m_qB.SetAngle(aB); + var mA = this.m_invMassA, mB = this.m_invMassB; + var iA = this.m_invIA, iB = this.m_invIB; + var rA = b2Rot.MulRV(qA, this.m_lalcA, this.m_rA); + var rB = b2Rot.MulRV(qB, this.m_lalcB, this.m_rB); + var d = b2Vec2.SubVV(b2Vec2.AddVV(cB, rB, b2Vec2.s_t0), b2Vec2.AddVV(cA, rA, b2Vec2.s_t1), b2PrismaticJoint.SolvePositionConstraints_s_d); + var axis = b2Rot.MulRV(qA, this.m_localXAxisA, this.m_axis); + var a1 = b2Vec2.CrossVV(b2Vec2.AddVV(d, rA, b2Vec2.s_t0), axis); + var a2 = b2Vec2.CrossVV(rB, axis); + var perp = b2Rot.MulRV(qA, this.m_localYAxisA, this.m_perp); + var s1 = b2Vec2.CrossVV(b2Vec2.AddVV(d, rA, b2Vec2.s_t0), perp); + var s2 = b2Vec2.CrossVV(rB, perp); + var impulse = b2PrismaticJoint.SolvePositionConstraints_s_impulse; + var C1_x = b2Vec2.DotVV(perp, d); + var C1_y = aB - aA - this.m_referenceAngle; + var linearError = b2Abs(C1_x); + var angularError = b2Abs(C1_y); + var active = false; + var C2 = 0; + if (this.m_enableLimit) { + var translation = b2Vec2.DotVV(axis, d); + if (b2Abs(this.m_upperTranslation - this.m_lowerTranslation) < 2 * b2_linearSlop) { + C2 = b2Clamp(translation, -b2_maxLinearCorrection, b2_maxLinearCorrection); + linearError = b2Max(linearError, b2Abs(translation)); + active = true; + } else if (translation <= this.m_lowerTranslation) { + C2 = b2Clamp(translation - this.m_lowerTranslation + b2_linearSlop, -b2_maxLinearCorrection, 0); + linearError = b2Max(linearError, this.m_lowerTranslation - translation); + active = true; + } else if (translation >= this.m_upperTranslation) { + C2 = b2Clamp(translation - this.m_upperTranslation - b2_linearSlop, 0, b2_maxLinearCorrection); + linearError = b2Max(linearError, translation - this.m_upperTranslation); + active = true; + } + } + if (active) { + var k11 = mA + mB + iA * s1 * s1 + iB * s2 * s2; + var k12 = iA * s1 + iB * s2; + var k13 = iA * s1 * a1 + iB * s2 * a2; + var k22 = iA + iB; + 0 === k22 && (k22 = 1); + var k23 = iA * a1 + iB * a2; + var k33 = mA + mB + iA * a1 * a1 + iB * a2 * a2; + var K = this.m_K3; + K.ex.SetXYZ(k11, k12, k13); + K.ey.SetXYZ(k12, k22, k23); + K.ez.SetXYZ(k13, k23, k33); + impulse = K.Solve33(-C1_x, -C1_y, -C2, impulse); + } else { + var k11 = mA + mB + iA * s1 * s1 + iB * s2 * s2; + var k12 = iA * s1 + iB * s2; + var k22 = iA + iB; + 0 === k22 && (k22 = 1); + var K2 = this.m_K2; + K2.ex.Set(k11, k12); + K2.ey.Set(k12, k22); + var impulse1 = K2.Solve(-C1_x, -C1_y, b2PrismaticJoint.SolvePositionConstraints_s_impulse1); + impulse.x = impulse1.x; + impulse.y = impulse1.y; + impulse.z = 0; + } + var P = b2Vec2.AddVV(b2Vec2.MulSV(impulse.x, perp, b2Vec2.s_t0), b2Vec2.MulSV(impulse.z, axis, b2Vec2.s_t1), b2PrismaticJoint.SolvePositionConstraints_s_P); + var LA = impulse.x * s1 + impulse.y + impulse.z * a1; + var LB = impulse.x * s2 + impulse.y + impulse.z * a2; + cA.SelfMulSub(mA, P); + aA -= iA * LA; + cB.SelfMulAdd(mB, P); + aB += iB * LB; + data.positions[this.m_indexA].a = aA; + data.positions[this.m_indexB].a = aB; + return linearError <= b2_linearSlop && angularError <= b2_angularSlop; + }; + b2PrismaticJoint.prototype.GetAnchorA = function(out) { + return this.m_bodyA.GetWorldPoint(this.m_localAnchorA, out); + }; + b2PrismaticJoint.prototype.GetAnchorB = function(out) { + return this.m_bodyB.GetWorldPoint(this.m_localAnchorB, out); + }; + b2PrismaticJoint.prototype.GetReactionForce = function(inv_dt, out) { + out.x = inv_dt * (this.m_impulse.x * this.m_perp.x + (this.m_motorImpulse + this.m_impulse.z) * this.m_axis.x); + out.y = inv_dt * (this.m_impulse.x * this.m_perp.y + (this.m_motorImpulse + this.m_impulse.z) * this.m_axis.y); + return out; + }; + b2PrismaticJoint.prototype.GetReactionTorque = function(inv_dt) { + return inv_dt * this.m_impulse.y; + }; + b2PrismaticJoint.prototype.GetLocalAnchorA = function() { + return this.m_localAnchorA; + }; + b2PrismaticJoint.prototype.GetLocalAnchorB = function() { + return this.m_localAnchorB; + }; + b2PrismaticJoint.prototype.GetLocalAxisA = function() { + return this.m_localXAxisA; + }; + b2PrismaticJoint.prototype.GetReferenceAngle = function() { + return this.m_referenceAngle; + }; + b2PrismaticJoint.prototype.GetJointTranslation = function() { + var pA = this.m_bodyA.GetWorldPoint(this.m_localAnchorA, b2PrismaticJoint.GetJointTranslation_s_pA); + var pB = this.m_bodyB.GetWorldPoint(this.m_localAnchorB, b2PrismaticJoint.GetJointTranslation_s_pB); + var d = b2Vec2.SubVV(pB, pA, b2PrismaticJoint.GetJointTranslation_s_d); + var axis = this.m_bodyA.GetWorldVector(this.m_localXAxisA, b2PrismaticJoint.GetJointTranslation_s_axis); + var translation = b2Vec2.DotVV(d, axis); + return translation; + }; + b2PrismaticJoint.prototype.GetJointSpeed = function() { + var bA = this.m_bodyA; + var bB = this.m_bodyB; + b2Vec2.SubVV(this.m_localAnchorA, bA.m_sweep.localCenter, this.m_lalcA); + var rA = b2Rot.MulRV(bA.m_xf.q, this.m_lalcA, this.m_rA); + b2Vec2.SubVV(this.m_localAnchorB, bB.m_sweep.localCenter, this.m_lalcB); + var rB = b2Rot.MulRV(bB.m_xf.q, this.m_lalcB, this.m_rB); + var pA = b2Vec2.AddVV(bA.m_sweep.c, rA, b2Vec2.s_t0); + var pB = b2Vec2.AddVV(bB.m_sweep.c, rB, b2Vec2.s_t1); + var d = b2Vec2.SubVV(pB, pA, b2Vec2.s_t2); + var axis = bA.GetWorldVector(this.m_localXAxisA, this.m_axis); + var vA = bA.m_linearVelocity; + var vB = bB.m_linearVelocity; + var wA = bA.m_angularVelocity; + var wB = bB.m_angularVelocity; + var speed = b2Vec2.DotVV(d, b2Vec2.CrossSV(wA, axis, b2Vec2.s_t0)) + b2Vec2.DotVV(axis, b2Vec2.SubVV(b2Vec2.AddVCrossSV(vB, wB, rB, b2Vec2.s_t0), b2Vec2.AddVCrossSV(vA, wA, rA, b2Vec2.s_t1), b2Vec2.s_t0)); + return speed; + }; + b2PrismaticJoint.prototype.IsLimitEnabled = function() { + return this.m_enableLimit; + }; + b2PrismaticJoint.prototype.EnableLimit = function(flag) { + if (flag !== this.m_enableLimit) { + this.m_bodyA.SetAwake(true); + this.m_bodyB.SetAwake(true); + this.m_enableLimit = flag; + this.m_impulse.z = 0; + } + }; + b2PrismaticJoint.prototype.GetLowerLimit = function() { + return this.m_lowerTranslation; + }; + b2PrismaticJoint.prototype.GetUpperLimit = function() { + return this.m_upperTranslation; + }; + b2PrismaticJoint.prototype.SetLimits = function(lower, upper) { + if (lower !== this.m_lowerTranslation || upper !== this.m_upperTranslation) { + this.m_bodyA.SetAwake(true); + this.m_bodyB.SetAwake(true); + this.m_lowerTranslation = lower; + this.m_upperTranslation = upper; + this.m_impulse.z = 0; + } + }; + b2PrismaticJoint.prototype.IsMotorEnabled = function() { + return this.m_enableMotor; + }; + b2PrismaticJoint.prototype.EnableMotor = function(flag) { + if (flag !== this.m_enableMotor) { + this.m_bodyA.SetAwake(true); + this.m_bodyB.SetAwake(true); + this.m_enableMotor = flag; + } + }; + b2PrismaticJoint.prototype.SetMotorSpeed = function(speed) { + if (speed !== this.m_motorSpeed) { + this.m_bodyA.SetAwake(true); + this.m_bodyB.SetAwake(true); + this.m_motorSpeed = speed; + } + }; + b2PrismaticJoint.prototype.GetMotorSpeed = function() { + return this.m_motorSpeed; + }; + b2PrismaticJoint.prototype.SetMaxMotorForce = function(force) { + if (force !== this.m_maxMotorForce) { + this.m_bodyA.SetAwake(true); + this.m_bodyB.SetAwake(true); + this.m_maxMotorForce = force; + } + }; + b2PrismaticJoint.prototype.GetMaxMotorForce = function() { + return this.m_maxMotorForce; + }; + b2PrismaticJoint.prototype.GetMotorForce = function(inv_dt) { + return inv_dt * this.m_motorImpulse; + }; + b2PrismaticJoint.prototype.Dump = function(log) { + var indexA = this.m_bodyA.m_islandIndex; + var indexB = this.m_bodyB.m_islandIndex; + log(" const jd: b2PrismaticJointDef = new b2PrismaticJointDef();\n"); + log(" jd.bodyA = bodies[%d];\n", indexA); + log(" jd.bodyB = bodies[%d];\n", indexB); + log(" jd.collideConnected = %s;\n", this.m_collideConnected ? "true" : "false"); + log(" jd.localAnchorA.Set(%.15f, %.15f);\n", this.m_localAnchorA.x, this.m_localAnchorA.y); + log(" jd.localAnchorB.Set(%.15f, %.15f);\n", this.m_localAnchorB.x, this.m_localAnchorB.y); + log(" jd.localAxisA.Set(%.15f, %.15f);\n", this.m_localXAxisA.x, this.m_localXAxisA.y); + log(" jd.referenceAngle = %.15f;\n", this.m_referenceAngle); + log(" jd.enableLimit = %s;\n", this.m_enableLimit ? "true" : "false"); + log(" jd.lowerTranslation = %.15f;\n", this.m_lowerTranslation); + log(" jd.upperTranslation = %.15f;\n", this.m_upperTranslation); + log(" jd.enableMotor = %s;\n", this.m_enableMotor ? "true" : "false"); + log(" jd.motorSpeed = %.15f;\n", this.m_motorSpeed); + log(" jd.maxMotorForce = %.15f;\n", this.m_maxMotorForce); + log(" joints[%d] = this.m_world.CreateJoint(jd);\n", this.m_index); + }; + b2PrismaticJoint.InitVelocityConstraints_s_d = new b2Vec2(); + b2PrismaticJoint.InitVelocityConstraints_s_P = new b2Vec2(); + b2PrismaticJoint.SolveVelocityConstraints_s_P = new b2Vec2(); + b2PrismaticJoint.SolveVelocityConstraints_s_f2r = new b2Vec2(); + b2PrismaticJoint.SolveVelocityConstraints_s_f1 = new b2Vec3(); + b2PrismaticJoint.SolveVelocityConstraints_s_df3 = new b2Vec3(); + b2PrismaticJoint.SolveVelocityConstraints_s_df2 = new b2Vec2(); + b2PrismaticJoint.SolvePositionConstraints_s_d = new b2Vec2(); + b2PrismaticJoint.SolvePositionConstraints_s_impulse = new b2Vec3(); + b2PrismaticJoint.SolvePositionConstraints_s_impulse1 = new b2Vec2(); + b2PrismaticJoint.SolvePositionConstraints_s_P = new b2Vec2(); + b2PrismaticJoint.GetJointTranslation_s_pA = new b2Vec2(); + b2PrismaticJoint.GetJointTranslation_s_pB = new b2Vec2(); + b2PrismaticJoint.GetJointTranslation_s_d = new b2Vec2(); + b2PrismaticJoint.GetJointTranslation_s_axis = new b2Vec2(); + return b2PrismaticJoint; + })(b2Joint); + var b2_minPulleyLength = 2; + var b2PulleyJointDef = (function(_super) { + __extends(b2PulleyJointDef, _super); + function b2PulleyJointDef() { + var _this = _super.call(this, exports.b2JointType.e_pulleyJoint) || this; + _this.groundAnchorA = new b2Vec2(-1, 1); + _this.groundAnchorB = new b2Vec2(1, 1); + _this.localAnchorA = new b2Vec2(-1, 0); + _this.localAnchorB = new b2Vec2(1, 0); + _this.lengthA = 0; + _this.lengthB = 0; + _this.ratio = 1; + _this.collideConnected = true; + return _this; + } + b2PulleyJointDef.prototype.Initialize = function(bA, bB, groundA, groundB, anchorA, anchorB, r) { + this.bodyA = bA; + this.bodyB = bB; + this.groundAnchorA.Copy(groundA); + this.groundAnchorB.Copy(groundB); + this.bodyA.GetLocalPoint(anchorA, this.localAnchorA); + this.bodyB.GetLocalPoint(anchorB, this.localAnchorB); + this.lengthA = b2Vec2.DistanceVV(anchorA, groundA); + this.lengthB = b2Vec2.DistanceVV(anchorB, groundB); + this.ratio = r; + }; + return b2PulleyJointDef; + })(b2JointDef); + var b2PulleyJoint = (function(_super) { + __extends(b2PulleyJoint, _super); + function b2PulleyJoint(def) { + var _this = _super.call(this, def) || this; + _this.m_groundAnchorA = new b2Vec2(); + _this.m_groundAnchorB = new b2Vec2(); + _this.m_lengthA = 0; + _this.m_lengthB = 0; + _this.m_localAnchorA = new b2Vec2(); + _this.m_localAnchorB = new b2Vec2(); + _this.m_constant = 0; + _this.m_ratio = 0; + _this.m_impulse = 0; + _this.m_indexA = 0; + _this.m_indexB = 0; + _this.m_uA = new b2Vec2(); + _this.m_uB = new b2Vec2(); + _this.m_rA = new b2Vec2(); + _this.m_rB = new b2Vec2(); + _this.m_localCenterA = new b2Vec2(); + _this.m_localCenterB = new b2Vec2(); + _this.m_invMassA = 0; + _this.m_invMassB = 0; + _this.m_invIA = 0; + _this.m_invIB = 0; + _this.m_mass = 0; + _this.m_qA = new b2Rot(); + _this.m_qB = new b2Rot(); + _this.m_lalcA = new b2Vec2(); + _this.m_lalcB = new b2Vec2(); + _this.m_groundAnchorA.Copy(b2Maybe(def.groundAnchorA, new b2Vec2(-1, 1))); + _this.m_groundAnchorB.Copy(b2Maybe(def.groundAnchorB, new b2Vec2(1, 0))); + _this.m_localAnchorA.Copy(b2Maybe(def.localAnchorA, new b2Vec2(-1, 0))); + _this.m_localAnchorB.Copy(b2Maybe(def.localAnchorB, new b2Vec2(1, 0))); + _this.m_lengthA = b2Maybe(def.lengthA, 0); + _this.m_lengthB = b2Maybe(def.lengthB, 0); + _this.m_ratio = b2Maybe(def.ratio, 1); + _this.m_constant = b2Maybe(def.lengthA, 0) + _this.m_ratio * b2Maybe(def.lengthB, 0); + _this.m_impulse = 0; + return _this; + } + b2PulleyJoint.prototype.InitVelocityConstraints = function(data) { + this.m_indexA = this.m_bodyA.m_islandIndex; + this.m_indexB = this.m_bodyB.m_islandIndex; + this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter); + this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter); + this.m_invMassA = this.m_bodyA.m_invMass; + this.m_invMassB = this.m_bodyB.m_invMass; + this.m_invIA = this.m_bodyA.m_invI; + this.m_invIB = this.m_bodyB.m_invI; + var cA = data.positions[this.m_indexA].c; + var aA = data.positions[this.m_indexA].a; + var vA = data.velocities[this.m_indexA].v; + var wA = data.velocities[this.m_indexA].w; + var cB = data.positions[this.m_indexB].c; + var aB = data.positions[this.m_indexB].a; + var vB = data.velocities[this.m_indexB].v; + var wB = data.velocities[this.m_indexB].w; + var qA = this.m_qA.SetAngle(aA), qB = this.m_qB.SetAngle(aB); + b2Vec2.SubVV(this.m_localAnchorA, this.m_localCenterA, this.m_lalcA); + b2Rot.MulRV(qA, this.m_lalcA, this.m_rA); + b2Vec2.SubVV(this.m_localAnchorB, this.m_localCenterB, this.m_lalcB); + b2Rot.MulRV(qB, this.m_lalcB, this.m_rB); + this.m_uA.Copy(cA).SelfAdd(this.m_rA).SelfSub(this.m_groundAnchorA); + this.m_uB.Copy(cB).SelfAdd(this.m_rB).SelfSub(this.m_groundAnchorB); + var lengthA = this.m_uA.Length(); + var lengthB = this.m_uB.Length(); + lengthA > 10 * b2_linearSlop ? this.m_uA.SelfMul(1 / lengthA) : this.m_uA.SetZero(); + lengthB > 10 * b2_linearSlop ? this.m_uB.SelfMul(1 / lengthB) : this.m_uB.SetZero(); + var ruA = b2Vec2.CrossVV(this.m_rA, this.m_uA); + var ruB = b2Vec2.CrossVV(this.m_rB, this.m_uB); + var mA = this.m_invMassA + this.m_invIA * ruA * ruA; + var mB = this.m_invMassB + this.m_invIB * ruB * ruB; + this.m_mass = mA + this.m_ratio * this.m_ratio * mB; + this.m_mass > 0 && (this.m_mass = 1 / this.m_mass); + if (data.step.warmStarting) { + this.m_impulse *= data.step.dtRatio; + var PA = b2Vec2.MulSV(-this.m_impulse, this.m_uA, b2PulleyJoint.InitVelocityConstraints_s_PA); + var PB = b2Vec2.MulSV(-this.m_ratio * this.m_impulse, this.m_uB, b2PulleyJoint.InitVelocityConstraints_s_PB); + vA.SelfMulAdd(this.m_invMassA, PA); + wA += this.m_invIA * b2Vec2.CrossVV(this.m_rA, PA); + vB.SelfMulAdd(this.m_invMassB, PB); + wB += this.m_invIB * b2Vec2.CrossVV(this.m_rB, PB); + } else this.m_impulse = 0; + data.velocities[this.m_indexA].w = wA; + data.velocities[this.m_indexB].w = wB; + }; + b2PulleyJoint.prototype.SolveVelocityConstraints = function(data) { + var vA = data.velocities[this.m_indexA].v; + var wA = data.velocities[this.m_indexA].w; + var vB = data.velocities[this.m_indexB].v; + var wB = data.velocities[this.m_indexB].w; + var vpA = b2Vec2.AddVCrossSV(vA, wA, this.m_rA, b2PulleyJoint.SolveVelocityConstraints_s_vpA); + var vpB = b2Vec2.AddVCrossSV(vB, wB, this.m_rB, b2PulleyJoint.SolveVelocityConstraints_s_vpB); + var Cdot = -b2Vec2.DotVV(this.m_uA, vpA) - this.m_ratio * b2Vec2.DotVV(this.m_uB, vpB); + var impulse = -this.m_mass * Cdot; + this.m_impulse += impulse; + var PA = b2Vec2.MulSV(-impulse, this.m_uA, b2PulleyJoint.SolveVelocityConstraints_s_PA); + var PB = b2Vec2.MulSV(-this.m_ratio * impulse, this.m_uB, b2PulleyJoint.SolveVelocityConstraints_s_PB); + vA.SelfMulAdd(this.m_invMassA, PA); + wA += this.m_invIA * b2Vec2.CrossVV(this.m_rA, PA); + vB.SelfMulAdd(this.m_invMassB, PB); + wB += this.m_invIB * b2Vec2.CrossVV(this.m_rB, PB); + data.velocities[this.m_indexA].w = wA; + data.velocities[this.m_indexB].w = wB; + }; + b2PulleyJoint.prototype.SolvePositionConstraints = function(data) { + var cA = data.positions[this.m_indexA].c; + var aA = data.positions[this.m_indexA].a; + var cB = data.positions[this.m_indexB].c; + var aB = data.positions[this.m_indexB].a; + var qA = this.m_qA.SetAngle(aA), qB = this.m_qB.SetAngle(aB); + b2Vec2.SubVV(this.m_localAnchorA, this.m_localCenterA, this.m_lalcA); + var rA = b2Rot.MulRV(qA, this.m_lalcA, this.m_rA); + b2Vec2.SubVV(this.m_localAnchorB, this.m_localCenterB, this.m_lalcB); + var rB = b2Rot.MulRV(qB, this.m_lalcB, this.m_rB); + var uA = this.m_uA.Copy(cA).SelfAdd(rA).SelfSub(this.m_groundAnchorA); + var uB = this.m_uB.Copy(cB).SelfAdd(rB).SelfSub(this.m_groundAnchorB); + var lengthA = uA.Length(); + var lengthB = uB.Length(); + lengthA > 10 * b2_linearSlop ? uA.SelfMul(1 / lengthA) : uA.SetZero(); + lengthB > 10 * b2_linearSlop ? uB.SelfMul(1 / lengthB) : uB.SetZero(); + var ruA = b2Vec2.CrossVV(rA, uA); + var ruB = b2Vec2.CrossVV(rB, uB); + var mA = this.m_invMassA + this.m_invIA * ruA * ruA; + var mB = this.m_invMassB + this.m_invIB * ruB * ruB; + var mass = mA + this.m_ratio * this.m_ratio * mB; + mass > 0 && (mass = 1 / mass); + var C = this.m_constant - lengthA - this.m_ratio * lengthB; + var linearError = b2Abs(C); + var impulse = -mass * C; + var PA = b2Vec2.MulSV(-impulse, uA, b2PulleyJoint.SolvePositionConstraints_s_PA); + var PB = b2Vec2.MulSV(-this.m_ratio * impulse, uB, b2PulleyJoint.SolvePositionConstraints_s_PB); + cA.SelfMulAdd(this.m_invMassA, PA); + aA += this.m_invIA * b2Vec2.CrossVV(rA, PA); + cB.SelfMulAdd(this.m_invMassB, PB); + aB += this.m_invIB * b2Vec2.CrossVV(rB, PB); + data.positions[this.m_indexA].a = aA; + data.positions[this.m_indexB].a = aB; + return linearError < b2_linearSlop; + }; + b2PulleyJoint.prototype.GetAnchorA = function(out) { + return this.m_bodyA.GetWorldPoint(this.m_localAnchorA, out); + }; + b2PulleyJoint.prototype.GetAnchorB = function(out) { + return this.m_bodyB.GetWorldPoint(this.m_localAnchorB, out); + }; + b2PulleyJoint.prototype.GetReactionForce = function(inv_dt, out) { + out.x = inv_dt * this.m_impulse * this.m_uB.x; + out.y = inv_dt * this.m_impulse * this.m_uB.y; + return out; + }; + b2PulleyJoint.prototype.GetReactionTorque = function(inv_dt) { + return 0; + }; + b2PulleyJoint.prototype.GetGroundAnchorA = function() { + return this.m_groundAnchorA; + }; + b2PulleyJoint.prototype.GetGroundAnchorB = function() { + return this.m_groundAnchorB; + }; + b2PulleyJoint.prototype.GetLengthA = function() { + return this.m_lengthA; + }; + b2PulleyJoint.prototype.GetLengthB = function() { + return this.m_lengthB; + }; + b2PulleyJoint.prototype.GetRatio = function() { + return this.m_ratio; + }; + b2PulleyJoint.prototype.GetCurrentLengthA = function() { + var p = this.m_bodyA.GetWorldPoint(this.m_localAnchorA, b2PulleyJoint.GetCurrentLengthA_s_p); + var s = this.m_groundAnchorA; + return b2Vec2.DistanceVV(p, s); + }; + b2PulleyJoint.prototype.GetCurrentLengthB = function() { + var p = this.m_bodyB.GetWorldPoint(this.m_localAnchorB, b2PulleyJoint.GetCurrentLengthB_s_p); + var s = this.m_groundAnchorB; + return b2Vec2.DistanceVV(p, s); + }; + b2PulleyJoint.prototype.Dump = function(log) { + var indexA = this.m_bodyA.m_islandIndex; + var indexB = this.m_bodyB.m_islandIndex; + log(" const jd: b2PulleyJointDef = new b2PulleyJointDef();\n"); + log(" jd.bodyA = bodies[%d];\n", indexA); + log(" jd.bodyB = bodies[%d];\n", indexB); + log(" jd.collideConnected = %s;\n", this.m_collideConnected ? "true" : "false"); + log(" jd.groundAnchorA.Set(%.15f, %.15f);\n", this.m_groundAnchorA.x, this.m_groundAnchorA.y); + log(" jd.groundAnchorB.Set(%.15f, %.15f);\n", this.m_groundAnchorB.x, this.m_groundAnchorB.y); + log(" jd.localAnchorA.Set(%.15f, %.15f);\n", this.m_localAnchorA.x, this.m_localAnchorA.y); + log(" jd.localAnchorB.Set(%.15f, %.15f);\n", this.m_localAnchorB.x, this.m_localAnchorB.y); + log(" jd.lengthA = %.15f;\n", this.m_lengthA); + log(" jd.lengthB = %.15f;\n", this.m_lengthB); + log(" jd.ratio = %.15f;\n", this.m_ratio); + log(" joints[%d] = this.m_world.CreateJoint(jd);\n", this.m_index); + }; + b2PulleyJoint.prototype.ShiftOrigin = function(newOrigin) { + this.m_groundAnchorA.SelfSub(newOrigin); + this.m_groundAnchorB.SelfSub(newOrigin); + }; + b2PulleyJoint.InitVelocityConstraints_s_PA = new b2Vec2(); + b2PulleyJoint.InitVelocityConstraints_s_PB = new b2Vec2(); + b2PulleyJoint.SolveVelocityConstraints_s_vpA = new b2Vec2(); + b2PulleyJoint.SolveVelocityConstraints_s_vpB = new b2Vec2(); + b2PulleyJoint.SolveVelocityConstraints_s_PA = new b2Vec2(); + b2PulleyJoint.SolveVelocityConstraints_s_PB = new b2Vec2(); + b2PulleyJoint.SolvePositionConstraints_s_PA = new b2Vec2(); + b2PulleyJoint.SolvePositionConstraints_s_PB = new b2Vec2(); + b2PulleyJoint.GetCurrentLengthA_s_p = new b2Vec2(); + b2PulleyJoint.GetCurrentLengthB_s_p = new b2Vec2(); + return b2PulleyJoint; + })(b2Joint); + var b2RevoluteJointDef = (function(_super) { + __extends(b2RevoluteJointDef, _super); + function b2RevoluteJointDef() { + var _this = _super.call(this, exports.b2JointType.e_revoluteJoint) || this; + _this.localAnchorA = new b2Vec2(0, 0); + _this.localAnchorB = new b2Vec2(0, 0); + _this.referenceAngle = 0; + _this.enableLimit = false; + _this.lowerAngle = 0; + _this.upperAngle = 0; + _this.enableMotor = false; + _this.motorSpeed = 0; + _this.maxMotorTorque = 0; + return _this; + } + b2RevoluteJointDef.prototype.Initialize = function(bA, bB, anchor) { + this.bodyA = bA; + this.bodyB = bB; + this.bodyA.GetLocalPoint(anchor, this.localAnchorA); + this.bodyB.GetLocalPoint(anchor, this.localAnchorB); + this.referenceAngle = this.bodyB.GetAngle() - this.bodyA.GetAngle(); + }; + return b2RevoluteJointDef; + })(b2JointDef); + var b2RevoluteJoint = (function(_super) { + __extends(b2RevoluteJoint, _super); + function b2RevoluteJoint(def) { + var _this = _super.call(this, def) || this; + _this.m_localAnchorA = new b2Vec2(); + _this.m_localAnchorB = new b2Vec2(); + _this.m_impulse = new b2Vec3(); + _this.m_motorImpulse = 0; + _this.m_enableMotor = false; + _this.m_maxMotorTorque = 0; + _this.m_motorSpeed = 0; + _this.m_enableLimit = false; + _this.m_referenceAngle = 0; + _this.m_lowerAngle = 0; + _this.m_upperAngle = 0; + _this.m_indexA = 0; + _this.m_indexB = 0; + _this.m_rA = new b2Vec2(); + _this.m_rB = new b2Vec2(); + _this.m_localCenterA = new b2Vec2(); + _this.m_localCenterB = new b2Vec2(); + _this.m_invMassA = 0; + _this.m_invMassB = 0; + _this.m_invIA = 0; + _this.m_invIB = 0; + _this.m_mass = new b2Mat33(); + _this.m_motorMass = 0; + _this.m_limitState = exports.b2LimitState.e_inactiveLimit; + _this.m_qA = new b2Rot(); + _this.m_qB = new b2Rot(); + _this.m_lalcA = new b2Vec2(); + _this.m_lalcB = new b2Vec2(); + _this.m_K = new b2Mat22(); + _this.m_localAnchorA.Copy(b2Maybe(def.localAnchorA, b2Vec2.ZERO)); + _this.m_localAnchorB.Copy(b2Maybe(def.localAnchorB, b2Vec2.ZERO)); + _this.m_referenceAngle = b2Maybe(def.referenceAngle, 0); + _this.m_impulse.SetZero(); + _this.m_motorImpulse = 0; + _this.m_lowerAngle = b2Maybe(def.lowerAngle, 0); + _this.m_upperAngle = b2Maybe(def.upperAngle, 0); + _this.m_maxMotorTorque = b2Maybe(def.maxMotorTorque, 0); + _this.m_motorSpeed = b2Maybe(def.motorSpeed, 0); + _this.m_enableLimit = b2Maybe(def.enableLimit, false); + _this.m_enableMotor = b2Maybe(def.enableMotor, false); + _this.m_limitState = exports.b2LimitState.e_inactiveLimit; + return _this; + } + b2RevoluteJoint.prototype.InitVelocityConstraints = function(data) { + this.m_indexA = this.m_bodyA.m_islandIndex; + this.m_indexB = this.m_bodyB.m_islandIndex; + this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter); + this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter); + this.m_invMassA = this.m_bodyA.m_invMass; + this.m_invMassB = this.m_bodyB.m_invMass; + this.m_invIA = this.m_bodyA.m_invI; + this.m_invIB = this.m_bodyB.m_invI; + var aA = data.positions[this.m_indexA].a; + var vA = data.velocities[this.m_indexA].v; + var wA = data.velocities[this.m_indexA].w; + var aB = data.positions[this.m_indexB].a; + var vB = data.velocities[this.m_indexB].v; + var wB = data.velocities[this.m_indexB].w; + var qA = this.m_qA.SetAngle(aA), qB = this.m_qB.SetAngle(aB); + b2Vec2.SubVV(this.m_localAnchorA, this.m_localCenterA, this.m_lalcA); + b2Rot.MulRV(qA, this.m_lalcA, this.m_rA); + b2Vec2.SubVV(this.m_localAnchorB, this.m_localCenterB, this.m_lalcB); + b2Rot.MulRV(qB, this.m_lalcB, this.m_rB); + var mA = this.m_invMassA, mB = this.m_invMassB; + var iA = this.m_invIA, iB = this.m_invIB; + var fixedRotation = iA + iB === 0; + this.m_mass.ex.x = mA + mB + this.m_rA.y * this.m_rA.y * iA + this.m_rB.y * this.m_rB.y * iB; + this.m_mass.ey.x = -this.m_rA.y * this.m_rA.x * iA - this.m_rB.y * this.m_rB.x * iB; + this.m_mass.ez.x = -this.m_rA.y * iA - this.m_rB.y * iB; + this.m_mass.ex.y = this.m_mass.ey.x; + this.m_mass.ey.y = mA + mB + this.m_rA.x * this.m_rA.x * iA + this.m_rB.x * this.m_rB.x * iB; + this.m_mass.ez.y = this.m_rA.x * iA + this.m_rB.x * iB; + this.m_mass.ex.z = this.m_mass.ez.x; + this.m_mass.ey.z = this.m_mass.ez.y; + this.m_mass.ez.z = iA + iB; + this.m_motorMass = iA + iB; + this.m_motorMass > 0 && (this.m_motorMass = 1 / this.m_motorMass); + this.m_enableMotor && !fixedRotation || (this.m_motorImpulse = 0); + if (this.m_enableLimit && !fixedRotation) { + var jointAngle = aB - aA - this.m_referenceAngle; + if (b2Abs(this.m_upperAngle - this.m_lowerAngle) < 2 * b2_angularSlop) this.m_limitState = exports.b2LimitState.e_equalLimits; else if (jointAngle <= this.m_lowerAngle) { + this.m_limitState !== exports.b2LimitState.e_atLowerLimit && (this.m_impulse.z = 0); + this.m_limitState = exports.b2LimitState.e_atLowerLimit; + } else if (jointAngle >= this.m_upperAngle) { + this.m_limitState !== exports.b2LimitState.e_atUpperLimit && (this.m_impulse.z = 0); + this.m_limitState = exports.b2LimitState.e_atUpperLimit; + } else { + this.m_limitState = exports.b2LimitState.e_inactiveLimit; + this.m_impulse.z = 0; + } + } else this.m_limitState = exports.b2LimitState.e_inactiveLimit; + if (data.step.warmStarting) { + this.m_impulse.SelfMul(data.step.dtRatio); + this.m_motorImpulse *= data.step.dtRatio; + var P = b2RevoluteJoint.InitVelocityConstraints_s_P.Set(this.m_impulse.x, this.m_impulse.y); + vA.SelfMulSub(mA, P); + wA -= iA * (b2Vec2.CrossVV(this.m_rA, P) + this.m_motorImpulse + this.m_impulse.z); + vB.SelfMulAdd(mB, P); + wB += iB * (b2Vec2.CrossVV(this.m_rB, P) + this.m_motorImpulse + this.m_impulse.z); + } else { + this.m_impulse.SetZero(); + this.m_motorImpulse = 0; + } + data.velocities[this.m_indexA].w = wA; + data.velocities[this.m_indexB].w = wB; + }; + b2RevoluteJoint.prototype.SolveVelocityConstraints = function(data) { + var vA = data.velocities[this.m_indexA].v; + var wA = data.velocities[this.m_indexA].w; + var vB = data.velocities[this.m_indexB].v; + var wB = data.velocities[this.m_indexB].w; + var mA = this.m_invMassA, mB = this.m_invMassB; + var iA = this.m_invIA, iB = this.m_invIB; + var fixedRotation = iA + iB === 0; + if (this.m_enableMotor && this.m_limitState !== exports.b2LimitState.e_equalLimits && !fixedRotation) { + var Cdot = wB - wA - this.m_motorSpeed; + var impulse = -this.m_motorMass * Cdot; + var oldImpulse = this.m_motorImpulse; + var maxImpulse = data.step.dt * this.m_maxMotorTorque; + this.m_motorImpulse = b2Clamp(this.m_motorImpulse + impulse, -maxImpulse, maxImpulse); + impulse = this.m_motorImpulse - oldImpulse; + wA -= iA * impulse; + wB += iB * impulse; + } + if (this.m_enableLimit && this.m_limitState !== exports.b2LimitState.e_inactiveLimit && !fixedRotation) { + var Cdot1 = b2Vec2.SubVV(b2Vec2.AddVCrossSV(vB, wB, this.m_rB, b2Vec2.s_t0), b2Vec2.AddVCrossSV(vA, wA, this.m_rA, b2Vec2.s_t1), b2RevoluteJoint.SolveVelocityConstraints_s_Cdot1); + var Cdot2 = wB - wA; + var impulse_v3 = this.m_mass.Solve33(Cdot1.x, Cdot1.y, Cdot2, b2RevoluteJoint.SolveVelocityConstraints_s_impulse_v3).SelfNeg(); + if (this.m_limitState === exports.b2LimitState.e_equalLimits) this.m_impulse.SelfAdd(impulse_v3); else if (this.m_limitState === exports.b2LimitState.e_atLowerLimit) { + var newImpulse = this.m_impulse.z + impulse_v3.z; + if (newImpulse < 0) { + var rhs_x = -Cdot1.x + this.m_impulse.z * this.m_mass.ez.x; + var rhs_y = -Cdot1.y + this.m_impulse.z * this.m_mass.ez.y; + var reduced_v2 = this.m_mass.Solve22(rhs_x, rhs_y, b2RevoluteJoint.SolveVelocityConstraints_s_reduced_v2); + impulse_v3.x = reduced_v2.x; + impulse_v3.y = reduced_v2.y; + impulse_v3.z = -this.m_impulse.z; + this.m_impulse.x += reduced_v2.x; + this.m_impulse.y += reduced_v2.y; + this.m_impulse.z = 0; + } else this.m_impulse.SelfAdd(impulse_v3); + } else if (this.m_limitState === exports.b2LimitState.e_atUpperLimit) { + var newImpulse = this.m_impulse.z + impulse_v3.z; + if (newImpulse > 0) { + var rhs_x = -Cdot1.x + this.m_impulse.z * this.m_mass.ez.x; + var rhs_y = -Cdot1.y + this.m_impulse.z * this.m_mass.ez.y; + var reduced_v2 = this.m_mass.Solve22(rhs_x, rhs_y, b2RevoluteJoint.SolveVelocityConstraints_s_reduced_v2); + impulse_v3.x = reduced_v2.x; + impulse_v3.y = reduced_v2.y; + impulse_v3.z = -this.m_impulse.z; + this.m_impulse.x += reduced_v2.x; + this.m_impulse.y += reduced_v2.y; + this.m_impulse.z = 0; + } else this.m_impulse.SelfAdd(impulse_v3); + } + var P = b2RevoluteJoint.SolveVelocityConstraints_s_P.Set(impulse_v3.x, impulse_v3.y); + vA.SelfMulSub(mA, P); + wA -= iA * (b2Vec2.CrossVV(this.m_rA, P) + impulse_v3.z); + vB.SelfMulAdd(mB, P); + wB += iB * (b2Vec2.CrossVV(this.m_rB, P) + impulse_v3.z); + } else { + var Cdot_v2 = b2Vec2.SubVV(b2Vec2.AddVCrossSV(vB, wB, this.m_rB, b2Vec2.s_t0), b2Vec2.AddVCrossSV(vA, wA, this.m_rA, b2Vec2.s_t1), b2RevoluteJoint.SolveVelocityConstraints_s_Cdot_v2); + var impulse_v2 = this.m_mass.Solve22(-Cdot_v2.x, -Cdot_v2.y, b2RevoluteJoint.SolveVelocityConstraints_s_impulse_v2); + this.m_impulse.x += impulse_v2.x; + this.m_impulse.y += impulse_v2.y; + vA.SelfMulSub(mA, impulse_v2); + wA -= iA * b2Vec2.CrossVV(this.m_rA, impulse_v2); + vB.SelfMulAdd(mB, impulse_v2); + wB += iB * b2Vec2.CrossVV(this.m_rB, impulse_v2); + } + data.velocities[this.m_indexA].w = wA; + data.velocities[this.m_indexB].w = wB; + }; + b2RevoluteJoint.prototype.SolvePositionConstraints = function(data) { + var cA = data.positions[this.m_indexA].c; + var aA = data.positions[this.m_indexA].a; + var cB = data.positions[this.m_indexB].c; + var aB = data.positions[this.m_indexB].a; + var qA = this.m_qA.SetAngle(aA), qB = this.m_qB.SetAngle(aB); + var angularError = 0; + var positionError = 0; + var fixedRotation = this.m_invIA + this.m_invIB === 0; + if (this.m_enableLimit && this.m_limitState !== exports.b2LimitState.e_inactiveLimit && !fixedRotation) { + var angle = aB - aA - this.m_referenceAngle; + var limitImpulse = 0; + if (this.m_limitState === exports.b2LimitState.e_equalLimits) { + var C = b2Clamp(angle - this.m_lowerAngle, -b2_maxAngularCorrection, b2_maxAngularCorrection); + limitImpulse = -this.m_motorMass * C; + angularError = b2Abs(C); + } else if (this.m_limitState === exports.b2LimitState.e_atLowerLimit) { + var C = angle - this.m_lowerAngle; + angularError = -C; + C = b2Clamp(C + b2_angularSlop, -b2_maxAngularCorrection, 0); + limitImpulse = -this.m_motorMass * C; + } else if (this.m_limitState === exports.b2LimitState.e_atUpperLimit) { + var C = angle - this.m_upperAngle; + angularError = C; + C = b2Clamp(C - b2_angularSlop, 0, b2_maxAngularCorrection); + limitImpulse = -this.m_motorMass * C; + } + aA -= this.m_invIA * limitImpulse; + aB += this.m_invIB * limitImpulse; + } + qA.SetAngle(aA); + qB.SetAngle(aB); + b2Vec2.SubVV(this.m_localAnchorA, this.m_localCenterA, this.m_lalcA); + var rA = b2Rot.MulRV(qA, this.m_lalcA, this.m_rA); + b2Vec2.SubVV(this.m_localAnchorB, this.m_localCenterB, this.m_lalcB); + var rB = b2Rot.MulRV(qB, this.m_lalcB, this.m_rB); + var C_v2 = b2Vec2.SubVV(b2Vec2.AddVV(cB, rB, b2Vec2.s_t0), b2Vec2.AddVV(cA, rA, b2Vec2.s_t1), b2RevoluteJoint.SolvePositionConstraints_s_C_v2); + positionError = C_v2.Length(); + var mA = this.m_invMassA, mB = this.m_invMassB; + var iA = this.m_invIA, iB = this.m_invIB; + var K = this.m_K; + K.ex.x = mA + mB + iA * rA.y * rA.y + iB * rB.y * rB.y; + K.ex.y = -iA * rA.x * rA.y - iB * rB.x * rB.y; + K.ey.x = K.ex.y; + K.ey.y = mA + mB + iA * rA.x * rA.x + iB * rB.x * rB.x; + var impulse = K.Solve(C_v2.x, C_v2.y, b2RevoluteJoint.SolvePositionConstraints_s_impulse).SelfNeg(); + cA.SelfMulSub(mA, impulse); + aA -= iA * b2Vec2.CrossVV(rA, impulse); + cB.SelfMulAdd(mB, impulse); + aB += iB * b2Vec2.CrossVV(rB, impulse); + data.positions[this.m_indexA].a = aA; + data.positions[this.m_indexB].a = aB; + return positionError <= b2_linearSlop && angularError <= b2_angularSlop; + }; + b2RevoluteJoint.prototype.GetAnchorA = function(out) { + return this.m_bodyA.GetWorldPoint(this.m_localAnchorA, out); + }; + b2RevoluteJoint.prototype.GetAnchorB = function(out) { + return this.m_bodyB.GetWorldPoint(this.m_localAnchorB, out); + }; + b2RevoluteJoint.prototype.GetReactionForce = function(inv_dt, out) { + out.x = inv_dt * this.m_impulse.x; + out.y = inv_dt * this.m_impulse.y; + return out; + }; + b2RevoluteJoint.prototype.GetReactionTorque = function(inv_dt) { + return inv_dt * this.m_impulse.z; + }; + b2RevoluteJoint.prototype.GetLocalAnchorA = function() { + return this.m_localAnchorA; + }; + b2RevoluteJoint.prototype.GetLocalAnchorB = function() { + return this.m_localAnchorB; + }; + b2RevoluteJoint.prototype.GetReferenceAngle = function() { + return this.m_referenceAngle; + }; + b2RevoluteJoint.prototype.GetJointAngle = function() { + return this.m_bodyB.m_sweep.a - this.m_bodyA.m_sweep.a - this.m_referenceAngle; + }; + b2RevoluteJoint.prototype.GetJointSpeed = function() { + return this.m_bodyB.m_angularVelocity - this.m_bodyA.m_angularVelocity; + }; + b2RevoluteJoint.prototype.IsMotorEnabled = function() { + return this.m_enableMotor; + }; + b2RevoluteJoint.prototype.EnableMotor = function(flag) { + if (flag !== this.m_enableMotor) { + this.m_bodyA.SetAwake(true); + this.m_bodyB.SetAwake(true); + this.m_enableMotor = flag; + } + }; + b2RevoluteJoint.prototype.GetMotorTorque = function(inv_dt) { + return inv_dt * this.m_motorImpulse; + }; + b2RevoluteJoint.prototype.GetMotorSpeed = function() { + return this.m_motorSpeed; + }; + b2RevoluteJoint.prototype.SetMaxMotorTorque = function(torque) { + if (torque !== this.m_maxMotorTorque) { + this.m_bodyA.SetAwake(true); + this.m_bodyB.SetAwake(true); + this.m_maxMotorTorque = torque; + } + }; + b2RevoluteJoint.prototype.GetMaxMotorTorque = function() { + return this.m_maxMotorTorque; + }; + b2RevoluteJoint.prototype.IsLimitEnabled = function() { + return this.m_enableLimit; + }; + b2RevoluteJoint.prototype.EnableLimit = function(flag) { + if (flag !== this.m_enableLimit) { + this.m_bodyA.SetAwake(true); + this.m_bodyB.SetAwake(true); + this.m_enableLimit = flag; + this.m_impulse.z = 0; + } + }; + b2RevoluteJoint.prototype.GetLowerLimit = function() { + return this.m_lowerAngle; + }; + b2RevoluteJoint.prototype.GetUpperLimit = function() { + return this.m_upperAngle; + }; + b2RevoluteJoint.prototype.SetLimits = function(lower, upper) { + if (lower !== this.m_lowerAngle || upper !== this.m_upperAngle) { + this.m_bodyA.SetAwake(true); + this.m_bodyB.SetAwake(true); + this.m_impulse.z = 0; + this.m_lowerAngle = lower; + this.m_upperAngle = upper; + } + }; + b2RevoluteJoint.prototype.SetMotorSpeed = function(speed) { + if (speed !== this.m_motorSpeed) { + this.m_bodyA.SetAwake(true); + this.m_bodyB.SetAwake(true); + this.m_motorSpeed = speed; + } + }; + b2RevoluteJoint.prototype.Dump = function(log) { + var indexA = this.m_bodyA.m_islandIndex; + var indexB = this.m_bodyB.m_islandIndex; + log(" const jd: b2RevoluteJointDef = new b2RevoluteJointDef();\n"); + log(" jd.bodyA = bodies[%d];\n", indexA); + log(" jd.bodyB = bodies[%d];\n", indexB); + log(" jd.collideConnected = %s;\n", this.m_collideConnected ? "true" : "false"); + log(" jd.localAnchorA.Set(%.15f, %.15f);\n", this.m_localAnchorA.x, this.m_localAnchorA.y); + log(" jd.localAnchorB.Set(%.15f, %.15f);\n", this.m_localAnchorB.x, this.m_localAnchorB.y); + log(" jd.referenceAngle = %.15f;\n", this.m_referenceAngle); + log(" jd.enableLimit = %s;\n", this.m_enableLimit ? "true" : "false"); + log(" jd.lowerAngle = %.15f;\n", this.m_lowerAngle); + log(" jd.upperAngle = %.15f;\n", this.m_upperAngle); + log(" jd.enableMotor = %s;\n", this.m_enableMotor ? "true" : "false"); + log(" jd.motorSpeed = %.15f;\n", this.m_motorSpeed); + log(" jd.maxMotorTorque = %.15f;\n", this.m_maxMotorTorque); + log(" joints[%d] = this.m_world.CreateJoint(jd);\n", this.m_index); + }; + b2RevoluteJoint.InitVelocityConstraints_s_P = new b2Vec2(); + b2RevoluteJoint.SolveVelocityConstraints_s_P = new b2Vec2(); + b2RevoluteJoint.SolveVelocityConstraints_s_Cdot_v2 = new b2Vec2(); + b2RevoluteJoint.SolveVelocityConstraints_s_Cdot1 = new b2Vec2(); + b2RevoluteJoint.SolveVelocityConstraints_s_impulse_v3 = new b2Vec3(); + b2RevoluteJoint.SolveVelocityConstraints_s_reduced_v2 = new b2Vec2(); + b2RevoluteJoint.SolveVelocityConstraints_s_impulse_v2 = new b2Vec2(); + b2RevoluteJoint.SolvePositionConstraints_s_C_v2 = new b2Vec2(); + b2RevoluteJoint.SolvePositionConstraints_s_impulse = new b2Vec2(); + return b2RevoluteJoint; + })(b2Joint); + var b2RopeJointDef = (function(_super) { + __extends(b2RopeJointDef, _super); + function b2RopeJointDef() { + var _this = _super.call(this, exports.b2JointType.e_ropeJoint) || this; + _this.localAnchorA = new b2Vec2(-1, 0); + _this.localAnchorB = new b2Vec2(1, 0); + _this.maxLength = 0; + return _this; + } + return b2RopeJointDef; + })(b2JointDef); + var b2RopeJoint = (function(_super) { + __extends(b2RopeJoint, _super); + function b2RopeJoint(def) { + var _this = _super.call(this, def) || this; + _this.m_localAnchorA = new b2Vec2(); + _this.m_localAnchorB = new b2Vec2(); + _this.m_maxLength = 0; + _this.m_length = 0; + _this.m_impulse = 0; + _this.m_indexA = 0; + _this.m_indexB = 0; + _this.m_u = new b2Vec2(); + _this.m_rA = new b2Vec2(); + _this.m_rB = new b2Vec2(); + _this.m_localCenterA = new b2Vec2(); + _this.m_localCenterB = new b2Vec2(); + _this.m_invMassA = 0; + _this.m_invMassB = 0; + _this.m_invIA = 0; + _this.m_invIB = 0; + _this.m_mass = 0; + _this.m_state = exports.b2LimitState.e_inactiveLimit; + _this.m_qA = new b2Rot(); + _this.m_qB = new b2Rot(); + _this.m_lalcA = new b2Vec2(); + _this.m_lalcB = new b2Vec2(); + _this.m_localAnchorA.Copy(b2Maybe(def.localAnchorA, new b2Vec2(-1, 0))); + _this.m_localAnchorB.Copy(b2Maybe(def.localAnchorB, new b2Vec2(1, 0))); + _this.m_maxLength = b2Maybe(def.maxLength, 0); + return _this; + } + b2RopeJoint.prototype.InitVelocityConstraints = function(data) { + this.m_indexA = this.m_bodyA.m_islandIndex; + this.m_indexB = this.m_bodyB.m_islandIndex; + this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter); + this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter); + this.m_invMassA = this.m_bodyA.m_invMass; + this.m_invMassB = this.m_bodyB.m_invMass; + this.m_invIA = this.m_bodyA.m_invI; + this.m_invIB = this.m_bodyB.m_invI; + var cA = data.positions[this.m_indexA].c; + var aA = data.positions[this.m_indexA].a; + var vA = data.velocities[this.m_indexA].v; + var wA = data.velocities[this.m_indexA].w; + var cB = data.positions[this.m_indexB].c; + var aB = data.positions[this.m_indexB].a; + var vB = data.velocities[this.m_indexB].v; + var wB = data.velocities[this.m_indexB].w; + var qA = this.m_qA.SetAngle(aA), qB = this.m_qB.SetAngle(aB); + b2Vec2.SubVV(this.m_localAnchorA, this.m_localCenterA, this.m_lalcA); + b2Rot.MulRV(qA, this.m_lalcA, this.m_rA); + b2Vec2.SubVV(this.m_localAnchorB, this.m_localCenterB, this.m_lalcB); + b2Rot.MulRV(qB, this.m_lalcB, this.m_rB); + this.m_u.Copy(cB).SelfAdd(this.m_rB).SelfSub(cA).SelfSub(this.m_rA); + this.m_length = this.m_u.Length(); + var C = this.m_length - this.m_maxLength; + this.m_state = C > 0 ? exports.b2LimitState.e_atUpperLimit : exports.b2LimitState.e_inactiveLimit; + if (!(this.m_length > b2_linearSlop)) { + this.m_u.SetZero(); + this.m_mass = 0; + this.m_impulse = 0; + return; + } + this.m_u.SelfMul(1 / this.m_length); + var crA = b2Vec2.CrossVV(this.m_rA, this.m_u); + var crB = b2Vec2.CrossVV(this.m_rB, this.m_u); + var invMass = this.m_invMassA + this.m_invIA * crA * crA + this.m_invMassB + this.m_invIB * crB * crB; + this.m_mass = 0 !== invMass ? 1 / invMass : 0; + if (data.step.warmStarting) { + this.m_impulse *= data.step.dtRatio; + var P = b2Vec2.MulSV(this.m_impulse, this.m_u, b2RopeJoint.InitVelocityConstraints_s_P); + vA.SelfMulSub(this.m_invMassA, P); + wA -= this.m_invIA * b2Vec2.CrossVV(this.m_rA, P); + vB.SelfMulAdd(this.m_invMassB, P); + wB += this.m_invIB * b2Vec2.CrossVV(this.m_rB, P); + } else this.m_impulse = 0; + data.velocities[this.m_indexA].w = wA; + data.velocities[this.m_indexB].w = wB; + }; + b2RopeJoint.prototype.SolveVelocityConstraints = function(data) { + var vA = data.velocities[this.m_indexA].v; + var wA = data.velocities[this.m_indexA].w; + var vB = data.velocities[this.m_indexB].v; + var wB = data.velocities[this.m_indexB].w; + var vpA = b2Vec2.AddVCrossSV(vA, wA, this.m_rA, b2RopeJoint.SolveVelocityConstraints_s_vpA); + var vpB = b2Vec2.AddVCrossSV(vB, wB, this.m_rB, b2RopeJoint.SolveVelocityConstraints_s_vpB); + var C = this.m_length - this.m_maxLength; + var Cdot = b2Vec2.DotVV(this.m_u, b2Vec2.SubVV(vpB, vpA, b2Vec2.s_t0)); + C < 0 && (Cdot += data.step.inv_dt * C); + var impulse = -this.m_mass * Cdot; + var oldImpulse = this.m_impulse; + this.m_impulse = b2Min(0, this.m_impulse + impulse); + impulse = this.m_impulse - oldImpulse; + var P = b2Vec2.MulSV(impulse, this.m_u, b2RopeJoint.SolveVelocityConstraints_s_P); + vA.SelfMulSub(this.m_invMassA, P); + wA -= this.m_invIA * b2Vec2.CrossVV(this.m_rA, P); + vB.SelfMulAdd(this.m_invMassB, P); + wB += this.m_invIB * b2Vec2.CrossVV(this.m_rB, P); + data.velocities[this.m_indexA].w = wA; + data.velocities[this.m_indexB].w = wB; + }; + b2RopeJoint.prototype.SolvePositionConstraints = function(data) { + var cA = data.positions[this.m_indexA].c; + var aA = data.positions[this.m_indexA].a; + var cB = data.positions[this.m_indexB].c; + var aB = data.positions[this.m_indexB].a; + var qA = this.m_qA.SetAngle(aA), qB = this.m_qB.SetAngle(aB); + b2Vec2.SubVV(this.m_localAnchorA, this.m_localCenterA, this.m_lalcA); + var rA = b2Rot.MulRV(qA, this.m_lalcA, this.m_rA); + b2Vec2.SubVV(this.m_localAnchorB, this.m_localCenterB, this.m_lalcB); + var rB = b2Rot.MulRV(qB, this.m_lalcB, this.m_rB); + var u = this.m_u.Copy(cB).SelfAdd(rB).SelfSub(cA).SelfSub(rA); + var length = u.Normalize(); + var C = length - this.m_maxLength; + C = b2Clamp(C, 0, b2_maxLinearCorrection); + var impulse = -this.m_mass * C; + var P = b2Vec2.MulSV(impulse, u, b2RopeJoint.SolvePositionConstraints_s_P); + cA.SelfMulSub(this.m_invMassA, P); + aA -= this.m_invIA * b2Vec2.CrossVV(rA, P); + cB.SelfMulAdd(this.m_invMassB, P); + aB += this.m_invIB * b2Vec2.CrossVV(rB, P); + data.positions[this.m_indexA].a = aA; + data.positions[this.m_indexB].a = aB; + return length - this.m_maxLength < b2_linearSlop; + }; + b2RopeJoint.prototype.GetAnchorA = function(out) { + return this.m_bodyA.GetWorldPoint(this.m_localAnchorA, out); + }; + b2RopeJoint.prototype.GetAnchorB = function(out) { + return this.m_bodyB.GetWorldPoint(this.m_localAnchorB, out); + }; + b2RopeJoint.prototype.GetReactionForce = function(inv_dt, out) { + return b2Vec2.MulSV(inv_dt * this.m_impulse, this.m_u, out); + }; + b2RopeJoint.prototype.GetReactionTorque = function(inv_dt) { + return 0; + }; + b2RopeJoint.prototype.GetLocalAnchorA = function() { + return this.m_localAnchorA; + }; + b2RopeJoint.prototype.GetLocalAnchorB = function() { + return this.m_localAnchorB; + }; + b2RopeJoint.prototype.SetMaxLength = function(length) { + this.m_maxLength = length; + }; + b2RopeJoint.prototype.GetMaxLength = function() { + return this.m_maxLength; + }; + b2RopeJoint.prototype.GetLimitState = function() { + return this.m_state; + }; + b2RopeJoint.prototype.Dump = function(log) { + var indexA = this.m_bodyA.m_islandIndex; + var indexB = this.m_bodyB.m_islandIndex; + log(" const jd: b2RopeJointDef = new b2RopeJointDef();\n"); + log(" jd.bodyA = bodies[%d];\n", indexA); + log(" jd.bodyB = bodies[%d];\n", indexB); + log(" jd.collideConnected = %s;\n", this.m_collideConnected ? "true" : "false"); + log(" jd.localAnchorA.Set(%.15f, %.15f);\n", this.m_localAnchorA.x, this.m_localAnchorA.y); + log(" jd.localAnchorB.Set(%.15f, %.15f);\n", this.m_localAnchorB.x, this.m_localAnchorB.y); + log(" jd.maxLength = %.15f;\n", this.m_maxLength); + log(" joints[%d] = this.m_world.CreateJoint(jd);\n", this.m_index); + }; + b2RopeJoint.InitVelocityConstraints_s_P = new b2Vec2(); + b2RopeJoint.SolveVelocityConstraints_s_vpA = new b2Vec2(); + b2RopeJoint.SolveVelocityConstraints_s_vpB = new b2Vec2(); + b2RopeJoint.SolveVelocityConstraints_s_P = new b2Vec2(); + b2RopeJoint.SolvePositionConstraints_s_P = new b2Vec2(); + return b2RopeJoint; + })(b2Joint); + var b2WeldJointDef = (function(_super) { + __extends(b2WeldJointDef, _super); + function b2WeldJointDef() { + var _this = _super.call(this, exports.b2JointType.e_weldJoint) || this; + _this.localAnchorA = new b2Vec2(); + _this.localAnchorB = new b2Vec2(); + _this.referenceAngle = 0; + _this.frequencyHz = 0; + _this.dampingRatio = 0; + return _this; + } + b2WeldJointDef.prototype.Initialize = function(bA, bB, anchor) { + this.bodyA = bA; + this.bodyB = bB; + this.bodyA.GetLocalPoint(anchor, this.localAnchorA); + this.bodyB.GetLocalPoint(anchor, this.localAnchorB); + this.referenceAngle = this.bodyB.GetAngle() - this.bodyA.GetAngle(); + }; + return b2WeldJointDef; + })(b2JointDef); + var b2WeldJoint = (function(_super) { + __extends(b2WeldJoint, _super); + function b2WeldJoint(def) { + var _this = _super.call(this, def) || this; + _this.m_frequencyHz = 0; + _this.m_dampingRatio = 0; + _this.m_bias = 0; + _this.m_localAnchorA = new b2Vec2(); + _this.m_localAnchorB = new b2Vec2(); + _this.m_referenceAngle = 0; + _this.m_gamma = 0; + _this.m_impulse = new b2Vec3(0, 0, 0); + _this.m_indexA = 0; + _this.m_indexB = 0; + _this.m_rA = new b2Vec2(); + _this.m_rB = new b2Vec2(); + _this.m_localCenterA = new b2Vec2(); + _this.m_localCenterB = new b2Vec2(); + _this.m_invMassA = 0; + _this.m_invMassB = 0; + _this.m_invIA = 0; + _this.m_invIB = 0; + _this.m_mass = new b2Mat33(); + _this.m_qA = new b2Rot(); + _this.m_qB = new b2Rot(); + _this.m_lalcA = new b2Vec2(); + _this.m_lalcB = new b2Vec2(); + _this.m_K = new b2Mat33(); + _this.m_frequencyHz = b2Maybe(def.frequencyHz, 0); + _this.m_dampingRatio = b2Maybe(def.dampingRatio, 0); + _this.m_localAnchorA.Copy(b2Maybe(def.localAnchorA, b2Vec2.ZERO)); + _this.m_localAnchorB.Copy(b2Maybe(def.localAnchorB, b2Vec2.ZERO)); + _this.m_referenceAngle = b2Maybe(def.referenceAngle, 0); + _this.m_impulse.SetZero(); + return _this; + } + b2WeldJoint.prototype.InitVelocityConstraints = function(data) { + this.m_indexA = this.m_bodyA.m_islandIndex; + this.m_indexB = this.m_bodyB.m_islandIndex; + this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter); + this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter); + this.m_invMassA = this.m_bodyA.m_invMass; + this.m_invMassB = this.m_bodyB.m_invMass; + this.m_invIA = this.m_bodyA.m_invI; + this.m_invIB = this.m_bodyB.m_invI; + var aA = data.positions[this.m_indexA].a; + var vA = data.velocities[this.m_indexA].v; + var wA = data.velocities[this.m_indexA].w; + var aB = data.positions[this.m_indexB].a; + var vB = data.velocities[this.m_indexB].v; + var wB = data.velocities[this.m_indexB].w; + var qA = this.m_qA.SetAngle(aA), qB = this.m_qB.SetAngle(aB); + b2Vec2.SubVV(this.m_localAnchorA, this.m_localCenterA, this.m_lalcA); + b2Rot.MulRV(qA, this.m_lalcA, this.m_rA); + b2Vec2.SubVV(this.m_localAnchorB, this.m_localCenterB, this.m_lalcB); + b2Rot.MulRV(qB, this.m_lalcB, this.m_rB); + var mA = this.m_invMassA, mB = this.m_invMassB; + var iA = this.m_invIA, iB = this.m_invIB; + var K = this.m_K; + K.ex.x = mA + mB + this.m_rA.y * this.m_rA.y * iA + this.m_rB.y * this.m_rB.y * iB; + K.ey.x = -this.m_rA.y * this.m_rA.x * iA - this.m_rB.y * this.m_rB.x * iB; + K.ez.x = -this.m_rA.y * iA - this.m_rB.y * iB; + K.ex.y = K.ey.x; + K.ey.y = mA + mB + this.m_rA.x * this.m_rA.x * iA + this.m_rB.x * this.m_rB.x * iB; + K.ez.y = this.m_rA.x * iA + this.m_rB.x * iB; + K.ex.z = K.ez.x; + K.ey.z = K.ez.y; + K.ez.z = iA + iB; + if (this.m_frequencyHz > 0) { + K.GetInverse22(this.m_mass); + var invM = iA + iB; + var m = invM > 0 ? 1 / invM : 0; + var C = aB - aA - this.m_referenceAngle; + var omega = 2 * b2_pi * this.m_frequencyHz; + var d = 2 * m * this.m_dampingRatio * omega; + var k = m * omega * omega; + var h = data.step.dt; + this.m_gamma = h * (d + h * k); + this.m_gamma = 0 !== this.m_gamma ? 1 / this.m_gamma : 0; + this.m_bias = C * h * k * this.m_gamma; + invM += this.m_gamma; + this.m_mass.ez.z = 0 !== invM ? 1 / invM : 0; + } else { + K.GetSymInverse33(this.m_mass); + this.m_gamma = 0; + this.m_bias = 0; + } + if (data.step.warmStarting) { + this.m_impulse.SelfMul(data.step.dtRatio); + var P = b2WeldJoint.InitVelocityConstraints_s_P.Set(this.m_impulse.x, this.m_impulse.y); + vA.SelfMulSub(mA, P); + wA -= iA * (b2Vec2.CrossVV(this.m_rA, P) + this.m_impulse.z); + vB.SelfMulAdd(mB, P); + wB += iB * (b2Vec2.CrossVV(this.m_rB, P) + this.m_impulse.z); + } else this.m_impulse.SetZero(); + data.velocities[this.m_indexA].w = wA; + data.velocities[this.m_indexB].w = wB; + }; + b2WeldJoint.prototype.SolveVelocityConstraints = function(data) { + var vA = data.velocities[this.m_indexA].v; + var wA = data.velocities[this.m_indexA].w; + var vB = data.velocities[this.m_indexB].v; + var wB = data.velocities[this.m_indexB].w; + var mA = this.m_invMassA, mB = this.m_invMassB; + var iA = this.m_invIA, iB = this.m_invIB; + if (this.m_frequencyHz > 0) { + var Cdot2 = wB - wA; + var impulse2 = -this.m_mass.ez.z * (Cdot2 + this.m_bias + this.m_gamma * this.m_impulse.z); + this.m_impulse.z += impulse2; + wA -= iA * impulse2; + wB += iB * impulse2; + var Cdot1 = b2Vec2.SubVV(b2Vec2.AddVCrossSV(vB, wB, this.m_rB, b2Vec2.s_t0), b2Vec2.AddVCrossSV(vA, wA, this.m_rA, b2Vec2.s_t1), b2WeldJoint.SolveVelocityConstraints_s_Cdot1); + var impulse1 = b2Mat33.MulM33XY(this.m_mass, Cdot1.x, Cdot1.y, b2WeldJoint.SolveVelocityConstraints_s_impulse1).SelfNeg(); + this.m_impulse.x += impulse1.x; + this.m_impulse.y += impulse1.y; + var P = impulse1; + vA.SelfMulSub(mA, P); + wA -= iA * b2Vec2.CrossVV(this.m_rA, P); + vB.SelfMulAdd(mB, P); + wB += iB * b2Vec2.CrossVV(this.m_rB, P); + } else { + var Cdot1 = b2Vec2.SubVV(b2Vec2.AddVCrossSV(vB, wB, this.m_rB, b2Vec2.s_t0), b2Vec2.AddVCrossSV(vA, wA, this.m_rA, b2Vec2.s_t1), b2WeldJoint.SolveVelocityConstraints_s_Cdot1); + var Cdot2 = wB - wA; + var impulse = b2Mat33.MulM33XYZ(this.m_mass, Cdot1.x, Cdot1.y, Cdot2, b2WeldJoint.SolveVelocityConstraints_s_impulse).SelfNeg(); + this.m_impulse.SelfAdd(impulse); + var P = b2WeldJoint.SolveVelocityConstraints_s_P.Set(impulse.x, impulse.y); + vA.SelfMulSub(mA, P); + wA -= iA * (b2Vec2.CrossVV(this.m_rA, P) + impulse.z); + vB.SelfMulAdd(mB, P); + wB += iB * (b2Vec2.CrossVV(this.m_rB, P) + impulse.z); + } + data.velocities[this.m_indexA].w = wA; + data.velocities[this.m_indexB].w = wB; + }; + b2WeldJoint.prototype.SolvePositionConstraints = function(data) { + var cA = data.positions[this.m_indexA].c; + var aA = data.positions[this.m_indexA].a; + var cB = data.positions[this.m_indexB].c; + var aB = data.positions[this.m_indexB].a; + var qA = this.m_qA.SetAngle(aA), qB = this.m_qB.SetAngle(aB); + var mA = this.m_invMassA, mB = this.m_invMassB; + var iA = this.m_invIA, iB = this.m_invIB; + b2Vec2.SubVV(this.m_localAnchorA, this.m_localCenterA, this.m_lalcA); + var rA = b2Rot.MulRV(qA, this.m_lalcA, this.m_rA); + b2Vec2.SubVV(this.m_localAnchorB, this.m_localCenterB, this.m_lalcB); + var rB = b2Rot.MulRV(qB, this.m_lalcB, this.m_rB); + var positionError, angularError; + var K = this.m_K; + K.ex.x = mA + mB + rA.y * rA.y * iA + rB.y * rB.y * iB; + K.ey.x = -rA.y * rA.x * iA - rB.y * rB.x * iB; + K.ez.x = -rA.y * iA - rB.y * iB; + K.ex.y = K.ey.x; + K.ey.y = mA + mB + rA.x * rA.x * iA + rB.x * rB.x * iB; + K.ez.y = rA.x * iA + rB.x * iB; + K.ex.z = K.ez.x; + K.ey.z = K.ez.y; + K.ez.z = iA + iB; + if (this.m_frequencyHz > 0) { + var C1 = b2Vec2.SubVV(b2Vec2.AddVV(cB, rB, b2Vec2.s_t0), b2Vec2.AddVV(cA, rA, b2Vec2.s_t1), b2WeldJoint.SolvePositionConstraints_s_C1); + positionError = C1.Length(); + angularError = 0; + var P = K.Solve22(C1.x, C1.y, b2WeldJoint.SolvePositionConstraints_s_P).SelfNeg(); + cA.SelfMulSub(mA, P); + aA -= iA * b2Vec2.CrossVV(rA, P); + cB.SelfMulAdd(mB, P); + aB += iB * b2Vec2.CrossVV(rB, P); + } else { + var C1 = b2Vec2.SubVV(b2Vec2.AddVV(cB, rB, b2Vec2.s_t0), b2Vec2.AddVV(cA, rA, b2Vec2.s_t1), b2WeldJoint.SolvePositionConstraints_s_C1); + var C2 = aB - aA - this.m_referenceAngle; + positionError = C1.Length(); + angularError = b2Abs(C2); + var impulse = K.Solve33(C1.x, C1.y, C2, b2WeldJoint.SolvePositionConstraints_s_impulse).SelfNeg(); + var P = b2WeldJoint.SolvePositionConstraints_s_P.Set(impulse.x, impulse.y); + cA.SelfMulSub(mA, P); + aA -= iA * (b2Vec2.CrossVV(this.m_rA, P) + impulse.z); + cB.SelfMulAdd(mB, P); + aB += iB * (b2Vec2.CrossVV(this.m_rB, P) + impulse.z); + } + data.positions[this.m_indexA].a = aA; + data.positions[this.m_indexB].a = aB; + return positionError <= b2_linearSlop && angularError <= b2_angularSlop; + }; + b2WeldJoint.prototype.GetAnchorA = function(out) { + return this.m_bodyA.GetWorldPoint(this.m_localAnchorA, out); + }; + b2WeldJoint.prototype.GetAnchorB = function(out) { + return this.m_bodyB.GetWorldPoint(this.m_localAnchorB, out); + }; + b2WeldJoint.prototype.GetReactionForce = function(inv_dt, out) { + out.x = inv_dt * this.m_impulse.x; + out.y = inv_dt * this.m_impulse.y; + return out; + }; + b2WeldJoint.prototype.GetReactionTorque = function(inv_dt) { + return inv_dt * this.m_impulse.z; + }; + b2WeldJoint.prototype.GetLocalAnchorA = function() { + return this.m_localAnchorA; + }; + b2WeldJoint.prototype.GetLocalAnchorB = function() { + return this.m_localAnchorB; + }; + b2WeldJoint.prototype.GetReferenceAngle = function() { + return this.m_referenceAngle; + }; + b2WeldJoint.prototype.SetFrequency = function(hz) { + this.m_frequencyHz = hz; + }; + b2WeldJoint.prototype.GetFrequency = function() { + return this.m_frequencyHz; + }; + b2WeldJoint.prototype.SetDampingRatio = function(ratio) { + this.m_dampingRatio = ratio; + }; + b2WeldJoint.prototype.GetDampingRatio = function() { + return this.m_dampingRatio; + }; + b2WeldJoint.prototype.Dump = function(log) { + var indexA = this.m_bodyA.m_islandIndex; + var indexB = this.m_bodyB.m_islandIndex; + log(" const jd: b2WeldJointDef = new b2WeldJointDef();\n"); + log(" jd.bodyA = bodies[%d];\n", indexA); + log(" jd.bodyB = bodies[%d];\n", indexB); + log(" jd.collideConnected = %s;\n", this.m_collideConnected ? "true" : "false"); + log(" jd.localAnchorA.Set(%.15f, %.15f);\n", this.m_localAnchorA.x, this.m_localAnchorA.y); + log(" jd.localAnchorB.Set(%.15f, %.15f);\n", this.m_localAnchorB.x, this.m_localAnchorB.y); + log(" jd.referenceAngle = %.15f;\n", this.m_referenceAngle); + log(" jd.frequencyHz = %.15f;\n", this.m_frequencyHz); + log(" jd.dampingRatio = %.15f;\n", this.m_dampingRatio); + log(" joints[%d] = this.m_world.CreateJoint(jd);\n", this.m_index); + }; + b2WeldJoint.InitVelocityConstraints_s_P = new b2Vec2(); + b2WeldJoint.SolveVelocityConstraints_s_Cdot1 = new b2Vec2(); + b2WeldJoint.SolveVelocityConstraints_s_impulse1 = new b2Vec2(); + b2WeldJoint.SolveVelocityConstraints_s_impulse = new b2Vec3(); + b2WeldJoint.SolveVelocityConstraints_s_P = new b2Vec2(); + b2WeldJoint.SolvePositionConstraints_s_C1 = new b2Vec2(); + b2WeldJoint.SolvePositionConstraints_s_P = new b2Vec2(); + b2WeldJoint.SolvePositionConstraints_s_impulse = new b2Vec3(); + return b2WeldJoint; + })(b2Joint); + var b2WheelJointDef = (function(_super) { + __extends(b2WheelJointDef, _super); + function b2WheelJointDef() { + var _this = _super.call(this, exports.b2JointType.e_wheelJoint) || this; + _this.localAnchorA = new b2Vec2(0, 0); + _this.localAnchorB = new b2Vec2(0, 0); + _this.localAxisA = new b2Vec2(1, 0); + _this.enableMotor = false; + _this.maxMotorTorque = 0; + _this.motorSpeed = 0; + _this.frequencyHz = 2; + _this.dampingRatio = .7; + return _this; + } + b2WheelJointDef.prototype.Initialize = function(bA, bB, anchor, axis) { + this.bodyA = bA; + this.bodyB = bB; + this.bodyA.GetLocalPoint(anchor, this.localAnchorA); + this.bodyB.GetLocalPoint(anchor, this.localAnchorB); + this.bodyA.GetLocalVector(axis, this.localAxisA); + }; + return b2WheelJointDef; + })(b2JointDef); + var b2WheelJoint = (function(_super) { + __extends(b2WheelJoint, _super); + function b2WheelJoint(def) { + var _this = _super.call(this, def) || this; + _this.m_frequencyHz = 0; + _this.m_dampingRatio = 0; + _this.m_localAnchorA = new b2Vec2(); + _this.m_localAnchorB = new b2Vec2(); + _this.m_localXAxisA = new b2Vec2(); + _this.m_localYAxisA = new b2Vec2(); + _this.m_impulse = 0; + _this.m_motorImpulse = 0; + _this.m_springImpulse = 0; + _this.m_maxMotorTorque = 0; + _this.m_motorSpeed = 0; + _this.m_enableMotor = false; + _this.m_indexA = 0; + _this.m_indexB = 0; + _this.m_localCenterA = new b2Vec2(); + _this.m_localCenterB = new b2Vec2(); + _this.m_invMassA = 0; + _this.m_invMassB = 0; + _this.m_invIA = 0; + _this.m_invIB = 0; + _this.m_ax = new b2Vec2(); + _this.m_ay = new b2Vec2(); + _this.m_sAx = 0; + _this.m_sBx = 0; + _this.m_sAy = 0; + _this.m_sBy = 0; + _this.m_mass = 0; + _this.m_motorMass = 0; + _this.m_springMass = 0; + _this.m_bias = 0; + _this.m_gamma = 0; + _this.m_qA = new b2Rot(); + _this.m_qB = new b2Rot(); + _this.m_lalcA = new b2Vec2(); + _this.m_lalcB = new b2Vec2(); + _this.m_rA = new b2Vec2(); + _this.m_rB = new b2Vec2(); + _this.m_frequencyHz = b2Maybe(def.frequencyHz, 2); + _this.m_dampingRatio = b2Maybe(def.dampingRatio, .7); + _this.m_localAnchorA.Copy(b2Maybe(def.localAnchorA, b2Vec2.ZERO)); + _this.m_localAnchorB.Copy(b2Maybe(def.localAnchorB, b2Vec2.ZERO)); + _this.m_localXAxisA.Copy(b2Maybe(def.localAxisA, b2Vec2.UNITX)); + b2Vec2.CrossOneV(_this.m_localXAxisA, _this.m_localYAxisA); + _this.m_maxMotorTorque = b2Maybe(def.maxMotorTorque, 0); + _this.m_motorSpeed = b2Maybe(def.motorSpeed, 0); + _this.m_enableMotor = b2Maybe(def.enableMotor, false); + _this.m_ax.SetZero(); + _this.m_ay.SetZero(); + return _this; + } + b2WheelJoint.prototype.GetMotorSpeed = function() { + return this.m_motorSpeed; + }; + b2WheelJoint.prototype.GetMaxMotorTorque = function() { + return this.m_maxMotorTorque; + }; + b2WheelJoint.prototype.SetSpringFrequencyHz = function(hz) { + this.m_frequencyHz = hz; + }; + b2WheelJoint.prototype.GetSpringFrequencyHz = function() { + return this.m_frequencyHz; + }; + b2WheelJoint.prototype.SetSpringDampingRatio = function(ratio) { + this.m_dampingRatio = ratio; + }; + b2WheelJoint.prototype.GetSpringDampingRatio = function() { + return this.m_dampingRatio; + }; + b2WheelJoint.prototype.InitVelocityConstraints = function(data) { + this.m_indexA = this.m_bodyA.m_islandIndex; + this.m_indexB = this.m_bodyB.m_islandIndex; + this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter); + this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter); + this.m_invMassA = this.m_bodyA.m_invMass; + this.m_invMassB = this.m_bodyB.m_invMass; + this.m_invIA = this.m_bodyA.m_invI; + this.m_invIB = this.m_bodyB.m_invI; + var mA = this.m_invMassA, mB = this.m_invMassB; + var iA = this.m_invIA, iB = this.m_invIB; + var cA = data.positions[this.m_indexA].c; + var aA = data.positions[this.m_indexA].a; + var vA = data.velocities[this.m_indexA].v; + var wA = data.velocities[this.m_indexA].w; + var cB = data.positions[this.m_indexB].c; + var aB = data.positions[this.m_indexB].a; + var vB = data.velocities[this.m_indexB].v; + var wB = data.velocities[this.m_indexB].w; + var qA = this.m_qA.SetAngle(aA), qB = this.m_qB.SetAngle(aB); + b2Vec2.SubVV(this.m_localAnchorA, this.m_localCenterA, this.m_lalcA); + var rA = b2Rot.MulRV(qA, this.m_lalcA, this.m_rA); + b2Vec2.SubVV(this.m_localAnchorB, this.m_localCenterB, this.m_lalcB); + var rB = b2Rot.MulRV(qB, this.m_lalcB, this.m_rB); + var d = b2Vec2.SubVV(b2Vec2.AddVV(cB, rB, b2Vec2.s_t0), b2Vec2.AddVV(cA, rA, b2Vec2.s_t1), b2WheelJoint.InitVelocityConstraints_s_d); + b2Rot.MulRV(qA, this.m_localYAxisA, this.m_ay); + this.m_sAy = b2Vec2.CrossVV(b2Vec2.AddVV(d, rA, b2Vec2.s_t0), this.m_ay); + this.m_sBy = b2Vec2.CrossVV(rB, this.m_ay); + this.m_mass = mA + mB + iA * this.m_sAy * this.m_sAy + iB * this.m_sBy * this.m_sBy; + this.m_mass > 0 && (this.m_mass = 1 / this.m_mass); + this.m_springMass = 0; + this.m_bias = 0; + this.m_gamma = 0; + if (this.m_frequencyHz > 0) { + b2Rot.MulRV(qA, this.m_localXAxisA, this.m_ax); + this.m_sAx = b2Vec2.CrossVV(b2Vec2.AddVV(d, rA, b2Vec2.s_t0), this.m_ax); + this.m_sBx = b2Vec2.CrossVV(rB, this.m_ax); + var invMass = mA + mB + iA * this.m_sAx * this.m_sAx + iB * this.m_sBx * this.m_sBx; + if (invMass > 0) { + this.m_springMass = 1 / invMass; + var C = b2Vec2.DotVV(d, this.m_ax); + var omega = 2 * b2_pi * this.m_frequencyHz; + var damp = 2 * this.m_springMass * this.m_dampingRatio * omega; + var k = this.m_springMass * omega * omega; + var h = data.step.dt; + this.m_gamma = h * (damp + h * k); + this.m_gamma > 0 && (this.m_gamma = 1 / this.m_gamma); + this.m_bias = C * h * k * this.m_gamma; + this.m_springMass = invMass + this.m_gamma; + this.m_springMass > 0 && (this.m_springMass = 1 / this.m_springMass); + } + } else this.m_springImpulse = 0; + if (this.m_enableMotor) { + this.m_motorMass = iA + iB; + this.m_motorMass > 0 && (this.m_motorMass = 1 / this.m_motorMass); + } else { + this.m_motorMass = 0; + this.m_motorImpulse = 0; + } + if (data.step.warmStarting) { + this.m_impulse *= data.step.dtRatio; + this.m_springImpulse *= data.step.dtRatio; + this.m_motorImpulse *= data.step.dtRatio; + var P = b2Vec2.AddVV(b2Vec2.MulSV(this.m_impulse, this.m_ay, b2Vec2.s_t0), b2Vec2.MulSV(this.m_springImpulse, this.m_ax, b2Vec2.s_t1), b2WheelJoint.InitVelocityConstraints_s_P); + var LA = this.m_impulse * this.m_sAy + this.m_springImpulse * this.m_sAx + this.m_motorImpulse; + var LB = this.m_impulse * this.m_sBy + this.m_springImpulse * this.m_sBx + this.m_motorImpulse; + vA.SelfMulSub(this.m_invMassA, P); + wA -= this.m_invIA * LA; + vB.SelfMulAdd(this.m_invMassB, P); + wB += this.m_invIB * LB; + } else { + this.m_impulse = 0; + this.m_springImpulse = 0; + this.m_motorImpulse = 0; + } + data.velocities[this.m_indexA].w = wA; + data.velocities[this.m_indexB].w = wB; + }; + b2WheelJoint.prototype.SolveVelocityConstraints = function(data) { + var mA = this.m_invMassA, mB = this.m_invMassB; + var iA = this.m_invIA, iB = this.m_invIB; + var vA = data.velocities[this.m_indexA].v; + var wA = data.velocities[this.m_indexA].w; + var vB = data.velocities[this.m_indexB].v; + var wB = data.velocities[this.m_indexB].w; + var Cdot = b2Vec2.DotVV(this.m_ax, b2Vec2.SubVV(vB, vA, b2Vec2.s_t0)) + this.m_sBx * wB - this.m_sAx * wA; + var impulse = -this.m_springMass * (Cdot + this.m_bias + this.m_gamma * this.m_springImpulse); + this.m_springImpulse += impulse; + var P = b2Vec2.MulSV(impulse, this.m_ax, b2WheelJoint.SolveVelocityConstraints_s_P); + var LA = impulse * this.m_sAx; + var LB = impulse * this.m_sBx; + vA.SelfMulSub(mA, P); + wA -= iA * LA; + vB.SelfMulAdd(mB, P); + wB += iB * LB; + var Cdot = wB - wA - this.m_motorSpeed; + var impulse = -this.m_motorMass * Cdot; + var oldImpulse = this.m_motorImpulse; + var maxImpulse = data.step.dt * this.m_maxMotorTorque; + this.m_motorImpulse = b2Clamp(this.m_motorImpulse + impulse, -maxImpulse, maxImpulse); + impulse = this.m_motorImpulse - oldImpulse; + wA -= iA * impulse; + wB += iB * impulse; + var Cdot = b2Vec2.DotVV(this.m_ay, b2Vec2.SubVV(vB, vA, b2Vec2.s_t0)) + this.m_sBy * wB - this.m_sAy * wA; + var impulse = -this.m_mass * Cdot; + this.m_impulse += impulse; + var P = b2Vec2.MulSV(impulse, this.m_ay, b2WheelJoint.SolveVelocityConstraints_s_P); + var LA = impulse * this.m_sAy; + var LB = impulse * this.m_sBy; + vA.SelfMulSub(mA, P); + wA -= iA * LA; + vB.SelfMulAdd(mB, P); + wB += iB * LB; + data.velocities[this.m_indexA].w = wA; + data.velocities[this.m_indexB].w = wB; + }; + b2WheelJoint.prototype.SolvePositionConstraints = function(data) { + var cA = data.positions[this.m_indexA].c; + var aA = data.positions[this.m_indexA].a; + var cB = data.positions[this.m_indexB].c; + var aB = data.positions[this.m_indexB].a; + var qA = this.m_qA.SetAngle(aA), qB = this.m_qB.SetAngle(aB); + b2Vec2.SubVV(this.m_localAnchorA, this.m_localCenterA, this.m_lalcA); + var rA = b2Rot.MulRV(qA, this.m_lalcA, this.m_rA); + b2Vec2.SubVV(this.m_localAnchorB, this.m_localCenterB, this.m_lalcB); + var rB = b2Rot.MulRV(qB, this.m_lalcB, this.m_rB); + var d = b2Vec2.AddVV(b2Vec2.SubVV(cB, cA, b2Vec2.s_t0), b2Vec2.SubVV(rB, rA, b2Vec2.s_t1), b2WheelJoint.SolvePositionConstraints_s_d); + var ay = b2Rot.MulRV(qA, this.m_localYAxisA, this.m_ay); + var sAy = b2Vec2.CrossVV(b2Vec2.AddVV(d, rA, b2Vec2.s_t0), ay); + var sBy = b2Vec2.CrossVV(rB, ay); + var C = b2Vec2.DotVV(d, this.m_ay); + var k = this.m_invMassA + this.m_invMassB + this.m_invIA * this.m_sAy * this.m_sAy + this.m_invIB * this.m_sBy * this.m_sBy; + var impulse; + impulse = 0 !== k ? -C / k : 0; + var P = b2Vec2.MulSV(impulse, ay, b2WheelJoint.SolvePositionConstraints_s_P); + var LA = impulse * sAy; + var LB = impulse * sBy; + cA.SelfMulSub(this.m_invMassA, P); + aA -= this.m_invIA * LA; + cB.SelfMulAdd(this.m_invMassB, P); + aB += this.m_invIB * LB; + data.positions[this.m_indexA].a = aA; + data.positions[this.m_indexB].a = aB; + return b2Abs(C) <= b2_linearSlop; + }; + b2WheelJoint.prototype.GetDefinition = function(def) { + return def; + }; + b2WheelJoint.prototype.GetAnchorA = function(out) { + return this.m_bodyA.GetWorldPoint(this.m_localAnchorA, out); + }; + b2WheelJoint.prototype.GetAnchorB = function(out) { + return this.m_bodyB.GetWorldPoint(this.m_localAnchorB, out); + }; + b2WheelJoint.prototype.GetReactionForce = function(inv_dt, out) { + out.x = inv_dt * (this.m_impulse * this.m_ay.x + this.m_springImpulse * this.m_ax.x); + out.y = inv_dt * (this.m_impulse * this.m_ay.y + this.m_springImpulse * this.m_ax.y); + return out; + }; + b2WheelJoint.prototype.GetReactionTorque = function(inv_dt) { + return inv_dt * this.m_motorImpulse; + }; + b2WheelJoint.prototype.GetLocalAnchorA = function() { + return this.m_localAnchorA; + }; + b2WheelJoint.prototype.GetLocalAnchorB = function() { + return this.m_localAnchorB; + }; + b2WheelJoint.prototype.GetLocalAxisA = function() { + return this.m_localXAxisA; + }; + b2WheelJoint.prototype.GetJointTranslation = function() { + return this.GetPrismaticJointTranslation(); + }; + b2WheelJoint.prototype.GetJointLinearSpeed = function() { + return this.GetPrismaticJointSpeed(); + }; + b2WheelJoint.prototype.GetJointAngle = function() { + return this.GetRevoluteJointAngle(); + }; + b2WheelJoint.prototype.GetJointAngularSpeed = function() { + return this.GetRevoluteJointSpeed(); + }; + b2WheelJoint.prototype.GetPrismaticJointTranslation = function() { + var bA = this.m_bodyA; + var bB = this.m_bodyB; + var pA = bA.GetWorldPoint(this.m_localAnchorA, new b2Vec2()); + var pB = bB.GetWorldPoint(this.m_localAnchorB, new b2Vec2()); + var d = b2Vec2.SubVV(pB, pA, new b2Vec2()); + var axis = bA.GetWorldVector(this.m_localXAxisA, new b2Vec2()); + var translation = b2Vec2.DotVV(d, axis); + return translation; + }; + b2WheelJoint.prototype.GetPrismaticJointSpeed = function() { + var bA = this.m_bodyA; + var bB = this.m_bodyB; + b2Vec2.SubVV(this.m_localAnchorA, bA.m_sweep.localCenter, this.m_lalcA); + var rA = b2Rot.MulRV(bA.m_xf.q, this.m_lalcA, this.m_rA); + b2Vec2.SubVV(this.m_localAnchorB, bB.m_sweep.localCenter, this.m_lalcB); + var rB = b2Rot.MulRV(bB.m_xf.q, this.m_lalcB, this.m_rB); + var pA = b2Vec2.AddVV(bA.m_sweep.c, rA, b2Vec2.s_t0); + var pB = b2Vec2.AddVV(bB.m_sweep.c, rB, b2Vec2.s_t1); + var d = b2Vec2.SubVV(pB, pA, b2Vec2.s_t2); + var axis = bA.GetWorldVector(this.m_localXAxisA, new b2Vec2()); + var vA = bA.m_linearVelocity; + var vB = bB.m_linearVelocity; + var wA = bA.m_angularVelocity; + var wB = bB.m_angularVelocity; + var speed = b2Vec2.DotVV(d, b2Vec2.CrossSV(wA, axis, b2Vec2.s_t0)) + b2Vec2.DotVV(axis, b2Vec2.SubVV(b2Vec2.AddVCrossSV(vB, wB, rB, b2Vec2.s_t0), b2Vec2.AddVCrossSV(vA, wA, rA, b2Vec2.s_t1), b2Vec2.s_t0)); + return speed; + }; + b2WheelJoint.prototype.GetRevoluteJointAngle = function() { + return this.m_bodyB.m_sweep.a - this.m_bodyA.m_sweep.a; + }; + b2WheelJoint.prototype.GetRevoluteJointSpeed = function() { + var wA = this.m_bodyA.m_angularVelocity; + var wB = this.m_bodyB.m_angularVelocity; + return wB - wA; + }; + b2WheelJoint.prototype.IsMotorEnabled = function() { + return this.m_enableMotor; + }; + b2WheelJoint.prototype.EnableMotor = function(flag) { + if (flag !== this.m_enableMotor) { + this.m_bodyA.SetAwake(true); + this.m_bodyB.SetAwake(true); + this.m_enableMotor = flag; + } + }; + b2WheelJoint.prototype.SetMotorSpeed = function(speed) { + if (speed !== this.m_motorSpeed) { + this.m_bodyA.SetAwake(true); + this.m_bodyB.SetAwake(true); + this.m_motorSpeed = speed; + } + }; + b2WheelJoint.prototype.SetMaxMotorTorque = function(force) { + if (force !== this.m_maxMotorTorque) { + this.m_bodyA.SetAwake(true); + this.m_bodyB.SetAwake(true); + this.m_maxMotorTorque = force; + } + }; + b2WheelJoint.prototype.GetMotorTorque = function(inv_dt) { + return inv_dt * this.m_motorImpulse; + }; + b2WheelJoint.prototype.Dump = function(log) { + var indexA = this.m_bodyA.m_islandIndex; + var indexB = this.m_bodyB.m_islandIndex; + log(" const jd: b2WheelJointDef = new b2WheelJointDef();\n"); + log(" jd.bodyA = bodies[%d];\n", indexA); + log(" jd.bodyB = bodies[%d];\n", indexB); + log(" jd.collideConnected = %s;\n", this.m_collideConnected ? "true" : "false"); + log(" jd.localAnchorA.Set(%.15f, %.15f);\n", this.m_localAnchorA.x, this.m_localAnchorA.y); + log(" jd.localAnchorB.Set(%.15f, %.15f);\n", this.m_localAnchorB.x, this.m_localAnchorB.y); + log(" jd.localAxisA.Set(%.15f, %.15f);\n", this.m_localXAxisA.x, this.m_localXAxisA.y); + log(" jd.enableMotor = %s;\n", this.m_enableMotor ? "true" : "false"); + log(" jd.motorSpeed = %.15f;\n", this.m_motorSpeed); + log(" jd.maxMotorTorque = %.15f;\n", this.m_maxMotorTorque); + log(" jd.frequencyHz = %.15f;\n", this.m_frequencyHz); + log(" jd.dampingRatio = %.15f;\n", this.m_dampingRatio); + log(" joints[%d] = this.m_world.CreateJoint(jd);\n", this.m_index); + }; + b2WheelJoint.InitVelocityConstraints_s_d = new b2Vec2(); + b2WheelJoint.InitVelocityConstraints_s_P = new b2Vec2(); + b2WheelJoint.SolveVelocityConstraints_s_P = new b2Vec2(); + b2WheelJoint.SolvePositionConstraints_s_d = new b2Vec2(); + b2WheelJoint.SolvePositionConstraints_s_P = new b2Vec2(); + return b2WheelJoint; + })(b2Joint); + function b2MixFriction(friction1, friction2) { + return b2Sqrt(friction1 * friction2); + } + function b2MixRestitution(restitution1, restitution2) { + return restitution1 > restitution2 ? restitution1 : restitution2; + } + var b2ContactEdge = (function() { + function b2ContactEdge(contact) { + this.prev = null; + this.next = null; + this.contact = contact; + } + return b2ContactEdge; + })(); + var b2Contact = (function() { + function b2Contact() { + this.m_islandFlag = false; + this.m_touchingFlag = false; + this.m_enabledFlag = false; + this.m_filterFlag = false; + this.m_bulletHitFlag = false; + this.m_toiFlag = false; + this.m_prev = null; + this.m_next = null; + this.m_indexA = 0; + this.m_indexB = 0; + this.m_manifold = new b2Manifold(); + this.m_toiCount = 0; + this.m_toi = 0; + this.m_friction = 0; + this.m_restitution = 0; + this.m_tangentSpeed = 0; + this.m_oldManifold = new b2Manifold(); + this.m_nodeA = new b2ContactEdge(this); + this.m_nodeB = new b2ContactEdge(this); + } + b2Contact.prototype.GetManifold = function() { + return this.m_manifold; + }; + b2Contact.prototype.GetWorldManifold = function(worldManifold) { + var bodyA = this.m_fixtureA.GetBody(); + var bodyB = this.m_fixtureB.GetBody(); + var shapeA = this.m_fixtureA.GetShape(); + var shapeB = this.m_fixtureB.GetShape(); + worldManifold.Initialize(this.m_manifold, bodyA.GetTransform(), shapeA.m_radius, bodyB.GetTransform(), shapeB.m_radius); + }; + b2Contact.prototype.IsTouching = function() { + return this.m_touchingFlag; + }; + b2Contact.prototype.SetEnabled = function(flag) { + this.m_enabledFlag = flag; + }; + b2Contact.prototype.IsEnabled = function() { + return this.m_enabledFlag; + }; + b2Contact.prototype.GetNext = function() { + return this.m_next; + }; + b2Contact.prototype.GetFixtureA = function() { + return this.m_fixtureA; + }; + b2Contact.prototype.GetChildIndexA = function() { + return this.m_indexA; + }; + b2Contact.prototype.GetFixtureB = function() { + return this.m_fixtureB; + }; + b2Contact.prototype.GetChildIndexB = function() { + return this.m_indexB; + }; + b2Contact.prototype.FlagForFiltering = function() { + this.m_filterFlag = true; + }; + b2Contact.prototype.SetFriction = function(friction) { + this.m_friction = friction; + }; + b2Contact.prototype.GetFriction = function() { + return this.m_friction; + }; + b2Contact.prototype.ResetFriction = function() { + this.m_friction = b2MixFriction(this.m_fixtureA.m_friction, this.m_fixtureB.m_friction); + }; + b2Contact.prototype.SetRestitution = function(restitution) { + this.m_restitution = restitution; + }; + b2Contact.prototype.GetRestitution = function() { + return this.m_restitution; + }; + b2Contact.prototype.ResetRestitution = function() { + this.m_restitution = b2MixRestitution(this.m_fixtureA.m_restitution, this.m_fixtureB.m_restitution); + }; + b2Contact.prototype.SetTangentSpeed = function(speed) { + this.m_tangentSpeed = speed; + }; + b2Contact.prototype.GetTangentSpeed = function() { + return this.m_tangentSpeed; + }; + b2Contact.prototype.Reset = function(fixtureA, indexA, fixtureB, indexB) { + this.m_islandFlag = false; + this.m_touchingFlag = false; + this.m_enabledFlag = true; + this.m_filterFlag = false; + this.m_bulletHitFlag = false; + this.m_toiFlag = false; + this.m_fixtureA = fixtureA; + this.m_fixtureB = fixtureB; + this.m_indexA = indexA; + this.m_indexB = indexB; + this.m_manifold.pointCount = 0; + this.m_prev = null; + this.m_next = null; + delete this.m_nodeA.contact; + this.m_nodeA.prev = null; + this.m_nodeA.next = null; + delete this.m_nodeA.other; + delete this.m_nodeB.contact; + this.m_nodeB.prev = null; + this.m_nodeB.next = null; + delete this.m_nodeB.other; + this.m_toiCount = 0; + this.m_friction = b2MixFriction(this.m_fixtureA.m_friction, this.m_fixtureB.m_friction); + this.m_restitution = b2MixRestitution(this.m_fixtureA.m_restitution, this.m_fixtureB.m_restitution); + }; + b2Contact.prototype.Update = function(listener) { + var tManifold = this.m_oldManifold; + this.m_oldManifold = this.m_manifold; + this.m_manifold = tManifold; + this.m_enabledFlag = true; + var touching = false; + var wasTouching = this.m_touchingFlag; + var sensorA = this.m_fixtureA.IsSensor(); + var sensorB = this.m_fixtureB.IsSensor(); + var sensor = sensorA || sensorB; + var bodyA = this.m_fixtureA.GetBody(); + var bodyB = this.m_fixtureB.GetBody(); + var xfA = bodyA.GetTransform(); + var xfB = bodyB.GetTransform(); + if (sensor) { + var shapeA = this.m_fixtureA.GetShape(); + var shapeB = this.m_fixtureB.GetShape(); + touching = b2TestOverlapShape(shapeA, this.m_indexA, shapeB, this.m_indexB, xfA, xfB); + this.m_manifold.pointCount = 0; + } else { + this.Evaluate(this.m_manifold, xfA, xfB); + touching = this.m_manifold.pointCount > 0; + for (var i = 0; i < this.m_manifold.pointCount; ++i) { + var mp2 = this.m_manifold.points[i]; + mp2.normalImpulse = 0; + mp2.tangentImpulse = 0; + var id2 = mp2.id; + for (var j = 0; j < this.m_oldManifold.pointCount; ++j) { + var mp1 = this.m_oldManifold.points[j]; + if (mp1.id.key === id2.key) { + mp2.normalImpulse = mp1.normalImpulse; + mp2.tangentImpulse = mp1.tangentImpulse; + break; + } + } + } + if (touching !== wasTouching) { + bodyA.SetAwake(true); + bodyB.SetAwake(true); + } + } + this.m_touchingFlag = touching; + !wasTouching && touching && listener && listener.BeginContact(this); + wasTouching && !touching && listener && listener.EndContact(this); + !sensor && touching && listener && listener.PreSolve(this, this.m_oldManifold); + }; + b2Contact.prototype.ComputeTOI = function(sweepA, sweepB) { + var input = b2Contact.ComputeTOI_s_input; + input.proxyA.SetShape(this.m_fixtureA.GetShape(), this.m_indexA); + input.proxyB.SetShape(this.m_fixtureB.GetShape(), this.m_indexB); + input.sweepA.Copy(sweepA); + input.sweepB.Copy(sweepB); + input.tMax = b2_linearSlop; + var output = b2Contact.ComputeTOI_s_output; + b2TimeOfImpact(output, input); + return output.t; + }; + b2Contact.ComputeTOI_s_input = new b2TOIInput(); + b2Contact.ComputeTOI_s_output = new b2TOIOutput(); + return b2Contact; + })(); + var b2CircleContact = (function(_super) { + __extends(b2CircleContact, _super); + function b2CircleContact() { + return _super.call(this) || this; + } + b2CircleContact.Create = function(allocator) { + return new b2CircleContact(); + }; + b2CircleContact.Destroy = function(contact, allocator) {}; + b2CircleContact.prototype.Reset = function(fixtureA, indexA, fixtureB, indexB) { + _super.prototype.Reset.call(this, fixtureA, indexA, fixtureB, indexB); + }; + b2CircleContact.prototype.Evaluate = function(manifold, xfA, xfB) { + var shapeA = this.m_fixtureA.GetShape(); + var shapeB = this.m_fixtureB.GetShape(); + b2CollideCircles(manifold, shapeA, xfA, shapeB, xfB); + }; + return b2CircleContact; + })(b2Contact); + var b2PolygonContact = (function(_super) { + __extends(b2PolygonContact, _super); + function b2PolygonContact() { + return _super.call(this) || this; + } + b2PolygonContact.Create = function(allocator) { + return new b2PolygonContact(); + }; + b2PolygonContact.Destroy = function(contact, allocator) {}; + b2PolygonContact.prototype.Reset = function(fixtureA, indexA, fixtureB, indexB) { + _super.prototype.Reset.call(this, fixtureA, indexA, fixtureB, indexB); + }; + b2PolygonContact.prototype.Evaluate = function(manifold, xfA, xfB) { + var shapeA = this.m_fixtureA.GetShape(); + var shapeB = this.m_fixtureB.GetShape(); + b2CollidePolygons(manifold, shapeA, xfA, shapeB, xfB); + }; + return b2PolygonContact; + })(b2Contact); + var b2PolygonAndCircleContact = (function(_super) { + __extends(b2PolygonAndCircleContact, _super); + function b2PolygonAndCircleContact() { + return _super.call(this) || this; + } + b2PolygonAndCircleContact.Create = function(allocator) { + return new b2PolygonAndCircleContact(); + }; + b2PolygonAndCircleContact.Destroy = function(contact, allocator) {}; + b2PolygonAndCircleContact.prototype.Reset = function(fixtureA, indexA, fixtureB, indexB) { + _super.prototype.Reset.call(this, fixtureA, indexA, fixtureB, indexB); + }; + b2PolygonAndCircleContact.prototype.Evaluate = function(manifold, xfA, xfB) { + var shapeA = this.m_fixtureA.GetShape(); + var shapeB = this.m_fixtureB.GetShape(); + b2CollidePolygonAndCircle(manifold, shapeA, xfA, shapeB, xfB); + }; + return b2PolygonAndCircleContact; + })(b2Contact); + var b2EdgeAndCircleContact = (function(_super) { + __extends(b2EdgeAndCircleContact, _super); + function b2EdgeAndCircleContact() { + return _super.call(this) || this; + } + b2EdgeAndCircleContact.Create = function(allocator) { + return new b2EdgeAndCircleContact(); + }; + b2EdgeAndCircleContact.Destroy = function(contact, allocator) {}; + b2EdgeAndCircleContact.prototype.Reset = function(fixtureA, indexA, fixtureB, indexB) { + _super.prototype.Reset.call(this, fixtureA, indexA, fixtureB, indexB); + }; + b2EdgeAndCircleContact.prototype.Evaluate = function(manifold, xfA, xfB) { + var shapeA = this.m_fixtureA.GetShape(); + var shapeB = this.m_fixtureB.GetShape(); + b2CollideEdgeAndCircle(manifold, shapeA, xfA, shapeB, xfB); + }; + return b2EdgeAndCircleContact; + })(b2Contact); + var b2EdgeAndPolygonContact = (function(_super) { + __extends(b2EdgeAndPolygonContact, _super); + function b2EdgeAndPolygonContact() { + return _super.call(this) || this; + } + b2EdgeAndPolygonContact.Create = function(allocator) { + return new b2EdgeAndPolygonContact(); + }; + b2EdgeAndPolygonContact.Destroy = function(contact, allocator) {}; + b2EdgeAndPolygonContact.prototype.Reset = function(fixtureA, indexA, fixtureB, indexB) { + _super.prototype.Reset.call(this, fixtureA, indexA, fixtureB, indexB); + }; + b2EdgeAndPolygonContact.prototype.Evaluate = function(manifold, xfA, xfB) { + var shapeA = this.m_fixtureA.GetShape(); + var shapeB = this.m_fixtureB.GetShape(); + b2CollideEdgeAndPolygon(manifold, shapeA, xfA, shapeB, xfB); + }; + return b2EdgeAndPolygonContact; + })(b2Contact); + var b2ChainAndCircleContact = (function(_super) { + __extends(b2ChainAndCircleContact, _super); + function b2ChainAndCircleContact() { + return _super.call(this) || this; + } + b2ChainAndCircleContact.Create = function(allocator) { + return new b2ChainAndCircleContact(); + }; + b2ChainAndCircleContact.Destroy = function(contact, allocator) {}; + b2ChainAndCircleContact.prototype.Reset = function(fixtureA, indexA, fixtureB, indexB) { + _super.prototype.Reset.call(this, fixtureA, indexA, fixtureB, indexB); + }; + b2ChainAndCircleContact.prototype.Evaluate = function(manifold, xfA, xfB) { + var shapeA = this.m_fixtureA.GetShape(); + var shapeB = this.m_fixtureB.GetShape(); + var chain = shapeA; + var edge = b2ChainAndCircleContact.Evaluate_s_edge; + chain.GetChildEdge(edge, this.m_indexA); + b2CollideEdgeAndCircle(manifold, edge, xfA, shapeB, xfB); + }; + b2ChainAndCircleContact.Evaluate_s_edge = new b2EdgeShape(); + return b2ChainAndCircleContact; + })(b2Contact); + var b2ChainAndPolygonContact = (function(_super) { + __extends(b2ChainAndPolygonContact, _super); + function b2ChainAndPolygonContact() { + return _super.call(this) || this; + } + b2ChainAndPolygonContact.Create = function(allocator) { + return new b2ChainAndPolygonContact(); + }; + b2ChainAndPolygonContact.Destroy = function(contact, allocator) {}; + b2ChainAndPolygonContact.prototype.Reset = function(fixtureA, indexA, fixtureB, indexB) { + _super.prototype.Reset.call(this, fixtureA, indexA, fixtureB, indexB); + }; + b2ChainAndPolygonContact.prototype.Evaluate = function(manifold, xfA, xfB) { + var shapeA = this.m_fixtureA.GetShape(); + var shapeB = this.m_fixtureB.GetShape(); + var chain = shapeA; + var edge = b2ChainAndPolygonContact.Evaluate_s_edge; + chain.GetChildEdge(edge, this.m_indexA); + b2CollideEdgeAndPolygon(manifold, edge, xfA, shapeB, xfB); + }; + b2ChainAndPolygonContact.Evaluate_s_edge = new b2EdgeShape(); + return b2ChainAndPolygonContact; + })(b2Contact); + var b2ContactRegister = (function() { + function b2ContactRegister() { + this.createFcn = null; + this.destroyFcn = null; + this.primary = false; + } + return b2ContactRegister; + })(); + var b2ContactFactory = (function() { + function b2ContactFactory(allocator) { + this.m_allocator = null; + this.m_allocator = allocator; + this.InitializeRegisters(); + } + b2ContactFactory.prototype.AddType = function(createFcn, destroyFcn, type1, type2) { + var _this = this; + var pool = b2MakeArray(256, (function(i) { + return createFcn(_this.m_allocator); + })); + function poolCreateFcn(allocator) { + return pool.pop() || createFcn(allocator); + } + function poolDestroyFcn(contact, allocator) { + pool.push(contact); + } + this.m_registers[type1][type2].createFcn = poolCreateFcn; + this.m_registers[type1][type2].destroyFcn = poolDestroyFcn; + this.m_registers[type1][type2].primary = true; + if (type1 !== type2) { + this.m_registers[type2][type1].createFcn = poolCreateFcn; + this.m_registers[type2][type1].destroyFcn = poolDestroyFcn; + this.m_registers[type2][type1].primary = false; + } + }; + b2ContactFactory.prototype.InitializeRegisters = function() { + this.m_registers = []; + for (var i = 0; i < exports.b2ShapeType.e_shapeTypeCount; i++) { + this.m_registers[i] = []; + for (var j = 0; j < exports.b2ShapeType.e_shapeTypeCount; j++) this.m_registers[i][j] = new b2ContactRegister(); + } + this.AddType(b2CircleContact.Create, b2CircleContact.Destroy, exports.b2ShapeType.e_circleShape, exports.b2ShapeType.e_circleShape); + this.AddType(b2PolygonAndCircleContact.Create, b2PolygonAndCircleContact.Destroy, exports.b2ShapeType.e_polygonShape, exports.b2ShapeType.e_circleShape); + this.AddType(b2PolygonContact.Create, b2PolygonContact.Destroy, exports.b2ShapeType.e_polygonShape, exports.b2ShapeType.e_polygonShape); + this.AddType(b2EdgeAndCircleContact.Create, b2EdgeAndCircleContact.Destroy, exports.b2ShapeType.e_edgeShape, exports.b2ShapeType.e_circleShape); + this.AddType(b2EdgeAndPolygonContact.Create, b2EdgeAndPolygonContact.Destroy, exports.b2ShapeType.e_edgeShape, exports.b2ShapeType.e_polygonShape); + this.AddType(b2ChainAndCircleContact.Create, b2ChainAndCircleContact.Destroy, exports.b2ShapeType.e_chainShape, exports.b2ShapeType.e_circleShape); + this.AddType(b2ChainAndPolygonContact.Create, b2ChainAndPolygonContact.Destroy, exports.b2ShapeType.e_chainShape, exports.b2ShapeType.e_polygonShape); + }; + b2ContactFactory.prototype.Create = function(fixtureA, indexA, fixtureB, indexB) { + var type1 = fixtureA.GetType(); + var type2 = fixtureB.GetType(); + var reg = this.m_registers[type1][type2]; + if (reg.createFcn) { + var c = reg.createFcn(this.m_allocator); + reg.primary ? c.Reset(fixtureA, indexA, fixtureB, indexB) : c.Reset(fixtureB, indexB, fixtureA, indexA); + return c; + } + return null; + }; + b2ContactFactory.prototype.Destroy = function(contact) { + var fixtureA = contact.m_fixtureA; + var fixtureB = contact.m_fixtureB; + if (contact.m_manifold.pointCount > 0 && !fixtureA.IsSensor() && !fixtureB.IsSensor()) { + fixtureA.GetBody().SetAwake(true); + fixtureB.GetBody().SetAwake(true); + } + var typeA = fixtureA.GetType(); + var typeB = fixtureB.GetType(); + var reg = this.m_registers[typeA][typeB]; + reg.destroyFcn && reg.destroyFcn(contact, this.m_allocator); + }; + return b2ContactFactory; + })(); + var b2DestructionListener = (function() { + function b2DestructionListener() {} + b2DestructionListener.prototype.SayGoodbyeJoint = function(joint) {}; + b2DestructionListener.prototype.SayGoodbyeFixture = function(fixture) {}; + b2DestructionListener.prototype.SayGoodbyeParticleGroup = function(group) {}; + b2DestructionListener.prototype.SayGoodbyeParticle = function(system, index) {}; + return b2DestructionListener; + })(); + var b2ContactFilter = (function() { + function b2ContactFilter() {} + b2ContactFilter.prototype.ShouldCollide = function(fixtureA, fixtureB) { + var bodyA = fixtureA.GetBody(); + var bodyB = fixtureB.GetBody(); + if (bodyB.GetType() === exports.b2BodyType.b2_staticBody && bodyA.GetType() === exports.b2BodyType.b2_staticBody) return false; + if (!bodyB.ShouldCollideConnected(bodyA)) return false; + var filter1 = fixtureA.GetFilterData(); + var filter2 = fixtureB.GetFilterData(); + if (filter1.groupIndex === filter2.groupIndex && 0 !== filter1.groupIndex) return filter1.groupIndex > 0; + var collide = 0 !== (filter1.maskBits & filter2.categoryBits) && 0 !== (filter1.categoryBits & filter2.maskBits); + return collide; + }; + b2ContactFilter.prototype.ShouldCollideFixtureParticle = function(fixture, system, index) { + return true; + }; + b2ContactFilter.prototype.ShouldCollideParticleParticle = function(system, indexA, indexB) { + return true; + }; + b2ContactFilter.b2_defaultFilter = new b2ContactFilter(); + return b2ContactFilter; + })(); + var b2ContactImpulse = (function() { + function b2ContactImpulse() { + this.normalImpulses = b2MakeNumberArray(b2_maxManifoldPoints); + this.tangentImpulses = b2MakeNumberArray(b2_maxManifoldPoints); + this.count = 0; + } + return b2ContactImpulse; + })(); + var b2ContactListener = (function() { + function b2ContactListener() {} + b2ContactListener.prototype.BeginContact = function(contact) {}; + b2ContactListener.prototype.EndContact = function(contact) {}; + b2ContactListener.prototype.BeginContactFixtureParticle = function(system, contact) {}; + b2ContactListener.prototype.EndContactFixtureParticle = function(system, contact) {}; + b2ContactListener.prototype.BeginContactParticleParticle = function(system, contact) {}; + b2ContactListener.prototype.EndContactParticleParticle = function(system, contact) {}; + b2ContactListener.prototype.PreSolve = function(contact, oldManifold) {}; + b2ContactListener.prototype.PostSolve = function(contact, impulse) {}; + b2ContactListener.b2_defaultListener = new b2ContactListener(); + return b2ContactListener; + })(); + var b2QueryCallback = (function() { + function b2QueryCallback() {} + b2QueryCallback.prototype.ReportFixture = function(fixture) { + return true; + }; + b2QueryCallback.prototype.ReportParticle = function(system, index) { + return false; + }; + b2QueryCallback.prototype.ShouldQueryParticleSystem = function(system) { + return true; + }; + return b2QueryCallback; + })(); + var b2RayCastCallback = (function() { + function b2RayCastCallback() {} + b2RayCastCallback.prototype.ReportFixture = function(fixture, point, normal, fraction) { + return fraction; + }; + b2RayCastCallback.prototype.ReportParticle = function(system, index, point, normal, fraction) { + return 0; + }; + b2RayCastCallback.prototype.ShouldQueryParticleSystem = function(system) { + return true; + }; + return b2RayCastCallback; + })(); + var b2ContactManager = (function() { + function b2ContactManager() { + this.m_broadPhase = new b2BroadPhase(); + this.m_contactList = null; + this.m_contactCount = 0; + this.m_contactFilter = b2ContactFilter.b2_defaultFilter; + this.m_contactListener = b2ContactListener.b2_defaultListener; + this.m_allocator = null; + this.m_contactFactory = new b2ContactFactory(this.m_allocator); + } + b2ContactManager.prototype.AddPair = function(proxyA, proxyB) { + var fixtureA = proxyA.fixture; + var fixtureB = proxyB.fixture; + var indexA = proxyA.childIndex; + var indexB = proxyB.childIndex; + var bodyA = fixtureA.GetBody(); + var bodyB = fixtureB.GetBody(); + if (bodyA === bodyB) return; + var edge = bodyB.GetContactList(); + while (edge) { + if (edge.other === bodyA) { + var fA = edge.contact.GetFixtureA(); + var fB = edge.contact.GetFixtureB(); + var iA = edge.contact.GetChildIndexA(); + var iB = edge.contact.GetChildIndexB(); + if (fA === fixtureA && fB === fixtureB && iA === indexA && iB === indexB) return; + if (fA === fixtureB && fB === fixtureA && iA === indexB && iB === indexA) return; + } + edge = edge.next; + } + if (this.m_contactFilter && !this.m_contactFilter.ShouldCollide(fixtureA, fixtureB)) return; + var c = this.m_contactFactory.Create(fixtureA, indexA, fixtureB, indexB); + if (null === c) return; + fixtureA = c.GetFixtureA(); + fixtureB = c.GetFixtureB(); + indexA = c.GetChildIndexA(); + indexB = c.GetChildIndexB(); + bodyA = fixtureA.m_body; + bodyB = fixtureB.m_body; + c.m_prev = null; + c.m_next = this.m_contactList; + null !== this.m_contactList && (this.m_contactList.m_prev = c); + this.m_contactList = c; + c.m_nodeA.contact = c; + c.m_nodeA.other = bodyB; + c.m_nodeA.prev = null; + c.m_nodeA.next = bodyA.m_contactList; + null !== bodyA.m_contactList && (bodyA.m_contactList.prev = c.m_nodeA); + bodyA.m_contactList = c.m_nodeA; + c.m_nodeB.contact = c; + c.m_nodeB.other = bodyA; + c.m_nodeB.prev = null; + c.m_nodeB.next = bodyB.m_contactList; + null !== bodyB.m_contactList && (bodyB.m_contactList.prev = c.m_nodeB); + bodyB.m_contactList = c.m_nodeB; + if (!fixtureA.IsSensor() && !fixtureB.IsSensor()) { + bodyA.SetAwake(true); + bodyB.SetAwake(true); + } + ++this.m_contactCount; + }; + b2ContactManager.prototype.FindNewContacts = function() { + var _this = this; + this.m_broadPhase.UpdatePairs((function(proxyA, proxyB) { + _this.AddPair(proxyA, proxyB); + })); + }; + b2ContactManager.prototype.Destroy = function(c) { + var fixtureA = c.GetFixtureA(); + var fixtureB = c.GetFixtureB(); + var bodyA = fixtureA.GetBody(); + var bodyB = fixtureB.GetBody(); + this.m_contactListener && c.IsTouching() && this.m_contactListener.EndContact(c); + c.m_prev && (c.m_prev.m_next = c.m_next); + c.m_next && (c.m_next.m_prev = c.m_prev); + c === this.m_contactList && (this.m_contactList = c.m_next); + c.m_nodeA.prev && (c.m_nodeA.prev.next = c.m_nodeA.next); + c.m_nodeA.next && (c.m_nodeA.next.prev = c.m_nodeA.prev); + c.m_nodeA === bodyA.m_contactList && (bodyA.m_contactList = c.m_nodeA.next); + c.m_nodeB.prev && (c.m_nodeB.prev.next = c.m_nodeB.next); + c.m_nodeB.next && (c.m_nodeB.next.prev = c.m_nodeB.prev); + c.m_nodeB === bodyB.m_contactList && (bodyB.m_contactList = c.m_nodeB.next); + this.m_contactFactory.Destroy(c); + --this.m_contactCount; + }; + b2ContactManager.prototype.Collide = function() { + var c = this.m_contactList; + while (c) { + var fixtureA = c.GetFixtureA(); + var fixtureB = c.GetFixtureB(); + var indexA = c.GetChildIndexA(); + var indexB = c.GetChildIndexB(); + var bodyA = fixtureA.GetBody(); + var bodyB = fixtureB.GetBody(); + if (c.m_filterFlag) { + if (this.m_contactFilter && !this.m_contactFilter.ShouldCollide(fixtureA, fixtureB)) { + var cNuke = c; + c = cNuke.m_next; + this.Destroy(cNuke); + continue; + } + c.m_filterFlag = false; + } + var activeA = bodyA.IsAwake() && bodyA.m_type !== exports.b2BodyType.b2_staticBody; + var activeB = bodyB.IsAwake() && bodyB.m_type !== exports.b2BodyType.b2_staticBody; + if (!activeA && !activeB) { + c = c.m_next; + continue; + } + var proxyA = fixtureA.m_proxies[indexA].treeNode; + var proxyB = fixtureB.m_proxies[indexB].treeNode; + var overlap = b2TestOverlapAABB(proxyA.aabb, proxyB.aabb); + if (!overlap) { + var cNuke = c; + c = cNuke.m_next; + this.Destroy(cNuke); + continue; + } + c.Update(this.m_contactListener); + c = c.m_next; + } + }; + return b2ContactManager; + })(); + var b2Profile = (function() { + function b2Profile() { + this.step = 0; + this.collide = 0; + this.solve = 0; + this.solveInit = 0; + this.solveVelocity = 0; + this.solvePosition = 0; + this.broadphase = 0; + this.solveTOI = 0; + } + b2Profile.prototype.Reset = function() { + this.step = 0; + this.collide = 0; + this.solve = 0; + this.solveInit = 0; + this.solveVelocity = 0; + this.solvePosition = 0; + this.broadphase = 0; + this.solveTOI = 0; + return this; + }; + return b2Profile; + })(); + var b2TimeStep = (function() { + function b2TimeStep() { + this.dt = 0; + this.inv_dt = 0; + this.dtRatio = 0; + this.velocityIterations = 0; + this.positionIterations = 0; + this.particleIterations = 0; + this.warmStarting = false; + } + b2TimeStep.prototype.Copy = function(step) { + this.dt = step.dt; + this.inv_dt = step.inv_dt; + this.dtRatio = step.dtRatio; + this.positionIterations = step.positionIterations; + this.velocityIterations = step.velocityIterations; + this.particleIterations = step.particleIterations; + this.warmStarting = step.warmStarting; + return this; + }; + return b2TimeStep; + })(); + var b2Position = (function() { + function b2Position() { + this.c = new b2Vec2(); + this.a = 0; + } + b2Position.MakeArray = function(length) { + return b2MakeArray(length, (function(i) { + return new b2Position(); + })); + }; + return b2Position; + })(); + var b2Velocity = (function() { + function b2Velocity() { + this.v = new b2Vec2(); + this.w = 0; + } + b2Velocity.MakeArray = function(length) { + return b2MakeArray(length, (function(i) { + return new b2Velocity(); + })); + }; + return b2Velocity; + })(); + var b2SolverData = (function() { + function b2SolverData() { + this.step = new b2TimeStep(); + } + return b2SolverData; + })(); + var g_blockSolve = false; + var b2VelocityConstraintPoint = (function() { + function b2VelocityConstraintPoint() { + this.rA = new b2Vec2(); + this.rB = new b2Vec2(); + this.normalImpulse = 0; + this.tangentImpulse = 0; + this.normalMass = 0; + this.tangentMass = 0; + this.velocityBias = 0; + } + b2VelocityConstraintPoint.MakeArray = function(length) { + return b2MakeArray(length, (function(i) { + return new b2VelocityConstraintPoint(); + })); + }; + return b2VelocityConstraintPoint; + })(); + var b2ContactVelocityConstraint = (function() { + function b2ContactVelocityConstraint() { + this.points = b2VelocityConstraintPoint.MakeArray(b2_maxManifoldPoints); + this.normal = new b2Vec2(); + this.tangent = new b2Vec2(); + this.normalMass = new b2Mat22(); + this.K = new b2Mat22(); + this.indexA = 0; + this.indexB = 0; + this.invMassA = 0; + this.invMassB = 0; + this.invIA = 0; + this.invIB = 0; + this.friction = 0; + this.restitution = 0; + this.tangentSpeed = 0; + this.pointCount = 0; + this.contactIndex = 0; + } + b2ContactVelocityConstraint.MakeArray = function(length) { + return b2MakeArray(length, (function(i) { + return new b2ContactVelocityConstraint(); + })); + }; + return b2ContactVelocityConstraint; + })(); + var b2ContactPositionConstraint = (function() { + function b2ContactPositionConstraint() { + this.localPoints = b2Vec2.MakeArray(b2_maxManifoldPoints); + this.localNormal = new b2Vec2(); + this.localPoint = new b2Vec2(); + this.indexA = 0; + this.indexB = 0; + this.invMassA = 0; + this.invMassB = 0; + this.localCenterA = new b2Vec2(); + this.localCenterB = new b2Vec2(); + this.invIA = 0; + this.invIB = 0; + this.type = exports.b2ManifoldType.e_unknown; + this.radiusA = 0; + this.radiusB = 0; + this.pointCount = 0; + } + b2ContactPositionConstraint.MakeArray = function(length) { + return b2MakeArray(length, (function(i) { + return new b2ContactPositionConstraint(); + })); + }; + return b2ContactPositionConstraint; + })(); + var b2ContactSolverDef = (function() { + function b2ContactSolverDef() { + this.step = new b2TimeStep(); + this.count = 0; + this.allocator = null; + } + return b2ContactSolverDef; + })(); + var b2PositionSolverManifold = (function() { + function b2PositionSolverManifold() { + this.normal = new b2Vec2(); + this.point = new b2Vec2(); + this.separation = 0; + } + b2PositionSolverManifold.prototype.Initialize = function(pc, xfA, xfB, index) { + var pointA = b2PositionSolverManifold.Initialize_s_pointA; + var pointB = b2PositionSolverManifold.Initialize_s_pointB; + var planePoint = b2PositionSolverManifold.Initialize_s_planePoint; + var clipPoint = b2PositionSolverManifold.Initialize_s_clipPoint; + switch (pc.type) { + case exports.b2ManifoldType.e_circles: + b2Transform.MulXV(xfA, pc.localPoint, pointA); + b2Transform.MulXV(xfB, pc.localPoints[0], pointB); + b2Vec2.SubVV(pointB, pointA, this.normal).SelfNormalize(); + b2Vec2.MidVV(pointA, pointB, this.point); + this.separation = b2Vec2.DotVV(b2Vec2.SubVV(pointB, pointA, b2Vec2.s_t0), this.normal) - pc.radiusA - pc.radiusB; + break; + + case exports.b2ManifoldType.e_faceA: + b2Rot.MulRV(xfA.q, pc.localNormal, this.normal); + b2Transform.MulXV(xfA, pc.localPoint, planePoint); + b2Transform.MulXV(xfB, pc.localPoints[index], clipPoint); + this.separation = b2Vec2.DotVV(b2Vec2.SubVV(clipPoint, planePoint, b2Vec2.s_t0), this.normal) - pc.radiusA - pc.radiusB; + this.point.Copy(clipPoint); + break; + + case exports.b2ManifoldType.e_faceB: + b2Rot.MulRV(xfB.q, pc.localNormal, this.normal); + b2Transform.MulXV(xfB, pc.localPoint, planePoint); + b2Transform.MulXV(xfA, pc.localPoints[index], clipPoint); + this.separation = b2Vec2.DotVV(b2Vec2.SubVV(clipPoint, planePoint, b2Vec2.s_t0), this.normal) - pc.radiusA - pc.radiusB; + this.point.Copy(clipPoint); + this.normal.SelfNeg(); + } + }; + b2PositionSolverManifold.Initialize_s_pointA = new b2Vec2(); + b2PositionSolverManifold.Initialize_s_pointB = new b2Vec2(); + b2PositionSolverManifold.Initialize_s_planePoint = new b2Vec2(); + b2PositionSolverManifold.Initialize_s_clipPoint = new b2Vec2(); + return b2PositionSolverManifold; + })(); + var b2ContactSolver = (function() { + function b2ContactSolver() { + this.m_step = new b2TimeStep(); + this.m_allocator = null; + this.m_positionConstraints = b2ContactPositionConstraint.MakeArray(1024); + this.m_velocityConstraints = b2ContactVelocityConstraint.MakeArray(1024); + this.m_count = 0; + } + b2ContactSolver.prototype.Initialize = function(def) { + this.m_step.Copy(def.step); + this.m_allocator = def.allocator; + this.m_count = def.count; + if (this.m_positionConstraints.length < this.m_count) { + var new_length = b2Max(2 * this.m_positionConstraints.length, this.m_count); + while (this.m_positionConstraints.length < new_length) this.m_positionConstraints[this.m_positionConstraints.length] = new b2ContactPositionConstraint(); + } + if (this.m_velocityConstraints.length < this.m_count) { + var new_length = b2Max(2 * this.m_velocityConstraints.length, this.m_count); + while (this.m_velocityConstraints.length < new_length) this.m_velocityConstraints[this.m_velocityConstraints.length] = new b2ContactVelocityConstraint(); + } + this.m_positions = def.positions; + this.m_velocities = def.velocities; + this.m_contacts = def.contacts; + for (var i = 0; i < this.m_count; ++i) { + var contact = this.m_contacts[i]; + var fixtureA = contact.m_fixtureA; + var fixtureB = contact.m_fixtureB; + var shapeA = fixtureA.GetShape(); + var shapeB = fixtureB.GetShape(); + var radiusA = shapeA.m_radius; + var radiusB = shapeB.m_radius; + var bodyA = fixtureA.GetBody(); + var bodyB = fixtureB.GetBody(); + var manifold = contact.GetManifold(); + var pointCount = manifold.pointCount; + var vc = this.m_velocityConstraints[i]; + vc.friction = contact.m_friction; + vc.restitution = contact.m_restitution; + vc.tangentSpeed = contact.m_tangentSpeed; + vc.indexA = bodyA.m_islandIndex; + vc.indexB = bodyB.m_islandIndex; + vc.invMassA = bodyA.m_invMass; + vc.invMassB = bodyB.m_invMass; + vc.invIA = bodyA.m_invI; + vc.invIB = bodyB.m_invI; + vc.contactIndex = i; + vc.pointCount = pointCount; + vc.K.SetZero(); + vc.normalMass.SetZero(); + var pc = this.m_positionConstraints[i]; + pc.indexA = bodyA.m_islandIndex; + pc.indexB = bodyB.m_islandIndex; + pc.invMassA = bodyA.m_invMass; + pc.invMassB = bodyB.m_invMass; + pc.localCenterA.Copy(bodyA.m_sweep.localCenter); + pc.localCenterB.Copy(bodyB.m_sweep.localCenter); + pc.invIA = bodyA.m_invI; + pc.invIB = bodyB.m_invI; + pc.localNormal.Copy(manifold.localNormal); + pc.localPoint.Copy(manifold.localPoint); + pc.pointCount = pointCount; + pc.radiusA = radiusA; + pc.radiusB = radiusB; + pc.type = manifold.type; + for (var j = 0; j < pointCount; ++j) { + var cp = manifold.points[j]; + var vcp = vc.points[j]; + if (this.m_step.warmStarting) { + vcp.normalImpulse = this.m_step.dtRatio * cp.normalImpulse; + vcp.tangentImpulse = this.m_step.dtRatio * cp.tangentImpulse; + } else { + vcp.normalImpulse = 0; + vcp.tangentImpulse = 0; + } + vcp.rA.SetZero(); + vcp.rB.SetZero(); + vcp.normalMass = 0; + vcp.tangentMass = 0; + vcp.velocityBias = 0; + pc.localPoints[j].Copy(cp.localPoint); + } + } + return this; + }; + b2ContactSolver.prototype.InitializeVelocityConstraints = function() { + var xfA = b2ContactSolver.InitializeVelocityConstraints_s_xfA; + var xfB = b2ContactSolver.InitializeVelocityConstraints_s_xfB; + var worldManifold = b2ContactSolver.InitializeVelocityConstraints_s_worldManifold; + var k_maxConditionNumber = 1e3; + for (var i = 0; i < this.m_count; ++i) { + var vc = this.m_velocityConstraints[i]; + var pc = this.m_positionConstraints[i]; + var radiusA = pc.radiusA; + var radiusB = pc.radiusB; + var manifold = this.m_contacts[vc.contactIndex].GetManifold(); + var indexA = vc.indexA; + var indexB = vc.indexB; + var mA = vc.invMassA; + var mB = vc.invMassB; + var iA = vc.invIA; + var iB = vc.invIB; + var localCenterA = pc.localCenterA; + var localCenterB = pc.localCenterB; + var cA = this.m_positions[indexA].c; + var aA = this.m_positions[indexA].a; + var vA = this.m_velocities[indexA].v; + var wA = this.m_velocities[indexA].w; + var cB = this.m_positions[indexB].c; + var aB = this.m_positions[indexB].a; + var vB = this.m_velocities[indexB].v; + var wB = this.m_velocities[indexB].w; + xfA.q.SetAngle(aA); + xfB.q.SetAngle(aB); + b2Vec2.SubVV(cA, b2Rot.MulRV(xfA.q, localCenterA, b2Vec2.s_t0), xfA.p); + b2Vec2.SubVV(cB, b2Rot.MulRV(xfB.q, localCenterB, b2Vec2.s_t0), xfB.p); + worldManifold.Initialize(manifold, xfA, radiusA, xfB, radiusB); + vc.normal.Copy(worldManifold.normal); + b2Vec2.CrossVOne(vc.normal, vc.tangent); + var pointCount = vc.pointCount; + for (var j = 0; j < pointCount; ++j) { + var vcp = vc.points[j]; + b2Vec2.SubVV(worldManifold.points[j], cA, vcp.rA); + b2Vec2.SubVV(worldManifold.points[j], cB, vcp.rB); + var rnA = b2Vec2.CrossVV(vcp.rA, vc.normal); + var rnB = b2Vec2.CrossVV(vcp.rB, vc.normal); + var kNormal = mA + mB + iA * rnA * rnA + iB * rnB * rnB; + vcp.normalMass = kNormal > 0 ? 1 / kNormal : 0; + var tangent = vc.tangent; + var rtA = b2Vec2.CrossVV(vcp.rA, tangent); + var rtB = b2Vec2.CrossVV(vcp.rB, tangent); + var kTangent = mA + mB + iA * rtA * rtA + iB * rtB * rtB; + vcp.tangentMass = kTangent > 0 ? 1 / kTangent : 0; + vcp.velocityBias = 0; + var vRel = b2Vec2.DotVV(vc.normal, b2Vec2.SubVV(b2Vec2.AddVCrossSV(vB, wB, vcp.rB, b2Vec2.s_t0), b2Vec2.AddVCrossSV(vA, wA, vcp.rA, b2Vec2.s_t1), b2Vec2.s_t0)); + vRel < -b2_velocityThreshold && (vcp.velocityBias += -vc.restitution * vRel); + } + if (2 === vc.pointCount && g_blockSolve) { + var vcp1 = vc.points[0]; + var vcp2 = vc.points[1]; + var rn1A = b2Vec2.CrossVV(vcp1.rA, vc.normal); + var rn1B = b2Vec2.CrossVV(vcp1.rB, vc.normal); + var rn2A = b2Vec2.CrossVV(vcp2.rA, vc.normal); + var rn2B = b2Vec2.CrossVV(vcp2.rB, vc.normal); + var k11 = mA + mB + iA * rn1A * rn1A + iB * rn1B * rn1B; + var k22 = mA + mB + iA * rn2A * rn2A + iB * rn2B * rn2B; + var k12 = mA + mB + iA * rn1A * rn2A + iB * rn1B * rn2B; + if (k11 * k11 < k_maxConditionNumber * (k11 * k22 - k12 * k12)) { + vc.K.ex.Set(k11, k12); + vc.K.ey.Set(k12, k22); + vc.K.GetInverse(vc.normalMass); + } else vc.pointCount = 1; + } + } + }; + b2ContactSolver.prototype.WarmStart = function() { + var P = b2ContactSolver.WarmStart_s_P; + for (var i = 0; i < this.m_count; ++i) { + var vc = this.m_velocityConstraints[i]; + var indexA = vc.indexA; + var indexB = vc.indexB; + var mA = vc.invMassA; + var iA = vc.invIA; + var mB = vc.invMassB; + var iB = vc.invIB; + var pointCount = vc.pointCount; + var vA = this.m_velocities[indexA].v; + var wA = this.m_velocities[indexA].w; + var vB = this.m_velocities[indexB].v; + var wB = this.m_velocities[indexB].w; + var normal = vc.normal; + var tangent = vc.tangent; + for (var j = 0; j < pointCount; ++j) { + var vcp = vc.points[j]; + b2Vec2.AddVV(b2Vec2.MulSV(vcp.normalImpulse, normal, b2Vec2.s_t0), b2Vec2.MulSV(vcp.tangentImpulse, tangent, b2Vec2.s_t1), P); + wA -= iA * b2Vec2.CrossVV(vcp.rA, P); + vA.SelfMulSub(mA, P); + wB += iB * b2Vec2.CrossVV(vcp.rB, P); + vB.SelfMulAdd(mB, P); + } + this.m_velocities[indexA].w = wA; + this.m_velocities[indexB].w = wB; + } + }; + b2ContactSolver.prototype.SolveVelocityConstraints = function() { + var dv = b2ContactSolver.SolveVelocityConstraints_s_dv; + var dv1 = b2ContactSolver.SolveVelocityConstraints_s_dv1; + var dv2 = b2ContactSolver.SolveVelocityConstraints_s_dv2; + var P = b2ContactSolver.SolveVelocityConstraints_s_P; + var a = b2ContactSolver.SolveVelocityConstraints_s_a; + var b = b2ContactSolver.SolveVelocityConstraints_s_b; + var x = b2ContactSolver.SolveVelocityConstraints_s_x; + var d = b2ContactSolver.SolveVelocityConstraints_s_d; + var P1 = b2ContactSolver.SolveVelocityConstraints_s_P1; + var P2 = b2ContactSolver.SolveVelocityConstraints_s_P2; + var P1P2 = b2ContactSolver.SolveVelocityConstraints_s_P1P2; + for (var i = 0; i < this.m_count; ++i) { + var vc = this.m_velocityConstraints[i]; + var indexA = vc.indexA; + var indexB = vc.indexB; + var mA = vc.invMassA; + var iA = vc.invIA; + var mB = vc.invMassB; + var iB = vc.invIB; + var pointCount = vc.pointCount; + var vA = this.m_velocities[indexA].v; + var wA = this.m_velocities[indexA].w; + var vB = this.m_velocities[indexB].v; + var wB = this.m_velocities[indexB].w; + var normal = vc.normal; + var tangent = vc.tangent; + var friction = vc.friction; + for (var j = 0; j < pointCount; ++j) { + var vcp = vc.points[j]; + b2Vec2.SubVV(b2Vec2.AddVCrossSV(vB, wB, vcp.rB, b2Vec2.s_t0), b2Vec2.AddVCrossSV(vA, wA, vcp.rA, b2Vec2.s_t1), dv); + var vt = b2Vec2.DotVV(dv, tangent) - vc.tangentSpeed; + var lambda = vcp.tangentMass * -vt; + var maxFriction = friction * vcp.normalImpulse; + var newImpulse = b2Clamp(vcp.tangentImpulse + lambda, -maxFriction, maxFriction); + lambda = newImpulse - vcp.tangentImpulse; + vcp.tangentImpulse = newImpulse; + b2Vec2.MulSV(lambda, tangent, P); + vA.SelfMulSub(mA, P); + wA -= iA * b2Vec2.CrossVV(vcp.rA, P); + vB.SelfMulAdd(mB, P); + wB += iB * b2Vec2.CrossVV(vcp.rB, P); + } + if (1 === vc.pointCount || false === g_blockSolve) for (var j = 0; j < pointCount; ++j) { + var vcp = vc.points[j]; + b2Vec2.SubVV(b2Vec2.AddVCrossSV(vB, wB, vcp.rB, b2Vec2.s_t0), b2Vec2.AddVCrossSV(vA, wA, vcp.rA, b2Vec2.s_t1), dv); + var vn = b2Vec2.DotVV(dv, normal); + var lambda = -vcp.normalMass * (vn - vcp.velocityBias); + var newImpulse = b2Max(vcp.normalImpulse + lambda, 0); + lambda = newImpulse - vcp.normalImpulse; + vcp.normalImpulse = newImpulse; + b2Vec2.MulSV(lambda, normal, P); + vA.SelfMulSub(mA, P); + wA -= iA * b2Vec2.CrossVV(vcp.rA, P); + vB.SelfMulAdd(mB, P); + wB += iB * b2Vec2.CrossVV(vcp.rB, P); + } else { + var cp1 = vc.points[0]; + var cp2 = vc.points[1]; + a.Set(cp1.normalImpulse, cp2.normalImpulse); + b2Vec2.SubVV(b2Vec2.AddVCrossSV(vB, wB, cp1.rB, b2Vec2.s_t0), b2Vec2.AddVCrossSV(vA, wA, cp1.rA, b2Vec2.s_t1), dv1); + b2Vec2.SubVV(b2Vec2.AddVCrossSV(vB, wB, cp2.rB, b2Vec2.s_t0), b2Vec2.AddVCrossSV(vA, wA, cp2.rA, b2Vec2.s_t1), dv2); + var vn1 = b2Vec2.DotVV(dv1, normal); + var vn2 = b2Vec2.DotVV(dv2, normal); + b.x = vn1 - cp1.velocityBias; + b.y = vn2 - cp2.velocityBias; + b.SelfSub(b2Mat22.MulMV(vc.K, a, b2Vec2.s_t0)); + for (;;) { + b2Mat22.MulMV(vc.normalMass, b, x).SelfNeg(); + if (x.x >= 0 && x.y >= 0) { + b2Vec2.SubVV(x, a, d); + b2Vec2.MulSV(d.x, normal, P1); + b2Vec2.MulSV(d.y, normal, P2); + b2Vec2.AddVV(P1, P2, P1P2); + vA.SelfMulSub(mA, P1P2); + wA -= iA * (b2Vec2.CrossVV(cp1.rA, P1) + b2Vec2.CrossVV(cp2.rA, P2)); + vB.SelfMulAdd(mB, P1P2); + wB += iB * (b2Vec2.CrossVV(cp1.rB, P1) + b2Vec2.CrossVV(cp2.rB, P2)); + cp1.normalImpulse = x.x; + cp2.normalImpulse = x.y; + break; + } + x.x = -cp1.normalMass * b.x; + x.y = 0; + vn1 = 0; + vn2 = vc.K.ex.y * x.x + b.y; + if (x.x >= 0 && vn2 >= 0) { + b2Vec2.SubVV(x, a, d); + b2Vec2.MulSV(d.x, normal, P1); + b2Vec2.MulSV(d.y, normal, P2); + b2Vec2.AddVV(P1, P2, P1P2); + vA.SelfMulSub(mA, P1P2); + wA -= iA * (b2Vec2.CrossVV(cp1.rA, P1) + b2Vec2.CrossVV(cp2.rA, P2)); + vB.SelfMulAdd(mB, P1P2); + wB += iB * (b2Vec2.CrossVV(cp1.rB, P1) + b2Vec2.CrossVV(cp2.rB, P2)); + cp1.normalImpulse = x.x; + cp2.normalImpulse = x.y; + break; + } + x.x = 0; + x.y = -cp2.normalMass * b.y; + vn1 = vc.K.ey.x * x.y + b.x; + vn2 = 0; + if (x.y >= 0 && vn1 >= 0) { + b2Vec2.SubVV(x, a, d); + b2Vec2.MulSV(d.x, normal, P1); + b2Vec2.MulSV(d.y, normal, P2); + b2Vec2.AddVV(P1, P2, P1P2); + vA.SelfMulSub(mA, P1P2); + wA -= iA * (b2Vec2.CrossVV(cp1.rA, P1) + b2Vec2.CrossVV(cp2.rA, P2)); + vB.SelfMulAdd(mB, P1P2); + wB += iB * (b2Vec2.CrossVV(cp1.rB, P1) + b2Vec2.CrossVV(cp2.rB, P2)); + cp1.normalImpulse = x.x; + cp2.normalImpulse = x.y; + break; + } + x.x = 0; + x.y = 0; + vn1 = b.x; + vn2 = b.y; + if (vn1 >= 0 && vn2 >= 0) { + b2Vec2.SubVV(x, a, d); + b2Vec2.MulSV(d.x, normal, P1); + b2Vec2.MulSV(d.y, normal, P2); + b2Vec2.AddVV(P1, P2, P1P2); + vA.SelfMulSub(mA, P1P2); + wA -= iA * (b2Vec2.CrossVV(cp1.rA, P1) + b2Vec2.CrossVV(cp2.rA, P2)); + vB.SelfMulAdd(mB, P1P2); + wB += iB * (b2Vec2.CrossVV(cp1.rB, P1) + b2Vec2.CrossVV(cp2.rB, P2)); + cp1.normalImpulse = x.x; + cp2.normalImpulse = x.y; + break; + } + break; + } + } + this.m_velocities[indexA].w = wA; + this.m_velocities[indexB].w = wB; + } + }; + b2ContactSolver.prototype.StoreImpulses = function() { + for (var i = 0; i < this.m_count; ++i) { + var vc = this.m_velocityConstraints[i]; + var manifold = this.m_contacts[vc.contactIndex].GetManifold(); + for (var j = 0; j < vc.pointCount; ++j) { + manifold.points[j].normalImpulse = vc.points[j].normalImpulse; + manifold.points[j].tangentImpulse = vc.points[j].tangentImpulse; + } + } + }; + b2ContactSolver.prototype.SolvePositionConstraints = function() { + var xfA = b2ContactSolver.SolvePositionConstraints_s_xfA; + var xfB = b2ContactSolver.SolvePositionConstraints_s_xfB; + var psm = b2ContactSolver.SolvePositionConstraints_s_psm; + var rA = b2ContactSolver.SolvePositionConstraints_s_rA; + var rB = b2ContactSolver.SolvePositionConstraints_s_rB; + var P = b2ContactSolver.SolvePositionConstraints_s_P; + var minSeparation = 0; + for (var i = 0; i < this.m_count; ++i) { + var pc = this.m_positionConstraints[i]; + var indexA = pc.indexA; + var indexB = pc.indexB; + var localCenterA = pc.localCenterA; + var mA = pc.invMassA; + var iA = pc.invIA; + var localCenterB = pc.localCenterB; + var mB = pc.invMassB; + var iB = pc.invIB; + var pointCount = pc.pointCount; + var cA = this.m_positions[indexA].c; + var aA = this.m_positions[indexA].a; + var cB = this.m_positions[indexB].c; + var aB = this.m_positions[indexB].a; + for (var j = 0; j < pointCount; ++j) { + xfA.q.SetAngle(aA); + xfB.q.SetAngle(aB); + b2Vec2.SubVV(cA, b2Rot.MulRV(xfA.q, localCenterA, b2Vec2.s_t0), xfA.p); + b2Vec2.SubVV(cB, b2Rot.MulRV(xfB.q, localCenterB, b2Vec2.s_t0), xfB.p); + psm.Initialize(pc, xfA, xfB, j); + var normal = psm.normal; + var point = psm.point; + var separation = psm.separation; + b2Vec2.SubVV(point, cA, rA); + b2Vec2.SubVV(point, cB, rB); + minSeparation = b2Min(minSeparation, separation); + var C = b2Clamp(b2_baumgarte * (separation + b2_linearSlop), -b2_maxLinearCorrection, 0); + var rnA = b2Vec2.CrossVV(rA, normal); + var rnB = b2Vec2.CrossVV(rB, normal); + var K = mA + mB + iA * rnA * rnA + iB * rnB * rnB; + var impulse = K > 0 ? -C / K : 0; + b2Vec2.MulSV(impulse, normal, P); + cA.SelfMulSub(mA, P); + aA -= iA * b2Vec2.CrossVV(rA, P); + cB.SelfMulAdd(mB, P); + aB += iB * b2Vec2.CrossVV(rB, P); + } + this.m_positions[indexA].a = aA; + this.m_positions[indexB].a = aB; + } + return minSeparation > -3 * b2_linearSlop; + }; + b2ContactSolver.prototype.SolveTOIPositionConstraints = function(toiIndexA, toiIndexB) { + var xfA = b2ContactSolver.SolveTOIPositionConstraints_s_xfA; + var xfB = b2ContactSolver.SolveTOIPositionConstraints_s_xfB; + var psm = b2ContactSolver.SolveTOIPositionConstraints_s_psm; + var rA = b2ContactSolver.SolveTOIPositionConstraints_s_rA; + var rB = b2ContactSolver.SolveTOIPositionConstraints_s_rB; + var P = b2ContactSolver.SolveTOIPositionConstraints_s_P; + var minSeparation = 0; + for (var i = 0; i < this.m_count; ++i) { + var pc = this.m_positionConstraints[i]; + var indexA = pc.indexA; + var indexB = pc.indexB; + var localCenterA = pc.localCenterA; + var localCenterB = pc.localCenterB; + var pointCount = pc.pointCount; + var mA = 0; + var iA = 0; + if (indexA === toiIndexA || indexA === toiIndexB) { + mA = pc.invMassA; + iA = pc.invIA; + } + var mB = 0; + var iB = 0; + if (indexB === toiIndexA || indexB === toiIndexB) { + mB = pc.invMassB; + iB = pc.invIB; + } + var cA = this.m_positions[indexA].c; + var aA = this.m_positions[indexA].a; + var cB = this.m_positions[indexB].c; + var aB = this.m_positions[indexB].a; + for (var j = 0; j < pointCount; ++j) { + xfA.q.SetAngle(aA); + xfB.q.SetAngle(aB); + b2Vec2.SubVV(cA, b2Rot.MulRV(xfA.q, localCenterA, b2Vec2.s_t0), xfA.p); + b2Vec2.SubVV(cB, b2Rot.MulRV(xfB.q, localCenterB, b2Vec2.s_t0), xfB.p); + psm.Initialize(pc, xfA, xfB, j); + var normal = psm.normal; + var point = psm.point; + var separation = psm.separation; + b2Vec2.SubVV(point, cA, rA); + b2Vec2.SubVV(point, cB, rB); + minSeparation = b2Min(minSeparation, separation); + var C = b2Clamp(b2_toiBaumgarte * (separation + b2_linearSlop), -b2_maxLinearCorrection, 0); + var rnA = b2Vec2.CrossVV(rA, normal); + var rnB = b2Vec2.CrossVV(rB, normal); + var K = mA + mB + iA * rnA * rnA + iB * rnB * rnB; + var impulse = K > 0 ? -C / K : 0; + b2Vec2.MulSV(impulse, normal, P); + cA.SelfMulSub(mA, P); + aA -= iA * b2Vec2.CrossVV(rA, P); + cB.SelfMulAdd(mB, P); + aB += iB * b2Vec2.CrossVV(rB, P); + } + this.m_positions[indexA].a = aA; + this.m_positions[indexB].a = aB; + } + return minSeparation >= -1.5 * b2_linearSlop; + }; + b2ContactSolver.InitializeVelocityConstraints_s_xfA = new b2Transform(); + b2ContactSolver.InitializeVelocityConstraints_s_xfB = new b2Transform(); + b2ContactSolver.InitializeVelocityConstraints_s_worldManifold = new b2WorldManifold(); + b2ContactSolver.WarmStart_s_P = new b2Vec2(); + b2ContactSolver.SolveVelocityConstraints_s_dv = new b2Vec2(); + b2ContactSolver.SolveVelocityConstraints_s_dv1 = new b2Vec2(); + b2ContactSolver.SolveVelocityConstraints_s_dv2 = new b2Vec2(); + b2ContactSolver.SolveVelocityConstraints_s_P = new b2Vec2(); + b2ContactSolver.SolveVelocityConstraints_s_a = new b2Vec2(); + b2ContactSolver.SolveVelocityConstraints_s_b = new b2Vec2(); + b2ContactSolver.SolveVelocityConstraints_s_x = new b2Vec2(); + b2ContactSolver.SolveVelocityConstraints_s_d = new b2Vec2(); + b2ContactSolver.SolveVelocityConstraints_s_P1 = new b2Vec2(); + b2ContactSolver.SolveVelocityConstraints_s_P2 = new b2Vec2(); + b2ContactSolver.SolveVelocityConstraints_s_P1P2 = new b2Vec2(); + b2ContactSolver.SolvePositionConstraints_s_xfA = new b2Transform(); + b2ContactSolver.SolvePositionConstraints_s_xfB = new b2Transform(); + b2ContactSolver.SolvePositionConstraints_s_psm = new b2PositionSolverManifold(); + b2ContactSolver.SolvePositionConstraints_s_rA = new b2Vec2(); + b2ContactSolver.SolvePositionConstraints_s_rB = new b2Vec2(); + b2ContactSolver.SolvePositionConstraints_s_P = new b2Vec2(); + b2ContactSolver.SolveTOIPositionConstraints_s_xfA = new b2Transform(); + b2ContactSolver.SolveTOIPositionConstraints_s_xfB = new b2Transform(); + b2ContactSolver.SolveTOIPositionConstraints_s_psm = new b2PositionSolverManifold(); + b2ContactSolver.SolveTOIPositionConstraints_s_rA = new b2Vec2(); + b2ContactSolver.SolveTOIPositionConstraints_s_rB = new b2Vec2(); + b2ContactSolver.SolveTOIPositionConstraints_s_P = new b2Vec2(); + return b2ContactSolver; + })(); + var b2Island = (function() { + function b2Island() { + this.m_allocator = null; + this.m_bodies = []; + this.m_contacts = []; + this.m_joints = []; + this.m_positions = b2Position.MakeArray(1024); + this.m_velocities = b2Velocity.MakeArray(1024); + this.m_bodyCount = 0; + this.m_jointCount = 0; + this.m_contactCount = 0; + this.m_bodyCapacity = 0; + this.m_contactCapacity = 0; + this.m_jointCapacity = 0; + } + b2Island.prototype.Initialize = function(bodyCapacity, contactCapacity, jointCapacity, allocator, listener) { + this.m_bodyCapacity = bodyCapacity; + this.m_contactCapacity = contactCapacity; + this.m_jointCapacity = jointCapacity; + this.m_bodyCount = 0; + this.m_contactCount = 0; + this.m_jointCount = 0; + this.m_allocator = allocator; + this.m_listener = listener; + if (this.m_positions.length < bodyCapacity) { + var new_length = b2Max(2 * this.m_positions.length, bodyCapacity); + while (this.m_positions.length < new_length) this.m_positions[this.m_positions.length] = new b2Position(); + } + if (this.m_velocities.length < bodyCapacity) { + var new_length = b2Max(2 * this.m_velocities.length, bodyCapacity); + while (this.m_velocities.length < new_length) this.m_velocities[this.m_velocities.length] = new b2Velocity(); + } + }; + b2Island.prototype.Clear = function() { + this.m_bodyCount = 0; + this.m_contactCount = 0; + this.m_jointCount = 0; + }; + b2Island.prototype.AddBody = function(body) { + body.m_islandIndex = this.m_bodyCount; + this.m_bodies[this.m_bodyCount++] = body; + }; + b2Island.prototype.AddContact = function(contact) { + this.m_contacts[this.m_contactCount++] = contact; + }; + b2Island.prototype.AddJoint = function(joint) { + this.m_joints[this.m_jointCount++] = joint; + }; + b2Island.prototype.Solve = function(profile, step, gravity, allowSleep) { + var timer = b2Island.s_timer.Reset(); + var h = step.dt; + for (var i = 0; i < this.m_bodyCount; ++i) { + var b = this.m_bodies[i]; + this.m_positions[i].c.Copy(b.m_sweep.c); + var a = b.m_sweep.a; + var v = this.m_velocities[i].v.Copy(b.m_linearVelocity); + var w = b.m_angularVelocity; + b.m_sweep.c0.Copy(b.m_sweep.c); + b.m_sweep.a0 = b.m_sweep.a; + if (b.m_type === exports.b2BodyType.b2_dynamicBody) { + v.x += h * (b.m_gravityScale * gravity.x + b.m_invMass * b.m_force.x); + v.y += h * (b.m_gravityScale * gravity.y + b.m_invMass * b.m_force.y); + w += h * b.m_invI * b.m_torque; + v.SelfMul(1 / (1 + h * b.m_linearDamping)); + w *= 1 / (1 + h * b.m_angularDamping); + } + this.m_positions[i].a = a; + this.m_velocities[i].w = w; + } + timer.Reset(); + var solverData = b2Island.s_solverData; + solverData.step.Copy(step); + solverData.positions = this.m_positions; + solverData.velocities = this.m_velocities; + var contactSolverDef = b2Island.s_contactSolverDef; + contactSolverDef.step.Copy(step); + contactSolverDef.contacts = this.m_contacts; + contactSolverDef.count = this.m_contactCount; + contactSolverDef.positions = this.m_positions; + contactSolverDef.velocities = this.m_velocities; + contactSolverDef.allocator = this.m_allocator; + var contactSolver = b2Island.s_contactSolver.Initialize(contactSolverDef); + contactSolver.InitializeVelocityConstraints(); + step.warmStarting && contactSolver.WarmStart(); + for (var i = 0; i < this.m_jointCount; ++i) this.m_joints[i].InitVelocityConstraints(solverData); + profile.solveInit = timer.GetMilliseconds(); + timer.Reset(); + for (var i = 0; i < step.velocityIterations; ++i) { + for (var j = 0; j < this.m_jointCount; ++j) this.m_joints[j].SolveVelocityConstraints(solverData); + contactSolver.SolveVelocityConstraints(); + } + contactSolver.StoreImpulses(); + profile.solveVelocity = timer.GetMilliseconds(); + for (var i = 0; i < this.m_bodyCount; ++i) { + var c = this.m_positions[i].c; + var a = this.m_positions[i].a; + var v = this.m_velocities[i].v; + var w = this.m_velocities[i].w; + var translation = b2Vec2.MulSV(h, v, b2Island.s_translation); + if (b2Vec2.DotVV(translation, translation) > b2_maxTranslationSquared) { + var ratio = b2_maxTranslation / translation.Length(); + v.SelfMul(ratio); + } + var rotation = h * w; + if (rotation * rotation > b2_maxRotationSquared) { + var ratio = b2_maxRotation / b2Abs(rotation); + w *= ratio; + } + c.x += h * v.x; + c.y += h * v.y; + a += h * w; + this.m_positions[i].a = a; + this.m_velocities[i].w = w; + } + timer.Reset(); + var positionSolved = false; + for (var i = 0; i < step.positionIterations; ++i) { + var contactsOkay = contactSolver.SolvePositionConstraints(); + var jointsOkay = true; + for (var j = 0; j < this.m_jointCount; ++j) { + var jointOkay = this.m_joints[j].SolvePositionConstraints(solverData); + jointsOkay = jointsOkay && jointOkay; + } + if (contactsOkay && jointsOkay) { + positionSolved = true; + break; + } + } + for (var i = 0; i < this.m_bodyCount; ++i) { + var body = this.m_bodies[i]; + body.m_sweep.c.Copy(this.m_positions[i].c); + body.m_sweep.a = this.m_positions[i].a; + body.m_linearVelocity.Copy(this.m_velocities[i].v); + body.m_angularVelocity = this.m_velocities[i].w; + body.SynchronizeTransform(); + } + profile.solvePosition = timer.GetMilliseconds(); + this.Report(contactSolver.m_velocityConstraints); + if (allowSleep) { + var minSleepTime = b2_maxFloat; + var linTolSqr = b2_linearSleepTolerance * b2_linearSleepTolerance; + var angTolSqr = b2_angularSleepTolerance * b2_angularSleepTolerance; + for (var i = 0; i < this.m_bodyCount; ++i) { + var b = this.m_bodies[i]; + if (b.GetType() === exports.b2BodyType.b2_staticBody) continue; + if (!b.m_autoSleepFlag || b.m_angularVelocity * b.m_angularVelocity > angTolSqr || b2Vec2.DotVV(b.m_linearVelocity, b.m_linearVelocity) > linTolSqr) { + b.m_sleepTime = 0; + minSleepTime = 0; + } else { + b.m_sleepTime += h; + minSleepTime = b2Min(minSleepTime, b.m_sleepTime); + } + } + if (minSleepTime >= b2_timeToSleep && positionSolved) for (var i = 0; i < this.m_bodyCount; ++i) { + var b = this.m_bodies[i]; + b.SetAwake(false); + } + } + }; + b2Island.prototype.SolveTOI = function(subStep, toiIndexA, toiIndexB) { + for (var i = 0; i < this.m_bodyCount; ++i) { + var b = this.m_bodies[i]; + this.m_positions[i].c.Copy(b.m_sweep.c); + this.m_positions[i].a = b.m_sweep.a; + this.m_velocities[i].v.Copy(b.m_linearVelocity); + this.m_velocities[i].w = b.m_angularVelocity; + } + var contactSolverDef = b2Island.s_contactSolverDef; + contactSolverDef.contacts = this.m_contacts; + contactSolverDef.count = this.m_contactCount; + contactSolverDef.allocator = this.m_allocator; + contactSolverDef.step.Copy(subStep); + contactSolverDef.positions = this.m_positions; + contactSolverDef.velocities = this.m_velocities; + var contactSolver = b2Island.s_contactSolver.Initialize(contactSolverDef); + for (var i = 0; i < subStep.positionIterations; ++i) { + var contactsOkay = contactSolver.SolveTOIPositionConstraints(toiIndexA, toiIndexB); + if (contactsOkay) break; + } + this.m_bodies[toiIndexA].m_sweep.c0.Copy(this.m_positions[toiIndexA].c); + this.m_bodies[toiIndexA].m_sweep.a0 = this.m_positions[toiIndexA].a; + this.m_bodies[toiIndexB].m_sweep.c0.Copy(this.m_positions[toiIndexB].c); + this.m_bodies[toiIndexB].m_sweep.a0 = this.m_positions[toiIndexB].a; + contactSolver.InitializeVelocityConstraints(); + for (var i = 0; i < subStep.velocityIterations; ++i) contactSolver.SolveVelocityConstraints(); + var h = subStep.dt; + for (var i = 0; i < this.m_bodyCount; ++i) { + var c = this.m_positions[i].c; + var a = this.m_positions[i].a; + var v = this.m_velocities[i].v; + var w = this.m_velocities[i].w; + var translation = b2Vec2.MulSV(h, v, b2Island.s_translation); + if (b2Vec2.DotVV(translation, translation) > b2_maxTranslationSquared) { + var ratio = b2_maxTranslation / translation.Length(); + v.SelfMul(ratio); + } + var rotation = h * w; + if (rotation * rotation > b2_maxRotationSquared) { + var ratio = b2_maxRotation / b2Abs(rotation); + w *= ratio; + } + c.SelfMulAdd(h, v); + a += h * w; + this.m_positions[i].a = a; + this.m_velocities[i].w = w; + var body = this.m_bodies[i]; + body.m_sweep.c.Copy(c); + body.m_sweep.a = a; + body.m_linearVelocity.Copy(v); + body.m_angularVelocity = w; + body.SynchronizeTransform(); + } + this.Report(contactSolver.m_velocityConstraints); + }; + b2Island.prototype.Report = function(constraints) { + if (null === this.m_listener) return; + for (var i = 0; i < this.m_contactCount; ++i) { + var c = this.m_contacts[i]; + if (!c) continue; + var vc = constraints[i]; + var impulse = b2Island.s_impulse; + impulse.count = vc.pointCount; + for (var j = 0; j < vc.pointCount; ++j) { + impulse.normalImpulses[j] = vc.points[j].normalImpulse; + impulse.tangentImpulses[j] = vc.points[j].tangentImpulse; + } + this.m_listener.PostSolve(c, impulse); + } + }; + b2Island.s_timer = new b2Timer(); + b2Island.s_solverData = new b2SolverData(); + b2Island.s_contactSolverDef = new b2ContactSolverDef(); + b2Island.s_contactSolver = new b2ContactSolver(); + b2Island.s_translation = new b2Vec2(); + b2Island.s_impulse = new b2ContactImpulse(); + return b2Island; + })(); + (function(b2ParticleFlag) { + b2ParticleFlag[b2ParticleFlag["b2_waterParticle"] = 0] = "b2_waterParticle"; + b2ParticleFlag[b2ParticleFlag["b2_zombieParticle"] = 2] = "b2_zombieParticle"; + b2ParticleFlag[b2ParticleFlag["b2_wallParticle"] = 4] = "b2_wallParticle"; + b2ParticleFlag[b2ParticleFlag["b2_springParticle"] = 8] = "b2_springParticle"; + b2ParticleFlag[b2ParticleFlag["b2_elasticParticle"] = 16] = "b2_elasticParticle"; + b2ParticleFlag[b2ParticleFlag["b2_viscousParticle"] = 32] = "b2_viscousParticle"; + b2ParticleFlag[b2ParticleFlag["b2_powderParticle"] = 64] = "b2_powderParticle"; + b2ParticleFlag[b2ParticleFlag["b2_tensileParticle"] = 128] = "b2_tensileParticle"; + b2ParticleFlag[b2ParticleFlag["b2_colorMixingParticle"] = 256] = "b2_colorMixingParticle"; + b2ParticleFlag[b2ParticleFlag["b2_destructionListenerParticle"] = 512] = "b2_destructionListenerParticle"; + b2ParticleFlag[b2ParticleFlag["b2_barrierParticle"] = 1024] = "b2_barrierParticle"; + b2ParticleFlag[b2ParticleFlag["b2_staticPressureParticle"] = 2048] = "b2_staticPressureParticle"; + b2ParticleFlag[b2ParticleFlag["b2_reactiveParticle"] = 4096] = "b2_reactiveParticle"; + b2ParticleFlag[b2ParticleFlag["b2_repulsiveParticle"] = 8192] = "b2_repulsiveParticle"; + b2ParticleFlag[b2ParticleFlag["b2_fixtureContactListenerParticle"] = 16384] = "b2_fixtureContactListenerParticle"; + b2ParticleFlag[b2ParticleFlag["b2_particleContactListenerParticle"] = 32768] = "b2_particleContactListenerParticle"; + b2ParticleFlag[b2ParticleFlag["b2_fixtureContactFilterParticle"] = 65536] = "b2_fixtureContactFilterParticle"; + b2ParticleFlag[b2ParticleFlag["b2_particleContactFilterParticle"] = 131072] = "b2_particleContactFilterParticle"; + })(exports.b2ParticleFlag || (exports.b2ParticleFlag = {})); + var b2ParticleDef = (function() { + function b2ParticleDef() { + this.flags = 0; + this.position = new b2Vec2(); + this.velocity = new b2Vec2(); + this.color = new b2Color(0, 0, 0, 0); + this.lifetime = 0; + this.userData = null; + this.group = null; + } + return b2ParticleDef; + })(); + function b2CalculateParticleIterations(gravity, radius, timeStep) { + var B2_MAX_RECOMMENDED_PARTICLE_ITERATIONS = 8; + var B2_RADIUS_THRESHOLD = .01; + var iterations = Math.ceil(Math.sqrt(gravity / (B2_RADIUS_THRESHOLD * radius)) * timeStep); + return b2Clamp(iterations, 1, B2_MAX_RECOMMENDED_PARTICLE_ITERATIONS); + } + var b2ParticleHandle = (function() { + function b2ParticleHandle() { + this.m_index = b2_invalidParticleIndex; + } + b2ParticleHandle.prototype.GetIndex = function() { + return this.m_index; + }; + b2ParticleHandle.prototype.SetIndex = function(index) { + this.m_index = index; + }; + return b2ParticleHandle; + })(); + (function(b2ParticleGroupFlag) { + b2ParticleGroupFlag[b2ParticleGroupFlag["b2_solidParticleGroup"] = 1] = "b2_solidParticleGroup"; + b2ParticleGroupFlag[b2ParticleGroupFlag["b2_rigidParticleGroup"] = 2] = "b2_rigidParticleGroup"; + b2ParticleGroupFlag[b2ParticleGroupFlag["b2_particleGroupCanBeEmpty"] = 4] = "b2_particleGroupCanBeEmpty"; + b2ParticleGroupFlag[b2ParticleGroupFlag["b2_particleGroupWillBeDestroyed"] = 8] = "b2_particleGroupWillBeDestroyed"; + b2ParticleGroupFlag[b2ParticleGroupFlag["b2_particleGroupNeedsUpdateDepth"] = 16] = "b2_particleGroupNeedsUpdateDepth"; + b2ParticleGroupFlag[b2ParticleGroupFlag["b2_particleGroupInternalMask"] = 24] = "b2_particleGroupInternalMask"; + })(exports.b2ParticleGroupFlag || (exports.b2ParticleGroupFlag = {})); + var b2ParticleGroupDef = (function() { + function b2ParticleGroupDef() { + this.flags = 0; + this.groupFlags = 0; + this.position = new b2Vec2(); + this.angle = 0; + this.linearVelocity = new b2Vec2(); + this.angularVelocity = 0; + this.color = new b2Color(); + this.strength = 1; + this.shapeCount = 0; + this.stride = 0; + this.particleCount = 0; + this.lifetime = 0; + this.userData = null; + this.group = null; + } + return b2ParticleGroupDef; + })(); + var b2ParticleGroup = (function() { + function b2ParticleGroup(system) { + this.m_firstIndex = 0; + this.m_lastIndex = 0; + this.m_groupFlags = 0; + this.m_strength = 1; + this.m_prev = null; + this.m_next = null; + this.m_timestamp = -1; + this.m_mass = 0; + this.m_inertia = 0; + this.m_center = new b2Vec2(); + this.m_linearVelocity = new b2Vec2(); + this.m_angularVelocity = 0; + this.m_transform = new b2Transform(); + this.m_userData = null; + this.m_system = system; + } + b2ParticleGroup.prototype.GetNext = function() { + return this.m_next; + }; + b2ParticleGroup.prototype.GetParticleSystem = function() { + return this.m_system; + }; + b2ParticleGroup.prototype.GetParticleCount = function() { + return this.m_lastIndex - this.m_firstIndex; + }; + b2ParticleGroup.prototype.GetBufferIndex = function() { + return this.m_firstIndex; + }; + b2ParticleGroup.prototype.ContainsParticle = function(index) { + return this.m_firstIndex <= index && index < this.m_lastIndex; + }; + b2ParticleGroup.prototype.GetAllParticleFlags = function() { + if (!this.m_system.m_flagsBuffer.data) throw new Error(); + var flags = 0; + for (var i = this.m_firstIndex; i < this.m_lastIndex; i++) flags |= this.m_system.m_flagsBuffer.data[i]; + return flags; + }; + b2ParticleGroup.prototype.GetGroupFlags = function() { + return this.m_groupFlags; + }; + b2ParticleGroup.prototype.SetGroupFlags = function(flags) { + flags |= this.m_groupFlags & exports.b2ParticleGroupFlag.b2_particleGroupInternalMask; + this.m_system.SetGroupFlags(this, flags); + }; + b2ParticleGroup.prototype.GetMass = function() { + this.UpdateStatistics(); + return this.m_mass; + }; + b2ParticleGroup.prototype.GetInertia = function() { + this.UpdateStatistics(); + return this.m_inertia; + }; + b2ParticleGroup.prototype.GetCenter = function() { + this.UpdateStatistics(); + return this.m_center; + }; + b2ParticleGroup.prototype.GetLinearVelocity = function() { + this.UpdateStatistics(); + return this.m_linearVelocity; + }; + b2ParticleGroup.prototype.GetAngularVelocity = function() { + this.UpdateStatistics(); + return this.m_angularVelocity; + }; + b2ParticleGroup.prototype.GetTransform = function() { + return this.m_transform; + }; + b2ParticleGroup.prototype.GetPosition = function() { + return this.m_transform.p; + }; + b2ParticleGroup.prototype.GetAngle = function() { + return this.m_transform.q.GetAngle(); + }; + b2ParticleGroup.prototype.GetLinearVelocityFromWorldPoint = function(worldPoint, out) { + var s_t0 = b2ParticleGroup.GetLinearVelocityFromWorldPoint_s_t0; + this.UpdateStatistics(); + return b2Vec2.AddVCrossSV(this.m_linearVelocity, this.m_angularVelocity, b2Vec2.SubVV(worldPoint, this.m_center, s_t0), out); + }; + b2ParticleGroup.prototype.GetUserData = function() { + return this.m_userData; + }; + b2ParticleGroup.prototype.SetUserData = function(data) { + this.m_userData = data; + }; + b2ParticleGroup.prototype.ApplyForce = function(force) { + this.m_system.ApplyForce(this.m_firstIndex, this.m_lastIndex, force); + }; + b2ParticleGroup.prototype.ApplyLinearImpulse = function(impulse) { + this.m_system.ApplyLinearImpulse(this.m_firstIndex, this.m_lastIndex, impulse); + }; + b2ParticleGroup.prototype.DestroyParticles = function(callDestructionListener) { + if (this.m_system.m_world.IsLocked()) throw new Error(); + for (var i = this.m_firstIndex; i < this.m_lastIndex; i++) this.m_system.DestroyParticle(i, callDestructionListener); + }; + b2ParticleGroup.prototype.UpdateStatistics = function() { + if (!this.m_system.m_positionBuffer.data) throw new Error(); + if (!this.m_system.m_velocityBuffer.data) throw new Error(); + var p = new b2Vec2(); + var v = new b2Vec2(); + if (this.m_timestamp !== this.m_system.m_timestamp) { + var m = this.m_system.GetParticleMass(); + this.m_mass = m * (this.m_lastIndex - this.m_firstIndex); + this.m_center.SetZero(); + this.m_linearVelocity.SetZero(); + for (var i = this.m_firstIndex; i < this.m_lastIndex; i++) { + this.m_center.SelfMulAdd(m, this.m_system.m_positionBuffer.data[i]); + this.m_linearVelocity.SelfMulAdd(m, this.m_system.m_velocityBuffer.data[i]); + } + if (this.m_mass > 0) { + var inv_mass = 1 / this.m_mass; + this.m_center.SelfMul(inv_mass); + this.m_linearVelocity.SelfMul(inv_mass); + } + this.m_inertia = 0; + this.m_angularVelocity = 0; + for (var i = this.m_firstIndex; i < this.m_lastIndex; i++) { + b2Vec2.SubVV(this.m_system.m_positionBuffer.data[i], this.m_center, p); + b2Vec2.SubVV(this.m_system.m_velocityBuffer.data[i], this.m_linearVelocity, v); + this.m_inertia += m * b2Vec2.DotVV(p, p); + this.m_angularVelocity += m * b2Vec2.CrossVV(p, v); + } + this.m_inertia > 0 && (this.m_angularVelocity *= 1 / this.m_inertia); + this.m_timestamp = this.m_system.m_timestamp; + } + }; + b2ParticleGroup.GetLinearVelocityFromWorldPoint_s_t0 = new b2Vec2(); + return b2ParticleGroup; + })(); + var b2StackQueue = (function() { + function b2StackQueue(capacity) { + this.m_front = 0; + this.m_back = 0; + this.m_capacity = 0; + this.m_buffer = b2MakeArray(capacity, (function(index) { + return null; + })); + this.m_capacity = capacity; + } + b2StackQueue.prototype.Push = function(item) { + if (this.m_back >= this.m_capacity) { + for (var i = this.m_front; i < this.m_back; i++) this.m_buffer[i - this.m_front] = this.m_buffer[i]; + this.m_back -= this.m_front; + this.m_front = 0; + if (this.m_back >= this.m_capacity) if (this.m_capacity > 0) { + this.m_buffer.concat(b2MakeArray(this.m_capacity, (function(index) { + return null; + }))); + this.m_capacity *= 2; + } else { + this.m_buffer.concat(b2MakeArray(1, (function(index) { + return null; + }))); + this.m_capacity = 1; + } + } + this.m_buffer[this.m_back] = item; + this.m_back++; + }; + b2StackQueue.prototype.Pop = function() { + this.m_buffer[this.m_front] = null; + this.m_front++; + }; + b2StackQueue.prototype.Empty = function() { + return this.m_front === this.m_back; + }; + b2StackQueue.prototype.Front = function() { + var item = this.m_buffer[this.m_front]; + if (!item) throw new Error(); + return item; + }; + return b2StackQueue; + })(); + var b2VoronoiDiagram = (function() { + function b2VoronoiDiagram(generatorCapacity) { + this.m_generatorCapacity = 0; + this.m_generatorCount = 0; + this.m_countX = 0; + this.m_countY = 0; + this.m_diagram = []; + this.m_generatorBuffer = b2MakeArray(generatorCapacity, (function(index) { + return new b2VoronoiDiagram.Generator(); + })); + this.m_generatorCapacity = generatorCapacity; + } + b2VoronoiDiagram.prototype.AddGenerator = function(center, tag, necessary) { + var g = this.m_generatorBuffer[this.m_generatorCount++]; + g.center.Copy(center); + g.tag = tag; + g.necessary = necessary; + }; + b2VoronoiDiagram.prototype.Generate = function(radius, margin) { + var inverseRadius = 1 / radius; + var lower = new b2Vec2(+b2_maxFloat, +b2_maxFloat); + var upper = new b2Vec2(-b2_maxFloat, -b2_maxFloat); + var necessary_count = 0; + for (var k = 0; k < this.m_generatorCount; k++) { + var g = this.m_generatorBuffer[k]; + if (g.necessary) { + b2Vec2.MinV(lower, g.center, lower); + b2Vec2.MaxV(upper, g.center, upper); + ++necessary_count; + } + } + if (0 === necessary_count) { + this.m_countX = 0; + this.m_countY = 0; + return; + } + lower.x -= margin; + lower.y -= margin; + upper.x += margin; + upper.y += margin; + this.m_countX = 1 + Math.floor(inverseRadius * (upper.x - lower.x)); + this.m_countY = 1 + Math.floor(inverseRadius * (upper.y - lower.y)); + this.m_diagram = []; + var queue = new b2StackQueue(4 * this.m_countX * this.m_countY); + for (var k = 0; k < this.m_generatorCount; k++) { + var g = this.m_generatorBuffer[k]; + g.center.SelfSub(lower).SelfMul(inverseRadius); + var x = Math.floor(g.center.x); + var y = Math.floor(g.center.y); + x >= 0 && y >= 0 && x < this.m_countX && y < this.m_countY && queue.Push(new b2VoronoiDiagram.Task(x, y, x + y * this.m_countX, g)); + } + while (!queue.Empty()) { + var task = queue.Front(); + var x = task.m_x; + var y = task.m_y; + var i = task.m_i; + var g = task.m_generator; + queue.Pop(); + if (!this.m_diagram[i]) { + this.m_diagram[i] = g; + x > 0 && queue.Push(new b2VoronoiDiagram.Task(x - 1, y, i - 1, g)); + y > 0 && queue.Push(new b2VoronoiDiagram.Task(x, y - 1, i - this.m_countX, g)); + x < this.m_countX - 1 && queue.Push(new b2VoronoiDiagram.Task(x + 1, y, i + 1, g)); + y < this.m_countY - 1 && queue.Push(new b2VoronoiDiagram.Task(x, y + 1, i + this.m_countX, g)); + } + } + for (var y = 0; y < this.m_countY; y++) for (var x = 0; x < this.m_countX - 1; x++) { + var i = x + y * this.m_countX; + var a = this.m_diagram[i]; + var b = this.m_diagram[i + 1]; + if (a !== b) { + queue.Push(new b2VoronoiDiagram.Task(x, y, i, b)); + queue.Push(new b2VoronoiDiagram.Task(x + 1, y, i + 1, a)); + } + } + for (var y = 0; y < this.m_countY - 1; y++) for (var x = 0; x < this.m_countX; x++) { + var i = x + y * this.m_countX; + var a = this.m_diagram[i]; + var b = this.m_diagram[i + this.m_countX]; + if (a !== b) { + queue.Push(new b2VoronoiDiagram.Task(x, y, i, b)); + queue.Push(new b2VoronoiDiagram.Task(x, y + 1, i + this.m_countX, a)); + } + } + while (!queue.Empty()) { + var task = queue.Front(); + var x = task.m_x; + var y = task.m_y; + var i = task.m_i; + var k = task.m_generator; + queue.Pop(); + var a = this.m_diagram[i]; + var b = k; + if (a !== b) { + var ax = a.center.x - x; + var ay = a.center.y - y; + var bx = b.center.x - x; + var by = b.center.y - y; + var a2 = ax * ax + ay * ay; + var b2 = bx * bx + by * by; + if (a2 > b2) { + this.m_diagram[i] = b; + x > 0 && queue.Push(new b2VoronoiDiagram.Task(x - 1, y, i - 1, b)); + y > 0 && queue.Push(new b2VoronoiDiagram.Task(x, y - 1, i - this.m_countX, b)); + x < this.m_countX - 1 && queue.Push(new b2VoronoiDiagram.Task(x + 1, y, i + 1, b)); + y < this.m_countY - 1 && queue.Push(new b2VoronoiDiagram.Task(x, y + 1, i + this.m_countX, b)); + } + } + } + }; + b2VoronoiDiagram.prototype.GetNodes = function(callback) { + for (var y = 0; y < this.m_countY - 1; y++) for (var x = 0; x < this.m_countX - 1; x++) { + var i = x + y * this.m_countX; + var a = this.m_diagram[i]; + var b = this.m_diagram[i + 1]; + var c = this.m_diagram[i + this.m_countX]; + var d = this.m_diagram[i + 1 + this.m_countX]; + if (b !== c) { + a !== b && a !== c && (a.necessary || b.necessary || c.necessary) && callback(a.tag, b.tag, c.tag); + d !== b && d !== c && (a.necessary || b.necessary || c.necessary) && callback(b.tag, d.tag, c.tag); + } + } + }; + return b2VoronoiDiagram; + })(); + (function(b2VoronoiDiagram) { + var Generator = (function() { + function Generator() { + this.center = new b2Vec2(); + this.tag = 0; + this.necessary = false; + } + return Generator; + })(); + b2VoronoiDiagram.Generator = Generator; + var Task = (function() { + function Task(x, y, i, g) { + this.m_x = x; + this.m_y = y; + this.m_i = i; + this.m_generator = g; + } + return Task; + })(); + b2VoronoiDiagram.Task = Task; + })(b2VoronoiDiagram || (b2VoronoiDiagram = {})); + function std_iter_swap(array, a, b) { + var tmp = array[a]; + array[a] = array[b]; + array[b] = tmp; + } + function default_compare(a, b) { + return a < b; + } + function std_sort(array, first, len, cmp) { + void 0 === first && (first = 0); + void 0 === len && (len = array.length - first); + void 0 === cmp && (cmp = default_compare); + var left = first; + var stack = []; + var pos = 0; + for (;;) { + for (;left + 1 < len; len++) { + var pivot = array[left + Math.floor(Math.random() * (len - left))]; + stack[pos++] = len; + for (var right = left - 1; ;) { + while (cmp(array[++right], pivot)) ; + while (cmp(pivot, array[--len])) ; + if (right >= len) break; + std_iter_swap(array, right, len); + } + } + if (0 === pos) break; + left = len; + len = stack[--pos]; + } + return array; + } + function std_stable_sort(array, first, len, cmp) { + void 0 === first && (first = 0); + void 0 === len && (len = array.length - first); + void 0 === cmp && (cmp = default_compare); + return std_sort(array, first, len, cmp); + } + function std_remove_if(array, predicate, length) { + void 0 === length && (length = array.length); + var l = 0; + for (var c = 0; c < length; ++c) { + if (predicate(array[c])) continue; + if (c === l) { + ++l; + continue; + } + std_iter_swap(array, l++, c); + } + return l; + } + function std_lower_bound(array, first, last, val, cmp) { + void 0 === cmp && (cmp = default_compare); + var count = last - first; + while (count > 0) { + var step = Math.floor(count / 2); + var it = first + step; + if (cmp(array[it], val)) { + first = ++it; + count -= step + 1; + } else count = step; + } + return first; + } + function std_upper_bound(array, first, last, val, cmp) { + void 0 === cmp && (cmp = default_compare); + var count = last - first; + while (count > 0) { + var step = Math.floor(count / 2); + var it = first + step; + if (cmp(val, array[it])) count = step; else { + first = ++it; + count -= step + 1; + } + } + return first; + } + function std_rotate(array, first, n_first, last) { + var next = n_first; + while (first !== next) { + std_iter_swap(array, first++, next++); + next === last ? next = n_first : first === n_first && (n_first = next); + } + } + function std_unique(array, first, last, cmp) { + if (first === last) return last; + var result = first; + while (++first !== last) cmp(array[result], array[first]) || std_iter_swap(array, ++result, first); + return ++result; + } + var b2GrowableBuffer = (function() { + function b2GrowableBuffer(allocator) { + this.data = []; + this.count = 0; + this.capacity = 0; + this.allocator = allocator; + } + b2GrowableBuffer.prototype.Append = function() { + this.count >= this.capacity && this.Grow(); + return this.count++; + }; + b2GrowableBuffer.prototype.Reserve = function(newCapacity) { + if (this.capacity >= newCapacity) return; + for (var i = this.capacity; i < newCapacity; ++i) this.data[i] = this.allocator(); + this.capacity = newCapacity; + }; + b2GrowableBuffer.prototype.Grow = function() { + var newCapacity = this.capacity ? 2 * this.capacity : b2_minParticleSystemBufferCapacity; + this.Reserve(newCapacity); + }; + b2GrowableBuffer.prototype.Free = function() { + if (0 === this.data.length) return; + this.data = []; + this.capacity = 0; + this.count = 0; + }; + b2GrowableBuffer.prototype.Shorten = function(newEnd) {}; + b2GrowableBuffer.prototype.Data = function() { + return this.data; + }; + b2GrowableBuffer.prototype.GetCount = function() { + return this.count; + }; + b2GrowableBuffer.prototype.SetCount = function(newCount) { + this.count = newCount; + }; + b2GrowableBuffer.prototype.GetCapacity = function() { + return this.capacity; + }; + b2GrowableBuffer.prototype.RemoveIf = function(pred) { + this.count = std_remove_if(this.data, pred, this.count); + }; + b2GrowableBuffer.prototype.Unique = function(pred) { + this.count = std_unique(this.data, 0, this.count, pred); + }; + return b2GrowableBuffer; + })(); + var b2FixtureParticleQueryCallback = (function(_super) { + __extends(b2FixtureParticleQueryCallback, _super); + function b2FixtureParticleQueryCallback(system) { + var _this = _super.call(this) || this; + _this.m_system = system; + return _this; + } + b2FixtureParticleQueryCallback.prototype.ShouldQueryParticleSystem = function(system) { + return false; + }; + b2FixtureParticleQueryCallback.prototype.ReportFixture = function(fixture) { + if (fixture.IsSensor()) return true; + var shape = fixture.GetShape(); + var childCount = shape.GetChildCount(); + for (var childIndex = 0; childIndex < childCount; childIndex++) { + var aabb = fixture.GetAABB(childIndex); + var enumerator = this.m_system.GetInsideBoundsEnumerator(aabb); + var index = void 0; + while ((index = enumerator.GetNext()) >= 0) this.ReportFixtureAndParticle(fixture, childIndex, index); + } + return true; + }; + b2FixtureParticleQueryCallback.prototype.ReportParticle = function(system, index) { + return false; + }; + b2FixtureParticleQueryCallback.prototype.ReportFixtureAndParticle = function(fixture, childIndex, index) {}; + return b2FixtureParticleQueryCallback; + })(b2QueryCallback); + var b2ParticleContact = (function() { + function b2ParticleContact() { + this.indexA = 0; + this.indexB = 0; + this.weight = 0; + this.normal = new b2Vec2(); + this.flags = 0; + } + b2ParticleContact.prototype.SetIndices = function(a, b) { + this.indexA = a; + this.indexB = b; + }; + b2ParticleContact.prototype.SetWeight = function(w) { + this.weight = w; + }; + b2ParticleContact.prototype.SetNormal = function(n) { + this.normal.Copy(n); + }; + b2ParticleContact.prototype.SetFlags = function(f) { + this.flags = f; + }; + b2ParticleContact.prototype.GetIndexA = function() { + return this.indexA; + }; + b2ParticleContact.prototype.GetIndexB = function() { + return this.indexB; + }; + b2ParticleContact.prototype.GetWeight = function() { + return this.weight; + }; + b2ParticleContact.prototype.GetNormal = function() { + return this.normal; + }; + b2ParticleContact.prototype.GetFlags = function() { + return this.flags; + }; + b2ParticleContact.prototype.IsEqual = function(rhs) { + return this.indexA === rhs.indexA && this.indexB === rhs.indexB && this.flags === rhs.flags && this.weight === rhs.weight && this.normal.x === rhs.normal.x && this.normal.y === rhs.normal.y; + }; + b2ParticleContact.prototype.IsNotEqual = function(rhs) { + return !this.IsEqual(rhs); + }; + b2ParticleContact.prototype.ApproximatelyEqual = function(rhs) { + var MAX_WEIGHT_DIFF = .01; + var MAX_NORMAL_DIFF_SQ = 1e-4; + return this.indexA === rhs.indexA && this.indexB === rhs.indexB && this.flags === rhs.flags && b2Abs(this.weight - rhs.weight) < MAX_WEIGHT_DIFF && b2Vec2.DistanceSquaredVV(this.normal, rhs.normal) < MAX_NORMAL_DIFF_SQ; + }; + return b2ParticleContact; + })(); + var b2ParticleBodyContact = (function() { + function b2ParticleBodyContact() { + this.index = 0; + this.weight = 0; + this.normal = new b2Vec2(); + this.mass = 0; + } + return b2ParticleBodyContact; + })(); + var b2ParticlePair = (function() { + function b2ParticlePair() { + this.indexA = 0; + this.indexB = 0; + this.flags = 0; + this.strength = 0; + this.distance = 0; + } + return b2ParticlePair; + })(); + var b2ParticleTriad = (function() { + function b2ParticleTriad() { + this.indexA = 0; + this.indexB = 0; + this.indexC = 0; + this.flags = 0; + this.strength = 0; + this.pa = new b2Vec2(0, 0); + this.pb = new b2Vec2(0, 0); + this.pc = new b2Vec2(0, 0); + this.ka = 0; + this.kb = 0; + this.kc = 0; + this.s = 0; + } + return b2ParticleTriad; + })(); + var b2ParticleSystemDef = (function() { + function b2ParticleSystemDef() { + this.strictContactCheck = false; + this.density = 1; + this.gravityScale = 1; + this.radius = 1; + this.maxCount = 0; + this.pressureStrength = .005; + this.dampingStrength = 1; + this.elasticStrength = .25; + this.springStrength = .25; + this.viscousStrength = .25; + this.surfaceTensionPressureStrength = .2; + this.surfaceTensionNormalStrength = .2; + this.repulsiveStrength = 1; + this.powderStrength = .5; + this.ejectionStrength = .5; + this.staticPressureStrength = .2; + this.staticPressureRelaxation = .2; + this.staticPressureIterations = 8; + this.colorMixingStrength = .5; + this.destroyByAge = true; + this.lifetimeGranularity = 1 / 60; + } + b2ParticleSystemDef.prototype.Copy = function(def) { + this.strictContactCheck = def.strictContactCheck; + this.density = def.density; + this.gravityScale = def.gravityScale; + this.radius = def.radius; + this.maxCount = def.maxCount; + this.pressureStrength = def.pressureStrength; + this.dampingStrength = def.dampingStrength; + this.elasticStrength = def.elasticStrength; + this.springStrength = def.springStrength; + this.viscousStrength = def.viscousStrength; + this.surfaceTensionPressureStrength = def.surfaceTensionPressureStrength; + this.surfaceTensionNormalStrength = def.surfaceTensionNormalStrength; + this.repulsiveStrength = def.repulsiveStrength; + this.powderStrength = def.powderStrength; + this.ejectionStrength = def.ejectionStrength; + this.staticPressureStrength = def.staticPressureStrength; + this.staticPressureRelaxation = def.staticPressureRelaxation; + this.staticPressureIterations = def.staticPressureIterations; + this.colorMixingStrength = def.colorMixingStrength; + this.destroyByAge = def.destroyByAge; + this.lifetimeGranularity = def.lifetimeGranularity; + return this; + }; + b2ParticleSystemDef.prototype.Clone = function() { + return new b2ParticleSystemDef().Copy(this); + }; + return b2ParticleSystemDef; + })(); + exports.b2ParticleSystem = (function() { + function b2ParticleSystem(def, world) { + this.m_paused = false; + this.m_timestamp = 0; + this.m_allParticleFlags = 0; + this.m_needsUpdateAllParticleFlags = false; + this.m_allGroupFlags = 0; + this.m_needsUpdateAllGroupFlags = false; + this.m_hasForce = false; + this.m_iterationIndex = 0; + this.m_inverseDensity = 0; + this.m_particleDiameter = 0; + this.m_inverseDiameter = 0; + this.m_squaredDiameter = 0; + this.m_count = 0; + this.m_internalAllocatedCapacity = 0; + this.m_handleIndexBuffer = new b2ParticleSystem.UserOverridableBuffer(); + this.m_flagsBuffer = new b2ParticleSystem.UserOverridableBuffer(); + this.m_positionBuffer = new b2ParticleSystem.UserOverridableBuffer(); + this.m_velocityBuffer = new b2ParticleSystem.UserOverridableBuffer(); + this.m_forceBuffer = []; + this.m_weightBuffer = []; + this.m_staticPressureBuffer = []; + this.m_accumulationBuffer = []; + this.m_accumulation2Buffer = []; + this.m_depthBuffer = []; + this.m_colorBuffer = new b2ParticleSystem.UserOverridableBuffer(); + this.m_groupBuffer = []; + this.m_userDataBuffer = new b2ParticleSystem.UserOverridableBuffer(); + this.m_stuckThreshold = 0; + this.m_lastBodyContactStepBuffer = new b2ParticleSystem.UserOverridableBuffer(); + this.m_bodyContactCountBuffer = new b2ParticleSystem.UserOverridableBuffer(); + this.m_consecutiveContactStepsBuffer = new b2ParticleSystem.UserOverridableBuffer(); + this.m_stuckParticleBuffer = new b2GrowableBuffer(function() { + return 0; + }); + this.m_proxyBuffer = new b2GrowableBuffer(function() { + return new b2ParticleSystem.Proxy(); + }); + this.m_contactBuffer = new b2GrowableBuffer(function() { + return new b2ParticleContact(); + }); + this.m_bodyContactBuffer = new b2GrowableBuffer(function() { + return new b2ParticleBodyContact(); + }); + this.m_pairBuffer = new b2GrowableBuffer(function() { + return new b2ParticlePair(); + }); + this.m_triadBuffer = new b2GrowableBuffer(function() { + return new b2ParticleTriad(); + }); + this.m_expirationTimeBuffer = new b2ParticleSystem.UserOverridableBuffer(); + this.m_indexByExpirationTimeBuffer = new b2ParticleSystem.UserOverridableBuffer(); + this.m_timeElapsed = 0; + this.m_expirationTimeBufferRequiresSorting = false; + this.m_groupCount = 0; + this.m_groupList = null; + this.m_def = new b2ParticleSystemDef(); + this.m_prev = null; + this.m_next = null; + this.SetStrictContactCheck(def.strictContactCheck); + this.SetDensity(def.density); + this.SetGravityScale(def.gravityScale); + this.SetRadius(def.radius); + this.SetMaxParticleCount(def.maxCount); + this.m_def = def.Clone(); + this.m_world = world; + this.SetDestructionByAge(this.m_def.destroyByAge); + } + b2ParticleSystem.computeTag = function(x, y) { + return (y + b2ParticleSystem.yOffset >>> 0 << b2ParticleSystem.yShift) + (b2ParticleSystem.xScale * x + b2ParticleSystem.xOffset >>> 0) >>> 0; + }; + b2ParticleSystem.computeRelativeTag = function(tag, x, y) { + return tag + (y << b2ParticleSystem.yShift) + (x << b2ParticleSystem.xShift) >>> 0; + }; + b2ParticleSystem.prototype.Drop = function() { + while (this.m_groupList) this.DestroyParticleGroup(this.m_groupList); + this.FreeUserOverridableBuffer(this.m_handleIndexBuffer); + this.FreeUserOverridableBuffer(this.m_flagsBuffer); + this.FreeUserOverridableBuffer(this.m_lastBodyContactStepBuffer); + this.FreeUserOverridableBuffer(this.m_bodyContactCountBuffer); + this.FreeUserOverridableBuffer(this.m_consecutiveContactStepsBuffer); + this.FreeUserOverridableBuffer(this.m_positionBuffer); + this.FreeUserOverridableBuffer(this.m_velocityBuffer); + this.FreeUserOverridableBuffer(this.m_colorBuffer); + this.FreeUserOverridableBuffer(this.m_userDataBuffer); + this.FreeUserOverridableBuffer(this.m_expirationTimeBuffer); + this.FreeUserOverridableBuffer(this.m_indexByExpirationTimeBuffer); + this.FreeBuffer(this.m_forceBuffer, this.m_internalAllocatedCapacity); + this.FreeBuffer(this.m_weightBuffer, this.m_internalAllocatedCapacity); + this.FreeBuffer(this.m_staticPressureBuffer, this.m_internalAllocatedCapacity); + this.FreeBuffer(this.m_accumulationBuffer, this.m_internalAllocatedCapacity); + this.FreeBuffer(this.m_accumulation2Buffer, this.m_internalAllocatedCapacity); + this.FreeBuffer(this.m_depthBuffer, this.m_internalAllocatedCapacity); + this.FreeBuffer(this.m_groupBuffer, this.m_internalAllocatedCapacity); + }; + b2ParticleSystem.prototype.CreateParticle = function(def) { + if (this.m_world.IsLocked()) throw new Error(); + if (this.m_count >= this.m_internalAllocatedCapacity) { + var capacity = this.m_count ? 2 * this.m_count : b2_minParticleSystemBufferCapacity; + this.ReallocateInternalAllocatedBuffers(capacity); + } + if (this.m_count >= this.m_internalAllocatedCapacity) { + if (!this.m_def.destroyByAge) return b2_invalidParticleIndex; + this.DestroyOldestParticle(0, false); + this.SolveZombie(); + } + var index = this.m_count++; + if (!this.m_flagsBuffer.data) throw new Error(); + this.m_flagsBuffer.data[index] = 0; + this.m_lastBodyContactStepBuffer.data && (this.m_lastBodyContactStepBuffer.data[index] = 0); + this.m_bodyContactCountBuffer.data && (this.m_bodyContactCountBuffer.data[index] = 0); + this.m_consecutiveContactStepsBuffer.data && (this.m_consecutiveContactStepsBuffer.data[index] = 0); + if (!this.m_positionBuffer.data) throw new Error(); + if (!this.m_velocityBuffer.data) throw new Error(); + this.m_positionBuffer.data[index] = (this.m_positionBuffer.data[index] || new b2Vec2()).Copy(b2Maybe(def.position, b2Vec2.ZERO)); + this.m_velocityBuffer.data[index] = (this.m_velocityBuffer.data[index] || new b2Vec2()).Copy(b2Maybe(def.velocity, b2Vec2.ZERO)); + this.m_weightBuffer[index] = 0; + this.m_forceBuffer[index] = (this.m_forceBuffer[index] || new b2Vec2()).SetZero(); + this.m_staticPressureBuffer && (this.m_staticPressureBuffer[index] = 0); + this.m_depthBuffer && (this.m_depthBuffer[index] = 0); + var color = new b2Color().Copy(b2Maybe(def.color, b2Color.ZERO)); + if (this.m_colorBuffer.data || !color.IsZero()) { + this.m_colorBuffer.data = this.RequestBuffer(this.m_colorBuffer.data); + this.m_colorBuffer.data[index] = (this.m_colorBuffer.data[index] || new b2Color()).Copy(color); + } + if (this.m_userDataBuffer.data || def.userData) { + this.m_userDataBuffer.data = this.RequestBuffer(this.m_userDataBuffer.data); + this.m_userDataBuffer.data[index] = def.userData; + } + this.m_handleIndexBuffer.data && (this.m_handleIndexBuffer.data[index] = null); + var proxy = this.m_proxyBuffer.data[this.m_proxyBuffer.Append()]; + var lifetime = b2Maybe(def.lifetime, 0); + var finiteLifetime = lifetime > 0; + if (this.m_expirationTimeBuffer.data || finiteLifetime) { + this.SetParticleLifetime(index, finiteLifetime ? lifetime : this.ExpirationTimeToLifetime(-this.GetQuantizedTimeElapsed())); + if (!this.m_indexByExpirationTimeBuffer.data) throw new Error(); + this.m_indexByExpirationTimeBuffer.data[index] = index; + } + proxy.index = index; + var group = b2Maybe(def.group, null); + this.m_groupBuffer[index] = group; + if (group) if (group.m_firstIndex < group.m_lastIndex) { + this.RotateBuffer(group.m_firstIndex, group.m_lastIndex, index); + group.m_lastIndex = index + 1; + } else { + group.m_firstIndex = index; + group.m_lastIndex = index + 1; + } + this.SetParticleFlags(index, b2Maybe(def.flags, 0)); + return index; + }; + b2ParticleSystem.prototype.GetParticleHandleFromIndex = function(index) { + this.m_handleIndexBuffer.data = this.RequestBuffer(this.m_handleIndexBuffer.data); + var handle = this.m_handleIndexBuffer.data[index]; + if (handle) return handle; + handle = new b2ParticleHandle(); + handle.SetIndex(index); + this.m_handleIndexBuffer.data[index] = handle; + return handle; + }; + b2ParticleSystem.prototype.DestroyParticle = function(index, callDestructionListener) { + void 0 === callDestructionListener && (callDestructionListener = false); + if (!this.m_flagsBuffer.data) throw new Error(); + var flags = exports.b2ParticleFlag.b2_zombieParticle; + callDestructionListener && (flags |= exports.b2ParticleFlag.b2_destructionListenerParticle); + this.SetParticleFlags(index, this.m_flagsBuffer.data[index] | flags); + }; + b2ParticleSystem.prototype.DestroyOldestParticle = function(index, callDestructionListener) { + void 0 === callDestructionListener && (callDestructionListener = false); + var particleCount = this.GetParticleCount(); + if (!this.m_indexByExpirationTimeBuffer.data) throw new Error(); + if (!this.m_expirationTimeBuffer.data) throw new Error(); + var oldestFiniteLifetimeParticle = this.m_indexByExpirationTimeBuffer.data[particleCount - (index + 1)]; + var oldestInfiniteLifetimeParticle = this.m_indexByExpirationTimeBuffer.data[index]; + this.DestroyParticle(this.m_expirationTimeBuffer.data[oldestFiniteLifetimeParticle] > 0 ? oldestFiniteLifetimeParticle : oldestInfiniteLifetimeParticle, callDestructionListener); + }; + b2ParticleSystem.prototype.DestroyParticlesInShape = function(shape, xf, callDestructionListener) { + void 0 === callDestructionListener && (callDestructionListener = false); + var s_aabb = b2ParticleSystem.DestroyParticlesInShape_s_aabb; + if (this.m_world.IsLocked()) throw new Error(); + var callback = new b2ParticleSystem.DestroyParticlesInShapeCallback(this, shape, xf, callDestructionListener); + var aabb = s_aabb; + shape.ComputeAABB(aabb, xf, 0); + this.m_world.QueryAABB(callback, aabb); + return callback.Destroyed(); + }; + b2ParticleSystem.prototype.CreateParticleGroup = function(groupDef) { + var s_transform = b2ParticleSystem.CreateParticleGroup_s_transform; + if (this.m_world.IsLocked()) throw new Error(); + var transform = s_transform; + transform.SetPositionAngle(b2Maybe(groupDef.position, b2Vec2.ZERO), b2Maybe(groupDef.angle, 0)); + var firstIndex = this.m_count; + groupDef.shape && this.CreateParticlesWithShapeForGroup(groupDef.shape, groupDef, transform); + groupDef.shapes && this.CreateParticlesWithShapesForGroup(groupDef.shapes, b2Maybe(groupDef.shapeCount, groupDef.shapes.length), groupDef, transform); + if (groupDef.positionData) { + var count = b2Maybe(groupDef.particleCount, groupDef.positionData.length); + for (var i = 0; i < count; i++) { + var p = groupDef.positionData[i]; + this.CreateParticleForGroup(groupDef, transform, p); + } + } + var lastIndex = this.m_count; + var group = new b2ParticleGroup(this); + group.m_firstIndex = firstIndex; + group.m_lastIndex = lastIndex; + group.m_strength = b2Maybe(groupDef.strength, 1); + group.m_userData = groupDef.userData; + group.m_transform.Copy(transform); + group.m_prev = null; + group.m_next = this.m_groupList; + this.m_groupList && (this.m_groupList.m_prev = group); + this.m_groupList = group; + ++this.m_groupCount; + for (var i = firstIndex; i < lastIndex; i++) this.m_groupBuffer[i] = group; + this.SetGroupFlags(group, b2Maybe(groupDef.groupFlags, 0)); + var filter = new b2ParticleSystem.ConnectionFilter(); + this.UpdateContacts(true); + this.UpdatePairsAndTriads(firstIndex, lastIndex, filter); + if (groupDef.group) { + this.JoinParticleGroups(groupDef.group, group); + group = groupDef.group; + } + return group; + }; + b2ParticleSystem.prototype.JoinParticleGroups = function(groupA, groupB) { + if (this.m_world.IsLocked()) throw new Error(); + this.RotateBuffer(groupB.m_firstIndex, groupB.m_lastIndex, this.m_count); + this.RotateBuffer(groupA.m_firstIndex, groupA.m_lastIndex, groupB.m_firstIndex); + var filter = new b2ParticleSystem.JoinParticleGroupsFilter(groupB.m_firstIndex); + this.UpdateContacts(true); + this.UpdatePairsAndTriads(groupA.m_firstIndex, groupB.m_lastIndex, filter); + for (var i = groupB.m_firstIndex; i < groupB.m_lastIndex; i++) this.m_groupBuffer[i] = groupA; + var groupFlags = groupA.m_groupFlags | groupB.m_groupFlags; + this.SetGroupFlags(groupA, groupFlags); + groupA.m_lastIndex = groupB.m_lastIndex; + groupB.m_firstIndex = groupB.m_lastIndex; + this.DestroyParticleGroup(groupB); + }; + b2ParticleSystem.prototype.SplitParticleGroup = function(group) { + this.UpdateContacts(true); + var particleCount = group.GetParticleCount(); + var nodeBuffer = b2MakeArray(particleCount, (function(index) { + return new b2ParticleSystem.ParticleListNode(); + })); + b2ParticleSystem.InitializeParticleLists(group, nodeBuffer); + this.MergeParticleListsInContact(group, nodeBuffer); + var survivingList = b2ParticleSystem.FindLongestParticleList(group, nodeBuffer); + this.MergeZombieParticleListNodes(group, nodeBuffer, survivingList); + this.CreateParticleGroupsFromParticleList(group, nodeBuffer, survivingList); + this.UpdatePairsAndTriadsWithParticleList(group, nodeBuffer); + }; + b2ParticleSystem.prototype.GetParticleGroupList = function() { + return this.m_groupList; + }; + b2ParticleSystem.prototype.GetParticleGroupCount = function() { + return this.m_groupCount; + }; + b2ParticleSystem.prototype.GetParticleCount = function() { + return this.m_count; + }; + b2ParticleSystem.prototype.GetMaxParticleCount = function() { + return this.m_def.maxCount; + }; + b2ParticleSystem.prototype.SetMaxParticleCount = function(count) { + this.m_def.maxCount = count; + }; + b2ParticleSystem.prototype.GetAllParticleFlags = function() { + return this.m_allParticleFlags; + }; + b2ParticleSystem.prototype.GetAllGroupFlags = function() { + return this.m_allGroupFlags; + }; + b2ParticleSystem.prototype.SetPaused = function(paused) { + this.m_paused = paused; + }; + b2ParticleSystem.prototype.GetPaused = function() { + return this.m_paused; + }; + b2ParticleSystem.prototype.SetDensity = function(density) { + this.m_def.density = density; + this.m_inverseDensity = 1 / this.m_def.density; + }; + b2ParticleSystem.prototype.GetDensity = function() { + return this.m_def.density; + }; + b2ParticleSystem.prototype.SetGravityScale = function(gravityScale) { + this.m_def.gravityScale = gravityScale; + }; + b2ParticleSystem.prototype.GetGravityScale = function() { + return this.m_def.gravityScale; + }; + b2ParticleSystem.prototype.SetDamping = function(damping) { + this.m_def.dampingStrength = damping; + }; + b2ParticleSystem.prototype.GetDamping = function() { + return this.m_def.dampingStrength; + }; + b2ParticleSystem.prototype.SetStaticPressureIterations = function(iterations) { + this.m_def.staticPressureIterations = iterations; + }; + b2ParticleSystem.prototype.GetStaticPressureIterations = function() { + return this.m_def.staticPressureIterations; + }; + b2ParticleSystem.prototype.SetRadius = function(radius) { + this.m_particleDiameter = 2 * radius; + this.m_squaredDiameter = this.m_particleDiameter * this.m_particleDiameter; + this.m_inverseDiameter = 1 / this.m_particleDiameter; + }; + b2ParticleSystem.prototype.GetRadius = function() { + return this.m_particleDiameter / 2; + }; + b2ParticleSystem.prototype.GetPositionBuffer = function() { + if (!this.m_positionBuffer.data) throw new Error(); + return this.m_positionBuffer.data; + }; + b2ParticleSystem.prototype.GetVelocityBuffer = function() { + if (!this.m_velocityBuffer.data) throw new Error(); + return this.m_velocityBuffer.data; + }; + b2ParticleSystem.prototype.GetColorBuffer = function() { + this.m_colorBuffer.data = this.RequestBuffer(this.m_colorBuffer.data); + return this.m_colorBuffer.data; + }; + b2ParticleSystem.prototype.GetGroupBuffer = function() { + return this.m_groupBuffer; + }; + b2ParticleSystem.prototype.GetWeightBuffer = function() { + return this.m_weightBuffer; + }; + b2ParticleSystem.prototype.GetUserDataBuffer = function() { + this.m_userDataBuffer.data = this.RequestBuffer(this.m_userDataBuffer.data); + return this.m_userDataBuffer.data; + }; + b2ParticleSystem.prototype.GetFlagsBuffer = function() { + if (!this.m_flagsBuffer.data) throw new Error(); + return this.m_flagsBuffer.data; + }; + b2ParticleSystem.prototype.SetParticleFlags = function(index, newFlags) { + if (!this.m_flagsBuffer.data) throw new Error(); + var oldFlags = this.m_flagsBuffer.data[index]; + oldFlags & ~newFlags && (this.m_needsUpdateAllParticleFlags = true); + if (~this.m_allParticleFlags & newFlags) { + newFlags & exports.b2ParticleFlag.b2_tensileParticle && (this.m_accumulation2Buffer = this.RequestBuffer(this.m_accumulation2Buffer)); + newFlags & exports.b2ParticleFlag.b2_colorMixingParticle && (this.m_colorBuffer.data = this.RequestBuffer(this.m_colorBuffer.data)); + this.m_allParticleFlags |= newFlags; + } + this.m_flagsBuffer.data[index] = newFlags; + }; + b2ParticleSystem.prototype.GetParticleFlags = function(index) { + if (!this.m_flagsBuffer.data) throw new Error(); + return this.m_flagsBuffer.data[index]; + }; + b2ParticleSystem.prototype.SetFlagsBuffer = function(buffer, capacity) { + this.SetUserOverridableBuffer(this.m_flagsBuffer, buffer, capacity); + }; + b2ParticleSystem.prototype.SetPositionBuffer = function(buffer, capacity) { + this.SetUserOverridableBuffer(this.m_positionBuffer, buffer, capacity); + }; + b2ParticleSystem.prototype.SetVelocityBuffer = function(buffer, capacity) { + this.SetUserOverridableBuffer(this.m_velocityBuffer, buffer, capacity); + }; + b2ParticleSystem.prototype.SetColorBuffer = function(buffer, capacity) { + this.SetUserOverridableBuffer(this.m_colorBuffer, buffer, capacity); + }; + b2ParticleSystem.prototype.SetUserDataBuffer = function(buffer, capacity) { + this.SetUserOverridableBuffer(this.m_userDataBuffer, buffer, capacity); + }; + b2ParticleSystem.prototype.GetContacts = function() { + return this.m_contactBuffer.data; + }; + b2ParticleSystem.prototype.GetContactCount = function() { + return this.m_contactBuffer.count; + }; + b2ParticleSystem.prototype.GetBodyContacts = function() { + return this.m_bodyContactBuffer.data; + }; + b2ParticleSystem.prototype.GetBodyContactCount = function() { + return this.m_bodyContactBuffer.count; + }; + b2ParticleSystem.prototype.GetPairs = function() { + return this.m_pairBuffer.data; + }; + b2ParticleSystem.prototype.GetPairCount = function() { + return this.m_pairBuffer.count; + }; + b2ParticleSystem.prototype.GetTriads = function() { + return this.m_triadBuffer.data; + }; + b2ParticleSystem.prototype.GetTriadCount = function() { + return this.m_triadBuffer.count; + }; + b2ParticleSystem.prototype.SetStuckThreshold = function(steps) { + this.m_stuckThreshold = steps; + if (steps > 0) { + this.m_lastBodyContactStepBuffer.data = this.RequestBuffer(this.m_lastBodyContactStepBuffer.data); + this.m_bodyContactCountBuffer.data = this.RequestBuffer(this.m_bodyContactCountBuffer.data); + this.m_consecutiveContactStepsBuffer.data = this.RequestBuffer(this.m_consecutiveContactStepsBuffer.data); + } + }; + b2ParticleSystem.prototype.GetStuckCandidates = function() { + return this.m_stuckParticleBuffer.Data(); + }; + b2ParticleSystem.prototype.GetStuckCandidateCount = function() { + return this.m_stuckParticleBuffer.GetCount(); + }; + b2ParticleSystem.prototype.ComputeCollisionEnergy = function() { + if (!this.m_velocityBuffer.data) throw new Error(); + var s_v = b2ParticleSystem.ComputeCollisionEnergy_s_v; + var vel_data = this.m_velocityBuffer.data; + var sum_v2 = 0; + for (var k = 0; k < this.m_contactBuffer.count; k++) { + var contact = this.m_contactBuffer.data[k]; + var a = contact.indexA; + var b = contact.indexB; + var n = contact.normal; + var v = b2Vec2.SubVV(vel_data[b], vel_data[a], s_v); + var vn = b2Vec2.DotVV(v, n); + vn < 0 && (sum_v2 += vn * vn); + } + return .5 * this.GetParticleMass() * sum_v2; + }; + b2ParticleSystem.prototype.SetStrictContactCheck = function(enabled) { + this.m_def.strictContactCheck = enabled; + }; + b2ParticleSystem.prototype.GetStrictContactCheck = function() { + return this.m_def.strictContactCheck; + }; + b2ParticleSystem.prototype.SetParticleLifetime = function(index, lifetime) { + var initializeExpirationTimes = null === this.m_indexByExpirationTimeBuffer.data; + this.m_expirationTimeBuffer.data = this.RequestBuffer(this.m_expirationTimeBuffer.data); + this.m_indexByExpirationTimeBuffer.data = this.RequestBuffer(this.m_indexByExpirationTimeBuffer.data); + if (initializeExpirationTimes) { + var particleCount = this.GetParticleCount(); + for (var i = 0; i < particleCount; ++i) this.m_indexByExpirationTimeBuffer.data[i] = i; + } + var quantizedLifetime = lifetime / this.m_def.lifetimeGranularity; + var newExpirationTime = quantizedLifetime > 0 ? this.GetQuantizedTimeElapsed() + quantizedLifetime : quantizedLifetime; + if (newExpirationTime !== this.m_expirationTimeBuffer.data[index]) { + this.m_expirationTimeBuffer.data[index] = newExpirationTime; + this.m_expirationTimeBufferRequiresSorting = true; + } + }; + b2ParticleSystem.prototype.GetParticleLifetime = function(index) { + return this.ExpirationTimeToLifetime(this.GetExpirationTimeBuffer()[index]); + }; + b2ParticleSystem.prototype.SetDestructionByAge = function(enable) { + enable && this.GetExpirationTimeBuffer(); + this.m_def.destroyByAge = enable; + }; + b2ParticleSystem.prototype.GetDestructionByAge = function() { + return this.m_def.destroyByAge; + }; + b2ParticleSystem.prototype.GetExpirationTimeBuffer = function() { + this.m_expirationTimeBuffer.data = this.RequestBuffer(this.m_expirationTimeBuffer.data); + return this.m_expirationTimeBuffer.data; + }; + b2ParticleSystem.prototype.ExpirationTimeToLifetime = function(expirationTime) { + return (expirationTime > 0 ? expirationTime - this.GetQuantizedTimeElapsed() : expirationTime) * this.m_def.lifetimeGranularity; + }; + b2ParticleSystem.prototype.GetIndexByExpirationTimeBuffer = function() { + this.GetParticleCount() ? this.SetParticleLifetime(0, this.GetParticleLifetime(0)) : this.m_indexByExpirationTimeBuffer.data = this.RequestBuffer(this.m_indexByExpirationTimeBuffer.data); + if (!this.m_indexByExpirationTimeBuffer.data) throw new Error(); + return this.m_indexByExpirationTimeBuffer.data; + }; + b2ParticleSystem.prototype.ParticleApplyLinearImpulse = function(index, impulse) { + this.ApplyLinearImpulse(index, index + 1, impulse); + }; + b2ParticleSystem.prototype.ApplyLinearImpulse = function(firstIndex, lastIndex, impulse) { + if (!this.m_velocityBuffer.data) throw new Error(); + var vel_data = this.m_velocityBuffer.data; + var numParticles = lastIndex - firstIndex; + var totalMass = numParticles * this.GetParticleMass(); + var velocityDelta = new b2Vec2().Copy(impulse).SelfMul(1 / totalMass); + for (var i = firstIndex; i < lastIndex; i++) vel_data[i].SelfAdd(velocityDelta); + }; + b2ParticleSystem.IsSignificantForce = function(force) { + return 0 !== force.x || 0 !== force.y; + }; + b2ParticleSystem.prototype.ParticleApplyForce = function(index, force) { + if (!this.m_flagsBuffer.data) throw new Error(); + if (b2ParticleSystem.IsSignificantForce(force) && this.ForceCanBeApplied(this.m_flagsBuffer.data[index])) { + this.PrepareForceBuffer(); + this.m_forceBuffer[index].SelfAdd(force); + } + }; + b2ParticleSystem.prototype.ApplyForce = function(firstIndex, lastIndex, force) { + var distributedForce = new b2Vec2().Copy(force).SelfMul(1 / (lastIndex - firstIndex)); + if (b2ParticleSystem.IsSignificantForce(distributedForce)) { + this.PrepareForceBuffer(); + for (var i = firstIndex; i < lastIndex; i++) this.m_forceBuffer[i].SelfAdd(distributedForce); + } + }; + b2ParticleSystem.prototype.GetNext = function() { + return this.m_next; + }; + b2ParticleSystem.prototype.QueryAABB = function(callback, aabb) { + if (0 === this.m_proxyBuffer.count) return; + var beginProxy = 0; + var endProxy = this.m_proxyBuffer.count; + var firstProxy = std_lower_bound(this.m_proxyBuffer.data, beginProxy, endProxy, b2ParticleSystem.computeTag(this.m_inverseDiameter * aabb.lowerBound.x, this.m_inverseDiameter * aabb.lowerBound.y), b2ParticleSystem.Proxy.CompareProxyTag); + var lastProxy = std_upper_bound(this.m_proxyBuffer.data, firstProxy, endProxy, b2ParticleSystem.computeTag(this.m_inverseDiameter * aabb.upperBound.x, this.m_inverseDiameter * aabb.upperBound.y), b2ParticleSystem.Proxy.CompareTagProxy); + if (!this.m_positionBuffer.data) throw new Error(); + var pos_data = this.m_positionBuffer.data; + for (var k = firstProxy; k < lastProxy; ++k) { + var proxy = this.m_proxyBuffer.data[k]; + var i = proxy.index; + var p = pos_data[i]; + if (aabb.lowerBound.x < p.x && p.x < aabb.upperBound.x && aabb.lowerBound.y < p.y && p.y < aabb.upperBound.y && !callback.ReportParticle(this, i)) break; + } + }; + b2ParticleSystem.prototype.QueryShapeAABB = function(callback, shape, xf, childIndex) { + void 0 === childIndex && (childIndex = 0); + var s_aabb = b2ParticleSystem.QueryShapeAABB_s_aabb; + var aabb = s_aabb; + shape.ComputeAABB(aabb, xf, childIndex); + this.QueryAABB(callback, aabb); + }; + b2ParticleSystem.prototype.QueryPointAABB = function(callback, point, slop) { + void 0 === slop && (slop = b2_linearSlop); + var s_aabb = b2ParticleSystem.QueryPointAABB_s_aabb; + var aabb = s_aabb; + aabb.lowerBound.Set(point.x - slop, point.y - slop); + aabb.upperBound.Set(point.x + slop, point.y + slop); + this.QueryAABB(callback, aabb); + }; + b2ParticleSystem.prototype.RayCast = function(callback, point1, point2) { + var s_aabb = b2ParticleSystem.RayCast_s_aabb; + var s_p = b2ParticleSystem.RayCast_s_p; + var s_v = b2ParticleSystem.RayCast_s_v; + var s_n = b2ParticleSystem.RayCast_s_n; + var s_point = b2ParticleSystem.RayCast_s_point; + if (0 === this.m_proxyBuffer.count) return; + if (!this.m_positionBuffer.data) throw new Error(); + var pos_data = this.m_positionBuffer.data; + var aabb = s_aabb; + b2Vec2.MinV(point1, point2, aabb.lowerBound); + b2Vec2.MaxV(point1, point2, aabb.upperBound); + var fraction = 1; + var v = b2Vec2.SubVV(point2, point1, s_v); + var v2 = b2Vec2.DotVV(v, v); + var enumerator = this.GetInsideBoundsEnumerator(aabb); + var i; + while ((i = enumerator.GetNext()) >= 0) { + var p = b2Vec2.SubVV(point1, pos_data[i], s_p); + var pv = b2Vec2.DotVV(p, v); + var p2 = b2Vec2.DotVV(p, p); + var determinant = pv * pv - v2 * (p2 - this.m_squaredDiameter); + if (determinant >= 0) { + var sqrtDeterminant = b2Sqrt(determinant); + var t = (-pv - sqrtDeterminant) / v2; + if (t > fraction) continue; + if (t < 0) { + t = (-pv + sqrtDeterminant) / v2; + if (t < 0 || t > fraction) continue; + } + var n = b2Vec2.AddVMulSV(p, t, v, s_n); + n.Normalize(); + var f = callback.ReportParticle(this, i, b2Vec2.AddVMulSV(point1, t, v, s_point), n, t); + fraction = b2Min(fraction, f); + if (fraction <= 0) break; + } + } + }; + b2ParticleSystem.prototype.ComputeAABB = function(aabb) { + var particleCount = this.GetParticleCount(); + aabb.lowerBound.x = +b2_maxFloat; + aabb.lowerBound.y = +b2_maxFloat; + aabb.upperBound.x = -b2_maxFloat; + aabb.upperBound.y = -b2_maxFloat; + if (!this.m_positionBuffer.data) throw new Error(); + var pos_data = this.m_positionBuffer.data; + for (var i = 0; i < particleCount; i++) { + var p = pos_data[i]; + b2Vec2.MinV(aabb.lowerBound, p, aabb.lowerBound); + b2Vec2.MaxV(aabb.upperBound, p, aabb.upperBound); + } + aabb.lowerBound.x -= this.m_particleDiameter; + aabb.lowerBound.y -= this.m_particleDiameter; + aabb.upperBound.x += this.m_particleDiameter; + aabb.upperBound.y += this.m_particleDiameter; + }; + b2ParticleSystem.prototype.FreeBuffer = function(b, capacity) { + if (null === b) return; + b.length = 0; + }; + b2ParticleSystem.prototype.FreeUserOverridableBuffer = function(b) { + 0 === b.userSuppliedCapacity && this.FreeBuffer(b.data, this.m_internalAllocatedCapacity); + }; + b2ParticleSystem.prototype.ReallocateBuffer3 = function(oldBuffer, oldCapacity, newCapacity) { + if (newCapacity <= oldCapacity) throw new Error(); + var newBuffer = oldBuffer ? oldBuffer.slice() : []; + newBuffer.length = newCapacity; + return newBuffer; + }; + b2ParticleSystem.prototype.ReallocateBuffer5 = function(buffer, userSuppliedCapacity, oldCapacity, newCapacity, deferred) { + if (newCapacity <= oldCapacity) throw new Error(); + if (!(!userSuppliedCapacity || newCapacity <= userSuppliedCapacity)) throw new Error(); + deferred && !buffer || userSuppliedCapacity || (buffer = this.ReallocateBuffer3(buffer, oldCapacity, newCapacity)); + return buffer; + }; + b2ParticleSystem.prototype.ReallocateBuffer4 = function(buffer, oldCapacity, newCapacity, deferred) { + return this.ReallocateBuffer5(buffer.data, buffer.userSuppliedCapacity, oldCapacity, newCapacity, deferred); + }; + b2ParticleSystem.prototype.RequestBuffer = function(buffer) { + if (!buffer) { + 0 === this.m_internalAllocatedCapacity && this.ReallocateInternalAllocatedBuffers(b2_minParticleSystemBufferCapacity); + buffer = []; + buffer.length = this.m_internalAllocatedCapacity; + } + return buffer; + }; + b2ParticleSystem.prototype.ReallocateHandleBuffers = function(newCapacity) { + this.m_handleIndexBuffer.data = this.ReallocateBuffer4(this.m_handleIndexBuffer, this.m_internalAllocatedCapacity, newCapacity, true); + }; + b2ParticleSystem.prototype.ReallocateInternalAllocatedBuffers = function(capacity) { + function LimitCapacity(capacity, maxCount) { + return maxCount && capacity > maxCount ? maxCount : capacity; + } + capacity = LimitCapacity(capacity, this.m_def.maxCount); + capacity = LimitCapacity(capacity, this.m_flagsBuffer.userSuppliedCapacity); + capacity = LimitCapacity(capacity, this.m_positionBuffer.userSuppliedCapacity); + capacity = LimitCapacity(capacity, this.m_velocityBuffer.userSuppliedCapacity); + capacity = LimitCapacity(capacity, this.m_colorBuffer.userSuppliedCapacity); + capacity = LimitCapacity(capacity, this.m_userDataBuffer.userSuppliedCapacity); + if (this.m_internalAllocatedCapacity < capacity) { + this.ReallocateHandleBuffers(capacity); + this.m_flagsBuffer.data = this.ReallocateBuffer4(this.m_flagsBuffer, this.m_internalAllocatedCapacity, capacity, false); + var stuck = this.m_stuckThreshold > 0; + this.m_lastBodyContactStepBuffer.data = this.ReallocateBuffer4(this.m_lastBodyContactStepBuffer, this.m_internalAllocatedCapacity, capacity, stuck); + this.m_bodyContactCountBuffer.data = this.ReallocateBuffer4(this.m_bodyContactCountBuffer, this.m_internalAllocatedCapacity, capacity, stuck); + this.m_consecutiveContactStepsBuffer.data = this.ReallocateBuffer4(this.m_consecutiveContactStepsBuffer, this.m_internalAllocatedCapacity, capacity, stuck); + this.m_positionBuffer.data = this.ReallocateBuffer4(this.m_positionBuffer, this.m_internalAllocatedCapacity, capacity, false); + this.m_velocityBuffer.data = this.ReallocateBuffer4(this.m_velocityBuffer, this.m_internalAllocatedCapacity, capacity, false); + this.m_forceBuffer = this.ReallocateBuffer5(this.m_forceBuffer, 0, this.m_internalAllocatedCapacity, capacity, false); + this.m_weightBuffer = this.ReallocateBuffer5(this.m_weightBuffer, 0, this.m_internalAllocatedCapacity, capacity, false); + this.m_staticPressureBuffer = this.ReallocateBuffer5(this.m_staticPressureBuffer, 0, this.m_internalAllocatedCapacity, capacity, true); + this.m_accumulationBuffer = this.ReallocateBuffer5(this.m_accumulationBuffer, 0, this.m_internalAllocatedCapacity, capacity, false); + this.m_accumulation2Buffer = this.ReallocateBuffer5(this.m_accumulation2Buffer, 0, this.m_internalAllocatedCapacity, capacity, true); + this.m_depthBuffer = this.ReallocateBuffer5(this.m_depthBuffer, 0, this.m_internalAllocatedCapacity, capacity, true); + this.m_colorBuffer.data = this.ReallocateBuffer4(this.m_colorBuffer, this.m_internalAllocatedCapacity, capacity, true); + this.m_groupBuffer = this.ReallocateBuffer5(this.m_groupBuffer, 0, this.m_internalAllocatedCapacity, capacity, false); + this.m_userDataBuffer.data = this.ReallocateBuffer4(this.m_userDataBuffer, this.m_internalAllocatedCapacity, capacity, true); + this.m_expirationTimeBuffer.data = this.ReallocateBuffer4(this.m_expirationTimeBuffer, this.m_internalAllocatedCapacity, capacity, true); + this.m_indexByExpirationTimeBuffer.data = this.ReallocateBuffer4(this.m_indexByExpirationTimeBuffer, this.m_internalAllocatedCapacity, capacity, false); + this.m_internalAllocatedCapacity = capacity; + } + }; + b2ParticleSystem.prototype.CreateParticleForGroup = function(groupDef, xf, p) { + var particleDef = new b2ParticleDef(); + particleDef.flags = b2Maybe(groupDef.flags, 0); + b2Transform.MulXV(xf, p, particleDef.position); + b2Vec2.AddVV(b2Maybe(groupDef.linearVelocity, b2Vec2.ZERO), b2Vec2.CrossSV(b2Maybe(groupDef.angularVelocity, 0), b2Vec2.SubVV(particleDef.position, b2Maybe(groupDef.position, b2Vec2.ZERO), b2Vec2.s_t0), b2Vec2.s_t0), particleDef.velocity); + particleDef.color.Copy(b2Maybe(groupDef.color, b2Color.ZERO)); + particleDef.lifetime = b2Maybe(groupDef.lifetime, 0); + particleDef.userData = groupDef.userData; + this.CreateParticle(particleDef); + }; + b2ParticleSystem.prototype.CreateParticlesStrokeShapeForGroup = function(shape, groupDef, xf) { + var s_edge = b2ParticleSystem.CreateParticlesStrokeShapeForGroup_s_edge; + var s_d = b2ParticleSystem.CreateParticlesStrokeShapeForGroup_s_d; + var s_p = b2ParticleSystem.CreateParticlesStrokeShapeForGroup_s_p; + var stride = b2Maybe(groupDef.stride, 0); + 0 === stride && (stride = this.GetParticleStride()); + var positionOnEdge = 0; + var childCount = shape.GetChildCount(); + for (var childIndex = 0; childIndex < childCount; childIndex++) { + var edge = null; + if (shape.GetType() === exports.b2ShapeType.e_edgeShape) edge = shape; else { + edge = s_edge; + shape.GetChildEdge(edge, childIndex); + } + var d = b2Vec2.SubVV(edge.m_vertex2, edge.m_vertex1, s_d); + var edgeLength = d.Length(); + while (positionOnEdge < edgeLength) { + var p = b2Vec2.AddVMulSV(edge.m_vertex1, positionOnEdge / edgeLength, d, s_p); + this.CreateParticleForGroup(groupDef, xf, p); + positionOnEdge += stride; + } + positionOnEdge -= edgeLength; + } + }; + b2ParticleSystem.prototype.CreateParticlesFillShapeForGroup = function(shape, groupDef, xf) { + var s_aabb = b2ParticleSystem.CreateParticlesFillShapeForGroup_s_aabb; + var s_p = b2ParticleSystem.CreateParticlesFillShapeForGroup_s_p; + var stride = b2Maybe(groupDef.stride, 0); + 0 === stride && (stride = this.GetParticleStride()); + var identity = b2Transform.IDENTITY; + var aabb = s_aabb; + shape.ComputeAABB(aabb, identity, 0); + for (var y = Math.floor(aabb.lowerBound.y / stride) * stride; y < aabb.upperBound.y; y += stride) for (var x = Math.floor(aabb.lowerBound.x / stride) * stride; x < aabb.upperBound.x; x += stride) { + var p = s_p.Set(x, y); + shape.TestPoint(identity, p) && this.CreateParticleForGroup(groupDef, xf, p); + } + }; + b2ParticleSystem.prototype.CreateParticlesWithShapeForGroup = function(shape, groupDef, xf) { + switch (shape.GetType()) { + case exports.b2ShapeType.e_edgeShape: + case exports.b2ShapeType.e_chainShape: + this.CreateParticlesStrokeShapeForGroup(shape, groupDef, xf); + break; + + case exports.b2ShapeType.e_polygonShape: + case exports.b2ShapeType.e_circleShape: + this.CreateParticlesFillShapeForGroup(shape, groupDef, xf); + } + }; + b2ParticleSystem.prototype.CreateParticlesWithShapesForGroup = function(shapes, shapeCount, groupDef, xf) { + var compositeShape = new b2ParticleSystem.CompositeShape(shapes, shapeCount); + this.CreateParticlesFillShapeForGroup(compositeShape, groupDef, xf); + }; + b2ParticleSystem.prototype.CloneParticle = function(oldIndex, group) { + var def = new b2ParticleDef(); + if (!this.m_flagsBuffer.data) throw new Error(); + if (!this.m_positionBuffer.data) throw new Error(); + if (!this.m_velocityBuffer.data) throw new Error(); + def.flags = this.m_flagsBuffer.data[oldIndex]; + def.position.Copy(this.m_positionBuffer.data[oldIndex]); + def.velocity.Copy(this.m_velocityBuffer.data[oldIndex]); + this.m_colorBuffer.data && def.color.Copy(this.m_colorBuffer.data[oldIndex]); + this.m_userDataBuffer.data && (def.userData = this.m_userDataBuffer.data[oldIndex]); + def.group = group; + var newIndex = this.CreateParticle(def); + if (this.m_handleIndexBuffer.data) { + var handle = this.m_handleIndexBuffer.data[oldIndex]; + handle && handle.SetIndex(newIndex); + this.m_handleIndexBuffer.data[newIndex] = handle; + this.m_handleIndexBuffer.data[oldIndex] = null; + } + this.m_lastBodyContactStepBuffer.data && (this.m_lastBodyContactStepBuffer.data[newIndex] = this.m_lastBodyContactStepBuffer.data[oldIndex]); + this.m_bodyContactCountBuffer.data && (this.m_bodyContactCountBuffer.data[newIndex] = this.m_bodyContactCountBuffer.data[oldIndex]); + this.m_consecutiveContactStepsBuffer.data && (this.m_consecutiveContactStepsBuffer.data[newIndex] = this.m_consecutiveContactStepsBuffer.data[oldIndex]); + this.m_hasForce && this.m_forceBuffer[newIndex].Copy(this.m_forceBuffer[oldIndex]); + this.m_staticPressureBuffer && (this.m_staticPressureBuffer[newIndex] = this.m_staticPressureBuffer[oldIndex]); + this.m_depthBuffer && (this.m_depthBuffer[newIndex] = this.m_depthBuffer[oldIndex]); + this.m_expirationTimeBuffer.data && (this.m_expirationTimeBuffer.data[newIndex] = this.m_expirationTimeBuffer.data[oldIndex]); + return newIndex; + }; + b2ParticleSystem.prototype.DestroyParticlesInGroup = function(group, callDestructionListener) { + void 0 === callDestructionListener && (callDestructionListener = false); + for (var i = group.m_firstIndex; i < group.m_lastIndex; i++) this.DestroyParticle(i, callDestructionListener); + }; + b2ParticleSystem.prototype.DestroyParticleGroup = function(group) { + this.m_world.m_destructionListener && this.m_world.m_destructionListener.SayGoodbyeParticleGroup(group); + this.SetGroupFlags(group, 0); + for (var i = group.m_firstIndex; i < group.m_lastIndex; i++) this.m_groupBuffer[i] = null; + group.m_prev && (group.m_prev.m_next = group.m_next); + group.m_next && (group.m_next.m_prev = group.m_prev); + group === this.m_groupList && (this.m_groupList = group.m_next); + --this.m_groupCount; + }; + b2ParticleSystem.ParticleCanBeConnected = function(flags, group) { + return 0 !== (flags & (exports.b2ParticleFlag.b2_wallParticle | exports.b2ParticleFlag.b2_springParticle | exports.b2ParticleFlag.b2_elasticParticle)) || null !== group && 0 !== (group.GetGroupFlags() & exports.b2ParticleGroupFlag.b2_rigidParticleGroup); + }; + b2ParticleSystem.prototype.UpdatePairsAndTriads = function(firstIndex, lastIndex, filter) { + var s_dab = b2ParticleSystem.UpdatePairsAndTriads_s_dab; + var s_dbc = b2ParticleSystem.UpdatePairsAndTriads_s_dbc; + var s_dca = b2ParticleSystem.UpdatePairsAndTriads_s_dca; + if (!this.m_flagsBuffer.data) throw new Error(); + if (!this.m_positionBuffer.data) throw new Error(); + if (!this.m_velocityBuffer.data) throw new Error(); + var pos_data = this.m_positionBuffer.data; + var particleFlags = 0; + for (var i = firstIndex; i < lastIndex; i++) particleFlags |= this.m_flagsBuffer.data[i]; + if (particleFlags & b2ParticleSystem.k_pairFlags) for (var k = 0; k < this.m_contactBuffer.count; k++) { + var contact = this.m_contactBuffer.data[k]; + var a = contact.indexA; + var b = contact.indexB; + var af = this.m_flagsBuffer.data[a]; + var bf = this.m_flagsBuffer.data[b]; + var groupA = this.m_groupBuffer[a]; + var groupB = this.m_groupBuffer[b]; + if (a >= firstIndex && a < lastIndex && b >= firstIndex && b < lastIndex && !((af | bf) & exports.b2ParticleFlag.b2_zombieParticle) && (af | bf) & b2ParticleSystem.k_pairFlags && (filter.IsNecessary(a) || filter.IsNecessary(b)) && b2ParticleSystem.ParticleCanBeConnected(af, groupA) && b2ParticleSystem.ParticleCanBeConnected(bf, groupB) && filter.ShouldCreatePair(a, b)) { + var pair = this.m_pairBuffer.data[this.m_pairBuffer.Append()]; + pair.indexA = a; + pair.indexB = b; + pair.flags = contact.flags; + pair.strength = b2Min(groupA ? groupA.m_strength : 1, groupB ? groupB.m_strength : 1); + pair.distance = b2Vec2.DistanceVV(pos_data[a], pos_data[b]); + } + std_stable_sort(this.m_pairBuffer.data, 0, this.m_pairBuffer.count, b2ParticleSystem.ComparePairIndices); + this.m_pairBuffer.Unique(b2ParticleSystem.MatchPairIndices); + } + if (particleFlags & b2ParticleSystem.k_triadFlags) { + var diagram = new b2VoronoiDiagram(lastIndex - firstIndex); + for (var i = firstIndex; i < lastIndex; i++) { + var flags = this.m_flagsBuffer.data[i]; + var group = this.m_groupBuffer[i]; + flags & exports.b2ParticleFlag.b2_zombieParticle || !b2ParticleSystem.ParticleCanBeConnected(flags, group) || diagram.AddGenerator(pos_data[i], i, filter.IsNecessary(i)); + } + var stride = this.GetParticleStride(); + diagram.Generate(stride / 2, 2 * stride); + var system_1 = this; + var callback = function callback(a, b, c) { + if (!system_1.m_flagsBuffer.data) throw new Error(); + var af = system_1.m_flagsBuffer.data[a]; + var bf = system_1.m_flagsBuffer.data[b]; + var cf = system_1.m_flagsBuffer.data[c]; + if ((af | bf | cf) & b2ParticleSystem.k_triadFlags && filter.ShouldCreateTriad(a, b, c)) { + var pa = pos_data[a]; + var pb = pos_data[b]; + var pc = pos_data[c]; + var dab = b2Vec2.SubVV(pa, pb, s_dab); + var dbc = b2Vec2.SubVV(pb, pc, s_dbc); + var dca = b2Vec2.SubVV(pc, pa, s_dca); + var maxDistanceSquared = b2_maxTriadDistanceSquared * system_1.m_squaredDiameter; + if (b2Vec2.DotVV(dab, dab) > maxDistanceSquared || b2Vec2.DotVV(dbc, dbc) > maxDistanceSquared || b2Vec2.DotVV(dca, dca) > maxDistanceSquared) return; + var groupA = system_1.m_groupBuffer[a]; + var groupB = system_1.m_groupBuffer[b]; + var groupC = system_1.m_groupBuffer[c]; + var triad = system_1.m_triadBuffer.data[system_1.m_triadBuffer.Append()]; + triad.indexA = a; + triad.indexB = b; + triad.indexC = c; + triad.flags = af | bf | cf; + triad.strength = b2Min(b2Min(groupA ? groupA.m_strength : 1, groupB ? groupB.m_strength : 1), groupC ? groupC.m_strength : 1); + var midPoint_x = (pa.x + pb.x + pc.x) / 3; + var midPoint_y = (pa.y + pb.y + pc.y) / 3; + triad.pa.x = pa.x - midPoint_x; + triad.pa.y = pa.y - midPoint_y; + triad.pb.x = pb.x - midPoint_x; + triad.pb.y = pb.y - midPoint_y; + triad.pc.x = pc.x - midPoint_x; + triad.pc.y = pc.y - midPoint_y; + triad.ka = -b2Vec2.DotVV(dca, dab); + triad.kb = -b2Vec2.DotVV(dab, dbc); + triad.kc = -b2Vec2.DotVV(dbc, dca); + triad.s = b2Vec2.CrossVV(pa, pb) + b2Vec2.CrossVV(pb, pc) + b2Vec2.CrossVV(pc, pa); + } + }; + diagram.GetNodes(callback); + std_stable_sort(this.m_triadBuffer.data, 0, this.m_triadBuffer.count, b2ParticleSystem.CompareTriadIndices); + this.m_triadBuffer.Unique(b2ParticleSystem.MatchTriadIndices); + } + }; + b2ParticleSystem.prototype.UpdatePairsAndTriadsWithReactiveParticles = function() { + var filter = new b2ParticleSystem.ReactiveFilter(this.m_flagsBuffer); + this.UpdatePairsAndTriads(0, this.m_count, filter); + if (!this.m_flagsBuffer.data) throw new Error(); + for (var i = 0; i < this.m_count; i++) this.m_flagsBuffer.data[i] &= ~exports.b2ParticleFlag.b2_reactiveParticle; + this.m_allParticleFlags &= ~exports.b2ParticleFlag.b2_reactiveParticle; + }; + b2ParticleSystem.ComparePairIndices = function(a, b) { + var diffA = a.indexA - b.indexA; + if (0 !== diffA) return diffA < 0; + return a.indexB < b.indexB; + }; + b2ParticleSystem.MatchPairIndices = function(a, b) { + return a.indexA === b.indexA && a.indexB === b.indexB; + }; + b2ParticleSystem.CompareTriadIndices = function(a, b) { + var diffA = a.indexA - b.indexA; + if (0 !== diffA) return diffA < 0; + var diffB = a.indexB - b.indexB; + if (0 !== diffB) return diffB < 0; + return a.indexC < b.indexC; + }; + b2ParticleSystem.MatchTriadIndices = function(a, b) { + return a.indexA === b.indexA && a.indexB === b.indexB && a.indexC === b.indexC; + }; + b2ParticleSystem.InitializeParticleLists = function(group, nodeBuffer) { + var bufferIndex = group.GetBufferIndex(); + var particleCount = group.GetParticleCount(); + for (var i = 0; i < particleCount; i++) { + var node = nodeBuffer[i]; + node.list = node; + node.next = null; + node.count = 1; + node.index = i + bufferIndex; + } + }; + b2ParticleSystem.prototype.MergeParticleListsInContact = function(group, nodeBuffer) { + var bufferIndex = group.GetBufferIndex(); + for (var k = 0; k < this.m_contactBuffer.count; k++) { + var contact = this.m_contactBuffer.data[k]; + var a = contact.indexA; + var b = contact.indexB; + if (!group.ContainsParticle(a) || !group.ContainsParticle(b)) continue; + var listA = nodeBuffer[a - bufferIndex].list; + var listB = nodeBuffer[b - bufferIndex].list; + if (listA === listB) continue; + if (listA.count < listB.count) { + var _tmp = listA; + listA = listB; + listB = _tmp; + } + b2ParticleSystem.MergeParticleLists(listA, listB); + } + }; + b2ParticleSystem.MergeParticleLists = function(listA, listB) { + for (var b = listB; ;) { + b.list = listA; + var nextB = b.next; + if (!nextB) { + b.next = listA.next; + break; + } + b = nextB; + } + listA.next = listB; + listA.count += listB.count; + listB.count = 0; + }; + b2ParticleSystem.FindLongestParticleList = function(group, nodeBuffer) { + var particleCount = group.GetParticleCount(); + var result = nodeBuffer[0]; + for (var i = 0; i < particleCount; i++) { + var node = nodeBuffer[i]; + result.count < node.count && (result = node); + } + return result; + }; + b2ParticleSystem.prototype.MergeZombieParticleListNodes = function(group, nodeBuffer, survivingList) { + if (!this.m_flagsBuffer.data) throw new Error(); + var particleCount = group.GetParticleCount(); + for (var i = 0; i < particleCount; i++) { + var node = nodeBuffer[i]; + node !== survivingList && this.m_flagsBuffer.data[node.index] & exports.b2ParticleFlag.b2_zombieParticle && b2ParticleSystem.MergeParticleListAndNode(survivingList, node); + } + }; + b2ParticleSystem.MergeParticleListAndNode = function(list, node) { + node.list = list; + node.next = list.next; + list.next = node; + list.count++; + node.count = 0; + }; + b2ParticleSystem.prototype.CreateParticleGroupsFromParticleList = function(group, nodeBuffer, survivingList) { + if (!this.m_flagsBuffer.data) throw new Error(); + var particleCount = group.GetParticleCount(); + var def = new b2ParticleGroupDef(); + def.groupFlags = group.GetGroupFlags(); + def.userData = group.GetUserData(); + for (var i = 0; i < particleCount; i++) { + var list = nodeBuffer[i]; + if (!list.count || list === survivingList) continue; + var newGroup = this.CreateParticleGroup(def); + for (var node = list; node; node = node.next) { + var oldIndex = node.index; + var newIndex = this.CloneParticle(oldIndex, newGroup); + this.m_flagsBuffer.data[oldIndex] |= exports.b2ParticleFlag.b2_zombieParticle; + node.index = newIndex; + } + } + }; + b2ParticleSystem.prototype.UpdatePairsAndTriadsWithParticleList = function(group, nodeBuffer) { + var bufferIndex = group.GetBufferIndex(); + for (var k = 0; k < this.m_pairBuffer.count; k++) { + var pair = this.m_pairBuffer.data[k]; + var a = pair.indexA; + var b = pair.indexB; + group.ContainsParticle(a) && (pair.indexA = nodeBuffer[a - bufferIndex].index); + group.ContainsParticle(b) && (pair.indexB = nodeBuffer[b - bufferIndex].index); + } + for (var k = 0; k < this.m_triadBuffer.count; k++) { + var triad = this.m_triadBuffer.data[k]; + var a = triad.indexA; + var b = triad.indexB; + var c = triad.indexC; + group.ContainsParticle(a) && (triad.indexA = nodeBuffer[a - bufferIndex].index); + group.ContainsParticle(b) && (triad.indexB = nodeBuffer[b - bufferIndex].index); + group.ContainsParticle(c) && (triad.indexC = nodeBuffer[c - bufferIndex].index); + } + }; + b2ParticleSystem.prototype.ComputeDepth = function() { + var contactGroups = []; + var contactGroupsCount = 0; + for (var k = 0; k < this.m_contactBuffer.count; k++) { + var contact = this.m_contactBuffer.data[k]; + var a = contact.indexA; + var b = contact.indexB; + var groupA = this.m_groupBuffer[a]; + var groupB = this.m_groupBuffer[b]; + groupA && groupA === groupB && groupA.m_groupFlags & exports.b2ParticleGroupFlag.b2_particleGroupNeedsUpdateDepth && (contactGroups[contactGroupsCount++] = contact); + } + var groupsToUpdate = []; + var groupsToUpdateCount = 0; + for (var group = this.m_groupList; group; group = group.GetNext()) if (group.m_groupFlags & exports.b2ParticleGroupFlag.b2_particleGroupNeedsUpdateDepth) { + groupsToUpdate[groupsToUpdateCount++] = group; + this.SetGroupFlags(group, group.m_groupFlags & ~exports.b2ParticleGroupFlag.b2_particleGroupNeedsUpdateDepth); + for (var i = group.m_firstIndex; i < group.m_lastIndex; i++) this.m_accumulationBuffer[i] = 0; + } + for (var k = 0; k < contactGroupsCount; k++) { + var contact = contactGroups[k]; + var a = contact.indexA; + var b = contact.indexB; + var w = contact.weight; + this.m_accumulationBuffer[a] += w; + this.m_accumulationBuffer[b] += w; + } + for (var i = 0; i < groupsToUpdateCount; i++) { + var group = groupsToUpdate[i]; + for (var i_1 = group.m_firstIndex; i_1 < group.m_lastIndex; i_1++) { + var w = this.m_accumulationBuffer[i_1]; + this.m_depthBuffer[i_1] = w < .8 ? 0 : b2_maxFloat; + } + } + var iterationCount = b2Sqrt(this.m_count) >> 0; + for (var t = 0; t < iterationCount; t++) { + var updated = false; + for (var k = 0; k < contactGroupsCount; k++) { + var contact = contactGroups[k]; + var a = contact.indexA; + var b = contact.indexB; + var r = 1 - contact.weight; + var ap0 = this.m_depthBuffer[a]; + var bp0 = this.m_depthBuffer[b]; + var ap1 = bp0 + r; + var bp1 = ap0 + r; + if (ap0 > ap1) { + this.m_depthBuffer[a] = ap1; + updated = true; + } + if (bp0 > bp1) { + this.m_depthBuffer[b] = bp1; + updated = true; + } + } + if (!updated) break; + } + for (var i = 0; i < groupsToUpdateCount; i++) { + var group = groupsToUpdate[i]; + for (var i_2 = group.m_firstIndex; i_2 < group.m_lastIndex; i_2++) this.m_depthBuffer[i_2] < b2_maxFloat ? this.m_depthBuffer[i_2] *= this.m_particleDiameter : this.m_depthBuffer[i_2] = 0; + } + }; + b2ParticleSystem.prototype.GetInsideBoundsEnumerator = function(aabb) { + var lowerTag = b2ParticleSystem.computeTag(this.m_inverseDiameter * aabb.lowerBound.x - 1, this.m_inverseDiameter * aabb.lowerBound.y - 1); + var upperTag = b2ParticleSystem.computeTag(this.m_inverseDiameter * aabb.upperBound.x + 1, this.m_inverseDiameter * aabb.upperBound.y + 1); + var beginProxy = 0; + var endProxy = this.m_proxyBuffer.count; + var firstProxy = std_lower_bound(this.m_proxyBuffer.data, beginProxy, endProxy, lowerTag, b2ParticleSystem.Proxy.CompareProxyTag); + var lastProxy = std_upper_bound(this.m_proxyBuffer.data, beginProxy, endProxy, upperTag, b2ParticleSystem.Proxy.CompareTagProxy); + return new b2ParticleSystem.InsideBoundsEnumerator(this, lowerTag, upperTag, firstProxy, lastProxy); + }; + b2ParticleSystem.prototype.UpdateAllParticleFlags = function() { + if (!this.m_flagsBuffer.data) throw new Error(); + this.m_allParticleFlags = 0; + for (var i = 0; i < this.m_count; i++) this.m_allParticleFlags |= this.m_flagsBuffer.data[i]; + this.m_needsUpdateAllParticleFlags = false; + }; + b2ParticleSystem.prototype.UpdateAllGroupFlags = function() { + this.m_allGroupFlags = 0; + for (var group = this.m_groupList; group; group = group.GetNext()) this.m_allGroupFlags |= group.m_groupFlags; + this.m_needsUpdateAllGroupFlags = false; + }; + b2ParticleSystem.prototype.AddContact = function(a, b, contacts) { + if (!this.m_flagsBuffer.data) throw new Error(); + if (!this.m_positionBuffer.data) throw new Error(); + var s_d = b2ParticleSystem.AddContact_s_d; + var pos_data = this.m_positionBuffer.data; + var d = b2Vec2.SubVV(pos_data[b], pos_data[a], s_d); + var distBtParticlesSq = b2Vec2.DotVV(d, d); + if (distBtParticlesSq < this.m_squaredDiameter) { + var invD = b2InvSqrt(distBtParticlesSq); + isFinite(invD) || (invD = 198177537e11); + var contact = this.m_contactBuffer.data[this.m_contactBuffer.Append()]; + contact.indexA = a; + contact.indexB = b; + contact.flags = this.m_flagsBuffer.data[a] | this.m_flagsBuffer.data[b]; + contact.weight = 1 - distBtParticlesSq * invD * this.m_inverseDiameter; + b2Vec2.MulSV(invD, d, contact.normal); + } + }; + b2ParticleSystem.prototype.FindContacts_Reference = function(contacts) { + var beginProxy = 0; + var endProxy = this.m_proxyBuffer.count; + this.m_contactBuffer.count = 0; + for (var a = beginProxy, c = beginProxy; a < endProxy; a++) { + var rightTag = b2ParticleSystem.computeRelativeTag(this.m_proxyBuffer.data[a].tag, 1, 0); + for (var b = a + 1; b < endProxy; b++) { + if (rightTag < this.m_proxyBuffer.data[b].tag) break; + this.AddContact(this.m_proxyBuffer.data[a].index, this.m_proxyBuffer.data[b].index, this.m_contactBuffer); + } + var bottomLeftTag = b2ParticleSystem.computeRelativeTag(this.m_proxyBuffer.data[a].tag, -1, 1); + for (;c < endProxy; c++) if (bottomLeftTag <= this.m_proxyBuffer.data[c].tag) break; + var bottomRightTag = b2ParticleSystem.computeRelativeTag(this.m_proxyBuffer.data[a].tag, 1, 1); + for (var b = c; b < endProxy; b++) { + if (bottomRightTag < this.m_proxyBuffer.data[b].tag) break; + this.AddContact(this.m_proxyBuffer.data[a].index, this.m_proxyBuffer.data[b].index, this.m_contactBuffer); + } + } + }; + b2ParticleSystem.prototype.FindContacts = function(contacts) { + this.FindContacts_Reference(contacts); + }; + b2ParticleSystem.prototype.UpdateProxies_Reference = function(proxies) { + if (!this.m_positionBuffer.data) throw new Error(); + var pos_data = this.m_positionBuffer.data; + var inv_diam = this.m_inverseDiameter; + for (var k = 0; k < this.m_proxyBuffer.count; ++k) { + var proxy = this.m_proxyBuffer.data[k]; + var i = proxy.index; + var p = pos_data[i]; + proxy.tag = b2ParticleSystem.computeTag(inv_diam * p.x, inv_diam * p.y); + } + }; + b2ParticleSystem.prototype.UpdateProxies = function(proxies) { + this.UpdateProxies_Reference(proxies); + }; + b2ParticleSystem.prototype.SortProxies = function(proxies) { + std_sort(this.m_proxyBuffer.data, 0, this.m_proxyBuffer.count, b2ParticleSystem.Proxy.CompareProxyProxy); + }; + b2ParticleSystem.prototype.FilterContacts = function(contacts) { + var contactFilter = this.GetParticleContactFilter(); + if (null === contactFilter) return; + var system = this; + var predicate = function predicate(contact) { + return 0 !== (contact.flags & exports.b2ParticleFlag.b2_particleContactFilterParticle) && !contactFilter.ShouldCollideParticleParticle(system, contact.indexA, contact.indexB); + }; + this.m_contactBuffer.RemoveIf(predicate); + }; + b2ParticleSystem.prototype.NotifyContactListenerPreContact = function(particlePairs) { + var contactListener = this.GetParticleContactListener(); + if (null === contactListener) return; + particlePairs.Initialize(this.m_contactBuffer, this.m_flagsBuffer); + throw new Error(); + }; + b2ParticleSystem.prototype.NotifyContactListenerPostContact = function(particlePairs) { + var contactListener = this.GetParticleContactListener(); + if (null === contactListener) return; + for (var k = 0; k < this.m_contactBuffer.count; ++k) { + var contact = this.m_contactBuffer.data[k]; + contactListener.BeginContactParticleParticle(this, contact); + } + throw new Error(); + }; + b2ParticleSystem.b2ParticleContactIsZombie = function(contact) { + return (contact.flags & exports.b2ParticleFlag.b2_zombieParticle) === exports.b2ParticleFlag.b2_zombieParticle; + }; + b2ParticleSystem.prototype.UpdateContacts = function(exceptZombie) { + this.UpdateProxies(this.m_proxyBuffer); + this.SortProxies(this.m_proxyBuffer); + var particlePairs = new b2ParticleSystem.b2ParticlePairSet(); + this.NotifyContactListenerPreContact(particlePairs); + this.FindContacts(this.m_contactBuffer); + this.FilterContacts(this.m_contactBuffer); + this.NotifyContactListenerPostContact(particlePairs); + exceptZombie && this.m_contactBuffer.RemoveIf(b2ParticleSystem.b2ParticleContactIsZombie); + }; + b2ParticleSystem.prototype.NotifyBodyContactListenerPreContact = function(fixtureSet) { + var contactListener = this.GetFixtureContactListener(); + if (null === contactListener) return; + fixtureSet.Initialize(this.m_bodyContactBuffer, this.m_flagsBuffer); + throw new Error(); + }; + b2ParticleSystem.prototype.NotifyBodyContactListenerPostContact = function(fixtureSet) { + var contactListener = this.GetFixtureContactListener(); + if (null === contactListener) return; + for (var k = 0; k < this.m_bodyContactBuffer.count; k++) { + var contact = this.m_bodyContactBuffer.data[k]; + contactListener.BeginContactFixtureParticle(this, contact); + } + throw new Error(); + }; + b2ParticleSystem.prototype.UpdateBodyContacts = function() { + var s_aabb = b2ParticleSystem.UpdateBodyContacts_s_aabb; + var fixtureSet = new b2ParticleSystem.FixtureParticleSet(); + this.NotifyBodyContactListenerPreContact(fixtureSet); + if (this.m_stuckThreshold > 0) { + if (!this.m_bodyContactCountBuffer.data) throw new Error(); + if (!this.m_lastBodyContactStepBuffer.data) throw new Error(); + if (!this.m_consecutiveContactStepsBuffer.data) throw new Error(); + var particleCount = this.GetParticleCount(); + for (var i = 0; i < particleCount; i++) { + this.m_bodyContactCountBuffer.data[i] = 0; + this.m_timestamp > this.m_lastBodyContactStepBuffer.data[i] + 1 && (this.m_consecutiveContactStepsBuffer.data[i] = 0); + } + } + this.m_bodyContactBuffer.SetCount(0); + this.m_stuckParticleBuffer.SetCount(0); + var aabb = s_aabb; + this.ComputeAABB(aabb); + var callback = new b2ParticleSystem.UpdateBodyContactsCallback(this, this.GetFixtureContactFilter()); + this.m_world.QueryAABB(callback, aabb); + this.m_def.strictContactCheck && this.RemoveSpuriousBodyContacts(); + this.NotifyBodyContactListenerPostContact(fixtureSet); + }; + b2ParticleSystem.prototype.Solve = function(step) { + var s_subStep = b2ParticleSystem.Solve_s_subStep; + if (0 === this.m_count) return; + this.m_expirationTimeBuffer.data && this.SolveLifetimes(step); + this.m_allParticleFlags & exports.b2ParticleFlag.b2_zombieParticle && this.SolveZombie(); + this.m_needsUpdateAllParticleFlags && this.UpdateAllParticleFlags(); + this.m_needsUpdateAllGroupFlags && this.UpdateAllGroupFlags(); + if (this.m_paused) return; + for (this.m_iterationIndex = 0; this.m_iterationIndex < step.particleIterations; this.m_iterationIndex++) { + ++this.m_timestamp; + var subStep = s_subStep.Copy(step); + subStep.dt /= step.particleIterations; + subStep.inv_dt *= step.particleIterations; + this.UpdateContacts(false); + this.UpdateBodyContacts(); + this.ComputeWeight(); + this.m_allGroupFlags & exports.b2ParticleGroupFlag.b2_particleGroupNeedsUpdateDepth && this.ComputeDepth(); + this.m_allParticleFlags & exports.b2ParticleFlag.b2_reactiveParticle && this.UpdatePairsAndTriadsWithReactiveParticles(); + this.m_hasForce && this.SolveForce(subStep); + this.m_allParticleFlags & exports.b2ParticleFlag.b2_viscousParticle && this.SolveViscous(); + this.m_allParticleFlags & exports.b2ParticleFlag.b2_repulsiveParticle && this.SolveRepulsive(subStep); + this.m_allParticleFlags & exports.b2ParticleFlag.b2_powderParticle && this.SolvePowder(subStep); + this.m_allParticleFlags & exports.b2ParticleFlag.b2_tensileParticle && this.SolveTensile(subStep); + this.m_allGroupFlags & exports.b2ParticleGroupFlag.b2_solidParticleGroup && this.SolveSolid(subStep); + this.m_allParticleFlags & exports.b2ParticleFlag.b2_colorMixingParticle && this.SolveColorMixing(); + this.SolveGravity(subStep); + this.m_allParticleFlags & exports.b2ParticleFlag.b2_staticPressureParticle && this.SolveStaticPressure(subStep); + this.SolvePressure(subStep); + this.SolveDamping(subStep); + this.m_allParticleFlags & b2ParticleSystem.k_extraDampingFlags && this.SolveExtraDamping(); + this.m_allParticleFlags & exports.b2ParticleFlag.b2_elasticParticle && this.SolveElastic(subStep); + this.m_allParticleFlags & exports.b2ParticleFlag.b2_springParticle && this.SolveSpring(subStep); + this.LimitVelocity(subStep); + this.m_allGroupFlags & exports.b2ParticleGroupFlag.b2_rigidParticleGroup && this.SolveRigidDamping(); + this.m_allParticleFlags & exports.b2ParticleFlag.b2_barrierParticle && this.SolveBarrier(subStep); + this.SolveCollision(subStep); + this.m_allGroupFlags & exports.b2ParticleGroupFlag.b2_rigidParticleGroup && this.SolveRigid(subStep); + this.m_allParticleFlags & exports.b2ParticleFlag.b2_wallParticle && this.SolveWall(); + if (!this.m_positionBuffer.data) throw new Error(); + if (!this.m_velocityBuffer.data) throw new Error(); + for (var i = 0; i < this.m_count; i++) this.m_positionBuffer.data[i].SelfMulAdd(subStep.dt, this.m_velocityBuffer.data[i]); + } + }; + b2ParticleSystem.prototype.SolveCollision = function(step) { + var s_aabb = b2ParticleSystem.SolveCollision_s_aabb; + if (!this.m_positionBuffer.data) throw new Error(); + if (!this.m_velocityBuffer.data) throw new Error(); + var pos_data = this.m_positionBuffer.data; + var vel_data = this.m_velocityBuffer.data; + var aabb = s_aabb; + aabb.lowerBound.x = +b2_maxFloat; + aabb.lowerBound.y = +b2_maxFloat; + aabb.upperBound.x = -b2_maxFloat; + aabb.upperBound.y = -b2_maxFloat; + for (var i = 0; i < this.m_count; i++) { + var v = vel_data[i]; + var p1 = pos_data[i]; + var p2_x = p1.x + step.dt * v.x; + var p2_y = p1.y + step.dt * v.y; + aabb.lowerBound.x = b2Min(aabb.lowerBound.x, b2Min(p1.x, p2_x)); + aabb.lowerBound.y = b2Min(aabb.lowerBound.y, b2Min(p1.y, p2_y)); + aabb.upperBound.x = b2Max(aabb.upperBound.x, b2Max(p1.x, p2_x)); + aabb.upperBound.y = b2Max(aabb.upperBound.y, b2Max(p1.y, p2_y)); + } + var callback = new b2ParticleSystem.SolveCollisionCallback(this, step); + this.m_world.QueryAABB(callback, aabb); + }; + b2ParticleSystem.prototype.LimitVelocity = function(step) { + if (!this.m_velocityBuffer.data) throw new Error(); + var vel_data = this.m_velocityBuffer.data; + var criticalVelocitySquared = this.GetCriticalVelocitySquared(step); + for (var i = 0; i < this.m_count; i++) { + var v = vel_data[i]; + var v2 = b2Vec2.DotVV(v, v); + v2 > criticalVelocitySquared && v.SelfMul(b2Sqrt(criticalVelocitySquared / v2)); + } + }; + b2ParticleSystem.prototype.SolveGravity = function(step) { + if (!this.m_velocityBuffer.data) throw new Error(); + var s_gravity = b2ParticleSystem.SolveGravity_s_gravity; + var vel_data = this.m_velocityBuffer.data; + var gravity = b2Vec2.MulSV(step.dt * this.m_def.gravityScale, this.m_world.GetGravity(), s_gravity); + for (var i = 0; i < this.m_count; i++) vel_data[i].SelfAdd(gravity); + }; + b2ParticleSystem.prototype.SolveBarrier = function(step) { + var s_aabb = b2ParticleSystem.SolveBarrier_s_aabb; + var s_va = b2ParticleSystem.SolveBarrier_s_va; + var s_vb = b2ParticleSystem.SolveBarrier_s_vb; + var s_pba = b2ParticleSystem.SolveBarrier_s_pba; + var s_vba = b2ParticleSystem.SolveBarrier_s_vba; + var s_vc = b2ParticleSystem.SolveBarrier_s_vc; + var s_pca = b2ParticleSystem.SolveBarrier_s_pca; + var s_vca = b2ParticleSystem.SolveBarrier_s_vca; + var s_qba = b2ParticleSystem.SolveBarrier_s_qba; + var s_qca = b2ParticleSystem.SolveBarrier_s_qca; + var s_dv = b2ParticleSystem.SolveBarrier_s_dv; + var s_f = b2ParticleSystem.SolveBarrier_s_f; + if (!this.m_flagsBuffer.data) throw new Error(); + if (!this.m_positionBuffer.data) throw new Error(); + if (!this.m_velocityBuffer.data) throw new Error(); + var pos_data = this.m_positionBuffer.data; + var vel_data = this.m_velocityBuffer.data; + for (var i = 0; i < this.m_count; i++) { + var flags = this.m_flagsBuffer.data[i]; + 0 !== (flags & b2ParticleSystem.k_barrierWallFlags) && vel_data[i].SetZero(); + } + var tmax = b2_barrierCollisionTime * step.dt; + var mass = this.GetParticleMass(); + for (var k = 0; k < this.m_pairBuffer.count; k++) { + var pair = this.m_pairBuffer.data[k]; + if (pair.flags & exports.b2ParticleFlag.b2_barrierParticle) { + var a = pair.indexA; + var b = pair.indexB; + var pa = pos_data[a]; + var pb = pos_data[b]; + var aabb = s_aabb; + b2Vec2.MinV(pa, pb, aabb.lowerBound); + b2Vec2.MaxV(pa, pb, aabb.upperBound); + var aGroup = this.m_groupBuffer[a]; + var bGroup = this.m_groupBuffer[b]; + var va = this.GetLinearVelocity(aGroup, a, pa, s_va); + var vb = this.GetLinearVelocity(bGroup, b, pb, s_vb); + var pba = b2Vec2.SubVV(pb, pa, s_pba); + var vba = b2Vec2.SubVV(vb, va, s_vba); + var enumerator = this.GetInsideBoundsEnumerator(aabb); + var c = void 0; + while ((c = enumerator.GetNext()) >= 0) { + var pc = pos_data[c]; + var cGroup = this.m_groupBuffer[c]; + if (aGroup !== cGroup && bGroup !== cGroup) { + var vc = this.GetLinearVelocity(cGroup, c, pc, s_vc); + var pca = b2Vec2.SubVV(pc, pa, s_pca); + var vca = b2Vec2.SubVV(vc, va, s_vca); + var e2 = b2Vec2.CrossVV(vba, vca); + var e1 = b2Vec2.CrossVV(pba, vca) - b2Vec2.CrossVV(pca, vba); + var e0 = b2Vec2.CrossVV(pba, pca); + var s = void 0, t = void 0; + var qba = s_qba, qca = s_qca; + if (0 === e2) { + if (0 === e1) continue; + t = -e0 / e1; + if (!(t >= 0 && t < tmax)) continue; + b2Vec2.AddVMulSV(pba, t, vba, qba); + b2Vec2.AddVMulSV(pca, t, vca, qca); + s = b2Vec2.DotVV(qba, qca) / b2Vec2.DotVV(qba, qba); + if (!(s >= 0 && s <= 1)) continue; + } else { + var det = e1 * e1 - 4 * e0 * e2; + if (det < 0) continue; + var sqrtDet = b2Sqrt(det); + var t1 = (-e1 - sqrtDet) / (2 * e2); + var t2 = (-e1 + sqrtDet) / (2 * e2); + if (t1 > t2) { + var tmp = t1; + t1 = t2; + t2 = tmp; + } + t = t1; + b2Vec2.AddVMulSV(pba, t, vba, qba); + b2Vec2.AddVMulSV(pca, t, vca, qca); + s = b2Vec2.DotVV(qba, qca) / b2Vec2.DotVV(qba, qba); + if (!(t >= 0 && t < tmax && s >= 0 && s <= 1)) { + t = t2; + if (!(t >= 0 && t < tmax)) continue; + b2Vec2.AddVMulSV(pba, t, vba, qba); + b2Vec2.AddVMulSV(pca, t, vca, qca); + s = b2Vec2.DotVV(qba, qca) / b2Vec2.DotVV(qba, qba); + if (!(s >= 0 && s <= 1)) continue; + } + } + var dv = s_dv; + dv.x = va.x + s * vba.x - vc.x; + dv.y = va.y + s * vba.y - vc.y; + var f = b2Vec2.MulSV(mass, dv, s_f); + if (cGroup && this.IsRigidGroup(cGroup)) { + var mass_1 = cGroup.GetMass(); + var inertia = cGroup.GetInertia(); + mass_1 > 0 && cGroup.m_linearVelocity.SelfMulAdd(1 / mass_1, f); + inertia > 0 && (cGroup.m_angularVelocity += b2Vec2.CrossVV(b2Vec2.SubVV(pc, cGroup.GetCenter(), b2Vec2.s_t0), f) / inertia); + } else vel_data[c].SelfAdd(dv); + this.ParticleApplyForce(c, f.SelfMul(-step.inv_dt)); + } + } + } + } + }; + b2ParticleSystem.prototype.SolveStaticPressure = function(step) { + if (!this.m_flagsBuffer.data) throw new Error(); + this.m_staticPressureBuffer = this.RequestBuffer(this.m_staticPressureBuffer); + var criticalPressure = this.GetCriticalPressure(step); + var pressurePerWeight = this.m_def.staticPressureStrength * criticalPressure; + var maxPressure = b2_maxParticlePressure * criticalPressure; + var relaxation = this.m_def.staticPressureRelaxation; + for (var t = 0; t < this.m_def.staticPressureIterations; t++) { + for (var i = 0; i < this.m_count; i++) this.m_accumulationBuffer[i] = 0; + for (var k = 0; k < this.m_contactBuffer.count; k++) { + var contact = this.m_contactBuffer.data[k]; + if (contact.flags & exports.b2ParticleFlag.b2_staticPressureParticle) { + var a = contact.indexA; + var b = contact.indexB; + var w = contact.weight; + this.m_accumulationBuffer[a] += w * this.m_staticPressureBuffer[b]; + this.m_accumulationBuffer[b] += w * this.m_staticPressureBuffer[a]; + } + } + for (var i = 0; i < this.m_count; i++) { + var w = this.m_weightBuffer[i]; + if (this.m_flagsBuffer.data[i] & exports.b2ParticleFlag.b2_staticPressureParticle) { + var wh = this.m_accumulationBuffer[i]; + var h = (wh + pressurePerWeight * (w - b2_minParticleWeight)) / (w + relaxation); + this.m_staticPressureBuffer[i] = b2Clamp(h, 0, maxPressure); + } else this.m_staticPressureBuffer[i] = 0; + } + } + }; + b2ParticleSystem.prototype.ComputeWeight = function() { + for (var k = 0; k < this.m_count; k++) this.m_weightBuffer[k] = 0; + for (var k = 0; k < this.m_bodyContactBuffer.count; k++) { + var contact = this.m_bodyContactBuffer.data[k]; + var a = contact.index; + var w = contact.weight; + this.m_weightBuffer[a] += w; + } + for (var k = 0; k < this.m_contactBuffer.count; k++) { + var contact = this.m_contactBuffer.data[k]; + var a = contact.indexA; + var b = contact.indexB; + var w = contact.weight; + this.m_weightBuffer[a] += w; + this.m_weightBuffer[b] += w; + } + }; + b2ParticleSystem.prototype.SolvePressure = function(step) { + var s_f = b2ParticleSystem.SolvePressure_s_f; + if (!this.m_flagsBuffer.data) throw new Error(); + if (!this.m_positionBuffer.data) throw new Error(); + if (!this.m_velocityBuffer.data) throw new Error(); + var pos_data = this.m_positionBuffer.data; + var vel_data = this.m_velocityBuffer.data; + var criticalPressure = this.GetCriticalPressure(step); + var pressurePerWeight = this.m_def.pressureStrength * criticalPressure; + var maxPressure = b2_maxParticlePressure * criticalPressure; + for (var i = 0; i < this.m_count; i++) { + var w = this.m_weightBuffer[i]; + var h = pressurePerWeight * b2Max(0, w - b2_minParticleWeight); + this.m_accumulationBuffer[i] = b2Min(h, maxPressure); + } + if (this.m_allParticleFlags & b2ParticleSystem.k_noPressureFlags) for (var i = 0; i < this.m_count; i++) this.m_flagsBuffer.data[i] & b2ParticleSystem.k_noPressureFlags && (this.m_accumulationBuffer[i] = 0); + if (this.m_allParticleFlags & exports.b2ParticleFlag.b2_staticPressureParticle) for (var i = 0; i < this.m_count; i++) this.m_flagsBuffer.data[i] & exports.b2ParticleFlag.b2_staticPressureParticle && (this.m_accumulationBuffer[i] += this.m_staticPressureBuffer[i]); + var velocityPerPressure = step.dt / (this.m_def.density * this.m_particleDiameter); + var inv_mass = this.GetParticleInvMass(); + for (var k = 0; k < this.m_bodyContactBuffer.count; k++) { + var contact = this.m_bodyContactBuffer.data[k]; + var a = contact.index; + var b = contact.body; + var w = contact.weight; + var m = contact.mass; + var n = contact.normal; + var p = pos_data[a]; + var h = this.m_accumulationBuffer[a] + pressurePerWeight * w; + var f = b2Vec2.MulSV(velocityPerPressure * w * m * h, n, s_f); + vel_data[a].SelfMulSub(inv_mass, f); + b.ApplyLinearImpulse(f, p, true); + } + for (var k = 0; k < this.m_contactBuffer.count; k++) { + var contact = this.m_contactBuffer.data[k]; + var a = contact.indexA; + var b = contact.indexB; + var w = contact.weight; + var n = contact.normal; + var h = this.m_accumulationBuffer[a] + this.m_accumulationBuffer[b]; + var f = b2Vec2.MulSV(velocityPerPressure * w * h, n, s_f); + vel_data[a].SelfSub(f); + vel_data[b].SelfAdd(f); + } + }; + b2ParticleSystem.prototype.SolveDamping = function(step) { + var s_v = b2ParticleSystem.SolveDamping_s_v; + var s_f = b2ParticleSystem.SolveDamping_s_f; + if (!this.m_positionBuffer.data) throw new Error(); + if (!this.m_velocityBuffer.data) throw new Error(); + var pos_data = this.m_positionBuffer.data; + var vel_data = this.m_velocityBuffer.data; + var linearDamping = this.m_def.dampingStrength; + var quadraticDamping = 1 / this.GetCriticalVelocity(step); + var inv_mass = this.GetParticleInvMass(); + for (var k = 0; k < this.m_bodyContactBuffer.count; k++) { + var contact = this.m_bodyContactBuffer.data[k]; + var a = contact.index; + var b = contact.body; + var w = contact.weight; + var m = contact.mass; + var n = contact.normal; + var p = pos_data[a]; + var v = b2Vec2.SubVV(b.GetLinearVelocityFromWorldPoint(p, b2Vec2.s_t0), vel_data[a], s_v); + var vn = b2Vec2.DotVV(v, n); + if (vn < 0) { + var damping = b2Max(linearDamping * w, b2Min(-quadraticDamping * vn, .5)); + var f = b2Vec2.MulSV(damping * m * vn, n, s_f); + vel_data[a].SelfMulAdd(inv_mass, f); + b.ApplyLinearImpulse(f.SelfNeg(), p, true); + } + } + for (var k = 0; k < this.m_contactBuffer.count; k++) { + var contact = this.m_contactBuffer.data[k]; + var a = contact.indexA; + var b = contact.indexB; + var w = contact.weight; + var n = contact.normal; + var v = b2Vec2.SubVV(vel_data[b], vel_data[a], s_v); + var vn = b2Vec2.DotVV(v, n); + if (vn < 0) { + var damping = b2Max(linearDamping * w, b2Min(-quadraticDamping * vn, .5)); + var f = b2Vec2.MulSV(damping * vn, n, s_f); + vel_data[a].SelfAdd(f); + vel_data[b].SelfSub(f); + } + } + }; + b2ParticleSystem.prototype.SolveRigidDamping = function() { + var s_t0 = b2ParticleSystem.SolveRigidDamping_s_t0; + var s_t1 = b2ParticleSystem.SolveRigidDamping_s_t1; + var s_p = b2ParticleSystem.SolveRigidDamping_s_p; + var s_v = b2ParticleSystem.SolveRigidDamping_s_v; + var invMassA = [ 0 ], invInertiaA = [ 0 ], tangentDistanceA = [ 0 ]; + var invMassB = [ 0 ], invInertiaB = [ 0 ], tangentDistanceB = [ 0 ]; + if (!this.m_positionBuffer.data) throw new Error(); + var pos_data = this.m_positionBuffer.data; + var damping = this.m_def.dampingStrength; + for (var k = 0; k < this.m_bodyContactBuffer.count; k++) { + var contact = this.m_bodyContactBuffer.data[k]; + var a = contact.index; + var aGroup = this.m_groupBuffer[a]; + if (aGroup && this.IsRigidGroup(aGroup)) { + var b = contact.body; + var n = contact.normal; + var w = contact.weight; + var p = pos_data[a]; + var v = b2Vec2.SubVV(b.GetLinearVelocityFromWorldPoint(p, s_t0), aGroup.GetLinearVelocityFromWorldPoint(p, s_t1), s_v); + var vn = b2Vec2.DotVV(v, n); + if (vn < 0) { + this.InitDampingParameterWithRigidGroupOrParticle(invMassA, invInertiaA, tangentDistanceA, true, aGroup, a, p, n); + this.InitDampingParameter(invMassB, invInertiaB, tangentDistanceB, b.GetMass(), b.GetInertia() - b.GetMass() * b.GetLocalCenter().LengthSquared(), b.GetWorldCenter(), p, n); + var f = damping * b2Min(w, 1) * this.ComputeDampingImpulse(invMassA[0], invInertiaA[0], tangentDistanceA[0], invMassB[0], invInertiaB[0], tangentDistanceB[0], vn); + this.ApplyDamping(invMassA[0], invInertiaA[0], tangentDistanceA[0], true, aGroup, a, f, n); + b.ApplyLinearImpulse(b2Vec2.MulSV(-f, n, b2Vec2.s_t0), p, true); + } + } + } + for (var k = 0; k < this.m_contactBuffer.count; k++) { + var contact = this.m_contactBuffer.data[k]; + var a = contact.indexA; + var b = contact.indexB; + var n = contact.normal; + var w = contact.weight; + var aGroup = this.m_groupBuffer[a]; + var bGroup = this.m_groupBuffer[b]; + var aRigid = this.IsRigidGroup(aGroup); + var bRigid = this.IsRigidGroup(bGroup); + if (aGroup !== bGroup && (aRigid || bRigid)) { + var p = b2Vec2.MidVV(pos_data[a], pos_data[b], s_p); + var v = b2Vec2.SubVV(this.GetLinearVelocity(bGroup, b, p, s_t0), this.GetLinearVelocity(aGroup, a, p, s_t1), s_v); + var vn = b2Vec2.DotVV(v, n); + if (vn < 0) { + this.InitDampingParameterWithRigidGroupOrParticle(invMassA, invInertiaA, tangentDistanceA, aRigid, aGroup, a, p, n); + this.InitDampingParameterWithRigidGroupOrParticle(invMassB, invInertiaB, tangentDistanceB, bRigid, bGroup, b, p, n); + var f = damping * w * this.ComputeDampingImpulse(invMassA[0], invInertiaA[0], tangentDistanceA[0], invMassB[0], invInertiaB[0], tangentDistanceB[0], vn); + this.ApplyDamping(invMassA[0], invInertiaA[0], tangentDistanceA[0], aRigid, aGroup, a, f, n); + this.ApplyDamping(invMassB[0], invInertiaB[0], tangentDistanceB[0], bRigid, bGroup, b, -f, n); + } + } + } + }; + b2ParticleSystem.prototype.SolveExtraDamping = function() { + var s_v = b2ParticleSystem.SolveExtraDamping_s_v; + var s_f = b2ParticleSystem.SolveExtraDamping_s_f; + if (!this.m_flagsBuffer.data) throw new Error(); + if (!this.m_positionBuffer.data) throw new Error(); + if (!this.m_velocityBuffer.data) throw new Error(); + var vel_data = this.m_velocityBuffer.data; + var pos_data = this.m_positionBuffer.data; + var inv_mass = this.GetParticleInvMass(); + for (var k = 0; k < this.m_bodyContactBuffer.count; k++) { + var contact = this.m_bodyContactBuffer.data[k]; + var a = contact.index; + if (this.m_flagsBuffer.data[a] & b2ParticleSystem.k_extraDampingFlags) { + var b = contact.body; + var m = contact.mass; + var n = contact.normal; + var p = pos_data[a]; + var v = b2Vec2.SubVV(b.GetLinearVelocityFromWorldPoint(p, b2Vec2.s_t0), vel_data[a], s_v); + var vn = b2Vec2.DotVV(v, n); + if (vn < 0) { + var f = b2Vec2.MulSV(.5 * m * vn, n, s_f); + vel_data[a].SelfMulAdd(inv_mass, f); + b.ApplyLinearImpulse(f.SelfNeg(), p, true); + } + } + } + }; + b2ParticleSystem.prototype.SolveWall = function() { + if (!this.m_flagsBuffer.data) throw new Error(); + if (!this.m_velocityBuffer.data) throw new Error(); + var vel_data = this.m_velocityBuffer.data; + for (var i = 0; i < this.m_count; i++) this.m_flagsBuffer.data[i] & exports.b2ParticleFlag.b2_wallParticle && vel_data[i].SetZero(); + }; + b2ParticleSystem.prototype.SolveRigid = function(step) { + var s_position = b2ParticleSystem.SolveRigid_s_position; + var s_rotation = b2ParticleSystem.SolveRigid_s_rotation; + var s_transform = b2ParticleSystem.SolveRigid_s_transform; + var s_velocityTransform = b2ParticleSystem.SolveRigid_s_velocityTransform; + if (!this.m_positionBuffer.data) throw new Error(); + if (!this.m_velocityBuffer.data) throw new Error(); + var pos_data = this.m_positionBuffer.data; + var vel_data = this.m_velocityBuffer.data; + for (var group = this.m_groupList; group; group = group.GetNext()) if (group.m_groupFlags & exports.b2ParticleGroupFlag.b2_rigidParticleGroup) { + group.UpdateStatistics(); + var rotation = s_rotation; + rotation.SetAngle(step.dt * group.m_angularVelocity); + var position = b2Vec2.AddVV(group.m_center, b2Vec2.SubVV(b2Vec2.MulSV(step.dt, group.m_linearVelocity, b2Vec2.s_t0), b2Rot.MulRV(rotation, group.m_center, b2Vec2.s_t1), b2Vec2.s_t0), s_position); + var transform = s_transform; + transform.SetPositionRotation(position, rotation); + b2Transform.MulXX(transform, group.m_transform, group.m_transform); + var velocityTransform = s_velocityTransform; + velocityTransform.p.x = step.inv_dt * transform.p.x; + velocityTransform.p.y = step.inv_dt * transform.p.y; + velocityTransform.q.s = step.inv_dt * transform.q.s; + velocityTransform.q.c = step.inv_dt * (transform.q.c - 1); + for (var i = group.m_firstIndex; i < group.m_lastIndex; i++) b2Transform.MulXV(velocityTransform, pos_data[i], vel_data[i]); + } + }; + b2ParticleSystem.prototype.SolveElastic = function(step) { + var s_pa = b2ParticleSystem.SolveElastic_s_pa; + var s_pb = b2ParticleSystem.SolveElastic_s_pb; + var s_pc = b2ParticleSystem.SolveElastic_s_pc; + var s_r = b2ParticleSystem.SolveElastic_s_r; + var s_t0 = b2ParticleSystem.SolveElastic_s_t0; + if (!this.m_positionBuffer.data) throw new Error(); + if (!this.m_velocityBuffer.data) throw new Error(); + var pos_data = this.m_positionBuffer.data; + var vel_data = this.m_velocityBuffer.data; + var elasticStrength = step.inv_dt * this.m_def.elasticStrength; + for (var k = 0; k < this.m_triadBuffer.count; k++) { + var triad = this.m_triadBuffer.data[k]; + if (triad.flags & exports.b2ParticleFlag.b2_elasticParticle) { + var a = triad.indexA; + var b = triad.indexB; + var c = triad.indexC; + var oa = triad.pa; + var ob = triad.pb; + var oc = triad.pc; + var pa = s_pa.Copy(pos_data[a]); + var pb = s_pb.Copy(pos_data[b]); + var pc = s_pc.Copy(pos_data[c]); + var va = vel_data[a]; + var vb = vel_data[b]; + var vc = vel_data[c]; + pa.SelfMulAdd(step.dt, va); + pb.SelfMulAdd(step.dt, vb); + pc.SelfMulAdd(step.dt, vc); + var midPoint_x = (pa.x + pb.x + pc.x) / 3; + var midPoint_y = (pa.y + pb.y + pc.y) / 3; + pa.x -= midPoint_x; + pa.y -= midPoint_y; + pb.x -= midPoint_x; + pb.y -= midPoint_y; + pc.x -= midPoint_x; + pc.y -= midPoint_y; + var r = s_r; + r.s = b2Vec2.CrossVV(oa, pa) + b2Vec2.CrossVV(ob, pb) + b2Vec2.CrossVV(oc, pc); + r.c = b2Vec2.DotVV(oa, pa) + b2Vec2.DotVV(ob, pb) + b2Vec2.DotVV(oc, pc); + var r2 = r.s * r.s + r.c * r.c; + var invR = b2InvSqrt(r2); + isFinite(invR) || (invR = 198177537e11); + r.s *= invR; + r.c *= invR; + var strength = elasticStrength * triad.strength; + b2Rot.MulRV(r, oa, s_t0); + b2Vec2.SubVV(s_t0, pa, s_t0); + b2Vec2.MulSV(strength, s_t0, s_t0); + va.SelfAdd(s_t0); + b2Rot.MulRV(r, ob, s_t0); + b2Vec2.SubVV(s_t0, pb, s_t0); + b2Vec2.MulSV(strength, s_t0, s_t0); + vb.SelfAdd(s_t0); + b2Rot.MulRV(r, oc, s_t0); + b2Vec2.SubVV(s_t0, pc, s_t0); + b2Vec2.MulSV(strength, s_t0, s_t0); + vc.SelfAdd(s_t0); + } + } + }; + b2ParticleSystem.prototype.SolveSpring = function(step) { + var s_pa = b2ParticleSystem.SolveSpring_s_pa; + var s_pb = b2ParticleSystem.SolveSpring_s_pb; + var s_d = b2ParticleSystem.SolveSpring_s_d; + var s_f = b2ParticleSystem.SolveSpring_s_f; + if (!this.m_positionBuffer.data) throw new Error(); + if (!this.m_velocityBuffer.data) throw new Error(); + var pos_data = this.m_positionBuffer.data; + var vel_data = this.m_velocityBuffer.data; + var springStrength = step.inv_dt * this.m_def.springStrength; + for (var k = 0; k < this.m_pairBuffer.count; k++) { + var pair = this.m_pairBuffer.data[k]; + if (pair.flags & exports.b2ParticleFlag.b2_springParticle) { + var a = pair.indexA; + var b = pair.indexB; + var pa = s_pa.Copy(pos_data[a]); + var pb = s_pb.Copy(pos_data[b]); + var va = vel_data[a]; + var vb = vel_data[b]; + pa.SelfMulAdd(step.dt, va); + pb.SelfMulAdd(step.dt, vb); + var d = b2Vec2.SubVV(pb, pa, s_d); + var r0 = pair.distance; + var r1 = d.Length(); + var strength = springStrength * pair.strength; + var f = b2Vec2.MulSV(strength * (r0 - r1) / r1, d, s_f); + va.SelfSub(f); + vb.SelfAdd(f); + } + } + }; + b2ParticleSystem.prototype.SolveTensile = function(step) { + var s_weightedNormal = b2ParticleSystem.SolveTensile_s_weightedNormal; + var s_s = b2ParticleSystem.SolveTensile_s_s; + var s_f = b2ParticleSystem.SolveTensile_s_f; + if (!this.m_velocityBuffer.data) throw new Error(); + var vel_data = this.m_velocityBuffer.data; + for (var i = 0; i < this.m_count; i++) { + this.m_accumulation2Buffer[i] = new b2Vec2(); + this.m_accumulation2Buffer[i].SetZero(); + } + for (var k = 0; k < this.m_contactBuffer.count; k++) { + var contact = this.m_contactBuffer.data[k]; + if (contact.flags & exports.b2ParticleFlag.b2_tensileParticle) { + var a = contact.indexA; + var b = contact.indexB; + var w = contact.weight; + var n = contact.normal; + var weightedNormal = b2Vec2.MulSV((1 - w) * w, n, s_weightedNormal); + this.m_accumulation2Buffer[a].SelfSub(weightedNormal); + this.m_accumulation2Buffer[b].SelfAdd(weightedNormal); + } + } + var criticalVelocity = this.GetCriticalVelocity(step); + var pressureStrength = this.m_def.surfaceTensionPressureStrength * criticalVelocity; + var normalStrength = this.m_def.surfaceTensionNormalStrength * criticalVelocity; + var maxVelocityVariation = b2_maxParticleForce * criticalVelocity; + for (var k = 0; k < this.m_contactBuffer.count; k++) { + var contact = this.m_contactBuffer.data[k]; + if (contact.flags & exports.b2ParticleFlag.b2_tensileParticle) { + var a = contact.indexA; + var b = contact.indexB; + var w = contact.weight; + var n = contact.normal; + var h = this.m_weightBuffer[a] + this.m_weightBuffer[b]; + var s = b2Vec2.SubVV(this.m_accumulation2Buffer[b], this.m_accumulation2Buffer[a], s_s); + var fn = b2Min(pressureStrength * (h - 2) + normalStrength * b2Vec2.DotVV(s, n), maxVelocityVariation) * w; + var f = b2Vec2.MulSV(fn, n, s_f); + vel_data[a].SelfSub(f); + vel_data[b].SelfAdd(f); + } + } + }; + b2ParticleSystem.prototype.SolveViscous = function() { + var s_v = b2ParticleSystem.SolveViscous_s_v; + var s_f = b2ParticleSystem.SolveViscous_s_f; + if (!this.m_flagsBuffer.data) throw new Error(); + if (!this.m_positionBuffer.data) throw new Error(); + if (!this.m_velocityBuffer.data) throw new Error(); + var pos_data = this.m_positionBuffer.data; + var vel_data = this.m_velocityBuffer.data; + var viscousStrength = this.m_def.viscousStrength; + var inv_mass = this.GetParticleInvMass(); + for (var k = 0; k < this.m_bodyContactBuffer.count; k++) { + var contact = this.m_bodyContactBuffer.data[k]; + var a = contact.index; + if (this.m_flagsBuffer.data[a] & exports.b2ParticleFlag.b2_viscousParticle) { + var b = contact.body; + var w = contact.weight; + var m = contact.mass; + var p = pos_data[a]; + var v = b2Vec2.SubVV(b.GetLinearVelocityFromWorldPoint(p, b2Vec2.s_t0), vel_data[a], s_v); + var f = b2Vec2.MulSV(viscousStrength * m * w, v, s_f); + vel_data[a].SelfMulAdd(inv_mass, f); + b.ApplyLinearImpulse(f.SelfNeg(), p, true); + } + } + for (var k = 0; k < this.m_contactBuffer.count; k++) { + var contact = this.m_contactBuffer.data[k]; + if (contact.flags & exports.b2ParticleFlag.b2_viscousParticle) { + var a = contact.indexA; + var b = contact.indexB; + var w = contact.weight; + var v = b2Vec2.SubVV(vel_data[b], vel_data[a], s_v); + var f = b2Vec2.MulSV(viscousStrength * w, v, s_f); + vel_data[a].SelfAdd(f); + vel_data[b].SelfSub(f); + } + } + }; + b2ParticleSystem.prototype.SolveRepulsive = function(step) { + var s_f = b2ParticleSystem.SolveRepulsive_s_f; + if (!this.m_velocityBuffer.data) throw new Error(); + var vel_data = this.m_velocityBuffer.data; + var repulsiveStrength = this.m_def.repulsiveStrength * this.GetCriticalVelocity(step); + for (var k = 0; k < this.m_contactBuffer.count; k++) { + var contact = this.m_contactBuffer.data[k]; + if (contact.flags & exports.b2ParticleFlag.b2_repulsiveParticle) { + var a = contact.indexA; + var b = contact.indexB; + if (this.m_groupBuffer[a] !== this.m_groupBuffer[b]) { + var w = contact.weight; + var n = contact.normal; + var f = b2Vec2.MulSV(repulsiveStrength * w, n, s_f); + vel_data[a].SelfSub(f); + vel_data[b].SelfAdd(f); + } + } + } + }; + b2ParticleSystem.prototype.SolvePowder = function(step) { + var s_f = b2ParticleSystem.SolvePowder_s_f; + if (!this.m_flagsBuffer.data) throw new Error(); + if (!this.m_positionBuffer.data) throw new Error(); + if (!this.m_velocityBuffer.data) throw new Error(); + var pos_data = this.m_positionBuffer.data; + var vel_data = this.m_velocityBuffer.data; + var powderStrength = this.m_def.powderStrength * this.GetCriticalVelocity(step); + var minWeight = 1 - b2_particleStride; + var inv_mass = this.GetParticleInvMass(); + for (var k = 0; k < this.m_bodyContactBuffer.count; k++) { + var contact = this.m_bodyContactBuffer.data[k]; + var a = contact.index; + if (this.m_flagsBuffer.data[a] & exports.b2ParticleFlag.b2_powderParticle) { + var w = contact.weight; + if (w > minWeight) { + var b = contact.body; + var m = contact.mass; + var p = pos_data[a]; + var n = contact.normal; + var f = b2Vec2.MulSV(powderStrength * m * (w - minWeight), n, s_f); + vel_data[a].SelfMulSub(inv_mass, f); + b.ApplyLinearImpulse(f, p, true); + } + } + } + for (var k = 0; k < this.m_contactBuffer.count; k++) { + var contact = this.m_contactBuffer.data[k]; + if (contact.flags & exports.b2ParticleFlag.b2_powderParticle) { + var w = contact.weight; + if (w > minWeight) { + var a = contact.indexA; + var b = contact.indexB; + var n = contact.normal; + var f = b2Vec2.MulSV(powderStrength * (w - minWeight), n, s_f); + vel_data[a].SelfSub(f); + vel_data[b].SelfAdd(f); + } + } + } + }; + b2ParticleSystem.prototype.SolveSolid = function(step) { + var s_f = b2ParticleSystem.SolveSolid_s_f; + if (!this.m_velocityBuffer.data) throw new Error(); + var vel_data = this.m_velocityBuffer.data; + this.m_depthBuffer = this.RequestBuffer(this.m_depthBuffer); + var ejectionStrength = step.inv_dt * this.m_def.ejectionStrength; + for (var k = 0; k < this.m_contactBuffer.count; k++) { + var contact = this.m_contactBuffer.data[k]; + var a = contact.indexA; + var b = contact.indexB; + if (this.m_groupBuffer[a] !== this.m_groupBuffer[b]) { + var w = contact.weight; + var n = contact.normal; + var h = this.m_depthBuffer[a] + this.m_depthBuffer[b]; + var f = b2Vec2.MulSV(ejectionStrength * h * w, n, s_f); + vel_data[a].SelfSub(f); + vel_data[b].SelfAdd(f); + } + } + }; + b2ParticleSystem.prototype.SolveForce = function(step) { + if (!this.m_velocityBuffer.data) throw new Error(); + var vel_data = this.m_velocityBuffer.data; + var velocityPerForce = step.dt * this.GetParticleInvMass(); + for (var i = 0; i < this.m_count; i++) vel_data[i].SelfMulAdd(velocityPerForce, this.m_forceBuffer[i]); + this.m_hasForce = false; + }; + b2ParticleSystem.prototype.SolveColorMixing = function() { + if (!this.m_flagsBuffer.data) throw new Error(); + if (!this.m_colorBuffer.data) throw new Error(); + var colorMixing = .5 * this.m_def.colorMixingStrength; + if (colorMixing) for (var k = 0; k < this.m_contactBuffer.count; k++) { + var contact = this.m_contactBuffer.data[k]; + var a = contact.indexA; + var b = contact.indexB; + if (this.m_flagsBuffer.data[a] & this.m_flagsBuffer.data[b] & exports.b2ParticleFlag.b2_colorMixingParticle) { + var colorA = this.m_colorBuffer.data[a]; + var colorB = this.m_colorBuffer.data[b]; + b2Color.MixColors(colorA, colorB, colorMixing); + } + } + }; + b2ParticleSystem.prototype.SolveZombie = function() { + if (!this.m_flagsBuffer.data) throw new Error(); + if (!this.m_positionBuffer.data) throw new Error(); + if (!this.m_velocityBuffer.data) throw new Error(); + var newCount = 0; + var newIndices = []; + for (var i = 0; i < this.m_count; i++) newIndices[i] = b2_invalidParticleIndex; + var allParticleFlags = 0; + for (var i = 0; i < this.m_count; i++) { + var flags = this.m_flagsBuffer.data[i]; + if (flags & exports.b2ParticleFlag.b2_zombieParticle) { + var destructionListener = this.m_world.m_destructionListener; + flags & exports.b2ParticleFlag.b2_destructionListenerParticle && destructionListener && destructionListener.SayGoodbyeParticle(this, i); + if (this.m_handleIndexBuffer.data) { + var handle = this.m_handleIndexBuffer.data[i]; + if (handle) { + handle.SetIndex(b2_invalidParticleIndex); + this.m_handleIndexBuffer.data[i] = null; + } + } + newIndices[i] = b2_invalidParticleIndex; + } else { + newIndices[i] = newCount; + if (i !== newCount) { + if (this.m_handleIndexBuffer.data) { + var handle = this.m_handleIndexBuffer.data[i]; + handle && handle.SetIndex(newCount); + this.m_handleIndexBuffer.data[newCount] = handle; + } + this.m_flagsBuffer.data[newCount] = this.m_flagsBuffer.data[i]; + this.m_lastBodyContactStepBuffer.data && (this.m_lastBodyContactStepBuffer.data[newCount] = this.m_lastBodyContactStepBuffer.data[i]); + this.m_bodyContactCountBuffer.data && (this.m_bodyContactCountBuffer.data[newCount] = this.m_bodyContactCountBuffer.data[i]); + this.m_consecutiveContactStepsBuffer.data && (this.m_consecutiveContactStepsBuffer.data[newCount] = this.m_consecutiveContactStepsBuffer.data[i]); + this.m_positionBuffer.data[newCount].Copy(this.m_positionBuffer.data[i]); + this.m_velocityBuffer.data[newCount].Copy(this.m_velocityBuffer.data[i]); + this.m_groupBuffer[newCount] = this.m_groupBuffer[i]; + this.m_hasForce && this.m_forceBuffer[newCount].Copy(this.m_forceBuffer[i]); + this.m_staticPressureBuffer && (this.m_staticPressureBuffer[newCount] = this.m_staticPressureBuffer[i]); + this.m_depthBuffer && (this.m_depthBuffer[newCount] = this.m_depthBuffer[i]); + this.m_colorBuffer.data && this.m_colorBuffer.data[newCount].Copy(this.m_colorBuffer.data[i]); + this.m_userDataBuffer.data && (this.m_userDataBuffer.data[newCount] = this.m_userDataBuffer.data[i]); + this.m_expirationTimeBuffer.data && (this.m_expirationTimeBuffer.data[newCount] = this.m_expirationTimeBuffer.data[i]); + } + newCount++; + allParticleFlags |= flags; + } + } + var Test = { + IsProxyInvalid: function IsProxyInvalid(proxy) { + return proxy.index < 0; + }, + IsContactInvalid: function IsContactInvalid(contact) { + return contact.indexA < 0 || contact.indexB < 0; + }, + IsBodyContactInvalid: function IsBodyContactInvalid(contact) { + return contact.index < 0; + }, + IsPairInvalid: function IsPairInvalid(pair) { + return pair.indexA < 0 || pair.indexB < 0; + }, + IsTriadInvalid: function IsTriadInvalid(triad) { + return triad.indexA < 0 || triad.indexB < 0 || triad.indexC < 0; + } + }; + for (var k = 0; k < this.m_proxyBuffer.count; k++) { + var proxy = this.m_proxyBuffer.data[k]; + proxy.index = newIndices[proxy.index]; + } + this.m_proxyBuffer.RemoveIf(Test.IsProxyInvalid); + for (var k = 0; k < this.m_contactBuffer.count; k++) { + var contact = this.m_contactBuffer.data[k]; + contact.indexA = newIndices[contact.indexA]; + contact.indexB = newIndices[contact.indexB]; + } + this.m_contactBuffer.RemoveIf(Test.IsContactInvalid); + for (var k = 0; k < this.m_bodyContactBuffer.count; k++) { + var contact = this.m_bodyContactBuffer.data[k]; + contact.index = newIndices[contact.index]; + } + this.m_bodyContactBuffer.RemoveIf(Test.IsBodyContactInvalid); + for (var k = 0; k < this.m_pairBuffer.count; k++) { + var pair = this.m_pairBuffer.data[k]; + pair.indexA = newIndices[pair.indexA]; + pair.indexB = newIndices[pair.indexB]; + } + this.m_pairBuffer.RemoveIf(Test.IsPairInvalid); + for (var k = 0; k < this.m_triadBuffer.count; k++) { + var triad = this.m_triadBuffer.data[k]; + triad.indexA = newIndices[triad.indexA]; + triad.indexB = newIndices[triad.indexB]; + triad.indexC = newIndices[triad.indexC]; + } + this.m_triadBuffer.RemoveIf(Test.IsTriadInvalid); + if (this.m_indexByExpirationTimeBuffer.data) { + var writeOffset = 0; + for (var readOffset = 0; readOffset < this.m_count; readOffset++) { + var newIndex = newIndices[this.m_indexByExpirationTimeBuffer.data[readOffset]]; + newIndex !== b2_invalidParticleIndex && (this.m_indexByExpirationTimeBuffer.data[writeOffset++] = newIndex); + } + } + for (var group = this.m_groupList; group; group = group.GetNext()) { + var firstIndex = newCount; + var lastIndex = 0; + var modified = false; + for (var i = group.m_firstIndex; i < group.m_lastIndex; i++) { + var j = newIndices[i]; + if (j >= 0) { + firstIndex = b2Min(firstIndex, j); + lastIndex = b2Max(lastIndex, j + 1); + } else modified = true; + } + if (firstIndex < lastIndex) { + group.m_firstIndex = firstIndex; + group.m_lastIndex = lastIndex; + modified && group.m_groupFlags & exports.b2ParticleGroupFlag.b2_solidParticleGroup && this.SetGroupFlags(group, group.m_groupFlags | exports.b2ParticleGroupFlag.b2_particleGroupNeedsUpdateDepth); + } else { + group.m_firstIndex = 0; + group.m_lastIndex = 0; + group.m_groupFlags & exports.b2ParticleGroupFlag.b2_particleGroupCanBeEmpty || this.SetGroupFlags(group, group.m_groupFlags | exports.b2ParticleGroupFlag.b2_particleGroupWillBeDestroyed); + } + } + this.m_count = newCount; + this.m_allParticleFlags = allParticleFlags; + this.m_needsUpdateAllParticleFlags = false; + for (var group = this.m_groupList; group; ) { + var next = group.GetNext(); + group.m_groupFlags & exports.b2ParticleGroupFlag.b2_particleGroupWillBeDestroyed && this.DestroyParticleGroup(group); + group = next; + } + }; + b2ParticleSystem.prototype.SolveLifetimes = function(step) { + if (!this.m_expirationTimeBuffer.data) throw new Error(); + if (!this.m_indexByExpirationTimeBuffer.data) throw new Error(); + this.m_timeElapsed = this.LifetimeToExpirationTime(step.dt); + var quantizedTimeElapsed = this.GetQuantizedTimeElapsed(); + var expirationTimes = this.m_expirationTimeBuffer.data; + var expirationTimeIndices = this.m_indexByExpirationTimeBuffer.data; + var particleCount = this.GetParticleCount(); + if (this.m_expirationTimeBufferRequiresSorting) { + var ExpirationTimeComparator = function ExpirationTimeComparator(particleIndexA, particleIndexB) { + var expirationTimeA = expirationTimes[particleIndexA]; + var expirationTimeB = expirationTimes[particleIndexB]; + var infiniteExpirationTimeA = expirationTimeA <= 0; + var infiniteExpirationTimeB = expirationTimeB <= 0; + return infiniteExpirationTimeA === infiniteExpirationTimeB ? expirationTimeA > expirationTimeB : infiniteExpirationTimeA; + }; + std_sort(expirationTimeIndices, 0, particleCount, ExpirationTimeComparator); + this.m_expirationTimeBufferRequiresSorting = false; + } + for (var i = particleCount - 1; i >= 0; --i) { + var particleIndex = expirationTimeIndices[i]; + var expirationTime = expirationTimes[particleIndex]; + if (quantizedTimeElapsed < expirationTime || expirationTime <= 0) break; + this.DestroyParticle(particleIndex); + } + }; + b2ParticleSystem.prototype.RotateBuffer = function(start, mid, end) { + if (start === mid || mid === end) return; + function newIndices(i) { + return i < start ? i : i < mid ? i + end - mid : i < end ? i + start - mid : i; + } + if (!this.m_flagsBuffer.data) throw new Error(); + if (!this.m_positionBuffer.data) throw new Error(); + if (!this.m_velocityBuffer.data) throw new Error(); + std_rotate(this.m_flagsBuffer.data, start, mid, end); + this.m_lastBodyContactStepBuffer.data && std_rotate(this.m_lastBodyContactStepBuffer.data, start, mid, end); + this.m_bodyContactCountBuffer.data && std_rotate(this.m_bodyContactCountBuffer.data, start, mid, end); + this.m_consecutiveContactStepsBuffer.data && std_rotate(this.m_consecutiveContactStepsBuffer.data, start, mid, end); + std_rotate(this.m_positionBuffer.data, start, mid, end); + std_rotate(this.m_velocityBuffer.data, start, mid, end); + std_rotate(this.m_groupBuffer, start, mid, end); + this.m_hasForce && std_rotate(this.m_forceBuffer, start, mid, end); + this.m_staticPressureBuffer && std_rotate(this.m_staticPressureBuffer, start, mid, end); + this.m_depthBuffer && std_rotate(this.m_depthBuffer, start, mid, end); + this.m_colorBuffer.data && std_rotate(this.m_colorBuffer.data, start, mid, end); + this.m_userDataBuffer.data && std_rotate(this.m_userDataBuffer.data, start, mid, end); + if (this.m_handleIndexBuffer.data) { + std_rotate(this.m_handleIndexBuffer.data, start, mid, end); + for (var i = start; i < end; ++i) { + var handle = this.m_handleIndexBuffer.data[i]; + handle && handle.SetIndex(newIndices(handle.GetIndex())); + } + } + if (this.m_expirationTimeBuffer.data) { + std_rotate(this.m_expirationTimeBuffer.data, start, mid, end); + var particleCount = this.GetParticleCount(); + if (!this.m_indexByExpirationTimeBuffer.data) throw new Error(); + var indexByExpirationTime = this.m_indexByExpirationTimeBuffer.data; + for (var i = 0; i < particleCount; ++i) indexByExpirationTime[i] = newIndices(indexByExpirationTime[i]); + } + for (var k = 0; k < this.m_proxyBuffer.count; k++) { + var proxy = this.m_proxyBuffer.data[k]; + proxy.index = newIndices(proxy.index); + } + for (var k = 0; k < this.m_contactBuffer.count; k++) { + var contact = this.m_contactBuffer.data[k]; + contact.indexA = newIndices(contact.indexA); + contact.indexB = newIndices(contact.indexB); + } + for (var k = 0; k < this.m_bodyContactBuffer.count; k++) { + var contact = this.m_bodyContactBuffer.data[k]; + contact.index = newIndices(contact.index); + } + for (var k = 0; k < this.m_pairBuffer.count; k++) { + var pair = this.m_pairBuffer.data[k]; + pair.indexA = newIndices(pair.indexA); + pair.indexB = newIndices(pair.indexB); + } + for (var k = 0; k < this.m_triadBuffer.count; k++) { + var triad = this.m_triadBuffer.data[k]; + triad.indexA = newIndices(triad.indexA); + triad.indexB = newIndices(triad.indexB); + triad.indexC = newIndices(triad.indexC); + } + for (var group = this.m_groupList; group; group = group.GetNext()) { + group.m_firstIndex = newIndices(group.m_firstIndex); + group.m_lastIndex = newIndices(group.m_lastIndex - 1) + 1; + } + }; + b2ParticleSystem.prototype.GetCriticalVelocity = function(step) { + return this.m_particleDiameter * step.inv_dt; + }; + b2ParticleSystem.prototype.GetCriticalVelocitySquared = function(step) { + var velocity = this.GetCriticalVelocity(step); + return velocity * velocity; + }; + b2ParticleSystem.prototype.GetCriticalPressure = function(step) { + return this.m_def.density * this.GetCriticalVelocitySquared(step); + }; + b2ParticleSystem.prototype.GetParticleStride = function() { + return b2_particleStride * this.m_particleDiameter; + }; + b2ParticleSystem.prototype.GetParticleMass = function() { + var stride = this.GetParticleStride(); + return this.m_def.density * stride * stride; + }; + b2ParticleSystem.prototype.GetParticleInvMass = function() { + var inverseStride = this.m_inverseDiameter * (1 / b2_particleStride); + return this.m_inverseDensity * inverseStride * inverseStride; + }; + b2ParticleSystem.prototype.GetFixtureContactFilter = function() { + return this.m_allParticleFlags & exports.b2ParticleFlag.b2_fixtureContactFilterParticle ? this.m_world.m_contactManager.m_contactFilter : null; + }; + b2ParticleSystem.prototype.GetParticleContactFilter = function() { + return this.m_allParticleFlags & exports.b2ParticleFlag.b2_particleContactFilterParticle ? this.m_world.m_contactManager.m_contactFilter : null; + }; + b2ParticleSystem.prototype.GetFixtureContactListener = function() { + return this.m_allParticleFlags & exports.b2ParticleFlag.b2_fixtureContactListenerParticle ? this.m_world.m_contactManager.m_contactListener : null; + }; + b2ParticleSystem.prototype.GetParticleContactListener = function() { + return this.m_allParticleFlags & exports.b2ParticleFlag.b2_particleContactListenerParticle ? this.m_world.m_contactManager.m_contactListener : null; + }; + b2ParticleSystem.prototype.SetUserOverridableBuffer = function(buffer, newData, newCapacity) { + buffer.data = newData; + buffer.userSuppliedCapacity = newCapacity; + }; + b2ParticleSystem.prototype.SetGroupFlags = function(group, newFlags) { + var oldFlags = group.m_groupFlags; + (oldFlags ^ newFlags) & exports.b2ParticleGroupFlag.b2_solidParticleGroup && (newFlags |= exports.b2ParticleGroupFlag.b2_particleGroupNeedsUpdateDepth); + oldFlags & ~newFlags && (this.m_needsUpdateAllGroupFlags = true); + if (~this.m_allGroupFlags & newFlags) { + newFlags & exports.b2ParticleGroupFlag.b2_solidParticleGroup && (this.m_depthBuffer = this.RequestBuffer(this.m_depthBuffer)); + this.m_allGroupFlags |= newFlags; + } + group.m_groupFlags = newFlags; + }; + b2ParticleSystem.BodyContactCompare = function(lhs, rhs) { + if (lhs.index === rhs.index) return lhs.weight > rhs.weight; + return lhs.index < rhs.index; + }; + b2ParticleSystem.prototype.RemoveSpuriousBodyContacts = function() { + std_sort(this.m_bodyContactBuffer.data, 0, this.m_bodyContactBuffer.count, b2ParticleSystem.BodyContactCompare); + var s_n = b2ParticleSystem.RemoveSpuriousBodyContacts_s_n; + var s_pos = b2ParticleSystem.RemoveSpuriousBodyContacts_s_pos; + var s_normal = b2ParticleSystem.RemoveSpuriousBodyContacts_s_normal; + var k_maxContactsPerPoint = 3; + var system = this; + var lastIndex = -1; + var currentContacts = 0; + var b2ParticleBodyContactRemovePredicate = function b2ParticleBodyContactRemovePredicate(contact) { + if (contact.index !== lastIndex) { + currentContacts = 0; + lastIndex = contact.index; + } + if (currentContacts++ > k_maxContactsPerPoint) return true; + var n = s_n.Copy(contact.normal); + n.SelfMul(system.m_particleDiameter * (1 - contact.weight)); + if (!system.m_positionBuffer.data) throw new Error(); + var pos = b2Vec2.AddVV(system.m_positionBuffer.data[contact.index], n, s_pos); + if (!contact.fixture.TestPoint(pos)) { + var childCount = contact.fixture.GetShape().GetChildCount(); + for (var childIndex = 0; childIndex < childCount; childIndex++) { + var normal = s_normal; + var distance = contact.fixture.ComputeDistance(pos, normal, childIndex); + if (distance < b2_linearSlop) return false; + } + return true; + } + return false; + }; + this.m_bodyContactBuffer.count = std_remove_if(this.m_bodyContactBuffer.data, b2ParticleBodyContactRemovePredicate, this.m_bodyContactBuffer.count); + }; + b2ParticleSystem.prototype.DetectStuckParticle = function(particle) { + if (this.m_stuckThreshold <= 0) return; + if (!this.m_bodyContactCountBuffer.data) throw new Error(); + if (!this.m_consecutiveContactStepsBuffer.data) throw new Error(); + if (!this.m_lastBodyContactStepBuffer.data) throw new Error(); + ++this.m_bodyContactCountBuffer.data[particle]; + if (2 === this.m_bodyContactCountBuffer.data[particle]) { + ++this.m_consecutiveContactStepsBuffer.data[particle]; + this.m_consecutiveContactStepsBuffer.data[particle] > this.m_stuckThreshold && (this.m_stuckParticleBuffer.data[this.m_stuckParticleBuffer.Append()] = particle); + } + this.m_lastBodyContactStepBuffer.data[particle] = this.m_timestamp; + }; + b2ParticleSystem.prototype.ValidateParticleIndex = function(index) { + return index >= 0 && index < this.GetParticleCount() && index !== b2_invalidParticleIndex; + }; + b2ParticleSystem.prototype.GetQuantizedTimeElapsed = function() { + return Math.floor(this.m_timeElapsed / 4294967296); + }; + b2ParticleSystem.prototype.LifetimeToExpirationTime = function(lifetime) { + return this.m_timeElapsed + Math.floor(lifetime / this.m_def.lifetimeGranularity * 4294967296); + }; + b2ParticleSystem.prototype.ForceCanBeApplied = function(flags) { + return !(flags & exports.b2ParticleFlag.b2_wallParticle); + }; + b2ParticleSystem.prototype.PrepareForceBuffer = function() { + if (!this.m_hasForce) { + for (var i = 0; i < this.m_count; i++) this.m_forceBuffer[i].SetZero(); + this.m_hasForce = true; + } + }; + b2ParticleSystem.prototype.IsRigidGroup = function(group) { + return null !== group && 0 !== (group.m_groupFlags & exports.b2ParticleGroupFlag.b2_rigidParticleGroup); + }; + b2ParticleSystem.prototype.GetLinearVelocity = function(group, particleIndex, point, out) { + if (group && this.IsRigidGroup(group)) return group.GetLinearVelocityFromWorldPoint(point, out); + if (!this.m_velocityBuffer.data) throw new Error(); + return out.Copy(this.m_velocityBuffer.data[particleIndex]); + }; + b2ParticleSystem.prototype.InitDampingParameter = function(invMass, invInertia, tangentDistance, mass, inertia, center, point, normal) { + invMass[0] = mass > 0 ? 1 / mass : 0; + invInertia[0] = inertia > 0 ? 1 / inertia : 0; + tangentDistance[0] = b2Vec2.CrossVV(b2Vec2.SubVV(point, center, b2Vec2.s_t0), normal); + }; + b2ParticleSystem.prototype.InitDampingParameterWithRigidGroupOrParticle = function(invMass, invInertia, tangentDistance, isRigidGroup, group, particleIndex, point, normal) { + if (group && isRigidGroup) this.InitDampingParameter(invMass, invInertia, tangentDistance, group.GetMass(), group.GetInertia(), group.GetCenter(), point, normal); else { + if (!this.m_flagsBuffer.data) throw new Error(); + var flags = this.m_flagsBuffer.data[particleIndex]; + this.InitDampingParameter(invMass, invInertia, tangentDistance, flags & exports.b2ParticleFlag.b2_wallParticle ? 0 : this.GetParticleMass(), 0, point, point, normal); + } + }; + b2ParticleSystem.prototype.ComputeDampingImpulse = function(invMassA, invInertiaA, tangentDistanceA, invMassB, invInertiaB, tangentDistanceB, normalVelocity) { + var invMass = invMassA + invInertiaA * tangentDistanceA * tangentDistanceA + invMassB + invInertiaB * tangentDistanceB * tangentDistanceB; + return invMass > 0 ? normalVelocity / invMass : 0; + }; + b2ParticleSystem.prototype.ApplyDamping = function(invMass, invInertia, tangentDistance, isRigidGroup, group, particleIndex, impulse, normal) { + if (group && isRigidGroup) { + group.m_linearVelocity.SelfMulAdd(impulse * invMass, normal); + group.m_angularVelocity += impulse * tangentDistance * invInertia; + } else { + if (!this.m_velocityBuffer.data) throw new Error(); + this.m_velocityBuffer.data[particleIndex].SelfMulAdd(impulse * invMass, normal); + } + }; + b2ParticleSystem.xTruncBits = 12; + b2ParticleSystem.yTruncBits = 12; + b2ParticleSystem.tagBits = 32; + b2ParticleSystem.yOffset = 1 << b2ParticleSystem.yTruncBits - 1; + b2ParticleSystem.yShift = b2ParticleSystem.tagBits - b2ParticleSystem.yTruncBits; + b2ParticleSystem.xShift = b2ParticleSystem.tagBits - b2ParticleSystem.yTruncBits - b2ParticleSystem.xTruncBits; + b2ParticleSystem.xScale = 1 << b2ParticleSystem.xShift; + b2ParticleSystem.xOffset = b2ParticleSystem.xScale * (1 << b2ParticleSystem.xTruncBits - 1); + b2ParticleSystem.yMask = (1 << b2ParticleSystem.yTruncBits) - 1 << b2ParticleSystem.yShift; + b2ParticleSystem.xMask = ~b2ParticleSystem.yMask; + b2ParticleSystem.DestroyParticlesInShape_s_aabb = new b2AABB(); + b2ParticleSystem.CreateParticleGroup_s_transform = new b2Transform(); + b2ParticleSystem.ComputeCollisionEnergy_s_v = new b2Vec2(); + b2ParticleSystem.QueryShapeAABB_s_aabb = new b2AABB(); + b2ParticleSystem.QueryPointAABB_s_aabb = new b2AABB(); + b2ParticleSystem.RayCast_s_aabb = new b2AABB(); + b2ParticleSystem.RayCast_s_p = new b2Vec2(); + b2ParticleSystem.RayCast_s_v = new b2Vec2(); + b2ParticleSystem.RayCast_s_n = new b2Vec2(); + b2ParticleSystem.RayCast_s_point = new b2Vec2(); + b2ParticleSystem.k_pairFlags = exports.b2ParticleFlag.b2_springParticle; + b2ParticleSystem.k_triadFlags = exports.b2ParticleFlag.b2_elasticParticle; + b2ParticleSystem.k_noPressureFlags = exports.b2ParticleFlag.b2_powderParticle | exports.b2ParticleFlag.b2_tensileParticle; + b2ParticleSystem.k_extraDampingFlags = exports.b2ParticleFlag.b2_staticPressureParticle; + b2ParticleSystem.k_barrierWallFlags = exports.b2ParticleFlag.b2_barrierParticle | exports.b2ParticleFlag.b2_wallParticle; + b2ParticleSystem.CreateParticlesStrokeShapeForGroup_s_edge = new b2EdgeShape(); + b2ParticleSystem.CreateParticlesStrokeShapeForGroup_s_d = new b2Vec2(); + b2ParticleSystem.CreateParticlesStrokeShapeForGroup_s_p = new b2Vec2(); + b2ParticleSystem.CreateParticlesFillShapeForGroup_s_aabb = new b2AABB(); + b2ParticleSystem.CreateParticlesFillShapeForGroup_s_p = new b2Vec2(); + b2ParticleSystem.UpdatePairsAndTriads_s_dab = new b2Vec2(); + b2ParticleSystem.UpdatePairsAndTriads_s_dbc = new b2Vec2(); + b2ParticleSystem.UpdatePairsAndTriads_s_dca = new b2Vec2(); + b2ParticleSystem.AddContact_s_d = new b2Vec2(); + b2ParticleSystem.UpdateBodyContacts_s_aabb = new b2AABB(); + b2ParticleSystem.Solve_s_subStep = new b2TimeStep(); + b2ParticleSystem.SolveCollision_s_aabb = new b2AABB(); + b2ParticleSystem.SolveGravity_s_gravity = new b2Vec2(); + b2ParticleSystem.SolveBarrier_s_aabb = new b2AABB(); + b2ParticleSystem.SolveBarrier_s_va = new b2Vec2(); + b2ParticleSystem.SolveBarrier_s_vb = new b2Vec2(); + b2ParticleSystem.SolveBarrier_s_pba = new b2Vec2(); + b2ParticleSystem.SolveBarrier_s_vba = new b2Vec2(); + b2ParticleSystem.SolveBarrier_s_vc = new b2Vec2(); + b2ParticleSystem.SolveBarrier_s_pca = new b2Vec2(); + b2ParticleSystem.SolveBarrier_s_vca = new b2Vec2(); + b2ParticleSystem.SolveBarrier_s_qba = new b2Vec2(); + b2ParticleSystem.SolveBarrier_s_qca = new b2Vec2(); + b2ParticleSystem.SolveBarrier_s_dv = new b2Vec2(); + b2ParticleSystem.SolveBarrier_s_f = new b2Vec2(); + b2ParticleSystem.SolvePressure_s_f = new b2Vec2(); + b2ParticleSystem.SolveDamping_s_v = new b2Vec2(); + b2ParticleSystem.SolveDamping_s_f = new b2Vec2(); + b2ParticleSystem.SolveRigidDamping_s_t0 = new b2Vec2(); + b2ParticleSystem.SolveRigidDamping_s_t1 = new b2Vec2(); + b2ParticleSystem.SolveRigidDamping_s_p = new b2Vec2(); + b2ParticleSystem.SolveRigidDamping_s_v = new b2Vec2(); + b2ParticleSystem.SolveExtraDamping_s_v = new b2Vec2(); + b2ParticleSystem.SolveExtraDamping_s_f = new b2Vec2(); + b2ParticleSystem.SolveRigid_s_position = new b2Vec2(); + b2ParticleSystem.SolveRigid_s_rotation = new b2Rot(); + b2ParticleSystem.SolveRigid_s_transform = new b2Transform(); + b2ParticleSystem.SolveRigid_s_velocityTransform = new b2Transform(); + b2ParticleSystem.SolveElastic_s_pa = new b2Vec2(); + b2ParticleSystem.SolveElastic_s_pb = new b2Vec2(); + b2ParticleSystem.SolveElastic_s_pc = new b2Vec2(); + b2ParticleSystem.SolveElastic_s_r = new b2Rot(); + b2ParticleSystem.SolveElastic_s_t0 = new b2Vec2(); + b2ParticleSystem.SolveSpring_s_pa = new b2Vec2(); + b2ParticleSystem.SolveSpring_s_pb = new b2Vec2(); + b2ParticleSystem.SolveSpring_s_d = new b2Vec2(); + b2ParticleSystem.SolveSpring_s_f = new b2Vec2(); + b2ParticleSystem.SolveTensile_s_weightedNormal = new b2Vec2(); + b2ParticleSystem.SolveTensile_s_s = new b2Vec2(); + b2ParticleSystem.SolveTensile_s_f = new b2Vec2(); + b2ParticleSystem.SolveViscous_s_v = new b2Vec2(); + b2ParticleSystem.SolveViscous_s_f = new b2Vec2(); + b2ParticleSystem.SolveRepulsive_s_f = new b2Vec2(); + b2ParticleSystem.SolvePowder_s_f = new b2Vec2(); + b2ParticleSystem.SolveSolid_s_f = new b2Vec2(); + b2ParticleSystem.RemoveSpuriousBodyContacts_s_n = new b2Vec2(); + b2ParticleSystem.RemoveSpuriousBodyContacts_s_pos = new b2Vec2(); + b2ParticleSystem.RemoveSpuriousBodyContacts_s_normal = new b2Vec2(); + return b2ParticleSystem; + })(); + (function(b2ParticleSystem) { + var UserOverridableBuffer = (function() { + function UserOverridableBuffer() { + this.data = null; + this.userSuppliedCapacity = 0; + } + return UserOverridableBuffer; + })(); + b2ParticleSystem.UserOverridableBuffer = UserOverridableBuffer; + var Proxy = (function() { + function Proxy() { + this.index = b2_invalidParticleIndex; + this.tag = 0; + } + Proxy.CompareProxyProxy = function(a, b) { + return a.tag < b.tag; + }; + Proxy.CompareTagProxy = function(a, b) { + return a < b.tag; + }; + Proxy.CompareProxyTag = function(a, b) { + return a.tag < b; + }; + return Proxy; + })(); + b2ParticleSystem.Proxy = Proxy; + var InsideBoundsEnumerator = (function() { + function InsideBoundsEnumerator(system, lower, upper, first, last) { + this.m_system = system; + this.m_xLower = (lower & b2ParticleSystem.xMask) >>> 0; + this.m_xUpper = (upper & b2ParticleSystem.xMask) >>> 0; + this.m_yLower = (lower & b2ParticleSystem.yMask) >>> 0; + this.m_yUpper = (upper & b2ParticleSystem.yMask) >>> 0; + this.m_first = first; + this.m_last = last; + } + InsideBoundsEnumerator.prototype.GetNext = function() { + while (this.m_first < this.m_last) { + var xTag = (this.m_system.m_proxyBuffer.data[this.m_first].tag & b2ParticleSystem.xMask) >>> 0; + if (xTag >= this.m_xLower && xTag <= this.m_xUpper) return this.m_system.m_proxyBuffer.data[this.m_first++].index; + this.m_first++; + } + return b2_invalidParticleIndex; + }; + return InsideBoundsEnumerator; + })(); + b2ParticleSystem.InsideBoundsEnumerator = InsideBoundsEnumerator; + var ParticleListNode = (function() { + function ParticleListNode() { + this.next = null; + this.count = 0; + this.index = 0; + } + return ParticleListNode; + })(); + b2ParticleSystem.ParticleListNode = ParticleListNode; + var FixedSetAllocator = (function() { + function FixedSetAllocator() {} + FixedSetAllocator.prototype.Allocate = function(itemSize, count) { + return count; + }; + FixedSetAllocator.prototype.Clear = function() {}; + FixedSetAllocator.prototype.GetCount = function() { + return 0; + }; + FixedSetAllocator.prototype.Invalidate = function(itemIndex) {}; + FixedSetAllocator.prototype.GetValidBuffer = function() { + return []; + }; + FixedSetAllocator.prototype.GetBuffer = function() { + return []; + }; + FixedSetAllocator.prototype.SetCount = function(count) {}; + return FixedSetAllocator; + })(); + b2ParticleSystem.FixedSetAllocator = FixedSetAllocator; + var FixtureParticle = (function() { + function FixtureParticle(fixture, particle) { + this.second = b2_invalidParticleIndex; + this.first = fixture; + this.second = particle; + } + return FixtureParticle; + })(); + b2ParticleSystem.FixtureParticle = FixtureParticle; + var FixtureParticleSet = (function(_super) { + __extends(FixtureParticleSet, _super); + function FixtureParticleSet() { + return null !== _super && _super.apply(this, arguments) || this; + } + FixtureParticleSet.prototype.Initialize = function(bodyContactBuffer, flagsBuffer) {}; + FixtureParticleSet.prototype.Find = function(pair) { + return b2_invalidParticleIndex; + }; + return FixtureParticleSet; + })(b2ParticleSystem.FixedSetAllocator); + b2ParticleSystem.FixtureParticleSet = FixtureParticleSet; + var ParticlePair = (function() { + function ParticlePair(particleA, particleB) { + this.first = b2_invalidParticleIndex; + this.second = b2_invalidParticleIndex; + this.first = particleA; + this.second = particleB; + } + return ParticlePair; + })(); + b2ParticleSystem.ParticlePair = ParticlePair; + var b2ParticlePairSet = (function(_super) { + __extends(b2ParticlePairSet, _super); + function b2ParticlePairSet() { + return null !== _super && _super.apply(this, arguments) || this; + } + b2ParticlePairSet.prototype.Initialize = function(contactBuffer, flagsBuffer) {}; + b2ParticlePairSet.prototype.Find = function(pair) { + return b2_invalidParticleIndex; + }; + return b2ParticlePairSet; + })(b2ParticleSystem.FixedSetAllocator); + b2ParticleSystem.b2ParticlePairSet = b2ParticlePairSet; + var ConnectionFilter = (function() { + function ConnectionFilter() {} + ConnectionFilter.prototype.IsNecessary = function(index) { + return true; + }; + ConnectionFilter.prototype.ShouldCreatePair = function(a, b) { + return true; + }; + ConnectionFilter.prototype.ShouldCreateTriad = function(a, b, c) { + return true; + }; + return ConnectionFilter; + })(); + b2ParticleSystem.ConnectionFilter = ConnectionFilter; + var DestroyParticlesInShapeCallback = (function(_super) { + __extends(DestroyParticlesInShapeCallback, _super); + function DestroyParticlesInShapeCallback(system, shape, xf, callDestructionListener) { + var _this = _super.call(this) || this; + _this.m_callDestructionListener = false; + _this.m_destroyed = 0; + _this.m_system = system; + _this.m_shape = shape; + _this.m_xf = xf; + _this.m_callDestructionListener = callDestructionListener; + _this.m_destroyed = 0; + return _this; + } + DestroyParticlesInShapeCallback.prototype.ReportFixture = function(fixture) { + return false; + }; + DestroyParticlesInShapeCallback.prototype.ReportParticle = function(particleSystem, index) { + if (particleSystem !== this.m_system) return false; + if (!this.m_system.m_positionBuffer.data) throw new Error(); + if (this.m_shape.TestPoint(this.m_xf, this.m_system.m_positionBuffer.data[index])) { + this.m_system.DestroyParticle(index, this.m_callDestructionListener); + this.m_destroyed++; + } + return true; + }; + DestroyParticlesInShapeCallback.prototype.Destroyed = function() { + return this.m_destroyed; + }; + return DestroyParticlesInShapeCallback; + })(b2QueryCallback); + b2ParticleSystem.DestroyParticlesInShapeCallback = DestroyParticlesInShapeCallback; + var JoinParticleGroupsFilter = (function(_super) { + __extends(JoinParticleGroupsFilter, _super); + function JoinParticleGroupsFilter(threshold) { + var _this = _super.call(this) || this; + _this.m_threshold = 0; + _this.m_threshold = threshold; + return _this; + } + JoinParticleGroupsFilter.prototype.ShouldCreatePair = function(a, b) { + return a < this.m_threshold && this.m_threshold <= b || b < this.m_threshold && this.m_threshold <= a; + }; + JoinParticleGroupsFilter.prototype.ShouldCreateTriad = function(a, b, c) { + return (a < this.m_threshold || b < this.m_threshold || c < this.m_threshold) && (this.m_threshold <= a || this.m_threshold <= b || this.m_threshold <= c); + }; + return JoinParticleGroupsFilter; + })(b2ParticleSystem.ConnectionFilter); + b2ParticleSystem.JoinParticleGroupsFilter = JoinParticleGroupsFilter; + var CompositeShape = (function(_super) { + __extends(CompositeShape, _super); + function CompositeShape(shapes, shapeCount) { + void 0 === shapeCount && (shapeCount = shapes.length); + var _this = _super.call(this, exports.b2ShapeType.e_unknown, 0) || this; + _this.m_shapeCount = 0; + _this.m_shapes = shapes; + _this.m_shapeCount = shapeCount; + return _this; + } + CompositeShape.prototype.Clone = function() { + throw new Error(); + }; + CompositeShape.prototype.GetChildCount = function() { + return 1; + }; + CompositeShape.prototype.TestPoint = function(xf, p) { + for (var i = 0; i < this.m_shapeCount; i++) if (this.m_shapes[i].TestPoint(xf, p)) return true; + return false; + }; + CompositeShape.prototype.ComputeDistance = function(xf, p, normal, childIndex) { + return 0; + }; + CompositeShape.prototype.RayCast = function(output, input, xf, childIndex) { + return false; + }; + CompositeShape.prototype.ComputeAABB = function(aabb, xf, childIndex) { + var s_subaabb = new b2AABB(); + aabb.lowerBound.x = +b2_maxFloat; + aabb.lowerBound.y = +b2_maxFloat; + aabb.upperBound.x = -b2_maxFloat; + aabb.upperBound.y = -b2_maxFloat; + for (var i = 0; i < this.m_shapeCount; i++) { + var childCount = this.m_shapes[i].GetChildCount(); + for (var j = 0; j < childCount; j++) { + var subaabb = s_subaabb; + this.m_shapes[i].ComputeAABB(subaabb, xf, j); + aabb.Combine1(subaabb); + } + } + }; + CompositeShape.prototype.ComputeMass = function(massData, density) {}; + CompositeShape.prototype.SetupDistanceProxy = function(proxy, index) {}; + CompositeShape.prototype.ComputeSubmergedArea = function(normal, offset, xf, c) { + return 0; + }; + CompositeShape.prototype.Dump = function(log) {}; + return CompositeShape; + })(b2Shape); + b2ParticleSystem.CompositeShape = CompositeShape; + var ReactiveFilter = (function(_super) { + __extends(ReactiveFilter, _super); + function ReactiveFilter(flagsBuffer) { + var _this = _super.call(this) || this; + _this.m_flagsBuffer = flagsBuffer; + return _this; + } + ReactiveFilter.prototype.IsNecessary = function(index) { + if (!this.m_flagsBuffer.data) throw new Error(); + return 0 !== (this.m_flagsBuffer.data[index] & exports.b2ParticleFlag.b2_reactiveParticle); + }; + return ReactiveFilter; + })(b2ParticleSystem.ConnectionFilter); + b2ParticleSystem.ReactiveFilter = ReactiveFilter; + var UpdateBodyContactsCallback = (function(_super) { + __extends(UpdateBodyContactsCallback, _super); + function UpdateBodyContactsCallback(system, contactFilter) { + var _this = _super.call(this, system) || this; + _this.m_contactFilter = contactFilter; + return _this; + } + UpdateBodyContactsCallback.prototype.ShouldCollideFixtureParticle = function(fixture, particleSystem, particleIndex) { + if (this.m_contactFilter) { + var flags = this.m_system.GetFlagsBuffer(); + if (flags[particleIndex] & exports.b2ParticleFlag.b2_fixtureContactFilterParticle) return this.m_contactFilter.ShouldCollideFixtureParticle(fixture, this.m_system, particleIndex); + } + return true; + }; + UpdateBodyContactsCallback.prototype.ReportFixtureAndParticle = function(fixture, childIndex, a) { + var s_n = b2ParticleSystem.UpdateBodyContactsCallback.ReportFixtureAndParticle_s_n; + var s_rp = b2ParticleSystem.UpdateBodyContactsCallback.ReportFixtureAndParticle_s_rp; + if (!this.m_system.m_flagsBuffer.data) throw new Error(); + if (!this.m_system.m_positionBuffer.data) throw new Error(); + var ap = this.m_system.m_positionBuffer.data[a]; + var n = s_n; + var d = fixture.ComputeDistance(ap, n, childIndex); + if (d < this.m_system.m_particleDiameter && this.ShouldCollideFixtureParticle(fixture, this.m_system, a)) { + var b = fixture.GetBody(); + var bp = b.GetWorldCenter(); + var bm = b.GetMass(); + var bI = b.GetInertia() - bm * b.GetLocalCenter().LengthSquared(); + var invBm = bm > 0 ? 1 / bm : 0; + var invBI = bI > 0 ? 1 / bI : 0; + var invAm = this.m_system.m_flagsBuffer.data[a] & exports.b2ParticleFlag.b2_wallParticle ? 0 : this.m_system.GetParticleInvMass(); + var rp = b2Vec2.SubVV(ap, bp, s_rp); + var rpn = b2Vec2.CrossVV(rp, n); + var invM = invAm + invBm + invBI * rpn * rpn; + var contact = this.m_system.m_bodyContactBuffer.data[this.m_system.m_bodyContactBuffer.Append()]; + contact.index = a; + contact.body = b; + contact.fixture = fixture; + contact.weight = 1 - d * this.m_system.m_inverseDiameter; + contact.normal.Copy(n.SelfNeg()); + contact.mass = invM > 0 ? 1 / invM : 0; + this.m_system.DetectStuckParticle(a); + } + }; + UpdateBodyContactsCallback.ReportFixtureAndParticle_s_n = new b2Vec2(); + UpdateBodyContactsCallback.ReportFixtureAndParticle_s_rp = new b2Vec2(); + return UpdateBodyContactsCallback; + })(b2FixtureParticleQueryCallback); + b2ParticleSystem.UpdateBodyContactsCallback = UpdateBodyContactsCallback; + var SolveCollisionCallback = (function(_super) { + __extends(SolveCollisionCallback, _super); + function SolveCollisionCallback(system, step) { + var _this = _super.call(this, system) || this; + _this.m_step = step; + return _this; + } + SolveCollisionCallback.prototype.ReportFixtureAndParticle = function(fixture, childIndex, a) { + var s_p1 = b2ParticleSystem.SolveCollisionCallback.ReportFixtureAndParticle_s_p1; + var s_output = b2ParticleSystem.SolveCollisionCallback.ReportFixtureAndParticle_s_output; + var s_input = b2ParticleSystem.SolveCollisionCallback.ReportFixtureAndParticle_s_input; + var s_p = b2ParticleSystem.SolveCollisionCallback.ReportFixtureAndParticle_s_p; + var s_v = b2ParticleSystem.SolveCollisionCallback.ReportFixtureAndParticle_s_v; + var s_f = b2ParticleSystem.SolveCollisionCallback.ReportFixtureAndParticle_s_f; + var body = fixture.GetBody(); + if (!this.m_system.m_positionBuffer.data) throw new Error(); + if (!this.m_system.m_velocityBuffer.data) throw new Error(); + var ap = this.m_system.m_positionBuffer.data[a]; + var av = this.m_system.m_velocityBuffer.data[a]; + var output = s_output; + var input = s_input; + if (0 === this.m_system.m_iterationIndex) { + var p1 = b2Transform.MulTXV(body.m_xf0, ap, s_p1); + if (fixture.GetShape().GetType() === exports.b2ShapeType.e_circleShape) { + p1.SelfSub(body.GetLocalCenter()); + b2Rot.MulRV(body.m_xf0.q, p1, p1); + b2Rot.MulTRV(body.m_xf.q, p1, p1); + p1.SelfAdd(body.GetLocalCenter()); + } + b2Transform.MulXV(body.m_xf, p1, input.p1); + } else input.p1.Copy(ap); + b2Vec2.AddVMulSV(ap, this.m_step.dt, av, input.p2); + input.maxFraction = 1; + if (fixture.RayCast(output, input, childIndex)) { + var n = output.normal; + var p = s_p; + p.x = (1 - output.fraction) * input.p1.x + output.fraction * input.p2.x + b2_linearSlop * n.x; + p.y = (1 - output.fraction) * input.p1.y + output.fraction * input.p2.y + b2_linearSlop * n.y; + var v = s_v; + v.x = this.m_step.inv_dt * (p.x - ap.x); + v.y = this.m_step.inv_dt * (p.y - ap.y); + this.m_system.m_velocityBuffer.data[a].Copy(v); + var f = s_f; + f.x = this.m_step.inv_dt * this.m_system.GetParticleMass() * (av.x - v.x); + f.y = this.m_step.inv_dt * this.m_system.GetParticleMass() * (av.y - v.y); + this.m_system.ParticleApplyForce(a, f); + } + }; + SolveCollisionCallback.prototype.ReportParticle = function(system, index) { + return false; + }; + SolveCollisionCallback.ReportFixtureAndParticle_s_p1 = new b2Vec2(); + SolveCollisionCallback.ReportFixtureAndParticle_s_output = new b2RayCastOutput(); + SolveCollisionCallback.ReportFixtureAndParticle_s_input = new b2RayCastInput(); + SolveCollisionCallback.ReportFixtureAndParticle_s_p = new b2Vec2(); + SolveCollisionCallback.ReportFixtureAndParticle_s_v = new b2Vec2(); + SolveCollisionCallback.ReportFixtureAndParticle_s_f = new b2Vec2(); + return SolveCollisionCallback; + })(b2FixtureParticleQueryCallback); + b2ParticleSystem.SolveCollisionCallback = SolveCollisionCallback; + })(exports.b2ParticleSystem || (exports.b2ParticleSystem = {})); + var b2World = (function() { + function b2World(gravity) { + this.m_newFixture = false; + this.m_locked = false; + this.m_clearForces = true; + this.m_contactManager = new b2ContactManager(); + this.m_bodyList = null; + this.m_jointList = null; + this.m_particleSystemList = null; + this.m_bodyCount = 0; + this.m_jointCount = 0; + this.m_gravity = new b2Vec2(); + this.m_allowSleep = true; + this.m_destructionListener = null; + this.m_debugDraw = null; + this.m_inv_dt0 = 0; + this.m_warmStarting = true; + this.m_continuousPhysics = true; + this.m_subStepping = false; + this.m_stepComplete = true; + this.m_profile = new b2Profile(); + this.m_island = new b2Island(); + this.s_stack = []; + this.m_controllerList = null; + this.m_controllerCount = 0; + this.m_gravity.Copy(gravity); + } + b2World.prototype.SetDestructionListener = function(listener) { + this.m_destructionListener = listener; + }; + b2World.prototype.SetContactFilter = function(filter) { + this.m_contactManager.m_contactFilter = filter; + }; + b2World.prototype.SetContactListener = function(listener) { + this.m_contactManager.m_contactListener = listener; + }; + b2World.prototype.SetDebugDraw = function(debugDraw) { + this.m_debugDraw = debugDraw; + }; + b2World.prototype.CreateBody = function(def) { + void 0 === def && (def = {}); + if (this.IsLocked()) throw new Error(); + var b = new b2Body(def, this); + b.m_prev = null; + b.m_next = this.m_bodyList; + this.m_bodyList && (this.m_bodyList.m_prev = b); + this.m_bodyList = b; + ++this.m_bodyCount; + return b; + }; + b2World.prototype.DestroyBody = function(b) { + if (this.IsLocked()) throw new Error(); + var je = b.m_jointList; + while (je) { + var je0 = je; + je = je.next; + this.m_destructionListener && this.m_destructionListener.SayGoodbyeJoint(je0.joint); + this.DestroyJoint(je0.joint); + b.m_jointList = je; + } + b.m_jointList = null; + var coe = b.m_controllerList; + while (coe) { + var coe0 = coe; + coe = coe.nextController; + coe0.controller.RemoveBody(b); + } + var ce = b.m_contactList; + while (ce) { + var ce0 = ce; + ce = ce.next; + this.m_contactManager.Destroy(ce0.contact); + } + b.m_contactList = null; + var f = b.m_fixtureList; + while (f) { + var f0 = f; + f = f.m_next; + this.m_destructionListener && this.m_destructionListener.SayGoodbyeFixture(f0); + f0.DestroyProxies(); + f0.Destroy(); + b.m_fixtureList = f; + b.m_fixtureCount -= 1; + } + b.m_fixtureList = null; + b.m_fixtureCount = 0; + b.m_prev && (b.m_prev.m_next = b.m_next); + b.m_next && (b.m_next.m_prev = b.m_prev); + b === this.m_bodyList && (this.m_bodyList = b.m_next); + --this.m_bodyCount; + }; + b2World._Joint_Create = function(def, allocator) { + switch (def.type) { + case exports.b2JointType.e_distanceJoint: + return new b2DistanceJoint(def); + + case exports.b2JointType.e_mouseJoint: + return new b2MouseJoint(def); + + case exports.b2JointType.e_prismaticJoint: + return new b2PrismaticJoint(def); + + case exports.b2JointType.e_revoluteJoint: + return new b2RevoluteJoint(def); + + case exports.b2JointType.e_pulleyJoint: + return new b2PulleyJoint(def); + + case exports.b2JointType.e_gearJoint: + return new b2GearJoint(def); + + case exports.b2JointType.e_wheelJoint: + return new b2WheelJoint(def); + + case exports.b2JointType.e_weldJoint: + return new b2WeldJoint(def); + + case exports.b2JointType.e_frictionJoint: + return new b2FrictionJoint(def); + + case exports.b2JointType.e_ropeJoint: + return new b2RopeJoint(def); + + case exports.b2JointType.e_motorJoint: + return new b2MotorJoint(def); + + case exports.b2JointType.e_areaJoint: + return new b2AreaJoint(def); + } + throw new Error(); + }; + b2World._Joint_Destroy = function(joint, allocator) {}; + b2World.prototype.CreateJoint = function(def) { + if (this.IsLocked()) throw new Error(); + var j = b2World._Joint_Create(def, null); + j.m_prev = null; + j.m_next = this.m_jointList; + this.m_jointList && (this.m_jointList.m_prev = j); + this.m_jointList = j; + ++this.m_jointCount; + j.m_edgeA.prev = null; + j.m_edgeA.next = j.m_bodyA.m_jointList; + j.m_bodyA.m_jointList && (j.m_bodyA.m_jointList.prev = j.m_edgeA); + j.m_bodyA.m_jointList = j.m_edgeA; + j.m_edgeB.prev = null; + j.m_edgeB.next = j.m_bodyB.m_jointList; + j.m_bodyB.m_jointList && (j.m_bodyB.m_jointList.prev = j.m_edgeB); + j.m_bodyB.m_jointList = j.m_edgeB; + var bodyA = def.bodyA; + var bodyB = def.bodyB; + if (!def.collideConnected) { + var edge = bodyB.GetContactList(); + while (edge) { + edge.other === bodyA && edge.contact.FlagForFiltering(); + edge = edge.next; + } + } + return j; + }; + b2World.prototype.DestroyJoint = function(j) { + if (this.IsLocked()) throw new Error(); + var collideConnected = j.m_collideConnected; + j.m_prev && (j.m_prev.m_next = j.m_next); + j.m_next && (j.m_next.m_prev = j.m_prev); + j === this.m_jointList && (this.m_jointList = j.m_next); + var bodyA = j.m_bodyA; + var bodyB = j.m_bodyB; + bodyA.SetAwake(true); + bodyB.SetAwake(true); + j.m_edgeA.prev && (j.m_edgeA.prev.next = j.m_edgeA.next); + j.m_edgeA.next && (j.m_edgeA.next.prev = j.m_edgeA.prev); + j.m_edgeA === bodyA.m_jointList && (bodyA.m_jointList = j.m_edgeA.next); + j.m_edgeA.prev = null; + j.m_edgeA.next = null; + j.m_edgeB.prev && (j.m_edgeB.prev.next = j.m_edgeB.next); + j.m_edgeB.next && (j.m_edgeB.next.prev = j.m_edgeB.prev); + j.m_edgeB === bodyB.m_jointList && (bodyB.m_jointList = j.m_edgeB.next); + j.m_edgeB.prev = null; + j.m_edgeB.next = null; + b2World._Joint_Destroy(j, null); + --this.m_jointCount; + if (!collideConnected) { + var edge = bodyB.GetContactList(); + while (edge) { + edge.other === bodyA && edge.contact.FlagForFiltering(); + edge = edge.next; + } + } + }; + b2World.prototype.CreateParticleSystem = function(def) { + if (this.IsLocked()) throw new Error(); + var p = new exports.b2ParticleSystem(def, this); + p.m_prev = null; + p.m_next = this.m_particleSystemList; + this.m_particleSystemList && (this.m_particleSystemList.m_prev = p); + this.m_particleSystemList = p; + return p; + }; + b2World.prototype.DestroyParticleSystem = function(p) { + if (this.IsLocked()) throw new Error(); + p.m_prev && (p.m_prev.m_next = p.m_next); + p.m_next && (p.m_next.m_prev = p.m_prev); + p === this.m_particleSystemList && (this.m_particleSystemList = p.m_next); + }; + b2World.prototype.CalculateReasonableParticleIterations = function(timeStep) { + if (null === this.m_particleSystemList) return 1; + function GetSmallestRadius(world) { + var smallestRadius = b2_maxFloat; + for (var system = world.GetParticleSystemList(); null !== system; system = system.m_next) smallestRadius = b2Min(smallestRadius, system.GetRadius()); + return smallestRadius; + } + return b2CalculateParticleIterations(this.m_gravity.Length(), GetSmallestRadius(this), timeStep); + }; + b2World.prototype.Step = function(dt, velocityIterations, positionIterations, particleIterations) { + void 0 === particleIterations && (particleIterations = this.CalculateReasonableParticleIterations(dt)); + var stepTimer = b2World.Step_s_stepTimer.Reset(); + if (this.m_newFixture) { + this.m_contactManager.FindNewContacts(); + this.m_newFixture = false; + } + this.m_locked = true; + var step = b2World.Step_s_step; + step.dt = dt; + step.velocityIterations = velocityIterations; + step.positionIterations = positionIterations; + step.particleIterations = particleIterations; + step.inv_dt = dt > 0 ? 1 / dt : 0; + step.dtRatio = this.m_inv_dt0 * dt; + step.warmStarting = this.m_warmStarting; + var timer = b2World.Step_s_timer.Reset(); + this.m_contactManager.Collide(); + this.m_profile.collide = timer.GetMilliseconds(); + if (this.m_stepComplete && step.dt > 0) { + var timer_1 = b2World.Step_s_timer.Reset(); + for (var p = this.m_particleSystemList; p; p = p.m_next) p.Solve(step); + this.Solve(step); + this.m_profile.solve = timer_1.GetMilliseconds(); + } + if (this.m_continuousPhysics && step.dt > 0) { + var timer_2 = b2World.Step_s_timer.Reset(); + this.SolveTOI(step); + this.m_profile.solveTOI = timer_2.GetMilliseconds(); + } + step.dt > 0 && (this.m_inv_dt0 = step.inv_dt); + this.m_clearForces && this.ClearForces(); + this.m_locked = false; + this.m_profile.step = stepTimer.GetMilliseconds(); + }; + b2World.prototype.ClearForces = function() { + for (var body = this.m_bodyList; body; body = body.m_next) { + body.m_force.SetZero(); + body.m_torque = 0; + } + }; + b2World.prototype.DrawParticleSystem = function(system) { + if (null === this.m_debugDraw) return; + var particleCount = system.GetParticleCount(); + if (particleCount) { + var radius = system.GetRadius(); + var positionBuffer = system.GetPositionBuffer(); + if (system.m_colorBuffer.data) { + var colorBuffer = system.GetColorBuffer(); + this.m_debugDraw.DrawParticles(positionBuffer, radius, colorBuffer, particleCount); + } else this.m_debugDraw.DrawParticles(positionBuffer, radius, null, particleCount); + } + }; + b2World.prototype.DrawDebugData = function() { + if (null === this.m_debugDraw) return; + var flags = this.m_debugDraw.GetFlags(); + var color = b2World.DrawDebugData_s_color.SetRGB(0, 0, 0); + if (flags & exports.b2DrawFlags.e_shapeBit) for (var b = this.m_bodyList; b; b = b.m_next) { + var xf = b.m_xf; + this.m_debugDraw.PushTransform(xf); + for (var f = b.GetFixtureList(); f; f = f.m_next) if (b.IsActive()) if (b.GetType() === exports.b2BodyType.b2_staticBody) { + color.SetRGB(.5, .9, .5); + this.DrawShape(f, color); + } else if (b.GetType() === exports.b2BodyType.b2_kinematicBody) { + color.SetRGB(.5, .5, .9); + this.DrawShape(f, color); + } else if (b.IsAwake()) { + color.SetRGB(.9, .7, .7); + this.DrawShape(f, color); + } else { + color.SetRGB(.6, .6, .6); + this.DrawShape(f, color); + } else { + color.SetRGB(.5, .5, .3); + this.DrawShape(f, color); + } + this.m_debugDraw.PopTransform(xf); + } + if (flags & exports.b2DrawFlags.e_particleBit) for (var p = this.m_particleSystemList; p; p = p.m_next) this.DrawParticleSystem(p); + if (flags & exports.b2DrawFlags.e_jointBit) for (var j = this.m_jointList; j; j = j.m_next) this.DrawJoint(j); + if (flags & exports.b2DrawFlags.e_aabbBit) { + color.SetRGB(.9, .3, .9); + var vs = b2World.DrawDebugData_s_vs; + for (var b = this.m_bodyList; b; b = b.m_next) { + if (!b.IsActive()) continue; + for (var f = b.GetFixtureList(); f; f = f.m_next) for (var i = 0; i < f.m_proxyCount; ++i) { + var proxy = f.m_proxies[i]; + var aabb = proxy.treeNode.aabb; + vs[0].Set(aabb.lowerBound.x, aabb.lowerBound.y); + vs[1].Set(aabb.upperBound.x, aabb.lowerBound.y); + vs[2].Set(aabb.upperBound.x, aabb.upperBound.y); + vs[3].Set(aabb.lowerBound.x, aabb.upperBound.y); + this.m_debugDraw.DrawPolygon(vs, 4, color); + } + } + } + if (flags & exports.b2DrawFlags.e_centerOfMassBit) for (var b = this.m_bodyList; b; b = b.m_next) { + var xf = b2World.DrawDebugData_s_xf; + xf.q.Copy(b.m_xf.q); + xf.p.Copy(b.GetWorldCenter()); + this.m_debugDraw.DrawTransform(xf); + } + if (flags & exports.b2DrawFlags.e_controllerBit) for (var c = this.m_controllerList; c; c = c.m_next) c.Draw(this.m_debugDraw); + }; + b2World.prototype.QueryAABB = function(callback, aabb, fn) { + this.m_contactManager.m_broadPhase.Query(aabb, (function(proxy) { + var fixture_proxy = proxy.userData; + var fixture = fixture_proxy.fixture; + if (callback) return callback.ReportFixture(fixture); + if (fn) return fn(fixture); + return true; + })); + if (callback instanceof b2QueryCallback) for (var p = this.m_particleSystemList; p; p = p.m_next) callback.ShouldQueryParticleSystem(p) && p.QueryAABB(callback, aabb); + }; + b2World.prototype.QueryAllAABB = function(aabb, out) { + void 0 === out && (out = []); + this.QueryAABB(null, aabb, (function(fixture) { + out.push(fixture); + return true; + })); + return out; + }; + b2World.prototype.QueryPointAABB = function(callback, point, fn) { + this.m_contactManager.m_broadPhase.QueryPoint(point, (function(proxy) { + var fixture_proxy = proxy.userData; + var fixture = fixture_proxy.fixture; + if (callback) return callback.ReportFixture(fixture); + if (fn) return fn(fixture); + return true; + })); + if (callback instanceof b2QueryCallback) for (var p = this.m_particleSystemList; p; p = p.m_next) callback.ShouldQueryParticleSystem(p) && p.QueryPointAABB(callback, point); + }; + b2World.prototype.QueryAllPointAABB = function(point, out) { + void 0 === out && (out = []); + this.QueryPointAABB(null, point, (function(fixture) { + out.push(fixture); + return true; + })); + return out; + }; + b2World.prototype.QueryFixtureShape = function(callback, shape, index, transform, fn) { + var aabb = b2World.QueryFixtureShape_s_aabb; + shape.ComputeAABB(aabb, transform, index); + this.m_contactManager.m_broadPhase.Query(aabb, (function(proxy) { + var fixture_proxy = proxy.userData; + var fixture = fixture_proxy.fixture; + if (b2TestOverlapShape(shape, index, fixture.GetShape(), fixture_proxy.childIndex, transform, fixture.GetBody().GetTransform())) { + if (callback) return callback.ReportFixture(fixture); + if (fn) return fn(fixture); + } + return true; + })); + if (callback instanceof b2QueryCallback) for (var p = this.m_particleSystemList; p; p = p.m_next) callback.ShouldQueryParticleSystem(p) && p.QueryAABB(callback, aabb); + }; + b2World.prototype.QueryAllFixtureShape = function(shape, index, transform, out) { + void 0 === out && (out = []); + this.QueryFixtureShape(null, shape, index, transform, (function(fixture) { + out.push(fixture); + return true; + })); + return out; + }; + b2World.prototype.QueryFixturePoint = function(callback, point, fn) { + this.m_contactManager.m_broadPhase.QueryPoint(point, (function(proxy) { + var fixture_proxy = proxy.userData; + var fixture = fixture_proxy.fixture; + if (fixture.TestPoint(point)) { + if (callback) return callback.ReportFixture(fixture); + if (fn) return fn(fixture); + } + return true; + })); + if (callback) for (var p = this.m_particleSystemList; p; p = p.m_next) callback.ShouldQueryParticleSystem(p) && p.QueryPointAABB(callback, point); + }; + b2World.prototype.QueryAllFixturePoint = function(point, out) { + void 0 === out && (out = []); + this.QueryFixturePoint(null, point, (function(fixture) { + out.push(fixture); + return true; + })); + return out; + }; + b2World.prototype.RayCast = function(callback, point1, point2, fn) { + var input = b2World.RayCast_s_input; + input.maxFraction = 1; + input.p1.Copy(point1); + input.p2.Copy(point2); + this.m_contactManager.m_broadPhase.RayCast(input, (function(input, proxy) { + var fixture_proxy = proxy.userData; + var fixture = fixture_proxy.fixture; + var index = fixture_proxy.childIndex; + var output = b2World.RayCast_s_output; + var hit = fixture.RayCast(output, input, index); + if (hit) { + var fraction = output.fraction; + var point = b2World.RayCast_s_point; + point.Set((1 - fraction) * point1.x + fraction * point2.x, (1 - fraction) * point1.y + fraction * point2.y); + if (callback) return callback.ReportFixture(fixture, point, output.normal, fraction); + if (fn) return fn(fixture, point, output.normal, fraction); + } + return input.maxFraction; + })); + if (callback) for (var p = this.m_particleSystemList; p; p = p.m_next) callback.ShouldQueryParticleSystem(p) && p.RayCast(callback, point1, point2); + }; + b2World.prototype.RayCastOne = function(point1, point2) { + var result = null; + var min_fraction = 1; + this.RayCast(null, point1, point2, (function(fixture, point, normal, fraction) { + if (fraction < min_fraction) { + min_fraction = fraction; + result = fixture; + } + return min_fraction; + })); + return result; + }; + b2World.prototype.RayCastAll = function(point1, point2, out) { + void 0 === out && (out = []); + this.RayCast(null, point1, point2, (function(fixture, point, normal, fraction) { + out.push(fixture); + return 1; + })); + return out; + }; + b2World.prototype.GetBodyList = function() { + return this.m_bodyList; + }; + b2World.prototype.GetJointList = function() { + return this.m_jointList; + }; + b2World.prototype.GetParticleSystemList = function() { + return this.m_particleSystemList; + }; + b2World.prototype.GetContactList = function() { + return this.m_contactManager.m_contactList; + }; + b2World.prototype.SetAllowSleeping = function(flag) { + if (flag === this.m_allowSleep) return; + this.m_allowSleep = flag; + if (!this.m_allowSleep) for (var b = this.m_bodyList; b; b = b.m_next) b.SetAwake(true); + }; + b2World.prototype.GetAllowSleeping = function() { + return this.m_allowSleep; + }; + b2World.prototype.SetWarmStarting = function(flag) { + this.m_warmStarting = flag; + }; + b2World.prototype.GetWarmStarting = function() { + return this.m_warmStarting; + }; + b2World.prototype.SetContinuousPhysics = function(flag) { + this.m_continuousPhysics = flag; + }; + b2World.prototype.GetContinuousPhysics = function() { + return this.m_continuousPhysics; + }; + b2World.prototype.SetSubStepping = function(flag) { + this.m_subStepping = flag; + }; + b2World.prototype.GetSubStepping = function() { + return this.m_subStepping; + }; + b2World.prototype.GetProxyCount = function() { + return this.m_contactManager.m_broadPhase.GetProxyCount(); + }; + b2World.prototype.GetBodyCount = function() { + return this.m_bodyCount; + }; + b2World.prototype.GetJointCount = function() { + return this.m_jointCount; + }; + b2World.prototype.GetContactCount = function() { + return this.m_contactManager.m_contactCount; + }; + b2World.prototype.GetTreeHeight = function() { + return this.m_contactManager.m_broadPhase.GetTreeHeight(); + }; + b2World.prototype.GetTreeBalance = function() { + return this.m_contactManager.m_broadPhase.GetTreeBalance(); + }; + b2World.prototype.GetTreeQuality = function() { + return this.m_contactManager.m_broadPhase.GetTreeQuality(); + }; + b2World.prototype.SetGravity = function(gravity, wake) { + void 0 === wake && (wake = true); + if (!b2Vec2.IsEqualToV(this.m_gravity, gravity)) { + this.m_gravity.Copy(gravity); + if (wake) for (var b = this.m_bodyList; b; b = b.m_next) b.SetAwake(true); + } + }; + b2World.prototype.GetGravity = function() { + return this.m_gravity; + }; + b2World.prototype.IsLocked = function() { + return this.m_locked; + }; + b2World.prototype.SetAutoClearForces = function(flag) { + this.m_clearForces = flag; + }; + b2World.prototype.GetAutoClearForces = function() { + return this.m_clearForces; + }; + b2World.prototype.ShiftOrigin = function(newOrigin) { + if (this.IsLocked()) throw new Error(); + for (var b = this.m_bodyList; b; b = b.m_next) { + b.m_xf.p.SelfSub(newOrigin); + b.m_sweep.c0.SelfSub(newOrigin); + b.m_sweep.c.SelfSub(newOrigin); + } + for (var j = this.m_jointList; j; j = j.m_next) j.ShiftOrigin(newOrigin); + this.m_contactManager.m_broadPhase.ShiftOrigin(newOrigin); + }; + b2World.prototype.GetContactManager = function() { + return this.m_contactManager; + }; + b2World.prototype.GetProfile = function() { + return this.m_profile; + }; + b2World.prototype.Dump = function(log) { + if (this.m_locked) return; + log("const g: b2Vec2 = new b2Vec2(%.15f, %.15f);\n", this.m_gravity.x, this.m_gravity.y); + log("this.m_world.SetGravity(g);\n"); + log("const bodies: b2Body[] = [];\n"); + log("const joints: b2Joint[] = [];\n"); + var i = 0; + for (var b = this.m_bodyList; b; b = b.m_next) { + b.m_islandIndex = i; + b.Dump(log); + ++i; + } + i = 0; + for (var j = this.m_jointList; j; j = j.m_next) { + j.m_index = i; + ++i; + } + for (var j = this.m_jointList; j; j = j.m_next) { + if (j.m_type === exports.b2JointType.e_gearJoint) continue; + log("{\n"); + j.Dump(log); + log("}\n"); + } + for (var j = this.m_jointList; j; j = j.m_next) { + if (j.m_type !== exports.b2JointType.e_gearJoint) continue; + log("{\n"); + j.Dump(log); + log("}\n"); + } + }; + b2World.prototype.DrawJoint = function(joint) { + if (null === this.m_debugDraw) return; + var bodyA = joint.GetBodyA(); + var bodyB = joint.GetBodyB(); + var xf1 = bodyA.m_xf; + var xf2 = bodyB.m_xf; + var x1 = xf1.p; + var x2 = xf2.p; + var p1 = joint.GetAnchorA(b2World.DrawJoint_s_p1); + var p2 = joint.GetAnchorB(b2World.DrawJoint_s_p2); + var color = b2World.DrawJoint_s_color.SetRGB(.5, .8, .8); + switch (joint.m_type) { + case exports.b2JointType.e_distanceJoint: + this.m_debugDraw.DrawSegment(p1, p2, color); + break; + + case exports.b2JointType.e_pulleyJoint: + var pulley = joint; + var s1 = pulley.GetGroundAnchorA(); + var s2 = pulley.GetGroundAnchorB(); + this.m_debugDraw.DrawSegment(s1, p1, color); + this.m_debugDraw.DrawSegment(s2, p2, color); + this.m_debugDraw.DrawSegment(s1, s2, color); + break; + + case exports.b2JointType.e_mouseJoint: + var c = b2World.DrawJoint_s_c; + c.Set(0, 1, 0); + this.m_debugDraw.DrawPoint(p1, 4, c); + this.m_debugDraw.DrawPoint(p2, 4, c); + c.Set(.8, .8, .8); + this.m_debugDraw.DrawSegment(p1, p2, c); + break; + + default: + this.m_debugDraw.DrawSegment(x1, p1, color); + this.m_debugDraw.DrawSegment(p1, p2, color); + this.m_debugDraw.DrawSegment(x2, p2, color); + } + }; + b2World.prototype.DrawShape = function(fixture, color) { + if (null === this.m_debugDraw) return; + var shape = fixture.GetShape(); + switch (shape.m_type) { + case exports.b2ShapeType.e_circleShape: + var circle = shape; + var center = circle.m_p; + var radius = circle.m_radius; + var axis = b2Vec2.UNITX; + this.m_debugDraw.DrawSolidCircle(center, radius, axis, color); + break; + + case exports.b2ShapeType.e_edgeShape: + var edge = shape; + var v1 = edge.m_vertex1; + var v2 = edge.m_vertex2; + this.m_debugDraw.DrawSegment(v1, v2, color); + break; + + case exports.b2ShapeType.e_chainShape: + var chain = shape; + var count = chain.m_count; + var vertices = chain.m_vertices; + var ghostColor = b2World.DrawShape_s_ghostColor.SetRGBA(.75 * color.r, .75 * color.g, .75 * color.b, color.a); + var v1 = vertices[0]; + this.m_debugDraw.DrawPoint(v1, 4, color); + if (chain.m_hasPrevVertex) { + var vp = chain.m_prevVertex; + this.m_debugDraw.DrawSegment(vp, v1, ghostColor); + this.m_debugDraw.DrawCircle(vp, .1, ghostColor); + } + for (var i = 1; i < count; ++i) { + var v2 = vertices[i]; + this.m_debugDraw.DrawSegment(v1, v2, color); + this.m_debugDraw.DrawPoint(v2, 4, color); + v1 = v2; + } + if (chain.m_hasNextVertex) { + var vn = chain.m_nextVertex; + this.m_debugDraw.DrawSegment(vn, v1, ghostColor); + this.m_debugDraw.DrawCircle(vn, .1, ghostColor); + } + break; + + case exports.b2ShapeType.e_polygonShape: + var poly = shape; + var vertexCount = poly.m_count; + var vertices = poly.m_vertices; + this.m_debugDraw.DrawSolidPolygon(vertices, vertexCount, color); + } + }; + b2World.prototype.Solve = function(step) { + for (var b = this.m_bodyList; b; b = b.m_next) b.m_xf0.Copy(b.m_xf); + for (var controller = this.m_controllerList; controller; controller = controller.m_next) controller.Step(step); + this.m_profile.solveInit = 0; + this.m_profile.solveVelocity = 0; + this.m_profile.solvePosition = 0; + var island = this.m_island; + island.Initialize(this.m_bodyCount, this.m_contactManager.m_contactCount, this.m_jointCount, null, this.m_contactManager.m_contactListener); + for (var b = this.m_bodyList; b; b = b.m_next) b.m_islandFlag = false; + for (var c = this.m_contactManager.m_contactList; c; c = c.m_next) c.m_islandFlag = false; + for (var j = this.m_jointList; j; j = j.m_next) j.m_islandFlag = false; + var stack = this.s_stack; + for (var seed = this.m_bodyList; seed; seed = seed.m_next) { + if (seed.m_islandFlag) continue; + if (!seed.IsAwake() || !seed.IsActive()) continue; + if (seed.GetType() === exports.b2BodyType.b2_staticBody) continue; + island.Clear(); + var stackCount = 0; + stack[stackCount++] = seed; + seed.m_islandFlag = true; + while (stackCount > 0) { + var b = stack[--stackCount]; + if (!b) throw new Error(); + island.AddBody(b); + b.m_awakeFlag = true; + if (b.GetType() === exports.b2BodyType.b2_staticBody) continue; + for (var ce = b.m_contactList; ce; ce = ce.next) { + var contact = ce.contact; + if (contact.m_islandFlag) continue; + if (!contact.IsEnabled() || !contact.IsTouching()) continue; + var sensorA = contact.m_fixtureA.m_isSensor; + var sensorB = contact.m_fixtureB.m_isSensor; + if (sensorA || sensorB) continue; + island.AddContact(contact); + contact.m_islandFlag = true; + var other = ce.other; + if (!other) throw new Error(); + if (other.m_islandFlag) continue; + stack[stackCount++] = other; + other.m_islandFlag = true; + } + for (var je = b.m_jointList; je; je = je.next) { + if (je.joint.m_islandFlag) continue; + var other = je.other; + if (!other.IsActive()) continue; + island.AddJoint(je.joint); + je.joint.m_islandFlag = true; + if (other.m_islandFlag) continue; + stack[stackCount++] = other; + other.m_islandFlag = true; + } + } + var profile = new b2Profile(); + island.Solve(profile, step, this.m_gravity, this.m_allowSleep); + this.m_profile.solveInit += profile.solveInit; + this.m_profile.solveVelocity += profile.solveVelocity; + this.m_profile.solvePosition += profile.solvePosition; + for (var i = 0; i < island.m_bodyCount; ++i) { + var b = island.m_bodies[i]; + b.GetType() === exports.b2BodyType.b2_staticBody && (b.m_islandFlag = false); + } + } + for (var i = 0; i < stack.length; ++i) { + if (!stack[i]) break; + stack[i] = null; + } + var timer = new b2Timer(); + for (var b = this.m_bodyList; b; b = b.m_next) { + if (!b.m_islandFlag) continue; + if (b.GetType() === exports.b2BodyType.b2_staticBody) continue; + b.SynchronizeFixtures(); + } + this.m_contactManager.FindNewContacts(); + this.m_profile.broadphase = timer.GetMilliseconds(); + }; + b2World.prototype.SolveTOI = function(step) { + var island = this.m_island; + island.Initialize(2 * b2_maxTOIContacts, b2_maxTOIContacts, 0, null, this.m_contactManager.m_contactListener); + if (this.m_stepComplete) { + for (var b = this.m_bodyList; b; b = b.m_next) { + b.m_islandFlag = false; + b.m_sweep.alpha0 = 0; + } + for (var c = this.m_contactManager.m_contactList; c; c = c.m_next) { + c.m_toiFlag = false; + c.m_islandFlag = false; + c.m_toiCount = 0; + c.m_toi = 1; + } + } + for (;;) { + var minContact = null; + var minAlpha = 1; + for (var c = this.m_contactManager.m_contactList; c; c = c.m_next) { + if (!c.IsEnabled()) continue; + if (c.m_toiCount > b2_maxSubSteps) continue; + var alpha = 1; + if (c.m_toiFlag) alpha = c.m_toi; else { + var fA_1 = c.GetFixtureA(); + var fB_1 = c.GetFixtureB(); + if (fA_1.IsSensor() || fB_1.IsSensor()) continue; + var bA_1 = fA_1.GetBody(); + var bB_1 = fB_1.GetBody(); + var typeA = bA_1.m_type; + var typeB = bB_1.m_type; + var activeA = bA_1.IsAwake() && typeA !== exports.b2BodyType.b2_staticBody; + var activeB = bB_1.IsAwake() && typeB !== exports.b2BodyType.b2_staticBody; + if (!activeA && !activeB) continue; + var collideA = bA_1.IsBullet() || typeA !== exports.b2BodyType.b2_dynamicBody; + var collideB = bB_1.IsBullet() || typeB !== exports.b2BodyType.b2_dynamicBody; + if (!collideA && !collideB) continue; + var alpha0 = bA_1.m_sweep.alpha0; + if (bA_1.m_sweep.alpha0 < bB_1.m_sweep.alpha0) { + alpha0 = bB_1.m_sweep.alpha0; + bA_1.m_sweep.Advance(alpha0); + } else if (bB_1.m_sweep.alpha0 < bA_1.m_sweep.alpha0) { + alpha0 = bA_1.m_sweep.alpha0; + bB_1.m_sweep.Advance(alpha0); + } + var indexA = c.GetChildIndexA(); + var indexB = c.GetChildIndexB(); + var input = b2World.SolveTOI_s_toi_input; + input.proxyA.SetShape(fA_1.GetShape(), indexA); + input.proxyB.SetShape(fB_1.GetShape(), indexB); + input.sweepA.Copy(bA_1.m_sweep); + input.sweepB.Copy(bB_1.m_sweep); + input.tMax = 1; + var output = b2World.SolveTOI_s_toi_output; + b2TimeOfImpact(output, input); + var beta = output.t; + alpha = output.state === exports.b2TOIOutputState.e_touching ? b2Min(alpha0 + (1 - alpha0) * beta, 1) : 1; + c.m_toi = alpha; + c.m_toiFlag = true; + } + if (alpha < minAlpha) { + minContact = c; + minAlpha = alpha; + } + } + if (null === minContact || 1 - 10 * b2_epsilon < minAlpha) { + this.m_stepComplete = true; + break; + } + var fA = minContact.GetFixtureA(); + var fB = minContact.GetFixtureB(); + var bA = fA.GetBody(); + var bB = fB.GetBody(); + var backup1 = b2World.SolveTOI_s_backup1.Copy(bA.m_sweep); + var backup2 = b2World.SolveTOI_s_backup2.Copy(bB.m_sweep); + bA.Advance(minAlpha); + bB.Advance(minAlpha); + minContact.Update(this.m_contactManager.m_contactListener); + minContact.m_toiFlag = false; + ++minContact.m_toiCount; + if (!minContact.IsEnabled() || !minContact.IsTouching()) { + minContact.SetEnabled(false); + bA.m_sweep.Copy(backup1); + bB.m_sweep.Copy(backup2); + bA.SynchronizeTransform(); + bB.SynchronizeTransform(); + continue; + } + bA.SetAwake(true); + bB.SetAwake(true); + island.Clear(); + island.AddBody(bA); + island.AddBody(bB); + island.AddContact(minContact); + bA.m_islandFlag = true; + bB.m_islandFlag = true; + minContact.m_islandFlag = true; + for (var i = 0; i < 2; ++i) { + var body = 0 === i ? bA : bB; + if (body.m_type === exports.b2BodyType.b2_dynamicBody) for (var ce = body.m_contactList; ce; ce = ce.next) { + if (island.m_bodyCount === island.m_bodyCapacity) break; + if (island.m_contactCount === island.m_contactCapacity) break; + var contact = ce.contact; + if (contact.m_islandFlag) continue; + var other = ce.other; + if (other.m_type === exports.b2BodyType.b2_dynamicBody && !body.IsBullet() && !other.IsBullet()) continue; + var sensorA = contact.m_fixtureA.m_isSensor; + var sensorB = contact.m_fixtureB.m_isSensor; + if (sensorA || sensorB) continue; + var backup = b2World.SolveTOI_s_backup.Copy(other.m_sweep); + other.m_islandFlag || other.Advance(minAlpha); + contact.Update(this.m_contactManager.m_contactListener); + if (!contact.IsEnabled()) { + other.m_sweep.Copy(backup); + other.SynchronizeTransform(); + continue; + } + if (!contact.IsTouching()) { + other.m_sweep.Copy(backup); + other.SynchronizeTransform(); + continue; + } + contact.m_islandFlag = true; + island.AddContact(contact); + if (other.m_islandFlag) continue; + other.m_islandFlag = true; + other.m_type !== exports.b2BodyType.b2_staticBody && other.SetAwake(true); + island.AddBody(other); + } + } + var subStep = b2World.SolveTOI_s_subStep; + subStep.dt = (1 - minAlpha) * step.dt; + subStep.inv_dt = 1 / subStep.dt; + subStep.dtRatio = 1; + subStep.positionIterations = 20; + subStep.velocityIterations = step.velocityIterations; + subStep.particleIterations = step.particleIterations; + subStep.warmStarting = false; + island.SolveTOI(subStep, bA.m_islandIndex, bB.m_islandIndex); + for (var i = 0; i < island.m_bodyCount; ++i) { + var body = island.m_bodies[i]; + body.m_islandFlag = false; + if (body.m_type !== exports.b2BodyType.b2_dynamicBody) continue; + body.SynchronizeFixtures(); + for (var ce = body.m_contactList; ce; ce = ce.next) { + ce.contact.m_toiFlag = false; + ce.contact.m_islandFlag = false; + } + } + this.m_contactManager.FindNewContacts(); + if (this.m_subStepping) { + this.m_stepComplete = false; + break; + } + } + }; + b2World.prototype.AddController = function(controller) { + controller.m_next = this.m_controllerList; + controller.m_prev = null; + this.m_controllerList && (this.m_controllerList.m_prev = controller); + this.m_controllerList = controller; + ++this.m_controllerCount; + return controller; + }; + b2World.prototype.RemoveController = function(controller) { + controller.m_prev && (controller.m_prev.m_next = controller.m_next); + controller.m_next && (controller.m_next.m_prev = controller.m_prev); + this.m_controllerList === controller && (this.m_controllerList = controller.m_next); + --this.m_controllerCount; + controller.m_prev = null; + controller.m_next = null; + return controller; + }; + b2World.Step_s_step = new b2TimeStep(); + b2World.Step_s_stepTimer = new b2Timer(); + b2World.Step_s_timer = new b2Timer(); + b2World.DrawDebugData_s_color = new b2Color(0, 0, 0); + b2World.DrawDebugData_s_vs = b2Vec2.MakeArray(4); + b2World.DrawDebugData_s_xf = new b2Transform(); + b2World.QueryFixtureShape_s_aabb = new b2AABB(); + b2World.RayCast_s_input = new b2RayCastInput(); + b2World.RayCast_s_output = new b2RayCastOutput(); + b2World.RayCast_s_point = new b2Vec2(); + b2World.DrawJoint_s_p1 = new b2Vec2(); + b2World.DrawJoint_s_p2 = new b2Vec2(); + b2World.DrawJoint_s_color = new b2Color(.5, .8, .8); + b2World.DrawJoint_s_c = new b2Color(); + b2World.DrawShape_s_ghostColor = new b2Color(); + b2World.SolveTOI_s_subStep = new b2TimeStep(); + b2World.SolveTOI_s_backup = new b2Sweep(); + b2World.SolveTOI_s_backup1 = new b2Sweep(); + b2World.SolveTOI_s_backup2 = new b2Sweep(); + b2World.SolveTOI_s_toi_input = new b2TOIInput(); + b2World.SolveTOI_s_toi_output = new b2TOIOutput(); + return b2World; + })(); + var b2ControllerEdge = (function() { + function b2ControllerEdge(controller, body) { + this.prevBody = null; + this.nextBody = null; + this.prevController = null; + this.nextController = null; + this.controller = controller; + this.body = body; + } + return b2ControllerEdge; + })(); + var b2Controller = (function() { + function b2Controller() { + this.m_bodyList = null; + this.m_bodyCount = 0; + this.m_prev = null; + this.m_next = null; + } + b2Controller.prototype.GetNext = function() { + return this.m_next; + }; + b2Controller.prototype.GetPrev = function() { + return this.m_prev; + }; + b2Controller.prototype.GetBodyList = function() { + return this.m_bodyList; + }; + b2Controller.prototype.AddBody = function(body) { + var edge = new b2ControllerEdge(this, body); + edge.nextBody = this.m_bodyList; + edge.prevBody = null; + this.m_bodyList && (this.m_bodyList.prevBody = edge); + this.m_bodyList = edge; + ++this.m_bodyCount; + edge.nextController = body.m_controllerList; + edge.prevController = null; + body.m_controllerList && (body.m_controllerList.prevController = edge); + body.m_controllerList = edge; + ++body.m_controllerCount; + }; + b2Controller.prototype.RemoveBody = function(body) { + if (this.m_bodyCount <= 0) throw new Error(); + var edge = this.m_bodyList; + while (edge && edge.body !== body) edge = edge.nextBody; + if (null === edge) throw new Error(); + edge.prevBody && (edge.prevBody.nextBody = edge.nextBody); + edge.nextBody && (edge.nextBody.prevBody = edge.prevBody); + this.m_bodyList === edge && (this.m_bodyList = edge.nextBody); + --this.m_bodyCount; + edge.nextController && (edge.nextController.prevController = edge.prevController); + edge.prevController && (edge.prevController.nextController = edge.nextController); + body.m_controllerList === edge && (body.m_controllerList = edge.nextController); + --body.m_controllerCount; + }; + b2Controller.prototype.Clear = function() { + while (this.m_bodyList) this.RemoveBody(this.m_bodyList.body); + this.m_bodyCount = 0; + }; + return b2Controller; + })(); + var b2BuoyancyController = (function(_super) { + __extends(b2BuoyancyController, _super); + function b2BuoyancyController() { + var _this = null !== _super && _super.apply(this, arguments) || this; + _this.normal = new b2Vec2(0, 1); + _this.offset = 0; + _this.density = 0; + _this.velocity = new b2Vec2(0, 0); + _this.linearDrag = 0; + _this.angularDrag = 0; + _this.useDensity = false; + _this.useWorldGravity = true; + _this.gravity = new b2Vec2(0, 0); + return _this; + } + b2BuoyancyController.prototype.Step = function(step) { + if (!this.m_bodyList) return; + this.useWorldGravity && this.gravity.Copy(this.m_bodyList.body.GetWorld().GetGravity()); + for (var i = this.m_bodyList; i; i = i.nextBody) { + var body = i.body; + if (!body.IsAwake()) continue; + var areac = new b2Vec2(); + var massc = new b2Vec2(); + var area = 0; + var mass = 0; + for (var fixture = body.GetFixtureList(); fixture; fixture = fixture.m_next) { + var sc = new b2Vec2(); + var sarea = fixture.GetShape().ComputeSubmergedArea(this.normal, this.offset, body.GetTransform(), sc); + area += sarea; + areac.x += sarea * sc.x; + areac.y += sarea * sc.y; + var shapeDensity = 0; + shapeDensity = this.useDensity ? fixture.GetDensity() : 1; + mass += sarea * shapeDensity; + massc.x += sarea * sc.x * shapeDensity; + massc.y += sarea * sc.y * shapeDensity; + } + areac.x /= area; + areac.y /= area; + massc.x /= mass; + massc.y /= mass; + if (area < b2_epsilon) continue; + var buoyancyForce = this.gravity.Clone().SelfNeg(); + buoyancyForce.SelfMul(this.density * area); + body.ApplyForce(buoyancyForce, massc); + var dragForce = body.GetLinearVelocityFromWorldPoint(areac, new b2Vec2()); + dragForce.SelfSub(this.velocity); + dragForce.SelfMul(-this.linearDrag * area); + body.ApplyForce(dragForce, areac); + body.ApplyTorque(-body.GetInertia() / body.GetMass() * area * body.GetAngularVelocity() * this.angularDrag); + } + }; + b2BuoyancyController.prototype.Draw = function(debugDraw) { + var r = 100; + var p1 = new b2Vec2(); + var p2 = new b2Vec2(); + p1.x = this.normal.x * this.offset + this.normal.y * r; + p1.y = this.normal.y * this.offset - this.normal.x * r; + p2.x = this.normal.x * this.offset - this.normal.y * r; + p2.y = this.normal.y * this.offset + this.normal.x * r; + var color = new b2Color(0, 0, .8); + debugDraw.DrawSegment(p1, p2, color); + }; + return b2BuoyancyController; + })(b2Controller); + var b2ConstantAccelController = (function(_super) { + __extends(b2ConstantAccelController, _super); + function b2ConstantAccelController() { + var _this = null !== _super && _super.apply(this, arguments) || this; + _this.A = new b2Vec2(0, 0); + return _this; + } + b2ConstantAccelController.prototype.Step = function(step) { + var dtA = b2Vec2.MulSV(step.dt, this.A, b2ConstantAccelController.Step_s_dtA); + for (var i = this.m_bodyList; i; i = i.nextBody) { + var body = i.body; + if (!body.IsAwake()) continue; + body.SetLinearVelocity(b2Vec2.AddVV(body.GetLinearVelocity(), dtA, b2Vec2.s_t0)); + } + }; + b2ConstantAccelController.prototype.Draw = function(draw) {}; + b2ConstantAccelController.Step_s_dtA = new b2Vec2(); + return b2ConstantAccelController; + })(b2Controller); + var b2ConstantForceController = (function(_super) { + __extends(b2ConstantForceController, _super); + function b2ConstantForceController() { + var _this = null !== _super && _super.apply(this, arguments) || this; + _this.F = new b2Vec2(0, 0); + return _this; + } + b2ConstantForceController.prototype.Step = function(step) { + for (var i = this.m_bodyList; i; i = i.nextBody) { + var body = i.body; + if (!body.IsAwake()) continue; + body.ApplyForce(this.F, body.GetWorldCenter()); + } + }; + b2ConstantForceController.prototype.Draw = function(draw) {}; + return b2ConstantForceController; + })(b2Controller); + var b2GravityController = (function(_super) { + __extends(b2GravityController, _super); + function b2GravityController() { + var _this = null !== _super && _super.apply(this, arguments) || this; + _this.G = 1; + _this.invSqr = true; + return _this; + } + b2GravityController.prototype.Step = function(step) { + if (this.invSqr) for (var i = this.m_bodyList; i; i = i.nextBody) { + var body1 = i.body; + var p1 = body1.GetWorldCenter(); + var mass1 = body1.GetMass(); + for (var j = this.m_bodyList; j && j !== i; j = j.nextBody) { + var body2 = j.body; + var p2 = body2.GetWorldCenter(); + var mass2 = body2.GetMass(); + var dx = p2.x - p1.x; + var dy = p2.y - p1.y; + var r2 = dx * dx + dy * dy; + if (r2 < b2_epsilon) continue; + var f = b2GravityController.Step_s_f.Set(dx, dy); + f.SelfMul(this.G / r2 / b2Sqrt(r2) * mass1 * mass2); + body1.IsAwake() && body1.ApplyForce(f, p1); + body2.IsAwake() && body2.ApplyForce(f.SelfMul(-1), p2); + } + } else for (var i = this.m_bodyList; i; i = i.nextBody) { + var body1 = i.body; + var p1 = body1.GetWorldCenter(); + var mass1 = body1.GetMass(); + for (var j = this.m_bodyList; j && j !== i; j = j.nextBody) { + var body2 = j.body; + var p2 = body2.GetWorldCenter(); + var mass2 = body2.GetMass(); + var dx = p2.x - p1.x; + var dy = p2.y - p1.y; + var r2 = dx * dx + dy * dy; + if (r2 < b2_epsilon) continue; + var f = b2GravityController.Step_s_f.Set(dx, dy); + f.SelfMul(this.G / r2 * mass1 * mass2); + body1.IsAwake() && body1.ApplyForce(f, p1); + body2.IsAwake() && body2.ApplyForce(f.SelfMul(-1), p2); + } + } + }; + b2GravityController.prototype.Draw = function(draw) {}; + b2GravityController.Step_s_f = new b2Vec2(); + return b2GravityController; + })(b2Controller); + var b2TensorDampingController = (function(_super) { + __extends(b2TensorDampingController, _super); + function b2TensorDampingController() { + var _this = null !== _super && _super.apply(this, arguments) || this; + _this.T = new b2Mat22(); + _this.maxTimestep = 0; + return _this; + } + b2TensorDampingController.prototype.Step = function(step) { + var timestep = step.dt; + if (timestep <= b2_epsilon) return; + timestep > this.maxTimestep && this.maxTimestep > 0 && (timestep = this.maxTimestep); + for (var i = this.m_bodyList; i; i = i.nextBody) { + var body = i.body; + if (!body.IsAwake()) continue; + var damping = body.GetWorldVector(b2Mat22.MulMV(this.T, body.GetLocalVector(body.GetLinearVelocity(), b2Vec2.s_t0), b2Vec2.s_t1), b2TensorDampingController.Step_s_damping); + body.SetLinearVelocity(b2Vec2.AddVV(body.GetLinearVelocity(), b2Vec2.MulSV(timestep, damping, b2Vec2.s_t0), b2Vec2.s_t1)); + } + }; + b2TensorDampingController.prototype.Draw = function(draw) {}; + b2TensorDampingController.prototype.SetAxisAligned = function(xDamping, yDamping) { + this.T.ex.x = -xDamping; + this.T.ex.y = 0; + this.T.ey.x = 0; + this.T.ey.y = -yDamping; + this.maxTimestep = xDamping > 0 || yDamping > 0 ? 1 / b2Max(xDamping, yDamping) : 0; + }; + b2TensorDampingController.Step_s_damping = new b2Vec2(); + return b2TensorDampingController; + })(b2Controller); + var b2RopeDef = (function() { + function b2RopeDef() { + this.vertices = []; + this.count = 0; + this.masses = []; + this.gravity = new b2Vec2(0, 0); + this.damping = .1; + this.k2 = .9; + this.k3 = .1; + } + return b2RopeDef; + })(); + var b2Rope = (function() { + function b2Rope() { + this.m_count = 0; + this.m_ps = []; + this.m_p0s = []; + this.m_vs = []; + this.m_ims = []; + this.m_Ls = []; + this.m_as = []; + this.m_gravity = new b2Vec2(); + this.m_damping = 0; + this.m_k2 = 1; + this.m_k3 = .1; + } + b2Rope.prototype.GetVertexCount = function() { + return this.m_count; + }; + b2Rope.prototype.GetVertices = function() { + return this.m_ps; + }; + b2Rope.prototype.Initialize = function(def) { + this.m_count = def.count; + this.m_ps = b2Vec2.MakeArray(this.m_count); + this.m_p0s = b2Vec2.MakeArray(this.m_count); + this.m_vs = b2Vec2.MakeArray(this.m_count); + this.m_ims = b2MakeNumberArray(this.m_count); + for (var i = 0; i < this.m_count; ++i) { + this.m_ps[i].Copy(def.vertices[i]); + this.m_p0s[i].Copy(def.vertices[i]); + this.m_vs[i].SetZero(); + var m = def.masses[i]; + this.m_ims[i] = m > 0 ? 1 / m : 0; + } + var count2 = this.m_count - 1; + var count3 = this.m_count - 2; + this.m_Ls = b2MakeNumberArray(count2); + this.m_as = b2MakeNumberArray(count3); + for (var i = 0; i < count2; ++i) { + var p1 = this.m_ps[i]; + var p2 = this.m_ps[i + 1]; + this.m_Ls[i] = b2Vec2.DistanceVV(p1, p2); + } + for (var i = 0; i < count3; ++i) { + var p1 = this.m_ps[i]; + var p2 = this.m_ps[i + 1]; + var p3 = this.m_ps[i + 2]; + var d1 = b2Vec2.SubVV(p2, p1, b2Vec2.s_t0); + var d2 = b2Vec2.SubVV(p3, p2, b2Vec2.s_t1); + var a = b2Vec2.CrossVV(d1, d2); + var b = b2Vec2.DotVV(d1, d2); + this.m_as[i] = b2Atan2(a, b); + } + this.m_gravity.Copy(def.gravity); + this.m_damping = def.damping; + this.m_k2 = def.k2; + this.m_k3 = def.k3; + }; + b2Rope.prototype.Step = function(h, iterations) { + if (0 === h) return; + var d = Math.exp(-h * this.m_damping); + for (var i = 0; i < this.m_count; ++i) { + this.m_p0s[i].Copy(this.m_ps[i]); + this.m_ims[i] > 0 && this.m_vs[i].SelfMulAdd(h, this.m_gravity); + this.m_vs[i].SelfMul(d); + this.m_ps[i].SelfMulAdd(h, this.m_vs[i]); + } + for (var i = 0; i < iterations; ++i) { + this.SolveC2(); + this.SolveC3(); + this.SolveC2(); + } + var inv_h = 1 / h; + for (var i = 0; i < this.m_count; ++i) b2Vec2.MulSV(inv_h, b2Vec2.SubVV(this.m_ps[i], this.m_p0s[i], b2Vec2.s_t0), this.m_vs[i]); + }; + b2Rope.prototype.SolveC2 = function() { + var count2 = this.m_count - 1; + for (var i = 0; i < count2; ++i) { + var p1 = this.m_ps[i]; + var p2 = this.m_ps[i + 1]; + var d = b2Vec2.SubVV(p2, p1, b2Rope.s_d); + var L = d.Normalize(); + var im1 = this.m_ims[i]; + var im2 = this.m_ims[i + 1]; + if (im1 + im2 === 0) continue; + var s1 = im1 / (im1 + im2); + var s2 = im2 / (im1 + im2); + p1.SelfMulSub(this.m_k2 * s1 * (this.m_Ls[i] - L), d); + p2.SelfMulAdd(this.m_k2 * s2 * (this.m_Ls[i] - L), d); + } + }; + b2Rope.prototype.SetAngle = function(angle) { + var count3 = this.m_count - 2; + for (var i = 0; i < count3; ++i) this.m_as[i] = angle; + }; + b2Rope.prototype.SolveC3 = function() { + var count3 = this.m_count - 2; + for (var i = 0; i < count3; ++i) { + var p1 = this.m_ps[i]; + var p2 = this.m_ps[i + 1]; + var p3 = this.m_ps[i + 2]; + var m1 = this.m_ims[i]; + var m2 = this.m_ims[i + 1]; + var m3 = this.m_ims[i + 2]; + var d1 = b2Vec2.SubVV(p2, p1, b2Rope.s_d1); + var d2 = b2Vec2.SubVV(p3, p2, b2Rope.s_d2); + var L1sqr = d1.LengthSquared(); + var L2sqr = d2.LengthSquared(); + if (L1sqr * L2sqr === 0) continue; + var a = b2Vec2.CrossVV(d1, d2); + var b = b2Vec2.DotVV(d1, d2); + var angle = b2Atan2(a, b); + var Jd1 = b2Vec2.MulSV(-1 / L1sqr, d1.SelfSkew(), b2Rope.s_Jd1); + var Jd2 = b2Vec2.MulSV(1 / L2sqr, d2.SelfSkew(), b2Rope.s_Jd2); + var J1 = b2Vec2.NegV(Jd1, b2Rope.s_J1); + var J2 = b2Vec2.SubVV(Jd1, Jd2, b2Rope.s_J2); + var J3 = Jd2; + var mass = m1 * b2Vec2.DotVV(J1, J1) + m2 * b2Vec2.DotVV(J2, J2) + m3 * b2Vec2.DotVV(J3, J3); + if (0 === mass) continue; + mass = 1 / mass; + var C = angle - this.m_as[i]; + while (C > b2_pi) { + angle -= 2 * b2_pi; + C = angle - this.m_as[i]; + } + while (C < -b2_pi) { + angle += 2 * b2_pi; + C = angle - this.m_as[i]; + } + var impulse = -this.m_k3 * mass * C; + p1.SelfMulAdd(m1 * impulse, J1); + p2.SelfMulAdd(m2 * impulse, J2); + p3.SelfMulAdd(m3 * impulse, J3); + } + }; + b2Rope.prototype.Draw = function(draw) { + var c = new b2Color(.4, .5, .7); + for (var i = 0; i < this.m_count - 1; ++i) draw.DrawSegment(this.m_ps[i], this.m_ps[i + 1], c); + }; + b2Rope.s_d = new b2Vec2(); + b2Rope.s_d1 = new b2Vec2(); + b2Rope.s_d2 = new b2Vec2(); + b2Rope.s_Jd1 = new b2Vec2(); + b2Rope.s_Jd2 = new b2Vec2(); + b2Rope.s_J1 = new b2Vec2(); + b2Rope.s_J2 = new b2Vec2(); + return b2Rope; + })(); + exports.b2Assert = b2Assert; + exports.b2Maybe = b2Maybe; + exports.b2_maxFloat = b2_maxFloat; + exports.b2_epsilon = b2_epsilon; + exports.b2_epsilon_sq = b2_epsilon_sq; + exports.b2_pi = b2_pi; + exports.b2_maxManifoldPoints = b2_maxManifoldPoints; + exports.b2_maxPolygonVertices = b2_maxPolygonVertices; + exports.b2_aabbExtension = b2_aabbExtension; + exports.b2_aabbMultiplier = b2_aabbMultiplier; + exports.b2_linearSlop = b2_linearSlop; + exports.b2_angularSlop = b2_angularSlop; + exports.b2_polygonRadius = b2_polygonRadius; + exports.b2_maxSubSteps = b2_maxSubSteps; + exports.b2_maxTOIContacts = b2_maxTOIContacts; + exports.b2_velocityThreshold = b2_velocityThreshold; + exports.b2_maxLinearCorrection = b2_maxLinearCorrection; + exports.b2_maxAngularCorrection = b2_maxAngularCorrection; + exports.b2_maxTranslation = b2_maxTranslation; + exports.b2_maxTranslationSquared = b2_maxTranslationSquared; + exports.b2_maxRotation = b2_maxRotation; + exports.b2_maxRotationSquared = b2_maxRotationSquared; + exports.b2_baumgarte = b2_baumgarte; + exports.b2_toiBaumgarte = b2_toiBaumgarte; + exports.b2_invalidParticleIndex = b2_invalidParticleIndex; + exports.b2_maxParticleIndex = b2_maxParticleIndex; + exports.b2_particleStride = b2_particleStride; + exports.b2_minParticleWeight = b2_minParticleWeight; + exports.b2_maxParticlePressure = b2_maxParticlePressure; + exports.b2_maxParticleForce = b2_maxParticleForce; + exports.b2_maxTriadDistance = b2_maxTriadDistance; + exports.b2_maxTriadDistanceSquared = b2_maxTriadDistanceSquared; + exports.b2_minParticleSystemBufferCapacity = b2_minParticleSystemBufferCapacity; + exports.b2_barrierCollisionTime = b2_barrierCollisionTime; + exports.b2_timeToSleep = b2_timeToSleep; + exports.b2_linearSleepTolerance = b2_linearSleepTolerance; + exports.b2_angularSleepTolerance = b2_angularSleepTolerance; + exports.b2Alloc = b2Alloc; + exports.b2Free = b2Free; + exports.b2Log = b2Log; + exports.b2Version = b2Version; + exports.b2_version = b2_version; + exports.b2_branch = b2_branch; + exports.b2_commit = b2_commit; + exports.b2ParseInt = b2ParseInt; + exports.b2ParseUInt = b2ParseUInt; + exports.b2MakeArray = b2MakeArray; + exports.b2MakeNullArray = b2MakeNullArray; + exports.b2MakeNumberArray = b2MakeNumberArray; + exports.b2_pi_over_180 = b2_pi_over_180; + exports.b2_180_over_pi = b2_180_over_pi; + exports.b2_two_pi = b2_two_pi; + exports.b2Abs = b2Abs; + exports.b2Min = b2Min; + exports.b2Max = b2Max; + exports.b2Clamp = b2Clamp; + exports.b2Swap = b2Swap; + exports.b2IsValid = b2IsValid; + exports.b2Sq = b2Sq; + exports.b2InvSqrt = b2InvSqrt; + exports.b2Sqrt = b2Sqrt; + exports.b2Pow = b2Pow; + exports.b2DegToRad = b2DegToRad; + exports.b2RadToDeg = b2RadToDeg; + exports.b2Cos = b2Cos; + exports.b2Sin = b2Sin; + exports.b2Acos = b2Acos; + exports.b2Asin = b2Asin; + exports.b2Atan2 = b2Atan2; + exports.b2NextPowerOfTwo = b2NextPowerOfTwo; + exports.b2IsPowerOfTwo = b2IsPowerOfTwo; + exports.b2Random = b2Random; + exports.b2RandomRange = b2RandomRange; + exports.b2Vec2 = b2Vec2; + exports.b2Vec2_zero = b2Vec2_zero; + exports.b2Vec3 = b2Vec3; + exports.b2Mat22 = b2Mat22; + exports.b2Mat33 = b2Mat33; + exports.b2Rot = b2Rot; + exports.b2Transform = b2Transform; + exports.b2Sweep = b2Sweep; + exports.b2Color = b2Color; + exports.b2Draw = b2Draw; + exports.b2Timer = b2Timer; + exports.b2Counter = b2Counter; + exports.b2GrowableStack = b2GrowableStack; + exports.b2BlockAllocator = b2BlockAllocator; + exports.b2StackAllocator = b2StackAllocator; + exports.b2ContactFeature = b2ContactFeature; + exports.b2ContactID = b2ContactID; + exports.b2ManifoldPoint = b2ManifoldPoint; + exports.b2Manifold = b2Manifold; + exports.b2WorldManifold = b2WorldManifold; + exports.b2GetPointStates = b2GetPointStates; + exports.b2ClipVertex = b2ClipVertex; + exports.b2RayCastInput = b2RayCastInput; + exports.b2RayCastOutput = b2RayCastOutput; + exports.b2AABB = b2AABB; + exports.b2TestOverlapAABB = b2TestOverlapAABB; + exports.b2ClipSegmentToLine = b2ClipSegmentToLine; + exports.b2TestOverlapShape = b2TestOverlapShape; + exports.b2DistanceProxy = b2DistanceProxy; + exports.b2SimplexCache = b2SimplexCache; + exports.b2DistanceInput = b2DistanceInput; + exports.b2DistanceOutput = b2DistanceOutput; + exports.b2ShapeCastInput = b2ShapeCastInput; + exports.b2ShapeCastOutput = b2ShapeCastOutput; + exports.b2_gjk_reset = b2_gjk_reset; + exports.b2SimplexVertex = b2SimplexVertex; + exports.b2Simplex = b2Simplex; + exports.b2Distance = b2Distance; + exports.b2ShapeCast = b2ShapeCast; + exports.b2Pair = b2Pair; + exports.b2BroadPhase = b2BroadPhase; + exports.b2PairLessThan = b2PairLessThan; + exports.b2TreeNode = b2TreeNode; + exports.b2DynamicTree = b2DynamicTree; + exports.b2_toi_reset = b2_toi_reset; + exports.b2TOIInput = b2TOIInput; + exports.b2TOIOutput = b2TOIOutput; + exports.b2SeparationFunction = b2SeparationFunction; + exports.b2TimeOfImpact = b2TimeOfImpact; + exports.b2CollideCircles = b2CollideCircles; + exports.b2CollidePolygonAndCircle = b2CollidePolygonAndCircle; + exports.b2CollidePolygons = b2CollidePolygons; + exports.b2CollideEdgeAndCircle = b2CollideEdgeAndCircle; + exports.b2CollideEdgeAndPolygon = b2CollideEdgeAndPolygon; + exports.b2MassData = b2MassData; + exports.b2Shape = b2Shape; + exports.b2CircleShape = b2CircleShape; + exports.b2PolygonShape = b2PolygonShape; + exports.b2EdgeShape = b2EdgeShape; + exports.b2ChainShape = b2ChainShape; + exports.b2Filter = b2Filter; + exports.b2FixtureDef = b2FixtureDef; + exports.b2FixtureProxy = b2FixtureProxy; + exports.b2Fixture = b2Fixture; + exports.b2BodyDef = b2BodyDef; + exports.b2Body = b2Body; + exports.b2World = b2World; + exports.b2DestructionListener = b2DestructionListener; + exports.b2ContactFilter = b2ContactFilter; + exports.b2ContactImpulse = b2ContactImpulse; + exports.b2ContactListener = b2ContactListener; + exports.b2QueryCallback = b2QueryCallback; + exports.b2RayCastCallback = b2RayCastCallback; + exports.b2Island = b2Island; + exports.b2Profile = b2Profile; + exports.b2TimeStep = b2TimeStep; + exports.b2Position = b2Position; + exports.b2Velocity = b2Velocity; + exports.b2SolverData = b2SolverData; + exports.b2ContactManager = b2ContactManager; + exports.b2MixFriction = b2MixFriction; + exports.b2MixRestitution = b2MixRestitution; + exports.b2ContactEdge = b2ContactEdge; + exports.b2Contact = b2Contact; + exports.b2ContactRegister = b2ContactRegister; + exports.b2ContactFactory = b2ContactFactory; + exports.g_blockSolve = g_blockSolve; + exports.b2VelocityConstraintPoint = b2VelocityConstraintPoint; + exports.b2ContactVelocityConstraint = b2ContactVelocityConstraint; + exports.b2ContactPositionConstraint = b2ContactPositionConstraint; + exports.b2ContactSolverDef = b2ContactSolverDef; + exports.b2PositionSolverManifold = b2PositionSolverManifold; + exports.b2ContactSolver = b2ContactSolver; + exports.b2CircleContact = b2CircleContact; + exports.b2PolygonContact = b2PolygonContact; + exports.b2PolygonAndCircleContact = b2PolygonAndCircleContact; + exports.b2EdgeAndCircleContact = b2EdgeAndCircleContact; + exports.b2EdgeAndPolygonContact = b2EdgeAndPolygonContact; + exports.b2ChainAndCircleContact = b2ChainAndCircleContact; + exports.b2ChainAndPolygonContact = b2ChainAndPolygonContact; + exports.b2Jacobian = b2Jacobian; + exports.b2JointEdge = b2JointEdge; + exports.b2JointDef = b2JointDef; + exports.b2Joint = b2Joint; + exports.b2AreaJointDef = b2AreaJointDef; + exports.b2AreaJoint = b2AreaJoint; + exports.b2DistanceJointDef = b2DistanceJointDef; + exports.b2DistanceJoint = b2DistanceJoint; + exports.b2FrictionJointDef = b2FrictionJointDef; + exports.b2FrictionJoint = b2FrictionJoint; + exports.b2GearJointDef = b2GearJointDef; + exports.b2GearJoint = b2GearJoint; + exports.b2MotorJointDef = b2MotorJointDef; + exports.b2MotorJoint = b2MotorJoint; + exports.b2MouseJointDef = b2MouseJointDef; + exports.b2MouseJoint = b2MouseJoint; + exports.b2PrismaticJointDef = b2PrismaticJointDef; + exports.b2PrismaticJoint = b2PrismaticJoint; + exports.b2_minPulleyLength = b2_minPulleyLength; + exports.b2PulleyJointDef = b2PulleyJointDef; + exports.b2PulleyJoint = b2PulleyJoint; + exports.b2RevoluteJointDef = b2RevoluteJointDef; + exports.b2RevoluteJoint = b2RevoluteJoint; + exports.b2RopeJointDef = b2RopeJointDef; + exports.b2RopeJoint = b2RopeJoint; + exports.b2WeldJointDef = b2WeldJointDef; + exports.b2WeldJoint = b2WeldJoint; + exports.b2WheelJointDef = b2WheelJointDef; + exports.b2WheelJoint = b2WheelJoint; + exports.b2ControllerEdge = b2ControllerEdge; + exports.b2Controller = b2Controller; + exports.b2BuoyancyController = b2BuoyancyController; + exports.b2ConstantAccelController = b2ConstantAccelController; + exports.b2ConstantForceController = b2ConstantForceController; + exports.b2GravityController = b2GravityController; + exports.b2TensorDampingController = b2TensorDampingController; + exports.b2ParticleDef = b2ParticleDef; + exports.b2CalculateParticleIterations = b2CalculateParticleIterations; + exports.b2ParticleHandle = b2ParticleHandle; + exports.b2ParticleGroupDef = b2ParticleGroupDef; + exports.b2ParticleGroup = b2ParticleGroup; + exports.b2GrowableBuffer = b2GrowableBuffer; + exports.b2FixtureParticleQueryCallback = b2FixtureParticleQueryCallback; + exports.b2ParticleContact = b2ParticleContact; + exports.b2ParticleBodyContact = b2ParticleBodyContact; + exports.b2ParticlePair = b2ParticlePair; + exports.b2ParticleTriad = b2ParticleTriad; + exports.b2ParticleSystemDef = b2ParticleSystemDef; + exports.b2RopeDef = b2RopeDef; + exports.b2Rope = b2Rope; + Object.defineProperty(exports, "__esModule", { + value: true + }); + })); + }), {} ], + 437: [ (function(require, module, exports) { + "use strict"; + var _global = "undefined" === typeof window ? global : window; + _global.cc = _global.cc || {}; + cc.internal = cc.internal || {}; + require("./predefine"); + require("./polyfill/string"); + require("./polyfill/misc"); + require("./polyfill/array"); + require("./polyfill/object"); + require("./polyfill/array-buffer"); + require("./polyfill/number"); + true; + require("./polyfill/typescript"); + require("./cocos2d/core/predefine"); + true; + require("./cocos2d"); + require("./extends"); + false; + module.exports = _global.cc; + }), { + "./cocos2d": 353, + "./cocos2d/core/predefine": 265, + "./extends": 412, + "./package": void 0, + "./polyfill/array": 439, + "./polyfill/array-buffer": 438, + "./polyfill/misc": 440, + "./polyfill/number": 441, + "./polyfill/object": 442, + "./polyfill/string": 443, + "./polyfill/typescript": 444, + "./predefine": 445 + } ], + 438: [ (function(require, module, exports) { + "use strict"; + if (!ArrayBuffer.isView) { + var TypedArray = Object.getPrototypeOf(Int8Array); + ArrayBuffer.isView = "function" === typeof TypedArray ? function(obj) { + return obj instanceof TypedArray; + } : function(obj) { + if ("object" !== typeof obj) return false; + var ctor = obj.constructor; + return ctor === Float64Array || ctor === Float32Array || ctor === Uint8Array || ctor === Uint32Array || ctor === Int8Array; + }; + } + }), {} ], + 439: [ (function(require, module, exports) { + "use strict"; + Array.isArray || (Array.isArray = function(arg) { + return "[object Array]" === Object.prototype.toString.call(arg); + }); + Array.prototype.find || (Array.prototype.find = function(callback) { + var length = this.length; + for (var i = 0; i < length; i++) { + var element = this[i]; + if (callback.call(this, element, i, this)) return element; + } + return; + }); + Array.prototype.includes || (Array.prototype.includes = function(value) { + return -1 !== this.indexOf(value); + }); + }), {} ], + 440: [ (function(require, module, exports) { + "use strict"; + Math.sign || (Math.sign = function(x) { + x = +x; + if (0 === x || isNaN(x)) return x; + return x > 0 ? 1 : -1; + }); + Math.log2 || (Math.log2 = function(x) { + return Math.log(x) * Math.LOG2E; + }); + Number.isInteger || (Number.isInteger = function(value) { + return "number" === typeof value && isFinite(value) && Math.floor(value) === value; + }); + if ((false, false) || !console.time) { + var Timer = window.performance || Date; + var _timerTable = Object.create(null); + console.time = function(label) { + _timerTable[label] = Timer.now(); + }; + console.timeEnd = function(label) { + var startTime = _timerTable[label]; + var duration = Timer.now() - startTime; + console.log(label + ": " + duration + "ms"); + }; + } + }), {} ], + 441: [ (function(require, module, exports) { + "use strict"; + Number.parseFloat = Number.parseFloat || parseFloat; + Number.parseInt = Number.parseInt || parseInt; + }), {} ], + 442: [ (function(require, module, exports) { + "use strict"; + Object.assign || (Object.assign = function(target, source) { + return cc.js.mixin(target, source); + }); + Object.getOwnPropertyDescriptors || (Object.getOwnPropertyDescriptors = function(obj) { + var descriptors = {}; + var ownKeys = Object.getOwnPropertyNames(obj); + Object.getOwnPropertySymbols && (ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(obj))); + for (var i = 0; i < ownKeys.length; ++i) { + var key = ownKeys[i]; + descriptors[key] = Object.getOwnPropertyDescriptor(obj, key); + } + return descriptors; + }); + }), {} ], + 443: [ (function(require, module, exports) { + "use strict"; + String.prototype.startsWith || (String.prototype.startsWith = function(searchString, position) { + position = position || 0; + return this.lastIndexOf(searchString, position) === position; + }); + String.prototype.endsWith || (String.prototype.endsWith = function(searchString, position) { + ("undefined" === typeof position || position > this.length) && (position = this.length); + position -= searchString.length; + var lastIndex = this.indexOf(searchString, position); + return -1 !== lastIndex && lastIndex === position; + }); + String.prototype.trimLeft || (String.prototype.trimLeft = function() { + return this.replace(/^\s+/, ""); + }); + }), {} ], + 444: [ (function(require, module, exports) { + "use strict"; + var extendStatics = Object.setPrototypeOf || { + __proto__: [] + } instanceof Array && function(d, b) { + d.__proto__ = b; + } || function(d, b) { + for (var p in b) b.hasOwnProperty(p) && (d[p] = b[p]); + }; + window.__extends = function(d, b) { + extendStatics(d, b); + function __() { + this.constructor = d; + } + d.prototype = null === b ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + window.__assign = Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && (t[p] = s[p]); + } + return t; + }; + window.__rest = function(s, e) { + var t = {}; + for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0 && (t[p] = s[p]); + if (null != s && "function" === typeof Object.getOwnPropertySymbols) for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]) && (t[p[i]] = s[p[i]]); + return t; + }; + window.__decorate = function(decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if ("object" === typeof Reflect && "function" === typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) (d = decorators[i]) && (r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r); + return c > 3 && r && Object.defineProperty(target, key, r), r; + }; + window.__param = function(paramIndex, decorator) { + return function(target, key) { + decorator(target, key, paramIndex); + }; + }; + window.__metadata = function(metadataKey, metadataValue) { + if ("object" === typeof Reflect && "function" === typeof Reflect.metadata) return Reflect.metadata(metadataKey, metadataValue); + }; + window.__awaiter = function(thisArg, _arguments, P, generator) { + function adopt(value) { + return value instanceof P ? value : new P(function(resolve) { + resolve(value); + }); + } + return new (P || (P = Promise))(function(resolve, reject) { + function fulfilled(value) { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + } + function rejected(value) { + try { + step(generator["throw"](value)); + } catch (e) { + reject(e); + } + } + function step(result) { + result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); + } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); + }; + window.__generator = function(thisArg, body) { + var _ = { + label: 0, + sent: function sent() { + if (1 & t[0]) throw t[1]; + return t[1]; + }, + trys: [], + ops: [] + }, f, y, t, g; + return g = { + next: verb(0), + throw: verb(1), + return: verb(2) + }, "function" === typeof Symbol && (g[Symbol.iterator] = function() { + return this; + }), g; + function verb(n) { + return function(v) { + return step([ n, v ]); + }; + } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = 2 & op[0] ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), + 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + (y = 0, t) && (op = [ 2 & op[0], t.value ]); + switch (op[0]) { + case 0: + case 1: + t = op; + break; + + case 4: + _.label++; + return { + value: op[1], + done: false + }; + + case 5: + _.label++; + y = op[1]; + op = [ 0 ]; + continue; + + case 7: + op = _.ops.pop(); + _.trys.pop(); + continue; + + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (6 === op[0] || 2 === op[0])) { + _ = 0; + continue; + } + if (3 === op[0] && (!t || op[1] > t[0] && op[1] < t[3])) { + _.label = op[1]; + break; + } + if (6 === op[0] && _.label < t[1]) { + _.label = t[1]; + t = op; + break; + } + if (t && _.label < t[2]) { + _.label = t[2]; + _.ops.push(op); + break; + } + t[2] && _.ops.pop(); + _.trys.pop(); + continue; + } + op = body.call(thisArg, _); + } catch (e) { + op = [ 6, e ]; + y = 0; + } finally { + f = t = 0; + } + if (5 & op[0]) throw op[1]; + return { + value: op[0] ? op[1] : void 0, + done: true + }; + } + }; + window.__exportStar = function(m, o) { + for (var p in m) "default" === p || Object.prototype.hasOwnProperty.call(o, p) || __createBinding(o, m, p); + }; + window.__createBinding = Object.create ? function(o, m, k, k2) { + void 0 === k2 && (k2 = k); + Object.defineProperty(o, k2, { + enumerable: true, + get: function get() { + return m[k]; + } + }); + } : function(o, m, k, k2) { + void 0 === k2 && (k2 = k); + o[k2] = m[k]; + }; + window.__values = function(o) { + var s = "function" === typeof Symbol && Symbol.iterator, m = s && o[s], i = 0; + if (m) return m.call(o); + if (o && "number" === typeof o.length) return { + next: function next() { + o && i >= o.length && (o = void 0); + return { + value: o && o[i++], + done: !o + }; + } + }; + throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); + }; + window.__read = function(o, n) { + var m = "function" === typeof Symbol && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((void 0 === n || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } catch (error) { + e = { + error: error + }; + } finally { + try { + r && !r.done && (m = i["return"]) && m.call(i); + } finally { + if (e) throw e.error; + } + } + return ar; + }; + window.__spread = function() { + for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); + return ar; + }; + window.__spreadArrays = function() { + for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; + for (var r = Array(s), k = 0, i = 0; i < il; i++) for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, + k++) r[k] = a[j]; + return r; + }; + window.__await = function(v) { + return this instanceof __await ? (this.v = v, this) : new __await(v); + }; + window.__asyncGenerator = function(thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), i, q = []; + return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function() { + return this; + }, i; + function verb(n) { + g[n] && (i[n] = function(v) { + return new Promise(function(a, b) { + q.push([ n, v, a, b ]) > 1 || resume(n, v); + }); + }); + } + function resume(n, v) { + try { + step(g[n](v)); + } catch (e) { + settle(q[0][3], e); + } + } + function step(r) { + r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); + } + function fulfill(value) { + resume("next", value); + } + function reject(value) { + resume("throw", value); + } + function settle(f, v) { + (f(v), q.shift(), q.length) && resume(q[0][0], q[0][1]); + } + }; + window.__asyncDelegator = function(o) { + var i, p; + return i = {}, verb("next"), verb("throw", (function(e) { + throw e; + })), verb("return"), i[Symbol.iterator] = function() { + return this; + }, i; + function verb(n, f) { + i[n] = o[n] ? function(v) { + return (p = !p) ? { + value: __await(o[n](v)), + done: "return" === n + } : f ? f(v) : v; + } : f; + } + }; + window.__asyncValues = function(o) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = "function" === typeof __values ? __values(o) : o[Symbol.iterator](), + i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function() { + return this; + }, i); + function verb(n) { + i[n] = o[n] && function(v) { + return new Promise(function(resolve, reject) { + v = o[n](v), settle(resolve, reject, v.done, v.value); + }); + }; + } + function settle(resolve, reject, d, v) { + Promise.resolve(v).then((function(v) { + resolve({ + value: v, + done: d + }); + }), reject); + } + }; + window.__makeTemplateObject = function(cooked, raw) { + Object.defineProperty ? Object.defineProperty(cooked, "raw", { + value: raw + }) : cooked.raw = raw; + return cooked; + }; + var __setModuleDefault = Object.create ? function(o, v) { + Object.defineProperty(o, "default", { + enumerable: true, + value: v + }); + } : function(o, v) { + o["default"] = v; + }; + window.__importStar = function(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (null != mod) for (var k in mod) "default" !== k && Object.prototype.hasOwnProperty.call(mod, k) && __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; + }; + window.__importDefault = function(mod) { + return mod && mod.__esModule ? mod : { + default: mod + }; + }; + window.__classPrivateFieldGet = function(receiver, privateMap) { + if (!privateMap.has(receiver)) throw new TypeError("attempted to get private field on non-instance"); + return privateMap.get(receiver); + }; + window.__classPrivateFieldSet = function(receiver, privateMap, value) { + if (!privateMap.has(receiver)) throw new TypeError("attempted to set private field on non-instance"); + privateMap.set(receiver, value); + return value; + }; + }), {} ], + 445: [ (function(require, module, exports) { + "use strict"; + var _global = "undefined" === typeof window ? global : window; + function defineMacro(name, defaultValue) { + "undefined" === typeof _global[name] && (_global[name] = defaultValue); + } + function defineDeprecatedMacroGetter(name, defaultValue) { + "undefined" === typeof _global[name] && Object.defineProperty(_global, name, { + get: function get() { + var recommandedUsage; + "CC_WECHATGAMESUB" === name ? recommandedUsage = "cc.sys.platform === cc.sys.WECHAT_GAME_SUB" : "CC_WECHATGAME" === name ? recommandedUsage = "cc.sys.platform === cc.sys.WECHAT_GAME" : "CC_QQPLAY" === name && (recommandedUsage = "cc.sys.platform === cc.sys.QQ_PLAY"); + cc.warnID(1400, name, recommandedUsage); + return defaultValue; + } + }); + } + function defined(name) { + return "object" === typeof _global[name]; + } + defineMacro("CC_BUILD", false); + true; + _global.CC_BUILD = true; + _global.CC_DEV = false; + _global.CC_DEBUG = true; + _global.CC_JSB = false; + _global.CC_NATIVERENDERER = false; + _global.CC_SUPPORT_JIT = true; + _global.CC_PHYSICS_BUILTIN = false; + _global.CC_PHYSICS_CANNON = true; + _global.CC_EDITOR = false; + _global.CC_PREVIEW = false; + _global.CC_TEST = false; + _global.CC_RUNTIME = false; + _global.CC_JSB = false; + var WECHATGAMESUB = !!(defined("wx") && wx.getSharedCanvas); + var WECHATGAME = !!(defined("wx") && (wx.getSystemInfoSync || wx.getSharedCanvas)); + var QQPLAY = defined("bk"); + defineDeprecatedMacroGetter("CC_WECHATGAMESUB", WECHATGAMESUB); + defineDeprecatedMacroGetter("CC_WECHATGAME", WECHATGAME); + defineDeprecatedMacroGetter("CC_QQPLAY", QQPLAY); + false; + var engineVersion = "2.4.9"; + _global["CocosEngine"] = cc.ENGINE_VERSION = engineVersion; + }), {} ] +}, {}, [ 437 ]); \ No newline at end of file diff --git a/Layered_virtual_list_2.x/build/web-mobile/favicon.8de18.ico b/Layered_virtual_list_2.x/build/web-mobile/favicon.8de18.ico new file mode 100644 index 0000000..0bd33cd Binary files /dev/null and b/Layered_virtual_list_2.x/build/web-mobile/favicon.8de18.ico differ diff --git a/Layered_virtual_list_2.x/build/web-mobile/index.html b/Layered_virtual_list_2.x/build/web-mobile/index.html new file mode 100644 index 0000000..f19c704 --- /dev/null +++ b/Layered_virtual_list_2.x/build/web-mobile/index.html @@ -0,0 +1,90 @@ + + + + + + Cocos Creator | Layered_virtual_list_2x + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+
+ + + + + + + + diff --git a/Layered_virtual_list_2.x/build/web-mobile/main.93be7.js b/Layered_virtual_list_2.x/build/web-mobile/main.93be7.js new file mode 100644 index 0000000..909b021 --- /dev/null +++ b/Layered_virtual_list_2.x/build/web-mobile/main.93be7.js @@ -0,0 +1,144 @@ +window.boot = function () { + var settings = window._CCSettings; + window._CCSettings = undefined; + var onProgress = null; + + var RESOURCES = cc.AssetManager.BuiltinBundleName.RESOURCES; + var INTERNAL = cc.AssetManager.BuiltinBundleName.INTERNAL; + var MAIN = cc.AssetManager.BuiltinBundleName.MAIN; + function setLoadingDisplay () { + // Loading splash scene + var splash = document.getElementById('splash'); + var progressBar = splash.querySelector('.progress-bar span'); + onProgress = function (finish, total) { + var percent = 100 * finish / total; + if (progressBar) { + progressBar.style.width = percent.toFixed(2) + '%'; + } + }; + splash.style.display = 'block'; + progressBar.style.width = '0%'; + + cc.director.once(cc.Director.EVENT_AFTER_SCENE_LAUNCH, function () { + splash.style.display = 'none'; + }); + } + + var onStart = function () { + + cc.view.enableRetina(true); + cc.view.resizeWithBrowserSize(true); + + if (cc.sys.isBrowser) { + setLoadingDisplay(); + } + + if (cc.sys.isMobile) { + if (settings.orientation === 'landscape') { + cc.view.setOrientation(cc.macro.ORIENTATION_LANDSCAPE); + } + else if (settings.orientation === 'portrait') { + cc.view.setOrientation(cc.macro.ORIENTATION_PORTRAIT); + } + cc.view.enableAutoFullScreen([ + cc.sys.BROWSER_TYPE_BAIDU, + cc.sys.BROWSER_TYPE_BAIDU_APP, + cc.sys.BROWSER_TYPE_WECHAT, + cc.sys.BROWSER_TYPE_MOBILE_QQ, + cc.sys.BROWSER_TYPE_MIUI, + cc.sys.BROWSER_TYPE_HUAWEI, + cc.sys.BROWSER_TYPE_UC, + ].indexOf(cc.sys.browserType) < 0); + } + + // Limit downloading max concurrent task to 2, + // more tasks simultaneously may cause performance draw back on some android system / browsers. + // You can adjust the number based on your own test result, you have to set it before any loading process to take effect. + if (cc.sys.isBrowser && cc.sys.os === cc.sys.OS_ANDROID) { + cc.assetManager.downloader.maxConcurrency = 2; + cc.assetManager.downloader.maxRequestsPerFrame = 2; + } + + var launchScene = settings.launchScene; + var bundle = cc.assetManager.bundles.find(function (b) { + return b.getSceneInfo(launchScene); + }); + + bundle.loadScene(launchScene, null, onProgress, + function (err, scene) { + if (!err) { + cc.director.runSceneImmediate(scene); + if (cc.sys.isBrowser) { + // show canvas + var canvas = document.getElementById('GameCanvas'); + canvas.style.visibility = ''; + var div = document.getElementById('GameDiv'); + if (div) { + div.style.backgroundImage = ''; + } + console.log('Success to load scene: ' + launchScene); + } + } + } + ); + + }; + + var option = { + id: 'GameCanvas', + debugMode: settings.debug ? cc.debug.DebugMode.INFO : cc.debug.DebugMode.ERROR, + showFPS: settings.debug, + frameRate: 60, + groupList: settings.groupList, + collisionMatrix: settings.collisionMatrix, + }; + + cc.assetManager.init({ + bundleVers: settings.bundleVers, + remoteBundles: settings.remoteBundles, + server: settings.server + }); + + var bundleRoot = [INTERNAL]; + settings.hasResourcesBundle && bundleRoot.push(RESOURCES); + + var count = 0; + function cb (err) { + if (err) return console.error(err.message, err.stack); + count++; + if (count === bundleRoot.length + 1) { + cc.assetManager.loadBundle(MAIN, function (err) { + if (!err) cc.game.run(option, onStart); + }); + } + } + + cc.assetManager.loadScript(settings.jsList.map(function (x) { return 'src/' + x;}), cb); + + for (var i = 0; i < bundleRoot.length; i++) { + cc.assetManager.loadBundle(bundleRoot[i], cb); + } +}; + +if (window.jsb) { + var isRuntime = (typeof loadRuntime === 'function'); + if (isRuntime) { + require('src/settings.bc186.js'); + require('src/cocos2d-runtime.js'); + if (CC_PHYSICS_BUILTIN || CC_PHYSICS_CANNON) { + require('src/physics.js'); + } + require('jsb-adapter/engine/index.js'); + } + else { + require('src/settings.bc186.js'); + require('src/cocos2d-jsb.js'); + if (CC_PHYSICS_BUILTIN || CC_PHYSICS_CANNON) { + require('src/physics.js'); + } + require('jsb-adapter/jsb-engine.js'); + } + + cc.macro.CLEANUP_IMAGE_CACHE = true; + window.boot(); +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/build/web-mobile/physics.9d2de.js b/Layered_virtual_list_2.x/build/web-mobile/physics.9d2de.js new file mode 100644 index 0000000..c5d3b42 --- /dev/null +++ b/Layered_virtual_list_2.x/build/web-mobile/physics.9d2de.js @@ -0,0 +1,9941 @@ +(function() { + function r(e, n, t) { + function o(i, f) { + if (!n[i]) { + if (!e[i]) { + var c = "function" == typeof require && require; + if (!f && c) return c(i, !0); + if (u) return u(i, !0); + var a = new Error("Cannot find module '" + i + "'"); + throw a.code = "MODULE_NOT_FOUND", a; + } + var p = n[i] = { + exports: {} + }; + e[i][0].call(p.exports, function(r) { + var n = e[i][1][r]; + return o(n || r); + }, p, p.exports, r, e, n, t); + } + return n[i].exports; + } + for (var u = "function" == typeof require && require, i = 0; i < t.length; i++) o(t[i]); + return o; + } + return r; +})()({ + 1: [ function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports.CannonRigidBody = void 0; + var _cannon = _interopRequireDefault(require("../../../../../external/cannon/cannon")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + "value" in descriptor && (descriptor.writable = true); + Object.defineProperty(target, descriptor.key, descriptor); + } + } + function _createClass(Constructor, protoProps, staticProps) { + protoProps && _defineProperties(Constructor.prototype, protoProps); + staticProps && _defineProperties(Constructor, staticProps); + return Constructor; + } + var v3_cannon0 = new _cannon["default"].Vec3(); + var v3_cannon1 = new _cannon["default"].Vec3(); + var Vec3 = cc.Vec3; + var CannonRigidBody = function() { + function CannonRigidBody() { + this._rigidBody = void 0; + this._sharedBody = void 0; + this._isEnabled = false; + } + var _proto = CannonRigidBody.prototype; + _proto.__preload = function __preload(com) { + this._rigidBody = com; + this._sharedBody = cc.director.getPhysics3DManager().physicsWorld.getSharedBody(this._rigidBody.node); + this._sharedBody.reference = true; + this._sharedBody.wrappedBody = this; + }; + _proto.onLoad = function onLoad() {}; + _proto.onEnable = function onEnable() { + this._isEnabled = true; + this.mass = this._rigidBody.mass; + this.allowSleep = this._rigidBody.allowSleep; + this.linearDamping = this._rigidBody.linearDamping; + this.angularDamping = this._rigidBody.angularDamping; + this.useGravity = this._rigidBody.useGravity; + this.isKinematic = this._rigidBody.isKinematic; + this.fixedRotation = this._rigidBody.fixedRotation; + this.linearFactor = this._rigidBody.linearFactor; + this.angularFactor = this._rigidBody.angularFactor; + this._sharedBody.enabled = true; + }; + _proto.onDisable = function onDisable() { + this._isEnabled = false; + this._sharedBody.enabled = false; + }; + _proto.onDestroy = function onDestroy() { + this._sharedBody.reference = false; + this._rigidBody = null; + this._sharedBody = null; + }; + _proto.wakeUp = function wakeUp() { + return this._sharedBody.body.wakeUp(); + }; + _proto.sleep = function sleep() { + return this._sharedBody.body.sleep(); + }; + _proto.getLinearVelocity = function getLinearVelocity(out) { + Vec3.copy(out, this._sharedBody.body.velocity); + return out; + }; + _proto.setLinearVelocity = function setLinearVelocity(value) { + var body = this._sharedBody.body; + body.isSleeping() && body.wakeUp(); + Vec3.copy(body.velocity, value); + }; + _proto.getAngularVelocity = function getAngularVelocity(out) { + Vec3.copy(out, this._sharedBody.body.angularVelocity); + return out; + }; + _proto.setAngularVelocity = function setAngularVelocity(value) { + var body = this._sharedBody.body; + body.isSleeping() && body.wakeUp(); + Vec3.copy(body.angularVelocity, value); + }; + _proto.applyForce = function applyForce(force, worldPoint) { + null == worldPoint && (worldPoint = Vec3.ZERO); + var body = this._sharedBody.body; + body.isSleeping() && body.wakeUp(); + body.applyForce(Vec3.copy(v3_cannon0, force), Vec3.copy(v3_cannon1, worldPoint)); + }; + _proto.applyImpulse = function applyImpulse(impulse, worldPoint) { + null == worldPoint && (worldPoint = Vec3.ZERO); + var body = this._sharedBody.body; + body.isSleeping() && body.wakeUp(); + body.applyImpulse(Vec3.copy(v3_cannon0, impulse), Vec3.copy(v3_cannon1, worldPoint)); + }; + _proto.applyLocalForce = function applyLocalForce(force, localPoint) { + null == localPoint && (localPoint = Vec3.ZERO); + var body = this._sharedBody.body; + body.isSleeping() && body.wakeUp(); + body.applyLocalForce(Vec3.copy(v3_cannon0, force), Vec3.copy(v3_cannon1, localPoint)); + }; + _proto.applyLocalImpulse = function applyLocalImpulse(impulse, localPoint) { + null == localPoint && (localPoint = Vec3.ZERO); + var body = this._sharedBody.body; + body.isSleeping() && body.wakeUp(); + body.applyLocalImpulse(Vec3.copy(v3_cannon0, impulse), Vec3.copy(v3_cannon1, localPoint)); + }; + _proto.applyTorque = function applyTorque(torque) { + var body = this._sharedBody.body; + body.isSleeping() && body.wakeUp(); + body.torque.x += torque.x; + body.torque.y += torque.y; + body.torque.z += torque.z; + }; + _proto.applyLocalTorque = function applyLocalTorque(torque) { + var body = this._sharedBody.body; + body.isSleeping() && body.wakeUp(); + Vec3.copy(v3_cannon0, torque); + body.vectorToWorldFrame(v3_cannon0, v3_cannon0); + body.torque.x += v3_cannon0.x; + body.torque.y += v3_cannon0.y; + body.torque.z += v3_cannon0.z; + }; + _createClass(CannonRigidBody, [ { + key: "isAwake", + get: function get() { + return this._sharedBody.body.isAwake(); + } + }, { + key: "isSleepy", + get: function get() { + return this._sharedBody.body.isSleepy(); + } + }, { + key: "isSleeping", + get: function get() { + return this._sharedBody.body.isSleeping(); + } + }, { + key: "allowSleep", + set: function set(v) { + var body = this._sharedBody.body; + body.isSleeping() && body.wakeUp(); + body.allowSleep = v; + } + }, { + key: "mass", + set: function set(value) { + var body = this._sharedBody.body; + body.mass = value; + 0 == body.mass ? body.type = _cannon["default"].Body.STATIC : body.type = this._rigidBody.isKinematic ? _cannon["default"].Body.KINEMATIC : _cannon["default"].Body.DYNAMIC; + body.updateMassProperties(); + body.isSleeping() && body.wakeUp(); + } + }, { + key: "isKinematic", + set: function set(value) { + var body = this._sharedBody.body; + 0 == body.mass ? body.type = _cannon["default"].Body.STATIC : body.type = value ? _cannon["default"].Body.KINEMATIC : _cannon["default"].Body.DYNAMIC; + } + }, { + key: "fixedRotation", + set: function set(value) { + var body = this._sharedBody.body; + body.isSleeping() && body.wakeUp(); + body.fixedRotation = value; + body.updateMassProperties(); + } + }, { + key: "linearDamping", + set: function set(value) { + this._sharedBody.body.linearDamping = value; + } + }, { + key: "angularDamping", + set: function set(value) { + this._sharedBody.body.angularDamping = value; + } + }, { + key: "useGravity", + set: function set(value) { + var body = this._sharedBody.body; + body.isSleeping() && body.wakeUp(); + body.useGravity = value; + } + }, { + key: "linearFactor", + set: function set(value) { + var body = this._sharedBody.body; + body.isSleeping() && body.wakeUp(); + Vec3.copy(body.linearFactor, value); + } + }, { + key: "angularFactor", + set: function set(value) { + var body = this._sharedBody.body; + body.isSleeping() && body.wakeUp(); + Vec3.copy(body.angularFactor, value); + } + }, { + key: "rigidBody", + get: function get() { + return this._rigidBody; + } + }, { + key: "sharedBody", + get: function get() { + return this._sharedBody; + } + }, { + key: "isEnabled", + get: function get() { + return this._isEnabled; + } + } ]); + return CannonRigidBody; + }(); + exports.CannonRigidBody = CannonRigidBody; + }, { + "../../../../../external/cannon/cannon": 24 + } ], + 2: [ function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports.CannonSharedBody = void 0; + var _cannon = _interopRequireDefault(require("../../../../../external/cannon/cannon")); + var _physicsEnum = require("../framework/physics-enum"); + var _util = require("../framework/util"); + var _cannonUtil = require("./cannon-util"); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + "value" in descriptor && (descriptor.writable = true); + Object.defineProperty(target, descriptor.key, descriptor); + } + } + function _createClass(Constructor, protoProps, staticProps) { + protoProps && _defineProperties(Constructor.prototype, protoProps); + staticProps && _defineProperties(Constructor, staticProps); + return Constructor; + } + var LocalDirtyFlag = cc.Node._LocalDirtyFlag; + var PHYSICS_SCALE = LocalDirtyFlag.PHYSICS_SCALE; + var Quat = cc.Quat; + var Vec3 = cc.Vec3; + var fastRemoveAt = cc.js.array.fastRemoveAt; + var v3_0 = new Vec3(); + var quat_0 = new Quat(); + var contactsPool = []; + var CollisionEventObject = { + type: "collision-enter", + selfCollider: null, + otherCollider: null, + contacts: [] + }; + var CannonSharedBody = function() { + CannonSharedBody.getSharedBody = function getSharedBody(node, wrappedWorld) { + var key = node._id; + if (CannonSharedBody.sharedBodiesMap.has(key)) return CannonSharedBody.sharedBodiesMap.get(key); + var newSB = new CannonSharedBody(node, wrappedWorld); + CannonSharedBody.sharedBodiesMap.set(node._id, newSB); + return newSB; + }; + function CannonSharedBody(node, wrappedWorld) { + this.node = void 0; + this.wrappedWorld = void 0; + this.body = new _cannon["default"].Body(); + this.shapes = []; + this.wrappedBody = null; + this.index = -1; + this.ref = 0; + this.onCollidedListener = this.onCollided.bind(this); + this.wrappedWorld = wrappedWorld; + this.node = node; + this.body.material = this.wrappedWorld.world.defaultMaterial; + this.body.addEventListener("cc-collide", this.onCollidedListener); + this._updateGroup(); + this.node.on(cc.Node.EventType.GROUP_CHANGED, this._updateGroup, this); + } + var _proto = CannonSharedBody.prototype; + _proto._updateGroup = function _updateGroup() { + (0, _cannonUtil.groupIndexToBitMask)(this.node.groupIndex, this.body); + }; + _proto.addShape = function addShape(v) { + var index = this.shapes.indexOf(v); + if (index < 0) { + var _index = this.body.shapes.length; + this.body.addShape(v.shape); + this.shapes.push(v); + v.setIndex(_index); + var offset = this.body.shapeOffsets[_index]; + var orient = this.body.shapeOrientations[_index]; + v.setOffsetAndOrient(offset, orient); + } + }; + _proto.removeShape = function removeShape(v) { + var index = this.shapes.indexOf(v); + if (index >= 0) { + fastRemoveAt(this.shapes, index); + this.body.removeShape(v.shape); + v.setIndex(-1); + } + }; + _proto.syncSceneToPhysics = function syncSceneToPhysics(force) { + void 0 === force && (force = false); + var node = this.node; + var needUpdateTransform = (0, _util.worldDirty)(node); + if (!force && !needUpdateTransform) return; + this.body.aabbNeedsUpdate = true; + node.getWorldPosition(v3_0); + node.getWorldRotation(quat_0); + Vec3.copy(this.body.position, v3_0); + Quat.copy(this.body.quaternion, quat_0); + if (node._localMatDirty & PHYSICS_SCALE) { + var wscale = node.__wscale; + for (var i = 0; i < this.shapes.length; i++) this.shapes[i].setScale(wscale); + (0, _cannonUtil.commitShapeUpdates)(this.body); + } + this.body.isSleeping() && this.body.wakeUp(); + }; + _proto.syncPhysicsToScene = function syncPhysicsToScene() { + if (this.body.type != _physicsEnum.ERigidBodyType.STATIC && !this.body.isSleeping()) { + Vec3.copy(v3_0, this.body.position); + Quat.copy(quat_0, this.body.quaternion); + this.node.setWorldPosition(v3_0); + this.node.setWorldRotation(quat_0); + } + }; + _proto.destroy = function destroy() { + this.body.removeEventListener("cc-collide", this.onCollidedListener); + this.node.off(cc.Node.EventType.GROUP_CHANGED, this._updateGroup, this); + CannonSharedBody.sharedBodiesMap["delete"](this.node._id); + delete _cannon["default"].World["idToBodyMap"][this.body.id]; + this.node = null; + this.wrappedWorld = null; + this.body = null; + this.shapes = null; + this.onCollidedListener = null; + }; + _proto.onCollided = function onCollided(event) { + CollisionEventObject.type = event.event; + var self = (0, _util.getWrap)(event.selfShape); + var other = (0, _util.getWrap)(event.otherShape); + if (self) { + CollisionEventObject.selfCollider = self.collider; + CollisionEventObject.otherCollider = other ? other.collider : null; + var i = 0; + for (i = CollisionEventObject.contacts.length; i--; ) contactsPool.push(CollisionEventObject.contacts.pop()); + for (i = 0; i < event.contacts.length; i++) { + var cq = event.contacts[i]; + if (contactsPool.length > 0) { + var c = contactsPool.pop(); + Vec3.copy(c.contactA, cq.ri); + Vec3.copy(c.contactB, cq.rj); + Vec3.copy(c.normal, cq.ni); + CollisionEventObject.contacts.push(c); + } else { + var _c = { + contactA: Vec3.copy(new Vec3(), cq.ri), + contactB: Vec3.copy(new Vec3(), cq.rj), + normal: Vec3.copy(new Vec3(), cq.ni) + }; + CollisionEventObject.contacts.push(_c); + } + } + for (i = 0; i < this.shapes.length; i++) { + var shape = this.shapes[i]; + CollisionEventObject.type = _cannonUtil.deprecatedEventMap[CollisionEventObject.type]; + shape.collider.emit(CollisionEventObject.type, CollisionEventObject); + CollisionEventObject.type = event.event; + shape.collider.emit(CollisionEventObject.type, CollisionEventObject); + } + } + }; + _createClass(CannonSharedBody, [ { + key: "enabled", + set: function set(v) { + if (v) { + if (this.index < 0) { + this.index = this.wrappedWorld.bodies.length; + this.wrappedWorld.addSharedBody(this); + var node = this.node; + this.body.aabbNeedsUpdate = true; + node.getWorldPosition(v3_0); + node.getWorldRotation(quat_0); + var pos = this.body.position; + pos.x = parseFloat(v3_0.x.toFixed(3)); + pos.y = parseFloat(v3_0.y.toFixed(3)); + pos.z = parseFloat(v3_0.z.toFixed(3)); + var rot = this.body.quaternion; + rot.x = parseFloat(quat_0.x.toFixed(12)); + rot.y = parseFloat(quat_0.y.toFixed(12)); + rot.z = parseFloat(quat_0.z.toFixed(12)); + rot.w = parseFloat(quat_0.w.toFixed(12)); + if (node._localMatDirty & PHYSICS_SCALE) { + var wscale = node.__wscale; + for (var i = 0; i < this.shapes.length; i++) this.shapes[i].setScale(wscale); + (0, _cannonUtil.commitShapeUpdates)(this.body); + } + this.body.isSleeping() && this.body.wakeUp(); + } + } else if (this.index >= 0) { + var isRemove = 0 == this.shapes.length && null == this.wrappedBody || 0 == this.shapes.length && null != this.wrappedBody && !this.wrappedBody.rigidBody.enabledInHierarchy || 0 == this.shapes.length && null != this.wrappedBody && !this.wrappedBody.isEnabled; + if (isRemove) { + this.body.sleep(); + this.index = -1; + this.wrappedWorld.removeSharedBody(this); + } + } + } + }, { + key: "reference", + set: function set(v) { + v ? this.ref++ : this.ref--; + 0 == this.ref && this.destroy(); + } + } ]); + return CannonSharedBody; + }(); + exports.CannonSharedBody = CannonSharedBody; + CannonSharedBody.sharedBodiesMap = new Map(); + }, { + "../../../../../external/cannon/cannon": 24, + "../framework/physics-enum": 19, + "../framework/util": 23, + "./cannon-util": 3 + } ], + 3: [ function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports.commitShapeUpdates = commitShapeUpdates; + exports.deprecatedEventMap = void 0; + exports.fillRaycastResult = fillRaycastResult; + exports.groupIndexToBitMask = groupIndexToBitMask; + exports.toCannonRaycastOptions = toCannonRaycastOptions; + var _util = require("../framework/util"); + var Vec3 = cc.Vec3; + function groupIndexToBitMask(groupIndex, out) { + var categoryBits = 1 << groupIndex; + var maskBits = 0; + var bits = cc.game.collisionMatrix[groupIndex]; + if (!bits) { + cc.error("cannon-utils: group is not exist", groupIndex); + return; + } + for (var i = 0; i < bits.length; i++) { + if (!bits[i]) continue; + maskBits |= 1 << i; + } + out.collisionFilterGroup = categoryBits; + out.collisionFilterMask = maskBits; + } + function toCannonRaycastOptions(out, options) { + out.checkCollisionResponse = !options.queryTrigger; + groupIndexToBitMask(options.groupIndex, out); + out.skipBackFaces = false; + } + function fillRaycastResult(result, cannonResult) { + result._assign(Vec3.copy(new Vec3(), cannonResult.hitPointWorld), cannonResult.distance, (0, + _util.getWrap)(cannonResult.shape).collider); + } + function commitShapeUpdates(body) { + body.aabbNeedsUpdate = true; + body.updateMassProperties(); + body.updateBoundingRadius(); + } + var deprecatedEventMap = { + onCollisionEnter: "collision-enter", + onCollisionStay: "collision-stay", + onCollisionExit: "collision-exit", + onTriggerEnter: "trigger-enter", + onTriggerStay: "trigger-stay", + onTriggerExit: "trigger-exit" + }; + exports.deprecatedEventMap = deprecatedEventMap; + }, { + "../framework/util": 23 + } ], + 4: [ function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports.CannonWorld = void 0; + var _cannon = _interopRequireDefault(require("../../../../../external/cannon/cannon")); + var _cannonUtil = require("./cannon-util"); + var _cannonShape = require("./shapes/cannon-shape"); + var _cannonSharedBody = require("./cannon-shared-body"); + var _util = require("../framework/util"); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + "value" in descriptor && (descriptor.writable = true); + Object.defineProperty(target, descriptor.key, descriptor); + } + } + function _createClass(Constructor, protoProps, staticProps) { + protoProps && _defineProperties(Constructor.prototype, protoProps); + staticProps && _defineProperties(Constructor, staticProps); + return Constructor; + } + var Vec3 = cc.Vec3; + var fastRemoveAt = cc.js.array.fastRemoveAt; + var CannonWorld = function() { + function CannonWorld() { + this.bodies = []; + this._world = void 0; + this._raycastResult = new _cannon["default"].RaycastResult(); + this._world = new _cannon["default"].World(); + this._world.broadphase = new _cannon["default"].NaiveBroadphase(); + this._world.addEventListener("postStep", this.onPostStep.bind(this)); + } + var _proto = CannonWorld.prototype; + _proto.onPostStep = function onPostStep() { + var p3dm = cc.director.getPhysics3DManager(); + if (p3dm.useFixedDigit) { + var pd = p3dm.fixDigits.position; + var rd = p3dm.fixDigits.rotation; + var bodies = this._world.bodies; + for (var i = 0; i < bodies.length; i++) { + var bi = bodies[i]; + if (bi.type != _cannon["default"].Body.STATIC && !bi.isSleeping()) { + var pos = bi.position; + pos.x = parseFloat(pos.x.toFixed(pd)); + pos.y = parseFloat(pos.y.toFixed(pd)); + pos.z = parseFloat(pos.z.toFixed(pd)); + var rot = bi.quaternion; + rot.x = parseFloat(rot.x.toFixed(rd)); + rot.y = parseFloat(rot.y.toFixed(rd)); + rot.z = parseFloat(rot.z.toFixed(rd)); + rot.w = parseFloat(rot.w.toFixed(rd)); + var vel = bi.velocity; + vel.x = parseFloat(vel.x.toFixed(pd)); + vel.y = parseFloat(vel.y.toFixed(pd)); + vel.z = parseFloat(vel.z.toFixed(pd)); + var avel = bi.angularVelocity; + avel.x = parseFloat(avel.x.toFixed(pd)); + avel.y = parseFloat(avel.y.toFixed(pd)); + avel.z = parseFloat(avel.z.toFixed(pd)); + } + } + } + }; + _proto.step = function step(deltaTime, timeSinceLastCalled, maxSubStep) { + this.syncSceneToPhysics(); + this._world.step(deltaTime, timeSinceLastCalled, maxSubStep); + this.syncPhysicsToScene(); + this.emitEvents(); + }; + _proto.syncSceneToPhysics = function syncSceneToPhysics() { + (0, _util.clearNodeTransformRecord)(); + for (var i = 0; i < this.bodies.length; i++) this.bodies[i].syncSceneToPhysics(); + (0, _util.clearNodeTransformDirtyFlag)(); + }; + _proto.syncPhysicsToScene = function syncPhysicsToScene() { + for (var i = 0; i < this.bodies.length; i++) this.bodies[i].syncPhysicsToScene(); + }; + _proto.emitEvents = function emitEvents() { + this._world.emitTriggeredEvents(); + this._world.emitCollisionEvents(); + }; + _proto.raycastClosest = function raycastClosest(worldRay, options, result) { + setupFromAndTo(worldRay, options.maxDistance); + (0, _cannonUtil.toCannonRaycastOptions)(raycastOpt, options); + var hit = this._world.raycastClosest(from, to, raycastOpt, this._raycastResult); + hit && (0, _cannonUtil.fillRaycastResult)(result, this._raycastResult); + return hit; + }; + _proto.raycast = function raycast(worldRay, options, pool, results) { + setupFromAndTo(worldRay, options.maxDistance); + (0, _cannonUtil.toCannonRaycastOptions)(raycastOpt, options); + var hit = this._world.raycastAll(from, to, raycastOpt, function(result) { + var r = pool.add(); + (0, _cannonUtil.fillRaycastResult)(r, result); + results.push(r); + }); + return hit; + }; + _proto.getSharedBody = function getSharedBody(node) { + return _cannonSharedBody.CannonSharedBody.getSharedBody(node, this); + }; + _proto.addSharedBody = function addSharedBody(sharedBody) { + var i = this.bodies.indexOf(sharedBody); + if (i < 0) { + this.bodies.push(sharedBody); + this._world.addBody(sharedBody.body); + } + }; + _proto.removeSharedBody = function removeSharedBody(sharedBody) { + var i = this.bodies.indexOf(sharedBody); + if (i >= 0) { + fastRemoveAt(this.bodies, i); + this._world.remove(sharedBody.body); + } + }; + _createClass(CannonWorld, [ { + key: "world", + get: function get() { + return this._world; + } + }, { + key: "defaultMaterial", + set: function set(mat) { + this._world.defaultMaterial.friction = mat.friction; + this._world.defaultMaterial.restitution = mat.restitution; + null != _cannonShape.CannonShape.idToMaterial[mat._uuid] && (_cannonShape.CannonShape.idToMaterial[mat._uuid] = this._world.defaultMaterial); + } + }, { + key: "allowSleep", + set: function set(v) { + this._world.allowSleep = v; + } + }, { + key: "gravity", + set: function set(gravity) { + Vec3.copy(this._world.gravity, gravity); + } + } ]); + return CannonWorld; + }(); + exports.CannonWorld = CannonWorld; + var from = new _cannon["default"].Vec3(); + var to = new _cannon["default"].Vec3(); + function setupFromAndTo(worldRay, distance) { + Vec3.copy(from, worldRay.o); + worldRay.computeHit(to, distance); + } + var raycastOpt = { + checkCollisionResponse: false, + collisionFilterGroup: -1, + collisionFilterMask: -1, + skipBackFaces: false + }; + }, { + "../../../../../external/cannon/cannon": 24, + "../framework/util": 23, + "./cannon-shared-body": 2, + "./cannon-util": 3, + "./shapes/cannon-shape": 7 + } ], + 5: [ function(require, module, exports) { + "use strict"; + var _physicsSelector = require("../framework/physics-selector"); + var _cannonRigidBody = require("./cannon-rigid-body"); + var _cannonWorld = require("./cannon-world"); + var _cannonBoxShape = require("./shapes/cannon-box-shape"); + var _cannonSphereShape = require("./shapes/cannon-sphere-shape"); + true; + (0, _physicsSelector.instantiate)(_cannonBoxShape.CannonBoxShape, _cannonSphereShape.CannonSphereShape, _cannonRigidBody.CannonRigidBody, _cannonWorld.CannonWorld); + }, { + "../framework/physics-selector": 22, + "./cannon-rigid-body": 1, + "./cannon-world": 4, + "./shapes/cannon-box-shape": 6, + "./shapes/cannon-sphere-shape": 8 + } ], + 6: [ function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports.CannonBoxShape = void 0; + var _cannon = _interopRequireDefault(require("../../../../../../external/cannon/cannon")); + var _cannonUtil = require("../cannon-util"); + var _cannonShape = require("./cannon-shape"); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + "value" in descriptor && (descriptor.writable = true); + Object.defineProperty(target, descriptor.key, descriptor); + } + } + function _createClass(Constructor, protoProps, staticProps) { + protoProps && _defineProperties(Constructor.prototype, protoProps); + staticProps && _defineProperties(Constructor, staticProps); + return Constructor; + } + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + _setPrototypeOf(subClass, superClass); + } + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + return _setPrototypeOf(o, p); + } + var Vec3 = cc.Vec3; + var v3_0 = new Vec3(); + var CannonBoxShape = function(_CannonShape) { + _inheritsLoose(CannonBoxShape, _CannonShape); + function CannonBoxShape(size) { + var _this; + _this = _CannonShape.call(this) || this; + _this.halfExtent = new _cannon["default"].Vec3(); + Vec3.multiplyScalar(_this.halfExtent, size, .5); + _this._shape = new _cannon["default"].Box(_this.halfExtent.clone()); + return _this; + } + var _proto = CannonBoxShape.prototype; + _proto.onLoad = function onLoad() { + _CannonShape.prototype.onLoad.call(this); + this.size = this.boxCollider.size; + }; + _proto.setScale = function setScale(scale) { + _CannonShape.prototype.setScale.call(this, scale); + this.size = this.boxCollider.size; + }; + _createClass(CannonBoxShape, [ { + key: "boxCollider", + get: function get() { + return this.collider; + } + }, { + key: "box", + get: function get() { + return this._shape; + } + }, { + key: "size", + set: function set(v) { + this.collider.node.getWorldScale(v3_0); + v3_0.x = Math.abs(v3_0.x); + v3_0.y = Math.abs(v3_0.y); + v3_0.z = Math.abs(v3_0.z); + Vec3.multiplyScalar(this.halfExtent, v, .5); + Vec3.multiply(this.box.halfExtents, this.halfExtent, v3_0); + this.box.updateConvexPolyhedronRepresentation(); + -1 != this._index && (0, _cannonUtil.commitShapeUpdates)(this._body); + } + } ]); + return CannonBoxShape; + }(_cannonShape.CannonShape); + exports.CannonBoxShape = CannonBoxShape; + }, { + "../../../../../../external/cannon/cannon": 24, + "../cannon-util": 3, + "./cannon-shape": 7 + } ], + 7: [ function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports.CannonShape = void 0; + var _cannon = _interopRequireDefault(require("../../../../../../external/cannon/cannon")); + var _util = require("../../framework/util"); + var _cannonUtil = require("../cannon-util"); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + "value" in descriptor && (descriptor.writable = true); + Object.defineProperty(target, descriptor.key, descriptor); + } + } + function _createClass(Constructor, protoProps, staticProps) { + protoProps && _defineProperties(Constructor.prototype, protoProps); + staticProps && _defineProperties(Constructor, staticProps); + return Constructor; + } + var TriggerEventObject = { + type: "trigger-enter", + selfCollider: null, + otherCollider: null + }; + var Vec3 = cc.Vec3; + var v3_0 = new Vec3(); + var CannonShape = function() { + function CannonShape() { + this._collider = void 0; + this._shape = void 0; + this._offset = new _cannon["default"].Vec3(); + this._orient = new _cannon["default"].Quaternion(); + this._index = -1; + this._sharedBody = void 0; + this.onTriggerListener = this.onTrigger.bind(this); + } + var _proto = CannonShape.prototype; + _proto.__preload = function __preload(comp) { + this._collider = comp; + (0, _util.setWrap)(this._shape, this); + this._shape.addEventListener("cc-trigger", this.onTriggerListener); + this._sharedBody = cc.director.getPhysics3DManager().physicsWorld.getSharedBody(this._collider.node); + this._sharedBody.reference = true; + }; + _proto.onLoad = function onLoad() { + this.center = this._collider.center; + this.isTrigger = this._collider.isTrigger; + }; + _proto.onEnable = function onEnable() { + this._sharedBody.addShape(this); + this._sharedBody.enabled = true; + }; + _proto.onDisable = function onDisable() { + this._sharedBody.removeShape(this); + this._sharedBody.enabled = false; + }; + _proto.onDestroy = function onDestroy() { + this._sharedBody.reference = false; + this._shape.removeEventListener("cc-trigger", this.onTriggerListener); + delete _cannon["default"].World["idToShapeMap"][this._shape.id]; + this._sharedBody = null; + (0, _util.setWrap)(this._shape, null); + this._offset = null; + this._orient = null; + this._shape = null; + this._collider = null; + this.onTriggerListener = null; + }; + _proto.setScale = function setScale(scale) { + this._setCenter(this._collider.center); + }; + _proto.setIndex = function setIndex(index) { + this._index = index; + }; + _proto.setOffsetAndOrient = function setOffsetAndOrient(offset, orient) { + cc.Vec3.copy(offset, this._offset); + cc.Vec3.copy(orient, this._orient); + this._offset = offset; + this._orient = orient; + }; + _proto._setCenter = function _setCenter(v) { + var lpos = this._offset; + Vec3.copy(lpos, v); + this._collider.node.getWorldScale(v3_0); + Vec3.multiply(lpos, lpos, v3_0); + }; + _proto.onTrigger = function onTrigger(event) { + TriggerEventObject.type = event.event; + var self = (0, _util.getWrap)(event.selfShape); + var other = (0, _util.getWrap)(event.otherShape); + if (self) { + TriggerEventObject.selfCollider = self.collider; + TriggerEventObject.otherCollider = other ? other.collider : null; + TriggerEventObject.type = _cannonUtil.deprecatedEventMap[TriggerEventObject.type]; + this._collider.emit(TriggerEventObject.type, TriggerEventObject); + TriggerEventObject.type = event.event; + this._collider.emit(TriggerEventObject.type, TriggerEventObject); + } + }; + _createClass(CannonShape, [ { + key: "shape", + get: function get() { + return this._shape; + } + }, { + key: "collider", + get: function get() { + return this._collider; + } + }, { + key: "attachedRigidBody", + get: function get() { + if (this._sharedBody.wrappedBody) return this._sharedBody.wrappedBody.rigidBody; + return null; + } + }, { + key: "sharedBody", + get: function get() { + return this._sharedBody; + } + }, { + key: "material", + set: function set(mat) { + if (null == mat) this._shape.material = null; else { + null == CannonShape.idToMaterial[mat._uuid] && (CannonShape.idToMaterial[mat._uuid] = new _cannon["default"].Material(mat._uuid)); + this._shape.material = CannonShape.idToMaterial[mat._uuid]; + this._shape.material.friction = mat.friction; + this._shape.material.restitution = mat.restitution; + } + } + }, { + key: "isTrigger", + set: function set(v) { + this._shape.collisionResponse = !v; + this._index >= 0 && this._body.updateHasTrigger(); + } + }, { + key: "center", + set: function set(v) { + this._setCenter(v); + this._index >= 0 && (0, _cannonUtil.commitShapeUpdates)(this._body); + } + }, { + key: "_body", + get: function get() { + return this._sharedBody.body; + } + } ]); + return CannonShape; + }(); + exports.CannonShape = CannonShape; + CannonShape.idToMaterial = {}; + }, { + "../../../../../../external/cannon/cannon": 24, + "../../framework/util": 23, + "../cannon-util": 3 + } ], + 8: [ function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports.CannonSphereShape = void 0; + var _cannon = _interopRequireDefault(require("../../../../../../external/cannon/cannon")); + var _cannonUtil = require("../cannon-util"); + var _cannonShape = require("./cannon-shape"); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + "value" in descriptor && (descriptor.writable = true); + Object.defineProperty(target, descriptor.key, descriptor); + } + } + function _createClass(Constructor, protoProps, staticProps) { + protoProps && _defineProperties(Constructor.prototype, protoProps); + staticProps && _defineProperties(Constructor, staticProps); + return Constructor; + } + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + _setPrototypeOf(subClass, superClass); + } + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + return _setPrototypeOf(o, p); + } + var v3_0 = new cc.Vec3(); + var CannonSphereShape = function(_CannonShape) { + _inheritsLoose(CannonSphereShape, _CannonShape); + function CannonSphereShape(radius) { + var _this; + _this = _CannonShape.call(this) || this; + _this._radius = void 0; + _this._radius = radius; + _this._shape = new _cannon["default"].Sphere(_this._radius); + return _this; + } + var _proto = CannonSphereShape.prototype; + _proto.onLoad = function onLoad() { + _CannonShape.prototype.onLoad.call(this); + this.radius = this.sphereCollider.radius; + }; + _proto.setScale = function setScale(scale) { + _CannonShape.prototype.setScale.call(this, scale); + this.radius = this.sphereCollider.radius; + }; + _createClass(CannonSphereShape, [ { + key: "sphereCollider", + get: function get() { + return this.collider; + } + }, { + key: "sphere", + get: function get() { + return this._shape; + } + }, { + key: "radius", + get: function get() { + return this._radius; + }, + set: function set(v) { + this.collider.node.getWorldScale(v3_0); + var max = v3_0.maxAxis(); + this.sphere.radius = v * Math.abs(max); + this.sphere.updateBoundingSphereRadius(); + -1 != this._index && (0, _cannonUtil.commitShapeUpdates)(this._body); + } + } ]); + return CannonSphereShape; + }(_cannonShape.CannonShape); + exports.CannonSphereShape = CannonSphereShape; + }, { + "../../../../../../external/cannon/cannon": 24, + "../cannon-util": 3, + "./cannon-shape": 7 + } ], + 9: [ function(require, module, exports) { + "use strict"; + require("../cannon/instantiate"); + var _cannon = _interopRequireDefault(require("../../../../../external/cannon/cannon")); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + window && (window.CANNON = _cannon["default"]); + }, { + "../../../../../external/cannon/cannon": 24, + "../cannon/instantiate": 5 + } ], + 10: [ function(require, module, exports) { + "use strict"; + exports.__esModule = true; + var _framework = require("../framework"); + Object.keys(_framework).forEach(function(key) { + if ("default" === key || "__esModule" === key) return; + if (key in exports && exports[key] === _framework[key]) return; + exports[key] = _framework[key]; + }); + }, { + "../framework": 17 + } ], + 11: [ function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports.PhysicsMaterial = void 0; + var _dec, _class, _class2, _descriptor, _descriptor2, _class3, _temp; + 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 + }); + } + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + "value" in descriptor && (descriptor.writable = true); + Object.defineProperty(target, descriptor.key, descriptor); + } + } + function _createClass(Constructor, protoProps, staticProps) { + protoProps && _defineProperties(Constructor.prototype, protoProps); + staticProps && _defineProperties(Constructor, staticProps); + return Constructor; + } + function _assertThisInitialized(self) { + if (void 0 === self) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + return self; + } + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + _setPrototypeOf(subClass, superClass); + } + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + return _setPrototypeOf(o, p); + } + 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; + ("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 && void 0 !== desc.initializer) { + desc.value = desc.initializer ? desc.initializer.call(context) : void 0; + desc.initializer = void 0; + } + if (void 0 === desc.initializer) { + Object.defineProperty(target, property, desc); + desc = null; + } + return desc; + } + function _initializerWarningHelper(descriptor, context) { + throw new Error("Decorating class property failed. Please ensure that proposal-class-properties is enabled and runs after the decorators transform."); + } + var _cc$_decorator = cc._decorator, ccclass = _cc$_decorator.ccclass, property = _cc$_decorator.property; + var fastRemove = cc.js.array.fastRemove; + var equals = cc.math.equals; + var PhysicsMaterial = (_dec = ccclass("cc.PhysicsMaterial"), _dec(_class = (_class2 = (_temp = _class3 = function(_cc$Asset) { + _inheritsLoose(PhysicsMaterial, _cc$Asset); + function PhysicsMaterial() { + var _this; + _this = _cc$Asset.call(this) || this; + _initializerDefineProperty(_this, "_friction", _descriptor, _assertThisInitialized(_this)); + _initializerDefineProperty(_this, "_restitution", _descriptor2, _assertThisInitialized(_this)); + cc.EventTarget.call(_assertThisInitialized(_this)); + PhysicsMaterial.allMaterials.push(_assertThisInitialized(_this)); + "" == _this._uuid && (_this._uuid = "pm_" + PhysicsMaterial._idCounter++); + return _this; + } + var _proto = PhysicsMaterial.prototype; + _proto.clone = function clone() { + var c = new PhysicsMaterial(); + c._friction = this._friction; + c._restitution = this._restitution; + return c; + }; + _proto.destroy = function destroy() { + if (_cc$Asset.prototype.destroy.call(this)) { + fastRemove(PhysicsMaterial.allMaterials, this); + return true; + } + return false; + }; + _createClass(PhysicsMaterial, [ { + key: "friction", + get: function get() { + return this._friction; + }, + set: function set(value) { + if (!equals(this._friction, value)) { + this._friction = value; + this.emit("physics_material_update"); + } + } + }, { + key: "restitution", + get: function get() { + return this._restitution; + }, + set: function set(value) { + if (!equals(this._restitution, value)) { + this._restitution = value; + this.emit("physics_material_update"); + } + } + } ]); + return PhysicsMaterial; + }(cc.Asset), _class3.allMaterials = [], _class3._idCounter = 0, _temp), _descriptor = _applyDecoratedDescriptor(_class2.prototype, "_friction", [ property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return .1; + } + }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "_restitution", [ property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return .1; + } + }), _applyDecoratedDescriptor(_class2.prototype, "friction", [ property ], Object.getOwnPropertyDescriptor(_class2.prototype, "friction"), _class2.prototype), + _applyDecoratedDescriptor(_class2.prototype, "restitution", [ property ], Object.getOwnPropertyDescriptor(_class2.prototype, "restitution"), _class2.prototype), + _class2)) || _class); + exports.PhysicsMaterial = PhysicsMaterial; + cc.js.mixin(PhysicsMaterial.prototype, cc.EventTarget.prototype); + cc.PhysicsMaterial = PhysicsMaterial; + }, {} ], + 12: [ function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports.BoxCollider3D = void 0; + var _instance = require("../../instance"); + var _colliderComponent = require("./collider-component"); + var _dec, _dec2, _dec3, _dec4, _class, _class2, _descriptor; + 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 + }); + } + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + "value" in descriptor && (descriptor.writable = true); + Object.defineProperty(target, descriptor.key, descriptor); + } + } + function _createClass(Constructor, protoProps, staticProps) { + protoProps && _defineProperties(Constructor.prototype, protoProps); + staticProps && _defineProperties(Constructor, staticProps); + return Constructor; + } + function _assertThisInitialized(self) { + if (void 0 === self) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + return self; + } + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + _setPrototypeOf(subClass, superClass); + } + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + return _setPrototypeOf(o, p); + } + function _initializerWarningHelper(descriptor, context) { + throw new Error("Decorating class property failed. Please ensure that proposal-class-properties is enabled and runs after the decorators transform."); + } + 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; + ("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 && void 0 !== desc.initializer) { + desc.value = desc.initializer ? desc.initializer.call(context) : void 0; + desc.initializer = void 0; + } + if (void 0 === desc.initializer) { + Object.defineProperty(target, property, desc); + desc = null; + } + return desc; + } + var _cc$_decorator = cc._decorator, ccclass = _cc$_decorator.ccclass, executeInEditMode = _cc$_decorator.executeInEditMode, executionOrder = _cc$_decorator.executionOrder, menu = _cc$_decorator.menu, property = _cc$_decorator.property; + var Vec3 = cc.Vec3; + var BoxCollider3D = (_dec = ccclass("cc.BoxCollider3D"), _dec2 = executionOrder(98), + _dec3 = menu("i18n:MAIN_MENU.component.physics/Collider/Box 3D"), _dec4 = property({ + type: cc.Vec3 + }), _dec(_class = _dec2(_class = _dec3(_class = executeInEditMode(_class = (_class2 = function(_Collider3D) { + _inheritsLoose(BoxCollider3D, _Collider3D); + function BoxCollider3D() { + var _this; + _this = _Collider3D.call(this) || this; + _initializerDefineProperty(_this, "_size", _descriptor, _assertThisInitialized(_this)); + true; + _this._shape = (0, _instance.createBoxShape)(_this._size); + return _this; + } + _createClass(BoxCollider3D, [ { + key: "size", + get: function get() { + return this._size; + }, + set: function set(value) { + Vec3.copy(this._size, value); + true; + this.boxShape.size = this._size; + } + }, { + key: "boxShape", + get: function get() { + return this._shape; + } + } ]); + return BoxCollider3D; + }(_colliderComponent.Collider3D), _applyDecoratedDescriptor(_class2.prototype, "size", [ _dec4 ], Object.getOwnPropertyDescriptor(_class2.prototype, "size"), _class2.prototype), + _descriptor = _applyDecoratedDescriptor(_class2.prototype, "_size", [ property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new Vec3(1, 1, 1); + } + }), _class2)) || _class) || _class) || _class) || _class); + exports.BoxCollider3D = BoxCollider3D; + }, { + "../../instance": 18, + "./collider-component": 13 + } ], + 13: [ function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports.Collider3D = void 0; + var _physicsMaterial = require("../../assets/physics-material"); + var _dec, _dec2, _dec3, _dec4, _dec5, _class, _class2, _descriptor, _descriptor2, _descriptor3; + 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 + }); + } + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + "value" in descriptor && (descriptor.writable = true); + Object.defineProperty(target, descriptor.key, descriptor); + } + } + function _createClass(Constructor, protoProps, staticProps) { + protoProps && _defineProperties(Constructor.prototype, protoProps); + staticProps && _defineProperties(Constructor, staticProps); + return Constructor; + } + function _assertThisInitialized(self) { + if (void 0 === self) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + return self; + } + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + _setPrototypeOf(subClass, superClass); + } + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + return _setPrototypeOf(o, p); + } + function _initializerWarningHelper(descriptor, context) { + throw new Error("Decorating class property failed. Please ensure that proposal-class-properties is enabled and runs after the decorators transform."); + } + 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; + ("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 && void 0 !== desc.initializer) { + desc.value = desc.initializer ? desc.initializer.call(context) : void 0; + desc.initializer = void 0; + } + if (void 0 === desc.initializer) { + Object.defineProperty(target, property, desc); + desc = null; + } + return desc; + } + var _cc$_decorator = cc._decorator, ccclass = _cc$_decorator.ccclass, property = _cc$_decorator.property; + var Vec3 = cc.Vec3; + var Collider3D = (_dec = ccclass("cc.Collider3D"), _dec2 = property({ + type: _physicsMaterial.PhysicsMaterial, + displayName: "Material", + displayOrder: -1 + }), _dec3 = property({ + displayOrder: 0 + }), _dec4 = property({ + type: cc.Vec3, + displayOrder: 1 + }), _dec5 = property({ + type: _physicsMaterial.PhysicsMaterial + }), _dec(_class = (_class2 = function(_cc$Component) { + _inheritsLoose(Collider3D, _cc$Component); + function Collider3D() { + var _this; + _this = _cc$Component.call(this) || this; + _this._shape = void 0; + _this._isSharedMaterial = true; + _initializerDefineProperty(_this, "_material", _descriptor, _assertThisInitialized(_this)); + _initializerDefineProperty(_this, "_isTrigger", _descriptor2, _assertThisInitialized(_this)); + _initializerDefineProperty(_this, "_center", _descriptor3, _assertThisInitialized(_this)); + cc.EventTarget.call(_assertThisInitialized(_this)); + return _this; + } + var _proto = Collider3D.prototype; + _proto.on = function on(type, callback, target, useCapture) {}; + _proto.off = function off(type, callback, target) {}; + _proto.once = function once(type, callback, target) {}; + _proto.emit = function emit(key) {}; + _proto.__preload = function __preload() { + true; + this._shape.__preload(this); + }; + _proto.onLoad = function onLoad() { + true; + true; + this.sharedMaterial = null == this._material ? cc.director.getPhysics3DManager().defaultMaterial : this._material; + this._shape.onLoad(); + }; + _proto.onEnable = function onEnable() { + true; + this._shape.onEnable(); + }; + _proto.onDisable = function onDisable() { + true; + this._shape.onDisable(); + }; + _proto.onDestroy = function onDestroy() { + true; + this._material && this._material.off("physics_material_update", this._updateMaterial, this); + this._shape.onDestroy(); + }; + _proto._updateMaterial = function _updateMaterial() { + true; + this._shape.material = this._material; + }; + _createClass(Collider3D, [ { + key: "sharedMaterial", + get: function get() { + return this._material; + }, + set: function set(value) { + this.material = value; + } + }, { + key: "material", + get: function get() { + true; + if (this._isSharedMaterial && null != this._material) { + this._material.off("physics_material_update", this._updateMaterial, this); + this._material = this._material.clone(); + this._material.on("physics_material_update", this._updateMaterial, this); + this._isSharedMaterial = false; + } + return this._material; + }, + set: function set(value) { + false, false; + if (null != value && null != this._material) { + if (this._material._uuid != value._uuid) { + this._material.off("physics_material_update", this._updateMaterial, this); + value.on("physics_material_update", this._updateMaterial, this); + this._isSharedMaterial = false; + this._material = value; + } + } else if (null != value && null == this._material) { + value.on("physics_material_update", this._updateMaterial, this); + this._material = value; + } else if (null == value && null != this._material) { + this._material.off("physics_material_update", this._updateMaterial, this); + this._material = value; + } + this._updateMaterial(); + } + }, { + key: "isTrigger", + get: function get() { + return this._isTrigger; + }, + set: function set(value) { + this._isTrigger = value; + true; + this._shape.isTrigger = this._isTrigger; + } + }, { + key: "center", + get: function get() { + return this._center; + }, + set: function set(value) { + Vec3.copy(this._center, value); + true; + this._shape.center = this._center; + } + }, { + key: "attachedRigidbody", + get: function get() { + return this.shape.attachedRigidBody; + } + }, { + key: "shape", + get: function get() { + return this._shape; + } + }, { + key: "_assertOnload", + get: function get() { + var r = 0 == this._isOnLoadCalled; + r && cc.error("Physics Error: Please make sure that the node has been added to the scene"); + return !r; + } + } ]); + return Collider3D; + }(cc.Component), _applyDecoratedDescriptor(_class2.prototype, "sharedMaterial", [ _dec2 ], Object.getOwnPropertyDescriptor(_class2.prototype, "sharedMaterial"), _class2.prototype), + _applyDecoratedDescriptor(_class2.prototype, "isTrigger", [ _dec3 ], Object.getOwnPropertyDescriptor(_class2.prototype, "isTrigger"), _class2.prototype), + _applyDecoratedDescriptor(_class2.prototype, "center", [ _dec4 ], Object.getOwnPropertyDescriptor(_class2.prototype, "center"), _class2.prototype), + _descriptor = _applyDecoratedDescriptor(_class2.prototype, "_material", [ _dec5 ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return null; + } + }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "_isTrigger", [ property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return false; + } + }), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "_center", [ property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new Vec3(); + } + }), _class2)) || _class); + exports.Collider3D = Collider3D; + cc.js.mixin(Collider3D.prototype, cc.EventTarget.prototype); + }, { + "../../assets/physics-material": 11 + } ], + 14: [ function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports.SphereCollider3D = void 0; + var _instance = require("../../instance"); + var _colliderComponent = require("./collider-component"); + var _dec, _dec2, _dec3, _class, _class2, _descriptor; + 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 + }); + } + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + "value" in descriptor && (descriptor.writable = true); + Object.defineProperty(target, descriptor.key, descriptor); + } + } + function _createClass(Constructor, protoProps, staticProps) { + protoProps && _defineProperties(Constructor.prototype, protoProps); + staticProps && _defineProperties(Constructor, staticProps); + return Constructor; + } + function _assertThisInitialized(self) { + if (void 0 === self) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + return self; + } + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + _setPrototypeOf(subClass, superClass); + } + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + return _setPrototypeOf(o, p); + } + function _initializerWarningHelper(descriptor, context) { + throw new Error("Decorating class property failed. Please ensure that proposal-class-properties is enabled and runs after the decorators transform."); + } + 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; + ("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 && void 0 !== desc.initializer) { + desc.value = desc.initializer ? desc.initializer.call(context) : void 0; + desc.initializer = void 0; + } + if (void 0 === desc.initializer) { + Object.defineProperty(target, property, desc); + desc = null; + } + return desc; + } + var _cc$_decorator = cc._decorator, ccclass = _cc$_decorator.ccclass, executeInEditMode = _cc$_decorator.executeInEditMode, executionOrder = _cc$_decorator.executionOrder, menu = _cc$_decorator.menu, property = _cc$_decorator.property; + var SphereCollider3D = (_dec = ccclass("cc.SphereCollider3D"), _dec2 = executionOrder(98), + _dec3 = menu("i18n:MAIN_MENU.component.physics/Collider/Sphere 3D"), _dec(_class = _dec2(_class = _dec3(_class = executeInEditMode(_class = (_class2 = function(_Collider3D) { + _inheritsLoose(SphereCollider3D, _Collider3D); + function SphereCollider3D() { + var _this; + _this = _Collider3D.call(this) || this; + _initializerDefineProperty(_this, "_radius", _descriptor, _assertThisInitialized(_this)); + true; + _this._shape = (0, _instance.createSphereShape)(_this._radius); + return _this; + } + _createClass(SphereCollider3D, [ { + key: "radius", + get: function get() { + return this._radius; + }, + set: function set(value) { + this._radius = value; + true; + this.sphereShape.radius = this._radius; + } + }, { + key: "sphereShape", + get: function get() { + return this._shape; + } + } ]); + return SphereCollider3D; + }(_colliderComponent.Collider3D), _applyDecoratedDescriptor(_class2.prototype, "radius", [ property ], Object.getOwnPropertyDescriptor(_class2.prototype, "radius"), _class2.prototype), + _descriptor = _applyDecoratedDescriptor(_class2.prototype, "_radius", [ property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return .5; + } + }), _class2)) || _class) || _class) || _class) || _class); + exports.SphereCollider3D = SphereCollider3D; + }, { + "../../instance": 18, + "./collider-component": 13 + } ], + 15: [ function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports.ConstantForce = void 0; + var _rigidBodyComponent = require("./rigid-body-component"); + var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4; + 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 + }); + } + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + "value" in descriptor && (descriptor.writable = true); + Object.defineProperty(target, descriptor.key, descriptor); + } + } + function _createClass(Constructor, protoProps, staticProps) { + protoProps && _defineProperties(Constructor.prototype, protoProps); + staticProps && _defineProperties(Constructor, staticProps); + return Constructor; + } + function _assertThisInitialized(self) { + if (void 0 === self) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + return self; + } + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + _setPrototypeOf(subClass, superClass); + } + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + return _setPrototypeOf(o, p); + } + 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; + ("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 && void 0 !== desc.initializer) { + desc.value = desc.initializer ? desc.initializer.call(context) : void 0; + desc.initializer = void 0; + } + if (void 0 === desc.initializer) { + Object.defineProperty(target, property, desc); + desc = null; + } + return desc; + } + function _initializerWarningHelper(descriptor, context) { + throw new Error("Decorating class property failed. Please ensure that proposal-class-properties is enabled and runs after the decorators transform."); + } + var _cc$_decorator = cc._decorator, ccclass = _cc$_decorator.ccclass, executeInEditMode = _cc$_decorator.executeInEditMode, executionOrder = _cc$_decorator.executionOrder, menu = _cc$_decorator.menu, property = _cc$_decorator.property, requireComponent = _cc$_decorator.requireComponent, disallowMultiple = _cc$_decorator.disallowMultiple; + var Vec3 = cc.Vec3; + var ConstantForce = (_dec = ccclass("cc.ConstantForce"), _dec2 = executionOrder(98), + _dec3 = requireComponent(_rigidBodyComponent.RigidBody3D), _dec4 = menu("i18n:MAIN_MENU.component.physics/Constant Force 3D"), + _dec5 = property({ + displayOrder: 0 + }), _dec6 = property({ + displayOrder: 1 + }), _dec7 = property({ + displayOrder: 2 + }), _dec8 = property({ + displayOrder: 3 + }), _dec(_class = _dec2(_class = _dec3(_class = _dec4(_class = disallowMultiple(_class = executeInEditMode(_class = (_class2 = function(_cc$Component) { + _inheritsLoose(ConstantForce, _cc$Component); + function ConstantForce() { + var _this; + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) args[_key] = arguments[_key]; + _this = _cc$Component.call.apply(_cc$Component, [ this ].concat(args)) || this; + _this._rigidbody = null; + _initializerDefineProperty(_this, "_force", _descriptor, _assertThisInitialized(_this)); + _initializerDefineProperty(_this, "_localForce", _descriptor2, _assertThisInitialized(_this)); + _initializerDefineProperty(_this, "_torque", _descriptor3, _assertThisInitialized(_this)); + _initializerDefineProperty(_this, "_localTorque", _descriptor4, _assertThisInitialized(_this)); + _this._mask = 0; + return _this; + } + var _proto = ConstantForce.prototype; + _proto.onLoad = function onLoad() { + true; + this._rigidbody = this.node.getComponent(_rigidBodyComponent.RigidBody3D); + this._maskUpdate(this._force, 1); + this._maskUpdate(this._localForce, 2); + this._maskUpdate(this._torque, 4); + this._maskUpdate(this._localTorque, 8); + }; + _proto.lateUpdate = function lateUpdate(dt) { + true; + if (null != this._rigidbody && 0 != this._mask) { + 1 & this._mask && this._rigidbody.applyForce(this._force); + 2 & this._mask && this._rigidbody.applyLocalForce(this.localForce); + 4 & this._mask && this._rigidbody.applyTorque(this._torque); + 8 & this._mask && this._rigidbody.applyLocalTorque(this._localTorque); + } + }; + _proto._maskUpdate = function _maskUpdate(t, m) { + Vec3.strictEquals(t, Vec3.ZERO) ? this._mask &= ~m : this._mask |= m; + }; + _createClass(ConstantForce, [ { + key: "force", + get: function get() { + return this._force; + }, + set: function set(value) { + Vec3.copy(this._force, value); + this._maskUpdate(this._force, 1); + } + }, { + key: "localForce", + get: function get() { + return this._localForce; + }, + set: function set(value) { + Vec3.copy(this._localForce, value); + this._maskUpdate(this.localForce, 2); + } + }, { + key: "torque", + get: function get() { + return this._torque; + }, + set: function set(value) { + Vec3.copy(this._torque, value); + this._maskUpdate(this._torque, 4); + } + }, { + key: "localTorque", + get: function get() { + return this._localTorque; + }, + set: function set(value) { + Vec3.copy(this._localTorque, value); + this._maskUpdate(this._localTorque, 8); + } + } ]); + return ConstantForce; + }(cc.Component), _descriptor = _applyDecoratedDescriptor(_class2.prototype, "_force", [ property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new Vec3(); + } + }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "_localForce", [ property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new Vec3(); + } + }), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "_torque", [ property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new Vec3(); + } + }), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "_localTorque", [ property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new Vec3(); + } + }), _applyDecoratedDescriptor(_class2.prototype, "force", [ _dec5 ], Object.getOwnPropertyDescriptor(_class2.prototype, "force"), _class2.prototype), + _applyDecoratedDescriptor(_class2.prototype, "localForce", [ _dec6 ], Object.getOwnPropertyDescriptor(_class2.prototype, "localForce"), _class2.prototype), + _applyDecoratedDescriptor(_class2.prototype, "torque", [ _dec7 ], Object.getOwnPropertyDescriptor(_class2.prototype, "torque"), _class2.prototype), + _applyDecoratedDescriptor(_class2.prototype, "localTorque", [ _dec8 ], Object.getOwnPropertyDescriptor(_class2.prototype, "localTorque"), _class2.prototype), + _class2)) || _class) || _class) || _class) || _class) || _class) || _class); + exports.ConstantForce = ConstantForce; + }, { + "./rigid-body-component": 16 + } ], + 16: [ function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports.RigidBody3D = void 0; + var _instance = require("../instance"); + var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _dec9, _dec10, _dec11, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6, _descriptor7, _descriptor8; + 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 + }); + } + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + "value" in descriptor && (descriptor.writable = true); + Object.defineProperty(target, descriptor.key, descriptor); + } + } + function _createClass(Constructor, protoProps, staticProps) { + protoProps && _defineProperties(Constructor.prototype, protoProps); + staticProps && _defineProperties(Constructor, staticProps); + return Constructor; + } + function _assertThisInitialized(self) { + if (void 0 === self) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + return self; + } + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + _setPrototypeOf(subClass, superClass); + } + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + return _setPrototypeOf(o, p); + } + function _initializerWarningHelper(descriptor, context) { + throw new Error("Decorating class property failed. Please ensure that proposal-class-properties is enabled and runs after the decorators transform."); + } + 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; + ("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 && void 0 !== desc.initializer) { + desc.value = desc.initializer ? desc.initializer.call(context) : void 0; + desc.initializer = void 0; + } + if (void 0 === desc.initializer) { + Object.defineProperty(target, property, desc); + desc = null; + } + return desc; + } + var _cc$_decorator = cc._decorator, ccclass = _cc$_decorator.ccclass, disallowMultiple = _cc$_decorator.disallowMultiple, executeInEditMode = _cc$_decorator.executeInEditMode, executionOrder = _cc$_decorator.executionOrder, menu = _cc$_decorator.menu, property = _cc$_decorator.property; + var Vec3 = cc.Vec3; + var RigidBody3D = (_dec = ccclass("cc.RigidBody3D"), _dec2 = executionOrder(99), + _dec3 = menu("i18n:MAIN_MENU.component.physics/Rigid Body 3D"), _dec4 = property({ + displayOrder: 0 + }), _dec5 = property({ + displayOrder: 1 + }), _dec6 = property({ + displayOrder: 2 + }), _dec7 = property({ + displayOrder: 3 + }), _dec8 = property({ + displayOrder: 4 + }), _dec9 = property({ + displayOrder: 5 + }), _dec10 = property({ + displayOrder: 6 + }), _dec11 = property({ + displayOrder: 7 + }), _dec(_class = _dec2(_class = _dec3(_class = executeInEditMode(_class = disallowMultiple(_class = (_class2 = function(_cc$Component) { + _inheritsLoose(RigidBody3D, _cc$Component); + function RigidBody3D() { + var _this; + _this = _cc$Component.call(this) || this; + _this._body = void 0; + _this._allowSleep = true; + _initializerDefineProperty(_this, "_mass", _descriptor, _assertThisInitialized(_this)); + _initializerDefineProperty(_this, "_linearDamping", _descriptor2, _assertThisInitialized(_this)); + _initializerDefineProperty(_this, "_angularDamping", _descriptor3, _assertThisInitialized(_this)); + _initializerDefineProperty(_this, "_fixedRotation", _descriptor4, _assertThisInitialized(_this)); + _initializerDefineProperty(_this, "_isKinematic", _descriptor5, _assertThisInitialized(_this)); + _initializerDefineProperty(_this, "_useGravity", _descriptor6, _assertThisInitialized(_this)); + _initializerDefineProperty(_this, "_linearFactor", _descriptor7, _assertThisInitialized(_this)); + _initializerDefineProperty(_this, "_angularFactor", _descriptor8, _assertThisInitialized(_this)); + true, true; + _this._body = (0, _instance.createRigidBody)(); + return _this; + } + var _proto = RigidBody3D.prototype; + _proto.__preload = function __preload() { + true, true; + this._body.__preload(this); + }; + _proto.onEnable = function onEnable() { + true, true; + this._body.onEnable(); + }; + _proto.onDisable = function onDisable() { + true, true; + this._body.onDisable(); + }; + _proto.onDestroy = function onDestroy() { + true, true; + this._body.onDestroy(); + }; + _proto.applyForce = function applyForce(force, relativePoint) { + this._assertOnload && true && this._body.applyForce(force, relativePoint); + }; + _proto.applyLocalForce = function applyLocalForce(force, localPoint) { + this._assertOnload && true && this._body.applyLocalForce(force, localPoint); + }; + _proto.applyImpulse = function applyImpulse(impulse, relativePoint) { + this._assertOnload && true && this._body.applyImpulse(impulse, relativePoint); + }; + _proto.applyLocalImpulse = function applyLocalImpulse(impulse, localPoint) { + this._assertOnload && true && this._body.applyLocalImpulse(impulse, localPoint); + }; + _proto.applyTorque = function applyTorque(torque) { + this._assertOnload && true && this._body.applyTorque(torque); + }; + _proto.applyLocalTorque = function applyLocalTorque(torque) { + this._assertOnload && true && this._body.applyLocalTorque(torque); + }; + _proto.wakeUp = function wakeUp() { + this._assertOnload && true && this._body.wakeUp(); + }; + _proto.sleep = function sleep() { + this._assertOnload && true && this._body.sleep(); + }; + _proto.getLinearVelocity = function getLinearVelocity(out) { + this._assertOnload && true && this._body.getLinearVelocity(out); + }; + _proto.setLinearVelocity = function setLinearVelocity(value) { + this._assertOnload && true && this._body.setLinearVelocity(value); + }; + _proto.getAngularVelocity = function getAngularVelocity(out) { + this._assertOnload && true && this._body.getAngularVelocity(out); + }; + _proto.setAngularVelocity = function setAngularVelocity(value) { + this._assertOnload && true && this._body.setAngularVelocity(value); + }; + _createClass(RigidBody3D, [ { + key: "allowSleep", + get: function get() { + return this._allowSleep; + }, + set: function set(v) { + this._allowSleep = v; + true, true; + this._body.allowSleep = v; + } + }, { + key: "mass", + get: function get() { + return this._mass; + }, + set: function set(value) { + this._mass = value; + true, true; + this._body.mass = value; + } + }, { + key: "linearDamping", + get: function get() { + return this._linearDamping; + }, + set: function set(value) { + this._linearDamping = value; + true, true; + this._body.linearDamping = value; + } + }, { + key: "angularDamping", + get: function get() { + return this._angularDamping; + }, + set: function set(value) { + this._angularDamping = value; + true, true; + this._body.angularDamping = value; + } + }, { + key: "isKinematic", + get: function get() { + return this._isKinematic; + }, + set: function set(value) { + this._isKinematic = value; + true, true; + this._body.isKinematic = value; + } + }, { + key: "useGravity", + get: function get() { + return this._useGravity; + }, + set: function set(value) { + this._useGravity = value; + true, true; + this._body.useGravity = value; + } + }, { + key: "fixedRotation", + get: function get() { + return this._fixedRotation; + }, + set: function set(value) { + this._fixedRotation = value; + true, true; + this._body.fixedRotation = value; + } + }, { + key: "linearFactor", + get: function get() { + return this._linearFactor; + }, + set: function set(value) { + Vec3.copy(this._linearFactor, value); + true, true; + this._body.linearFactor = this._linearFactor; + } + }, { + key: "angularFactor", + get: function get() { + return this._angularFactor; + }, + set: function set(value) { + Vec3.copy(this._angularFactor, value); + true, true; + this._body.angularFactor = this._angularFactor; + } + }, { + key: "isAwake", + get: function get() { + if (this._assertOnload && true) return this._body.isAwake; + return false; + } + }, { + key: "isSleepy", + get: function get() { + if (this._assertOnload && true) return this._body.isSleepy; + return false; + } + }, { + key: "isSleeping", + get: function get() { + if (this._assertOnload && true) return this._body.isSleeping; + return false; + } + }, { + key: "rigidBody", + get: function get() { + return this._body; + } + }, { + key: "_assertOnload", + get: function get() { + var r = 0 == this._isOnLoadCalled; + r && cc.error("Physics Error: Please make sure that the node has been added to the scene"); + return !r; + } + } ]); + return RigidBody3D; + }(cc.Component), _applyDecoratedDescriptor(_class2.prototype, "mass", [ _dec4 ], Object.getOwnPropertyDescriptor(_class2.prototype, "mass"), _class2.prototype), + _applyDecoratedDescriptor(_class2.prototype, "linearDamping", [ _dec5 ], Object.getOwnPropertyDescriptor(_class2.prototype, "linearDamping"), _class2.prototype), + _applyDecoratedDescriptor(_class2.prototype, "angularDamping", [ _dec6 ], Object.getOwnPropertyDescriptor(_class2.prototype, "angularDamping"), _class2.prototype), + _applyDecoratedDescriptor(_class2.prototype, "isKinematic", [ _dec7 ], Object.getOwnPropertyDescriptor(_class2.prototype, "isKinematic"), _class2.prototype), + _applyDecoratedDescriptor(_class2.prototype, "useGravity", [ _dec8 ], Object.getOwnPropertyDescriptor(_class2.prototype, "useGravity"), _class2.prototype), + _applyDecoratedDescriptor(_class2.prototype, "fixedRotation", [ _dec9 ], Object.getOwnPropertyDescriptor(_class2.prototype, "fixedRotation"), _class2.prototype), + _applyDecoratedDescriptor(_class2.prototype, "linearFactor", [ _dec10 ], Object.getOwnPropertyDescriptor(_class2.prototype, "linearFactor"), _class2.prototype), + _applyDecoratedDescriptor(_class2.prototype, "angularFactor", [ _dec11 ], Object.getOwnPropertyDescriptor(_class2.prototype, "angularFactor"), _class2.prototype), + _descriptor = _applyDecoratedDescriptor(_class2.prototype, "_mass", [ property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return 10; + } + }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "_linearDamping", [ property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return .1; + } + }), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "_angularDamping", [ property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return .1; + } + }), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "_fixedRotation", [ property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return false; + } + }), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, "_isKinematic", [ property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return false; + } + }), _descriptor6 = _applyDecoratedDescriptor(_class2.prototype, "_useGravity", [ property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return true; + } + }), _descriptor7 = _applyDecoratedDescriptor(_class2.prototype, "_linearFactor", [ property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new Vec3(1, 1, 1); + } + }), _descriptor8 = _applyDecoratedDescriptor(_class2.prototype, "_angularFactor", [ property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new Vec3(1, 1, 1); + } + }), _class2)) || _class) || _class) || _class) || _class) || _class); + exports.RigidBody3D = RigidBody3D; + }, { + "../instance": 18 + } ], + 17: [ function(require, module, exports) { + "use strict"; + exports.__esModule = true; + var _physicsManager = require("./physics-manager"); + exports.Physics3DManager = _physicsManager.Physics3DManager; + var _physicsRayResult = require("./physics-ray-result"); + exports.PhysicsRayResult = _physicsRayResult.PhysicsRayResult; + var _boxColliderComponent = require("./components/collider/box-collider-component"); + exports.BoxCollider3D = _boxColliderComponent.BoxCollider3D; + var _colliderComponent = require("./components/collider/collider-component"); + exports.Collider3D = _colliderComponent.Collider3D; + var _sphereColliderComponent = require("./components/collider/sphere-collider-component"); + exports.SphereCollider3D = _sphereColliderComponent.SphereCollider3D; + var _rigidBodyComponent = require("./components/rigid-body-component"); + exports.RigidBody3D = _rigidBodyComponent.RigidBody3D; + var _constantForce = require("./components/constant-force"); + var _physicsMaterial = require("./assets/physics-material"); + exports.PhysicsMaterial = _physicsMaterial.PhysicsMaterial; + cc.Physics3DManager = _physicsManager.Physics3DManager; + cc.Collider3D = _colliderComponent.Collider3D; + cc.BoxCollider3D = _boxColliderComponent.BoxCollider3D; + cc.SphereCollider3D = _sphereColliderComponent.SphereCollider3D; + cc.RigidBody3D = _rigidBodyComponent.RigidBody3D; + cc.PhysicsRayResult = _physicsRayResult.PhysicsRayResult; + cc.ConstantForce = _constantForce.ConstantForce; + }, { + "./assets/physics-material": 11, + "./components/collider/box-collider-component": 12, + "./components/collider/collider-component": 13, + "./components/collider/sphere-collider-component": 14, + "./components/constant-force": 15, + "./components/rigid-body-component": 16, + "./physics-manager": 20, + "./physics-ray-result": 21 + } ], + 18: [ function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports.createBoxShape = createBoxShape; + exports.createPhysicsWorld = createPhysicsWorld; + exports.createRigidBody = createRigidBody; + exports.createSphereShape = createSphereShape; + var _physicsSelector = require("./physics-selector"); + function createPhysicsWorld() { + return new _physicsSelector.PhysicsWorld(); + } + function createRigidBody() { + return new _physicsSelector.RigidBody(); + } + function createBoxShape(size) { + return new _physicsSelector.BoxShape(size); + } + function createSphereShape(radius) { + return new _physicsSelector.SphereShape(radius); + } + }, { + "./physics-selector": 22 + } ], + 19: [ function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports.ERigidBodyType = void 0; + var ERigidBodyType; + exports.ERigidBodyType = ERigidBodyType; + (function(ERigidBodyType) { + ERigidBodyType[ERigidBodyType["DYNAMIC"] = 1] = "DYNAMIC"; + ERigidBodyType[ERigidBodyType["STATIC"] = 2] = "STATIC"; + ERigidBodyType[ERigidBodyType["KINEMATIC"] = 4] = "KINEMATIC"; + })(ERigidBodyType || (exports.ERigidBodyType = ERigidBodyType = {})); + }, {} ], + 20: [ function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports.Physics3DManager = void 0; + var _instance = require("./instance"); + var _physicsMaterial = require("./assets/physics-material"); + var _physicsRayResult = require("./physics-ray-result"); + var _dec, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6; + 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 + }); + } + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + "value" in descriptor && (descriptor.writable = true); + Object.defineProperty(target, descriptor.key, descriptor); + } + } + function _createClass(Constructor, protoProps, staticProps) { + protoProps && _defineProperties(Constructor.prototype, protoProps); + staticProps && _defineProperties(Constructor, staticProps); + return Constructor; + } + 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; + ("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 && void 0 !== desc.initializer) { + desc.value = desc.initializer ? desc.initializer.call(context) : void 0; + desc.initializer = void 0; + } + if (void 0 === desc.initializer) { + Object.defineProperty(target, property, desc); + desc = null; + } + return desc; + } + function _initializerWarningHelper(descriptor, context) { + throw new Error("Decorating class property failed. Please ensure that proposal-class-properties is enabled and runs after the decorators transform."); + } + var _cc$_decorator = cc._decorator, property = _cc$_decorator.property, ccclass = _cc$_decorator.ccclass; + var Physics3DManager = (_dec = ccclass("cc.Physics3DManager"), _dec(_class = (_class2 = function() { + function Physics3DManager() { + this.physicsWorld = void 0; + this.raycastClosestResult = new _physicsRayResult.PhysicsRayResult(); + this.raycastResults = []; + _initializerDefineProperty(this, "_enabled", _descriptor, this); + _initializerDefineProperty(this, "_allowSleep", _descriptor2, this); + _initializerDefineProperty(this, "_gravity", _descriptor3, this); + _initializerDefineProperty(this, "_maxSubStep", _descriptor4, this); + _initializerDefineProperty(this, "_fixedTime", _descriptor5, this); + _initializerDefineProperty(this, "_useFixedTime", _descriptor6, this); + this.useAccumulator = false; + this._accumulator = 0; + this.useFixedDigit = false; + this.useInternalTime = false; + this.fixDigits = { + position: 5, + rotation: 12, + timeNow: 3 + }; + this._deltaTime = 0; + this._lastTime = 0; + this._material = null; + this.raycastOptions = { + groupIndex: -1, + queryTrigger: true, + maxDistance: Infinity + }; + this.raycastResultPool = new cc.RecyclePool(function() { + return new _physicsRayResult.PhysicsRayResult(); + }, 1); + cc.director._scheduler && cc.director._scheduler.enableForTarget(this); + this.physicsWorld = (0, _instance.createPhysicsWorld)(); + this._lastTime = performance.now(); + true; + this.gravity = this._gravity; + this.allowSleep = this._allowSleep; + this._material = new _physicsMaterial.PhysicsMaterial(); + this._material.friction = .1; + this._material.restitution = .1; + this._material.on("physics_material_update", this._updateMaterial, this); + this.physicsWorld.defaultMaterial = this._material; + } + var _proto = Physics3DManager.prototype; + _proto.update = function update(deltaTime) { + false; + if (!this._enabled) return; + if (this.useInternalTime) { + var now = parseFloat(performance.now().toFixed(this.fixDigits.timeNow)); + this._deltaTime = now > this._lastTime ? (now - this._lastTime) / 1e3 : 0; + this._lastTime = now; + } else this._deltaTime = deltaTime; + cc.director.emit(cc.Director.EVENT_BEFORE_PHYSICS); + false; + if (this._useFixedTime) this.physicsWorld.step(this._fixedTime); else if (this.useAccumulator) { + var i = 0; + this._accumulator += this._deltaTime; + while (i < this._maxSubStep && this._accumulator > this._fixedTime) { + this.physicsWorld.step(this._fixedTime); + this._accumulator -= this._fixedTime; + i++; + } + } else this.physicsWorld.step(this._fixedTime, this._deltaTime, this._maxSubStep); + cc.director.emit(cc.Director.EVENT_AFTER_PHYSICS); + }; + _proto.raycast = function raycast(worldRay, groupIndexOrName, maxDistance, queryTrigger) { + void 0 === groupIndexOrName && (groupIndexOrName = 0); + void 0 === maxDistance && (maxDistance = Infinity); + void 0 === queryTrigger && (queryTrigger = true); + this.raycastResultPool.reset(); + this.raycastResults.length = 0; + if ("string" == typeof groupIndexOrName) { + var groupIndex = cc.game.groupList.indexOf(groupIndexOrName); + -1 == groupIndex && (groupIndex = 0); + this.raycastOptions.groupIndex = groupIndex; + } else this.raycastOptions.groupIndex = groupIndexOrName; + this.raycastOptions.maxDistance = maxDistance; + this.raycastOptions.queryTrigger = queryTrigger; + var result = this.physicsWorld.raycast(worldRay, this.raycastOptions, this.raycastResultPool, this.raycastResults); + if (result) return this.raycastResults; + return null; + }; + _proto.raycastClosest = function raycastClosest(worldRay, groupIndexOrName, maxDistance, queryTrigger) { + void 0 === groupIndexOrName && (groupIndexOrName = 0); + void 0 === maxDistance && (maxDistance = Infinity); + void 0 === queryTrigger && (queryTrigger = true); + if ("string" == typeof groupIndexOrName) { + var groupIndex = cc.game.groupList.indexOf(groupIndexOrName); + -1 == groupIndex && (groupIndex = 0); + this.raycastOptions.groupIndex = groupIndex; + } else this.raycastOptions.groupIndex = groupIndexOrName; + this.raycastOptions.maxDistance = maxDistance; + this.raycastOptions.queryTrigger = queryTrigger; + var result = this.physicsWorld.raycastClosest(worldRay, this.raycastOptions, this.raycastClosestResult); + if (result) return this.raycastClosestResult; + return null; + }; + _proto._updateMaterial = function _updateMaterial() { + true; + this.physicsWorld.defaultMaterial = this._material; + }; + _createClass(Physics3DManager, [ { + key: "enabled", + get: function get() { + return this._enabled; + }, + set: function set(value) { + this._enabled = value; + } + }, { + key: "allowSleep", + get: function get() { + return this._allowSleep; + }, + set: function set(v) { + this._allowSleep = v; + true, true; + this.physicsWorld.allowSleep = this._allowSleep; + } + }, { + key: "maxSubStep", + get: function get() { + return this._maxSubStep; + }, + set: function set(value) { + this._maxSubStep = value; + } + }, { + key: "deltaTime", + get: function get() { + return this._fixedTime; + }, + set: function set(value) { + this._fixedTime = value; + } + }, { + key: "useFixedTime", + get: function get() { + return this._useFixedTime; + }, + set: function set(value) { + this._useFixedTime = value; + } + }, { + key: "gravity", + get: function get() { + return this._gravity; + }, + set: function set(gravity) { + this._gravity.set(gravity); + true, true; + this.physicsWorld.gravity = gravity; + } + }, { + key: "defaultMaterial", + get: function get() { + return this._material; + } + } ]); + return Physics3DManager; + }(), _descriptor = _applyDecoratedDescriptor(_class2.prototype, "_enabled", [ property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return false; + } + }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "_allowSleep", [ property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return true; + } + }), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "_gravity", [ property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return new cc.Vec3(0, -10, 0); + } + }), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "_maxSubStep", [ property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return 1; + } + }), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, "_fixedTime", [ property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return 1 / 60; + } + }), _descriptor6 = _applyDecoratedDescriptor(_class2.prototype, "_useFixedTime", [ property ], { + configurable: true, + enumerable: true, + writable: true, + initializer: function initializer() { + return true; + } + }), _class2)) || _class); + exports.Physics3DManager = Physics3DManager; + }, { + "./assets/physics-material": 11, + "./instance": 18, + "./physics-ray-result": 21 + } ], + 21: [ function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports.PhysicsRayResult = void 0; + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + "value" in descriptor && (descriptor.writable = true); + Object.defineProperty(target, descriptor.key, descriptor); + } + } + function _createClass(Constructor, protoProps, staticProps) { + protoProps && _defineProperties(Constructor.prototype, protoProps); + staticProps && _defineProperties(Constructor, staticProps); + return Constructor; + } + var Vec3 = cc.Vec3; + var PhysicsRayResult = function() { + function PhysicsRayResult() { + this._hitPoint = new Vec3(); + this._distance = 0; + this._collidier = null; + } + var _proto = PhysicsRayResult.prototype; + _proto._assign = function _assign(hitPoint, distance, collider) { + Vec3.copy(this._hitPoint, hitPoint); + this._distance = distance; + this._collidier = collider; + }; + _proto.clone = function clone() { + var c = new PhysicsRayResult(); + Vec3.copy(c._hitPoint, this._hitPoint); + c._distance = this._distance; + c._collidier = this._collidier; + return c; + }; + _createClass(PhysicsRayResult, [ { + key: "hitPoint", + get: function get() { + return this._hitPoint; + } + }, { + key: "distance", + get: function get() { + return this._distance; + } + }, { + key: "collider", + get: function get() { + return this._collidier; + } + } ]); + return PhysicsRayResult; + }(); + exports.PhysicsRayResult = PhysicsRayResult; + }, {} ], + 22: [ function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports.SphereShape = exports.RigidBody = exports.PhysicsWorld = exports.BoxShape = void 0; + exports.instantiate = instantiate; + var BoxShape; + exports.BoxShape = BoxShape; + var SphereShape; + exports.SphereShape = SphereShape; + var RigidBody; + exports.RigidBody = RigidBody; + var PhysicsWorld; + exports.PhysicsWorld = PhysicsWorld; + function instantiate(boxShape, sphereShape, body, world) { + exports.BoxShape = BoxShape = boxShape; + exports.SphereShape = SphereShape = sphereShape; + exports.RigidBody = RigidBody = body; + exports.PhysicsWorld = PhysicsWorld = world; + } + }, {} ], + 23: [ function(require, module, exports) { + "use strict"; + exports.__esModule = true; + exports.clearNodeTransformDirtyFlag = clearNodeTransformDirtyFlag; + exports.clearNodeTransformRecord = clearNodeTransformRecord; + exports.getWrap = getWrap; + exports.setWrap = setWrap; + exports.stringfyQuat = stringfyQuat; + exports.stringfyVec3 = stringfyVec3; + exports.updateWorldRT = updateWorldRT; + exports.updateWorldTransform = updateWorldTransform; + exports.worldDirty = worldDirty; + function stringfyVec3(value) { + return "(x: " + value.x + ", y: " + value.y + ", z: " + value.z + ")"; + } + function stringfyQuat(value) { + return "(x: " + value.x + ", y: " + value.y + ", z: " + value.z + ", w: " + value.w + ")"; + } + function setWrap(object, wrapper) { + object.__cc_wrapper__ = wrapper; + } + function getWrap(object) { + return object.__cc_wrapper__; + } + var LocalDirtyFlag = cc.Node._LocalDirtyFlag; + var PHYSICS_TRS = LocalDirtyFlag.PHYSICS_TRS; + var ALL_TRS = LocalDirtyFlag.ALL_TRS; + var SKEW = LocalDirtyFlag.SKEW; + var FLAG_TRANSFORM = cc.RenderFlow.FLAG_TRANSFORM; + var Mat3 = cc.Mat3; + var Mat4 = cc.Mat4; + var Vec3 = cc.Vec3; + var Quat = cc.Quat; + var Trs = cc.Trs; + var _nodeArray = []; + var _lpos = cc.v3(); + var _lrot = cc.quat(); + var _mat3 = new Mat3(); + var _mat3m = _mat3.m; + var _quat = cc.quat(); + var _mat4 = cc.mat4(); + var _nodeTransformRecord = {}; + function clearNodeTransformDirtyFlag() { + for (var key in _nodeTransformRecord) { + var physicsNode = _nodeTransformRecord[key]; + physicsNode._localMatDirty &= ~ALL_TRS; + if (!(physicsNode._localMatDirty & SKEW)) { + physicsNode._worldMatDirty = false; + true, physicsNode._renderFlag &= ~FLAG_TRANSFORM; + } + } + _nodeTransformRecord = {}; + _nodeArray.length = 0; + } + function clearNodeTransformRecord() { + _nodeTransformRecord = {}; + _nodeArray.length = 0; + } + function updateWorldTransform(node, traverseAllNode) { + void 0 === traverseAllNode && (traverseAllNode = false); + var cur = node; + var i = 0; + var needUpdateTransform = false; + var physicsDirtyFlag = 0; + while (cur) { + if (!traverseAllNode && _nodeTransformRecord[cur._id]) { + physicsDirtyFlag |= cur._localMatDirty & PHYSICS_TRS; + needUpdateTransform = needUpdateTransform || !!physicsDirtyFlag; + break; + } + _nodeArray[i++] = cur; + cur._localMatDirty & PHYSICS_TRS && (needUpdateTransform = true); + cur = cur._parent; + } + if (!needUpdateTransform) return false; + var child; + var childWorldMat, curWorldMat, childTrs, childLocalMat; + var wpos, wrot, wscale; + _nodeArray.length = i; + while (i) { + child = _nodeArray[--i]; + !traverseAllNode && (_nodeTransformRecord[child._id] = child); + childWorldMat = child._worldMatrix; + childLocalMat = child._matrix; + childTrs = child._trs; + wpos = child.__wpos = child.__wpos || cc.v3(); + wrot = child.__wrot = child.__wrot || cc.quat(); + wscale = child.__wscale = child.__wscale || cc.v3(); + child._localMatDirty & PHYSICS_TRS && Trs.toMat4(childLocalMat, childTrs); + child._localMatDirty |= physicsDirtyFlag; + physicsDirtyFlag |= child._localMatDirty & PHYSICS_TRS; + if (!(physicsDirtyFlag & PHYSICS_TRS)) { + cur = child; + continue; + } + if (cur) { + curWorldMat = cur._worldMatrix; + Trs.toPosition(_lpos, childTrs); + Vec3.transformMat4(wpos, _lpos, curWorldMat); + Mat4.multiply(childWorldMat, curWorldMat, childLocalMat); + Trs.toRotation(_lrot, childTrs); + Quat.multiply(wrot, cur.__wrot, _lrot); + Mat3.fromQuat(_mat3, Quat.conjugate(_quat, wrot)); + Mat3.multiplyMat4(_mat3, _mat3, childWorldMat); + wscale.x = _mat3m[0]; + wscale.y = _mat3m[4]; + wscale.z = _mat3m[8]; + } else { + Trs.toPosition(wpos, childTrs); + Trs.toRotation(wrot, childTrs); + Trs.toScale(wscale, childTrs); + Mat4.copy(childWorldMat, childLocalMat); + } + cur = child; + } + return true; + } + function updateWorldRT(node, position, rotation) { + var parent = node.parent; + if (parent) { + updateWorldTransform(parent, true); + Vec3.transformMat4(_lpos, position, Mat4.invert(_mat4, parent._worldMatrix)); + Quat.multiply(_quat, Quat.conjugate(_quat, parent.__wrot), rotation); + node.setPosition(_lpos); + node.setRotation(_quat); + } else { + node.setPosition(position); + node.setRotation(rotation); + } + } + function worldDirty(node) { + var cur = node; + while (cur) { + if (cur._worldMatDirty) return true; + cur = cur._parent; + } + return false; + } + }, {} ], + 24: [ function(require, module, exports) { + (function(global) { + "use strict"; + !function(e) { + if ("object" == typeof exports && "undefined" != typeof module) module.exports = e(); else if ("function" == typeof define && define.amd) define([], e); else { + var f; + "undefined" != typeof window ? f = window : "undefined" != typeof global ? f = global : "undefined" != typeof self && (f = self), + f.CANNON = e(); + } + }(function() { + var define, module, exports; + return function e(t, n, r) { + function s(o, u) { + if (!n[o]) { + if (!t[o]) { + var a = "function" == typeof require && require; + if (!u && a) return a(o, !0); + if (i) return i(o, !0); + throw new Error("Cannot find module '" + o + "'"); + } + var f = n[o] = { + exports: {} + }; + t[o][0].call(f.exports, function(e) { + var n = t[o][1][e]; + return s(n || e); + }, f, f.exports, e, t, n, r); + } + return n[o].exports; + } + var i = "function" == typeof require && require; + for (var o = 0; o < r.length; o++) s(r[o]); + return s; + }({ + 1: [ function(_dereq_, module, exports) { + module.exports = { + name: "@cocos/cannon", + version: "1.1.1-exp.3", + description: "A lightweight 3D physics engine written in JavaScript.", + homepage: "https://github.com/cocos-creator/cannon.js", + author: "Stefan Hedman (http://steffe.se), JayceLai", + keywords: [ "cannon.js", "cocos", "creator", "physics.9d2de", "engine", "3d" ], + scripts: { + build: "grunt && npm run preprocess && grunt addLicense && grunt addDate", + preprocess: "node node_modules/uglify-js/bin/uglifyjs build/cannon.js -o build/cannon.min.js -c -m" + }, + main: "./build/cannon.min.js", + engines: { + node: "*" + }, + repository: { + type: "git", + url: "https://github.com/cocos-creator/cannon.js.git" + }, + bugs: { + url: "https://github.com/cocos-creator/cannon.js/issues" + }, + licenses: [ { + type: "MIT" + } ], + devDependencies: { + jshint: "latest", + "uglify-js": "latest", + nodeunit: "^0.9.0", + grunt: "~0.4.0", + "grunt-contrib-jshint": "~0.1.1", + "grunt-contrib-nodeunit": "^0.4.1", + "grunt-contrib-concat": "~0.1.3", + "grunt-contrib-uglify": "^0.5.1", + "grunt-browserify": "^2.1.4", + "grunt-contrib-yuidoc": "^0.5.2", + browserify: "*" + }, + dependencies: {} + }; + }, {} ], + 2: [ function(_dereq_, module, exports) { + module.exports = { + version: _dereq_("../package.json").version, + AABB: _dereq_("./collision/AABB"), + ArrayCollisionMatrix: _dereq_("./collision/ArrayCollisionMatrix"), + Body: _dereq_("./objects/Body"), + Box: _dereq_("./shapes/Box"), + Broadphase: _dereq_("./collision/Broadphase"), + Constraint: _dereq_("./constraints/Constraint"), + ContactEquation: _dereq_("./equations/ContactEquation"), + Narrowphase: _dereq_("./world/Narrowphase"), + ConeTwistConstraint: _dereq_("./constraints/ConeTwistConstraint"), + ContactMaterial: _dereq_("./material/ContactMaterial"), + ConvexPolyhedron: _dereq_("./shapes/ConvexPolyhedron"), + Cylinder: _dereq_("./shapes/Cylinder"), + DistanceConstraint: _dereq_("./constraints/DistanceConstraint"), + Equation: _dereq_("./equations/Equation"), + EventTarget: _dereq_("./utils/EventTarget"), + FrictionEquation: _dereq_("./equations/FrictionEquation"), + GSSolver: _dereq_("./solver/GSSolver"), + GridBroadphase: _dereq_("./collision/GridBroadphase"), + Heightfield: _dereq_("./shapes/Heightfield"), + HingeConstraint: _dereq_("./constraints/HingeConstraint"), + LockConstraint: _dereq_("./constraints/LockConstraint"), + Mat3: _dereq_("./math/Mat3"), + Material: _dereq_("./material/Material"), + NaiveBroadphase: _dereq_("./collision/NaiveBroadphase"), + ObjectCollisionMatrix: _dereq_("./collision/ObjectCollisionMatrix"), + Pool: _dereq_("./utils/Pool"), + Particle: _dereq_("./shapes/Particle"), + Plane: _dereq_("./shapes/Plane"), + PointToPointConstraint: _dereq_("./constraints/PointToPointConstraint"), + Quaternion: _dereq_("./math/Quaternion"), + Ray: _dereq_("./collision/Ray"), + RaycastVehicle: _dereq_("./objects/RaycastVehicle"), + RaycastResult: _dereq_("./collision/RaycastResult"), + RigidVehicle: _dereq_("./objects/RigidVehicle"), + RotationalEquation: _dereq_("./equations/RotationalEquation"), + RotationalMotorEquation: _dereq_("./equations/RotationalMotorEquation"), + SAPBroadphase: _dereq_("./collision/SAPBroadphase"), + SPHSystem: _dereq_("./objects/SPHSystem"), + Shape: _dereq_("./shapes/Shape"), + Solver: _dereq_("./solver/Solver"), + Sphere: _dereq_("./shapes/Sphere"), + SplitSolver: _dereq_("./solver/SplitSolver"), + Spring: _dereq_("./objects/Spring"), + Transform: _dereq_("./math/Transform"), + Trimesh: _dereq_("./shapes/Trimesh"), + Vec3: _dereq_("./math/Vec3"), + Vec3Pool: _dereq_("./utils/Vec3Pool"), + World: _dereq_("./world/World"), + Octree: _dereq_("./utils/Octree"), + CMath: _dereq_("./math/CMath") + }; + }, { + "../package.json": 1, + "./collision/AABB": 3, + "./collision/ArrayCollisionMatrix": 4, + "./collision/Broadphase": 5, + "./collision/GridBroadphase": 6, + "./collision/NaiveBroadphase": 7, + "./collision/ObjectCollisionMatrix": 8, + "./collision/Ray": 10, + "./collision/RaycastResult": 11, + "./collision/SAPBroadphase": 12, + "./constraints/ConeTwistConstraint": 13, + "./constraints/Constraint": 14, + "./constraints/DistanceConstraint": 15, + "./constraints/HingeConstraint": 16, + "./constraints/LockConstraint": 17, + "./constraints/PointToPointConstraint": 18, + "./equations/ContactEquation": 20, + "./equations/Equation": 21, + "./equations/FrictionEquation": 22, + "./equations/RotationalEquation": 23, + "./equations/RotationalMotorEquation": 24, + "./material/ContactMaterial": 25, + "./material/Material": 26, + "./math/CMath": 27, + "./math/Mat3": 29, + "./math/Quaternion": 30, + "./math/Transform": 31, + "./math/Vec3": 32, + "./objects/Body": 33, + "./objects/RaycastVehicle": 34, + "./objects/RigidVehicle": 35, + "./objects/SPHSystem": 36, + "./objects/Spring": 37, + "./shapes/Box": 39, + "./shapes/ConvexPolyhedron": 40, + "./shapes/Cylinder": 41, + "./shapes/Heightfield": 42, + "./shapes/Particle": 43, + "./shapes/Plane": 44, + "./shapes/Shape": 45, + "./shapes/Sphere": 46, + "./shapes/Trimesh": 47, + "./solver/GSSolver": 48, + "./solver/Solver": 49, + "./solver/SplitSolver": 50, + "./utils/EventTarget": 51, + "./utils/Octree": 52, + "./utils/Pool": 53, + "./utils/Vec3Pool": 56, + "./world/Narrowphase": 57, + "./world/World": 58 + } ], + 3: [ function(_dereq_, module, exports) { + var Vec3 = _dereq_("../math/Vec3"); + var Utils = _dereq_("../utils/Utils"); + module.exports = AABB; + function AABB(options) { + options = options || {}; + this.lowerBound = new Vec3(); + options.lowerBound && this.lowerBound.copy(options.lowerBound); + this.upperBound = new Vec3(); + options.upperBound && this.upperBound.copy(options.upperBound); + } + var tmp = new Vec3(); + AABB.prototype.setFromPoints = function(points, position, quaternion, skinSize) { + var l = this.lowerBound, u = this.upperBound, q = quaternion; + l.copy(points[0]); + q && q.vmult(l, l); + u.copy(l); + for (var i = 1; i < points.length; i++) { + var p = points[i]; + if (q) { + q.vmult(p, tmp); + p = tmp; + } + p.x > u.x && (u.x = p.x); + p.x < l.x && (l.x = p.x); + p.y > u.y && (u.y = p.y); + p.y < l.y && (l.y = p.y); + p.z > u.z && (u.z = p.z); + p.z < l.z && (l.z = p.z); + } + if (position) { + position.vadd(l, l); + position.vadd(u, u); + } + if (skinSize) { + l.x -= skinSize; + l.y -= skinSize; + l.z -= skinSize; + u.x += skinSize; + u.y += skinSize; + u.z += skinSize; + } + return this; + }; + AABB.prototype.copy = function(aabb) { + this.lowerBound.copy(aabb.lowerBound); + this.upperBound.copy(aabb.upperBound); + return this; + }; + AABB.prototype.clone = function() { + return new AABB().copy(this); + }; + AABB.prototype.extend = function(aabb) { + this.lowerBound.x = Math.min(this.lowerBound.x, aabb.lowerBound.x); + this.upperBound.x = Math.max(this.upperBound.x, aabb.upperBound.x); + this.lowerBound.y = Math.min(this.lowerBound.y, aabb.lowerBound.y); + this.upperBound.y = Math.max(this.upperBound.y, aabb.upperBound.y); + this.lowerBound.z = Math.min(this.lowerBound.z, aabb.lowerBound.z); + this.upperBound.z = Math.max(this.upperBound.z, aabb.upperBound.z); + }; + AABB.prototype.overlaps = function(aabb) { + var l1 = this.lowerBound, u1 = this.upperBound, l2 = aabb.lowerBound, u2 = aabb.upperBound; + var overlapsX = l2.x <= u1.x && u1.x <= u2.x || l1.x <= u2.x && u2.x <= u1.x; + var overlapsY = l2.y <= u1.y && u1.y <= u2.y || l1.y <= u2.y && u2.y <= u1.y; + var overlapsZ = l2.z <= u1.z && u1.z <= u2.z || l1.z <= u2.z && u2.z <= u1.z; + return overlapsX && overlapsY && overlapsZ; + }; + AABB.prototype.volume = function() { + var l = this.lowerBound, u = this.upperBound; + return (u.x - l.x) * (u.y - l.y) * (u.z - l.z); + }; + AABB.prototype.contains = function(aabb) { + var l1 = this.lowerBound, u1 = this.upperBound, l2 = aabb.lowerBound, u2 = aabb.upperBound; + return l1.x <= l2.x && u1.x >= u2.x && l1.y <= l2.y && u1.y >= u2.y && l1.z <= l2.z && u1.z >= u2.z; + }; + AABB.prototype.getCorners = function(a, b, c, d, e, f, g, h) { + var l = this.lowerBound, u = this.upperBound; + a.copy(l); + b.set(u.x, l.y, l.z); + c.set(u.x, u.y, l.z); + d.set(l.x, u.y, u.z); + e.set(u.x, l.y, u.z); + f.set(l.x, u.y, l.z); + g.set(l.x, l.y, u.z); + h.copy(u); + }; + var transformIntoFrame_corners = [ new Vec3(), new Vec3(), new Vec3(), new Vec3(), new Vec3(), new Vec3(), new Vec3(), new Vec3() ]; + AABB.prototype.toLocalFrame = function(frame, target) { + var corners = transformIntoFrame_corners; + var a = corners[0]; + var b = corners[1]; + var c = corners[2]; + var d = corners[3]; + var e = corners[4]; + var f = corners[5]; + var g = corners[6]; + var h = corners[7]; + this.getCorners(a, b, c, d, e, f, g, h); + for (var i = 0; 8 !== i; i++) { + var corner = corners[i]; + frame.pointToLocal(corner, corner); + } + return target.setFromPoints(corners); + }; + AABB.prototype.toWorldFrame = function(frame, target) { + var corners = transformIntoFrame_corners; + var a = corners[0]; + var b = corners[1]; + var c = corners[2]; + var d = corners[3]; + var e = corners[4]; + var f = corners[5]; + var g = corners[6]; + var h = corners[7]; + this.getCorners(a, b, c, d, e, f, g, h); + for (var i = 0; 8 !== i; i++) { + var corner = corners[i]; + frame.pointToWorld(corner, corner); + } + return target.setFromPoints(corners); + }; + AABB.prototype.overlapsRay = function(ray) { + var t = 0; + var dirFracX = 1 / ray._direction.x; + var dirFracY = 1 / ray._direction.y; + var dirFracZ = 1 / ray._direction.z; + var t1 = (this.lowerBound.x - ray.from.x) * dirFracX; + var t2 = (this.upperBound.x - ray.from.x) * dirFracX; + var t3 = (this.lowerBound.y - ray.from.y) * dirFracY; + var t4 = (this.upperBound.y - ray.from.y) * dirFracY; + var t5 = (this.lowerBound.z - ray.from.z) * dirFracZ; + var t6 = (this.upperBound.z - ray.from.z) * dirFracZ; + var tmin = Math.max(Math.max(Math.min(t1, t2), Math.min(t3, t4)), Math.min(t5, t6)); + var tmax = Math.min(Math.min(Math.max(t1, t2), Math.max(t3, t4)), Math.max(t5, t6)); + if (tmax < 0) return false; + if (tmin > tmax) return false; + return true; + }; + }, { + "../math/Vec3": 32, + "../utils/Utils": 55 + } ], + 4: [ function(_dereq_, module, exports) { + module.exports = ArrayCollisionMatrix; + function ArrayCollisionMatrix() { + this.matrix = []; + } + ArrayCollisionMatrix.prototype.get = function(i, j) { + i = i.index; + j = j.index; + if (j > i) { + var temp = j; + j = i; + i = temp; + } + return this.matrix[(i * (i + 1) >> 1) + j - 1]; + }; + ArrayCollisionMatrix.prototype.set = function(i, j, value) { + i = i.index; + j = j.index; + if (j > i) { + var temp = j; + j = i; + i = temp; + } + this.matrix[(i * (i + 1) >> 1) + j - 1] = value ? 1 : 0; + }; + ArrayCollisionMatrix.prototype.reset = function() { + for (var i = 0, l = this.matrix.length; i !== l; i++) this.matrix[i] = 0; + }; + ArrayCollisionMatrix.prototype.setNumObjects = function(n) { + this.matrix.length = n * (n - 1) >> 1; + }; + }, {} ], + 5: [ function(_dereq_, module, exports) { + var Body = _dereq_("../objects/Body"); + var Vec3 = _dereq_("../math/Vec3"); + var Quaternion = _dereq_("../math/Quaternion"); + var Shape = _dereq_("../shapes/Shape"); + var Plane = _dereq_("../shapes/Plane"); + module.exports = Broadphase; + function Broadphase() { + this.world = null; + this.useBoundingBoxes = false; + this.dirty = true; + } + Broadphase.prototype.collisionPairs = function(world, p1, p2) { + throw new Error("collisionPairs not implemented for this BroadPhase class!"); + }; + Broadphase.prototype.needBroadphaseCollision = function(bodyA, bodyB) { + if (0 === (bodyA.collisionFilterGroup & bodyB.collisionFilterMask) || 0 === (bodyB.collisionFilterGroup & bodyA.collisionFilterMask)) return false; + if (bodyA.hasTrigger || bodyB.hasTrigger) return true; + if ((0 !== (bodyA.type & Body.STATIC) || bodyA.sleepState === Body.SLEEPING) && (0 !== (bodyB.type & Body.STATIC) || bodyB.sleepState === Body.SLEEPING)) return false; + return true; + }; + Broadphase.prototype.intersectionTest = function(bodyA, bodyB, pairs1, pairs2) { + this.useBoundingBoxes ? this.doBoundingBoxBroadphase(bodyA, bodyB, pairs1, pairs2) : this.doBoundingSphereBroadphase(bodyA, bodyB, pairs1, pairs2); + }; + var Broadphase_collisionPairs_r = new Vec3(), Broadphase_collisionPairs_normal = new Vec3(), Broadphase_collisionPairs_quat = new Quaternion(), Broadphase_collisionPairs_relpos = new Vec3(); + Broadphase.prototype.doBoundingSphereBroadphase = function(bodyA, bodyB, pairs1, pairs2) { + var r = Broadphase_collisionPairs_r; + bodyB.position.vsub(bodyA.position, r); + var boundingRadiusSum2 = Math.pow(bodyA.boundingRadius + bodyB.boundingRadius, 2); + var norm2 = r.norm2(); + if (norm2 < boundingRadiusSum2) { + pairs1.push(bodyA); + pairs2.push(bodyB); + } + }; + Broadphase.prototype.doBoundingBoxBroadphase = function(bodyA, bodyB, pairs1, pairs2) { + bodyA.aabbNeedsUpdate && bodyA.computeAABB(); + bodyB.aabbNeedsUpdate && bodyB.computeAABB(); + if (bodyA.aabb.overlaps(bodyB.aabb)) { + pairs1.push(bodyA); + pairs2.push(bodyB); + } + }; + var Broadphase_makePairsUnique_temp = { + keys: [] + }, Broadphase_makePairsUnique_p1 = [], Broadphase_makePairsUnique_p2 = []; + Broadphase.prototype.makePairsUnique = function(pairs1, pairs2) { + var t = Broadphase_makePairsUnique_temp, p1 = Broadphase_makePairsUnique_p1, p2 = Broadphase_makePairsUnique_p2, N = pairs1.length; + for (var i = 0; i !== N; i++) { + p1[i] = pairs1[i]; + p2[i] = pairs2[i]; + } + pairs1.length = 0; + pairs2.length = 0; + for (var i = 0; i !== N; i++) { + var id1 = p1[i].id, id2 = p2[i].id; + var key = id1 < id2 ? id1 + "," + id2 : id2 + "," + id1; + t[key] = i; + t.keys.push(key); + } + for (var i = 0; i !== t.keys.length; i++) { + var key = t.keys.pop(), pairIndex = t[key]; + pairs1.push(p1[pairIndex]); + pairs2.push(p2[pairIndex]); + delete t[key]; + } + }; + Broadphase.prototype.setWorld = function(world) {}; + var bsc_dist = new Vec3(); + Broadphase.boundingSphereCheck = function(bodyA, bodyB) { + var dist = bsc_dist; + bodyA.position.vsub(bodyB.position, dist); + return Math.pow(bodyA.shape.boundingSphereRadius + bodyB.shape.boundingSphereRadius, 2) > dist.norm2(); + }; + Broadphase.prototype.aabbQuery = function(world, aabb, result) { + console.warn(".aabbQuery is not implemented in this Broadphase subclass."); + return []; + }; + }, { + "../math/Quaternion": 30, + "../math/Vec3": 32, + "../objects/Body": 33, + "../shapes/Plane": 44, + "../shapes/Shape": 45 + } ], + 6: [ function(_dereq_, module, exports) { + module.exports = GridBroadphase; + var Broadphase = _dereq_("./Broadphase"); + var Vec3 = _dereq_("../math/Vec3"); + var Shape = _dereq_("../shapes/Shape"); + function GridBroadphase(aabbMin, aabbMax, nx, ny, nz) { + Broadphase.apply(this); + this.nx = nx || 10; + this.ny = ny || 10; + this.nz = nz || 10; + this.aabbMin = aabbMin || new Vec3(100, 100, 100); + this.aabbMax = aabbMax || new Vec3(-100, -100, -100); + var nbins = this.nx * this.ny * this.nz; + if (nbins <= 0) throw "GridBroadphase: Each dimension's n must be >0"; + this.bins = []; + this.binLengths = []; + this.bins.length = nbins; + this.binLengths.length = nbins; + for (var i = 0; i < nbins; i++) { + this.bins[i] = []; + this.binLengths[i] = 0; + } + } + GridBroadphase.prototype = new Broadphase(); + GridBroadphase.prototype.constructor = GridBroadphase; + var GridBroadphase_collisionPairs_d = new Vec3(); + var GridBroadphase_collisionPairs_binPos = new Vec3(); + GridBroadphase.prototype.collisionPairs = function(world, pairs1, pairs2) { + var N = world.numObjects(), bodies = world.bodies; + var max = this.aabbMax, min = this.aabbMin, nx = this.nx, ny = this.ny, nz = this.nz; + var xstep = ny * nz; + var ystep = nz; + var zstep = 1; + var xmax = max.x, ymax = max.y, zmax = max.z, xmin = min.x, ymin = min.y, zmin = min.z; + var xmult = nx / (xmax - xmin), ymult = ny / (ymax - ymin), zmult = nz / (zmax - zmin); + var binsizeX = (xmax - xmin) / nx, binsizeY = (ymax - ymin) / ny, binsizeZ = (zmax - zmin) / nz; + var binRadius = .5 * Math.sqrt(binsizeX * binsizeX + binsizeY * binsizeY + binsizeZ * binsizeZ); + var types = Shape.types; + var SPHERE = types.SPHERE, PLANE = types.PLANE, BOX = types.BOX, COMPOUND = types.COMPOUND, CONVEXPOLYHEDRON = types.CONVEXPOLYHEDRON; + var bins = this.bins, binLengths = this.binLengths, Nbins = this.bins.length; + for (var i = 0; i !== Nbins; i++) binLengths[i] = 0; + var ceil = Math.ceil; + var min = Math.min; + var max = Math.max; + function addBoxToBins(x0, y0, z0, x1, y1, z1, bi) { + var xoff0 = (x0 - xmin) * xmult | 0, yoff0 = (y0 - ymin) * ymult | 0, zoff0 = (z0 - zmin) * zmult | 0, xoff1 = ceil((x1 - xmin) * xmult), yoff1 = ceil((y1 - ymin) * ymult), zoff1 = ceil((z1 - zmin) * zmult); + xoff0 < 0 ? xoff0 = 0 : xoff0 >= nx && (xoff0 = nx - 1); + yoff0 < 0 ? yoff0 = 0 : yoff0 >= ny && (yoff0 = ny - 1); + zoff0 < 0 ? zoff0 = 0 : zoff0 >= nz && (zoff0 = nz - 1); + xoff1 < 0 ? xoff1 = 0 : xoff1 >= nx && (xoff1 = nx - 1); + yoff1 < 0 ? yoff1 = 0 : yoff1 >= ny && (yoff1 = ny - 1); + zoff1 < 0 ? zoff1 = 0 : zoff1 >= nz && (zoff1 = nz - 1); + xoff0 *= xstep; + yoff0 *= ystep; + zoff0 *= zstep; + xoff1 *= xstep; + yoff1 *= ystep; + zoff1 *= zstep; + for (var xoff = xoff0; xoff <= xoff1; xoff += xstep) for (var yoff = yoff0; yoff <= yoff1; yoff += ystep) for (var zoff = zoff0; zoff <= zoff1; zoff += zstep) { + var idx = xoff + yoff + zoff; + bins[idx][binLengths[idx]++] = bi; + } + } + for (var i = 0; i !== N; i++) { + var bi = bodies[i]; + var si = bi.shape; + switch (si.type) { + case SPHERE: + var x = bi.position.x, y = bi.position.y, z = bi.position.z; + var r = si.radius; + addBoxToBins(x - r, y - r, z - r, x + r, y + r, z + r, bi); + break; + + case PLANE: + si.worldNormalNeedsUpdate && si.computeWorldNormal(bi.quaternion); + var planeNormal = si.worldNormal; + var xreset = xmin + .5 * binsizeX - bi.position.x, yreset = ymin + .5 * binsizeY - bi.position.y, zreset = zmin + .5 * binsizeZ - bi.position.z; + var d = GridBroadphase_collisionPairs_d; + d.set(xreset, yreset, zreset); + for (var xi = 0, xoff = 0; xi !== nx; xi++, xoff += xstep, d.y = yreset, d.x += binsizeX) for (var yi = 0, yoff = 0; yi !== ny; yi++, + yoff += ystep, d.z = zreset, d.y += binsizeY) for (var zi = 0, zoff = 0; zi !== nz; zi++, + zoff += zstep, d.z += binsizeZ) if (d.dot(planeNormal) < binRadius) { + var idx = xoff + yoff + zoff; + bins[idx][binLengths[idx]++] = bi; + } + break; + + default: + bi.aabbNeedsUpdate && bi.computeAABB(); + addBoxToBins(bi.aabb.lowerBound.x, bi.aabb.lowerBound.y, bi.aabb.lowerBound.z, bi.aabb.upperBound.x, bi.aabb.upperBound.y, bi.aabb.upperBound.z, bi); + } + } + for (var i = 0; i !== Nbins; i++) { + var binLength = binLengths[i]; + if (binLength > 1) { + var bin = bins[i]; + for (var xi = 0; xi !== binLength; xi++) { + var bi = bin[xi]; + for (var yi = 0; yi !== xi; yi++) { + var bj = bin[yi]; + this.needBroadphaseCollision(bi, bj) && this.intersectionTest(bi, bj, pairs1, pairs2); + } + } + } + } + this.makePairsUnique(pairs1, pairs2); + }; + }, { + "../math/Vec3": 32, + "../shapes/Shape": 45, + "./Broadphase": 5 + } ], + 7: [ function(_dereq_, module, exports) { + module.exports = NaiveBroadphase; + var Broadphase = _dereq_("./Broadphase"); + var AABB = _dereq_("./AABB"); + function NaiveBroadphase() { + Broadphase.apply(this); + } + NaiveBroadphase.prototype = new Broadphase(); + NaiveBroadphase.prototype.constructor = NaiveBroadphase; + NaiveBroadphase.prototype.collisionPairs = function(world, pairs1, pairs2) { + var bodies = world.bodies, n = bodies.length, i, j, bi, bj; + for (i = 0; i !== n; i++) for (j = 0; j !== i; j++) { + bi = bodies[i]; + bj = bodies[j]; + if (!this.needBroadphaseCollision(bi, bj)) continue; + this.intersectionTest(bi, bj, pairs1, pairs2); + } + }; + var tmpAABB = new AABB(); + NaiveBroadphase.prototype.aabbQuery = function(world, aabb, result) { + result = result || []; + for (var i = 0; i < world.bodies.length; i++) { + var b = world.bodies[i]; + b.aabbNeedsUpdate && b.computeAABB(); + b.aabb.overlaps(aabb) && result.push(b); + } + return result; + }; + }, { + "./AABB": 3, + "./Broadphase": 5 + } ], + 8: [ function(_dereq_, module, exports) { + module.exports = ObjectCollisionMatrix; + function ObjectCollisionMatrix() { + this.matrix = {}; + } + ObjectCollisionMatrix.prototype.get = function(i, j) { + i = i.id; + j = j.id; + if (j > i) { + var temp = j; + j = i; + i = temp; + } + return i + "-" + j in this.matrix; + }; + ObjectCollisionMatrix.prototype.set = function(i, j, value) { + i = i.id; + j = j.id; + if (j > i) { + var temp = j; + j = i; + i = temp; + } + value ? this.matrix[i + "-" + j] = true : delete this.matrix[i + "-" + j]; + }; + ObjectCollisionMatrix.prototype.reset = function() { + this.matrix = {}; + }; + ObjectCollisionMatrix.prototype.setNumObjects = function(n) {}; + }, {} ], + 9: [ function(_dereq_, module, exports) { + module.exports = OverlapKeeper; + function OverlapKeeper() { + this.current = []; + this.previous = []; + } + OverlapKeeper.prototype.getKey = function(i, j) { + if (j < i) { + var temp = j; + j = i; + i = temp; + } + return i << 16 | j; + }; + OverlapKeeper.prototype.set = function(i, j) { + var key = this.getKey(i, j); + var current = this.current; + var index = 0; + while (key > current[index]) index++; + if (key === current[index]) return; + for (var j = current.length - 1; j >= index; j--) current[j + 1] = current[j]; + current[index] = key; + }; + OverlapKeeper.prototype.tick = function() { + var tmp = this.current; + this.current = this.previous; + this.previous = tmp; + this.current.length = 0; + }; + function unpackAndPush(array, key) { + array.push((4294901760 & key) >> 16, 65535 & key); + } + OverlapKeeper.prototype.getDiff = function(additions, removals) { + var a = this.current; + var b = this.previous; + var al = a.length; + var bl = b.length; + var j = 0; + for (var i = 0; i < al; i++) { + var found = false; + var keyA = a[i]; + while (keyA > b[j]) j++; + found = keyA === b[j]; + found || unpackAndPush(additions, keyA); + } + j = 0; + for (var i = 0; i < bl; i++) { + var found = false; + var keyB = b[i]; + while (keyB > a[j]) j++; + found = a[j] === keyB; + found || unpackAndPush(removals, keyB); + } + }; + }, {} ], + 10: [ function(_dereq_, module, exports) { + module.exports = Ray; + var Vec3 = _dereq_("../math/Vec3"); + var Quaternion = _dereq_("../math/Quaternion"); + var Transform = _dereq_("../math/Transform"); + var ConvexPolyhedron = _dereq_("../shapes/ConvexPolyhedron"); + var Box = _dereq_("../shapes/Box"); + var RaycastResult = _dereq_("../collision/RaycastResult"); + var Shape = _dereq_("../shapes/Shape"); + var AABB = _dereq_("../collision/AABB"); + function Ray(from, to) { + this.from = from ? from.clone() : new Vec3(); + this.to = to ? to.clone() : new Vec3(); + this._direction = new Vec3(); + this.precision = 1e-4; + this.checkCollisionResponse = true; + this.skipBackfaces = false; + this.collisionFilterMask = -1; + this.collisionFilterGroup = -1; + this.mode = Ray.ANY; + this.result = new RaycastResult(); + this.hasHit = false; + this.callback = function(result) {}; + } + Ray.prototype.constructor = Ray; + Ray.CLOSEST = 1; + Ray.ANY = 2; + Ray.ALL = 4; + var tmpAABB = new AABB(); + var tmpArray = []; + Ray.prototype.intersectWorld = function(world, options) { + this.mode = options.mode || Ray.ANY; + this.result = options.result || new RaycastResult(); + this.skipBackfaces = !!options.skipBackfaces; + this.checkCollisionResponse = !!options.checkCollisionResponse; + this.collisionFilterMask = "undefined" !== typeof options.collisionFilterMask ? options.collisionFilterMask : -1; + this.collisionFilterGroup = "undefined" !== typeof options.collisionFilterGroup ? options.collisionFilterGroup : -1; + options.from && this.from.copy(options.from); + options.to && this.to.copy(options.to); + this.callback = options.callback || function() {}; + this.hasHit = false; + this.result.reset(); + this._updateDirection(); + this.getAABB(tmpAABB); + tmpArray.length = 0; + world.broadphase.aabbQuery(world, tmpAABB, tmpArray); + this.intersectBodies(tmpArray); + return this.hasHit; + }; + var v1 = new Vec3(), v2 = new Vec3(); + Ray.pointInTriangle = pointInTriangle; + function pointInTriangle(p, a, b, c) { + c.vsub(a, v0); + b.vsub(a, v1); + p.vsub(a, v2); + var dot00 = v0.dot(v0); + var dot01 = v0.dot(v1); + var dot02 = v0.dot(v2); + var dot11 = v1.dot(v1); + var dot12 = v1.dot(v2); + var u, v; + return (u = dot11 * dot02 - dot01 * dot12) >= 0 && (v = dot00 * dot12 - dot01 * dot02) >= 0 && u + v < dot00 * dot11 - dot01 * dot01; + } + var intersectBody_xi = new Vec3(); + var intersectBody_qi = new Quaternion(); + Ray.prototype.intersectBody = function(body, result) { + if (result) { + this.result = result; + this._updateDirection(); + } + var checkCollisionResponse = this.checkCollisionResponse; + if (checkCollisionResponse && !body.collisionResponse) return; + if (0 === (this.collisionFilterGroup & body.collisionFilterMask) || 0 === (body.collisionFilterGroup & this.collisionFilterMask)) return; + var xi = intersectBody_xi; + var qi = intersectBody_qi; + for (var i = 0, N = body.shapes.length; i < N; i++) { + var shape = body.shapes[i]; + if (checkCollisionResponse && !shape.collisionResponse) continue; + body.quaternion.mult(body.shapeOrientations[i], qi); + body.quaternion.vmult(body.shapeOffsets[i], xi); + xi.vadd(body.position, xi); + this.intersectShape(shape, qi, xi, body); + if (this.result._shouldStop) break; + } + }; + Ray.prototype.intersectBodies = function(bodies, result) { + if (result) { + this.result = result; + this._updateDirection(); + } + for (var i = 0, l = bodies.length; !this.result._shouldStop && i < l; i++) this.intersectBody(bodies[i]); + }; + Ray.prototype._updateDirection = function() { + this.to.vsub(this.from, this._direction); + this._direction.normalize(); + }; + Ray.prototype.intersectShape = function(shape, quat, position, body) { + var from = this.from; + var distance = distanceFromIntersection(from, this._direction, position); + if (distance > shape.boundingSphereRadius) return; + var intersectMethod = this[shape.type]; + intersectMethod && intersectMethod.call(this, shape, quat, position, body, shape); + }; + var vector = new Vec3(); + var normal = new Vec3(); + var intersectPoint = new Vec3(); + var a = new Vec3(); + var b = new Vec3(); + var c = new Vec3(); + var d = new Vec3(); + var tmpRaycastResult = new RaycastResult(); + Ray.prototype.intersectBox = function(shape, quat, position, body, reportedShape) { + return this.intersectConvex(shape.convexPolyhedronRepresentation, quat, position, body, reportedShape); + }; + Ray.prototype[Shape.types.BOX] = Ray.prototype.intersectBox; + Ray.prototype.intersectPlane = function(shape, quat, position, body, reportedShape) { + var from = this.from; + var to = this.to; + var direction = this._direction; + var worldNormal = new Vec3(0, 0, 1); + quat.vmult(worldNormal, worldNormal); + var len = new Vec3(); + from.vsub(position, len); + var planeToFrom = len.dot(worldNormal); + to.vsub(position, len); + var planeToTo = len.dot(worldNormal); + if (planeToFrom * planeToTo > 0) return; + if (from.distanceTo(to) < planeToFrom) return; + var n_dot_dir = worldNormal.dot(direction); + if (Math.abs(n_dot_dir) < this.precision) return; + var planePointToFrom = new Vec3(); + var dir_scaled_with_t = new Vec3(); + var hitPointWorld = new Vec3(); + from.vsub(position, planePointToFrom); + var t = -worldNormal.dot(planePointToFrom) / n_dot_dir; + direction.scale(t, dir_scaled_with_t); + from.vadd(dir_scaled_with_t, hitPointWorld); + this.reportIntersection(worldNormal, hitPointWorld, reportedShape, body, -1); + }; + Ray.prototype[Shape.types.PLANE] = Ray.prototype.intersectPlane; + Ray.prototype.getAABB = function(result) { + var to = this.to; + var from = this.from; + result.lowerBound.x = Math.min(to.x, from.x); + result.lowerBound.y = Math.min(to.y, from.y); + result.lowerBound.z = Math.min(to.z, from.z); + result.upperBound.x = Math.max(to.x, from.x); + result.upperBound.y = Math.max(to.y, from.y); + result.upperBound.z = Math.max(to.z, from.z); + }; + var intersectConvexOptions = { + faceList: [ 0 ] + }; + var worldPillarOffset = new Vec3(); + var intersectHeightfield_localRay = new Ray(); + var intersectHeightfield_index = []; + var intersectHeightfield_minMax = []; + Ray.prototype.intersectHeightfield = function(shape, quat, position, body, reportedShape) { + var data = shape.data, w = shape.elementSize; + var localRay = intersectHeightfield_localRay; + localRay.from.copy(this.from); + localRay.to.copy(this.to); + Transform.pointToLocalFrame(position, quat, localRay.from, localRay.from); + Transform.pointToLocalFrame(position, quat, localRay.to, localRay.to); + localRay._updateDirection(); + var index = intersectHeightfield_index; + var iMinX, iMinY, iMaxX, iMaxY; + iMinX = iMinY = 0; + iMaxX = iMaxY = shape.data.length - 1; + var aabb = new AABB(); + localRay.getAABB(aabb); + shape.getIndexOfPosition(aabb.lowerBound.x, aabb.lowerBound.y, index, true); + iMinX = Math.max(iMinX, index[0]); + iMinY = Math.max(iMinY, index[1]); + shape.getIndexOfPosition(aabb.upperBound.x, aabb.upperBound.y, index, true); + iMaxX = Math.min(iMaxX, index[0] + 1); + iMaxY = Math.min(iMaxY, index[1] + 1); + for (var i = iMinX; i < iMaxX; i++) for (var j = iMinY; j < iMaxY; j++) { + if (this.result._shouldStop) return; + shape.getAabbAtIndex(i, j, aabb); + if (!aabb.overlapsRay(localRay)) continue; + shape.getConvexTrianglePillar(i, j, false); + Transform.pointToWorldFrame(position, quat, shape.pillarOffset, worldPillarOffset); + this.intersectConvex(shape.pillarConvex, quat, worldPillarOffset, body, reportedShape, intersectConvexOptions); + if (this.result._shouldStop) return; + shape.getConvexTrianglePillar(i, j, true); + Transform.pointToWorldFrame(position, quat, shape.pillarOffset, worldPillarOffset); + this.intersectConvex(shape.pillarConvex, quat, worldPillarOffset, body, reportedShape, intersectConvexOptions); + } + }; + Ray.prototype[Shape.types.HEIGHTFIELD] = Ray.prototype.intersectHeightfield; + var Ray_intersectSphere_intersectionPoint = new Vec3(); + var Ray_intersectSphere_normal = new Vec3(); + Ray.prototype.intersectSphere = function(shape, quat, position, body, reportedShape) { + var from = this.from, to = this.to, r = shape.radius; + var a = Math.pow(to.x - from.x, 2) + Math.pow(to.y - from.y, 2) + Math.pow(to.z - from.z, 2); + var b = 2 * ((to.x - from.x) * (from.x - position.x) + (to.y - from.y) * (from.y - position.y) + (to.z - from.z) * (from.z - position.z)); + var c = Math.pow(from.x - position.x, 2) + Math.pow(from.y - position.y, 2) + Math.pow(from.z - position.z, 2) - Math.pow(r, 2); + var delta = Math.pow(b, 2) - 4 * a * c; + var intersectionPoint = Ray_intersectSphere_intersectionPoint; + var normal = Ray_intersectSphere_normal; + if (delta < 0) return; + if (0 === delta) { + from.lerp(to, delta, intersectionPoint); + intersectionPoint.vsub(position, normal); + normal.normalize(); + this.reportIntersection(normal, intersectionPoint, reportedShape, body, -1); + } else { + var d1 = (-b - Math.sqrt(delta)) / (2 * a); + var d2 = (-b + Math.sqrt(delta)) / (2 * a); + if (d1 >= 0 && d1 <= 1) { + from.lerp(to, d1, intersectionPoint); + intersectionPoint.vsub(position, normal); + normal.normalize(); + this.reportIntersection(normal, intersectionPoint, reportedShape, body, -1); + } + if (this.result._shouldStop) return; + if (d2 >= 0 && d2 <= 1) { + from.lerp(to, d2, intersectionPoint); + intersectionPoint.vsub(position, normal); + normal.normalize(); + this.reportIntersection(normal, intersectionPoint, reportedShape, body, -1); + } + } + }; + Ray.prototype[Shape.types.SPHERE] = Ray.prototype.intersectSphere; + var intersectConvex_normal = new Vec3(); + var intersectConvex_minDistNormal = new Vec3(); + var intersectConvex_minDistIntersect = new Vec3(); + var intersectConvex_vector = new Vec3(); + Ray.prototype.intersectConvex = function intersectConvex(shape, quat, position, body, reportedShape, options) { + var minDistNormal = intersectConvex_minDistNormal; + var normal = intersectConvex_normal; + var vector = intersectConvex_vector; + var minDistIntersect = intersectConvex_minDistIntersect; + var faceList = options && options.faceList || null; + var faces = shape.faces, vertices = shape.vertices, normals = shape.faceNormals; + var direction = this._direction; + var from = this.from; + var to = this.to; + var fromToDistance = from.distanceTo(to); + var minDist = -1; + var Nfaces = faceList ? faceList.length : faces.length; + var result = this.result; + for (var j = 0; !result._shouldStop && j < Nfaces; j++) { + var fi = faceList ? faceList[j] : j; + var face = faces[fi]; + var faceNormal = normals[fi]; + var q = quat; + var x = position; + vector.copy(vertices[face[0]]); + q.vmult(vector, vector); + vector.vadd(x, vector); + vector.vsub(from, vector); + q.vmult(faceNormal, normal); + var dot = direction.dot(normal); + if (Math.abs(dot) < this.precision) continue; + var scalar = normal.dot(vector) / dot; + if (scalar < 0) continue; + direction.mult(scalar, intersectPoint); + intersectPoint.vadd(from, intersectPoint); + a.copy(vertices[face[0]]); + q.vmult(a, a); + x.vadd(a, a); + for (var i = 1; !result._shouldStop && i < face.length - 1; i++) { + b.copy(vertices[face[i]]); + c.copy(vertices[face[i + 1]]); + q.vmult(b, b); + q.vmult(c, c); + x.vadd(b, b); + x.vadd(c, c); + var distance = intersectPoint.distanceTo(from); + if (!(pointInTriangle(intersectPoint, a, b, c) || pointInTriangle(intersectPoint, b, a, c)) || distance > fromToDistance) continue; + this.reportIntersection(normal, intersectPoint, reportedShape, body, fi); + } + } + }; + Ray.prototype[Shape.types.CONVEXPOLYHEDRON] = Ray.prototype.intersectConvex; + var intersectTrimesh_normal = new Vec3(); + var intersectTrimesh_localDirection = new Vec3(); + var intersectTrimesh_localFrom = new Vec3(); + var intersectTrimesh_localTo = new Vec3(); + var intersectTrimesh_worldNormal = new Vec3(); + var intersectTrimesh_worldIntersectPoint = new Vec3(); + var intersectTrimesh_localAABB = new AABB(); + var intersectTrimesh_triangles = []; + var intersectTrimesh_treeTransform = new Transform(); + Ray.prototype.intersectTrimesh = function intersectTrimesh(mesh, quat, position, body, reportedShape, options) { + var normal = intersectTrimesh_normal; + var triangles = intersectTrimesh_triangles; + var treeTransform = intersectTrimesh_treeTransform; + var minDistNormal = intersectConvex_minDistNormal; + var vector = intersectConvex_vector; + var minDistIntersect = intersectConvex_minDistIntersect; + var localAABB = intersectTrimesh_localAABB; + var localDirection = intersectTrimesh_localDirection; + var localFrom = intersectTrimesh_localFrom; + var localTo = intersectTrimesh_localTo; + var worldIntersectPoint = intersectTrimesh_worldIntersectPoint; + var worldNormal = intersectTrimesh_worldNormal; + var faceList = options && options.faceList || null; + var indices = mesh.indices, vertices = mesh.vertices, normals = mesh.faceNormals; + var from = this.from; + var to = this.to; + var direction = this._direction; + var minDist = -1; + treeTransform.position.copy(position); + treeTransform.quaternion.copy(quat); + Transform.vectorToLocalFrame(position, quat, direction, localDirection); + Transform.pointToLocalFrame(position, quat, from, localFrom); + Transform.pointToLocalFrame(position, quat, to, localTo); + localTo.x *= mesh.scale.x; + localTo.y *= mesh.scale.y; + localTo.z *= mesh.scale.z; + localFrom.x *= mesh.scale.x; + localFrom.y *= mesh.scale.y; + localFrom.z *= mesh.scale.z; + localTo.vsub(localFrom, localDirection); + localDirection.normalize(); + var fromToDistanceSquared = localFrom.distanceSquared(localTo); + mesh.tree.rayQuery(this, treeTransform, triangles); + for (var i = 0, N = triangles.length; !this.result._shouldStop && i !== N; i++) { + var trianglesIndex = triangles[i]; + mesh.getNormal(trianglesIndex, normal); + mesh.getVertex(indices[3 * trianglesIndex], a); + a.vsub(localFrom, vector); + var dot = localDirection.dot(normal); + var scalar = normal.dot(vector) / dot; + if (scalar < 0) continue; + localDirection.scale(scalar, intersectPoint); + intersectPoint.vadd(localFrom, intersectPoint); + mesh.getVertex(indices[3 * trianglesIndex + 1], b); + mesh.getVertex(indices[3 * trianglesIndex + 2], c); + var squaredDistance = intersectPoint.distanceSquared(localFrom); + if (!(pointInTriangle(intersectPoint, b, a, c) || pointInTriangle(intersectPoint, a, b, c)) || squaredDistance > fromToDistanceSquared) continue; + Transform.vectorToWorldFrame(quat, normal, worldNormal); + Transform.pointToWorldFrame(position, quat, intersectPoint, worldIntersectPoint); + this.reportIntersection(worldNormal, worldIntersectPoint, reportedShape, body, trianglesIndex); + } + triangles.length = 0; + }; + Ray.prototype[Shape.types.TRIMESH] = Ray.prototype.intersectTrimesh; + Ray.prototype.reportIntersection = function(normal, hitPointWorld, shape, body, hitFaceIndex) { + var from = this.from; + var to = this.to; + var distance = from.distanceTo(hitPointWorld); + var result = this.result; + if (this.skipBackfaces && normal.dot(this._direction) > 0) return; + result.hitFaceIndex = "undefined" !== typeof hitFaceIndex ? hitFaceIndex : -1; + switch (this.mode) { + case Ray.ALL: + this.hasHit = true; + result.set(from, to, normal, hitPointWorld, shape, body, distance); + result.hasHit = true; + this.callback(result); + break; + + case Ray.CLOSEST: + if (distance < result.distance || !result.hasHit) { + this.hasHit = true; + result.hasHit = true; + result.set(from, to, normal, hitPointWorld, shape, body, distance); + } + break; + + case Ray.ANY: + this.hasHit = true; + result.hasHit = true; + result.set(from, to, normal, hitPointWorld, shape, body, distance); + result._shouldStop = true; + } + }; + var v0 = new Vec3(), intersect = new Vec3(); + function distanceFromIntersection(from, direction, position) { + position.vsub(from, v0); + var dot = v0.dot(direction); + direction.mult(dot, intersect); + intersect.vadd(from, intersect); + var distance = position.distanceTo(intersect); + return distance; + } + }, { + "../collision/AABB": 3, + "../collision/RaycastResult": 11, + "../math/Quaternion": 30, + "../math/Transform": 31, + "../math/Vec3": 32, + "../shapes/Box": 39, + "../shapes/ConvexPolyhedron": 40, + "../shapes/Shape": 45 + } ], + 11: [ function(_dereq_, module, exports) { + var Vec3 = _dereq_("../math/Vec3"); + module.exports = RaycastResult; + function RaycastResult() { + this.rayFromWorld = new Vec3(); + this.rayToWorld = new Vec3(); + this.hitNormalWorld = new Vec3(); + this.hitPointWorld = new Vec3(); + this.hasHit = false; + this.shape = null; + this.body = null; + this.hitFaceIndex = -1; + this.distance = -1; + this._shouldStop = false; + } + RaycastResult.prototype.reset = function() { + this.rayFromWorld.setZero(); + this.rayToWorld.setZero(); + this.hitNormalWorld.setZero(); + this.hitPointWorld.setZero(); + this.hasHit = false; + this.shape = null; + this.body = null; + this.hitFaceIndex = -1; + this.distance = -1; + this._shouldStop = false; + }; + RaycastResult.prototype.abort = function() { + this._shouldStop = true; + }; + RaycastResult.prototype.set = function(rayFromWorld, rayToWorld, hitNormalWorld, hitPointWorld, shape, body, distance) { + this.rayFromWorld.copy(rayFromWorld); + this.rayToWorld.copy(rayToWorld); + this.hitNormalWorld.copy(hitNormalWorld); + this.hitPointWorld.copy(hitPointWorld); + this.shape = shape; + this.body = body; + this.distance = distance; + }; + }, { + "../math/Vec3": 32 + } ], + 12: [ function(_dereq_, module, exports) { + var Shape = _dereq_("../shapes/Shape"); + var Broadphase = _dereq_("../collision/Broadphase"); + module.exports = SAPBroadphase; + function SAPBroadphase(world) { + Broadphase.apply(this); + this.axisList = []; + this.world = null; + this.axisIndex = 0; + var axisList = this.axisList; + this._addBodyHandler = function(e) { + axisList.push(e.body); + }; + this._removeBodyHandler = function(e) { + var idx = axisList.indexOf(e.body); + -1 !== idx && axisList.splice(idx, 1); + }; + world && this.setWorld(world); + } + SAPBroadphase.prototype = new Broadphase(); + SAPBroadphase.prototype.setWorld = function(world) { + this.axisList.length = 0; + for (var i = 0; i < world.bodies.length; i++) this.axisList.push(world.bodies[i]); + world.removeEventListener("addBody", this._addBodyHandler); + world.removeEventListener("removeBody", this._removeBodyHandler); + world.addEventListener("addBody", this._addBodyHandler); + world.addEventListener("removeBody", this._removeBodyHandler); + this.world = world; + this.dirty = true; + }; + SAPBroadphase.insertionSortX = function(a) { + for (var i = 1, l = a.length; i < l; i++) { + var v = a[i]; + for (var j = i - 1; j >= 0; j--) { + if (a[j].aabb.lowerBound.x <= v.aabb.lowerBound.x) break; + a[j + 1] = a[j]; + } + a[j + 1] = v; + } + return a; + }; + SAPBroadphase.insertionSortY = function(a) { + for (var i = 1, l = a.length; i < l; i++) { + var v = a[i]; + for (var j = i - 1; j >= 0; j--) { + if (a[j].aabb.lowerBound.y <= v.aabb.lowerBound.y) break; + a[j + 1] = a[j]; + } + a[j + 1] = v; + } + return a; + }; + SAPBroadphase.insertionSortZ = function(a) { + for (var i = 1, l = a.length; i < l; i++) { + var v = a[i]; + for (var j = i - 1; j >= 0; j--) { + if (a[j].aabb.lowerBound.z <= v.aabb.lowerBound.z) break; + a[j + 1] = a[j]; + } + a[j + 1] = v; + } + return a; + }; + SAPBroadphase.prototype.collisionPairs = function(world, p1, p2) { + var bodies = this.axisList, N = bodies.length, axisIndex = this.axisIndex, i, j; + if (this.dirty) { + this.sortList(); + this.dirty = false; + } + for (i = 0; i !== N; i++) { + var bi = bodies[i]; + for (j = i + 1; j < N; j++) { + var bj = bodies[j]; + if (!this.needBroadphaseCollision(bi, bj)) continue; + if (!SAPBroadphase.checkBounds(bi, bj, axisIndex)) break; + this.intersectionTest(bi, bj, p1, p2); + } + } + }; + SAPBroadphase.prototype.sortList = function() { + var axisList = this.axisList; + var axisIndex = this.axisIndex; + var N = axisList.length; + for (var i = 0; i !== N; i++) { + var bi = axisList[i]; + bi.aabbNeedsUpdate && bi.computeAABB(); + } + 0 === axisIndex ? SAPBroadphase.insertionSortX(axisList) : 1 === axisIndex ? SAPBroadphase.insertionSortY(axisList) : 2 === axisIndex && SAPBroadphase.insertionSortZ(axisList); + }; + SAPBroadphase.checkBounds = function(bi, bj, axisIndex) { + var biPos; + var bjPos; + if (0 === axisIndex) { + biPos = bi.position.x; + bjPos = bj.position.x; + } else if (1 === axisIndex) { + biPos = bi.position.y; + bjPos = bj.position.y; + } else if (2 === axisIndex) { + biPos = bi.position.z; + bjPos = bj.position.z; + } + var ri = bi.boundingRadius, rj = bj.boundingRadius, boundA1 = biPos - ri, boundA2 = biPos + ri, boundB1 = bjPos - rj, boundB2 = bjPos + rj; + return boundB1 < boundA2; + }; + SAPBroadphase.prototype.autoDetectAxis = function() { + var sumX = 0, sumX2 = 0, sumY = 0, sumY2 = 0, sumZ = 0, sumZ2 = 0, bodies = this.axisList, N = bodies.length, invN = 1 / N; + for (var i = 0; i !== N; i++) { + var b = bodies[i]; + var centerX = b.position.x; + sumX += centerX; + sumX2 += centerX * centerX; + var centerY = b.position.y; + sumY += centerY; + sumY2 += centerY * centerY; + var centerZ = b.position.z; + sumZ += centerZ; + sumZ2 += centerZ * centerZ; + } + var varianceX = sumX2 - sumX * sumX * invN, varianceY = sumY2 - sumY * sumY * invN, varianceZ = sumZ2 - sumZ * sumZ * invN; + this.axisIndex = varianceX > varianceY ? varianceX > varianceZ ? 0 : 2 : varianceY > varianceZ ? 1 : 2; + }; + SAPBroadphase.prototype.aabbQuery = function(world, aabb, result) { + result = result || []; + if (this.dirty) { + this.sortList(); + this.dirty = false; + } + var axisIndex = this.axisIndex, axis = "x"; + 1 === axisIndex && (axis = "y"); + 2 === axisIndex && (axis = "z"); + var axisList = this.axisList; + var lower = aabb.lowerBound[axis]; + var upper = aabb.upperBound[axis]; + for (var i = 0; i < axisList.length; i++) { + var b = axisList[i]; + b.aabbNeedsUpdate && b.computeAABB(); + b.aabb.overlaps(aabb) && result.push(b); + } + return result; + }; + }, { + "../collision/Broadphase": 5, + "../shapes/Shape": 45 + } ], + 13: [ function(_dereq_, module, exports) { + module.exports = ConeTwistConstraint; + var Constraint = _dereq_("./Constraint"); + var PointToPointConstraint = _dereq_("./PointToPointConstraint"); + var ConeEquation = _dereq_("../equations/ConeEquation"); + var RotationalEquation = _dereq_("../equations/RotationalEquation"); + var ContactEquation = _dereq_("../equations/ContactEquation"); + var Vec3 = _dereq_("../math/Vec3"); + function ConeTwistConstraint(bodyA, bodyB, options) { + options = options || {}; + var maxForce = "undefined" !== typeof options.maxForce ? options.maxForce : 1e6; + var pivotA = options.pivotA ? options.pivotA.clone() : new Vec3(); + var pivotB = options.pivotB ? options.pivotB.clone() : new Vec3(); + this.axisA = options.axisA ? options.axisA.clone() : new Vec3(); + this.axisB = options.axisB ? options.axisB.clone() : new Vec3(); + PointToPointConstraint.call(this, bodyA, pivotA, bodyB, pivotB, maxForce); + this.collideConnected = !!options.collideConnected; + this.angle = "undefined" !== typeof options.angle ? options.angle : 0; + var c = this.coneEquation = new ConeEquation(bodyA, bodyB, options); + var t = this.twistEquation = new RotationalEquation(bodyA, bodyB, options); + this.twistAngle = "undefined" !== typeof options.twistAngle ? options.twistAngle : 0; + c.maxForce = 0; + c.minForce = -maxForce; + t.maxForce = 0; + t.minForce = -maxForce; + this.equations.push(c, t); + } + ConeTwistConstraint.prototype = new PointToPointConstraint(); + ConeTwistConstraint.constructor = ConeTwistConstraint; + var ConeTwistConstraint_update_tmpVec1 = new Vec3(); + var ConeTwistConstraint_update_tmpVec2 = new Vec3(); + ConeTwistConstraint.prototype.update = function() { + var bodyA = this.bodyA, bodyB = this.bodyB, cone = this.coneEquation, twist = this.twistEquation; + PointToPointConstraint.prototype.update.call(this); + bodyA.vectorToWorldFrame(this.axisA, cone.axisA); + bodyB.vectorToWorldFrame(this.axisB, cone.axisB); + this.axisA.tangents(twist.axisA, twist.axisA); + bodyA.vectorToWorldFrame(twist.axisA, twist.axisA); + this.axisB.tangents(twist.axisB, twist.axisB); + bodyB.vectorToWorldFrame(twist.axisB, twist.axisB); + cone.angle = this.angle; + twist.maxAngle = this.twistAngle; + }; + }, { + "../equations/ConeEquation": 19, + "../equations/ContactEquation": 20, + "../equations/RotationalEquation": 23, + "../math/Vec3": 32, + "./Constraint": 14, + "./PointToPointConstraint": 18 + } ], + 14: [ function(_dereq_, module, exports) { + module.exports = Constraint; + var Utils = _dereq_("../utils/Utils"); + function Constraint(bodyA, bodyB, options) { + options = Utils.defaults(options, { + collideConnected: true, + wakeUpBodies: true + }); + this.equations = []; + this.bodyA = bodyA; + this.bodyB = bodyB; + this.id = Constraint.idCounter++; + this.collideConnected = options.collideConnected; + if (options.wakeUpBodies) { + bodyA && bodyA.wakeUp(); + bodyB && bodyB.wakeUp(); + } + } + Constraint.prototype.update = function() { + throw new Error("method update() not implmemented in this Constraint subclass!"); + }; + Constraint.prototype.enable = function() { + var eqs = this.equations; + for (var i = 0; i < eqs.length; i++) eqs[i].enabled = true; + }; + Constraint.prototype.disable = function() { + var eqs = this.equations; + for (var i = 0; i < eqs.length; i++) eqs[i].enabled = false; + }; + Constraint.idCounter = 0; + }, { + "../utils/Utils": 55 + } ], + 15: [ function(_dereq_, module, exports) { + module.exports = DistanceConstraint; + var Constraint = _dereq_("./Constraint"); + var ContactEquation = _dereq_("../equations/ContactEquation"); + function DistanceConstraint(bodyA, bodyB, distance, maxForce) { + Constraint.call(this, bodyA, bodyB); + "undefined" === typeof distance && (distance = bodyA.position.distanceTo(bodyB.position)); + "undefined" === typeof maxForce && (maxForce = 1e6); + this.distance = distance; + var eq = this.distanceEquation = new ContactEquation(bodyA, bodyB); + this.equations.push(eq); + eq.minForce = -maxForce; + eq.maxForce = maxForce; + } + DistanceConstraint.prototype = new Constraint(); + DistanceConstraint.prototype.update = function() { + var bodyA = this.bodyA; + var bodyB = this.bodyB; + var eq = this.distanceEquation; + var halfDist = .5 * this.distance; + var normal = eq.ni; + bodyB.position.vsub(bodyA.position, normal); + normal.normalize(); + normal.mult(halfDist, eq.ri); + normal.mult(-halfDist, eq.rj); + }; + }, { + "../equations/ContactEquation": 20, + "./Constraint": 14 + } ], + 16: [ function(_dereq_, module, exports) { + module.exports = HingeConstraint; + var Constraint = _dereq_("./Constraint"); + var PointToPointConstraint = _dereq_("./PointToPointConstraint"); + var RotationalEquation = _dereq_("../equations/RotationalEquation"); + var RotationalMotorEquation = _dereq_("../equations/RotationalMotorEquation"); + var ContactEquation = _dereq_("../equations/ContactEquation"); + var Vec3 = _dereq_("../math/Vec3"); + function HingeConstraint(bodyA, bodyB, options) { + options = options || {}; + var maxForce = "undefined" !== typeof options.maxForce ? options.maxForce : 1e6; + var pivotA = options.pivotA ? options.pivotA.clone() : new Vec3(); + var pivotB = options.pivotB ? options.pivotB.clone() : new Vec3(); + PointToPointConstraint.call(this, bodyA, pivotA, bodyB, pivotB, maxForce); + var axisA = this.axisA = options.axisA ? options.axisA.clone() : new Vec3(1, 0, 0); + axisA.normalize(); + var axisB = this.axisB = options.axisB ? options.axisB.clone() : new Vec3(1, 0, 0); + axisB.normalize(); + var r1 = this.rotationalEquation1 = new RotationalEquation(bodyA, bodyB, options); + var r2 = this.rotationalEquation2 = new RotationalEquation(bodyA, bodyB, options); + var motor = this.motorEquation = new RotationalMotorEquation(bodyA, bodyB, maxForce); + motor.enabled = false; + this.equations.push(r1, r2, motor); + } + HingeConstraint.prototype = new PointToPointConstraint(); + HingeConstraint.constructor = HingeConstraint; + HingeConstraint.prototype.enableMotor = function() { + this.motorEquation.enabled = true; + }; + HingeConstraint.prototype.disableMotor = function() { + this.motorEquation.enabled = false; + }; + HingeConstraint.prototype.setMotorSpeed = function(speed) { + this.motorEquation.targetVelocity = speed; + }; + HingeConstraint.prototype.setMotorMaxForce = function(maxForce) { + this.motorEquation.maxForce = maxForce; + this.motorEquation.minForce = -maxForce; + }; + var HingeConstraint_update_tmpVec1 = new Vec3(); + var HingeConstraint_update_tmpVec2 = new Vec3(); + HingeConstraint.prototype.update = function() { + var bodyA = this.bodyA, bodyB = this.bodyB, motor = this.motorEquation, r1 = this.rotationalEquation1, r2 = this.rotationalEquation2, worldAxisA = HingeConstraint_update_tmpVec1, worldAxisB = HingeConstraint_update_tmpVec2; + var axisA = this.axisA; + var axisB = this.axisB; + PointToPointConstraint.prototype.update.call(this); + bodyA.quaternion.vmult(axisA, worldAxisA); + bodyB.quaternion.vmult(axisB, worldAxisB); + worldAxisA.tangents(r1.axisA, r2.axisA); + r1.axisB.copy(worldAxisB); + r2.axisB.copy(worldAxisB); + if (this.motorEquation.enabled) { + bodyA.quaternion.vmult(this.axisA, motor.axisA); + bodyB.quaternion.vmult(this.axisB, motor.axisB); + } + }; + }, { + "../equations/ContactEquation": 20, + "../equations/RotationalEquation": 23, + "../equations/RotationalMotorEquation": 24, + "../math/Vec3": 32, + "./Constraint": 14, + "./PointToPointConstraint": 18 + } ], + 17: [ function(_dereq_, module, exports) { + module.exports = LockConstraint; + var Constraint = _dereq_("./Constraint"); + var PointToPointConstraint = _dereq_("./PointToPointConstraint"); + var RotationalEquation = _dereq_("../equations/RotationalEquation"); + var RotationalMotorEquation = _dereq_("../equations/RotationalMotorEquation"); + var ContactEquation = _dereq_("../equations/ContactEquation"); + var Vec3 = _dereq_("../math/Vec3"); + function LockConstraint(bodyA, bodyB, options) { + options = options || {}; + var maxForce = "undefined" !== typeof options.maxForce ? options.maxForce : 1e6; + var pivotA = new Vec3(); + var pivotB = new Vec3(); + var halfWay = new Vec3(); + bodyA.position.vadd(bodyB.position, halfWay); + halfWay.scale(.5, halfWay); + bodyB.pointToLocalFrame(halfWay, pivotB); + bodyA.pointToLocalFrame(halfWay, pivotA); + PointToPointConstraint.call(this, bodyA, pivotA, bodyB, pivotB, maxForce); + this.xA = bodyA.vectorToLocalFrame(Vec3.UNIT_X); + this.xB = bodyB.vectorToLocalFrame(Vec3.UNIT_X); + this.yA = bodyA.vectorToLocalFrame(Vec3.UNIT_Y); + this.yB = bodyB.vectorToLocalFrame(Vec3.UNIT_Y); + this.zA = bodyA.vectorToLocalFrame(Vec3.UNIT_Z); + this.zB = bodyB.vectorToLocalFrame(Vec3.UNIT_Z); + var r1 = this.rotationalEquation1 = new RotationalEquation(bodyA, bodyB, options); + var r2 = this.rotationalEquation2 = new RotationalEquation(bodyA, bodyB, options); + var r3 = this.rotationalEquation3 = new RotationalEquation(bodyA, bodyB, options); + this.equations.push(r1, r2, r3); + } + LockConstraint.prototype = new PointToPointConstraint(); + LockConstraint.constructor = LockConstraint; + var LockConstraint_update_tmpVec1 = new Vec3(); + var LockConstraint_update_tmpVec2 = new Vec3(); + LockConstraint.prototype.update = function() { + var bodyA = this.bodyA, bodyB = this.bodyB, motor = this.motorEquation, r1 = this.rotationalEquation1, r2 = this.rotationalEquation2, r3 = this.rotationalEquation3, worldAxisA = LockConstraint_update_tmpVec1, worldAxisB = LockConstraint_update_tmpVec2; + PointToPointConstraint.prototype.update.call(this); + bodyA.vectorToWorldFrame(this.xA, r1.axisA); + bodyB.vectorToWorldFrame(this.yB, r1.axisB); + bodyA.vectorToWorldFrame(this.yA, r2.axisA); + bodyB.vectorToWorldFrame(this.zB, r2.axisB); + bodyA.vectorToWorldFrame(this.zA, r3.axisA); + bodyB.vectorToWorldFrame(this.xB, r3.axisB); + }; + }, { + "../equations/ContactEquation": 20, + "../equations/RotationalEquation": 23, + "../equations/RotationalMotorEquation": 24, + "../math/Vec3": 32, + "./Constraint": 14, + "./PointToPointConstraint": 18 + } ], + 18: [ function(_dereq_, module, exports) { + module.exports = PointToPointConstraint; + var Constraint = _dereq_("./Constraint"); + var ContactEquation = _dereq_("../equations/ContactEquation"); + var Vec3 = _dereq_("../math/Vec3"); + function PointToPointConstraint(bodyA, pivotA, bodyB, pivotB, maxForce) { + Constraint.call(this, bodyA, bodyB); + maxForce = "undefined" !== typeof maxForce ? maxForce : 1e6; + this.pivotA = pivotA ? pivotA.clone() : new Vec3(); + this.pivotB = pivotB ? pivotB.clone() : new Vec3(); + var x = this.equationX = new ContactEquation(bodyA, bodyB); + var y = this.equationY = new ContactEquation(bodyA, bodyB); + var z = this.equationZ = new ContactEquation(bodyA, bodyB); + this.equations.push(x, y, z); + x.minForce = y.minForce = z.minForce = -maxForce; + x.maxForce = y.maxForce = z.maxForce = maxForce; + x.ni.set(1, 0, 0); + y.ni.set(0, 1, 0); + z.ni.set(0, 0, 1); + } + PointToPointConstraint.prototype = new Constraint(); + PointToPointConstraint.prototype.update = function() { + var bodyA = this.bodyA; + var bodyB = this.bodyB; + var x = this.equationX; + var y = this.equationY; + var z = this.equationZ; + bodyA.quaternion.vmult(this.pivotA, x.ri); + bodyB.quaternion.vmult(this.pivotB, x.rj); + y.ri.copy(x.ri); + y.rj.copy(x.rj); + z.ri.copy(x.ri); + z.rj.copy(x.rj); + }; + }, { + "../equations/ContactEquation": 20, + "../math/Vec3": 32, + "./Constraint": 14 + } ], + 19: [ function(_dereq_, module, exports) { + module.exports = ConeEquation; + var Vec3 = _dereq_("../math/Vec3"); + var Mat3 = _dereq_("../math/Mat3"); + var Equation = _dereq_("./Equation"); + var CMath = _dereq_("../math/CMath"); + function ConeEquation(bodyA, bodyB, options) { + options = options || {}; + var maxForce = "undefined" !== typeof options.maxForce ? options.maxForce : 1e6; + Equation.call(this, bodyA, bodyB, -maxForce, maxForce); + this.axisA = options.axisA ? options.axisA.clone() : new Vec3(1, 0, 0); + this.axisB = options.axisB ? options.axisB.clone() : new Vec3(0, 1, 0); + this.angle = "undefined" !== typeof options.angle ? options.angle : 0; + } + ConeEquation.prototype = new Equation(); + ConeEquation.prototype.constructor = ConeEquation; + var tmpVec1 = new Vec3(); + var tmpVec2 = new Vec3(); + ConeEquation.prototype.computeB = function(h) { + var a = this.a, b = this.b, ni = this.axisA, nj = this.axisB, nixnj = tmpVec1, njxni = tmpVec2, GA = this.jacobianElementA, GB = this.jacobianElementB; + ni.cross(nj, nixnj); + nj.cross(ni, njxni); + GA.rotational.copy(njxni); + GB.rotational.copy(nixnj); + var g = CMath.cos(this.angle) - ni.dot(nj), GW = this.computeGW(), GiMf = this.computeGiMf(); + var B = -g * a - GW * b - h * GiMf; + return B; + }; + }, { + "../math/CMath": 27, + "../math/Mat3": 29, + "../math/Vec3": 32, + "./Equation": 21 + } ], + 20: [ function(_dereq_, module, exports) { + module.exports = ContactEquation; + var Equation = _dereq_("./Equation"); + var Vec3 = _dereq_("../math/Vec3"); + var Mat3 = _dereq_("../math/Mat3"); + function ContactEquation(bodyA, bodyB, maxForce) { + maxForce = "undefined" !== typeof maxForce ? maxForce : 1e6; + Equation.call(this, bodyA, bodyB, 0, maxForce); + this.si = null; + this.sj = null; + this.restitution = 0; + this.ri = new Vec3(); + this.rj = new Vec3(); + this.ni = new Vec3(); + } + ContactEquation.prototype = new Equation(); + ContactEquation.prototype.constructor = ContactEquation; + var ContactEquation_computeB_temp1 = new Vec3(); + var ContactEquation_computeB_temp2 = new Vec3(); + var ContactEquation_computeB_temp3 = new Vec3(); + ContactEquation.prototype.computeB = function(h) { + var a = this.a, b = this.b, bi = this.bi, bj = this.bj, ri = this.ri, rj = this.rj, rixn = ContactEquation_computeB_temp1, rjxn = ContactEquation_computeB_temp2, vi = bi.velocity, wi = bi.angularVelocity, fi = bi.force, taui = bi.torque, vj = bj.velocity, wj = bj.angularVelocity, fj = bj.force, tauj = bj.torque, penetrationVec = ContactEquation_computeB_temp3, GA = this.jacobianElementA, GB = this.jacobianElementB, n = this.ni; + ri.cross(n, rixn); + rj.cross(n, rjxn); + n.negate(GA.spatial); + rixn.negate(GA.rotational); + GB.spatial.copy(n); + GB.rotational.copy(rjxn); + penetrationVec.copy(bj.position); + penetrationVec.vadd(rj, penetrationVec); + penetrationVec.vsub(bi.position, penetrationVec); + penetrationVec.vsub(ri, penetrationVec); + var g = n.dot(penetrationVec); + var ePlusOne = this.restitution + 1; + var GW = ePlusOne * vj.dot(n) - ePlusOne * vi.dot(n) + wj.dot(rjxn) - wi.dot(rixn); + var GiMf = this.computeGiMf(); + var B = -g * a - GW * b - h * GiMf; + return B; + }; + var ContactEquation_getImpactVelocityAlongNormal_vi = new Vec3(); + var ContactEquation_getImpactVelocityAlongNormal_vj = new Vec3(); + var ContactEquation_getImpactVelocityAlongNormal_xi = new Vec3(); + var ContactEquation_getImpactVelocityAlongNormal_xj = new Vec3(); + var ContactEquation_getImpactVelocityAlongNormal_relVel = new Vec3(); + ContactEquation.prototype.getImpactVelocityAlongNormal = function() { + var vi = ContactEquation_getImpactVelocityAlongNormal_vi; + var vj = ContactEquation_getImpactVelocityAlongNormal_vj; + var xi = ContactEquation_getImpactVelocityAlongNormal_xi; + var xj = ContactEquation_getImpactVelocityAlongNormal_xj; + var relVel = ContactEquation_getImpactVelocityAlongNormal_relVel; + this.bi.position.vadd(this.ri, xi); + this.bj.position.vadd(this.rj, xj); + this.bi.getVelocityAtWorldPoint(xi, vi); + this.bj.getVelocityAtWorldPoint(xj, vj); + vi.vsub(vj, relVel); + return this.ni.dot(relVel); + }; + }, { + "../math/Mat3": 29, + "../math/Vec3": 32, + "./Equation": 21 + } ], + 21: [ function(_dereq_, module, exports) { + module.exports = Equation; + var JacobianElement = _dereq_("../math/JacobianElement"), Vec3 = _dereq_("../math/Vec3"); + function Equation(bi, bj, minForce, maxForce) { + this.id = Equation.id++; + this.minForce = "undefined" === typeof minForce ? -1e6 : minForce; + this.maxForce = "undefined" === typeof maxForce ? 1e6 : maxForce; + this.bi = bi; + this.bj = bj; + this.a = 0; + this.b = 0; + this.eps = 0; + this.jacobianElementA = new JacobianElement(); + this.jacobianElementB = new JacobianElement(); + this.enabled = true; + this.multiplier = 0; + this.setSpookParams(1e7, 4, 1 / 60); + } + Equation.prototype.constructor = Equation; + Equation.id = 0; + Equation.prototype.setSpookParams = function(stiffness, relaxation, timeStep) { + var d = relaxation, k = stiffness, h = timeStep; + this.a = 4 / (h * (1 + 4 * d)); + this.b = 4 * d / (1 + 4 * d); + this.eps = 4 / (h * h * k * (1 + 4 * d)); + }; + Equation.prototype.computeB = function(a, b, h) { + var GW = this.computeGW(), Gq = this.computeGq(), GiMf = this.computeGiMf(); + return -Gq * a - GW * b - GiMf * h; + }; + Equation.prototype.computeGq = function() { + var GA = this.jacobianElementA, GB = this.jacobianElementB, bi = this.bi, bj = this.bj, xi = bi.position, xj = bj.position; + return GA.spatial.dot(xi) + GB.spatial.dot(xj); + }; + var zero = new Vec3(); + Equation.prototype.computeGW = function() { + var GA = this.jacobianElementA, GB = this.jacobianElementB, bi = this.bi, bj = this.bj, vi = bi.velocity, vj = bj.velocity, wi = bi.angularVelocity, wj = bj.angularVelocity; + return GA.multiplyVectors(vi, wi) + GB.multiplyVectors(vj, wj); + }; + Equation.prototype.computeGWlambda = function() { + var GA = this.jacobianElementA, GB = this.jacobianElementB, bi = this.bi, bj = this.bj, vi = bi.vlambda, vj = bj.vlambda, wi = bi.wlambda, wj = bj.wlambda; + return GA.multiplyVectors(vi, wi) + GB.multiplyVectors(vj, wj); + }; + var iMfi = new Vec3(), iMfj = new Vec3(), invIi_vmult_taui = new Vec3(), invIj_vmult_tauj = new Vec3(); + Equation.prototype.computeGiMf = function() { + var GA = this.jacobianElementA, GB = this.jacobianElementB, bi = this.bi, bj = this.bj, fi = bi.force, ti = bi.torque, fj = bj.force, tj = bj.torque, invMassi = bi.invMassSolve, invMassj = bj.invMassSolve; + fi.scale(invMassi, iMfi); + fj.scale(invMassj, iMfj); + bi.invInertiaWorldSolve.vmult(ti, invIi_vmult_taui); + bj.invInertiaWorldSolve.vmult(tj, invIj_vmult_tauj); + return GA.multiplyVectors(iMfi, invIi_vmult_taui) + GB.multiplyVectors(iMfj, invIj_vmult_tauj); + }; + var tmp = new Vec3(); + Equation.prototype.computeGiMGt = function() { + var GA = this.jacobianElementA, GB = this.jacobianElementB, bi = this.bi, bj = this.bj, invMassi = bi.invMassSolve, invMassj = bj.invMassSolve, invIi = bi.invInertiaWorldSolve, invIj = bj.invInertiaWorldSolve, result = invMassi + invMassj; + invIi.vmult(GA.rotational, tmp); + result += tmp.dot(GA.rotational); + invIj.vmult(GB.rotational, tmp); + result += tmp.dot(GB.rotational); + return result; + }; + var addToWlambda_temp = new Vec3(), addToWlambda_Gi = new Vec3(), addToWlambda_Gj = new Vec3(), addToWlambda_ri = new Vec3(), addToWlambda_rj = new Vec3(), addToWlambda_Mdiag = new Vec3(); + Equation.prototype.addToWlambda = function(deltalambda) { + var GA = this.jacobianElementA, GB = this.jacobianElementB, bi = this.bi, bj = this.bj, temp = addToWlambda_temp; + bi.vlambda.addScaledVector(bi.invMassSolve * deltalambda, GA.spatial, bi.vlambda); + bj.vlambda.addScaledVector(bj.invMassSolve * deltalambda, GB.spatial, bj.vlambda); + bi.invInertiaWorldSolve.vmult(GA.rotational, temp); + bi.wlambda.addScaledVector(deltalambda, temp, bi.wlambda); + bj.invInertiaWorldSolve.vmult(GB.rotational, temp); + bj.wlambda.addScaledVector(deltalambda, temp, bj.wlambda); + }; + Equation.prototype.computeC = function() { + return this.computeGiMGt() + this.eps; + }; + }, { + "../math/JacobianElement": 28, + "../math/Vec3": 32 + } ], + 22: [ function(_dereq_, module, exports) { + module.exports = FrictionEquation; + var Equation = _dereq_("./Equation"); + var Vec3 = _dereq_("../math/Vec3"); + var Mat3 = _dereq_("../math/Mat3"); + function FrictionEquation(bodyA, bodyB, slipForce) { + Equation.call(this, bodyA, bodyB, -slipForce, slipForce); + this.ri = new Vec3(); + this.rj = new Vec3(); + this.t = new Vec3(); + } + FrictionEquation.prototype = new Equation(); + FrictionEquation.prototype.constructor = FrictionEquation; + var FrictionEquation_computeB_temp1 = new Vec3(); + var FrictionEquation_computeB_temp2 = new Vec3(); + FrictionEquation.prototype.computeB = function(h) { + var a = this.a, b = this.b, bi = this.bi, bj = this.bj, ri = this.ri, rj = this.rj, rixt = FrictionEquation_computeB_temp1, rjxt = FrictionEquation_computeB_temp2, t = this.t; + ri.cross(t, rixt); + rj.cross(t, rjxt); + var GA = this.jacobianElementA, GB = this.jacobianElementB; + t.negate(GA.spatial); + rixt.negate(GA.rotational); + GB.spatial.copy(t); + GB.rotational.copy(rjxt); + var GW = this.computeGW(); + var GiMf = this.computeGiMf(); + var B = -GW * b - h * GiMf; + return B; + }; + }, { + "../math/Mat3": 29, + "../math/Vec3": 32, + "./Equation": 21 + } ], + 23: [ function(_dereq_, module, exports) { + module.exports = RotationalEquation; + var Vec3 = _dereq_("../math/Vec3"); + var Mat3 = _dereq_("../math/Mat3"); + var Equation = _dereq_("./Equation"); + var CMath = _dereq_("../math/CMath"); + function RotationalEquation(bodyA, bodyB, options) { + options = options || {}; + var maxForce = "undefined" !== typeof options.maxForce ? options.maxForce : 1e6; + Equation.call(this, bodyA, bodyB, -maxForce, maxForce); + this.axisA = options.axisA ? options.axisA.clone() : new Vec3(1, 0, 0); + this.axisB = options.axisB ? options.axisB.clone() : new Vec3(0, 1, 0); + this.maxAngle = Math.PI / 2; + } + RotationalEquation.prototype = new Equation(); + RotationalEquation.prototype.constructor = RotationalEquation; + var tmpVec1 = new Vec3(); + var tmpVec2 = new Vec3(); + RotationalEquation.prototype.computeB = function(h) { + var a = this.a, b = this.b, ni = this.axisA, nj = this.axisB, nixnj = tmpVec1, njxni = tmpVec2, GA = this.jacobianElementA, GB = this.jacobianElementB; + ni.cross(nj, nixnj); + nj.cross(ni, njxni); + GA.rotational.copy(njxni); + GB.rotational.copy(nixnj); + var g = CMath.cos(this.maxAngle) - ni.dot(nj), GW = this.computeGW(), GiMf = this.computeGiMf(); + var B = -g * a - GW * b - h * GiMf; + return B; + }; + }, { + "../math/CMath": 27, + "../math/Mat3": 29, + "../math/Vec3": 32, + "./Equation": 21 + } ], + 24: [ function(_dereq_, module, exports) { + module.exports = RotationalMotorEquation; + var Vec3 = _dereq_("../math/Vec3"); + var Mat3 = _dereq_("../math/Mat3"); + var Equation = _dereq_("./Equation"); + function RotationalMotorEquation(bodyA, bodyB, maxForce) { + maxForce = "undefined" !== typeof maxForce ? maxForce : 1e6; + Equation.call(this, bodyA, bodyB, -maxForce, maxForce); + this.axisA = new Vec3(); + this.axisB = new Vec3(); + this.targetVelocity = 0; + } + RotationalMotorEquation.prototype = new Equation(); + RotationalMotorEquation.prototype.constructor = RotationalMotorEquation; + RotationalMotorEquation.prototype.computeB = function(h) { + var a = this.a, b = this.b, bi = this.bi, bj = this.bj, axisA = this.axisA, axisB = this.axisB, GA = this.jacobianElementA, GB = this.jacobianElementB; + GA.rotational.copy(axisA); + axisB.negate(GB.rotational); + var GW = this.computeGW() - this.targetVelocity, GiMf = this.computeGiMf(); + var B = -GW * b - h * GiMf; + return B; + }; + }, { + "../math/Mat3": 29, + "../math/Vec3": 32, + "./Equation": 21 + } ], + 25: [ function(_dereq_, module, exports) { + var Utils = _dereq_("../utils/Utils"); + module.exports = ContactMaterial; + function ContactMaterial(m1, m2, options) { + options = Utils.defaults(options, { + friction: .3, + restitution: .3, + contactEquationStiffness: 1e7, + contactEquationRelaxation: 3, + frictionEquationStiffness: 1e7, + frictionEquationRelaxation: 3 + }); + this.id = ContactMaterial.idCounter++; + this.materials = [ m1, m2 ]; + this.friction = options.friction; + this.restitution = options.restitution; + this.contactEquationStiffness = options.contactEquationStiffness; + this.contactEquationRelaxation = options.contactEquationRelaxation; + this.frictionEquationStiffness = options.frictionEquationStiffness; + this.frictionEquationRelaxation = options.frictionEquationRelaxation; + } + ContactMaterial.idCounter = 0; + }, { + "../utils/Utils": 55 + } ], + 26: [ function(_dereq_, module, exports) { + module.exports = Material; + function Material(options) { + var name = ""; + options = options || {}; + if ("string" === typeof options) { + name = options; + options = {}; + } else "object" === typeof options && (name = ""); + this.name = name; + this.id = Material.idCounter++; + this.friction = "undefined" !== typeof options.friction ? options.friction : -1; + this.restitution = "undefined" !== typeof options.restitution ? options.restitution : -1; + } + Material.idCounter = 0; + }, {} ], + 27: [ function(_dereq_, module, exports) { + var rad2ang = 180 / Math.PI; + function radian2angle(rad) { + return rad * rad2ang; + } + var sinArr = {}; + function calculateSinByDigit(digit) { + if (sinArr.digit == digit) return; + var step = 1 / Math.pow(10, digit); + for (var i = 0; i <= 90; i += step) sinArr[i.toFixed(digit)] = Math.sin(i / rad2ang); + sinArr.digit = digit; + } + function sin360(angle, digit) { + if (angle <= 90) return sinArr[angle.toFixed(digit)]; + if (angle <= 180) { + angle = 180 - angle; + return sinArr[angle.toFixed(digit)]; + } + if (angle <= 270) { + angle -= 180; + return -sinArr[angle.toFixed(digit)]; + } + angle = 360 - angle; + return -sinArr[angle.toFixed(digit)]; + } + function sin(rad) { + var angle = radian2angle(rad) % 360; + angle < 0 && (angle += 360); + return sin360(angle, CMath._digit); + } + function cos(rad) { + var angle = (radian2angle(rad) + 90) % 360; + angle < 0 && (angle += 360); + return sin360(angle, CMath._digit); + } + function sinNative(rad) { + return Math.sin(rad).toFixed(CMath.digit); + } + function cosNative(rad) { + return Math.cos(rad).toFixed(CMath.digit); + } + var CMath = { + sin: Math.sin, + cos: Math.cos, + atan2: Math.atan2 + }; + CMath._sin = sin; + CMath._cos = cos; + CMath._sinArr = sinArr; + CMath._sin360 = sin360; + CMath._sinNative = sinNative; + CMath._cosNative = cosNative; + CMath._radian2angle = radian2angle; + CMath._calculateSinByDigit = calculateSinByDigit; + CMath._digit = 1; + Object.defineProperty(CMath, "digit", { + get: function get() { + return this._digit; + }, + set: function set(v) { + this._digit = v; + 1 == this._mode && calculateSinByDigit(v); + } + }); + CMath._mode = 0; + Object.defineProperty(CMath, "mode", { + get: function get() { + return this._mode; + }, + set: function set(v) { + if (this._mode != v) { + this._mode = v; + if (0 == v) { + CMath.sin = Math.sin; + CMath.cos = Math.cos; + } else if (1 == v) { + CMath.digit = CMath._digit; + CMath.sin = sin; + CMath.cos = cos; + } else if (2 == v) { + CMath.sin = sinNative; + CMath.cos = cosNative; + } + } + } + }); + module.exports = CMath; + }, {} ], + 28: [ function(_dereq_, module, exports) { + module.exports = JacobianElement; + var Vec3 = _dereq_("./Vec3"); + function JacobianElement() { + this.spatial = new Vec3(); + this.rotational = new Vec3(); + } + JacobianElement.prototype.multiplyElement = function(element) { + return element.spatial.dot(this.spatial) + element.rotational.dot(this.rotational); + }; + JacobianElement.prototype.multiplyVectors = function(spatial, rotational) { + return spatial.dot(this.spatial) + rotational.dot(this.rotational); + }; + }, { + "./Vec3": 32 + } ], + 29: [ function(_dereq_, module, exports) { + module.exports = Mat3; + var Vec3 = _dereq_("./Vec3"); + function Mat3(elements) { + this.elements = elements || [ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]; + } + Mat3.prototype.identity = function() { + var e = this.elements; + e[0] = 1; + e[1] = 0; + e[2] = 0; + e[3] = 0; + e[4] = 1; + e[5] = 0; + e[6] = 0; + e[7] = 0; + e[8] = 1; + }; + Mat3.prototype.setZero = function() { + var e = this.elements; + e[0] = 0; + e[1] = 0; + e[2] = 0; + e[3] = 0; + e[4] = 0; + e[5] = 0; + e[6] = 0; + e[7] = 0; + e[8] = 0; + }; + Mat3.prototype.setTrace = function(vec3) { + var e = this.elements; + e[0] = vec3.x; + e[4] = vec3.y; + e[8] = vec3.z; + }; + Mat3.prototype.getTrace = function(target) { + var target = target || new Vec3(); + var e = this.elements; + target.x = e[0]; + target.y = e[4]; + target.z = e[8]; + }; + Mat3.prototype.vmult = function(v, target) { + target = target || new Vec3(); + var e = this.elements, x = v.x, y = v.y, z = v.z; + target.x = e[0] * x + e[1] * y + e[2] * z; + target.y = e[3] * x + e[4] * y + e[5] * z; + target.z = e[6] * x + e[7] * y + e[8] * z; + return target; + }; + Mat3.prototype.smult = function(s) { + for (var i = 0; i < this.elements.length; i++) this.elements[i] *= s; + }; + Mat3.prototype.mmult = function(m, target) { + var r = target || new Mat3(); + for (var i = 0; i < 3; i++) for (var j = 0; j < 3; j++) { + var sum = 0; + for (var k = 0; k < 3; k++) sum += m.elements[i + 3 * k] * this.elements[k + 3 * j]; + r.elements[i + 3 * j] = sum; + } + return r; + }; + Mat3.prototype.scale = function(v, target) { + target = target || new Mat3(); + var e = this.elements, t = target.elements; + for (var i = 0; 3 !== i; i++) { + t[3 * i + 0] = v.x * e[3 * i + 0]; + t[3 * i + 1] = v.y * e[3 * i + 1]; + t[3 * i + 2] = v.z * e[3 * i + 2]; + } + return target; + }; + Mat3.prototype.solve = function(b, target) { + target = target || new Vec3(); + var nr = 3; + var nc = 4; + var eqns = []; + for (var i = 0; i < nr * nc; i++) eqns.push(0); + var i, j; + for (i = 0; i < 3; i++) for (j = 0; j < 3; j++) eqns[i + nc * j] = this.elements[i + 3 * j]; + eqns[3] = b.x; + eqns[7] = b.y; + eqns[11] = b.z; + var n = 3, k = n, np; + var kp = 4; + var p, els; + do { + i = k - n; + if (0 === eqns[i + nc * i]) for (j = i + 1; j < k; j++) if (0 !== eqns[i + nc * j]) { + np = kp; + do { + p = kp - np; + eqns[p + nc * i] += eqns[p + nc * j]; + } while (--np); + break; + } + if (0 !== eqns[i + nc * i]) for (j = i + 1; j < k; j++) { + var multiplier = eqns[i + nc * j] / eqns[i + nc * i]; + np = kp; + do { + p = kp - np; + eqns[p + nc * j] = p <= i ? 0 : eqns[p + nc * j] - eqns[p + nc * i] * multiplier; + } while (--np); + } + } while (--n); + target.z = eqns[2 * nc + 3] / eqns[2 * nc + 2]; + target.y = (eqns[1 * nc + 3] - eqns[1 * nc + 2] * target.z) / eqns[1 * nc + 1]; + target.x = (eqns[0 * nc + 3] - eqns[0 * nc + 2] * target.z - eqns[0 * nc + 1] * target.y) / eqns[0 * nc + 0]; + if (isNaN(target.x) || isNaN(target.y) || isNaN(target.z) || Infinity === target.x || Infinity === target.y || Infinity === target.z) throw "Could not solve equation! Got x=[" + target.toString() + "], b=[" + b.toString() + "], A=[" + this.toString() + "]"; + return target; + }; + Mat3.prototype.e = function(row, column, value) { + if (void 0 === value) return this.elements[column + 3 * row]; + this.elements[column + 3 * row] = value; + }; + Mat3.prototype.copy = function(source) { + for (var i = 0; i < source.elements.length; i++) this.elements[i] = source.elements[i]; + return this; + }; + Mat3.prototype.toString = function() { + var r = ""; + var sep = ","; + for (var i = 0; i < 9; i++) r += this.elements[i] + sep; + return r; + }; + Mat3.prototype.reverse = function(target) { + target = target || new Mat3(); + var nr = 3; + var nc = 6; + var eqns = []; + for (var i = 0; i < nr * nc; i++) eqns.push(0); + var i, j; + for (i = 0; i < 3; i++) for (j = 0; j < 3; j++) eqns[i + nc * j] = this.elements[i + 3 * j]; + eqns[3] = 1; + eqns[9] = 0; + eqns[15] = 0; + eqns[4] = 0; + eqns[10] = 1; + eqns[16] = 0; + eqns[5] = 0; + eqns[11] = 0; + eqns[17] = 1; + var n = 3, k = n, np; + var kp = nc; + var p; + do { + i = k - n; + if (0 === eqns[i + nc * i]) for (j = i + 1; j < k; j++) if (0 !== eqns[i + nc * j]) { + np = kp; + do { + p = kp - np; + eqns[p + nc * i] += eqns[p + nc * j]; + } while (--np); + break; + } + if (0 !== eqns[i + nc * i]) for (j = i + 1; j < k; j++) { + var multiplier = eqns[i + nc * j] / eqns[i + nc * i]; + np = kp; + do { + p = kp - np; + eqns[p + nc * j] = p <= i ? 0 : eqns[p + nc * j] - eqns[p + nc * i] * multiplier; + } while (--np); + } + } while (--n); + i = 2; + do { + j = i - 1; + do { + var multiplier = eqns[i + nc * j] / eqns[i + nc * i]; + np = nc; + do { + p = nc - np; + eqns[p + nc * j] = eqns[p + nc * j] - eqns[p + nc * i] * multiplier; + } while (--np); + } while (j--); + } while (--i); + i = 2; + do { + var multiplier = 1 / eqns[i + nc * i]; + np = nc; + do { + p = nc - np; + eqns[p + nc * i] = eqns[p + nc * i] * multiplier; + } while (--np); + } while (i--); + i = 2; + do { + j = 2; + do { + p = eqns[nr + j + nc * i]; + if (isNaN(p) || Infinity === p) throw "Could not reverse! A=[" + this.toString() + "]"; + target.e(i, j, p); + } while (j--); + } while (i--); + return target; + }; + Mat3.prototype.setRotationFromQuaternion = function(q) { + var x = q.x, y = q.y, z = q.z, w = q.w, x2 = x + x, y2 = y + y, z2 = z + z, xx = x * x2, xy = x * y2, xz = x * z2, yy = y * y2, yz = y * z2, zz = z * z2, wx = w * x2, wy = w * y2, wz = w * z2, e = this.elements; + e[0] = 1 - (yy + zz); + e[1] = xy - wz; + e[2] = xz + wy; + e[3] = xy + wz; + e[4] = 1 - (xx + zz); + e[5] = yz - wx; + e[6] = xz - wy; + e[7] = yz + wx; + e[8] = 1 - (xx + yy); + return this; + }; + Mat3.prototype.transpose = function(target) { + target = target || new Mat3(); + var Mt = target.elements, M = this.elements; + for (var i = 0; 3 !== i; i++) for (var j = 0; 3 !== j; j++) Mt[3 * i + j] = M[3 * j + i]; + return target; + }; + }, { + "./Vec3": 32 + } ], + 30: [ function(_dereq_, module, exports) { + module.exports = Quaternion; + var Vec3 = _dereq_("./Vec3"); + var CMath = _dereq_("./CMath"); + function Quaternion(x, y, z, w) { + this.x = void 0 !== x ? x : 0; + this.y = void 0 !== y ? y : 0; + this.z = void 0 !== z ? z : 0; + this.w = void 0 !== w ? w : 1; + } + Quaternion.prototype.set = function(x, y, z, w) { + this.x = x; + this.y = y; + this.z = z; + this.w = w; + return this; + }; + Quaternion.prototype.toString = function() { + return this.x + "," + this.y + "," + this.z + "," + this.w; + }; + Quaternion.prototype.toArray = function() { + return [ this.x, this.y, this.z, this.w ]; + }; + Quaternion.prototype.setFromAxisAngle = function(axis, angle) { + var s = CMath.sin(.5 * angle); + this.x = axis.x * s; + this.y = axis.y * s; + this.z = axis.z * s; + this.w = CMath.cos(.5 * angle); + return this; + }; + Quaternion.prototype.toAxisAngle = function(targetAxis) { + targetAxis = targetAxis || new Vec3(); + this.normalize(); + var angle = 2 * Math.acos(this.w); + var s = Math.sqrt(1 - this.w * this.w); + if (s < .001) { + targetAxis.x = this.x; + targetAxis.y = this.y; + targetAxis.z = this.z; + } else { + targetAxis.x = this.x / s; + targetAxis.y = this.y / s; + targetAxis.z = this.z / s; + } + return [ targetAxis, angle ]; + }; + var sfv_t1 = new Vec3(), sfv_t2 = new Vec3(); + Quaternion.prototype.setFromVectors = function(u, v) { + if (u.isAntiparallelTo(v)) { + var t1 = sfv_t1; + var t2 = sfv_t2; + u.tangents(t1, t2); + this.setFromAxisAngle(t1, Math.PI); + } else { + var a = u.cross(v); + this.x = a.x; + this.y = a.y; + this.z = a.z; + this.w = Math.sqrt(Math.pow(u.norm(), 2) * Math.pow(v.norm(), 2)) + u.dot(v); + this.normalize(); + } + return this; + }; + var Quaternion_mult_va = new Vec3(); + var Quaternion_mult_vb = new Vec3(); + var Quaternion_mult_vaxvb = new Vec3(); + Quaternion.prototype.mult = function(q, target) { + target = target || new Quaternion(); + var ax = this.x, ay = this.y, az = this.z, aw = this.w, bx = q.x, by = q.y, bz = q.z, bw = q.w; + target.x = ax * bw + aw * bx + ay * bz - az * by; + target.y = ay * bw + aw * by + az * bx - ax * bz; + target.z = az * bw + aw * bz + ax * by - ay * bx; + target.w = aw * bw - ax * bx - ay * by - az * bz; + return target; + }; + Quaternion.prototype.inverse = function(target) { + var x = this.x, y = this.y, z = this.z, w = this.w; + target = target || new Quaternion(); + this.conjugate(target); + var inorm2 = 1 / (x * x + y * y + z * z + w * w); + target.x *= inorm2; + target.y *= inorm2; + target.z *= inorm2; + target.w *= inorm2; + return target; + }; + Quaternion.prototype.conjugate = function(target) { + target = target || new Quaternion(); + target.x = -this.x; + target.y = -this.y; + target.z = -this.z; + target.w = this.w; + return target; + }; + Quaternion.prototype.normalize = function() { + var l = Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w); + if (0 === l) { + this.x = 0; + this.y = 0; + this.z = 0; + this.w = 0; + } else { + l = 1 / l; + this.x *= l; + this.y *= l; + this.z *= l; + this.w *= l; + } + return this; + }; + Quaternion.prototype.normalizeFast = function() { + var f = (3 - (this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w)) / 2; + if (0 === f) { + this.x = 0; + this.y = 0; + this.z = 0; + this.w = 0; + } else { + this.x *= f; + this.y *= f; + this.z *= f; + this.w *= f; + } + return this; + }; + Quaternion.prototype.vmult = function(v, target) { + target = target || new Vec3(); + var x = v.x, y = v.y, z = v.z; + var qx = this.x, qy = this.y, qz = this.z, qw = this.w; + var ix = qw * x + qy * z - qz * y, iy = qw * y + qz * x - qx * z, iz = qw * z + qx * y - qy * x, iw = -qx * x - qy * y - qz * z; + target.x = ix * qw + iw * -qx + iy * -qz - iz * -qy; + target.y = iy * qw + iw * -qy + iz * -qx - ix * -qz; + target.z = iz * qw + iw * -qz + ix * -qy - iy * -qx; + return target; + }; + Quaternion.prototype.copy = function(source) { + this.x = source.x; + this.y = source.y; + this.z = source.z; + this.w = source.w; + return this; + }; + Quaternion.prototype.toEuler = function(target, order) { + order = order || "YZX"; + var heading, attitude, bank; + var x = this.x, y = this.y, z = this.z, w = this.w; + switch (order) { + case "YZX": + var test = x * y + z * w; + if (test > .499) { + heading = 2 * CMath.atan2(x, w); + attitude = Math.PI / 2; + bank = 0; + } + if (test < -.499) { + heading = -2 * CMath.atan2(x, w); + attitude = -Math.PI / 2; + bank = 0; + } + if (isNaN(heading)) { + var sqx = x * x; + var sqy = y * y; + var sqz = z * z; + heading = CMath.atan2(2 * y * w - 2 * x * z, 1 - 2 * sqy - 2 * sqz); + attitude = Math.asin(2 * test); + bank = CMath.atan2(2 * x * w - 2 * y * z, 1 - 2 * sqx - 2 * sqz); + } + break; + + default: + throw new Error("Euler order " + order + " not supported yet."); + } + target.y = heading; + target.z = attitude; + target.x = bank; + }; + Quaternion.prototype.setFromEuler = function(x, y, z, order) { + order = order || "XYZ"; + var c1 = CMath.cos(x / 2); + var c2 = CMath.cos(y / 2); + var c3 = CMath.cos(z / 2); + var s1 = CMath.sin(x / 2); + var s2 = CMath.sin(y / 2); + var s3 = CMath.sin(z / 2); + if ("XYZ" === order) { + this.x = s1 * c2 * c3 + c1 * s2 * s3; + this.y = c1 * s2 * c3 - s1 * c2 * s3; + this.z = c1 * c2 * s3 + s1 * s2 * c3; + this.w = c1 * c2 * c3 - s1 * s2 * s3; + } else if ("YXZ" === order) { + this.x = s1 * c2 * c3 + c1 * s2 * s3; + this.y = c1 * s2 * c3 - s1 * c2 * s3; + this.z = c1 * c2 * s3 - s1 * s2 * c3; + this.w = c1 * c2 * c3 + s1 * s2 * s3; + } else if ("ZXY" === order) { + this.x = s1 * c2 * c3 - c1 * s2 * s3; + this.y = c1 * s2 * c3 + s1 * c2 * s3; + this.z = c1 * c2 * s3 + s1 * s2 * c3; + this.w = c1 * c2 * c3 - s1 * s2 * s3; + } else if ("ZYX" === order) { + this.x = s1 * c2 * c3 - c1 * s2 * s3; + this.y = c1 * s2 * c3 + s1 * c2 * s3; + this.z = c1 * c2 * s3 - s1 * s2 * c3; + this.w = c1 * c2 * c3 + s1 * s2 * s3; + } else if ("YZX" === order) { + this.x = s1 * c2 * c3 + c1 * s2 * s3; + this.y = c1 * s2 * c3 + s1 * c2 * s3; + this.z = c1 * c2 * s3 - s1 * s2 * c3; + this.w = c1 * c2 * c3 - s1 * s2 * s3; + } else if ("XZY" === order) { + this.x = s1 * c2 * c3 - c1 * s2 * s3; + this.y = c1 * s2 * c3 - s1 * c2 * s3; + this.z = c1 * c2 * s3 + s1 * s2 * c3; + this.w = c1 * c2 * c3 + s1 * s2 * s3; + } + return this; + }; + Quaternion.prototype.clone = function() { + return new Quaternion(this.x, this.y, this.z, this.w); + }; + Quaternion.prototype.slerp = function(toQuat, t, target) { + target = target || new Quaternion(); + var ax = this.x, ay = this.y, az = this.z, aw = this.w, bx = toQuat.x, by = toQuat.y, bz = toQuat.z, bw = toQuat.w; + var omega, cosom, sinom, scale0, scale1; + cosom = ax * bx + ay * by + az * bz + aw * bw; + if (cosom < 0) { + cosom = -cosom; + bx = -bx; + by = -by; + bz = -bz; + bw = -bw; + } + if (1 - cosom > 1e-6) { + omega = Math.acos(cosom); + sinom = CMath.sin(omega); + scale0 = CMath.sin((1 - t) * omega) / sinom; + scale1 = CMath.sin(t * omega) / sinom; + } else { + scale0 = 1 - t; + scale1 = t; + } + target.x = scale0 * ax + scale1 * bx; + target.y = scale0 * ay + scale1 * by; + target.z = scale0 * az + scale1 * bz; + target.w = scale0 * aw + scale1 * bw; + return target; + }; + Quaternion.prototype.integrate = function(angularVelocity, dt, angularFactor, target) { + target = target || new Quaternion(); + var ax = angularVelocity.x * angularFactor.x, ay = angularVelocity.y * angularFactor.y, az = angularVelocity.z * angularFactor.z, bx = this.x, by = this.y, bz = this.z, bw = this.w; + var half_dt = .5 * dt; + target.x += half_dt * (ax * bw + ay * bz - az * by); + target.y += half_dt * (ay * bw + az * bx - ax * bz); + target.z += half_dt * (az * bw + ax * by - ay * bx); + target.w += half_dt * (-ax * bx - ay * by - az * bz); + return target; + }; + }, { + "./CMath": 27, + "./Vec3": 32 + } ], + 31: [ function(_dereq_, module, exports) { + var Vec3 = _dereq_("./Vec3"); + var Quaternion = _dereq_("./Quaternion"); + module.exports = Transform; + function Transform(options) { + options = options || {}; + this.position = new Vec3(); + options.position && this.position.copy(options.position); + this.quaternion = new Quaternion(); + options.quaternion && this.quaternion.copy(options.quaternion); + } + var tmpQuat = new Quaternion(); + Transform.pointToLocalFrame = function(position, quaternion, worldPoint, result) { + var result = result || new Vec3(); + worldPoint.vsub(position, result); + quaternion.conjugate(tmpQuat); + tmpQuat.vmult(result, result); + return result; + }; + Transform.prototype.pointToLocal = function(worldPoint, result) { + return Transform.pointToLocalFrame(this.position, this.quaternion, worldPoint, result); + }; + Transform.pointToWorldFrame = function(position, quaternion, localPoint, result) { + var result = result || new Vec3(); + quaternion.vmult(localPoint, result); + result.vadd(position, result); + return result; + }; + Transform.prototype.pointToWorld = function(localPoint, result) { + return Transform.pointToWorldFrame(this.position, this.quaternion, localPoint, result); + }; + Transform.prototype.vectorToWorldFrame = function(localVector, result) { + var result = result || new Vec3(); + this.quaternion.vmult(localVector, result); + return result; + }; + Transform.vectorToWorldFrame = function(quaternion, localVector, result) { + quaternion.vmult(localVector, result); + return result; + }; + Transform.vectorToLocalFrame = function(position, quaternion, worldVector, result) { + var result = result || new Vec3(); + quaternion.w *= -1; + quaternion.vmult(worldVector, result); + quaternion.w *= -1; + return result; + }; + }, { + "./Quaternion": 30, + "./Vec3": 32 + } ], + 32: [ function(_dereq_, module, exports) { + module.exports = Vec3; + var Mat3 = _dereq_("./Mat3"); + function Vec3(x, y, z) { + this.x = x || 0; + this.y = y || 0; + this.z = z || 0; + } + Vec3.ZERO = new Vec3(0, 0, 0); + Vec3.UNIT_X = new Vec3(1, 0, 0); + Vec3.UNIT_Y = new Vec3(0, 1, 0); + Vec3.UNIT_Z = new Vec3(0, 0, 1); + Vec3.prototype.cross = function(v, target) { + var vx = v.x, vy = v.y, vz = v.z, x = this.x, y = this.y, z = this.z; + target = target || new Vec3(); + target.x = y * vz - z * vy; + target.y = z * vx - x * vz; + target.z = x * vy - y * vx; + return target; + }; + Vec3.prototype.set = function(x, y, z) { + this.x = x; + this.y = y; + this.z = z; + return this; + }; + Vec3.prototype.setZero = function() { + this.x = this.y = this.z = 0; + }; + Vec3.prototype.vadd = function(v, target) { + if (!target) return new Vec3(this.x + v.x, this.y + v.y, this.z + v.z); + target.x = v.x + this.x; + target.y = v.y + this.y; + target.z = v.z + this.z; + }; + Vec3.prototype.vsub = function(v, target) { + if (!target) return new Vec3(this.x - v.x, this.y - v.y, this.z - v.z); + target.x = this.x - v.x; + target.y = this.y - v.y; + target.z = this.z - v.z; + }; + Vec3.prototype.crossmat = function() { + return new Mat3([ 0, -this.z, this.y, this.z, 0, -this.x, -this.y, this.x, 0 ]); + }; + Vec3.prototype.normalize = function() { + var x = this.x, y = this.y, z = this.z; + var n = Math.sqrt(x * x + y * y + z * z); + if (n > 0) { + var invN = 1 / n; + this.x *= invN; + this.y *= invN; + this.z *= invN; + } else { + this.x = 0; + this.y = 0; + this.z = 0; + } + return n; + }; + Vec3.prototype.unit = function(target) { + target = target || new Vec3(); + var x = this.x, y = this.y, z = this.z; + var ninv = Math.sqrt(x * x + y * y + z * z); + if (ninv > 0) { + ninv = 1 / ninv; + target.x = x * ninv; + target.y = y * ninv; + target.z = z * ninv; + } else { + target.x = 1; + target.y = 0; + target.z = 0; + } + return target; + }; + Vec3.prototype.norm = function() { + var x = this.x, y = this.y, z = this.z; + return Math.sqrt(x * x + y * y + z * z); + }; + Vec3.prototype.length = Vec3.prototype.norm; + Vec3.prototype.norm2 = function() { + return this.dot(this); + }; + Vec3.prototype.lengthSquared = Vec3.prototype.norm2; + Vec3.prototype.distanceTo = function(p) { + var x = this.x, y = this.y, z = this.z; + var px = p.x, py = p.y, pz = p.z; + return Math.sqrt((px - x) * (px - x) + (py - y) * (py - y) + (pz - z) * (pz - z)); + }; + Vec3.prototype.distanceSquared = function(p) { + var x = this.x, y = this.y, z = this.z; + var px = p.x, py = p.y, pz = p.z; + return (px - x) * (px - x) + (py - y) * (py - y) + (pz - z) * (pz - z); + }; + Vec3.prototype.mult = function(scalar, target) { + target = target || new Vec3(); + var x = this.x, y = this.y, z = this.z; + target.x = scalar * x; + target.y = scalar * y; + target.z = scalar * z; + return target; + }; + Vec3.prototype.vmul = function(vector, target) { + target = target || new Vec3(); + target.x = vector.x * this.x; + target.y = vector.y * this.y; + target.z = vector.z * this.z; + return target; + }; + Vec3.prototype.scale = Vec3.prototype.mult; + Vec3.prototype.addScaledVector = function(scalar, vector, target) { + target = target || new Vec3(); + target.x = this.x + scalar * vector.x; + target.y = this.y + scalar * vector.y; + target.z = this.z + scalar * vector.z; + return target; + }; + Vec3.prototype.dot = function(v) { + return this.x * v.x + this.y * v.y + this.z * v.z; + }; + Vec3.prototype.isZero = function() { + return 0 === this.x && 0 === this.y && 0 === this.z; + }; + Vec3.prototype.negate = function(target) { + target = target || new Vec3(); + target.x = -this.x; + target.y = -this.y; + target.z = -this.z; + return target; + }; + var Vec3_tangents_n = new Vec3(); + var Vec3_tangents_randVec = new Vec3(); + Vec3.prototype.tangents = function(t1, t2) { + var norm = this.norm(); + if (norm > 0) { + var n = Vec3_tangents_n; + var inorm = 1 / norm; + n.set(this.x * inorm, this.y * inorm, this.z * inorm); + var randVec = Vec3_tangents_randVec; + if (Math.abs(n.x) < .9) { + randVec.set(1, 0, 0); + n.cross(randVec, t1); + } else { + randVec.set(0, 1, 0); + n.cross(randVec, t1); + } + n.cross(t1, t2); + } else { + t1.set(1, 0, 0); + t2.set(0, 1, 0); + } + }; + Vec3.prototype.toString = function() { + return this.x + "," + this.y + "," + this.z; + }; + Vec3.prototype.toArray = function() { + return [ this.x, this.y, this.z ]; + }; + Vec3.prototype.copy = function(source) { + this.x = source.x; + this.y = source.y; + this.z = source.z; + return this; + }; + Vec3.prototype.lerp = function(v, t, target) { + var x = this.x, y = this.y, z = this.z; + target.x = x + (v.x - x) * t; + target.y = y + (v.y - y) * t; + target.z = z + (v.z - z) * t; + }; + Vec3.prototype.almostEquals = function(v, precision) { + void 0 === precision && (precision = 1e-6); + if (Math.abs(this.x - v.x) > precision || Math.abs(this.y - v.y) > precision || Math.abs(this.z - v.z) > precision) return false; + return true; + }; + Vec3.prototype.almostZero = function(precision) { + void 0 === precision && (precision = 1e-6); + if (Math.abs(this.x) > precision || Math.abs(this.y) > precision || Math.abs(this.z) > precision) return false; + return true; + }; + var antip_neg = new Vec3(); + Vec3.prototype.isAntiparallelTo = function(v, precision) { + this.negate(antip_neg); + return antip_neg.almostEquals(v, precision); + }; + Vec3.prototype.clone = function() { + return new Vec3(this.x, this.y, this.z); + }; + }, { + "./Mat3": 29 + } ], + 33: [ function(_dereq_, module, exports) { + module.exports = Body; + var EventTarget = _dereq_("../utils/EventTarget"); + var Shape = _dereq_("../shapes/Shape"); + var Vec3 = _dereq_("../math/Vec3"); + var Mat3 = _dereq_("../math/Mat3"); + var Quaternion = _dereq_("../math/Quaternion"); + var Material = _dereq_("../material/Material"); + var AABB = _dereq_("../collision/AABB"); + var Box = _dereq_("../shapes/Box"); + var World = _dereq_("../world/World"); + function Body(options) { + options = options || {}; + EventTarget.apply(this); + this.id = Body.idCounter++; + this.world = null; + this.preStep = null; + this.postStep = null; + this.vlambda = new Vec3(); + this.collisionFilterGroup = "number" === typeof options.collisionFilterGroup ? options.collisionFilterGroup : 1; + this.collisionFilterMask = "number" === typeof options.collisionFilterMask ? options.collisionFilterMask : -1; + this.collisionResponse = true; + this.position = new Vec3(); + this.previousPosition = new Vec3(); + this.interpolatedPosition = new Vec3(); + this.initPosition = new Vec3(); + if (options.position) { + this.position.copy(options.position); + this.previousPosition.copy(options.position); + this.interpolatedPosition.copy(options.position); + this.initPosition.copy(options.position); + } + this.velocity = new Vec3(); + options.velocity && this.velocity.copy(options.velocity); + this.initVelocity = new Vec3(); + this.force = new Vec3(); + var mass = "number" === typeof options.mass ? options.mass : 0; + this.mass = mass; + this.invMass = mass > 0 ? 1 / mass : 0; + this.material = options.material || null; + this.linearDamping = "number" === typeof options.linearDamping ? options.linearDamping : .01; + this.type = mass <= 0 ? Body.STATIC : Body.DYNAMIC; + typeof options.type === typeof Body.STATIC && (this.type = options.type); + this.allowSleep = "undefined" === typeof options.allowSleep || options.allowSleep; + this.sleepState = 0; + this.sleepSpeedLimit = "undefined" !== typeof options.sleepSpeedLimit ? options.sleepSpeedLimit : .1; + this.sleepTimeLimit = "undefined" !== typeof options.sleepTimeLimit ? options.sleepTimeLimit : 1; + this.timeLastSleepy = 0; + this._wakeUpAfterNarrowphase = false; + this.torque = new Vec3(); + this.quaternion = new Quaternion(); + this.initQuaternion = new Quaternion(); + this.previousQuaternion = new Quaternion(); + this.interpolatedQuaternion = new Quaternion(); + if (options.quaternion) { + this.quaternion.copy(options.quaternion); + this.initQuaternion.copy(options.quaternion); + this.previousQuaternion.copy(options.quaternion); + this.interpolatedQuaternion.copy(options.quaternion); + } + this.angularVelocity = new Vec3(); + options.angularVelocity && this.angularVelocity.copy(options.angularVelocity); + this.initAngularVelocity = new Vec3(); + this.shapes = []; + this.shapeOffsets = []; + this.shapeOrientations = []; + this.inertia = new Vec3(); + this.invInertia = new Vec3(); + this.invInertiaWorld = new Mat3(); + this.invMassSolve = 0; + this.invInertiaSolve = new Vec3(); + this.invInertiaWorldSolve = new Mat3(); + this.fixedRotation = "undefined" !== typeof options.fixedRotation && options.fixedRotation; + this.useGravity = true; + this.angularDamping = "undefined" !== typeof options.angularDamping ? options.angularDamping : .01; + this.linearFactor = new Vec3(1, 1, 1); + options.linearFactor && this.linearFactor.copy(options.linearFactor); + this.angularFactor = new Vec3(1, 1, 1); + options.angularFactor && this.angularFactor.copy(options.angularFactor); + this.aabb = new AABB(); + this.aabbNeedsUpdate = true; + this.boundingRadius = 0; + this.wlambda = new Vec3(); + options.shape && this.addShape(options.shape); + this.hasTrigger = true; + this.updateMassProperties(); + } + Body.prototype = new EventTarget(); + Body.prototype.constructor = Body; + Body.COLLIDE_EVENT_NAME = "collide"; + Body.DYNAMIC = 1; + Body.STATIC = 2; + Body.KINEMATIC = 4; + Body.AWAKE = 0; + Body.SLEEPY = 1; + Body.SLEEPING = 2; + Body.idCounter = 0; + Body.wakeupEvent = { + type: "wakeup" + }; + Body.prototype.wakeUp = function() { + World.SLEEPING = false; + var s = this.sleepState; + this.sleepState = 0; + this._wakeUpAfterNarrowphase = false; + s === Body.SLEEPING && this.dispatchEvent(Body.wakeupEvent); + }; + Body.prototype.sleep = function() { + this.sleepState = Body.SLEEPING; + this.velocity.set(0, 0, 0); + this.angularVelocity.set(0, 0, 0); + this._wakeUpAfterNarrowphase = false; + }; + Body.sleepyEvent = { + type: "sleepy" + }; + Body.sleepEvent = { + type: "sleep" + }; + Body.prototype.sleepTick = function(time) { + if (this.allowSleep) { + var sleepState = this.sleepState; + var speedSquared = this.velocity.norm2() + this.angularVelocity.norm2(); + var speedLimitSquared = Math.pow(this.sleepSpeedLimit, 2); + if (sleepState === Body.AWAKE && speedSquared < speedLimitSquared) { + this.sleepState = Body.SLEEPY; + this.timeLastSleepy = time; + this.dispatchEvent(Body.sleepyEvent); + } else if (sleepState === Body.SLEEPY && speedSquared > speedLimitSquared) this.wakeUp(); else if (sleepState === Body.SLEEPY && time - this.timeLastSleepy > this.sleepTimeLimit) { + this.sleep(); + this.dispatchEvent(Body.sleepEvent); + } + } + }; + Body.prototype.updateSolveMassProperties = function() { + if (this.sleepState === Body.SLEEPING || this.type === Body.KINEMATIC) { + this.invMassSolve = 0; + this.invInertiaSolve.setZero(); + this.invInertiaWorldSolve.setZero(); + } else { + this.invMassSolve = this.invMass; + this.invInertiaSolve.copy(this.invInertia); + this.invInertiaWorldSolve.copy(this.invInertiaWorld); + } + }; + Body.prototype.pointToLocalFrame = function(worldPoint, result) { + var result = result || new Vec3(); + worldPoint.vsub(this.position, result); + this.quaternion.conjugate().vmult(result, result); + return result; + }; + Body.prototype.vectorToLocalFrame = function(worldVector, result) { + var result = result || new Vec3(); + this.quaternion.conjugate().vmult(worldVector, result); + return result; + }; + Body.prototype.pointToWorldFrame = function(localPoint, result) { + var result = result || new Vec3(); + this.quaternion.vmult(localPoint, result); + result.vadd(this.position, result); + return result; + }; + Body.prototype.vectorToWorldFrame = function(localVector, result) { + var result = result || new Vec3(); + this.quaternion.vmult(localVector, result); + return result; + }; + var tmpVec = new Vec3(); + var tmpQuat = new Quaternion(); + Body.prototype.addShape = function(shape, _offset, _orientation) { + var offset = new Vec3(); + var orientation = new Quaternion(); + _offset && offset.copy(_offset); + _orientation && orientation.copy(_orientation); + this.shapes.push(shape); + this.shapeOffsets.push(offset); + this.shapeOrientations.push(orientation); + this.aabbNeedsUpdate = true; + this.updateMassProperties(); + this.updateBoundingRadius(); + this.updateHasTrigger(); + World.idToShapeMap[shape.id] = shape; + shape.body = this; + return this; + }; + Body.prototype.removeShape = function(shape) { + var idx = this.shapes.indexOf(shape); + if (-1 === idx) return; + this.shapes.splice(idx, 1); + this.shapeOffsets.splice(idx, 1); + this.shapeOrientations.splice(idx, 1); + this.aabbNeedsUpdate = true; + this.updateMassProperties(); + this.updateBoundingRadius(); + this.updateHasTrigger(); + }; + Body.prototype.updateBoundingRadius = function() { + var shapes = this.shapes, shapeOffsets = this.shapeOffsets, N = shapes.length, radius = 0; + for (var i = 0; i !== N; i++) { + var shape = shapes[i]; + shape.updateBoundingSphereRadius(); + var offset = shapeOffsets[i].norm(), r = shape.boundingSphereRadius; + offset + r > radius && (radius = offset + r); + } + this.boundingRadius = radius; + }; + var computeAABB_shapeAABB = new AABB(); + Body.prototype.computeAABB = function() { + var shapes = this.shapes, shapeOffsets = this.shapeOffsets, shapeOrientations = this.shapeOrientations, N = shapes.length, offset = tmpVec, orientation = tmpQuat, bodyQuat = this.quaternion, aabb = this.aabb, shapeAABB = computeAABB_shapeAABB; + for (var i = 0; i !== N; i++) { + var shape = shapes[i]; + bodyQuat.vmult(shapeOffsets[i], offset); + offset.vadd(this.position, offset); + shapeOrientations[i].mult(bodyQuat, orientation); + shape.calculateWorldAABB(offset, orientation, shapeAABB.lowerBound, shapeAABB.upperBound); + 0 === i ? aabb.copy(shapeAABB) : aabb.extend(shapeAABB); + } + this.aabbNeedsUpdate = false; + }; + var uiw_m1 = new Mat3(), uiw_m2 = new Mat3(), uiw_m3 = new Mat3(); + Body.prototype.updateInertiaWorld = function(force) { + var I = this.invInertia; + if (I.x !== I.y || I.y !== I.z || force) { + var m1 = uiw_m1, m2 = uiw_m2, m3 = uiw_m3; + m1.setRotationFromQuaternion(this.quaternion); + m1.transpose(m2); + m1.scale(I, m1); + m1.mmult(m2, this.invInertiaWorld); + } else ; + }; + var Body_applyForce_r = new Vec3(); + var Body_applyForce_rotForce = new Vec3(); + Body.prototype.applyForce = function(force, relativePoint) { + if (this.type !== Body.DYNAMIC) return; + var rotForce = Body_applyForce_rotForce; + relativePoint.cross(force, rotForce); + this.force.vadd(force, this.force); + this.torque.vadd(rotForce, this.torque); + }; + var Body_applyLocalForce_worldForce = new Vec3(); + var Body_applyLocalForce_relativePointWorld = new Vec3(); + Body.prototype.applyLocalForce = function(localForce, localPoint) { + if (this.type !== Body.DYNAMIC) return; + var worldForce = Body_applyLocalForce_worldForce; + var relativePointWorld = Body_applyLocalForce_relativePointWorld; + this.vectorToWorldFrame(localForce, worldForce); + this.vectorToWorldFrame(localPoint, relativePointWorld); + this.applyForce(worldForce, relativePointWorld); + }; + var Body_applyImpulse_r = new Vec3(); + var Body_applyImpulse_velo = new Vec3(); + var Body_applyImpulse_rotVelo = new Vec3(); + Body.prototype.applyImpulse = function(impulse, relativePoint) { + if (this.type !== Body.DYNAMIC) return; + var r = relativePoint; + var velo = Body_applyImpulse_velo; + velo.copy(impulse); + velo.mult(this.invMass, velo); + this.velocity.vadd(velo, this.velocity); + var rotVelo = Body_applyImpulse_rotVelo; + r.cross(impulse, rotVelo); + this.invInertiaWorld.vmult(rotVelo, rotVelo); + this.angularVelocity.vadd(rotVelo, this.angularVelocity); + }; + var Body_applyLocalImpulse_worldImpulse = new Vec3(); + var Body_applyLocalImpulse_relativePoint = new Vec3(); + Body.prototype.applyLocalImpulse = function(localImpulse, localPoint) { + if (this.type !== Body.DYNAMIC) return; + var worldImpulse = Body_applyLocalImpulse_worldImpulse; + var relativePointWorld = Body_applyLocalImpulse_relativePoint; + this.vectorToWorldFrame(localImpulse, worldImpulse); + this.vectorToWorldFrame(localPoint, relativePointWorld); + this.applyImpulse(worldImpulse, relativePointWorld); + }; + var Body_updateMassProperties_halfExtents = new Vec3(); + Body.prototype.updateMassProperties = function() { + var halfExtents = Body_updateMassProperties_halfExtents; + this.invMass = this.mass > 0 ? 1 / this.mass : 0; + var I = this.inertia; + var fixed = this.fixedRotation; + this.computeAABB(); + halfExtents.set((this.aabb.upperBound.x - this.aabb.lowerBound.x) / 2, (this.aabb.upperBound.y - this.aabb.lowerBound.y) / 2, (this.aabb.upperBound.z - this.aabb.lowerBound.z) / 2); + Box.calculateInertia(halfExtents, this.mass, I); + this.invInertia.set(I.x > 0 && !fixed ? 1 / I.x : 0, I.y > 0 && !fixed ? 1 / I.y : 0, I.z > 0 && !fixed ? 1 / I.z : 0); + this.updateInertiaWorld(true); + }; + Body.prototype.getVelocityAtWorldPoint = function(worldPoint, result) { + var r = new Vec3(); + worldPoint.vsub(this.position, r); + this.angularVelocity.cross(r, result); + this.velocity.vadd(result, result); + return result; + }; + var torque = new Vec3(); + var invI_tau_dt = new Vec3(); + var w = new Quaternion(); + var wq = new Quaternion(); + Body.prototype.integrate = function(dt, quatNormalize, quatNormalizeFast) { + this.previousPosition.copy(this.position); + this.previousQuaternion.copy(this.quaternion); + if (!(this.type === Body.DYNAMIC || this.type === Body.KINEMATIC) || this.sleepState === Body.SLEEPING) return; + var velo = this.velocity, angularVelo = this.angularVelocity, pos = this.position, force = this.force, torque = this.torque, quat = this.quaternion, invMass = this.invMass, invInertia = this.invInertiaWorld, linearFactor = this.linearFactor; + var iMdt = invMass * dt; + velo.x += force.x * iMdt * linearFactor.x; + velo.y += force.y * iMdt * linearFactor.y; + velo.z += force.z * iMdt * linearFactor.z; + var e = invInertia.elements; + var angularFactor = this.angularFactor; + var tx = torque.x * angularFactor.x; + var ty = torque.y * angularFactor.y; + var tz = torque.z * angularFactor.z; + angularVelo.x += dt * (e[0] * tx + e[1] * ty + e[2] * tz); + angularVelo.y += dt * (e[3] * tx + e[4] * ty + e[5] * tz); + angularVelo.z += dt * (e[6] * tx + e[7] * ty + e[8] * tz); + pos.x += velo.x * dt; + pos.y += velo.y * dt; + pos.z += velo.z * dt; + quat.integrate(this.angularVelocity, dt, this.angularFactor, quat); + quatNormalize && (quatNormalizeFast ? quat.normalizeFast() : quat.normalize()); + this.aabbNeedsUpdate = true; + this.updateInertiaWorld(); + }; + Body.prototype.isSleeping = function() { + return this.sleepState === Body.SLEEPING; + }; + Body.prototype.isSleepy = function() { + return this.sleepState === Body.SLEEPY; + }; + Body.prototype.isAwake = function() { + return this.sleepState === Body.AWAKE; + }; + Body.prototype.updateHasTrigger = function() { + for (var i = this.shapes.length; i--; ) { + this.hasTrigger = !this.shapes[i].collisionResponse; + if (this.hasTrigger) break; + } + }; + }, { + "../collision/AABB": 3, + "../material/Material": 26, + "../math/Mat3": 29, + "../math/Quaternion": 30, + "../math/Vec3": 32, + "../shapes/Box": 39, + "../shapes/Shape": 45, + "../utils/EventTarget": 51, + "../world/World": 58 + } ], + 34: [ function(_dereq_, module, exports) { + var Body = _dereq_("./Body"); + var Vec3 = _dereq_("../math/Vec3"); + var Quaternion = _dereq_("../math/Quaternion"); + var RaycastResult = _dereq_("../collision/RaycastResult"); + var Ray = _dereq_("../collision/Ray"); + var WheelInfo = _dereq_("../objects/WheelInfo"); + module.exports = RaycastVehicle; + function RaycastVehicle(options) { + this.chassisBody = options.chassisBody; + this.wheelInfos = []; + this.sliding = false; + this.world = null; + this.indexRightAxis = "undefined" !== typeof options.indexRightAxis ? options.indexRightAxis : 1; + this.indexForwardAxis = "undefined" !== typeof options.indexForwardAxis ? options.indexForwardAxis : 0; + this.indexUpAxis = "undefined" !== typeof options.indexUpAxis ? options.indexUpAxis : 2; + } + var tmpVec1 = new Vec3(); + var tmpVec2 = new Vec3(); + var tmpVec3 = new Vec3(); + var tmpVec4 = new Vec3(); + var tmpVec5 = new Vec3(); + var tmpVec6 = new Vec3(); + var tmpRay = new Ray(); + RaycastVehicle.prototype.addWheel = function(options) { + options = options || {}; + var info = new WheelInfo(options); + var index = this.wheelInfos.length; + this.wheelInfos.push(info); + return index; + }; + RaycastVehicle.prototype.setSteeringValue = function(value, wheelIndex) { + var wheel = this.wheelInfos[wheelIndex]; + wheel.steering = value; + }; + var torque = new Vec3(); + RaycastVehicle.prototype.applyEngineForce = function(value, wheelIndex) { + this.wheelInfos[wheelIndex].engineForce = value; + }; + RaycastVehicle.prototype.setBrake = function(brake, wheelIndex) { + this.wheelInfos[wheelIndex].brake = brake; + }; + RaycastVehicle.prototype.addToWorld = function(world) { + var constraints = this.constraints; + world.addBody(this.chassisBody); + var that = this; + this.preStepCallback = function() { + that.updateVehicle(world.dt); + }; + world.addEventListener("preStep", this.preStepCallback); + this.world = world; + }; + RaycastVehicle.prototype.getVehicleAxisWorld = function(axisIndex, result) { + result.set(0 === axisIndex ? 1 : 0, 1 === axisIndex ? 1 : 0, 2 === axisIndex ? 1 : 0); + this.chassisBody.vectorToWorldFrame(result, result); + }; + RaycastVehicle.prototype.updateVehicle = function(timeStep) { + var wheelInfos = this.wheelInfos; + var numWheels = wheelInfos.length; + var chassisBody = this.chassisBody; + for (var i = 0; i < numWheels; i++) this.updateWheelTransform(i); + this.currentVehicleSpeedKmHour = 3.6 * chassisBody.velocity.norm(); + var forwardWorld = new Vec3(); + this.getVehicleAxisWorld(this.indexForwardAxis, forwardWorld); + forwardWorld.dot(chassisBody.velocity) < 0 && (this.currentVehicleSpeedKmHour *= -1); + for (var i = 0; i < numWheels; i++) this.castRay(wheelInfos[i]); + this.updateSuspension(timeStep); + var impulse = new Vec3(); + var relpos = new Vec3(); + for (var i = 0; i < numWheels; i++) { + var wheel = wheelInfos[i]; + var suspensionForce = wheel.suspensionForce; + suspensionForce > wheel.maxSuspensionForce && (suspensionForce = wheel.maxSuspensionForce); + wheel.raycastResult.hitNormalWorld.scale(suspensionForce * timeStep, impulse); + wheel.raycastResult.hitPointWorld.vsub(chassisBody.position, relpos); + chassisBody.applyImpulse(impulse, relpos); + } + this.updateFriction(timeStep); + var hitNormalWorldScaledWithProj = new Vec3(); + var fwd = new Vec3(); + var vel = new Vec3(); + for (i = 0; i < numWheels; i++) { + var wheel = wheelInfos[i]; + chassisBody.getVelocityAtWorldPoint(wheel.chassisConnectionPointWorld, vel); + var m = 1; + switch (this.indexUpAxis) { + case 1: + m = -1; + } + if (wheel.isInContact) { + this.getVehicleAxisWorld(this.indexForwardAxis, fwd); + var proj = fwd.dot(wheel.raycastResult.hitNormalWorld); + wheel.raycastResult.hitNormalWorld.scale(proj, hitNormalWorldScaledWithProj); + fwd.vsub(hitNormalWorldScaledWithProj, fwd); + var proj2 = fwd.dot(vel); + wheel.deltaRotation = m * proj2 * timeStep / wheel.radius; + } + !wheel.sliding && wheel.isInContact || 0 === wheel.engineForce || !wheel.useCustomSlidingRotationalSpeed || (wheel.deltaRotation = (wheel.engineForce > 0 ? 1 : -1) * wheel.customSlidingRotationalSpeed * timeStep); + Math.abs(wheel.brake) > Math.abs(wheel.engineForce) && (wheel.deltaRotation = 0); + wheel.rotation += wheel.deltaRotation; + wheel.deltaRotation *= .99; + } + }; + RaycastVehicle.prototype.updateSuspension = function(deltaTime) { + var chassisBody = this.chassisBody; + var chassisMass = chassisBody.mass; + var wheelInfos = this.wheelInfos; + var numWheels = wheelInfos.length; + for (var w_it = 0; w_it < numWheels; w_it++) { + var wheel = wheelInfos[w_it]; + if (wheel.isInContact) { + var force; + var susp_length = wheel.suspensionRestLength; + var current_length = wheel.suspensionLength; + var length_diff = susp_length - current_length; + force = wheel.suspensionStiffness * length_diff * wheel.clippedInvContactDotSuspension; + var projected_rel_vel = wheel.suspensionRelativeVelocity; + var susp_damping; + susp_damping = projected_rel_vel < 0 ? wheel.dampingCompression : wheel.dampingRelaxation; + force -= susp_damping * projected_rel_vel; + wheel.suspensionForce = force * chassisMass; + wheel.suspensionForce < 0 && (wheel.suspensionForce = 0); + } else wheel.suspensionForce = 0; + } + }; + RaycastVehicle.prototype.removeFromWorld = function(world) { + var constraints = this.constraints; + world.remove(this.chassisBody); + world.removeEventListener("preStep", this.preStepCallback); + this.world = null; + }; + var castRay_rayvector = new Vec3(); + var castRay_target = new Vec3(); + RaycastVehicle.prototype.castRay = function(wheel) { + var rayvector = castRay_rayvector; + var target = castRay_target; + this.updateWheelTransformWorld(wheel); + var chassisBody = this.chassisBody; + var depth = -1; + var raylen = wheel.suspensionRestLength + wheel.radius; + wheel.directionWorld.scale(raylen, rayvector); + var source = wheel.chassisConnectionPointWorld; + source.vadd(rayvector, target); + var raycastResult = wheel.raycastResult; + var param = 0; + raycastResult.reset(); + var oldState = chassisBody.collisionResponse; + chassisBody.collisionResponse = false; + this.world.rayTest(source, target, raycastResult); + chassisBody.collisionResponse = oldState; + var object = raycastResult.body; + wheel.raycastResult.groundObject = 0; + if (object) { + depth = raycastResult.distance; + wheel.raycastResult.hitNormalWorld = raycastResult.hitNormalWorld; + wheel.isInContact = true; + var hitDistance = raycastResult.distance; + wheel.suspensionLength = hitDistance - wheel.radius; + var minSuspensionLength = wheel.suspensionRestLength - wheel.maxSuspensionTravel; + var maxSuspensionLength = wheel.suspensionRestLength + wheel.maxSuspensionTravel; + wheel.suspensionLength < minSuspensionLength && (wheel.suspensionLength = minSuspensionLength); + if (wheel.suspensionLength > maxSuspensionLength) { + wheel.suspensionLength = maxSuspensionLength; + wheel.raycastResult.reset(); + } + var denominator = wheel.raycastResult.hitNormalWorld.dot(wheel.directionWorld); + var chassis_velocity_at_contactPoint = new Vec3(); + chassisBody.getVelocityAtWorldPoint(wheel.raycastResult.hitPointWorld, chassis_velocity_at_contactPoint); + var projVel = wheel.raycastResult.hitNormalWorld.dot(chassis_velocity_at_contactPoint); + if (denominator >= -.1) { + wheel.suspensionRelativeVelocity = 0; + wheel.clippedInvContactDotSuspension = 10; + } else { + var inv = -1 / denominator; + wheel.suspensionRelativeVelocity = projVel * inv; + wheel.clippedInvContactDotSuspension = inv; + } + } else { + wheel.suspensionLength = wheel.suspensionRestLength + 0 * wheel.maxSuspensionTravel; + wheel.suspensionRelativeVelocity = 0; + wheel.directionWorld.scale(-1, wheel.raycastResult.hitNormalWorld); + wheel.clippedInvContactDotSuspension = 1; + } + return depth; + }; + RaycastVehicle.prototype.updateWheelTransformWorld = function(wheel) { + wheel.isInContact = false; + var chassisBody = this.chassisBody; + chassisBody.pointToWorldFrame(wheel.chassisConnectionPointLocal, wheel.chassisConnectionPointWorld); + chassisBody.vectorToWorldFrame(wheel.directionLocal, wheel.directionWorld); + chassisBody.vectorToWorldFrame(wheel.axleLocal, wheel.axleWorld); + }; + RaycastVehicle.prototype.updateWheelTransform = function(wheelIndex) { + var up = tmpVec4; + var right = tmpVec5; + var fwd = tmpVec6; + var wheel = this.wheelInfos[wheelIndex]; + this.updateWheelTransformWorld(wheel); + wheel.directionLocal.scale(-1, up); + right.copy(wheel.axleLocal); + up.cross(right, fwd); + fwd.normalize(); + right.normalize(); + var steering = wheel.steering; + var steeringOrn = new Quaternion(); + steeringOrn.setFromAxisAngle(up, steering); + var rotatingOrn = new Quaternion(); + rotatingOrn.setFromAxisAngle(right, wheel.rotation); + var q = wheel.worldTransform.quaternion; + this.chassisBody.quaternion.mult(steeringOrn, q); + q.mult(rotatingOrn, q); + q.normalize(); + var p = wheel.worldTransform.position; + p.copy(wheel.directionWorld); + p.scale(wheel.suspensionLength, p); + p.vadd(wheel.chassisConnectionPointWorld, p); + }; + var directions = [ new Vec3(1, 0, 0), new Vec3(0, 1, 0), new Vec3(0, 0, 1) ]; + RaycastVehicle.prototype.getWheelTransformWorld = function(wheelIndex) { + return this.wheelInfos[wheelIndex].worldTransform; + }; + var updateFriction_surfNormalWS_scaled_proj = new Vec3(); + var updateFriction_axle = []; + var updateFriction_forwardWS = []; + var sideFrictionStiffness2 = 1; + RaycastVehicle.prototype.updateFriction = function(timeStep) { + var surfNormalWS_scaled_proj = updateFriction_surfNormalWS_scaled_proj; + var wheelInfos = this.wheelInfos; + var numWheels = wheelInfos.length; + var chassisBody = this.chassisBody; + var forwardWS = updateFriction_forwardWS; + var axle = updateFriction_axle; + var numWheelsOnGround = 0; + for (var i = 0; i < numWheels; i++) { + var wheel = wheelInfos[i]; + var groundObject = wheel.raycastResult.body; + groundObject && numWheelsOnGround++; + wheel.sideImpulse = 0; + wheel.forwardImpulse = 0; + forwardWS[i] || (forwardWS[i] = new Vec3()); + axle[i] || (axle[i] = new Vec3()); + } + for (var i = 0; i < numWheels; i++) { + var wheel = wheelInfos[i]; + var groundObject = wheel.raycastResult.body; + if (groundObject) { + var axlei = axle[i]; + var wheelTrans = this.getWheelTransformWorld(i); + wheelTrans.vectorToWorldFrame(directions[this.indexRightAxis], axlei); + var surfNormalWS = wheel.raycastResult.hitNormalWorld; + var proj = axlei.dot(surfNormalWS); + surfNormalWS.scale(proj, surfNormalWS_scaled_proj); + axlei.vsub(surfNormalWS_scaled_proj, axlei); + axlei.normalize(); + surfNormalWS.cross(axlei, forwardWS[i]); + forwardWS[i].normalize(); + wheel.sideImpulse = resolveSingleBilateral(chassisBody, wheel.raycastResult.hitPointWorld, groundObject, wheel.raycastResult.hitPointWorld, axlei); + wheel.sideImpulse *= sideFrictionStiffness2; + } + } + var sideFactor = 1; + var fwdFactor = .5; + this.sliding = false; + for (var i = 0; i < numWheels; i++) { + var wheel = wheelInfos[i]; + var groundObject = wheel.raycastResult.body; + var rollingFriction = 0; + wheel.slipInfo = 1; + if (groundObject) { + var defaultRollingFrictionImpulse = 0; + var maxImpulse = wheel.brake ? wheel.brake : defaultRollingFrictionImpulse; + rollingFriction = calcRollingFriction(chassisBody, groundObject, wheel.raycastResult.hitPointWorld, forwardWS[i], maxImpulse); + rollingFriction += wheel.engineForce * timeStep; + var factor = maxImpulse / rollingFriction; + wheel.slipInfo *= factor; + } + wheel.forwardImpulse = 0; + wheel.skidInfo = 1; + if (groundObject) { + wheel.skidInfo = 1; + var maximp = wheel.suspensionForce * timeStep * wheel.frictionSlip; + var maximpSide = maximp; + var maximpSquared = maximp * maximpSide; + wheel.forwardImpulse = rollingFriction; + var x = wheel.forwardImpulse * fwdFactor; + var y = wheel.sideImpulse * sideFactor; + var impulseSquared = x * x + y * y; + wheel.sliding = false; + if (impulseSquared > maximpSquared) { + this.sliding = true; + wheel.sliding = true; + var factor = maximp / Math.sqrt(impulseSquared); + wheel.skidInfo *= factor; + } + } + } + if (this.sliding) for (var i = 0; i < numWheels; i++) { + var wheel = wheelInfos[i]; + if (0 !== wheel.sideImpulse && wheel.skidInfo < 1) { + wheel.forwardImpulse *= wheel.skidInfo; + wheel.sideImpulse *= wheel.skidInfo; + } + } + for (var i = 0; i < numWheels; i++) { + var wheel = wheelInfos[i]; + var rel_pos = new Vec3(); + wheel.raycastResult.hitPointWorld.vsub(chassisBody.position, rel_pos); + if (0 !== wheel.forwardImpulse) { + var impulse = new Vec3(); + forwardWS[i].scale(wheel.forwardImpulse, impulse); + chassisBody.applyImpulse(impulse, rel_pos); + } + if (0 !== wheel.sideImpulse) { + var groundObject = wheel.raycastResult.body; + var rel_pos2 = new Vec3(); + wheel.raycastResult.hitPointWorld.vsub(groundObject.position, rel_pos2); + var sideImp = new Vec3(); + axle[i].scale(wheel.sideImpulse, sideImp); + chassisBody.vectorToLocalFrame(rel_pos, rel_pos); + rel_pos["xyz"[this.indexUpAxis]] *= wheel.rollInfluence; + chassisBody.vectorToWorldFrame(rel_pos, rel_pos); + chassisBody.applyImpulse(sideImp, rel_pos); + sideImp.scale(-1, sideImp); + groundObject.applyImpulse(sideImp, rel_pos2); + } + } + }; + var calcRollingFriction_vel1 = new Vec3(); + var calcRollingFriction_vel2 = new Vec3(); + var calcRollingFriction_vel = new Vec3(); + function calcRollingFriction(body0, body1, frictionPosWorld, frictionDirectionWorld, maxImpulse) { + var j1 = 0; + var contactPosWorld = frictionPosWorld; + var vel1 = calcRollingFriction_vel1; + var vel2 = calcRollingFriction_vel2; + var vel = calcRollingFriction_vel; + body0.getVelocityAtWorldPoint(contactPosWorld, vel1); + body1.getVelocityAtWorldPoint(contactPosWorld, vel2); + vel1.vsub(vel2, vel); + var vrel = frictionDirectionWorld.dot(vel); + var denom0 = computeImpulseDenominator(body0, frictionPosWorld, frictionDirectionWorld); + var denom1 = computeImpulseDenominator(body1, frictionPosWorld, frictionDirectionWorld); + var relaxation = 1; + var jacDiagABInv = relaxation / (denom0 + denom1); + j1 = -vrel * jacDiagABInv; + maxImpulse < j1 && (j1 = maxImpulse); + j1 < -maxImpulse && (j1 = -maxImpulse); + return j1; + } + var computeImpulseDenominator_r0 = new Vec3(); + var computeImpulseDenominator_c0 = new Vec3(); + var computeImpulseDenominator_vec = new Vec3(); + var computeImpulseDenominator_m = new Vec3(); + function computeImpulseDenominator(body, pos, normal) { + var r0 = computeImpulseDenominator_r0; + var c0 = computeImpulseDenominator_c0; + var vec = computeImpulseDenominator_vec; + var m = computeImpulseDenominator_m; + pos.vsub(body.position, r0); + r0.cross(normal, c0); + body.invInertiaWorld.vmult(c0, m); + m.cross(r0, vec); + return body.invMass + normal.dot(vec); + } + var resolveSingleBilateral_vel1 = new Vec3(); + var resolveSingleBilateral_vel2 = new Vec3(); + var resolveSingleBilateral_vel = new Vec3(); + function resolveSingleBilateral(body1, pos1, body2, pos2, normal, impulse) { + var normalLenSqr = normal.norm2(); + if (normalLenSqr > 1.1) return 0; + var vel1 = resolveSingleBilateral_vel1; + var vel2 = resolveSingleBilateral_vel2; + var vel = resolveSingleBilateral_vel; + body1.getVelocityAtWorldPoint(pos1, vel1); + body2.getVelocityAtWorldPoint(pos2, vel2); + vel1.vsub(vel2, vel); + var rel_vel = normal.dot(vel); + var contactDamping = .2; + var massTerm = 1 / (body1.invMass + body2.invMass); + var impulse = -contactDamping * rel_vel * massTerm; + return impulse; + } + }, { + "../collision/Ray": 10, + "../collision/RaycastResult": 11, + "../math/Quaternion": 30, + "../math/Vec3": 32, + "../objects/WheelInfo": 38, + "./Body": 33 + } ], + 35: [ function(_dereq_, module, exports) { + var Body = _dereq_("./Body"); + var Sphere = _dereq_("../shapes/Sphere"); + var Box = _dereq_("../shapes/Box"); + var Vec3 = _dereq_("../math/Vec3"); + var HingeConstraint = _dereq_("../constraints/HingeConstraint"); + var CMath = _dereq_("../math/CMath"); + module.exports = RigidVehicle; + function RigidVehicle(options) { + this.wheelBodies = []; + this.coordinateSystem = "undefined" === typeof options.coordinateSystem ? new Vec3(1, 2, 3) : options.coordinateSystem.clone(); + this.chassisBody = options.chassisBody; + if (!this.chassisBody) { + var chassisShape = new Box(new Vec3(5, 2, .5)); + this.chassisBody = new Body(1, chassisShape); + } + this.constraints = []; + this.wheelAxes = []; + this.wheelForces = []; + } + RigidVehicle.prototype.addWheel = function(options) { + options = options || {}; + var wheelBody = options.body; + wheelBody || (wheelBody = new Body(1, new Sphere(1.2))); + this.wheelBodies.push(wheelBody); + this.wheelForces.push(0); + var zero = new Vec3(); + var position = "undefined" !== typeof options.position ? options.position.clone() : new Vec3(); + var worldPosition = new Vec3(); + this.chassisBody.pointToWorldFrame(position, worldPosition); + wheelBody.position.set(worldPosition.x, worldPosition.y, worldPosition.z); + var axis = "undefined" !== typeof options.axis ? options.axis.clone() : new Vec3(0, 1, 0); + this.wheelAxes.push(axis); + var hingeConstraint = new HingeConstraint(this.chassisBody, wheelBody, { + pivotA: position, + axisA: axis, + pivotB: Vec3.ZERO, + axisB: axis, + collideConnected: false + }); + this.constraints.push(hingeConstraint); + return this.wheelBodies.length - 1; + }; + RigidVehicle.prototype.setSteeringValue = function(value, wheelIndex) { + var axis = this.wheelAxes[wheelIndex]; + var c = CMath.cos(value), s = CMath.sin(value), x = axis.x, y = axis.y; + this.constraints[wheelIndex].axisA.set(c * x - s * y, s * x + c * y, 0); + }; + RigidVehicle.prototype.setMotorSpeed = function(value, wheelIndex) { + var hingeConstraint = this.constraints[wheelIndex]; + hingeConstraint.enableMotor(); + hingeConstraint.motorTargetVelocity = value; + }; + RigidVehicle.prototype.disableMotor = function(wheelIndex) { + var hingeConstraint = this.constraints[wheelIndex]; + hingeConstraint.disableMotor(); + }; + var torque = new Vec3(); + RigidVehicle.prototype.setWheelForce = function(value, wheelIndex) { + this.wheelForces[wheelIndex] = value; + }; + RigidVehicle.prototype.applyWheelForce = function(value, wheelIndex) { + var axis = this.wheelAxes[wheelIndex]; + var wheelBody = this.wheelBodies[wheelIndex]; + var bodyTorque = wheelBody.torque; + axis.scale(value, torque); + wheelBody.vectorToWorldFrame(torque, torque); + bodyTorque.vadd(torque, bodyTorque); + }; + RigidVehicle.prototype.addToWorld = function(world) { + var constraints = this.constraints; + var bodies = this.wheelBodies.concat([ this.chassisBody ]); + for (var i = 0; i < bodies.length; i++) world.addBody(bodies[i]); + for (var i = 0; i < constraints.length; i++) world.addConstraint(constraints[i]); + world.addEventListener("preStep", this._update.bind(this)); + }; + RigidVehicle.prototype._update = function() { + var wheelForces = this.wheelForces; + for (var i = 0; i < wheelForces.length; i++) this.applyWheelForce(wheelForces[i], i); + }; + RigidVehicle.prototype.removeFromWorld = function(world) { + var constraints = this.constraints; + var bodies = this.wheelBodies.concat([ this.chassisBody ]); + for (var i = 0; i < bodies.length; i++) world.remove(bodies[i]); + for (var i = 0; i < constraints.length; i++) world.removeConstraint(constraints[i]); + }; + var worldAxis = new Vec3(); + RigidVehicle.prototype.getWheelSpeed = function(wheelIndex) { + var axis = this.wheelAxes[wheelIndex]; + var wheelBody = this.wheelBodies[wheelIndex]; + var w = wheelBody.angularVelocity; + this.chassisBody.vectorToWorldFrame(axis, worldAxis); + return w.dot(worldAxis); + }; + }, { + "../constraints/HingeConstraint": 16, + "../math/CMath": 27, + "../math/Vec3": 32, + "../shapes/Box": 39, + "../shapes/Sphere": 46, + "./Body": 33 + } ], + 36: [ function(_dereq_, module, exports) { + module.exports = SPHSystem; + var Shape = _dereq_("../shapes/Shape"); + var Vec3 = _dereq_("../math/Vec3"); + var Quaternion = _dereq_("../math/Quaternion"); + var Particle = _dereq_("../shapes/Particle"); + var Body = _dereq_("../objects/Body"); + var Material = _dereq_("../material/Material"); + function SPHSystem() { + this.particles = []; + this.density = 1; + this.smoothingRadius = 1; + this.speedOfSound = 1; + this.viscosity = .01; + this.eps = 1e-6; + this.pressures = []; + this.densities = []; + this.neighbors = []; + } + SPHSystem.prototype.add = function(particle) { + this.particles.push(particle); + this.neighbors.length < this.particles.length && this.neighbors.push([]); + }; + SPHSystem.prototype.remove = function(particle) { + var idx = this.particles.indexOf(particle); + if (-1 !== idx) { + this.particles.splice(idx, 1); + this.neighbors.length > this.particles.length && this.neighbors.pop(); + } + }; + var SPHSystem_getNeighbors_dist = new Vec3(); + SPHSystem.prototype.getNeighbors = function(particle, neighbors) { + var N = this.particles.length, id = particle.id, R2 = this.smoothingRadius * this.smoothingRadius, dist = SPHSystem_getNeighbors_dist; + for (var i = 0; i !== N; i++) { + var p = this.particles[i]; + p.position.vsub(particle.position, dist); + id !== p.id && dist.norm2() < R2 && neighbors.push(p); + } + }; + var SPHSystem_update_dist = new Vec3(), SPHSystem_update_a_pressure = new Vec3(), SPHSystem_update_a_visc = new Vec3(), SPHSystem_update_gradW = new Vec3(), SPHSystem_update_r_vec = new Vec3(), SPHSystem_update_u = new Vec3(); + SPHSystem.prototype.update = function() { + var N = this.particles.length, dist = SPHSystem_update_dist, cs = this.speedOfSound, eps = this.eps; + for (var i = 0; i !== N; i++) { + var p = this.particles[i]; + var neighbors = this.neighbors[i]; + neighbors.length = 0; + this.getNeighbors(p, neighbors); + neighbors.push(this.particles[i]); + var numNeighbors = neighbors.length; + var sum = 0; + for (var j = 0; j !== numNeighbors; j++) { + p.position.vsub(neighbors[j].position, dist); + var len = dist.norm(); + var weight = this.w(len); + sum += neighbors[j].mass * weight; + } + this.densities[i] = sum; + this.pressures[i] = cs * cs * (this.densities[i] - this.density); + } + var a_pressure = SPHSystem_update_a_pressure; + var a_visc = SPHSystem_update_a_visc; + var gradW = SPHSystem_update_gradW; + var r_vec = SPHSystem_update_r_vec; + var u = SPHSystem_update_u; + for (var i = 0; i !== N; i++) { + var particle = this.particles[i]; + a_pressure.set(0, 0, 0); + a_visc.set(0, 0, 0); + var Pij; + var nabla; + var Vij; + var neighbors = this.neighbors[i]; + var numNeighbors = neighbors.length; + for (var j = 0; j !== numNeighbors; j++) { + var neighbor = neighbors[j]; + particle.position.vsub(neighbor.position, r_vec); + var r = r_vec.norm(); + Pij = -neighbor.mass * (this.pressures[i] / (this.densities[i] * this.densities[i] + eps) + this.pressures[j] / (this.densities[j] * this.densities[j] + eps)); + this.gradw(r_vec, gradW); + gradW.mult(Pij, gradW); + a_pressure.vadd(gradW, a_pressure); + neighbor.velocity.vsub(particle.velocity, u); + u.mult(1 / (1e-4 + this.densities[i] * this.densities[j]) * this.viscosity * neighbor.mass, u); + nabla = this.nablaw(r); + u.mult(nabla, u); + a_visc.vadd(u, a_visc); + } + a_visc.mult(particle.mass, a_visc); + a_pressure.mult(particle.mass, a_pressure); + particle.force.vadd(a_visc, particle.force); + particle.force.vadd(a_pressure, particle.force); + } + }; + SPHSystem.prototype.w = function(r) { + var h = this.smoothingRadius; + return 315 / (64 * Math.PI * Math.pow(h, 9)) * Math.pow(h * h - r * r, 3); + }; + SPHSystem.prototype.gradw = function(rVec, resultVec) { + var r = rVec.norm(), h = this.smoothingRadius; + rVec.mult(945 / (32 * Math.PI * Math.pow(h, 9)) * Math.pow(h * h - r * r, 2), resultVec); + }; + SPHSystem.prototype.nablaw = function(r) { + var h = this.smoothingRadius; + var nabla = 945 / (32 * Math.PI * Math.pow(h, 9)) * (h * h - r * r) * (7 * r * r - 3 * h * h); + return nabla; + }; + }, { + "../material/Material": 26, + "../math/Quaternion": 30, + "../math/Vec3": 32, + "../objects/Body": 33, + "../shapes/Particle": 43, + "../shapes/Shape": 45 + } ], + 37: [ function(_dereq_, module, exports) { + var Vec3 = _dereq_("../math/Vec3"); + module.exports = Spring; + function Spring(bodyA, bodyB, options) { + options = options || {}; + this.restLength = "number" === typeof options.restLength ? options.restLength : 1; + this.stiffness = options.stiffness || 100; + this.damping = options.damping || 1; + this.bodyA = bodyA; + this.bodyB = bodyB; + this.localAnchorA = new Vec3(); + this.localAnchorB = new Vec3(); + options.localAnchorA && this.localAnchorA.copy(options.localAnchorA); + options.localAnchorB && this.localAnchorB.copy(options.localAnchorB); + options.worldAnchorA && this.setWorldAnchorA(options.worldAnchorA); + options.worldAnchorB && this.setWorldAnchorB(options.worldAnchorB); + } + Spring.prototype.setWorldAnchorA = function(worldAnchorA) { + this.bodyA.pointToLocalFrame(worldAnchorA, this.localAnchorA); + }; + Spring.prototype.setWorldAnchorB = function(worldAnchorB) { + this.bodyB.pointToLocalFrame(worldAnchorB, this.localAnchorB); + }; + Spring.prototype.getWorldAnchorA = function(result) { + this.bodyA.pointToWorldFrame(this.localAnchorA, result); + }; + Spring.prototype.getWorldAnchorB = function(result) { + this.bodyB.pointToWorldFrame(this.localAnchorB, result); + }; + var applyForce_r = new Vec3(), applyForce_r_unit = new Vec3(), applyForce_u = new Vec3(), applyForce_f = new Vec3(), applyForce_worldAnchorA = new Vec3(), applyForce_worldAnchorB = new Vec3(), applyForce_ri = new Vec3(), applyForce_rj = new Vec3(), applyForce_ri_x_f = new Vec3(), applyForce_rj_x_f = new Vec3(), applyForce_tmp = new Vec3(); + Spring.prototype.applyForce = function() { + var k = this.stiffness, d = this.damping, l = this.restLength, bodyA = this.bodyA, bodyB = this.bodyB, r = applyForce_r, r_unit = applyForce_r_unit, u = applyForce_u, f = applyForce_f, tmp = applyForce_tmp; + var worldAnchorA = applyForce_worldAnchorA, worldAnchorB = applyForce_worldAnchorB, ri = applyForce_ri, rj = applyForce_rj, ri_x_f = applyForce_ri_x_f, rj_x_f = applyForce_rj_x_f; + this.getWorldAnchorA(worldAnchorA); + this.getWorldAnchorB(worldAnchorB); + worldAnchorA.vsub(bodyA.position, ri); + worldAnchorB.vsub(bodyB.position, rj); + worldAnchorB.vsub(worldAnchorA, r); + var rlen = r.norm(); + r_unit.copy(r); + r_unit.normalize(); + bodyB.velocity.vsub(bodyA.velocity, u); + bodyB.angularVelocity.cross(rj, tmp); + u.vadd(tmp, u); + bodyA.angularVelocity.cross(ri, tmp); + u.vsub(tmp, u); + r_unit.mult(-k * (rlen - l) - d * u.dot(r_unit), f); + bodyA.force.vsub(f, bodyA.force); + bodyB.force.vadd(f, bodyB.force); + ri.cross(f, ri_x_f); + rj.cross(f, rj_x_f); + bodyA.torque.vsub(ri_x_f, bodyA.torque); + bodyB.torque.vadd(rj_x_f, bodyB.torque); + }; + }, { + "../math/Vec3": 32 + } ], + 38: [ function(_dereq_, module, exports) { + var Vec3 = _dereq_("../math/Vec3"); + var Transform = _dereq_("../math/Transform"); + var RaycastResult = _dereq_("../collision/RaycastResult"); + var Utils = _dereq_("../utils/Utils"); + module.exports = WheelInfo; + function WheelInfo(options) { + options = Utils.defaults(options, { + chassisConnectionPointLocal: new Vec3(), + chassisConnectionPointWorld: new Vec3(), + directionLocal: new Vec3(), + directionWorld: new Vec3(), + axleLocal: new Vec3(), + axleWorld: new Vec3(), + suspensionRestLength: 1, + suspensionMaxLength: 2, + radius: 1, + suspensionStiffness: 100, + dampingCompression: 10, + dampingRelaxation: 10, + frictionSlip: 1e4, + steering: 0, + rotation: 0, + deltaRotation: 0, + rollInfluence: .01, + maxSuspensionForce: Number.MAX_VALUE, + isFrontWheel: true, + clippedInvContactDotSuspension: 1, + suspensionRelativeVelocity: 0, + suspensionForce: 0, + skidInfo: 0, + suspensionLength: 0, + maxSuspensionTravel: 1, + useCustomSlidingRotationalSpeed: false, + customSlidingRotationalSpeed: -.1 + }); + this.maxSuspensionTravel = options.maxSuspensionTravel; + this.customSlidingRotationalSpeed = options.customSlidingRotationalSpeed; + this.useCustomSlidingRotationalSpeed = options.useCustomSlidingRotationalSpeed; + this.sliding = false; + this.chassisConnectionPointLocal = options.chassisConnectionPointLocal.clone(); + this.chassisConnectionPointWorld = options.chassisConnectionPointWorld.clone(); + this.directionLocal = options.directionLocal.clone(); + this.directionWorld = options.directionWorld.clone(); + this.axleLocal = options.axleLocal.clone(); + this.axleWorld = options.axleWorld.clone(); + this.suspensionRestLength = options.suspensionRestLength; + this.suspensionMaxLength = options.suspensionMaxLength; + this.radius = options.radius; + this.suspensionStiffness = options.suspensionStiffness; + this.dampingCompression = options.dampingCompression; + this.dampingRelaxation = options.dampingRelaxation; + this.frictionSlip = options.frictionSlip; + this.steering = 0; + this.rotation = 0; + this.deltaRotation = 0; + this.rollInfluence = options.rollInfluence; + this.maxSuspensionForce = options.maxSuspensionForce; + this.engineForce = 0; + this.brake = 0; + this.isFrontWheel = options.isFrontWheel; + this.clippedInvContactDotSuspension = 1; + this.suspensionRelativeVelocity = 0; + this.suspensionForce = 0; + this.skidInfo = 0; + this.suspensionLength = 0; + this.sideImpulse = 0; + this.forwardImpulse = 0; + this.raycastResult = new RaycastResult(); + this.worldTransform = new Transform(); + this.isInContact = false; + } + var chassis_velocity_at_contactPoint = new Vec3(); + var relpos = new Vec3(); + var chassis_velocity_at_contactPoint = new Vec3(); + WheelInfo.prototype.updateWheel = function(chassis) { + var raycastResult = this.raycastResult; + if (this.isInContact) { + var project = raycastResult.hitNormalWorld.dot(raycastResult.directionWorld); + raycastResult.hitPointWorld.vsub(chassis.position, relpos); + chassis.getVelocityAtWorldPoint(relpos, chassis_velocity_at_contactPoint); + var projVel = raycastResult.hitNormalWorld.dot(chassis_velocity_at_contactPoint); + if (project >= -.1) { + this.suspensionRelativeVelocity = 0; + this.clippedInvContactDotSuspension = 10; + } else { + var inv = -1 / project; + this.suspensionRelativeVelocity = projVel * inv; + this.clippedInvContactDotSuspension = inv; + } + } else { + raycastResult.suspensionLength = this.suspensionRestLength; + this.suspensionRelativeVelocity = 0; + raycastResult.directionWorld.scale(-1, raycastResult.hitNormalWorld); + this.clippedInvContactDotSuspension = 1; + } + }; + }, { + "../collision/RaycastResult": 11, + "../math/Transform": 31, + "../math/Vec3": 32, + "../utils/Utils": 55 + } ], + 39: [ function(_dereq_, module, exports) { + module.exports = Box; + var Shape = _dereq_("./Shape"); + var Vec3 = _dereq_("../math/Vec3"); + var ConvexPolyhedron = _dereq_("./ConvexPolyhedron"); + function Box(halfExtents) { + Shape.call(this, { + type: Shape.types.BOX + }); + this.halfExtents = halfExtents; + this.convexPolyhedronRepresentation = null; + this.updateConvexPolyhedronRepresentation(); + this.updateBoundingSphereRadius(); + } + Box.prototype = new Shape(); + Box.prototype.constructor = Box; + Box.prototype.updateConvexPolyhedronRepresentation = function() { + var sx = this.halfExtents.x; + var sy = this.halfExtents.y; + var sz = this.halfExtents.z; + var V = Vec3; + var vertices = [ new V(-sx, -sy, -sz), new V(sx, -sy, -sz), new V(sx, sy, -sz), new V(-sx, sy, -sz), new V(-sx, -sy, sz), new V(sx, -sy, sz), new V(sx, sy, sz), new V(-sx, sy, sz) ]; + var indices = [ [ 3, 2, 1, 0 ], [ 4, 5, 6, 7 ], [ 5, 4, 0, 1 ], [ 2, 3, 7, 6 ], [ 0, 4, 7, 3 ], [ 1, 2, 6, 5 ] ]; + var axes = [ new V(0, 0, 1), new V(0, 1, 0), new V(1, 0, 0) ]; + var h = new ConvexPolyhedron(vertices, indices); + this.convexPolyhedronRepresentation = h; + h.material = this.material; + }; + Box.prototype.calculateLocalInertia = function(mass, target) { + target = target || new Vec3(); + Box.calculateInertia(this.halfExtents, mass, target); + return target; + }; + Box.calculateInertia = function(halfExtents, mass, target) { + var e = halfExtents; + if (e.isZero()) { + target.x = 2 / 12 * mass; + target.y = 2 / 12 * mass; + target.z = 2 / 12 * mass; + } else { + target.x = 1 / 12 * mass * (2 * e.y * 2 * e.y + 2 * e.z * 2 * e.z); + target.y = 1 / 12 * mass * (2 * e.x * 2 * e.x + 2 * e.z * 2 * e.z); + target.z = 1 / 12 * mass * (2 * e.y * 2 * e.y + 2 * e.x * 2 * e.x); + } + }; + Box.prototype.getSideNormals = function(sixTargetVectors, quat) { + var sides = sixTargetVectors; + var ex = this.halfExtents; + sides[0].set(ex.x, 0, 0); + sides[1].set(0, ex.y, 0); + sides[2].set(0, 0, ex.z); + sides[3].set(-ex.x, 0, 0); + sides[4].set(0, -ex.y, 0); + sides[5].set(0, 0, -ex.z); + if (void 0 !== quat) for (var i = 0; i !== sides.length; i++) quat.vmult(sides[i], sides[i]); + return sides; + }; + Box.prototype.volume = function() { + return 8 * this.halfExtents.x * this.halfExtents.y * this.halfExtents.z; + }; + Box.prototype.updateBoundingSphereRadius = function() { + this.boundingSphereRadius = this.halfExtents.norm(); + }; + var worldCornerTempPos = new Vec3(); + var worldCornerTempNeg = new Vec3(); + Box.prototype.forEachWorldCorner = function(pos, quat, callback) { + var e = this.halfExtents; + var corners = [ [ e.x, e.y, e.z ], [ -e.x, e.y, e.z ], [ -e.x, -e.y, e.z ], [ -e.x, -e.y, -e.z ], [ e.x, -e.y, -e.z ], [ e.x, e.y, -e.z ], [ -e.x, e.y, -e.z ], [ e.x, -e.y, e.z ] ]; + for (var i = 0; i < corners.length; i++) { + worldCornerTempPos.set(corners[i][0], corners[i][1], corners[i][2]); + quat.vmult(worldCornerTempPos, worldCornerTempPos); + pos.vadd(worldCornerTempPos, worldCornerTempPos); + callback(worldCornerTempPos.x, worldCornerTempPos.y, worldCornerTempPos.z); + } + }; + var worldCornersTemp = [ new Vec3(), new Vec3(), new Vec3(), new Vec3(), new Vec3(), new Vec3(), new Vec3(), new Vec3() ]; + Box.prototype.calculateWorldAABB = function(pos, quat, min, max) { + var e = this.halfExtents; + worldCornersTemp[0].set(e.x, e.y, e.z); + worldCornersTemp[1].set(-e.x, e.y, e.z); + worldCornersTemp[2].set(-e.x, -e.y, e.z); + worldCornersTemp[3].set(-e.x, -e.y, -e.z); + worldCornersTemp[4].set(e.x, -e.y, -e.z); + worldCornersTemp[5].set(e.x, e.y, -e.z); + worldCornersTemp[6].set(-e.x, e.y, -e.z); + worldCornersTemp[7].set(e.x, -e.y, e.z); + var wc = worldCornersTemp[0]; + quat.vmult(wc, wc); + pos.vadd(wc, wc); + max.copy(wc); + min.copy(wc); + for (var i = 1; i < 8; i++) { + var wc = worldCornersTemp[i]; + quat.vmult(wc, wc); + pos.vadd(wc, wc); + var x = wc.x; + var y = wc.y; + var z = wc.z; + x > max.x && (max.x = x); + y > max.y && (max.y = y); + z > max.z && (max.z = z); + x < min.x && (min.x = x); + y < min.y && (min.y = y); + z < min.z && (min.z = z); + } + }; + }, { + "../math/Vec3": 32, + "./ConvexPolyhedron": 40, + "./Shape": 45 + } ], + 40: [ function(_dereq_, module, exports) { + module.exports = ConvexPolyhedron; + var Shape = _dereq_("./Shape"); + var Vec3 = _dereq_("../math/Vec3"); + var Quaternion = _dereq_("../math/Quaternion"); + var Transform = _dereq_("../math/Transform"); + function ConvexPolyhedron(points, faces, uniqueAxes) { + Shape.call(this, { + type: Shape.types.CONVEXPOLYHEDRON + }); + this.vertices = points || []; + this.worldVertices = []; + this.worldVerticesNeedsUpdate = true; + this.faces = faces || []; + this.faceNormals = []; + this.computeNormals(); + this.worldFaceNormalsNeedsUpdate = true; + this.worldFaceNormals = []; + this.uniqueEdges = []; + this.uniqueAxes = uniqueAxes ? uniqueAxes.slice() : null; + this.computeEdges(); + this.updateBoundingSphereRadius(); + } + ConvexPolyhedron.prototype = new Shape(); + ConvexPolyhedron.prototype.constructor = ConvexPolyhedron; + var computeEdges_tmpEdge = new Vec3(); + ConvexPolyhedron.prototype.computeEdges = function() { + var faces = this.faces; + var vertices = this.vertices; + var nv = vertices.length; + var edges = this.uniqueEdges; + edges.length = 0; + var edge = computeEdges_tmpEdge; + for (var i = 0; i !== faces.length; i++) { + var face = faces[i]; + var numVertices = face.length; + for (var j = 0; j !== numVertices; j++) { + var k = (j + 1) % numVertices; + vertices[face[j]].vsub(vertices[face[k]], edge); + edge.normalize(); + var found = false; + for (var p = 0; p !== edges.length; p++) if (edges[p].almostEquals(edge) || edges[p].almostEquals(edge)) { + found = true; + break; + } + found || edges.push(edge.clone()); + } + } + }; + ConvexPolyhedron.prototype.computeNormals = function() { + this.faceNormals.length = this.faces.length; + for (var i = 0; i < this.faces.length; i++) { + for (var j = 0; j < this.faces[i].length; j++) if (!this.vertices[this.faces[i][j]]) throw new Error("Vertex " + this.faces[i][j] + " not found!"); + var n = this.faceNormals[i] || new Vec3(); + this.getFaceNormal(i, n); + n.negate(n); + this.faceNormals[i] = n; + var vertex = this.vertices[this.faces[i][0]]; + if (n.dot(vertex) < 0) { + console.error(".faceNormals[" + i + "] = Vec3(" + n.toString() + ") looks like it points into the shape? The vertices follow. Make sure they are ordered CCW around the normal, using the right hand rule."); + for (var j = 0; j < this.faces[i].length; j++) console.warn(".vertices[" + this.faces[i][j] + "] = Vec3(" + this.vertices[this.faces[i][j]].toString() + ")"); + } + } + }; + var cb = new Vec3(); + var ab = new Vec3(); + ConvexPolyhedron.computeNormal = function(va, vb, vc, target) { + vb.vsub(va, ab); + vc.vsub(vb, cb); + cb.cross(ab, target); + target.isZero() || target.normalize(); + }; + ConvexPolyhedron.prototype.getFaceNormal = function(i, target) { + var f = this.faces[i]; + var va = this.vertices[f[0]]; + var vb = this.vertices[f[1]]; + var vc = this.vertices[f[2]]; + return ConvexPolyhedron.computeNormal(va, vb, vc, target); + }; + var cah_WorldNormal = new Vec3(); + ConvexPolyhedron.prototype.clipAgainstHull = function(posA, quatA, hullB, posB, quatB, separatingNormal, minDist, maxDist, result) { + var WorldNormal = cah_WorldNormal; + var hullA = this; + var curMaxDist = maxDist; + var closestFaceB = -1; + var dmax = -Number.MAX_VALUE; + for (var face = 0; face < hullB.faces.length; face++) { + WorldNormal.copy(hullB.faceNormals[face]); + quatB.vmult(WorldNormal, WorldNormal); + var d = WorldNormal.dot(separatingNormal); + if (d > dmax) { + dmax = d; + closestFaceB = face; + } + } + var worldVertsB1 = []; + var polyB = hullB.faces[closestFaceB]; + var numVertices = polyB.length; + for (var e0 = 0; e0 < numVertices; e0++) { + var b = hullB.vertices[polyB[e0]]; + var worldb = new Vec3(); + worldb.copy(b); + quatB.vmult(worldb, worldb); + posB.vadd(worldb, worldb); + worldVertsB1.push(worldb); + } + closestFaceB >= 0 && this.clipFaceAgainstHull(separatingNormal, posA, quatA, worldVertsB1, minDist, maxDist, result); + }; + var fsa_faceANormalWS3 = new Vec3(), fsa_Worldnormal1 = new Vec3(), fsa_deltaC = new Vec3(), fsa_worldEdge0 = new Vec3(), fsa_worldEdge1 = new Vec3(), fsa_Cross = new Vec3(); + ConvexPolyhedron.prototype.findSeparatingAxis = function(hullB, posA, quatA, posB, quatB, target, faceListA, faceListB) { + var faceANormalWS3 = fsa_faceANormalWS3, Worldnormal1 = fsa_Worldnormal1, deltaC = fsa_deltaC, worldEdge0 = fsa_worldEdge0, worldEdge1 = fsa_worldEdge1, Cross = fsa_Cross; + var dmin = Number.MAX_VALUE; + var hullA = this; + var curPlaneTests = 0; + if (hullA.uniqueAxes) for (var i = 0; i !== hullA.uniqueAxes.length; i++) { + quatA.vmult(hullA.uniqueAxes[i], faceANormalWS3); + var d = hullA.testSepAxis(faceANormalWS3, hullB, posA, quatA, posB, quatB); + if (false === d) return false; + if (d < dmin) { + dmin = d; + target.copy(faceANormalWS3); + } + } else { + var numFacesA = faceListA ? faceListA.length : hullA.faces.length; + for (var i = 0; i < numFacesA; i++) { + var fi = faceListA ? faceListA[i] : i; + faceANormalWS3.copy(hullA.faceNormals[fi]); + quatA.vmult(faceANormalWS3, faceANormalWS3); + var d = hullA.testSepAxis(faceANormalWS3, hullB, posA, quatA, posB, quatB); + if (false === d) return false; + if (d < dmin) { + dmin = d; + target.copy(faceANormalWS3); + } + } + } + if (hullB.uniqueAxes) for (var i = 0; i !== hullB.uniqueAxes.length; i++) { + quatB.vmult(hullB.uniqueAxes[i], Worldnormal1); + curPlaneTests++; + var d = hullA.testSepAxis(Worldnormal1, hullB, posA, quatA, posB, quatB); + if (false === d) return false; + if (d < dmin) { + dmin = d; + target.copy(Worldnormal1); + } + } else { + var numFacesB = faceListB ? faceListB.length : hullB.faces.length; + for (var i = 0; i < numFacesB; i++) { + var fi = faceListB ? faceListB[i] : i; + Worldnormal1.copy(hullB.faceNormals[fi]); + quatB.vmult(Worldnormal1, Worldnormal1); + curPlaneTests++; + var d = hullA.testSepAxis(Worldnormal1, hullB, posA, quatA, posB, quatB); + if (false === d) return false; + if (d < dmin) { + dmin = d; + target.copy(Worldnormal1); + } + } + } + for (var e0 = 0; e0 !== hullA.uniqueEdges.length; e0++) { + quatA.vmult(hullA.uniqueEdges[e0], worldEdge0); + for (var e1 = 0; e1 !== hullB.uniqueEdges.length; e1++) { + quatB.vmult(hullB.uniqueEdges[e1], worldEdge1); + worldEdge0.cross(worldEdge1, Cross); + if (!Cross.almostZero()) { + Cross.normalize(); + var dist = hullA.testSepAxis(Cross, hullB, posA, quatA, posB, quatB); + if (false === dist) return false; + if (dist < dmin) { + dmin = dist; + target.copy(Cross); + } + } + } + } + posB.vsub(posA, deltaC); + deltaC.dot(target) > 0 && target.negate(target); + return true; + }; + var maxminA = [], maxminB = []; + ConvexPolyhedron.prototype.testSepAxis = function(axis, hullB, posA, quatA, posB, quatB) { + var hullA = this; + ConvexPolyhedron.project(hullA, axis, posA, quatA, maxminA); + ConvexPolyhedron.project(hullB, axis, posB, quatB, maxminB); + var maxA = maxminA[0]; + var minA = maxminA[1]; + var maxB = maxminB[0]; + var minB = maxminB[1]; + if (maxA < minB || maxB < minA) return false; + var d0 = maxA - minB; + var d1 = maxB - minA; + var depth = d0 < d1 ? d0 : d1; + return depth; + }; + var cli_aabbmin = new Vec3(), cli_aabbmax = new Vec3(); + ConvexPolyhedron.prototype.calculateLocalInertia = function(mass, target) { + this.computeLocalAABB(cli_aabbmin, cli_aabbmax); + var x = cli_aabbmax.x - cli_aabbmin.x, y = cli_aabbmax.y - cli_aabbmin.y, z = cli_aabbmax.z - cli_aabbmin.z; + target.x = 1 / 12 * mass * (2 * y * 2 * y + 2 * z * 2 * z); + target.y = 1 / 12 * mass * (2 * x * 2 * x + 2 * z * 2 * z); + target.z = 1 / 12 * mass * (2 * y * 2 * y + 2 * x * 2 * x); + }; + ConvexPolyhedron.prototype.getPlaneConstantOfFace = function(face_i) { + var f = this.faces[face_i]; + var n = this.faceNormals[face_i]; + var v = this.vertices[f[0]]; + var c = -n.dot(v); + return c; + }; + var cfah_faceANormalWS = new Vec3(), cfah_edge0 = new Vec3(), cfah_WorldEdge0 = new Vec3(), cfah_worldPlaneAnormal1 = new Vec3(), cfah_planeNormalWS1 = new Vec3(), cfah_worldA1 = new Vec3(), cfah_localPlaneNormal = new Vec3(), cfah_planeNormalWS = new Vec3(); + ConvexPolyhedron.prototype.clipFaceAgainstHull = function(separatingNormal, posA, quatA, worldVertsB1, minDist, maxDist, result) { + var faceANormalWS = cfah_faceANormalWS, edge0 = cfah_edge0, WorldEdge0 = cfah_WorldEdge0, worldPlaneAnormal1 = cfah_worldPlaneAnormal1, planeNormalWS1 = cfah_planeNormalWS1, worldA1 = cfah_worldA1, localPlaneNormal = cfah_localPlaneNormal, planeNormalWS = cfah_planeNormalWS; + var hullA = this; + var worldVertsB2 = []; + var pVtxIn = worldVertsB1; + var pVtxOut = worldVertsB2; + var closestFaceA = -1; + var dmin = Number.MAX_VALUE; + for (var face = 0; face < hullA.faces.length; face++) { + faceANormalWS.copy(hullA.faceNormals[face]); + quatA.vmult(faceANormalWS, faceANormalWS); + var d = faceANormalWS.dot(separatingNormal); + if (d < dmin) { + dmin = d; + closestFaceA = face; + } + } + if (closestFaceA < 0) return; + var polyA = hullA.faces[closestFaceA]; + polyA.connectedFaces = []; + for (var i = 0; i < hullA.faces.length; i++) for (var j = 0; j < hullA.faces[i].length; j++) -1 !== polyA.indexOf(hullA.faces[i][j]) && i !== closestFaceA && -1 === polyA.connectedFaces.indexOf(i) && polyA.connectedFaces.push(i); + var numContacts = pVtxIn.length; + var numVerticesA = polyA.length; + var res = []; + for (var e0 = 0; e0 < numVerticesA; e0++) { + var a = hullA.vertices[polyA[e0]]; + var b = hullA.vertices[polyA[(e0 + 1) % numVerticesA]]; + a.vsub(b, edge0); + WorldEdge0.copy(edge0); + quatA.vmult(WorldEdge0, WorldEdge0); + posA.vadd(WorldEdge0, WorldEdge0); + worldPlaneAnormal1.copy(this.faceNormals[closestFaceA]); + quatA.vmult(worldPlaneAnormal1, worldPlaneAnormal1); + posA.vadd(worldPlaneAnormal1, worldPlaneAnormal1); + WorldEdge0.cross(worldPlaneAnormal1, planeNormalWS1); + planeNormalWS1.negate(planeNormalWS1); + worldA1.copy(a); + quatA.vmult(worldA1, worldA1); + posA.vadd(worldA1, worldA1); + var planeEqWS1 = -worldA1.dot(planeNormalWS1); + var planeEqWS; + true; + var otherFace = polyA.connectedFaces[e0]; + localPlaneNormal.copy(this.faceNormals[otherFace]); + var localPlaneEq = this.getPlaneConstantOfFace(otherFace); + planeNormalWS.copy(localPlaneNormal); + quatA.vmult(planeNormalWS, planeNormalWS); + var planeEqWS = localPlaneEq - planeNormalWS.dot(posA); + this.clipFaceAgainstPlane(pVtxIn, pVtxOut, planeNormalWS, planeEqWS); + while (pVtxIn.length) pVtxIn.shift(); + while (pVtxOut.length) pVtxIn.push(pVtxOut.shift()); + } + localPlaneNormal.copy(this.faceNormals[closestFaceA]); + var localPlaneEq = this.getPlaneConstantOfFace(closestFaceA); + planeNormalWS.copy(localPlaneNormal); + quatA.vmult(planeNormalWS, planeNormalWS); + var planeEqWS = localPlaneEq - planeNormalWS.dot(posA); + for (var i = 0; i < pVtxIn.length; i++) { + var depth = planeNormalWS.dot(pVtxIn[i]) + planeEqWS; + depth <= minDist && (depth = minDist); + if (depth <= maxDist) { + var point = pVtxIn[i]; + if (depth <= 0) { + var p = { + point: point, + normal: planeNormalWS, + depth: depth + }; + result.push(p); + } + } + } + }; + ConvexPolyhedron.prototype.clipFaceAgainstPlane = function(inVertices, outVertices, planeNormal, planeConstant) { + var n_dot_first, n_dot_last; + var numVerts = inVertices.length; + if (numVerts < 2) return outVertices; + var firstVertex = inVertices[inVertices.length - 1], lastVertex = inVertices[0]; + n_dot_first = planeNormal.dot(firstVertex) + planeConstant; + for (var vi = 0; vi < numVerts; vi++) { + lastVertex = inVertices[vi]; + n_dot_last = planeNormal.dot(lastVertex) + planeConstant; + if (n_dot_first < 0) if (n_dot_last < 0) { + var newv = new Vec3(); + newv.copy(lastVertex); + outVertices.push(newv); + } else { + var newv = new Vec3(); + firstVertex.lerp(lastVertex, n_dot_first / (n_dot_first - n_dot_last), newv); + outVertices.push(newv); + } else if (n_dot_last < 0) { + var newv = new Vec3(); + firstVertex.lerp(lastVertex, n_dot_first / (n_dot_first - n_dot_last), newv); + outVertices.push(newv); + outVertices.push(lastVertex); + } + firstVertex = lastVertex; + n_dot_first = n_dot_last; + } + return outVertices; + }; + ConvexPolyhedron.prototype.computeWorldVertices = function(position, quat) { + var N = this.vertices.length; + while (this.worldVertices.length < N) this.worldVertices.push(new Vec3()); + var verts = this.vertices, worldVerts = this.worldVertices; + for (var i = 0; i !== N; i++) { + quat.vmult(verts[i], worldVerts[i]); + position.vadd(worldVerts[i], worldVerts[i]); + } + this.worldVerticesNeedsUpdate = false; + }; + var computeLocalAABB_worldVert = new Vec3(); + ConvexPolyhedron.prototype.computeLocalAABB = function(aabbmin, aabbmax) { + var n = this.vertices.length, vertices = this.vertices, worldVert = computeLocalAABB_worldVert; + aabbmin.set(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE); + aabbmax.set(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE); + for (var i = 0; i < n; i++) { + var v = vertices[i]; + v.x < aabbmin.x ? aabbmin.x = v.x : v.x > aabbmax.x && (aabbmax.x = v.x); + v.y < aabbmin.y ? aabbmin.y = v.y : v.y > aabbmax.y && (aabbmax.y = v.y); + v.z < aabbmin.z ? aabbmin.z = v.z : v.z > aabbmax.z && (aabbmax.z = v.z); + } + }; + ConvexPolyhedron.prototype.computeWorldFaceNormals = function(quat) { + var N = this.faceNormals.length; + while (this.worldFaceNormals.length < N) this.worldFaceNormals.push(new Vec3()); + var normals = this.faceNormals, worldNormals = this.worldFaceNormals; + for (var i = 0; i !== N; i++) quat.vmult(normals[i], worldNormals[i]); + this.worldFaceNormalsNeedsUpdate = false; + }; + ConvexPolyhedron.prototype.updateBoundingSphereRadius = function() { + var max2 = 0; + var verts = this.vertices; + for (var i = 0, N = verts.length; i !== N; i++) { + var norm2 = verts[i].norm2(); + norm2 > max2 && (max2 = norm2); + } + this.boundingSphereRadius = Math.sqrt(max2); + }; + var tempWorldVertex = new Vec3(); + ConvexPolyhedron.prototype.calculateWorldAABB = function(pos, quat, min, max) { + var n = this.vertices.length, verts = this.vertices; + var minx, miny, minz, maxx, maxy, maxz; + for (var i = 0; i < n; i++) { + tempWorldVertex.copy(verts[i]); + quat.vmult(tempWorldVertex, tempWorldVertex); + pos.vadd(tempWorldVertex, tempWorldVertex); + var v = tempWorldVertex; + (v.x < minx || void 0 === minx) && (minx = v.x); + (v.x > maxx || void 0 === maxx) && (maxx = v.x); + (v.y < miny || void 0 === miny) && (miny = v.y); + (v.y > maxy || void 0 === maxy) && (maxy = v.y); + (v.z < minz || void 0 === minz) && (minz = v.z); + (v.z > maxz || void 0 === maxz) && (maxz = v.z); + } + min.set(minx, miny, minz); + max.set(maxx, maxy, maxz); + }; + ConvexPolyhedron.prototype.volume = function() { + return 4 * Math.PI * this.boundingSphereRadius / 3; + }; + ConvexPolyhedron.prototype.getAveragePointLocal = function(target) { + target = target || new Vec3(); + var n = this.vertices.length, verts = this.vertices; + for (var i = 0; i < n; i++) target.vadd(verts[i], target); + target.mult(1 / n, target); + return target; + }; + ConvexPolyhedron.prototype.transformAllPoints = function(offset, quat) { + var n = this.vertices.length, verts = this.vertices; + if (quat) { + for (var i = 0; i < n; i++) { + var v = verts[i]; + quat.vmult(v, v); + } + for (var i = 0; i < this.faceNormals.length; i++) { + var v = this.faceNormals[i]; + quat.vmult(v, v); + } + } + if (offset) for (var i = 0; i < n; i++) { + var v = verts[i]; + v.vadd(offset, v); + } + }; + var ConvexPolyhedron_pointIsInside = new Vec3(); + var ConvexPolyhedron_vToP = new Vec3(); + var ConvexPolyhedron_vToPointInside = new Vec3(); + ConvexPolyhedron.prototype.pointIsInside = function(p) { + var n = this.vertices.length, verts = this.vertices, faces = this.faces, normals = this.faceNormals; + var positiveResult = null; + var N = this.faces.length; + var pointInside = ConvexPolyhedron_pointIsInside; + this.getAveragePointLocal(pointInside); + for (var i = 0; i < N; i++) { + var numVertices = this.faces[i].length; + var n = normals[i]; + var v = verts[faces[i][0]]; + var vToP = ConvexPolyhedron_vToP; + p.vsub(v, vToP); + var r1 = n.dot(vToP); + var vToPointInside = ConvexPolyhedron_vToPointInside; + pointInside.vsub(v, vToPointInside); + var r2 = n.dot(vToPointInside); + if (r1 < 0 && r2 > 0 || r1 > 0 && r2 < 0) return false; + } + return positiveResult ? 1 : -1; + }; + var project_worldVertex = new Vec3(); + var project_localAxis = new Vec3(); + var project_localOrigin = new Vec3(); + ConvexPolyhedron.project = function(hull, axis, pos, quat, result) { + var n = hull.vertices.length, worldVertex = project_worldVertex, localAxis = project_localAxis, max = 0, min = 0, localOrigin = project_localOrigin, vs = hull.vertices; + localOrigin.setZero(); + Transform.vectorToLocalFrame(pos, quat, axis, localAxis); + Transform.pointToLocalFrame(pos, quat, localOrigin, localOrigin); + var add = localOrigin.dot(localAxis); + min = max = vs[0].dot(localAxis); + for (var i = 1; i < n; i++) { + var val = vs[i].dot(localAxis); + val > max && (max = val); + val < min && (min = val); + } + min -= add; + max -= add; + if (min > max) { + var temp = min; + min = max; + max = temp; + } + result[0] = max; + result[1] = min; + }; + }, { + "../math/Quaternion": 30, + "../math/Transform": 31, + "../math/Vec3": 32, + "./Shape": 45 + } ], + 41: [ function(_dereq_, module, exports) { + module.exports = Cylinder; + var Shape = _dereq_("./Shape"); + var Vec3 = _dereq_("../math/Vec3"); + var Quaternion = _dereq_("../math/Quaternion"); + var ConvexPolyhedron = _dereq_("./ConvexPolyhedron"); + var CMath = _dereq_("../math/CMath"); + function Cylinder(radiusTop, radiusBottom, height, numSegments, isDirY) { + if (isDirY) { + var N = numSegments, cos = CMath.cos, sin = CMath.sin; + var halfH = height / 2; + var vertices = []; + var indices = []; + var tf = [ 0 ]; + var bf = [ 1 ]; + var axes = []; + var theta = 2 * Math.PI / N; + for (var i = 0; i < N; i++) { + vertices.push(new Vec3(radiusTop * cos(theta * i), halfH, radiusTop * sin(theta * i))); + vertices.push(new Vec3(radiusTop * cos(theta * i), -halfH, radiusTop * sin(theta * i))); + if (i < N - 1) { + indices.push([ 2 * i + 2, 2 * i + 3, 2 * i + 1, 2 * i ]); + tf.push(2 * i + 2); + bf.push(2 * i + 3); + } else indices.push([ 0, 1, 2 * i + 1, 2 * i ]); + (N % 2 === 1 || i < N / 2) && axes.push(new Vec3(cos(theta * (i + .5)), 0, sin(theta * (i + .5)))); + } + indices.push(bf); + var temp = []; + for (var i = 0; i < tf.length; i++) temp.push(tf[tf.length - i - 1]); + indices.push(temp); + axes.push(new Vec3(0, 1, 0)); + ConvexPolyhedron.call(this, vertices, indices, axes); + return; + } + var N = numSegments, verts = [], axes = [], faces = [], bottomface = [], topface = [], cos = CMath.cos, sin = CMath.sin; + verts.push(new Vec3(radiusBottom * cos(0), radiusBottom * sin(0), .5 * -height)); + bottomface.push(0); + verts.push(new Vec3(radiusTop * cos(0), radiusTop * sin(0), .5 * height)); + topface.push(1); + for (var i = 0; i < N; i++) { + var theta = 2 * Math.PI / N * (i + 1); + var thetaN = 2 * Math.PI / N * (i + .5); + if (i < N - 1) { + verts.push(new Vec3(radiusBottom * cos(theta), radiusBottom * sin(theta), .5 * -height)); + bottomface.push(2 * i + 2); + verts.push(new Vec3(radiusTop * cos(theta), radiusTop * sin(theta), .5 * height)); + topface.push(2 * i + 3); + faces.push([ 2 * i + 2, 2 * i + 3, 2 * i + 1, 2 * i ]); + } else faces.push([ 0, 1, 2 * i + 1, 2 * i ]); + (N % 2 === 1 || i < N / 2) && axes.push(new Vec3(cos(thetaN), sin(thetaN), 0)); + } + faces.push(topface); + axes.push(new Vec3(0, 0, 1)); + var temp = []; + for (var i = 0; i < bottomface.length; i++) temp.push(bottomface[bottomface.length - i - 1]); + faces.push(temp); + ConvexPolyhedron.call(this, verts, faces, axes); + } + Cylinder.prototype = new ConvexPolyhedron(); + }, { + "../math/CMath": 27, + "../math/Quaternion": 30, + "../math/Vec3": 32, + "./ConvexPolyhedron": 40, + "./Shape": 45 + } ], + 42: [ function(_dereq_, module, exports) { + var Shape = _dereq_("./Shape"); + var ConvexPolyhedron = _dereq_("./ConvexPolyhedron"); + var Vec3 = _dereq_("../math/Vec3"); + var Utils = _dereq_("../utils/Utils"); + module.exports = Heightfield; + function Heightfield(data, options) { + options = Utils.defaults(options, { + maxValue: null, + minValue: null, + elementSize: 1 + }); + this.data = data; + this.maxValue = options.maxValue; + this.minValue = options.minValue; + this.elementSize = options.elementSize; + null === options.minValue && this.updateMinValue(); + null === options.maxValue && this.updateMaxValue(); + this.cacheEnabled = true; + Shape.call(this, { + type: Shape.types.HEIGHTFIELD + }); + this.pillarConvex = new ConvexPolyhedron(); + this.pillarOffset = new Vec3(); + this.updateBoundingSphereRadius(); + this._cachedPillars = {}; + } + Heightfield.prototype = new Shape(); + Heightfield.prototype.update = function() { + this._cachedPillars = {}; + }; + Heightfield.prototype.updateMinValue = function() { + var data = this.data; + var minValue = data[0][0]; + for (var i = 0; i !== data.length; i++) for (var j = 0; j !== data[i].length; j++) { + var v = data[i][j]; + v < minValue && (minValue = v); + } + this.minValue = minValue; + }; + Heightfield.prototype.updateMaxValue = function() { + var data = this.data; + var maxValue = data[0][0]; + for (var i = 0; i !== data.length; i++) for (var j = 0; j !== data[i].length; j++) { + var v = data[i][j]; + v > maxValue && (maxValue = v); + } + this.maxValue = maxValue; + }; + Heightfield.prototype.setHeightValueAtIndex = function(xi, yi, value) { + var data = this.data; + data[xi][yi] = value; + this.clearCachedConvexTrianglePillar(xi, yi, false); + if (xi > 0) { + this.clearCachedConvexTrianglePillar(xi - 1, yi, true); + this.clearCachedConvexTrianglePillar(xi - 1, yi, false); + } + if (yi > 0) { + this.clearCachedConvexTrianglePillar(xi, yi - 1, true); + this.clearCachedConvexTrianglePillar(xi, yi - 1, false); + } + yi > 0 && xi > 0 && this.clearCachedConvexTrianglePillar(xi - 1, yi - 1, true); + }; + Heightfield.prototype.getRectMinMax = function(iMinX, iMinY, iMaxX, iMaxY, result) { + result = result || []; + var data = this.data, max = this.minValue; + for (var i = iMinX; i <= iMaxX; i++) for (var j = iMinY; j <= iMaxY; j++) { + var height = data[i][j]; + height > max && (max = height); + } + result[0] = this.minValue; + result[1] = max; + }; + Heightfield.prototype.getIndexOfPosition = function(x, y, result, clamp) { + var w = this.elementSize; + var data = this.data; + var xi = Math.floor(x / w); + var yi = Math.floor(y / w); + result[0] = xi; + result[1] = yi; + if (clamp) { + xi < 0 && (xi = 0); + yi < 0 && (yi = 0); + xi >= data.length - 1 && (xi = data.length - 1); + yi >= data[0].length - 1 && (yi = data[0].length - 1); + } + if (xi < 0 || yi < 0 || xi >= data.length - 1 || yi >= data[0].length - 1) return false; + return true; + }; + var getHeightAt_idx = []; + var getHeightAt_weights = new Vec3(); + var getHeightAt_a = new Vec3(); + var getHeightAt_b = new Vec3(); + var getHeightAt_c = new Vec3(); + Heightfield.prototype.getTriangleAt = function(x, y, edgeClamp, a, b, c) { + var idx = getHeightAt_idx; + this.getIndexOfPosition(x, y, idx, edgeClamp); + var xi = idx[0]; + var yi = idx[1]; + var data = this.data; + if (edgeClamp) { + xi = Math.min(data.length - 2, Math.max(0, xi)); + yi = Math.min(data[0].length - 2, Math.max(0, yi)); + } + var elementSize = this.elementSize; + var lowerDist2 = Math.pow(x / elementSize - xi, 2) + Math.pow(y / elementSize - yi, 2); + var upperDist2 = Math.pow(x / elementSize - (xi + 1), 2) + Math.pow(y / elementSize - (yi + 1), 2); + var upper = lowerDist2 > upperDist2; + this.getTriangle(xi, yi, upper, a, b, c); + return upper; + }; + var getNormalAt_a = new Vec3(); + var getNormalAt_b = new Vec3(); + var getNormalAt_c = new Vec3(); + var getNormalAt_e0 = new Vec3(); + var getNormalAt_e1 = new Vec3(); + Heightfield.prototype.getNormalAt = function(x, y, edgeClamp, result) { + var a = getNormalAt_a; + var b = getNormalAt_b; + var c = getNormalAt_c; + var e0 = getNormalAt_e0; + var e1 = getNormalAt_e1; + this.getTriangleAt(x, y, edgeClamp, a, b, c); + b.vsub(a, e0); + c.vsub(a, e1); + e0.cross(e1, result); + result.normalize(); + }; + Heightfield.prototype.getAabbAtIndex = function(xi, yi, result) { + var data = this.data; + var elementSize = this.elementSize; + result.lowerBound.set(xi * elementSize, yi * elementSize, data[xi][yi]); + result.upperBound.set((xi + 1) * elementSize, (yi + 1) * elementSize, data[xi + 1][yi + 1]); + }; + Heightfield.prototype.getHeightAt = function(x, y, edgeClamp) { + var data = this.data; + var a = getHeightAt_a; + var b = getHeightAt_b; + var c = getHeightAt_c; + var idx = getHeightAt_idx; + this.getIndexOfPosition(x, y, idx, edgeClamp); + var xi = idx[0]; + var yi = idx[1]; + if (edgeClamp) { + xi = Math.min(data.length - 2, Math.max(0, xi)); + yi = Math.min(data[0].length - 2, Math.max(0, yi)); + } + var upper = this.getTriangleAt(x, y, edgeClamp, a, b, c); + barycentricWeights(x, y, a.x, a.y, b.x, b.y, c.x, c.y, getHeightAt_weights); + var w = getHeightAt_weights; + return upper ? data[xi + 1][yi + 1] * w.x + data[xi][yi + 1] * w.y + data[xi + 1][yi] * w.z : data[xi][yi] * w.x + data[xi + 1][yi] * w.y + data[xi][yi + 1] * w.z; + }; + function barycentricWeights(x, y, ax, ay, bx, by, cx, cy, result) { + result.x = ((by - cy) * (x - cx) + (cx - bx) * (y - cy)) / ((by - cy) * (ax - cx) + (cx - bx) * (ay - cy)); + result.y = ((cy - ay) * (x - cx) + (ax - cx) * (y - cy)) / ((by - cy) * (ax - cx) + (cx - bx) * (ay - cy)); + result.z = 1 - result.x - result.y; + } + Heightfield.prototype.getCacheConvexTrianglePillarKey = function(xi, yi, getUpperTriangle) { + return xi + "_" + yi + "_" + (getUpperTriangle ? 1 : 0); + }; + Heightfield.prototype.getCachedConvexTrianglePillar = function(xi, yi, getUpperTriangle) { + return this._cachedPillars[this.getCacheConvexTrianglePillarKey(xi, yi, getUpperTriangle)]; + }; + Heightfield.prototype.setCachedConvexTrianglePillar = function(xi, yi, getUpperTriangle, convex, offset) { + this._cachedPillars[this.getCacheConvexTrianglePillarKey(xi, yi, getUpperTriangle)] = { + convex: convex, + offset: offset + }; + }; + Heightfield.prototype.clearCachedConvexTrianglePillar = function(xi, yi, getUpperTriangle) { + delete this._cachedPillars[this.getCacheConvexTrianglePillarKey(xi, yi, getUpperTriangle)]; + }; + Heightfield.prototype.getTriangle = function(xi, yi, upper, a, b, c) { + var data = this.data; + var elementSize = this.elementSize; + if (upper) { + a.set((xi + 1) * elementSize, (yi + 1) * elementSize, data[xi + 1][yi + 1]); + b.set(xi * elementSize, (yi + 1) * elementSize, data[xi][yi + 1]); + c.set((xi + 1) * elementSize, yi * elementSize, data[xi + 1][yi]); + } else { + a.set(xi * elementSize, yi * elementSize, data[xi][yi]); + b.set((xi + 1) * elementSize, yi * elementSize, data[xi + 1][yi]); + c.set(xi * elementSize, (yi + 1) * elementSize, data[xi][yi + 1]); + } + }; + Heightfield.prototype.getConvexTrianglePillar = function(xi, yi, getUpperTriangle) { + var result = this.pillarConvex; + var offsetResult = this.pillarOffset; + if (this.cacheEnabled) { + var data = this.getCachedConvexTrianglePillar(xi, yi, getUpperTriangle); + if (data) { + this.pillarConvex = data.convex; + this.pillarOffset = data.offset; + return; + } + result = new ConvexPolyhedron(); + offsetResult = new Vec3(); + this.pillarConvex = result; + this.pillarOffset = offsetResult; + } + var data = this.data; + var elementSize = this.elementSize; + var faces = result.faces; + result.vertices.length = 6; + for (var i = 0; i < 6; i++) result.vertices[i] || (result.vertices[i] = new Vec3()); + faces.length = 5; + for (var i = 0; i < 5; i++) faces[i] || (faces[i] = []); + var verts = result.vertices; + var h = (Math.min(data[xi][yi], data[xi + 1][yi], data[xi][yi + 1], data[xi + 1][yi + 1]) - this.minValue) / 2 + this.minValue; + if (getUpperTriangle) { + offsetResult.set((xi + .75) * elementSize, (yi + .75) * elementSize, h); + verts[0].set(.25 * elementSize, .25 * elementSize, data[xi + 1][yi + 1] - h); + verts[1].set(-.75 * elementSize, .25 * elementSize, data[xi][yi + 1] - h); + verts[2].set(.25 * elementSize, -.75 * elementSize, data[xi + 1][yi] - h); + verts[3].set(.25 * elementSize, .25 * elementSize, -h - 1); + verts[4].set(-.75 * elementSize, .25 * elementSize, -h - 1); + verts[5].set(.25 * elementSize, -.75 * elementSize, -h - 1); + faces[0][0] = 0; + faces[0][1] = 1; + faces[0][2] = 2; + faces[1][0] = 5; + faces[1][1] = 4; + faces[1][2] = 3; + faces[2][0] = 2; + faces[2][1] = 5; + faces[2][2] = 3; + faces[2][3] = 0; + faces[3][0] = 3; + faces[3][1] = 4; + faces[3][2] = 1; + faces[3][3] = 0; + faces[4][0] = 1; + faces[4][1] = 4; + faces[4][2] = 5; + faces[4][3] = 2; + } else { + offsetResult.set((xi + .25) * elementSize, (yi + .25) * elementSize, h); + verts[0].set(-.25 * elementSize, -.25 * elementSize, data[xi][yi] - h); + verts[1].set(.75 * elementSize, -.25 * elementSize, data[xi + 1][yi] - h); + verts[2].set(-.25 * elementSize, .75 * elementSize, data[xi][yi + 1] - h); + verts[3].set(-.25 * elementSize, -.25 * elementSize, -h - 1); + verts[4].set(.75 * elementSize, -.25 * elementSize, -h - 1); + verts[5].set(-.25 * elementSize, .75 * elementSize, -h - 1); + faces[0][0] = 0; + faces[0][1] = 1; + faces[0][2] = 2; + faces[1][0] = 5; + faces[1][1] = 4; + faces[1][2] = 3; + faces[2][0] = 0; + faces[2][1] = 2; + faces[2][2] = 5; + faces[2][3] = 3; + faces[3][0] = 1; + faces[3][1] = 0; + faces[3][2] = 3; + faces[3][3] = 4; + faces[4][0] = 4; + faces[4][1] = 5; + faces[4][2] = 2; + faces[4][3] = 1; + } + result.computeNormals(); + result.computeEdges(); + result.updateBoundingSphereRadius(); + this.setCachedConvexTrianglePillar(xi, yi, getUpperTriangle, result, offsetResult); + }; + Heightfield.prototype.calculateLocalInertia = function(mass, target) { + target = target || new Vec3(); + target.set(0, 0, 0); + return target; + }; + Heightfield.prototype.volume = function() { + return Number.MAX_VALUE; + }; + Heightfield.prototype.calculateWorldAABB = function(pos, quat, min, max) { + min.set(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE); + max.set(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE); + }; + Heightfield.prototype.updateBoundingSphereRadius = function() { + var data = this.data, s = this.elementSize; + this.boundingSphereRadius = new Vec3(data.length * s, data[0].length * s, Math.max(Math.abs(this.maxValue), Math.abs(this.minValue))).norm(); + }; + Heightfield.prototype.setHeightsFromImage = function(image, scale) { + var canvas = document.createElement("canvas"); + canvas.width = image.width; + canvas.height = image.height; + var context = canvas.getContext("2d"); + context.drawImage(image, 0, 0); + var imageData = context.getImageData(0, 0, image.width, image.height); + var matrix = this.data; + matrix.length = 0; + this.elementSize = Math.abs(scale.x) / imageData.width; + for (var i = 0; i < imageData.height; i++) { + var row = []; + for (var j = 0; j < imageData.width; j++) { + var a = imageData.data[4 * (i * imageData.height + j)]; + var b = imageData.data[4 * (i * imageData.height + j) + 1]; + var c = imageData.data[4 * (i * imageData.height + j) + 2]; + var height = (a + b + c) / 4 / 255 * scale.z; + scale.x < 0 ? row.push(height) : row.unshift(height); + } + scale.y < 0 ? matrix.unshift(row) : matrix.push(row); + } + this.updateMaxValue(); + this.updateMinValue(); + this.update(); + }; + }, { + "../math/Vec3": 32, + "../utils/Utils": 55, + "./ConvexPolyhedron": 40, + "./Shape": 45 + } ], + 43: [ function(_dereq_, module, exports) { + module.exports = Particle; + var Shape = _dereq_("./Shape"); + var Vec3 = _dereq_("../math/Vec3"); + function Particle() { + Shape.call(this, { + type: Shape.types.PARTICLE + }); + } + Particle.prototype = new Shape(); + Particle.prototype.constructor = Particle; + Particle.prototype.calculateLocalInertia = function(mass, target) { + target = target || new Vec3(); + target.set(0, 0, 0); + return target; + }; + Particle.prototype.volume = function() { + return 0; + }; + Particle.prototype.updateBoundingSphereRadius = function() { + this.boundingSphereRadius = 0; + }; + Particle.prototype.calculateWorldAABB = function(pos, quat, min, max) { + min.copy(pos); + max.copy(pos); + }; + }, { + "../math/Vec3": 32, + "./Shape": 45 + } ], + 44: [ function(_dereq_, module, exports) { + module.exports = Plane; + var Shape = _dereq_("./Shape"); + var Vec3 = _dereq_("../math/Vec3"); + function Plane() { + Shape.call(this, { + type: Shape.types.PLANE + }); + this.worldNormal = new Vec3(); + this.worldNormalNeedsUpdate = true; + this.boundingSphereRadius = Number.MAX_VALUE; + } + Plane.prototype = new Shape(); + Plane.prototype.constructor = Plane; + Plane.prototype.computeWorldNormal = function(quat) { + var n = this.worldNormal; + n.set(0, 0, 1); + quat.vmult(n, n); + this.worldNormalNeedsUpdate = false; + }; + Plane.prototype.calculateLocalInertia = function(mass, target) { + target = target || new Vec3(); + return target; + }; + Plane.prototype.volume = function() { + return Number.MAX_VALUE; + }; + var tempNormal = new Vec3(); + Plane.prototype.calculateWorldAABB = function(pos, quat, min, max) { + tempNormal.set(0, 0, 1); + quat.vmult(tempNormal, tempNormal); + var maxVal = Number.MAX_VALUE; + min.set(-maxVal, -maxVal, -maxVal); + max.set(maxVal, maxVal, maxVal); + 1 === tempNormal.x && (max.x = pos.x); + 1 === tempNormal.y && (max.y = pos.y); + 1 === tempNormal.z && (max.z = pos.z); + -1 === tempNormal.x && (min.x = pos.x); + -1 === tempNormal.y && (min.y = pos.y); + -1 === tempNormal.z && (min.z = pos.z); + }; + Plane.prototype.updateBoundingSphereRadius = function() { + this.boundingSphereRadius = Number.MAX_VALUE; + }; + }, { + "../math/Vec3": 32, + "./Shape": 45 + } ], + 45: [ function(_dereq_, module, exports) { + module.exports = Shape; + var EventTarget = _dereq_("../utils/EventTarget"); + var Shape = _dereq_("./Shape"); + var Vec3 = _dereq_("../math/Vec3"); + var Quaternion = _dereq_("../math/Quaternion"); + var Material = _dereq_("../material/Material"); + function Shape(options) { + options = options || {}; + EventTarget.apply(this); + this.id = Shape.idCounter++; + this.type = options.type || 0; + this.boundingSphereRadius = 0; + this.collisionResponse = !options.collisionResponse || options.collisionResponse; + this.collisionFilterGroup = void 0 !== options.collisionFilterGroup ? options.collisionFilterGroup : 1; + this.collisionFilterMask = void 0 !== options.collisionFilterMask ? options.collisionFilterMask : -1; + this.material = options.material ? options.material : null; + this.body = null; + } + Shape.prototype = new EventTarget(); + Shape.prototype.constructor = Shape; + Shape.prototype.updateBoundingSphereRadius = function() { + throw "computeBoundingSphereRadius() not implemented for shape type " + this.type; + }; + Shape.prototype.volume = function() { + throw "volume() not implemented for shape type " + this.type; + }; + Shape.prototype.calculateLocalInertia = function(mass, target) { + throw "calculateLocalInertia() not implemented for shape type " + this.type; + }; + Shape.idCounter = 0; + Shape.types = { + SPHERE: 1, + PLANE: 2, + BOX: 4, + COMPOUND: 8, + CONVEXPOLYHEDRON: 16, + HEIGHTFIELD: 32, + PARTICLE: 64, + CYLINDER: 128, + TRIMESH: 256 + }; + }, { + "../material/Material": 26, + "../math/Quaternion": 30, + "../math/Vec3": 32, + "../utils/EventTarget": 51, + "./Shape": 45 + } ], + 46: [ function(_dereq_, module, exports) { + module.exports = Sphere; + var Shape = _dereq_("./Shape"); + var Vec3 = _dereq_("../math/Vec3"); + function Sphere(radius) { + Shape.call(this, { + type: Shape.types.SPHERE + }); + this.radius = void 0 !== radius ? radius : 1; + if (this.radius < 0) throw new Error("The sphere radius cannot be negative."); + this.updateBoundingSphereRadius(); + } + Sphere.prototype = new Shape(); + Sphere.prototype.constructor = Sphere; + Sphere.prototype.calculateLocalInertia = function(mass, target) { + target = target || new Vec3(); + var I = 2 * mass * this.radius * this.radius / 5; + target.x = I; + target.y = I; + target.z = I; + return target; + }; + Sphere.prototype.volume = function() { + return 4 * Math.PI * this.radius / 3; + }; + Sphere.prototype.updateBoundingSphereRadius = function() { + this.boundingSphereRadius = this.radius; + }; + Sphere.prototype.calculateWorldAABB = function(pos, quat, min, max) { + var r = this.radius; + var axes = [ "x", "y", "z" ]; + for (var i = 0; i < axes.length; i++) { + var ax = axes[i]; + min[ax] = pos[ax] - r; + max[ax] = pos[ax] + r; + } + }; + }, { + "../math/Vec3": 32, + "./Shape": 45 + } ], + 47: [ function(_dereq_, module, exports) { + module.exports = Trimesh; + var Shape = _dereq_("./Shape"); + var Vec3 = _dereq_("../math/Vec3"); + var Quaternion = _dereq_("../math/Quaternion"); + var Transform = _dereq_("../math/Transform"); + var AABB = _dereq_("../collision/AABB"); + var Octree = _dereq_("../utils/Octree"); + var CMath = _dereq_("../math/CMath"); + function Trimesh(vertices, indices) { + Shape.call(this, { + type: Shape.types.TRIMESH + }); + this.vertices = new Float32Array(vertices); + this.indices = new Int16Array(indices); + this.normals = new Float32Array(indices.length); + this.aabb = new AABB(); + this.edges = null; + this.scale = new Vec3(1, 1, 1); + this.tree = new Octree(); + this.updateEdges(); + this.updateNormals(); + this.updateAABB(); + this.updateBoundingSphereRadius(); + this.updateTree(); + } + Trimesh.prototype = new Shape(); + Trimesh.prototype.constructor = Trimesh; + var computeNormals_n = new Vec3(); + Trimesh.prototype.updateTree = function() { + var tree = this.tree; + tree.reset(); + tree.aabb.copy(this.aabb); + var scale = this.scale; + tree.aabb.lowerBound.x *= 1 / scale.x; + tree.aabb.lowerBound.y *= 1 / scale.y; + tree.aabb.lowerBound.z *= 1 / scale.z; + tree.aabb.upperBound.x *= 1 / scale.x; + tree.aabb.upperBound.y *= 1 / scale.y; + tree.aabb.upperBound.z *= 1 / scale.z; + var triangleAABB = new AABB(); + var a = new Vec3(); + var b = new Vec3(); + var c = new Vec3(); + var points = [ a, b, c ]; + for (var i = 0; i < this.indices.length / 3; i++) { + var i3 = 3 * i; + this._getUnscaledVertex(this.indices[i3], a); + this._getUnscaledVertex(this.indices[i3 + 1], b); + this._getUnscaledVertex(this.indices[i3 + 2], c); + triangleAABB.setFromPoints(points); + tree.insert(triangleAABB, i); + } + tree.removeEmptyNodes(); + }; + var unscaledAABB = new AABB(); + Trimesh.prototype.getTrianglesInAABB = function(aabb, result) { + unscaledAABB.copy(aabb); + var scale = this.scale; + var isx = scale.x; + var isy = scale.y; + var isz = scale.z; + var l = unscaledAABB.lowerBound; + var u = unscaledAABB.upperBound; + l.x /= isx; + l.y /= isy; + l.z /= isz; + u.x /= isx; + u.y /= isy; + u.z /= isz; + return this.tree.aabbQuery(unscaledAABB, result); + }; + Trimesh.prototype.setScale = function(scale) { + var wasUniform = this.scale.x === this.scale.y === this.scale.z; + var isUniform = scale.x === scale.y === scale.z; + wasUniform && isUniform || this.updateNormals(); + this.scale.copy(scale); + this.updateAABB(); + this.updateBoundingSphereRadius(); + }; + Trimesh.prototype.updateNormals = function() { + var n = computeNormals_n; + var normals = this.normals; + for (var i = 0; i < this.indices.length / 3; i++) { + var i3 = 3 * i; + var a = this.indices[i3], b = this.indices[i3 + 1], c = this.indices[i3 + 2]; + this.getVertex(a, va); + this.getVertex(b, vb); + this.getVertex(c, vc); + Trimesh.computeNormal(vb, va, vc, n); + normals[i3] = n.x; + normals[i3 + 1] = n.y; + normals[i3 + 2] = n.z; + } + }; + Trimesh.prototype.updateEdges = function() { + var edges = {}; + var add = function add(indexA, indexB) { + var key = a < b ? a + "_" + b : b + "_" + a; + edges[key] = true; + }; + for (var i = 0; i < this.indices.length / 3; i++) { + var i3 = 3 * i; + var a = this.indices[i3], b = this.indices[i3 + 1], c = this.indices[i3 + 2]; + add(a, b); + add(b, c); + add(c, a); + } + var keys = Object.keys(edges); + this.edges = new Int16Array(2 * keys.length); + for (var i = 0; i < keys.length; i++) { + var indices = keys[i].split("_"); + this.edges[2 * i] = parseInt(indices[0], 10); + this.edges[2 * i + 1] = parseInt(indices[1], 10); + } + }; + Trimesh.prototype.getEdgeVertex = function(edgeIndex, firstOrSecond, vertexStore) { + var vertexIndex = this.edges[2 * edgeIndex + (firstOrSecond ? 1 : 0)]; + this.getVertex(vertexIndex, vertexStore); + }; + var getEdgeVector_va = new Vec3(); + var getEdgeVector_vb = new Vec3(); + Trimesh.prototype.getEdgeVector = function(edgeIndex, vectorStore) { + var va = getEdgeVector_va; + var vb = getEdgeVector_vb; + this.getEdgeVertex(edgeIndex, 0, va); + this.getEdgeVertex(edgeIndex, 1, vb); + vb.vsub(va, vectorStore); + }; + var cb = new Vec3(); + var ab = new Vec3(); + Trimesh.computeNormal = function(va, vb, vc, target) { + vb.vsub(va, ab); + vc.vsub(vb, cb); + cb.cross(ab, target); + target.isZero() || target.normalize(); + }; + var va = new Vec3(); + var vb = new Vec3(); + var vc = new Vec3(); + Trimesh.prototype.getVertex = function(i, out) { + var scale = this.scale; + this._getUnscaledVertex(i, out); + out.x *= scale.x; + out.y *= scale.y; + out.z *= scale.z; + return out; + }; + Trimesh.prototype._getUnscaledVertex = function(i, out) { + var i3 = 3 * i; + var vertices = this.vertices; + return out.set(vertices[i3], vertices[i3 + 1], vertices[i3 + 2]); + }; + Trimesh.prototype.getWorldVertex = function(i, pos, quat, out) { + this.getVertex(i, out); + Transform.pointToWorldFrame(pos, quat, out, out); + return out; + }; + Trimesh.prototype.getTriangleVertices = function(i, a, b, c) { + var i3 = 3 * i; + this.getVertex(this.indices[i3], a); + this.getVertex(this.indices[i3 + 1], b); + this.getVertex(this.indices[i3 + 2], c); + }; + Trimesh.prototype.getNormal = function(i, target) { + var i3 = 3 * i; + return target.set(this.normals[i3], this.normals[i3 + 1], this.normals[i3 + 2]); + }; + var cli_aabb = new AABB(); + Trimesh.prototype.calculateLocalInertia = function(mass, target) { + this.computeLocalAABB(cli_aabb); + var x = cli_aabb.upperBound.x - cli_aabb.lowerBound.x, y = cli_aabb.upperBound.y - cli_aabb.lowerBound.y, z = cli_aabb.upperBound.z - cli_aabb.lowerBound.z; + return target.set(1 / 12 * mass * (2 * y * 2 * y + 2 * z * 2 * z), 1 / 12 * mass * (2 * x * 2 * x + 2 * z * 2 * z), 1 / 12 * mass * (2 * y * 2 * y + 2 * x * 2 * x)); + }; + var computeLocalAABB_worldVert = new Vec3(); + Trimesh.prototype.computeLocalAABB = function(aabb) { + var l = aabb.lowerBound, u = aabb.upperBound, n = this.vertices.length, vertices = this.vertices, v = computeLocalAABB_worldVert; + this.getVertex(0, v); + l.copy(v); + u.copy(v); + for (var i = 0; i !== n; i++) { + this.getVertex(i, v); + v.x < l.x ? l.x = v.x : v.x > u.x && (u.x = v.x); + v.y < l.y ? l.y = v.y : v.y > u.y && (u.y = v.y); + v.z < l.z ? l.z = v.z : v.z > u.z && (u.z = v.z); + } + }; + Trimesh.prototype.updateAABB = function() { + this.computeLocalAABB(this.aabb); + }; + Trimesh.prototype.updateBoundingSphereRadius = function() { + var max2 = 0; + var vertices = this.vertices; + var v = new Vec3(); + for (var i = 0, N = vertices.length / 3; i !== N; i++) { + this.getVertex(i, v); + var norm2 = v.norm2(); + norm2 > max2 && (max2 = norm2); + } + this.boundingSphereRadius = Math.sqrt(max2); + }; + var tempWorldVertex = new Vec3(); + var calculateWorldAABB_frame = new Transform(); + var calculateWorldAABB_aabb = new AABB(); + Trimesh.prototype.calculateWorldAABB = function(pos, quat, min, max) { + var frame = calculateWorldAABB_frame; + var result = calculateWorldAABB_aabb; + frame.position = pos; + frame.quaternion = quat; + this.aabb.toWorldFrame(frame, result); + min.copy(result.lowerBound); + max.copy(result.upperBound); + }; + Trimesh.prototype.volume = function() { + return 4 * Math.PI * this.boundingSphereRadius / 3; + }; + Trimesh.createTorus = function(radius, tube, radialSegments, tubularSegments, arc) { + radius = radius || 1; + tube = tube || .5; + radialSegments = radialSegments || 8; + tubularSegments = tubularSegments || 6; + arc = arc || 2 * Math.PI; + var vertices = []; + var indices = []; + for (var j = 0; j <= radialSegments; j++) for (var i = 0; i <= tubularSegments; i++) { + var u = i / tubularSegments * arc; + var v = j / radialSegments * Math.PI * 2; + var x = (radius + tube * CMath.cos(v)) * CMath.cos(u); + var y = (radius + tube * CMath.cos(v)) * CMath.sin(u); + var z = tube * CMath.sin(v); + vertices.push(x, y, z); + } + for (var j = 1; j <= radialSegments; j++) for (var i = 1; i <= tubularSegments; i++) { + var a = (tubularSegments + 1) * j + i - 1; + var b = (tubularSegments + 1) * (j - 1) + i - 1; + var c = (tubularSegments + 1) * (j - 1) + i; + var d = (tubularSegments + 1) * j + i; + indices.push(a, b, d); + indices.push(b, c, d); + } + return new Trimesh(vertices, indices); + }; + }, { + "../collision/AABB": 3, + "../math/CMath": 27, + "../math/Quaternion": 30, + "../math/Transform": 31, + "../math/Vec3": 32, + "../utils/Octree": 52, + "./Shape": 45 + } ], + 48: [ function(_dereq_, module, exports) { + module.exports = GSSolver; + var Vec3 = _dereq_("../math/Vec3"); + var Quaternion = _dereq_("../math/Quaternion"); + var Solver = _dereq_("./Solver"); + function GSSolver() { + Solver.call(this); + this.iterations = 10; + this.tolerance = 1e-7; + } + GSSolver.prototype = new Solver(); + var GSSolver_solve_lambda = []; + var GSSolver_solve_invCs = []; + var GSSolver_solve_Bs = []; + GSSolver.prototype.solve = function(dt, world) { + var iter = 0, maxIter = this.iterations, tolSquared = this.tolerance * this.tolerance, equations = this.equations, Neq = equations.length, bodies = world.bodies, Nbodies = bodies.length, h = dt, q, B, invC, deltalambda, deltalambdaTot, GWlambda, lambdaj; + if (0 !== Neq) for (var i = 0; i !== Nbodies; i++) bodies[i].updateSolveMassProperties(); + var invCs = GSSolver_solve_invCs, Bs = GSSolver_solve_Bs, lambda = GSSolver_solve_lambda; + invCs.length = Neq; + Bs.length = Neq; + lambda.length = Neq; + for (var i = 0; i !== Neq; i++) { + var c = equations[i]; + lambda[i] = 0; + Bs[i] = c.computeB(h); + invCs[i] = 1 / c.computeC(); + } + if (0 !== Neq) { + for (var i = 0; i !== Nbodies; i++) { + var b = bodies[i], vlambda = b.vlambda, wlambda = b.wlambda; + vlambda.set(0, 0, 0); + wlambda.set(0, 0, 0); + } + for (iter = 0; iter !== maxIter; iter++) { + deltalambdaTot = 0; + for (var j = 0; j !== Neq; j++) { + var c = equations[j]; + B = Bs[j]; + invC = invCs[j]; + lambdaj = lambda[j]; + GWlambda = c.computeGWlambda(); + deltalambda = invC * (B - GWlambda - c.eps * lambdaj); + lambdaj + deltalambda < c.minForce ? deltalambda = c.minForce - lambdaj : lambdaj + deltalambda > c.maxForce && (deltalambda = c.maxForce - lambdaj); + lambda[j] += deltalambda; + deltalambdaTot += deltalambda > 0 ? deltalambda : -deltalambda; + c.addToWlambda(deltalambda); + } + if (deltalambdaTot * deltalambdaTot < tolSquared) break; + } + for (var i = 0; i !== Nbodies; i++) { + var b = bodies[i], v = b.velocity, w = b.angularVelocity; + b.vlambda.vmul(b.linearFactor, b.vlambda); + v.vadd(b.vlambda, v); + b.wlambda.vmul(b.angularFactor, b.wlambda); + w.vadd(b.wlambda, w); + } + var l = equations.length; + var invDt = 1 / h; + while (l--) equations[l].multiplier = lambda[l] * invDt; + } + return iter; + }; + }, { + "../math/Quaternion": 30, + "../math/Vec3": 32, + "./Solver": 49 + } ], + 49: [ function(_dereq_, module, exports) { + module.exports = Solver; + function Solver() { + this.equations = []; + } + Solver.prototype.solve = function(dt, world) { + return 0; + }; + Solver.prototype.addEquation = function(eq) { + eq.enabled && this.equations.push(eq); + }; + Solver.prototype.removeEquation = function(eq) { + var eqs = this.equations; + var i = eqs.indexOf(eq); + -1 !== i && eqs.splice(i, 1); + }; + Solver.prototype.removeAllEquations = function() { + this.equations.length = 0; + }; + }, {} ], + 50: [ function(_dereq_, module, exports) { + module.exports = SplitSolver; + var Vec3 = _dereq_("../math/Vec3"); + var Quaternion = _dereq_("../math/Quaternion"); + var Solver = _dereq_("./Solver"); + var Body = _dereq_("../objects/Body"); + function SplitSolver(subsolver) { + Solver.call(this); + this.iterations = 10; + this.tolerance = 1e-7; + this.subsolver = subsolver; + this.nodes = []; + this.nodePool = []; + while (this.nodePool.length < 128) this.nodePool.push(this.createNode()); + } + SplitSolver.prototype = new Solver(); + var SplitSolver_solve_nodes = []; + var SplitSolver_solve_nodePool = []; + var SplitSolver_solve_eqs = []; + var SplitSolver_solve_bds = []; + var SplitSolver_solve_dummyWorld = { + bodies: [] + }; + var STATIC = Body.STATIC; + function getUnvisitedNode(nodes) { + var Nnodes = nodes.length; + for (var i = 0; i !== Nnodes; i++) { + var node = nodes[i]; + if (!node.visited && !(node.body.type & STATIC)) return node; + } + return false; + } + var queue = []; + function bfs(root, visitFunc, bds, eqs) { + queue.push(root); + root.visited = true; + visitFunc(root, bds, eqs); + while (queue.length) { + var node = queue.pop(); + var child; + while (child = getUnvisitedNode(node.children)) { + child.visited = true; + visitFunc(child, bds, eqs); + queue.push(child); + } + } + } + function visitFunc(node, bds, eqs) { + bds.push(node.body); + var Neqs = node.eqs.length; + for (var i = 0; i !== Neqs; i++) { + var eq = node.eqs[i]; + -1 === eqs.indexOf(eq) && eqs.push(eq); + } + } + SplitSolver.prototype.createNode = function() { + return { + body: null, + children: [], + eqs: [], + visited: false + }; + }; + SplitSolver.prototype.solve = function(dt, world) { + var nodes = SplitSolver_solve_nodes, nodePool = this.nodePool, bodies = world.bodies, equations = this.equations, Neq = equations.length, Nbodies = bodies.length, subsolver = this.subsolver; + while (nodePool.length < Nbodies) nodePool.push(this.createNode()); + nodes.length = Nbodies; + for (var i = 0; i < Nbodies; i++) nodes[i] = nodePool[i]; + for (var i = 0; i !== Nbodies; i++) { + var node = nodes[i]; + node.body = bodies[i]; + node.children.length = 0; + node.eqs.length = 0; + node.visited = false; + } + for (var k = 0; k !== Neq; k++) { + var eq = equations[k], i = bodies.indexOf(eq.bi), j = bodies.indexOf(eq.bj), ni = nodes[i], nj = nodes[j]; + ni.children.push(nj); + ni.eqs.push(eq); + nj.children.push(ni); + nj.eqs.push(eq); + } + var child, n = 0, eqs = SplitSolver_solve_eqs; + subsolver.tolerance = this.tolerance; + subsolver.iterations = this.iterations; + var dummyWorld = SplitSolver_solve_dummyWorld; + while (child = getUnvisitedNode(nodes)) { + eqs.length = 0; + dummyWorld.bodies.length = 0; + bfs(child, visitFunc, dummyWorld.bodies, eqs); + var Neqs = eqs.length; + eqs = eqs.sort(sortById); + for (var i = 0; i !== Neqs; i++) subsolver.addEquation(eqs[i]); + var iter = subsolver.solve(dt, dummyWorld); + subsolver.removeAllEquations(); + n++; + } + return n; + }; + function sortById(a, b) { + return b.id - a.id; + } + }, { + "../math/Quaternion": 30, + "../math/Vec3": 32, + "../objects/Body": 33, + "./Solver": 49 + } ], + 51: [ function(_dereq_, module, exports) { + var EventTarget = function EventTarget() {}; + module.exports = EventTarget; + EventTarget.prototype = { + constructor: EventTarget, + addEventListener: function addEventListener(type, listener) { + void 0 === this._listeners && (this._listeners = {}); + var listeners = this._listeners; + void 0 === listeners[type] && (listeners[type] = []); + -1 === listeners[type].indexOf(listener) && listeners[type].push(listener); + return this; + }, + hasEventListener: function hasEventListener(type, listener) { + if (void 0 === this._listeners) return false; + var listeners = this._listeners; + if (void 0 !== listeners[type] && -1 !== listeners[type].indexOf(listener)) return true; + return false; + }, + hasAnyEventListener: function hasAnyEventListener(type) { + if (void 0 === this._listeners) return false; + var listeners = this._listeners; + return void 0 !== listeners[type]; + }, + removeEventListener: function removeEventListener(type, listener) { + if (void 0 === this._listeners) return this; + var listeners = this._listeners; + if (void 0 === listeners[type]) return this; + var index = listeners[type].indexOf(listener); + -1 !== index && listeners[type].splice(index, 1); + return this; + }, + dispatchEvent: function dispatchEvent(event) { + if (void 0 === this._listeners) return this; + var listeners = this._listeners; + var listenerArray = listeners[event.type]; + if (void 0 !== listenerArray) { + event.target = this; + for (var i = 0, l = listenerArray.length; i < l; i++) listenerArray[i].call(this, event); + } + return this; + } + }; + }, {} ], + 52: [ function(_dereq_, module, exports) { + var AABB = _dereq_("../collision/AABB"); + var Vec3 = _dereq_("../math/Vec3"); + module.exports = Octree; + function OctreeNode(options) { + options = options || {}; + this.root = options.root || null; + this.aabb = options.aabb ? options.aabb.clone() : new AABB(); + this.data = []; + this.children = []; + } + function Octree(aabb, options) { + options = options || {}; + options.root = null; + options.aabb = aabb; + OctreeNode.call(this, options); + this.maxDepth = "undefined" !== typeof options.maxDepth ? options.maxDepth : 8; + } + Octree.prototype = new OctreeNode(); + OctreeNode.prototype.reset = function(aabb, options) { + this.children.length = this.data.length = 0; + }; + OctreeNode.prototype.insert = function(aabb, elementData, level) { + var nodeData = this.data; + level = level || 0; + if (!this.aabb.contains(aabb)) return false; + var children = this.children; + if (level < (this.maxDepth || this.root.maxDepth)) { + var subdivided = false; + if (!children.length) { + this.subdivide(); + subdivided = true; + } + for (var i = 0; 8 !== i; i++) if (children[i].insert(aabb, elementData, level + 1)) return true; + subdivided && (children.length = 0); + } + nodeData.push(elementData); + return true; + }; + var halfDiagonal = new Vec3(); + OctreeNode.prototype.subdivide = function() { + var aabb = this.aabb; + var l = aabb.lowerBound; + var u = aabb.upperBound; + var children = this.children; + children.push(new OctreeNode({ + aabb: new AABB({ + lowerBound: new Vec3(0, 0, 0) + }) + }), new OctreeNode({ + aabb: new AABB({ + lowerBound: new Vec3(1, 0, 0) + }) + }), new OctreeNode({ + aabb: new AABB({ + lowerBound: new Vec3(1, 1, 0) + }) + }), new OctreeNode({ + aabb: new AABB({ + lowerBound: new Vec3(1, 1, 1) + }) + }), new OctreeNode({ + aabb: new AABB({ + lowerBound: new Vec3(0, 1, 1) + }) + }), new OctreeNode({ + aabb: new AABB({ + lowerBound: new Vec3(0, 0, 1) + }) + }), new OctreeNode({ + aabb: new AABB({ + lowerBound: new Vec3(1, 0, 1) + }) + }), new OctreeNode({ + aabb: new AABB({ + lowerBound: new Vec3(0, 1, 0) + }) + })); + u.vsub(l, halfDiagonal); + halfDiagonal.scale(.5, halfDiagonal); + var root = this.root || this; + for (var i = 0; 8 !== i; i++) { + var child = children[i]; + child.root = root; + var lowerBound = child.aabb.lowerBound; + lowerBound.x *= halfDiagonal.x; + lowerBound.y *= halfDiagonal.y; + lowerBound.z *= halfDiagonal.z; + lowerBound.vadd(l, lowerBound); + lowerBound.vadd(halfDiagonal, child.aabb.upperBound); + } + }; + OctreeNode.prototype.aabbQuery = function(aabb, result) { + var nodeData = this.data; + var children = this.children; + var queue = [ this ]; + while (queue.length) { + var node = queue.pop(); + node.aabb.overlaps(aabb) && Array.prototype.push.apply(result, node.data); + Array.prototype.push.apply(queue, node.children); + } + return result; + }; + var tmpAABB = new AABB(); + OctreeNode.prototype.rayQuery = function(ray, treeTransform, result) { + ray.getAABB(tmpAABB); + tmpAABB.toLocalFrame(treeTransform, tmpAABB); + this.aabbQuery(tmpAABB, result); + return result; + }; + OctreeNode.prototype.removeEmptyNodes = function() { + for (var i = this.children.length - 1; i >= 0; i--) { + this.children[i].removeEmptyNodes(); + this.children[i].children.length || this.children[i].data.length || this.children.splice(i, 1); + } + }; + }, { + "../collision/AABB": 3, + "../math/Vec3": 32 + } ], + 53: [ function(_dereq_, module, exports) { + module.exports = Pool; + function Pool() { + this.objects = []; + this.type = Object; + } + Pool.prototype.release = function() { + var Nargs = arguments.length; + for (var i = 0; i !== Nargs; i++) this.objects.push(arguments[i]); + return this; + }; + Pool.prototype.get = function() { + return 0 === this.objects.length ? this.constructObject() : this.objects.pop(); + }; + Pool.prototype.constructObject = function() { + throw new Error("constructObject() not implemented in this Pool subclass yet!"); + }; + Pool.prototype.resize = function(size) { + var objects = this.objects; + while (objects.length > size) objects.pop(); + while (objects.length < size) objects.push(this.constructObject()); + return this; + }; + }, {} ], + 54: [ function(_dereq_, module, exports) { + module.exports = TupleDictionary; + function TupleDictionary() { + this.data = { + keys: [] + }; + } + TupleDictionary.prototype.get = function(i, j) { + if (i > j) { + var temp = j; + j = i; + i = temp; + } + return this.data[i + "-" + j]; + }; + TupleDictionary.prototype.set = function(i, j, value) { + if (i > j) { + var temp = j; + j = i; + i = temp; + } + var key = i + "-" + j; + this.get(i, j) || this.data.keys.push(key); + this.data[key] = value; + return this.data[key]; + }; + TupleDictionary.prototype.del = function(i, j) { + if (i > j) { + var temp = j; + j = i; + i = temp; + } + var key = i + "-" + j; + var index = this.data.keys.indexOf(key); + if (index >= 0) { + this.data.keys.splice(index, 1); + delete this.data[key]; + return true; + } + return false; + }; + TupleDictionary.prototype.reset = function() { + this.data = { + keys: [] + }; + }; + TupleDictionary.prototype.getLength = function() { + return this.data.keys.length; + }; + TupleDictionary.prototype.getKeyByIndex = function(index) { + return this.data.keys[index]; + }; + TupleDictionary.prototype.getDataByKey = function(Key) { + return this.data[Key]; + }; + }, {} ], + 55: [ function(_dereq_, module, exports) { + function Utils() {} + module.exports = Utils; + Utils.defaults = function(options, defaults) { + options = options || {}; + for (var key in defaults) key in options || (options[key] = defaults[key]); + return options; + }; + }, {} ], + 56: [ function(_dereq_, module, exports) { + module.exports = Vec3Pool; + var Vec3 = _dereq_("../math/Vec3"); + var Pool = _dereq_("./Pool"); + function Vec3Pool() { + Pool.call(this); + this.type = Vec3; + } + Vec3Pool.prototype = new Pool(); + Vec3Pool.prototype.constructObject = function() { + return new Vec3(); + }; + }, { + "../math/Vec3": 32, + "./Pool": 53 + } ], + 57: [ function(_dereq_, module, exports) { + module.exports = Narrowphase; + var AABB = _dereq_("../collision/AABB"); + var Body = _dereq_("../objects/Body"); + var Shape = _dereq_("../shapes/Shape"); + var Ray = _dereq_("../collision/Ray"); + var Vec3 = _dereq_("../math/Vec3"); + var Transform = _dereq_("../math/Transform"); + var ConvexPolyhedron = _dereq_("../shapes/ConvexPolyhedron"); + var Quaternion = _dereq_("../math/Quaternion"); + var Solver = _dereq_("../solver/Solver"); + var Vec3Pool = _dereq_("../utils/Vec3Pool"); + var ContactEquation = _dereq_("../equations/ContactEquation"); + var FrictionEquation = _dereq_("../equations/FrictionEquation"); + function Narrowphase(world) { + this.contactPointPool = []; + this.frictionEquationPool = []; + this.result = []; + this.frictionResult = []; + this.v3pool = new Vec3Pool(); + this.world = world; + this.currentContactMaterial = null; + this.enableFrictionReduction = false; + } + Narrowphase.prototype.createContactEquation = function(bi, bj, si, sj, overrideShapeA, overrideShapeB) { + var c; + if (this.contactPointPool.length) { + c = this.contactPointPool.pop(); + c.bi = bi; + c.bj = bj; + } else c = new ContactEquation(bi, bj); + c.enabled = bi.collisionResponse && bj.collisionResponse && si.collisionResponse && sj.collisionResponse; + var cm = this.currentContactMaterial; + c.restitution = cm.restitution; + c.setSpookParams(cm.contactEquationStiffness, cm.contactEquationRelaxation, this.world.dt); + var matA = si.material || bi.material; + var matB = sj.material || bj.material; + matA && matB && matA.restitution >= 0 && matB.restitution >= 0 && (c.restitution = matA.restitution * matB.restitution); + c.si = overrideShapeA || si; + c.sj = overrideShapeB || sj; + return c; + }; + Narrowphase.prototype.createFrictionEquationsFromContact = function(contactEquation, outArray) { + var bodyA = contactEquation.bi; + var bodyB = contactEquation.bj; + var shapeA = contactEquation.si; + var shapeB = contactEquation.sj; + var world = this.world; + var cm = this.currentContactMaterial; + var friction = cm.friction; + var matA = shapeA.material || bodyA.material; + var matB = shapeB.material || bodyB.material; + matA && matB && matA.friction >= 0 && matB.friction >= 0 && (friction = matA.friction * matB.friction); + if (friction > 0) { + var mug = friction * world.gravity.length(); + var reducedMass = bodyA.invMass + bodyB.invMass; + reducedMass > 0 && (reducedMass = 1 / reducedMass); + var pool = this.frictionEquationPool; + var c1 = pool.length ? pool.pop() : new FrictionEquation(bodyA, bodyB, mug * reducedMass); + var c2 = pool.length ? pool.pop() : new FrictionEquation(bodyA, bodyB, mug * reducedMass); + c1.bi = c2.bi = bodyA; + c1.bj = c2.bj = bodyB; + c1.minForce = c2.minForce = -mug * reducedMass; + c1.maxForce = c2.maxForce = mug * reducedMass; + c1.ri.copy(contactEquation.ri); + c1.rj.copy(contactEquation.rj); + c2.ri.copy(contactEquation.ri); + c2.rj.copy(contactEquation.rj); + contactEquation.ni.tangents(c1.t, c2.t); + c1.setSpookParams(cm.frictionEquationStiffness, cm.frictionEquationRelaxation, world.dt); + c2.setSpookParams(cm.frictionEquationStiffness, cm.frictionEquationRelaxation, world.dt); + c1.enabled = c2.enabled = contactEquation.enabled; + outArray.push(c1, c2); + return true; + } + return false; + }; + var averageNormal = new Vec3(); + var averageContactPointA = new Vec3(); + var averageContactPointB = new Vec3(); + Narrowphase.prototype.createFrictionFromAverage = function(numContacts) { + var c = this.result[this.result.length - 1]; + if (!this.createFrictionEquationsFromContact(c, this.frictionResult) || 1 === numContacts) return; + var f1 = this.frictionResult[this.frictionResult.length - 2]; + var f2 = this.frictionResult[this.frictionResult.length - 1]; + averageNormal.setZero(); + averageContactPointA.setZero(); + averageContactPointB.setZero(); + var bodyA = c.bi; + var bodyB = c.bj; + for (var i = 0; i !== numContacts; i++) { + c = this.result[this.result.length - 1 - i]; + if (c.bodyA !== bodyA) { + averageNormal.vadd(c.ni, averageNormal); + averageContactPointA.vadd(c.ri, averageContactPointA); + averageContactPointB.vadd(c.rj, averageContactPointB); + } else { + averageNormal.vsub(c.ni, averageNormal); + averageContactPointA.vadd(c.rj, averageContactPointA); + averageContactPointB.vadd(c.ri, averageContactPointB); + } + } + var invNumContacts = 1 / numContacts; + averageContactPointA.scale(invNumContacts, f1.ri); + averageContactPointB.scale(invNumContacts, f1.rj); + f2.ri.copy(f1.ri); + f2.rj.copy(f1.rj); + averageNormal.normalize(); + averageNormal.tangents(f1.t, f2.t); + }; + var tmpVec1 = new Vec3(); + var tmpVec2 = new Vec3(); + var tmpQuat1 = new Quaternion(); + var tmpQuat2 = new Quaternion(); + Narrowphase.prototype.getContacts = function(p1, p2, world, result, oldcontacts, frictionResult, frictionPool) { + this.contactPointPool = oldcontacts; + this.frictionEquationPool = frictionPool; + this.result = result; + this.frictionResult = frictionResult; + var qi = tmpQuat1; + var qj = tmpQuat2; + var xi = tmpVec1; + var xj = tmpVec2; + for (var k = 0, N = p1.length; k !== N; k++) { + var bi = p1[k], bj = p2[k]; + var bodyContactMaterial = null; + bi.material && bj.material && (bodyContactMaterial = world.getContactMaterial(bi.material, bj.material) || null); + var justTest = false == bi.collisionResponse || false == bj.collisionResponse || bi.type & Body.KINEMATIC && bj.type & Body.STATIC || bi.type & Body.STATIC && bj.type & Body.KINEMATIC || bi.type & Body.KINEMATIC && bj.type & Body.KINEMATIC; + for (var i = 0; i < bi.shapes.length; i++) { + bi.quaternion.mult(bi.shapeOrientations[i], qi); + bi.quaternion.vmult(bi.shapeOffsets[i], xi); + xi.vadd(bi.position, xi); + var si = bi.shapes[i]; + for (var j = 0; j < bj.shapes.length; j++) { + bj.quaternion.mult(bj.shapeOrientations[j], qj); + bj.quaternion.vmult(bj.shapeOffsets[j], xj); + xj.vadd(bj.position, xj); + var sj = bj.shapes[j]; + if (!(si.collisionFilterMask & sj.collisionFilterGroup && sj.collisionFilterMask & si.collisionFilterGroup)) continue; + if (xi.distanceTo(xj) > si.boundingSphereRadius + sj.boundingSphereRadius) continue; + justTest |= false == si.collisionResponse || false == sj.collisionResponse; + var shapeContactMaterial = null; + si.material && sj.material && (shapeContactMaterial = world.getContactMaterial(si.material, sj.material) || null); + this.currentContactMaterial = shapeContactMaterial || bodyContactMaterial || world.defaultContactMaterial; + var resolver = this[si.type | sj.type]; + if (resolver) { + var retval = false; + retval = si.type < sj.type ? resolver.call(this, si, sj, xi, xj, qi, qj, bi, bj, si, sj, justTest) : resolver.call(this, sj, si, xj, xi, qj, qi, bj, bi, si, sj, justTest); + if (retval && justTest) { + world.shapeOverlapKeeper.set(si.id, sj.id); + world.bodyOverlapKeeper.set(bi.id, bj.id); + var data = { + si: si, + sj: sj + }; + world.triggerDic.set(si.id, sj.id, data); + world.oldTriggerDic.set(si.id, sj.id, data); + } + } + } + } + } + }; + var numWarnings = 0; + var maxWarnings = 10; + function warn(msg) { + if (numWarnings > maxWarnings) return; + numWarnings++; + console.warn(msg); + } + Narrowphase.prototype[Shape.types.BOX | Shape.types.BOX] = Narrowphase.prototype.boxBox = function(si, sj, xi, xj, qi, qj, bi, bj, rsi, rsj, justTest) { + si.convexPolyhedronRepresentation.material = si.material; + sj.convexPolyhedronRepresentation.material = sj.material; + si.convexPolyhedronRepresentation.collisionResponse = si.collisionResponse; + sj.convexPolyhedronRepresentation.collisionResponse = sj.collisionResponse; + return this.convexConvex(si.convexPolyhedronRepresentation, sj.convexPolyhedronRepresentation, xi, xj, qi, qj, bi, bj, si, sj, justTest); + }; + Narrowphase.prototype[Shape.types.BOX | Shape.types.CONVEXPOLYHEDRON] = Narrowphase.prototype.boxConvex = function(si, sj, xi, xj, qi, qj, bi, bj, rsi, rsj, justTest) { + si.convexPolyhedronRepresentation.material = si.material; + si.convexPolyhedronRepresentation.collisionResponse = si.collisionResponse; + return this.convexConvex(si.convexPolyhedronRepresentation, sj, xi, xj, qi, qj, bi, bj, si, sj, justTest); + }; + Narrowphase.prototype[Shape.types.BOX | Shape.types.PARTICLE] = Narrowphase.prototype.boxParticle = function(si, sj, xi, xj, qi, qj, bi, bj, rsi, rsj, justTest) { + si.convexPolyhedronRepresentation.material = si.material; + si.convexPolyhedronRepresentation.collisionResponse = si.collisionResponse; + return this.convexParticle(si.convexPolyhedronRepresentation, sj, xi, xj, qi, qj, bi, bj, si, sj, justTest); + }; + Narrowphase.prototype[Shape.types.SPHERE] = Narrowphase.prototype.sphereSphere = function(si, sj, xi, xj, qi, qj, bi, bj, rsi, rsj, justTest) { + if (justTest) return xi.distanceSquared(xj) < Math.pow(si.radius + sj.radius, 2); + var r = this.createContactEquation(bi, bj, si, sj, rsi, rsj); + xj.vsub(xi, r.ni); + r.ni.normalize(); + r.ri.copy(r.ni); + r.rj.copy(r.ni); + r.ri.mult(si.radius, r.ri); + r.rj.mult(-sj.radius, r.rj); + r.ri.vadd(xi, r.ri); + r.ri.vsub(bi.position, r.ri); + r.rj.vadd(xj, r.rj); + r.rj.vsub(bj.position, r.rj); + this.result.push(r); + this.createFrictionEquationsFromContact(r, this.frictionResult); + }; + var planeTrimesh_normal = new Vec3(); + var planeTrimesh_relpos = new Vec3(); + var planeTrimesh_projected = new Vec3(); + Narrowphase.prototype[Shape.types.PLANE | Shape.types.TRIMESH] = Narrowphase.prototype.planeTrimesh = function(planeShape, trimeshShape, planePos, trimeshPos, planeQuat, trimeshQuat, planeBody, trimeshBody, rsi, rsj, justTest) { + var v = new Vec3(); + var normal = planeTrimesh_normal; + normal.set(0, 0, 1); + planeQuat.vmult(normal, normal); + for (var i = 0; i < trimeshShape.vertices.length / 3; i++) { + trimeshShape.getVertex(i, v); + var v2 = new Vec3(); + v2.copy(v); + Transform.pointToWorldFrame(trimeshPos, trimeshQuat, v2, v); + var relpos = planeTrimesh_relpos; + v.vsub(planePos, relpos); + var dot = normal.dot(relpos); + if (dot <= 0) { + if (justTest) return true; + var r = this.createContactEquation(planeBody, trimeshBody, planeShape, trimeshShape, rsi, rsj); + r.ni.copy(normal); + var projected = planeTrimesh_projected; + normal.scale(relpos.dot(normal), projected); + v.vsub(projected, projected); + r.ri.copy(projected); + r.ri.vsub(planeBody.position, r.ri); + r.rj.copy(v); + r.rj.vsub(trimeshBody.position, r.rj); + this.result.push(r); + this.createFrictionEquationsFromContact(r, this.frictionResult); + } + } + }; + var sphereTrimesh_normal = new Vec3(); + var sphereTrimesh_relpos = new Vec3(); + var sphereTrimesh_projected = new Vec3(); + var sphereTrimesh_v = new Vec3(); + var sphereTrimesh_v2 = new Vec3(); + var sphereTrimesh_edgeVertexA = new Vec3(); + var sphereTrimesh_edgeVertexB = new Vec3(); + var sphereTrimesh_edgeVector = new Vec3(); + var sphereTrimesh_edgeVectorUnit = new Vec3(); + var sphereTrimesh_localSpherePos = new Vec3(); + var sphereTrimesh_tmp = new Vec3(); + var sphereTrimesh_va = new Vec3(); + var sphereTrimesh_vb = new Vec3(); + var sphereTrimesh_vc = new Vec3(); + var sphereTrimesh_localSphereAABB = new AABB(); + var sphereTrimesh_triangles = []; + Narrowphase.prototype[Shape.types.SPHERE | Shape.types.TRIMESH] = Narrowphase.prototype.sphereTrimesh = function(sphereShape, trimeshShape, spherePos, trimeshPos, sphereQuat, trimeshQuat, sphereBody, trimeshBody, rsi, rsj, justTest) { + var edgeVertexA = sphereTrimesh_edgeVertexA; + var edgeVertexB = sphereTrimesh_edgeVertexB; + var edgeVector = sphereTrimesh_edgeVector; + var edgeVectorUnit = sphereTrimesh_edgeVectorUnit; + var localSpherePos = sphereTrimesh_localSpherePos; + var tmp = sphereTrimesh_tmp; + var localSphereAABB = sphereTrimesh_localSphereAABB; + var v2 = sphereTrimesh_v2; + var relpos = sphereTrimesh_relpos; + var triangles = sphereTrimesh_triangles; + Transform.pointToLocalFrame(trimeshPos, trimeshQuat, spherePos, localSpherePos); + var sphereRadius = sphereShape.radius; + localSphereAABB.lowerBound.set(localSpherePos.x - sphereRadius, localSpherePos.y - sphereRadius, localSpherePos.z - sphereRadius); + localSphereAABB.upperBound.set(localSpherePos.x + sphereRadius, localSpherePos.y + sphereRadius, localSpherePos.z + sphereRadius); + trimeshShape.getTrianglesInAABB(localSphereAABB, triangles); + var v = sphereTrimesh_v; + var radiusSquared = sphereShape.radius * sphereShape.radius; + for (var i = 0; i < triangles.length; i++) for (var j = 0; j < 3; j++) { + trimeshShape.getVertex(trimeshShape.indices[3 * triangles[i] + j], v); + v.vsub(localSpherePos, relpos); + if (relpos.norm2() <= radiusSquared) { + v2.copy(v); + Transform.pointToWorldFrame(trimeshPos, trimeshQuat, v2, v); + v.vsub(spherePos, relpos); + if (justTest) return true; + var r = this.createContactEquation(sphereBody, trimeshBody, sphereShape, trimeshShape, rsi, rsj); + r.ni.copy(relpos); + r.ni.normalize(); + r.ri.copy(r.ni); + r.ri.scale(sphereShape.radius, r.ri); + r.ri.vadd(spherePos, r.ri); + r.ri.vsub(sphereBody.position, r.ri); + r.rj.copy(v); + r.rj.vsub(trimeshBody.position, r.rj); + this.result.push(r); + this.createFrictionEquationsFromContact(r, this.frictionResult); + } + } + for (var i = 0; i < triangles.length; i++) for (var j = 0; j < 3; j++) { + trimeshShape.getVertex(trimeshShape.indices[3 * triangles[i] + j], edgeVertexA); + trimeshShape.getVertex(trimeshShape.indices[3 * triangles[i] + (j + 1) % 3], edgeVertexB); + edgeVertexB.vsub(edgeVertexA, edgeVector); + localSpherePos.vsub(edgeVertexB, tmp); + var positionAlongEdgeB = tmp.dot(edgeVector); + localSpherePos.vsub(edgeVertexA, tmp); + var positionAlongEdgeA = tmp.dot(edgeVector); + if (positionAlongEdgeA > 0 && positionAlongEdgeB < 0) { + localSpherePos.vsub(edgeVertexA, tmp); + edgeVectorUnit.copy(edgeVector); + edgeVectorUnit.normalize(); + positionAlongEdgeA = tmp.dot(edgeVectorUnit); + edgeVectorUnit.scale(positionAlongEdgeA, tmp); + tmp.vadd(edgeVertexA, tmp); + var dist = tmp.distanceTo(localSpherePos); + if (dist < sphereShape.radius) { + if (justTest) return true; + var r = this.createContactEquation(sphereBody, trimeshBody, sphereShape, trimeshShape, rsi, rsj); + tmp.vsub(localSpherePos, r.ni); + r.ni.normalize(); + r.ni.scale(sphereShape.radius, r.ri); + Transform.pointToWorldFrame(trimeshPos, trimeshQuat, tmp, tmp); + tmp.vsub(trimeshBody.position, r.rj); + Transform.vectorToWorldFrame(trimeshQuat, r.ni, r.ni); + Transform.vectorToWorldFrame(trimeshQuat, r.ri, r.ri); + this.result.push(r); + this.createFrictionEquationsFromContact(r, this.frictionResult); + } + } + } + var va = sphereTrimesh_va; + var vb = sphereTrimesh_vb; + var vc = sphereTrimesh_vc; + var normal = sphereTrimesh_normal; + for (var i = 0, N = triangles.length; i !== N; i++) { + trimeshShape.getTriangleVertices(triangles[i], va, vb, vc); + trimeshShape.getNormal(triangles[i], normal); + localSpherePos.vsub(va, tmp); + var dist = tmp.dot(normal); + normal.scale(dist, tmp); + localSpherePos.vsub(tmp, tmp); + dist = tmp.distanceTo(localSpherePos); + if (Ray.pointInTriangle(tmp, va, vb, vc) && dist < sphereShape.radius) { + if (justTest) return true; + var r = this.createContactEquation(sphereBody, trimeshBody, sphereShape, trimeshShape, rsi, rsj); + tmp.vsub(localSpherePos, r.ni); + r.ni.normalize(); + r.ni.scale(sphereShape.radius, r.ri); + Transform.pointToWorldFrame(trimeshPos, trimeshQuat, tmp, tmp); + tmp.vsub(trimeshBody.position, r.rj); + Transform.vectorToWorldFrame(trimeshQuat, r.ni, r.ni); + Transform.vectorToWorldFrame(trimeshQuat, r.ri, r.ri); + this.result.push(r); + this.createFrictionEquationsFromContact(r, this.frictionResult); + } + } + triangles.length = 0; + }; + var point_on_plane_to_sphere = new Vec3(); + var plane_to_sphere_ortho = new Vec3(); + var p_s_ni = new Vec3(); + var p_s_ri = new Vec3(); + var p_s_rj = new Vec3(); + Narrowphase.prototype[Shape.types.SPHERE | Shape.types.PLANE] = Narrowphase.prototype.spherePlane = function(si, sj, xi, xj, qi, qj, bi, bj, rsi, rsj, justTest) { + p_s_ni.set(0, 0, 1); + qj.vmult(p_s_ni, p_s_ni); + p_s_ni.negate(p_s_ni); + p_s_ni.normalize(); + p_s_ni.mult(si.radius, p_s_ri); + xi.vsub(xj, point_on_plane_to_sphere); + p_s_ni.mult(p_s_ni.dot(point_on_plane_to_sphere), plane_to_sphere_ortho); + point_on_plane_to_sphere.vsub(plane_to_sphere_ortho, p_s_rj); + if (-point_on_plane_to_sphere.dot(p_s_ni) <= si.radius) { + if (justTest) return true; + var r = this.createContactEquation(bi, bj, si, sj, rsi, rsj); + r.ni.copy(p_s_ni); + r.ri.copy(p_s_ri); + r.rj.copy(p_s_rj); + var ri = r.ri; + var rj = r.rj; + ri.vadd(xi, ri); + ri.vsub(bi.position, ri); + rj.vadd(xj, rj); + rj.vsub(bj.position, rj); + this.result.push(r); + this.createFrictionEquationsFromContact(r, this.frictionResult); + } + return false; + }; + var pointInPolygon_edge = new Vec3(); + var pointInPolygon_edge_x_normal = new Vec3(); + var pointInPolygon_vtp = new Vec3(); + function pointInPolygon(verts, normal, p) { + var positiveResult = null; + var N = verts.length; + for (var i = 0; i !== N; i++) { + var v = verts[i]; + var edge = pointInPolygon_edge; + verts[(i + 1) % N].vsub(v, edge); + var edge_x_normal = pointInPolygon_edge_x_normal; + edge.cross(normal, edge_x_normal); + var vertex_to_p = pointInPolygon_vtp; + p.vsub(v, vertex_to_p); + var r = edge_x_normal.dot(vertex_to_p); + if (null === positiveResult || r > 0 && true === positiveResult || r <= 0 && false === positiveResult) { + null === positiveResult && (positiveResult = r > 0); + continue; + } + return false; + } + return true; + } + var box_to_sphere = new Vec3(); + var sphereBox_ns = new Vec3(); + var sphereBox_ns1 = new Vec3(); + var sphereBox_ns2 = new Vec3(); + var sphereBox_sides = [ new Vec3(), new Vec3(), new Vec3(), new Vec3(), new Vec3(), new Vec3() ]; + var sphereBox_sphere_to_corner = new Vec3(); + var sphereBox_side_ns = new Vec3(); + var sphereBox_side_ns1 = new Vec3(); + var sphereBox_side_ns2 = new Vec3(); + Narrowphase.prototype[Shape.types.SPHERE | Shape.types.BOX] = Narrowphase.prototype.sphereBox = function(si, sj, xi, xj, qi, qj, bi, bj, rsi, rsj, justTest) { + var v3pool = this.v3pool; + var sides = sphereBox_sides; + xi.vsub(xj, box_to_sphere); + sj.getSideNormals(sides, qj); + var R = si.radius; + var penetrating_sides = []; + var found = false; + var side_ns = sphereBox_side_ns; + var side_ns1 = sphereBox_side_ns1; + var side_ns2 = sphereBox_side_ns2; + var side_h = null; + var side_penetrations = 0; + var side_dot1 = 0; + var side_dot2 = 0; + var side_distance = null; + for (var idx = 0, nsides = sides.length; idx !== nsides && false === found; idx++) { + var ns = sphereBox_ns; + ns.copy(sides[idx]); + var h = ns.norm(); + ns.normalize(); + var dot = box_to_sphere.dot(ns); + if (dot < h + R && dot > 0) { + var ns1 = sphereBox_ns1; + var ns2 = sphereBox_ns2; + ns1.copy(sides[(idx + 1) % 3]); + ns2.copy(sides[(idx + 2) % 3]); + var h1 = ns1.norm(); + var h2 = ns2.norm(); + ns1.normalize(); + ns2.normalize(); + var dot1 = box_to_sphere.dot(ns1); + var dot2 = box_to_sphere.dot(ns2); + if (dot1 < h1 && dot1 > -h1 && dot2 < h2 && dot2 > -h2) { + var dist = Math.abs(dot - h - R); + if (null === side_distance || dist < side_distance) { + side_distance = dist; + side_dot1 = dot1; + side_dot2 = dot2; + side_h = h; + side_ns.copy(ns); + side_ns1.copy(ns1); + side_ns2.copy(ns2); + side_penetrations++; + if (justTest) return true; + } + } + } + } + if (side_penetrations) { + found = true; + var r = this.createContactEquation(bi, bj, si, sj, rsi, rsj); + side_ns.mult(-R, r.ri); + r.ni.copy(side_ns); + r.ni.negate(r.ni); + side_ns.mult(side_h, side_ns); + side_ns1.mult(side_dot1, side_ns1); + side_ns.vadd(side_ns1, side_ns); + side_ns2.mult(side_dot2, side_ns2); + side_ns.vadd(side_ns2, r.rj); + r.ri.vadd(xi, r.ri); + r.ri.vsub(bi.position, r.ri); + r.rj.vadd(xj, r.rj); + r.rj.vsub(bj.position, r.rj); + this.result.push(r); + this.createFrictionEquationsFromContact(r, this.frictionResult); + } + var rj = v3pool.get(); + var sphere_to_corner = sphereBox_sphere_to_corner; + for (var j = 0; 2 !== j && !found; j++) for (var k = 0; 2 !== k && !found; k++) for (var l = 0; 2 !== l && !found; l++) { + rj.set(0, 0, 0); + j ? rj.vadd(sides[0], rj) : rj.vsub(sides[0], rj); + k ? rj.vadd(sides[1], rj) : rj.vsub(sides[1], rj); + l ? rj.vadd(sides[2], rj) : rj.vsub(sides[2], rj); + xj.vadd(rj, sphere_to_corner); + sphere_to_corner.vsub(xi, sphere_to_corner); + if (sphere_to_corner.norm2() < R * R) { + if (justTest) return true; + found = true; + var r = this.createContactEquation(bi, bj, si, sj, rsi, rsj); + r.ri.copy(sphere_to_corner); + r.ri.normalize(); + r.ni.copy(r.ri); + r.ri.mult(R, r.ri); + r.rj.copy(rj); + r.ri.vadd(xi, r.ri); + r.ri.vsub(bi.position, r.ri); + r.rj.vadd(xj, r.rj); + r.rj.vsub(bj.position, r.rj); + this.result.push(r); + this.createFrictionEquationsFromContact(r, this.frictionResult); + } + } + v3pool.release(rj); + rj = null; + var edgeTangent = v3pool.get(); + var edgeCenter = v3pool.get(); + var r = v3pool.get(); + var orthogonal = v3pool.get(); + var dist = v3pool.get(); + var Nsides = sides.length; + for (var j = 0; j !== Nsides && !found; j++) for (var k = 0; k !== Nsides && !found; k++) if (j % 3 !== k % 3) { + sides[k].cross(sides[j], edgeTangent); + edgeTangent.normalize(); + sides[j].vadd(sides[k], edgeCenter); + r.copy(xi); + r.vsub(edgeCenter, r); + r.vsub(xj, r); + var orthonorm = r.dot(edgeTangent); + edgeTangent.mult(orthonorm, orthogonal); + var l = 0; + while (l === j % 3 || l === k % 3) l++; + dist.copy(xi); + dist.vsub(orthogonal, dist); + dist.vsub(edgeCenter, dist); + dist.vsub(xj, dist); + var tdist = Math.abs(orthonorm); + var ndist = dist.norm(); + if (tdist < sides[l].norm() && ndist < R) { + if (justTest) return true; + found = true; + var res = this.createContactEquation(bi, bj, si, sj, rsi, rsj); + edgeCenter.vadd(orthogonal, res.rj); + res.rj.copy(res.rj); + dist.negate(res.ni); + res.ni.normalize(); + res.ri.copy(res.rj); + res.ri.vadd(xj, res.ri); + res.ri.vsub(xi, res.ri); + res.ri.normalize(); + res.ri.mult(R, res.ri); + res.ri.vadd(xi, res.ri); + res.ri.vsub(bi.position, res.ri); + res.rj.vadd(xj, res.rj); + res.rj.vsub(bj.position, res.rj); + this.result.push(res); + this.createFrictionEquationsFromContact(res, this.frictionResult); + } + } + v3pool.release(edgeTangent, edgeCenter, r, orthogonal, dist); + }; + var convex_to_sphere = new Vec3(); + var sphereConvex_edge = new Vec3(); + var sphereConvex_edgeUnit = new Vec3(); + var sphereConvex_sphereToCorner = new Vec3(); + var sphereConvex_worldCorner = new Vec3(); + var sphereConvex_worldNormal = new Vec3(); + var sphereConvex_worldPoint = new Vec3(); + var sphereConvex_worldSpherePointClosestToPlane = new Vec3(); + var sphereConvex_penetrationVec = new Vec3(); + var sphereConvex_sphereToWorldPoint = new Vec3(); + Narrowphase.prototype[Shape.types.SPHERE | Shape.types.CONVEXPOLYHEDRON] = Narrowphase.prototype.sphereConvex = function(si, sj, xi, xj, qi, qj, bi, bj, rsi, rsj, justTest) { + var v3pool = this.v3pool; + xi.vsub(xj, convex_to_sphere); + var normals = sj.faceNormals; + var faces = sj.faces; + var verts = sj.vertices; + var R = si.radius; + var penetrating_sides = []; + for (var i = 0; i !== verts.length; i++) { + var v = verts[i]; + var worldCorner = sphereConvex_worldCorner; + qj.vmult(v, worldCorner); + xj.vadd(worldCorner, worldCorner); + var sphere_to_corner = sphereConvex_sphereToCorner; + worldCorner.vsub(xi, sphere_to_corner); + if (sphere_to_corner.norm2() < R * R) { + if (justTest) return true; + found = true; + var r = this.createContactEquation(bi, bj, si, sj, rsi, rsj); + r.ri.copy(sphere_to_corner); + r.ri.normalize(); + r.ni.copy(r.ri); + r.ri.mult(R, r.ri); + worldCorner.vsub(xj, r.rj); + r.ri.vadd(xi, r.ri); + r.ri.vsub(bi.position, r.ri); + r.rj.vadd(xj, r.rj); + r.rj.vsub(bj.position, r.rj); + this.result.push(r); + this.createFrictionEquationsFromContact(r, this.frictionResult); + return; + } + } + var found = false; + for (var i = 0, nfaces = faces.length; i !== nfaces && false === found; i++) { + var normal = normals[i]; + var face = faces[i]; + var worldNormal = sphereConvex_worldNormal; + qj.vmult(normal, worldNormal); + var worldPoint = sphereConvex_worldPoint; + qj.vmult(verts[face[0]], worldPoint); + worldPoint.vadd(xj, worldPoint); + var worldSpherePointClosestToPlane = sphereConvex_worldSpherePointClosestToPlane; + worldNormal.mult(-R, worldSpherePointClosestToPlane); + xi.vadd(worldSpherePointClosestToPlane, worldSpherePointClosestToPlane); + var penetrationVec = sphereConvex_penetrationVec; + worldSpherePointClosestToPlane.vsub(worldPoint, penetrationVec); + var penetration = penetrationVec.dot(worldNormal); + var worldPointToSphere = sphereConvex_sphereToWorldPoint; + xi.vsub(worldPoint, worldPointToSphere); + if (penetration < 0 && worldPointToSphere.dot(worldNormal) > 0) { + var faceVerts = []; + for (var j = 0, Nverts = face.length; j !== Nverts; j++) { + var worldVertex = v3pool.get(); + qj.vmult(verts[face[j]], worldVertex); + xj.vadd(worldVertex, worldVertex); + faceVerts.push(worldVertex); + } + if (pointInPolygon(faceVerts, worldNormal, xi)) { + if (justTest) return true; + found = true; + var r = this.createContactEquation(bi, bj, si, sj, rsi, rsj); + worldNormal.mult(-R, r.ri); + worldNormal.negate(r.ni); + var penetrationVec2 = v3pool.get(); + worldNormal.mult(-penetration, penetrationVec2); + var penetrationSpherePoint = v3pool.get(); + worldNormal.mult(-R, penetrationSpherePoint); + xi.vsub(xj, r.rj); + r.rj.vadd(penetrationSpherePoint, r.rj); + r.rj.vadd(penetrationVec2, r.rj); + r.rj.vadd(xj, r.rj); + r.rj.vsub(bj.position, r.rj); + r.ri.vadd(xi, r.ri); + r.ri.vsub(bi.position, r.ri); + v3pool.release(penetrationVec2); + v3pool.release(penetrationSpherePoint); + this.result.push(r); + this.createFrictionEquationsFromContact(r, this.frictionResult); + for (var j = 0, Nfaceverts = faceVerts.length; j !== Nfaceverts; j++) v3pool.release(faceVerts[j]); + return; + } + for (var j = 0; j !== face.length; j++) { + var v1 = v3pool.get(); + var v2 = v3pool.get(); + qj.vmult(verts[face[(j + 1) % face.length]], v1); + qj.vmult(verts[face[(j + 2) % face.length]], v2); + xj.vadd(v1, v1); + xj.vadd(v2, v2); + var edge = sphereConvex_edge; + v2.vsub(v1, edge); + var edgeUnit = sphereConvex_edgeUnit; + edge.unit(edgeUnit); + var p = v3pool.get(); + var v1_to_xi = v3pool.get(); + xi.vsub(v1, v1_to_xi); + var dot = v1_to_xi.dot(edgeUnit); + edgeUnit.mult(dot, p); + p.vadd(v1, p); + var xi_to_p = v3pool.get(); + p.vsub(xi, xi_to_p); + if (dot > 0 && dot * dot < edge.norm2() && xi_to_p.norm2() < R * R) { + if (justTest) return true; + var r = this.createContactEquation(bi, bj, si, sj, rsi, rsj); + p.vsub(xj, r.rj); + p.vsub(xi, r.ni); + r.ni.normalize(); + r.ni.mult(R, r.ri); + r.rj.vadd(xj, r.rj); + r.rj.vsub(bj.position, r.rj); + r.ri.vadd(xi, r.ri); + r.ri.vsub(bi.position, r.ri); + this.result.push(r); + this.createFrictionEquationsFromContact(r, this.frictionResult); + for (var j = 0, Nfaceverts = faceVerts.length; j !== Nfaceverts; j++) v3pool.release(faceVerts[j]); + v3pool.release(v1); + v3pool.release(v2); + v3pool.release(p); + v3pool.release(xi_to_p); + v3pool.release(v1_to_xi); + return; + } + v3pool.release(v1); + v3pool.release(v2); + v3pool.release(p); + v3pool.release(xi_to_p); + v3pool.release(v1_to_xi); + } + for (var j = 0, Nfaceverts = faceVerts.length; j !== Nfaceverts; j++) v3pool.release(faceVerts[j]); + } + } + }; + var planeBox_normal = new Vec3(); + var plane_to_corner = new Vec3(); + Narrowphase.prototype[Shape.types.PLANE | Shape.types.BOX] = Narrowphase.prototype.planeBox = function(si, sj, xi, xj, qi, qj, bi, bj, rsi, rsj, justTest) { + sj.convexPolyhedronRepresentation.material = sj.material; + sj.convexPolyhedronRepresentation.collisionResponse = sj.collisionResponse; + sj.convexPolyhedronRepresentation.id = sj.id; + return this.planeConvex(si, sj.convexPolyhedronRepresentation, xi, xj, qi, qj, bi, bj, si, sj, justTest); + }; + var planeConvex_v = new Vec3(); + var planeConvex_normal = new Vec3(); + var planeConvex_relpos = new Vec3(); + var planeConvex_projected = new Vec3(); + Narrowphase.prototype[Shape.types.PLANE | Shape.types.CONVEXPOLYHEDRON] = Narrowphase.prototype.planeConvex = function(planeShape, convexShape, planePosition, convexPosition, planeQuat, convexQuat, planeBody, convexBody, si, sj, justTest) { + var worldVertex = planeConvex_v, worldNormal = planeConvex_normal; + worldNormal.set(0, 0, 1); + planeQuat.vmult(worldNormal, worldNormal); + var numContacts = 0; + var relpos = planeConvex_relpos; + for (var i = 0; i !== convexShape.vertices.length; i++) { + worldVertex.copy(convexShape.vertices[i]); + convexQuat.vmult(worldVertex, worldVertex); + convexPosition.vadd(worldVertex, worldVertex); + worldVertex.vsub(planePosition, relpos); + var dot = worldNormal.dot(relpos); + if (dot <= 0) { + if (justTest) return true; + var r = this.createContactEquation(planeBody, convexBody, planeShape, convexShape, si, sj); + var projected = planeConvex_projected; + worldNormal.mult(worldNormal.dot(relpos), projected); + worldVertex.vsub(projected, projected); + projected.vsub(planePosition, r.ri); + r.ni.copy(worldNormal); + worldVertex.vsub(convexPosition, r.rj); + r.ri.vadd(planePosition, r.ri); + r.ri.vsub(planeBody.position, r.ri); + r.rj.vadd(convexPosition, r.rj); + r.rj.vsub(convexBody.position, r.rj); + this.result.push(r); + numContacts++; + this.enableFrictionReduction || this.createFrictionEquationsFromContact(r, this.frictionResult); + } + } + this.enableFrictionReduction && numContacts && this.createFrictionFromAverage(numContacts); + }; + var convexConvex_sepAxis = new Vec3(); + var convexConvex_q = new Vec3(); + Narrowphase.prototype[Shape.types.CONVEXPOLYHEDRON] = Narrowphase.prototype.convexConvex = function(si, sj, xi, xj, qi, qj, bi, bj, rsi, rsj, justTest, faceListA, faceListB) { + var sepAxis = convexConvex_sepAxis; + if (xi.distanceTo(xj) > si.boundingSphereRadius + sj.boundingSphereRadius) return; + if (si.findSeparatingAxis(sj, xi, qi, xj, qj, sepAxis, faceListA, faceListB)) { + var res = []; + var q = convexConvex_q; + si.clipAgainstHull(xi, qi, sj, xj, qj, sepAxis, -100, 100, res); + var numContacts = 0; + for (var j = 0; j !== res.length; j++) { + if (justTest) return true; + var r = this.createContactEquation(bi, bj, si, sj, rsi, rsj), ri = r.ri, rj = r.rj; + sepAxis.negate(r.ni); + res[j].normal.negate(q); + q.mult(res[j].depth, q); + res[j].point.vadd(q, ri); + rj.copy(res[j].point); + ri.vsub(xi, ri); + rj.vsub(xj, rj); + ri.vadd(xi, ri); + ri.vsub(bi.position, ri); + rj.vadd(xj, rj); + rj.vsub(bj.position, rj); + this.result.push(r); + numContacts++; + this.enableFrictionReduction || this.createFrictionEquationsFromContact(r, this.frictionResult); + } + this.enableFrictionReduction && numContacts && this.createFrictionFromAverage(numContacts); + } + }; + var particlePlane_normal = new Vec3(); + var particlePlane_relpos = new Vec3(); + var particlePlane_projected = new Vec3(); + Narrowphase.prototype[Shape.types.PLANE | Shape.types.PARTICLE] = Narrowphase.prototype.planeParticle = function(sj, si, xj, xi, qj, qi, bj, bi, rsi, rsj, justTest) { + var normal = particlePlane_normal; + normal.set(0, 0, 1); + bj.quaternion.vmult(normal, normal); + var relpos = particlePlane_relpos; + xi.vsub(bj.position, relpos); + var dot = normal.dot(relpos); + if (dot <= 0) { + if (justTest) return true; + var r = this.createContactEquation(bi, bj, si, sj, rsi, rsj); + r.ni.copy(normal); + r.ni.negate(r.ni); + r.ri.set(0, 0, 0); + var projected = particlePlane_projected; + normal.mult(normal.dot(xi), projected); + xi.vsub(projected, projected); + r.rj.copy(projected); + this.result.push(r); + this.createFrictionEquationsFromContact(r, this.frictionResult); + } + }; + var particleSphere_normal = new Vec3(); + Narrowphase.prototype[Shape.types.PARTICLE | Shape.types.SPHERE] = Narrowphase.prototype.sphereParticle = function(sj, si, xj, xi, qj, qi, bj, bi, rsi, rsj, justTest) { + var normal = particleSphere_normal; + normal.set(0, 0, 1); + xi.vsub(xj, normal); + var lengthSquared = normal.norm2(); + if (lengthSquared <= sj.radius * sj.radius) { + if (justTest) return true; + var r = this.createContactEquation(bi, bj, si, sj, rsi, rsj); + normal.normalize(); + r.rj.copy(normal); + r.rj.mult(sj.radius, r.rj); + r.ni.copy(normal); + r.ni.negate(r.ni); + r.ri.set(0, 0, 0); + this.result.push(r); + this.createFrictionEquationsFromContact(r, this.frictionResult); + } + }; + var cqj = new Quaternion(); + var convexParticle_local = new Vec3(); + var convexParticle_normal = new Vec3(); + var convexParticle_penetratedFaceNormal = new Vec3(); + var convexParticle_vertexToParticle = new Vec3(); + var convexParticle_worldPenetrationVec = new Vec3(); + Narrowphase.prototype[Shape.types.PARTICLE | Shape.types.CONVEXPOLYHEDRON] = Narrowphase.prototype.convexParticle = function(sj, si, xj, xi, qj, qi, bj, bi, rsi, rsj, justTest) { + var penetratedFaceIndex = -1; + var penetratedFaceNormal = convexParticle_penetratedFaceNormal; + var worldPenetrationVec = convexParticle_worldPenetrationVec; + var minPenetration = null; + var numDetectedFaces = 0; + var local = convexParticle_local; + local.copy(xi); + local.vsub(xj, local); + qj.conjugate(cqj); + cqj.vmult(local, local); + if (sj.pointIsInside(local)) { + sj.worldVerticesNeedsUpdate && sj.computeWorldVertices(xj, qj); + sj.worldFaceNormalsNeedsUpdate && sj.computeWorldFaceNormals(qj); + for (var i = 0, nfaces = sj.faces.length; i !== nfaces; i++) { + var verts = [ sj.worldVertices[sj.faces[i][0]] ]; + var normal = sj.worldFaceNormals[i]; + xi.vsub(verts[0], convexParticle_vertexToParticle); + var penetration = -normal.dot(convexParticle_vertexToParticle); + if (null === minPenetration || Math.abs(penetration) < Math.abs(minPenetration)) { + if (justTest) return true; + minPenetration = penetration; + penetratedFaceIndex = i; + penetratedFaceNormal.copy(normal); + numDetectedFaces++; + } + } + if (-1 !== penetratedFaceIndex) { + var r = this.createContactEquation(bi, bj, si, sj, rsi, rsj); + penetratedFaceNormal.mult(minPenetration, worldPenetrationVec); + worldPenetrationVec.vadd(xi, worldPenetrationVec); + worldPenetrationVec.vsub(xj, worldPenetrationVec); + r.rj.copy(worldPenetrationVec); + penetratedFaceNormal.negate(r.ni); + r.ri.set(0, 0, 0); + var ri = r.ri, rj = r.rj; + ri.vadd(xi, ri); + ri.vsub(bi.position, ri); + rj.vadd(xj, rj); + rj.vsub(bj.position, rj); + this.result.push(r); + this.createFrictionEquationsFromContact(r, this.frictionResult); + } else console.warn("Point found inside convex, but did not find penetrating face!"); + } + }; + Narrowphase.prototype[Shape.types.BOX | Shape.types.HEIGHTFIELD] = Narrowphase.prototype.boxHeightfield = function(si, sj, xi, xj, qi, qj, bi, bj, rsi, rsj, justTest) { + si.convexPolyhedronRepresentation.material = si.material; + si.convexPolyhedronRepresentation.collisionResponse = si.collisionResponse; + return this.convexHeightfield(si.convexPolyhedronRepresentation, sj, xi, xj, qi, qj, bi, bj, si, sj, justTest); + }; + var convexHeightfield_tmp1 = new Vec3(); + var convexHeightfield_tmp2 = new Vec3(); + var convexHeightfield_faceList = [ 0 ]; + Narrowphase.prototype[Shape.types.CONVEXPOLYHEDRON | Shape.types.HEIGHTFIELD] = Narrowphase.prototype.convexHeightfield = function(convexShape, hfShape, convexPos, hfPos, convexQuat, hfQuat, convexBody, hfBody, rsi, rsj, justTest) { + var data = hfShape.data, w = hfShape.elementSize, radius = convexShape.boundingSphereRadius, worldPillarOffset = convexHeightfield_tmp2, faceList = convexHeightfield_faceList; + var localConvexPos = convexHeightfield_tmp1; + Transform.pointToLocalFrame(hfPos, hfQuat, convexPos, localConvexPos); + var iMinX = Math.floor((localConvexPos.x - radius) / w) - 1, iMaxX = Math.ceil((localConvexPos.x + radius) / w) + 1, iMinY = Math.floor((localConvexPos.y - radius) / w) - 1, iMaxY = Math.ceil((localConvexPos.y + radius) / w) + 1; + if (iMaxX < 0 || iMaxY < 0 || iMinX > data.length || iMinY > data[0].length) return; + iMinX < 0 && (iMinX = 0); + iMaxX < 0 && (iMaxX = 0); + iMinY < 0 && (iMinY = 0); + iMaxY < 0 && (iMaxY = 0); + iMinX >= data.length && (iMinX = data.length - 1); + iMaxX >= data.length && (iMaxX = data.length - 1); + iMaxY >= data[0].length && (iMaxY = data[0].length - 1); + iMinY >= data[0].length && (iMinY = data[0].length - 1); + var minMax = []; + hfShape.getRectMinMax(iMinX, iMinY, iMaxX, iMaxY, minMax); + var min = minMax[0]; + var max = minMax[1]; + if (localConvexPos.z - radius > max || localConvexPos.z + radius < min) return; + for (var i = iMinX; i < iMaxX; i++) for (var j = iMinY; j < iMaxY; j++) { + var intersecting = false; + hfShape.getConvexTrianglePillar(i, j, false); + Transform.pointToWorldFrame(hfPos, hfQuat, hfShape.pillarOffset, worldPillarOffset); + convexPos.distanceTo(worldPillarOffset) < hfShape.pillarConvex.boundingSphereRadius + convexShape.boundingSphereRadius && (intersecting = this.convexConvex(convexShape, hfShape.pillarConvex, convexPos, worldPillarOffset, convexQuat, hfQuat, convexBody, hfBody, rsi, rsj, justTest, faceList, null)); + if (justTest && intersecting) return true; + hfShape.getConvexTrianglePillar(i, j, true); + Transform.pointToWorldFrame(hfPos, hfQuat, hfShape.pillarOffset, worldPillarOffset); + convexPos.distanceTo(worldPillarOffset) < hfShape.pillarConvex.boundingSphereRadius + convexShape.boundingSphereRadius && (intersecting = this.convexConvex(convexShape, hfShape.pillarConvex, convexPos, worldPillarOffset, convexQuat, hfQuat, convexBody, hfBody, rsi, rsj, justTest, faceList, null)); + if (justTest && intersecting) return true; + } + }; + var sphereHeightfield_tmp1 = new Vec3(); + var sphereHeightfield_tmp2 = new Vec3(); + Narrowphase.prototype[Shape.types.SPHERE | Shape.types.HEIGHTFIELD] = Narrowphase.prototype.sphereHeightfield = function(sphereShape, hfShape, spherePos, hfPos, sphereQuat, hfQuat, sphereBody, hfBody, rsi, rsj, justTest) { + var data = hfShape.data, radius = sphereShape.radius, w = hfShape.elementSize, worldPillarOffset = sphereHeightfield_tmp2; + var localSpherePos = sphereHeightfield_tmp1; + Transform.pointToLocalFrame(hfPos, hfQuat, spherePos, localSpherePos); + var iMinX = Math.floor((localSpherePos.x - radius) / w) - 1, iMaxX = Math.ceil((localSpherePos.x + radius) / w) + 1, iMinY = Math.floor((localSpherePos.y - radius) / w) - 1, iMaxY = Math.ceil((localSpherePos.y + radius) / w) + 1; + if (iMaxX < 0 || iMaxY < 0 || iMinX > data.length || iMinY > data[0].length) return; + iMinX < 0 && (iMinX = 0); + iMaxX < 0 && (iMaxX = 0); + iMinY < 0 && (iMinY = 0); + iMaxY < 0 && (iMaxY = 0); + iMinX >= data.length && (iMinX = data.length - 1); + iMaxX >= data.length && (iMaxX = data.length - 1); + iMaxY >= data[0].length && (iMaxY = data[0].length - 1); + iMinY >= data[0].length && (iMinY = data[0].length - 1); + var minMax = []; + hfShape.getRectMinMax(iMinX, iMinY, iMaxX, iMaxY, minMax); + var min = minMax[0]; + var max = minMax[1]; + if (localSpherePos.z - radius > max || localSpherePos.z + radius < min) return; + var result = this.result; + for (var i = iMinX; i < iMaxX; i++) for (var j = iMinY; j < iMaxY; j++) { + var numContactsBefore = result.length; + var intersecting = false; + hfShape.getConvexTrianglePillar(i, j, false); + Transform.pointToWorldFrame(hfPos, hfQuat, hfShape.pillarOffset, worldPillarOffset); + spherePos.distanceTo(worldPillarOffset) < hfShape.pillarConvex.boundingSphereRadius + sphereShape.boundingSphereRadius && (intersecting = this.sphereConvex(sphereShape, hfShape.pillarConvex, spherePos, worldPillarOffset, sphereQuat, hfQuat, sphereBody, hfBody, sphereShape, hfShape, justTest)); + if (justTest && intersecting) return true; + hfShape.getConvexTrianglePillar(i, j, true); + Transform.pointToWorldFrame(hfPos, hfQuat, hfShape.pillarOffset, worldPillarOffset); + spherePos.distanceTo(worldPillarOffset) < hfShape.pillarConvex.boundingSphereRadius + sphereShape.boundingSphereRadius && (intersecting = this.sphereConvex(sphereShape, hfShape.pillarConvex, spherePos, worldPillarOffset, sphereQuat, hfQuat, sphereBody, hfBody, sphereShape, hfShape, justTest)); + if (justTest && intersecting) return true; + var numContacts = result.length - numContactsBefore; + if (numContacts > 2) return; + } + }; + }, { + "../collision/AABB": 3, + "../collision/Ray": 10, + "../equations/ContactEquation": 20, + "../equations/FrictionEquation": 22, + "../math/Quaternion": 30, + "../math/Transform": 31, + "../math/Vec3": 32, + "../objects/Body": 33, + "../shapes/ConvexPolyhedron": 40, + "../shapes/Shape": 45, + "../solver/Solver": 49, + "../utils/Vec3Pool": 56 + } ], + 58: [ function(_dereq_, module, exports) { + module.exports = World; + var Shape = _dereq_("../shapes/Shape"); + var Vec3 = _dereq_("../math/Vec3"); + var Quaternion = _dereq_("../math/Quaternion"); + var GSSolver = _dereq_("../solver/GSSolver"); + var ContactEquation = _dereq_("../equations/ContactEquation"); + var FrictionEquation = _dereq_("../equations/FrictionEquation"); + var Narrowphase = _dereq_("./Narrowphase"); + var EventTarget = _dereq_("../utils/EventTarget"); + var ArrayCollisionMatrix = _dereq_("../collision/ArrayCollisionMatrix"); + var ObjectCollisionMatrix = _dereq_("../collision/ObjectCollisionMatrix"); + var OverlapKeeper = _dereq_("../collision/OverlapKeeper"); + var Material = _dereq_("../material/Material"); + var ContactMaterial = _dereq_("../material/ContactMaterial"); + var Body = _dereq_("../objects/Body"); + var TupleDictionary = _dereq_("../utils/TupleDictionary"); + var RaycastResult = _dereq_("../collision/RaycastResult"); + var AABB = _dereq_("../collision/AABB"); + var Ray = _dereq_("../collision/Ray"); + var NaiveBroadphase = _dereq_("../collision/NaiveBroadphase"); + function World(options) { + options = options || {}; + EventTarget.apply(this); + this.dt = -1; + this.allowSleep = !!options.allowSleep; + this.contacts = []; + this.frictionEquations = []; + this.quatNormalizeSkip = void 0 !== options.quatNormalizeSkip ? options.quatNormalizeSkip : 0; + this.quatNormalizeFast = void 0 !== options.quatNormalizeFast && options.quatNormalizeFast; + this.time = 0; + this.timeFixed = 0; + this.stepnumber = 0; + this.default_dt = 1 / 60; + this.nextId = 0; + this.gravity = new Vec3(); + options.gravity && this.gravity.copy(options.gravity); + this.broadphase = void 0 !== options.broadphase ? options.broadphase : new NaiveBroadphase(); + this.bodies = []; + this.solver = void 0 !== options.solver ? options.solver : new GSSolver(); + this.constraints = []; + this.narrowphase = new Narrowphase(this); + this.collisionMatrix = new ArrayCollisionMatrix(); + this.collisionMatrixPrevious = new ArrayCollisionMatrix(); + this.bodyOverlapKeeper = new OverlapKeeper(); + this.shapeOverlapKeeper = new OverlapKeeper(); + this.materials = []; + this.contactmaterials = []; + this.contactMaterialTable = new TupleDictionary(); + this.defaultMaterial = new Material("default"); + this.defaultContactMaterial = new ContactMaterial(this.defaultMaterial, this.defaultMaterial, { + friction: .3, + restitution: 0 + }); + this.doProfiling = false; + this.profile = { + solve: 0, + makeContactConstraints: 0, + broadphase: 0, + integrate: 0, + narrowphase: 0 + }; + this.accumulator = 0; + this.subsystems = []; + this.addBodyEvent = { + type: "addBody", + body: null + }; + this.removeBodyEvent = { + type: "removeBody", + body: null + }; + this.idToBodyMap = {}; + this.broadphase.setWorld(this); + this.substeps = 0; + this.cm = new ObjectCollisionMatrix(); + this.tm = new ObjectCollisionMatrix(); + this.triggerDic = new TupleDictionary(); + this.oldTriggerDic = new TupleDictionary(); + this.contactsDic = new TupleDictionary(); + this.oldContactsDic = new TupleDictionary(); + } + World.idToBodyMap = {}; + World.idToShapeMap = {}; + World.prototype = new EventTarget(); + var tmpAABB1 = new AABB(); + var tmpArray1 = []; + var tmpRay = new Ray(); + World.prototype.getContactMaterial = function(m1, m2) { + return this.contactMaterialTable.get(m1.id, m2.id); + }; + World.prototype.numObjects = function() { + return this.bodies.length; + }; + World.prototype.collisionMatrixTick = function() { + var temp = this.collisionMatrixPrevious; + this.collisionMatrixPrevious = this.collisionMatrix; + this.collisionMatrix = temp; + this.collisionMatrix.reset(); + this.bodyOverlapKeeper.tick(); + this.shapeOverlapKeeper.tick(); + }; + World.prototype.add = World.prototype.addBody = function(body) { + World.SLEEPING = false; + if (-1 !== this.bodies.indexOf(body)) return; + body.index = this.bodies.length; + this.bodies.push(body); + body.world = this; + body.initPosition.copy(body.position); + body.initVelocity.copy(body.velocity); + body.timeLastSleepy = this.time; + if (body instanceof Body) { + body.initAngularVelocity.copy(body.angularVelocity); + body.initQuaternion.copy(body.quaternion); + } + this.collisionMatrix.setNumObjects(this.bodies.length); + this.addBodyEvent.body = body; + this.cm.setNumObjects(this.bodies.length); + World.idToBodyMap[body.id] = body; + this.dispatchEvent(this.addBodyEvent); + }; + World.prototype.addConstraint = function(c) { + World.SLEEPING = false; + this.constraints.push(c); + }; + World.prototype.removeConstraint = function(c) { + World.SLEEPING = false; + var idx = this.constraints.indexOf(c); + -1 !== idx && this.constraints.splice(idx, 1); + }; + World.prototype.rayTest = function(from, to, result) { + result instanceof RaycastResult ? this.raycastClosest(from, to, { + skipBackfaces: true + }, result) : this.raycastAll(from, to, { + skipBackfaces: true + }, result); + }; + World.prototype.raycastAll = function(from, to, options, callback) { + options.mode = Ray.ALL; + options.from = from; + options.to = to; + options.callback = callback; + return tmpRay.intersectWorld(this, options); + }; + World.prototype.raycastAny = function(from, to, options, result) { + options.mode = Ray.ANY; + options.from = from; + options.to = to; + options.result = result; + return tmpRay.intersectWorld(this, options); + }; + World.prototype.raycastClosest = function(from, to, options, result) { + options.mode = Ray.CLOSEST; + options.from = from; + options.to = to; + options.result = result; + return tmpRay.intersectWorld(this, options); + }; + World.prototype.remove = function(body) { + World.SLEEPING = false; + body.world = null; + var n = this.bodies.length - 1, bodies = this.bodies, idx = bodies.indexOf(body); + if (-1 !== idx) { + bodies.splice(idx, 1); + for (var i = 0; i !== bodies.length; i++) bodies[i].index = i; + this.collisionMatrix.setNumObjects(n); + this.removeBodyEvent.body = body; + delete World.idToBodyMap[body.id]; + this.cm.setNumObjects(n); + this.dispatchEvent(this.removeBodyEvent); + } + }; + World.prototype.removeBody = World.prototype.remove; + World.prototype.getBodyById = function(id) { + return World.idToBodyMap[id]; + }; + World.prototype.getShapeById = function(id) { + return World.idToShapeMap[id]; + }; + World.prototype.addMaterial = function(m) { + this.materials.push(m); + }; + World.prototype.addContactMaterial = function(cmat) { + this.contactmaterials.push(cmat); + this.contactMaterialTable.set(cmat.materials[0].id, cmat.materials[1].id, cmat); + }; + "undefined" === typeof performance && (performance = {}); + if (!performance.now) { + var nowOffset = Date.now(); + performance.timing && performance.timing.navigationStart && (nowOffset = performance.timing.navigationStart); + performance.now = function() { + return Date.now() - nowOffset; + }; + } + var step_tmp1 = new Vec3(); + World.prototype.step = function(dt, timeSinceLastCalled, maxSubSteps) { + maxSubSteps = maxSubSteps || 10; + timeSinceLastCalled = timeSinceLastCalled || 0; + if (0 === timeSinceLastCalled) { + this.internalStep(dt); + this.time += dt; + this.substeps = 1; + } else { + this.accumulator += timeSinceLastCalled; + this.substeps = 0; + while (this.accumulator >= dt && this.substeps < maxSubSteps) { + this.internalStep(dt); + this.accumulator -= dt; + this.substeps++; + } + var t = this.accumulator % dt / dt; + for (var j = 0; j !== this.bodies.length; j++) { + var b = this.bodies[j]; + b.previousPosition.lerp(b.position, t, b.interpolatedPosition); + b.previousQuaternion.slerp(b.quaternion, t, b.interpolatedQuaternion); + b.previousQuaternion.normalize(); + } + this.time += timeSinceLastCalled; + } + }; + var World_step_postStepEvent = { + type: "postStep" + }, World_step_preStepEvent = { + type: "preStep" + }, World_step_collideEvent = { + type: "collide", + body: null, + contact: null + }, World_step_oldContacts = [], World_step_frictionEquationPool = [], World_step_p1 = [], World_step_p2 = [], World_step_gvec = new Vec3(), World_step_vi = new Vec3(), World_step_vj = new Vec3(), World_step_wi = new Vec3(), World_step_wj = new Vec3(), World_step_t1 = new Vec3(), World_step_t2 = new Vec3(), World_step_rixn = new Vec3(), World_step_rjxn = new Vec3(), World_step_step_q = new Quaternion(), World_step_step_w = new Quaternion(), World_step_step_wq = new Quaternion(), invI_tau_dt = new Vec3(); + World.prototype.internalStep = function(dt) { + this.dt = dt; + var world = this, that = this, contacts = this.contacts, p1 = World_step_p1, p2 = World_step_p2, N = this.numObjects(), bodies = this.bodies, solver = this.solver, gravity = this.gravity, doProfiling = this.doProfiling, profile = this.profile, DYNAMIC = Body.DYNAMIC, profilingStart, constraints = this.constraints, frictionEquationPool = World_step_frictionEquationPool, gnorm = gravity.norm(), gx = gravity.x, gy = gravity.y, gz = gravity.z, i = 0; + doProfiling && (profilingStart = performance.now()); + for (i = 0; i !== N; i++) { + var bi = bodies[i]; + if (bi.useGravity && bi.type === DYNAMIC) { + var f = bi.force, m = bi.mass; + f.x += m * gx; + f.y += m * gy; + f.z += m * gz; + } + } + for (var i = 0, Nsubsystems = this.subsystems.length; i !== Nsubsystems; i++) this.subsystems[i].update(); + doProfiling && (profilingStart = performance.now()); + p1.length = 0; + p2.length = 0; + this.broadphase.collisionPairs(this, p1, p2); + doProfiling && (profile.broadphase = performance.now() - profilingStart); + var Nconstraints = constraints.length; + for (i = 0; i !== Nconstraints; i++) { + var c = constraints[i]; + if (!c.collideConnected) for (var j = p1.length - 1; j >= 0; j -= 1) if (c.bodyA === p1[j] && c.bodyB === p2[j] || c.bodyB === p1[j] && c.bodyA === p2[j]) { + p1.splice(j, 1); + p2.splice(j, 1); + } + } + this.collisionMatrixTick(); + doProfiling && (profilingStart = performance.now()); + var oldcontacts = World_step_oldContacts; + var NoldContacts = contacts.length; + for (i = 0; i !== NoldContacts; i++) oldcontacts.push(contacts[i]); + contacts.length = 0; + var NoldFrictionEquations = this.frictionEquations.length; + for (i = 0; i !== NoldFrictionEquations; i++) frictionEquationPool.push(this.frictionEquations[i]); + this.frictionEquations.length = 0; + this.narrowphase.getContacts(p1, p2, this, contacts, oldcontacts, this.frictionEquations, frictionEquationPool); + if (0 == contacts.length && World.SLEEPING) return; + doProfiling && (profile.narrowphase = performance.now() - profilingStart); + doProfiling && (profilingStart = performance.now()); + for (var i = 0; i < this.frictionEquations.length; i++) solver.addEquation(this.frictionEquations[i]); + var ncontacts = contacts.length; + for (var k = 0; k !== ncontacts; k++) { + var c = contacts[k]; + var bi = c.bi, bj = c.bj, si = c.si, sj = c.sj; + si.material && sj.material ? si.material.restitution >= 0 && sj.material.restitution >= 0 && (c.restitution = si.material.restitution * sj.material.restitution) : bi.material && bj.material && bi.material.restitution >= 0 && bj.material.restitution >= 0 && (c.restitution = bi.material.restitution * bj.material.restitution); + solver.addEquation(c); + if (bi.allowSleep && bi.type === Body.DYNAMIC && bi.sleepState === Body.SLEEPING && bj.sleepState === Body.AWAKE && bj.type !== Body.STATIC) { + var speedSquaredB = bj.velocity.norm2() + bj.angularVelocity.norm2(); + var speedLimitSquaredB = Math.pow(bj.sleepSpeedLimit, 2); + speedSquaredB >= 2 * speedLimitSquaredB && (bi._wakeUpAfterNarrowphase = true); + } + if (bj.allowSleep && bj.type === Body.DYNAMIC && bj.sleepState === Body.SLEEPING && bi.sleepState === Body.AWAKE && bi.type !== Body.STATIC) { + var speedSquaredA = bi.velocity.norm2() + bi.angularVelocity.norm2(); + var speedLimitSquaredA = Math.pow(bi.sleepSpeedLimit, 2); + speedSquaredA >= 2 * speedLimitSquaredA && (bj._wakeUpAfterNarrowphase = true); + } + this.collisionMatrix.set(bi, bj, true); + if (!this.collisionMatrixPrevious.get(bi, bj)) { + World_step_collideEvent.body = bj; + World_step_collideEvent.contact = c; + bi.dispatchEvent(World_step_collideEvent); + World_step_collideEvent.body = bi; + bj.dispatchEvent(World_step_collideEvent); + } + this.bodyOverlapKeeper.set(bi.id, bj.id); + this.shapeOverlapKeeper.set(si.id, sj.id); + } + this.emitContactEvents(); + if (doProfiling) { + profile.makeContactConstraints = performance.now() - profilingStart; + profilingStart = performance.now(); + } + for (i = 0; i !== N; i++) { + var bi = bodies[i]; + if (bi._wakeUpAfterNarrowphase) { + bi.wakeUp(); + bi._wakeUpAfterNarrowphase = false; + } + } + var Nconstraints = constraints.length; + for (i = 0; i !== Nconstraints; i++) { + var c = constraints[i]; + c.update(); + for (var j = 0, Neq = c.equations.length; j !== Neq; j++) { + var eq = c.equations[j]; + solver.addEquation(eq); + } + } + solver.solve(dt, this); + doProfiling && (profile.solve = performance.now() - profilingStart); + solver.removeAllEquations(); + var pow = Math.pow; + for (i = 0; i !== N; i++) { + var bi = bodies[i]; + if (bi.type & DYNAMIC) { + var ld = pow(1 - bi.linearDamping, dt); + var v = bi.velocity; + v.mult(ld, v); + var av = bi.angularVelocity; + if (av) { + var ad = pow(1 - bi.angularDamping, dt); + av.mult(ad, av); + } + } + } + this.dispatchEvent(World_step_preStepEvent); + for (i = 0; i !== N; i++) { + var bi = bodies[i]; + bi.preStep && bi.preStep.call(bi); + } + doProfiling && (profilingStart = performance.now()); + var stepnumber = this.stepnumber; + var quatNormalize = stepnumber % (this.quatNormalizeSkip + 1) === 0; + var quatNormalizeFast = this.quatNormalizeFast; + for (i = 0; i !== N; i++) bodies[i].integrate(dt, quatNormalize, quatNormalizeFast); + this.clearForces(); + this.broadphase.dirty = true; + doProfiling && (profile.integrate = performance.now() - profilingStart); + this.time += dt; + this.timeFixed += dt; + this.stepnumber += 1; + this.dispatchEvent(World_step_postStepEvent); + for (i = 0; i !== N; i++) { + var bi = bodies[i]; + var postStep = bi.postStep; + postStep && postStep.call(bi); + } + if (this.allowSleep) { + for (i = 0; i !== N; i++) bodies[i].sleepTick(this.time); + World.SLEEPING = true; + for (i = 0; i !== N; i++) { + var bi = bodies[i]; + if (bi.type != Body.STATIC && !bi.isSleeping()) { + World.SLEEPING = false; + break; + } + } + } else World.SLEEPING = false; + }; + World.prototype.emitContactEvents = function() { + var additions = []; + var removals = []; + var beginContactEvent = { + type: "beginContact", + bodyA: null, + bodyB: null + }; + var endContactEvent = { + type: "endContact", + bodyA: null, + bodyB: null + }; + var beginShapeContactEvent = { + type: "beginShapeContact", + bodyA: null, + bodyB: null, + shapeA: null, + shapeB: null + }; + var endShapeContactEvent = { + type: "endShapeContact", + bodyA: null, + bodyB: null, + shapeA: null, + shapeB: null + }; + return function() { + var hasBeginContact = this.hasAnyEventListener("beginContact"); + var hasEndContact = this.hasAnyEventListener("endContact"); + (hasBeginContact || hasEndContact) && this.bodyOverlapKeeper.getDiff(additions, removals); + if (hasBeginContact) { + for (var i = 0, l = additions.length; i < l; i += 2) { + beginContactEvent.bodyA = this.getBodyById(additions[i]); + beginContactEvent.bodyB = this.getBodyById(additions[i + 1]); + this.dispatchEvent(beginContactEvent); + } + beginContactEvent.bodyA = beginContactEvent.bodyB = null; + } + if (hasEndContact) { + for (var i = 0, l = removals.length; i < l; i += 2) { + endContactEvent.bodyA = this.getBodyById(removals[i]); + endContactEvent.bodyB = this.getBodyById(removals[i + 1]); + this.dispatchEvent(endContactEvent); + } + endContactEvent.bodyA = endContactEvent.bodyB = null; + } + additions.length = removals.length = 0; + var hasBeginShapeContact = this.hasAnyEventListener("beginShapeContact"); + var hasEndShapeContact = this.hasAnyEventListener("endShapeContact"); + (hasBeginShapeContact || hasEndShapeContact) && this.shapeOverlapKeeper.getDiff(additions, removals); + if (hasBeginShapeContact) { + for (var i = 0, l = additions.length; i < l; i += 2) { + var shapeA = this.getShapeById(additions[i]); + var shapeB = this.getShapeById(additions[i + 1]); + beginShapeContactEvent.shapeA = shapeA; + beginShapeContactEvent.shapeB = shapeB; + beginShapeContactEvent.bodyA = shapeA.body; + beginShapeContactEvent.bodyB = shapeB.body; + this.dispatchEvent(beginShapeContactEvent); + } + beginShapeContactEvent.bodyA = beginShapeContactEvent.bodyB = beginShapeContactEvent.shapeA = beginShapeContactEvent.shapeB = null; + } + if (hasEndShapeContact) { + for (var i = 0, l = removals.length; i < l; i += 2) { + var shapeA = this.getShapeById(removals[i]); + var shapeB = this.getShapeById(removals[i + 1]); + endShapeContactEvent.shapeA = shapeA; + endShapeContactEvent.shapeB = shapeB; + endShapeContactEvent.bodyA = shapeA.body; + endShapeContactEvent.bodyB = shapeB.body; + this.dispatchEvent(endShapeContactEvent); + } + endShapeContactEvent.bodyA = endShapeContactEvent.bodyB = endShapeContactEvent.shapeA = endShapeContactEvent.shapeB = null; + } + }; + }(); + World.prototype.clearForces = function() { + var bodies = this.bodies; + var N = bodies.length; + for (var i = 0; i !== N; i++) { + var b = bodies[i], force = b.force, tau = b.torque; + b.force.set(0, 0, 0); + b.torque.set(0, 0, 0); + } + }; + var cc_trigger = { + type: "cc-trigger", + event: "", + selfBody: null, + otherBody: null, + selfShape: null, + otherShape: null + }; + var cc_collide = { + type: "cc-collide", + event: "", + body: null, + selfShape: null, + otherShape: null, + contacts: null + }; + var cc_oldContacts = []; + World.prototype.emitTriggeredEvents = function() { + if (0 == this.substeps) return; + var key; + var data; + var i = this.triggerDic.getLength(); + while (i--) { + key = this.triggerDic.getKeyByIndex(i); + data = this.triggerDic.getDataByKey(key); + if (null == data) continue; + var shapeA = data.si; + var shapeB = data.sj; + if (this.tm.get(shapeA, shapeB)) cc_trigger.event = "onTriggerStay"; else { + this.tm.set(shapeA, shapeB, true); + cc_trigger.event = "onTriggerEnter"; + } + cc_trigger.selfShape = shapeA; + cc_trigger.otherShape = shapeB; + cc_trigger.selfBody = shapeA.body; + cc_trigger.otherBody = shapeB.body; + shapeA.dispatchEvent(cc_trigger); + cc_trigger.selfShape = shapeB; + cc_trigger.otherShape = shapeA; + cc_trigger.selfBody = shapeB.body; + cc_trigger.otherBody = shapeA.body; + shapeB.dispatchEvent(cc_trigger); + } + i = this.oldTriggerDic.getLength(); + while (i > 0) { + i--; + key = this.oldTriggerDic.getKeyByIndex(i); + if (null != this.triggerDic.getDataByKey(key)) continue; + data = this.oldTriggerDic.getDataByKey(key); + if (null == data) continue; + var shapeA = data.si; + var shapeB = data.sj; + this.tm.set(shapeA, shapeB, false); + this.oldTriggerDic.del(shapeA.id, shapeB.id) && i--; + cc_trigger.event = "onTriggerExit"; + cc_trigger.selfShape = shapeA; + cc_trigger.otherShape = shapeB; + cc_trigger.selfBody = shapeA.body; + cc_trigger.otherBody = shapeB.body; + shapeA.dispatchEvent(cc_trigger); + cc_trigger.selfShape = shapeB; + cc_trigger.otherShape = shapeA; + cc_trigger.selfBody = shapeB.body; + cc_trigger.otherBody = shapeA.body; + shapeB.dispatchEvent(cc_trigger); + } + this.triggerDic.reset(); + }; + World.prototype.emitCollisionEvents = function() { + if (0 == this.substeps) return; + var contacts = this.contacts; + var i = this.contacts.length; + while (i--) { + var c = contacts[i]; + var si = c.si; + var sj = c.sj; + var item = this.contactsDic.get(si.id, sj.id); + null == item && (item = this.contactsDic.set(si.id, sj.id, [])); + item.push(c); + } + var key; + var data; + var i = this.contactsDic.getLength(); + while (i--) { + key = this.contactsDic.getKeyByIndex(i); + data = this.contactsDic.getDataByKey(key); + if (null == data) continue; + var si = data[0].si; + var sj = data[0].sj; + var bi = si.body; + var bj = sj.body; + if (this.cm.get(bi, bj)) cc_collide.event = "onCollisionStay"; else { + this.cm.set(bi, bj, true); + cc_collide.event = "onCollisionEnter"; + } + cc_collide.bi = bi; + cc_collide.contact = data[0]; + cc_collide.contacts = data; + cc_collide.body = bj; + cc_collide.selfShape = si; + cc_collide.otherShape = sj; + bi.dispatchEvent(cc_collide); + cc_collide.body = bi; + cc_collide.selfShape = sj; + cc_collide.otherShape = si; + bj.dispatchEvent(cc_collide); + } + var oldcontacts = cc_oldContacts; + for (i = oldcontacts.length; i--; ) { + var c = oldcontacts[i]; + var si = c.si; + var sj = c.sj; + null == this.oldContactsDic.get(si.id, sj.id) && this.oldContactsDic.set(si.id, sj.id, c); + } + i = this.oldContactsDic.getLength(); + while (i--) { + key = this.oldContactsDic.getKeyByIndex(i); + if (null == this.contactsDic.getDataByKey(key)) { + data = this.oldContactsDic.getDataByKey(key); + var si = data.si; + var sj = data.sj; + var bi = si.body; + var bj = sj.body; + if (this.cm.get(bi, bj) && (!bi.isSleeping() || !bj.isSleeping())) { + this.cm.set(bi, bj, false); + cc_collide.bi = bi; + cc_collide.contact = data; + cc_collide.event = "onCollisionExit"; + cc_collide.body = bj; + cc_collide.selfShape = si; + cc_collide.otherShape = sj; + cc_collide.contacts.length = 0; + cc_collide.contacts.push(data); + bi.dispatchEvent(cc_collide); + cc_collide.body = bi; + cc_collide.selfShape = sj; + cc_collide.otherShape = si; + bj.dispatchEvent(cc_collide); + } + } + } + this.contactsDic.reset(); + this.oldContactsDic.reset(); + World_step_oldContacts = cc_oldContacts; + cc_oldContacts = this.contacts.slice(); + this.contacts.length = 0; + }; + }, { + "../collision/AABB": 3, + "../collision/ArrayCollisionMatrix": 4, + "../collision/NaiveBroadphase": 7, + "../collision/ObjectCollisionMatrix": 8, + "../collision/OverlapKeeper": 9, + "../collision/Ray": 10, + "../collision/RaycastResult": 11, + "../equations/ContactEquation": 20, + "../equations/FrictionEquation": 22, + "../material/ContactMaterial": 25, + "../material/Material": 26, + "../math/Quaternion": 30, + "../math/Vec3": 32, + "../objects/Body": 33, + "../shapes/Shape": 45, + "../solver/GSSolver": 48, + "../utils/EventTarget": 51, + "../utils/TupleDictionary": 54, + "./Narrowphase": 57 + } ] + }, {}, [ 2 ])(2); + }); + }).call(this, "undefined" !== typeof global ? global : "undefined" !== typeof self ? self : "undefined" !== typeof window ? window : {}); + }, {} ] +}, {}, [ 10, 9 ]); \ No newline at end of file diff --git a/Layered_virtual_list_2.x/build/web-mobile/splash.85cfd.png b/Layered_virtual_list_2.x/build/web-mobile/splash.85cfd.png new file mode 100644 index 0000000..708c9eb Binary files /dev/null and b/Layered_virtual_list_2.x/build/web-mobile/splash.85cfd.png differ diff --git a/Layered_virtual_list_2.x/build/web-mobile/src/settings.bc186.js b/Layered_virtual_list_2.x/build/web-mobile/src/settings.bc186.js new file mode 100644 index 0000000..5dcb1ca --- /dev/null +++ b/Layered_virtual_list_2.x/build/web-mobile/src/settings.bc186.js @@ -0,0 +1,23 @@ +window._CCSettings = { + platform: "web-mobile", + groupList: [ + "default" + ], + collisionMatrix: [ + [ + true + ] + ], + hasResourcesBundle: false, + hasStartSceneBundle: false, + remoteBundles: [], + subpackages: [], + launchScene: "db://assets/Scene/helloworld.fire", + orientation: "", + debug: true, + jsList: [], + bundleVers: { + internal: "cb4f5", + main: "c102c" + } +}; diff --git a/Layered_virtual_list_2.x/build/web-mobile/style-desktop.dfd76.css b/Layered_virtual_list_2.x/build/web-mobile/style-desktop.dfd76.css new file mode 100644 index 0000000..7187649 --- /dev/null +++ b/Layered_virtual_list_2.x/build/web-mobile/style-desktop.dfd76.css @@ -0,0 +1,116 @@ +body { + cursor: default; + padding: 0; + border: 0; + margin: 0; + + text-align: center; + background-color: white; + font-family: Helvetica, Verdana, Arial, sans-serif; +} + +body, canvas, div { + outline: none; + -moz-user-select: none; + -webkit-user-select: none; + -ms-user-select: none; + -khtml-user-select: none; + -webkit-tap-highlight-color: rgba(0, 0, 0, 0); +} + +/* Remove spin of input type number */ +input::-webkit-outer-spin-button, +input::-webkit-inner-spin-button { + /* display: none; <- Crashes Chrome on hover */ + -webkit-appearance: none; + margin: 0; /* <-- Apparently some margin are still there even though it's hidden */ +} + +#Cocos2dGameContainer { + position: absolute; + margin: 0; + overflow: hidden; + left: 0px; + top: 0px; +} + +canvas { + background-color: rgba(0, 0, 0, 0); +} + +a:link, a:visited { + color: #000; +} + +a:active, a:hover { + color: #666; +} + +p.header { + font-size: small; +} + +p.footer { + font-size: x-small; +} + +#splash { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + + background: #171717 url(./splash.85cfd.png) no-repeat center; + background-size: 350px; +} + +.progress-bar { + background-color: #1a1a1a; + position: absolute; + left: 50%; + top: 80%; + height: 5px; + width: 300px; + margin: 0 -150px; + border-radius: 5px; + box-shadow: 0 1px 5px #000 inset, 0 1px 0 #444; +} + +.progress-bar span { + display: block; + height: 100%; + border-radius: 5px; + box-shadow: 0 1px 0 rgba(255, 255, 255, .5) inset; + transition: width .4s ease-in-out; + background-color: #3dc5de; +} + +.stripes span { + background-size: 30px 30px; + background-image: linear-gradient(135deg, rgba(255, 255, 255, .15) 25%, transparent 25%, + transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, + transparent 75%, transparent); + + animation: animate-stripes 1s linear infinite; +} + +@keyframes animate-stripes { + 0% {background-position: 0 0;} 100% {background-position: 60px 0;} +} + +h1 { + color: #444; + text-shadow: 3px 3px 15px; +} + +#GameDiv { + width: 800px; + height: 450px; + margin: 0 auto; + background: black; + position: relative; + border: 3px solid black; + border-radius: 6px; + box-shadow: 0 5px 40px #333 +} diff --git a/Layered_virtual_list_2.x/build/web-mobile/style-mobile.6e9cd.css b/Layered_virtual_list_2.x/build/web-mobile/style-mobile.6e9cd.css new file mode 100644 index 0000000..8e0fe7f --- /dev/null +++ b/Layered_virtual_list_2.x/build/web-mobile/style-mobile.6e9cd.css @@ -0,0 +1,124 @@ +html { + -ms-touch-action: none; +} + +body, canvas, div { + display: block; + outline: none; + -webkit-tap-highlight-color: rgba(0, 0, 0, 0); + + user-select: none; + -moz-user-select: none; + -webkit-user-select: none; + -ms-user-select: none; + -khtml-user-select: none; + -webkit-tap-highlight-color: rgba(0, 0, 0, 0); +} + +/* Remove spin of input type number */ +input::-webkit-outer-spin-button, +input::-webkit-inner-spin-button { + /* display: none; <- Crashes Chrome on hover */ + -webkit-appearance: none; + margin: 0; /* <-- Apparently some margin are still there even though it's hidden */ +} + +body { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + padding: 0; + border: 0; + margin: 0; + + cursor: default; + color: #888; + background-color: #333; + + text-align: center; + font-family: Helvetica, Verdana, Arial, sans-serif; + + display: flex; + flex-direction: column; + + /* fix bug: https://github.com/cocos-creator/2d-tasks/issues/791 */ + /* overflow cannot be applied in Cocos2dGameContainer, + otherwise child elements will be hidden when Cocos2dGameContainer rotated 90 deg */ + overflow: hidden; +} + +#Cocos2dGameContainer { + position: absolute; + margin: 0; + left: 0px; + top: 0px; + + display: -webkit-box; + -webkit-box-orient: horizontal; + -webkit-box-align: center; + -webkit-box-pack: center; +} + +canvas { + background-color: rgba(0, 0, 0, 0); +} + +a:link, a:visited { + color: #666; +} + +a:active, a:hover { + color: #666; +} + +p.header { + font-size: small; +} + +p.footer { + font-size: x-small; +} + +#splash { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + background: #171717 url(./splash.85cfd.png) no-repeat center; + background-size: 45%; +} + +.progress-bar { + position: absolute; + left: 27.5%; + top: 80%; + height: 3px; + padding: 2px; + width: 45%; + border-radius: 7px; + box-shadow: 0 1px 5px #000 inset, 0 1px 0 #444; +} + +.progress-bar span { + display: block; + height: 100%; + border-radius: 3px; + transition: width .4s ease-in-out; + background-color: #3dc5de; +} + +.stripes span { + background-size: 30px 30px; + background-image: linear-gradient(135deg, rgba(255, 255, 255, .15) 25%, transparent 25%, + transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, + transparent 75%, transparent); + + animation: animate-stripes 1s linear infinite; +} + +@keyframes animate-stripes { + 0% {background-position: 0 0;} 100% {background-position: 60px 0;} +} diff --git a/Layered_virtual_list_2.x/creator.d.ts b/Layered_virtual_list_2.x/creator.d.ts new file mode 100644 index 0000000..72c6e91 --- /dev/null +++ b/Layered_virtual_list_2.x/creator.d.ts @@ -0,0 +1,32073 @@ + +/** !#en +The main namespace of Cocos2d-JS, all engine core classes, functions, properties and constants are defined in this namespace. +!#zh +Cocos 引擎的主要命名空间,引擎代码中所有的类,函数,属性和常量都在这个命名空间中定义。 */ +declare namespace cc { + /** The current version of Cocos2d being used.
+ Please DO NOT remove this String, it is an important flag for bug tracking.
+ If you post a bug to forum, please attach this flag. */ + export var ENGINE_VERSION: string; + /** + !#en + Creates the speed action which changes the speed of an action, making it take longer (speed > 1) + or less (speed < 1) time.
+ Useful to simulate 'slow motion' or 'fast forward' effect. + !#zh 修改目标动作的速率。 + @param action action + @param speed speed + + @example + ```js + // change the target action speed; + var action = cc.scaleTo(0.2, 1, 0.6); + var newAction = cc.speed(action, 0.5); + ``` + */ + export function speed(action: ActionInterval, speed: number): Action; + /** + !#en Create a follow action which makes its target follows another node. + !#zh 追踪目标节点的位置。 + @param followedNode followedNode + @param rect rect + + @example + ```js + // example + // creates the action with a set boundary + var followAction = cc.follow(targetNode, cc.rect(0, 0, screenWidth * 2 - 100, screenHeight)); + node.runAction(followAction); + + // creates the action with no boundary set + var followAction = cc.follow(targetNode); + node.runAction(followAction); + ``` + */ + export function follow(followedNode: Node, rect: Rect): Action; + /** + Points setter + @param points points + */ + export function setPoints(points: any[]): void; + /** + !#en Creates an action with a Cardinal Spline array of points and tension. + !#zh 按基数样条曲线轨迹移动到目标位置。 + @param duration duration + @param points array of control points + @param tension tension + + @example + ```js + //create a cc.CardinalSplineTo + var action1 = cc.cardinalSplineTo(3, array, 0); + ``` + */ + export function cardinalSplineTo(duration: number, points: any[], tension: number): ActionInterval; + /** + update position of target + @param newPos newPos + */ + export function updatePosition(newPos: Vec2): void; + /** + !#en Creates an action with a Cardinal Spline array of points and tension. + !#zh 按基数样条曲线轨迹移动指定的距离。 + @param duration duration + @param points points + @param tension tension + */ + export function cardinalSplineBy(duration: number, points: any[], tension: number): ActionInterval; + /** + !#en Creates an action with a Cardinal Spline array of points and tension. + !#zh 按 Catmull Rom 样条曲线轨迹移动到目标位置。 + @param dt dt + @param points points + + @example + ```js + var action1 = cc.catmullRomTo(3, array); + ``` + */ + export function catmullRomTo(dt: number, points: any[]): ActionInterval; + /** + !#en Creates an action with a Cardinal Spline array of points and tension. + !#zh 按 Catmull Rom 样条曲线轨迹移动指定的距离。 + @param dt dt + @param points points + + @example + ```js + var action1 = cc.catmullRomBy(3, array); + ``` + */ + export function catmullRomBy(dt: number, points: any[]): ActionInterval; + /** + !#en + Creates the action easing object with the rate parameter.
+ From slow to fast. + !#zh 创建 easeIn 缓动对象,由慢到快。 + @param rate rate + + @example + ```js + action.easing(cc.easeIn(3.0)); + ``` + */ + export function easeIn(rate: number): any; + /** + !#en + Creates the action easing object with the rate parameter.
+ From fast to slow. + !#zh 创建 easeOut 缓动对象,由快到慢。 + @param rate rate + + @example + ```js + action.easing(cc.easeOut(3.0)); + ``` + */ + export function easeOut(rate: number): any; + /** + !#en + Creates the action easing object with the rate parameter.
+ Slow to fast then to slow. + !#zh 创建 easeInOut 缓动对象,慢到快,然后慢。 + @param rate rate + + @example + ```js + action.easing(cc.easeInOut(3.0)); + ``` + */ + export function easeInOut(rate: number): any; + /** + !#en + Creates the action easing object with the rate parameter.
+ Reference easeInExpo:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeExponentialIn 缓动对象。
+ EaseExponentialIn 是按指数函数缓动进入的动作。
+ 参考 easeInExpo:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + action.easing(cc.easeExponentialIn()); + ``` + */ + export function easeExponentialIn(): any; + /** + !#en + Creates the action easing object.
+ Reference easeOutExpo:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeExponentialOut 缓动对象。
+ EaseExponentialOut 是按指数函数缓动退出的动作。
+ 参考 easeOutExpo:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + action.easing(cc.easeExponentialOut()); + ``` + */ + export function easeExponentialOut(): any; + /** + !#en + Creates an EaseExponentialInOut action easing object.
+ Reference easeInOutExpo:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeExponentialInOut 缓动对象。
+ EaseExponentialInOut 是按指数函数缓动进入并退出的动作。
+ 参考 easeInOutExpo:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + action.easing(cc.easeExponentialInOut()); + ``` + */ + export function easeExponentialInOut(): any; + /** + !#en + Creates an EaseSineIn action.
+ Reference easeInSine:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 EaseSineIn 缓动对象。
+ EaseSineIn 是按正弦函数缓动进入的动作。
+ 参考 easeInSine:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + action.easing(cc.easeSineIn()); + ``` + */ + export function easeSineIn(): any; + /** + !#en + Creates an EaseSineOut action easing object.
+ Reference easeOutSine:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 EaseSineOut 缓动对象。
+ EaseSineIn 是按正弦函数缓动退出的动作。
+ 参考 easeOutSine:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + action.easing(cc.easeSineOut()); + ``` + */ + export function easeSineOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInOutSine:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeSineInOut 缓动对象。
+ EaseSineIn 是按正弦函数缓动进入并退出的动作。
+ 参考 easeInOutSine:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + action.easing(cc.easeSineInOut()); + ``` + */ + export function easeSineInOut(): any; + /** + !#en + Creates the action easing object with the period in radians (default is 0.3).
+ Reference easeInElastic:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeElasticIn 缓动对象。
+ EaseElasticIn 是按弹性曲线缓动进入的动作。
+ 参数 easeInElastic:http://www.zhihu.com/question/21981571/answer/19925418 + @param period period + + @example + ```js + // example + action.easing(cc.easeElasticIn(3.0)); + ``` + */ + export function easeElasticIn(period: number): any; + /** + !#en + Creates the action easing object with the period in radians (default is 0.3).
+ Reference easeOutElastic:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeElasticOut 缓动对象。
+ EaseElasticOut 是按弹性曲线缓动退出的动作。
+ 参考 easeOutElastic:http://www.zhihu.com/question/21981571/answer/19925418 + @param period period + + @example + ```js + // example + action.easing(cc.easeElasticOut(3.0)); + ``` + */ + export function easeElasticOut(period: number): any; + /** + !#en + Creates the action easing object with the period in radians (default is 0.3).
+ Reference easeInOutElastic:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeElasticInOut 缓动对象。
+ EaseElasticInOut 是按弹性曲线缓动进入并退出的动作。
+ 参考 easeInOutElastic:http://www.zhihu.com/question/21981571/answer/19925418 + @param period period + + @example + ```js + // example + action.easing(cc.easeElasticInOut(3.0)); + ``` + */ + export function easeElasticInOut(period: number): any; + /** + !#en + Creates the action easing object.
+ Eased bounce effect at the beginning. + !#zh + 创建 easeBounceIn 缓动对象。
+ EaseBounceIn 是按弹跳动作缓动进入的动作。 + + @example + ```js + // example + action.easing(cc.easeBounceIn()); + ``` + */ + export function easeBounceIn(): any; + /** + !#en + Creates the action easing object.
+ Eased bounce effect at the ending. + !#zh + 创建 easeBounceOut 缓动对象。
+ EaseBounceOut 是按弹跳动作缓动退出的动作。 + + @example + ```js + // example + action.easing(cc.easeBounceOut()); + ``` + */ + export function easeBounceOut(): any; + /** + !#en + Creates the action easing object.
+ Eased bounce effect at the begining and ending. + !#zh + 创建 easeBounceInOut 缓动对象。
+ EaseBounceInOut 是按弹跳动作缓动进入并退出的动作。 + + @example + ```js + // example + action.easing(cc.easeBounceInOut()); + ``` + */ + export function easeBounceInOut(): any; + /** + !#en + Creates the action easing object.
+ In the opposite direction to move slowly, and then accelerated to the right direction. + !#zh + 创建 easeBackIn 缓动对象。
+ easeBackIn 是在相反的方向缓慢移动,然后加速到正确的方向。
+ + @example + ```js + // example + action.easing(cc.easeBackIn()); + ``` + */ + export function easeBackIn(): any; + /** + !#en + Creates the action easing object.
+ Fast moving more than the finish, and then slowly back to the finish. + !#zh + 创建 easeBackOut 缓动对象。
+ easeBackOut 快速移动超出目标,然后慢慢回到目标点。 + + @example + ```js + // example + action.easing(cc.easeBackOut()); + ``` + */ + export function easeBackOut(): any; + /** + !#en + Creates the action easing object.
+ Begining of cc.EaseBackIn. Ending of cc.EaseBackOut. + !#zh + 创建 easeBackInOut 缓动对象。
+ + @example + ```js + // example + action.easing(cc.easeBackInOut()); + ``` + */ + export function easeBackInOut(): any; + /** + !#en + Creates the action easing object.
+ Into the 4 reference point.
+ To calculate the motion curve. + !#zh + 创建 easeBezierAction 缓动对象。
+ EaseBezierAction 是按贝塞尔曲线缓动的动作。 + @param p0 The first bezier parameter + @param p1 The second bezier parameter + @param p2 The third bezier parameter + @param p3 The fourth bezier parameter + + @example + ```js + // example + action.easing(cc.easeBezierAction(0.5, 0.5, 1.0, 1.0)); + ``` + */ + export function easeBezierAction(p0: number, p1: number, p2: number, p3: number): any; + /** + !#en + Creates the action easing object.
+ Reference easeInQuad:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuadraticActionIn 缓动对象。
+ EaseQuadraticIn是按二次函数缓动进入的动作。
+ 参考 easeInQuad:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeQuadraticActionIn()); + ``` + */ + export function easeQuadraticActionIn(): any; + /** + !#en + Creates the action easing object.
+ Reference easeOutQuad:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuadraticActionOut 缓动对象。
+ EaseQuadraticOut 是按二次函数缓动退出的动作。
+ 参考 easeOutQuad:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeQuadraticActionOut()); + ``` + */ + export function easeQuadraticActionOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInOutQuad:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuadraticActionInOut 缓动对象。
+ EaseQuadraticInOut 是按二次函数缓动进入并退出的动作。
+ 参考 easeInOutQuad:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeQuadraticActionInOut()); + ``` + */ + export function easeQuadraticActionInOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeIntQuart:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuarticActionIn 缓动对象。
+ EaseQuarticIn 是按四次函数缓动进入的动作。
+ 参考 easeIntQuart:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeQuarticActionIn()); + ``` + */ + export function easeQuarticActionIn(): any; + /** + !#en + Creates the action easing object.
+ Reference easeOutQuart:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuarticActionOut 缓动对象。
+ EaseQuarticOut 是按四次函数缓动退出的动作。
+ 参考 easeOutQuart:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.QuarticActionOut()); + ``` + */ + export function easeQuarticActionOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInOutQuart:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuarticActionInOut 缓动对象。
+ EaseQuarticInOut 是按四次函数缓动进入并退出的动作。
+ 参考 easeInOutQuart:http://www.zhihu.com/question/21981571/answer/19925418 + */ + export function easeQuarticActionInOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInQuint:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuinticActionIn 缓动对象。
+ EaseQuinticIn 是按五次函数缓动进的动作。
+ 参考 easeInQuint:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeQuinticActionIn()); + ``` + */ + export function easeQuinticActionIn(): any; + /** + !#en + Creates the action easing object.
+ Reference easeOutQuint:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuinticActionOut 缓动对象。
+ EaseQuinticOut 是按五次函数缓动退出的动作 + 参考 easeOutQuint:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeQuadraticActionOut()); + ``` + */ + export function easeQuinticActionOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInOutQuint:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuinticActionInOut 缓动对象。
+ EaseQuinticInOut是按五次函数缓动进入并退出的动作。
+ 参考 easeInOutQuint:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeQuinticActionInOut()); + ``` + */ + export function easeQuinticActionInOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInCirc:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeCircleActionIn 缓动对象。
+ EaseCircleIn是按圆形曲线缓动进入的动作。
+ 参考 easeInCirc:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeCircleActionIn()); + ``` + */ + export function easeCircleActionIn(): any; + /** + !#en + Creates the action easing object.
+ Reference easeOutCirc:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeCircleActionOut 缓动对象。
+ EaseCircleOut是按圆形曲线缓动退出的动作。
+ 参考 easeOutCirc:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + actioneasing(cc.easeCircleActionOut()); + ``` + */ + export function easeCircleActionOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInOutCirc:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeCircleActionInOut 缓动对象。
+ EaseCircleInOut 是按圆形曲线缓动进入并退出的动作。
+ 参考 easeInOutCirc:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeCircleActionInOut()); + ``` + */ + export function easeCircleActionInOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInCubic:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeCubicActionIn 缓动对象。
+ EaseCubicIn 是按三次函数缓动进入的动作。
+ 参考 easeInCubic:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeCubicActionIn()); + ``` + */ + export function easeCubicActionIn(): any; + /** + !#en + Creates the action easing object.
+ Reference easeOutCubic:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeCubicActionOut 缓动对象。
+ EaseCubicOut 是按三次函数缓动退出的动作。
+ 参考 easeOutCubic:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeCubicActionOut()); + ``` + */ + export function easeCubicActionOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInOutCubic:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeCubicActionInOut 缓动对象。
+ EaseCubicInOut是按三次函数缓动进入并退出的动作。
+ 参考 easeInOutCubic:http://www.zhihu.com/question/21981571/answer/19925418 + */ + export function easeCubicActionInOut(): any; + /** + !#en Show the Node. + !#zh 立即显示。 + + @example + ```js + // example + var showAction = cc.show(); + ``` + */ + export function show(): ActionInstant; + /** + !#en Hide the node. + !#zh 立即隐藏。 + + @example + ```js + // example + var hideAction = cc.hide(); + ``` + */ + export function hide(): ActionInstant; + /** + !#en Toggles the visibility of a node. + !#zh 显隐状态切换。 + + @example + ```js + // example + var toggleVisibilityAction = cc.toggleVisibility(); + ``` + */ + export function toggleVisibility(): ActionInstant; + /** + !#en Create a RemoveSelf object with a flag indicate whether the target should be cleaned up while removing. + !#zh 从父节点移除自身。 + @param isNeedCleanUp isNeedCleanUp + + @example + ```js + // example + var removeSelfAction = cc.removeSelf(); + ``` + */ + export function removeSelf(isNeedCleanUp ?: boolean): ActionInstant; + /** + !#en Destroy self + !#zh 创建一个销毁自身的动作。 + + @example + ```js + var destroySelfAction = cc.destroySelf(); + ``` + */ + export function destroySelf(): ActionInstant; + /** + !#en Create a FlipX action to flip or unflip the target. + !#zh X轴翻转。 + @param flip Indicate whether the target should be flipped or not + + @example + ```js + var flipXAction = cc.flipX(true); + ``` + */ + export function flipX(flip: boolean): ActionInstant; + /** + !#en Create a FlipY action to flip or unflip the target. + !#zh Y轴翻转。 + @param flip flip + + @example + ```js + var flipYAction = cc.flipY(true); + ``` + */ + export function flipY(flip: boolean): ActionInstant; + /** + !#en Creates a Place action with a position. + !#zh 放置在目标位置。 + @param pos pos + @param y y + + @example + ```js + // example + var placeAction = cc.place(cc.v2(200, 200)); + var placeAction = cc.place(200, 200); + ``` + */ + export function place(pos: Vec2|number, y?: number): ActionInstant; + /** + !#en Creates the action with the callback. + !#zh 执行回调函数。 + @param selector selector + @param selectorTarget selectorTarget + @param data data for function, it accepts all data types. + + @example + ```js + // example + // CallFunc without data + var finish = cc.callFunc(this.removeSprite, this); + + // CallFunc with data + var finish = cc.callFunc(this.removeFromParentAndCleanup, this._grossini, true); + ``` + */ + export function callFunc(selector: Function, selectorTarget?: any, data?: any): ActionInstant; + /** + !#en + Helper constructor to create an array of sequenceable actions + The created action will run actions sequentially, one after another. + !#zh 顺序执行动作,创建的动作将按顺序依次运行。 + @param actionOrActionArray actionOrActionArray + @param tempArray tempArray + + @example + ```js + // example + // create sequence with actions + var seq = cc.sequence(act1, act2); + + // create sequence with array + var seq = cc.sequence(actArray); + ``` + */ + export function sequence(actionOrActionArray: FiniteTimeAction|FiniteTimeAction[], ...tempArray: FiniteTimeAction[]): ActionInterval; + /** + !#en Creates a Repeat action. Times is an unsigned integer between 1 and pow(2,30) + !#zh 重复动作,可以按一定次数重复一个动,如果想永远重复一个动作请使用 repeatForever 动作来完成。 + @param action action + @param times times + + @example + ```js + // example + var rep = cc.repeat(cc.sequence(jump2, jump1), 5); + ``` + */ + export function repeat(action: FiniteTimeAction, times: number): ActionInterval; + /** + !#en Create a acton which repeat forever, as it runs forever, it can't be added into cc.sequence and cc.spawn. + !#zh 永远地重复一个动作,有限次数内重复一个动作请使用 repeat 动作,由于这个动作不会停止,所以不能被添加到 cc.sequence 或 cc.spawn 中。 + @param action action + + @example + ```js + // example + var repeat = cc.repeatForever(cc.rotateBy(1.0, 360)); + ``` + */ + export function repeatForever(action: FiniteTimeAction): ActionInterval; + /** + !#en Create a spawn action which runs several actions in parallel. + !#zh 同步执行动作,同步执行一组动作。 + @param actionOrActionArray actionOrActionArray + @param tempArray tempArray + + @example + ```js + // example + var action = cc.spawn(cc.jumpBy(2, cc.v2(300, 0), 50, 4), cc.rotateBy(2, 720)); + todo: It should be the direct use new + ``` + */ + export function spawn(actionOrActionArray: FiniteTimeAction|FiniteTimeAction[], ...tempArray: FiniteTimeAction[]): FiniteTimeAction; + /** + !#en + Rotates a Node object to a certain angle by modifying its angle property.
+ The direction will be decided by the shortest angle. + !#zh 旋转到目标角度,通过逐帧修改它的 angle 属性,旋转方向将由最短的角度决定。 + @param duration duration in seconds + @param dstAngle dstAngle in degrees. + + @example + ```js + // example + var rotateTo = cc.rotateTo(2, 61.0); + ``` + */ + export function rotateTo(duration: number, dstAngle: number): ActionInterval; + /** + !#en + Rotates a Node object clockwise a number of degrees by modifying its angle property. + Relative to its properties to modify. + !#zh 旋转指定的角度。 + @param duration duration in seconds + @param deltaAngle deltaAngle in degrees + + @example + ```js + // example + var actionBy = cc.rotateBy(2, 360); + ``` + */ + export function rotateBy(duration: number, deltaAngle: number): ActionInterval; + /** + !#en + Moves a Node object x,y pixels by modifying its position property.
+ x and y are relative to the position of the object.
+ Several MoveBy actions can be concurrently called, and the resulting
+ movement will be the sum of individual movements. + !#zh 移动指定的距离。 + @param duration duration in seconds + @param deltaPos deltaPos + @param deltaY deltaY + + @example + ```js + // example + var actionTo = cc.moveBy(2, cc.v2(windowSize.width - 40, windowSize.height - 40)); + ``` + */ + export function moveBy(duration: number, deltaPos: Vec2|number, deltaY?: number): ActionInterval; + /** + !#en + Moves a Node object to the position x,y. x and y are absolute coordinates by modifying its position property.
+ Several MoveTo actions can be concurrently called, and the resulting
+ movement will be the sum of individual movements. + !#zh 移动到目标位置。 + @param duration duration in seconds + @param position position + @param y y + + @example + ```js + // example + var actionBy = cc.moveTo(2, cc.v2(80, 80)); + ``` + */ + export function moveTo(duration: number, position: Vec2|number, y?: number): ActionInterval; + /** + !#en + Create a action which skews a Node object to given angles by modifying its skewX and skewY properties. + Changes to the specified value. + !#zh 偏斜到目标角度。 + @param t time in seconds + @param sx sx + @param sy sy + + @example + ```js + // example + var actionTo = cc.skewTo(2, 37.2, -37.2); + ``` + */ + export function skewTo(t: number, sx: number, sy: number): ActionInterval; + /** + !#en + Skews a Node object by skewX and skewY degrees.
+ Relative to its property modification. + !#zh 偏斜指定的角度。 + @param t time in seconds + @param sx sx skew in degrees for X axis + @param sy sy skew in degrees for Y axis + + @example + ```js + // example + var actionBy = cc.skewBy(2, 0, -90); + ``` + */ + export function skewBy(t: number, sx: number, sy: number): ActionInterval; + /** + !#en + Moves a Node object simulating a parabolic jump movement by modifying it's position property. + Relative to its movement. + !#zh 用跳跃的方式移动指定的距离。 + @param duration duration + @param position position + @param y y + @param height height + @param jumps jumps + + @example + ```js + // example + var actionBy = cc.jumpBy(2, cc.v2(300, 0), 50, 4); + var actionBy = cc.jumpBy(2, 300, 0, 50, 4); + ``` + */ + export function jumpBy(duration: number, position: Vec2|number, y?: number, height?: number, jumps?: number): ActionInterval; + /** + !#en + Moves a Node object to a parabolic position simulating a jump movement by modifying its position property.
+ Jump to the specified location. + !#zh 用跳跃的方式移动到目标位置。 + @param duration duration + @param position position + @param y y + @param height height + @param jumps jumps + + @example + ```js + // example + var actionTo = cc.jumpTo(2, cc.v2(300, 300), 50, 4); + var actionTo = cc.jumpTo(2, 300, 300, 50, 4); + ``` + */ + export function jumpTo(duration: number, position: Vec2|number, y?: number, height?: number, jumps?: number): ActionInterval; + /** + !#en + An action that moves the target with a cubic Bezier curve by a certain distance. + Relative to its movement. + !#zh 按贝赛尔曲线轨迹移动指定的距离。 + @param t time in seconds + @param c Array of points + + @example + ```js + // example + var bezier = [cc.v2(0, windowSize.height / 2), cc.v2(300, -windowSize.height / 2), cc.v2(300, 100)]; + var bezierForward = cc.bezierBy(3, bezier); + ``` + */ + export function bezierBy(t: number, c: Vec2[]): ActionInterval; + /** + !#en An action that moves the target with a cubic Bezier curve to a destination point. + !#zh 按贝赛尔曲线轨迹移动到目标位置。 + @param t t + @param c Array of points + + @example + ```js + // example + var bezier = [cc.v2(0, windowSize.height / 2), cc.v2(300, -windowSize.height / 2), cc.v2(300, 100)]; + var bezierTo = cc.bezierTo(2, bezier); + ``` + */ + export function bezierTo(t: number, c: Vec2[]): ActionInterval; + /** + !#en Scales a Node object to a zoom factor by modifying it's scale property. + !#zh 将节点大小缩放到指定的倍数。 + @param duration duration + @param sx scale parameter in X + @param sy scale parameter in Y, if Null equal to sx + + @example + ```js + // example + // It scales to 0.5 in both X and Y. + var actionTo = cc.scaleTo(2, 0.5); + + // It scales to 0.5 in x and 2 in Y + var actionTo = cc.scaleTo(2, 0.5, 2); + ``` + */ + export function scaleTo(duration: number, sx: number, sy?: number): ActionInterval; + /** + !#en + Scales a Node object a zoom factor by modifying it's scale property. + Relative to its changes. + !#zh 按指定的倍数缩放节点大小。 + @param duration duration in seconds + @param sx sx scale parameter in X + @param sy sy scale parameter in Y, if Null equal to sx + + @example + ```js + // example without sy, it scales by 2 both in X and Y + var actionBy = cc.scaleBy(2, 2); + + //example with sy, it scales by 0.25 in X and 4.5 in Y + var actionBy2 = cc.scaleBy(2, 0.25, 4.5); + ``` + */ + export function scaleBy(duration: number, sx: number, sy?: number|void): ActionInterval; + /** + !#en Blinks a Node object by modifying it's visible property. + !#zh 闪烁(基于透明度)。 + @param duration duration in seconds + @param blinks blinks in times + + @example + ```js + // example + var action = cc.blink(2, 10); + ``` + */ + export function blink(duration: number, blinks: number): ActionInterval; + /** + !#en + Fades an object that implements the cc.RGBAProtocol protocol. + It modifies the opacity from the current value to a custom one. + !#zh 修改透明度到指定值。 + @param duration duration + @param opacity 0-255, 0 is transparent + + @example + ```js + // example + var action = cc.fadeTo(1.0, 0); + ``` + */ + export function fadeTo(duration: number, opacity: number): ActionInterval; + /** + !#en Fades In an object that implements the cc.RGBAProtocol protocol. It modifies the opacity from 0 to 255. + !#zh 渐显效果。 + @param duration duration in seconds + + @example + ```js + //example + var action = cc.fadeIn(1.0); + ``` + */ + export function fadeIn(duration: number): ActionInterval; + /** + !#en Fades Out an object that implements the cc.RGBAProtocol protocol. It modifies the opacity from 255 to 0. + !#zh 渐隐效果。 + @param d duration in seconds + + @example + ```js + // example + var action = cc.fadeOut(1.0); + ``` + */ + export function fadeOut(d: number): ActionInterval; + /** + !#en Tints a Node that implements the cc.NodeRGB protocol from current tint to a custom one. + !#zh 修改颜色到指定值。 + @param duration duration + @param red 0-255 + @param green 0-255 + @param blue 0-255 + + @example + ```js + // example + var action = cc.tintTo(2, 255, 0, 255); + ``` + */ + export function tintTo(duration: number, red: number, green: number, blue: number): ActionInterval; + /** + !#en + Tints a Node that implements the cc.NodeRGB protocol from current tint to a custom one. + Relative to their own color change. + !#zh 按照指定的增量修改颜色。 + @param duration duration in seconds + @param deltaRed deltaRed + @param deltaGreen deltaGreen + @param deltaBlue deltaBlue + + @example + ```js + // example + var action = cc.tintBy(2, -127, -255, -127); + ``` + */ + export function tintBy(duration: number, deltaRed: number, deltaGreen: number, deltaBlue: number): ActionInterval; + /** + !#en Delays the action a certain amount of seconds. + !#zh 延迟指定的时间量。 + @param d duration in seconds + + @example + ```js + // example + var delay = cc.delayTime(1); + ``` + */ + export function delayTime(d: number): ActionInterval; + /** + !#en Executes an action in reverse order, from time=duration to time=0. + !#zh 反转目标动作的时间轴。 + @param action action + + @example + ```js + // example + var reverse = cc.reverseTime(this); + ``` + */ + export function reverseTime(action: FiniteTimeAction): ActionInterval; + /** + !#en Create an action with the specified action and forced target. + !#zh 用已有动作和一个新的目标节点创建动作。 + @param target target + @param action action + */ + export function targetedAction(target: Node, action: FiniteTimeAction): ActionInterval; + /** + + @param target the target to animate + */ + export function tween (target?: T) : Tween; + /** !#en This is a Easing instance. + !#zh 这是一个 Easing 类实例。 */ + export var easing: Easing; + /** + !#en + Outputs an error message to the Cocos Creator Console (editor) or Web Console (runtime).
+ - In Cocos Creator, error is red.
+ - In Chrome, error have a red icon along with red message text.
+ !#zh + 输出错误消息到 Cocos Creator 编辑器的 Console 或运行时页面端的 Console 中。
+ - 在 Cocos Creator 中,错误信息显示是红色的。
+ - 在 Chrome 中,错误信息有红色的图标以及红色的消息文本。
+ @param msg A JavaScript string containing zero or more substitution strings. + @param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output. + */ + export function error(msg: any, ...subst: any[]): void; + /** + !#en + Outputs a warning message to the Cocos Creator Console (editor) or Web Console (runtime). + - In Cocos Creator, warning is yellow. + - In Chrome, warning have a yellow warning icon with the message text. + !#zh + 输出警告消息到 Cocos Creator 编辑器的 Console 或运行时 Web 端的 Console 中。
+ - 在 Cocos Creator 中,警告信息显示是黄色的。
+ - 在 Chrome 中,警告信息有着黄色的图标以及黄色的消息文本。
+ @param msg A JavaScript string containing zero or more substitution strings. + @param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output. + */ + export function warn(msg: any, ...subst: any[]): void; + /** + !#en Outputs a message to the Cocos Creator Console (editor) or Web Console (runtime). + !#zh 输出一条消息到 Cocos Creator 编辑器的 Console 或运行时 Web 端的 Console 中。 + @param msg A JavaScript string containing zero or more substitution strings. + @param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output. + */ + export function log(msg: string|any, ...subst: any[]): void; + /** !#en Director + !#zh 导演类。 */ + export var director: Director; + /** !#en This is a Game instance. + !#zh 这是一个 Game 类的实例,包含游戏主体信息并负责驱动游戏的游戏对象。。 */ + export var game: Game; + /** + !#en + Rotates a Node object to a certain angle by modifying its quternion property.
+ The direction will be decided by the shortest angle. + !#zh 旋转到目标角度,通过逐帧修改它的 quternion 属性,旋转方向将由最短的角度决定。 + @param duration duration in seconds + @param dstAngleX dstAngleX in degrees. + @param dstAngleY dstAngleY in degrees. + @param dstAngleZ dstAngleZ in degrees. + + @example + ```js + // example + var rotate3DTo = cc.rotate3DTo(2, cc.v3(0, 180, 0)); + ``` + */ + export function rotate3DTo(duration: number, dstAngleX: number|Vec3|Quat, dstAngleY?: number, dstAngleZ?: number): ActionInterval; + /** + !#en + Rotates a Node object counter clockwise a number of degrees by modifying its quaternion property. + Relative to its properties to modify. + !#zh 旋转指定的 3D 角度。 + @param duration duration in seconds + @param deltaAngleX deltaAngleX in degrees + @param deltaAngleY deltaAngleY in degrees + @param deltaAngleZ deltaAngleZ in degrees + + @example + ```js + // example + var actionBy = cc.rotate3DBy(2, cc.v3(0, 360, 0)); + ``` + */ + export function rotate3DBy(duration: number, deltaAngleX: number|Vec3, deltaAngleY?: number, deltaAngleZ?: number): ActionInterval; + export var assetManager: AssetManager; + /** !#en + cc.resources is a bundle and controls all asset under assets/resources + + !#zh + cc.resources 是一个 bundle,用于管理所有在 assets/resources 下的资源 */ + export var resources: AssetManager.Bundle; + /** !#en The System event singleton for global usage + !#zh 系统事件单例,方便全局使用 */ + export var systemEvent: SystemEvent; + /** + Finds a node by hierarchy path, the path is case-sensitive. + It will traverse the hierarchy by splitting the path using '/' character. + This function will still returns the node even if it is inactive. + It is recommended to not use this function every frame instead cache the result at startup. + @param path path + @param referenceNode referenceNode + */ + export function find(path: string, referenceNode?: Node): Node; + /** + !#en Defines a CCClass using the given specification, please see [Class](/docs/editors_and_tools/creator-chapters/scripting/class.html) for details. + !#zh 定义一个 CCClass,传入参数必须是一个包含类型参数的字面量对象,具体用法请查阅[类型定义](/docs/creator/scripting/class.html)。 + @param options options + + @example + ```js + // define base class + var Node = cc.Class(); + + // define sub class + var Sprite = cc.Class({ + name: 'Sprite', + extends: Node, + + ctor: function () { + this.url = ""; + this.id = 0; + }, + + statics: { + // define static members + count: 0, + getBounds: function (spriteList) { + // compute bounds... + } + }, + + properties { + width: { + default: 128, + type: cc.Integer, + tooltip: 'The width of sprite' + }, + height: 128, + size: { + get: function () { + return cc.v2(this.width, this.height); + } + } + }, + + load: function () { + // load this.url... + }; + }); + + // instantiate + + var obj = new Sprite(); + obj.url = 'sprite.png'; + obj.load(); + ``` + */ + export function Class(options?: {name?: string; extends?: Function; ctor?: Function; __ctor__?: Function; properties?: any; statics?: any; mixins?: Function[]; editor?: {executeInEditMode?: boolean; requireComponent?: Function; menu?: string; executionOrder?: number; disallowMultiple?: boolean; playOnFocus?: boolean; inspector?: string; icon?: string; help?: string; }; update?: Function; lateUpdate?: Function; onLoad?: Function; start?: Function; onEnable?: Function; onDisable?: Function; onDestroy?: Function; onFocusInEditor?: Function; onLostFocusInEditor?: Function; resetInEditor?: Function; onRestore?: Function; _getLocalBounds?: Function; }): Function; + /** + !#en + Define an enum type.
+ If a enum item has a value of -1, it will be given an Integer number according to it's order in the list.
+ Otherwise it will use the value specified by user who writes the enum definition. + + !#zh + 定义一个枚举类型。
+ 用户可以把枚举值设为任意的整数,如果设为 -1,系统将会分配为上一个枚举值 + 1。 + @param obj a JavaScript literal object containing enum names and values, or a TypeScript enum type + + @example + ```js + // JavaScript: + + var WrapMode = cc.Enum({ + Repeat: -1, + Clamp: -1 + }); + + // Texture.WrapMode.Repeat == 0 + // Texture.WrapMode.Clamp == 1 + // Texture.WrapMode[0] == "Repeat" + // Texture.WrapMode[1] == "Clamp" + + var FlagType = cc.Enum({ + Flag1: 1, + Flag2: 2, + Flag3: 4, + Flag4: 8, + }); + + var AtlasSizeList = cc.Enum({ + 128: 128, + 256: 256, + 512: 512, + 1024: 1024, + }); + + // TypeScript: + + // If used in TypeScript, just define a TypeScript enum: + enum Direction { + Up, + Down, + Left, + Right + } + + // If you need to inspect the enum in Properties panel, you can call cc.Enum: + const {ccclass, property} = cc._decorator; + + @ccclass + class NewScript extends cc.Component { + @property({ + type: cc.Enum(Direction) // call cc.Enum + }) + direction: Direction = Direction.Up; + } + + ``` + */ + export function Enum(obj: T): T; + /** + + @param touches touches + */ + export function handleTouchesBegin(touches: any[]): void; + /** + + @param touches touches + */ + export function handleTouchesMove(touches: any[]): void; + /** + + @param touches touches + */ + export function handleTouchesEnd(touches: any[]): void; + /** + + @param touches touches + */ + export function handleTouchesCancel(touches: any[]): void; + /** + + @param touches touches + */ + export function getSetOfTouchesEndOrCancel(touches: any[]): any[]; + /** + + @param touch touch + */ + export function getPreTouch(touch: Touch): Touch; + /** + + @param touch touch + */ + export function setPreTouch(touch: Touch): void; + /** + + @param tx tx + @param ty ty + @param pos pos + */ + export function getTouchByXY(tx: number, ty: number, pos: Vec2): Touch; + /** + + @param location location + @param pos pos + @param eventType eventType + */ + export function getMouseEvent(location: Vec2, pos: Vec2, eventType: number): Event.EventMouse; + /** + + @param event event + @param pos pos + */ + export function getPointByEvent(event: Touch, pos: Vec2): Vec2; + /** + + @param event event + @param pos pos + */ + export function getTouchesByEvent(event: Touch, pos: Vec2): any[]; + /** + + @param element element + */ + export function registerSystemEvent(element: HTMLElement): void; + /** + + @param dt dt + */ + export function update(dt: number): void; + /** + !#en + Checks whether the object is non-nil and not yet destroyed.
+ When an object's `destroy` is called, it is actually destroyed after the end of this frame. + So `isValid` will return false from the next frame, while `isValid` in the current frame will still be true. + If you want to determine whether the current frame has called `destroy`, use `cc.isValid(obj, true)`, + but this is often caused by a particular logical requirements, which is not normally required. + + !#zh + 检查该对象是否不为 null 并且尚未销毁。
+ 当一个对象的 `destroy` 调用以后,会在这一帧结束后才真正销毁。因此从下一帧开始 `isValid` 就会返回 false,而当前帧内 `isValid` 仍然会是 true。如果希望判断当前帧是否调用过 `destroy`,请使用 `cc.isValid(obj, true)`,不过这往往是特殊的业务需求引起的,通常情况下不需要这样。 + @param value value + @param strictMode If true, Object called destroy() in this frame will also treated as invalid. + + @example + ```js + var node = new cc.Node(); + cc.log(cc.isValid(node)); // true + node.destroy(); + cc.log(cc.isValid(node)); // true, still valid in this frame + // after a frame... + cc.log(cc.isValid(node)); // false, destroyed in the end of last frame + ``` + */ + export function isValid(value: any, strictMode?: boolean): boolean; + /** !#en cc.view is the shared view object. + !#zh cc.view 是全局的视图对象。 */ + export var view: View; + /** !#en cc.winSize is the alias object for the size of the current game window. + !#zh cc.winSize 为当前的游戏窗口的大小。 */ + export var winSize: Size; + /** Specify that the input value must be integer in Inspector. + Also used to indicates that the elements in array should be type integer. */ + export var Integer: string; + /** Indicates that the elements in array should be type double. */ + export var Float: string; + /** Indicates that the elements in array should be type boolean. */ + export var Boolean: string; + /** Indicates that the elements in array should be type string. */ + export var String: string; + /** + !#en Deserialize json to cc.Asset + !#zh 将 JSON 反序列化为对象实例。 + @param data the serialized cc.Asset json string or json object. + @param details additional loading result + @param options options + */ + export function deserialize(data: string|any, details?: Details, options?: any): any; + /** + !#en Clones the object `original` and returns the clone, or instantiate a node from the Prefab. + !#zh 克隆指定的任意类型的对象,或者从 Prefab 实例化出新节点。 + + (Instantiate 时,function 和 dom 等非可序列化对象会直接保留原有引用,Asset 会直接进行浅拷贝,可序列化类型会进行深拷贝。) + @param original An existing object that you want to make a copy of. + + @example + ```js + // instantiate node from prefab + var scene = cc.director.getScene(); + var node = cc.instantiate(prefabAsset); + node.parent = scene; + // clone node + var scene = cc.director.getScene(); + var node = cc.instantiate(targetNode); + node.parent = scene; + ``` + */ + export function instantiate(original: Prefab): Node; + export function instantiate(original: T): T; + /** + !#en + The convenience method to create a new {{#crossLink "Color/Color:method"}}cc.Color{{/crossLink}} + Alpha channel is optional. Default value is 255. + + !#zh + 通过该方法来创建一个新的 {{#crossLink "Color/Color:method"}}cc.Color{{/crossLink}} 对象。 + Alpha 通道是可选的。默认值是 255。 + @param r r + @param g g + @param b b + @param a a + + @example + ```js + ----------------------- + // 1. All channels seperately as parameters + var color1 = new cc.Color(255, 255, 255, 255); + // 2. Convert a hex string to a color + var color2 = new cc.Color("#000000"); + // 3. An color object as parameter + var color3 = new cc.Color({r: 255, g: 255, b: 255, a: 255}); + + ``` + */ + export function color(r?: number, g?: number, b?: number, a?: number): Color; + /** + !#en The convenience method to create a new {{#crossLink "Mat4"}}cc.Mat4{{/crossLink}}. + !#zh 通过该简便的函数进行创建 {{#crossLink "Mat4"}}cc.Mat4{{/crossLink}} 对象。 + @param m00 Component in column 0, row 0 position (index 0) + @param m01 Component in column 0, row 1 position (index 1) + @param m02 Component in column 0, row 2 position (index 2) + @param m03 Component in column 0, row 3 position (index 3) + @param m10 Component in column 1, row 0 position (index 4) + @param m11 Component in column 1, row 1 position (index 5) + @param m12 Component in column 1, row 2 position (index 6) + @param m13 Component in column 1, row 3 position (index 7) + @param m20 Component in column 2, row 0 position (index 8) + @param m21 Component in column 2, row 1 position (index 9) + @param m22 Component in column 2, row 2 position (index 10) + @param m23 Component in column 2, row 3 position (index 11) + @param m30 Component in column 3, row 0 position (index 12) + @param m31 Component in column 3, row 1 position (index 13) + @param m32 Component in column 3, row 2 position (index 14) + @param m33 Component in column 3, row 3 position (index 15) + */ + export function mat4(m00?: number, m01?: number, m02?: number, m03?: number, m10?: number, m11?: number, m12?: number, m13?: number, m20?: number, m21?: number, m22?: number, m23?: number, m30?: number, m31?: number, m32?: number, m33?: number): Mat4; + /** + !#en The convenience method to create a new {{#crossLink "Quat"}}cc.Quat{{/crossLink}}. + !#zh 通过该简便的函数进行创建 {{#crossLink "Quat"}}cc.Quat{{/crossLink}} 对象。 + @param x x + @param y y + @param z z + @param w w + */ + export function quat(x?: number|any, y?: number, z?: number, w?: number): Quat; + /** + !#en + The convenience method to create a new Rect. + see {{#crossLink "Rect/Rect:method"}}cc.Rect{{/crossLink}} + !#zh + 该方法用来快速创建一个新的矩形。{{#crossLink "Rect/Rect:method"}}cc.Rect{{/crossLink}} + @param x x + @param y y + @param w w + @param h h + + @example + ```js + var a = new cc.Rect(0 , 0, 10, 0); + ``` + */ + export function rect(x?: number, y?: number, w?: number, h?: number): Rect; + /** + !#en + Helper function that creates a cc.Size.
+ Please use cc.p or cc.v2 instead, it will soon replace cc.Size. + !#zh + 创建一个 cc.Size 对象的帮助函数。
+ 注意:可以使用 cc.p 或者是 cc.v2 代替,它们将很快取代 cc.Size。 + @param w width or a size object + @param h height + + @example + ```js + var size1 = cc.size(); + var size2 = cc.size(100,100); + var size3 = cc.size(size2); + var size4 = cc.size({width: 100, height: 100}); + + ``` + */ + export function size(w: number|Size, h?: number): Size; + export var EPSILON: number; + /** + Clamps a value between a minimum float and maximum float value. + @param val val + @param min min + @param max max + */ + export function clamp(val: number, min: number, max: number): number; + /** + Clamps a value between 0 and 1. + @param val val + */ + export function clamp01(val: number): number; + /** + + @param from from + @param to to + @param ratio the interpolation coefficient + */ + export function lerp(from: number, to: number, ratio: number): number; + export function random(): void; + /** + Returns a floating-point random number between min (inclusive) and max (exclusive). + @param min min + @param max max + */ + export function randomRange(min: number, max: number): number; + /** + Returns a random integer between min (inclusive) and max (exclusive). + @param min min + @param max max + */ + export function randomRangeInt(min: number, max: number): number; + /** + Linear congruential generator using Hull-Dobell Theorem. + @param seed the random seed + */ + export function pseudoRandom(seed: number): number; + /** + Returns a floating-point pseudo-random number between min (inclusive) and max (exclusive). + @param seed seed + @param min min + @param max max + */ + export function pseudoRandomRange(seed: number, min: number, max: number): number; + /** + Returns a pseudo-random integer between min (inclusive) and max (exclusive). + @param seed seed + @param min min + @param max max + */ + export function pseudoRandomRangeInt(seed: number, min: number, max: number): number; + /** + Returns the next power of two for the value + @param val val + */ + export function nextPow2(val: number): number; + /** + Returns float remainder for t / length + @param t time start at 0 + @param length time of one cycle + */ + export function repeat(t: number, length: number): number; + /** + Returns time wrapped in ping-pong mode + @param t time start at 0 + @param length time of one cycle + */ + export function repeat(t: number, length: number): number; + /** + Returns ratio of a value within a given range + @param from start value + @param to end value + @param value given value + */ + export function repeat(from: number, to: number, value: number): number; + /** + Returns -1, 0, +1 depending on sign of x. + @param v v + */ + export function sign(v: number): void; + /** + !#en The convenience method to create a new {{#crossLink "Vec2"}}cc.Vec2{{/crossLink}}. + !#zh 通过该简便的函数进行创建 {{#crossLink "Vec2"}}cc.Vec2{{/crossLink}} 对象。 + @param x x + @param y y + + @example + ```js + var v1 = cc.v2(); + var v2 = cc.v2(0, 0); + var v3 = cc.v2(v2); + var v4 = cc.v2({x: 100, y: 100}); + ``` + */ + export function v2(x?: number|any, y?: number): Vec2; + /** + !#en The convenience method to create a new {{#crossLink "Vec3"}}cc.Vec3{{/crossLink}}. + !#zh 通过该简便的函数进行创建 {{#crossLink "Vec3"}}cc.Vec3{{/crossLink}} 对象。 + @param x x + @param y y + @param z z + + @example + ```js + var v1 = cc.v3(); + var v2 = cc.v3(0, 0, 0); + var v3 = cc.v3(v2); + var v4 = cc.v3({x: 100, y: 100, z: 0}); + ``` + */ + export function v3(x?: number|any, y?: number, z?: number): Vec3; + export var dynamicAtlasManager: DynamicAtlasManager; + /** !#en The matrix storage */ + export var matrix: any[]; + /** + !#en Get an element + @param i i + @param j j + */ + export function get(i: number, j: number): number; + /** + !#en Set an element + @param i i + @param j j + @param value value + */ + export function set(i: number, j: number, value: boolean): void; + /** + !#en Sets all elements to zero + */ + export function reset(): void; + /** !#en Base class cc.Action for action classes. + !#zh Action 类是所有动作类型的基类。 */ + export class Action { + /** + !#en + to copy object with deep copy. + returns a clone of action. + !#zh 返回一个克隆的动作。 + */ + clone(): Action; + /** + !#en + return true if the action has finished. + !#zh 如果动作已完成就返回 true。 + */ + isDone(): boolean; + /** + !#en get the target. + !#zh 获取当前目标节点。 + */ + getTarget(): Node; + /** + !#en The action will modify the target properties. + !#zh 设置目标节点。 + @param target target + */ + setTarget(target: Node): void; + /** + !#en get the original target. + !#zh 获取原始目标节点。 + */ + getOriginalTarget(): Node; + /** + !#en get tag number. + !#zh 获取用于识别动作的标签。 + */ + getTag(): number; + /** + !#en set tag number. + !#zh 设置标签,用于识别动作。 + @param tag tag + */ + setTag(tag: number): void; + /** !#en Default Action tag. + !#zh 默认动作标签。 */ + static TAG_INVALID: number; + } + /** !#en + Base class actions that do have a finite time duration.
+ Possible actions:
+ - An action with a duration of 0 seconds.
+ - An action with a duration of 35.5 seconds. + + Infinite time actions are valid + !#zh 有限时间动作,这种动作拥有时长 duration 属性。 */ + export class FiniteTimeAction extends Action { + /** + !#en get duration of the action. (seconds). + !#zh 获取动作以秒为单位的持续时间。 + */ + getDuration(): number; + /** + !#en set duration of the action. (seconds). + !#zh 设置动作以秒为单位的持续时间。 + @param duration duration + */ + setDuration(duration: number): void; + /** + !#en + Returns a reversed action.
+ For example:
+ - The action will be x coordinates of 0 move to 100.
+ - The reversed action will be x of 100 move to 0. + - Will be rewritten + !#zh 返回一个新的动作,执行与原动作完全相反的动作。 + */ + reverse(): void; + /** + !#en + to copy object with deep copy. + returns a clone of action. + !#zh 返回一个克隆的动作。 + */ + clone(): FiniteTimeAction; + } + /** !#en Instant actions are immediate actions. They don't have a duration like the ActionInterval actions. + !#zh 即时动作,这种动作立即就会执行,继承自 FiniteTimeAction。 */ + export class ActionInstant extends FiniteTimeAction { + } + /** !#en +

An interval action is an action that takes place within a certain period of time.
+ It has an start time, and a finish time. The finish time is the parameter
+ duration plus the start time.

+ +

These CCActionInterval actions have some interesting properties, like:
+ - They can run normally (default)
+ - They can run reversed with the reverse method
+ - They can run with the time altered with the Accelerate, AccelDeccel and Speed actions.

+ +

For example, you can simulate a Ping Pong effect running the action normally and
+ then running it again in Reverse mode.

+ !#zh 时间间隔动作,这种动作在已定时间内完成,继承 FiniteTimeAction。 */ + export class ActionInterval extends FiniteTimeAction { + /** + !#en Implementation of ease motion. + !#zh 缓动运动。 + @param easeObj easeObj + + @example + ```js + action.easing(cc.easeIn(3.0)); + ``` + */ + easing(easeObj: any): ActionInterval; + /** + !#en + Repeats an action a number of times. + To repeat an action forever use the CCRepeatForever action. + !#zh 重复动作可以按一定次数重复一个动作,使用 RepeatForever 动作来永远重复一个动作。 + @param times times + */ + repeat(times: number): ActionInterval; + /** + !#en + Repeats an action for ever.
+ To repeat the an action for a limited number of times use the Repeat action.
+ !#zh 永远地重复一个动作,有限次数内重复一个动作请使用 Repeat 动作。 + */ + repeatForever(): ActionInterval; + } + /** !#en + cc.ActionManager is a class that can manage actions.
+ Normally you won't need to use this class directly. 99% of the cases you will use the CCNode interface, + which uses this class's singleton object. + But there are some cases where you might need to use this class.
+ Examples:
+ - When you want to run an action where the target is different from a CCNode.
+ - When you want to pause / resume the actions
+ !#zh + cc.ActionManager 是可以管理动作的单例类。
+ 通常你并不需要直接使用这个类,99%的情况您将使用 CCNode 的接口。
+ 但也有一些情况下,您可能需要使用这个类。
+ 例如: + - 当你想要运行一个动作,但目标不是 CCNode 类型时。
+ - 当你想要暂停/恢复动作时。
*/ + export class ActionManager { + /** + !#en + Adds an action with a target.
+ If the target is already present, then the action will be added to the existing target. + If the target is not present, a new instance of this target will be created either paused or not, and the action will be added to the newly created target. + When the target is paused, the queued actions won't be 'ticked'. + !#zh + 增加一个动作,同时还需要提供动作的目标对象,目标对象是否暂停作为参数。
+ 如果目标已存在,动作将会被直接添加到现有的节点中。
+ 如果目标不存在,将为这一目标创建一个新的实例,并将动作添加进去。
+ 当目标状态的 paused 为 true,动作将不会被执行 + @param action action + @param target target + @param paused paused + */ + addAction(action: Action, target: Node, paused: boolean): void; + /** + !#en Removes all actions from all the targets. + !#zh 移除所有对象的所有动作。 + */ + removeAllActions(): void; + /** + !#en + Removes all actions from a certain target.
+ All the actions that belongs to the target will be removed. + !#zh + 移除指定对象上的所有动作。
+ 属于该目标的所有的动作将被删除。 + @param target target + @param forceDelete forceDelete + */ + removeAllActionsFromTarget(target: Node, forceDelete: boolean): void; + /** + !#en Removes an action given an action reference. + !#zh 移除指定的动作。 + @param action action + */ + removeAction(action: Action): void; + /** + !#en Removes an action given its tag and the target. + !#zh 删除指定对象下特定标签的一个动作,将删除首个匹配到的动作。 + @param tag tag + @param target target + */ + removeActionByTag(tag: number, target?: Node): void; + /** + !#en Gets an action given its tag an a target. + !#zh 通过目标对象和标签获取一个动作。 + @param tag tag + @param target target + */ + getActionByTag(tag: number, target: Node): Action; + /** + !#en + Returns the numbers of actions that are running in a certain target.
+ Composable actions are counted as 1 action.
+ Example:
+ - If you are running 1 Sequence of 7 actions, it will return 1.
+ - If you are running 7 Sequences of 2 actions, it will return 7. + !#zh + 返回指定对象下所有正在运行的动作数量。
+ 组合动作被算作一个动作。
+ 例如:
+ - 如果您正在运行 7 个动作组成的序列动作(Sequence),这个函数将返回 1。
+ - 如果你正在运行 2 个序列动作(Sequence)和 5 个普通动作,这个函数将返回 7。
+ @param target target + */ + getNumberOfRunningActionsInTarget(target: Node): number; + /** + !#en Pauses the target: all running actions and newly added actions will be paused. + !#zh 暂停指定对象:所有正在运行的动作和新添加的动作都将会暂停。 + @param target target + */ + pauseTarget(target: Node): void; + /** + !#en Resumes the target. All queued actions will be resumed. + !#zh 让指定目标恢复运行。在执行序列中所有被暂停的动作将重新恢复运行。 + @param target target + */ + resumeTarget(target: Node): void; + /** + !#en Pauses all running actions, returning a list of targets whose actions were paused. + !#zh 暂停所有正在运行的动作,返回一个包含了那些动作被暂停了的目标对象的列表。 + */ + pauseAllRunningActions(): any[]; + /** + !#en Resume a set of targets (convenience function to reverse a pauseAllRunningActions or pauseTargets call). + !#zh 让一组指定对象恢复运行(用来逆转 pauseAllRunningActions 效果的便捷函数)。 + @param targetsToResume targetsToResume + */ + resumeTargets(targetsToResume: any[]): void; + /** + !#en Pause a set of targets. + !#zh 暂停一组指定对象。 + @param targetsToPause targetsToPause + */ + pauseTargets(targetsToPause: any[]): void; + /** + !#en + purges the shared action manager. It releases the retained instance.
+ because it uses this, so it can not be static. + !#zh + 清除共用的动作管理器。它释放了持有的实例。
+ 因为它使用 this,因此它不能是静态的。 + */ + purgeSharedManager(): void; + /** + !#en The ActionManager update。 + !#zh ActionManager 主循环。 + @param dt delta time in seconds + */ + update(dt: number): void; + } + /** !#en + Tween provide a simple and flexible way to create action. Tween's api is more flexible than `cc.Action`: + - Support creating an action sequence in chained api. + - Support animate any objects' any properties, not limited to node's properties. By contrast, `cc.Action` needs to create a new action class to support new node property. + - Support working with `cc.Action`. + - Support easing and progress function. + !#zh + Tween 提供了一个简单灵活的方法来创建 action。相对于 Cocos 传统的 `cc.Action`,`cc.Tween` 在创建动画上要灵活非常多: + - 支持以链式结构的方式创建一个动画序列。 + - 支持对任意对象的任意属性进行缓动,不再局限于节点上的属性,而 `cc.Action` 添加一个属性的支持时还需要添加一个新的 action 类型。 + - 支持与 `cc.Action` 混用。 + - 支持设置 {{#crossLink "Easing"}}{{/crossLink}} 或者 progress 函数。 */ + export class Tween { + /** + + @param target target + */ + constructor(target?: any); + /** + !#en Stop all tweens + !#zh 停止所有缓动 + */ + static stopAll(): void; + /** + !#en Stop all tweens by tag + !#zh 停止所有指定标签的缓动 + @param tag tag + */ + static stopAllByTag(tag: number): void; + /** + !#en Stop all tweens by target + !#zh 停止所有指定对象的缓动 + @param target target + */ + static stopAllByTarget(target: any): void; + /** + !#en + Insert an action or tween to this sequence + !#zh + 插入一个 action 或者 tween 到队列中 + @param other other + */ + then(other: Action|Tween): Tween; + /** + !#en + Set tween target + !#zh + 设置 tween 的 target + @param target target + */ + target(target: any): Tween; + /** + !#en + Start this tween + !#zh + 运行当前 tween + */ + start(): Tween; + /** + !#en + Stop this tween + !#zh + 停止当前 tween + */ + stop(): Tween; + /** + !#en Sets tween tag + !#zh 设置缓动的标签 + @param tag tag + */ + tag(tag: number): Tween; + /** + !#en + Clone a tween + !#zh + 克隆当前 tween + @param target target + */ + clone(target?: any): Tween; + /** + !#en + Integrate all previous actions to an action. + !#zh + 将之前所有的 action 整合为一个 action。 + */ + union(): Tween; + /** + !#en Sets target's position property according to the bezier curve. + !#zh 按照贝塞尔路径设置目标的 position 属性。 + @param duration duration + @param c1 c1 + @param c2 c2 + @param to to + */ + bezierTo(duration: number, c1: Vec2, c2: Vec2, to: Vec2): Tween; + /** + !#en Sets target's position property according to the bezier curve. + !#zh 按照贝塞尔路径设置目标的 position 属性。 + @param duration duration + @param c1 c1 + @param c2 c2 + @param to to + */ + bezierBy(duration: number, c1: Vec2, c2: Vec2, to: Vec2): Tween; + /** + !#en Flips target's scaleX + !#zh 翻转目标的 scaleX 属性 + */ + flipX(): Tween; + /** + !#en Flips target's scaleY + !#zh 翻转目标的 scaleY 属性 + */ + flipY(): Tween; + /** + !#en Blinks target by set target's opacity property + !#zh 通过设置目标的 opacity 属性达到闪烁效果 + @param duration duration + @param times times + @param opts opts + */ + blink(duration: number, times: number, opts?: {progress?: Function; easing?: Function|string; }): Tween; + /** + !#en + Add an action which calculate with absolute value + !#zh + 添加一个对属性进行绝对值计算的 action + @param duration duration + @param props {scale: 2, position: cc.v3(100, 100, 100)} + @param opts opts + */ + to > (duration: number, props: ConstructorType, opts?: OPTS) : Tween; + /** + !#en + Add an action which calculate with relative value + !#zh + 添加一个对属性进行相对值计算的 action + @param duration duration + @param props {scale: 2, position: cc.v3(100, 100, 100)} + @param opts opts + */ + by > (duration: number, props: ConstructorType, opts?: OPTS) : Tween; + /** + !#en + Directly set target properties + !#zh + 直接设置 target 的属性 + @param props props + */ + set (props: ConstructorType) : Tween; + /** + !#en + Add an delay action + !#zh + 添加一个延时 action + @param duration duration + */ + delay(duration: number): Tween; + /** + !#en + Add an callback action + !#zh + 添加一个回调 action + @param callback callback + @param selectTarget selectTarget + */ + call(callback: Function, selectTarget?: object): Tween; + /** + !#en + Add an hide action + !#zh + 添加一个隐藏 action + */ + hide(): Tween; + /** + !#en + Add an show action + !#zh + 添加一个显示 action + */ + show(): Tween; + /** + !#en + Add an removeSelf action + !#zh + 添加一个移除自己 action + */ + removeSelf(): Tween; + /** + !#en + Add an sequence action + !#zh + 添加一个队列 action + @param action action + @param actions actions + */ + sequence(action: Action|Tween, ...actions: (Action|Tween)[]): Tween; + /** + !#en + Add an parallel action + !#zh + 添加一个并行 action + @param action action + @param actions actions + */ + parallel(action: Action|Tween, ...actions: (Action|Tween)[]): Tween; + /** + !#en + Add an repeat action. This action will integrate before actions to a sequence action as their parameters. + !#zh + 添加一个重复 action,这个 action 会将前一个动作作为他的参数。 + @param repeatTimes repeatTimes + @param action action + */ + repeat(repeatTimes: number, action?: Action|Tween): Tween; + /** + !#en + Add an repeat forever action. This action will integrate before actions to a sequence action as their parameters. + !#zh + 添加一个永久重复 action,这个 action 会将前一个动作作为他的参数。 + @param action action + */ + repeatForever(action?: Action|Tween): Tween; + /** + !#en + Add an reverse time action. This action will integrate before actions to a sequence action as their parameters. + !#zh + 添加一个倒置时间 action,这个 action 会将前一个动作作为他的参数。 + @param action action + */ + reverseTime(action?: Action|Tween): Tween; + } + /** !#en `cc.audioEngine` is the singleton object, it provide simple audio APIs. + !#zh + cc.audioengine是单例对象。
+ 主要用来播放音频,播放的时候会返回一个 audioID,之后都可以通过这个 audioID 来操作这个音频对象。
+ 不使用的时候,请使用 `cc.audioEngine.uncache(filePath);` 进行资源释放
+ 注意:
+ 在 Android 系统浏览器上,不同浏览器,不同版本的效果不尽相同。
+ 比如说:大多数浏览器都需要用户物理交互才可以开始播放音效,有一些不支持 WebAudio,有一些不支持多音轨播放。总之如果对音乐依赖比较强,请做尽可能多的测试。 */ + export class audioEngine { + /** + !#en Play audio. + !#zh 播放音频 + @param clip The audio clip to play. + @param loop Whether the music loop or not. + @param volume Volume size. + + @example + ```js + cc.resources.load(path, cc.AudioClip, null, function (err, clip) { + var audioID = cc.audioEngine.play(clip, false, 0.5); + }); + ``` + */ + static play(clip: AudioClip, loop: boolean, volume: number): number; + /** + !#en Set audio loop. + !#zh 设置音频是否循环。 + @param audioID audio id. + @param loop Whether cycle. + + @example + ```js + cc.audioEngine.setLoop(id, true); + ``` + */ + static setLoop(audioID: number, loop: boolean): void; + /** + !#en Get audio cycle state. + !#zh 获取音频的循环状态。 + @param audioID audio id. + + @example + ```js + cc.audioEngine.isLoop(id); + ``` + */ + static isLoop(audioID: number): boolean; + /** + !#en Set the volume of audio. + !#zh 设置音量(0.0 ~ 1.0)。 + @param audioID audio id. + @param volume Volume must be in 0.0~1.0 . + + @example + ```js + cc.audioEngine.setVolume(id, 0.5); + ``` + */ + static setVolume(audioID: number, volume: number): void; + /** + !#en The volume of the music max value is 1.0,the min value is 0.0 . + !#zh 获取音量(0.0 ~ 1.0)。 + @param audioID audio id. + + @example + ```js + var volume = cc.audioEngine.getVolume(id); + ``` + */ + static getVolume(audioID: number): number; + /** + !#en Set current time + !#zh 设置当前的音频时间。 + @param audioID audio id. + @param sec current time. + + @example + ```js + cc.audioEngine.setCurrentTime(id, 2); + ``` + */ + static setCurrentTime(audioID: number, sec: number): boolean; + /** + !#en Get current time + !#zh 获取当前的音频播放时间。 + @param audioID audio id. + + @example + ```js + var time = cc.audioEngine.getCurrentTime(id); + ``` + */ + static getCurrentTime(audioID: number): number; + /** + !#en Get audio duration + !#zh 获取音频总时长。 + @param audioID audio id. + + @example + ```js + var time = cc.audioEngine.getDuration(id); + ``` + */ + static getDuration(audioID: number): number; + /** + !#en Get audio state + !#zh 获取音频状态。 + @param audioID audio id. + + @example + ```js + var state = cc.audioEngine.getState(id); + ``` + */ + static getState(audioID: number): audioEngine.AudioState; + /** + !#en Set Audio finish callback + !#zh 设置一个音频结束后的回调 + @param audioID audio id. + @param callback loaded callback. + + @example + ```js + cc.audioEngine.setFinishCallback(id, function () {}); + ``` + */ + static setFinishCallback(audioID: number, callback: Function): void; + /** + !#en Pause playing audio. + !#zh 暂停正在播放音频。 + @param audioID The return value of function play. + + @example + ```js + cc.audioEngine.pause(audioID); + ``` + */ + static pause(audioID: number): void; + /** + !#en Pause all playing audio + !#zh 暂停现在正在播放的所有音频。 + + @example + ```js + cc.audioEngine.pauseAll(); + ``` + */ + static pauseAll(): void; + /** + !#en Resume playing audio. + !#zh 恢复播放指定的音频。 + @param audioID The return value of function play. + + @example + ```js + cc.audioEngine.resume(audioID); + ``` + */ + static resume(audioID: number): void; + /** + !#en Resume all playing audio. + !#zh 恢复播放所有之前暂停的所有音频。 + + @example + ```js + cc.audioEngine.resumeAll(); + ``` + */ + static resumeAll(): void; + /** + !#en Stop playing audio. + !#zh 停止播放指定音频。 + @param audioID The return value of function play. + + @example + ```js + cc.audioEngine.stop(audioID); + ``` + */ + static stop(audioID: number): void; + /** + !#en Stop all playing audio. + !#zh 停止正在播放的所有音频。 + + @example + ```js + cc.audioEngine.stopAll(); + ``` + */ + static stopAll(): void; + /** + !#en Set up an audio can generate a few examples. + !#zh 设置一个音频可以设置几个实例 + @param num a number of instances to be created from within an audio + + @example + ```js + cc.audioEngine.setMaxAudioInstance(20); + ``` + */ + static setMaxAudioInstance(num: number): void; + /** + !#en Getting audio can produce several examples. + !#zh 获取一个音频可以设置几个实例 + + @example + ```js + cc.audioEngine.getMaxAudioInstance(); + ``` + */ + static getMaxAudioInstance(): number; + /** + !#en Unload the preloaded audio from internal buffer. + !#zh 卸载预加载的音频。 + @param clip clip + + @example + ```js + cc.audioEngine.uncache(filePath); + ``` + */ + static uncache(clip: AudioClip): void; + /** + !#en Unload all audio from internal buffer. + !#zh 卸载所有音频。 + + @example + ```js + cc.audioEngine.uncacheAll(); + ``` + */ + static uncacheAll(): void; + /** + !#en Play background music + !#zh 播放背景音乐 + @param clip The audio clip to play. + @param loop Whether the music loop or not. + + @example + ```js + cc.resources.load(path, cc.AudioClip, null, function (err, clip) { + var audioID = cc.audioEngine.playMusic(clip, false); + }); + ``` + */ + static playMusic(clip: AudioClip, loop: boolean): number; + /** + !#en Stop background music. + !#zh 停止播放背景音乐。 + + @example + ```js + cc.audioEngine.stopMusic(); + ``` + */ + static stopMusic(): void; + /** + !#en Pause the background music. + !#zh 暂停播放背景音乐。 + + @example + ```js + cc.audioEngine.pauseMusic(); + ``` + */ + static pauseMusic(): void; + /** + !#en Resume playing background music. + !#zh 恢复播放背景音乐。 + + @example + ```js + cc.audioEngine.resumeMusic(); + ``` + */ + static resumeMusic(): void; + /** + !#en Get the volume(0.0 ~ 1.0). + !#zh 获取音量(0.0 ~ 1.0)。 + + @example + ```js + var volume = cc.audioEngine.getMusicVolume(); + ``` + */ + static getMusicVolume(): number; + /** + !#en Set the background music volume. + !#zh 设置背景音乐音量(0.0 ~ 1.0)。 + @param volume Volume must be in 0.0~1.0. + + @example + ```js + cc.audioEngine.setMusicVolume(0.5); + ``` + */ + static setMusicVolume(volume: number): void; + /** + !#en Background music playing state + !#zh 背景音乐是否正在播放 + + @example + ```js + cc.audioEngine.isMusicPlaying(); + ``` + */ + static isMusicPlaying(): boolean; + /** + !#en Play effect audio. + !#zh 播放音效 + @param clip The audio clip to play. + @param loop Whether the music loop or not. + + @example + ```js + cc.resources.load(path, cc.AudioClip, null, function (err, clip) { + var audioID = cc.audioEngine.playEffect(clip, false); + }); + ``` + */ + static playEffect(clip: AudioClip, loop: boolean): number; + /** + !#en Set the volume of effect audio. + !#zh 设置音效音量(0.0 ~ 1.0)。 + @param volume Volume must be in 0.0~1.0. + + @example + ```js + cc.audioEngine.setEffectsVolume(0.5); + ``` + */ + static setEffectsVolume(volume: number): void; + /** + !#en The volume of the effect audio max value is 1.0,the min value is 0.0 . + !#zh 获取音效音量(0.0 ~ 1.0)。 + + @example + ```js + var volume = cc.audioEngine.getEffectsVolume(); + ``` + */ + static getEffectsVolume(): number; + /** + !#en Pause effect audio. + !#zh 暂停播放音效。 + @param audioID audio id. + + @example + ```js + cc.audioEngine.pauseEffect(audioID); + ``` + */ + static pauseEffect(audioID: number): void; + /** + !#en Stop playing all the sound effects. + !#zh 暂停播放所有音效。 + + @example + ```js + cc.audioEngine.pauseAllEffects(); + ``` + */ + static pauseAllEffects(): void; + /** + !#en Resume effect audio. + !#zh 恢复播放音效音频。 + @param audioID The return value of function play. + + @example + ```js + cc.audioEngine.resumeEffect(audioID); + ``` + */ + static resumeEffect(audioID: number): void; + /** + !#en Resume all effect audio. + !#zh 恢复播放所有之前暂停的音效。 + + @example + ```js + cc.audioEngine.resumeAllEffects(); + ``` + */ + static resumeAllEffects(): void; + /** + !#en Stop playing the effect audio. + !#zh 停止播放音效。 + @param audioID audio id. + + @example + ```js + cc.audioEngine.stopEffect(id); + ``` + */ + static stopEffect(audioID: number): void; + /** + !#en Stop playing all the effects. + !#zh 停止播放所有音效。 + + @example + ```js + cc.audioEngine.stopAllEffects(); + ``` + */ + static stopAllEffects(): void; + } + /** !#en Class for animation data handling. + !#zh 动画剪辑,用于存储动画数据。 */ + export class AnimationClip extends Asset { + /** !#en Duration of this animation. + !#zh 动画的持续时间。 */ + duration: number; + /** !#en FrameRate of this animation. + !#zh 动画的帧速率。 */ + sample: number; + /** !#en Speed of this animation. + !#zh 动画的播放速度。 */ + speed: number; + /** !#en WrapMode of this animation. + !#zh 动画的循环模式。 */ + wrapMode: WrapMode; + /** !#en Curve data. + !#zh 曲线数据。 */ + curveData: any; + /** !#en Event data. + !#zh 事件数据。 */ + events: {frame: number, func: string, params: string[]}[]; + /** + !#en Crate clip with a set of sprite frames + !#zh 使用一组序列帧图片来创建动画剪辑 + @param spriteFrames spriteFrames + @param sample sample + + @example + ```js + var clip = cc.AnimationClip.createWithSpriteFrames(spriteFrames, 10); + ``` + */ + static createWithSpriteFrames(spriteFrames: SpriteFrame[], sample: number): AnimationClip; + } + /** !#en + This class provide easing methods for {{#crossLink "tween"}}{{/crossLink}} class.
+ Demonstratio: https://easings.net/ + !#zh + 缓动函数类,为 {{#crossLink "Tween"}}{{/crossLink}} 提供缓动效果函数。
+ 函数效果演示: https://easings.net/ */ + export class Easing { + /** + !#en Easing in with quadratic formula. From slow to fast. + !#zh 平方曲线缓入函数。运动由慢到快。 + @param t The current time as a percentage of the total time. + */ + quadIn(t: number): number; + /** + !#en Easing out with quadratic formula. From fast to slow. + !#zh 平方曲线缓出函数。运动由快到慢。 + @param t The current time as a percentage of the total time. + */ + quadOut(t: number): number; + /** + !#en Easing in and out with quadratic formula. From slow to fast, then back to slow. + !#zh 平方曲线缓入缓出函数。运动由慢到快再到慢。 + @param t The current time as a percentage of the total time. + */ + quadInOut(t: number): number; + /** + !#en Easing in with cubic formula. From slow to fast. + !#zh 立方曲线缓入函数。运动由慢到快。 + @param t The current time as a percentage of the total time. + */ + cubicIn(t: number): number; + /** + !#en Easing out with cubic formula. From slow to fast. + !#zh 立方曲线缓出函数。运动由快到慢。 + @param t The current time as a percentage of the total time. + */ + cubicOut(t: number): number; + /** + !#en Easing in and out with cubic formula. From slow to fast, then back to slow. + !#zh 立方曲线缓入缓出函数。运动由慢到快再到慢。 + @param t The current time as a percentage of the total time. + */ + cubicInOut(t: number): number; + /** + !#en Easing in with quartic formula. From slow to fast. + !#zh 四次方曲线缓入函数。运动由慢到快。 + @param t The current time as a percentage of the total time. + */ + quartIn(t: number): number; + /** + !#en Easing out with quartic formula. From fast to slow. + !#zh 四次方曲线缓出函数。运动由快到慢。 + @param t The current time as a percentage of the total time. + */ + quartOut(t: number): number; + /** + !#en Easing in and out with quartic formula. From slow to fast, then back to slow. + !#zh 四次方曲线缓入缓出函数。运动由慢到快再到慢。 + @param t The current time as a percentage of the total time. + */ + quartInOut(t: number): number; + /** + !#en Easing in with quintic formula. From slow to fast. + !#zh 五次方曲线缓入函数。运动由慢到快。 + @param t The current time as a percentage of the total time. + */ + quintIn(t: number): number; + /** + !#en Easing out with quintic formula. From fast to slow. + !#zh 五次方曲线缓出函数。运动由快到慢。 + @param t The current time as a percentage of the total time. + */ + quintOut(t: number): number; + /** + !#en Easing in and out with quintic formula. From slow to fast, then back to slow. + !#zh 五次方曲线缓入缓出函数。运动由慢到快再到慢。 + @param t The current time as a percentage of the total time. + */ + quintInOut(t: number): number; + /** + !#en Easing in and out with sine formula. From slow to fast. + !#zh 正弦曲线缓入函数。运动由慢到快。 + @param t The current time as a percentage of the total time. + */ + sineIn(t: number): number; + /** + !#en Easing in and out with sine formula. From fast to slow. + !#zh 正弦曲线缓出函数。运动由快到慢。 + @param t The current time as a percentage of the total time. + */ + sineOut(t: number): number; + /** + !#en Easing in and out with sine formula. From slow to fast, then back to slow. + !#zh 正弦曲线缓入缓出函数。运动由慢到快再到慢。 + @param t The current time as a percentage of the total time. + */ + sineInOut(t: number): number; + /** + !#en Easing in and out with exponential formula. From slow to fast. + !#zh 指数曲线缓入函数。运动由慢到快。 + @param t The current time as a percentage of the total time. + */ + expoIn(t: number): number; + /** + !#en Easing in and out with exponential formula. From fast to slow. + !#zh 指数曲线缓出函数。运动由快到慢。 + @param t The current time as a percentage of the total time. + */ + expoOut(t: number): number; + /** + !#en Easing in and out with exponential formula. From slow to fast. + !#zh 指数曲线缓入和缓出函数。运动由慢到很快再到慢。 + @param t The current time as a percentage of the total time, then back to slow. + */ + expoInOut(t: number): number; + /** + !#en Easing in and out with circular formula. From slow to fast. + !#zh 循环公式缓入函数。运动由慢到快。 + @param t The current time as a percentage of the total time. + */ + circIn(t: number): number; + /** + !#en Easing in and out with circular formula. From fast to slow. + !#zh 循环公式缓出函数。运动由快到慢。 + @param t The current time as a percentage of the total time. + */ + circOut(t: number): number; + /** + !#en Easing in and out with circular formula. From slow to fast. + !#zh 指数曲线缓入缓出函数。运动由慢到很快再到慢。 + @param t The current time as a percentage of the total time, then back to slow. + */ + circInOut(t: number): number; + /** + !#en Easing in action with a spring oscillating effect. + !#zh 弹簧回震效果的缓入函数。 + @param t The current time as a percentage of the total time. + */ + elasticIn(t: number): number; + /** + !#en Easing out action with a spring oscillating effect. + !#zh 弹簧回震效果的缓出函数。 + @param t The current time as a percentage of the total time. + */ + elasticOut(t: number): number; + /** + !#en Easing in and out action with a spring oscillating effect. + !#zh 弹簧回震效果的缓入缓出函数。 + @param t The current time as a percentage of the total time. + */ + elasticInOut(t: number): number; + /** + !#en Easing in action with "back up" behavior. + !#zh 回退效果的缓入函数。 + @param t The current time as a percentage of the total time. + */ + backIn(t: number): number; + /** + !#en Easing out action with "back up" behavior. + !#zh 回退效果的缓出函数。 + @param t The current time as a percentage of the total time. + */ + backOut(t: number): number; + /** + !#en Easing in and out action with "back up" behavior. + !#zh 回退效果的缓入缓出函数。 + @param t The current time as a percentage of the total time. + */ + backInOut(t: number): number; + /** + !#en Easing in action with bouncing effect. + !#zh 弹跳效果的缓入函数。 + @param t The current time as a percentage of the total time. + */ + bounceIn(t: number): number; + /** + !#en Easing out action with bouncing effect. + !#zh 弹跳效果的缓出函数。 + @param t The current time as a percentage of the total time. + */ + bounceOut(t: number): number; + /** + !#en Easing in and out action with bouncing effect. + !#zh 弹跳效果的缓入缓出函数。 + @param t The current time as a percentage of the total time. + */ + bounceInOut(t: number): number; + /** + !#en Target will run action with smooth effect. + !#zh 平滑效果函数。 + @param t The current time as a percentage of the total time. + */ + smooth(t: number): number; + /** + !#en Target will run action with fade effect. + !#zh 渐褪效果函数。 + @param t The current time as a percentage of the total time. + */ + fade(t: number): number; + } + /** !#en + The AnimationState gives full control over animation playback process. + In most cases the Animation Component is sufficient and easier to use. Use the AnimationState if you need full control. + !#zh + AnimationState 完全控制动画播放过程。
+ 大多数情况下 动画组件 是足够和易于使用的。如果您需要更多的动画控制接口,请使用 AnimationState。 */ + export class AnimationState extends Playable { + /** + + @param clip clip + @param name name + */ + constructor(clip: AnimationClip, name?: string); + /** !#en The curves list. + !#zh 曲线列表。 */ + curves: any[]; + /** !#en The start delay which represents the number of seconds from an animation's start time to the start of + the active interval. + !#zh 延迟多少秒播放。 */ + delay: number; + /** !#en The animation's iteration count property. + + A real number greater than or equal to zero (including positive infinity) representing the number of times + to repeat the animation node. + + Values less than zero and NaN values are treated as the value 1.0 for the purpose of timing model + calculations. + + !#zh 迭代次数,指动画播放多少次后结束, normalize time。 如 2.5(2次半) */ + repeatCount: number; + /** !#en The iteration duration of this animation in seconds. (length) + !#zh 单次动画的持续时间,秒。 */ + duration: number; + /** !#en The animation's playback speed. 1 is normal playback speed. + !#zh 播放速率。 */ + speed: number; + /** !#en + Wrapping mode of the playing animation. + Notice : dynamic change wrapMode will reset time and repeatCount property + !#zh + 动画循环方式。 + 需要注意的是,动态修改 wrapMode 时,会重置 time 以及 repeatCount */ + wrapMode: WrapMode; + /** !#en The current time of this animation in seconds. + !#zh 动画当前的时间,秒。 */ + time: number; + /** !#en The clip that is being played by this animation state. + !#zh 此动画状态正在播放的剪辑。 */ + clip: AnimationClip; + /** !#en The name of the playing animation. + !#zh 动画的名字 */ + name: string; + } + /** undefined */ + export class Playable { + /** !#en Is playing or paused in play mode? + !#zh 当前是否正在播放。 */ + isPlaying: boolean; + /** !#en Is currently paused? This can be true even if in edit mode(isPlaying == false). + !#zh 当前是否正在暂停 */ + isPaused: boolean; + /** + !#en Play this animation. + !#zh 播放动画。 + */ + play(): void; + /** + !#en Stop this animation. + !#zh 停止动画播放。 + */ + stop(): void; + /** + !#en Pause this animation. + !#zh 暂停动画。 + */ + pause(): void; + /** + !#en Resume this animation. + !#zh 重新播放动画。 + */ + resume(): void; + /** + !#en Perform a single frame step. + !#zh 执行一帧动画。 + */ + step(): void; + } + /** !#en Specifies how time is treated when it is outside of the keyframe range of an Animation. + !#zh 动画使用的循环模式。 */ + export enum WrapMode { + Default = 0, + Normal = 0, + Reverse = 0, + Loop = 0, + LoopReverse = 0, + PingPong = 0, + PingPongReverse = 0, + } + /** !#en An object to boot the game. + !#zh 包含游戏主体信息并负责驱动游戏的游戏对象。 */ + export class debug { + /** + !#en Gets error message with the error id and possible parameters. + !#zh 通过 error id 和必要的参数来获取错误信息。 + @param errorId errorId + @param param param + */ + static getError(errorId: number, param?: any): string; + /** + !#en Returns whether or not to display the FPS informations. + !#zh 是否显示 FPS 信息。 + */ + static isDisplayStats(): boolean; + /** + !#en Sets whether display the FPS on the bottom-left corner. + !#zh 设置是否在左下角显示 FPS。 + @param displayStats displayStats + */ + static setDisplayStats(displayStats: boolean): void; + } + /** !#en +

+ ATTENTION: USE cc.director INSTEAD OF cc.Director.
+ cc.director is a singleton object which manage your game's logic flow.
+ Since the cc.director is a singleton, you don't need to call any constructor or create functions,
+ the standard way to use it is by calling:
+ - cc.director.methodName();
+ + It creates and handle the main Window and manages how and when to execute the Scenes.
+
+ The cc.director is also responsible for:
+ - initializing the OpenGL context
+ - setting the OpenGL pixel format (default on is RGB565)
+ - setting the OpenGL buffer depth (default on is 0-bit)
+ - setting the color for clear screen (default one is BLACK)
+ - setting the projection (default one is 3D)
+ - setting the orientation (default one is Portrait)
+
+
+ The cc.director also sets the default OpenGL context:
+ - GL_TEXTURE_2D is enabled
+ - GL_VERTEX_ARRAY is enabled
+ - GL_COLOR_ARRAY is enabled
+ - GL_TEXTURE_COORD_ARRAY is enabled
+

+

+ cc.director also synchronizes timers with the refresh rate of the display.
+ Features and Limitations:
+ - Scheduled timers & drawing are synchronizes with the refresh rate of the display
+ - Only supports animation intervals of 1/60 1/30 & 1/15
+

+ + !#zh +

+ 注意:用 cc.director 代替 cc.Director。
+ cc.director 一个管理你的游戏的逻辑流程的单例对象。
+ 由于 cc.director 是一个单例,你不需要调用任何构造函数或创建函数,
+ 使用它的标准方法是通过调用:
+ - cc.director.methodName(); +
+ 它创建和处理主窗口并且管理什么时候执行场景。
+
+ cc.director 还负责:
+ - 初始化 OpenGL 环境。
+ - 设置OpenGL像素格式。(默认是 RGB565)
+ - 设置OpenGL缓冲区深度 (默认是 0-bit)
+ - 设置空白场景的颜色 (默认是 黑色)
+ - 设置投影 (默认是 3D)
+ - 设置方向 (默认是 Portrait)
+
+ cc.director 设置了 OpenGL 默认环境
+ - GL_TEXTURE_2D 启用。
+ - GL_VERTEX_ARRAY 启用。
+ - GL_COLOR_ARRAY 启用。
+ - GL_TEXTURE_COORD_ARRAY 启用。
+

+

+ cc.director 也同步定时器与显示器的刷新速率。 +
+ 特点和局限性:
+ - 将计时器 & 渲染与显示器的刷新频率同步。
+ - 只支持动画的间隔 1/60 1/30 & 1/15。
+

*/ + export class Director extends EventTarget { + /** + !#en + Converts a view coordinate to an WebGL coordinate
+ Useful to convert (multi) touches coordinates to the current layout (portrait or landscape)
+ Implementation can be found in CCDirectorWebGL. + !#zh 将触摸点的屏幕坐标转换为 WebGL View 下的坐标。 + @param uiPoint uiPoint + */ + convertToGL(uiPoint: Vec2): Vec2; + /** + !#en + Converts an OpenGL coordinate to a view coordinate
+ Useful to convert node points to window points for calls such as glScissor
+ Implementation can be found in CCDirectorWebGL. + !#zh 将触摸点的 WebGL View 坐标转换为屏幕坐标。 + @param glPoint glPoint + */ + convertToUI(glPoint: Vec2): Vec2; + /** + End the life of director in the next frame + */ + end(): void; + /** + !#en + Returns the size of the WebGL view in points.
+ It takes into account any possible rotation (device orientation) of the window. + !#zh 获取视图的大小,以点为单位。 + */ + getWinSize(): Size; + /** + !#en + Returns the size of the OpenGL view in pixels.
+ It takes into account any possible rotation (device orientation) of the window.
+ On Mac winSize and winSizeInPixels return the same value. + (The pixel here refers to the resource resolution. If you want to get the physics resolution of device, you need to use cc.view.getFrameSize()) + !#zh + 获取视图大小,以像素为单位(这里的像素指的是资源分辨率。 + 如果要获取屏幕物理分辨率,需要用 cc.view.getFrameSize()) + */ + getWinSizeInPixels(): Size; + /** + !#en Pause the director's ticker, only involve the game logic execution. + It won't pause the rendering process nor the event manager. + If you want to pause the entier game including rendering, audio and event, + please use {{#crossLink "Game.pause"}}cc.game.pause{{/crossLink}} + !#zh 暂停正在运行的场景,该暂停只会停止游戏逻辑执行,但是不会停止渲染和 UI 响应。 + 如果想要更彻底得暂停游戏,包含渲染,音频和事件,请使用 {{#crossLink "Game.pause"}}cc.game.pause{{/crossLink}}。 + */ + pause(): void; + /** + !#en + Run a scene. Replaces the running scene with a new one or enter the first scene.
+ The new scene will be launched immediately. + !#zh 立刻切换指定场景。 + @param scene The need run scene. + @param onBeforeLoadScene The function invoked at the scene before loading. + @param onLaunched The function invoked at the scene after launch. + */ + runSceneImmediate(scene: Scene|SceneAsset, onBeforeLoadScene?: Function, onLaunched?: Function): void; + /** + !#en + Run a scene. Replaces the running scene with a new one or enter the first scene. + The new scene will be launched at the end of the current frame. + !#zh 运行指定场景。 + @param scene The need run scene. + @param onBeforeLoadScene The function invoked at the scene before loading. + @param onLaunched The function invoked at the scene after launch. + */ + runScene(scene: Scene|SceneAsset, onBeforeLoadScene?: Function, onLaunched?: Function): void; + /** + !#en Loads the scene by its name. + !#zh 通过场景名称进行加载场景。 + @param sceneName The name of the scene to load. + @param onLaunched callback, will be called after scene launched. + */ + loadScene(sceneName: string, onLaunched?: Function): boolean; + /** + !#en + Preloads the scene to reduces loading time. You can call this method at any time you want. + After calling this method, you still need to launch the scene by `cc.director.loadScene`. + It will be totally fine to call `cc.director.loadScene` at any time even if the preloading is not + yet finished, the scene will be launched after loaded automatically. + !#zh 预加载场景,你可以在任何时候调用这个方法。 + 调用完后,你仍然需要通过 `cc.director.loadScene` 来启动场景,因为这个方法不会执行场景加载操作。 + 就算预加载还没完成,你也可以直接调用 `cc.director.loadScene`,加载完成后场景就会启动。 + @param sceneName The name of the scene to preload. + @param onProgress callback, will be called when the load progression change. + @param onLoaded callback, will be called after scene loaded. + */ + preloadScene(sceneName: string, onProgress?: (completedCount: number, totalCount: number, item: any) => void, onLoaded?: (error: Error) => void): void; + /** + !#en Resume game logic execution after pause, if the current scene is not paused, nothing will happen. + !#zh 恢复暂停场景的游戏逻辑,如果当前场景没有暂停将没任何事情发生。 + */ + resume(): void; + /** + !#en + Enables or disables WebGL depth test.
+ Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js + !#zh 启用/禁用深度测试(在 Canvas 渲染模式下不会生效)。 + @param on on + */ + setDepthTest(on: boolean): void; + /** + !#en + Set color for clear screen.
+ (Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js) + !#zh + 设置场景的默认擦除颜色。
+ 支持全透明,但不支持透明度为中间值。要支持全透明需手工开启 cc.macro.ENABLE_TRANSPARENT_CANVAS。 + @param clearColor clearColor + */ + setClearColor(clearColor: Color): void; + /** + !#en Returns current logic Scene. + !#zh 获取当前逻辑场景。 + + @example + ```js + // This will help you to get the Canvas node in scene + cc.director.getScene().getChildByName('Canvas'); + ``` + */ + getScene(): Scene; + /** + !#en Returns the FPS value. Please use {{#crossLink "Game.setFrameRate"}}cc.game.setFrameRate{{/crossLink}} to control animation interval. + !#zh 获取单位帧执行时间。请使用 {{#crossLink "Game.setFrameRate"}}cc.game.setFrameRate{{/crossLink}} 来控制游戏帧率。 + */ + getAnimationInterval(): number; + /** + Sets animation interval, this doesn't control the main loop. + To control the game's frame rate overall, please use {{#crossLink "Game.setFrameRate"}}cc.game.setFrameRate{{/crossLink}} + @param value The animation interval desired. + */ + setAnimationInterval(value: number): void; + /** + !#en Returns the delta time since last frame. + !#zh 获取上一帧的增量时间。 + */ + getDeltaTime(): number; + /** + !#en Returns the total passed time since game start, unit: ms + !#zh 获取从游戏开始到现在总共经过的时间,单位为 ms + */ + getTotalTime(): number; + /** + !#en Returns how many frames were called since the director started. + !#zh 获取 director 启动以来游戏运行的总帧数。 + */ + getTotalFrames(): number; + /** + !#en Returns whether or not the Director is paused. + !#zh 是否处于暂停状态。 + */ + isPaused(): boolean; + /** + !#en Returns the cc.Scheduler associated with this director. + !#zh 获取和 director 相关联的 cc.Scheduler。 + */ + getScheduler(): Scheduler; + /** + !#en Sets the cc.Scheduler associated with this director. + !#zh 设置和 director 相关联的 cc.Scheduler。 + @param scheduler scheduler + */ + setScheduler(scheduler: Scheduler): void; + /** + !#en Returns the cc.ActionManager associated with this director. + !#zh 获取和 director 相关联的 cc.ActionManager(动作管理器)。 + */ + getActionManager(): ActionManager; + /** + !#en Sets the cc.ActionManager associated with this director. + !#zh 设置和 director 相关联的 cc.ActionManager(动作管理器)。 + @param actionManager actionManager + */ + setActionManager(actionManager: ActionManager): void; + /** + !#en Returns the cc.CollisionManager associated with this director. + !#zh 获取和 director 相关联的 cc.CollisionManager (碰撞管理器)。 + */ + getCollisionManager(): CollisionManager; + /** + !#en Returns the cc.PhysicsManager associated with this director. + !#zh 返回与 director 相关联的 cc.PhysicsManager (物理管理器)。 + */ + getPhysicsManager(): PhysicsManager; + /** + !#en Returns the cc.Physics3DManager associated with this director. + !#zh 返回与 director 相关联的 cc.Physics3DManager (物理管理器)。 + */ + getPhysics3DManager(): Physics3DManager; + /** !#en The event projection changed of cc.Director. This event will not get triggered since v2.0 + !#zh cc.Director 投影变化的事件。从 v2.0 开始这个事件不会再被触发 */ + static EVENT_PROJECTION_CHANGED: string; + /** !#en The event which will be triggered before loading a new scene. + !#zh 加载新场景之前所触发的事件。 */ + static EVENT_BEFORE_SCENE_LOADING: string; + /** !#en The event which will be triggered before launching a new scene. + !#zh 运行新场景之前所触发的事件。 */ + static EVENT_BEFORE_SCENE_LAUNCH: string; + /** !#en The event which will be triggered after launching a new scene. + !#zh 运行新场景之后所触发的事件。 */ + static EVENT_AFTER_SCENE_LAUNCH: string; + /** !#en The event which will be triggered at the beginning of every frame. + !#zh 每个帧的开始时所触发的事件。 */ + static EVENT_BEFORE_UPDATE: string; + /** !#en The event which will be triggered after engine and components update logic. + !#zh 将在引擎和组件 “update” 逻辑之后所触发的事件。 */ + static EVENT_AFTER_UPDATE: string; + /** !#en The event is deprecated since v2.0, please use cc.Director.EVENT_BEFORE_DRAW instead + !#zh 这个事件从 v2.0 开始被废弃,请直接使用 cc.Director.EVENT_BEFORE_DRAW */ + static EVENT_BEFORE_VISIT: string; + /** !#en The event is deprecated since v2.0, please use cc.Director.EVENT_BEFORE_DRAW instead + !#zh 这个事件从 v2.0 开始被废弃,请直接使用 cc.Director.EVENT_BEFORE_DRAW */ + static EVENT_AFTER_VISIT: string; + /** !#en The event which will be triggered before the rendering process. + !#zh 渲染过程之前所触发的事件。 */ + static EVENT_BEFORE_DRAW: string; + /** !#en The event which will be triggered after the rendering process. + !#zh 渲染过程之后所触发的事件。 */ + static EVENT_AFTER_DRAW: string; + /** Constant for 2D projection (orthogonal projection) */ + static PROJECTION_2D: number; + /** Constant for 3D projection with a fovy=60, znear=0.5f and zfar=1500. */ + static PROJECTION_3D: number; + /** Constant for custom projection, if cc.Director's projection set to it, it calls "updateProjection" on the projection delegate. */ + static PROJECTION_CUSTOM: number; + /** Constant for default projection of cc.Director, default projection is 2D projection */ + static PROJECTION_DEFAULT: number; + } + /** !#en An object to boot the game. + !#zh 包含游戏主体信息并负责驱动游戏的游戏对象。 */ + export class Game extends EventTarget { + /** !#en Event triggered when game hide to background. + Please note that this event is not 100% guaranteed to be fired on Web platform, + on native platforms, it corresponds to enter background event, os status bar or notification center may not trigger this event. + !#zh 游戏进入后台时触发的事件。 + 请注意,在 WEB 平台,这个事件不一定会 100% 触发,这完全取决于浏览器的回调行为。 + 在原生平台,它对应的是应用被切换到后台事件,下拉菜单和上拉状态栏等不一定会触发这个事件,这取决于系统行为。 */ + EVENT_HIDE: string; + /** !#en Event triggered when game back to foreground + Please note that this event is not 100% guaranteed to be fired on Web platform, + on native platforms, it corresponds to enter foreground event. + !#zh 游戏进入前台运行时触发的事件。 + 请注意,在 WEB 平台,这个事件不一定会 100% 触发,这完全取决于浏览器的回调行为。 + 在原生平台,它对应的是应用被切换到前台事件。 */ + EVENT_SHOW: string; + /** !#en Event triggered when game restart + !#zh 调用restart后,触发事件。 */ + EVENT_RESTART: string; + /** Event triggered after game inited, at this point all engine objects and game scripts are loaded */ + EVENT_GAME_INITED: string; + /** Event triggered after engine inited, at this point you will be able to use all engine classes. + It was defined as EVENT_RENDERER_INITED in cocos creator v1.x and renamed in v2.0 */ + EVENT_ENGINE_INITED: string; + /** Web Canvas 2d API as renderer backend */ + RENDER_TYPE_CANVAS: number; + /** WebGL API as renderer backend */ + RENDER_TYPE_WEBGL: number; + /** OpenGL API as renderer backend */ + RENDER_TYPE_OPENGL: number; + /** !#en The outer frame of the game canvas, parent of game container. + !#zh 游戏画布的外框,container 的父容器。 */ + frame: any; + /** !#en The container of game canvas. + !#zh 游戏画布的容器。 */ + container: HTMLDivElement; + /** !#en The canvas of the game. + !#zh 游戏的画布。 */ + canvas: HTMLCanvasElement; + /** !#en The renderer backend of the game. + !#zh 游戏的渲染器类型。 */ + renderType: number; + /** !#en + The current game configuration, including:
+ 1. debugMode
+ "debugMode" possible values :
+ 0 - No message will be printed.
+ 1 - cc.error, cc.assert, cc.warn, cc.log will print in console.
+ 2 - cc.error, cc.assert, cc.warn will print in console.
+ 3 - cc.error, cc.assert will print in console.
+ 4 - cc.error, cc.assert, cc.warn, cc.log will print on canvas, available only on web.
+ 5 - cc.error, cc.assert, cc.warn will print on canvas, available only on web.
+ 6 - cc.error, cc.assert will print on canvas, available only on web.
+ 2. showFPS
+ Left bottom corner fps information will show when "showFPS" equals true, otherwise it will be hide.
+ 3. exposeClassName
+ Expose class name to chrome debug tools, the class intantiate performance is a little bit slower when exposed.
+ 4. frameRate
+ "frameRate" set the wanted frame rate for your game, but the real fps depends on your game implementation and the running environment.
+ 5. id
+ "gameCanvas" sets the id of your canvas element on the web page, it's useful only on web.
+ 6. renderMode
+ "renderMode" sets the renderer type, only useful on web :
+ 0 - Automatically chosen by engine
+ 1 - Forced to use canvas renderer
+ 2 - Forced to use WebGL renderer, but this will be ignored on mobile browsers
+
+ Please DO NOT modify this object directly, it won't have any effect.
+ !#zh + 当前的游戏配置,包括:
+ 1. debugMode(debug 模式,但是在浏览器中这个选项会被忽略)
+ "debugMode" 各种设置选项的意义。
+ 0 - 没有消息被打印出来。
+ 1 - cc.error,cc.assert,cc.warn,cc.log 将打印在 console 中。
+ 2 - cc.error,cc.assert,cc.warn 将打印在 console 中。
+ 3 - cc.error,cc.assert 将打印在 console 中。
+ 4 - cc.error,cc.assert,cc.warn,cc.log 将打印在 canvas 中(仅适用于 web 端)。
+ 5 - cc.error,cc.assert,cc.warn 将打印在 canvas 中(仅适用于 web 端)。
+ 6 - cc.error,cc.assert 将打印在 canvas 中(仅适用于 web 端)。
+ 2. showFPS(显示 FPS)
+ 当 showFPS 为 true 的时候界面的左下角将显示 fps 的信息,否则被隐藏。
+ 3. exposeClassName
+ 暴露类名让 Chrome DevTools 可以识别,如果开启会稍稍降低类的创建过程的性能,但对对象构造没有影响。
+ 4. frameRate (帧率)
+ “frameRate” 设置想要的帧率你的游戏,但真正的FPS取决于你的游戏实现和运行环境。
+ 5. id
+ "gameCanvas" Web 页面上的 Canvas Element ID,仅适用于 web 端。
+ 6. renderMode(渲染模式)
+ “renderMode” 设置渲染器类型,仅适用于 web 端:
+ 0 - 通过引擎自动选择。
+ 1 - 强制使用 canvas 渲染。 + 2 - 强制使用 WebGL 渲染,但是在部分 Android 浏览器中这个选项会被忽略。
+
+ 注意:请不要直接修改这个对象,它不会有任何效果。 */ + config: any; + /** + !#en Callback when the scripts of engine have been load. + !#zh 当引擎完成启动后的回调函数。 + */ + onStart(): void; + /** + !#en Set frame rate of game. + !#zh 设置游戏帧率。 + @param frameRate frameRate + */ + setFrameRate(frameRate: number): void; + /** + !#en Get frame rate set for the game, it doesn't represent the real frame rate. + !#zh 获取设置的游戏帧率(不等同于实际帧率)。 + */ + getFrameRate(): number; + /** + !#en Run the game frame by frame. + !#zh 执行一帧游戏循环。 + */ + step(): void; + /** + !#en Pause the game main loop. This will pause: + game logic execution, rendering process, event manager, background music and all audio effects. + This is different with cc.director.pause which only pause the game logic execution. + !#zh 暂停游戏主循环。包含:游戏逻辑,渲染,事件处理,背景音乐和所有音效。这点和只暂停游戏逻辑的 cc.director.pause 不同。 + */ + pause(): void; + /** + !#en Resume the game from pause. This will resume: + game logic execution, rendering process, event manager, background music and all audio effects. + !#zh 恢复游戏主循环。包含:游戏逻辑,渲染,事件处理,背景音乐和所有音效。 + */ + resume(): void; + /** + !#en Check whether the game is paused. + !#zh 判断游戏是否暂停。 + */ + isPaused(): boolean; + /** + !#en Restart game. + !#zh 重新开始游戏 + */ + restart(): void; + /** + !#en End game, it will close the game window + !#zh 退出游戏 + */ + end(): void; + /** + !#en + Register an callback of a specific event type on the game object. + This type of event should be triggered via `emit`. + !#zh + 注册 game 的特定事件类型回调。这种类型的事件应该被 `emit` 触发。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + */ + on(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Register an callback of a specific event type on the game object, + the callback will remove itself after the first time it is triggered. + !#zh + 注册 game 的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + */ + once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; + /** + !#en Prepare game. + !#zh 准备引擎,请不要直接调用这个函数。 + @param cb cb + */ + prepare(cb: Function): void; + /** + !#en Run game with configuration object and onStart function. + !#zh 运行游戏,并且指定引擎配置和 onStart 的回调。 + @param config Pass configuration object or onStart function + @param onStart function to be executed after game initialized + */ + run(config: any, onStart: Function): void; + /** + !#en + Add a persistent root node to the game, the persistent node won't be destroyed during scene transition.
+ The target node must be placed in the root level of hierarchy, otherwise this API won't have any effect. + !#zh + 声明常驻根节点,该节点不会被在场景切换中被销毁。
+ 目标节点必须位于为层级的根节点,否则无效。 + @param node The node to be made persistent + */ + addPersistRootNode(node: Node): void; + /** + !#en Remove a persistent root node. + !#zh 取消常驻根节点。 + @param node The node to be removed from persistent node list + */ + removePersistRootNode(node: Node): void; + /** + !#en Check whether the node is a persistent root node. + !#zh 检查节点是否是常驻根节点。 + @param node The node to be checked + */ + isPersistRootNode(node: Node): boolean; + } + /** !#en + Class of all entities in Cocos Creator scenes.
+ For events supported by Node, please refer to {{#crossLink "Node.EventType"}}{{/crossLink}} + !#zh + Cocos Creator 场景中的所有节点类。
+ 支持的节点事件,请参阅 {{#crossLink "Node.EventType"}}{{/crossLink}}。 */ + export class Node extends _BaseNode { + /** !#en + Group index of node.
+ Which Group this node belongs to will resolve that this node's collision components can collide with which other collision componentns.
+ !#zh + 节点的分组索引。
+ 节点的分组将关系到节点的碰撞组件可以与哪些碰撞组件相碰撞。
*/ + groupIndex: number; + /** !#en + Group of node.
+ Which Group this node belongs to will resolve that this node's collision components can collide with which other collision componentns.
+ !#zh + 节点的分组。
+ 节点的分组将关系到节点的碰撞组件可以与哪些碰撞组件相碰撞。
*/ + group: string; + /** !#en The position (x, y) of the node in its parent's coordinates. + !#zh 节点在父节点坐标系中的位置(x, y)。 */ + position: Vec3; + /** !#en x axis position of node. + !#zh 节点 X 轴坐标。 */ + x: number; + /** !#en y axis position of node. + !#zh 节点 Y 轴坐标。 */ + y: number; + /** !#en z axis position of node. + !#zh 节点 Z 轴坐标。 */ + z: number; + /** !#en Rotation of node. + !#zh 该节点旋转角度。 */ + rotation: number; + /** !#en + Angle of node, the positive value is anti-clockwise direction. + !#zh + 该节点的旋转角度,正值为逆时针方向。 */ + angle: number; + /** !#en The rotation as Euler angles in degrees, used in 3D node. + !#zh 该节点的欧拉角度,用于 3D 节点。 */ + eulerAngles: Vec3; + /** !#en Rotation on x axis. + !#zh 该节点 X 轴旋转角度。 */ + rotationX: number; + /** !#en Rotation on y axis. + !#zh 该节点 Y 轴旋转角度。 */ + rotationY: number; + /** !#en The local scale relative to the parent. + !#zh 节点相对父节点的缩放。 */ + scale: number; + /** !#en Scale on x axis. + !#zh 节点 X 轴缩放。 */ + scaleX: number; + /** !#en Scale on y axis. + !#zh 节点 Y 轴缩放。 */ + scaleY: number; + /** !#en Scale on z axis. + !#zh 节点 Z 轴缩放。 */ + scaleZ: number; + /** !#en Skew x + !#zh 该节点 X 轴倾斜角度。 */ + skewX: number; + /** !#en Skew y + !#zh 该节点 Y 轴倾斜角度。 */ + skewY: number; + /** !#en Opacity of node, default value is 255. + !#zh 节点透明度,默认值为 255。 */ + opacity: number; + /** !#en Color of node, default value is white: (255, 255, 255). + !#zh 节点颜色。默认为白色,数值为:(255,255,255)。 */ + color: Color; + /** !#en Anchor point's position on x axis. + !#zh 节点 X 轴锚点位置。 */ + anchorX: number; + /** !#en Anchor point's position on y axis. + !#zh 节点 Y 轴锚点位置。 */ + anchorY: number; + /** !#en Width of node. + !#zh 节点宽度。 */ + width: number; + /** !#en Height of node. + !#zh 节点高度。 */ + height: number; + /** !#en zIndex is the 'key' used to sort the node relative to its siblings.
+ The value of zIndex should be in the range between cc.macro.MIN_ZINDEX and cc.macro.MAX_ZINDEX.
+ The Node's parent will sort all its children based on the zIndex value and the arrival order.
+ Nodes with greater zIndex will be sorted after nodes with smaller zIndex.
+ If two nodes have the same zIndex, then the node that was added first to the children's array will be in front of the other node in the array.
+ Node's order in children list will affect its rendering order. Parent is always rendering before all children. + !#zh zIndex 是用来对节点进行排序的关键属性,它决定一个节点在兄弟节点之间的位置。
+ zIndex 的取值应该介于 cc.macro.MIN_ZINDEX 和 cc.macro.MAX_ZINDEX 之间 + 父节点主要根据节点的 zIndex 和添加次序来排序,拥有更高 zIndex 的节点将被排在后面,如果两个节点的 zIndex 一致,先添加的节点会稳定排在另一个节点之前。
+ 节点在 children 中的顺序决定了其渲染顺序。父节点永远在所有子节点之前被渲染 */ + zIndex: number; + /** !#en + Switch 2D/3D node. The 2D nodes will run faster. + !#zh + 切换 2D/3D 节点,2D 节点会有更高的运行效率 */ + is3DNode: boolean; + /** !#en Returns a normalized vector representing the up direction (Y axis) of the node in world space. + !#zh 获取节点正上方(y 轴)面对的方向,返回值为世界坐标系下的归一化向量 */ + up: Vec3; + /** !#en Returns a normalized vector representing the right direction (X axis) of the node in world space. + !#zh 获取节点正右方(x 轴)面对的方向,返回值为世界坐标系下的归一化向量 */ + right: Vec3; + /** !#en Returns a normalized vector representing the forward direction (Z axis) of the node in world space. + !#zh 获取节点正前方(z 轴)面对的方向,返回值为世界坐标系下的归一化向量 */ + forward: Vec3; + /** + + @param name name + */ + constructor(name?: string); + /** + !#en + Register a callback of a specific event type on Node.
+ Use this method to register touch or mouse event permit propagation based on scene graph,
+ These kinds of event are triggered with dispatchEvent, the dispatch process has three steps:
+ 1. Capturing phase: dispatch in capture targets (`_getCapturingTargets`), e.g. parents in node tree, from root to the real target
+ 2. At target phase: dispatch to the listeners of the real target
+ 3. Bubbling phase: dispatch in bubble targets (`_getBubblingTargets`), e.g. parents in node tree, from the real target to root
+ In any moment of the dispatching process, it can be stopped via `event.stopPropagation()` or `event.stopPropagationImmidiate()`.
+ It's the recommended way to register touch/mouse event for Node,
+ please do not use cc.eventManager directly for Node.
+ You can also register custom event and use `emit` to trigger custom event on Node.
+ For such events, there won't be capturing and bubbling phase, your event will be dispatched directly to its listeners registered on the same node.
+ You can also pass event callback parameters with `emit` by passing parameters after `type`. + !#zh + 在节点上注册指定类型的回调函数,也可以设置 target 用于绑定响应函数的 this 对象。
+ 鼠标或触摸事件会被系统调用 dispatchEvent 方法触发,触发的过程包含三个阶段:
+ 1. 捕获阶段:派发事件给捕获目标(通过 `_getCapturingTargets` 获取),比如,节点树中注册了捕获阶段的父节点,从根节点开始派发直到目标节点。
+ 2. 目标阶段:派发给目标节点的监听器。
+ 3. 冒泡阶段:派发事件给冒泡目标(通过 `_getBubblingTargets` 获取),比如,节点树中注册了冒泡阶段的父节点,从目标节点开始派发直到根节点。
+ 同时您可以将事件派发到父节点或者通过调用 stopPropagation 拦截它。
+ 推荐使用这种方式来监听节点上的触摸或鼠标事件,请不要在节点上直接使用 cc.eventManager。
+ 你也可以注册自定义事件到节点上,并通过 emit 方法触发此类事件,对于这类事件,不会发生捕获冒泡阶段,只会直接派发给注册在该节点上的监听器
+ 你可以通过在 emit 方法调用时在 type 之后传递额外的参数作为事件回调的参数列表 + @param type A string representing the event type to listen for.
See {{#crossLink "Node/EventTyupe/POSITION_CHANGED"}}Node Events{{/crossLink}} for all builtin events. + @param callback The callback that will be invoked when the event is dispatched. The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + @param useCapture When set to true, the listener will be triggered at capturing phase which is ahead of the final target emit, otherwise it will be triggered during bubbling phase. + + @example + ```js + this.node.on(cc.Node.EventType.TOUCH_START, this.memberFunction, this); // if "this" is component and the "memberFunction" declared in CCClass. + node.on(cc.Node.EventType.TOUCH_START, callback, this); + node.on(cc.Node.EventType.TOUCH_MOVE, callback, this); + node.on(cc.Node.EventType.TOUCH_END, callback, this); + node.on(cc.Node.EventType.TOUCH_CANCEL, callback, this); + node.on(cc.Node.EventType.ANCHOR_CHANGED, callback); + node.on(cc.Node.EventType.COLOR_CHANGED, callback); + ``` + */ + on(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Register an callback of a specific event type on the Node, + the callback will remove itself after the first time it is triggered. + !#zh + 注册节点的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + node.once(cc.Node.EventType.ANCHOR_CHANGED, callback); + ``` + */ + once(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Removes the callback previously registered with the same type, callback, target and or useCapture. + This method is merely an alias to removeEventListener. + !#zh 删除之前与同类型,回调,目标或 useCapture 注册的回调。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + @param useCapture When set to true, the listener will be triggered at capturing phase which is ahead of the final target emit, otherwise it will be triggered during bubbling phase. + + @example + ```js + this.node.off(cc.Node.EventType.TOUCH_START, this.memberFunction, this); + node.off(cc.Node.EventType.TOUCH_START, callback, this.node); + node.off(cc.Node.EventType.ANCHOR_CHANGED, callback, this); + ``` + */ + off(type: string, callback?: Function, target?: any, useCapture?: boolean): void; + /** + !#en Removes all callbacks previously registered with the same target. + !#zh 移除目标上的所有注册事件。 + @param target The target to be searched for all related callbacks + + @example + ```js + node.targetOff(target); + ``` + */ + targetOff(target: any): void; + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en + Trigger an event directly with the event name and necessary arguments. + !#zh + 通过事件名发送自定义事件 + @param type event type + @param arg1 First argument in callback + @param arg2 Second argument in callback + @param arg3 Third argument in callback + @param arg4 Fourth argument in callback + @param arg5 Fifth argument in callback + + @example + ```js + eventTarget.emit('fire', event); + eventTarget.emit('fire', message, emitter); + ``` + */ + emit(type: string, arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any): void; + /** + !#en + Dispatches an event into the event flow. + The event target is the EventTarget object upon which the dispatchEvent() method is called. + !#zh 分发事件到事件流中。 + @param event The Event object that is dispatched into the event flow + */ + dispatchEvent(event: Event): void; + /** + !#en Pause node related system events registered with the current Node. Node system events includes touch and mouse events. + If recursive is set to true, then this API will pause the node system events for the node and all nodes in its sub node tree. + Reference: http://docs.cocos2d-x.org/editors_and_tools/creator-chapters/scripting/internal-events/ + !#zh 暂停当前节点上注册的所有节点系统事件,节点系统事件包含触摸和鼠标事件。 + 如果传递 recursive 为 true,那么这个 API 将暂停本节点和它的子树上所有节点的节点系统事件。 + 参考:https://www.cocos.com/docs/creator/scripting/internal-events.html + @param recursive Whether to pause node system events on the sub node tree. + + @example + ```js + node.pauseSystemEvents(true); + ``` + */ + pauseSystemEvents(recursive: boolean): void; + /** + !#en Resume node related system events registered with the current Node. Node system events includes touch and mouse events. + If recursive is set to true, then this API will resume the node system events for the node and all nodes in its sub node tree. + Reference: http://docs.cocos2d-x.org/editors_and_tools/creator-chapters/scripting/internal-events/ + !#zh 恢复当前节点上注册的所有节点系统事件,节点系统事件包含触摸和鼠标事件。 + 如果传递 recursive 为 true,那么这个 API 将恢复本节点和它的子树上所有节点的节点系统事件。 + 参考:https://www.cocos.com/docs/creator/scripting/internal-events.html + @param recursive Whether to resume node system events on the sub node tree. + + @example + ```js + node.resumeSystemEvents(true); + ``` + */ + resumeSystemEvents(recursive: boolean): void; + /** + !#en + Executes an action, and returns the action that is executed.
+ The node becomes the action's target. Refer to cc.Action's getTarget()
+ Calling runAction while the node is not active won't have any effect.
+ Note:You shouldn't modify the action after runAction, that won't take any effect.
+ if you want to modify, when you define action plus. + !#zh + 执行并返回该执行的动作。该节点将会变成动作的目标。
+ 调用 runAction 时,节点自身处于不激活状态将不会有任何效果。
+ 注意:你不应该修改 runAction 后的动作,将无法发挥作用,如果想进行修改,请在定义 action 时加入。 + @param action action + + @example + ```js + var action = cc.scaleTo(0.2, 1, 0.6); + node.runAction(action); + node.runAction(action).repeatForever(); // fail + node.runAction(action.repeatForever()); // right + ``` + */ + runAction(action: Action): Action; + /** + !#en Pause all actions running on the current node. Equals to `cc.director.getActionManager().pauseTarget(node)`. + !#zh 暂停本节点上所有正在运行的动作。和 `cc.director.getActionManager().pauseTarget(node);` 等价。 + + @example + ```js + node.pauseAllActions(); + ``` + */ + pauseAllActions(): void; + /** + !#en Resume all paused actions on the current node. Equals to `cc.director.getActionManager().resumeTarget(node)`. + !#zh 恢复运行本节点上所有暂停的动作。和 `cc.director.getActionManager().resumeTarget(node);` 等价。 + + @example + ```js + node.resumeAllActions(); + ``` + */ + resumeAllActions(): void; + /** + !#en Stops and removes all actions from the running action list . + !#zh 停止并且移除所有正在运行的动作列表。 + + @example + ```js + node.stopAllActions(); + ``` + */ + stopAllActions(): void; + /** + !#en Stops and removes an action from the running action list. + !#zh 停止并移除指定的动作。 + @param action An action object to be removed. + + @example + ```js + var action = cc.scaleTo(0.2, 1, 0.6); + node.stopAction(action); + ``` + */ + stopAction(action: Action): void; + /** + !#en Removes an action from the running action list by its tag. + !#zh 停止并且移除指定标签的动作。 + @param tag A tag that indicates the action to be removed. + + @example + ```js + node.stopActionByTag(1); + ``` + */ + stopActionByTag(tag: number): void; + /** + !#en Returns an action from the running action list by its tag. + !#zh 通过标签获取指定动作。 + @param tag tag + + @example + ```js + var action = node.getActionByTag(1); + ``` + */ + getActionByTag(tag: number): Action; + /** + !#en + Returns the numbers of actions that are running plus the ones that are schedule to run (actions in actionsToAdd and actions arrays).
+ Composable actions are counted as 1 action. Example:
+ If you are running 1 Sequence of 7 actions, it will return 1.
+ If you are running 7 Sequences of 2 actions, it will return 7.

+ !#zh + 获取运行着的动作加上正在调度运行的动作的总数。
+ 例如:
+ - 如果你正在运行 7 个动作中的 1 个 Sequence,它将返回 1。
+ - 如果你正在运行 2 个动作中的 7 个 Sequence,它将返回 7。
+ + @example + ```js + var count = node.getNumberOfRunningActions(); + cc.log("Running Action Count: " + count); + ``` + */ + getNumberOfRunningActions(): number; + /** + !#en + Returns a copy of the position (x, y, z) of the node in its parent's coordinates. + You can pass a cc.Vec2 or cc.Vec3 as the argument to receive the return values. + !#zh + 获取节点在父节点坐标系中的位置(x, y, z)。 + 你可以传一个 cc.Vec2 或者 cc.Vec3 作为参数来接收返回值。 + @param out The return value to receive position + + @example + ```js + cc.log("Node Position: " + node.getPosition()); + ``` + */ + getPosition(out?: Vec2|Vec3): Vec2; + /** + !#en + Sets the position (x, y, z) of the node in its parent's coordinates.
+ Usually we use cc.v2(x, y) to compose cc.Vec2 object, in this case, position.z will become 0.
+ and passing two numbers (x, y) is more efficient than passing cc.Vec2 object, in this case, position.z will remain unchanged. + For 3D node we can use cc.v3(x, y, z) to compose cc.Vec3 object,
+ and passing three numbers (x, y, z) is more efficient than passing cc.Vec3 object. + !#zh + 设置节点在父节点坐标系中的位置。
+ 可以通过下面的方式设置坐标点:
+ 1. 传入 2 个数值 x, y (此时不会改变 position.z 的值)。
+ 2. 传入 cc.v2(x, y) 类型为 cc.Vec2 的对象 (此时 position.z 的值将被设置为0)。 + 3. 对于 3D 节点可以传入 3 个数值 x, y, z。
+ 4. 对于 3D 节点可以传入 cc.v3(x, y, z) 类型为 cc.Vec3 的对象。 + @param x X coordinate for position or the position object + @param y Y coordinate for position + @param z Z coordinate for position + */ + setPosition(x: Vec2|Vec3|number, y?: number, z?: number): void; + /** + !#en + Returns the scale factor of the node. + Need pass a cc.Vec2 or cc.Vec3 as the argument to receive the return values. + !#zh 获取节点的缩放,需要传一个 cc.Vec2 或者 cc.Vec3 作为参数来接收返回值。 + @param out out + + @example + ```js + cc.log("Node Scale: " + node.getScale(cc.v3())); + ``` + */ + getScale(out: Vec2|Vec3): Vec2; + /** + !#en + Sets the scale of axis in local coordinates of the node. + You can operate 2 axis in 2D node, and 3 axis in 3D node. + When only (x, y) is passed, the value of scale.z will not be changed. + When a Vec2 is passed in, the value of scale.z will be set to 0. + !#zh + 设置节点在本地坐标系中坐标轴上的缩放比例。 + 2D 节点可以操作两个坐标轴,而 3D 节点可以操作三个坐标轴。 + 当只传入 (x, y) 时,scale.z 的值不会被改变。 + 当只传入 Vec2 对象时,scale.z 的值将被设置为0。 + @param x scaleX or scale object + @param y y + @param z z + + @example + ```js + node.setScale(cc.v2(2, 2)); // Notice: scaleZ will be 0 + node.setScale(cc.v3(2, 2, 2)); // for 3D node + node.setScale(2); + ``` + */ + setScale(x: number|Vec2|Vec3, y?: number, z?: number): void; + /** + !#en + Get rotation of node (in quaternion). + Need pass a cc.Quat as the argument to receive the return values. + !#zh + 获取该节点的 quaternion 旋转角度,需要传一个 cc.Quat 作为参数来接收返回值。 + @param out out + */ + getRotation(out: Quat): Quat; + /** + !#en Set rotation of node (in quaternion). + !#zh 设置该节点的 quaternion 旋转角度。 + @param quat Quaternion object represents the rotation or the x value of quaternion + @param y y value of quternion + @param z z value of quternion + @param w w value of quternion + */ + setRotation(quat: Quat|number, y?: number, z?: number, w?: number): void; + /** + !#en + Returns a copy the untransformed size of the node.
+ The contentSize remains the same no matter the node is scaled or rotated.
+ All nodes has a size. Layer and Scene has the same size of the screen by default.
+ !#zh 获取节点自身大小,不受该节点是否被缩放或者旋转的影响。 + + @example + ```js + cc.log("Content Size: " + node.getContentSize()); + ``` + */ + getContentSize(): Size; + /** + !#en + Sets the untransformed size of the node.
+ The contentSize remains the same no matter the node is scaled or rotated.
+ All nodes has a size. Layer and Scene has the same size of the screen. + !#zh 设置节点原始大小,不受该节点是否被缩放或者旋转的影响。 + @param size The untransformed size of the node or The untransformed size's width of the node. + @param height The untransformed size's height of the node. + + @example + ```js + node.setContentSize(cc.size(100, 100)); + node.setContentSize(100, 100); + ``` + */ + setContentSize(size: Size|number, height?: number): void; + /** + !#en + Returns a copy of the anchor point.
+ Anchor point is the point around which all transformations and positioning manipulations take place.
+ It's like a pin in the node where it is "attached" to its parent.
+ The anchorPoint is normalized, like a percentage. (0,0) means the bottom-left corner and (1,1) means the top-right corner.
+ But you can use values higher than (1,1) and lower than (0,0) too.
+ The default anchor point is (0.5,0.5), so it starts at the center of the node. + !#zh + 获取节点锚点,用百分比表示。
+ 锚点应用于所有变换和坐标点的操作,它就像在节点上连接其父节点的大头针。
+ 锚点是标准化的,就像百分比一样。(0,0) 表示左下角,(1,1) 表示右上角。
+ 但是你可以使用比(1,1)更高的值或者比(0,0)更低的值。
+ 默认的锚点是(0.5,0.5),因此它开始于节点的中心位置。
+ 注意:Creator 中的锚点仅用于定位所在的节点,子节点的定位不受影响。 + + @example + ```js + cc.log("Node AnchorPoint: " + node.getAnchorPoint()); + ``` + */ + getAnchorPoint(): Vec2; + /** + !#en + Sets the anchor point in percent.
+ anchor point is the point around which all transformations and positioning manipulations take place.
+ It's like a pin in the node where it is "attached" to its parent.
+ The anchorPoint is normalized, like a percentage. (0,0) means the bottom-left corner and (1,1) means the top-right corner.
+ But you can use values higher than (1,1) and lower than (0,0) too.
+ The default anchor point is (0.5,0.5), so it starts at the center of the node. + !#zh + 设置锚点的百分比。
+ 锚点应用于所有变换和坐标点的操作,它就像在节点上连接其父节点的大头针。
+ 锚点是标准化的,就像百分比一样。(0,0) 表示左下角,(1,1) 表示右上角。
+ 但是你可以使用比(1,1)更高的值或者比(0,0)更低的值。
+ 默认的锚点是(0.5,0.5),因此它开始于节点的中心位置。
+ 注意:Creator 中的锚点仅用于定位所在的节点,子节点的定位不受影响。 + @param point The anchor point of node or The x axis anchor of node. + @param y The y axis anchor of node. + + @example + ```js + node.setAnchorPoint(cc.v2(1, 1)); + node.setAnchorPoint(1, 1); + ``` + */ + setAnchorPoint(point: Vec2|number, y?: number): void; + /** + !#en Set rotation by lookAt target point, normally used by Camera Node + !#zh 通过观察目标来设置 rotation,一般用于 Camera Node 上 + @param pos pos + @param up default is (0,1,0) + */ + lookAt(pos: Vec3, up?: Vec3): void; + /** + !#en + Get the local transform matrix (4x4), based on parent node coordinates + !#zh 返回局部空间坐标系的矩阵,基于父节点坐标系。 + @param out The matrix object to be filled with data + + @example + ```js + let mat4 = cc.mat4(); + node.getLocalMatrix(mat4); + ``` + */ + getLocalMatrix(out: Mat4): Mat4; + /** + !#en + Get the world transform matrix (4x4) + !#zh 返回世界空间坐标系的矩阵。 + @param out The matrix object to be filled with data + + @example + ```js + let mat4 = cc.mat4(); + node.getWorldMatrix(mat4); + ``` + */ + getWorldMatrix(out: Mat4): Mat4; + /** + !#en + Converts a Point to node (local) space coordinates. + !#zh + 将一个点转换到节点 (局部) 空间坐标系。 + @param worldPoint worldPoint + @param out out + + @example + ```js + var newVec2 = node.convertToNodeSpaceAR(cc.v2(100, 100)); + var newVec3 = node.convertToNodeSpaceAR(cc.v3(100, 100, 100)); + ``` + */ + convertToNodeSpaceAR(worldPoint: T, out?: T): T; + /** + !#en + Converts a Point in node coordinates to world space coordinates. + !#zh + 将节点坐标系下的一个点转换到世界空间坐标系。 + @param nodePoint nodePoint + @param out out + + @example + ```js + var newVec2 = node.convertToWorldSpaceAR(cc.v2(100, 100)); + var newVec3 = node.convertToWorldSpaceAR(cc.v3(100, 100, 100)); + ``` + */ + convertToWorldSpaceAR(nodePoint: T, out?: T): T; + /** + !#en Converts a Point to node (local) space coordinates then add the anchor point position. + So the return position will be related to the left bottom corner of the node's bounding box. + This equals to the API behavior of cocos2d-x, you probably want to use convertToNodeSpaceAR instead + !#zh 将一个点转换到节点 (局部) 坐标系,并加上锚点的坐标。
+ 也就是说返回的坐标是相对于节点包围盒左下角的坐标。
+ 这个 API 的设计是为了和 cocos2d-x 中行为一致,更多情况下你可能需要使用 convertToNodeSpaceAR。 + @param worldPoint worldPoint + + @example + ```js + var newVec2 = node.convertToNodeSpace(cc.v2(100, 100)); + ``` + */ + convertToNodeSpace(worldPoint: Vec2): Vec2; + /** + !#en Converts a Point related to the left bottom corner of the node's bounding box to world space coordinates. + This equals to the API behavior of cocos2d-x, you probably want to use convertToWorldSpaceAR instead + !#zh 将一个相对于节点左下角的坐标位置转换到世界空间坐标系。 + 这个 API 的设计是为了和 cocos2d-x 中行为一致,更多情况下你可能需要使用 convertToWorldSpaceAR + @param nodePoint nodePoint + + @example + ```js + var newVec2 = node.convertToWorldSpace(cc.v2(100, 100)); + ``` + */ + convertToWorldSpace(nodePoint: Vec2): Vec2; + /** + !#en + Returns the matrix that transform the node's (local) space coordinates into the parent's space coordinates.
+ The matrix is in Pixels. + !#zh 返回这个将节点(局部)的空间坐标系转换成父节点的空间坐标系的矩阵。这个矩阵以像素为单位。 + @param out The affine transform object to be filled with data + + @example + ```js + let affineTransform = cc.AffineTransform.create(); + node.getNodeToParentTransform(affineTransform); + ``` + */ + getNodeToParentTransform(out?: AffineTransform): AffineTransform; + /** + !#en + Returns the matrix that transform the node's (local) space coordinates into the parent's space coordinates.
+ The matrix is in Pixels.
+ This method is AR (Anchor Relative). + !#zh + 返回这个将节点(局部)的空间坐标系转换成父节点的空间坐标系的矩阵。
+ 这个矩阵以像素为单位。
+ 该方法基于节点坐标。 + @param out The affine transform object to be filled with data + + @example + ```js + let affineTransform = cc.AffineTransform.create(); + node.getNodeToParentTransformAR(affineTransform); + ``` + */ + getNodeToParentTransformAR(out?: AffineTransform): AffineTransform; + /** + !#en Returns the world affine transform matrix. The matrix is in Pixels. + !#zh 返回节点到世界坐标系的仿射变换矩阵。矩阵单位是像素。 + @param out The affine transform object to be filled with data + + @example + ```js + let affineTransform = cc.AffineTransform.create(); + node.getNodeToWorldTransform(affineTransform); + ``` + */ + getNodeToWorldTransform(out?: AffineTransform): AffineTransform; + /** + !#en + Returns the world affine transform matrix. The matrix is in Pixels.
+ This method is AR (Anchor Relative). + !#zh + 返回节点到世界坐标仿射变换矩阵。矩阵单位是像素。
+ 该方法基于节点坐标。 + @param out The affine transform object to be filled with data + + @example + ```js + let affineTransform = cc.AffineTransform.create(); + node.getNodeToWorldTransformAR(affineTransform); + ``` + */ + getNodeToWorldTransformAR(out?: AffineTransform): AffineTransform; + /** + !#en + Returns the matrix that transform parent's space coordinates to the node's (local) space coordinates.
+ The matrix is in Pixels. The returned transform is readonly and cannot be changed. + !#zh + 返回将父节点的坐标系转换成节点(局部)的空间坐标系的矩阵。
+ 该矩阵以像素为单位。返回的矩阵是只读的,不能更改。 + @param out The affine transform object to be filled with data + + @example + ```js + let affineTransform = cc.AffineTransform.create(); + node.getParentToNodeTransform(affineTransform); + ``` + */ + getParentToNodeTransform(out?: AffineTransform): AffineTransform; + /** + !#en Returns the inverse world affine transform matrix. The matrix is in Pixels. + !#en 返回世界坐标系到节点坐标系的逆矩阵。 + @param out The affine transform object to be filled with data + + @example + ```js + let affineTransform = cc.AffineTransform.create(); + node.getWorldToNodeTransform(affineTransform); + ``` + */ + getWorldToNodeTransform(out?: AffineTransform): AffineTransform; + /** + !#en convenience methods which take a cc.Touch instead of cc.Vec2. + !#zh 将触摸点转换成本地坐标系中位置。 + @param touch The touch object + + @example + ```js + var newVec2 = node.convertTouchToNodeSpace(touch); + ``` + */ + convertTouchToNodeSpace(touch: Touch): Vec2; + /** + !#en converts a cc.Touch (world coordinates) into a local coordinate. This method is AR (Anchor Relative). + !#zh 转换一个 cc.Touch(世界坐标)到一个局部坐标,该方法基于节点坐标。 + @param touch The touch object + + @example + ```js + var newVec2 = node.convertTouchToNodeSpaceAR(touch); + ``` + */ + convertTouchToNodeSpaceAR(touch: Touch): Vec2; + /** + !#en + Returns a "local" axis aligned bounding box of the node.
+ The returned box is relative only to its parent. + !#zh 返回父节坐标系下的轴向对齐的包围盒。 + + @example + ```js + var boundingBox = node.getBoundingBox(); + ``` + */ + getBoundingBox(): Rect; + /** + !#en + Returns a "world" axis aligned bounding box of the node.
+ The bounding box contains self and active children's world bounding box. + !#zh + 返回节点在世界坐标系下的对齐轴向的包围盒(AABB)。
+ 该边框包含自身和已激活的子节点的世界边框。 + + @example + ```js + var newRect = node.getBoundingBoxToWorld(); + ``` + */ + getBoundingBoxToWorld(): Rect; + /** + !#en + Adds a child to the node with z order and name. + !#zh + 添加子节点,并且可以修改该节点的 局部 Z 顺序和名字。 + @param child A child node + @param zIndex Z order for drawing priority. Please refer to zIndex property + @param name A name to identify the node easily. Please refer to name property + + @example + ```js + node.addChild(newNode, 1, "node"); + ``` + */ + addChild(child: Node, zIndex?: number, name?: string): void; + /** + !#en Stops all running actions and schedulers. + !#zh 停止所有正在播放的动作和计时器。 + + @example + ```js + node.cleanup(); + ``` + */ + cleanup(): void; + /** + !#en Sorts the children array depends on children's zIndex and arrivalOrder, + normally you won't need to invoke this function. + !#zh 根据子节点的 zIndex 和 arrivalOrder 进行排序,正常情况下开发者不需要手动调用这个函数。 + */ + sortAllChildren(): void; + /** + !#en + Returns the displayed opacity of Node, + the difference between displayed opacity and opacity is that displayed opacity is calculated based on opacity and parent node's opacity when cascade opacity enabled. + !#zh + 获取节点显示透明度, + 显示透明度和透明度之间的不同之处在于当启用级连透明度时, + 显示透明度是基于自身透明度和父节点透明度计算的。 + */ + getDisplayedOpacity(): number; + /** + !#en + Returns the displayed color of Node, + the difference between displayed color and color is that displayed color is calculated based on color and parent node's color when cascade color enabled. + !#zh + 获取节点的显示颜色, + 显示颜色和颜色之间的不同之处在于当启用级连颜色时, + 显示颜色是基于自身颜色和父节点颜色计算的。 + */ + getDisplayedColor(): Color; + /** !#en Cascade opacity is removed from v2.0 + Indicate whether node's opacity value affect its child nodes, default value is true. + !#zh 透明度级联功能从 v2.0 开始已移除 + 节点的不透明度值是否影响其子节点,默认值为 true。 */ + cascadeOpacity: boolean; + /** + !#en Cascade opacity is removed from v2.0 + Returns whether node's opacity value affect its child nodes. + !#zh 透明度级联功能从 v2.0 开始已移除 + 返回节点的不透明度值是否影响其子节点。 + */ + isCascadeOpacityEnabled(): boolean; + /** + !#en Cascade opacity is removed from v2.0 + Enable or disable cascade opacity, if cascade enabled, child nodes' opacity will be the multiplication of parent opacity and its own opacity. + !#zh 透明度级联功能从 v2.0 开始已移除 + 启用或禁用级连不透明度,如果级连启用,子节点的不透明度将是父不透明度乘上它自己的不透明度。 + @param cascadeOpacityEnabled cascadeOpacityEnabled + */ + setCascadeOpacityEnabled(cascadeOpacityEnabled: boolean): void; + /** + !#en Opacity modify RGB have been removed since v2.0 + Set whether color should be changed with the opacity value, + useless in ccsg.Node, but this function is override in some class to have such behavior. + !#zh 透明度影响颜色配置已经被废弃 + 设置更改透明度时是否修改RGB值, + @param opacityValue opacityValue + */ + setOpacityModifyRGB(opacityValue: boolean): void; + /** + !#en Opacity modify RGB have been removed since v2.0 + Get whether color should be changed with the opacity value. + !#zh 透明度影响颜色配置已经被废弃 + 获取更改透明度时是否修改RGB值。 + */ + isOpacityModifyRGB(): boolean; + } + /** !#en + Class of private entities in Cocos Creator scenes.
+ The PrivateNode is hidden in editor, and completely transparent to users.
+ It's normally used as Node's private content created by components in parent node.
+ So in theory private nodes are not children, they are part of the parent node.
+ Private node have two important characteristics:
+ 1. It has the minimum z index and cannot be modified, because they can't be displayed over real children.
+ 2. The positioning of private nodes is also special, they will consider the left bottom corner of the parent node's bounding box as the origin of local coordinates.
+ In this way, they can be easily kept inside the bounding box.
+ Currently, it's used by RichText component and TileMap component. + !#zh + Cocos Creator 场景中的私有节点类。
+ 私有节点在编辑器中不可见,对用户透明。
+ 通常私有节点是被一些特殊的组件创建出来作为父节点的一部分而存在的,理论上来说,它们不是子节点,而是父节点的组成部分。
+ 私有节点有两个非常重要的特性:
+ 1. 它有着最小的渲染排序的 Z 轴深度,并且无法被更改,因为它们不能被显示在其他正常子节点之上。
+ 2. 它的定位也是特殊的,对于私有节点来说,父节点包围盒的左下角是它的局部坐标系原点,这个原点相当于父节点的位置减去它锚点的偏移。这样私有节点可以比较容易被控制在包围盒之中。
+ 目前在引擎中,RichText 和 TileMap 都有可能生成私有节点。 */ + export class PrivateNode extends Node { + /** + + @param name name + */ + constructor(name?: string); + } + /** !#en + cc.Scene is a subclass of cc.Node that is used only as an abstract concept.
+ cc.Scene and cc.Node are almost identical with the difference that users can not modify cc.Scene manually. + !#zh + cc.Scene 是 cc.Node 的子类,仅作为一个抽象的概念。
+ cc.Scene 和 cc.Node 有点不同,用户不应直接修改 cc.Scene。 */ + export class Scene extends Node { + /** !#en Indicates whether all (directly or indirectly) static referenced assets of this scene are releasable by default after scene unloading. + !#zh 指示该场景中直接或间接静态引用到的所有资源是否默认在场景切换后自动释放。 */ + autoReleaseAssets: boolean; + } + /** !#en + Scheduler is responsible of triggering the scheduled callbacks.
+ You should not use NSTimer. Instead use this class.
+
+ There are 2 different types of callbacks (selectors):
+ - update callback: the 'update' callback will be called every frame. You can customize the priority.
+ - custom callback: A custom callback will be called every frame, or with a custom interval of time
+
+ The 'custom selectors' should be avoided when possible. It is faster, + and consumes less memory to use the 'update callback'. * + !#zh + Scheduler 是负责触发回调函数的类。
+ 通常情况下,建议使用 cc.director.getScheduler() 来获取系统定时器。
+ 有两种不同类型的定时器:
+ - update 定时器:每一帧都会触发。您可以自定义优先级。
+ - 自定义定时器:自定义定时器可以每一帧或者自定义的时间间隔触发。
+ 如果希望每帧都触发,应该使用 update 定时器,使用 update 定时器更快,而且消耗更少的内存。 */ + export class Scheduler { + /** + !#en This method should be called for any target which needs to schedule tasks, and this method should be called before any scheduler API usage. + This method will add a `_id` property if it doesn't exist. + !#zh 任何需要用 Scheduler 管理任务的对象主体都应该调用这个方法,并且应该在调用任何 Scheduler API 之前调用这个方法。 + 这个方法会给对象添加一个 `_id` 属性,如果这个属性不存在的话。 + @param target target + */ + enableForTarget(target: any): void; + /** + !#en + Modifies the time of all scheduled callbacks.
+ You can use this property to create a 'slow motion' or 'fast forward' effect.
+ Default is 1.0. To create a 'slow motion' effect, use values below 1.0.
+ To create a 'fast forward' effect, use values higher than 1.0.
+ Note:It will affect EVERY scheduled selector / action. + !#zh + 设置时间间隔的缩放比例。
+ 您可以使用这个方法来创建一个 “slow motion(慢动作)” 或 “fast forward(快进)” 的效果。
+ 默认是 1.0。要创建一个 “slow motion(慢动作)” 效果,使用值低于 1.0。
+ 要使用 “fast forward(快进)” 效果,使用值大于 1.0。
+ 注意:它影响该 Scheduler 下管理的所有定时器。 + @param timeScale timeScale + */ + setTimeScale(timeScale: number): void; + /** + !#en Returns time scale of scheduler. + !#zh 获取时间间隔的缩放比例。 + */ + getTimeScale(): number; + /** + !#en 'update' the scheduler. (You should NEVER call this method, unless you know what you are doing.) + !#zh update 调度函数。(不应该直接调用这个方法,除非完全了解这么做的结果) + @param dt delta time + */ + update(dt: number): void; + /** + !#en +

+ The scheduled method will be called every 'interval' seconds.
+ If paused is YES, then it won't be called until it is resumed.
+ If 'interval' is 0, it will be called every frame, but if so, it recommended to use 'scheduleUpdateForTarget:' instead.
+ If the callback function is already scheduled, then only the interval parameter will be updated without re-scheduling it again.
+ repeat let the action be repeated repeat + 1 times, use cc.macro.REPEAT_FOREVER to let the action run continuously
+ delay is the amount of time the action will wait before it'll start
+

+ !#zh + 指定回调函数,调用对象等信息来添加一个新的定时器。
+ 如果 paused 值为 true,那么直到 resume 被调用才开始计时。
+ 当时间间隔达到指定值时,设置的回调函数将会被调用。
+ 如果 interval 值为 0,那么回调函数每一帧都会被调用,但如果是这样, + 建议使用 scheduleUpdateForTarget 代替。
+ 如果回调函数已经被定时器使用,那么只会更新之前定时器的时间间隔参数,不会设置新的定时器。
+ repeat 值可以让定时器触发 repeat + 1 次,使用 cc.macro.REPEAT_FOREVER + 可以让定时器一直循环触发。
+ delay 值指定延迟时间,定时器会在延迟指定的时间之后开始计时。 + @param callback callback + @param target target + @param interval interval + @param repeat repeat + @param delay delay + @param paused paused + + @example + ```js + //register a schedule to scheduler + cc.director.getScheduler().schedule(callback, this, interval, !this._isRunning); + + ``` + */ + schedule(callback: Function, target: any, interval: number, repeat: number, delay: number, paused?: boolean): void; + schedule(callback: Function, target: any, interval: number, paused?: boolean): void; + /** + !#en + Schedules the update callback for a given target, + During every frame after schedule started, the "update" function of target will be invoked. + !#zh + 使用指定的优先级为指定的对象设置 update 定时器。 + update 定时器每一帧都会被触发,触发时自动调用指定对象的 "update" 函数。 + 优先级的值越低,定时器被触发的越早。 + @param target target + @param priority priority + @param paused paused + */ + scheduleUpdate(target: any, priority: number, paused: boolean): void; + /** + !#en + Unschedules a callback for a callback and a given target. + If you want to unschedule the "update", use `unscheduleUpdate()` + !#zh + 取消指定对象定时器。 + 如果需要取消 update 定时器,请使用 unscheduleUpdate()。 + @param callback The callback to be unscheduled + @param target The target bound to the callback. + */ + unschedule(callback: Function, target: any): void; + /** + !#en Unschedules the update callback for a given target. + !#zh 取消指定对象的 update 定时器。 + @param target The target to be unscheduled. + */ + unscheduleUpdate(target: any): void; + /** + !#en + Unschedules all scheduled callbacks for a given target. + This also includes the "update" callback. + !#zh 取消指定对象的所有定时器,包括 update 定时器。 + @param target The target to be unscheduled. + */ + unscheduleAllForTarget(target: any): void; + /** + !#en + Unschedules all scheduled callbacks from all targets including the system callbacks.
+ You should NEVER call this method, unless you know what you are doing. + !#zh + 取消所有对象的所有定时器,包括系统定时器。
+ 不要调用此函数,除非你确定你在做什么。 + */ + unscheduleAll(): void; + /** + !#en + Unschedules all callbacks from all targets with a minimum priority.
+ You should only call this with `PRIORITY_NON_SYSTEM_MIN` or higher. + !#zh + 取消所有优先级的值大于指定优先级的定时器。
+ 你应该只取消优先级的值大于 PRIORITY_NON_SYSTEM_MIN 的定时器。 + @param minPriority The minimum priority of selector to be unscheduled. Which means, all selectors which + priority is higher than minPriority will be unscheduled. + */ + unscheduleAllWithMinPriority(minPriority: number): void; + /** + !#en Checks whether a callback for a given target is scheduled. + !#zh 检查指定的回调函数和回调对象组合是否存在定时器。 + @param callback The callback to check. + @param target The target of the callback. + */ + isScheduled(callback: Function, target: any): boolean; + /** + !#en + Pause all selectors from all targets.
+ You should NEVER call this method, unless you know what you are doing. + !#zh + 暂停所有对象的所有定时器。
+ 不要调用这个方法,除非你知道你正在做什么。 + */ + pauseAllTargets(): void; + /** + !#en + Pause all selectors from all targets with a minimum priority.
+ You should only call this with kCCPriorityNonSystemMin or higher. + !#zh + 暂停所有优先级的值大于指定优先级的定时器。
+ 你应该只暂停优先级的值大于 PRIORITY_NON_SYSTEM_MIN 的定时器。 + @param minPriority minPriority + */ + pauseAllTargetsWithMinPriority(minPriority: number): void; + /** + !#en + Resume selectors on a set of targets.
+ This can be useful for undoing a call to pauseAllCallbacks. + !#zh + 恢复指定数组中所有对象的定时器。
+ 这个函数是 pauseAllCallbacks 的逆操作。 + @param targetsToResume targetsToResume + */ + resumeTargets(targetsToResume: any[]): void; + /** + !#en + Pauses the target.
+ All scheduled selectors/update for a given target won't be 'ticked' until the target is resumed.
+ If the target is not present, nothing happens. + !#zh + 暂停指定对象的定时器。
+ 指定对象的所有定时器都会被暂停。
+ 如果指定的对象没有定时器,什么也不会发生。 + @param target target + */ + pauseTarget(target: any): void; + /** + !#en + Resumes the target.
+ The 'target' will be unpaused, so all schedule selectors/update will be 'ticked' again.
+ If the target is not present, nothing happens. + !#zh + 恢复指定对象的所有定时器。
+ 指定对象的所有定时器将继续工作。
+ 如果指定的对象没有定时器,什么也不会发生。 + @param target target + */ + resumeTarget(target: any): void; + /** + !#en Returns whether or not the target is paused. + !#zh 返回指定对象的定时器是否暂停了。 + @param target target + */ + isTargetPaused(target: any): boolean; + /** !#en Priority level reserved for system services. + !#zh 系统服务的优先级。 */ + static PRIORITY_SYSTEM: number; + /** !#en Minimum priority level for user scheduling. + !#zh 用户调度最低优先级。 */ + static PRIORITY_NON_SYSTEM: number; + } + /** !#en cc.VideoPlayer is a component for playing videos, you can use it for showing videos in your game. Because different platforms have different authorization, API and control methods for VideoPlayer component. And have not yet formed a unified standard, only Web, iOS, and Android platforms are currently supported. + !#zh Video 组件,用于在游戏中播放视频。由于不同平台对于 VideoPlayer 组件的授权、API、控制方式都不同,还没有形成统一的标准,所以目前只支持 Web、iOS 和 Android 平台。 */ + export class VideoPlayer extends Component { + /** !#en The resource type of videoplayer, REMOTE for remote url and LOCAL for local file path. + !#zh 视频来源:REMOTE 表示远程视频 URL,LOCAL 表示本地视频地址。 */ + resourceType: VideoPlayer.ResourceType; + /** !#en The remote URL of video. + !#zh 远程视频的 URL */ + remoteURL: string; + /** !#en The local video full path. + !#zh 本地视频的 URL */ + clip: string; + /** !#en The current playback time of the now playing item in seconds, you could also change the start playback time. + !#zh 指定视频从什么时间点开始播放,单位是秒,也可以用来获取当前视频播放的时间进度。 */ + currentTime: number; + /** !#en The volume of the video. + !#zh 视频的音量(0.0 ~ 1.0) */ + volume: number; + /** !#en Mutes the VideoPlayer. Mute sets the volume=0, Un-Mute restore the original volume. + !#zh 是否静音视频。静音时设置音量为 0,取消静音是恢复原来的音量。 */ + mute: boolean; + /** !#en Whether keep the aspect ration of the original video. + !#zh 是否保持视频原来的宽高比 */ + keepAspectRatio: boolean; + /** !#en Whether play video in fullscreen mode. + !#zh 是否全屏播放视频 */ + isFullscreen: boolean; + /** !#en Always below the game view (only useful on Web. Note: The specific effects are not guaranteed to be consistent, depending on whether each browser supports or restricts). + !#zh 永远在游戏视图最底层(这个属性只有在 Web 平台上有效果。注意:具体效果无法保证一致,跟各个浏览器是否支持与限制有关) */ + stayOnBottom: boolean; + /** !#en the video player's callback, it will be triggered when certain event occurs, like: playing, paused, stopped and completed. + !#zh 视频播放回调函数,该回调函数会在特定情况被触发,比如播放中,暂时,停止和完成播放。 */ + videoPlayerEvent: Component.EventHandler[]; + /** + !#en If a video is paused, call this method could resume playing. If a video is stopped, call this method to play from scratch. + !#zh 如果视频被暂停播放了,调用这个接口可以继续播放。如果视频被停止播放了,调用这个接口可以从头开始播放。 + */ + play(): void; + /** + !#en If a video is paused, call this method to resume playing. + !#zh 如果一个视频播放被暂停播放了,调用这个接口可以继续播放。 + */ + resume(): void; + /** + !#en If a video is playing, call this method to pause playing. + !#zh 如果一个视频正在播放,调用这个接口可以暂停播放。 + */ + pause(): void; + /** + !#en If a video is playing, call this method to stop playing immediately. + !#zh 如果一个视频正在播放,调用这个接口可以立马停止播放。 + */ + stop(): void; + /** + !#en Gets the duration of the video + !#zh 获取视频文件的播放总时长 + */ + getDuration(): number; + /** + !#en Determine whether video is playing or not. + !#zh 判断当前视频是否处于播放状态 + */ + isPlaying(): boolean; + /** + !#en if you don't need the VideoPlayer and it isn't in any running Scene, you should + call the destroy method on this component or the associated node explicitly. + Otherwise, the created DOM element won't be removed from web page. + !#zh + 如果你不再使用 VideoPlayer,并且组件未添加到场景中,那么你必须手动对组件或所在节点调用 destroy。 + 这样才能移除网页上的 DOM 节点,避免 Web 平台内存泄露。 + + @example + ```js + videoplayer.node.parent = null; // or videoplayer.node.removeFromParent(false); + // when you don't need videoplayer anymore + videoplayer.node.destroy(); + ``` + */ + destroy(): boolean; + } + /** Class for particle asset handling. */ + export class ParticleAsset extends Asset { + } + /** Particle System base class.
+ Attributes of a Particle System:
+ - emmision rate of the particles
+ - Gravity Mode (Mode A):
+ - gravity
+ - direction
+ - speed +- variance
+ - tangential acceleration +- variance
+ - radial acceleration +- variance
+ - Radius Mode (Mode B):
+ - startRadius +- variance
+ - endRadius +- variance
+ - rotate +- variance
+ - Properties common to all modes:
+ - life +- life variance
+ - start spin +- variance
+ - end spin +- variance
+ - start size +- variance
+ - end size +- variance
+ - start color +- variance
+ - end color +- variance
+ - life +- variance
+ - blending function
+ - texture
+
+ cocos2d also supports particles generated by Particle Designer (http://particledesigner.71squared.com/).
+ 'Radius Mode' in Particle Designer uses a fixed emit rate of 30 hz. Since that can't be guarateed in cocos2d,
+ cocos2d uses a another approach, but the results are almost identical.
+ cocos2d supports all the variables used by Particle Designer plus a bit more:
+ - spinning particles (supported when using ParticleSystem)
+ - tangential acceleration (Gravity mode)
+ - radial acceleration (Gravity mode)
+ - radius direction (Radius mode) (Particle Designer supports outwards to inwards direction only)
+ It is possible to customize any of the above mentioned properties in runtime. Example:
*/ + export class ParticleSystem extends RenderComponent implements BlendFunc { + /** !#en Play particle in edit mode. + !#zh 在编辑器模式下预览粒子,启用后选中粒子时,粒子将自动播放。 */ + preview: boolean; + /** !#en + If set custom to true, then use custom properties insteadof read particle file. + !#zh 是否自定义粒子属性。 */ + custom: boolean; + /** !#en The plist file. + !#zh plist 格式的粒子配置文件。 */ + file: ParticleAsset; + /** !#en SpriteFrame used for particles display + !#zh 用于粒子呈现的 SpriteFrame */ + spriteFrame: SpriteFrame; + /** !#en Texture of Particle System, readonly, please use spriteFrame to setup new texture。 + !#zh 粒子贴图,只读属性,请使用 spriteFrame 属性来替换贴图。 */ + texture: string; + /** !#en Current quantity of particles that are being simulated. + !#zh 当前播放的粒子数量。 */ + particleCount: number; + /** !#en Indicate whether the system simulation have stopped. + !#zh 指示粒子播放是否完毕。 */ + stopped: boolean; + /** !#en If set to true, the particle system will automatically start playing on onLoad. + !#zh 如果设置为 true 运行时会自动发射粒子。 */ + playOnLoad: boolean; + /** !#en Indicate whether the owner node will be auto-removed when it has no particles left. + !#zh 粒子播放完毕后自动销毁所在的节点。 */ + autoRemoveOnFinish: boolean; + /** !#en Indicate whether the particle system is activated. + !#zh 是否激活粒子。 */ + active: boolean; + /** !#en Maximum particles of the system. + !#zh 粒子最大数量。 */ + totalParticles: number; + /** !#en How many seconds the emitter wil run. -1 means 'forever'. + !#zh 发射器生存时间,单位秒,-1表示持续发射。 */ + duration: number; + /** !#en Emission rate of the particles. + !#zh 每秒发射的粒子数目。 */ + emissionRate: number; + /** !#en Life of each particle setter. + !#zh 粒子的运行时间。 */ + life: number; + /** !#en Variation of life. + !#zh 粒子的运行时间变化范围。 */ + lifeVar: number; + /** !#en Start color of each particle. + !#zh 粒子初始颜色。 */ + startColor: Color; + /** !#en Variation of the start color. + !#zh 粒子初始颜色变化范围。 */ + startColorVar: Color; + /** !#en Ending color of each particle. + !#zh 粒子结束颜色。 */ + endColor: Color; + /** !#en Variation of the end color. + !#zh 粒子结束颜色变化范围。 */ + endColorVar: Color; + /** !#en Angle of each particle setter. + !#zh 粒子角度。 */ + angle: number; + /** !#en Variation of angle of each particle setter. + !#zh 粒子角度变化范围。 */ + angleVar: number; + /** !#en Start size in pixels of each particle. + !#zh 粒子的初始大小。 */ + startSize: number; + /** !#en Variation of start size in pixels. + !#zh 粒子初始大小的变化范围。 */ + startSizeVar: number; + /** !#en End size in pixels of each particle. + !#zh 粒子结束时的大小。 */ + endSize: number; + /** !#en Variation of end size in pixels. + !#zh 粒子结束大小的变化范围。 */ + endSizeVar: number; + /** !#en Start angle of each particle. + !#zh 粒子开始自旋角度。 */ + startSpin: number; + /** !#en Variation of start angle. + !#zh 粒子开始自旋角度变化范围。 */ + startSpinVar: number; + /** !#en End angle of each particle. + !#zh 粒子结束自旋角度。 */ + endSpin: number; + /** !#en Variation of end angle. + !#zh 粒子结束自旋角度变化范围。 */ + endSpinVar: number; + /** !#en Source position of the emitter. + !#zh 发射器位置。 */ + sourcePos: Vec2; + /** !#en Variation of source position. + !#zh 发射器位置的变化范围。(横向和纵向) */ + posVar: Vec2; + /** !#en Particles movement type. + !#zh 粒子位置类型。 */ + positionType: ParticleSystem.PositionType; + /** !#en Particles emitter modes. + !#zh 发射器类型。 */ + emitterMode: ParticleSystem.EmitterMode; + /** !#en Gravity of the emitter. + !#zh 重力。 */ + gravity: Vec2; + /** !#en Speed of the emitter. + !#zh 速度。 */ + speed: number; + /** !#en Variation of the speed. + !#zh 速度变化范围。 */ + speedVar: number; + /** !#en Tangential acceleration of each particle. Only available in 'Gravity' mode. + !#zh 每个粒子的切向加速度,即垂直于重力方向的加速度,只有在重力模式下可用。 */ + tangentialAccel: number; + /** !#en Variation of the tangential acceleration. + !#zh 每个粒子的切向加速度变化范围。 */ + tangentialAccelVar: number; + /** !#en Acceleration of each particle. Only available in 'Gravity' mode. + !#zh 粒子径向加速度,即平行于重力方向的加速度,只有在重力模式下可用。 */ + radialAccel: number; + /** !#en Variation of the radial acceleration. + !#zh 粒子径向加速度变化范围。 */ + radialAccelVar: number; + /** !#en Indicate whether the rotation of each particle equals to its direction. Only available in 'Gravity' mode. + !#zh 每个粒子的旋转是否等于其方向,只有在重力模式下可用。 */ + rotationIsDir: boolean; + /** !#en Starting radius of the particles. Only available in 'Radius' mode. + !#zh 初始半径,表示粒子出生时相对发射器的距离,只有在半径模式下可用。 */ + startRadius: number; + /** !#en Variation of the starting radius. + !#zh 初始半径变化范围。 */ + startRadiusVar: number; + /** !#en Ending radius of the particles. Only available in 'Radius' mode. + !#zh 结束半径,只有在半径模式下可用。 */ + endRadius: number; + /** !#en Variation of the ending radius. + !#zh 结束半径变化范围。 */ + endRadiusVar: number; + /** !#en Number of degress to rotate a particle around the source pos per second. Only available in 'Radius' mode. + !#zh 粒子每秒围绕起始点的旋转角度,只有在半径模式下可用。 */ + rotatePerS: number; + /** !#en Variation of the degress to rotate a particle around the source pos per second. + !#zh 粒子每秒围绕起始点的旋转角度变化范围。 */ + rotatePerSVar: number; + /** !#en The Particle emitter lives forever. + !#zh 表示发射器永久存在 */ + static DURATION_INFINITY: number; + /** !#en The starting size of the particle is equal to the ending size. + !#zh 表示粒子的起始大小等于结束大小。 */ + static START_SIZE_EQUAL_TO_END_SIZE: number; + /** !#en The starting radius of the particle is equal to the ending radius. + !#zh 表示粒子的起始半径等于结束半径。 */ + static START_RADIUS_EQUAL_TO_END_RADIUS: number; + /** + !#en Stop emitting particles. Running particles will continue to run until they die. + !#zh 停止发射器发射粒子,发射出去的粒子将继续运行,直至粒子生命结束。 + + @example + ```js + // stop particle system. + myParticleSystem.stopSystem(); + ``` + */ + stopSystem(): void; + /** + !#en Kill all living particles. + !#zh 杀死所有存在的粒子,然后重新启动粒子发射器。 + + @example + ```js + // play particle system. + myParticleSystem.resetSystem(); + ``` + */ + resetSystem(): void; + /** + !#en Whether or not the system is full. + !#zh 发射器中粒子是否大于等于设置的总粒子数量。 + */ + isFull(): boolean; + /** + !#en Sets a new texture with a rect. The rect is in texture position and size. + Please use spriteFrame property instead, this function is deprecated since v1.9 + !#zh 设置一张新贴图和关联的矩形。 + 请直接设置 spriteFrame 属性,这个函数从 v1.9 版本开始已经被废弃 + @param texture texture + @param rect rect + */ + setTextureWithRect(texture: Texture2D, rect: Rect): void; + /** !#en specify the source Blend Factor, this will generate a custom material object, please pay attention to the memory cost. + !#zh 指定原图的混合模式,这会克隆一个新的材质对象,注意这带来的开销 */ + srcBlendFactor: macro.BlendFactor; + /** !#en specify the destination Blend Factor. + !#zh 指定目标的混合模式 */ + dstBlendFactor: macro.BlendFactor; + } + /** cc.TMXLayerInfo contains the information about the layers like: + - Layer name + - Layer size + - Layer opacity at creation time (it can be modified at runtime) + - Whether the layer is visible (if it's not visible, then the CocosNode won't be created) + This information is obtained from the TMX file. */ + export class TMXLayerInfo { + /** Properties of the layer info. */ + properties: any; + } + /** cc.TMXImageLayerInfo contains the information about the image layers. + This information is obtained from the TMX file. */ + export class TMXImageLayerInfo { + } + /**

cc.TMXObjectGroupInfo contains the information about the object group like: + - group name + - group size + - group opacity at creation time (it can be modified at runtime) + - Whether the group is visible + + This information is obtained from the TMX file.

*/ + export class TMXObjectGroupInfo { + /** Properties of the ObjectGroup info. */ + properties: any[]; + } + /**

cc.TMXTilesetInfo contains the information about the tilesets like:
+ - Tileset name
+ - Tileset spacing
+ - Tileset margin
+ - size of the tiles
+ - Image used for the tiles
+ - Image size
+ + This information is obtained from the TMX file.

*/ + export class TMXTilesetInfo { + /** Tileset name */ + name: string; + /** First grid */ + firstGid: number; + /** Spacing */ + spacing: number; + /** Margin */ + margin: number; + /** Texture containing the tiles (should be sprite sheet / texture atlas) */ + sourceImage: any; + /** Size in pixels of the image */ + imageSize: Size; + } + /**

cc.TMXMapInfo contains the information about the map like:
+ - Map orientation (hexagonal, isometric or orthogonal)
+ - Tile size
+ - Map size

+ +

And it also contains:
+ - Layers (an array of TMXLayerInfo objects)
+ - Tilesets (an array of TMXTilesetInfo objects)
+ - ObjectGroups (an array of TMXObjectGroupInfo objects)

+ +

This information is obtained from the TMX file.

*/ + export class TMXMapInfo { + /** Properties of the map info. */ + properties: any[]; + /** Map orientation. */ + orientation: number; + /** Parent element. */ + parentElement: any; + /** Parent GID. */ + parentGID: number; + /** Layer attributes. */ + layerAttrs: any; + /** Is reading storing characters stream. */ + storingCharacters: boolean; + /** Current string stored from characters stream. */ + currentString: string; + /** Width of the map */ + mapWidth: number; + /** Height of the map */ + mapHeight: number; + /** Width of a tile */ + tileWidth: number; + /** Height of a tile */ + tileHeight: number; + static ATTRIB_NONE: number; + static ATTRIB_BASE64: number; + static ATTRIB_GZIP: number; + static ATTRIB_ZLIB: number; + } + /** !#en Render the TMX layer. + !#zh 渲染 TMX layer。 */ + export class TiledLayer extends Component { + /** + !#en enable or disable culling + !#zh 开启或关闭裁剪。 + @param value value + */ + enableCulling(value: any): void; + /** + !#en Adds user's node into layer. + !#zh 添加用户节点。 + @param node node + */ + addUserNode(node: Node): boolean; + /** + !#en Removes user's node. + !#zh 移除用户节点。 + @param node node + */ + removeUserNode(node: Node): boolean; + /** + !#en Destroy user's node. + !#zh 销毁用户节点。 + @param node node + */ + destroyUserNode(node: Node): void; + /** + !#en Gets the layer name. + !#zh 获取层的名称。 + + @example + ```js + let layerName = tiledLayer.getLayerName(); + cc.log(layerName); + ``` + */ + getLayerName(): string; + /** + !#en Set the layer name. + !#zh 设置层的名称 + @param layerName layerName + + @example + ```js + tiledLayer.setLayerName("New Layer"); + ``` + */ + SetLayerName(layerName: string): void; + /** + !#en Return the value for the specific property name. + !#zh 获取指定属性名的值。 + @param propertyName propertyName + + @example + ```js + let property = tiledLayer.getProperty("info"); + cc.log(property); + ``` + */ + getProperty(propertyName: string): any; + /** + !#en Returns the position in pixels of a given tile coordinate. + !#zh 获取指定 tile 的像素坐标。 + @param pos position or x + @param y y + + @example + ```js + let pos = tiledLayer.getPositionAt(cc.v2(0, 0)); + cc.log("Pos: " + pos); + let pos = tiledLayer.getPositionAt(0, 0); + cc.log("Pos: " + pos); + ``` + */ + getPositionAt(pos: Vec2|number, y?: number): Vec2; + /** + !#en + Sets the tiles gid (gid = tile global id) at a given tiles rect. + !#zh + 设置给定区域的 tile 的 gid (gid = tile 全局 id), + @param gids an array contains gid + @param beginCol begin col number + @param beginRow begin row number + @param totalCols count of column + + @example + ```js + tiledLayer.setTilesGIDAt([1, 1, 1, 1], 10, 10, 2) + ``` + */ + setTilesGIDAt(gids: any[], beginCol: number, beginRow: number, totalCols: number): void; + /** + !#en + Sets the tile gid (gid = tile global id) at a given tile coordinate.
+ The Tile GID can be obtained by using the method "tileGIDAt" or by using the TMX editor . Tileset Mgr +1.
+ If a tile is already placed at that position, then it will be removed. + !#zh + 设置给定坐标的 tile 的 gid (gid = tile 全局 id), + tile 的 GID 可以使用方法 “tileGIDAt” 来获得。
+ 如果一个 tile 已经放在那个位置,那么它将被删除。 + @param gid gid + @param posOrX position or x + @param flagsOrY flags or y + @param flags flags + + @example + ```js + tiledLayer.setTileGIDAt(1001, 10, 10, 1) + ``` + */ + setTileGIDAt(gid: number, posOrX: Vec2|number, flagsOrY: number, flags?: number): void; + /** + !#en + Returns the tiles data.An array fill with GIDs.
+ !#zh + 返回 tiles 数据. 由GID构成的一个数组.
+ */ + getTiles(): number[]; + /** + !#en + Returns the tile gid at a given tile coordinate.
+ if it returns 0, it means that the tile is empty.
+ !#zh + 通过给定的 tile 坐标、flags(可选)返回 tile 的 GID.
+ 如果它返回 0,则表示该 tile 为空。
+ @param pos or x + @param y y + + @example + ```js + let tileGid = tiledLayer.getTileGIDAt(0, 0); + ``` + */ + getTileGIDAt(pos: Vec2|number, y?: number): number; + /** + !#en Layer orientation, which is the same as the map orientation. + !#zh 获取 Layer 方向(同地图方向)。 + + @example + ```js + let orientation = tiledLayer.getLayerOrientation(); + cc.log("Layer Orientation: " + orientation); + ``` + */ + getLayerOrientation(): number; + /** + !#en properties from the layer. They can be added using Tiled. + !#zh 获取 layer 的属性,可以使用 Tiled 编辑器添加属性。 + + @example + ```js + let properties = tiledLayer.getProperties(); + cc.log("Properties: " + properties); + ``` + */ + getProperties(): any; + /** + !#en + Get the TiledTile with the tile coordinate.
+ If there is no tile in the specified coordinate and forceCreate parameter is true,
+ then will create a new TiledTile at the coordinate. + The renderer will render the tile with the rotation, scale, position and color property of the TiledTile. + !#zh + 通过指定的 tile 坐标获取对应的 TiledTile。
+ 如果指定的坐标没有 tile,并且设置了 forceCreate 那么将会在指定的坐标创建一个新的 TiledTile 。
+ 在渲染这个 tile 的时候,将会使用 TiledTile 的节点的旋转、缩放、位移、颜色属性。
+ @param x x + @param y y + @param forceCreate forceCreate + + @example + ```js + let tile = tiledLayer.getTiledTileAt(100, 100, true); + cc.log(tile); + ``` + */ + getTiledTileAt(x: number, y: number, forceCreate: boolean): TiledTile; + /** + !#en + Change tile to TiledTile at the specified coordinate. + !#zh + 将指定的 tile 坐标替换为指定的 TiledTile。 + @param x x + @param y y + @param tiledTile tiledTile + */ + setTiledTileAt(x: number, y: number, tiledTile: TiledTile): TiledTile; + /** + !#en Return texture. + !#zh 获取纹理。 + @param index The index of textures + */ + getTexture(index: any): Texture2D; + /** + !#en Return texture. + !#zh 获取纹理。 + */ + getTextures(): Texture2D; + /** + !#en Set the texture. + !#zh 设置纹理。 + @param texture texture + */ + setTexture(texture: Texture2D): void; + /** + !#en Set the texture. + !#zh 设置纹理。 + @param textures textures + */ + setTexture(textures: Texture2D): void; + /** + !#en Gets layer size. + !#zh 获得层大小。 + + @example + ```js + let size = tiledLayer.getLayerSize(); + cc.log("layer size: " + size); + ``` + */ + getLayerSize(): Size; + /** + !#en Size of the map's tile (could be different from the tile's size). + !#zh 获取 tile 的大小( tile 的大小可能会有所不同)。 + + @example + ```js + let mapTileSize = tiledLayer.getMapTileSize(); + cc.log("MapTile size: " + mapTileSize); + ``` + */ + getMapTileSize(): Size; + /** + !#en Gets Tile set first information for the layer. + !#zh 获取 layer 索引位置为0的 Tileset 信息。 + @param index The index of tilesets + */ + getTileSet(index: any): TMXTilesetInfo; + /** + !#en Gets tile set all information for the layer. + !#zh 获取 layer 所有的 Tileset 信息。 + */ + getTileSet(): TMXTilesetInfo; + /** + !#en Sets tile set information for the layer. + !#zh 设置 layer 的 tileset 信息。 + @param tileset tileset + */ + setTileSet(tileset: TMXTilesetInfo): void; + /** + !#en Sets Tile set information for the layer. + !#zh 设置 layer 的 Tileset 信息。 + @param tilesets tilesets + */ + setTileSets(tilesets: TMXTilesetInfo): void; + } + /** !#en Renders a TMX Tile Map in the scene. + !#zh 在场景中渲染一个 tmx 格式的 Tile Map。 */ + export class TiledMap extends Component { + /** !#en The TiledMap Asset. + !#zh TiledMap 资源。 */ + tmxAsset: TiledMapAsset; + /** + !#en Gets the map size. + !#zh 获取地图大小。 + + @example + ```js + let mapSize = tiledMap.getMapSize(); + cc.log("Map Size: " + mapSize); + ``` + */ + getMapSize(): Size; + /** + !#en Gets the tile size. + !#zh 获取地图背景中 tile 元素的大小。 + + @example + ```js + let tileSize = tiledMap.getTileSize(); + cc.log("Tile Size: " + tileSize); + ``` + */ + getTileSize(): Size; + /** + !#en map orientation. + !#zh 获取地图方向。 + + @example + ```js + let mapOrientation = tiledMap.getMapOrientation(); + cc.log("Map Orientation: " + mapOrientation); + ``` + */ + getMapOrientation(): number; + /** + !#en object groups. + !#zh 获取所有的对象层。 + + @example + ```js + let objGroups = titledMap.getObjectGroups(); + for (let i = 0; i < objGroups.length; ++i) { + cc.log("obj: " + objGroups[i]); + } + ``` + */ + getObjectGroups(): TiledObjectGroup[]; + /** + !#en Return the TMXObjectGroup for the specific group. + !#zh 获取指定的 TMXObjectGroup。 + @param groupName groupName + + @example + ```js + let group = titledMap.getObjectGroup("Players"); + cc.log("ObjectGroup: " + group); + ``` + */ + getObjectGroup(groupName: string): TiledObjectGroup; + /** + !#en enable or disable culling + !#zh 开启或关闭裁剪。 + @param value value + */ + enableCulling(value: any): void; + /** + !#en Gets the map properties. + !#zh 获取地图的属性。 + + @example + ```js + let properties = titledMap.getProperties(); + for (let i = 0; i < properties.length; ++i) { + cc.log("Properties: " + properties[i]); + } + ``` + */ + getProperties(): any[]; + /** + !#en Return All layers array. + !#zh 返回包含所有 layer 的数组。 + + @example + ```js + let layers = titledMap.getLayers(); + for (let i = 0; i < layers.length; ++i) { + cc.log("Layers: " + layers[i]); + } + ``` + */ + getLayers(): TiledLayer[]; + /** + !#en return the cc.TiledLayer for the specific layer. + !#zh 获取指定名称的 layer。 + @param layerName layerName + + @example + ```js + let layer = titledMap.getLayer("Player"); + cc.log(layer); + ``` + */ + getLayer(layerName: string): TiledLayer; + /** + !#en Return the value for the specific property name. + !#zh 通过属性名称,获取指定的属性。 + @param propertyName propertyName + + @example + ```js + let property = titledMap.getProperty("info"); + cc.log("Property: " + property); + ``` + */ + getProperty(propertyName: string): string; + /** + !#en Return properties dictionary for tile GID. + !#zh 通过 GID ,获取指定的属性。 + @param GID GID + + @example + ```js + let properties = titledMap.getPropertiesForGID(GID); + cc.log("Properties: " + properties); + ``` + */ + getPropertiesForGID(GID: number): any; + } + /** Class for tiled map asset handling. */ + export class TiledMapAsset extends Asset { + textures: Texture2D[]; + textureNames: string[]; + textureSizes: Size[]; + imageLayerTextures: Texture2D[]; + imageLayerTextureNames: string[]; + } + /** !#en Renders the TMX object group. + !#zh 渲染 tmx object group。 */ + export class TiledObjectGroup extends Component { + /** + !#en Offset position of child objects. + !#zh 获取子对象的偏移位置。 + + @example + ```js + let offset = tMXObjectGroup.getPositionOffset(); + ``` + */ + getPositionOffset(): Vec2; + /** + !#en List of properties stored in a dictionary. + !#zh 以映射的形式获取属性列表。 + + @example + ```js + let offset = tMXObjectGroup.getProperties(); + ``` + */ + getProperties(): any; + /** + !#en Gets the Group name. + !#zh 获取组名称。 + + @example + ```js + let groupName = tMXObjectGroup.getGroupName; + ``` + */ + getGroupName(): string; + /** + !#en + Return the object for the specific object name.
+ It will return the 1st object found on the array for the given name. + !#zh 获取指定的对象。 + @param objectName objectName + + @example + ```js + let object = tMXObjectGroup.getObject("Group"); + ``` + */ + getObject(objectName: string): any; + /** + !#en Gets the objects. + !#zh 获取对象数组。 + + @example + ```js + let objects = tMXObjectGroup.getObjects(); + ``` + */ + getObjects(): any[]; + } + /** !#en TiledTile can control the specified map tile. + It will apply the node rotation, scale, translate to the map tile. + You can change the TiledTile's gid to change the map tile's style. + !#zh TiledTile 可以单独对某一个地图块进行操作。 + 他会将节点的旋转,缩放,平移操作应用在这个地图块上,并可以通过更换当前地图块的 gid 来更换地图块的显示样式。 */ + export class TiledTile extends Component { + /** !#en Specify the TiledTile horizontal coordinate,use map tile as the unit. + !#zh 指定 TiledTile 的横向坐标,以地图块为单位 */ + x: number; + /** !#en Specify the TiledTile vertical coordinate,use map tile as the unit. + !#zh 指定 TiledTile 的纵向坐标,以地图块为单位 */ + y: number; + /** !#en Specify the TiledTile gid. + !#zh 指定 TiledTile 的 gid 值 */ + gid: number; + } + /** !#en cc.WebView is a component for display web pages in the game. Because different platforms have different authorization, API and control methods for WebView component. And have not yet formed a unified standard, only Web, iOS, and Android platforms are currently supported. + !#zh WebView 组件,用于在游戏中显示网页。由于不同平台对于 WebView 组件的授权、API、控制方式都不同,还没有形成统一的标准,所以目前只支持 Web、iOS 和 Android 平台。 */ + export class WebView extends Component { + /** !#en A given URL to be loaded by the WebView, it should have a http or https prefix. + !#zh 指定 WebView 加载的网址,它应该是一个 http 或者 https 开头的字符串 */ + url: string; + /** !#en The webview's event callback , it will be triggered when certain webview event occurs. + !#zh WebView 的回调事件,当网页加载过程中,加载完成后或者加载出错时都会回调此函数 */ + webviewLoadedEvents: Component.EventHandler[]; + /** + !#en + Set javascript interface scheme (see also setOnJSCallback).
+ Note: Supports only on the Android and iOS. For HTML5, please refer to the official documentation.
+ Please refer to the official documentation for more details. + !#zh + 设置 JavaScript 接口方案(与 'setOnJSCallback' 配套使用)。
+ 注意:只支持 Android 和 iOS ,Web 端用法请前往官方文档查看。
+ 详情请参阅官方文档 + @param scheme scheme + */ + setJavascriptInterfaceScheme(scheme: string): void; + /** + !#en + This callback called when load URL that start with javascript + interface scheme (see also setJavascriptInterfaceScheme).
+ Note: Supports only on the Android and iOS. For HTML5, please refer to the official documentation.
+ Please refer to the official documentation for more details. + !#zh + 当加载 URL 以 JavaScript 接口方案开始时调用这个回调函数。
+ 注意:只支持 Android 和 iOS,Web 端用法请前往官方文档查看。 + 详情请参阅官方文档 + @param callback callback + */ + setOnJSCallback(callback: Function): void; + /** + !#en + Evaluates JavaScript in the context of the currently displayed page.
+ Please refer to the official document for more details
+ Note: Cross domain issues need to be resolved by yourself
+ !#zh + 执行 WebView 内部页面脚本(详情请参阅官方文档)
+ 注意:需要自行解决跨域问题 + @param str str + */ + evaluateJS(str: string): void; + /** + !#en if you don't need the WebView and it isn't in any running Scene, you should + call the destroy method on this component or the associated node explicitly. + Otherwise, the created DOM element won't be removed from web page. + !#zh + 如果你不再使用 WebView,并且组件未添加到场景中,那么你必须手动对组件或所在节点调用 destroy。 + 这样才能移除网页上的 DOM 节点,避免 Web 平台内存泄露。 + + @example + ```js + webview.node.parent = null; // or webview.node.removeFromParent(false); + // when you don't need webview anymore + webview.node.destroy(); + ``` + */ + destroy(): boolean; + } + /** !#en + cc.NodePool is the cache pool designed for node type.
+ It can helps you to improve your game performance for objects which need frequent release and recreate operations
+ + It's recommended to create cc.NodePool instances by node type, the type corresponds to node type in game design, not the class, + for example, a prefab is a specific node type.
+ When you create a node pool, you can pass a Component which contains `unuse`, `reuse` functions to control the content of node.
+ + Some common use case is :
+ 1. Bullets in game (die very soon, massive creation and recreation, no side effect on other objects)
+ 2. Blocks in candy crash (massive creation and recreation)
+ etc... + !#zh + cc.NodePool 是用于管理节点对象的对象缓存池。
+ 它可以帮助您提高游戏性能,适用于优化对象的反复创建和销毁
+ 以前 cocos2d-x 中的 cc.pool 和新的节点事件注册系统不兼容,因此请使用 cc.NodePool 来代替。 + + 新的 NodePool 需要实例化之后才能使用,每种不同的节点对象池需要一个不同的对象池实例,这里的种类对应于游戏中的节点设计,一个 prefab 相当于一个种类的节点。
+ 在创建缓冲池时,可以传入一个包含 unuse, reuse 函数的组件类型用于节点的回收和复用逻辑。
+ + 一些常见的用例是:
+ 1.在游戏中的子弹(死亡很快,频繁创建,对其他对象无副作用)
+ 2.糖果粉碎传奇中的木块(频繁创建)。 + 等等.... */ + export class NodePool { + /** + !#en + Constructor for creating a pool for a specific node template (usually a prefab). You can pass a component (type or name) argument for handling event for reusing and recycling node. + !#zh + 使用构造函数来创建一个节点专用的对象池,您可以传递一个组件类型或名称,用于处理节点回收和复用时的事件逻辑。 + @param poolHandlerComp !#en The constructor or the class name of the component to control the unuse/reuse logic. !#zh 处理节点回收和复用事件逻辑的组件类型或名称。 + + @example + ```js + properties: { + template: cc.Prefab + }, + onLoad () { + // MyTemplateHandler is a component with 'unuse' and 'reuse' to handle events when node is reused or recycled. + this.myPool = new cc.NodePool('MyTemplateHandler'); + } + ``` + */ + constructor(poolHandlerComp?: {prototype: Component}|string); + /** !#en The pool handler component, it could be the class name or the constructor. + !#zh 缓冲池处理组件,用于节点的回收和复用逻辑,这个属性可以是组件类名或组件的构造函数。 */ + poolHandlerComp: Function|string; + /** + !#en The current available size in the pool + !#zh 获取当前缓冲池的可用对象数量 + */ + size(): number; + /** + !#en Destroy all cached nodes in the pool + !#zh 销毁对象池中缓存的所有节点 + */ + clear(): void; + /** + !#en Put a new Node into the pool. + It will automatically remove the node from its parent without cleanup. + It will also invoke unuse method of the poolHandlerComp if exist. + !#zh 向缓冲池中存入一个不再需要的节点对象。 + 这个函数会自动将目标节点从父节点上移除,但是不会进行 cleanup 操作。 + 这个函数会调用 poolHandlerComp 的 unuse 函数,如果组件和函数都存在的话。 + @param obj obj + + @example + ```js + let myNode = cc.instantiate(this.template); + this.myPool.put(myNode); + ``` + */ + put(obj: Node): void; + /** + !#en Get a obj from pool, if no available object in pool, null will be returned. + This function will invoke the reuse function of poolHandlerComp if exist. + !#zh 获取对象池中的对象,如果对象池没有可用对象,则返回空。 + 这个函数会调用 poolHandlerComp 的 reuse 函数,如果组件和函数都存在的话。 + @param params !#en Params to pass to 'reuse' method in poolHandlerComp !#zh 向 poolHandlerComp 中的 'reuse' 函数传递的参数 + + @example + ```js + let newNode = this.myPool.get(); + ``` + */ + get(...params: any[]): Node; + } + /** !#en + Camera is usefull when making reel game or other games which need scroll screen. + Using camera will be more efficient than moving node to scroll screen. + Camera + !#zh + 摄像机在制作卷轴或是其他需要移动屏幕的游戏时比较有用,使用摄像机将会比移动节点来移动屏幕更加高效。 */ + export class Camera extends Component { + /** !#en + The camera zoom ratio, only support 2D camera. + !#zh + 摄像机缩放比率, 只支持 2D camera。 */ + zoomRatio: number; + /** !#en + Field of view. The width of the Camera’s view angle, measured in degrees along the local Y axis. + !#zh + 决定摄像机视角的宽度,当摄像机处于透视投影模式下这个属性才会生效。 */ + fov: number; + /** !#en + The viewport size of the Camera when set to orthographic projection. + !#zh + 摄像机在正交投影模式下的视窗大小。 */ + orthoSize: number; + /** !#en + The near clipping plane. + !#zh + 摄像机的近剪裁面。 */ + nearClip: number; + /** !#en + The far clipping plane. + !#zh + 摄像机的远剪裁面。 */ + farClip: number; + /** !#en + Is the camera orthographic (true) or perspective (false)? + !#zh + 设置摄像机的投影模式是正交还是透视模式。 */ + ortho: boolean; + /** !#en + Four values (0 ~ 1) that indicate where on the screen this camera view will be drawn. + !#zh + 决定摄像机绘制在屏幕上哪个位置,值为(0 ~ 1)。 */ + rect: Rect; + /** !#en + This is used to render parts of the scene selectively. + !#zh + 决定摄像机会渲染场景的哪一部分。 */ + cullingMask: number; + /** !#en + Determining what to clear when camera rendering. + !#zh + 决定摄像机渲染时会清除哪些状态。 */ + clearFlags: Camera.ClearFlags; + /** !#en + The color with which the screen will be cleared. + !#zh + 摄像机用于清除屏幕的背景色。 */ + backgroundColor: Color; + /** !#en + Camera's depth in the camera rendering order. Cameras with higher depth are rendered after cameras with lower depth. + !#zh + 摄像机深度。用于决定摄像机的渲染顺序,值越大渲染在越上层。 */ + depth: number; + /** !#en + Destination render texture. + Usually cameras render directly to screen, but for some effects it is useful to make a camera render into a texture. + !#zh + 摄像机渲染的目标 RenderTexture。 + 一般摄像机会直接渲染到屏幕上,但是有一些效果可以使用摄像机渲染到 RenderTexture 上再对 RenderTexture 进行处理来实现。 */ + targetTexture: RenderTexture; + /** !#en + Sets the camera's render stages. + !#zh + 设置摄像机渲染的阶段 */ + renderStages: number; + /** !#en Whether auto align camera viewport to screen + !#zh 是否自动将摄像机的视口对准屏幕 */ + alignWithScreen: boolean; + /** !#en + The primary camera in the scene. Returns the rear most rendered camera, which is the camera with the lowest depth. + !#zh + 当前场景中激活的主摄像机。将会返回渲染在屏幕最底层,也就是 depth 最小的摄像机。 */ + static main: Camera; + /** !#en + All enabled cameras. + !#zh + 当前激活的所有摄像机。 */ + static cameras: Camera[]; + /** + !#en + Get the first camera which the node belong to. + !#zh + 获取节点所在的第一个摄像机。 + @param node node + */ + static findCamera(node: Node): Camera; + /** + !#en + Get the screen to world matrix, only support 2D camera which alignWithScreen is true. + !#zh + 获取屏幕坐标系到世界坐标系的矩阵,只适用于 alignWithScreen 为 true 的 2D 摄像机。 + @param out the matrix to receive the result + */ + getScreenToWorldMatrix2D(out: Mat4): Mat4; + /** + !#en + Get the world to camera matrix, only support 2D camera which alignWithScreen is true. + !#zh + 获取世界坐标系到摄像机坐标系的矩阵,只适用于 alignWithScreen 为 true 的 2D 摄像机。 + @param out the matrix to receive the result + */ + getWorldToScreenMatrix2D(out: Mat4): Mat4; + /** + !#en + Convert point from screen to world. + !#zh + 将坐标从屏幕坐标系转换到世界坐标系。 + @param screenPosition screenPosition + @param out out + */ + getScreenToWorldPoint(screenPosition: Vec3|Vec2, out?: Vec3|Vec2): Vec3; + /** + !#en + Convert point from world to screen. + !#zh + 将坐标从世界坐标系转化到屏幕坐标系。 + @param worldPosition worldPosition + @param out out + */ + getWorldToScreenPoint(worldPosition: Vec3|Vec2, out?: Vec3|Vec2): Vec3; + /** + !#en + Get a ray from screen position + !#zh + 从屏幕坐标获取一条射线 + @param screenPos screenPos + */ + getRay(screenPos: Vec2): geomUtils.Ray; + /** + !#en + Check whether the node is in the camera. + !#zh + 检测节点是否被此摄像机影响 + @param node the node which need to check + */ + containsNode(node: Node): boolean; + /** + !#en + Render the camera manually. + !#zh + 手动渲染摄像机。 + @param rootNode rootNode + */ + render(rootNode?: Node): void; + /** + !#en + Returns the matrix that transform the node's (local) space coordinates into the camera's space coordinates. + !#zh + 返回一个将节点坐标系转换到摄像机坐标系下的矩阵 + @param node the node which should transform + */ + getNodeToCameraTransform(node: Node): AffineTransform; + /** + !#en + Conver a camera coordinates point to world coordinates. + !#zh + 将一个摄像机坐标系下的点转换到世界坐标系下。 + @param point the point which should transform + @param out the point to receive the result + */ + getCameraToWorldPoint(point: Vec2, out?: Vec2): Vec2; + /** + !#en + Conver a world coordinates point to camera coordinates. + !#zh + 将一个世界坐标系下的点转换到摄像机坐标系下。 + @param point point + @param out the point to receive the result + */ + getWorldToCameraPoint(point: Vec2, out?: Vec2): Vec2; + /** + !#en + Get the camera to world matrix + !#zh + 获取摄像机坐标系到世界坐标系的矩阵 + @param out the matrix to receive the result + */ + getCameraToWorldMatrix(out: Mat4): Mat4; + /** + !#en + Get the world to camera matrix + !#zh + 获取世界坐标系到摄像机坐标系的矩阵 + @param out the matrix to receive the result + */ + getWorldToCameraMatrix(out: Mat4): Mat4; + } + /** !#en The Light Component + + !#zh 光源组件 */ + export class Light extends Component { + } + /** !#en + This module controls asset's behaviors and information, include loading, releasing etc. it is a singleton + All member can be accessed with `cc.assetManager`. + + !#zh + 此模块管理资源的行为和信息,包括加载,释放等,这是一个单例,所有成员能够通过 `cc.assetManager` 调用 */ + export class AssetManager { + /** !#en + Normal loading pipeline + + !#zh + 正常加载管线 */ + pipeline: cc.AssetManager.Pipeline; + /** !#en + Fetching pipeline + + !#zh + 下载管线 */ + fetchPipeline: cc.AssetManager.Pipeline; + /** !#en + Url transformer + + !#zh + Url 转换器 */ + transformPipeline: cc.AssetManager.Pipeline; + /** !#en + The collection of bundle which is already loaded, you can remove cache with {{#crossLink "AssetManager/removeBundle:method"}}{{/crossLink}} + + !#zh + 已加载 bundle 的集合, 你能通过 {{#crossLink "AssetManager/removeBundle:method"}}{{/crossLink}} 来移除缓存 */ + bundles: AssetManager.Cache; + /** !#en + The collection of asset which is already loaded, you can remove cache with {{#crossLink "AssetManager/releaseAsset:method"}}{{/crossLink}} + + !#zh + 已加载资源的集合, 你能通过 {{#crossLink "AssetManager/releaseAsset:method"}}{{/crossLink}} 来移除缓存 */ + assets: AssetManager.Cache; + /** !#en + Manage relationship between asset and its dependencies + + !#zh + 管理资源依赖关系 */ + dependUtil: cc.AssetManager.DependUtil; + /** !#en + Whether or not cache the loaded asset + + !#zh + 是否缓存已加载的资源 */ + cacheAsset: boolean; + /** !#en + Whether or not load asset forcely, if it is true, asset will be loaded regardless of error + + !#zh + 是否强制加载资源, 如果为 true ,加载资源将会忽略报错 */ + force: boolean; + /** !#en + Some useful function + + !#zh + 一些有用的方法 */ + utils: cc.AssetManager.Helper; + /** !#en + Manage all downloading task + + !#zh + 管理所有下载任务 */ + downloader: cc.AssetManager.Downloader; + /** !#en + Manage all parsing task + + !#zh + 管理所有解析任务 */ + parser: cc.AssetManager.Parser; + /** !#en + Manage internal asset + + !#zh + 管理内置资源 */ + builtins: cc.AssetManager.Builtins; + /** !#en + Manage all packed asset + + !#zh + 管理所有合并后的资源 */ + packManager: cc.AssetManager.PackManager; + /** !#en + Cache manager is a module which controls all caches downloaded from server in non-web platform. + + !#zh + 缓存管理器是一个模块,在非 WEB 平台上,用于管理所有从服务器上下载下来的缓存 */ + cacheManager: cc.AssetManager.CacheManager|null; + /** !#en + The preset of options + + !#zh + 可选参数的预设集 */ + presets: Record>; + /** !#en + The builtin 'main' bundle + + !#zh + 内置 main 包 */ + main: cc.AssetManager.Bundle; + /** !#en + The builtin 'resources' bundle + + !#zh + 内置 resources 包 */ + resources: cc.AssetManager.Bundle; + /** !#en + The builtin 'internal' bundle + + !#zh + 内置 internal 包 */ + internal: cc.AssetManager.Bundle; + /** + !#en + Initialize assetManager with options + + !#zh + 初始化资源管理器 + @param options options + */ + init(options: Record): void; + /** + !#en + Get the bundle which has been loaded + + !#zh + 获取已加载的分包 + @param name The name of bundle + + @example + ```js + // ${project}/assets/test1 + cc.assetManager.getBundle('test1'); + + cc.assetManager.getBundle('resources'); + ``` + */ + getBundle (name: string): cc.AssetManager.Bundle; + /** + !#en + Remove this bundle. NOTE: The asset whthin this bundle will not be released automatically, you can call {{#crossLink "Bundle/releaseAll:method"}}{{/crossLink}} manually before remove it if you need + + !#zh + 移除此包, 注意:这个包内的资源不会自动释放, 如果需要的话你可以在摧毁之前手动调用 {{#crossLink "Bundle/releaseAll:method"}}{{/crossLink}} 进行释放 + @param bundle The bundle to be removed + */ + removeBundle(bundle: cc.AssetManager.Bundle): void; + /** + !#en + General interface used to load assets with a progression callback and a complete callback. You can achieve almost all effect you want with combination of `requests` and `options`. + It is highly recommended that you use more simple API, such as `load`, `loadDir` etc. Every custom parameter in `options` will be distribute to each of `requests`. + if request already has same one, the parameter in request will be given priority. Besides, if request has dependencies, `options` will distribute to dependencies too. + Every custom parameter in `requests` will be tranfered to handler of `downloader` and `parser` as `options`. + You can register you own handler downloader or parser to collect these custom parameters for some effect. + + Reserved Keyword: `uuid`, `url`, `path`, `dir`, `scene`, `type`, `priority`, `preset`, `audioLoadMode`, `ext`, `bundle`, `onFileProgress`, `maxConcurrency`, `maxRequestsPerFrame` + `maxRetryCount`, `version`, `responseType`, `withCredentials`, `mimeType`, `timeout`, `header`, `reload`, `cacheAsset`, `cacheEnabled`, + Please DO NOT use these words as custom options! + + !#zh + 通用加载资源接口,可传入进度回调以及完成回调,通过组合 `request` 和 `options` 参数,几乎可以实现和扩展所有想要的加载效果。非常建议你使用更简单的API,例如 `load`、`loadDir` 等。 + `options` 中的自定义参数将会分发到 `requests` 的每一项中,如果request中已存在同名的参数则以 `requests` 中为准,同时如果有其他 + 依赖资源,则 `options` 中的参数会继续向依赖项中分发。request中的自定义参数都会以 `options` 形式传入加载流程中的 `downloader`, `parser` 的方法中, 你可以 + 扩展 `downloader`, `parser` 收集参数完成想实现的效果。 + + 保留关键字: `uuid`, `url`, `path`, `dir`, `scene`, `type`, `priority`, `preset`, `audioLoadMode`, `ext`, `bundle`, `onFileProgress`, `maxConcurrency`, `maxRequestsPerFrame` + `maxRetryCount`, `version`, `responseType`, `withCredentials`, `mimeType`, `timeout`, `header`, `reload`, `cacheAsset`, `cacheEnabled`, + 请不要使用这些字段为自定义参数! + @param requests The request you want to load + @param options Optional parameters + @param onProgress Callback invoked when progression change + @param onComplete Callback invoked when finish loading + + @example + ```js + cc.assetManager.loadAny({url: 'http://example.com/a.png'}, (err, img) => cc.log(img)); + cc.assetManager.loadAny(['60sVXiTH1D/6Aft4MRt9VC'], (err, assets) => cc.log(assets)); + cc.assetManager.loadAny([{ uuid: '0cbZa5Y71CTZAccaIFluuZ'}, {url: 'http://example.com/a.png'}], (err, assets) => cc.log(assets)); + cc.assetManager.downloader.register('.asset', (url, options, onComplete) => { + url += '?userName=' + options.userName + "&password=" + options.password; + cc.assetManager.downloader.downloadFile(url, null, onComplete); + }); + cc.assetManager.parser.register('.asset', (file, options, onComplete) => { + var json = JSON.parse(file); + var skin = json[options.skin]; + var model = json[options.model]; + onComplete(null, {skin, model}); + }); + cc.assetManager.loadAny({ url: 'http://example.com/my.asset', skin: 'xxx', model: 'xxx', userName: 'xxx', password: 'xxx' }); + ``` + */ + loadAny(requests: string | string[] | Record | Record[], options: Record, onProgress: (finished: number, total: number, item: cc.AssetManager.RequestItem) => void, onComplete: (err: Error, data: any) => void): void; + loadAny(requests: string | string[] | Record | Record[], onProgress: (finished: number, total: number, item: cc.AssetManager.RequestItem) => void, onComplete: (err: Error, data: any) => void): void; + loadAny(requests: string | string[] | Record | Record[], options: Record, onComplete: (err: Error, data: any) => void): void; + loadAny(requests: string | string[] | Record | Record[], onComplete: (err: Error, data: any) => void): void; + loadAny(requests: string | string[] | Record | Record[], options: Record): void; + loadAny(requests: string | string[] | Record | Record[]): void; + /** + !#en + General interface used to preload assets with a progression callback and a complete callback.It is highly recommended that you use more simple API, such as `preloadRes`, `preloadResDir` etc. + Everything about preload is just likes `cc.assetManager.loadAny`, the difference is `cc.assetManager.preloadAny` will only download asset but not parse asset. You need to invoke `cc.assetManager.loadAny(preloadTask)` + to finish loading asset + + !#zh + 通用预加载资源接口,可传入进度回调以及完成回调,非常建议你使用更简单的 API ,例如 `preloadRes`, `preloadResDir` 等。`preloadAny` 和 `loadAny` 几乎一样,区别在于 `preloadAny` 只会下载资源,不会去解析资源,你需要调用 `cc.assetManager.loadAny(preloadTask)` + 来完成资源加载。 + @param requests The request you want to preload + @param options Optional parameters + @param onProgress Callback invoked when progression change + @param onComplete Callback invoked when finish preloading + + @example + ```js + cc.assetManager.preloadAny('0cbZa5Y71CTZAccaIFluuZ', (err) => cc.assetManager.loadAny('0cbZa5Y71CTZAccaIFluuZ')); + ``` + */ + preloadAny(requests: string | string[] | Record | Record[], options: Record, onProgress: (finished: number, total: number, item: cc.AssetManager.RequestItem) => void, onComplete: (err: Error, items: cc.AssetManager.RequestItem[]) => void): void; + preloadAny(requests: string | string[] | Record | Record[], onProgress: (finished: number, total: number, item: cc.AssetManager.RequestItem) => void, onComplete: (err: Error, items: cc.AssetManager.RequestItem[]) => void): void; + preloadAny(requests: string | string[] | Record | Record[], options: Record, onComplete: (err: Error, items: cc.AssetManager.RequestItem[]) => void): void; + preloadAny(requests: string | string[] | Record | Record[], onComplete: (err: Error, items: cc.AssetManager.RequestItem[]) => void): void; + preloadAny(requests: string | string[] | Record | Record[], options: Record): void; + preloadAny(requests: string | string[] | Record | Record[]): void; + /** + !#en + Load native file of asset, if you check the option 'Async Load Assets', you may need to load native file with this before you use the asset + + !#zh + 加载资源的原生文件,如果你勾选了'延迟加载资源'选项,你可能需要在使用资源之前调用此方法来加载原生文件 + @param asset The asset + @param options Some optional parameters + @param onComplete Callback invoked when finish loading + + @example + ```js + cc.assetManager.postLoadNative(texture, (err) => console.log(err)); + ``` + */ + postLoadNative(asset: cc.Asset, options: Record, onComplete: (err: Error) => void): void; + postLoadNative(asset: cc.Asset, onComplete: (err: Error) => void): void; + postLoadNative(asset: cc.Asset, options: Record): void; + postLoadNative(asset: cc.Asset): void; + /** + !#en + Load remote asset with url, such as audio, image, text and so on. + + !#zh + 使用 url 加载远程资源,例如音频,图片,文本等等。 + @param url The url of asset + @param options Some optional parameters + @param onComplete Callback invoked when finish loading + + @example + ```js + cc.assetManager.loadRemote('http://www.cloud.com/test1.jpg', (err, texture) => console.log(err)); + cc.assetManager.loadRemote('http://www.cloud.com/test2.mp3', (err, audioClip) => console.log(err)); + cc.assetManager.loadRemote('http://www.cloud.com/test3', { ext: '.png' }, (err, texture) => console.log(err)); + ``` + */ + loadRemote(url: string, options: Record, onComplete: (err: Error, asset: T) => void): void; + loadRemote(url: string, onComplete: (err: Error, asset: T) => void): void; + loadRemote(url: string, options: Record): void; + loadRemote(url: string): void; + /** + !#en + Load script + + !#zh + 加载脚本 + @param url Url of the script + @param options Some optional paramters + @param onComplete Callback when script loaded or failed + + @example + ```js + loadScript('http://localhost:8080/index.js', null, (err) => console.log(err)); + ``` + */ + loadScript(url: string|string[], options: Record, onComplete: (err: Error) => void): void; + loadScript(url: string|string[], onComplete: (err: Error) => void): void; + loadScript(url: string|string[], options: Record): void; + loadScript(url: string|string[]): void; + /** + !#en + load bundle + + !#zh + 加载资源包 + @param nameOrUrl The name or root path of bundle + @param options Some optional paramter, same like downloader.downloadFile + @param onComplete Callback when bundle loaded or failed + + @example + ```js + loadBundle('http://localhost:8080/test', null, (err, bundle) => console.log(err)); + ``` + */ + loadBundle(nameOrUrl: string, options: Record, onComplete: (err: Error, bundle: cc.AssetManager.Bundle) => void): void; + loadBundle(nameOrUrl: string, onComplete: (err: Error, bundle: cc.AssetManager.Bundle) => void): void; + loadBundle(nameOrUrl: string, options: Record): void; + loadBundle(nameOrUrl: string): void; + /** + !#en + Release asset and it's dependencies. + This method will not only remove the cache of the asset in assetManager, but also clean up its content. + For example, if you release a texture, the texture asset and its gl texture data will be freed up. + Notice, this method may cause the texture to be unusable, if there are still other nodes use the same texture, they may turn to black and report gl errors. + + !#zh + 释放资源以及其依赖资源, 这个方法不仅会从 assetManager 中删除资源的缓存引用,还会清理它的资源内容。 + 比如说,当你释放一个 texture 资源,这个 texture 和它的 gl 贴图数据都会被释放。 + 注意,这个函数可能会导致资源贴图或资源所依赖的贴图不可用,如果场景中存在节点仍然依赖同样的贴图,它们可能会变黑并报 GL 错误。 + @param asset The asset to be released + + @example + ```js + // release a texture which is no longer need + cc.assetManager.releaseAsset(texture); + ``` + */ + releaseAsset(asset: cc.Asset): void; + /** + !#en + Release all assets. Refer to {{#crossLink "AssetManager/releaseAsset:method"}}{{/crossLink}} for detailed informations. + + !#zh + 释放所有资源。详细信息请参考 {{#crossLink "AssetManager/releaseAsset:method"}}{{/crossLink}} + */ + releaseAll(): void; + } + /** `cc.loader` is deprecated, please backup your project and upgrade to {{#crossLink "AssetManager"}}{{/crossLink}} */ + export class loader { + /** `cc.loader.onProgress` is deprecated, please transfer onProgress to API as a parameter */ + static onProgress: any; + /** + `cc.loader.load` is deprecated, please use {{#crossLink "AssetManager/loadAny:method"}}{{/crossLink}} instead + @param resources Url list in an array + @param progressCallback Callback invoked when progression change + @param completeCallback Callback invoked when all resources loaded + */ + static load(resources: string|string[]|{uuid?: string, url?: string, type?: string}, completeCallback?: Function): void; + static load(resources: string|string[]|{uuid?: string, url?: string, type?: string}, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: Function|null): void; + /** + `cc.loader.getXMLHttpRequest` is deprecated, please use `XMLHttpRequest` directly + */ + static getXMLHttpRequest(): XMLHttpRequest; + /** + `cc.loader.getItem` is deprecated, please use `cc.assetManager.asset.get` instead + @param id The id of the item + */ + static getItem(id: any): any; + /** + `cc.loader.loadRes` is deprecated, please use {{#crossLink "Bundle/load:method"}}{{/crossLink}} instead + @param url Url of the target resource. + The url is relative to the "resources" folder, extensions must be omitted. + @param type Only asset of type will be loaded if this argument is supplied. + @param progressCallback Callback invoked when progression change. + @param completeCallback Callback invoked when the resource loaded. + */ + static loadRes(url: string, type: typeof cc.Asset, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any) => void)|null): void; + static loadRes(url: string, type: typeof cc.Asset, completeCallback: (error: Error, resource: any) => void): void; + static loadRes(url: string, type: typeof cc.Asset): void; + static loadRes(url: string, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any) => void)|null): void; + static loadRes(url: string, completeCallback: (error: Error, resource: any) => void): void; + static loadRes(url: string): void; + /** + `cc.loader.loadResArray` is deprecated, please use {{#crossLink "Bundle/load:method"}}{{/crossLink}} instead + @param urls Array of URLs of the target resource. + The url is relative to the "resources" folder, extensions must be omitted. + @param type Only asset of type will be loaded if this argument is supplied. + @param progressCallback Callback invoked when progression change. + @param completeCallback A callback which is called when all assets have been loaded, or an error occurs. + */ + static loadResArray(url: string[], type: typeof cc.Asset, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any[]) => void)|null): void; + static loadResArray(url: string[], type: typeof cc.Asset, completeCallback: (error: Error, resource: any[]) => void): void; + static loadResArray(url: string[], type: typeof cc.Asset): void; + static loadResArray(url: string[], progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any[]) => void)|null): void; + static loadResArray(url: string[], completeCallback: (error: Error, resource: any[]) => void): void; + static loadResArray(url: string[]): void; + static loadResArray(url: string[], type: typeof cc.Asset[]): void; + /** + `cc.loader.loadResDir` is deprecated, please use {{#crossLink "Bundle/loadDir:method"}}{{/crossLink}} instead + @param url Url of the target folder. + The url is relative to the "resources" folder, extensions must be omitted. + @param type Only asset of type will be loaded if this argument is supplied. + @param progressCallback Callback invoked when progression change. + @param completeCallback A callback which is called when all assets have been loaded, or an error occurs. + */ + static loadResDir(url: string, type: typeof cc.Asset, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any[], urls: string[]) => void)|null): void; + static loadResDir(url: string, type: typeof cc.Asset, completeCallback: (error: Error, resource: any[], urls: string[]) => void): void; + static loadResDir(url: string, type: typeof cc.Asset): void; + static loadResDir(url: string, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any[], urls: string[]) => void)|null): void; + static loadResDir(url: string, completeCallback: (error: Error, resource: any[], urls: string[]) => void): void; + static loadResDir(url: string): void; + /** + `cc.loader.getRes` is deprecated, please use {{#crossLink "Bundle/get:method"}}{{/crossLink}} instead + @param url url + @param type Only asset of type will be returned if this argument is supplied. + */ + static getRes(url: string, type?: Function): any; + /** + `cc.loader.getDependsRecursively` is deprecated, please use use {{#crossLink "DependUtil/getDepsRecursively:method"}}{{/crossLink}} instead + @param owner The owner asset or the resource url or the asset's uuid + */ + static getDependsRecursively(owner: Asset|string): any[]; + /** `cc.loader.assetLoader` was removed, assetLoader and md5Pipe were merged into {{#crossLink "AssetManager/transformPipeline:property"}}{{/crossLink}} */ + static assetLoader: any; + /** `cc.loader.md5Pipe` is deprecated, assetLoader and md5Pipe were merged into {{#crossLink "AssetManager/transformPipeline:property"}}{{/crossLink}} */ + static md5Pipe: any; + /** `cc.loader.downloader` is deprecated, please use {{#crossLink "AssetManager/downloader:property"}}{{/crossLink}} instead */ + static downloader: any; + /** `cc.loader.loader` is deprecated, please use {{#crossLink "AssetManager/parser:property"}}{{/crossLink}} instead */ + static loader: any; + /** + `cc.loader.addDownloadHandlers` is deprecated, please use `cc.assetManager.downloader.register` instead + @param extMap Custom supported types with corresponded handler + */ + static addDownloadHandlers(extMap: any): void; + /** + `cc.loader.addLoadHandlers` is deprecated, please use `cc.assetManager.parser.register` instead + @param extMap Custom supported types with corresponded handler + */ + static addLoadHandlers(extMap: any): void; + /** + `cc.loader.release` is deprecated, please use {{#crossLink "AssetManager/releaseAsset:method"}}{{/crossLink}} instead + @param asset asset + */ + static release(asset: Asset|string|any[]): void; + /** + `cc.loader.releaseAsset` is deprecated, please use {{#crossLink "AssetManager/releaseAsset:method"}}{{/crossLink}} instead + @param asset asset + */ + static releaseAsset(asset: Asset): void; + /** + `cc.loader.releaseRes` is deprecated, please use {{#crossLink "AssetManager/releaseRes:method"}}{{/crossLink}} instead + @param url url + @param type Only asset of type will be released if this argument is supplied. + */ + static releaseRes(url: string, type?: Function): void; + /** + `cc.loader.releaseResDir` was removed, please use {{#crossLink "AssetManager/releaseRes:method"}}{{/crossLink}} instead + */ + static releaseResDir(): void; + /** + `cc.loader.releaseAll` is deprecated, please use {{#crossLink "AssetManager/releaseAll:method"}}{{/crossLink}} instead + */ + static releaseAll(): void; + /** + `cc.loader.removeItem` is deprecated, please use `cc.assetManager.assets.remove` instead + @param id The id of the item + */ + static removeItem(id: any): boolean; + /** + `cc.loader.setAutoRelease` is deprecated, if you want to prevent some asset from auto releasing, please use {{#crossLink "Asset/addRef:method"}}{{/crossLink}} instead + @param assetOrUrlOrUuid asset object or the raw asset's url or uuid + @param autoRelease indicates whether should release automatically + */ + static setAutoRelease(assetOrUrlOrUuid: Asset|string, autoRelease: boolean): void; + /** + `cc.loader.setAutoReleaseRecursively` is deprecated, if you want to prevent some asset from auto releasing, please use {{#crossLink "Asset/addRef:method"}}{{/crossLink}} instead + @param assetOrUrlOrUuid asset object or the raw asset's url or uuid + @param autoRelease indicates whether should release automatically + */ + static setAutoReleaseRecursively(assetOrUrlOrUuid: Asset|string, autoRelease: boolean): void; + /** + `cc.loader.isAutoRelease` is deprecated + @param assetOrUrl asset object or the raw asset's url + */ + static isAutoRelease(assetOrUrl: Asset|string): boolean; + } + /** `cc.url` is deprecated */ + export class url { + /** + `cc.url.raw` is deprecated, please use `cc.resources.load` directly, or use `Asset.nativeUrl` instead. + @param url url + */ + static raw(url: string): string; + } + /** `cc.LoadingItems` was removed, please use {{#crossLink "Task"}}{{/crossLink}} instead */ + export class LoadingItems { + } + /** !#en + Base class for handling assets used in Creator.
+ + You may want to override:
+ - createNode
+ - getset functions of _nativeAsset
+ - cc.Object._serialize
+ - cc.Object._deserialize
+ !#zh + Creator 中的资源基类。
+ + 您可能需要重写:
+ - createNode
+ - _nativeAsset 的 getset 方法
+ - cc.Object._serialize
+ - cc.Object._deserialize
*/ + export class Asset extends Object { + /** `cc.Asset.url` is deprecated, please use {{#crossLink "Asset/nativeUrl:property"}}{{/crossLink}} instead */ + url: string; + /** !#en + Whether the asset is loaded or not. + !#zh + 该资源是否已经成功加载。 */ + loaded: boolean; + /** !#en + Returns the url of this asset's native object, if none it will returns an empty string. + !#zh + 返回该资源对应的目标平台资源的 URL,如果没有将返回一个空字符串。 */ + nativeUrl: string; + /** !#en + The number of reference + + !#zh + 引用的数量 */ + refCount: number; + /** !#en Indicates whether its dependent raw assets can support deferred load if the owner scene (or prefab) is marked as `asyncLoadAssets`. + !#zh 当场景或 Prefab 被标记为 `asyncLoadAssets`,禁止延迟加载该资源所依赖的其它原始资源。 */ + static preventDeferredLoadDependents: boolean; + /** !#en Indicates whether its native object should be preloaded from native url. + !#zh 禁止预加载原生对象。 */ + static preventPreloadNativeObject: boolean; + /** + !#en + Returns the asset's url. + + The `Asset` object overrides the `toString()` method of the `Object` object. + For `Asset` objects, the `toString()` method returns a string representation of the object. + JavaScript calls the `toString()` method automatically when an asset is to be represented as a text value or when a texture is referred to in a string concatenation. + !#zh + 返回资源的 URL。 + + Asset 对象将会重写 Object 对象的 `toString()` 方法。 + 对于 Asset 对象,`toString()` 方法返回该对象的字符串表示形式。 + 当资源要表示为文本值时或在字符串连接时引用时,JavaScript 会自动调用 `toString()` 方法。 + */ + toString(): string; + /** + !#en + Create a new node using this asset in the scene.
+ If this type of asset dont have its corresponding node type, this method should be null. + !#zh + 使用该资源在场景中创建一个新节点。
+ 如果这类资源没有相应的节点类型,该方法应该是空的。 + @param callback callback + */ + createNode(callback: (error: string, node: any) => void): void; + /** + !#en + Add references of asset + + !#zh + 增加资源的引用 + */ + addRef(): cc.Asset; + /** + !#en + Reduce references of asset and it will be auto released when refCount equals 0. + + !#zh + 减少资源的引用并尝试进行自动释放。 + */ + decRef(): cc.Asset; + } + /** Predefined constants */ + export class macro { + /** `cc.macro.DOWNLOAD_MAX_CONCURRENT` is deprecated now, please use {{#crossLink "Downloader/maxConcurrency:property"}}{{/crossLink}} instead */ + static DOWNLOAD_MAX_CONCURRENT: number; + /** PI / 180 */ + static RAD: number; + /** One degree */ + static DEG: number; + static REPEAT_FOREVER: number; + static FLT_EPSILON: number; + /** Minimum z index value for node */ + static MIN_ZINDEX: number; + /** Maximum z index value for node */ + static MAX_ZINDEX: number; + static ONE: number; + static ZERO: number; + static SRC_ALPHA: number; + static SRC_ALPHA_SATURATE: number; + static SRC_COLOR: number; + static DST_ALPHA: number; + static DST_COLOR: number; + static ONE_MINUS_SRC_ALPHA: number; + static ONE_MINUS_SRC_COLOR: number; + static ONE_MINUS_DST_ALPHA: number; + static ONE_MINUS_DST_COLOR: number; + static ONE_MINUS_CONSTANT_ALPHA: number; + static ONE_MINUS_CONSTANT_COLOR: number; + /** Oriented vertically */ + static ORIENTATION_PORTRAIT: number; + /** Oriented horizontally */ + static ORIENTATION_LANDSCAPE: number; + /** Oriented automatically */ + static ORIENTATION_AUTO: number; + /**

+ If enabled, the texture coordinates will be calculated by using this formula:
+ - texCoord.left = (rect.x*2+1) / (texture.wide*2);
+ - texCoord.right = texCoord.left + (rect.width*2-2)/(texture.wide*2);
+
+ The same for bottom and top.
+
+ This formula prevents artifacts by using 99% of the texture.
+ The "correct" way to prevent artifacts is by expand the texture's border with the same color by 1 pixel
+
+ Affected component:
+ - cc.TMXLayer
+
+ Enabled by default. To disabled set it to 0.
+ To modify it, in Web engine please refer to CCMacro.js, in JSB please refer to CCConfig.h +

*/ + static FIX_ARTIFACTS_BY_STRECHING_TEXEL_TMX: number; + /** Position of the FPS (Default: 0,0 (bottom-left corner))
+ To modify it, in Web engine please refer to CCMacro.js, in JSB please refer to CCConfig.h */ + static DIRECTOR_STATS_POSITION: Vec2; + /**

+ If enabled, actions that alter the position property (eg: CCMoveBy, CCJumpBy, CCBezierBy, etc..) will be stacked.
+ If you run 2 or more 'position' actions at the same time on a node, then end position will be the sum of all the positions.
+ If disabled, only the last run action will take effect. +

*/ + static ENABLE_STACKABLE_ACTIONS: number; + /** !#en + The timeout to determine whether a touch is no longer active and should be removed. + The reason to add this timeout is due to an issue in X5 browser core, + when X5 is presented in wechat on Android, if a touch is glissed from the bottom up, and leave the page area, + no touch cancel event is triggered, and the touch will be considered active forever. + After multiple times of this action, our maximum touches number will be reached and all new touches will be ignored. + So this new mechanism can remove the touch that should be inactive if it's not updated during the last 5000 milliseconds. + Though it might remove a real touch if it's just not moving for the last 5 seconds which is not easy with the sensibility of mobile touch screen. + You can modify this value to have a better behavior if you find it's not enough. + !#zh + 用于甄别一个触点对象是否已经失效并且可以被移除的延时时长 + 添加这个时长的原因是 X5 内核在微信浏览器中出现的一个 bug。 + 在这个环境下,如果用户将一个触点从底向上移出页面区域,将不会触发任何 touch cancel 或 touch end 事件,而这个触点会被永远当作停留在页面上的有效触点。 + 重复这样操作几次之后,屏幕上的触点数量将达到我们的事件系统所支持的最高触点数量,之后所有的触摸事件都将被忽略。 + 所以这个新的机制可以在触点在一定时间内没有任何更新的情况下视为失效触点并从事件系统中移除。 + 当然,这也可能移除一个真实的触点,如果用户的触点真的在一定时间段内完全没有移动(这在当前手机屏幕的灵敏度下会很难)。 + 你可以修改这个值来获得你需要的效果,默认值是 5000 毫秒。 */ + static TOUCH_TIMEOUT: number; + /** !#en + The maximum vertex count for a single batched draw call. + !#zh + 最大可以被单次批处理渲染的顶点数量。 */ + static BATCH_VERTEX_COUNT: number; + /** !#en + Whether or not enabled tiled map auto culling. If you set the TiledMap skew or rotation, then need to manually disable this, otherwise, the rendering will be wrong. + !#zh + 是否开启瓦片地图的自动裁减功能。瓦片地图如果设置了 skew, rotation 或者采用了摄像机的话,需要手动关闭,否则渲染会出错。 */ + static ENABLE_TILEDMAP_CULLING: boolean; + /** !#en + Boolean that indicates if the canvas contains an alpha channel, default sets to false for better performance. + Though if you want to make your canvas background transparent and show other dom elements at the background, + you can set it to true before `cc.game.run`. + Web only. + !#zh + 用于设置 Canvas 背景是否支持 alpha 通道,默认为 false,这样可以有更高的性能表现。 + 如果你希望 Canvas 背景是透明的,并显示背后的其他 DOM 元素,你可以在 `cc.game.run` 之前将这个值设为 true。 + 仅支持 Web */ + static ENABLE_TRANSPARENT_CANVAS: boolean; + /** !#en + Boolean that indicates if the WebGL context is created with `antialias` option turned on, default value is false. + Set it to true could make your game graphics slightly smoother, like texture hard edges when rotated. + Whether to use this really depend on your game design and targeted platform, + device with retina display usually have good detail on graphics with or without this option, + you probably don't want antialias if your game style is pixel art based. + Also, it could have great performance impact with some browser / device using software MSAA. + You can set it to true before `cc.game.run`. + Web only. + !#zh + 用于设置在创建 WebGL Context 时是否开启抗锯齿选项,默认值是 false。 + 将这个选项设置为 true 会让你的游戏画面稍稍平滑一些,比如旋转硬边贴图时的锯齿。是否开启这个选项很大程度上取决于你的游戏和面向的平台。 + 在大多数拥有 retina 级别屏幕的设备上用户往往无法区分这个选项带来的变化;如果你的游戏选择像素艺术风格,你也多半不会想开启这个选项。 + 同时,在少部分使用软件级别抗锯齿算法的设备或浏览器上,这个选项会对性能产生比较大的影响。 + 你可以在 `cc.game.run` 之前设置这个值,否则它不会生效。 + 仅支持 Web */ + static ENABLE_WEBGL_ANTIALIAS: boolean; + /** !#en + Whether or not enable auto culling. + This feature have been removed in v2.0 new renderer due to overall performance consumption. + We have no plan currently to re-enable auto culling. + If your game have more dynamic objects, we suggest to disable auto culling. + If your game have more static objects, we suggest to enable auto culling. + !#zh + 是否开启自动裁减功能,开启裁减功能将会把在屏幕外的物体从渲染队列中去除掉。 + 这个功能在 v2.0 的新渲染器中被移除了,因为它在大多数游戏中所带来的损耗要高于性能的提升,目前我们没有计划重新支持自动裁剪。 + 如果游戏中的动态物体比较多的话,建议将此选项关闭。 + 如果游戏中的静态物体比较多的话,建议将此选项打开。 */ + static ENABLE_CULLING: boolean; + /** !#en + Whether to clear the original image cache after uploaded a texture to GPU. If cleared, [Dynamic Atlas](https://docs.cocos.com/creator/manual/en/advanced-topics/dynamic-atlas.html) will not be supported. + Normally you don't need to enable this option on the web platform, because Image object doesn't consume too much memory. + But on WeChat Game platform, the current version cache decoded data in Image object, which has high memory usage. + So we enabled this option by default on WeChat, so that we can release Image cache immediately after uploaded to GPU. + !#zh + 是否在将贴图上传至 GPU 之后删除原始图片缓存,删除之后图片将无法进行 [动态合图](https://docs.cocos.com/creator/manual/zh/advanced-topics/dynamic-atlas.html)。 + 在 Web 平台,你通常不需要开启这个选项,因为在 Web 平台 Image 对象所占用的内存很小。 + 但是在微信小游戏平台的当前版本,Image 对象会缓存解码后的图片数据,它所占用的内存空间很大。 + 所以我们在微信平台默认开启了这个选项,这样我们就可以在上传 GL 贴图之后立即释放 Image 对象的内存,避免过高的内存占用。 */ + static CLEANUP_IMAGE_CACHE: boolean; + /** !#en + Whether or not show mesh wire frame. + !#zh + 是否显示网格的线框。 */ + static SHOW_MESH_WIREFRAME: boolean; + /** !#en + Whether or not show mesh normal. + !#zh + 是否显示网格的法线。 */ + static SHOW_MESH_NORMAL: boolean; + /** !#en + Whether to enable multi-touch. + !#zh + 是否开启多点触摸 */ + static ENABLE_MULTI_TOUCH: boolean; + /** References: + https://developer.mozilla.org/en-US/docs/Web/API/ImageBitmap + https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/createImageBitmap + + !#en + Whether to use image bitmap first. If enabled, memory usage will increase. + + !#zh + 是否优先使用 image bitmap,启用之后,内存占用会变高 */ + static ALLOW_IMAGE_BITMAP: boolean; + /** !#en + Whether to use native TTF renderer which is faster but layout slightly different. + + !#zh + 是否使用原生的文本渲染机制, 布局和编辑器有差异. */ + static ENABLE_NATIVE_TTF_RENDERER: boolean; + /** !#en + The image format supported by the engine defaults, and the supported formats may differ in different build platforms and device types. + Currently all platform and device support ['.webp', '.jpg', '.jpeg', '.bmp', '.png'], The iOS mobile platform also supports the PVR format。 + !#zh + 引擎默认支持的图片格式,支持的格式可能在不同的构建平台和设备类型上有所差别。 + 目前所有平台和设备支持的格式有 ['.webp', '.jpg', '.jpeg', '.bmp', '.png']. 另外 Ios 手机平台还额外支持了 PVR 格式。 */ + static SUPPORT_TEXTURE_FORMATS: string[]; + } + /** !#en Class for audio data handling. + !#zh 音频资源类。 */ + export class AudioClip extends Asset implements EventTarget { + /** !#en Get the audio clip duration + !#zh 获取音频剪辑的长度 */ + duration: number; + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en + Register an callback of a specific event type on the EventTarget. + This type of event should be triggered via `emit`. + !#zh + 注册事件目标的特定事件类型回调。这种类型的事件应该被 `emit` 触发。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, node); + ``` + */ + on(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. + !#zh + 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + + @example + ```js + // register fire eventListener + var callback = eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, target); + // remove fire event listener + eventTarget.off('fire', callback, target); + // remove all fire event listeners + eventTarget.off('fire'); + ``` + */ + off(type: string, callback?: Function, target?: any): void; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.once('fire', function () { + cc.log("this is the callback and will be invoked only once"); + }, node); + ``` + */ + once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; + /** + !#en + Send an event with the event object. + !#zh + 通过事件对象派发事件 + @param event event + */ + dispatchEvent(event: Event): void; + /** + !#en + Destroy all callbackInfos. + !#zh + 销毁记录的事件 + */ + clear(): void; + } + /** !#en Class for BitmapFont handling. + !#zh 位图字体资源类。 */ + export class BitmapFont extends Font { + } + /** undefined */ + export class BufferAsset extends Asset { + } + /** !#en Class for Font handling. + !#zh 字体资源类。 */ + export class Font extends Asset { + } + /** !#en + Class for JSON file. When the JSON file is loaded, this object is returned. + The parsed JSON object can be accessed through the `json` attribute in it.
+ If you want to get the original JSON text, you should modify the extname to `.txt` + so that it is loaded as a `TextAsset` instead of a `JsonAsset`. + + !#zh + JSON 资源类。JSON 文件加载后,将会返回该对象。可以通过其中的 `json` 属性访问解析后的 JSON 对象。
+ 如果你想要获得 JSON 的原始文本,那么应该修改源文件的后缀为 `.txt`,这样就会加载为一个 `TextAsset` 而不是 `JsonAsset`。 */ + export class JsonAsset extends Asset { + /** The loaded JSON object. */ + json: any; + } + /** !#en Class for LabelAtlas handling. + !#zh 艺术数字字体资源类。 */ + export class LabelAtlas extends BitmapFont { + } + /** !#en Class for prefab handling. + !#zh 预制资源类。 */ + export class Prefab extends Asset { + /** the main cc.Node in the prefab */ + data: Node; + /** !#zh + 设置实例化这个 prefab 时所用的优化策略。根据使用情况设置为合适的值,能优化该 prefab 实例化所用的时间。 + !#en + Indicates the optimization policy for instantiating this prefab. + Set to a suitable value based on usage, can optimize the time it takes to instantiate this prefab. */ + optimizationPolicy: Prefab.OptimizationPolicy; + /** !#en Indicates the raw assets of this prefab can be load after prefab loaded. + !#zh 指示该 Prefab 依赖的资源可否在 Prefab 加载后再延迟加载。 */ + asyncLoadAssets: boolean; + readonly: boolean; + /** + Dynamically translation prefab data into minimized code.
+ This method will be called automatically before the first time the prefab being instantiated, + but you can re-call to refresh the create function once you modified the original prefab data in script. + */ + compileCreateFunction(): void; + } + /** Render textures are textures that can be rendered to. */ + export class RenderTexture extends Texture2D { + /** + !#en + Init the render texture with size. + !#zh + 初始化 render texture + @param width width + @param height height + @param depthStencilFormat depthStencilFormat + */ + initWithSize(width?: number, height?: number, depthStencilFormat?: number): void; + /** + !#en + Get pixels from render texture, the pixels data stores in a RGBA Uint8Array. + It will return a new (width * height * 4) length Uint8Array by default。 + You can specify a data to store the pixels to reuse the data, + you and can specify other params to specify the texture region to read. + !#zh + 从 render texture 读取像素数据,数据类型为 RGBA 格式的 Uint8Array 数组。 + 默认每次调用此函数会生成一个大小为 (长 x 高 x 4) 的 Uint8Array。 + 你可以通过传入 data 来接收像素数据,也可以通过传参来指定需要读取的区域的像素。 + @param data data + @param x x + @param y y + @param w w + @param h h + */ + readPixels(data?: Uint8Array, x?: number, y?: number, w?: number, h?: number): Uint8Array; + } + /** !#en Class for scene handling. + !#zh 场景资源类。 */ + export class SceneAsset extends Asset { + scene: Scene; + /** !#en Indicates the raw assets of this scene can be load after scene launched. + !#zh 指示该场景依赖的资源可否在场景切换后再延迟加载。 */ + asyncLoadAssets: boolean; + } + /** !#en Class for script handling. + !#zh Script 资源类。 */ + export class _Script extends Asset { + } + /** !#en Class for JavaScript handling. + !#zh JavaScript 资源类。 */ + export class _JavaScript extends Asset { + } + /** !#en Class for TypeScript handling. + !#zh TypeScript 资源类。 */ + export class TypeScript extends Asset { + } + /** !#en Class for sprite atlas handling. + !#zh 精灵图集资源类。 */ + export class SpriteAtlas extends Asset { + /** + Returns the texture of the sprite atlas + */ + getTexture(): Texture2D; + /** + Returns the sprite frame correspond to the given key in sprite atlas. + @param key key + */ + getSpriteFrame(key: string): SpriteFrame; + /** + Returns the sprite frames in sprite atlas. + */ + getSpriteFrames(): SpriteFrame[]; + } + /** !#en + A cc.SpriteFrame has:
+ - texture: A cc.Texture2D that will be used by render components
+ - rectangle: A rectangle of the texture + + !#zh + 一个 SpriteFrame 包含:
+ - 纹理:会被渲染组件使用的 Texture2D 对象。
+ - 矩形:在纹理中的矩形区域。 */ + export class SpriteFrame extends Asset implements EventTarget { + /** !#en Top border of the sprite + !#zh sprite 的顶部边框 */ + insetTop: number; + /** !#en Bottom border of the sprite + !#zh sprite 的底部边框 */ + insetBottom: number; + /** !#en Left border of the sprite + !#zh sprite 的左边边框 */ + insetLeft: number; + /** !#en Right border of the sprite + !#zh sprite 的左边边框 */ + insetRight: number; + /** + !#en + Constructor of SpriteFrame class. + !#zh + SpriteFrame 类的构造函数。 + @param filename filename + @param rect rect + @param rotated Whether the frame is rotated in the texture + @param offset The offset of the frame in the texture + @param originalSize The size of the frame in the texture + */ + constructor(filename?: string|Texture2D, rect?: Rect, rotated?: boolean, offset?: Vec2, originalSize?: Size); + /** + !#en Returns whether the texture have been loaded + !#zh 返回是否已加载纹理 + */ + textureLoaded(): boolean; + /** + !#en Returns whether the sprite frame is rotated in the texture. + !#zh 获取 SpriteFrame 是否旋转 + */ + isRotated(): boolean; + /** + !#en Set whether the sprite frame is rotated in the texture. + !#zh 设置 SpriteFrame 是否旋转 + @param bRotated bRotated + */ + setRotated(bRotated: boolean): void; + /** + !#en Returns whether the sprite frame is flip x axis in the texture. + !#zh 获取 SpriteFrame 是否反转 x 轴 + */ + isFlipX(): boolean; + /** + !#en Returns whether the sprite frame is flip y axis in the texture. + !#zh 获取 SpriteFrame 是否反转 y 轴 + */ + isFlipY(): boolean; + /** + !#en Set whether the sprite frame is flip x axis in the texture. + !#zh 设置 SpriteFrame 是否翻转 x 轴 + @param flipX flipX + */ + setFlipX(flipX: boolean): void; + /** + !#en Set whether the sprite frame is flip y axis in the texture. + !#zh 设置 SpriteFrame 是否翻转 y 轴 + @param flipY flipY + */ + setFlipY(flipY: boolean): void; + /** + !#en Returns the rect of the sprite frame in the texture. + !#zh 获取 SpriteFrame 的纹理矩形区域 + */ + getRect(): Rect; + /** + !#en Sets the rect of the sprite frame in the texture. + !#zh 设置 SpriteFrame 的纹理矩形区域 + @param rect rect + */ + setRect(rect: Rect): void; + /** + !#en Returns the original size of the trimmed image. + !#zh 获取修剪前的原始大小 + */ + getOriginalSize(): Size; + /** + !#en Sets the original size of the trimmed image. + !#zh 设置修剪前的原始大小 + @param size size + */ + setOriginalSize(size: Size): void; + /** + !#en Returns the texture of the frame. + !#zh 获取使用的纹理实例 + */ + getTexture(): Texture2D; + /** + !#en Returns the offset of the frame in the texture. + !#zh 获取偏移量 + */ + getOffset(): Vec2; + /** + !#en Sets the offset of the frame in the texture. + !#zh 设置偏移量 + @param offsets offsets + */ + setOffset(offsets: Vec2): void; + /** + !#en Clone the sprite frame. + !#zh 克隆 SpriteFrame + */ + clone(): SpriteFrame; + /** + !#en Set SpriteFrame with Texture, rect, rotated, offset and originalSize.
+ !#zh 通过 Texture,rect,rotated,offset 和 originalSize 设置 SpriteFrame。 + @param texture texture + @param rect rect + @param rotated rotated + @param offset offset + @param originalSize originalSize + */ + setTexture(texture: Texture2D, rect?: Rect, rotated?: boolean, offset?: Vec2, originalSize?: Size): boolean; + /** + !#en If a loading scene (or prefab) is marked as `asyncLoadAssets`, all the textures of the SpriteFrame which + associated by user's custom Components in the scene, will not preload automatically. + These textures will be load when Sprite component is going to render the SpriteFrames. + You can call this method if you want to load the texture early. + !#zh 当加载中的场景或 Prefab 被标记为 `asyncLoadAssets` 时,用户在场景中由自定义组件关联到的所有 SpriteFrame 的贴图都不会被提前加载。 + 只有当 Sprite 组件要渲染这些 SpriteFrame 时,才会检查贴图是否加载。如果你希望加载过程提前,你可以手工调用这个方法。 + + @example + ```js + if (spriteFrame.textureLoaded()) { + this._onSpriteFrameLoaded(); + } + else { + spriteFrame.once('load', this._onSpriteFrameLoaded, this); + spriteFrame.ensureLoadTexture(); + } + ``` + */ + ensureLoadTexture(): void; + /** + !#en + If you do not need to use the SpriteFrame temporarily, you can call this method so that its texture could be garbage collected. Then when you need to render the SpriteFrame, you should call `ensureLoadTexture` manually to reload texture. + !#zh + 当你暂时不再使用这个 SpriteFrame 时,可以调用这个方法来保证引用的贴图对象能被 GC。然后当你要渲染 SpriteFrame 时,你需要手动调用 `ensureLoadTexture` 来重新加载贴图。 + */ + clearTexture(): void; + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en + Register an callback of a specific event type on the EventTarget. + This type of event should be triggered via `emit`. + !#zh + 注册事件目标的特定事件类型回调。这种类型的事件应该被 `emit` 触发。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, node); + ``` + */ + on(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. + !#zh + 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + + @example + ```js + // register fire eventListener + var callback = eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, target); + // remove fire event listener + eventTarget.off('fire', callback, target); + // remove all fire event listeners + eventTarget.off('fire'); + ``` + */ + off(type: string, callback?: Function, target?: any): void; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.once('fire', function () { + cc.log("this is the callback and will be invoked only once"); + }, node); + ``` + */ + once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; + /** + !#en + Send an event with the event object. + !#zh + 通过事件对象派发事件 + @param event event + */ + dispatchEvent(event: Event): void; + /** + !#en + Destroy all callbackInfos. + !#zh + 销毁记录的事件 + */ + clear(): void; + } + /** !#en Class for TTFFont handling. + !#zh TTF 字体资源类。 */ + export class TTFFont extends Font { + } + /** !#en Class for text file. + !#zh 文本资源类。 */ + export class TextAsset extends Asset { + /** The text contents of the resource. */ + text: string; + } + /** This class allows to easily create OpenGL or Canvas 2D textures from images or raw data. */ + export class Texture2D extends Asset implements EventTarget { + /** !#en Sets whether generate mipmaps for the texture + !#zh 是否为纹理设置生成 mipmaps。 */ + genMipmaps: boolean; + /** !#en + Sets whether texture can be packed into texture atlas. + If need use texture uv in custom Effect, please sets packable to false. + !#zh + 设置纹理是否允许参与合图。 + 如果需要在自定义 Effect 中使用纹理 UV,需要禁止该选项。 */ + packable: boolean; + /** !#en + Whether the texture is loaded or not + !#zh + 贴图是否已经成功加载 */ + loaded: boolean; + /** !#en + Texture width in pixel + !#zh + 贴图像素宽度 */ + width: number; + /** !#en + Texture height in pixel + !#zh + 贴图像素高度 */ + height: number; + /** + !#en + Get renderer texture implementation object + extended from render.Texture2D + !#zh 返回渲染器内部贴图对象 + */ + getImpl(): void; + /** + Update texture options, not available in Canvas render mode. + image, format, premultiplyAlpha can not be updated in native. + @param options options + */ + update(options: {image: DOMImageElement; genMipmaps: boolean; format: Texture2D.PixelFormat; minFilter: Texture2D.Filter; magFilter: Texture2D.Filter; wrapS: WrapMode; wrapT: WrapMode; premultiplyAlpha: boolean; }): void; + /** + !#en + Init with HTML element. + !#zh 用 HTML Image 或 Canvas 对象初始化贴图。 + @param element element + + @example + ```js + var img = new Image(); + img.src = dataURL; + texture.initWithElement(img); + ``` + */ + initWithElement(element: HTMLImageElement|HTMLCanvasElement): void; + /** + !#en + Intializes with texture data in ArrayBufferView. + !#zh 使用一个存储在 ArrayBufferView 中的图像数据(raw data)初始化数据。 + @param data data + @param pixelFormat pixelFormat + @param pixelsWidth pixelsWidth + @param pixelsHeight pixelsHeight + */ + initWithData(data: ArrayBufferView, pixelFormat: number, pixelsWidth: number, pixelsHeight: number): boolean; + /** + !#en + HTMLElement Object getter, available only on web.
+ Note: texture is packed into texture atlas by default
+ you should set texture.packable as false before getting Html element object. + !#zh 获取当前贴图对应的 HTML Image 或 Canvas 对象,只在 Web 平台下有效。
+ 注意:
+ texture 默认参与动态合图,如果需要获取到正确的 Html 元素对象,需要先设置 texture.packable 为 false + */ + getHtmlElementObj(): HTMLImageElement; + /** + !#en + Destory this texture and immediately release its video memory. (Inherit from cc.Object.destroy)
+ After destroy, this object is not usable anymore. + You can use cc.isValid(obj) to check whether the object is destroyed before accessing it. + !#zh + 销毁该贴图,并立即释放它对应的显存。(继承自 cc.Object.destroy)
+ 销毁后,该对象不再可用。您可以在访问对象之前使用 cc.isValid(obj) 来检查对象是否已被销毁。 + */ + destroy(): boolean; + /** + !#en + Pixel format of the texture. + !#zh 获取纹理的像素格式。 + */ + getPixelFormat(): number; + /** + !#en + Whether or not the texture has their Alpha premultiplied. + !#zh 检查纹理在上传 GPU 时预乘选项是否开启。 + */ + hasPremultipliedAlpha(): boolean; + /** + !#en + Handler of texture loaded event. + Since v2.0, you don't need to invoke this function, it will be invoked automatically after texture loaded. + !#zh 贴图加载事件处理器。v2.0 之后你将不在需要手动执行这个函数,它会在贴图加载成功之后自动执行。 + @param premultiplied premultiplied + */ + handleLoadedTexture(premultiplied?: boolean): void; + /** + !#en + Description of cc.Texture2D. + !#zh cc.Texture2D 描述。 + */ + description(): string; + /** + !#en + Release texture, please use destroy instead. + !#zh 释放纹理,请使用 destroy 替代。 + */ + releaseTexture(): void; + /** + !#en Sets the wrap s and wrap t options.
+ If the texture size is NPOT (non power of 2), then in can only use gl.CLAMP_TO_EDGE in gl.TEXTURE_WRAP_{S,T}. + !#zh 设置纹理包装模式。 + 若纹理贴图尺寸是 NPOT(non power of 2),则只能使用 Texture2D.WrapMode.CLAMP_TO_EDGE。 + @param wrapS wrapS + @param wrapT wrapT + */ + setWrapMode(wrapS: Texture2D.WrapMode, wrapT: Texture2D.WrapMode): void; + /** + !#en Sets the minFilter and magFilter options + !#zh 设置纹理贴图缩小和放大过滤器算法选项。 + @param minFilter minFilter + @param magFilter magFilter + */ + setFilters(minFilter: Texture2D.Filter, magFilter: Texture2D.Filter): void; + /** + !#en + Sets the flipY options + !#zh 设置贴图的纵向翻转选项。 + @param flipY flipY + */ + setFlipY(flipY: boolean): void; + /** + !#en + Sets the premultiply alpha options + !#zh 设置贴图的预乘选项。 + @param premultiply premultiply + */ + setPremultiplyAlpha(premultiply: boolean): void; + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en + Register an callback of a specific event type on the EventTarget. + This type of event should be triggered via `emit`. + !#zh + 注册事件目标的特定事件类型回调。这种类型的事件应该被 `emit` 触发。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, node); + ``` + */ + on(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. + !#zh + 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + + @example + ```js + // register fire eventListener + var callback = eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, target); + // remove fire event listener + eventTarget.off('fire', callback, target); + // remove all fire event listeners + eventTarget.off('fire'); + ``` + */ + off(type: string, callback?: Function, target?: any): void; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.once('fire', function () { + cc.log("this is the callback and will be invoked only once"); + }, node); + ``` + */ + once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; + /** + !#en + Send an event with the event object. + !#zh + 通过事件对象派发事件 + @param event event + */ + dispatchEvent(event: Event): void; + /** + !#en + Destroy all callbackInfos. + !#zh + 销毁记录的事件 + */ + clear(): void; + } + /** !#en Box Collider. + !#zh 包围盒碰撞组件 */ + export class BoxCollider extends Collider implements Collider.Box { + /** !#en + Collider info in world coordinate. + !#zh + 碰撞体的世界坐标系下的信息。 */ + world: ColliderInfo; + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Box size + !#zh 包围盒大小 */ + size: Size; + } + /** !#en Circle Collider. + !#zh 圆形碰撞组件 */ + export class CircleCollider extends Collider implements Collider.Circle { + /** !#en + Collider info in world coordinate. + !#zh + 碰撞体的世界坐标系下的信息。 */ + world: ColliderInfo; + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Circle radius + !#zh 圆形半径 */ + radius: number; + } + /** !#en Collider component base class. + !#zh 碰撞组件基类 */ + export class Collider extends Component { + /** !#en Tag. If a node has several collider components, you can judge which type of collider is collided according to the tag. + !#zh 标签。当一个节点上有多个碰撞组件时,在发生碰撞后,可以使用此标签来判断是节点上的哪个碰撞组件被碰撞了。 */ + tag: number; + } + /** !#en + Collider Info. + !#zh + 碰撞体信息。 */ + export class ColliderInfo { + /** !#en + Collider aabb information of last frame + !#zh + 碰撞体上一帧的 aabb 信息 */ + preAabb: Rect; + /** !#en + Collider aabb information of current frame + !#zh + 碰撞体当前帧的 aabb 信息 */ + aabb: Rect; + /** !#en + Collider matrix + !#zh + 碰撞体的矩阵信息 */ + matrix: Mat4; + /** !#en + Collider radius (for CircleCollider) + !#zh + 碰撞体的半径(只对 CircleCollider 有效) */ + radius: number; + /** !#en + Collider position (for CircleCollider) + !#zh + 碰撞体的位置(只对 CircleCollider 有效) */ + position: Vec2; + /** !#en + Collider points (for BoxCollider and PolygonCollider) + !#zh + 碰撞体的顶点信息(只对 BoxCollider 和 PolygonCollider 有效) */ + points: Vec2[]; + } + /** !#en + A simple collision manager class. + It will calculate whether the collider collides other colliders, if collides then call the callbacks. + !#zh + 一个简单的碰撞组件管理类,用于处理节点之间的碰撞组件是否产生了碰撞,并调用相应回调函数。 */ + export class CollisionManager implements EventTarget { + /** !#en + !#zh + 是否开启碰撞管理,默认为不开启 */ + enabled: boolean; + /** !#en + !#zh + 是否绘制碰撞组件的包围盒,默认为不绘制 */ + enabledDrawBoundingBox: boolean; + /** !#en + !#zh + 是否绘制碰撞组件的形状,默认为不绘制 */ + enabledDebugDraw: boolean; + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en + Register an callback of a specific event type on the EventTarget. + This type of event should be triggered via `emit`. + !#zh + 注册事件目标的特定事件类型回调。这种类型的事件应该被 `emit` 触发。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, node); + ``` + */ + on(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. + !#zh + 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + + @example + ```js + // register fire eventListener + var callback = eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, target); + // remove fire event listener + eventTarget.off('fire', callback, target); + // remove all fire event listeners + eventTarget.off('fire'); + ``` + */ + off(type: string, callback?: Function, target?: any): void; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.once('fire', function () { + cc.log("this is the callback and will be invoked only once"); + }, node); + ``` + */ + once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; + /** + !#en + Send an event with the event object. + !#zh + 通过事件对象派发事件 + @param event event + */ + dispatchEvent(event: Event): void; + /** + !#en + Destroy all callbackInfos. + !#zh + 销毁记录的事件 + */ + clear(): void; + } + /** !#en Intersection helper class + !#zh 辅助类,用于测试形状与形状是否相交 */ + export class Intersection { + /** + !#en Test line and line + !#zh 测试线段与线段是否相交 + @param a1 The start point of the first line + @param a2 The end point of the first line + @param b1 The start point of the second line + @param b2 The end point of the second line + */ + static lineLine(a1: Vec2, a2: Vec2, b1: Vec2, b2: Vec2): boolean; + /** + !#en Test line and rect + !#zh 测试线段与矩形是否相交 + @param a1 The start point of the line + @param a2 The end point of the line + @param b The rect + */ + static lineRect(a1: Vec2, a2: Vec2, b: Rect): boolean; + /** + !#en Test line and polygon + !#zh 测试线段与多边形是否相交 + @param a1 The start point of the line + @param a2 The end point of the line + @param b The polygon, a set of points + */ + static linePolygon(a1: Vec2, a2: Vec2, b: Vec2[]): boolean; + /** + !#en Test rect and rect + !#zh 测试矩形与矩形是否相交 + @param a The first rect + @param b The second rect + */ + static rectRect(a: Rect, b: Rect): boolean; + /** + !#en Test rect and polygon + !#zh 测试矩形与多边形是否相交 + @param a The rect + @param b The polygon, a set of points + */ + static rectPolygon(a: Rect, b: Vec2[]): boolean; + /** + !#en Test polygon and polygon + !#zh 测试多边形与多边形是否相交 + @param a The first polygon, a set of points + @param b The second polygon, a set of points + */ + static polygonPolygon(a: Vec2[], b: Vec2[]): boolean; + /** + !#en Test circle and circle + !#zh 测试圆形与圆形是否相交 + @param a Object contains position and radius + @param b Object contains position and radius + */ + static circleCircle(a: {position: Vec2, radius: number}, b: {position: Vec2, radius: number}): boolean; + /** + !#en Test polygon and circle + !#zh 测试矩形与圆形是否相交 + @param polygon The Polygon, a set of points + @param circle Object contains position and radius + */ + static polygonCircle(polygon: Vec2[], circle: {position: Vec2, radius: number}): boolean; + /** + !#en Test whether the point is in the polygon + !#zh 测试一个点是否在一个多边形中 + @param point The point + @param polygon The polygon, a set of points + */ + static pointInPolygon(point: Vec2, polygon: Vec2[]): boolean; + /** + !#en Calculate the distance of point to line. + !#zh 计算点到直线的距离。如果这是一条线段并且垂足不在线段内,则会计算点到线段端点的距离。 + @param point The point + @param start The start point of line + @param end The end point of line + @param isSegment whether this line is a segment + */ + static pointLineDistance(point: Vec2, start: Vec2, end: Vec2, isSegment: boolean): number; + } + /** !#en Polygon Collider. + !#zh 多边形碰撞组件 */ + export class PolygonCollider extends Collider implements Collider.Polygon { + /** !#en + Collider info in world coordinate. + !#zh + 碰撞体的世界坐标系下的信息。 */ + world: ColliderInfo; + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Polygon points + !#zh 多边形顶点数组 */ + points: Vec2[]; + } + /** !#en The touch event class + !#zh 封装了触摸相关的信息。 */ + export class Touch { + /** + !#en Returns the current touch location in OpenGL coordinates.、 + !#zh 获取当前触点位置。 + */ + getLocation(): Vec2; + /** + !#en Returns X axis location value. + !#zh 获取当前触点 X 轴位置。 + */ + getLocationX(): number; + /** + !#en Returns Y axis location value. + !#zh 获取当前触点 Y 轴位置。 + */ + getLocationY(): number; + /** + !#en Returns the previous touch location in OpenGL coordinates. + !#zh 获取触点在上一次事件时的位置对象,对象包含 x 和 y 属性。 + */ + getPreviousLocation(): Vec2; + /** + !#en Returns the start touch location in OpenGL coordinates. + !#zh 获取触点落下时的位置对象,对象包含 x 和 y 属性。 + */ + getStartLocation(): Vec2; + /** + !#en Returns the delta distance from the previous touche to the current one in screen coordinates. + !#zh 获取触点距离上一次事件移动的距离对象,对象包含 x 和 y 属性。 + */ + getDelta(): Vec2; + /** + !#en Returns the current touch location in screen coordinates. + !#zh 获取当前事件在游戏窗口内的坐标位置对象,对象包含 x 和 y 属性。 + */ + getLocationInView(): Vec2; + /** + !#en Returns the previous touch location in screen coordinates. + !#zh 获取触点在上一次事件时在游戏窗口中的位置对象,对象包含 x 和 y 属性。 + */ + getPreviousLocationInView(): Vec2; + /** + !#en Returns the start touch location in screen coordinates. + !#zh 获取触点落下时在游戏窗口中的位置对象,对象包含 x 和 y 属性。 + */ + getStartLocationInView(): Vec2; + /** + !#en Returns the id of cc.Touch. + !#zh 触点的标识 ID,可以用来在多点触摸中跟踪触点。 + */ + getID(): number; + /** + !#en Sets information to touch. + !#zh 设置触摸相关的信息。用于监控触摸事件。 + @param id id + @param x x + @param y y + */ + setTouchInfo(id: number, x: number, y: number): void; + } + /** !#en + EventTarget is an object to which an event is dispatched when something has occurred. + Entity are the most common event targets, but other objects can be event targets too. + + Event targets are an important part of the Fireball event model. + The event target serves as the focal point for how events flow through the scene graph. + When an event such as a mouse click or a keypress occurs, Fireball dispatches an event object + into the event flow from the root of the hierarchy. The event object then makes its way through + the scene graph until it reaches the event target, at which point it begins its return trip through + the scene graph. This round-trip journey to the event target is conceptually divided into three phases: + - The capture phase comprises the journey from the root to the last node before the event target's node + - The target phase comprises only the event target node + - The bubbling phase comprises any subsequent nodes encountered on the return trip to the root of the tree + See also: http://www.w3.org/TR/DOM-Level-3-Events/#event-flow + + Event targets can implement the following methods: + - _getCapturingTargets + - _getBubblingTargets + + !#zh + 事件目标是事件触发时,分派的事件对象,Node 是最常见的事件目标, + 但是其他对象也可以是事件目标。
*/ + export class EventTarget extends CallbacksInvoker { + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en + Register an callback of a specific event type on the EventTarget. + This type of event should be triggered via `emit`. + !#zh + 注册事件目标的特定事件类型回调。这种类型的事件应该被 `emit` 触发。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, node); + ``` + */ + on(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. + !#zh + 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + + @example + ```js + // register fire eventListener + var callback = eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, target); + // remove fire event listener + eventTarget.off('fire', callback, target); + // remove all fire event listeners + eventTarget.off('fire'); + ``` + */ + off(type: string, callback?: Function, target?: any): void; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.once('fire', function () { + cc.log("this is the callback and will be invoked only once"); + }, node); + ``` + */ + once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; + /** + !#en + Send an event with the event object. + !#zh + 通过事件对象派发事件 + @param event event + */ + dispatchEvent(event: Event): void; + /** + !#en + Destroy all callbackInfos. + !#zh + 销毁记录的事件 + */ + clear(): void; + } + /** !#en Base class of all kinds of events. + !#zh 包含事件相关信息的对象。 */ + export class Event { + /** + + @param type The name of the event (case-sensitive), e.g. "click", "fire", or "submit" + @param bubbles A boolean indicating whether the event bubbles up through the tree or not + */ + constructor(type: string, bubbles: boolean); + /** !#en The name of the event (case-sensitive), e.g. "click", "fire", or "submit". + !#zh 事件类型。 */ + type: string; + /** !#en Indicate whether the event bubbles up through the tree or not. + !#zh 表示该事件是否进行冒泡。 */ + bubbles: boolean; + /** !#en A reference to the target to which the event was originally dispatched. + !#zh 最初事件触发的目标 */ + target: any; + /** !#en A reference to the currently registered target for the event. + !#zh 当前目标 */ + currentTarget: any; + /** !#en + Indicates which phase of the event flow is currently being evaluated. + Returns an integer value represented by 4 constants: + - Event.NONE = 0 + - Event.CAPTURING_PHASE = 1 + - Event.AT_TARGET = 2 + - Event.BUBBLING_PHASE = 3 + The phases are explained in the [section 3.1, Event dispatch and DOM event flow] + (http://www.w3.org/TR/DOM-Level-3-Events/#event-flow), of the DOM Level 3 Events specification. + !#zh 事件阶段 */ + eventPhase: number; + /** + !#en Reset the event for being stored in the object pool. + !#zh 重置对象池中存储的事件。 + */ + unuse(): string; + /** + !#en Reuse the event for being used again by the object pool. + !#zh 用于对象池再次使用的事件。 + */ + reuse(): string; + /** + !#en Stops propagation for current event. + !#zh 停止传递当前事件。 + */ + stopPropagation(): void; + /** + !#en Stops propagation for current event immediately, + the event won't even be dispatched to the listeners attached in the current target. + !#zh 立即停止当前事件的传递,事件甚至不会被分派到所连接的当前目标。 + */ + stopPropagationImmediate(): void; + /** + !#en Checks whether the event has been stopped. + !#zh 检查该事件是否已经停止传递. + */ + isStopped(): boolean; + /** + !#en +

+ Gets current target of the event
+ note: It only be available when the event listener is associated with node.
+ It returns 0 when the listener is associated with fixed priority. +

+ !#zh 获取当前目标节点 + */ + getCurrentTarget(): Node; + /** + !#en Gets the event type. + !#zh 获取事件类型 + */ + getType(): string; + /** !#en Code for event without type. + !#zh 没有类型的事件 */ + static NO_TYPE: string; + /** !#en The type code of Touch event. + !#zh 触摸事件类型 */ + static TOUCH: string; + /** !#en The type code of Mouse event. + !#zh 鼠标事件类型 */ + static MOUSE: string; + /** !#en The type code of Keyboard event. + !#zh 键盘事件类型 */ + static KEYBOARD: string; + /** !#en The type code of Acceleration event. + !#zh 加速器事件类型 */ + static ACCELERATION: string; + /** !#en Events not currently dispatched are in this phase + !#zh 尚未派发事件阶段 */ + static NONE: number; + /** !#en + The capturing phase comprises the journey from the root to the last node before the event target's node + see http://www.w3.org/TR/DOM-Level-3-Events/#event-flow + !#zh 捕获阶段,包括事件目标节点之前从根节点到最后一个节点的过程。 */ + static CAPTURING_PHASE: number; + /** !#en + The target phase comprises only the event target node + see http://www.w3.org/TR/DOM-Level-3-Events/#event-flow + !#zh 目标阶段仅包括事件目标节点。 */ + static AT_TARGET: number; + /** !#en + The bubbling phase comprises any subsequent nodes encountered on the return trip to the root of the hierarchy + see http://www.w3.org/TR/DOM-Level-3-Events/#event-flow + !#zh 冒泡阶段, 包括回程遇到到层次根节点的任何后续节点。 */ + static BUBBLING_PHASE: number; + } + /** !#en + The System event, it currently supports keyboard events and accelerometer events.
+ You can get the SystemEvent instance with cc.systemEvent.
+ !#zh + 系统事件,它目前支持按键事件和重力感应事件。
+ 你可以通过 cc.systemEvent 获取到 SystemEvent 的实例。
*/ + export class SystemEvent extends EventTarget { + /** + !#en whether enable accelerometer event + !#zh 是否启用加速度计事件 + @param isEnable isEnable + */ + setAccelerometerEnabled(isEnable: boolean): void; + /** + !#en set accelerometer interval value + !#zh 设置加速度计间隔值 + @param interval interval + */ + setAccelerometerInterval(interval: number): void; + } + /** !#en The animation component is used to play back animations. + + Animation provide several events to register: + - play : Emit when begin playing animation + - stop : Emit when stop playing animation + - pause : Emit when pause animation + - resume : Emit when resume animation + - lastframe : If animation repeat count is larger than 1, emit when animation play to the last frame + - finished : Emit when finish playing animation + + !#zh Animation 组件用于播放动画。 + + Animation 提供了一系列可注册的事件: + - play : 开始播放时 + - stop : 停止播放时 + - pause : 暂停播放时 + - resume : 恢复播放时 + - lastframe : 假如动画循环次数大于 1,当动画播放到最后一帧时 + - finished : 动画播放完成时 */ + export class Animation extends Component implements EventTarget { + /** !#en Animation will play the default clip when start game. + !#zh 在勾选自动播放或调用 play() 时默认播放的动画剪辑。 */ + defaultClip: AnimationClip; + /** !#en Current played clip. + !#zh 当前播放的动画剪辑。 */ + currentClip: AnimationClip; + /** !#en Whether the animation should auto play the default clip when start game. + !#zh 是否在运行游戏后自动播放默认动画剪辑。 */ + playOnLoad: boolean; + /** + !#en Get all the clips used in this animation. + !#zh 获取动画组件上的所有动画剪辑。 + */ + getClips(): AnimationClip[]; + /** + !#en Plays an animation and stop other animations. + !#zh 播放指定的动画,并且停止当前正在播放动画。如果没有指定动画,则播放默认动画。 + @param name The name of animation to play. If no name is supplied then the default animation will be played. + @param startTime play an animation from startTime + + @example + ```js + var animCtrl = this.node.getComponent(cc.Animation); + animCtrl.play("linear"); + ``` + */ + play(name?: string, startTime?: number): AnimationState; + /** + !#en + Plays an additive animation, it will not stop other animations. + If there are other animations playing, then will play several animations at the same time. + !#zh 播放指定的动画(将不会停止当前播放的动画)。如果没有指定动画,则播放默认动画。 + @param name The name of animation to play. If no name is supplied then the default animation will be played. + @param startTime play an animation from startTime + + @example + ```js + // linear_1 and linear_2 at the same time playing. + var animCtrl = this.node.getComponent(cc.Animation); + animCtrl.playAdditive("linear_1"); + animCtrl.playAdditive("linear_2"); + ``` + */ + playAdditive(name?: string, startTime?: number): AnimationState; + /** + !#en Stops an animation named name. If no name is supplied then stops all playing animations that were started with this Animation.
+ Stopping an animation also Rewinds it to the Start. + !#zh 停止指定的动画。如果没有指定名字,则停止当前正在播放的动画。 + @param name The animation to stop, if not supplied then stops all playing animations. + */ + stop(name?: string): void; + /** + !#en Pauses an animation named name. If no name is supplied then pauses all playing animations that were started with this Animation. + !#zh 暂停当前或者指定的动画。如果没有指定名字,则暂停当前正在播放的动画。 + @param name The animation to pauses, if not supplied then pauses all playing animations. + */ + pause(name?: string): void; + /** + !#en Resumes an animation named name. If no name is supplied then resumes all paused animations that were started with this Animation. + !#zh 重新播放指定的动画,如果没有指定名字,则重新播放当前正在播放的动画。 + @param name The animation to resumes, if not supplied then resumes all paused animations. + */ + resume(name?: string): void; + /** + !#en Make an animation named name go to the specified time. If no name is supplied then make all animations go to the specified time. + !#zh 设置指定动画的播放时间。如果没有指定名字,则设置当前播放动画的播放时间。 + @param time The time to go to + @param name Specified animation name, if not supplied then make all animations go to the time. + */ + setCurrentTime(time?: number, name?: string): void; + /** + !#en Returns the animation state named name. If no animation with the specified name, the function will return null. + !#zh 获取当前或者指定的动画状态,如果未找到指定动画剪辑则返回 null。 + @param name name + */ + getAnimationState(name: string): AnimationState; + /** + !#en Adds a clip to the animation with name newName. If a clip with that name already exists it will be replaced with the new clip. + !#zh 添加动画剪辑,并且可以重新设置该动画剪辑的名称。 + @param clip the clip to add + @param newName newName + */ + addClip(clip: AnimationClip, newName?: string): AnimationState; + /** + !#en + Remove clip from the animation list. This will remove the clip and any animation states based on it. + If there are animation states depand on the clip are playing or clip is defaultClip, it will not delete the clip. + But if force is true, then will always remove the clip and any animation states based on it. If clip is defaultClip, defaultClip will be reset to null + !#zh + 从动画列表中移除指定的动画剪辑,
+ 如果依赖于 clip 的 AnimationState 正在播放或者 clip 是 defaultClip 的话,默认是不会删除 clip 的。 + 但是如果 force 参数为 true,则会强制停止该动画,然后移除该动画剪辑和相关的动画。这时候如果 clip 是 defaultClip,defaultClip 将会被重置为 null。 + @param clip clip + @param force If force is true, then will always remove the clip and any animation states based on it. + */ + removeClip(clip: AnimationClip, force?: boolean): void; + /** + !#en + Samples animations at the current state.
+ This is useful when you explicitly want to set up some animation state, and sample it once. + !#zh 对指定或当前动画进行采样。你可以手动将动画设置到某一个状态,然后采样一次。 + @param name name + */ + sample(name: string): void; + /** + !#en + Register animation event callback. + The event arguments will provide the AnimationState which emit the event. + When play an animation, will auto register the event callback to the AnimationState, and unregister the event callback from the AnimationState when animation stopped. + !#zh + 注册动画事件回调。 + 回调的事件里将会附上发送事件的 AnimationState。 + 当播放一个动画时,会自动将事件注册到对应的 AnimationState 上,停止播放时会将事件从这个 AnimationState 上取消注册。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param state state + @param target The target (this object) to invoke the callback, can be null + @param useCapture When set to true, the capture argument prevents callback + from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. + When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE. + Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET. + + @example + ```js + onPlay: function (type, state) { + // callback + } + + // register event to all animation + animation.on('play', this.onPlay, this); + ``` + */ + on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void; + on(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void; + on(type: string, callback: (type: string, state: cc.AnimationState) => void, target?: any, useCapture?: boolean): (type: string, state: cc.AnimationState) => void; + /** + !#en + Unregister animation event callback. + !#zh + 取消注册动画事件回调。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not. + If not specified, useCapture defaults to false. If a callback was registered twice, + one with capture and one without, each must be removed separately. Removal of a capturing callback + does not affect a non-capturing version of the same listener, and vice versa. + + @example + ```js + // unregister event to all animation + animation.off('play', this.onPlay, this); + ``` + */ + off(type: string, callback?: Function, target?: any, useCapture?: boolean): void; + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.once('fire', function () { + cc.log("this is the callback and will be invoked only once"); + }, node); + ``` + */ + once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; + /** + !#en + Send an event with the event object. + !#zh + 通过事件对象派发事件 + @param event event + */ + dispatchEvent(event: Event): void; + /** + !#en + Destroy all callbackInfos. + !#zh + 销毁记录的事件 + */ + clear(): void; + } + /** !#en Audio Source. + !#zh 音频源组件,能对音频剪辑。 */ + export class AudioSource extends Component { + /** !#en + Is the audio source playing (Read Only).
+ Note: isPlaying is not supported for Native platforms. + !#zh + 该音频剪辑是否正播放(只读)。
+ 注意:Native 平台暂时不支持 isPlaying。 */ + isPlaying: boolean; + /** !#en The clip of the audio source to play. + !#zh 要播放的音频剪辑。 */ + clip: AudioClip; + /** !#en The volume of the audio source. + !#zh 音频源的音量(0.0 ~ 1.0)。 */ + volume: number; + /** !#en Is the audio source mute? + !#zh 是否静音音频源。Mute 是设置音量为 0,取消静音是恢复原来的音量。 */ + mute: boolean; + /** !#en Is the audio source looping? + !#zh 音频源是否循环播放? */ + loop: boolean; + /** !#en If set to true, the audio source will automatically start playing on onEnable. + !#zh 如果设置为 true,音频源将在 onEnable 时自动播放。 */ + playOnLoad: boolean; + /** !#en If set to true and AudioClip is a deferred load resource, the component will preload AudioClip in the onLoad phase. + !#zh 如果设置为 true 且 AudioClip 为延迟加载资源,组件将在 onLoad 阶段预加载 AudioClip。 */ + preload: boolean; + /** + !#en Plays the clip. + !#zh 播放音频剪辑。 + */ + play(): void; + /** + !#en Stops the clip. + !#zh 停止当前音频剪辑。 + */ + stop(): void; + /** + !#en Pause the clip. + !#zh 暂停当前音频剪辑。 + */ + pause(): void; + /** + !#en Resume the clip. + !#zh 恢复播放。 + */ + resume(): void; + /** + !#en Rewind playing music. + !#zh 从头开始播放。 + */ + rewind(): void; + /** + !#en Get current time + !#zh 获取当前的播放时间 + */ + getCurrentTime(): number; + /** + !#en Set current time + !#zh 设置当前的播放时间 + @param time time + */ + setCurrentTime(time: number): number; + /** + !#en Get audio duration + !#zh 获取当前音频的长度 + */ + getDuration(): number; + } + /** !#en + This component will block all input events (mouse and touch) within the bounding box of the node, preventing the input from penetrating into the underlying node, typically for the background of the top UI.
+ This component does not have any API interface and can be added directly to the scene to take effect. + !#zh + 该组件将拦截所属节点 bounding box 内的所有输入事件(鼠标和触摸),防止输入穿透到下层节点,一般用于上层 UI 的背景。
+ 该组件没有任何 API 接口,直接添加到场景即可生效。 */ + export class BlockInputEvents extends Component { + } + /** !#en + Button component. Can be pressed or clicked. Button has 4 Transition types: + + - Button.Transition.NONE // Button will do nothing + - Button.Transition.COLOR // Button will change target's color + - Button.Transition.SPRITE // Button will change target Sprite's sprite + - Button.Transition.SCALE // Button will change target node's scale + + The button can bind events (but you must be on the button's node to bind events).
+ The following events can be triggered on all platforms. + + - cc.Node.EventType.TOUCH_START // Press + - cc.Node.EventType.TOUCH_MOVE // After pressing and moving + - cc.Node.EventType.TOUCH_END // After pressing and releasing + - cc.Node.EventType.TOUCH_CANCEL // Press to cancel + + The following events are only triggered on the PC platform: + + - cc.Node.EventType.MOUSE_DOWN + - cc.Node.EventType.MOUSE_MOVE + - cc.Node.EventType.MOUSE_ENTER + - cc.Node.EventType.MOUSE_LEAVE + - cc.Node.EventType.MOUSE_UP + - cc.Node.EventType.MOUSE_WHEEL + + User can get the current clicked node with 'event.target' from event object which is passed as parameter in the callback function of click event. + + !#zh + 按钮组件。可以被按下,或者点击。 + + 按钮可以通过修改 Transition 来设置按钮状态过渡的方式: + + - Button.Transition.NONE // 不做任何过渡 + - Button.Transition.COLOR // 进行颜色之间过渡 + - Button.Transition.SPRITE // 进行精灵之间过渡 + - Button.Transition.SCALE // 进行缩放过渡 + + 按钮可以绑定事件(但是必须要在按钮的 Node 上才能绑定事件):
+ 以下事件可以在全平台上都触发: + + - cc.Node.EventType.TOUCH_START // 按下时事件 + - cc.Node.EventType.TOUCH_MOVE // 按住移动后事件 + - cc.Node.EventType.TOUCH_END // 按下后松开后事件 + - cc.Node.EventType.TOUCH_CANCEL // 按下取消事件 + + 以下事件只在 PC 平台上触发: + + - cc.Node.EventType.MOUSE_DOWN // 鼠标按下时事件 + - cc.Node.EventType.MOUSE_MOVE // 鼠标按住移动后事件 + - cc.Node.EventType.MOUSE_ENTER // 鼠标进入目标事件 + - cc.Node.EventType.MOUSE_LEAVE // 鼠标离开目标事件 + - cc.Node.EventType.MOUSE_UP // 鼠标松开事件 + - cc.Node.EventType.MOUSE_WHEEL // 鼠标滚轮事件 + + 用户可以通过获取 __点击事件__ 回调函数的参数 event 的 target 属性获取当前点击对象。 */ + export class Button extends Component implements GraySpriteState { + /** !#en + Whether the Button is disabled. + If true, the Button will trigger event and do transition. + !#zh + 按钮事件是否被响应,如果为 false,则按钮将被禁用。 */ + interactable: boolean; + /** !#en When this flag is true, Button target sprite will turn gray when interactable is false. + !#zh 如果这个标记为 true,当 button 的 interactable 属性为 false 的时候,会使用内置 shader 让 button 的 target 节点的 sprite 组件变灰 */ + enableAutoGrayEffect: boolean; + /** !#en Transition type + !#zh 按钮状态改变时过渡方式。 */ + transition: Button.Transition; + /** !#en Normal state color. + !#zh 普通状态下按钮所显示的颜色。 */ + normalColor: Color; + /** !#en Pressed state color + !#zh 按下状态时按钮所显示的颜色。 */ + pressedColor: Color; + /** !#en Hover state color + !#zh 悬停状态下按钮所显示的颜色。 */ + hoverColor: Color; + /** !#en Disabled state color + !#zh 禁用状态下按钮所显示的颜色。 */ + disabledColor: Color; + /** !#en Color and Scale transition duration + !#zh 颜色过渡和缩放过渡时所需时间 */ + duration: number; + /** !#en When user press the button, the button will zoom to a scale. + The final scale of the button equals (button original scale * zoomScale) + !#zh 当用户点击按钮后,按钮会缩放到一个值,这个值等于 Button 原始 scale * zoomScale */ + zoomScale: number; + /** !#en Normal state sprite + !#zh 普通状态下按钮所显示的 Sprite 。 */ + normalSprite: SpriteFrame; + /** !#en Pressed state sprite + !#zh 按下状态时按钮所显示的 Sprite 。 */ + pressedSprite: SpriteFrame; + /** !#en Hover state sprite + !#zh 悬停状态下按钮所显示的 Sprite 。 */ + hoverSprite: SpriteFrame; + /** !#en Disabled state sprite + !#zh 禁用状态下按钮所显示的 Sprite 。 */ + disabledSprite: SpriteFrame; + /** !#en + Transition target. + When Button state changed: + If Transition type is Button.Transition.NONE, Button will do nothing + If Transition type is Button.Transition.COLOR, Button will change target's color + If Transition type is Button.Transition.SPRITE, Button will change target Sprite's sprite + !#zh + 需要过渡的目标。 + 当前按钮状态改变规则: + -如果 Transition type 选择 Button.Transition.NONE,按钮不做任何过渡。 + -如果 Transition type 选择 Button.Transition.COLOR,按钮会对目标颜色进行颜色之间的过渡。 + -如果 Transition type 选择 Button.Transition.Sprite,按钮会对目标 Sprite 进行 Sprite 之间的过渡。 */ + target: Node; + /** !#en If Button is clicked, it will trigger event's handler + !#zh 按钮的点击事件列表。 */ + clickEvents: Component.EventHandler[]; + /** !#en The normal material. + !#zh 正常状态的材质。 */ + normalMaterial: Material; + /** !#en The gray material. + !#zh 置灰状态的材质。 */ + grayMaterial: Material; + } + /** !#zh 作为 UI 根节点,为所有子节点提供视窗四边的位置信息以供对齐,另外提供屏幕适配策略接口,方便从编辑器设置。
+ 注:由于本节点的尺寸会跟随屏幕拉伸,所以 anchorPoint 只支持 (0.5, 0.5),否则适配不同屏幕时坐标会有偏差。 */ + export class Canvas extends Component { + /** !#en Current active canvas, the scene should only have one active canvas at the same time. + !#zh 当前激活的画布组件,场景同一时间只能有一个激活的画布。 */ + static instance: Canvas; + /** !#en The desigin resolution for current scene. + !#zh 当前场景设计分辨率。 */ + designResolution: Size; + /** !#en TODO + !#zh: 是否优先将设计分辨率高度撑满视图高度。 */ + fitHeight: boolean; + /** !#en TODO + !#zh: 是否优先将设计分辨率宽度撑满视图宽度。 */ + fitWidth: boolean; + } + /** !#en + Base class for everything attached to Node(Entity).
+
+ NOTE: Not allowed to use construction parameters for Component's subclasses, + because Component is created by the engine. + !#zh + 所有附加到节点的基类。
+
+ 注意:不允许使用组件的子类构造参数,因为组件是由引擎创建的。 */ + export class Component extends Object { + /** !#en The node this component is attached to. A component is always attached to a node. + !#zh 该组件被附加到的节点。组件总会附加到一个节点。 */ + node: Node; + /** !#en The uuid for editor. + !#zh 组件的 uuid,用于编辑器。 */ + uuid: string; + /** !#en indicates whether this component is enabled or not. + !#zh 表示该组件自身是否启用。 */ + enabled: boolean; + /** !#en indicates whether this component is enabled and its node is also active in the hierarchy. + !#zh 表示该组件是否被启用并且所在的节点也处于激活状态。 */ + enabledInHierarchy: boolean; + /** !#en Returns a value which used to indicate the onLoad get called or not. + !#zh 返回一个值用来判断 onLoad 是否被调用过,不等于 0 时调用过,等于 0 时未调用。 */ + _isOnLoadCalled: number; + /** + !#en Update is called every frame, if the Component is enabled.
+ This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere. + !#zh 如果该组件启用,则每帧调用 update。
+ 该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。 + @param dt the delta time in seconds it took to complete the last frame + */ + protected update(dt: number): void; + /** + !#en LateUpdate is called every frame, if the Component is enabled.
+ This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere. + !#zh 如果该组件启用,则每帧调用 LateUpdate。
+ 该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。 + @param dt the delta time in seconds it took to complete the last frame + */ + protected lateUpdate(dt: number): void; + /** + !#en + When attaching to an active node or its node first activated. + onLoad is always called before any start functions, this allows you to order initialization of scripts.
+ This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere. + !#zh + 当附加到一个激活的节点上或者其节点第一次激活时候调用。onLoad 总是会在任何 start 方法调用前执行,这能用于安排脚本的初始化顺序。
+ 该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。 + */ + protected onLoad(): void; + /** + !#en + Called before all scripts' update if the Component is enabled the first time. + Usually used to initialize some logic which need to be called after all components' `onload` methods called.
+ This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere. + !#zh + 如果该组件第一次启用,则在所有组件的 update 之前调用。通常用于需要在所有组件的 onLoad 初始化完毕后执行的逻辑。
+ 该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。 + */ + protected start(): void; + /** + !#en Called when this component becomes enabled and its node is active.
+ This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere. + !#zh 当该组件被启用,并且它的节点也激活时。
+ 该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。 + */ + protected onEnable(): void; + /** + !#en Called when this component becomes disabled or its node becomes inactive.
+ This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere. + !#zh 当该组件被禁用或节点变为无效时调用。
+ 该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。 + */ + protected onDisable(): void; + /** + !#en Called when this component will be destroyed.
+ This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere. + !#zh 当该组件被销毁时调用
+ 该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。 + */ + protected onDestroy(): void; + protected onFocusInEditor(): void; + protected onLostFocusInEditor(): void; + /** + !#en Called to initialize the component or node’s properties when adding the component the first time or when the Reset command is used. This function is only called in editor. + !#zh 用来初始化组件或节点的一些属性,当该组件被第一次添加到节点上或用户点击了它的 Reset 菜单时调用。这个回调只会在编辑器下调用。 + */ + protected resetInEditor(): void; + /** + !#en Adds a component class to the node. You can also add component to node by passing in the name of the script. + !#zh 向节点添加一个组件类,你还可以通过传入脚本的名称来添加组件。 + @param typeOrClassName the constructor or the class name of the component to add + + @example + ```js + var sprite = node.addComponent(cc.Sprite); + var test = node.addComponent("Test"); + ``` + */ + addComponent(type: {new(): T}): T; + addComponent(className: string): any; + /** + !#en + Returns the component of supplied type if the node has one attached, null if it doesn't.
+ You can also get component in the node by passing in the name of the script. + !#zh + 获取节点上指定类型的组件,如果节点有附加指定类型的组件,则返回,如果没有则为空。
+ 传入参数也可以是脚本的名称。 + @param typeOrClassName typeOrClassName + + @example + ```js + // get sprite component. + var sprite = node.getComponent(cc.Sprite); + // get custom test calss. + var test = node.getComponent("Test"); + ``` + */ + getComponent(type: {prototype: T}): T; + getComponent(className: string): any; + /** + !#en Returns all components of supplied Type in the node. + !#zh 返回节点上指定类型的所有组件。 + @param typeOrClassName typeOrClassName + + @example + ```js + var sprites = node.getComponents(cc.Sprite); + var tests = node.getComponents("Test"); + ``` + */ + getComponents(type: {prototype: T}): T[]; + getComponents(className: string): any[]; + /** + !#en Returns the component of supplied type in any of its children using depth first search. + !#zh 递归查找所有子节点中第一个匹配指定类型的组件。 + @param typeOrClassName typeOrClassName + + @example + ```js + var sprite = node.getComponentInChildren(cc.Sprite); + var Test = node.getComponentInChildren("Test"); + ``` + */ + getComponentInChildren(type: {prototype: T}): T; + getComponentInChildren(className: string): any; + /** + !#en Returns the components of supplied type in self or any of its children using depth first search. + !#zh 递归查找自身或所有子节点中指定类型的组件 + @param typeOrClassName typeOrClassName + + @example + ```js + var sprites = node.getComponentsInChildren(cc.Sprite); + var tests = node.getComponentsInChildren("Test"); + ``` + */ + getComponentsInChildren(type: {prototype: T}): T[]; + getComponentsInChildren(className: string): any[]; + /** + !#en + If the component's bounding box is different from the node's, you can implement this method to supply + a custom axis aligned bounding box (AABB), so the editor's scene view can perform hit test properly. + !#zh + 如果组件的包围盒与节点不同,您可以实现该方法以提供自定义的轴向对齐的包围盒(AABB), + 以便编辑器的场景视图可以正确地执行点选测试。 + @param out_rect the Rect to receive the bounding box + */ + _getLocalBounds(out_rect: Rect): void; + /** + !#en + onRestore is called after the user clicks the Reset item in the Inspector's context menu or performs + an undo operation on this component.
+
+ If the component contains the "internal state", short for "temporary member variables which not included
+ in its CCClass properties", then you may need to implement this function.
+
+ The editor will call the getset accessors of your component to record/restore the component's state
+ for undo/redo operation. However, in extreme cases, it may not works well. Then you should implement
+ this function to manually synchronize your component's "internal states" with its public properties.
+ Once you implement this function, all the getset accessors of your component will not be called when
+ the user performs an undo/redo operation. Which means that only the properties with default value
+ will be recorded or restored by editor.
+
+ Similarly, the editor may failed to reset your component correctly in extreme cases. Then if you need
+ to support the reset menu, you should manually synchronize your component's "internal states" with its
+ properties in this function. Once you implement this function, all the getset accessors of your component
+ will not be called during reset operation. Which means that only the properties with default value
+ will be reset by editor. + + This function is only called in editor mode. + !#zh + onRestore 是用户在检查器菜单点击 Reset 时,对此组件执行撤消操作后调用的。
+
+ 如果组件包含了“内部状态”(不在 CCClass 属性中定义的临时成员变量),那么你可能需要实现该方法。
+
+ 编辑器执行撤销/重做操作时,将调用组件的 get set 来录制和还原组件的状态。然而,在极端的情况下,它可能无法良好运作。
+ 那么你就应该实现这个方法,手动根据组件的属性同步“内部状态”。一旦你实现这个方法,当用户撤销或重做时,组件的所有 get set 都不会再被调用。这意味着仅仅指定了默认值的属性将被编辑器记录和还原。
+
+ 同样的,编辑可能无法在极端情况下正确地重置您的组件。如果你需要支持组件重置菜单,则需要在该方法中手工同步组件属性到“内部状态”。一旦你实现这个方法,组件的所有 get set 都不会在重置操作时被调用。这意味着仅仅指定了默认值的属性将被编辑器重置。 +
+ 此方法仅在编辑器下会被调用。 + */ + onRestore(): void; + /** + !#en + Schedules a custom selector.
+ If the selector is already scheduled, then the interval parameter will be updated without scheduling it again. + !#zh + 调度一个自定义的回调函数。
+ 如果回调函数已调度,那么将不会重复调度它,只会更新时间间隔参数。 + @param callback The callback function + @param interval Tick interval in seconds. 0 means tick every frame. + @param repeat The selector will be executed (repeat + 1) times, you can use cc.macro.REPEAT_FOREVER for tick infinitely. + @param delay The amount of time that the first tick will wait before execution. Unit: s + + @example + ```js + var timeCallback = function (dt) { + cc.log("time: " + dt); + } + this.schedule(timeCallback, 1); + ``` + */ + schedule(callback: Function, interval?: number, repeat?: number, delay?: number): void; + /** + !#en Schedules a callback function that runs only once, with a delay of 0 or larger. + !#zh 调度一个只运行一次的回调函数,可以指定 0 让回调函数在下一帧立即执行或者在一定的延时之后执行。 + @param callback A function wrapped as a selector + @param delay The amount of time that the first tick will wait before execution. Unit: s + + @example + ```js + var timeCallback = function (dt) { + cc.log("time: " + dt); + } + this.scheduleOnce(timeCallback, 2); + ``` + */ + scheduleOnce(callback: Function, delay?: number): void; + /** + !#en Unschedules a custom callback function. + !#zh 取消调度一个自定义的回调函数。 + @param callback_fn A function wrapped as a selector + + @example + ```js + this.unschedule(_callback); + ``` + */ + unschedule(callback_fn: Function): void; + /** + !#en + unschedule all scheduled callback functions: custom callback functions, and the 'update' callback function.
+ Actions are not affected by this method. + !#zh 取消调度所有已调度的回调函数:定制的回调函数以及 `update` 回调函数。动作不受此方法影响。 + + @example + ```js + this.unscheduleAllCallbacks(); + ``` + */ + unscheduleAllCallbacks(): void; + } + /** !#en The Label Component. + !#zh 文字标签组件 */ + export class Label extends RenderComponent { + /** !#en Content string of label. + !#zh 标签显示的文本内容。 */ + string: string; + /** !#en Horizontal Alignment of label. + !#zh 文本内容的水平对齐方式。 */ + horizontalAlign: Label.HorizontalAlign; + /** !#en Vertical Alignment of label. + !#zh 文本内容的垂直对齐方式。 */ + verticalAlign: Label.VerticalAlign; + /** !#en The actual rendering font size in shrink mode + !#zh SHRINK 模式下面文本实际渲染的字体大小 */ + actualFontSize: number; + /** !#en Font size of label. + !#zh 文本字体大小。 */ + fontSize: number; + /** !#en Font family of label, only take effect when useSystemFont property is true. + !#zh 文本字体名称, 只在 useSystemFont 属性为 true 的时候生效。 */ + fontFamily: string; + /** !#en Line Height of label. + !#zh 文本行高。 */ + lineHeight: number; + /** !#en Overflow of label. + !#zh 文字显示超出范围时的处理方式。 */ + overflow: Label.Overflow; + /** !#en Whether auto wrap label when string width is large than label width. + !#zh 是否自动换行。 */ + enableWrapText: boolean; + /** !#en The font of label. + !#zh 文本字体。 */ + font: Font; + /** !#en Whether use system font name or not. + !#zh 是否使用系统字体。 */ + useSystemFont: boolean; + /** !#en The spacing of the x axis between characters, only take Effect when using bitmap fonts. + !#zh 文字之间 x 轴的间距,仅在使用位图字体时生效。 */ + spacingX: number; + /** !#en The cache mode of label. This mode only supports system fonts. + !#zh 文本缓存模式, 该模式只支持系统字体。 */ + cacheMode: Label.CacheMode; + /** !#en Whether enable bold. + !#zh 是否启用黑体。 */ + enableBold: boolean; + /** !#en Whether enable italic. + !#zh 是否启用斜体。 */ + enableItalic: boolean; + /** !#en Whether enable underline. + !#zh 是否启用下划线。 */ + enableUnderline: boolean; + /** !#en The height of underline. + !#zh 下划线高度。 */ + underlineHeight: number; + /** + !#zh 需要保证当前场景中没有使用CHAR缓存的Label才可以清除,否则已渲染的文字没有重新绘制会不显示 + !#en It can be cleared that need to ensure there is not use the CHAR cache in the current scene. Otherwise, the rendered text will not be displayed without repainting. + */ + static clearCharCache(): void; + } + /** !#en Outline effect used to change the display, only for system fonts or TTF fonts + !#zh 描边效果组件,用于字体描边,只能用于系统字体 */ + export class LabelOutline extends Component { + /** !#en outline color + !#zh 改变描边的颜色 */ + color: Color; + /** !#en Change the outline width + !#zh 改变描边的宽度 */ + width: number; + } + /** !#en Shadow effect for Label component, only for system fonts or TTF fonts + !#zh 用于给 Label 组件添加阴影效果,只能用于系统字体或 ttf 字体 */ + export class LabelShadow extends Component { + /** !#en The shadow color + !#zh 阴影的颜色 */ + color: Color; + /** !#en Offset between font and shadow + !#zh 字体与阴影的偏移 */ + offset: Vec2; + /** !#en A non-negative float specifying the level of shadow blur + !#zh 阴影的模糊程度 */ + blur: number; + } + /** !#en + The Layout is a container component, use it to arrange child elements easily.
+ Note:
+ 1.Scaling and rotation of child nodes are not considered.
+ 2.After setting the Layout, the results need to be updated until the next frame, + unless you manually call {{#crossLink "Layout/updateLayout:method"}}{{/crossLink}}。 + !#zh + Layout 组件相当于一个容器,能自动对它的所有子节点进行统一排版。
+ 注意:
+ 1.不会考虑子节点的缩放和旋转。
+ 2.对 Layout 设置后结果需要到下一帧才会更新,除非你设置完以后手动调用 {{#crossLink "Layout/updateLayout:method"}}{{/crossLink}}。 */ + export class Layout extends Component { + /** !#en The layout type. + !#zh 布局类型 */ + type: Layout.Type; + /** !#en + The are three resize modes for Layout. + None, resize Container and resize children. + !#zh 缩放模式 */ + resizeMode: Layout.ResizeMode; + /** !#en The cell size for grid layout. + !#zh 每个格子的大小,只有布局类型为 GRID 的时候才有效。 */ + cellSize: Size; + /** !#en + The start axis for grid layout. If you choose horizontal, then children will layout horizontally at first, + and then break line on demand. Choose vertical if you want to layout vertically at first . + !#zh 起始轴方向类型,可进行水平和垂直布局排列,只有布局类型为 GRID 的时候才有效。 */ + startAxis: Layout.AxisDirection; + /** !#en The left padding of layout, it only effect the layout in one direction. + !#zh 容器内左边距,只会在一个布局方向上生效。 */ + paddingLeft: number; + /** !#en The right padding of layout, it only effect the layout in one direction. + !#zh 容器内右边距,只会在一个布局方向上生效。 */ + paddingRight: number; + /** !#en The top padding of layout, it only effect the layout in one direction. + !#zh 容器内上边距,只会在一个布局方向上生效。 */ + paddingTop: number; + /** !#en The bottom padding of layout, it only effect the layout in one direction. + !#zh 容器内下边距,只会在一个布局方向上生效。 */ + paddingBottom: number; + /** !#en The distance in x-axis between each element in layout. + !#zh 子节点之间的水平间距。 */ + spacingX: number; + /** !#en The distance in y-axis between each element in layout. + !#zh 子节点之间的垂直间距。 */ + spacingY: number; + /** !#en + Only take effect in Vertical layout mode. + This option changes the start element's positioning. + !#zh 垂直排列子节点的方向。 */ + verticalDirection: Layout.VerticalDirection; + /** !#en + Only take effect in Horizontal layout mode. + This option changes the start element's positioning. + !#zh 水平排列子节点的方向。 */ + horizontalDirection: Layout.HorizontalDirection; + /** !#en Adjust the layout if the children scaled. + !#zh 子节点缩放比例是否影响布局。 */ + affectedByScale: boolean; + /** + !#en Perform the layout update + !#zh 立即执行更新布局 + + @example + ```js + layout.type = cc.Layout.HORIZONTAL; + layout.node.addChild(childNode); + cc.log(childNode.x); // not yet changed + layout.updateLayout(); + cc.log(childNode.x); // changed + ``` + */ + updateLayout(): void; + } + /** !#en The Mask Component + !#zh 遮罩组件 */ + export class Mask extends RenderComponent { + /** !#en The mask type. + !#zh 遮罩类型 */ + type: Mask.Type; + /** !#en The mask image + !#zh 遮罩所需要的贴图 */ + spriteFrame: SpriteFrame; + /** !#en + The alpha threshold.(Not supported Canvas Mode)
+ The content is drawn only where the stencil have pixel with alpha greater than the alphaThreshold.
+ Should be a float between 0 and 1.
+ This default to 0.1. + When it's set to 1, the stencil will discard all pixels, nothing will be shown. + !#zh + Alpha 阈值(不支持 Canvas 模式)
+ 只有当模板的像素的 alpha 大于等于 alphaThreshold 时,才会绘制内容。
+ 该数值 0 ~ 1 之间的浮点数,默认值为 0.1 + 当被设置为 1 时,会丢弃所有蒙版像素,所以不会显示任何内容 */ + alphaThreshold: number; + /** !#en Reverse mask (Not supported Canvas Mode) + !#zh 反向遮罩(不支持 Canvas 模式) */ + inverted: boolean; + /** TODO: remove segments, not supported by graphics + !#en The segements for ellipse mask. + !#zh 椭圆遮罩的曲线细分数 */ + segements: number; + } + /** !#en + cc.MotionStreak manages a Ribbon based on it's motion in absolute space.
+ You construct it with a fadeTime, minimum segment size, texture path, texture
+ length and color. The fadeTime controls how long it takes each vertex in
+ the streak to fade out, the minimum segment size it how many pixels the
+ streak will move before adding a new ribbon segment, and the texture
+ length is the how many pixels the texture is stretched across. The texture
+ is vertically aligned along the streak segment. + !#zh 运动轨迹,用于游戏对象的运动轨迹上实现拖尾渐隐效果。 */ + export class MotionStreak extends Component implements BlendFunc { + /** !#en + !#zh 在编辑器模式下预览拖尾效果。 */ + preview: boolean; + /** !#en The fade time to fade. + !#zh 拖尾的渐隐时间,以秒为单位。 */ + fadeTime: number; + /** !#en The minimum segment size. + !#zh 拖尾之间最小距离。 */ + minSeg: number; + /** !#en The stroke's width. + !#zh 拖尾的宽度。 */ + stroke: number; + /** !#en The texture of the MotionStreak. + !#zh 拖尾的贴图。 */ + texture: Texture2D; + /** !#en The color of the MotionStreak. + !#zh 拖尾的颜色 */ + color: Color; + /** !#en The fast Mode. + !#zh 是否启用了快速模式。当启用快速模式,新的点会被更快地添加,但精度较低。 */ + fastMode: boolean; + /** + !#en Remove all living segments of the ribbon. + !#zh 删除当前所有的拖尾片段。 + + @example + ```js + // Remove all living segments of the ribbon. + myMotionStreak.reset(); + ``` + */ + reset(): void; + /** !#en specify the source Blend Factor, this will generate a custom material object, please pay attention to the memory cost. + !#zh 指定原图的混合模式,这会克隆一个新的材质对象,注意这带来的开销 */ + srcBlendFactor: macro.BlendFactor; + /** !#en specify the destination Blend Factor. + !#zh 指定目标的混合模式 */ + dstBlendFactor: macro.BlendFactor; + } + /** !#en The PageView control + !#zh 页面视图组件 */ + export class PageView extends ScrollView { + /** !#en Specify the size type of each page in PageView. + !#zh 页面视图中每个页面大小类型 */ + sizeMode: PageView.SizeMode; + /** !#en The page view direction + !#zh 页面视图滚动类型 */ + direction: PageView.Direction; + /** !#en + The scroll threshold value, when drag exceeds this value, + release the next page will automatically scroll, less than the restore + !#zh 滚动临界值,默认单位百分比,当拖拽超出该数值时,松开会自动滚动下一页,小于时则还原。 */ + scrollThreshold: number; + /** !#en + Auto page turning velocity threshold. When users swipe the PageView quickly, + it will calculate a velocity based on the scroll distance and time, + if the calculated velocity is larger than the threshold, then it will trigger page turning. + !#zh + 快速滑动翻页临界值。 + 当用户快速滑动时,会根据滑动开始和结束的距离与时间计算出一个速度值, + 该值与此临界值相比较,如果大于临界值,则进行自动翻页。 */ + autoPageTurningThreshold: number; + /** !#en Change the PageTurning event timing of PageView. + !#zh 设置 PageView PageTurning 事件的发送时机。 */ + pageTurningEventTiming: number; + /** !#en The Page View Indicator + !#zh 页面视图指示器组件 */ + indicator: PageViewIndicator; + /** !#en The time required to turn over a page. unit: second + !#zh 每个页面翻页时所需时间。单位:秒 */ + pageTurningSpeed: number; + /** !#en PageView events callback + !#zh 滚动视图的事件回调函数 */ + pageEvents: Component.EventHandler[]; + /** + !#en Returns current page index + !#zh 返回当前页面索引 + */ + getCurrentPageIndex(): number; + /** + !#en Set current page index + !#zh 设置当前页面索引 + @param index index + */ + setCurrentPageIndex(index: number): void; + /** + !#en Returns all pages of pageview + !#zh 返回视图中的所有页面 + */ + getPages(): Node[]; + /** + !#en At the end of the current page view to insert a new view + !#zh 在当前页面视图的尾部插入一个新视图 + @param page page + */ + addPage(page: Node): void; + /** + !#en Inserts a page in the specified location + !#zh 将页面插入指定位置中 + @param page page + @param index index + */ + insertPage(page: Node, index: number): void; + /** + !#en Removes a page from PageView. + !#zh 移除指定页面 + @param page page + */ + removePage(page: Node): void; + /** + !#en Removes a page at index of PageView. + !#zh 移除指定下标的页面 + @param index index + */ + removePageAtIndex(index: number): void; + /** + !#en Removes all pages from PageView + !#zh 移除所有页面 + */ + removeAllPages(): void; + /** + !#en Scroll PageView to index. + !#zh 滚动到指定页面 + @param idx index of page. + @param timeInSecond scrolling time + */ + scrollToPage(idx: number, timeInSecond: number): void; + } + /** !#en The Page View Indicator Component + !#zh 页面视图每页标记组件 */ + export class PageViewIndicator extends Component { + /** !#en The spriteFrame for each element. + !#zh 每个页面标记显示的图片 */ + spriteFrame: SpriteFrame; + /** !#en The location direction of PageViewIndicator. + !#zh 页面标记摆放方向 */ + direction: PageViewIndicator.Direction; + /** !#en The cellSize for each element. + !#zh 每个页面标记的大小 */ + cellSize: Size; + /** !#en The distance between each element. + !#zh 每个页面标记之间的边距 */ + spacing: number; + /** + !#en Set Page View + !#zh 设置页面视图 + @param target target + */ + setPageView(target: PageView): void; + } + /** !#en + Visual indicator of progress in some operation. + Displays a bar to the user representing how far the operation has progressed. + !#zh + 进度条组件,可用于显示加载资源时的进度。 */ + export class ProgressBar extends Component { + /** !#en The targeted Sprite which will be changed progressively. + !#zh 用来显示进度条比例的 Sprite 对象。 */ + barSprite: Sprite; + /** !#en The progress mode, there are two modes supported now: horizontal and vertical. + !#zh 进度条的模式 */ + mode: ProgressBar.Mode; + /** !#en The total width or height of the bar sprite. + !#zh 进度条实际的总长度 */ + totalLength: number; + /** !#en The current progress of the bar sprite. The valid value is between 0-1. + !#zh 当前进度值,该数值的区间是 0-1 之间。 */ + progress: number; + /** !#en Whether reverse the progress direction of the bar sprite. + !#zh 进度条是否进行反方向变化。 */ + reverse: boolean; + } + /** !#en + Base class for components which supports rendering features. + !#zh + 所有支持渲染的组件的基类 */ + export class RenderComponent extends Component { + /** !#en The materials used by this render component. + !#zh 渲染组件使用的材质。 */ + sharedMaterials: Material[]; + /** + !#en Get the material by index. + !#zh 根据指定索引获取材质 + @param index index + */ + getMaterial(index: number): MaterialVariant; + /** + !#en Gets all the materials. + !#zh 获取所有材质。 + */ + getMaterials(): MaterialVariant[]; + /** + !#en Set the material by index. + !#zh 根据指定索引设置材质 + @param index index + @param material material + */ + setMaterial(index: number, material: Material): Material; + } + /** !#en The RichText Component. + !#zh 富文本组件 */ + export class RichText extends Component { + /** !#en Content string of RichText. + !#zh 富文本显示的文本内容。 */ + string: string; + /** !#en Horizontal Alignment of each line in RichText. + !#zh 文本内容的水平对齐方式。 */ + horizontalAlign: macro.TextAlignment; + /** !#en Font size of RichText. + !#zh 富文本字体大小。 */ + fontSize: number; + /** !#en Custom System font of RichText + !#zh 富文本定制系统字体 */ + fontFamily: string; + /** !#en Custom TTF font of RichText + !#zh 富文本定制字体 */ + font: TTFFont; + /** !#en Whether use system font name or not. + !#zh 是否使用系统字体。 */ + useSystemFont: boolean; + /** !#en The cache mode of label. This mode only supports system fonts. + !#zh 文本缓存模式, 该模式只支持系统字体。 */ + cacheMode: Label.CacheMode; + /** !#en The maximize width of the RichText + !#zh 富文本的最大宽度 */ + maxWidth: number; + /** !#en Line Height of RichText. + !#zh 富文本行高。 */ + lineHeight: number; + /** !#en The image atlas for the img tag. For each src value in the img tag, there should be a valid spriteFrame in the image atlas. + !#zh 对于 img 标签里面的 src 属性名称,都需要在 imageAtlas 里面找到一个有效的 spriteFrame,否则 img tag 会判定为无效。 */ + imageAtlas: SpriteAtlas; + /** !#en + Once checked, the RichText will block all input events (mouse and touch) within + the bounding box of the node, preventing the input from penetrating into the underlying node. + !#zh + 选中此选项后,RichText 将阻止节点边界框中的所有输入事件(鼠标和触摸),从而防止输入事件穿透到底层节点。 */ + handleTouchEvent: boolean; + } + /** !#en + This component is used to adjust the layout of current node to respect the safe area of a notched mobile device such as the iPhone X. + It is typically used for the top node of the UI interaction area. For specific usage, refer to the official [example-cases/02_ui/16_safeArea/SafeArea.fire](https://github.com/cocos-creator/example-cases). + + The concept of safe area is to give you a fixed inner rectangle in which you can safely display content that will be drawn on screen. + You are strongly discouraged from providing controls outside of this area. But your screen background could embellish edges. + + This component internally uses the API `cc.sys.getSafeAreaRect();` to obtain the safe area of the current iOS or Android device, + and implements the adaptation by using the Widget component and set anchor. + + !#zh + 该组件会将所在节点的布局适配到 iPhone X 等异形屏手机的安全区域内,通常用于 UI 交互区域的顶层节点,具体用法可参考官方范例 [example-cases/02_ui/16_safeArea/SafeArea.fire](https://github.com/cocos-creator/example-cases)。 + + 该组件内部通过 API `cc.sys.getSafeAreaRect();` 获取到当前 iOS 或 Android 设备的安全区域,并通过 Widget 组件实现适配。 */ + export class SafeArea extends Component { + /** + !#en Adapt to safe area + !#zh 立即适配安全区域 + + @example + ```js + let safeArea = this.node.addComponent(cc.SafeArea); + safeArea.updateArea(); + ``` + */ + updateArea(): void; + } + /** !#en + The Scrollbar control allows the user to scroll an image or other view that is too large to see completely + !#zh 滚动条组件 */ + export class Scrollbar extends Component { + /** !#en The "handle" part of the scrollbar. + !#zh 作为当前滚动区域位置显示的滑块 Sprite。 */ + handle: Sprite; + /** !#en The direction of scrollbar. + !#zh ScrollBar 的滚动方向。 */ + direction: Scrollbar.Direction; + /** !#en Whether enable auto hide or not. + !#zh 是否在没有滚动动作时自动隐藏 ScrollBar。 */ + enableAutoHide: boolean; + /** !#en + The time to hide scrollbar when scroll finished. + Note: This value is only useful when enableAutoHide is true. + !#zh + 没有滚动动作后经过多久会自动隐藏。 + 注意:只要当 “enableAutoHide” 为 true 时,才有效。 */ + autoHideTime: number; + } + /** !#en + Layout container for a view hierarchy that can be scrolled by the user, + allowing it to be larger than the physical display. + + !#zh + 滚动视图组件 */ + export class ScrollView extends Component { + /** !#en This is a reference to the UI element to be scrolled. + !#zh 可滚动展示内容的节点。 */ + content: Node; + /** !#en Enable horizontal scroll. + !#zh 是否开启水平滚动。 */ + horizontal: boolean; + /** !#en Enable vertical scroll. + !#zh 是否开启垂直滚动。 */ + vertical: boolean; + /** !#en When inertia is set, the content will continue to move when touch ended. + !#zh 是否开启滚动惯性。 */ + inertia: boolean; + /** !#en + It determines how quickly the content stop moving. A value of 1 will stop the movement immediately. + A value of 0 will never stop the movement until it reaches to the boundary of scrollview. + !#zh + 开启惯性后,在用户停止触摸后滚动多快停止,0表示永不停止,1表示立刻停止。 */ + brake: number; + /** !#en When elastic is set, the content will be bounce back when move out of boundary. + !#zh 是否允许滚动内容超过边界,并在停止触摸后回弹。 */ + elastic: boolean; + /** !#en The elapse time of bouncing back. A value of 0 will bounce back immediately. + !#zh 回弹持续的时间,0 表示将立即反弹。 */ + bounceDuration: number; + /** !#en The horizontal scrollbar reference. + !#zh 水平滚动的 ScrollBar。 */ + horizontalScrollBar: Scrollbar; + /** !#en The vertical scrollbar reference. + !#zh 垂直滚动的 ScrollBar。 */ + verticalScrollBar: Scrollbar; + /** !#en Scrollview events callback + !#zh 滚动视图的事件回调函数 */ + scrollEvents: Component.EventHandler[]; + /** !#en If cancelInnerEvents is set to true, the scroll behavior will cancel touch events on inner content nodes + It's set to true by default. + !#zh 如果这个属性被设置为 true,那么滚动行为会取消子节点上注册的触摸事件,默认被设置为 true。 + 注意,子节点上的 touchstart 事件仍然会触发,触点移动距离非常短的情况下 touchmove 和 touchend 也不会受影响。 */ + cancelInnerEvents: boolean; + /** + !#en Scroll the content to the bottom boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图底部。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the bottom boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the bottom of the view. + scrollView.scrollToBottom(0.1); + ``` + */ + scrollToBottom(timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the top boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图顶部。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the top boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the top of the view. + scrollView.scrollToTop(0.1); + ``` + */ + scrollToTop(timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the left boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图左边。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the left boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the left of the view. + scrollView.scrollToLeft(0.1); + ``` + */ + scrollToLeft(timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the right boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图右边。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the right boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the right of the view. + scrollView.scrollToRight(0.1); + ``` + */ + scrollToRight(timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the top left boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图左上角。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the top left boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the upper left corner of the view. + scrollView.scrollToTopLeft(0.1); + ``` + */ + scrollToTopLeft(timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the top right boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图右上角。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the top right boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the top right corner of the view. + scrollView.scrollToTopRight(0.1); + ``` + */ + scrollToTopRight(timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the bottom left boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图左下角。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the bottom left boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the lower left corner of the view. + scrollView.scrollToBottomLeft(0.1); + ``` + */ + scrollToBottomLeft(timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the bottom right boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图右下角。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the bottom right boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the lower right corner of the view. + scrollView.scrollToBottomRight(0.1); + ``` + */ + scrollToBottomRight(timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll with an offset related to the ScrollView's top left origin, if timeInSecond is omitted, then it will jump to the + specific offset immediately. + !#zh 视图内容在规定时间内将滚动到 ScrollView 相对左上角原点的偏移位置, 如果 timeInSecond参数不传,则立即滚动到指定偏移位置。 + @param offset A Vec2, the value of which each axis between 0 and maxScrollOffset + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the specific offset of ScrollView immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to middle position in 0.1 second in x-axis + let maxScrollOffset = this.getMaxScrollOffset(); + scrollView.scrollToOffset(cc.v2(maxScrollOffset.x / 2, 0), 0.1); + ``` + */ + scrollToOffset(offset: Vec2, timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Get the positive offset value corresponds to the content's top left boundary. + !#zh 获取滚动视图相对于左上角原点的当前滚动偏移 + */ + getScrollOffset(): Vec2; + /** + !#en Get the maximize available scroll offset + !#zh 获取滚动视图最大可以滚动的偏移量 + */ + getMaxScrollOffset(): Vec2; + /** + !#en Scroll the content to the horizontal percent position of ScrollView. + !#zh 视图内容在规定时间内将滚动到 ScrollView 水平方向的百分比位置上。 + @param percent A value between 0 and 1. + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the horizontal percent position of ScrollView immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to middle position. + scrollView.scrollToBottomRight(0.5, 0.1); + ``` + */ + scrollToPercentHorizontal(percent: number, timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the percent position of ScrollView in any direction. + !#zh 视图内容在规定时间内进行垂直方向和水平方向的滚动,并且滚动到指定百分比位置上。 + @param anchor A point which will be clamp between cc.v2(0,0) and cc.v2(1,1). + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the percent position of ScrollView immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Vertical scroll to the bottom of the view. + scrollView.scrollTo(cc.v2(0, 1), 0.1); + + // Horizontal scroll to view right. + scrollView.scrollTo(cc.v2(1, 0), 0.1); + ``` + */ + scrollTo(anchor: Vec2, timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the vertical percent position of ScrollView. + !#zh 视图内容在规定时间内滚动到 ScrollView 垂直方向的百分比位置上。 + @param percent A value between 0 and 1. + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the vertical percent position of ScrollView immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + // Scroll to middle position. + scrollView.scrollToPercentVertical(0.5, 0.1); + */ + scrollToPercentVertical(percent: number, timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Stop auto scroll immediately + !#zh 停止自动滚动, 调用此 API 可以让 Scrollview 立即停止滚动 + */ + stopAutoScroll(): void; + /** + !#en Modify the content position. + !#zh 设置当前视图内容的坐标点。 + @param position The position in content's parent space. + */ + setContentPosition(position: Vec2): void; + /** + !#en Query the content's position in its parent space. + !#zh 获取当前视图内容的坐标点。 + */ + getContentPosition(): Vec2; + /** + !#en Query whether the user is currently dragging the ScrollView to scroll it + !#zh 用户是否在拖拽当前滚动视图 + */ + isScrolling(): boolean; + /** + !#en Query whether the ScrollView is currently scrolling because of a bounceback or inertia slowdown. + !#zh 当前滚动视图是否在惯性滚动 + */ + isAutoScrolling(): boolean; + } + /** !#en The Slider Control + !#zh 滑动器组件 */ + export class Slider extends Component { + /** !#en The "handle" part of the slider + !#zh 滑动器滑块按钮部件 */ + handle: Button; + /** !#en The slider direction + !#zh 滑动器方向 */ + direction: Slider.Direction; + /** !#en The current progress of the slider. The valid value is between 0-1 + !#zh 当前进度值,该数值的区间是 0-1 之间 */ + progress: number; + /** !#en The slider slide events' callback array + !#zh 滑动器组件滑动事件回调函数数组 */ + slideEvents: Component.EventHandler[]; + } + /** !#en Renders a sprite in the scene. + !#zh 该组件用于在场景中渲染精灵。 */ + export class Sprite extends RenderComponent implements BlendFunc { + /** !#en The sprite frame of the sprite. + !#zh 精灵的精灵帧 */ + spriteFrame: SpriteFrame; + /** !#en The sprite render type. + !#zh 精灵渲染类型 */ + type: Sprite.Type; + /** !#en + The fill type, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”. + !#zh + 精灵填充类型,仅渲染类型设置为 cc.Sprite.Type.FILLED 时有效。 */ + fillType: Sprite.FillType; + /** !#en + The fill Center, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”. + !#zh + 填充中心点,仅渲染类型设置为 cc.Sprite.Type.FILLED 时有效。 */ + fillCenter: Vec2; + /** !#en + The fill Start, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”. + !#zh + 填充起始点,仅渲染类型设置为 cc.Sprite.Type.FILLED 时有效。 */ + fillStart: number; + /** !#en + The fill Range, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”. + !#zh + 填充范围,仅渲染类型设置为 cc.Sprite.Type.FILLED 时有效。 */ + fillRange: number; + /** !#en specify the frame is trimmed or not. + !#zh 是否使用裁剪模式 */ + trim: boolean; + /** !#en specify the size tracing mode. + !#zh 精灵尺寸调整模式 */ + sizeMode: Sprite.SizeMode; + /** + Change the state of sprite. + @param state NORMAL or GRAY State. + */ + setState(state: Sprite.State): void; + /** + Gets the current state. + */ + getState(): Sprite.State; + /** !#en specify the source Blend Factor, this will generate a custom material object, please pay attention to the memory cost. + !#zh 指定原图的混合模式,这会克隆一个新的材质对象,注意这带来的开销 */ + srcBlendFactor: macro.BlendFactor; + /** !#en specify the destination Blend Factor. + !#zh 指定目标的混合模式 */ + dstBlendFactor: macro.BlendFactor; + } + /** !#en The toggle component is a CheckBox, when it used together with a ToggleGroup, it + could be treated as a RadioButton. + !#zh Toggle 是一个 CheckBox,当它和 ToggleGroup 一起使用的时候,可以变成 RadioButton。 */ + export class Toggle extends Button implements GraySpriteState { + /** !#en When this value is true, the check mark component will be enabled, otherwise + the check mark component will be disabled. + !#zh 如果这个设置为 true,则 check mark 组件会处于 enabled 状态,否则处于 disabled 状态。 */ + isChecked: boolean; + /** !#en The toggle group which the toggle belongs to, when it is null, the toggle is a CheckBox. + Otherwise, the toggle is a RadioButton. + !#zh Toggle 所属的 ToggleGroup,这个属性是可选的。如果这个属性为 null,则 Toggle 是一个 CheckBox, + 否则,Toggle 是一个 RadioButton。 */ + toggleGroup: ToggleGroup; + /** !#en The image used for the checkmark. + !#zh Toggle 处于选中状态时显示的图片 */ + checkMark: Sprite; + /** !#en If Toggle is clicked, it will trigger event's handler + !#zh Toggle 按钮的点击事件列表。 */ + checkEvents: Component.EventHandler[]; + /** + !#en Make the toggle button checked. + !#zh 使 toggle 按钮处于选中状态 + */ + check(): void; + /** + !#en Make the toggle button unchecked. + !#zh 使 toggle 按钮处于未选中状态 + */ + uncheck(): void; + /** !#en The normal material. + !#zh 正常状态的材质。 */ + normalMaterial: Material; + /** !#en The gray material. + !#zh 置灰状态的材质。 */ + grayMaterial: Material; + } + /** !#en ToggleContainer is not a visiable UI component but a way to modify the behavior of a set of Toggles.
+ Toggles that belong to the same group could only have one of them to be switched on at a time.
+ Note: All the first layer child node containing the toggle component will auto be added to the container + !#zh ToggleContainer 不是一个可见的 UI 组件,它可以用来修改一组 Toggle 组件的行为。
+ 当一组 Toggle 属于同一个 ToggleContainer 的时候,任何时候只能有一个 Toggle 处于选中状态。
+ 注意:所有包含 Toggle 组件的一级子节点都会自动被添加到该容器中 */ + export class ToggleContainer extends Component { + /** !#en If this setting is true, a toggle could be switched off and on when pressed. + If it is false, it will make sure there is always only one toggle could be switched on + and the already switched on toggle can't be switched off. + !#zh 如果这个设置为 true, 那么 toggle 按钮在被点击的时候可以反复地被选中和未选中。 */ + allowSwitchOff: boolean; + /** !#en If Toggle is clicked, it will trigger event's handler + !#zh Toggle 按钮的点击事件列表。 */ + checkEvents: Component.EventHandler[]; + /** !#en Read only property, return the toggle items array reference managed by ToggleContainer. + !#zh 只读属性,返回 ToggleContainer 管理的 toggle 数组引用 */ + toggleItems: Toggle[]; + } + /** !#en ToggleGroup is not a visiable UI component but a way to modify the behavior of a set of Toggles. + Toggles that belong to the same group could only have one of them to be switched on at a time. + !#zh ToggleGroup 不是一个可见的 UI 组件,它可以用来修改一组 Toggle 组件的行为。当一组 Toggle 属于同一个 ToggleGroup 的时候, + 任何时候只能有一个 Toggle 处于选中状态。 */ + export class ToggleGroup extends Component { + /** !#en If this setting is true, a toggle could be switched off and on when pressed. + If it is false, it will make sure there is always only one toggle could be switched on + and the already switched on toggle can't be switched off. + !#zh 如果这个设置为 true, 那么 toggle 按钮在被点击的时候可以反复地被选中和未选中。 */ + allowSwitchOff: boolean; + /** !#en Read only property, return the toggle items array reference managed by toggleGroup. + !#zh 只读属性,返回 toggleGroup 管理的 toggle 数组引用 */ + toggleItems: any[]; + } + /** !#en + Handling touch events in a ViewGroup takes special care, + because it's common for a ViewGroup to have children that are targets for different touch events than the ViewGroup itself. + To make sure that each view correctly receives the touch events intended for it, + ViewGroup should register capture phase event and handle the event propagation properly. + Please refer to Scrollview for more information. + + !#zh + ViewGroup的事件处理比较特殊,因为 ViewGroup 里面的子节点关心的事件跟 ViewGroup 本身可能不一样。 + 为了让子节点能够正确地处理事件,ViewGroup 需要注册 capture 阶段的事件,并且合理地处理 ViewGroup 之间的事件传递。 + 请参考 ScrollView 的实现来获取更多信息。 */ + export class ViewGroup extends Component { + } + /** !#en + Stores and manipulate the anchoring based on its parent. + Widget are used for GUI but can also be used for other things. + Widget will adjust current node's position and size automatically, but the results after adjustment can not be obtained until the next frame unless you call {{#crossLink "Widget/updateAlignment:method"}}{{/crossLink}} manually. + !#zh + Widget 组件,用于设置和适配其相对于父节点的边距,Widget 通常被用于 UI 界面,也可以用于其他地方。 + Widget 会自动调整当前节点的坐标和宽高,不过目前调整后的结果要到下一帧才能在脚本里获取到,除非你先手动调用 {{#crossLink "Widget/updateAlignment:method"}}{{/crossLink}}。 */ + export class Widget extends Component { + /** !#en Specifies an alignment target that can only be one of the parent nodes of the current node. + The default value is null, and when null, indicates the current parent. + !#zh 指定一个对齐目标,只能是当前节点的其中一个父节点,默认为空,为空时表示当前父节点。 */ + target: Node; + /** !#en Whether to align the top. + !#zh 是否对齐上边。 */ + isAlignTop: boolean; + /** !#en + Vertically aligns the midpoint, This will open the other vertical alignment options cancel. + !#zh + 是否垂直方向对齐中点,开启此项会将垂直方向其他对齐选项取消。 */ + isAlignVerticalCenter: boolean; + /** !#en Whether to align the bottom. + !#zh 是否对齐下边。 */ + isAlignBottom: boolean; + /** !#en Whether to align the left. + !#zh 是否对齐左边 */ + isAlignLeft: boolean; + /** !#en + Horizontal aligns the midpoint. This will open the other horizontal alignment options canceled. + !#zh + 是否水平方向对齐中点,开启此选项会将水平方向其他对齐选项取消。 */ + isAlignHorizontalCenter: boolean; + /** !#en Whether to align the right. + !#zh 是否对齐右边。 */ + isAlignRight: boolean; + /** !#en + Whether the stretched horizontally, when enable the left and right alignment will be stretched horizontally, + the width setting is invalid (read only). + !#zh + 当前是否水平拉伸。当同时启用左右对齐时,节点将会被水平拉伸,此时节点的宽度只读。 */ + isStretchWidth: boolean; + /** !#en + Whether the stretched vertically, when enable the left and right alignment will be stretched vertically, + then height setting is invalid (read only) + !#zh + 当前是否垂直拉伸。当同时启用上下对齐时,节点将会被垂直拉伸,此时节点的高度只读。 */ + isStretchHeight: boolean; + /** !#en + The margins between the top of this node and the top of parent node, + the value can be negative, Only available in 'isAlignTop' open. + !#zh + 本节点顶边和父节点顶边的距离,可填写负值,只有在 isAlignTop 开启时才有作用。 */ + top: number; + /** !#en + The margins between the bottom of this node and the bottom of parent node, + the value can be negative, Only available in 'isAlignBottom' open. + !#zh + 本节点底边和父节点底边的距离,可填写负值,只有在 isAlignBottom 开启时才有作用。 */ + bottom: number; + /** !#en + The margins between the left of this node and the left of parent node, + the value can be negative, Only available in 'isAlignLeft' open. + !#zh + 本节点左边和父节点左边的距离,可填写负值,只有在 isAlignLeft 开启时才有作用。 */ + left: number; + /** !#en + The margins between the right of this node and the right of parent node, + the value can be negative, Only available in 'isAlignRight' open. + !#zh + 本节点右边和父节点右边的距离,可填写负值,只有在 isAlignRight 开启时才有作用。 */ + right: number; + /** !#en + Horizontal aligns the midpoint offset value, + the value can be negative, Only available in 'isAlignHorizontalCenter' open. + !#zh 水平居中的偏移值,可填写负值,只有在 isAlignHorizontalCenter 开启时才有作用。 */ + horizontalCenter: number; + /** !#en + Vertical aligns the midpoint offset value, + the value can be negative, Only available in 'isAlignVerticalCenter' open. + !#zh 垂直居中的偏移值,可填写负值,只有在 isAlignVerticalCenter 开启时才有作用。 */ + verticalCenter: number; + /** !#en If true, horizontalCenter is pixel margin, otherwise is percentage (0 - 1) margin. + !#zh 如果为 true,"horizontalCenter" 将会以像素作为偏移值,反之为百分比(0 到 1)。 */ + isAbsoluteHorizontalCenter: boolean; + /** !#en If true, verticalCenter is pixel margin, otherwise is percentage (0 - 1) margin. + !#zh 如果为 true,"verticalCenter" 将会以像素作为偏移值,反之为百分比(0 到 1)。 */ + isAbsoluteVerticalCenter: boolean; + /** !#en + If true, top is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's height. + !#zh + 如果为 true,"top" 将会以像素作为边距,否则将会以相对父物体高度的百分比(0 到 1)作为边距。 */ + isAbsoluteTop: boolean; + /** !#en + If true, bottom is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's height. + !#zh + 如果为 true,"bottom" 将会以像素作为边距,否则将会以相对父物体高度的百分比(0 到 1)作为边距。 */ + isAbsoluteBottom: boolean; + /** !#en + If true, left is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's width. + !#zh + 如果为 true,"left" 将会以像素作为边距,否则将会以相对父物体宽度的百分比(0 到 1)作为边距。 */ + isAbsoluteLeft: boolean; + /** !#en + If true, right is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's width. + !#zh + 如果为 true,"right" 将会以像素作为边距,否则将会以相对父物体宽度的百分比(0 到 1)作为边距。 */ + isAbsoluteRight: boolean; + /** !#en Specifies the alignment mode of the Widget, which determines when the widget should refresh. + !#zh 指定 Widget 的对齐模式,用于决定 Widget 应该何时刷新。 */ + alignMode: Widget.AlignMode; + /** + !#en + Immediately perform the widget alignment. You need to manually call this method only if + you need to get the latest results after the alignment before the end of current frame. + !#zh + 立刻执行 widget 对齐操作。这个接口一般不需要手工调用。 + 只有当你需要在当前帧结束前获得 widget 对齐后的最新结果时才需要手动调用这个方法。 + + @example + ```js + widget.top = 10; // change top margin + cc.log(widget.node.y); // not yet changed + widget.updateAlignment(); + cc.log(widget.node.y); // changed + ``` + */ + updateAlignment(): void; + /** !#en + When turned on, it will only be aligned once at the end of the onEnable frame, + then immediately disables the current component. + This will allow the script or animation to continue controlling the current node. + Note: It will still be aligned at the frame when onEnable is called. + !#zh + 开启后仅会在 onEnable 的当帧结束时对齐一次,然后立刻禁用当前组件。 + 这样便于脚本或动画继续控制当前节点。 + 注意:onEnable 时所在的那一帧仍然会进行对齐。 */ + isAlignOnce: boolean; + } + /** !#en SubContextView is a view component which controls open data context viewport in minigame platform.
+ The component's node size decide the viewport of the sub context content in main context, + the entire sub context texture will be scaled to the node's bounding box area.
+ This component provides multiple important features:
+ 1. Sub context could use its own resolution size and policy.
+ 2. Sub context could be minized to smallest size it needed.
+ 3. Resolution of sub context content could be increased.
+ 4. User touch input is transformed to the correct viewport.
+ 5. Texture update is handled by this component. User don't need to worry.
+ One important thing to be noted, whenever the node's bounding box change, + !#zh SubContextView 可以用来控制小游戏平台开放数据域在主域中的视窗的位置。
+ 这个组件的节点尺寸决定了开放数据域内容在主域中的尺寸,整个开放数据域会被缩放到节点的包围盒范围内。
+ 在这个组件的控制下,用户可以更自由得控制开放数据域:
+ 1. 子域中可以使用独立的设计分辨率和适配模式
+ 2. 子域区域尺寸可以缩小到只容纳内容即可
+ 3. 子域的分辨率也可以被放大,以便获得更清晰的显示效果
+ 4. 用户输入坐标会被自动转换到正确的子域视窗中
+ 5. 子域内容贴图的更新由组件负责,用户不需要处理
*/ + export class SubContextView extends Component { + /** + !#en Reset open data context size and viewport + !#zh 重置开放数据域的尺寸和视窗 + */ + reset(): void; + /** + !#en Update the sub context viewport manually, it should be called whenever the node's bounding box changes. + !#zh 更新开放数据域相对于主域的 viewport,这个函数应该在节点包围盒改变时手动调用。 + */ + updateSubContextViewport(): void; + } + /** !#en WXSubContextView is deprecated since v2.4.1, please use SubContextView instead. + !#zh 自 v2.4.1 起,WXSubContextView 已经废弃,请使用 SubContextView */ + export class WXSubContextView extends Component { + } + /** !#en SwanSubContextView is deprecated since v2.4.1, please use SubContextView instead. + !#zh 自 v2.4.1 起,SwanSubContextView 已经废弃,请使用 SubContextView */ + export class SwanSubContextView extends Component { + } + /** !#en Mesh Asset. + !#zh 网格资源。 */ + export class Mesh extends Asset implements EventTarget { + /** !#en Get ir set the sub meshes. + !#zh 设置或者获取子网格。 */ + subMeshes: InputAssembler[]; + /** + !#en + Init vertex buffer according to the vertex format. + !#zh + 根据顶点格式初始化顶点内存。 + @param vertexFormat vertex format + @param vertexCount how much vertex should be create in this buffer. + @param dynamic whether or not to use dynamic buffer. + @param index index + */ + init(vertexFormat: gfx.VertexFormat, vertexCount: number, dynamic?: boolean, index?: boolean): void; + /** + !#en + Set the vertex values. + !#zh + 设置顶点数据 + @param name the attribute name, e.g. gfx.ATTR_POSITION + @param values the vertex values + */ + setVertices(name: string, values: Vec2[]|Vec3[]|Color[]|number[]|Uint8Array|Float32Array): void; + /** + !#en + Set the sub mesh indices. + !#zh + 设置子网格索引。 + @param indices the sub mesh indices. + @param index sub mesh index. + @param dynamic whether or not to use dynamic buffer. + */ + setIndices(indices: number[]|Uint16Array|Uint8Array, index?: number, dynamic?: boolean): void; + /** + !#en + Set the sub mesh primitive type. + !#zh + 设置子网格绘制线条的方式。 + @param type type + @param index index + */ + setPrimitiveType(type: number, index: number): void; + /** + !#en + Clear the buffer data. + !#zh + 清除网格创建的内存数据。 + */ + clear(): void; + /** + !#en Set mesh bounding box + !#zh 设置网格的包围盒 + @param min min + @param max max + */ + setBoundingBox(min: Vec3, max: Vec3): void; + /** + !#en Read the specified attributes of the subgrid into the target buffer. + !#zh 读取子网格的指定属性到目标缓冲区中。 + @param primitiveIndex The subgrid index. + @param attributeName attribute name. + @param buffer The target buffer. + @param stride The byte interval between adjacent attributes in the target buffer. + @param offset The offset of the first attribute in the target buffer. + */ + copyAttribute(primitiveIndex: number, attributeName: string, buffer: ArrayBuffer, stride: number, offset: number): boolean; + /** + !#en Read the index data of the subgrid into the target array. + !#zh 读取子网格的索引数据到目标数组中。 + @param primitiveIndex The subgrid index. + @param outputArray The target array. + */ + copyIndices(primitiveIndex: number, outputArray: DataView): boolean; + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en + Register an callback of a specific event type on the EventTarget. + This type of event should be triggered via `emit`. + !#zh + 注册事件目标的特定事件类型回调。这种类型的事件应该被 `emit` 触发。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, node); + ``` + */ + on(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. + !#zh + 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + + @example + ```js + // register fire eventListener + var callback = eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, target); + // remove fire event listener + eventTarget.off('fire', callback, target); + // remove all fire event listeners + eventTarget.off('fire'); + ``` + */ + off(type: string, callback?: Function, target?: any): void; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.once('fire', function () { + cc.log("this is the callback and will be invoked only once"); + }, node); + ``` + */ + once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; + /** + !#en + Send an event with the event object. + !#zh + 通过事件对象派发事件 + @param event event + */ + dispatchEvent(event: Event): void; + } + /** !#en + Mesh Renderer Component + !#zh + 网格渲染组件 */ + export class MeshRenderer extends RenderComponent { + /** !#en + The mesh which the renderer uses. + !#zh + 设置使用的网格 */ + mesh: Mesh; + /** !#en + Whether the mesh should receive shadows. + !#zh + 网格是否接受光源投射的阴影 */ + receiveShadows: boolean; + /** !#en + Shadow Casting Mode + !#zh + 网格投射阴影的模式 */ + shadowCastingMode: MeshRenderer.ShadowCastingMode; + /** !#en + Enable auto merge mesh, only support when mesh's VertexFormat, PrimitiveType, materials are all the same + !#zh + 开启自动合并 mesh 功能,只有在网格的 顶点格式,PrimitiveType, 使用的材质 都一致的情况下才会有效 */ + enableAutoBatch: boolean; + } + /** The class BufferRange denotes a range of the buffer. */ + export class BufferRange { + /** The offset of the range. */ + offset: number; + /** The length of the range. */ + length: number; + } + /** undefined */ + export class VertexFormat { + /** The data range of this bundle. + This range of data is essentially mapped to a GPU vertex buffer. */ + data: BufferRange; + /** The attribute formats. */ + formats: VertexFormat; + /** The vertex bundle that the primitive use. */ + vertexBundleIndices: number[]; + /** The data range of the primitive. + This range of data is essentially mapped to a GPU indices buffer. */ + data: BufferRange; + /** The type of this primitive's indices. */ + indexUnit: number; + /** The primitive's topology. */ + topology: number; + } + /** undefined */ + export class Graphics extends RenderComponent { + /** !#en + Current line width. + !#zh + 当前线条宽度 */ + lineWidth: number; + /** !#en + lineJoin determines how two connecting segments (of lines, arcs or curves) with non-zero lengths in a shape are joined together. + !#zh + lineJoin 用来设置2个长度不为0的相连部分(线段,圆弧,曲线)如何连接在一起的属性。 */ + lineJoin: Graphics.LineJoin; + /** !#en + lineCap determines how the end points of every line are drawn. + !#zh + lineCap 指定如何绘制每一条线段末端。 */ + lineCap: Graphics.LineCap; + /** !#en + stroke color + !#zh + 线段颜色 */ + strokeColor: Color; + /** !#en + fill color + !#zh + 填充颜色 */ + fillColor: Color; + /** !#en + Sets the miter limit ratio + !#zh + 设置斜接面限制比例 */ + miterLimit: number; + /** + !#en Move path start point to (x,y). + !#zh 移动路径起点到坐标(x, y) + @param x The x axis of the coordinate for the end point. + @param y The y axis of the coordinate for the end point. + */ + moveTo(x?: number, y?: number): void; + /** + !#en Adds a straight line to the path + !#zh 绘制直线路径 + @param x The x axis of the coordinate for the end point. + @param y The y axis of the coordinate for the end point. + */ + lineTo(x?: number, y?: number): void; + /** + !#en Adds a cubic Bézier curve to the path + !#zh 绘制三次贝赛尔曲线路径 + @param c1x The x axis of the coordinate for the first control point. + @param c1y The y axis of the coordinate for first control point. + @param c2x The x axis of the coordinate for the second control point. + @param c2y The y axis of the coordinate for the second control point. + @param x The x axis of the coordinate for the end point. + @param y The y axis of the coordinate for the end point. + */ + bezierCurveTo(c1x?: number, c1y?: number, c2x?: number, c2y?: number, x?: number, y?: number): void; + /** + !#en Adds a quadratic Bézier curve to the path + !#zh 绘制二次贝赛尔曲线路径 + @param cx The x axis of the coordinate for the control point. + @param cy The y axis of the coordinate for the control point. + @param x The x axis of the coordinate for the end point. + @param y The y axis of the coordinate for the end point. + */ + quadraticCurveTo(cx?: number, cy?: number, x?: number, y?: number): void; + /** + !#en Adds an arc to the path which is centered at (cx, cy) position with radius r starting at startAngle and ending at endAngle going in the given direction by counterclockwise (defaulting to false). + !#zh 绘制圆弧路径。圆弧路径的圆心在 (cx, cy) 位置,半径为 r ,根据 counterclockwise (默认为false)指定的方向从 startAngle 开始绘制,到 endAngle 结束。 + @param cx The x axis of the coordinate for the center point. + @param cy The y axis of the coordinate for the center point. + @param r The arc's radius. + @param startAngle The angle at which the arc starts, measured clockwise from the positive x axis and expressed in radians. + @param endAngle The angle at which the arc ends, measured clockwise from the positive x axis and expressed in radians. + @param counterclockwise An optional Boolean which, if true, causes the arc to be drawn counter-clockwise between the two angles. By default it is drawn clockwise. + */ + arc(cx?: number, cy?: number, r?: number, startAngle?: number, endAngle?: number, counterclockwise?: boolean): void; + /** + !#en Adds an ellipse to the path. + !#zh 绘制椭圆路径。 + @param cx The x axis of the coordinate for the center point. + @param cy The y axis of the coordinate for the center point. + @param rx The ellipse's x-axis radius. + @param ry The ellipse's y-axis radius. + */ + ellipse(cx?: number, cy?: number, rx?: number, ry?: number): void; + /** + !#en Adds an circle to the path. + !#zh 绘制圆形路径。 + @param cx The x axis of the coordinate for the center point. + @param cy The y axis of the coordinate for the center point. + @param r The circle's radius. + */ + circle(cx?: number, cy?: number, r?: number): void; + /** + !#en Adds an rectangle to the path. + !#zh 绘制矩形路径。 + @param x The x axis of the coordinate for the rectangle starting point. + @param y The y axis of the coordinate for the rectangle starting point. + @param w The rectangle's width. + @param h The rectangle's height. + */ + rect(x?: number, y?: number, w?: number, h?: number): void; + /** + !#en Adds an round corner rectangle to the path. + !#zh 绘制圆角矩形路径。 + @param x The x axis of the coordinate for the rectangle starting point. + @param y The y axis of the coordinate for the rectangle starting point. + @param w The rectangles width. + @param h The rectangle's height. + @param r The radius of the rectangle. + */ + roundRect(x?: number, y?: number, w?: number, h?: number, r?: number): void; + /** + !#en Draws a filled rectangle. + !#zh 绘制填充矩形。 + @param x The x axis of the coordinate for the rectangle starting point. + @param y The y axis of the coordinate for the rectangle starting point. + @param w The rectangle's width. + @param h The rectangle's height. + */ + fillRect(x?: number, y?: number, w?: number, h?: number): void; + /** + !#en Erasing any previously drawn content. + !#zh 擦除之前绘制的所有内容的方法。 + @param clean Whether to clean the graphics inner cache. + */ + clear(clean?: boolean): void; + /** + !#en Causes the point of the pen to move back to the start of the current path. It tries to add a straight line from the current point to the start. + !#zh 将笔点返回到当前路径起始点的。它尝试从当前点到起始点绘制一条直线。 + */ + close(): void; + /** + !#en Strokes the current or given path with the current stroke style. + !#zh 根据当前的画线样式,绘制当前或已经存在的路径。 + */ + stroke(): void; + /** + !#en Fills the current or given path with the current fill style. + !#zh 根据当前的画线样式,填充当前或已经存在的路径。 + */ + fill(): void; + } + /** !#en The module provides utilities for working with file and directory paths + !#zh 用于处理文件与目录的路径的模块 */ + export class path { + /** + !#en Join strings to be a path. + !#zh 拼接字符串为 Path + + @example + ```js + ------------------------------ + cc.path.join("a", "b.png"); //-->"a/b.png" + cc.path.join("a", "b", "c.png"); //-->"a/b/c.png" + cc.path.join("a", "b"); //-->"a/b" + cc.path.join("a", "b", "/"); //-->"a/b/" + cc.path.join("a", "b/", "/"); //-->"a/b/" + + ``` + */ + static join(): string; + /** + !#en Get the ext name of a path including '.', like '.png'. + !#zh 返回 Path 的扩展名,包括 '.',例如 '.png'。 + @param pathStr pathStr + + @example + ```js + --------------------------- + cc.path.extname("a/b.png"); //-->".png" + cc.path.extname("a/b.png?a=1&b=2"); //-->".png" + cc.path.extname("a/b"); //-->null + cc.path.extname("a/b?a=1&b=2"); //-->null + + ``` + */ + static extname(pathStr: string): any; + /** + !#en Get the main name of a file name + !#zh 获取文件名的主名称 + @param fileName fileName + */ + static mainFileName(fileName: string): string; + /** + !#en Get the file name of a file path. + !#zh 获取文件路径的文件名。 + @param pathStr pathStr + @param extname extname + + @example + ```js + --------------------------------- + cc.path.basename("a/b.png"); //-->"b.png" + cc.path.basename("a/b.png?a=1&b=2"); //-->"b.png" + cc.path.basename("a/b.png", ".png"); //-->"b" + cc.path.basename("a/b.png?a=1&b=2", ".png"); //-->"b" + cc.path.basename("a/b.png", ".txt"); //-->"b.png" + + ``` + */ + static basename(pathStr: string, extname?: string): any; + /** + !#en Get dirname of a file path. + !#zh 获取文件路径的目录名。 + @param pathStr pathStr + + @example + ```js + --------------------------------- + * unix + cc.path.driname("a/b/c.png"); //-->"a/b" + cc.path.driname("a/b/c.png?a=1&b=2"); //-->"a/b" + cc.path.dirname("a/b/"); //-->"a/b" + cc.path.dirname("c.png"); //-->"" + * windows + cc.path.driname("a\\b\\c.png"); //-->"a\b" + cc.path.driname("a\\b\\c.png?a=1&b=2"); //-->"a\b" + + ``` + */ + static dirname(pathStr: string): any; + /** + !#en Change extname of a file path. + !#zh 更改文件路径的扩展名。 + @param pathStr pathStr + @param extname extname + + @example + ```js + --------------------------------- + cc.path.changeExtname("a/b.png", ".plist"); //-->"a/b.plist" + cc.path.changeExtname("a/b.png?a=1&b=2", ".plist"); //-->"a/b.plist?a=1&b=2" + + ``` + */ + static changeExtname(pathStr: string, extname?: string): string; + } + /** !#en + AffineTransform class represent an affine transform matrix. It's composed basically by translation, rotation, scale transformations.
+ !#zh + AffineTransform 类代表一个仿射变换矩阵。它基本上是由平移旋转,缩放转变所组成。
*/ + export class AffineTransform { + /** + !#en Create a AffineTransform object with all contents in the matrix. + !#zh 用在矩阵中的所有内容创建一个 AffineTransform 对象。 + @param a a + @param b b + @param c c + @param d d + @param tx tx + @param ty ty + */ + static create(a: number, b: number, c: number, d: number, tx: number, ty: number): AffineTransform; + /** + !#en + Create a identity transformation matrix:
+ [ 1, 0, 0,
+ 0, 1, 0 ] + !#zh + 单位矩阵:
+ [ 1, 0, 0,
+ 0, 1, 0 ] + */ + static identity(): AffineTransform; + /** + !#en Clone a AffineTransform object from the specified transform. + !#zh 克隆指定的 AffineTransform 对象。 + @param t t + */ + static clone(t: AffineTransform): AffineTransform; + /** + !#en + Concatenate a transform matrix to another + The results are reflected in the out affine transform + out = t1 * t2 + This function is memory free, you should create the output affine transform by yourself and manage its memory. + !#zh + 拼接两个矩阵,将结果保存到 out 矩阵。这个函数不创建任何内存,你需要先创建 AffineTransform 对象用来存储结果,并作为第一个参数传入函数。 + out = t1 * t2 + @param out Out object to store the concat result + @param t1 The first transform object. + @param t2 The transform object to concatenate. + */ + static concat(out: AffineTransform, t1: AffineTransform, t2: AffineTransform): AffineTransform; + /** + !#en Get the invert transform of an AffineTransform object. + This function is memory free, you should create the output affine transform by yourself and manage its memory. + !#zh 求逆矩阵。这个函数不创建任何内存,你需要先创建 AffineTransform 对象用来存储结果,并作为第一个参数传入函数。 + @param out out + @param t t + */ + static invert(out: AffineTransform, t: AffineTransform): AffineTransform; + /** + !#en Get an AffineTransform object from a given matrix 4x4. + This function is memory free, you should create the output affine transform by yourself and manage its memory. + !#zh 从一个 4x4 Matrix 获取 AffineTransform 对象。这个函数不创建任何内存,你需要先创建 AffineTransform 对象用来存储结果,并作为第一个参数传入函数。 + @param out out + @param mat mat + */ + static invert(out: AffineTransform, mat: Mat4): AffineTransform; + /** + !#en Apply the affine transformation on a point. + This function is memory free, you should create the output Vec2 by yourself and manage its memory. + !#zh 对一个点应用矩阵变换。这个函数不创建任何内存,你需要先创建一个 Vec2 对象用来存储结果,并作为第一个参数传入函数。 + @param out The output point to store the result + @param point Point to apply transform or x. + @param transOrY transform matrix or y. + @param t transform matrix. + */ + static transformVec2(out: Vec2, point: Vec2|number, transOrY: AffineTransform|number, t?: AffineTransform): Vec2; + /** + !#en Apply the affine transformation on a size. + This function is memory free, you should create the output Size by yourself and manage its memory. + !#zh 应用仿射变换矩阵到 Size 上。这个函数不创建任何内存,你需要先创建一个 Size 对象用来存储结果,并作为第一个参数传入函数。 + @param out The output point to store the result + @param size size + @param t t + */ + static transformSize(out: Size, size: Size, t: AffineTransform): Size; + /** + !#en Apply the affine transformation on a rect. + This function is memory free, you should create the output Rect by yourself and manage its memory. + !#zh 应用仿射变换矩阵到 Rect 上。这个函数不创建任何内存,你需要先创建一个 Rect 对象用来存储结果,并作为第一个参数传入函数。 + @param out out + @param rect rect + @param anAffineTransform anAffineTransform + */ + static transformRect(out: Rect, rect: Rect, anAffineTransform: AffineTransform): Rect; + /** + !#en Apply the affine transformation on a rect, and truns to an Oriented Bounding Box. + This function is memory free, you should create the output vectors by yourself and manage their memory. + !#zh 应用仿射变换矩阵到 Rect 上, 并转换为有向包围盒。这个函数不创建任何内存,你需要先创建包围盒的四个 Vector 对象用来存储结果,并作为前四个参数传入函数。 + @param out_bl out_bl + @param out_tl out_tl + @param out_tr out_tr + @param out_br out_br + @param rect rect + @param anAffineTransform anAffineTransform + */ + static transformObb(out_bl: Vec2, out_tl: Vec2, out_tr: Vec2, out_br: Vec2, rect: Rect, anAffineTransform: AffineTransform): void; + } + /** A base node for CCNode, it will: + - maintain scene hierarchy and active logic + - notifications if some properties changed + - define some interfaces shares between CCNode + - define machanisms for Enity Component Systems + - define prefab and serialize functions */ + export class _BaseNode extends Object implements EventTarget { + /** !#en Name of node. + !#zh 该节点名称。 */ + name: string; + /** !#en The uuid for editor, will be stripped before building project. + !#zh 主要用于编辑器的 uuid,在编辑器下可用于持久化存储,在项目构建之后将变成自增的 id。 */ + uuid: string; + /** !#en All children nodes. + !#zh 节点的所有子节点。 */ + children: Node[]; + /** !#en All children nodes. + !#zh 节点的子节点数量。 */ + childrenCount: number; + /** !#en + The local active state of this node.
+ Note that a Node may be inactive because a parent is not active, even if this returns true.
+ Use {{#crossLink "Node/activeInHierarchy:property"}}{{/crossLink}} if you want to check if the Node is actually treated as active in the scene. + !#zh + 当前节点的自身激活状态。
+ 值得注意的是,一个节点的父节点如果不被激活,那么即使它自身设为激活,它仍然无法激活。
+ 如果你想检查节点在场景中实际的激活状态可以使用 {{#crossLink "Node/activeInHierarchy:property"}}{{/crossLink}}。 */ + active: boolean; + /** !#en Indicates whether this node is active in the scene. + !#zh 表示此节点是否在场景中激活。 */ + activeInHierarchy: boolean; + /** + + @param name name + */ + constructor(name?: string); + /** !#en The parent of the node. + !#zh 该节点的父节点。 */ + parent: Node; + /** + !#en Get parent of the node. + !#zh 获取该节点的父节点。 + + @example + ```js + var parent = this.node.getParent(); + ``` + */ + getParent(): Node; + /** + !#en Set parent of the node. + !#zh 设置该节点的父节点。 + @param value value + + @example + ```js + node.setParent(newNode); + ``` + */ + setParent(value: Node): void; + /** + !#en + Properties configuration function
+ All properties in attrs will be set to the node,
+ when the setter of the node is available,
+ the property will be set via setter function.
+ !#zh 属性配置函数。在 attrs 的所有属性将被设置为节点属性。 + @param attrs Properties to be set to node + + @example + ```js + var attrs = { key: 0, num: 100 }; + node.attr(attrs); + ``` + */ + attr(attrs: any): void; + /** + !#en Returns a child from the container given its uuid. + !#zh 通过 uuid 获取节点的子节点。 + @param uuid The uuid to find the child node. + + @example + ```js + var child = node.getChildByUuid(uuid); + ``` + */ + getChildByUuid(uuid: string): Node; + /** + !#en Returns a child from the container given its name. + !#zh 通过名称获取节点的子节点。 + @param name A name to find the child node. + + @example + ```js + var child = node.getChildByName("Test Node"); + ``` + */ + getChildByName(name: string): Node; + /** + !#en + Inserts a child to the node at a specified index. + !#zh + 插入子节点到指定位置 + @param child the child node to be inserted + @param siblingIndex the sibling index to place the child in + + @example + ```js + node.insertChild(child, 2); + ``` + */ + insertChild(child: Node, siblingIndex: number): void; + /** + !#en Get the sibling index. + !#zh 获取同级索引。 + + @example + ```js + var index = node.getSiblingIndex(); + ``` + */ + getSiblingIndex(): number; + /** + !#en Set the sibling index of this node. + !#zh 设置节点同级索引。 + @param index index + + @example + ```js + node.setSiblingIndex(1); + ``` + */ + setSiblingIndex(index: number): void; + /** + !#en Walk though the sub children tree of the current node. + Each node, including the current node, in the sub tree will be visited two times, before all children and after all children. + This function call is not recursive, it's based on stack. + Please don't walk any other node inside the walk process. + !#zh 遍历该节点的子树里的所有节点并按规则执行回调函数。 + 对子树中的所有节点,包含当前节点,会执行两次回调,prefunc 会在访问它的子节点之前调用,postfunc 会在访问所有子节点之后调用。 + 这个函数的实现不是基于递归的,而是基于栈展开递归的方式。 + 请不要在 walk 过程中对任何其他的节点嵌套执行 walk。 + @param prefunc The callback to process node when reach the node for the first time + @param postfunc The callback to process node when re-visit the node after walked all children in its sub tree + + @example + ```js + node.walk(function (target) { + console.log('Walked through node ' + target.name + ' for the first time'); + }, function (target) { + console.log('Walked through node ' + target.name + ' after walked all children in its sub tree'); + }); + ``` + */ + walk(prefunc: (target: _BaseNode) => void, postfunc: (target: _BaseNode) => void): void; + /** + !#en + Remove itself from its parent node. If cleanup is `true`, then also remove all events and actions.
+ If the cleanup parameter is not passed, it will force a cleanup, so it is recommended that you always pass in the `false` parameter when calling this API.
+ If the node orphan, then nothing happens. + !#zh + 从父节点中删除该节点。如果不传入 cleanup 参数或者传入 `true`,那么这个节点上所有绑定的事件、action 都会被删除。
+ 因此建议调用这个 API 时总是传入 `false` 参数。
+ 如果这个节点是一个孤节点,那么什么都不会发生。 + @param cleanup true if all actions and callbacks on this node should be removed, false otherwise. + + @example + ```js + node.removeFromParent(); + node.removeFromParent(false); + ``` + */ + removeFromParent(cleanup?: boolean): void; + /** + !#en + Removes a child from the container. It will also cleanup all running actions depending on the cleanup parameter.

+ If the cleanup parameter is not passed, it will force a cleanup.
+ "remove" logic MUST only be on this method
+ If a class wants to extend the 'removeChild' behavior it only needs
+ to override this method. + !#zh + 移除节点中指定的子节点,是否需要清理所有正在运行的行为取决于 cleanup 参数。
+ 如果 cleanup 参数不传入,默认为 true 表示清理。
+ @param child The child node which will be removed. + @param cleanup true if all running actions and callbacks on the child node will be cleanup, false otherwise. + + @example + ```js + node.removeChild(newNode); + node.removeChild(newNode, false); + ``` + */ + removeChild(child: Node, cleanup?: boolean): void; + /** + !#en + Removes all children from the container and do a cleanup all running actions depending on the cleanup parameter.
+ If the cleanup parameter is not passed, it will force a cleanup. + !#zh + 移除节点所有的子节点,是否需要清理所有正在运行的行为取决于 cleanup 参数。
+ 如果 cleanup 参数不传入,默认为 true 表示清理。 + @param cleanup true if all running actions on all children nodes should be cleanup, false otherwise. + + @example + ```js + node.removeAllChildren(); + node.removeAllChildren(false); + ``` + */ + removeAllChildren(cleanup?: boolean): void; + /** + !#en Is this node a child of the given node? + !#zh 是否是指定节点的子节点? + @param parent parent + + @example + ```js + node.isChildOf(newNode); + ``` + */ + isChildOf(parent: Node): boolean; + /** + !#en + Returns the component of supplied type if the node has one attached, null if it doesn't.
+ You can also get component in the node by passing in the name of the script. + !#zh + 获取节点上指定类型的组件,如果节点有附加指定类型的组件,则返回,如果没有则为空。
+ 传入参数也可以是脚本的名称。 + @param typeOrClassName typeOrClassName + + @example + ```js + // get sprite component + var sprite = node.getComponent(cc.Sprite); + // get custom test class + var test = node.getComponent("Test"); + ``` + */ + getComponent(type: {prototype: T}): T; + getComponent(className: string): any; + /** + !#en Returns all components of supplied type in the node. + !#zh 返回节点上指定类型的所有组件。 + @param typeOrClassName typeOrClassName + + @example + ```js + var sprites = node.getComponents(cc.Sprite); + var tests = node.getComponents("Test"); + ``` + */ + getComponents(type: {prototype: T}): T[]; + getComponents(className: string): any[]; + /** + !#en Returns the component of supplied type in any of its children using depth first search. + !#zh 递归查找所有子节点中第一个匹配指定类型的组件。 + @param typeOrClassName typeOrClassName + + @example + ```js + var sprite = node.getComponentInChildren(cc.Sprite); + var Test = node.getComponentInChildren("Test"); + ``` + */ + getComponentInChildren(type: {prototype: T}): T; + getComponentInChildren(className: string): any; + /** + !#en Returns all components of supplied type in self or any of its children. + !#zh 递归查找自身或所有子节点中指定类型的组件 + @param typeOrClassName typeOrClassName + + @example + ```js + var sprites = node.getComponentsInChildren(cc.Sprite); + var tests = node.getComponentsInChildren("Test"); + ``` + */ + getComponentsInChildren(type: {prototype: T}): T[]; + getComponentsInChildren(className: string): any[]; + /** + !#en Adds a component class to the node. You can also add component to node by passing in the name of the script. + !#zh 向节点添加一个指定类型的组件类,你还可以通过传入脚本的名称来添加组件。 + @param typeOrClassName The constructor or the class name of the component to add + + @example + ```js + var sprite = node.addComponent(cc.Sprite); + var test = node.addComponent("Test"); + ``` + */ + addComponent(type: {new(): T}): T; + addComponent(className: string): any; + /** + !#en + Removes a component identified by the given name or removes the component object given. + You can also use component.destroy() if you already have the reference. + !#zh + 删除节点上的指定组件,传入参数可以是一个组件构造函数或组件名,也可以是已经获得的组件引用。 + 如果你已经获得组件引用,你也可以直接调用 component.destroy() + @param component The need remove component. + + @example + ```js + node.removeComponent(cc.Sprite); + var Test = require("Test"); + node.removeComponent(Test); + ``` + */ + removeComponent(component: string|Function|Component): void; + /** + !#en + Destroy all children from the node, and release all their own references to other objects.
+ Actual destruct operation will delayed until before rendering. + !#zh + 销毁所有子节点,并释放所有它们对其它对象的引用。
+ 实际销毁操作会延迟到当前帧渲染前执行。 + + @example + ```js + node.destroyAllChildren(); + ``` + */ + destroyAllChildren(): void; + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en + Register an callback of a specific event type on the EventTarget. + This type of event should be triggered via `emit`. + !#zh + 注册事件目标的特定事件类型回调。这种类型的事件应该被 `emit` 触发。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, node); + ``` + */ + on(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. + !#zh + 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + + @example + ```js + // register fire eventListener + var callback = eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, target); + // remove fire event listener + eventTarget.off('fire', callback, target); + // remove all fire event listeners + eventTarget.off('fire'); + ``` + */ + off(type: string, callback?: Function, target?: any): void; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.once('fire', function () { + cc.log("this is the callback and will be invoked only once"); + }, node); + ``` + */ + once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; + /** + !#en + Send an event with the event object. + !#zh + 通过事件对象派发事件 + @param event event + */ + dispatchEvent(event: Event): void; + /** + !#en + Destroy all callbackInfos. + !#zh + 销毁记录的事件 + */ + clear(): void; + } + /** !#en + Helper class for setting material blend function. + !#zh + 设置材质混合模式的辅助类。 */ + export class BlendFunc { + /** !#en specify the source Blend Factor, this will generate a custom material object, please pay attention to the memory cost. + !#zh 指定原图的混合模式,这会克隆一个新的材质对象,注意这带来的开销 */ + srcBlendFactor: macro.BlendFactor; + /** !#en specify the destination Blend Factor. + !#zh 指定目标的混合模式 */ + dstBlendFactor: macro.BlendFactor; + } + /** An internal helper class for switching render component's material between normal sprite material and gray sprite material. */ + export class GraySpriteState { + /** !#en The normal material. + !#zh 正常状态的材质。 */ + normalMaterial: Material; + /** !#en The gray material. + !#zh 置灰状态的材质。 */ + grayMaterial: Material; + } + /** misc utilities */ + export class misc { + /** + !#en Clamp a value between from and to. + !#zh + 限定浮点数的最大最小值。
+ 数值大于 max_inclusive 则返回 max_inclusive。
+ 数值小于 min_inclusive 则返回 min_inclusive。
+ 否则返回自身。 + @param value value + @param min_inclusive min_inclusive + @param max_inclusive max_inclusive + + @example + ```js + var v1 = cc.misc.clampf(20, 0, 20); // 20; + var v2 = cc.misc.clampf(-1, 0, 20); // 0; + var v3 = cc.misc.clampf(10, 0, 20); // 10; + ``` + */ + static clampf(value: number, min_inclusive: number, max_inclusive: number): number; + /** + !#en Clamp a value between 0 and 1. + !#zh 限定浮点数的取值范围为 0 ~ 1 之间。 + @param value value + + @example + ```js + var v1 = cc.misc.clamp01(20); // 1; + var v2 = cc.misc.clamp01(-1); // 0; + var v3 = cc.misc.clamp01(0.5); // 0.5; + ``` + */ + static clamp01(value: number): number; + /** + Linear interpolation between 2 numbers, the ratio sets how much it is biased to each end + @param a number A + @param b number B + @param r ratio between 0 and 1 + + @example + ```js + ---- + lerp + cc.misc.lerp(2,10,0.5)//returns 6 + cc.misc.lerp(2,10,0.2)//returns 3.6 + + ``` + */ + static lerp(a: number, b: number, r: number): number; + /** + converts degrees to radians + @param angle angle + */ + static degreesToRadians(angle: number): number; + /** + converts radians to degrees + @param angle angle + */ + static radiansToDegrees(angle: number): number; + } + /** !#en The renderer object which provide access to render system APIs, + detailed APIs will be available progressively. + !#zh 提供基础渲染接口的渲染器对象,渲染层的基础接口将逐步开放给用户 */ + export class renderer { + /** !#en The render engine is available only after cc.game.EVENT_ENGINE_INITED event.
+ Normally it will be inited as the webgl render engine, but in wechat open context domain, + it will be inited as the canvas render engine. Canvas render engine is no longer available for other use case since v2.0. + !#zh 基础渲染引擎对象只在 cc.game.EVENT_ENGINE_INITED 事件触发后才可获取。
+ 大多数情况下,它都会是 WebGL 渲染引擎实例,但是在微信开放数据域当中,它会是 Canvas 渲染引擎实例。请注意,从 2.0 开始,我们在其他平台和环境下都废弃了 Canvas 渲染器。 */ + static renderEngine: any; + /** !#en The total draw call count in last rendered frame. + !#zh 上一次渲染帧所提交的渲染批次总数。 */ + static drawCalls: number; + } + /** !#en the device accelerometer reports values for each axis in units of g-force. + !#zh 设备重力传感器传递的各个轴的数据。 */ + export class constructor { + /** + whether enable accelerometer event + @param isEnable isEnable + */ + setAccelerometerEnabled(isEnable: boolean): void; + /** + set accelerometer interval value + @param interval interval + */ + setAccelerometerInterval(interval: number): void; + } + /** undefined */ + export enum VerticalTextAlignment { + TOP = 0, + CENTER = 0, + BOTTOM = 0, + } + /** The base class of most of all the objects in Fireball. */ + export class Object { + /** !#en The name of the object. + !#zh 该对象的名称。 */ + name: string; + /** !#en + Indicates whether the object is not yet destroyed. (It will not be available after being destroyed)
+ When an object's `destroy` is called, it is actually destroyed after the end of this frame. + So `isValid` will return false from the next frame, while `isValid` in the current frame will still be true. + If you want to determine whether the current frame has called `destroy`, use `cc.isValid(obj, true)`, + but this is often caused by a particular logical requirements, which is not normally required. + + !#zh + 表示该对象是否可用(被 destroy 后将不可用)。
+ 当一个对象的 `destroy` 调用以后,会在这一帧结束后才真正销毁。因此从下一帧开始 `isValid` 就会返回 false,而当前帧内 `isValid` 仍然会是 true。如果希望判断当前帧是否调用过 `destroy`,请使用 `cc.isValid(obj, true)`,不过这往往是特殊的业务需求引起的,通常情况下不需要这样。 */ + isValid: boolean; + /** + !#en + Destroy this Object, and release all its own references to other objects.
+ Actual object destruction will delayed until before rendering. + From the next frame, this object is not usable anymore. + You can use `cc.isValid(obj)` to check whether the object is destroyed before accessing it. + !#zh + 销毁该对象,并释放所有它对其它对象的引用。
+ 实际销毁操作会延迟到当前帧渲染前执行。从下一帧开始,该对象将不再可用。 + 您可以在访问对象之前使用 `cc.isValid(obj)` 来检查对象是否已被销毁。 + + @example + ```js + obj.destroy(); + ``` + */ + destroy(): boolean; + } + /** Bit mask that controls object states. */ + export enum Flags { + DontSave = 0, + EditorOnly = 0, + HideInHierarchy = 0, + } + /** System variables */ + export class sys { + /** English language code */ + static LANGUAGE_ENGLISH: string; + /** Chinese language code */ + static LANGUAGE_CHINESE: string; + /** French language code */ + static LANGUAGE_FRENCH: string; + /** Italian language code */ + static LANGUAGE_ITALIAN: string; + /** German language code */ + static LANGUAGE_GERMAN: string; + /** Spanish language code */ + static LANGUAGE_SPANISH: string; + /** Spanish language code */ + static LANGUAGE_DUTCH: string; + /** Russian language code */ + static LANGUAGE_RUSSIAN: string; + /** Korean language code */ + static LANGUAGE_KOREAN: string; + /** Japanese language code */ + static LANGUAGE_JAPANESE: string; + /** Hungarian language code */ + static LANGUAGE_HUNGARIAN: string; + /** Portuguese language code */ + static LANGUAGE_PORTUGUESE: string; + /** Arabic language code */ + static LANGUAGE_ARABIC: string; + /** Norwegian language code */ + static LANGUAGE_NORWEGIAN: string; + /** Polish language code */ + static LANGUAGE_POLISH: string; + /** Turkish language code */ + static LANGUAGE_TURKISH: string; + /** Ukrainian language code */ + static LANGUAGE_UKRAINIAN: string; + /** Romanian language code */ + static LANGUAGE_ROMANIAN: string; + /** Bulgarian language code */ + static LANGUAGE_BULGARIAN: string; + /** Unknown language code */ + static LANGUAGE_UNKNOWN: string; + static OS_IOS: string; + static OS_ANDROID: string; + static OS_WINDOWS: string; + static OS_MARMALADE: string; + static OS_LINUX: string; + static OS_BADA: string; + static OS_BLACKBERRY: string; + static OS_OSX: string; + static OS_WP8: string; + static OS_WINRT: string; + static OS_UNKNOWN: string; + static UNKNOWN: number; + static WIN32: number; + static LINUX: number; + static MACOS: number; + static ANDROID: number; + static IPHONE: number; + static IPAD: number; + static BLACKBERRY: number; + static NACL: number; + static EMSCRIPTEN: number; + static TIZEN: number; + static WINRT: number; + static WP8: number; + static MOBILE_BROWSER: number; + static DESKTOP_BROWSER: number; + /** Indicates whether executes in editor's window process (Electron's renderer context) */ + static EDITOR_PAGE: number; + /** Indicates whether executes in editor's main process (Electron's browser context) */ + static EDITOR_CORE: number; + static WECHAT_GAME: number; + static QQ_PLAY: number; + static FB_PLAYABLE_ADS: number; + static BAIDU_GAME: number; + static VIVO_GAME: number; + static OPPO_GAME: number; + static HUAWEI_GAME: number; + static XIAOMI_GAME: number; + static JKW_GAME: number; + static ALIPAY_GAME: number; + static WECHAT_GAME_SUB: number; + static BAIDU_GAME_SUB: number; + static QTT_GAME: number; + static BYTEDANCE_GAME: number; + static BYTEDANCE_GAME_SUB: number; + static LINKSURE: number; + /** BROWSER_TYPE_WECHAT */ + static BROWSER_TYPE_WECHAT: string; + static BROWSER_TYPE_ANDROID: string; + static BROWSER_TYPE_IE: string; + static BROWSER_TYPE_EDGE: string; + static BROWSER_TYPE_QQ: string; + static BROWSER_TYPE_MOBILE_QQ: string; + static BROWSER_TYPE_UC: string; + /** uc third party integration. */ + static BROWSER_TYPE_UCBS: string; + static BROWSER_TYPE_360: string; + static BROWSER_TYPE_BAIDU_APP: string; + static BROWSER_TYPE_BAIDU: string; + static BROWSER_TYPE_MAXTHON: string; + static BROWSER_TYPE_OPERA: string; + static BROWSER_TYPE_OUPENG: string; + static BROWSER_TYPE_MIUI: string; + static BROWSER_TYPE_FIREFOX: string; + static BROWSER_TYPE_SAFARI: string; + static BROWSER_TYPE_CHROME: string; + static BROWSER_TYPE_LIEBAO: string; + static BROWSER_TYPE_QZONE: string; + static BROWSER_TYPE_SOUGOU: string; + static BROWSER_TYPE_HUAWEI: string; + static BROWSER_TYPE_UNKNOWN: string; + /** Is native ? This is set to be true in jsb auto. */ + static isNative: boolean; + /** Is web browser ? */ + static isBrowser: boolean; + /** + Is webgl extension support? + @param name name + */ + static glExtension(name: any): boolean; + /** + Get max joint matrix size for skinned mesh renderer. + */ + static getMaxJointMatrixSize(): void; + /** + !#en + Returns the safe area of the screen (in design resolution). If the screen is not notched, the visibleRect will be returned by default. + Currently supports Android, iOS and WeChat Mini Game platform. + !#zh + 返回手机屏幕安全区域(设计分辨率为单位),如果不是异形屏将默认返回 visibleRect。目前支持安卓、iOS 原生平台和微信小游戏平台。 + */ + static getSafeAreaRect(): Rect; + /** Indicate whether system is mobile system */ + static isMobile: boolean; + /** Indicate the running platform */ + static platform: number; + /** Get current language iso 639-1 code. + Examples of valid language codes include "zh-tw", "en", "en-us", "fr", "fr-fr", "es-es", etc. + The actual value totally depends on results provided by destination platform. */ + static languageCode: string; + /** Indicate the current language of the running system */ + static language: string; + /** Indicate the running os name */ + static os: string; + /** Indicate the running os version */ + static osVersion: string; + /** Indicate the running os main version */ + static osMainVersion: number; + /** Indicate the running browser type */ + static browserType: string|void; + /** Indicate the running browser version */ + static browserVersion: string|void; + /** Indicate the real pixel resolution of the whole game window */ + static windowPixelResolution: Size; + /** cc.sys.localStorage is a local storage component. */ + static localStorage: any; + /** The capabilities of the current platform */ + static capabilities: any; + /** + !#en + Get the network type of current device, return cc.sys.NetworkType.LAN if failure. + !#zh + 获取当前设备的网络类型, 如果网络类型无法获取,默认将返回 cc.sys.NetworkType.LAN + */ + static getNetworkType(): sys.NetworkType; + /** + !#en + Get the battery level of current device, return 1.0 if failure. + !#zh + 获取当前设备的电池电量,如果电量无法获取,默认将返回 1 + */ + static getBatteryLevel(): number; + /** + Forces the garbage collection, only available in JSB + */ + static garbageCollect(): void; + /** + Restart the JS VM, only available in JSB + */ + static restartVM(): void; + /** + Check whether an object is valid, + In web engine, it will return true if the object exist + In native engine, it will return true if the JS object and the correspond native object are both valid + @param obj obj + */ + static isObjectValid(obj: any): boolean; + /** + Dump system informations + */ + static dump(): void; + /** + Open a url in browser + @param url url + */ + static openURL(url: string): void; + /** + Get the number of milliseconds elapsed since 1 January 1970 00:00:00 UTC. + */ + static now(): number; + } + /** The fullscreen API provides an easy way for web content to be presented using the user's entire screen. + It's invalid on safari, QQbrowser and android browser */ + export class screen { + /** + initialize + */ + init(): void; + /** + return true if it's full now. + */ + fullScreen(): boolean; + /** + change the screen to full mode. + @param element element + @param onFullScreenChange onFullScreenChange + @param onFullScreenError onFullScreenError + */ + requestFullScreen(element: Element, onFullScreenChange: Function, onFullScreenError: Function): void; + /** + exit the full mode. + */ + exitFullScreen(): boolean; + /** + Automatically request full screen with a touch/click event + @param element element + @param onFullScreenChange onFullScreenChange + */ + autoFullScreen(element: Element, onFullScreenChange: Function): void; + } + /** cc.view is the singleton object which represents the game window.
+ It's main task include:
+ - Apply the design resolution policy
+ - Provide interaction with the window, like resize event on web, retina display support, etc...
+ - Manage the game view port which can be different with the window
+ - Manage the content scale and translation
+
+ Since the cc.view is a singleton, you don't need to call any constructor or create functions,
+ the standard way to use it is by calling:
+ - cc.view.methodName();
*/ + export class View extends EventTarget { + /** + !#en + Sets view's target-densitydpi for android mobile browser. it can be set to:
+ 1. cc.macro.DENSITYDPI_DEVICE, value is "device-dpi"
+ 2. cc.macro.DENSITYDPI_HIGH, value is "high-dpi" (default value)
+ 3. cc.macro.DENSITYDPI_MEDIUM, value is "medium-dpi" (browser's default value)
+ 4. cc.macro.DENSITYDPI_LOW, value is "low-dpi"
+ 5. Custom value, e.g: "480"
+ !#zh 设置目标内容的每英寸像素点密度。 + @param densityDPI densityDPI + */ + setTargetDensityDPI(densityDPI: string): void; + /** + !#en + Returns the current target-densitydpi value of cc.view. + !#zh 获取目标内容的每英寸像素点密度。 + */ + getTargetDensityDPI(): string; + /** + !#en + Sets whether resize canvas automatically when browser's size changed.
+ Useful only on web. + !#zh 设置当发现浏览器的尺寸改变时,是否自动调整 canvas 尺寸大小。 + 仅在 Web 模式下有效。 + @param enabled Whether enable automatic resize with browser's resize event + */ + resizeWithBrowserSize(enabled: boolean): void; + /** + !#en + Sets the callback function for cc.view's resize action,
+ this callback will be invoked before applying resolution policy,
+ so you can do any additional modifications within the callback.
+ Useful only on web. + !#zh 设置 cc.view 调整视窗尺寸行为的回调函数, + 这个回调函数会在应用适配模式之前被调用, + 因此你可以在这个回调函数内添加任意附加改变, + 仅在 Web 平台下有效。 + @param callback The callback function + */ + setResizeCallback(callback: Function|void): void; + /** + !#en + Sets the orientation of the game, it can be landscape, portrait or auto. + When set it to landscape or portrait, and screen w/h ratio doesn't fit, + cc.view will automatically rotate the game canvas using CSS. + Note that this function doesn't have any effect in native, + in native, you need to set the application orientation in native project settings + !#zh 设置游戏屏幕朝向,它能够是横版,竖版或自动。 + 当设置为横版或竖版,并且屏幕的宽高比例不匹配时, + cc.view 会自动用 CSS 旋转游戏场景的 canvas, + 这个方法不会对 native 部分产生任何影响,对于 native 而言,你需要在应用设置中的设置排版。 + @param orientation Possible values: cc.macro.ORIENTATION_LANDSCAPE | cc.macro.ORIENTATION_PORTRAIT | cc.macro.ORIENTATION_AUTO + */ + setOrientation(orientation: number): void; + /** + !#en + Sets whether the engine modify the "viewport" meta in your web page.
+ It's enabled by default, we strongly suggest you not to disable it.
+ And even when it's enabled, you can still set your own "viewport" meta, it won't be overridden
+ Only useful on web + !#zh 设置引擎是否调整 viewport meta 来配合屏幕适配。 + 默认设置为启动,我们强烈建议你不要将它设置为关闭。 + 即使当它启动时,你仍然能够设置你的 viewport meta,它不会被覆盖。 + 仅在 Web 模式下有效 + @param enabled Enable automatic modification to "viewport" meta + */ + adjustViewportMeta(enabled: boolean): void; + /** + !#en + Retina support is enabled by default for Apple device but disabled for other devices,
+ it takes effect only when you called setDesignResolutionPolicy
+ Only useful on web + !#zh 对于 Apple 这种支持 Retina 显示的设备上默认进行优化而其他类型设备默认不进行优化, + 它仅会在你调用 setDesignResolutionPolicy 方法时有影响。 + 仅在 Web 模式下有效。 + @param enabled Enable or disable retina display + */ + enableRetina(enabled: boolean): void; + /** + !#en + Check whether retina display is enabled.
+ Only useful on web + !#zh 检查是否对 Retina 显示设备进行优化。 + 仅在 Web 模式下有效。 + */ + isRetinaEnabled(): boolean; + /** + !#en Whether to Enable on anti-alias + !#zh 控制抗锯齿是否开启 + @param enabled Enable or not anti-alias + */ + enableAntiAlias(enabled: boolean): void; + /** + !#en Returns whether the current enable on anti-alias + !#zh 返回当前是否抗锯齿 + */ + isAntiAliasEnabled(): boolean; + /** + !#en + If enabled, the application will try automatically to enter full screen mode on mobile devices
+ You can pass true as parameter to enable it and disable it by passing false.
+ Only useful on web + !#zh 启动时,移动端游戏会在移动端自动尝试进入全屏模式。 + 你能够传入 true 为参数去启动它,用 false 参数来关闭它。 + @param enabled Enable or disable auto full screen on mobile devices + */ + enableAutoFullScreen(enabled: boolean): void; + /** + !#en + Check whether auto full screen is enabled.
+ Only useful on web + !#zh 检查自动进入全屏模式是否启动。 + 仅在 Web 模式下有效。 + */ + isAutoFullScreenEnabled(): boolean; + /** + !#en + Returns the canvas size of the view.
+ On native platforms, it returns the screen size since the view is a fullscreen view.
+ On web, it returns the size of the canvas element. + !#zh 返回视图中 canvas 的尺寸。 + 在 native 平台下,它返回全屏视图下屏幕的尺寸。 + 在 Web 平台下,它返回 canvas 元素尺寸。 + */ + getCanvasSize(): Size; + /** + !#en + Returns the frame size of the view.
+ On native platforms, it returns the screen size since the view is a fullscreen view.
+ On web, it returns the size of the canvas's outer DOM element. + !#zh 返回视图中边框尺寸。 + 在 native 平台下,它返回全屏视图下屏幕的尺寸。 + 在 web 平台下,它返回 canvas 元素的外层 DOM 元素尺寸。 + */ + getFrameSize(): Size; + /** + !#en + On native, it sets the frame size of view.
+ On web, it sets the size of the canvas's outer DOM element. + !#zh 在 native 平台下,设置视图框架尺寸。 + 在 web 平台下,设置 canvas 外层 DOM 元素尺寸。 + @param width width + @param height height + */ + setFrameSize(width: number, height: number): void; + /** + !#en + Returns the visible area size of the view port. + !#zh 返回视图窗口可见区域尺寸。 + */ + getVisibleSize(): Size; + /** + !#en + Returns the visible area size of the view port. + !#zh 返回视图窗口可见区域像素尺寸。 + */ + getVisibleSizeInPixel(): Size; + /** + !#en + Returns the visible origin of the view port. + !#zh 返回视图窗口可见区域原点。 + */ + getVisibleOrigin(): Vec2; + /** + !#en + Returns the visible origin of the view port. + !#zh 返回视图窗口可见区域像素原点。 + */ + getVisibleOriginInPixel(): Vec2; + /** + !#en + Returns the current resolution policy + !#zh 返回当前分辨率方案 + */ + getResolutionPolicy(): ResolutionPolicy; + /** + !#en + Sets the current resolution policy + !#zh 设置当前分辨率模式 + @param resolutionPolicy resolutionPolicy + */ + setResolutionPolicy(resolutionPolicy: ResolutionPolicy|number): void; + /** + !#en + Sets the resolution policy with designed view size in points.
+ The resolution policy include:
+ [1] ResolutionExactFit Fill screen by stretch-to-fit: if the design resolution ratio of width to height is different from the screen resolution ratio, your game view will be stretched.
+ [2] ResolutionNoBorder Full screen without black border: if the design resolution ratio of width to height is different from the screen resolution ratio, two areas of your game view will be cut.
+ [3] ResolutionShowAll Full screen with black border: if the design resolution ratio of width to height is different from the screen resolution ratio, two black borders will be shown.
+ [4] ResolutionFixedHeight Scale the content's height to screen's height and proportionally scale its width
+ [5] ResolutionFixedWidth Scale the content's width to screen's width and proportionally scale its height
+ [cc.ResolutionPolicy] [Web only feature] Custom resolution policy, constructed by cc.ResolutionPolicy
+ !#zh 通过设置设计分辨率和匹配模式来进行游戏画面的屏幕适配。 + @param width Design resolution width. + @param height Design resolution height. + @param resolutionPolicy The resolution policy desired + */ + setDesignResolutionSize(width: number, height: number, resolutionPolicy: ResolutionPolicy|number): void; + /** + !#en + Returns the designed size for the view. + Default resolution size is the same as 'getFrameSize'. + !#zh 返回视图的设计分辨率。 + 默认下分辨率尺寸同 `getFrameSize` 方法相同 + */ + getDesignResolutionSize(): Size; + /** + !#en + Sets the container to desired pixel resolution and fit the game content to it. + This function is very useful for adaptation in mobile browsers. + In some HD android devices, the resolution is very high, but its browser performance may not be very good. + In this case, enabling retina display is very costy and not suggested, and if retina is disabled, the image may be blurry. + But this API can be helpful to set a desired pixel resolution which is in between. + This API will do the following: + 1. Set viewport's width to the desired width in pixel + 2. Set body width to the exact pixel resolution + 3. The resolution policy will be reset with designed view size in points. + !#zh 设置容器(container)需要的像素分辨率并且适配相应分辨率的游戏内容。 + @param width Design resolution width. + @param height Design resolution height. + @param resolutionPolicy The resolution policy desired + */ + setRealPixelResolution(width: number, height: number, resolutionPolicy: ResolutionPolicy|number): void; + /** + !#en + Sets view port rectangle with points. + !#zh 用设计分辨率下的点尺寸来设置视窗。 + @param x x + @param y y + @param w width + @param h height + */ + setViewportInPoints(x: number, y: number, w: number, h: number): void; + /** + !#en + Sets Scissor rectangle with points. + !#zh 用设计分辨率下的点的尺寸来设置 scissor 剪裁区域。 + @param x x + @param y y + @param w w + @param h h + */ + setScissorInPoints(x: number, y: number, w: number, h: number): void; + /** + !#en + Returns whether GL_SCISSOR_TEST is enable + !#zh 检查 scissor 是否生效。 + */ + isScissorEnabled(): boolean; + /** + !#en + Returns the current scissor rectangle + !#zh 返回当前的 scissor 剪裁区域。 + */ + getScissorRect(): Rect; + /** + !#en + Returns the view port rectangle. + !#zh 返回视窗剪裁区域。 + */ + getViewportRect(): Rect; + /** + !#en + Returns scale factor of the horizontal direction (X axis). + !#zh 返回横轴的缩放比,这个缩放比是将画布像素分辨率放到设计分辨率的比例。 + */ + getScaleX(): number; + /** + !#en + Returns scale factor of the vertical direction (Y axis). + !#zh 返回纵轴的缩放比,这个缩放比是将画布像素分辨率缩放到设计分辨率的比例。 + */ + getScaleY(): number; + /** + !#en + Returns device pixel ratio for retina display. + !#zh 返回设备或浏览器像素比例。 + */ + getDevicePixelRatio(): number; + /** + !#en + Returns the real location in view for a translation based on a related position + !#zh 将屏幕坐标转换为游戏视图下的坐标。 + @param tx The X axis translation + @param ty The Y axis translation + @param relatedPos The related position object including "left", "top", "width", "height" informations + */ + convertToLocationInView(tx: number, ty: number, relatedPos: any): Vec2; + } + /**

cc.game.containerStrategy class is the root strategy class of container's scale strategy, + it controls the behavior of how to scale the cc.game.container and cc.game.canvas object

*/ + export class ContainerStrategy { + /** + !#en + Manipulation before appling the strategy + !#zh 在应用策略之前的操作 + @param view The target view + */ + preApply(view: View): void; + /** + !#en + Function to apply this strategy + !#zh 策略应用方法 + @param view view + @param designedResolution designedResolution + */ + apply(view: View, designedResolution: Size): void; + /** + !#en + Manipulation after applying the strategy + !#zh 策略调用之后的操作 + @param view The target view + */ + postApply(view: View): void; + } + /**

cc.ContentStrategy class is the root strategy class of content's scale strategy, + it controls the behavior of how to scale the scene and setup the viewport for the game

*/ + export class ContentStrategy { + /** + !#en + Manipulation before applying the strategy + !#zh 策略应用前的操作 + @param view The target view + */ + preApply(view: View): void; + /** + !#en Function to apply this strategy + The return value is {scale: [scaleX, scaleY], viewport: {cc.Rect}}, + The target view can then apply these value to itself, it's preferred not to modify directly its private variables + !#zh 调用策略方法 + @param view view + @param designedResolution designedResolution + */ + apply(view: View, designedResolution: Size): any; + /** + !#en + Manipulation after applying the strategy + !#zh 策略调用之后的操作 + @param view The target view + */ + postApply(view: View): void; + } + /** undefined */ + export class EqualToFrame extends ContainerStrategy { + } + /** undefined */ + export class ProportionalToFrame extends ContainerStrategy { + } + /** undefined */ + export class EqualToWindow extends EqualToFrame { + } + /** undefined */ + export class ProportionalToWindow extends ProportionalToFrame { + } + /** undefined */ + export class OriginalContainer extends ContainerStrategy { + } + /**

cc.ResolutionPolicy class is the root strategy class of scale strategy, + its main task is to maintain the compatibility with Cocos2d-x

*/ + export class ResolutionPolicy { + /** + + @param containerStg The container strategy + @param contentStg The content strategy + */ + constructor(containerStg: ContainerStrategy, contentStg: ContentStrategy); + /** + !#en Manipulation before applying the resolution policy + !#zh 策略应用前的操作 + @param view The target view + */ + preApply(view: View): void; + /** + !#en Function to apply this resolution policy + The return value is {scale: [scaleX, scaleY], viewport: {cc.Rect}}, + The target view can then apply these value to itself, it's preferred not to modify directly its private variables + !#zh 调用策略方法 + @param view The target view + @param designedResolution The user defined design resolution + */ + apply(view: View, designedResolution: Size): any; + /** + !#en Manipulation after appyling the strategy + !#zh 策略应用之后的操作 + @param view The target view + */ + postApply(view: View): void; + /** + !#en + Setup the container's scale strategy + !#zh 设置容器的适配策略 + @param containerStg containerStg + */ + setContainerStrategy(containerStg: ContainerStrategy): void; + /** + !#en + Setup the content's scale strategy + !#zh 设置内容的适配策略 + @param contentStg contentStg + */ + setContentStrategy(contentStg: ContentStrategy): void; + /** The entire application is visible in the specified area without trying to preserve the original aspect ratio.
+ Distortion can occur, and the application may appear stretched or compressed. */ + static EXACT_FIT: number; + /** The entire application fills the specified area, without distortion but possibly with some cropping,
+ while maintaining the original aspect ratio of the application. */ + static NO_BORDER: number; + /** The entire application is visible in the specified area without distortion while maintaining the original
+ aspect ratio of the application. Borders can appear on two sides of the application. */ + static SHOW_ALL: number; + /** The application takes the height of the design resolution size and modifies the width of the internal
+ canvas so that it fits the aspect ratio of the device
+ no distortion will occur however you must make sure your application works on different
+ aspect ratios */ + static FIXED_HEIGHT: number; + /** The application takes the width of the design resolution size and modifies the height of the internal
+ canvas so that it fits the aspect ratio of the device
+ no distortion will occur however you must make sure your application works on different
+ aspect ratios */ + static FIXED_WIDTH: number; + /** Unknow policy */ + static UNKNOWN: number; + } + /** cc.visibleRect is a singleton object which defines the actual visible rect of the current view, + it should represent the same rect as cc.view.getViewportRect() */ + export class visibleRect { + /** + initialize + @param visibleRect visibleRect + */ + static init(visibleRect: Rect): void; + /** Top left coordinate of the screen related to the game scene. */ + static topLeft: Vec2; + /** Top right coordinate of the screen related to the game scene. */ + static topRight: Vec2; + /** Top center coordinate of the screen related to the game scene. */ + static top: Vec2; + /** Bottom left coordinate of the screen related to the game scene. */ + static bottomLeft: Vec2; + /** Bottom right coordinate of the screen related to the game scene. */ + static bottomRight: Vec2; + /** Bottom center coordinate of the screen related to the game scene. */ + static bottom: Vec2; + /** Center coordinate of the screen related to the game scene. */ + static center: Vec2; + /** Left center coordinate of the screen related to the game scene. */ + static left: Vec2; + /** Right center coordinate of the screen related to the game scene. */ + static right: Vec2; + /** Width of the screen. */ + static width: number; + /** Height of the screen. */ + static height: number; + } + /** !#en The callbacks invoker to handle and invoke callbacks by key. + !#zh CallbacksInvoker 用来根据 Key 管理并调用回调方法。 */ + export class CallbacksInvoker { + /** + !#zh + 检查指定事件是否已注册回调。 + !#en + Check if the specified key has any registered callback. If a callback is also specified, + it will only return true if the callback is registered. + @param key key + @param callback callback + @param target target + */ + hasEventListener(key: string, callback?: Function, target?: any): boolean; + /** + !#zh + 移除在特定事件类型中注册的所有回调或在某个目标中注册的所有回调。 + + !#en + Removes all callbacks registered in a certain event type or all callbacks registered with a certain target + @param keyOrTarget The event key to be removed or the target to be removed + */ + removeAll(keyOrTarget: string|any): void; + /** + !#zh + 删除之前与同类型,回调,目标注册的回调。 + @param key key + @param callback callback + @param target target + */ + off(key: string, callback: Function, target?: any): void; + /** + !#en + Trigger an event directly with the event name and necessary arguments. + !#zh + 通过事件名发送自定义事件 + @param key event type + @param arg1 First argument + @param arg2 Second argument + @param arg3 Third argument + @param arg4 Fourth argument + @param arg5 Fifth argument + + @example + ```js + eventTarget.emit('fire', event); + eventTarget.emit('fire', message, emitter); + ``` + */ + emit(key: string, arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any): void; + } + /** !#en Contains information collected during deserialization + !#zh 包含反序列化时的一些信息 */ + export class Details { + /** the obj list whose field needs to load asset by uuid */ + uuidObjList: any[]; + /** the corresponding field name which referenced to the asset */ + uuidPropList: (String|Number)[]; + /** list of the depends assets' uuid */ + uuidList: string[]; + /** + + @param data data + */ + init(data: any): void; + reset(): void; + /** + + @param obj obj + @param propName propName + @param uuid uuid + */ + push(obj: any, propName: string, uuid: string): void; + /** list of the depends assets' uuid */ + uuidList: string[]; + /** the obj list whose field needs to load asset by uuid */ + uuidObjList: any[]; + /** the corresponding field name which referenced to the asset */ + uuidPropList: string[]; + reset(): void; + /** + + @param obj obj + @param propName propName + @param uuid uuid + */ + push(obj: any, propName: string, uuid: string): void; + } + /** undefined */ + export class WorldManifold { + /** !#en + world contact point (point of intersection) + !#zh + 碰撞点集合 */ + points: Vec2[]; + /** !#en + world vector pointing from A to B + !#zh + 世界坐标系下由 A 指向 B 的向量 */ + normal: Vec2; + } + /** !#en + A manifold point is a contact point belonging to a contact manifold. + It holds details related to the geometry and dynamics of the contact points. + Note: the impulses are used for internal caching and may not + provide reliable contact forces, especially for high speed collisions. + !#zh + ManifoldPoint 是接触信息中的接触点信息。它拥有关于几何和接触点的详细信息。 + 注意:信息中的冲量用于系统内部缓存,提供的接触力可能不是很准确,特别是高速移动中的碰撞信息。 */ + export class ManifoldPoint { + /** !#en + The local point usage depends on the manifold type: + -e_circles: the local center of circleB + -e_faceA: the local center of circleB or the clip point of polygonB + -e_faceB: the clip point of polygonA + !#zh + 本地坐标点的用途取决于 manifold 的类型 + - e_circles: circleB 的本地中心点 + - e_faceA: circleB 的本地中心点 或者是 polygonB 的截取点 + - e_faceB: polygonB 的截取点 */ + localPoint: Vec2; + /** !#en + Normal impulse. + !#zh + 法线冲量。 */ + normalImpulse: number; + /** !#en + Tangent impulse. + !#zh + 切线冲量。 */ + tangentImpulse: number; + } + /** undefined */ + export class Manifold { + /** !#en + Manifold type : 0: e_circles, 1: e_faceA, 2: e_faceB + !#zh + Manifold 类型 : 0: e_circles, 1: e_faceA, 2: e_faceB */ + type: number; + /** !#en + The local point usage depends on the manifold type: + -e_circles: the local center of circleA + -e_faceA: the center of faceA + -e_faceB: the center of faceB + !#zh + 用途取决于 manifold 类型 + -e_circles: circleA 的本地中心点 + -e_faceA: faceA 的本地中心点 + -e_faceB: faceB 的本地中心点 */ + localPoint: Vec2; + /** !#en + -e_circles: not used + -e_faceA: the normal on polygonA + -e_faceB: the normal on polygonB + !#zh + -e_circles: 没被使用到 + -e_faceA: polygonA 的法向量 + -e_faceB: polygonB 的法向量 */ + localNormal: Vec2; + /** !#en + the points of contact. + !#zh + 接触点信息。 */ + points: ManifoldPoint[]; + } + /** !#en + Contact impulses for reporting. + !#zh + 用于返回给回调的接触冲量。 */ + export class PhysicsImpulse { + /** !#en + Normal impulses. + !#zh + 法线方向的冲量 */ + normalImpulses: any; + /** !#en + Tangent impulses + !#zh + 切线方向的冲量 */ + tangentImpulses: any; + } + /** !#en + PhysicsContact will be generated during begin and end collision as a parameter of the collision callback. + Note that contacts will be reused for speed up cpu time, so do not cache anything in the contact. + !#zh + 物理接触会在开始和结束碰撞之间生成,并作为参数传入到碰撞回调函数中。 + 注意:传入的物理接触会被系统进行重用,所以不要在使用中缓存里面的任何信息。 */ + export class PhysicsContact { + /** + !#en + Get the world manifold. + !#zh + 获取世界坐标系下的碰撞信息。 + */ + getWorldManifold(): WorldManifold; + /** + !#en + Get the manifold. + !#zh + 获取本地(局部)坐标系下的碰撞信息。 + */ + getManifold(): Manifold; + /** + !#en + Get the impulses. + Note: PhysicsImpulse can only used in onPostSolve callback. + !#zh + 获取冲量信息 + 注意:这个信息只有在 onPostSolve 回调中才能获取到 + */ + getImpulse(): PhysicsImpulse; + /** !#en + One of the collider that collided + !#zh + 发生碰撞的碰撞体之一 */ + colliderA: Collider; + /** !#en + One of the collider that collided + !#zh + 发生碰撞的碰撞体之一 */ + colliderB: Collider; + /** !#en + If set disabled to true, the contact will be ignored until contact end. + If you just want to disabled contact for current time step or sub-step, please use disabledOnce. + !#zh + 如果 disabled 被设置为 true,那么直到接触结束此接触都将被忽略。 + 如果只是希望在当前时间步或子步中忽略此接触,请使用 disabledOnce 。 */ + disabled: boolean; + /** !#en + Disabled contact for current time step or sub-step. + !#zh + 在当前时间步或子步中忽略此接触。 */ + disabledOnce: boolean; + /** + !#en + Is this contact touching? + !#zh + 返回碰撞体是否已经接触到。 + */ + isTouching(): boolean; + /** + !#en + Set the desired tangent speed for a conveyor belt behavior. + !#zh + 为传送带设置期望的切线速度 + @param tangentSpeed tangentSpeed + */ + setTangentSpeed(tangentSpeed: number): void; + /** + !#en + Get the desired tangent speed. + !#zh + 获取切线速度 + */ + getTangentSpeed(): number; + /** + !#en + Override the default friction mixture. You can call this in onPreSolve callback. + !#zh + 覆盖默认的摩擦力系数。你可以在 onPreSolve 回调中调用此函数。 + @param friction friction + */ + setFriction(friction: number): void; + /** + !#en + Get the friction. + !#zh + 获取当前摩擦力系数 + */ + getFriction(): number; + /** + !#en + Reset the friction mixture to the default value. + !#zh + 重置摩擦力系数到默认值 + */ + resetFriction(): void; + /** + !#en + Override the default restitution mixture. You can call this in onPreSolve callback. + !#zh + 覆盖默认的恢复系数。你可以在 onPreSolve 回调中调用此函数。 + @param restitution restitution + */ + setRestitution(restitution: number): void; + /** + !#en + Get the restitution. + !#zh + 获取当前恢复系数 + */ + getRestitution(): number; + /** + !#en + Reset the restitution mixture to the default value. + !#zh + 重置恢复系数到默认值 + */ + resetRestitution(): void; + } + /** !#en + Physics manager uses box2d as the inner physics system, and hide most box2d implement details(creating rigidbody, synchronize rigidbody info to node). + You can visit some common box2d function through physics manager(hit testing, raycast, debug info). + Physics manager distributes the collision information to each collision callback when collision is produced. + Note: You need first enable the collision listener in the rigidbody. + !#zh + 物理系统将 box2d 作为内部物理系统,并且隐藏了大部分 box2d 实现细节(比如创建刚体,同步刚体信息到节点中等)。 + 你可以通过物理系统访问一些 box2d 常用的功能,比如点击测试,射线测试,设置测试信息等。 + 物理系统还管理碰撞信息的分发,她会在产生碰撞时,将碰撞信息分发到各个碰撞回调中。 + 注意:你需要先在刚体中开启碰撞接听才会产生相应的碰撞回调。
+ 支持的物理系统指定绘制信息事件,请参阅 {{#crossLink "PhysicsManager.DrawBits"}}{{/crossLink}} */ + export class PhysicsManager implements EventTarget { + /** !#en + The ratio transform between physics unit and pixel unit, generally is 32. + !#zh + 物理单位与像素单位互相转换的比率,一般是 32。 */ + static PTM_RATIO: number; + /** !#en + The velocity iterations for the velocity constraint solver. + !#zh + 速度更新迭代数 */ + static VELOCITY_ITERATIONS: number; + /** !#en + The position Iterations for the position constraint solver. + !#zh + 位置迭代更新数 */ + static POSITION_ITERATIONS: number; + /** !#en + Specify the fixed time step. + Need enabledAccumulator to make it work. + !#zh + 指定固定的物理更新间隔时间,需要开启 enabledAccumulator 才有效。 */ + static FIXED_TIME_STEP: number; + /** !#en + Specify the max accumulator time. + Need enabledAccumulator to make it work. + !#zh + 每次可用于更新物理系统的最大时间,需要开启 enabledAccumulator 才有效。 */ + static MAX_ACCUMULATOR: number; + /** !#en + If enabled accumulator, then will call step function with the fixed time step FIXED_TIME_STEP. + And if the update dt is bigger than the time step, then will call step function several times. + If disabled accumulator, then will call step function with a time step calculated with the frame rate. + !#zh + 如果开启此选项,那么将会以固定的间隔时间 FIXED_TIME_STEP 来更新物理引擎,如果一个 update 的间隔时间大于 FIXED_TIME_STEP,则会对物理引擎进行多次更新。 + 如果关闭此选项,那么将会根据设定的 frame rate 计算出一个间隔时间来更新物理引擎。 */ + enabledAccumulator: boolean; + /** + !#en + Test which collider contains the given world point + !#zh + 获取包含给定世界坐标系点的碰撞体 + @param point the world point + */ + testPoint(point: Vec2): PhysicsCollider; + /** + !#en + Test which colliders intersect the given world rect + !#zh + 获取与给定世界坐标系矩形相交的碰撞体 + @param rect the world rect + */ + testAABB(rect: Rect): PhysicsCollider[]; + /** + !#en + Raycast the world for all colliders in the path of the ray. + The raycast ignores colliders that contain the starting point. + !#zh + 检测哪些碰撞体在给定射线的路径上,射线检测将忽略包含起始点的碰撞体。 + @param p1 start point of the raycast + @param p2 end point of the raycast + @param type optional, default is RayCastType.Closest + */ + rayCast(p1: Vec2, p2: Vec2, type: RayCastType): PhysicsRayCastResult[]; + /** !#en + Enabled the physics manager? + !#zh + 指定是否启用物理系统? */ + enabled: boolean; + /** !#en + Debug draw flags. + !#zh + 设置调试绘制标志 */ + debugDrawFlags: number; + /** !#en + The physics world gravity. + !#zh + 物理世界重力值 */ + gravity: Vec2; + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en + Register an callback of a specific event type on the EventTarget. + This type of event should be triggered via `emit`. + !#zh + 注册事件目标的特定事件类型回调。这种类型的事件应该被 `emit` 触发。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, node); + ``` + */ + on(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. + !#zh + 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + + @example + ```js + // register fire eventListener + var callback = eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, target); + // remove fire event listener + eventTarget.off('fire', callback, target); + // remove all fire event listeners + eventTarget.off('fire'); + ``` + */ + off(type: string, callback?: Function, target?: any): void; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.once('fire', function () { + cc.log("this is the callback and will be invoked only once"); + }, node); + ``` + */ + once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; + /** + !#en + Send an event with the event object. + !#zh + 通过事件对象派发事件 + @param event event + */ + dispatchEvent(event: Event): void; + /** + !#en + Destroy all callbackInfos. + !#zh + 销毁记录的事件 + */ + clear(): void; + } + /** undefined */ + export class PhysicsRayCastResult { + /** !#en + The PhysicsCollider which intersects with the raycast + !#zh + 与射线相交的碰撞体 */ + collider: PhysicsCollider; + /** !#en + The intersection point + !#zh + 射线与碰撞体相交的点 */ + point: Vec2; + /** !#en + The normal vector at the point of intersection + !#zh + 射线与碰撞体相交的点的法向量 */ + normal: Vec2; + /** !#en + The fraction of the raycast path at the point of intersection + !#zh + 射线与碰撞体相交的点占射线长度的分数 */ + fraction: number; + } + /** !#en Enum for RigidBodyType. + !#zh 刚体类型 */ + export enum RigidBodyType { + Static = 0, + Kinematic = 0, + Dynamic = 0, + Animated = 0, + } + /** !#en Enum for RayCastType. + !#zh 射线检测类型 */ + export enum RayCastType { + Closest = 0, + Any = 0, + AllClosest = 0, + All = 0, + } + /** undefined */ + export class RigidBody extends Component { + /** !#en + Should enabled contact listener? + When a collision is trigger, the collision callback will only be called when enabled contact listener. + !#zh + 是否启用接触接听器。 + 当 collider 产生碰撞时,只有开启了接触接听器才会调用相应的回调函数 */ + enabledContactListener: boolean; + /** + !#en + Collision callback. + Called when two collider begin to touch. + !#zh + 碰撞回调。 + 如果你的脚本中实现了这个函数,那么它将会在两个碰撞体开始接触时被调用。 + @param contact contact information + @param selfCollider the collider belong to this rigidbody + @param otherCollider the collider belong to another rigidbody + */ + onBeginContact(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void; + /** + !#en + Collision callback. + Called when two collider cease to touch. + !#zh + 碰撞回调。 + 如果你的脚本中实现了这个函数,那么它将会在两个碰撞体停止接触时被调用。 + @param contact contact information + @param selfCollider the collider belong to this rigidbody + @param otherCollider the collider belong to another rigidbody + */ + onEndContact(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void; + /** + !#en + Collision callback. + This is called when a contact is updated. + This allows you to inspect a contact before it goes to the solver(e.g. disable contact). + Note: this is called only for awake bodies. + Note: this is called even when the number of contact points is zero. + Note: this is not called for sensors. + !#zh + 碰撞回调。 + 如果你的脚本中实现了这个函数,那么它将会在接触更新时被调用。 + 你可以在接触被处理前根据他包含的信息作出相应的处理,比如将这个接触禁用掉。 + 注意:回调只会为醒着的刚体调用。 + 注意:接触点为零的时候也有可能被调用。 + 注意:感知体(sensor)的回调不会被调用。 + @param contact contact information + @param selfCollider the collider belong to this rigidbody + @param otherCollider the collider belong to another rigidbody + */ + onPreSolve(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void; + /** + !#en + Collision callback. + This is called after a contact is updated. + You can get the impulses from the contact in this callback. + !#zh + 碰撞回调。 + 如果你的脚本中实现了这个函数,那么它将会在接触更新完后被调用。 + 你可以在这个回调中从接触信息中获取到冲量信息。 + @param contact contact information + @param selfCollider the collider belong to this rigidbody + @param otherCollider the collider belong to another rigidbody + */ + onPostSolve(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void; + /** !#en + Is this a fast moving body that should be prevented from tunneling through + other moving bodies? + Note : + - All bodies are prevented from tunneling through kinematic and static bodies. This setting is only considered on dynamic bodies. + - You should use this flag sparingly since it increases processing time. + !#zh + 这个刚体是否是一个快速移动的刚体,并且需要禁止穿过其他快速移动的刚体? + 需要注意的是 : + - 所有刚体都被禁止从 运动刚体 和 静态刚体 中穿过。此选项只关注于 动态刚体。 + - 应该尽量少的使用此选项,因为它会增加程序处理时间。 */ + bullet: boolean; + /** !#en + Rigidbody type : Static, Kinematic, Dynamic or Animated. + !#zh + 刚体类型: Static, Kinematic, Dynamic or Animated. */ + type: RigidBodyType; + /** !#en + Set this flag to false if this body should never fall asleep. + Note that this increases CPU usage. + !#zh + 如果此刚体永远都不应该进入睡眠,那么设置这个属性为 false。 + 需要注意这将使 CPU 占用率提高。 */ + allowSleep: boolean; + /** !#en + Scale the gravity applied to this body. + !#zh + 缩放应用在此刚体上的重力值 */ + gravityScale: number; + /** !#en + Linear damping is use to reduce the linear velocity. + The damping parameter can be larger than 1, but the damping effect becomes sensitive to the + time step when the damping parameter is large. + !#zh + Linear damping 用于衰减刚体的线性速度。衰减系数可以大于 1,但是当衰减系数比较大的时候,衰减的效果会变得比较敏感。 */ + linearDamping: number; + /** !#en + Angular damping is use to reduce the angular velocity. The damping parameter + can be larger than 1 but the damping effect becomes sensitive to the + time step when the damping parameter is large. + !#zh + Angular damping 用于衰减刚体的角速度。衰减系数可以大于 1,但是当衰减系数比较大的时候,衰减的效果会变得比较敏感。 */ + angularDamping: number; + /** !#en + The linear velocity of the body's origin in world co-ordinates. + !#zh + 刚体在世界坐标下的线性速度 */ + linearVelocity: Vec2; + /** !#en + The angular velocity of the body. + !#zh + 刚体的角速度 */ + angularVelocity: number; + /** !#en + Should this body be prevented from rotating? + !#zh + 是否禁止此刚体进行旋转 */ + fixedRotation: boolean; + /** !#en + Set the sleep state of the body. A sleeping body has very low CPU cost.(When the rigid body is hit, if the rigid body is in sleep state, it will be immediately awakened.) + !#zh + 设置刚体的睡眠状态。 睡眠的刚体具有非常低的 CPU 成本。(当刚体被碰撞到时,如果刚体处于睡眠状态,它会立即被唤醒) */ + awake: boolean; + /** !#en + Whether to wake up this rigid body during initialization + !#zh + 是否在初始化时唤醒此刚体 */ + awakeOnLoad: boolean; + /** !#en + Set the active state of the body. An inactive body is not + simulated and cannot be collided with or woken up. + If body is active, all fixtures will be added to the + broad-phase. + If body is inactive, all fixtures will be removed from + the broad-phase and all contacts will be destroyed. + Fixtures on an inactive body are implicitly inactive and will + not participate in collisions, ray-casts, or queries. + Joints connected to an inactive body are implicitly inactive. + !#zh + 设置刚体的激活状态。一个非激活状态下的刚体是不会被模拟和碰撞的,不管它是否处于睡眠状态下。 + 如果刚体处于激活状态下,所有夹具会被添加到 粗测阶段(broad-phase)。 + 如果刚体处于非激活状态下,所有夹具会被从 粗测阶段(broad-phase)中移除。 + 在非激活状态下的夹具不会参与到碰撞,射线,或者查找中 + 链接到非激活状态下刚体的关节也是非激活的。 */ + active: boolean; + /** + !#en + Converts a given point in the world coordinate system to this rigid body's local coordinate system + !#zh + 将一个给定的世界坐标系下的点转换为刚体本地坐标系下的点 + @param worldPoint a point in world coordinates. + @param out optional, the receiving point + */ + getLocalPoint(worldPoint: Vec2, out: Vec2): Vec2; + /** + !#en + Converts a given point in this rigid body's local coordinate system to the world coordinate system + !#zh + 将一个给定的刚体本地坐标系下的点转换为世界坐标系下的点 + @param localPoint a point in local coordinates. + @param out optional, the receiving point + */ + getWorldPoint(localPoint: Vec2, out: Vec2): Vec2; + /** + !#en + Converts a given vector in this rigid body's local coordinate system to the world coordinate system + !#zh + 将一个给定的刚体本地坐标系下的向量转换为世界坐标系下的向量 + @param localVector a vector in world coordinates. + @param out optional, the receiving vector + */ + getWorldVector(localVector: Vec2, out: Vec2): Vec2; + /** + !#en + Converts a given vector in the world coordinate system to this rigid body's local coordinate system + !#zh + 将一个给定的世界坐标系下的向量转换为刚体本地坐标系下的向量 + @param worldVector a vector in world coordinates. + @param out optional, the receiving vector + */ + getLocalVector(worldVector: Vec2, out: Vec2): Vec2; + /** + !#en + Get the world body origin position. + !#zh + 获取刚体世界坐标系下的原点值 + @param out optional, the receiving point + */ + getWorldPosition(out: Vec2): Vec2; + /** + !#en + Get the world body rotation angle. + !#zh + 获取刚体世界坐标系下的旋转值。 + */ + getWorldRotation(): number; + /** + !#en + Get the local position of the center of mass. + !#zh + 获取刚体本地坐标系下的质心 + */ + getLocalCenter(): Vec2; + /** + !#en + Get the world position of the center of mass. + !#zh + 获取刚体世界坐标系下的质心 + */ + getWorldCenter(): Vec2; + /** + !#en + Get the world linear velocity of a world point attached to this body. + !#zh + 获取刚体上指定点的线性速度 + @param worldPoint a point in world coordinates. + @param out optional, the receiving point + */ + getLinearVelocityFromWorldPoint(worldPoint: Vec2, out: Vec2): Vec2; + /** + !#en + Get total mass of the body. + !#zh + 获取刚体的质量。 + */ + getMass(): number; + /** + !#en + Get the rotational inertia of the body about the local origin. + !#zh + 获取刚体本地坐标系下原点的旋转惯性 + */ + getInertia(): number; + /** + !#en + Get all the joints connect to the rigidbody. + !#zh + 获取链接到此刚体的所有关节 + */ + getJointList(): Joint[]; + /** + !#en + Apply a force at a world point. If the force is not + applied at the center of mass, it will generate a torque and + affect the angular velocity. + !#zh + 施加一个力到刚体上的一个点。如果力没有施加到刚体的质心上,还会产生一个扭矩并且影响到角速度。 + @param force the world force vector. + @param point the world position. + @param wake also wake up the body. + */ + applyForce(force: Vec2, point: Vec2, wake: boolean): void; + /** + !#en + Apply a force to the center of mass. + !#zh + 施加一个力到刚体上的质心上。 + @param force the world force vector. + @param wake also wake up the body. + */ + applyForceToCenter(force: Vec2, wake: boolean): void; + /** + !#en + Apply a torque. This affects the angular velocity. + !#zh + 施加一个扭矩力,将影响刚体的角速度 + @param torque about the z-axis (out of the screen), usually in N-m. + @param wake also wake up the body + */ + applyTorque(torque: number, wake: boolean): void; + /** + !#en + Apply a impulse at a world point, This immediately modifies the velocity. + If the impulse is not applied at the center of mass, it will generate a torque and + affect the angular velocity. + !#zh + 施加冲量到刚体上的一个点,将立即改变刚体的线性速度。 + 如果冲量施加到的点不是刚体的质心,那么将产生一个扭矩并影响刚体的角速度。 + @param impulse the world impulse vector, usually in N-seconds or kg-m/s. + @param point the world position + @param wake alse wake up the body + */ + applyLinearImpulse(impulse: Vec2, point: Vec2, wake: boolean): void; + /** + !#en + Apply an angular impulse. + !#zh + 施加一个角速度冲量。 + @param impulse the angular impulse in units of kg*m*m/s + @param wake also wake up the body + */ + applyAngularImpulse(impulse: number, wake: boolean): void; + /** + !#en + Synchronize node's world position to box2d rigidbody's position. + If enableAnimated is true and rigidbody's type is Animated type, + will set linear velocity instead of directly set rigidbody's position. + !#zh + 同步节点的世界坐标到 box2d 刚体的坐标上。 + 如果 enableAnimated 是 true,并且刚体的类型是 Animated ,那么将设置刚体的线性速度来代替直接设置刚体的位置。 + @param enableAnimated enableAnimated + */ + syncPosition(enableAnimated: boolean): void; + /** + !#en + Synchronize node's world angle to box2d rigidbody's angle. + If enableAnimated is true and rigidbody's type is Animated type, + will set angular velocity instead of directly set rigidbody's angle. + !#zh + 同步节点的世界旋转角度值到 box2d 刚体的旋转值上。 + 如果 enableAnimated 是 true,并且刚体的类型是 Animated ,那么将设置刚体的角速度来代替直接设置刚体的角度。 + @param enableAnimated enableAnimated + */ + syncRotation(enableAnimated: boolean): void; + } + /** !#en + Representation of RGBA colors. + + Each color component is a floating point value with a range from 0 to 255. + + You can also use the convenience method {{#crossLink "cc/color:method"}}cc.color{{/crossLink}} to create a new Color. + + !#zh + cc.Color 用于表示颜色。 + + 它包含 RGBA 四个以浮点数保存的颜色分量,每个的值都在 0 到 255 之间。 + + 您也可以通过使用 {{#crossLink "cc/color:method"}}cc.color{{/crossLink}} 的便捷方法来创建一个新的 Color。 */ + export class Color extends ValueType { + /** !#en Solid white, RGBA is [255, 255, 255, 255]. + !#zh 纯白色,RGBA 是 [255, 255, 255, 255]。 */ + static WHITE: Color; + /** !#en Solid black, RGBA is [0, 0, 0, 255]. + !#zh 纯黑色,RGBA 是 [0, 0, 0, 255]。 */ + static BLACK: Color; + /** !#en Transparent, RGBA is [0, 0, 0, 0]. + !#zh 透明,RGBA 是 [0, 0, 0, 0]。 */ + static TRANSPARENT: Color; + /** !#en Grey, RGBA is [127.5, 127.5, 127.5]. + !#zh 灰色,RGBA 是 [127.5, 127.5, 127.5]。 */ + static GRAY: Color; + /** !#en Solid red, RGBA is [255, 0, 0]. + !#zh 纯红色,RGBA 是 [255, 0, 0]。 */ + static RED: Color; + /** !#en Solid green, RGBA is [0, 255, 0]. + !#zh 纯绿色,RGBA 是 [0, 255, 0]。 */ + static GREEN: Color; + /** !#en Solid blue, RGBA is [0, 0, 255]. + !#zh 纯蓝色,RGBA 是 [0, 0, 255]。 */ + static BLUE: Color; + /** !#en Yellow, RGBA is [255, 235, 4]. + !#zh 黄色,RGBA 是 [255, 235, 4]。 */ + static YELLOW: Color; + /** !#en Orange, RGBA is [255, 127, 0]. + !#zh 橙色,RGBA 是 [255, 127, 0]。 */ + static ORANGE: Color; + /** !#en Cyan, RGBA is [0, 255, 255]. + !#zh 青色,RGBA 是 [0, 255, 255]。 */ + static CYAN: Color; + /** !#en Magenta, RGBA is [255, 0, 255]. + !#zh 洋红色(品红色),RGBA 是 [255, 0, 255]。 */ + static MAGENTA: Color; + /** + Copy content of a color into another. + */ + static copy (out: Color, a: Color): Color; + /** + Clone a new color. + */ + static clone (a: Color): Color; + /** + Set the components of a color to the given values. + */ + static set (out: Color, r?: number, g?: number, b?: number, a?: number): Color; + /** + Converts the hexadecimal formal color into rgb formal. + */ + static fromHex (out: Color, hex: number): Color; + /** + Converts the hexadecimal formal color into rgb formal. + */ + static fromHEX (out: Color, hex: string): Color; + /** + Add components of two colors, respectively. + */ + static add (out: Color, a: Color, b: Color): Color; + /** + Subtract components of color b from components of color a, respectively. + */ + static subtract (out: Color, a: Color, b: Color): Color; + /** + Multiply components of two colors, respectively. + */ + static multiply (out: Color, a: Color, b: Color): Color; + /** + Divide components of color a by components of color b, respectively. + */ + static divide (out: Color, a: Color, b: Color): Color; + /** + Scales a color by a number. + */ + static scale (out: Color, a: Color, b: number): Color; + /** + Performs a linear interpolation between two colors. + */ + static lerp (out: Color, a: Color, b: Color, t: number): Color; + /** + !#zh 颜色转数组 + !#en Turn an array of colors + @param ofs 数组起始偏移量 + */ + static toArray > (out: Out, a: IColorLike, ofs?: number): Out; + /** + !#zh 数组转颜色 + !#en An array of colors turn + @param ofs 数组起始偏移量 + */ + static fromArray (arr: IWritableArrayLike, out: Out, ofs?: number): Out; + /** + !#zh 颜色 RGB 预乘 Alpha 通道 + !#en RGB premultiply alpha channel + @param out 返回颜色 + @param color 预乘处理的目标颜色 + */ + static premultiplyAlpha (out: Out, a: IColorLike); + /** + + @param r red component of the color, default value is 0. + @param g green component of the color, defualt value is 0. + @param b blue component of the color, default value is 0. + @param a alpha component of the color, default value is 255. + */ + constructor(r?: number, g?: number, b?: number, a?: number); + /** + !#en Clone a new color from the current color. + !#zh 克隆当前颜色。 + + @example + ```js + var color = new cc.Color(); + var newColor = color.clone();// Color {r: 0, g: 0, b: 0, a: 255} + ``` + */ + clone(): Color; + /** + !#en TODO + !#zh 判断两个颜色是否相等。 + @param other other + + @example + ```js + var color1 = cc.Color.WHITE; + var color2 = new cc.Color(255, 255, 255); + cc.log(color1.equals(color2)); // true; + color2 = cc.Color.RED; + cc.log(color2.equals(color1)); // false; + ``` + */ + equals(other: Color): boolean; + /** + !#en TODO + !#zh 线性插值 + @param to to + @param ratio the interpolation coefficient. + @param out optional, the receiving vector. + + @example + ```js + // Converts a white color to a black one trough time. + update: function (dt) { + var color = this.node.color; + if (color.equals(cc.Color.BLACK)) { + return; + } + this.ratio += dt * 0.1; + this.node.color = cc.Color.WHITE.lerp(cc.Color.BLACK, ratio); + } + + ``` + */ + lerp(to: Color, ratio: number, out?: Color): Color; + /** + !#en TODO + !#zh 转换为方便阅读的字符串。 + + @example + ```js + var color = cc.Color.WHITE; + color.toString(); // "rgba(255, 255, 255, 255)" + ``` + */ + toString(): string; + /** !#en Get or set red channel value + !#zh 获取或者设置红色通道 */ + r: number; + /** !#en Get or set green channel value + !#zh 获取或者设置绿色通道 */ + g: number; + /** !#en Get or set blue channel value + !#zh 获取或者设置蓝色通道 */ + b: number; + /** !#en Get or set alpha channel value + !#zh 获取或者设置透明通道 */ + a: number; + /** + !#en Gets red channel value + !#zh 获取当前颜色的红色值。 + */ + getR(): number; + /** + !#en Sets red value and return the current color object + !#zh 设置当前的红色值,并返回当前对象。 + @param red the new Red component. + + @example + ```js + var color = new cc.Color(); + color.setR(255); // Color {r: 255, g: 0, b: 0, a: 255} + ``` + */ + setR(red: number): Color; + /** + !#en Gets green channel value + !#zh 获取当前颜色的绿色值。 + */ + getG(): number; + /** + !#en Sets green value and return the current color object + !#zh 设置当前的绿色值,并返回当前对象。 + @param green the new Green component. + + @example + ```js + var color = new cc.Color(); + color.setG(255); // Color {r: 0, g: 255, b: 0, a: 255} + ``` + */ + setG(green: number): Color; + /** + !#en Gets blue channel value + !#zh 获取当前颜色的蓝色值。 + */ + getB(): number; + /** + !#en Sets blue value and return the current color object + !#zh 设置当前的蓝色值,并返回当前对象。 + @param blue the new Blue component. + + @example + ```js + var color = new cc.Color(); + color.setB(255); // Color {r: 0, g: 0, b: 255, a: 255} + ``` + */ + setB(blue: number): Color; + /** + !#en Gets alpha channel value + !#zh 获取当前颜色的透明度值。 + */ + getA(): number; + /** + !#en Sets alpha value and return the current color object + !#zh 设置当前的透明度,并返回当前对象。 + @param alpha the new Alpha component. + + @example + ```js + var color = new cc.Color(); + color.setA(0); // Color {r: 0, g: 0, b: 0, a: 0} + ``` + */ + setA(alpha: number): Color; + /** + !#en Convert color to css format. + !#zh 转换为 CSS 格式。 + @param opt "rgba", "rgb", "#rgb" or "#rrggbb". + + @example + ```js + var color = cc.Color.BLACK; + color.toCSS(); // "rgba(0,0,0,1.00)"; + color.toCSS("rgba"); // "rgba(0,0,0,1.00)"; + color.toCSS("rgb"); // "rgba(0,0,0)"; + color.toCSS("#rgb"); // "#000"; + color.toCSS("#rrggbb"); // "#000000"; + ``` + */ + toCSS(opt?: string): string; + /** + !#en Read hex string and store color data into the current color object, the hex string must be formated as rgba or rgb. + !#zh 读取 16 进制颜色。 + @param hexString hexString + + @example + ```js + var color = cc.Color.BLACK; + color.fromHEX("#FFFF33"); // Color {r: 255, g: 255, b: 51, a: 255}; + ``` + */ + fromHEX(hexString: string): Color; + /** + !#en convert Color to HEX color string. + !#zh 转换为 16 进制。 + @param fmt "#rgb", "#rrggbb" or "#rrggbbaa". + + @example + ```js + var color = cc.Color.BLACK; + color.toHEX("#rgb"); // "000"; + color.toHEX("#rrggbb"); // "000000"; + ``` + */ + toHEX(fmt?: string): string; + /** + !#en Convert to 24bit rgb value. + !#zh 转换为 24bit 的 RGB 值。 + + @example + ```js + var color = cc.Color.YELLOW; + color.toRGBValue(); // 16771844; + ``` + */ + toRGBValue(): number; + /** + !#en Read HSV model color and convert to RGB color + !#zh 读取 HSV(色彩模型)格式。 + @param h h + @param s s + @param v v + + @example + ```js + var color = cc.Color.YELLOW; + color.fromHSV(0, 0, 1); // Color {r: 255, g: 255, b: 255, a: 255}; + ``` + */ + fromHSV(h: number, s: number, v: number): Color; + /** + !#en Transform to HSV model color + !#zh 转换为 HSV(色彩模型)格式。 + + @example + ```js + var color = cc.Color.YELLOW; + color.toHSV(); // Object {h: 0.1533864541832669, s: 0.9843137254901961, v: 1}; + ``` + */ + toHSV(): any; + /** + !#en Set the color + !#zh 设置颜色 + @param color color + */ + set (color: Color): Color; + /** + !#en Multiplies the current color by the specified color + !#zh 将当前颜色乘以与指定颜色 + @param other other + */ + multiply(other: Color): Color; + } + /** Mathematical 3x3 matrix. + + NOTE: we use column-major matrix for all matrix calculation. + + This may lead to some confusion when referencing OpenGL documentation, + however, which represents out all matricies in column-major format. + This means that while in code a matrix may be typed out as: + + [1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 1, 0, + x, y, z, 0] + + The same matrix in the [OpenGL documentation](https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glTranslate.xml) + is written as: + + 1 0 0 x + 0 1 0 y + 0 0 1 z + 0 0 0 0 + + Please rest assured, however, that they are the same thing! + This is not unique to glMatrix, either, as OpenGL developers have long been confused by the + apparent lack of consistency between the memory layout and the documentation. */ + export class Mat3 extends ValueType { + /** Identity of Mat3 */ + static IDENTITY: Mat3; + /** + !#zh 矩阵转数组 + !#en Matrix transpose array + @param ofs 数组内的起始偏移量 + */ + static toArray > (out: Out, mat: IMat3Like, ofs?: number): Out; + /** + !#zh 数组转矩阵 + !#en Transfer matrix array + @param ofs 数组起始偏移量 + */ + static fromArray (out: Out, arr: IWritableArrayLike, ofs?: number): Out; + /** !#en Matrix Data + !#zh 矩阵数据 */ + m: Float64Array|Float32Array; + constructor (m00?: number | Float32Array, m01?: number, m02?: number, m03?: number, m04?: number, m05?: number, m06?: number, m07?: number, m08?: number); + } + /** !#en Representation of 4*4 matrix. + !#zh 表示 4*4 矩阵 */ + export class Mat4 extends ValueType { + /** + !#en Multiply the current matrix with another one + !#zh 将当前矩阵与指定矩阵相乘 + @param other the second operand + @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created + */ + mul(other: Mat4, out?: Mat4): Mat4; + /** + !#en Multiply each element of the matrix by a scalar. + !#zh 将矩阵的每一个元素都乘以指定的缩放值。 + @param number amount to scale the matrix's elements by + @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created + */ + mulScalar(number: number, out?: Mat4): Mat4; + /** + !#en Subtracts the current matrix with another one + !#zh 将当前矩阵与指定的矩阵相减 + @param other the second operand + @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created + */ + sub(other: Mat4, out?: Mat4): Mat4; + /** Identity of Mat4 */ + static IDENTITY: Mat4; + /** + !#zh 获得指定矩阵的拷贝 + !#en Copy of the specified matrix to obtain + */ + static clone (a: Out): Mat4; + /** + !#zh 复制目标矩阵 + !#en Copy the target matrix + */ + static copy (out: Out, a: Out): Out; + /** + !#zh 将目标赋值为单位矩阵 + !#en The target of an assignment is the identity matrix + */ + static identity (out: Out): Out; + /** + !#zh 转置矩阵 + !#en Transposed matrix + */ + static transpose (out: Out, a: Out): Out; + /** + !#zh 矩阵求逆 + !#en Matrix inversion + */ + static invert (out: Out, a: Out): Out; + /** + !#zh 矩阵行列式 + !#en Matrix determinant + */ + static determinant (a: Out): number; + /** + !#zh 矩阵乘法 + !#en Matrix Multiplication + */ + static multiply (out: Out, a: Out, b: Out): Out; + /** + !#zh 在给定矩阵变换基础上加入变换 + !#en Was added in a given transformation matrix transformation on the basis of + */ + static transform (out: Out, a: Out, v: VecLike): Out; + /** + !#zh 在给定矩阵变换基础上加入新位移变换 + !#en Add new displacement transducer in a matrix transformation on the basis of a given + */ + static translate (out: Out, a: Out, v: VecLike): Out; + /** + !#zh 在给定矩阵变换基础上加入新缩放变换 + !#en Add new scaling transformation in a given matrix transformation on the basis of + */ + static scale (out: Out, a: Out, v: VecLike): Out; + /** + !#zh 在给定矩阵变换基础上加入新旋转变换 + !#en Add a new rotational transform matrix transformation on the basis of a given + @param rad 旋转角度 + @param axis 旋转轴 + */ + static rotate (out: Out, a: Out, rad: number, axis: VecLike): Out; + /** + !#zh 在给定矩阵变换基础上加入绕 X 轴的旋转变换 + !#en Add rotational transformation around the X axis at a given matrix transformation on the basis of + @param rad 旋转角度 + */ + static rotateX (out: Out, a: Out, rad: number): Out; + /** + !#zh 在给定矩阵变换基础上加入绕 Y 轴的旋转变换 + !#en Add about the Y axis rotation transformation in a given matrix transformation on the basis of + @param rad 旋转角度 + */ + static rotateY (out: Out, a: Out, rad: number): Out; + /** + !#zh 在给定矩阵变换基础上加入绕 Z 轴的旋转变换 + !#en Added about the Z axis at a given rotational transformation matrix transformation on the basis of + @param rad 旋转角度 + */ + static rotateZ (out: Out, a: Out, rad: number): Out; + /** + !#zh 计算位移矩阵 + !#en Displacement matrix calculation + */ + static fromTranslation (out: Out, v: VecLike): Out; + /** + !#zh 计算缩放矩阵 + !#en Scaling matrix calculation + */ + static fromScaling (out: Out, v: VecLike): Out; + /** + !#zh 计算旋转矩阵 + !#en Calculates the rotation matrix + */ + static fromRotation (out: Out, rad: number, axis: VecLike): Out; + /** + !#zh 计算绕 X 轴的旋转矩阵 + !#en Calculating rotation matrix about the X axis + */ + static fromXRotation (out: Out, rad: number): Out; + /** + !#zh 计算绕 Y 轴的旋转矩阵 + !#en Calculating rotation matrix about the Y axis + */ + static fromYRotation (out: Out, rad: number): Out; + /** + !#zh 计算绕 Z 轴的旋转矩阵 + !#en Calculating rotation matrix about the Z axis + */ + static fromZRotation (out: Out, rad: number): Out; + /** + !#zh 根据旋转和位移信息计算矩阵 + !#en The rotation and displacement information calculating matrix + */ + static fromRT (out: Out, q: Quat, v: VecLike): Out; + /** + !#zh 提取矩阵的位移信息, 默认矩阵中的变换以 S->R->T 的顺序应用 + !#en Extracting displacement information of the matrix, the matrix transform to the default sequential application S-> R-> T is + */ + static getTranslation (out: VecLike, mat: Out): VecLike; + /** + !#zh 提取矩阵的缩放信息, 默认矩阵中的变换以 S->R->T 的顺序应用 + !#en Scaling information extraction matrix, the matrix transform to the default sequential application S-> R-> T is + */ + static getScaling (out: VecLike, mat: Out): VecLike; + /** + !#zh 提取矩阵的旋转信息, 默认输入矩阵不含有缩放信息,如考虑缩放应使用 `toRTS` 函数。 + !#en Rotation information extraction matrix, the matrix containing no default input scaling information, such as the use of `toRTS` should consider the scaling function. + */ + static getRotation (out: Quat, mat: Out): Quat; + /** + !#zh 提取旋转、位移、缩放信息, 默认矩阵中的变换以 S->R->T 的顺序应用 + !#en Extracting rotational displacement, zoom information, the default matrix transformation in order S-> R-> T applications + */ + static toRTS (mat: Out, q: Quat, v: VecLike, s: VecLike): void; + /** + !#zh 根据旋转、位移、缩放信息计算矩阵,以 S->R->T 的顺序应用 + !#en The rotary displacement, the scaling matrix calculation information, the order S-> R-> T applications + */ + static fromRTS (out: Out, q: Quat, v: VecLike, s: VecLike): Out; + /** + !#zh 根据指定的旋转、位移、缩放及变换中心信息计算矩阵,以 S->R->T 的顺序应用 + !#en According to the specified rotation, displacement, and scale conversion matrix calculation information center, order S-> R-> T applications + @param q 旋转值 + @param v 位移值 + @param s 缩放值 + @param o 指定变换中心 + */ + static fromRTSOrigin (out: Out, q: Quat, v: VecLike, s: VecLike, o: VecLike): Out; + /** + !#zh 根据指定的旋转信息计算矩阵 + !#en The rotation matrix calculation information specified + */ + static fromQuat (out: Out, q: Quat): Out; + /** + !#zh 根据指定的视锥体信息计算矩阵 + !#en The matrix calculation information specified frustum + @param left 左平面距离 + @param right 右平面距离 + @param bottom 下平面距离 + @param top 上平面距离 + @param near 近平面距离 + @param far 远平面距离 + */ + static frustum (out: Out, left: number, right: number, bottom: number, top: number, near: number, far: number): Out; + /** + !#zh 计算透视投影矩阵 + !#en Perspective projection matrix calculation + @param fovy 纵向视角高度 + @param aspect 长宽比 + @param near 近平面距离 + @param far 远平面距离 + */ + static perspective (out: Out, fovy: number, aspect: number, near: number, far: number): Out; + /** + !#zh 计算正交投影矩阵 + !#en Computing orthogonal projection matrix + @param left 左平面距离 + @param right 右平面距离 + @param bottom 下平面距离 + @param top 上平面距离 + @param near 近平面距离 + @param far 远平面距离 + */ + static ortho (out: Out, left: number, right: number, bottom: number, top: number, near: number, far: number): Out; + /** + !#zh 根据视点计算矩阵,注意 `eye - center` 不能为零向量或与 `up` 向量平行 + !#en `Up` parallel vector or vector center` not be zero - the matrix calculation according to the viewpoint, note` eye + @param eye 当前位置 + @param center 目标视点 + @param up 视口上方向 + */ + static lookAt (out: Out, eye: VecLike, center: VecLike, up: VecLike): Out; + /** + !#zh 计算逆转置矩阵 + !#en Reversal matrix calculation + */ + static inverseTranspose (out: Out, a: Out): Out; + /** + !#zh 逐元素矩阵加法 + !#en Element by element matrix addition + */ + static add (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素矩阵减法 + !#en Matrix element by element subtraction + */ + static subtract (out: Out, a: Out, b: Out): Out; + /** + !#zh 矩阵标量乘法 + !#en Matrix scalar multiplication + */ + static multiplyScalar (out: Out, a: Out, b: number): Out; + /** + !#zh 逐元素矩阵标量乘加: A + B * scale + !#en Elements of the matrix by the scalar multiplication and addition: A + B * scale + */ + static multiplyScalarAndAdd (out: Out, a: Out, b: Out, scale: number): Out; + /** + !#zh 矩阵等价判断 + !#en Analyzing the equivalent matrix + */ + static strictEquals (a: Out, b: Out): boolean; + /** + !#zh 排除浮点数误差的矩阵近似等价判断 + !#en Negative floating point error is approximately equivalent to determining a matrix + */ + static equals (a: Out, b: Out, epsilon?: number): boolean; + /** + !#zh 矩阵转数组 + !#en Matrix transpose array + @param ofs 数组内的起始偏移量 + */ + static toArray > (out: Out, mat: IMat4Like, ofs?: number): Out; + /** + !#zh 数组转矩阵 + !#en Transfer matrix array + @param ofs 数组起始偏移量 + */ + static fromArray (out: Out, arr: IWritableArrayLike, ofs?: number): Out; + /** !#en Matrix Data + !#zh 矩阵数据 */ + m: Float64Array|Float32Array; + /** + !#en + Constructor + see {{#crossLink "cc/mat4:method"}}cc.mat4{{/crossLink}} + !#zh + 构造函数,可查看 {{#crossLink "cc/mat4:method"}}cc.mat4{{/crossLink}} + */ + constructor ( m00?: number, m01?: number, m02?: number, m03?: number, m10?: number, m11?: number, m12?: number, m13?: number, m20?: number, m21?: number, m22?: number, m23?: number, m30?: number, m31?: number, m32?: number, m33?: number); + /** + !#en clone a Mat4 object + !#zh 克隆一个 Mat4 对象 + */ + clone(): Mat4; + /** + !#en Sets the matrix with another one's value + !#zh 用另一个矩阵设置这个矩阵的值。 + @param srcObj srcObj + */ + set(srcObj: Mat4): Mat4; + /** + !#en Check whether two matrix equal + !#zh 当前的矩阵是否与指定的矩阵相等。 + @param other other + */ + equals(other: Mat4): boolean; + /** + !#en Check whether two matrix equal with default degree of variance. + !#zh + 近似判断两个矩阵是否相等。
+ 判断 2 个矩阵是否在默认误差范围之内,如果在则返回 true,反之则返回 false。 + @param other other + */ + fuzzyEquals(other: Mat4): boolean; + /** + !#en Transform to string with matrix informations + !#zh 转换为方便阅读的字符串。 + */ + toString(): string; + /** + Set the matrix to the identity matrix + */ + identity(): Mat4; + /** + Transpose the values of a mat4 + @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created. + */ + transpose(out?: Mat4): Mat4; + /** + Inverts a mat4 + @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created. + */ + invert(out?: Mat4): Mat4; + /** + Calculates the adjugate of a mat4 + @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created. + */ + adjoint(out?: Mat4): Mat4; + /** + Calculates the determinant of a mat4 + */ + determinant(): number; + /** + Adds two Mat4 + @param other the second operand + @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created. + */ + add(other: Mat4, out?: Mat4): Mat4; + /** + Subtracts the current matrix with another one + @param other the second operand + */ + subtract(other: Mat4): Mat4; + /** + Subtracts the current matrix with another one + @param other the second operand + */ + multiply(other: Mat4): Mat4; + /** + Multiply each element of the matrix by a scalar. + @param number amount to scale the matrix's elements by + */ + multiplyScalar(number: number): Mat4; + /** + Translate a mat4 by the given vector + @param v vector to translate by + @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created + */ + translate(v: Vec3, out?: Mat4): Mat4; + /** + Scales the mat4 by the dimensions in the given vec3 + @param v vector to scale by + @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created + */ + scale(v: Vec3, out?: Mat4): Mat4; + /** + Rotates a mat4 by the given angle around the given axis + @param rad the angle to rotate the matrix by + @param axis the axis to rotate around + @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created + */ + rotate(rad: number, axis: Vec3, out?: Mat4): Mat4; + /** + Returns the translation vector component of a transformation matrix. + @param out Vector to receive translation component, if not provided, a new vec3 will be created + */ + getTranslation(out: Vec3): Vec3; + /** + Returns the scale factor component of a transformation matrix + @param out Vector to receive scale component, if not provided, a new vec3 will be created + */ + getScale(out: Vec3): Vec3; + /** + Returns the rotation factor component of a transformation matrix + @param out Vector to receive rotation component, if not provided, a new quaternion object will be created + */ + getRotation(out: Quat): Quat; + /** + Restore the matrix values from a quaternion rotation, vector translation and vector scale + @param q Rotation quaternion + @param v Translation vector + @param s Scaling vector + */ + fromRTS(q: Quat, v: Vec3, s: Vec3): Mat4; + /** + Restore the matrix values from a quaternion rotation + @param q Rotation quaternion + */ + fromQuat(q: Quat): Mat4; + } + /** !#en Representation of 2D vectors and points. + !#zh 表示 2D 向量和坐标 */ + export class Quat extends ValueType { + /** + !#en + Constructor + see {{#crossLink "cc/quat:method"}}cc.quat{{/crossLink}} + !#zh + 构造函数,可查看 {{#crossLink "cc/quat:method"}}cc.quat{{/crossLink}} + @param x x + @param y y + @param z z + @param w w + */ + constructor(x?: number, y?: number, z?: number, w?: number); + /** + !#en Calculate the multiply result between this quaternion and another one + !#zh 计算四元数乘积的结果 + @param other other + @param out out + */ + mul(other: Quat, out?: Quat): Quat; + /** + !#zh 获得指定四元数的拷贝 + !#en Obtaining copy specified quaternion + */ + static clone (a: Out): Quat; + /** + !#zh 复制目标四元数 + !#en Copy quaternion target + */ + static copy (out: Out, a: QuatLike): Out; + /** + !#zh 设置四元数值 + !#en Provided Quaternion Value + */ + static set (out: Out, x: number, y: number, z: number, w: number): Out; + /** + !#zh 将目标赋值为单位四元数 + !#en The target of an assignment as a unit quaternion + */ + static identity (out: Out): Out; + /** + !#zh 设置四元数为两向量间的最短路径旋转,默认两向量都已归一化 + !#en Set quaternion rotation is the shortest path between two vectors, the default two vectors are normalized + */ + static rotationTo (out: Out, a: VecLike, b: VecLike): Out; + /** + !#zh 获取四元数的旋转轴和旋转弧度 + !#en Get the rotary shaft and the arc of rotation quaternion + @param outAxis 旋转轴输出 + @param q 源四元数 + */ + static getAxisAngle (outAxis: VecLike, q: Out): number; + /** + !#zh 四元数乘法 + !#en Quaternion multiplication + */ + static multiply (out: Out, a: QuatLike_1, b: QuatLike_2): Out; + /** + !#zh 四元数标量乘法 + !#en Quaternion scalar multiplication + */ + static multiplyScalar (out: Out, a: Out, b: number): Out; + /** + !#zh 四元数乘加:A + B * scale + !#en Quaternion multiplication and addition: A + B * scale + */ + static scaleAndAdd (out: Out, a: Out, b: Out, scale: number): Out; + /** + !#zh 绕 X 轴旋转指定四元数 + !#en About the X axis specified quaternion + @param rad 旋转弧度 + */ + static rotateX (out: Out, a: Out, rad: number): Out; + /** + !#zh 绕 Y 轴旋转指定四元数 + !#en Rotation about the Y axis designated quaternion + @param rad 旋转弧度 + */ + static rotateY (out: Out, a: Out, rad: number): Out; + /** + !#zh 绕 Z 轴旋转指定四元数 + !#en Around the Z axis specified quaternion + @param rad 旋转弧度 + */ + static rotateZ (out: Out, a: Out, rad: number): Out; + /** + !#zh 绕世界空间下指定轴旋转四元数 + !#en Space around the world at a given axis of rotation quaternion + @param axis 旋转轴,默认已归一化 + @param rad 旋转弧度 + */ + static rotateAround (out: Out, rot: Out, axis: VecLike, rad: number): Out; + /** + !#zh 绕本地空间下指定轴旋转四元数 + !#en Local space around the specified axis rotation quaternion + @param axis 旋转轴 + @param rad 旋转弧度 + */ + static rotateAroundLocal (out: Out, rot: Out, axis: VecLike, rad: number): Out; + /** + !#zh 根据 xyz 分量计算 w 分量,默认已归一化 + !#en The component w xyz components calculated, normalized by default + */ + static calculateW (out: Out, a: Out): Out; + /** + !#zh 四元数点积(数量积) + !#en Quaternion dot product (scalar product) + */ + static dot (a: Out, b: Out): number; + /** + !#zh 逐元素线性插值: A + t * (B - A) + !#en Element by element linear interpolation: A + t * (B - A) + */ + static lerp (out: Out, a: Out, b: Out, t: number): Out; + /** + !#zh 四元数球面插值 + !#en Spherical quaternion interpolation + */ + static slerp(out: Out, a: QuatLike_1, b: QuatLike_2, t: number): Out; + /** + !#zh 带两个控制点的四元数球面插值 + !#en Quaternion with two spherical interpolation control points + */ + static sqlerp (out: Out, a: Out, b: Out, c: Out, d: Out, t: number): Out; + /** + !#zh 四元数求逆 + !#en Quaternion inverse + */ + static invert (out: Out, a: QuatLike): Out; + /** + !#zh 求共轭四元数,对单位四元数与求逆等价,但更高效 + !#en Conjugating a quaternion, and the unit quaternion equivalent to inversion, but more efficient + */ + static conjugate (out: Out, a: Out): Out; + /** + !#zh 求四元数长度 + !#en Seek length quaternion + */ + static len (a: Out): number; + /** + !#zh 求四元数长度平方 + !#en Seeking quaternion square of the length + */ + static lengthSqr (a: Out): number; + /** + !#zh 归一化四元数 + !#en Normalized quaternions + */ + static normalize (out: Out, a: Out): Out; + /** + !#zh 根据本地坐标轴朝向计算四元数,默认三向量都已归一化且相互垂直 + !#en Calculated according to the local orientation quaternion coordinate axis, the default three vectors are normalized and mutually perpendicular + */ + static fromAxes (out: Out, xAxis: VecLike, yAxis: VecLike, zAxis: VecLike): Out; + /** + !#zh 根据视口的前方向和上方向计算四元数 + !#en The forward direction and the direction of the viewport computing quaternion + @param view 视口面向的前方向,必须归一化 + @param up 视口的上方向,必须归一化,默认为 (0, 1, 0) + */ + static fromViewUp (out: Out, view: Vec3, up?: Vec3): Out; + /** + !#zh 根据旋转轴和旋转弧度计算四元数 + !#en The quaternion calculated and the arc of rotation of the rotary shaft + */ + static fromAxisAngle (out: Out, axis: VecLike, rad: number): Out; + /** + !#zh 根据三维矩阵信息计算四元数,默认输入矩阵不含有缩放信息 + !#en Calculating the three-dimensional quaternion matrix information, default zoom information input matrix does not contain + */ + static fromMat3 (out: Out, mat: Mat3): Out; + /** + !#zh 根据欧拉角信息计算四元数,旋转顺序为 YZX + !#en The quaternion calculated Euler angle information, rotation order YZX + */ + static fromEuler (out: Out, x: number, y: number, z: number): Out; + /** + !#zh 返回定义此四元数的坐标系 X 轴向量 + !#en This returns the result of the quaternion coordinate system X-axis vector + */ + static toAxisX (out: VecLike, q: Out): VecLike; + /** + !#zh 返回定义此四元数的坐标系 Y 轴向量 + !#en This returns the result of the quaternion coordinate system Y axis vector + */ + static toAxisY (out: VecLike, q: Out): VecLike; + /** + !#zh 返回定义此四元数的坐标系 Z 轴向量 + !#en This returns the result of the quaternion coordinate system the Z-axis vector + */ + static toAxisZ (out: VecLike, q: Out): VecLike; + /** + !#zh 根据四元数计算欧拉角,返回角度 x, y 在 [-180, 180] 区间内, z 默认在 [-90, 90] 区间内,旋转顺序为 YZX + !#en The quaternion calculated Euler angles, return angle x, y in the [-180, 180] interval, z default the range [-90, 90] interval, the rotation order YZX + @param outerZ z 取值范围区间改为 [-180, -90] U [90, 180] + */ + static toEuler (out: Out, q: IQuatLike, outerZ?: boolean): Out; + /** + !#zh 四元数等价判断 + !#en Analyzing quaternion equivalent + */ + static strictEquals (a: Out, b: Out): boolean; + /** + !#zh 排除浮点数误差的四元数近似等价判断 + !#en Negative floating point error quaternion approximately equivalent Analyzing + */ + static equals (a: Out, b: Out, epsilon?: number): boolean; + /** + !#zh 四元数转数组 + !#en Quaternion rotation array + @param ofs 数组内的起始偏移量 + */ + static toArray > (out: Out, q: IQuatLike, ofs?: number): Out; + /** + !#zh 数组转四元数 + !#en Array to a quaternion + @param ofs 数组起始偏移量 + */ + static fromArray (out: Out, arr: IWritableArrayLike, ofs?: number): Out; + x: number; + y: number; + z: number; + w: number; + /** + !#en clone a Quat object and return the new object + !#zh 克隆一个四元数并返回 + */ + clone(): Quat; + /** + !#en Set values with another quaternion + !#zh 用另一个四元数的值设置到当前对象上。 + @param newValue !#en new value to set. !#zh 要设置的新值 + */ + set(newValue: Quat): Quat; + /** + !#en Check whether current quaternion equals another + !#zh 当前的四元数是否与指定的四元数相等。 + @param other other + */ + equals(other: Quat): boolean; + /** + !#en Convert quaternion to euler + !#zh 转换四元数到欧拉角 + @param out out + */ + toEuler(out: Vec3): Vec3; + /** + !#en Convert euler to quaternion + !#zh 转换欧拉角到四元数 + @param euler euler + */ + fromEuler(euler: Vec3): Quat; + /** + !#en Calculate the interpolation result between this quaternion and another one with given ratio + !#zh 计算四元数的插值结果 + @param to to + @param ratio ratio + @param out out + */ + lerp(to: Quat, ratio: number, out?: Quat): Quat; + /** + !#en Calculate the multiply result between this quaternion and another one + !#zh 计算四元数乘积的结果 + @param other other + */ + multiply(other: Quat): Quat; + /** + !#en Rotates a quaternion by the given angle (in radians) about a world space axis. + !#zh 围绕世界空间轴按给定弧度旋转四元数 + @param rot Quaternion to rotate + @param axis The axis around which to rotate in world space + @param rad Angle (in radians) to rotate + @param out Quaternion to store result + */ + rotateAround(rot: Quat, axis: Vec3, rad: number, out?: Quat): Quat; + } + /** !#en A 2D rectangle defined by x, y position and width, height. + !#zh 通过位置和宽高定义的 2D 矩形。 */ + export class Rect extends ValueType { + /** + !#en + Constructor of Rect class. + see {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} for convenience method. + !#zh + Rect类的构造函数。可以通过 {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} 简便方法进行创建。 + @param x x + @param y y + @param w w + @param h h + */ + constructor(x?: number, y?: number, w?: number, h?: number); + /** + !#en Creates a rectangle from two coordinate values. + !#zh 根据指定 2 个坐标创建出一个矩形区域。 + @param v1 v1 + @param v2 v2 + + @example + ```js + cc.Rect.fromMinMax(cc.v2(10, 10), cc.v2(20, 20)); // Rect {x: 10, y: 10, width: 10, height: 10}; + ``` + */ + static fromMinMax(v1: Vec2, v2: Vec2): Rect; + x: number; + y: number; + width: number; + height: number; + /** + !#en TODO + !#zh 克隆一个新的 Rect。 + + @example + ```js + var a = new cc.Rect(0, 0, 10, 10); + a.clone();// Rect {x: 0, y: 0, width: 10, height: 10} + ``` + */ + clone(): Rect; + /** + !#en TODO + !#zh 是否等于指定的矩形。 + @param other other + + @example + ```js + var a = new cc.Rect(0, 0, 10, 10); + var b = new cc.Rect(0, 0, 10, 10); + a.equals(b);// true; + ``` + */ + equals(other: Rect): boolean; + /** + !#en TODO + !#zh 线性插值 + @param to to + @param ratio the interpolation coefficient. + @param out optional, the receiving vector. + + @example + ```js + var a = new cc.Rect(0, 0, 10, 10); + var b = new cc.Rect(50, 50, 100, 100); + update (dt) { + // method 1; + var c = a.lerp(b, dt * 0.1); + // method 2; + a.lerp(b, dt * 0.1, c); + } + ``` + */ + lerp(to: Rect, ratio: number, out?: Rect): Rect; + /** + !#en Check whether the current rectangle intersects with the given one + !#zh 当前矩形与指定矩形是否相交。 + @param rect rect + + @example + ```js + var a = new cc.Rect(0, 0, 10, 10); + var b = new cc.Rect(0, 0, 20, 20); + a.intersects(b);// true + ``` + */ + intersects(rect: Rect): boolean; + /** + !#en Returns the overlapping portion of 2 rectangles. + !#zh 返回 2 个矩形重叠的部分。 + @param out Stores the result + @param rectB rectB + + @example + ```js + var a = new cc.Rect(0, 10, 20, 20); + var b = new cc.Rect(0, 10, 10, 10); + var intersection = new cc.Rect(); + a.intersection(intersection, b); // intersection {x: 0, y: 10, width: 10, height: 10}; + ``` + */ + intersection(out: Rect, rectB: Rect): Rect; + /** + !#en Check whether the current rect contains the given point + !#zh 当前矩形是否包含指定坐标点。 + Returns true if the point inside this rectangle. + @param point point + + @example + ```js + var a = new cc.Rect(0, 0, 10, 10); + var b = new cc.Vec2(0, 5); + a.contains(b);// true + ``` + */ + contains(point: Vec2): boolean; + /** + !#en Returns true if the other rect totally inside this rectangle. + !#zh 当前矩形是否包含指定矩形。 + @param rect rect + + @example + ```js + var a = new cc.Rect(0, 0, 20, 20); + var b = new cc.Rect(0, 0, 10, 10); + a.containsRect(b);// true + ``` + */ + containsRect(rect: Rect): boolean; + /** + !#en Returns the smallest rectangle that contains the current rect and the given rect. + !#zh 返回一个包含当前矩形和指定矩形的最小矩形。 + @param out Stores the result + @param rectB rectB + + @example + ```js + var a = new cc.Rect(0, 10, 20, 20); + var b = new cc.Rect(0, 10, 10, 10); + var union = new cc.Rect(); + a.union(union, b); // union {x: 0, y: 10, width: 20, height: 20}; + ``` + */ + union(out: Rect, rectB: Rect): Rect; + /** + !#en Apply matrix4 to the rect. + !#zh 使用 mat4 对矩形进行矩阵转换。 + @param out The output rect + @param mat The matrix4 + */ + transformMat4(out: Rect, mat: Mat4): void; + /** + !#en Output rect informations to string + !#zh 转换为方便阅读的字符串 + + @example + ```js + var a = new cc.Rect(0, 0, 10, 10); + a.toString();// "(0.00, 0.00, 10.00, 10.00)"; + ``` + */ + toString(): string; + /** !#en The minimum x value, equals to rect.x + !#zh 矩形 x 轴上的最小值,等价于 rect.x。 */ + xMin: number; + /** !#en The minimum y value, equals to rect.y + !#zh 矩形 y 轴上的最小值。 */ + yMin: number; + /** !#en The maximum x value. + !#zh 矩形 x 轴上的最大值。 */ + xMax: number; + /** !#en The maximum y value. + !#zh 矩形 y 轴上的最大值。 */ + yMax: number; + /** !#en The position of the center of the rectangle. + !#zh 矩形的中心点。 */ + center: Vec2; + /** !#en The X and Y position of the rectangle. + !#zh 矩形的 x 和 y 坐标。 */ + origin: Vec2; + /** !#en Width and height of the rectangle. + !#zh 矩形的大小。 */ + size: Size; + } + /** !#en + cc.Size is the class for size object,
+ please do not use its constructor to create sizes,
+ use {{#crossLink "cc/size:method"}}{{/crossLink}} alias function instead.
+ It will be deprecated soon, please use cc.Vec2 instead. + + !#zh + cc.Size 是 size 对象的类。
+ 请不要使用它的构造函数创建的 size,
+ 使用 {{#crossLink "cc/size:method"}}{{/crossLink}} 别名函数。
+ 它不久将被取消,请使用cc.Vec2代替。 */ + export class Size { + /** + + @param width width + @param height height + */ + constructor(width: number|Size, height?: number); + /** !#en return a Size object with width = 0 and height = 0. + !#zh 返回一个宽度为 0 和高度为 0 的 Size 对象。 */ + static ZERO: Size; + width: number; + height: number; + /** + !#en TODO + !#zh 克隆 size 对象。 + + @example + ```js + var a = new cc.size(10, 10); + a.clone();// return Size {width: 0, height: 0}; + ``` + */ + clone(): Size; + /** + !#en TODO + !#zh 当前 Size 对象是否等于指定 Size 对象。 + @param other other + + @example + ```js + var a = new cc.size(10, 10); + a.equals(new cc.size(10, 10));// return true; + ``` + */ + equals(other: Size): boolean; + /** + !#en TODO + !#zh 线性插值。 + @param to to + @param ratio the interpolation coefficient. + @param out optional, the receiving vector. + + @example + ```js + var a = new cc.size(10, 10); + var b = new cc.rect(50, 50, 100, 100); + update (dt) { + // method 1; + var c = a.lerp(b, dt * 0.1); + // method 2; + a.lerp(b, dt * 0.1, c); + } + ``` + */ + lerp(to: Rect, ratio: number, out?: Size): Size; + /** + !#en TODO + !#zh 转换为方便阅读的字符串。 + + @example + ```js + var a = new cc.size(10, 10); + a.toString();// return "(10.00, 10.00)"; + ``` + */ + toString(): string; + } + /** !#en The base class of all value types. + !#zh 所有值类型的基类。 */ + export class ValueType { + /** + !#en This method returns an exact copy of current value. + !#zh 克隆当前值,该方法返回一个新对象,新对象的值和原对象相等。 + */ + clone(): ValueType; + /** + !#en Compares this object with the other one. + !#zh 当前对象是否等于指定对象。 + @param other other + */ + equals(other: ValueType): boolean; + /** + !#en + Linearly interpolates between this value to to value by ratio which is in the range [0, 1]. + When ratio = 0 returns this. When ratio = 1 return to. When ratio = 0.5 returns the average of this and to. + !#zh + 线性插值。
+ 当 ratio = 0 时返回自身,ratio = 1 时返回目标,ratio = 0.5 返回自身和目标的平均值。。 + @param to the to value + @param ratio the interpolation coefficient + */ + lerp(to: ValueType, ratio: number): ValueType; + /** + !#en + Copys all the properties from another given object to this value. + !#zh + 从其它对象把所有属性复制到当前对象。 + @param source the source to copy + */ + set(source: ValueType): void; + /** + !#en Convert to a readable string. + !#zh 转换为方便阅读的字符串。 + */ + toString(): string; + } + /** !#en Representation of 2D vectors and points. + !#zh 表示 2D 向量和坐标 */ + export class Vec2 extends ValueType { + /** + !#en Returns the length of this vector. + !#zh 返回该向量的长度。 + + @example + ```js + var v = cc.v2(10, 10); + v.mag(); // return 14.142135623730951; + ``` + */ + mag(): number; + /** + !#en Returns the squared length of this vector. + !#zh 返回该向量的长度平方。 + + @example + ```js + var v = cc.v2(10, 10); + v.magSqr(); // return 200; + ``` + */ + magSqr(): number; + /** + !#en Subtracts one vector from this. If you want to save result to another vector, use sub() instead. + !#zh 向量减法。如果你想保存结果到另一个向量,可使用 sub() 代替。 + @param vector vector + + @example + ```js + var v = cc.v2(10, 10); + v.subSelf(cc.v2(5, 5));// return Vec2 {x: 5, y: 5}; + ``` + */ + subSelf(vector: Vec2): Vec2; + /** + !#en Subtracts one vector from this, and returns the new result. + !#zh 向量减法,并返回新结果。 + @param vector vector + @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created + + @example + ```js + var v = cc.v2(10, 10); + v.sub(cc.v2(5, 5)); // return Vec2 {x: 5, y: 5}; + var v1 = new Vec2; + v.sub(cc.v2(5, 5), v1); // return Vec2 {x: 5, y: 5}; + ``` + */ + sub(vector: Vec2, out?: Vec2): Vec2; + /** + !#en Multiplies this by a number. If you want to save result to another vector, use mul() instead. + !#zh 缩放当前向量。如果你想结果保存到另一个向量,可使用 mul() 代替。 + @param num num + + @example + ```js + var v = cc.v2(10, 10); + v.mulSelf(5);// return Vec2 {x: 50, y: 50}; + ``` + */ + mulSelf(num: number): Vec2; + /** + !#en Multiplies by a number, and returns the new result. + !#zh 缩放向量,并返回新结果。 + @param num num + @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created + + @example + ```js + var v = cc.v2(10, 10); + v.mul(5); // return Vec2 {x: 50, y: 50}; + var v1 = new Vec2; + v.mul(5, v1); // return Vec2 {x: 50, y: 50}; + ``` + */ + mul(num: number, out?: Vec2): Vec2; + /** + !#en Divides by a number. If you want to save result to another vector, use div() instead. + !#zh 向量除法。如果你想结果保存到另一个向量,可使用 div() 代替。 + @param num num + + @example + ```js + var v = cc.v2(10, 10); + v.divSelf(5); // return Vec2 {x: 2, y: 2}; + ``` + */ + divSelf(num: number): Vec2; + /** + !#en Divides by a number, and returns the new result. + !#zh 向量除法,并返回新的结果。 + @param num num + @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created + + @example + ```js + var v = cc.v2(10, 10); + v.div(5); // return Vec2 {x: 2, y: 2}; + var v1 = new Vec2; + v.div(5, v1); // return Vec2 {x: 2, y: 2}; + ``` + */ + div(num: number, out?: Vec2): Vec2; + /** + !#en Multiplies two vectors. + !#zh 分量相乘。 + @param vector vector + + @example + ```js + var v = cc.v2(10, 10); + v.scaleSelf(cc.v2(5, 5));// return Vec2 {x: 50, y: 50}; + ``` + */ + scaleSelf(vector: Vec2): Vec2; + /** + !#en Multiplies two vectors, and returns the new result. + !#zh 分量相乘,并返回新的结果。 + @param vector vector + @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created + + @example + ```js + var v = cc.v2(10, 10); + v.scale(cc.v2(5, 5)); // return Vec2 {x: 50, y: 50}; + var v1 = new Vec2; + v.scale(cc.v2(5, 5), v1); // return Vec2 {x: 50, y: 50}; + ``` + */ + scale(vector: Vec2, out?: Vec2): Vec2; + /** + !#en Negates the components. If you want to save result to another vector, use neg() instead. + !#zh 向量取反。如果你想结果保存到另一个向量,可使用 neg() 代替。 + + @example + ```js + var v = cc.v2(10, 10); + v.negSelf(); // return Vec2 {x: -10, y: -10}; + ``` + */ + negSelf(): Vec2; + /** + !#en Negates the components, and returns the new result. + !#zh 返回取反后的新向量。 + @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created + + @example + ```js + var v = cc.v2(10, 10); + var v1 = new Vec2; + v.neg(v1); // return Vec2 {x: -10, y: -10}; + ``` + */ + neg(out?: Vec2): Vec2; + /** !#en return a Vec2 object with x = 1 and y = 1. + !#zh 新 Vec2 对象。 */ + static ONE: Vec2; + /** !#en return a Vec2 object with x = 0 and y = 0. + !#zh 返回 x = 0 和 y = 0 的 Vec2 对象。 */ + static ZERO: Vec2; + /** !#en return a readonly Vec2 object with x = 0 and y = 0. + !#zh 返回一个 x = 0 和 y = 0 的 Vec2 只读对象。 */ + static ZERO_R: Vec2; + /** !#en return a Vec2 object with x = 0 and y = 1. + !#zh 返回 x = 0 和 y = 1 的 Vec2 对象。 */ + static UP: Vec2; + /** !#en return a readonly Vec2 object with x = 0 and y = 1. + !#zh 返回 x = 0 和 y = 1 的 Vec2 只读对象。 */ + static UP_R: Vec2; + /** !#en return a readonly Vec2 object with x = 1 and y = 0. + !#zh 返回 x = 1 和 y = 0 的 Vec2 只读对象。 */ + static RIGHT: Vec2; + /** !#en return a Vec2 object with x = 1 and y = 0. + !#zh 返回 x = 1 和 y = 0 的 Vec2 对象。 */ + static RIGHT_R: Vec2; + /** + !#zh 获得指定向量的拷贝 + */ + static clone (a: Out): Vec2; + /** + !#zh 复制指定向量的值 + */ + static copy (out: Out, a: Out): Out; + /** + !#zh 设置向量值 + */ + static set (out: Out, x: number, y: number): Out; + /** + !#zh 逐元素向量加法 + */ + static add (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量减法 + */ + static subtract (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量乘法 + */ + static multiply (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量除法 + */ + static divide (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量向上取整 + */ + static ceil (out: Out, a: Out): Out; + /** + !#zh 逐元素向量向下取整 + */ + static floor (out: Out, a: Out): Out; + /** + !#zh 逐元素向量最小值 + */ + static min (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量最大值 + */ + static max (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量四舍五入取整 + */ + static round (out: Out, a: Out): Out; + /** + !#zh 向量标量乘法 + */ + static multiplyScalar (out: Out, a: Out, b: number): Out; + /** + !#zh 逐元素向量乘加: A + B * scale + */ + static scaleAndAdd (out: Out, a: Out, b: Out, scale: number): Out; + /** + !#zh 求两向量的欧氏距离 + */ + static distance (a: Out, b: Out): number; + /** + !#zh 求两向量的欧氏距离平方 + */ + static squaredDistance (a: Out, b: Out): number; + /** + !#zh 求向量长度 + */ + static len (a: Out): number; + /** + !#zh 求向量长度平方 + */ + static lengthSqr (a: Out): number; + /** + !#zh 逐元素向量取负 + */ + static negate (out: Out, a: Out): Out; + /** + !#zh 逐元素向量取倒数,接近 0 时返回 Infinity + */ + static inverse (out: Out, a: Out): Out; + /** + !#zh 逐元素向量取倒数,接近 0 时返回 0 + */ + static inverseSafe (out: Out, a: Out): Out; + /** + !#zh 归一化向量 + */ + static normalize (out: Out, a: Vec2Like): Out; + /** + !#zh 向量点积(数量积) + */ + static dot (a: Out, b: Out): number; + /** + !#zh 向量叉积(向量积),注意二维向量的叉积为与 Z 轴平行的三维向量 + */ + static cross (out: Vec2, a: Out, b: Out): Vec2; + /** + !#zh 逐元素向量线性插值: A + t * (B - A) + */ + static lerp (out: Out, a: Out, b: Out, t: number): Out; + /** + !#zh 生成一个在单位圆上均匀分布的随机向量 + */ + static random (out: Out, scale?: number): Out; + /** + !#zh 向量与三维矩阵乘法,默认向量第三位为 1。 + */ + static transformMat3 (out: Out, a: Out, mat: IMat3Like): Out; + /** + !#zh 向量与四维矩阵乘法,默认向量第三位为 0,第四位为 1。 + */ + static transformMat4 (out: Out, a: Out, mat: MatLike): Out; + /** + !#zh 向量等价判断 + */ + static strictEquals (a: Out, b: Out): boolean; + /** + !#zh 排除浮点数误差的向量近似等价判断 + */ + static equals (a: Out, b: Out, epsilon?: number): boolean; + /** + !#zh 排除浮点数误差的向量近似等价判断 + */ + static angle (a: Out, b: Out): number; + /** + !#zh 向量转数组 + */ + static toArray > (out: Out, v: IVec2Like, ofs?: number): Out; + /** + !#zh 数组转向量 + */ + static fromArray (out: Out, arr: IWritableArrayLike, ofs?: number): Out; + x: number; + y: number; + /** + !#en + Constructor + see {{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} or {{#crossLink "cc/p:method"}}cc.p{{/crossLink}} + !#zh + 构造函数,可查看 {{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} 或者 {{#crossLink "cc/p:method"}}cc.p{{/crossLink}} + @param x x + @param y y + */ + constructor(x?: number, y?: number); + /** + !#en clone a Vec2 object + !#zh 克隆一个 Vec2 对象 + */ + clone(): Vec2; + /** + !#en Sets vector with another's value + !#zh 设置向量值。 + @param newValue !#en new value to set. !#zh 要设置的新值 + */ + set(newValue: Vec2): Vec2; + /** + !#en Check whether two vector equal + !#zh 当前的向量是否与指定的向量相等。 + @param other other + */ + equals(other: Vec2): boolean; + /** + !#en Check whether two vector equal with some degree of variance. + !#zh + 近似判断两个点是否相等。
+ 判断 2 个向量是否在指定数值的范围之内,如果在则返回 true,反之则返回 false。 + @param other other + @param variance variance + */ + fuzzyEquals(other: Vec2, variance: number): boolean; + /** + !#en Transform to string with vector informations + !#zh 转换为方便阅读的字符串。 + */ + toString(): string; + /** + !#en Calculate linear interpolation result between this vector and another one with given ratio + !#zh 线性插值。 + @param to to + @param ratio the interpolation coefficient + @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created + */ + lerp(to: Vec2, ratio: number, out?: Vec2): Vec2; + /** + !#en Clamp the vector between from float and to float. + !#zh + 返回指定限制区域后的向量。
+ 向量大于 max_inclusive 则返回 max_inclusive。
+ 向量小于 min_inclusive 则返回 min_inclusive。
+ 否则返回自身。 + @param min_inclusive min_inclusive + @param max_inclusive max_inclusive + + @example + ```js + var min_inclusive = cc.v2(0, 0); + var max_inclusive = cc.v2(20, 20); + var v1 = cc.v2(20, 20).clampf(min_inclusive, max_inclusive); // Vec2 {x: 20, y: 20}; + var v2 = cc.v2(0, 0).clampf(min_inclusive, max_inclusive); // Vec2 {x: 0, y: 0}; + var v3 = cc.v2(10, 10).clampf(min_inclusive, max_inclusive); // Vec2 {x: 10, y: 10}; + ``` + */ + clampf(min_inclusive: Vec2, max_inclusive: Vec2): Vec2; + /** + !#en Adds this vector. + !#zh 向量加法。 + @param vector vector + @param out out + + @example + ```js + var v = cc.v2(10, 10); + v.add(cc.v2(5, 5));// return Vec2 {x: 15, y: 15}; + ``` + */ + add(vector: Vec2, out?: Vec2): Vec2; + /** + !#en Adds this vector. If you want to save result to another vector, use add() instead. + !#zh 向量加法。如果你想保存结果到另一个向量,使用 add() 代替。 + @param vector vector + */ + addSelf(vector: Vec2): Vec2; + /** + !#en Subtracts one vector from this. + !#zh 向量减法。 + @param vector vector + + @example + ```js + var v = cc.v2(10, 10); + v.subSelf(cc.v2(5, 5));// return Vec2 {x: 5, y: 5}; + ``` + */ + subtract(vector: Vec2): Vec2; + /** + !#en Multiplies this by a number. + !#zh 缩放当前向量。 + @param num num + + @example + ```js + var v = cc.v2(10, 10); + v.multiply(5);// return Vec2 {x: 50, y: 50}; + ``` + */ + multiplyScalar(num: number): Vec2; + /** + !#en Multiplies two vectors. + !#zh 分量相乘。 + @param vector vector + + @example + ```js + var v = cc.v2(10, 10); + v.multiply(cc.v2(5, 5));// return Vec2 {x: 50, y: 50}; + ``` + */ + multiply(vector: Vec2): Vec2; + /** + !#en Divides by a number. + !#zh 向量除法。 + @param num num + + @example + ```js + var v = cc.v2(10, 10); + v.divide(5); // return Vec2 {x: 2, y: 2}; + ``` + */ + divide(num: number): Vec2; + /** + !#en Negates the components. + !#zh 向量取反。 + + @example + ```js + var v = cc.v2(10, 10); + v.negate(); // return Vec2 {x: -10, y: -10}; + ``` + */ + negate(): Vec2; + /** + !#en Dot product + !#zh 当前向量与指定向量进行点乘。 + @param vector vector + + @example + ```js + var v = cc.v2(10, 10); + v.dot(cc.v2(5, 5)); // return 100; + ``` + */ + dot(vector?: Vec2): number; + /** + !#en Cross product + !#zh 当前向量与指定向量进行叉乘。 + @param vector vector + + @example + ```js + var v = cc.v2(10, 10); + v.cross(cc.v2(5, 5)); // return 0; + ``` + */ + cross(vector?: Vec2): number; + /** + !#en Returns the length of this vector. + !#zh 返回该向量的长度。 + + @example + ```js + var v = cc.v2(10, 10); + v.len(); // return 14.142135623730951; + ``` + */ + len(): number; + /** + !#en Returns the squared length of this vector. + !#zh 返回该向量的长度平方。 + + @example + ```js + var v = cc.v2(10, 10); + v.lengthSqr(); // return 200; + ``` + */ + lengthSqr(): number; + /** + !#en Make the length of this vector to 1. + !#zh 向量归一化,让这个向量的长度为 1。 + + @example + ```js + var v = cc.v2(10, 10); + v.normalizeSelf(); // return Vec2 {x: 0.7071067811865475, y: 0.7071067811865475}; + ``` + */ + normalizeSelf(): Vec2; + /** + !#en + Returns this vector with a magnitude of 1.
+
+ Note that the current vector is unchanged and a new normalized vector is returned. If you want to normalize the current vector, use normalizeSelf function. + !#zh + 返回归一化后的向量。
+
+ 注意,当前向量不变,并返回一个新的归一化向量。如果你想来归一化当前向量,可使用 normalizeSelf 函数。 + @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created + */ + normalize(out?: Vec2): Vec2; + /** + !#en Get angle in radian between this and vector. + !#zh 夹角的弧度。 + @param vector vector + */ + angle(vector: Vec2): number; + /** + !#en Get angle in radian between this and vector with direction. + !#zh 带方向的夹角的弧度。 + @param vector vector + */ + signAngle(vector: Vec2): number; + /** + !#en rotate + !#zh 返回旋转给定弧度后的新向量。 + @param radians radians + @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created + */ + rotate(radians: number, out?: Vec2): Vec2; + /** + !#en rotate self + !#zh 按指定弧度旋转向量。 + @param radians radians + */ + rotateSelf(radians: number): Vec2; + /** + !#en Calculates the projection of the current vector over the given vector. + !#zh 返回当前向量在指定 vector 向量上的投影向量。 + @param vector vector + + @example + ```js + var v1 = cc.v2(20, 20); + var v2 = cc.v2(5, 5); + v1.project(v2); // Vec2 {x: 20, y: 20}; + ``` + */ + project(vector: Vec2): Vec2; + /** + Transforms the vec2 with a mat4. 3rd vector component is implicitly '0', 4th vector component is implicitly '1' + @param m matrix to transform with + @param out the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created + */ + transformMat4(m: Mat4, out?: Vec2): Vec2; + /** + Returns the maximum value in x, y. + */ + maxAxis(): number; + } + /** !#en Representation of 3D vectors and points. + !#zh 表示 3D 向量和坐标 */ + export class Vec3 extends ValueType { + /** + !#en Returns the length of this vector. + !#zh 返回该向量的长度。 + + @example + ```js + var v = cc.v3(10, 10, 10); + v.mag(); // return 17.320508075688775; + ``` + */ + mag(): number; + /** + !#en Returns the squared length of this vector. + !#zh 返回该向量的长度平方。 + */ + magSqr(): number; + /** + !#en Subtracts one vector from this. If you want to save result to another vector, use sub() instead. + !#zh 向量减法。如果你想保存结果到另一个向量,可使用 sub() 代替。 + @param vector vector + */ + subSelf(vector: Vec3): Vec3; + /** + !#en Subtracts one vector from this, and returns the new result. + !#zh 向量减法,并返回新结果。 + @param vector vector + @param out optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created + */ + sub(vector: Vec3, out?: Vec3): Vec3; + /** + !#en Multiplies this by a number. If you want to save result to another vector, use mul() instead. + !#zh 缩放当前向量。如果你想结果保存到另一个向量,可使用 mul() 代替。 + @param num num + */ + mulSelf(num: number): Vec3; + /** + !#en Multiplies by a number, and returns the new result. + !#zh 缩放向量,并返回新结果。 + @param num num + @param out optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created + */ + mul(num: number, out?: Vec3): Vec3; + /** + !#en Divides by a number. If you want to save result to another vector, use div() instead. + !#zh 向量除法。如果你想结果保存到另一个向量,可使用 div() 代替。 + @param num num + */ + divSelf(num: number): Vec3; + /** + !#en Divides by a number, and returns the new result. + !#zh 向量除法,并返回新的结果。 + @param num num + @param out optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created + */ + div(num: number, out?: Vec3): Vec3; + /** + !#en Multiplies two vectors. + !#zh 分量相乘。 + @param vector vector + */ + scaleSelf(vector: Vec3): Vec3; + /** + !#en Multiplies two vectors, and returns the new result. + !#zh 分量相乘,并返回新的结果。 + @param vector vector + @param out optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created + */ + scale(vector: Vec3, out?: Vec3): Vec3; + /** + !#en Negates the components. If you want to save result to another vector, use neg() instead. + !#zh 向量取反。如果你想结果保存到另一个向量,可使用 neg() 代替。 + */ + negSelf(): Vec3; + /** + !#en Negates the components, and returns the new result. + !#zh 返回取反后的新向量。 + @param out optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created + */ + neg(out?: Vec3): Vec3; + /** !#en return a Vec3 object with x = 1, y = 1, z = 1. + !#zh 新 Vec3 对象。 */ + static ONE: Vec3; + /** !#en return a Vec3 object with x = 0, y = 0, z = 0. + !#zh 返回 x = 0,y = 0,z = 0 的 Vec3 对象。 */ + static ZERO: Vec3; + /** !#en return a Vec3 object with x = 0, y = 1, z = 0. + !#zh 返回 x = 0, y = 1, z = 0 的 Vec3 对象。 */ + static UP: Vec3; + /** !#en return a Vec3 object with x = 1, y = 0, z = 0. + !#zh 返回 x = 1,y = 0,z = 0 的 Vec3 对象。 */ + static RIGHT: Vec3; + /** !#en return a Vec3 object with x = 0, y = 0, z = 1. + !#zh 返回 x = 0,y = 0,z = 1 的 Vec3 对象。 */ + static FORWARD: Vec3; + /** + !#zh 将目标赋值为零向量 + !#en The target of an assignment zero vector + */ + static zero (out: Out): Out; + /** + !#zh 获得指定向量的拷贝 + !#en Obtaining copy vectors designated + */ + static clone (a: Out): Vec3; + /** + !#zh 复制目标向量 + !#en Copy the target vector + */ + static copy (out: Out, a: Vec3Like): Out; + /** + !#zh 设置向量值 + !#en Set to value + */ + static set (out: Out, x: number, y: number, z: number): Out; + /** + !#zh 逐元素向量加法 + !#en Element-wise vector addition + */ + static add (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量减法 + !#en Element-wise vector subtraction + */ + static subtract (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量乘法 (分量积) + !#en Element-wise vector multiplication (product component) + */ + static multiply (out: Out, a: Vec3Like_1, b: Vec3Like_2): Out; + /** + !#zh 逐元素向量除法 + !#en Element-wise vector division + */ + static divide (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量向上取整 + !#en Rounding up by elements of the vector + */ + static ceil (out: Out, a: Out): Out; + /** + !#zh 逐元素向量向下取整 + !#en Element vector by rounding down + */ + static floor (out: Out, a: Out): Out; + /** + !#zh 逐元素向量最小值 + !#en The minimum by-element vector + */ + static min (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量最大值 + !#en The maximum value of the element-wise vector + */ + static max (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量四舍五入取整 + !#en Element-wise vector of rounding to whole + */ + static round (out: Out, a: Out): Out; + /** + !#zh 向量标量乘法 + !#en Vector scalar multiplication + */ + static multiplyScalar (out: Out, a: Vec3Like, b: number): Out; + /** + !#zh 逐元素向量乘加: A + B * scale + !#en Element-wise vector multiply add: A + B * scale + */ + static scaleAndAdd (out: Out, a: Out, b: Out, scale: number): Out; + /** + !#zh 求两向量的欧氏距离 + !#en Seeking two vectors Euclidean distance + */ + static distance (a: Out, b: Out): number; + /** + !#zh 求两向量的欧氏距离平方 + !#en Euclidean distance squared seeking two vectors + */ + static squaredDistance (a: Out, b: Out): number; + /** + !#zh 求向量长度 + !#en Seeking vector length + */ + static len (a: Out): number; + /** + !#zh 求向量长度平方 + !#en Seeking squared vector length + */ + static lengthSqr (a: Out): number; + /** + !#zh 逐元素向量取负 + !#en By taking the negative elements of the vector + */ + static negate (out: Out, a: Out): Out; + /** + !#zh 逐元素向量取倒数,接近 0 时返回 Infinity + !#en Element vector by taking the inverse, return near 0 Infinity + */ + static inverse (out: Out, a: Out): Out; + /** + !#zh 逐元素向量取倒数,接近 0 时返回 0 + !#en Element vector by taking the inverse, return near 0 0 + */ + static inverseSafe (out: Out, a: Out): Out; + /** + !#zh 归一化向量 + !#en Normalized vector + */ + static normalize (out: Out, a: Vec3Like): Out; + /** + !#zh 向量点积(数量积) + !#en Vector dot product (scalar product) + */ + static dot (a: Out, b: Out): number; + /** + !#zh 向量叉积(向量积) + !#en Vector cross product (vector product) + */ + static cross (out: Out, a: Vec3Like_1, b: Vec3Like_2): Out; + /** + !#zh 逐元素向量线性插值: A + t * (B - A) + !#en Vector element by element linear interpolation: A + t * (B - A) + */ + static lerp (out: Out, a: Out, b: Out, t: number): Out; + /** + !#zh 生成一个在单位球体上均匀分布的随机向量 + !#en Generates a uniformly distributed random vectors on the unit sphere + @param scale 生成的向量长度 + */ + static random (out: Out, scale?: number): Out; + /** + !#zh 向量与四维矩阵乘法,默认向量第四位为 1。 + !#en Four-dimensional vector and matrix multiplication, the default vectors fourth one. + */ + static transformMat4 (out: Out, a: Vec3Like, mat: MatLike): Out; + /** + !#zh 向量与四维矩阵乘法,默认向量第四位为 0。 + !#en Four-dimensional vector and matrix multiplication, vector fourth default is 0. + */ + static transformMat4Normal (out: Out, a: Out, mat: MatLike): Out; + /** + !#zh 向量与三维矩阵乘法 + !#en Dimensional vector matrix multiplication + */ + static transformMat3 (out: Out, a: Out, mat: MatLike): Out; + /** + !#zh 向量仿射变换 + !#en Affine transformation vector + */ + static transformAffine(out: Out, v: VecLike, mat: MatLike): Out; + /** + !#zh 向量四元数乘法 + !#en Vector quaternion multiplication + */ + static transformQuat (out: Out, a: VecLike, q: QuatLike): Out; + /** + !#zh 以缩放 -> 旋转 -> 平移顺序变换向量 + !#en To scale -> rotation -> transformation vector sequence translation + */ + static transformRTS(out: Out, a: VecLike, r: QuatLike, t: VecLike, s: VecLike): Out; + /** + !#zh 以平移 -> 旋转 -> 缩放顺序逆变换向量 + !#en Translational -> rotation -> Zoom inverse transformation vector sequence + */ + static transformInverseRTS(out: Out, a: VecLike, r: QuatLike, t: VecLike, s: VecLike): Out; + /** + !#zh 绕 X 轴旋转向量指定弧度 + !#en Rotation vector specified angle about the X axis + @param v 待旋转向量 + @param o 旋转中心 + @param a 旋转弧度 + */ + static rotateX (out: Out, v: Out, o: Out, a: number): Out; + /** + !#zh 绕 Y 轴旋转向量指定弧度 + !#en Rotation vector specified angle around the Y axis + @param v 待旋转向量 + @param o 旋转中心 + @param a 旋转弧度 + */ + static rotateY (out: Out, v: Out, o: Out, a: number): Out; + /** + !#zh 绕 Z 轴旋转向量指定弧度 + !#en Around the Z axis specified angle vector + @param v 待旋转向量 + @param o 旋转中心 + @param a 旋转弧度 + */ + static rotateZ (out: Out, v: Out, o: Out, a: number): Out; + /** + !#zh 向量等价判断 + !#en Equivalent vectors Analyzing + */ + static strictEquals (a: Out, b: Out): boolean; + /** + !#zh 排除浮点数误差的向量近似等价判断 + !#en Negative error vector floating point approximately equivalent Analyzing + */ + static equals (a: Out, b: Out, epsilon?: number): boolean; + /** + !#zh 求两向量夹角弧度 + !#en Radian angle between two vectors seek + */ + static angle (a: Out, b: Out): number; + /** + !#zh 计算向量在指定平面上的投影 + !#en Calculating a projection vector in the specified plane + @param a 待投影向量 + @param n 指定平面的法线 + */ + static projectOnPlane (out: Out, a: Out, n: Out): Out; + /** + !#zh 计算向量在指定向量上的投影 + !#en Projection vector calculated in the vector designated + @param a 待投影向量 + @param n 目标向量 + */ + static project (out: Out, a: Out, b: Out): Out; + /** + !#zh 向量转数组 + !#en Vector transfer array + @param ofs 数组起始偏移量 + */ + static toArray > (out: Out, v: IVec3Like, ofs?: number): Out; + /** + !#zh 数组转向量 + !#en Array steering amount + @param ofs 数组起始偏移量 + */ + static fromArray (out: Out, arr: IWritableArrayLike, ofs?: number): Out; + x: number; + y: number; + z: number; + /** + !#en + Constructor + see {{#crossLink "cc/vec3:method"}}cc.v3{{/crossLink}} + !#zh + 构造函数,可查看 {{#crossLink "cc/vec3:method"}}cc.v3{{/crossLink}} + @param x x + @param y y + @param z z + */ + constructor(x?: Vec3|number, y?: number, z?: number); + /** + !#en clone a Vec3 value + !#zh 克隆一个 Vec3 值 + */ + clone(): Vec3; + /** + !#en Set the current vector value with the given vector. + !#zh 用另一个向量设置当前的向量对象值。 + @param newValue !#en new value to set. !#zh 要设置的新值 + */ + set(newValue: Vec3): Vec3; + /** + !#en Check whether the vector equals another one + !#zh 当前的向量是否与指定的向量相等。 + @param other other + */ + equals(other: Vec3): boolean; + /** + !#en Check whether two vector equal with some degree of variance. + !#zh + 近似判断两个点是否相等。
+ 判断 2 个向量是否在指定数值的范围之内,如果在则返回 true,反之则返回 false。 + @param other other + @param variance variance + */ + fuzzyEquals(other: Vec3, variance: number): boolean; + /** + !#en Transform to string with vector informations + !#zh 转换为方便阅读的字符串。 + */ + toString(): string; + /** + !#en Calculate linear interpolation result between this vector and another one with given ratio + !#zh 线性插值。 + @param to to + @param ratio the interpolation coefficient + @param out optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created + */ + lerp(to: Vec3, ratio: number, out?: Vec3): Vec3; + /** + !#en Clamp the vector between from float and to float. + !#zh + 返回指定限制区域后的向量。
+ 向量大于 max_inclusive 则返回 max_inclusive。
+ 向量小于 min_inclusive 则返回 min_inclusive。
+ 否则返回自身。 + @param min_inclusive min_inclusive + @param max_inclusive max_inclusive + */ + clampf(min_inclusive: Vec3, max_inclusive: Vec3): Vec3; + /** + !#en Adds this vector. If you want to save result to another vector, use add() instead. + !#zh 向量加法。如果你想保存结果到另一个向量,使用 add() 代替。 + @param vector vector + */ + addSelf(vector: Vec3): Vec3; + /** + !#en Adds two vectors, and returns the new result. + !#zh 向量加法,并返回新结果。 + @param vector vector + @param out optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created + */ + add(vector: Vec3, out?: Vec3): Vec3; + /** + !#en Subtracts one vector from this. + !#zh 向量减法。 + @param vector vector + */ + subtract(vector: Vec3): Vec3; + /** + !#en Multiplies this by a number. + !#zh 缩放当前向量。 + @param num num + */ + multiplyScalar(num: number): Vec3; + /** + !#en Multiplies two vectors. + !#zh 分量相乘。 + @param vector vector + */ + multiply(vector: Vec3): Vec3; + /** + !#en Divides by a number. + !#zh 向量除法。 + @param num num + */ + divide(num: number): Vec3; + /** + !#en Negates the components. + !#zh 向量取反。 + */ + negate(): Vec3; + /** + !#en Dot product + !#zh 当前向量与指定向量进行点乘。 + @param vector vector + */ + dot(vector?: Vec3): number; + /** + !#en Cross product + !#zh 当前向量与指定向量进行叉乘。 + @param vector vector + @param out out + */ + cross(vector: Vec3, out?: Vec3): Vec3; + /** + !#en Returns the length of this vector. + !#zh 返回该向量的长度。 + + @example + ```js + var v = cc.v3(10, 10, 10); + v.len(); // return 17.320508075688775; + ``` + */ + len(): number; + /** + !#en Returns the squared length of this vector. + !#zh 返回该向量的长度平方。 + */ + lengthSqr(): number; + /** + !#en Make the length of this vector to 1. + !#zh 向量归一化,让这个向量的长度为 1。 + */ + normalizeSelf(): Vec3; + /** + !#en + Returns this vector with a magnitude of 1.
+
+ Note that the current vector is unchanged and a new normalized vector is returned. If you want to normalize the current vector, use normalizeSelf function. + !#zh + 返回归一化后的向量。
+
+ 注意,当前向量不变,并返回一个新的归一化向量。如果你想来归一化当前向量,可使用 normalizeSelf 函数。 + @param out optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created + */ + normalize(out?: Vec3): Vec3; + /** + Transforms the vec3 with a mat4. 4th vector component is implicitly '1' + @param m matrix to transform with + @param out the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created + */ + transformMat4(m: Mat4, out?: Vec3): Vec3; + /** + Returns the maximum value in x, y, and z + */ + maxAxis(): number; + /** + !#en Get angle in radian between this and vector. + !#zh 夹角的弧度。 + @param vector vector + */ + angle(vector: Vec3): number; + /** + !#en Calculates the projection of the current vector over the given vector. + !#zh 返回当前向量在指定 vector 向量上的投影向量。 + @param vector vector + + @example + ```js + var v1 = cc.v3(20, 20, 20); + var v2 = cc.v3(5, 5, 5); + v1.project(v2); // Vec3 {x: 20, y: 20, z: 20}; + ``` + */ + project(vector: Vec3): Vec3; + /** + !#en Get angle in radian between this and vector with direction.
+ In order to compatible with the vec2 API. + !#zh 带方向的夹角的弧度。该方法仅用做兼容 2D 计算。 + @param vector vector + */ + signAngle(vector: Vec3|Vec2): number; + /** + !#en rotate. In order to compatible with the vec2 API. + !#zh 返回旋转给定弧度后的新向量。该方法仅用做兼容 2D 计算。 + @param radians radians + @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created + */ + rotate(radians: number, out?: Vec3): Vec2; + /** + !#en rotate self. In order to compatible with the vec2 API. + !#zh 按指定弧度旋转向量。该方法仅用做兼容 2D 计算。 + @param radians radians + */ + rotateSelf(radians: number): Vec3; + } + /** !#en Representation of 3D vectors and points. + !#zh 表示 3D 向量和坐标 */ + export class Vec4 extends ValueType { + /** + !#en Subtracts one vector from this. If you want to save result to another vector, use sub() instead. + !#zh 向量减法。如果你想保存结果到另一个向量,可使用 sub() 代替。 + @param vector vector + */ + subSelf(vector: Vec4): Vec4; + /** + !#en Subtracts one vector from this, and returns the new result. + !#zh 向量减法,并返回新结果。 + @param vector vector + @param out optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created + */ + sub(vector: Vec4, out?: Vec4): Vec4; + /** + !#en Multiplies this by a number. If you want to save result to another vector, use mul() instead. + !#zh 缩放当前向量。如果你想结果保存到另一个向量,可使用 mul() 代替。 + @param num num + */ + mulSelf(num: number): Vec4; + /** + !#en Multiplies by a number, and returns the new result. + !#zh 缩放向量,并返回新结果。 + @param num num + @param out optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created + */ + mul(num: number, out?: Vec4): Vec4; + /** + !#en Divides by a number. If you want to save result to another vector, use div() instead. + !#zh 向量除法。如果你想结果保存到另一个向量,可使用 div() 代替。 + @param num num + */ + divSelf(num: number): Vec4; + /** + !#en Divides by a number, and returns the new result. + !#zh 向量除法,并返回新的结果。 + @param num num + @param out optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created + */ + div(num: number, out?: Vec4): Vec4; + /** + !#en Multiplies two vectors. + !#zh 分量相乘。 + @param vector vector + */ + scaleSelf(vector: Vec4): Vec4; + /** + !#en Multiplies two vectors, and returns the new result. + !#zh 分量相乘,并返回新的结果。 + @param vector vector + @param out optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created + */ + scale(vector: Vec4, out?: Vec4): Vec4; + /** + !#en Negates the components. If you want to save result to another vector, use neg() instead. + !#zh 向量取反。如果你想结果保存到另一个向量,可使用 neg() 代替。 + */ + negSelf(): Vec4; + /** + !#en Negates the components, and returns the new result. + !#zh 返回取反后的新向量。 + @param out optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created + */ + neg(out?: Vec4): Vec4; + /** + !#zh 获得指定向量的拷贝 + !#en Obtaining copy vectors designated + */ + static clone (a: Out): Vec4; + /** + !#zh 复制目标向量 + !#en Copy the target vector + */ + static copy (out: Out, a: Out): Out; + /** + !#zh 设置向量值 + !#en Set to value + */ + static set (out: Out, x: number, y: number, z: number, w: number): Out; + /** + !#zh 逐元素向量加法 + !#en Element-wise vector addition + */ + static add (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量减法 + !#en Element-wise vector subtraction + */ + static subtract (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量乘法 + !#en Element-wise vector multiplication + */ + static multiply (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量除法 + !#en Element-wise vector division + */ + static divide (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量向上取整 + !#en Rounding up by elements of the vector + */ + static ceil (out: Out, a: Out): Out; + /** + !#zh 逐元素向量向下取整 + !#en Element vector by rounding down + */ + static floor (out: Out, a: Out): Out; + /** + !#zh 逐元素向量最小值 + !#en The minimum by-element vector + */ + static min (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量最大值 + !#en The maximum value of the element-wise vector + */ + static max (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量四舍五入取整 + !#en Element-wise vector of rounding to whole + */ + static round (out: Out, a: Out): Out; + /** + !#zh 向量标量乘法 + !#en Vector scalar multiplication + */ + static multiplyScalar (out: Out, a: Out, b: number): Out; + /** + !#zh 逐元素向量乘加: A + B * scale + !#en Element-wise vector multiply add: A + B * scale + */ + static scaleAndAdd (out: Out, a: Out, b: Out, scale: number): Out; + /** + !#zh 求两向量的欧氏距离 + !#en Seeking two vectors Euclidean distance + */ + static distance (a: Out, b: Out): number; + /** + !#zh 求两向量的欧氏距离平方 + !#en Euclidean distance squared seeking two vectors + */ + static squaredDistance (a: Out, b: Out): number; + /** + !#zh 求向量长度 + !#en Seeking vector length + */ + static len (a: Out): number; + /** + !#zh 求向量长度平方 + !#en Seeking squared vector length + */ + static lengthSqr (a: Out): number; + /** + !#zh 逐元素向量取负 + !#en By taking the negative elements of the vector + */ + static negate (out: Out, a: Out): Out; + /** + !#zh 逐元素向量取倒数,接近 0 时返回 Infinity + !#en Element vector by taking the inverse, return near 0 Infinity + */ + static inverse (out: Out, a: Out): Out; + /** + !#zh 逐元素向量取倒数,接近 0 时返回 0 + !#en Element vector by taking the inverse, return near 0 0 + */ + static inverseSafe (out: Out, a: Out): Out; + /** + !#zh 归一化向量 + !#en Normalized vector + */ + static normalize (out: Out, a: Out): Out; + /** + !#zh 向量点积(数量积) + !#en Vector dot product (scalar product) + */ + static dot (a: Out, b: Out): number; + /** + !#zh 逐元素向量线性插值: A + t * (B - A) + !#en Vector element by element linear interpolation: A + t * (B - A) + */ + static lerp (out: Out, a: Out, b: Out, t: number): Out; + /** + !#zh 生成一个在单位球体上均匀分布的随机向量 + !#en Generates a uniformly distributed random vectors on the unit sphere + @param scale 生成的向量长度 + */ + static random (out: Out, scale?: number): Out; + /** + !#zh 向量矩阵乘法 + !#en Vector matrix multiplication + */ + static transformMat4 (out: Out, a: Out, mat: MatLike): Out; + /** + !#zh 向量仿射变换 + !#en Affine transformation vector + */ + static transformAffine(out: Out, v: VecLike, mat: MatLike): Out; + /** + !#zh 向量四元数乘法 + !#en Vector quaternion multiplication + */ + static transformQuat (out: Out, a: Out, q: QuatLike): Out; + /** + !#zh 向量等价判断 + !#en Equivalent vectors Analyzing + */ + static strictEquals (a: Out, b: Out): boolean; + /** + !#zh 排除浮点数误差的向量近似等价判断 + !#en Negative error vector floating point approximately equivalent Analyzing + */ + static equals (a: Out, b: Out, epsilon?: number): boolean; + /** + !#zh 向量转数组 + !#en Vector transfer array + @param ofs 数组起始偏移量 + */ + static toArray > (out: Out, v: IVec4Like, ofs?: number): Out; + /** + !#zh 数组转向量 + !#en Array steering amount + @param ofs 数组起始偏移量 + */ + static fromArray (out: Out, arr: IWritableArrayLike, ofs?: number): Out; + x: number; + y: number; + z: number; + w: number; + /** + !#en + Constructor + see {{#crossLink "cc/vec4:method"}}cc.v4{{/crossLink}} + !#zh + 构造函数,可查看 {{#crossLink "cc/vec4:method"}}cc.v4{{/crossLink}} + @param x x + @param y y + @param z z + @param w w + */ + constructor(x?: number, y?: number, z?: number, w?: number); + /** + !#en clone a Vec4 value + !#zh 克隆一个 Vec4 值 + */ + clone(): Vec4; + /** + !#en Set the current vector value with the given vector. + !#zh 用另一个向量设置当前的向量对象值。 + @param newValue !#en new value to set. !#zh 要设置的新值 + */ + set(newValue: Vec4): Vec4; + /** + !#en Check whether the vector equals another one + !#zh 当前的向量是否与指定的向量相等。 + @param other other + @param epsilon epsilon + */ + equals(other: Vec4, epsilon?: number): boolean; + /** + !#en Check whether the vector equals another one + !#zh 判断当前向量是否在误差范围内与指定分量的向量相等。 + @param x 相比较的向量的 x 分量。 + @param y 相比较的向量的 y 分量。 + @param z 相比较的向量的 z 分量。 + @param w 相比较的向量的 w 分量。 + @param epsilon 允许的误差,应为非负数。 + */ + equals4f(x: number, y: number, z: number, w: number, epsilon?: number): boolean; + /** + !#en Check whether strict equals other Vec4 + !#zh 判断当前向量是否与指定向量相等。两向量的各分量都分别相等时返回 `true`;否则返回 `false`。 + @param other 相比较的向量。 + */ + strictEquals(other: Vec4): boolean; + /** + !#en Check whether strict equals other Vec4 + !#zh 判断当前向量是否与指定分量的向量相等。两向量的各分量都分别相等时返回 `true`;否则返回 `false`。 + @param x 指定向量的 x 分量。 + @param y 指定向量的 y 分量。 + @param z 指定向量的 z 分量。 + @param w 指定向量的 w 分量。 + */ + strictEquals4f(x: number, y: number, z: number, w: number): boolean; + /** + !#en Calculate linear interpolation result between this vector and another one with given ratio + !#zh 根据指定的插值比率,从当前向量到目标向量之间做插值。 + @param to 目标向量。 + @param ratio 插值比率,范围为 [0,1]。 + */ + lerp(to: Vec4, ratio: number): Vec4; + /** + !#en Transform to string with vector informations + !#zh 返回当前向量的字符串表示。 + */ + toString(): string; + /** + !#en Clamp the vector between minInclusive and maxInclusive. + !#zh 设置当前向量的值,使其各个分量都处于指定的范围内。 + @param minInclusive 每个分量都代表了对应分量允许的最小值。 + @param maxInclusive 每个分量都代表了对应分量允许的最大值。 + */ + clampf(minInclusive: Vec4, maxInclusive: Vec4): Vec4; + /** + !#en Adds this vector. If you want to save result to another vector, use add() instead. + !#zh 向量加法。如果你想保存结果到另一个向量,使用 add() 代替。 + @param vector vector + */ + addSelf(vector: Vec4): Vec4; + /** + !#en Adds two vectors, and returns the new result. + !#zh 向量加法,并返回新结果。 + @param vector vector + @param out optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created + */ + add(vector: Vec4, out?: Vec4): Vec4; + /** + !#en Subtracts one vector from this, and returns the new result. + !#zh 向量减法,并返回新结果。 + @param vector vector + @param out optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created + */ + subtract(vector: Vec4, out?: Vec4): Vec4; + /** + !#en Multiplies this by a number. + !#zh 缩放当前向量。 + @param num num + */ + multiplyScalar(num: number): Vec4; + /** + !#en Multiplies two vectors. + !#zh 分量相乘。 + @param vector vector + */ + multiply(vector: Vec4): Vec4; + /** + !#en Divides by a number. + !#zh 向量除法。 + @param num num + */ + divide(num: number): Vec4; + /** + !#en Negates the components. + !#zh 向量取反 + */ + negate(): Vec4; + /** + !#en Dot product + !#zh 当前向量与指定向量进行点乘。 + @param vector vector + */ + dot(vector?: Vec4): number; + /** + !#en Cross product + !#zh 当前向量与指定向量进行叉乘。 + @param vector vector + @param out out + */ + cross(vector: Vec4, out?: Vec4): Vec4; + /** + !#en Returns the length of this vector. + !#zh 返回该向量的长度。 + + @example + ```js + var v = cc.v4(10, 10); + v.len(); // return 14.142135623730951; + ``` + */ + len(): number; + /** + !#en Returns the squared length of this vector. + !#zh 返回该向量的长度平方。 + */ + lengthSqr(): number; + /** + !#en Make the length of this vector to 1. + !#zh 向量归一化,让这个向量的长度为 1。 + */ + normalizeSelf(): Vec4; + /** + !#en + Returns this vector with a magnitude of 1.
+
+ Note that the current vector is unchanged and a new normalized vector is returned. If you want to normalize the current vector, use normalizeSelf function. + !#zh + 返回归一化后的向量。
+
+ 注意,当前向量不变,并返回一个新的归一化向量。如果你想来归一化当前向量,可使用 normalizeSelf 函数。 + @param out optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created + */ + normalize(out?: Vec4): Vec4; + /** + Transforms the vec4 with a mat4. 4th vector component is implicitly '1' + @param m matrix to transform with + @param out the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created + */ + transformMat4(m: Mat4, out?: Vec4): Vec4; + /** + Returns the maximum value in x, y, z, w. + */ + maxAxis(): number; + } + /** !#en . + !#zh 。 */ + export class SkeletonAnimation extends Animation { + } + /** !#en SkeletonAnimationClip Asset. + !#zh 骨骼动画剪辑。 */ + export class SkeletonAnimationClip extends AnimationClip { + } + /** !#en + Skinned Mesh Renderer + !#zh + 蒙皮渲染组件 */ + export class SkinnedMeshRenderer extends MeshRenderer { + /** !#en + Skeleton Asset + !#zh + 骨骼资源 */ + skeleton: sp.Skeleton; + /** !#en + Root Bone + !#zh + 骨骼根节点 */ + rootBone: Node; + } + /** !#en The animation curve of 3d particle. + !#zh 3D 粒子动画曲线 */ + export class AnimationCurve { + /** !#en Array of key value. + !#zh 关键值列表。 */ + keyFrames: Keyframe[]; + /** !#en Pre-wrap mode. + !#zh 前置循环模式。 */ + preWrapMode: WrapMode; + /** !#en Post-wrap mode. + !#zh 后置循环模式。 */ + postWrapMode: WrapMode; + } + /** !#en The burst of 3d particle. + !#zh 3D 粒子发射时的爆发个数 */ + export class Burst { + /** !#en Time between the start of the particle system and the trigger of this Brust + !#zh 粒子系统开始运行到触发此次 Brust 的时间 */ + time: number; + /** !#en Minimum number of emitted particles + !#zh 发射粒子的最小数量 */ + minCount: number; + /** !#en Maximum number of emitted particles + !#zh 发射粒子的最大数量 */ + maxCount: number; + /** !#en The number of times Burst was triggered. + !#zh Burst 的触发次数 */ + repeatCount: number; + /** !#en Interval of each trigger + !#zh 每次触发的间隔时间 */ + repeatInterval: number; + /** !#en Number of particles emitted + !#zh 发射的粒子的数量 */ + count: CurveRange; + } + /** !#en The ParticleSystem3D Component. + !#zh 3D 粒子组件 */ + export class ParticleSystem3D extends RenderComponent { + /** !#en The run time of particle. + !#zh 粒子系统运行时间 */ + duration: number; + /** !#en The maximum number of particles that a particle system can generate. + !#zh 粒子系统能生成的最大粒子数量 */ + capacity: number; + /** !#en Whether the particle system loops. + !#zh 粒子系统是否循环播放 */ + loop: boolean; + /** !#en Whether the particles start playing automatically after loaded. + !#zh 粒子系统加载后是否自动开始播放 */ + playOnAwake: boolean; + /** !#en When selected, the particle system will start playing after one round has been played (only effective when loop is enabled). + !#zh 选中之后,粒子系统会以已播放完一轮之后的状态开始播放(仅当循环播放启用时有效) */ + prewarm: boolean; + /** !#en The coordinate system in which the particle system is located.
+ World coordinates (does not change when the position of other objects changes)
+ Local coordinates (moving as the position of the parent node changes)
+ Custom coordinates (moving with the position of a custom node) + !#zh 选择粒子系统所在的坐标系
+ 世界坐标(不随其他物体位置改变而变换)
+ 局部坐标(跟随父节点位置改变而移动)
+ 自定坐标(跟随自定义节点的位置改变而移动) */ + simulationSpace: ParticleSystem3DAssembler.Space; + /** !#en Controlling the update speed of the entire particle system. + !#zh 控制整个粒子系统的更新速度。 */ + simulationSpeed: number; + /** !#en Delay particle emission time after particle system starts running. + !#zh 粒子系统开始运行后,延迟粒子发射的时间。 */ + startDelay: CurveRange; + /** !#en Particle life cycle。 + !#zh 粒子生命周期。 */ + startLifetime: CurveRange; + /** !#en Particle initial color + !#zh 粒子初始颜色 */ + startColor: GradientRange; + /** !#en Particle scale space + !#zh 缩放空间 */ + scaleSpace: ParticleSystem3DAssembler.Space; + /** !#en Initial particle size + !#zh 粒子初始大小 */ + startSize: CurveRange; + /** !#en Initial particle speed + !#zh 粒子初始速度 */ + startSpeed: CurveRange; + /** !#en Particle initial rotation angle + !#zh 粒子初始旋转角度 */ + startRotation: CurveRange; + /** !#en Gravity coefficient of particles affected by gravity + !#zh 粒子受重力影响的重力系数 */ + gravityModifier: CurveRange; + /** !#en Particles emitted per second + !#zh 每秒发射的粒子数 */ + rateOverTime: CurveRange; + /** !#en Number of particles emitted per unit distance moved + !#zh 每移动单位距离发射的粒子数 */ + rateOverDistance: CurveRange; + /** !#en The number of Brusts that emit a specified number of particles at a specified time + !#zh 设定在指定时间发射指定数量的粒子的 Brust 的数量 */ + bursts: Burst[]; + /** !#en Particle emitter module + !#zh 粒子发射器模块 */ + shapeModule: ShapeModule; + /** !#en Color control module + !#zh 颜色控制模块 */ + colorOverLifetimeModule: ColorOverLifetimeModule; + /** !#en Particle size module + !#zh 粒子大小模块 */ + sizeOvertimeModule: SizeOvertimeModule; + /** !#en Particle speed module + !#zh 粒子速度模块 */ + velocityOvertimeModule: VelocityOvertimeModule; + /** !#en Particle acceleration module + !#zh 粒子加速度模块 */ + forceOvertimeModule: ForceOvertimeModule; + /** !#en Particle limit speed module (only CPU particles are supported) + !#zh 粒子限制速度模块(只支持 CPU 粒子) */ + limitVelocityOvertimeModule: LimitVelocityOvertimeModule; + /** !#en Particle rotation module + !#zh 粒子旋转模块 */ + rotationOvertimeModule: RotationOvertimeModule; + /** !#en Texture Animation Module + !#zh 贴图动画模块 */ + textureAnimationModule: TextureAnimationModule; + /** !#en Particle Trajectory Module + !#zh 粒子轨迹模块 */ + trailModule: TrailModule; + /** !#en Particle generation mode + !#zh 设定粒子生成模式 */ + renderMode: ParticleSystem3DAssembler.RenderMode; + /** !#en When the particle generation mode is StrecthedBillboard, in the direction of movement of the particles is stretched by velocity magnitude + !#zh 在粒子生成方式为 StrecthedBillboard 时,对粒子在运动方向上按速度大小进行拉伸 */ + velocityScale: number; + /** !#en When the particle generation method is StrecthedBillboard, the particles are stretched according to the particle size in the direction of motion + !#zh 在粒子生成方式为 StrecthedBillboard 时,对粒子在运动方向上按粒子大小进行拉伸 */ + lengthScale: number; + /** !#en Particle model + !#zh 粒子模型 */ + mesh: Mesh; + /** !#en Particle material + !#zh 粒子材质 */ + particleMaterial: Material; + /** !#en Particle trail material + !#zh 粒子轨迹材质 */ + trailMaterial: Material; + /** + !#en Playing particle effects + !#zh 播放粒子效果 + */ + play(): void; + /** + !#en Pause particle effect + !#zh 暂停播放粒子效果 + */ + pause(): void; + /** + !#en Stop particle effect + !#zh 停止播放粒子效果 + */ + stop(): void; + /** + !#en Remove all particle effect + !#zh 将所有粒子从粒子系统中清除 + */ + clear(): void; + } + /** !#en + Helper class for ES5 Map. + !#zh + ES5 Map 辅助类。 */ + export class MapUtils { + } + /** !#en Effect Asset. + !#zh Effect 资源类型。 */ + export class EffectAsset extends Asset { + } + /** !#en Material Asset. + !#zh 材质资源类。 */ + export class Material extends Asset { + /** + !#en Get built-in materials + !#zh 获取内置材质 + @param name name + */ + static getBuiltinMaterial(name: string): Material; + /** + !#en Creates a Material with builtin Effect. + !#zh 使用内建 Effect 创建一个材质。 + @param effectName effectName + @param techniqueIndex techniqueIndex + */ + static createWithBuiltin(effectName: string, techniqueIndex?: number): Material; + /** + !#en Creates a Material. + !#zh 创建一个材质。 + @param effectAsset effectAsset + @param techniqueIndex techniqueIndex + */ + static create(effectAsset: EffectAsset, techniqueIndex?: number): Material; + /** + !#en Sets the Material property + !#zh 设置材质的属性 + @param name name + @param val val + @param passIdx passIdx + @param directly directly + */ + setProperty(name: string, val: any, passIdx?: number, directly?: boolean): void; + /** + !#en Gets the Material property. + !#zh 获取材质的属性。 + @param name name + @param passIdx passIdx + */ + getProperty(name: string, passIdx: number): any; + /** + !#en Sets the Material define. + !#zh 设置材质的宏定义。 + @param name name + @param val val + @param passIdx passIdx + @param force force + */ + define(name: string, val: boolean|number, passIdx?: number, force?: boolean): void; + /** + !#en Gets the Material define. + !#zh 获取材质的宏定义。 + @param name name + @param passIdx passIdx + */ + getDefine(name: string, passIdx?: number): boolean; + /** + !#en Sets the Material cull mode. + !#zh 设置材质的裁减模式。 + @param cullMode cullMode + @param passIdx passIdx + */ + setCullMode(cullMode: number, passIdx: number): void; + /** + !#en Sets the Material depth states. + !#zh 设置材质的深度渲染状态。 + @param depthTest depthTest + @param depthWrite depthWrite + @param depthFunc depthFunc + @param passIdx passIdx + */ + setDepth(depthTest: boolean, depthWrite: boolean, depthFunc: number, passIdx: number): void; + /** + !#en Sets the Material blend states. + !#zh 设置材质的混合渲染状态。 + @param enabled enabled + @param blendEq blendEq + @param blendSrc blendSrc + @param blendDst blendDst + @param blendAlphaEq blendAlphaEq + @param blendSrcAlpha blendSrcAlpha + @param blendDstAlpha blendDstAlpha + @param blendColor blendColor + @param passIdx passIdx + */ + setBlend(enabled: boolean, blendEq: number, blendSrc: number, blendDst: number, blendAlphaEq: number, blendSrcAlpha: number, blendDstAlpha: number, blendColor: number, passIdx: number): void; + /** + !#en Sets whether enable the stencil test. + !#zh 设置是否开启模板测试。 + @param stencilTest stencilTest + @param passIdx passIdx + */ + setStencilEnabled(stencilTest: number, passIdx: number): void; + /** + !#en Sets the Material stencil render states. + !#zh 设置材质的模板测试渲染参数。 + @param stencilTest stencilTest + @param stencilFunc stencilFunc + @param stencilRef stencilRef + @param stencilMask stencilMask + @param stencilFailOp stencilFailOp + @param stencilZFailOp stencilZFailOp + @param stencilZPassOp stencilZPassOp + @param stencilWriteMask stencilWriteMask + @param passIdx passIdx + */ + setStencil(stencilTest: number, stencilFunc: number, stencilRef: number, stencilMask: number, stencilFailOp: number, stencilZFailOp: number, stencilZPassOp: number, stencilWriteMask: number, passIdx: number): void; + } + /** !#en + Material Variant is an extension of the Material Asset. + Changes to Material Variant do not affect other Material Variant or Material Asset, + and changes to Material Asset are synchronized to the Material Variant. + However, when a Material Variant had already modifies a state, the Material Asset state is not synchronized to the Material Variant. + !#zh + 材质变体是材质资源的一个延伸。 + 材质变体的修改不会影响到其他的材质变体或者材质资源,而材质资源的修改会同步体现到材质变体上, + 但是当材质变体对一个状态修改后,材质资源再对这个状态修改是不会同步到材质变体上的。 */ + export class MaterialVariant extends Material { + /** + + @param materialName materialName + @param owner owner + */ + static createWithBuiltin (materialName: string, owner: cc.RenderComponent): MaterialVariant | null; + /** + + @param material material + @param owner owner + */ + static create (material: Material, owner: cc.RenderComponent): MaterialVariant | null; + } + /** !#en cc.EditBox is a component for inputing text, you can use it to gather small amounts of text from users. + !#zh EditBox 组件,用于获取用户的输入文本。 */ + export class EditBox extends Component { + /** !#en Input string of EditBox. + !#zh 输入框的初始输入内容,如果为空则会显示占位符的文本。 */ + string: string; + /** !#en The Label component attached to the node for EditBox's input text label + !#zh 输入框输入文本节点上挂载的 Label 组件对象 */ + textLabel: Label; + /** !#en The Label component attached to the node for EditBox's placeholder text label + !#zh 输入框占位符节点上挂载的 Label 组件对象 */ + placeholderLabel: Label; + /** !#en The Sprite component attached to the node for EditBox's background + !#zh 输入框背景节点上挂载的 Sprite 组件对象 */ + background: Sprite; + /** !#en The background image of EditBox. This property will be removed in the future, use editBox.background instead please. + !#zh 输入框的背景图片。 该属性会在将来的版本中移除,请用 editBox.background */ + backgroundImage: SpriteFrame; + /** !#en + The return key type of EditBox. + Note: it is meaningless for web platforms and desktop platforms. + !#zh + 指定移动设备上面回车按钮的样式。 + 注意:这个选项对 web 平台与 desktop 平台无效。 */ + returnType: EditBox.KeyboardReturnType; + /** !#en Set the input flags that are to be applied to the EditBox. + !#zh 指定输入标志位,可以指定输入方式为密码或者单词首字母大写。 */ + inputFlag: EditBox.InputFlag; + /** !#en + Set the input mode of the edit box. + If you pass ANY, it will create a multiline EditBox. + !#zh + 指定输入模式: ANY表示多行输入,其它都是单行输入,移动平台上还可以指定键盘样式。 */ + inputMode: EditBox.InputMode; + /** !#en Font size of the input text. This property will be removed in the future, use editBox.textLabel.fontSize instead please. + !#zh 输入框文本的字体大小。 该属性会在将来的版本中移除,请使用 editBox.textLabel.fontSize。 */ + fontSize: number; + /** !#en Change the lineHeight of displayed text. This property will be removed in the future, use editBox.textLabel.lineHeight instead. + !#zh 输入框文本的行高。该属性会在将来的版本中移除,请使用 editBox.textLabel.lineHeight */ + lineHeight: number; + /** !#en Font color of the input text. This property will be removed in the future, use editBox.textLabel.node.color instead. + !#zh 输入框文本的颜色。该属性会在将来的版本中移除,请使用 editBox.textLabel.node.color */ + fontColor: Color; + /** !#en The display text of placeholder. + !#zh 输入框占位符的文本内容。 */ + placeholder: string; + /** !#en The font size of placeholder. This property will be removed in the future, use editBox.placeholderLabel.fontSize instead. + !#zh 输入框占位符的字体大小。该属性会在将来的版本中移除,请使用 editBox.placeholderLabel.fontSize */ + placeholderFontSize: number; + /** !#en The font color of placeholder. This property will be removed in the future, use editBox.placeholderLabel.node.color instead. + !#zh 输入框占位符的字体颜色。该属性会在将来的版本中移除,请使用 editBox.placeholderLabel.node.color */ + placeholderFontColor: Color; + /** !#en The maximize input length of EditBox. + - If pass a value less than 0, it won't limit the input number of characters. + - If pass 0, it doesn't allow input any characters. + !#zh 输入框最大允许输入的字符个数。 + - 如果值为小于 0 的值,则不会限制输入字符个数。 + - 如果值为 0,则不允许用户进行任何输入。 */ + maxLength: number; + /** !#en The input is always visible and be on top of the game view (only useful on Web), this property will be removed on v2.1 + !zh 输入框总是可见,并且永远在游戏视图的上面(这个属性只有在 Web 上面修改有意义),该属性会在 v2.1 中移除 + Note: only available on Web at the moment. */ + stayOnTop: boolean; + /** !#en Set the tabIndex of the DOM input element (only useful on Web). + !#zh 修改 DOM 输入元素的 tabIndex(这个属性只有在 Web 上面修改有意义)。 */ + tabIndex: number; + /** !#en The event handler to be called when EditBox began to edit text. + !#zh 开始编辑文本输入框触发的事件回调。 */ + editingDidBegan: Component.EventHandler[]; + /** !#en The event handler to be called when EditBox text changes. + !#zh 编辑文本输入框时触发的事件回调。 */ + textChanged: Component.EventHandler[]; + /** !#en The event handler to be called when EditBox edit ends. + !#zh 结束编辑文本输入框时触发的事件回调。 */ + editingDidEnded: Component.EventHandler[]; + /** !#en The event handler to be called when return key is pressed. Windows is not supported. + !#zh 当用户按下回车按键时的事件回调,目前不支持 windows 平台 */ + editingReturn: Component.EventHandler[]; + /** + !#en Let the EditBox get focus, this method will be removed on v2.1 + !#zh 让当前 EditBox 获得焦点, 这个方法会在 v2.1 中移除 + */ + setFocus(): void; + /** + !#en Let the EditBox get focus + !#zh 让当前 EditBox 获得焦点 + */ + focus(): void; + /** + !#en Let the EditBox lose focus + !#zh 让当前 EditBox 失去焦点 + */ + blur(): void; + /** + !#en Determine whether EditBox is getting focus or not. + !#zh 判断 EditBox 是否获得了焦点 + */ + isFocused(): void; + /** + !#en if you don't need the EditBox and it isn't in any running Scene, you should + call the destroy method on this component or the associated node explicitly. + Otherwise, the created DOM element won't be removed from web page. + !#zh + 如果你不再使用 EditBox,并且组件未添加到场景中,那么你必须手动对组件或所在节点调用 destroy。 + 这样才能移除网页上的 DOM 节点,避免 Web 平台内存泄露。 + + @example + ```js + editbox.node.parent = null; // or editbox.node.removeFromParent(false); + // when you don't need editbox anymore + editbox.node.destroy(); + ``` + */ + destroy(): boolean; + } + /** undefined */ + export class PhysicsBoxCollider extends PhysicsCollider implements Collider.Box { + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Box size + !#zh 包围盒大小 */ + size: Size; + } + /** undefined */ + export class PhysicsChainCollider extends PolygonCollider { + /** !#en Whether the chain is loop + !#zh 链条是否首尾相连 */ + loop: boolean; + /** !#en Chain points + !#zh 链条顶点数组 */ + points: Vec2[]; + } + /** undefined */ + export class PhysicsCircleCollider extends PhysicsCollider implements Collider.Circle { + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Circle radius + !#zh 圆形半径 */ + radius: number; + } + /** undefined */ + export class PhysicsCollider extends Collider { + /** !#en + The density. + !#zh + 密度 */ + density: number; + /** !#en + A sensor collider collects contact information but never generates a collision response + !#zh + 一个传感器类型的碰撞体会产生碰撞回调,但是不会发生物理碰撞效果。 */ + sensor: boolean; + /** !#en + The friction coefficient, usually in the range [0,1]. + !#zh + 摩擦系数,取值一般在 [0, 1] 之间 */ + friction: number; + /** !#en + The restitution (elasticity) usually in the range [0,1]. + !#zh + 弹性系数,取值一般在 [0, 1]之间 */ + restitution: number; + /** !#en + Physics collider will find the rigidbody component on the node and set to this property. + !#zh + 碰撞体会在初始化时查找节点上是否存在刚体,如果查找成功则赋值到这个属性上。 */ + body: RigidBody; + /** + !#en + Apply current changes to collider, this will regenerate inner box2d fixtures. + !#zh + 应用当前 collider 中的修改,调用此函数会重新生成内部 box2d 的夹具。 + */ + apply(): void; + /** + !#en + Get the world aabb of the collider + !#zh + 获取碰撞体的世界坐标系下的包围盒 + */ + getAABB(): void; + } + /** undefined */ + export class PhysicsPolygonCollider extends PhysicsCollider implements Collider.Polygon { + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Polygon points + !#zh 多边形顶点数组 */ + points: Vec2[]; + } + /** !#en + A distance joint constrains two points on two bodies + to remain at a fixed distance from each other. You can view + this as a massless, rigid rod. + !#zh + 距离关节通过一个固定的长度来约束关节链接的两个刚体。你可以将它想象成一个无质量,坚固的木棍。 */ + export class DistanceJoint extends Joint { + /** !#en + The distance separating the two ends of the joint. + !#zh + 关节两端的距离 */ + distance: number; + /** !#en + The spring frequency. + !#zh + 弹性系数。 */ + frequency: number; + /** !#en + The damping ratio. + !#zh + 阻尼,表示关节变形后,恢复到初始状态受到的阻力。 */ + dampingRatio: number; + } + /** !#en + Base class for joints to connect rigidbody. + !#zh + 关节类的基类 */ + export class Joint extends Component { + /** !#en + The anchor of the rigidbody. + !#zh + 刚体的锚点。 */ + anchor: Vec2; + /** !#en + The anchor of the connected rigidbody. + !#zh + 关节另一端刚体的锚点。 */ + connectedAnchor: Vec2; + /** !#en + The rigidbody to which the other end of the joint is attached. + !#zh + 关节另一端链接的刚体 */ + connectedBody: RigidBody; + /** !#en + Should the two rigid bodies connected with this joint collide with each other? + !#zh + 链接到关节上的两个刚体是否应该相互碰撞? */ + collideConnected: boolean; + /** + !#en + Apply current changes to joint, this will regenerate inner box2d joint. + !#zh + 应用当前关节中的修改,调用此函数会重新生成内部 box2d 的关节。 + */ + apply(): void; + /** + !#en + Get the anchor point on rigidbody in world coordinates. + !#zh + 获取刚体世界坐标系下的锚点。 + */ + getWorldAnchor(): Vec2; + /** + !#en + Get the anchor point on connected rigidbody in world coordinates. + !#zh + 获取链接刚体世界坐标系下的锚点。 + */ + getWorldConnectedAnchor(): Vec2; + /** + !#en + Gets the reaction force of the joint. + !#zh + 获取关节的反作用力。 + @param timeStep The time to calculate the reaction force for. + */ + getReactionForce(timeStep: number): Vec2; + /** + !#en + Gets the reaction torque of the joint. + !#zh + 获取关节的反扭矩。 + @param timeStep The time to calculate the reaction torque for. + */ + getReactionTorque(timeStep: number): number; + } + /** !#en + A motor joint is used to control the relative motion + between two bodies. A typical usage is to control the movement + of a dynamic body with respect to the ground. + !#zh + 马达关节被用来控制两个刚体间的相对运动。 + 一个典型的例子是用来控制一个动态刚体相对于地面的运动。 */ + export class MotorJoint extends Joint { + /** !#en + The anchor of the rigidbody. + !#zh + 刚体的锚点。 */ + anchor: Vec2; + /** !#en + The anchor of the connected rigidbody. + !#zh + 关节另一端刚体的锚点。 */ + connectedAnchor: Vec2; + /** !#en + The linear offset from connected rigidbody to rigidbody. + !#zh + 关节另一端的刚体相对于起始端刚体的位置偏移量 */ + linearOffset: Vec2; + /** !#en + The angular offset from connected rigidbody to rigidbody. + !#zh + 关节另一端的刚体相对于起始端刚体的角度偏移量 */ + angularOffset: number; + /** !#en + The maximum force can be applied to rigidbody. + !#zh + 可以应用于刚体的最大的力值 */ + maxForce: number; + /** !#en + The maximum torque can be applied to rigidbody. + !#zh + 可以应用于刚体的最大扭矩值 */ + maxTorque: number; + /** !#en + The position correction factor in the range [0,1]. + !#zh + 位置矫正系数,范围为 [0, 1] */ + correctionFactor: number; + } + /** !#en + A mouse joint is used to make a point on a body track a + specified world point. This a soft constraint with a maximum + force. This allows the constraint to stretch and without + applying huge forces. + Mouse Joint will auto register the touch event with the mouse region node, + and move the choosed rigidbody in touch move event. + Note : generally mouse joint only used in test bed. + !#zh + 鼠标关节用于使刚体上的一个点追踪一个指定的世界坐标系下的位置。 + 鼠标关节可以指定一个最大的力来施加一个柔和的约束。 + 鼠标关节会自动使用 mouse region 节点来注册鼠标事件,并且在触摸移动事件中移动选中的刚体。 + 注意:一般鼠标关节只在测试环境中使用。 */ + export class MouseJoint extends Joint { + /** !#en + The anchor of the rigidbody. + !#zh + 刚体的锚点。 */ + anchor: Vec2; + /** !#en + The anchor of the connected rigidbody. + !#zh + 关节另一端刚体的锚点。 */ + connectedAnchor: Vec2; + /** !#en + The node used to register touch evnet. + If this is null, it will be the joint's node. + !#zh + 用于注册触摸事件的节点。 + 如果没有设置这个值,那么将会使用关节的节点来注册事件。 */ + mouseRegion: Node; + /** !#en + The target point. + The mouse joint will move choosed rigidbody to target point. + !#zh + 目标点,鼠标关节将会移动选中的刚体到指定的目标点 */ + target: Vec2; + /** !#en + The spring frequency. + !#zh + 弹簧系数。 */ + frequency: number; + /** !#en + The damping ratio. + !#zh + 阻尼,表示关节变形后,恢复到初始状态受到的阻力。 */ + 0: number; + /** !#en + The maximum force + !#zh + 最大阻力值 */ + maxForce: number; + } + /** !#en + A prismatic joint. This joint provides one degree of freedom: translation + along an axis fixed in rigidbody. Relative rotation is prevented. You can + use a joint limit to restrict the range of motion and a joint motor to + drive the motion or to model joint friction. + !#zh + 移动关节指定了只能在一个方向上移动刚体。 + 你可以开启关节限制来设置刚体运行移动的间距,也可以开启马达来使用关节马达驱动刚体的运行。 */ + export class PrismaticJoint extends Joint { + /** !#en + The local joint axis relative to rigidbody. + !#zh + 指定刚体可以移动的方向。 */ + localAxisA: Vec2; + /** !#en + The reference angle. + !#zh + 相对角度 */ + referenceAngle: number; + /** !#en + Enable joint distance limit? + !#zh + 是否开启关节的距离限制? */ + enableLimit: boolean; + /** !#en + Enable joint motor? + !#zh + 是否开启关节马达? */ + enableMotor: boolean; + /** !#en + The lower joint limit. + !#zh + 刚体能够移动的最小值 */ + lowerLimit: number; + /** !#en + The upper joint limit. + !#zh + 刚体能够移动的最大值 */ + upperLimit: number; + /** !#en + The maxium force can be applied to rigidbody to rearch the target motor speed. + !#zh + 可以施加到刚体的最大力。 */ + maxMotorForce: number; + /** !#en + The expected motor speed. + !#zh + 期望的马达速度。 */ + motorSpeed: number; + } + /** !#en + A revolute joint constrains two bodies to share a common point while they + are free to rotate about the point. The relative rotation about the shared + point is the joint angle. You can limit the relative rotation with + a joint limit that specifies a lower and upper angle. You can use a motor + to drive the relative rotation about the shared point. A maximum motor torque + is provided so that infinite forces are not generated. + !#zh + 旋转关节可以约束两个刚体围绕一个点来进行旋转。 + 你可以通过开启关节限制来限制旋转的最大角度和最小角度。 + 你可以通过开启马达来施加一个扭矩力来驱动这两个刚体在这一点上的相对速度。 */ + export class RevoluteJoint extends Joint { + /** !#en + The reference angle. + An angle between bodies considered to be zero for the joint angle. + !#zh + 相对角度。 + 两个物体之间角度为零时可以看作相等于关节角度 */ + referenceAngle: number; + /** !#en + The lower angle. + !#zh + 角度的最低限制。 */ + lowerAngle: number; + /** !#en + The upper angle. + !#zh + 角度的最高限制。 */ + upperAngle: number; + /** !#en + The maxium torque can be applied to rigidbody to rearch the target motor speed. + !#zh + 可以施加到刚体的最大扭矩。 */ + maxMotorTorque: number; + /** !#en + The expected motor speed. + !#zh + 期望的马达速度。 */ + motorSpeed: number; + /** !#en + Enable joint limit? + !#zh + 是否开启关节的限制? */ + enableLimit: boolean; + /** !#en + Enable joint motor? + !#zh + 是否开启关节马达? */ + enableMotor: boolean; + /** + !#en + Get the joint angle. + !#zh + 获取关节角度。 + */ + getJointAngle(): number; + } + /** !#en + A rope joint enforces a maximum distance between two points + on two bodies. It has no other effect. + Warning: if you attempt to change the maximum length during + the simulation you will get some non-physical behavior. + !#zh + 绳子关节只指定两个刚体间的最大距离,没有其他的效果。 + 注意:如果你试图动态修改关节的长度,这有可能会得到一些意外的效果。 */ + export class RopeJoint extends Joint { + /** !#en + The max length. + !#zh + 最大长度。 */ + maxLength: number; + } + /** !#en + A weld joint essentially glues two bodies together. A weld joint may + distort somewhat because the island constraint solver is approximate. + !#zh + 熔接关节相当于将两个刚体粘在了一起。 + 熔接关节可能会使某些东西失真,因为约束求解器算出的都是近似值。 */ + export class WeldJoint extends Joint { + /** !#en + The reference angle. + !#zh + 相对角度。 */ + referenceAngle: number; + /** !#en + The frequency. + !#zh + 弹性系数。 */ + frequency: number; + /** !#en + The damping ratio. + !#zh + 阻尼,表示关节变形后,恢复到初始状态受到的阻力。 */ + 0: number; + } + /** !#en + A wheel joint. This joint provides two degrees of freedom: translation + along an axis fixed in bodyA and rotation in the plane. You can use a joint motor to drive + the rotation or to model rotational friction. + This joint is designed for vehicle suspensions. + !#zh + 轮子关节提供两个维度的自由度:旋转和沿着指定方向上位置的移动。 + 你可以通过开启关节马达来使用马达驱动刚体的旋转。 + 轮组关节是专门为机动车类型设计的。 */ + export class WheelJoint extends Joint { + /** !#en + The local joint axis relative to rigidbody. + !#zh + 指定刚体可以移动的方向。 */ + localAxisA: Vec2; + /** !#en + The maxium torque can be applied to rigidbody to rearch the target motor speed. + !#zh + 可以施加到刚体的最大扭矩。 */ + maxMotorTorque: number; + /** !#en + The expected motor speed. + !#zh + 期望的马达速度。 */ + motorSpeed: number; + /** !#en + Enable joint motor? + !#zh + 是否开启关节马达? */ + enableMotor: boolean; + /** !#en + The spring frequency. + !#zh + 弹性系数。 */ + frequency: number; + /** !#en + The damping ratio. + !#zh + 阻尼,表示关节变形后,恢复到初始状态受到的阻力。 */ + dampingRatio: number; + } + /** !#en The rigid body type + !#zh 刚体类型 */ + export enum ERigidBodyType { + DYNAMIC = 0, + STATIC = 0, + KINEMATIC = 0, + } + /** !#en + Trigger event + !#zh + 触发事件。 */ + export class ITriggerEvent { + /** !#en + The type of event fired + !#zh + 触发的事件类型 */ + type: string; + /** !#en + Triggers its own collider in the event + !#zh + 触发事件中的自己的碰撞器 */ + selfCollider: Collider3D; + /** !#en + Triggers another collider in the event + !#zh + 触发事件中的另一个碰撞器 */ + otherCollider: Collider3D; + } + /** !#en + Collision information for collision events. + !#zh + 碰撞事件的碰撞信息。 */ + export class IContactEquation { + /** !#en + The collision point A in the collision information. + !#zh + 碰撞信息中的碰撞点 A。 */ + contactA: Vec3; + /** !#en + Collision point B in collision information. + !#zh + 碰撞信息中的碰撞点 B。 */ + contactB: Vec3; + /** !#en + Normals in collision information. + !#zh + 碰撞信息中的法线。 */ + normal: Vec3; + } + /** !#en + Collision events. + !#zh + 碰撞事件。 */ + export class ICollisionEvent { + /** !#en + Event type of collision. + !#zh + 碰撞的事件类型。 */ + type: string; + /** !#en + Collider of its own in collision. + !#zh + 碰撞中的自己的碰撞器。 */ + selfCollider: Collider3D; + /** !#en + Another collider in the collision. + !#zh + 碰撞中的另一个碰撞器。 */ + otherCollider: Collider3D; + /** !#en + Information about all the points of impact in the collision. + !#zh + 碰撞中的所有碰撞点的信息。 */ + contacts: IContactEquation[]; + } + /** !#en + Physical systems manager. + !#zh + 物理系统管理器。 */ + export class Physics3DManager { + /** !#en + Whether to enable the physics system, default is false. + !#zh + 是否启用物理系统,默认不启用。 */ + enabled: boolean; + /** !#en + Whether to allow the physics system to automatically hibernate, default is true. + !#zh + 物理系统是否允许自动休眠,默认为 true。 */ + allowSleep: boolean; + /** !#en + The maximum number of sub-steps a full step is permitted to be broken into, default is 2. + !#zh + 物理每帧模拟的最大子步数,默认为 2。 */ + maxSubStep: number; + /** !#en + Time spent in each simulation of physics, default is 1/60s. + !#zh + 物理每步模拟消耗的固定时间,默认为 1/60 秒。 */ + deltaTime: number; + /** !#en + Whether to use a fixed time step. + !#zh + 是否使用固定的时间步长。 */ + useFixedTime: boolean; + /** !#en + Gravity value of the physics simulation, default is (0, -10, 0). + !#zh + 物理世界的重力数值,默认为 (0, -10, 0)。 */ + gravity: Vec3; + /** !#en + Gets the global default physical material. Note that builtin is null. + !#zh + 获取全局的默认物理材质,注意:builtin 时为 null。 */ + defaultMaterial: PhysicsMaterial|void; + /** + !#en + A physical system simulation is performed once and will now be performed automatically once per frame. + !#zh + 执行一次物理系统的模拟,目前将在每帧自动执行一次。 + @param deltaTime The time difference from the last execution is currently elapsed per frame + */ + update(deltaTime: number): void; + /** + !#en Detect all collision boxes and return all detected results, or null if none is detected. Note that the return value is taken from the object pool, so do not save the result reference or modify the result. + !#zh 检测所有的碰撞盒,并返回所有被检测到的结果,若没有检测到,则返回空值。注意返回值是从对象池中取的,所以请不要保存结果引用或者修改结果。 + @param worldRay A ray in world space + @param groupIndexOrName Collision group index or group name + @param maxDistance Maximum detection distance + @param queryTrigger Detect trigger or not + */ + raycast(worldRay: geomUtils.Ray, groupIndexOrName: number|string, maxDistance: number, queryTrigger: boolean): PhysicsRayResult[]; + /** + !#en Detect all collision boxes and return the detection result with the shortest ray distance. If not, return null value. Note that the return value is taken from the object pool, so do not save the result reference or modify the result. + !#zh 检测所有的碰撞盒,并返回射线距离最短的检测结果,若没有,则返回空值。注意返回值是从对象池中取的,所以请不要保存结果引用或者修改结果。 + @param worldRay A ray in world space + @param groupIndexOrName Collision group index or group name + @param maxDistance Maximum detection distance + @param queryTrigger Detect trigger or not + */ + raycastClosest(worldRay: geomUtils.Ray, groupIndexOrName: number|string, maxDistance: number, queryTrigger: boolean): PhysicsRayResult; + } + /** !#en + Used to store physical ray detection results + !#zh + 用于保存物理射线检测结果 */ + export class PhysicsRayResult { + /** !#en + Hit the point + !#zh + 击中点 */ + hitPoint: Vec3; + /** !#en + Distance + !#zh + 距离 */ + distance: number; + /** !#en + Hit the collision box + !#zh + 击中的碰撞盒 */ + collider: Collider3D; + /** + !#en + Set up ray. This method is used internally by the engine. Do not call it from an external script + !#zh + 设置射线,此方法由引擎内部使用,请勿在外部脚本调用 + @param hitPoint hitPoint + @param distance distance + @param collider collider + */ + _assign(hitPoint: Vec3, distance: number, collider: Collider3D): void; + /** + !#en + Clone + !#zh + 克隆 + */ + clone(): void; + } + /** !#en The shape module of 3d particle. + !#zh 3D 粒子的发射形状模块 */ + export class ShapeModule { + /** !#en The enable of shapeModule. + !#zh 是否启用 */ + enable: boolean; + /** !#en Particle emitter type. + !#zh 粒子发射器类型。 */ + shapeType: shapeModule.ShapeType; + /** !#en The emission site of the particle. + !#zh 粒子从发射器哪个部位发射。 */ + emitFrom: shapeModule.EmitLocation; + /** !#en Particle emitter radius. + !#zh 粒子发射器半径。 */ + radius: number; + /** !#en Particle emitter emission position (not valid for Box type emitters): + - 0 means emitted from the surface; + - 1 means launch from the center; + - 0 ~ 1 indicates emission from the center to the surface. + !#zh 粒子发射器发射位置(对 Box 类型的发射器无效): + - 0 表示从表面发射; + - 1 表示从中心发射; + - 0 ~ 1 之间表示在中心到表面之间发射。 */ + radiusThickness: number; + /** !#en The angle between the axis of the cone and the generatrix + Determines the opening and closing of the cone launcher + !#zh 圆锥的轴与母线的夹角。 + 决定圆锥发射器的开合程度。 */ + angle: number; + /** !#en Particle emitters emit in a fan-shaped range. + !#zh 粒子发射器在一个扇形范围内发射。 */ + arc: number; + /** !#en How particles are emitted in the sector range. + !#zh 粒子在扇形范围内的发射方式。 */ + arcMode: shapeModule.ArcMode; + /** !#en Controls the discrete intervals around the arcs where particles might be generated. + !#zh 控制可能产生粒子的弧周围的离散间隔。 */ + arcSpread: number; + /** !#en The speed at which particles are emitted around the circumference. + !#zh 粒子沿圆周发射的速度。 */ + arcSpeed: CurveRange; + /** !#en Axis length from top of cone to bottom of cone . + Determines the height of the cone emitter. + !#zh 圆锥顶部截面距离底部的轴长。 + 决定圆锥发射器的高度。 */ + length: number; + /** !#en Particle emitter emission location (for box-type particle emitters). + !#zh 粒子发射器发射位置(针对 Box 类型的粒子发射器。 */ + boxThickness: Vec3; + /** !#en Particle Emitter Position + !#zh 粒子发射器位置。 */ + position: Vec3; + /** !#en Particle emitter rotation angle. + !#zh 粒子发射器旋转角度。 */ + rotation: Vec3; + /** !#en Particle emitter scaling + !#zh 粒子发射器缩放比例。 */ + scale: Vec3; + /** !#en The direction of particle movement is determined based on the initial direction of the particles. + !#zh 根据粒子的初始方向决定粒子的移动方向。 */ + alignToDirection: boolean; + /** !#en Set particle generation direction randomly. + !#zh 粒子生成方向随机设定。 */ + randomDirectionAmount: number; + /** !#en Interpolation between the current emission direction and the direction from the current position to the center of the node. + !#zh 表示当前发射方向与当前位置到结点中心连线方向的插值。 */ + sphericalDirectionAmount: number; + } + /** !#en The color over time module of 3d particle. + !#zh 3D 粒子颜色变化模块 */ + export class ColorOvertimeModule { + /** !#en The enable of ColorOvertimeModule. + !#zh 是否启用 */ + enable: boolean; + } + /** !#en The curve range of target value. + !#zh 目标值的曲线范围 */ + export class CurveRange { + /** !#en Curve type. + !#zh 曲线类型。 */ + mode: debug.DebugMode; + /** !#en The curve to use when mode is Curve. + !#zh 当 mode 为 Curve 时,使用的曲线。 */ + curve: AnimationCurve; + /** !#en The lower limit of the curve to use when mode is TwoCurves + !#zh 当 mode 为 TwoCurves 时,使用的曲线下限。 */ + curveMin: AnimationCurve; + /** !#en The upper limit of the curve to use when mode is TwoCurves + !#zh 当 mode 为 TwoCurves 时,使用的曲线上限。 */ + curveMax: AnimationCurve; + /** !#en When mode is Constant, the value of the curve. + !#zh 当 mode 为 Constant 时,曲线的值。 */ + constant: number; + /** !#en The lower limit of the curve to use when mode is TwoConstants + !#zh 当 mode 为 TwoConstants 时,曲线的下限。 */ + constantMin: number; + /** !#en The upper limit of the curve to use when mode is TwoConstants + !#zh 当 mode 为 TwoConstants 时,曲线的上限。 */ + constantMax: number; + /** !#en Coefficients applied to curve interpolation. + !#zh 应用于曲线插值的系数。 */ + multiplier: number; + } + /** !#en The force over time module of 3d particle. + !#zh 3D 粒子的加速度模块 */ + export class ForceOvertimeModule { + /** !#en The enable of ColorOvertimeModule. + !#zh 是否启用 */ + enable: boolean; + /** !#en Coordinate system used in acceleration calculation. + !#zh 加速度计算时采用的坐标系。 */ + space: ParticleSystem3DAssembler.Space; + /** !#en X-axis acceleration component. + !#zh X 轴方向上的加速度分量。 */ + x: CurveRange; + /** !#en Y-axis acceleration component. + !#zh Y 轴方向上的加速度分量。 */ + y: CurveRange; + /** !#en Z-axis acceleration component. + !#zh Z 轴方向上的加速度分量。 */ + z: CurveRange; + } + /** !#en The gradient range of color. + !#zh 颜色值的渐变范围 */ + export class GradientRange { + /** !#en Gradient type. + !#zh 渐变色类型。 */ + mode: debug.DebugMode; + /** !#en The color when mode is Color. + !#zh 当 mode 为 Color 时的颜色。 */ + color: Color; + /** !#en Lower color limit when mode is TwoColors. + !#zh 当 mode 为 TwoColors 时的颜色下限。 */ + colorMin: Color; + /** !#en Upper color limit when mode is TwoColors. + !#zh 当 mode 为 TwoColors 时的颜色上限。 */ + colorMax: Color; + /** !#en Color gradient when mode is Gradient + !#zh 当 mode 为 Gradient 时的颜色渐变。 */ + gradient: Gradient; + /** !#en Lower color gradient limit when mode is TwoGradients. + !#zh 当 mode 为 TwoGradients 时的颜色渐变下限。 */ + gradientMin: Gradient; + /** !#en Upper color gradient limit when mode is TwoGradients. + !#zh 当 mode 为 TwoGradients 时的颜色渐变上限。 */ + gradientMax: Gradient; + } + /** !#en The color key of gradient. + !#zh color 关键帧 */ + export class ColorKey { + /** !#en Color value. + !#zh 颜色值。 */ + color: Color; + /** !#en Time value. + !#zh 时间值。 */ + time: number; + } + /** !#en The alpha key of gradient. + !#zh alpha 关键帧 */ + export class AlphaKey { + /** !#en Alpha value. + !#zh 透明度。 */ + alpha: number; + /** !#en Time. + !#zh 时间帧。 */ + time: number; + } + /** !#en The gradient data of color. + !#zh 颜色渐变数据 */ + export class Gradient { + /** !#en Array of color key. + !#zh 颜色关键帧列表。 */ + colorKeys: ColorKey[]; + /** !#en Array of alpha key. + !#zh 透明度关键帧列表。 */ + alphaKeys: AlphaKey[]; + /** !#en Blend mode. + !#zh 混合模式。 */ + mode: debug.DebugMode; + } + /** !#en The limit velocity module of 3d particle. + !#zh 3D 粒子的限速模块 */ + export class LimitVelocityOvertimeModule { + /** !#en The enable of LimitVelocityOvertimeModule. + !#zh 是否启用 */ + enable: boolean; + /** !#en The coordinate system used when calculating the lower speed limit. + !#zh 计算速度下限时采用的坐标系。 */ + space: ParticleSystem3DAssembler.Space; + /** !#en Whether to limit the three axes separately. + !#zh 是否三个轴分开限制。 */ + separateAxes: boolean; + /** !#en Lower speed limit + !#zh 速度下限。 */ + limit: CurveRange; + /** !#en Lower speed limit in X direction. + !#zh X 轴方向上的速度下限。 */ + limitX: CurveRange; + /** !#en Lower speed limit in Y direction. + !#zh Y 轴方向上的速度下限。 */ + limitY: CurveRange; + /** !#en Lower speed limit in Z direction. + !#zh Z 轴方向上的速度下限。 */ + limitZ: CurveRange; + /** !#en Interpolation of current speed and lower speed limit. + !#zh 当前速度与速度下限的插值。 */ + dampen: number; + } + /** !#en The optimized curve. + !#zh 优化曲线 */ + export class OptimizedCurve { + } + /** !#en The rotation module of 3d particle. + !#zh 3D 粒子的旋转模块 */ + export class RotationOvertimeModule { + /** !#en The enable of RotationOvertimeModule. + !#zh 是否启用 */ + enable: boolean; + /** !#en Whether to set the rotation of three axes separately (not currently supported) + !#zh 是否三个轴分开设定旋转(暂不支持)。 */ + separateAxes: boolean; + /** !#en Set rotation around X axis. + !#zh 绕 X 轴设定旋转。 */ + x: CurveRange; + /** !#en Set rotation around Y axis. + !#zh 绕 Y 轴设定旋转。 */ + y: CurveRange; + /** !#en Set rotation around Z axis. + !#zh 绕 Z 轴设定旋转。 */ + z: CurveRange; + } + /** !#en The size module of 3d particle. + !#zh 3D 粒子的大小模块 */ + export class SizeOvertimeModule { + /** !#en The enable of SizeOvertimeModule. + !#zh 是否启用 */ + enable: boolean; + /** !#en Decide whether to control particle size independently on each axis. + !#zh 决定是否在每个轴上独立控制粒子大小。 */ + separateAxes: boolean; + /** !#en Define a curve to determine the size change of particles during their life cycle. + !#zh 定义一条曲线来决定粒子在其生命周期中的大小变化。 */ + size: CurveRange; + /** !#en Defines a curve to determine the size change of particles in the X-axis direction during their life cycle. + !#zh 定义一条曲线来决定粒子在其生命周期中 X 轴方向上的大小变化。 */ + x: CurveRange; + /** !#en Defines a curve to determine the size change of particles in the Y-axis direction during their life cycle. + !#zh 定义一条曲线来决定粒子在其生命周期中 Y 轴方向上的大小变化。 */ + y: CurveRange; + /** !#en Defines a curve to determine the size change of particles in the Z-axis direction during their life cycle. + !#zh 定义一条曲线来决定粒子在其生命周期中 Z 轴方向上的大小变化。 */ + z: CurveRange; + } + /** !#en The texture animation module of 3d particle. + !#zh 3D 粒子的贴图动画模块 */ + export class TextureAnimationModule { + /** !#en The enable of TextureAnimationModule. + !#zh 是否启用 */ + enable: boolean; + /** !#en Set the type of particle map animation (only supports Grid mode for the time being) + !#zh 设定粒子贴图动画的类型(暂只支持 Grid 模式。 */ + mode: debug.DebugMode; + /** !#en Animation frames in X direction. + !#zh X 方向动画帧数。 */ + numTilesX: number; + /** !#en Animation frames in Y direction. + !#zh Y 方向动画帧数。 */ + numTilesY: number; + /** !#en The way of the animation plays. + !#zh 动画播放方式。 */ + animation: Animation; + /** !#en Randomly select a line from the animated map to generate the animation.
+ This option only takes effect when the animation playback mode is SingleRow. + !#zh 随机从动画贴图中选择一行以生成动画。
+ 此选项仅在动画播放方式为 SingleRow 时生效。 */ + randomRow: boolean; + /** !#en Select specific lines from the animation map to generate the animation.
+ This option is only available when the animation playback mode is SingleRow and randomRow is disabled. + !#zh 从动画贴图中选择特定行以生成动画。
+ 此选项仅在动画播放方式为 SingleRow 时且禁用 randomRow 时可用。 */ + rowIndex: number; + /** !#en Frame and time curve of animation playback in one cycle. + !#zh 一个周期内动画播放的帧与时间变化曲线。 */ + frameOverTime: CurveRange; + /** !#en Play from which frames, the time is the life cycle of the entire particle system. + !#zh 从第几帧开始播放,时间为整个粒子系统的生命周期。 */ + startFrame: CurveRange; + /** !#en Number of playback loops in a life cycle. + !#zh 一个生命周期内播放循环的次数。 */ + cycleCount: number; + } + /** !#en The velocity module of 3d particle. + !#zh 3D 粒子的速度模块 */ + export class VelocityOvertimeModule { + /** !#en The enable of VelocityOvertimeModule. + !#zh 是否启用 */ + enable: boolean; + /** !#en Coordinate system used in speed calculation. + !#zh 速度计算时采用的坐标系。 */ + space: ParticleSystem3DAssembler.Space; + /** !#en Velocity component in X axis direction + !#zh X 轴方向上的速度分量。 */ + x: CurveRange; + /** !#en Velocity component in Y axis direction + !#zh Y 轴方向上的速度分量。 */ + y: CurveRange; + /** !#en Velocity component in Z axis direction + !#zh Z 轴方向上的速度分量。 */ + z: CurveRange; + /** !#en Speed correction factor (only supports CPU particles). + !#zh 速度修正系数(只支持 CPU 粒子)。 */ + speedModifier: CurveRange; + } + /** Rigid body interface */ + export class IRigidBody { + rigidBody: RigidBody3D; + mass: number; + linearDamping: number; + angularDamping: number; + isKinematic: boolean; + useGravity: boolean; + fixedRotation: boolean; + linearFactor: IVec3Like; + angularFactor: IVec3Like; + allowSleep: boolean; + isAwake: boolean; + isSleepy: boolean; + isSleeping: boolean; + wakeUp(): void; + sleep(): void; + /** + + @param out out + */ + getLinearVelocity(out: IVec3Like): void; + /** + + @param out out + */ + setLinearVelocity(out: IVec3Like): void; + /** + + @param out out + */ + getAngularVelocity(out: IVec3Like): void; + /** + + @param out out + */ + setAngularVelocity(out: IVec3Like): void; + /** + + @param force force + @param relativePoint relativePoint + */ + applyForce(force: IVec3Like, relativePoint: IVec3Like): void; + /** + + @param force force + @param relativePoint relativePoint + */ + applyLocalForce(force: IVec3Like, relativePoint: IVec3Like): void; + /** + + @param force force + @param relativePoint relativePoint + */ + applyImpulse(force: IVec3Like, relativePoint: IVec3Like): void; + /** + + @param force force + @param relativePoint relativePoint + */ + applyLocalImpulse(force: IVec3Like, relativePoint: IVec3Like): void; + /** + + @param torque torque + */ + applyTorque(torque: IVec3Like): void; + /** + + @param torque torque + */ + applyLocalTorque(torque: IVec3Like): void; + } + /** Class has x y z properties */ + export class IVec3Like { + x: number; + y: number; + z: number; + } + /** Class has x y z w properties */ + export class IQuatLike { + x: number; + y: number; + z: number; + w: number; + } + /** !#en Base shape interface. */ + export class IBaseShape { + collider: Collider3D; + attachedRigidBody: RigidBody3D|void; + material: any; + isTrigger: boolean; + center: IVec3Like; + } + /** !#en box shape interface */ + export class IBoxShape { + size: IVec3Like; + } + /** !#en Sphere shape interface */ + export class ISphereShape { + radius: number; + } + /** Ray cast options */ + export class IRaycastOptions { + groupIndex: number; + queryTrigger: boolean; + maxDistance: number; + } + /** Collision detect */ + export class ICollisionDetect { + /** + Ray cast, and return information of the closest hit. + @param worldRay worldRay + @param options options + @param out out + */ + raycastClosest(worldRay: geomUtils.Ray, options: IRaycastOptions, out: PhysicsRayResult): boolean; + /** + Ray cast against all bodies. The provided callback will be executed for each hit with a RaycastResult as single argument. + @param worldRay worldRay + @param options options + @param pool pool + @param resultes resultes + */ + raycast(worldRay: geomUtils.Ray, options: IRaycastOptions, pool: RecyclePool, resultes: PhysicsRayResult[]): boolean; + } + /** Physics world interface */ + export class IPhysicsWorld { + } + /** !#en The trail module of 3d particle. + !#zh 3D 粒子拖尾模块 */ + export class TrailModule { + /** !#en The enable of trailModule. + !#zh 是否启用 */ + enable: boolean; + /** !#en Sets how particles generate trajectories. + !#zh 设定粒子生成轨迹的方式。 */ + mode: trailModule.TrailMode; + /** !#en Life cycle of trajectory. + !#zh 轨迹存在的生命周期。 */ + lifeTime: CurveRange; + /** !#en Minimum spacing between each track particle + !#zh 每个轨迹粒子之间的最小间距。 */ + minParticleDistance: number; + /** !#en The coordinate system of trajectories. + !#zh 轨迹设定时的坐标系。 */ + space: ParticleSystem3DAssembler.Space; + /** !#en Whether the particle itself exists. + !#zh 粒子本身是否存在。 */ + existWithParticles: boolean; + /** !#en Set the texture fill method + !#zh 设定纹理填充方式。 */ + textureMode: trailModule.TextureMode; + /** !#en Whether to use particle width + !#zh 是否使用粒子的宽度。 */ + widthFromParticle: boolean; + /** !#en Curves that control track length + !#zh 控制轨迹长度的曲线。 */ + widthRatio: CurveRange; + /** !#en Whether to use particle color + !#zh 是否使用粒子的颜色。 */ + colorFromParticle: boolean; + /** !#en The color of trajectories. + !#zh 轨迹的颜色。 */ + colorOverTrail: GradientRange; + /** !#en Trajectories color over time. + !#zh 轨迹随时间变化的颜色。 */ + colorOvertime: GradientRange; + } + /** !#en Manage Dynamic Atlas Manager. Dynamic Atlas Manager is used for merging textures at runtime, see [Dynamic Atlas](https://docs.cocos.com/creator/manual/en/advanced-topics/dynamic-atlas.html) for details. + !#zh 管理动态图集。动态图集用于在运行时对贴图进行合并,详见 [动态合图](https://docs.cocos.com/creator/manual/zh/advanced-topics/dynamic-atlas.html)。 */ + export class DynamicAtlasManager { + /** !#en Enable or disable the dynamic atlas, see [Dynamic Atlas](https://docs.cocos.com/creator/manual/en/advanced-topics/dynamic-atlas.html) for details. + !#zh 开启或者关闭动态图集,详见 [动态合图](https://docs.cocos.com/creator/manual/zh/advanced-topics/dynamic-atlas.html)。 */ + enabled: boolean; + /** !#en The maximum number of atlas that can be created. + !#zh 可以创建的最大图集数量。 */ + maxAtlasCount: number; + /** !#en Get the current created atlas count. + !#zh 获取当前已经创建的图集数量。 */ + atlasCount: number; + /** !#en Is enable textureBleeding. + !#zh 是否开启 textureBleeding */ + textureBleeding: boolean; + /** !#en The size of the atlas that was created + !#zh 创建的图集的宽高 */ + textureSize: number; + /** !#en The maximum size of the picture that can be added to the atlas. + !#zh 可以添加进图集的图片的最大尺寸。 */ + maxFrameSize: number; + /** !#en The minimum size of the picture that can be added to the atlas. + !#zh 可以添加进图集的图片的最小尺寸。 */ + minFrameSize: number; + /** + !#en Append a sprite frame into the dynamic atlas. + !#zh 添加碎图进入动态图集。 + @param spriteFrame spriteFrame + */ + insertSpriteFrame(spriteFrame: SpriteFrame): void; + /** + !#en Resets all dynamic atlas, and the existing ones will be destroyed. + !#zh 重置所有动态图集,已有的动态图集会被销毁。 + */ + reset(): void; + /** + !#en Displays all the dynamic atlas in the current scene, which you can use to view the current atlas state. + !#zh 在当前场景中显示所有动态图集,可以用来查看当前的合图状态。 + @param show show + */ + showDebug(show: boolean): Node; + } + /** !#en + Physics material. + !#zh + 物理材质。 */ + export class PhysicsMaterial extends Asset { + /** !#en + Friction for this material. + !#zh + 物理材质的摩擦力。 */ + friction: number; + /** !#en + Restitution for this material. + !#zh + 物理材质的弹力。 */ + restitution: number; + } + /** !#en + Each frame applies a constant force to a rigid body, depending on the RigidBody3D + !#zh + 在每帧对一个刚体施加持续的力,依赖 RigidBody3D 组件 */ + export class ConstantForce extends Component { + /** !#en + Set the force used in the world coordinate system, use `this.force = otherVec3`. + !#zh + 设置世界坐标系中使用的力,设置时请用 `this.force = otherVec3` 的方式。 */ + force: Vec3; + /** !#en + Set the force used in the local coordinate system, using `this.localforce = otherVec3`. + !#zh + 获取和设置本地坐标系中使用的力,设置时请用 `this.localForce = otherVec3` 的方式。 */ + localForce: Vec3; + /** !#en + Torque applied to the world orientation + !#zh + 对世界朝向施加的扭矩 */ + torque: Vec3; + /** !#en + Torque applied to local orientation, using `this.localtorque = otherVec3`. + !#zh + 对本地朝向施加的扭矩,设置时请用 `this.localTorque = otherVec3` 的方式。 */ + localTorque: Vec3; + } + /** !#en + RigidBody is the basic object that make up the physical world, and it can make a node physically affected and react. + !#zh + 刚体是组成物理世界的基本对象,可以让一个节点受到物理影响并产生反应。该组件在使用 Builtin 物理引擎时无效。 */ + export class RigidBody3D extends Component { + /** !#en + Whether sleep is allowed. + !#zh + 是否允许休眠。 */ + allowSleep: boolean; + /** !#en + The mass of the rigidbody. + !#zh + 刚体的质量。 */ + mass: number; + /** !#en + Used to reduce the linear rate of rigidbody. The larger the value, the slower the rigidbody moves. + !#zh + 线性阻尼,用于减小刚体的线性速率,值越大物体移动越慢。 */ + linearDamping: number; + /** !#en + Used to reduce the rotation rate of rigidbody. The larger the value, the slower the rigidbody rotates. + !#zh + 角阻尼,用于减小刚体的旋转速率,值越大刚体旋转越慢。 */ + angularDamping: number; + /** !#en + If enabled, the developer controls the displacement and rotation of the rigidbody, not the physics engine. + !#zh + 是否由开发者来控制刚体的位移和旋转,而不是受物理引擎的影响。 */ + isKinematic: boolean; + /** !#en + If enabled, the rigidbody is affected by gravity. + !#zh + 如果开启,刚体会受到重力影响。 */ + useGravity: boolean; + /** !#en + If enabled, the rigidbody will be fixed without rotation during a collision. + !#zh + 如果开启,发生碰撞时会固定刚体不产生旋转。 */ + fixedRotation: boolean; + /** !#en + It can affect the linear velocity change of the rigidbody in each axis. The larger the value, the faster the rigidbody moves. + !#zh + 线性因子,可影响刚体在每个轴向的线性速度变化,值越大刚体移动越快。 */ + linearFactor: Vec3; + /** !#en + It can affect the rotation speed change of the rigidbody in each axis. The larger the value, the faster the rigidbody rotates. + !#zh + 旋转因子,可影响刚体在每个轴向的旋转速度变化,值越大刚体旋转越快。 */ + angularFactor: Vec3; + /** !#en + The rigidbody is awake. + !#zh + 刚体是否为唤醒的状态。 */ + isAwake: boolean; + /** !#en + The rigidbody can enter hibernation. + !#zh + 刚体是否为可进入休眠的状态。 */ + isSleepy: boolean; + /** !#en + The rigidbody is sleeping. + !#zh + 刚体是否为正在休眠的状态。 */ + isSleeping: boolean; + /** !#en + Get the rigidbody object inside the physics engine. + !#zh + 获得物理引擎内部刚体对象。 */ + rigidBody: IRigidBody; + /** + !#en + A force is applied to a rigid body at a point in world space. + !#zh + 在世界空间中的某点上对刚体施加一个作用力。 + @param force force + @param relativePoint The point of action, relative to the center of the rigid body. + */ + applyForce(force: Vec3, relativePoint: Vec3): void; + /** + !#en + Apply a force on the rigid body at a point in local space. + !#zh + 在本地空间中的某点上对刚体施加一个作用力。 + @param force force + @param localPoint Point of application + */ + applyLocalForce(force: Vec3, localPoint: Vec3): void; + /** + !#en + Apply an impulse to a rigid body at a point in world space. + !#zh + 在世界空间的某点上对刚体施加一个冲量。 + @param impulse impulse + @param relativePoint The point of action, relative to the center of the rigid body. + */ + applyImpulse(impulse: Vec3, relativePoint: Vec3): void; + /** + !#en + Apply an impulse to the rigid body at a point in local space. + !#zh + 在本地空间的某点上对刚体施加一个冲量。 + @param impulse impulse + @param localPoint Point of application + */ + applyLocalImpulse(impulse: Vec3, localPoint: Vec3): void; + /** + !#en + Apply a torque to the rigid body. + !#zh + 对刚体施加扭转力。 + @param torque torque + */ + applyTorque(torque: Vec3): void; + /** + !#en + Apply a local torque to the rigid body. + !#zh + 对刚体施加本地扭转力。 + @param torque torque + */ + applyLocalTorque(torque: Vec3): void; + /** + !#en + Awaken the rigid body. + !#zh + 唤醒刚体。 + */ + wakeUp(): void; + /** + !#en + Dormant rigid body. + !#zh + 休眠刚体。 + */ + sleep(): void; + /** + !#en + Get linear velocity. + !#zh + 获取线性速度。 + @param out out + */ + getLinearVelocity(out: Vec3): void; + /** + !#en + Set linear speed. + !#zh + 设置线性速度。 + @param value value + */ + setLinearVelocity(value: Vec3): void; + /** + !#en + Gets the rotation speed. + !#zh + 获取旋转速度。 + @param out out + */ + getAngularVelocity(out: Vec3): void; + /** + !#en + Set rotation speed. + !#zh + 设置旋转速度。 + @param value value + */ + setAngularVelocity(value: Vec3): void; + } + /** !#en + Physics box collider + !#zh + 物理盒子碰撞器 */ + export class BoxCollider3D extends Collider3D { + /** !#en + Get or set the size of the box, in local space. + !#zh + 获取或设置盒的大小。 */ + size: Vec3; + boxShape: IBoxShape; + } + /** !#en + The base class of the collider. + !#zh + 碰撞器的基类。 */ + export class Collider3D extends Component implements EventTarget { + sharedMaterial: PhysicsMaterial; + /** !#en + get or set the collider is trigger, this will be always trigger if using builtin. + !#zh + 获取或设置碰撞器是否为触发器。 */ + isTrigger: boolean; + /** !#en + get or set the center of the collider, in local space. + !#zh + 获取或设置碰撞器的中心点。 */ + center: Vec3; + /** !#en + get the collider attached rigidbody, this may be null. + !#zh + 获取碰撞器所绑定的刚体组件,可能为 null。 */ + attachedRigidbody: RigidBody3D|void; + /** !#en + get collider shape. + !#zh + 获取碰撞器形状。 */ + shape: IBaseShape; + /** + !#en + Register an callback of a specific event type on the EventTarget. + This type of event should be triggered via `emit`. + !#zh + 注册事件目标的特定事件类型回调。这种类型的事件应该被 `emit` 触发。 + @param type The type of collider event can be `trigger-enter`, `trigger-stay`, `trigger-exit` or `collision-enter`, `collision-stay`, `collision-exit`. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null. + + @example + ```js + eventTarget.on('fire', function (event) { + // event is ITriggerEvent or ICollisionEvent + }, node); + ``` + */ + on(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. + !#zh + 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。 + @param type The type of collider event can be `trigger-enter`, `trigger-stay`, `trigger-exit` or `collision-enter`, `collision-stay`, `collision-exit`. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed. + + @example + ```js + // register fire eventListener + var callback = eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, target); + // remove fire event listener + eventTarget.off('fire', callback, target); + // remove all fire event listeners + eventTarget.off('fire'); + ``` + */ + off(type: string, callback?: Function, target?: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type The type of collider event can be `trigger-enter`, `trigger-stay`, `trigger-exit` or `collision-enter`, `collision-stay`, `collision-exit`. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null. + + @example + ```js + eventTarget.once('fire', function (event) { + // event is ITriggerEvent or ICollisionEvent + }, node); + ``` + */ + once(type: string, callback: (event: ITriggerEvent|ICollisionEvent) => void, target?: any): void; + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Send an event with the event object. + !#zh + 通过事件对象派发事件 + @param event event + */ + dispatchEvent(event: Event): void; + /** + !#en + Destroy all callbackInfos. + !#zh + 销毁记录的事件 + */ + clear(): void; + } + /** !#en + Physics sphere collider + !#zh + 物理球碰撞器 */ + export class SphereCollider3D extends Collider3D { + /** !#en + Get or set the radius of the sphere. + !#zh + 获取或设置球的半径。 */ + radius: number; + sphereShape: ISphereShape; + } + /**************************************************** + * audioEngine + *****************************************************/ + + export namespace audioEngine { + /** !#en Audio state. + !#zh 声音播放状态 */ + export enum AudioState { + ERROR = 0, + INITIALZING = 0, + PLAYING = 0, + PAUSED = 0, + STOPPED = 0, + } + } + + /**************************************************** + * debug + *****************************************************/ + + export namespace debug { + /** !#en Enum for debug modes. + !#zh 调试模式 */ + export enum DebugMode { + NONE = 0, + INFO = 0, + WARN = 0, + ERROR = 0, + INFO_FOR_WEB_PAGE = 0, + WARN_FOR_WEB_PAGE = 0, + ERROR_FOR_WEB_PAGE = 0, + } + } + + /**************************************************** + * Node + *****************************************************/ + + export namespace Node { + /** !#en Node's local dirty properties flag + !#zh Node 的本地属性 dirty 状态位 */ + export enum _LocalDirtyFlag { + POSITION = 0, + SCALE = 0, + ROTATION = 0, + SKEW = 0, + TRS = 0, + RS = 0, + TRS = 0, + PHYSICS_POSITION = 0, + PHYSICS_SCALE = 0, + PHYSICS_ROTATION = 0, + PHYSICS_TRS = 0, + PHYSICS_RS = 0, + ALL_POSITION = 0, + ALL_SCALE = 0, + ALL_ROTATION = 0, + ALL_TRS = 0, + ALL = 0, + } + } + + /**************************************************** + * Node + *****************************************************/ + + export namespace Node { + /** !#en The event type supported by Node + !#zh Node 支持的事件类型 */ + export class EventType { + /** !#en The event type for touch start event, you can use its value directly: 'touchstart' + !#zh 当手指触摸到屏幕时。 */ + static TOUCH_START: string; + /** !#en The event type for touch move event, you can use its value directly: 'touchmove' + !#zh 当手指在屏幕上移动时。 */ + static TOUCH_MOVE: string; + /** !#en The event type for touch end event, you can use its value directly: 'touchend' + !#zh 当手指在目标节点区域内离开屏幕时。 */ + static TOUCH_END: string; + /** !#en The event type for touch end event, you can use its value directly: 'touchcancel' + !#zh 当手指在目标节点区域外离开屏幕时。 */ + static TOUCH_CANCEL: string; + /** !#en The event type for mouse down events, you can use its value directly: 'mousedown' + !#zh 当鼠标按下时触发一次。 */ + static MOUSE_DOWN: string; + /** !#en The event type for mouse move events, you can use its value directly: 'mousemove' + !#zh 当鼠标在目标节点在目标节点区域中移动时,不论是否按下。 */ + static MOUSE_MOVE: string; + /** !#en The event type for mouse enter target events, you can use its value directly: 'mouseenter' + !#zh 当鼠标移入目标节点区域时,不论是否按下。 */ + static MOUSE_ENTER: string; + /** !#en The event type for mouse leave target events, you can use its value directly: 'mouseleave' + !#zh 当鼠标移出目标节点区域时,不论是否按下。 */ + static MOUSE_LEAVE: string; + /** !#en The event type for mouse up events, you can use its value directly: 'mouseup' + !#zh 当鼠标从按下状态松开时触发一次。 */ + static MOUSE_UP: string; + /** !#en The event type for mouse wheel events, you can use its value directly: 'mousewheel' + !#zh 当鼠标滚轮滚动时。 */ + static MOUSE_WHEEL: string; + /** !#en The event type for position change events. + Performance note, this event will be triggered every time corresponding properties being changed, + if the event callback have heavy logic it may have great performance impact, try to avoid such scenario. + !#zh 当节点位置改变时触发的事件。 + 性能警告:这个事件会在每次对应的属性被修改时触发,如果事件回调损耗较高,有可能对性能有很大的负面影响,请尽量避免这种情况。 */ + static POSITION_CHANGED: string; + /** !#en The event type for rotation change events. + Performance note, this event will be triggered every time corresponding properties being changed, + if the event callback have heavy logic it may have great performance impact, try to avoid such scenario. + !#zh 当节点旋转改变时触发的事件。 + 性能警告:这个事件会在每次对应的属性被修改时触发,如果事件回调损耗较高,有可能对性能有很大的负面影响,请尽量避免这种情况。 */ + static ROTATION_CHANGED: string; + /** !#en The event type for scale change events. + Performance note, this event will be triggered every time corresponding properties being changed, + if the event callback have heavy logic it may have great performance impact, try to avoid such scenario. + !#zh 当节点缩放改变时触发的事件。 + 性能警告:这个事件会在每次对应的属性被修改时触发,如果事件回调损耗较高,有可能对性能有很大的负面影响,请尽量避免这种情况。 */ + static SCALE_CHANGED: string; + /** !#en The event type for size change events. + Performance note, this event will be triggered every time corresponding properties being changed, + if the event callback have heavy logic it may have great performance impact, try to avoid such scenario. + !#zh 当节点尺寸改变时触发的事件。 + 性能警告:这个事件会在每次对应的属性被修改时触发,如果事件回调损耗较高,有可能对性能有很大的负面影响,请尽量避免这种情况。 */ + static SIZE_CHANGED: string; + /** !#en The event type for anchor point change events. + Performance note, this event will be triggered every time corresponding properties being changed, + if the event callback have heavy logic it may have great performance impact, try to avoid such scenario. + !#zh 当节点锚点改变时触发的事件。 + 性能警告:这个事件会在每次对应的属性被修改时触发,如果事件回调损耗较高,有可能对性能有很大的负面影响,请尽量避免这种情况。 */ + static ANCHOR_CHANGED: string; + /** !#en The event type for color change events. + Performance note, this event will be triggered every time corresponding properties being changed, + if the event callback have heavy logic it may have great performance impact, try to avoid such scenario. + !#zh 当节点颜色改变时触发的事件。 + 性能警告:这个事件会在每次对应的属性被修改时触发,如果事件回调损耗较高,有可能对性能有很大的负面影响,请尽量避免这种情况。 */ + static COLOR_CHANGED: string; + /** !#en The event type for new child added events. + !#zh 当新的子节点被添加时触发的事件。 */ + static CHILD_ADDED: string; + /** !#en The event type for child removed events. + !#zh 当子节点被移除时触发的事件。 */ + static CHILD_REMOVED: string; + /** !#en The event type for children reorder events. + !#zh 当子节点顺序改变时触发的事件。 */ + static CHILD_REORDER: string; + /** !#en The event type for node group changed events. + !#zh 当节点归属群组发生变化时触发的事件。 */ + static GROUP_CHANGED: string; + /** !#en The event type for node's sibling order changed. + !#zh 当节点在兄弟节点中的顺序发生变化时触发的事件。 */ + static SIBLING_ORDER_CHANGED: string; + } + } + + /**************************************************** + * VideoPlayer + *****************************************************/ + + export namespace VideoPlayer { + /** !#en Video event type + !#zh 视频事件类型 */ + export enum EventType { + PLAYING = 0, + PAUSED = 0, + STOPPED = 0, + COMPLETED = 0, + META_LOADED = 0, + CLICKED = 0, + READY_TO_PLAY = 0, + } + } + + /**************************************************** + * VideoPlayer + *****************************************************/ + + export namespace VideoPlayer { + /** !#en Enum for video resouce type type. + !#zh 视频来源 */ + export enum ResourceType { + REMOTE = 0, + LOCAL = 0, + } + } + + /**************************************************** + * ParticleSystem + *****************************************************/ + + export namespace ParticleSystem { + /** !#en Enum for emitter modes + !#zh 发射模式 */ + export enum EmitterMode { + GRAVITY = 0, + RADIUS = 0, + } + } + + /**************************************************** + * ParticleSystem + *****************************************************/ + + export namespace ParticleSystem { + /** !#en Enum for particles movement type. + !#zh 粒子位置类型 */ + export enum PositionType { + FREE = 0, + RELATIVE = 0, + GROUPED = 0, + } + } + + /**************************************************** + * TiledMap + *****************************************************/ + + export namespace TiledMap { + /** !#en The orientation of tiled map. + !#zh Tiled Map 地图方向。 */ + export enum Orientation { + ORTHO = 0, + HEX = 0, + ISO = 0, + } + } + + /**************************************************** + * TiledMap + *****************************************************/ + + export namespace TiledMap { + /** The property type of tiled map. */ + export enum Property { + NONE = 0, + MAP = 0, + LAYER = 0, + OBJECTGROUP = 0, + OBJECT = 0, + TILE = 0, + } + } + + /**************************************************** + * TiledMap + *****************************************************/ + + export namespace TiledMap { + /** The tile flags of tiled map. */ + export enum TileFlag { + HORIZONTAL = 0, + VERTICAL = 0, + DIAGONAL = 0, + FLIPPED_ALL = 0, + FLIPPED_MASK = 0, + } + } + + /**************************************************** + * TiledMap + *****************************************************/ + + export namespace TiledMap { + /** !#en The stagger axis of Hex tiled map. + !#zh 六边形地图的 stagger axis 值 */ + export enum StaggerAxis { + STAGGERAXIS_X = 0, + STAGGERAXIS_Y = 0, + } + } + + /**************************************************** + * TiledMap + *****************************************************/ + + export namespace TiledMap { + /** !#en The render order of tiled map. + !#zh 地图的渲染顺序 */ + export enum RenderOrder { + STAGGERINDEX_ODD = 0, + STAGGERINDEX_EVEN = 0, + RightDown = 0, + RightUp = 0, + LeftDown = 0, + LeftUp = 0, + } + } + + /**************************************************** + * TiledMap + *****************************************************/ + + export namespace TiledMap { + /** !#en TiledMap Object Type + !#zh 地图物体类型 */ + export enum TMXObjectType { + RECT = 0, + ELLIPSE = 0, + POLYGON = 0, + POLYLINE = 0, + IMAGE = 0, + TEXT = 0, + } + } + + /**************************************************** + * WebView + *****************************************************/ + + export namespace WebView { + /** !#en WebView event type + !#zh 网页视图事件类型 */ + export enum EventType { + LOADED = 0, + LOADING = 0, + ERROR = 0, + } + } + + /**************************************************** + * Camera + *****************************************************/ + + export namespace Camera { + /** !#en Values for Camera.clearFlags, determining what to clear when rendering a Camera. + !#zh 摄像机清除标记位,决定摄像机渲染时会清除哪些状态 */ + export enum ClearFlags { + COLOR = 0, + DEPTH = 0, + STENCIL = 0, + } + } + + /**************************************************** + * Light + *****************************************************/ + + export namespace Light { + /** !#en The light source type + + !#zh 光源类型 */ + export enum Type { + DIRECTIONAL = 0, + POINT = 0, + SPOT = 0, + AMBIENT = 0, + } + } + + /**************************************************** + * Light + *****************************************************/ + + export namespace Light { + /** !#en The shadow type + + !#zh 阴影类型 */ + export enum ShadowType { + NONE = 0, + HARD = 0, + SOFT_PCF3X3 = 0, + SOFT_PCF5X5 = 0, + } + } + + /**************************************************** + * Prefab + *****************************************************/ + + export namespace Prefab { + /** !#zh + Prefab 创建实例所用的优化策略,配合 {{#crossLink "Prefab.optimizationPolicy"}}cc.Prefab#optimizationPolicy{{/crossLink}} 使用。 + !#en + An enumeration used with the {{#crossLink "Prefab.optimizationPolicy"}}cc.Prefab#optimizationPolicy{{/crossLink}} + to specify how to optimize the instantiate operation. */ + export enum OptimizationPolicy { + AUTO = 0, + SINGLE_INSTANCE = 0, + MULTI_INSTANCE = 0, + } + } + + /**************************************************** + * RenderTexture + *****************************************************/ + + export namespace RenderTexture { + /** !#en The depth buffer and stencil buffer format for RenderTexture. + !#zh RenderTexture 的深度缓冲以及模板缓冲格式。 */ + export enum DepthStencilFormat { + RB_FMT_D24S8 = 0, + RB_FMT_S8 = 0, + RB_FMT_D16 = 0, + } + } + + /**************************************************** + * Texture2D + *****************************************************/ + + export namespace Texture2D { + /** The texture pixel format, default value is RGBA8888, + you should note that textures loaded by normal image files (png, jpg) can only support RGBA8888 format, + other formats are supported by compressed file types or raw data. */ + export enum PixelFormat { + RGB565 = 0, + RGB5A1 = 0, + RGBA4444 = 0, + RGB888 = 0, + RGBA8888 = 0, + RGBA32F = 0, + A8 = 0, + I8 = 0, + AI88 = 0, + RGB_PVRTC_2BPPV1 = 0, + RGBA_PVRTC_2BPPV1 = 0, + RGB_A_PVRTC_2BPPV1 = 0, + RGB_PVRTC_4BPPV1 = 0, + RGBA_PVRTC_4BPPV1 = 0, + RGB_A_PVRTC_4BPPV1 = 0, + RGB_ETC1 = 0, + RGBA_ETC1 = 0, + RGB_ETC2 = 0, + RGBA_ETC2 = 0, + } + } + + /**************************************************** + * Texture2D + *****************************************************/ + + export namespace Texture2D { + /** The texture wrap mode */ + export enum WrapMode { + REPEAT = 0, + CLAMP_TO_EDGE = 0, + MIRRORED_REPEAT = 0, + } + } + + /**************************************************** + * Texture2D + *****************************************************/ + + export namespace Texture2D { + /** The texture filter mode */ + export enum Filter { + LINEAR = 0, + NEAREST = 0, + } + } + + /**************************************************** + * Collider + *****************************************************/ + + export namespace Collider { + /** !#en Defines a Box Collider . + !#zh 用来定义包围盒碰撞体 */ + export class Box { + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Box size + !#zh 包围盒大小 */ + size: Size; + } + } + + /**************************************************** + * Collider + *****************************************************/ + + export namespace Collider { + /** !#en Defines a Circle Collider . + !#zh 用来定义圆形碰撞体 */ + export class Circle { + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Circle radius + !#zh 圆形半径 */ + radius: number; + } + } + + /**************************************************** + * Collider + *****************************************************/ + + export namespace Collider { + /** !#en Defines a Polygon Collider . + !#zh 用来定义多边形碰撞体 */ + export class Polygon { + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Polygon points + !#zh 多边形顶点数组 */ + points: Vec2[]; + } + } + + /**************************************************** + * Event + *****************************************************/ + + export namespace Event { + /** !#en The mouse event + !#zh 鼠标事件类型 */ + export class EventMouse extends Event { + /** + !#en Sets scroll data. + !#zh 设置鼠标的滚动数据。 + @param scrollX scrollX + @param scrollY scrollY + */ + setScrollData(scrollX: number, scrollY: number): void; + /** + !#en Returns the x axis scroll value. + !#zh 获取鼠标滚动的X轴距离,只有滚动时才有效。 + */ + getScrollX(): number; + /** + !#en Returns the y axis scroll value. + !#zh 获取滚轮滚动的 Y 轴距离,只有滚动时才有效。 + */ + getScrollY(): number; + /** + !#en Sets cursor location. + !#zh 设置当前鼠标位置。 + @param x x + @param y y + */ + setLocation(x: number, y: number): void; + /** + !#en Returns cursor location. + !#zh 获取鼠标位置对象,对象包含 x 和 y 属性。 + */ + getLocation(): Vec2; + /** + !#en Returns the current cursor location in screen coordinates. + !#zh 获取当前事件在游戏窗口内的坐标位置对象,对象包含 x 和 y 属性。 + */ + getLocationInView(): Vec2; + /** + !#en Returns the previous touch location. + !#zh 获取鼠标点击在上一次事件时的位置对象,对象包含 x 和 y 属性。 + */ + getPreviousLocation(): Vec2; + /** + !#en Returns the delta distance from the previous location to current location. + !#zh 获取鼠标距离上一次事件移动的距离对象,对象包含 x 和 y 属性。 + */ + getDelta(): Vec2; + /** + !#en Returns the X axis delta distance from the previous location to current location. + !#zh 获取鼠标距离上一次事件移动的 X 轴距离。 + */ + getDeltaX(): number; + /** + !#en Returns the Y axis delta distance from the previous location to current location. + !#zh 获取鼠标距离上一次事件移动的 Y 轴距离。 + */ + getDeltaY(): number; + /** + !#en Sets mouse button. + !#zh 设置鼠标按键。 + @param button button + */ + setButton(button: number): void; + /** + !#en Returns mouse button. + !#zh 获取鼠标按键。 + */ + getButton(): number; + /** + !#en Returns location X axis data. + !#zh 获取鼠标当前位置 X 轴。 + */ + getLocationX(): number; + /** + !#en Returns location Y axis data. + !#zh 获取鼠标当前位置 Y 轴。 + */ + getLocationY(): number; + /** !#en The none event code of mouse event. + !#zh 无。 */ + static NONE: number; + /** !#en The event type code of mouse down event. + !#zh 鼠标按下事件。 */ + static DOWN: number; + /** !#en The event type code of mouse up event. + !#zh 鼠标按下后释放事件。 */ + static UP: number; + /** !#en The event type code of mouse move event. + !#zh 鼠标移动事件。 */ + static MOVE: number; + /** !#en The event type code of mouse scroll event. + !#zh 鼠标滚轮事件。 */ + static SCROLL: number; + /** !#en The tag of Mouse left button. + !#zh 鼠标左键的标签。 */ + static BUTTON_LEFT: number; + /** !#en The tag of Mouse right button (The right button number is 2 on browser). + !#zh 鼠标右键的标签。 */ + static BUTTON_RIGHT: number; + /** !#en The tag of Mouse middle button (The right button number is 1 on browser). + !#zh 鼠标中键的标签。 */ + static BUTTON_MIDDLE: number; + /** !#en The tag of Mouse button 4. + !#zh 鼠标按键 4 的标签。 */ + static BUTTON_4: number; + /** !#en The tag of Mouse button 5. + !#zh 鼠标按键 5 的标签。 */ + static BUTTON_5: number; + /** !#en The tag of Mouse button 6. + !#zh 鼠标按键 6 的标签。 */ + static BUTTON_6: number; + /** !#en The tag of Mouse button 7. + !#zh 鼠标按键 7 的标签。 */ + static BUTTON_7: number; + /** !#en The tag of Mouse button 8. + !#zh 鼠标按键 8 的标签。 */ + static BUTTON_8: number; + } + } + + /**************************************************** + * Event + *****************************************************/ + + export namespace Event { + /** !#en The touch event + !#zh 触摸事件 */ + export class EventTouch extends Event { + /** + + @param touchArr The array of the touches + @param bubbles A boolean indicating whether the event bubbles up through the tree or not + */ + constructor(touchArr: any[], bubbles: boolean); + /** !#en The current touch object + !#zh 当前触点对象 */ + touch: Touch; + /** + !#en Returns event code. + !#zh 获取事件类型。 + */ + getEventCode(): number; + /** + !#en Returns touches of event. + !#zh 获取触摸点的列表。 + */ + getTouches(): any[]; + /** + !#en Sets touch location. + !#zh 设置当前触点位置 + @param x x + @param y y + */ + setLocation(x: number, y: number): void; + /** + !#en Returns touch location. + !#zh 获取触点位置。 + */ + getLocation(): Vec2; + /** + !#en Returns the current touch location in screen coordinates. + !#zh 获取当前触点在游戏窗口中的位置。 + */ + getLocationInView(): Vec2; + /** + !#en Returns the previous touch location. + !#zh 获取触点在上一次事件时的位置对象,对象包含 x 和 y 属性。 + */ + getPreviousLocation(): Vec2; + /** + !#en Returns the start touch location. + !#zh 获取触点落下时的位置对象,对象包含 x 和 y 属性。 + */ + getStartLocation(): Vec2; + /** + !#en Returns the id of cc.Touch. + !#zh 触点的标识 ID,可以用来在多点触摸中跟踪触点。 + */ + getID(): number; + /** + !#en Returns the delta distance from the previous location to current location. + !#zh 获取触点距离上一次事件移动的距离对象,对象包含 x 和 y 属性。 + */ + getDelta(): Vec2; + /** + !#en Returns the X axis delta distance from the previous location to current location. + !#zh 获取触点距离上一次事件移动的 x 轴距离。 + */ + getDeltaX(): number; + /** + !#en Returns the Y axis delta distance from the previous location to current location. + !#zh 获取触点距离上一次事件移动的 y 轴距离。 + */ + getDeltaY(): number; + /** + !#en Returns location X axis data. + !#zh 获取当前触点 X 轴位置。 + */ + getLocationX(): number; + /** + !#en Returns location Y axis data. + !#zh 获取当前触点 Y 轴位置。 + */ + getLocationY(): number; + } + } + + /**************************************************** + * Event + *****************************************************/ + + export namespace Event { + /** !#en The acceleration event + !#zh 加速度事件 */ + export class EventAcceleration extends Event { + } + } + + /**************************************************** + * Event + *****************************************************/ + + export namespace Event { + /** !#en The keyboard event + !#zh 键盘事件 */ + export class EventKeyboard extends Event { + /** !#en + The keyCode read-only property represents a system and implementation dependent numerical code identifying the unmodified value of the pressed key. + This is usually the decimal ASCII (RFC 20) or Windows 1252 code corresponding to the key. + If the key can't be identified, this value is 0. + + !#zh + keyCode 是只读属性它表示一个系统和依赖于实现的数字代码,可以识别按键的未修改值。 + 这通常是十进制 ASCII (RFC20) 或者 Windows 1252 代码,所对应的密钥。 + 如果无法识别该键,则该值为 0。 */ + keyCode: number; + } + } + + /**************************************************** + * Event + *****************************************************/ + + export namespace Event { + /** !#en The Custom event + !#zh 自定义事件 */ + export class EventCustom extends Event { + /** + + @param type The name of the event (case-sensitive), e.g. "click", "fire", or "submit" + @param bubbles A boolean indicating whether the event bubbles up through the tree or not + */ + constructor(type: string, bubbles: boolean); + /** !#en A reference to the detailed data of the event + !#zh 事件的详细数据 */ + detail: any; + /** + !#en Sets user data + !#zh 设置用户数据 + @param data data + */ + setUserData(data: any): void; + /** + !#en Gets user data + !#zh 获取用户数据 + */ + getUserData(): any; + /** + !#en Gets event name + !#zh 获取事件名称 + */ + getEventName(): string; + } + } + + /**************************************************** + * SystemEvent + *****************************************************/ + + export namespace SystemEvent { + /** !#en The event type supported by SystemEvent + !#zh SystemEvent 支持的事件类型 */ + export class EventType { + /** !#en The event type for press the key down event, you can use its value directly: 'keydown' + !#zh 当按下按键时触发的事件 */ + static KEY_DOWN: string; + /** !#en The event type for press the key up event, you can use its value directly: 'keyup' + !#zh 当松开按键时触发的事件 */ + static KEY_UP: string; + /** !#en The event type for press the devicemotion event, you can use its value directly: 'devicemotion' + !#zh 重力感应 */ + static DEVICEMOTION: string; + } + } + + /**************************************************** + * Animation + *****************************************************/ + + export namespace Animation { + /** !#en The event type supported by Animation + !#zh Animation 支持的事件类型 */ + export class EventType { + /** !#en Emit when begin playing animation + !#zh 开始播放时触发 */ + static PLAY: string; + /** !#en Emit when stop playing animation + !#zh 停止播放时触发 */ + static STOP: string; + /** !#en Emit when pause animation + !#zh 暂停播放时触发 */ + static PAUSE: string; + /** !#en Emit when resume animation + !#zh 恢复播放时触发 */ + static RESUME: string; + /** !#en If animation repeat count is larger than 1, emit when animation play to the last frame + !#zh 假如动画循环次数大于 1,当动画播放到最后一帧时触发 */ + static LASTFRAME: string; + /** !#en Emit when finish playing animation + !#zh 动画播放完成时触发 */ + static FINISHED: string; + } + } + + /**************************************************** + * Button + *****************************************************/ + + export namespace Button { + /** !#en Enum for transition type. + !#zh 过渡类型 */ + export enum Transition { + NONE = 0, + COLOR = 0, + SPRITE = 0, + SCALE = 0, + } + } + + /**************************************************** + * Component + *****************************************************/ + + export namespace Component { + /** !#en + Component will register a event to target component's handler. + And it will trigger the handler when a certain event occurs. + + !@zh + “EventHandler” 类用来设置场景中的事件回调, + 该类允许用户设置回调目标节点,目标组件名,组件方法名, + 并可通过 emit 方法调用目标函数。 */ + export class EventHandler { + /** !#en the node that contains target callback, such as the node example script belongs to + !#zh 事件响应函数所在节点 ,比如例子中脚本归属的节点本身 */ + target: Node; + /** !#en name of the component(script) that contains target callback, such as the name 'MainMenu' of script in example + !#zh 事件响应函数所在组件名(脚本名), 比如例子中的脚本名 'MainMenu' */ + component: string; + /** !#en Event handler, such as function's name 'onClick' in example + !#zh 响应事件函数名,比如例子中的 'onClick' */ + handler: string; + /** !#en Custom Event Data, such as 'eventType' in example + !#zh 自定义事件数据,比如例子中的 eventType */ + customEventData: string; + /** + + @param events events + @param params params + */ + static emitEvents(events: EventHandler[], ...params: any[]): void; + /** + !#en Emit event with params + !#zh 触发目标组件上的指定 handler 函数,该参数是回调函数的参数值(可不填)。 + @param params params + + @example + ```js + // Call Function + var eventHandler = new cc.Component.EventHandler(); + eventHandler.target = newTarget; + eventHandler.component = "MainMenu"; + eventHandler.handler = "OnClick" + eventHandler.emit(["param1", "param2", ....]); + ``` + */ + emit(params: any[]): void; + } + } + + /**************************************************** + * Label + *****************************************************/ + + export namespace Label { + /** !#en Enum for text alignment. + !#zh 文本横向对齐类型 */ + export enum HorizontalAlign { + LEFT = 0, + CENTER = 0, + RIGHT = 0, + } + } + + /**************************************************** + * Label + *****************************************************/ + + export namespace Label { + /** !#en Enum for vertical text alignment. + !#zh 文本垂直对齐类型 */ + export enum VerticalAlign { + TOP = 0, + CENTER = 0, + BOTTOM = 0, + } + } + + /**************************************************** + * Label + *****************************************************/ + + export namespace Label { + /** !#en Enum for Overflow. + !#zh Overflow 类型 */ + export enum Overflow { + NONE = 0, + CLAMP = 0, + SHRINK = 0, + RESIZE_HEIGHT = 0, + } + } + + /**************************************************** + * Label + *****************************************************/ + + export namespace Label { + /** !#en Enum for font type. + !#zh Type 类型 */ + export enum Type { + TTF = 0, + BMFont = 0, + SystemFont = 0, + } + } + + /**************************************************** + * Label + *****************************************************/ + + export namespace Label { + /** !#en Enum for cache mode. + !#zh CacheMode 类型 */ + export enum CacheMode { + NONE = 0, + BITMAP = 0, + CHAR = 0, + } + } + + /**************************************************** + * Layout + *****************************************************/ + + export namespace Layout { + /** !#en Enum for Layout type + !#zh 布局类型 */ + export enum Type { + NONE = 0, + HORIZONTAL = 0, + VERTICAL = 0, + GRID = 0, + } + } + + /**************************************************** + * Layout + *****************************************************/ + + export namespace Layout { + /** !#en Enum for Layout Resize Mode + !#zh 缩放模式 */ + export enum ResizeMode { + NONE = 0, + CONTAINER = 0, + CHILDREN = 0, + } + } + + /**************************************************** + * Layout + *****************************************************/ + + export namespace Layout { + /** !#en Enum for Grid Layout start axis direction. + The items in grid layout will be arranged in each axis at first.; + !#zh 布局轴向,只用于 GRID 布局。 */ + export enum AxisDirection { + HORIZONTAL = 0, + VERTICAL = 0, + } + } + + /**************************************************** + * Layout + *****************************************************/ + + export namespace Layout { + /** !#en Enum for vertical layout direction. + Used in Grid Layout together with AxisDirection is VERTICAL + !#zh 垂直方向布局方式 */ + export enum VerticalDirection { + BOTTOM_TO_TOP = 0, + TOP_TO_BOTTOM = 0, + } + } + + /**************************************************** + * Layout + *****************************************************/ + + export namespace Layout { + /** !#en Enum for horizontal layout direction. + Used in Grid Layout together with AxisDirection is HORIZONTAL + !#zh 水平方向布局方式 */ + export enum HorizontalDirection { + LEFT_TO_RIGHT = 0, + RIGHT_TO_LEFT = 0, + } + } + + /**************************************************** + * Mask + *****************************************************/ + + export namespace Mask { + /** !#en the type for mask. + !#zh 遮罩组件类型 */ + export enum Type { + RECT = 0, + ELLIPSE = 0, + IMAGE_STENCIL = 0, + } + } + + /**************************************************** + * PageView + *****************************************************/ + + export namespace PageView { + /** !#en The Page View Size Mode + !#zh 页面视图每个页面统一的大小类型 */ + export enum SizeMode { + Unified = 0, + Free = 0, + } + } + + /**************************************************** + * PageView + *****************************************************/ + + export namespace PageView { + /** !#en The Page View Direction + !#zh 页面视图滚动类型 */ + export enum Direction { + Horizontal = 0, + Vertical = 0, + } + } + + /**************************************************** + * PageView + *****************************************************/ + + export namespace PageView { + /** !#en Enum for ScrollView event type. + !#zh 滚动视图事件类型 */ + export enum EventType { + PAGE_TURNING = 0, + } + } + + /**************************************************** + * PageViewIndicator + *****************************************************/ + + export namespace PageViewIndicator { + /** !#en Enum for PageView Indicator direction + !#zh 页面视图指示器的摆放方向 */ + export enum Direction { + HORIZONTAL = 0, + VERTICAL = 0, + } + } + + /**************************************************** + * ProgressBar + *****************************************************/ + + export namespace ProgressBar { + /** !#en Enum for ProgressBar mode + !#zh 进度条模式 */ + export enum Mode { + HORIZONTAL = 0, + VERTICAL = 0, + FILLED = 0, + } + } + + /**************************************************** + * Scrollbar + *****************************************************/ + + export namespace Scrollbar { + /** Enum for Scrollbar direction */ + export enum Direction { + HORIZONTAL = 0, + VERTICAL = 0, + } + } + + /**************************************************** + * ScrollView + *****************************************************/ + + export namespace ScrollView { + /** !#en Enum for ScrollView event type. + !#zh 滚动视图事件类型 */ + export enum EventType { + SCROLL_TO_TOP = 0, + SCROLL_TO_BOTTOM = 0, + SCROLL_TO_LEFT = 0, + SCROLL_TO_RIGHT = 0, + SCROLLING = 0, + BOUNCE_TOP = 0, + BOUNCE_BOTTOM = 0, + BOUNCE_LEFT = 0, + BOUNCE_RIGHT = 0, + SCROLL_ENDED = 0, + TOUCH_UP = 0, + AUTOSCROLL_ENDED_WITH_THRESHOLD = 0, + SCROLL_BEGAN = 0, + } + } + + /**************************************************** + * Slider + *****************************************************/ + + export namespace Slider { + /** !#en The Slider Direction + !#zh 滑动器方向 */ + export enum Direction { + Horizontal = 0, + Vertical = 0, + } + } + + /**************************************************** + * Sprite + *****************************************************/ + + export namespace Sprite { + /** !#en Enum for sprite type. + !#zh Sprite 类型 */ + export enum Type { + SIMPLE = 0, + SLICED = 0, + TILED = 0, + FILLED = 0, + MESH = 0, + } + } + + /**************************************************** + * Sprite + *****************************************************/ + + export namespace Sprite { + /** !#en Enum for fill type. + !#zh 填充类型 */ + export enum FillType { + HORIZONTAL = 0, + VERTICAL = 0, + RADIAL = 0, + } + } + + /**************************************************** + * Sprite + *****************************************************/ + + export namespace Sprite { + /** !#en Sprite Size can track trimmed size, raw size or none. + !#zh 精灵尺寸调整模式 */ + export enum SizeMode { + CUSTOM = 0, + TRIMMED = 0, + RAW = 0, + } + } + + /**************************************************** + * Sprite + *****************************************************/ + + export namespace Sprite { + /** !#en Sprite state can choice the normal or grayscale. + !#zh 精灵颜色通道模式。 */ + export enum State { + NORMAL = 0, + GRAY = 0, + } + } + + /**************************************************** + * Widget + *****************************************************/ + + export namespace Widget { + /** !#en Enum for Widget's alignment mode, indicating when the widget should refresh. + !#zh Widget 的对齐模式,表示 Widget 应该何时刷新。 */ + export enum AlignMode { + ONCE = 0, + ON_WINDOW_RESIZE = 0, + ALWAYS = 0, + } + } + + /**************************************************** + * geomUtils + *****************************************************/ + + export namespace geomUtils { + /** Aabb */ + export class Aabb { + /** + create a new aabb + @param px X coordinates for aabb's original point + @param py Y coordinates for aabb's original point + @param pz Z coordinates for aabb's original point + @param w the half of aabb width + @param h the half of aabb height + @param l the half of aabb length + */ + create(px: number, py: number, pz: number, w: number, h: number, l: number): Aabb; + /** + clone a new aabb + @param a the source aabb + */ + clone(a: Aabb): Aabb; + /** + copy the values from one aabb to another + @param out the receiving aabb + @param a the source aabb + */ + copy(out: Aabb, a: Aabb): Aabb; + /** + create a new aabb from two corner points + @param out the receiving aabb + @param minPos lower corner position of the aabb + @param maxPos upper corner position of the aabb + */ + fromPoints(out: Aabb, minPos: Vec3, maxPos: Vec3): Aabb; + /** + Set the components of a aabb to the given values + @param out the receiving aabb + @param px X coordinates for aabb's original point + @param py Y coordinates for aabb's original point + @param pz Z coordinates for aabb's original point + @param w the half of aabb width + @param h the half of aabb height + @param l the half of aabb length + */ + set(out: Aabb, px: number, py: number, pz: number, w: number, h: number, l: number): Aabb; + center: Vec3; + halfExtents: Vec3; + _type: number; + /** + Get the bounding points of this shape + @param minPos minPos + @param maxPos maxPos + */ + getBoundary(minPos: Vec3, maxPos: Vec3): void; + /** + Transform this shape + @param m the transform matrix + @param pos the position part of the transform + @param rot the rotation part of the transform + @param scale the scale part of the transform + @param out the target shape + */ + transform(m: Mat4, pos: Vec3, rot: Quat, scale: Vec3, out?: Aabb): void; + } + } + + /**************************************************** + * geomUtils + *****************************************************/ + + export namespace geomUtils { + /** !#en Shape type. */ + export enum enums { + SHAPE_RAY = 0, + SHAPE_LINE = 0, + SHAPE_SPHERE = 0, + SHAPE_AABB = 0, + SHAPE_OBB = 0, + SHAPE_PLANE = 0, + SHAPE_TRIANGLE = 0, + SHAPE_FRUSTUM = 0, + SHAPE_FRUSTUM_ACCURATE = 0, + } + } + + /**************************************************** + * geomUtils + *****************************************************/ + + export namespace geomUtils { + /** !#en frustum + !#zh 平截头体 */ + export class Frustum { + /** Set whether to use accurate intersection testing function on this frustum */ + accurate: boolean; + /** + create a new frustum + */ + static create(): Frustum; + /** + Clone a frustum + @param f f + */ + static clone(f: Frustum): Frustum; + /** + Copy the values from one frustum to another + @param out out + @param f f + */ + copy(out: Frustum, f: Frustum): Frustum; + planes: geomUtils.Plane[]; + planes: Vec3[]; + /** + !#en Update the frustum information according to the given transform matrix. + Note that the resulting planes are not normalized under normal mode. + @param m the view-projection matrix + @param inv the inverse view-projection matrix + */ + update(m: Mat4, inv: Mat4): void; + /** + !#en transform by matrix + @param mat mat + */ + transform(mat: Mat4): void; + } + } + + /**************************************************** + * geomUtils + *****************************************************/ + + export namespace geomUtils { + /** undefined */ + export class intersect { + /** + !#en + Check whether ray intersect with nodes + !#zh + 检测射线是否与物体有交集 + @param root If root is null, then traversal nodes from scene node + @param worldRay worldRay + @param handler handler + @param filter filter + */ + static ray_cast(root: Node, worldRay: geomUtils.Ray, handler: Function, filter: Function): any[]; + /** + !#en ray-plane intersect
+ !#zh 射线与平面的相交性检测。 + @param ray ray + @param plane plane + */ + static ray_plane(ray: geomUtils.Ray, plane: geomUtils.Plane): number; + /** + !#en line-plane intersect
+ !#zh 线段与平面的相交性检测。 + @param line line + @param plane plane + */ + static line_plane(line: geomUtils.Line, plane: geomUtils.Plane): number; + /** + !#en ray-triangle intersect
+ !#zh 射线与三角形的相交性检测。 + @param ray ray + @param triangle triangle + @param doubleSided doubleSided + */ + static ray_triangle(ray: geomUtils.Ray, triangle: geomUtils.Triangle, doubleSided: boolean): number; + /** + !#en line-triangle intersect
+ !#zh 线段与三角形的相交性检测。 + @param line line + @param triangle triangle + @param outPt optional, The intersection point + */ + static line_triangle(line: geomUtils.Line, triangle: geomUtils.Triangle, outPt: Vec3): number; + /** + !#en line-quad intersect
+ !#zh 线段与四边形的相交性检测。 + @param p A point on a line segment + @param q Another point on the line segment + @param a Quadrilateral point a + @param b Quadrilateral point b + @param c Quadrilateral point c + @param d Quadrilateral point d + @param outPt optional, The intersection point + */ + static line_quad(p: Vec3, q: Vec3, a: Vec3, b: Vec3, c: Vec3, d: Vec3, outPt: Vec3): number; + /** + !#en ray-sphere intersect
+ !#zh 射线和球的相交性检测。 + @param ray ray + @param sphere sphere + */ + static ray_sphere(ray: geomUtils.Ray, sphere: geomUtils.Sphere): number; + /** + !#en ray-aabb intersect
+ !#zh 射线和轴对齐包围盒的相交性检测。 + @param ray ray + @param aabb Align the axis around the box + */ + static ray_aabb(ray: geomUtils.Ray, aabb: Aabb): number; + /** + !#en ray-obb intersect
+ !#zh 射线和方向包围盒的相交性检测。 + @param ray ray + @param obb Direction box + */ + static ray_obb(ray: geomUtils.Ray, obb: geomUtils.Obb): number; + /** + !#en aabb-aabb intersect
+ !#zh 轴对齐包围盒和轴对齐包围盒的相交性检测。 + @param aabb1 Axis alignment surrounds box 1 + @param aabb2 Axis alignment surrounds box 2 + */ + static aabb_aabb(aabb1: Aabb, aabb2: Aabb): number; + /** + !#en aabb-obb intersect
+ !#zh 轴对齐包围盒和方向包围盒的相交性检测。 + @param aabb Align the axis around the box + @param obb Direction box + */ + static aabb_obb(aabb: Aabb, obb: geomUtils.Obb): number; + /** + !#en aabb-plane intersect
+ !#zh 轴对齐包围盒和平面的相交性检测。 + @param aabb Align the axis around the box + @param plane plane + */ + static aabb_plane(aabb: Aabb, plane: geomUtils.Plane): number; + /** + !#en aabb-frustum intersect, faster but has false positive corner cases
+ !#zh 轴对齐包围盒和锥台相交性检测,速度快,但有错误情况。 + @param aabb Align the axis around the box + @param frustum frustum + */ + static aabb_frustum(aabb: Aabb, frustum: Frustum): number; + /** + !#en aabb-frustum intersect, handles most of the false positives correctly
+ !#zh 轴对齐包围盒和锥台相交性检测,正确处理大多数错误情况。 + @param aabb Align the axis around the box + @param frustum frustum + */ + static aabb_frustum_accurate(aabb: Aabb, frustum: Frustum): number; + /** + !#en obb-point intersect
+ !#zh 方向包围盒和点的相交性检测。 + @param obb Direction box + @param point point + */ + static obb_point(obb: geomUtils.Obb, point: geomUtils.Vec3): boolean; + /** + !#en obb-plane intersect
+ !#zh 方向包围盒和平面的相交性检测。 + @param obb Direction box + @param plane plane + */ + static obb_plane(obb: geomUtils.Obb, plane: geomUtils.Plane): number; + /** + !#en obb-frustum intersect, faster but has false positive corner cases
+ !#zh 方向包围盒和锥台相交性检测,速度快,但有错误情况。 + @param obb Direction box + @param frustum frustum + */ + static obb_frustum(obb: geomUtils.Obb, frustum: Frustum): number; + /** + !#en obb-frustum intersect, handles most of the false positives correctly
+ !#zh 方向包围盒和锥台相交性检测,正确处理大多数错误情况。 + @param obb Direction box + @param frustum frustum + */ + static obb_frustum_accurate(obb: geomUtils.Obb, frustum: Frustum): number; + /** + !#en obb-obb intersect
+ !#zh 方向包围盒和方向包围盒的相交性检测。 + @param obb1 Direction box1 + @param obb2 Direction box2 + */ + static obb_obb(obb1: geomUtils.Obb, obb2: geomUtils.Obb): number; + /** + !#en phere-plane intersect, not necessarily faster than obb-plane
+ due to the length calculation of the plane normal to factor out
+ the unnomalized plane distance
+ !#zh 球与平面的相交性检测。 + @param sphere sphere + @param plane plane + */ + static sphere_plane(sphere: geomUtils.Sphere, plane: geomUtils.Plane): number; + /** + !#en sphere-frustum intersect, faster but has false positive corner cases
+ !#zh 球和锥台的相交性检测,速度快,但有错误情况。 + @param sphere sphere + @param frustum frustum + */ + static sphere_frustum(sphere: geomUtils.Sphere, frustum: Frustum): number; + /** + !#en sphere-frustum intersect, handles the false positives correctly
+ !#zh 球和锥台的相交性检测,正确处理大多数错误情况。 + @param sphere sphere + @param frustum frustum + */ + static sphere_frustum_accurate(sphere: geomUtils.Sphere, frustum: Frustum): number; + /** + !#en sphere-sphere intersect
+ !#zh 球和球的相交性检测。 + @param sphere0 sphere0 + @param sphere1 sphere1 + */ + static sphere_sphere(sphere0: geomUtils.Sphere, sphere1: geomUtils.Sphere): boolean; + /** + !#en sphere-aabb intersect
+ !#zh 球和轴对齐包围盒的相交性检测。 + @param sphere sphere + @param aabb aabb + */ + static sphere_aabb(sphere: geomUtils.Sphere, aabb: Aabb): boolean; + /** + !#en sphere-obb intersect
+ !#zh 球和方向包围盒的相交性检测。 + @param sphere sphere + @param obb obb + */ + static sphere_obb(sphere: geomUtils.Sphere, obb: geomUtils.Obb): boolean; + /** + !#en + The intersection detection of g1 and g2 can fill in the shape in the basic geometry. + !#zh + g1 和 g2 的相交性检测,可填入基础几何中的形状。 + @param g1 Geometry 1 + @param g2 Geometry 2 + @param outPt optional, Intersection point. (note: only partial shape detection with this return value) + */ + static resolve(g1: any, g2: any, outPt: any): void; + } + } + + /**************************************************** + * geomUtils + *****************************************************/ + + export namespace geomUtils { + /** !#en + line + !#zh + 直线 */ + export class Line { + /** + !#en + create a new line + !#zh + 创建一个新的 line。 + @param sx The x part of the starting point. + @param sy The y part of the starting point. + @param sz The z part of the starting point. + @param ex The x part of the end point. + @param ey The y part of the end point. + @param ez The z part of the end point. + */ + create(sx: number, sy: number, sz: number, ex: number, ey: number, ez: number): Line; + /** + !#en + Creates a new line initialized with values from an existing line + !#zh + 克隆一个新的 line。 + @param a The source of cloning. + */ + clone(a: Line): Line; + /** + !#en + Copy the values from one line to another + !#zh + 复制一个线的值到另一个。 + @param out The object that accepts the action. + @param a The source of the copy. + */ + copy(out: Line, a: Line): Line; + /** + !#en + create a line from two points + !#zh + 用两个点创建一个线。 + @param out The object that accepts the action. + @param start The starting point. + @param end At the end. + */ + fromPoints(out: Line, start: Vec3, end: Vec3): Line; + /** + !#en + Set the components of a Vec3 to the given values + !#zh + 将给定线的属性设置为给定值。 + @param out The object that accepts the action. + @param sx The x part of the starting point. + @param sy The y part of the starting point. + @param sz The z part of the starting point. + @param ex The x part of the end point. + @param ey The y part of the end point. + @param ez The z part of the end point. + */ + set(out: Line, sx: number, sy: number, sz: number, ex: number, ey: number, ez: number): Line; + /** + !#en + Calculate the length of the line. + !#zh + 计算线的长度。 + @param a The line to calculate. + */ + len(a: Line): number; + /** !#en + Start points. + !#zh + 起点。 */ + s: Vec3; + /** !#en + End points. + !#zh + 终点。 */ + e: Vec3; + /** + !#en + Calculate the length of the line. + !#zh + 计算线的长度。 + */ + length(): number; + } + } + + /**************************************************** + * geomUtils + *****************************************************/ + + export namespace geomUtils { + /** !#en obb + !#zh + 基础几何 方向包围盒。 */ + export class Obb { + /** !#zh + 获取形状的类型。 */ + type: number; + /** + !#en + create a new obb + !#zh + 创建一个新的 obb 实例。 + @param cx X coordinates of the shape relative to the origin. + @param cy Y coordinates of the shape relative to the origin. + @param cz Z coordinates of the shape relative to the origin. + @param hw Obb is half the width. + @param hh Obb is half the height. + @param hl Obb is half the Length. + @param ox_1 Direction matrix parameter. + @param ox_2 Direction matrix parameter. + @param ox_3 Direction matrix parameter. + @param oy_1 Direction matrix parameter. + @param oy_2 Direction matrix parameter. + @param oy_3 Direction matrix parameter. + @param oz_1 Direction matrix parameter. + @param oz_2 Direction matrix parameter. + @param oz_3 Direction matrix parameter. + */ + create(cx: number, cy: number, cz: number, hw: number, hh: number, hl: number, ox_1: number, ox_2: number, ox_3: number, oy_1: number, oy_2: number, oy_3: number, oz_1: number, oz_2: number, oz_3: number): Obb; + /** + !#en + clone a new obb + !#zh + 克隆一个 obb。 + @param a The target of cloning. + */ + clone(a: Obb): Obb; + /** + !#en + copy the values from one obb to another + !#zh + 将从一个 obb 的值复制到另一个 obb。 + @param out Obb that accepts the operation. + @param a Obb being copied. + */ + copy(out: Obb, a: Obb): Obb; + /** + !#en + create a new obb from two corner points + !#zh + 用两个点创建一个新的 obb。 + @param out Obb that accepts the operation. + @param minPos The smallest point of obb. + @param maxPos Obb's maximum point. + */ + fromPoints(out: Obb, minPos: Vec3, maxPos: Vec3): Obb; + /** + !#en + Set the components of a obb to the given values + !#zh + 将给定 obb 的属性设置为给定的值。 + @param cx X coordinates of the shape relative to the origin. + @param cy Y coordinates of the shape relative to the origin. + @param cz Z coordinates of the shape relative to the origin. + @param hw Obb is half the width. + @param hh Obb is half the height. + @param hl Obb is half the Length. + @param ox_1 Direction matrix parameter. + @param ox_2 Direction matrix parameter. + @param ox_3 Direction matrix parameter. + @param oy_1 Direction matrix parameter. + @param oy_2 Direction matrix parameter. + @param oy_3 Direction matrix parameter. + @param oz_1 Direction matrix parameter. + @param oz_2 Direction matrix parameter. + @param oz_3 Direction matrix parameter. + */ + set(cx: number, cy: number, cz: number, hw: number, hh: number, hl: number, ox_1: number, ox_2: number, ox_3: number, oy_1: number, oy_2: number, oy_3: number, oz_1: number, oz_2: number, oz_3: number): Obb; + /** !#en + The center of the local coordinate. + !#zh + 本地坐标的中心点。 */ + center: Vec3; + /** !#en + Half the length, width, and height. + !#zh + 长宽高的一半。 */ + halfExtents: Vec3; + /** !#en + Direction matrix. + !#zh + 方向矩阵。 */ + orientation: Mat3; + /** + !#en + Get the bounding points of this shape + !#zh + 获取 obb 的最小点和最大点。 + @param minPos minPos + @param maxPos maxPos + */ + getBoundary(minPos: Vec3, maxPos: Vec3): void; + /** + !#en Transform this shape + !#zh + 将 out 根据这个 obb 的数据进行变换。 + @param m The transformation matrix. + @param pos The position part of the transformation. + @param rot The rotating part of the transformation. + @param scale The scaling part of the transformation. + @param out Target of transformation. + */ + transform(m: Mat4, pos: Vec3, rot: Quat, scale: Vec3, out: Obb): void; + /** + !#en + Transform out based on this obb data. + !#zh + 将 out 根据这个 obb 的数据进行变换。 + @param m The transformation matrix. + @param rot The rotating part of the transformation. + @param out Target of transformation. + */ + translateAndRotate(m: Mat4, rot: Quat, out: Obb): void; + /** + !#en + Scale out based on this obb data. + !#zh + 将 out 根据这个 obb 的数据进行缩放。 + @param scale Scale value. + @param out Scaled target. + */ + setScale(scale: Vec3, out: Obb): void; + } + } + + /**************************************************** + * geomUtils + *****************************************************/ + + export namespace geomUtils { + /** !#en + plane。 + !#zh + 平面。 */ + export class Plane { + /** + !#en + create a new plane + !#zh + 创建一个新的 plane。 + @param nx The x part of the normal component. + @param ny The y part of the normal component. + @param nz The z part of the normal component. + @param d Distance from the origin. + */ + create(nx: number, ny: number, nz: number, d: number): Plane; + /** + !#en + clone a new plane + !#zh + 克隆一个新的 plane。 + @param p The source of cloning. + */ + clone(p: Plane): Plane; + /** + !#en + copy the values from one plane to another + !#zh + 复制一个平面的值到另一个。 + @param out The object that accepts the action. + @param p The source of the copy. + */ + copy(out: Plane, p: Plane): Plane; + /** + !#en + create a plane from three points + !#zh + 用三个点创建一个平面。 + @param out The object that accepts the action. + @param a Point a。 + @param b Point b。 + @param c Point c。 + */ + fromPoints(out: Plane, a: Vec3, b: Vec3, c: Vec3): Plane; + /** + !#en + Set the components of a plane to the given values + !#zh + 将给定平面的属性设置为给定值。 + @param out The object that accepts the action. + @param nx The x part of the normal component. + @param ny The y part of the normal component. + @param nz The z part of the normal component. + @param d Distance from the origin. + */ + set(out: Plane, nx: number, ny: number, nz: number, d: number): Plane; + /** + !#en + create plane from normal and point + !#zh + 用一条法线和一个点创建平面。 + @param out The object that accepts the action. + @param normal The normal of a plane. + @param point A point on the plane. + */ + fromNormalAndPoint(out: Plane, normal: Vec3, point: Vec3): Plane; + /** + !#en + normalize a plane + !#zh + 归一化一个平面。 + @param out The object that accepts the action. + @param a Source data for operations. + */ + normalize(out: Plane, a: Plane): Plane; + /** !#en + A normal vector. + !#zh + 法线向量。 */ + n: Vec3; + /** !#en + The distance from the origin to the plane. + !#zh + 原点到平面的距离。 */ + d: number; + /** + !#en + Transform a plane. + !#zh + 变换一个平面。 + @param mat mat + */ + transform(mat: Mat4): void; + } + } + + /**************************************************** + * geomUtils + *****************************************************/ + + export namespace geomUtils { + /** !#en + ray + !#zh + 射线。 */ + export class Ray { + /** + !#en + create a new ray + !#zh + 创建一条射线。 + @param ox The x part of the starting point. + @param oy The y part of the starting point. + @param oz The z part of the starting point. + @param dx X in the direction. + @param dy Y in the direction. + @param dz Z in the direction. + */ + create(ox: number, oy: number, oz: number, dx: number, dy: number, dz: number): Ray; + /** + !#en + Creates a new ray initialized with values from an existing ray + !#zh + 从一条射线克隆出一条新的射线。 + @param a Clone target + */ + clone(a: Ray): Ray; + /** + !#en + Copy the values from one ray to another + !#zh + 将从一个 ray 的值复制到另一个 ray。 + @param out Accept the ray of the operation. + @param a Copied ray. + */ + copy(out: Ray, a: Ray): Ray; + /** + !#en + create a ray from two points + !#zh + 用两个点创建一条射线。 + @param out Receive the operating ray. + @param origin Origin of ray + @param target A point on a ray. + */ + fromPoints(out: Ray, origin: Vec3, target: Vec3): Ray; + /** + !#en + Set the components of a ray to the given values + !#zh + 将给定射线的属性设置为给定的值。 + @param out Receive the operating ray. + @param ox The x part of the starting point. + @param oy The y part of the starting point. + @param oz The z part of the starting point. + @param dx X in the direction. + @param dy Y in the direction. + @param dz Z in the direction. + */ + set(out: Ray, ox: number, oy: number, oz: number, dx: number, dy: number, dz: number): Ray; + /** !#en + Start point. + !#zh + 起点。 */ + o: Vec3; + /** !#e + Direction + !#zh + 方向。 */ + d: Vec3; + /** + !#en Compute hit. + @param out out + @param distance distance + */ + computeHit(out: IVec3Like, distance: number): void; + } + } + + /**************************************************** + * geomUtils + *****************************************************/ + + export namespace geomUtils { + /** !#en + Sphere. + !#zh + 轴对齐球。 */ + export class Sphere { + /** + !#en + create a new sphere + !#zh + 创建一个新的 sphere 实例。 + @param cx X coordinates of the shape relative to the origin. + @param cy Y coordinates of the shape relative to the origin. + @param cz Z coordinates of the shape relative to the origin. + @param r Radius of sphere + */ + create(cx: any, cy: any, cz: any, r: any): Sphere; + /** + !#en + clone a new sphere + !#zh + 克隆一个新的 sphere 实例。 + @param p The target of cloning. + */ + clone(p: Sphere): Sphere; + /** + !#en + copy the values from one sphere to another + !#zh + 将从一个 sphere 的值复制到另一个 sphere。 + @param out Accept the sphere of operations. + @param a Sphere being copied. + */ + copy(out: Sphere, a: Sphere): Sphere; + /** + !#en + create a new bounding sphere from two corner points + !#zh + 从两个点创建一个新的 sphere。 + @param out Accept the sphere of operations. + @param minPos The smallest point of sphere. + @param maxPos The maximum point of sphere. + */ + fromPoints(out: any, minPos: any, maxPos: any): Sphere; + /** + !#en Set the components of a sphere to the given values + !#zh 将球体的属性设置为给定的值。 + @param out Accept the sphere of operations. + @param cx X coordinates of the shape relative to the origin. + @param cy Y coordinates of the shape relative to the origin. + @param cz Z coordinates of the shape relative to the origin. + @param r Radius. + */ + set(out: Sphere, cx: any, cy: any, cz: any, r: number): Sphere; + /** !#en + The center of the local coordinate. + !#zh + 本地坐标的中心点。 */ + center: Vec3; + /** !#zh + 半径。 */ + radius: number; + /** + !#en + Clone. + !#zh + 获得克隆。 + */ + clone(): void; + /** + !#en + Copy sphere + !#zh + 拷贝对象。 + @param a Copy target. + */ + copy(a: any): void; + /** + !#en + Get the bounding points of this shape + !#zh + 获取此形状的边界点。 + @param minPos minPos + @param maxPos maxPos + */ + getBoundary(minPos: Vec3, maxPos: Vec3): void; + /** + !#en + Transform this shape + !#zh + 将 out 根据这个 sphere 的数据进行变换。 + @param m The transformation matrix. + @param pos The position part of the transformation. + @param rot The rotating part of the transformation. + @param scale The scaling part of the transformation. + @param out The target of the transformation. + */ + transform(m: any, pos: any, rot: any, scale: any, out: any): void; + /** + !#en + Scale out based on the sphere data. + !#zh + 将 out 根据这个 sphere 的数据进行缩放。 + @param scale Scale value + @param out Scale target + */ + setScale(scale: any, out: any): void; + } + } + + /**************************************************** + * geomUtils + *****************************************************/ + + export namespace geomUtils { + /** Triangle */ + export class Triangle { + /** + create a new triangle + @param ax ax + @param ay ay + @param az az + @param bx bx + @param by by + @param bz bz + @param cx cx + @param cy cy + @param cz cz + */ + create(ax: number, ay: number, az: number, bx: number, by: number, bz: number, cx: number, cy: number, cz: number): Triangle; + /** + clone a new triangle + @param t the source plane + */ + clone(t: Triangle): Triangle; + /** + copy the values from one triangle to another + @param out the receiving triangle + @param t the source triangle + */ + copy(out: Triangle, t: Triangle): Triangle; + /** + Create a triangle from three points + @param out the receiving triangle + @param a a + @param b b + @param c c + */ + fromPoints(out: Triangle, a: Vec3, b: Vec3, c: Vec3): Triangle; + /** + Set the components of a triangle to the given values + @param out the receiving plane + @param ax X component of a + @param ay Y component of a + @param az Z component of a + @param bx X component of b + @param by Y component of b + @param bz Z component of b + @param cx X component of c + @param cy Y component of c + @param cz Z component of c + */ + set(out: Triangle, ax: number, ay: number, az: number, bx: number, by: number, bz: number, cx: number, cy: number, cz: number): Plane; + a: Vec3; + b: Vec3; + c: Vec3; + } + } + + /**************************************************** + * MeshRenderer + *****************************************************/ + + export namespace MeshRenderer { + /** !#en Shadow projection mode + + !#ch 阴影投射方式 */ + export enum ShadowCastingMode { + OFF = 0, + ON = 0, + } + } + + /**************************************************** + * Graphics + *****************************************************/ + + export namespace Graphics { + /** !#en Enum for LineCap. + !#zh 线段末端属性 */ + export enum LineCap { + BUTT = 0, + ROUND = 0, + SQUARE = 0, + } + } + + /**************************************************** + * Graphics + *****************************************************/ + + export namespace Graphics { + /** !#en Enum for LineJoin. + !#zh 线段拐角属性 */ + export enum LineJoin { + BEVEL = 0, + ROUND = 0, + MITER = 0, + } + } + + /**************************************************** + * macro + *****************************************************/ + + export namespace macro { + /** !#en Key map for keyboard event + !#zh 键盘事件的按键值 */ + export enum KEY { + none = 0, + back = 0, + menu = 0, + backspace = 0, + tab = 0, + enter = 0, + shift = 0, + ctrl = 0, + alt = 0, + pause = 0, + capslock = 0, + escape = 0, + space = 0, + pageup = 0, + pagedown = 0, + end = 0, + home = 0, + left = 0, + up = 0, + right = 0, + down = 0, + select = 0, + insert = 0, + Delete = 0, + a = 0, + b = 0, + c = 0, + d = 0, + e = 0, + f = 0, + g = 0, + h = 0, + i = 0, + j = 0, + k = 0, + l = 0, + m = 0, + n = 0, + o = 0, + p = 0, + q = 0, + r = 0, + s = 0, + t = 0, + u = 0, + v = 0, + w = 0, + x = 0, + y = 0, + z = 0, + num0 = 0, + num1 = 0, + num2 = 0, + num3 = 0, + num4 = 0, + num5 = 0, + num6 = 0, + num7 = 0, + num8 = 0, + num9 = 0, + '*' = 0, + '+' = 0, + '-' = 0, + numdel = 0, + '/' = 0, + f1 = 0, + f2 = 0, + f3 = 0, + f4 = 0, + f5 = 0, + f6 = 0, + f7 = 0, + f8 = 0, + f9 = 0, + f10 = 0, + f11 = 0, + f12 = 0, + numlock = 0, + scrolllock = 0, + ';' = 0, + semicolon = 0, + equal = 0, + '=' = 0, + ',' = 0, + comma = 0, + dash = 0, + '.' = 0, + period = 0, + forwardslash = 0, + grave = 0, + '[' = 0, + openbracket = 0, + backslash = 0, + ']' = 0, + closebracket = 0, + quote = 0, + dpadLeft = 0, + dpadRight = 0, + dpadUp = 0, + dpadDown = 0, + dpadCenter = 0, + } + } + + /**************************************************** + * macro + *****************************************************/ + + export namespace macro { + /** Image formats */ + export enum ImageFormat { + JPG = 0, + PNG = 0, + TIFF = 0, + WEBP = 0, + PVR = 0, + ETC = 0, + S3TC = 0, + ATITC = 0, + TGA = 0, + RAWDATA = 0, + UNKNOWN = 0, + } + } + + /**************************************************** + * macro + *****************************************************/ + + export namespace macro { + /** !#en + Enum for blend factor + Refer to: http://www.andersriggelsen.dk/glblendfunc.php + !#zh + 混合因子 + 可参考: http://www.andersriggelsen.dk/glblendfunc.php */ + export enum BlendFactor { + ONE = 0, + ZERO = 0, + SRC_ALPHA = 0, + SRC_COLOR = 0, + DST_ALPHA = 0, + DST_COLOR = 0, + ONE_MINUS_SRC_ALPHA = 0, + ONE_MINUS_SRC_COLOR = 0, + ONE_MINUS_DST_ALPHA = 0, + ONE_MINUS_DST_COLOR = 0, + } + } + + /**************************************************** + * macro + *****************************************************/ + + export namespace macro { + /** undefined */ + export enum TextAlignment { + LEFT = 0, + CENTER = 0, + RIGHT = 0, + } + } + + /**************************************************** + * sys + *****************************************************/ + + export namespace sys { + /** !#en + Network type enumeration + !#zh + 网络类型枚举 */ + export enum NetworkType { + NONE = 0, + LAN = 0, + WWAN = 0, + } + } + + /**************************************************** + * PhysicsManager + *****************************************************/ + + export namespace PhysicsManager { + /** !#en + The draw bits for drawing physics debug information.
+ example:
+ ```js + cc.director.getPhysicsManager().debugDrawFlags = + // cc.PhysicsManager.DrawBits.e_aabbBit | + // cc.PhysicsManager.DrawBits.e_pairBit | + // cc.PhysicsManager.DrawBits.e_centerOfMassBit | + cc.PhysicsManager.DrawBits.e_jointBit | + cc.PhysicsManager.DrawBits.e_shapeBit; + ``` + !#zh + 指定物理系统需要绘制哪些调试信息。
+ example:
+ ```js + cc.director.getPhysicsManager().debugDrawFlags = + // cc.PhysicsManager.DrawBits.e_aabbBit | + // cc.PhysicsManager.DrawBits.e_pairBit | + // cc.PhysicsManager.DrawBits.e_centerOfMassBit | + cc.PhysicsManager.DrawBits.e_jointBit | + cc.PhysicsManager.DrawBits.e_shapeBit; + ``` */ + export enum DrawBits { + e_aabbBit = 0, + e_jointBit = 0, + e_shapeBit = 0, + } + } + + /**************************************************** + * AnimationCurve + *****************************************************/ + + export namespace AnimationCurve { + /** !#en The wrap mode + !#zh 循环模式 */ + export enum WrapMode { + Default = 0, + Once = 0, + Loop = 0, + PingPong = 0, + ClampForever = 0, + time = 0, + value = 0, + inTangent = 0, + outTangent = 0, + } + } + + /**************************************************** + * ParticleSystem3DAssembler + *****************************************************/ + + export namespace ParticleSystem3DAssembler { + /** undefined */ + export enum Space { + } + } + + /**************************************************** + * ParticleSystem3DAssembler + *****************************************************/ + + export namespace ParticleSystem3DAssembler { + /** 粒子的生成模式 */ + export enum RenderMode { + } + } + + /**************************************************** + * shapeModule + *****************************************************/ + + export namespace shapeModule { + /** 粒子发射器类型 */ + export enum ShapeType { + Box = 0, + Circle = 0, + Cone = 0, + Sphere = 0, + Hemisphere = 0, + } + } + + /**************************************************** + * shapeModule + *****************************************************/ + + export namespace shapeModule { + /** 粒子从发射器的哪个部位发射 */ + export enum EmitLocation { + Base = 0, + Edge = 0, + Shell = 0, + Volume = 0, + } + } + + /**************************************************** + * shapeModule + *****************************************************/ + + export namespace shapeModule { + /** 粒子在扇形区域的发射方式 */ + export enum ArcMode { + Random = 0, + Loop = 0, + PingPong = 0, + } + } + + /**************************************************** + * trailModule + *****************************************************/ + + export namespace trailModule { + /** 选择如何为粒子系统生成轨迹 */ + export enum TrailMode { + } + } + + /**************************************************** + * trailModule + *****************************************************/ + + export namespace trailModule { + /** 纹理填充模式 */ + export enum TextureMode { + } + } + + /**************************************************** + * primitive + *****************************************************/ + + export namespace primitive { + /** undefined */ + export enum PolyhedronType { + Tetrahedron = 0, + Octahedron = 0, + Dodecahedron = 0, + Icosahedron = 0, + Rhombicuboctahedron = 0, + TriangularPrism = 0, + PentagonalPrism = 0, + HexagonalPrism = 0, + SquarePyramid = 0, + PentagonalPyramid = 0, + TriangularDipyramid = 0, + PentagonalDipyramid = 0, + ElongatedSquareDipyramid = 0, + ElongatedPentagonalDipyramid = 0, + ElongatedPentagonalCupola = 0, + } + } + + /**************************************************** + * primitive + *****************************************************/ + + export namespace primitive { + /** undefined */ + export class VertexData { + positions: number[]; + normals: number[]; + uvs: number[]; + indices: number[]; + minPos: Vec3; + maxPos: Vec3; + boundingRadius: number; + } + } + + /**************************************************** + * Material + *****************************************************/ + + export namespace Material { + /** !#en Material builtin name + !#zh 内置材质名字 */ + export enum BUILTIN_NAME { + SPRITE = 0, + GRAY_SPRITE = 0, + UNLIT = 0, + } + } + + /**************************************************** + * EditBox + *****************************************************/ + + export namespace EditBox { + /** !#en Enum for keyboard return types + !#zh 键盘的返回键类型 */ + export enum KeyboardReturnType { + DEFAULT = 0, + DONE = 0, + SEND = 0, + SEARCH = 0, + GO = 0, + NEXT = 0, + } + } + + /**************************************************** + * EditBox + *****************************************************/ + + export namespace EditBox { + /** !#en The EditBox's InputMode defines the type of text that the user is allowed to enter. + !#zh 输入模式 */ + export enum InputMode { + ANY = 0, + EMAIL_ADDR = 0, + NUMERIC = 0, + PHONE_NUMBER = 0, + URL = 0, + DECIMAL = 0, + SINGLE_LINE = 0, + } + } + + /**************************************************** + * EditBox + *****************************************************/ + + export namespace EditBox { + /** !#en Enum for the EditBox's input flags + !#zh 定义了一些用于设置文本显示和文本格式化的标志位。 */ + export enum InputFlag { + PASSWORD = 0, + SENSITIVE = 0, + INITIAL_CAPS_WORD = 0, + INITIAL_CAPS_SENTENCE = 0, + INITIAL_CAPS_ALL_CHARACTERS = 0, + DEFAULT = 0, + } + } + + /**************************************************** + * textureAnimationModule + *****************************************************/ + + export namespace textureAnimationModule { + /** 粒子贴图动画类型 */ + export enum Mode { + } + } + + /**************************************************** + * textureAnimationModule + *****************************************************/ + + export namespace textureAnimationModule { + /** 贴图动画的播放方式 */ + export enum Animation { + } + } + +} + +/** !#en +The global main namespace of Spine, all classes, functions, +properties and constants of Spine are defined in this namespace +!#zh +Spine 的全局的命名空间, +与 Spine 相关的所有的类,函数,属性,常量都在这个命名空间中定义。 */ +declare namespace sp { + /** !#en + The skeleton of Spine
+
+ (Skeleton has a reference to a SkeletonData and stores the state for skeleton instance, + which consists of the current pose's bone SRT, slot colors, and which slot attachments are visible.
+ Multiple skeletons can use the same SkeletonData which includes all animations, skins, and attachments.)
+ !#zh + Spine 骨骼动画
+
+ (Skeleton 具有对骨骼数据的引用并且存储了骨骼实例的状态, + 它由当前的骨骼动作,slot 颜色,和可见的 slot attachments 组成。
+ 多个 Skeleton 可以使用相同的骨骼数据,其中包括所有的动画,皮肤和 attachments。 */ + export class Skeleton extends cc.RenderComponent { + /** !#en The skeletal animation is paused? + !#zh 该骨骼动画是否暂停。 */ + paused: boolean; + /** !#en + The skeleton data contains the skeleton information (bind pose bones, slots, draw order, + attachments, skins, etc) and animations but does not hold any state.
+ Multiple skeletons can share the same skeleton data. + !#zh + 骨骼数据包含了骨骼信息(绑定骨骼动作,slots,渲染顺序, + attachments,皮肤等等)和动画但不持有任何状态。
+ 多个 Skeleton 可以共用相同的骨骼数据。 */ + skeletonData: SkeletonData; + /** !#en The name of default skin. + !#zh 默认的皮肤名称。 */ + defaultSkin: string; + /** !#en The name of default animation. + !#zh 默认的动画名称。 */ + defaultAnimation: string; + /** !#en The name of current playing animation. + !#zh 当前播放的动画名称。 */ + animation: string; + _defaultSkinIndex: number; + /** !#en TODO + !#zh 是否循环播放当前骨骼动画。 */ + loop: boolean; + /** !#en Indicates whether to enable premultiplied alpha. + You should disable this option when image's transparent area appears to have opaque pixels, + or enable this option when image's half transparent area appears to be darken. + !#zh 是否启用贴图预乘。 + 当图片的透明区域出现色块时需要关闭该选项,当图片的半透明区域颜色变黑时需要启用该选项。 */ + premultipliedAlpha: boolean; + /** !#en The time scale of this skeleton. + !#zh 当前骨骼中所有动画的时间缩放率。 */ + timeScale: number; + /** !#en Indicates whether open debug slots. + !#zh 是否显示 slot 的 debug 信息。 */ + debugSlots: boolean; + /** !#en Indicates whether open debug bones. + !#zh 是否显示 bone 的 debug 信息。 */ + debugBones: boolean; + /** !#en Indicates whether open debug mesh. + !#zh 是否显示 mesh 的 debug 信息。 */ + debugMesh: boolean; + /** !#en Enabled two color tint. + !#zh 是否启用染色效果。 */ + useTint: boolean; + /** !#en Enabled batch model, if skeleton is complex, do not enable batch, or will lower performance. + !#zh 开启合批,如果渲染大量相同纹理,且结构简单的骨骼动画,开启合批可以降低drawcall,否则请不要开启,cpu消耗会上升。 */ + enableBatch: boolean; + /** + !#en + Sets runtime skeleton data to sp.Skeleton.
+ This method is different from the `skeletonData` property. This method is passed in the raw data provided by the Spine runtime, and the skeletonData type is the asset type provided by Creator. + !#zh + 设置底层运行时用到的 SkeletonData。
+ 这个接口有别于 `skeletonData` 属性,这个接口传入的是 Spine runtime 提供的原始数据,而 skeletonData 的类型是 Creator 提供的资源类型。 + @param skeletonData skeletonData + */ + setSkeletonData(skeletonData: sp.spine.SkeletonData): void; + /** + !#en Sets slots visible range. + !#zh 设置骨骼插槽可视范围。 + @param startSlotIndex startSlotIndex + @param endSlotIndex endSlotIndex + */ + setSlotsRange(startSlotIndex: number, endSlotIndex: number): void; + /** + !#en Sets animation state data.
+ The parameter type is {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.AnimationStateData. + !#zh 设置动画状态数据。
+ 参数是 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.AnimationStateData。 + @param stateData stateData + */ + setAnimationStateData(stateData: sp.spine.AnimationStateData): void; + /** + !#en + It's best to set cache mode before set property 'dragonAsset', or will waste some cpu time. + If set the mode in editor, then no need to worry about order problem. + !#zh + 若想切换渲染模式,最好在设置'dragonAsset'之前,先设置好渲染模式,否则有运行时开销。 + 若在编辑中设置渲染模式,则无需担心设置次序的问题。 + @param cacheMode cacheMode + + @example + ```js + skeleton.setAnimationCacheMode(sp.Skeleton.AnimationCacheMode.SHARED_CACHE); + ``` + */ + setAnimationCacheMode(cacheMode: Skeleton.AnimationCacheMode): void; + /** + !#en Whether in cached mode. + !#zh 当前是否处于缓存模式。 + */ + isAnimationCached(): boolean; + /** + !#en Sets vertex effect delegate. + !#zh 设置顶点动画代理 + @param effectDelegate effectDelegate + */ + setVertexEffectDelegate(effectDelegate: VertexEffectDelegate): void; + /** + !#en Computes the world SRT from the local SRT for each bone. + !#zh 重新更新所有骨骼的世界 Transform, + 当获取 bone 的数值未更新时,即可使用该函数进行更新数值。 + + @example + ```js + var bone = spine.findBone('head'); + cc.log(bone.worldX); // return 0; + spine.updateWorldTransform(); + bone = spine.findBone('head'); + cc.log(bone.worldX); // return -23.12; + ``` + */ + updateWorldTransform(): void; + /** + !#en Sets the bones and slots to the setup pose. + !#zh 还原到起始动作 + */ + setToSetupPose(): void; + /** + !#en + Sets the bones to the setup pose, + using the values from the `BoneData` list in the `SkeletonData`. + !#zh + 设置 bone 到起始动作 + 使用 SkeletonData 中的 BoneData 列表中的值。 + */ + setBonesToSetupPose(): void; + /** + !#en + Sets the slots to the setup pose, + using the values from the `SlotData` list in the `SkeletonData`. + !#zh + 设置 slot 到起始动作。 + 使用 SkeletonData 中的 SlotData 列表中的值。 + */ + setSlotsToSetupPose(): void; + /** + !#en + Updating an animation cache to calculate all frame data in the animation is a cost in + performance due to calculating all data in a single frame. + To update the cache, use the invalidAnimationCache method with high performance. + !#zh + 更新某个动画缓存, 预计算动画中所有帧数据,由于在单帧计算所有数据,所以较消耗性能。 + 若想更新缓存,可使用 invalidAnimationCache 方法,具有较高性能。 + @param animName animName + */ + updateAnimationCache(animName: string): void; + /** + !#en + Invalidates the animation cache, which is then recomputed on each frame.. + !#zh + 使动画缓存失效,之后会在每帧重新计算。 + */ + invalidAnimationCache(): void; + /** + !#en + Finds a bone by name. + This does a string comparison for every bone.
+ Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Bone object. + !#zh + 通过名称查找 bone。 + 这里对每个 bone 的名称进行了对比。
+ 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Bone 对象。 + @param boneName boneName + */ + findBone(boneName: string): sp.spine.Bone; + /** + !#en + Finds a slot by name. This does a string comparison for every slot.
+ Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Slot object. + !#zh + 通过名称查找 slot。这里对每个 slot 的名称进行了比较。
+ 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Slot 对象。 + @param slotName slotName + */ + findSlot(slotName: string): sp.spine.Slot; + /** + !#en + Finds a skin by name and makes it the active skin. + This does a string comparison for every skin.
+ Note that setting the skin does not change which attachments are visible.
+ Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Skin object. + !#zh + 按名称查找皮肤,激活该皮肤。这里对每个皮肤的名称进行了比较。
+ 注意:设置皮肤不会改变 attachment 的可见性。
+ 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Skin 对象。 + @param skinName skinName + */ + setSkin(skinName: string): void; + /** + !#en + Returns the attachment for the slot and attachment name. + The skeleton looks first in its skin, then in the skeleton data’s default skin.
+ Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Attachment object. + !#zh + 通过 slot 和 attachment 的名称获取 attachment。Skeleton 优先查找它的皮肤,然后才是 Skeleton Data 中默认的皮肤。
+ 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Attachment 对象。 + @param slotName slotName + @param attachmentName attachmentName + */ + getAttachment(slotName: string, attachmentName: string): sp.spine.Attachment; + /** + !#en + Sets the attachment for the slot and attachment name. + The skeleton looks first in its skin, then in the skeleton data’s default skin. + !#zh + 通过 slot 和 attachment 的名字来设置 attachment。 + Skeleton 优先查找它的皮肤,然后才是 Skeleton Data 中默认的皮肤。 + @param slotName slotName + @param attachmentName attachmentName + */ + setAttachment(slotName: string, attachmentName: string): void; + /** + Return the renderer of attachment. + @param regionAttachment regionAttachment + */ + getTextureAtlas(regionAttachment: sp.spine.RegionAttachment|spine.BoundingBoxAttachment): sp.spine.TextureAtlasRegion; + /** + !#en + Mix applies all keyframe values, + interpolated for the specified time and mixed with the current values. + !#zh 为所有关键帧设定混合及混合时间(从当前值开始差值)。 + @param fromAnimation fromAnimation + @param toAnimation toAnimation + @param duration duration + */ + setMix(fromAnimation: string, toAnimation: string, duration: number): void; + /** + !#en Set the current animation. Any queued animations are cleared.
+ Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry object. + !#zh 设置当前动画。队列中的任何的动画将被清除。
+ 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry 对象。 + @param trackIndex trackIndex + @param name name + @param loop loop + */ + setAnimation(trackIndex: number, name: string, loop: boolean): sp.spine.TrackEntry; + /** + !#en Adds an animation to be played delay seconds after the current or last queued animation.
+ Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry object. + !#zh 添加一个动画到动画队列尾部,还可以延迟指定的秒数。
+ 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry 对象。 + @param trackIndex trackIndex + @param name name + @param loop loop + @param delay delay + */ + addAnimation(trackIndex: number, name: string, loop: boolean, delay?: number): sp.spine.TrackEntry; + /** + !#en Find animation with specified name. + !#zh 查找指定名称的动画 + @param name name + */ + findAnimation(name: string): sp.spine.Animation; + /** + !#en Returns track entry by trackIndex.
+ Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry object. + !#zh 通过 track 索引获取 TrackEntry。
+ 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry 对象。 + @param trackIndex trackIndex + */ + getCurrent(trackIndex: any): sp.spine.TrackEntry; + /** + !#en Clears all tracks of animation state. + !#zh 清除所有 track 的动画状态。 + */ + clearTracks(): void; + /** + !#en Clears track of animation state by trackIndex. + !#zh 清除出指定 track 的动画状态。 + @param trackIndex trackIndex + */ + clearTrack(trackIndex: number): void; + /** + !#en Set the start event listener. + !#zh 用来设置开始播放动画的事件监听。 + @param listener listener + */ + setStartListener(listener: Function): void; + /** + !#en Set the interrupt event listener. + !#zh 用来设置动画被打断的事件监听。 + @param listener listener + */ + setInterruptListener(listener: Function): void; + /** + !#en Set the end event listener. + !#zh 用来设置动画播放完后的事件监听。 + @param listener listener + */ + setEndListener(listener: Function): void; + /** + !#en Set the dispose event listener. + !#zh 用来设置动画将被销毁的事件监听。 + @param listener listener + */ + setDisposeListener(listener: Function): void; + /** + !#en Set the complete event listener. + !#zh 用来设置动画播放一次循环结束后的事件监听。 + @param listener listener + */ + setCompleteListener(listener: Function): void; + /** + !#en Set the animation event listener. + !#zh 用来设置动画播放过程中帧事件的监听。 + @param listener listener + */ + setEventListener(listener: Function): void; + /** + !#en Set the start event listener for specified TrackEntry. + !#zh 用来为指定的 TrackEntry 设置动画开始播放的事件监听。 + @param entry entry + @param listener listener + */ + setTrackStartListener(entry: sp.spine.TrackEntry, listener: Function): void; + /** + !#en Set the interrupt event listener for specified TrackEntry. + !#zh 用来为指定的 TrackEntry 设置动画被打断的事件监听。 + @param entry entry + @param listener listener + */ + setTrackInterruptListener(entry: sp.spine.TrackEntry, listener: Function): void; + /** + !#en Set the end event listener for specified TrackEntry. + !#zh 用来为指定的 TrackEntry 设置动画播放结束的事件监听。 + @param entry entry + @param listener listener + */ + setTrackEndListener(entry: sp.spine.TrackEntry, listener: Function): void; + /** + !#en Set the dispose event listener for specified TrackEntry. + !#zh 用来为指定的 TrackEntry 设置动画即将被销毁的事件监听。 + @param entry entry + @param listener listener + */ + setTrackDisposeListener(entry: sp.spine.TrackEntry, listener: Function): void; + /** + !#en Set the complete event listener for specified TrackEntry. + !#zh 用来为指定的 TrackEntry 设置动画一次循环播放结束的事件监听。 + @param entry entry + @param listener listener + */ + setTrackCompleteListener(entry: sp.spine.TrackEntry, listener: (entry: sp.spine.TrackEntry, loopCount: number) => void): void; + /** + !#en Set the event listener for specified TrackEntry. + !#zh 用来为指定的 TrackEntry 设置动画帧事件的监听。 + @param entry entry + @param listener listener + */ + setTrackEventListener(entry: sp.spine.TrackEntry, listener: Function): void; + /** + !#en Get the animation state object + !#zh 获取动画状态 + */ + getState(): sp.spine.AnimationState; + } + /** !#en The skeleton data of spine. + !#zh Spine 的 骨骼数据。 */ + export class SkeletonData extends cc.Asset { + /** !#en See http://en.esotericsoftware.com/spine-json-format + !#zh 可查看 Spine 官方文档 http://zh.esotericsoftware.com/spine-json-format */ + skeletonJson: any; + atlasText: string; + textures: cc.Texture2D[]; + /** !#en + A scale can be specified on the JSON or binary loader which will scale the bone positions, + image sizes, and animation translations. + This can be useful when using different sized images than were used when designing the skeleton + in Spine. For example, if using images that are half the size than were used in Spine, + a scale of 0.5 can be used. This is commonly used for games that can run with either low or high + resolution texture atlases. + see http://en.esotericsoftware.com/spine-using-runtimes#Scaling + !#zh 可查看 Spine 官方文档: http://zh.esotericsoftware.com/spine-using-runtimes#Scaling */ + scale: number; + /** + !#en Get the included SkeletonData used in spine runtime.
+ Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.SkeletonData object. + !#zh 获取 Spine Runtime 使用的 SkeletonData。
+ 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.SkeletonData 对象。 + @param quiet quiet + */ + getRuntimeData(quiet?: boolean): sp.spine.SkeletonData; + } + /** !#en The event type of spine skeleton animation. + !#zh 骨骼动画事件类型。 */ + export enum AnimationEventType { + START = 0, + END = 0, + COMPLETE = 0, + EVENT = 0, + } + /** !#en + The delegate of spine vertex effect + !#zh + Spine 顶点动画代理 */ + export class VertexEffectDelegate { + /** + !#en Clears vertex effect. + !#zh 清空顶点效果 + */ + clear(): void; + /** + !#en Inits delegate with jitter effect + !#zh 设置顶点抖动效果 + @param jitterX jitterX + @param jitterY jitterY + */ + initJitter(jitterX: number, jitterY: number): void; + /** + !#en Inits delegate with swirl effect + !#zh 设置顶点漩涡效果 + @param radius radius + @param power power + */ + initSwirlWithPow(radius: number, power: number): sp.spine.JitterEffect; + /** + !#en Inits delegate with swirl effect + !#zh 设置顶点漩涡效果 + @param radius radius + @param power power + */ + initSwirlWithPowOut(radius: number, power: number): sp.spine.SwirlEffect; + /** + !#en Gets jitter vertex effect + !#zh 获取顶点抖动效果 + */ + getJitterVertexEffect(): sp.spine.JitterEffect; + /** + !#en Gets swirl vertex effect + !#zh 获取顶点漩涡效果 + */ + getSwirlVertexEffect(): sp.spine.SwirlEffect; + /** + !#en Gets vertex effect + !#zh 获取顶点效果 + */ + getVertexEffect(): sp.spine.JitterEffect; + /** + !#en Gets effect type + !#zh 获取效果类型 + */ + getEffectType(): string; + } + /**************************************************** + * sp + *****************************************************/ + + export namespace sp { + /** !#en Attach node tool + !#zh 挂点工具类 */ + export class AttachUtil { + /** + !#en Gets attached root node. + !#zh 获取挂接节点树的根节点 + */ + getAttachedRootNode(): cc.Node; + /** + !#en Gets attached node which you want. + !#zh 获得对应的挂点 + @param boneName boneName + */ + getAttachedNodes(boneName: string): cc.Node[]; + /** + !#en Destroy attached node which you want. + !#zh 销毁对应的挂点 + @param boneName boneName + */ + destroyAttachedNodes(boneName: string): void; + /** + !#en Traverse all bones to generate the minimum node tree containing the given bone names, NOTE that make sure the skeleton has initialized before calling this interface. + !#zh 遍历所有插槽,生成包含所有给定插槽名称的最小节点树,注意,调用该接口前请确保骨骼动画已经初始化好。 + @param boneName boneName + */ + generateAttachedNodes(boneName: string): cc.Node[]; + /** + !#en Destroy all attached node. + !#zh 销毁所有挂点 + */ + destroyAllAttachedNodes(): void; + /** + !#en Traverse all bones to generate a tree containing all bones nodes, NOTE that make sure the skeleton has initialized before calling this interface. + !#zh 遍历所有插槽,生成包含所有插槽的节点树,注意,调用该接口前请确保骨骼动画已经初始化好。 + */ + generateAllAttachedNodes(): cc.Node; + } + } + + /**************************************************** + * Skeleton + *****************************************************/ + + export namespace Skeleton { + /** !#en Enum for animation cache mode type. + !#zh Spine动画缓存类型 */ + export enum AnimationCacheMode { + REALTIME = 0, + SHARED_CACHE = 0, + PRIVATE_CACHE = 0, + } + } + +} + +/** !#en +`sp.spine` is the namespace for official Spine Runtime, which officially implemented and maintained by Spine.
+Please refer to the official documentation for its detailed usage: [http://en.esotericsoftware.com/spine-using-runtimes](http://en.esotericsoftware.com/spine-using-runtimes) +!#zh +sp.spine 模块是 Spine 官方运行库的 API 入口,由 Spine 官方统一实现和维护,具体用法请参考:[http://zh.esotericsoftware.com/spine-using-runtimes](http://zh.esotericsoftware.com/spine-using-runtimes) */ +declare namespace sp.spine { +} + +/** !#en +The global main namespace of DragonBones, all classes, functions, +properties and constants of DragonBones are defined in this namespace +!#zh +DragonBones 的全局的命名空间, +与 DragonBones 相关的所有的类,函数,属性,常量都在这个命名空间中定义。 */ +declare namespace dragonBones { + /** !#en + The Armature Display of DragonBones
+
+ Armature Display has a reference to a DragonBonesAsset and stores the state for ArmatureDisplay instance, + which consists of the current pose's bone SRT, slot colors, and which slot attachments are visible.
+ Multiple Armature Display can use the same DragonBonesAsset which includes all animations, skins, and attachments.
+ !#zh + DragonBones 骨骼动画
+
+ Armature Display 具有对骨骼数据的引用并且存储了骨骼实例的状态, + 它由当前的骨骼动作,slot 颜色,和可见的 slot attachments 组成。
+ 多个 Armature Display 可以使用相同的骨骼数据,其中包括所有的动画,皮肤和 attachments。
*/ + export class ArmatureDisplay extends cc.RenderComponent { + /** !#en + The DragonBones data contains the armatures information (bind pose bones, slots, draw order, + attachments, skins, etc) and animations but does not hold any state.
+ Multiple ArmatureDisplay can share the same DragonBones data. + !#zh + 骨骼数据包含了骨骼信息(绑定骨骼动作,slots,渲染顺序, + attachments,皮肤等等)和动画但不持有任何状态。
+ 多个 ArmatureDisplay 可以共用相同的骨骼数据。 */ + dragonAsset: DragonBonesAsset; + /** !#en + The atlas asset for the DragonBones. + !#zh + 骨骼数据所需的 Atlas Texture 数据。 */ + dragonAtlasAsset: DragonBonesAtlasAsset; + /** !#en The name of current armature. + !#zh 当前的 Armature 名称。 */ + armatureName: string; + /** !#en The name of current playing animation. + !#zh 当前播放的动画名称。 */ + animationName: string; + _defaultArmatureIndex: number; + /** !#en The time scale of this armature. + !#zh 当前骨骼中所有动画的时间缩放率。 */ + timeScale: number; + /** !#en The play times of the default animation. + -1 means using the value of config file; + 0 means repeat for ever + >0 means repeat times + !#zh 播放默认动画的循环次数 + -1 表示使用配置文件中的默认值; + 0 表示无限循环 + >0 表示循环次数 */ + playTimes: number; + /** !#en Indicates whether to enable premultiplied alpha. + You should disable this option when image's transparent area appears to have opaque pixels, + or enable this option when image's half transparent area appears to be darken. + !#zh 是否启用贴图预乘。 + 当图片的透明区域出现色块时需要关闭该选项,当图片的半透明区域颜色变黑时需要启用该选项。 */ + premultipliedAlpha: boolean; + /** !#en Indicates whether open debug bones. + !#zh 是否显示 bone 的 debug 信息。 */ + debugBones: boolean; + /** !#en Enabled batch model, if skeleton is complex, do not enable batch, or will lower performance. + !#zh 开启合批,如果渲染大量相同纹理,且结构简单的骨骼动画,开启合批可以降低drawcall,否则请不要开启,cpu消耗会上升。 */ + enableBatch: boolean; + /** + !#en + The key of dragonbones cache data, which is regard as 'dragonbonesName', when you want to change dragonbones cloth. + !#zh + 缓存龙骨数据的key值,换装的时会使用到该值,作为dragonbonesName使用 + + @example + ```js + let factory = dragonBones.CCFactory.getInstance(); + let needChangeSlot = needChangeArmature.armature().getSlot("changeSlotName"); + factory.replaceSlotDisplay(toChangeArmature.getArmatureKey(), "armatureName", "slotName", "displayName", needChangeSlot); + ``` + */ + getArmatureKey(): string; + /** + !#en + It's best to set cache mode before set property 'dragonAsset', or will waste some cpu time. + If set the mode in editor, then no need to worry about order problem. + !#zh + 若想切换渲染模式,最好在设置'dragonAsset'之前,先设置好渲染模式,否则有运行时开销。 + 若在编辑中设置渲染模式,则无需担心设置次序的问题。 + @param cacheMode cacheMode + + @example + ```js + armatureDisplay.setAnimationCacheMode(dragonBones.ArmatureDisplay.AnimationCacheMode.SHARED_CACHE); + ``` + */ + setAnimationCacheMode(cacheMode: ArmatureDisplay.AnimationCacheMode): void; + /** + !#en Whether in cached mode. + !#zh 当前是否处于缓存模式。 + */ + isAnimationCached(): boolean; + /** + !#en + Play the specified animation. + Parameter animName specify the animation name. + Parameter playTimes specify the repeat times of the animation. + -1 means use the value of the config file. + 0 means play the animation for ever. + >0 means repeat times. + !#zh + 播放指定的动画. + animName 指定播放动画的名称。 + playTimes 指定播放动画的次数。 + -1 为使用配置文件中的次数。 + 0 为无限循环播放。 + >0 为动画的重复次数。 + @param animName animName + @param playTimes playTimes + */ + playAnimation(animName: string, playTimes: number): dragonBones.AnimationState; + /** + !#en + Updating an animation cache to calculate all frame data in the animation is a cost in + performance due to calculating all data in a single frame. + To update the cache, use the invalidAnimationCache method with high performance. + !#zh + 更新某个动画缓存, 预计算动画中所有帧数据,由于在单帧计算所有数据,所以较消耗性能。 + 若想更新缓存,可使用 invalidAnimationCache 方法,具有较高性能。 + @param animName animName + */ + updateAnimationCache(animName: string): void; + /** + !#en + Invalidates the animation cache, which is then recomputed on each frame.. + !#zh + 使动画缓存失效,之后会在每帧重新计算。 + */ + invalidAnimationCache(): void; + /** + !#en + Get the all armature names in the DragonBones Data. + !#zh + 获取 DragonBones 数据中所有的 armature 名称 + */ + getArmatureNames(): any[]; + /** + !#en + Get the all animation names of specified armature. + !#zh + 获取指定的 armature 的所有动画名称。 + @param armatureName armatureName + */ + getAnimationNames(armatureName: string): any[]; + /** + !#en + Add event listener for the DragonBones Event, the same to addEventListener. + !#zh + 添加 DragonBones 事件监听器,与 addEventListener 作用相同。 + @param type A string representing the event type to listen for. + @param listener The callback that will be invoked when the event is dispatched. + @param target The target (this object) to invoke the callback, can be null + */ + on(type: string, listener: (event: cc.Event) => void, target?: any): void; + /** + !#en + Remove the event listener for the DragonBones Event, the same to removeEventListener. + !#zh + 移除 DragonBones 事件监听器,与 removeEventListener 作用相同。 + @param type A string representing the event type to listen for. + @param listener listener + @param target target + */ + off(type: string, listener?: Function, target?: any): void; + /** + !#en + Add DragonBones one-time event listener, the callback will remove itself after the first time it is triggered. + !#zh + 添加 DragonBones 一次性事件监听器,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param listener The callback that will be invoked when the event is dispatched. + @param target The target (this object) to invoke the callback, can be null + */ + once(type: string, listener: (event: cc.Event) => void, target?: any): void; + /** + !#en + Add event listener for the DragonBones Event. + !#zh + 添加 DragonBones 事件监听器。 + @param type A string representing the event type to listen for. + @param listener The callback that will be invoked when the event is dispatched. + @param target The target (this object) to invoke the callback, can be null + */ + addEventListener(type: string, listener: (event: cc.Event) => void, target?: any): void; + /** + !#en + Remove the event listener for the DragonBones Event. + !#zh + 移除 DragonBones 事件监听器。 + @param type A string representing the event type to listen for. + @param listener listener + @param target target + */ + removeEventListener(type: string, listener?: Function, target?: any): void; + /** + !#en + Build the armature for specified name. + !#zh + 构建指定名称的 armature 对象 + @param armatureName armatureName + @param node node + */ + buildArmature(armatureName: string, node: cc.Node): ArmatureDisplay; + /** + !#en + Get the current armature object of the ArmatureDisplay. + !#zh + 获取 ArmatureDisplay 当前使用的 Armature 对象 + */ + armature(): any; + } + /** DragonBones factory */ + export class CCFactory extends BaseFactory { + /** + + + @example + ```js + let factory = dragonBones.CCFactory.getInstance(); + ``` + */ + static getInstance(): CCFactory; + } + /** !#en The skeleton data of dragonBones. + !#zh dragonBones 的 骨骼数据。 */ + export class DragonBonesAsset extends cc.Asset { + /** !#en See http://developer.egret.com/cn/github/egret-docs/DB/dbLibs/dataFormat/index.html + !#zh 可查看 DragonBones 官方文档 http://developer.egret.com/cn/github/egret-docs/DB/dbLibs/dataFormat/index.html */ + dragonBonesJson: string; + } + /** !#en The skeleton atlas data of dragonBones. + !#zh dragonBones 的骨骼纹理数据。 */ + export class DragonBonesAtlasAsset extends cc.Asset { + atlasJson: string; + texture: cc.Texture2D; + } + /**************************************************** + * ArmatureDisplay + *****************************************************/ + + export namespace ArmatureDisplay { + /** !#en Enum for cache mode type. + !#zh Dragonbones渲染类型 */ + export enum AnimationCacheMode { + REALTIME = 0, + SHARED_CACHE = 0, + PRIVATE_CACHE = 0, + } + } + + /**************************************************** + * dragonBones + *****************************************************/ + + export namespace dragonBones { + /** !#en Attach node tool + !#zh 挂点工具类 */ + export class AttachUtil { + /** + !#en Gets attached root node. + !#zh 获取挂接节点树的根节点 + */ + getAttachedRootNode(): cc.Node; + /** + !#en Gets attached node which you want. + !#zh 获得对应的挂点 + @param boneName boneName + */ + getAttachedNodes(boneName: string): cc.Node[]; + /** + !#en Destroy attached node which you want. + !#zh 销毁对应的挂点 + @param boneName boneName + */ + destroyAttachedNodes(boneName: string): void; + /** + !#en Traverse all bones to generate the minimum node tree containing the given bone names, NOTE that make sure the skeleton has initialized before calling this interface. + !#zh 遍历所有插槽,生成包含所有给定插槽名称的最小节点树,注意,调用该接口前请确保骨骼动画已经初始化好。 + @param boneName boneName + */ + generateAttachedNodes(boneName: string): cc.Node[]; + /** + !#en Destroy all attached node. + !#zh 销毁所有挂点 + */ + destroyAllAttachedNodes(): void; + /** + !#en Traverse all bones to generate a tree containing all bones nodes, NOTE that make sure the skeleton has initialized before calling this interface. + !#zh 遍历所有插槽,生成包含所有插槽的节点树,注意,调用该接口前请确保骨骼动画已经初始化好。 + */ + generateAllAttachedNodes(): cc.Node; + } + } + +} + +/** !#en +This module controls asset's behaviors and information, include loading, releasing etc. +All member can be accessed with `cc.assetManager`. All class or enum can be accessed with `cc.AssetManager` + +!#zh +此模块管理资源的行为和信息,包括加载,释放等,所有成员能够通过 `cc.assetManager` 调用. 所有类型或枚举能通过 `cc.AssetManager` 访问 */ +declare namespace cc.AssetManager { + /** !#en + This module contains the builtin asset, it's a singleton, all member can be accessed with `cc.assetManager.builtins` + + !#zh + 此模块包含内建资源,这是一个单例,所有成员能通过 `cc.assetManager.builtins` 访问 */ + export class Builtins { + /** + !#en + Initialize + + !#zh + 初始化 + @param cb Callback when finish loading built-in assets + */ + init (cb: () => void): void; + /** + !#en + Get the built-in asset using specific type and name. + + !#zh + 通过特定的类型和名称获取内建资源 + @param type The type of asset, such as `effect` + @param name The name of asset, such as `phong` + + @example + ```js + cc.assetManaer.builtins.getBuiltin('effect', 'phone'); + ``` + */ + getBuiltin(type?: string, name?: string): cc.Asset | Cache; + /** + !#en + Clear all builtin assets + + !#zh + 清空所有内置资源 + */ + clear(): void; + } + /** !#en + A bundle contains an amount of assets(includes scene), you can load, preload, release asset which is in this bundle + + !#zh + 一个包含一定数量资源(包括场景)的包,你可以加载,预加载,释放此包内的资源 */ + export class Bundle { + /** + !#en + Create a bundle + + !#zh + 创建一个 bundle + */ + constructor(); + /** !#en + The name of this bundle + + !#zh + 此 bundle 的名称 */ + name: string; + /** !#en + The dependency of this bundle + + !#zh + 此 bundle 的依赖 */ + deps: string[]; + /** !#en + The root path of this bundle, such like 'http://example.com/bundle1' + + !#zh + 此 bundle 的根路径, 例如 'http://example.com/bundle1' */ + base: string; + /** + !#en + Get asset's info using path, only valid when asset is in bundle folder. + + !#zh + 使用 path 获取资源的配置信息 + @param path The relative path of asset, such as 'images/a' + @param type The constructor of asset, such as `cc.Texture2D` + + @example + ```js + var info = bundle.getInfoWithPath('image/a', cc.Texture2D); + ``` + */ + getInfoWithPath (path: string, type?: typeof cc.Asset): Record; + /** + !#en + Get all asset's info within specific folder + + !#zh + 获取在某个指定文件夹下的所有资源信息 + @param path The relative path of folder, such as 'images' + @param type The constructor should be used to filter paths + @param out The output array + + @example + ```js + var infos = []; + bundle.getDirWithPath('images', cc.Texture2D, infos); + ``` + */ + getDirWithPath (path: string, type: typeof cc.Asset, out: Array>): Array>; + getDirWithPath (path: string, type: typeof cc.Asset): Array>; + getDirWithPath (path: string): Array>; + /** + !#en + Get asset's info with uuid + + !#zh + 通过 uuid 获取资源信息 + @param uuid The asset's uuid + + @example + ```js + var info = bundle.getAssetInfo('fcmR3XADNLgJ1ByKhqcC5Z'); + ``` + */ + getAssetInfo (uuid: string): Record; + /** + !#en + Get scene'info with name + + !#zh + 通过场景名获取场景信息 + @param name The name of scene + + @example + ```js + var info = bundle.getSceneInfo('first.fire'); + ``` + */ + getSceneInfo(name: string): Record; + /** + !#en + Initialize this bundle with options + + !#zh + 初始化此 bundle + @param options options + */ + init(options: Record): void; + /** + !#en + Load the asset within this bundle by the path which is relative to bundle's path + + !#zh + 通过相对路径加载分包中的资源。路径是相对分包文件夹路径的相对路径 + @param paths Paths of the target assets.The path is relative to the bundle's folder, extensions must be omitted. + @param type Only asset of type will be loaded if this argument is supplied. + @param onProgress Callback invoked when progression change. + @param onComplete Callback invoked when all assets loaded. + + @example + ```js + // load the texture (${project}/assets/resources/textures/background.jpg) from resources + cc.resources.load('textures/background', cc.Texture2D, (err, texture) => console.log(err)); + + // load the audio (${project}/assets/resources/music/hit.mp3) from resources + cc.resources.load('music/hit', cc.AudioClip, (err, audio) => console.log(err)); + + // load the prefab (${project}/assets/bundle1/misc/character/cocos) from bundle1 folder + bundle1.load('misc/character/cocos', cc.Prefab, (err, prefab) => console.log(err)); + + // load the sprite frame (${project}/assets/some/xxx/bundle2/imgs/cocos.png) from bundle2 folder + bundle2.load('imgs/cocos', cc.SpriteFrame, null, (err, spriteFrame) => console.log(err)); + ``` + */ + load(paths: string, type: typeof cc.Asset, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, assets: T) => void): void; + load(paths: string[], type: typeof cc.Asset, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, assets: Array) => void): void; + load(paths: string, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, assets: T) => void): void; + load(paths: string[], onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, assets: Array) => void): void; + load(paths: string, type: typeof cc.Asset, onComplete?: (error: Error, assets: T) => void): void; + load(paths: string[], type: typeof cc.Asset, onComplete?: (error: Error, assets: Array) => void): void; + load(paths: string, onComplete?: (error: Error, assets: T) => void): void; + load(paths: string[], onComplete?: (error: Error, assets: Array) => void): void; + /** + !#en + Preload the asset within this bundle by the path which is relative to bundle's path. + After calling this method, you still need to finish loading by calling `Bundle.load`. + It will be totally fine to call `Bundle.load` at any time even if the preloading is not + yet finished + + !#zh + 通过相对路径预加载分包中的资源。路径是相对分包文件夹路径的相对路径。调用完后,你仍然需要通过 `Bundle.load` 来完成加载。 + 就算预加载还没完成,你也可以直接调用 `Bundle.load`。 + @param paths Paths of the target asset.The path is relative to bundle folder, extensions must be omitted. + @param type Only asset of type will be loaded if this argument is supplied. + @param onProgress Callback invoked when progression change. + @param onComplete Callback invoked when the resource loaded. + + @example + ```js + // preload the texture (${project}/assets/resources/textures/background.jpg) from resources + cc.resources.preload('textures/background', cc.Texture2D); + + // preload the audio (${project}/assets/resources/music/hit.mp3) from resources + cc.resources.preload('music/hit', cc.AudioClip); + // wait for while + cc.resources.load('music/hit', cc.AudioClip, (err, audioClip) => {}); + + * // preload the prefab (${project}/assets/bundle1/misc/character/cocos) from bundle1 folder + bundle1.preload('misc/character/cocos', cc.Prefab); + + // load the sprite frame of (${project}/assets/bundle2/imgs/cocos.png) from bundle2 folder + bundle2.preload('imgs/cocos', cc.SpriteFrame); + // wait for while + bundle2.load('imgs/cocos', cc.SpriteFrame, (err, spriteFrame) => {}); + ``` + */ + preload(paths: string|string[], type: typeof cc.Asset, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, items: RequestItem[]) => void): void; + preload(paths: string|string[], onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, items: RequestItem[]) => void): void; + preload(paths: string|string[], type: typeof cc.Asset, onComplete: (error: Error, items: RequestItem[]) => void): void; + preload(paths: string|string[], type: typeof cc.Asset): void; + preload(paths: string|string[], onComplete: (error: Error, items: RequestItem[]) => void): void; + preload(paths: string|string[]): void; + /** + !#en + Load all assets under a folder inside the bundle folder.
+
+ Note: All asset paths in Creator use forward slashes, paths using backslashes will not work. + + !#zh + 加载目标文件夹中的所有资源, 注意:路径中只能使用斜杠,反斜杠将停止工作 + @param dir path of the target folder.The path is relative to the bundle folder, extensions must be omitted. + @param type Only asset of type will be loaded if this argument is supplied. + @param onProgress Callback invoked when progression change. + @param onComplete A callback which is called when all assets have been loaded, or an error occurs. + + @example + ```js + // load all audios (resources/audios/) + cc.resources.loadDir('audios', cc.AudioClip, (err, audios) => {}); + + // load all textures in "resources/imgs/" + cc.resources.loadDir('imgs', cc.Texture2D, null, function (err, textures) { + var texture1 = textures[0]; + var texture2 = textures[1]; + }); + + // load all prefabs (${project}/assets/bundle1/misc/characters/) from bundle1 folder + bundle1.loadDir('misc/characters', cc.Prefab, (err, prefabs) => console.log(err)); + + // load all sprite frame (${project}/assets/some/xxx/bundle2/skills/) from bundle2 folder + bundle2.loadDir('skills', cc.SpriteFrame, null, (err, spriteFrames) => console.log(err)); + ``` + */ + loadDir(dir: string, type: typeof cc.Asset, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, assets: Array) => void): void; + loadDir(dir: string, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, assets: Array) => void): void; + loadDir(dir: string, type: typeof cc.Asset, onComplete: (error: Error, assets: Array) => void): void; + loadDir(dir: string, type: typeof cc.Asset): void; + loadDir(dir: string, onComplete: (error: Error, assets: Array) => void): void; + loadDir(dir: string): void; + /** + !#en + Preload all assets under a folder inside the bundle folder.
After calling this method, you still need to finish loading by calling `Bundle.loadDir`. + It will be totally fine to call `Bundle.loadDir` at any time even if the preloading is not yet finished + + !#zh + 预加载目标文件夹中的所有资源。调用完后,你仍然需要通过 `Bundle.loadDir` 来完成加载。 + 就算预加载还没完成,你也可以直接调用 `Bundle.loadDir`。 + @param dir path of the target folder.The path is relative to the bundle folder, extensions must be omitted. + @param type Only asset of type will be preloaded if this argument is supplied. + @param onProgress Callback invoked when progression change. + @param onComplete A callback which is called when all assets have been loaded, or an error occurs. + + @example + ```js + // preload all audios (resources/audios/) + cc.resources.preloadDir('audios', cc.AudioClip); + + // preload all textures in "resources/imgs/" + cc.resources.preloadDir('imgs', cc.Texture2D); + // wait for while + cc.resources.loadDir('imgs', cc.Texture2D, (err, textures) => {}); + + // preload all prefabs (${project}/assets/bundle1/misc/characters/) from bundle1 folder + bundle1.preloadDir('misc/characters', cc.Prefab); + + // preload all sprite frame (${project}/assets/some/xxx/bundle2/skills/) from bundle2 folder + bundle2.preloadDir('skills', cc.SpriteFrame); + // wait for while + bundle2.loadDir('skills', cc.SpriteFrame, (err, spriteFrames) => {}); + ``` + */ + preloadDir(dir: string, type: typeof cc.Asset, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, items: RequestItem[]) => void): void; + preloadDir(dir: string, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, items: RequestItem[]) => void): void; + preloadDir(dir: string, type: typeof cc.Asset, onComplete: (error: Error, items: RequestItem[]) => void): void; + preloadDir(dir: string, type: typeof cc.Asset): void; + preloadDir(dir: string, onComplete: (error: Error, items: RequestItem[]) => void): void; + preloadDir(dir: string): void; + /** + !#en + Loads the scene within this bundle by its name. + + !#zh + 通过场景名称加载分包中的场景。 + @param sceneName The name of the scene to load. + @param options Some optional parameters + @param onProgress Callback invoked when progression change. + @param onComplete callback, will be called after scene launched. + + @example + ```js + bundle1.loadScene('first', (err, sceneAsset) => cc.director.runScene(sceneAsset)); + ``` + */ + loadScene(sceneName: string, options: Record, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, sceneAsset: cc.SceneAsset) => void): void; + loadScene(sceneName: string, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, sceneAsset: cc.SceneAsset) => void): void; + loadScene(sceneName: string, options: Record, onComplete: (error: Error, sceneAsset: cc.SceneAsset) => void): void; + loadScene(sceneName: string, onComplete: (error: Error, sceneAsset: cc.SceneAsset) => void): void; + loadScene(sceneName: string, options: Record): void; + loadScene(sceneName: string): void; + /** + !#en + Preloads the scene within this bundle by its name. After calling this method, you still need to finish loading by calling `Bundle.loadScene` or `cc.director.loadScene`. + It will be totally fine to call `Bundle.loadDir` at any time even if the preloading is not yet finished + + !#zh + 通过场景名称预加载分包中的场景.调用完后,你仍然需要通过 `Bundle.loadScene` 或 `cc.director.loadScene` 来完成加载。 + 就算预加载还没完成,你也可以直接调用 `Bundle.loadScene` 或 `cc.director.loadScene`。 + @param sceneName The name of the scene to preload. + @param options Some optional parameters + @param onProgress callback, will be called when the load progression change. + @param onComplete callback, will be called after scene loaded. + + @example + ```js + bundle1.preloadScene('first'); + // wait for a while + bundle1.loadScene('first', (err, scene) => cc.director.runScene(scene)); + ``` + */ + preloadScene(sceneName: string, options: Record, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error) => void): void; + preloadScene(sceneName: string, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error) => void): void; + preloadScene(sceneName: string, options: Record, onComplete: (error: Error) => void): void; + preloadScene(sceneName: string, onComplete: (error: Error) => void): void; + preloadScene(sceneName: string, options: Record): void; + preloadScene(sceneName: string): void; + /** + !#en + Get asset within this bundle by path and type.
+ After you load asset with {{#crossLink "Bundle/load:method"}}{{/crossLink}} or {{#crossLink "Bundle/loadDir:method"}}{{/crossLink}}, + you can acquire them by passing the path to this API. + + !#zh + 通过路径与类型获取资源。在你使用 {{#crossLink "Bundle/load:method"}}{{/crossLink}} 或者 {{#crossLink "Bundle/loadDir:method"}}{{/crossLink}} 之后, + 你能通过传路径通过这个 API 获取到这些资源。 + @param path The path of asset + @param type Only asset of type will be returned if this argument is supplied. + + @example + ```js + bundle1.get('music/hit', cc.AudioClip); + ``` + */ + get (path: string, type?: typeof cc.Asset): T; + /** + !#en + Release the asset loaded by {{#crossLink "Bundle/load:method"}}{{/crossLink}} or {{#crossLink "Bundle/loadDir:method"}}{{/crossLink}} and it's dependencies. + Refer to {{#crossLink "AssetManager/releaseAsset:method"}}{{/crossLink}} for detailed informations. + + !#zh + 释放通过 {{#crossLink "Bundle/load:method"}}{{/crossLink}} 或者 {{#crossLink "Bundle/loadDir:method"}}{{/crossLink}} 加载的资源。详细信息请参考 {{#crossLink "AssetManager/releaseAsset:method"}}{{/crossLink}} + @param path The path of asset + @param type Only asset of type will be released if this argument is supplied. + + @example + ```js + // release a texture which is no longer need + bundle1.release('misc/character/cocos'); + ``` + */ + release(path: string, type: typeof cc.Asset): void; + release(path: string): void; + /** + !#en + Release all assets within this bundle. Refer to {{#crossLink "AssetManager/releaseAll:method"}}{{/crossLink}} for detailed informations. + + !#zh + 释放此包中的所有资源。详细信息请参考 {{#crossLink "AssetManager/releaseAll:method"}}{{/crossLink}} + + @example + ```js + // release all asset within bundle1 + bundle1.releaseAll(); + ``` + */ + releaseAll(): void; + } + /** !#en + Cache manager is a module which controls all caches downloaded from server in non-web platform, it is a singleton + All member can be accessed with `cc.assetManager.cacheManager`. + + !#zh + 缓存管理器是一个模块,在非 WEB 平台上,用于管理所有从服务器上下载下来的缓存,这是一个单例,所有成员能通过 `cc.assetManager.cacheManager` 访问。 */ + export class CacheManager { + /** !#en + The name of cacheDir + + !#zh + 缓存目录的名称 */ + cacheDir: string; + /** !#en + Whether or not cache asset into user's storage space, this property only works on mini-game platforms + + !#zh + 是否缓存资源到用户存储空间,此属性只在小游戏平台有效 */ + cacheEnabled: boolean; + /** !#en + Whether or not auto clear cache when storage ran out, this property only works on mini-game platforms + + !#zh + 是否在存储空间满了后自动清理缓存,此属性只在小游戏平台有效 */ + autoClear: boolean; + /** !#en + The interval between caching resources, this property only works on mini-game platforms, unit: ms + + !#zh + 缓存资源的间隔时间,此属性只在小游戏平台有效,单位:ms */ + cacheInterval: number; + /** !#en + The interval between deleting resources, when you use `cleanLRU`, the resources will be deleted as this interval, unit: ms + + !#zh + 清理资源的间隔时间,当你使用 `cleanLRU` 时,资源将以此间隔被删除,单位:ms */ + deleteInterval: number; + /** !#en + List of all cached files + + !#zh + 所有缓存文件列表 */ + cachedFiles: Cache<{ bundle: string, url: string, lastTime: number }>; + /** + !#en + Get cached path with origin url + + !#zh + 通过原始 url 获取缓存后的路径 + @param originUrl originUrl + */ + getCache(originUrl: string): string; + /** + !#en + Get temporary path with origin url, this method only works on mini-game platforms + + !#zh + 通过原始 url 获取临时文件的路径,此方法只在小游戏平台有效 + @param originUrl originUrl + */ + getTemp(originUrl: string): string; + /** + !#en + Clear all caches, please use with caution, If necessary, we recommend using it before the game is launched + + !#zh + 清空所有缓存,请谨慎使用,如果必要的话,我们建议在游戏启动之前使用 + */ + clearCache(): void; + /** + !#en + Clear part of caches with LRU strategy + + !#zh + 使用 LRU 策略清空部分缓存 + */ + clearLRU(): void; + /** + !#en + Remove cache with origin url + + !#zh + 通过原始 url 移除缓存 + */ + removeCache(): void; + } + /** !#en + use to cache something + + !#zh + 用于缓存某些内容 */ + export class Cache { + /** + !#en + Create a cache + + !#zh + 创建一个 cache + @param map An object used to initialize + */ + constructor(map?: Record); + /** + !#en + Add Key-Value to cache + + !#zh + 增加键值对到缓存中 + @param key The key + @param val The value + + @example + ```js + var cache = new Cache(); + cache.add('test', null); + ``` + */ + add(key: string, val: T): T; + /** + !#en + Get the cached content by key + + !#zh + 通过 key 获取对应的 value + @param key The key + + @example + ```js + var cache = new Cache(); + var test = cache.get('test'); + ``` + */ + get(key: string): T; + /** + !#en + Check whether or not content exists by key + + !#zh + 通过 Key 判断是否存在对应的内容 + @param key The key + + @example + ```js + var cache = new Cache(); + var exist = cache.has('test'); + ``` + */ + has(key: string): boolean; + /** + !#en + Remove the cached content by key + + !#zh + 通过 Key 移除对应的内容 + @param key The key + + @example + ```js + var cache = new Cache(); + var content = cache.remove('test'); + ``` + */ + remove(key: string): T; + /** + !#en + Clear all content + + !#zh + 清除所有内容 + + @example + ```js + var cache = new Cache(); + cache.clear(); + ``` + */ + clear():void; + /** + !#en + Enumerate all content and invoke function + + !#zh + 枚举所有内容并执行方法 + @param func Function to be invoked + + @example + ```js + var cache = new Cache(); + cache.forEach((val, key) => console.log(key)); + ``` + */ + forEach(func: (val: T, key: string) => void): void; + /** + !#en + Enumerate all content to find one element which can fulfill condition + + !#zh + 枚举所有内容,找到一个可以满足条件的元素 + @param predicate The condition + + @example + ```js + var cache = new Cache(); + var val = cache.find((val, key) => key === 'test'); + ``` + */ + find(predicate: (val: T, key: string) => boolean): T; + /** !#en + The count of cached content + + !#zh + 缓存数量 */ + count: number; + /** + !#en + Destroy this cache + + !#zh + 销毁这个 cache + */ + destroy(): void; + } + /** !#en + Control asset's dependency list, it is a singleton. All member can be accessed with `cc.assetManager.dependUtil` + + !#zh + 控制资源的依赖列表,这是一个单例, 所有成员能通过 `cc.assetManager.dependUtil` 访问 */ + export class DependUtil { + /** + !#en + Get asset's native dependency. For example, Texture's native dependency is image. + + !#zh + 获取资源的原生依赖,例如 Texture 的原生依赖是图片 + @param uuid asset's uuid + + @example + ```js + var dep = dependUtil.getNativeDep('fcmR3XADNLgJ1ByKhqcC5Z'); + ``` + */ + getNativeDep(uuid: string): Record; + /** + !#en + Get asset's direct referencing non-native dependency list. For example, Material's non-native dependencies are Texture. + + !#zh + 获取资源直接引用的非原生依赖列表,例如,材质的非原生依赖是 Texture + @param uuid asset's uuid + + @example + ```js + var deps = dependUtil.getDeps('fcmR3XADNLgJ1ByKhqcC5Z'); + ``` + */ + getDeps(uuid: string): string[]; + /** + !#en + Get non-native dependency list of the loaded asset, include indirect reference. + The returned array stores the dependencies with their uuid, after retrieve dependencies, + + !#zh + 获取某个已经加载好的资源的所有非原生依赖资源列表,包括间接引用的资源,并保存在数组中返回。 + 返回的数组将仅保存依赖资源的 uuid。 + @param uuid The asset's uuid + + @example + ```js + var deps = dependUtil.getDepsRecursively('fcmR3XADNLgJ1ByKhqcC5Z'); + ``` + */ + getDepsRecursively(uuid: string): string[]; + } + /** !#en + Control all download process, it is a singleton. All member can be accessed with `cc.assetManager.downloader` , it can download several types of files: + 1. Text + 2. Image + 3. Audio + 4. Assets + 5. Scripts + + !#zh + 管理所有下载过程,downloader 是个单例,所有成员能通过 `cc.assetManager.downloader` 访问,它能下载以下几种类型的文件: + 1. 文本 + 2. 图片 + 3. 音频 + 4. 资源 + 5. 脚本 */ + export class Downloader { + /** !#en + The address of remote server + + !#zh + 远程服务器地址 */ + remoteServerAddress: string; + /** !#en + The maximum number of concurrent when downloading + + !#zh + 下载时的最大并发数 */ + maxConcurrency: number; + /** !#en + The maximum number of request can be launched per frame when downloading + + !#zh + 下载时每帧可以启动的最大请求数 */ + maxRequestsPerFrame: number; + /** !#en + The max number of retries when fail + + !#zh + 失败重试次数 */ + maxRetryCount: number; + /** !#en + Wait for while before another retry, unit: ms + + !#zh + 重试的间隔时间 */ + retryInterval: number; + /** + !#en + Register custom handler if you want to change default behavior or extend downloader to download other format file + + !#zh + 当你想修改默认行为或者拓展 downloader 来下载其他格式文件时可以注册自定义的 handler + @param type Extension likes '.jpg' or map likes {'.jpg': jpgHandler, '.png': pngHandler} + @param handler handler + + @example + ```js + downloader.register('.tga', (url, options, onComplete) => onComplete(null, null)); + downloader.register({'.tga': (url, options, onComplete) => onComplete(null, null), '.ext': (url, options, onComplete) => onComplete(null, null)}); + ``` + */ + register(type: string, handler: (url: string, options: Record, onComplete: (err: Error, content: any) => void) => void): void; + register(map: Record, onComplete: (err: Error, content: any) => void) => void>): void; + /** + !#en + Use corresponding handler to download file under limitation + + !#zh + 在限制下使用对应的 handler 来下载文件 + @param url The url should be downloaded + @param type The type indicates that which handler should be used to download, such as '.jpg' + @param options some optional paramters will be transferred to the corresponding handler. + @param onComplete callback when finishing downloading + + @example + ```js + download('http://example.com/test.tga', '.tga', {onFileProgress: (loaded, total) => console.lgo(loaded/total)}, onComplete: (err) => console.log(err)); + ``` + */ + download(id: string, url: string, type: string, options: Record, onComplete: (err: Error, content: any) => void): void; + } + /** !#en + Provide some helpful function, it is a singleton. All member can be accessed with `cc.assetManager.utils` + + !#zh + 提供一些辅助方法,helper 是一个单例, 所有成员能通过 `cc.assetManager.utils` 访问 */ + export class Helper { + /** + !#en + Decode uuid, returns the original uuid + + !#zh + 解码 uuid,返回原始 uuid + @param base64 the encoded uuid + + @example + ```js + var uuid = 'fcmR3XADNLgJ1ByKhqcC5Z'; + var originalUuid = decodeUuid(uuid); // fc991dd7-0033-4b80-9d41-c8a86a702e59 + ``` + */ + decodeUuid(base64: string): string; + /** + !#en + Extract uuid from url + + !#zh + 从 url 中提取 uuid + @param url url + + @example + ```js + var url = 'assets/main/import/fc/fc991dd7-0033-4b80-9d41-c8a86a702e59.json'; + var uuid = getUuidFromURL(url); // fc991dd7-0033-4b80-9d41-c8a86a702e59 + ``` + */ + getUuidFromURL(url: string): string; + /** + !#en + Transform uuid to url + + !#zh + 转换 uuid 为 url + @param uuid The uuid of asset + @param options Some optional parameters + + @example + ```js + // json path, 'assets/main/import/fc/fc991dd7-0033-4b80-9d41-c8a86a702e59.json'; + var url = getUrlWithUuid('fcmR3XADNLgJ1ByKhqcC5Z', {isNative: false}); + + // png path, 'assets/main/native/fc/fc991dd7-0033-4b80-9d41-c8a86a702e59.png'; + var url = getUrlWithUuid('fcmR3XADNLgJ1ByKhqcC5Z', {isNative: true, nativeExt: '.png'}); + ``` + */ + getUrlWithUuid(uuid: string, options?: Record): string; + /** + !#en + Check if the type of asset is scene + + !#zh + 检查资源类型是否是场景 + @param asset asset + */ + isScene(asset: any): boolean; + /** + !#en + Normalize url, strip './' and '/' + + !#zh + 标准化 url ,去除 './' 和 '/' + @param url url + */ + normalize(url: string): string; + } + /** !#en + Handle the packed asset, include unpacking, loading, cache and so on. It is a singleton. All member can be accessed with `cc.assetManager.packManager` + + !#zh + 处理打包资源,包括拆包,加载,缓存等等,这是一个单例, 所有成员能通过 `cc.assetManager.packManager` 访问 */ + export class PackManager { + /** + !#en + Unpack the json, revert to what it was before packing + + !#zh + 拆解 json 包,恢复为打包之前的内容 + @param pack The pack + @param json The content of pack + @param options Some optional parameters + @param onComplete Callback when finish unpacking + + @example + ```js + downloader.downloadFile('pack.json', {responseType: 'json'}, null, (err, file) => { + packManager.unpackJson(['a', 'b'], file, null, (err, data) => console.log(err)); + }); + ``` + */ + unpackJson(pack: string[], json: any, options: Record, onComplete?: (err: Error, content: any) => void): void; + /** + !#en + Register custom handler if you want to change default behavior or extend packManager to unpack other format pack + + !#zh + 当你想修改默认行为或者拓展 packManager 来拆分其他格式的包时可以注册自定义的 handler + @param type Extension likes '.bin' or map likes {'.bin': binHandler, '.ab': abHandler} + @param handler handler + + @example + ```js + packManager.register('.bin', (packUuid, file, options, onComplete) => onComplete(null, null)); + packManager.register({'.bin': (packUuid, file, options, onComplete) => onComplete(null, null), '.ab': (packUuid, file, options, onComplete) => onComplete(null, null)}); + ``` + */ + register(type: string, handler: (packUuid: string, data: any, options: Record, onComplete: (err: Error, content: any) => void) => void): void; + register(map: Record, onComplete: (err: Error, content: any) => void) => void>): void; + /** + !#en + Use corresponding handler to unpack package + + !#zh + 用对应的 handler 来进行解包 + @param pack The uuid of packed assets + @param data The packed data + @param type The type indicates that which handler should be used to download, such as '.jpg' + @param options Some optional parameter + @param onComplete callback when finishing unpacking + + @example + ```js + downloader.downloadFile('pack.json', {responseType: 'json'}, null, (err, file) => { + packManager.unpack(['2fawq123d', '1zsweq23f'], file, '.json', null, (err, data) => console.log(err)); + }); + ``` + */ + unpack(pack: string[], data: any, type: string, options: Record, onComplete?: (err: Error, data: any) => void): void; + /** + !#en + Download request item, If item is not in any package, download as usual. Otherwise, download the corresponding package and unpack it. + And then retrieve the corresponding content form it. + + !#zh + 下载请求对象,如果请求对象不在任何包内,则正常下载,否则下载对应的 package 并进行拆解,并取回包内对应的内容 + @param item Some item you want to download + @param options Some optional parameters + @param onComplete Callback when finished + + @example + ```js + var requestItem = cc.AssetManager.RequestItem.create(); + requestItem.uuid = 'fcmR3XADNLgJ1ByKhqcC5Z'; + requestItem.info = config.getAssetInfo('fcmR3XADNLgJ1ByKhqcC5Z'); + packManager.load(requestItem, null, (err, data) => console.log(err)); + ``` + */ + load(item: RequestItem, options: Record, onComplete: (err: Error, data: any) => void): void; + } + /** !#en + Parse the downloaded file, it's a singleton, all member can be accessed with `cc.assetManager.parser` + + !#zh + 解析已下载的文件,parser 是一个单例, 所有成员能通过 `cc.assetManaager.parser` 访问 */ + export class Parser { + /** + !#en + Register custom handler if you want to change default behavior or extend parser to parse other format file + + !#zh + 当你想修改默认行为或者拓展 parser 来解析其他格式文件时可以注册自定义的handler + @param type Extension likes '.jpg' or map likes {'.jpg': jpgHandler, '.png': pngHandler} + @param handler The corresponding handler + + @example + ```js + parser.register('.tga', (file, options, onComplete) => onComplete(null, null)); + parser.register({'.tga': (file, options, onComplete) => onComplete(null, null), '.ext': (file, options, onComplete) => onComplete(null, null)}); + ``` + */ + register(type: string, handler: (file: any, options: Record, onComplete: (err: Error, data: any) => void) => void): void; + register(map: Record, onComplete: (err: Error, data: any) => void) => void>): void; + /** + !#en + Use corresponding handler to parse file + + !#zh + 使用对应的handler来解析文件 + @param id The id of file + @param file File + @param type The corresponding type of file, likes '.jpg'. + @param options Some optional paramters will be transferred to the corresponding handler. + @param onComplete callback when finishing downloading + + @example + ```js + downloader.downloadFile('test.jpg', {responseType: 'blob'}, null, (err, file) => { + parser.parse('test.jpg', file, '.jpg', null, (err, img) => console.log(err)); + }); + ``` + */ + parse(id: string, file: any, type: string, options: Record, onComplete: (err: Error, content: any) => void): void; + } + /** !#en + Pipeline can execute the task for some effect. + + !#zh + 管线能执行任务达到某个效果 */ + export class Pipeline { + /** !#en + The id of pipeline + + !#zh + 管线的 id */ + id: number; + /** !#en + The name of pipeline + + !#zh + 管线的名字 */ + name: string; + /** !#en + All pipes of pipeline + + !#zh + 所有的管道 */ + pipes: Function[]; + /** + !#en + Create a new pipeline + + !#zh + 创建一个管线 + @param name The name of pipeline + @param funcs The array of pipe, every pipe must be function which take two parameters, the first is a `Task` flowed in pipeline, the second is complete callback + + @example + ```js + var pipeline = new Pipeline('download', [ + (task, done) => { + var url = task.input; + cc.assetManager.downloader.downloadFile(url, null, null, (err, result) => { + task.output = result; + done(err); + }); + }, + (task, done) => { + var text = task.input; + var json = JSON.stringify(text); + task.output = json; + done(); + } + ]); + ``` + */ + constructor(name: string, funcs: Array<(task: Task, done?: (err: Error) => void) => void>); + /** + !#en + At specific point insert a new pipe to pipeline + + !#zh + 在某个特定的点为管线插入一个新的 pipe + @param func The new pipe + @param index The specific point you want to insert at. + + @example + ```js + var pipeline = new Pipeline('test', []); + pipeline.insert((task, done) => { + // do something + done(); + }, 0); + ``` + */ + insert(func: (task: Task, callback?: (err: Error) => void) => void, index: number): Pipeline; + /** + !#en + Append a new pipe to the pipeline + + !#zh + 添加一个管道到管线中 + @param func The new pipe + + @example + ```js + var pipeline = new Pipeline('test', []); + pipeline.append((task, done) => { + // do something + done(); + }); + ``` + */ + append(func: (task: Task, callback?: (err: Error) => void) => void): Pipeline; + /** + !#en + Remove pipe which at specific point + + !#zh + 移除特定位置的管道 + @param index The specific point + + @example + ```js + var pipeline = new Pipeline('test', (task, done) => { + // do something + done(); + }); + pipeline.remove(0); + ``` + */ + remove(index: number): Pipeline; + /** + !#en + Execute task synchronously + + !#zh + 同步执行任务 + @param task The task will be executed + + @example + ```js + var pipeline = new Pipeline('sync', [(task) => { + let input = task.input; + task.output = doSomething(task.input); + }]); + + var task = new Task({input: 'test'}); + console.log(pipeline.sync(task)); + ``` + */ + sync(task: Task): any; + /** + !#en + Execute task asynchronously + + !#zh + 异步执行任务 + @param task The task will be executed + + @example + ```js + var pipeline = new Pipeline('sync', [(task, done) => { + let input = task.input; + task.output = doSomething(task.input); + done(); + }]); + var task = new Task({input: 'test', onComplete: (err, result) => console.log(result)}); + pipeline.async(task); + ``` + */ + async(task: Task): void; + } + /** !#en + A collection of information about a request + + !#zh + 请求的相关信息集合 */ + export class RequestItem { + /** !#en + The uuid of request + + !#zh + 请求资源的uuid */ + uuid: string; + /** !#en + The final url of request + + !#zh + 请求的最终url */ + url: string; + /** !#en + The extension name of asset + + !#zh + 资源的扩展名 */ + ext: string; + /** !#en + The content of asset + + !#zh + 资源的内容 */ + content: any; + /** !#en + The file of asset + + !#zh + 资源的文件 */ + file: any; + /** !#en + The information of asset + + !#zh + 资源的相关信息 */ + info: any; + /** !#en + Whether or not it is native asset + + !#zh + 资源是否是原生资源 */ + isNative: boolean; + /** !#en + Custom options + + !#zh + 自定义参数 */ + options: any; + /** + !#en + Create a request item + + !#zh + 创建一个 request item + */ + constructor(); + /** !#en + The id of request, combined from uuid and isNative + + !#zh + 请求的 id, 由 uuid 和 isNative 组合而成 */ + id: string; + /** + !#en + Recycle this for reuse + + !#zh + 回收 requestItem 用于复用 + */ + recycle(): void; + /** + !#en + Create a new request item from pool + + !#zh + 从对象池中创建 requestItem + */ + static create(): RequestItem; + } + /** !#en + The builtin bundles + + !#zh + 内置 bundle */ + export enum BuiltinBundleName { + RESOURCES = 0, + INTERNAL = 0, + MAIN = 0, + START_SCENE = 0, + } + /** !#en + Task is used to run in the pipeline for some effect + + !#zh + 任务用于在管线中运行以达成某种效果 */ + export class Task { + /** !#en + The id of task + + !#zh + 任务id */ + id: number; + /** !#en + The callback when task is completed + + !#zh + 完成回调 */ + onComplete: Function; + /** !#en + The callback of progression + + !#zh + 进度回调 */ + onProgress: Function; + /** !#en + The callback when something goes wrong + + !#zh + 错误回调 */ + onError: Function; + /** !#en + The source of task + + !#zh + 任务的源 */ + source: any; + /** !#en + The output of task + + !#zh + 任务的输出 */ + output: any; + /** !#en + The input of task + + !#zh + 任务的输入 */ + input: any; + /** !#en + The progression of task + + !#zh + 任务的进度 */ + progress: any; + /** !#en + Custom options + + !#zh + 自定义参数 */ + options: any; + /** + !#en + Create a new Task + + !#zh + 创建一个任务 + @param options Some optional paramters + */ + constructor(options?: {onComplete?: (err: Error, result: any) => void, onError?: () => void, onProgress?: Function, input: any, progress?: any, options?: Record}); + /** + !#en + Set paramters of this task + + !#zh + 设置任务的参数 + @param options Some optional paramters + + @example + ```js + var task = new Task(); + task.set({input: ['test'], onComplete: (err, result) => console.log(err), onProgress: (finish, total) => console.log(finish / total)}); + ``` + */ + set(options?: {onComplete?: (err: Error, result: any) => void, onError?: () => void, onProgress?: Function, input: any, progress?: any, options?: Record}): void; + /** + !#en + Dispatch event + + !#zh + 发布事件 + @param event The event name + @param param1 Parameter 1 + @param param2 Parameter 2 + @param param3 Parameter 3 + @param param4 Parameter 4 + + @example + ```js + var task = Task.create(); + Task.onComplete = (msg) => console.log(msg); + Task.dispatch('complete', 'hello world'); + ``` + */ + dispatch(event: string, param1?: any, param2?: any, param3?: any, param4?: any): void; + /** + !#en + Recycle this for reuse + + !#zh + 回收 task 用于复用 + */ + recycle(): void; + /** !#en + Whether or not this task is completed + + !#zh + 此任务是否已经完成 */ + isFinish: boolean; + /** + !#en + Create a new task from pool + + !#zh + 从对象池中创建 task + @param options Some optional paramters + */ + static create(options?: {onComplete?: (err: Error, result: any) => void, onError?: () => void, onProgress?: Function, input: any, progress?: any, options?: Record}): Task; + } +} + +/** Some helpful utilities */ +declare namespace cc.geomUtils { + /** + !#en + the distance between a point and a plane + !#zh + 计算点和平面之间的距离。 + @param point point + @param plane plane + */ + export function point_plane(point: cc.Vec3, plane: cc.Plane): number; + /** + !#en + the closest point on plane to a given point + !#zh + 计算平面上最接近给定点的点。 + @param out Closest point + @param point Given point + @param plane plane + */ + export function pt_point_plane(out: cc.Vec3, point: cc.Vec3, plane: cc.Plane): cc.Vec3; + /** + !#en + the closest point on aabb to a given point + !#zh + 计算 aabb 上最接近给定点的点。 + @param out Closest point. + @param point Given point. + @param aabb Align the axis around the box. + */ + export function pt_point_aabb(out: cc.Vec3, point: cc.Vec3, aabb: cc.Aabb): cc.Vec3; + /** + !#en + the closest point on obb to a given point + !#zh + 计算 obb 上最接近给定点的点。 + @param out Closest point + @param point Given point + @param obb Direction box + */ + export function pt_point_obb(out: cc.Vec3, point: cc.Vec3, obb: cc.Obb): cc.Vec3; +} + +/** !#en Some JavaScript decorators which can be accessed with "cc._decorator". +!#zh 一些 JavaScript 装饰器,目前可以通过 "cc._decorator" 来访问。 +(这些 API 仍不完全稳定,有可能随着 JavaScript 装饰器的标准实现而调整) */ +declare namespace cc._decorator { + /** + !#en + Declare the standard [ES6 Class](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes) + as CCClass, please see [Class](../../../manual/en/scripting/class.html) for details. + !#zh + 将标准写法的 [ES6 Class](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes) 声明为 CCClass,具体用法请参阅[类型定义](../../../manual/zh/scripting/class.html)。 + @param name The class name used for serialization. + + @example + ```js + const {ccclass} = cc._decorator; + + // define a CCClass, omit the name + @ccclass + class NewScript extends cc.Component { + // ... + } + + // define a CCClass with a name + @ccclass('LoginData') + class LoginData { + // ... + } + ``` + */ + export function ccclass(name?: string): Function; + export function ccclass(_class?: Function): void; + /** + !#en + Declare property for [CCClass](../../../manual/en/scripting/reference/attributes.html). + !#zh + 定义 [CCClass](../../../manual/zh/scripting/reference/attributes.html) 所用的属性。 + @param options an object with some property attributes + + @example + ```js + const {ccclass, property} = cc._decorator; + + @ccclass + class NewScript extends cc.Component { + @property({ + type: cc.Node + }) + targetNode1 = null; + + @property(cc.Node) + targetNode2 = null; + + @property(cc.Button) + targetButton = null; + + @property + _width = 100; + + @property + get width () { + return this._width; + } + + @property + set width (value) { + this._width = value; + } + + @property + offset = new cc.Vec2(100, 100); + + @property(cc.Vec2) + offsets = []; + + @property(cc.SpriteFrame) + frame = null; + } + + // above is equivalent to (上面的代码相当于): + + var NewScript = cc.Class({ + properties: { + targetNode1: { + default: null, + type: cc.Node + }, + + targetNode2: { + default: null, + type: cc.Node + }, + + targetButton: { + default: null, + type: cc.Button + }, + + _width: 100, + + width: { + get () { + return this._width; + }, + set (value) { + this._width = value; + } + }, + + offset: new cc.Vec2(100, 100) + + offsets: { + default: [], + type: cc.Vec2 + } + + frame: { + default: null, + type: cc.SpriteFrame + }, + } + }); + ``` + */ + export function property(options?: {type?: any; visible?: boolean|(() => boolean); displayName?: string; tooltip?: string; multiline?: boolean; readonly?: boolean; min?: number; max?: number; step?: number; range?: number[]; slide?: boolean; serializable?: boolean; formerlySerializedAs?: string; editorOnly?: boolean; override?: boolean; animatable?: boolean} | any[]|Function|cc.ValueType|number|string|boolean): Function; + export function property(_target: Object, _key: any, _desc?: any): void; + /** + !#en + Makes a CCClass that inherit from component execute in edit mode.
+ By default, all components are only executed in play mode, + which means they will not have their callback functions executed while the Editor is in edit mode. + !#zh + 允许继承自 Component 的 CCClass 在编辑器里执行。
+ 默认情况下,所有 Component 都只会在运行时才会执行,也就是说它们的生命周期回调不会在编辑器里触发。 + + @example + ```js + const {ccclass, executeInEditMode} = cc._decorator; + + @ccclass + @executeInEditMode + class NewScript extends cc.Component { + // ... + } + ``` + */ + export function executeInEditMode(): Function; + export function executeInEditMode(_class: Function): void; + /** + !#en + Automatically add required component as a dependency for the CCClass that inherit from component. + !#zh + 为声明为 CCClass 的组件添加依赖的其它组件。当组件添加到节点上时,如果依赖的组件不存在,引擎将会自动将依赖组件添加到同一个节点,防止脚本出错。该设置在运行时同样有效。 + @param requiredComponent requiredComponent + + @example + ```js + const {ccclass, requireComponent} = cc._decorator; + + @ccclass + @requireComponent(cc.Sprite) + class SpriteCtrl extends cc.Component { + // ... + } + ``` + */ + export function requireComponent(requiredComponent: typeof cc.Component): Function; + /** + !#en + The menu path to register a component to the editors "Component" menu. Eg. "Rendering/CameraCtrl". + !#zh + 将当前组件添加到组件菜单中,方便用户查找。例如 "Rendering/CameraCtrl"。 + @param path The path is the menu represented like a pathname. + For example the menu could be "Rendering/CameraCtrl". + + @example + ```js + const {ccclass, menu} = cc._decorator; + + @ccclass + @menu("Rendering/CameraCtrl") + class NewScript extends cc.Component { + // ... + } + ``` + */ + export function menu(path: string): Function; + /** + !#en + The execution order of lifecycle methods for Component. + Those less than 0 will execute before while those greater than 0 will execute after. + The order will only affect onLoad, onEnable, start, update and lateUpdate while onDisable and onDestroy will not be affected. + !#zh + 设置脚本生命周期方法调用的优先级。优先级小于 0 的组件将会优先执行,优先级大于 0 的组件将会延后执行。优先级仅会影响 onLoad, onEnable, start, update 和 lateUpdate,而 onDisable 和 onDestroy 不受影响。 + @param order The execution order of lifecycle methods for Component. Those less than 0 will execute before while those greater than 0 will execute after. + + @example + ```js + const {ccclass, executionOrder} = cc._decorator; + + @ccclass + @executionOrder(1) + class CameraCtrl extends cc.Component { + // ... + } + ``` + */ + export function executionOrder(order: number): Function; + /** + !#en + Prevents Component of the same type (or subtype) to be added more than once to a Node. + !#zh + 防止多个相同类型(或子类型)的组件被添加到同一个节点。 + + @example + ```js + const {ccclass, disallowMultiple} = cc._decorator; + + @ccclass + @disallowMultiple + class CameraCtrl extends cc.Component { + // ... + } + ``` + */ + export function disallowMultiple(): Function; + export function disallowMultiple(_class: Function): void; + /** + !#en + If specified, the editor's scene view will keep updating this node in 60 fps when it is selected, otherwise, it will update only if necessary.
+ This property is only available if executeInEditMode is true. + !#zh + 当指定了 "executeInEditMode" 以后,playOnFocus 可以在选中当前组件所在的节点时,提高编辑器的场景刷新频率到 60 FPS,否则场景就只会在必要的时候进行重绘。 + + @example + ```js + const {ccclass, playOnFocus, executeInEditMode} = cc._decorator; + + @ccclass + @executeInEditMode + @playOnFocus + class CameraCtrl extends cc.Component { + // ... + } + ``` + */ + export function playOnFocus(): Function; + export function playOnFocus(_class: Function): void; + /** + !#en + Specifying the url of the custom html to draw the component in **Properties**. + !#zh + 自定义当前组件在 **属性检查器** 中渲染时所用的网页 url。 + @param url url + + @example + ```js + const {ccclass, inspector} = cc._decorator; + + @ccclass + @inspector("packages://inspector/inspectors/comps/camera-ctrl.js") + class NewScript extends cc.Component { + // ... + } + ``` + */ + export function inspector(path: string): Function; + /** + !#en + The custom documentation URL. + !#zh + 指定当前组件的帮助文档的 url,设置过后,在 **属性检查器** 中就会出现一个帮助图标,用户点击将打开指定的网页。 + @param url url + + @example + ```js + const {ccclass, help} = cc._decorator; + + @ccclass + @help("app://docs/html/components/spine.html") + class NewScript extends cc.Component { + // ... + } + ``` + */ + export function help(path: string): Function; + /** + NOTE:
+ The old mixins implemented in cc.Class(ES5) behaves exact the same as multiple inheritance. + But since ES6, class constructor can't be function-called and class methods become non-enumerable, + so we can not mix in ES6 Classes.
+ See:
+ [https://esdiscuss.org/topic/traits-are-now-impossible-in-es6-until-es7-since-rev32](https://esdiscuss.org/topic/traits-are-now-impossible-in-es6-until-es7-since-rev32)
+ One possible solution (but IDE unfriendly):
+ [http://justinfagnani.com/2015/12/21/real-mixins-with-javascript-classes](http://justinfagnani.com/2015/12/21/real-mixins-with-javascript-classes/)
+
+ NOTE:
+ You must manually call mixins constructor, this is different from cc.Class(ES5). + @param ctor constructors to mix, only support ES5 constructors or classes defined by using `cc.Class`, + not support ES6 Classes. + + @example + ```js + const {ccclass, mixins} = cc._decorator; + + class Animal { ... } + + const Fly = cc.Class({ + constructor () { ... } + }); + + @ccclass + @mixins(cc.EventTarget, Fly) + class Bird extends Animal { + constructor () { + super(); + + // You must manually call mixins constructor, this is different from cc.Class(ES5) + cc.EventTarget.call(this); + Fly.call(this); + } + // ... + } + ``` + */ + export function mixins(ctor: Function, ...rest: Function[]): Function; +} + +/** !#en This module provides some JavaScript utilities. All members can be accessed with `cc.js`. +!#zh 这个模块封装了 JavaScript 相关的一些实用函数,你可以通过 `cc.js` 来访问这个模块。 */ +declare namespace cc.js { + /** + Check the obj whether is number or not + If a number is created by using 'new Number(10086)', the typeof it will be "object"... + Then you can use this function if you care about this case. + @param obj obj + */ + export function isNumber(obj: any): boolean; + /** + Check the obj whether is string or not. + If a string is created by using 'new String("blabla")', the typeof it will be "object"... + Then you can use this function if you care about this case. + @param obj obj + */ + export function isString(obj: any): boolean; + /** + Copy all properties not defined in obj from arguments[1...n] + @param obj object to extend its properties + @param sourceObj source object to copy properties from + */ + export function addon(obj: any, ...sourceObj: any[]): any; + /** + copy all properties from arguments[1...n] to obj + @param obj obj + @param sourceObj sourceObj + */ + export function mixin(obj: any, ...sourceObj: any[]): any; + /** + Derive the class from the supplied base class. + Both classes are just native javascript constructors, not created by cc.Class, so + usually you will want to inherit using {{#crossLink "cc/Class:method"}}cc.Class {{/crossLink}} instead. + @param cls cls + @param base the baseclass to inherit + */ + export function extend(cls: Function, base: Function): Function; + /** + Get super class + @param ctor the constructor of subclass + */ + export function getSuper(ctor: Function): Function; + /** + Checks whether subclass is child of superclass or equals to superclass + @param subclass subclass + @param superclass superclass + */ + export function isChildClassOf(subclass: Function, superclass: Function): boolean; + /** + Removes all enumerable properties from object + @param obj obj + */ + export function clear(obj: any): void; + /** + Checks whether obj is an empty object + @param obj obj + */ + export function isEmptyObject(obj: any): boolean; + /** + Get property descriptor in object and all its ancestors + @param obj obj + @param name name + */ + export function getPropertyDescriptor(obj: any, name: string): any; + /** + Define value, just help to call Object.defineProperty.
+ The configurable will be true. + @param obj obj + @param prop prop + @param value value + @param writable writable + @param enumerable enumerable + */ + export function value(obj: any, prop: string, value: any, writable?: boolean, enumerable?: boolean): void; + /** + Define get set accessor, just help to call Object.defineProperty(...) + @param obj obj + @param prop prop + @param getter getter + @param setter setter + @param enumerable enumerable + @param configurable configurable + */ + export function getset(obj: any, prop: string, getter: Function, setter?: Function, enumerable?: boolean, configurable?: boolean): void; + /** + Define get accessor, just help to call Object.defineProperty(...) + @param obj obj + @param prop prop + @param getter getter + @param enumerable enumerable + @param configurable configurable + */ + export function get(obj: any, prop: string, getter: Function, enumerable?: boolean, configurable?: boolean): void; + /** + Define set accessor, just help to call Object.defineProperty(...) + @param obj obj + @param prop prop + @param setter setter + @param enumerable enumerable + @param configurable configurable + */ + export function set(obj: any, prop: string, setter: Function, enumerable?: boolean, configurable?: boolean): void; + /** + Get class name of the object, if object is just a {} (and which class named 'Object'), it will return "". + (modified from the code from this stackoverflow post) + @param objOrCtor instance or constructor + */ + export function getClassName(objOrCtor: any|Function): string; + /** !#en All classes registered in the engine, indexed by ID. + !#zh 引擎中已注册的所有类型,通过 ID 进行索引。 */ + export var _registeredClassIds: any; + /** !#en All classes registered in the engine, indexed by name. + !#zh 引擎中已注册的所有类型,通过名称进行索引。 */ + export var _registeredClassNames: any; + /** + Register the class by specified name manually + @param className className + @param constructor constructor + */ + export function setClassName(className: string, constructor: Function): void; + /** + Unregister a class from fireball. + + If you dont need a registered class anymore, you should unregister the class so that Fireball will not keep its reference anymore. + Please note that its still your responsibility to free other references to the class. + @param constructor the class you will want to unregister, any number of classes can be added + */ + export function unregisterClass(...constructor: Function[]): void; + /** + Get the registered class by name + @param classname classname + */ + export function getClassByName(classname: string): Function; + /** + Defines a polyfill field for deprecated codes. + @param obj YourObject or YourClass.prototype + @param obsoleted "OldParam" or "YourClass.OldParam" + @param newExpr "NewParam" or "YourClass.NewParam" + @param writable writable + */ + export function obsolete(obj: any, obsoleted: string, newExpr: string, writable?: boolean): void; + /** + Defines all polyfill fields for obsoleted codes corresponding to the enumerable properties of props. + @param obj YourObject or YourClass.prototype + @param objName "YourObject" or "YourClass" + @param props props + @param writable writable + */ + export function obsoletes(obj: any, objName: any, props: any, writable?: boolean): void; + /** + A string tool to construct a string with format string. + @param msg A JavaScript string containing zero or more substitution strings (%s). + @param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output. + + @example + ```js + cc.js.formatStr("a: %s, b: %s", a, b); + cc.js.formatStr(a, b, c); + ``` + */ + export function formatStr(msg: string|any, ...subst: any[]): string; + /** + !#en + A simple wrapper of `Object.create(null)` which ensures the return object have no prototype (and thus no inherited members). So we can skip `hasOwnProperty` calls on property lookups. It is a worthwhile optimization than the `{}` literal when `hasOwnProperty` calls are necessary. + !#zh + 该方法是对 `Object.create(null)` 的简单封装。`Object.create(null)` 用于创建无 prototype (也就无继承)的空对象。这样我们在该对象上查找属性时,就不用进行 `hasOwnProperty` 判断。在需要频繁判断 `hasOwnProperty` 时,使用这个方法性能会比 `{}` 更高。 + @param forceDictMode Apply the delete operator to newly created map object. This causes V8 to put the object in "dictionary mode" and disables creation of hidden classes which are very expensive for objects that are constantly changing shape. + */ + export function createMap(forceDictMode?: boolean): any; + /** undefined */ + export class array { + /** + Removes the array item at the specified index. + @param array array + @param index index + */ + static removeAt(array: any[], index: number): void; + /** + Removes the array item at the specified index. + It's faster but the order of the array will be changed. + @param array array + @param index index + */ + static fastRemoveAt(array: any[], index: number): void; + /** + Removes the first occurrence of a specific object from the array. + @param array array + @param value value + */ + static remove(array: any[], value: any): boolean; + /** + Removes the first occurrence of a specific object from the array. + It's faster but the order of the array will be changed. + @param array array + @param value value + */ + static fastRemove(array: any[], value: number): void; + /** + Verify array's Type + @param array array + @param type type + */ + static verifyType(array: any[], type: Function): boolean; + /** + Removes from array all values in minusArr. For each Value in minusArr, the first matching instance in array will be removed. + @param array Source Array + @param minusArr minus Array + */ + static removeArray(array: any[], minusArr: any[]): void; + /** + Inserts some objects at index + @param array array + @param addObjs addObjs + @param index index + */ + static appendObjectsAt(array: any[], addObjs: any[], index: number): any[]; + /** + Determines whether the array contains a specific value. + @param array array + @param value value + */ + static contains(array: any[], value: any): boolean; + /** + Copy an array's item to a new array (its performance is better than Array.slice) + @param array array + */ + static copy(array: any[]): any[]; + } + /** !#en + A fixed-length object pool designed for general type.
+ The implementation of this object pool is very simple, + it can helps you to improve your game performance for objects which need frequent release and recreate operations
+ !#zh + 长度固定的对象缓存池,可以用来缓存各种对象类型。
+ 这个对象池的实现非常精简,它可以帮助您提高游戏性能,适用于优化对象的反复创建和销毁。 */ + export class Pool { + /** + !#en + Constructor for creating an object pool for the specific object type. + You can pass a callback argument for process the cleanup logic when the object is recycled. + !#zh + 使用构造函数来创建一个指定对象类型的对象池,您可以传递一个回调函数,用于处理对象回收时的清理逻辑。 + @param cleanupFunc the callback method used to process the cleanup logic when the object is recycled. + @param size initializes the length of the array + */ + constructor(cleanupFunc: (obj: any) => void, size: number); + constructor(size: number); + /** + !#en + Get and initialize an object from pool. This method defaults to null and requires the user to implement it. + !#zh + 获取并初始化对象池中的对象。这个方法默认为空,需要用户自己实现。 + @param params parameters to used to initialize the object + */ + get(...params: any[]): any; + /** !#en + The current number of available objects, the default is 0, it will gradually increase with the recycle of the object, + the maximum will not exceed the size specified when the constructor is called. + !#zh + 当前可用对象数量,一开始默认是 0,随着对象的回收会逐渐增大,最大不会超过调用构造函数时指定的 size。 */ + count: number; + /** + !#en + Get an object from pool, if no available object in the pool, null will be returned. + !#zh + 获取对象池中的对象,如果对象池没有可用对象,则返回空。 + */ + _get(): any; + /** + !#en Put an object into the pool. + !#zh 向对象池返还一个不再需要的对象。 + */ + put(): void; + /** + !#en Resize the pool. + !#zh 设置对象池容量。 + */ + resize(): void; + } +} + +/** !#en A basic module for creating vertex data for 3D objects. You can access this module by `cc.primitive`. +!#zh 一个创建 3D 物体顶点数据的基础模块,你可以通过 `cc.primitive` 来访问这个模块。 */ +declare namespace cc.primitive { + /** + !#en Create box vertex data + !#zh 创建长方体顶点数据 + @param width width + @param height height + @param length length + @param opts opts + */ + export function box(width: number, height: number, length: number, opts: {widthSegments: number; heightSegments: number; lengthSegments: number; }): cc.VertexData; + /** + !#en Create cone vertex data + !#zh 创建圆锥体顶点数据 + @param radius radius + @param height height + @param opts opts + */ + export function cone(radius: number, height: number, opts: {radialSegments: number; heightSegments: number; capped: boolean; arc: number; }): cc.VertexData; + /** + !#en Create cylinder vertex data + !#zh 创建圆柱体顶点数据 + @param radiusTop radiusTop + @param radiusBottom radiusBottom + @param height height + @param opts opts + */ + export function cylinder(radiusTop: number, radiusBottom: number, height: number, opts: {radialSegments: number; heightSegments: number; capped: boolean; arc: number; }): cc.VertexData; + /** + !#en Create plane vertex data + !#zh 创建平台顶点数据 + @param width width + @param length length + @param opts opts + */ + export function plane(width: number, length: number, opts: {widthSegments: number; lengthSegments: number; }): cc.VertexData; + /** + !#en Create quad vertex data + !#zh 创建面片顶点数据 + */ + export function quad(): cc.VertexData; + /** + !#en Create sphere vertex data + !#zh 创建球体顶点数据 + @param radius radius + @param opts opts + */ + export function sphere(radius: number, opts: {segments: number; }): cc.VertexData; + /** + !#en Create torus vertex data + !#zh 创建圆环顶点数据 + @param radius radius + @param tube tube + @param opts opts + */ + export function torus(radius: number, tube: number, opts: {radialSegments: number; tubularSegments: number; arc: number; }): cc.VertexData; + /** + !#en Create capsule vertex data + !#zh 创建胶囊体顶点数据 + @param radiusTop radiusTop + @param radiusBottom radiusBottom + @param height height + @param opts opts + */ + export function capsule(radiusTop: number, radiusBottom: number, height: number, opts: {sides: number; heightSegments: number; capped: boolean; arc: number; }): cc.VertexData; + /** + !#en Create polyhedron vertex data + !#zh 创建多面体顶点数据 + @param type type + @param Size Size + @param opts opts + */ + export function polyhedron(type: cc.primitive.PolyhedronType, Size: number, opts: {sizeX: number; sizeY: number; sizeZ: number; }): cc.VertexData; +} + +declare let CC_JSB: boolean +declare let CC_NATIVERENDERER: boolean +declare let CC_EDITOR: boolean +declare let CC_PREVIEW: boolean +declare let CC_TEST: boolean +declare let CC_DEBUG: boolean + +declare let cc: { + // polyfills: { + // destroyObject? (object: any): void; + // }; + [x: string]: any; +} + +declare let Editor: any; + +// https://medium.com/dailyjs/typescript-create-a-condition-based-subset-types-9d902cea5b8c +type FlagExcludedType = { [Key in keyof Base]: Base[Key] extends Type ? never : Key }; +type AllowedNames = FlagExcludedType[keyof Base]; +type KeyPartial = { [P in K]?: T[P] }; +type OmitType = KeyPartial>; +type ConstructorType = OmitType; + +declare interface IWritableArrayLike { + readonly length: number; + [index: number]: T; +} + +declare let module: { + exports: object +} + + +declare interface Math { + sign(v: number); +} + +declare interface Object { + assign(target: {}, source: {}); +} + + +type FloatArray = Float64Array | Float32Array; + +interface IColorLike { + r: number; + g: number; + b: number; + a: number; + _val: number; + +} + +interface IMat3Like { + m: FloatArray +} + +interface IMat4Like { + m: FloatArray +} + +interface IQuatLike { + x: number; + y: number; + z: number; + w: number; +} + +interface IRectLike { + x: number; + y: number; + width: number; + height: number; +} + +interface ISizeLike { + width: number; + height: number; +} + +interface IVec2Like { + x: number; + y: number; +} + +interface IVec3Like { + x: number; + y: number; + z: number; +} + +interface IVec4Like { + x: number; + y: number; + z: number; + w: number; +} +declare namespace dragonBones { + /** + * @internal + * @private + */ + const webAssemblyModule: { + HEAP16: Int16Array; + _malloc(byteSize: number): number; + _free(pointer: number): void; + setDataBinary(data: DragonBonesData, binaryPointer: number, intBytesLength: number, floatBytesLength: number, frameIntBytesLength: number, frameFloatBytesLength: number, frameBytesLength: number, timelineBytesLength: number): void; + }; +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + const enum BinaryOffset { + WeigthBoneCount = 0, + WeigthFloatOffset = 1, + WeigthBoneIndices = 2, + MeshVertexCount = 0, + MeshTriangleCount = 1, + MeshFloatOffset = 2, + MeshWeightOffset = 3, + MeshVertexIndices = 4, + TimelineScale = 0, + TimelineOffset = 1, + TimelineKeyFrameCount = 2, + TimelineFrameValueCount = 3, + TimelineFrameValueOffset = 4, + TimelineFrameOffset = 5, + FramePosition = 0, + FrameTweenType = 1, + FrameTweenEasingOrCurveSampleCount = 2, + FrameCurveSamples = 3, + DeformMeshOffset = 0, + DeformCount = 1, + DeformValueCount = 2, + DeformValueOffset = 3, + DeformFloatOffset = 4, + } + /** + * @internal + * @private + */ + const enum ArmatureType { + Armature = 0, + MovieClip = 1, + Stage = 2, + } + /** + * @internal + * @private + */ + const enum BoneType { + Bone = 0, + Surface = 1, + } + /** + * @private + */ + const enum DisplayType { + Image = 0, + Armature = 1, + Mesh = 2, + BoundingBox = 3, + } + /** + * - Bounding box type. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 边界框类型。 + * @version DragonBones 5.0 + * @language zh_CN + */ + const enum BoundingBoxType { + Rectangle = 0, + Ellipse = 1, + Polygon = 2, + } + /** + * @internal + * @private + */ + const enum ActionType { + Play = 0, + Frame = 10, + Sound = 11, + } + /** + * @internal + * @private + */ + const enum BlendMode { + Normal = 0, + Add = 1, + Alpha = 2, + Darken = 3, + Difference = 4, + Erase = 5, + HardLight = 6, + Invert = 7, + Layer = 8, + Lighten = 9, + Multiply = 10, + Overlay = 11, + Screen = 12, + Subtract = 13, + } + /** + * @internal + * @private + */ + const enum TweenType { + None = 0, + Line = 1, + Curve = 2, + QuadIn = 3, + QuadOut = 4, + QuadInOut = 5, + } + /** + * @internal + * @private + */ + const enum TimelineType { + Action = 0, + ZOrder = 1, + BoneAll = 10, + BoneTranslate = 11, + BoneRotate = 12, + BoneScale = 13, + Surface = 50, + SlotDisplay = 20, + SlotColor = 21, + SlotFFD = 22, + IKConstraint = 30, + AnimationTime = 40, + AnimationWeight = 41, + } + /** + * - Offset mode. + * @version DragonBones 5.5 + * @language en_US + */ + /** + * - 偏移模式。 + * @version DragonBones 5.5 + * @language zh_CN + */ + const enum OffsetMode { + None = 0, + Additive = 1, + Override = 2, + } + /** + * - Animation fade out mode. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画淡出模式。 + * @version DragonBones 4.5 + * @language zh_CN + */ + const enum AnimationFadeOutMode { + /** + * - Do not fade out of any animation states. + * @language en_US + */ + /** + * - 不淡出任何的动画状态。 + * @language zh_CN + */ + None = 0, + /** + * - Fade out the animation states of the same layer. + * @language en_US + */ + /** + * - 淡出同层的动画状态。 + * @language zh_CN + */ + SameLayer = 1, + /** + * - Fade out the animation states of the same group. + * @language en_US + */ + /** + * - 淡出同组的动画状态。 + * @language zh_CN + */ + SameGroup = 2, + /** + * - Fade out the animation states of the same layer and group. + * @language en_US + */ + /** + * - 淡出同层并且同组的动画状态。 + * @language zh_CN + */ + SameLayerAndGroup = 3, + /** + * - Fade out of all animation states. + * @language en_US + */ + /** + * - 淡出所有的动画状态。 + * @language zh_CN + */ + All = 4, + /** + * - Does not replace the animation state with the same name. + * @language en_US + */ + /** + * - 不替换同名的动画状态。 + * @language zh_CN + */ + Single = 5, + } + /** + * @private + */ + interface Map { + [key: string]: T; + } + /** + * @private + */ + class DragonBones { + static readonly VERSION: string; + static yDown: boolean; + static debug: boolean; + static debugDraw: boolean; + static webAssembly: boolean; + private readonly _clock; + private readonly _events; + private readonly _objects; + private _eventManager; + constructor(eventManager: IEventDispatcher); + advanceTime(passedTime: number): void; + bufferEvent(value: EventObject): void; + bufferObject(object: BaseObject): void; + readonly clock: WorldClock; + readonly eventManager: IEventDispatcher; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The BaseObject is the base class for all objects in the DragonBones framework. + * All BaseObject instances are cached to the object pool to reduce the performance consumption of frequent requests for memory or memory recovery. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 基础对象,通常 DragonBones 的对象都继承自该类。 + * 所有基础对象的实例都会缓存到对象池,以减少频繁申请内存或内存回收的性能消耗。 + * @version DragonBones 4.5 + * @language zh_CN + */ + abstract class BaseObject { + private static _hashCode; + private static _defaultMaxCount; + private static readonly _maxCountMap; + private static readonly _poolsMap; + private static _returnObject(object); + static toString(): string; + /** + * - Set the maximum cache count of the specify object pool. + * @param objectConstructor - The specify class. (Set all object pools max cache count if not set) + * @param maxCount - Max count. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 设置特定对象池的最大缓存数量。 + * @param objectConstructor - 特定的类。 (不设置则设置所有对象池的最大缓存数量) + * @param maxCount - 最大缓存数量。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static setMaxCount(objectConstructor: (typeof BaseObject) | null, maxCount: number): void; + /** + * - Clear the cached instances of a specify object pool. + * @param objectConstructor - Specify class. (Clear all cached instances if not set) + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 清除特定对象池的缓存实例。 + * @param objectConstructor - 特定的类。 (不设置则清除所有缓存的实例) + * @version DragonBones 4.5 + * @language zh_CN + */ + static clearPool(objectConstructor?: (typeof BaseObject) | null): void; + /** + * - Get an instance of the specify class from object pool. + * @param objectConstructor - The specify class. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 从对象池中获取特定类的实例。 + * @param objectConstructor - 特定的类。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static borrowObject(objectConstructor: { + new (): T; + }): T; + /** + * - A unique identification number assigned to the object. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 分配给此实例的唯一标识号。 + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly hashCode: number; + private _isInPool; + /** + * @private + */ + protected abstract _onClear(): void; + /** + * - Clear the object and return it back to object pool。 + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 清除该实例的所有数据并将其返还对象池。 + * @version DragonBones 4.5 + * @language zh_CN + */ + returnToPool(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - 2D Transform matrix. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 2D 转换矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class Matrix { + /** + * - The value that affects the positioning of pixels along the x axis when scaling or rotating an image. + * @default 1.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 缩放或旋转图像时影响像素沿 x 轴定位的值。 + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + a: number; + /** + * - The value that affects the positioning of pixels along the y axis when rotating or skewing an image. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 旋转或倾斜图像时影响像素沿 y 轴定位的值。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + b: number; + /** + * - The value that affects the positioning of pixels along the x axis when rotating or skewing an image. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 旋转或倾斜图像时影响像素沿 x 轴定位的值。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + c: number; + /** + * - The value that affects the positioning of pixels along the y axis when scaling or rotating an image. + * @default 1.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 缩放或旋转图像时影响像素沿 y 轴定位的值。 + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + d: number; + /** + * - The distance by which to translate each point along the x axis. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 沿 x 轴平移每个点的距离。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + tx: number; + /** + * - The distance by which to translate each point along the y axis. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 沿 y 轴平移每个点的距离。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + ty: number; + /** + * @private + */ + constructor(a?: number, b?: number, c?: number, d?: number, tx?: number, ty?: number); + toString(): string; + /** + * @private + */ + copyFrom(value: Matrix): Matrix; + /** + * @private + */ + copyFromArray(value: Array, offset?: number): Matrix; + /** + * - Convert to unit matrix. + * The resulting matrix has the following properties: a=1, b=0, c=0, d=1, tx=0, ty=0. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 转换为单位矩阵。 + * 该矩阵具有以下属性:a=1、b=0、c=0、d=1、tx=0、ty=0。 + * @version DragonBones 3.0 + * @language zh_CN + */ + identity(): Matrix; + /** + * - Multiplies the current matrix with another matrix. + * @param value - The matrix that needs to be multiplied. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 将当前矩阵与另一个矩阵相乘。 + * @param value - 需要相乘的矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + concat(value: Matrix): Matrix; + /** + * - Convert to inverse matrix. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 转换为逆矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + invert(): Matrix; + /** + * - Apply a matrix transformation to a specific point. + * @param x - X coordinate. + * @param y - Y coordinate. + * @param result - The point after the transformation is applied. + * @param delta - Whether to ignore tx, ty's conversion to point. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 将矩阵转换应用于特定点。 + * @param x - 横坐标。 + * @param y - 纵坐标。 + * @param result - 应用转换之后的点。 + * @param delta - 是否忽略 tx,ty 对点的转换。 + * @version DragonBones 3.0 + * @language zh_CN + */ + transformPoint(x: number, y: number, result: { + x: number; + y: number; + }, delta?: boolean): void; + /** + * @private + */ + transformRectangle(rectangle: { + x: number; + y: number; + width: number; + height: number; + }, delta?: boolean): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - 2D Transform. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 2D 变换。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class Transform { + /** + * @private + */ + static readonly PI: number; + /** + * @private + */ + static readonly PI_D: number; + /** + * @private + */ + static readonly PI_H: number; + /** + * @private + */ + static readonly PI_Q: number; + /** + * @private + */ + static readonly RAD_DEG: number; + /** + * @private + */ + static readonly DEG_RAD: number; + /** + * @private + */ + static normalizeRadian(value: number): number; + /** + * - Horizontal translate. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 水平位移。 + * @version DragonBones 3.0 + * @language zh_CN + */ + x: number; + /** + * - Vertical translate. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 垂直位移。 + * @version DragonBones 3.0 + * @language zh_CN + */ + y: number; + /** + * - Skew. (In radians) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 倾斜。 (以弧度为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + skew: number; + /** + * - rotation. (In radians) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 旋转。 (以弧度为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + rotation: number; + /** + * - Horizontal Scaling. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 水平缩放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + scaleX: number; + /** + * - Vertical scaling. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 垂直缩放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + scaleY: number; + /** + * @private + */ + constructor(x?: number, y?: number, skew?: number, rotation?: number, scaleX?: number, scaleY?: number); + toString(): string; + /** + * @private + */ + copyFrom(value: Transform): Transform; + /** + * @private + */ + identity(): Transform; + /** + * @private + */ + add(value: Transform): Transform; + /** + * @private + */ + minus(value: Transform): Transform; + /** + * @private + */ + fromMatrix(matrix: Matrix): Transform; + /** + * @private + */ + toMatrix(matrix: Matrix): Transform; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + class ColorTransform { + alphaMultiplier: number; + redMultiplier: number; + greenMultiplier: number; + blueMultiplier: number; + alphaOffset: number; + redOffset: number; + greenOffset: number; + blueOffset: number; + constructor(alphaMultiplier?: number, redMultiplier?: number, greenMultiplier?: number, blueMultiplier?: number, alphaOffset?: number, redOffset?: number, greenOffset?: number, blueOffset?: number); + copyFrom(value: ColorTransform): void; + identity(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The Point object represents a location in a two-dimensional coordinate system. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - Point 对象表示二维坐标系统中的某个位置。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class Point { + /** + * - The horizontal coordinate. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 该点的水平坐标。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + x: number; + /** + * - The vertical coordinate. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 该点的垂直坐标。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + y: number; + /** + * - Creates a new point. If you pass no parameters to this method, a point is created at (0,0). + * @param x - The horizontal coordinate. + * @param y - The vertical coordinate. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 创建一个 egret.Point 对象.若不传入任何参数,将会创建一个位于(0,0)位置的点。 + * @param x - 该对象的x属性值,默认为 0.0。 + * @param y - 该对象的y属性值,默认为 0.0。 + * @version DragonBones 3.0 + * @language zh_CN + */ + constructor(x?: number, y?: number); + /** + * @private + */ + copyFrom(value: Point): void; + /** + * @private + */ + clear(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - A Rectangle object is an area defined by its position, as indicated by its top-left corner point (x, y) and by its + * width and its height.
+ * The x, y, width, and height properties of the Rectangle class are independent of each other; changing the value of + * one property has no effect on the others. However, the right and bottom properties are integrally related to those + * four properties. For example, if you change the value of the right property, the value of the width property changes; + * if you change the bottom property, the value of the height property changes. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - Rectangle 对象是按其位置(由它左上角的点 (x, y) 确定)以及宽度和高度定义的区域。
+ * Rectangle 类的 x、y、width 和 height 属性相互独立;更改一个属性的值不会影响其他属性。 + * 但是,right 和 bottom 属性与这四个属性是整体相关的。例如,如果更改 right 属性的值,则 width + * 属性的值将发生变化;如果更改 bottom 属性,则 height 属性的值将发生变化。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class Rectangle { + /** + * - The x coordinate of the top-left corner of the rectangle. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 矩形左上角的 x 坐标。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + x: number; + /** + * - The y coordinate of the top-left corner of the rectangle. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 矩形左上角的 y 坐标。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + y: number; + /** + * - The width of the rectangle, in pixels. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 矩形的宽度(以像素为单位)。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + width: number; + /** + * - 矩形的高度(以像素为单位)。 + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - The height of the rectangle, in pixels. + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + height: number; + /** + * @private + */ + constructor(x?: number, y?: number, width?: number, height?: number); + /** + * @private + */ + copyFrom(value: Rectangle): void; + /** + * @private + */ + clear(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The user custom data. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 用户自定义数据。 + * @version DragonBones 5.0 + * @language zh_CN + */ + class UserData extends BaseObject { + static toString(): string; + /** + * - The custom int numbers. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 自定义整数。 + * @version DragonBones 5.0 + * @language zh_CN + */ + readonly ints: Array; + /** + * - The custom float numbers. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 自定义浮点数。 + * @version DragonBones 5.0 + * @language zh_CN + */ + readonly floats: Array; + /** + * - The custom strings. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 自定义字符串。 + * @version DragonBones 5.0 + * @language zh_CN + */ + readonly strings: Array; + /** + * @inheritDoc + */ + protected _onClear(): void; + /** + * @internal + * @private + */ + addInt(value: number): void; + /** + * @internal + * @private + */ + addFloat(value: number): void; + /** + * @internal + * @private + */ + addString(value: string): void; + /** + * - Get the custom int number. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 获取自定义整数。 + * @version DragonBones 5.0 + * @language zh_CN + */ + getInt(index?: number): number; + /** + * - Get the custom float number. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 获取自定义浮点数。 + * @version DragonBones 5.0 + * @language zh_CN + */ + getFloat(index?: number): number; + /** + * - Get the custom string. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 获取自定义字符串。 + * @version DragonBones 5.0 + * @language zh_CN + */ + getString(index?: number): string; + } + /** + * @internal + * @private + */ + class ActionData extends BaseObject { + static toString(): string; + type: ActionType; + name: string; + bone: BoneData | null; + slot: SlotData | null; + data: UserData | null; + protected _onClear(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The DragonBones data. + * A DragonBones data contains multiple armature data. + * @see dragonBones.ArmatureData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 龙骨数据。 + * 一个龙骨数据包含多个骨架数据。 + * @see dragonBones.ArmatureData + * @version DragonBones 3.0 + * @language zh_CN + */ + class DragonBonesData extends BaseObject { + static toString(): string; + /** + * @private + */ + autoSearch: boolean; + /** + * - The animation frame rate. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画帧频。 + * @version DragonBones 3.0 + * @language zh_CN + */ + frameRate: number; + /** + * - The data version. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 数据版本。 + * @version DragonBones 3.0 + * @language zh_CN + */ + version: string; + /** + * - The DragonBones data name. + * The name is consistent with the DragonBones project name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 龙骨数据名称。 + * 该名称与龙骨项目名保持一致。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + stage: ArmatureData | null; + /** + * @internal + * @private + */ + readonly frameIndices: Array; + /** + * @internal + * @private + */ + readonly cachedFrames: Array; + /** + * - All armature data names. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 所有的骨架数据名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly armatureNames: Array; + /** + * @private + */ + readonly armatures: Map; + /** + * @internal + * @private + */ + binary: ArrayBuffer; + /** + * @internal + * @private + */ + intArray: Int16Array; + /** + * @internal + * @private + */ + floatArray: Float32Array; + /** + * @internal + * @private + */ + frameIntArray: Int16Array; + /** + * @internal + * @private + */ + frameFloatArray: Float32Array; + /** + * @internal + * @private + */ + frameArray: Int16Array; + /** + * @internal + * @private + */ + timelineArray: Uint16Array; + /** + * @private + */ + userData: UserData | null; + /** + * @inheritDoc + */ + protected _onClear(): void; + /** + * @internal + * @private + */ + addArmature(value: ArmatureData): void; + /** + * - Get a specific armature data. + * @param name - The armature data name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的骨架数据。 + * @param name - 骨架数据名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + getArmature(name: string): ArmatureData | null; + /** + * - Deprecated, please refer to {@link #dragonBones.BaseFactory#removeDragonBonesData()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #dragonBones.BaseFactory#removeDragonBonesData()}。 + * @deprecated + * @language zh_CN + */ + dispose(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The armature data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨架数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class ArmatureData extends BaseObject { + static toString(): string; + /** + * @private + */ + type: ArmatureType; + /** + * - The animation frame rate. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画帧率。 + * @version DragonBones 3.0 + * @language zh_CN + */ + frameRate: number; + /** + * @private + */ + cacheFrameRate: number; + /** + * @private + */ + scale: number; + /** + * - The armature name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨架名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + readonly aabb: Rectangle; + /** + * - The names of all the animation data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 所有的动画数据名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly animationNames: Array; + /** + * @private + */ + readonly sortedBones: Array; + /** + * @private + */ + readonly sortedSlots: Array; + /** + * @private + */ + readonly defaultActions: Array; + /** + * @private + */ + readonly actions: Array; + /** + * @private + */ + readonly bones: Map; + /** + * @private + */ + readonly slots: Map; + /** + * @private + */ + readonly constraints: Map; + /** + * @private + */ + readonly skins: Map; + /** + * @private + */ + readonly animations: Map; + /** + * - The default skin data. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 默认插槽数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + defaultSkin: SkinData | null; + /** + * - The default animation data. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 默认动画数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + defaultAnimation: AnimationData | null; + /** + * @private + */ + canvas: CanvasData | null; + /** + * @private + */ + userData: UserData | null; + /** + * @private + */ + parent: DragonBonesData; + /** + * @inheritDoc + */ + protected _onClear(): void; + /** + * @internal + * @private + */ + sortBones(): void; + /** + * @internal + * @private + */ + cacheFrames(frameRate: number): void; + /** + * @internal + * @private + */ + setCacheFrame(globalTransformMatrix: Matrix, transform: Transform): number; + /** + * @internal + * @private + */ + getCacheFrame(globalTransformMatrix: Matrix, transform: Transform, arrayOffset: number): void; + /** + * @internal + * @private + */ + addBone(value: BoneData): void; + /** + * @internal + * @private + */ + addSlot(value: SlotData): void; + /** + * @internal + * @private + */ + addConstraint(value: ConstraintData): void; + /** + * @internal + * @private + */ + addSkin(value: SkinData): void; + /** + * @internal + * @private + */ + addAnimation(value: AnimationData): void; + /** + * @internal + * @private + */ + addAction(value: ActionData, isDefault: boolean): void; + /** + * - Get a specific done data. + * @param name - The bone name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的骨骼数据。 + * @param name - 骨骼名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + getBone(name: string): BoneData | null; + /** + * - Get a specific slot data. + * @param name - The slot name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的插槽数据。 + * @param name - 插槽名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + getSlot(name: string): SlotData | null; + /** + * @private + */ + getConstraint(name: string): ConstraintData | null; + /** + * - Get a specific skin data. + * @param name - The skin name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定皮肤数据。 + * @param name - 皮肤名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + getSkin(name: string): SkinData | null; + /** + * @internal + * @private + */ + getMesh(skinName: string, slotName: string, meshName: string): MeshDisplayData | null; + /** + * - Get a specific animation data. + * @param name - The animation name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的动画数据。 + * @param name - 动画名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + getAnimation(name: string): AnimationData | null; + } + /** + * - The bone data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨骼数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class BoneData extends BaseObject { + static toString(): string; + /** + * @private + */ + inheritTranslation: boolean; + /** + * @private + */ + inheritRotation: boolean; + /** + * @private + */ + inheritScale: boolean; + /** + * @private + */ + inheritReflection: boolean; + /** + * @private + */ + type: BoneType; + /** + * - The bone length. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨骼长度。 + * @version DragonBones 3.0 + * @language zh_CN + */ + length: number; + /** + * - The bone name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨骼名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + readonly transform: Transform; + /** + * @private + */ + userData: UserData | null; + /** + * - The parent bone data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 父骨骼数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + parent: BoneData | null; + /** + * @inheritDoc + */ + protected _onClear(): void; + } + /** + * @internal + * @private + */ + class SurfaceData extends BoneData { + static toString(): string; + segmentX: number; + segmentY: number; + readonly vertices: Array; + /** + * @inheritDoc + */ + protected _onClear(): void; + } + /** + * - The slot data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 插槽数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class SlotData extends BaseObject { + /** + * @internal + * @private + */ + static readonly DEFAULT_COLOR: ColorTransform; + /** + * @internal + * @private + */ + static createColor(): ColorTransform; + static toString(): string; + /** + * @private + */ + blendMode: BlendMode; + /** + * @private + */ + displayIndex: number; + /** + * @private + */ + zOrder: number; + /** + * - The slot name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 插槽名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + color: ColorTransform; + /** + * @private + */ + userData: UserData | null; + /** + * - The parent bone data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 父骨骼数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + parent: BoneData; + /** + * @inheritDoc + */ + protected _onClear(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + abstract class ConstraintData extends BaseObject { + order: number; + name: string; + target: BoneData; + root: BoneData; + bone: BoneData | null; + protected _onClear(): void; + } + /** + * @internal + * @private + */ + class IKConstraintData extends ConstraintData { + static toString(): string; + scaleEnabled: boolean; + bendPositive: boolean; + weight: number; + protected _onClear(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + class CanvasData extends BaseObject { + static toString(): string; + hasBackground: boolean; + color: number; + x: number; + y: number; + width: number; + height: number; + protected _onClear(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The skin data, typically a armature data instance contains at least one skinData. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 皮肤数据,通常一个骨架数据至少包含一个皮肤数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class SkinData extends BaseObject { + static toString(): string; + /** + * - The skin name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 皮肤名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + readonly displays: Map>; + /** + * @private + */ + parent: ArmatureData; + /** + * @inheritDoc + */ + protected _onClear(): void; + /** + * @internal + * @private + */ + addDisplay(slotName: string, value: DisplayData | null): void; + /** + * @private + */ + getDisplay(slotName: string, displayName: string): DisplayData | null; + /** + * @private + */ + getDisplays(slotName: string): Array | null; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + abstract class DisplayData extends BaseObject { + type: DisplayType; + name: string; + path: string; + parent: SkinData; + readonly transform: Transform; + protected _onClear(): void; + } + /** + * @internal + * @private + */ + class ImageDisplayData extends DisplayData { + static toString(): string; + readonly pivot: Point; + texture: TextureData | null; + protected _onClear(): void; + } + /** + * @internal + * @private + */ + class ArmatureDisplayData extends DisplayData { + static toString(): string; + inheritAnimation: boolean; + readonly actions: Array; + armature: ArmatureData | null; + protected _onClear(): void; + /** + * @private + */ + addAction(value: ActionData): void; + } + /** + * @internal + * @private + */ + class MeshDisplayData extends DisplayData { + static toString(): string; + inheritDeform: boolean; + offset: number; + weight: WeightData | null; + glue: GlueData | null; + texture: TextureData | null; + protected _onClear(): void; + } + /** + * @internal + * @private + */ + class BoundingBoxDisplayData extends DisplayData { + static toString(): string; + boundingBox: BoundingBoxData | null; + protected _onClear(): void; + } + /** + * @internal + * @private + */ + class WeightData extends BaseObject { + static toString(): string; + count: number; + offset: number; + readonly bones: Array; + protected _onClear(): void; + addBone(value: BoneData): void; + } + /** + * @internal + * @private + */ + class GlueData extends BaseObject { + static toString(): string; + readonly weights: Array; + readonly meshes: Array; + protected _onClear(): void; + addMesh(value: MeshDisplayData | null): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The base class of bounding box data. + * @see dragonBones.RectangleData + * @see dragonBones.EllipseData + * @see dragonBones.PolygonData + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 边界框数据基类。 + * @see dragonBones.RectangleData + * @see dragonBones.EllipseData + * @see dragonBones.PolygonData + * @version DragonBones 5.0 + * @language zh_CN + */ + abstract class BoundingBoxData extends BaseObject { + /** + * - The bounding box type. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 边界框类型。 + * @version DragonBones 5.0 + * @language zh_CN + */ + type: BoundingBoxType; + /** + * @private + */ + color: number; + /** + * @private + */ + width: number; + /** + * @private + */ + height: number; + /** + * @private + */ + protected _onClear(): void; + /** + * - Check whether the bounding box contains a specific point. (Local coordinate system) + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 检查边界框是否包含特定点。(本地坐标系) + * @version DragonBones 5.0 + * @language zh_CN + */ + abstract containsPoint(pX: number, pY: number): boolean; + /** + * - Check whether the bounding box intersects a specific segment. (Local coordinate system) + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 检查边界框是否与特定线段相交。(本地坐标系) + * @version DragonBones 5.0 + * @language zh_CN + */ + abstract intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA: { + x: number; + y: number; + } | null, intersectionPointB: { + x: number; + y: number; + } | null, normalRadians: { + x: number; + y: number; + } | null): number; + } + /** + * - The rectangle bounding box data. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 矩形边界框数据。 + * @version DragonBones 5.1 + * @language zh_CN + */ + class RectangleBoundingBoxData extends BoundingBoxData { + static toString(): string; + /** + * - Compute the bit code for a point (x, y) using the clip rectangle + */ + private static _computeOutCode(x, y, xMin, yMin, xMax, yMax); + /** + * @private + */ + static rectangleIntersectsSegment(xA: number, yA: number, xB: number, yB: number, xMin: number, yMin: number, xMax: number, yMax: number, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): number; + /** + * @inheritDoc + * @private + */ + protected _onClear(): void; + /** + * @inheritDoc + */ + containsPoint(pX: number, pY: number): boolean; + /** + * @inheritDoc + */ + intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): number; + } + /** + * - The ellipse bounding box data. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 椭圆边界框数据。 + * @version DragonBones 5.1 + * @language zh_CN + */ + class EllipseBoundingBoxData extends BoundingBoxData { + static toString(): string; + /** + * @private + */ + static ellipseIntersectsSegment(xA: number, yA: number, xB: number, yB: number, xC: number, yC: number, widthH: number, heightH: number, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): number; + /** + * @inheritDoc + * @private + */ + protected _onClear(): void; + /** + * @inheritDoc + */ + containsPoint(pX: number, pY: number): boolean; + /** + * @inheritDoc + */ + intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): number; + } + /** + * - The polygon bounding box data. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 多边形边界框数据。 + * @version DragonBones 5.1 + * @language zh_CN + */ + class PolygonBoundingBoxData extends BoundingBoxData { + static toString(): string; + /** + * @private + */ + static polygonIntersectsSegment(xA: number, yA: number, xB: number, yB: number, vertices: Array, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): number; + /** + * @private + */ + x: number; + /** + * @private + */ + y: number; + /** + * - The polygon vertices. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 多边形顶点。 + * @version DragonBones 5.1 + * @language zh_CN + */ + readonly vertices: Array; + /** + * @private + */ + weight: WeightData | null; + /** + * @inheritDoc + * @private + */ + protected _onClear(): void; + /** + * @inheritDoc + */ + containsPoint(pX: number, pY: number): boolean; + /** + * @inheritDoc + */ + intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): number; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The animation data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class AnimationData extends BaseObject { + static toString(): string; + /** + * - FrameIntArray. + * @internal + * @private + */ + frameIntOffset: number; + /** + * - FrameFloatArray. + * @internal + * @private + */ + frameFloatOffset: number; + /** + * - FrameArray. + * @internal + * @private + */ + frameOffset: number; + /** + * - The frame count of the animation. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画的帧数。 + * @version DragonBones 3.0 + * @language zh_CN + */ + frameCount: number; + /** + * - The play times of the animation. [0: Loop play, [1~N]: Play N times] + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画的播放次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次] + * @version DragonBones 3.0 + * @language zh_CN + */ + playTimes: number; + /** + * - The duration of the animation. (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画的持续时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + duration: number; + /** + * @private + */ + scale: number; + /** + * - The fade in time of the animation. (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画的淡入时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + fadeInTime: number; + /** + * @private + */ + cacheFrameRate: number; + /** + * - The animation name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + readonly cachedFrames: Array; + /** + * @private + */ + readonly boneTimelines: Map>; + /** + * @private + */ + readonly surfaceTimelines: Map>; + /** + * @private + */ + readonly slotTimelines: Map>; + /** + * @private + */ + readonly constraintTimelines: Map>; + /** + * @private + */ + readonly animationTimelines: Map>; + /** + * @private + */ + readonly boneCachedFrameIndices: Map>; + /** + * @private + */ + readonly slotCachedFrameIndices: Map>; + /** + * @private + */ + actionTimeline: TimelineData | null; + /** + * @private + */ + zOrderTimeline: TimelineData | null; + /** + * @private + */ + parent: ArmatureData; + /** + * @inheritDoc + */ + protected _onClear(): void; + /** + * @internal + * @private + */ + cacheFrames(frameRate: number): void; + /** + * @private + */ + addBoneTimeline(bone: BoneData, timeline: TimelineData): void; + /** + * @private + */ + addSurfaceTimeline(surface: SurfaceData, timeline: TimelineData): void; + /** + * @private + */ + addSlotTimeline(slot: SlotData, timeline: TimelineData): void; + /** + * @private + */ + addConstraintTimeline(constraint: ConstraintData, timeline: TimelineData): void; + /** + * @private + */ + addAnimationTimeline(name: string, timeline: TimelineData): void; + /** + * @private + */ + getBoneTimelines(name: string): Array | null; + /** + * @private + */ + getSurfaceTimelines(name: string): Array | null; + /** + * @private + */ + getSlotTimelines(name: string): Array | null; + /** + * @private + */ + getConstraintTimelines(name: string): Array | null; + /** + * @private + */ + getAnimationTimelines(name: string): Array | null; + /** + * @private + */ + getBoneCachedFrameIndices(name: string): Array | null; + /** + * @private + */ + getSlotCachedFrameIndices(name: string): Array | null; + } + /** + * @internal + * @private + */ + class TimelineData extends BaseObject { + static toString(): string; + type: TimelineType; + offset: number; + frameIndicesOffset: number; + protected _onClear(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The animation config is used to describe all the information needed to play an animation state. + * The API is still in the experimental phase and may encounter bugs or stability or compatibility issues when used. + * @see dragonBones.AnimationState + * @beta + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画配置用来描述播放一个动画状态所需要的全部信息。 + * 该 API 仍在实验阶段,使用时可能遭遇 bug 或稳定性或兼容性问题。 + * @see dragonBones.AnimationState + * @beta + * @version DragonBones 5.0 + * @language zh_CN + */ + class AnimationConfig extends BaseObject { + static toString(): string; + /** + * @private + */ + pauseFadeOut: boolean; + /** + * - Fade out the pattern of other animation states when the animation state is fade in. + * This property is typically used to specify the substitution of multiple animation states blend. + * @default dragonBones.AnimationFadeOutMode.All + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 淡入动画状态时淡出其他动画状态的模式。 + * 该属性通常用来指定多个动画状态混合时的相互替换关系。 + * @default dragonBones.AnimationFadeOutMode.All + * @version DragonBones 5.0 + * @language zh_CN + */ + fadeOutMode: AnimationFadeOutMode; + /** + * @private + */ + fadeOutTweenType: TweenType; + /** + * @private + */ + fadeOutTime: number; + /** + * @private + */ + pauseFadeIn: boolean; + /** + * @private + */ + actionEnabled: boolean; + /** + * @private + */ + additiveBlending: boolean; + /** + * - Whether the animation state has control over the display property of the slots. + * Sometimes blend a animation state does not want it to control the display properties of the slots, + * especially if other animation state are controlling the display properties of the slots. + * @default true + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画状态是否对插槽的显示对象属性有控制权。 + * 有时混合一个动画状态并不希望其控制插槽的显示对象属性, + * 尤其是其他动画状态正在控制这些插槽的显示对象属性时。 + * @default true + * @version DragonBones 5.0 + * @language zh_CN + */ + displayControl: boolean; + /** + * - Whether to reset the objects without animation to the armature pose when the animation state is start to play. + * This property should usually be set to false when blend multiple animation states. + * @default true + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 开始播放动画状态时是否将没有动画的对象重置为骨架初始值。 + * 通常在混合多个动画状态时应该将该属性设置为 false。 + * @default true + * @version DragonBones 5.1 + * @language zh_CN + */ + resetToPose: boolean; + /** + * @private + */ + fadeInTweenType: TweenType; + /** + * - The play times. [0: Loop play, [1~N]: Play N times] + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 播放次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次] + * @version DragonBones 3.0 + * @language zh_CN + */ + playTimes: number; + /** + * - The blend layer. + * High layer animation state will get the blend weight first. + * When the blend weight is assigned more than 1, the remaining animation states will no longer get the weight assigned. + * @readonly + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 混合图层。 + * 图层高的动画状态会优先获取混合权重。 + * 当混合权重分配超过 1 时,剩余的动画状态将不再获得权重分配。 + * @readonly + * @version DragonBones 5.0 + * @language zh_CN + */ + layer: number; + /** + * - The start time of play. (In seconds) + * @default 0.0 + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 播放的开始时间。 (以秒为单位) + * @default 0.0 + * @version DragonBones 5.0 + * @language zh_CN + */ + position: number; + /** + * - The duration of play. + * [-1: Use the default value of the animation data, 0: Stop play, (0~N]: The duration] (In seconds) + * @default -1.0 + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 播放的持续时间。 + * [-1: 使用动画数据默认值, 0: 动画停止, (0~N]: 持续时间] (以秒为单位) + * @default -1.0 + * @version DragonBones 5.0 + * @language zh_CN + */ + duration: number; + /** + * - The play speed. + * The value is an overlay relationship with {@link dragonBones.Animation#timeScale}. + * [(-N~0): Reverse play, 0: Stop play, (0~1): Slow play, 1: Normal play, (1~N): Fast play] + * @default 1.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 播放速度。 + * 该值与 {@link dragonBones.Animation#timeScale} 是叠加关系。 + * [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + timeScale: number; + /** + * - The blend weight. + * @default 1.0 + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 混合权重。 + * @default 1.0 + * @version DragonBones 5.0 + * @language zh_CN + */ + weight: number; + /** + * - The fade in time. + * [-1: Use the default value of the animation data, [0~N]: The fade in time] (In seconds) + * @default -1.0 + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 淡入时间。 + * [-1: 使用动画数据默认值, [0~N]: 淡入时间] (以秒为单位) + * @default -1.0 + * @version DragonBones 5.0 + * @language zh_CN + */ + fadeInTime: number; + /** + * - The auto fade out time when the animation state play completed. + * [-1: Do not fade out automatically, [0~N]: The fade out time] (In seconds) + * @default -1.0 + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画状态播放完成后的自动淡出时间。 + * [-1: 不自动淡出, [0~N]: 淡出时间] (以秒为单位) + * @default -1.0 + * @version DragonBones 5.0 + * @language zh_CN + */ + autoFadeOutTime: number; + /** + * - The name of the animation state. (Can be different from the name of the animation data) + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画状态名称。 (可以不同于动画数据) + * @version DragonBones 5.0 + * @language zh_CN + */ + name: string; + /** + * - The animation data name. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画数据名称。 + * @version DragonBones 5.0 + * @language zh_CN + */ + animation: string; + /** + * - The blend group name of the animation state. + * This property is typically used to specify the substitution of multiple animation states blend. + * @readonly + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 混合组名称。 + * 该属性通常用来指定多个动画状态混合时的相互替换关系。 + * @readonly + * @version DragonBones 5.0 + * @language zh_CN + */ + group: string; + /** + * @private + */ + readonly boneMask: Array; + /** + * @private + */ + protected _onClear(): void; + /** + * @private + */ + clear(): void; + /** + * @private + */ + copyFrom(value: AnimationConfig): void; + /** + * @private + */ + containsBoneMask(name: string): boolean; + /** + * @private + */ + addBoneMask(armature: Armature, name: string, recursive?: boolean): void; + /** + * @private + */ + removeBoneMask(armature: Armature, name: string, recursive?: boolean): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The texture atlas data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 贴图集数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + abstract class TextureAtlasData extends BaseObject { + /** + * @private + */ + autoSearch: boolean; + /** + * @private + */ + width: number; + /** + * @private + */ + height: number; + /** + * @private + */ + scale: number; + /** + * - The texture atlas name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 贴图集名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * - The image path of the texture atlas. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 贴图集图片路径。 + * @version DragonBones 3.0 + * @language zh_CN + */ + imagePath: string; + /** + * @private + */ + readonly textures: Map; + /** + * @inheritDoc + */ + protected _onClear(): void; + /** + * @private + */ + copyFrom(value: TextureAtlasData): void; + /** + * @internal + * @private + */ + abstract createTexture(): TextureData; + /** + * @internal + * @private + */ + addTexture(value: TextureData): void; + /** + * @private + */ + getTexture(name: string): TextureData | null; + } + /** + * @internal + * @private + */ + abstract class TextureData extends BaseObject { + static createRectangle(): Rectangle; + rotated: boolean; + name: string; + readonly region: Rectangle; + parent: TextureAtlasData; + frame: Rectangle | null; + protected _onClear(): void; + copyFrom(value: TextureData): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The armature proxy interface, the docking engine needs to implement it concretely. + * @see dragonBones.Armature + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 骨架代理接口,对接的引擎需要对其进行具体实现。 + * @see dragonBones.Armature + * @version DragonBones 5.0 + * @language zh_CN + */ + interface IArmatureProxy extends IEventDispatcher { + /** + * @internal + * @private + */ + dbInit(armature: Armature): void; + /** + * @internal + * @private + */ + dbClear(): void; + /** + * @internal + * @private + */ + dbUpdate(): void; + /** + * - Dispose the instance and the Armature instance. (The Armature instance will return to the object pool) + * @example + *
+         *     removeChild(armatureDisplay);
+         *     armatureDisplay.dispose();
+         * 
+ * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 释放该实例和骨架。 (骨架会回收到对象池) + * @example + *
+         *     removeChild(armatureDisplay);
+         *     armatureDisplay.dispose();
+         * 
+ * @version DragonBones 4.5 + * @language zh_CN + */ + dispose(disposeProxy: boolean): void; + /** + * - The armature. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 骨架。 + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly armature: Armature; + /** + * - The animation player. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画播放器。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly animation: Animation; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - Armature is the core of the skeleton animation system. + * @see dragonBones.ArmatureData + * @see dragonBones.Bone + * @see dragonBones.Slot + * @see dragonBones.Animation + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨架是骨骼动画系统的核心。 + * @see dragonBones.ArmatureData + * @see dragonBones.Bone + * @see dragonBones.Slot + * @see dragonBones.Animation + * @version DragonBones 3.0 + * @language zh_CN + */ + class Armature extends BaseObject implements IAnimatable { + static toString(): string; + private static _onSortSlots(a, b); + /** + * - Whether to inherit the animation control of the parent armature. + * True to try to have the child armature play an animation with the same name when the parent armature play the animation. + * @default true + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 是否继承父骨架的动画控制。 + * 如果该值为 true,当父骨架播放动画时,会尝试让子骨架播放同名动画。 + * @default true + * @version DragonBones 4.5 + * @language zh_CN + */ + inheritAnimation: boolean; + /** + * @private + */ + userData: any; + private _lockUpdate; + private _bonesDirty; + private _slotsDirty; + private _zOrderDirty; + private _flipX; + private _flipY; + /** + * @internal + * @private + */ + _cacheFrameIndex: number; + private readonly _bones; + private readonly _slots; + /** + * @internal + * @private + */ + readonly _glueSlots: Array; + /** + * @internal + * @private + */ + readonly _constraints: Array; + private readonly _actions; + /** + * @internal + * @private + */ + _armatureData: ArmatureData; + private _animation; + private _proxy; + private _display; + /** + * @internal + * @private + */ + _replaceTextureAtlasData: TextureAtlasData | null; + private _replacedTexture; + /** + * @internal + * @private + */ + _dragonBones: DragonBones; + private _clock; + /** + * @internal + * @private + */ + _parent: Slot | null; + /** + * @private + */ + protected _onClear(): void; + private _sortBones(); + private _sortSlots(); + /** + * @internal + * @private + */ + _sortZOrder(slotIndices: Array | Int16Array | null, offset: number): void; + /** + * @internal + * @private + */ + _addBoneToBoneList(value: Bone): void; + /** + * @internal + * @private + */ + _removeBoneFromBoneList(value: Bone): void; + /** + * @internal + * @private + */ + _addSlotToSlotList(value: Slot): void; + /** + * @internal + * @private + */ + _removeSlotFromSlotList(value: Slot): void; + /** + * @internal + * @private + */ + _bufferAction(action: ActionData, append: boolean): void; + /** + * - Dispose the armature. (Return to the object pool) + * @example + *
+         *     removeChild(armature.display);
+         *     armature.dispose();
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 释放骨架。 (回收到对象池) + * @example + *
+         *     removeChild(armature.display);
+         *     armature.dispose();
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + dispose(): void; + /** + * @internal + * @private + */ + init(armatureData: ArmatureData, proxy: IArmatureProxy, display: any, dragonBones: DragonBones): void; + /** + * @inheritDoc + */ + advanceTime(passedTime: number): void; + /** + * - Forces a specific bone or its owning slot to update the transform or display property in the next frame. + * @param boneName - The bone name. (If not set, all bones will be update) + * @param updateSlot - Whether to update the bone's slots. (Default: false) + * @see dragonBones.Bone#invalidUpdate() + * @see dragonBones.Slot#invalidUpdate() + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 强制特定骨骼或其拥有的插槽在下一帧更新变换或显示属性。 + * @param boneName - 骨骼名称。 (如果未设置,将更新所有骨骼) + * @param updateSlot - 是否更新骨骼的插槽。 (默认: false) + * @see dragonBones.Bone#invalidUpdate() + * @see dragonBones.Slot#invalidUpdate() + * @version DragonBones 3.0 + * @language zh_CN + */ + invalidUpdate(boneName?: string | null, updateSlot?: boolean): void; + /** + * - Check whether a specific point is inside a custom bounding box in a slot. + * The coordinate system of the point is the inner coordinate system of the armature. + * Custom bounding boxes need to be customized in Dragonbones Pro. + * @param x - The horizontal coordinate of the point. + * @param y - The vertical coordinate of the point. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 检查特定点是否在某个插槽的自定义边界框内。 + * 点的坐标系为骨架内坐标系。 + * 自定义边界框需要在 DragonBones Pro 中自定义。 + * @param x - 点的水平坐标。 + * @param y - 点的垂直坐标。 + * @version DragonBones 5.0 + * @language zh_CN + */ + containsPoint(x: number, y: number): Slot | null; + /** + * - Check whether a specific segment intersects a custom bounding box for a slot in the armature. + * The coordinate system of the segment and intersection is the inner coordinate system of the armature. + * Custom bounding boxes need to be customized in Dragonbones Pro. + * @param xA - The horizontal coordinate of the beginning of the segment. + * @param yA - The vertical coordinate of the beginning of the segment. + * @param xB - The horizontal coordinate of the end point of the segment. + * @param yB - The vertical coordinate of the end point of the segment. + * @param intersectionPointA - The first intersection at which a line segment intersects the bounding box from the beginning to the end. (If not set, the intersection point will not calculated) + * @param intersectionPointB - The first intersection at which a line segment intersects the bounding box from the end to the beginning. (If not set, the intersection point will not calculated) + * @param normalRadians - The normal radians of the tangent of the intersection boundary box. [x: Normal radian of the first intersection tangent, y: Normal radian of the second intersection tangent] (If not set, the normal will not calculated) + * @returns The slot of the first custom bounding box where the segment intersects from the start point to the end point. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 检查特定线段是否与骨架的某个插槽的自定义边界框相交。 + * 线段和交点的坐标系均为骨架内坐标系。 + * 自定义边界框需要在 DragonBones Pro 中自定义。 + * @param xA - 线段起点的水平坐标。 + * @param yA - 线段起点的垂直坐标。 + * @param xB - 线段终点的水平坐标。 + * @param yB - 线段终点的垂直坐标。 + * @param intersectionPointA - 线段从起点到终点与边界框相交的第一个交点。 (如果未设置,则不计算交点) + * @param intersectionPointB - 线段从终点到起点与边界框相交的第一个交点。 (如果未设置,则不计算交点) + * @param normalRadians - 交点边界框切线的法线弧度。 [x: 第一个交点切线的法线弧度, y: 第二个交点切线的法线弧度] (如果未设置,则不计算法线) + * @returns 线段从起点到终点相交的第一个自定义边界框的插槽。 + * @version DragonBones 5.0 + * @language zh_CN + */ + intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): Slot | null; + /** + * - Get a specific bone. + * @param name - The bone name. + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的骨骼。 + * @param name - 骨骼名称。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + getBone(name: string): Bone | null; + /** + * - Get a specific bone by the display. + * @param display - The display object. + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 通过显示对象获取特定的骨骼。 + * @param display - 显示对象。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + getBoneByDisplay(display: any): Bone | null; + /** + * - Get a specific slot. + * @param name - The slot name. + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的插槽。 + * @param name - 插槽名称。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + getSlot(name: string): Slot | null; + /** + * - Get a specific slot by the display. + * @param display - The display object. + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 通过显示对象获取特定的插槽。 + * @param display - 显示对象。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + getSlotByDisplay(display: any): Slot | null; + /** + * @deprecated + */ + addBone(value: Bone, parentName: string): void; + /** + * @deprecated + */ + addSlot(value: Slot, parentName: string): void; + /** + * @private + */ + addConstraint(value: Constraint): void; + /** + * @deprecated + */ + removeBone(value: Bone): void; + /** + * @deprecated + */ + removeSlot(value: Slot): void; + /** + * - Get all bones. + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取所有的骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + getBones(): Array; + /** + * - Get all slots. + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取所有的插槽。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + getSlots(): Array; + /** + * - Whether to flip the armature horizontally. + * @version DragonBones 5.5 + * @language en_US + */ + /** + * - 是否将骨架水平翻转。 + * @version DragonBones 5.5 + * @language zh_CN + */ + flipX: boolean; + /** + * - Whether to flip the armature vertically. + * @version DragonBones 5.5 + * @language en_US + */ + /** + * - 是否将骨架垂直翻转。 + * @version DragonBones 5.5 + * @language zh_CN + */ + flipY: boolean; + /** + * - The animation cache frame rate, which turns on the animation cache when the set value is greater than 0. + * There is a certain amount of memory overhead to improve performance by caching animation data in memory. + * The frame rate should not be set too high, usually with the frame rate of the animation is similar and lower than the program running frame rate. + * When the animation cache is turned on, some features will fail, such as the offset property of bone. + * @example + *
+         *     armature.cacheFrameRate = 24;
+         * 
+ * @see dragonBones.DragonBonesData#frameRate + * @see dragonBones.ArmatureData#frameRate + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画缓存帧率,当设置的值大于 0 的时,将会开启动画缓存。 + * 通过将动画数据缓存在内存中来提高运行性能,会有一定的内存开销。 + * 帧率不宜设置的过高,通常跟动画的帧率相当且低于程序运行的帧率。 + * 开启动画缓存后,某些功能将会失效,比如骨骼的 offset 属性等。 + * @example + *
+         *     armature.cacheFrameRate = 24;
+         * 
+ * @see dragonBones.DragonBonesData#frameRate + * @see dragonBones.ArmatureData#frameRate + * @version DragonBones 4.5 + * @language zh_CN + */ + cacheFrameRate: number; + /** + * - The armature name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨架名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly name: string; + /** + * - The armature data. + * @see dragonBones.ArmatureData + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 骨架数据。 + * @see dragonBones.ArmatureData + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly armatureData: ArmatureData; + /** + * - The animation player. + * @see dragonBones.Animation + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画播放器。 + * @see dragonBones.Animation + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly animation: Animation; + /** + * @pivate + */ + readonly proxy: IArmatureProxy; + /** + * - The EventDispatcher instance of the armature. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 该骨架的 EventDispatcher 实例。 + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly eventDispatcher: IEventDispatcher; + /** + * - The display container. + * The display of the slot is displayed as the parent. + * Depending on the rendering engine, the type will be different, usually the DisplayObjectContainer type. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 显示容器实例。 + * 插槽的显示对象都会以此显示容器为父级。 + * 根据渲染引擎的不同,类型会不同,通常是 DisplayObjectContainer 类型。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly display: any; + /** + * @private + */ + replacedTexture: any; + /** + * @inheritDoc + */ + clock: WorldClock | null; + /** + * - Get the parent slot which the armature belongs to. + * @see dragonBones.Slot + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 该骨架所属的父插槽。 + * @see dragonBones.Slot + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly parent: Slot | null; + /** + * @deprecated + * @private + */ + replaceTexture(texture: any): void; + /** + * - Deprecated, please refer to {@link #eventDispatcher}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #eventDispatcher}。 + * @deprecated + * @language zh_CN + */ + hasEventListener(type: EventStringType): boolean; + /** + * - Deprecated, please refer to {@link #eventDispatcher}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #eventDispatcher}。 + * @deprecated + * @language zh_CN + */ + addEventListener(type: EventStringType, listener: Function, target: any): void; + /** + * - Deprecated, please refer to {@link #eventDispatcher}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #eventDispatcher}。 + * @deprecated + * @language zh_CN + */ + removeEventListener(type: EventStringType, listener: Function, target: any): void; + /** + * - Deprecated, please refer to {@link #cacheFrameRate}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #cacheFrameRate}。 + * @deprecated + * @language zh_CN + */ + enableAnimationCache(frameRate: number): void; + /** + * - Deprecated, please refer to {@link #display}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #display}。 + * @deprecated + * @language zh_CN + */ + getDisplay(): any; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The base class of the transform object. + * @see dragonBones.Transform + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 变换对象的基类。 + * @see dragonBones.Transform + * @version DragonBones 4.5 + * @language zh_CN + */ + abstract class TransformObject extends BaseObject { + /** + * @private + */ + protected static readonly _helpMatrix: Matrix; + /** + * @private + */ + protected static readonly _helpTransform: Transform; + /** + * @private + */ + protected static readonly _helpPoint: Point; + /** + * - A matrix relative to the armature coordinate system. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 相对于骨架坐标系的矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly globalTransformMatrix: Matrix; + /** + * - A transform relative to the armature coordinate system. + * @see #updateGlobalTransform() + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 相对于骨架坐标系的变换。 + * @see #updateGlobalTransform() + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly global: Transform; + /** + * - The offset transform relative to the armature or the parent bone coordinate system. + * @see #dragonBones.Bone#invalidUpdate() + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 相对于骨架或父骨骼坐标系的偏移变换。 + * @see #dragonBones.Bone#invalidUpdate() + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly offset: Transform; + /** + * @private + */ + origin: Transform | null; + /** + * @private + */ + userData: any; + /** + * @private + */ + protected _globalDirty: boolean; + /** + * @internal + * @private + */ + _armature: Armature; + /** + * @internal + * @private + */ + _parent: Bone; + /** + * @private + */ + protected _onClear(): void; + /** + * @internal + * @private + */ + _setArmature(value: Armature | null): void; + /** + * @internal + * @private + */ + _setParent(value: Bone | null): void; + /** + * - For performance considerations, rotation or scale in the {@link #global} attribute of the bone or slot is not always properly accessible, + * some engines do not rely on these attributes to update rendering, such as Egret. + * The use of this method ensures that the access to the {@link #global} property is correctly rotation or scale. + * @example + *
+         *     bone.updateGlobalTransform();
+         *     let rotation = bone.global.rotation;
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 出于性能的考虑,骨骼或插槽的 {@link #global} 属性中的旋转或缩放并不总是正确可访问的,有些引擎并不依赖这些属性更新渲染,比如 Egret。 + * 使用此方法可以保证访问到 {@link #global} 属性中正确的旋转或缩放。 + * @example + *
+         *     bone.updateGlobalTransform();
+         *     let rotation = bone.global.rotation;
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + updateGlobalTransform(): void; + /** + * - The armature to which it belongs. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 所属的骨架。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly armature: Armature; + /** + * - The parent bone to which it belongs. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 所属的父骨骼。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly parent: Bone; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - Bone is one of the most important logical units in the armature animation system, + * and is responsible for the realization of translate, rotation, scaling in the animations. + * A armature can contain multiple bones. + * @see dragonBones.BoneData + * @see dragonBones.Armature + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨骼在骨骼动画体系中是最重要的逻辑单元之一,负责动画中的平移、旋转、缩放的实现。 + * 一个骨架中可以包含多个骨骼。 + * @see dragonBones.BoneData + * @see dragonBones.Armature + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + class Bone extends TransformObject { + static toString(): string; + /** + * - The offset mode. + * @see #offset + * @version DragonBones 5.5 + * @language en_US + */ + /** + * - 偏移模式。 + * @see #offset + * @version DragonBones 5.5 + * @language zh_CN + */ + offsetMode: OffsetMode; + /** + * @internal + * @private + */ + readonly animationPose: Transform; + /** + * @internal + * @private + */ + _transformDirty: boolean; + /** + * @internal + * @private + */ + _childrenTransformDirty: boolean; + protected _localDirty: boolean; + /** + * @internal + * @private + */ + _hasConstraint: boolean; + private _visible; + protected _cachedFrameIndex: number; + /** + * @internal + * @private + */ + readonly _blendState: BlendState; + /** + * @internal + * @private + */ + _boneData: BoneData; + /** + * @internal + * @private + */ + _cachedFrameIndices: Array | null; + /** + * @inheritDoc + */ + protected _onClear(): void; + /** + * @private + */ + protected _updateGlobalTransformMatrix(isCache: boolean): void; + /** + * @inheritDoc + */ + _setArmature(value: Armature | null): void; + /** + * @internal + * @private + */ + init(boneData: BoneData): void; + /** + * @internal + * @private + */ + update(cacheFrameIndex: number): void; + /** + * @internal + * @private + */ + updateByConstraint(): void; + /** + * - Forces the bone to update the transform in the next frame. + * When the bone is not animated or its animation state is finished, the bone will not continue to update, + * and when the skeleton must be updated for some reason, the method needs to be called explicitly. + * @example + *
+         *     let bone = armature.getBone("arm");
+         *     bone.offset.scaleX = 2.0;
+         *     bone.invalidUpdate();
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 强制骨骼在下一帧更新变换。 + * 当该骨骼没有动画状态或其动画状态播放完成时,骨骼将不在继续更新,而此时由于某些原因必须更新骨骼时,则需要显式调用该方法。 + * @example + *
+         *     let bone = armature.getBone("arm");
+         *     bone.offset.scaleX = 2.0;
+         *     bone.invalidUpdate();
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + invalidUpdate(): void; + /** + * - Check whether the bone contains a specific bone or slot. + * @see dragonBones.Bone + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 检查该骨骼是否包含特定的骨骼或插槽。 + * @see dragonBones.Bone + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + contains(value: TransformObject): boolean; + /** + * - The bone data. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 骨骼数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly boneData: BoneData; + /** + * - The visible of all slots in the bone. + * @default true + * @see dragonBones.Slot#visible + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 此骨骼所有插槽的可见。 + * @default true + * @see dragonBones.Slot#visible + * @version DragonBones 3.0 + * @language zh_CN + */ + visible: boolean; + /** + * - The bone name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨骼名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly name: string; + /** + * - Deprecated, please refer to {@link dragonBones.Armature#getBones()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link dragonBones.Armature#getBones()}。 + * @deprecated + * @language zh_CN + */ + getBones(): Array; + /** + * - Deprecated, please refer to {@link dragonBones.Armature#getSlots()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link dragonBones.Armature#getSlots()}。 + * @deprecated + * @language zh_CN + */ + getSlots(): Array; + /** + * - Deprecated, please refer to {@link dragonBones.Armature#getSlot()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link dragonBones.Armature#getSlot()}。 + * @deprecated + * @language zh_CN + */ + readonly slot: Slot | null; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + class Surface extends Bone { + static toString(): string; + private _dX; + private _dY; + private _k; + private _kX; + private _kY; + /** + * For debug draw. + * @internal + * @private + */ + readonly _vertices: Array; + /** + * For timeline state. + * @internal + * @private + */ + readonly _deformVertices: Array; + /** + * x1, y1, x2, y2, x3, y3, x4, y4, d1X, d1Y, d2X, d2Y + */ + private readonly _hullCache; + /** + * Inside [flag, a, b, c, d, tx, ty], Outside [flag, a, b, c, d, tx, ty] + */ + private readonly _matrixCahce; + /** + * @inheritDoc + */ + protected _onClear(): void; + private _getAffineTransform(x, y, lX, lY, aX, aY, bX, bY, cX, cY, transform, matrix, isDown); + private _updateVertices(); + /** + * @private + */ + protected _updateGlobalTransformMatrix(isCache: boolean): void; + _getGlobalTransformMatrix(x: number, y: number): Matrix; + init(surfaceData: SurfaceData): void; + /** + * @internal + * @private + */ + update(cacheFrameIndex: number): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The slot attached to the armature, controls the display status and properties of the display object. + * A bone can contain multiple slots. + * A slot can contain multiple display objects, displaying only one of the display objects at a time, + * but you can toggle the display object into frame animation while the animation is playing. + * The display object can be a normal texture, or it can be a display of a child armature, a grid display object, + * and a custom other display object. + * @see dragonBones.Armature + * @see dragonBones.Bone + * @see dragonBones.SlotData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 插槽附着在骨骼上,控制显示对象的显示状态和属性。 + * 一个骨骼上可以包含多个插槽。 + * 一个插槽中可以包含多个显示对象,同一时间只能显示其中的一个显示对象,但可以在动画播放的过程中切换显示对象实现帧动画。 + * 显示对象可以是普通的图片纹理,也可以是子骨架的显示容器,网格显示对象,还可以是自定义的其他显示对象。 + * @see dragonBones.Armature + * @see dragonBones.Bone + * @see dragonBones.SlotData + * @version DragonBones 3.0 + * @language zh_CN + */ + abstract class Slot extends TransformObject { + /** + * - Displays the animated state or mixed group name controlled by the object, set to null to be controlled by all animation states. + * @default null + * @see dragonBones.AnimationState#displayControl + * @see dragonBones.AnimationState#name + * @see dragonBones.AnimationState#group + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 显示对象受到控制的动画状态或混合组名称,设置为 null 则表示受所有的动画状态控制。 + * @default null + * @see dragonBones.AnimationState#displayControl + * @see dragonBones.AnimationState#name + * @see dragonBones.AnimationState#group + * @version DragonBones 4.5 + * @language zh_CN + */ + displayController: string | null; + /** + * @private + */ + protected _displayDirty: boolean; + /** + * @private + */ + protected _zOrderDirty: boolean; + /** + * @private + */ + protected _visibleDirty: boolean; + /** + * @private + */ + protected _blendModeDirty: boolean; + /** + * @internal + * @private + */ + _colorDirty: boolean; + /** + * @internal + * @private + */ + _meshDirty: boolean; + /** + * @private + */ + protected _transformDirty: boolean; + /** + * @private + */ + protected _visible: boolean; + /** + * @private + */ + protected _blendMode: BlendMode; + /** + * @private + */ + protected _displayIndex: number; + /** + * @private + */ + protected _animationDisplayIndex: number; + /** + * @internal + * @private + */ + _zOrder: number; + /** + * @private + */ + protected _cachedFrameIndex: number; + /** + * @internal + * @private + */ + _pivotX: number; + /** + * @internal + * @private + */ + _pivotY: number; + /** + * @private + */ + protected readonly _localMatrix: Matrix; + /** + * @internal + * @private + */ + readonly _colorTransform: ColorTransform; + /** + * @internal + * @private + */ + readonly _deformVertices: Array; + /** + * @private + */ + readonly _displayDatas: Array; + /** + * @private + */ + protected readonly _displayList: Array; + /** + * @private + */ + protected readonly _meshBones: Array; + /** + * @private + */ + protected readonly _meshSlots: Array; + /** + * @internal + * @private + */ + _slotData: SlotData; + /** + * @private + */ + protected _rawDisplayDatas: Array | null; + /** + * @private + */ + protected _displayData: DisplayData | null; + /** + * @private + */ + protected _textureData: TextureData | null; + /** + * @internal + * @private + */ + _meshData: MeshDisplayData | null; + /** + * @private + */ + protected _boundingBoxData: BoundingBoxData | null; + /** + * @private + */ + protected _rawDisplay: any; + /** + * @private + */ + protected _meshDisplay: any; + /** + * @private + */ + protected _display: any; + /** + * @private + */ + protected _childArmature: Armature | null; + /** + * @internal + * @private + */ + _cachedFrameIndices: Array | null; + /** + * @inheritDoc + */ + protected _onClear(): void; + /** + * @private + */ + protected abstract _initDisplay(value: any, isRetain: boolean): void; + /** + * @private + */ + protected abstract _disposeDisplay(value: any, isRelease: boolean): void; + /** + * @private + */ + protected abstract _onUpdateDisplay(): void; + /** + * @private + */ + protected abstract _addDisplay(): void; + /** + * @private + */ + protected abstract _replaceDisplay(value: any): void; + /** + * @private + */ + protected abstract _removeDisplay(): void; + /** + * @private + */ + protected abstract _updateZOrder(): void; + /** + * @private + */ + abstract _updateVisible(): void; + /** + * @private + */ + protected abstract _updateBlendMode(): void; + /** + * @private + */ + protected abstract _updateColor(): void; + /** + * @private + */ + protected abstract _updateFrame(): void; + /** + * @private + */ + protected abstract _updateMesh(): void; + /** + * @internal + * @private + */ + abstract _updateGlueMesh(): void; + /** + * @private + */ + protected abstract _updateTransform(): void; + /** + * @private + */ + protected abstract _identityTransform(): void; + /** + * @private + */ + protected _getDefaultRawDisplayData(): DisplayData | null; + /** + * @private + */ + protected _updateDisplayData(): void; + /** + * @private + */ + protected _updateDisplay(): void; + /** + * @private + */ + protected _updateGlobalTransformMatrix(isCache: boolean): void; + /** + * @private + */ + protected _isMeshBonesUpdate(): boolean; + /** + * @inheritDoc + */ + _setArmature(value: Armature | null): void; + /** + * @internal + * @private + */ + _setDisplayIndex(value: number, isAnimation?: boolean): boolean; + /** + * @internal + * @private + */ + _setZorder(value: number): boolean; + /** + * @internal + * @private + */ + _setColor(value: ColorTransform): boolean; + /** + * @internal + * @private + */ + _setDisplayList(value: Array | null): boolean; + /** + * @internal + * @private + */ + init(slotData: SlotData, displayDatas: Array | null, rawDisplay: any, meshDisplay: any): void; + /** + * @internal + * @private + */ + update(cacheFrameIndex: number): void; + /** + * @private + */ + updateTransformAndMatrix(): void; + /** + * @private + */ + replaceDisplayData(value: DisplayData | null, displayIndex?: number): void; + /** + * - Check whether a specific point is inside a custom bounding box in the slot. + * The coordinate system of the point is the inner coordinate system of the armature. + * Custom bounding boxes need to be customized in Dragonbones Pro. + * @param x - The horizontal coordinate of the point. + * @param y - The vertical coordinate of the point. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 检查特定点是否在插槽的自定义边界框内。 + * 点的坐标系为骨架内坐标系。 + * 自定义边界框需要在 DragonBones Pro 中自定义。 + * @param x - 点的水平坐标。 + * @param y - 点的垂直坐标。 + * @version DragonBones 5.0 + * @language zh_CN + */ + containsPoint(x: number, y: number): boolean; + /** + * - Check whether a specific segment intersects a custom bounding box for the slot. + * The coordinate system of the segment and intersection is the inner coordinate system of the armature. + * Custom bounding boxes need to be customized in Dragonbones Pro. + * @param xA - The horizontal coordinate of the beginning of the segment. + * @param yA - The vertical coordinate of the beginning of the segment. + * @param xB - The horizontal coordinate of the end point of the segment. + * @param yB - The vertical coordinate of the end point of the segment. + * @param intersectionPointA - The first intersection at which a line segment intersects the bounding box from the beginning to the end. (If not set, the intersection point will not calculated) + * @param intersectionPointB - The first intersection at which a line segment intersects the bounding box from the end to the beginning. (If not set, the intersection point will not calculated) + * @param normalRadians - The normal radians of the tangent of the intersection boundary box. [x: Normal radian of the first intersection tangent, y: Normal radian of the second intersection tangent] (If not set, the normal will not calculated) + * @returns Intersection situation. [1: Disjoint and segments within the bounding box, 0: Disjoint, 1: Intersecting and having a nodal point and ending in the bounding box, 2: Intersecting and having a nodal point and starting at the bounding box, 3: Intersecting and having two intersections, N: Intersecting and having N intersections] + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 检查特定线段是否与插槽的自定义边界框相交。 + * 线段和交点的坐标系均为骨架内坐标系。 + * 自定义边界框需要在 DragonBones Pro 中自定义。 + * @param xA - 线段起点的水平坐标。 + * @param yA - 线段起点的垂直坐标。 + * @param xB - 线段终点的水平坐标。 + * @param yB - 线段终点的垂直坐标。 + * @param intersectionPointA - 线段从起点到终点与边界框相交的第一个交点。 (如果未设置,则不计算交点) + * @param intersectionPointB - 线段从终点到起点与边界框相交的第一个交点。 (如果未设置,则不计算交点) + * @param normalRadians - 交点边界框切线的法线弧度。 [x: 第一个交点切线的法线弧度, y: 第二个交点切线的法线弧度] (如果未设置,则不计算法线) + * @returns 相交的情况。 [-1: 不相交且线段在包围盒内, 0: 不相交, 1: 相交且有一个交点且终点在包围盒内, 2: 相交且有一个交点且起点在包围盒内, 3: 相交且有两个交点, N: 相交且有 N 个交点] + * @version DragonBones 5.0 + * @language zh_CN + */ + intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): number; + /** + * - Forces the slot to update the state of the display object in the next frame. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 强制插槽在下一帧更新显示对象的状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + invalidUpdate(): void; + /** + * - The visible of slot's display object. + * @default true + * @version DragonBones 5.6 + * @language en_US + */ + /** + * - 插槽的显示对象的可见。 + * @default true + * @version DragonBones 5.6 + * @language zh_CN + */ + visible: boolean; + /** + * - The index of the display object displayed in the display list. + * @example + *
+         *     let slot = armature.getSlot("weapon");
+         *     slot.displayIndex = 3;
+         *     slot.displayController = "none";
+         * 
+ * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 此时显示的显示对象在显示列表中的索引。 + * @example + *
+         *     let slot = armature.getSlot("weapon");
+         *     slot.displayIndex = 3;
+         *     slot.displayController = "none";
+         * 
+ * @version DragonBones 4.5 + * @language zh_CN + */ + displayIndex: number; + /** + * - The slot name. + * @see dragonBones.SlotData#name + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 插槽名称。 + * @see dragonBones.SlotData#name + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly name: string; + /** + * - Contains a display list of display objects or child armatures. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 包含显示对象或子骨架的显示列表。 + * @version DragonBones 3.0 + * @language zh_CN + */ + displayList: Array; + /** + * - The slot data. + * @see dragonBones.SlotData + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 插槽数据。 + * @see dragonBones.SlotData + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly slotData: SlotData; + /** + * @private + */ + rawDisplayDatas: Array | null; + /** + * - The custom bounding box data for the slot at current time. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 插槽此时的自定义包围盒数据。 + * @version DragonBones 5.0 + * @language zh_CN + */ + readonly boundingBoxData: BoundingBoxData | null; + /** + * @private + */ + readonly rawDisplay: any; + /** + * @private + */ + readonly meshDisplay: any; + /** + * - The display object that the slot displays at this time. + * @example + *
+         *     let slot = armature.getSlot("text");
+         *     slot.display = new yourEngine.TextField();
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 插槽此时显示的显示对象。 + * @example + *
+         *     let slot = armature.getSlot("text");
+         *     slot.display = new yourEngine.TextField();
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + display: any; + /** + * - The child armature that the slot displayed at current time. + * @example + *
+         *     let slot = armature.getSlot("weapon");
+         *     slot.childArmature = factory.buildArmature("weapon_blabla", "weapon_blabla_project");
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 插槽此时显示的子骨架。 + * @example + *
+         *     let slot = armature.getSlot("weapon");
+         *     slot.childArmature = factory.buildArmature("weapon_blabla", "weapon_blabla_project");
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + childArmature: Armature | null; + /** + * - Deprecated, please refer to {@link #display}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #display}。 + * @deprecated + * @language zh_CN + */ + getDisplay(): any; + /** + * - Deprecated, please refer to {@link #display}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #display}。 + * @deprecated + * @language zh_CN + */ + setDisplay(value: any): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + abstract class Constraint extends BaseObject { + protected static readonly _helpMatrix: Matrix; + protected static readonly _helpTransform: Transform; + protected static readonly _helpPoint: Point; + /** + * - For timeline state. + * @internal + */ + _constraintData: ConstraintData; + protected _armature: Armature; + /** + * - For sort bones. + * @internal + */ + _target: Bone; + /** + * - For sort bones. + * @internal + */ + _root: Bone; + protected _bone: Bone | null; + protected _onClear(): void; + abstract init(constraintData: ConstraintData, armature: Armature): void; + abstract update(): void; + abstract invalidUpdate(): void; + readonly name: string; + } + /** + * @internal + * @private + */ + class IKConstraint extends Constraint { + static toString(): string; + private _scaleEnabled; + /** + * - For timeline state. + * @internal + */ + _bendPositive: boolean; + /** + * - For timeline state. + * @internal + */ + _weight: number; + protected _onClear(): void; + private _computeA(); + private _computeB(); + init(constraintData: ConstraintData, armature: Armature): void; + update(): void; + invalidUpdate(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - Play animation interface. (Both Armature and Wordclock implement the interface) + * Any instance that implements the interface can be added to the Worldclock instance and advance time by Worldclock instance uniformly. + * @see dragonBones.WorldClock + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 播放动画接口。 (Armature 和 WordClock 都实现了该接口) + * 任何实现了此接口的实例都可以添加到 WorldClock 实例中,由 WorldClock 实例统一更新时间。 + * @see dragonBones.WorldClock + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + interface IAnimatable { + /** + * - Advance time. + * @param passedTime - Passed time. (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 更新时间。 + * @param passedTime - 前进的时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + advanceTime(passedTime: number): void; + /** + * - The Wordclock instance to which the current belongs. + * @example + *
+         *     armature.clock = factory.clock; // Add armature to clock.
+         *     armature.clock = null; // Remove armature from clock.
+         * 
+ * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 当前所属的 WordClock 实例。 + * @example + *
+         *     armature.clock = factory.clock; // 将骨架添加到时钟。
+         *     armature.clock = null; // 将骨架从时钟移除。
+         * 
+ * @version DragonBones 5.0 + * @language zh_CN + */ + clock: WorldClock | null; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - Worldclock provides clock support for animations, advance time for each IAnimatable object added to the instance. + * @see dragonBones.IAnimateble + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - WorldClock 对动画提供时钟支持,为每个加入到该实例的 IAnimatable 对象更新时间。 + * @see dragonBones.IAnimateble + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + class WorldClock implements IAnimatable { + /** + * - Current time. (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 当前的时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + time: number; + /** + * - The play speed, used to control animation speed-shift play. + * [0: Stop play, (0~1): Slow play, 1: Normal play, (1~N): Fast play] + * @default 1.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 播放速度,用于控制动画变速播放。 + * [0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + timeScale: number; + private readonly _animatebles; + private _clock; + /** + * - Creating a Worldclock instance. Typically, you do not need to create Worldclock instance. + * When multiple Worldclock instances are running at different speeds, can achieving some specific animation effects, such as bullet time. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 创建一个 WorldClock 实例。通常并不需要创建 WorldClock 实例。 + * 当多个 WorldClock 实例使用不同的速度运行时,可以实现一些特殊的动画效果,比如子弹时间等。 + * @version DragonBones 3.0 + * @language zh_CN + */ + constructor(time?: number); + /** + * - Advance time for all IAnimatable instances. + * @param passedTime - Passed time. [-1: Automatically calculates the time difference between the current frame and the previous frame, [0~N): Passed time] (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 为所有的 IAnimatable 实例更新时间。 + * @param passedTime - 前进的时间。 [-1: 自动计算当前帧与上一帧的时间差, [0~N): 前进的时间] (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + advanceTime(passedTime: number): void; + /** + * - Check whether contains a specific instance of IAnimatable. + * @param value - The IAnimatable instance. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 检查是否包含特定的 IAnimatable 实例。 + * @param value - IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + contains(value: IAnimatable): boolean; + /** + * - Add IAnimatable instance. + * @param value - The IAnimatable instance. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 添加 IAnimatable 实例。 + * @param value - IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + add(value: IAnimatable): void; + /** + * - Removes a specified IAnimatable instance. + * @param value - The IAnimatable instance. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 移除特定的 IAnimatable 实例。 + * @param value - IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + remove(value: IAnimatable): void; + /** + * - Clear all IAnimatable instances. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 清除所有的 IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + clear(): void; + /** + * @inheritDoc + */ + clock: WorldClock | null; + /** + * - Deprecated, please refer to {@link dragonBones.BaseFactory#clock}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link dragonBones.BaseFactory#clock}。 + * @deprecated + * @language zh_CN + */ + static readonly clock: WorldClock; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The animation player is used to play the animation data and manage the animation states. + * @see dragonBones.AnimationData + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画播放器用来播放动画数据和管理动画状态。 + * @see dragonBones.AnimationData + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + class Animation extends BaseObject { + static toString(): string; + /** + * - The play speed of all animations. [0: Stop, (0~1): Slow, 1: Normal, (1~N): Fast] + * @default 1.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 所有动画的播放速度。 [0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + timeScale: number; + private _lockUpdate; + private _animationDirty; + private _inheritTimeScale; + private readonly _animationNames; + private readonly _animationStates; + private readonly _animations; + private _armature; + private _animationConfig; + private _lastAnimationState; + /** + * @private + */ + protected _onClear(): void; + private _fadeOut(animationConfig); + /** + * @internal + * @private + */ + init(armature: Armature): void; + /** + * @internal + * @private + */ + advanceTime(passedTime: number): void; + /** + * - Clear all animations states. + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 清除所有的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + reset(): void; + /** + * - Pause a specific animation state. + * @param animationName - The name of animation state. (If not set, it will pause all animations) + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 暂停指定动画状态的播放。 + * @param animationName - 动画状态名称。 (如果未设置,则暂停所有动画) + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + stop(animationName?: string | null): void; + /** + * - Play animation with a specific animation config. + * The API is still in the experimental phase and may encounter bugs or stability or compatibility issues when used. + * @param animationConfig - The animation config. + * @returns The playing animation state. + * @see dragonBones.AnimationConfig + * @beta + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 通过指定的动画配置来播放动画。 + * 该 API 仍在实验阶段,使用时可能遭遇 bug 或稳定性或兼容性问题。 + * @param animationConfig - 动画配置。 + * @returns 播放的动画状态。 + * @see dragonBones.AnimationConfig + * @beta + * @version DragonBones 5.0 + * @language zh_CN + */ + playConfig(animationConfig: AnimationConfig): AnimationState | null; + /** + * - Play a specific animation. + * @param animationName - The name of animation data. (If not set, The default animation will be played, or resume the animation playing from pause status, or replay the last playing animation) + * @param playTimes - Playing repeat times. [-1: Use default value of the animation data, 0: No end loop playing, [1~N]: Repeat N times] (default: -1) + * @returns The playing animation state. + * @example + *
+         *     armature.animation.play("walk");
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 播放指定动画。 + * @param animationName - 动画数据名称。 (如果未设置,则播放默认动画,或将暂停状态切换为播放状态,或重新播放之前播放的动画) + * @param playTimes - 循环播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) + * @returns 播放的动画状态。 + * @example + *
+         *     armature.animation.play("walk");
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + play(animationName?: string | null, playTimes?: number): AnimationState | null; + /** + * - Fade in a specific animation. + * @param animationName - The name of animation data. + * @param fadeInTime - The fade in time. [-1: Use the default value of animation data, [0~N]: The fade in time (In seconds)] (Default: -1) + * @param playTimes - playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) + * @param layer - The blending layer, the animation states in high level layer will get the blending weights with high priority, when the total blending weights are more than 1.0, there will be no more weights can be allocated to the other animation states. (Default: 0) + * @param group - The blending group name, it is typically used to specify the substitution of multiple animation states blending. (Default: null) + * @param fadeOutMode - The fade out mode, which is typically used to specify alternate mode of multiple animation states blending. (Default: AnimationFadeOutMode.SameLayerAndGroup) + * @returns The playing animation state. + * @example + *
+         *     armature.animation.fadeIn("walk", 0.3, 0, 0, "normalGroup").resetToPose = false;
+         *     armature.animation.fadeIn("attack", 0.3, 1, 0, "attackGroup").resetToPose = false;
+         * 
+ * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 淡入播放指定的动画。 + * @param animationName - 动画数据名称。 + * @param fadeInTime - 淡入时间。 [-1: 使用动画数据默认值, [0~N]: 淡入时间 (以秒为单位)] (默认: -1) + * @param playTimes - 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) + * @param layer - 混合图层,图层高的动画状态会优先获取混合权重,当混合权重分配总和超过 1.0 时,剩余的动画状态将不能再获得权重分配。 (默认: 0) + * @param group - 混合组名称,该属性通常用来指定多个动画状态混合时的相互替换关系。 (默认: null) + * @param fadeOutMode - 淡出模式,该属性通常用来指定多个动画状态混合时的相互替换模式。 (默认: AnimationFadeOutMode.SameLayerAndGroup) + * @returns 播放的动画状态。 + * @example + *
+         *     armature.animation.fadeIn("walk", 0.3, 0, 0, "normalGroup").resetToPose = false;
+         *     armature.animation.fadeIn("attack", 0.3, 1, 0, "attackGroup").resetToPose = false;
+         * 
+ * @version DragonBones 4.5 + * @language zh_CN + */ + fadeIn(animationName: string, fadeInTime?: number, playTimes?: number, layer?: number, group?: string | null, fadeOutMode?: AnimationFadeOutMode): AnimationState | null; + /** + * - Play a specific animation from the specific time. + * @param animationName - The name of animation data. + * @param time - The start time point of playing. (In seconds) + * @param playTimes - Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) + * @returns The played animation state. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 从指定时间开始播放指定的动画。 + * @param animationName - 动画数据名称。 + * @param time - 播放开始的时间。 (以秒为单位) + * @param playTimes - 循环播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) + * @returns 播放的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndPlayByTime(animationName: string, time?: number, playTimes?: number): AnimationState | null; + /** + * - Play a specific animation from the specific frame. + * @param animationName - The name of animation data. + * @param frame - The start frame of playing. + * @param playTimes - Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) + * @returns The played animation state. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 从指定帧开始播放指定的动画。 + * @param animationName - 动画数据名称。 + * @param frame - 播放开始的帧数。 + * @param playTimes - 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) + * @returns 播放的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndPlayByFrame(animationName: string, frame?: number, playTimes?: number): AnimationState | null; + /** + * - Play a specific animation from the specific progress. + * @param animationName - The name of animation data. + * @param progress - The start progress value of playing. + * @param playTimes - Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) + * @returns The played animation state. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 从指定进度开始播放指定的动画。 + * @param animationName - 动画数据名称。 + * @param progress - 开始播放的进度。 + * @param playTimes - 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) + * @returns 播放的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndPlayByProgress(animationName: string, progress?: number, playTimes?: number): AnimationState | null; + /** + * - Stop a specific animation at the specific time. + * @param animationName - The name of animation data. + * @param time - The stop time. (In seconds) + * @returns The played animation state. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 在指定时间停止指定动画播放 + * @param animationName - 动画数据名称。 + * @param time - 停止的时间。 (以秒为单位) + * @returns 播放的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndStopByTime(animationName: string, time?: number): AnimationState | null; + /** + * - Stop a specific animation at the specific frame. + * @param animationName - The name of animation data. + * @param frame - The stop frame. + * @returns The played animation state. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 在指定帧停止指定动画的播放 + * @param animationName - 动画数据名称。 + * @param frame - 停止的帧数。 + * @returns 播放的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndStopByFrame(animationName: string, frame?: number): AnimationState | null; + /** + * - Stop a specific animation at the specific progress. + * @param animationName - The name of animation data. + * @param progress - The stop progress value. + * @returns The played animation state. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 在指定的进度停止指定的动画播放。 + * @param animationName - 动画数据名称。 + * @param progress - 停止进度。 + * @returns 播放的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndStopByProgress(animationName: string, progress?: number): AnimationState | null; + /** + * - Get a specific animation state. + * @param animationName - The name of animation state. + * @example + *
+         *     armature.animation.play("walk");
+         *     let walkState = armature.animation.getState("walk");
+         *     walkState.timeScale = 0.5;
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取指定的动画状态 + * @param animationName - 动画状态名称。 + * @example + *
+         *     armature.animation.play("walk");
+         *     let walkState = armature.animation.getState("walk");
+         *     walkState.timeScale = 0.5;
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + getState(animationName: string): AnimationState | null; + /** + * - Check whether a specific animation data is included. + * @param animationName - The name of animation data. + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 检查是否包含指定的动画数据 + * @param animationName - 动画数据名称。 + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language zh_CN + */ + hasAnimation(animationName: string): boolean; + /** + * - Get all the animation states. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 获取所有的动画状态 + * @version DragonBones 5.1 + * @language zh_CN + */ + getStates(): Array; + /** + * - Check whether there is an animation state is playing + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 检查是否有动画状态正在播放 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly isPlaying: boolean; + /** + * - Check whether all the animation states' playing were finished. + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 检查是否所有的动画状态均已播放完毕。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly isCompleted: boolean; + /** + * - The name of the last playing animation state. + * @see #lastAnimationState + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 上一个播放的动画状态名称 + * @see #lastAnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly lastAnimationName: string; + /** + * - The name of all animation data + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 所有动画数据的名称 + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly animationNames: Array; + /** + * - All animation data. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 所有的动画数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + animations: Map; + /** + * - An AnimationConfig instance that can be used quickly. + * @see dragonBones.AnimationConfig + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 一个可以快速使用的动画配置实例。 + * @see dragonBones.AnimationConfig + * @version DragonBones 5.0 + * @language zh_CN + */ + readonly animationConfig: AnimationConfig; + /** + * - The last playing animation state + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 上一个播放的动画状态 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly lastAnimationState: AnimationState | null; + /** + * - Deprecated, please refer to {@link #play()} {@link #fadeIn()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #play()} {@link #fadeIn()}。 + * @deprecated + * @language zh_CN + */ + gotoAndPlay(animationName: string, fadeInTime?: number, duration?: number, playTimes?: number, layer?: number, group?: string | null, fadeOutMode?: AnimationFadeOutMode, pauseFadeOut?: boolean, pauseFadeIn?: boolean): AnimationState | null; + /** + * - Deprecated, please refer to {@link #gotoAndStopByTime()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #gotoAndStopByTime()}。 + * @deprecated + * @language zh_CN + */ + gotoAndStop(animationName: string, time?: number): AnimationState | null; + /** + * - Deprecated, please refer to {@link #animationNames}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #animationNames}。 + * @deprecated + * @language zh_CN + */ + readonly animationList: Array; + /** + * - Deprecated, please refer to {@link #animationNames}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #animationNames}。 + * @deprecated + * @language zh_CN + */ + readonly animationDataList: Array; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The animation state is generated when the animation data is played. + * @see dragonBones.Animation + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画状态由播放动画数据时产生。 + * @see dragonBones.Animation + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language zh_CN + */ + class AnimationState extends BaseObject { + static toString(): string; + /** + * @private + */ + actionEnabled: boolean; + /** + * @private + */ + additiveBlending: boolean; + /** + * - Whether the animation state has control over the display object properties of the slots. + * Sometimes blend a animation state does not want it to control the display object properties of the slots, + * especially if other animation state are controlling the display object properties of the slots. + * @default true + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画状态是否对插槽的显示对象属性有控制权。 + * 有时混合一个动画状态并不希望其控制插槽的显示对象属性, + * 尤其是其他动画状态正在控制这些插槽的显示对象属性时。 + * @default true + * @version DragonBones 5.0 + * @language zh_CN + */ + displayControl: boolean; + /** + * - Whether to reset the objects without animation to the armature pose when the animation state is start to play. + * This property should usually be set to false when blend multiple animation states. + * @default true + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 开始播放动画状态时是否将没有动画的对象重置为骨架初始值。 + * 通常在混合多个动画状态时应该将该属性设置为 false。 + * @default true + * @version DragonBones 5.1 + * @language zh_CN + */ + resetToPose: boolean; + /** + * - The play times. [0: Loop play, [1~N]: Play N times] + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 播放次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次] + * @version DragonBones 3.0 + * @language zh_CN + */ + playTimes: number; + /** + * - The blend layer. + * High layer animation state will get the blend weight first. + * When the blend weight is assigned more than 1, the remaining animation states will no longer get the weight assigned. + * @readonly + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 混合图层。 + * 图层高的动画状态会优先获取混合权重。 + * 当混合权重分配超过 1 时,剩余的动画状态将不再获得权重分配。 + * @readonly + * @version DragonBones 5.0 + * @language zh_CN + */ + layer: number; + /** + * - The play speed. + * The value is an overlay relationship with {@link dragonBones.Animation#timeScale}. + * [(-N~0): Reverse play, 0: Stop play, (0~1): Slow play, 1: Normal play, (1~N): Fast play] + * @default 1.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 播放速度。 + * 该值与 {@link dragonBones.Animation#timeScale} 是叠加关系。 + * [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + timeScale: number; + /** + * - The blend weight. + * @default 1.0 + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 混合权重。 + * @default 1.0 + * @version DragonBones 5.0 + * @language zh_CN + */ + weight: number; + /** + * - The auto fade out time when the animation state play completed. + * [-1: Do not fade out automatically, [0~N]: The fade out time] (In seconds) + * @default -1.0 + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画状态播放完成后的自动淡出时间。 + * [-1: 不自动淡出, [0~N]: 淡出时间] (以秒为单位) + * @default -1.0 + * @version DragonBones 5.0 + * @language zh_CN + */ + autoFadeOutTime: number; + /** + * @private + */ + fadeTotalTime: number; + /** + * - The name of the animation state. (Can be different from the name of the animation data) + * @readonly + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画状态名称。 (可以不同于动画数据) + * @readonly + * @version DragonBones 5.0 + * @language zh_CN + */ + name: string; + /** + * - The blend group name of the animation state. + * This property is typically used to specify the substitution of multiple animation states blend. + * @readonly + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 混合组名称。 + * 该属性通常用来指定多个动画状态混合时的相互替换关系。 + * @readonly + * @version DragonBones 5.0 + * @language zh_CN + */ + group: string; + private _timelineDirty; + /** + * - xx: Play Enabled, Fade Play Enabled + * @internal + * @private + */ + _playheadState: number; + /** + * -1: Fade in, 0: Fade complete, 1: Fade out; + * @internal + * @private + */ + _fadeState: number; + /** + * -1: Fade start, 0: Fading, 1: Fade complete; + * @internal + * @private + */ + _subFadeState: number; + /** + * @internal + * @private + */ + _position: number; + /** + * @internal + * @private + */ + _duration: number; + private _fadeTime; + private _time; + /** + * @internal + * @private + */ + _fadeProgress: number; + /** + * @internal + * @private + */ + _weightResult: number; + /** + * @internal + * @private + */ + readonly _blendState: BlendState; + private readonly _boneMask; + private readonly _boneTimelines; + private readonly _surfaceTimelines; + private readonly _slotTimelines; + private readonly _constraintTimelines; + private readonly _animationTimelines; + private readonly _poseTimelines; + private readonly _bonePoses; + /** + * @internal + * @private + */ + _animationData: AnimationData; + private _armature; + /** + * @internal + * @private + */ + _actionTimeline: ActionTimelineState; + private _zOrderTimeline; + /** + * @internal + * @private + */ + _parent: AnimationState; + /** + * @private + */ + protected _onClear(): void; + private _updateTimelines(); + private _updateBoneAndSlotTimelines(); + private _advanceFadeTime(passedTime); + /** + * @internal + * @private + */ + init(armature: Armature, animationData: AnimationData, animationConfig: AnimationConfig): void; + /** + * @internal + * @private + */ + advanceTime(passedTime: number, cacheFrameRate: number): void; + /** + * - Continue play. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 继续播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + play(): void; + /** + * - Stop play. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 暂停播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + stop(): void; + /** + * - Fade out the animation state. + * @param fadeOutTime - The fade out time. (In seconds) + * @param pausePlayhead - Whether to pause the animation playing when fade out. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 淡出动画状态。 + * @param fadeOutTime - 淡出时间。 (以秒为单位) + * @param pausePlayhead - 淡出时是否暂停播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + fadeOut(fadeOutTime: number, pausePlayhead?: boolean): void; + /** + * - Check if a specific bone mask is included. + * @param name - The bone name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 检查是否包含特定骨骼遮罩。 + * @param name - 骨骼名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + containsBoneMask(name: string): boolean; + /** + * - Add a specific bone mask. + * @param name - The bone name. + * @param recursive - Whether or not to add a mask to the bone's sub-bone. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 添加特定的骨骼遮罩。 + * @param name - 骨骼名称。 + * @param recursive - 是否为该骨骼的子骨骼添加遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + addBoneMask(name: string, recursive?: boolean): void; + /** + * - Remove the mask of a specific bone. + * @param name - The bone name. + * @param recursive - Whether to remove the bone's sub-bone mask. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 删除特定骨骼的遮罩。 + * @param name - 骨骼名称。 + * @param recursive - 是否删除该骨骼的子骨骼遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + removeBoneMask(name: string, recursive?: boolean): void; + /** + * - Remove all bone masks. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 删除所有骨骼遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + removeAllBoneMask(): void; + /** + * - Whether the animation state is fading in. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 是否正在淡入。 + * @version DragonBones 5.1 + * @language zh_CN + */ + readonly isFadeIn: boolean; + /** + * - Whether the animation state is fading out. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 是否正在淡出。 + * @version DragonBones 5.1 + * @language zh_CN + */ + readonly isFadeOut: boolean; + /** + * - Whether the animation state is fade completed. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 是否淡入或淡出完毕。 + * @version DragonBones 5.1 + * @language zh_CN + */ + readonly isFadeComplete: boolean; + /** + * - Whether the animation state is playing. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 是否正在播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly isPlaying: boolean; + /** + * - Whether the animation state is play completed. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 是否播放完毕。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly isCompleted: boolean; + /** + * - The times has been played. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 已经循环播放的次数。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly currentPlayTimes: number; + /** + * - The total time. (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 总播放时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly totalTime: number; + /** + * - The time is currently playing. (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 当前播放的时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + currentTime: number; + /** + * - The animation data. + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画数据。 + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly animationData: AnimationData; + } + /** + * @internal + * @private + */ + class BonePose extends BaseObject { + static toString(): string; + readonly current: Transform; + readonly delta: Transform; + readonly result: Transform; + protected _onClear(): void; + } + /** + * @internal + * @private + */ + class BlendState { + dirty: boolean; + layer: number; + leftWeight: number; + layerWeight: number; + blendWeight: number; + update(weight: number, layer: number): number; + clear(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + const enum TweenState { + None = 0, + Once = 1, + Always = 2, + } + /** + * @internal + * @private + */ + abstract class TimelineState extends BaseObject { + playState: number; + currentPlayTimes: number; + currentTime: number; + protected _tweenState: TweenState; + protected _frameRate: number; + protected _frameValueOffset: number; + protected _frameCount: number; + protected _frameOffset: number; + protected _frameIndex: number; + protected _frameRateR: number; + protected _position: number; + protected _duration: number; + protected _timeScale: number; + protected _timeOffset: number; + protected _dragonBonesData: DragonBonesData; + protected _animationData: AnimationData; + protected _timelineData: TimelineData | null; + protected _armature: Armature; + protected _animationState: AnimationState; + protected _actionTimeline: TimelineState; + protected _frameArray: Array | Int16Array; + protected _frameIntArray: Array | Int16Array; + protected _frameFloatArray: Array | Int16Array; + protected _timelineArray: Array | Uint16Array; + protected _frameIndices: Array; + protected _onClear(): void; + protected abstract _onArriveAtFrame(): void; + protected abstract _onUpdateFrame(): void; + protected _setCurrentTime(passedTime: number): boolean; + init(armature: Armature, animationState: AnimationState, timelineData: TimelineData | null): void; + fadeOut(): void; + update(passedTime: number): void; + } + /** + * @internal + * @private + */ + abstract class TweenTimelineState extends TimelineState { + private static _getEasingValue(tweenType, progress, easing); + private static _getEasingCurveValue(progress, samples, count, offset); + protected _tweenType: TweenType; + protected _curveCount: number; + protected _framePosition: number; + protected _frameDurationR: number; + protected _tweenProgress: number; + protected _tweenEasing: number; + protected _onClear(): void; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + } + /** + * @internal + * @private + */ + abstract class BoneTimelineState extends TweenTimelineState { + bone: Bone; + bonePose: BonePose; + protected _onClear(): void; + blend(state: number): void; + } + /** + * @internal + * @private + */ + abstract class SlotTimelineState extends TweenTimelineState { + slot: Slot; + protected _onClear(): void; + } + /** + * @internal + * @private + */ + abstract class ConstraintTimelineState extends TweenTimelineState { + constraint: Constraint; + protected _onClear(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + class ActionTimelineState extends TimelineState { + static toString(): string; + private _onCrossFrame(frameIndex); + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + update(passedTime: number): void; + setCurrentTime(value: number): void; + } + /** + * @internal + * @private + */ + class ZOrderTimelineState extends TimelineState { + static toString(): string; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + } + /** + * @internal + * @private + */ + class BoneAllTimelineState extends BoneTimelineState { + static toString(): string; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + fadeOut(): void; + } + /** + * @internal + * @private + */ + class BoneTranslateTimelineState extends BoneTimelineState { + static toString(): string; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + } + /** + * @internal + * @private + */ + class BoneRotateTimelineState extends BoneTimelineState { + static toString(): string; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + fadeOut(): void; + } + /** + * @internal + * @private + */ + class BoneScaleTimelineState extends BoneTimelineState { + static toString(): string; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + } + /** + * @internal + * @private + */ + class SurfaceTimelineState extends TweenTimelineState { + static toString(): string; + surface: Surface; + private _frameFloatOffset; + private _valueCount; + private _deformCount; + private _valueOffset; + private readonly _current; + private readonly _delta; + private readonly _result; + protected _onClear(): void; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + init(armature: Armature, animationState: AnimationState, timelineData: TimelineData | null): void; + blend(state: number): void; + } + /** + * @internal + * @private + */ + class SlotDislayTimelineState extends SlotTimelineState { + static toString(): string; + protected _onArriveAtFrame(): void; + } + /** + * @internal + * @private + */ + class SlotColorTimelineState extends SlotTimelineState { + static toString(): string; + private _dirty; + private readonly _current; + private readonly _delta; + private readonly _result; + protected _onClear(): void; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + fadeOut(): void; + update(passedTime: number): void; + } + /** + * @internal + * @private + */ + class SlotFFDTimelineState extends SlotTimelineState { + static toString(): string; + meshOffset: number; + private _dirty; + private _frameFloatOffset; + private _valueCount; + private _deformCount; + private _valueOffset; + private readonly _current; + private readonly _delta; + private readonly _result; + protected _onClear(): void; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + init(armature: Armature, animationState: AnimationState, timelineData: TimelineData | null): void; + fadeOut(): void; + update(passedTime: number): void; + } + /** + * @internal + * @private + */ + class IKConstraintTimelineState extends ConstraintTimelineState { + static toString(): string; + private _current; + private _delta; + protected _onClear(): void; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + } + /** + * @internal + * @private + */ + class AnimationTimelineState extends TweenTimelineState { + static toString(): string; + animationState: AnimationState; + private readonly _floats; + protected _onClear(): void; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + blend(state: number): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The properties of the object carry basic information about an event, + * which are passed as parameter or parameter's parameter to event listeners when an event occurs. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 事件对象,包含有关事件的基本信息,当发生事件时,该实例将作为参数或参数的参数传递给事件侦听器。 + * @version DragonBones 4.5 + * @language zh_CN + */ + class EventObject extends BaseObject { + /** + * - Animation start play. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画开始播放。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly START: string; + /** + * - Animation loop play complete once. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画循环播放完成一次。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly LOOP_COMPLETE: string; + /** + * - Animation play complete. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画播放完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly COMPLETE: string; + /** + * - Animation fade in start. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画淡入开始。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly FADE_IN: string; + /** + * - Animation fade in complete. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画淡入完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly FADE_IN_COMPLETE: string; + /** + * - Animation fade out start. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画淡出开始。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly FADE_OUT: string; + /** + * - Animation fade out complete. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画淡出完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly FADE_OUT_COMPLETE: string; + /** + * - Animation frame event. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画帧事件。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly FRAME_EVENT: string; + /** + * - Animation frame sound event. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画帧声音事件。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly SOUND_EVENT: string; + static toString(): string; + /** + * - If is a frame event, the value is used to describe the time that the event was in the animation timeline. (In seconds) + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 如果是帧事件,此值用来描述该事件在动画时间轴中所处的时间。(以秒为单位) + * @version DragonBones 4.5 + * @language zh_CN + */ + time: number; + /** + * - The event type。 + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 事件类型。 + * @version DragonBones 4.5 + * @language zh_CN + */ + type: EventStringType; + /** + * - The event name. (The frame event name or the frame sound name) + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 事件名称。 (帧事件的名称或帧声音的名称) + * @version DragonBones 4.5 + * @language zh_CN + */ + name: string; + /** + * - The armature that dispatch the event. + * @see dragonBones.Armature + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 发出该事件的骨架。 + * @see dragonBones.Armature + * @version DragonBones 4.5 + * @language zh_CN + */ + armature: Armature; + /** + * - The bone that dispatch the event. + * @see dragonBones.Bone + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 发出该事件的骨骼。 + * @see dragonBones.Bone + * @version DragonBones 4.5 + * @language zh_CN + */ + bone: Bone | null; + /** + * - The slot that dispatch the event. + * @see dragonBones.Slot + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 发出该事件的插槽。 + * @see dragonBones.Slot + * @version DragonBones 4.5 + * @language zh_CN + */ + slot: Slot | null; + /** + * - The animation state that dispatch the event. + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 发出该事件的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + animationState: AnimationState; + /** + * - The custom data. + * @see dragonBones.CustomData + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 自定义数据。 + * @see dragonBones.CustomData + * @version DragonBones 5.0 + * @language zh_CN + */ + data: UserData | null; + /** + * @private + */ + protected _onClear(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @private + */ + type EventStringType = string | "start" | "loopComplete" | "complete" | "fadeIn" | "fadeInComplete" | "fadeOut" | "fadeOutComplete" | "frameEvent" | "soundEvent"; + /** + * - The event dispatcher interface. + * Dragonbones event dispatch usually relies on docking engine to implement, which defines the event method to be implemented when docking the engine. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 事件派发接口。 + * DragonBones 的事件派发通常依赖于对接的引擎来实现,该接口定义了对接引擎时需要实现的事件方法。 + * @version DragonBones 4.5 + * @language zh_CN + */ + interface IEventDispatcher { + /** + * - Checks whether the object has any listeners registered for a specific type of event。 + * @param type - Event type. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 检查是否为特定的事件类型注册了任何侦听器。 + * @param type - 事件类型。 + * @version DragonBones 4.5 + * @language zh_CN + */ + hasDBEventListener(type: EventStringType): boolean; + /** + * - Dispatches an event into the event flow. + * @param type - Event type. + * @param eventObject - Event object. + * @see dragonBones.EventObject + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 分派特定的事件到事件流中。 + * @param type - 事件类型。 + * @param eventObject - 事件数据。 + * @see dragonBones.EventObject + * @version DragonBones 4.5 + * @language zh_CN + */ + dispatchDBEvent(type: EventStringType, eventObject: EventObject): void; + /** + * - Add an event listener object so that the listener receives notification of an event. + * @param type - Event type. + * @param listener - Event listener. + * @param thisObject - The listener function's "this". + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 添加特定事件类型的事件侦听器,以使侦听器能够接收事件通知。 + * @param type - 事件类型。 + * @param listener - 事件侦听器。 + * @param thisObject - 侦听函数绑定的 this 对象。 + * @version DragonBones 4.5 + * @language zh_CN + */ + addDBEventListener(type: EventStringType, listener: Function, thisObject: any): void; + /** + * - Removes a listener from the object. + * @param type - Event type. + * @param listener - Event listener. + * @param thisObject - The listener function's "this". + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 删除特定事件类型的侦听器。 + * @param type - 事件类型。 + * @param listener - 事件侦听器。 + * @param thisObject - 侦听函数绑定的 this 对象。 + * @version DragonBones 4.5 + * @language zh_CN + */ + removeDBEventListener(type: EventStringType, listener: Function, thisObject: any): void; + /** + * - Deprecated, please refer to {@link #hasDBEventListener()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #hasDBEventListener()}。 + * @deprecated + * @language zh_CN + */ + hasEvent(type: EventStringType): boolean; + /** + * - Deprecated, please refer to {@link #addDBEventListener()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #addDBEventListener()}。 + * @deprecated + * @language zh_CN + */ + addEvent(type: EventStringType, listener: Function, thisObject: any): void; + /** + * - Deprecated, please refer to {@link #removeDBEventListener()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #removeDBEventListener()}。 + * @deprecated + * @language zh_CN + */ + removeEvent(type: EventStringType, listener: Function, thisObject: any): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + abstract class DataParser { + protected static readonly DATA_VERSION_2_3: string; + protected static readonly DATA_VERSION_3_0: string; + protected static readonly DATA_VERSION_4_0: string; + protected static readonly DATA_VERSION_4_5: string; + protected static readonly DATA_VERSION_5_0: string; + protected static readonly DATA_VERSION_5_5: string; + protected static readonly DATA_VERSION: string; + protected static readonly DATA_VERSIONS: Array; + protected static readonly TEXTURE_ATLAS: string; + protected static readonly SUB_TEXTURE: string; + protected static readonly FORMAT: string; + protected static readonly IMAGE_PATH: string; + protected static readonly WIDTH: string; + protected static readonly HEIGHT: string; + protected static readonly ROTATED: string; + protected static readonly FRAME_X: string; + protected static readonly FRAME_Y: string; + protected static readonly FRAME_WIDTH: string; + protected static readonly FRAME_HEIGHT: string; + protected static readonly DRADON_BONES: string; + protected static readonly USER_DATA: string; + protected static readonly ARMATURE: string; + protected static readonly BONE: string; + protected static readonly SURFACE: string; + protected static readonly SLOT: string; + protected static readonly CONSTRAINT: string; + protected static readonly IK: string; + protected static readonly SKIN: string; + protected static readonly DISPLAY: string; + protected static readonly ANIMATION: string; + protected static readonly Z_ORDER: string; + protected static readonly FFD: string; + protected static readonly FRAME: string; + protected static readonly TRANSLATE_FRAME: string; + protected static readonly ROTATE_FRAME: string; + protected static readonly SCALE_FRAME: string; + protected static readonly DISPLAY_FRAME: string; + protected static readonly COLOR_FRAME: string; + protected static readonly DEFAULT_ACTIONS: string; + protected static readonly ACTIONS: string; + protected static readonly EVENTS: string; + protected static readonly INTS: string; + protected static readonly FLOATS: string; + protected static readonly STRINGS: string; + protected static readonly CANVAS: string; + protected static readonly TRANSFORM: string; + protected static readonly PIVOT: string; + protected static readonly AABB: string; + protected static readonly COLOR: string; + protected static readonly VERSION: string; + protected static readonly COMPATIBLE_VERSION: string; + protected static readonly FRAME_RATE: string; + protected static readonly TYPE: string; + protected static readonly SUB_TYPE: string; + protected static readonly NAME: string; + protected static readonly PARENT: string; + protected static readonly TARGET: string; + protected static readonly STAGE: string; + protected static readonly SHARE: string; + protected static readonly PATH: string; + protected static readonly LENGTH: string; + protected static readonly DISPLAY_INDEX: string; + protected static readonly BLEND_MODE: string; + protected static readonly INHERIT_TRANSLATION: string; + protected static readonly INHERIT_ROTATION: string; + protected static readonly INHERIT_SCALE: string; + protected static readonly INHERIT_REFLECTION: string; + protected static readonly INHERIT_ANIMATION: string; + protected static readonly INHERIT_DEFORM: string; + protected static readonly SEGMENT_X: string; + protected static readonly SEGMENT_Y: string; + protected static readonly BEND_POSITIVE: string; + protected static readonly CHAIN: string; + protected static readonly WEIGHT: string; + protected static readonly FADE_IN_TIME: string; + protected static readonly PLAY_TIMES: string; + protected static readonly SCALE: string; + protected static readonly OFFSET: string; + protected static readonly POSITION: string; + protected static readonly DURATION: string; + protected static readonly TWEEN_EASING: string; + protected static readonly TWEEN_ROTATE: string; + protected static readonly TWEEN_SCALE: string; + protected static readonly CLOCK_WISE: string; + protected static readonly CURVE: string; + protected static readonly SOUND: string; + protected static readonly EVENT: string; + protected static readonly ACTION: string; + protected static readonly X: string; + protected static readonly Y: string; + protected static readonly SKEW_X: string; + protected static readonly SKEW_Y: string; + protected static readonly SCALE_X: string; + protected static readonly SCALE_Y: string; + protected static readonly VALUE: string; + protected static readonly ROTATE: string; + protected static readonly SKEW: string; + protected static readonly ALPHA_OFFSET: string; + protected static readonly RED_OFFSET: string; + protected static readonly GREEN_OFFSET: string; + protected static readonly BLUE_OFFSET: string; + protected static readonly ALPHA_MULTIPLIER: string; + protected static readonly RED_MULTIPLIER: string; + protected static readonly GREEN_MULTIPLIER: string; + protected static readonly BLUE_MULTIPLIER: string; + protected static readonly UVS: string; + protected static readonly VERTICES: string; + protected static readonly TRIANGLES: string; + protected static readonly WEIGHTS: string; + protected static readonly SLOT_POSE: string; + protected static readonly BONE_POSE: string; + protected static readonly GLUE_WEIGHTS: string; + protected static readonly GLUE_MESHES: string; + protected static readonly GOTO_AND_PLAY: string; + protected static readonly DEFAULT_NAME: string; + protected static _getArmatureType(value: string): ArmatureType; + protected static _getBoneType(value: string): BoneType; + protected static _getDisplayType(value: string): DisplayType; + protected static _getBoundingBoxType(value: string): BoundingBoxType; + protected static _getActionType(value: string): ActionType; + protected static _getBlendMode(value: string): BlendMode; + abstract parseDragonBonesData(rawData: any, scale: number): DragonBonesData | null; + abstract parseTextureAtlasData(rawData: any, textureAtlasData: TextureAtlasData, scale: number): boolean; + /** + * - Deprecated, please refer to {@link dragonBones.BaseFactory#parsetTextureAtlasData()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link dragonBones.BaseFactory#parsetTextureAtlasData()}。 + * @deprecated + * @language zh_CN + */ + static parseDragonBonesData(rawData: any): DragonBonesData | null; + /** + * - Deprecated, please refer to {@link dragonBones.BaseFactory#parsetTextureAtlasData()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link dragonBones.BaseFactory#parsetTextureAtlasData()}。 + * @deprecated + * @language zh_CN + */ + static parseTextureAtlasData(rawData: any, scale?: number): any; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + class ObjectDataParser extends DataParser { + protected static _getBoolean(rawData: any, key: string, defaultValue: boolean): boolean; + protected static _getNumber(rawData: any, key: string, defaultValue: number): number; + protected static _getString(rawData: any, key: string, defaultValue: string): string; + protected _rawTextureAtlasIndex: number; + protected readonly _rawBones: Array; + protected _data: DragonBonesData; + protected _armature: ArmatureData; + protected _bone: BoneData; + protected _surface: SurfaceData; + protected _slot: SlotData; + protected _skin: SkinData; + protected _mesh: MeshDisplayData; + protected _animation: AnimationData; + protected _timeline: TimelineData; + protected _rawTextureAtlases: Array | null; + private _defaultColorOffset; + private _prevClockwise; + private _prevRotation; + private readonly _helpMatrixA; + private readonly _helpMatrixB; + private readonly _helpTransform; + private readonly _helpColorTransform; + private readonly _helpPoint; + private readonly _helpArray; + private readonly _intArray; + private readonly _floatArray; + private readonly _frameIntArray; + private readonly _frameFloatArray; + private readonly _frameArray; + private readonly _timelineArray; + private readonly _cacheRawMeshes; + private readonly _cacheMeshes; + private readonly _actionFrames; + private readonly _weightSlotPose; + private readonly _weightBonePoses; + private readonly _cacheBones; + private readonly _slotChildActions; + private _getCurvePoint(x1, y1, x2, y2, x3, y3, x4, y4, t, result); + private _samplingEasingCurve(curve, samples); + private _parseActionDataInFrame(rawData, frameStart, bone, slot); + private _mergeActionFrame(rawData, frameStart, type, bone, slot); + protected _parseArmature(rawData: any, scale: number): ArmatureData; + protected _parseBone(rawData: any): BoneData; + protected _parseIKConstraint(rawData: any): ConstraintData | null; + protected _parseSlot(rawData: any, zOrder: number): SlotData; + protected _parseSkin(rawData: any): SkinData; + protected _parseDisplay(rawData: any): DisplayData | null; + protected _parsePivot(rawData: any, display: ImageDisplayData): void; + protected _parseMesh(rawData: any, mesh: MeshDisplayData): void; + protected _parseMeshGlue(rawData: any, mesh: MeshDisplayData): void; + protected _parseBoundingBox(rawData: any): BoundingBoxData | null; + protected _parsePolygonBoundingBox(rawData: any): PolygonBoundingBoxData; + protected _parseAnimation(rawData: any): AnimationData; + protected _parseTimeline(rawData: any, rawFrames: Array | null, framesKey: string, type: TimelineType, addIntOffset: boolean, addFloatOffset: boolean, frameValueCount: number, frameParser: (rawData: any, frameStart: number, frameCount: number) => number): TimelineData | null; + protected _parseBoneTimeline(rawData: any): void; + protected _parseSlotTimeline(rawData: any): void; + protected _parseFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseTweenFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseActionFrame(frame: ActionFrame, frameStart: number, frameCount: number): number; + protected _parseZOrderFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseBoneAllFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseBoneTranslateFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseBoneRotateFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseBoneScaleFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseSurfaceFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseSlotDisplayFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseSlotColorFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseSlotFFDFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseIKConstraintFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseAnimationFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseActionData(rawData: any, type: ActionType, bone: BoneData | null, slot: SlotData | null): Array; + protected _parseTransform(rawData: any, transform: Transform, scale: number): void; + protected _parseColorTransform(rawData: any, color: ColorTransform): void; + protected _parseArray(rawData: any): void; + protected _modifyArray(): void; + parseDragonBonesData(rawData: any, scale?: number): DragonBonesData | null; + parseTextureAtlasData(rawData: any, textureAtlasData: TextureAtlasData, scale?: number): boolean; + private static _objectDataParserInstance; + /** + * - Deprecated, please refer to {@link dragonBones.BaseFactory#parseDragonBonesData()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link dragonBones.BaseFactory#parseDragonBonesData()}。 + * @deprecated + * @language zh_CN + */ + static getInstance(): ObjectDataParser; + } + /** + * @internal + * @private + */ + class ActionFrame { + frameStart: number; + readonly actions: Array; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + class BinaryDataParser extends ObjectDataParser { + private _binaryOffset; + private _binary; + private _intArrayBuffer; + private _floatArrayBuffer; + private _frameIntArrayBuffer; + private _frameFloatArrayBuffer; + private _frameArrayBuffer; + private _timelineArrayBuffer; + private _inRange(a, min, max); + private _decodeUTF8(data); + private _getUTF16Key(value); + private _parseBinaryTimeline(type, offset, timelineData?); + protected _parseMesh(rawData: any, mesh: MeshDisplayData): void; + protected _parseAnimation(rawData: any): AnimationData; + protected _parseArray(rawData: any): void; + parseDragonBonesData(rawData: any, scale?: number): DragonBonesData | null; + private static _binaryDataParserInstance; + /** + * - Deprecated, please refer to {@link dragonBones.BaseFactory#parseDragonBonesData()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link dragonBones.BaseFactory#parseDragonBonesData()}。 + * @deprecated + * @language zh_CN + */ + static getInstance(): BinaryDataParser; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - Base class for the factory that create the armatures. (Typically only one global factory instance is required) + * The factory instance create armatures by parsed and added DragonBonesData instances and TextureAtlasData instances. + * Once the data has been parsed, it has been cached in the factory instance and does not need to be parsed again until it is cleared by the factory instance. + * @see dragonBones.DragonBonesData + * @see dragonBones.TextureAtlasData + * @see dragonBones.ArmatureData + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 创建骨架的工厂基类。 (通常只需要一个全局工厂实例) + * 工厂通过解析并添加的 DragonBonesData 实例和 TextureAtlasData 实例来创建骨架。 + * 当数据被解析过之后,已经添加到工厂中,在没有被工厂清理之前,不需要再次解析。 + * @see dragonBones.DragonBonesData + * @see dragonBones.TextureAtlasData + * @see dragonBones.ArmatureData + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + abstract class BaseFactory { + /** + * @private + */ + protected static _objectParser: ObjectDataParser; + /** + * @private + */ + protected static _binaryParser: BinaryDataParser; + /** + * @private + */ + autoSearch: boolean; + /** + * @private + */ + protected readonly _dragonBonesDataMap: Map; + /** + * @private + */ + protected readonly _textureAtlasDataMap: Map>; + /** + * @private + */ + protected _dragonBones: DragonBones; + /** + * @private + */ + protected _dataParser: DataParser; + /** + * - Create a factory instance. (typically only one global factory instance is required) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 创建一个工厂实例。 (通常只需要一个全局工厂实例) + * @version DragonBones 3.0 + * @language zh_CN + */ + constructor(dataParser?: DataParser | null); + /** + * @private + */ + protected _isSupportMesh(): boolean; + /** + * @private + */ + protected _getTextureData(textureAtlasName: string, textureName: string): TextureData | null; + /** + * @private + */ + protected _fillBuildArmaturePackage(dataPackage: BuildArmaturePackage, dragonBonesName: string, armatureName: string, skinName: string, textureAtlasName: string): boolean; + /** + * @private + */ + protected _buildBones(dataPackage: BuildArmaturePackage, armature: Armature): void; + /** + * @private + */ + protected _buildSlots(dataPackage: BuildArmaturePackage, armature: Armature): void; + /** + * @private + */ + protected _buildChildArmature(dataPackage: BuildArmaturePackage | null, slot: Slot, displayData: DisplayData): Armature | null; + /** + * @private + */ + protected _getSlotDisplay(dataPackage: BuildArmaturePackage | null, displayData: DisplayData, rawDisplayData: DisplayData | null, slot: Slot): any; + /** + * @private + */ + protected abstract _buildTextureAtlasData(textureAtlasData: TextureAtlasData | null, textureAtlas: any): TextureAtlasData; + /** + * @private + */ + protected abstract _buildArmature(dataPackage: BuildArmaturePackage): Armature; + /** + * @private + */ + protected abstract _buildSlot(dataPackage: BuildArmaturePackage, slotData: SlotData, displays: Array | null, armature: Armature): Slot; + /** + * - Parse the raw data to a DragonBonesData instance and cache it to the factory. + * @param rawData - The raw data. + * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (If not set, use the instance name instead) + * @param scale - Specify a scaling value for all armatures. (Default: 1.0) + * @returns DragonBonesData instance + * @see #getDragonBonesData() + * @see #addDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 将原始数据解析为 DragonBonesData 实例,并缓存到工厂中。 + * @param rawData - 原始数据。 + * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) + * @param scale - 为所有的骨架指定一个缩放值。 (默认: 1.0) + * @returns DragonBonesData 实例 + * @see #getDragonBonesData() + * @see #addDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 4.5 + * @language zh_CN + */ + parseDragonBonesData(rawData: any, name?: string | null, scale?: number): DragonBonesData | null; + /** + * - Parse the raw texture atlas data and the texture atlas object to a TextureAtlasData instance and cache it to the factory. + * @param rawData - The raw texture atlas data. + * @param textureAtlas - The texture atlas object. + * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (If not set, use the instance name instead) + * @param scale - Specify a scaling value for the map set. (Default: 1.0) + * @returns TextureAtlasData instance + * @see #getTextureAtlasData() + * @see #addTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 将原始贴图集数据和贴图集对象解析为 TextureAtlasData 实例,并缓存到工厂中。 + * @param rawData - 原始贴图集数据。 + * @param textureAtlas - 贴图集对象。 + * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) + * @param scale - 为贴图集指定一个缩放值。 (默认: 1.0) + * @returns TextureAtlasData 实例 + * @see #getTextureAtlasData() + * @see #addTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 4.5 + * @language zh_CN + */ + parseTextureAtlasData(rawData: any, textureAtlas: any, name?: string | null, scale?: number): TextureAtlasData; + /** + * @private + */ + updateTextureAtlasData(name: string, textureAtlases: Array): void; + /** + * - Get a specific DragonBonesData instance. + * @param name - The DragonBonesData instance cache name. + * @returns DragonBonesData instance + * @see #parseDragonBonesData() + * @see #addDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的 DragonBonesData 实例。 + * @param name - DragonBonesData 实例的缓存名称。 + * @returns DragonBonesData 实例 + * @see #parseDragonBonesData() + * @see #addDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language zh_CN + */ + getDragonBonesData(name: string): DragonBonesData | null; + /** + * - Cache a DragonBonesData instance to the factory. + * @param data - The DragonBonesData instance. + * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (if not set, use the instance name instead) + * @see #parseDragonBonesData() + * @see #getDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 将 DragonBonesData 实例缓存到工厂中。 + * @param data - DragonBonesData 实例。 + * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) + * @see #parseDragonBonesData() + * @see #getDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language zh_CN + */ + addDragonBonesData(data: DragonBonesData, name?: string | null): void; + /** + * - Remove a DragonBonesData instance. + * @param name - The DragonBonesData instance cache name. + * @param disposeData - Whether to dispose data. (Default: true) + * @see #parseDragonBonesData() + * @see #getDragonBonesData() + * @see #addDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 移除 DragonBonesData 实例。 + * @param name - DragonBonesData 实例缓存名称。 + * @param disposeData - 是否释放数据。 (默认: true) + * @see #parseDragonBonesData() + * @see #getDragonBonesData() + * @see #addDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language zh_CN + */ + removeDragonBonesData(name: string, disposeData?: boolean): void; + /** + * - Get a list of specific TextureAtlasData instances. + * @param name - The TextureAtlasData cahce name. + * @see #parseTextureAtlasData() + * @see #addTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的 TextureAtlasData 实例列表。 + * @param name - TextureAtlasData 实例缓存名称。 + * @see #parseTextureAtlasData() + * @see #addTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language zh_CN + */ + getTextureAtlasData(name: string): Array | null; + /** + * - Cache a TextureAtlasData instance to the factory. + * @param data - The TextureAtlasData instance. + * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (if not set, use the instance name instead) + * @see #parseTextureAtlasData() + * @see #getTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 将 TextureAtlasData 实例缓存到工厂中。 + * @param data - TextureAtlasData 实例。 + * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) + * @see #parseTextureAtlasData() + * @see #getTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language zh_CN + */ + addTextureAtlasData(data: TextureAtlasData, name?: string | null): void; + /** + * - Remove a TextureAtlasData instance. + * @param name - The TextureAtlasData instance cache name. + * @param disposeData - Whether to dispose data. + * @see #parseTextureAtlasData() + * @see #getTextureAtlasData() + * @see #addTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 移除 TextureAtlasData 实例。 + * @param name - TextureAtlasData 实例的缓存名称。 + * @param disposeData - 是否释放数据。 + * @see #parseTextureAtlasData() + * @see #getTextureAtlasData() + * @see #addTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language zh_CN + */ + removeTextureAtlasData(name: string, disposeData?: boolean): void; + /** + * - Get a specific armature data. + * @param name - The armature data name. + * @param dragonBonesName - The cached name for DragonbonesData instance. + * @see dragonBones.ArmatureData + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 获取特定的骨架数据。 + * @param name - 骨架数据名称。 + * @param dragonBonesName - DragonBonesData 实例的缓存名称。 + * @see dragonBones.ArmatureData + * @version DragonBones 5.1 + * @language zh_CN + */ + getArmatureData(name: string, dragonBonesName?: string): ArmatureData | null; + /** + * - Clear all cached DragonBonesData instances and TextureAtlasData instances. + * @param disposeData - Whether to dispose data. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 清除缓存的所有 DragonBonesData 实例和 TextureAtlasData 实例。 + * @param disposeData - 是否释放数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + clear(disposeData?: boolean): void; + /** + * - Create a armature from cached DragonBonesData instances and TextureAtlasData instances. + * @param armatureName - The armature data name. + * @param dragonBonesName - The cached name of the DragonBonesData instance. (If not set, all DragonBonesData instances are retrieved, and when multiple DragonBonesData instances contain a the same name armature data, it may not be possible to accurately create a specific armature) + * @param skinName - The skin name, you can set a different ArmatureData name to share it's skin data. (If not set, use the default skin data) + * @returns The armature. + * @example + *
+         *     let armature = factory.buildArmature("armatureName", "dragonBonesName");
+         *     armature.clock = factory.clock;
+         * 
+ * @see dragonBones.DragonBonesData + * @see dragonBones.ArmatureData + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 通过缓存的 DragonBonesData 实例和 TextureAtlasData 实例创建一个骨架。 + * @param armatureName - 骨架数据名称。 + * @param dragonBonesName - DragonBonesData 实例的缓存名称。 (如果未设置,将检索所有的 DragonBonesData 实例,当多个 DragonBonesData 实例中包含同名的骨架数据时,可能无法准确的创建出特定的骨架) + * @param skinName - 皮肤名称,可以设置一个其他骨架数据名称来共享其皮肤数据(如果未设置,则使用默认的皮肤数据)。 + * @returns 骨架。 + * @example + *
+         *     let armature = factory.buildArmature("armatureName", "dragonBonesName");
+         *     armature.clock = factory.clock;
+         * 
+ * @see dragonBones.DragonBonesData + * @see dragonBones.ArmatureData + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + buildArmature(armatureName: string, dragonBonesName?: string, skinName?: string, textureAtlasName?: string): Armature | null; + /** + * @private + */ + replaceDisplay(slot: Slot, displayData: DisplayData, displayIndex?: number): void; + /** + * - Replaces the current display data for a particular slot with a specific display data. + * Specify display data with "dragonBonesName/armatureName/slotName/displayName". + * @param dragonBonesName - The DragonBonesData instance cache name. + * @param armatureName - The armature data name. + * @param slotName - The slot data name. + * @param displayName - The display data name. + * @param slot - The slot. + * @param displayIndex - The index of the display data that is replaced. (If it is not set, replaces the current display data) + * @example + *
+         *     let slot = armature.getSlot("weapon");
+         *     factory.replaceSlotDisplay("dragonBonesName", "armatureName", "slotName", "displayName", slot);
+         * 
+ * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 用特定的显示对象数据替换特定插槽当前的显示对象数据。 + * 用 "dragonBonesName/armatureName/slotName/displayName" 指定显示对象数据。 + * @param dragonBonesName - DragonBonesData 实例的缓存名称。 + * @param armatureName - 骨架数据名称。 + * @param slotName - 插槽数据名称。 + * @param displayName - 显示对象数据名称。 + * @param slot - 插槽。 + * @param displayIndex - 被替换的显示对象数据的索引。 (如果未设置,则替换当前的显示对象数据) + * @example + *
+         *     let slot = armature.getSlot("weapon");
+         *     factory.replaceSlotDisplay("dragonBonesName", "armatureName", "slotName", "displayName", slot);
+         * 
+ * @version DragonBones 4.5 + * @language zh_CN + */ + replaceSlotDisplay(dragonBonesName: string, armatureName: string, slotName: string, displayName: string, slot: Slot, displayIndex?: number): boolean; + /** + * @private + */ + replaceSlotDisplayList(dragonBonesName: string | null, armatureName: string, slotName: string, slot: Slot): boolean; + /** + * - Share specific skin data with specific armature. + * @param armature - The armature. + * @param skin - The skin data. + * @param isOverride - Whether it completely override the original skin. (Default: false) + * @param exclude - A list of slot names that do not need to be replace. + * @example + *
+         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
+         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
+         *     if (armatureDataB && armatureDataB.defaultSkin) {
+         *     factory.replaceSkin(armatureA, armatureDataB.defaultSkin, false, ["arm_l", "weapon_l"]);
+         *     }
+         * 
+ * @see dragonBones.Armature + * @see dragonBones.SkinData + * @version DragonBones 5.6 + * @language en_US + */ + /** + * - 将特定的皮肤数据共享给特定的骨架使用。 + * @param armature - 骨架。 + * @param skin - 皮肤数据。 + * @param isOverride - 是否完全覆盖原来的皮肤。 (默认: false) + * @param exclude - 不需要被替换的插槽名称列表。 + * @example + *
+         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
+         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
+         *     if (armatureDataB && armatureDataB.defaultSkin) {
+         *     factory.replaceSkin(armatureA, armatureDataB.defaultSkin, false, ["arm_l", "weapon_l"]);
+         *     }
+         * 
+ * @see dragonBones.Armature + * @see dragonBones.SkinData + * @version DragonBones 5.6 + * @language zh_CN + */ + replaceSkin(armature: Armature, skin: SkinData, isOverride?: boolean, exclude?: Array | null): boolean; + /** + * - Replaces the existing animation data for a specific armature with the animation data for the specific armature data. + * This enables you to make a armature template so that other armature without animations can share it's animations. + * @param armature - The armtaure. + * @param armatureData - The armature data. + * @param isOverride - Whether to completely overwrite the original animation. (Default: false) + * @example + *
+         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
+         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
+         *     if (armatureDataB) {
+         *     factory.replaceAnimation(armatureA, armatureDataB);
+         *     }
+         * 
+ * @see dragonBones.Armature + * @see dragonBones.ArmatureData + * @version DragonBones 5.6 + * @language en_US + */ + /** + * - 用特定骨架数据的动画数据替换特定骨架现有的动画数据。 + * 这样就能实现制作一个骨架动画模板,让其他没有制作动画的骨架共享该动画。 + * @param armature - 骨架。 + * @param armatureData - 骨架数据。 + * @param isOverride - 是否完全覆盖原来的动画。(默认: false)。 + * @example + *
+         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
+         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
+         *     if (armatureDataB) {
+         *     factory.replaceAnimation(armatureA, armatureDataB);
+         *     }
+         * 
+ * @see dragonBones.Armature + * @see dragonBones.ArmatureData + * @version DragonBones 5.6 + * @language zh_CN + */ + replaceAnimation(armature: Armature, armatureData: ArmatureData, isOverride?: boolean): boolean; + /** + * @private + */ + getAllDragonBonesData(): Map; + /** + * @private + */ + getAllTextureAtlasData(): Map>; + /** + * - An Worldclock instance updated by engine. + * @version DragonBones 5.7 + * @language en_US + */ + /** + * - 由引擎驱动的 WorldClock 实例。 + * @version DragonBones 5.7 + * @language zh_CN + */ + readonly clock: WorldClock; + /** + * @private + */ + readonly dragonBones: DragonBones; + /** + * - Deprecated, please refer to {@link #replaceSkin}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #replaceSkin}。 + * @deprecated + * @language zh_CN + */ + changeSkin(armature: Armature, skin: SkinData, exclude?: Array | null): boolean; + /** + * - Deprecated, please refer to {@link #replaceAnimation}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #replaceAnimation}。 + * @deprecated + * @language zh_CN + */ + copyAnimationsToArmature(toArmature: Armature, fromArmatreName: string, fromSkinName?: string, fromDragonBonesDataName?: string, replaceOriginalAnimation?: boolean): boolean; + } + /** + * @internal + * @private + */ + class BuildArmaturePackage { + dataName: string; + textureAtlasName: string; + data: DragonBonesData; + armature: ArmatureData; + skin: SkinData | null; + } +} + +declare namespace sp.spine { + class Animation { + name: string; + timelines: Array; + timelineIds: Array; + duration: number; + constructor(name: string, timelines: Array, duration: number); + hasTimeline(id: number): boolean; + apply(skeleton: Skeleton, lastTime: number, time: number, loop: boolean, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + static binarySearch(values: ArrayLike, target: number, step?: number): number; + static linearSearch(values: ArrayLike, target: number, step: number): number; + } + interface Timeline { + apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + getPropertyId(): number; + } + enum MixBlend { + setup = 0, + first = 1, + replace = 2, + add = 3 + } + enum MixDirection { + mixIn = 0, + mixOut = 1 + } + enum TimelineType { + rotate = 0, + translate = 1, + scale = 2, + shear = 3, + attachment = 4, + color = 5, + deform = 6, + event = 7, + drawOrder = 8, + ikConstraint = 9, + transformConstraint = 10, + pathConstraintPosition = 11, + pathConstraintSpacing = 12, + pathConstraintMix = 13, + twoColor = 14 + } + abstract class CurveTimeline implements Timeline { + static LINEAR: number; + static STEPPED: number; + static BEZIER: number; + static BEZIER_SIZE: number; + private curves; + abstract getPropertyId(): number; + constructor(frameCount: number); + getFrameCount(): number; + setLinear(frameIndex: number): void; + setStepped(frameIndex: number): void; + getCurveType(frameIndex: number): number; + setCurve(frameIndex: number, cx1: number, cy1: number, cx2: number, cy2: number): void; + getCurvePercent(frameIndex: number, percent: number): number; + abstract apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class RotateTimeline extends CurveTimeline { + static ENTRIES: number; + static PREV_TIME: number; + static PREV_ROTATION: number; + static ROTATION: number; + boneIndex: number; + frames: ArrayLike; + constructor(frameCount: number); + getPropertyId(): number; + setFrame(frameIndex: number, time: number, degrees: number): void; + apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class TranslateTimeline extends CurveTimeline { + static ENTRIES: number; + static PREV_TIME: number; + static PREV_X: number; + static PREV_Y: number; + static X: number; + static Y: number; + boneIndex: number; + frames: ArrayLike; + constructor(frameCount: number); + getPropertyId(): number; + setFrame(frameIndex: number, time: number, x: number, y: number): void; + apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class ScaleTimeline extends TranslateTimeline { + constructor(frameCount: number); + getPropertyId(): number; + apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class ShearTimeline extends TranslateTimeline { + constructor(frameCount: number); + getPropertyId(): number; + apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class ColorTimeline extends CurveTimeline { + static ENTRIES: number; + static PREV_TIME: number; + static PREV_R: number; + static PREV_G: number; + static PREV_B: number; + static PREV_A: number; + static R: number; + static G: number; + static B: number; + static A: number; + slotIndex: number; + frames: ArrayLike; + constructor(frameCount: number); + getPropertyId(): number; + setFrame(frameIndex: number, time: number, r: number, g: number, b: number, a: number): void; + apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class TwoColorTimeline extends CurveTimeline { + static ENTRIES: number; + static PREV_TIME: number; + static PREV_R: number; + static PREV_G: number; + static PREV_B: number; + static PREV_A: number; + static PREV_R2: number; + static PREV_G2: number; + static PREV_B2: number; + static R: number; + static G: number; + static B: number; + static A: number; + static R2: number; + static G2: number; + static B2: number; + slotIndex: number; + frames: ArrayLike; + constructor(frameCount: number); + getPropertyId(): number; + setFrame(frameIndex: number, time: number, r: number, g: number, b: number, a: number, r2: number, g2: number, b2: number): void; + apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class AttachmentTimeline implements Timeline { + slotIndex: number; + frames: ArrayLike; + attachmentNames: Array; + constructor(frameCount: number); + getPropertyId(): number; + getFrameCount(): number; + setFrame(frameIndex: number, time: number, attachmentName: string): void; + apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class DeformTimeline extends CurveTimeline { + slotIndex: number; + attachment: VertexAttachment; + frames: ArrayLike; + frameVertices: Array>; + constructor(frameCount: number); + getPropertyId(): number; + setFrame(frameIndex: number, time: number, vertices: ArrayLike): void; + apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class EventTimeline implements Timeline { + frames: ArrayLike; + events: Array; + constructor(frameCount: number); + getPropertyId(): number; + getFrameCount(): number; + setFrame(frameIndex: number, event: Event): void; + apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class DrawOrderTimeline implements Timeline { + frames: ArrayLike; + drawOrders: Array>; + constructor(frameCount: number); + getPropertyId(): number; + getFrameCount(): number; + setFrame(frameIndex: number, time: number, drawOrder: Array): void; + apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class IkConstraintTimeline extends CurveTimeline { + static ENTRIES: number; + static PREV_TIME: number; + static PREV_MIX: number; + static PREV_SOFTNESS: number; + static PREV_BEND_DIRECTION: number; + static PREV_COMPRESS: number; + static PREV_STRETCH: number; + static MIX: number; + static SOFTNESS: number; + static BEND_DIRECTION: number; + static COMPRESS: number; + static STRETCH: number; + ikConstraintIndex: number; + frames: ArrayLike; + constructor(frameCount: number); + getPropertyId(): number; + setFrame(frameIndex: number, time: number, mix: number, softness: number, bendDirection: number, compress: boolean, stretch: boolean): void; + apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class TransformConstraintTimeline extends CurveTimeline { + static ENTRIES: number; + static PREV_TIME: number; + static PREV_ROTATE: number; + static PREV_TRANSLATE: number; + static PREV_SCALE: number; + static PREV_SHEAR: number; + static ROTATE: number; + static TRANSLATE: number; + static SCALE: number; + static SHEAR: number; + transformConstraintIndex: number; + frames: ArrayLike; + constructor(frameCount: number); + getPropertyId(): number; + setFrame(frameIndex: number, time: number, rotateMix: number, translateMix: number, scaleMix: number, shearMix: number): void; + apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class PathConstraintPositionTimeline extends CurveTimeline { + static ENTRIES: number; + static PREV_TIME: number; + static PREV_VALUE: number; + static VALUE: number; + pathConstraintIndex: number; + frames: ArrayLike; + constructor(frameCount: number); + getPropertyId(): number; + setFrame(frameIndex: number, time: number, value: number): void; + apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class PathConstraintSpacingTimeline extends PathConstraintPositionTimeline { + constructor(frameCount: number); + getPropertyId(): number; + apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class PathConstraintMixTimeline extends CurveTimeline { + static ENTRIES: number; + static PREV_TIME: number; + static PREV_ROTATE: number; + static PREV_TRANSLATE: number; + static ROTATE: number; + static TRANSLATE: number; + pathConstraintIndex: number; + frames: ArrayLike; + constructor(frameCount: number); + getPropertyId(): number; + setFrame(frameIndex: number, time: number, rotateMix: number, translateMix: number): void; + apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } +} +declare namespace sp.spine { + class AnimationState { + static emptyAnimation: Animation; + static SUBSEQUENT: number; + static FIRST: number; + static HOLD: number; + static HOLD_MIX: number; + static NOT_LAST: number; + data: AnimationStateData; + tracks: TrackEntry[]; + timeScale: number; + events: Event[]; + listeners: AnimationStateListener[]; + queue: EventQueue; + propertyIDs: IntSet; + animationsChanged: boolean; + trackEntryPool: Pool; + constructor(data: AnimationStateData); + update(delta: number): void; + updateMixingFrom(to: TrackEntry, delta: number): boolean; + apply(skeleton: Skeleton): boolean; + applyMixingFrom(to: TrackEntry, skeleton: Skeleton, blend: MixBlend): number; + applyRotateTimeline(timeline: Timeline, skeleton: Skeleton, time: number, alpha: number, blend: MixBlend, timelinesRotation: Array, i: number, firstFrame: boolean): void; + queueEvents(entry: TrackEntry, animationTime: number): void; + clearTracks(): void; + clearTrack(trackIndex: number): void; + setCurrent(index: number, current: TrackEntry, interrupt: boolean): void; + setAnimation(trackIndex: number, animationName: string, loop: boolean): TrackEntry; + setAnimationWith(trackIndex: number, animation: Animation, loop: boolean): TrackEntry; + addAnimation(trackIndex: number, animationName: string, loop: boolean, delay: number): TrackEntry; + addAnimationWith(trackIndex: number, animation: Animation, loop: boolean, delay: number): TrackEntry; + setEmptyAnimation(trackIndex: number, mixDuration: number): TrackEntry; + addEmptyAnimation(trackIndex: number, mixDuration: number, delay: number): TrackEntry; + setEmptyAnimations(mixDuration: number): void; + expandToIndex(index: number): TrackEntry; + trackEntry(trackIndex: number, animation: Animation, loop: boolean, last: TrackEntry): TrackEntry; + disposeNext(entry: TrackEntry): void; + _animationsChanged(): void; + computeHold(entry: TrackEntry): void; + computeNotLast(entry: TrackEntry): void; + getCurrent(trackIndex: number): TrackEntry; + addListener(listener: AnimationStateListener): void; + removeListener(listener: AnimationStateListener): void; + clearListeners(): void; + clearListenerNotifications(): void; + } + class TrackEntry { + animation: Animation; + next: TrackEntry; + mixingFrom: TrackEntry; + mixingTo: TrackEntry; + listener: AnimationStateListener; + trackIndex: number; + loop: boolean; + holdPrevious: boolean; + eventThreshold: number; + attachmentThreshold: number; + drawOrderThreshold: number; + animationStart: number; + animationEnd: number; + animationLast: number; + nextAnimationLast: number; + delay: number; + trackTime: number; + trackLast: number; + nextTrackLast: number; + trackEnd: number; + timeScale: number; + alpha: number; + mixTime: number; + mixDuration: number; + interruptAlpha: number; + totalAlpha: number; + mixBlend: MixBlend; + timelineMode: number[]; + timelineHoldMix: TrackEntry[]; + timelinesRotation: number[]; + reset(): void; + getAnimationTime(): number; + setAnimationLast(animationLast: number): void; + isComplete(): boolean; + resetRotationDirections(): void; + } + class EventQueue { + objects: Array; + drainDisabled: boolean; + animState: AnimationState; + constructor(animState: AnimationState); + start(entry: TrackEntry): void; + interrupt(entry: TrackEntry): void; + end(entry: TrackEntry): void; + dispose(entry: TrackEntry): void; + complete(entry: TrackEntry): void; + event(entry: TrackEntry, event: Event): void; + drain(): void; + clear(): void; + } + enum EventType { + start = 0, + interrupt = 1, + end = 2, + dispose = 3, + complete = 4, + event = 5 + } + interface AnimationStateListener { + start(entry: TrackEntry): void; + interrupt(entry: TrackEntry): void; + end(entry: TrackEntry): void; + dispose(entry: TrackEntry): void; + complete(entry: TrackEntry): void; + event(entry: TrackEntry, event: Event): void; + } + abstract class AnimationStateAdapter implements AnimationStateListener { + start(entry: TrackEntry): void; + interrupt(entry: TrackEntry): void; + end(entry: TrackEntry): void; + dispose(entry: TrackEntry): void; + complete(entry: TrackEntry): void; + event(entry: TrackEntry, event: Event): void; + } +} +declare namespace sp.spine { + class AnimationStateData { + skeletonData: SkeletonData; + animationToMixTime: Map; + defaultMix: number; + constructor(skeletonData: SkeletonData); + setMix(fromName: string, toName: string, duration: number): void; + setMixWith(from: Animation, to: Animation, duration: number): void; + getMix(from: Animation, to: Animation): number; + } +} +declare namespace sp.spine { + class AssetManager implements Disposable { + private pathPrefix; + private textureLoader; + private assets; + private errors; + private toLoad; + private loaded; + constructor(textureLoader: (image: HTMLImageElement) => any, pathPrefix?: string); + private static downloadText; + private static downloadBinary; + loadBinary(path: string, success?: (path: string, binary: Uint8Array) => void, error?: (path: string, error: string) => void): void; + loadText(path: string, success?: (path: string, text: string) => void, error?: (path: string, error: string) => void): void; + loadTexture(path: string, success?: (path: string, image: HTMLImageElement) => void, error?: (path: string, error: string) => void): void; + loadTextureData(path: string, data: string, success?: (path: string, image: HTMLImageElement) => void, error?: (path: string, error: string) => void): void; + loadTextureAtlas(path: string, success?: (path: string, atlas: TextureAtlas) => void, error?: (path: string, error: string) => void): void; + get(path: string): any; + remove(path: string): void; + removeAll(): void; + isLoadingComplete(): boolean; + getToLoad(): number; + getLoaded(): number; + dispose(): void; + hasErrors(): boolean; + getErrors(): Map; + } +} +declare namespace sp.spine { + class AtlasAttachmentLoader implements AttachmentLoader { + atlas: TextureAtlas; + constructor(atlas: TextureAtlas); + newRegionAttachment(skin: Skin, name: string, path: string): RegionAttachment; + newMeshAttachment(skin: Skin, name: string, path: string): MeshAttachment; + newBoundingBoxAttachment(skin: Skin, name: string): BoundingBoxAttachment; + newPathAttachment(skin: Skin, name: string): PathAttachment; + newPointAttachment(skin: Skin, name: string): PointAttachment; + newClippingAttachment(skin: Skin, name: string): ClippingAttachment; + } +} +declare namespace sp.spine { + enum BlendMode { + Normal = 0, + Additive = 1, + Multiply = 2, + Screen = 3 + } +} +declare namespace sp.spine { + class Bone implements Updatable { + data: BoneData; + skeleton: Skeleton; + parent: Bone; + children: Bone[]; + x: number; + y: number; + rotation: number; + scaleX: number; + scaleY: number; + shearX: number; + shearY: number; + ax: number; + ay: number; + arotation: number; + ascaleX: number; + ascaleY: number; + ashearX: number; + ashearY: number; + appliedValid: boolean; + a: number; + b: number; + c: number; + d: number; + worldY: number; + worldX: number; + sorted: boolean; + active: boolean; + constructor(data: BoneData, skeleton: Skeleton, parent: Bone); + isActive(): boolean; + update(): void; + updateWorldTransform(): void; + updateWorldTransformWith(x: number, y: number, rotation: number, scaleX: number, scaleY: number, shearX: number, shearY: number): void; + setToSetupPose(): void; + getWorldRotationX(): number; + getWorldRotationY(): number; + getWorldScaleX(): number; + getWorldScaleY(): number; + updateAppliedTransform(): void; + worldToLocal(world: Vector2): Vector2; + localToWorld(local: Vector2): Vector2; + worldToLocalRotation(worldRotation: number): number; + localToWorldRotation(localRotation: number): number; + rotateWorld(degrees: number): void; + } +} +declare namespace sp.spine { + class BoneData { + index: number; + name: string; + parent: BoneData; + length: number; + x: number; + y: number; + rotation: number; + scaleX: number; + scaleY: number; + shearX: number; + shearY: number; + transformMode: TransformMode; + skinRequired: boolean; + color: Color; + constructor(index: number, name: string, parent: BoneData); + } + enum TransformMode { + Normal = 0, + OnlyTranslation = 1, + NoRotationOrReflection = 2, + NoScale = 3, + NoScaleOrReflection = 4 + } +} +declare namespace sp.spine { + abstract class ConstraintData { + name: string; + order: number; + skinRequired: boolean; + constructor(name: string, order: number, skinRequired: boolean); + } +} +declare namespace sp.spine { + class Event { + data: EventData; + intValue: number; + floatValue: number; + stringValue: string; + time: number; + volume: number; + balance: number; + constructor(time: number, data: EventData); + } +} +declare namespace sp.spine { + class EventData { + name: string; + intValue: number; + floatValue: number; + stringValue: string; + audioPath: string; + volume: number; + balance: number; + constructor(name: string); + } +} +declare namespace sp.spine { + class IkConstraint implements Updatable { + data: IkConstraintData; + bones: Array; + target: Bone; + bendDirection: number; + compress: boolean; + stretch: boolean; + mix: number; + softness: number; + active: boolean; + constructor(data: IkConstraintData, skeleton: Skeleton); + isActive(): boolean; + apply(): void; + update(): void; + apply1(bone: Bone, targetX: number, targetY: number, compress: boolean, stretch: boolean, uniform: boolean, alpha: number): void; + apply2(parent: Bone, child: Bone, targetX: number, targetY: number, bendDir: number, stretch: boolean, softness: number, alpha: number): void; + } +} +declare namespace sp.spine { + class IkConstraintData extends ConstraintData { + bones: BoneData[]; + target: BoneData; + bendDirection: number; + compress: boolean; + stretch: boolean; + uniform: boolean; + mix: number; + softness: number; + constructor(name: string); + } +} +declare namespace sp.spine { + class PathConstraint implements Updatable { + static NONE: number; + static BEFORE: number; + static AFTER: number; + static epsilon: number; + data: PathConstraintData; + bones: Array; + target: Slot; + position: number; + spacing: number; + rotateMix: number; + translateMix: number; + spaces: number[]; + positions: number[]; + world: number[]; + curves: number[]; + lengths: number[]; + segments: number[]; + active: boolean; + constructor(data: PathConstraintData, skeleton: Skeleton); + isActive(): boolean; + apply(): void; + update(): void; + computeWorldPositions(path: PathAttachment, spacesCount: number, tangents: boolean, percentPosition: boolean, percentSpacing: boolean): number[]; + addBeforePosition(p: number, temp: Array, i: number, out: Array, o: number): void; + addAfterPosition(p: number, temp: Array, i: number, out: Array, o: number): void; + addCurvePosition(p: number, x1: number, y1: number, cx1: number, cy1: number, cx2: number, cy2: number, x2: number, y2: number, out: Array, o: number, tangents: boolean): void; + } +} +declare namespace sp.spine { + class PathConstraintData extends ConstraintData { + bones: BoneData[]; + target: SlotData; + positionMode: PositionMode; + spacingMode: SpacingMode; + rotateMode: RotateMode; + offsetRotation: number; + position: number; + spacing: number; + rotateMix: number; + translateMix: number; + constructor(name: string); + } + enum PositionMode { + Fixed = 0, + Percent = 1 + } + enum SpacingMode { + Length = 0, + Fixed = 1, + Percent = 2 + } + enum RotateMode { + Tangent = 0, + Chain = 1, + ChainScale = 2 + } +} +declare namespace sp.spine { + class SharedAssetManager implements Disposable { + private pathPrefix; + private clientAssets; + private queuedAssets; + private rawAssets; + private errors; + constructor(pathPrefix?: string); + private queueAsset; + loadText(clientId: string, path: string): void; + loadJson(clientId: string, path: string): void; + loadTexture(clientId: string, textureLoader: (image: HTMLImageElement) => any, path: string): void; + get(clientId: string, path: string): any; + private updateClientAssets; + isLoadingComplete(clientId: string): boolean; + dispose(): void; + hasErrors(): boolean; + getErrors(): Map; + } +} +declare namespace sp.spine { + class Skeleton { + data: SkeletonData; + bones: Array; + slots: Array; + drawOrder: Array; + ikConstraints: Array; + transformConstraints: Array; + pathConstraints: Array; + _updateCache: Updatable[]; + updateCacheReset: Updatable[]; + skin: Skin; + color: Color; + time: number; + scaleX: number; + scaleY: number; + x: number; + y: number; + constructor(data: SkeletonData); + updateCache(): void; + sortIkConstraint(constraint: IkConstraint): void; + sortPathConstraint(constraint: PathConstraint): void; + sortTransformConstraint(constraint: TransformConstraint): void; + sortPathConstraintAttachment(skin: Skin, slotIndex: number, slotBone: Bone): void; + sortPathConstraintAttachmentWith(attachment: Attachment, slotBone: Bone): void; + sortBone(bone: Bone): void; + sortReset(bones: Array): void; + updateWorldTransform(): void; + setToSetupPose(): void; + setBonesToSetupPose(): void; + setSlotsToSetupPose(): void; + getRootBone(): Bone; + findBone(boneName: string): Bone; + findBoneIndex(boneName: string): number; + findSlot(slotName: string): Slot; + findSlotIndex(slotName: string): number; + setSkinByName(skinName: string): void; + setSkin(newSkin: Skin): void; + getAttachmentByName(slotName: string, attachmentName: string): Attachment; + getAttachment(slotIndex: number, attachmentName: string): Attachment; + setAttachment(slotName: string, attachmentName: string): void; + findIkConstraint(constraintName: string): IkConstraint; + findTransformConstraint(constraintName: string): TransformConstraint; + findPathConstraint(constraintName: string): PathConstraint; + getBounds(offset: Vector2, size: Vector2, temp?: Array): void; + update(delta: number): void; + } +} +declare namespace sp.spine { + class SkeletonBinary { + static AttachmentTypeValues: number[]; + static TransformModeValues: TransformMode[]; + static PositionModeValues: PositionMode[]; + static SpacingModeValues: SpacingMode[]; + static RotateModeValues: RotateMode[]; + static BlendModeValues: BlendMode[]; + static BONE_ROTATE: number; + static BONE_TRANSLATE: number; + static BONE_SCALE: number; + static BONE_SHEAR: number; + static SLOT_ATTACHMENT: number; + static SLOT_COLOR: number; + static SLOT_TWO_COLOR: number; + static PATH_POSITION: number; + static PATH_SPACING: number; + static PATH_MIX: number; + static CURVE_LINEAR: number; + static CURVE_STEPPED: number; + static CURVE_BEZIER: number; + scale: number; + attachmentLoader: AttachmentLoader; + private linkedMeshes; + constructor(attachmentLoader: AttachmentLoader); + readSkeletonData(binary: Uint8Array): SkeletonData; + private readSkin; + private readAttachment; + private readVertices; + private readFloatArray; + private readShortArray; + private readAnimation; + private readCurve; + setCurve(timeline: CurveTimeline, frameIndex: number, cx1: number, cy1: number, cx2: number, cy2: number): void; + } +} +declare namespace sp.spine { + class SkeletonBounds { + minX: number; + minY: number; + maxX: number; + maxY: number; + boundingBoxes: BoundingBoxAttachment[]; + polygons: ArrayLike[]; + private polygonPool; + update(skeleton: Skeleton, updateAabb: boolean): void; + aabbCompute(): void; + aabbContainsPoint(x: number, y: number): boolean; + aabbIntersectsSegment(x1: number, y1: number, x2: number, y2: number): boolean; + aabbIntersectsSkeleton(bounds: SkeletonBounds): boolean; + containsPoint(x: number, y: number): BoundingBoxAttachment; + containsPointPolygon(polygon: ArrayLike, x: number, y: number): boolean; + intersectsSegment(x1: number, y1: number, x2: number, y2: number): BoundingBoxAttachment; + intersectsSegmentPolygon(polygon: ArrayLike, x1: number, y1: number, x2: number, y2: number): boolean; + getPolygon(boundingBox: BoundingBoxAttachment): ArrayLike; + getWidth(): number; + getHeight(): number; + } +} +declare namespace sp.spine { + class SkeletonClipping { + private triangulator; + private clippingPolygon; + private clipOutput; + clippedVertices: number[]; + clippedTriangles: number[]; + private scratch; + private clipAttachment; + private clippingPolygons; + clipStart(slot: Slot, clip: ClippingAttachment): number; + clipEndWithSlot(slot: Slot): void; + clipEnd(): void; + isClipping(): boolean; + clipTriangles(vertices: ArrayLike, verticesLength: number, triangles: ArrayLike, trianglesLength: number, uvs: ArrayLike, light: Color, dark: Color, twoColor: boolean): void; + clip(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, clippingArea: Array, output: Array): boolean; + static makeClockwise(polygon: ArrayLike): void; + } +} +declare namespace sp.spine { + class SkeletonData { + name: string; + bones: BoneData[]; + slots: SlotData[]; + skins: Skin[]; + defaultSkin: Skin; + events: EventData[]; + animations: Animation[]; + ikConstraints: IkConstraintData[]; + transformConstraints: TransformConstraintData[]; + pathConstraints: PathConstraintData[]; + x: number; + y: number; + width: number; + height: number; + version: string; + hash: string; + fps: number; + imagesPath: string; + audioPath: string; + findBone(boneName: string): BoneData; + findBoneIndex(boneName: string): number; + findSlot(slotName: string): SlotData; + findSlotIndex(slotName: string): number; + findSkin(skinName: string): Skin; + findEvent(eventDataName: string): EventData; + findAnimation(animationName: string): Animation; + findIkConstraint(constraintName: string): IkConstraintData; + findTransformConstraint(constraintName: string): TransformConstraintData; + findPathConstraint(constraintName: string): PathConstraintData; + findPathConstraintIndex(pathConstraintName: string): number; + } +} +declare namespace sp.spine { + class SkeletonJson { + attachmentLoader: AttachmentLoader; + scale: number; + private linkedMeshes; + constructor(attachmentLoader: AttachmentLoader); + readSkeletonData(json: string | any): SkeletonData; + readAttachment(map: any, skin: Skin, slotIndex: number, name: string, skeletonData: SkeletonData): Attachment; + readVertices(map: any, attachment: VertexAttachment, verticesLength: number): void; + readAnimation(map: any, name: string, skeletonData: SkeletonData): void; + readCurve(map: any, timeline: CurveTimeline, frameIndex: number): void; + getValue(map: any, prop: string, defaultValue: any): any; + static blendModeFromString(str: string): BlendMode; + static positionModeFromString(str: string): PositionMode; + static spacingModeFromString(str: string): SpacingMode; + static rotateModeFromString(str: string): RotateMode; + static transformModeFromString(str: string): TransformMode; + } +} +declare namespace sp.spine { + class SkinEntry { + slotIndex: number; + name: string; + attachment: Attachment; + constructor(slotIndex: number, name: string, attachment: Attachment); + } + class Skin { + name: string; + attachments: Map[]; + bones: BoneData[]; + constraints: ConstraintData[]; + constructor(name: string); + setAttachment(slotIndex: number, name: string, attachment: Attachment): void; + addSkin(skin: Skin): void; + copySkin(skin: Skin): void; + getAttachment(slotIndex: number, name: string): Attachment; + removeAttachment(slotIndex: number, name: string): void; + getAttachments(): Array; + getAttachmentsForSlot(slotIndex: number, attachments: Array): void; + clear(): void; + attachAll(skeleton: Skeleton, oldSkin: Skin): void; + } +} +declare namespace sp.spine { + class Slot { + data: SlotData; + bone: Bone; + color: Color; + darkColor: Color; + private attachment; + private attachmentTime; + deform: number[]; + constructor(data: SlotData, bone: Bone); + getSkeleton(): Skeleton; + getAttachment(): Attachment; + setAttachment(attachment: Attachment): void; + setAttachmentTime(time: number): void; + getAttachmentTime(): number; + setToSetupPose(): void; + } +} +declare namespace sp.spine { + class SlotData { + index: number; + name: string; + boneData: BoneData; + color: Color; + darkColor: Color; + attachmentName: string; + blendMode: BlendMode; + constructor(index: number, name: string, boneData: BoneData); + } +} +declare namespace sp.spine { + abstract class Texture { + protected _image: HTMLImageElement; + constructor(image: HTMLImageElement); + getImage(): HTMLImageElement; + abstract setFilters(minFilter: TextureFilter, magFilter: TextureFilter): void; + abstract setWraps(uWrap: TextureWrap, vWrap: TextureWrap): void; + abstract dispose(): void; + static filterFromString(text: string): TextureFilter; + static wrapFromString(text: string): TextureWrap; + } + enum TextureFilter { + Nearest = 9728, + Linear = 9729, + MipMap = 9987, + MipMapNearestNearest = 9984, + MipMapLinearNearest = 9985, + MipMapNearestLinear = 9986, + MipMapLinearLinear = 9987 + } + enum TextureWrap { + MirroredRepeat = 33648, + ClampToEdge = 33071, + Repeat = 10497 + } + class TextureRegion { + renderObject: any; + u: number; + v: number; + u2: number; + v2: number; + width: number; + height: number; + rotate: boolean; + offsetX: number; + offsetY: number; + originalWidth: number; + originalHeight: number; + } + class FakeTexture extends Texture { + setFilters(minFilter: TextureFilter, magFilter: TextureFilter): void; + setWraps(uWrap: TextureWrap, vWrap: TextureWrap): void; + dispose(): void; + } +} +declare namespace sp.spine { + class TextureAtlas implements Disposable { + pages: TextureAtlasPage[]; + regions: TextureAtlasRegion[]; + constructor(atlasText: string, textureLoader: (path: string) => any); + private load; + findRegion(name: string): TextureAtlasRegion; + dispose(): void; + } + class TextureAtlasPage { + name: string; + minFilter: TextureFilter; + magFilter: TextureFilter; + uWrap: TextureWrap; + vWrap: TextureWrap; + texture: Texture; + width: number; + height: number; + } + class TextureAtlasRegion extends TextureRegion { + page: TextureAtlasPage; + name: string; + x: number; + y: number; + index: number; + rotate: boolean; + degrees: number; + texture: Texture; + } +} +declare namespace sp.spine { + class TransformConstraint implements Updatable { + data: TransformConstraintData; + bones: Array; + target: Bone; + rotateMix: number; + translateMix: number; + scaleMix: number; + shearMix: number; + temp: Vector2; + active: boolean; + constructor(data: TransformConstraintData, skeleton: Skeleton); + isActive(): boolean; + apply(): void; + update(): void; + applyAbsoluteWorld(): void; + applyRelativeWorld(): void; + applyAbsoluteLocal(): void; + applyRelativeLocal(): void; + } +} +declare namespace sp.spine { + class TransformConstraintData extends ConstraintData { + bones: BoneData[]; + target: BoneData; + rotateMix: number; + translateMix: number; + scaleMix: number; + shearMix: number; + offsetRotation: number; + offsetX: number; + offsetY: number; + offsetScaleX: number; + offsetScaleY: number; + offsetShearY: number; + relative: boolean; + local: boolean; + constructor(name: string); + } +} +declare namespace sp.spine { + class Triangulator { + private convexPolygons; + private convexPolygonsIndices; + private indicesArray; + private isConcaveArray; + private triangles; + private polygonPool; + private polygonIndicesPool; + triangulate(verticesArray: ArrayLike): Array; + decompose(verticesArray: Array, triangles: Array): Array>; + private static isConcave; + private static positiveArea; + private static winding; + } +} +declare namespace sp.spine { + interface Updatable { + update(): void; + isActive(): boolean; + } +} +declare namespace sp.spine { + interface Map { + [key: string]: T; + } + class IntSet { + array: number[]; + add(value: number): boolean; + contains(value: number): boolean; + remove(value: number): void; + clear(): void; + } + interface Disposable { + dispose(): void; + } + interface Restorable { + restore(): void; + } + class Color { + r: number; + g: number; + b: number; + a: number; + static WHITE: Color; + static RED: Color; + static GREEN: Color; + static BLUE: Color; + static MAGENTA: Color; + constructor(r?: number, g?: number, b?: number, a?: number); + set(r: number, g: number, b: number, a: number): this; + setFromColor(c: Color): this; + setFromString(hex: string): this; + add(r: number, g: number, b: number, a: number): this; + clamp(): this; + static rgba8888ToColor(color: Color, value: number): void; + static rgb888ToColor(color: Color, value: number): void; + } + class MathUtils { + static PI: number; + static PI2: number; + static radiansToDegrees: number; + static radDeg: number; + static degreesToRadians: number; + static degRad: number; + static clamp(value: number, min: number, max: number): number; + static cosDeg(degrees: number): number; + static sinDeg(degrees: number): number; + static signum(value: number): number; + static toInt(x: number): number; + static cbrt(x: number): number; + static randomTriangular(min: number, max: number): number; + static randomTriangularWith(min: number, max: number, mode: number): number; + } + abstract class Interpolation { + protected abstract applyInternal(a: number): number; + apply(start: number, end: number, a: number): number; + } + class Pow extends Interpolation { + protected power: number; + constructor(power: number); + applyInternal(a: number): number; + } + class PowOut extends Pow { + constructor(power: number); + applyInternal(a: number): number; + } + class Utils { + static SUPPORTS_TYPED_ARRAYS: boolean; + static arrayCopy(source: ArrayLike, sourceStart: number, dest: ArrayLike, destStart: number, numElements: number): void; + static setArraySize(array: Array, size: number, value?: any): Array; + static ensureArrayCapacity(array: Array, size: number, value?: any): Array; + static newArray(size: number, defaultValue: T): Array; + static newFloatArray(size: number): ArrayLike; + static newShortArray(size: number): ArrayLike; + static toFloatArray(array: Array): number[] | Float32Array; + static toSinglePrecision(value: number): number; + static webkit602BugfixHelper(alpha: number, blend: MixBlend): void; + static contains(array: Array, element: T, identity?: boolean): boolean; + } + class DebugUtils { + static logBones(skeleton: Skeleton): void; + } + class Pool { + private items; + private instantiator; + constructor(instantiator: () => T); + obtain(): T; + free(item: T): void; + freeAll(items: ArrayLike): void; + clear(): void; + } + class Vector2 { + x: number; + y: number; + constructor(x?: number, y?: number); + set(x: number, y: number): Vector2; + length(): number; + normalize(): this; + } + class TimeKeeper { + maxDelta: number; + framesPerSecond: number; + delta: number; + totalTime: number; + private lastTime; + private frameCount; + private frameTime; + update(): void; + } + interface ArrayLike { + length: number; + [n: number]: T; + } + class WindowedMean { + values: Array; + addedValues: number; + lastValue: number; + mean: number; + dirty: boolean; + constructor(windowSize?: number); + hasEnoughData(): boolean; + addValue(value: number): void; + getMean(): number; + } +} +declare namespace sp.spine { + interface VertexEffect { + begin(skeleton: Skeleton): void; + transform(position: Vector2, uv: Vector2, light: Color, dark: Color): void; + end(): void; + } +} +interface Math { + fround(n: number): number; +} +declare namespace sp.spine { + abstract class Attachment { + name: string; + constructor(name: string); + abstract copy(): Attachment; + } + abstract class VertexAttachment extends Attachment { + private static nextID; + id: number; + bones: Array; + vertices: ArrayLike; + worldVerticesLength: number; + deformAttachment: VertexAttachment; + constructor(name: string); + computeWorldVertices(slot: Slot, start: number, count: number, worldVertices: ArrayLike, offset: number, stride: number): void; + copyTo(attachment: VertexAttachment): void; + } +} +declare namespace sp.spine { + interface AttachmentLoader { + newRegionAttachment(skin: Skin, name: string, path: string): RegionAttachment; + newMeshAttachment(skin: Skin, name: string, path: string): MeshAttachment; + newBoundingBoxAttachment(skin: Skin, name: string): BoundingBoxAttachment; + newPathAttachment(skin: Skin, name: string): PathAttachment; + newPointAttachment(skin: Skin, name: string): PointAttachment; + newClippingAttachment(skin: Skin, name: string): ClippingAttachment; + } +} +declare namespace sp.spine { + enum AttachmentType { + Region = 0, + BoundingBox = 1, + Mesh = 2, + LinkedMesh = 3, + Path = 4, + Point = 5, + Clipping = 6 + } +} +declare namespace sp.spine { + class BoundingBoxAttachment extends VertexAttachment { + color: Color; + constructor(name: string); + copy(): Attachment; + } +} +declare namespace sp.spine { + class ClippingAttachment extends VertexAttachment { + endSlot: SlotData; + color: Color; + constructor(name: string); + copy(): Attachment; + } +} +declare namespace sp.spine { + class MeshAttachment extends VertexAttachment { + region: TextureRegion; + path: string; + regionUVs: ArrayLike; + uvs: ArrayLike; + triangles: Array; + color: Color; + width: number; + height: number; + hullLength: number; + edges: Array; + private parentMesh; + tempColor: Color; + constructor(name: string); + updateUVs(): void; + getParentMesh(): MeshAttachment; + setParentMesh(parentMesh: MeshAttachment): void; + copy(): Attachment; + newLinkedMesh(): MeshAttachment; + } +} +declare namespace sp.spine { + class PathAttachment extends VertexAttachment { + lengths: Array; + closed: boolean; + constantSpeed: boolean; + color: Color; + constructor(name: string); + copy(): Attachment; + } +} +declare namespace sp.spine { + class PointAttachment extends VertexAttachment { + x: number; + y: number; + rotation: number; + color: Color; + constructor(name: string); + computeWorldPosition(bone: Bone, point: Vector2): Vector2; + computeWorldRotation(bone: Bone): number; + copy(): Attachment; + } +} +declare namespace sp.spine { + class RegionAttachment extends Attachment { + static OX1: number; + static OY1: number; + static OX2: number; + static OY2: number; + static OX3: number; + static OY3: number; + static OX4: number; + static OY4: number; + static X1: number; + static Y1: number; + static C1R: number; + static C1G: number; + static C1B: number; + static C1A: number; + static U1: number; + static V1: number; + static X2: number; + static Y2: number; + static C2R: number; + static C2G: number; + static C2B: number; + static C2A: number; + static U2: number; + static V2: number; + static X3: number; + static Y3: number; + static C3R: number; + static C3G: number; + static C3B: number; + static C3A: number; + static U3: number; + static V3: number; + static X4: number; + static Y4: number; + static C4R: number; + static C4G: number; + static C4B: number; + static C4A: number; + static U4: number; + static V4: number; + x: number; + y: number; + scaleX: number; + scaleY: number; + rotation: number; + width: number; + height: number; + color: Color; + path: string; + rendererObject: any; + region: TextureRegion; + offset: ArrayLike; + uvs: ArrayLike; + tempColor: Color; + constructor(name: string); + updateOffset(): void; + setRegion(region: TextureRegion): void; + computeWorldVertices(bone: Bone, worldVertices: ArrayLike, offset: number, stride: number): void; + copy(): Attachment; + } +} +declare namespace sp.spine { + class JitterEffect implements VertexEffect { + jitterX: number; + jitterY: number; + constructor(jitterX: number, jitterY: number); + begin(skeleton: Skeleton): void; + transform(position: Vector2, uv: Vector2, light: Color, dark: Color): void; + end(): void; + } +} +declare namespace sp.spine { + class SwirlEffect implements VertexEffect { + static interpolation: PowOut; + centerX: number; + centerY: number; + radius: number; + angle: number; + private worldX; + private worldY; + constructor(radius: number); + begin(skeleton: Skeleton): void; + transform(position: Vector2, uv: Vector2, light: Color, dark: Color): void; + end(): void; + } +} + +/** + * API for jsb module + * Author: haroel + * Homepage: https://github.com/haroel/creatorexDTS + */ +declare namespace jsb{ + export module reflection{ + /** + * https://docs.cocos.com/creator/manual/zh/advanced-topics/java-reflection.html + * call OBJC/Java static methods + * + * @param className + * @param methodName + * @param methodSignature + * @param parameters + */ + export function callStaticMethod (className: string, methodName: string, methodSignature: string, ...parameters:any): any; + } + /** + * 下载任务对象 + */ + export type DownloaderTask = { requestURL: string, storagePath: string, identifier: string }; + + /** + * Http file downloader for jsb! + */ + export class Downloader{ + /** + * create a download task + * @param requestURL + * @param storagePath + * @param identifier + */ + createDownloadFileTask (requestURL:string, storagePath:string, identifier?:string): DownloaderTask; + + setOnFileTaskSuccess (onSucceed: (task: DownloaderTask) => void): void; + + setOnTaskProgress (onProgress: (task: DownloaderTask, bytesReceived: number, totalBytesReceived: number, totalBytesExpected: number) => void): void; + + setOnTaskError (onError: (task: DownloaderTask, errorCode: number, errorCodeInternal: number, errorStr: string) => void): void; + + } + + export interface ManifestAsset { + md5: string; + path: string; + compressed: boolean; + size: number; + downloadState: number; + } + + export class Manifest { + constructor (manifestUrl: string); + constructor (content: string, manifestRoot: string); + parseFile (manifestUrl: string): void; + parseJSONString (content: string, manifestRoot: string): void; + + getManifestRoot (): string; + getManifestFileUrl (): string; + getVersionFileUrl (): string; + getSearchPaths (): [string]; + getVersion (): string; + getPackageUrl (): boolean; + + setUpdating (isUpdating: boolean): void; + isUpdating (): boolean; + isVersionLoaded (): boolean; + isLoaded (): boolean; + } + + export class EventAssetsManager { + // EventCode + static ERROR_NO_LOCAL_MANIFEST: number; + static ERROR_DOWNLOAD_MANIFEST: number; + static ERROR_PARSE_MANIFEST: number; + static NEW_VERSION_FOUND: number; + static ALREADY_UP_TO_DATE: number; + static UPDATE_PROGRESSION: number; + static ASSET_UPDATED: number; + static ERROR_UPDATING: number; + static UPDATE_FINISHED: number; + static UPDATE_FAILED: number; + static ERROR_DECOMPRESS: number; + + constructor (eventName: string, manager: AssetsManager, eventCode: number, + assetId?: string, message?: string, curleCode?: number, curlmCode?: number); + getAssetsManagerEx (): AssetsManager; + isResuming (): boolean; + + getDownloadedFiles (): number; + getDownloadedBytes (): number; + getTotalFiles (): number; + getTotalBytes (): number; + getPercent (): number; + getPercentByFile (): number; + + getEventCode (): number; + getMessage (): string; + getAssetId (): string; + getCURLECode (): number; + getCURLMCode (): number; + } + + export module AssetsManager { + export enum State { + UNINITED, + UNCHECKED, + PREDOWNLOAD_VERSION, + DOWNLOADING_VERSION, + VERSION_LOADED, + PREDOWNLOAD_MANIFEST, + DOWNLOADING_MANIFEST, + MANIFEST_LOADED, + NEED_UPDATE, + READY_TO_UPDATE, + UPDATING, + UNZIPPING, + UP_TO_DATE, + FAIL_TO_UPDATE, + } + } + + export class AssetsManager { + constructor (manifestUrl: string, storagePath: string, versionCompareHandle?: (versionA: string, versionB: string) => number); + static create (manifestUrl: string, storagePath: string): AssetsManager; + + getState (): AssetsManager.State; + getStoragePath (): string + getMaxConcurrentTask (): number; + // setMaxConcurrentTask (max: number): void; // actually not supported + + checkUpdate (): void; + prepareUpdate (): void; + update (): void; + isResuming (): boolean; + + getDownloadedFiles (): number; + getDownloadedBytes (): number; + getTotalFiles (): number; + getTotalBytes (): number; + downloadFailedAssets (): void; + + getLocalManifest (): Manifest; + loadLocalManifest (manifestUrl: string): boolean; + loadLocalManifest (localManifest: Manifest, storagePath: string): boolean; + getRemoteManifest (): Manifest; + loadRemoteManifest (remoteManifest: Manifest): boolean; + + /** + * Setup your own version compare handler, versionA and B is versions in string. + * if the return value greater than 0, versionA is greater than B, + * if the return value equals 0, versionA equals to B, + * if the return value smaller than 0, versionA is smaller than B. + */ + setVersionCompareHandle (versionCompareHandle?: (versionA: string, versionB: string) => number): void; + /** + * Setup the verification callback, Return true if the verification passed, otherwise return false + */ + setVerifyCallback (verifyCallback: (path: string, asset: ManifestAsset) => boolean): void; + setEventCallback (eventCallback: (event: EventAssetsManager) => void): void; + } + + /** + * FileUtils Helper class to handle file operations. + */ + export module fileUtils{ + /** + * Checks whether the path is an absolute path. + * + * @note On Android, if the parameter passed in is relative to "@assets/", this method will treat it as an absolute path. + * Also on Blackberry, path starts with "app/native/Resources/" is treated as an absolute path. + * + * @param path The path that needs to be checked. + * @return True if it's an absolute path, false if not. + */ + export function isAbsolutePath (path:string):boolean; + /** Returns the fullpath for a given filename. + + First it will try to get a new filename from the "filenameLookup" dictionary. + If a new filename can't be found on the dictionary, it will use the original filename. + Then it will try to obtain the full path of the filename using the FileUtils search rules: resolutions, and search paths. + The file search is based on the array element order of search paths and resolution directories. + + For instance: + + We set two elements("/mnt/sdcard/", "internal_dir/") to search paths vector by setSearchPaths, + and set three elements("resources-ipadhd/", "resources-ipad/", "resources-iphonehd") + to resolutions vector by setSearchResolutionsOrder. The "internal_dir" is relative to "Resources/". + + If we have a file named 'sprite.png', the mapping in fileLookup dictionary contains `key: sprite.png -> value: sprite.pvr.gz`. + Firstly, it will replace 'sprite.png' with 'sprite.pvr.gz', then searching the file sprite.pvr.gz as follows: + + /mnt/sdcard/resources-ipadhd/sprite.pvr.gz (if not found, search next) + /mnt/sdcard/resources-ipad/sprite.pvr.gz (if not found, search next) + /mnt/sdcard/resources-iphonehd/sprite.pvr.gz (if not found, search next) + /mnt/sdcard/sprite.pvr.gz (if not found, search next) + internal_dir/resources-ipadhd/sprite.pvr.gz (if not found, search next) + internal_dir/resources-ipad/sprite.pvr.gz (if not found, search next) + internal_dir/resources-iphonehd/sprite.pvr.gz (if not found, search next) + internal_dir/sprite.pvr.gz (if not found, return "sprite.png") + + If the filename contains relative path like "gamescene/uilayer/sprite.png", + and the mapping in fileLookup dictionary contains `key: gamescene/uilayer/sprite.png -> value: gamescene/uilayer/sprite.pvr.gz`. + The file search order will be: + + /mnt/sdcard/gamescene/uilayer/resources-ipadhd/sprite.pvr.gz (if not found, search next) + /mnt/sdcard/gamescene/uilayer/resources-ipad/sprite.pvr.gz (if not found, search next) + /mnt/sdcard/gamescene/uilayer/resources-iphonehd/sprite.pvr.gz (if not found, search next) + /mnt/sdcard/gamescene/uilayer/sprite.pvr.gz (if not found, search next) + internal_dir/gamescene/uilayer/resources-ipadhd/sprite.pvr.gz (if not found, search next) + internal_dir/gamescene/uilayer/resources-ipad/sprite.pvr.gz (if not found, search next) + internal_dir/gamescene/uilayer/resources-iphonehd/sprite.pvr.gz (if not found, search next) + internal_dir/gamescene/uilayer/sprite.pvr.gz (if not found, return "gamescene/uilayer/sprite.png") + + If the new file can't be found on the file system, it will return the parameter filename directly. + + This method was added to simplify multiplatform support. Whether you are using cocos2d-js or any cross-compilation toolchain like StellaSDK or Apportable, + you might need to load different resources for a given file in the different platforms. + + @since v2.1 + */ + export function fullPathForFilename (filename:string):string; + /** + * Gets string from a file. + */ + export function getStringFromFile (filename:string):string; + /** + * Removes a file. + * + * @param filepath The full path of the file, it must be an absolute path. + * @return True if the file have been removed successfully, false if not. + */ + export function removeFile (filepath:string):boolean; + /** + * Checks whether the path is a directory. + * + * @param dirPath The path of the directory, it could be a relative or an absolute path. + * @return True if the directory exists, false if not. + */ + export function isDirectoryExist (dirPath:string):boolean; + /** + * Normalize: remove . and .. + * @param filepath + */ + export function normalizePath (filepath:string):string; + /** + * Get default resource root path. + */ + export function getDefaultResourceRootPath ():string; + /** + * Loads the filenameLookup dictionary from the contents of a filename. + * + * @note The plist file name should follow the format below: + * + * @code + * + * + * + * + * filenames + * + * sounds/click.wav + * sounds/click.caf + * sounds/endgame.wav + * sounds/endgame.caf + * sounds/gem-0.wav + * sounds/gem-0.caf + * + * metadata + * + * version + * 1 + * + * + * + * @endcode + * @param filename The plist file name. + * + @since v2.1 + * @js loadFilenameLookup + * @lua loadFilenameLookup + */ + export function loadFilenameLookup (filepath:string):void; + /** Checks whether to pop up a message box when failed to load an image. + * @return True if pop up a message box when failed to load an image, false if not. + */ + export function isPopupNotify ():boolean; + /** + * Sets whether to pop-up a message box when failed to load an image. + */ + export function setPopupNotify (notify:boolean):void; + + // Converts the contents of a file to a ValueVector. + // This method is used internally. + export function getValueVectorFromFile (filepath:string):Array; + /** + * Gets the array of search paths. + * + * @return The array of search paths which may contain the prefix of default resource root path. + * @note In best practise, getter function should return the value of setter function passes in. + * But since we should not break the compatibility, we keep using the old logic. + * Therefore, If you want to get the original search paths, please call 'getOriginalSearchPaths()' instead. + * @see fullPathForFilename(const char*). + * @lua NA + */ + export function getSearchPaths ():Array; + /** + * + * @param filepath + */ + export function getFileDir (filepath:string):string; + /** + * write a ValueMap into a plist file + * + *@param dict the ValueMap want to save (key,value) + *@param fullPath The full path to the file you want to save a string + *@return bool + */ + export function writeToFile ( valueMap:any ):boolean; + /** + * Gets the original search path array set by 'setSearchPaths' or 'addSearchPath'. + * @return The array of the original search paths + */ + export function getOriginalSearchPaths ():Array; + /** + * List all files in a directory. + * + * @param dirPath The path of the directory, it could be a relative or an absolute path. + * @return File paths in a string vector + */ + export function listFiles (filepath:string):Array; + /** + * Converts the contents of a file to a ValueMap. + * @param filename The filename of the file to gets content. + * @return ValueMap of the file contents. + * @note This method is used internally. + */ + export function getValueMapFromFile (filepath:string):any; + /** + * Retrieve the file size. + * + * @note If a relative path was passed in, it will be inserted a default root path at the beginning. + * @param filepath The path of the file, it could be a relative or absolute path. + * @return The file size. + */ + export function getFileSize (filepath:string):number; + + /** Converts the contents of a file to a ValueMap. + * This method is used internally. + */ + export function getValueMapFromData (filedata:string,filesize:number):any; + /** + * Removes a directory. + * + * @param dirPath The full path of the directory, it must be an absolute path. + * @return True if the directory have been removed successfully, false if not. + */ + export function removeDirectory (dirPath:string):boolean; + /** + * Sets the array of search paths. + * + * You can use this array to modify the search path of the resources. + * If you want to use "themes" or search resources in the "cache", you can do it easily by adding new entries in this array. + * + * @note This method could access relative path and absolute path. + * If the relative path was passed to the vector, FileUtils will add the default resource directory before the relative path. + * For instance: + * On Android, the default resource root path is "@assets/". + * If "/mnt/sdcard/" and "resources-large" were set to the search paths vector, + * "resources-large" will be converted to "@assets/resources-large" since it was a relative path. + * + * @param searchPaths The array contains search paths. + * @see fullPathForFilename(const char*) + * @since v2.1 + * In js:var setSearchPaths(var jsval); + * @lua NA + */ + export function setSearchPaths ( searchPath:Array):void; + /** + * write a string into a file + * + * @param dataStr the string want to save + * @param fullPath The full path to the file you want to save a string + * @return bool True if write success + */ + export function writeStringToFile (dataStr:string,fullPath:string):boolean; + /** + * Sets the array that contains the search order of the resources. + * + * @param searchResolutionsOrder The source array that contains the search order of the resources. + * @see getSearchResolutionsOrder(), fullPathForFilename(const char*). + * @since v2.1 + * In js:var setSearchResolutionsOrder(var jsval) + * @lua NA + */ + export function setSearchResolutionsOrder (searchResolutionsOrder:Array):void; + /** + * Append search order of the resources. + * + * @see setSearchResolutionsOrder(), fullPathForFilename(). + * @since v2.1 + */ + export function addSearchResolutionsOrder (order:string,front:boolean):void; + /** + * Add search path. + * + * @since v2.1 + */ + export function addSearchPath (path:string,front:boolean):void; + /** + * write ValueVector into a plist file + * + *@param vecData the ValueVector want to save + *@param fullPath The full path to the file you want to save a string + *@return bool + */ + export function writeValueVectorToFile (vecData:Array,fullPath:string):boolean; + /** + * Checks whether a file exists. + * + * @note If a relative path was passed in, it will be inserted a default root path at the beginning. + * @param filename The path of the file, it could be a relative or absolute path. + * @return True if the file exists, false if not. + */ + export function isFileExist (filename:string):boolean; + /**©∫ + * Purges full path caches. + */ + export function purgeCachedEntries ():void; + /** + * Gets full path from a file name and the path of the relative file. + * @param filename The file name. + * @param relativeFile The path of the relative file. + * @return The full path. + * e.g. filename: hello.png, pszRelativeFile: /User/path1/path2/hello.plist + * Return: /User/path1/path2/hello.pvr (If there a a key(hello.png)-value(hello.pvr) in FilenameLookup dictionary. ) + * + */ + export function fullPathFromRelativeFile (filename:string,relativeFile:string):string; + /** + * Windows fopen can't support UTF-8 filename + * Need convert all parameters fopen and other 3rd-party libs + * + * @param filenameUtf8 std::string name file for conversion from utf-8 + * @return std::string ansi filename in current locale + */ + export function getSuitableFOpen (filenameUtf8:string):string; + /** + * write ValueMap into a plist file + * + *@param dict the ValueMap want to save + *@param fullPath The full path to the file you want to save a string + *@return bool + */ + export function writeValueMapToFile (dict:any,fullPath:string):string; + /** + * Gets filename extension is a suffix (separated from the base filename by a dot) in lower case. + * Examples of filename extensions are .png, .jpeg, .exe, .dmg and .txt. + * @param filePath The path of the file, it could be a relative or absolute path. + * @return suffix for filename in lower case or empty if a dot not found. + */ + export function getFileExtension (filePath:string):string; + /** + * Sets writable path. + */ + export function setWritablePath (writablePath:string):void; + /** + * Set default resource root path. + */ + export function setDefaultResourceRootPath (filepath:string):void; + + /** + * Gets the array that contains the search order of the resources. + * + * @see setSearchResolutionsOrder(const std::vector&), fullPathForFilename(const char*). + * @since v2.1 + * @lua NA + */ + export function getSearchResolutionsOrder ():Array; + /** + * Creates a directory. + * + * @param dirPath The path of the directory, it must be an absolute path. + * @return True if the directory have been created successfully, false if not. + */ + export function createDirectory (dirPath:string):string; + /** + * List all files recursively in a directory. + * + * @param dirPath The path of the directory, it could be a relative or an absolute path. + * @return File paths in a string vector + */ + export function listFilesRecursively (dirPath:string, files:Array):void; + /** + * Gets the writable path. + * @return The path that can be write/read a file in + */ + export function getWritablePath ():string; + } +} + +/** Running in the editor. */ +declare const CC_EDITOR: boolean; +/** Preview in browser or simulator. */ +declare const CC_PREVIEW: boolean; +/** Running in the editor or preview. */ +declare const CC_DEV: boolean; +/** Running in the editor or preview, or build in debug mode. */ +declare const CC_DEBUG: boolean; +/** Running in published project. */ +declare const CC_BUILD: boolean; +/** Running in native platforms (mobile app, desktop app, or simulator). */ +declare const CC_JSB: boolean; +/** Running in runtime environments. */ +declare const CC_RUNTIME: boolean; +/** Running in the engine's unit test. */ +declare const CC_TEST: boolean; +/** Running in the WeChat Mini Game. */ +declare const CC_WECHATGAME: boolean; diff --git a/Layered_virtual_list_2.x/jsconfig.json b/Layered_virtual_list_2.x/jsconfig.json new file mode 100644 index 0000000..05394dd --- /dev/null +++ b/Layered_virtual_list_2.x/jsconfig.json @@ -0,0 +1,13 @@ +{ + "compilerOptions": { + "target": "es6", + "module": "commonjs" + }, + "exclude": [ + "node_modules", + "library", + "local", + "settings", + "temp" + ] +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/00/0004d1cf-a0ad-47d8-ab17-34d3db9d35a3.json b/Layered_virtual_list_2.x/library/imports/00/0004d1cf-a0ad-47d8-ab17-34d3db9d35a3.json new file mode 100644 index 0000000..ee16172 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/00/0004d1cf-a0ad-47d8-ab17-34d3db9d35a3.json @@ -0,0 +1,409 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "slider", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 1, + "asyncLoadAssets": false, + "readonly": false + }, + { + "__type__": "cc.Node", + "_name": "slider", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + }, + { + "__id__": 5 + } + ], + "_active": true, + "_components": [ + { + "__id__": 9 + } + ], + "_prefab": { + "__id__": 10 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 300, + "height": 20 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Background", + "_objFlags": 512, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 3 + } + ], + "_prefab": { + "__id__": 4 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 300, + "height": 20 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "31d8962d-babb-4ec7-be19-8e9f54a4ea99" + }, + "_type": 1, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "0004d1cf-a0ad-47d8-ab17-34d3db9d35a3" + }, + "fileId": "f43c4gNvOtBE41OTztiOT6T", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "Handle", + "_objFlags": 512, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 6 + }, + { + "__id__": 7 + } + ], + "_prefab": { + "__id__": 8 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 32, + "height": 32 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 5 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "e7aba14b-f956-4480-b254-8d57832e273f" + }, + "_type": 1, + "_sizeMode": 2, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "" + }, + { + "__type__": "cc.Button", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 5 + }, + "_enabled": true, + "_normalMaterial": null, + "_grayMaterial": null, + "duration": 0.1, + "zoomScale": 1.1, + "clickEvents": [], + "_N$interactable": true, + "_N$enableAutoGrayEffect": true, + "_N$transition": 3, + "transition": 3, + "_N$normalColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$pressedColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "pressedColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$disabledColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$normalSprite": { + "__uuid__": "e7aba14b-f956-4480-b254-8d57832e273f" + }, + "_N$pressedSprite": { + "__uuid__": "e7aba14b-f956-4480-b254-8d57832e273f" + }, + "pressedSprite": { + "__uuid__": "e7aba14b-f956-4480-b254-8d57832e273f" + }, + "_N$hoverSprite": { + "__uuid__": "e7aba14b-f956-4480-b254-8d57832e273f" + }, + "hoverSprite": { + "__uuid__": "e7aba14b-f956-4480-b254-8d57832e273f" + }, + "_N$disabledSprite": { + "__uuid__": "29158224-f8dd-4661-a796-1ffab537140e" + }, + "_N$target": { + "__id__": 5 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "0004d1cf-a0ad-47d8-ab17-34d3db9d35a3" + }, + "fileId": "93f4b6UTvtD0Iy5hi3tLIn2", + "sync": false + }, + { + "__type__": "cc.Slider", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "direction": 0, + "slideEvents": [], + "_N$handle": { + "__id__": 7 + }, + "_N$progress": 0.5, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "0004d1cf-a0ad-47d8-ab17-34d3db9d35a3" + }, + "fileId": "8ac42iRpDlK6pemd22ZO6x/", + "sync": false + } +] \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/02/0275e94c-56a7-410f-bd1a-fc7483f7d14a.json b/Layered_virtual_list_2.x/library/imports/02/0275e94c-56a7-410f-bd1a-fc7483f7d14a.json new file mode 100644 index 0000000..e7522d6 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/02/0275e94c-56a7-410f-bd1a-fc7483f7d14a.json @@ -0,0 +1,4 @@ +{ + "__type__": "cc.Texture2D", + "content": "0,9729,9729,33071,33071,0,0,1" +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/02/0275e94c-56a7-410f-bd1a-fc7483f7d14a.png b/Layered_virtual_list_2.x/library/imports/02/0275e94c-56a7-410f-bd1a-fc7483f7d14a.png new file mode 100644 index 0000000..fa6376e Binary files /dev/null and b/Layered_virtual_list_2.x/library/imports/02/0275e94c-56a7-410f-bd1a-fc7483f7d14a.png differ diff --git a/Layered_virtual_list_2.x/library/imports/02/0291c134-b3da-4098-b7b5-e397edbe947f.json b/Layered_virtual_list_2.x/library/imports/02/0291c134-b3da-4098-b7b5-e397edbe947f.json new file mode 100644 index 0000000..e7522d6 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/02/0291c134-b3da-4098-b7b5-e397edbe947f.json @@ -0,0 +1,4 @@ +{ + "__type__": "cc.Texture2D", + "content": "0,9729,9729,33071,33071,0,0,1" +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/02/0291c134-b3da-4098-b7b5-e397edbe947f.png b/Layered_virtual_list_2.x/library/imports/02/0291c134-b3da-4098-b7b5-e397edbe947f.png new file mode 100644 index 0000000..147354d Binary files /dev/null and b/Layered_virtual_list_2.x/library/imports/02/0291c134-b3da-4098-b7b5-e397edbe947f.png differ diff --git a/Layered_virtual_list_2.x/library/imports/04/046f172c-1574-488b-bbb8-6415a9adb96d.bin b/Layered_virtual_list_2.x/library/imports/04/046f172c-1574-488b-bbb8-6415a9adb96d.bin new file mode 100644 index 0000000..bafcd5d Binary files /dev/null and b/Layered_virtual_list_2.x/library/imports/04/046f172c-1574-488b-bbb8-6415a9adb96d.bin differ diff --git a/Layered_virtual_list_2.x/library/imports/04/046f172c-1574-488b-bbb8-6415a9adb96d.json b/Layered_virtual_list_2.x/library/imports/04/046f172c-1574-488b-bbb8-6415a9adb96d.json new file mode 100644 index 0000000..1685753 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/04/046f172c-1574-488b-bbb8-6415a9adb96d.json @@ -0,0 +1,90 @@ +[ + { + "__type__": "cc.Mesh", + "_name": "", + "_objFlags": 0, + "_native": ".bin", + "_vertexBundles": [ + { + "__id__": 1 + } + ], + "_primitives": [ + { + "__id__": 6 + } + ], + "_minPos": { + "__type__": "cc.Vec3", + "x": -0.5, + "y": -0.5, + "z": -0.5 + }, + "_maxPos": { + "__type__": "cc.Vec3", + "x": 0.5, + "y": 0.5, + "z": 0.5 + } + }, + { + "__type__": "cc.mesh.VertexBundle", + "data": { + "__id__": 2 + }, + "formats": [ + { + "__id__": 3 + }, + { + "__id__": 4 + }, + { + "__id__": 5 + } + ], + "verticesCount": 24 + }, + { + "__type__": "cc.BufferRange", + "offset": 0, + "length": 768 + }, + { + "__type__": "cc.mesh.VertexFormat", + "name": "a_normal", + "type": 5126, + "num": 3, + "normalize": false + }, + { + "__type__": "cc.mesh.VertexFormat", + "name": "a_position", + "type": 5126, + "num": 3, + "normalize": false + }, + { + "__type__": "cc.mesh.VertexFormat", + "name": "a_uv0", + "type": 5126, + "num": 2, + "normalize": false + }, + { + "__type__": "cc.mesh.Primitive", + "vertexBundleIndices": [ + 0 + ], + "data": { + "__id__": 7 + }, + "indexUnit": 5123, + "topology": 4 + }, + { + "__type__": "cc.BufferRange", + "offset": 768, + "length": 72 + } +] \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/0c/0cf30284-9073-46bc-9eba-e62b69dbbff3.json b/Layered_virtual_list_2.x/library/imports/0c/0cf30284-9073-46bc-9eba-e62b69dbbff3.json new file mode 100644 index 0000000..09feeb5 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/0c/0cf30284-9073-46bc-9eba-e62b69dbbff3.json @@ -0,0 +1,117 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "point", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "asyncLoadAssets": false, + "readonly": false + }, + { + "__type__": "cc.Node", + "_name": "light", + "_objFlags": 0, + "_parent": null, + "_children": [], + "_active": true, + "_level": 1, + "_components": [ + { + "__id__": 2 + } + ], + "_prefab": { + "__id__": 3 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "groupIndex": 0, + "_id": "", + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Light", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "_type": 1, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_intensity": 1, + "_range": 1000, + "_spotAngle": 60, + "_spotExp": 1, + "_shadowType": 0, + "_shadowResolution": 1024, + "_shadowDarkness": 0.5, + "_shadowMinDepth": 1, + "_shadowMaxDepth": 1000, + "_shadowDepthScale": 250, + "_shadowFrustumSize": 50, + "_shadowBias": 0.0005, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "0cf30284-9073-46bc-9eba-e62b69dbbff3" + }, + "fileId": "33zOkteexCqamZ4PXuwJaW", + "sync": false + } +] \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/0d/0d784963-d024-4ea6-a7db-03be0ad63010.json b/Layered_virtual_list_2.x/library/imports/0d/0d784963-d024-4ea6-a7db-03be0ad63010.json new file mode 100644 index 0000000..732cefd --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/0d/0d784963-d024-4ea6-a7db-03be0ad63010.json @@ -0,0 +1,384 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "toggle", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 1, + "asyncLoadAssets": false, + "readonly": false + }, + { + "__type__": "cc.Node", + "_name": "toggle", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + }, + { + "__id__": 5 + } + ], + "_active": true, + "_components": [ + { + "__id__": 8 + } + ], + "_prefab": { + "__id__": 9 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 28, + "height": 28 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Background", + "_objFlags": 512, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 3 + } + ], + "_prefab": { + "__id__": 4 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 28, + "height": 28 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "6827ca32-0107-4552-bab2-dfb31799bb44" + }, + "_type": 0, + "_sizeMode": 1, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "0d784963-d024-4ea6-a7db-03be0ad63010" + }, + "fileId": "238bacn/jZGGYuFN7ndSzkO", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "checkmark", + "_objFlags": 512, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 6 + } + ], + "_prefab": { + "__id__": 7 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 28, + "height": 28 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 5 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "90004ad6-2f6d-40e1-93ef-b714375c6f06" + }, + "_type": 0, + "_sizeMode": 2, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": false, + "_atlas": null, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "0d784963-d024-4ea6-a7db-03be0ad63010" + }, + "fileId": "0d447hRg/9AuLVwR7+lDw/1", + "sync": false + }, + { + "__type__": "cc.Toggle", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "_normalMaterial": null, + "_grayMaterial": null, + "duration": 0.1, + "zoomScale": 1.2, + "clickEvents": [], + "_N$interactable": true, + "_N$enableAutoGrayEffect": false, + "_N$transition": 3, + "transition": 3, + "_N$normalColor": { + "__type__": "cc.Color", + "r": 214, + "g": 214, + "b": 214, + "a": 255 + }, + "_N$pressedColor": { + "__type__": "cc.Color", + "r": 211, + "g": 211, + "b": 211, + "a": 255 + }, + "pressedColor": { + "__type__": "cc.Color", + "r": 211, + "g": 211, + "b": 211, + "a": 255 + }, + "_N$hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$disabledColor": { + "__type__": "cc.Color", + "r": 124, + "g": 124, + "b": 124, + "a": 255 + }, + "_N$normalSprite": null, + "_N$pressedSprite": null, + "pressedSprite": null, + "_N$hoverSprite": null, + "hoverSprite": null, + "_N$disabledSprite": null, + "_N$target": { + "__id__": 2 + }, + "_N$isChecked": true, + "toggleGroup": null, + "checkMark": { + "__id__": 6 + }, + "checkEvents": [], + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "0d784963-d024-4ea6-a7db-03be0ad63010" + }, + "fileId": "3d81aISgHdGFblE/PZD2Cp3", + "sync": false + } +] \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/0e/0e42ba95-1fa1-46aa-b2cf-143cd1bcee2c.json b/Layered_virtual_list_2.x/library/imports/0e/0e42ba95-1fa1-46aa-b2cf-143cd1bcee2c.json new file mode 100644 index 0000000..95d88cf --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/0e/0e42ba95-1fa1-46aa-b2cf-143cd1bcee2c.json @@ -0,0 +1,101 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "tiledtile", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "asyncLoadAssets": false, + "readonly": false + }, + { + "__type__": "cc.Node", + "_name": "New TiledTile", + "_objFlags": 0, + "_parent": null, + "_children": [], + "_active": true, + "_level": 1, + "_components": [ + { + "__id__": 2 + } + ], + "_prefab": { + "__id__": 3 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_skewX": 0, + "_skewY": 0, + "_localZOrder": 45, + "groupIndex": 0, + "_id": "", + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.TiledTile", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "_x": 0, + "_y": 0, + "_gid": 6, + "_layer": null, + "_id": "39h1tJvWtC8oLyzYKulleV" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "0e42ba95-1fa1-46aa-b2cf-143cd1bcee2c" + }, + "fileId": "fb1JS09SVFapQy1+PoRN4F", + "sync": false + } +] \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/0e/0e93aeaa-0b53-4e40-b8e0-6268b4e07bd7.json b/Layered_virtual_list_2.x/library/imports/0e/0e93aeaa-0b53-4e40-b8e0-6268b4e07bd7.json new file mode 100644 index 0000000..f4d3619 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/0e/0e93aeaa-0b53-4e40-b8e0-6268b4e07bd7.json @@ -0,0 +1,125 @@ +{ + "__type__": "cc.EffectAsset", + "_name": "builtin-2d-spine", + "_objFlags": 0, + "_native": "", + "properties": null, + "techniques": [ + { + "passes": [ + { + "blendState": { + "targets": [ + { + "blend": true + } + ] + }, + "rasterizerState": { + "cullMode": 0 + }, + "properties": { + "texture": { + "value": "white", + "type": 29 + }, + "alphaThreshold": { + "value": [ + 0.5 + ], + "type": 13 + } + }, + "program": "builtin-2d-spine|vs|fs" + } + ] + } + ], + "shaders": [ + { + "hash": 3550530479, + "glsl3": { + "vert": "\nprecision highp float;\nuniform CCGlobal {\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\nuniform CCLocal {\n mat4 cc_matWorld;\n mat4 cc_matWorldIT;\n};\nin vec3 a_position;\nin vec4 a_color;\n#if USE_TINT\n in vec4 a_color0;\n#endif\nin vec2 a_uv0;\nout vec2 v_uv0;\nout vec4 v_light;\n#if USE_TINT\n out vec4 v_dark;\n#endif\nvoid main () {\n mat4 mvp;\n #if CC_USE_MODEL\n mvp = cc_matViewProj * cc_matWorld;\n #else\n mvp = cc_matViewProj;\n #endif\n v_uv0 = a_uv0;\n v_light = a_color;\n #if USE_TINT\n v_dark = a_color0;\n #endif\n gl_Position = mvp * vec4(a_position, 1);\n}", + "frag": "\nprecision highp float;\nuniform sampler2D texture;\nin vec2 v_uv0;\nin vec4 v_light;\n#if USE_TINT\n in vec4 v_dark;\n#endif\n#if USE_ALPHA_TEST\n uniform ALPHA_TEST {\n float alphaThreshold;\n };\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\nvoid main () {\n vec4 texColor = vec4(1.0);\n vec4 texture_tmp = texture(texture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture\n texture_tmp.a *= texture(texture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n texColor.rgb *= (texture_tmp.rgb * texture_tmp.rgb);\n texColor.a *= texture_tmp.a;\n #else\n texColor *= texture_tmp;\n #endif\n vec4 finalColor;\n #if USE_TINT\n finalColor.a = v_light.a * texColor.a;\n finalColor.rgb = ((texColor.a - 1.0) * v_dark.a + 1.0 - texColor.rgb) * v_dark.rgb + texColor.rgb * v_light.rgb;\n #else\n finalColor = texColor * v_light;\n #endif\n ALPHA_TEST(finalColor);\n gl_FragColor = finalColor;\n}" + }, + "glsl1": { + "vert": "\nprecision highp float;\nuniform mat4 cc_matViewProj;\nuniform mat4 cc_matWorld;\nattribute vec3 a_position;\nattribute vec4 a_color;\n#if USE_TINT\n attribute vec4 a_color0;\n#endif\nattribute vec2 a_uv0;\nvarying vec2 v_uv0;\nvarying vec4 v_light;\n#if USE_TINT\n varying vec4 v_dark;\n#endif\nvoid main () {\n mat4 mvp;\n #if CC_USE_MODEL\n mvp = cc_matViewProj * cc_matWorld;\n #else\n mvp = cc_matViewProj;\n #endif\n v_uv0 = a_uv0;\n v_light = a_color;\n #if USE_TINT\n v_dark = a_color0;\n #endif\n gl_Position = mvp * vec4(a_position, 1);\n}", + "frag": "\nprecision highp float;\nuniform sampler2D texture;\nvarying vec2 v_uv0;\nvarying vec4 v_light;\n#if USE_TINT\n varying vec4 v_dark;\n#endif\n#if USE_ALPHA_TEST\n uniform float alphaThreshold;\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\nvoid main () {\n vec4 texColor = vec4(1.0);\n vec4 texture_tmp = texture2D(texture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture\n texture_tmp.a *= texture2D(texture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n texColor.rgb *= (texture_tmp.rgb * texture_tmp.rgb);\n texColor.a *= texture_tmp.a;\n #else\n texColor *= texture_tmp;\n #endif\n vec4 finalColor;\n #if USE_TINT\n finalColor.a = v_light.a * texColor.a;\n finalColor.rgb = ((texColor.a - 1.0) * v_dark.a + 1.0 - texColor.rgb) * v_dark.rgb + texColor.rgb * v_light.rgb;\n #else\n finalColor = texColor * v_light;\n #endif\n ALPHA_TEST(finalColor);\n gl_FragColor = finalColor;\n}" + }, + "builtins": { + "globals": { + "blocks": [ + { + "name": "CCGlobal", + "defines": [] + } + ], + "samplers": [] + }, + "locals": { + "blocks": [ + { + "name": "CCLocal", + "defines": [] + } + ], + "samplers": [] + } + }, + "defines": [ + { + "name": "USE_TINT", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_MODEL", + "type": "boolean", + "defines": [] + }, + { + "name": "USE_ALPHA_TEST", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_ALPHA_ATLAS_texture", + "type": "boolean", + "defines": [] + }, + { + "name": "INPUT_IS_GAMMA", + "type": "boolean", + "defines": [] + } + ], + "blocks": [ + { + "name": "ALPHA_TEST", + "members": [ + { + "name": "alphaThreshold", + "type": 13, + "count": 1 + } + ], + "defines": [ + "USE_ALPHA_TEST" + ], + "binding": 0 + } + ], + "samplers": [ + { + "name": "texture", + "type": 29, + "count": 1, + "defines": [], + "binding": 30 + } + ], + "record": null, + "name": "builtin-2d-spine|vs|fs" + } + ] +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/11/115286d1-2e10-49ee-aab4-341583f607e8.json b/Layered_virtual_list_2.x/library/imports/11/115286d1-2e10-49ee-aab4-341583f607e8.json new file mode 100644 index 0000000..d0941d4 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/11/115286d1-2e10-49ee-aab4-341583f607e8.json @@ -0,0 +1,106 @@ +{ + "__type__": "cc.EffectAsset", + "_name": "__builtin-editor-gizmo", + "_objFlags": 0, + "_native": "", + "properties": null, + "techniques": [ + { + "passes": [ + { + "stage": "transparent", + "blendState": { + "targets": [ + { + "blend": true, + "blendEq": 32774, + "blendAlphaEq": 32774, + "blendSrcAlpha": 1, + "blendDstAlpha": 771 + } + ] + }, + "rasterizerState": { + "cullMode": 0 + }, + "depthStencilState": { + "depthTest": false, + "depthWrite": false + }, + "properties": { + "diffuseColor": { + "value": [ + 1, + 1, + 1, + 1 + ], + "editor": { + "type": "color" + }, + "type": 16 + } + }, + "program": "__builtin-editor-gizmo|vs|fs" + } + ] + } + ], + "shaders": [ + { + "hash": 2992916359, + "glsl3": { + "vert": "\nprecision highp float;\nuniform CCGlobal {\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\nuniform CCLocal {\n mat4 cc_matWorld;\n mat4 cc_matWorldIT;\n};\nvarying vec3 v_worldNormal;\nvarying vec3 v_worldPosition;\nvarying vec3 v_localPosition;\nvarying vec3 v_right;\nvarying vec3 v_up;\nvarying vec3 v_forward;\nattribute vec3 a_position;\nattribute vec3 a_normal;\nvoid main () {\n vec4 pos = vec4(a_position, 1);\n v_localPosition = a_position;\n v_worldPosition = (cc_matWorld * pos).xyz;\n v_worldNormal = (cc_matWorldIT * vec4(a_normal, 0)).xyz;\n v_right = vec3(cc_matView[0][0], cc_matView[1][0], cc_matView[2][0]);\n v_up = vec3(cc_matView[0][1], cc_matView[1][1], cc_matView[2][1]);\n v_forward = vec3(cc_matView[0][2], cc_matView[1][2], cc_matView[2][2]);\n gl_Position = cc_matViewProj * cc_matWorld * pos;\n}", + "frag": "\nprecision highp float;\nvec4 CCFragOutput (vec4 color) {\n #if OUTPUT_TO_GAMMA\n color.rgb = sqrt(color.rgb);\n #endif\n\treturn color;\n}\nmat3 transpose(mat3 v) {\n mat3 tmp;\n tmp[0] = vec3(v[0].x, v[1].x, v[2].x);\n tmp[1] = vec3(v[0].y, v[1].y, v[2].y);\n tmp[2] = vec3(v[0].z, v[1].z, v[2].z);\n return tmp;\n}\nvoid ClipQuadToHorizon(inout vec3 L[5], out int n) {\n int config = 0;\n if (L[0].z > 0.0) config += 1;\n if (L[1].z > 0.0) config += 2;\n if (L[2].z > 0.0) config += 4;\n if (L[3].z > 0.0) config += 8;\n config = 15;\n n = 0;\n if (config == 0)\n {\n }\n else if (config == 1)\n {\n n = 3;\n L[1] = -L[1].z * L[0] + L[0].z * L[1];\n L[2] = -L[3].z * L[0] + L[0].z * L[3];\n }\n else if (config == 2)\n {\n n = 3;\n L[0] = -L[0].z * L[1] + L[1].z * L[0];\n L[2] = -L[2].z * L[1] + L[1].z * L[2];\n }\n else if (config == 3)\n {\n n = 4;\n L[2] = -L[2].z * L[1] + L[1].z * L[2];\n L[3] = -L[3].z * L[0] + L[0].z * L[3];\n }\n else if (config == 4)\n {\n n = 3;\n L[0] = -L[3].z * L[2] + L[2].z * L[3];\n L[1] = -L[1].z * L[2] + L[2].z * L[1];\n }\n else if (config == 5)\n {\n n = 0;\n }\n else if (config == 6)\n {\n n = 4;\n L[0] = -L[0].z * L[1] + L[1].z * L[0];\n L[3] = -L[3].z * L[2] + L[2].z * L[3];\n }\n else if (config == 7)\n {\n n = 5;\n L[4] = -L[3].z * L[0] + L[0].z * L[3];\n L[3] = -L[3].z * L[2] + L[2].z * L[3];\n }\n else if (config == 8)\n {\n n = 3;\n L[0] = -L[0].z * L[3] + L[3].z * L[0];\n L[1] = -L[2].z * L[3] + L[3].z * L[2];\n L[2] = L[3];\n }\n else if (config == 9)\n {\n n = 4;\n L[1] = -L[1].z * L[0] + L[0].z * L[1];\n L[2] = -L[2].z * L[3] + L[3].z * L[2];\n }\n else if (config == 10)\n {\n n = 0;\n }\n else if (config == 11)\n {\n n = 5;\n L[4] = L[3];\n L[3] = -L[2].z * L[3] + L[3].z * L[2];\n L[2] = -L[2].z * L[1] + L[1].z * L[2];\n }\n else if (config == 12)\n {\n n = 4;\n L[1] = -L[1].z * L[2] + L[2].z * L[1];\n L[0] = -L[0].z * L[3] + L[3].z * L[0];\n }\n else if (config == 13)\n {\n n = 5;\n L[4] = L[3];\n L[3] = L[2];\n L[2] = -L[1].z * L[2] + L[2].z * L[1];\n L[1] = -L[1].z * L[0] + L[0].z * L[1];\n }\n else if (config == 14)\n {\n n = 5;\n L[4] = -L[0].z * L[3] + L[3].z * L[0];\n L[0] = -L[0].z * L[1] + L[1].z * L[0];\n }\n else if (config == 15)\n {\n n = 4;\n }\n if (n == 3)\n L[3] = L[0];\n if (n == 4)\n L[4] = L[0];\n}\nfloat IntegrateEdge(vec3 v1, vec3 v2) {\n float cosTheta = dot(v1, v2);\n float theta = acos(cosTheta);\n return cross(v1, v2).z * ((theta > 0.001) ? theta/sin(theta) : 4.0);\n}\nvec3 LTC_Evaluate(vec3 N, vec3 V, vec3 P, mat3 Minv, vec3 points[4]) {\n vec3 T1, T2;\n T1 = normalize(V - N*dot(V, N));\n T2 = cross(N, T1);\n Minv = Minv * transpose(mat3(T1, T2, N));\n vec3 L[5];\n L[0] = Minv * (points[0] - P);\n L[1] = Minv * (points[1] - P);\n L[2] = Minv * (points[2] - P);\n L[3] = Minv * (points[3] - P);\n int n;\n ClipQuadToHorizon(L, n);\n if (n == 0)\n return vec3(0, 0, 0);\n L[0] = normalize(L[0]);\n L[1] = normalize(L[1]);\n L[2] = normalize(L[2]);\n L[3] = normalize(L[3]);\n L[4] = normalize(L[4]);\n float sum = 0.0;\n sum += IntegrateEdge(L[0], L[1]);\n sum += IntegrateEdge(L[1], L[2]);\n sum += IntegrateEdge(L[2], L[3]);\n if (n >= 4)\n sum += IntegrateEdge(L[3], L[4]);\n if (n == 5)\n sum += IntegrateEdge(L[4], L[0]);\n sum = max(0.0, sum);\n vec3 Lo_i = vec3(sum, sum, sum);\n return Lo_i;\n}\nuniform CCGlobal {\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\nuniform DIFFUSE_COLOR {\n vec4 diffuseColor;\n};\nvarying vec3 v_worldNormal;\nvarying vec3 v_worldPosition;\nvarying vec3 v_localPosition;\nvarying vec3 v_right;\nvarying vec3 v_up;\nvarying vec3 v_forward;\nvoid main () {\n vec3 N = normalize(v_worldNormal);\n vec3 V = normalize(cc_cameraPos.xyz - v_worldPosition);\n vec3 points[4];\n vec3 up = vec3(0, 1, 0);\n points[0] = (v_forward * 3.0 + v_right + up) * 40.0;\n points[1] = (v_forward * 3.0 - v_right + up) * 40.0;\n points[2] = (v_forward * 3.0 - v_right - up) * 40.0;\n points[3] = (v_forward * 3.0 + v_right - up) * 40.0;\n vec3 diffuse = diffuseColor.rgb * (0.2 + LTC_Evaluate(N, V, v_localPosition, mat3(1), points) * 0.8);\n gl_FragColor = CCFragOutput(vec4(diffuse, diffuseColor.a));\n}" + }, + "glsl1": { + "vert": "\nprecision highp float;\nuniform mat4 cc_matView;\nuniform mat4 cc_matViewProj;\nuniform mat4 cc_matWorld;\nuniform mat4 cc_matWorldIT;\nvarying vec3 v_worldNormal;\nvarying vec3 v_worldPosition;\nvarying vec3 v_localPosition;\nvarying vec3 v_right;\nvarying vec3 v_up;\nvarying vec3 v_forward;\nattribute vec3 a_position;\nattribute vec3 a_normal;\nvoid main () {\n vec4 pos = vec4(a_position, 1);\n v_localPosition = a_position;\n v_worldPosition = (cc_matWorld * pos).xyz;\n v_worldNormal = (cc_matWorldIT * vec4(a_normal, 0)).xyz;\n v_right = vec3(cc_matView[0][0], cc_matView[1][0], cc_matView[2][0]);\n v_up = vec3(cc_matView[0][1], cc_matView[1][1], cc_matView[2][1]);\n v_forward = vec3(cc_matView[0][2], cc_matView[1][2], cc_matView[2][2]);\n gl_Position = cc_matViewProj * cc_matWorld * pos;\n}", + "frag": "\nprecision highp float;\nvec4 CCFragOutput (vec4 color) {\n #if OUTPUT_TO_GAMMA\n color.rgb = sqrt(color.rgb);\n #endif\n\treturn color;\n}\nmat3 transpose(mat3 v) {\n mat3 tmp;\n tmp[0] = vec3(v[0].x, v[1].x, v[2].x);\n tmp[1] = vec3(v[0].y, v[1].y, v[2].y);\n tmp[2] = vec3(v[0].z, v[1].z, v[2].z);\n return tmp;\n}\nvoid ClipQuadToHorizon(inout vec3 L[5], out int n) {\n int config = 0;\n if (L[0].z > 0.0) config += 1;\n if (L[1].z > 0.0) config += 2;\n if (L[2].z > 0.0) config += 4;\n if (L[3].z > 0.0) config += 8;\n config = 15;\n n = 0;\n if (config == 0)\n {\n }\n else if (config == 1)\n {\n n = 3;\n L[1] = -L[1].z * L[0] + L[0].z * L[1];\n L[2] = -L[3].z * L[0] + L[0].z * L[3];\n }\n else if (config == 2)\n {\n n = 3;\n L[0] = -L[0].z * L[1] + L[1].z * L[0];\n L[2] = -L[2].z * L[1] + L[1].z * L[2];\n }\n else if (config == 3)\n {\n n = 4;\n L[2] = -L[2].z * L[1] + L[1].z * L[2];\n L[3] = -L[3].z * L[0] + L[0].z * L[3];\n }\n else if (config == 4)\n {\n n = 3;\n L[0] = -L[3].z * L[2] + L[2].z * L[3];\n L[1] = -L[1].z * L[2] + L[2].z * L[1];\n }\n else if (config == 5)\n {\n n = 0;\n }\n else if (config == 6)\n {\n n = 4;\n L[0] = -L[0].z * L[1] + L[1].z * L[0];\n L[3] = -L[3].z * L[2] + L[2].z * L[3];\n }\n else if (config == 7)\n {\n n = 5;\n L[4] = -L[3].z * L[0] + L[0].z * L[3];\n L[3] = -L[3].z * L[2] + L[2].z * L[3];\n }\n else if (config == 8)\n {\n n = 3;\n L[0] = -L[0].z * L[3] + L[3].z * L[0];\n L[1] = -L[2].z * L[3] + L[3].z * L[2];\n L[2] = L[3];\n }\n else if (config == 9)\n {\n n = 4;\n L[1] = -L[1].z * L[0] + L[0].z * L[1];\n L[2] = -L[2].z * L[3] + L[3].z * L[2];\n }\n else if (config == 10)\n {\n n = 0;\n }\n else if (config == 11)\n {\n n = 5;\n L[4] = L[3];\n L[3] = -L[2].z * L[3] + L[3].z * L[2];\n L[2] = -L[2].z * L[1] + L[1].z * L[2];\n }\n else if (config == 12)\n {\n n = 4;\n L[1] = -L[1].z * L[2] + L[2].z * L[1];\n L[0] = -L[0].z * L[3] + L[3].z * L[0];\n }\n else if (config == 13)\n {\n n = 5;\n L[4] = L[3];\n L[3] = L[2];\n L[2] = -L[1].z * L[2] + L[2].z * L[1];\n L[1] = -L[1].z * L[0] + L[0].z * L[1];\n }\n else if (config == 14)\n {\n n = 5;\n L[4] = -L[0].z * L[3] + L[3].z * L[0];\n L[0] = -L[0].z * L[1] + L[1].z * L[0];\n }\n else if (config == 15)\n {\n n = 4;\n }\n if (n == 3)\n L[3] = L[0];\n if (n == 4)\n L[4] = L[0];\n}\nfloat IntegrateEdge(vec3 v1, vec3 v2) {\n float cosTheta = dot(v1, v2);\n float theta = acos(cosTheta);\n return cross(v1, v2).z * ((theta > 0.001) ? theta/sin(theta) : 4.0);\n}\nvec3 LTC_Evaluate(vec3 N, vec3 V, vec3 P, mat3 Minv, vec3 points[4]) {\n vec3 T1, T2;\n T1 = normalize(V - N*dot(V, N));\n T2 = cross(N, T1);\n Minv = Minv * transpose(mat3(T1, T2, N));\n vec3 L[5];\n L[0] = Minv * (points[0] - P);\n L[1] = Minv * (points[1] - P);\n L[2] = Minv * (points[2] - P);\n L[3] = Minv * (points[3] - P);\n int n;\n ClipQuadToHorizon(L, n);\n if (n == 0)\n return vec3(0, 0, 0);\n L[0] = normalize(L[0]);\n L[1] = normalize(L[1]);\n L[2] = normalize(L[2]);\n L[3] = normalize(L[3]);\n L[4] = normalize(L[4]);\n float sum = 0.0;\n sum += IntegrateEdge(L[0], L[1]);\n sum += IntegrateEdge(L[1], L[2]);\n sum += IntegrateEdge(L[2], L[3]);\n if (n >= 4)\n sum += IntegrateEdge(L[3], L[4]);\n if (n == 5)\n sum += IntegrateEdge(L[4], L[0]);\n sum = max(0.0, sum);\n vec3 Lo_i = vec3(sum, sum, sum);\n return Lo_i;\n}\nuniform vec4 cc_cameraPos;\nuniform vec4 diffuseColor;\nvarying vec3 v_worldNormal;\nvarying vec3 v_worldPosition;\nvarying vec3 v_localPosition;\nvarying vec3 v_right;\nvarying vec3 v_up;\nvarying vec3 v_forward;\nvoid main () {\n vec3 N = normalize(v_worldNormal);\n vec3 V = normalize(cc_cameraPos.xyz - v_worldPosition);\n vec3 points[4];\n vec3 up = vec3(0, 1, 0);\n points[0] = (v_forward * 3.0 + v_right + up) * 40.0;\n points[1] = (v_forward * 3.0 - v_right + up) * 40.0;\n points[2] = (v_forward * 3.0 - v_right - up) * 40.0;\n points[3] = (v_forward * 3.0 + v_right - up) * 40.0;\n vec3 diffuse = diffuseColor.rgb * (0.2 + LTC_Evaluate(N, V, v_localPosition, mat3(1), points) * 0.8);\n gl_FragColor = CCFragOutput(vec4(diffuse, diffuseColor.a));\n}" + }, + "builtins": { + "globals": { + "blocks": [ + { + "name": "CCGlobal", + "defines": [] + } + ], + "samplers": [] + }, + "locals": { + "blocks": [ + { + "name": "CCLocal", + "defines": [] + } + ], + "samplers": [] + } + }, + "defines": [ + { + "name": "OUTPUT_TO_GAMMA", + "type": "boolean", + "defines": [] + } + ], + "blocks": [ + { + "name": "DIFFUSE_COLOR", + "members": [ + { + "name": "diffuseColor", + "type": 16, + "count": 1 + } + ], + "defines": [], + "binding": 0 + } + ], + "samplers": [], + "record": null, + "name": "__builtin-editor-gizmo|vs|fs" + } + ] +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/14/144c3297-af63-49e8-b8ef-1cfa29b3be28.json b/Layered_virtual_list_2.x/library/imports/14/144c3297-af63-49e8-b8ef-1cfa29b3be28.json new file mode 100644 index 0000000..49bba4a --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/14/144c3297-af63-49e8-b8ef-1cfa29b3be28.json @@ -0,0 +1,84 @@ +{ + "__type__": "cc.EffectAsset", + "_name": "builtin-2d-gray-sprite", + "_objFlags": 0, + "_native": "", + "properties": null, + "techniques": [ + { + "passes": [ + { + "blendState": { + "targets": [ + { + "blend": true + } + ] + }, + "rasterizerState": { + "cullMode": 0 + }, + "properties": { + "texture": { + "value": "white", + "type": 29 + } + }, + "program": "builtin-2d-gray-sprite|vs|fs" + } + ] + } + ], + "shaders": [ + { + "hash": 4278481454, + "glsl3": { + "vert": "\nprecision highp float;\nuniform CCGlobal {\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\nin vec3 a_position;\nin mediump vec2 a_uv0;\nout mediump vec2 v_uv0;\nin vec4 a_color;\nout vec4 v_color;\nvoid main () {\n gl_Position = cc_matViewProj * vec4(a_position, 1);\n v_uv0 = a_uv0;\n v_color = a_color;\n}", + "frag": "\nprecision highp float;\nuniform sampler2D texture;\nin mediump vec2 v_uv0;\nin vec4 v_color;\nvoid main () {\n vec4 color = v_color;\n vec4 texture_tmp = texture(texture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture\n texture_tmp.a *= texture(texture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n color.rgb *= (texture_tmp.rgb * texture_tmp.rgb);\n color.a *= texture_tmp.a;\n #else\n color *= texture_tmp;\n #endif\n float gray = 0.2126*color.r + 0.7152*color.g + 0.0722*color.b;\n gl_FragColor = vec4(gray, gray, gray, color.a);\n}" + }, + "glsl1": { + "vert": "\nprecision highp float;\nuniform mat4 cc_matViewProj;\nattribute vec3 a_position;\nattribute mediump vec2 a_uv0;\nvarying mediump vec2 v_uv0;\nattribute vec4 a_color;\nvarying vec4 v_color;\nvoid main () {\n gl_Position = cc_matViewProj * vec4(a_position, 1);\n v_uv0 = a_uv0;\n v_color = a_color;\n}", + "frag": "\nprecision highp float;\nuniform sampler2D texture;\nvarying mediump vec2 v_uv0;\nvarying vec4 v_color;\nvoid main () {\n vec4 color = v_color;\n vec4 texture_tmp = texture2D(texture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture\n texture_tmp.a *= texture2D(texture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n color.rgb *= (texture_tmp.rgb * texture_tmp.rgb);\n color.a *= texture_tmp.a;\n #else\n color *= texture_tmp;\n #endif\n float gray = 0.2126*color.r + 0.7152*color.g + 0.0722*color.b;\n gl_FragColor = vec4(gray, gray, gray, color.a);\n}" + }, + "builtins": { + "globals": { + "blocks": [ + { + "name": "CCGlobal", + "defines": [] + } + ], + "samplers": [] + }, + "locals": { + "blocks": [], + "samplers": [] + } + }, + "defines": [ + { + "name": "CC_USE_ALPHA_ATLAS_texture", + "type": "boolean", + "defines": [] + }, + { + "name": "INPUT_IS_GAMMA", + "type": "boolean", + "defines": [] + } + ], + "blocks": [], + "samplers": [ + { + "name": "texture", + "type": 29, + "count": 1, + "defines": [], + "binding": 30 + } + ], + "record": null, + "name": "builtin-2d-gray-sprite|vs|fs" + } + ] +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/14/14c74869-bdb4-4f57-86d8-a7875de2be30.bin b/Layered_virtual_list_2.x/library/imports/14/14c74869-bdb4-4f57-86d8-a7875de2be30.bin new file mode 100644 index 0000000..1f0d8b8 Binary files /dev/null and b/Layered_virtual_list_2.x/library/imports/14/14c74869-bdb4-4f57-86d8-a7875de2be30.bin differ diff --git a/Layered_virtual_list_2.x/library/imports/14/14c74869-bdb4-4f57-86d8-a7875de2be30.json b/Layered_virtual_list_2.x/library/imports/14/14c74869-bdb4-4f57-86d8-a7875de2be30.json new file mode 100644 index 0000000..0ead9bd --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/14/14c74869-bdb4-4f57-86d8-a7875de2be30.json @@ -0,0 +1,90 @@ +[ + { + "__type__": "cc.Mesh", + "_name": "", + "_objFlags": 0, + "_native": ".bin", + "_vertexBundles": [ + { + "__id__": 1 + } + ], + "_primitives": [ + { + "__id__": 6 + } + ], + "_minPos": { + "__type__": "cc.Vec3", + "x": -0.5, + "y": -0.0999999940395355, + "z": -0.5 + }, + "_maxPos": { + "__type__": "cc.Vec3", + "x": 0.5, + "y": 0.0999999940395355, + "z": 0.5 + } + }, + { + "__type__": "cc.mesh.VertexBundle", + "data": { + "__id__": 2 + }, + "formats": [ + { + "__id__": 3 + }, + { + "__id__": 4 + }, + { + "__id__": 5 + } + ], + "verticesCount": 1089 + }, + { + "__type__": "cc.BufferRange", + "offset": 0, + "length": 34848 + }, + { + "__type__": "cc.mesh.VertexFormat", + "name": "a_normal", + "type": 5126, + "num": 3, + "normalize": false + }, + { + "__type__": "cc.mesh.VertexFormat", + "name": "a_position", + "type": 5126, + "num": 3, + "normalize": false + }, + { + "__type__": "cc.mesh.VertexFormat", + "name": "a_uv0", + "type": 5126, + "num": 2, + "normalize": false + }, + { + "__type__": "cc.mesh.Primitive", + "vertexBundleIndices": [ + 0 + ], + "data": { + "__id__": 7 + }, + "indexUnit": 5123, + "topology": 4 + }, + { + "__type__": "cc.BufferRange", + "offset": 34848, + "length": 12288 + } +] \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/1a/1a32fc76-f0bd-4f66-980f-56929c0ca0b3.json b/Layered_virtual_list_2.x/library/imports/1a/1a32fc76-f0bd-4f66-980f-56929c0ca0b3.json new file mode 100644 index 0000000..314a308 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/1a/1a32fc76-f0bd-4f66-980f-56929c0ca0b3.json @@ -0,0 +1,28 @@ +{ + "__type__": "cc.SpriteFrame", + "content": { + "name": "default_radio_button_on", + "texture": "9d60001f-b5f4-4726-a629-2659e3ded0b8", + "atlas": "", + "rect": [ + 1, + 1, + 30, + 30 + ], + "offset": [ + 0, + 0 + ], + "originalSize": [ + 32, + 32 + ], + "capInsets": [ + 0, + 0, + 0, + 0 + ] + } +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/1b/1b4785ab-e079-4c84-b756-9c959c0fa7e2.js b/Layered_virtual_list_2.x/library/imports/1b/1b4785ab-e079-4c84-b756-9c959c0fa7e2.js new file mode 100644 index 0000000..5abc2a4 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/1b/1b4785ab-e079-4c84-b756-9c959c0fa7e2.js @@ -0,0 +1,254 @@ +"use strict"; +cc._RF.push(module, '1b478Wr4HlMhLdWnJWcD6fi', 'RenderAlternative_old'); +// Script/RenderAlternative_old.ts + +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var RenderReactiveHandler_1 = require("./RenderReactiveHandler"); +/** + * 目前该渲染代理功能存在的问题 + * 1.被代理节点的父级不能出现scaleX和scaleY不一致的情况,被代理节点本身没有这个限制 + */ +var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property; +var RenderAlternative = /** @class */ (function (_super) { + __extends(RenderAlternative, _super); + function RenderAlternative() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /**渲染层节点 */ + _this.renderLayer = null; + /**渲染的zIndex 动态调整zIndex,用于方便临近合批 */ + _this.renderZIndex = 0; + /**同步的间隔(帧为单位) */ + _this.syncInv = 0.01; + /**渲染的sIndex */ + _this.sIndex = 0; + /**非渲染组件 */ + _this.proxyRender = null; + /**渲染组件 */ + _this.renderCompnent = null; + /**上次更新的数据 */ + _this.lastWMat4 = null; + /**上次更新的数据 */ + _this.lastLMat4 = null; + /**上次更新的数据 */ + _this.lastPos = null; + /**距离下次刷新累计了多少间隔 */ + _this.accuTime = 0; + /**最后一次刷新时间 */ + _this.lastFrameTime = null; + /**是否进行刷新 */ + _this.isAttachFrame = false; + return _this; + } + RenderAlternative_1 = RenderAlternative; + Object.defineProperty(RenderAlternative.prototype, "zIndex", { + /**获取总的ZIndex */ + get: function () { + var zIndex = this.renderZIndex + (this.sIndex * 0.01); + var parentNode = this.node.parent; + while (parentNode != this.renderLayer.parent && parentNode != cc.director.getScene()) { + var render = parentNode.getComponent(RenderAlternative_1); + if (render) { + zIndex += render.zIndex + 1; + break; + } + parentNode = parentNode.parent; + } + return zIndex; + }, + enumerable: false, + configurable: true + }); + /** + * 设置渲染节点层 + * @param layer + */ + RenderAlternative.prototype.init = function (layer) { + if (layer) { + this.renderLayer = layer; + } + if (!this.renderLayer) { + console.warn("\u8282\u70B9" + this.node.name + "\u6CA1\u6709\u8BBE\u7F6E\u6E32\u67D3\u5C42"); + return null; + } + return this.initRender(); + }; + /** + * 初始化渲染节点 + */ + RenderAlternative.prototype.initRender = function () { + var node = this.getRender(); + node.setParent(this.renderLayer ? this.renderLayer : cc.director.getScene().getChildByName("Canvas")); + this.isAttachFrame = true; + requestAnimationFrame(this.frameUpdate.bind(this)); + return this.doProxy(); + }; + /**生成代理 */ + RenderAlternative.prototype.doProxy = function () { + this.proxyRender = new Proxy(this.renderCompnent, new RenderReactiveHandler_1.RenderReactiveHandler()); + return this.proxyRender; + }; + RenderAlternative.prototype.frameUpdate = function () { + var now = cc.sys.now(); + !this.lastFrameTime && (this.lastFrameTime = now); + var dt = now - this.lastFrameTime; + if (this.proxyRender) { + this.accuTime += dt; + if (this.accuTime >= this.syncInv) { + this.accuTime -= this.syncInv; + this.updateProp(); + } + } + if (this.isAttachFrame) { + requestAnimationFrame(this.frameUpdate.bind(this)); + } + }; + /**更新最新状态 */ + RenderAlternative.prototype.updateProp = function () { + var node = this.renderCompnent.node; + if (!this.node.activeInHierarchy) { + node.opacity = 0; + return; + } + node.anchorX = this.node.anchorX; + node.anchorY = this.node.anchorY; + node.width = this.node.width; + node.height = this.node.height; + node.group = this.node.group; + node.color = this.node.color; + node.opacity = this.getOpacity(this.node); + var wMat4 = cc.mat4(); + this.node.getWorldMatrix(wMat4); + /* let lMat4 = cc.mat4(); + this.node.getLocalMatrix(wMat4); */ + //此处本可以过滤许多不必要的更新,但尚未排查出问题 + if (true /* || !this.lastWMat4?.equals(wMat4) || !this.lastLMat4?.equals(lMat4) */) { + this.onAngleChange(wMat4); + this.onScaleChange(wMat4); + this.onPosChange(); + /* this.lastLMat4 = lMat4; + this.lastWMat4 = wMat4; */ + } + node.zIndex = this.zIndex; + node.zIndex = this.zIndex; + }; + RenderAlternative.prototype.onDestroy = function () { + this.renderCompnent.node.destroy(); + this.renderCompnent = null; + this.proxyRender = null; + }; + /** + * 获取节点透明度 + * @param node + */ + RenderAlternative.prototype.getOpacity = function (node) { + var opacity = (node.opacity / 255); + var parentNode = node.parent; + while (parentNode != this.renderLayer.parent && parentNode != cc.director.getScene()) { + opacity *= (parentNode.opacity / 255); + parentNode = parentNode.parent; + } + return opacity * 255; + }; + /**位置变化处理 */ + RenderAlternative.prototype.onPosChange = function () { + var wpos = this.node.parent.convertToWorldSpaceAR(this.node.position); + this.renderCompnent.node.position = this.renderLayer.convertToNodeSpaceAR(wpos); + }; + /**旋转变化处理 */ + RenderAlternative.prototype.onAngleChange = function (mat4) { + this.renderCompnent.node.angle = this.extractRotationAngleFromMat4(mat4); + }; + /** + * 从 cc.Mat4 中获取旋转角度(不受缩放影响) + * @param matrix 输入的 cc.Mat4 矩阵 + * @returns 旋转角度(以度为单位) + */ + RenderAlternative.prototype.extractRotationAngleFromMat4 = function (matrix) { + // 提取旋转部分 + var scaleX = Math.sqrt(matrix.m[0] * matrix.m[0] + matrix.m[4] * matrix.m[4] + matrix.m[8] * matrix.m[8]); + var scaleY = Math.sqrt(matrix.m[1] * matrix.m[1] + matrix.m[5] * matrix.m[5] + matrix.m[9] * matrix.m[9]); + // 计算 Z 轴旋转角度(绕 Z 轴的旋转角度) + var angle = Math.atan2(matrix.m[1] / scaleY, matrix.m[0] / scaleX); + // 将弧度转换为角度 + var degrees = angle * (180 / Math.PI); + return degrees; + }; + /** + * 缩放变化处理 + * @param mat4 + */ + RenderAlternative.prototype.onScaleChange = function (mat4) { + var scale = this.extractScaleFromMat4(mat4); + this.renderCompnent.node.scaleX = scale.x; + this.renderCompnent.node.scaleY = scale.y; + this.renderCompnent.node.scaleZ = scale.z; + }; + /** + * 从mat4中获取缩放值 + * @param mat4 + * @returns + */ + RenderAlternative.prototype.extractScaleFromMat4 = function (mat4) { + var scaleX = cc.v3(mat4.m[0], mat4.m[1], mat4.m[2]).mag(); + var scaleY = cc.v3(mat4.m[4], mat4.m[5], mat4.m[6]).mag(); + var scaleZ = cc.v3(mat4.m[8], mat4.m[9], mat4.m[10]).mag(); + return cc.v3(scaleX, scaleY, scaleZ); + }; + /** + * 获取渲染组件 + * @param node + */ + RenderAlternative.prototype.getRender = function () { + var _a, _b; + var node = cc.instantiate(this.node); + node.removeAllChildren(); + this.renderCompnent = node.getComponent(cc.RenderComponent); + (_a = this.node.getComponent(cc.LabelOutline)) === null || _a === void 0 ? void 0 : _a.destroy(); + (_b = this.node.getComponent(cc.LabelShadow)) === null || _b === void 0 ? void 0 : _b.destroy(); + this.node.getComponent(cc.RenderComponent).destroy(); + var components = node.getComponents(cc.Component); + for (var i = 0, len = components.length; i < len; ++i) { + var comp = components[i]; + if (!((comp instanceof cc.RenderComponent) || (comp instanceof cc.LabelOutline) || (comp instanceof cc.LabelShadow))) { + comp.destroy(); + } + } + return node; + }; + var RenderAlternative_1; + __decorate([ + property + ], RenderAlternative.prototype, "renderZIndex", void 0); + __decorate([ + property({ + tooltip: '设置同步的间隔(秒为单位),0就是每帧都同步,0.1就是隔0.1秒同步一次' + }) + ], RenderAlternative.prototype, "syncInv", void 0); + RenderAlternative = RenderAlternative_1 = __decorate([ + ccclass + ], RenderAlternative); + return RenderAlternative; +}(cc.Component)); +exports.default = RenderAlternative; + +cc._RF.pop(); \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/1b/1b4785ab-e079-4c84-b756-9c959c0fa7e2.js.map b/Layered_virtual_list_2.x/library/imports/1b/1b4785ab-e079-4c84-b756-9c959c0fa7e2.js.map new file mode 100644 index 0000000..75ce3a3 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/1b/1b4785ab-e079-4c84-b756-9c959c0fa7e2.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["assets\\Script\\RenderAlternative_old.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iEAAgE;AAEhE;;;GAGG;AACG,IAAA,KAAwB,EAAE,CAAC,UAAU,EAAnC,OAAO,aAAA,EAAE,QAAQ,cAAkB,CAAC;AAE5C;IAA+C,qCAAY;IAA3D;QAAA,qEAkNC;QAjNG,WAAW;QACJ,iBAAW,GAAY,IAAI,CAAC;QACnC,mCAAmC;QAE5B,kBAAY,GAAW,CAAC,CAAC;QAChC,iBAAiB;QAIV,aAAO,GAAW,IAAI,CAAC;QAC9B,eAAe;QACR,YAAM,GAAW,CAAC,CAAC;QAC1B,WAAW;QACJ,iBAAW,GAAuB,IAAI,CAAC;QAC9C,UAAU;QACF,oBAAc,GAAuB,IAAI,CAAC;QAClD,aAAa;QACN,eAAS,GAAY,IAAI,CAAC;QACjC,aAAa;QACN,eAAS,GAAY,IAAI,CAAC;QACjC,aAAa;QACN,aAAO,GAAY,IAAI,CAAC;QAC/B,mBAAmB;QACZ,cAAQ,GAAW,CAAC,CAAC;QAC5B,cAAc;QACP,mBAAa,GAAW,IAAI,CAAC;QACpC,YAAY;QACL,mBAAa,GAAY,KAAK,CAAC;;IAsL1C,CAAC;0BAlNoB,iBAAiB;IA+BlC,sBAAI,qCAAM;QADV,gBAAgB;aAChB;YACI,IAAI,MAAM,GAAG,IAAI,CAAC,YAAY,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;YACtD,IAAI,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;YAClC,OAAO,UAAU,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,IAAI,UAAU,IAAI,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,EAAE;gBAClF,IAAI,MAAM,GAAG,UAAU,CAAC,YAAY,CAAC,mBAAiB,CAAC,CAAC;gBACxD,IAAI,MAAM,EAAE;oBACR,MAAM,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;oBAC5B,MAAM;iBACT;gBACD,UAAU,GAAG,UAAU,CAAC,MAAM,CAAC;aAClC;YACD,OAAO,MAAM,CAAC;QAClB,CAAC;;;OAAA;IAED;;;OAGG;IACH,gCAAI,GAAJ,UAAmC,KAAe;QAC9C,IAAI,KAAK,EAAE;YACP,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;SAC5B;QACD,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;YACnB,OAAO,CAAC,IAAI,CAAC,iBAAK,IAAI,CAAC,IAAI,CAAC,IAAI,+CAAS,CAAC,CAAA;YAC1C,OAAO,IAAI,CAAC;SACf;QACD,OAAO,IAAI,CAAC,UAAU,EAAK,CAAC;IAChC,CAAC;IACD;;OAEG;IACK,sCAAU,GAAlB;QACI,IAAI,IAAI,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;QAC5B,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC;QACtG,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;QAC1B,qBAAqB,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QACnD,OAAO,IAAI,CAAC,OAAO,EAAK,CAAC;IAC7B,CAAC;IACD,UAAU;IACF,mCAAO,GAAf;QACI,IAAI,CAAC,WAAW,GAAG,IAAI,KAAK,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,6CAAqB,EAAE,CAAM,CAAC;QACpF,OAAO,IAAI,CAAC,WAAgB,CAAC;IACjC,CAAC;IAGS,uCAAW,GAArB;QACI,IAAI,GAAG,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;QACvB,CAAC,IAAI,CAAC,aAAa,IAAI,CAAC,IAAI,CAAC,aAAa,GAAG,GAAG,CAAC,CAAC;QAClD,IAAI,EAAE,GAAG,GAAG,GAAG,IAAI,CAAC,aAAa,CAAC;QAClC,IAAI,IAAI,CAAC,WAAW,EAAE;YAClB,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAC;YACpB,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,OAAO,EAAE;gBAC/B,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,OAAO,CAAC;gBAC9B,IAAI,CAAC,UAAU,EAAE,CAAC;aACrB;SACJ;QACD,IAAI,IAAI,CAAC,aAAa,EAAE;YACpB,qBAAqB,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;SACtD;IACL,CAAC;IAED,YAAY;IACL,sCAAU,GAAjB;QACI,IAAI,IAAI,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC;QACpC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE;YAC9B,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;YACjB,OAAO;SACV;QACD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC;QACjC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC;QACjC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;QAC7B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;QAC/B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;QAC7B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAE1C,IAAI,KAAK,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC;QACtB,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;QAChC;2CACmC;QACnC,0BAA0B;QAC1B,IAAI,IAAI,CAAC,yEAAyE,EAAE;YAChF,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;YAC1B,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;YAC1B,IAAI,CAAC,WAAW,EAAE,CAAC;YACnB;uCAC2B;SAC9B;QACD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IAC9B,CAAC;IAES,qCAAS,GAAnB;QACI,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;QACnC,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;QAC3B,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;IAC5B,CAAC;IAED;;;OAGG;IACK,sCAAU,GAAlB,UAAmB,IAAa;QAC5B,IAAI,OAAO,GAAG,CAAC,IAAI,CAAC,OAAO,GAAG,GAAG,CAAC,CAAC;QACnC,IAAI,UAAU,GAAG,IAAI,CAAC,MAAM,CAAA;QAC5B,OAAO,UAAU,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,IAAI,UAAU,IAAI,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,EAAE;YAClF,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,GAAG,GAAG,CAAC,CAAC;YACtC,UAAU,GAAG,UAAU,CAAC,MAAM,CAAC;SAClC;QACD,OAAO,OAAO,GAAG,GAAG,CAAC;IACzB,CAAC;IACD,YAAY;IACJ,uCAAW,GAAnB;QACI,IAAI,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACtE,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC;IACpF,CAAC;IACD,YAAY;IACJ,yCAAa,GAArB,UAAsB,IAAa;QAC/B,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,4BAA4B,CAAC,IAAI,CAAC,CAAC;IAC7E,CAAC;IACD;;;;OAIG;IACK,wDAA4B,GAApC,UAAqC,MAAe;QAChD,SAAS;QACT,IAAI,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1G,IAAI,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAE1G,yBAAyB;QACzB,IAAI,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC;QAEnE,WAAW;QACX,IAAI,OAAO,GAAG,KAAK,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC;QACtC,OAAO,OAAO,CAAC;IACnB,CAAC;IACD;;;OAGG;IACK,yCAAa,GAArB,UAAsB,IAAa;QAC/B,IAAI,KAAK,GAAG,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAA;QAC3C,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC;QAC1C,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC;QAC1C,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC;IAC9C,CAAC;IACD;;;;OAIG;IACK,gDAAoB,GAA5B,UAA6B,IAAa;QACtC,IAAI,MAAM,GAAG,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;QAC1D,IAAI,MAAM,GAAG,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;QAC1D,IAAI,MAAM,GAAG,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;QAC3D,OAAO,EAAE,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC,CAAC;IACD;;;OAGG;IACK,qCAAS,GAAjB;;QACI,IAAI,IAAI,GAAG,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACzB,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC;QAC5D,MAAA,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,YAAY,CAAC,0CAAE,OAAO,GAAG;QACnD,MAAA,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,WAAW,CAAC,0CAAE,OAAO,GAAG;QAClD,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC,OAAO,EAAE,CAAC;QACrD,IAAI,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC;QAClD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,GAAG,GAAG,EAAE,EAAE,CAAC,EAAE;YACnD,IAAI,IAAI,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;YACzB,IAAI,CAAC,CAAC,CAAC,IAAI,YAAY,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,YAAY,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,YAAY,EAAE,CAAC,WAAW,CAAC,CAAC,EAAE;gBAClH,IAAI,CAAC,OAAO,EAAE,CAAC;aAClB;SACJ;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;;IA3MD;QADC,QAAQ;2DACuB;IAKhC;QAHC,QAAQ,CAAC;YACN,OAAO,EAAE,uCAAuC;SACnD,CAAC;sDAC4B;IAVb,iBAAiB;QADrC,OAAO;OACa,iBAAiB,CAkNrC;IAAD,wBAAC;CAlND,AAkNC,CAlN8C,EAAE,CAAC,SAAS,GAkN1D;kBAlNoB,iBAAiB","file":"","sourceRoot":"/","sourcesContent":["import { RenderReactiveHandler } from \"./RenderReactiveHandler\";\r\n\r\n/**\r\n * 目前该渲染代理功能存在的问题\r\n * 1.被代理节点的父级不能出现scaleX和scaleY不一致的情况,被代理节点本身没有这个限制\r\n */\r\nconst { ccclass, property } = cc._decorator;\r\n@ccclass\r\nexport default class RenderAlternative extends cc.Component {\r\n /**渲染层节点 */\r\n public renderLayer: cc.Node = null;\r\n /**渲染的zIndex 动态调整zIndex,用于方便临近合批 */\r\n @property\r\n public renderZIndex: number = 0;\r\n /**同步的间隔(帧为单位) */\r\n @property({\r\n tooltip: '设置同步的间隔(秒为单位),0就是每帧都同步,0.1就是隔0.1秒同步一次'\r\n })\r\n public syncInv: number = 0.01;\r\n /**渲染的sIndex */\r\n public sIndex: number = 0;\r\n /**非渲染组件 */\r\n public proxyRender: cc.RenderComponent = null;\r\n /**渲染组件 */\r\n private renderCompnent: cc.RenderComponent = null;\r\n /**上次更新的数据 */\r\n public lastWMat4: cc.Mat4 = null;\r\n /**上次更新的数据 */\r\n public lastLMat4: cc.Mat4 = null;\r\n /**上次更新的数据 */\r\n public lastPos: cc.Vec3 = null;\r\n /**距离下次刷新累计了多少间隔 */\r\n public accuTime: number = 0;\r\n /**最后一次刷新时间 */\r\n public lastFrameTime: number = null;\r\n /**是否进行刷新 */\r\n public isAttachFrame: boolean = false;\r\n\r\n /**获取总的ZIndex */\r\n get zIndex() {\r\n let zIndex = this.renderZIndex + (this.sIndex * 0.01);\r\n let parentNode = this.node.parent;\r\n while (parentNode != this.renderLayer.parent && parentNode != cc.director.getScene()) {\r\n let render = parentNode.getComponent(RenderAlternative);\r\n if (render) {\r\n zIndex += render.zIndex + 1;\r\n break;\r\n }\r\n parentNode = parentNode.parent;\r\n }\r\n return zIndex;\r\n }\r\n\r\n /**\r\n * 设置渲染节点层\r\n * @param layer \r\n */\r\n init(layer?: cc.Node): T {\r\n if (layer) {\r\n this.renderLayer = layer;\r\n }\r\n if (!this.renderLayer) {\r\n console.warn(`节点${this.node.name}没有设置渲染层`)\r\n return null;\r\n }\r\n return this.initRender();\r\n }\r\n /**\r\n * 初始化渲染节点\r\n */\r\n private initRender(): T {\r\n let node = this.getRender();\r\n node.setParent(this.renderLayer ? this.renderLayer : cc.director.getScene().getChildByName(\"Canvas\"));\r\n this.isAttachFrame = true;\r\n requestAnimationFrame(this.frameUpdate.bind(this));\r\n return this.doProxy();\r\n }\r\n /**生成代理 */\r\n private doProxy(): T {\r\n this.proxyRender = new Proxy(this.renderCompnent, new RenderReactiveHandler()) as T;\r\n return this.proxyRender as T;\r\n }\r\n\r\n\r\n protected frameUpdate(): void {\r\n let now = cc.sys.now();\r\n !this.lastFrameTime && (this.lastFrameTime = now);\r\n let dt = now - this.lastFrameTime;\r\n if (this.proxyRender) {\r\n this.accuTime += dt;\r\n if (this.accuTime >= this.syncInv) {\r\n this.accuTime -= this.syncInv;\r\n this.updateProp();\r\n }\r\n }\r\n if (this.isAttachFrame) {\r\n requestAnimationFrame(this.frameUpdate.bind(this));\r\n }\r\n }\r\n\r\n /**更新最新状态 */\r\n public updateProp() {\r\n let node = this.renderCompnent.node;\r\n if (!this.node.activeInHierarchy) {\r\n node.opacity = 0;\r\n return;\r\n }\r\n node.anchorX = this.node.anchorX;\r\n node.anchorY = this.node.anchorY;\r\n node.width = this.node.width;\r\n node.height = this.node.height;\r\n node.group = this.node.group;\r\n node.color = this.node.color;\r\n node.opacity = this.getOpacity(this.node);\r\n\r\n let wMat4 = cc.mat4();\r\n this.node.getWorldMatrix(wMat4);\r\n /* let lMat4 = cc.mat4();\r\n this.node.getLocalMatrix(wMat4); */\r\n //此处本可以过滤许多不必要的更新,但尚未排查出问题\r\n if (true /* || !this.lastWMat4?.equals(wMat4) || !this.lastLMat4?.equals(lMat4) */) {\r\n this.onAngleChange(wMat4);\r\n this.onScaleChange(wMat4);\r\n this.onPosChange();\r\n /* this.lastLMat4 = lMat4;\r\n this.lastWMat4 = wMat4; */\r\n }\r\n node.zIndex = this.zIndex;\r\n node.zIndex = this.zIndex;\r\n }\r\n\r\n protected onDestroy(): void {\r\n this.renderCompnent.node.destroy();\r\n this.renderCompnent = null;\r\n this.proxyRender = null;\r\n }\r\n\r\n /**\r\n * 获取节点透明度\r\n * @param node \r\n */\r\n private getOpacity(node: cc.Node) {\r\n let opacity = (node.opacity / 255);\r\n let parentNode = node.parent\r\n while (parentNode != this.renderLayer.parent && parentNode != cc.director.getScene()) {\r\n opacity *= (parentNode.opacity / 255);\r\n parentNode = parentNode.parent;\r\n }\r\n return opacity * 255;\r\n }\r\n /**位置变化处理 */\r\n private onPosChange() {\r\n let wpos = this.node.parent.convertToWorldSpaceAR(this.node.position);\r\n this.renderCompnent.node.position = this.renderLayer.convertToNodeSpaceAR(wpos);\r\n }\r\n /**旋转变化处理 */\r\n private onAngleChange(mat4: cc.Mat4) {\r\n this.renderCompnent.node.angle = this.extractRotationAngleFromMat4(mat4);\r\n }\r\n /**\r\n * 从 cc.Mat4 中获取旋转角度(不受缩放影响)\r\n * @param matrix 输入的 cc.Mat4 矩阵\r\n * @returns 旋转角度(以度为单位)\r\n */\r\n private extractRotationAngleFromMat4(matrix: cc.Mat4): number {\r\n // 提取旋转部分\r\n let scaleX = Math.sqrt(matrix.m[0] * matrix.m[0] + matrix.m[4] * matrix.m[4] + matrix.m[8] * matrix.m[8]);\r\n let scaleY = Math.sqrt(matrix.m[1] * matrix.m[1] + matrix.m[5] * matrix.m[5] + matrix.m[9] * matrix.m[9]);\r\n\r\n // 计算 Z 轴旋转角度(绕 Z 轴的旋转角度)\r\n let angle = Math.atan2(matrix.m[1] / scaleY, matrix.m[0] / scaleX);\r\n\r\n // 将弧度转换为角度\r\n let degrees = angle * (180 / Math.PI);\r\n return degrees;\r\n }\r\n /**\r\n * 缩放变化处理\r\n * @param mat4 \r\n */\r\n private onScaleChange(mat4: cc.Mat4) {\r\n let scale = this.extractScaleFromMat4(mat4)\r\n this.renderCompnent.node.scaleX = scale.x;\r\n this.renderCompnent.node.scaleY = scale.y;\r\n this.renderCompnent.node.scaleZ = scale.z;\r\n }\r\n /**\r\n * 从mat4中获取缩放值\r\n * @param mat4 \r\n * @returns \r\n */\r\n private extractScaleFromMat4(mat4: cc.Mat4): cc.Vec3 {\r\n let scaleX = cc.v3(mat4.m[0], mat4.m[1], mat4.m[2]).mag();\r\n let scaleY = cc.v3(mat4.m[4], mat4.m[5], mat4.m[6]).mag();\r\n let scaleZ = cc.v3(mat4.m[8], mat4.m[9], mat4.m[10]).mag();\r\n return cc.v3(scaleX, scaleY, scaleZ);\r\n }\r\n /**\r\n * 获取渲染组件\r\n * @param node \r\n */\r\n private getRender() {\r\n let node = cc.instantiate(this.node);\r\n node.removeAllChildren();\r\n this.renderCompnent = node.getComponent(cc.RenderComponent);\r\n this.node.getComponent(cc.LabelOutline)?.destroy();\r\n this.node.getComponent(cc.LabelShadow)?.destroy();\r\n this.node.getComponent(cc.RenderComponent).destroy();\r\n let components = node.getComponents(cc.Component);\r\n for (let i = 0, len = components.length; i < len; ++i) {\r\n let comp = components[i];\r\n if (!((comp instanceof cc.RenderComponent) || (comp instanceof cc.LabelOutline) || (comp instanceof cc.LabelShadow))) {\r\n comp.destroy();\r\n }\r\n }\r\n return node;\r\n }\r\n\r\n}\r\n"]} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/1c/1c5e4038-953a-44c2-b620-0bbfc6170477.json b/Layered_virtual_list_2.x/library/imports/1c/1c5e4038-953a-44c2-b620-0bbfc6170477.json new file mode 100644 index 0000000..c9c8359 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/1c/1c5e4038-953a-44c2-b620-0bbfc6170477.json @@ -0,0 +1,109 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "cylinder", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "asyncLoadAssets": false, + "readonly": false + }, + { + "__type__": "cc.Node", + "_name": "cylinder", + "_objFlags": 0, + "_parent": null, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 2 + } + ], + "_prefab": { + "__id__": 3 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.MeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "a5849239-3ad3-41d1-8ab4-ae9fea11f97f" + } + ], + "_mesh": { + "__uuid__": "b430cea3-6ab3-4106-b073-26c698918edd" + }, + "_receiveShadows": false, + "_shadowCastingMode": 0, + "_enableAutoBatch": false, + "textures": [], + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "1c5e4038-953a-44c2-b620-0bbfc6170477" + }, + "fileId": "3dlUtIqQhGCrx5Sishojtq", + "sync": false + } +] \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/1f/1f55e3be-b89b-4b79-88de-47fd31018044.json b/Layered_virtual_list_2.x/library/imports/1f/1f55e3be-b89b-4b79-88de-47fd31018044.json new file mode 100644 index 0000000..5c4dfb3 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/1f/1f55e3be-b89b-4b79-88de-47fd31018044.json @@ -0,0 +1,112 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "sprite_splash", + "_objFlags": 0, + "data": { + "__id__": 1 + }, + "optimizationPolicy": 1, + "asyncLoadAssets": false, + "readonly": false + }, + { + "__type__": "cc.Node", + "_name": "New Sprite (Splash)", + "_objFlags": 0, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_cascadeOpacityEnabled": true, + "_parent": null, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 100 + }, + "_children": [], + "_skewX": 0, + "_skewY": 0, + "_localZOrder": 0, + "_globalZOrder": 0, + "_tag": -1, + "_opacityModifyRGB": false, + "_reorderChildDirty": false, + "_id": "", + "_active": true, + "_components": [ + { + "__id__": 2 + } + ], + "_prefab": { + "__id__": 3 + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "_spriteFrame": { + "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_atlas": null + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": null, + "fileId": "1a0f4zwu2VOapqEJkWXIF0R" + } +] \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/23/232d2782-c4bd-4bb4-9e01-909f03d6d3b9.json b/Layered_virtual_list_2.x/library/imports/23/232d2782-c4bd-4bb4-9e01-909f03d6d3b9.json new file mode 100644 index 0000000..40b3a2e --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/23/232d2782-c4bd-4bb4-9e01-909f03d6d3b9.json @@ -0,0 +1,108 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "videoplayer", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 1, + "asyncLoadAssets": false, + "readonly": false + }, + { + "__type__": "cc.Node", + "_name": "videoplayer", + "_objFlags": 0, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_cascadeOpacityEnabled": true, + "_parent": null, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 428, + "height": 240 + }, + "_children": [], + "_skewX": 0, + "_skewY": 0, + "_localZOrder": 0, + "_globalZOrder": 0, + "_tag": -1, + "_opacityModifyRGB": false, + "_reorderChildDirty": false, + "_id": "", + "_active": true, + "_components": [ + { + "__id__": 2 + } + ], + "_prefab": { + "__id__": 3 + }, + "groupIndex": 0, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.VideoPlayer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "_resourceType": 1, + "_remoteURL": "", + "_clip": { + "__uuid__": "2be36297-9abb-4fee-8049-9ed5e271da8a" + }, + "_time": 0, + "videoPlayerEvent": [], + "_N$keepAspectRatio": true, + "_N$isFullscreen": false + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "232d2782-c4bd-4bb4-9e01-909f03d6d3b9" + }, + "fileId": "f0e6ehf9IVMI51Egy+e0ZTA" + } +] \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/27/27756ebb-3d33-44b0-9b96-e858fadd4dd4.json b/Layered_virtual_list_2.x/library/imports/27/27756ebb-3d33-44b0-9b96-e858fadd4dd4.json new file mode 100644 index 0000000..d39c707 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/27/27756ebb-3d33-44b0-9b96-e858fadd4dd4.json @@ -0,0 +1,105 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "label", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 1, + "asyncLoadAssets": false, + "readonly": false + }, + { + "__type__": "cc.Node", + "_name": "Label", + "_objFlags": 0, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_cascadeOpacityEnabled": true, + "_parent": null, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 128, + "height": 50 + }, + "_children": [], + "_skewX": 0, + "_skewY": 0, + "_localZOrder": 0, + "_globalZOrder": 0, + "_ignoreAnchorPointForPosition": false, + "_tag": -1, + "_opacityModifyRGB": false, + "_id": "", + "_active": true, + "_components": [ + { + "__id__": 2 + } + ], + "_prefab": { + "__id__": 3 + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "_useOriginalSize": false, + "_fontSize": 40, + "_lineHeight": 40, + "_enableWrapText": true, + "_isSystemFontUsed": true, + "_N$string": "Label", + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$overflow": 0 + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": null, + "fileId": "d1cddH/doRNQ4Aodz8556bh" + } +] \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/28/2874f8dd-416c-4440-81b7-555975426e93.json b/Layered_virtual_list_2.x/library/imports/28/2874f8dd-416c-4440-81b7-555975426e93.json new file mode 100644 index 0000000..2a1c2d1 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/28/2874f8dd-416c-4440-81b7-555975426e93.json @@ -0,0 +1,136 @@ +{ + "__type__": "cc.EffectAsset", + "_name": "builtin-2d-sprite", + "_objFlags": 0, + "_native": "", + "properties": null, + "techniques": [ + { + "passes": [ + { + "blendState": { + "targets": [ + { + "blend": true + } + ] + }, + "rasterizerState": { + "cullMode": 0 + }, + "properties": { + "texture": { + "value": "white", + "type": 29 + }, + "alphaThreshold": { + "value": [ + 0.5 + ], + "type": 13 + } + }, + "program": "builtin-2d-sprite|vs|fs" + } + ] + } + ], + "shaders": [ + { + "hash": 2440430725, + "glsl3": { + "vert": "\nprecision highp float;\nuniform CCGlobal {\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\nuniform CCLocal {\n mat4 cc_matWorld;\n mat4 cc_matWorldIT;\n};\nin vec3 a_position;\nin vec4 a_color;\nout vec4 v_color;\n#if USE_TEXTURE\nin vec2 a_uv0;\nout vec2 v_uv0;\n#endif\nvoid main () {\n vec4 pos = vec4(a_position, 1);\n #if CC_USE_MODEL\n pos = cc_matViewProj * cc_matWorld * pos;\n #else\n pos = cc_matViewProj * pos;\n #endif\n #if USE_TEXTURE\n v_uv0 = a_uv0;\n #endif\n v_color = a_color;\n gl_Position = pos;\n}", + "frag": "\nprecision highp float;\n#if USE_ALPHA_TEST\n uniform ALPHA_TEST {\n float alphaThreshold;\n };\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\nin vec4 v_color;\n#if USE_TEXTURE\nin vec2 v_uv0;\nuniform sampler2D texture;\n#endif\nvoid main () {\n vec4 o = vec4(1, 1, 1, 1);\n #if USE_TEXTURE\n vec4 texture_tmp = texture(texture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture\n texture_tmp.a *= texture(texture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n o.rgb *= (texture_tmp.rgb * texture_tmp.rgb);\n o.a *= texture_tmp.a;\n #else\n o *= texture_tmp;\n #endif\n #endif\n o *= v_color;\n ALPHA_TEST(o);\n #if USE_BGRA\n gl_FragColor = o.bgra;\n #else\n gl_FragColor = o.rgba;\n #endif\n}" + }, + "glsl1": { + "vert": "\nprecision highp float;\nuniform mat4 cc_matViewProj;\nuniform mat4 cc_matWorld;\nattribute vec3 a_position;\nattribute vec4 a_color;\nvarying vec4 v_color;\n#if USE_TEXTURE\nattribute vec2 a_uv0;\nvarying vec2 v_uv0;\n#endif\nvoid main () {\n vec4 pos = vec4(a_position, 1);\n #if CC_USE_MODEL\n pos = cc_matViewProj * cc_matWorld * pos;\n #else\n pos = cc_matViewProj * pos;\n #endif\n #if USE_TEXTURE\n v_uv0 = a_uv0;\n #endif\n v_color = a_color;\n gl_Position = pos;\n}", + "frag": "\nprecision highp float;\n#if USE_ALPHA_TEST\n uniform float alphaThreshold;\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\nvarying vec4 v_color;\n#if USE_TEXTURE\nvarying vec2 v_uv0;\nuniform sampler2D texture;\n#endif\nvoid main () {\n vec4 o = vec4(1, 1, 1, 1);\n #if USE_TEXTURE\n vec4 texture_tmp = texture2D(texture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture\n texture_tmp.a *= texture2D(texture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n o.rgb *= (texture_tmp.rgb * texture_tmp.rgb);\n o.a *= texture_tmp.a;\n #else\n o *= texture_tmp;\n #endif\n #endif\n o *= v_color;\n ALPHA_TEST(o);\n #if USE_BGRA\n gl_FragColor = o.bgra;\n #else\n gl_FragColor = o.rgba;\n #endif\n}" + }, + "builtins": { + "globals": { + "blocks": [ + { + "name": "CCGlobal", + "defines": [] + } + ], + "samplers": [] + }, + "locals": { + "blocks": [ + { + "name": "CCLocal", + "defines": [] + } + ], + "samplers": [] + } + }, + "defines": [ + { + "name": "USE_TEXTURE", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_MODEL", + "type": "boolean", + "defines": [] + }, + { + "name": "USE_ALPHA_TEST", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_ALPHA_ATLAS_texture", + "type": "boolean", + "defines": [ + "USE_TEXTURE" + ] + }, + { + "name": "INPUT_IS_GAMMA", + "type": "boolean", + "defines": [ + "USE_TEXTURE" + ] + }, + { + "name": "USE_BGRA", + "type": "boolean", + "defines": [] + } + ], + "blocks": [ + { + "name": "ALPHA_TEST", + "members": [ + { + "name": "alphaThreshold", + "type": 13, + "count": 1 + } + ], + "defines": [ + "USE_ALPHA_TEST" + ], + "binding": 0 + } + ], + "samplers": [ + { + "name": "texture", + "type": 29, + "count": 1, + "defines": [ + "USE_TEXTURE" + ], + "binding": 30 + } + ], + "record": null, + "name": "builtin-2d-sprite|vs|fs" + } + ] +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/29/29158224-f8dd-4661-a796-1ffab537140e.json b/Layered_virtual_list_2.x/library/imports/29/29158224-f8dd-4661-a796-1ffab537140e.json new file mode 100644 index 0000000..67cf670 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/29/29158224-f8dd-4661-a796-1ffab537140e.json @@ -0,0 +1,28 @@ +{ + "__type__": "cc.SpriteFrame", + "content": { + "name": "default_btn_disabled", + "texture": "71561142-4c83-4933-afca-cb7a17f67053", + "atlas": "", + "rect": [ + 0, + 0, + 40, + 40 + ], + "offset": [ + 0, + 0 + ], + "originalSize": [ + 40, + 40 + ], + "capInsets": [ + 12, + 12, + 12, + 12 + ] + } +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/2a/2a296057-247c-4a1c-bbeb-0548b6c98650.json b/Layered_virtual_list_2.x/library/imports/2a/2a296057-247c-4a1c-bbeb-0548b6c98650.json new file mode 100644 index 0000000..42be778 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/2a/2a296057-247c-4a1c-bbeb-0548b6c98650.json @@ -0,0 +1,21 @@ +{ + "__type__": "cc.Material", + "_name": "builtin-unlit", + "_objFlags": 0, + "_native": "", + "_effectAsset": { + "__uuid__": "6d91e591-4ce0-465c-809f-610ec95019c6" + }, + "_techniqueData": { + "0": { + "props": { + "diffuseTexture": { + "__uuid__": "0275e94c-56a7-410f-bd1a-fc7483f7d14a" + } + }, + "defines": { + "USE_DIFFUSE_TEXTURE": true + } + } + } +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/2a/2a7c0036-e0b3-4fe1-8998-89a54b8a2bec.json b/Layered_virtual_list_2.x/library/imports/2a/2a7c0036-e0b3-4fe1-8998-89a54b8a2bec.json new file mode 100644 index 0000000..f9a0e79 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/2a/2a7c0036-e0b3-4fe1-8998-89a54b8a2bec.json @@ -0,0 +1,653 @@ +{ + "__type__": "cc.EffectAsset", + "_name": "builtin-3d-trail", + "_objFlags": 0, + "_native": "", + "properties": null, + "techniques": [ + { + "name": "add", + "passes": [ + { + "rasterizerState": { + "cullMode": 0 + }, + "blendState": { + "targets": [ + { + "blend": true, + "blendSrc": 770, + "blendDst": 1, + "blendSrcAlpha": 770, + "blendDstAlpha": 1 + } + ] + }, + "depthStencilState": { + "depthTest": true, + "depthWrite": false + }, + "properties": { + "mainTexture": { + "value": "grey", + "type": 29 + }, + "mainTiling_Offset": { + "value": [ + 1, + 1, + 0, + 0 + ], + "type": 16 + }, + "frameTile_velLenScale": { + "value": [ + 1, + 1, + 0, + 0 + ], + "type": 16 + }, + "tintColor": { + "value": [ + 0.5, + 0.5, + 0.5, + 0.5 + ], + "inspector": { + "type": "color" + }, + "type": 16 + } + }, + "program": "builtin-3d-trail|particle-trail:vs_main|tinted-fs:add" + } + ] + }, + { + "name": "alpha-blend", + "passes": [ + { + "rasterizerState": { + "cullMode": 0 + }, + "blendState": { + "targets": [ + { + "blend": true, + "blendSrc": 1, + "blendDst": 771, + "blendSrcAlpha": 1, + "blendDstAlpha": 771 + } + ] + }, + "depthStencilState": { + "depthTest": true, + "depthWrite": false + }, + "properties": { + "mainTexture": { + "value": "grey", + "type": 29 + }, + "mainTiling_Offset": { + "value": [ + 1, + 1, + 0, + 0 + ], + "type": 16 + }, + "frameTile_velLenScale": { + "value": [ + 1, + 1, + 0, + 0 + ], + "type": 16 + }, + "tintColor": { + "value": [ + 0.5, + 0.5, + 0.5, + 0.5 + ], + "inspector": { + "type": "color" + }, + "type": 16 + } + }, + "program": "builtin-3d-trail|particle-trail:vs_main|tinted-fs:add" + } + ] + }, + { + "name": "add-multiply", + "passes": [ + { + "rasterizerState": { + "cullMode": 0 + }, + "blendState": { + "targets": [ + { + "blend": true, + "blendSrc": 1, + "blendDst": 771, + "blendSrcAlpha": 1, + "blendDstAlpha": 771 + } + ] + }, + "depthStencilState": { + "depthTest": true, + "depthWrite": false + }, + "properties": { + "mainTexture": { + "value": "grey", + "type": 29 + }, + "mainTiling_Offset": { + "value": [ + 1, + 1, + 0, + 0 + ], + "type": 16 + }, + "frameTile_velLenScale": { + "value": [ + 1, + 1, + 0, + 0 + ], + "type": 16 + }, + "tintColor": { + "value": [ + 0.5, + 0.5, + 0.5, + 0.5 + ], + "inspector": { + "type": "color" + }, + "type": 16 + } + }, + "program": "builtin-3d-trail|particle-trail:vs_main|tinted-fs:multiply" + } + ] + }, + { + "name": "add-smooth", + "passes": [ + { + "rasterizerState": { + "cullMode": 0 + }, + "blendState": { + "targets": [ + { + "blend": true, + "blendSrc": 1, + "blendDst": 771, + "blendSrcAlpha": 1, + "blendDstAlpha": 771 + } + ] + }, + "depthStencilState": { + "depthTest": true, + "depthWrite": false + }, + "properties": { + "mainTexture": { + "value": "grey", + "type": 29 + }, + "mainTiling_Offset": { + "value": [ + 1, + 1, + 0, + 0 + ], + "type": 16 + }, + "frameTile_velLenScale": { + "value": [ + 1, + 1, + 0, + 0 + ], + "type": 16 + } + }, + "program": "builtin-3d-trail|particle-trail:vs_main|no-tint-fs:addSmooth" + } + ] + }, + { + "name": "premultiply-blend", + "passes": [ + { + "rasterizerState": { + "cullMode": 0 + }, + "blendState": { + "targets": [ + { + "blend": true, + "blendSrc": 1, + "blendDst": 771, + "blendSrcAlpha": 1, + "blendDstAlpha": 771 + } + ] + }, + "depthStencilState": { + "depthTest": true, + "depthWrite": false + }, + "properties": { + "mainTexture": { + "value": "grey", + "type": 29 + }, + "mainTiling_Offset": { + "value": [ + 1, + 1, + 0, + 0 + ], + "type": 16 + }, + "frameTile_velLenScale": { + "value": [ + 1, + 1, + 0, + 0 + ], + "type": 16 + } + }, + "program": "builtin-3d-trail|particle-trail:vs_main|no-tint-fs:premultiplied" + } + ] + } + ], + "shaders": [ + { + "hash": 2929688198, + "glsl3": { + "vert": "\nprecision mediump float;\nuniform Constants{\n vec4 mainTiling_Offset;\n vec4 frameTile_velLenScale;\n vec4 scale;\n};\nuniform CCGlobal {\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\nuniform CCLocal {\n mat4 cc_matWorld;\n mat4 cc_matWorldIT;\n};\nout vec2 uv;\nout vec4 color;\nin vec3 a_position;\nin vec4 a_texCoord;\nin vec3 a_texCoord1;\nin vec3 a_texCoord2;\nin vec4 a_color;\n#if CC_DRAW_WIRE_FRAME\n out vec3 vBarycentric;\n#endif\nvec4 vs_main() {\n highp vec4 pos = vec4(a_position, 1);\n vec4 velocity = vec4(a_texCoord1.xyz, 0);\n#if !CC_USE_WORLD_SPACE\n pos = cc_matWorld * pos;\n velocity = cc_matWorld * velocity;\n#endif\n float vertOffset = (a_texCoord.x - 0.5) * a_texCoord.y;\n vec3 camUp = normalize(cross(pos.xyz - cc_cameraPos.xyz, velocity.xyz));\n pos.xyz += camUp * vertOffset;\n pos = cc_matViewProj * pos;\n uv = a_texCoord.zw * mainTiling_Offset.xy + mainTiling_Offset.zw;;\n color = a_color;\n#if CC_DRAW_WIRE_FRAME\n vBarycentric = a_texCoord2;\n#endif\n return pos;\n}\nvoid main() { gl_Position = vs_main(); }", + "frag": "\nprecision mediump float;\nvec4 CCFragOutput (vec4 color) {\n #if OUTPUT_TO_GAMMA\n color.rgb = sqrt(color.rgb);\n #endif\n\treturn color;\n}\nin vec2 uv;\nin vec4 color;\n#if CC_DRAW_WIRE_FRAME\n in vec3 vBarycentric;\n#endif\nuniform sampler2D mainTexture;\nuniform FragConstants {\n vec4 tintColor;\n};\nvec4 add () {\n vec4 col = 2.0 * color * tintColor * texture(mainTexture, uv);\n #if CC_DRAW_WIRE_FRAME\n if (any(lessThan(vBarycentric, vec3(0.02)))) {\n col = vec4(0., 1., 1., 1.);\n }\n #endif\n return CCFragOutput(col);\n}\nout vec4 cc_FragColor;\nvoid main() { cc_FragColor = add(); }" + }, + "glsl1": { + "vert": "\nprecision mediump float;\nuniform vec4 mainTiling_Offset;\nuniform mat4 cc_matViewProj;\nuniform vec4 cc_cameraPos;\nuniform mat4 cc_matWorld;\nvarying vec2 uv;\nvarying vec4 color;\nattribute vec3 a_position;\nattribute vec4 a_texCoord;\nattribute vec3 a_texCoord1;\nattribute vec3 a_texCoord2;\nattribute vec4 a_color;\n#if CC_DRAW_WIRE_FRAME\n varying vec3 vBarycentric;\n#endif\nvec4 vs_main() {\n highp vec4 pos = vec4(a_position, 1);\n vec4 velocity = vec4(a_texCoord1.xyz, 0);\n#if !CC_USE_WORLD_SPACE\n pos = cc_matWorld * pos;\n velocity = cc_matWorld * velocity;\n#endif\n float vertOffset = (a_texCoord.x - 0.5) * a_texCoord.y;\n vec3 camUp = normalize(cross(pos.xyz - cc_cameraPos.xyz, velocity.xyz));\n pos.xyz += camUp * vertOffset;\n pos = cc_matViewProj * pos;\n uv = a_texCoord.zw * mainTiling_Offset.xy + mainTiling_Offset.zw;;\n color = a_color;\n#if CC_DRAW_WIRE_FRAME\n vBarycentric = a_texCoord2;\n#endif\n return pos;\n}\nvoid main() { gl_Position = vs_main(); }", + "frag": "\nprecision mediump float;\nvec4 CCFragOutput (vec4 color) {\n #if OUTPUT_TO_GAMMA\n color.rgb = sqrt(color.rgb);\n #endif\n\treturn color;\n}\nvarying vec2 uv;\nvarying vec4 color;\n#if CC_DRAW_WIRE_FRAME\n varying vec3 vBarycentric;\n#endif\nuniform sampler2D mainTexture;\nuniform vec4 tintColor;\nvec4 add () {\n vec4 col = 2.0 * color * tintColor * texture2D(mainTexture, uv);\n #if CC_DRAW_WIRE_FRAME\n if (any(lessThan(vBarycentric, vec3(0.02)))) {\n col = vec4(0., 1., 1., 1.);\n }\n #endif\n return CCFragOutput(col);\n}\nvoid main() { gl_FragColor = add(); }" + }, + "builtins": { + "globals": { + "blocks": [ + { + "name": "CCGlobal", + "defines": [] + } + ], + "samplers": [] + }, + "locals": { + "blocks": [ + { + "name": "CCLocal", + "defines": [] + } + ], + "samplers": [] + } + }, + "defines": [ + { + "name": "CC_DRAW_WIRE_FRAME", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_WORLD_SPACE", + "type": "boolean", + "defines": [] + }, + { + "name": "OUTPUT_TO_GAMMA", + "type": "boolean", + "defines": [] + } + ], + "blocks": [ + { + "name": "Constants", + "members": [ + { + "name": "mainTiling_Offset", + "type": 16, + "count": 1 + }, + { + "name": "frameTile_velLenScale", + "type": 16, + "count": 1 + }, + { + "name": "scale", + "type": 16, + "count": 1 + } + ], + "defines": [], + "binding": 0 + }, + { + "name": "FragConstants", + "members": [ + { + "name": "tintColor", + "type": 16, + "count": 1 + } + ], + "defines": [], + "binding": 1 + } + ], + "samplers": [ + { + "name": "mainTexture", + "type": 29, + "count": 1, + "defines": [], + "binding": 30 + } + ], + "record": null, + "name": "builtin-3d-trail|particle-trail:vs_main|tinted-fs:add" + }, + { + "hash": 4224037318, + "glsl3": { + "vert": "\nprecision mediump float;\nuniform Constants{\n vec4 mainTiling_Offset;\n vec4 frameTile_velLenScale;\n vec4 scale;\n};\nuniform CCGlobal {\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\nuniform CCLocal {\n mat4 cc_matWorld;\n mat4 cc_matWorldIT;\n};\nout vec2 uv;\nout vec4 color;\nin vec3 a_position;\nin vec4 a_texCoord;\nin vec3 a_texCoord1;\nin vec3 a_texCoord2;\nin vec4 a_color;\n#if CC_DRAW_WIRE_FRAME\n out vec3 vBarycentric;\n#endif\nvec4 vs_main() {\n highp vec4 pos = vec4(a_position, 1);\n vec4 velocity = vec4(a_texCoord1.xyz, 0);\n#if !CC_USE_WORLD_SPACE\n pos = cc_matWorld * pos;\n velocity = cc_matWorld * velocity;\n#endif\n float vertOffset = (a_texCoord.x - 0.5) * a_texCoord.y;\n vec3 camUp = normalize(cross(pos.xyz - cc_cameraPos.xyz, velocity.xyz));\n pos.xyz += camUp * vertOffset;\n pos = cc_matViewProj * pos;\n uv = a_texCoord.zw * mainTiling_Offset.xy + mainTiling_Offset.zw;;\n color = a_color;\n#if CC_DRAW_WIRE_FRAME\n vBarycentric = a_texCoord2;\n#endif\n return pos;\n}\nvoid main() { gl_Position = vs_main(); }", + "frag": "\nprecision mediump float;\nvec4 CCFragOutput (vec4 color) {\n #if OUTPUT_TO_GAMMA\n color.rgb = sqrt(color.rgb);\n #endif\n\treturn color;\n}\nin vec2 uv;\nin vec4 color;\n#if CC_DRAW_WIRE_FRAME\n in vec3 vBarycentric;\n#endif\nuniform sampler2D mainTexture;\nuniform FragConstants {\n vec4 tintColor;\n};\nvec4 multiply () {\n vec4 col;\n vec4 texColor = texture(mainTexture, uv);\n col.rgb = tintColor.rgb * texColor.rgb * color.rgb * vec3(2.0);\n col.a = (1.0 - texColor.a) * (tintColor.a * color.a * 2.0);\n #if CC_DRAW_WIRE_FRAME\n if (any(lessThan(vBarycentric, vec3(0.02)))) {\n col = vec4(0., 1., 1., col.a);\n }\n #endif\n return CCFragOutput(col);\n}\nout vec4 cc_FragColor;\nvoid main() { cc_FragColor = multiply(); }" + }, + "glsl1": { + "vert": "\nprecision mediump float;\nuniform vec4 mainTiling_Offset;\nuniform mat4 cc_matViewProj;\nuniform vec4 cc_cameraPos;\nuniform mat4 cc_matWorld;\nvarying vec2 uv;\nvarying vec4 color;\nattribute vec3 a_position;\nattribute vec4 a_texCoord;\nattribute vec3 a_texCoord1;\nattribute vec3 a_texCoord2;\nattribute vec4 a_color;\n#if CC_DRAW_WIRE_FRAME\n varying vec3 vBarycentric;\n#endif\nvec4 vs_main() {\n highp vec4 pos = vec4(a_position, 1);\n vec4 velocity = vec4(a_texCoord1.xyz, 0);\n#if !CC_USE_WORLD_SPACE\n pos = cc_matWorld * pos;\n velocity = cc_matWorld * velocity;\n#endif\n float vertOffset = (a_texCoord.x - 0.5) * a_texCoord.y;\n vec3 camUp = normalize(cross(pos.xyz - cc_cameraPos.xyz, velocity.xyz));\n pos.xyz += camUp * vertOffset;\n pos = cc_matViewProj * pos;\n uv = a_texCoord.zw * mainTiling_Offset.xy + mainTiling_Offset.zw;;\n color = a_color;\n#if CC_DRAW_WIRE_FRAME\n vBarycentric = a_texCoord2;\n#endif\n return pos;\n}\nvoid main() { gl_Position = vs_main(); }", + "frag": "\nprecision mediump float;\nvec4 CCFragOutput (vec4 color) {\n #if OUTPUT_TO_GAMMA\n color.rgb = sqrt(color.rgb);\n #endif\n\treturn color;\n}\nvarying vec2 uv;\nvarying vec4 color;\n#if CC_DRAW_WIRE_FRAME\n varying vec3 vBarycentric;\n#endif\nuniform sampler2D mainTexture;\nuniform vec4 tintColor;\nvec4 multiply () {\n vec4 col;\n vec4 texColor = texture2D(mainTexture, uv);\n col.rgb = tintColor.rgb * texColor.rgb * color.rgb * vec3(2.0);\n col.a = (1.0 - texColor.a) * (tintColor.a * color.a * 2.0);\n #if CC_DRAW_WIRE_FRAME\n if (any(lessThan(vBarycentric, vec3(0.02)))) {\n col = vec4(0., 1., 1., col.a);\n }\n #endif\n return CCFragOutput(col);\n}\nvoid main() { gl_FragColor = multiply(); }" + }, + "builtins": { + "globals": { + "blocks": [ + { + "name": "CCGlobal", + "defines": [] + } + ], + "samplers": [] + }, + "locals": { + "blocks": [ + { + "name": "CCLocal", + "defines": [] + } + ], + "samplers": [] + } + }, + "defines": [ + { + "name": "CC_DRAW_WIRE_FRAME", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_WORLD_SPACE", + "type": "boolean", + "defines": [] + }, + { + "name": "OUTPUT_TO_GAMMA", + "type": "boolean", + "defines": [] + } + ], + "blocks": [ + { + "name": "Constants", + "members": [ + { + "name": "mainTiling_Offset", + "type": 16, + "count": 1 + }, + { + "name": "frameTile_velLenScale", + "type": 16, + "count": 1 + }, + { + "name": "scale", + "type": 16, + "count": 1 + } + ], + "defines": [], + "binding": 0 + }, + { + "name": "FragConstants", + "members": [ + { + "name": "tintColor", + "type": 16, + "count": 1 + } + ], + "defines": [], + "binding": 1 + } + ], + "samplers": [ + { + "name": "mainTexture", + "type": 29, + "count": 1, + "defines": [], + "binding": 30 + } + ], + "record": null, + "name": "builtin-3d-trail|particle-trail:vs_main|tinted-fs:multiply" + }, + { + "hash": 1704877102, + "glsl3": { + "vert": "\nprecision mediump float;\nuniform Constants{\n vec4 mainTiling_Offset;\n vec4 frameTile_velLenScale;\n vec4 scale;\n};\nuniform CCGlobal {\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\nuniform CCLocal {\n mat4 cc_matWorld;\n mat4 cc_matWorldIT;\n};\nout vec2 uv;\nout vec4 color;\nin vec3 a_position;\nin vec4 a_texCoord;\nin vec3 a_texCoord1;\nin vec3 a_texCoord2;\nin vec4 a_color;\n#if CC_DRAW_WIRE_FRAME\n out vec3 vBarycentric;\n#endif\nvec4 vs_main() {\n highp vec4 pos = vec4(a_position, 1);\n vec4 velocity = vec4(a_texCoord1.xyz, 0);\n#if !CC_USE_WORLD_SPACE\n pos = cc_matWorld * pos;\n velocity = cc_matWorld * velocity;\n#endif\n float vertOffset = (a_texCoord.x - 0.5) * a_texCoord.y;\n vec3 camUp = normalize(cross(pos.xyz - cc_cameraPos.xyz, velocity.xyz));\n pos.xyz += camUp * vertOffset;\n pos = cc_matViewProj * pos;\n uv = a_texCoord.zw * mainTiling_Offset.xy + mainTiling_Offset.zw;;\n color = a_color;\n#if CC_DRAW_WIRE_FRAME\n vBarycentric = a_texCoord2;\n#endif\n return pos;\n}\nvoid main() { gl_Position = vs_main(); }", + "frag": "\nprecision mediump float;\nvec4 CCFragOutput (vec4 color) {\n #if OUTPUT_TO_GAMMA\n color.rgb = sqrt(color.rgb);\n #endif\n\treturn color;\n}\nin vec2 uv;\nin vec4 color;\nuniform sampler2D mainTexture;\nvec4 addSmooth () {\n vec4 col = color * texture(mainTexture, uv);\n col.rgb *= col.a;\n return CCFragOutput(col);\n}\nout vec4 cc_FragColor;\nvoid main() { cc_FragColor = addSmooth(); }" + }, + "glsl1": { + "vert": "\nprecision mediump float;\nuniform vec4 mainTiling_Offset;\nuniform mat4 cc_matViewProj;\nuniform vec4 cc_cameraPos;\nuniform mat4 cc_matWorld;\nvarying vec2 uv;\nvarying vec4 color;\nattribute vec3 a_position;\nattribute vec4 a_texCoord;\nattribute vec3 a_texCoord1;\nattribute vec3 a_texCoord2;\nattribute vec4 a_color;\n#if CC_DRAW_WIRE_FRAME\n varying vec3 vBarycentric;\n#endif\nvec4 vs_main() {\n highp vec4 pos = vec4(a_position, 1);\n vec4 velocity = vec4(a_texCoord1.xyz, 0);\n#if !CC_USE_WORLD_SPACE\n pos = cc_matWorld * pos;\n velocity = cc_matWorld * velocity;\n#endif\n float vertOffset = (a_texCoord.x - 0.5) * a_texCoord.y;\n vec3 camUp = normalize(cross(pos.xyz - cc_cameraPos.xyz, velocity.xyz));\n pos.xyz += camUp * vertOffset;\n pos = cc_matViewProj * pos;\n uv = a_texCoord.zw * mainTiling_Offset.xy + mainTiling_Offset.zw;;\n color = a_color;\n#if CC_DRAW_WIRE_FRAME\n vBarycentric = a_texCoord2;\n#endif\n return pos;\n}\nvoid main() { gl_Position = vs_main(); }", + "frag": "\nprecision mediump float;\nvec4 CCFragOutput (vec4 color) {\n #if OUTPUT_TO_GAMMA\n color.rgb = sqrt(color.rgb);\n #endif\n\treturn color;\n}\nvarying vec2 uv;\nvarying vec4 color;\nuniform sampler2D mainTexture;\nvec4 addSmooth () {\n vec4 col = color * texture2D(mainTexture, uv);\n col.rgb *= col.a;\n return CCFragOutput(col);\n}\nvoid main() { gl_FragColor = addSmooth(); }" + }, + "builtins": { + "globals": { + "blocks": [ + { + "name": "CCGlobal", + "defines": [] + } + ], + "samplers": [] + }, + "locals": { + "blocks": [ + { + "name": "CCLocal", + "defines": [] + } + ], + "samplers": [] + } + }, + "defines": [ + { + "name": "CC_DRAW_WIRE_FRAME", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_WORLD_SPACE", + "type": "boolean", + "defines": [] + }, + { + "name": "OUTPUT_TO_GAMMA", + "type": "boolean", + "defines": [] + } + ], + "blocks": [ + { + "name": "Constants", + "members": [ + { + "name": "mainTiling_Offset", + "type": 16, + "count": 1 + }, + { + "name": "frameTile_velLenScale", + "type": 16, + "count": 1 + }, + { + "name": "scale", + "type": 16, + "count": 1 + } + ], + "defines": [], + "binding": 0 + } + ], + "samplers": [ + { + "name": "mainTexture", + "type": 29, + "count": 1, + "defines": [], + "binding": 30 + } + ], + "record": null, + "name": "builtin-3d-trail|particle-trail:vs_main|no-tint-fs:addSmooth" + }, + { + "hash": 2717357054, + "glsl3": { + "vert": "\nprecision mediump float;\nuniform Constants{\n vec4 mainTiling_Offset;\n vec4 frameTile_velLenScale;\n vec4 scale;\n};\nuniform CCGlobal {\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\nuniform CCLocal {\n mat4 cc_matWorld;\n mat4 cc_matWorldIT;\n};\nout vec2 uv;\nout vec4 color;\nin vec3 a_position;\nin vec4 a_texCoord;\nin vec3 a_texCoord1;\nin vec3 a_texCoord2;\nin vec4 a_color;\n#if CC_DRAW_WIRE_FRAME\n out vec3 vBarycentric;\n#endif\nvec4 vs_main() {\n highp vec4 pos = vec4(a_position, 1);\n vec4 velocity = vec4(a_texCoord1.xyz, 0);\n#if !CC_USE_WORLD_SPACE\n pos = cc_matWorld * pos;\n velocity = cc_matWorld * velocity;\n#endif\n float vertOffset = (a_texCoord.x - 0.5) * a_texCoord.y;\n vec3 camUp = normalize(cross(pos.xyz - cc_cameraPos.xyz, velocity.xyz));\n pos.xyz += camUp * vertOffset;\n pos = cc_matViewProj * pos;\n uv = a_texCoord.zw * mainTiling_Offset.xy + mainTiling_Offset.zw;;\n color = a_color;\n#if CC_DRAW_WIRE_FRAME\n vBarycentric = a_texCoord2;\n#endif\n return pos;\n}\nvoid main() { gl_Position = vs_main(); }", + "frag": "\nprecision mediump float;\nvec4 CCFragOutput (vec4 color) {\n #if OUTPUT_TO_GAMMA\n color.rgb = sqrt(color.rgb);\n #endif\n\treturn color;\n}\nin vec2 uv;\nin vec4 color;\nuniform sampler2D mainTexture;\nvec4 premultiplied () {\n vec4 col = color * texture(mainTexture, uv) * color.a;\n return CCFragOutput(col);\n}\nout vec4 cc_FragColor;\nvoid main() { cc_FragColor = premultiplied(); }" + }, + "glsl1": { + "vert": "\nprecision mediump float;\nuniform vec4 mainTiling_Offset;\nuniform mat4 cc_matViewProj;\nuniform vec4 cc_cameraPos;\nuniform mat4 cc_matWorld;\nvarying vec2 uv;\nvarying vec4 color;\nattribute vec3 a_position;\nattribute vec4 a_texCoord;\nattribute vec3 a_texCoord1;\nattribute vec3 a_texCoord2;\nattribute vec4 a_color;\n#if CC_DRAW_WIRE_FRAME\n varying vec3 vBarycentric;\n#endif\nvec4 vs_main() {\n highp vec4 pos = vec4(a_position, 1);\n vec4 velocity = vec4(a_texCoord1.xyz, 0);\n#if !CC_USE_WORLD_SPACE\n pos = cc_matWorld * pos;\n velocity = cc_matWorld * velocity;\n#endif\n float vertOffset = (a_texCoord.x - 0.5) * a_texCoord.y;\n vec3 camUp = normalize(cross(pos.xyz - cc_cameraPos.xyz, velocity.xyz));\n pos.xyz += camUp * vertOffset;\n pos = cc_matViewProj * pos;\n uv = a_texCoord.zw * mainTiling_Offset.xy + mainTiling_Offset.zw;;\n color = a_color;\n#if CC_DRAW_WIRE_FRAME\n vBarycentric = a_texCoord2;\n#endif\n return pos;\n}\nvoid main() { gl_Position = vs_main(); }", + "frag": "\nprecision mediump float;\nvec4 CCFragOutput (vec4 color) {\n #if OUTPUT_TO_GAMMA\n color.rgb = sqrt(color.rgb);\n #endif\n\treturn color;\n}\nvarying vec2 uv;\nvarying vec4 color;\nuniform sampler2D mainTexture;\nvec4 premultiplied () {\n vec4 col = color * texture2D(mainTexture, uv) * color.a;\n return CCFragOutput(col);\n}\nvoid main() { gl_FragColor = premultiplied(); }" + }, + "builtins": { + "globals": { + "blocks": [ + { + "name": "CCGlobal", + "defines": [] + } + ], + "samplers": [] + }, + "locals": { + "blocks": [ + { + "name": "CCLocal", + "defines": [] + } + ], + "samplers": [] + } + }, + "defines": [ + { + "name": "CC_DRAW_WIRE_FRAME", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_WORLD_SPACE", + "type": "boolean", + "defines": [] + }, + { + "name": "OUTPUT_TO_GAMMA", + "type": "boolean", + "defines": [] + } + ], + "blocks": [ + { + "name": "Constants", + "members": [ + { + "name": "mainTiling_Offset", + "type": 16, + "count": 1 + }, + { + "name": "frameTile_velLenScale", + "type": 16, + "count": 1 + }, + { + "name": "scale", + "type": 16, + "count": 1 + } + ], + "defines": [], + "binding": 0 + } + ], + "samplers": [ + { + "name": "mainTexture", + "type": 29, + "count": 1, + "defines": [], + "binding": 30 + } + ], + "record": null, + "name": "builtin-3d-trail|particle-trail:vs_main|no-tint-fs:premultiplied" + } + ] +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/2b/2be36297-9abb-4fee-8049-9ed5e271da8a.json b/Layered_virtual_list_2.x/library/imports/2b/2be36297-9abb-4fee-8049-9ed5e271da8a.json new file mode 100644 index 0000000..368d8a6 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/2b/2be36297-9abb-4fee-8049-9ed5e271da8a.json @@ -0,0 +1,6 @@ +{ + "__type__": "cc.VideoClip", + "_name": "default_video", + "_objFlags": 0, + "_native": ".mp4" +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/2b/2be36297-9abb-4fee-8049-9ed5e271da8a.mp4 b/Layered_virtual_list_2.x/library/imports/2b/2be36297-9abb-4fee-8049-9ed5e271da8a.mp4 new file mode 100644 index 0000000..8159a03 Binary files /dev/null and b/Layered_virtual_list_2.x/library/imports/2b/2be36297-9abb-4fee-8049-9ed5e271da8a.mp4 differ diff --git a/Layered_virtual_list_2.x/library/imports/2c/2c937608-2562-40ea-b264-7395df6f0cea.json b/Layered_virtual_list_2.x/library/imports/2c/2c937608-2562-40ea-b264-7395df6f0cea.json new file mode 100644 index 0000000..35728e3 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/2c/2c937608-2562-40ea-b264-7395df6f0cea.json @@ -0,0 +1,249 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "canvas", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 1, + "asyncLoadAssets": false, + "readonly": false + }, + { + "__type__": "cc.Node", + "_name": "Canvas", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + } + ], + "_active": true, + "_components": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "_prefab": { + "__id__": 7 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 960, + "height": 640 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 480, + 320, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Main Camera", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 3 + } + ], + "_prefab": { + "__id__": 4 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 365.46272039703314, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Camera", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "_cullingMask": 4294967295, + "_clearFlags": 7, + "_backgroundColor": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_depth": -1, + "_zoomRatio": 1, + "_targetTexture": null, + "_fov": 60, + "_orthoSize": 10, + "_nearClip": 1, + "_farClip": 4096, + "_ortho": true, + "_rect": { + "__type__": "cc.Rect", + "x": 0, + "y": 0, + "width": 1, + "height": 1 + }, + "_renderStages": 1, + "_alignWithScreen": true, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "2c937608-2562-40ea-b264-7395df6f0cea" + }, + "fileId": "d2xIc1y/ZF6Kn7K3yqwDJm", + "sync": false + }, + { + "__type__": "cc.Canvas", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "_designResolution": { + "__type__": "cc.Size", + "width": 960, + "height": 640 + }, + "_fitWidth": false, + "_fitHeight": true, + "_id": "" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "alignMode": 1, + "_target": null, + "_alignFlags": 45, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 0, + "_originalHeight": 0, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "2c937608-2562-40ea-b264-7395df6f0cea" + }, + "fileId": "a6aa1W/pshGFZkMhhqxkZYP", + "sync": false + } +] \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/2d/2d2f792f-a40c-49bb-a189-ed176a246e49.json b/Layered_virtual_list_2.x/library/imports/2d/2d2f792f-a40c-49bb-a189-ed176a246e49.json new file mode 100644 index 0000000..1622c0d --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/2d/2d2f792f-a40c-49bb-a189-ed176a246e49.json @@ -0,0 +1,1954 @@ +[ + { + "__type__": "cc.SceneAsset", + "_name": "helloworld", + "_objFlags": 0, + "_native": "", + "scene": { + "__id__": 1 + }, + "asyncLoadAssets": false + }, + { + "__type__": "cc.Scene", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + } + ], + "_active": false, + "_components": [], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_is3DNode": true, + "_groupIndex": 0, + "groupIndex": 0, + "autoReleaseAssets": false, + "_id": "2d2f792f-a40c-49bb-a189-ed176a246e49" + }, + { + "__type__": "cc.Node", + "_name": "Canvas", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 3 + }, + { + "__id__": 5 + }, + { + "__id__": 9 + }, + { + "__id__": 17 + }, + { + "__id__": 26 + } + ], + "_active": true, + "_components": [ + { + "__id__": 46 + }, + { + "__id__": 47 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 252, + "g": 252, + "b": 252, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 750, + "height": 1334 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 375, + 667, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "a286bbGknJLZpRpxROV6M94" + }, + { + "__type__": "cc.Node", + "_name": "Main Camera", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 4 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "09K3aRxxtPX4CkhgKEDjJC" + }, + { + "__type__": "cc.Camera", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 3 + }, + "_enabled": true, + "_cullingMask": 4294967295, + "_clearFlags": 7, + "_backgroundColor": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_depth": -1, + "_zoomRatio": 1, + "_targetTexture": null, + "_fov": 60, + "_orthoSize": 10, + "_nearClip": 1, + "_farClip": 4096, + "_ortho": true, + "_rect": { + "__type__": "cc.Rect", + "x": 0, + "y": 0, + "width": 1, + "height": 1 + }, + "_renderStages": 1, + "_alignWithScreen": true, + "_id": "39hvvfgtBNGI33C9knv3qJ" + }, + { + "__type__": "cc.Node", + "_name": "TestLoop", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 6 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "ea+1z95MVNUJtfZx0Pj5uw" + }, + { + "__type__": "4850bCv26VE3LcjWQcJHche", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 5 + }, + "_enabled": true, + "rendeLayer": { + "__id__": 7 + }, + "scrollView": { + "__id__": 11 + }, + "showPrefab": { + "__uuid__": "6b1c6ed5-0dab-415a-b3cc-4408f270a2d0" + }, + "_id": "4ecJ/NvtNECq11eqajw/72" + }, + { + "__type__": "cc.Node", + "_name": "layer", + "_objFlags": 0, + "_parent": { + "__id__": 8 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 200, + "height": 300 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 123.761, + -500, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "50nGMWMotB8IRitJD4pcqd" + }, + { + "__type__": "cc.Node", + "_name": "view", + "_objFlags": 0, + "_parent": { + "__id__": 9 + }, + "_children": [ + { + "__id__": 12 + }, + { + "__id__": 7 + } + ], + "_active": true, + "_components": [ + { + "__id__": 15 + }, + { + "__id__": 16 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 750, + "height": 1000 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 1 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 500, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "c6mYKChI5JOIj+cE9APPY7" + }, + { + "__type__": "cc.Node", + "_name": "Vertical", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [ + { + "__id__": 8 + } + ], + "_active": true, + "_components": [ + { + "__id__": 10 + }, + { + "__id__": 11 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 750, + "height": 1000 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "43vHaNbn5LBatV59YArlhV" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 9 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "9bbda31e-ad49-43c9-aaf2-f7d9896bac69" + }, + "_type": 1, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "1d6unlyRJMsoRZ4n/erVRP" + }, + { + "__type__": "cc.ScrollView", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 9 + }, + "_enabled": true, + "horizontal": false, + "vertical": true, + "inertia": true, + "brake": 0.75, + "elastic": true, + "bounceDuration": 0.23, + "scrollEvents": [], + "cancelInnerEvents": true, + "_N$content": { + "__id__": 12 + }, + "content": { + "__id__": 12 + }, + "_N$horizontalScrollBar": null, + "_N$verticalScrollBar": null, + "_id": "85FvdcFWBDV4M9KxRZecCJ" + }, + { + "__type__": "cc.Node", + "_name": "content", + "_objFlags": 0, + "_parent": { + "__id__": 8 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 13 + }, + { + "__id__": 14 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 750, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 1 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "1bXfuT7ExLwJKge3owlyzF" + }, + { + "__type__": "cc.Layout", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 12 + }, + "_enabled": true, + "_layoutSize": { + "__type__": "cc.Size", + "width": 750, + "height": 0 + }, + "_resize": 1, + "_N$layoutType": 2, + "_N$cellSize": { + "__type__": "cc.Size", + "width": 40, + "height": 40 + }, + "_N$startAxis": 0, + "_N$paddingLeft": 0, + "_N$paddingRight": 0, + "_N$paddingTop": 0, + "_N$paddingBottom": 0, + "_N$spacingX": 0, + "_N$spacingY": 10, + "_N$verticalDirection": 1, + "_N$horizontalDirection": 0, + "_N$affectedByScale": false, + "_id": "97UH7rpo1KOJZZSsFYERBu" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 12 + }, + "_enabled": true, + "alignMode": 1, + "_target": null, + "_alignFlags": 41, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 220, + "_originalHeight": 0, + "_id": "94j1vJKZhC7rvaDXU/XM+I" + }, + { + "__type__": "cc.Mask", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 8 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_spriteFrame": null, + "_type": 0, + "_segments": 64, + "_N$alphaThreshold": 0, + "_N$inverted": false, + "_id": "cdlgF0KFZAAZzi3KNcEqEW" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 8 + }, + "_enabled": true, + "alignMode": 1, + "_target": null, + "_alignFlags": 45, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 240, + "_originalHeight": 250, + "_id": "a7YdvisBhKuIlN3CCuPMaJ" + }, + { + "__type__": "cc.Node", + "_name": "Horizontal", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [ + { + "__id__": 18 + } + ], + "_active": false, + "_components": [ + { + "__id__": 24 + }, + { + "__id__": 25 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 500, + "height": 1000 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "36VvP0G09KXaygeBwQJi38" + }, + { + "__type__": "cc.Node", + "_name": "view", + "_objFlags": 0, + "_parent": { + "__id__": 17 + }, + "_children": [ + { + "__id__": 19 + } + ], + "_active": true, + "_components": [ + { + "__id__": 22 + }, + { + "__id__": 23 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 500, + "height": 1000 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -250, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "5cVJZx64VDAbE0+GHS+ljM" + }, + { + "__type__": "cc.Node", + "_name": "content", + "_objFlags": 0, + "_parent": { + "__id__": 18 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 20 + }, + { + "__id__": 21 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 220, + "height": 1000 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "044WGrpVlJX6HvptTPUEC1" + }, + { + "__type__": "cc.Layout", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 19 + }, + "_enabled": true, + "_layoutSize": { + "__type__": "cc.Size", + "width": 220, + "height": 1000 + }, + "_resize": 1, + "_N$layoutType": 1, + "_N$cellSize": { + "__type__": "cc.Size", + "width": 40, + "height": 40 + }, + "_N$startAxis": 0, + "_N$paddingLeft": 0, + "_N$paddingRight": 0, + "_N$paddingTop": 0, + "_N$paddingBottom": 0, + "_N$spacingX": 0, + "_N$spacingY": 5, + "_N$verticalDirection": 1, + "_N$horizontalDirection": 0, + "_N$affectedByScale": false, + "_id": "55aN0610JMRq/gQKnyzhAY" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 19 + }, + "_enabled": true, + "alignMode": 1, + "_target": null, + "_alignFlags": 13, + "_left": 0, + "_right": 280, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 220, + "_originalHeight": 0, + "_id": "e4s1D76VBHvauUganIA4KW" + }, + { + "__type__": "cc.Mask", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 18 + }, + "_enabled": false, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_spriteFrame": null, + "_type": 0, + "_segments": 64, + "_N$alphaThreshold": 0, + "_N$inverted": false, + "_id": "bf6UMcWrhOr4jcJ8Xr/ccS" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 18 + }, + "_enabled": true, + "alignMode": 1, + "_target": null, + "_alignFlags": 45, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 240, + "_originalHeight": 250, + "_id": "795+OK4EFMo68XgmKpU2O+" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 17 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "9bbda31e-ad49-43c9-aaf2-f7d9896bac69" + }, + "_type": 1, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "27RDHW2iJEgbMioz+T5We3" + }, + { + "__type__": "cc.ScrollView", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 17 + }, + "_enabled": true, + "horizontal": true, + "vertical": false, + "inertia": true, + "brake": 0.75, + "elastic": true, + "bounceDuration": 0.23, + "scrollEvents": [], + "cancelInnerEvents": true, + "_N$content": { + "__id__": 19 + }, + "content": { + "__id__": 19 + }, + "_N$horizontalScrollBar": null, + "_N$verticalScrollBar": null, + "_id": "9f7KeQvGdBb42l9mua/S+H" + }, + { + "__type__": "cc.Node", + "_name": "parent", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [ + { + "__id__": 27 + }, + { + "__id__": 33 + }, + { + "__id__": 39 + } + ], + "_active": false, + "_components": [ + { + "__id__": 45 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 40, + "g": 168, + "b": 45, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 500, + "height": 500 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "4eapwQhy9FJr1oDtIF5XMt" + }, + { + "__type__": "cc.Node", + "_name": "1", + "_objFlags": 0, + "_parent": { + "__id__": 26 + }, + "_children": [ + { + "__id__": 28 + } + ], + "_active": true, + "_components": [ + { + "__id__": 31 + }, + { + "__id__": 32 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 100 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -80.714, + 123.761, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "cclp30DuxPI40Ql8RTgIp5" + }, + { + "__type__": "cc.Node", + "_name": "New Label", + "_objFlags": 0, + "_parent": { + "__id__": 27 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 29 + }, + { + "__id__": 30 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 22.25, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "d1NK110VBOjL8p0409QsTv" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 28 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_string": "1", + "_N$string": "1", + "_fontSize": 40, + "_lineHeight": 40, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_styleFlags": 0, + "_underlineHeight": 0, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 2, + "_id": "1ec9ZPVK9DiY33RUQtjAmR" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 28 + }, + "_enabled": true, + "renderLayer": { + "__id__": 7 + }, + "renderZIndex": 0, + "syncInv": 0, + "_id": "28rh4vPCtDH7mfQfnunwP+" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 27 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "dctkJzgctIRbPAF7CX/X0D" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 27 + }, + "_enabled": true, + "renderLayer": { + "__id__": 7 + }, + "renderZIndex": 0, + "syncInv": 0, + "_id": "34s75vARxOxYwCNg9irB9g" + }, + { + "__type__": "cc.Node", + "_name": "2", + "_objFlags": 0, + "_parent": { + "__id__": 26 + }, + "_children": [ + { + "__id__": 34 + } + ], + "_active": true, + "_components": [ + { + "__id__": 37 + }, + { + "__id__": 38 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 184, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 100 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -80.714, + 123.761, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "f3s/MnZNRHTIi/Q+H1UxKx" + }, + { + "__type__": "cc.Node", + "_name": "New Label", + "_objFlags": 0, + "_parent": { + "__id__": 33 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 35 + }, + { + "__id__": 36 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 22.25, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "d32B7NZuBGY63WBdbVTVyG" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 34 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_string": "2", + "_N$string": "2", + "_fontSize": 40, + "_lineHeight": 40, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_styleFlags": 0, + "_underlineHeight": 0, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 2, + "_id": "14NDOGnfhG9K+YOHXLcfhJ" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 34 + }, + "_enabled": true, + "renderLayer": { + "__id__": 7 + }, + "renderZIndex": 0, + "syncInv": 0, + "_id": "3b2tZBLXFLfbVjUa9moptZ" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 33 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "56VszVbJ5PB7PzxYIgK1UZ" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 33 + }, + "_enabled": true, + "renderLayer": { + "__id__": 7 + }, + "renderZIndex": 0, + "syncInv": 0, + "_id": "98jNMDg2NNpL0CwReAWY24" + }, + { + "__type__": "cc.Node", + "_name": "3", + "_objFlags": 0, + "_parent": { + "__id__": 26 + }, + "_children": [ + { + "__id__": 40 + } + ], + "_active": true, + "_components": [ + { + "__id__": 43 + }, + { + "__id__": 44 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 10, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 100 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -80.714, + 123.761, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "1e4i8OlSlN1L+L8ylsTJMp" + }, + { + "__type__": "cc.Node", + "_name": "New Label", + "_objFlags": 0, + "_parent": { + "__id__": 39 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 41 + }, + { + "__id__": 42 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 22.25, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "d8eW94wH5Emo/po5DP/fed" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 40 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_string": "3", + "_N$string": "3", + "_fontSize": 40, + "_lineHeight": 40, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_styleFlags": 0, + "_underlineHeight": 0, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 2, + "_id": "7fju1YtiROgKcUrz8Jbxoo" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 40 + }, + "_enabled": true, + "renderLayer": { + "__id__": 7 + }, + "renderZIndex": 0, + "syncInv": 0, + "_id": "04gNKYOURMUYIzBSFmEZQb" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 39 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "e3/Rip1ZxCQrAeRRXarp6n" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 39 + }, + "_enabled": true, + "renderLayer": { + "__id__": 7 + }, + "renderZIndex": 0, + "syncInv": 0, + "_id": "27WCjM2uhB5pVrJMpptJfp" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 26 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "69pO2jE6tFNr13iHtLu7XS" + }, + { + "__type__": "cc.Canvas", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "_designResolution": { + "__type__": "cc.Size", + "width": 750, + "height": 1334 + }, + "_fitWidth": true, + "_fitHeight": false, + "_id": "dfvGuB0gdP+bfdBA5GrvZn" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "alignMode": 1, + "_target": null, + "_alignFlags": 45, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 0, + "_originalHeight": 0, + "_id": "ddKTtCCMFIwpiha8iT+uxE" + } +] \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/2d/2d9a4b85-b0ab-4c46-84c5-18f393ab2058.json b/Layered_virtual_list_2.x/library/imports/2d/2d9a4b85-b0ab-4c46-84c5-18f393ab2058.json new file mode 100644 index 0000000..998101e --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/2d/2d9a4b85-b0ab-4c46-84c5-18f393ab2058.json @@ -0,0 +1,109 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "sphere", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "asyncLoadAssets": false, + "readonly": false + }, + { + "__type__": "cc.Node", + "_name": "sphere", + "_objFlags": 0, + "_parent": null, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 2 + } + ], + "_prefab": { + "__id__": 3 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.MeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "a5849239-3ad3-41d1-8ab4-ae9fea11f97f" + } + ], + "_mesh": { + "__uuid__": "3bbdb0f6-c5f6-45de-9f33-8b5cbafb4d6d" + }, + "_receiveShadows": false, + "_shadowCastingMode": 0, + "_enableAutoBatch": false, + "textures": [], + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "2d9a4b85-b0ab-4c46-84c5-18f393ab2058" + }, + "fileId": "e0chObmn1N5q+1kVoqVegu", + "sync": false + } +] \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/30/30682f87-9f0d-4f17-8a44-72863791461b.json b/Layered_virtual_list_2.x/library/imports/30/30682f87-9f0d-4f17-8a44-72863791461b.json new file mode 100644 index 0000000..c7d30ac --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/30/30682f87-9f0d-4f17-8a44-72863791461b.json @@ -0,0 +1,102 @@ +{ + "__type__": "cc.EffectAsset", + "_name": "builtin-2d-graphics", + "_objFlags": 0, + "_native": "", + "properties": null, + "techniques": [ + { + "passes": [ + { + "blendState": { + "targets": [ + { + "blend": true, + "blendSrc": 1, + "blendDst": 771, + "blendSrcAlpha": 1, + "blendDstAlpha": 771 + } + ] + }, + "rasterizerState": { + "cullMode": 0 + }, + "properties": { + "alphaThreshold": { + "value": [ + 0.5 + ], + "type": 13 + } + }, + "program": "builtin-2d-graphics|vs|fs" + } + ] + } + ], + "shaders": [ + { + "hash": 550349795, + "glsl3": { + "vert": "\nprecision highp float;\nuniform CCGlobal {\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\nuniform CCLocal {\n mat4 cc_matWorld;\n mat4 cc_matWorldIT;\n};\nin vec3 a_position;\nin vec4 a_color;\nout vec4 v_color;\nin float a_dist;\nout float v_dist;\nvoid main () {\n vec4 pos = vec4(a_position, 1);\n pos = cc_matViewProj * cc_matWorld * pos;\n v_color = a_color;\n v_dist = a_dist;\n gl_Position = pos;\n}", + "frag": "\n#if CC_SUPPORT_standard_derivatives\n #extension GL_OES_standard_derivatives : enable\n#endif\nprecision highp float;\n#if USE_ALPHA_TEST\n uniform ALPHA_TEST {\n float alphaThreshold;\n };\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\nin vec4 v_color;\nin float v_dist;\nvoid main () {\n vec4 o = v_color;\n ALPHA_TEST(o);\n #if CC_SUPPORT_standard_derivatives\n float aa = fwidth(v_dist);\n #else\n float aa = 0.05;\n #endif\n float alpha = 1. - smoothstep(-aa, 0., abs(v_dist) - 1.0);\n o.rgb *= o.a;\n o *= alpha;\n gl_FragColor = o;\n}" + }, + "glsl1": { + "vert": "\nprecision highp float;\nuniform mat4 cc_matViewProj;\nuniform mat4 cc_matWorld;\nattribute vec3 a_position;\nattribute vec4 a_color;\nvarying vec4 v_color;\nattribute float a_dist;\nvarying float v_dist;\nvoid main () {\n vec4 pos = vec4(a_position, 1);\n pos = cc_matViewProj * cc_matWorld * pos;\n v_color = a_color;\n v_dist = a_dist;\n gl_Position = pos;\n}", + "frag": "\n#if CC_SUPPORT_standard_derivatives\n #extension GL_OES_standard_derivatives : enable\n#endif\nprecision highp float;\n#if USE_ALPHA_TEST\n uniform float alphaThreshold;\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\nvarying vec4 v_color;\nvarying float v_dist;\nvoid main () {\n vec4 o = v_color;\n ALPHA_TEST(o);\n #if CC_SUPPORT_standard_derivatives\n float aa = fwidth(v_dist);\n #else\n float aa = 0.05;\n #endif\n float alpha = 1. - smoothstep(-aa, 0., abs(v_dist) - 1.0);\n o.rgb *= o.a;\n o *= alpha;\n gl_FragColor = o;\n}" + }, + "builtins": { + "globals": { + "blocks": [ + { + "name": "CCGlobal", + "defines": [] + } + ], + "samplers": [] + }, + "locals": { + "blocks": [ + { + "name": "CCLocal", + "defines": [] + } + ], + "samplers": [] + } + }, + "defines": [ + { + "name": "CC_SUPPORT_standard_derivatives", + "type": "boolean", + "defines": [] + }, + { + "name": "USE_ALPHA_TEST", + "type": "boolean", + "defines": [] + } + ], + "blocks": [ + { + "name": "ALPHA_TEST", + "members": [ + { + "name": "alphaThreshold", + "type": 13, + "count": 1 + } + ], + "defines": [ + "USE_ALPHA_TEST" + ], + "binding": 0 + } + ], + "samplers": [], + "record": null, + "name": "builtin-2d-graphics|vs|fs" + } + ] +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/31/31d8962d-babb-4ec7-be19-8e9f54a4ea99.json b/Layered_virtual_list_2.x/library/imports/31/31d8962d-babb-4ec7-be19-8e9f54a4ea99.json new file mode 100644 index 0000000..fba6fa5 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/31/31d8962d-babb-4ec7-be19-8e9f54a4ea99.json @@ -0,0 +1,28 @@ +{ + "__type__": "cc.SpriteFrame", + "content": { + "name": "default_scrollbar", + "texture": "0291c134-b3da-4098-b7b5-e397edbe947f", + "atlas": "", + "rect": [ + 0, + 0, + 30, + 15 + ], + "offset": [ + 0, + 0 + ], + "originalSize": [ + 30, + 15 + ], + "capInsets": [ + 10, + 4, + 10, + 4 + ] + } +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/32/32044bd2-481f-4cf1-a656-e2b2fb1594eb.json b/Layered_virtual_list_2.x/library/imports/32/32044bd2-481f-4cf1-a656-e2b2fb1594eb.json new file mode 100644 index 0000000..8176883 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/32/32044bd2-481f-4cf1-a656-e2b2fb1594eb.json @@ -0,0 +1,710 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "scrollview", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 1, + "asyncLoadAssets": false, + "readonly": false + }, + { + "__type__": "cc.Node", + "_name": "scrollview", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + }, + { + "__id__": 9 + } + ], + "_active": true, + "_components": [ + { + "__id__": 19 + }, + { + "__id__": 7 + } + ], + "_prefab": { + "__id__": 20 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 240, + "height": 250 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "scrollBar", + "_objFlags": 512, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 3 + } + ], + "_active": true, + "_components": [ + { + "__id__": 6 + }, + { + "__id__": 16 + }, + { + "__id__": 17 + } + ], + "_prefab": { + "__id__": 18 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 12, + "height": 250 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 1, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 120, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "bar", + "_objFlags": 512, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 4 + } + ], + "_prefab": { + "__id__": 5 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 10, + "height": 30 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 1, + "y": 0 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -1, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 3 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "5c3bb932-6c3c-468f-88a9-c8c61d458641" + }, + "_type": 1, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "32044bd2-481f-4cf1-a656-e2b2fb1594eb" + }, + "fileId": "b1f27kt1ClHyJvwBLxrEfQY", + "sync": false + }, + { + "__type__": "cc.Scrollbar", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "_scrollView": { + "__id__": 7 + }, + "_touching": false, + "_opacity": 255, + "enableAutoHide": true, + "autoHideTime": 1, + "_N$handle": { + "__id__": 4 + }, + "_N$direction": 1, + "_id": "" + }, + { + "__type__": "cc.ScrollView", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "horizontal": false, + "vertical": true, + "inertia": true, + "brake": 0.75, + "elastic": true, + "bounceDuration": 0.23, + "scrollEvents": [], + "cancelInnerEvents": true, + "_N$content": { + "__id__": 8 + }, + "content": { + "__id__": 8 + }, + "_N$horizontalScrollBar": null, + "_N$verticalScrollBar": { + "__id__": 6 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "content", + "_objFlags": 512, + "_parent": { + "__id__": 9 + }, + "_children": [ + { + "__id__": 12 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 15 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 220, + "height": 400 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 1 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 115.30999755859375, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "view", + "_objFlags": 512, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 8 + } + ], + "_active": true, + "_components": [ + { + "__id__": 10 + } + ], + "_prefab": { + "__id__": 11 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 240, + "height": 250 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Mask", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 9 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_spriteFrame": null, + "_type": 0, + "_segments": 64, + "_N$alphaThreshold": 0, + "_N$inverted": false, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "32044bd2-481f-4cf1-a656-e2b2fb1594eb" + }, + "fileId": "c1dc9Kk/CRJqaNnBOP4YGDS", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "item", + "_objFlags": 512, + "_parent": { + "__id__": 8 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 13 + } + ], + "_prefab": { + "__id__": 14 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 131.33, + "height": 65.2 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 1 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -102.19999694824219, + -10.149999618530273, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 12 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_useOriginalSize": false, + "_string": "ScrollView content\n\n", + "_N$string": "ScrollView content\n\n", + "_fontSize": 16, + "_lineHeight": 20, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_styleFlags": 0, + "_underlineHeight": 0, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 0, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 0, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "32044bd2-481f-4cf1-a656-e2b2fb1594eb" + }, + "fileId": "5280bTjVfhISb/ztQTswOuX", + "sync": false + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "32044bd2-481f-4cf1-a656-e2b2fb1594eb" + }, + "fileId": "036a4WKD5hBcbQJmMrbqoW8", + "sync": false + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "alignMode": 0, + "_target": null, + "_alignFlags": 37, + "_left": 350.07654921020657, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 0, + "_originalHeight": 237, + "_id": "" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "5fe5dcaa-b513-4dc5-a166-573627b3a159" + }, + "_type": 1, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "32044bd2-481f-4cf1-a656-e2b2fb1594eb" + }, + "fileId": "f8b835eFHxKj4uMGeoBGz+U", + "sync": false + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "9bbda31e-ad49-43c9-aaf2-f7d9896bac69" + }, + "_type": 1, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "32044bd2-481f-4cf1-a656-e2b2fb1594eb" + }, + "fileId": "2bb72ntvphNH4HtVfnSNUVp", + "sync": false + } +] \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/3a/3a3767fc-5a7c-4f4b-b174-8f4038113095.json b/Layered_virtual_list_2.x/library/imports/3a/3a3767fc-5a7c-4f4b-b174-8f4038113095.json new file mode 100644 index 0000000..175dc24 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/3a/3a3767fc-5a7c-4f4b-b174-8f4038113095.json @@ -0,0 +1,992 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "Item", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "asyncLoadAssets": false, + "readonly": false + }, + { + "__type__": "cc.Node", + "_name": "Item", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + }, + { + "__id__": 6 + }, + { + "__id__": 11 + }, + { + "__id__": 23 + } + ], + "_active": true, + "_components": [ + { + "__id__": 28 + } + ], + "_prefab": { + "__id__": 29 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 750, + "height": 80 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 1 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bg", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 3 + }, + { + "__id__": 4 + } + ], + "_prefab": { + "__id__": 5 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 48, + "g": 147, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 750, + "height": 80 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + -40, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "alignMode": 2, + "_target": null, + "_alignFlags": 45, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 100, + "_originalHeight": 100, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "2fWAV/kSxKbLNNotfg0pAI", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "nameLb", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 7 + }, + { + "__id__": 8 + }, + { + "__id__": 9 + } + ], + "_prefab": { + "__id__": 10 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 142.25, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -261.821, + -45.115, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 6 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_string": "我是第1", + "_N$string": "我是第1", + "_fontSize": 40, + "_lineHeight": 40, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_styleFlags": 1, + "_underlineHeight": 0, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 2, + "_id": "" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 6 + }, + "_enabled": true, + "renderZIndex": 1, + "syncInv": 0.01, + "_id": "" + }, + { + "__type__": "cc.LabelShadow", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 6 + }, + "_enabled": true, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_offset": { + "__type__": "cc.Vec2", + "x": 2, + "y": -5 + }, + "_blur": 2, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "50Nr1a5SVMCLPTFU4WTSCP", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "New Button", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 12 + } + ], + "_active": true, + "_components": [ + { + "__id__": 21 + } + ], + "_prefab": { + "__id__": 22 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -106.669, + -44.121, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Background", + "_objFlags": 0, + "_parent": { + "__id__": 11 + }, + "_children": [ + { + "__id__": 13 + } + ], + "_active": true, + "_components": [ + { + "__id__": 17 + }, + { + "__id__": 18 + }, + { + "__id__": 19 + } + ], + "_prefab": { + "__id__": 20 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 0 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Label", + "_objFlags": 0, + "_parent": { + "__id__": 12 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 14 + }, + { + "__id__": 15 + } + ], + "_prefab": { + "__id__": 16 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 13 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_string": "button", + "_N$string": "button", + "_fontSize": 20, + "_lineHeight": 40, + "_enableWrapText": false, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_styleFlags": 0, + "_underlineHeight": 0, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 1, + "_N$cacheMode": 2, + "_id": "" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 13 + }, + "_enabled": true, + "renderZIndex": 1, + "syncInv": 0.01, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "12747hBa5Ok7wyGD/cQP/v", + "sync": false + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 12 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952" + }, + "_type": 1, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 12 + }, + "_enabled": true, + "alignMode": 0, + "_target": null, + "_alignFlags": 45, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 100, + "_originalHeight": 40, + "_id": "" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 12 + }, + "_enabled": true, + "renderZIndex": 0, + "syncInv": 0.01, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "b2yBk+BHFOF7B8n1gYypgp", + "sync": false + }, + { + "__type__": "cc.Button", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 11 + }, + "_enabled": true, + "_normalMaterial": null, + "_grayMaterial": null, + "duration": 0.1, + "zoomScale": 1.2, + "clickEvents": [], + "_N$interactable": true, + "_N$enableAutoGrayEffect": false, + "_N$transition": 3, + "transition": 3, + "_N$normalColor": { + "__type__": "cc.Color", + "r": 230, + "g": 230, + "b": 230, + "a": 255 + }, + "_N$pressedColor": { + "__type__": "cc.Color", + "r": 200, + "g": 200, + "b": 200, + "a": 255 + }, + "pressedColor": { + "__type__": "cc.Color", + "r": 200, + "g": 200, + "b": 200, + "a": 255 + }, + "_N$hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$disabledColor": { + "__type__": "cc.Color", + "r": 120, + "g": 120, + "b": 120, + "a": 200 + }, + "_N$normalSprite": { + "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952" + }, + "_N$pressedSprite": { + "__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a" + }, + "pressedSprite": { + "__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a" + }, + "_N$hoverSprite": { + "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952" + }, + "hoverSprite": { + "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952" + }, + "_N$disabledSprite": { + "__uuid__": "29158224-f8dd-4661-a796-1ffab537140e" + }, + "_N$target": { + "__id__": 12 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "14TO6K8WlMjp8gwgtWA0qf", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "contentLb", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 24 + }, + { + "__id__": 25 + }, + { + "__id__": 26 + } + ], + "_prefab": { + "__id__": 27 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 333.07, + "height": 44 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 151.722, + -43.961, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 23 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_string": "ScrollView content", + "_N$string": "ScrollView content", + "_fontSize": 40, + "_lineHeight": 40, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_styleFlags": 0, + "_underlineHeight": 0, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 2, + "_id": "" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 23 + }, + "_enabled": true, + "renderZIndex": 1, + "syncInv": 0.01, + "_id": "" + }, + { + "__type__": "cc.LabelOutline", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 23 + }, + "_enabled": true, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_width": 2, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "41ShEz5VJCm68duiIf01ZR", + "sync": false + }, + { + "__type__": "7e1f6lmx11Hho9BNV3MqKkZ", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "nameLb": { + "__id__": 7 + }, + "contentLb": { + "__id__": 24 + }, + "Button": { + "__id__": 11 + }, + "ButtonLb": { + "__id__": 14 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "", + "sync": false + } +] \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/3a/3a7bb79f-32fd-422e-ada2-96f518fed422.json b/Layered_virtual_list_2.x/library/imports/3a/3a7bb79f-32fd-422e-ada2-96f518fed422.json new file mode 100644 index 0000000..b77eac2 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/3a/3a7bb79f-32fd-422e-ada2-96f518fed422.json @@ -0,0 +1,10 @@ +{ + "__type__": "cc.Material", + "_name": "builtin-2d-gray-sprite", + "_objFlags": 0, + "_native": "", + "_effectAsset": { + "__uuid__": "144c3297-af63-49e8-b8ef-1cfa29b3be28" + }, + "_techniqueData": {} +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/3b/3bbdb0f6-c5f6-45de-9f33-8b5cbafb4d6d.bin b/Layered_virtual_list_2.x/library/imports/3b/3bbdb0f6-c5f6-45de-9f33-8b5cbafb4d6d.bin new file mode 100644 index 0000000..f10cc50 Binary files /dev/null and b/Layered_virtual_list_2.x/library/imports/3b/3bbdb0f6-c5f6-45de-9f33-8b5cbafb4d6d.bin differ diff --git a/Layered_virtual_list_2.x/library/imports/3b/3bbdb0f6-c5f6-45de-9f33-8b5cbafb4d6d.json b/Layered_virtual_list_2.x/library/imports/3b/3bbdb0f6-c5f6-45de-9f33-8b5cbafb4d6d.json new file mode 100644 index 0000000..3237675 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/3b/3bbdb0f6-c5f6-45de-9f33-8b5cbafb4d6d.json @@ -0,0 +1,90 @@ +[ + { + "__type__": "cc.Mesh", + "_name": "", + "_objFlags": 0, + "_native": ".bin", + "_vertexBundles": [ + { + "__id__": 1 + } + ], + "_primitives": [ + { + "__id__": 6 + } + ], + "_minPos": { + "__type__": "cc.Vec3", + "x": -0.5, + "y": -0.5, + "z": -0.5 + }, + "_maxPos": { + "__type__": "cc.Vec3", + "x": 0.5, + "y": 0.5, + "z": 0.5 + } + }, + { + "__type__": "cc.mesh.VertexBundle", + "data": { + "__id__": 2 + }, + "formats": [ + { + "__id__": 3 + }, + { + "__id__": 4 + }, + { + "__id__": 5 + } + ], + "verticesCount": 1089 + }, + { + "__type__": "cc.BufferRange", + "offset": 0, + "length": 34848 + }, + { + "__type__": "cc.mesh.VertexFormat", + "name": "a_normal", + "type": 5126, + "num": 3, + "normalize": false + }, + { + "__type__": "cc.mesh.VertexFormat", + "name": "a_position", + "type": 5126, + "num": 3, + "normalize": false + }, + { + "__type__": "cc.mesh.VertexFormat", + "name": "a_uv0", + "type": 5126, + "num": 2, + "normalize": false + }, + { + "__type__": "cc.mesh.Primitive", + "vertexBundleIndices": [ + 0 + ], + "data": { + "__id__": 7 + }, + "indexUnit": 5123, + "topology": 4 + }, + { + "__type__": "cc.BufferRange", + "offset": 34848, + "length": 12288 + } +] \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/3e/3ed1232c-1b00-4818-8d5e-2112f30b11a4.json b/Layered_virtual_list_2.x/library/imports/3e/3ed1232c-1b00-4818-8d5e-2112f30b11a4.json new file mode 100644 index 0000000..6941318 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/3e/3ed1232c-1b00-4818-8d5e-2112f30b11a4.json @@ -0,0 +1,654 @@ +[ + { + "__type__": "cc.SceneAsset", + "_name": "TestMatrix", + "_objFlags": 0, + "_native": "", + "scene": { + "__id__": 1 + }, + "asyncLoadAssets": false + }, + { + "__type__": "cc.Scene", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + } + ], + "_active": true, + "_components": [], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_is3DNode": true, + "_groupIndex": 0, + "groupIndex": 0, + "autoReleaseAssets": false, + "_id": "3ed1232c-1b00-4818-8d5e-2112f30b11a4" + }, + { + "__type__": "cc.Node", + "_name": "Canvas", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 3 + }, + { + "__id__": 5 + }, + { + "__id__": 9 + } + ], + "_active": true, + "_components": [ + { + "__id__": 12 + }, + { + "__id__": 13 + }, + { + "__id__": 14 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 1334, + "height": 750 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 667, + 375, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "a5esZu+45LA5mBpvttspPD" + }, + { + "__type__": "cc.Node", + "_name": "Main Camera", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 4 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 960, + "height": 640 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "e1WoFrQ79G7r4ZuQE3HlNb" + }, + { + "__type__": "cc.Camera", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 3 + }, + "_enabled": true, + "_cullingMask": 4294967295, + "_clearFlags": 7, + "_backgroundColor": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_depth": -1, + "_zoomRatio": 1, + "_targetTexture": null, + "_fov": 60, + "_orthoSize": 10, + "_nearClip": 1, + "_farClip": 4096, + "_ortho": true, + "_rect": { + "__type__": "cc.Rect", + "x": 0, + "y": 0, + "width": 1, + "height": 1 + }, + "_renderStages": 1, + "_alignWithScreen": true, + "_id": "81GN3uXINKVLeW4+iKSlim" + }, + { + "__type__": "cc.Node", + "_name": "targetParent", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [ + { + "__id__": 6 + } + ], + "_active": true, + "_components": [ + { + "__id__": 8 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 40, + "height": 36 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -284.547, + -47.425, + 0, + 0, + 0, + 0.10452846326765347, + 0.9945218953682733, + 0.8, + 0.8, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 12 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "edt8E0W/NHXJRfLL5w0FEx" + }, + { + "__type__": "cc.Node", + "_name": "target", + "_objFlags": 0, + "_parent": { + "__id__": 5 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 7 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 234, + "g": 105, + "b": 105, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 40, + "height": 36 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 62.57, + -72.45, + 0, + 0, + 0, + 0.13917310096006544, + 0.9902680687415704, + 0.2, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 16 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "6eHCMdQvJGuZlXE52ZvHyf" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 6 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "8cdb44ac-a3f6-449f-b354-7cd48cf84061" + }, + "_type": 0, + "_sizeMode": 1, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "12C4OEfbpPZ7D293sA4N2X" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 5 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "8cdb44ac-a3f6-449f-b354-7cd48cf84061" + }, + "_type": 0, + "_sizeMode": 1, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "32BW2ujgdMuoadwfa8sy8R" + }, + { + "__type__": "cc.Node", + "_name": "SrcParent", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [ + { + "__id__": 10 + } + ], + "_active": true, + "_components": [], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 134.369, + 51.377, + 0, + 0, + 0, + -0.25881904510252074, + 0.9659258262890683, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": -30 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "fe2RbrNhxIUZiF7XIU03Th" + }, + { + "__type__": "cc.Node", + "_name": "src", + "_objFlags": 0, + "_parent": { + "__id__": 9 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 11 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 100 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -71.628, + 13.407, + 0, + 0, + 0, + 0, + 1, + 1.2, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "a6z5vIfndNfZSVcOsoQPPR" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 10 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "b41guspOdA+rTJ9wP8FM7K" + }, + { + "__type__": "cc.Canvas", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "_designResolution": { + "__type__": "cc.Size", + "width": 1334, + "height": 750 + }, + "_fitWidth": false, + "_fitHeight": true, + "_id": "59Cd0ovbdF4byw5sbjJDx7" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "alignMode": 1, + "_target": null, + "_alignFlags": 45, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 0, + "_originalHeight": 0, + "_id": "29zXboiXFBKoIV4PQ2liTe" + }, + { + "__type__": "41fb7HlhIJNzZMkSaq31ryP", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "target": { + "__id__": 6 + }, + "targetParent": { + "__id__": 5 + }, + "srcTarget": { + "__id__": 10 + }, + "srcTargetParent": { + "__id__": 9 + }, + "_id": "61Ee/a6NhDDKpan+btqgEB" + } +] \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/3f/3f376125-a699-40ca-ad05-04d662eaa1f2.json b/Layered_virtual_list_2.x/library/imports/3f/3f376125-a699-40ca-ad05-04d662eaa1f2.json new file mode 100644 index 0000000..5de9f59 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/3f/3f376125-a699-40ca-ad05-04d662eaa1f2.json @@ -0,0 +1,109 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "plane", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "asyncLoadAssets": false, + "readonly": false + }, + { + "__type__": "cc.Node", + "_name": "plane", + "_objFlags": 0, + "_parent": null, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 2 + } + ], + "_prefab": { + "__id__": 3 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.MeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "a5849239-3ad3-41d1-8ab4-ae9fea11f97f" + } + ], + "_mesh": { + "__uuid__": "a1ef2fc9-9c57-418a-8f69-6bed9a7a0e7f" + }, + "_receiveShadows": false, + "_shadowCastingMode": 0, + "_enableAutoBatch": false, + "textures": [], + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "3f376125-a699-40ca-ad05-04d662eaa1f2" + }, + "fileId": "9fhEbTXI1IApxjLqbjx+1L", + "sync": false + } +] \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/41/41fb71e5-8482-4dcd-9324-49aab7d6bc8f.js b/Layered_virtual_list_2.x/library/imports/41/41fb71e5-8482-4dcd-9324-49aab7d6bc8f.js new file mode 100644 index 0000000..23e7ac8 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/41/41fb71e5-8482-4dcd-9324-49aab7d6bc8f.js @@ -0,0 +1,158 @@ +"use strict"; +cc._RF.push(module, '41fb7HlhIJNzZMkSaq31ryP', 'TestMatrix'); +// Scene/TestMatrix.ts + +"use strict"; +// Learn TypeScript: +// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html +// Learn Attribute: +// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html +// Learn life-cycle callbacks: +// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property; +var NewClass = /** @class */ (function (_super) { + __extends(NewClass, _super); + function NewClass() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.target = null; + _this.targetParent = null; + _this.srcTarget = null; + _this.srcTargetParent = null; + return _this; + // update (dt) {} + } + // LIFE-CYCLE CALLBACKS: + NewClass.prototype.onLoad = function () { + // cc.director.on(cc.Director.EVENT_BEFORE_DRAW, this.onBeforeDraw, this); + }; + NewClass.prototype.start = function () { + // this.scheduleOnce(() => { + // this.target.x = 100; + // this.target.scaleX = 2; + // }, 3); + // this.scheduleOnce(() => { + // this.targetParent.x = 10; + // this.target.scaleX = 1.1; + // }, 1); + var targetNode = this.target; // 需要获取世界矩阵的节点 + var parentNode = this.targetParent; // 要转换到的节点 + var localMatrix = cc.mat4(); + targetNode.getLocalMatrix(localMatrix); + this.getMatrixInfo(localMatrix); + // 获取目标节点的世界矩阵 + var worldMatrix = cc.mat4(); + targetNode.getWorldMatrix(worldMatrix); + // 获取父节点的世界矩阵 + var parentWorldMatrix = cc.mat4(); + parentNode.getWorldMatrix(parentWorldMatrix); + // 获取父节点的逆矩阵 + var parentInverseMatrix = parentWorldMatrix.invert(); + // 将目标节点的世界矩阵转换为父节点的本地矩阵 + var localMatrix2 = parentInverseMatrix.multiply(worldMatrix); + this.getMatrixInfo(localMatrix2); + }; + NewClass.prototype.matrixTransform = function () { + // 假设我们有一个目标节点和一个父节点 + var targetNode = this.target; // 需要获取世界矩阵的节点 + var parentNode = this.srcTargetParent; // 要转换到的节点 + // 获取目标节点的世界矩阵 + var worldMatrix = cc.mat4(); + targetNode.getWorldMatrix(worldMatrix); + // 获取父节点的世界矩阵 + var parentWorldMatrix = cc.mat4(); + parentNode.getWorldMatrix(parentWorldMatrix); + // 获取父节点的逆矩阵 + var parentInverseMatrix = parentWorldMatrix.invert(); + // 将目标节点的世界矩阵转换为父节点的本地矩阵 + var localMatrix = parentInverseMatrix.multiply(worldMatrix); + // 提取位置 + var position = cc.v3(worldMatrix.m[12], worldMatrix.m[13], worldMatrix.m[14]); + // 提取缩放 + var scaleX = Math.sqrt(worldMatrix.m[0] * worldMatrix.m[0] + worldMatrix.m[1] * worldMatrix.m[1] + worldMatrix.m[2] * worldMatrix.m[2]); + var scaleY = Math.sqrt(worldMatrix.m[4] * worldMatrix.m[4] + worldMatrix.m[5] * worldMatrix.m[5] + worldMatrix.m[6] * worldMatrix.m[6]); + var scaleZ = Math.sqrt(worldMatrix.m[8] * worldMatrix.m[8] + worldMatrix.m[9] * worldMatrix.m[9] + worldMatrix.m[10] * worldMatrix.m[10]); + // 提取旋转(假设是二维旋转) + var angle = Math.atan2(worldMatrix.m[1] / scaleX, worldMatrix.m[0] / scaleX) * (180 / Math.PI); + // 输出结果 + console.log("Position:", position); + console.log("Scale:", cc.v3(scaleX, scaleY, scaleZ)); + console.log("Angle:", angle); + }; + NewClass.prototype.getMatrixInfo = function (matrix) { + // 提取位置 + var position = cc.v3(matrix.m[12], matrix.m[13], matrix.m[14]); + // 提取缩放 + var scaleX = Math.sqrt(matrix.m[0] * matrix.m[0] + matrix.m[1] * matrix.m[1] + matrix.m[2] * matrix.m[2]); + var scaleY = Math.sqrt(matrix.m[4] * matrix.m[4] + matrix.m[5] * matrix.m[5] + matrix.m[6] * matrix.m[6]); + var scaleZ = Math.sqrt(matrix.m[8] * matrix.m[8] + matrix.m[9] * matrix.m[9] + matrix.m[10] * matrix.m[10]); + // 提取旋转(假设是二维旋转) + var angle = Math.atan2(matrix.m[1] / scaleX, matrix.m[0] / scaleX) * (180 / Math.PI); + // 输出结果 + console.log("Position:", position); + console.log("Scale:", cc.v3(scaleX, scaleY, scaleZ)); + console.log("Angle:", angle); + }; + NewClass.prototype.onDestroy = function () { + cc.director.off(cc.Director.EVENT_BEFORE_DRAW, this.onBeforeDraw, this); + }; + NewClass.prototype.onBeforeDraw = function () { + this.checkDirty(this.target); + this.checkDirty(this.targetParent); + }; + NewClass.prototype.checkDirty = function (node) { + //@ts-ignore + var _localMatDirty = node._localMatDirty; + if (_localMatDirty) { + console.log(node.name, _localMatDirty); + } + //@ts-ignore + var _worldMatDirty = node._worldMatDirty; + if (_worldMatDirty) { + console.log(node.name, _worldMatDirty); + } + //@ts-ignore + var _renderFlag = node._renderFlag; + if (_renderFlag) { + console.log(node.name, _renderFlag); + } + }; + __decorate([ + property(cc.Node) + ], NewClass.prototype, "target", void 0); + __decorate([ + property(cc.Node) + ], NewClass.prototype, "targetParent", void 0); + __decorate([ + property(cc.Node) + ], NewClass.prototype, "srcTarget", void 0); + __decorate([ + property(cc.Node) + ], NewClass.prototype, "srcTargetParent", void 0); + NewClass = __decorate([ + ccclass + ], NewClass); + return NewClass; +}(cc.Component)); +exports.default = NewClass; + +cc._RF.pop(); \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/41/41fb71e5-8482-4dcd-9324-49aab7d6bc8f.js.map b/Layered_virtual_list_2.x/library/imports/41/41fb71e5-8482-4dcd-9324-49aab7d6bc8f.js.map new file mode 100644 index 0000000..1478edf --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/41/41fb71e5-8482-4dcd-9324-49aab7d6bc8f.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["assets\\Scene\\TestMatrix.ts"],"names":[],"mappings":";;;;;AAAA,oBAAoB;AACpB,wEAAwE;AACxE,mBAAmB;AACnB,kFAAkF;AAClF,8BAA8B;AAC9B,kFAAkF;;;;;;;;;;;;;;;;;;;;;AAE5E,IAAA,KAAwB,EAAE,CAAC,UAAU,EAAnC,OAAO,aAAA,EAAE,QAAQ,cAAkB,CAAC;AAG5C;IAAsC,4BAAY;IAAlD;QAAA,qEAyIC;QAtIG,YAAM,GAAY,IAAI,CAAC;QAGvB,kBAAY,GAAY,IAAI,CAAC;QAG7B,eAAS,GAAY,IAAI,CAAC;QAG1B,qBAAe,GAAY,IAAI,CAAC;;QA4HhC,iBAAiB;IACrB,CAAC;IA5HG,wBAAwB;IAExB,yBAAM,GAAN;QACI,0EAA0E;IAC9E,CAAC;IAED,wBAAK,GAAL;QACI,4BAA4B;QAC5B,2BAA2B;QAC3B,8BAA8B;QAC9B,SAAS;QAET,4BAA4B;QAC5B,gCAAgC;QAChC,gCAAgC;QAChC,SAAS;QACT,IAAI,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,cAAc;QAC5C,IAAI,UAAU,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC,UAAU;QAE9C,IAAI,WAAW,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC;QAC5B,UAAU,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;QACvC,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;QAEhC,cAAc;QACd,IAAI,WAAW,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC;QAC5B,UAAU,CAAC,cAAc,CAAC,WAAW,CAAC,CAAA;QACtC,aAAa;QACb,IAAI,iBAAiB,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC;QAClC,UAAU,CAAC,cAAc,CAAC,iBAAiB,CAAC,CAAC;QAE7C,YAAY;QACZ,IAAI,mBAAmB,GAAG,iBAAiB,CAAC,MAAM,EAAE,CAAC;QAErD,wBAAwB;QACxB,IAAI,YAAY,GAAG,mBAAmB,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;QAE7D,IAAI,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC;IAErC,CAAC;IAED,kCAAe,GAAf;QACI,oBAAoB;QACpB,IAAI,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,cAAc;QAC5C,IAAI,UAAU,GAAG,IAAI,CAAC,eAAe,CAAC,CAAC,UAAU;QAEjD,cAAc;QACd,IAAI,WAAW,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC;QAC5B,UAAU,CAAC,cAAc,CAAC,WAAW,CAAC,CAAA;QAEtC,aAAa;QACb,IAAI,iBAAiB,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC;QAClC,UAAU,CAAC,cAAc,CAAC,iBAAiB,CAAC,CAAA;QAE5C,YAAY;QACZ,IAAI,mBAAmB,GAAG,iBAAiB,CAAC,MAAM,EAAE,CAAC;QAErD,wBAAwB;QACxB,IAAI,WAAW,GAAG,mBAAmB,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;QAG5D,OAAO;QACP,IAAI,QAAQ,GAAG,EAAE,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAE9E,OAAO;QACP,IAAI,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACxI,IAAI,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACxI,IAAI,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAE1I,gBAAgB;QAChB,IAAI,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC;QAE/F,OAAO;QACP,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;QACnC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;QACrD,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IACjC,CAAC;IAED,gCAAa,GAAb,UAAc,MAAe;QACzB,OAAO;QACP,IAAI,QAAQ,GAAG,EAAE,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAE/D,OAAO;QACP,IAAI,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1G,IAAI,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1G,IAAI,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAE5G,gBAAgB;QAChB,IAAI,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC;QAErF,OAAO;QACP,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;QACnC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;QACrD,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IACjC,CAAC;IAED,4BAAS,GAAT;QACI,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,QAAQ,CAAC,iBAAiB,EAAE,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;IAC5E,CAAC;IAGD,+BAAY,GAAZ;QACI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC7B,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACvC,CAAC;IAED,6BAAU,GAAV,UAAW,IAAa;QACpB,YAAY;QACZ,IAAI,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC;QACzC,IAAI,cAAc,EAAE;YAChB,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;SAC1C;QACD,YAAY;QACZ,IAAI,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC;QACzC,IAAI,cAAc,EAAE;YAChB,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;SAC1C;QACD,YAAY;QACZ,IAAI,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;QACnC,IAAI,WAAW,EAAE;YACb,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;SACvC;IACL,CAAC;IAnID;QADC,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC;4CACK;IAGvB;QADC,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC;kDACW;IAG7B;QADC,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC;+CACQ;IAG1B;QADC,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC;qDACc;IAZf,QAAQ;QAD5B,OAAO;OACa,QAAQ,CAyI5B;IAAD,eAAC;CAzID,AAyIC,CAzIqC,EAAE,CAAC,SAAS,GAyIjD;kBAzIoB,QAAQ","file":"","sourceRoot":"/","sourcesContent":["// Learn TypeScript:\r\n// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html\r\n// Learn Attribute:\r\n// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html\r\n// Learn life-cycle callbacks:\r\n// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html\r\n\r\nconst { ccclass, property } = cc._decorator;\r\n\r\n@ccclass\r\nexport default class NewClass extends cc.Component {\r\n\r\n @property(cc.Node)\r\n target: cc.Node = null;\r\n\r\n @property(cc.Node)\r\n targetParent: cc.Node = null;\r\n\r\n @property(cc.Node)\r\n srcTarget: cc.Node = null;\r\n\r\n @property(cc.Node)\r\n srcTargetParent: cc.Node = null;\r\n // LIFE-CYCLE CALLBACKS:\r\n\r\n onLoad() {\r\n // cc.director.on(cc.Director.EVENT_BEFORE_DRAW, this.onBeforeDraw, this);\r\n }\r\n\r\n start() {\r\n // this.scheduleOnce(() => {\r\n // this.target.x = 100;\r\n // this.target.scaleX = 2;\r\n // }, 3);\r\n\r\n // this.scheduleOnce(() => {\r\n // this.targetParent.x = 10;\r\n // this.target.scaleX = 1.1;\r\n // }, 1);\r\n let targetNode = this.target; // 需要获取世界矩阵的节点\r\n let parentNode = this.targetParent; // 要转换到的节点\r\n\r\n let localMatrix = cc.mat4();\r\n targetNode.getLocalMatrix(localMatrix);\r\n this.getMatrixInfo(localMatrix);\r\n\r\n // 获取目标节点的世界矩阵\r\n let worldMatrix = cc.mat4();\r\n targetNode.getWorldMatrix(worldMatrix)\r\n // 获取父节点的世界矩阵\r\n let parentWorldMatrix = cc.mat4();\r\n parentNode.getWorldMatrix(parentWorldMatrix);\r\n\r\n // 获取父节点的逆矩阵\r\n let parentInverseMatrix = parentWorldMatrix.invert();\r\n\r\n // 将目标节点的世界矩阵转换为父节点的本地矩阵\r\n let localMatrix2 = parentInverseMatrix.multiply(worldMatrix);\r\n\r\n this.getMatrixInfo(localMatrix2);\r\n\r\n }\r\n\r\n matrixTransform() {\r\n // 假设我们有一个目标节点和一个父节点\r\n let targetNode = this.target; // 需要获取世界矩阵的节点\r\n let parentNode = this.srcTargetParent; // 要转换到的节点\r\n\r\n // 获取目标节点的世界矩阵\r\n let worldMatrix = cc.mat4();\r\n targetNode.getWorldMatrix(worldMatrix)\r\n\r\n // 获取父节点的世界矩阵\r\n let parentWorldMatrix = cc.mat4();\r\n parentNode.getWorldMatrix(parentWorldMatrix)\r\n\r\n // 获取父节点的逆矩阵\r\n let parentInverseMatrix = parentWorldMatrix.invert();\r\n\r\n // 将目标节点的世界矩阵转换为父节点的本地矩阵\r\n let localMatrix = parentInverseMatrix.multiply(worldMatrix);\r\n\r\n\r\n // 提取位置\r\n let position = cc.v3(worldMatrix.m[12], worldMatrix.m[13], worldMatrix.m[14]);\r\n\r\n // 提取缩放\r\n let scaleX = Math.sqrt(worldMatrix.m[0] * worldMatrix.m[0] + worldMatrix.m[1] * worldMatrix.m[1] + worldMatrix.m[2] * worldMatrix.m[2]);\r\n let scaleY = Math.sqrt(worldMatrix.m[4] * worldMatrix.m[4] + worldMatrix.m[5] * worldMatrix.m[5] + worldMatrix.m[6] * worldMatrix.m[6]);\r\n let scaleZ = Math.sqrt(worldMatrix.m[8] * worldMatrix.m[8] + worldMatrix.m[9] * worldMatrix.m[9] + worldMatrix.m[10] * worldMatrix.m[10]);\r\n\r\n // 提取旋转(假设是二维旋转)\r\n let angle = Math.atan2(worldMatrix.m[1] / scaleX, worldMatrix.m[0] / scaleX) * (180 / Math.PI);\r\n\r\n // 输出结果\r\n console.log(\"Position:\", position);\r\n console.log(\"Scale:\", cc.v3(scaleX, scaleY, scaleZ));\r\n console.log(\"Angle:\", angle);\r\n }\r\n\r\n getMatrixInfo(matrix: cc.Mat4) {\r\n // 提取位置\r\n let position = cc.v3(matrix.m[12], matrix.m[13], matrix.m[14]);\r\n\r\n // 提取缩放\r\n let scaleX = Math.sqrt(matrix.m[0] * matrix.m[0] + matrix.m[1] * matrix.m[1] + matrix.m[2] * matrix.m[2]);\r\n let scaleY = Math.sqrt(matrix.m[4] * matrix.m[4] + matrix.m[5] * matrix.m[5] + matrix.m[6] * matrix.m[6]);\r\n let scaleZ = Math.sqrt(matrix.m[8] * matrix.m[8] + matrix.m[9] * matrix.m[9] + matrix.m[10] * matrix.m[10]);\r\n\r\n // 提取旋转(假设是二维旋转)\r\n let angle = Math.atan2(matrix.m[1] / scaleX, matrix.m[0] / scaleX) * (180 / Math.PI);\r\n\r\n // 输出结果\r\n console.log(\"Position:\", position);\r\n console.log(\"Scale:\", cc.v3(scaleX, scaleY, scaleZ));\r\n console.log(\"Angle:\", angle);\r\n }\r\n\r\n onDestroy(): void {\r\n cc.director.off(cc.Director.EVENT_BEFORE_DRAW, this.onBeforeDraw, this);\r\n }\r\n\r\n\r\n onBeforeDraw() {\r\n this.checkDirty(this.target);\r\n this.checkDirty(this.targetParent);\r\n }\r\n\r\n checkDirty(node: cc.Node) {\r\n //@ts-ignore\r\n let _localMatDirty = node._localMatDirty;\r\n if (_localMatDirty) {\r\n console.log(node.name, _localMatDirty);\r\n }\r\n //@ts-ignore\r\n let _worldMatDirty = node._worldMatDirty;\r\n if (_worldMatDirty) {\r\n console.log(node.name, _worldMatDirty);\r\n }\r\n //@ts-ignore\r\n let _renderFlag = node._renderFlag;\r\n if (_renderFlag) {\r\n console.log(node.name, _renderFlag);\r\n }\r\n }\r\n\r\n // update (dt) {}\r\n}\r\n"]} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/43/4300f941-ba03-4d19-bdb1-959ef40f1852.json b/Layered_virtual_list_2.x/library/imports/43/4300f941-ba03-4d19-bdb1-959ef40f1852.json new file mode 100644 index 0000000..c73a4ee --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/43/4300f941-ba03-4d19-bdb1-959ef40f1852.json @@ -0,0 +1,28 @@ +{ + "__type__": "cc.SpriteFrame", + "content": { + "name": "default-particle", + "texture": "600301aa-3357-4a10-b086-84f011fa32ba", + "atlas": "", + "rect": [ + 2, + 2, + 61, + 61 + ], + "offset": [ + 0.5, + -0.5 + ], + "originalSize": [ + 64, + 64 + ], + "capInsets": [ + 0, + 0, + 0, + 0 + ] + } +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/43/430eccbf-bf2c-4e6e-8c0c-884bbb487f32.json b/Layered_virtual_list_2.x/library/imports/43/430eccbf-bf2c-4e6e-8c0c-884bbb487f32.json new file mode 100644 index 0000000..ff20bdc --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/43/430eccbf-bf2c-4e6e-8c0c-884bbb487f32.json @@ -0,0 +1,194 @@ +{ + "__type__": "cc.EffectAsset", + "_name": "__builtin-editor-gizmo-line", + "_objFlags": 0, + "_native": "", + "properties": null, + "techniques": [ + { + "passes": [ + { + "stage": "transparent", + "blendState": { + "targets": [ + { + "blend": true, + "blendEq": 32774, + "blendSrc": 770, + "blendDst": 1 + } + ] + }, + "rasterizerState": { + "cullMode": 0 + }, + "depthStencilState": { + "depthTest": true + }, + "properties": { + "diffuseColor": { + "value": [ + 1, + 1, + 1, + 1 + ], + "editor": { + "type": "color" + }, + "type": 16 + } + }, + "program": "__builtin-editor-gizmo-line|gizmo-line-vs|gizmo-line-fs:front" + }, + { + "stage": "transparent", + "blendState": { + "targets": [ + { + "blend": true, + "blendEq": 32774, + "blendSrc": 770, + "blendDst": 1 + } + ] + }, + "rasterizerState": { + "cullMode": 0 + }, + "depthStencilState": { + "depthTest": true, + "depthFunc": 516 + }, + "properties": { + "diffuseColor": { + "value": [ + 1, + 1, + 1, + 1 + ], + "editor": { + "type": "color" + }, + "type": 16 + } + }, + "program": "__builtin-editor-gizmo-line|gizmo-line-vs|gizmo-line-fs:back" + } + ] + } + ], + "shaders": [ + { + "hash": 2579669062, + "glsl3": { + "vert": "\nprecision highp float;\nuniform CCGlobal {\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\nuniform CCLocal {\n mat4 cc_matWorld;\n mat4 cc_matWorldIT;\n};\nattribute vec3 a_position;\nvoid main () {\n gl_Position = cc_matViewProj * cc_matWorld * vec4(a_position, 1);\n gl_Position.z -= 0.0001;\n}", + "frag": "\nprecision highp float;\nvec4 CCFragOutput (vec4 color) {\n #if OUTPUT_TO_GAMMA\n color.rgb = sqrt(color.rgb);\n #endif\n\treturn color;\n}\nuniform DIFFUSE_COLOR {\n vec4 diffuseColor;\n};\nvec4 front() {\n return CCFragOutput(diffuseColor);\n}\nout vec4 cc_FragColor;\nvoid main() { cc_FragColor = front(); }" + }, + "glsl1": { + "vert": "\nprecision highp float;\nuniform mat4 cc_matViewProj;\nuniform mat4 cc_matWorld;\nattribute vec3 a_position;\nvoid main () {\n gl_Position = cc_matViewProj * cc_matWorld * vec4(a_position, 1);\n gl_Position.z -= 0.0001;\n}", + "frag": "\nprecision highp float;\nvec4 CCFragOutput (vec4 color) {\n #if OUTPUT_TO_GAMMA\n color.rgb = sqrt(color.rgb);\n #endif\n\treturn color;\n}\nuniform vec4 diffuseColor;\nvec4 front() {\n return CCFragOutput(diffuseColor);\n}\nvoid main() { gl_FragColor = front(); }" + }, + "builtins": { + "globals": { + "blocks": [ + { + "name": "CCGlobal", + "defines": [] + } + ], + "samplers": [] + }, + "locals": { + "blocks": [ + { + "name": "CCLocal", + "defines": [] + } + ], + "samplers": [] + } + }, + "defines": [ + { + "name": "OUTPUT_TO_GAMMA", + "type": "boolean", + "defines": [] + } + ], + "blocks": [ + { + "name": "DIFFUSE_COLOR", + "members": [ + { + "name": "diffuseColor", + "type": 16, + "count": 1 + } + ], + "defines": [], + "binding": 0 + } + ], + "samplers": [], + "record": null, + "name": "__builtin-editor-gizmo-line|gizmo-line-vs|gizmo-line-fs:front" + }, + { + "hash": 2538316070, + "glsl3": { + "vert": "\nprecision highp float;\nuniform CCGlobal {\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\nuniform CCLocal {\n mat4 cc_matWorld;\n mat4 cc_matWorldIT;\n};\nattribute vec3 a_position;\nvoid main () {\n gl_Position = cc_matViewProj * cc_matWorld * vec4(a_position, 1);\n gl_Position.z -= 0.0001;\n}", + "frag": "\nprecision highp float;\nvec4 CCFragOutput (vec4 color) {\n #if OUTPUT_TO_GAMMA\n color.rgb = sqrt(color.rgb);\n #endif\n\treturn color;\n}\nuniform DIFFUSE_COLOR {\n vec4 diffuseColor;\n};\nvec4 back() {\n return CCFragOutput(vec4(diffuseColor.rgb, diffuseColor.a * 0.2));\n}\nout vec4 cc_FragColor;\nvoid main() { cc_FragColor = back(); }" + }, + "glsl1": { + "vert": "\nprecision highp float;\nuniform mat4 cc_matViewProj;\nuniform mat4 cc_matWorld;\nattribute vec3 a_position;\nvoid main () {\n gl_Position = cc_matViewProj * cc_matWorld * vec4(a_position, 1);\n gl_Position.z -= 0.0001;\n}", + "frag": "\nprecision highp float;\nvec4 CCFragOutput (vec4 color) {\n #if OUTPUT_TO_GAMMA\n color.rgb = sqrt(color.rgb);\n #endif\n\treturn color;\n}\nuniform vec4 diffuseColor;\nvec4 back() {\n return CCFragOutput(vec4(diffuseColor.rgb, diffuseColor.a * 0.2));\n}\nvoid main() { gl_FragColor = back(); }" + }, + "builtins": { + "globals": { + "blocks": [ + { + "name": "CCGlobal", + "defines": [] + } + ], + "samplers": [] + }, + "locals": { + "blocks": [ + { + "name": "CCLocal", + "defines": [] + } + ], + "samplers": [] + } + }, + "defines": [ + { + "name": "OUTPUT_TO_GAMMA", + "type": "boolean", + "defines": [] + } + ], + "blocks": [ + { + "name": "DIFFUSE_COLOR", + "members": [ + { + "name": "diffuseColor", + "type": 16, + "count": 1 + } + ], + "defines": [], + "binding": 0 + } + ], + "samplers": [], + "record": null, + "name": "__builtin-editor-gizmo-line|gizmo-line-vs|gizmo-line-fs:back" + } + ] +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/43/432fa09c-cf03-4cff-a186-982604408a07.json b/Layered_virtual_list_2.x/library/imports/43/432fa09c-cf03-4cff-a186-982604408a07.json new file mode 100644 index 0000000..8912483 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/43/432fa09c-cf03-4cff-a186-982604408a07.json @@ -0,0 +1,39 @@ +{ + "__type__": "cc.Material", + "_name": "builtin-3d-particle", + "_objFlags": 0, + "_native": "", + "_effectAsset": { + "__uuid__": "829a282c-b049-4019-bd38-5ace8d8a6417" + }, + "_techniqueData": { + "0": { + "props": { + "mainTexture": { + "__uuid__": "600301aa-3357-4a10-b086-84f011fa32ba" + }, + "mainTiling_Offset": { + "__type__": "cc.Vec4", + "x": 1, + "y": 1, + "z": 0, + "w": 0 + }, + "tintColor": { + "__type__": "cc.Color", + "r": 172, + "g": 165, + "b": 165, + "a": 127 + } + }, + "defines": { + "CC_USE_BILLBOARD": true, + "CC_USE_STRETCHED_BILLBOARD": false, + "CC_USE_HORIZONTAL_BILLBOARD": false, + "CC_USE_VERTICAL_BILLBOARD": false, + "CC_USE_MESH": false + } + } + } +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/46/466d4f9b-e5f4-4ea8-85d5-3c6e9a65658a.json b/Layered_virtual_list_2.x/library/imports/46/466d4f9b-e5f4-4ea8-85d5-3c6e9a65658a.json new file mode 100644 index 0000000..e2f3cfe --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/46/466d4f9b-e5f4-4ea8-85d5-3c6e9a65658a.json @@ -0,0 +1,18 @@ +{ + "__type__": "cc.Material", + "_name": "builtin-3d-trail", + "_objFlags": 0, + "_native": "", + "_effectAsset": { + "__uuid__": "2a7c0036-e0b3-4fe1-8998-89a54b8a2bec" + }, + "_techniqueData": { + "0": { + "props": { + "mainTexture": { + "__uuid__": "0275e94c-56a7-410f-bd1a-fc7483f7d14a" + } + } + } + } +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/47/472df5d3-35e7-4184-9e6c-7f41bee65ee3.json b/Layered_virtual_list_2.x/library/imports/47/472df5d3-35e7-4184-9e6c-7f41bee65ee3.json new file mode 100644 index 0000000..aa87208 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/47/472df5d3-35e7-4184-9e6c-7f41bee65ee3.json @@ -0,0 +1,28 @@ +{ + "__type__": "cc.SpriteFrame", + "content": { + "name": "atom", + "texture": "d0a82d39-bede-46c4-b698-c81ff0dedfff", + "atlas": "", + "rect": [ + 0, + 0, + 31, + 31 + ], + "offset": [ + 0, + 0 + ], + "originalSize": [ + 31, + 31 + ], + "capInsets": [ + 0, + 0, + 0, + 0 + ] + } +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/48/4850b0af-dba5-44dc-b723-5907091dc85e.js b/Layered_virtual_list_2.x/library/imports/48/4850b0af-dba5-44dc-b723-5907091dc85e.js new file mode 100644 index 0000000..a5410f0 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/48/4850b0af-dba5-44dc-b723-5907091dc85e.js @@ -0,0 +1,97 @@ +"use strict"; +cc._RF.push(module, '4850bCv26VE3LcjWQcJHche', 'TestLoop'); +// Scene/TestLoop.ts + +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.TestLoop = void 0; +var LoopList_1 = require("../Script/LoopList"); +var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property; +var TestLoop = /** @class */ (function (_super) { + __extends(TestLoop, _super); + function TestLoop() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /**分层渲染节点 */ + _this.rendeLayer = null; + /**显示节点预制件 */ + _this.scrollView = null; + /**显示节点预制件 */ + _this.showPrefab = null; + return _this; + } + TestLoop.prototype.start = function () { + //测试横向宽高数据 + /* let baseWidth = 80; + let changeWidth = 20; + let baseHeight = 600; + let changeHeight = 150; + let anchor = cc.v2(0.5, 0.5) */ + //测试纵向宽高数据 + var baseWidth = 600; + var changeWidth = 150; + var baseHeight = 80; + var changeHeight = 20; + var anchor = cc.v2(0.5, 0.5); + var data = []; + for (var i = 0, len = 30; i < len; ++i) { + data.push({ + index: i, text: "内容" + i + }); + } + LoopList_1.default.ins("Test").init(this.scrollView, this.rendeLayer, 18); + LoopList_1.default.ins("Test").initData(data, this.showPrefab, cc.size(baseWidth, baseHeight), anchor); + /* //测试插入数据 + this.scheduleOnce(() => { + LoopList.ins("Test").insertData({ index: 1, text: "我是插入1", size: cc.size(baseWidth, baseHeight) }, 1); + }, 3) + + //测试压入数据 + this.scheduleOnce(() => { + LoopList.ins("Test").pushDatas([ + { index: 1, text: "我是压入1", size: cc.size(baseWidth, baseHeight) }, + { index: 2, text: "我是压入2", size: cc.size(baseWidth, baseHeight) }, + { index: 3, text: "我是压入3", size: cc.size(baseWidth, baseHeight) }, + ]); + }, 4) + + //测试压入数据 + this.scheduleOnce(() => { + LoopList.ins("Test").removeData(1); + }, 5) */ + }; + __decorate([ + property(cc.Node) + ], TestLoop.prototype, "rendeLayer", void 0); + __decorate([ + property(cc.ScrollView) + ], TestLoop.prototype, "scrollView", void 0); + __decorate([ + property(cc.Prefab) + ], TestLoop.prototype, "showPrefab", void 0); + TestLoop = __decorate([ + ccclass + ], TestLoop); + return TestLoop; +}(cc.Component)); +exports.TestLoop = TestLoop; + +cc._RF.pop(); \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/48/4850b0af-dba5-44dc-b723-5907091dc85e.js.map b/Layered_virtual_list_2.x/library/imports/48/4850b0af-dba5-44dc-b723-5907091dc85e.js.map new file mode 100644 index 0000000..d1118fb --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/48/4850b0af-dba5-44dc-b723-5907091dc85e.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["assets\\Scene\\TestLoop.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,+CAA0C;AAEpC,IAAA,KAAwB,EAAE,CAAC,UAAU,EAAnC,OAAO,aAAA,EAAE,QAAQ,cAAkB,CAAC;AAG5C;IAA8B,4BAAY;IAA1C;QAAA,qEAsDC;QArDG,YAAY;QAEL,gBAAU,GAAY,IAAI,CAAC;QAClC,aAAa;QAEN,gBAAU,GAAkB,IAAI,CAAC;QACxC,aAAa;QAEN,gBAAU,GAAc,IAAI,CAAC;;IA6CxC,CAAC;IA3CG,wBAAK,GAAL;QACI,UAAU;QACV;;;;uCAI+B;QAE/B,UAAU;QACV,IAAI,SAAS,GAAG,GAAG,CAAC;QACpB,IAAI,WAAW,GAAG,GAAG,CAAC;QACtB,IAAI,UAAU,GAAG,EAAE,CAAC;QACpB,IAAI,YAAY,GAAG,EAAE,CAAC;QACtB,IAAI,MAAM,GAAG,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QAE7B,IAAI,IAAI,GAAY,EAAE,CAAC;QACvB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,EAAE,EAAE,CAAC,GAAG,GAAG,EAAE,EAAE,CAAC,EAAE;YACpC,IAAI,CAAC,IAAI,CAAC;gBACN,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,GAAG,CAAC;aAC3B,CAAC,CAAC;SACN;QACD,kBAAQ,CAAC,GAAG,CAAQ,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;QACvE,kBAAQ,CAAC,GAAG,CAAQ,MAAM,CAAC,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,UAAU,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,CAAC;QAEpG;;;;;;;;;;;;;;;;;gBAiBQ;IACZ,CAAC;IAlDD;QADC,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC;gDACgB;IAGlC;QADC,QAAQ,CAAC,EAAE,CAAC,UAAU,CAAC;gDACgB;IAGxC;QADC,QAAQ,CAAC,EAAE,CAAC,MAAM,CAAC;gDACgB;IAT3B,QAAQ;QADpB,OAAO;OACK,QAAQ,CAsDpB;IAAD,eAAC;CAtDD,AAsDC,CAtD6B,EAAE,CAAC,SAAS,GAsDzC;AAtDY,4BAAQ","file":"","sourceRoot":"/","sourcesContent":["\r\n\r\nimport LoopList from '../Script/LoopList';\r\nimport { IData } from './TestShowNode';\r\nconst { ccclass, property } = cc._decorator;\r\n\r\n@ccclass\r\nexport class TestLoop extends cc.Component {\r\n /**分层渲染节点 */\r\n @property(cc.Node)\r\n public rendeLayer: cc.Node = null;\r\n /**显示节点预制件 */\r\n @property(cc.ScrollView)\r\n public scrollView: cc.ScrollView = null;\r\n /**显示节点预制件 */\r\n @property(cc.Prefab)\r\n public showPrefab: cc.Prefab = null;\r\n\r\n start() {\r\n //测试横向宽高数据\r\n /* let baseWidth = 80;\r\n let changeWidth = 20;\r\n let baseHeight = 600;\r\n let changeHeight = 150;\r\n let anchor = cc.v2(0.5, 0.5) */\r\n\r\n //测试纵向宽高数据\r\n let baseWidth = 600;\r\n let changeWidth = 150;\r\n let baseHeight = 80;\r\n let changeHeight = 20;\r\n let anchor = cc.v2(0.5, 0.5);\r\n\r\n let data: IData[] = [];\r\n for (let i = 0, len = 30; i < len; ++i) {\r\n data.push({\r\n index: i, text: \"内容\" + i\r\n });\r\n }\r\n LoopList.ins(\"Test\").init(this.scrollView, this.rendeLayer, 18);\r\n LoopList.ins(\"Test\").initData(data, this.showPrefab, cc.size(baseWidth, baseHeight), anchor);\r\n\r\n /* //测试插入数据\r\n this.scheduleOnce(() => {\r\n LoopList.ins(\"Test\").insertData({ index: 1, text: \"我是插入1\", size: cc.size(baseWidth, baseHeight) }, 1);\r\n }, 3)\r\n\r\n //测试压入数据\r\n this.scheduleOnce(() => {\r\n LoopList.ins(\"Test\").pushDatas([\r\n { index: 1, text: \"我是压入1\", size: cc.size(baseWidth, baseHeight) },\r\n { index: 2, text: \"我是压入2\", size: cc.size(baseWidth, baseHeight) },\r\n { index: 3, text: \"我是压入3\", size: cc.size(baseWidth, baseHeight) },\r\n ]);\r\n }, 4)\r\n\r\n //测试压入数据\r\n this.scheduleOnce(() => {\r\n LoopList.ins(\"Test\").removeData(1);\r\n }, 5) */\r\n }\r\n}\r\n\r\n\r\n"]} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/4a/4a37dd57-78cd-4cec-aad4-f11a73d12b63.json b/Layered_virtual_list_2.x/library/imports/4a/4a37dd57-78cd-4cec-aad4-f11a73d12b63.json new file mode 100644 index 0000000..383aa8b --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/4a/4a37dd57-78cd-4cec-aad4-f11a73d12b63.json @@ -0,0 +1,104 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "richtext", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 1, + "asyncLoadAssets": false, + "readonly": false + }, + { + "__type__": "cc.Node", + "_name": "richText", + "_objFlags": 0, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_cascadeOpacityEnabled": true, + "_parent": null, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 153.38, + "height": 50 + }, + "_children": [], + "_skewX": 0, + "_skewY": 0, + "_localZOrder": 0, + "_globalZOrder": 0, + "_tag": -1, + "_opacityModifyRGB": false, + "_id": "", + "_active": true, + "_components": [ + { + "__id__": 2 + } + ], + "_prefab": { + "__id__": 3 + }, + "groupIndex": 0, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.RichText", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "_useOriginalSize": true, + "_N$string": "RichText", + "_N$horizontalAlign": 0, + "_N$fontSize": 40, + "_N$maxWidth": 0, + "_N$lineHeight": 50 + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "4a37dd57-78cd-4cec-aad4-f11a73d12b63" + }, + "fileId": "fd4fe1WoCpJK6rVCZ13Z14R" + } +] \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/4b/4bab67cb-18e6-4099-b840-355f0473f890.json b/Layered_virtual_list_2.x/library/imports/4b/4bab67cb-18e6-4099-b840-355f0473f890.json new file mode 100644 index 0000000..e7522d6 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/4b/4bab67cb-18e6-4099-b840-355f0473f890.json @@ -0,0 +1,4 @@ +{ + "__type__": "cc.Texture2D", + "content": "0,9729,9729,33071,33071,0,0,1" +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/4b/4bab67cb-18e6-4099-b840-355f0473f890.png b/Layered_virtual_list_2.x/library/imports/4b/4bab67cb-18e6-4099-b840-355f0473f890.png new file mode 100644 index 0000000..388f6f0 Binary files /dev/null and b/Layered_virtual_list_2.x/library/imports/4b/4bab67cb-18e6-4099-b840-355f0473f890.png differ diff --git a/Layered_virtual_list_2.x/library/imports/56/567dcd80-8bf4-4535-8a5a-313f1caf078a.json b/Layered_virtual_list_2.x/library/imports/56/567dcd80-8bf4-4535-8a5a-313f1caf078a.json new file mode 100644 index 0000000..e7522d6 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/56/567dcd80-8bf4-4535-8a5a-313f1caf078a.json @@ -0,0 +1,4 @@ +{ + "__type__": "cc.Texture2D", + "content": "0,9729,9729,33071,33071,0,0,1" +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/56/567dcd80-8bf4-4535-8a5a-313f1caf078a.png b/Layered_virtual_list_2.x/library/imports/56/567dcd80-8bf4-4535-8a5a-313f1caf078a.png new file mode 100644 index 0000000..4b9602c Binary files /dev/null and b/Layered_virtual_list_2.x/library/imports/56/567dcd80-8bf4-4535-8a5a-313f1caf078a.png differ diff --git a/Layered_virtual_list_2.x/library/imports/59/5965ffac-69da-4b55-bcde-9225d0613c28.json b/Layered_virtual_list_2.x/library/imports/59/5965ffac-69da-4b55-bcde-9225d0613c28.json new file mode 100644 index 0000000..de04efa --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/59/5965ffac-69da-4b55-bcde-9225d0613c28.json @@ -0,0 +1,250 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "progressBar", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 1, + "asyncLoadAssets": false, + "readonly": false + }, + { + "__type__": "cc.Node", + "_name": "progressBar", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + } + ], + "_active": true, + "_components": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "_prefab": { + "__id__": 7 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 300, + "height": 15 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "bar", + "_objFlags": 512, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 3 + } + ], + "_prefab": { + "__id__": 4 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 150, + "height": 15 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -150, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "67e68bc9-dad5-4ad9-a2d8-7e03d458e32f" + }, + "_type": 1, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "5965ffac-69da-4b55-bcde-9225d0613c28" + }, + "fileId": "38d28QPqAdC1L4aQLAAwhV2", + "sync": false + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "88e79fd5-96b4-4a77-a1f4-312467171014" + }, + "_type": 1, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "" + }, + { + "__type__": "cc.ProgressBar", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "_N$totalLength": 300, + "_N$barSprite": { + "__id__": 3 + }, + "_N$mode": 0, + "_N$progress": 0.5, + "_N$reverse": false, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "5965ffac-69da-4b55-bcde-9225d0613c28" + }, + "fileId": "c8bd6EVT6lD4bVMS1d/i0BC", + "sync": false + } +] \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/5b/5be1578b-9d99-422a-a3ca-e01dd8e09eb1.js b/Layered_virtual_list_2.x/library/imports/5b/5be1578b-9d99-422a-a3ca-e01dd8e09eb1.js new file mode 100644 index 0000000..2d818d1 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/5b/5be1578b-9d99-422a-a3ca-e01dd8e09eb1.js @@ -0,0 +1,264 @@ +"use strict"; +cc._RF.push(module, '5be15eLnZlCKqPK4B3Y4J6x', 'RenderAlternative1'); +// Script/RenderAlternative1.ts + +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var RenderReactiveHandler_1 = require("./RenderReactiveHandler"); +/** + * 目前该渲染代理功能存在的问题 + * 1.被代理节点的父级不能出现scaleX和scaleY不一致的情况,被代理节点本身没有这个限制 + */ +var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property; +var RenderAlternative = /** @class */ (function (_super) { + __extends(RenderAlternative, _super); + function RenderAlternative() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /**渲染层节点 */ + _this.renderLayer = null; + /**渲染的zIndex 动态调整zIndex,用于方便临近合批 */ + _this.renderZIndex = 0; + /**同步的间隔(帧为单位) */ + _this.syncInv = 0.01; + /**渲染的sIndex */ + _this.sIndex = 0; + /**非渲染组件 */ + _this.proxyRender = null; + /**渲染组件 */ + _this.renderCompnent = null; + /**上次更新的数据 */ + _this.lastWMat4 = null; + /**上次更新的数据 */ + _this.lastLMat4 = null; + /**上次更新的数据 */ + _this.lastPos = null; + /**距离下次刷新累计了多少间隔 */ + _this.accuTime = 0; + /**最后一次刷新时间 */ + _this.lastFrameTime = null; + /**是否进行刷新 */ + _this.isAttachFrame = false; + return _this; + } + RenderAlternative_1 = RenderAlternative; + Object.defineProperty(RenderAlternative.prototype, "zIndex", { + /**获取总的ZIndex */ + get: function () { + var zIndex = this.renderZIndex + (this.sIndex * 0.01); + var parentNode = this.node.parent; + while (parentNode != this.renderLayer.parent && parentNode != cc.director.getScene()) { + var render = parentNode.getComponent(RenderAlternative_1); + if (render) { + zIndex += render.zIndex + 1; + break; + } + parentNode = parentNode.parent; + } + return zIndex; + }, + enumerable: false, + configurable: true + }); + /** + * 设置渲染节点层 + * @param layer + */ + RenderAlternative.prototype.init = function (layer) { + if (layer) { + this.renderLayer = layer; + } + if (!this.renderLayer) { + console.warn("\u8282\u70B9" + this.node.name + "\u6CA1\u6709\u8BBE\u7F6E\u6E32\u67D3\u5C42"); + return null; + } + return this.initRender(); + }; + /** + * 初始化渲染节点 + */ + RenderAlternative.prototype.initRender = function () { + var node = this.getRender(); + node.setParent(this.renderLayer ? this.renderLayer : cc.director.getScene().getChildByName("Canvas")); + this.isAttachFrame = true; + requestAnimationFrame(this.frameUpdate.bind(this)); + return this.doProxy(); + }; + /**生成代理 */ + RenderAlternative.prototype.doProxy = function () { + this.proxyRender = new Proxy(this.renderCompnent, new RenderReactiveHandler_1.RenderReactiveHandler()); + return this.proxyRender; + }; + RenderAlternative.prototype.frameUpdate = function () { + var now = cc.sys.now(); + !this.lastFrameTime && (this.lastFrameTime = now); + var dt = now - this.lastFrameTime; + if (this.proxyRender) { + this.accuTime += dt; + if (this.accuTime >= this.syncInv) { + this.accuTime -= this.syncInv; + this.updateProp(); + } + } + if (this.isAttachFrame) { + requestAnimationFrame(this.frameUpdate.bind(this)); + } + }; + /**更新最新状态 */ + RenderAlternative.prototype.updateProp = function () { + var node = this.renderCompnent.node; + if (!this.node.activeInHierarchy) { + node.opacity = 0; + return; + } + node.anchorX = this.node.anchorX; + node.anchorY = this.node.anchorY; + node.width = this.node.width; + node.height = this.node.height; + node.group = this.node.group; + node.color = this.node.color; + node.opacity = this.getOpacity(this.node); + var wMat4 = cc.mat4(); + this.node.getWorldMatrix(wMat4); + if (!this.lastWMat4 || !this.lastWMat4.equals(wMat4)) { + var localMatrix = this.getLocalMatrix(wMat4, node); + this.setLocalXYZScaleAngle(localMatrix, node, this.lastLMat4); + this.lastWMat4 = wMat4; + this.lastLMat4 = localMatrix; + } + node.zIndex = this.zIndex; + }; + RenderAlternative.prototype.getLocalMatrix = function (worldMatrix, node) { + var parentNode = null; + if (cc.isValid(node)) { + if (cc.isValid(node.parent)) { + parentNode = node.parent; + } + } + // 获取父节点的世界矩阵 + var parentWorldMatrix = cc.mat4(); + parentNode.getWorldMatrix(parentWorldMatrix); + // 获取父节点的逆矩阵 + var parentInverseMatrix = parentWorldMatrix.invert(); + // 将目标节点的世界矩阵转换为父节点的本地矩阵 + var localMatrix = parentInverseMatrix.multiply(worldMatrix); + return localMatrix; + }; + RenderAlternative.prototype.setLocalXYZScaleAngle = function (matrix, node, lastMatrix) { + if (lastMatrix && matrix.equals(lastMatrix)) { + return; + } + // 提取位置 + node.setPosition(matrix.m[12], matrix.m[13], matrix.m[14]); + var scaleX = null; + var scaleY = null; + var angle = null; + // 提取缩放X + if (!lastMatrix) { + scaleX = Math.sqrt(matrix.m[0] * matrix.m[0] + matrix.m[1] * matrix.m[1] + matrix.m[2] * matrix.m[2]); + } + else if (!this.equalsValue(matrix.m[0], lastMatrix.m[0]) + || !this.equalsValue(matrix.m[1], lastMatrix.m[1]) + || !this.equalsValue(matrix.m[2], lastMatrix.m[2])) { + scaleX = Math.sqrt(matrix.m[0] * matrix.m[0] + matrix.m[1] * matrix.m[1] + matrix.m[2] * matrix.m[2]); + } + // 提取缩放Y + if (!lastMatrix) { + scaleY = Math.sqrt(matrix.m[4] * matrix.m[4] + matrix.m[5] * matrix.m[5] + matrix.m[6] * matrix.m[6]); + } + else if (!this.equalsValue(matrix.m[4], lastMatrix.m[4]) + || !this.equalsValue(matrix.m[5], lastMatrix.m[5]) + || !this.equalsValue(matrix.m[6], lastMatrix.m[6])) { + scaleY = Math.sqrt(matrix.m[4] * matrix.m[4] + matrix.m[5] * matrix.m[5] + matrix.m[6] * matrix.m[6]); + } + //设置缩放X + if (scaleX !== null) { + node.scaleX = scaleX; + // 提取旋转 + angle = Math.atan2(matrix.m[1] / scaleX, matrix.m[0] / scaleX) * (180 / Math.PI); + } + if (scaleY !== null) { + node.scaleY = scaleY; + } + if (angle !== null) { + node.rotation = angle; + } + }; + RenderAlternative.prototype.equalsValue = function (a, b, epsilon) { + if (epsilon === void 0) { epsilon = 0.00001; } + return Math.abs(a - b) < epsilon; + }; + RenderAlternative.prototype.onDestroy = function () { + this.renderCompnent.node.destroy(); + this.renderCompnent = null; + this.proxyRender = null; + }; + /** + * 获取节点透明度 + * @param node + */ + RenderAlternative.prototype.getOpacity = function (node) { + var opacity = (node.opacity / 255); + var parentNode = node.parent; + while (parentNode != this.renderLayer.parent && parentNode != cc.director.getScene()) { + opacity *= (parentNode.opacity / 255); + parentNode = parentNode.parent; + } + return opacity * 255; + }; + /** + * 获取渲染组件 + * @param node + */ + RenderAlternative.prototype.getRender = function () { + var _a, _b; + var node = cc.instantiate(this.node); + node.removeAllChildren(); + this.renderCompnent = node.getComponent(cc.RenderComponent); + (_a = this.node.getComponent(cc.LabelOutline)) === null || _a === void 0 ? void 0 : _a.destroy(); + (_b = this.node.getComponent(cc.LabelShadow)) === null || _b === void 0 ? void 0 : _b.destroy(); + this.node.getComponent(cc.RenderComponent).destroy(); + var components = node.getComponents(cc.Component); + for (var i = 0, len = components.length; i < len; ++i) { + var comp = components[i]; + if (!((comp instanceof cc.RenderComponent) || (comp instanceof cc.LabelOutline) || (comp instanceof cc.LabelShadow))) { + comp.destroy(); + } + } + return node; + }; + var RenderAlternative_1; + __decorate([ + property + ], RenderAlternative.prototype, "renderZIndex", void 0); + __decorate([ + property({ + tooltip: '设置同步的间隔(秒为单位),0就是每帧都同步,0.1就是隔0.1秒同步一次' + }) + ], RenderAlternative.prototype, "syncInv", void 0); + RenderAlternative = RenderAlternative_1 = __decorate([ + ccclass + ], RenderAlternative); + return RenderAlternative; +}(cc.Component)); +exports.default = RenderAlternative; + +cc._RF.pop(); \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/5b/5be1578b-9d99-422a-a3ca-e01dd8e09eb1.js.map b/Layered_virtual_list_2.x/library/imports/5b/5be1578b-9d99-422a-a3ca-e01dd8e09eb1.js.map new file mode 100644 index 0000000..050ce77 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/5b/5be1578b-9d99-422a-a3ca-e01dd8e09eb1.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["assets\\Script\\RenderAlternative1.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iEAAgE;AAEhE;;;GAGG;AACG,IAAA,KAAwB,EAAE,CAAC,UAAU,EAAnC,OAAO,aAAA,EAAE,QAAQ,cAAkB,CAAC;AAE5C;IAA+C,qCAAY;IAA3D;QAAA,qEA6NC;QA5NG,WAAW;QACJ,iBAAW,GAAY,IAAI,CAAC;QACnC,mCAAmC;QAE5B,kBAAY,GAAW,CAAC,CAAC;QAChC,iBAAiB;QAIV,aAAO,GAAW,IAAI,CAAC;QAC9B,eAAe;QACR,YAAM,GAAW,CAAC,CAAC;QAC1B,WAAW;QACJ,iBAAW,GAAuB,IAAI,CAAC;QAC9C,UAAU;QACF,oBAAc,GAAuB,IAAI,CAAC;QAClD,aAAa;QACN,eAAS,GAAY,IAAI,CAAC;QACjC,aAAa;QACN,eAAS,GAAY,IAAI,CAAC;QACjC,aAAa;QACN,aAAO,GAAY,IAAI,CAAC;QAC/B,mBAAmB;QACZ,cAAQ,GAAW,CAAC,CAAC;QAC5B,cAAc;QACP,mBAAa,GAAW,IAAI,CAAC;QACpC,YAAY;QACL,mBAAa,GAAY,KAAK,CAAC;;IAiM1C,CAAC;0BA7NoB,iBAAiB;IA+BlC,sBAAI,qCAAM;QADV,gBAAgB;aAChB;YACI,IAAI,MAAM,GAAG,IAAI,CAAC,YAAY,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;YACtD,IAAI,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;YAClC,OAAO,UAAU,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,IAAI,UAAU,IAAI,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,EAAE;gBAClF,IAAI,MAAM,GAAG,UAAU,CAAC,YAAY,CAAC,mBAAiB,CAAC,CAAC;gBACxD,IAAI,MAAM,EAAE;oBACR,MAAM,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;oBAC5B,MAAM;iBACT;gBACD,UAAU,GAAG,UAAU,CAAC,MAAM,CAAC;aAClC;YACD,OAAO,MAAM,CAAC;QAClB,CAAC;;;OAAA;IAED;;;OAGG;IACH,gCAAI,GAAJ,UAAmC,KAAe;QAC9C,IAAI,KAAK,EAAE;YACP,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;SAC5B;QACD,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;YACnB,OAAO,CAAC,IAAI,CAAC,iBAAK,IAAI,CAAC,IAAI,CAAC,IAAI,+CAAS,CAAC,CAAA;YAC1C,OAAO,IAAI,CAAC;SACf;QACD,OAAO,IAAI,CAAC,UAAU,EAAK,CAAC;IAChC,CAAC;IACD;;OAEG;IACK,sCAAU,GAAlB;QACI,IAAI,IAAI,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;QAC5B,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC;QACtG,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;QAC1B,qBAAqB,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QACnD,OAAO,IAAI,CAAC,OAAO,EAAK,CAAC;IAC7B,CAAC;IACD,UAAU;IACF,mCAAO,GAAf;QACI,IAAI,CAAC,WAAW,GAAG,IAAI,KAAK,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,6CAAqB,EAAE,CAAM,CAAC;QACpF,OAAO,IAAI,CAAC,WAAgB,CAAC;IACjC,CAAC;IAGS,uCAAW,GAArB;QACI,IAAI,GAAG,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;QACvB,CAAC,IAAI,CAAC,aAAa,IAAI,CAAC,IAAI,CAAC,aAAa,GAAG,GAAG,CAAC,CAAC;QAClD,IAAI,EAAE,GAAG,GAAG,GAAG,IAAI,CAAC,aAAa,CAAC;QAClC,IAAI,IAAI,CAAC,WAAW,EAAE;YAClB,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAC;YACpB,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,OAAO,EAAE;gBAC/B,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,OAAO,CAAC;gBAC9B,IAAI,CAAC,UAAU,EAAE,CAAC;aACrB;SACJ;QACD,IAAI,IAAI,CAAC,aAAa,EAAE;YACpB,qBAAqB,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;SACtD;IACL,CAAC;IAED,YAAY;IACL,sCAAU,GAAjB;QACI,IAAI,IAAI,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC;QACpC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE;YAC9B,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;YACjB,OAAO;SACV;QACD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC;QACjC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC;QACjC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;QAC7B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;QAC/B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;QAC7B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAE1C,IAAI,KAAK,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC;QACtB,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;QAChC,IAAI,CAAC,IAAI,CAAC,SAAS,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;YAClD,IAAI,WAAW,GAAG,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;YACnD,IAAI,CAAC,qBAAqB,CAAC,WAAW,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;YAC9D,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;YACvB,IAAI,CAAC,SAAS,GAAG,WAAW,CAAC;SAChC;QACD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IAC9B,CAAC;IAEO,0CAAc,GAAtB,UAAuB,WAAoB,EAAE,IAAa;QACtD,IAAI,UAAU,GAAG,IAAI,CAAC;QACtB,IAAI,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YAClB,IAAI,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE;gBACzB,UAAU,GAAG,IAAI,CAAC,MAAM,CAAA;aAC3B;SACJ;QACD,aAAa;QACb,IAAI,iBAAiB,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC;QAClC,UAAU,CAAC,cAAc,CAAC,iBAAiB,CAAC,CAAC;QAC7C,YAAY;QACZ,IAAI,mBAAmB,GAAG,iBAAiB,CAAC,MAAM,EAAE,CAAC;QACrD,wBAAwB;QACxB,IAAI,WAAW,GAAG,mBAAmB,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;QAC5D,OAAO,WAAW,CAAC;IAEvB,CAAC;IAEO,iDAAqB,GAA7B,UAA8B,MAAe,EAAE,IAAa,EAAE,UAAoB;QAC9E,IAAI,UAAU,IAAI,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE;YACzC,OAAO;SACV;QAED,OAAO;QACP,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAE3D,IAAI,MAAM,GAAG,IAAI,CAAC;QAClB,IAAI,MAAM,GAAG,IAAI,CAAC;QAClB,IAAI,KAAK,GAAG,IAAI,CAAC;QACjB,QAAQ;QACR,IAAI,CAAC,UAAU,EAAE;YACb,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;SACzG;aAAM,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;eACnD,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;eAC/C,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE;YACpD,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;SACzG;QACD,QAAQ;QACR,IAAI,CAAC,UAAU,EAAE;YACb,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;SACzG;aAAM,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;eACnD,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;eAC/C,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE;YACpD,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;SACzG;QACD,OAAO;QACP,IAAI,MAAM,KAAK,IAAI,EAAE;YACjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;YACrB,OAAO;YACP,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC;SACpF;QACD,IAAI,MAAM,KAAK,IAAI,EAAE;YACjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;SACxB;QACD,IAAI,KAAK,KAAK,IAAI,EAAE;YAChB,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;SACzB;IACL,CAAC;IAEO,uCAAW,GAAnB,UAAoB,CAAS,EAAE,CAAS,EAAE,OAAyB;QAAzB,wBAAA,EAAA,iBAAyB;QAC/D,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,OAAO,CAAC;IACrC,CAAC;IAES,qCAAS,GAAnB;QACI,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;QACnC,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;QAC3B,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;IAC5B,CAAC;IAED;;;OAGG;IACK,sCAAU,GAAlB,UAAmB,IAAa;QAC5B,IAAI,OAAO,GAAG,CAAC,IAAI,CAAC,OAAO,GAAG,GAAG,CAAC,CAAC;QACnC,IAAI,UAAU,GAAG,IAAI,CAAC,MAAM,CAAA;QAC5B,OAAO,UAAU,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,IAAI,UAAU,IAAI,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,EAAE;YAClF,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,GAAG,GAAG,CAAC,CAAC;YACtC,UAAU,GAAG,UAAU,CAAC,MAAM,CAAC;SAClC;QACD,OAAO,OAAO,GAAG,GAAG,CAAC;IACzB,CAAC;IACD;;;OAGG;IACK,qCAAS,GAAjB;;QACI,IAAI,IAAI,GAAG,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACzB,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC;QAC5D,MAAA,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,YAAY,CAAC,0CAAE,OAAO,GAAG;QACnD,MAAA,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,WAAW,CAAC,0CAAE,OAAO,GAAG;QAClD,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC,OAAO,EAAE,CAAC;QACrD,IAAI,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC;QAClD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,GAAG,GAAG,EAAE,EAAE,CAAC,EAAE;YACnD,IAAI,IAAI,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;YACzB,IAAI,CAAC,CAAC,CAAC,IAAI,YAAY,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,YAAY,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,YAAY,EAAE,CAAC,WAAW,CAAC,CAAC,EAAE;gBAClH,IAAI,CAAC,OAAO,EAAE,CAAC;aAClB;SACJ;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;;IAtND;QADC,QAAQ;2DACuB;IAKhC;QAHC,QAAQ,CAAC;YACN,OAAO,EAAE,uCAAuC;SACnD,CAAC;sDAC4B;IAVb,iBAAiB;QADrC,OAAO;OACa,iBAAiB,CA6NrC;IAAD,wBAAC;CA7ND,AA6NC,CA7N8C,EAAE,CAAC,SAAS,GA6N1D;kBA7NoB,iBAAiB","file":"","sourceRoot":"/","sourcesContent":["import { RenderReactiveHandler } from \"./RenderReactiveHandler\";\r\n\r\n/**\r\n * 目前该渲染代理功能存在的问题\r\n * 1.被代理节点的父级不能出现scaleX和scaleY不一致的情况,被代理节点本身没有这个限制\r\n */\r\nconst { ccclass, property } = cc._decorator;\r\n@ccclass\r\nexport default class RenderAlternative extends cc.Component {\r\n /**渲染层节点 */\r\n public renderLayer: cc.Node = null;\r\n /**渲染的zIndex 动态调整zIndex,用于方便临近合批 */\r\n @property\r\n public renderZIndex: number = 0;\r\n /**同步的间隔(帧为单位) */\r\n @property({\r\n tooltip: '设置同步的间隔(秒为单位),0就是每帧都同步,0.1就是隔0.1秒同步一次'\r\n })\r\n public syncInv: number = 0.01;\r\n /**渲染的sIndex */\r\n public sIndex: number = 0;\r\n /**非渲染组件 */\r\n public proxyRender: cc.RenderComponent = null;\r\n /**渲染组件 */\r\n private renderCompnent: cc.RenderComponent = null;\r\n /**上次更新的数据 */\r\n public lastWMat4: cc.Mat4 = null;\r\n /**上次更新的数据 */\r\n public lastLMat4: cc.Mat4 = null;\r\n /**上次更新的数据 */\r\n public lastPos: cc.Vec3 = null;\r\n /**距离下次刷新累计了多少间隔 */\r\n public accuTime: number = 0;\r\n /**最后一次刷新时间 */\r\n public lastFrameTime: number = null;\r\n /**是否进行刷新 */\r\n public isAttachFrame: boolean = false;\r\n\r\n /**获取总的ZIndex */\r\n get zIndex() {\r\n let zIndex = this.renderZIndex + (this.sIndex * 0.01);\r\n let parentNode = this.node.parent;\r\n while (parentNode != this.renderLayer.parent && parentNode != cc.director.getScene()) {\r\n let render = parentNode.getComponent(RenderAlternative);\r\n if (render) {\r\n zIndex += render.zIndex + 1;\r\n break;\r\n }\r\n parentNode = parentNode.parent;\r\n }\r\n return zIndex;\r\n }\r\n\r\n /**\r\n * 设置渲染节点层\r\n * @param layer \r\n */\r\n init(layer?: cc.Node): T {\r\n if (layer) {\r\n this.renderLayer = layer;\r\n }\r\n if (!this.renderLayer) {\r\n console.warn(`节点${this.node.name}没有设置渲染层`)\r\n return null;\r\n }\r\n return this.initRender();\r\n }\r\n /**\r\n * 初始化渲染节点\r\n */\r\n private initRender(): T {\r\n let node = this.getRender();\r\n node.setParent(this.renderLayer ? this.renderLayer : cc.director.getScene().getChildByName(\"Canvas\"));\r\n this.isAttachFrame = true;\r\n requestAnimationFrame(this.frameUpdate.bind(this));\r\n return this.doProxy();\r\n }\r\n /**生成代理 */\r\n private doProxy(): T {\r\n this.proxyRender = new Proxy(this.renderCompnent, new RenderReactiveHandler()) as T;\r\n return this.proxyRender as T;\r\n }\r\n\r\n\r\n protected frameUpdate(): void {\r\n let now = cc.sys.now();\r\n !this.lastFrameTime && (this.lastFrameTime = now);\r\n let dt = now - this.lastFrameTime;\r\n if (this.proxyRender) {\r\n this.accuTime += dt;\r\n if (this.accuTime >= this.syncInv) {\r\n this.accuTime -= this.syncInv;\r\n this.updateProp();\r\n }\r\n }\r\n if (this.isAttachFrame) {\r\n requestAnimationFrame(this.frameUpdate.bind(this));\r\n }\r\n }\r\n\r\n /**更新最新状态 */\r\n public updateProp() {\r\n let node = this.renderCompnent.node;\r\n if (!this.node.activeInHierarchy) {\r\n node.opacity = 0;\r\n return;\r\n }\r\n node.anchorX = this.node.anchorX;\r\n node.anchorY = this.node.anchorY;\r\n node.width = this.node.width;\r\n node.height = this.node.height;\r\n node.group = this.node.group;\r\n node.color = this.node.color;\r\n node.opacity = this.getOpacity(this.node);\r\n\r\n let wMat4 = cc.mat4();\r\n this.node.getWorldMatrix(wMat4);\r\n if (!this.lastWMat4 || !this.lastWMat4.equals(wMat4)) {\r\n let localMatrix = this.getLocalMatrix(wMat4, node);\r\n this.setLocalXYZScaleAngle(localMatrix, node, this.lastLMat4);\r\n this.lastWMat4 = wMat4;\r\n this.lastLMat4 = localMatrix;\r\n }\r\n node.zIndex = this.zIndex;\r\n }\r\n\r\n private getLocalMatrix(worldMatrix: cc.Mat4, node: cc.Node) {\r\n let parentNode = null;\r\n if (cc.isValid(node)) {\r\n if (cc.isValid(node.parent)) {\r\n parentNode = node.parent\r\n }\r\n }\r\n // 获取父节点的世界矩阵\r\n let parentWorldMatrix = cc.mat4();\r\n parentNode.getWorldMatrix(parentWorldMatrix);\r\n // 获取父节点的逆矩阵\r\n let parentInverseMatrix = parentWorldMatrix.invert();\r\n // 将目标节点的世界矩阵转换为父节点的本地矩阵\r\n let localMatrix = parentInverseMatrix.multiply(worldMatrix);\r\n return localMatrix;\r\n\r\n }\r\n\r\n private setLocalXYZScaleAngle(matrix: cc.Mat4, node: cc.Node, lastMatrix?: cc.Mat4) {\r\n if (lastMatrix && matrix.equals(lastMatrix)) {\r\n return;\r\n }\r\n\r\n // 提取位置\r\n node.setPosition(matrix.m[12], matrix.m[13], matrix.m[14]);\r\n\r\n let scaleX = null;\r\n let scaleY = null;\r\n let angle = null;\r\n // 提取缩放X\r\n if (!lastMatrix) {\r\n scaleX = Math.sqrt(matrix.m[0] * matrix.m[0] + matrix.m[1] * matrix.m[1] + matrix.m[2] * matrix.m[2]);\r\n } else if (!this.equalsValue(matrix.m[0], lastMatrix.m[0])\r\n || !this.equalsValue(matrix.m[1], lastMatrix.m[1])\r\n || !this.equalsValue(matrix.m[2], lastMatrix.m[2])) {\r\n scaleX = Math.sqrt(matrix.m[0] * matrix.m[0] + matrix.m[1] * matrix.m[1] + matrix.m[2] * matrix.m[2]);\r\n }\r\n // 提取缩放Y\r\n if (!lastMatrix) {\r\n scaleY = Math.sqrt(matrix.m[4] * matrix.m[4] + matrix.m[5] * matrix.m[5] + matrix.m[6] * matrix.m[6]);\r\n } else if (!this.equalsValue(matrix.m[4], lastMatrix.m[4])\r\n || !this.equalsValue(matrix.m[5], lastMatrix.m[5])\r\n || !this.equalsValue(matrix.m[6], lastMatrix.m[6])) {\r\n scaleY = Math.sqrt(matrix.m[4] * matrix.m[4] + matrix.m[5] * matrix.m[5] + matrix.m[6] * matrix.m[6]);\r\n }\r\n //设置缩放X\r\n if (scaleX !== null) {\r\n node.scaleX = scaleX;\r\n // 提取旋转\r\n angle = Math.atan2(matrix.m[1] / scaleX, matrix.m[0] / scaleX) * (180 / Math.PI);\r\n }\r\n if (scaleY !== null) {\r\n node.scaleY = scaleY;\r\n }\r\n if (angle !== null) {\r\n node.rotation = angle;\r\n }\r\n }\r\n\r\n private equalsValue(a: number, b: number, epsilon: number = 0.00001) {\r\n return Math.abs(a - b) < epsilon;\r\n }\r\n\r\n protected onDestroy(): void {\r\n this.renderCompnent.node.destroy();\r\n this.renderCompnent = null;\r\n this.proxyRender = null;\r\n }\r\n\r\n /**\r\n * 获取节点透明度\r\n * @param node \r\n */\r\n private getOpacity(node: cc.Node) {\r\n let opacity = (node.opacity / 255);\r\n let parentNode = node.parent\r\n while (parentNode != this.renderLayer.parent && parentNode != cc.director.getScene()) {\r\n opacity *= (parentNode.opacity / 255);\r\n parentNode = parentNode.parent;\r\n }\r\n return opacity * 255;\r\n }\r\n /**\r\n * 获取渲染组件\r\n * @param node \r\n */\r\n private getRender() {\r\n let node = cc.instantiate(this.node);\r\n node.removeAllChildren();\r\n this.renderCompnent = node.getComponent(cc.RenderComponent);\r\n this.node.getComponent(cc.LabelOutline)?.destroy();\r\n this.node.getComponent(cc.LabelShadow)?.destroy();\r\n this.node.getComponent(cc.RenderComponent).destroy();\r\n let components = node.getComponents(cc.Component);\r\n for (let i = 0, len = components.length; i < len; ++i) {\r\n let comp = components[i];\r\n if (!((comp instanceof cc.RenderComponent) || (comp instanceof cc.LabelOutline) || (comp instanceof cc.LabelShadow))) {\r\n comp.destroy();\r\n }\r\n }\r\n return node;\r\n }\r\n\r\n}\r\n"]} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/5c/5c3bb932-6c3c-468f-88a9-c8c61d458641.json b/Layered_virtual_list_2.x/library/imports/5c/5c3bb932-6c3c-468f-88a9-c8c61d458641.json new file mode 100644 index 0000000..a6721ed --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/5c/5c3bb932-6c3c-468f-88a9-c8c61d458641.json @@ -0,0 +1,28 @@ +{ + "__type__": "cc.SpriteFrame", + "content": { + "name": "default_scrollbar_vertical", + "texture": "d6d3ca85-4681-47c1-b5dd-d036a9d39ea2", + "atlas": "", + "rect": [ + 0, + 0, + 15, + 30 + ], + "offset": [ + 0, + 0 + ], + "originalSize": [ + 15, + 30 + ], + "capInsets": [ + 4, + 10, + 4, + 10 + ] + } +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/5f/5fe5dcaa-b513-4dc5-a166-573627b3a159.json b/Layered_virtual_list_2.x/library/imports/5f/5fe5dcaa-b513-4dc5-a166-573627b3a159.json new file mode 100644 index 0000000..c57e552 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/5f/5fe5dcaa-b513-4dc5-a166-573627b3a159.json @@ -0,0 +1,28 @@ +{ + "__type__": "cc.SpriteFrame", + "content": { + "name": "default_scrollbar_vertical_bg", + "texture": "617323dd-11f4-4dd3-8eec-0caf6b3b45b9", + "atlas": "", + "rect": [ + 0, + 0, + 15, + 30 + ], + "offset": [ + 0, + 0 + ], + "originalSize": [ + 15, + 30 + ], + "capInsets": [ + 4, + 10, + 4, + 10 + ] + } +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/60/600301aa-3357-4a10-b086-84f011fa32ba.json b/Layered_virtual_list_2.x/library/imports/60/600301aa-3357-4a10-b086-84f011fa32ba.json new file mode 100644 index 0000000..99d8ebb --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/60/600301aa-3357-4a10-b086-84f011fa32ba.json @@ -0,0 +1,4 @@ +{ + "__type__": "cc.Texture2D", + "content": "0,9729,9729,33071,33071,1,0,0" +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/60/600301aa-3357-4a10-b086-84f011fa32ba.png b/Layered_virtual_list_2.x/library/imports/60/600301aa-3357-4a10-b086-84f011fa32ba.png new file mode 100644 index 0000000..c6adfe9 Binary files /dev/null and b/Layered_virtual_list_2.x/library/imports/60/600301aa-3357-4a10-b086-84f011fa32ba.png differ diff --git a/Layered_virtual_list_2.x/library/imports/61/617323dd-11f4-4dd3-8eec-0caf6b3b45b9.json b/Layered_virtual_list_2.x/library/imports/61/617323dd-11f4-4dd3-8eec-0caf6b3b45b9.json new file mode 100644 index 0000000..e7522d6 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/61/617323dd-11f4-4dd3-8eec-0caf6b3b45b9.json @@ -0,0 +1,4 @@ +{ + "__type__": "cc.Texture2D", + "content": "0,9729,9729,33071,33071,0,0,1" +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/61/617323dd-11f4-4dd3-8eec-0caf6b3b45b9.png b/Layered_virtual_list_2.x/library/imports/61/617323dd-11f4-4dd3-8eec-0caf6b3b45b9.png new file mode 100644 index 0000000..a2a849a Binary files /dev/null and b/Layered_virtual_list_2.x/library/imports/61/617323dd-11f4-4dd3-8eec-0caf6b3b45b9.png differ diff --git a/Layered_virtual_list_2.x/library/imports/61/61906da3-7003-4bda-9abc-5769c76faee4.json b/Layered_virtual_list_2.x/library/imports/61/61906da3-7003-4bda-9abc-5769c76faee4.json new file mode 100644 index 0000000..e746c9d --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/61/61906da3-7003-4bda-9abc-5769c76faee4.json @@ -0,0 +1,117 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "ambient", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "asyncLoadAssets": false, + "readonly": false + }, + { + "__type__": "cc.Node", + "_name": "light", + "_objFlags": 0, + "_parent": null, + "_children": [], + "_active": true, + "_level": 1, + "_components": [ + { + "__id__": 2 + } + ], + "_prefab": { + "__id__": 3 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "groupIndex": 0, + "_id": "", + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Light", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "_type": 3, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_intensity": 0.25, + "_range": 1, + "_spotAngle": 60, + "_spotExp": 1, + "_shadowType": 0, + "_shadowResolution": 1024, + "_shadowDarkness": 0.5, + "_shadowMinDepth": 1, + "_shadowMaxDepth": 1000, + "_shadowDepthScale": 250, + "_shadowFrustumSize": 50, + "_shadowBias": 0.0005, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "61906da3-7003-4bda-9abc-5769c76faee4" + }, + "fileId": "33zOkteexCqamZ4PXuwJaW", + "sync": false + } +] \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/61/61aeb05b-3b32-452b-8eed-2b76deeed554.json b/Layered_virtual_list_2.x/library/imports/61/61aeb05b-3b32-452b-8eed-2b76deeed554.json new file mode 100644 index 0000000..9f7ffb2 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/61/61aeb05b-3b32-452b-8eed-2b76deeed554.json @@ -0,0 +1,535 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "editbox", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 1, + "asyncLoadAssets": false, + "readonly": false + }, + { + "__type__": "cc.Node", + "_name": "editbox", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + }, + { + "__id__": 6 + }, + { + "__id__": 10 + } + ], + "_active": true, + "_components": [ + { + "__id__": 14 + } + ], + "_prefab": { + "__id__": 15 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 160, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "BACKGROUND_SPRITE", + "_objFlags": 512, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 3 + }, + { + "__id__": 4 + } + ], + "_prefab": { + "__id__": 5 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 160, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "ff0e91c7-55c6-4086-a39f-cb6e457b8c3b" + }, + "_type": 1, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "alignMode": 0, + "_target": null, + "_alignFlags": 45, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 160, + "_originalHeight": 40, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "61aeb05b-3b32-452b-8eed-2b76deeed554" + }, + "fileId": "fcoT9mL35BlLUlR0xQ5QBI", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "TEXT_LABEL", + "_objFlags": 512, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": false, + "_components": [ + { + "__id__": 7 + }, + { + "__id__": 8 + } + ], + "_prefab": { + "__id__": 9 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 158, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 1 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -78, + 20, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 6 + }, + "_enabled": true, + "_materials": [], + "_useOriginalSize": true, + "_string": "", + "_N$string": "", + "_fontSize": 20, + "_lineHeight": 25, + "_enableWrapText": false, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_styleFlags": 0, + "_underlineHeight": 0, + "_N$horizontalAlign": 0, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 1, + "_N$cacheMode": 0, + "_id": "" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 6 + }, + "_enabled": true, + "alignMode": 0, + "_target": null, + "_alignFlags": 45, + "_left": 2, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 158, + "_originalHeight": 40, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "61aeb05b-3b32-452b-8eed-2b76deeed554" + }, + "fileId": "0blsIXU11M95uloDvhs/X9", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "PLACEHOLDER_LABEL", + "_objFlags": 512, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 11 + }, + { + "__id__": 12 + } + ], + "_prefab": { + "__id__": 13 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 187, + "g": 187, + "b": 187, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 158, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 1 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -78, + 20, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 10 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_useOriginalSize": true, + "_string": "Enter text here...", + "_N$string": "Enter text here...", + "_fontSize": 20, + "_lineHeight": 25, + "_enableWrapText": false, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_styleFlags": 0, + "_underlineHeight": 0, + "_N$horizontalAlign": 0, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 1, + "_N$cacheMode": 0, + "_id": "" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 10 + }, + "_enabled": true, + "alignMode": 0, + "_target": null, + "_alignFlags": 45, + "_left": 2, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 158, + "_originalHeight": 40, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "61aeb05b-3b32-452b-8eed-2b76deeed554" + }, + "fileId": "d9Sjcz6gxMGYCoLbO/scJL", + "sync": false + }, + { + "__type__": "cc.EditBox", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "_useOriginalSize": false, + "_string": "", + "returnType": 0, + "maxLength": 8, + "_tabIndex": 0, + "editingDidBegan": [], + "textChanged": [], + "editingDidEnded": [], + "editingReturn": [], + "_N$textLabel": { + "__id__": 7 + }, + "_N$placeholderLabel": { + "__id__": 11 + }, + "_N$background": { + "__id__": 3 + }, + "_N$inputFlag": 5, + "_N$inputMode": 6, + "_N$stayOnTop": false, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "61aeb05b-3b32-452b-8eed-2b76deeed554" + }, + "fileId": "590f66n7/1CY5uRJYcGGuJO", + "sync": false + } +] \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/67/67e68bc9-dad5-4ad9-a2d8-7e03d458e32f.json b/Layered_virtual_list_2.x/library/imports/67/67e68bc9-dad5-4ad9-a2d8-7e03d458e32f.json new file mode 100644 index 0000000..5f858bc --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/67/67e68bc9-dad5-4ad9-a2d8-7e03d458e32f.json @@ -0,0 +1,28 @@ +{ + "__type__": "cc.SpriteFrame", + "content": { + "name": "default_progressbar", + "texture": "cfef78f1-c8df-49b7-8ed0-4c953ace2621", + "atlas": "", + "rect": [ + 0, + 0, + 30, + 15 + ], + "offset": [ + 0, + 0 + ], + "originalSize": [ + 30, + 15 + ], + "capInsets": [ + 10, + 4, + 10, + 4 + ] + } +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/68/6827ca32-0107-4552-bab2-dfb31799bb44.json b/Layered_virtual_list_2.x/library/imports/68/6827ca32-0107-4552-bab2-dfb31799bb44.json new file mode 100644 index 0000000..661f423 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/68/6827ca32-0107-4552-bab2-dfb31799bb44.json @@ -0,0 +1,28 @@ +{ + "__type__": "cc.SpriteFrame", + "content": { + "name": "default_toggle_normal", + "texture": "d29077ba-1627-4a72-9579-7b56a235340c", + "atlas": "", + "rect": [ + 0, + 0, + 28, + 28 + ], + "offset": [ + 0, + 0 + ], + "originalSize": [ + 28, + 28 + ], + "capInsets": [ + 0, + 0, + 0, + 0 + ] + } +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/6b/6b1c6ed5-0dab-415a-b3cc-4408f270a2d0.json b/Layered_virtual_list_2.x/library/imports/6b/6b1c6ed5-0dab-415a-b3cc-4408f270a2d0.json new file mode 100644 index 0000000..eae2939 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/6b/6b1c6ed5-0dab-415a-b3cc-4408f270a2d0.json @@ -0,0 +1,1041 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "showNode", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "asyncLoadAssets": false, + "readonly": false + }, + { + "__type__": "cc.Node", + "_name": "showNode", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + }, + { + "__id__": 7 + }, + { + "__id__": 12 + }, + { + "__id__": 24 + } + ], + "_active": true, + "_components": [ + { + "__id__": 29 + }, + { + "__id__": 30 + } + ], + "_prefab": { + "__id__": 31 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 750, + "height": 1334 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 1 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 375, + 1334, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bg", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 3 + }, + { + "__id__": 4 + }, + { + "__id__": 5 + } + ], + "_prefab": { + "__id__": 6 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 48, + "g": 147, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 750, + "height": 1334 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + -667, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "alignMode": 2, + "_target": null, + "_alignFlags": 45, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 100, + "_originalHeight": 100, + "_id": "" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "renderLayer": null, + "renderZIndex": 0, + "syncInv": 0.01, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "2fWAV/kSxKbLNNotfg0pAI", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "nameLb", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 8 + }, + { + "__id__": 9 + }, + { + "__id__": 10 + } + ], + "_prefab": { + "__id__": 11 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 142.25, + "height": 50.4 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -261.821, + -45.115, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 7 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_string": "我是第1", + "_N$string": "我是第1", + "_fontSize": 40, + "_lineHeight": 40, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_styleFlags": 0, + "_underlineHeight": 0, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 0, + "_id": "" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 7 + }, + "_enabled": true, + "renderLayer": null, + "renderZIndex": 1, + "syncInv": 0.01, + "_id": "" + }, + { + "__type__": "cc.LabelShadow", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 7 + }, + "_enabled": true, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_offset": { + "__type__": "cc.Vec2", + "x": 2, + "y": -5 + }, + "_blur": 2, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "50Nr1a5SVMCLPTFU4WTSCP", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "New Button", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 13 + }, + { + "__id__": 18 + } + ], + "_active": true, + "_components": [ + { + "__id__": 22 + } + ], + "_prefab": { + "__id__": 23 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -106.669, + -44.121, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Background", + "_objFlags": 0, + "_parent": { + "__id__": 12 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 14 + }, + { + "__id__": 15 + }, + { + "__id__": 16 + } + ], + "_prefab": { + "__id__": 17 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 0 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 13 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952" + }, + "_type": 1, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 13 + }, + "_enabled": true, + "alignMode": 0, + "_target": null, + "_alignFlags": 45, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 100, + "_originalHeight": 40, + "_id": "" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 13 + }, + "_enabled": true, + "renderLayer": null, + "renderZIndex": 0, + "syncInv": 0.01, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "b2yBk+BHFOF7B8n1gYypgp", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "Label", + "_objFlags": 0, + "_parent": { + "__id__": 12 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 19 + }, + { + "__id__": 20 + } + ], + "_prefab": { + "__id__": 21 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 18 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_string": "button", + "_N$string": "button", + "_fontSize": 20, + "_lineHeight": 40, + "_enableWrapText": false, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_styleFlags": 0, + "_underlineHeight": 0, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 1, + "_N$cacheMode": 2, + "_id": "" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 18 + }, + "_enabled": true, + "renderLayer": null, + "renderZIndex": 1, + "syncInv": 0.01, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "78ZrwHpmZIaZAh4fh1OXyZ", + "sync": false + }, + { + "__type__": "cc.Button", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 12 + }, + "_enabled": true, + "_normalMaterial": null, + "_grayMaterial": null, + "duration": 0.1, + "zoomScale": 1.2, + "clickEvents": [], + "_N$interactable": true, + "_N$enableAutoGrayEffect": false, + "_N$transition": 3, + "transition": 3, + "_N$normalColor": { + "__type__": "cc.Color", + "r": 230, + "g": 230, + "b": 230, + "a": 255 + }, + "_N$pressedColor": { + "__type__": "cc.Color", + "r": 200, + "g": 200, + "b": 200, + "a": 255 + }, + "pressedColor": { + "__type__": "cc.Color", + "r": 200, + "g": 200, + "b": 200, + "a": 255 + }, + "_N$hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$disabledColor": { + "__type__": "cc.Color", + "r": 120, + "g": 120, + "b": 120, + "a": 200 + }, + "_N$normalSprite": { + "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952" + }, + "_N$pressedSprite": { + "__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a" + }, + "pressedSprite": { + "__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a" + }, + "_N$hoverSprite": { + "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952" + }, + "hoverSprite": { + "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952" + }, + "_N$disabledSprite": { + "__uuid__": "29158224-f8dd-4661-a796-1ffab537140e" + }, + "_N$target": { + "__id__": 13 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "14TO6K8WlMjp8gwgtWA0qf", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "contentLb", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 25 + }, + { + "__id__": 26 + }, + { + "__id__": 27 + } + ], + "_prefab": { + "__id__": 28 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 333.07, + "height": 44 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 151.722, + -43.961, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 24 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_string": "ScrollView content", + "_N$string": "ScrollView content", + "_fontSize": 40, + "_lineHeight": 40, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_styleFlags": 0, + "_underlineHeight": 0, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 2, + "_id": "" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 24 + }, + "_enabled": true, + "renderLayer": null, + "renderZIndex": 1, + "syncInv": 0.01, + "_id": "" + }, + { + "__type__": "cc.LabelOutline", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 24 + }, + "_enabled": true, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_width": 2, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "41ShEz5VJCm68duiIf01ZR", + "sync": false + }, + { + "__type__": "9e178M6rUlI5qgi1+HcLO30", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "nameLb": { + "__id__": 8 + }, + "contentLb": { + "__id__": 25 + }, + "Button": { + "__id__": 12 + }, + "ButtonLb": { + "__id__": 19 + }, + "_id": "" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "alignMode": 2, + "_target": null, + "_alignFlags": 45, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 750, + "_originalHeight": 100, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "", + "sync": false + } +] \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/6c/6c5cf6e1-b044-4eac-9431-835644d57381.json b/Layered_virtual_list_2.x/library/imports/6c/6c5cf6e1-b044-4eac-9431-835644d57381.json new file mode 100644 index 0000000..a86f8af --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/6c/6c5cf6e1-b044-4eac-9431-835644d57381.json @@ -0,0 +1,103 @@ +{ + "__type__": "cc.EffectAsset", + "_name": "__builtin-editor-gizmo-unlit", + "_objFlags": 0, + "_native": "", + "properties": null, + "techniques": [ + { + "passes": [ + { + "stage": "transparent", + "blendState": { + "targets": [ + { + "blend": true, + "blendEq": 32774 + } + ] + }, + "rasterizerState": { + "cullMode": 0 + }, + "depthStencilState": { + "depthTest": false, + "depthWrite": false + }, + "properties": { + "diffuseColor": { + "value": [ + 1, + 1, + 1, + 1 + ], + "editor": { + "type": "color" + }, + "type": 16 + } + }, + "program": "__builtin-editor-gizmo-unlit|gizmo-unlit-vs|gizmo-unlit-fs:front" + } + ] + } + ], + "shaders": [ + { + "hash": 304964736, + "glsl3": { + "vert": "\nprecision highp float;\nattribute vec3 a_position;\nuniform CCGlobal {\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\nuniform CCLocal {\n mat4 cc_matWorld;\n mat4 cc_matWorldIT;\n};\nvoid main () {\n gl_Position = cc_matViewProj * cc_matWorld * vec4(a_position, 1);\n}", + "frag": "\nprecision highp float;\nvec4 CCFragOutput (vec4 color) {\n #if OUTPUT_TO_GAMMA\n color.rgb = sqrt(color.rgb);\n #endif\n\treturn color;\n}\nuniform DIFFUSE_COLOR {\n vec4 diffuseColor;\n};\nvec4 front() {\n return CCFragOutput(diffuseColor);\n}\nout vec4 cc_FragColor;\nvoid main() { cc_FragColor = front(); }" + }, + "glsl1": { + "vert": "\nprecision highp float;\nattribute vec3 a_position;\nuniform mat4 cc_matViewProj;\nuniform mat4 cc_matWorld;\nvoid main () {\n gl_Position = cc_matViewProj * cc_matWorld * vec4(a_position, 1);\n}", + "frag": "\nprecision highp float;\nvec4 CCFragOutput (vec4 color) {\n #if OUTPUT_TO_GAMMA\n color.rgb = sqrt(color.rgb);\n #endif\n\treturn color;\n}\nuniform vec4 diffuseColor;\nvec4 front() {\n return CCFragOutput(diffuseColor);\n}\nvoid main() { gl_FragColor = front(); }" + }, + "builtins": { + "globals": { + "blocks": [ + { + "name": "CCGlobal", + "defines": [] + } + ], + "samplers": [] + }, + "locals": { + "blocks": [ + { + "name": "CCLocal", + "defines": [] + } + ], + "samplers": [] + } + }, + "defines": [ + { + "name": "OUTPUT_TO_GAMMA", + "type": "boolean", + "defines": [] + } + ], + "blocks": [ + { + "name": "DIFFUSE_COLOR", + "members": [ + { + "name": "diffuseColor", + "type": 16, + "count": 1 + } + ], + "defines": [], + "binding": 0 + } + ], + "samplers": [], + "record": null, + "name": "__builtin-editor-gizmo-unlit|gizmo-unlit-vs|gizmo-unlit-fs:front" + } + ] +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/6c/6c9ef10d-b479-420b-bfe6-39cdda6a8ae0.json b/Layered_virtual_list_2.x/library/imports/6c/6c9ef10d-b479-420b-bfe6-39cdda6a8ae0.json new file mode 100644 index 0000000..479bf5c --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/6c/6c9ef10d-b479-420b-bfe6-39cdda6a8ae0.json @@ -0,0 +1,109 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "quad", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "asyncLoadAssets": false, + "readonly": false + }, + { + "__type__": "cc.Node", + "_name": "quad", + "_objFlags": 0, + "_parent": null, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 2 + } + ], + "_prefab": { + "__id__": 3 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.MeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "a5849239-3ad3-41d1-8ab4-ae9fea11f97f" + } + ], + "_mesh": { + "__uuid__": "e93d3fa9-8c21-4375-8a21-14ba84066c77" + }, + "_receiveShadows": false, + "_shadowCastingMode": 0, + "_enableAutoBatch": false, + "textures": [], + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "6c9ef10d-b479-420b-bfe6-39cdda6a8ae0" + }, + "fileId": "9b58ZeS0JLyLtsBZ/OlhCu", + "sync": false + } +] \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/6d/6d91e591-4ce0-465c-809f-610ec95019c6.json b/Layered_virtual_list_2.x/library/imports/6d/6d91e591-4ce0-465c-809f-610ec95019c6.json new file mode 100644 index 0000000..f179fed --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/6d/6d91e591-4ce0-465c-809f-610ec95019c6.json @@ -0,0 +1,333 @@ +{ + "__type__": "cc.EffectAsset", + "_name": "builtin-unlit", + "_objFlags": 0, + "_native": "", + "properties": null, + "techniques": [ + { + "name": "opaque", + "passes": [ + { + "blendState": { + "targets": [ + { + "blend": true + } + ] + }, + "rasterizerState": { + "cullMode": 0 + }, + "depthStencilState": { + "depthTest": true, + "depthWrite": true + }, + "properties": { + "diffuseTexture": { + "value": "white", + "type": 29 + }, + "diffuseColor": { + "value": [ + 1, + 1, + 1, + 1 + ], + "editor": { + "type": "color" + }, + "type": 16 + }, + "alphaThreshold": { + "value": [ + 0.5 + ], + "type": 13 + }, + "mainTiling": { + "value": [ + 1, + 1 + ], + "type": 14 + }, + "mainOffset": { + "value": [ + 0, + 0 + ], + "type": 14 + } + }, + "program": "builtin-unlit|unlit-vs|unlit-fs" + } + ] + }, + { + "name": "transparent", + "passes": [ + { + "stage": "transparent", + "blendState": { + "targets": [ + { + "blend": true + } + ] + }, + "rasterizerState": { + "cullMode": 0 + }, + "depthStencilState": { + "depthTest": true, + "depthWrite": false + }, + "properties": { + "diffuseTexture": { + "value": "white", + "type": 29 + }, + "diffuseColor": { + "value": [ + 1, + 1, + 1, + 1 + ], + "editor": { + "type": "color" + }, + "type": 16 + }, + "alphaThreshold": { + "value": [ + 0.5 + ], + "type": 13 + }, + "mainTiling": { + "value": [ + 1, + 1 + ], + "type": 14 + }, + "mainOffset": { + "value": [ + 0, + 0 + ], + "type": 14 + } + }, + "program": "builtin-unlit|unlit-vs|unlit-fs" + } + ] + } + ], + "shaders": [ + { + "hash": 922858114, + "glsl3": { + "vert": "\nprecision highp float;\nuniform CCLocal {\n mat4 cc_matWorld;\n mat4 cc_matWorldIT;\n};\nuniform CCGlobal {\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\n#if CC_USE_SKINNING\n in vec4 a_weights;\n in vec4 a_joints;\n #if CC_USE_JOINTS_TEXTRUE\n uniform SKINNING {\n vec2 jointsTextureSize;\n };\n uniform sampler2D jointsTexture;\n #if CC_JOINTS_TEXTURE_FLOAT32\n mat4 getBoneMatrix(const in float i) {\n float width = jointsTextureSize.x;\n float height = jointsTextureSize.y;\n float j = i * 4.0;\n float x = mod(j, width);\n float y = floor(j / width);\n float dx = 1.0 / width;\n float dy = 1.0 / height;\n y = dy * (y + 0.5);\n vec4 v1 = texture(jointsTexture, vec2(dx * (x + 0.5), y));\n vec4 v2 = texture(jointsTexture, vec2(dx * (x + 1.5), y));\n vec4 v3 = texture(jointsTexture, vec2(dx * (x + 2.5), y));\n vec4 v4 = texture(jointsTexture, vec2(dx * (x + 3.5), y));\n return mat4(v1, v2, v3, v4);\n }\n #else\n float decode32(vec4 rgba) {\n float Sign = 1.0 - step(128.0, rgba[0]) * 2.0;\n float Exponent = 2.0 * mod(rgba[0], 128.0) + step(128.0, rgba[1]) - 127.0;\n float Mantissa = mod(rgba[1], 128.0) * 65536.0 + rgba[2] * 256.0 + rgba[3] + 8388608.0;\n return Sign * exp2(Exponent - 23.0) * Mantissa;\n }\n vec4 decodevec4 (vec4 x, vec4 y, vec4 z, vec4 w) {\n return vec4(\n decode32(x.wzyx * 255.0),\n decode32(y.wzyx * 255.0),\n decode32(z.wzyx * 255.0),\n decode32(w.wzyx * 255.0)\n );\n }\n vec4 decodevec4 (float dx, float x, float y) {\n return decodevec4(\n texture(jointsTexture, vec2(dx * (x + 0.5), y)),\n texture(jointsTexture, vec2(dx * (x + 1.5), y)),\n texture(jointsTexture, vec2(dx * (x + 2.5), y)),\n texture(jointsTexture, vec2(dx * (x + 3.5), y))\n );\n }\n mat4 getBoneMatrix(const in float i) {\n float width = jointsTextureSize.x;\n float height = jointsTextureSize.y;\n float j = i * 16.0;\n float x = mod(j, width);\n float y = floor(j / width);\n float dx = 1.0 / width;\n float dy = 1.0 / height;\n y = dy * (y + 0.5);\n vec4 v1 = decodevec4(dx, x, y);\n vec4 v2 = decodevec4(dx, x+4.0, y);\n vec4 v3 = decodevec4(dx, x+8.0, y);\n vec4 v4 = decodevec4(dx, x+12.0, y);\n return mat4(v1, v2, v3, v4);\n }\n #endif\n #else\n uniform JOINT_MATRIX {\n mat4 jointMatrices[50];\n };\n mat4 getBoneMatrix(const in float i) {\n return jointMatrices[int(i)];\n }\n #endif\n mat4 skinMatrix() {\n return\n getBoneMatrix(a_joints.x) * a_weights.x +\n getBoneMatrix(a_joints.y) * a_weights.y +\n getBoneMatrix(a_joints.z) * a_weights.z +\n getBoneMatrix(a_joints.w) * a_weights.w\n ;\n }\n#endif\nstruct StandardVertInput {\n vec2 uv;\n vec4 position;\n vec3 normal;\n vec4 tangent;\n vec4 color;\n};\nin vec3 a_position;\n#if CC_USE_ATTRIBUTE_UV0\nin vec2 a_uv0;\n#endif\n#if CC_USE_ATTRIBUTE_COLOR\nin vec4 a_color;\n#endif\n#if CC_USE_ATTRIBUTE_NORMAL\nin vec3 a_normal;\n#endif\n#if CC_USE_ATTRIBUTE_TANGENT\nin vec4 a_tangent;\n#endif\nvoid CCAttribute (out StandardVertInput In) {\n In.position = vec4(a_position, 1.0);\n #if CC_USE_ATTRIBUTE_UV0\n In.uv = a_uv0;\n #else\n In.uv = vec2(0.0);\n #endif\n #if CC_USE_ATTRIBUTE_COLOR\n In.color = a_color;\n #else\n In.color = vec4(1.0);\n #endif\n #if CC_USE_ATTRIBUTE_NORMAL\n In.normal = a_normal;\n #else\n In.normal = vec3(0.0, 1.0, 0.0);\n #endif\n #if CC_USE_ATTRIBUTE_TANGENT\n In.tangent = a_tangent;\n #else\n In.tangent = vec4(1.0, 0.0, 0.0, 0.0);\n #endif\n}\nvoid CCVertInput(out StandardVertInput In) {\n CCAttribute(In);\n #if CC_USE_SKINNING\n mat4 m = skinMatrix();\n In.position = m * In.position;\n #if CC_USE_ATTRIBUTE_NORMAL\n In.normal = (m * vec4(In.normal, 0)).xyz;\n #endif\n #if CC_USE_ATTRIBUTE_TANGENT\n In.tangent = m * In.tangent;\n #endif\n #endif\n}\nuniform MAIN_TILING {\n vec2 mainTiling;\n vec2 mainOffset;\n};\n#if CC_USE_ATTRIBUTE_UV0 && USE_DIFFUSE_TEXTURE\n out mediump vec2 v_uv0;\n#endif\n#if CC_USE_ATTRIBUTE_COLOR\n out lowp vec4 v_color;\n#endif\nvoid main () {\n StandardVertInput In;\n CCVertInput(In);\n #if CC_USE_ATTRIBUTE_COLOR\n v_color = In.color;\n #endif\n #if CC_USE_ATTRIBUTE_UV0 && USE_DIFFUSE_TEXTURE\n v_uv0 = In.uv * mainTiling + mainOffset;\n #endif\n gl_Position = cc_matViewProj * cc_matWorld * In.position;\n}", + "frag": "\nprecision highp float;\n#if USE_ALPHA_TEST\n uniform ALPHA_TEST {\n float alphaThreshold;\n };\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\nvec4 CCFragOutput (vec4 color) {\n #if OUTPUT_TO_GAMMA\n color.rgb = sqrt(color.rgb);\n #endif\n\treturn color;\n}\nuniform UNLIT {\n lowp vec4 diffuseColor;\n};\n#if USE_DIFFUSE_TEXTURE\n uniform sampler2D diffuseTexture;\n#endif\n#if CC_USE_ATTRIBUTE_COLOR\n in lowp vec4 v_color;\n#endif\n#if CC_USE_ATTRIBUTE_UV0 && USE_DIFFUSE_TEXTURE\n in mediump vec2 v_uv0;\n#endif\nvoid main () {\n vec4 color = diffuseColor;\n #if CC_USE_ATTRIBUTE_UV0 && USE_DIFFUSE_TEXTURE\n vec4 diffuseTexture_tmp = texture(diffuseTexture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_diffuseTexture\n diffuseTexture_tmp.a *= texture(diffuseTexture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n color.rgb *= (diffuseTexture_tmp.rgb * diffuseTexture_tmp.rgb);\n color.a *= diffuseTexture_tmp.a;\n #else\n color *= diffuseTexture_tmp;\n #endif\n #endif\n #if CC_USE_ATTRIBUTE_COLOR\n color *= v_color;\n #endif\n ALPHA_TEST(color);\n gl_FragColor = CCFragOutput(color);\n}" + }, + "glsl1": { + "vert": "\nprecision highp float;\nuniform mat4 cc_matWorld;\nuniform mat4 cc_matViewProj;\n#if CC_USE_SKINNING\n attribute vec4 a_weights;\n attribute vec4 a_joints;\n #if CC_USE_JOINTS_TEXTRUE\n uniform vec2 jointsTextureSize;\n uniform sampler2D jointsTexture;\n #if CC_JOINTS_TEXTURE_FLOAT32\n mat4 getBoneMatrix(const in float i) {\n float width = jointsTextureSize.x;\n float height = jointsTextureSize.y;\n float j = i * 4.0;\n float x = mod(j, width);\n float y = floor(j / width);\n float dx = 1.0 / width;\n float dy = 1.0 / height;\n y = dy * (y + 0.5);\n vec4 v1 = texture2D(jointsTexture, vec2(dx * (x + 0.5), y));\n vec4 v2 = texture2D(jointsTexture, vec2(dx * (x + 1.5), y));\n vec4 v3 = texture2D(jointsTexture, vec2(dx * (x + 2.5), y));\n vec4 v4 = texture2D(jointsTexture, vec2(dx * (x + 3.5), y));\n return mat4(v1, v2, v3, v4);\n }\n #else\n float decode32(vec4 rgba) {\n float Sign = 1.0 - step(128.0, rgba[0]) * 2.0;\n float Exponent = 2.0 * mod(rgba[0], 128.0) + step(128.0, rgba[1]) - 127.0;\n float Mantissa = mod(rgba[1], 128.0) * 65536.0 + rgba[2] * 256.0 + rgba[3] + 8388608.0;\n return Sign * exp2(Exponent - 23.0) * Mantissa;\n }\n vec4 decodevec4 (vec4 x, vec4 y, vec4 z, vec4 w) {\n return vec4(\n decode32(x.wzyx * 255.0),\n decode32(y.wzyx * 255.0),\n decode32(z.wzyx * 255.0),\n decode32(w.wzyx * 255.0)\n );\n }\n vec4 decodevec4 (float dx, float x, float y) {\n return decodevec4(\n texture2D(jointsTexture, vec2(dx * (x + 0.5), y)),\n texture2D(jointsTexture, vec2(dx * (x + 1.5), y)),\n texture2D(jointsTexture, vec2(dx * (x + 2.5), y)),\n texture2D(jointsTexture, vec2(dx * (x + 3.5), y))\n );\n }\n mat4 getBoneMatrix(const in float i) {\n float width = jointsTextureSize.x;\n float height = jointsTextureSize.y;\n float j = i * 16.0;\n float x = mod(j, width);\n float y = floor(j / width);\n float dx = 1.0 / width;\n float dy = 1.0 / height;\n y = dy * (y + 0.5);\n vec4 v1 = decodevec4(dx, x, y);\n vec4 v2 = decodevec4(dx, x+4.0, y);\n vec4 v3 = decodevec4(dx, x+8.0, y);\n vec4 v4 = decodevec4(dx, x+12.0, y);\n return mat4(v1, v2, v3, v4);\n }\n #endif\n #else\n uniform mat4 jointMatrices[50];\n mat4 getBoneMatrix(const in float i) {\n return jointMatrices[int(i)];\n }\n #endif\n mat4 skinMatrix() {\n return\n getBoneMatrix(a_joints.x) * a_weights.x +\n getBoneMatrix(a_joints.y) * a_weights.y +\n getBoneMatrix(a_joints.z) * a_weights.z +\n getBoneMatrix(a_joints.w) * a_weights.w\n ;\n }\n#endif\nstruct StandardVertInput {\n vec2 uv;\n vec4 position;\n vec3 normal;\n vec4 tangent;\n vec4 color;\n};\nattribute vec3 a_position;\n#if CC_USE_ATTRIBUTE_UV0\nattribute vec2 a_uv0;\n#endif\n#if CC_USE_ATTRIBUTE_COLOR\nattribute vec4 a_color;\n#endif\n#if CC_USE_ATTRIBUTE_NORMAL\nattribute vec3 a_normal;\n#endif\n#if CC_USE_ATTRIBUTE_TANGENT\nattribute vec4 a_tangent;\n#endif\nvoid CCAttribute (out StandardVertInput In) {\n In.position = vec4(a_position, 1.0);\n #if CC_USE_ATTRIBUTE_UV0\n In.uv = a_uv0;\n #else\n In.uv = vec2(0.0);\n #endif\n #if CC_USE_ATTRIBUTE_COLOR\n In.color = a_color;\n #else\n In.color = vec4(1.0);\n #endif\n #if CC_USE_ATTRIBUTE_NORMAL\n In.normal = a_normal;\n #else\n In.normal = vec3(0.0, 1.0, 0.0);\n #endif\n #if CC_USE_ATTRIBUTE_TANGENT\n In.tangent = a_tangent;\n #else\n In.tangent = vec4(1.0, 0.0, 0.0, 0.0);\n #endif\n}\nvoid CCVertInput(out StandardVertInput In) {\n CCAttribute(In);\n #if CC_USE_SKINNING\n mat4 m = skinMatrix();\n In.position = m * In.position;\n #if CC_USE_ATTRIBUTE_NORMAL\n In.normal = (m * vec4(In.normal, 0)).xyz;\n #endif\n #if CC_USE_ATTRIBUTE_TANGENT\n In.tangent = m * In.tangent;\n #endif\n #endif\n}\nuniform vec2 mainTiling;\nuniform vec2 mainOffset;\n#if CC_USE_ATTRIBUTE_UV0 && USE_DIFFUSE_TEXTURE\n varying mediump vec2 v_uv0;\n#endif\n#if CC_USE_ATTRIBUTE_COLOR\n varying lowp vec4 v_color;\n#endif\nvoid main () {\n StandardVertInput In;\n CCVertInput(In);\n #if CC_USE_ATTRIBUTE_COLOR\n v_color = In.color;\n #endif\n #if CC_USE_ATTRIBUTE_UV0 && USE_DIFFUSE_TEXTURE\n v_uv0 = In.uv * mainTiling + mainOffset;\n #endif\n gl_Position = cc_matViewProj * cc_matWorld * In.position;\n}", + "frag": "\nprecision highp float;\n#if USE_ALPHA_TEST\n uniform float alphaThreshold;\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\nvec4 CCFragOutput (vec4 color) {\n #if OUTPUT_TO_GAMMA\n color.rgb = sqrt(color.rgb);\n #endif\n\treturn color;\n}\nuniform lowp vec4 diffuseColor;\n#if USE_DIFFUSE_TEXTURE\n uniform sampler2D diffuseTexture;\n#endif\n#if CC_USE_ATTRIBUTE_COLOR\n varying lowp vec4 v_color;\n#endif\n#if CC_USE_ATTRIBUTE_UV0 && USE_DIFFUSE_TEXTURE\n varying mediump vec2 v_uv0;\n#endif\nvoid main () {\n vec4 color = diffuseColor;\n #if CC_USE_ATTRIBUTE_UV0 && USE_DIFFUSE_TEXTURE\n vec4 diffuseTexture_tmp = texture2D(diffuseTexture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_diffuseTexture\n diffuseTexture_tmp.a *= texture2D(diffuseTexture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n color.rgb *= (diffuseTexture_tmp.rgb * diffuseTexture_tmp.rgb);\n color.a *= diffuseTexture_tmp.a;\n #else\n color *= diffuseTexture_tmp;\n #endif\n #endif\n #if CC_USE_ATTRIBUTE_COLOR\n color *= v_color;\n #endif\n ALPHA_TEST(color);\n gl_FragColor = CCFragOutput(color);\n}" + }, + "builtins": { + "globals": { + "blocks": [ + { + "name": "CCGlobal", + "defines": [] + } + ], + "samplers": [] + }, + "locals": { + "blocks": [ + { + "name": "CCLocal", + "defines": [] + } + ], + "samplers": [] + } + }, + "defines": [ + { + "name": "CC_USE_SKINNING", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_JOINTS_TEXTRUE", + "type": "boolean", + "defines": [ + "CC_USE_SKINNING" + ] + }, + { + "name": "CC_JOINTS_TEXTURE_FLOAT32", + "type": "boolean", + "defines": [ + "CC_USE_SKINNING", + "CC_USE_JOINTS_TEXTRUE" + ] + }, + { + "name": "CC_USE_ATTRIBUTE_UV0", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_ATTRIBUTE_COLOR", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_ATTRIBUTE_NORMAL", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_ATTRIBUTE_TANGENT", + "type": "boolean", + "defines": [] + }, + { + "name": "USE_DIFFUSE_TEXTURE", + "type": "boolean", + "defines": [] + }, + { + "name": "USE_ALPHA_TEST", + "type": "boolean", + "defines": [] + }, + { + "name": "OUTPUT_TO_GAMMA", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_ALPHA_ATLAS_diffuseTexture", + "type": "boolean", + "defines": [ + "CC_USE_ATTRIBUTE_UV0", + "USE_DIFFUSE_TEXTURE" + ] + }, + { + "name": "INPUT_IS_GAMMA", + "type": "boolean", + "defines": [ + "CC_USE_ATTRIBUTE_UV0", + "USE_DIFFUSE_TEXTURE" + ] + } + ], + "blocks": [ + { + "name": "SKINNING", + "members": [ + { + "name": "jointsTextureSize", + "type": 14, + "count": 1 + } + ], + "defines": [ + "CC_USE_SKINNING", + "CC_USE_JOINTS_TEXTRUE" + ], + "binding": 0 + }, + { + "name": "JOINT_MATRIX", + "members": [ + { + "name": "jointMatrices", + "type": 26, + "count": 50 + } + ], + "defines": [ + "CC_USE_SKINNING" + ], + "binding": 1 + }, + { + "name": "MAIN_TILING", + "members": [ + { + "name": "mainTiling", + "type": 14, + "count": 1 + }, + { + "name": "mainOffset", + "type": 14, + "count": 1 + } + ], + "defines": [], + "binding": 2 + }, + { + "name": "ALPHA_TEST", + "members": [ + { + "name": "alphaThreshold", + "type": 13, + "count": 1 + } + ], + "defines": [ + "USE_ALPHA_TEST" + ], + "binding": 3 + }, + { + "name": "UNLIT", + "members": [ + { + "name": "diffuseColor", + "type": 16, + "count": 1 + } + ], + "defines": [], + "binding": 4 + } + ], + "samplers": [ + { + "name": "jointsTexture", + "type": 29, + "count": 1, + "defines": [ + "CC_USE_SKINNING", + "CC_USE_JOINTS_TEXTRUE" + ], + "binding": 30 + }, + { + "name": "diffuseTexture", + "type": 29, + "count": 1, + "defines": [ + "USE_DIFFUSE_TEXTURE" + ], + "binding": 31 + } + ], + "record": null, + "name": "builtin-unlit|unlit-vs|unlit-fs" + } + ] +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/6e/6e056173-d285-473c-b206-40a7fff5386e.json b/Layered_virtual_list_2.x/library/imports/6e/6e056173-d285-473c-b206-40a7fff5386e.json new file mode 100644 index 0000000..e7522d6 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/6e/6e056173-d285-473c-b206-40a7fff5386e.json @@ -0,0 +1,4 @@ +{ + "__type__": "cc.Texture2D", + "content": "0,9729,9729,33071,33071,0,0,1" +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/6e/6e056173-d285-473c-b206-40a7fff5386e.png b/Layered_virtual_list_2.x/library/imports/6e/6e056173-d285-473c-b206-40a7fff5386e.png new file mode 100644 index 0000000..ffe3879 Binary files /dev/null and b/Layered_virtual_list_2.x/library/imports/6e/6e056173-d285-473c-b206-40a7fff5386e.png differ diff --git a/Layered_virtual_list_2.x/library/imports/6f/6f801092-0c37-4f30-89ef-c8d960825b36.json b/Layered_virtual_list_2.x/library/imports/6f/6f801092-0c37-4f30-89ef-c8d960825b36.json new file mode 100644 index 0000000..003367b --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/6f/6f801092-0c37-4f30-89ef-c8d960825b36.json @@ -0,0 +1,10 @@ +{ + "__type__": "cc.Material", + "_name": "builtin-2d-base", + "_objFlags": 0, + "_native": "", + "_effectAsset": { + "__uuid__": "2874f8dd-416c-4440-81b7-555975426e93" + }, + "_techniqueData": {} +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/70/70bbeb73-6dc2-4ee4-8faf-76b3a0e34ec4.json b/Layered_virtual_list_2.x/library/imports/70/70bbeb73-6dc2-4ee4-8faf-76b3a0e34ec4.json new file mode 100644 index 0000000..6e22adb --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/70/70bbeb73-6dc2-4ee4-8faf-76b3a0e34ec4.json @@ -0,0 +1,2327 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "3d-particle", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "asyncLoadAssets": false, + "readonly": false + }, + { + "__type__": "cc.Node", + "_name": "ParticleSystem3D", + "_objFlags": 0, + "_parent": null, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 2 + } + ], + "_prefab": { + "__id__": 154 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.ParticleSystem3D", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "432fa09c-cf03-4cff-a186-982604408a07" + } + ], + "duration": 5, + "_capacity": 100, + "loop": true, + "playOnAwake": true, + "_prewarm": false, + "_simulationSpace": 1, + "simulationSpeed": 1, + "startDelay": { + "__id__": 3 + }, + "startLifetime": { + "__id__": 9 + }, + "startColor": { + "__id__": 13 + }, + "scaleSpace": 1, + "startSize": { + "__id__": 17 + }, + "startSpeed": { + "__id__": 21 + }, + "startRotation": { + "__id__": 25 + }, + "gravityModifier": { + "__id__": 29 + }, + "rateOverTime": { + "__id__": 33 + }, + "rateOverDistance": { + "__id__": 37 + }, + "bursts": [], + "_renderMode": 0, + "_velocityScale": 1, + "_lengthScale": 1, + "_mesh": null, + "_id": "", + "_shapeModule": { + "__id__": 41 + }, + "_colorOverLifetimeModule": { + "__id__": 46 + }, + "_sizeOvertimeModule": { + "__id__": 51 + }, + "_velocityOvertimeModule": { + "__id__": 68 + }, + "_forceOvertimeModule": { + "__id__": 85 + }, + "_limitVelocityOvertimeModule": { + "__id__": 98 + }, + "_rotationOvertimeModule": { + "__id__": 115 + }, + "_textureAnimationModule": { + "__id__": 128 + }, + "_trailModule": { + "__id__": 137 + } + }, + { + "__type__": "cc.CurveRange", + "mode": 0, + "curve": { + "__id__": 4 + }, + "curveMin": { + "__id__": 7 + }, + "curveMax": { + "__id__": 8 + }, + "constant": 0, + "constantMin": 0, + "constantMax": 0, + "multiplier": 1 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.Keyframe", + "time": 0, + "value": 1, + "inTangent": 0, + "outTangent": 0 + }, + { + "__type__": "cc.Keyframe", + "time": 1, + "value": 1, + "inTangent": 0, + "outTangent": 0 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.CurveRange", + "mode": 0, + "curve": { + "__id__": 10 + }, + "curveMin": { + "__id__": 11 + }, + "curveMax": { + "__id__": 12 + }, + "constant": 5, + "constantMin": 0, + "constantMax": 0, + "multiplier": 1 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.GradientRange", + "_mode": 0, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "colorMin": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "colorMax": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "gradient": { + "__id__": 14 + }, + "gradientMin": { + "__id__": 15 + }, + "gradientMax": { + "__id__": 16 + } + }, + { + "__type__": "cc.Gradient", + "colorKeys": [], + "alphaKeys": [], + "mode": 0 + }, + { + "__type__": "cc.Gradient", + "colorKeys": [], + "alphaKeys": [], + "mode": 0 + }, + { + "__type__": "cc.Gradient", + "colorKeys": [], + "alphaKeys": [], + "mode": 0 + }, + { + "__type__": "cc.CurveRange", + "mode": 0, + "curve": { + "__id__": 18 + }, + "curveMin": { + "__id__": 19 + }, + "curveMax": { + "__id__": 20 + }, + "constant": 1, + "constantMin": 0, + "constantMax": 0, + "multiplier": 1 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.CurveRange", + "mode": 0, + "curve": { + "__id__": 22 + }, + "curveMin": { + "__id__": 23 + }, + "curveMax": { + "__id__": 24 + }, + "constant": 5, + "constantMin": 0, + "constantMax": 0, + "multiplier": 1 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.CurveRange", + "mode": 0, + "curve": { + "__id__": 26 + }, + "curveMin": { + "__id__": 27 + }, + "curveMax": { + "__id__": 28 + }, + "constant": 0, + "constantMin": 0, + "constantMax": 0, + "multiplier": 1 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.CurveRange", + "mode": 0, + "curve": { + "__id__": 30 + }, + "curveMin": { + "__id__": 31 + }, + "curveMax": { + "__id__": 32 + }, + "constant": 0, + "constantMin": 0, + "constantMax": 0, + "multiplier": 1 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.CurveRange", + "mode": 0, + "curve": { + "__id__": 34 + }, + "curveMin": { + "__id__": 35 + }, + "curveMax": { + "__id__": 36 + }, + "constant": 10, + "constantMin": 0, + "constantMax": 0, + "multiplier": 1 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.CurveRange", + "mode": 0, + "curve": { + "__id__": 38 + }, + "curveMin": { + "__id__": 39 + }, + "curveMax": { + "__id__": 40 + }, + "constant": 0, + "constantMin": 0, + "constantMax": 0, + "multiplier": 1 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.ShapeModule", + "enable": true, + "_shapeType": 2, + "emitFrom": 0, + "radius": 1, + "radiusThickness": 1, + "_angle": 0.4363323129985824, + "_arc": 6.283185307179586, + "arcMode": 0, + "arcSpread": 0, + "arcSpeed": { + "__id__": 42 + }, + "length": 5, + "boxThickness": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_position": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_rotation": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_scale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "alignToDirection": false, + "randomDirectionAmount": 0, + "sphericalDirectionAmount": 0, + "randomPositionAmount": 0 + }, + { + "__type__": "cc.CurveRange", + "mode": 0, + "curve": { + "__id__": 43 + }, + "curveMin": { + "__id__": 44 + }, + "curveMax": { + "__id__": 45 + }, + "constant": 0, + "constantMin": 0, + "constantMax": 0, + "multiplier": 1 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.ColorOvertimeModule", + "enable": false, + "color": { + "__id__": 47 + } + }, + { + "__type__": "cc.GradientRange", + "_mode": 0, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "color": { + "__type__": "cc.Color", + "r": 253, + "g": 7, + "b": 7, + "a": 255 + }, + "colorMin": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "colorMax": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "gradient": { + "__id__": 48 + }, + "gradientMin": { + "__id__": 49 + }, + "gradientMax": { + "__id__": 50 + } + }, + { + "__type__": "cc.Gradient", + "colorKeys": [], + "alphaKeys": [], + "mode": 0 + }, + { + "__type__": "cc.Gradient", + "colorKeys": [], + "alphaKeys": [], + "mode": 0 + }, + { + "__type__": "cc.Gradient", + "colorKeys": [], + "alphaKeys": [], + "mode": 0 + }, + { + "__type__": "cc.SizeOvertimeModule", + "enable": false, + "separateAxes": false, + "size": { + "__id__": 52 + }, + "x": { + "__id__": 56 + }, + "y": { + "__id__": 60 + }, + "z": { + "__id__": 64 + } + }, + { + "__type__": "cc.CurveRange", + "mode": 0, + "curve": { + "__id__": 53 + }, + "curveMin": { + "__id__": 54 + }, + "curveMax": { + "__id__": 55 + }, + "constant": 0, + "constantMin": 0, + "constantMax": 0, + "multiplier": 1 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.CurveRange", + "mode": 0, + "curve": { + "__id__": 57 + }, + "curveMin": { + "__id__": 58 + }, + "curveMax": { + "__id__": 59 + }, + "constant": 0, + "constantMin": 0, + "constantMax": 0, + "multiplier": 1 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.CurveRange", + "mode": 0, + "curve": { + "__id__": 61 + }, + "curveMin": { + "__id__": 62 + }, + "curveMax": { + "__id__": 63 + }, + "constant": 0, + "constantMin": 0, + "constantMax": 0, + "multiplier": 1 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.CurveRange", + "mode": 0, + "curve": { + "__id__": 65 + }, + "curveMin": { + "__id__": 66 + }, + "curveMax": { + "__id__": 67 + }, + "constant": 0, + "constantMin": 0, + "constantMax": 0, + "multiplier": 1 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.VelocityOvertimeModule", + "enable": false, + "space": 1, + "x": { + "__id__": 69 + }, + "y": { + "__id__": 73 + }, + "z": { + "__id__": 77 + }, + "speedModifier": { + "__id__": 81 + } + }, + { + "__type__": "cc.CurveRange", + "mode": 0, + "curve": { + "__id__": 70 + }, + "curveMin": { + "__id__": 71 + }, + "curveMax": { + "__id__": 72 + }, + "constant": 0, + "constantMin": 0, + "constantMax": 0, + "multiplier": 1 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.CurveRange", + "mode": 0, + "curve": { + "__id__": 74 + }, + "curveMin": { + "__id__": 75 + }, + "curveMax": { + "__id__": 76 + }, + "constant": 0, + "constantMin": 0, + "constantMax": 0, + "multiplier": 1 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.CurveRange", + "mode": 0, + "curve": { + "__id__": 78 + }, + "curveMin": { + "__id__": 79 + }, + "curveMax": { + "__id__": 80 + }, + "constant": 0, + "constantMin": 0, + "constantMax": 0, + "multiplier": 1 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.CurveRange", + "mode": 0, + "curve": { + "__id__": 82 + }, + "curveMin": { + "__id__": 83 + }, + "curveMax": { + "__id__": 84 + }, + "constant": 1, + "constantMin": 0, + "constantMax": 0, + "multiplier": 1 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.ForceOvertimeModule", + "enable": false, + "space": 1, + "x": { + "__id__": 86 + }, + "y": { + "__id__": 90 + }, + "z": { + "__id__": 94 + } + }, + { + "__type__": "cc.CurveRange", + "mode": 0, + "curve": { + "__id__": 87 + }, + "curveMin": { + "__id__": 88 + }, + "curveMax": { + "__id__": 89 + }, + "constant": 0, + "constantMin": 0, + "constantMax": 0, + "multiplier": 1 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.CurveRange", + "mode": 0, + "curve": { + "__id__": 91 + }, + "curveMin": { + "__id__": 92 + }, + "curveMax": { + "__id__": 93 + }, + "constant": 0, + "constantMin": 0, + "constantMax": 0, + "multiplier": 1 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.CurveRange", + "mode": 0, + "curve": { + "__id__": 95 + }, + "curveMin": { + "__id__": 96 + }, + "curveMax": { + "__id__": 97 + }, + "constant": 0, + "constantMin": 0, + "constantMax": 0, + "multiplier": 1 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.LimitVelocityOvertimeModule", + "enable": false, + "space": 1, + "separateAxes": false, + "limit": { + "__id__": 99 + }, + "limitX": { + "__id__": 103 + }, + "limitY": { + "__id__": 107 + }, + "limitZ": { + "__id__": 111 + }, + "dampen": 3 + }, + { + "__type__": "cc.CurveRange", + "mode": 0, + "curve": { + "__id__": 100 + }, + "curveMin": { + "__id__": 101 + }, + "curveMax": { + "__id__": 102 + }, + "constant": 0, + "constantMin": 0, + "constantMax": 0, + "multiplier": 1 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.CurveRange", + "mode": 0, + "curve": { + "__id__": 104 + }, + "curveMin": { + "__id__": 105 + }, + "curveMax": { + "__id__": 106 + }, + "constant": 0, + "constantMin": 0, + "constantMax": 0, + "multiplier": 1 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.CurveRange", + "mode": 0, + "curve": { + "__id__": 108 + }, + "curveMin": { + "__id__": 109 + }, + "curveMax": { + "__id__": 110 + }, + "constant": 0, + "constantMin": 0, + "constantMax": 0, + "multiplier": 1 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.CurveRange", + "mode": 0, + "curve": { + "__id__": 112 + }, + "curveMin": { + "__id__": 113 + }, + "curveMax": { + "__id__": 114 + }, + "constant": 0, + "constantMin": 0, + "constantMax": 0, + "multiplier": 1 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.RotationOvertimeModule", + "enable": false, + "_separateAxes": false, + "x": { + "__id__": 116 + }, + "y": { + "__id__": 120 + }, + "z": { + "__id__": 124 + } + }, + { + "__type__": "cc.CurveRange", + "mode": 0, + "curve": { + "__id__": 117 + }, + "curveMin": { + "__id__": 118 + }, + "curveMax": { + "__id__": 119 + }, + "constant": 0, + "constantMin": 0, + "constantMax": 0, + "multiplier": 1 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.CurveRange", + "mode": 0, + "curve": { + "__id__": 121 + }, + "curveMin": { + "__id__": 122 + }, + "curveMax": { + "__id__": 123 + }, + "constant": 0, + "constantMin": 0, + "constantMax": 0, + "multiplier": 1 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.CurveRange", + "mode": 0, + "curve": { + "__id__": 125 + }, + "curveMin": { + "__id__": 126 + }, + "curveMax": { + "__id__": 127 + }, + "constant": 0, + "constantMin": 0, + "constantMax": 0, + "multiplier": 1 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.TextureAnimationModule", + "_enable": false, + "_mode": 0, + "animation": 0, + "randomRow": false, + "rowIndex": 0, + "frameOverTime": { + "__id__": 129 + }, + "startFrame": { + "__id__": 133 + }, + "cycleCount": 0, + "_numTilesX": 0, + "_numTilesY": 0 + }, + { + "__type__": "cc.CurveRange", + "mode": 0, + "curve": { + "__id__": 130 + }, + "curveMin": { + "__id__": 131 + }, + "curveMax": { + "__id__": 132 + }, + "constant": 0, + "constantMin": 0, + "constantMax": 0, + "multiplier": 1 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.CurveRange", + "mode": 0, + "curve": { + "__id__": 134 + }, + "curveMin": { + "__id__": 135 + }, + "curveMax": { + "__id__": 136 + }, + "constant": 0, + "constantMin": 0, + "constantMax": 0, + "multiplier": 1 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.TrailModule", + "_enable": false, + "mode": 0, + "lifeTime": { + "__id__": 138 + }, + "_minParticleDistance": 0.1, + "_space": 0, + "existWithParticles": true, + "textureMode": 0, + "widthFromParticle": true, + "widthRatio": { + "__id__": 142 + }, + "colorFromParticle": false, + "colorOverTrail": { + "__id__": 146 + }, + "colorOvertime": { + "__id__": 150 + } + }, + { + "__type__": "cc.CurveRange", + "mode": 0, + "curve": { + "__id__": 139 + }, + "curveMin": { + "__id__": 140 + }, + "curveMax": { + "__id__": 141 + }, + "constant": 1, + "constantMin": 0, + "constantMax": 0, + "multiplier": 1 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.CurveRange", + "mode": 0, + "curve": { + "__id__": 143 + }, + "curveMin": { + "__id__": 144 + }, + "curveMax": { + "__id__": 145 + }, + "constant": 0, + "constantMin": 0, + "constantMax": 0, + "multiplier": 1 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.AnimationCurve", + "keyFrames": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "preWrapMode": 2, + "postWrapMode": 2 + }, + { + "__type__": "cc.GradientRange", + "_mode": 0, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "colorMin": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "colorMax": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "gradient": { + "__id__": 147 + }, + "gradientMin": { + "__id__": 148 + }, + "gradientMax": { + "__id__": 149 + } + }, + { + "__type__": "cc.Gradient", + "colorKeys": [], + "alphaKeys": [], + "mode": 0 + }, + { + "__type__": "cc.Gradient", + "colorKeys": [], + "alphaKeys": [], + "mode": 0 + }, + { + "__type__": "cc.Gradient", + "colorKeys": [], + "alphaKeys": [], + "mode": 0 + }, + { + "__type__": "cc.GradientRange", + "_mode": 0, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "colorMin": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "colorMax": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "gradient": { + "__id__": 151 + }, + "gradientMin": { + "__id__": 152 + }, + "gradientMax": { + "__id__": 153 + } + }, + { + "__type__": "cc.Gradient", + "colorKeys": [], + "alphaKeys": [], + "mode": 0 + }, + { + "__type__": "cc.Gradient", + "colorKeys": [], + "alphaKeys": [], + "mode": 0 + }, + { + "__type__": "cc.Gradient", + "colorKeys": [], + "alphaKeys": [], + "mode": 0 + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "70bbeb73-6dc2-4ee4-8faf-76b3a0e34ec4" + }, + "fileId": "a7grHQWGBCppuqJqizdE84", + "sync": false + } +] \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/70/70d7cdb0-04cd-41bb-9480-c06a4785f386.json b/Layered_virtual_list_2.x/library/imports/70/70d7cdb0-04cd-41bb-9480-c06a4785f386.json new file mode 100644 index 0000000..7ea85d0 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/70/70d7cdb0-04cd-41bb-9480-c06a4785f386.json @@ -0,0 +1,123 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "3d-camera", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "asyncLoadAssets": false, + "readonly": false + }, + { + "__type__": "cc.Node", + "_name": "3D Camera", + "_objFlags": 0, + "_parent": null, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 2 + } + ], + "_prefab": { + "__id__": 3 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 10, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Camera", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "_cullingMask": 4294967295, + "_clearFlags": 6, + "_backgroundColor": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_depth": 0, + "_zoomRatio": 1, + "_targetTexture": null, + "_fov": 60, + "_orthoSize": 10, + "_nearClip": 1, + "_farClip": 1024, + "_ortho": false, + "_rect": { + "__type__": "cc.Rect", + "x": 0, + "y": 0, + "width": 1, + "height": 1 + }, + "_renderStages": 1, + "_alignWithScreen": false, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "70d7cdb0-04cd-41bb-9480-c06a4785f386" + }, + "fileId": "abdJ5/jGlPzq+iDQghzEti", + "sync": false + } +] \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/71/71561142-4c83-4933-afca-cb7a17f67053.json b/Layered_virtual_list_2.x/library/imports/71/71561142-4c83-4933-afca-cb7a17f67053.json new file mode 100644 index 0000000..e7522d6 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/71/71561142-4c83-4933-afca-cb7a17f67053.json @@ -0,0 +1,4 @@ +{ + "__type__": "cc.Texture2D", + "content": "0,9729,9729,33071,33071,0,0,1" +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/71/71561142-4c83-4933-afca-cb7a17f67053.png b/Layered_virtual_list_2.x/library/imports/71/71561142-4c83-4933-afca-cb7a17f67053.png new file mode 100644 index 0000000..a3f2d16 Binary files /dev/null and b/Layered_virtual_list_2.x/library/imports/71/71561142-4c83-4933-afca-cb7a17f67053.png differ diff --git a/Layered_virtual_list_2.x/library/imports/71/7168db62-0edc-42e5-be5d-682cf6c4a165.json b/Layered_virtual_list_2.x/library/imports/71/7168db62-0edc-42e5-be5d-682cf6c4a165.json new file mode 100644 index 0000000..bae6ef0 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/71/7168db62-0edc-42e5-be5d-682cf6c4a165.json @@ -0,0 +1,28 @@ +{ + "__type__": "cc.SpriteFrame", + "content": { + "name": "default_toggle_disabled", + "texture": "c25b9d50-c8fc-4d27-beeb-6e7c1f2e5c0f", + "atlas": "", + "rect": [ + 0, + 0, + 28, + 28 + ], + "offset": [ + 0, + 0 + ], + "originalSize": [ + 28, + 28 + ], + "capInsets": [ + 0, + 0, + 0, + 0 + ] + } +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/73/73a0903d-d80e-4e3c-aa67-f999543c08f5.json b/Layered_virtual_list_2.x/library/imports/73/73a0903d-d80e-4e3c-aa67-f999543c08f5.json new file mode 100644 index 0000000..e7522d6 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/73/73a0903d-d80e-4e3c-aa67-f999543c08f5.json @@ -0,0 +1,4 @@ +{ + "__type__": "cc.Texture2D", + "content": "0,9729,9729,33071,33071,0,0,1" +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/73/73a0903d-d80e-4e3c-aa67-f999543c08f5.png b/Layered_virtual_list_2.x/library/imports/73/73a0903d-d80e-4e3c-aa67-f999543c08f5.png new file mode 100644 index 0000000..a0985fc Binary files /dev/null and b/Layered_virtual_list_2.x/library/imports/73/73a0903d-d80e-4e3c-aa67-f999543c08f5.png differ diff --git a/Layered_virtual_list_2.x/library/imports/75/75120702-79b9-4d8a-9e06-0ab82828c5ba.json b/Layered_virtual_list_2.x/library/imports/75/75120702-79b9-4d8a-9e06-0ab82828c5ba.json new file mode 100644 index 0000000..768f631 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/75/75120702-79b9-4d8a-9e06-0ab82828c5ba.json @@ -0,0 +1,1002 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "showNodeH", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "asyncLoadAssets": false, + "readonly": false + }, + { + "__type__": "cc.Node", + "_name": "showNodeH", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + }, + { + "__id__": 7 + }, + { + "__id__": 11 + }, + { + "__id__": 23 + } + ], + "_active": true, + "_components": [ + { + "__id__": 27 + }, + { + "__id__": 28 + } + ], + "_prefab": { + "__id__": 29 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 750, + "height": 1334 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 1 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 375, + 1334, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bg", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 3 + }, + { + "__id__": 4 + }, + { + "__id__": 5 + } + ], + "_prefab": { + "__id__": 6 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 48, + "g": 147, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 750, + "height": 1334 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + -667, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "alignMode": 2, + "_target": null, + "_alignFlags": 45, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 100, + "_originalHeight": 100, + "_id": "" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "renderLayer": null, + "renderZIndex": 0, + "syncInv": 0.01, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "75120702-79b9-4d8a-9e06-0ab82828c5ba" + }, + "fileId": "2fWAV/kSxKbLNNotfg0pAI", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "nameLb", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 8 + }, + { + "__id__": 9 + } + ], + "_prefab": { + "__id__": 10 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 40, + "height": 160 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + -91.236, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 7 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_string": "我是第1", + "_N$string": "我是第1", + "_fontSize": 40, + "_lineHeight": 40, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_styleFlags": 0, + "_underlineHeight": 0, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 3, + "_N$cacheMode": 2, + "_id": "" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 7 + }, + "_enabled": true, + "renderLayer": null, + "renderZIndex": 1, + "syncInv": 0.01, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "75120702-79b9-4d8a-9e06-0ab82828c5ba" + }, + "fileId": "50Nr1a5SVMCLPTFU4WTSCP", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "New Button", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 12 + }, + { + "__id__": 17 + } + ], + "_active": true, + "_components": [ + { + "__id__": 21 + } + ], + "_prefab": { + "__id__": 22 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + -200.564, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Background", + "_objFlags": 0, + "_parent": { + "__id__": 11 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 13 + }, + { + "__id__": 14 + }, + { + "__id__": 15 + } + ], + "_prefab": { + "__id__": 16 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 0 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 12 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952" + }, + "_type": 1, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 12 + }, + "_enabled": true, + "alignMode": 0, + "_target": null, + "_alignFlags": 45, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 100, + "_originalHeight": 40, + "_id": "" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 12 + }, + "_enabled": true, + "renderLayer": null, + "renderZIndex": 0, + "syncInv": 0.01, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "75120702-79b9-4d8a-9e06-0ab82828c5ba" + }, + "fileId": "b2yBk+BHFOF7B8n1gYypgp", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "Label", + "_objFlags": 0, + "_parent": { + "__id__": 11 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 18 + }, + { + "__id__": 19 + } + ], + "_prefab": { + "__id__": 20 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 17 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_string": "button", + "_N$string": "button", + "_fontSize": 20, + "_lineHeight": 40, + "_enableWrapText": false, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_styleFlags": 0, + "_underlineHeight": 0, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 1, + "_N$cacheMode": 2, + "_id": "" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 17 + }, + "_enabled": true, + "renderLayer": null, + "renderZIndex": 1, + "syncInv": 0.01, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "75120702-79b9-4d8a-9e06-0ab82828c5ba" + }, + "fileId": "78ZrwHpmZIaZAh4fh1OXyZ", + "sync": false + }, + { + "__type__": "cc.Button", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 11 + }, + "_enabled": true, + "_normalMaterial": null, + "_grayMaterial": null, + "duration": 0.1, + "zoomScale": 1.2, + "clickEvents": [], + "_N$interactable": true, + "_N$enableAutoGrayEffect": false, + "_N$transition": 3, + "transition": 3, + "_N$normalColor": { + "__type__": "cc.Color", + "r": 230, + "g": 230, + "b": 230, + "a": 255 + }, + "_N$pressedColor": { + "__type__": "cc.Color", + "r": 200, + "g": 200, + "b": 200, + "a": 255 + }, + "pressedColor": { + "__type__": "cc.Color", + "r": 200, + "g": 200, + "b": 200, + "a": 255 + }, + "_N$hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$disabledColor": { + "__type__": "cc.Color", + "r": 120, + "g": 120, + "b": 120, + "a": 200 + }, + "_N$normalSprite": { + "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952" + }, + "_N$pressedSprite": { + "__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a" + }, + "pressedSprite": { + "__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a" + }, + "_N$hoverSprite": { + "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952" + }, + "hoverSprite": { + "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952" + }, + "_N$disabledSprite": { + "__uuid__": "29158224-f8dd-4661-a796-1ffab537140e" + }, + "_N$target": { + "__id__": 12 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "75120702-79b9-4d8a-9e06-0ab82828c5ba" + }, + "fileId": "14TO6K8WlMjp8gwgtWA0qf", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "contentLb", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 24 + }, + { + "__id__": 25 + } + ], + "_prefab": { + "__id__": 26 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 40, + "height": 440 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + -466.093, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 23 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_string": "ScrollView content", + "_N$string": "ScrollView content", + "_fontSize": 40, + "_lineHeight": 40, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_styleFlags": 0, + "_underlineHeight": 0, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 3, + "_N$cacheMode": 2, + "_id": "" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 23 + }, + "_enabled": true, + "renderLayer": null, + "renderZIndex": 1, + "syncInv": 0.01, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "75120702-79b9-4d8a-9e06-0ab82828c5ba" + }, + "fileId": "41ShEz5VJCm68duiIf01ZR", + "sync": false + }, + { + "__type__": "9e178M6rUlI5qgi1+HcLO30", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "renderAlternatives": [ + { + "__id__": 3 + }, + { + "__id__": 13 + } + ], + "nameLb": { + "__id__": 8 + }, + "contentLb": { + "__id__": 24 + }, + "Button": { + "__id__": 11 + }, + "ButtonLb": { + "__id__": 18 + }, + "_id": "" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "alignMode": 2, + "_target": null, + "_alignFlags": 45, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 750, + "_originalHeight": 100, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "75120702-79b9-4d8a-9e06-0ab82828c5ba" + }, + "fileId": "", + "sync": false + } +] \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/78/785a442c-3ceb-45be-a46e-7317f625f3b9.json b/Layered_virtual_list_2.x/library/imports/78/785a442c-3ceb-45be-a46e-7317f625f3b9.json new file mode 100644 index 0000000..552ef35 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/78/785a442c-3ceb-45be-a46e-7317f625f3b9.json @@ -0,0 +1,150 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "layout", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 1, + "asyncLoadAssets": false, + "readonly": false + }, + { + "__type__": "cc.Node", + "_name": "layout", + "_objFlags": 0, + "_parent": null, + "_children": [], + "_active": true, + "_level": 1, + "_components": [ + { + "__id__": 2 + }, + { + "__id__": 3 + } + ], + "_prefab": { + "__id__": 4 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 200, + "height": 150 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_skewX": 0, + "_skewY": 0, + "_localZOrder": 23, + "groupIndex": 0, + "_id": "", + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "9bbda31e-ad49-43c9-aaf2-f7d9896bac69" + }, + "_type": 1, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_state": 0, + "_atlas": null, + "_id": "2ahobdsPRNsqLW+QOpm+dP" + }, + { + "__type__": "cc.Layout", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "_layoutSize": { + "__type__": "cc.Size", + "width": 200, + "height": 150 + }, + "_resize": 0, + "_N$layoutType": 0, + "_N$padding": 0, + "_N$cellSize": { + "__type__": "cc.Size", + "width": 40, + "height": 40 + }, + "_N$startAxis": 0, + "_N$paddingLeft": 0, + "_N$paddingRight": 0, + "_N$paddingTop": 0, + "_N$paddingBottom": 0, + "_N$spacingX": 0, + "_N$spacingY": 0, + "_N$verticalDirection": 1, + "_N$horizontalDirection": 0, + "_id": "bfIqKhkQ5DR4a9m9sj/AzV" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "785a442c-3ceb-45be-a46e-7317f625f3b9" + }, + "fileId": "7f8d2O3hcNDT55RjJXZrQyg", + "sync": false + } +] \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/7a/7a17de6e-227a-46b1-8009-e7157d4d3acf.bin b/Layered_virtual_list_2.x/library/imports/7a/7a17de6e-227a-46b1-8009-e7157d4d3acf.bin new file mode 100644 index 0000000..785c0a9 Binary files /dev/null and b/Layered_virtual_list_2.x/library/imports/7a/7a17de6e-227a-46b1-8009-e7157d4d3acf.bin differ diff --git a/Layered_virtual_list_2.x/library/imports/7a/7a17de6e-227a-46b1-8009-e7157d4d3acf.json b/Layered_virtual_list_2.x/library/imports/7a/7a17de6e-227a-46b1-8009-e7157d4d3acf.json new file mode 100644 index 0000000..aa843a8 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/7a/7a17de6e-227a-46b1-8009-e7157d4d3acf.json @@ -0,0 +1,90 @@ +[ + { + "__type__": "cc.Mesh", + "_name": "", + "_objFlags": 0, + "_native": ".bin", + "_vertexBundles": [ + { + "__id__": 1 + } + ], + "_primitives": [ + { + "__id__": 6 + } + ], + "_minPos": { + "__type__": "cc.Vec3", + "x": -0.5, + "y": -0.5, + "z": -0.499999940395355 + }, + "_maxPos": { + "__type__": "cc.Vec3", + "x": 0.5, + "y": 0.5, + "z": 0.5 + } + }, + { + "__type__": "cc.mesh.VertexBundle", + "data": { + "__id__": 2 + }, + "formats": [ + { + "__id__": 3 + }, + { + "__id__": 4 + }, + { + "__id__": 5 + } + ], + "verticesCount": 129 + }, + { + "__type__": "cc.BufferRange", + "offset": 0, + "length": 4128 + }, + { + "__type__": "cc.mesh.VertexFormat", + "name": "a_normal", + "type": 5126, + "num": 3, + "normalize": false + }, + { + "__type__": "cc.mesh.VertexFormat", + "name": "a_position", + "type": 5126, + "num": 3, + "normalize": false + }, + { + "__type__": "cc.mesh.VertexFormat", + "name": "a_uv0", + "type": 5126, + "num": 2, + "normalize": false + }, + { + "__type__": "cc.mesh.Primitive", + "vertexBundleIndices": [ + 0 + ], + "data": { + "__id__": 7 + }, + "indexUnit": 5123, + "topology": 4 + }, + { + "__type__": "cc.BufferRange", + "offset": 4128, + "length": 384 + } +] \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/7a/7afd064b-113f-480e-b793-8817d19f63c3.json b/Layered_virtual_list_2.x/library/imports/7a/7afd064b-113f-480e-b793-8817d19f63c3.json new file mode 100644 index 0000000..2afdc94 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/7a/7afd064b-113f-480e-b793-8817d19f63c3.json @@ -0,0 +1,10 @@ +{ + "__type__": "cc.Material", + "_name": "builtin-2d-spine", + "_objFlags": 0, + "_native": "", + "_effectAsset": { + "__uuid__": "0e93aeaa-0b53-4e40-b8e0-6268b4e07bd7" + }, + "_techniqueData": {} +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/7d/7d4ffd94-42d6-4045-9db7-a744229adfc4.json b/Layered_virtual_list_2.x/library/imports/7d/7d4ffd94-42d6-4045-9db7-a744229adfc4.json new file mode 100644 index 0000000..e8aecc3 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/7d/7d4ffd94-42d6-4045-9db7-a744229adfc4.json @@ -0,0 +1,28 @@ +{ + "__type__": "cc.SpriteFrame", + "content": { + "name": "default_toggle_pressed", + "texture": "b181c1e4-0a72-4a91-bfb0-ae6f36ca60bd", + "atlas": "", + "rect": [ + 0, + 0, + 28, + 28 + ], + "offset": [ + 0, + 0 + ], + "originalSize": [ + 28, + 28 + ], + "capInsets": [ + 0, + 0, + 0, + 0 + ] + } +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/7d/7de03a80-4457-438d-95a7-3e7cdffd6086.json b/Layered_virtual_list_2.x/library/imports/7d/7de03a80-4457-438d-95a7-3e7cdffd6086.json new file mode 100644 index 0000000..9ceb3f2 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/7d/7de03a80-4457-438d-95a7-3e7cdffd6086.json @@ -0,0 +1,96 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "tiledmap", + "_objFlags": 0, + "data": { + "__id__": 1 + }, + "optimizationPolicy": 1, + "asyncLoadAssets": false, + "readonly": false + }, + { + "__type__": "cc.Node", + "_name": "New TiledMap", + "_objFlags": 0, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_cascadeOpacityEnabled": true, + "_parent": null, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_children": [], + "_skewX": 0, + "_skewY": 0, + "_localZOrder": 0, + "_globalZOrder": 0, + "_tag": -1, + "_opacityModifyRGB": false, + "_reorderChildDirty": false, + "_id": "", + "_active": true, + "_components": [ + { + "__id__": 2 + } + ], + "_prefab": { + "__id__": 3 + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.TiledMap", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "_tmxFile": null + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": null, + "fileId": "6d9cbIJlHhJ/4JAwDJiN9SB" + } +] \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/7e/7e1f6966-c75d-4786-8f41-355dcca8a919.js b/Layered_virtual_list_2.x/library/imports/7e/7e1f6966-c75d-4786-8f41-355dcca8a919.js new file mode 100644 index 0000000..9ee1bcf --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/7e/7e1f6966-c75d-4786-8f41-355dcca8a919.js @@ -0,0 +1,77 @@ +"use strict"; +cc._RF.push(module, '7e1f6lmx11Hho9BNV3MqKkZ', 'Item'); +// Scene/Item.ts + +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var RenderAlternativeItem_1 = require("../Script/RenderAlternativeItem"); +var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property; +var Item = /** @class */ (function (_super) { + __extends(Item, _super); + function Item() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /** */ + _this.nameLb = null; + /** */ + _this.contentLb = null; + /** */ + _this.Button = null; + /** */ + _this.ButtonLb = null; + _this.data = null; + return _this; + // update (dt) {} + } + Item.prototype.init = function (data) { + this.data = data.data; + var layer = data.layer; + this.initRenderLayer(layer); + this.initShow(); + }; + /** + * 初始化显示 + * @param data + */ + Item.prototype.initShow = function () { + this.nameLb.string = "我是第" + this.data.index + "个"; + this.contentLb.string = "我是内容" + this.data.name; + }; + __decorate([ + property(cc.Label) + ], Item.prototype, "nameLb", void 0); + __decorate([ + property(cc.Label) + ], Item.prototype, "contentLb", void 0); + __decorate([ + property(cc.Node) + ], Item.prototype, "Button", void 0); + __decorate([ + property(cc.Label) + ], Item.prototype, "ButtonLb", void 0); + Item = __decorate([ + ccclass + ], Item); + return Item; +}(RenderAlternativeItem_1.default)); +exports.default = Item; + +cc._RF.pop(); \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/7e/7e1f6966-c75d-4786-8f41-355dcca8a919.js.map b/Layered_virtual_list_2.x/library/imports/7e/7e1f6966-c75d-4786-8f41-355dcca8a919.js.map new file mode 100644 index 0000000..55c1fe7 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/7e/7e1f6966-c75d-4786-8f41-355dcca8a919.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["assets\\Scene\\Item.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yEAAoE;AAG9D,IAAA,KAAwB,EAAE,CAAC,UAAU,EAAnC,OAAO,aAAA,EAAE,QAAQ,cAAkB,CAAC;AAG5C;IAAkC,wBAAqB;IAAvD;QAAA,qEAkCC;QAhCG,MAAM;QAEC,YAAM,GAAa,IAAI,CAAC;QAC/B,MAAM;QAEC,eAAS,GAAa,IAAI,CAAC;QAClC,MAAM;QAEC,YAAM,GAAY,IAAI,CAAC;QAC9B,MAAM;QAEC,cAAQ,GAAa,IAAI,CAAC;QAEjC,UAAI,GAAQ,IAAI,CAAC;;QAkBjB,iBAAiB;IACrB,CAAC;IAjBG,mBAAI,GAAJ,UAAK,IAAS;QACV,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACtB,IAAI,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACvB,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;QAC5B,IAAI,CAAC,QAAQ,EAAE,CAAC;IACpB,CAAC;IAED;;;OAGG;IACH,uBAAQ,GAAR;QACI,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC;QACnD,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;IACpD,CAAC;IA3BD;QADC,QAAQ,CAAC,EAAE,CAAC,KAAK,CAAC;wCACY;IAG/B;QADC,QAAQ,CAAC,EAAE,CAAC,KAAK,CAAC;2CACe;IAGlC;QADC,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC;wCACY;IAG9B;QADC,QAAQ,CAAC,EAAE,CAAC,KAAK,CAAC;0CACc;IAbhB,IAAI;QADxB,OAAO;OACa,IAAI,CAkCxB;IAAD,WAAC;CAlCD,AAkCC,CAlCiC,+BAAqB,GAkCtD;kBAlCoB,IAAI","file":"","sourceRoot":"/","sourcesContent":["import RenderAlternativeItem from \"../Script/RenderAlternativeItem\";\r\n\r\n\r\nconst { ccclass, property } = cc._decorator;\r\n\r\n@ccclass\r\nexport default class Item extends RenderAlternativeItem {\r\n\r\n /** */\r\n @property(cc.Label)\r\n public nameLb: cc.Label = null;\r\n /** */\r\n @property(cc.Label)\r\n public contentLb: cc.Label = null;\r\n /** */\r\n @property(cc.Node)\r\n public Button: cc.Node = null;\r\n /** */\r\n @property(cc.Label)\r\n public ButtonLb: cc.Label = null;\r\n\r\n data: any = null;\r\n\r\n init(data: any) {\r\n this.data = data.data;\r\n let layer = data.layer;\r\n this.initRenderLayer(layer);\r\n this.initShow();\r\n }\r\n\r\n /**\r\n * 初始化显示\r\n * @param data \r\n */\r\n initShow() {\r\n this.nameLb.string = \"我是第\" + this.data.index + \"个\";\r\n this.contentLb.string = \"我是内容\" + this.data.name;\r\n }\r\n\r\n // update (dt) {}\r\n}\r\n"]} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/82/829a282c-b049-4019-bd38-5ace8d8a6417.json b/Layered_virtual_list_2.x/library/imports/82/829a282c-b049-4019-bd38-5ace8d8a6417.json new file mode 100644 index 0000000..acc059c --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/82/829a282c-b049-4019-bd38-5ace8d8a6417.json @@ -0,0 +1,939 @@ +{ + "__type__": "cc.EffectAsset", + "_name": "builtin-3d-particle", + "_objFlags": 0, + "_native": "", + "properties": null, + "techniques": [ + { + "name": "opaque-add", + "passes": [ + { + "stage": "opaque", + "rasterizerState": { + "cullMode": 0 + }, + "blendState": { + "targets": [ + { + "blend": true, + "blendSrc": 770, + "blendDst": 1, + "blendSrcAlpha": 770, + "blendDstAlpha": 1 + } + ] + }, + "depthStencilState": { + "depthTest": true, + "depthWrite": false + }, + "properties": { + "mainTexture": { + "value": "grey", + "type": 29 + }, + "mainTiling_Offset": { + "value": [ + 1, + 1, + 0, + 0 + ], + "type": 16 + }, + "tintColor": { + "value": [ + 0.5, + 0.5, + 0.5, + 0.5 + ], + "inspector": { + "type": "color" + }, + "type": 16 + } + }, + "program": "builtin-3d-particle|particle-vs-legacy:lpvs_main|tinted-fs:add" + } + ] + }, + { + "name": "opaque-alpha-blend", + "passes": [ + { + "stage": "opaque", + "rasterizerState": { + "cullMode": 0 + }, + "blendState": { + "targets": [ + { + "blend": true, + "blendSrc": 770, + "blendDst": 771, + "blendSrcAlpha": 770, + "blendDstAlpha": 771 + } + ] + }, + "depthStencilState": { + "depthTest": true, + "depthWrite": false + }, + "properties": { + "mainTexture": { + "value": "grey", + "type": 29 + }, + "mainTiling_Offset": { + "value": [ + 1, + 1, + 0, + 0 + ], + "type": 16 + }, + "tintColor": { + "value": [ + 0.5, + 0.5, + 0.5, + 0.5 + ], + "inspector": { + "type": "color" + }, + "type": 16 + } + }, + "program": "builtin-3d-particle|particle-vs-legacy:lpvs_main|tinted-fs:add" + } + ] + }, + { + "name": "opaque-add-multiply", + "passes": [ + { + "stage": "opaque", + "rasterizerState": { + "cullMode": 0 + }, + "blendState": { + "targets": [ + { + "blend": true, + "blendSrc": 770, + "blendDst": 771, + "blendSrcAlpha": 770, + "blendDstAlpha": 771 + } + ] + }, + "depthStencilState": { + "depthTest": true, + "depthWrite": false + }, + "properties": { + "mainTexture": { + "value": "grey", + "type": 29 + }, + "mainTiling_Offset": { + "value": [ + 1, + 1, + 0, + 0 + ], + "type": 16 + }, + "tintColor": { + "value": [ + 0.5, + 0.5, + 0.5, + 0.5 + ], + "inspector": { + "type": "color" + }, + "type": 16 + } + }, + "program": "builtin-3d-particle|particle-vs-legacy:lpvs_main|tinted-fs:multiply" + } + ] + }, + { + "name": "opaque-add-smooth", + "passes": [ + { + "stage": "opaque", + "rasterizerState": { + "cullMode": 0 + }, + "blendState": { + "targets": [ + { + "blend": true, + "blendSrc": 770, + "blendDst": 771, + "blendSrcAlpha": 770, + "blendDstAlpha": 771 + } + ] + }, + "depthStencilState": { + "depthTest": true, + "depthWrite": false + }, + "properties": { + "mainTexture": { + "value": "grey", + "type": 29 + }, + "mainTiling_Offset": { + "value": [ + 1, + 1, + 0, + 0 + ], + "type": 16 + } + }, + "program": "builtin-3d-particle|particle-vs-legacy:lpvs_main|no-tint-fs:addSmooth" + } + ] + }, + { + "name": "opaque-premultiply-blend", + "passes": [ + { + "stage": "opaque", + "rasterizerState": { + "cullMode": 0 + }, + "blendState": { + "targets": [ + { + "blend": true, + "blendSrc": 770, + "blendDst": 771, + "blendSrcAlpha": 770, + "blendDstAlpha": 771 + } + ] + }, + "depthStencilState": { + "depthTest": true, + "depthWrite": false + }, + "properties": { + "mainTexture": { + "value": "grey", + "type": 29 + }, + "mainTiling_Offset": { + "value": [ + 1, + 1, + 0, + 0 + ], + "type": 16 + } + }, + "program": "builtin-3d-particle|particle-vs-legacy:lpvs_main|no-tint-fs:premultiplied" + } + ] + }, + { + "name": "transparent-add", + "passes": [ + { + "stage": "transparent", + "rasterizerState": { + "cullMode": 0 + }, + "blendState": { + "targets": [ + { + "blend": true, + "blendSrc": 770, + "blendDst": 1, + "blendSrcAlpha": 770, + "blendDstAlpha": 1 + } + ] + }, + "depthStencilState": { + "depthTest": true, + "depthWrite": false + }, + "properties": { + "mainTexture": { + "value": "grey", + "type": 29 + }, + "mainTiling_Offset": { + "value": [ + 1, + 1, + 0, + 0 + ], + "type": 16 + }, + "tintColor": { + "value": [ + 0.5, + 0.5, + 0.5, + 0.5 + ], + "inspector": { + "type": "color" + }, + "type": 16 + } + }, + "program": "builtin-3d-particle|particle-vs-legacy:lpvs_main|tinted-fs:add" + } + ] + }, + { + "name": "transparent-alpha-blend", + "passes": [ + { + "stage": "transparent", + "rasterizerState": { + "cullMode": 0 + }, + "blendState": { + "targets": [ + { + "blend": true, + "blendSrc": 770, + "blendDst": 771, + "blendSrcAlpha": 770, + "blendDstAlpha": 771 + } + ] + }, + "depthStencilState": { + "depthTest": true, + "depthWrite": false + }, + "properties": { + "mainTexture": { + "value": "grey", + "type": 29 + }, + "mainTiling_Offset": { + "value": [ + 1, + 1, + 0, + 0 + ], + "type": 16 + }, + "tintColor": { + "value": [ + 0.5, + 0.5, + 0.5, + 0.5 + ], + "inspector": { + "type": "color" + }, + "type": 16 + } + }, + "program": "builtin-3d-particle|particle-vs-legacy:lpvs_main|tinted-fs:add" + } + ] + }, + { + "name": "transparent-add-multiply", + "passes": [ + { + "stage": "transparent", + "rasterizerState": { + "cullMode": 0 + }, + "blendState": { + "targets": [ + { + "blend": true, + "blendSrc": 770, + "blendDst": 771, + "blendSrcAlpha": 770, + "blendDstAlpha": 771 + } + ] + }, + "depthStencilState": { + "depthTest": true, + "depthWrite": false + }, + "properties": { + "mainTexture": { + "value": "grey", + "type": 29 + }, + "mainTiling_Offset": { + "value": [ + 1, + 1, + 0, + 0 + ], + "type": 16 + }, + "tintColor": { + "value": [ + 0.5, + 0.5, + 0.5, + 0.5 + ], + "inspector": { + "type": "color" + }, + "type": 16 + } + }, + "program": "builtin-3d-particle|particle-vs-legacy:lpvs_main|tinted-fs:multiply" + } + ] + }, + { + "name": "transparent-add-smooth", + "passes": [ + { + "stage": "transparent", + "rasterizerState": { + "cullMode": 0 + }, + "blendState": { + "targets": [ + { + "blend": true, + "blendSrc": 770, + "blendDst": 771, + "blendSrcAlpha": 770, + "blendDstAlpha": 771 + } + ] + }, + "depthStencilState": { + "depthTest": true, + "depthWrite": false + }, + "properties": { + "mainTexture": { + "value": "grey", + "type": 29 + }, + "mainTiling_Offset": { + "value": [ + 1, + 1, + 0, + 0 + ], + "type": 16 + } + }, + "program": "builtin-3d-particle|particle-vs-legacy:lpvs_main|no-tint-fs:addSmooth" + } + ] + }, + { + "name": "transparent-premultiply-blend", + "passes": [ + { + "stage": "transparent", + "rasterizerState": { + "cullMode": 0 + }, + "blendState": { + "targets": [ + { + "blend": true, + "blendSrc": 770, + "blendDst": 771, + "blendSrcAlpha": 770, + "blendDstAlpha": 771 + } + ] + }, + "depthStencilState": { + "depthTest": true, + "depthWrite": false + }, + "properties": { + "mainTexture": { + "value": "grey", + "type": 29 + }, + "mainTiling_Offset": { + "value": [ + 1, + 1, + 0, + 0 + ], + "type": 16 + } + }, + "program": "builtin-3d-particle|particle-vs-legacy:lpvs_main|no-tint-fs:premultiplied" + } + ] + } + ], + "shaders": [ + { + "hash": 1682193167, + "glsl3": { + "vert": "\nprecision highp float;\nvec4 quaternionFromAxis(vec3 xAxis,vec3 yAxis,vec3 zAxis){\n mat3 m = mat3(xAxis,yAxis,zAxis);\n float trace = m[0][0] + m[1][1] + m[2][2];\n vec4 quat;\n if (trace > 0.) {\n float s = 0.5 / sqrt(trace + 1.0);\n quat.w = 0.25 / s;\n quat.x = (m[2][1] - m[1][2]) * s;\n quat.y = (m[0][2] - m[2][0]) * s;\n quat.z = (m[1][0] - m[0][1]) * s;\n } else if ((m[0][0] > m[1][1]) && (m[0][0] > m[2][2])) {\n float s = 2.0 * sqrt(1.0 + m[0][0] - m[1][1] - m[2][2]);\n quat.w = (m[2][1] - m[1][2]) / s;\n quat.x = 0.25 * s;\n quat.y = (m[0][1] + m[1][0]) / s;\n quat.z = (m[0][2] + m[2][0]) / s;\n } else if (m[1][1] > m[2][2]) {\n float s = 2.0 * sqrt(1.0 + m[1][1] - m[0][0] - m[2][2]);\n quat.w = (m[0][2] - m[2][0]) / s;\n quat.x = (m[0][1] + m[1][0]) / s;\n quat.y = 0.25 * s;\n quat.z = (m[1][2] + m[2][1]) / s;\n } else {\n float s = 2.0 * sqrt(1.0 + m[2][2] - m[0][0] - m[1][1]);\n quat.w = (m[1][0] - m[0][1]) / s;\n quat.x = (m[0][2] + m[2][0]) / s;\n quat.y = (m[1][2] + m[2][1]) / s;\n quat.z = 0.25 * s;\n }\n float len = quat.x * quat.x + quat.y * quat.y + quat.z * quat.z + quat.w * quat.w;\n if (len > 0.) {\n len = 1. / sqrt(len);\n quat.x = quat.x * len;\n quat.y = quat.y * len;\n quat.z = quat.z * len;\n quat.w = quat.w * len;\n }\n return quat;\n}\nvec4 quaternionFromEuler(vec3 angle){\n float x = angle.x / 2.;\n float y = angle.y / 2.;\n float z = angle.z / 2.;\n float sx = sin(x);\n float cx = cos(x);\n float sy = sin(y);\n float cy = cos(y);\n float sz = sin(z);\n float cz = cos(z);\n vec4 quat = vec4(0);\n quat.x = sx * cy * cz + cx * sy * sz;\n quat.y = cx * sy * cz + sx * cy * sz;\n quat.z = cx * cy * sz - sx * sy * cz;\n quat.w = cx * cy * cz - sx * sy * sz;\n return quat;\n}\nmat4 matrixFromRT(vec4 q, vec3 p){\n float x2 = q.x + q.x;\n float y2 = q.y + q.y;\n float z2 = q.z + q.z;\n float xx = q.x * x2;\n float xy = q.x * y2;\n float xz = q.x * z2;\n float yy = q.y * y2;\n float yz = q.y * z2;\n float zz = q.z * z2;\n float wx = q.w * x2;\n float wy = q.w * y2;\n float wz = q.w * z2;\n return mat4(\n 1. - (yy + zz), xy + wz, xz - wy, 0,\n xy - wz, 1. - (xx + zz), yz + wx, 0,\n xz + wy, yz - wx, 1. - (xx + yy), 0,\n p.x, p.y, p.z, 1\n );\n}\nmat4 matFromRTS(vec4 q, vec3 t, vec3 s){\n float x = q.x, y = q.y, z = q.z, w = q.w;\n float x2 = x + x;\n float y2 = y + y;\n float z2 = z + z;\n float xx = x * x2;\n float xy = x * y2;\n float xz = x * z2;\n float yy = y * y2;\n float yz = y * z2;\n float zz = z * z2;\n float wx = w * x2;\n float wy = w * y2;\n float wz = w * z2;\n float sx = s.x;\n float sy = s.y;\n float sz = s.z;\n return mat4((1. - (yy + zz)) * sx, (xy + wz) * sx, (xz - wy) * sx, 0,\n (xy - wz) * sy, (1. - (xx + zz)) * sy, (yz + wx) * sy, 0,\n (xz + wy) * sz, (yz - wx) * sz, (1. - (xx + yy)) * sz, 0,\n t.x, t.y, t.z, 1);\n}\nvec4 quatMultiply(vec4 a, vec4 b){\n vec4 quat;\n quat.x = a.x * b.w + a.w * b.x + a.y * b.z - a.z * b.y;\n quat.y = a.y * b.w + a.w * b.y + a.z * b.x - a.x * b.z;\n quat.z = a.z * b.w + a.w * b.z + a.x * b.y - a.y * b.x;\n quat.w = a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z;\n return quat;\n}\nvoid rotateVecFromQuat(inout vec3 v, vec4 q){\n float ix = q.w * v.x + q.y * v.z - q.z * v.y;\n float iy = q.w * v.y + q.z * v.x - q.x * v.z;\n float iz = q.w * v.z + q.x * v.y - q.y * v.x;\n float iw = -q.x * v.x - q.y * v.y - q.z * v.z;\n v.x = ix * q.w + iw * -q.x + iy * -q.z - iz * -q.y;\n v.y = iy * q.w + iw * -q.y + iz * -q.x - ix * -q.z;\n v.z = iz * q.w + iw * -q.z + ix * -q.y - iy * -q.x;\n}\nvec3 rotateInLocalSpace(vec3 pos, vec3 xAxis, vec3 yAxis, vec3 zAxis, vec4 q){\n float z = pos.z;\n float x = pos.x;\n float y = pos.y;\n vec4 viewQuat = quaternionFromAxis(xAxis, yAxis, zAxis);\n vec4 rotQuat = quatMultiply(viewQuat, q);\n rotateVecFromQuat(pos, rotQuat);\n return pos;\n}\nvoid rotateCorner(inout vec2 corner, float angle){\n float xOS = cos(angle) * corner.x - sin(angle) * corner.y;\n float yOS = sin(angle) * corner.x + cos(angle) * corner.y;\n corner.x = xOS;\n corner.y = yOS;\n}\nuniform Constants{\n vec4 mainTiling_Offset;\n vec4 frameTile_velLenScale;\n vec4 scale;\n};\nuniform CCGlobal {\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\nuniform CCLocal {\n mat4 cc_matWorld;\n mat4 cc_matWorldIT;\n};\nout vec2 uv;\nout vec4 color;\nvoid computeVertPos(inout vec4 pos, vec2 vertOffset, vec4 q, vec3 s\n#if CC_USE_BILLBOARD || CC_USE_VERTICAL_BILLBOARD\n , mat4 viewInv\n#endif\n#if CC_USE_STRETCHED_BILLBOARD\n , vec3 eye\n , vec4 velocity\n , float velocityScale\n , float lengthScale\n , float xIndex\n#endif\n) {\n#if CC_USE_BILLBOARD\n vec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\n vec3 camX = normalize(vec3(viewInv[0][0], viewInv[1][0], viewInv[2][0]));\n vec3 camY = normalize(vec3(viewInv[0][1], viewInv[1][1], viewInv[2][1]));\n vec3 camZ = normalize(vec3(viewInv[0][2], viewInv[1][2], viewInv[2][2]));\n pos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, camZ, q);\n#elif CC_USE_STRETCHED_BILLBOARD\n vec3 camRight = normalize(cross(pos.xyz - eye, velocity.xyz)) * s.x;\n vec3 camUp = velocity.xyz * velocityScale + normalize(velocity.xyz) * lengthScale * s.y;\n pos.xyz += (camRight * abs(vertOffset.x) * sign(vertOffset.y)) - camUp * xIndex;\n#elif CC_USE_HORIZONTAL_BILLBOARD\n vec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\n vec3 camX = vec3(1, 0, 0);\n vec3 camY = vec3(0, 0, -1);\n pos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, cross(camX, camY), q);\n#elif CC_USE_VERTICAL_BILLBOARD\n vec2 viewSpaceVert = vec2(vertOffset.x * s.x, vertOffset.y * s.y);\n rotateCorner(viewSpaceVert, q.z);\n vec3 camX = normalize(vec3(cc_matView[0][0], cc_matView[1][0], cc_matView[2][0]));\n vec3 camY = vec3(0, 1, 0);\n vec3 offset = camX * viewSpaceVert.x + camY * viewSpaceVert.y;\n pos.xyz += offset;\n#else\n pos.x += vertOffset.x;\n pos.y += vertOffset.y;\n#endif\n}\nvec2 computeUV(float frameIndex, vec2 vertIndex, vec2 frameTile){\n vec2 aniUV = vec2(0, floor(frameIndex * frameTile.y));\n aniUV.x = floor(frameIndex * frameTile.x * frameTile.y - aniUV.y * frameTile.x);\n#if !CC_USE_MESH\n vertIndex.y = 1. - vertIndex.y;\n#endif\n return (aniUV.xy + vertIndex) / vec2(frameTile.x, frameTile.y);\n}\nin vec3 a_position;\nin vec3 a_texCoord;\nin vec3 a_texCoord1;\nin vec3 a_texCoord2;\nin vec4 a_color;\n#if CC_USE_STRETCHED_BILLBOARD\n in vec3 a_color1;\n#endif\n#if CC_USE_MESH\n in vec3 a_texCoord3;\n in vec3 a_normal;\n in vec4 a_color1;\n#endif\nvec4 lpvs_main() {\n vec3 compScale = scale.xyz * a_texCoord1;\n vec4 pos = vec4(a_position, 1);\n#if CC_USE_STRETCHED_BILLBOARD\n vec4 velocity = vec4(a_color1.xyz, 0);\n#endif\n#if !CC_USE_WORLD_SPACE\n pos = cc_matWorld * pos;\n #if CC_USE_STRETCHED_BILLBOARD\n velocity = cc_matWorld * velocity;\n #endif\n#endif\n#if !CC_USE_MESH\n vec2 cornerOffset = vec2((a_texCoord.xy - 0.5));\n #if CC_USE_BILLBOARD\n vec3 rotEuler = a_texCoord2;\n #elif CC_USE_STRETCHED_BILLBOARD\n vec3 rotEuler = vec3(0.);\n #else\n vec3 rotEuler = vec3(0., 0., a_texCoord2.z);\n #endif\n computeVertPos(pos, cornerOffset, quaternionFromEuler(rotEuler), compScale\n #if CC_USE_BILLBOARD || CC_USE_VERTICAL_BILLBOARD\n , cc_matViewInv\n #endif\n #if CC_USE_STRETCHED_BILLBOARD\n , cc_cameraPos.xyz\n , velocity\n , frameTile_velLenScale.z\n , frameTile_velLenScale.w\n , a_texCoord.x\n #endif\n );\n color = a_color;\n#else\n mat4 xformNoScale = matrixFromRT(quaternionFromEuler(a_texCoord2), pos.xyz);\n mat4 xform = matFromRTS(quaternionFromEuler(a_texCoord2), pos.xyz, compScale);\n pos = xform * vec4(a_texCoord3, 1);\n vec4 normal = xformNoScale * vec4(a_normal, 0);\n color = a_color * a_color1;\n#endif\n uv = computeUV(a_texCoord.z, a_texCoord.xy, frameTile_velLenScale.xy) * mainTiling_Offset.xy + mainTiling_Offset.zw;\n pos = cc_matViewProj * pos;\n return pos;\n}\nvoid main() { gl_Position = lpvs_main(); }", + "frag": "\nprecision highp float;\nvec4 CCFragOutput (vec4 color) {\n #if OUTPUT_TO_GAMMA\n color.rgb = sqrt(color.rgb);\n #endif\n\treturn color;\n}\nin vec2 uv;\nin vec4 color;\nuniform sampler2D mainTexture;\nuniform FragConstants {\n vec4 tintColor;\n};\nvec4 add () {\n vec4 col = 2.0 * color * tintColor * texture(mainTexture, uv);\n return CCFragOutput(col);\n}\nout vec4 cc_FragColor;\nvoid main() { cc_FragColor = add(); }" + }, + "glsl1": { + "vert": "\nprecision highp float;\nvec4 quaternionFromAxis(vec3 xAxis,vec3 yAxis,vec3 zAxis){\n mat3 m = mat3(xAxis,yAxis,zAxis);\n float trace = m[0][0] + m[1][1] + m[2][2];\n vec4 quat;\n if (trace > 0.) {\n float s = 0.5 / sqrt(trace + 1.0);\n quat.w = 0.25 / s;\n quat.x = (m[2][1] - m[1][2]) * s;\n quat.y = (m[0][2] - m[2][0]) * s;\n quat.z = (m[1][0] - m[0][1]) * s;\n } else if ((m[0][0] > m[1][1]) && (m[0][0] > m[2][2])) {\n float s = 2.0 * sqrt(1.0 + m[0][0] - m[1][1] - m[2][2]);\n quat.w = (m[2][1] - m[1][2]) / s;\n quat.x = 0.25 * s;\n quat.y = (m[0][1] + m[1][0]) / s;\n quat.z = (m[0][2] + m[2][0]) / s;\n } else if (m[1][1] > m[2][2]) {\n float s = 2.0 * sqrt(1.0 + m[1][1] - m[0][0] - m[2][2]);\n quat.w = (m[0][2] - m[2][0]) / s;\n quat.x = (m[0][1] + m[1][0]) / s;\n quat.y = 0.25 * s;\n quat.z = (m[1][2] + m[2][1]) / s;\n } else {\n float s = 2.0 * sqrt(1.0 + m[2][2] - m[0][0] - m[1][1]);\n quat.w = (m[1][0] - m[0][1]) / s;\n quat.x = (m[0][2] + m[2][0]) / s;\n quat.y = (m[1][2] + m[2][1]) / s;\n quat.z = 0.25 * s;\n }\n float len = quat.x * quat.x + quat.y * quat.y + quat.z * quat.z + quat.w * quat.w;\n if (len > 0.) {\n len = 1. / sqrt(len);\n quat.x = quat.x * len;\n quat.y = quat.y * len;\n quat.z = quat.z * len;\n quat.w = quat.w * len;\n }\n return quat;\n}\nvec4 quaternionFromEuler(vec3 angle){\n float x = angle.x / 2.;\n float y = angle.y / 2.;\n float z = angle.z / 2.;\n float sx = sin(x);\n float cx = cos(x);\n float sy = sin(y);\n float cy = cos(y);\n float sz = sin(z);\n float cz = cos(z);\n vec4 quat = vec4(0);\n quat.x = sx * cy * cz + cx * sy * sz;\n quat.y = cx * sy * cz + sx * cy * sz;\n quat.z = cx * cy * sz - sx * sy * cz;\n quat.w = cx * cy * cz - sx * sy * sz;\n return quat;\n}\nmat4 matrixFromRT(vec4 q, vec3 p){\n float x2 = q.x + q.x;\n float y2 = q.y + q.y;\n float z2 = q.z + q.z;\n float xx = q.x * x2;\n float xy = q.x * y2;\n float xz = q.x * z2;\n float yy = q.y * y2;\n float yz = q.y * z2;\n float zz = q.z * z2;\n float wx = q.w * x2;\n float wy = q.w * y2;\n float wz = q.w * z2;\n return mat4(\n 1. - (yy + zz), xy + wz, xz - wy, 0,\n xy - wz, 1. - (xx + zz), yz + wx, 0,\n xz + wy, yz - wx, 1. - (xx + yy), 0,\n p.x, p.y, p.z, 1\n );\n}\nmat4 matFromRTS(vec4 q, vec3 t, vec3 s){\n float x = q.x, y = q.y, z = q.z, w = q.w;\n float x2 = x + x;\n float y2 = y + y;\n float z2 = z + z;\n float xx = x * x2;\n float xy = x * y2;\n float xz = x * z2;\n float yy = y * y2;\n float yz = y * z2;\n float zz = z * z2;\n float wx = w * x2;\n float wy = w * y2;\n float wz = w * z2;\n float sx = s.x;\n float sy = s.y;\n float sz = s.z;\n return mat4((1. - (yy + zz)) * sx, (xy + wz) * sx, (xz - wy) * sx, 0,\n (xy - wz) * sy, (1. - (xx + zz)) * sy, (yz + wx) * sy, 0,\n (xz + wy) * sz, (yz - wx) * sz, (1. - (xx + yy)) * sz, 0,\n t.x, t.y, t.z, 1);\n}\nvec4 quatMultiply(vec4 a, vec4 b){\n vec4 quat;\n quat.x = a.x * b.w + a.w * b.x + a.y * b.z - a.z * b.y;\n quat.y = a.y * b.w + a.w * b.y + a.z * b.x - a.x * b.z;\n quat.z = a.z * b.w + a.w * b.z + a.x * b.y - a.y * b.x;\n quat.w = a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z;\n return quat;\n}\nvoid rotateVecFromQuat(inout vec3 v, vec4 q){\n float ix = q.w * v.x + q.y * v.z - q.z * v.y;\n float iy = q.w * v.y + q.z * v.x - q.x * v.z;\n float iz = q.w * v.z + q.x * v.y - q.y * v.x;\n float iw = -q.x * v.x - q.y * v.y - q.z * v.z;\n v.x = ix * q.w + iw * -q.x + iy * -q.z - iz * -q.y;\n v.y = iy * q.w + iw * -q.y + iz * -q.x - ix * -q.z;\n v.z = iz * q.w + iw * -q.z + ix * -q.y - iy * -q.x;\n}\nvec3 rotateInLocalSpace(vec3 pos, vec3 xAxis, vec3 yAxis, vec3 zAxis, vec4 q){\n float z = pos.z;\n float x = pos.x;\n float y = pos.y;\n vec4 viewQuat = quaternionFromAxis(xAxis, yAxis, zAxis);\n vec4 rotQuat = quatMultiply(viewQuat, q);\n rotateVecFromQuat(pos, rotQuat);\n return pos;\n}\nvoid rotateCorner(inout vec2 corner, float angle){\n float xOS = cos(angle) * corner.x - sin(angle) * corner.y;\n float yOS = sin(angle) * corner.x + cos(angle) * corner.y;\n corner.x = xOS;\n corner.y = yOS;\n}\nuniform vec4 mainTiling_Offset;\nuniform vec4 frameTile_velLenScale;\nuniform vec4 scale;\nuniform mat4 cc_matView;\nuniform mat4 cc_matViewInv;\nuniform mat4 cc_matViewProj;\nuniform vec4 cc_cameraPos;\nuniform mat4 cc_matWorld;\nvarying vec2 uv;\nvarying vec4 color;\nvoid computeVertPos(inout vec4 pos, vec2 vertOffset, vec4 q, vec3 s\n#if CC_USE_BILLBOARD || CC_USE_VERTICAL_BILLBOARD\n , mat4 viewInv\n#endif\n#if CC_USE_STRETCHED_BILLBOARD\n , vec3 eye\n , vec4 velocity\n , float velocityScale\n , float lengthScale\n , float xIndex\n#endif\n) {\n#if CC_USE_BILLBOARD\n vec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\n vec3 camX = normalize(vec3(viewInv[0][0], viewInv[1][0], viewInv[2][0]));\n vec3 camY = normalize(vec3(viewInv[0][1], viewInv[1][1], viewInv[2][1]));\n vec3 camZ = normalize(vec3(viewInv[0][2], viewInv[1][2], viewInv[2][2]));\n pos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, camZ, q);\n#elif CC_USE_STRETCHED_BILLBOARD\n vec3 camRight = normalize(cross(pos.xyz - eye, velocity.xyz)) * s.x;\n vec3 camUp = velocity.xyz * velocityScale + normalize(velocity.xyz) * lengthScale * s.y;\n pos.xyz += (camRight * abs(vertOffset.x) * sign(vertOffset.y)) - camUp * xIndex;\n#elif CC_USE_HORIZONTAL_BILLBOARD\n vec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\n vec3 camX = vec3(1, 0, 0);\n vec3 camY = vec3(0, 0, -1);\n pos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, cross(camX, camY), q);\n#elif CC_USE_VERTICAL_BILLBOARD\n vec2 viewSpaceVert = vec2(vertOffset.x * s.x, vertOffset.y * s.y);\n rotateCorner(viewSpaceVert, q.z);\n vec3 camX = normalize(vec3(cc_matView[0][0], cc_matView[1][0], cc_matView[2][0]));\n vec3 camY = vec3(0, 1, 0);\n vec3 offset = camX * viewSpaceVert.x + camY * viewSpaceVert.y;\n pos.xyz += offset;\n#else\n pos.x += vertOffset.x;\n pos.y += vertOffset.y;\n#endif\n}\nvec2 computeUV(float frameIndex, vec2 vertIndex, vec2 frameTile){\n vec2 aniUV = vec2(0, floor(frameIndex * frameTile.y));\n aniUV.x = floor(frameIndex * frameTile.x * frameTile.y - aniUV.y * frameTile.x);\n#if !CC_USE_MESH\n vertIndex.y = 1. - vertIndex.y;\n#endif\n return (aniUV.xy + vertIndex) / vec2(frameTile.x, frameTile.y);\n}\nattribute vec3 a_position;\nattribute vec3 a_texCoord;\nattribute vec3 a_texCoord1;\nattribute vec3 a_texCoord2;\nattribute vec4 a_color;\n#if CC_USE_STRETCHED_BILLBOARD\n attribute vec3 a_color1;\n#endif\n#if CC_USE_MESH\n attribute vec3 a_texCoord3;\n attribute vec3 a_normal;\n attribute vec4 a_color1;\n#endif\nvec4 lpvs_main() {\n vec3 compScale = scale.xyz * a_texCoord1;\n vec4 pos = vec4(a_position, 1);\n#if CC_USE_STRETCHED_BILLBOARD\n vec4 velocity = vec4(a_color1.xyz, 0);\n#endif\n#if !CC_USE_WORLD_SPACE\n pos = cc_matWorld * pos;\n #if CC_USE_STRETCHED_BILLBOARD\n velocity = cc_matWorld * velocity;\n #endif\n#endif\n#if !CC_USE_MESH\n vec2 cornerOffset = vec2((a_texCoord.xy - 0.5));\n #if CC_USE_BILLBOARD\n vec3 rotEuler = a_texCoord2;\n #elif CC_USE_STRETCHED_BILLBOARD\n vec3 rotEuler = vec3(0.);\n #else\n vec3 rotEuler = vec3(0., 0., a_texCoord2.z);\n #endif\n computeVertPos(pos, cornerOffset, quaternionFromEuler(rotEuler), compScale\n #if CC_USE_BILLBOARD || CC_USE_VERTICAL_BILLBOARD\n , cc_matViewInv\n #endif\n #if CC_USE_STRETCHED_BILLBOARD\n , cc_cameraPos.xyz\n , velocity\n , frameTile_velLenScale.z\n , frameTile_velLenScale.w\n , a_texCoord.x\n #endif\n );\n color = a_color;\n#else\n mat4 xformNoScale = matrixFromRT(quaternionFromEuler(a_texCoord2), pos.xyz);\n mat4 xform = matFromRTS(quaternionFromEuler(a_texCoord2), pos.xyz, compScale);\n pos = xform * vec4(a_texCoord3, 1);\n vec4 normal = xformNoScale * vec4(a_normal, 0);\n color = a_color * a_color1;\n#endif\n uv = computeUV(a_texCoord.z, a_texCoord.xy, frameTile_velLenScale.xy) * mainTiling_Offset.xy + mainTiling_Offset.zw;\n pos = cc_matViewProj * pos;\n return pos;\n}\nvoid main() { gl_Position = lpvs_main(); }", + "frag": "\nprecision highp float;\nvec4 CCFragOutput (vec4 color) {\n #if OUTPUT_TO_GAMMA\n color.rgb = sqrt(color.rgb);\n #endif\n\treturn color;\n}\nvarying vec2 uv;\nvarying vec4 color;\nuniform sampler2D mainTexture;\nuniform vec4 tintColor;\nvec4 add () {\n vec4 col = 2.0 * color * tintColor * texture2D(mainTexture, uv);\n return CCFragOutput(col);\n}\nvoid main() { gl_FragColor = add(); }" + }, + "builtins": { + "globals": { + "blocks": [ + { + "name": "CCGlobal", + "defines": [] + } + ], + "samplers": [] + }, + "locals": { + "blocks": [ + { + "name": "CCLocal", + "defines": [] + } + ], + "samplers": [] + } + }, + "defines": [ + { + "name": "CC_USE_BILLBOARD", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_STRETCHED_BILLBOARD", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_HORIZONTAL_BILLBOARD", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_VERTICAL_BILLBOARD", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_MESH", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_WORLD_SPACE", + "type": "boolean", + "defines": [] + }, + { + "name": "OUTPUT_TO_GAMMA", + "type": "boolean", + "defines": [] + } + ], + "blocks": [ + { + "name": "Constants", + "members": [ + { + "name": "mainTiling_Offset", + "type": 16, + "count": 1 + }, + { + "name": "frameTile_velLenScale", + "type": 16, + "count": 1 + }, + { + "name": "scale", + "type": 16, + "count": 1 + } + ], + "defines": [], + "binding": 0 + }, + { + "name": "FragConstants", + "members": [ + { + "name": "tintColor", + "type": 16, + "count": 1 + } + ], + "defines": [], + "binding": 1 + } + ], + "samplers": [ + { + "name": "mainTexture", + "type": 29, + "count": 1, + "defines": [], + "binding": 30 + } + ], + "record": null, + "name": "builtin-3d-particle|particle-vs-legacy:lpvs_main|tinted-fs:add" + }, + { + "hash": 1933642753, + "glsl3": { + "vert": "\nprecision highp float;\nvec4 quaternionFromAxis(vec3 xAxis,vec3 yAxis,vec3 zAxis){\n mat3 m = mat3(xAxis,yAxis,zAxis);\n float trace = m[0][0] + m[1][1] + m[2][2];\n vec4 quat;\n if (trace > 0.) {\n float s = 0.5 / sqrt(trace + 1.0);\n quat.w = 0.25 / s;\n quat.x = (m[2][1] - m[1][2]) * s;\n quat.y = (m[0][2] - m[2][0]) * s;\n quat.z = (m[1][0] - m[0][1]) * s;\n } else if ((m[0][0] > m[1][1]) && (m[0][0] > m[2][2])) {\n float s = 2.0 * sqrt(1.0 + m[0][0] - m[1][1] - m[2][2]);\n quat.w = (m[2][1] - m[1][2]) / s;\n quat.x = 0.25 * s;\n quat.y = (m[0][1] + m[1][0]) / s;\n quat.z = (m[0][2] + m[2][0]) / s;\n } else if (m[1][1] > m[2][2]) {\n float s = 2.0 * sqrt(1.0 + m[1][1] - m[0][0] - m[2][2]);\n quat.w = (m[0][2] - m[2][0]) / s;\n quat.x = (m[0][1] + m[1][0]) / s;\n quat.y = 0.25 * s;\n quat.z = (m[1][2] + m[2][1]) / s;\n } else {\n float s = 2.0 * sqrt(1.0 + m[2][2] - m[0][0] - m[1][1]);\n quat.w = (m[1][0] - m[0][1]) / s;\n quat.x = (m[0][2] + m[2][0]) / s;\n quat.y = (m[1][2] + m[2][1]) / s;\n quat.z = 0.25 * s;\n }\n float len = quat.x * quat.x + quat.y * quat.y + quat.z * quat.z + quat.w * quat.w;\n if (len > 0.) {\n len = 1. / sqrt(len);\n quat.x = quat.x * len;\n quat.y = quat.y * len;\n quat.z = quat.z * len;\n quat.w = quat.w * len;\n }\n return quat;\n}\nvec4 quaternionFromEuler(vec3 angle){\n float x = angle.x / 2.;\n float y = angle.y / 2.;\n float z = angle.z / 2.;\n float sx = sin(x);\n float cx = cos(x);\n float sy = sin(y);\n float cy = cos(y);\n float sz = sin(z);\n float cz = cos(z);\n vec4 quat = vec4(0);\n quat.x = sx * cy * cz + cx * sy * sz;\n quat.y = cx * sy * cz + sx * cy * sz;\n quat.z = cx * cy * sz - sx * sy * cz;\n quat.w = cx * cy * cz - sx * sy * sz;\n return quat;\n}\nmat4 matrixFromRT(vec4 q, vec3 p){\n float x2 = q.x + q.x;\n float y2 = q.y + q.y;\n float z2 = q.z + q.z;\n float xx = q.x * x2;\n float xy = q.x * y2;\n float xz = q.x * z2;\n float yy = q.y * y2;\n float yz = q.y * z2;\n float zz = q.z * z2;\n float wx = q.w * x2;\n float wy = q.w * y2;\n float wz = q.w * z2;\n return mat4(\n 1. - (yy + zz), xy + wz, xz - wy, 0,\n xy - wz, 1. - (xx + zz), yz + wx, 0,\n xz + wy, yz - wx, 1. - (xx + yy), 0,\n p.x, p.y, p.z, 1\n );\n}\nmat4 matFromRTS(vec4 q, vec3 t, vec3 s){\n float x = q.x, y = q.y, z = q.z, w = q.w;\n float x2 = x + x;\n float y2 = y + y;\n float z2 = z + z;\n float xx = x * x2;\n float xy = x * y2;\n float xz = x * z2;\n float yy = y * y2;\n float yz = y * z2;\n float zz = z * z2;\n float wx = w * x2;\n float wy = w * y2;\n float wz = w * z2;\n float sx = s.x;\n float sy = s.y;\n float sz = s.z;\n return mat4((1. - (yy + zz)) * sx, (xy + wz) * sx, (xz - wy) * sx, 0,\n (xy - wz) * sy, (1. - (xx + zz)) * sy, (yz + wx) * sy, 0,\n (xz + wy) * sz, (yz - wx) * sz, (1. - (xx + yy)) * sz, 0,\n t.x, t.y, t.z, 1);\n}\nvec4 quatMultiply(vec4 a, vec4 b){\n vec4 quat;\n quat.x = a.x * b.w + a.w * b.x + a.y * b.z - a.z * b.y;\n quat.y = a.y * b.w + a.w * b.y + a.z * b.x - a.x * b.z;\n quat.z = a.z * b.w + a.w * b.z + a.x * b.y - a.y * b.x;\n quat.w = a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z;\n return quat;\n}\nvoid rotateVecFromQuat(inout vec3 v, vec4 q){\n float ix = q.w * v.x + q.y * v.z - q.z * v.y;\n float iy = q.w * v.y + q.z * v.x - q.x * v.z;\n float iz = q.w * v.z + q.x * v.y - q.y * v.x;\n float iw = -q.x * v.x - q.y * v.y - q.z * v.z;\n v.x = ix * q.w + iw * -q.x + iy * -q.z - iz * -q.y;\n v.y = iy * q.w + iw * -q.y + iz * -q.x - ix * -q.z;\n v.z = iz * q.w + iw * -q.z + ix * -q.y - iy * -q.x;\n}\nvec3 rotateInLocalSpace(vec3 pos, vec3 xAxis, vec3 yAxis, vec3 zAxis, vec4 q){\n float z = pos.z;\n float x = pos.x;\n float y = pos.y;\n vec4 viewQuat = quaternionFromAxis(xAxis, yAxis, zAxis);\n vec4 rotQuat = quatMultiply(viewQuat, q);\n rotateVecFromQuat(pos, rotQuat);\n return pos;\n}\nvoid rotateCorner(inout vec2 corner, float angle){\n float xOS = cos(angle) * corner.x - sin(angle) * corner.y;\n float yOS = sin(angle) * corner.x + cos(angle) * corner.y;\n corner.x = xOS;\n corner.y = yOS;\n}\nuniform Constants{\n vec4 mainTiling_Offset;\n vec4 frameTile_velLenScale;\n vec4 scale;\n};\nuniform CCGlobal {\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\nuniform CCLocal {\n mat4 cc_matWorld;\n mat4 cc_matWorldIT;\n};\nout vec2 uv;\nout vec4 color;\nvoid computeVertPos(inout vec4 pos, vec2 vertOffset, vec4 q, vec3 s\n#if CC_USE_BILLBOARD || CC_USE_VERTICAL_BILLBOARD\n , mat4 viewInv\n#endif\n#if CC_USE_STRETCHED_BILLBOARD\n , vec3 eye\n , vec4 velocity\n , float velocityScale\n , float lengthScale\n , float xIndex\n#endif\n) {\n#if CC_USE_BILLBOARD\n vec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\n vec3 camX = normalize(vec3(viewInv[0][0], viewInv[1][0], viewInv[2][0]));\n vec3 camY = normalize(vec3(viewInv[0][1], viewInv[1][1], viewInv[2][1]));\n vec3 camZ = normalize(vec3(viewInv[0][2], viewInv[1][2], viewInv[2][2]));\n pos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, camZ, q);\n#elif CC_USE_STRETCHED_BILLBOARD\n vec3 camRight = normalize(cross(pos.xyz - eye, velocity.xyz)) * s.x;\n vec3 camUp = velocity.xyz * velocityScale + normalize(velocity.xyz) * lengthScale * s.y;\n pos.xyz += (camRight * abs(vertOffset.x) * sign(vertOffset.y)) - camUp * xIndex;\n#elif CC_USE_HORIZONTAL_BILLBOARD\n vec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\n vec3 camX = vec3(1, 0, 0);\n vec3 camY = vec3(0, 0, -1);\n pos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, cross(camX, camY), q);\n#elif CC_USE_VERTICAL_BILLBOARD\n vec2 viewSpaceVert = vec2(vertOffset.x * s.x, vertOffset.y * s.y);\n rotateCorner(viewSpaceVert, q.z);\n vec3 camX = normalize(vec3(cc_matView[0][0], cc_matView[1][0], cc_matView[2][0]));\n vec3 camY = vec3(0, 1, 0);\n vec3 offset = camX * viewSpaceVert.x + camY * viewSpaceVert.y;\n pos.xyz += offset;\n#else\n pos.x += vertOffset.x;\n pos.y += vertOffset.y;\n#endif\n}\nvec2 computeUV(float frameIndex, vec2 vertIndex, vec2 frameTile){\n vec2 aniUV = vec2(0, floor(frameIndex * frameTile.y));\n aniUV.x = floor(frameIndex * frameTile.x * frameTile.y - aniUV.y * frameTile.x);\n#if !CC_USE_MESH\n vertIndex.y = 1. - vertIndex.y;\n#endif\n return (aniUV.xy + vertIndex) / vec2(frameTile.x, frameTile.y);\n}\nin vec3 a_position;\nin vec3 a_texCoord;\nin vec3 a_texCoord1;\nin vec3 a_texCoord2;\nin vec4 a_color;\n#if CC_USE_STRETCHED_BILLBOARD\n in vec3 a_color1;\n#endif\n#if CC_USE_MESH\n in vec3 a_texCoord3;\n in vec3 a_normal;\n in vec4 a_color1;\n#endif\nvec4 lpvs_main() {\n vec3 compScale = scale.xyz * a_texCoord1;\n vec4 pos = vec4(a_position, 1);\n#if CC_USE_STRETCHED_BILLBOARD\n vec4 velocity = vec4(a_color1.xyz, 0);\n#endif\n#if !CC_USE_WORLD_SPACE\n pos = cc_matWorld * pos;\n #if CC_USE_STRETCHED_BILLBOARD\n velocity = cc_matWorld * velocity;\n #endif\n#endif\n#if !CC_USE_MESH\n vec2 cornerOffset = vec2((a_texCoord.xy - 0.5));\n #if CC_USE_BILLBOARD\n vec3 rotEuler = a_texCoord2;\n #elif CC_USE_STRETCHED_BILLBOARD\n vec3 rotEuler = vec3(0.);\n #else\n vec3 rotEuler = vec3(0., 0., a_texCoord2.z);\n #endif\n computeVertPos(pos, cornerOffset, quaternionFromEuler(rotEuler), compScale\n #if CC_USE_BILLBOARD || CC_USE_VERTICAL_BILLBOARD\n , cc_matViewInv\n #endif\n #if CC_USE_STRETCHED_BILLBOARD\n , cc_cameraPos.xyz\n , velocity\n , frameTile_velLenScale.z\n , frameTile_velLenScale.w\n , a_texCoord.x\n #endif\n );\n color = a_color;\n#else\n mat4 xformNoScale = matrixFromRT(quaternionFromEuler(a_texCoord2), pos.xyz);\n mat4 xform = matFromRTS(quaternionFromEuler(a_texCoord2), pos.xyz, compScale);\n pos = xform * vec4(a_texCoord3, 1);\n vec4 normal = xformNoScale * vec4(a_normal, 0);\n color = a_color * a_color1;\n#endif\n uv = computeUV(a_texCoord.z, a_texCoord.xy, frameTile_velLenScale.xy) * mainTiling_Offset.xy + mainTiling_Offset.zw;\n pos = cc_matViewProj * pos;\n return pos;\n}\nvoid main() { gl_Position = lpvs_main(); }", + "frag": "\nprecision highp float;\nvec4 CCFragOutput (vec4 color) {\n #if OUTPUT_TO_GAMMA\n color.rgb = sqrt(color.rgb);\n #endif\n\treturn color;\n}\nin vec2 uv;\nin vec4 color;\nuniform sampler2D mainTexture;\nuniform FragConstants {\n vec4 tintColor;\n};\nvec4 multiply () {\n vec4 col;\n vec4 texColor = texture(mainTexture, uv);\n col.rgb = tintColor.rgb * texColor.rgb * color.rgb * vec3(2.0);\n col.a = (1.0 - texColor.a) * (tintColor.a * color.a * 2.0);\n return CCFragOutput(col);\n}\nout vec4 cc_FragColor;\nvoid main() { cc_FragColor = multiply(); }" + }, + "glsl1": { + "vert": "\nprecision highp float;\nvec4 quaternionFromAxis(vec3 xAxis,vec3 yAxis,vec3 zAxis){\n mat3 m = mat3(xAxis,yAxis,zAxis);\n float trace = m[0][0] + m[1][1] + m[2][2];\n vec4 quat;\n if (trace > 0.) {\n float s = 0.5 / sqrt(trace + 1.0);\n quat.w = 0.25 / s;\n quat.x = (m[2][1] - m[1][2]) * s;\n quat.y = (m[0][2] - m[2][0]) * s;\n quat.z = (m[1][0] - m[0][1]) * s;\n } else if ((m[0][0] > m[1][1]) && (m[0][0] > m[2][2])) {\n float s = 2.0 * sqrt(1.0 + m[0][0] - m[1][1] - m[2][2]);\n quat.w = (m[2][1] - m[1][2]) / s;\n quat.x = 0.25 * s;\n quat.y = (m[0][1] + m[1][0]) / s;\n quat.z = (m[0][2] + m[2][0]) / s;\n } else if (m[1][1] > m[2][2]) {\n float s = 2.0 * sqrt(1.0 + m[1][1] - m[0][0] - m[2][2]);\n quat.w = (m[0][2] - m[2][0]) / s;\n quat.x = (m[0][1] + m[1][0]) / s;\n quat.y = 0.25 * s;\n quat.z = (m[1][2] + m[2][1]) / s;\n } else {\n float s = 2.0 * sqrt(1.0 + m[2][2] - m[0][0] - m[1][1]);\n quat.w = (m[1][0] - m[0][1]) / s;\n quat.x = (m[0][2] + m[2][0]) / s;\n quat.y = (m[1][2] + m[2][1]) / s;\n quat.z = 0.25 * s;\n }\n float len = quat.x * quat.x + quat.y * quat.y + quat.z * quat.z + quat.w * quat.w;\n if (len > 0.) {\n len = 1. / sqrt(len);\n quat.x = quat.x * len;\n quat.y = quat.y * len;\n quat.z = quat.z * len;\n quat.w = quat.w * len;\n }\n return quat;\n}\nvec4 quaternionFromEuler(vec3 angle){\n float x = angle.x / 2.;\n float y = angle.y / 2.;\n float z = angle.z / 2.;\n float sx = sin(x);\n float cx = cos(x);\n float sy = sin(y);\n float cy = cos(y);\n float sz = sin(z);\n float cz = cos(z);\n vec4 quat = vec4(0);\n quat.x = sx * cy * cz + cx * sy * sz;\n quat.y = cx * sy * cz + sx * cy * sz;\n quat.z = cx * cy * sz - sx * sy * cz;\n quat.w = cx * cy * cz - sx * sy * sz;\n return quat;\n}\nmat4 matrixFromRT(vec4 q, vec3 p){\n float x2 = q.x + q.x;\n float y2 = q.y + q.y;\n float z2 = q.z + q.z;\n float xx = q.x * x2;\n float xy = q.x * y2;\n float xz = q.x * z2;\n float yy = q.y * y2;\n float yz = q.y * z2;\n float zz = q.z * z2;\n float wx = q.w * x2;\n float wy = q.w * y2;\n float wz = q.w * z2;\n return mat4(\n 1. - (yy + zz), xy + wz, xz - wy, 0,\n xy - wz, 1. - (xx + zz), yz + wx, 0,\n xz + wy, yz - wx, 1. - (xx + yy), 0,\n p.x, p.y, p.z, 1\n );\n}\nmat4 matFromRTS(vec4 q, vec3 t, vec3 s){\n float x = q.x, y = q.y, z = q.z, w = q.w;\n float x2 = x + x;\n float y2 = y + y;\n float z2 = z + z;\n float xx = x * x2;\n float xy = x * y2;\n float xz = x * z2;\n float yy = y * y2;\n float yz = y * z2;\n float zz = z * z2;\n float wx = w * x2;\n float wy = w * y2;\n float wz = w * z2;\n float sx = s.x;\n float sy = s.y;\n float sz = s.z;\n return mat4((1. - (yy + zz)) * sx, (xy + wz) * sx, (xz - wy) * sx, 0,\n (xy - wz) * sy, (1. - (xx + zz)) * sy, (yz + wx) * sy, 0,\n (xz + wy) * sz, (yz - wx) * sz, (1. - (xx + yy)) * sz, 0,\n t.x, t.y, t.z, 1);\n}\nvec4 quatMultiply(vec4 a, vec4 b){\n vec4 quat;\n quat.x = a.x * b.w + a.w * b.x + a.y * b.z - a.z * b.y;\n quat.y = a.y * b.w + a.w * b.y + a.z * b.x - a.x * b.z;\n quat.z = a.z * b.w + a.w * b.z + a.x * b.y - a.y * b.x;\n quat.w = a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z;\n return quat;\n}\nvoid rotateVecFromQuat(inout vec3 v, vec4 q){\n float ix = q.w * v.x + q.y * v.z - q.z * v.y;\n float iy = q.w * v.y + q.z * v.x - q.x * v.z;\n float iz = q.w * v.z + q.x * v.y - q.y * v.x;\n float iw = -q.x * v.x - q.y * v.y - q.z * v.z;\n v.x = ix * q.w + iw * -q.x + iy * -q.z - iz * -q.y;\n v.y = iy * q.w + iw * -q.y + iz * -q.x - ix * -q.z;\n v.z = iz * q.w + iw * -q.z + ix * -q.y - iy * -q.x;\n}\nvec3 rotateInLocalSpace(vec3 pos, vec3 xAxis, vec3 yAxis, vec3 zAxis, vec4 q){\n float z = pos.z;\n float x = pos.x;\n float y = pos.y;\n vec4 viewQuat = quaternionFromAxis(xAxis, yAxis, zAxis);\n vec4 rotQuat = quatMultiply(viewQuat, q);\n rotateVecFromQuat(pos, rotQuat);\n return pos;\n}\nvoid rotateCorner(inout vec2 corner, float angle){\n float xOS = cos(angle) * corner.x - sin(angle) * corner.y;\n float yOS = sin(angle) * corner.x + cos(angle) * corner.y;\n corner.x = xOS;\n corner.y = yOS;\n}\nuniform vec4 mainTiling_Offset;\nuniform vec4 frameTile_velLenScale;\nuniform vec4 scale;\nuniform mat4 cc_matView;\nuniform mat4 cc_matViewInv;\nuniform mat4 cc_matViewProj;\nuniform vec4 cc_cameraPos;\nuniform mat4 cc_matWorld;\nvarying vec2 uv;\nvarying vec4 color;\nvoid computeVertPos(inout vec4 pos, vec2 vertOffset, vec4 q, vec3 s\n#if CC_USE_BILLBOARD || CC_USE_VERTICAL_BILLBOARD\n , mat4 viewInv\n#endif\n#if CC_USE_STRETCHED_BILLBOARD\n , vec3 eye\n , vec4 velocity\n , float velocityScale\n , float lengthScale\n , float xIndex\n#endif\n) {\n#if CC_USE_BILLBOARD\n vec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\n vec3 camX = normalize(vec3(viewInv[0][0], viewInv[1][0], viewInv[2][0]));\n vec3 camY = normalize(vec3(viewInv[0][1], viewInv[1][1], viewInv[2][1]));\n vec3 camZ = normalize(vec3(viewInv[0][2], viewInv[1][2], viewInv[2][2]));\n pos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, camZ, q);\n#elif CC_USE_STRETCHED_BILLBOARD\n vec3 camRight = normalize(cross(pos.xyz - eye, velocity.xyz)) * s.x;\n vec3 camUp = velocity.xyz * velocityScale + normalize(velocity.xyz) * lengthScale * s.y;\n pos.xyz += (camRight * abs(vertOffset.x) * sign(vertOffset.y)) - camUp * xIndex;\n#elif CC_USE_HORIZONTAL_BILLBOARD\n vec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\n vec3 camX = vec3(1, 0, 0);\n vec3 camY = vec3(0, 0, -1);\n pos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, cross(camX, camY), q);\n#elif CC_USE_VERTICAL_BILLBOARD\n vec2 viewSpaceVert = vec2(vertOffset.x * s.x, vertOffset.y * s.y);\n rotateCorner(viewSpaceVert, q.z);\n vec3 camX = normalize(vec3(cc_matView[0][0], cc_matView[1][0], cc_matView[2][0]));\n vec3 camY = vec3(0, 1, 0);\n vec3 offset = camX * viewSpaceVert.x + camY * viewSpaceVert.y;\n pos.xyz += offset;\n#else\n pos.x += vertOffset.x;\n pos.y += vertOffset.y;\n#endif\n}\nvec2 computeUV(float frameIndex, vec2 vertIndex, vec2 frameTile){\n vec2 aniUV = vec2(0, floor(frameIndex * frameTile.y));\n aniUV.x = floor(frameIndex * frameTile.x * frameTile.y - aniUV.y * frameTile.x);\n#if !CC_USE_MESH\n vertIndex.y = 1. - vertIndex.y;\n#endif\n return (aniUV.xy + vertIndex) / vec2(frameTile.x, frameTile.y);\n}\nattribute vec3 a_position;\nattribute vec3 a_texCoord;\nattribute vec3 a_texCoord1;\nattribute vec3 a_texCoord2;\nattribute vec4 a_color;\n#if CC_USE_STRETCHED_BILLBOARD\n attribute vec3 a_color1;\n#endif\n#if CC_USE_MESH\n attribute vec3 a_texCoord3;\n attribute vec3 a_normal;\n attribute vec4 a_color1;\n#endif\nvec4 lpvs_main() {\n vec3 compScale = scale.xyz * a_texCoord1;\n vec4 pos = vec4(a_position, 1);\n#if CC_USE_STRETCHED_BILLBOARD\n vec4 velocity = vec4(a_color1.xyz, 0);\n#endif\n#if !CC_USE_WORLD_SPACE\n pos = cc_matWorld * pos;\n #if CC_USE_STRETCHED_BILLBOARD\n velocity = cc_matWorld * velocity;\n #endif\n#endif\n#if !CC_USE_MESH\n vec2 cornerOffset = vec2((a_texCoord.xy - 0.5));\n #if CC_USE_BILLBOARD\n vec3 rotEuler = a_texCoord2;\n #elif CC_USE_STRETCHED_BILLBOARD\n vec3 rotEuler = vec3(0.);\n #else\n vec3 rotEuler = vec3(0., 0., a_texCoord2.z);\n #endif\n computeVertPos(pos, cornerOffset, quaternionFromEuler(rotEuler), compScale\n #if CC_USE_BILLBOARD || CC_USE_VERTICAL_BILLBOARD\n , cc_matViewInv\n #endif\n #if CC_USE_STRETCHED_BILLBOARD\n , cc_cameraPos.xyz\n , velocity\n , frameTile_velLenScale.z\n , frameTile_velLenScale.w\n , a_texCoord.x\n #endif\n );\n color = a_color;\n#else\n mat4 xformNoScale = matrixFromRT(quaternionFromEuler(a_texCoord2), pos.xyz);\n mat4 xform = matFromRTS(quaternionFromEuler(a_texCoord2), pos.xyz, compScale);\n pos = xform * vec4(a_texCoord3, 1);\n vec4 normal = xformNoScale * vec4(a_normal, 0);\n color = a_color * a_color1;\n#endif\n uv = computeUV(a_texCoord.z, a_texCoord.xy, frameTile_velLenScale.xy) * mainTiling_Offset.xy + mainTiling_Offset.zw;\n pos = cc_matViewProj * pos;\n return pos;\n}\nvoid main() { gl_Position = lpvs_main(); }", + "frag": "\nprecision highp float;\nvec4 CCFragOutput (vec4 color) {\n #if OUTPUT_TO_GAMMA\n color.rgb = sqrt(color.rgb);\n #endif\n\treturn color;\n}\nvarying vec2 uv;\nvarying vec4 color;\nuniform sampler2D mainTexture;\nuniform vec4 tintColor;\nvec4 multiply () {\n vec4 col;\n vec4 texColor = texture2D(mainTexture, uv);\n col.rgb = tintColor.rgb * texColor.rgb * color.rgb * vec3(2.0);\n col.a = (1.0 - texColor.a) * (tintColor.a * color.a * 2.0);\n return CCFragOutput(col);\n}\nvoid main() { gl_FragColor = multiply(); }" + }, + "builtins": { + "globals": { + "blocks": [ + { + "name": "CCGlobal", + "defines": [] + } + ], + "samplers": [] + }, + "locals": { + "blocks": [ + { + "name": "CCLocal", + "defines": [] + } + ], + "samplers": [] + } + }, + "defines": [ + { + "name": "CC_USE_BILLBOARD", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_STRETCHED_BILLBOARD", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_HORIZONTAL_BILLBOARD", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_VERTICAL_BILLBOARD", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_MESH", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_WORLD_SPACE", + "type": "boolean", + "defines": [] + }, + { + "name": "OUTPUT_TO_GAMMA", + "type": "boolean", + "defines": [] + } + ], + "blocks": [ + { + "name": "Constants", + "members": [ + { + "name": "mainTiling_Offset", + "type": 16, + "count": 1 + }, + { + "name": "frameTile_velLenScale", + "type": 16, + "count": 1 + }, + { + "name": "scale", + "type": 16, + "count": 1 + } + ], + "defines": [], + "binding": 0 + }, + { + "name": "FragConstants", + "members": [ + { + "name": "tintColor", + "type": 16, + "count": 1 + } + ], + "defines": [], + "binding": 1 + } + ], + "samplers": [ + { + "name": "mainTexture", + "type": 29, + "count": 1, + "defines": [], + "binding": 30 + } + ], + "record": null, + "name": "builtin-3d-particle|particle-vs-legacy:lpvs_main|tinted-fs:multiply" + }, + { + "hash": 1851787849, + "glsl3": { + "vert": "\nprecision highp float;\nvec4 quaternionFromAxis(vec3 xAxis,vec3 yAxis,vec3 zAxis){\n mat3 m = mat3(xAxis,yAxis,zAxis);\n float trace = m[0][0] + m[1][1] + m[2][2];\n vec4 quat;\n if (trace > 0.) {\n float s = 0.5 / sqrt(trace + 1.0);\n quat.w = 0.25 / s;\n quat.x = (m[2][1] - m[1][2]) * s;\n quat.y = (m[0][2] - m[2][0]) * s;\n quat.z = (m[1][0] - m[0][1]) * s;\n } else if ((m[0][0] > m[1][1]) && (m[0][0] > m[2][2])) {\n float s = 2.0 * sqrt(1.0 + m[0][0] - m[1][1] - m[2][2]);\n quat.w = (m[2][1] - m[1][2]) / s;\n quat.x = 0.25 * s;\n quat.y = (m[0][1] + m[1][0]) / s;\n quat.z = (m[0][2] + m[2][0]) / s;\n } else if (m[1][1] > m[2][2]) {\n float s = 2.0 * sqrt(1.0 + m[1][1] - m[0][0] - m[2][2]);\n quat.w = (m[0][2] - m[2][0]) / s;\n quat.x = (m[0][1] + m[1][0]) / s;\n quat.y = 0.25 * s;\n quat.z = (m[1][2] + m[2][1]) / s;\n } else {\n float s = 2.0 * sqrt(1.0 + m[2][2] - m[0][0] - m[1][1]);\n quat.w = (m[1][0] - m[0][1]) / s;\n quat.x = (m[0][2] + m[2][0]) / s;\n quat.y = (m[1][2] + m[2][1]) / s;\n quat.z = 0.25 * s;\n }\n float len = quat.x * quat.x + quat.y * quat.y + quat.z * quat.z + quat.w * quat.w;\n if (len > 0.) {\n len = 1. / sqrt(len);\n quat.x = quat.x * len;\n quat.y = quat.y * len;\n quat.z = quat.z * len;\n quat.w = quat.w * len;\n }\n return quat;\n}\nvec4 quaternionFromEuler(vec3 angle){\n float x = angle.x / 2.;\n float y = angle.y / 2.;\n float z = angle.z / 2.;\n float sx = sin(x);\n float cx = cos(x);\n float sy = sin(y);\n float cy = cos(y);\n float sz = sin(z);\n float cz = cos(z);\n vec4 quat = vec4(0);\n quat.x = sx * cy * cz + cx * sy * sz;\n quat.y = cx * sy * cz + sx * cy * sz;\n quat.z = cx * cy * sz - sx * sy * cz;\n quat.w = cx * cy * cz - sx * sy * sz;\n return quat;\n}\nmat4 matrixFromRT(vec4 q, vec3 p){\n float x2 = q.x + q.x;\n float y2 = q.y + q.y;\n float z2 = q.z + q.z;\n float xx = q.x * x2;\n float xy = q.x * y2;\n float xz = q.x * z2;\n float yy = q.y * y2;\n float yz = q.y * z2;\n float zz = q.z * z2;\n float wx = q.w * x2;\n float wy = q.w * y2;\n float wz = q.w * z2;\n return mat4(\n 1. - (yy + zz), xy + wz, xz - wy, 0,\n xy - wz, 1. - (xx + zz), yz + wx, 0,\n xz + wy, yz - wx, 1. - (xx + yy), 0,\n p.x, p.y, p.z, 1\n );\n}\nmat4 matFromRTS(vec4 q, vec3 t, vec3 s){\n float x = q.x, y = q.y, z = q.z, w = q.w;\n float x2 = x + x;\n float y2 = y + y;\n float z2 = z + z;\n float xx = x * x2;\n float xy = x * y2;\n float xz = x * z2;\n float yy = y * y2;\n float yz = y * z2;\n float zz = z * z2;\n float wx = w * x2;\n float wy = w * y2;\n float wz = w * z2;\n float sx = s.x;\n float sy = s.y;\n float sz = s.z;\n return mat4((1. - (yy + zz)) * sx, (xy + wz) * sx, (xz - wy) * sx, 0,\n (xy - wz) * sy, (1. - (xx + zz)) * sy, (yz + wx) * sy, 0,\n (xz + wy) * sz, (yz - wx) * sz, (1. - (xx + yy)) * sz, 0,\n t.x, t.y, t.z, 1);\n}\nvec4 quatMultiply(vec4 a, vec4 b){\n vec4 quat;\n quat.x = a.x * b.w + a.w * b.x + a.y * b.z - a.z * b.y;\n quat.y = a.y * b.w + a.w * b.y + a.z * b.x - a.x * b.z;\n quat.z = a.z * b.w + a.w * b.z + a.x * b.y - a.y * b.x;\n quat.w = a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z;\n return quat;\n}\nvoid rotateVecFromQuat(inout vec3 v, vec4 q){\n float ix = q.w * v.x + q.y * v.z - q.z * v.y;\n float iy = q.w * v.y + q.z * v.x - q.x * v.z;\n float iz = q.w * v.z + q.x * v.y - q.y * v.x;\n float iw = -q.x * v.x - q.y * v.y - q.z * v.z;\n v.x = ix * q.w + iw * -q.x + iy * -q.z - iz * -q.y;\n v.y = iy * q.w + iw * -q.y + iz * -q.x - ix * -q.z;\n v.z = iz * q.w + iw * -q.z + ix * -q.y - iy * -q.x;\n}\nvec3 rotateInLocalSpace(vec3 pos, vec3 xAxis, vec3 yAxis, vec3 zAxis, vec4 q){\n float z = pos.z;\n float x = pos.x;\n float y = pos.y;\n vec4 viewQuat = quaternionFromAxis(xAxis, yAxis, zAxis);\n vec4 rotQuat = quatMultiply(viewQuat, q);\n rotateVecFromQuat(pos, rotQuat);\n return pos;\n}\nvoid rotateCorner(inout vec2 corner, float angle){\n float xOS = cos(angle) * corner.x - sin(angle) * corner.y;\n float yOS = sin(angle) * corner.x + cos(angle) * corner.y;\n corner.x = xOS;\n corner.y = yOS;\n}\nuniform Constants{\n vec4 mainTiling_Offset;\n vec4 frameTile_velLenScale;\n vec4 scale;\n};\nuniform CCGlobal {\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\nuniform CCLocal {\n mat4 cc_matWorld;\n mat4 cc_matWorldIT;\n};\nout vec2 uv;\nout vec4 color;\nvoid computeVertPos(inout vec4 pos, vec2 vertOffset, vec4 q, vec3 s\n#if CC_USE_BILLBOARD || CC_USE_VERTICAL_BILLBOARD\n , mat4 viewInv\n#endif\n#if CC_USE_STRETCHED_BILLBOARD\n , vec3 eye\n , vec4 velocity\n , float velocityScale\n , float lengthScale\n , float xIndex\n#endif\n) {\n#if CC_USE_BILLBOARD\n vec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\n vec3 camX = normalize(vec3(viewInv[0][0], viewInv[1][0], viewInv[2][0]));\n vec3 camY = normalize(vec3(viewInv[0][1], viewInv[1][1], viewInv[2][1]));\n vec3 camZ = normalize(vec3(viewInv[0][2], viewInv[1][2], viewInv[2][2]));\n pos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, camZ, q);\n#elif CC_USE_STRETCHED_BILLBOARD\n vec3 camRight = normalize(cross(pos.xyz - eye, velocity.xyz)) * s.x;\n vec3 camUp = velocity.xyz * velocityScale + normalize(velocity.xyz) * lengthScale * s.y;\n pos.xyz += (camRight * abs(vertOffset.x) * sign(vertOffset.y)) - camUp * xIndex;\n#elif CC_USE_HORIZONTAL_BILLBOARD\n vec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\n vec3 camX = vec3(1, 0, 0);\n vec3 camY = vec3(0, 0, -1);\n pos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, cross(camX, camY), q);\n#elif CC_USE_VERTICAL_BILLBOARD\n vec2 viewSpaceVert = vec2(vertOffset.x * s.x, vertOffset.y * s.y);\n rotateCorner(viewSpaceVert, q.z);\n vec3 camX = normalize(vec3(cc_matView[0][0], cc_matView[1][0], cc_matView[2][0]));\n vec3 camY = vec3(0, 1, 0);\n vec3 offset = camX * viewSpaceVert.x + camY * viewSpaceVert.y;\n pos.xyz += offset;\n#else\n pos.x += vertOffset.x;\n pos.y += vertOffset.y;\n#endif\n}\nvec2 computeUV(float frameIndex, vec2 vertIndex, vec2 frameTile){\n vec2 aniUV = vec2(0, floor(frameIndex * frameTile.y));\n aniUV.x = floor(frameIndex * frameTile.x * frameTile.y - aniUV.y * frameTile.x);\n#if !CC_USE_MESH\n vertIndex.y = 1. - vertIndex.y;\n#endif\n return (aniUV.xy + vertIndex) / vec2(frameTile.x, frameTile.y);\n}\nin vec3 a_position;\nin vec3 a_texCoord;\nin vec3 a_texCoord1;\nin vec3 a_texCoord2;\nin vec4 a_color;\n#if CC_USE_STRETCHED_BILLBOARD\n in vec3 a_color1;\n#endif\n#if CC_USE_MESH\n in vec3 a_texCoord3;\n in vec3 a_normal;\n in vec4 a_color1;\n#endif\nvec4 lpvs_main() {\n vec3 compScale = scale.xyz * a_texCoord1;\n vec4 pos = vec4(a_position, 1);\n#if CC_USE_STRETCHED_BILLBOARD\n vec4 velocity = vec4(a_color1.xyz, 0);\n#endif\n#if !CC_USE_WORLD_SPACE\n pos = cc_matWorld * pos;\n #if CC_USE_STRETCHED_BILLBOARD\n velocity = cc_matWorld * velocity;\n #endif\n#endif\n#if !CC_USE_MESH\n vec2 cornerOffset = vec2((a_texCoord.xy - 0.5));\n #if CC_USE_BILLBOARD\n vec3 rotEuler = a_texCoord2;\n #elif CC_USE_STRETCHED_BILLBOARD\n vec3 rotEuler = vec3(0.);\n #else\n vec3 rotEuler = vec3(0., 0., a_texCoord2.z);\n #endif\n computeVertPos(pos, cornerOffset, quaternionFromEuler(rotEuler), compScale\n #if CC_USE_BILLBOARD || CC_USE_VERTICAL_BILLBOARD\n , cc_matViewInv\n #endif\n #if CC_USE_STRETCHED_BILLBOARD\n , cc_cameraPos.xyz\n , velocity\n , frameTile_velLenScale.z\n , frameTile_velLenScale.w\n , a_texCoord.x\n #endif\n );\n color = a_color;\n#else\n mat4 xformNoScale = matrixFromRT(quaternionFromEuler(a_texCoord2), pos.xyz);\n mat4 xform = matFromRTS(quaternionFromEuler(a_texCoord2), pos.xyz, compScale);\n pos = xform * vec4(a_texCoord3, 1);\n vec4 normal = xformNoScale * vec4(a_normal, 0);\n color = a_color * a_color1;\n#endif\n uv = computeUV(a_texCoord.z, a_texCoord.xy, frameTile_velLenScale.xy) * mainTiling_Offset.xy + mainTiling_Offset.zw;\n pos = cc_matViewProj * pos;\n return pos;\n}\nvoid main() { gl_Position = lpvs_main(); }", + "frag": "\nprecision highp float;\nvec4 CCFragOutput (vec4 color) {\n #if OUTPUT_TO_GAMMA\n color.rgb = sqrt(color.rgb);\n #endif\n\treturn color;\n}\nin vec2 uv;\nin vec4 color;\nuniform sampler2D mainTexture;\nvec4 addSmooth () {\n vec4 col = color * texture(mainTexture, uv);\n col.rgb *= col.a;\n return CCFragOutput(col);\n}\nout vec4 cc_FragColor;\nvoid main() { cc_FragColor = addSmooth(); }" + }, + "glsl1": { + "vert": "\nprecision highp float;\nvec4 quaternionFromAxis(vec3 xAxis,vec3 yAxis,vec3 zAxis){\n mat3 m = mat3(xAxis,yAxis,zAxis);\n float trace = m[0][0] + m[1][1] + m[2][2];\n vec4 quat;\n if (trace > 0.) {\n float s = 0.5 / sqrt(trace + 1.0);\n quat.w = 0.25 / s;\n quat.x = (m[2][1] - m[1][2]) * s;\n quat.y = (m[0][2] - m[2][0]) * s;\n quat.z = (m[1][0] - m[0][1]) * s;\n } else if ((m[0][0] > m[1][1]) && (m[0][0] > m[2][2])) {\n float s = 2.0 * sqrt(1.0 + m[0][0] - m[1][1] - m[2][2]);\n quat.w = (m[2][1] - m[1][2]) / s;\n quat.x = 0.25 * s;\n quat.y = (m[0][1] + m[1][0]) / s;\n quat.z = (m[0][2] + m[2][0]) / s;\n } else if (m[1][1] > m[2][2]) {\n float s = 2.0 * sqrt(1.0 + m[1][1] - m[0][0] - m[2][2]);\n quat.w = (m[0][2] - m[2][0]) / s;\n quat.x = (m[0][1] + m[1][0]) / s;\n quat.y = 0.25 * s;\n quat.z = (m[1][2] + m[2][1]) / s;\n } else {\n float s = 2.0 * sqrt(1.0 + m[2][2] - m[0][0] - m[1][1]);\n quat.w = (m[1][0] - m[0][1]) / s;\n quat.x = (m[0][2] + m[2][0]) / s;\n quat.y = (m[1][2] + m[2][1]) / s;\n quat.z = 0.25 * s;\n }\n float len = quat.x * quat.x + quat.y * quat.y + quat.z * quat.z + quat.w * quat.w;\n if (len > 0.) {\n len = 1. / sqrt(len);\n quat.x = quat.x * len;\n quat.y = quat.y * len;\n quat.z = quat.z * len;\n quat.w = quat.w * len;\n }\n return quat;\n}\nvec4 quaternionFromEuler(vec3 angle){\n float x = angle.x / 2.;\n float y = angle.y / 2.;\n float z = angle.z / 2.;\n float sx = sin(x);\n float cx = cos(x);\n float sy = sin(y);\n float cy = cos(y);\n float sz = sin(z);\n float cz = cos(z);\n vec4 quat = vec4(0);\n quat.x = sx * cy * cz + cx * sy * sz;\n quat.y = cx * sy * cz + sx * cy * sz;\n quat.z = cx * cy * sz - sx * sy * cz;\n quat.w = cx * cy * cz - sx * sy * sz;\n return quat;\n}\nmat4 matrixFromRT(vec4 q, vec3 p){\n float x2 = q.x + q.x;\n float y2 = q.y + q.y;\n float z2 = q.z + q.z;\n float xx = q.x * x2;\n float xy = q.x * y2;\n float xz = q.x * z2;\n float yy = q.y * y2;\n float yz = q.y * z2;\n float zz = q.z * z2;\n float wx = q.w * x2;\n float wy = q.w * y2;\n float wz = q.w * z2;\n return mat4(\n 1. - (yy + zz), xy + wz, xz - wy, 0,\n xy - wz, 1. - (xx + zz), yz + wx, 0,\n xz + wy, yz - wx, 1. - (xx + yy), 0,\n p.x, p.y, p.z, 1\n );\n}\nmat4 matFromRTS(vec4 q, vec3 t, vec3 s){\n float x = q.x, y = q.y, z = q.z, w = q.w;\n float x2 = x + x;\n float y2 = y + y;\n float z2 = z + z;\n float xx = x * x2;\n float xy = x * y2;\n float xz = x * z2;\n float yy = y * y2;\n float yz = y * z2;\n float zz = z * z2;\n float wx = w * x2;\n float wy = w * y2;\n float wz = w * z2;\n float sx = s.x;\n float sy = s.y;\n float sz = s.z;\n return mat4((1. - (yy + zz)) * sx, (xy + wz) * sx, (xz - wy) * sx, 0,\n (xy - wz) * sy, (1. - (xx + zz)) * sy, (yz + wx) * sy, 0,\n (xz + wy) * sz, (yz - wx) * sz, (1. - (xx + yy)) * sz, 0,\n t.x, t.y, t.z, 1);\n}\nvec4 quatMultiply(vec4 a, vec4 b){\n vec4 quat;\n quat.x = a.x * b.w + a.w * b.x + a.y * b.z - a.z * b.y;\n quat.y = a.y * b.w + a.w * b.y + a.z * b.x - a.x * b.z;\n quat.z = a.z * b.w + a.w * b.z + a.x * b.y - a.y * b.x;\n quat.w = a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z;\n return quat;\n}\nvoid rotateVecFromQuat(inout vec3 v, vec4 q){\n float ix = q.w * v.x + q.y * v.z - q.z * v.y;\n float iy = q.w * v.y + q.z * v.x - q.x * v.z;\n float iz = q.w * v.z + q.x * v.y - q.y * v.x;\n float iw = -q.x * v.x - q.y * v.y - q.z * v.z;\n v.x = ix * q.w + iw * -q.x + iy * -q.z - iz * -q.y;\n v.y = iy * q.w + iw * -q.y + iz * -q.x - ix * -q.z;\n v.z = iz * q.w + iw * -q.z + ix * -q.y - iy * -q.x;\n}\nvec3 rotateInLocalSpace(vec3 pos, vec3 xAxis, vec3 yAxis, vec3 zAxis, vec4 q){\n float z = pos.z;\n float x = pos.x;\n float y = pos.y;\n vec4 viewQuat = quaternionFromAxis(xAxis, yAxis, zAxis);\n vec4 rotQuat = quatMultiply(viewQuat, q);\n rotateVecFromQuat(pos, rotQuat);\n return pos;\n}\nvoid rotateCorner(inout vec2 corner, float angle){\n float xOS = cos(angle) * corner.x - sin(angle) * corner.y;\n float yOS = sin(angle) * corner.x + cos(angle) * corner.y;\n corner.x = xOS;\n corner.y = yOS;\n}\nuniform vec4 mainTiling_Offset;\nuniform vec4 frameTile_velLenScale;\nuniform vec4 scale;\nuniform mat4 cc_matView;\nuniform mat4 cc_matViewInv;\nuniform mat4 cc_matViewProj;\nuniform vec4 cc_cameraPos;\nuniform mat4 cc_matWorld;\nvarying vec2 uv;\nvarying vec4 color;\nvoid computeVertPos(inout vec4 pos, vec2 vertOffset, vec4 q, vec3 s\n#if CC_USE_BILLBOARD || CC_USE_VERTICAL_BILLBOARD\n , mat4 viewInv\n#endif\n#if CC_USE_STRETCHED_BILLBOARD\n , vec3 eye\n , vec4 velocity\n , float velocityScale\n , float lengthScale\n , float xIndex\n#endif\n) {\n#if CC_USE_BILLBOARD\n vec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\n vec3 camX = normalize(vec3(viewInv[0][0], viewInv[1][0], viewInv[2][0]));\n vec3 camY = normalize(vec3(viewInv[0][1], viewInv[1][1], viewInv[2][1]));\n vec3 camZ = normalize(vec3(viewInv[0][2], viewInv[1][2], viewInv[2][2]));\n pos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, camZ, q);\n#elif CC_USE_STRETCHED_BILLBOARD\n vec3 camRight = normalize(cross(pos.xyz - eye, velocity.xyz)) * s.x;\n vec3 camUp = velocity.xyz * velocityScale + normalize(velocity.xyz) * lengthScale * s.y;\n pos.xyz += (camRight * abs(vertOffset.x) * sign(vertOffset.y)) - camUp * xIndex;\n#elif CC_USE_HORIZONTAL_BILLBOARD\n vec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\n vec3 camX = vec3(1, 0, 0);\n vec3 camY = vec3(0, 0, -1);\n pos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, cross(camX, camY), q);\n#elif CC_USE_VERTICAL_BILLBOARD\n vec2 viewSpaceVert = vec2(vertOffset.x * s.x, vertOffset.y * s.y);\n rotateCorner(viewSpaceVert, q.z);\n vec3 camX = normalize(vec3(cc_matView[0][0], cc_matView[1][0], cc_matView[2][0]));\n vec3 camY = vec3(0, 1, 0);\n vec3 offset = camX * viewSpaceVert.x + camY * viewSpaceVert.y;\n pos.xyz += offset;\n#else\n pos.x += vertOffset.x;\n pos.y += vertOffset.y;\n#endif\n}\nvec2 computeUV(float frameIndex, vec2 vertIndex, vec2 frameTile){\n vec2 aniUV = vec2(0, floor(frameIndex * frameTile.y));\n aniUV.x = floor(frameIndex * frameTile.x * frameTile.y - aniUV.y * frameTile.x);\n#if !CC_USE_MESH\n vertIndex.y = 1. - vertIndex.y;\n#endif\n return (aniUV.xy + vertIndex) / vec2(frameTile.x, frameTile.y);\n}\nattribute vec3 a_position;\nattribute vec3 a_texCoord;\nattribute vec3 a_texCoord1;\nattribute vec3 a_texCoord2;\nattribute vec4 a_color;\n#if CC_USE_STRETCHED_BILLBOARD\n attribute vec3 a_color1;\n#endif\n#if CC_USE_MESH\n attribute vec3 a_texCoord3;\n attribute vec3 a_normal;\n attribute vec4 a_color1;\n#endif\nvec4 lpvs_main() {\n vec3 compScale = scale.xyz * a_texCoord1;\n vec4 pos = vec4(a_position, 1);\n#if CC_USE_STRETCHED_BILLBOARD\n vec4 velocity = vec4(a_color1.xyz, 0);\n#endif\n#if !CC_USE_WORLD_SPACE\n pos = cc_matWorld * pos;\n #if CC_USE_STRETCHED_BILLBOARD\n velocity = cc_matWorld * velocity;\n #endif\n#endif\n#if !CC_USE_MESH\n vec2 cornerOffset = vec2((a_texCoord.xy - 0.5));\n #if CC_USE_BILLBOARD\n vec3 rotEuler = a_texCoord2;\n #elif CC_USE_STRETCHED_BILLBOARD\n vec3 rotEuler = vec3(0.);\n #else\n vec3 rotEuler = vec3(0., 0., a_texCoord2.z);\n #endif\n computeVertPos(pos, cornerOffset, quaternionFromEuler(rotEuler), compScale\n #if CC_USE_BILLBOARD || CC_USE_VERTICAL_BILLBOARD\n , cc_matViewInv\n #endif\n #if CC_USE_STRETCHED_BILLBOARD\n , cc_cameraPos.xyz\n , velocity\n , frameTile_velLenScale.z\n , frameTile_velLenScale.w\n , a_texCoord.x\n #endif\n );\n color = a_color;\n#else\n mat4 xformNoScale = matrixFromRT(quaternionFromEuler(a_texCoord2), pos.xyz);\n mat4 xform = matFromRTS(quaternionFromEuler(a_texCoord2), pos.xyz, compScale);\n pos = xform * vec4(a_texCoord3, 1);\n vec4 normal = xformNoScale * vec4(a_normal, 0);\n color = a_color * a_color1;\n#endif\n uv = computeUV(a_texCoord.z, a_texCoord.xy, frameTile_velLenScale.xy) * mainTiling_Offset.xy + mainTiling_Offset.zw;\n pos = cc_matViewProj * pos;\n return pos;\n}\nvoid main() { gl_Position = lpvs_main(); }", + "frag": "\nprecision highp float;\nvec4 CCFragOutput (vec4 color) {\n #if OUTPUT_TO_GAMMA\n color.rgb = sqrt(color.rgb);\n #endif\n\treturn color;\n}\nvarying vec2 uv;\nvarying vec4 color;\nuniform sampler2D mainTexture;\nvec4 addSmooth () {\n vec4 col = color * texture2D(mainTexture, uv);\n col.rgb *= col.a;\n return CCFragOutput(col);\n}\nvoid main() { gl_FragColor = addSmooth(); }" + }, + "builtins": { + "globals": { + "blocks": [ + { + "name": "CCGlobal", + "defines": [] + } + ], + "samplers": [] + }, + "locals": { + "blocks": [ + { + "name": "CCLocal", + "defines": [] + } + ], + "samplers": [] + } + }, + "defines": [ + { + "name": "CC_USE_BILLBOARD", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_STRETCHED_BILLBOARD", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_HORIZONTAL_BILLBOARD", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_VERTICAL_BILLBOARD", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_MESH", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_WORLD_SPACE", + "type": "boolean", + "defines": [] + }, + { + "name": "OUTPUT_TO_GAMMA", + "type": "boolean", + "defines": [] + } + ], + "blocks": [ + { + "name": "Constants", + "members": [ + { + "name": "mainTiling_Offset", + "type": 16, + "count": 1 + }, + { + "name": "frameTile_velLenScale", + "type": 16, + "count": 1 + }, + { + "name": "scale", + "type": 16, + "count": 1 + } + ], + "defines": [], + "binding": 0 + } + ], + "samplers": [ + { + "name": "mainTexture", + "type": 29, + "count": 1, + "defines": [], + "binding": 30 + } + ], + "record": null, + "name": "builtin-3d-particle|particle-vs-legacy:lpvs_main|no-tint-fs:addSmooth" + }, + { + "hash": 145387972, + "glsl3": { + "vert": "\nprecision highp float;\nvec4 quaternionFromAxis(vec3 xAxis,vec3 yAxis,vec3 zAxis){\n mat3 m = mat3(xAxis,yAxis,zAxis);\n float trace = m[0][0] + m[1][1] + m[2][2];\n vec4 quat;\n if (trace > 0.) {\n float s = 0.5 / sqrt(trace + 1.0);\n quat.w = 0.25 / s;\n quat.x = (m[2][1] - m[1][2]) * s;\n quat.y = (m[0][2] - m[2][0]) * s;\n quat.z = (m[1][0] - m[0][1]) * s;\n } else if ((m[0][0] > m[1][1]) && (m[0][0] > m[2][2])) {\n float s = 2.0 * sqrt(1.0 + m[0][0] - m[1][1] - m[2][2]);\n quat.w = (m[2][1] - m[1][2]) / s;\n quat.x = 0.25 * s;\n quat.y = (m[0][1] + m[1][0]) / s;\n quat.z = (m[0][2] + m[2][0]) / s;\n } else if (m[1][1] > m[2][2]) {\n float s = 2.0 * sqrt(1.0 + m[1][1] - m[0][0] - m[2][2]);\n quat.w = (m[0][2] - m[2][0]) / s;\n quat.x = (m[0][1] + m[1][0]) / s;\n quat.y = 0.25 * s;\n quat.z = (m[1][2] + m[2][1]) / s;\n } else {\n float s = 2.0 * sqrt(1.0 + m[2][2] - m[0][0] - m[1][1]);\n quat.w = (m[1][0] - m[0][1]) / s;\n quat.x = (m[0][2] + m[2][0]) / s;\n quat.y = (m[1][2] + m[2][1]) / s;\n quat.z = 0.25 * s;\n }\n float len = quat.x * quat.x + quat.y * quat.y + quat.z * quat.z + quat.w * quat.w;\n if (len > 0.) {\n len = 1. / sqrt(len);\n quat.x = quat.x * len;\n quat.y = quat.y * len;\n quat.z = quat.z * len;\n quat.w = quat.w * len;\n }\n return quat;\n}\nvec4 quaternionFromEuler(vec3 angle){\n float x = angle.x / 2.;\n float y = angle.y / 2.;\n float z = angle.z / 2.;\n float sx = sin(x);\n float cx = cos(x);\n float sy = sin(y);\n float cy = cos(y);\n float sz = sin(z);\n float cz = cos(z);\n vec4 quat = vec4(0);\n quat.x = sx * cy * cz + cx * sy * sz;\n quat.y = cx * sy * cz + sx * cy * sz;\n quat.z = cx * cy * sz - sx * sy * cz;\n quat.w = cx * cy * cz - sx * sy * sz;\n return quat;\n}\nmat4 matrixFromRT(vec4 q, vec3 p){\n float x2 = q.x + q.x;\n float y2 = q.y + q.y;\n float z2 = q.z + q.z;\n float xx = q.x * x2;\n float xy = q.x * y2;\n float xz = q.x * z2;\n float yy = q.y * y2;\n float yz = q.y * z2;\n float zz = q.z * z2;\n float wx = q.w * x2;\n float wy = q.w * y2;\n float wz = q.w * z2;\n return mat4(\n 1. - (yy + zz), xy + wz, xz - wy, 0,\n xy - wz, 1. - (xx + zz), yz + wx, 0,\n xz + wy, yz - wx, 1. - (xx + yy), 0,\n p.x, p.y, p.z, 1\n );\n}\nmat4 matFromRTS(vec4 q, vec3 t, vec3 s){\n float x = q.x, y = q.y, z = q.z, w = q.w;\n float x2 = x + x;\n float y2 = y + y;\n float z2 = z + z;\n float xx = x * x2;\n float xy = x * y2;\n float xz = x * z2;\n float yy = y * y2;\n float yz = y * z2;\n float zz = z * z2;\n float wx = w * x2;\n float wy = w * y2;\n float wz = w * z2;\n float sx = s.x;\n float sy = s.y;\n float sz = s.z;\n return mat4((1. - (yy + zz)) * sx, (xy + wz) * sx, (xz - wy) * sx, 0,\n (xy - wz) * sy, (1. - (xx + zz)) * sy, (yz + wx) * sy, 0,\n (xz + wy) * sz, (yz - wx) * sz, (1. - (xx + yy)) * sz, 0,\n t.x, t.y, t.z, 1);\n}\nvec4 quatMultiply(vec4 a, vec4 b){\n vec4 quat;\n quat.x = a.x * b.w + a.w * b.x + a.y * b.z - a.z * b.y;\n quat.y = a.y * b.w + a.w * b.y + a.z * b.x - a.x * b.z;\n quat.z = a.z * b.w + a.w * b.z + a.x * b.y - a.y * b.x;\n quat.w = a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z;\n return quat;\n}\nvoid rotateVecFromQuat(inout vec3 v, vec4 q){\n float ix = q.w * v.x + q.y * v.z - q.z * v.y;\n float iy = q.w * v.y + q.z * v.x - q.x * v.z;\n float iz = q.w * v.z + q.x * v.y - q.y * v.x;\n float iw = -q.x * v.x - q.y * v.y - q.z * v.z;\n v.x = ix * q.w + iw * -q.x + iy * -q.z - iz * -q.y;\n v.y = iy * q.w + iw * -q.y + iz * -q.x - ix * -q.z;\n v.z = iz * q.w + iw * -q.z + ix * -q.y - iy * -q.x;\n}\nvec3 rotateInLocalSpace(vec3 pos, vec3 xAxis, vec3 yAxis, vec3 zAxis, vec4 q){\n float z = pos.z;\n float x = pos.x;\n float y = pos.y;\n vec4 viewQuat = quaternionFromAxis(xAxis, yAxis, zAxis);\n vec4 rotQuat = quatMultiply(viewQuat, q);\n rotateVecFromQuat(pos, rotQuat);\n return pos;\n}\nvoid rotateCorner(inout vec2 corner, float angle){\n float xOS = cos(angle) * corner.x - sin(angle) * corner.y;\n float yOS = sin(angle) * corner.x + cos(angle) * corner.y;\n corner.x = xOS;\n corner.y = yOS;\n}\nuniform Constants{\n vec4 mainTiling_Offset;\n vec4 frameTile_velLenScale;\n vec4 scale;\n};\nuniform CCGlobal {\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\nuniform CCLocal {\n mat4 cc_matWorld;\n mat4 cc_matWorldIT;\n};\nout vec2 uv;\nout vec4 color;\nvoid computeVertPos(inout vec4 pos, vec2 vertOffset, vec4 q, vec3 s\n#if CC_USE_BILLBOARD || CC_USE_VERTICAL_BILLBOARD\n , mat4 viewInv\n#endif\n#if CC_USE_STRETCHED_BILLBOARD\n , vec3 eye\n , vec4 velocity\n , float velocityScale\n , float lengthScale\n , float xIndex\n#endif\n) {\n#if CC_USE_BILLBOARD\n vec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\n vec3 camX = normalize(vec3(viewInv[0][0], viewInv[1][0], viewInv[2][0]));\n vec3 camY = normalize(vec3(viewInv[0][1], viewInv[1][1], viewInv[2][1]));\n vec3 camZ = normalize(vec3(viewInv[0][2], viewInv[1][2], viewInv[2][2]));\n pos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, camZ, q);\n#elif CC_USE_STRETCHED_BILLBOARD\n vec3 camRight = normalize(cross(pos.xyz - eye, velocity.xyz)) * s.x;\n vec3 camUp = velocity.xyz * velocityScale + normalize(velocity.xyz) * lengthScale * s.y;\n pos.xyz += (camRight * abs(vertOffset.x) * sign(vertOffset.y)) - camUp * xIndex;\n#elif CC_USE_HORIZONTAL_BILLBOARD\n vec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\n vec3 camX = vec3(1, 0, 0);\n vec3 camY = vec3(0, 0, -1);\n pos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, cross(camX, camY), q);\n#elif CC_USE_VERTICAL_BILLBOARD\n vec2 viewSpaceVert = vec2(vertOffset.x * s.x, vertOffset.y * s.y);\n rotateCorner(viewSpaceVert, q.z);\n vec3 camX = normalize(vec3(cc_matView[0][0], cc_matView[1][0], cc_matView[2][0]));\n vec3 camY = vec3(0, 1, 0);\n vec3 offset = camX * viewSpaceVert.x + camY * viewSpaceVert.y;\n pos.xyz += offset;\n#else\n pos.x += vertOffset.x;\n pos.y += vertOffset.y;\n#endif\n}\nvec2 computeUV(float frameIndex, vec2 vertIndex, vec2 frameTile){\n vec2 aniUV = vec2(0, floor(frameIndex * frameTile.y));\n aniUV.x = floor(frameIndex * frameTile.x * frameTile.y - aniUV.y * frameTile.x);\n#if !CC_USE_MESH\n vertIndex.y = 1. - vertIndex.y;\n#endif\n return (aniUV.xy + vertIndex) / vec2(frameTile.x, frameTile.y);\n}\nin vec3 a_position;\nin vec3 a_texCoord;\nin vec3 a_texCoord1;\nin vec3 a_texCoord2;\nin vec4 a_color;\n#if CC_USE_STRETCHED_BILLBOARD\n in vec3 a_color1;\n#endif\n#if CC_USE_MESH\n in vec3 a_texCoord3;\n in vec3 a_normal;\n in vec4 a_color1;\n#endif\nvec4 lpvs_main() {\n vec3 compScale = scale.xyz * a_texCoord1;\n vec4 pos = vec4(a_position, 1);\n#if CC_USE_STRETCHED_BILLBOARD\n vec4 velocity = vec4(a_color1.xyz, 0);\n#endif\n#if !CC_USE_WORLD_SPACE\n pos = cc_matWorld * pos;\n #if CC_USE_STRETCHED_BILLBOARD\n velocity = cc_matWorld * velocity;\n #endif\n#endif\n#if !CC_USE_MESH\n vec2 cornerOffset = vec2((a_texCoord.xy - 0.5));\n #if CC_USE_BILLBOARD\n vec3 rotEuler = a_texCoord2;\n #elif CC_USE_STRETCHED_BILLBOARD\n vec3 rotEuler = vec3(0.);\n #else\n vec3 rotEuler = vec3(0., 0., a_texCoord2.z);\n #endif\n computeVertPos(pos, cornerOffset, quaternionFromEuler(rotEuler), compScale\n #if CC_USE_BILLBOARD || CC_USE_VERTICAL_BILLBOARD\n , cc_matViewInv\n #endif\n #if CC_USE_STRETCHED_BILLBOARD\n , cc_cameraPos.xyz\n , velocity\n , frameTile_velLenScale.z\n , frameTile_velLenScale.w\n , a_texCoord.x\n #endif\n );\n color = a_color;\n#else\n mat4 xformNoScale = matrixFromRT(quaternionFromEuler(a_texCoord2), pos.xyz);\n mat4 xform = matFromRTS(quaternionFromEuler(a_texCoord2), pos.xyz, compScale);\n pos = xform * vec4(a_texCoord3, 1);\n vec4 normal = xformNoScale * vec4(a_normal, 0);\n color = a_color * a_color1;\n#endif\n uv = computeUV(a_texCoord.z, a_texCoord.xy, frameTile_velLenScale.xy) * mainTiling_Offset.xy + mainTiling_Offset.zw;\n pos = cc_matViewProj * pos;\n return pos;\n}\nvoid main() { gl_Position = lpvs_main(); }", + "frag": "\nprecision highp float;\nvec4 CCFragOutput (vec4 color) {\n #if OUTPUT_TO_GAMMA\n color.rgb = sqrt(color.rgb);\n #endif\n\treturn color;\n}\nin vec2 uv;\nin vec4 color;\nuniform sampler2D mainTexture;\nvec4 premultiplied () {\n vec4 col = color * texture(mainTexture, uv) * color.a;\n return CCFragOutput(col);\n}\nout vec4 cc_FragColor;\nvoid main() { cc_FragColor = premultiplied(); }" + }, + "glsl1": { + "vert": "\nprecision highp float;\nvec4 quaternionFromAxis(vec3 xAxis,vec3 yAxis,vec3 zAxis){\n mat3 m = mat3(xAxis,yAxis,zAxis);\n float trace = m[0][0] + m[1][1] + m[2][2];\n vec4 quat;\n if (trace > 0.) {\n float s = 0.5 / sqrt(trace + 1.0);\n quat.w = 0.25 / s;\n quat.x = (m[2][1] - m[1][2]) * s;\n quat.y = (m[0][2] - m[2][0]) * s;\n quat.z = (m[1][0] - m[0][1]) * s;\n } else if ((m[0][0] > m[1][1]) && (m[0][0] > m[2][2])) {\n float s = 2.0 * sqrt(1.0 + m[0][0] - m[1][1] - m[2][2]);\n quat.w = (m[2][1] - m[1][2]) / s;\n quat.x = 0.25 * s;\n quat.y = (m[0][1] + m[1][0]) / s;\n quat.z = (m[0][2] + m[2][0]) / s;\n } else if (m[1][1] > m[2][2]) {\n float s = 2.0 * sqrt(1.0 + m[1][1] - m[0][0] - m[2][2]);\n quat.w = (m[0][2] - m[2][0]) / s;\n quat.x = (m[0][1] + m[1][0]) / s;\n quat.y = 0.25 * s;\n quat.z = (m[1][2] + m[2][1]) / s;\n } else {\n float s = 2.0 * sqrt(1.0 + m[2][2] - m[0][0] - m[1][1]);\n quat.w = (m[1][0] - m[0][1]) / s;\n quat.x = (m[0][2] + m[2][0]) / s;\n quat.y = (m[1][2] + m[2][1]) / s;\n quat.z = 0.25 * s;\n }\n float len = quat.x * quat.x + quat.y * quat.y + quat.z * quat.z + quat.w * quat.w;\n if (len > 0.) {\n len = 1. / sqrt(len);\n quat.x = quat.x * len;\n quat.y = quat.y * len;\n quat.z = quat.z * len;\n quat.w = quat.w * len;\n }\n return quat;\n}\nvec4 quaternionFromEuler(vec3 angle){\n float x = angle.x / 2.;\n float y = angle.y / 2.;\n float z = angle.z / 2.;\n float sx = sin(x);\n float cx = cos(x);\n float sy = sin(y);\n float cy = cos(y);\n float sz = sin(z);\n float cz = cos(z);\n vec4 quat = vec4(0);\n quat.x = sx * cy * cz + cx * sy * sz;\n quat.y = cx * sy * cz + sx * cy * sz;\n quat.z = cx * cy * sz - sx * sy * cz;\n quat.w = cx * cy * cz - sx * sy * sz;\n return quat;\n}\nmat4 matrixFromRT(vec4 q, vec3 p){\n float x2 = q.x + q.x;\n float y2 = q.y + q.y;\n float z2 = q.z + q.z;\n float xx = q.x * x2;\n float xy = q.x * y2;\n float xz = q.x * z2;\n float yy = q.y * y2;\n float yz = q.y * z2;\n float zz = q.z * z2;\n float wx = q.w * x2;\n float wy = q.w * y2;\n float wz = q.w * z2;\n return mat4(\n 1. - (yy + zz), xy + wz, xz - wy, 0,\n xy - wz, 1. - (xx + zz), yz + wx, 0,\n xz + wy, yz - wx, 1. - (xx + yy), 0,\n p.x, p.y, p.z, 1\n );\n}\nmat4 matFromRTS(vec4 q, vec3 t, vec3 s){\n float x = q.x, y = q.y, z = q.z, w = q.w;\n float x2 = x + x;\n float y2 = y + y;\n float z2 = z + z;\n float xx = x * x2;\n float xy = x * y2;\n float xz = x * z2;\n float yy = y * y2;\n float yz = y * z2;\n float zz = z * z2;\n float wx = w * x2;\n float wy = w * y2;\n float wz = w * z2;\n float sx = s.x;\n float sy = s.y;\n float sz = s.z;\n return mat4((1. - (yy + zz)) * sx, (xy + wz) * sx, (xz - wy) * sx, 0,\n (xy - wz) * sy, (1. - (xx + zz)) * sy, (yz + wx) * sy, 0,\n (xz + wy) * sz, (yz - wx) * sz, (1. - (xx + yy)) * sz, 0,\n t.x, t.y, t.z, 1);\n}\nvec4 quatMultiply(vec4 a, vec4 b){\n vec4 quat;\n quat.x = a.x * b.w + a.w * b.x + a.y * b.z - a.z * b.y;\n quat.y = a.y * b.w + a.w * b.y + a.z * b.x - a.x * b.z;\n quat.z = a.z * b.w + a.w * b.z + a.x * b.y - a.y * b.x;\n quat.w = a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z;\n return quat;\n}\nvoid rotateVecFromQuat(inout vec3 v, vec4 q){\n float ix = q.w * v.x + q.y * v.z - q.z * v.y;\n float iy = q.w * v.y + q.z * v.x - q.x * v.z;\n float iz = q.w * v.z + q.x * v.y - q.y * v.x;\n float iw = -q.x * v.x - q.y * v.y - q.z * v.z;\n v.x = ix * q.w + iw * -q.x + iy * -q.z - iz * -q.y;\n v.y = iy * q.w + iw * -q.y + iz * -q.x - ix * -q.z;\n v.z = iz * q.w + iw * -q.z + ix * -q.y - iy * -q.x;\n}\nvec3 rotateInLocalSpace(vec3 pos, vec3 xAxis, vec3 yAxis, vec3 zAxis, vec4 q){\n float z = pos.z;\n float x = pos.x;\n float y = pos.y;\n vec4 viewQuat = quaternionFromAxis(xAxis, yAxis, zAxis);\n vec4 rotQuat = quatMultiply(viewQuat, q);\n rotateVecFromQuat(pos, rotQuat);\n return pos;\n}\nvoid rotateCorner(inout vec2 corner, float angle){\n float xOS = cos(angle) * corner.x - sin(angle) * corner.y;\n float yOS = sin(angle) * corner.x + cos(angle) * corner.y;\n corner.x = xOS;\n corner.y = yOS;\n}\nuniform vec4 mainTiling_Offset;\nuniform vec4 frameTile_velLenScale;\nuniform vec4 scale;\nuniform mat4 cc_matView;\nuniform mat4 cc_matViewInv;\nuniform mat4 cc_matViewProj;\nuniform vec4 cc_cameraPos;\nuniform mat4 cc_matWorld;\nvarying vec2 uv;\nvarying vec4 color;\nvoid computeVertPos(inout vec4 pos, vec2 vertOffset, vec4 q, vec3 s\n#if CC_USE_BILLBOARD || CC_USE_VERTICAL_BILLBOARD\n , mat4 viewInv\n#endif\n#if CC_USE_STRETCHED_BILLBOARD\n , vec3 eye\n , vec4 velocity\n , float velocityScale\n , float lengthScale\n , float xIndex\n#endif\n) {\n#if CC_USE_BILLBOARD\n vec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\n vec3 camX = normalize(vec3(viewInv[0][0], viewInv[1][0], viewInv[2][0]));\n vec3 camY = normalize(vec3(viewInv[0][1], viewInv[1][1], viewInv[2][1]));\n vec3 camZ = normalize(vec3(viewInv[0][2], viewInv[1][2], viewInv[2][2]));\n pos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, camZ, q);\n#elif CC_USE_STRETCHED_BILLBOARD\n vec3 camRight = normalize(cross(pos.xyz - eye, velocity.xyz)) * s.x;\n vec3 camUp = velocity.xyz * velocityScale + normalize(velocity.xyz) * lengthScale * s.y;\n pos.xyz += (camRight * abs(vertOffset.x) * sign(vertOffset.y)) - camUp * xIndex;\n#elif CC_USE_HORIZONTAL_BILLBOARD\n vec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\n vec3 camX = vec3(1, 0, 0);\n vec3 camY = vec3(0, 0, -1);\n pos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, cross(camX, camY), q);\n#elif CC_USE_VERTICAL_BILLBOARD\n vec2 viewSpaceVert = vec2(vertOffset.x * s.x, vertOffset.y * s.y);\n rotateCorner(viewSpaceVert, q.z);\n vec3 camX = normalize(vec3(cc_matView[0][0], cc_matView[1][0], cc_matView[2][0]));\n vec3 camY = vec3(0, 1, 0);\n vec3 offset = camX * viewSpaceVert.x + camY * viewSpaceVert.y;\n pos.xyz += offset;\n#else\n pos.x += vertOffset.x;\n pos.y += vertOffset.y;\n#endif\n}\nvec2 computeUV(float frameIndex, vec2 vertIndex, vec2 frameTile){\n vec2 aniUV = vec2(0, floor(frameIndex * frameTile.y));\n aniUV.x = floor(frameIndex * frameTile.x * frameTile.y - aniUV.y * frameTile.x);\n#if !CC_USE_MESH\n vertIndex.y = 1. - vertIndex.y;\n#endif\n return (aniUV.xy + vertIndex) / vec2(frameTile.x, frameTile.y);\n}\nattribute vec3 a_position;\nattribute vec3 a_texCoord;\nattribute vec3 a_texCoord1;\nattribute vec3 a_texCoord2;\nattribute vec4 a_color;\n#if CC_USE_STRETCHED_BILLBOARD\n attribute vec3 a_color1;\n#endif\n#if CC_USE_MESH\n attribute vec3 a_texCoord3;\n attribute vec3 a_normal;\n attribute vec4 a_color1;\n#endif\nvec4 lpvs_main() {\n vec3 compScale = scale.xyz * a_texCoord1;\n vec4 pos = vec4(a_position, 1);\n#if CC_USE_STRETCHED_BILLBOARD\n vec4 velocity = vec4(a_color1.xyz, 0);\n#endif\n#if !CC_USE_WORLD_SPACE\n pos = cc_matWorld * pos;\n #if CC_USE_STRETCHED_BILLBOARD\n velocity = cc_matWorld * velocity;\n #endif\n#endif\n#if !CC_USE_MESH\n vec2 cornerOffset = vec2((a_texCoord.xy - 0.5));\n #if CC_USE_BILLBOARD\n vec3 rotEuler = a_texCoord2;\n #elif CC_USE_STRETCHED_BILLBOARD\n vec3 rotEuler = vec3(0.);\n #else\n vec3 rotEuler = vec3(0., 0., a_texCoord2.z);\n #endif\n computeVertPos(pos, cornerOffset, quaternionFromEuler(rotEuler), compScale\n #if CC_USE_BILLBOARD || CC_USE_VERTICAL_BILLBOARD\n , cc_matViewInv\n #endif\n #if CC_USE_STRETCHED_BILLBOARD\n , cc_cameraPos.xyz\n , velocity\n , frameTile_velLenScale.z\n , frameTile_velLenScale.w\n , a_texCoord.x\n #endif\n );\n color = a_color;\n#else\n mat4 xformNoScale = matrixFromRT(quaternionFromEuler(a_texCoord2), pos.xyz);\n mat4 xform = matFromRTS(quaternionFromEuler(a_texCoord2), pos.xyz, compScale);\n pos = xform * vec4(a_texCoord3, 1);\n vec4 normal = xformNoScale * vec4(a_normal, 0);\n color = a_color * a_color1;\n#endif\n uv = computeUV(a_texCoord.z, a_texCoord.xy, frameTile_velLenScale.xy) * mainTiling_Offset.xy + mainTiling_Offset.zw;\n pos = cc_matViewProj * pos;\n return pos;\n}\nvoid main() { gl_Position = lpvs_main(); }", + "frag": "\nprecision highp float;\nvec4 CCFragOutput (vec4 color) {\n #if OUTPUT_TO_GAMMA\n color.rgb = sqrt(color.rgb);\n #endif\n\treturn color;\n}\nvarying vec2 uv;\nvarying vec4 color;\nuniform sampler2D mainTexture;\nvec4 premultiplied () {\n vec4 col = color * texture2D(mainTexture, uv) * color.a;\n return CCFragOutput(col);\n}\nvoid main() { gl_FragColor = premultiplied(); }" + }, + "builtins": { + "globals": { + "blocks": [ + { + "name": "CCGlobal", + "defines": [] + } + ], + "samplers": [] + }, + "locals": { + "blocks": [ + { + "name": "CCLocal", + "defines": [] + } + ], + "samplers": [] + } + }, + "defines": [ + { + "name": "CC_USE_BILLBOARD", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_STRETCHED_BILLBOARD", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_HORIZONTAL_BILLBOARD", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_VERTICAL_BILLBOARD", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_MESH", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_WORLD_SPACE", + "type": "boolean", + "defines": [] + }, + { + "name": "OUTPUT_TO_GAMMA", + "type": "boolean", + "defines": [] + } + ], + "blocks": [ + { + "name": "Constants", + "members": [ + { + "name": "mainTiling_Offset", + "type": 16, + "count": 1 + }, + { + "name": "frameTile_velLenScale", + "type": 16, + "count": 1 + }, + { + "name": "scale", + "type": 16, + "count": 1 + } + ], + "defines": [], + "binding": 0 + } + ], + "samplers": [ + { + "name": "mainTexture", + "type": 29, + "count": 1, + "defines": [], + "binding": 30 + } + ], + "record": null, + "name": "builtin-3d-particle|particle-vs-legacy:lpvs_main|no-tint-fs:premultiplied" + } + ] +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/83/83f5eff8-3385-4f95-9b76-8da0aa1d96cd.bin b/Layered_virtual_list_2.x/library/imports/83/83f5eff8-3385-4f95-9b76-8da0aa1d96cd.bin new file mode 100644 index 0000000..fd7f98c Binary files /dev/null and b/Layered_virtual_list_2.x/library/imports/83/83f5eff8-3385-4f95-9b76-8da0aa1d96cd.bin differ diff --git a/Layered_virtual_list_2.x/library/imports/83/83f5eff8-3385-4f95-9b76-8da0aa1d96cd.json b/Layered_virtual_list_2.x/library/imports/83/83f5eff8-3385-4f95-9b76-8da0aa1d96cd.json new file mode 100644 index 0000000..c7ff387 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/83/83f5eff8-3385-4f95-9b76-8da0aa1d96cd.json @@ -0,0 +1,90 @@ +[ + { + "__type__": "cc.Mesh", + "_name": "", + "_objFlags": 0, + "_native": ".bin", + "_vertexBundles": [ + { + "__id__": 1 + } + ], + "_primitives": [ + { + "__id__": 6 + } + ], + "_minPos": { + "__type__": "cc.Vec3", + "x": -0.5, + "y": -1, + "z": -0.5 + }, + "_maxPos": { + "__type__": "cc.Vec3", + "x": 0.5, + "y": 1, + "z": 0.5 + } + }, + { + "__type__": "cc.mesh.VertexBundle", + "data": { + "__id__": 2 + }, + "formats": [ + { + "__id__": 3 + }, + { + "__id__": 4 + }, + { + "__id__": 5 + } + ], + "verticesCount": 1155 + }, + { + "__type__": "cc.BufferRange", + "offset": 0, + "length": 36960 + }, + { + "__type__": "cc.mesh.VertexFormat", + "name": "a_normal", + "type": 5126, + "num": 3, + "normalize": false + }, + { + "__type__": "cc.mesh.VertexFormat", + "name": "a_position", + "type": 5126, + "num": 3, + "normalize": false + }, + { + "__type__": "cc.mesh.VertexFormat", + "name": "a_uv0", + "type": 5126, + "num": 2, + "normalize": false + }, + { + "__type__": "cc.mesh.Primitive", + "vertexBundleIndices": [ + 0 + ], + "data": { + "__id__": 7 + }, + "indexUnit": 5123, + "topology": 4 + }, + { + "__type__": "cc.BufferRange", + "offset": 36960, + "length": 12288 + } +] \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/88/88e79fd5-96b4-4a77-a1f4-312467171014.json b/Layered_virtual_list_2.x/library/imports/88/88e79fd5-96b4-4a77-a1f4-312467171014.json new file mode 100644 index 0000000..f211a73 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/88/88e79fd5-96b4-4a77-a1f4-312467171014.json @@ -0,0 +1,28 @@ +{ + "__type__": "cc.SpriteFrame", + "content": { + "name": "default_progressbar_bg", + "texture": "99170b0b-d210-46f1-b213-7d9e3f23098a", + "atlas": "", + "rect": [ + 0, + 0, + 60, + 15 + ], + "offset": [ + 0, + 0 + ], + "originalSize": [ + 60, + 15 + ], + "capInsets": [ + 10, + 4, + 10, + 4 + ] + } +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/89/897ef7a1-4860-4f64-968d-f5924b18668a.json b/Layered_virtual_list_2.x/library/imports/89/897ef7a1-4860-4f64-968d-f5924b18668a.json new file mode 100644 index 0000000..9579ab7 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/89/897ef7a1-4860-4f64-968d-f5924b18668a.json @@ -0,0 +1,123 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "2d-camera", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "asyncLoadAssets": false, + "readonly": false + }, + { + "__type__": "cc.Node", + "_name": "2D Camera", + "_objFlags": 0, + "_parent": null, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 2 + } + ], + "_prefab": { + "__id__": 3 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 554.2562584220408, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Camera", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "_cullingMask": 4294967295, + "_clearFlags": 6, + "_backgroundColor": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_depth": 0, + "_zoomRatio": 1, + "_targetTexture": null, + "_fov": 60, + "_orthoSize": 10, + "_nearClip": 0.1, + "_farClip": 4096, + "_ortho": true, + "_rect": { + "__type__": "cc.Rect", + "x": 0, + "y": 0, + "width": 1, + "height": 1 + }, + "_renderStages": 1, + "_alignWithScreen": true, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "897ef7a1-4860-4f64-968d-f5924b18668a" + }, + "fileId": "abdJ5/jGlPzq+iDQghzEti", + "sync": false + } +] \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/8a/8a96b965-2dc0-4e03-aa90-3b79cb93b5b4.json b/Layered_virtual_list_2.x/library/imports/8a/8a96b965-2dc0-4e03-aa90-3b79cb93b5b4.json new file mode 100644 index 0000000..e7522d6 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/8a/8a96b965-2dc0-4e03-aa90-3b79cb93b5b4.json @@ -0,0 +1,4 @@ +{ + "__type__": "cc.Texture2D", + "content": "0,9729,9729,33071,33071,0,0,1" +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/8a/8a96b965-2dc0-4e03-aa90-3b79cb93b5b4.png b/Layered_virtual_list_2.x/library/imports/8a/8a96b965-2dc0-4e03-aa90-3b79cb93b5b4.png new file mode 100644 index 0000000..ff833c2 Binary files /dev/null and b/Layered_virtual_list_2.x/library/imports/8a/8a96b965-2dc0-4e03-aa90-3b79cb93b5b4.png differ diff --git a/Layered_virtual_list_2.x/library/imports/8c/8c5001fd-07ee-4a4b-a8a0-63e15195e94d.json b/Layered_virtual_list_2.x/library/imports/8c/8c5001fd-07ee-4a4b-a8a0-63e15195e94d.json new file mode 100644 index 0000000..6236241 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/8c/8c5001fd-07ee-4a4b-a8a0-63e15195e94d.json @@ -0,0 +1,100 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "webview", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 1, + "asyncLoadAssets": false, + "readonly": false + }, + { + "__type__": "cc.Node", + "_name": "webview", + "_objFlags": 0, + "_parent": null, + "_children": [], + "_active": true, + "_level": 1, + "_components": [ + { + "__id__": 2 + } + ], + "_prefab": { + "__id__": 3 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 300, + "height": 200 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_skewX": 0, + "_skewY": 0, + "_localZOrder": 55, + "groupIndex": 0, + "_id": "", + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.WebView", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "_useOriginalSize": false, + "_url": "", + "webviewEvents": [], + "_id": "12QHFUfdhF+4w/zU5gB7ZI" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "8c5001fd-07ee-4a4b-a8a0-63e15195e94d" + }, + "fileId": "2fb356PwclC8L2CbHhqGUVr", + "sync": false + } +] \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/8c/8cdb44ac-a3f6-449f-b354-7cd48cf84061.json b/Layered_virtual_list_2.x/library/imports/8c/8cdb44ac-a3f6-449f-b354-7cd48cf84061.json new file mode 100644 index 0000000..1a0da16 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/8c/8cdb44ac-a3f6-449f-b354-7cd48cf84061.json @@ -0,0 +1,28 @@ +{ + "__type__": "cc.SpriteFrame", + "content": { + "name": "default_sprite", + "texture": "6e056173-d285-473c-b206-40a7fff5386e", + "atlas": "", + "rect": [ + 0, + 2, + 40, + 36 + ], + "offset": [ + 0, + 0 + ], + "originalSize": [ + 40, + 40 + ], + "capInsets": [ + 0, + 0, + 0, + 0 + ] + } +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/90/90004ad6-2f6d-40e1-93ef-b714375c6f06.json b/Layered_virtual_list_2.x/library/imports/90/90004ad6-2f6d-40e1-93ef-b714375c6f06.json new file mode 100644 index 0000000..398992c --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/90/90004ad6-2f6d-40e1-93ef-b714375c6f06.json @@ -0,0 +1,28 @@ +{ + "__type__": "cc.SpriteFrame", + "content": { + "name": "default_toggle_checkmark", + "texture": "73a0903d-d80e-4e3c-aa67-f999543c08f5", + "atlas": "", + "rect": [ + 4, + 5, + 20, + 18 + ], + "offset": [ + 0, + 0 + ], + "originalSize": [ + 28, + 28 + ], + "capInsets": [ + 0, + 0, + 0, + 0 + ] + } +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/95/954fec8b-cd16-4bb9-a3b7-7719660e7558.json b/Layered_virtual_list_2.x/library/imports/95/954fec8b-cd16-4bb9-a3b7-7719660e7558.json new file mode 100644 index 0000000..a8f65d3 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/95/954fec8b-cd16-4bb9-a3b7-7719660e7558.json @@ -0,0 +1,215 @@ +{ + "__type__": "cc.Model", + "_name": "primitives", + "_objFlags": 0, + "_native": "", + "_nodes": [ + { + "name": "RootNode", + "scale": [ + 1, + 1, + 1 + ], + "children": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8 + ], + "position": [ + 0, + 0, + 0 + ], + "quat": [ + 0, + 0, + 0, + 1 + ], + "path": "" + }, + { + "name": "capsule", + "scale": [ + 100, + 100, + 100 + ], + "mesh": 0, + "parent": null, + "position": [ + 0, + 0, + 0 + ], + "quat": [ + 8.14603353660459e-8, + 0, + 0, + 1 + ], + "path": "capsule" + }, + { + "name": "plane", + "scale": [ + 100, + 100, + 100 + ], + "mesh": 1, + "parent": null, + "position": [ + 0, + 0, + 0 + ], + "quat": [ + 8.14603353660459e-8, + 0, + 0, + 1 + ], + "path": "plane" + }, + { + "name": "cone", + "scale": [ + 100, + 100, + 100 + ], + "mesh": 2, + "parent": null, + "position": [ + 0, + 0, + 0 + ], + "quat": [ + -0.707106828689575, + 0, + 0, + 0.707106709480286 + ], + "path": "cone" + }, + { + "name": "torus", + "scale": [ + 100, + 100, + 100 + ], + "mesh": 3, + "parent": null, + "position": [ + 0, + 0, + 0 + ], + "quat": [ + 8.14603353660459e-8, + 0, + 0, + 1 + ], + "path": "torus" + }, + { + "name": "sphere", + "scale": [ + 100, + 100, + 100 + ], + "mesh": 4, + "parent": null, + "position": [ + 0, + 0, + 0 + ], + "quat": [ + 8.14603353660459e-8, + 0, + 0, + 1 + ], + "path": "sphere" + }, + { + "name": "quad", + "scale": [ + 100, + 100, + 100 + ], + "mesh": 5, + "parent": null, + "position": [ + 0, + 0, + 0 + ], + "quat": [ + 8.14603353660459e-8, + 0, + 0, + 1 + ], + "path": "quad" + }, + { + "name": "cylinder", + "scale": [ + 100, + 100, + 100 + ], + "mesh": 6, + "parent": null, + "position": [ + 0, + 0, + 0 + ], + "quat": [ + 8.14603353660459e-8, + 0, + 0, + 1 + ], + "path": "cylinder" + }, + { + "name": "box", + "scale": [ + 100, + 100, + 100 + ], + "mesh": 7, + "parent": null, + "position": [ + 0, + 0, + 0 + ], + "quat": [ + 8.14603353660459e-8, + 0, + 0, + 1 + ], + "path": "box" + } + ], + "_precomputeJointMatrix": false +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/96/96083d03-c332-4a3f-9386-d03e2d19e8ee.json b/Layered_virtual_list_2.x/library/imports/96/96083d03-c332-4a3f-9386-d03e2d19e8ee.json new file mode 100644 index 0000000..18f8c2c --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/96/96083d03-c332-4a3f-9386-d03e2d19e8ee.json @@ -0,0 +1,112 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "sprite", + "_objFlags": 0, + "data": { + "__id__": 1 + }, + "optimizationPolicy": 1, + "asyncLoadAssets": false, + "readonly": false + }, + { + "__type__": "cc.Node", + "_name": "Sprite", + "_objFlags": 0, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_cascadeOpacityEnabled": true, + "_parent": null, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 40, + "height": 36 + }, + "_children": [], + "_skewX": 0, + "_skewY": 0, + "_localZOrder": 0, + "_globalZOrder": 0, + "_tag": -1, + "_opacityModifyRGB": false, + "_reorderChildDirty": false, + "_id": "", + "_active": true, + "_components": [ + { + "__id__": 2 + } + ], + "_prefab": { + "__id__": 3 + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "_spriteFrame": { + "__uuid__": "8cdb44ac-a3f6-449f-b354-7cd48cf84061" + }, + "_type": 0, + "_sizeMode": 1, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_atlas": null + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": null, + "fileId": "d7118yAG5lKybkFOAh8koPL" + } +] \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/97/972b9a4d-47ee-4c74-b5c3-61d8a69bc29f.json b/Layered_virtual_list_2.x/library/imports/97/972b9a4d-47ee-4c74-b5c3-61d8a69bc29f.json new file mode 100644 index 0000000..7f2be63 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/97/972b9a4d-47ee-4c74-b5c3-61d8a69bc29f.json @@ -0,0 +1,421 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "button", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 1, + "asyncLoadAssets": false, + "readonly": false + }, + { + "__type__": "cc.Node", + "_name": "button", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + } + ], + "_active": true, + "_components": [ + { + "__id__": 9 + } + ], + "_prefab": { + "__id__": 10 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Background", + "_objFlags": 512, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 3 + } + ], + "_active": true, + "_components": [ + { + "__id__": 6 + }, + { + "__id__": 7 + } + ], + "_prefab": { + "__id__": 8 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Label", + "_objFlags": 512, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 4 + } + ], + "_prefab": { + "__id__": 5 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 3 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_useOriginalSize": false, + "_string": "button", + "_N$string": "button", + "_fontSize": 20, + "_lineHeight": 40, + "_enableWrapText": false, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_styleFlags": 0, + "_underlineHeight": 0, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 1, + "_N$cacheMode": 1, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "972b9a4d-47ee-4c74-b5c3-61d8a69bc29f" + }, + "fileId": "89ZOGI9GxIA7ukuWhMzutw", + "sync": false + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952" + }, + "_type": 1, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "alignMode": 0, + "_target": null, + "_alignFlags": 45, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 100, + "_originalHeight": 40, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "972b9a4d-47ee-4c74-b5c3-61d8a69bc29f" + }, + "fileId": "abgf9KGgdMsahHlBHOj/Jv", + "sync": false + }, + { + "__type__": "cc.Button", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "_normalMaterial": null, + "_grayMaterial": null, + "duration": 0.1, + "zoomScale": 1.2, + "clickEvents": [], + "_N$interactable": true, + "_N$enableAutoGrayEffect": false, + "_N$transition": 2, + "transition": 2, + "_N$normalColor": { + "__type__": "cc.Color", + "r": 230, + "g": 230, + "b": 230, + "a": 255 + }, + "_N$pressedColor": { + "__type__": "cc.Color", + "r": 200, + "g": 200, + "b": 200, + "a": 255 + }, + "pressedColor": { + "__type__": "cc.Color", + "r": 200, + "g": 200, + "b": 200, + "a": 255 + }, + "_N$hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$disabledColor": { + "__type__": "cc.Color", + "r": 120, + "g": 120, + "b": 120, + "a": 200 + }, + "_N$normalSprite": { + "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952" + }, + "_N$pressedSprite": { + "__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a" + }, + "pressedSprite": { + "__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a" + }, + "_N$hoverSprite": { + "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952" + }, + "hoverSprite": { + "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952" + }, + "_N$disabledSprite": { + "__uuid__": "29158224-f8dd-4661-a796-1ffab537140e" + }, + "_N$target": { + "__id__": 2 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "972b9a4d-47ee-4c74-b5c3-61d8a69bc29f" + }, + "fileId": "59d3ePxgxhP17q/bKZe2Mkj", + "sync": false + } +] \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/99/99170b0b-d210-46f1-b213-7d9e3f23098a.json b/Layered_virtual_list_2.x/library/imports/99/99170b0b-d210-46f1-b213-7d9e3f23098a.json new file mode 100644 index 0000000..e7522d6 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/99/99170b0b-d210-46f1-b213-7d9e3f23098a.json @@ -0,0 +1,4 @@ +{ + "__type__": "cc.Texture2D", + "content": "0,9729,9729,33071,33071,0,0,1" +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/99/99170b0b-d210-46f1-b213-7d9e3f23098a.png b/Layered_virtual_list_2.x/library/imports/99/99170b0b-d210-46f1-b213-7d9e3f23098a.png new file mode 100644 index 0000000..72def9a Binary files /dev/null and b/Layered_virtual_list_2.x/library/imports/99/99170b0b-d210-46f1-b213-7d9e3f23098a.png differ diff --git a/Layered_virtual_list_2.x/library/imports/9b/9bbda31e-ad49-43c9-aaf2-f7d9896bac69.json b/Layered_virtual_list_2.x/library/imports/9b/9bbda31e-ad49-43c9-aaf2-f7d9896bac69.json new file mode 100644 index 0000000..8a1a2e0 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/9b/9bbda31e-ad49-43c9-aaf2-f7d9896bac69.json @@ -0,0 +1,28 @@ +{ + "__type__": "cc.SpriteFrame", + "content": { + "name": "default_panel", + "texture": "d81ec8ad-247c-4e62-aa3c-d35c4193c7af", + "atlas": "", + "rect": [ + 0, + 0, + 20, + 20 + ], + "offset": [ + 0, + 0 + ], + "originalSize": [ + 20, + 20 + ], + "capInsets": [ + 6, + 6, + 6, + 6 + ] + } +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/9d/9d60001f-b5f4-4726-a629-2659e3ded0b8.json b/Layered_virtual_list_2.x/library/imports/9d/9d60001f-b5f4-4726-a629-2659e3ded0b8.json new file mode 100644 index 0000000..e7522d6 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/9d/9d60001f-b5f4-4726-a629-2659e3ded0b8.json @@ -0,0 +1,4 @@ +{ + "__type__": "cc.Texture2D", + "content": "0,9729,9729,33071,33071,0,0,1" +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/9d/9d60001f-b5f4-4726-a629-2659e3ded0b8.png b/Layered_virtual_list_2.x/library/imports/9d/9d60001f-b5f4-4726-a629-2659e3ded0b8.png new file mode 100644 index 0000000..4f42da0 Binary files /dev/null and b/Layered_virtual_list_2.x/library/imports/9d/9d60001f-b5f4-4726-a629-2659e3ded0b8.png differ diff --git a/Layered_virtual_list_2.x/library/imports/9e/9e17833a-ad49-48e6-a822-d7e1dc2cedf4.js b/Layered_virtual_list_2.x/library/imports/9e/9e17833a-ad49-48e6-a822-d7e1dc2cedf4.js new file mode 100644 index 0000000..a3243b7 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/9e/9e17833a-ad49-48e6-a822-d7e1dc2cedf4.js @@ -0,0 +1,90 @@ +"use strict"; +cc._RF.push(module, '9e178M6rUlI5qgi1+HcLO30', 'TestShowNode'); +// Scene/TestShowNode.ts + +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.TestShowNode = void 0; +var LoopList_1 = require("../Script/LoopList"); +var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property; +var TestShowNode = /** @class */ (function (_super) { + __extends(TestShowNode, _super); + function TestShowNode() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /** */ + _this.nameLb = null; + /** */ + _this.contentLb = null; + /** */ + _this.Button = null; + /** */ + _this.ButtonLb = null; + return _this; + } + /** + * 初始化显示 + * @param data + */ + TestShowNode.prototype.initShow = function () { + this.node.width = this.data.size.width; + this.node.height = this.data.size.height; + this.nameLb.string = "我是第" + this.data.index + "个"; + this.contentLb.string = "我是内容" + this.data.text; + //这个是改变控件大小的事例 + if (this.data.index == 5 || this.data.index == 11) { + //this.changeSize(cell); + } + }; + /** + * 改变大小 + * @param cell + */ + TestShowNode.prototype.changeSize = function (cell) { + var _this = this; + this.resize(cc.size(cell.size.width, 100 + (Math.random() * 400))); + this.scheduleOnce(function () { + _this.changeSize(cell); + }, 3 + Math.random() * 3); + }; + TestShowNode.prototype.onRecircle = function () { + //做释放操作 + }; + __decorate([ + property(cc.Label) + ], TestShowNode.prototype, "nameLb", void 0); + __decorate([ + property(cc.Label) + ], TestShowNode.prototype, "contentLb", void 0); + __decorate([ + property(cc.Node) + ], TestShowNode.prototype, "Button", void 0); + __decorate([ + property(cc.Label) + ], TestShowNode.prototype, "ButtonLb", void 0); + TestShowNode = __decorate([ + ccclass + ], TestShowNode); + return TestShowNode; +}(LoopList_1.ShowNode)); +exports.TestShowNode = TestShowNode; + +cc._RF.pop(); \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/9e/9e17833a-ad49-48e6-a822-d7e1dc2cedf4.js.map b/Layered_virtual_list_2.x/library/imports/9e/9e17833a-ad49-48e6-a822-d7e1dc2cedf4.js.map new file mode 100644 index 0000000..e384b67 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/9e/9e17833a-ad49-48e6-a822-d7e1dc2cedf4.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["assets\\Scene\\TestShowNode.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAwD;AAElD,IAAA,KAAwB,EAAE,CAAC,UAAU,EAAnC,OAAO,aAAA,EAAE,QAAQ,cAAkB,CAAC;AAQ5C;IAAkC,gCAAe;IAAjD;QAAA,qEA2CC;QA1CG,MAAM;QAEC,YAAM,GAAa,IAAI,CAAC;QAC/B,MAAM;QAEC,eAAS,GAAa,IAAI,CAAC;QAClC,MAAM;QAEC,YAAM,GAAY,IAAI,CAAC;QAC9B,MAAM;QAEC,cAAQ,GAAa,IAAI,CAAC;;IA+BrC,CAAC;IA7BG;;;OAGG;IACH,+BAAQ,GAAR;QACI,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;QACvC,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;QACzC,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC;QACnD,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;QAChD,cAAc;QACd,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,EAAE;YAC/C,wBAAwB;SAC3B;IACL,CAAC;IAED;;;OAGG;IACH,iCAAU,GAAV,UAAW,IAAqB;QAAhC,iBAKC;QAJG,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;QACnE,IAAI,CAAC,YAAY,CAAC;YACd,KAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;QACzB,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAA;IAC7B,CAAC;IAED,iCAAU,GAAV;QACI,OAAO;IACX,CAAC;IAvCD;QADC,QAAQ,CAAC,EAAE,CAAC,KAAK,CAAC;gDACY;IAG/B;QADC,QAAQ,CAAC,EAAE,CAAC,KAAK,CAAC;mDACe;IAGlC;QADC,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC;gDACY;IAG9B;QADC,QAAQ,CAAC,EAAE,CAAC,KAAK,CAAC;kDACc;IAZxB,YAAY;QADxB,OAAO;OACK,YAAY,CA2CxB;IAAD,mBAAC;CA3CD,AA2CC,CA3CiC,mBAAQ,GA2CzC;AA3CY,oCAAY","file":"","sourceRoot":"/","sourcesContent":["import ItemCell, { ShowNode } from \"../Script/LoopList\";\r\nimport RenderAlternative from \"../Script/RenderAlternative\";\r\nconst { ccclass, property } = cc._decorator;\r\nexport interface IData {\r\n size?: cc.Size,\r\n index: number,\r\n text: string\r\n}\r\n\r\n@ccclass\r\nexport class TestShowNode extends ShowNode {\r\n /** */\r\n @property(cc.Label)\r\n public nameLb: cc.Label = null;\r\n /** */\r\n @property(cc.Label)\r\n public contentLb: cc.Label = null;\r\n /** */\r\n @property(cc.Node)\r\n public Button: cc.Node = null;\r\n /** */\r\n @property(cc.Label)\r\n public ButtonLb: cc.Label = null;\r\n\r\n /**\r\n * 初始化显示\r\n * @param data \r\n */\r\n initShow() {\r\n this.node.width = this.data.size.width;\r\n this.node.height = this.data.size.height;\r\n this.nameLb.string = \"我是第\" + this.data.index + \"个\";\r\n this.contentLb.string = \"我是内容\" + this.data.text;\r\n //这个是改变控件大小的事例\r\n if (this.data.index == 5 || this.data.index == 11) {\r\n //this.changeSize(cell);\r\n }\r\n }\r\n\r\n /**\r\n * 改变大小\r\n * @param cell \r\n */\r\n changeSize(cell: ItemCell) {\r\n this.resize(cc.size(cell.size.width, 100 + (Math.random() * 400)));\r\n this.scheduleOnce(() => {\r\n this.changeSize(cell)\r\n }, 3 + Math.random() * 3)\r\n }\r\n\r\n onRecircle() {\r\n //做释放操作\r\n }\r\n}\r\n\r\n\r\n"]} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/a1/a153945d-2511-4c14-be7b-05d242f47d57.json b/Layered_virtual_list_2.x/library/imports/a1/a153945d-2511-4c14-be7b-05d242f47d57.json new file mode 100644 index 0000000..332d844 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/a1/a153945d-2511-4c14-be7b-05d242f47d57.json @@ -0,0 +1,15 @@ +{ + "__type__": "cc.Material", + "_name": "builtin-2d-graphics", + "_objFlags": 0, + "_native": "", + "_effectAsset": { + "__uuid__": "30682f87-9f0d-4f17-8a44-72863791461b" + }, + "_techniqueIndex": 0, + "_techniqueData": { + "0": { + "defines": {} + } + } +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/a1/a1ef2fc9-9c57-418a-8f69-6bed9a7a0e7f.bin b/Layered_virtual_list_2.x/library/imports/a1/a1ef2fc9-9c57-418a-8f69-6bed9a7a0e7f.bin new file mode 100644 index 0000000..d38e13f Binary files /dev/null and b/Layered_virtual_list_2.x/library/imports/a1/a1ef2fc9-9c57-418a-8f69-6bed9a7a0e7f.bin differ diff --git a/Layered_virtual_list_2.x/library/imports/a1/a1ef2fc9-9c57-418a-8f69-6bed9a7a0e7f.json b/Layered_virtual_list_2.x/library/imports/a1/a1ef2fc9-9c57-418a-8f69-6bed9a7a0e7f.json new file mode 100644 index 0000000..aefb61b --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/a1/a1ef2fc9-9c57-418a-8f69-6bed9a7a0e7f.json @@ -0,0 +1,90 @@ +[ + { + "__type__": "cc.Mesh", + "_name": "", + "_objFlags": 0, + "_native": ".bin", + "_vertexBundles": [ + { + "__id__": 1 + } + ], + "_primitives": [ + { + "__id__": 6 + } + ], + "_minPos": { + "__type__": "cc.Vec3", + "x": -5, + "y": 0, + "z": -5 + }, + "_maxPos": { + "__type__": "cc.Vec3", + "x": 5, + "y": 0, + "z": 5 + } + }, + { + "__type__": "cc.mesh.VertexBundle", + "data": { + "__id__": 2 + }, + "formats": [ + { + "__id__": 3 + }, + { + "__id__": 4 + }, + { + "__id__": 5 + } + ], + "verticesCount": 121 + }, + { + "__type__": "cc.BufferRange", + "offset": 0, + "length": 3872 + }, + { + "__type__": "cc.mesh.VertexFormat", + "name": "a_normal", + "type": 5126, + "num": 3, + "normalize": false + }, + { + "__type__": "cc.mesh.VertexFormat", + "name": "a_position", + "type": 5126, + "num": 3, + "normalize": false + }, + { + "__type__": "cc.mesh.VertexFormat", + "name": "a_uv0", + "type": 5126, + "num": 2, + "normalize": false + }, + { + "__type__": "cc.mesh.Primitive", + "vertexBundleIndices": [ + 0 + ], + "data": { + "__id__": 7 + }, + "indexUnit": 5123, + "topology": 4 + }, + { + "__type__": "cc.BufferRange", + "offset": 3872, + "length": 1200 + } +] \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/a2/a23235d1-15db-4b95-8439-a2e005bfff91.json b/Layered_virtual_list_2.x/library/imports/a2/a23235d1-15db-4b95-8439-a2e005bfff91.json new file mode 100644 index 0000000..1b02fdd --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/a2/a23235d1-15db-4b95-8439-a2e005bfff91.json @@ -0,0 +1,28 @@ +{ + "__type__": "cc.SpriteFrame", + "content": { + "name": "default_sprite_splash", + "texture": "0275e94c-56a7-410f-bd1a-fc7483f7d14a", + "atlas": "", + "rect": [ + 0, + 0, + 2, + 2 + ], + "offset": [ + 0, + 0 + ], + "originalSize": [ + 2, + 2 + ], + "capInsets": [ + 0, + 0, + 0, + 0 + ] + } +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/a5/a579b610-0aa7-4a8b-b36b-be34cc834dcc.bin b/Layered_virtual_list_2.x/library/imports/a5/a579b610-0aa7-4a8b-b36b-be34cc834dcc.bin new file mode 100644 index 0000000..743d7d2 Binary files /dev/null and b/Layered_virtual_list_2.x/library/imports/a5/a579b610-0aa7-4a8b-b36b-be34cc834dcc.bin differ diff --git a/Layered_virtual_list_2.x/library/imports/a5/a579b610-0aa7-4a8b-b36b-be34cc834dcc.json b/Layered_virtual_list_2.x/library/imports/a5/a579b610-0aa7-4a8b-b36b-be34cc834dcc.json new file mode 100644 index 0000000..2236ff8 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/a5/a579b610-0aa7-4a8b-b36b-be34cc834dcc.json @@ -0,0 +1,7 @@ +{ + "__type__": "cc.BufferAsset", + "_name": "buffer", + "_objFlags": 0, + "_native": ".bin", + "buffer": null +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/a5/a5849239-3ad3-41d1-8ab4-ae9fea11f97f.json b/Layered_virtual_list_2.x/library/imports/a5/a5849239-3ad3-41d1-8ab4-ae9fea11f97f.json new file mode 100644 index 0000000..8cd93af --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/a5/a5849239-3ad3-41d1-8ab4-ae9fea11f97f.json @@ -0,0 +1,24 @@ +{ + "__type__": "cc.Material", + "_name": "", + "_objFlags": 0, + "_native": "", + "_effectAsset": { + "__uuid__": "abc2cb62-7852-4525-a90d-d474487b88f2" + }, + "_techniqueIndex": 0, + "_techniqueData": { + "0": { + "props": { + "diffuseColor": { + "__type__": "cc.Color", + "r": 127, + "g": 127, + "b": 127, + "a": 255 + } + }, + "defines": {} + } + } +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/a8/a87cc147-01b2-43f8-8e42-a7ca90b0c757.json b/Layered_virtual_list_2.x/library/imports/a8/a87cc147-01b2-43f8-8e42-a7ca90b0c757.json new file mode 100644 index 0000000..0a667ca --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/a8/a87cc147-01b2-43f8-8e42-a7ca90b0c757.json @@ -0,0 +1,109 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "box", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "asyncLoadAssets": false, + "readonly": false + }, + { + "__type__": "cc.Node", + "_name": "box", + "_objFlags": 0, + "_parent": null, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 2 + } + ], + "_prefab": { + "__id__": 3 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.MeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "a5849239-3ad3-41d1-8ab4-ae9fea11f97f" + } + ], + "_mesh": { + "__uuid__": "046f172c-1574-488b-bbb8-6415a9adb96d" + }, + "_receiveShadows": false, + "_shadowCastingMode": 0, + "_enableAutoBatch": false, + "textures": [], + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "a87cc147-01b2-43f8-8e42-a7ca90b0c757" + }, + "fileId": "04A14e1BZJxrPk6zgr35H5", + "sync": false + } +] \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/ab/ab2fdde9-10c2-44e4-bfe1-fcfcc1a86aa9.json b/Layered_virtual_list_2.x/library/imports/ab/ab2fdde9-10c2-44e4-bfe1-fcfcc1a86aa9.json new file mode 100644 index 0000000..0c73930 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/ab/ab2fdde9-10c2-44e4-bfe1-fcfcc1a86aa9.json @@ -0,0 +1,884 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "primitives", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "asyncLoadAssets": false, + "readonly": true + }, + { + "__type__": "cc.Node", + "_name": "RootNode", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + }, + { + "__id__": 5 + }, + { + "__id__": 8 + }, + { + "__id__": 11 + }, + { + "__id__": 14 + }, + { + "__id__": 17 + }, + { + "__id__": 20 + }, + { + "__id__": 23 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 26 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "capsule", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 3 + } + ], + "_prefab": { + "__id__": 4 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 8.146033536604618e-8, + 0, + 0, + 0.9999999999999967, + 100, + 100, + 100 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0.000009334666828389458, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.MeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "a5849239-3ad3-41d1-8ab4-ae9fea11f97f" + } + ], + "_mesh": { + "__uuid__": "83f5eff8-3385-4f95-9b76-8da0aa1d96cd" + }, + "_receiveShadows": false, + "_shadowCastingMode": 0, + "_enableAutoBatch": false, + "textures": [], + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "capsule", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "plane", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 6 + } + ], + "_prefab": { + "__id__": 7 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 8.146033536604618e-8, + 0, + 0, + 0.9999999999999967, + 100, + 100, + 100 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0.000009334666828389458, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.MeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 5 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "a5849239-3ad3-41d1-8ab4-ae9fea11f97f" + } + ], + "_mesh": { + "__uuid__": "a1ef2fc9-9c57-418a-8f69-6bed9a7a0e7f" + }, + "_receiveShadows": false, + "_shadowCastingMode": 0, + "_enableAutoBatch": false, + "textures": [], + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "plane", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "cone", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 9 + } + ], + "_prefab": { + "__id__": 10 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + -0.7071068286895765, + 0, + 0, + 0.7071067336835153, + 100, + 100, + 100 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": -90.00000769819565, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.MeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 8 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "a5849239-3ad3-41d1-8ab4-ae9fea11f97f" + } + ], + "_mesh": { + "__uuid__": "7a17de6e-227a-46b1-8009-e7157d4d3acf" + }, + "_receiveShadows": false, + "_shadowCastingMode": 0, + "_enableAutoBatch": false, + "textures": [], + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "cone", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "torus", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 12 + } + ], + "_prefab": { + "__id__": 13 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 8.146033536604618e-8, + 0, + 0, + 0.9999999999999967, + 100, + 100, + 100 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0.000009334666828389458, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.MeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 11 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "a5849239-3ad3-41d1-8ab4-ae9fea11f97f" + } + ], + "_mesh": { + "__uuid__": "14c74869-bdb4-4f57-86d8-a7875de2be30" + }, + "_receiveShadows": false, + "_shadowCastingMode": 0, + "_enableAutoBatch": false, + "textures": [], + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "torus", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "sphere", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 15 + } + ], + "_prefab": { + "__id__": 16 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 8.146033536604618e-8, + 0, + 0, + 0.9999999999999967, + 100, + 100, + 100 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0.000009334666828389458, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.MeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 14 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "a5849239-3ad3-41d1-8ab4-ae9fea11f97f" + } + ], + "_mesh": { + "__uuid__": "3bbdb0f6-c5f6-45de-9f33-8b5cbafb4d6d" + }, + "_receiveShadows": false, + "_shadowCastingMode": 0, + "_enableAutoBatch": false, + "textures": [], + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "sphere", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "quad", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 18 + } + ], + "_prefab": { + "__id__": 19 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 8.146033536604618e-8, + 0, + 0, + 0.9999999999999967, + 100, + 100, + 100 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0.000009334666828389458, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.MeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 17 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "a5849239-3ad3-41d1-8ab4-ae9fea11f97f" + } + ], + "_mesh": { + "__uuid__": "e93d3fa9-8c21-4375-8a21-14ba84066c77" + }, + "_receiveShadows": false, + "_shadowCastingMode": 0, + "_enableAutoBatch": false, + "textures": [], + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "quad", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "cylinder", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 21 + } + ], + "_prefab": { + "__id__": 22 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 8.146033536604618e-8, + 0, + 0, + 0.9999999999999967, + 100, + 100, + 100 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0.000009334666828389458, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.MeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 20 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "a5849239-3ad3-41d1-8ab4-ae9fea11f97f" + } + ], + "_mesh": { + "__uuid__": "b430cea3-6ab3-4106-b073-26c698918edd" + }, + "_receiveShadows": false, + "_shadowCastingMode": 0, + "_enableAutoBatch": false, + "textures": [], + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "cylinder", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "box", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 24 + } + ], + "_prefab": { + "__id__": 25 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 8.146033536604618e-8, + 0, + 0, + 0.9999999999999967, + 100, + 100, + 100 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0.000009334666828389458, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.MeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 23 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "a5849239-3ad3-41d1-8ab4-ae9fea11f97f" + } + ], + "_mesh": { + "__uuid__": "046f172c-1574-488b-bbb8-6415a9adb96d" + }, + "_receiveShadows": false, + "_shadowCastingMode": 0, + "_enableAutoBatch": false, + "textures": [], + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "box", + "sync": false + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "", + "sync": false + } +] \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/ab/abc2cb62-7852-4525-a90d-d474487b88f2.json b/Layered_virtual_list_2.x/library/imports/ab/abc2cb62-7852-4525-a90d-d474487b88f2.json new file mode 100644 index 0000000..3aa4a40 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/ab/abc2cb62-7852-4525-a90d-d474487b88f2.json @@ -0,0 +1,653 @@ +{ + "__type__": "cc.EffectAsset", + "_name": "builtin-phong", + "_objFlags": 0, + "_native": "", + "properties": null, + "techniques": [ + { + "passes": [ + { + "name": "phong", + "rasterizerState": { + "cullMode": 1029 + }, + "depthStencilState": { + "depthTest": true, + "depthWrite": true + }, + "properties": { + "alphaThreshold": { + "value": [ + 0.5 + ], + "type": 13 + }, + "mainTiling": { + "value": [ + 1, + 1 + ], + "type": 14 + }, + "mainOffset": { + "value": [ + 0, + 0 + ], + "type": 14 + }, + "diffuseColor": { + "value": [ + 1, + 1, + 1, + 1 + ], + "editor": { + "type": "color" + }, + "type": 16 + }, + "diffuseTexture": { + "value": "white", + "type": 29 + }, + "specularColor": { + "value": [ + 1, + 1, + 1, + 1 + ], + "editor": { + "type": "color" + }, + "type": 16 + }, + "specularTexture": { + "value": "white", + "type": 29 + }, + "emissiveColor": { + "value": [ + 0, + 0, + 0, + 1 + ], + "editor": { + "type": "color" + }, + "type": 16 + }, + "emissiveTexture": { + "value": "white", + "type": 29 + }, + "glossiness": { + "value": [ + 10 + ], + "type": 13 + }, + "normalTexture": { + "value": "white", + "type": 29 + } + }, + "program": "builtin-phong|phong-vs|phong-fs" + }, + { + "name": "shadowcast", + "stage": "shadowcast", + "rasterizerState": { + "cullMode": 1029 + }, + "depthStencilState": { + "depthTest": true, + "depthWrite": true + }, + "program": "builtin-phong|shadow-map-vs|shadow-map-fs" + } + ] + } + ], + "shaders": [ + { + "hash": 3560892936, + "glsl3": { + "vert": "\nprecision highp float;\nuniform CCLocal {\n mat4 cc_matWorld;\n mat4 cc_matWorldIT;\n};\nuniform CCGlobal {\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\n#if CC_USE_SKINNING\n in vec4 a_weights;\n in vec4 a_joints;\n #if CC_USE_JOINTS_TEXTRUE\n uniform SKINNING {\n vec2 jointsTextureSize;\n };\n uniform sampler2D jointsTexture;\n #if CC_JOINTS_TEXTURE_FLOAT32\n mat4 getBoneMatrix(const in float i) {\n float width = jointsTextureSize.x;\n float height = jointsTextureSize.y;\n float j = i * 4.0;\n float x = mod(j, width);\n float y = floor(j / width);\n float dx = 1.0 / width;\n float dy = 1.0 / height;\n y = dy * (y + 0.5);\n vec4 v1 = texture(jointsTexture, vec2(dx * (x + 0.5), y));\n vec4 v2 = texture(jointsTexture, vec2(dx * (x + 1.5), y));\n vec4 v3 = texture(jointsTexture, vec2(dx * (x + 2.5), y));\n vec4 v4 = texture(jointsTexture, vec2(dx * (x + 3.5), y));\n return mat4(v1, v2, v3, v4);\n }\n #else\n float decode32(vec4 rgba) {\n float Sign = 1.0 - step(128.0, rgba[0]) * 2.0;\n float Exponent = 2.0 * mod(rgba[0], 128.0) + step(128.0, rgba[1]) - 127.0;\n float Mantissa = mod(rgba[1], 128.0) * 65536.0 + rgba[2] * 256.0 + rgba[3] + 8388608.0;\n return Sign * exp2(Exponent - 23.0) * Mantissa;\n }\n vec4 decodevec4 (vec4 x, vec4 y, vec4 z, vec4 w) {\n return vec4(\n decode32(x.wzyx * 255.0),\n decode32(y.wzyx * 255.0),\n decode32(z.wzyx * 255.0),\n decode32(w.wzyx * 255.0)\n );\n }\n vec4 decodevec4 (float dx, float x, float y) {\n return decodevec4(\n texture(jointsTexture, vec2(dx * (x + 0.5), y)),\n texture(jointsTexture, vec2(dx * (x + 1.5), y)),\n texture(jointsTexture, vec2(dx * (x + 2.5), y)),\n texture(jointsTexture, vec2(dx * (x + 3.5), y))\n );\n }\n mat4 getBoneMatrix(const in float i) {\n float width = jointsTextureSize.x;\n float height = jointsTextureSize.y;\n float j = i * 16.0;\n float x = mod(j, width);\n float y = floor(j / width);\n float dx = 1.0 / width;\n float dy = 1.0 / height;\n y = dy * (y + 0.5);\n vec4 v1 = decodevec4(dx, x, y);\n vec4 v2 = decodevec4(dx, x+4.0, y);\n vec4 v3 = decodevec4(dx, x+8.0, y);\n vec4 v4 = decodevec4(dx, x+12.0, y);\n return mat4(v1, v2, v3, v4);\n }\n #endif\n #else\n uniform JOINT_MATRIX {\n mat4 jointMatrices[50];\n };\n mat4 getBoneMatrix(const in float i) {\n return jointMatrices[int(i)];\n }\n #endif\n mat4 skinMatrix() {\n return\n getBoneMatrix(a_joints.x) * a_weights.x +\n getBoneMatrix(a_joints.y) * a_weights.y +\n getBoneMatrix(a_joints.z) * a_weights.z +\n getBoneMatrix(a_joints.w) * a_weights.w\n ;\n }\n#endif\nstruct StandardVertInput {\n vec2 uv;\n vec4 position;\n vec3 normal;\n vec4 tangent;\n vec4 color;\n};\nin vec3 a_position;\n#if CC_USE_ATTRIBUTE_UV0\nin vec2 a_uv0;\n#endif\n#if CC_USE_ATTRIBUTE_COLOR\nin vec4 a_color;\n#endif\n#if CC_USE_ATTRIBUTE_NORMAL\nin vec3 a_normal;\n#endif\n#if CC_USE_ATTRIBUTE_TANGENT\nin vec4 a_tangent;\n#endif\nvoid CCAttribute (out StandardVertInput In) {\n In.position = vec4(a_position, 1.0);\n #if CC_USE_ATTRIBUTE_UV0\n In.uv = a_uv0;\n #else\n In.uv = vec2(0.0);\n #endif\n #if CC_USE_ATTRIBUTE_COLOR\n In.color = a_color;\n #else\n In.color = vec4(1.0);\n #endif\n #if CC_USE_ATTRIBUTE_NORMAL\n In.normal = a_normal;\n #else\n In.normal = vec3(0.0, 1.0, 0.0);\n #endif\n #if CC_USE_ATTRIBUTE_TANGENT\n In.tangent = a_tangent;\n #else\n In.tangent = vec4(1.0, 0.0, 0.0, 0.0);\n #endif\n}\nvoid CCVertInput(out StandardVertInput In) {\n CCAttribute(In);\n #if CC_USE_SKINNING\n mat4 m = skinMatrix();\n In.position = m * In.position;\n #if CC_USE_ATTRIBUTE_NORMAL\n In.normal = (m * vec4(In.normal, 0)).xyz;\n #endif\n #if CC_USE_ATTRIBUTE_TANGENT\n In.tangent = m * In.tangent;\n #endif\n #endif\n}\n#if CC_USE_SHADOW_MAP && CC_NUM_SHADOW_LIGHTS > 0\n uniform CC_SHADOW {\n mat4 cc_shadow_lightViewProjMatrix[2];\n vec4 cc_shadow_info[2];\n };\n #if CC_NUM_SHADOW_LIGHTS > 0\n uniform sampler2D cc_shadow_map_0;\n #endif\n #if CC_NUM_SHADOW_LIGHTS > 1\n uniform sampler2D cc_shadow_map_1;\n #endif\n varying vec4 v_posLightSpace[2];\n varying float v_depth[2];\n#endif\nvoid CCShadowInput (vec3 worldPos) {\n #if CC_USE_SHADOW_MAP && CC_NUM_SHADOW_LIGHTS > 0\n for (int i = 0; i < CC_NUM_SHADOW_LIGHTS; i++) {\n v_posLightSpace[i] = cc_shadow_lightViewProjMatrix[i] * vec4(worldPos, 1.0);\n v_depth[i] = (v_posLightSpace[i].z + cc_shadow_info[i].x) / (cc_shadow_info[i].x + cc_shadow_info[i].y);\n }\n #endif\n}\nuniform MAIN_TILING {\n vec2 mainTiling;\n vec2 mainOffset;\n};\n#if CC_USE_ATTRIBUTE_UV0 && (USE_DIFFUSE_TEXTURE || USE_EMISSIVE_TEXTURE || USE_SPECULAR_TEXTURE || USE_NORMAL_TEXTURE)\n out mediump vec2 v_uv0;\n#endif\n#if CC_USE_ATTRIBUTE_COLOR\n out lowp vec4 v_color;\n#endif\n#if USE_NORMAL_TEXTURE\n out vec3 v_tangent;\n out vec3 v_bitangent;\n#endif\nout vec3 v_worldNormal;\nout vec3 v_worldPos;\nout vec3 v_viewDirection;\nvoid main () {\n StandardVertInput In;\n CCVertInput(In);\n vec4 position = In.position;\n v_worldNormal = normalize((cc_matWorldIT * vec4(In.normal, 0)).xyz);\n v_worldPos = (cc_matWorld * position).xyz;\n v_viewDirection = normalize(cc_cameraPos.xyz - v_worldPos);\n #if CC_USE_ATTRIBUTE_UV0 && (USE_DIFFUSE_TEXTURE || USE_EMISSIVE_TEXTURE || USE_SPECULAR_TEXTURE || USE_NORMAL_TEXTURE)\n v_uv0 = In.uv * mainTiling + mainOffset;\n #endif\n #if CC_USE_ATTRIBUTE_COLOR\n v_color = In.color;\n #endif\n #if USE_NORMAL_TEXTURE\n v_tangent = normalize((cc_matWorld * vec4(In.tangent.xyz, 0.0)).xyz);\n v_bitangent = cross(v_worldNormal, v_tangent) * In.tangent.w;\n #endif\n CCShadowInput(v_worldPos);\n gl_Position = cc_matViewProj * cc_matWorld * position;\n}", + "frag": "\nprecision highp float;\nuniform CCGlobal {\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\nvec4 CCFragOutput (vec4 color) {\n #if OUTPUT_TO_GAMMA\n color.rgb = sqrt(color.rgb);\n #endif\n\treturn color;\n}\n#if USE_ALPHA_TEST\n uniform ALPHA_TEST {\n float alphaThreshold;\n };\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\nuniform PhongFrag {\n lowp vec4 diffuseColor;\n lowp vec4 specularColor;\n lowp vec4 emissiveColor;\n float glossiness;\n};\n#if USE_DIFFUSE_TEXTURE\n uniform sampler2D diffuseTexture;\n#endif\n#if USE_SPECULAR && USE_SPECULAR_TEXTURE\n uniform sampler2D specularTexture;\n#endif\n#if USE_EMISSIVE && USE_EMISSIVE_TEXTURE\n uniform sampler2D emissiveTexture;\n#endif\n#if USE_NORMAL_TEXTURE\n in vec3 v_tangent;\n in vec3 v_bitangent;\n uniform sampler2D normalTexture;\n#endif\nin vec3 v_worldNormal;\nin vec3 v_worldPos;\nin vec3 v_viewDirection;\n#if CC_USE_ATTRIBUTE_UV0 && (USE_DIFFUSE_TEXTURE || (USE_EMISSIVE && USE_EMISSIVE_TEXTURE) || (USE_SPECULAR && USE_SPECULAR_TEXTURE) || USE_NORMAL_TEXTURE)\n in mediump vec2 v_uv0;\n#endif\n#if CC_USE_ATTRIBUTE_COLOR\n in lowp vec4 v_color;\n#endif\n#if CC_USE_SHADOW_MAP && CC_NUM_SHADOW_LIGHTS > 0\n uniform CC_SHADOW {\n mat4 cc_shadow_lightViewProjMatrix[2];\n vec4 cc_shadow_info[2];\n };\n #if CC_NUM_SHADOW_LIGHTS > 0\n uniform sampler2D cc_shadow_map_0;\n #endif\n #if CC_NUM_SHADOW_LIGHTS > 1\n uniform sampler2D cc_shadow_map_1;\n #endif\n varying vec4 v_posLightSpace[2];\n varying float v_depth[2];\n#endif\nfloat unpackRGBAToDepth(vec4 color) {\n return dot(color, vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n}\nfloat getDepth(sampler2D shadowMap, vec2 shadowUV) {\n return unpackRGBAToDepth(texture(shadowMap, shadowUV));\n}\nfloat computeFallOff(float shadow, vec2 coords, float frustumEdgeFalloff) {\n return shadow;\n}\nfloat shadowSimple(sampler2D shadowMap, vec2 shadowUV, float currentDepth, float darkness) {\n float closestDepth = getDepth(shadowMap, shadowUV);\n return currentDepth > closestDepth ? 1.0 - darkness : 1.0;\n}\nfloat shadowPCF3X3(sampler2D shadowMap, vec2 shadowUV, float currentDepth, float darkness, float shadowSize) {\n float shadow = 0.0;\n for (int x = -1; x <= 1; ++x) {\n for (int y = -1; y <= 1; ++y) {\n float closestDepth = getDepth(shadowMap, shadowUV + vec2(x, y) * 1.0/shadowSize);\n shadow += currentDepth > closestDepth ? 1.0 - darkness : 1.0;\n }\n }\n shadow /= 9.0;\n return shadow;\n}\nfloat shadowPCF5X5(sampler2D shadowMap, vec2 shadowUV, float currentDepth, float darkness, float shadowSize) {\n float shadow = 0.0;\n for (int x = -2; x <= 2; ++x) {\n for (int y = -2; y <= 2; ++y) {\n float closestDepth = getDepth(shadowMap, shadowUV + vec2(x, y) * 1.0/shadowSize);\n shadow += currentDepth > closestDepth ? 1.0 - darkness : 1.0;\n }\n }\n shadow /= 25.0;\n return shadow;\n}\n#if CC_NUM_LIGHTS > 0\nuniform CCLIGHTS {\n vec4 cc_lightPositionAndRange[4];\n vec4 cc_lightDirection[4];\n vec4 cc_lightColor[4];\n};\n#endif\nstruct LightInfo {\n vec3 lightDir;\n vec3 radiance;\n vec4 lightColor;\n};\nLightInfo computeDirectionalLighting(\n vec4 lightDirection,\n vec4 lightColor\n) {\n LightInfo ret;\n ret.lightDir = -normalize(lightDirection.xyz);\n ret.radiance = lightColor.rgb;\n ret.lightColor = lightColor;\n return ret;\n}\nLightInfo computePointLighting(\n vec3 worldPosition,\n vec4 lightPositionAndRange,\n vec4 lightColor\n) {\n LightInfo ret;\n vec3 lightDir = lightPositionAndRange.xyz - worldPosition;\n float attenuation = max(0., 1.0 - length(lightDir) / lightPositionAndRange.w);\n ret.lightDir = normalize(lightDir);\n ret.radiance = lightColor.rgb * attenuation;\n ret.lightColor = lightColor;\n return ret;\n}\nLightInfo computeSpotLighting(\n vec3 worldPosition,\n vec4 lightPositionAndRange,\n vec4 lightDirection,\n vec4 lightColor\n) {\n LightInfo ret;\n vec3 lightDir = lightPositionAndRange.xyz - worldPosition;\n float attenuation = max(0., 1.0 - length(lightDir) / lightPositionAndRange.w);\n lightDir = normalize(lightDir);\n float cosConeAngle = max(0., dot(lightDirection.xyz, -lightDir));\n cosConeAngle = cosConeAngle < lightDirection.w ? 0. : cosConeAngle;\n cosConeAngle = pow(cosConeAngle, lightColor.w);\n ret.lightDir = lightDir;\n ret.radiance = lightColor.rgb * attenuation * cosConeAngle;\n ret.lightColor = lightColor;\n return ret;\n}\nstruct Lighting {\n vec3 diffuse;\n vec3 specular;\n};\nstruct PhongSurface {\n vec3 diffuse;\n vec3 emissive;\n vec3 specular;\n float opacity;\n float glossiness;\n vec3 position;\n vec3 normal;\n vec3 viewDirection;\n};\nLighting brdf (PhongSurface s, LightInfo info) {\n Lighting result;\n float ndh = 0.0;\n vec3 halfDir = normalize(s.viewDirection + info.lightDir);\n float NdotH = max(0.0, dot(s.normal, halfDir));\n NdotH = pow(NdotH, max(1.0, s.glossiness * 128.0));\n result.diffuse = info.radiance * max(0.0, dot(s.normal, info.lightDir));\n result.specular = info.radiance * NdotH;\n return result;\n}\nvec4 composePhongShading (Lighting lighting, PhongSurface s) {\n vec4 o = vec4(0.0, 0.0, 0.0, 1.0);\n o.rgb = lighting.diffuse * s.diffuse;\n #if USE_EMISSIVE\n o.rgb += s.emissive;\n #endif\n #if USE_SPECULAR\n o.rgb += lighting.specular * s.specular;\n #endif\n o.a = s.opacity;\n return o;\n}\nvec3 ambient(PhongSurface s, vec4 ambientColor) {\n return s.diffuse * ambientColor.rgb;\n}\nvec4 CCPhongShading (in PhongSurface s) {\n Lighting result;\n result.diffuse = vec3(0, 0, 0);\n result.specular = vec3(0, 0, 0);\n #if CC_NUM_LIGHTS > 0\n #if CC_LIGHT_0_TYPE == 3\n result.diffuse += ambient(s, cc_lightColor[0]);\n #else\n LightInfo info0;\n #if CC_LIGHT_0_TYPE == 0\n info0 = computeDirectionalLighting(cc_lightDirection[0], cc_lightColor[0]);\n #elif CC_LIGHT_0_TYPE == 1\n info0 = computePointLighting(s.position, cc_lightPositionAndRange[0], cc_lightColor[0]);\n #elif CC_LIGHT_0_TYPE == 2\n info0 = computeSpotLighting(s.position, cc_lightPositionAndRange[0], cc_lightDirection[0], cc_lightColor[0]);\n #endif\n Lighting result0 = brdf(s, info0);\n #if CC_USE_SHADOW_MAP && CC_NUM_SHADOW_LIGHTS > 0\n float shadow_0 = 1.0;\n vec2 projCoords0 = v_posLightSpace[0].xy / v_posLightSpace[0].w;\n vec2 shadowUV0 = projCoords0 * 0.5 + vec2(0.5);\n if (shadowUV0.x >= 0.0 && shadowUV0.x <= 1.0 && shadowUV0.y >= 0.0 && shadowUV0.y <= 1.0) {\n float currentDepth0 = clamp(v_depth[0], 0.0, 1.0);\n #if CC_SHADOW_0_TYPE == 3\n shadow_0 = shadowPCF3X3(cc_shadow_map_0, shadowUV0, currentDepth0, cc_shadow_info[0].w, cc_shadow_info[0].z);\n #elif CC_SHADOW_0_TYPE == 4\n shadow_0 = shadowPCF5X5(cc_shadow_map_0, shadowUV0, currentDepth0, cc_shadow_info[0].w, cc_shadow_info[0].z);\n #else\n shadow_0 = shadowSimple(cc_shadow_map_0, shadowUV0, currentDepth0, cc_shadow_info[0].w);\n #endif\n shadow_0 = computeFallOff(shadow_0, projCoords0, 0.0);\n }\n result0.diffuse *= shadow_0;\n result0.specular *= shadow_0;\n #endif\n result.diffuse += result0.diffuse;\n result.specular += result0.specular;\n #endif\n #endif\n #if CC_NUM_LIGHTS > 1\n #if CC_LIGHT_1_TYPE == 3\n result.diffuse += ambient(s, cc_lightColor[1]);\n #else\n LightInfo info1;\n #if CC_LIGHT_1_TYPE == 0\n info1 = computeDirectionalLighting(cc_lightDirection[1], cc_lightColor[1]);\n #elif CC_LIGHT_1_TYPE == 1\n info1 = computePointLighting(s.position, cc_lightPositionAndRange[1], cc_lightColor[1]);\n #elif CC_LIGHT_1_TYPE == 2\n info1 = computeSpotLighting(s.position, cc_lightPositionAndRange[1], cc_lightDirection[1], cc_lightColor[1]);\n #endif\n Lighting result1 = brdf(s, info1);\n #if CC_USE_SHADOW_MAP && CC_NUM_SHADOW_LIGHTS > 1\n float shadow_1 = 1.0;\n vec2 projCoords1 = v_posLightSpace[1].xy / v_posLightSpace[1].w;\n vec2 shadowUV1 = projCoords1 * 0.5 + vec2(0.5);\n if (shadowUV1.x >= 0.0 && shadowUV1.x <= 1.0 && shadowUV1.y >= 0.0 && shadowUV1.y <= 1.0) {\n float currentDepth1 = clamp(v_depth[1], 0.0, 1.0);\n #if CC_SHADOW_1_TYPE == 3\n shadow_1 = shadowPCF3X3(cc_shadow_map_1, shadowUV1, currentDepth1, cc_shadow_info[1].w, cc_shadow_info[1].z);\n #elif CC_SHADOW_1_TYPE == 4\n shadow_1 = shadowPCF5X5(cc_shadow_map_1, shadowUV1, currentDepth1, cc_shadow_info[1].w, cc_shadow_info[1].z);\n #else\n shadow_1 = shadowSimple(cc_shadow_map_1, shadowUV1, currentDepth1, cc_shadow_info[1].w);\n #endif\n shadow_1 = computeFallOff(shadow_1, projCoords1, 0.0);\n }\n result1.diffuse *= shadow_1;\n result1.specular *= shadow_1;\n #endif\n result.diffuse += result1.diffuse;\n result.specular += result1.specular;\n #endif\n #endif\n #if CC_NUM_LIGHTS > 2\n #if CC_LIGHT_2_TYPE == 3\n result.diffuse += ambient(s, cc_lightColor[2]);\n #else\n LightInfo info2;\n #if CC_LIGHT_2_TYPE == 0\n info2 = computeDirectionalLighting(cc_lightDirection[2], cc_lightColor[2]);\n #elif CC_LIGHT_2_TYPE == 1\n info2 = computePointLighting(s.position, cc_lightPositionAndRange[2], cc_lightColor[2]);\n #elif CC_LIGHT_2_TYPE == 2\n info2 = computeSpotLighting(s.position, cc_lightPositionAndRange[2], cc_lightDirection[2], cc_lightColor[2]);\n #endif\n Lighting result2 = brdf(s, info2);\n #if CC_USE_SHADOW_MAP && CC_NUM_SHADOW_LIGHTS > 2\n float shadow_2 = 1.0;\n vec2 projCoords2 = v_posLightSpace[2].xy / v_posLightSpace[2].w;\n vec2 shadowUV2 = projCoords2 * 0.5 + vec2(0.5);\n if (shadowUV2.x >= 0.0 && shadowUV2.x <= 1.0 && shadowUV2.y >= 0.0 && shadowUV2.y <= 1.0) {\n float currentDepth2 = clamp(v_depth[2], 0.0, 1.0);\n #if CC_SHADOW_2_TYPE == 3\n shadow_2 = shadowPCF3X3(cc_shadow_map_2, shadowUV2, currentDepth2, cc_shadow_info[2].w, cc_shadow_info[2].z);\n #elif CC_SHADOW_2_TYPE == 4\n shadow_2 = shadowPCF5X5(cc_shadow_map_2, shadowUV2, currentDepth2, cc_shadow_info[2].w, cc_shadow_info[2].z);\n #else\n shadow_2 = shadowSimple(cc_shadow_map_2, shadowUV2, currentDepth2, cc_shadow_info[2].w);\n #endif\n shadow_2 = computeFallOff(shadow_2, projCoords2, 0.0);\n }\n result2.diffuse *= shadow_2;\n result2.specular *= shadow_2;\n #endif\n result.diffuse += result2.diffuse;\n result.specular += result2.specular;\n #endif\n #endif\n #if CC_NUM_LIGHTS > 3\n #if CC_LIGHT_3_TYPE == 3\n result.diffuse += ambient(s, cc_lightColor[3]);\n #else\n LightInfo info3;\n #if CC_LIGHT_3_TYPE == 0\n info3 = computeDirectionalLighting(cc_lightDirection[3], cc_lightColor[3]);\n #elif CC_LIGHT_3_TYPE == 1\n info3 = computePointLighting(s.position, cc_lightPositionAndRange[3], cc_lightColor[3]);\n #elif CC_LIGHT_3_TYPE == 2\n info3 = computeSpotLighting(s.position, cc_lightPositionAndRange[3], cc_lightDirection[3], cc_lightColor[3]);\n #endif\n Lighting result3 = brdf(s, info3);\n #if CC_USE_SHADOW_MAP && CC_NUM_SHADOW_LIGHTS > 3\n float shadow_3 = 1.0;\n vec2 projCoords3 = v_posLightSpace[3].xy / v_posLightSpace[3].w;\n vec2 shadowUV3 = projCoords3 * 0.5 + vec2(0.5);\n if (shadowUV3.x >= 0.0 && shadowUV3.x <= 1.0 && shadowUV3.y >= 0.0 && shadowUV3.y <= 1.0) {\n float currentDepth3 = clamp(v_depth[3], 0.0, 1.0);\n #if CC_SHADOW_3_TYPE == 3\n shadow_3 = shadowPCF3X3(cc_shadow_map_3, shadowUV3, currentDepth3, cc_shadow_info[3].w, cc_shadow_info[3].z);\n #elif CC_SHADOW_3_TYPE == 4\n shadow_3 = shadowPCF5X5(cc_shadow_map_3, shadowUV3, currentDepth3, cc_shadow_info[3].w, cc_shadow_info[3].z);\n #else\n shadow_3 = shadowSimple(cc_shadow_map_3, shadowUV3, currentDepth3, cc_shadow_info[3].w);\n #endif\n shadow_3 = computeFallOff(shadow_3, projCoords3, 0.0);\n }\n result3.diffuse *= shadow_3;\n result3.specular *= shadow_3;\n #endif\n result.diffuse += result3.diffuse;\n result.specular += result3.specular;\n #endif\n #endif\n return composePhongShading(result, s);\n}\nvoid surf (out PhongSurface s) {\n vec4 diffuse = vec4(1, 1, 1, 1);\n #if CC_USE_ATTRIBUTE_COLOR\n diffuse *= v_color;\n #endif\n diffuse *= diffuseColor;\n #if USE_DIFFUSE_TEXTURE\n vec4 diffuseTexture_tmp = texture(diffuseTexture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_diffuseTexture\n diffuseTexture_tmp.a *= texture(diffuseTexture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n diffuse.rgb *= (diffuseTexture_tmp.rgb * diffuseTexture_tmp.rgb);\n diffuse.a *= diffuseTexture_tmp.a;\n #else\n diffuse *= diffuseTexture_tmp;\n #endif\n #endif\n ALPHA_TEST(diffuse);\n s.diffuse = diffuse.rgb;\n s.opacity = diffuse.a;\n #if USE_EMISSIVE\n s.emissive = emissiveColor.rgb;\n #if USE_EMISSIVE_TEXTURE\n vec4 emissiveTexture_tmp = texture(emissiveTexture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_emissiveTexture\n emissiveTexture_tmp.a *= texture(emissiveTexture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n s.emissive.rgb *= (emissiveTexture_tmp.rgb * emissiveTexture_tmp.rgb);\n #else\n s.emissive.rgb *= emissiveTexture_tmp.rgb;\n #endif\n #endif\n #endif\n #if USE_SPECULAR\n s.specular = specularColor.rgb;\n #if USE_SPECULAR_TEXTURE\n vec4 specularTexture_tmp = texture(specularTexture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_specularTexture\n specularTexture_tmp.a *= texture(specularTexture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n s.specular.rgb *= (specularTexture_tmp.rgb * specularTexture_tmp.rgb);\n #else\n s.specular.rgb *= specularTexture_tmp.rgb;\n #endif\n #endif\n #endif\n s.normal = v_worldNormal;\n #if USE_NORMAL_TEXTURE\n vec3 nmmp = texture(normalTexture, v_uv0).xyz - vec3(0.5);\n s.normal =\n nmmp.x * normalize(v_tangent) +\n nmmp.y * normalize(v_bitangent) +\n nmmp.z * normalize(s.normal);\n s.normal = normalize(s.normal);\n #endif\n s.position = v_worldPos;\n s.viewDirection = v_viewDirection;\n s.glossiness = glossiness;\n}\nvoid main () {\n PhongSurface s;\n surf(s);\n vec4 color = CCPhongShading(s);\n gl_FragColor = CCFragOutput(color);\n}" + }, + "glsl1": { + "vert": "\nprecision highp float;\nuniform mat4 cc_matWorld;\nuniform mat4 cc_matWorldIT;\nuniform mat4 cc_matViewProj;\nuniform vec4 cc_cameraPos;\n#if CC_USE_SKINNING\n attribute vec4 a_weights;\n attribute vec4 a_joints;\n #if CC_USE_JOINTS_TEXTRUE\n uniform vec2 jointsTextureSize;\n uniform sampler2D jointsTexture;\n #if CC_JOINTS_TEXTURE_FLOAT32\n mat4 getBoneMatrix(const in float i) {\n float width = jointsTextureSize.x;\n float height = jointsTextureSize.y;\n float j = i * 4.0;\n float x = mod(j, width);\n float y = floor(j / width);\n float dx = 1.0 / width;\n float dy = 1.0 / height;\n y = dy * (y + 0.5);\n vec4 v1 = texture2D(jointsTexture, vec2(dx * (x + 0.5), y));\n vec4 v2 = texture2D(jointsTexture, vec2(dx * (x + 1.5), y));\n vec4 v3 = texture2D(jointsTexture, vec2(dx * (x + 2.5), y));\n vec4 v4 = texture2D(jointsTexture, vec2(dx * (x + 3.5), y));\n return mat4(v1, v2, v3, v4);\n }\n #else\n float decode32(vec4 rgba) {\n float Sign = 1.0 - step(128.0, rgba[0]) * 2.0;\n float Exponent = 2.0 * mod(rgba[0], 128.0) + step(128.0, rgba[1]) - 127.0;\n float Mantissa = mod(rgba[1], 128.0) * 65536.0 + rgba[2] * 256.0 + rgba[3] + 8388608.0;\n return Sign * exp2(Exponent - 23.0) * Mantissa;\n }\n vec4 decodevec4 (vec4 x, vec4 y, vec4 z, vec4 w) {\n return vec4(\n decode32(x.wzyx * 255.0),\n decode32(y.wzyx * 255.0),\n decode32(z.wzyx * 255.0),\n decode32(w.wzyx * 255.0)\n );\n }\n vec4 decodevec4 (float dx, float x, float y) {\n return decodevec4(\n texture2D(jointsTexture, vec2(dx * (x + 0.5), y)),\n texture2D(jointsTexture, vec2(dx * (x + 1.5), y)),\n texture2D(jointsTexture, vec2(dx * (x + 2.5), y)),\n texture2D(jointsTexture, vec2(dx * (x + 3.5), y))\n );\n }\n mat4 getBoneMatrix(const in float i) {\n float width = jointsTextureSize.x;\n float height = jointsTextureSize.y;\n float j = i * 16.0;\n float x = mod(j, width);\n float y = floor(j / width);\n float dx = 1.0 / width;\n float dy = 1.0 / height;\n y = dy * (y + 0.5);\n vec4 v1 = decodevec4(dx, x, y);\n vec4 v2 = decodevec4(dx, x+4.0, y);\n vec4 v3 = decodevec4(dx, x+8.0, y);\n vec4 v4 = decodevec4(dx, x+12.0, y);\n return mat4(v1, v2, v3, v4);\n }\n #endif\n #else\n uniform mat4 jointMatrices[50];\n mat4 getBoneMatrix(const in float i) {\n return jointMatrices[int(i)];\n }\n #endif\n mat4 skinMatrix() {\n return\n getBoneMatrix(a_joints.x) * a_weights.x +\n getBoneMatrix(a_joints.y) * a_weights.y +\n getBoneMatrix(a_joints.z) * a_weights.z +\n getBoneMatrix(a_joints.w) * a_weights.w\n ;\n }\n#endif\nstruct StandardVertInput {\n vec2 uv;\n vec4 position;\n vec3 normal;\n vec4 tangent;\n vec4 color;\n};\nattribute vec3 a_position;\n#if CC_USE_ATTRIBUTE_UV0\nattribute vec2 a_uv0;\n#endif\n#if CC_USE_ATTRIBUTE_COLOR\nattribute vec4 a_color;\n#endif\n#if CC_USE_ATTRIBUTE_NORMAL\nattribute vec3 a_normal;\n#endif\n#if CC_USE_ATTRIBUTE_TANGENT\nattribute vec4 a_tangent;\n#endif\nvoid CCAttribute (out StandardVertInput In) {\n In.position = vec4(a_position, 1.0);\n #if CC_USE_ATTRIBUTE_UV0\n In.uv = a_uv0;\n #else\n In.uv = vec2(0.0);\n #endif\n #if CC_USE_ATTRIBUTE_COLOR\n In.color = a_color;\n #else\n In.color = vec4(1.0);\n #endif\n #if CC_USE_ATTRIBUTE_NORMAL\n In.normal = a_normal;\n #else\n In.normal = vec3(0.0, 1.0, 0.0);\n #endif\n #if CC_USE_ATTRIBUTE_TANGENT\n In.tangent = a_tangent;\n #else\n In.tangent = vec4(1.0, 0.0, 0.0, 0.0);\n #endif\n}\nvoid CCVertInput(out StandardVertInput In) {\n CCAttribute(In);\n #if CC_USE_SKINNING\n mat4 m = skinMatrix();\n In.position = m * In.position;\n #if CC_USE_ATTRIBUTE_NORMAL\n In.normal = (m * vec4(In.normal, 0)).xyz;\n #endif\n #if CC_USE_ATTRIBUTE_TANGENT\n In.tangent = m * In.tangent;\n #endif\n #endif\n}\n#if CC_USE_SHADOW_MAP && CC_NUM_SHADOW_LIGHTS > 0\n uniform mat4 cc_shadow_lightViewProjMatrix[2];\nuniform vec4 cc_shadow_info[2];\n #if CC_NUM_SHADOW_LIGHTS > 0\n uniform sampler2D cc_shadow_map_0;\n #endif\n #if CC_NUM_SHADOW_LIGHTS > 1\n uniform sampler2D cc_shadow_map_1;\n #endif\n varying vec4 v_posLightSpace[2];\n varying float v_depth[2];\n#endif\nvoid CCShadowInput (vec3 worldPos) {\n #if CC_USE_SHADOW_MAP && CC_NUM_SHADOW_LIGHTS > 0\n for (int i = 0; i < CC_NUM_SHADOW_LIGHTS; i++) {\n v_posLightSpace[i] = cc_shadow_lightViewProjMatrix[i] * vec4(worldPos, 1.0);\n v_depth[i] = (v_posLightSpace[i].z + cc_shadow_info[i].x) / (cc_shadow_info[i].x + cc_shadow_info[i].y);\n }\n #endif\n}\nuniform vec2 mainTiling;\nuniform vec2 mainOffset;\n#if CC_USE_ATTRIBUTE_UV0 && (USE_DIFFUSE_TEXTURE || USE_EMISSIVE_TEXTURE || USE_SPECULAR_TEXTURE || USE_NORMAL_TEXTURE)\n varying mediump vec2 v_uv0;\n#endif\n#if CC_USE_ATTRIBUTE_COLOR\n varying lowp vec4 v_color;\n#endif\n#if USE_NORMAL_TEXTURE\n varying vec3 v_tangent;\n varying vec3 v_bitangent;\n#endif\nvarying vec3 v_worldNormal;\nvarying vec3 v_worldPos;\nvarying vec3 v_viewDirection;\nvoid main () {\n StandardVertInput In;\n CCVertInput(In);\n vec4 position = In.position;\n v_worldNormal = normalize((cc_matWorldIT * vec4(In.normal, 0)).xyz);\n v_worldPos = (cc_matWorld * position).xyz;\n v_viewDirection = normalize(cc_cameraPos.xyz - v_worldPos);\n #if CC_USE_ATTRIBUTE_UV0 && (USE_DIFFUSE_TEXTURE || USE_EMISSIVE_TEXTURE || USE_SPECULAR_TEXTURE || USE_NORMAL_TEXTURE)\n v_uv0 = In.uv * mainTiling + mainOffset;\n #endif\n #if CC_USE_ATTRIBUTE_COLOR\n v_color = In.color;\n #endif\n #if USE_NORMAL_TEXTURE\n v_tangent = normalize((cc_matWorld * vec4(In.tangent.xyz, 0.0)).xyz);\n v_bitangent = cross(v_worldNormal, v_tangent) * In.tangent.w;\n #endif\n CCShadowInput(v_worldPos);\n gl_Position = cc_matViewProj * cc_matWorld * position;\n}", + "frag": "\nprecision highp float;\nvec4 CCFragOutput (vec4 color) {\n #if OUTPUT_TO_GAMMA\n color.rgb = sqrt(color.rgb);\n #endif\n\treturn color;\n}\n#if USE_ALPHA_TEST\n uniform float alphaThreshold;\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\nuniform lowp vec4 diffuseColor;\nuniform lowp vec4 specularColor;\nuniform lowp vec4 emissiveColor;\nuniform float glossiness;\n#if USE_DIFFUSE_TEXTURE\n uniform sampler2D diffuseTexture;\n#endif\n#if USE_SPECULAR && USE_SPECULAR_TEXTURE\n uniform sampler2D specularTexture;\n#endif\n#if USE_EMISSIVE && USE_EMISSIVE_TEXTURE\n uniform sampler2D emissiveTexture;\n#endif\n#if USE_NORMAL_TEXTURE\n varying vec3 v_tangent;\n varying vec3 v_bitangent;\n uniform sampler2D normalTexture;\n#endif\nvarying vec3 v_worldNormal;\nvarying vec3 v_worldPos;\nvarying vec3 v_viewDirection;\n#if CC_USE_ATTRIBUTE_UV0 && (USE_DIFFUSE_TEXTURE || (USE_EMISSIVE && USE_EMISSIVE_TEXTURE) || (USE_SPECULAR && USE_SPECULAR_TEXTURE) || USE_NORMAL_TEXTURE)\n varying mediump vec2 v_uv0;\n#endif\n#if CC_USE_ATTRIBUTE_COLOR\n varying lowp vec4 v_color;\n#endif\n#if CC_USE_SHADOW_MAP && CC_NUM_SHADOW_LIGHTS > 0\n uniform vec4 cc_shadow_info[2];\n #if CC_NUM_SHADOW_LIGHTS > 0\n uniform sampler2D cc_shadow_map_0;\n #endif\n #if CC_NUM_SHADOW_LIGHTS > 1\n uniform sampler2D cc_shadow_map_1;\n #endif\n varying vec4 v_posLightSpace[2];\n varying float v_depth[2];\n#endif\nfloat unpackRGBAToDepth(vec4 color) {\n return dot(color, vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n}\nfloat getDepth(sampler2D shadowMap, vec2 shadowUV) {\n return unpackRGBAToDepth(texture2D(shadowMap, shadowUV));\n}\nfloat computeFallOff(float shadow, vec2 coords, float frustumEdgeFalloff) {\n return shadow;\n}\nfloat shadowSimple(sampler2D shadowMap, vec2 shadowUV, float currentDepth, float darkness) {\n float closestDepth = getDepth(shadowMap, shadowUV);\n return currentDepth > closestDepth ? 1.0 - darkness : 1.0;\n}\nfloat shadowPCF3X3(sampler2D shadowMap, vec2 shadowUV, float currentDepth, float darkness, float shadowSize) {\n float shadow = 0.0;\n for (int x = -1; x <= 1; ++x) {\n for (int y = -1; y <= 1; ++y) {\n float closestDepth = getDepth(shadowMap, shadowUV + vec2(x, y) * 1.0/shadowSize);\n shadow += currentDepth > closestDepth ? 1.0 - darkness : 1.0;\n }\n }\n shadow /= 9.0;\n return shadow;\n}\nfloat shadowPCF5X5(sampler2D shadowMap, vec2 shadowUV, float currentDepth, float darkness, float shadowSize) {\n float shadow = 0.0;\n for (int x = -2; x <= 2; ++x) {\n for (int y = -2; y <= 2; ++y) {\n float closestDepth = getDepth(shadowMap, shadowUV + vec2(x, y) * 1.0/shadowSize);\n shadow += currentDepth > closestDepth ? 1.0 - darkness : 1.0;\n }\n }\n shadow /= 25.0;\n return shadow;\n}\n#if CC_NUM_LIGHTS > 0\nuniform vec4 cc_lightPositionAndRange[4];\nuniform vec4 cc_lightDirection[4];\nuniform vec4 cc_lightColor[4];\n#endif\nstruct LightInfo {\n vec3 lightDir;\n vec3 radiance;\n vec4 lightColor;\n};\nLightInfo computeDirectionalLighting(\n vec4 lightDirection,\n vec4 lightColor\n) {\n LightInfo ret;\n ret.lightDir = -normalize(lightDirection.xyz);\n ret.radiance = lightColor.rgb;\n ret.lightColor = lightColor;\n return ret;\n}\nLightInfo computePointLighting(\n vec3 worldPosition,\n vec4 lightPositionAndRange,\n vec4 lightColor\n) {\n LightInfo ret;\n vec3 lightDir = lightPositionAndRange.xyz - worldPosition;\n float attenuation = max(0., 1.0 - length(lightDir) / lightPositionAndRange.w);\n ret.lightDir = normalize(lightDir);\n ret.radiance = lightColor.rgb * attenuation;\n ret.lightColor = lightColor;\n return ret;\n}\nLightInfo computeSpotLighting(\n vec3 worldPosition,\n vec4 lightPositionAndRange,\n vec4 lightDirection,\n vec4 lightColor\n) {\n LightInfo ret;\n vec3 lightDir = lightPositionAndRange.xyz - worldPosition;\n float attenuation = max(0., 1.0 - length(lightDir) / lightPositionAndRange.w);\n lightDir = normalize(lightDir);\n float cosConeAngle = max(0., dot(lightDirection.xyz, -lightDir));\n cosConeAngle = cosConeAngle < lightDirection.w ? 0. : cosConeAngle;\n cosConeAngle = pow(cosConeAngle, lightColor.w);\n ret.lightDir = lightDir;\n ret.radiance = lightColor.rgb * attenuation * cosConeAngle;\n ret.lightColor = lightColor;\n return ret;\n}\nstruct Lighting {\n vec3 diffuse;\n vec3 specular;\n};\nstruct PhongSurface {\n vec3 diffuse;\n vec3 emissive;\n vec3 specular;\n float opacity;\n float glossiness;\n vec3 position;\n vec3 normal;\n vec3 viewDirection;\n};\nLighting brdf (PhongSurface s, LightInfo info) {\n Lighting result;\n float ndh = 0.0;\n vec3 halfDir = normalize(s.viewDirection + info.lightDir);\n float NdotH = max(0.0, dot(s.normal, halfDir));\n NdotH = pow(NdotH, max(1.0, s.glossiness * 128.0));\n result.diffuse = info.radiance * max(0.0, dot(s.normal, info.lightDir));\n result.specular = info.radiance * NdotH;\n return result;\n}\nvec4 composePhongShading (Lighting lighting, PhongSurface s) {\n vec4 o = vec4(0.0, 0.0, 0.0, 1.0);\n o.rgb = lighting.diffuse * s.diffuse;\n #if USE_EMISSIVE\n o.rgb += s.emissive;\n #endif\n #if USE_SPECULAR\n o.rgb += lighting.specular * s.specular;\n #endif\n o.a = s.opacity;\n return o;\n}\nvec3 ambient(PhongSurface s, vec4 ambientColor) {\n return s.diffuse * ambientColor.rgb;\n}\nvec4 CCPhongShading (in PhongSurface s) {\n Lighting result;\n result.diffuse = vec3(0, 0, 0);\n result.specular = vec3(0, 0, 0);\n #if CC_NUM_LIGHTS > 0\n #if CC_LIGHT_0_TYPE == 3\n result.diffuse += ambient(s, cc_lightColor[0]);\n #else\n LightInfo info0;\n #if CC_LIGHT_0_TYPE == 0\n info0 = computeDirectionalLighting(cc_lightDirection[0], cc_lightColor[0]);\n #elif CC_LIGHT_0_TYPE == 1\n info0 = computePointLighting(s.position, cc_lightPositionAndRange[0], cc_lightColor[0]);\n #elif CC_LIGHT_0_TYPE == 2\n info0 = computeSpotLighting(s.position, cc_lightPositionAndRange[0], cc_lightDirection[0], cc_lightColor[0]);\n #endif\n Lighting result0 = brdf(s, info0);\n #if CC_USE_SHADOW_MAP && CC_NUM_SHADOW_LIGHTS > 0\n float shadow_0 = 1.0;\n vec2 projCoords0 = v_posLightSpace[0].xy / v_posLightSpace[0].w;\n vec2 shadowUV0 = projCoords0 * 0.5 + vec2(0.5);\n if (shadowUV0.x >= 0.0 && shadowUV0.x <= 1.0 && shadowUV0.y >= 0.0 && shadowUV0.y <= 1.0) {\n float currentDepth0 = clamp(v_depth[0], 0.0, 1.0);\n #if CC_SHADOW_0_TYPE == 3\n shadow_0 = shadowPCF3X3(cc_shadow_map_0, shadowUV0, currentDepth0, cc_shadow_info[0].w, cc_shadow_info[0].z);\n #elif CC_SHADOW_0_TYPE == 4\n shadow_0 = shadowPCF5X5(cc_shadow_map_0, shadowUV0, currentDepth0, cc_shadow_info[0].w, cc_shadow_info[0].z);\n #else\n shadow_0 = shadowSimple(cc_shadow_map_0, shadowUV0, currentDepth0, cc_shadow_info[0].w);\n #endif\n shadow_0 = computeFallOff(shadow_0, projCoords0, 0.0);\n }\n result0.diffuse *= shadow_0;\n result0.specular *= shadow_0;\n #endif\n result.diffuse += result0.diffuse;\n result.specular += result0.specular;\n #endif\n #endif\n #if CC_NUM_LIGHTS > 1\n #if CC_LIGHT_1_TYPE == 3\n result.diffuse += ambient(s, cc_lightColor[1]);\n #else\n LightInfo info1;\n #if CC_LIGHT_1_TYPE == 0\n info1 = computeDirectionalLighting(cc_lightDirection[1], cc_lightColor[1]);\n #elif CC_LIGHT_1_TYPE == 1\n info1 = computePointLighting(s.position, cc_lightPositionAndRange[1], cc_lightColor[1]);\n #elif CC_LIGHT_1_TYPE == 2\n info1 = computeSpotLighting(s.position, cc_lightPositionAndRange[1], cc_lightDirection[1], cc_lightColor[1]);\n #endif\n Lighting result1 = brdf(s, info1);\n #if CC_USE_SHADOW_MAP && CC_NUM_SHADOW_LIGHTS > 1\n float shadow_1 = 1.0;\n vec2 projCoords1 = v_posLightSpace[1].xy / v_posLightSpace[1].w;\n vec2 shadowUV1 = projCoords1 * 0.5 + vec2(0.5);\n if (shadowUV1.x >= 0.0 && shadowUV1.x <= 1.0 && shadowUV1.y >= 0.0 && shadowUV1.y <= 1.0) {\n float currentDepth1 = clamp(v_depth[1], 0.0, 1.0);\n #if CC_SHADOW_1_TYPE == 3\n shadow_1 = shadowPCF3X3(cc_shadow_map_1, shadowUV1, currentDepth1, cc_shadow_info[1].w, cc_shadow_info[1].z);\n #elif CC_SHADOW_1_TYPE == 4\n shadow_1 = shadowPCF5X5(cc_shadow_map_1, shadowUV1, currentDepth1, cc_shadow_info[1].w, cc_shadow_info[1].z);\n #else\n shadow_1 = shadowSimple(cc_shadow_map_1, shadowUV1, currentDepth1, cc_shadow_info[1].w);\n #endif\n shadow_1 = computeFallOff(shadow_1, projCoords1, 0.0);\n }\n result1.diffuse *= shadow_1;\n result1.specular *= shadow_1;\n #endif\n result.diffuse += result1.diffuse;\n result.specular += result1.specular;\n #endif\n #endif\n #if CC_NUM_LIGHTS > 2\n #if CC_LIGHT_2_TYPE == 3\n result.diffuse += ambient(s, cc_lightColor[2]);\n #else\n LightInfo info2;\n #if CC_LIGHT_2_TYPE == 0\n info2 = computeDirectionalLighting(cc_lightDirection[2], cc_lightColor[2]);\n #elif CC_LIGHT_2_TYPE == 1\n info2 = computePointLighting(s.position, cc_lightPositionAndRange[2], cc_lightColor[2]);\n #elif CC_LIGHT_2_TYPE == 2\n info2 = computeSpotLighting(s.position, cc_lightPositionAndRange[2], cc_lightDirection[2], cc_lightColor[2]);\n #endif\n Lighting result2 = brdf(s, info2);\n #if CC_USE_SHADOW_MAP && CC_NUM_SHADOW_LIGHTS > 2\n float shadow_2 = 1.0;\n vec2 projCoords2 = v_posLightSpace[2].xy / v_posLightSpace[2].w;\n vec2 shadowUV2 = projCoords2 * 0.5 + vec2(0.5);\n if (shadowUV2.x >= 0.0 && shadowUV2.x <= 1.0 && shadowUV2.y >= 0.0 && shadowUV2.y <= 1.0) {\n float currentDepth2 = clamp(v_depth[2], 0.0, 1.0);\n #if CC_SHADOW_2_TYPE == 3\n shadow_2 = shadowPCF3X3(cc_shadow_map_2, shadowUV2, currentDepth2, cc_shadow_info[2].w, cc_shadow_info[2].z);\n #elif CC_SHADOW_2_TYPE == 4\n shadow_2 = shadowPCF5X5(cc_shadow_map_2, shadowUV2, currentDepth2, cc_shadow_info[2].w, cc_shadow_info[2].z);\n #else\n shadow_2 = shadowSimple(cc_shadow_map_2, shadowUV2, currentDepth2, cc_shadow_info[2].w);\n #endif\n shadow_2 = computeFallOff(shadow_2, projCoords2, 0.0);\n }\n result2.diffuse *= shadow_2;\n result2.specular *= shadow_2;\n #endif\n result.diffuse += result2.diffuse;\n result.specular += result2.specular;\n #endif\n #endif\n #if CC_NUM_LIGHTS > 3\n #if CC_LIGHT_3_TYPE == 3\n result.diffuse += ambient(s, cc_lightColor[3]);\n #else\n LightInfo info3;\n #if CC_LIGHT_3_TYPE == 0\n info3 = computeDirectionalLighting(cc_lightDirection[3], cc_lightColor[3]);\n #elif CC_LIGHT_3_TYPE == 1\n info3 = computePointLighting(s.position, cc_lightPositionAndRange[3], cc_lightColor[3]);\n #elif CC_LIGHT_3_TYPE == 2\n info3 = computeSpotLighting(s.position, cc_lightPositionAndRange[3], cc_lightDirection[3], cc_lightColor[3]);\n #endif\n Lighting result3 = brdf(s, info3);\n #if CC_USE_SHADOW_MAP && CC_NUM_SHADOW_LIGHTS > 3\n float shadow_3 = 1.0;\n vec2 projCoords3 = v_posLightSpace[3].xy / v_posLightSpace[3].w;\n vec2 shadowUV3 = projCoords3 * 0.5 + vec2(0.5);\n if (shadowUV3.x >= 0.0 && shadowUV3.x <= 1.0 && shadowUV3.y >= 0.0 && shadowUV3.y <= 1.0) {\n float currentDepth3 = clamp(v_depth[3], 0.0, 1.0);\n #if CC_SHADOW_3_TYPE == 3\n shadow_3 = shadowPCF3X3(cc_shadow_map_3, shadowUV3, currentDepth3, cc_shadow_info[3].w, cc_shadow_info[3].z);\n #elif CC_SHADOW_3_TYPE == 4\n shadow_3 = shadowPCF5X5(cc_shadow_map_3, shadowUV3, currentDepth3, cc_shadow_info[3].w, cc_shadow_info[3].z);\n #else\n shadow_3 = shadowSimple(cc_shadow_map_3, shadowUV3, currentDepth3, cc_shadow_info[3].w);\n #endif\n shadow_3 = computeFallOff(shadow_3, projCoords3, 0.0);\n }\n result3.diffuse *= shadow_3;\n result3.specular *= shadow_3;\n #endif\n result.diffuse += result3.diffuse;\n result.specular += result3.specular;\n #endif\n #endif\n return composePhongShading(result, s);\n}\nvoid surf (out PhongSurface s) {\n vec4 diffuse = vec4(1, 1, 1, 1);\n #if CC_USE_ATTRIBUTE_COLOR\n diffuse *= v_color;\n #endif\n diffuse *= diffuseColor;\n #if USE_DIFFUSE_TEXTURE\n vec4 diffuseTexture_tmp = texture2D(diffuseTexture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_diffuseTexture\n diffuseTexture_tmp.a *= texture2D(diffuseTexture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n diffuse.rgb *= (diffuseTexture_tmp.rgb * diffuseTexture_tmp.rgb);\n diffuse.a *= diffuseTexture_tmp.a;\n #else\n diffuse *= diffuseTexture_tmp;\n #endif\n #endif\n ALPHA_TEST(diffuse);\n s.diffuse = diffuse.rgb;\n s.opacity = diffuse.a;\n #if USE_EMISSIVE\n s.emissive = emissiveColor.rgb;\n #if USE_EMISSIVE_TEXTURE\n vec4 emissiveTexture_tmp = texture2D(emissiveTexture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_emissiveTexture\n emissiveTexture_tmp.a *= texture2D(emissiveTexture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n s.emissive.rgb *= (emissiveTexture_tmp.rgb * emissiveTexture_tmp.rgb);\n #else\n s.emissive.rgb *= emissiveTexture_tmp.rgb;\n #endif\n #endif\n #endif\n #if USE_SPECULAR\n s.specular = specularColor.rgb;\n #if USE_SPECULAR_TEXTURE\n vec4 specularTexture_tmp = texture2D(specularTexture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_specularTexture\n specularTexture_tmp.a *= texture2D(specularTexture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n s.specular.rgb *= (specularTexture_tmp.rgb * specularTexture_tmp.rgb);\n #else\n s.specular.rgb *= specularTexture_tmp.rgb;\n #endif\n #endif\n #endif\n s.normal = v_worldNormal;\n #if USE_NORMAL_TEXTURE\n vec3 nmmp = texture2D(normalTexture, v_uv0).xyz - vec3(0.5);\n s.normal =\n nmmp.x * normalize(v_tangent) +\n nmmp.y * normalize(v_bitangent) +\n nmmp.z * normalize(s.normal);\n s.normal = normalize(s.normal);\n #endif\n s.position = v_worldPos;\n s.viewDirection = v_viewDirection;\n s.glossiness = glossiness;\n}\nvoid main () {\n PhongSurface s;\n surf(s);\n vec4 color = CCPhongShading(s);\n gl_FragColor = CCFragOutput(color);\n}" + }, + "builtins": { + "globals": { + "blocks": [ + { + "name": "CCGlobal", + "defines": [] + }, + { + "name": "CC_SHADOW", + "defines": [ + "CC_USE_SHADOW_MAP", + "CC_NUM_SHADOW_LIGHTS" + ] + }, + { + "name": "CCLIGHTS", + "defines": [ + "CC_NUM_LIGHTS" + ] + } + ], + "samplers": [ + { + "name": "cc_shadow_map_0", + "defines": [ + "CC_USE_SHADOW_MAP", + "CC_NUM_SHADOW_LIGHTS" + ] + }, + { + "name": "cc_shadow_map_1", + "defines": [ + "CC_USE_SHADOW_MAP", + "CC_NUM_SHADOW_LIGHTS" + ] + } + ] + }, + "locals": { + "blocks": [ + { + "name": "CCLocal", + "defines": [] + } + ], + "samplers": [] + } + }, + "defines": [ + { + "name": "CC_USE_SKINNING", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_JOINTS_TEXTRUE", + "type": "boolean", + "defines": [ + "CC_USE_SKINNING" + ] + }, + { + "name": "CC_JOINTS_TEXTURE_FLOAT32", + "type": "boolean", + "defines": [ + "CC_USE_SKINNING", + "CC_USE_JOINTS_TEXTRUE" + ] + }, + { + "name": "CC_USE_ATTRIBUTE_UV0", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_ATTRIBUTE_COLOR", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_ATTRIBUTE_NORMAL", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_ATTRIBUTE_TANGENT", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_SHADOW_MAP", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_NUM_SHADOW_LIGHTS", + "type": "number", + "defines": [ + "CC_USE_SHADOW_MAP" + ], + "range": [ + 0, + 3 + ] + }, + { + "name": "USE_DIFFUSE_TEXTURE", + "type": "boolean", + "defines": [] + }, + { + "name": "USE_NORMAL_TEXTURE", + "type": "boolean", + "defines": [] + }, + { + "name": "OUTPUT_TO_GAMMA", + "type": "boolean", + "defines": [] + }, + { + "name": "USE_ALPHA_TEST", + "type": "boolean", + "defines": [] + }, + { + "name": "USE_SPECULAR", + "type": "boolean", + "defines": [] + }, + { + "name": "USE_SPECULAR_TEXTURE", + "type": "boolean", + "defines": [ + "USE_SPECULAR" + ] + }, + { + "name": "USE_EMISSIVE", + "type": "boolean", + "defines": [] + }, + { + "name": "USE_EMISSIVE_TEXTURE", + "type": "boolean", + "defines": [ + "USE_EMISSIVE" + ] + }, + { + "name": "CC_NUM_LIGHTS", + "type": "number", + "defines": [], + "range": [ + 0, + 3 + ] + }, + { + "name": "CC_LIGHT_0_TYPE", + "type": "number", + "defines": [ + "CC_NUM_LIGHTS" + ], + "range": [ + 0, + 3 + ] + }, + { + "name": "CC_SHADOW_0_TYPE", + "type": "number", + "defines": [ + "CC_NUM_LIGHTS", + "CC_USE_SHADOW_MAP", + "CC_NUM_SHADOW_LIGHTS" + ], + "range": [ + 0, + 3 + ] + }, + { + "name": "CC_LIGHT_1_TYPE", + "type": "number", + "defines": [ + "CC_NUM_LIGHTS" + ], + "range": [ + 0, + 3 + ] + }, + { + "name": "CC_SHADOW_1_TYPE", + "type": "number", + "defines": [ + "CC_NUM_LIGHTS", + "CC_USE_SHADOW_MAP", + "CC_NUM_SHADOW_LIGHTS" + ], + "range": [ + 0, + 3 + ] + }, + { + "name": "CC_LIGHT_2_TYPE", + "type": "number", + "defines": [ + "CC_NUM_LIGHTS" + ], + "range": [ + 0, + 3 + ] + }, + { + "name": "CC_SHADOW_2_TYPE", + "type": "number", + "defines": [ + "CC_NUM_LIGHTS", + "CC_USE_SHADOW_MAP", + "CC_NUM_SHADOW_LIGHTS" + ], + "range": [ + 0, + 3 + ] + }, + { + "name": "CC_LIGHT_3_TYPE", + "type": "number", + "defines": [ + "CC_NUM_LIGHTS" + ], + "range": [ + 0, + 3 + ] + }, + { + "name": "CC_SHADOW_3_TYPE", + "type": "number", + "defines": [ + "CC_NUM_LIGHTS", + "CC_USE_SHADOW_MAP", + "CC_NUM_SHADOW_LIGHTS" + ], + "range": [ + 0, + 3 + ] + }, + { + "name": "CC_USE_ALPHA_ATLAS_diffuseTexture", + "type": "boolean", + "defines": [ + "USE_DIFFUSE_TEXTURE" + ] + }, + { + "name": "INPUT_IS_GAMMA", + "type": "boolean", + "defines": [ + "USE_DIFFUSE_TEXTURE" + ] + }, + { + "name": "CC_USE_ALPHA_ATLAS_emissiveTexture", + "type": "boolean", + "defines": [ + "USE_EMISSIVE", + "USE_EMISSIVE_TEXTURE" + ] + }, + { + "name": "CC_USE_ALPHA_ATLAS_specularTexture", + "type": "boolean", + "defines": [ + "USE_SPECULAR", + "USE_SPECULAR_TEXTURE" + ] + } + ], + "blocks": [ + { + "name": "SKINNING", + "members": [ + { + "name": "jointsTextureSize", + "type": 14, + "count": 1 + } + ], + "defines": [ + "CC_USE_SKINNING", + "CC_USE_JOINTS_TEXTRUE" + ], + "binding": 0 + }, + { + "name": "JOINT_MATRIX", + "members": [ + { + "name": "jointMatrices", + "type": 26, + "count": 50 + } + ], + "defines": [ + "CC_USE_SKINNING" + ], + "binding": 1 + }, + { + "name": "MAIN_TILING", + "members": [ + { + "name": "mainTiling", + "type": 14, + "count": 1 + }, + { + "name": "mainOffset", + "type": 14, + "count": 1 + } + ], + "defines": [], + "binding": 2 + }, + { + "name": "ALPHA_TEST", + "members": [ + { + "name": "alphaThreshold", + "type": 13, + "count": 1 + } + ], + "defines": [ + "USE_ALPHA_TEST" + ], + "binding": 3 + }, + { + "name": "PhongFrag", + "members": [ + { + "name": "diffuseColor", + "type": 16, + "count": 1 + }, + { + "name": "specularColor", + "type": 16, + "count": 1 + }, + { + "name": "emissiveColor", + "type": 16, + "count": 1 + }, + { + "name": "glossiness", + "type": 13, + "count": 1 + } + ], + "defines": [], + "binding": 4 + } + ], + "samplers": [ + { + "name": "jointsTexture", + "type": 29, + "count": 1, + "defines": [ + "CC_USE_SKINNING", + "CC_USE_JOINTS_TEXTRUE" + ], + "binding": 30 + }, + { + "name": "diffuseTexture", + "type": 29, + "count": 1, + "defines": [ + "USE_DIFFUSE_TEXTURE" + ], + "binding": 31 + }, + { + "name": "specularTexture", + "type": 29, + "count": 1, + "defines": [ + "USE_SPECULAR", + "USE_SPECULAR_TEXTURE" + ], + "binding": 32 + }, + { + "name": "emissiveTexture", + "type": 29, + "count": 1, + "defines": [ + "USE_EMISSIVE", + "USE_EMISSIVE_TEXTURE" + ], + "binding": 33 + }, + { + "name": "normalTexture", + "type": 29, + "count": 1, + "defines": [ + "USE_NORMAL_TEXTURE" + ], + "binding": 34 + } + ], + "record": null, + "name": "builtin-phong|phong-vs|phong-fs" + }, + { + "hash": 1165371292, + "glsl3": { + "vert": "\nprecision highp float;\nin vec3 a_position;\nuniform CCLocal {\n mat4 cc_matWorld;\n mat4 cc_matWorldIT;\n};\nuniform CC_SHADOW_MAP {\n mat4 cc_shadow_map_lightViewProjMatrix;\n vec4 cc_shadow_map_info;\n float cc_shadow_map_bias;\n};\nout float v_depth;\n#if CC_USE_SKINNING\n in vec4 a_weights;\n in vec4 a_joints;\n #if CC_USE_JOINTS_TEXTRUE\n uniform SKINNING {\n vec2 jointsTextureSize;\n };\n uniform sampler2D jointsTexture;\n #if CC_JOINTS_TEXTURE_FLOAT32\n mat4 getBoneMatrix(const in float i) {\n float width = jointsTextureSize.x;\n float height = jointsTextureSize.y;\n float j = i * 4.0;\n float x = mod(j, width);\n float y = floor(j / width);\n float dx = 1.0 / width;\n float dy = 1.0 / height;\n y = dy * (y + 0.5);\n vec4 v1 = texture(jointsTexture, vec2(dx * (x + 0.5), y));\n vec4 v2 = texture(jointsTexture, vec2(dx * (x + 1.5), y));\n vec4 v3 = texture(jointsTexture, vec2(dx * (x + 2.5), y));\n vec4 v4 = texture(jointsTexture, vec2(dx * (x + 3.5), y));\n return mat4(v1, v2, v3, v4);\n }\n #else\n float decode32(vec4 rgba) {\n float Sign = 1.0 - step(128.0, rgba[0]) * 2.0;\n float Exponent = 2.0 * mod(rgba[0], 128.0) + step(128.0, rgba[1]) - 127.0;\n float Mantissa = mod(rgba[1], 128.0) * 65536.0 + rgba[2] * 256.0 + rgba[3] + 8388608.0;\n return Sign * exp2(Exponent - 23.0) * Mantissa;\n }\n vec4 decodevec4 (vec4 x, vec4 y, vec4 z, vec4 w) {\n return vec4(\n decode32(x.wzyx * 255.0),\n decode32(y.wzyx * 255.0),\n decode32(z.wzyx * 255.0),\n decode32(w.wzyx * 255.0)\n );\n }\n vec4 decodevec4 (float dx, float x, float y) {\n return decodevec4(\n texture(jointsTexture, vec2(dx * (x + 0.5), y)),\n texture(jointsTexture, vec2(dx * (x + 1.5), y)),\n texture(jointsTexture, vec2(dx * (x + 2.5), y)),\n texture(jointsTexture, vec2(dx * (x + 3.5), y))\n );\n }\n mat4 getBoneMatrix(const in float i) {\n float width = jointsTextureSize.x;\n float height = jointsTextureSize.y;\n float j = i * 16.0;\n float x = mod(j, width);\n float y = floor(j / width);\n float dx = 1.0 / width;\n float dy = 1.0 / height;\n y = dy * (y + 0.5);\n vec4 v1 = decodevec4(dx, x, y);\n vec4 v2 = decodevec4(dx, x+4.0, y);\n vec4 v3 = decodevec4(dx, x+8.0, y);\n vec4 v4 = decodevec4(dx, x+12.0, y);\n return mat4(v1, v2, v3, v4);\n }\n #endif\n #else\n uniform JOINT_MATRIX {\n mat4 jointMatrices[50];\n };\n mat4 getBoneMatrix(const in float i) {\n return jointMatrices[int(i)];\n }\n #endif\n mat4 skinMatrix() {\n return\n getBoneMatrix(a_joints.x) * a_weights.x +\n getBoneMatrix(a_joints.y) * a_weights.y +\n getBoneMatrix(a_joints.z) * a_weights.z +\n getBoneMatrix(a_joints.w) * a_weights.w\n ;\n }\n#endif\nvoid SKIN_VERTEX(inout vec4 a1) {\n #if CC_USE_SKINNING\n mat4 m = skinMatrix();\n a1 = m * a1;\n #endif\n}\nvoid SKIN_VERTEX(inout vec4 a1, inout vec4 a2) {\n #if CC_USE_SKINNING\n mat4 m = skinMatrix();\n a1 = m * a1;\n a2 = m * a2;\n #endif\n}\nvoid SKIN_VERTEX(inout vec4 a1, inout vec4 a2, inout vec4 a3) {\n #if CC_USE_SKINNING\n mat4 m = skinMatrix();\n a1 = m * a1;\n a2 = m * a2;\n a3 = m * a3;\n #endif\n}\nvoid main () {\n vec4 position = vec4(a_position, 1);\n SKIN_VERTEX(position);\n gl_Position = cc_shadow_map_lightViewProjMatrix * cc_matWorld * position;\n v_depth = ((gl_Position.z + cc_shadow_map_info.x) / (cc_shadow_map_info.x + cc_shadow_map_info.y)) + cc_shadow_map_bias;\n}", + "frag": "\nprecision highp float;\nin float v_depth;\nvec4 packDepthToRGBA(float depth) {\n vec4 ret = vec4(1.0, 255.0, 65025.0, 160581375.0) * depth;\n ret = fract(ret);\n ret -= ret.yzww * vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 0.0);\n return ret;\n}\nvoid main () {\n gl_FragColor = packDepthToRGBA(v_depth);\n}" + }, + "glsl1": { + "vert": "\nprecision highp float;\nattribute vec3 a_position;\nuniform mat4 cc_matWorld;\nuniform mat4 cc_shadow_map_lightViewProjMatrix;\nuniform vec4 cc_shadow_map_info;\nuniform float cc_shadow_map_bias;\nvarying float v_depth;\n#if CC_USE_SKINNING\n attribute vec4 a_weights;\n attribute vec4 a_joints;\n #if CC_USE_JOINTS_TEXTRUE\n uniform vec2 jointsTextureSize;\n uniform sampler2D jointsTexture;\n #if CC_JOINTS_TEXTURE_FLOAT32\n mat4 getBoneMatrix(const in float i) {\n float width = jointsTextureSize.x;\n float height = jointsTextureSize.y;\n float j = i * 4.0;\n float x = mod(j, width);\n float y = floor(j / width);\n float dx = 1.0 / width;\n float dy = 1.0 / height;\n y = dy * (y + 0.5);\n vec4 v1 = texture2D(jointsTexture, vec2(dx * (x + 0.5), y));\n vec4 v2 = texture2D(jointsTexture, vec2(dx * (x + 1.5), y));\n vec4 v3 = texture2D(jointsTexture, vec2(dx * (x + 2.5), y));\n vec4 v4 = texture2D(jointsTexture, vec2(dx * (x + 3.5), y));\n return mat4(v1, v2, v3, v4);\n }\n #else\n float decode32(vec4 rgba) {\n float Sign = 1.0 - step(128.0, rgba[0]) * 2.0;\n float Exponent = 2.0 * mod(rgba[0], 128.0) + step(128.0, rgba[1]) - 127.0;\n float Mantissa = mod(rgba[1], 128.0) * 65536.0 + rgba[2] * 256.0 + rgba[3] + 8388608.0;\n return Sign * exp2(Exponent - 23.0) * Mantissa;\n }\n vec4 decodevec4 (vec4 x, vec4 y, vec4 z, vec4 w) {\n return vec4(\n decode32(x.wzyx * 255.0),\n decode32(y.wzyx * 255.0),\n decode32(z.wzyx * 255.0),\n decode32(w.wzyx * 255.0)\n );\n }\n vec4 decodevec4 (float dx, float x, float y) {\n return decodevec4(\n texture2D(jointsTexture, vec2(dx * (x + 0.5), y)),\n texture2D(jointsTexture, vec2(dx * (x + 1.5), y)),\n texture2D(jointsTexture, vec2(dx * (x + 2.5), y)),\n texture2D(jointsTexture, vec2(dx * (x + 3.5), y))\n );\n }\n mat4 getBoneMatrix(const in float i) {\n float width = jointsTextureSize.x;\n float height = jointsTextureSize.y;\n float j = i * 16.0;\n float x = mod(j, width);\n float y = floor(j / width);\n float dx = 1.0 / width;\n float dy = 1.0 / height;\n y = dy * (y + 0.5);\n vec4 v1 = decodevec4(dx, x, y);\n vec4 v2 = decodevec4(dx, x+4.0, y);\n vec4 v3 = decodevec4(dx, x+8.0, y);\n vec4 v4 = decodevec4(dx, x+12.0, y);\n return mat4(v1, v2, v3, v4);\n }\n #endif\n #else\n uniform mat4 jointMatrices[50];\n mat4 getBoneMatrix(const in float i) {\n return jointMatrices[int(i)];\n }\n #endif\n mat4 skinMatrix() {\n return\n getBoneMatrix(a_joints.x) * a_weights.x +\n getBoneMatrix(a_joints.y) * a_weights.y +\n getBoneMatrix(a_joints.z) * a_weights.z +\n getBoneMatrix(a_joints.w) * a_weights.w\n ;\n }\n#endif\nvoid SKIN_VERTEX(inout vec4 a1) {\n #if CC_USE_SKINNING\n mat4 m = skinMatrix();\n a1 = m * a1;\n #endif\n}\nvoid SKIN_VERTEX(inout vec4 a1, inout vec4 a2) {\n #if CC_USE_SKINNING\n mat4 m = skinMatrix();\n a1 = m * a1;\n a2 = m * a2;\n #endif\n}\nvoid SKIN_VERTEX(inout vec4 a1, inout vec4 a2, inout vec4 a3) {\n #if CC_USE_SKINNING\n mat4 m = skinMatrix();\n a1 = m * a1;\n a2 = m * a2;\n a3 = m * a3;\n #endif\n}\nvoid main () {\n vec4 position = vec4(a_position, 1);\n SKIN_VERTEX(position);\n gl_Position = cc_shadow_map_lightViewProjMatrix * cc_matWorld * position;\n v_depth = ((gl_Position.z + cc_shadow_map_info.x) / (cc_shadow_map_info.x + cc_shadow_map_info.y)) + cc_shadow_map_bias;\n}", + "frag": "\nprecision highp float;\nvarying float v_depth;\nvec4 packDepthToRGBA(float depth) {\n vec4 ret = vec4(1.0, 255.0, 65025.0, 160581375.0) * depth;\n ret = fract(ret);\n ret -= ret.yzww * vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 0.0);\n return ret;\n}\nvoid main () {\n gl_FragColor = packDepthToRGBA(v_depth);\n}" + }, + "builtins": { + "globals": { + "blocks": [ + { + "name": "CC_SHADOW_MAP", + "defines": [] + } + ], + "samplers": [] + }, + "locals": { + "blocks": [ + { + "name": "CCLocal", + "defines": [] + } + ], + "samplers": [] + } + }, + "defines": [ + { + "name": "CC_USE_SKINNING", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_JOINTS_TEXTRUE", + "type": "boolean", + "defines": [ + "CC_USE_SKINNING" + ] + }, + { + "name": "CC_JOINTS_TEXTURE_FLOAT32", + "type": "boolean", + "defines": [ + "CC_USE_SKINNING", + "CC_USE_JOINTS_TEXTRUE" + ] + } + ], + "blocks": [ + { + "name": "SKINNING", + "members": [ + { + "name": "jointsTextureSize", + "type": 14, + "count": 1 + } + ], + "defines": [ + "CC_USE_SKINNING", + "CC_USE_JOINTS_TEXTRUE" + ], + "binding": 0 + }, + { + "name": "JOINT_MATRIX", + "members": [ + { + "name": "jointMatrices", + "type": 26, + "count": 50 + } + ], + "defines": [ + "CC_USE_SKINNING" + ], + "binding": 1 + } + ], + "samplers": [ + { + "name": "jointsTexture", + "type": 29, + "count": 1, + "defines": [ + "CC_USE_SKINNING", + "CC_USE_JOINTS_TEXTRUE" + ], + "binding": 30 + } + ], + "record": null, + "name": "builtin-phong|shadow-map-vs|shadow-map-fs" + } + ] +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/ad/ad26be66-5bff-4a2d-aa4c-87e71ad64839.json b/Layered_virtual_list_2.x/library/imports/ad/ad26be66-5bff-4a2d-aa4c-87e71ad64839.json new file mode 100644 index 0000000..da7da3a --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/ad/ad26be66-5bff-4a2d-aa4c-87e71ad64839.json @@ -0,0 +1,2469 @@ +[ + { + "__type__": "cc.SceneAsset", + "_name": "Demo", + "_objFlags": 0, + "_native": "", + "scene": { + "__id__": 1 + }, + "asyncLoadAssets": false + }, + { + "__type__": "cc.Scene", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + } + ], + "_active": false, + "_components": [], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_is3DNode": true, + "_groupIndex": 0, + "groupIndex": 0, + "autoReleaseAssets": false, + "_id": "ad26be66-5bff-4a2d-aa4c-87e71ad64839" + }, + { + "__type__": "cc.Node", + "_name": "Canvas", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 3 + }, + { + "__id__": 5 + }, + { + "__id__": 14 + }, + { + "__id__": 34 + }, + { + "__id__": 49 + } + ], + "_active": true, + "_components": [ + { + "__id__": 56 + }, + { + "__id__": 57 + }, + { + "__id__": 58 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 252, + "g": 252, + "b": 252, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 750, + "height": 1334 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 375, + 667, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "a286bbGknJLZpRpxROV6M94" + }, + { + "__type__": "cc.Node", + "_name": "Main Camera", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 4 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "09K3aRxxtPX4CkhgKEDjJC" + }, + { + "__type__": "cc.Camera", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 3 + }, + "_enabled": true, + "_cullingMask": 4294967295, + "_clearFlags": 7, + "_backgroundColor": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_depth": -1, + "_zoomRatio": 1, + "_targetTexture": null, + "_fov": 60, + "_orthoSize": 10, + "_nearClip": 1, + "_farClip": 4096, + "_ortho": true, + "_rect": { + "__type__": "cc.Rect", + "x": 0, + "y": 0, + "width": 1, + "height": 1 + }, + "_renderStages": 1, + "_alignWithScreen": true, + "_id": "39hvvfgtBNGI33C9knv3qJ" + }, + { + "__type__": "cc.Node", + "_name": "Horizontal", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [ + { + "__id__": 6 + } + ], + "_active": false, + "_components": [ + { + "__id__": 12 + }, + { + "__id__": 13 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 500, + "height": 1000 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "36VvP0G09KXaygeBwQJi38" + }, + { + "__type__": "cc.Node", + "_name": "view", + "_objFlags": 0, + "_parent": { + "__id__": 5 + }, + "_children": [ + { + "__id__": 7 + } + ], + "_active": true, + "_components": [ + { + "__id__": 10 + }, + { + "__id__": 11 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 500, + "height": 1000 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -250, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "5cVJZx64VDAbE0+GHS+ljM" + }, + { + "__type__": "cc.Node", + "_name": "content", + "_objFlags": 0, + "_parent": { + "__id__": 6 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 8 + }, + { + "__id__": 9 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 220, + "height": 1000 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "044WGrpVlJX6HvptTPUEC1" + }, + { + "__type__": "cc.Layout", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 7 + }, + "_enabled": true, + "_layoutSize": { + "__type__": "cc.Size", + "width": 220, + "height": 1000 + }, + "_resize": 1, + "_N$layoutType": 1, + "_N$cellSize": { + "__type__": "cc.Size", + "width": 40, + "height": 40 + }, + "_N$startAxis": 0, + "_N$paddingLeft": 0, + "_N$paddingRight": 0, + "_N$paddingTop": 0, + "_N$paddingBottom": 0, + "_N$spacingX": 0, + "_N$spacingY": 5, + "_N$verticalDirection": 1, + "_N$horizontalDirection": 0, + "_N$affectedByScale": false, + "_id": "55aN0610JMRq/gQKnyzhAY" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 7 + }, + "_enabled": true, + "alignMode": 1, + "_target": null, + "_alignFlags": 13, + "_left": 0, + "_right": 280, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 220, + "_originalHeight": 0, + "_id": "e4s1D76VBHvauUganIA4KW" + }, + { + "__type__": "cc.Mask", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 6 + }, + "_enabled": false, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_spriteFrame": null, + "_type": 0, + "_segments": 64, + "_N$alphaThreshold": 0, + "_N$inverted": false, + "_id": "bf6UMcWrhOr4jcJ8Xr/ccS" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 6 + }, + "_enabled": true, + "alignMode": 1, + "_target": null, + "_alignFlags": 45, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 240, + "_originalHeight": 250, + "_id": "795+OK4EFMo68XgmKpU2O+" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 5 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "9bbda31e-ad49-43c9-aaf2-f7d9896bac69" + }, + "_type": 1, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "27RDHW2iJEgbMioz+T5We3" + }, + { + "__type__": "cc.ScrollView", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 5 + }, + "_enabled": true, + "horizontal": true, + "vertical": false, + "inertia": true, + "brake": 0.75, + "elastic": true, + "bounceDuration": 0.23, + "scrollEvents": [], + "cancelInnerEvents": true, + "_N$content": { + "__id__": 7 + }, + "content": { + "__id__": 7 + }, + "_N$horizontalScrollBar": null, + "_N$verticalScrollBar": null, + "_id": "9f7KeQvGdBb42l9mua/S+H" + }, + { + "__type__": "cc.Node", + "_name": "parent", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [ + { + "__id__": 15 + }, + { + "__id__": 21 + }, + { + "__id__": 27 + } + ], + "_active": false, + "_components": [ + { + "__id__": 33 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 40, + "g": 168, + "b": 45, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 500, + "height": 500 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "4eapwQhy9FJr1oDtIF5XMt" + }, + { + "__type__": "cc.Node", + "_name": "1", + "_objFlags": 0, + "_parent": { + "__id__": 14 + }, + "_children": [ + { + "__id__": 16 + } + ], + "_active": true, + "_components": [ + { + "__id__": 19 + }, + { + "__id__": 20 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 100 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -80.714, + 123.761, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "cclp30DuxPI40Ql8RTgIp5" + }, + { + "__type__": "cc.Node", + "_name": "New Label", + "_objFlags": 0, + "_parent": { + "__id__": 15 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 17 + }, + { + "__id__": 18 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 22.25, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "d1NK110VBOjL8p0409QsTv" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 16 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_string": "1", + "_N$string": "1", + "_fontSize": 40, + "_lineHeight": 40, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_styleFlags": 0, + "_underlineHeight": 0, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 2, + "_id": "1ec9ZPVK9DiY33RUQtjAmR" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 16 + }, + "_enabled": true, + "renderZIndex": 0, + "syncInv": 0, + "_id": "28rh4vPCtDH7mfQfnunwP+" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 15 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "dctkJzgctIRbPAF7CX/X0D" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 15 + }, + "_enabled": true, + "renderZIndex": 0, + "syncInv": 0, + "_id": "34s75vARxOxYwCNg9irB9g" + }, + { + "__type__": "cc.Node", + "_name": "2", + "_objFlags": 0, + "_parent": { + "__id__": 14 + }, + "_children": [ + { + "__id__": 22 + } + ], + "_active": true, + "_components": [ + { + "__id__": 25 + }, + { + "__id__": 26 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 184, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 100 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -80.714, + 123.761, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "f3s/MnZNRHTIi/Q+H1UxKx" + }, + { + "__type__": "cc.Node", + "_name": "New Label", + "_objFlags": 0, + "_parent": { + "__id__": 21 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 23 + }, + { + "__id__": 24 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 22.25, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "d32B7NZuBGY63WBdbVTVyG" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 22 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_string": "2", + "_N$string": "2", + "_fontSize": 40, + "_lineHeight": 40, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_styleFlags": 0, + "_underlineHeight": 0, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 2, + "_id": "14NDOGnfhG9K+YOHXLcfhJ" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 22 + }, + "_enabled": true, + "renderZIndex": 0, + "syncInv": 0, + "_id": "3b2tZBLXFLfbVjUa9moptZ" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 21 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "56VszVbJ5PB7PzxYIgK1UZ" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 21 + }, + "_enabled": true, + "renderZIndex": 0, + "syncInv": 0, + "_id": "98jNMDg2NNpL0CwReAWY24" + }, + { + "__type__": "cc.Node", + "_name": "3", + "_objFlags": 0, + "_parent": { + "__id__": 14 + }, + "_children": [ + { + "__id__": 28 + } + ], + "_active": true, + "_components": [ + { + "__id__": 31 + }, + { + "__id__": 32 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 10, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 100 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -80.714, + 123.761, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "1e4i8OlSlN1L+L8ylsTJMp" + }, + { + "__type__": "cc.Node", + "_name": "New Label", + "_objFlags": 0, + "_parent": { + "__id__": 27 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 29 + }, + { + "__id__": 30 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 22.25, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "d8eW94wH5Emo/po5DP/fed" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 28 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_string": "3", + "_N$string": "3", + "_fontSize": 40, + "_lineHeight": 40, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_styleFlags": 0, + "_underlineHeight": 0, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 2, + "_id": "7fju1YtiROgKcUrz8Jbxoo" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 28 + }, + "_enabled": true, + "renderZIndex": 0, + "syncInv": 0, + "_id": "04gNKYOURMUYIzBSFmEZQb" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 27 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "e3/Rip1ZxCQrAeRRXarp6n" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 27 + }, + "_enabled": true, + "renderZIndex": 0, + "syncInv": 0, + "_id": "27WCjM2uhB5pVrJMpptJfp" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 14 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "69pO2jE6tFNr13iHtLu7XS" + }, + { + "__type__": "cc.Node", + "_name": "New ScrollView", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [ + { + "__id__": 35 + }, + { + "__id__": 41 + } + ], + "_active": true, + "_components": [ + { + "__id__": 48 + }, + { + "__id__": 39 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 750, + "height": 800 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "4eGuzFXoZNobw3BF4ASKAl" + }, + { + "__type__": "cc.Node", + "_name": "scrollBar", + "_objFlags": 512, + "_parent": { + "__id__": 34 + }, + "_children": [ + { + "__id__": 36 + } + ], + "_active": true, + "_components": [ + { + "__id__": 38 + }, + { + "__id__": 46 + }, + { + "__id__": 47 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 12, + "height": 800 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 1, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 375, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "8akGSmvKdGfpkBdpJRBHZE" + }, + { + "__type__": "cc.Node", + "_name": "bar", + "_objFlags": 512, + "_parent": { + "__id__": 35 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 37 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 10, + "height": 30 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 1, + "y": 0 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -1, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "7bmTftw15O4qa5K7nMaeeP" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 36 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "5c3bb932-6c3c-468f-88a9-c8c61d458641" + }, + "_type": 1, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "d1YRo81MlPh75Wn1ly3AHz" + }, + { + "__type__": "cc.Scrollbar", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 35 + }, + "_enabled": true, + "_scrollView": { + "__id__": 39 + }, + "_touching": false, + "_opacity": 255, + "enableAutoHide": true, + "autoHideTime": 1, + "_N$handle": { + "__id__": 37 + }, + "_N$direction": 1, + "_id": "0aw0b7ZDtMv4f4xfCJmUds" + }, + { + "__type__": "cc.ScrollView", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 34 + }, + "_enabled": true, + "horizontal": false, + "vertical": true, + "inertia": true, + "brake": 0.75, + "elastic": true, + "bounceDuration": 0.23, + "scrollEvents": [], + "cancelInnerEvents": true, + "_N$content": { + "__id__": 40 + }, + "content": { + "__id__": 40 + }, + "_N$horizontalScrollBar": null, + "_N$verticalScrollBar": { + "__id__": 38 + }, + "_id": "a15DEfCgFF96pX2ZD3tyRp" + }, + { + "__type__": "cc.Node", + "_name": "content", + "_objFlags": 0, + "_parent": { + "__id__": 41 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 44 + }, + { + "__id__": 45 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 750, + "height": 400 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 1 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 400, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "eaaskmjr1JNpm0IyW6NXUv" + }, + { + "__type__": "cc.Node", + "_name": "view", + "_objFlags": 512, + "_parent": { + "__id__": 34 + }, + "_children": [ + { + "__id__": 40 + }, + { + "__id__": 42 + } + ], + "_active": true, + "_components": [ + { + "__id__": 43 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 750, + "height": 800 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "0eJGBTx2lAfZ5rKiVwDRan" + }, + { + "__type__": "cc.Node", + "_name": "layer", + "_objFlags": 0, + "_parent": { + "__id__": 41 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "57l2vDrEVENoXOVjZya0Sq" + }, + { + "__type__": "cc.Mask", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 41 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_spriteFrame": null, + "_type": 0, + "_segments": 64, + "_N$alphaThreshold": 0, + "_N$inverted": false, + "_id": "eagMrCa6xBFYH2Zf5TZb6W" + }, + { + "__type__": "cc.Layout", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 40 + }, + "_enabled": true, + "_layoutSize": { + "__type__": "cc.Size", + "width": 750, + "height": 400 + }, + "_resize": 1, + "_N$layoutType": 2, + "_N$cellSize": { + "__type__": "cc.Size", + "width": 40, + "height": 40 + }, + "_N$startAxis": 0, + "_N$paddingLeft": 0, + "_N$paddingRight": 0, + "_N$paddingTop": 0, + "_N$paddingBottom": 0, + "_N$spacingX": 0, + "_N$spacingY": 10, + "_N$verticalDirection": 1, + "_N$horizontalDirection": 0, + "_N$affectedByScale": false, + "_id": "0a0C+3FExHp6QjuUrpje5d" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 40 + }, + "_enabled": true, + "alignMode": 1, + "_target": null, + "_alignFlags": 41, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 220, + "_originalHeight": 0, + "_id": "b0bf5HmcdPO6RE8va/SD78" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 35 + }, + "_enabled": true, + "alignMode": 0, + "_target": null, + "_alignFlags": 37, + "_left": 350.07654921020657, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 0, + "_originalHeight": 237, + "_id": "0aL6Pd3k1COanH0KlFfNJT" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 35 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "5fe5dcaa-b513-4dc5-a166-573627b3a159" + }, + "_type": 1, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "028UkzTehDxJuY5Slc8IhY" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 34 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "9bbda31e-ad49-43c9-aaf2-f7d9896bac69" + }, + "_type": 1, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "ffF25iPJlH+Kxp09D8v2RS" + }, + { + "__type__": "cc.Node", + "_name": "New Button", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [ + { + "__id__": 50 + } + ], + "_active": false, + "_components": [ + { + "__id__": 55 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + -488.632, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "4eYy0vpB1LBY2A3u7SD33M" + }, + { + "__type__": "cc.Node", + "_name": "Background", + "_objFlags": 512, + "_parent": { + "__id__": 49 + }, + "_children": [ + { + "__id__": 51 + } + ], + "_active": true, + "_components": [ + { + "__id__": 53 + }, + { + "__id__": 54 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 0 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "74AS41UFlDxoKuiVw7MDrT" + }, + { + "__type__": "cc.Node", + "_name": "Label", + "_objFlags": 512, + "_parent": { + "__id__": 50 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 52 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "01ioYlqgpO3Zz31GV3fSke" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 51 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_string": "button", + "_N$string": "button", + "_fontSize": 20, + "_lineHeight": 40, + "_enableWrapText": false, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_styleFlags": 0, + "_underlineHeight": 0, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 1, + "_N$cacheMode": 1, + "_id": "d8YhzvrDBC3pyKvNP8jM2s" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 50 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952" + }, + "_type": 1, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "3ahjbsxYVD0KHQ1J1t4rhw" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 50 + }, + "_enabled": true, + "alignMode": 0, + "_target": null, + "_alignFlags": 45, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 100, + "_originalHeight": 40, + "_id": "5fZebfqLxKXKIP0kbOHNfA" + }, + { + "__type__": "cc.Button", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 49 + }, + "_enabled": true, + "_normalMaterial": null, + "_grayMaterial": null, + "duration": 0.1, + "zoomScale": 1.2, + "clickEvents": [], + "_N$interactable": true, + "_N$enableAutoGrayEffect": false, + "_N$transition": 3, + "transition": 3, + "_N$normalColor": { + "__type__": "cc.Color", + "r": 230, + "g": 230, + "b": 230, + "a": 255 + }, + "_N$pressedColor": { + "__type__": "cc.Color", + "r": 200, + "g": 200, + "b": 200, + "a": 255 + }, + "pressedColor": { + "__type__": "cc.Color", + "r": 200, + "g": 200, + "b": 200, + "a": 255 + }, + "_N$hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$disabledColor": { + "__type__": "cc.Color", + "r": 120, + "g": 120, + "b": 120, + "a": 200 + }, + "_N$normalSprite": { + "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952" + }, + "_N$pressedSprite": { + "__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a" + }, + "pressedSprite": { + "__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a" + }, + "_N$hoverSprite": { + "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952" + }, + "hoverSprite": { + "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952" + }, + "_N$disabledSprite": { + "__uuid__": "29158224-f8dd-4661-a796-1ffab537140e" + }, + "_N$target": { + "__id__": 50 + }, + "_id": "caKLIVawdPZ64Zt8ZkLprq" + }, + { + "__type__": "cc.Canvas", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "_designResolution": { + "__type__": "cc.Size", + "width": 750, + "height": 1334 + }, + "_fitWidth": true, + "_fitHeight": false, + "_id": "dfvGuB0gdP+bfdBA5GrvZn" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "alignMode": 1, + "_target": null, + "_alignFlags": 45, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 0, + "_originalHeight": 0, + "_id": "ddKTtCCMFIwpiha8iT+uxE" + }, + { + "__type__": "b9be0tgoIVPk72LiE6N39f/", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "scrollView": { + "__id__": 39 + }, + "prefab": { + "__uuid__": "3a3767fc-5a7c-4f4b-b174-8f4038113095" + }, + "layer": { + "__id__": 42 + }, + "_id": "7fT97q3OtHbLCfyWtjclN3" + } +] \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/b1/b181c1e4-0a72-4a91-bfb0-ae6f36ca60bd.json b/Layered_virtual_list_2.x/library/imports/b1/b181c1e4-0a72-4a91-bfb0-ae6f36ca60bd.json new file mode 100644 index 0000000..e7522d6 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/b1/b181c1e4-0a72-4a91-bfb0-ae6f36ca60bd.json @@ -0,0 +1,4 @@ +{ + "__type__": "cc.Texture2D", + "content": "0,9729,9729,33071,33071,0,0,1" +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/b1/b181c1e4-0a72-4a91-bfb0-ae6f36ca60bd.png b/Layered_virtual_list_2.x/library/imports/b1/b181c1e4-0a72-4a91-bfb0-ae6f36ca60bd.png new file mode 100644 index 0000000..c298191 Binary files /dev/null and b/Layered_virtual_list_2.x/library/imports/b1/b181c1e4-0a72-4a91-bfb0-ae6f36ca60bd.png differ diff --git a/Layered_virtual_list_2.x/library/imports/b2/b2687ac4-099e-403c-a192-ff477686f4f5.json b/Layered_virtual_list_2.x/library/imports/b2/b2687ac4-099e-403c-a192-ff477686f4f5.json new file mode 100644 index 0000000..ff5da9c --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/b2/b2687ac4-099e-403c-a192-ff477686f4f5.json @@ -0,0 +1,9 @@ +{ + "__type__": "cc.ParticleAsset", + "_name": "atom", + "_objFlags": 0, + "_native": ".plist", + "spriteFrame": { + "__uuid__": "472df5d3-35e7-4184-9e6c-7f41bee65ee3" + } +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/b2/b2687ac4-099e-403c-a192-ff477686f4f5.plist b/Layered_virtual_list_2.x/library/imports/b2/b2687ac4-099e-403c-a192-ff477686f4f5.plist new file mode 100644 index 0000000..fea5100 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/b2/b2687ac4-099e-403c-a192-ff477686f4f5.plist @@ -0,0 +1,108 @@ + + + + + angle + 360 + angleVariance + 360 + blendFuncDestination + 1 + blendFuncSource + 770 + duration + -1 + emitterType + 0 + finishColorAlpha + 0.8399999737739563 + finishColorBlue + 0.0771484375 + finishColorGreen + 0.6349284052848816 + finishColorRed + 0.6808268427848816 + finishColorVarianceAlpha + 0.7400000095367432 + finishColorVarianceBlue + 0.9800000190734863 + finishColorVarianceGreen + 0.9800000190734863 + finishColorVarianceRed + 0.41999998688697815 + finishParticleSize + 30.31999969482422 + finishParticleSizeVariance + 0 + gravityx + 0.25 + gravityy + 0.8600000143051147 + maxParticles + 200 + maxRadius + 100 + maxRadiusVariance + 0 + minRadius + 0 + particleLifespan + 0.20000000298023224 + particleLifespanVariance + 0.5 + radialAccelVariance + 65.79000091552734 + radialAcceleration + -671.0499877929688 + rotatePerSecond + 0 + rotatePerSecondVariance + 0 + rotationEnd + -47.369998931884766 + rotationEndVariance + -142.11000061035156 + rotationStart + -47.369998931884766 + rotationStartVariance + 0 + sourcePositionVariancex + 7 + sourcePositionVariancey + 7 + sourcePositionx + 373.7277526855469 + sourcePositiony + 478.40472412109375 + speed + 0 + speedVariance + 190.7899932861328 + startColorAlpha + 0.6399999856948853 + startColorBlue + 0.3375650942325592 + startColorGreen + 0.7879231572151184 + startColorRed + 0.794921875 + startColorVarianceAlpha + 0.7799999713897705 + startColorVarianceBlue + 0.6800000071525574 + startColorVarianceGreen + 1 + startColorVarianceRed + 0.8999999761581421 + startParticleSize + 3.369999885559082 + startParticleSizeVariance + 50 + tangentialAccelVariance + 65.79000091552734 + tangentialAcceleration + -92.11000061035156 + spriteFrameUuid + 472df5d3-35e7-4184-9e6c-7f41bee65ee3 + + \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/b4/b430cea3-6ab3-4106-b073-26c698918edd.bin b/Layered_virtual_list_2.x/library/imports/b4/b430cea3-6ab3-4106-b073-26c698918edd.bin new file mode 100644 index 0000000..8d3eae3 Binary files /dev/null and b/Layered_virtual_list_2.x/library/imports/b4/b430cea3-6ab3-4106-b073-26c698918edd.bin differ diff --git a/Layered_virtual_list_2.x/library/imports/b4/b430cea3-6ab3-4106-b073-26c698918edd.json b/Layered_virtual_list_2.x/library/imports/b4/b430cea3-6ab3-4106-b073-26c698918edd.json new file mode 100644 index 0000000..52363a8 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/b4/b430cea3-6ab3-4106-b073-26c698918edd.json @@ -0,0 +1,90 @@ +[ + { + "__type__": "cc.Mesh", + "_name": "", + "_objFlags": 0, + "_native": ".bin", + "_vertexBundles": [ + { + "__id__": 1 + } + ], + "_primitives": [ + { + "__id__": 6 + } + ], + "_minPos": { + "__type__": "cc.Vec3", + "x": -0.5, + "y": -1, + "z": -0.5 + }, + "_maxPos": { + "__type__": "cc.Vec3", + "x": 0.5, + "y": 1, + "z": 0.5 + } + }, + { + "__type__": "cc.mesh.VertexBundle", + "data": { + "__id__": 2 + }, + "formats": [ + { + "__id__": 3 + }, + { + "__id__": 4 + }, + { + "__id__": 5 + } + ], + "verticesCount": 193 + }, + { + "__type__": "cc.BufferRange", + "offset": 0, + "length": 6176 + }, + { + "__type__": "cc.mesh.VertexFormat", + "name": "a_normal", + "type": 5126, + "num": 3, + "normalize": false + }, + { + "__type__": "cc.mesh.VertexFormat", + "name": "a_position", + "type": 5126, + "num": 3, + "normalize": false + }, + { + "__type__": "cc.mesh.VertexFormat", + "name": "a_uv0", + "type": 5126, + "num": 2, + "normalize": false + }, + { + "__type__": "cc.mesh.Primitive", + "vertexBundleIndices": [ + 0 + ], + "data": { + "__id__": 7 + }, + "indexUnit": 5123, + "topology": 4 + }, + { + "__type__": "cc.BufferRange", + "offset": 6176, + "length": 768 + } +] \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/b4/b43ff3c2-02bb-4874-81f7-f2dea6970f18.json b/Layered_virtual_list_2.x/library/imports/b4/b43ff3c2-02bb-4874-81f7-f2dea6970f18.json new file mode 100644 index 0000000..e7522d6 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/b4/b43ff3c2-02bb-4874-81f7-f2dea6970f18.json @@ -0,0 +1,4 @@ +{ + "__type__": "cc.Texture2D", + "content": "0,9729,9729,33071,33071,0,0,1" +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/b4/b43ff3c2-02bb-4874-81f7-f2dea6970f18.png b/Layered_virtual_list_2.x/library/imports/b4/b43ff3c2-02bb-4874-81f7-f2dea6970f18.png new file mode 100644 index 0000000..3bb6159 Binary files /dev/null and b/Layered_virtual_list_2.x/library/imports/b4/b43ff3c2-02bb-4874-81f7-f2dea6970f18.png differ diff --git a/Layered_virtual_list_2.x/library/imports/b4/b4ec1494-dff7-4875-91b7-3837f064a937.js b/Layered_virtual_list_2.x/library/imports/b4/b4ec1494-dff7-4875-91b7-3837f064a937.js new file mode 100644 index 0000000..0a3696b --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/b4/b4ec1494-dff7-4875-91b7-3837f064a937.js @@ -0,0 +1,913 @@ +"use strict"; +cc._RF.push(module, 'b4ec1SU3/dIdZG3ODfwZKk3', 'LoopList'); +// Script/LoopList.ts + +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ItemCell = exports.ShowNode = void 0; +var RenderAlternative_1 = require("./RenderAlternative"); +var ShowNode = /** @class */ (function (_super) { + __extends(ShowNode, _super); + function ShowNode() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /**是否初始化过代理组建 */ + _this.hasInit = false; + return _this; + } + /**初始化 */ + ShowNode.prototype.init = function (cell, data, renderLayer) { + this.cell = cell; + this.data = data; + if (this.renderLayer != renderLayer) { + this.renderLayer = renderLayer; + renderLayer && this.initRenders(); + } + this.initShow(); + }; + /**初始化操作 */ + ShowNode.prototype.initShow = function () { }; + /**被回收,应该做一些释放的操作 */ + ShowNode.prototype.onRecircle = function () { }; + /** + * 在特定时间内进行大小变化 + * @param targetSize + * @param time + */ + ShowNode.prototype.resize = function (targetSize, time) { + if (time === void 0) { time = 0.3; } + this.cell.resize(targetSize, time); + }; + /** + * 处理分层代理渲染 + */ + ShowNode.prototype.initRenders = function () { + if (!this.hasInit && this.renderLayer) { + var propMap = new WeakMap(); + var keys = Object.keys(this); + for (var i = 0, len = keys.length; i < len; ++i) { + var value = this[keys[i]]; + var alternative = null; + if (value instanceof cc.Node) { + alternative = value.getComponent(RenderAlternative_1.default); + if (alternative) { + alternative.init(this.renderLayer); + } + } + else if (value instanceof cc.RenderComponent) { + alternative = value.getComponent(RenderAlternative_1.default); + if (alternative) { + this[keys[i]] = alternative.init(this.renderLayer); + } + } + alternative && propMap.set(alternative, true); + } + this.dealChilrenAlternative(this.node, propMap, 0, 0); + this.hasInit = true; + } + }; + /** + * 处理子节点代理 + * @param node + * @param propMap 记录脚本已经处理过的属性代理 + * @param parentSindex 父节点的所在的顺序 + * @param depth 深度 + */ + ShowNode.prototype.dealChilrenAlternative = function (node, propMap, parentSindex, depth) { + var _a; + for (var i = 0, len = node.children.length; i < len; i++) { + var children = node.children[i]; + var alternative = (_a = children.getComponent(cc.RenderComponent)) === null || _a === void 0 ? void 0 : _a.getComponent(RenderAlternative_1.default); + var sIndex = parentSindex + (i * Math.pow(0.1, depth)); + if (alternative) { + if ((!propMap.has(alternative) || !propMap.get(alternative))) { + alternative.init(this.renderLayer); + } + alternative.sIndex = sIndex; + } + this.dealChilrenAlternative(children, propMap, sIndex, depth + 1); + } + }; + return ShowNode; +}(cc.Component)); +exports.ShowNode = ShowNode; +var ItemCell = /** @class */ (function () { + /** + * 构造函数 + * @param node + * @param looplist + */ + function ItemCell(node, looplist) { + /**持有cell的list */ + this.looplist = null; + /**位置节点 */ + this.node = null; + /**显示节点 */ + this.showNode = null; + /**尺寸 */ + this.size = null; + /**数据下标 */ + this.dataIndex = null; + /**cell下标 */ + this.cellIndex = null; + /**数据 */ + this.data = null; + this.node = node; + this.looplist = looplist; + } + /** + * 初始化 + * @param data + * @param size + * @param dataIndex + * @param cellIndex + * @param looplist + */ + ItemCell.prototype.init = function (data, size, dataIndex, cellIndex, looplist) { + cc.Tween.stopAllByTarget(this.node); + this.cellIndex = cellIndex; + this.dataIndex = dataIndex; + this.looplist = looplist; + this.node.width = size.width; + this.node.height = size.height; + this.data = data; + this.size = size; + }; + /** + * 重置大小 + * @param size + */ + ItemCell.prototype.resize = function (size, time) { + var _this = this; + var nodeSides = getNodeBorder(this, [true, true, true, true]); + var changeSize = cc.size(size.width - this.size.width, size.height - this.size.height); + this.size = size; + this.looplist.dealChangeSize(this, nodeSides, changeSize, time).then(function () { + _this.node.width = size.width; + _this.node.height = size.height; + _this.looplist.updateNodes(); + }); + }; + /** + * 更新节点显示 + * @param isShow 是否显示 + * @param prefab 需要显示的节点的预制件(也可以是节点,或者预制件url,生成方式自由改动) + * @param cacheNode 对象池中的显示节点 + * @param renderLayer 分层节点 + */ + ItemCell.prototype.updateShow = function (isShow, prefab, cacheNode, renderLayer) { + if (isShow) { + //当前没有显示节点 + if (!this.showNode) { + //如果是临时对象池还有节点则重用 + if (cacheNode) { + this.showNode = cacheNode; + } + else { //否则使用传入的预制件进行生成 + this.showNode = cc.instantiate(prefab).getComponent(ShowNode); + } + this.showNode.node.setParent(this.node); + this.showNode.node.position = cc.v3(); + this.updateShowNode(renderLayer); + } + } + }; + /** + * 更新showNode节点显示 + * @param renderLayer + */ + ItemCell.prototype.updateShowNode = function (renderLayer) { + //当前有显示节点 + if (this.showNode) { + this.showNode.init(this, this.data, renderLayer); + } + }; + Object.defineProperty(ItemCell.prototype, "hasNoNode", { + get: function () { + return !this.showNode; + }, + enumerable: false, + configurable: true + }); + ItemCell.prototype.recircle = function () { + if (this.showNode) { + var node = this.showNode; + this.showNode.getComponent(ShowNode).onRecircle(); + this.showNode.node.removeFromParent(false); + this.showNode = null; + return node; + } + }; + ItemCell.prototype.destroy = function () { + this.node.destroy(); + this.node = null; + this.looplist = null; + }; + /** + * 失去 + * @returns + */ + ItemCell.prototype.lostShowNode = function () { + if (this.showNode) { + var node = this.showNode; + this.showNode.node.removeFromParent(false); + this.showNode = null; + return node; + } + }; + /** + * 获取显示节点 + * @param showNode + */ + ItemCell.prototype.getShowNode = function (showNode) { + this.showNode = showNode; + showNode.node.setParent(this.node); + this.showNode.cell = this; + }; + return ItemCell; +}()); +exports.ItemCell = ItemCell; +/** + * 目前列表注意事项 + * 1.开启cellMaxNum后不能一行多列或者一列多行,只能单行或者单列 + */ +var LoopList = /** @class */ (function () { + function LoopList() { + /**分层节点(只有在showNode中挂载了RenderAlternative才能起作用) */ + this.renderLayer = null; + /**滚动组件 */ + this.scrollView = null; + /**cell节点最大数量 */ + this.cellMaxNum = null; + /**当前起点 */ + this.curStartIndex = null; + /**数据 */ + this.datas = []; + /**item节点们 */ + this.itemCells = []; + /**预制件 */ + this.prefab = null; + /**显示节点的池子 */ + this.showNodePool = []; + /**边缘数据 */ + this.viewSides = {}; + /**上一帧滚动容器的坐标 */ + this.lastPos = null; + /**刷新显示的间隔次数 */ + this.updateInv = 0; + /**循环切换的最后一次时间 */ + this.lastChange = 0; + /**通用尺寸 */ + this.size = null; + /**通用锚点 */ + this.anchor = null; + } + LoopList.ins = function (listName) { + if (!this.insMap.has(listName)) { + this.insMap.set(listName, new LoopList()); + } + return this.insMap.get(listName); + }; + LoopList.prototype.onLoad = function () { + this.updateBorder(); + }; + /** + * 更新边界 + */ + LoopList.prototype.updateBorder = function () { + var _this = this; + var view = this.scrollView.node.getChildByName("view"); + view.anchorX = this.scrollView.content.anchorX; + view.anchorY = this.scrollView.content.anchorY; + //修改锚点之后下一帧世界坐标才会更新,没办法只能等一帧了 + return new Promise(function (resolve, reject) { + requestAnimationFrame(function () { + var wpos = getNodeWPos(view); + //显示区域左边缘 + var leftSide = wpos.x - (view.width * view.anchorX); + //显示区域右边缘 + var rightSide = wpos.x + (view.width * (1 - view.anchorX)); + //显示区域下边缘 + var bottomSide = wpos.y - (view.height * view.anchorY); + //显示区域上边缘 + var topSide = wpos.y + (view.height * (1 - view.anchorY)); + _this.viewSides = { + leftSide: leftSide, rightSide: rightSide, bottomSide: bottomSide, topSide: topSide, + size: cc.size(view.width, view.height) + }; + _this.scrollView.content.setPosition(cc.v3(0, 0)); + resolve(); + }); + }); + }; + /** + * 初始化滚动列表 + * @param scrollView + * @param cellMaxNum cell节点的最大数量,设置成null则不启用,启用的话,要设置成(可视窗刚好能显示的最大数量*2)+2,假设最多能看到10个节点,那么设置成22 + * @param renderLayer 渲染分层的父节点,如果传入则可以配合showNode上的renderAlternative来进行渲染分层 + */ + LoopList.prototype.init = function (scrollView, renderLayer, cellMaxNum) { + return __awaiter(this, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + cellMaxNum && (this.cellMaxNum = cellMaxNum); + renderLayer && (this.renderLayer = renderLayer); + this.scrollView = scrollView; + return [4 /*yield*/, this.updateBorder()]; + case 1: + _a.sent(); + this.scrollView.node.on("scrolling", this.scrollingListener, this); + return [2 /*return*/]; + } + }); + }); + }; + /**滚动监听 */ + LoopList.prototype.scrollingListener = function () { + this.updateInv--; + if (this.updateInv <= 0) { + this.updateInv = 2; + var showCells = this.updateNodes(); + if (!this.cellMaxNum) { + return; + } + if (!this.lastPos) { + this.lastPos = this.scrollView.content.position.clone(); + } + else { + var offset = this.scrollView.content.position.clone().sub(this.lastPos); + this.lastPos = this.scrollView.content.position.clone(); + var now = cc.sys.now(); + if (!this.lastChange || (now - this.lastChange) > 100) { + this.lastChange = now; + this.dealLoopList(offset, showCells); + } + } + } + }; + /** + * 初始化 + * @param data 数据组 + * @param prefab 预制件 + * @param size 通用尺寸 + * @param anchor cell的锚点 + */ + LoopList.prototype.initData = function (data, prefab, size, anchor) { + if (anchor === void 0) { anchor = cc.v2(0.5, 0.5); } + this.datas = data; + this.size = size; + this.anchor = anchor; + this.prefab = prefab; + var len = this.cellMaxNum ? this.cellMaxNum : data.length; + this.curStartIndex = 0; + for (var i = 0; i < len; ++i) { + var itemCell = this.itemCells[i]; + if (!itemCell) { + var node = new cc.Node('LoopListCell'); + itemCell = this.itemCells[i] = new ItemCell(node, this); + node.setAnchorPoint(anchor); + node.setParent(this.scrollView.content); + } + var data_1 = this.datas[this.curStartIndex + i]; + var cellSize = data_1.size ? data_1.size : size; + itemCell.init(data_1, cellSize, this.curStartIndex + i, i, this); + } + for (var i = data.length, len_1 = this.itemCells.length; i < len_1; ++i) { + this.recircleShowNode(this.itemCells[i].recircle()); + this.itemCells[i].destroy(); + this.itemCells[i] = null; + } + this.updateNodes(); + }; + /** + * 压入新的数据 + * @param datas + */ + LoopList.prototype.pushDatas = function (datas) { + var length = this.datas.length; + for (var i = 0, len = datas.length; i < len; ++i) { + var data = datas[i]; + this.datas.push(data); + var index = length + i; + this.addNodeFromIndex(index); + } + }; + /** + * 插入新的数据 + * @param data + * @param insertIndex + */ + LoopList.prototype.insertData = function (data, insertIndex) { + if (this.datas.length >= insertIndex) { + this.datas.splice(insertIndex, 0, data); + this.addNodeFromIndex(insertIndex); + } + else { + this.pushDatas([data]); + } + }; + /** + * 移除对应数据 + * @param removeIndex + */ + LoopList.prototype.removeData = function (removeIndex) { + var _this = this; + if (this.datas.length >= removeIndex) { + this.datas.splice(removeIndex, 1); + if (this.cellMaxNum) { + var cellIndex_1 = removeIndex - this.curStartIndex; + //在使用范围内 + if (cellIndex_1 >= 0 && cellIndex_1 < this.cellMaxNum) { + var itemCell = this.itemCells[cellIndex_1]; + var nodeSides = getNodeBorder(itemCell, [true, true, true, true]); + var changeSize = cc.size(-itemCell.size.width, -itemCell.size.height); + itemCell.size = cc.size(0, 0); + this.dealChangeSize(itemCell, nodeSides, changeSize).then(function () { + //更新数据 + for (var i = cellIndex_1; i < _this.cellMaxNum; i++) { + var curDataIndex = _this.curStartIndex + i; + var curData = _this.datas[curDataIndex]; + var curCellSize = curData.size ? curData.size : _this.size; + _this.itemCells[i].init(curData, curCellSize, curDataIndex, i, _this); + _this.itemCells[i].updateShowNode(_this.renderLayer); + } + }); + } + } + else { + var itemCell_1 = this.itemCells.splice(removeIndex, 1)[0]; + var nodeSides = getNodeBorder(itemCell_1, [true, true, true, true]); + var changeSize = cc.size(-itemCell_1.size.width, -itemCell_1.size.height); + itemCell_1.size = cc.size(0, 0); + this.dealChangeSize(itemCell_1, nodeSides, changeSize).then(function () { + _this.recircleShowNode(itemCell_1.recircle()); + itemCell_1.node.destroy(); + }); + } + } + }; + /** + * 从某个数据开始更新 + * @param dataIndex + */ + LoopList.prototype.addNodeFromIndex = function (dataIndex) { + return __awaiter(this, void 0, void 0, function () { + var data, cellSize, cellIndex, i, curDataIndex, curData, curCellSize, nodeSides, itemCell_2, nodeSides_1, node, itemCell_3; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + data = this.datas[dataIndex]; + cellSize = data.size ? data.size : this.size; + if (!this.cellMaxNum) return [3 /*break*/, 1]; + cellIndex = dataIndex - this.curStartIndex; + //在使用范围内 + if (cellIndex >= 0 && cellIndex < this.cellMaxNum) { + //更新数据 + for (i = cellIndex; i < this.cellMaxNum; i++) { + curDataIndex = this.curStartIndex + i; + curData = this.datas[curDataIndex]; + curCellSize = curData.size ? curData.size : this.size; + this.itemCells[i].init(curData, curCellSize, curDataIndex, i, this); + this.itemCells[i].updateShowNode(this.renderLayer); + } + nodeSides = null; + itemCell_2 = this.itemCells[cellIndex]; + if (itemCell_2) { + nodeSides = getNodeBorder(itemCell_2, [true, true, true, true]); + itemCell_2.node.width = 0; + itemCell_2.node.height = 0; + this.dealChangeSize(itemCell_2, nodeSides, cellSize).then(function () { + itemCell_2.node.width = cellSize.width; + itemCell_2.node.height = cellSize.height; + }); + } + } + return [3 /*break*/, 4]; + case 1: + nodeSides_1 = null; + if (this.itemCells[dataIndex]) { + nodeSides_1 = getNodeBorder(this.itemCells[dataIndex], [true, true, true, true]); + } + node = new cc.Node('LoopListCell'); + node.setAnchorPoint(this.anchor); + node.setParent(this.scrollView.content); + node.setSiblingIndex(dataIndex); + itemCell_3 = new ItemCell(node, this); + this.itemCells.splice(dataIndex, 0, itemCell_3); + itemCell_3.init(data, cellSize, dataIndex, dataIndex, this); + if (!!nodeSides_1) return [3 /*break*/, 3]; + return [4 /*yield*/, new Promise(function (resolve, reject) { + requestAnimationFrame(function () { + nodeSides_1 = getNodeBorder(itemCell_3, [true, true, true, true]); + resolve(); + }); + })]; + case 2: + _a.sent(); + _a.label = 3; + case 3: + if (nodeSides_1) { + itemCell_3.node.width = 0; + itemCell_3.node.height = 0; + this.dealChangeSize(itemCell_3, nodeSides_1, cellSize).then(function () { + itemCell_3.node.width = cellSize.width; + itemCell_3.node.height = cellSize.height; + }); + } + this.dealItemShow(itemCell_3); + _a.label = 4; + case 4: return [2 /*return*/]; + } + }); + }); + }; + /** + * 处理列表的循环利用 + * @param offset + * @param dataIndexs + */ + LoopList.prototype.dealLoopList = function (offset, showCells) { + var startCell = showCells[0]; + var endCell = showCells[showCells.length - 1]; + if (this.scrollView.vertical) { + /**内容上移 */ + if (offset.y > 0) { + //已经到达最后倒数第二个节点并且还有数据 + if (this.scrollView.content.y >= (-this.itemCells[this.itemCells.length - 2].node.y - this.viewSides.size.height) && endCell.dataIndex < this.datas.length - 2) { + //显示开始数据下标(这里-1是想要顶部留一个itemcell做缓冲) + var showStart = startCell.dataIndex - 1; + //剩余可展示的数据量 + var leave = this.datas.length - showStart; + //计算应该从那个位置开始重新赋值,因为如果直接移动到最上方,数据量不够覆盖所有的cell + var cellStartIndex = Math.max(0, this.itemCells.length - leave); + //计算第一个cell的数据下标 + this.curStartIndex = showStart - cellStartIndex; + var cellTop = getNodeBorder(this.itemCells[startCell.cellIndex], [true]).topSide; + var contentHeight = 0; + var targetY = 0; + var jumpFirst = true; + var showIndex = 0; + for (var i = 0, len = this.itemCells.length; i < len; ++i) { + if (i >= cellStartIndex) { + //将当前已经显示的showNode节点直接重新设置到移动后的节点上 + if (showIndex < showCells.length && !jumpFirst) { + if (showIndex == 0) { + targetY = contentHeight; + } + var showNode = showCells[showIndex].lostShowNode(); + showIndex++; + this.itemCells[i].getShowNode(showNode); + } + jumpFirst = false; + } + var dataIndex = this.curStartIndex + i; + var data = this.datas[dataIndex]; + var cellSize = data.size ? data.size : this.size; + contentHeight += cellSize.height; + this.itemCells[i].init(data, cellSize, dataIndex, i, this); + } + //将content的位置移动到最上方并对齐移动前的状态 + var posY = targetY + (cellTop - this.viewSides.topSide); + this.scrollView.content.setPosition(cc.v3(this.scrollView.content.position.x, posY)); + this.scrollView.scrollToOffset(cc.v2(0, posY + endCell.size.height), 1); + this.lastPos = null; + } + } //内容下移 + else if (offset.y < 0) { + //已经到达第二个节点并且还有数据 + if (this.scrollView.content.y < (-this.itemCells[2].node.y) && startCell.dataIndex > 1) { + //展示的最后一个数据下表,+1是为了在底部预留一部分空间 + var showEndIndex = endCell.dataIndex + 1; + //计算应该从那个位置开始重新赋值,因为如果直接移动到最下方,数据量不够覆盖所有的cell + var cellEndIndex = Math.min(this.itemCells.length - 2, showEndIndex - 1); + //计算第一个cell的数据下标 + this.curStartIndex = Math.max(showEndIndex - (this.itemCells.length - 1), 0); + //将content的位置移动到最下方并对齐移动前的状态 + var cellTop = getNodeBorder(this.itemCells[startCell.cellIndex], [true]).topSide; + var contentHeight = 0; + var showIndex = showCells.length - 1; + for (var i = this.itemCells.length - 1; i >= 0; --i) { + if (i <= cellEndIndex) { + //将当前已经显示的showNode节点直接重新设置到移动后的节点上 + if (showIndex >= 0) { + var showNode = showCells[showIndex].lostShowNode(); + showIndex--; + this.itemCells[i].getShowNode(showNode); + } + else { + showIndex--; + } + } + var dataIndex = this.curStartIndex + i; + var data = this.datas[dataIndex]; + var cellSize = data.size ? data.size : this.size; + if (showIndex < -1) { + contentHeight += cellSize.height; + } + this.itemCells[i].init(data, cellSize, dataIndex, i, this); + } + //将content的位置移动到最下方并对齐移动前的状态 + var posY = contentHeight + (cellTop - this.viewSides.topSide); + this.scrollView.content.setPosition(cc.v3(this.scrollView.content.position.x, posY)); + this.scrollView.scrollToOffset(cc.v2(0, posY - startCell.size.height), 1); + this.lastPos = null; + } + } + } + else if (this.scrollView.horizontal) { + if (offset.x < 0) { + //已经到达最后倒数第二个节点并且还有数据 + if (this.scrollView.content.x <= (-(this.itemCells[this.itemCells.length - 2].node.x - this.viewSides.size.width)) && endCell.dataIndex < this.datas.length - 2) { + //显示开始数据下标(这里-1是想要左侧留一个itemcell做缓冲) + var showStart = startCell.dataIndex - 1; + //剩余可展示的数据量 + var leave = this.datas.length - showStart; + //计算应该从那个位置开始重新赋值,因为如果直接移动到最左侧,数据量不够覆盖所有的cell + var cellStartIndex = Math.max(0, this.itemCells.length - leave); + //计算第一个cell的数据下标 + this.curStartIndex = showStart - cellStartIndex; + var cellLeft = getNodeBorder(this.itemCells[startCell.cellIndex], [false, false, true]).leftSide; + var contentWidth = 0; + var targetX = 0; + var jumpFirst = true; + var showIndex = 0; + for (var i = 0, len = this.itemCells.length; i < len; ++i) { + if (i >= cellStartIndex) { + //将当前已经显示的showNode节点直接重新设置到移动后的节点上 + if (showIndex < showCells.length && !jumpFirst) { + if (showIndex == 0) { + targetX = contentWidth; + } + var showNode = showCells[showIndex].lostShowNode(); + showIndex++; + this.itemCells[i].getShowNode(showNode); + } + jumpFirst = false; + } + var dataIndex = this.curStartIndex + i; + var data = this.datas[dataIndex]; + var cellSize = data.size ? data.size : this.size; + contentWidth += cellSize.width; + this.itemCells[i].init(data, cellSize, dataIndex, i, this); + } + //将content的位置移动到最左侧并对齐移动前的状态 + var posX = (cellLeft - this.viewSides.leftSide) - targetX; + this.scrollView.content.setPosition(cc.v3(posX, this.scrollView.content.position.y)); + this.scrollView.scrollToOffset(cc.v2(-(posX - endCell.size.width), 0), 1); + this.lastPos = null; + } + } + else if (offset.x > 0) { + //已经到达第二个节点并且还有数据 + if (this.scrollView.content.x > (-this.itemCells[2].node.x) && startCell.dataIndex > 1) { + //展示的最后一个数据下表,+1是为了在右侧预留一部分空间 + var showEndIndex = endCell.dataIndex + 1; + //计算应该从那个位置开始重新赋值,因为如果直接移动到最右侧,数据量不够覆盖所有的cell + var cellEndIndex = Math.min(this.itemCells.length - 2, showEndIndex - 1); + //计算第一个cell的数据下标 + this.curStartIndex = Math.max(showEndIndex - (this.itemCells.length - 1), 0); + //将content的位置移动到最右侧并对齐移动前的状态 + var cellLeft = getNodeBorder(this.itemCells[startCell.cellIndex], [false, false, true]).leftSide; + var contentWidth = 0; + var showIndex = showCells.length - 1; + for (var i = this.itemCells.length - 1; i >= 0; --i) { + if (i <= cellEndIndex) { + //将当前已经显示的showNode节点直接重新设置到移动后的节点上 + if (showIndex >= 0) { + var showNode = showCells[showIndex].lostShowNode(); + showIndex--; + this.itemCells[i].getShowNode(showNode); + } + else { + showIndex--; + } + } + var dataIndex = this.curStartIndex + i; + var data = this.datas[dataIndex]; + var cellSize = data.size ? data.size : this.size; + if (showIndex < -1) { + contentWidth += cellSize.width; + } + this.itemCells[i].init(data, cellSize, dataIndex, i, this); + } + //将content的位置移动到最右侧并对齐移动前的状态 + var posX = (cellLeft - this.viewSides.leftSide) - contentWidth; + this.scrollView.content.setPosition(cc.v3(posX, this.scrollView.content.position.y)); + this.scrollView.scrollToOffset(cc.v2(-(posX + startCell.size.width), 0), 1); + this.lastPos = null; + } + } + } + }; + /**更新节点的显示 */ + LoopList.prototype.updateNodes = function () { + var showCells = []; + for (var i = 0, len = this.itemCells.length; i < len; ++i) { + var itemCell = this.itemCells[i]; + var isShow = this.dealItemShow(itemCell); + if (isShow) { + showCells.push(itemCell); + } + } + return showCells; + }; + /** + * 处理cell的显示隐藏 + * @param itemCell + */ + LoopList.prototype.dealItemShow = function (itemCell) { + if (itemCell) { + var isShow = this.checkInView(itemCell); + if (isShow) { + itemCell.hasNoNode && itemCell.updateShow(isShow, this.prefab, this.showNodePool.length > 0 ? this.showNodePool.pop() : null, this.renderLayer); + } + else { + !itemCell.hasNoNode && this.recircleShowNode(itemCell.recircle()); + } + return isShow; + } + }; + /** + * 检查是否在屏幕内 + * @param node + * @returns + */ + LoopList.prototype.checkInView = function (itemCell) { + var nodeSides = getNodeBorder(itemCell, [true, true, true, true]); + //节点右侧边缘在屏幕左侧外面或者节点左边缘在屏幕右侧外面 则不在显示区域 + var horizontalOutside = nodeSides.rightSide < this.viewSides.leftSide + || nodeSides.leftSide > this.viewSides.rightSide; + var verticalOutside = false; + if (!horizontalOutside) { + //节点上边缘在屏幕下方外面或者节点下边缘在屏幕上方外面 则不在显示区域 + verticalOutside = nodeSides.topSide < this.viewSides.bottomSide + || nodeSides.bottomSide > this.viewSides.topSide; + } + return !horizontalOutside && !verticalOutside; + }; + /** + * 处理变化的大小 + * @param cell + * @param nodeSides + * @param changeSize + */ + LoopList.prototype.dealChangeSize = function (cell, nodeSides, changeSize, time) { + if (time === void 0) { time = 0.3; } + return __awaiter(this, void 0, void 0, function () { + var topToBottomFulfill, bottomToTopFulfill, leftToRightFulfill, RightToLeftFulfill; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + topToBottomFulfill = (this.scrollView.content.anchorY == 1 && nodeSides.bottomSide >= this.viewSides.topSide); + bottomToTopFulfill = (this.scrollView.content.anchorY == 0 && nodeSides.topSide <= this.viewSides.bottomSide); + if (topToBottomFulfill || bottomToTopFulfill) { + if (topToBottomFulfill) { + this.scrollView.setContentPosition(cc.v2(this.scrollView.content.x, this.scrollView.content.y + changeSize.height)); + } + else { + this.scrollView.setContentPosition(cc.v2(this.scrollView.content.x, this.scrollView.content.y - changeSize.height)); + } + } + leftToRightFulfill = (this.scrollView.content.anchorX == 0 && nodeSides.rightSide <= this.viewSides.leftSide); + RightToLeftFulfill = (this.scrollView.content.anchorX == 1 && nodeSides.leftSide >= this.viewSides.rightSide); + if (leftToRightFulfill || RightToLeftFulfill) { + if (RightToLeftFulfill) { + this.scrollView.setContentPosition(cc.v2(this.scrollView.content.x + changeSize.width, this.scrollView.content.y)); + } + else { + this.scrollView.setContentPosition(cc.v2(this.scrollView.content.x - changeSize.width, this.scrollView.content.y)); + } + } + if (!!(topToBottomFulfill || bottomToTopFulfill || leftToRightFulfill || RightToLeftFulfill)) return [3 /*break*/, 2]; + cc.Tween.stopAllByTarget(cell.node); + return [4 /*yield*/, new Promise(function (resolve, reject) { + cc.tween(cell.node).to(time, { width: cell.size.width, height: cell.size.height }).call(function () { + resolve(); + }).start(); + })]; + case 1: + _a.sent(); + _a.label = 2; + case 2: + this.updateNodes(); + return [2 /*return*/, true]; + } + }); + }); + }; + /** + * 回收显示节点 + * @param node + */ + LoopList.prototype.recircleShowNode = function (node) { + node && this.showNodePool.push(node); + }; + /** + * 释放当前列表 + */ + LoopList.prototype.freeList = function () { + this.scrollView.node.off("scrolling", this.scrollingListener); + for (var i = 0, len = this.itemCells.length; i < len; ++i) { + this.recircleShowNode(this.itemCells[i].recircle()); + this.itemCells[i].destroy(); + } + this.itemCells = []; + for (var index = 0, len = this.showNodePool.length; index < len; ++index) { + this.showNodePool[index].destroy(); + } + this.showNodePool = []; + this.renderLayer = null; + this.scrollView = null; + this.prefab = null; + }; + LoopList.insMap = new Map(); + return LoopList; +}()); +exports.default = LoopList; +/** + * 获取节点的边缘 + * @param node + * @param needArr 顺序是上 下 左 右 + */ +function getNodeBorder(cell, needArr) { + var node = cell.node; + var boderData = {}; + var wpos = getNodeWPos(node); + //显示区域上边缘 + if (needArr[0]) { + boderData.topSide = wpos.y + (node.height * (1 - node.anchorY)); + } + //显示区域下边缘 + if (needArr[1]) { + boderData.bottomSide = wpos.y - (node.height * node.anchorY); + } + //显示区域左边缘 + if (needArr[2]) { + boderData.leftSide = wpos.x - (node.width * node.anchorX); + } + //显示区域右边缘 + if (needArr[3]) { + boderData.rightSide = wpos.x + (node.width * (1 - node.anchorX)); + } + boderData.size = cc.size(node.width, node.height); + return boderData; +} +/** + * 获取节点世界坐标 + * @param node + * @returns + */ +function getNodeWPos(node) { + return node.parent.convertToWorldSpaceAR(node.position); +} + +cc._RF.pop(); \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/b4/b4ec1494-dff7-4875-91b7-3837f064a937.js.map b/Layered_virtual_list_2.x/library/imports/b4/b4ec1494-dff7-4875-91b7-3837f064a937.js.map new file mode 100644 index 0000000..f2c10e0 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/b4/b4ec1494-dff7-4875-91b7-3837f064a937.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["assets\\Script\\LoopList.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yDAAoD;AAUpD;IAA+C,4BAAY;IAA3D;QAAA,qEAgFC;QA/EG,gBAAgB;QACR,aAAO,GAAY,KAAK,CAAC;;IA8ErC,CAAC;IAvEG,SAAS;IACF,uBAAI,GAAX,UAAY,IAAiB,EAAE,IAAO,EAAE,WAAoB;QACxD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,IAAI,CAAC,WAAW,IAAI,WAAW,EAAE;YACjC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;YAC/B,WAAW,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;SACrC;QACD,IAAI,CAAC,QAAQ,EAAE,CAAC;IACpB,CAAC;IACD,WAAW;IACX,2BAAQ,GAAR,cAAa,CAAC;IACd,oBAAoB;IACpB,6BAAU,GAAV,cAAe,CAAC;IAEhB;;;;OAIG;IACI,yBAAM,GAAb,UAAc,UAAmB,EAAE,IAAkB;QAAlB,qBAAA,EAAA,UAAkB;QACjD,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;IACvC,CAAC;IACD;;OAEG;IACK,8BAAW,GAAnB;QACI,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,WAAW,EAAE;YACnC,IAAI,OAAO,GAAwC,IAAI,OAAO,EAAE,CAAC;YACjE,IAAI,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC7B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,GAAG,GAAG,EAAE,EAAE,CAAC,EAAE;gBAC7C,IAAI,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;gBAC1B,IAAI,WAAW,GAAsB,IAAI,CAAC;gBAC1C,IAAI,KAAK,YAAY,EAAE,CAAC,IAAI,EAAE;oBAC1B,WAAW,GAAG,KAAK,CAAC,YAAY,CAAC,2BAAiB,CAAC,CAAC;oBACpD,IAAI,WAAW,EAAE;wBACb,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;qBACtC;iBACJ;qBAAM,IAAI,KAAK,YAAY,EAAE,CAAC,eAAe,EAAE;oBAC5C,WAAW,GAAG,KAAK,CAAC,YAAY,CAAC,2BAAiB,CAAC,CAAC;oBACpD,IAAI,WAAW,EAAE;wBACb,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,IAAI,CAAe,IAAI,CAAC,WAAW,CAAC,CAAC;qBACpE;iBACJ;gBACD,WAAW,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;aACjD;YACD,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;YACtD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;SACvB;IACL,CAAC;IACD;;;;;;OAMG;IACH,yCAAsB,GAAtB,UAAuB,IAAa,EAAE,OAA4C,EAAE,YAAoB,EAAE,KAAa;;QACnH,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE;YACtD,IAAI,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;YAChC,IAAI,WAAW,SAAG,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC,eAAe,CAAC,0CAAE,YAAY,CAAC,2BAAiB,CAAC,CAAC;YAC7F,IAAI,MAAM,GAAG,YAAY,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;YACvD,IAAI,WAAW,EAAE;gBACb,IAAI,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,EAAE;oBAC1D,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;iBACtC;gBACD,WAAW,CAAC,MAAM,GAAG,MAAM,CAAC;aAC/B;YACD,IAAI,CAAC,sBAAsB,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;SACrE;IACL,CAAC;IACL,eAAC;AAAD,CAhFA,AAgFC,CAhF8C,EAAE,CAAC,SAAS,GAgF1D;AAhFY,4BAAQ;AAiFrB;IAeI;;;;OAIG;IACH,kBAAY,IAAa,EAAE,QAAqB;QAnBhD,iBAAiB;QACV,aAAQ,GAAgB,IAAI,CAAC;QACpC,UAAU;QACH,SAAI,GAAY,IAAI,CAAC;QAC5B,UAAU;QACH,aAAQ,GAAgB,IAAI,CAAC;QACpC,QAAQ;QACD,SAAI,GAAY,IAAI,CAAC;QAC5B,UAAU;QACH,cAAS,GAAW,IAAI,CAAC;QAChC,YAAY;QACL,cAAS,GAAW,IAAI,CAAC;QAChC,QAAQ;QACD,SAAI,GAAM,IAAI,CAAC;QAOlB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC7B,CAAC;IAED;;;;;;;OAOG;IACI,uBAAI,GAAX,UAAY,IAAO,EAAE,IAAa,EAAE,SAAiB,EAAE,SAAiB,EAAE,QAAqB;QAC3F,EAAE,CAAC,KAAK,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACpC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QAC7B,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC/B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACrB,CAAC;IACD;;;OAGG;IACH,yBAAM,GAAN,UAAO,IAAa,EAAE,IAAY;QAAlC,iBASC;QARG,IAAI,SAAS,GAAG,aAAa,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;QAC9D,IAAI,UAAU,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACvF,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC;YACjE,KAAI,CAAC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;YAC7B,KAAI,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;YAC/B,KAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC;QAChC,CAAC,CAAC,CAAC;IACP,CAAC;IAED;;;;;;OAMG;IACH,6BAAU,GAAV,UAAW,MAAe,EAAE,MAAiB,EAAE,SAAsB,EAAE,WAAoB;QACvF,IAAI,MAAM,EAAE;YACR,UAAU;YACV,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;gBAChB,iBAAiB;gBACjB,IAAI,SAAS,EAAE;oBACX,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAC;iBAC7B;qBAAM,EAAC,gBAAgB;oBACpB,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;iBACjE;gBACD,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACxC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC;gBACtC,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;aACpC;SACJ;IACL,CAAC;IACD;;;OAGG;IACH,iCAAc,GAAd,UAAe,WAAoB;QAC/B,SAAS;QACT,IAAI,IAAI,CAAC,QAAQ,EAAE;YACf,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;SACpD;IACL,CAAC;IAED,sBAAI,+BAAS;aAAb;YACI,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC;QAC1B,CAAC;;;OAAA;IAED,2BAAQ,GAAR;QACI,IAAI,IAAI,CAAC,QAAQ,EAAE;YACf,IAAI,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC;YACzB,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,UAAU,EAAE,CAAC;YAClD,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;YAC3C,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;YACrB,OAAO,IAAI,CAAC;SACf;IACL,CAAC;IAGD,0BAAO,GAAP;QACI,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;QACpB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;IACzB,CAAC;IAED;;;OAGG;IACH,+BAAY,GAAZ;QACI,IAAI,IAAI,CAAC,QAAQ,EAAE;YACf,IAAI,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC;YACzB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;YAC3C,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;YACrB,OAAO,IAAI,CAAC;SACf;IACL,CAAC;IAED;;;OAGG;IACH,8BAAW,GAAX,UAAY,QAAqB;QAC7B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACnC,IAAI,CAAC,QAAQ,CAAC,IAAI,GAAG,IAAI,CAAC;IAC9B,CAAC;IACL,eAAC;AAAD,CAvIA,AAuIC,IAAA;AAvIY,4BAAQ;AAyIrB;;;GAGG;AACH;IAAA;QAQI,iDAAiD;QACzC,gBAAW,GAAY,IAAI,CAAC;QACpC,UAAU;QACF,eAAU,GAAkB,IAAI,CAAC;QACzC,gBAAgB;QACR,eAAU,GAAW,IAAI,CAAC;QAClC,UAAU;QACF,kBAAa,GAAW,IAAI,CAAC;QACrC,QAAQ;QACA,UAAK,GAAQ,EAAE,CAAC;QACxB,aAAa;QACL,cAAS,GAAkB,EAAE,CAAC;QACtC,SAAS;QACD,WAAM,GAAc,IAAI,CAAC;QACjC,aAAa;QACL,iBAAY,GAAkB,EAAE,CAAC;QACzC,UAAU;QACF,cAAS,GAAY,EAAE,CAAC;QAChC,gBAAgB;QACT,YAAO,GAAY,IAAI,CAAC;QAC/B,eAAe;QACR,cAAS,GAAW,CAAC,CAAC;QAC7B,iBAAiB;QACV,eAAU,GAAW,CAAC,CAAC;QAC9B,UAAU;QACH,SAAI,GAAY,IAAI,CAAC;QAC5B,UAAU;QACH,WAAM,GAAY,IAAI,CAAC;IAyhBlC,CAAC;IA1jBiB,YAAG,GAAjB,UAAqB,QAAgB;QACjC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;YAC5B,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,QAAQ,EAAK,CAAC,CAAC;SAChD;QACD,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAgB,CAAC;IACpD,CAAC;IA8BD,yBAAM,GAAN;QACI,IAAI,CAAC,YAAY,EAAE,CAAA;IACvB,CAAC;IAED;;OAEG;IACI,+BAAY,GAAnB;QAAA,iBAwBC;QAvBG,IAAI,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;QACvD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC;QAC/C,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC;QAC/C,6BAA6B;QAC7B,OAAO,IAAI,OAAO,CAAO,UAAC,OAAO,EAAE,MAAM;YACrC,qBAAqB,CAAC;gBAClB,IAAI,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;gBAC7B,SAAS;gBACT,IAAI,QAAQ,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC;gBACpD,SAAS;gBACT,IAAI,SAAS,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;gBAC3D,SAAS;gBACT,IAAI,UAAU,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC;gBACvD,SAAS;gBACT,IAAI,OAAO,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;gBAC1D,KAAI,CAAC,SAAS,GAAG;oBACb,QAAQ,UAAA,EAAE,SAAS,WAAA,EAAE,UAAU,YAAA,EAAE,OAAO,SAAA;oBAAE,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC;iBACnF,CAAC;gBACF,KAAI,CAAC,UAAU,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;gBACjD,OAAO,EAAE,CAAC;YACd,CAAC,CAAC,CAAA;QACN,CAAC,CAAC,CAAA;IAEN,CAAC;IAED;;;;;OAKG;IACG,uBAAI,GAAV,UAAW,UAAyB,EAAE,WAAqB,EAAE,UAAmB;;;;;wBAC5E,UAAU,IAAI,CAAC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC,CAAC;wBAC7C,WAAW,IAAI,CAAC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC,CAAC;wBAChD,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;wBAC7B,qBAAM,IAAI,CAAC,YAAY,EAAE,EAAA;;wBAAzB,SAAyB,CAAC;wBAC1B,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,WAAW,EAAE,IAAI,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC;;;;;KACtE;IAED,UAAU;IACV,oCAAiB,GAAjB;QACI,IAAI,CAAC,SAAS,EAAE,CAAC;QACjB,IAAI,IAAI,CAAC,SAAS,IAAI,CAAC,EAAE;YACrB,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC;YACnB,IAAI,SAAS,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;YAEnC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE;gBAClB,OAAO;aACV;YACD,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;gBACf,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;aAC3D;iBAAM;gBACH,IAAI,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;gBACxE,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;gBACxD,IAAI,GAAG,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;gBACvB,IAAI,CAAC,IAAI,CAAC,UAAU,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,GAAG,EAAE;oBACnD,IAAI,CAAC,UAAU,GAAG,GAAG,CAAC;oBACtB,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;iBACxC;aACJ;SACJ;IACL,CAAC;IACD;;;;;;OAMG;IACI,2BAAQ,GAAf,UAAgB,IAAS,EAAE,MAAiB,EAAE,IAAc,EAAE,MAAiC;QAAjC,uBAAA,EAAA,SAAkB,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC;QAC3F,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC;QAC1D,IAAI,CAAC,aAAa,GAAG,CAAC,CAAC;QACvB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,EAAE,EAAE,CAAC,EAAE;YAC1B,IAAI,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;YACjC,IAAI,CAAC,QAAQ,EAAE;gBACX,IAAI,IAAI,GAAG,IAAI,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,CAAA;gBACtC,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,IAAI,QAAQ,CAAI,IAAI,EAAE,IAAI,CAAC,CAAC;gBAC3D,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;gBAC5B,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;aAC3C;YACD,IAAI,MAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,GAAG,CAAC,CAAC,CAAC;YAC9C,IAAI,QAAQ,GAAG,MAAI,CAAC,IAAI,CAAC,CAAC,CAAC,MAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;YAC5C,QAAQ,CAAC,IAAI,CAAC,MAAI,EAAE,QAAQ,EAAE,IAAI,CAAC,aAAa,GAAG,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;SAClE;QACD,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,KAAG,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,GAAG,KAAG,EAAE,EAAE,CAAC,EAAE;YACjE,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;YACpD,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAA;YAC3B,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;SAC5B;QACD,IAAI,CAAC,WAAW,EAAE,CAAC;IACvB,CAAC;IAED;;;OAGG;IACI,4BAAS,GAAhB,UAAiB,KAAU;QACvB,IAAI,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;QAC/B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,GAAG,GAAG,EAAE,EAAE,CAAC,EAAE;YAC9C,IAAI,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;YACpB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACtB,IAAI,KAAK,GAAG,MAAM,GAAG,CAAC,CAAC;YACvB,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;SAChC;IACL,CAAC;IACD;;;;OAIG;IACI,6BAAU,GAAjB,UAAkB,IAAO,EAAE,WAAmB;QAC1C,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,WAAW,EAAE;YAClC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;YACxC,IAAI,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC;SACtC;aAAM;YACH,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;SAC1B;IACL,CAAC;IACD;;;OAGG;IACI,6BAAU,GAAjB,UAAkB,WAAmB;QAArC,iBAiCC;QAhCG,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,WAAW,EAAE;YAClC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;YAClC,IAAI,IAAI,CAAC,UAAU,EAAE;gBACjB,IAAI,WAAS,GAAG,WAAW,GAAG,IAAI,CAAC,aAAa,CAAC;gBACjD,QAAQ;gBACR,IAAI,WAAS,IAAI,CAAC,IAAI,WAAS,GAAG,IAAI,CAAC,UAAU,EAAE;oBAC/C,IAAI,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,WAAS,CAAC,CAAC;oBACzC,IAAI,SAAS,GAAG,aAAa,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;oBAClE,IAAI,UAAU,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;oBACtE,QAAQ,CAAC,IAAI,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;oBAC9B,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC,IAAI,CAAC;wBACtD,MAAM;wBACN,KAAK,IAAI,CAAC,GAAG,WAAS,EAAE,CAAC,GAAG,KAAI,CAAC,UAAU,EAAE,CAAC,EAAE,EAAE;4BAC9C,IAAI,YAAY,GAAG,KAAI,CAAC,aAAa,GAAG,CAAC,CAAC;4BAC1C,IAAI,OAAO,GAAG,KAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;4BACvC,IAAI,WAAW,GAAY,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,KAAI,CAAC,IAAI,CAAC;4BACnE,KAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC,EAAE,KAAI,CAAC,CAAC;4BACpE,KAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,KAAI,CAAC,WAAW,CAAC,CAAC;yBACtD;oBACL,CAAC,CAAC,CAAC;iBACN;aACJ;iBAAM;gBACH,IAAI,UAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBACxD,IAAI,SAAS,GAAG,aAAa,CAAC,UAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;gBAClE,IAAI,UAAU,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,UAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,UAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;gBACtE,UAAQ,CAAC,IAAI,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;gBAC9B,IAAI,CAAC,cAAc,CAAC,UAAQ,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC,IAAI,CAAC;oBACtD,KAAI,CAAC,gBAAgB,CAAC,UAAQ,CAAC,QAAQ,EAAE,CAAC,CAAA;oBAC1C,UAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;gBAC5B,CAAC,CAAC,CAAC;aACN;SACJ;IACL,CAAC;IACD;;;OAGG;IACW,mCAAgB,GAA9B,UAA+B,SAAiB;;;;;;wBACxC,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;wBAC7B,QAAQ,GAAY,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;6BAEtD,IAAI,CAAC,UAAU,EAAf,wBAAe;wBACX,SAAS,GAAG,SAAS,GAAG,IAAI,CAAC,aAAa,CAAC;wBAC/C,QAAQ;wBACR,IAAI,SAAS,IAAI,CAAC,IAAI,SAAS,GAAG,IAAI,CAAC,UAAU,EAAE;4BAC/C,MAAM;4BACN,KAAS,CAAC,GAAG,SAAS,EAAE,CAAC,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC,EAAE,EAAE;gCAC1C,YAAY,GAAG,IAAI,CAAC,aAAa,GAAG,CAAC,CAAC;gCACtC,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;gCACnC,WAAW,GAAY,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;gCACnE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;gCACpE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;6BACtD;4BAEG,SAAS,GAAY,IAAI,CAAC;4BAC1B,aAAwB,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;4BACtD,IAAI,UAAQ,EAAE;gCACV,SAAS,GAAG,aAAa,CAAC,UAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;gCAC9D,UAAQ,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;gCACxB,UAAQ,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;gCACzB,IAAI,CAAC,cAAc,CAAC,UAAQ,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC,IAAI,CAAC;oCACpD,UAAQ,CAAC,IAAI,CAAC,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC;oCACrC,UAAQ,CAAC,IAAI,CAAC,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC;gCAC3C,CAAC,CAAC,CAAC;6BACN;yBACJ;;;wBAGG,cAAqB,IAAI,CAAC;wBAC9B,IAAI,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE;4BAC3B,WAAS,GAAG,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;yBAClF;wBACG,IAAI,GAAG,IAAI,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,CAAA;wBACtC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;wBACjC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;wBACxC,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;wBAC5B,aAAwB,IAAI,QAAQ,CAAI,IAAI,EAAE,IAAI,CAAC,CAAC;wBACxD,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,EAAE,UAAQ,CAAC,CAAA;wBAC7C,UAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;6BACtD,CAAC,WAAS,EAAV,wBAAU;wBACV,qBAAM,IAAI,OAAO,CAAO,UAAC,OAAO,EAAE,MAAM;gCACpC,qBAAqB,CAAC;oCAClB,WAAS,GAAG,aAAa,CAAC,UAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;oCAC9D,OAAO,EAAE,CAAC;gCACd,CAAC,CAAC,CAAA;4BACN,CAAC,CAAC,EAAA;;wBALF,SAKE,CAAC;;;wBAEP,IAAI,WAAS,EAAE;4BACX,UAAQ,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;4BACxB,UAAQ,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;4BACzB,IAAI,CAAC,cAAc,CAAC,UAAQ,EAAE,WAAS,EAAE,QAAQ,CAAC,CAAC,IAAI,CAAC;gCACpD,UAAQ,CAAC,IAAI,CAAC,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC;gCACrC,UAAQ,CAAC,IAAI,CAAC,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC;4BAC3C,CAAC,CAAC,CAAC;yBACN;wBACD,IAAI,CAAC,YAAY,CAAC,UAAQ,CAAC,CAAC;;;;;;KAEnC;IAED;;;;OAIG;IACK,+BAAY,GAApB,UAAqB,MAAe,EAAE,SAAwB;QAC1D,IAAI,SAAS,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;QAC7B,IAAI,OAAO,GAAG,SAAS,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAC9C,IAAI,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE;YAC1B,UAAU;YACV,IAAI,MAAM,CAAC,CAAC,GAAG,CAAC,EAAE;gBACd,qBAAqB;gBACrB,IAAI,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;oBAC7J,mCAAmC;oBACnC,IAAI,SAAS,GAAG,SAAS,CAAC,SAAS,GAAG,CAAC,CAAC;oBACxC,YAAY;oBACZ,IAAI,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC;oBAC1C,6CAA6C;oBAC7C,IAAI,cAAc,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC;oBAChE,gBAAgB;oBAChB,IAAI,CAAC,aAAa,GAAG,SAAS,GAAG,cAAc,CAAC;oBAEhD,IAAI,OAAO,GAAG,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC;oBAEjF,IAAI,aAAa,GAAG,CAAC,CAAC;oBACtB,IAAI,OAAO,GAAG,CAAC,CAAC;oBAChB,IAAI,SAAS,GAAG,IAAI,CAAC;oBACrB,IAAI,SAAS,GAAG,CAAC,CAAC;oBAClB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,GAAG,GAAG,EAAE,EAAE,CAAC,EAAE;wBACvD,IAAI,CAAC,IAAI,cAAc,EAAE;4BACrB,kCAAkC;4BAClC,IAAI,SAAS,GAAG,SAAS,CAAC,MAAM,IAAI,CAAC,SAAS,EAAE;gCAC5C,IAAI,SAAS,IAAI,CAAC,EAAE;oCAChB,OAAO,GAAG,aAAa,CAAC;iCAC3B;gCACD,IAAI,QAAQ,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC,YAAY,EAAE,CAAC;gCACnD,SAAS,EAAE,CAAC;gCACZ,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;6BAC3C;4BACD,SAAS,GAAG,KAAK,CAAC;yBACrB;wBACD,IAAI,SAAS,GAAG,IAAI,CAAC,aAAa,GAAG,CAAC,CAAC;wBACvC,IAAI,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;wBACjC,IAAI,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;wBACjD,aAAa,IAAI,QAAQ,CAAC,MAAM,CAAC;wBACjC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;qBAC9D;oBAED,4BAA4B;oBAC5B,IAAI,IAAI,GAAG,OAAO,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAA;oBACvD,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;oBACrF,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAA;oBACvE,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;iBACvB;aACJ,CAAC,MAAM;iBACH,IAAI,MAAM,CAAC,CAAC,GAAG,CAAC,EAAE;gBACnB,iBAAiB;gBACjB,IAAI,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,SAAS,CAAC,SAAS,GAAG,CAAC,EAAE;oBACrF,6BAA6B;oBAC7B,IAAI,YAAY,GAAG,OAAO,CAAC,SAAS,GAAG,CAAC,CAAC;oBACzC,6CAA6C;oBAC7C,IAAI,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,YAAY,GAAG,CAAC,CAAC,CAAC;oBACzE,gBAAgB;oBAChB,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,GAAG,CAAC,YAAY,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;oBAE7E,4BAA4B;oBAC5B,IAAI,OAAO,GAAG,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC;oBAEjF,IAAI,aAAa,GAAG,CAAC,CAAC;oBACtB,IAAI,SAAS,GAAG,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;oBACrC,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,EAAE;wBACjD,IAAI,CAAC,IAAI,YAAY,EAAE;4BACnB,kCAAkC;4BAClC,IAAI,SAAS,IAAI,CAAC,EAAE;gCAChB,IAAI,QAAQ,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC,YAAY,EAAE,CAAC;gCACnD,SAAS,EAAE,CAAC;gCACZ,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;6BAC3C;iCAAM;gCACH,SAAS,EAAE,CAAC;6BACf;yBACJ;wBACD,IAAI,SAAS,GAAG,IAAI,CAAC,aAAa,GAAG,CAAC,CAAC;wBACvC,IAAI,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;wBACjC,IAAI,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;wBACjD,IAAI,SAAS,GAAG,CAAC,CAAC,EAAE;4BAChB,aAAa,IAAI,QAAQ,CAAC,MAAM,CAAC;yBACpC;wBACD,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;qBAC9D;oBAED,4BAA4B;oBAC5B,IAAI,IAAI,GAAG,aAAa,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAA;oBAC7D,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;oBACrF,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAA;oBACzE,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;iBACvB;aACJ;SACJ;aAAM,IAAI,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE;YACnC,IAAI,MAAM,CAAC,CAAC,GAAG,CAAC,EAAE;gBACd,qBAAqB;gBACrB,IAAI,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAE,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;oBAC9J,mCAAmC;oBACnC,IAAI,SAAS,GAAG,SAAS,CAAC,SAAS,GAAG,CAAC,CAAC;oBACxC,YAAY;oBACZ,IAAI,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC;oBAC1C,6CAA6C;oBAC7C,IAAI,cAAc,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC;oBAChE,gBAAgB;oBAChB,IAAI,CAAC,aAAa,GAAG,SAAS,GAAG,cAAc,CAAC;oBAEhD,IAAI,QAAQ,GAAG,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC;oBAEjG,IAAI,YAAY,GAAG,CAAC,CAAC;oBACrB,IAAI,OAAO,GAAG,CAAC,CAAC;oBAChB,IAAI,SAAS,GAAG,IAAI,CAAC;oBACrB,IAAI,SAAS,GAAG,CAAC,CAAC;oBAClB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,GAAG,GAAG,EAAE,EAAE,CAAC,EAAE;wBACvD,IAAI,CAAC,IAAI,cAAc,EAAE;4BACrB,kCAAkC;4BAClC,IAAI,SAAS,GAAG,SAAS,CAAC,MAAM,IAAI,CAAC,SAAS,EAAE;gCAC5C,IAAI,SAAS,IAAI,CAAC,EAAE;oCAChB,OAAO,GAAG,YAAY,CAAC;iCAC1B;gCACD,IAAI,QAAQ,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC,YAAY,EAAE,CAAC;gCACnD,SAAS,EAAE,CAAC;gCACZ,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;6BAC3C;4BACD,SAAS,GAAG,KAAK,CAAC;yBACrB;wBACD,IAAI,SAAS,GAAG,IAAI,CAAC,aAAa,GAAG,CAAC,CAAC;wBACvC,IAAI,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;wBACjC,IAAI,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;wBACjD,YAAY,IAAI,QAAQ,CAAC,KAAK,CAAC;wBAC/B,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;qBAC9D;oBAED,4BAA4B;oBAC5B,IAAI,IAAI,GAAG,CAAC,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC;oBAC1D,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;oBACrF,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;oBACzE,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;iBACvB;aACJ;iBAAM,IAAI,MAAM,CAAC,CAAC,GAAG,CAAC,EAAE;gBACrB,iBAAiB;gBACjB,IAAI,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,SAAS,CAAC,SAAS,GAAG,CAAC,EAAE;oBACpF,6BAA6B;oBAC7B,IAAI,YAAY,GAAG,OAAO,CAAC,SAAS,GAAG,CAAC,CAAC;oBACzC,6CAA6C;oBAC7C,IAAI,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,YAAY,GAAG,CAAC,CAAC,CAAC;oBACzE,gBAAgB;oBAChB,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,GAAG,CAAC,YAAY,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;oBAE7E,4BAA4B;oBAC5B,IAAI,QAAQ,GAAG,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC;oBAEjG,IAAI,YAAY,GAAG,CAAC,CAAC;oBACrB,IAAI,SAAS,GAAG,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;oBACrC,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,EAAE;wBACjD,IAAI,CAAC,IAAI,YAAY,EAAE;4BACnB,kCAAkC;4BAClC,IAAI,SAAS,IAAI,CAAC,EAAE;gCAChB,IAAI,QAAQ,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC,YAAY,EAAE,CAAC;gCACnD,SAAS,EAAE,CAAC;gCACZ,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;6BAC3C;iCAAM;gCACH,SAAS,EAAE,CAAC;6BACf;yBACJ;wBACD,IAAI,SAAS,GAAG,IAAI,CAAC,aAAa,GAAG,CAAC,CAAC;wBACvC,IAAI,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;wBACjC,IAAI,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;wBACjD,IAAI,SAAS,GAAG,CAAC,CAAC,EAAE;4BAChB,YAAY,IAAI,QAAQ,CAAC,KAAK,CAAC;yBAClC;wBACD,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;qBAC9D;oBAED,4BAA4B;oBAC5B,IAAI,IAAI,GAAG,CAAC,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,YAAY,CAAC;oBAC/D,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;oBACrF,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,EAAE,CAAC,EAAE,CAAC,CAAE,CAAC,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;oBAC5E,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;iBACvB;aACJ;SACJ;IACL,CAAC;IAGD,aAAa;IACN,8BAAW,GAAlB;QACI,IAAI,SAAS,GAAkB,EAAE,CAAC;QAClC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,GAAG,GAAG,EAAE,EAAE,CAAC,EAAE;YACvD,IAAI,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;YACjC,IAAI,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAA;YACxC,IAAI,MAAM,EAAE;gBACR,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;aAC3B;SACJ;QACD,OAAO,SAAS,CAAC;IACrB,CAAC;IAED;;;OAGG;IACK,+BAAY,GAApB,UAAqB,QAAqB;QACtC,IAAI,QAAQ,EAAE;YACV,IAAI,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;YACxC,IAAI,MAAM,EAAE;gBACR,QAAQ,CAAC,SAAS,IAAI,QAAQ,CAAC,UAAU,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;aACnJ;iBAAM;gBACH,CAAC,QAAQ,CAAC,SAAS,IAAI,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC;aACrE;YACD,OAAO,MAAM,CAAC;SACjB;IACL,CAAC;IAGD;;;;OAIG;IACK,8BAAW,GAAnB,UAAoB,QAAqB;QACrC,IAAI,SAAS,GAAG,aAAa,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;QAClE,qCAAqC;QACrC,IAAI,iBAAiB,GAAG,SAAS,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ;eAC9D,SAAS,CAAC,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC;QAErD,IAAI,eAAe,GAAG,KAAK,CAAC;QAC5B,IAAI,CAAC,iBAAiB,EAAE;YACpB,oCAAoC;YACpC,eAAe,GAAG,SAAS,CAAC,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU;mBACxD,SAAS,CAAC,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;SACxD;QACD,OAAO,CAAC,iBAAiB,IAAI,CAAC,eAAe,CAAC;IAClD,CAAC;IACD;;;;;OAKG;IACU,iCAAc,GAA3B,UAA4B,IAAiB,EAAE,SAAkB,EAAE,UAAmB,EAAE,IAAkB;QAAlB,qBAAA,EAAA,UAAkB;;;;;;wBAClG,kBAAkB,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,OAAO,IAAI,CAAC,IAAI,SAAS,CAAC,UAAU,IAAI,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;wBAC9G,kBAAkB,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,OAAO,IAAI,CAAC,IAAI,SAAS,CAAC,OAAO,IAAI,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;wBAClH,IAAI,kBAAkB,IAAI,kBAAkB,EAAE;4BAC1C,IAAI,kBAAkB,EAAE;gCACpB,IAAI,CAAC,UAAU,CAAC,kBAAkB,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,CAAA;6BACtH;iCAAM;gCACH,IAAI,CAAC,UAAU,CAAC,kBAAkB,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,CAAA;6BACtH;yBACJ;wBACG,kBAAkB,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,OAAO,IAAI,CAAC,IAAI,SAAS,CAAC,SAAS,IAAI,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;wBAC9G,kBAAkB,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,OAAO,IAAI,CAAC,IAAI,SAAS,CAAC,QAAQ,IAAI,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;wBAClH,IAAI,kBAAkB,IAAI,kBAAkB,EAAE;4BAC1C,IAAI,kBAAkB,EAAE;gCACpB,IAAI,CAAC,UAAU,CAAC,kBAAkB,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,GAAG,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAA;6BACrH;iCAAM;gCACH,IAAI,CAAC,UAAU,CAAC,kBAAkB,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,GAAG,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAA;6BACrH;yBACJ;6BACG,CAAC,CAAC,kBAAkB,IAAI,kBAAkB,IAAI,kBAAkB,IAAI,kBAAkB,CAAC,EAAvF,wBAAuF;wBACvF,EAAE,CAAC,KAAK,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;wBACpC,qBAAM,IAAI,OAAO,CAAO,UAAC,OAAO,EAAE,MAAM;gCACpC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC;oCACpF,OAAO,EAAE,CAAC;gCACd,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC;4BACf,CAAC,CAAC,EAAA;;wBAJF,SAIE,CAAA;;;wBAEN,IAAI,CAAC,WAAW,EAAE,CAAC;wBACnB,sBAAO,IAAI,EAAC;;;;KACf;IAED;;;OAGG;IACK,mCAAgB,GAAxB,UAAyB,IAAiB;QACtC,IAAI,IAAI,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACzC,CAAC;IAED;;OAEG;IACI,2BAAQ,GAAf;QACI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAC9D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,GAAG,GAAG,EAAE,EAAE,CAAC,EAAE;YACvD,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;YACpD,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;SAC/B;QACD,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;QACpB,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,KAAK,GAAG,GAAG,EAAE,EAAE,KAAK,EAAE;YACtE,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC;SACtC;QACD,IAAI,CAAC,YAAY,GAAG,EAAE,CAAC;QACvB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;IACvB,CAAC;IAzjBa,eAAM,GAA+B,IAAI,GAAG,EAAE,CAAC;IA2jBjE,eAAC;CA5jBD,AA4jBC,IAAA;kBA5jBoB,QAAQ;AA6jB7B;;;;GAIG;AACH,SAAS,aAAa,CAAC,IAAmB,EAAE,OAAkB;IAC1D,IAAI,IAAI,GAAG,IAAI,CAAC,IAAI,CAAA;IACpB,IAAI,SAAS,GAAY,EAAE,CAAC;IAC5B,IAAI,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;IAC7B,SAAS;IACT,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE;QACZ,SAAS,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;KACnE;IACD,SAAS;IACT,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE;QACZ,SAAS,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC;KAChE;IACD,SAAS;IACT,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE;QACZ,SAAS,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC;KAC7D;IACD,SAAS;IACT,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE;QACZ,SAAS,CAAC,SAAS,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;KACpE;IACD,SAAS,CAAC,IAAI,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IAClD,OAAO,SAAS,CAAC;AACrB,CAAC;AAED;;;;GAIG;AACH,SAAS,WAAW,CAAC,IAAa;IAC9B,OAAO,IAAI,CAAC,MAAM,CAAC,qBAAqB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AAC5D,CAAC","file":"","sourceRoot":"/","sourcesContent":["import RenderAlternative from \"./RenderAlternative\";\r\n\r\ninterface IBorder {\r\n leftSide?: number;\r\n rightSide?: number;\r\n bottomSide?: number;\r\n topSide?: number;\r\n size?: cc.Size;\r\n}\r\ntype TDate = { size?: cc.Size };\r\nexport class ShowNode extends cc.Component {\r\n /**是否初始化过代理组建 */\r\n private hasInit: boolean = false;\r\n /**渲染分层开启的挂载节点 */\r\n public renderLayer: cc.Node;\r\n /**上级的cell */\r\n public cell: ItemCell;\r\n /**数据 */\r\n public data: T;\r\n /**初始化 */\r\n public init(cell: ItemCell, data: T, renderLayer: cc.Node) {\r\n this.cell = cell;\r\n this.data = data;\r\n if (this.renderLayer != renderLayer) {\r\n this.renderLayer = renderLayer;\r\n renderLayer && this.initRenders();\r\n }\r\n this.initShow();\r\n }\r\n /**初始化操作 */\r\n initShow() { }\r\n /**被回收,应该做一些释放的操作 */\r\n onRecircle() { }\r\n\r\n /**\r\n * 在特定时间内进行大小变化\r\n * @param targetSize \r\n * @param time \r\n */\r\n public resize(targetSize: cc.Size, time: number = 0.3) {\r\n this.cell.resize(targetSize, time);\r\n }\r\n /**\r\n * 处理分层代理渲染\r\n */\r\n private initRenders() {\r\n if (!this.hasInit && this.renderLayer) {\r\n let propMap: WeakMap = new WeakMap();\r\n let keys = Object.keys(this);\r\n for (let i = 0, len = keys.length; i < len; ++i) {\r\n let value = this[keys[i]];\r\n let alternative: RenderAlternative = null;\r\n if (value instanceof cc.Node) {\r\n alternative = value.getComponent(RenderAlternative);\r\n if (alternative) {\r\n alternative.init(this.renderLayer);\r\n }\r\n } else if (value instanceof cc.RenderComponent) {\r\n alternative = value.getComponent(RenderAlternative);\r\n if (alternative) {\r\n this[keys[i]] = alternative.init(this.renderLayer);\r\n }\r\n }\r\n alternative && propMap.set(alternative, true);\r\n }\r\n this.dealChilrenAlternative(this.node, propMap, 0, 0);\r\n this.hasInit = true;\r\n }\r\n }\r\n /**\r\n * 处理子节点代理\r\n * @param node \r\n * @param propMap 记录脚本已经处理过的属性代理\r\n * @param parentSindex 父节点的所在的顺序\r\n * @param depth 深度\r\n */\r\n dealChilrenAlternative(node: cc.Node, propMap: WeakMap, parentSindex: number, depth: number) {\r\n for (let i = 0, len = node.children.length; i < len; i++) {\r\n let children = node.children[i];\r\n let alternative = children.getComponent(cc.RenderComponent)?.getComponent(RenderAlternative);\r\n let sIndex = parentSindex + (i * Math.pow(0.1, depth));\r\n if (alternative) {\r\n if ((!propMap.has(alternative) || !propMap.get(alternative))) {\r\n alternative.init(this.renderLayer);\r\n }\r\n alternative.sIndex = sIndex;\r\n }\r\n this.dealChilrenAlternative(children, propMap, sIndex, depth + 1);\r\n }\r\n }\r\n}\r\nexport class ItemCell {\r\n /**持有cell的list */\r\n public looplist: LoopList = null;\r\n /**位置节点 */\r\n public node: cc.Node = null;\r\n /**显示节点 */\r\n public showNode: ShowNode = null;\r\n /**尺寸 */\r\n public size: cc.Size = null;\r\n /**数据下标 */\r\n public dataIndex: number = null;\r\n /**cell下标 */\r\n public cellIndex: number = null;\r\n /**数据 */\r\n public data: T = null;\r\n /**\r\n * 构造函数\r\n * @param node \r\n * @param looplist \r\n */\r\n constructor(node: cc.Node, looplist: LoopList) {\r\n this.node = node;\r\n this.looplist = looplist;\r\n }\r\n\r\n /**\r\n * 初始化\r\n * @param data \r\n * @param size \r\n * @param dataIndex \r\n * @param cellIndex \r\n * @param looplist \r\n */\r\n public init(data: T, size: cc.Size, dataIndex: number, cellIndex: number, looplist: LoopList) {\r\n cc.Tween.stopAllByTarget(this.node);\r\n this.cellIndex = cellIndex;\r\n this.dataIndex = dataIndex;\r\n this.looplist = looplist;\r\n this.node.width = size.width;\r\n this.node.height = size.height;\r\n this.data = data;\r\n this.size = size;\r\n }\r\n /**\r\n * 重置大小\r\n * @param size \r\n */\r\n resize(size: cc.Size, time: number) {\r\n let nodeSides = getNodeBorder(this, [true, true, true, true]);\r\n let changeSize = cc.size(size.width - this.size.width, size.height - this.size.height);\r\n this.size = size;\r\n this.looplist.dealChangeSize(this, nodeSides, changeSize, time).then(() => {\r\n this.node.width = size.width;\r\n this.node.height = size.height;\r\n this.looplist.updateNodes();\r\n });\r\n }\r\n\r\n /**\r\n * 更新节点显示\r\n * @param isShow 是否显示\r\n * @param prefab 需要显示的节点的预制件(也可以是节点,或者预制件url,生成方式自由改动)\r\n * @param cacheNode 对象池中的显示节点\r\n * @param renderLayer 分层节点\r\n */\r\n updateShow(isShow: boolean, prefab: cc.Prefab, cacheNode: ShowNode, renderLayer: cc.Node) {\r\n if (isShow) {\r\n //当前没有显示节点\r\n if (!this.showNode) {\r\n //如果是临时对象池还有节点则重用\r\n if (cacheNode) {\r\n this.showNode = cacheNode;\r\n } else {//否则使用传入的预制件进行生成\r\n this.showNode = cc.instantiate(prefab).getComponent(ShowNode);\r\n }\r\n this.showNode.node.setParent(this.node);\r\n this.showNode.node.position = cc.v3();\r\n this.updateShowNode(renderLayer);\r\n }\r\n }\r\n }\r\n /**\r\n * 更新showNode节点显示\r\n * @param renderLayer \r\n */\r\n updateShowNode(renderLayer: cc.Node) {\r\n //当前有显示节点\r\n if (this.showNode) {\r\n this.showNode.init(this, this.data, renderLayer);\r\n }\r\n }\r\n\r\n get hasNoNode() {\r\n return !this.showNode;\r\n }\r\n\r\n recircle() {\r\n if (this.showNode) {\r\n let node = this.showNode;\r\n this.showNode.getComponent(ShowNode).onRecircle();\r\n this.showNode.node.removeFromParent(false);\r\n this.showNode = null;\r\n return node;\r\n }\r\n }\r\n\r\n\r\n destroy() {\r\n this.node.destroy();\r\n this.node = null;\r\n this.looplist = null;\r\n }\r\n\r\n /**\r\n * 失去\r\n * @returns \r\n */\r\n lostShowNode() {\r\n if (this.showNode) {\r\n let node = this.showNode;\r\n this.showNode.node.removeFromParent(false);\r\n this.showNode = null;\r\n return node;\r\n }\r\n }\r\n\r\n /**\r\n * 获取显示节点\r\n * @param showNode \r\n */\r\n getShowNode(showNode: ShowNode) {\r\n this.showNode = showNode;\r\n showNode.node.setParent(this.node);\r\n this.showNode.cell = this;\r\n }\r\n}\r\n\r\n/**\r\n * 目前列表注意事项\r\n * 1.开启cellMaxNum后不能一行多列或者一列多行,只能单行或者单列\r\n */\r\nexport default class LoopList {\r\n public static insMap: Map> = new Map();\r\n public static ins(listName: string): LoopList {\r\n if (!this.insMap.has(listName)) {\r\n this.insMap.set(listName, new LoopList());\r\n }\r\n return this.insMap.get(listName) as LoopList;\r\n }\r\n /**分层节点(只有在showNode中挂载了RenderAlternative才能起作用) */\r\n private renderLayer: cc.Node = null;\r\n /**滚动组件 */\r\n private scrollView: cc.ScrollView = null;\r\n /**cell节点最大数量 */\r\n private cellMaxNum: number = null;\r\n /**当前起点 */\r\n private curStartIndex: number = null;\r\n /**数据 */\r\n private datas: T[] = [];\r\n /**item节点们 */\r\n private itemCells: ItemCell[] = [];\r\n /**预制件 */\r\n private prefab: cc.Prefab = null;\r\n /**显示节点的池子 */\r\n private showNodePool: ShowNode[] = [];\r\n /**边缘数据 */\r\n private viewSides: IBorder = {};\r\n /**上一帧滚动容器的坐标 */\r\n public lastPos: cc.Vec3 = null;\r\n /**刷新显示的间隔次数 */\r\n public updateInv: number = 0;\r\n /**循环切换的最后一次时间 */\r\n public lastChange: number = 0;\r\n /**通用尺寸 */\r\n public size: cc.Size = null;\r\n /**通用锚点 */\r\n public anchor: cc.Vec2 = null;\r\n\r\n onLoad() {\r\n this.updateBorder()\r\n }\r\n\r\n /**\r\n * 更新边界\r\n */\r\n public updateBorder() {\r\n let view = this.scrollView.node.getChildByName(\"view\");\r\n view.anchorX = this.scrollView.content.anchorX;\r\n view.anchorY = this.scrollView.content.anchorY;\r\n //修改锚点之后下一帧世界坐标才会更新,没办法只能等一帧了\r\n return new Promise((resolve, reject) => {\r\n requestAnimationFrame(() => {\r\n let wpos = getNodeWPos(view);\r\n //显示区域左边缘\r\n let leftSide = wpos.x - (view.width * view.anchorX);\r\n //显示区域右边缘\r\n let rightSide = wpos.x + (view.width * (1 - view.anchorX));\r\n //显示区域下边缘\r\n let bottomSide = wpos.y - (view.height * view.anchorY);\r\n //显示区域上边缘\r\n let topSide = wpos.y + (view.height * (1 - view.anchorY));\r\n this.viewSides = {\r\n leftSide, rightSide, bottomSide, topSide, size: cc.size(view.width, view.height)\r\n };\r\n this.scrollView.content.setPosition(cc.v3(0, 0));\r\n resolve();\r\n })\r\n })\r\n\r\n }\r\n\r\n /**\r\n * 初始化滚动列表\r\n * @param scrollView \r\n * @param cellMaxNum cell节点的最大数量,设置成null则不启用,启用的话,要设置成(可视窗刚好能显示的最大数量*2)+2,假设最多能看到10个节点,那么设置成22\r\n * @param renderLayer 渲染分层的父节点,如果传入则可以配合showNode上的renderAlternative来进行渲染分层\r\n */\r\n async init(scrollView: cc.ScrollView, renderLayer?: cc.Node, cellMaxNum?: number) {\r\n cellMaxNum && (this.cellMaxNum = cellMaxNum);\r\n renderLayer && (this.renderLayer = renderLayer);\r\n this.scrollView = scrollView;\r\n await this.updateBorder();\r\n this.scrollView.node.on(\"scrolling\", this.scrollingListener, this);\r\n }\r\n\r\n /**滚动监听 */\r\n scrollingListener() {\r\n this.updateInv--;\r\n if (this.updateInv <= 0) {\r\n this.updateInv = 2;\r\n let showCells = this.updateNodes();\r\n\r\n if (!this.cellMaxNum) {\r\n return;\r\n }\r\n if (!this.lastPos) {\r\n this.lastPos = this.scrollView.content.position.clone();\r\n } else {\r\n let offset = this.scrollView.content.position.clone().sub(this.lastPos);\r\n this.lastPos = this.scrollView.content.position.clone();\r\n let now = cc.sys.now();\r\n if (!this.lastChange || (now - this.lastChange) > 100) {\r\n this.lastChange = now;\r\n this.dealLoopList(offset, showCells);\r\n }\r\n }\r\n }\r\n }\r\n /**\r\n * 初始化\r\n * @param data 数据组\r\n * @param prefab 预制件\r\n * @param size 通用尺寸\r\n * @param anchor cell的锚点\r\n */\r\n public initData(data: T[], prefab: cc.Prefab, size?: cc.Size, anchor: cc.Vec2 = cc.v2(0.5, 0.5)) {\r\n this.datas = data;\r\n this.size = size;\r\n this.anchor = anchor;\r\n this.prefab = prefab;\r\n let len = this.cellMaxNum ? this.cellMaxNum : data.length;\r\n this.curStartIndex = 0;\r\n for (let i = 0; i < len; ++i) {\r\n let itemCell = this.itemCells[i];\r\n if (!itemCell) {\r\n let node = new cc.Node('LoopListCell')\r\n itemCell = this.itemCells[i] = new ItemCell(node, this);\r\n node.setAnchorPoint(anchor);\r\n node.setParent(this.scrollView.content);\r\n }\r\n let data = this.datas[this.curStartIndex + i];\r\n let cellSize = data.size ? data.size : size;\r\n itemCell.init(data, cellSize, this.curStartIndex + i, i, this);\r\n }\r\n for (let i = data.length, len = this.itemCells.length; i < len; ++i) {\r\n this.recircleShowNode(this.itemCells[i].recircle());\r\n this.itemCells[i].destroy()\r\n this.itemCells[i] = null;\r\n }\r\n this.updateNodes();\r\n }\r\n\r\n /**\r\n * 压入新的数据\r\n * @param datas \r\n */\r\n public pushDatas(datas: T[]) {\r\n let length = this.datas.length;\r\n for (let i = 0, len = datas.length; i < len; ++i) {\r\n let data = datas[i];\r\n this.datas.push(data);\r\n let index = length + i;\r\n this.addNodeFromIndex(index);\r\n }\r\n }\r\n /**\r\n * 插入新的数据\r\n * @param data \r\n * @param insertIndex \r\n */\r\n public insertData(data: T, insertIndex: number) {\r\n if (this.datas.length >= insertIndex) {\r\n this.datas.splice(insertIndex, 0, data);\r\n this.addNodeFromIndex(insertIndex);\r\n } else {\r\n this.pushDatas([data]);\r\n }\r\n }\r\n /**\r\n * 移除对应数据\r\n * @param removeIndex \r\n */\r\n public removeData(removeIndex: number) {\r\n if (this.datas.length >= removeIndex) {\r\n this.datas.splice(removeIndex, 1);\r\n if (this.cellMaxNum) {\r\n let cellIndex = removeIndex - this.curStartIndex;\r\n //在使用范围内\r\n if (cellIndex >= 0 && cellIndex < this.cellMaxNum) {\r\n let itemCell = this.itemCells[cellIndex];\r\n let nodeSides = getNodeBorder(itemCell, [true, true, true, true]);\r\n let changeSize = cc.size(-itemCell.size.width, -itemCell.size.height);\r\n itemCell.size = cc.size(0, 0);\r\n this.dealChangeSize(itemCell, nodeSides, changeSize).then(() => {\r\n //更新数据\r\n for (let i = cellIndex; i < this.cellMaxNum; i++) {\r\n let curDataIndex = this.curStartIndex + i;\r\n let curData = this.datas[curDataIndex];\r\n let curCellSize: cc.Size = curData.size ? curData.size : this.size;\r\n this.itemCells[i].init(curData, curCellSize, curDataIndex, i, this);\r\n this.itemCells[i].updateShowNode(this.renderLayer);\r\n }\r\n });\r\n }\r\n } else {\r\n let itemCell = this.itemCells.splice(removeIndex, 1)[0];\r\n let nodeSides = getNodeBorder(itemCell, [true, true, true, true]);\r\n let changeSize = cc.size(-itemCell.size.width, -itemCell.size.height);\r\n itemCell.size = cc.size(0, 0);\r\n this.dealChangeSize(itemCell, nodeSides, changeSize).then(() => {\r\n this.recircleShowNode(itemCell.recircle())\r\n itemCell.node.destroy();\r\n });\r\n }\r\n }\r\n }\r\n /**\r\n * 从某个数据开始更新\r\n * @param dataIndex \r\n */\r\n private async addNodeFromIndex(dataIndex: number) {\r\n let data = this.datas[dataIndex];\r\n let cellSize: cc.Size = data.size ? data.size : this.size;\r\n //是否开启cell循环\r\n if (this.cellMaxNum) {\r\n let cellIndex = dataIndex - this.curStartIndex;\r\n //在使用范围内\r\n if (cellIndex >= 0 && cellIndex < this.cellMaxNum) {\r\n //更新数据\r\n for (let i = cellIndex; i < this.cellMaxNum; i++) {\r\n let curDataIndex = this.curStartIndex + i;\r\n let curData = this.datas[curDataIndex];\r\n let curCellSize: cc.Size = curData.size ? curData.size : this.size;\r\n this.itemCells[i].init(curData, curCellSize, curDataIndex, i, this);\r\n this.itemCells[i].updateShowNode(this.renderLayer);\r\n }\r\n //获取当前的位置\r\n let nodeSides: IBorder = null;\r\n let itemCell: ItemCell = this.itemCells[cellIndex];\r\n if (itemCell) {\r\n nodeSides = getNodeBorder(itemCell, [true, true, true, true]);\r\n itemCell.node.width = 0;\r\n itemCell.node.height = 0;\r\n this.dealChangeSize(itemCell, nodeSides, cellSize).then(() => {\r\n itemCell.node.width = cellSize.width;\r\n itemCell.node.height = cellSize.height;\r\n });\r\n }\r\n }\r\n } else {\r\n //获取当前的位置\r\n let nodeSides: IBorder = null;\r\n if (this.itemCells[dataIndex]) {\r\n nodeSides = getNodeBorder(this.itemCells[dataIndex], [true, true, true, true]);\r\n }\r\n let node = new cc.Node('LoopListCell')\r\n node.setAnchorPoint(this.anchor);\r\n node.setParent(this.scrollView.content);\r\n node.setSiblingIndex(dataIndex);\r\n let itemCell: ItemCell = new ItemCell(node, this);\r\n this.itemCells.splice(dataIndex, 0, itemCell)\r\n itemCell.init(data, cellSize, dataIndex, dataIndex, this);\r\n if (!nodeSides) {\r\n await new Promise((resolve, reject) => {\r\n requestAnimationFrame(() => {\r\n nodeSides = getNodeBorder(itemCell, [true, true, true, true]);\r\n resolve();\r\n })\r\n });\r\n }\r\n if (nodeSides) {\r\n itemCell.node.width = 0;\r\n itemCell.node.height = 0;\r\n this.dealChangeSize(itemCell, nodeSides, cellSize).then(() => {\r\n itemCell.node.width = cellSize.width;\r\n itemCell.node.height = cellSize.height;\r\n });\r\n }\r\n this.dealItemShow(itemCell);\r\n }\r\n }\r\n\r\n /**\r\n * 处理列表的循环利用\r\n * @param offset \r\n * @param dataIndexs \r\n */\r\n private dealLoopList(offset: cc.Vec3, showCells: ItemCell[]) {\r\n let startCell = showCells[0];\r\n let endCell = showCells[showCells.length - 1];\r\n if (this.scrollView.vertical) {\r\n /**内容上移 */\r\n if (offset.y > 0) {\r\n //已经到达最后倒数第二个节点并且还有数据\r\n if (this.scrollView.content.y >= (- this.itemCells[this.itemCells.length - 2].node.y - this.viewSides.size.height) && endCell.dataIndex < this.datas.length - 2) {\r\n //显示开始数据下标(这里-1是想要顶部留一个itemcell做缓冲)\r\n let showStart = startCell.dataIndex - 1;\r\n //剩余可展示的数据量 \r\n let leave = this.datas.length - showStart;\r\n //计算应该从那个位置开始重新赋值,因为如果直接移动到最上方,数据量不够覆盖所有的cell\r\n let cellStartIndex = Math.max(0, this.itemCells.length - leave);\r\n //计算第一个cell的数据下标\r\n this.curStartIndex = showStart - cellStartIndex;\r\n\r\n let cellTop = getNodeBorder(this.itemCells[startCell.cellIndex], [true]).topSide;\r\n\r\n let contentHeight = 0;\r\n let targetY = 0;\r\n let jumpFirst = true;\r\n let showIndex = 0;\r\n for (let i = 0, len = this.itemCells.length; i < len; ++i) {\r\n if (i >= cellStartIndex) {\r\n //将当前已经显示的showNode节点直接重新设置到移动后的节点上\r\n if (showIndex < showCells.length && !jumpFirst) {\r\n if (showIndex == 0) {\r\n targetY = contentHeight;\r\n }\r\n let showNode = showCells[showIndex].lostShowNode();\r\n showIndex++;\r\n this.itemCells[i].getShowNode(showNode);\r\n }\r\n jumpFirst = false;\r\n }\r\n let dataIndex = this.curStartIndex + i;\r\n let data = this.datas[dataIndex];\r\n let cellSize = data.size ? data.size : this.size;\r\n contentHeight += cellSize.height;\r\n this.itemCells[i].init(data, cellSize, dataIndex, i, this);\r\n }\r\n\r\n //将content的位置移动到最上方并对齐移动前的状态\r\n let posY = targetY + (cellTop - this.viewSides.topSide)\r\n this.scrollView.content.setPosition(cc.v3(this.scrollView.content.position.x, posY));\r\n this.scrollView.scrollToOffset(cc.v2(0, posY + endCell.size.height), 1)\r\n this.lastPos = null;\r\n }\r\n } //内容下移\r\n else if (offset.y < 0) {\r\n //已经到达第二个节点并且还有数据\r\n if (this.scrollView.content.y < (- this.itemCells[2].node.y) && startCell.dataIndex > 1) {\r\n //展示的最后一个数据下表,+1是为了在底部预留一部分空间\r\n let showEndIndex = endCell.dataIndex + 1;\r\n //计算应该从那个位置开始重新赋值,因为如果直接移动到最下方,数据量不够覆盖所有的cell\r\n let cellEndIndex = Math.min(this.itemCells.length - 2, showEndIndex - 1);\r\n //计算第一个cell的数据下标\r\n this.curStartIndex = Math.max(showEndIndex - (this.itemCells.length - 1), 0);\r\n\r\n //将content的位置移动到最下方并对齐移动前的状态\r\n let cellTop = getNodeBorder(this.itemCells[startCell.cellIndex], [true]).topSide;\r\n\r\n let contentHeight = 0;\r\n let showIndex = showCells.length - 1;\r\n for (let i = this.itemCells.length - 1; i >= 0; --i) {\r\n if (i <= cellEndIndex) {\r\n //将当前已经显示的showNode节点直接重新设置到移动后的节点上\r\n if (showIndex >= 0) {\r\n let showNode = showCells[showIndex].lostShowNode();\r\n showIndex--;\r\n this.itemCells[i].getShowNode(showNode);\r\n } else {\r\n showIndex--;\r\n }\r\n }\r\n let dataIndex = this.curStartIndex + i;\r\n let data = this.datas[dataIndex];\r\n let cellSize = data.size ? data.size : this.size;\r\n if (showIndex < -1) {\r\n contentHeight += cellSize.height;\r\n }\r\n this.itemCells[i].init(data, cellSize, dataIndex, i, this);\r\n }\r\n\r\n //将content的位置移动到最下方并对齐移动前的状态\r\n let posY = contentHeight + (cellTop - this.viewSides.topSide)\r\n this.scrollView.content.setPosition(cc.v3(this.scrollView.content.position.x, posY));\r\n this.scrollView.scrollToOffset(cc.v2(0, posY - startCell.size.height), 1)\r\n this.lastPos = null;\r\n }\r\n }\r\n } else if (this.scrollView.horizontal) {\r\n if (offset.x < 0) {\r\n //已经到达最后倒数第二个节点并且还有数据\r\n if (this.scrollView.content.x <= (- (this.itemCells[this.itemCells.length - 2].node.x - this.viewSides.size.width)) && endCell.dataIndex < this.datas.length - 2) {\r\n //显示开始数据下标(这里-1是想要左侧留一个itemcell做缓冲)\r\n let showStart = startCell.dataIndex - 1;\r\n //剩余可展示的数据量 \r\n let leave = this.datas.length - showStart;\r\n //计算应该从那个位置开始重新赋值,因为如果直接移动到最左侧,数据量不够覆盖所有的cell\r\n let cellStartIndex = Math.max(0, this.itemCells.length - leave);\r\n //计算第一个cell的数据下标\r\n this.curStartIndex = showStart - cellStartIndex;\r\n\r\n let cellLeft = getNodeBorder(this.itemCells[startCell.cellIndex], [false, false, true]).leftSide;\r\n\r\n let contentWidth = 0;\r\n let targetX = 0;\r\n let jumpFirst = true;\r\n let showIndex = 0;\r\n for (let i = 0, len = this.itemCells.length; i < len; ++i) {\r\n if (i >= cellStartIndex) {\r\n //将当前已经显示的showNode节点直接重新设置到移动后的节点上\r\n if (showIndex < showCells.length && !jumpFirst) {\r\n if (showIndex == 0) {\r\n targetX = contentWidth;\r\n }\r\n let showNode = showCells[showIndex].lostShowNode();\r\n showIndex++;\r\n this.itemCells[i].getShowNode(showNode);\r\n }\r\n jumpFirst = false;\r\n }\r\n let dataIndex = this.curStartIndex + i;\r\n let data = this.datas[dataIndex];\r\n let cellSize = data.size ? data.size : this.size;\r\n contentWidth += cellSize.width;\r\n this.itemCells[i].init(data, cellSize, dataIndex, i, this);\r\n }\r\n\r\n //将content的位置移动到最左侧并对齐移动前的状态\r\n let posX = (cellLeft - this.viewSides.leftSide) - targetX;\r\n this.scrollView.content.setPosition(cc.v3(posX, this.scrollView.content.position.y));\r\n this.scrollView.scrollToOffset(cc.v2(-(posX - endCell.size.width), 0), 1)\r\n this.lastPos = null;\r\n }\r\n } else if (offset.x > 0) {\r\n //已经到达第二个节点并且还有数据\r\n if (this.scrollView.content.x > (-this.itemCells[2].node.x) && startCell.dataIndex > 1) {\r\n //展示的最后一个数据下表,+1是为了在右侧预留一部分空间\r\n let showEndIndex = endCell.dataIndex + 1;\r\n //计算应该从那个位置开始重新赋值,因为如果直接移动到最右侧,数据量不够覆盖所有的cell\r\n let cellEndIndex = Math.min(this.itemCells.length - 2, showEndIndex - 1);\r\n //计算第一个cell的数据下标\r\n this.curStartIndex = Math.max(showEndIndex - (this.itemCells.length - 1), 0);\r\n\r\n //将content的位置移动到最右侧并对齐移动前的状态\r\n let cellLeft = getNodeBorder(this.itemCells[startCell.cellIndex], [false, false, true]).leftSide;\r\n\r\n let contentWidth = 0;\r\n let showIndex = showCells.length - 1;\r\n for (let i = this.itemCells.length - 1; i >= 0; --i) {\r\n if (i <= cellEndIndex) {\r\n //将当前已经显示的showNode节点直接重新设置到移动后的节点上\r\n if (showIndex >= 0) {\r\n let showNode = showCells[showIndex].lostShowNode();\r\n showIndex--;\r\n this.itemCells[i].getShowNode(showNode);\r\n } else {\r\n showIndex--;\r\n }\r\n }\r\n let dataIndex = this.curStartIndex + i;\r\n let data = this.datas[dataIndex];\r\n let cellSize = data.size ? data.size : this.size;\r\n if (showIndex < -1) {\r\n contentWidth += cellSize.width;\r\n }\r\n this.itemCells[i].init(data, cellSize, dataIndex, i, this);\r\n }\r\n\r\n //将content的位置移动到最右侧并对齐移动前的状态\r\n let posX = (cellLeft - this.viewSides.leftSide) - contentWidth;\r\n this.scrollView.content.setPosition(cc.v3(posX, this.scrollView.content.position.y));\r\n this.scrollView.scrollToOffset(cc.v2(- (posX + startCell.size.width), 0), 1)\r\n this.lastPos = null;\r\n }\r\n }\r\n }\r\n }\r\n\r\n\r\n /**更新节点的显示 */\r\n public updateNodes() {\r\n let showCells: ItemCell[] = [];\r\n for (let i = 0, len = this.itemCells.length; i < len; ++i) {\r\n let itemCell = this.itemCells[i];\r\n let isShow = this.dealItemShow(itemCell)\r\n if (isShow) {\r\n showCells.push(itemCell)\r\n }\r\n }\r\n return showCells;\r\n }\r\n\r\n /**\r\n * 处理cell的显示隐藏\r\n * @param itemCell \r\n */\r\n private dealItemShow(itemCell: ItemCell) {\r\n if (itemCell) {\r\n let isShow = this.checkInView(itemCell);\r\n if (isShow) {\r\n itemCell.hasNoNode && itemCell.updateShow(isShow, this.prefab, this.showNodePool.length > 0 ? this.showNodePool.pop() : null, this.renderLayer);\r\n } else {\r\n !itemCell.hasNoNode && this.recircleShowNode(itemCell.recircle());\r\n }\r\n return isShow;\r\n }\r\n }\r\n\r\n\r\n /**\r\n * 检查是否在屏幕内\r\n * @param node \r\n * @returns \r\n */\r\n private checkInView(itemCell: ItemCell) {\r\n let nodeSides = getNodeBorder(itemCell, [true, true, true, true]);\r\n //节点右侧边缘在屏幕左侧外面或者节点左边缘在屏幕右侧外面 则不在显示区域\r\n let horizontalOutside = nodeSides.rightSide < this.viewSides.leftSide\r\n || nodeSides.leftSide > this.viewSides.rightSide;\r\n\r\n let verticalOutside = false;\r\n if (!horizontalOutside) {\r\n //节点上边缘在屏幕下方外面或者节点下边缘在屏幕上方外面 则不在显示区域\r\n verticalOutside = nodeSides.topSide < this.viewSides.bottomSide\r\n || nodeSides.bottomSide > this.viewSides.topSide;\r\n }\r\n return !horizontalOutside && !verticalOutside;\r\n }\r\n /**\r\n * 处理变化的大小\r\n * @param cell \r\n * @param nodeSides \r\n * @param changeSize \r\n */\r\n public async dealChangeSize(cell: ItemCell, nodeSides: IBorder, changeSize: cc.Size, time: number = 0.3) {\r\n let topToBottomFulfill = (this.scrollView.content.anchorY == 1 && nodeSides.bottomSide >= this.viewSides.topSide);\r\n let bottomToTopFulfill = (this.scrollView.content.anchorY == 0 && nodeSides.topSide <= this.viewSides.bottomSide);\r\n if (topToBottomFulfill || bottomToTopFulfill) {\r\n if (topToBottomFulfill) {\r\n this.scrollView.setContentPosition(cc.v2(this.scrollView.content.x, this.scrollView.content.y + changeSize.height))\r\n } else {\r\n this.scrollView.setContentPosition(cc.v2(this.scrollView.content.x, this.scrollView.content.y - changeSize.height))\r\n }\r\n }\r\n let leftToRightFulfill = (this.scrollView.content.anchorX == 0 && nodeSides.rightSide <= this.viewSides.leftSide);\r\n let RightToLeftFulfill = (this.scrollView.content.anchorX == 1 && nodeSides.leftSide >= this.viewSides.rightSide);\r\n if (leftToRightFulfill || RightToLeftFulfill) {\r\n if (RightToLeftFulfill) {\r\n this.scrollView.setContentPosition(cc.v2(this.scrollView.content.x + changeSize.width, this.scrollView.content.y))\r\n } else {\r\n this.scrollView.setContentPosition(cc.v2(this.scrollView.content.x - changeSize.width, this.scrollView.content.y))\r\n }\r\n }\r\n if (!(topToBottomFulfill || bottomToTopFulfill || leftToRightFulfill || RightToLeftFulfill)) {\r\n cc.Tween.stopAllByTarget(cell.node);\r\n await new Promise((resolve, reject) => {\r\n cc.tween(cell.node).to(time, { width: cell.size.width, height: cell.size.height }).call(() => {\r\n resolve();\r\n }).start();\r\n })\r\n }\r\n this.updateNodes();\r\n return true;\r\n }\r\n\r\n /**\r\n * 回收显示节点\r\n * @param node \r\n */\r\n private recircleShowNode(node: ShowNode) {\r\n node && this.showNodePool.push(node);\r\n }\r\n\r\n /**\r\n * 释放当前列表\r\n */\r\n public freeList() {\r\n this.scrollView.node.off(\"scrolling\", this.scrollingListener);\r\n for (let i = 0, len = this.itemCells.length; i < len; ++i) {\r\n this.recircleShowNode(this.itemCells[i].recircle());\r\n this.itemCells[i].destroy();\r\n }\r\n this.itemCells = [];\r\n for (let index = 0, len = this.showNodePool.length; index < len; ++index) {\r\n this.showNodePool[index].destroy();\r\n }\r\n this.showNodePool = [];\r\n this.renderLayer = null;\r\n this.scrollView = null;\r\n this.prefab = null;\r\n }\r\n\r\n}\r\n/**\r\n * 获取节点的边缘\r\n * @param node \r\n * @param needArr 顺序是上 下 左 右\r\n */\r\nfunction getNodeBorder(cell: ItemCell, needArr: boolean[]) {\r\n let node = cell.node\r\n let boderData: IBorder = {};\r\n let wpos = getNodeWPos(node);\r\n //显示区域上边缘\r\n if (needArr[0]) {\r\n boderData.topSide = wpos.y + (node.height * (1 - node.anchorY));\r\n }\r\n //显示区域下边缘\r\n if (needArr[1]) {\r\n boderData.bottomSide = wpos.y - (node.height * node.anchorY);\r\n }\r\n //显示区域左边缘\r\n if (needArr[2]) {\r\n boderData.leftSide = wpos.x - (node.width * node.anchorX);\r\n }\r\n //显示区域右边缘\r\n if (needArr[3]) {\r\n boderData.rightSide = wpos.x + (node.width * (1 - node.anchorX));\r\n }\r\n boderData.size = cc.size(node.width, node.height);\r\n return boderData;\r\n}\r\n\r\n/**\r\n * 获取节点世界坐标\r\n * @param node \r\n * @returns \r\n */\r\nfunction getNodeWPos(node: cc.Node) {\r\n return node.parent.convertToWorldSpaceAR(node.position);\r\n}\r\n\r\n\r\n"]} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/b5/b5fc2cf2-7942-483d-be1f-bbeadc4714ad.json b/Layered_virtual_list_2.x/library/imports/b5/b5fc2cf2-7942-483d-be1f-bbeadc4714ad.json new file mode 100644 index 0000000..5ce72fa --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/b5/b5fc2cf2-7942-483d-be1f-bbeadc4714ad.json @@ -0,0 +1,109 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "cone", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "asyncLoadAssets": false, + "readonly": false + }, + { + "__type__": "cc.Node", + "_name": "cone", + "_objFlags": 0, + "_parent": null, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 2 + } + ], + "_prefab": { + "__id__": 3 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + -0.7071068286895765, + 0, + 0, + 0.7071067336835153, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": -90.00000769819565, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.MeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "a5849239-3ad3-41d1-8ab4-ae9fea11f97f" + } + ], + "_mesh": { + "__uuid__": "7a17de6e-227a-46b1-8009-e7157d4d3acf" + }, + "_receiveShadows": false, + "_shadowCastingMode": 0, + "_enableAutoBatch": false, + "textures": [], + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "b5fc2cf2-7942-483d-be1f-bbeadc4714ad" + }, + "fileId": "71bfK5TRVH64FzEUsiCu4S", + "sync": false + } +] \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/b8/b8223619-7e38-47c4-841f-9160c232495a.json b/Layered_virtual_list_2.x/library/imports/b8/b8223619-7e38-47c4-841f-9160c232495a.json new file mode 100644 index 0000000..214266f --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/b8/b8223619-7e38-47c4-841f-9160c232495a.json @@ -0,0 +1,9 @@ +{ + "__type__": "cc.ParticleAsset", + "_name": "atom", + "_objFlags": 0, + "_native": ".plist", + "spriteFrame": { + "__uuid__": "bb42ed8e-0867-4584-ad63-b6f84f83bba8" + } +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/b8/b8223619-7e38-47c4-841f-9160c232495a.plist b/Layered_virtual_list_2.x/library/imports/b8/b8223619-7e38-47c4-841f-9160c232495a.plist new file mode 100644 index 0000000..8e59750 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/b8/b8223619-7e38-47c4-841f-9160c232495a.plist @@ -0,0 +1,108 @@ + + + + + angle + 360 + angleVariance + 360 + blendFuncDestination + 1 + blendFuncSource + 770 + duration + -1 + emitterType + 0 + finishColorAlpha + 0.8399999737739563 + finishColorBlue + 0.0771484375 + finishColorGreen + 0.6349284052848816 + finishColorRed + 0.6808268427848816 + finishColorVarianceAlpha + 0.7400000095367432 + finishColorVarianceBlue + 0.9800000190734863 + finishColorVarianceGreen + 0.9800000190734863 + finishColorVarianceRed + 0.41999998688697815 + finishParticleSize + 30.31999969482422 + finishParticleSizeVariance + 0 + gravityx + 0.25 + gravityy + 0.8600000143051147 + maxParticles + 200 + maxRadius + 100 + maxRadiusVariance + 0 + minRadius + 0 + particleLifespan + 0.20000000298023224 + particleLifespanVariance + 0.5 + radialAccelVariance + 65.79000091552734 + radialAcceleration + -671.0499877929688 + rotatePerSecond + 0 + rotatePerSecondVariance + 0 + rotationEnd + -47.369998931884766 + rotationEndVariance + -142.11000061035156 + rotationStart + -47.369998931884766 + rotationStartVariance + 0 + sourcePositionVariancex + 7 + sourcePositionVariancey + 7 + sourcePositionx + 373.7277526855469 + sourcePositiony + 478.40472412109375 + speed + 0 + speedVariance + 190.7899932861328 + startColorAlpha + 0.6399999856948853 + startColorBlue + 0.3375650942325592 + startColorGreen + 0.7879231572151184 + startColorRed + 0.794921875 + startColorVarianceAlpha + 0.7799999713897705 + startColorVarianceBlue + 0.6800000071525574 + startColorVarianceGreen + 1 + startColorVarianceRed + 0.8999999761581421 + startParticleSize + 3.369999885559082 + startParticleSizeVariance + 50 + tangentialAccelVariance + 65.79000091552734 + tangentialAcceleration + -92.11000061035156 + spriteFrameUuid + bb42ed8e-0867-4584-ad63-b6f84f83bba8 + + \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/b9/b9be0b60-a085-4f93-bd8b-884e8ddfd7ff.js b/Layered_virtual_list_2.x/library/imports/b9/b9be0b60-a085-4f93-bd8b-884e8ddfd7ff.js new file mode 100644 index 0000000..a1be642 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/b9/b9be0b60-a085-4f93-bd8b-884e8ddfd7ff.js @@ -0,0 +1,73 @@ +"use strict"; +cc._RF.push(module, 'b9be0tgoIVPk72LiE6N39f/', 'TestRenderAlternative'); +// Scene/TestRenderAlternative.ts + +"use strict"; +// Learn TypeScript: +// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html +// Learn Attribute: +// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html +// Learn life-cycle callbacks: +// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property; +var TestRenderAlternative = /** @class */ (function (_super) { + __extends(TestRenderAlternative, _super); + function TestRenderAlternative() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.scrollView = null; + _this.prefab = null; + _this.layer = null; + return _this; + // update (dt) {} + } + // onLoad () {} + TestRenderAlternative.prototype.start = function () { + var count = 1000; + var datas = []; + for (var i = 0; i < count; i++) { + var data = { name: 'name' + i, index: i }; + datas.push({ data: data, layer: this.layer }); + } + for (var i = 0; i < datas.length; i++) { + var item = cc.instantiate(this.prefab); + this.scrollView.content.addChild(item); + item.getComponent('Item').init(datas[i]); + } + }; + __decorate([ + property(cc.ScrollView) + ], TestRenderAlternative.prototype, "scrollView", void 0); + __decorate([ + property(cc.Prefab) + ], TestRenderAlternative.prototype, "prefab", void 0); + __decorate([ + property(cc.Node) + ], TestRenderAlternative.prototype, "layer", void 0); + TestRenderAlternative = __decorate([ + ccclass + ], TestRenderAlternative); + return TestRenderAlternative; +}(cc.Component)); +exports.default = TestRenderAlternative; + +cc._RF.pop(); \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/b9/b9be0b60-a085-4f93-bd8b-884e8ddfd7ff.js.map b/Layered_virtual_list_2.x/library/imports/b9/b9be0b60-a085-4f93-bd8b-884e8ddfd7ff.js.map new file mode 100644 index 0000000..aa2420b --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/b9/b9be0b60-a085-4f93-bd8b-884e8ddfd7ff.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["assets\\Scene\\TestRenderAlternative.ts"],"names":[],"mappings":";;;;;AAAA,oBAAoB;AACpB,wEAAwE;AACxE,mBAAmB;AACnB,kFAAkF;AAClF,8BAA8B;AAC9B,kFAAkF;;;;;;;;;;;;;;;;;;;;;AAE5E,IAAA,KAAwB,EAAE,CAAC,UAAU,EAAnC,OAAO,aAAA,EAAE,QAAQ,cAAkB,CAAC;AAG5C;IAAmD,yCAAY;IAA/D;QAAA,qEA6BC;QA1BG,gBAAU,GAAkB,IAAI,CAAC;QAGjC,YAAM,GAAc,IAAI,CAAC;QAGzB,WAAK,GAAY,IAAI,CAAC;;QAmBtB,iBAAiB;IACrB,CAAC;IAlBG,eAAe;IAEf,qCAAK,GAAL;QACI,IAAI,KAAK,GAAG,IAAI,CAAC;QACjB,IAAI,KAAK,GAAG,EAAE,CAAC;QACf,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE,EAAE;YAC5B,IAAI,IAAI,GAAG,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;YAC1C,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;SACjD;QAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACnC,IAAI,IAAI,GAAG,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACvC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;YACvC,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;SAC5C;IACL,CAAC;IAvBD;QADC,QAAQ,CAAC,EAAE,CAAC,UAAU,CAAC;6DACS;IAGjC;QADC,QAAQ,CAAC,EAAE,CAAC,MAAM,CAAC;yDACK;IAGzB;QADC,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC;wDACI;IATL,qBAAqB;QADzC,OAAO;OACa,qBAAqB,CA6BzC;IAAD,4BAAC;CA7BD,AA6BC,CA7BkD,EAAE,CAAC,SAAS,GA6B9D;kBA7BoB,qBAAqB","file":"","sourceRoot":"/","sourcesContent":["// Learn TypeScript:\r\n// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html\r\n// Learn Attribute:\r\n// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html\r\n// Learn life-cycle callbacks:\r\n// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html\r\n\r\nconst { ccclass, property } = cc._decorator;\r\n\r\n@ccclass\r\nexport default class TestRenderAlternative extends cc.Component {\r\n\r\n @property(cc.ScrollView)\r\n scrollView: cc.ScrollView = null;\r\n\r\n @property(cc.Prefab)\r\n prefab: cc.Prefab = null;\r\n\r\n @property(cc.Node)\r\n layer: cc.Node = null;\r\n\r\n // onLoad () {}\r\n\r\n start() {\r\n let count = 1000;\r\n let datas = [];\r\n for (let i = 0; i < count; i++) {\r\n let data = { name: 'name' + i, index: i };\r\n datas.push({ data: data, layer: this.layer });\r\n }\r\n\r\n for (let i = 0; i < datas.length; i++) {\r\n let item = cc.instantiate(this.prefab);\r\n this.scrollView.content.addChild(item);\r\n item.getComponent('Item').init(datas[i]);\r\n }\r\n }\r\n\r\n // update (dt) {}\r\n}\r\n"]} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/bb/bb42ed8e-0867-4584-ad63-b6f84f83bba8.json b/Layered_virtual_list_2.x/library/imports/bb/bb42ed8e-0867-4584-ad63-b6f84f83bba8.json new file mode 100644 index 0000000..bb18fb8 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/bb/bb42ed8e-0867-4584-ad63-b6f84f83bba8.json @@ -0,0 +1,28 @@ +{ + "__type__": "cc.SpriteFrame", + "content": { + "name": "atom", + "texture": "8a96b965-2dc0-4e03-aa90-3b79cb93b5b4", + "atlas": "", + "rect": [ + 0, + 0, + 31, + 31 + ], + "offset": [ + 0, + 0 + ], + "originalSize": [ + 31, + 31 + ], + "capInsets": [ + 0, + 0, + 0, + 0 + ] + } +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/bf/bf0a434c-84dd-4a8e-a08a-7a36f180cc75.json b/Layered_virtual_list_2.x/library/imports/bf/bf0a434c-84dd-4a8e-a08a-7a36f180cc75.json new file mode 100644 index 0000000..2297fb2 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/bf/bf0a434c-84dd-4a8e-a08a-7a36f180cc75.json @@ -0,0 +1,1217 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "toggleContainer", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 1, + "asyncLoadAssets": false, + "readonly": false + }, + { + "__type__": "cc.Node", + "_name": "toggleContainer", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + }, + { + "__id__": 11 + }, + { + "__id__": 20 + } + ], + "_active": true, + "_components": [ + { + "__id__": 29 + } + ], + "_prefab": { + "__id__": 30 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 221, + "height": 61 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "toggle1", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 3 + }, + { + "__id__": 6 + } + ], + "_active": true, + "_components": [ + { + "__id__": 9 + } + ], + "_prefab": { + "__id__": 10 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 41, + "height": 28 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -62, + 3, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Background", + "_objFlags": 512, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 4 + } + ], + "_prefab": { + "__id__": 5 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 32, + "height": 32 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 3 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "e7aba14b-f956-4480-b254-8d57832e273f" + }, + "_type": 0, + "_sizeMode": 2, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": false, + "_atlas": null, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "bf0a434c-84dd-4a8e-a08a-7a36f180cc75" + }, + "fileId": "12e439SyJxPm6pHTRj/H92b", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "checkmark", + "_objFlags": 512, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 7 + } + ], + "_prefab": { + "__id__": 8 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 32, + "height": 32 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 6 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "1a32fc76-f0bd-4f66-980f-56929c0ca0b3" + }, + "_type": 0, + "_sizeMode": 2, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": false, + "_atlas": null, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "bf0a434c-84dd-4a8e-a08a-7a36f180cc75" + }, + "fileId": "d5f81EvT59O3IYhi0b8awdA", + "sync": false + }, + { + "__type__": "cc.Toggle", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "_normalMaterial": null, + "_grayMaterial": null, + "duration": 0.1, + "zoomScale": 1.2, + "clickEvents": [], + "_N$interactable": true, + "_N$enableAutoGrayEffect": false, + "_N$transition": 3, + "transition": 3, + "_N$normalColor": { + "__type__": "cc.Color", + "r": 214, + "g": 214, + "b": 214, + "a": 255 + }, + "_N$pressedColor": { + "__type__": "cc.Color", + "r": 211, + "g": 211, + "b": 211, + "a": 255 + }, + "pressedColor": { + "__type__": "cc.Color", + "r": 211, + "g": 211, + "b": 211, + "a": 255 + }, + "_N$hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$disabledColor": { + "__type__": "cc.Color", + "r": 124, + "g": 124, + "b": 124, + "a": 255 + }, + "_N$normalSprite": null, + "_N$pressedSprite": null, + "pressedSprite": null, + "_N$hoverSprite": null, + "hoverSprite": null, + "_N$disabledSprite": null, + "_N$target": { + "__id__": 2 + }, + "_N$isChecked": true, + "toggleGroup": null, + "checkMark": { + "__id__": 7 + }, + "checkEvents": [], + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "bf0a434c-84dd-4a8e-a08a-7a36f180cc75" + }, + "fileId": "f8ae482OYFF86r5AHHZHzkB", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "toggle2", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 12 + }, + { + "__id__": 15 + } + ], + "_active": true, + "_components": [ + { + "__id__": 18 + } + ], + "_prefab": { + "__id__": 19 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 42, + "height": 28 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 15, + 3, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Background", + "_objFlags": 512, + "_parent": { + "__id__": 11 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 13 + } + ], + "_prefab": { + "__id__": 14 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 32, + "height": 32 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 12 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "e7aba14b-f956-4480-b254-8d57832e273f" + }, + "_type": 0, + "_sizeMode": 2, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": false, + "_atlas": null, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "bf0a434c-84dd-4a8e-a08a-7a36f180cc75" + }, + "fileId": "23182iNXjhGfbiM+k2MoPhG", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "checkmark", + "_objFlags": 512, + "_parent": { + "__id__": 11 + }, + "_children": [], + "_active": false, + "_components": [ + { + "__id__": 16 + } + ], + "_prefab": { + "__id__": 17 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 32, + "height": 32 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 15 + }, + "_enabled": true, + "_materials": [], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "1a32fc76-f0bd-4f66-980f-56929c0ca0b3" + }, + "_type": 0, + "_sizeMode": 2, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": false, + "_atlas": null, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "bf0a434c-84dd-4a8e-a08a-7a36f180cc75" + }, + "fileId": "67160qO3xZPvYfuiiHVaiyt", + "sync": false + }, + { + "__type__": "cc.Toggle", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 11 + }, + "_enabled": true, + "_normalMaterial": null, + "_grayMaterial": null, + "duration": 0.1, + "zoomScale": 1.2, + "clickEvents": [], + "_N$interactable": true, + "_N$enableAutoGrayEffect": false, + "_N$transition": 3, + "transition": 3, + "_N$normalColor": { + "__type__": "cc.Color", + "r": 214, + "g": 214, + "b": 214, + "a": 255 + }, + "_N$pressedColor": { + "__type__": "cc.Color", + "r": 211, + "g": 211, + "b": 211, + "a": 255 + }, + "pressedColor": { + "__type__": "cc.Color", + "r": 211, + "g": 211, + "b": 211, + "a": 255 + }, + "_N$hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$disabledColor": { + "__type__": "cc.Color", + "r": 124, + "g": 124, + "b": 124, + "a": 255 + }, + "_N$normalSprite": null, + "_N$pressedSprite": null, + "pressedSprite": null, + "_N$hoverSprite": null, + "hoverSprite": null, + "_N$disabledSprite": null, + "_N$target": { + "__id__": 11 + }, + "_N$isChecked": false, + "toggleGroup": null, + "checkMark": { + "__id__": 16 + }, + "checkEvents": [], + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "bf0a434c-84dd-4a8e-a08a-7a36f180cc75" + }, + "fileId": "4b82d4NuWJDnZcPM+lR6By/", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "toggle3", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 21 + }, + { + "__id__": 24 + } + ], + "_active": true, + "_components": [ + { + "__id__": 27 + } + ], + "_prefab": { + "__id__": 28 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 37, + "height": 28 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 91, + 3, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Background", + "_objFlags": 512, + "_parent": { + "__id__": 20 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 22 + } + ], + "_prefab": { + "__id__": 23 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 32, + "height": 32 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 21 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "e7aba14b-f956-4480-b254-8d57832e273f" + }, + "_type": 0, + "_sizeMode": 2, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": false, + "_atlas": null, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "bf0a434c-84dd-4a8e-a08a-7a36f180cc75" + }, + "fileId": "7042dNy6Q1OmYWrdrd+O8Q7", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "checkmark", + "_objFlags": 512, + "_parent": { + "__id__": 20 + }, + "_children": [], + "_active": false, + "_components": [ + { + "__id__": 25 + } + ], + "_prefab": { + "__id__": 26 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 32, + "height": 32 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 24 + }, + "_enabled": true, + "_materials": [], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "1a32fc76-f0bd-4f66-980f-56929c0ca0b3" + }, + "_type": 0, + "_sizeMode": 2, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": false, + "_atlas": null, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "bf0a434c-84dd-4a8e-a08a-7a36f180cc75" + }, + "fileId": "faafbv5RyVCB5deTlAulXVo", + "sync": false + }, + { + "__type__": "cc.Toggle", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 20 + }, + "_enabled": true, + "_normalMaterial": null, + "_grayMaterial": null, + "duration": 0.1, + "zoomScale": 1.2, + "clickEvents": [], + "_N$interactable": true, + "_N$enableAutoGrayEffect": false, + "_N$transition": 3, + "transition": 3, + "_N$normalColor": { + "__type__": "cc.Color", + "r": 214, + "g": 214, + "b": 214, + "a": 255 + }, + "_N$pressedColor": { + "__type__": "cc.Color", + "r": 211, + "g": 211, + "b": 211, + "a": 255 + }, + "pressedColor": { + "__type__": "cc.Color", + "r": 211, + "g": 211, + "b": 211, + "a": 255 + }, + "_N$hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$disabledColor": { + "__type__": "cc.Color", + "r": 124, + "g": 124, + "b": 124, + "a": 255 + }, + "_N$normalSprite": null, + "_N$pressedSprite": null, + "pressedSprite": null, + "_N$hoverSprite": null, + "hoverSprite": null, + "_N$disabledSprite": null, + "_N$target": { + "__id__": 20 + }, + "_N$isChecked": false, + "toggleGroup": null, + "checkMark": { + "__id__": 25 + }, + "checkEvents": [], + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "bf0a434c-84dd-4a8e-a08a-7a36f180cc75" + }, + "fileId": "2b5ebCn5ohKwJt/iEtuj16b", + "sync": false + }, + { + "__type__": "cc.ToggleContainer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "allowSwitchOff": false, + "checkEvents": [], + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "bf0a434c-84dd-4a8e-a08a-7a36f180cc75" + }, + "fileId": "8762b/ljEVCT4m/QHu2tS1g", + "sync": false + } +] \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/c0/c0040c95-c57f-49cd-9cbc-12316b73d0d4.json b/Layered_virtual_list_2.x/library/imports/c0/c0040c95-c57f-49cd-9cbc-12316b73d0d4.json new file mode 100644 index 0000000..9b71e99 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/c0/c0040c95-c57f-49cd-9cbc-12316b73d0d4.json @@ -0,0 +1,54 @@ +{ + "__type__": "cc.EffectAsset", + "_name": "builtin-clear-stencil", + "_objFlags": 0, + "_native": "", + "properties": null, + "techniques": [ + { + "passes": [ + { + "blendState": { + "targets": [ + { + "blend": true + } + ] + }, + "rasterizerState": { + "cullMode": 0 + }, + "program": "builtin-clear-stencil|vs|fs" + } + ] + } + ], + "shaders": [ + { + "hash": 2075641479, + "glsl3": { + "vert": "\nprecision highp float;\nin vec3 a_position;\nvoid main () {\n gl_Position = vec4(a_position, 1);\n}", + "frag": "\nprecision highp float;\nvoid main () {\n gl_FragColor = vec4(1.0);\n}" + }, + "glsl1": { + "vert": "\nprecision highp float;\nattribute vec3 a_position;\nvoid main () {\n gl_Position = vec4(a_position, 1);\n}", + "frag": "\nprecision highp float;\nvoid main () {\n gl_FragColor = vec4(1.0);\n}" + }, + "builtins": { + "globals": { + "blocks": [], + "samplers": [] + }, + "locals": { + "blocks": [], + "samplers": [] + } + }, + "defines": [], + "blocks": [], + "samplers": [], + "record": null, + "name": "builtin-clear-stencil|vs|fs" + } + ] +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/c2/c25b9d50-c8fc-4d27-beeb-6e7c1f2e5c0f.json b/Layered_virtual_list_2.x/library/imports/c2/c25b9d50-c8fc-4d27-beeb-6e7c1f2e5c0f.json new file mode 100644 index 0000000..e7522d6 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/c2/c25b9d50-c8fc-4d27-beeb-6e7c1f2e5c0f.json @@ -0,0 +1,4 @@ +{ + "__type__": "cc.Texture2D", + "content": "0,9729,9729,33071,33071,0,0,1" +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/c2/c25b9d50-c8fc-4d27-beeb-6e7c1f2e5c0f.png b/Layered_virtual_list_2.x/library/imports/c2/c25b9d50-c8fc-4d27-beeb-6e7c1f2e5c0f.png new file mode 100644 index 0000000..746e92b Binary files /dev/null and b/Layered_virtual_list_2.x/library/imports/c2/c25b9d50-c8fc-4d27-beeb-6e7c1f2e5c0f.png differ diff --git a/Layered_virtual_list_2.x/library/imports/c4/c4480a0a-6ac5-443f-8b40-361a14257fc8.json b/Layered_virtual_list_2.x/library/imports/c4/c4480a0a-6ac5-443f-8b40-361a14257fc8.json new file mode 100644 index 0000000..68bc654 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/c4/c4480a0a-6ac5-443f-8b40-361a14257fc8.json @@ -0,0 +1,16 @@ +{ + "__type__": "cc.Material", + "_name": "builtin-phong", + "_objFlags": 0, + "_native": "", + "_effectAsset": { + "__uuid__": "abc2cb62-7852-4525-a90d-d474487b88f2" + }, + "_techniqueData": { + "0": { + "defines": { + "USE_SPECULAR": true + } + } + } +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/c9/c9fa51ff-3f01-4601-8f80-325d1b11dab7.json b/Layered_virtual_list_2.x/library/imports/c9/c9fa51ff-3f01-4601-8f80-325d1b11dab7.json new file mode 100644 index 0000000..946d1a6 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/c9/c9fa51ff-3f01-4601-8f80-325d1b11dab7.json @@ -0,0 +1,28 @@ +{ + "__type__": "cc.SpriteFrame", + "content": { + "name": "default_scrollbar_bg", + "texture": "4bab67cb-18e6-4099-b840-355f0473f890", + "atlas": "", + "rect": [ + 0, + 0, + 30, + 15 + ], + "offset": [ + 0, + 0 + ], + "originalSize": [ + 30, + 15 + ], + "capInsets": [ + 10, + 4, + 10, + 4 + ] + } +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/ca/ca8401fe-ad6e-41a8-bd46-8e3e4e9945be.json b/Layered_virtual_list_2.x/library/imports/ca/ca8401fe-ad6e-41a8-bd46-8e3e4e9945be.json new file mode 100644 index 0000000..33c871e --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/ca/ca8401fe-ad6e-41a8-bd46-8e3e4e9945be.json @@ -0,0 +1,875 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "pageview", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 1, + "asyncLoadAssets": false, + "readonly": false + }, + { + "__type__": "cc.Node", + "_name": "pageview", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + }, + { + "__id__": 5 + }, + { + "__id__": 20 + } + ], + "_active": true, + "_components": [ + { + "__id__": 22 + } + ], + "_prefab": { + "__id__": 24 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 400, + "height": 350 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "background", + "_objFlags": 512, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 3 + } + ], + "_prefab": { + "__id__": 4 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 400, + "height": 350 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "9bbda31e-ad49-43c9-aaf2-f7d9896bac69" + }, + "_type": 1, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "ca8401fe-ad6e-41a8-bd46-8e3e4e9945be" + }, + "fileId": "d4995IHzA9DsKLlMTyCB0bq", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "view", + "_objFlags": 512, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 6 + } + ], + "_active": true, + "_components": [ + { + "__id__": 18 + } + ], + "_prefab": { + "__id__": 19 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 400, + "height": 350 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "content", + "_objFlags": 512, + "_parent": { + "__id__": 5 + }, + "_children": [ + { + "__id__": 7 + }, + { + "__id__": 10 + }, + { + "__id__": 13 + } + ], + "_active": true, + "_components": [ + { + "__id__": 16 + } + ], + "_prefab": { + "__id__": 17 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 1200, + "height": 350 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -200, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "page_1", + "_objFlags": 512, + "_parent": { + "__id__": 6 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 8 + } + ], + "_prefab": { + "__id__": 9 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 200, + "b": 200, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 400, + "height": 290 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 200, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 7 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "9bbda31e-ad49-43c9-aaf2-f7d9896bac69" + }, + "_type": 1, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "ca8401fe-ad6e-41a8-bd46-8e3e4e9945be" + }, + "fileId": "e4b25otxWBLVpmoEY72dW1B", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "page_2", + "_objFlags": 512, + "_parent": { + "__id__": 6 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 11 + } + ], + "_prefab": { + "__id__": 12 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 200, + "g": 255, + "b": 200, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 400, + "height": 290 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 600, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 10 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "9bbda31e-ad49-43c9-aaf2-f7d9896bac69" + }, + "_type": 1, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "ca8401fe-ad6e-41a8-bd46-8e3e4e9945be" + }, + "fileId": "0460dpbuuVL6IrBc9SGei8F", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "page_3", + "_objFlags": 512, + "_parent": { + "__id__": 6 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 14 + } + ], + "_prefab": { + "__id__": 15 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 200, + "g": 200, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 400, + "height": 290 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 1000, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 13 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "9bbda31e-ad49-43c9-aaf2-f7d9896bac69" + }, + "_type": 1, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "ca8401fe-ad6e-41a8-bd46-8e3e4e9945be" + }, + "fileId": "7a1b8sccmBN1Jj/ZHKaE3JK", + "sync": false + }, + { + "__type__": "cc.Layout", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 6 + }, + "_enabled": true, + "_layoutSize": { + "__type__": "cc.Size", + "width": 1200, + "height": 350 + }, + "_resize": 1, + "_N$layoutType": 1, + "_N$cellSize": { + "__type__": "cc.Size", + "width": 40, + "height": 40 + }, + "_N$startAxis": 0, + "_N$paddingLeft": 0, + "_N$paddingRight": 0, + "_N$paddingTop": 0, + "_N$paddingBottom": 0, + "_N$spacingX": 0, + "_N$spacingY": 15, + "_N$verticalDirection": 1, + "_N$horizontalDirection": 0, + "_N$affectedByScale": false, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "ca8401fe-ad6e-41a8-bd46-8e3e4e9945be" + }, + "fileId": "47588+/BXNHEK1F1sC9uHbf", + "sync": false + }, + { + "__type__": "cc.Mask", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 5 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_spriteFrame": null, + "_type": 0, + "_segments": 64, + "_N$alphaThreshold": 0, + "_N$inverted": false, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "ca8401fe-ad6e-41a8-bd46-8e3e4e9945be" + }, + "fileId": "5b1864GVRZEC7Qc8fzYUge7", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "indicator", + "_objFlags": 512, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 21 + } + ], + "_prefab": { + "__id__": 23 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 27 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + -160, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.PageViewIndicator", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 20 + }, + "_enabled": true, + "_layout": null, + "_pageView": { + "__id__": 22 + }, + "_indicators": [], + "spriteFrame": { + "__uuid__": "c9fa51ff-3f01-4601-8f80-325d1b11dab7" + }, + "direction": 0, + "cellSize": { + "__type__": "cc.Size", + "width": 10, + "height": 10 + }, + "spacing": 10, + "_id": "" + }, + { + "__type__": "cc.PageView", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "horizontal": true, + "vertical": true, + "inertia": true, + "brake": 0.5, + "elastic": true, + "bounceDuration": 0.5, + "scrollEvents": [], + "cancelInnerEvents": true, + "_N$content": { + "__id__": 6 + }, + "content": { + "__id__": 6 + }, + "scrollThreshold": 0.5, + "autoPageTurningThreshold": 100, + "pageTurningEventTiming": 0.1, + "pageTurningSpeed": 0.3, + "pageEvents": [], + "_N$sizeMode": 0, + "_N$direction": 0, + "_N$indicator": { + "__id__": 21 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "ca8401fe-ad6e-41a8-bd46-8e3e4e9945be" + }, + "fileId": "c3bcdZElclEBJbaV6uqwUJx", + "sync": false + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "ca8401fe-ad6e-41a8-bd46-8e3e4e9945be" + }, + "fileId": "52f01L6ceBGDrJGf8m2N/2X", + "sync": false + } +] \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/cd/cd33edea-55f5-46c2-958d-357a01384a36.json b/Layered_virtual_list_2.x/library/imports/cd/cd33edea-55f5-46c2-958d-357a01384a36.json new file mode 100644 index 0000000..73d7484 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/cd/cd33edea-55f5-46c2-958d-357a01384a36.json @@ -0,0 +1,177 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "particlesystem", + "_objFlags": 0, + "data": { + "__id__": 1 + }, + "optimizationPolicy": 1, + "asyncLoadAssets": false, + "readonly": false + }, + { + "__type__": "cc.Node", + "_name": "ParticleSystem", + "_objFlags": 0, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_cascadeOpacityEnabled": true, + "_parent": null, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_children": [], + "_skewX": 0, + "_skewY": 0, + "_localZOrder": 0, + "_globalZOrder": 0, + "_tag": -1, + "_opacityModifyRGB": false, + "_reorderChildDirty": false, + "_id": "", + "_active": true, + "_components": [ + { + "__id__": 2 + } + ], + "_prefab": { + "__id__": 3 + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.ParticleSystem", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "_custom": false, + "_file": { + "__uuid__": "b2687ac4-099e-403c-a192-ff477686f4f5" + }, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "playOnLoad": true, + "_autoRemoveOnFinish": false, + "totalParticles": 150, + "duration": -1, + "emissionRate": 10, + "life": 1, + "lifeVar": 0, + "_startColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_startColorVar": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_endColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 0 + }, + "_endColorVar": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 0 + }, + "angle": 90, + "angleVar": 20, + "startSize": 50, + "startSizeVar": 0, + "endSize": 0, + "endSizeVar": 0, + "startSpin": 0, + "startSpinVar": 0, + "endSpin": 0, + "endSpinVar": 0, + "sourcePos": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "posVar": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_positionType": 0, + "_emitterMode": 0, + "gravity": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "speed": 180, + "speedVar": 50, + "tangentialAccel": 80, + "tangentialAccelVar": 0, + "radialAccel": 0, + "radialAccelVar": 0, + "rotationIsDir": false, + "startRadius": 0, + "startRadiusVar": 0, + "endRadius": 0, + "endRadiusVar": 0, + "rotatePerS": 0, + "rotatePerSVar": 0, + "_N$preview": true + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": null, + "fileId": "868c9k4nqZNHpGMlTm0Yx6q" + } +] \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/cf/cf7e0bb8-a81c-44a9-ad79-d28d43991032.json b/Layered_virtual_list_2.x/library/imports/cf/cf7e0bb8-a81c-44a9-ad79-d28d43991032.json new file mode 100644 index 0000000..02c1e1e --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/cf/cf7e0bb8-a81c-44a9-ad79-d28d43991032.json @@ -0,0 +1,10 @@ +{ + "__type__": "cc.Material", + "_name": "builtin-clear-stencil", + "_objFlags": 0, + "_native": "", + "_effectAsset": { + "__uuid__": "c0040c95-c57f-49cd-9cbc-12316b73d0d4" + }, + "_techniqueData": {} +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/cf/cfef78f1-c8df-49b7-8ed0-4c953ace2621.json b/Layered_virtual_list_2.x/library/imports/cf/cfef78f1-c8df-49b7-8ed0-4c953ace2621.json new file mode 100644 index 0000000..e7522d6 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/cf/cfef78f1-c8df-49b7-8ed0-4c953ace2621.json @@ -0,0 +1,4 @@ +{ + "__type__": "cc.Texture2D", + "content": "0,9729,9729,33071,33071,0,0,1" +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/cf/cfef78f1-c8df-49b7-8ed0-4c953ace2621.png b/Layered_virtual_list_2.x/library/imports/cf/cfef78f1-c8df-49b7-8ed0-4c953ace2621.png new file mode 100644 index 0000000..3a103b8 Binary files /dev/null and b/Layered_virtual_list_2.x/library/imports/cf/cfef78f1-c8df-49b7-8ed0-4c953ace2621.png differ diff --git a/Layered_virtual_list_2.x/library/imports/d0/d0a82d39-bede-46c4-b698-c81ff0dedfff.json b/Layered_virtual_list_2.x/library/imports/d0/d0a82d39-bede-46c4-b698-c81ff0dedfff.json new file mode 100644 index 0000000..e7522d6 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/d0/d0a82d39-bede-46c4-b698-c81ff0dedfff.json @@ -0,0 +1,4 @@ +{ + "__type__": "cc.Texture2D", + "content": "0,9729,9729,33071,33071,0,0,1" +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/d0/d0a82d39-bede-46c4-b698-c81ff0dedfff.png b/Layered_virtual_list_2.x/library/imports/d0/d0a82d39-bede-46c4-b698-c81ff0dedfff.png new file mode 100644 index 0000000..ff833c2 Binary files /dev/null and b/Layered_virtual_list_2.x/library/imports/d0/d0a82d39-bede-46c4-b698-c81ff0dedfff.png differ diff --git a/Layered_virtual_list_2.x/library/imports/d1/d1b8be49-b0a0-435c-83b7-552bed4bbe35.json b/Layered_virtual_list_2.x/library/imports/d1/d1b8be49-b0a0-435c-83b7-552bed4bbe35.json new file mode 100644 index 0000000..34be145 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/d1/d1b8be49-b0a0-435c-83b7-552bed4bbe35.json @@ -0,0 +1,1222 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "toggleGroup", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 1, + "asyncLoadAssets": false, + "readonly": false + }, + { + "__type__": "cc.Node", + "_name": "toggleGroup", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + }, + { + "__id__": 12 + }, + { + "__id__": 21 + } + ], + "_active": true, + "_components": [ + { + "__id__": 10 + } + ], + "_prefab": { + "__id__": 30 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 221, + "height": 61 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "toggle1", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 3 + }, + { + "__id__": 6 + } + ], + "_active": true, + "_components": [ + { + "__id__": 9 + } + ], + "_prefab": { + "__id__": 11 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 41, + "height": 28 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -62, + 3, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Background", + "_objFlags": 512, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 4 + } + ], + "_prefab": { + "__id__": 5 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 32, + "height": 32 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 3 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "e7aba14b-f956-4480-b254-8d57832e273f" + }, + "_type": 0, + "_sizeMode": 2, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": false, + "_atlas": null, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "d1b8be49-b0a0-435c-83b7-552bed4bbe35" + }, + "fileId": "77Nw/VkxBDlYn1tJHSiW69", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "checkmark", + "_objFlags": 512, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 7 + } + ], + "_prefab": { + "__id__": 8 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 32, + "height": 32 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 6 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "1a32fc76-f0bd-4f66-980f-56929c0ca0b3" + }, + "_type": 0, + "_sizeMode": 2, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": false, + "_atlas": null, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "d1b8be49-b0a0-435c-83b7-552bed4bbe35" + }, + "fileId": "eabUMeFj1JHYgwbMpSg1zc", + "sync": false + }, + { + "__type__": "cc.Toggle", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "_normalMaterial": null, + "_grayMaterial": null, + "duration": 0.1, + "zoomScale": 1.2, + "clickEvents": [], + "_N$interactable": true, + "_N$enableAutoGrayEffect": false, + "_N$transition": 3, + "transition": 3, + "_N$normalColor": { + "__type__": "cc.Color", + "r": 214, + "g": 214, + "b": 214, + "a": 255 + }, + "_N$pressedColor": { + "__type__": "cc.Color", + "r": 211, + "g": 211, + "b": 211, + "a": 255 + }, + "pressedColor": { + "__type__": "cc.Color", + "r": 211, + "g": 211, + "b": 211, + "a": 255 + }, + "_N$hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$disabledColor": { + "__type__": "cc.Color", + "r": 124, + "g": 124, + "b": 124, + "a": 255 + }, + "_N$normalSprite": null, + "_N$pressedSprite": null, + "pressedSprite": null, + "_N$hoverSprite": null, + "hoverSprite": null, + "_N$disabledSprite": null, + "_N$target": { + "__id__": 2 + }, + "_N$isChecked": true, + "toggleGroup": { + "__id__": 10 + }, + "checkMark": { + "__id__": 7 + }, + "checkEvents": [], + "_id": "" + }, + { + "__type__": "cc.ToggleGroup", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "allowSwitchOff": false, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "d1b8be49-b0a0-435c-83b7-552bed4bbe35" + }, + "fileId": "25DeyD94tFkalmK6Tg7UdE", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "toggle2", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 13 + }, + { + "__id__": 16 + } + ], + "_active": true, + "_components": [ + { + "__id__": 19 + } + ], + "_prefab": { + "__id__": 20 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 42, + "height": 28 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 15, + 3, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Background", + "_objFlags": 512, + "_parent": { + "__id__": 12 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 14 + } + ], + "_prefab": { + "__id__": 15 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 32, + "height": 32 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 13 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "e7aba14b-f956-4480-b254-8d57832e273f" + }, + "_type": 0, + "_sizeMode": 2, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": false, + "_atlas": null, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "d1b8be49-b0a0-435c-83b7-552bed4bbe35" + }, + "fileId": "72QEruyX5CrIAFmVn9a3F6", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "checkmark", + "_objFlags": 512, + "_parent": { + "__id__": 12 + }, + "_children": [], + "_active": false, + "_components": [ + { + "__id__": 17 + } + ], + "_prefab": { + "__id__": 18 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 32, + "height": 32 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 16 + }, + "_enabled": true, + "_materials": [], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "1a32fc76-f0bd-4f66-980f-56929c0ca0b3" + }, + "_type": 0, + "_sizeMode": 2, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": false, + "_atlas": null, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "d1b8be49-b0a0-435c-83b7-552bed4bbe35" + }, + "fileId": "c7L6vaJVRBDZfq/ZftHdp1", + "sync": false + }, + { + "__type__": "cc.Toggle", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 12 + }, + "_enabled": true, + "_normalMaterial": null, + "_grayMaterial": null, + "duration": 0.1, + "zoomScale": 1.2, + "clickEvents": [], + "_N$interactable": true, + "_N$enableAutoGrayEffect": false, + "_N$transition": 3, + "transition": 3, + "_N$normalColor": { + "__type__": "cc.Color", + "r": 214, + "g": 214, + "b": 214, + "a": 255 + }, + "_N$pressedColor": { + "__type__": "cc.Color", + "r": 211, + "g": 211, + "b": 211, + "a": 255 + }, + "pressedColor": { + "__type__": "cc.Color", + "r": 211, + "g": 211, + "b": 211, + "a": 255 + }, + "_N$hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$disabledColor": { + "__type__": "cc.Color", + "r": 124, + "g": 124, + "b": 124, + "a": 255 + }, + "_N$normalSprite": null, + "_N$pressedSprite": null, + "pressedSprite": null, + "_N$hoverSprite": null, + "hoverSprite": null, + "_N$disabledSprite": null, + "_N$target": { + "__id__": 12 + }, + "_N$isChecked": false, + "toggleGroup": { + "__id__": 10 + }, + "checkMark": { + "__id__": 17 + }, + "checkEvents": [], + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "d1b8be49-b0a0-435c-83b7-552bed4bbe35" + }, + "fileId": "61w1JEqOlGsaSeDBTtJqu3", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "toggle3", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 22 + }, + { + "__id__": 25 + } + ], + "_active": true, + "_components": [ + { + "__id__": 28 + } + ], + "_prefab": { + "__id__": 29 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 37, + "height": 28 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 91, + 3, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Background", + "_objFlags": 512, + "_parent": { + "__id__": 21 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 23 + } + ], + "_prefab": { + "__id__": 24 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 32, + "height": 32 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 22 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "e7aba14b-f956-4480-b254-8d57832e273f" + }, + "_type": 0, + "_sizeMode": 2, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": false, + "_atlas": null, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "d1b8be49-b0a0-435c-83b7-552bed4bbe35" + }, + "fileId": "9dSgcVxjxAToRrdMlwhWpR", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "checkmark", + "_objFlags": 512, + "_parent": { + "__id__": 21 + }, + "_children": [], + "_active": false, + "_components": [ + { + "__id__": 26 + } + ], + "_prefab": { + "__id__": 27 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 32, + "height": 32 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 25 + }, + "_enabled": true, + "_materials": [], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "1a32fc76-f0bd-4f66-980f-56929c0ca0b3" + }, + "_type": 0, + "_sizeMode": 2, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": false, + "_atlas": null, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "d1b8be49-b0a0-435c-83b7-552bed4bbe35" + }, + "fileId": "24Fq6PF85FxZmTxjsAlpwl", + "sync": false + }, + { + "__type__": "cc.Toggle", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 21 + }, + "_enabled": true, + "_normalMaterial": null, + "_grayMaterial": null, + "duration": 0.1, + "zoomScale": 1.2, + "clickEvents": [], + "_N$interactable": true, + "_N$enableAutoGrayEffect": false, + "_N$transition": 3, + "transition": 3, + "_N$normalColor": { + "__type__": "cc.Color", + "r": 214, + "g": 214, + "b": 214, + "a": 255 + }, + "_N$pressedColor": { + "__type__": "cc.Color", + "r": 211, + "g": 211, + "b": 211, + "a": 255 + }, + "pressedColor": { + "__type__": "cc.Color", + "r": 211, + "g": 211, + "b": 211, + "a": 255 + }, + "_N$hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$disabledColor": { + "__type__": "cc.Color", + "r": 124, + "g": 124, + "b": 124, + "a": 255 + }, + "_N$normalSprite": null, + "_N$pressedSprite": null, + "pressedSprite": null, + "_N$hoverSprite": null, + "hoverSprite": null, + "_N$disabledSprite": null, + "_N$target": { + "__id__": 21 + }, + "_N$isChecked": false, + "toggleGroup": { + "__id__": 10 + }, + "checkMark": { + "__id__": 26 + }, + "checkEvents": [], + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "d1b8be49-b0a0-435c-83b7-552bed4bbe35" + }, + "fileId": "99UOOvWWtLsock+J9rw0jb", + "sync": false + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "d1b8be49-b0a0-435c-83b7-552bed4bbe35" + }, + "fileId": "d7d5Rc1ntDm421UemL1Qj0", + "sync": false + } +] \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/d2/d29077ba-1627-4a72-9579-7b56a235340c.json b/Layered_virtual_list_2.x/library/imports/d2/d29077ba-1627-4a72-9579-7b56a235340c.json new file mode 100644 index 0000000..e7522d6 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/d2/d29077ba-1627-4a72-9579-7b56a235340c.json @@ -0,0 +1,4 @@ +{ + "__type__": "cc.Texture2D", + "content": "0,9729,9729,33071,33071,0,0,1" +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/d2/d29077ba-1627-4a72-9579-7b56a235340c.png b/Layered_virtual_list_2.x/library/imports/d2/d29077ba-1627-4a72-9579-7b56a235340c.png new file mode 100644 index 0000000..d63c921 Binary files /dev/null and b/Layered_virtual_list_2.x/library/imports/d2/d29077ba-1627-4a72-9579-7b56a235340c.png differ diff --git a/Layered_virtual_list_2.x/library/imports/d3/d33f6314-18ec-4937-978c-27d5334b7287.js b/Layered_virtual_list_2.x/library/imports/d3/d33f6314-18ec-4937-978c-27d5334b7287.js new file mode 100644 index 0000000..9717478 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/d3/d33f6314-18ec-4937-978c-27d5334b7287.js @@ -0,0 +1,109 @@ +"use strict"; +cc._RF.push(module, 'd33f6MUGOxJN5eMJ9UzS3KH', 'RenderAlternativeItem'); +// Script/RenderAlternativeItem.ts + +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var RenderAlternative_1 = require("./RenderAlternative"); +var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property; +var RenderAlternativeItem = /** @class */ (function (_super) { + __extends(RenderAlternativeItem, _super); + /** + * 渲染分层Item挂载组件 + * 处理渲染分层Item的渲染分层 + */ + function RenderAlternativeItem() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /**是否初始化过代理组建 */ + _this.hasInit = false; + return _this; + } + /**初始化 */ + RenderAlternativeItem.prototype.initRenderLayer = function (renderLayer) { + if (this.renderLayer != renderLayer) { + this.renderLayer = renderLayer; + renderLayer && this.initRenders(); + } + }; + /** + * 处理分层代理渲染 + */ + RenderAlternativeItem.prototype.initRenders = function () { + if (!this.hasInit && this.renderLayer) { + // + var propMap = new WeakMap(); + var keys = Object.keys(this); + for (var i = 0, len = keys.length; i < len; ++i) { + var value = this[keys[i]]; + var alternative = null; + if (value instanceof cc.Node) { + alternative = value.getComponent(RenderAlternative_1.default); + if (alternative) { + alternative.init(this.renderLayer); + } + } + else if (value instanceof cc.RenderComponent) { + alternative = value.getComponent(RenderAlternative_1.default); + if (alternative) { + this[keys[i]] = alternative.init(this.renderLayer); + } + } + alternative && propMap.set(alternative, true); + } + this.dealChilrenAlternative(this.node, propMap, 0, 0); + this.hasInit = true; + } + }; + /** + * 处理子节点代理 + * @param node + * @param propMap 记录脚本已经处理过的属性代理 + * @param parentSindex 父节点的所在的顺序 + * @param depth 深度 + */ + RenderAlternativeItem.prototype.dealChilrenAlternative = function (node, propMap, parentSindex, depth) { + var _a; + for (var i = 0, len = node.children.length; i < len; i++) { + var children = node.children[i]; + var alternative = (_a = children.getComponent(cc.RenderComponent)) === null || _a === void 0 ? void 0 : _a.getComponent(RenderAlternative_1.default); + var sIndex = parentSindex + (i * Math.pow(0.1, depth)); + if (alternative) { + if ((!propMap.has(alternative) || !propMap.get(alternative))) { + alternative.init(this.renderLayer); + } + alternative.sIndex = sIndex; + } + this.dealChilrenAlternative(children, propMap, sIndex, depth + 1); + } + }; + RenderAlternativeItem = __decorate([ + ccclass + /** + * 渲染分层Item挂载组件 + * 处理渲染分层Item的渲染分层 + */ + ], RenderAlternativeItem); + return RenderAlternativeItem; +}(cc.Component)); +exports.default = RenderAlternativeItem; + +cc._RF.pop(); \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/d3/d33f6314-18ec-4937-978c-27d5334b7287.js.map b/Layered_virtual_list_2.x/library/imports/d3/d33f6314-18ec-4937-978c-27d5334b7287.js.map new file mode 100644 index 0000000..3fa21b1 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/d3/d33f6314-18ec-4937-978c-27d5334b7287.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["assets\\Script\\RenderAlternativeItem.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yDAAoD;AAG9C,IAAA,KAAwB,EAAE,CAAC,UAAU,EAAnC,OAAO,aAAA,EAAE,QAAQ,cAAkB,CAAC;AAO5C;IAAmD,yCAAY;IAJ/D;;;OAGG;IACH;QAAA,qEA8DC;QA5DG,gBAAgB;QACR,aAAO,GAAY,KAAK,CAAC;;IA2DrC,CAAC;IAxDG,SAAS;IACF,+CAAe,GAAtB,UAAuB,WAAoB;QACvC,IAAI,IAAI,CAAC,WAAW,IAAI,WAAW,EAAE;YACjC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;YAC/B,WAAW,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;SACrC;IACL,CAAC;IACD;;OAEG;IACK,2CAAW,GAAnB;QACI,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,WAAW,EAAE;YACnC,EAAE;YACF,IAAI,OAAO,GAAwC,IAAI,OAAO,EAAE,CAAC;YACjE,IAAI,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC7B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,GAAG,GAAG,EAAE,EAAE,CAAC,EAAE;gBAC7C,IAAI,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;gBAC1B,IAAI,WAAW,GAAsB,IAAI,CAAC;gBAC1C,IAAI,KAAK,YAAY,EAAE,CAAC,IAAI,EAAE;oBAC1B,WAAW,GAAG,KAAK,CAAC,YAAY,CAAC,2BAAiB,CAAC,CAAC;oBACpD,IAAI,WAAW,EAAE;wBACb,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;qBACtC;iBACJ;qBAAM,IAAI,KAAK,YAAY,EAAE,CAAC,eAAe,EAAE;oBAC5C,WAAW,GAAG,KAAK,CAAC,YAAY,CAAC,2BAAiB,CAAC,CAAC;oBACpD,IAAI,WAAW,EAAE;wBACb,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,IAAI,CAAe,IAAI,CAAC,WAAW,CAAC,CAAC;qBACpE;iBACJ;gBACD,WAAW,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;aACjD;YACD,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;YACtD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;SACvB;IACL,CAAC;IACD;;;;;;OAMG;IACH,sDAAsB,GAAtB,UAAuB,IAAa,EAAE,OAA4C,EAAE,YAAoB,EAAE,KAAa;;QACnH,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE;YACtD,IAAI,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;YAChC,IAAI,WAAW,SAAG,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC,eAAe,CAAC,0CAAE,YAAY,CAAC,2BAAiB,CAAC,CAAC;YAC7F,IAAI,MAAM,GAAG,YAAY,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;YACvD,IAAI,WAAW,EAAE;gBACb,IAAI,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,EAAE;oBAC1D,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;iBACtC;gBACD,WAAW,CAAC,MAAM,GAAG,MAAM,CAAC;aAC/B;YACD,IAAI,CAAC,sBAAsB,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;SACrE;IACL,CAAC;IA7DgB,qBAAqB;QALzC,OAAO;QACR;;;WAGG;OACkB,qBAAqB,CA8DzC;IAAD,4BAAC;CA9DD,AA8DC,CA9DkD,EAAE,CAAC,SAAS,GA8D9D;kBA9DoB,qBAAqB","file":"","sourceRoot":"/","sourcesContent":["import RenderAlternative from \"./RenderAlternative\";\r\n\r\n\r\nconst { ccclass, property } = cc._decorator;\r\n\r\n@ccclass\r\n/**\r\n * 渲染分层Item挂载组件\r\n * 处理渲染分层Item的渲染分层\r\n */\r\nexport default class RenderAlternativeItem extends cc.Component {\r\n\r\n /**是否初始化过代理组建 */\r\n private hasInit: boolean = false;\r\n /**渲染分层开启的挂载节点 */\r\n public renderLayer: cc.Node;\r\n /**初始化 */\r\n public initRenderLayer(renderLayer: cc.Node) {\r\n if (this.renderLayer != renderLayer) {\r\n this.renderLayer = renderLayer;\r\n renderLayer && this.initRenders();\r\n }\r\n }\r\n /**\r\n * 处理分层代理渲染\r\n */\r\n private initRenders() {\r\n if (!this.hasInit && this.renderLayer) {\r\n //\r\n let propMap: WeakMap = new WeakMap();\r\n let keys = Object.keys(this);\r\n for (let i = 0, len = keys.length; i < len; ++i) {\r\n let value = this[keys[i]];\r\n let alternative: RenderAlternative = null;\r\n if (value instanceof cc.Node) {\r\n alternative = value.getComponent(RenderAlternative);\r\n if (alternative) {\r\n alternative.init(this.renderLayer);\r\n }\r\n } else if (value instanceof cc.RenderComponent) {\r\n alternative = value.getComponent(RenderAlternative);\r\n if (alternative) {\r\n this[keys[i]] = alternative.init(this.renderLayer);\r\n }\r\n }\r\n alternative && propMap.set(alternative, true);\r\n }\r\n this.dealChilrenAlternative(this.node, propMap, 0, 0);\r\n this.hasInit = true;\r\n }\r\n }\r\n /**\r\n * 处理子节点代理\r\n * @param node \r\n * @param propMap 记录脚本已经处理过的属性代理\r\n * @param parentSindex 父节点的所在的顺序\r\n * @param depth 深度\r\n */\r\n dealChilrenAlternative(node: cc.Node, propMap: WeakMap, parentSindex: number, depth: number) {\r\n for (let i = 0, len = node.children.length; i < len; i++) {\r\n let children = node.children[i];\r\n let alternative = children.getComponent(cc.RenderComponent)?.getComponent(RenderAlternative);\r\n let sIndex = parentSindex + (i * Math.pow(0.1, depth));\r\n if (alternative) {\r\n if ((!propMap.has(alternative) || !propMap.get(alternative))) {\r\n alternative.init(this.renderLayer);\r\n }\r\n alternative.sIndex = sIndex;\r\n }\r\n this.dealChilrenAlternative(children, propMap, sIndex, depth + 1);\r\n }\r\n }\r\n}\r\n"]} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/d3/d38d025a-fb9d-4cf0-bf13-61343069ef50.js b/Layered_virtual_list_2.x/library/imports/d3/d38d025a-fb9d-4cf0-bf13-61343069ef50.js new file mode 100644 index 0000000..8bc1637 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/d3/d38d025a-fb9d-4cf0-bf13-61343069ef50.js @@ -0,0 +1,84 @@ +"use strict"; +cc._RF.push(module, 'd38d0Ja+51M8L8TYTQwae9Q', 'RenderReactiveHandler'); +// Script/RenderReactiveHandler.ts + +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.RenderReactiveHandler = exports.hasChanged = exports.hasOwn = exports.isObject = void 0; +function isObject(value) { + return value !== null && typeof value === 'object'; +} +exports.isObject = isObject; +var hasOwnProperty = Object.prototype.hasOwnProperty; +/** 是否自身上存在属性 */ +function hasOwn(val, key) { + if (val instanceof cc.Component) { + return key in val; + } + return hasOwnProperty.call(val, key); +} +exports.hasOwn = hasOwn; +/** 比较值是否变化了,考虑NaN;如果是对象直接认为改变了 */ +function hasChanged(value, oldValue) { + var type = typeof value; + if (type === "object") + return true; + return !Object.is(value, oldValue); +} +exports.hasChanged = hasChanged; +var RenderReactiveHandler = /** @class */ (function () { + function RenderReactiveHandler(reactiveTarget) { + /**需要作出反应的对象 */ + this.reactiveTarget = null; + this.reactiveTarget = reactiveTarget; + } + /** + * + * @param target 被代理的对象 + * @param prop 被代理的对象的属性名 + * @param value 被代理的对象的属性值 + * @param receiver 代理对象 + * @returns + */ + RenderReactiveHandler.prototype.set = function (target, prop, value, receiver) { + var oldValue = Reflect.get(target, prop); + var hadKey = hasOwn(target, prop); + var result = Reflect.set(target, prop, value); + if (!hadKey || hasChanged(value, oldValue)) { + if (prop == "angle" || prop == 'scale' || prop == "position" || prop == "_renderFlag") + return; + if (prop == 'activeInHierarchy') { + console.warn(target); + } + // 属性变化 + this.reactiveTarget && (Reflect.set(this.reactiveTarget, prop, value)); + } + return result; + }; + RenderReactiveHandler.prototype.apply = function () { + console.warn(arguments); + }; + RenderReactiveHandler.prototype.get = function (target, prop, receiver) { + if (prop === '__raw__') { + return target; + } + else if (prop === '__isReactive__') { + return true; + } + var rawValue = Reflect.get(target, prop); + return rawValue; + }; + RenderReactiveHandler.prototype.deleteProperty = function (target, prop) { + var hadKey = hasOwn(target, prop); + var oldValue = target[prop]; + var result = Reflect.deleteProperty(target, prop); + if (result && hadKey) { + //trigger(target, prop, void 0, oldValue); + } + return result; + }; + return RenderReactiveHandler; +}()); +exports.RenderReactiveHandler = RenderReactiveHandler; + +cc._RF.pop(); \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/d3/d38d025a-fb9d-4cf0-bf13-61343069ef50.js.map b/Layered_virtual_list_2.x/library/imports/d3/d38d025a-fb9d-4cf0-bf13-61343069ef50.js.map new file mode 100644 index 0000000..db07343 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/d3/d38d025a-fb9d-4cf0-bf13-61343069ef50.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["assets\\Script\\RenderReactiveHandler.ts"],"names":[],"mappings":";;;;;;;AACA,SAAgB,QAAQ,CAAC,KAAc;IACnC,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC;AACvD,CAAC;AAFD,4BAEC;AAED,IAAM,cAAc,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc,CAAA;AACtD,gBAAgB;AAChB,SAAgB,MAAM,CAAC,GAAW,EAAE,GAA6B;IAC7D,IAAI,GAAG,YAAY,EAAE,CAAC,SAAS,EAAE;QAC7B,OAAO,GAAG,IAAI,GAAG,CAAC;KACrB;IACD,OAAO,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AACzC,CAAC;AALD,wBAKC;AAED,kCAAkC;AAClC,SAAgB,UAAU,CAAC,KAAU,EAAE,QAAa;IAChD,IAAI,IAAI,GAAG,OAAO,KAAK,CAAC;IACxB,IAAI,IAAI,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IACnC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;AACvC,CAAC;AAJD,gCAIC;AAGD;IACI,+BAAY,cAAuB;QAGnC,eAAe;QACP,mBAAc,GAAW,IAAI,CAAC;QAHlC,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IACzC,CAAC;IAID;;;;;;;OAOG;IACH,mCAAG,GAAH,UAAI,MAAc,EAAE,IAAqB,EAAE,KAAU,EAAE,QAAa;QAEhE,IAAI,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QACzC,IAAI,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAClC,IAAI,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;QAC9C,IAAI,CAAC,MAAM,IAAI,UAAU,CAAC,KAAK,EAAE,QAAQ,CAAC,EAAE;YACxC,IAAI,IAAI,IAAI,OAAO,IAAI,IAAI,IAAI,OAAO,IAAI,IAAI,IAAI,UAAU,IAAI,IAAI,IAAI,aAAa;gBAAE,OAAO;YAC9F,IAAI,IAAI,IAAI,mBAAmB,EAAE;gBAC7B,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;aACxB;YACD,OAAO;YACP,IAAI,CAAC,cAAc,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;SAC1E;QAED,OAAO,MAAM,CAAA;IACjB,CAAC;IAED,qCAAK,GAAL;QACI,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;IAC3B,CAAC;IAED,mCAAG,GAAH,UAAI,MAAc,EAAE,IAAqB,EAAE,QAAa;QAEpD,IAAI,IAAI,KAAK,SAAS,EAAE;YACpB,OAAO,MAAM,CAAC;SACjB;aACI,IAAI,IAAI,KAAK,gBAAgB,EAAE;YAChC,OAAO,IAAI,CAAC;SACf;QACD,IAAI,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QACzC,OAAO,QAAQ,CAAC;IACpB,CAAC;IAED,8CAAc,GAAd,UAAe,MAAc,EAAE,IAAqB;QAChD,IAAI,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAClC,IAAI,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;QAC5B,IAAI,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAClD,IAAI,MAAM,IAAI,MAAM,EAAE;YAClB,0CAA0C;SAC7C;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;IACL,4BAAC;AAAD,CA1DA,AA0DC,IAAA;AA1DY,sDAAqB","file":"","sourceRoot":"/","sourcesContent":["\r\nexport function isObject(value: unknown): value is Record {\r\n return value !== null && typeof value === 'object';\r\n}\r\n\r\nconst hasOwnProperty = Object.prototype.hasOwnProperty\r\n/** 是否自身上存在属性 */\r\nexport function hasOwn(val: object, key: string | number | symbol): key is keyof typeof val {\r\n if (val instanceof cc.Component) {\r\n return key in val;\r\n }\r\n return hasOwnProperty.call(val, key);\r\n}\r\n\r\n/** 比较值是否变化了,考虑NaN;如果是对象直接认为改变了 */\r\nexport function hasChanged(value: any, oldValue: any): boolean {\r\n let type = typeof value;\r\n if (type === \"object\") return true;\r\n return !Object.is(value, oldValue);\r\n}\r\n\r\n\r\nexport class RenderReactiveHandler {\r\n constructor(reactiveTarget?: object) {\r\n this.reactiveTarget = reactiveTarget;\r\n }\r\n /**需要作出反应的对象 */\r\n private reactiveTarget: object = null;\r\n\r\n /**\r\n * \r\n * @param target 被代理的对象\r\n * @param prop 被代理的对象的属性名\r\n * @param value 被代理的对象的属性值\r\n * @param receiver 代理对象\r\n * @returns \r\n */\r\n set(target: object, prop: string | symbol, value: any, receiver: any): boolean {\r\n\r\n let oldValue = Reflect.get(target, prop);\r\n let hadKey = hasOwn(target, prop);\r\n let result = Reflect.set(target, prop, value);\r\n if (!hadKey || hasChanged(value, oldValue)) {\r\n if (prop == \"angle\" || prop == 'scale' || prop == \"position\" || prop == \"_renderFlag\") return;\r\n if (prop == 'activeInHierarchy') {\r\n console.warn(target);\r\n }\r\n // 属性变化\r\n this.reactiveTarget && (Reflect.set(this.reactiveTarget, prop, value));\r\n }\r\n\r\n return result\r\n }\r\n\r\n apply() {\r\n console.warn(arguments)\r\n }\r\n\r\n get(target: object, prop: string | symbol, receiver: any): any {\r\n\r\n if (prop === '__raw__') {\r\n return target;\r\n }\r\n else if (prop === '__isReactive__') {\r\n return true;\r\n }\r\n let rawValue = Reflect.get(target, prop);\r\n return rawValue;\r\n }\r\n\r\n deleteProperty(target: object, prop: string | symbol): boolean {\r\n let hadKey = hasOwn(target, prop);\r\n let oldValue = target[prop];\r\n let result = Reflect.deleteProperty(target, prop);\r\n if (result && hadKey) {\r\n //trigger(target, prop, void 0, oldValue);\r\n }\r\n\r\n return result;\r\n }\r\n}\r\n"]} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/d6/d6d3ca85-4681-47c1-b5dd-d036a9d39ea2.json b/Layered_virtual_list_2.x/library/imports/d6/d6d3ca85-4681-47c1-b5dd-d036a9d39ea2.json new file mode 100644 index 0000000..e7522d6 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/d6/d6d3ca85-4681-47c1-b5dd-d036a9d39ea2.json @@ -0,0 +1,4 @@ +{ + "__type__": "cc.Texture2D", + "content": "0,9729,9729,33071,33071,0,0,1" +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/d6/d6d3ca85-4681-47c1-b5dd-d036a9d39ea2.png b/Layered_virtual_list_2.x/library/imports/d6/d6d3ca85-4681-47c1-b5dd-d036a9d39ea2.png new file mode 100644 index 0000000..6bda1af Binary files /dev/null and b/Layered_virtual_list_2.x/library/imports/d6/d6d3ca85-4681-47c1-b5dd-d036a9d39ea2.png differ diff --git a/Layered_virtual_list_2.x/library/imports/d8/d81ec8ad-247c-4e62-aa3c-d35c4193c7af.json b/Layered_virtual_list_2.x/library/imports/d8/d81ec8ad-247c-4e62-aa3c-d35c4193c7af.json new file mode 100644 index 0000000..e7522d6 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/d8/d81ec8ad-247c-4e62-aa3c-d35c4193c7af.json @@ -0,0 +1,4 @@ +{ + "__type__": "cc.Texture2D", + "content": "0,9729,9729,33071,33071,0,0,1" +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/d8/d81ec8ad-247c-4e62-aa3c-d35c4193c7af.png b/Layered_virtual_list_2.x/library/imports/d8/d81ec8ad-247c-4e62-aa3c-d35c4193c7af.png new file mode 100644 index 0000000..78314b4 Binary files /dev/null and b/Layered_virtual_list_2.x/library/imports/d8/d81ec8ad-247c-4e62-aa3c-d35c4193c7af.png differ diff --git a/Layered_virtual_list_2.x/library/imports/dd/ddb99b39-7004-47cd-9705-751905c43c46.json b/Layered_virtual_list_2.x/library/imports/dd/ddb99b39-7004-47cd-9705-751905c43c46.json new file mode 100644 index 0000000..0f22a96 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/dd/ddb99b39-7004-47cd-9705-751905c43c46.json @@ -0,0 +1,117 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "directional", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "asyncLoadAssets": false, + "readonly": false + }, + { + "__type__": "cc.Node", + "_name": "light", + "_objFlags": 0, + "_parent": null, + "_children": [], + "_active": true, + "_level": 1, + "_components": [ + { + "__id__": 2 + } + ], + "_prefab": { + "__id__": 3 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "groupIndex": 0, + "_id": "", + "_eulerAngles": { + "x": 0, + "y": 0, + "z": 0, + "__type__": "cc.Vec3" + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Light", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "_type": 0, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_intensity": 1, + "_range": 1000, + "_spotAngle": 60, + "_spotExp": 1, + "_shadowType": 0, + "_shadowResolution": 1024, + "_shadowDarkness": 0.5, + "_shadowMinDepth": 1, + "_shadowMaxDepth": 1000, + "_shadowDepthScale": 250, + "_shadowFrustumSize": 50, + "_shadowBias": 0.0005, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "ddb99b39-7004-47cd-9705-751905c43c46" + }, + "fileId": "33zOkteexCqamZ4PXuwJaW", + "sync": false + } +] \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/de/de510076-056b-484f-b94c-83bef217d0e1.json b/Layered_virtual_list_2.x/library/imports/de/de510076-056b-484f-b94c-83bef217d0e1.json new file mode 100644 index 0000000..4f32d22 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/de/de510076-056b-484f-b94c-83bef217d0e1.json @@ -0,0 +1,109 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "torus", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "asyncLoadAssets": false, + "readonly": false + }, + { + "__type__": "cc.Node", + "_name": "torus", + "_objFlags": 0, + "_parent": null, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 2 + } + ], + "_prefab": { + "__id__": 3 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.MeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "a5849239-3ad3-41d1-8ab4-ae9fea11f97f" + } + ], + "_mesh": { + "__uuid__": "14c74869-bdb4-4f57-86d8-a7875de2be30" + }, + "_receiveShadows": false, + "_shadowCastingMode": 0, + "_enableAutoBatch": false, + "textures": [], + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "de510076-056b-484f-b94c-83bef217d0e1" + }, + "fileId": "a1gx3/CoNJb6xz1joaf6oM", + "sync": false + } +] \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/e0/e02d87d4-e599-4d16-8001-e14891ac6506.json b/Layered_virtual_list_2.x/library/imports/e0/e02d87d4-e599-4d16-8001-e14891ac6506.json new file mode 100644 index 0000000..5a4d972 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/e0/e02d87d4-e599-4d16-8001-e14891ac6506.json @@ -0,0 +1,16 @@ +{ + "__type__": "cc.Material", + "_name": "builtin-2d-label", + "_objFlags": 0, + "_native": "", + "_effectAsset": { + "__uuid__": "f18742d7-56d2-4eb5-ae49-2d9d710b37c8" + }, + "_techniqueData": { + "0": { + "defines": { + "USE_TEXTURE": true + } + } + } +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/e2/e2f00085-c597-422d-9759-52c360279106.json b/Layered_virtual_list_2.x/library/imports/e2/e2f00085-c597-422d-9759-52c360279106.json new file mode 100644 index 0000000..5744bae --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/e2/e2f00085-c597-422d-9759-52c360279106.json @@ -0,0 +1,825 @@ +{ + "__type__": "cc.EffectAsset", + "_name": "builtin-toon", + "_objFlags": 0, + "_native": "", + "properties": null, + "techniques": [ + { + "passes": [ + { + "name": "outline", + "rasterizerState": { + "cullMode": 1028 + }, + "depthStencilState": { + "depthTest": true, + "depthWrite": true + }, + "properties": { + "lineWidth": { + "value": [ + 10 + ], + "type": 13 + }, + "depthBias": { + "value": [ + 0 + ], + "type": 13 + }, + "outlineBaseColor": { + "value": [ + 0, + 0, + 0, + 1 + ], + "editor": { + "type": "color" + }, + "type": 16 + }, + "outlineBaseColorMap": { + "value": "gray", + "type": 29 + } + }, + "program": "builtin-toon|outline-vs:vert|outline-fs:frag" + }, + { + "name": "toon", + "depthStencilState": { + "depthTest": true, + "depthWrite": true + }, + "properties": { + "tilingOffset": { + "value": [ + 1, + 1, + 0, + 0 + ], + "type": 16 + }, + "normalMap": { + "value": "normal", + "type": 29 + }, + "baseColorMap": { + "value": "white", + "type": 29 + }, + "specular": { + "value": [ + 1, + 1, + 1, + 0.5 + ], + "editor": { + "type": "color" + }, + "type": 16 + }, + "specularMap": { + "value": "white", + "type": 29 + }, + "specularThreshold": { + "value": [ + 0.5 + ], + "type": 13 + }, + "emissive": { + "value": [ + 0, + 0, + 0, + 1 + ], + "editor": { + "type": "color" + }, + "type": 16 + }, + "emissiveMap": { + "value": "white", + "type": 29 + }, + "shadowColor": { + "value": [ + 0, + 0, + 0, + 1 + ], + "editor": { + "type": "color" + }, + "type": 16 + }, + "shadowIntensity": { + "value": [ + 0.5 + ], + "type": 13 + }, + "highlightColor": { + "value": [ + 1, + 1, + 1, + 1 + ], + "editor": { + "type": "color" + }, + "type": 16 + }, + "lightThreshold": { + "value": [ + 0.5 + ], + "type": 13 + }, + "lightSmoothness": { + "value": [ + 0.1 + ], + "type": 13 + } + }, + "program": "builtin-toon|toon-vs:vert|toon-fs:frag" + } + ] + } + ], + "shaders": [ + { + "hash": 2752667346, + "glsl3": { + "vert": "\nprecision highp float;\nuniform CCGlobal {\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\nuniform CCLocal {\n mat4 cc_matWorld;\n mat4 cc_matWorldIT;\n};\n#if CC_USE_SKINNING\n in vec4 a_weights;\n in vec4 a_joints;\n #if CC_USE_JOINTS_TEXTRUE\n uniform SKINNING {\n vec2 jointsTextureSize;\n };\n uniform sampler2D jointsTexture;\n #if CC_JOINTS_TEXTURE_FLOAT32\n mat4 getBoneMatrix(const in float i) {\n float width = jointsTextureSize.x;\n float height = jointsTextureSize.y;\n float j = i * 4.0;\n float x = mod(j, width);\n float y = floor(j / width);\n float dx = 1.0 / width;\n float dy = 1.0 / height;\n y = dy * (y + 0.5);\n vec4 v1 = texture(jointsTexture, vec2(dx * (x + 0.5), y));\n vec4 v2 = texture(jointsTexture, vec2(dx * (x + 1.5), y));\n vec4 v3 = texture(jointsTexture, vec2(dx * (x + 2.5), y));\n vec4 v4 = texture(jointsTexture, vec2(dx * (x + 3.5), y));\n return mat4(v1, v2, v3, v4);\n }\n #else\n float decode32(vec4 rgba) {\n float Sign = 1.0 - step(128.0, rgba[0]) * 2.0;\n float Exponent = 2.0 * mod(rgba[0], 128.0) + step(128.0, rgba[1]) - 127.0;\n float Mantissa = mod(rgba[1], 128.0) * 65536.0 + rgba[2] * 256.0 + rgba[3] + 8388608.0;\n return Sign * exp2(Exponent - 23.0) * Mantissa;\n }\n vec4 decodevec4 (vec4 x, vec4 y, vec4 z, vec4 w) {\n return vec4(\n decode32(x.wzyx * 255.0),\n decode32(y.wzyx * 255.0),\n decode32(z.wzyx * 255.0),\n decode32(w.wzyx * 255.0)\n );\n }\n vec4 decodevec4 (float dx, float x, float y) {\n return decodevec4(\n texture(jointsTexture, vec2(dx * (x + 0.5), y)),\n texture(jointsTexture, vec2(dx * (x + 1.5), y)),\n texture(jointsTexture, vec2(dx * (x + 2.5), y)),\n texture(jointsTexture, vec2(dx * (x + 3.5), y))\n );\n }\n mat4 getBoneMatrix(const in float i) {\n float width = jointsTextureSize.x;\n float height = jointsTextureSize.y;\n float j = i * 16.0;\n float x = mod(j, width);\n float y = floor(j / width);\n float dx = 1.0 / width;\n float dy = 1.0 / height;\n y = dy * (y + 0.5);\n vec4 v1 = decodevec4(dx, x, y);\n vec4 v2 = decodevec4(dx, x+4.0, y);\n vec4 v3 = decodevec4(dx, x+8.0, y);\n vec4 v4 = decodevec4(dx, x+12.0, y);\n return mat4(v1, v2, v3, v4);\n }\n #endif\n #else\n uniform JOINT_MATRIX {\n mat4 jointMatrices[50];\n };\n mat4 getBoneMatrix(const in float i) {\n return jointMatrices[int(i)];\n }\n #endif\n mat4 skinMatrix() {\n return\n getBoneMatrix(a_joints.x) * a_weights.x +\n getBoneMatrix(a_joints.y) * a_weights.y +\n getBoneMatrix(a_joints.z) * a_weights.z +\n getBoneMatrix(a_joints.w) * a_weights.w\n ;\n }\n#endif\nstruct StandardVertInput {\n vec2 uv;\n vec4 position;\n vec3 normal;\n vec4 tangent;\n vec4 color;\n};\nin vec3 a_position;\n#if CC_USE_ATTRIBUTE_UV0\nin vec2 a_uv0;\n#endif\n#if CC_USE_ATTRIBUTE_COLOR\nin vec4 a_color;\n#endif\n#if CC_USE_ATTRIBUTE_NORMAL\nin vec3 a_normal;\n#endif\n#if CC_USE_ATTRIBUTE_TANGENT\nin vec4 a_tangent;\n#endif\nvoid CCAttribute (out StandardVertInput In) {\n In.position = vec4(a_position, 1.0);\n #if CC_USE_ATTRIBUTE_UV0\n In.uv = a_uv0;\n #else\n In.uv = vec2(0.0);\n #endif\n #if CC_USE_ATTRIBUTE_COLOR\n In.color = a_color;\n #else\n In.color = vec4(1.0);\n #endif\n #if CC_USE_ATTRIBUTE_NORMAL\n In.normal = a_normal;\n #else\n In.normal = vec3(0.0, 1.0, 0.0);\n #endif\n #if CC_USE_ATTRIBUTE_TANGENT\n In.tangent = a_tangent;\n #else\n In.tangent = vec4(1.0, 0.0, 0.0, 0.0);\n #endif\n}\nvoid CCVertInput(out StandardVertInput In) {\n CCAttribute(In);\n #if CC_USE_SKINNING\n mat4 m = skinMatrix();\n In.position = m * In.position;\n #if CC_USE_ATTRIBUTE_NORMAL\n In.normal = (m * vec4(In.normal, 0)).xyz;\n #endif\n #if CC_USE_ATTRIBUTE_TANGENT\n In.tangent = m * In.tangent;\n #endif\n #endif\n}\nout vec2 v_uv;\nuniform OutlineVert {\n float lineWidth;\n float depthBias;\n};\nvec4 vert () {\n StandardVertInput In;\n CCVertInput(In);\n float width = lineWidth * 0.001;\n #if USE_POSITION_SCALING\n vec3 dir = normalize(In.position.xyz);\n float flip = dot(dir, normalize(In.normal)) < 0.0 ? -1.0 : 1.0;\n In.position.xyz += flip * dir * width * 2.0;\n vec4 pos = cc_matViewProj * cc_matWorld * In.position;\n #else\n In.position.xyz += normalize(In.normal) * width;\n vec4 pos = cc_matViewProj * cc_matWorld * In.position;\n #endif\n pos.z -= depthBias * 0.002;\n v_uv = In.uv;\n return pos;\n}\nvoid main() { gl_Position = vert(); }", + "frag": "\nprecision highp float;\nuniform CCGlobal {\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\n#if CC_USE_SHADOW_MAP && CC_NUM_SHADOW_LIGHTS > 0\n uniform CC_SHADOW {\n mat4 cc_shadow_lightViewProjMatrix[2];\n vec4 cc_shadow_info[2];\n };\n #if CC_NUM_SHADOW_LIGHTS > 0\n uniform sampler2D cc_shadow_map_0;\n #endif\n #if CC_NUM_SHADOW_LIGHTS > 1\n uniform sampler2D cc_shadow_map_1;\n #endif\n varying vec4 v_posLightSpace[2];\n varying float v_depth[2];\n#endif\n#if CC_NUM_LIGHTS > 0\nuniform CCLIGHTS {\n vec4 cc_lightPositionAndRange[4];\n vec4 cc_lightDirection[4];\n vec4 cc_lightColor[4];\n};\n#endif\nstruct LightInfo {\n vec3 lightDir;\n vec3 radiance;\n vec4 lightColor;\n};\nstruct Lighting {\n vec3 diffuse;\n vec3 specular;\n};\nin vec2 v_uv;\nuniform OutlineFrag {\n vec4 outlineBaseColor;\n};\n#if USE_OUTLINE_BASE_COLOR_MAP\n uniform sampler2D outlineBaseColorMap;\n#endif\nvec4 frag () {\n vec4 color = outlineBaseColor;\n #if CC_NUM_DIR_LIGHTS > 0\n for (int i = 0; i < CC_NUM_DIR_LIGHTS; i++) {\n color *= cc_dirLightColor[i];\n }\n #endif\n #if USE_OUTLINE_BASE_COLOR_MAP\n vec4 outlineBaseColorMap_tmp = texture(outlineBaseColorMap, v_uv);\n #if CC_USE_ALPHA_ATLAS_outlineBaseColorMap\n outlineBaseColorMap_tmp.a *= texture(outlineBaseColorMap, v_uv + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n color.rgb *= (outlineBaseColorMap_tmp.rgb * outlineBaseColorMap_tmp.rgb);\n color.a *= outlineBaseColorMap_tmp.a;\n #else\n color *= outlineBaseColorMap_tmp;\n #endif\n #endif\n return vec4(color.rgb, 1.0);\n}\nout vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }" + }, + "glsl1": { + "vert": "\nprecision highp float;\nuniform mat4 cc_matViewProj;\nuniform mat4 cc_matWorld;\n#if CC_USE_SKINNING\n attribute vec4 a_weights;\n attribute vec4 a_joints;\n #if CC_USE_JOINTS_TEXTRUE\n uniform vec2 jointsTextureSize;\n uniform sampler2D jointsTexture;\n #if CC_JOINTS_TEXTURE_FLOAT32\n mat4 getBoneMatrix(const in float i) {\n float width = jointsTextureSize.x;\n float height = jointsTextureSize.y;\n float j = i * 4.0;\n float x = mod(j, width);\n float y = floor(j / width);\n float dx = 1.0 / width;\n float dy = 1.0 / height;\n y = dy * (y + 0.5);\n vec4 v1 = texture2D(jointsTexture, vec2(dx * (x + 0.5), y));\n vec4 v2 = texture2D(jointsTexture, vec2(dx * (x + 1.5), y));\n vec4 v3 = texture2D(jointsTexture, vec2(dx * (x + 2.5), y));\n vec4 v4 = texture2D(jointsTexture, vec2(dx * (x + 3.5), y));\n return mat4(v1, v2, v3, v4);\n }\n #else\n float decode32(vec4 rgba) {\n float Sign = 1.0 - step(128.0, rgba[0]) * 2.0;\n float Exponent = 2.0 * mod(rgba[0], 128.0) + step(128.0, rgba[1]) - 127.0;\n float Mantissa = mod(rgba[1], 128.0) * 65536.0 + rgba[2] * 256.0 + rgba[3] + 8388608.0;\n return Sign * exp2(Exponent - 23.0) * Mantissa;\n }\n vec4 decodevec4 (vec4 x, vec4 y, vec4 z, vec4 w) {\n return vec4(\n decode32(x.wzyx * 255.0),\n decode32(y.wzyx * 255.0),\n decode32(z.wzyx * 255.0),\n decode32(w.wzyx * 255.0)\n );\n }\n vec4 decodevec4 (float dx, float x, float y) {\n return decodevec4(\n texture2D(jointsTexture, vec2(dx * (x + 0.5), y)),\n texture2D(jointsTexture, vec2(dx * (x + 1.5), y)),\n texture2D(jointsTexture, vec2(dx * (x + 2.5), y)),\n texture2D(jointsTexture, vec2(dx * (x + 3.5), y))\n );\n }\n mat4 getBoneMatrix(const in float i) {\n float width = jointsTextureSize.x;\n float height = jointsTextureSize.y;\n float j = i * 16.0;\n float x = mod(j, width);\n float y = floor(j / width);\n float dx = 1.0 / width;\n float dy = 1.0 / height;\n y = dy * (y + 0.5);\n vec4 v1 = decodevec4(dx, x, y);\n vec4 v2 = decodevec4(dx, x+4.0, y);\n vec4 v3 = decodevec4(dx, x+8.0, y);\n vec4 v4 = decodevec4(dx, x+12.0, y);\n return mat4(v1, v2, v3, v4);\n }\n #endif\n #else\n uniform mat4 jointMatrices[50];\n mat4 getBoneMatrix(const in float i) {\n return jointMatrices[int(i)];\n }\n #endif\n mat4 skinMatrix() {\n return\n getBoneMatrix(a_joints.x) * a_weights.x +\n getBoneMatrix(a_joints.y) * a_weights.y +\n getBoneMatrix(a_joints.z) * a_weights.z +\n getBoneMatrix(a_joints.w) * a_weights.w\n ;\n }\n#endif\nstruct StandardVertInput {\n vec2 uv;\n vec4 position;\n vec3 normal;\n vec4 tangent;\n vec4 color;\n};\nattribute vec3 a_position;\n#if CC_USE_ATTRIBUTE_UV0\nattribute vec2 a_uv0;\n#endif\n#if CC_USE_ATTRIBUTE_COLOR\nattribute vec4 a_color;\n#endif\n#if CC_USE_ATTRIBUTE_NORMAL\nattribute vec3 a_normal;\n#endif\n#if CC_USE_ATTRIBUTE_TANGENT\nattribute vec4 a_tangent;\n#endif\nvoid CCAttribute (out StandardVertInput In) {\n In.position = vec4(a_position, 1.0);\n #if CC_USE_ATTRIBUTE_UV0\n In.uv = a_uv0;\n #else\n In.uv = vec2(0.0);\n #endif\n #if CC_USE_ATTRIBUTE_COLOR\n In.color = a_color;\n #else\n In.color = vec4(1.0);\n #endif\n #if CC_USE_ATTRIBUTE_NORMAL\n In.normal = a_normal;\n #else\n In.normal = vec3(0.0, 1.0, 0.0);\n #endif\n #if CC_USE_ATTRIBUTE_TANGENT\n In.tangent = a_tangent;\n #else\n In.tangent = vec4(1.0, 0.0, 0.0, 0.0);\n #endif\n}\nvoid CCVertInput(out StandardVertInput In) {\n CCAttribute(In);\n #if CC_USE_SKINNING\n mat4 m = skinMatrix();\n In.position = m * In.position;\n #if CC_USE_ATTRIBUTE_NORMAL\n In.normal = (m * vec4(In.normal, 0)).xyz;\n #endif\n #if CC_USE_ATTRIBUTE_TANGENT\n In.tangent = m * In.tangent;\n #endif\n #endif\n}\nvarying vec2 v_uv;\nuniform float lineWidth;\nuniform float depthBias;\nvec4 vert () {\n StandardVertInput In;\n CCVertInput(In);\n float width = lineWidth * 0.001;\n #if USE_POSITION_SCALING\n vec3 dir = normalize(In.position.xyz);\n float flip = dot(dir, normalize(In.normal)) < 0.0 ? -1.0 : 1.0;\n In.position.xyz += flip * dir * width * 2.0;\n vec4 pos = cc_matViewProj * cc_matWorld * In.position;\n #else\n In.position.xyz += normalize(In.normal) * width;\n vec4 pos = cc_matViewProj * cc_matWorld * In.position;\n #endif\n pos.z -= depthBias * 0.002;\n v_uv = In.uv;\n return pos;\n}\nvoid main() { gl_Position = vert(); }", + "frag": "\nprecision highp float;\n#if CC_USE_SHADOW_MAP && CC_NUM_SHADOW_LIGHTS > 0\n #if CC_NUM_SHADOW_LIGHTS > 0\n uniform sampler2D cc_shadow_map_0;\n #endif\n #if CC_NUM_SHADOW_LIGHTS > 1\n uniform sampler2D cc_shadow_map_1;\n #endif\n varying vec4 v_posLightSpace[2];\n varying float v_depth[2];\n#endif\n#if CC_NUM_LIGHTS > 0\n#endif\nstruct LightInfo {\n vec3 lightDir;\n vec3 radiance;\n vec4 lightColor;\n};\nstruct Lighting {\n vec3 diffuse;\n vec3 specular;\n};\nvarying vec2 v_uv;\nuniform vec4 outlineBaseColor;\n#if USE_OUTLINE_BASE_COLOR_MAP\n uniform sampler2D outlineBaseColorMap;\n#endif\nvec4 frag () {\n vec4 color = outlineBaseColor;\n #if CC_NUM_DIR_LIGHTS > 0\n for (int i = 0; i < CC_NUM_DIR_LIGHTS; i++) {\n color *= cc_dirLightColor[i];\n }\n #endif\n #if USE_OUTLINE_BASE_COLOR_MAP\n vec4 outlineBaseColorMap_tmp = texture2D(outlineBaseColorMap, v_uv);\n #if CC_USE_ALPHA_ATLAS_outlineBaseColorMap\n outlineBaseColorMap_tmp.a *= texture2D(outlineBaseColorMap, v_uv + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n color.rgb *= (outlineBaseColorMap_tmp.rgb * outlineBaseColorMap_tmp.rgb);\n color.a *= outlineBaseColorMap_tmp.a;\n #else\n color *= outlineBaseColorMap_tmp;\n #endif\n #endif\n return vec4(color.rgb, 1.0);\n}\nvoid main() { gl_FragColor = frag(); }" + }, + "builtins": { + "globals": { + "blocks": [ + { + "name": "CCGlobal", + "defines": [] + }, + { + "name": "CC_SHADOW", + "defines": [ + "CC_USE_SHADOW_MAP", + "CC_NUM_SHADOW_LIGHTS" + ] + }, + { + "name": "CCLIGHTS", + "defines": [ + "CC_NUM_LIGHTS" + ] + } + ], + "samplers": [ + { + "name": "cc_shadow_map_0", + "defines": [ + "CC_USE_SHADOW_MAP", + "CC_NUM_SHADOW_LIGHTS" + ] + }, + { + "name": "cc_shadow_map_1", + "defines": [ + "CC_USE_SHADOW_MAP", + "CC_NUM_SHADOW_LIGHTS" + ] + } + ] + }, + "locals": { + "blocks": [ + { + "name": "CCLocal", + "defines": [] + } + ], + "samplers": [] + } + }, + "defines": [ + { + "name": "CC_USE_SKINNING", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_JOINTS_TEXTRUE", + "type": "boolean", + "defines": [ + "CC_USE_SKINNING" + ] + }, + { + "name": "CC_JOINTS_TEXTURE_FLOAT32", + "type": "boolean", + "defines": [ + "CC_USE_SKINNING", + "CC_USE_JOINTS_TEXTRUE" + ] + }, + { + "name": "CC_USE_ATTRIBUTE_UV0", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_ATTRIBUTE_COLOR", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_ATTRIBUTE_NORMAL", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_ATTRIBUTE_TANGENT", + "type": "boolean", + "defines": [] + }, + { + "name": "USE_POSITION_SCALING", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_SHADOW_MAP", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_NUM_SHADOW_LIGHTS", + "type": "number", + "defines": [ + "CC_USE_SHADOW_MAP" + ], + "range": [ + 0, + 3 + ] + }, + { + "name": "CC_NUM_LIGHTS", + "type": "number", + "defines": [], + "range": [ + 0, + 3 + ] + }, + { + "name": "USE_OUTLINE_BASE_COLOR_MAP", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_NUM_DIR_LIGHTS", + "type": "number", + "defines": [], + "range": [ + 0, + 3 + ] + }, + { + "name": "CC_USE_ALPHA_ATLAS_outlineBaseColorMap", + "type": "boolean", + "defines": [ + "USE_OUTLINE_BASE_COLOR_MAP" + ] + }, + { + "name": "INPUT_IS_GAMMA", + "type": "boolean", + "defines": [ + "USE_OUTLINE_BASE_COLOR_MAP" + ] + } + ], + "blocks": [ + { + "name": "SKINNING", + "members": [ + { + "name": "jointsTextureSize", + "type": 14, + "count": 1 + } + ], + "defines": [ + "CC_USE_SKINNING", + "CC_USE_JOINTS_TEXTRUE" + ], + "binding": 0 + }, + { + "name": "JOINT_MATRIX", + "members": [ + { + "name": "jointMatrices", + "type": 26, + "count": 50 + } + ], + "defines": [ + "CC_USE_SKINNING" + ], + "binding": 1 + }, + { + "name": "OutlineVert", + "members": [ + { + "name": "lineWidth", + "type": 13, + "count": 1 + }, + { + "name": "depthBias", + "type": 13, + "count": 1 + } + ], + "defines": [], + "binding": 2 + }, + { + "name": "OutlineFrag", + "members": [ + { + "name": "outlineBaseColor", + "type": 16, + "count": 1 + } + ], + "defines": [], + "binding": 3 + } + ], + "samplers": [ + { + "name": "jointsTexture", + "type": 29, + "count": 1, + "defines": [ + "CC_USE_SKINNING", + "CC_USE_JOINTS_TEXTRUE" + ], + "binding": 30 + }, + { + "name": "outlineBaseColorMap", + "type": 29, + "count": 1, + "defines": [ + "USE_OUTLINE_BASE_COLOR_MAP" + ], + "binding": 31 + } + ], + "record": null, + "name": "builtin-toon|outline-vs:vert|outline-fs:frag" + }, + { + "hash": 1621866752, + "glsl3": { + "vert": "\nprecision highp float;\nuniform CCGlobal {\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\nuniform CCLocal {\n mat4 cc_matWorld;\n mat4 cc_matWorldIT;\n};\n#if CC_USE_SKINNING\n in vec4 a_weights;\n in vec4 a_joints;\n #if CC_USE_JOINTS_TEXTRUE\n uniform SKINNING {\n vec2 jointsTextureSize;\n };\n uniform sampler2D jointsTexture;\n #if CC_JOINTS_TEXTURE_FLOAT32\n mat4 getBoneMatrix(const in float i) {\n float width = jointsTextureSize.x;\n float height = jointsTextureSize.y;\n float j = i * 4.0;\n float x = mod(j, width);\n float y = floor(j / width);\n float dx = 1.0 / width;\n float dy = 1.0 / height;\n y = dy * (y + 0.5);\n vec4 v1 = texture(jointsTexture, vec2(dx * (x + 0.5), y));\n vec4 v2 = texture(jointsTexture, vec2(dx * (x + 1.5), y));\n vec4 v3 = texture(jointsTexture, vec2(dx * (x + 2.5), y));\n vec4 v4 = texture(jointsTexture, vec2(dx * (x + 3.5), y));\n return mat4(v1, v2, v3, v4);\n }\n #else\n float decode32(vec4 rgba) {\n float Sign = 1.0 - step(128.0, rgba[0]) * 2.0;\n float Exponent = 2.0 * mod(rgba[0], 128.0) + step(128.0, rgba[1]) - 127.0;\n float Mantissa = mod(rgba[1], 128.0) * 65536.0 + rgba[2] * 256.0 + rgba[3] + 8388608.0;\n return Sign * exp2(Exponent - 23.0) * Mantissa;\n }\n vec4 decodevec4 (vec4 x, vec4 y, vec4 z, vec4 w) {\n return vec4(\n decode32(x.wzyx * 255.0),\n decode32(y.wzyx * 255.0),\n decode32(z.wzyx * 255.0),\n decode32(w.wzyx * 255.0)\n );\n }\n vec4 decodevec4 (float dx, float x, float y) {\n return decodevec4(\n texture(jointsTexture, vec2(dx * (x + 0.5), y)),\n texture(jointsTexture, vec2(dx * (x + 1.5), y)),\n texture(jointsTexture, vec2(dx * (x + 2.5), y)),\n texture(jointsTexture, vec2(dx * (x + 3.5), y))\n );\n }\n mat4 getBoneMatrix(const in float i) {\n float width = jointsTextureSize.x;\n float height = jointsTextureSize.y;\n float j = i * 16.0;\n float x = mod(j, width);\n float y = floor(j / width);\n float dx = 1.0 / width;\n float dy = 1.0 / height;\n y = dy * (y + 0.5);\n vec4 v1 = decodevec4(dx, x, y);\n vec4 v2 = decodevec4(dx, x+4.0, y);\n vec4 v3 = decodevec4(dx, x+8.0, y);\n vec4 v4 = decodevec4(dx, x+12.0, y);\n return mat4(v1, v2, v3, v4);\n }\n #endif\n #else\n uniform JOINT_MATRIX {\n mat4 jointMatrices[50];\n };\n mat4 getBoneMatrix(const in float i) {\n return jointMatrices[int(i)];\n }\n #endif\n mat4 skinMatrix() {\n return\n getBoneMatrix(a_joints.x) * a_weights.x +\n getBoneMatrix(a_joints.y) * a_weights.y +\n getBoneMatrix(a_joints.z) * a_weights.z +\n getBoneMatrix(a_joints.w) * a_weights.w\n ;\n }\n#endif\nstruct StandardVertInput {\n vec2 uv;\n vec4 position;\n vec3 normal;\n vec4 tangent;\n vec4 color;\n};\nin vec3 a_position;\n#if CC_USE_ATTRIBUTE_UV0\nin vec2 a_uv0;\n#endif\n#if CC_USE_ATTRIBUTE_COLOR\nin vec4 a_color;\n#endif\n#if CC_USE_ATTRIBUTE_NORMAL\nin vec3 a_normal;\n#endif\n#if CC_USE_ATTRIBUTE_TANGENT\nin vec4 a_tangent;\n#endif\nvoid CCAttribute (out StandardVertInput In) {\n In.position = vec4(a_position, 1.0);\n #if CC_USE_ATTRIBUTE_UV0\n In.uv = a_uv0;\n #else\n In.uv = vec2(0.0);\n #endif\n #if CC_USE_ATTRIBUTE_COLOR\n In.color = a_color;\n #else\n In.color = vec4(1.0);\n #endif\n #if CC_USE_ATTRIBUTE_NORMAL\n In.normal = a_normal;\n #else\n In.normal = vec3(0.0, 1.0, 0.0);\n #endif\n #if CC_USE_ATTRIBUTE_TANGENT\n In.tangent = a_tangent;\n #else\n In.tangent = vec4(1.0, 0.0, 0.0, 0.0);\n #endif\n}\nvoid CCVertInput(out StandardVertInput In) {\n CCAttribute(In);\n #if CC_USE_SKINNING\n mat4 m = skinMatrix();\n In.position = m * In.position;\n #if CC_USE_ATTRIBUTE_NORMAL\n In.normal = (m * vec4(In.normal, 0)).xyz;\n #endif\n #if CC_USE_ATTRIBUTE_TANGENT\n In.tangent = m * In.tangent;\n #endif\n #endif\n}\nout vec3 v_position;\nout vec2 v_uv;\nout vec3 v_normal;\nout vec3 v_viewDirection;\n#if USE_NORMAL_MAP\n out vec3 v_tangent;\n out vec3 v_bitangent;\n#endif\nuniform ToonVert {\n vec4 tilingOffset;\n};\nvec4 vert () {\n StandardVertInput In;\n CCVertInput(In);\n vec4 pos = cc_matWorld * In.position;\n v_position = pos.xyz;\n v_uv = In.uv * tilingOffset.xy + tilingOffset.zw;\n v_viewDirection = normalize(cc_cameraPos.xyz - v_position);\n v_normal = (cc_matWorldIT * vec4(In.normal, 0.0)).xyz;\n #if USE_NORMAL_MAP\n v_tangent = normalize((cc_matWorldIT * vec4(In.tangent.xyz, 0.0)).xyz);\n v_bitangent = cross(v_normal, v_tangent) * In.tangent.w;\n #endif\n return cc_matViewProj * pos;\n}\nvoid main() { gl_Position = vert(); }", + "frag": "\nprecision highp float;\nuniform CCGlobal {\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\n#if CC_USE_SHADOW_MAP && CC_NUM_SHADOW_LIGHTS > 0\n uniform CC_SHADOW {\n mat4 cc_shadow_lightViewProjMatrix[2];\n vec4 cc_shadow_info[2];\n };\n #if CC_NUM_SHADOW_LIGHTS > 0\n uniform sampler2D cc_shadow_map_0;\n #endif\n #if CC_NUM_SHADOW_LIGHTS > 1\n uniform sampler2D cc_shadow_map_1;\n #endif\n varying vec4 v_posLightSpace[2];\n varying float v_depth[2];\n#endif\nfloat unpackRGBAToDepth(vec4 color) {\n return dot(color, vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n}\nfloat getDepth(sampler2D shadowMap, vec2 shadowUV) {\n return unpackRGBAToDepth(texture(shadowMap, shadowUV));\n}\nfloat computeFallOff(float shadow, vec2 coords, float frustumEdgeFalloff) {\n return shadow;\n}\nfloat shadowSimple(sampler2D shadowMap, vec2 shadowUV, float currentDepth, float darkness) {\n float closestDepth = getDepth(shadowMap, shadowUV);\n return currentDepth > closestDepth ? 1.0 - darkness : 1.0;\n}\nfloat shadowPCF3X3(sampler2D shadowMap, vec2 shadowUV, float currentDepth, float darkness, float shadowSize) {\n float shadow = 0.0;\n for (int x = -1; x <= 1; ++x) {\n for (int y = -1; y <= 1; ++y) {\n float closestDepth = getDepth(shadowMap, shadowUV + vec2(x, y) * 1.0/shadowSize);\n shadow += currentDepth > closestDepth ? 1.0 - darkness : 1.0;\n }\n }\n shadow /= 9.0;\n return shadow;\n}\nfloat shadowPCF5X5(sampler2D shadowMap, vec2 shadowUV, float currentDepth, float darkness, float shadowSize) {\n float shadow = 0.0;\n for (int x = -2; x <= 2; ++x) {\n for (int y = -2; y <= 2; ++y) {\n float closestDepth = getDepth(shadowMap, shadowUV + vec2(x, y) * 1.0/shadowSize);\n shadow += currentDepth > closestDepth ? 1.0 - darkness : 1.0;\n }\n }\n shadow /= 25.0;\n return shadow;\n}\n#if CC_NUM_LIGHTS > 0\nuniform CCLIGHTS {\n vec4 cc_lightPositionAndRange[4];\n vec4 cc_lightDirection[4];\n vec4 cc_lightColor[4];\n};\n#endif\nstruct LightInfo {\n vec3 lightDir;\n vec3 radiance;\n vec4 lightColor;\n};\nLightInfo computeDirectionalLighting(\n vec4 lightDirection,\n vec4 lightColor\n) {\n LightInfo ret;\n ret.lightDir = -normalize(lightDirection.xyz);\n ret.radiance = lightColor.rgb;\n ret.lightColor = lightColor;\n return ret;\n}\nLightInfo computePointLighting(\n vec3 worldPosition,\n vec4 lightPositionAndRange,\n vec4 lightColor\n) {\n LightInfo ret;\n vec3 lightDir = lightPositionAndRange.xyz - worldPosition;\n float attenuation = max(0., 1.0 - length(lightDir) / lightPositionAndRange.w);\n ret.lightDir = normalize(lightDir);\n ret.radiance = lightColor.rgb * attenuation;\n ret.lightColor = lightColor;\n return ret;\n}\nLightInfo computeSpotLighting(\n vec3 worldPosition,\n vec4 lightPositionAndRange,\n vec4 lightDirection,\n vec4 lightColor\n) {\n LightInfo ret;\n vec3 lightDir = lightPositionAndRange.xyz - worldPosition;\n float attenuation = max(0., 1.0 - length(lightDir) / lightPositionAndRange.w);\n lightDir = normalize(lightDir);\n float cosConeAngle = max(0., dot(lightDirection.xyz, -lightDir));\n cosConeAngle = cosConeAngle < lightDirection.w ? 0. : cosConeAngle;\n cosConeAngle = pow(cosConeAngle, lightColor.w);\n ret.lightDir = lightDir;\n ret.radiance = lightColor.rgb * attenuation * cosConeAngle;\n ret.lightColor = lightColor;\n return ret;\n}\nstruct Lighting {\n vec3 diffuse;\n vec3 specular;\n};\nstruct ToonSurface {\n vec4 baseColor;\n vec3 specular;\n float specularThreshold;\n vec3 position;\n vec3 normal;\n vec3 viewDirection;\n vec3 emissive;\n vec3 shadowColor;\n float shadowIntensity;\n vec3 highlightColor;\n float lightThreshold;\n float lightSmoothness;\n};\nconst float T_H = 0.25;\nfloat TreshHoldLighting(float lThreshold, float smoothness, float v) {\n return smoothstep(lThreshold-smoothness*T_H, lThreshold+smoothness*T_H, v);\n}\nLighting toon (ToonSurface s, LightInfo info) {\n Lighting result;\n vec3 N = s.normal;\n vec3 L = info.lightDir;\n vec3 V = s.viewDirection;\n vec3 H = normalize(L + V);\n float NL = 0.5 * dot(N, L) + 0.5;\n float NH = 0.5 * dot(H, N) + 0.5;\n vec3 c = vec3(0.0);\n vec3 attenuation = info.radiance;\n vec3 lightColor = info.lightColor.rgb;\n vec3 shadowColor = mix(s.highlightColor * lightColor, s.shadowColor, s.shadowIntensity);\n vec3 diffuse = TreshHoldLighting(s.lightThreshold, s.lightSmoothness, NL) * attenuation;\n diffuse = mix(shadowColor, s.highlightColor * lightColor, diffuse);\n result.diffuse = diffuse * s.baseColor.rgb;\n float specularWeight = 1.0 - pow(s.specularThreshold, 5.0);\n float specularMask = step(specularWeight, NH);\n vec3 specular = s.specular.rgb * specularMask;\n result.specular = specular * attenuation;\n return result;\n}\nvec3 ambient(ToonSurface s, vec4 ambientColor) {\n return s.baseColor.rgb * ambientColor.rgb;\n}\nvec4 CCToonShading (ToonSurface s) {\n Lighting result;\n result.diffuse = vec3(0, 0, 0);\n result.specular = vec3(0, 0, 0);\n #if CC_NUM_LIGHTS > 0\n #if CC_LIGHT_0_TYPE == 3\n result.diffuse += ambient(s, cc_lightColor[0]);\n #else\n LightInfo info0;\n #if CC_LIGHT_0_TYPE == 0\n info0 = computeDirectionalLighting(cc_lightDirection[0], cc_lightColor[0]);\n #elif CC_LIGHT_0_TYPE == 1\n info0 = computePointLighting(s.position, cc_lightPositionAndRange[0], cc_lightColor[0]);\n #elif CC_LIGHT_0_TYPE == 2\n info0 = computeSpotLighting(s.position, cc_lightPositionAndRange[0], cc_lightDirection[0], cc_lightColor[0]);\n #endif\n Lighting result0 = toon(s, info0);\n #if CC_USE_SHADOW_MAP && CC_NUM_SHADOW_LIGHTS > 0\n float shadow_0 = 1.0;\n vec2 projCoords0 = v_posLightSpace[0].xy / v_posLightSpace[0].w;\n vec2 shadowUV0 = projCoords0 * 0.5 + vec2(0.5);\n if (shadowUV0.x >= 0.0 && shadowUV0.x <= 1.0 && shadowUV0.y >= 0.0 && shadowUV0.y <= 1.0) {\n float currentDepth0 = clamp(v_depth[0], 0.0, 1.0);\n #if CC_SHADOW_0_TYPE == 3\n shadow_0 = shadowPCF3X3(cc_shadow_map_0, shadowUV0, currentDepth0, cc_shadow_info[0].w, cc_shadow_info[0].z);\n #elif CC_SHADOW_0_TYPE == 4\n shadow_0 = shadowPCF5X5(cc_shadow_map_0, shadowUV0, currentDepth0, cc_shadow_info[0].w, cc_shadow_info[0].z);\n #else\n shadow_0 = shadowSimple(cc_shadow_map_0, shadowUV0, currentDepth0, cc_shadow_info[0].w);\n #endif\n shadow_0 = computeFallOff(shadow_0, projCoords0, 0.0);\n }\n result0.diffuse *= shadow_0;\n result0.specular *= shadow_0;\n #endif\n result.diffuse += result0.diffuse;\n result.specular += result0.specular;\n #endif\n #endif\n #if CC_NUM_LIGHTS > 1\n #if CC_LIGHT_1_TYPE == 3\n result.diffuse += ambient(s, cc_lightColor[1]);\n #else\n LightInfo info1;\n #if CC_LIGHT_1_TYPE == 0\n info1 = computeDirectionalLighting(cc_lightDirection[1], cc_lightColor[1]);\n #elif CC_LIGHT_1_TYPE == 1\n info1 = computePointLighting(s.position, cc_lightPositionAndRange[1], cc_lightColor[1]);\n #elif CC_LIGHT_1_TYPE == 2\n info1 = computeSpotLighting(s.position, cc_lightPositionAndRange[1], cc_lightDirection[1], cc_lightColor[1]);\n #endif\n Lighting result1 = toon(s, info1);\n #if CC_USE_SHADOW_MAP && CC_NUM_SHADOW_LIGHTS > 1\n float shadow_1 = 1.0;\n vec2 projCoords1 = v_posLightSpace[1].xy / v_posLightSpace[1].w;\n vec2 shadowUV1 = projCoords1 * 0.5 + vec2(0.5);\n if (shadowUV1.x >= 0.0 && shadowUV1.x <= 1.0 && shadowUV1.y >= 0.0 && shadowUV1.y <= 1.0) {\n float currentDepth1 = clamp(v_depth[1], 0.0, 1.0);\n #if CC_SHADOW_1_TYPE == 3\n shadow_1 = shadowPCF3X3(cc_shadow_map_1, shadowUV1, currentDepth1, cc_shadow_info[1].w, cc_shadow_info[1].z);\n #elif CC_SHADOW_1_TYPE == 4\n shadow_1 = shadowPCF5X5(cc_shadow_map_1, shadowUV1, currentDepth1, cc_shadow_info[1].w, cc_shadow_info[1].z);\n #else\n shadow_1 = shadowSimple(cc_shadow_map_1, shadowUV1, currentDepth1, cc_shadow_info[1].w);\n #endif\n shadow_1 = computeFallOff(shadow_1, projCoords1, 0.0);\n }\n result1.diffuse *= shadow_1;\n result1.specular *= shadow_1;\n #endif\n result.diffuse += result1.diffuse;\n result.specular += result1.specular;\n #endif\n #endif\n #if CC_NUM_LIGHTS > 2\n #if CC_LIGHT_2_TYPE == 3\n result.diffuse += ambient(s, cc_lightColor[2]);\n #else\n LightInfo info2;\n #if CC_LIGHT_2_TYPE == 0\n info2 = computeDirectionalLighting(cc_lightDirection[2], cc_lightColor[2]);\n #elif CC_LIGHT_2_TYPE == 1\n info2 = computePointLighting(s.position, cc_lightPositionAndRange[2], cc_lightColor[2]);\n #elif CC_LIGHT_2_TYPE == 2\n info2 = computeSpotLighting(s.position, cc_lightPositionAndRange[2], cc_lightDirection[2], cc_lightColor[2]);\n #endif\n Lighting result2 = toon(s, info2);\n #if CC_USE_SHADOW_MAP && CC_NUM_SHADOW_LIGHTS > 2\n float shadow_2 = 1.0;\n vec2 projCoords2 = v_posLightSpace[2].xy / v_posLightSpace[2].w;\n vec2 shadowUV2 = projCoords2 * 0.5 + vec2(0.5);\n if (shadowUV2.x >= 0.0 && shadowUV2.x <= 1.0 && shadowUV2.y >= 0.0 && shadowUV2.y <= 1.0) {\n float currentDepth2 = clamp(v_depth[2], 0.0, 1.0);\n #if CC_SHADOW_2_TYPE == 3\n shadow_2 = shadowPCF3X3(cc_shadow_map_2, shadowUV2, currentDepth2, cc_shadow_info[2].w, cc_shadow_info[2].z);\n #elif CC_SHADOW_2_TYPE == 4\n shadow_2 = shadowPCF5X5(cc_shadow_map_2, shadowUV2, currentDepth2, cc_shadow_info[2].w, cc_shadow_info[2].z);\n #else\n shadow_2 = shadowSimple(cc_shadow_map_2, shadowUV2, currentDepth2, cc_shadow_info[2].w);\n #endif\n shadow_2 = computeFallOff(shadow_2, projCoords2, 0.0);\n }\n result2.diffuse *= shadow_2;\n result2.specular *= shadow_2;\n #endif\n result.diffuse += result2.diffuse;\n result.specular += result2.specular;\n #endif\n #endif\n #if CC_NUM_LIGHTS > 3\n #if CC_LIGHT_3_TYPE == 3\n result.diffuse += ambient(s, cc_lightColor[3]);\n #else\n LightInfo info3;\n #if CC_LIGHT_3_TYPE == 0\n info3 = computeDirectionalLighting(cc_lightDirection[3], cc_lightColor[3]);\n #elif CC_LIGHT_3_TYPE == 1\n info3 = computePointLighting(s.position, cc_lightPositionAndRange[3], cc_lightColor[3]);\n #elif CC_LIGHT_3_TYPE == 2\n info3 = computeSpotLighting(s.position, cc_lightPositionAndRange[3], cc_lightDirection[3], cc_lightColor[3]);\n #endif\n Lighting result3 = toon(s, info3);\n #if CC_USE_SHADOW_MAP && CC_NUM_SHADOW_LIGHTS > 3\n float shadow_3 = 1.0;\n vec2 projCoords3 = v_posLightSpace[3].xy / v_posLightSpace[3].w;\n vec2 shadowUV3 = projCoords3 * 0.5 + vec2(0.5);\n if (shadowUV3.x >= 0.0 && shadowUV3.x <= 1.0 && shadowUV3.y >= 0.0 && shadowUV3.y <= 1.0) {\n float currentDepth3 = clamp(v_depth[3], 0.0, 1.0);\n #if CC_SHADOW_3_TYPE == 3\n shadow_3 = shadowPCF3X3(cc_shadow_map_3, shadowUV3, currentDepth3, cc_shadow_info[3].w, cc_shadow_info[3].z);\n #elif CC_SHADOW_3_TYPE == 4\n shadow_3 = shadowPCF5X5(cc_shadow_map_3, shadowUV3, currentDepth3, cc_shadow_info[3].w, cc_shadow_info[3].z);\n #else\n shadow_3 = shadowSimple(cc_shadow_map_3, shadowUV3, currentDepth3, cc_shadow_info[3].w);\n #endif\n shadow_3 = computeFallOff(shadow_3, projCoords3, 0.0);\n }\n result3.diffuse *= shadow_3;\n result3.specular *= shadow_3;\n #endif\n result.diffuse += result3.diffuse;\n result.specular += result3.specular;\n #endif\n #endif\n vec3 finalColor = result.diffuse + result.specular + s.emissive;\n return vec4(finalColor, s.baseColor.a);\n}\nvec4 CCFragOutput (vec4 color) {\n #if OUTPUT_TO_GAMMA\n color.rgb = sqrt(color.rgb);\n #endif\n\treturn color;\n}\nin vec3 v_position;\nin vec2 v_uv;\nin vec3 v_viewDirection;\nin vec3 v_normal;\n#if USE_NORMAL_MAP\n in vec3 v_tangent;\n in vec3 v_bitangent;\n uniform sampler2D normalMap;\n#endif\n#if USE_BASE_COLOR_MAP\n uniform sampler2D baseColorMap;\n#endif\n#if USE_SPECULAR_MAP\n uniform sampler2D specularMap;\n#endif\n#if USE_EMISSIVE_MAP\n uniform sampler2D emissiveMap;\n#endif\nuniform ToonFrag {\n vec4 colorScale;\n vec4 specular;\n vec4 emissive;\n vec4 shadowColor;\n vec4 highlightColor;\n float specularThreshold;\n float shadowIntensity;\n float lightThreshold;\n float lightSmoothness;\n};\nvoid surf (out ToonSurface s) {\n #if USE_BASE_COLOR_MAP\n s.baseColor = vec4(1.);\n vec4 baseColorMap_tmp = texture(baseColorMap, v_uv);\n #if CC_USE_ALPHA_ATLAS_baseColorMap\n baseColorMap_tmp.a *= texture(baseColorMap, v_uv + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n s.baseColor.rgb *= (baseColorMap_tmp.rgb * baseColorMap_tmp.rgb);\n s.baseColor.a *= baseColorMap_tmp.a;\n #else\n s.baseColor *= baseColorMap_tmp;\n #endif\n #else\n s.baseColor = highlightColor;\n #endif\n s.normal = normalize(v_normal);\n #if USE_NORMAL_MAP\n vec3 nmmp = texture2D(normalMap, v_uv).xyz - vec3(0.5);\n s.normal = normalize(\n nmmp.x * normalize(v_tangent) +\n nmmp.y * normalize(v_bitangent) +\n nmmp.z * s.normal);\n #endif\n s.position = v_position;\n s.specular = specular.rgb * specular.a;\n #if USE_SPECULAR_MAP\n vec4 specularMap_tmp = texture(specularMap, v_uv);\n #if CC_USE_ALPHA_ATLAS_specularMap\n specularMap_tmp.a *= texture(specularMap, v_uv + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n s.specular.rgb *= (specularMap_tmp.rgb * specularMap_tmp.rgb);\n #else\n s.specular.rgb *= specularMap_tmp.rgb;\n #endif\n #endif\n s.emissive = emissive.rgb;\n #if USE_EMISSIVE_MAP\n vec4 emissiveMap_tmp = texture(emissiveMap, v_uv);\n #if CC_USE_ALPHA_ATLAS_emissiveMap\n emissiveMap_tmp.a *= texture(emissiveMap, v_uv + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n s.emissive.rgb *= (emissiveMap_tmp.rgb * emissiveMap_tmp.rgb);\n #else\n s.emissive.rgb *= emissiveMap_tmp.rgb;\n #endif\n #endif\n s.lightThreshold = lightThreshold;\n s.lightSmoothness = lightSmoothness;\n s.shadowColor = shadowColor.rgb;\n s.highlightColor = highlightColor.rgb;\n s.shadowIntensity = shadowIntensity;\n s.specularThreshold = specularThreshold;\n s.viewDirection = v_viewDirection;\n}\nvec4 frag () {\n ToonSurface s;\n surf(s);\n vec4 color = CCToonShading(s);\n return CCFragOutput(color);\n}\nout vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }" + }, + "glsl1": { + "vert": "\nprecision highp float;\nuniform mat4 cc_matViewProj;\nuniform vec4 cc_cameraPos;\nuniform mat4 cc_matWorld;\nuniform mat4 cc_matWorldIT;\n#if CC_USE_SKINNING\n attribute vec4 a_weights;\n attribute vec4 a_joints;\n #if CC_USE_JOINTS_TEXTRUE\n uniform vec2 jointsTextureSize;\n uniform sampler2D jointsTexture;\n #if CC_JOINTS_TEXTURE_FLOAT32\n mat4 getBoneMatrix(const in float i) {\n float width = jointsTextureSize.x;\n float height = jointsTextureSize.y;\n float j = i * 4.0;\n float x = mod(j, width);\n float y = floor(j / width);\n float dx = 1.0 / width;\n float dy = 1.0 / height;\n y = dy * (y + 0.5);\n vec4 v1 = texture2D(jointsTexture, vec2(dx * (x + 0.5), y));\n vec4 v2 = texture2D(jointsTexture, vec2(dx * (x + 1.5), y));\n vec4 v3 = texture2D(jointsTexture, vec2(dx * (x + 2.5), y));\n vec4 v4 = texture2D(jointsTexture, vec2(dx * (x + 3.5), y));\n return mat4(v1, v2, v3, v4);\n }\n #else\n float decode32(vec4 rgba) {\n float Sign = 1.0 - step(128.0, rgba[0]) * 2.0;\n float Exponent = 2.0 * mod(rgba[0], 128.0) + step(128.0, rgba[1]) - 127.0;\n float Mantissa = mod(rgba[1], 128.0) * 65536.0 + rgba[2] * 256.0 + rgba[3] + 8388608.0;\n return Sign * exp2(Exponent - 23.0) * Mantissa;\n }\n vec4 decodevec4 (vec4 x, vec4 y, vec4 z, vec4 w) {\n return vec4(\n decode32(x.wzyx * 255.0),\n decode32(y.wzyx * 255.0),\n decode32(z.wzyx * 255.0),\n decode32(w.wzyx * 255.0)\n );\n }\n vec4 decodevec4 (float dx, float x, float y) {\n return decodevec4(\n texture2D(jointsTexture, vec2(dx * (x + 0.5), y)),\n texture2D(jointsTexture, vec2(dx * (x + 1.5), y)),\n texture2D(jointsTexture, vec2(dx * (x + 2.5), y)),\n texture2D(jointsTexture, vec2(dx * (x + 3.5), y))\n );\n }\n mat4 getBoneMatrix(const in float i) {\n float width = jointsTextureSize.x;\n float height = jointsTextureSize.y;\n float j = i * 16.0;\n float x = mod(j, width);\n float y = floor(j / width);\n float dx = 1.0 / width;\n float dy = 1.0 / height;\n y = dy * (y + 0.5);\n vec4 v1 = decodevec4(dx, x, y);\n vec4 v2 = decodevec4(dx, x+4.0, y);\n vec4 v3 = decodevec4(dx, x+8.0, y);\n vec4 v4 = decodevec4(dx, x+12.0, y);\n return mat4(v1, v2, v3, v4);\n }\n #endif\n #else\n uniform mat4 jointMatrices[50];\n mat4 getBoneMatrix(const in float i) {\n return jointMatrices[int(i)];\n }\n #endif\n mat4 skinMatrix() {\n return\n getBoneMatrix(a_joints.x) * a_weights.x +\n getBoneMatrix(a_joints.y) * a_weights.y +\n getBoneMatrix(a_joints.z) * a_weights.z +\n getBoneMatrix(a_joints.w) * a_weights.w\n ;\n }\n#endif\nstruct StandardVertInput {\n vec2 uv;\n vec4 position;\n vec3 normal;\n vec4 tangent;\n vec4 color;\n};\nattribute vec3 a_position;\n#if CC_USE_ATTRIBUTE_UV0\nattribute vec2 a_uv0;\n#endif\n#if CC_USE_ATTRIBUTE_COLOR\nattribute vec4 a_color;\n#endif\n#if CC_USE_ATTRIBUTE_NORMAL\nattribute vec3 a_normal;\n#endif\n#if CC_USE_ATTRIBUTE_TANGENT\nattribute vec4 a_tangent;\n#endif\nvoid CCAttribute (out StandardVertInput In) {\n In.position = vec4(a_position, 1.0);\n #if CC_USE_ATTRIBUTE_UV0\n In.uv = a_uv0;\n #else\n In.uv = vec2(0.0);\n #endif\n #if CC_USE_ATTRIBUTE_COLOR\n In.color = a_color;\n #else\n In.color = vec4(1.0);\n #endif\n #if CC_USE_ATTRIBUTE_NORMAL\n In.normal = a_normal;\n #else\n In.normal = vec3(0.0, 1.0, 0.0);\n #endif\n #if CC_USE_ATTRIBUTE_TANGENT\n In.tangent = a_tangent;\n #else\n In.tangent = vec4(1.0, 0.0, 0.0, 0.0);\n #endif\n}\nvoid CCVertInput(out StandardVertInput In) {\n CCAttribute(In);\n #if CC_USE_SKINNING\n mat4 m = skinMatrix();\n In.position = m * In.position;\n #if CC_USE_ATTRIBUTE_NORMAL\n In.normal = (m * vec4(In.normal, 0)).xyz;\n #endif\n #if CC_USE_ATTRIBUTE_TANGENT\n In.tangent = m * In.tangent;\n #endif\n #endif\n}\nvarying vec3 v_position;\nvarying vec2 v_uv;\nvarying vec3 v_normal;\nvarying vec3 v_viewDirection;\n#if USE_NORMAL_MAP\n varying vec3 v_tangent;\n varying vec3 v_bitangent;\n#endif\nuniform vec4 tilingOffset;\nvec4 vert () {\n StandardVertInput In;\n CCVertInput(In);\n vec4 pos = cc_matWorld * In.position;\n v_position = pos.xyz;\n v_uv = In.uv * tilingOffset.xy + tilingOffset.zw;\n v_viewDirection = normalize(cc_cameraPos.xyz - v_position);\n v_normal = (cc_matWorldIT * vec4(In.normal, 0.0)).xyz;\n #if USE_NORMAL_MAP\n v_tangent = normalize((cc_matWorldIT * vec4(In.tangent.xyz, 0.0)).xyz);\n v_bitangent = cross(v_normal, v_tangent) * In.tangent.w;\n #endif\n return cc_matViewProj * pos;\n}\nvoid main() { gl_Position = vert(); }", + "frag": "\nprecision highp float;\n#if CC_USE_SHADOW_MAP && CC_NUM_SHADOW_LIGHTS > 0\n uniform vec4 cc_shadow_info[2];\n #if CC_NUM_SHADOW_LIGHTS > 0\n uniform sampler2D cc_shadow_map_0;\n #endif\n #if CC_NUM_SHADOW_LIGHTS > 1\n uniform sampler2D cc_shadow_map_1;\n #endif\n varying vec4 v_posLightSpace[2];\n varying float v_depth[2];\n#endif\nfloat unpackRGBAToDepth(vec4 color) {\n return dot(color, vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n}\nfloat getDepth(sampler2D shadowMap, vec2 shadowUV) {\n return unpackRGBAToDepth(texture2D(shadowMap, shadowUV));\n}\nfloat computeFallOff(float shadow, vec2 coords, float frustumEdgeFalloff) {\n return shadow;\n}\nfloat shadowSimple(sampler2D shadowMap, vec2 shadowUV, float currentDepth, float darkness) {\n float closestDepth = getDepth(shadowMap, shadowUV);\n return currentDepth > closestDepth ? 1.0 - darkness : 1.0;\n}\nfloat shadowPCF3X3(sampler2D shadowMap, vec2 shadowUV, float currentDepth, float darkness, float shadowSize) {\n float shadow = 0.0;\n for (int x = -1; x <= 1; ++x) {\n for (int y = -1; y <= 1; ++y) {\n float closestDepth = getDepth(shadowMap, shadowUV + vec2(x, y) * 1.0/shadowSize);\n shadow += currentDepth > closestDepth ? 1.0 - darkness : 1.0;\n }\n }\n shadow /= 9.0;\n return shadow;\n}\nfloat shadowPCF5X5(sampler2D shadowMap, vec2 shadowUV, float currentDepth, float darkness, float shadowSize) {\n float shadow = 0.0;\n for (int x = -2; x <= 2; ++x) {\n for (int y = -2; y <= 2; ++y) {\n float closestDepth = getDepth(shadowMap, shadowUV + vec2(x, y) * 1.0/shadowSize);\n shadow += currentDepth > closestDepth ? 1.0 - darkness : 1.0;\n }\n }\n shadow /= 25.0;\n return shadow;\n}\n#if CC_NUM_LIGHTS > 0\nuniform vec4 cc_lightPositionAndRange[4];\nuniform vec4 cc_lightDirection[4];\nuniform vec4 cc_lightColor[4];\n#endif\nstruct LightInfo {\n vec3 lightDir;\n vec3 radiance;\n vec4 lightColor;\n};\nLightInfo computeDirectionalLighting(\n vec4 lightDirection,\n vec4 lightColor\n) {\n LightInfo ret;\n ret.lightDir = -normalize(lightDirection.xyz);\n ret.radiance = lightColor.rgb;\n ret.lightColor = lightColor;\n return ret;\n}\nLightInfo computePointLighting(\n vec3 worldPosition,\n vec4 lightPositionAndRange,\n vec4 lightColor\n) {\n LightInfo ret;\n vec3 lightDir = lightPositionAndRange.xyz - worldPosition;\n float attenuation = max(0., 1.0 - length(lightDir) / lightPositionAndRange.w);\n ret.lightDir = normalize(lightDir);\n ret.radiance = lightColor.rgb * attenuation;\n ret.lightColor = lightColor;\n return ret;\n}\nLightInfo computeSpotLighting(\n vec3 worldPosition,\n vec4 lightPositionAndRange,\n vec4 lightDirection,\n vec4 lightColor\n) {\n LightInfo ret;\n vec3 lightDir = lightPositionAndRange.xyz - worldPosition;\n float attenuation = max(0., 1.0 - length(lightDir) / lightPositionAndRange.w);\n lightDir = normalize(lightDir);\n float cosConeAngle = max(0., dot(lightDirection.xyz, -lightDir));\n cosConeAngle = cosConeAngle < lightDirection.w ? 0. : cosConeAngle;\n cosConeAngle = pow(cosConeAngle, lightColor.w);\n ret.lightDir = lightDir;\n ret.radiance = lightColor.rgb * attenuation * cosConeAngle;\n ret.lightColor = lightColor;\n return ret;\n}\nstruct Lighting {\n vec3 diffuse;\n vec3 specular;\n};\nstruct ToonSurface {\n vec4 baseColor;\n vec3 specular;\n float specularThreshold;\n vec3 position;\n vec3 normal;\n vec3 viewDirection;\n vec3 emissive;\n vec3 shadowColor;\n float shadowIntensity;\n vec3 highlightColor;\n float lightThreshold;\n float lightSmoothness;\n};\nconst float T_H = 0.25;\nfloat TreshHoldLighting(float lThreshold, float smoothness, float v) {\n return smoothstep(lThreshold-smoothness*T_H, lThreshold+smoothness*T_H, v);\n}\nLighting toon (ToonSurface s, LightInfo info) {\n Lighting result;\n vec3 N = s.normal;\n vec3 L = info.lightDir;\n vec3 V = s.viewDirection;\n vec3 H = normalize(L + V);\n float NL = 0.5 * dot(N, L) + 0.5;\n float NH = 0.5 * dot(H, N) + 0.5;\n vec3 c = vec3(0.0);\n vec3 attenuation = info.radiance;\n vec3 lightColor = info.lightColor.rgb;\n vec3 shadowColor = mix(s.highlightColor * lightColor, s.shadowColor, s.shadowIntensity);\n vec3 diffuse = TreshHoldLighting(s.lightThreshold, s.lightSmoothness, NL) * attenuation;\n diffuse = mix(shadowColor, s.highlightColor * lightColor, diffuse);\n result.diffuse = diffuse * s.baseColor.rgb;\n float specularWeight = 1.0 - pow(s.specularThreshold, 5.0);\n float specularMask = step(specularWeight, NH);\n vec3 specular = s.specular.rgb * specularMask;\n result.specular = specular * attenuation;\n return result;\n}\nvec3 ambient(ToonSurface s, vec4 ambientColor) {\n return s.baseColor.rgb * ambientColor.rgb;\n}\nvec4 CCToonShading (ToonSurface s) {\n Lighting result;\n result.diffuse = vec3(0, 0, 0);\n result.specular = vec3(0, 0, 0);\n #if CC_NUM_LIGHTS > 0\n #if CC_LIGHT_0_TYPE == 3\n result.diffuse += ambient(s, cc_lightColor[0]);\n #else\n LightInfo info0;\n #if CC_LIGHT_0_TYPE == 0\n info0 = computeDirectionalLighting(cc_lightDirection[0], cc_lightColor[0]);\n #elif CC_LIGHT_0_TYPE == 1\n info0 = computePointLighting(s.position, cc_lightPositionAndRange[0], cc_lightColor[0]);\n #elif CC_LIGHT_0_TYPE == 2\n info0 = computeSpotLighting(s.position, cc_lightPositionAndRange[0], cc_lightDirection[0], cc_lightColor[0]);\n #endif\n Lighting result0 = toon(s, info0);\n #if CC_USE_SHADOW_MAP && CC_NUM_SHADOW_LIGHTS > 0\n float shadow_0 = 1.0;\n vec2 projCoords0 = v_posLightSpace[0].xy / v_posLightSpace[0].w;\n vec2 shadowUV0 = projCoords0 * 0.5 + vec2(0.5);\n if (shadowUV0.x >= 0.0 && shadowUV0.x <= 1.0 && shadowUV0.y >= 0.0 && shadowUV0.y <= 1.0) {\n float currentDepth0 = clamp(v_depth[0], 0.0, 1.0);\n #if CC_SHADOW_0_TYPE == 3\n shadow_0 = shadowPCF3X3(cc_shadow_map_0, shadowUV0, currentDepth0, cc_shadow_info[0].w, cc_shadow_info[0].z);\n #elif CC_SHADOW_0_TYPE == 4\n shadow_0 = shadowPCF5X5(cc_shadow_map_0, shadowUV0, currentDepth0, cc_shadow_info[0].w, cc_shadow_info[0].z);\n #else\n shadow_0 = shadowSimple(cc_shadow_map_0, shadowUV0, currentDepth0, cc_shadow_info[0].w);\n #endif\n shadow_0 = computeFallOff(shadow_0, projCoords0, 0.0);\n }\n result0.diffuse *= shadow_0;\n result0.specular *= shadow_0;\n #endif\n result.diffuse += result0.diffuse;\n result.specular += result0.specular;\n #endif\n #endif\n #if CC_NUM_LIGHTS > 1\n #if CC_LIGHT_1_TYPE == 3\n result.diffuse += ambient(s, cc_lightColor[1]);\n #else\n LightInfo info1;\n #if CC_LIGHT_1_TYPE == 0\n info1 = computeDirectionalLighting(cc_lightDirection[1], cc_lightColor[1]);\n #elif CC_LIGHT_1_TYPE == 1\n info1 = computePointLighting(s.position, cc_lightPositionAndRange[1], cc_lightColor[1]);\n #elif CC_LIGHT_1_TYPE == 2\n info1 = computeSpotLighting(s.position, cc_lightPositionAndRange[1], cc_lightDirection[1], cc_lightColor[1]);\n #endif\n Lighting result1 = toon(s, info1);\n #if CC_USE_SHADOW_MAP && CC_NUM_SHADOW_LIGHTS > 1\n float shadow_1 = 1.0;\n vec2 projCoords1 = v_posLightSpace[1].xy / v_posLightSpace[1].w;\n vec2 shadowUV1 = projCoords1 * 0.5 + vec2(0.5);\n if (shadowUV1.x >= 0.0 && shadowUV1.x <= 1.0 && shadowUV1.y >= 0.0 && shadowUV1.y <= 1.0) {\n float currentDepth1 = clamp(v_depth[1], 0.0, 1.0);\n #if CC_SHADOW_1_TYPE == 3\n shadow_1 = shadowPCF3X3(cc_shadow_map_1, shadowUV1, currentDepth1, cc_shadow_info[1].w, cc_shadow_info[1].z);\n #elif CC_SHADOW_1_TYPE == 4\n shadow_1 = shadowPCF5X5(cc_shadow_map_1, shadowUV1, currentDepth1, cc_shadow_info[1].w, cc_shadow_info[1].z);\n #else\n shadow_1 = shadowSimple(cc_shadow_map_1, shadowUV1, currentDepth1, cc_shadow_info[1].w);\n #endif\n shadow_1 = computeFallOff(shadow_1, projCoords1, 0.0);\n }\n result1.diffuse *= shadow_1;\n result1.specular *= shadow_1;\n #endif\n result.diffuse += result1.diffuse;\n result.specular += result1.specular;\n #endif\n #endif\n #if CC_NUM_LIGHTS > 2\n #if CC_LIGHT_2_TYPE == 3\n result.diffuse += ambient(s, cc_lightColor[2]);\n #else\n LightInfo info2;\n #if CC_LIGHT_2_TYPE == 0\n info2 = computeDirectionalLighting(cc_lightDirection[2], cc_lightColor[2]);\n #elif CC_LIGHT_2_TYPE == 1\n info2 = computePointLighting(s.position, cc_lightPositionAndRange[2], cc_lightColor[2]);\n #elif CC_LIGHT_2_TYPE == 2\n info2 = computeSpotLighting(s.position, cc_lightPositionAndRange[2], cc_lightDirection[2], cc_lightColor[2]);\n #endif\n Lighting result2 = toon(s, info2);\n #if CC_USE_SHADOW_MAP && CC_NUM_SHADOW_LIGHTS > 2\n float shadow_2 = 1.0;\n vec2 projCoords2 = v_posLightSpace[2].xy / v_posLightSpace[2].w;\n vec2 shadowUV2 = projCoords2 * 0.5 + vec2(0.5);\n if (shadowUV2.x >= 0.0 && shadowUV2.x <= 1.0 && shadowUV2.y >= 0.0 && shadowUV2.y <= 1.0) {\n float currentDepth2 = clamp(v_depth[2], 0.0, 1.0);\n #if CC_SHADOW_2_TYPE == 3\n shadow_2 = shadowPCF3X3(cc_shadow_map_2, shadowUV2, currentDepth2, cc_shadow_info[2].w, cc_shadow_info[2].z);\n #elif CC_SHADOW_2_TYPE == 4\n shadow_2 = shadowPCF5X5(cc_shadow_map_2, shadowUV2, currentDepth2, cc_shadow_info[2].w, cc_shadow_info[2].z);\n #else\n shadow_2 = shadowSimple(cc_shadow_map_2, shadowUV2, currentDepth2, cc_shadow_info[2].w);\n #endif\n shadow_2 = computeFallOff(shadow_2, projCoords2, 0.0);\n }\n result2.diffuse *= shadow_2;\n result2.specular *= shadow_2;\n #endif\n result.diffuse += result2.diffuse;\n result.specular += result2.specular;\n #endif\n #endif\n #if CC_NUM_LIGHTS > 3\n #if CC_LIGHT_3_TYPE == 3\n result.diffuse += ambient(s, cc_lightColor[3]);\n #else\n LightInfo info3;\n #if CC_LIGHT_3_TYPE == 0\n info3 = computeDirectionalLighting(cc_lightDirection[3], cc_lightColor[3]);\n #elif CC_LIGHT_3_TYPE == 1\n info3 = computePointLighting(s.position, cc_lightPositionAndRange[3], cc_lightColor[3]);\n #elif CC_LIGHT_3_TYPE == 2\n info3 = computeSpotLighting(s.position, cc_lightPositionAndRange[3], cc_lightDirection[3], cc_lightColor[3]);\n #endif\n Lighting result3 = toon(s, info3);\n #if CC_USE_SHADOW_MAP && CC_NUM_SHADOW_LIGHTS > 3\n float shadow_3 = 1.0;\n vec2 projCoords3 = v_posLightSpace[3].xy / v_posLightSpace[3].w;\n vec2 shadowUV3 = projCoords3 * 0.5 + vec2(0.5);\n if (shadowUV3.x >= 0.0 && shadowUV3.x <= 1.0 && shadowUV3.y >= 0.0 && shadowUV3.y <= 1.0) {\n float currentDepth3 = clamp(v_depth[3], 0.0, 1.0);\n #if CC_SHADOW_3_TYPE == 3\n shadow_3 = shadowPCF3X3(cc_shadow_map_3, shadowUV3, currentDepth3, cc_shadow_info[3].w, cc_shadow_info[3].z);\n #elif CC_SHADOW_3_TYPE == 4\n shadow_3 = shadowPCF5X5(cc_shadow_map_3, shadowUV3, currentDepth3, cc_shadow_info[3].w, cc_shadow_info[3].z);\n #else\n shadow_3 = shadowSimple(cc_shadow_map_3, shadowUV3, currentDepth3, cc_shadow_info[3].w);\n #endif\n shadow_3 = computeFallOff(shadow_3, projCoords3, 0.0);\n }\n result3.diffuse *= shadow_3;\n result3.specular *= shadow_3;\n #endif\n result.diffuse += result3.diffuse;\n result.specular += result3.specular;\n #endif\n #endif\n vec3 finalColor = result.diffuse + result.specular + s.emissive;\n return vec4(finalColor, s.baseColor.a);\n}\nvec4 CCFragOutput (vec4 color) {\n #if OUTPUT_TO_GAMMA\n color.rgb = sqrt(color.rgb);\n #endif\n\treturn color;\n}\nvarying vec3 v_position;\nvarying vec2 v_uv;\nvarying vec3 v_viewDirection;\nvarying vec3 v_normal;\n#if USE_NORMAL_MAP\n varying vec3 v_tangent;\n varying vec3 v_bitangent;\n uniform sampler2D normalMap;\n#endif\n#if USE_BASE_COLOR_MAP\n uniform sampler2D baseColorMap;\n#endif\n#if USE_SPECULAR_MAP\n uniform sampler2D specularMap;\n#endif\n#if USE_EMISSIVE_MAP\n uniform sampler2D emissiveMap;\n#endif\nuniform vec4 specular;\nuniform vec4 emissive;\nuniform vec4 shadowColor;\nuniform vec4 highlightColor;\nuniform float specularThreshold;\nuniform float shadowIntensity;\nuniform float lightThreshold;\nuniform float lightSmoothness;\nvoid surf (out ToonSurface s) {\n #if USE_BASE_COLOR_MAP\n s.baseColor = vec4(1.);\n vec4 baseColorMap_tmp = texture2D(baseColorMap, v_uv);\n #if CC_USE_ALPHA_ATLAS_baseColorMap\n baseColorMap_tmp.a *= texture2D(baseColorMap, v_uv + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n s.baseColor.rgb *= (baseColorMap_tmp.rgb * baseColorMap_tmp.rgb);\n s.baseColor.a *= baseColorMap_tmp.a;\n #else\n s.baseColor *= baseColorMap_tmp;\n #endif\n #else\n s.baseColor = highlightColor;\n #endif\n s.normal = normalize(v_normal);\n #if USE_NORMAL_MAP\n vec3 nmmp = texture2D(normalMap, v_uv).xyz - vec3(0.5);\n s.normal = normalize(\n nmmp.x * normalize(v_tangent) +\n nmmp.y * normalize(v_bitangent) +\n nmmp.z * s.normal);\n #endif\n s.position = v_position;\n s.specular = specular.rgb * specular.a;\n #if USE_SPECULAR_MAP\n vec4 specularMap_tmp = texture2D(specularMap, v_uv);\n #if CC_USE_ALPHA_ATLAS_specularMap\n specularMap_tmp.a *= texture2D(specularMap, v_uv + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n s.specular.rgb *= (specularMap_tmp.rgb * specularMap_tmp.rgb);\n #else\n s.specular.rgb *= specularMap_tmp.rgb;\n #endif\n #endif\n s.emissive = emissive.rgb;\n #if USE_EMISSIVE_MAP\n vec4 emissiveMap_tmp = texture2D(emissiveMap, v_uv);\n #if CC_USE_ALPHA_ATLAS_emissiveMap\n emissiveMap_tmp.a *= texture2D(emissiveMap, v_uv + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n s.emissive.rgb *= (emissiveMap_tmp.rgb * emissiveMap_tmp.rgb);\n #else\n s.emissive.rgb *= emissiveMap_tmp.rgb;\n #endif\n #endif\n s.lightThreshold = lightThreshold;\n s.lightSmoothness = lightSmoothness;\n s.shadowColor = shadowColor.rgb;\n s.highlightColor = highlightColor.rgb;\n s.shadowIntensity = shadowIntensity;\n s.specularThreshold = specularThreshold;\n s.viewDirection = v_viewDirection;\n}\nvec4 frag () {\n ToonSurface s;\n surf(s);\n vec4 color = CCToonShading(s);\n return CCFragOutput(color);\n}\nvoid main() { gl_FragColor = frag(); }" + }, + "builtins": { + "globals": { + "blocks": [ + { + "name": "CCGlobal", + "defines": [] + }, + { + "name": "CC_SHADOW", + "defines": [ + "CC_USE_SHADOW_MAP", + "CC_NUM_SHADOW_LIGHTS" + ] + }, + { + "name": "CCLIGHTS", + "defines": [ + "CC_NUM_LIGHTS" + ] + } + ], + "samplers": [ + { + "name": "cc_shadow_map_0", + "defines": [ + "CC_USE_SHADOW_MAP", + "CC_NUM_SHADOW_LIGHTS" + ] + }, + { + "name": "cc_shadow_map_1", + "defines": [ + "CC_USE_SHADOW_MAP", + "CC_NUM_SHADOW_LIGHTS" + ] + } + ] + }, + "locals": { + "blocks": [ + { + "name": "CCLocal", + "defines": [] + } + ], + "samplers": [] + } + }, + "defines": [ + { + "name": "CC_USE_SKINNING", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_JOINTS_TEXTRUE", + "type": "boolean", + "defines": [ + "CC_USE_SKINNING" + ] + }, + { + "name": "CC_JOINTS_TEXTURE_FLOAT32", + "type": "boolean", + "defines": [ + "CC_USE_SKINNING", + "CC_USE_JOINTS_TEXTRUE" + ] + }, + { + "name": "CC_USE_ATTRIBUTE_UV0", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_ATTRIBUTE_COLOR", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_ATTRIBUTE_NORMAL", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_ATTRIBUTE_TANGENT", + "type": "boolean", + "defines": [] + }, + { + "name": "USE_NORMAL_MAP", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_SHADOW_MAP", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_NUM_SHADOW_LIGHTS", + "type": "number", + "defines": [ + "CC_USE_SHADOW_MAP" + ], + "range": [ + 0, + 3 + ] + }, + { + "name": "CC_NUM_LIGHTS", + "type": "number", + "defines": [], + "range": [ + 0, + 3 + ] + }, + { + "name": "CC_LIGHT_0_TYPE", + "type": "number", + "defines": [ + "CC_NUM_LIGHTS" + ], + "range": [ + 0, + 3 + ] + }, + { + "name": "CC_SHADOW_0_TYPE", + "type": "number", + "defines": [ + "CC_NUM_LIGHTS", + "CC_USE_SHADOW_MAP", + "CC_NUM_SHADOW_LIGHTS" + ], + "range": [ + 0, + 3 + ] + }, + { + "name": "CC_LIGHT_1_TYPE", + "type": "number", + "defines": [ + "CC_NUM_LIGHTS" + ], + "range": [ + 0, + 3 + ] + }, + { + "name": "CC_SHADOW_1_TYPE", + "type": "number", + "defines": [ + "CC_NUM_LIGHTS", + "CC_USE_SHADOW_MAP", + "CC_NUM_SHADOW_LIGHTS" + ], + "range": [ + 0, + 3 + ] + }, + { + "name": "CC_LIGHT_2_TYPE", + "type": "number", + "defines": [ + "CC_NUM_LIGHTS" + ], + "range": [ + 0, + 3 + ] + }, + { + "name": "CC_SHADOW_2_TYPE", + "type": "number", + "defines": [ + "CC_NUM_LIGHTS", + "CC_USE_SHADOW_MAP", + "CC_NUM_SHADOW_LIGHTS" + ], + "range": [ + 0, + 3 + ] + }, + { + "name": "CC_LIGHT_3_TYPE", + "type": "number", + "defines": [ + "CC_NUM_LIGHTS" + ], + "range": [ + 0, + 3 + ] + }, + { + "name": "CC_SHADOW_3_TYPE", + "type": "number", + "defines": [ + "CC_NUM_LIGHTS", + "CC_USE_SHADOW_MAP", + "CC_NUM_SHADOW_LIGHTS" + ], + "range": [ + 0, + 3 + ] + }, + { + "name": "OUTPUT_TO_GAMMA", + "type": "boolean", + "defines": [] + }, + { + "name": "USE_BASE_COLOR_MAP", + "type": "boolean", + "defines": [] + }, + { + "name": "USE_SPECULAR_MAP", + "type": "boolean", + "defines": [] + }, + { + "name": "USE_EMISSIVE_MAP", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_ALPHA_ATLAS_baseColorMap", + "type": "boolean", + "defines": [ + "USE_BASE_COLOR_MAP" + ] + }, + { + "name": "INPUT_IS_GAMMA", + "type": "boolean", + "defines": [ + "USE_BASE_COLOR_MAP" + ] + }, + { + "name": "CC_USE_ALPHA_ATLAS_specularMap", + "type": "boolean", + "defines": [ + "USE_SPECULAR_MAP" + ] + }, + { + "name": "CC_USE_ALPHA_ATLAS_emissiveMap", + "type": "boolean", + "defines": [ + "USE_EMISSIVE_MAP" + ] + } + ], + "blocks": [ + { + "name": "SKINNING", + "members": [ + { + "name": "jointsTextureSize", + "type": 14, + "count": 1 + } + ], + "defines": [ + "CC_USE_SKINNING", + "CC_USE_JOINTS_TEXTRUE" + ], + "binding": 0 + }, + { + "name": "JOINT_MATRIX", + "members": [ + { + "name": "jointMatrices", + "type": 26, + "count": 50 + } + ], + "defines": [ + "CC_USE_SKINNING" + ], + "binding": 1 + }, + { + "name": "ToonVert", + "members": [ + { + "name": "tilingOffset", + "type": 16, + "count": 1 + } + ], + "defines": [], + "binding": 2 + }, + { + "name": "ToonFrag", + "members": [ + { + "name": "colorScale", + "type": 16, + "count": 1 + }, + { + "name": "specular", + "type": 16, + "count": 1 + }, + { + "name": "emissive", + "type": 16, + "count": 1 + }, + { + "name": "shadowColor", + "type": 16, + "count": 1 + }, + { + "name": "highlightColor", + "type": 16, + "count": 1 + }, + { + "name": "specularThreshold", + "type": 13, + "count": 1 + }, + { + "name": "shadowIntensity", + "type": 13, + "count": 1 + }, + { + "name": "lightThreshold", + "type": 13, + "count": 1 + }, + { + "name": "lightSmoothness", + "type": 13, + "count": 1 + } + ], + "defines": [], + "binding": 3 + } + ], + "samplers": [ + { + "name": "jointsTexture", + "type": 29, + "count": 1, + "defines": [ + "CC_USE_SKINNING", + "CC_USE_JOINTS_TEXTRUE" + ], + "binding": 30 + }, + { + "name": "normalMap", + "type": 29, + "count": 1, + "defines": [ + "USE_NORMAL_MAP" + ], + "binding": 31 + }, + { + "name": "baseColorMap", + "type": 29, + "count": 1, + "defines": [ + "USE_BASE_COLOR_MAP" + ], + "binding": 32 + }, + { + "name": "specularMap", + "type": 29, + "count": 1, + "defines": [ + "USE_SPECULAR_MAP" + ], + "binding": 33 + }, + { + "name": "emissiveMap", + "type": 29, + "count": 1, + "defines": [ + "USE_EMISSIVE_MAP" + ], + "binding": 34 + } + ], + "record": null, + "name": "builtin-toon|toon-vs:vert|toon-fs:frag" + } + ] +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/e7/e7aba14b-f956-4480-b254-8d57832e273f.json b/Layered_virtual_list_2.x/library/imports/e7/e7aba14b-f956-4480-b254-8d57832e273f.json new file mode 100644 index 0000000..4bcfaf0 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/e7/e7aba14b-f956-4480-b254-8d57832e273f.json @@ -0,0 +1,28 @@ +{ + "__type__": "cc.SpriteFrame", + "content": { + "name": "default_radio_button_off", + "texture": "567dcd80-8bf4-4535-8a5a-313f1caf078a", + "atlas": "", + "rect": [ + 3, + 3, + 26, + 26 + ], + "offset": [ + 0, + 0 + ], + "originalSize": [ + 32, + 32 + ], + "capInsets": [ + 0, + 0, + 0, + 0 + ] + } +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/e8/e851e89b-faa2-4484-bea6-5c01dd9f06e2.json b/Layered_virtual_list_2.x/library/imports/e8/e851e89b-faa2-4484-bea6-5c01dd9f06e2.json new file mode 100644 index 0000000..e7522d6 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/e8/e851e89b-faa2-4484-bea6-5c01dd9f06e2.json @@ -0,0 +1,4 @@ +{ + "__type__": "cc.Texture2D", + "content": "0,9729,9729,33071,33071,0,0,1" +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/e8/e851e89b-faa2-4484-bea6-5c01dd9f06e2.png b/Layered_virtual_list_2.x/library/imports/e8/e851e89b-faa2-4484-bea6-5c01dd9f06e2.png new file mode 100644 index 0000000..dff9999 Binary files /dev/null and b/Layered_virtual_list_2.x/library/imports/e8/e851e89b-faa2-4484-bea6-5c01dd9f06e2.png differ diff --git a/Layered_virtual_list_2.x/library/imports/e9/e93d3fa9-8c21-4375-8a21-14ba84066c77.bin b/Layered_virtual_list_2.x/library/imports/e9/e93d3fa9-8c21-4375-8a21-14ba84066c77.bin new file mode 100644 index 0000000..2a87dd2 Binary files /dev/null and b/Layered_virtual_list_2.x/library/imports/e9/e93d3fa9-8c21-4375-8a21-14ba84066c77.bin differ diff --git a/Layered_virtual_list_2.x/library/imports/e9/e93d3fa9-8c21-4375-8a21-14ba84066c77.json b/Layered_virtual_list_2.x/library/imports/e9/e93d3fa9-8c21-4375-8a21-14ba84066c77.json new file mode 100644 index 0000000..e12424b --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/e9/e93d3fa9-8c21-4375-8a21-14ba84066c77.json @@ -0,0 +1,90 @@ +[ + { + "__type__": "cc.Mesh", + "_name": "", + "_objFlags": 0, + "_native": ".bin", + "_vertexBundles": [ + { + "__id__": 1 + } + ], + "_primitives": [ + { + "__id__": 6 + } + ], + "_minPos": { + "__type__": "cc.Vec3", + "x": -0.5, + "y": -0.5, + "z": 0 + }, + "_maxPos": { + "__type__": "cc.Vec3", + "x": 0.5, + "y": 0.5, + "z": 0 + } + }, + { + "__type__": "cc.mesh.VertexBundle", + "data": { + "__id__": 2 + }, + "formats": [ + { + "__id__": 3 + }, + { + "__id__": 4 + }, + { + "__id__": 5 + } + ], + "verticesCount": 4 + }, + { + "__type__": "cc.BufferRange", + "offset": 0, + "length": 128 + }, + { + "__type__": "cc.mesh.VertexFormat", + "name": "a_normal", + "type": 5126, + "num": 3, + "normalize": false + }, + { + "__type__": "cc.mesh.VertexFormat", + "name": "a_position", + "type": 5126, + "num": 3, + "normalize": false + }, + { + "__type__": "cc.mesh.VertexFormat", + "name": "a_uv0", + "type": 5126, + "num": 2, + "normalize": false + }, + { + "__type__": "cc.mesh.Primitive", + "vertexBundleIndices": [ + 0 + ], + "data": { + "__id__": 7 + }, + "indexUnit": 5123, + "topology": 4 + }, + { + "__type__": "cc.BufferRange", + "offset": 128, + "length": 12 + } +] \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/e9/e9ec654c-97a2-4787-9325-e6a10375219a.json b/Layered_virtual_list_2.x/library/imports/e9/e9ec654c-97a2-4787-9325-e6a10375219a.json new file mode 100644 index 0000000..487e43d --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/e9/e9ec654c-97a2-4787-9325-e6a10375219a.json @@ -0,0 +1,28 @@ +{ + "__type__": "cc.SpriteFrame", + "content": { + "name": "default_btn_pressed", + "texture": "b43ff3c2-02bb-4874-81f7-f2dea6970f18", + "atlas": "", + "rect": [ + 0, + 0, + 40, + 40 + ], + "offset": [ + 0, + 0 + ], + "originalSize": [ + 40, + 40 + ], + "capInsets": [ + 12, + 12, + 12, + 12 + ] + } +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/ec/eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432.json b/Layered_virtual_list_2.x/library/imports/ec/eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432.json new file mode 100644 index 0000000..dfa75fc --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/ec/eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432.json @@ -0,0 +1,16 @@ +{ + "__type__": "cc.Material", + "_name": "builtin-2d-sprite", + "_objFlags": 0, + "_native": "", + "_effectAsset": { + "__uuid__": "2874f8dd-416c-4440-81b7-555975426e93" + }, + "_techniqueData": { + "0": { + "defines": { + "USE_TEXTURE": true + } + } + } +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/ed/ed88f13d-fcad-4848-aa35-65a2cb973584.json b/Layered_virtual_list_2.x/library/imports/ed/ed88f13d-fcad-4848-aa35-65a2cb973584.json new file mode 100644 index 0000000..4c141df --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/ed/ed88f13d-fcad-4848-aa35-65a2cb973584.json @@ -0,0 +1,512 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "3d-stage", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "asyncLoadAssets": false, + "readonly": false + }, + { + "__type__": "cc.Node", + "_name": "New 3D Stage", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + }, + { + "__id__": 5 + }, + { + "__id__": 8 + }, + { + "__id__": 11 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 14 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "3D Camera", + "_objFlags": 512, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 3 + } + ], + "_prefab": { + "__id__": 4 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 10, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Camera", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "_cullingMask": 4294967295, + "_clearFlags": 6, + "_backgroundColor": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_depth": 0, + "_zoomRatio": 1, + "_targetTexture": null, + "_fov": 60, + "_orthoSize": 10, + "_nearClip": 1, + "_farClip": 1024, + "_ortho": false, + "_rect": { + "__type__": "cc.Rect", + "x": 0, + "y": 0, + "width": 1, + "height": 1 + }, + "_renderStages": 1, + "_alignWithScreen": false, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "ed88f13d-fcad-4848-aa35-65a2cb973584" + }, + "fileId": "09OTSCM6BL1LhNz6/uluXk", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "New Directional Light", + "_objFlags": 512, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 6 + } + ], + "_prefab": { + "__id__": 7 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + -0.25881904510252074, + 0, + 0, + 0.9659258262890683, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": -30, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Light", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 5 + }, + "_enabled": true, + "_type": 0, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_intensity": 1, + "_range": 1000, + "_spotAngle": 60, + "_spotExp": 1, + "_shadowType": 0, + "_shadowResolution": 1024, + "_shadowDarkness": 0.5, + "_shadowMinDepth": 1, + "_shadowMaxDepth": 1000, + "_shadowFrustumSize": 50, + "_shadowBias": 0.0005, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "ed88f13d-fcad-4848-aa35-65a2cb973584" + }, + "fileId": "3a6x6Es1NL4rpUC3Efs1MH", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "New Ambient Light", + "_objFlags": 512, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 9 + } + ], + "_prefab": { + "__id__": 10 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Light", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 8 + }, + "_enabled": true, + "_type": 3, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_intensity": 0.25, + "_range": 1, + "_spotAngle": 60, + "_spotExp": 1, + "_shadowType": 0, + "_shadowResolution": 1024, + "_shadowDarkness": 0.5, + "_shadowMinDepth": 1, + "_shadowMaxDepth": 1000, + "_shadowFrustumSize": 50, + "_shadowBias": 0.0005, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "ed88f13d-fcad-4848-aa35-65a2cb973584" + }, + "fileId": "77dtDtUX9D6KSMMqNy4utl", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "New Box", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 12 + } + ], + "_prefab": { + "__id__": 13 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.MeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 11 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "a5849239-3ad3-41d1-8ab4-ae9fea11f97f" + } + ], + "_mesh": { + "__uuid__": "046f172c-1574-488b-bbb8-6415a9adb96d" + }, + "_receiveShadows": false, + "_shadowCastingMode": 0, + "_enableAutoBatch": false, + "textures": [], + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "ed88f13d-fcad-4848-aa35-65a2cb973584" + }, + "fileId": "53C6mOUF5FXpk7lkLCsXQc", + "sync": false + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "ed88f13d-fcad-4848-aa35-65a2cb973584" + }, + "fileId": "38R8VzTKlGM4vBvAyA2GaF", + "sync": false + } +] \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/ed/edd215b9-2796-4a05-aaf5-81f96c9281ce.json b/Layered_virtual_list_2.x/library/imports/ed/edd215b9-2796-4a05-aaf5-81f96c9281ce.json new file mode 100644 index 0000000..e7522d6 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/ed/edd215b9-2796-4a05-aaf5-81f96c9281ce.json @@ -0,0 +1,4 @@ +{ + "__type__": "cc.Texture2D", + "content": "0,9729,9729,33071,33071,0,0,1" +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/ed/edd215b9-2796-4a05-aaf5-81f96c9281ce.png b/Layered_virtual_list_2.x/library/imports/ed/edd215b9-2796-4a05-aaf5-81f96c9281ce.png new file mode 100644 index 0000000..ec12e51 Binary files /dev/null and b/Layered_virtual_list_2.x/library/imports/ed/edd215b9-2796-4a05-aaf5-81f96c9281ce.png differ diff --git a/Layered_virtual_list_2.x/library/imports/f0/f0048c10-f03e-4c97-b9d3-3506e1d58952.json b/Layered_virtual_list_2.x/library/imports/f0/f0048c10-f03e-4c97-b9d3-3506e1d58952.json new file mode 100644 index 0000000..02a9a3c --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/f0/f0048c10-f03e-4c97-b9d3-3506e1d58952.json @@ -0,0 +1,28 @@ +{ + "__type__": "cc.SpriteFrame", + "content": { + "name": "default_btn_normal", + "texture": "e851e89b-faa2-4484-bea6-5c01dd9f06e2", + "atlas": "", + "rect": [ + 0, + 0, + 40, + 40 + ], + "offset": [ + 0, + 0 + ], + "originalSize": [ + 40, + 40 + ], + "capInsets": [ + 12, + 12, + 12, + 12 + ] + } +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/f1/f18742d7-56d2-4eb5-ae49-2d9d710b37c8.json b/Layered_virtual_list_2.x/library/imports/f1/f18742d7-56d2-4eb5-ae49-2d9d710b37c8.json new file mode 100644 index 0000000..8636c21 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/f1/f18742d7-56d2-4eb5-ae49-2d9d710b37c8.json @@ -0,0 +1,182 @@ +{ + "__type__": "cc.EffectAsset", + "_name": "builtin-2d-label", + "_objFlags": 0, + "_native": "", + "properties": null, + "techniques": [ + { + "passes": [ + { + "blendState": { + "targets": [ + { + "blend": true + } + ] + }, + "rasterizerState": { + "cullMode": 0 + }, + "properties": { + "texture": { + "value": "white", + "type": 29 + }, + "alphaThreshold": { + "value": [ + 0.5 + ], + "type": 13 + }, + "outlineSize": { + "value": [ + 0 + ], + "type": 13 + }, + "outlineColor": { + "value": [ + 1, + 1, + 1, + 1 + ], + "type": 16 + } + }, + "program": "builtin-2d-label|vs|fs" + } + ] + } + ], + "shaders": [ + { + "hash": 1105459032, + "glsl3": { + "vert": "\nprecision highp float;\nuniform CCGlobal {\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\nuniform CCLocal {\n mat4 cc_matWorld;\n mat4 cc_matWorldIT;\n};\nin vec3 a_position;\nin vec4 a_color;\nout vec4 v_color;\n#if USE_TEXTURE\nin vec2 a_uv0;\nout vec2 v_uv0;\n#endif\nvoid main () {\n vec4 pos = vec4(a_position, 1);\n #if CC_USE_MODEL\n pos = cc_matViewProj * cc_matWorld * pos;\n #else\n pos = cc_matViewProj * pos;\n #endif\n #if USE_TEXTURE\n v_uv0 = a_uv0;\n #endif\n v_color = a_color;\n gl_Position = pos;\n}", + "frag": "\n#if CC_SUPPORT_standard_derivatives\n #extension GL_OES_standard_derivatives : enable\n#endif\nprecision highp float;\n#if USE_ALPHA_TEST\n uniform ALPHA_TEST {\n float alphaThreshold;\n };\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\nin vec4 v_color;\n#if USE_TEXTURE\nin vec2 v_uv0;\nuniform sampler2D texture;\n#endif\n#if USE_SDF\nuniform Outline {\n vec4 outlineColor;\n float outlineSize;\n};\n#endif\nvoid main () {\n#if USE_SDF\n #if USE_TEXTURE_ALPHAONLY\n float dist = texture(texture, v_uv0).a;\n #else\n float dist = texture(texture, v_uv0).r;\n #endif\n #if USE_SDF_EXTEND\n const float EDGE_VALUE = 0.45;\n #else\n const float EDGE_VALUE = 0.5;\n #endif\n #if CC_SUPPORT_standard_derivatives\n float smoothing = fwidth(dist);\n #else\n float smoothing = 0.05;\n #endif\n float outEdge = EDGE_VALUE - outlineSize;\n float bg = smoothstep(outEdge - smoothing, outEdge, dist);\n float fg = smoothstep(EDGE_VALUE - smoothing, EDGE_VALUE, dist);\n vec4 fgColor = outlineColor * (1.0 - fg) + v_color * fg;\n gl_FragColor = vec4(fgColor.rgb, fgColor.a * bg);\n#else\n vec4 o = vec4(1, 1, 1, 1);\n #if USE_TEXTURE\n #if USE_TEXTURE_ALPHAONLY\n o.a *= texture(texture, v_uv0).a;\n #else\n o *= texture(texture, v_uv0);\n #endif\n #if CC_USE_ALPHA_ATLAS_TEXTURE\n o.a *= texture2D(texture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #endif\n o *= v_color;\n ALPHA_TEST(o);\n gl_FragColor = o;\n#endif\n}" + }, + "glsl1": { + "vert": "\nprecision highp float;\nuniform mat4 cc_matViewProj;\nuniform mat4 cc_matWorld;\nattribute vec3 a_position;\nattribute vec4 a_color;\nvarying vec4 v_color;\n#if USE_TEXTURE\nattribute vec2 a_uv0;\nvarying vec2 v_uv0;\n#endif\nvoid main () {\n vec4 pos = vec4(a_position, 1);\n #if CC_USE_MODEL\n pos = cc_matViewProj * cc_matWorld * pos;\n #else\n pos = cc_matViewProj * pos;\n #endif\n #if USE_TEXTURE\n v_uv0 = a_uv0;\n #endif\n v_color = a_color;\n gl_Position = pos;\n}", + "frag": "\n#if CC_SUPPORT_standard_derivatives\n #extension GL_OES_standard_derivatives : enable\n#endif\nprecision highp float;\n#if USE_ALPHA_TEST\n uniform float alphaThreshold;\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\nvarying vec4 v_color;\n#if USE_TEXTURE\nvarying vec2 v_uv0;\nuniform sampler2D texture;\n#endif\n#if USE_SDF\nuniform vec4 outlineColor;\nuniform float outlineSize;\n#endif\nvoid main () {\n#if USE_SDF\n #if USE_TEXTURE_ALPHAONLY\n float dist = texture2D(texture, v_uv0).a;\n #else\n float dist = texture2D(texture, v_uv0).r;\n #endif\n #if USE_SDF_EXTEND\n const float EDGE_VALUE = 0.45;\n #else\n const float EDGE_VALUE = 0.5;\n #endif\n #if CC_SUPPORT_standard_derivatives\n float smoothing = fwidth(dist);\n #else\n float smoothing = 0.05;\n #endif\n float outEdge = EDGE_VALUE - outlineSize;\n float bg = smoothstep(outEdge - smoothing, outEdge, dist);\n float fg = smoothstep(EDGE_VALUE - smoothing, EDGE_VALUE, dist);\n vec4 fgColor = outlineColor * (1.0 - fg) + v_color * fg;\n gl_FragColor = vec4(fgColor.rgb, fgColor.a * bg);\n#else\n vec4 o = vec4(1, 1, 1, 1);\n #if USE_TEXTURE\n #if USE_TEXTURE_ALPHAONLY\n o.a *= texture2D(texture, v_uv0).a;\n #else\n o *= texture2D(texture, v_uv0);\n #endif\n #if CC_USE_ALPHA_ATLAS_TEXTURE\n o.a *= texture2D(texture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #endif\n o *= v_color;\n ALPHA_TEST(o);\n gl_FragColor = o;\n#endif\n}" + }, + "builtins": { + "globals": { + "blocks": [ + { + "name": "CCGlobal", + "defines": [] + } + ], + "samplers": [] + }, + "locals": { + "blocks": [ + { + "name": "CCLocal", + "defines": [] + } + ], + "samplers": [] + } + }, + "defines": [ + { + "name": "USE_TEXTURE", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_USE_MODEL", + "type": "boolean", + "defines": [] + }, + { + "name": "CC_SUPPORT_standard_derivatives", + "type": "boolean", + "defines": [] + }, + { + "name": "USE_ALPHA_TEST", + "type": "boolean", + "defines": [] + }, + { + "name": "USE_SDF", + "type": "boolean", + "defines": [] + }, + { + "name": "USE_TEXTURE_ALPHAONLY", + "type": "boolean", + "defines": [ + "USE_SDF" + ] + }, + { + "name": "USE_SDF_EXTEND", + "type": "boolean", + "defines": [ + "USE_SDF" + ] + }, + { + "name": "CC_USE_ALPHA_ATLAS_TEXTURE", + "type": "boolean", + "defines": [ + "USE_TEXTURE" + ] + } + ], + "blocks": [ + { + "name": "ALPHA_TEST", + "members": [ + { + "name": "alphaThreshold", + "type": 13, + "count": 1 + } + ], + "defines": [ + "USE_ALPHA_TEST" + ], + "binding": 0 + }, + { + "name": "Outline", + "members": [ + { + "name": "outlineColor", + "type": 16, + "count": 1 + }, + { + "name": "outlineSize", + "type": 13, + "count": 1 + } + ], + "defines": [ + "USE_SDF" + ], + "binding": 1 + } + ], + "samplers": [ + { + "name": "texture", + "type": 29, + "count": 1, + "defines": [ + "USE_TEXTURE" + ], + "binding": 30 + } + ], + "record": null, + "name": "builtin-2d-label|vs|fs" + } + ] +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/f5/f5331fd2-bf42-4ee3-a3fd-3e1657600eff.json b/Layered_virtual_list_2.x/library/imports/f5/f5331fd2-bf42-4ee3-a3fd-3e1657600eff.json new file mode 100644 index 0000000..80791fc --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/f5/f5331fd2-bf42-4ee3-a3fd-3e1657600eff.json @@ -0,0 +1,117 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "spot", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "asyncLoadAssets": false, + "readonly": false + }, + { + "__type__": "cc.Node", + "_name": "light", + "_objFlags": 0, + "_parent": null, + "_children": [], + "_active": true, + "_level": 1, + "_components": [ + { + "__id__": 2 + } + ], + "_prefab": { + "__id__": 3 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "groupIndex": 0, + "_id": "", + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Light", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "_type": 2, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_intensity": 1, + "_range": 1000, + "_spotAngle": 60, + "_spotExp": 1, + "_shadowType": 0, + "_shadowResolution": 1024, + "_shadowDarkness": 0.5, + "_shadowMinDepth": 1, + "_shadowMaxDepth": 1000, + "_shadowDepthScale": 250, + "_shadowFrustumSize": 50, + "_shadowBias": 0.0005, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "f5331fd2-bf42-4ee3-a3fd-3e1657600eff" + }, + "fileId": "33zOkteexCqamZ4PXuwJaW", + "sync": false + } +] \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/f9/f9782c63-e103-4af3-8d8e-007a1a6d115b.js b/Layered_virtual_list_2.x/library/imports/f9/f9782c63-e103-4af3-8d8e-007a1a6d115b.js new file mode 100644 index 0000000..e003033 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/f9/f9782c63-e103-4af3-8d8e-007a1a6d115b.js @@ -0,0 +1,264 @@ +"use strict"; +cc._RF.push(module, 'f9782xj4QNK842OAHoabRFb', 'RenderAlternative'); +// Script/RenderAlternative.ts + +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var RenderReactiveHandler_1 = require("./RenderReactiveHandler"); +/** + * 目前该渲染代理功能存在的问题 + * 1.被代理节点的父级不能出现scaleX和scaleY不一致的情况,被代理节点本身没有这个限制 + */ +var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property; +var RenderAlternative = /** @class */ (function (_super) { + __extends(RenderAlternative, _super); + function RenderAlternative() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /**渲染层节点 */ + _this.renderLayer = null; + /**渲染的zIndex 动态调整zIndex,用于方便临近合批 */ + _this.renderZIndex = 0; + /**同步的间隔(帧为单位) */ + _this.syncInv = 0.01; + /**渲染的sIndex */ + _this.sIndex = 0; + /**非渲染组件 */ + _this.proxyRender = null; + /**渲染组件 */ + _this.renderCompnent = null; + /**上次更新的数据 */ + _this.lastWMat4 = null; + /**上次更新的数据 */ + _this.lastLMat4 = null; + /**上次更新的数据 */ + _this.lastPos = null; + /**距离下次刷新累计了多少间隔 */ + _this.accuTime = 0; + /**最后一次刷新时间 */ + _this.lastFrameTime = null; + /**是否进行刷新 */ + _this.isAttachFrame = false; + return _this; + } + RenderAlternative_1 = RenderAlternative; + Object.defineProperty(RenderAlternative.prototype, "zIndex", { + /**获取总的ZIndex */ + get: function () { + var zIndex = this.renderZIndex + (this.sIndex * 0.01); + var parentNode = this.node.parent; + while (parentNode != this.renderLayer.parent && parentNode != cc.director.getScene()) { + var render = parentNode.getComponent(RenderAlternative_1); + if (render) { + zIndex += render.zIndex + 1; + break; + } + parentNode = parentNode.parent; + } + return zIndex; + }, + enumerable: false, + configurable: true + }); + /** + * 设置渲染节点层 + * @param layer + */ + RenderAlternative.prototype.init = function (layer) { + if (layer) { + this.renderLayer = layer; + } + if (!this.renderLayer) { + console.warn("\u8282\u70B9" + this.node.name + "\u6CA1\u6709\u8BBE\u7F6E\u6E32\u67D3\u5C42"); + return null; + } + return this.initRender(); + }; + /** + * 初始化渲染节点 + */ + RenderAlternative.prototype.initRender = function () { + var node = this.getRender(); + node.setParent(this.renderLayer ? this.renderLayer : cc.director.getScene().getChildByName("Canvas")); + this.isAttachFrame = true; + requestAnimationFrame(this.frameUpdate.bind(this)); + return this.doProxy(); + }; + /**生成代理 */ + RenderAlternative.prototype.doProxy = function () { + this.proxyRender = new Proxy(this.renderCompnent, new RenderReactiveHandler_1.RenderReactiveHandler()); + return this.proxyRender; + }; + RenderAlternative.prototype.frameUpdate = function () { + var now = cc.sys.now(); + !this.lastFrameTime && (this.lastFrameTime = now); + var dt = now - this.lastFrameTime; + if (this.proxyRender) { + this.accuTime += dt; + if (this.accuTime >= this.syncInv) { + this.accuTime -= this.syncInv; + this.updateProp(); + } + } + if (this.isAttachFrame) { + requestAnimationFrame(this.frameUpdate.bind(this)); + } + }; + /**更新最新状态 */ + RenderAlternative.prototype.updateProp = function () { + var node = this.renderCompnent.node; + if (!this.node.activeInHierarchy) { + node.opacity = 0; + return; + } + node.anchorX = this.node.anchorX; + node.anchorY = this.node.anchorY; + node.width = this.node.width; + node.height = this.node.height; + node.group = this.node.group; + node.color = this.node.color; + node.opacity = this.getOpacity(this.node); + var wMat4 = cc.mat4(); + this.node.getWorldMatrix(wMat4); + if (!this.lastWMat4 || !this.lastWMat4.equals(wMat4)) { + var localMatrix = this.getLocalMatrix(wMat4, node); + this.setLocalXYZScaleAngle(localMatrix, node, this.lastLMat4); + this.lastWMat4 = wMat4; + this.lastLMat4 = localMatrix; + } + node.zIndex = this.zIndex; + }; + RenderAlternative.prototype.getLocalMatrix = function (worldMatrix, node) { + var parentNode = null; + if (cc.isValid(node)) { + if (cc.isValid(node.parent)) { + parentNode = node.parent; + } + } + // 获取父节点的世界矩阵 + var parentWorldMatrix = cc.mat4(); + parentNode.getWorldMatrix(parentWorldMatrix); + // 获取父节点的逆矩阵 + var parentInverseMatrix = parentWorldMatrix.invert(); + // 将目标节点的世界矩阵转换为父节点的本地矩阵 + var localMatrix = parentInverseMatrix.multiply(worldMatrix); + return localMatrix; + }; + RenderAlternative.prototype.setLocalXYZScaleAngle = function (matrix, node, lastMatrix) { + if (lastMatrix && matrix.equals(lastMatrix)) { + return; + } + // 提取位置 + node.setPosition(matrix.m[12], matrix.m[13], matrix.m[14]); + var scaleX = null; + var scaleY = null; + var angle = null; + // 提取缩放X + if (!lastMatrix) { + scaleX = Math.sqrt(matrix.m[0] * matrix.m[0] + matrix.m[1] * matrix.m[1] + matrix.m[2] * matrix.m[2]); + } + else if (!this.equalsValue(matrix.m[0], lastMatrix.m[0]) + || !this.equalsValue(matrix.m[1], lastMatrix.m[1]) + || !this.equalsValue(matrix.m[2], lastMatrix.m[2])) { + scaleX = Math.sqrt(matrix.m[0] * matrix.m[0] + matrix.m[1] * matrix.m[1] + matrix.m[2] * matrix.m[2]); + } + // 提取缩放Y + if (!lastMatrix) { + scaleY = Math.sqrt(matrix.m[4] * matrix.m[4] + matrix.m[5] * matrix.m[5] + matrix.m[6] * matrix.m[6]); + } + else if (!this.equalsValue(matrix.m[4], lastMatrix.m[4]) + || !this.equalsValue(matrix.m[5], lastMatrix.m[5]) + || !this.equalsValue(matrix.m[6], lastMatrix.m[6])) { + scaleY = Math.sqrt(matrix.m[4] * matrix.m[4] + matrix.m[5] * matrix.m[5] + matrix.m[6] * matrix.m[6]); + } + //设置缩放X + if (scaleX !== null) { + node.scaleX = scaleX; + // 提取旋转 + angle = Math.atan2(matrix.m[1] / scaleX, matrix.m[0] / scaleX) * (180 / Math.PI); + } + if (scaleY !== null) { + node.scaleY = scaleY; + } + if (angle !== null) { + node.rotation = angle; + } + }; + RenderAlternative.prototype.equalsValue = function (a, b, epsilon) { + if (epsilon === void 0) { epsilon = 0.00001; } + return Math.abs(a - b) < epsilon; + }; + RenderAlternative.prototype.onDestroy = function () { + this.renderCompnent.node.destroy(); + this.renderCompnent = null; + this.proxyRender = null; + }; + /** + * 获取节点透明度 + * @param node + */ + RenderAlternative.prototype.getOpacity = function (node) { + var opacity = (node.opacity / 255); + var parentNode = node.parent; + while (parentNode != this.renderLayer.parent && parentNode != cc.director.getScene()) { + opacity *= (parentNode.opacity / 255); + parentNode = parentNode.parent; + } + return opacity * 255; + }; + /** + * 获取渲染组件 + * @param node + */ + RenderAlternative.prototype.getRender = function () { + var _a, _b; + var node = cc.instantiate(this.node); + node.removeAllChildren(); + this.renderCompnent = node.getComponent(cc.RenderComponent); + (_a = this.node.getComponent(cc.LabelOutline)) === null || _a === void 0 ? void 0 : _a.destroy(); + (_b = this.node.getComponent(cc.LabelShadow)) === null || _b === void 0 ? void 0 : _b.destroy(); + this.node.getComponent(cc.RenderComponent).destroy(); + var components = node.getComponents(cc.Component); + for (var i = 0, len = components.length; i < len; ++i) { + var comp = components[i]; + if (!((comp instanceof cc.RenderComponent) || (comp instanceof cc.LabelOutline) || (comp instanceof cc.LabelShadow))) { + comp.destroy(); + } + } + return node; + }; + var RenderAlternative_1; + __decorate([ + property + ], RenderAlternative.prototype, "renderZIndex", void 0); + __decorate([ + property({ + tooltip: '设置同步的间隔(秒为单位),0就是每帧都同步,0.1就是隔0.1秒同步一次' + }) + ], RenderAlternative.prototype, "syncInv", void 0); + RenderAlternative = RenderAlternative_1 = __decorate([ + ccclass + ], RenderAlternative); + return RenderAlternative; +}(cc.Component)); +exports.default = RenderAlternative; + +cc._RF.pop(); \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/f9/f9782c63-e103-4af3-8d8e-007a1a6d115b.js.map b/Layered_virtual_list_2.x/library/imports/f9/f9782c63-e103-4af3-8d8e-007a1a6d115b.js.map new file mode 100644 index 0000000..9417eeb --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/f9/f9782c63-e103-4af3-8d8e-007a1a6d115b.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["assets\\Script\\RenderAlternative.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iEAAgE;AAEhE;;;GAGG;AACG,IAAA,KAAwB,EAAE,CAAC,UAAU,EAAnC,OAAO,aAAA,EAAE,QAAQ,cAAkB,CAAC;AAE5C;IAA+C,qCAAY;IAA3D;QAAA,qEA6NC;QA5NG,WAAW;QACJ,iBAAW,GAAY,IAAI,CAAC;QACnC,mCAAmC;QAE5B,kBAAY,GAAW,CAAC,CAAC;QAChC,iBAAiB;QAIV,aAAO,GAAW,IAAI,CAAC;QAC9B,eAAe;QACR,YAAM,GAAW,CAAC,CAAC;QAC1B,WAAW;QACJ,iBAAW,GAAuB,IAAI,CAAC;QAC9C,UAAU;QACF,oBAAc,GAAuB,IAAI,CAAC;QAClD,aAAa;QACN,eAAS,GAAY,IAAI,CAAC;QACjC,aAAa;QACN,eAAS,GAAY,IAAI,CAAC;QACjC,aAAa;QACN,aAAO,GAAY,IAAI,CAAC;QAC/B,mBAAmB;QACZ,cAAQ,GAAW,CAAC,CAAC;QAC5B,cAAc;QACP,mBAAa,GAAW,IAAI,CAAC;QACpC,YAAY;QACL,mBAAa,GAAY,KAAK,CAAC;;IAiM1C,CAAC;0BA7NoB,iBAAiB;IA+BlC,sBAAI,qCAAM;QADV,gBAAgB;aAChB;YACI,IAAI,MAAM,GAAG,IAAI,CAAC,YAAY,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;YACtD,IAAI,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;YAClC,OAAO,UAAU,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,IAAI,UAAU,IAAI,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,EAAE;gBAClF,IAAI,MAAM,GAAG,UAAU,CAAC,YAAY,CAAC,mBAAiB,CAAC,CAAC;gBACxD,IAAI,MAAM,EAAE;oBACR,MAAM,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;oBAC5B,MAAM;iBACT;gBACD,UAAU,GAAG,UAAU,CAAC,MAAM,CAAC;aAClC;YACD,OAAO,MAAM,CAAC;QAClB,CAAC;;;OAAA;IAED;;;OAGG;IACH,gCAAI,GAAJ,UAAmC,KAAe;QAC9C,IAAI,KAAK,EAAE;YACP,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;SAC5B;QACD,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;YACnB,OAAO,CAAC,IAAI,CAAC,iBAAK,IAAI,CAAC,IAAI,CAAC,IAAI,+CAAS,CAAC,CAAA;YAC1C,OAAO,IAAI,CAAC;SACf;QACD,OAAO,IAAI,CAAC,UAAU,EAAK,CAAC;IAChC,CAAC;IACD;;OAEG;IACK,sCAAU,GAAlB;QACI,IAAI,IAAI,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;QAC5B,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC;QACtG,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;QAC1B,qBAAqB,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QACnD,OAAO,IAAI,CAAC,OAAO,EAAK,CAAC;IAC7B,CAAC;IACD,UAAU;IACF,mCAAO,GAAf;QACI,IAAI,CAAC,WAAW,GAAG,IAAI,KAAK,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,6CAAqB,EAAE,CAAM,CAAC;QACpF,OAAO,IAAI,CAAC,WAAgB,CAAC;IACjC,CAAC;IAGS,uCAAW,GAArB;QACI,IAAI,GAAG,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;QACvB,CAAC,IAAI,CAAC,aAAa,IAAI,CAAC,IAAI,CAAC,aAAa,GAAG,GAAG,CAAC,CAAC;QAClD,IAAI,EAAE,GAAG,GAAG,GAAG,IAAI,CAAC,aAAa,CAAC;QAClC,IAAI,IAAI,CAAC,WAAW,EAAE;YAClB,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAC;YACpB,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,OAAO,EAAE;gBAC/B,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,OAAO,CAAC;gBAC9B,IAAI,CAAC,UAAU,EAAE,CAAC;aACrB;SACJ;QACD,IAAI,IAAI,CAAC,aAAa,EAAE;YACpB,qBAAqB,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;SACtD;IACL,CAAC;IAED,YAAY;IACL,sCAAU,GAAjB;QACI,IAAI,IAAI,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC;QACpC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE;YAC9B,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;YACjB,OAAO;SACV;QACD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC;QACjC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC;QACjC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;QAC7B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;QAC/B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;QAC7B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAE1C,IAAI,KAAK,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC;QACtB,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;QAChC,IAAI,CAAC,IAAI,CAAC,SAAS,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;YAClD,IAAI,WAAW,GAAG,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;YACnD,IAAI,CAAC,qBAAqB,CAAC,WAAW,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;YAC9D,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;YACvB,IAAI,CAAC,SAAS,GAAG,WAAW,CAAC;SAChC;QACD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IAC9B,CAAC;IAEO,0CAAc,GAAtB,UAAuB,WAAoB,EAAE,IAAa;QACtD,IAAI,UAAU,GAAG,IAAI,CAAC;QACtB,IAAI,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YAClB,IAAI,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE;gBACzB,UAAU,GAAG,IAAI,CAAC,MAAM,CAAA;aAC3B;SACJ;QACD,aAAa;QACb,IAAI,iBAAiB,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC;QAClC,UAAU,CAAC,cAAc,CAAC,iBAAiB,CAAC,CAAC;QAC7C,YAAY;QACZ,IAAI,mBAAmB,GAAG,iBAAiB,CAAC,MAAM,EAAE,CAAC;QACrD,wBAAwB;QACxB,IAAI,WAAW,GAAG,mBAAmB,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;QAC5D,OAAO,WAAW,CAAC;IAEvB,CAAC;IAEO,iDAAqB,GAA7B,UAA8B,MAAe,EAAE,IAAa,EAAE,UAAoB;QAC9E,IAAI,UAAU,IAAI,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE;YACzC,OAAO;SACV;QAED,OAAO;QACP,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAE3D,IAAI,MAAM,GAAG,IAAI,CAAC;QAClB,IAAI,MAAM,GAAG,IAAI,CAAC;QAClB,IAAI,KAAK,GAAG,IAAI,CAAC;QACjB,QAAQ;QACR,IAAI,CAAC,UAAU,EAAE;YACb,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;SACzG;aAAM,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;eACnD,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;eAC/C,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE;YACpD,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;SACzG;QACD,QAAQ;QACR,IAAI,CAAC,UAAU,EAAE;YACb,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;SACzG;aAAM,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;eACnD,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;eAC/C,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE;YACpD,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;SACzG;QACD,OAAO;QACP,IAAI,MAAM,KAAK,IAAI,EAAE;YACjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;YACrB,OAAO;YACP,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC;SACpF;QACD,IAAI,MAAM,KAAK,IAAI,EAAE;YACjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;SACxB;QACD,IAAI,KAAK,KAAK,IAAI,EAAE;YAChB,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;SACzB;IACL,CAAC;IAEO,uCAAW,GAAnB,UAAoB,CAAS,EAAE,CAAS,EAAE,OAAyB;QAAzB,wBAAA,EAAA,iBAAyB;QAC/D,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,OAAO,CAAC;IACrC,CAAC;IAES,qCAAS,GAAnB;QACI,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;QACnC,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;QAC3B,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;IAC5B,CAAC;IAED;;;OAGG;IACK,sCAAU,GAAlB,UAAmB,IAAa;QAC5B,IAAI,OAAO,GAAG,CAAC,IAAI,CAAC,OAAO,GAAG,GAAG,CAAC,CAAC;QACnC,IAAI,UAAU,GAAG,IAAI,CAAC,MAAM,CAAA;QAC5B,OAAO,UAAU,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,IAAI,UAAU,IAAI,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,EAAE;YAClF,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,GAAG,GAAG,CAAC,CAAC;YACtC,UAAU,GAAG,UAAU,CAAC,MAAM,CAAC;SAClC;QACD,OAAO,OAAO,GAAG,GAAG,CAAC;IACzB,CAAC;IACD;;;OAGG;IACK,qCAAS,GAAjB;;QACI,IAAI,IAAI,GAAG,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACzB,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC;QAC5D,MAAA,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,YAAY,CAAC,0CAAE,OAAO,GAAG;QACnD,MAAA,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,WAAW,CAAC,0CAAE,OAAO,GAAG;QAClD,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC,OAAO,EAAE,CAAC;QACrD,IAAI,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC;QAClD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,GAAG,GAAG,EAAE,EAAE,CAAC,EAAE;YACnD,IAAI,IAAI,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;YACzB,IAAI,CAAC,CAAC,CAAC,IAAI,YAAY,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,YAAY,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,YAAY,EAAE,CAAC,WAAW,CAAC,CAAC,EAAE;gBAClH,IAAI,CAAC,OAAO,EAAE,CAAC;aAClB;SACJ;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;;IAtND;QADC,QAAQ;2DACuB;IAKhC;QAHC,QAAQ,CAAC;YACN,OAAO,EAAE,uCAAuC;SACnD,CAAC;sDAC4B;IAVb,iBAAiB;QADrC,OAAO;OACa,iBAAiB,CA6NrC;IAAD,wBAAC;CA7ND,AA6NC,CA7N8C,EAAE,CAAC,SAAS,GA6N1D;kBA7NoB,iBAAiB","file":"","sourceRoot":"/","sourcesContent":["import { RenderReactiveHandler } from \"./RenderReactiveHandler\";\r\n\r\n/**\r\n * 目前该渲染代理功能存在的问题\r\n * 1.被代理节点的父级不能出现scaleX和scaleY不一致的情况,被代理节点本身没有这个限制\r\n */\r\nconst { ccclass, property } = cc._decorator;\r\n@ccclass\r\nexport default class RenderAlternative extends cc.Component {\r\n /**渲染层节点 */\r\n public renderLayer: cc.Node = null;\r\n /**渲染的zIndex 动态调整zIndex,用于方便临近合批 */\r\n @property\r\n public renderZIndex: number = 0;\r\n /**同步的间隔(帧为单位) */\r\n @property({\r\n tooltip: '设置同步的间隔(秒为单位),0就是每帧都同步,0.1就是隔0.1秒同步一次'\r\n })\r\n public syncInv: number = 0.01;\r\n /**渲染的sIndex */\r\n public sIndex: number = 0;\r\n /**非渲染组件 */\r\n public proxyRender: cc.RenderComponent = null;\r\n /**渲染组件 */\r\n private renderCompnent: cc.RenderComponent = null;\r\n /**上次更新的数据 */\r\n public lastWMat4: cc.Mat4 = null;\r\n /**上次更新的数据 */\r\n public lastLMat4: cc.Mat4 = null;\r\n /**上次更新的数据 */\r\n public lastPos: cc.Vec3 = null;\r\n /**距离下次刷新累计了多少间隔 */\r\n public accuTime: number = 0;\r\n /**最后一次刷新时间 */\r\n public lastFrameTime: number = null;\r\n /**是否进行刷新 */\r\n public isAttachFrame: boolean = false;\r\n\r\n /**获取总的ZIndex */\r\n get zIndex() {\r\n let zIndex = this.renderZIndex + (this.sIndex * 0.01);\r\n let parentNode = this.node.parent;\r\n while (parentNode != this.renderLayer.parent && parentNode != cc.director.getScene()) {\r\n let render = parentNode.getComponent(RenderAlternative);\r\n if (render) {\r\n zIndex += render.zIndex + 1;\r\n break;\r\n }\r\n parentNode = parentNode.parent;\r\n }\r\n return zIndex;\r\n }\r\n\r\n /**\r\n * 设置渲染节点层\r\n * @param layer \r\n */\r\n init(layer?: cc.Node): T {\r\n if (layer) {\r\n this.renderLayer = layer;\r\n }\r\n if (!this.renderLayer) {\r\n console.warn(`节点${this.node.name}没有设置渲染层`)\r\n return null;\r\n }\r\n return this.initRender();\r\n }\r\n /**\r\n * 初始化渲染节点\r\n */\r\n private initRender(): T {\r\n let node = this.getRender();\r\n node.setParent(this.renderLayer ? this.renderLayer : cc.director.getScene().getChildByName(\"Canvas\"));\r\n this.isAttachFrame = true;\r\n requestAnimationFrame(this.frameUpdate.bind(this));\r\n return this.doProxy();\r\n }\r\n /**生成代理 */\r\n private doProxy(): T {\r\n this.proxyRender = new Proxy(this.renderCompnent, new RenderReactiveHandler()) as T;\r\n return this.proxyRender as T;\r\n }\r\n\r\n\r\n protected frameUpdate(): void {\r\n let now = cc.sys.now();\r\n !this.lastFrameTime && (this.lastFrameTime = now);\r\n let dt = now - this.lastFrameTime;\r\n if (this.proxyRender) {\r\n this.accuTime += dt;\r\n if (this.accuTime >= this.syncInv) {\r\n this.accuTime -= this.syncInv;\r\n this.updateProp();\r\n }\r\n }\r\n if (this.isAttachFrame) {\r\n requestAnimationFrame(this.frameUpdate.bind(this));\r\n }\r\n }\r\n\r\n /**更新最新状态 */\r\n public updateProp() {\r\n let node = this.renderCompnent.node;\r\n if (!this.node.activeInHierarchy) {\r\n node.opacity = 0;\r\n return;\r\n }\r\n node.anchorX = this.node.anchorX;\r\n node.anchorY = this.node.anchorY;\r\n node.width = this.node.width;\r\n node.height = this.node.height;\r\n node.group = this.node.group;\r\n node.color = this.node.color;\r\n node.opacity = this.getOpacity(this.node);\r\n\r\n let wMat4 = cc.mat4();\r\n this.node.getWorldMatrix(wMat4);\r\n if (!this.lastWMat4 || !this.lastWMat4.equals(wMat4)) {\r\n let localMatrix = this.getLocalMatrix(wMat4, node);\r\n this.setLocalXYZScaleAngle(localMatrix, node, this.lastLMat4);\r\n this.lastWMat4 = wMat4;\r\n this.lastLMat4 = localMatrix;\r\n }\r\n node.zIndex = this.zIndex;\r\n }\r\n\r\n private getLocalMatrix(worldMatrix: cc.Mat4, node: cc.Node) {\r\n let parentNode = null;\r\n if (cc.isValid(node)) {\r\n if (cc.isValid(node.parent)) {\r\n parentNode = node.parent\r\n }\r\n }\r\n // 获取父节点的世界矩阵\r\n let parentWorldMatrix = cc.mat4();\r\n parentNode.getWorldMatrix(parentWorldMatrix);\r\n // 获取父节点的逆矩阵\r\n let parentInverseMatrix = parentWorldMatrix.invert();\r\n // 将目标节点的世界矩阵转换为父节点的本地矩阵\r\n let localMatrix = parentInverseMatrix.multiply(worldMatrix);\r\n return localMatrix;\r\n\r\n }\r\n\r\n private setLocalXYZScaleAngle(matrix: cc.Mat4, node: cc.Node, lastMatrix?: cc.Mat4) {\r\n if (lastMatrix && matrix.equals(lastMatrix)) {\r\n return;\r\n }\r\n\r\n // 提取位置\r\n node.setPosition(matrix.m[12], matrix.m[13], matrix.m[14]);\r\n\r\n let scaleX = null;\r\n let scaleY = null;\r\n let angle = null;\r\n // 提取缩放X\r\n if (!lastMatrix) {\r\n scaleX = Math.sqrt(matrix.m[0] * matrix.m[0] + matrix.m[1] * matrix.m[1] + matrix.m[2] * matrix.m[2]);\r\n } else if (!this.equalsValue(matrix.m[0], lastMatrix.m[0])\r\n || !this.equalsValue(matrix.m[1], lastMatrix.m[1])\r\n || !this.equalsValue(matrix.m[2], lastMatrix.m[2])) {\r\n scaleX = Math.sqrt(matrix.m[0] * matrix.m[0] + matrix.m[1] * matrix.m[1] + matrix.m[2] * matrix.m[2]);\r\n }\r\n // 提取缩放Y\r\n if (!lastMatrix) {\r\n scaleY = Math.sqrt(matrix.m[4] * matrix.m[4] + matrix.m[5] * matrix.m[5] + matrix.m[6] * matrix.m[6]);\r\n } else if (!this.equalsValue(matrix.m[4], lastMatrix.m[4])\r\n || !this.equalsValue(matrix.m[5], lastMatrix.m[5])\r\n || !this.equalsValue(matrix.m[6], lastMatrix.m[6])) {\r\n scaleY = Math.sqrt(matrix.m[4] * matrix.m[4] + matrix.m[5] * matrix.m[5] + matrix.m[6] * matrix.m[6]);\r\n }\r\n //设置缩放X\r\n if (scaleX !== null) {\r\n node.scaleX = scaleX;\r\n // 提取旋转\r\n angle = Math.atan2(matrix.m[1] / scaleX, matrix.m[0] / scaleX) * (180 / Math.PI);\r\n }\r\n if (scaleY !== null) {\r\n node.scaleY = scaleY;\r\n }\r\n if (angle !== null) {\r\n node.rotation = angle;\r\n }\r\n }\r\n\r\n private equalsValue(a: number, b: number, epsilon: number = 0.00001) {\r\n return Math.abs(a - b) < epsilon;\r\n }\r\n\r\n protected onDestroy(): void {\r\n this.renderCompnent.node.destroy();\r\n this.renderCompnent = null;\r\n this.proxyRender = null;\r\n }\r\n\r\n /**\r\n * 获取节点透明度\r\n * @param node \r\n */\r\n private getOpacity(node: cc.Node) {\r\n let opacity = (node.opacity / 255);\r\n let parentNode = node.parent\r\n while (parentNode != this.renderLayer.parent && parentNode != cc.director.getScene()) {\r\n opacity *= (parentNode.opacity / 255);\r\n parentNode = parentNode.parent;\r\n }\r\n return opacity * 255;\r\n }\r\n /**\r\n * 获取渲染组件\r\n * @param node \r\n */\r\n private getRender() {\r\n let node = cc.instantiate(this.node);\r\n node.removeAllChildren();\r\n this.renderCompnent = node.getComponent(cc.RenderComponent);\r\n this.node.getComponent(cc.LabelOutline)?.destroy();\r\n this.node.getComponent(cc.LabelShadow)?.destroy();\r\n this.node.getComponent(cc.RenderComponent).destroy();\r\n let components = node.getComponents(cc.Component);\r\n for (let i = 0, len = components.length; i < len; ++i) {\r\n let comp = components[i];\r\n if (!((comp instanceof cc.RenderComponent) || (comp instanceof cc.LabelOutline) || (comp instanceof cc.LabelShadow))) {\r\n comp.destroy();\r\n }\r\n }\r\n return node;\r\n }\r\n\r\n}\r\n"]} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/fe/fe1417b6-fe6b-46a4-ae7c-9fd331f33a2a.json b/Layered_virtual_list_2.x/library/imports/fe/fe1417b6-fe6b-46a4-ae7c-9fd331f33a2a.json new file mode 100644 index 0000000..940bec2 --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/fe/fe1417b6-fe6b-46a4-ae7c-9fd331f33a2a.json @@ -0,0 +1,109 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "capsule", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "asyncLoadAssets": false, + "readonly": false + }, + { + "__type__": "cc.Node", + "_name": "capsule", + "_objFlags": 0, + "_parent": null, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 2 + } + ], + "_prefab": { + "__id__": 3 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.MeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "a5849239-3ad3-41d1-8ab4-ae9fea11f97f" + } + ], + "_mesh": { + "__uuid__": "83f5eff8-3385-4f95-9b76-8da0aa1d96cd" + }, + "_receiveShadows": false, + "_shadowCastingMode": 0, + "_enableAutoBatch": false, + "textures": [], + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "fe1417b6-fe6b-46a4-ae7c-9fd331f33a2a" + }, + "fileId": "03MuJmYVpF+Kz929rGKeef", + "sync": false + } +] \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/imports/ff/ff0e91c7-55c6-4086-a39f-cb6e457b8c3b.json b/Layered_virtual_list_2.x/library/imports/ff/ff0e91c7-55c6-4086-a39f-cb6e457b8c3b.json new file mode 100644 index 0000000..b60fd4f --- /dev/null +++ b/Layered_virtual_list_2.x/library/imports/ff/ff0e91c7-55c6-4086-a39f-cb6e457b8c3b.json @@ -0,0 +1,28 @@ +{ + "__type__": "cc.SpriteFrame", + "content": { + "name": "default_editbox_bg", + "texture": "edd215b9-2796-4a05-aaf5-81f96c9281ce", + "atlas": "", + "rect": [ + 0, + 0, + 40, + 40 + ], + "offset": [ + 0, + 0 + ], + "originalSize": [ + 40, + 40 + ], + "capInsets": [ + 12, + 12, + 12, + 12 + ] + } +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/library/uuid-to-mtime.json b/Layered_virtual_list_2.x/library/uuid-to-mtime.json new file mode 100644 index 0000000..872c794 --- /dev/null +++ b/Layered_virtual_list_2.x/library/uuid-to-mtime.json @@ -0,0 +1,597 @@ +{ + "29f52784-2fca-467b-92e7-8fd9ef8c57b7": { + "asset": 1730284156857, + "meta": 1730292644838, + "relativePath": "Scene" + }, + "4734c20c-0db8-4eb2-92ea-e692f4d70934": { + "asset": 1730278649389, + "meta": 1730292644838, + "relativePath": "Script" + }, + "9e17833a-ad49-48e6-a822-d7e1dc2cedf4": { + "asset": 1730253222075, + "meta": 1730253281667, + "relativePath": "Scene\\TestShowNode.ts" + }, + "b4ec1494-dff7-4875-91b7-3837f064a937": { + "asset": 1730253222077, + "meta": 1730253281838, + "relativePath": "Script\\LoopList.ts" + }, + "d38d025a-fb9d-4cf0-bf13-61343069ef50": { + "asset": 1730253222078, + "meta": 1730253281890, + "relativePath": "Script\\RenderReactiveHandler.ts" + }, + "2d2f792f-a40c-49bb-a189-ed176a246e49": { + "asset": 1730253751443, + "meta": 1730253751447, + "relativePath": "Scene\\helloworld.fire" + }, + "6b1c6ed5-0dab-415a-b3cc-4408f270a2d0": { + "asset": 1730269099515, + "meta": 1730269099519, + "relativePath": "Scene\\showNode.prefab" + }, + "75120702-79b9-4d8a-9e06-0ab82828c5ba": { + "asset": 1730253281895, + "meta": 1730253281895, + "relativePath": "Scene\\showNodeH.prefab" + }, + "ad26be66-5bff-4a2d-aa4c-87e71ad64839": { + "asset": 1730278463081, + "meta": 1730278463084, + "relativePath": "Scene\\Demo.fire" + }, + "3a3767fc-5a7c-4f4b-b174-8f4038113095": { + "asset": 1730278401671, + "meta": 1730278401675, + "relativePath": "Scene\\Item.prefab" + }, + "4850b0af-dba5-44dc-b723-5907091dc85e": { + "asset": 1730269779202, + "meta": 1730269783425, + "relativePath": "Scene\\TestLoop.ts" + }, + "9836134e-b892-4283-b6b2-78b5acf3ed45": { + "asset": 1689401789490, + "meta": 1730292640699, + "relativePath": "effects" + }, + "abc2cb62-7852-4525-a90d-d474487b88f2": { + "asset": 1689401789484, + "meta": 1730292640809, + "relativePath": "effects\\builtin-phong.effect" + }, + "e2f00085-c597-422d-9759-52c360279106": { + "asset": 1689401789485, + "meta": 1730292640852, + "relativePath": "effects\\builtin-toon.effect" + }, + "430eccbf-bf2c-4e6e-8c0c-884bbb487f32": { + "asset": 1689401789486, + "meta": 1730292640863, + "relativePath": "effects\\__builtin-editor-gizmo-line.effect" + }, + "6c5cf6e1-b044-4eac-9431-835644d57381": { + "asset": 1689401789487, + "meta": 1730292640869, + "relativePath": "effects\\__builtin-editor-gizmo-unlit.effect" + }, + "115286d1-2e10-49ee-aab4-341583f607e8": { + "asset": 1689401789489, + "meta": 1730292640893, + "relativePath": "effects\\__builtin-editor-gizmo.effect" + }, + "f8e6b000-5643-4b86-9080-aa680ce1f599": { + "asset": 1689401789514, + "meta": 1730292640700, + "relativePath": "image" + }, + "5c3eedba-6c41-4c0c-9ba7-d91f813cbd1c": { + "asset": 1689401789516, + "meta": 1730292640700, + "relativePath": "materials" + }, + "fc09f9bd-2cce-4605-b630-8145ef809ed6": { + "asset": 1689401789519, + "meta": 1730292640701, + "relativePath": "misc" + }, + "db019bf7-f71c-4111-98cf-918ea180cb48": { + "asset": 1689401789531, + "meta": 1730292640701, + "relativePath": "model" + }, + "e39e96e6-6f6e-413f-bcf1-ac7679bb648a": { + "asset": 1689401789528, + "meta": 1730292640928, + "relativePath": "model\\prefab" + }, + "b43ff3c2-02bb-4874-81f7-f2dea6970f18": { + "asset": 1689401789497, + "meta": 1730292640917, + "relativePath": "image\\default_btn_pressed.png" + }, + "71561142-4c83-4933-afca-cb7a17f67053": { + "asset": 1689401789493, + "meta": 1730292640912, + "relativePath": "image\\default_btn_disabled.png" + }, + "e851e89b-faa2-4484-bea6-5c01dd9f06e2": { + "asset": 1689401789496, + "meta": 1730292640915, + "relativePath": "image\\default_btn_normal.png" + }, + "d81ec8ad-247c-4e62-aa3c-d35c4193c7af": { + "asset": 1689401789499, + "meta": 1730292640918, + "relativePath": "image\\default_panel.png" + }, + "f6e6dd15-71d1-4ffe-ace7-24fd39942c05": { + "asset": 1689401789534, + "meta": 1730292640702, + "relativePath": "obsolete" + }, + "cfef78f1-c8df-49b7-8ed0-4c953ace2621": { + "asset": 1689401789500, + "meta": 1730292640919, + "relativePath": "image\\default_progressbar.png" + }, + "99170b0b-d210-46f1-b213-7d9e3f23098a": { + "asset": 1689401789501, + "meta": 1730292640925, + "relativePath": "image\\default_progressbar_bg.png" + }, + "edd215b9-2796-4a05-aaf5-81f96c9281ce": { + "asset": 1689401789498, + "meta": 1730292640914, + "relativePath": "image\\default_editbox_bg.png" + }, + "567dcd80-8bf4-4535-8a5a-313f1caf078a": { + "asset": 1689401789502, + "meta": 1730292640922, + "relativePath": "image\\default_radio_button_off.png" + }, + "f743d2b6-b7ea-4c14-a55b-547ed4d0a045": { + "asset": 1689401789536, + "meta": 1730292640703, + "relativePath": "particle" + }, + "0291c134-b3da-4098-b7b5-e397edbe947f": { + "asset": 1689401789504, + "meta": 1730292640926, + "relativePath": "image\\default_scrollbar.png" + }, + "9d60001f-b5f4-4726-a629-2659e3ded0b8": { + "asset": 1689401789503, + "meta": 1730292640927, + "relativePath": "image\\default_radio_button_on.png" + }, + "ae6c6c98-11e4-452f-8758-75f5c6a56e83": { + "asset": 1689401789568, + "meta": 1730292640703, + "relativePath": "prefab" + }, + "4bab67cb-18e6-4099-b840-355f0473f890": { + "asset": 1689401789505, + "meta": 1730292641010, + "relativePath": "image\\default_scrollbar_bg.png" + }, + "617323dd-11f4-4dd3-8eec-0caf6b3b45b9": { + "asset": 1689401789507, + "meta": 1730292641031, + "relativePath": "image\\default_scrollbar_vertical_bg.png" + }, + "d6d3ca85-4681-47c1-b5dd-d036a9d39ea2": { + "asset": 1689401789506, + "meta": 1730292641032, + "relativePath": "image\\default_scrollbar_vertical.png" + }, + "c4480a0a-6ac5-443f-8b40-361a14257fc8": { + "asset": 1689401789516, + "meta": 1730292641992, + "relativePath": "materials\\builtin-phong.mtl" + }, + "b5fc2cf2-7942-483d-be1f-bbeadc4714ad": { + "asset": 1689401789523, + "meta": 1730292641075, + "relativePath": "model\\prefab\\cone.prefab" + }, + "6e056173-d285-473c-b206-40a7fff5386e": { + "asset": 1689401789509, + "meta": 1730292641028, + "relativePath": "image\\default_sprite.png" + }, + "a87cc147-01b2-43f8-8e42-a7ca90b0c757": { + "asset": 1689401789521, + "meta": 1730292641074, + "relativePath": "model\\prefab\\box.prefab" + }, + "a3ee0214-b432-4865-9666-4a3211814282": { + "asset": 1689401789553, + "meta": 1730292641040, + "relativePath": "prefab\\light" + }, + "73a0903d-d80e-4e3c-aa67-f999543c08f5": { + "asset": 1689401789511, + "meta": 1730292641034, + "relativePath": "image\\default_toggle_checkmark.png" + }, + "fe1417b6-fe6b-46a4-ae7c-9fd331f33a2a": { + "asset": 1689401789522, + "meta": 1730292641090, + "relativePath": "model\\prefab\\capsule.prefab" + }, + "1c5e4038-953a-44c2-b620-0bbfc6170477": { + "asset": 1689401789524, + "meta": 1730292641083, + "relativePath": "model\\prefab\\cylinder.prefab" + }, + "c25b9d50-c8fc-4d27-beeb-6e7c1f2e5c0f": { + "asset": 1689401789512, + "meta": 1730292641036, + "relativePath": "image\\default_toggle_disabled.png" + }, + "6c9ef10d-b479-420b-bfe6-39cdda6a8ae0": { + "asset": 1689401789526, + "meta": 1730292641176, + "relativePath": "model\\prefab\\quad.prefab" + }, + "2d9a4b85-b0ab-4c46-84c5-18f393ab2058": { + "asset": 1689401789527, + "meta": 1730292641194, + "relativePath": "model\\prefab\\sphere.prefab" + }, + "de510076-056b-484f-b94c-83bef217d0e1": { + "asset": 1689401789528, + "meta": 1730292641196, + "relativePath": "model\\prefab\\torus.prefab" + }, + "600301aa-3357-4a10-b086-84f011fa32ba": { + "asset": 1689401789492, + "meta": 1730292640920, + "relativePath": "image\\default-particle.png" + }, + "897ef7a1-4860-4f64-968d-f5924b18668a": { + "asset": 1689401789539, + "meta": 1730292641042, + "relativePath": "prefab\\2d-camera.prefab" + }, + "3f376125-a699-40ca-ad05-04d662eaa1f2": { + "asset": 1689401789524, + "meta": 1730292641161, + "relativePath": "model\\prefab\\plane.prefab" + }, + "70d7cdb0-04cd-41bb-9480-c06a4785f386": { + "asset": 1689401789540, + "meta": 1730292641043, + "relativePath": "prefab\\3d-camera.prefab" + }, + "0275e94c-56a7-410f-bd1a-fc7483f7d14a": { + "asset": 1689401789510, + "meta": 1730292641029, + "relativePath": "image\\default_sprite_splash.png" + }, + "ed88f13d-fcad-4848-aa35-65a2cb973584": { + "asset": 1689401789542, + "meta": 1730292641044, + "relativePath": "prefab\\3d-stage.prefab" + }, + "70bbeb73-6dc2-4ee4-8faf-76b3a0e34ec4": { + "asset": 1689401789541, + "meta": 1730292641046, + "relativePath": "prefab\\3d-particle.prefab" + }, + "d29077ba-1627-4a72-9579-7b56a235340c": { + "asset": 1689401789513, + "meta": 1730292641033, + "relativePath": "image\\default_toggle_normal.png" + }, + "2c937608-2562-40ea-b264-7395df6f0cea": { + "asset": 1689401789544, + "meta": 1730292641047, + "relativePath": "prefab\\canvas.prefab" + }, + "972b9a4d-47ee-4c74-b5c3-61d8a69bc29f": { + "asset": 1689401789543, + "meta": 1730292641048, + "relativePath": "prefab\\button.prefab" + }, + "b181c1e4-0a72-4a91-bfb0-ae6f36ca60bd": { + "asset": 1689401789513, + "meta": 1730292641037, + "relativePath": "image\\default_toggle_pressed.png" + }, + "61aeb05b-3b32-452b-8eed-2b76deeed554": { + "asset": 1689401789544, + "meta": 1730292641051, + "relativePath": "prefab\\editbox.prefab" + }, + "27756ebb-3d33-44b0-9b96-e858fadd4dd4": { + "asset": 1689401789546, + "meta": 1730292641052, + "relativePath": "prefab\\label.prefab" + }, + "785a442c-3ceb-45be-a46e-7317f625f3b9": { + "asset": 1689401789546, + "meta": 1730292641053, + "relativePath": "prefab\\layout.prefab" + }, + "ca8401fe-ad6e-41a8-bd46-8e3e4e9945be": { + "asset": 1689401789553, + "meta": 1730292641056, + "relativePath": "prefab\\pageview.prefab" + }, + "5965ffac-69da-4b55-bcde-9225d0613c28": { + "asset": 1689401789556, + "meta": 1730292641059, + "relativePath": "prefab\\progressBar.prefab" + }, + "cd33edea-55f5-46c2-958d-357a01384a36": { + "asset": 1689401789555, + "meta": 1730292641055, + "relativePath": "prefab\\particlesystem.prefab" + }, + "4a37dd57-78cd-4cec-aad4-f11a73d12b63": { + "asset": 1689401789557, + "meta": 1730292641057, + "relativePath": "prefab\\richtext.prefab" + }, + "d8afc78c-4eac-4a9f-83dd-67bc70344d33": { + "asset": 1689401789579, + "meta": 1730292640704, + "relativePath": "resources" + }, + "0004d1cf-a0ad-47d8-ab17-34d3db9d35a3": { + "asset": 1689401789558, + "meta": 1730292641063, + "relativePath": "prefab\\slider.prefab" + }, + "294c1663-4adf-4a1e-a795-53808011a38a": { + "asset": 1689401789578, + "meta": 1730292641060, + "relativePath": "resources\\effects" + }, + "32044bd2-481f-4cf1-a656-e2b2fb1594eb": { + "asset": 1689401789557, + "meta": 1730292641061, + "relativePath": "prefab\\scrollview.prefab" + }, + "bbee2217-c261-49bd-a8ce-708d6bcc3500": { + "asset": 1689401789588, + "meta": 1730292641062, + "relativePath": "resources\\materials" + }, + "96083d03-c332-4a3f-9386-d03e2d19e8ee": { + "asset": 1689401789559, + "meta": 1730292641058, + "relativePath": "prefab\\sprite.prefab" + }, + "30682f87-9f0d-4f17-8a44-72863791461b": { + "asset": 1689401789570, + "meta": 1730292641082, + "relativePath": "resources\\effects\\builtin-2d-graphics.effect" + }, + "1f55e3be-b89b-4b79-88de-47fd31018044": { + "asset": 1689401789560, + "meta": 1730292641064, + "relativePath": "prefab\\sprite_splash.prefab" + }, + "144c3297-af63-49e8-b8ef-1cfa29b3be28": { + "asset": 1689401789571, + "meta": 1730292641089, + "relativePath": "resources\\effects\\builtin-2d-gray-sprite.effect" + }, + "7de03a80-4457-438d-95a7-3e7cdffd6086": { + "asset": 1689401789561, + "meta": 1730292641065, + "relativePath": "prefab\\tiledmap.prefab" + }, + "f18742d7-56d2-4eb5-ae49-2d9d710b37c8": { + "asset": 1689401789572, + "meta": 1730292641098, + "relativePath": "resources\\effects\\builtin-2d-label.effect" + }, + "0e93aeaa-0b53-4e40-b8e0-6268b4e07bd7": { + "asset": 1689401789573, + "meta": 1730292641105, + "relativePath": "resources\\effects\\builtin-2d-spine.effect" + }, + "2874f8dd-416c-4440-81b7-555975426e93": { + "asset": 1689401789574, + "meta": 1730292641110, + "relativePath": "resources\\effects\\builtin-2d-sprite.effect" + }, + "829a282c-b049-4019-bd38-5ace8d8a6417": { + "asset": 1689401789575, + "meta": 1730292641160, + "relativePath": "resources\\effects\\builtin-3d-particle.effect" + }, + "2a7c0036-e0b3-4fe1-8998-89a54b8a2bec": { + "asset": 1689401789576, + "meta": 1730292641174, + "relativePath": "resources\\effects\\builtin-3d-trail.effect" + }, + "c0040c95-c57f-49cd-9cbc-12316b73d0d4": { + "asset": 1689401789577, + "meta": 1730292641180, + "relativePath": "resources\\effects\\builtin-clear-stencil.effect" + }, + "6d91e591-4ce0-465c-809f-610ec95019c6": { + "asset": 1689401789578, + "meta": 1730292641192, + "relativePath": "resources\\effects\\builtin-unlit.effect" + }, + "bf0a434c-84dd-4a8e-a08a-7a36f180cc75": { + "asset": 1689401789564, + "meta": 1730292641069, + "relativePath": "prefab\\toggleContainer.prefab" + }, + "0e42ba95-1fa1-46aa-b2cf-143cd1bcee2c": { + "asset": 1689401789562, + "meta": 1730292641066, + "relativePath": "prefab\\tiledtile.prefab" + }, + "0d784963-d024-4ea6-a7db-03be0ad63010": { + "asset": 1689401789563, + "meta": 1730292641068, + "relativePath": "prefab\\toggle.prefab" + }, + "d1b8be49-b0a0-435c-83b7-552bed4bbe35": { + "asset": 1689401789565, + "meta": 1730292641073, + "relativePath": "prefab\\toggleGroup.prefab" + }, + "232d2782-c4bd-4bb4-9e01-909f03d6d3b9": { + "asset": 1689401789567, + "meta": 1730292641070, + "relativePath": "prefab\\videoplayer.prefab" + }, + "8c5001fd-07ee-4a4b-a8a0-63e15195e94d": { + "asset": 1689401789567, + "meta": 1730292641072, + "relativePath": "prefab\\webview.prefab" + }, + "2be36297-9abb-4fee-8049-9ed5e271da8a": { + "asset": 1689401789519, + "meta": 1730292641038, + "relativePath": "misc\\default_video.mp4" + }, + "ddb99b39-7004-47cd-9705-751905c43c46": { + "asset": 1689401789550, + "meta": 1730292641199, + "relativePath": "prefab\\light\\directional.prefab" + }, + "0cf30284-9073-46bc-9eba-e62b69dbbff3": { + "asset": 1689401789551, + "meta": 1730292641201, + "relativePath": "prefab\\light\\point.prefab" + }, + "61906da3-7003-4bda-9abc-5769c76faee4": { + "asset": 1689401789549, + "meta": 1730292641198, + "relativePath": "prefab\\light\\ambient.prefab" + }, + "f5331fd2-bf42-4ee3-a3fd-3e1657600eff": { + "asset": 1689401789552, + "meta": 1730292641200, + "relativePath": "prefab\\light\\spot.prefab" + }, + "6f801092-0c37-4f30-89ef-c8d960825b36": { + "asset": 1689401789579, + "meta": 1730292642010, + "relativePath": "resources\\materials\\builtin-2d-base.mtl" + }, + "a153945d-2511-4c14-be7b-05d242f47d57": { + "asset": 1689401789580, + "meta": 1730292642012, + "relativePath": "resources\\materials\\builtin-2d-graphics.mtl" + }, + "e02d87d4-e599-4d16-8001-e14891ac6506": { + "asset": 1689401789582, + "meta": 1730292642011, + "relativePath": "resources\\materials\\builtin-2d-label.mtl" + }, + "7afd064b-113f-480e-b793-8817d19f63c3": { + "asset": 1689401789583, + "meta": 1730292642013, + "relativePath": "resources\\materials\\builtin-2d-spine.mtl" + }, + "3a7bb79f-32fd-422e-ada2-96f518fed422": { + "asset": 1689401789581, + "meta": 1730292642012, + "relativePath": "resources\\materials\\builtin-2d-gray-sprite.mtl" + }, + "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432": { + "asset": 1689401789584, + "meta": 1730292642013, + "relativePath": "resources\\materials\\builtin-2d-sprite.mtl" + }, + "cf7e0bb8-a81c-44a9-ad79-d28d43991032": { + "asset": 1689401789587, + "meta": 1730292642020, + "relativePath": "resources\\materials\\builtin-clear-stencil.mtl" + }, + "2a296057-247c-4a1c-bbeb-0548b6c98650": { + "asset": 1689401789588, + "meta": 1730292642021, + "relativePath": "resources\\materials\\builtin-unlit.mtl" + }, + "432fa09c-cf03-4cff-a186-982604408a07": { + "asset": 1689401789585, + "meta": 1730292642014, + "relativePath": "resources\\materials\\builtin-3d-particle.mtl" + }, + "466d4f9b-e5f4-4ea8-85d5-3c6e9a65658a": { + "asset": 1689401789586, + "meta": 1730292642019, + "relativePath": "resources\\materials\\builtin-3d-trail.mtl" + }, + "d0a82d39-bede-46c4-b698-c81ff0dedfff": { + "asset": 1689401789536, + "meta": 1730292641049, + "relativePath": "particle\\atom.png" + }, + "8a96b965-2dc0-4e03-aa90-3b79cb93b5b4": { + "asset": 1689401789533, + "meta": 1730292641040, + "relativePath": "obsolete\\atom.png" + }, + "b2687ac4-099e-403c-a192-ff477686f4f5": { + "asset": 1689401789535, + "meta": 1730292642042, + "relativePath": "particle\\atom.plist" + }, + "b8223619-7e38-47c4-841f-9160c232495a": { + "asset": 1689401789532, + "meta": 1730292642042, + "relativePath": "obsolete\\atom.plist" + }, + "954fec8b-cd16-4bb9-a3b7-7719660e7558": { + "asset": 1689401789530, + "meta": 1730292644827, + "relativePath": "model\\primitives.fbx" + }, + "d33f6314-18ec-4937-978c-27d5334b7287": { + "asset": 1730277692043, + "meta": 1730277701265, + "relativePath": "Script\\RenderAlternativeItem.ts" + }, + "7e1f6966-c75d-4786-8f41-355dcca8a919": { + "asset": 1730278488785, + "meta": 1730278495096, + "relativePath": "Scene\\Item.ts" + }, + "1b4785ab-e079-4c84-b756-9c959c0fa7e2": { + "asset": 1730278636856, + "meta": 1730278649425, + "relativePath": "Script\\RenderAlternative_old.ts" + }, + "3ed1232c-1b00-4818-8d5e-2112f30b11a4": { + "asset": 1730298620419, + "meta": 1730298620422, + "relativePath": "Scene\\TestMatrix.fire" + }, + "41fb71e5-8482-4dcd-9324-49aab7d6bc8f": { + "asset": 1730299956994, + "meta": 1730299959425, + "relativePath": "Scene\\TestMatrix.ts" + }, + "5be1578b-9d99-422a-a3ca-e01dd8e09eb1": { + "asset": 1730303368341, + "meta": 1730303759223, + "relativePath": "Script\\RenderAlternative1.ts" + }, + "b9be0b60-a085-4f93-bd8b-884e8ddfd7ff": { + "asset": 1730303823696, + "meta": 1730303828137, + "relativePath": "Scene\\TestRenderAlternative.ts" + }, + "f9782c63-e103-4af3-8d8e-007a1a6d115b": { + "asset": 1730304131082, + "meta": 1730304134093, + "relativePath": "Script\\RenderAlternative.ts" + } +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/local/builder.json b/Layered_virtual_list_2.x/local/builder.json new file mode 100644 index 0000000..b3efeaf --- /dev/null +++ b/Layered_virtual_list_2.x/local/builder.json @@ -0,0 +1,20 @@ +{ + "platform": "web-mobile", + "actualPlatform": "web-mobile", + "template": "link", + "buildPath": "./build", + "debug": true, + "sourceMaps": false, + "embedWebDebugger": false, + "previewWidth": "1280", + "previewHeight": "720", + "useDebugKeystore": true, + "keystorePath": "", + "keystorePassword": "", + "keystoreAlias": "", + "keystoreAliasPassword": "", + "apiLevel": "", + "appABIs": [], + "vsVersion": "auto", + "buildScriptsOnly": false +} diff --git a/Layered_virtual_list_2.x/local/layout.editor.json b/Layered_virtual_list_2.x/local/layout.editor.json new file mode 100644 index 0000000..e96d03e --- /dev/null +++ b/Layered_virtual_list_2.x/local/layout.editor.json @@ -0,0 +1,118 @@ +{ + "version": "1.1.1", + "windows": { + "main": { + "main": true, + "url": "app://editor/index.html", + "windowType": "dockable", + "x": 0, + "y": 0, + "width": 1920, + "height": 1040, + "layout": { + "type": "dock-h", + "children": [ + { + "width": 553.328125, + "height": 922, + "type": "dock-v", + "children": [ + { + "width": 553.328125, + "height": 318.921875, + "type": "panel", + "active": 0, + "children": [ + "hierarchy" + ] + }, + { + "width": 553.328125, + "height": 600.078125, + "type": "panel", + "active": 0, + "children": [ + "assets" + ] + } + ] + }, + { + "width": 646.546875, + "height": 922, + "type": "dock-v", + "children": [ + { + "width": 646.546875, + "height": 458.5, + "type": "dock-h", + "children": [ + { + "width": 379.546875, + "height": 458.5, + "type": "panel", + "active": 0, + "children": [ + "scene" + ] + }, + { + "width": 264, + "height": 458.5, + "type": "panel", + "active": 0, + "children": [ + "node-library" + ] + } + ] + }, + { + "width": 646.546875, + "height": 460.5, + "type": "panel", + "active": 0, + "children": [ + "console", + "timeline", + "game-window" + ] + } + ] + }, + { + "width": 698.109375, + "height": 922, + "type": "panel", + "active": 0, + "children": [ + "inspector", + "cocos-services" + ] + } + ] + }, + "panels": [ + "hierarchy", + "assets", + "scene", + "node-library", + "console", + "timeline", + "game-window", + "inspector", + "cocos-services" + ] + }, + " common-asset-worker-worker": {} + }, + "panels": { + "builder": { + "x": 702, + "y": 136, + "width": 516, + "height": 739 + } + }, + "panelLabelWidth": {} +} diff --git a/Layered_virtual_list_2.x/local/local.json b/Layered_virtual_list_2.x/local/local.json new file mode 100644 index 0000000..acf7caf --- /dev/null +++ b/Layered_virtual_list_2.x/local/local.json @@ -0,0 +1,11 @@ +{ + "last-edit": "ad26be66-5bff-4a2d-aa4c-87e71ad64839", + "recent-items": [ + "75120702-79b9-4d8a-9e06-0ab82828c5ba", + "6b1c6ed5-0dab-415a-b3cc-4408f270a2d0", + "3a3767fc-5a7c-4f4b-b174-8f4038113095", + "2d2f792f-a40c-49bb-a189-ed176a246e49", + "3ed1232c-1b00-4818-8d5e-2112f30b11a4", + "ad26be66-5bff-4a2d-aa4c-87e71ad64839" + ] +} diff --git a/Layered_virtual_list_2.x/local/node-library.json b/Layered_virtual_list_2.x/local/node-library.json new file mode 100644 index 0000000..4493d9b --- /dev/null +++ b/Layered_virtual_list_2.x/local/node-library.json @@ -0,0 +1,6 @@ +{ + "user": { + "name": "User", + "prefab": [] + } +} diff --git a/Layered_virtual_list_2.x/local/node-tree-state.json b/Layered_virtual_list_2.x/local/node-tree-state.json new file mode 100644 index 0000000..f56ff12 --- /dev/null +++ b/Layered_virtual_list_2.x/local/node-tree-state.json @@ -0,0 +1,3 @@ +{ + "nodeFoldStates": [] +} diff --git a/Layered_virtual_list_2.x/project.json b/Layered_virtual_list_2.x/project.json new file mode 100644 index 0000000..7b5e950 --- /dev/null +++ b/Layered_virtual_list_2.x/project.json @@ -0,0 +1,8 @@ +{ + "engine": "cocos2d-html5", + "packages": "packages", + "version": "2.4.9", + "name": "NewProject", + "id": "70b6bc84-f9c1-4ffa-89f5-f89dc56ad0ce", + "isNew": false +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/settings/builder.json b/Layered_virtual_list_2.x/settings/builder.json new file mode 100644 index 0000000..36ecdb7 --- /dev/null +++ b/Layered_virtual_list_2.x/settings/builder.json @@ -0,0 +1,55 @@ +{ + "title": "Layered_virtual_list_2x", + "packageName": "org.cocos2d.demo", + "startScene": "2d2f792f-a40c-49bb-a189-ed176a246e49", + "excludeScenes": [], + "orientation": { + "landscapeRight": true, + "landscapeLeft": true, + "portrait": false, + "upsideDown": false + }, + "webOrientation": "auto", + "inlineSpriteFrames": true, + "inlineSpriteFrames_native": true, + "mainCompressionType": "default", + "mainIsRemote": false, + "optimizeHotUpdate": false, + "md5Cache": true, + "nativeMd5Cache": true, + "encryptJs": true, + "xxteaKey": "d311a1fe-b5a5-41", + "zipCompressJs": true, + "fb-instant-games": {}, + "android": { + "packageName": "org.cocos2d.demo", + "REMOTE_SERVER_ROOT": "" + }, + "ios": { + "packageName": "org.cocos2d.demo", + "REMOTE_SERVER_ROOT": "", + "ios_enable_jit": true + }, + "mac": { + "packageName": "org.cocos2d.demo", + "REMOTE_SERVER_ROOT": "", + "width": 1280, + "height": 720 + }, + "win32": { + "REMOTE_SERVER_ROOT": "", + "width": 1280, + "height": 720 + }, + "android-instant": { + "packageName": "org.cocos2d.demo", + "REMOTE_SERVER_ROOT": "", + "pathPattern": "", + "scheme": "https", + "host": "", + "skipRecord": false, + "recordPath": "" + }, + "appBundle": false, + "agreements": {} +} diff --git a/Layered_virtual_list_2.x/settings/project.json b/Layered_virtual_list_2.x/settings/project.json new file mode 100644 index 0000000..9fc352b --- /dev/null +++ b/Layered_virtual_list_2.x/settings/project.json @@ -0,0 +1,40 @@ +{ + "group-list": [ + "default" + ], + "collision-matrix": [ + [ + true + ] + ], + "excluded-modules": [ + "3D Physics/Builtin" + ], + "preview-port": 7456, + "design-resolution-width": 1334, + "design-resolution-height": 750, + "fit-width": false, + "fit-height": true, + "use-project-simulator-setting": false, + "simulator-orientation": false, + "use-customize-simulator": true, + "simulator-resolution": { + "width": 960, + "height": 640 + }, + "clear-simulator-cache": true, + "facebook": { + "enable": false, + "appID": "", + "live": { + "enable": false + }, + "audience": { + "enable": false + } + }, + "migrate-history": [ + "cloud-function" + ], + "last-module-event-record-time": 1730253939253 +} diff --git a/Layered_virtual_list_2.x/settings/services.json b/Layered_virtual_list_2.x/settings/services.json new file mode 100644 index 0000000..599b09e --- /dev/null +++ b/Layered_virtual_list_2.x/settings/services.json @@ -0,0 +1,6 @@ +{ + "game": { + "name": "未知游戏", + "appid": "UNKNOW" + } +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/temp/BackupAssets/assets/Scene/Demo.fire b/Layered_virtual_list_2.x/temp/BackupAssets/assets/Scene/Demo.fire new file mode 100644 index 0000000..1082c5c --- /dev/null +++ b/Layered_virtual_list_2.x/temp/BackupAssets/assets/Scene/Demo.fire @@ -0,0 +1,2468 @@ +[ + { + "__type__": "cc.SceneAsset", + "_name": "", + "_objFlags": 0, + "_native": "", + "scene": { + "__id__": 1 + } + }, + { + "__type__": "cc.Scene", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + } + ], + "_active": false, + "_components": [], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_is3DNode": true, + "_groupIndex": 0, + "groupIndex": 0, + "autoReleaseAssets": false, + "_id": "ad26be66-5bff-4a2d-aa4c-87e71ad64839" + }, + { + "__type__": "cc.Node", + "_name": "Canvas", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 3 + }, + { + "__id__": 5 + }, + { + "__id__": 14 + }, + { + "__id__": 34 + }, + { + "__id__": 49 + } + ], + "_active": true, + "_components": [ + { + "__id__": 56 + }, + { + "__id__": 57 + }, + { + "__id__": 58 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 252, + "g": 252, + "b": 252, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 750, + "height": 1334 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 375, + 667, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "a286bbGknJLZpRpxROV6M94" + }, + { + "__type__": "cc.Node", + "_name": "Main Camera", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 4 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "09K3aRxxtPX4CkhgKEDjJC" + }, + { + "__type__": "cc.Camera", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 3 + }, + "_enabled": true, + "_cullingMask": 4294967295, + "_clearFlags": 7, + "_backgroundColor": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_depth": -1, + "_zoomRatio": 1, + "_targetTexture": null, + "_fov": 60, + "_orthoSize": 10, + "_nearClip": 1, + "_farClip": 4096, + "_ortho": true, + "_rect": { + "__type__": "cc.Rect", + "x": 0, + "y": 0, + "width": 1, + "height": 1 + }, + "_renderStages": 1, + "_alignWithScreen": true, + "_id": "39hvvfgtBNGI33C9knv3qJ" + }, + { + "__type__": "cc.Node", + "_name": "Horizontal", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [ + { + "__id__": 6 + } + ], + "_active": false, + "_components": [ + { + "__id__": 12 + }, + { + "__id__": 13 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 500, + "height": 1000 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "36VvP0G09KXaygeBwQJi38" + }, + { + "__type__": "cc.Node", + "_name": "view", + "_objFlags": 0, + "_parent": { + "__id__": 5 + }, + "_children": [ + { + "__id__": 7 + } + ], + "_active": true, + "_components": [ + { + "__id__": 10 + }, + { + "__id__": 11 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 500, + "height": 1000 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -250, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "5cVJZx64VDAbE0+GHS+ljM" + }, + { + "__type__": "cc.Node", + "_name": "content", + "_objFlags": 0, + "_parent": { + "__id__": 6 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 8 + }, + { + "__id__": 9 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 220, + "height": 1000 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "044WGrpVlJX6HvptTPUEC1" + }, + { + "__type__": "cc.Layout", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 7 + }, + "_enabled": true, + "_layoutSize": { + "__type__": "cc.Size", + "width": 220, + "height": 1000 + }, + "_resize": 1, + "_N$layoutType": 1, + "_N$cellSize": { + "__type__": "cc.Size", + "width": 40, + "height": 40 + }, + "_N$startAxis": 0, + "_N$paddingLeft": 0, + "_N$paddingRight": 0, + "_N$paddingTop": 0, + "_N$paddingBottom": 0, + "_N$spacingX": 0, + "_N$spacingY": 5, + "_N$verticalDirection": 1, + "_N$horizontalDirection": 0, + "_N$affectedByScale": false, + "_id": "55aN0610JMRq/gQKnyzhAY" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 7 + }, + "_enabled": true, + "alignMode": 1, + "_target": null, + "_alignFlags": 13, + "_left": 0, + "_right": 280, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 220, + "_originalHeight": 0, + "_id": "e4s1D76VBHvauUganIA4KW" + }, + { + "__type__": "cc.Mask", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 6 + }, + "_enabled": false, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_spriteFrame": null, + "_type": 0, + "_segments": 64, + "_N$alphaThreshold": 0, + "_N$inverted": false, + "_id": "bf6UMcWrhOr4jcJ8Xr/ccS" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 6 + }, + "_enabled": true, + "alignMode": 1, + "_target": null, + "_alignFlags": 45, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 240, + "_originalHeight": 250, + "_id": "795+OK4EFMo68XgmKpU2O+" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 5 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "9bbda31e-ad49-43c9-aaf2-f7d9896bac69" + }, + "_type": 1, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "27RDHW2iJEgbMioz+T5We3" + }, + { + "__type__": "cc.ScrollView", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 5 + }, + "_enabled": true, + "horizontal": true, + "vertical": false, + "inertia": true, + "brake": 0.75, + "elastic": true, + "bounceDuration": 0.23, + "scrollEvents": [], + "cancelInnerEvents": true, + "_N$content": { + "__id__": 7 + }, + "content": { + "__id__": 7 + }, + "_N$horizontalScrollBar": null, + "_N$verticalScrollBar": null, + "_id": "9f7KeQvGdBb42l9mua/S+H" + }, + { + "__type__": "cc.Node", + "_name": "parent", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [ + { + "__id__": 15 + }, + { + "__id__": 21 + }, + { + "__id__": 27 + } + ], + "_active": false, + "_components": [ + { + "__id__": 33 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 40, + "g": 168, + "b": 45, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 500, + "height": 500 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "4eapwQhy9FJr1oDtIF5XMt" + }, + { + "__type__": "cc.Node", + "_name": "1", + "_objFlags": 0, + "_parent": { + "__id__": 14 + }, + "_children": [ + { + "__id__": 16 + } + ], + "_active": true, + "_components": [ + { + "__id__": 19 + }, + { + "__id__": 20 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 100 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -80.714, + 123.761, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "cclp30DuxPI40Ql8RTgIp5" + }, + { + "__type__": "cc.Node", + "_name": "New Label", + "_objFlags": 0, + "_parent": { + "__id__": 15 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 17 + }, + { + "__id__": 18 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 22.25, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "d1NK110VBOjL8p0409QsTv" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 16 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_string": "1", + "_N$string": "1", + "_fontSize": 40, + "_lineHeight": 40, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_styleFlags": 0, + "_underlineHeight": 0, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 2, + "_id": "1ec9ZPVK9DiY33RUQtjAmR" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 16 + }, + "_enabled": true, + "renderZIndex": 0, + "syncInv": 0, + "_id": "28rh4vPCtDH7mfQfnunwP+" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 15 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "dctkJzgctIRbPAF7CX/X0D" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 15 + }, + "_enabled": true, + "renderZIndex": 0, + "syncInv": 0, + "_id": "34s75vARxOxYwCNg9irB9g" + }, + { + "__type__": "cc.Node", + "_name": "2", + "_objFlags": 0, + "_parent": { + "__id__": 14 + }, + "_children": [ + { + "__id__": 22 + } + ], + "_active": true, + "_components": [ + { + "__id__": 25 + }, + { + "__id__": 26 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 184, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 100 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -80.714, + 123.761, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "f3s/MnZNRHTIi/Q+H1UxKx" + }, + { + "__type__": "cc.Node", + "_name": "New Label", + "_objFlags": 0, + "_parent": { + "__id__": 21 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 23 + }, + { + "__id__": 24 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 22.25, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "d32B7NZuBGY63WBdbVTVyG" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 22 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_string": "2", + "_N$string": "2", + "_fontSize": 40, + "_lineHeight": 40, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_styleFlags": 0, + "_underlineHeight": 0, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 2, + "_id": "14NDOGnfhG9K+YOHXLcfhJ" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 22 + }, + "_enabled": true, + "renderZIndex": 0, + "syncInv": 0, + "_id": "3b2tZBLXFLfbVjUa9moptZ" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 21 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "56VszVbJ5PB7PzxYIgK1UZ" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 21 + }, + "_enabled": true, + "renderZIndex": 0, + "syncInv": 0, + "_id": "98jNMDg2NNpL0CwReAWY24" + }, + { + "__type__": "cc.Node", + "_name": "3", + "_objFlags": 0, + "_parent": { + "__id__": 14 + }, + "_children": [ + { + "__id__": 28 + } + ], + "_active": true, + "_components": [ + { + "__id__": 31 + }, + { + "__id__": 32 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 10, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 100 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -80.714, + 123.761, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "1e4i8OlSlN1L+L8ylsTJMp" + }, + { + "__type__": "cc.Node", + "_name": "New Label", + "_objFlags": 0, + "_parent": { + "__id__": 27 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 29 + }, + { + "__id__": 30 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 22.25, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "d8eW94wH5Emo/po5DP/fed" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 28 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_string": "3", + "_N$string": "3", + "_fontSize": 40, + "_lineHeight": 40, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_styleFlags": 0, + "_underlineHeight": 0, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 2, + "_id": "7fju1YtiROgKcUrz8Jbxoo" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 28 + }, + "_enabled": true, + "renderZIndex": 0, + "syncInv": 0, + "_id": "04gNKYOURMUYIzBSFmEZQb" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 27 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "e3/Rip1ZxCQrAeRRXarp6n" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 27 + }, + "_enabled": true, + "renderZIndex": 0, + "syncInv": 0, + "_id": "27WCjM2uhB5pVrJMpptJfp" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 14 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "69pO2jE6tFNr13iHtLu7XS" + }, + { + "__type__": "cc.Node", + "_name": "New ScrollView", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [ + { + "__id__": 35 + }, + { + "__id__": 41 + } + ], + "_active": true, + "_components": [ + { + "__id__": 48 + }, + { + "__id__": 39 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 750, + "height": 800 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "4eGuzFXoZNobw3BF4ASKAl" + }, + { + "__type__": "cc.Node", + "_name": "scrollBar", + "_objFlags": 512, + "_parent": { + "__id__": 34 + }, + "_children": [ + { + "__id__": 36 + } + ], + "_active": true, + "_components": [ + { + "__id__": 38 + }, + { + "__id__": 46 + }, + { + "__id__": 47 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 12, + "height": 800 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 1, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 375, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "8akGSmvKdGfpkBdpJRBHZE" + }, + { + "__type__": "cc.Node", + "_name": "bar", + "_objFlags": 512, + "_parent": { + "__id__": 35 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 37 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 10, + "height": 30 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 1, + "y": 0 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -1, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "7bmTftw15O4qa5K7nMaeeP" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 36 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "5c3bb932-6c3c-468f-88a9-c8c61d458641" + }, + "_type": 1, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "d1YRo81MlPh75Wn1ly3AHz" + }, + { + "__type__": "cc.Scrollbar", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 35 + }, + "_enabled": true, + "_scrollView": { + "__id__": 39 + }, + "_touching": false, + "_opacity": 255, + "enableAutoHide": true, + "autoHideTime": 1, + "_N$handle": { + "__id__": 37 + }, + "_N$direction": 1, + "_id": "0aw0b7ZDtMv4f4xfCJmUds" + }, + { + "__type__": "cc.ScrollView", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 34 + }, + "_enabled": true, + "horizontal": false, + "vertical": true, + "inertia": true, + "brake": 0.75, + "elastic": true, + "bounceDuration": 0.23, + "scrollEvents": [], + "cancelInnerEvents": true, + "_N$content": { + "__id__": 40 + }, + "content": { + "__id__": 40 + }, + "_N$horizontalScrollBar": null, + "_N$verticalScrollBar": { + "__id__": 38 + }, + "_id": "a15DEfCgFF96pX2ZD3tyRp" + }, + { + "__type__": "cc.Node", + "_name": "content", + "_objFlags": 0, + "_parent": { + "__id__": 41 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 44 + }, + { + "__id__": 45 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 750, + "height": 400 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 1 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 400, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "eaaskmjr1JNpm0IyW6NXUv" + }, + { + "__type__": "cc.Node", + "_name": "view", + "_objFlags": 512, + "_parent": { + "__id__": 34 + }, + "_children": [ + { + "__id__": 40 + }, + { + "__id__": 42 + } + ], + "_active": true, + "_components": [ + { + "__id__": 43 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 750, + "height": 800 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "0eJGBTx2lAfZ5rKiVwDRan" + }, + { + "__type__": "cc.Node", + "_name": "layer", + "_objFlags": 0, + "_parent": { + "__id__": 41 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "57l2vDrEVENoXOVjZya0Sq" + }, + { + "__type__": "cc.Mask", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 41 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_spriteFrame": null, + "_type": 0, + "_segments": 64, + "_N$alphaThreshold": 0, + "_N$inverted": false, + "_id": "eagMrCa6xBFYH2Zf5TZb6W" + }, + { + "__type__": "cc.Layout", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 40 + }, + "_enabled": true, + "_layoutSize": { + "__type__": "cc.Size", + "width": 750, + "height": 400 + }, + "_resize": 1, + "_N$layoutType": 2, + "_N$cellSize": { + "__type__": "cc.Size", + "width": 40, + "height": 40 + }, + "_N$startAxis": 0, + "_N$paddingLeft": 0, + "_N$paddingRight": 0, + "_N$paddingTop": 0, + "_N$paddingBottom": 0, + "_N$spacingX": 0, + "_N$spacingY": 10, + "_N$verticalDirection": 1, + "_N$horizontalDirection": 0, + "_N$affectedByScale": false, + "_id": "0a0C+3FExHp6QjuUrpje5d" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 40 + }, + "_enabled": true, + "alignMode": 1, + "_target": null, + "_alignFlags": 41, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 220, + "_originalHeight": 0, + "_id": "b0bf5HmcdPO6RE8va/SD78" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 35 + }, + "_enabled": true, + "alignMode": 0, + "_target": null, + "_alignFlags": 37, + "_left": 350.07654921020657, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 0, + "_originalHeight": 237, + "_id": "0aL6Pd3k1COanH0KlFfNJT" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 35 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "5fe5dcaa-b513-4dc5-a166-573627b3a159" + }, + "_type": 1, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "028UkzTehDxJuY5Slc8IhY" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 34 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "9bbda31e-ad49-43c9-aaf2-f7d9896bac69" + }, + "_type": 1, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "ffF25iPJlH+Kxp09D8v2RS" + }, + { + "__type__": "cc.Node", + "_name": "New Button", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [ + { + "__id__": 50 + } + ], + "_active": true, + "_components": [ + { + "__id__": 55 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + -488.632, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "4eYy0vpB1LBY2A3u7SD33M" + }, + { + "__type__": "cc.Node", + "_name": "Background", + "_objFlags": 512, + "_parent": { + "__id__": 49 + }, + "_children": [ + { + "__id__": 51 + } + ], + "_active": true, + "_components": [ + { + "__id__": 53 + }, + { + "__id__": 54 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 0 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "74AS41UFlDxoKuiVw7MDrT" + }, + { + "__type__": "cc.Node", + "_name": "Label", + "_objFlags": 512, + "_parent": { + "__id__": 50 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 52 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "01ioYlqgpO3Zz31GV3fSke" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 51 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_string": "button", + "_N$string": "button", + "_fontSize": 20, + "_lineHeight": 40, + "_enableWrapText": false, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_styleFlags": 0, + "_underlineHeight": 0, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 1, + "_N$cacheMode": 1, + "_id": "d8YhzvrDBC3pyKvNP8jM2s" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 50 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952" + }, + "_type": 1, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "3ahjbsxYVD0KHQ1J1t4rhw" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 50 + }, + "_enabled": true, + "alignMode": 0, + "_target": null, + "_alignFlags": 45, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 100, + "_originalHeight": 40, + "_id": "5fZebfqLxKXKIP0kbOHNfA" + }, + { + "__type__": "cc.Button", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 49 + }, + "_enabled": true, + "_normalMaterial": null, + "_grayMaterial": null, + "duration": 0.1, + "zoomScale": 1.2, + "clickEvents": [], + "_N$interactable": true, + "_N$enableAutoGrayEffect": false, + "_N$transition": 3, + "transition": 3, + "_N$normalColor": { + "__type__": "cc.Color", + "r": 230, + "g": 230, + "b": 230, + "a": 255 + }, + "_N$pressedColor": { + "__type__": "cc.Color", + "r": 200, + "g": 200, + "b": 200, + "a": 255 + }, + "pressedColor": { + "__type__": "cc.Color", + "r": 200, + "g": 200, + "b": 200, + "a": 255 + }, + "_N$hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$disabledColor": { + "__type__": "cc.Color", + "r": 120, + "g": 120, + "b": 120, + "a": 200 + }, + "_N$normalSprite": { + "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952" + }, + "_N$pressedSprite": { + "__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a" + }, + "pressedSprite": { + "__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a" + }, + "_N$hoverSprite": { + "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952" + }, + "hoverSprite": { + "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952" + }, + "_N$disabledSprite": { + "__uuid__": "29158224-f8dd-4661-a796-1ffab537140e" + }, + "_N$target": { + "__id__": 50 + }, + "_id": "caKLIVawdPZ64Zt8ZkLprq" + }, + { + "__type__": "cc.Canvas", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "_designResolution": { + "__type__": "cc.Size", + "width": 750, + "height": 1334 + }, + "_fitWidth": true, + "_fitHeight": false, + "_id": "dfvGuB0gdP+bfdBA5GrvZn" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "alignMode": 1, + "_target": null, + "_alignFlags": 45, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 0, + "_originalHeight": 0, + "_id": "ddKTtCCMFIwpiha8iT+uxE" + }, + { + "__type__": "b9be0tgoIVPk72LiE6N39f/", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "scrollView": { + "__id__": 39 + }, + "prefab": { + "__uuid__": "3a3767fc-5a7c-4f4b-b174-8f4038113095" + }, + "layer": { + "__id__": 42 + }, + "_id": "7fT97q3OtHbLCfyWtjclN3" + } +] \ No newline at end of file diff --git a/Layered_virtual_list_2.x/temp/BackupAssets/assets/Scene/Item.prefab b/Layered_virtual_list_2.x/temp/BackupAssets/assets/Scene/Item.prefab new file mode 100644 index 0000000..f8e25b7 --- /dev/null +++ b/Layered_virtual_list_2.x/temp/BackupAssets/assets/Scene/Item.prefab @@ -0,0 +1,992 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "asyncLoadAssets": false, + "readonly": false + }, + { + "__type__": "cc.Node", + "_name": "Item", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + }, + { + "__id__": 6 + }, + { + "__id__": 11 + }, + { + "__id__": 23 + } + ], + "_active": true, + "_components": [ + { + "__id__": 28 + } + ], + "_prefab": { + "__id__": 29 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 750, + "height": 80 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 1 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bg", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 3 + }, + { + "__id__": 4 + } + ], + "_prefab": { + "__id__": 5 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 48, + "g": 147, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 750, + "height": 80 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + -40, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "alignMode": 2, + "_target": null, + "_alignFlags": 45, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 100, + "_originalHeight": 100, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "2fWAV/kSxKbLNNotfg0pAI", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "nameLb", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 7 + }, + { + "__id__": 8 + }, + { + "__id__": 9 + } + ], + "_prefab": { + "__id__": 10 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 142.25, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -261.821, + -45.115, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 6 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_string": "我是第1", + "_N$string": "我是第1", + "_fontSize": 40, + "_lineHeight": 40, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_styleFlags": 1, + "_underlineHeight": 0, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 2, + "_id": "" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 6 + }, + "_enabled": true, + "renderZIndex": 1, + "syncInv": 0.01, + "_id": "" + }, + { + "__type__": "cc.LabelShadow", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 6 + }, + "_enabled": true, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_offset": { + "__type__": "cc.Vec2", + "x": 2, + "y": -5 + }, + "_blur": 2, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "50Nr1a5SVMCLPTFU4WTSCP", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "New Button", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 12 + } + ], + "_active": true, + "_components": [ + { + "__id__": 21 + } + ], + "_prefab": { + "__id__": 22 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -106.669, + -44.121, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Background", + "_objFlags": 0, + "_parent": { + "__id__": 11 + }, + "_children": [ + { + "__id__": 13 + } + ], + "_active": true, + "_components": [ + { + "__id__": 17 + }, + { + "__id__": 18 + }, + { + "__id__": 19 + } + ], + "_prefab": { + "__id__": 20 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 0 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Label", + "_objFlags": 0, + "_parent": { + "__id__": 12 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 14 + }, + { + "__id__": 15 + } + ], + "_prefab": { + "__id__": 16 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 13 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_string": "button", + "_N$string": "button", + "_fontSize": 20, + "_lineHeight": 40, + "_enableWrapText": false, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_styleFlags": 0, + "_underlineHeight": 0, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 1, + "_N$cacheMode": 2, + "_id": "" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 13 + }, + "_enabled": true, + "renderZIndex": 1, + "syncInv": 0.01, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "12747hBa5Ok7wyGD/cQP/v", + "sync": false + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 12 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952" + }, + "_type": 1, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 12 + }, + "_enabled": true, + "alignMode": 0, + "_target": null, + "_alignFlags": 45, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 100, + "_originalHeight": 40, + "_id": "" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 12 + }, + "_enabled": true, + "renderZIndex": 0, + "syncInv": 0.01, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "b2yBk+BHFOF7B8n1gYypgp", + "sync": false + }, + { + "__type__": "cc.Button", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 11 + }, + "_enabled": true, + "_normalMaterial": null, + "_grayMaterial": null, + "duration": 0.1, + "zoomScale": 1.2, + "clickEvents": [], + "_N$interactable": true, + "_N$enableAutoGrayEffect": false, + "_N$transition": 3, + "transition": 3, + "_N$normalColor": { + "__type__": "cc.Color", + "r": 230, + "g": 230, + "b": 230, + "a": 255 + }, + "_N$pressedColor": { + "__type__": "cc.Color", + "r": 200, + "g": 200, + "b": 200, + "a": 255 + }, + "pressedColor": { + "__type__": "cc.Color", + "r": 200, + "g": 200, + "b": 200, + "a": 255 + }, + "_N$hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$disabledColor": { + "__type__": "cc.Color", + "r": 120, + "g": 120, + "b": 120, + "a": 200 + }, + "_N$normalSprite": { + "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952" + }, + "_N$pressedSprite": { + "__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a" + }, + "pressedSprite": { + "__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a" + }, + "_N$hoverSprite": { + "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952" + }, + "hoverSprite": { + "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952" + }, + "_N$disabledSprite": { + "__uuid__": "29158224-f8dd-4661-a796-1ffab537140e" + }, + "_N$target": { + "__id__": 12 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "14TO6K8WlMjp8gwgtWA0qf", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "contentLb", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 24 + }, + { + "__id__": 25 + }, + { + "__id__": 26 + } + ], + "_prefab": { + "__id__": 27 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 333.07, + "height": 44 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 151.722, + -43.961, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 23 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_string": "ScrollView content", + "_N$string": "ScrollView content", + "_fontSize": 40, + "_lineHeight": 40, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_styleFlags": 0, + "_underlineHeight": 0, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 2, + "_id": "" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 23 + }, + "_enabled": true, + "renderZIndex": 1, + "syncInv": 0.01, + "_id": "" + }, + { + "__type__": "cc.LabelOutline", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 23 + }, + "_enabled": true, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_width": 2, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "41ShEz5VJCm68duiIf01ZR", + "sync": false + }, + { + "__type__": "7e1f6lmx11Hho9BNV3MqKkZ", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "nameLb": { + "__id__": 7 + }, + "contentLb": { + "__id__": 24 + }, + "Button": { + "__id__": 11 + }, + "ButtonLb": { + "__id__": 14 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "", + "sync": false + } +] \ No newline at end of file diff --git a/Layered_virtual_list_2.x/temp/BackupAssets/assets/Scene/TestMatrix.fire b/Layered_virtual_list_2.x/temp/BackupAssets/assets/Scene/TestMatrix.fire new file mode 100644 index 0000000..4716dbb --- /dev/null +++ b/Layered_virtual_list_2.x/temp/BackupAssets/assets/Scene/TestMatrix.fire @@ -0,0 +1,653 @@ +[ + { + "__type__": "cc.SceneAsset", + "_name": "", + "_objFlags": 0, + "_native": "", + "scene": { + "__id__": 1 + } + }, + { + "__type__": "cc.Scene", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + } + ], + "_active": true, + "_components": [], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_is3DNode": true, + "_groupIndex": 0, + "groupIndex": 0, + "autoReleaseAssets": false, + "_id": "3ed1232c-1b00-4818-8d5e-2112f30b11a4" + }, + { + "__type__": "cc.Node", + "_name": "Canvas", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 3 + }, + { + "__id__": 5 + }, + { + "__id__": 9 + } + ], + "_active": true, + "_components": [ + { + "__id__": 12 + }, + { + "__id__": 13 + }, + { + "__id__": 14 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 1334, + "height": 750 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 667, + 375, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "a5esZu+45LA5mBpvttspPD" + }, + { + "__type__": "cc.Node", + "_name": "Main Camera", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 4 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 960, + "height": 640 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "e1WoFrQ79G7r4ZuQE3HlNb" + }, + { + "__type__": "cc.Camera", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 3 + }, + "_enabled": true, + "_cullingMask": 4294967295, + "_clearFlags": 7, + "_backgroundColor": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_depth": -1, + "_zoomRatio": 1, + "_targetTexture": null, + "_fov": 60, + "_orthoSize": 10, + "_nearClip": 1, + "_farClip": 4096, + "_ortho": true, + "_rect": { + "__type__": "cc.Rect", + "x": 0, + "y": 0, + "width": 1, + "height": 1 + }, + "_renderStages": 1, + "_alignWithScreen": true, + "_id": "81GN3uXINKVLeW4+iKSlim" + }, + { + "__type__": "cc.Node", + "_name": "targetParent", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [ + { + "__id__": 6 + } + ], + "_active": true, + "_components": [ + { + "__id__": 8 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 40, + "height": 36 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -284.547, + -47.425, + 0, + 0, + 0, + 0.10452846326765347, + 0.9945218953682733, + 0.8, + 0.8, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 12 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "edt8E0W/NHXJRfLL5w0FEx" + }, + { + "__type__": "cc.Node", + "_name": "target", + "_objFlags": 0, + "_parent": { + "__id__": 5 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 7 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 234, + "g": 105, + "b": 105, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 40, + "height": 36 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 62.57, + -72.45, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "6eHCMdQvJGuZlXE52ZvHyf" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 6 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "8cdb44ac-a3f6-449f-b354-7cd48cf84061" + }, + "_type": 0, + "_sizeMode": 1, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "12C4OEfbpPZ7D293sA4N2X" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 5 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "8cdb44ac-a3f6-449f-b354-7cd48cf84061" + }, + "_type": 0, + "_sizeMode": 1, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "32BW2ujgdMuoadwfa8sy8R" + }, + { + "__type__": "cc.Node", + "_name": "SrcParent", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [ + { + "__id__": 10 + } + ], + "_active": true, + "_components": [], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 134.369, + 51.377, + 0, + 0, + 0, + -0.25881904510252074, + 0.9659258262890683, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": -30 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "fe2RbrNhxIUZiF7XIU03Th" + }, + { + "__type__": "cc.Node", + "_name": "src", + "_objFlags": 0, + "_parent": { + "__id__": 9 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 11 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 100 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -71.628, + 13.407, + 0, + 0, + 0, + 0, + 1, + 1.2, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "a6z5vIfndNfZSVcOsoQPPR" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 10 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "b41guspOdA+rTJ9wP8FM7K" + }, + { + "__type__": "cc.Canvas", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "_designResolution": { + "__type__": "cc.Size", + "width": 1334, + "height": 750 + }, + "_fitWidth": false, + "_fitHeight": true, + "_id": "59Cd0ovbdF4byw5sbjJDx7" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "alignMode": 1, + "_target": null, + "_alignFlags": 45, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 0, + "_originalHeight": 0, + "_id": "29zXboiXFBKoIV4PQ2liTe" + }, + { + "__type__": "41fb7HlhIJNzZMkSaq31ryP", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "target": { + "__id__": 6 + }, + "targetParent": { + "__id__": 5 + }, + "srcTarget": { + "__id__": 10 + }, + "srcTargetParent": { + "__id__": 9 + }, + "_id": "61Ee/a6NhDDKpan+btqgEB" + } +] \ No newline at end of file diff --git a/Layered_virtual_list_2.x/temp/BackupAssets/assets/Scene/helloworld.fire b/Layered_virtual_list_2.x/temp/BackupAssets/assets/Scene/helloworld.fire new file mode 100644 index 0000000..e62842e --- /dev/null +++ b/Layered_virtual_list_2.x/temp/BackupAssets/assets/Scene/helloworld.fire @@ -0,0 +1,1953 @@ +[ + { + "__type__": "cc.SceneAsset", + "_name": "", + "_objFlags": 0, + "_native": "", + "scene": { + "__id__": 1 + } + }, + { + "__type__": "cc.Scene", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + } + ], + "_active": false, + "_components": [], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_is3DNode": true, + "_groupIndex": 0, + "groupIndex": 0, + "autoReleaseAssets": false, + "_id": "2d2f792f-a40c-49bb-a189-ed176a246e49" + }, + { + "__type__": "cc.Node", + "_name": "Canvas", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 3 + }, + { + "__id__": 5 + }, + { + "__id__": 9 + }, + { + "__id__": 17 + }, + { + "__id__": 26 + } + ], + "_active": true, + "_components": [ + { + "__id__": 46 + }, + { + "__id__": 47 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 252, + "g": 252, + "b": 252, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 750, + "height": 1334 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 375, + 667, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "a286bbGknJLZpRpxROV6M94" + }, + { + "__type__": "cc.Node", + "_name": "Main Camera", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 4 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "09K3aRxxtPX4CkhgKEDjJC" + }, + { + "__type__": "cc.Camera", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 3 + }, + "_enabled": true, + "_cullingMask": 4294967295, + "_clearFlags": 7, + "_backgroundColor": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_depth": -1, + "_zoomRatio": 1, + "_targetTexture": null, + "_fov": 60, + "_orthoSize": 10, + "_nearClip": 1, + "_farClip": 4096, + "_ortho": true, + "_rect": { + "__type__": "cc.Rect", + "x": 0, + "y": 0, + "width": 1, + "height": 1 + }, + "_renderStages": 1, + "_alignWithScreen": true, + "_id": "39hvvfgtBNGI33C9knv3qJ" + }, + { + "__type__": "cc.Node", + "_name": "TestLoop", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 6 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "ea+1z95MVNUJtfZx0Pj5uw" + }, + { + "__type__": "4850bCv26VE3LcjWQcJHche", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 5 + }, + "_enabled": true, + "rendeLayer": { + "__id__": 7 + }, + "scrollView": { + "__id__": 11 + }, + "showPrefab": { + "__uuid__": "6b1c6ed5-0dab-415a-b3cc-4408f270a2d0" + }, + "_id": "4ecJ/NvtNECq11eqajw/72" + }, + { + "__type__": "cc.Node", + "_name": "layer", + "_objFlags": 0, + "_parent": { + "__id__": 8 + }, + "_children": [], + "_active": true, + "_components": [], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 200, + "height": 300 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 123.761, + -500, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "50nGMWMotB8IRitJD4pcqd" + }, + { + "__type__": "cc.Node", + "_name": "view", + "_objFlags": 0, + "_parent": { + "__id__": 9 + }, + "_children": [ + { + "__id__": 12 + }, + { + "__id__": 7 + } + ], + "_active": true, + "_components": [ + { + "__id__": 15 + }, + { + "__id__": 16 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 750, + "height": 1000 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 1 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 500, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "c6mYKChI5JOIj+cE9APPY7" + }, + { + "__type__": "cc.Node", + "_name": "Vertical", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [ + { + "__id__": 8 + } + ], + "_active": true, + "_components": [ + { + "__id__": 10 + }, + { + "__id__": 11 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 750, + "height": 1000 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "43vHaNbn5LBatV59YArlhV" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 9 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "9bbda31e-ad49-43c9-aaf2-f7d9896bac69" + }, + "_type": 1, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "1d6unlyRJMsoRZ4n/erVRP" + }, + { + "__type__": "cc.ScrollView", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 9 + }, + "_enabled": true, + "horizontal": false, + "vertical": true, + "inertia": true, + "brake": 0.75, + "elastic": true, + "bounceDuration": 0.23, + "scrollEvents": [], + "cancelInnerEvents": true, + "_N$content": { + "__id__": 12 + }, + "content": { + "__id__": 12 + }, + "_N$horizontalScrollBar": null, + "_N$verticalScrollBar": null, + "_id": "85FvdcFWBDV4M9KxRZecCJ" + }, + { + "__type__": "cc.Node", + "_name": "content", + "_objFlags": 0, + "_parent": { + "__id__": 8 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 13 + }, + { + "__id__": 14 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 750, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 1 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "1bXfuT7ExLwJKge3owlyzF" + }, + { + "__type__": "cc.Layout", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 12 + }, + "_enabled": true, + "_layoutSize": { + "__type__": "cc.Size", + "width": 750, + "height": 0 + }, + "_resize": 1, + "_N$layoutType": 2, + "_N$cellSize": { + "__type__": "cc.Size", + "width": 40, + "height": 40 + }, + "_N$startAxis": 0, + "_N$paddingLeft": 0, + "_N$paddingRight": 0, + "_N$paddingTop": 0, + "_N$paddingBottom": 0, + "_N$spacingX": 0, + "_N$spacingY": 10, + "_N$verticalDirection": 1, + "_N$horizontalDirection": 0, + "_N$affectedByScale": false, + "_id": "97UH7rpo1KOJZZSsFYERBu" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 12 + }, + "_enabled": true, + "alignMode": 1, + "_target": null, + "_alignFlags": 41, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 220, + "_originalHeight": 0, + "_id": "94j1vJKZhC7rvaDXU/XM+I" + }, + { + "__type__": "cc.Mask", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 8 + }, + "_enabled": false, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_spriteFrame": null, + "_type": 0, + "_segments": 64, + "_N$alphaThreshold": 0, + "_N$inverted": false, + "_id": "cdlgF0KFZAAZzi3KNcEqEW" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 8 + }, + "_enabled": true, + "alignMode": 1, + "_target": null, + "_alignFlags": 45, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 240, + "_originalHeight": 250, + "_id": "a7YdvisBhKuIlN3CCuPMaJ" + }, + { + "__type__": "cc.Node", + "_name": "Horizontal", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [ + { + "__id__": 18 + } + ], + "_active": false, + "_components": [ + { + "__id__": 24 + }, + { + "__id__": 25 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 500, + "height": 1000 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "36VvP0G09KXaygeBwQJi38" + }, + { + "__type__": "cc.Node", + "_name": "view", + "_objFlags": 0, + "_parent": { + "__id__": 17 + }, + "_children": [ + { + "__id__": 19 + } + ], + "_active": true, + "_components": [ + { + "__id__": 22 + }, + { + "__id__": 23 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 500, + "height": 1000 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -250, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "5cVJZx64VDAbE0+GHS+ljM" + }, + { + "__type__": "cc.Node", + "_name": "content", + "_objFlags": 0, + "_parent": { + "__id__": 18 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 20 + }, + { + "__id__": 21 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 220, + "height": 1000 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "044WGrpVlJX6HvptTPUEC1" + }, + { + "__type__": "cc.Layout", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 19 + }, + "_enabled": true, + "_layoutSize": { + "__type__": "cc.Size", + "width": 220, + "height": 1000 + }, + "_resize": 1, + "_N$layoutType": 1, + "_N$cellSize": { + "__type__": "cc.Size", + "width": 40, + "height": 40 + }, + "_N$startAxis": 0, + "_N$paddingLeft": 0, + "_N$paddingRight": 0, + "_N$paddingTop": 0, + "_N$paddingBottom": 0, + "_N$spacingX": 0, + "_N$spacingY": 5, + "_N$verticalDirection": 1, + "_N$horizontalDirection": 0, + "_N$affectedByScale": false, + "_id": "55aN0610JMRq/gQKnyzhAY" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 19 + }, + "_enabled": true, + "alignMode": 1, + "_target": null, + "_alignFlags": 13, + "_left": 0, + "_right": 280, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 220, + "_originalHeight": 0, + "_id": "e4s1D76VBHvauUganIA4KW" + }, + { + "__type__": "cc.Mask", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 18 + }, + "_enabled": false, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_spriteFrame": null, + "_type": 0, + "_segments": 64, + "_N$alphaThreshold": 0, + "_N$inverted": false, + "_id": "bf6UMcWrhOr4jcJ8Xr/ccS" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 18 + }, + "_enabled": true, + "alignMode": 1, + "_target": null, + "_alignFlags": 45, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 240, + "_originalHeight": 250, + "_id": "795+OK4EFMo68XgmKpU2O+" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 17 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "9bbda31e-ad49-43c9-aaf2-f7d9896bac69" + }, + "_type": 1, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "27RDHW2iJEgbMioz+T5We3" + }, + { + "__type__": "cc.ScrollView", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 17 + }, + "_enabled": true, + "horizontal": true, + "vertical": false, + "inertia": true, + "brake": 0.75, + "elastic": true, + "bounceDuration": 0.23, + "scrollEvents": [], + "cancelInnerEvents": true, + "_N$content": { + "__id__": 19 + }, + "content": { + "__id__": 19 + }, + "_N$horizontalScrollBar": null, + "_N$verticalScrollBar": null, + "_id": "9f7KeQvGdBb42l9mua/S+H" + }, + { + "__type__": "cc.Node", + "_name": "parent", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [ + { + "__id__": 27 + }, + { + "__id__": 33 + }, + { + "__id__": 39 + } + ], + "_active": false, + "_components": [ + { + "__id__": 45 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 40, + "g": 168, + "b": 45, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 500, + "height": 500 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "4eapwQhy9FJr1oDtIF5XMt" + }, + { + "__type__": "cc.Node", + "_name": "1", + "_objFlags": 0, + "_parent": { + "__id__": 26 + }, + "_children": [ + { + "__id__": 28 + } + ], + "_active": true, + "_components": [ + { + "__id__": 31 + }, + { + "__id__": 32 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 100 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -80.714, + 123.761, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "cclp30DuxPI40Ql8RTgIp5" + }, + { + "__type__": "cc.Node", + "_name": "New Label", + "_objFlags": 0, + "_parent": { + "__id__": 27 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 29 + }, + { + "__id__": 30 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 22.25, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "d1NK110VBOjL8p0409QsTv" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 28 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_string": "1", + "_N$string": "1", + "_fontSize": 40, + "_lineHeight": 40, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_styleFlags": 0, + "_underlineHeight": 0, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 2, + "_id": "1ec9ZPVK9DiY33RUQtjAmR" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 28 + }, + "_enabled": true, + "renderLayer": { + "__id__": 7 + }, + "renderZIndex": 0, + "syncInv": 0, + "_id": "28rh4vPCtDH7mfQfnunwP+" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 27 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "dctkJzgctIRbPAF7CX/X0D" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 27 + }, + "_enabled": true, + "renderLayer": { + "__id__": 7 + }, + "renderZIndex": 0, + "syncInv": 0, + "_id": "34s75vARxOxYwCNg9irB9g" + }, + { + "__type__": "cc.Node", + "_name": "2", + "_objFlags": 0, + "_parent": { + "__id__": 26 + }, + "_children": [ + { + "__id__": 34 + } + ], + "_active": true, + "_components": [ + { + "__id__": 37 + }, + { + "__id__": 38 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 184, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 100 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -80.714, + 123.761, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "f3s/MnZNRHTIi/Q+H1UxKx" + }, + { + "__type__": "cc.Node", + "_name": "New Label", + "_objFlags": 0, + "_parent": { + "__id__": 33 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 35 + }, + { + "__id__": 36 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 22.25, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "d32B7NZuBGY63WBdbVTVyG" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 34 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_string": "2", + "_N$string": "2", + "_fontSize": 40, + "_lineHeight": 40, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_styleFlags": 0, + "_underlineHeight": 0, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 2, + "_id": "14NDOGnfhG9K+YOHXLcfhJ" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 34 + }, + "_enabled": true, + "renderLayer": { + "__id__": 7 + }, + "renderZIndex": 0, + "syncInv": 0, + "_id": "3b2tZBLXFLfbVjUa9moptZ" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 33 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "56VszVbJ5PB7PzxYIgK1UZ" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 33 + }, + "_enabled": true, + "renderLayer": { + "__id__": 7 + }, + "renderZIndex": 0, + "syncInv": 0, + "_id": "98jNMDg2NNpL0CwReAWY24" + }, + { + "__type__": "cc.Node", + "_name": "3", + "_objFlags": 0, + "_parent": { + "__id__": 26 + }, + "_children": [ + { + "__id__": 40 + } + ], + "_active": true, + "_components": [ + { + "__id__": 43 + }, + { + "__id__": 44 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 10, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 100 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -80.714, + 123.761, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "1e4i8OlSlN1L+L8ylsTJMp" + }, + { + "__type__": "cc.Node", + "_name": "New Label", + "_objFlags": 0, + "_parent": { + "__id__": 39 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 41 + }, + { + "__id__": 42 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 22.25, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "d8eW94wH5Emo/po5DP/fed" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 40 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_string": "3", + "_N$string": "3", + "_fontSize": 40, + "_lineHeight": 40, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_styleFlags": 0, + "_underlineHeight": 0, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 2, + "_id": "7fju1YtiROgKcUrz8Jbxoo" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 40 + }, + "_enabled": true, + "renderLayer": { + "__id__": 7 + }, + "renderZIndex": 0, + "syncInv": 0, + "_id": "04gNKYOURMUYIzBSFmEZQb" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 39 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "e3/Rip1ZxCQrAeRRXarp6n" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 39 + }, + "_enabled": true, + "renderLayer": { + "__id__": 7 + }, + "renderZIndex": 0, + "syncInv": 0, + "_id": "27WCjM2uhB5pVrJMpptJfp" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 26 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "69pO2jE6tFNr13iHtLu7XS" + }, + { + "__type__": "cc.Canvas", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "_designResolution": { + "__type__": "cc.Size", + "width": 750, + "height": 1334 + }, + "_fitWidth": true, + "_fitHeight": false, + "_id": "dfvGuB0gdP+bfdBA5GrvZn" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "alignMode": 1, + "_target": null, + "_alignFlags": 45, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 0, + "_originalHeight": 0, + "_id": "ddKTtCCMFIwpiha8iT+uxE" + } +] \ No newline at end of file diff --git a/Layered_virtual_list_2.x/temp/BackupAssets/assets/Scene/showNode.prefab b/Layered_virtual_list_2.x/temp/BackupAssets/assets/Scene/showNode.prefab new file mode 100644 index 0000000..bb0f9b0 --- /dev/null +++ b/Layered_virtual_list_2.x/temp/BackupAssets/assets/Scene/showNode.prefab @@ -0,0 +1,1041 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "asyncLoadAssets": false, + "readonly": false + }, + { + "__type__": "cc.Node", + "_name": "showNode", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + }, + { + "__id__": 7 + }, + { + "__id__": 12 + }, + { + "__id__": 24 + } + ], + "_active": true, + "_components": [ + { + "__id__": 29 + }, + { + "__id__": 30 + } + ], + "_prefab": { + "__id__": 31 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 750, + "height": 1334 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 1 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 375, + 1334, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Bg", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 3 + }, + { + "__id__": 4 + }, + { + "__id__": 5 + } + ], + "_prefab": { + "__id__": 6 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 48, + "g": 147, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 750, + "height": 1334 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + -667, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "alignMode": 2, + "_target": null, + "_alignFlags": 45, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 100, + "_originalHeight": 100, + "_id": "" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "renderLayer": null, + "renderZIndex": 0, + "syncInv": 0.01, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "6b1c6ed5-0dab-415a-b3cc-4408f270a2d0" + }, + "fileId": "2fWAV/kSxKbLNNotfg0pAI", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "nameLb", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 8 + }, + { + "__id__": 9 + }, + { + "__id__": 10 + } + ], + "_prefab": { + "__id__": 11 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 142.25, + "height": 50.4 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -261.821, + -45.115, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 7 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_string": "我是第1", + "_N$string": "我是第1", + "_fontSize": 40, + "_lineHeight": 40, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_styleFlags": 0, + "_underlineHeight": 0, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 0, + "_id": "" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 7 + }, + "_enabled": true, + "renderLayer": null, + "renderZIndex": 1, + "syncInv": 0.01, + "_id": "" + }, + { + "__type__": "cc.LabelShadow", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 7 + }, + "_enabled": true, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_offset": { + "__type__": "cc.Vec2", + "x": 2, + "y": -5 + }, + "_blur": 2, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "6b1c6ed5-0dab-415a-b3cc-4408f270a2d0" + }, + "fileId": "50Nr1a5SVMCLPTFU4WTSCP", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "New Button", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 13 + }, + { + "__id__": 18 + } + ], + "_active": true, + "_components": [ + { + "__id__": 22 + } + ], + "_prefab": { + "__id__": 23 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -106.669, + -44.121, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Background", + "_objFlags": 0, + "_parent": { + "__id__": 12 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 14 + }, + { + "__id__": 15 + }, + { + "__id__": 16 + } + ], + "_prefab": { + "__id__": 17 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 0 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 13 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952" + }, + "_type": 1, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 13 + }, + "_enabled": true, + "alignMode": 0, + "_target": null, + "_alignFlags": 45, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 100, + "_originalHeight": 40, + "_id": "" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 13 + }, + "_enabled": true, + "renderLayer": null, + "renderZIndex": 0, + "syncInv": 0.01, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "6b1c6ed5-0dab-415a-b3cc-4408f270a2d0" + }, + "fileId": "b2yBk+BHFOF7B8n1gYypgp", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "Label", + "_objFlags": 0, + "_parent": { + "__id__": 12 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 19 + }, + { + "__id__": 20 + } + ], + "_prefab": { + "__id__": 21 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 18 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_string": "button", + "_N$string": "button", + "_fontSize": 20, + "_lineHeight": 40, + "_enableWrapText": false, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_styleFlags": 0, + "_underlineHeight": 0, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 1, + "_N$cacheMode": 2, + "_id": "" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 18 + }, + "_enabled": true, + "renderLayer": null, + "renderZIndex": 1, + "syncInv": 0.01, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "6b1c6ed5-0dab-415a-b3cc-4408f270a2d0" + }, + "fileId": "78ZrwHpmZIaZAh4fh1OXyZ", + "sync": false + }, + { + "__type__": "cc.Button", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 12 + }, + "_enabled": true, + "_normalMaterial": null, + "_grayMaterial": null, + "duration": 0.1, + "zoomScale": 1.2, + "clickEvents": [], + "_N$interactable": true, + "_N$enableAutoGrayEffect": false, + "_N$transition": 3, + "transition": 3, + "_N$normalColor": { + "__type__": "cc.Color", + "r": 230, + "g": 230, + "b": 230, + "a": 255 + }, + "_N$pressedColor": { + "__type__": "cc.Color", + "r": 200, + "g": 200, + "b": 200, + "a": 255 + }, + "pressedColor": { + "__type__": "cc.Color", + "r": 200, + "g": 200, + "b": 200, + "a": 255 + }, + "_N$hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$disabledColor": { + "__type__": "cc.Color", + "r": 120, + "g": 120, + "b": 120, + "a": 200 + }, + "_N$normalSprite": { + "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952" + }, + "_N$pressedSprite": { + "__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a" + }, + "pressedSprite": { + "__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a" + }, + "_N$hoverSprite": { + "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952" + }, + "hoverSprite": { + "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952" + }, + "_N$disabledSprite": { + "__uuid__": "29158224-f8dd-4661-a796-1ffab537140e" + }, + "_N$target": { + "__id__": 13 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "6b1c6ed5-0dab-415a-b3cc-4408f270a2d0" + }, + "fileId": "14TO6K8WlMjp8gwgtWA0qf", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "contentLb", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 25 + }, + { + "__id__": 26 + }, + { + "__id__": 27 + } + ], + "_prefab": { + "__id__": 28 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 333.07, + "height": 44 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 151.722, + -43.961, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 24 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_string": "ScrollView content", + "_N$string": "ScrollView content", + "_fontSize": 40, + "_lineHeight": 40, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_styleFlags": 0, + "_underlineHeight": 0, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 2, + "_id": "" + }, + { + "__type__": "f9782xj4QNK842OAHoabRFb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 24 + }, + "_enabled": true, + "renderLayer": null, + "renderZIndex": 1, + "syncInv": 0.01, + "_id": "" + }, + { + "__type__": "cc.LabelOutline", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 24 + }, + "_enabled": true, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_width": 2, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "6b1c6ed5-0dab-415a-b3cc-4408f270a2d0" + }, + "fileId": "41ShEz5VJCm68duiIf01ZR", + "sync": false + }, + { + "__type__": "9e178M6rUlI5qgi1+HcLO30", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "nameLb": { + "__id__": 8 + }, + "contentLb": { + "__id__": 25 + }, + "Button": { + "__id__": 12 + }, + "ButtonLb": { + "__id__": 19 + }, + "_id": "" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "alignMode": 2, + "_target": null, + "_alignFlags": 45, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 750, + "_originalHeight": 100, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "6b1c6ed5-0dab-415a-b3cc-4408f270a2d0" + }, + "fileId": "", + "sync": false + } +] \ No newline at end of file diff --git a/Layered_virtual_list_2.x/temp/gltf/4142882b247e9c199882f8f75ed5cdbb_out/4142882b247e9c199882f8f75ed5cdbb.gltf b/Layered_virtual_list_2.x/temp/gltf/4142882b247e9c199882f8f75ed5cdbb_out/4142882b247e9c199882f8f75ed5cdbb.gltf new file mode 100644 index 0000000..ca72477 --- /dev/null +++ b/Layered_virtual_list_2.x/temp/gltf/4142882b247e9c199882f8f75ed5cdbb_out/4142882b247e9c199882f8f75ed5cdbb.gltf @@ -0,0 +1,859 @@ +{ + "asset": { + "generator": "FBX2glTF", + "version": "2.0" + }, + "scene": 0, + "buffers": [ + { + "byteLength": 161028, + "uri": "buffer.bin" + } + ], + "bufferViews": [ + { + "buffer": 0, + "byteLength": 12288, + "byteOffset": 0, + "target": 34963 + }, + { + "buffer": 0, + "byteLength": 13860, + "byteOffset": 12288, + "target": 34962 + }, + { + "buffer": 0, + "byteLength": 13860, + "byteOffset": 26148, + "target": 34962 + }, + { + "buffer": 0, + "byteLength": 9240, + "byteOffset": 40008, + "target": 34962 + }, + { + "buffer": 0, + "byteLength": 1200, + "byteOffset": 49248, + "target": 34963 + }, + { + "buffer": 0, + "byteLength": 1452, + "byteOffset": 50448, + "target": 34962 + }, + { + "buffer": 0, + "byteLength": 1452, + "byteOffset": 51900, + "target": 34962 + }, + { + "buffer": 0, + "byteLength": 968, + "byteOffset": 53352, + "target": 34962 + }, + { + "buffer": 0, + "byteLength": 384, + "byteOffset": 54320, + "target": 34963 + }, + { + "buffer": 0, + "byteLength": 1548, + "byteOffset": 54704, + "target": 34962 + }, + { + "buffer": 0, + "byteLength": 1548, + "byteOffset": 56252, + "target": 34962 + }, + { + "buffer": 0, + "byteLength": 1032, + "byteOffset": 57800, + "target": 34962 + }, + { + "buffer": 0, + "byteLength": 12288, + "byteOffset": 58832, + "target": 34963 + }, + { + "buffer": 0, + "byteLength": 13068, + "byteOffset": 71120, + "target": 34962 + }, + { + "buffer": 0, + "byteLength": 13068, + "byteOffset": 84188, + "target": 34962 + }, + { + "buffer": 0, + "byteLength": 8712, + "byteOffset": 97256, + "target": 34962 + }, + { + "buffer": 0, + "byteLength": 12288, + "byteOffset": 105968, + "target": 34963 + }, + { + "buffer": 0, + "byteLength": 13068, + "byteOffset": 118256, + "target": 34962 + }, + { + "buffer": 0, + "byteLength": 13068, + "byteOffset": 131324, + "target": 34962 + }, + { + "buffer": 0, + "byteLength": 8712, + "byteOffset": 144392, + "target": 34962 + }, + { + "buffer": 0, + "byteLength": 12, + "byteOffset": 153104, + "target": 34963 + }, + { + "buffer": 0, + "byteLength": 48, + "byteOffset": 153116, + "target": 34962 + }, + { + "buffer": 0, + "byteLength": 48, + "byteOffset": 153164, + "target": 34962 + }, + { + "buffer": 0, + "byteLength": 32, + "byteOffset": 153212, + "target": 34962 + }, + { + "buffer": 0, + "byteLength": 768, + "byteOffset": 153244, + "target": 34963 + }, + { + "buffer": 0, + "byteLength": 2316, + "byteOffset": 154012, + "target": 34962 + }, + { + "buffer": 0, + "byteLength": 2316, + "byteOffset": 156328, + "target": 34962 + }, + { + "buffer": 0, + "byteLength": 1544, + "byteOffset": 158644, + "target": 34962 + }, + { + "buffer": 0, + "byteLength": 72, + "byteOffset": 160188, + "target": 34963 + }, + { + "buffer": 0, + "byteLength": 288, + "byteOffset": 160260, + "target": 34962 + }, + { + "buffer": 0, + "byteLength": 288, + "byteOffset": 160548, + "target": 34962 + }, + { + "buffer": 0, + "byteLength": 192, + "byteOffset": 160836, + "target": 34962 + } + ], + "scenes": [ + { + "name": "Root Scene", + "nodes": [ + 0 + ] + } + ], + "accessors": [ + { + "componentType": 5123, + "type": "SCALAR", + "count": 6144, + "bufferView": 0, + "byteOffset": 0 + }, + { + "componentType": 5126, + "type": "VEC3", + "count": 1155, + "bufferView": 1, + "byteOffset": 0, + "min": [ + -0.5, + -1.0, + -0.5 + ], + "max": [ + 0.5, + 1.0, + 0.5 + ] + }, + { + "componentType": 5126, + "type": "VEC3", + "count": 1155, + "bufferView": 2, + "byteOffset": 0 + }, + { + "componentType": 5126, + "type": "VEC2", + "count": 1155, + "bufferView": 3, + "byteOffset": 0 + }, + { + "componentType": 5123, + "type": "SCALAR", + "count": 600, + "bufferView": 4, + "byteOffset": 0 + }, + { + "componentType": 5126, + "type": "VEC3", + "count": 121, + "bufferView": 5, + "byteOffset": 0, + "min": [ + -5.0, + 0.0, + -5.0 + ], + "max": [ + 5.0, + 0.0, + 5.0 + ] + }, + { + "componentType": 5126, + "type": "VEC3", + "count": 121, + "bufferView": 6, + "byteOffset": 0 + }, + { + "componentType": 5126, + "type": "VEC2", + "count": 121, + "bufferView": 7, + "byteOffset": 0 + }, + { + "componentType": 5123, + "type": "SCALAR", + "count": 192, + "bufferView": 8, + "byteOffset": 0 + }, + { + "componentType": 5126, + "type": "VEC3", + "count": 129, + "bufferView": 9, + "byteOffset": 0, + "min": [ + -0.5, + -0.5, + -0.499999940395355 + ], + "max": [ + 0.5, + 0.5, + 0.5 + ] + }, + { + "componentType": 5126, + "type": "VEC3", + "count": 129, + "bufferView": 10, + "byteOffset": 0 + }, + { + "componentType": 5126, + "type": "VEC2", + "count": 129, + "bufferView": 11, + "byteOffset": 0 + }, + { + "componentType": 5123, + "type": "SCALAR", + "count": 6144, + "bufferView": 12, + "byteOffset": 0 + }, + { + "componentType": 5126, + "type": "VEC3", + "count": 1089, + "bufferView": 13, + "byteOffset": 0, + "min": [ + -0.5, + -0.0999999940395355, + -0.5 + ], + "max": [ + 0.5, + 0.0999999940395355, + 0.5 + ] + }, + { + "componentType": 5126, + "type": "VEC3", + "count": 1089, + "bufferView": 14, + "byteOffset": 0 + }, + { + "componentType": 5126, + "type": "VEC2", + "count": 1089, + "bufferView": 15, + "byteOffset": 0 + }, + { + "componentType": 5123, + "type": "SCALAR", + "count": 6144, + "bufferView": 16, + "byteOffset": 0 + }, + { + "componentType": 5126, + "type": "VEC3", + "count": 1089, + "bufferView": 17, + "byteOffset": 0, + "min": [ + -0.5, + -0.5, + -0.5 + ], + "max": [ + 0.5, + 0.5, + 0.5 + ] + }, + { + "componentType": 5126, + "type": "VEC3", + "count": 1089, + "bufferView": 18, + "byteOffset": 0 + }, + { + "componentType": 5126, + "type": "VEC2", + "count": 1089, + "bufferView": 19, + "byteOffset": 0 + }, + { + "componentType": 5123, + "type": "SCALAR", + "count": 6, + "bufferView": 20, + "byteOffset": 0 + }, + { + "componentType": 5126, + "type": "VEC3", + "count": 4, + "bufferView": 21, + "byteOffset": 0, + "min": [ + -0.5, + -0.5, + 0.0 + ], + "max": [ + 0.5, + 0.5, + 0.0 + ] + }, + { + "componentType": 5126, + "type": "VEC3", + "count": 4, + "bufferView": 22, + "byteOffset": 0 + }, + { + "componentType": 5126, + "type": "VEC2", + "count": 4, + "bufferView": 23, + "byteOffset": 0 + }, + { + "componentType": 5123, + "type": "SCALAR", + "count": 384, + "bufferView": 24, + "byteOffset": 0 + }, + { + "componentType": 5126, + "type": "VEC3", + "count": 193, + "bufferView": 25, + "byteOffset": 0, + "min": [ + -0.5, + -1.0, + -0.5 + ], + "max": [ + 0.5, + 1.0, + 0.5 + ] + }, + { + "componentType": 5126, + "type": "VEC3", + "count": 193, + "bufferView": 26, + "byteOffset": 0 + }, + { + "componentType": 5126, + "type": "VEC2", + "count": 193, + "bufferView": 27, + "byteOffset": 0 + }, + { + "componentType": 5123, + "type": "SCALAR", + "count": 36, + "bufferView": 28, + "byteOffset": 0 + }, + { + "componentType": 5126, + "type": "VEC3", + "count": 24, + "bufferView": 29, + "byteOffset": 0, + "min": [ + -0.5, + -0.5, + -0.5 + ], + "max": [ + 0.5, + 0.5, + 0.5 + ] + }, + { + "componentType": 5126, + "type": "VEC3", + "count": 24, + "bufferView": 30, + "byteOffset": 0 + }, + { + "componentType": 5126, + "type": "VEC2", + "count": 24, + "bufferView": 31, + "byteOffset": 0 + } + ], + "samplers": [ + {} + ], + "materials": [ + { + "name": "DefaultMaterial", + "alphaMode": "OPAQUE", + "extras": { + "fromFBX": { + "shadingModel": "Lambert", + "isTruePBR": false + } + }, + "pbrMetallicRoughness": { + "baseColorFactor": [ + 0.5, + 0.5, + 0.5, + 1.0 + ], + "metallicFactor": 0.200000002980232, + "roughnessFactor": 0.800000011920929 + } + } + ], + "meshes": [ + { + "name": "capsule", + "primitives": [ + { + "material": 0, + "mode": 4, + "attributes": { + "NORMAL": 2, + "POSITION": 1, + "TEXCOORD_0": 3 + }, + "indices": 0 + } + ] + }, + { + "name": "plane", + "primitives": [ + { + "material": 0, + "mode": 4, + "attributes": { + "NORMAL": 6, + "POSITION": 5, + "TEXCOORD_0": 7 + }, + "indices": 4 + } + ] + }, + { + "name": "cone", + "primitives": [ + { + "material": 0, + "mode": 4, + "attributes": { + "NORMAL": 10, + "POSITION": 9, + "TEXCOORD_0": 11 + }, + "indices": 8 + } + ] + }, + { + "name": "torus", + "primitives": [ + { + "material": 0, + "mode": 4, + "attributes": { + "NORMAL": 14, + "POSITION": 13, + "TEXCOORD_0": 15 + }, + "indices": 12 + } + ] + }, + { + "name": "sphere", + "primitives": [ + { + "material": 0, + "mode": 4, + "attributes": { + "NORMAL": 18, + "POSITION": 17, + "TEXCOORD_0": 19 + }, + "indices": 16 + } + ] + }, + { + "name": "quad", + "primitives": [ + { + "material": 0, + "mode": 4, + "attributes": { + "NORMAL": 22, + "POSITION": 21, + "TEXCOORD_0": 23 + }, + "indices": 20 + } + ] + }, + { + "name": "cylinder", + "primitives": [ + { + "material": 0, + "mode": 4, + "attributes": { + "NORMAL": 26, + "POSITION": 25, + "TEXCOORD_0": 27 + }, + "indices": 24 + } + ] + }, + { + "name": "box", + "primitives": [ + { + "material": 0, + "mode": 4, + "attributes": { + "NORMAL": 30, + "POSITION": 29, + "TEXCOORD_0": 31 + }, + "indices": 28 + } + ] + } + ], + "nodes": [ + { + "name": "RootNode", + "translation": [ + 0.0, + 0.0, + 0.0 + ], + "rotation": [ + 0.0, + 0.0, + 0.0, + 1.0 + ], + "scale": [ + 1.0, + 1.0, + 1.0 + ], + "children": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8 + ] + }, + { + "name": "capsule", + "translation": [ + 0.0, + 0.0, + 0.0 + ], + "rotation": [ + 8.14603353660459e-08, + 0.0, + 0.0, + 1.0 + ], + "scale": [ + 100.0, + 100.0, + 100.0 + ], + "mesh": 0 + }, + { + "name": "plane", + "translation": [ + 0.0, + 0.0, + 0.0 + ], + "rotation": [ + 8.14603353660459e-08, + 0.0, + 0.0, + 1.0 + ], + "scale": [ + 100.0, + 100.0, + 100.0 + ], + "mesh": 1 + }, + { + "name": "cone", + "translation": [ + 0.0, + 0.0, + 0.0 + ], + "rotation": [ + -0.707106828689575, + 0.0, + 0.0, + 0.707106709480286 + ], + "scale": [ + 100.0, + 100.0, + 100.0 + ], + "mesh": 2 + }, + { + "name": "torus", + "translation": [ + 0.0, + 0.0, + 0.0 + ], + "rotation": [ + 8.14603353660459e-08, + 0.0, + 0.0, + 1.0 + ], + "scale": [ + 100.0, + 100.0, + 100.0 + ], + "mesh": 3 + }, + { + "name": "sphere", + "translation": [ + 0.0, + 0.0, + 0.0 + ], + "rotation": [ + 8.14603353660459e-08, + 0.0, + 0.0, + 1.0 + ], + "scale": [ + 100.0, + 100.0, + 100.0 + ], + "mesh": 4 + }, + { + "name": "quad", + "translation": [ + 0.0, + 0.0, + 0.0 + ], + "rotation": [ + 8.14603353660459e-08, + 0.0, + 0.0, + 1.0 + ], + "scale": [ + 100.0, + 100.0, + 100.0 + ], + "mesh": 5 + }, + { + "name": "cylinder", + "translation": [ + 0.0, + 0.0, + 0.0 + ], + "rotation": [ + 8.14603353660459e-08, + 0.0, + 0.0, + 1.0 + ], + "scale": [ + 100.0, + 100.0, + 100.0 + ], + "mesh": 6 + }, + { + "name": "box", + "translation": [ + 0.0, + 0.0, + 0.0 + ], + "rotation": [ + 8.14603353660459e-08, + 0.0, + 0.0, + 1.0 + ], + "scale": [ + 100.0, + 100.0, + 100.0 + ], + "mesh": 7 + } + ] +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/temp/gltf/4142882b247e9c199882f8f75ed5cdbb_out/buffer.bin b/Layered_virtual_list_2.x/temp/gltf/4142882b247e9c199882f8f75ed5cdbb_out/buffer.bin new file mode 100644 index 0000000..743d7d2 Binary files /dev/null and b/Layered_virtual_list_2.x/temp/gltf/4142882b247e9c199882f8f75ed5cdbb_out/buffer.bin differ diff --git a/Layered_virtual_list_2.x/temp/gltf/98f966a1f05a368f7d69d15f85aec953_out/98f966a1f05a368f7d69d15f85aec953.gltf b/Layered_virtual_list_2.x/temp/gltf/98f966a1f05a368f7d69d15f85aec953_out/98f966a1f05a368f7d69d15f85aec953.gltf new file mode 100644 index 0000000..ca72477 --- /dev/null +++ b/Layered_virtual_list_2.x/temp/gltf/98f966a1f05a368f7d69d15f85aec953_out/98f966a1f05a368f7d69d15f85aec953.gltf @@ -0,0 +1,859 @@ +{ + "asset": { + "generator": "FBX2glTF", + "version": "2.0" + }, + "scene": 0, + "buffers": [ + { + "byteLength": 161028, + "uri": "buffer.bin" + } + ], + "bufferViews": [ + { + "buffer": 0, + "byteLength": 12288, + "byteOffset": 0, + "target": 34963 + }, + { + "buffer": 0, + "byteLength": 13860, + "byteOffset": 12288, + "target": 34962 + }, + { + "buffer": 0, + "byteLength": 13860, + "byteOffset": 26148, + "target": 34962 + }, + { + "buffer": 0, + "byteLength": 9240, + "byteOffset": 40008, + "target": 34962 + }, + { + "buffer": 0, + "byteLength": 1200, + "byteOffset": 49248, + "target": 34963 + }, + { + "buffer": 0, + "byteLength": 1452, + "byteOffset": 50448, + "target": 34962 + }, + { + "buffer": 0, + "byteLength": 1452, + "byteOffset": 51900, + "target": 34962 + }, + { + "buffer": 0, + "byteLength": 968, + "byteOffset": 53352, + "target": 34962 + }, + { + "buffer": 0, + "byteLength": 384, + "byteOffset": 54320, + "target": 34963 + }, + { + "buffer": 0, + "byteLength": 1548, + "byteOffset": 54704, + "target": 34962 + }, + { + "buffer": 0, + "byteLength": 1548, + "byteOffset": 56252, + "target": 34962 + }, + { + "buffer": 0, + "byteLength": 1032, + "byteOffset": 57800, + "target": 34962 + }, + { + "buffer": 0, + "byteLength": 12288, + "byteOffset": 58832, + "target": 34963 + }, + { + "buffer": 0, + "byteLength": 13068, + "byteOffset": 71120, + "target": 34962 + }, + { + "buffer": 0, + "byteLength": 13068, + "byteOffset": 84188, + "target": 34962 + }, + { + "buffer": 0, + "byteLength": 8712, + "byteOffset": 97256, + "target": 34962 + }, + { + "buffer": 0, + "byteLength": 12288, + "byteOffset": 105968, + "target": 34963 + }, + { + "buffer": 0, + "byteLength": 13068, + "byteOffset": 118256, + "target": 34962 + }, + { + "buffer": 0, + "byteLength": 13068, + "byteOffset": 131324, + "target": 34962 + }, + { + "buffer": 0, + "byteLength": 8712, + "byteOffset": 144392, + "target": 34962 + }, + { + "buffer": 0, + "byteLength": 12, + "byteOffset": 153104, + "target": 34963 + }, + { + "buffer": 0, + "byteLength": 48, + "byteOffset": 153116, + "target": 34962 + }, + { + "buffer": 0, + "byteLength": 48, + "byteOffset": 153164, + "target": 34962 + }, + { + "buffer": 0, + "byteLength": 32, + "byteOffset": 153212, + "target": 34962 + }, + { + "buffer": 0, + "byteLength": 768, + "byteOffset": 153244, + "target": 34963 + }, + { + "buffer": 0, + "byteLength": 2316, + "byteOffset": 154012, + "target": 34962 + }, + { + "buffer": 0, + "byteLength": 2316, + "byteOffset": 156328, + "target": 34962 + }, + { + "buffer": 0, + "byteLength": 1544, + "byteOffset": 158644, + "target": 34962 + }, + { + "buffer": 0, + "byteLength": 72, + "byteOffset": 160188, + "target": 34963 + }, + { + "buffer": 0, + "byteLength": 288, + "byteOffset": 160260, + "target": 34962 + }, + { + "buffer": 0, + "byteLength": 288, + "byteOffset": 160548, + "target": 34962 + }, + { + "buffer": 0, + "byteLength": 192, + "byteOffset": 160836, + "target": 34962 + } + ], + "scenes": [ + { + "name": "Root Scene", + "nodes": [ + 0 + ] + } + ], + "accessors": [ + { + "componentType": 5123, + "type": "SCALAR", + "count": 6144, + "bufferView": 0, + "byteOffset": 0 + }, + { + "componentType": 5126, + "type": "VEC3", + "count": 1155, + "bufferView": 1, + "byteOffset": 0, + "min": [ + -0.5, + -1.0, + -0.5 + ], + "max": [ + 0.5, + 1.0, + 0.5 + ] + }, + { + "componentType": 5126, + "type": "VEC3", + "count": 1155, + "bufferView": 2, + "byteOffset": 0 + }, + { + "componentType": 5126, + "type": "VEC2", + "count": 1155, + "bufferView": 3, + "byteOffset": 0 + }, + { + "componentType": 5123, + "type": "SCALAR", + "count": 600, + "bufferView": 4, + "byteOffset": 0 + }, + { + "componentType": 5126, + "type": "VEC3", + "count": 121, + "bufferView": 5, + "byteOffset": 0, + "min": [ + -5.0, + 0.0, + -5.0 + ], + "max": [ + 5.0, + 0.0, + 5.0 + ] + }, + { + "componentType": 5126, + "type": "VEC3", + "count": 121, + "bufferView": 6, + "byteOffset": 0 + }, + { + "componentType": 5126, + "type": "VEC2", + "count": 121, + "bufferView": 7, + "byteOffset": 0 + }, + { + "componentType": 5123, + "type": "SCALAR", + "count": 192, + "bufferView": 8, + "byteOffset": 0 + }, + { + "componentType": 5126, + "type": "VEC3", + "count": 129, + "bufferView": 9, + "byteOffset": 0, + "min": [ + -0.5, + -0.5, + -0.499999940395355 + ], + "max": [ + 0.5, + 0.5, + 0.5 + ] + }, + { + "componentType": 5126, + "type": "VEC3", + "count": 129, + "bufferView": 10, + "byteOffset": 0 + }, + { + "componentType": 5126, + "type": "VEC2", + "count": 129, + "bufferView": 11, + "byteOffset": 0 + }, + { + "componentType": 5123, + "type": "SCALAR", + "count": 6144, + "bufferView": 12, + "byteOffset": 0 + }, + { + "componentType": 5126, + "type": "VEC3", + "count": 1089, + "bufferView": 13, + "byteOffset": 0, + "min": [ + -0.5, + -0.0999999940395355, + -0.5 + ], + "max": [ + 0.5, + 0.0999999940395355, + 0.5 + ] + }, + { + "componentType": 5126, + "type": "VEC3", + "count": 1089, + "bufferView": 14, + "byteOffset": 0 + }, + { + "componentType": 5126, + "type": "VEC2", + "count": 1089, + "bufferView": 15, + "byteOffset": 0 + }, + { + "componentType": 5123, + "type": "SCALAR", + "count": 6144, + "bufferView": 16, + "byteOffset": 0 + }, + { + "componentType": 5126, + "type": "VEC3", + "count": 1089, + "bufferView": 17, + "byteOffset": 0, + "min": [ + -0.5, + -0.5, + -0.5 + ], + "max": [ + 0.5, + 0.5, + 0.5 + ] + }, + { + "componentType": 5126, + "type": "VEC3", + "count": 1089, + "bufferView": 18, + "byteOffset": 0 + }, + { + "componentType": 5126, + "type": "VEC2", + "count": 1089, + "bufferView": 19, + "byteOffset": 0 + }, + { + "componentType": 5123, + "type": "SCALAR", + "count": 6, + "bufferView": 20, + "byteOffset": 0 + }, + { + "componentType": 5126, + "type": "VEC3", + "count": 4, + "bufferView": 21, + "byteOffset": 0, + "min": [ + -0.5, + -0.5, + 0.0 + ], + "max": [ + 0.5, + 0.5, + 0.0 + ] + }, + { + "componentType": 5126, + "type": "VEC3", + "count": 4, + "bufferView": 22, + "byteOffset": 0 + }, + { + "componentType": 5126, + "type": "VEC2", + "count": 4, + "bufferView": 23, + "byteOffset": 0 + }, + { + "componentType": 5123, + "type": "SCALAR", + "count": 384, + "bufferView": 24, + "byteOffset": 0 + }, + { + "componentType": 5126, + "type": "VEC3", + "count": 193, + "bufferView": 25, + "byteOffset": 0, + "min": [ + -0.5, + -1.0, + -0.5 + ], + "max": [ + 0.5, + 1.0, + 0.5 + ] + }, + { + "componentType": 5126, + "type": "VEC3", + "count": 193, + "bufferView": 26, + "byteOffset": 0 + }, + { + "componentType": 5126, + "type": "VEC2", + "count": 193, + "bufferView": 27, + "byteOffset": 0 + }, + { + "componentType": 5123, + "type": "SCALAR", + "count": 36, + "bufferView": 28, + "byteOffset": 0 + }, + { + "componentType": 5126, + "type": "VEC3", + "count": 24, + "bufferView": 29, + "byteOffset": 0, + "min": [ + -0.5, + -0.5, + -0.5 + ], + "max": [ + 0.5, + 0.5, + 0.5 + ] + }, + { + "componentType": 5126, + "type": "VEC3", + "count": 24, + "bufferView": 30, + "byteOffset": 0 + }, + { + "componentType": 5126, + "type": "VEC2", + "count": 24, + "bufferView": 31, + "byteOffset": 0 + } + ], + "samplers": [ + {} + ], + "materials": [ + { + "name": "DefaultMaterial", + "alphaMode": "OPAQUE", + "extras": { + "fromFBX": { + "shadingModel": "Lambert", + "isTruePBR": false + } + }, + "pbrMetallicRoughness": { + "baseColorFactor": [ + 0.5, + 0.5, + 0.5, + 1.0 + ], + "metallicFactor": 0.200000002980232, + "roughnessFactor": 0.800000011920929 + } + } + ], + "meshes": [ + { + "name": "capsule", + "primitives": [ + { + "material": 0, + "mode": 4, + "attributes": { + "NORMAL": 2, + "POSITION": 1, + "TEXCOORD_0": 3 + }, + "indices": 0 + } + ] + }, + { + "name": "plane", + "primitives": [ + { + "material": 0, + "mode": 4, + "attributes": { + "NORMAL": 6, + "POSITION": 5, + "TEXCOORD_0": 7 + }, + "indices": 4 + } + ] + }, + { + "name": "cone", + "primitives": [ + { + "material": 0, + "mode": 4, + "attributes": { + "NORMAL": 10, + "POSITION": 9, + "TEXCOORD_0": 11 + }, + "indices": 8 + } + ] + }, + { + "name": "torus", + "primitives": [ + { + "material": 0, + "mode": 4, + "attributes": { + "NORMAL": 14, + "POSITION": 13, + "TEXCOORD_0": 15 + }, + "indices": 12 + } + ] + }, + { + "name": "sphere", + "primitives": [ + { + "material": 0, + "mode": 4, + "attributes": { + "NORMAL": 18, + "POSITION": 17, + "TEXCOORD_0": 19 + }, + "indices": 16 + } + ] + }, + { + "name": "quad", + "primitives": [ + { + "material": 0, + "mode": 4, + "attributes": { + "NORMAL": 22, + "POSITION": 21, + "TEXCOORD_0": 23 + }, + "indices": 20 + } + ] + }, + { + "name": "cylinder", + "primitives": [ + { + "material": 0, + "mode": 4, + "attributes": { + "NORMAL": 26, + "POSITION": 25, + "TEXCOORD_0": 27 + }, + "indices": 24 + } + ] + }, + { + "name": "box", + "primitives": [ + { + "material": 0, + "mode": 4, + "attributes": { + "NORMAL": 30, + "POSITION": 29, + "TEXCOORD_0": 31 + }, + "indices": 28 + } + ] + } + ], + "nodes": [ + { + "name": "RootNode", + "translation": [ + 0.0, + 0.0, + 0.0 + ], + "rotation": [ + 0.0, + 0.0, + 0.0, + 1.0 + ], + "scale": [ + 1.0, + 1.0, + 1.0 + ], + "children": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8 + ] + }, + { + "name": "capsule", + "translation": [ + 0.0, + 0.0, + 0.0 + ], + "rotation": [ + 8.14603353660459e-08, + 0.0, + 0.0, + 1.0 + ], + "scale": [ + 100.0, + 100.0, + 100.0 + ], + "mesh": 0 + }, + { + "name": "plane", + "translation": [ + 0.0, + 0.0, + 0.0 + ], + "rotation": [ + 8.14603353660459e-08, + 0.0, + 0.0, + 1.0 + ], + "scale": [ + 100.0, + 100.0, + 100.0 + ], + "mesh": 1 + }, + { + "name": "cone", + "translation": [ + 0.0, + 0.0, + 0.0 + ], + "rotation": [ + -0.707106828689575, + 0.0, + 0.0, + 0.707106709480286 + ], + "scale": [ + 100.0, + 100.0, + 100.0 + ], + "mesh": 2 + }, + { + "name": "torus", + "translation": [ + 0.0, + 0.0, + 0.0 + ], + "rotation": [ + 8.14603353660459e-08, + 0.0, + 0.0, + 1.0 + ], + "scale": [ + 100.0, + 100.0, + 100.0 + ], + "mesh": 3 + }, + { + "name": "sphere", + "translation": [ + 0.0, + 0.0, + 0.0 + ], + "rotation": [ + 8.14603353660459e-08, + 0.0, + 0.0, + 1.0 + ], + "scale": [ + 100.0, + 100.0, + 100.0 + ], + "mesh": 4 + }, + { + "name": "quad", + "translation": [ + 0.0, + 0.0, + 0.0 + ], + "rotation": [ + 8.14603353660459e-08, + 0.0, + 0.0, + 1.0 + ], + "scale": [ + 100.0, + 100.0, + 100.0 + ], + "mesh": 5 + }, + { + "name": "cylinder", + "translation": [ + 0.0, + 0.0, + 0.0 + ], + "rotation": [ + 8.14603353660459e-08, + 0.0, + 0.0, + 1.0 + ], + "scale": [ + 100.0, + 100.0, + 100.0 + ], + "mesh": 6 + }, + { + "name": "box", + "translation": [ + 0.0, + 0.0, + 0.0 + ], + "rotation": [ + 8.14603353660459e-08, + 0.0, + 0.0, + 1.0 + ], + "scale": [ + 100.0, + 100.0, + 100.0 + ], + "mesh": 7 + } + ] +} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/temp/gltf/98f966a1f05a368f7d69d15f85aec953_out/buffer.bin b/Layered_virtual_list_2.x/temp/gltf/98f966a1f05a368f7d69d15f85aec953_out/buffer.bin new file mode 100644 index 0000000..743d7d2 Binary files /dev/null and b/Layered_virtual_list_2.x/temp/gltf/98f966a1f05a368f7d69d15f85aec953_out/buffer.bin differ diff --git a/Layered_virtual_list_2.x/temp/quick-scripts/dst/__file_stats__.json b/Layered_virtual_list_2.x/temp/quick-scripts/dst/__file_stats__.json new file mode 100644 index 0000000..5ca13ae --- /dev/null +++ b/Layered_virtual_list_2.x/temp/quick-scripts/dst/__file_stats__.json @@ -0,0 +1 @@ +{"version":"1.0.8","stats":{"D:/CocosProject/Layered_virtual_list_2.x/temp/quick-scripts/src/__qc_index__.js":"2024-10-30T13:03:25.540Z","D:/CocosProject/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Scene/TestRenderAlternative.js":"2024-10-30T12:50:44.958Z","D:/CocosProject/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Script/RenderAlternative.js":"2024-10-30T12:50:44.961Z","D:/CocosProject/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Scene/TestShowNode.js":"2024-10-30T12:50:44.957Z","D:/CocosProject/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Scene/TestMatrix.js":"2024-10-30T12:50:44.954Z","D:/CocosProject/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Scene/Item.js":"2024-10-30T12:50:44.956Z","D:/CocosProject/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Script/RenderAlternativeItem.js":"2024-10-30T12:50:44.960Z","D:/CocosProject/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Scene/TestLoop.js":"2024-10-30T12:50:44.955Z","D:/CocosProject/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Script/RenderReactiveHandler.js":"2024-10-30T12:50:44.960Z","D:/CocosProject/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Script/LoopList.js":"2024-10-30T12:50:44.957Z","D:/CocosProject/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Script/RenderAlternative_old.js":"2024-10-30T12:50:44.953Z"}} diff --git a/Layered_virtual_list_2.x/temp/quick-scripts/dst/__qc_bundle__.js b/Layered_virtual_list_2.x/temp/quick-scripts/dst/__qc_bundle__.js new file mode 100644 index 0000000..e56dfc3 --- /dev/null +++ b/Layered_virtual_list_2.x/temp/quick-scripts/dst/__qc_bundle__.js @@ -0,0 +1,2671 @@ + + (function() { + var nodeEnv = typeof require !== 'undefined' && typeof process !== 'undefined'; + var __module = nodeEnv ? module : {exports:{}}; + var __filename = 'preview-scripts/__qc_index__.js'; + var __require = nodeEnv ? function (request) { + return cc.require(request); + } : function (request) { + return __quick_compile_project__.require(request, __filename); + }; + function __define (exports, require, module) { + if (!nodeEnv) {__quick_compile_project__.registerModule(__filename, module);} +require('./assets/Scene/Item'); +require('./assets/Scene/TestLoop'); +require('./assets/Scene/TestMatrix'); +require('./assets/Scene/TestRenderAlternative'); +require('./assets/Scene/TestShowNode'); +require('./assets/Script/LoopList'); +require('./assets/Script/RenderAlternative'); +require('./assets/Script/RenderAlternative1'); +require('./assets/Script/RenderAlternativeItem'); +require('./assets/Script/RenderAlternative_old'); +require('./assets/Script/RenderReactiveHandler'); + + } + if (nodeEnv) { + __define(__module.exports, __require, __module); + } + else { + __quick_compile_project__.registerModuleFunc(__filename, function () { + __define(__module.exports, __require, __module); + }); + } + })(); +//------QC-SOURCE-SPLIT------ + + (function() { + var nodeEnv = typeof require !== 'undefined' && typeof process !== 'undefined'; + var __module = nodeEnv ? module : {exports:{}}; + var __filename = 'preview-scripts/assets/Scene/TestRenderAlternative.js'; + var __require = nodeEnv ? function (request) { + return cc.require(request); + } : function (request) { + return __quick_compile_project__.require(request, __filename); + }; + function __define (exports, require, module) { + if (!nodeEnv) {__quick_compile_project__.registerModule(__filename, module);}"use strict"; +cc._RF.push(module, 'b9be0tgoIVPk72LiE6N39f/', 'TestRenderAlternative'); +// Scene/TestRenderAlternative.ts + +"use strict"; +// Learn TypeScript: +// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html +// Learn Attribute: +// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html +// Learn life-cycle callbacks: +// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property; +var TestRenderAlternative = /** @class */ (function (_super) { + __extends(TestRenderAlternative, _super); + function TestRenderAlternative() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.scrollView = null; + _this.prefab = null; + _this.layer = null; + return _this; + // update (dt) {} + } + // onLoad () {} + TestRenderAlternative.prototype.start = function () { + var count = 1000; + var datas = []; + for (var i = 0; i < count; i++) { + var data = { name: 'name' + i, index: i }; + datas.push({ data: data, layer: this.layer }); + } + for (var i = 0; i < datas.length; i++) { + var item = cc.instantiate(this.prefab); + this.scrollView.content.addChild(item); + item.getComponent('Item').init(datas[i]); + } + }; + __decorate([ + property(cc.ScrollView) + ], TestRenderAlternative.prototype, "scrollView", void 0); + __decorate([ + property(cc.Prefab) + ], TestRenderAlternative.prototype, "prefab", void 0); + __decorate([ + property(cc.Node) + ], TestRenderAlternative.prototype, "layer", void 0); + TestRenderAlternative = __decorate([ + ccclass + ], TestRenderAlternative); + return TestRenderAlternative; +}(cc.Component)); +exports.default = TestRenderAlternative; + +cc._RF.pop(); + } + if (nodeEnv) { + __define(__module.exports, __require, __module); + } + else { + __quick_compile_project__.registerModuleFunc(__filename, function () { + __define(__module.exports, __require, __module); + }); + } + })(); +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImFzc2V0c1xcU2NlbmVcXFRlc3RSZW5kZXJBbHRlcm5hdGl2ZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7O0FBQUEsb0JBQW9CO0FBQ3BCLHdFQUF3RTtBQUN4RSxtQkFBbUI7QUFDbkIsa0ZBQWtGO0FBQ2xGLDhCQUE4QjtBQUM5QixrRkFBa0Y7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OztBQUU1RSxJQUFBLEtBQXdCLEVBQUUsQ0FBQyxVQUFVLEVBQW5DLE9BQU8sYUFBQSxFQUFFLFFBQVEsY0FBa0IsQ0FBQztBQUc1QztJQUFtRCx5Q0FBWTtJQUEvRDtRQUFBLHFFQTZCQztRQTFCRyxnQkFBVSxHQUFrQixJQUFJLENBQUM7UUFHakMsWUFBTSxHQUFjLElBQUksQ0FBQztRQUd6QixXQUFLLEdBQVksSUFBSSxDQUFDOztRQW1CdEIsaUJBQWlCO0lBQ3JCLENBQUM7SUFsQkcsZUFBZTtJQUVmLHFDQUFLLEdBQUw7UUFDSSxJQUFJLEtBQUssR0FBRyxJQUFJLENBQUM7UUFDakIsSUFBSSxLQUFLLEdBQUcsRUFBRSxDQUFDO1FBQ2YsS0FBSyxJQUFJLENBQUMsR0FBRyxDQUFDLEVBQUUsQ0FBQyxHQUFHLEtBQUssRUFBRSxDQUFDLEVBQUUsRUFBRTtZQUM1QixJQUFJLElBQUksR0FBRyxFQUFFLElBQUksRUFBRSxNQUFNLEdBQUcsQ0FBQyxFQUFFLEtBQUssRUFBRSxDQUFDLEVBQUUsQ0FBQztZQUMxQyxLQUFLLENBQUMsSUFBSSxDQUFDLEVBQUUsSUFBSSxFQUFFLElBQUksRUFBRSxLQUFLLEVBQUUsSUFBSSxDQUFDLEtBQUssRUFBRSxDQUFDLENBQUM7U0FDakQ7UUFFRCxLQUFLLElBQUksQ0FBQyxHQUFHLENBQUMsRUFBRSxDQUFDLEdBQUcsS0FBSyxDQUFDLE1BQU0sRUFBRSxDQUFDLEVBQUUsRUFBRTtZQUNuQyxJQUFJLElBQUksR0FBRyxFQUFFLENBQUMsV0FBVyxDQUFDLElBQUksQ0FBQyxNQUFNLENBQUMsQ0FBQztZQUN2QyxJQUFJLENBQUMsVUFBVSxDQUFDLE9BQU8sQ0FBQyxRQUFRLENBQUMsSUFBSSxDQUFDLENBQUM7WUFDdkMsSUFBSSxDQUFDLFlBQVksQ0FBQyxNQUFNLENBQUMsQ0FBQyxJQUFJLENBQUMsS0FBSyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUM7U0FDNUM7SUFDTCxDQUFDO0lBdkJEO1FBREMsUUFBUSxDQUFDLEVBQUUsQ0FBQyxVQUFVLENBQUM7NkRBQ1M7SUFHakM7UUFEQyxRQUFRLENBQUMsRUFBRSxDQUFDLE1BQU0sQ0FBQzt5REFDSztJQUd6QjtRQURDLFFBQVEsQ0FBQyxFQUFFLENBQUMsSUFBSSxDQUFDO3dEQUNJO0lBVEwscUJBQXFCO1FBRHpDLE9BQU87T0FDYSxxQkFBcUIsQ0E2QnpDO0lBQUQsNEJBQUM7Q0E3QkQsQUE2QkMsQ0E3QmtELEVBQUUsQ0FBQyxTQUFTLEdBNkI5RDtrQkE3Qm9CLHFCQUFxQiIsImZpbGUiOiIiLCJzb3VyY2VSb290IjoiLyIsInNvdXJjZXNDb250ZW50IjpbIi8vIExlYXJuIFR5cGVTY3JpcHQ6XHJcbi8vICAtIGh0dHBzOi8vZG9jcy5jb2Nvcy5jb20vY3JlYXRvci9tYW51YWwvZW4vc2NyaXB0aW5nL3R5cGVzY3JpcHQuaHRtbFxyXG4vLyBMZWFybiBBdHRyaWJ1dGU6XHJcbi8vICAtIGh0dHBzOi8vZG9jcy5jb2Nvcy5jb20vY3JlYXRvci9tYW51YWwvZW4vc2NyaXB0aW5nL3JlZmVyZW5jZS9hdHRyaWJ1dGVzLmh0bWxcclxuLy8gTGVhcm4gbGlmZS1jeWNsZSBjYWxsYmFja3M6XHJcbi8vICAtIGh0dHBzOi8vZG9jcy5jb2Nvcy5jb20vY3JlYXRvci9tYW51YWwvZW4vc2NyaXB0aW5nL2xpZmUtY3ljbGUtY2FsbGJhY2tzLmh0bWxcclxuXHJcbmNvbnN0IHsgY2NjbGFzcywgcHJvcGVydHkgfSA9IGNjLl9kZWNvcmF0b3I7XHJcblxyXG5AY2NjbGFzc1xyXG5leHBvcnQgZGVmYXVsdCBjbGFzcyBUZXN0UmVuZGVyQWx0ZXJuYXRpdmUgZXh0ZW5kcyBjYy5Db21wb25lbnQge1xyXG5cclxuICAgIEBwcm9wZXJ0eShjYy5TY3JvbGxWaWV3KVxyXG4gICAgc2Nyb2xsVmlldzogY2MuU2Nyb2xsVmlldyA9IG51bGw7XHJcblxyXG4gICAgQHByb3BlcnR5KGNjLlByZWZhYilcclxuICAgIHByZWZhYjogY2MuUHJlZmFiID0gbnVsbDtcclxuXHJcbiAgICBAcHJvcGVydHkoY2MuTm9kZSlcclxuICAgIGxheWVyOiBjYy5Ob2RlID0gbnVsbDtcclxuXHJcbiAgICAvLyBvbkxvYWQgKCkge31cclxuXHJcbiAgICBzdGFydCgpIHtcclxuICAgICAgICBsZXQgY291bnQgPSAxMDAwO1xyXG4gICAgICAgIGxldCBkYXRhcyA9IFtdO1xyXG4gICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgY291bnQ7IGkrKykge1xyXG4gICAgICAgICAgICBsZXQgZGF0YSA9IHsgbmFtZTogJ25hbWUnICsgaSwgaW5kZXg6IGkgfTtcclxuICAgICAgICAgICAgZGF0YXMucHVzaCh7IGRhdGE6IGRhdGEsIGxheWVyOiB0aGlzLmxheWVyIH0pO1xyXG4gICAgICAgIH1cclxuXHJcbiAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBkYXRhcy5sZW5ndGg7IGkrKykge1xyXG4gICAgICAgICAgICBsZXQgaXRlbSA9IGNjLmluc3RhbnRpYXRlKHRoaXMucHJlZmFiKTtcclxuICAgICAgICAgICAgdGhpcy5zY3JvbGxWaWV3LmNvbnRlbnQuYWRkQ2hpbGQoaXRlbSk7XHJcbiAgICAgICAgICAgIGl0ZW0uZ2V0Q29tcG9uZW50KCdJdGVtJykuaW5pdChkYXRhc1tpXSk7XHJcbiAgICAgICAgfVxyXG4gICAgfVxyXG5cclxuICAgIC8vIHVwZGF0ZSAoZHQpIHt9XHJcbn1cclxuIl19 +//------QC-SOURCE-SPLIT------ + + (function() { + var nodeEnv = typeof require !== 'undefined' && typeof process !== 'undefined'; + var __module = nodeEnv ? module : {exports:{}}; + var __filename = 'preview-scripts/assets/Script/RenderAlternative.js'; + var __require = nodeEnv ? function (request) { + return cc.require(request); + } : function (request) { + return __quick_compile_project__.require(request, __filename); + }; + function __define (exports, require, module) { + if (!nodeEnv) {__quick_compile_project__.registerModule(__filename, module);}"use strict"; +cc._RF.push(module, 'f9782xj4QNK842OAHoabRFb', 'RenderAlternative'); +// Script/RenderAlternative.ts + +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var RenderReactiveHandler_1 = require("./RenderReactiveHandler"); +/** + * 目前该渲染代理功能存在的问题 + * 1.被代理节点的父级不能出现scaleX和scaleY不一致的情况,被代理节点本身没有这个限制 + */ +var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property; +var RenderAlternative = /** @class */ (function (_super) { + __extends(RenderAlternative, _super); + function RenderAlternative() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /**渲染层节点 */ + _this.renderLayer = null; + /**渲染的zIndex 动态调整zIndex,用于方便临近合批 */ + _this.renderZIndex = 0; + /**同步的间隔(帧为单位) */ + _this.syncInv = 0.01; + /**渲染的sIndex */ + _this.sIndex = 0; + /**非渲染组件 */ + _this.proxyRender = null; + /**渲染组件 */ + _this.renderCompnent = null; + /**上次更新的数据 */ + _this.lastWMat4 = null; + /**上次更新的数据 */ + _this.lastLMat4 = null; + /**上次更新的数据 */ + _this.lastPos = null; + /**距离下次刷新累计了多少间隔 */ + _this.accuTime = 0; + /**最后一次刷新时间 */ + _this.lastFrameTime = null; + /**是否进行刷新 */ + _this.isAttachFrame = false; + return _this; + } + RenderAlternative_1 = RenderAlternative; + Object.defineProperty(RenderAlternative.prototype, "zIndex", { + /**获取总的ZIndex */ + get: function () { + var zIndex = this.renderZIndex + (this.sIndex * 0.01); + var parentNode = this.node.parent; + while (parentNode != this.renderLayer.parent && parentNode != cc.director.getScene()) { + var render = parentNode.getComponent(RenderAlternative_1); + if (render) { + zIndex += render.zIndex + 1; + break; + } + parentNode = parentNode.parent; + } + return zIndex; + }, + enumerable: false, + configurable: true + }); + /** + * 设置渲染节点层 + * @param layer + */ + RenderAlternative.prototype.init = function (layer) { + if (layer) { + this.renderLayer = layer; + } + if (!this.renderLayer) { + console.warn("\u8282\u70B9" + this.node.name + "\u6CA1\u6709\u8BBE\u7F6E\u6E32\u67D3\u5C42"); + return null; + } + return this.initRender(); + }; + /** + * 初始化渲染节点 + */ + RenderAlternative.prototype.initRender = function () { + var node = this.getRender(); + node.setParent(this.renderLayer ? this.renderLayer : cc.director.getScene().getChildByName("Canvas")); + this.isAttachFrame = true; + requestAnimationFrame(this.frameUpdate.bind(this)); + return this.doProxy(); + }; + /**生成代理 */ + RenderAlternative.prototype.doProxy = function () { + this.proxyRender = new Proxy(this.renderCompnent, new RenderReactiveHandler_1.RenderReactiveHandler()); + return this.proxyRender; + }; + RenderAlternative.prototype.frameUpdate = function () { + var now = cc.sys.now(); + !this.lastFrameTime && (this.lastFrameTime = now); + var dt = now - this.lastFrameTime; + if (this.proxyRender) { + this.accuTime += dt; + if (this.accuTime >= this.syncInv) { + this.accuTime -= this.syncInv; + this.updateProp(); + } + } + if (this.isAttachFrame) { + requestAnimationFrame(this.frameUpdate.bind(this)); + } + }; + /**更新最新状态 */ + RenderAlternative.prototype.updateProp = function () { + var node = this.renderCompnent.node; + if (!this.node.activeInHierarchy) { + node.opacity = 0; + return; + } + node.anchorX = this.node.anchorX; + node.anchorY = this.node.anchorY; + node.width = this.node.width; + node.height = this.node.height; + node.group = this.node.group; + node.color = this.node.color; + node.opacity = this.getOpacity(this.node); + var wMat4 = cc.mat4(); + this.node.getWorldMatrix(wMat4); + if (!this.lastWMat4 || !this.lastWMat4.equals(wMat4)) { + var localMatrix = this.getLocalMatrix(wMat4, node); + this.setLocalXYZScaleAngle(localMatrix, node, this.lastLMat4); + this.lastWMat4 = wMat4; + this.lastLMat4 = localMatrix; + } + node.zIndex = this.zIndex; + }; + RenderAlternative.prototype.getLocalMatrix = function (worldMatrix, node) { + var parentNode = null; + if (cc.isValid(node)) { + if (cc.isValid(node.parent)) { + parentNode = node.parent; + } + } + // 获取父节点的世界矩阵 + var parentWorldMatrix = cc.mat4(); + parentNode.getWorldMatrix(parentWorldMatrix); + // 获取父节点的逆矩阵 + var parentInverseMatrix = parentWorldMatrix.invert(); + // 将目标节点的世界矩阵转换为父节点的本地矩阵 + var localMatrix = parentInverseMatrix.multiply(worldMatrix); + return localMatrix; + }; + RenderAlternative.prototype.setLocalXYZScaleAngle = function (matrix, node, lastMatrix) { + if (lastMatrix && matrix.equals(lastMatrix)) { + return; + } + // 提取位置 + node.setPosition(matrix.m[12], matrix.m[13], matrix.m[14]); + var scaleX = null; + var scaleY = null; + var angle = null; + // 提取缩放X + if (!lastMatrix) { + scaleX = Math.sqrt(matrix.m[0] * matrix.m[0] + matrix.m[1] * matrix.m[1] + matrix.m[2] * matrix.m[2]); + } + else if (!this.equalsValue(matrix.m[0], lastMatrix.m[0]) + || !this.equalsValue(matrix.m[1], lastMatrix.m[1]) + || !this.equalsValue(matrix.m[2], lastMatrix.m[2])) { + scaleX = Math.sqrt(matrix.m[0] * matrix.m[0] + matrix.m[1] * matrix.m[1] + matrix.m[2] * matrix.m[2]); + } + // 提取缩放Y + if (!lastMatrix) { + scaleY = Math.sqrt(matrix.m[4] * matrix.m[4] + matrix.m[5] * matrix.m[5] + matrix.m[6] * matrix.m[6]); + } + else if (!this.equalsValue(matrix.m[4], lastMatrix.m[4]) + || !this.equalsValue(matrix.m[5], lastMatrix.m[5]) + || !this.equalsValue(matrix.m[6], lastMatrix.m[6])) { + scaleY = Math.sqrt(matrix.m[4] * matrix.m[4] + matrix.m[5] * matrix.m[5] + matrix.m[6] * matrix.m[6]); + } + //设置缩放X + if (scaleX !== null) { + node.scaleX = scaleX; + // 提取旋转 + angle = Math.atan2(matrix.m[1] / scaleX, matrix.m[0] / scaleX) * (180 / Math.PI); + } + if (scaleY !== null) { + node.scaleY = scaleY; + } + if (angle !== null) { + node.rotation = angle; + } + }; + RenderAlternative.prototype.equalsValue = function (a, b, epsilon) { + if (epsilon === void 0) { epsilon = 0.00001; } + return Math.abs(a - b) < epsilon; + }; + RenderAlternative.prototype.onDestroy = function () { + this.renderCompnent.node.destroy(); + this.renderCompnent = null; + this.proxyRender = null; + }; + /** + * 获取节点透明度 + * @param node + */ + RenderAlternative.prototype.getOpacity = function (node) { + var opacity = (node.opacity / 255); + var parentNode = node.parent; + while (parentNode != this.renderLayer.parent && parentNode != cc.director.getScene()) { + opacity *= (parentNode.opacity / 255); + parentNode = parentNode.parent; + } + return opacity * 255; + }; + /** + * 获取渲染组件 + * @param node + */ + RenderAlternative.prototype.getRender = function () { + var _a, _b; + var node = cc.instantiate(this.node); + node.removeAllChildren(); + this.renderCompnent = node.getComponent(cc.RenderComponent); + (_a = this.node.getComponent(cc.LabelOutline)) === null || _a === void 0 ? void 0 : _a.destroy(); + (_b = this.node.getComponent(cc.LabelShadow)) === null || _b === void 0 ? void 0 : _b.destroy(); + this.node.getComponent(cc.RenderComponent).destroy(); + var components = node.getComponents(cc.Component); + for (var i = 0, len = components.length; i < len; ++i) { + var comp = components[i]; + if (!((comp instanceof cc.RenderComponent) || (comp instanceof cc.LabelOutline) || (comp instanceof cc.LabelShadow))) { + comp.destroy(); + } + } + return node; + }; + var RenderAlternative_1; + __decorate([ + property + ], RenderAlternative.prototype, "renderZIndex", void 0); + __decorate([ + property({ + tooltip: '设置同步的间隔(秒为单位),0就是每帧都同步,0.1就是隔0.1秒同步一次' + }) + ], RenderAlternative.prototype, "syncInv", void 0); + RenderAlternative = RenderAlternative_1 = __decorate([ + ccclass + ], RenderAlternative); + return RenderAlternative; +}(cc.Component)); +exports.default = RenderAlternative; + +cc._RF.pop(); + } + if (nodeEnv) { + __define(__module.exports, __require, __module); + } + else { + __quick_compile_project__.registerModuleFunc(__filename, function () { + __define(__module.exports, __require, __module); + }); + } + })(); +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImFzc2V0c1xcU2NyaXB0XFxSZW5kZXJBbHRlcm5hdGl2ZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7QUFBQSxpRUFBZ0U7QUFFaEU7OztHQUdHO0FBQ0csSUFBQSxLQUF3QixFQUFFLENBQUMsVUFBVSxFQUFuQyxPQUFPLGFBQUEsRUFBRSxRQUFRLGNBQWtCLENBQUM7QUFFNUM7SUFBK0MscUNBQVk7SUFBM0Q7UUFBQSxxRUE2TkM7UUE1TkcsV0FBVztRQUNKLGlCQUFXLEdBQVksSUFBSSxDQUFDO1FBQ25DLG1DQUFtQztRQUU1QixrQkFBWSxHQUFXLENBQUMsQ0FBQztRQUNoQyxpQkFBaUI7UUFJVixhQUFPLEdBQVcsSUFBSSxDQUFDO1FBQzlCLGVBQWU7UUFDUixZQUFNLEdBQVcsQ0FBQyxDQUFDO1FBQzFCLFdBQVc7UUFDSixpQkFBVyxHQUF1QixJQUFJLENBQUM7UUFDOUMsVUFBVTtRQUNGLG9CQUFjLEdBQXVCLElBQUksQ0FBQztRQUNsRCxhQUFhO1FBQ04sZUFBUyxHQUFZLElBQUksQ0FBQztRQUNqQyxhQUFhO1FBQ04sZUFBUyxHQUFZLElBQUksQ0FBQztRQUNqQyxhQUFhO1FBQ04sYUFBTyxHQUFZLElBQUksQ0FBQztRQUMvQixtQkFBbUI7UUFDWixjQUFRLEdBQVcsQ0FBQyxDQUFDO1FBQzVCLGNBQWM7UUFDUCxtQkFBYSxHQUFXLElBQUksQ0FBQztRQUNwQyxZQUFZO1FBQ0wsbUJBQWEsR0FBWSxLQUFLLENBQUM7O0lBaU0xQyxDQUFDOzBCQTdOb0IsaUJBQWlCO0lBK0JsQyxzQkFBSSxxQ0FBTTtRQURWLGdCQUFnQjthQUNoQjtZQUNJLElBQUksTUFBTSxHQUFHLElBQUksQ0FBQyxZQUFZLEdBQUcsQ0FBQyxJQUFJLENBQUMsTUFBTSxHQUFHLElBQUksQ0FBQyxDQUFDO1lBQ3RELElBQUksVUFBVSxHQUFHLElBQUksQ0FBQyxJQUFJLENBQUMsTUFBTSxDQUFDO1lBQ2xDLE9BQU8sVUFBVSxJQUFJLElBQUksQ0FBQyxXQUFXLENBQUMsTUFBTSxJQUFJLFVBQVUsSUFBSSxFQUFFLENBQUMsUUFBUSxDQUFDLFFBQVEsRUFBRSxFQUFFO2dCQUNsRixJQUFJLE1BQU0sR0FBRyxVQUFVLENBQUMsWUFBWSxDQUFDLG1CQUFpQixDQUFDLENBQUM7Z0JBQ3hELElBQUksTUFBTSxFQUFFO29CQUNSLE1BQU0sSUFBSSxNQUFNLENBQUMsTUFBTSxHQUFHLENBQUMsQ0FBQztvQkFDNUIsTUFBTTtpQkFDVDtnQkFDRCxVQUFVLEdBQUcsVUFBVSxDQUFDLE1BQU0sQ0FBQzthQUNsQztZQUNELE9BQU8sTUFBTSxDQUFDO1FBQ2xCLENBQUM7OztPQUFBO0lBRUQ7OztPQUdHO0lBQ0gsZ0NBQUksR0FBSixVQUFtQyxLQUFlO1FBQzlDLElBQUksS0FBSyxFQUFFO1lBQ1AsSUFBSSxDQUFDLFdBQVcsR0FBRyxLQUFLLENBQUM7U0FDNUI7UUFDRCxJQUFJLENBQUMsSUFBSSxDQUFDLFdBQVcsRUFBRTtZQUNuQixPQUFPLENBQUMsSUFBSSxDQUFDLGlCQUFLLElBQUksQ0FBQyxJQUFJLENBQUMsSUFBSSwrQ0FBUyxDQUFDLENBQUE7WUFDMUMsT0FBTyxJQUFJLENBQUM7U0FDZjtRQUNELE9BQU8sSUFBSSxDQUFDLFVBQVUsRUFBSyxDQUFDO0lBQ2hDLENBQUM7SUFDRDs7T0FFRztJQUNLLHNDQUFVLEdBQWxCO1FBQ0ksSUFBSSxJQUFJLEdBQUcsSUFBSSxDQUFDLFNBQVMsRUFBRSxDQUFDO1FBQzVCLElBQUksQ0FBQyxTQUFTLENBQUMsSUFBSSxDQUFDLFdBQVcsQ0FBQyxDQUFDLENBQUMsSUFBSSxDQUFDLFdBQVcsQ0FBQyxDQUFDLENBQUMsRUFBRSxDQUFDLFFBQVEsQ0FBQyxRQUFRLEVBQUUsQ0FBQyxjQUFjLENBQUMsUUFBUSxDQUFDLENBQUMsQ0FBQztRQUN0RyxJQUFJLENBQUMsYUFBYSxHQUFHLElBQUksQ0FBQztRQUMxQixxQkFBcUIsQ0FBQyxJQUFJLENBQUMsV0FBVyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsQ0FBQyxDQUFDO1FBQ25ELE9BQU8sSUFBSSxDQUFDLE9BQU8sRUFBSyxDQUFDO0lBQzdCLENBQUM7SUFDRCxVQUFVO0lBQ0YsbUNBQU8sR0FBZjtRQUNJLElBQUksQ0FBQyxXQUFXLEdBQUcsSUFBSSxLQUFLLENBQUMsSUFBSSxDQUFDLGNBQWMsRUFBRSxJQUFJLDZDQUFxQixFQUFFLENBQU0sQ0FBQztRQUNwRixPQUFPLElBQUksQ0FBQyxXQUFnQixDQUFDO0lBQ2pDLENBQUM7SUFHUyx1Q0FBVyxHQUFyQjtRQUNJLElBQUksR0FBRyxHQUFHLEVBQUUsQ0FBQyxHQUFHLENBQUMsR0FBRyxFQUFFLENBQUM7UUFDdkIsQ0FBQyxJQUFJLENBQUMsYUFBYSxJQUFJLENBQUMsSUFBSSxDQUFDLGFBQWEsR0FBRyxHQUFHLENBQUMsQ0FBQztRQUNsRCxJQUFJLEVBQUUsR0FBRyxHQUFHLEdBQUcsSUFBSSxDQUFDLGFBQWEsQ0FBQztRQUNsQyxJQUFJLElBQUksQ0FBQyxXQUFXLEVBQUU7WUFDbEIsSUFBSSxDQUFDLFFBQVEsSUFBSSxFQUFFLENBQUM7WUFDcEIsSUFBSSxJQUFJLENBQUMsUUFBUSxJQUFJLElBQUksQ0FBQyxPQUFPLEVBQUU7Z0JBQy9CLElBQUksQ0FBQyxRQUFRLElBQUksSUFBSSxDQUFDLE9BQU8sQ0FBQztnQkFDOUIsSUFBSSxDQUFDLFVBQVUsRUFBRSxDQUFDO2FBQ3JCO1NBQ0o7UUFDRCxJQUFJLElBQUksQ0FBQyxhQUFhLEVBQUU7WUFDcEIscUJBQXFCLENBQUMsSUFBSSxDQUFDLFdBQVcsQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLENBQUMsQ0FBQztTQUN0RDtJQUNMLENBQUM7SUFFRCxZQUFZO0lBQ0wsc0NBQVUsR0FBakI7UUFDSSxJQUFJLElBQUksR0FBRyxJQUFJLENBQUMsY0FBYyxDQUFDLElBQUksQ0FBQztRQUNwQyxJQUFJLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxpQkFBaUIsRUFBRTtZQUM5QixJQUFJLENBQUMsT0FBTyxHQUFHLENBQUMsQ0FBQztZQUNqQixPQUFPO1NBQ1Y7UUFDRCxJQUFJLENBQUMsT0FBTyxHQUFHLElBQUksQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDO1FBQ2pDLElBQUksQ0FBQyxPQUFPLEdBQUcsSUFBSSxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUM7UUFDakMsSUFBSSxDQUFDLEtBQUssR0FBRyxJQUFJLENBQUMsSUFBSSxDQUFDLEtBQUssQ0FBQztRQUM3QixJQUFJLENBQUMsTUFBTSxHQUFHLElBQUksQ0FBQyxJQUFJLENBQUMsTUFBTSxDQUFDO1FBQy9CLElBQUksQ0FBQyxLQUFLLEdBQUcsSUFBSSxDQUFDLElBQUksQ0FBQyxLQUFLLENBQUM7UUFDN0IsSUFBSSxDQUFDLEtBQUssR0FBRyxJQUFJLENBQUMsSUFBSSxDQUFDLEtBQUssQ0FBQztRQUM3QixJQUFJLENBQUMsT0FBTyxHQUFHLElBQUksQ0FBQyxVQUFVLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxDQUFDO1FBRTFDLElBQUksS0FBSyxHQUFHLEVBQUUsQ0FBQyxJQUFJLEVBQUUsQ0FBQztRQUN0QixJQUFJLENBQUMsSUFBSSxDQUFDLGNBQWMsQ0FBQyxLQUFLLENBQUMsQ0FBQztRQUNoQyxJQUFJLENBQUMsSUFBSSxDQUFDLFNBQVMsSUFBSSxDQUFDLElBQUksQ0FBQyxTQUFTLENBQUMsTUFBTSxDQUFDLEtBQUssQ0FBQyxFQUFFO1lBQ2xELElBQUksV0FBVyxHQUFHLElBQUksQ0FBQyxjQUFjLENBQUMsS0FBSyxFQUFFLElBQUksQ0FBQyxDQUFDO1lBQ25ELElBQUksQ0FBQyxxQkFBcUIsQ0FBQyxXQUFXLEVBQUUsSUFBSSxFQUFFLElBQUksQ0FBQyxTQUFTLENBQUMsQ0FBQztZQUM5RCxJQUFJLENBQUMsU0FBUyxHQUFHLEtBQUssQ0FBQztZQUN2QixJQUFJLENBQUMsU0FBUyxHQUFHLFdBQVcsQ0FBQztTQUNoQztRQUNELElBQUksQ0FBQyxNQUFNLEdBQUcsSUFBSSxDQUFDLE1BQU0sQ0FBQztJQUM5QixDQUFDO0lBRU8sMENBQWMsR0FBdEIsVUFBdUIsV0FBb0IsRUFBRSxJQUFhO1FBQ3RELElBQUksVUFBVSxHQUFHLElBQUksQ0FBQztRQUN0QixJQUFJLEVBQUUsQ0FBQyxPQUFPLENBQUMsSUFBSSxDQUFDLEVBQUU7WUFDbEIsSUFBSSxFQUFFLENBQUMsT0FBTyxDQUFDLElBQUksQ0FBQyxNQUFNLENBQUMsRUFBRTtnQkFDekIsVUFBVSxHQUFHLElBQUksQ0FBQyxNQUFNLENBQUE7YUFDM0I7U0FDSjtRQUNELGFBQWE7UUFDYixJQUFJLGlCQUFpQixHQUFHLEVBQUUsQ0FBQyxJQUFJLEVBQUUsQ0FBQztRQUNsQyxVQUFVLENBQUMsY0FBYyxDQUFDLGlCQUFpQixDQUFDLENBQUM7UUFDN0MsWUFBWTtRQUNaLElBQUksbUJBQW1CLEdBQUcsaUJBQWlCLENBQUMsTUFBTSxFQUFFLENBQUM7UUFDckQsd0JBQXdCO1FBQ3hCLElBQUksV0FBVyxHQUFHLG1CQUFtQixDQUFDLFFBQVEsQ0FBQyxXQUFXLENBQUMsQ0FBQztRQUM1RCxPQUFPLFdBQVcsQ0FBQztJQUV2QixDQUFDO0lBRU8saURBQXFCLEdBQTdCLFVBQThCLE1BQWUsRUFBRSxJQUFhLEVBQUUsVUFBb0I7UUFDOUUsSUFBSSxVQUFVLElBQUksTUFBTSxDQUFDLE1BQU0sQ0FBQyxVQUFVLENBQUMsRUFBRTtZQUN6QyxPQUFPO1NBQ1Y7UUFFRCxPQUFPO1FBQ1AsSUFBSSxDQUFDLFdBQVcsQ0FBQyxNQUFNLENBQUMsQ0FBQyxDQUFDLEVBQUUsQ0FBQyxFQUFFLE1BQU0sQ0FBQyxDQUFDLENBQUMsRUFBRSxDQUFDLEVBQUUsTUFBTSxDQUFDLENBQUMsQ0FBQyxFQUFFLENBQUMsQ0FBQyxDQUFDO1FBRTNELElBQUksTUFBTSxHQUFHLElBQUksQ0FBQztRQUNsQixJQUFJLE1BQU0sR0FBRyxJQUFJLENBQUM7UUFDbEIsSUFBSSxLQUFLLEdBQUcsSUFBSSxDQUFDO1FBQ2pCLFFBQVE7UUFDUixJQUFJLENBQUMsVUFBVSxFQUFFO1lBQ2IsTUFBTSxHQUFHLElBQUksQ0FBQyxJQUFJLENBQUMsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQztTQUN6RzthQUFNLElBQUksQ0FBQyxJQUFJLENBQUMsV0FBVyxDQUFDLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEVBQUUsVUFBVSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQztlQUNuRCxDQUFDLElBQUksQ0FBQyxXQUFXLENBQUMsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsRUFBRSxVQUFVLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDO2VBQy9DLENBQUMsSUFBSSxDQUFDLFdBQVcsQ0FBQyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxFQUFFLFVBQVUsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsRUFBRTtZQUNwRCxNQUFNLEdBQUcsSUFBSSxDQUFDLElBQUksQ0FBQyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDO1NBQ3pHO1FBQ0QsUUFBUTtRQUNSLElBQUksQ0FBQyxVQUFVLEVBQUU7WUFDYixNQUFNLEdBQUcsSUFBSSxDQUFDLElBQUksQ0FBQyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDO1NBQ3pHO2FBQU0sSUFBSSxDQUFDLElBQUksQ0FBQyxXQUFXLENBQUMsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsRUFBRSxVQUFVLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDO2VBQ25ELENBQUMsSUFBSSxDQUFDLFdBQVcsQ0FBQyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxFQUFFLFVBQVUsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUM7ZUFDL0MsQ0FBQyxJQUFJLENBQUMsV0FBVyxDQUFDLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEVBQUUsVUFBVSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxFQUFFO1lBQ3BELE1BQU0sR0FBRyxJQUFJLENBQUMsSUFBSSxDQUFDLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUM7U0FDekc7UUFDRCxPQUFPO1FBQ1AsSUFBSSxNQUFNLEtBQUssSUFBSSxFQUFFO1lBQ2pCLElBQUksQ0FBQyxNQUFNLEdBQUcsTUFBTSxDQUFDO1lBQ3JCLE9BQU87WUFDUCxLQUFLLEdBQUcsSUFBSSxDQUFDLEtBQUssQ0FBQyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLE1BQU0sRUFBRSxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLE1BQU0sQ0FBQyxHQUFHLENBQUMsR0FBRyxHQUFHLElBQUksQ0FBQyxFQUFFLENBQUMsQ0FBQztTQUNwRjtRQUNELElBQUksTUFBTSxLQUFLLElBQUksRUFBRTtZQUNqQixJQUFJLENBQUMsTUFBTSxHQUFHLE1BQU0sQ0FBQztTQUN4QjtRQUNELElBQUksS0FBSyxLQUFLLElBQUksRUFBRTtZQUNoQixJQUFJLENBQUMsUUFBUSxHQUFHLEtBQUssQ0FBQztTQUN6QjtJQUNMLENBQUM7SUFFTyx1Q0FBVyxHQUFuQixVQUFvQixDQUFTLEVBQUUsQ0FBUyxFQUFFLE9BQXlCO1FBQXpCLHdCQUFBLEVBQUEsaUJBQXlCO1FBQy9ELE9BQU8sSUFBSSxDQUFDLEdBQUcsQ0FBQyxDQUFDLEdBQUcsQ0FBQyxDQUFDLEdBQUcsT0FBTyxDQUFDO0lBQ3JDLENBQUM7SUFFUyxxQ0FBUyxHQUFuQjtRQUNJLElBQUksQ0FBQyxjQUFjLENBQUMsSUFBSSxDQUFDLE9BQU8sRUFBRSxDQUFDO1FBQ25DLElBQUksQ0FBQyxjQUFjLEdBQUcsSUFBSSxDQUFDO1FBQzNCLElBQUksQ0FBQyxXQUFXLEdBQUcsSUFBSSxDQUFDO0lBQzVCLENBQUM7SUFFRDs7O09BR0c7SUFDSyxzQ0FBVSxHQUFsQixVQUFtQixJQUFhO1FBQzVCLElBQUksT0FBTyxHQUFHLENBQUMsSUFBSSxDQUFDLE9BQU8sR0FBRyxHQUFHLENBQUMsQ0FBQztRQUNuQyxJQUFJLFVBQVUsR0FBRyxJQUFJLENBQUMsTUFBTSxDQUFBO1FBQzVCLE9BQU8sVUFBVSxJQUFJLElBQUksQ0FBQyxXQUFXLENBQUMsTUFBTSxJQUFJLFVBQVUsSUFBSSxFQUFFLENBQUMsUUFBUSxDQUFDLFFBQVEsRUFBRSxFQUFFO1lBQ2xGLE9BQU8sSUFBSSxDQUFDLFVBQVUsQ0FBQyxPQUFPLEdBQUcsR0FBRyxDQUFDLENBQUM7WUFDdEMsVUFBVSxHQUFHLFVBQVUsQ0FBQyxNQUFNLENBQUM7U0FDbEM7UUFDRCxPQUFPLE9BQU8sR0FBRyxHQUFHLENBQUM7SUFDekIsQ0FBQztJQUNEOzs7T0FHRztJQUNLLHFDQUFTLEdBQWpCOztRQUNJLElBQUksSUFBSSxHQUFHLEVBQUUsQ0FBQyxXQUFXLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxDQUFDO1FBQ3JDLElBQUksQ0FBQyxpQkFBaUIsRUFBRSxDQUFDO1FBQ3pCLElBQUksQ0FBQyxjQUFjLEdBQUcsSUFBSSxDQUFDLFlBQVksQ0FBQyxFQUFFLENBQUMsZUFBZSxDQUFDLENBQUM7UUFDNUQsTUFBQSxJQUFJLENBQUMsSUFBSSxDQUFDLFlBQVksQ0FBQyxFQUFFLENBQUMsWUFBWSxDQUFDLDBDQUFFLE9BQU8sR0FBRztRQUNuRCxNQUFBLElBQUksQ0FBQyxJQUFJLENBQUMsWUFBWSxDQUFDLEVBQUUsQ0FBQyxXQUFXLENBQUMsMENBQUUsT0FBTyxHQUFHO1FBQ2xELElBQUksQ0FBQyxJQUFJLENBQUMsWUFBWSxDQUFDLEVBQUUsQ0FBQyxlQUFlLENBQUMsQ0FBQyxPQUFPLEVBQUUsQ0FBQztRQUNyRCxJQUFJLFVBQVUsR0FBRyxJQUFJLENBQUMsYUFBYSxDQUFDLEVBQUUsQ0FBQyxTQUFTLENBQUMsQ0FBQztRQUNsRCxLQUFLLElBQUksQ0FBQyxHQUFHLENBQUMsRUFBRSxHQUFHLEdBQUcsVUFBVSxDQUFDLE1BQU0sRUFBRSxDQUFDLEdBQUcsR0FBRyxFQUFFLEVBQUUsQ0FBQyxFQUFFO1lBQ25ELElBQUksSUFBSSxHQUFHLFVBQVUsQ0FBQyxDQUFDLENBQUMsQ0FBQztZQUN6QixJQUFJLENBQUMsQ0FBQyxDQUFDLElBQUksWUFBWSxFQUFFLENBQUMsZUFBZSxDQUFDLElBQUksQ0FBQyxJQUFJLFlBQVksRUFBRSxDQUFDLFlBQVksQ0FBQyxJQUFJLENBQUMsSUFBSSxZQUFZLEVBQUUsQ0FBQyxXQUFXLENBQUMsQ0FBQyxFQUFFO2dCQUNsSCxJQUFJLENBQUMsT0FBTyxFQUFFLENBQUM7YUFDbEI7U0FDSjtRQUNELE9BQU8sSUFBSSxDQUFDO0lBQ2hCLENBQUM7O0lBdE5EO1FBREMsUUFBUTsyREFDdUI7SUFLaEM7UUFIQyxRQUFRLENBQUM7WUFDTixPQUFPLEVBQUUsdUNBQXVDO1NBQ25ELENBQUM7c0RBQzRCO0lBVmIsaUJBQWlCO1FBRHJDLE9BQU87T0FDYSxpQkFBaUIsQ0E2TnJDO0lBQUQsd0JBQUM7Q0E3TkQsQUE2TkMsQ0E3TjhDLEVBQUUsQ0FBQyxTQUFTLEdBNk4xRDtrQkE3Tm9CLGlCQUFpQiIsImZpbGUiOiIiLCJzb3VyY2VSb290IjoiLyIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7IFJlbmRlclJlYWN0aXZlSGFuZGxlciB9IGZyb20gXCIuL1JlbmRlclJlYWN0aXZlSGFuZGxlclwiO1xyXG5cclxuLyoqXHJcbiAqIOebruWJjeivpea4suafk+S7o+eQhuWKn+iDveWtmOWcqOeahOmXrumimFxyXG4gKiAxLuiiq+S7o+eQhuiKgueCueeahOeItue6p+S4jeiDveWHuueOsHNjYWxlWOWSjHNjYWxlWeS4jeS4gOiHtOeahOaDheWGte+8jOiiq+S7o+eQhuiKgueCueacrOi6q+ayoeaciei/meS4qumZkOWItlxyXG4gKi9cclxuY29uc3QgeyBjY2NsYXNzLCBwcm9wZXJ0eSB9ID0gY2MuX2RlY29yYXRvcjtcclxuQGNjY2xhc3NcclxuZXhwb3J0IGRlZmF1bHQgY2xhc3MgUmVuZGVyQWx0ZXJuYXRpdmUgZXh0ZW5kcyBjYy5Db21wb25lbnQge1xyXG4gICAgLyoq5riy5p+T5bGC6IqC54K5ICovXHJcbiAgICBwdWJsaWMgcmVuZGVyTGF5ZXI6IGNjLk5vZGUgPSBudWxsO1xyXG4gICAgLyoq5riy5p+T55qEekluZGV4IOWKqOaAgeiwg+aVtHpJbmRleCznlKjkuo7mlrnkvr/kuLTov5HlkIjmibkgKi9cclxuICAgIEBwcm9wZXJ0eVxyXG4gICAgcHVibGljIHJlbmRlclpJbmRleDogbnVtYmVyID0gMDtcclxuICAgIC8qKuWQjOatpeeahOmXtOmalO+8iOW4p+S4uuWNleS9je+8iSAqL1xyXG4gICAgQHByb3BlcnR5KHtcclxuICAgICAgICB0b29sdGlwOiAn6K6+572u5ZCM5q2l55qE6Ze06ZqUKOenkuS4uuWNleS9jSnvvIww5bCx5piv5q+P5bin6YO95ZCM5q2l77yMMC4x5bCx5piv6ZqUMC4x56eS5ZCM5q2l5LiA5qyhJ1xyXG4gICAgfSlcclxuICAgIHB1YmxpYyBzeW5jSW52OiBudW1iZXIgPSAwLjAxO1xyXG4gICAgLyoq5riy5p+T55qEc0luZGV4ICovXHJcbiAgICBwdWJsaWMgc0luZGV4OiBudW1iZXIgPSAwO1xyXG4gICAgLyoq6Z2e5riy5p+T57uE5Lu2ICovXHJcbiAgICBwdWJsaWMgcHJveHlSZW5kZXI6IGNjLlJlbmRlckNvbXBvbmVudCA9IG51bGw7XHJcbiAgICAvKirmuLLmn5Pnu4Tku7YgKi9cclxuICAgIHByaXZhdGUgcmVuZGVyQ29tcG5lbnQ6IGNjLlJlbmRlckNvbXBvbmVudCA9IG51bGw7XHJcbiAgICAvKirkuIrmrKHmm7TmlrDnmoTmlbDmja4gKi9cclxuICAgIHB1YmxpYyBsYXN0V01hdDQ6IGNjLk1hdDQgPSBudWxsO1xyXG4gICAgLyoq5LiK5qyh5pu05paw55qE5pWw5o2uICovXHJcbiAgICBwdWJsaWMgbGFzdExNYXQ0OiBjYy5NYXQ0ID0gbnVsbDtcclxuICAgIC8qKuS4iuasoeabtOaWsOeahOaVsOaNriAqL1xyXG4gICAgcHVibGljIGxhc3RQb3M6IGNjLlZlYzMgPSBudWxsO1xyXG4gICAgLyoq6Led56a75LiL5qyh5Yi35paw57Sv6K6h5LqG5aSa5bCR6Ze06ZqUICovXHJcbiAgICBwdWJsaWMgYWNjdVRpbWU6IG51bWJlciA9IDA7XHJcbiAgICAvKirmnIDlkI7kuIDmrKHliLfmlrDml7bpl7QgKi9cclxuICAgIHB1YmxpYyBsYXN0RnJhbWVUaW1lOiBudW1iZXIgPSBudWxsO1xyXG4gICAgLyoq5piv5ZCm6L+b6KGM5Yi35pawICovXHJcbiAgICBwdWJsaWMgaXNBdHRhY2hGcmFtZTogYm9vbGVhbiA9IGZhbHNlO1xyXG5cclxuICAgIC8qKuiOt+WPluaAu+eahFpJbmRleCAqL1xyXG4gICAgZ2V0IHpJbmRleCgpIHtcclxuICAgICAgICBsZXQgekluZGV4ID0gdGhpcy5yZW5kZXJaSW5kZXggKyAodGhpcy5zSW5kZXggKiAwLjAxKTtcclxuICAgICAgICBsZXQgcGFyZW50Tm9kZSA9IHRoaXMubm9kZS5wYXJlbnQ7XHJcbiAgICAgICAgd2hpbGUgKHBhcmVudE5vZGUgIT0gdGhpcy5yZW5kZXJMYXllci5wYXJlbnQgJiYgcGFyZW50Tm9kZSAhPSBjYy5kaXJlY3Rvci5nZXRTY2VuZSgpKSB7XHJcbiAgICAgICAgICAgIGxldCByZW5kZXIgPSBwYXJlbnROb2RlLmdldENvbXBvbmVudChSZW5kZXJBbHRlcm5hdGl2ZSk7XHJcbiAgICAgICAgICAgIGlmIChyZW5kZXIpIHtcclxuICAgICAgICAgICAgICAgIHpJbmRleCArPSByZW5kZXIuekluZGV4ICsgMTtcclxuICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIHBhcmVudE5vZGUgPSBwYXJlbnROb2RlLnBhcmVudDtcclxuICAgICAgICB9XHJcbiAgICAgICAgcmV0dXJuIHpJbmRleDtcclxuICAgIH1cclxuXHJcbiAgICAvKipcclxuICAgICAqIOiuvue9rua4suafk+iKgueCueWxglxyXG4gICAgICogQHBhcmFtIGxheWVyIFxyXG4gICAgICovXHJcbiAgICBpbml0PFQgZXh0ZW5kcyBjYy5SZW5kZXJDb21wb25lbnQ+KGxheWVyPzogY2MuTm9kZSk6IFQge1xyXG4gICAgICAgIGlmIChsYXllcikge1xyXG4gICAgICAgICAgICB0aGlzLnJlbmRlckxheWVyID0gbGF5ZXI7XHJcbiAgICAgICAgfVxyXG4gICAgICAgIGlmICghdGhpcy5yZW5kZXJMYXllcikge1xyXG4gICAgICAgICAgICBjb25zb2xlLndhcm4oYOiKgueCuSR7dGhpcy5ub2RlLm5hbWV95rKh5pyJ6K6+572u5riy5p+T5bGCYClcclxuICAgICAgICAgICAgcmV0dXJuIG51bGw7XHJcbiAgICAgICAgfVxyXG4gICAgICAgIHJldHVybiB0aGlzLmluaXRSZW5kZXI8VD4oKTtcclxuICAgIH1cclxuICAgIC8qKlxyXG4gICAgICog5Yid5aeL5YyW5riy5p+T6IqC54K5XHJcbiAgICAgKi9cclxuICAgIHByaXZhdGUgaW5pdFJlbmRlcjxUIGV4dGVuZHMgY2MuUmVuZGVyQ29tcG9uZW50PigpOiBUIHtcclxuICAgICAgICBsZXQgbm9kZSA9IHRoaXMuZ2V0UmVuZGVyKCk7XHJcbiAgICAgICAgbm9kZS5zZXRQYXJlbnQodGhpcy5yZW5kZXJMYXllciA/IHRoaXMucmVuZGVyTGF5ZXIgOiBjYy5kaXJlY3Rvci5nZXRTY2VuZSgpLmdldENoaWxkQnlOYW1lKFwiQ2FudmFzXCIpKTtcclxuICAgICAgICB0aGlzLmlzQXR0YWNoRnJhbWUgPSB0cnVlO1xyXG4gICAgICAgIHJlcXVlc3RBbmltYXRpb25GcmFtZSh0aGlzLmZyYW1lVXBkYXRlLmJpbmQodGhpcykpO1xyXG4gICAgICAgIHJldHVybiB0aGlzLmRvUHJveHk8VD4oKTtcclxuICAgIH1cclxuICAgIC8qKueUn+aIkOS7o+eQhiAqL1xyXG4gICAgcHJpdmF0ZSBkb1Byb3h5PFQgZXh0ZW5kcyBjYy5SZW5kZXJDb21wb25lbnQ+KCk6IFQge1xyXG4gICAgICAgIHRoaXMucHJveHlSZW5kZXIgPSBuZXcgUHJveHkodGhpcy5yZW5kZXJDb21wbmVudCwgbmV3IFJlbmRlclJlYWN0aXZlSGFuZGxlcigpKSBhcyBUO1xyXG4gICAgICAgIHJldHVybiB0aGlzLnByb3h5UmVuZGVyIGFzIFQ7XHJcbiAgICB9XHJcblxyXG5cclxuICAgIHByb3RlY3RlZCBmcmFtZVVwZGF0ZSgpOiB2b2lkIHtcclxuICAgICAgICBsZXQgbm93ID0gY2Muc3lzLm5vdygpO1xyXG4gICAgICAgICF0aGlzLmxhc3RGcmFtZVRpbWUgJiYgKHRoaXMubGFzdEZyYW1lVGltZSA9IG5vdyk7XHJcbiAgICAgICAgbGV0IGR0ID0gbm93IC0gdGhpcy5sYXN0RnJhbWVUaW1lO1xyXG4gICAgICAgIGlmICh0aGlzLnByb3h5UmVuZGVyKSB7XHJcbiAgICAgICAgICAgIHRoaXMuYWNjdVRpbWUgKz0gZHQ7XHJcbiAgICAgICAgICAgIGlmICh0aGlzLmFjY3VUaW1lID49IHRoaXMuc3luY0ludikge1xyXG4gICAgICAgICAgICAgICAgdGhpcy5hY2N1VGltZSAtPSB0aGlzLnN5bmNJbnY7XHJcbiAgICAgICAgICAgICAgICB0aGlzLnVwZGF0ZVByb3AoKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH1cclxuICAgICAgICBpZiAodGhpcy5pc0F0dGFjaEZyYW1lKSB7XHJcbiAgICAgICAgICAgIHJlcXVlc3RBbmltYXRpb25GcmFtZSh0aGlzLmZyYW1lVXBkYXRlLmJpbmQodGhpcykpO1xyXG4gICAgICAgIH1cclxuICAgIH1cclxuXHJcbiAgICAvKirmm7TmlrDmnIDmlrDnirbmgIEgKi9cclxuICAgIHB1YmxpYyB1cGRhdGVQcm9wKCkge1xyXG4gICAgICAgIGxldCBub2RlID0gdGhpcy5yZW5kZXJDb21wbmVudC5ub2RlO1xyXG4gICAgICAgIGlmICghdGhpcy5ub2RlLmFjdGl2ZUluSGllcmFyY2h5KSB7XHJcbiAgICAgICAgICAgIG5vZGUub3BhY2l0eSA9IDA7XHJcbiAgICAgICAgICAgIHJldHVybjtcclxuICAgICAgICB9XHJcbiAgICAgICAgbm9kZS5hbmNob3JYID0gdGhpcy5ub2RlLmFuY2hvclg7XHJcbiAgICAgICAgbm9kZS5hbmNob3JZID0gdGhpcy5ub2RlLmFuY2hvclk7XHJcbiAgICAgICAgbm9kZS53aWR0aCA9IHRoaXMubm9kZS53aWR0aDtcclxuICAgICAgICBub2RlLmhlaWdodCA9IHRoaXMubm9kZS5oZWlnaHQ7XHJcbiAgICAgICAgbm9kZS5ncm91cCA9IHRoaXMubm9kZS5ncm91cDtcclxuICAgICAgICBub2RlLmNvbG9yID0gdGhpcy5ub2RlLmNvbG9yO1xyXG4gICAgICAgIG5vZGUub3BhY2l0eSA9IHRoaXMuZ2V0T3BhY2l0eSh0aGlzLm5vZGUpO1xyXG5cclxuICAgICAgICBsZXQgd01hdDQgPSBjYy5tYXQ0KCk7XHJcbiAgICAgICAgdGhpcy5ub2RlLmdldFdvcmxkTWF0cml4KHdNYXQ0KTtcclxuICAgICAgICBpZiAoIXRoaXMubGFzdFdNYXQ0IHx8ICF0aGlzLmxhc3RXTWF0NC5lcXVhbHMod01hdDQpKSB7XHJcbiAgICAgICAgICAgIGxldCBsb2NhbE1hdHJpeCA9IHRoaXMuZ2V0TG9jYWxNYXRyaXgod01hdDQsIG5vZGUpO1xyXG4gICAgICAgICAgICB0aGlzLnNldExvY2FsWFlaU2NhbGVBbmdsZShsb2NhbE1hdHJpeCwgbm9kZSwgdGhpcy5sYXN0TE1hdDQpO1xyXG4gICAgICAgICAgICB0aGlzLmxhc3RXTWF0NCA9IHdNYXQ0O1xyXG4gICAgICAgICAgICB0aGlzLmxhc3RMTWF0NCA9IGxvY2FsTWF0cml4O1xyXG4gICAgICAgIH1cclxuICAgICAgICBub2RlLnpJbmRleCA9IHRoaXMuekluZGV4O1xyXG4gICAgfVxyXG5cclxuICAgIHByaXZhdGUgZ2V0TG9jYWxNYXRyaXgod29ybGRNYXRyaXg6IGNjLk1hdDQsIG5vZGU6IGNjLk5vZGUpIHtcclxuICAgICAgICBsZXQgcGFyZW50Tm9kZSA9IG51bGw7XHJcbiAgICAgICAgaWYgKGNjLmlzVmFsaWQobm9kZSkpIHtcclxuICAgICAgICAgICAgaWYgKGNjLmlzVmFsaWQobm9kZS5wYXJlbnQpKSB7XHJcbiAgICAgICAgICAgICAgICBwYXJlbnROb2RlID0gbm9kZS5wYXJlbnRcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH1cclxuICAgICAgICAvLyDojrflj5bniLboioLngrnnmoTkuJbnlYznn6npmLVcclxuICAgICAgICBsZXQgcGFyZW50V29ybGRNYXRyaXggPSBjYy5tYXQ0KCk7XHJcbiAgICAgICAgcGFyZW50Tm9kZS5nZXRXb3JsZE1hdHJpeChwYXJlbnRXb3JsZE1hdHJpeCk7XHJcbiAgICAgICAgLy8g6I635Y+W54i26IqC54K555qE6YCG55+p6Zi1XHJcbiAgICAgICAgbGV0IHBhcmVudEludmVyc2VNYXRyaXggPSBwYXJlbnRXb3JsZE1hdHJpeC5pbnZlcnQoKTtcclxuICAgICAgICAvLyDlsIbnm67moIfoioLngrnnmoTkuJbnlYznn6npmLXovazmjaLkuLrniLboioLngrnnmoTmnKzlnLDnn6npmLVcclxuICAgICAgICBsZXQgbG9jYWxNYXRyaXggPSBwYXJlbnRJbnZlcnNlTWF0cml4Lm11bHRpcGx5KHdvcmxkTWF0cml4KTtcclxuICAgICAgICByZXR1cm4gbG9jYWxNYXRyaXg7XHJcblxyXG4gICAgfVxyXG5cclxuICAgIHByaXZhdGUgc2V0TG9jYWxYWVpTY2FsZUFuZ2xlKG1hdHJpeDogY2MuTWF0NCwgbm9kZTogY2MuTm9kZSwgbGFzdE1hdHJpeD86IGNjLk1hdDQpIHtcclxuICAgICAgICBpZiAobGFzdE1hdHJpeCAmJiBtYXRyaXguZXF1YWxzKGxhc3RNYXRyaXgpKSB7XHJcbiAgICAgICAgICAgIHJldHVybjtcclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIC8vIOaPkOWPluS9jee9rlxyXG4gICAgICAgIG5vZGUuc2V0UG9zaXRpb24obWF0cml4Lm1bMTJdLCBtYXRyaXgubVsxM10sIG1hdHJpeC5tWzE0XSk7XHJcblxyXG4gICAgICAgIGxldCBzY2FsZVggPSBudWxsO1xyXG4gICAgICAgIGxldCBzY2FsZVkgPSBudWxsO1xyXG4gICAgICAgIGxldCBhbmdsZSA9IG51bGw7XHJcbiAgICAgICAgLy8g5o+Q5Y+W57yp5pS+WFxyXG4gICAgICAgIGlmICghbGFzdE1hdHJpeCkge1xyXG4gICAgICAgICAgICBzY2FsZVggPSBNYXRoLnNxcnQobWF0cml4Lm1bMF0gKiBtYXRyaXgubVswXSArIG1hdHJpeC5tWzFdICogbWF0cml4Lm1bMV0gKyBtYXRyaXgubVsyXSAqIG1hdHJpeC5tWzJdKTtcclxuICAgICAgICB9IGVsc2UgaWYgKCF0aGlzLmVxdWFsc1ZhbHVlKG1hdHJpeC5tWzBdLCBsYXN0TWF0cml4Lm1bMF0pXHJcbiAgICAgICAgICAgIHx8ICF0aGlzLmVxdWFsc1ZhbHVlKG1hdHJpeC5tWzFdLCBsYXN0TWF0cml4Lm1bMV0pXHJcbiAgICAgICAgICAgIHx8ICF0aGlzLmVxdWFsc1ZhbHVlKG1hdHJpeC5tWzJdLCBsYXN0TWF0cml4Lm1bMl0pKSB7XHJcbiAgICAgICAgICAgIHNjYWxlWCA9IE1hdGguc3FydChtYXRyaXgubVswXSAqIG1hdHJpeC5tWzBdICsgbWF0cml4Lm1bMV0gKiBtYXRyaXgubVsxXSArIG1hdHJpeC5tWzJdICogbWF0cml4Lm1bMl0pO1xyXG4gICAgICAgIH1cclxuICAgICAgICAvLyDmj5Dlj5bnvKnmlL5ZXHJcbiAgICAgICAgaWYgKCFsYXN0TWF0cml4KSB7XHJcbiAgICAgICAgICAgIHNjYWxlWSA9IE1hdGguc3FydChtYXRyaXgubVs0XSAqIG1hdHJpeC5tWzRdICsgbWF0cml4Lm1bNV0gKiBtYXRyaXgubVs1XSArIG1hdHJpeC5tWzZdICogbWF0cml4Lm1bNl0pO1xyXG4gICAgICAgIH0gZWxzZSBpZiAoIXRoaXMuZXF1YWxzVmFsdWUobWF0cml4Lm1bNF0sIGxhc3RNYXRyaXgubVs0XSlcclxuICAgICAgICAgICAgfHwgIXRoaXMuZXF1YWxzVmFsdWUobWF0cml4Lm1bNV0sIGxhc3RNYXRyaXgubVs1XSlcclxuICAgICAgICAgICAgfHwgIXRoaXMuZXF1YWxzVmFsdWUobWF0cml4Lm1bNl0sIGxhc3RNYXRyaXgubVs2XSkpIHtcclxuICAgICAgICAgICAgc2NhbGVZID0gTWF0aC5zcXJ0KG1hdHJpeC5tWzRdICogbWF0cml4Lm1bNF0gKyBtYXRyaXgubVs1XSAqIG1hdHJpeC5tWzVdICsgbWF0cml4Lm1bNl0gKiBtYXRyaXgubVs2XSk7XHJcbiAgICAgICAgfVxyXG4gICAgICAgIC8v6K6+572u57yp5pS+WFxyXG4gICAgICAgIGlmIChzY2FsZVggIT09IG51bGwpIHtcclxuICAgICAgICAgICAgbm9kZS5zY2FsZVggPSBzY2FsZVg7XHJcbiAgICAgICAgICAgIC8vIOaPkOWPluaXi+i9rFxyXG4gICAgICAgICAgICBhbmdsZSA9IE1hdGguYXRhbjIobWF0cml4Lm1bMV0gLyBzY2FsZVgsIG1hdHJpeC5tWzBdIC8gc2NhbGVYKSAqICgxODAgLyBNYXRoLlBJKTtcclxuICAgICAgICB9XHJcbiAgICAgICAgaWYgKHNjYWxlWSAhPT0gbnVsbCkge1xyXG4gICAgICAgICAgICBub2RlLnNjYWxlWSA9IHNjYWxlWTtcclxuICAgICAgICB9XHJcbiAgICAgICAgaWYgKGFuZ2xlICE9PSBudWxsKSB7XHJcbiAgICAgICAgICAgIG5vZGUucm90YXRpb24gPSBhbmdsZTtcclxuICAgICAgICB9XHJcbiAgICB9XHJcblxyXG4gICAgcHJpdmF0ZSBlcXVhbHNWYWx1ZShhOiBudW1iZXIsIGI6IG51bWJlciwgZXBzaWxvbjogbnVtYmVyID0gMC4wMDAwMSkge1xyXG4gICAgICAgIHJldHVybiBNYXRoLmFicyhhIC0gYikgPCBlcHNpbG9uO1xyXG4gICAgfVxyXG5cclxuICAgIHByb3RlY3RlZCBvbkRlc3Ryb3koKTogdm9pZCB7XHJcbiAgICAgICAgdGhpcy5yZW5kZXJDb21wbmVudC5ub2RlLmRlc3Ryb3koKTtcclxuICAgICAgICB0aGlzLnJlbmRlckNvbXBuZW50ID0gbnVsbDtcclxuICAgICAgICB0aGlzLnByb3h5UmVuZGVyID0gbnVsbDtcclxuICAgIH1cclxuXHJcbiAgICAvKipcclxuICAgICAqIOiOt+WPluiKgueCuemAj+aYjuW6plxyXG4gICAgICogQHBhcmFtIG5vZGUgXHJcbiAgICAgKi9cclxuICAgIHByaXZhdGUgZ2V0T3BhY2l0eShub2RlOiBjYy5Ob2RlKSB7XHJcbiAgICAgICAgbGV0IG9wYWNpdHkgPSAobm9kZS5vcGFjaXR5IC8gMjU1KTtcclxuICAgICAgICBsZXQgcGFyZW50Tm9kZSA9IG5vZGUucGFyZW50XHJcbiAgICAgICAgd2hpbGUgKHBhcmVudE5vZGUgIT0gdGhpcy5yZW5kZXJMYXllci5wYXJlbnQgJiYgcGFyZW50Tm9kZSAhPSBjYy5kaXJlY3Rvci5nZXRTY2VuZSgpKSB7XHJcbiAgICAgICAgICAgIG9wYWNpdHkgKj0gKHBhcmVudE5vZGUub3BhY2l0eSAvIDI1NSk7XHJcbiAgICAgICAgICAgIHBhcmVudE5vZGUgPSBwYXJlbnROb2RlLnBhcmVudDtcclxuICAgICAgICB9XHJcbiAgICAgICAgcmV0dXJuIG9wYWNpdHkgKiAyNTU7XHJcbiAgICB9XHJcbiAgICAvKipcclxuICAgICAqIOiOt+WPlua4suafk+e7hOS7tlxyXG4gICAgICogQHBhcmFtIG5vZGUgXHJcbiAgICAgKi9cclxuICAgIHByaXZhdGUgZ2V0UmVuZGVyKCkge1xyXG4gICAgICAgIGxldCBub2RlID0gY2MuaW5zdGFudGlhdGUodGhpcy5ub2RlKTtcclxuICAgICAgICBub2RlLnJlbW92ZUFsbENoaWxkcmVuKCk7XHJcbiAgICAgICAgdGhpcy5yZW5kZXJDb21wbmVudCA9IG5vZGUuZ2V0Q29tcG9uZW50KGNjLlJlbmRlckNvbXBvbmVudCk7XHJcbiAgICAgICAgdGhpcy5ub2RlLmdldENvbXBvbmVudChjYy5MYWJlbE91dGxpbmUpPy5kZXN0cm95KCk7XHJcbiAgICAgICAgdGhpcy5ub2RlLmdldENvbXBvbmVudChjYy5MYWJlbFNoYWRvdyk/LmRlc3Ryb3koKTtcclxuICAgICAgICB0aGlzLm5vZGUuZ2V0Q29tcG9uZW50KGNjLlJlbmRlckNvbXBvbmVudCkuZGVzdHJveSgpO1xyXG4gICAgICAgIGxldCBjb21wb25lbnRzID0gbm9kZS5nZXRDb21wb25lbnRzKGNjLkNvbXBvbmVudCk7XHJcbiAgICAgICAgZm9yIChsZXQgaSA9IDAsIGxlbiA9IGNvbXBvbmVudHMubGVuZ3RoOyBpIDwgbGVuOyArK2kpIHtcclxuICAgICAgICAgICAgbGV0IGNvbXAgPSBjb21wb25lbnRzW2ldO1xyXG4gICAgICAgICAgICBpZiAoISgoY29tcCBpbnN0YW5jZW9mIGNjLlJlbmRlckNvbXBvbmVudCkgfHwgKGNvbXAgaW5zdGFuY2VvZiBjYy5MYWJlbE91dGxpbmUpIHx8IChjb21wIGluc3RhbmNlb2YgY2MuTGFiZWxTaGFkb3cpKSkge1xyXG4gICAgICAgICAgICAgICAgY29tcC5kZXN0cm95KCk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9XHJcbiAgICAgICAgcmV0dXJuIG5vZGU7XHJcbiAgICB9XHJcblxyXG59XHJcbiJdfQ== +//------QC-SOURCE-SPLIT------ + + (function() { + var nodeEnv = typeof require !== 'undefined' && typeof process !== 'undefined'; + var __module = nodeEnv ? module : {exports:{}}; + var __filename = 'preview-scripts/assets/Scene/TestShowNode.js'; + var __require = nodeEnv ? function (request) { + return cc.require(request); + } : function (request) { + return __quick_compile_project__.require(request, __filename); + }; + function __define (exports, require, module) { + if (!nodeEnv) {__quick_compile_project__.registerModule(__filename, module);}"use strict"; +cc._RF.push(module, '9e178M6rUlI5qgi1+HcLO30', 'TestShowNode'); +// Scene/TestShowNode.ts + +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.TestShowNode = void 0; +var LoopList_1 = require("../Script/LoopList"); +var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property; +var TestShowNode = /** @class */ (function (_super) { + __extends(TestShowNode, _super); + function TestShowNode() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /** */ + _this.nameLb = null; + /** */ + _this.contentLb = null; + /** */ + _this.Button = null; + /** */ + _this.ButtonLb = null; + return _this; + } + /** + * 初始化显示 + * @param data + */ + TestShowNode.prototype.initShow = function () { + this.node.width = this.data.size.width; + this.node.height = this.data.size.height; + this.nameLb.string = "我是第" + this.data.index + "个"; + this.contentLb.string = "我是内容" + this.data.text; + //这个是改变控件大小的事例 + if (this.data.index == 5 || this.data.index == 11) { + //this.changeSize(cell); + } + }; + /** + * 改变大小 + * @param cell + */ + TestShowNode.prototype.changeSize = function (cell) { + var _this = this; + this.resize(cc.size(cell.size.width, 100 + (Math.random() * 400))); + this.scheduleOnce(function () { + _this.changeSize(cell); + }, 3 + Math.random() * 3); + }; + TestShowNode.prototype.onRecircle = function () { + //做释放操作 + }; + __decorate([ + property(cc.Label) + ], TestShowNode.prototype, "nameLb", void 0); + __decorate([ + property(cc.Label) + ], TestShowNode.prototype, "contentLb", void 0); + __decorate([ + property(cc.Node) + ], TestShowNode.prototype, "Button", void 0); + __decorate([ + property(cc.Label) + ], TestShowNode.prototype, "ButtonLb", void 0); + TestShowNode = __decorate([ + ccclass + ], TestShowNode); + return TestShowNode; +}(LoopList_1.ShowNode)); +exports.TestShowNode = TestShowNode; + +cc._RF.pop(); + } + if (nodeEnv) { + __define(__module.exports, __require, __module); + } + else { + __quick_compile_project__.registerModuleFunc(__filename, function () { + __define(__module.exports, __require, __module); + }); + } + })(); +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImFzc2V0c1xcU2NlbmVcXFRlc3RTaG93Tm9kZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0FBQUEsK0NBQXdEO0FBRWxELElBQUEsS0FBd0IsRUFBRSxDQUFDLFVBQVUsRUFBbkMsT0FBTyxhQUFBLEVBQUUsUUFBUSxjQUFrQixDQUFDO0FBUTVDO0lBQWtDLGdDQUFlO0lBQWpEO1FBQUEscUVBMkNDO1FBMUNHLE1BQU07UUFFQyxZQUFNLEdBQWEsSUFBSSxDQUFDO1FBQy9CLE1BQU07UUFFQyxlQUFTLEdBQWEsSUFBSSxDQUFDO1FBQ2xDLE1BQU07UUFFQyxZQUFNLEdBQVksSUFBSSxDQUFDO1FBQzlCLE1BQU07UUFFQyxjQUFRLEdBQWEsSUFBSSxDQUFDOztJQStCckMsQ0FBQztJQTdCRzs7O09BR0c7SUFDSCwrQkFBUSxHQUFSO1FBQ0ksSUFBSSxDQUFDLElBQUksQ0FBQyxLQUFLLEdBQUcsSUFBSSxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsS0FBSyxDQUFDO1FBQ3ZDLElBQUksQ0FBQyxJQUFJLENBQUMsTUFBTSxHQUFHLElBQUksQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLE1BQU0sQ0FBQztRQUN6QyxJQUFJLENBQUMsTUFBTSxDQUFDLE1BQU0sR0FBRyxLQUFLLEdBQUcsSUFBSSxDQUFDLElBQUksQ0FBQyxLQUFLLEdBQUcsR0FBRyxDQUFDO1FBQ25ELElBQUksQ0FBQyxTQUFTLENBQUMsTUFBTSxHQUFHLE1BQU0sR0FBRyxJQUFJLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQztRQUNoRCxjQUFjO1FBQ2QsSUFBSSxJQUFJLENBQUMsSUFBSSxDQUFDLEtBQUssSUFBSSxDQUFDLElBQUksSUFBSSxDQUFDLElBQUksQ0FBQyxLQUFLLElBQUksRUFBRSxFQUFFO1lBQy9DLHdCQUF3QjtTQUMzQjtJQUNMLENBQUM7SUFFRDs7O09BR0c7SUFDSCxpQ0FBVSxHQUFWLFVBQVcsSUFBcUI7UUFBaEMsaUJBS0M7UUFKRyxJQUFJLENBQUMsTUFBTSxDQUFDLEVBQUUsQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxLQUFLLEVBQUUsR0FBRyxHQUFHLENBQUMsSUFBSSxDQUFDLE1BQU0sRUFBRSxHQUFHLEdBQUcsQ0FBQyxDQUFDLENBQUMsQ0FBQztRQUNuRSxJQUFJLENBQUMsWUFBWSxDQUFDO1lBQ2QsS0FBSSxDQUFDLFVBQVUsQ0FBQyxJQUFJLENBQUMsQ0FBQTtRQUN6QixDQUFDLEVBQUUsQ0FBQyxHQUFHLElBQUksQ0FBQyxNQUFNLEVBQUUsR0FBRyxDQUFDLENBQUMsQ0FBQTtJQUM3QixDQUFDO0lBRUQsaUNBQVUsR0FBVjtRQUNJLE9BQU87SUFDWCxDQUFDO0lBdkNEO1FBREMsUUFBUSxDQUFDLEVBQUUsQ0FBQyxLQUFLLENBQUM7Z0RBQ1k7SUFHL0I7UUFEQyxRQUFRLENBQUMsRUFBRSxDQUFDLEtBQUssQ0FBQzttREFDZTtJQUdsQztRQURDLFFBQVEsQ0FBQyxFQUFFLENBQUMsSUFBSSxDQUFDO2dEQUNZO0lBRzlCO1FBREMsUUFBUSxDQUFDLEVBQUUsQ0FBQyxLQUFLLENBQUM7a0RBQ2M7SUFaeEIsWUFBWTtRQUR4QixPQUFPO09BQ0ssWUFBWSxDQTJDeEI7SUFBRCxtQkFBQztDQTNDRCxBQTJDQyxDQTNDaUMsbUJBQVEsR0EyQ3pDO0FBM0NZLG9DQUFZIiwiZmlsZSI6IiIsInNvdXJjZVJvb3QiOiIvIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IEl0ZW1DZWxsLCB7IFNob3dOb2RlIH0gZnJvbSBcIi4uL1NjcmlwdC9Mb29wTGlzdFwiO1xyXG5pbXBvcnQgUmVuZGVyQWx0ZXJuYXRpdmUgZnJvbSBcIi4uL1NjcmlwdC9SZW5kZXJBbHRlcm5hdGl2ZVwiO1xyXG5jb25zdCB7IGNjY2xhc3MsIHByb3BlcnR5IH0gPSBjYy5fZGVjb3JhdG9yO1xyXG5leHBvcnQgaW50ZXJmYWNlIElEYXRhIHtcclxuICAgIHNpemU/OiBjYy5TaXplLFxyXG4gICAgaW5kZXg6IG51bWJlcixcclxuICAgIHRleHQ6IHN0cmluZ1xyXG59XHJcblxyXG5AY2NjbGFzc1xyXG5leHBvcnQgY2xhc3MgVGVzdFNob3dOb2RlIGV4dGVuZHMgU2hvd05vZGU8SURhdGE+IHtcclxuICAgIC8qKiAqL1xyXG4gICAgQHByb3BlcnR5KGNjLkxhYmVsKVxyXG4gICAgcHVibGljIG5hbWVMYjogY2MuTGFiZWwgPSBudWxsO1xyXG4gICAgLyoqICovXHJcbiAgICBAcHJvcGVydHkoY2MuTGFiZWwpXHJcbiAgICBwdWJsaWMgY29udGVudExiOiBjYy5MYWJlbCA9IG51bGw7XHJcbiAgICAvKiogKi9cclxuICAgIEBwcm9wZXJ0eShjYy5Ob2RlKVxyXG4gICAgcHVibGljIEJ1dHRvbjogY2MuTm9kZSA9IG51bGw7XHJcbiAgICAvKiogKi9cclxuICAgIEBwcm9wZXJ0eShjYy5MYWJlbClcclxuICAgIHB1YmxpYyBCdXR0b25MYjogY2MuTGFiZWwgPSBudWxsO1xyXG5cclxuICAgIC8qKlxyXG4gICAgICog5Yid5aeL5YyW5pi+56S6XHJcbiAgICAgKiBAcGFyYW0gZGF0YSBcclxuICAgICAqL1xyXG4gICAgaW5pdFNob3coKSB7XHJcbiAgICAgICAgdGhpcy5ub2RlLndpZHRoID0gdGhpcy5kYXRhLnNpemUud2lkdGg7XHJcbiAgICAgICAgdGhpcy5ub2RlLmhlaWdodCA9IHRoaXMuZGF0YS5zaXplLmhlaWdodDtcclxuICAgICAgICB0aGlzLm5hbWVMYi5zdHJpbmcgPSBcIuaIkeaYr+esrFwiICsgdGhpcy5kYXRhLmluZGV4ICsgXCLkuKpcIjtcclxuICAgICAgICB0aGlzLmNvbnRlbnRMYi5zdHJpbmcgPSBcIuaIkeaYr+WGheWuuVwiICsgdGhpcy5kYXRhLnRleHQ7XHJcbiAgICAgICAgLy/ov5nkuKrmmK/mlLnlj5jmjqfku7blpKflsI/nmoTkuovkvotcclxuICAgICAgICBpZiAodGhpcy5kYXRhLmluZGV4ID09IDUgfHwgdGhpcy5kYXRhLmluZGV4ID09IDExKSB7XHJcbiAgICAgICAgICAgIC8vdGhpcy5jaGFuZ2VTaXplKGNlbGwpO1xyXG4gICAgICAgIH1cclxuICAgIH1cclxuXHJcbiAgICAvKipcclxuICAgICAqIOaUueWPmOWkp+Wwj1xyXG4gICAgICogQHBhcmFtIGNlbGwgXHJcbiAgICAgKi9cclxuICAgIGNoYW5nZVNpemUoY2VsbDogSXRlbUNlbGw8SURhdGE+KSB7XHJcbiAgICAgICAgdGhpcy5yZXNpemUoY2Muc2l6ZShjZWxsLnNpemUud2lkdGgsIDEwMCArIChNYXRoLnJhbmRvbSgpICogNDAwKSkpO1xyXG4gICAgICAgIHRoaXMuc2NoZWR1bGVPbmNlKCgpID0+IHtcclxuICAgICAgICAgICAgdGhpcy5jaGFuZ2VTaXplKGNlbGwpXHJcbiAgICAgICAgfSwgMyArIE1hdGgucmFuZG9tKCkgKiAzKVxyXG4gICAgfVxyXG5cclxuICAgIG9uUmVjaXJjbGUoKSB7XHJcbiAgICAgICAgLy/lgZrph4rmlL7mk43kvZxcclxuICAgIH1cclxufVxyXG5cclxuXHJcbiJdfQ== +//------QC-SOURCE-SPLIT------ + + (function() { + var nodeEnv = typeof require !== 'undefined' && typeof process !== 'undefined'; + var __module = nodeEnv ? module : {exports:{}}; + var __filename = 'preview-scripts/assets/Scene/TestMatrix.js'; + var __require = nodeEnv ? function (request) { + return cc.require(request); + } : function (request) { + return __quick_compile_project__.require(request, __filename); + }; + function __define (exports, require, module) { + if (!nodeEnv) {__quick_compile_project__.registerModule(__filename, module);}"use strict"; +cc._RF.push(module, '41fb7HlhIJNzZMkSaq31ryP', 'TestMatrix'); +// Scene/TestMatrix.ts + +"use strict"; +// Learn TypeScript: +// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html +// Learn Attribute: +// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html +// Learn life-cycle callbacks: +// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property; +var NewClass = /** @class */ (function (_super) { + __extends(NewClass, _super); + function NewClass() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.target = null; + _this.targetParent = null; + _this.srcTarget = null; + _this.srcTargetParent = null; + return _this; + // update (dt) {} + } + // LIFE-CYCLE CALLBACKS: + NewClass.prototype.onLoad = function () { + // cc.director.on(cc.Director.EVENT_BEFORE_DRAW, this.onBeforeDraw, this); + }; + NewClass.prototype.start = function () { + // this.scheduleOnce(() => { + // this.target.x = 100; + // this.target.scaleX = 2; + // }, 3); + // this.scheduleOnce(() => { + // this.targetParent.x = 10; + // this.target.scaleX = 1.1; + // }, 1); + var targetNode = this.target; // 需要获取世界矩阵的节点 + var parentNode = this.targetParent; // 要转换到的节点 + var localMatrix = cc.mat4(); + targetNode.getLocalMatrix(localMatrix); + this.getMatrixInfo(localMatrix); + // 获取目标节点的世界矩阵 + var worldMatrix = cc.mat4(); + targetNode.getWorldMatrix(worldMatrix); + // 获取父节点的世界矩阵 + var parentWorldMatrix = cc.mat4(); + parentNode.getWorldMatrix(parentWorldMatrix); + // 获取父节点的逆矩阵 + var parentInverseMatrix = parentWorldMatrix.invert(); + // 将目标节点的世界矩阵转换为父节点的本地矩阵 + var localMatrix2 = parentInverseMatrix.multiply(worldMatrix); + this.getMatrixInfo(localMatrix2); + }; + NewClass.prototype.matrixTransform = function () { + // 假设我们有一个目标节点和一个父节点 + var targetNode = this.target; // 需要获取世界矩阵的节点 + var parentNode = this.srcTargetParent; // 要转换到的节点 + // 获取目标节点的世界矩阵 + var worldMatrix = cc.mat4(); + targetNode.getWorldMatrix(worldMatrix); + // 获取父节点的世界矩阵 + var parentWorldMatrix = cc.mat4(); + parentNode.getWorldMatrix(parentWorldMatrix); + // 获取父节点的逆矩阵 + var parentInverseMatrix = parentWorldMatrix.invert(); + // 将目标节点的世界矩阵转换为父节点的本地矩阵 + var localMatrix = parentInverseMatrix.multiply(worldMatrix); + // 提取位置 + var position = cc.v3(worldMatrix.m[12], worldMatrix.m[13], worldMatrix.m[14]); + // 提取缩放 + var scaleX = Math.sqrt(worldMatrix.m[0] * worldMatrix.m[0] + worldMatrix.m[1] * worldMatrix.m[1] + worldMatrix.m[2] * worldMatrix.m[2]); + var scaleY = Math.sqrt(worldMatrix.m[4] * worldMatrix.m[4] + worldMatrix.m[5] * worldMatrix.m[5] + worldMatrix.m[6] * worldMatrix.m[6]); + var scaleZ = Math.sqrt(worldMatrix.m[8] * worldMatrix.m[8] + worldMatrix.m[9] * worldMatrix.m[9] + worldMatrix.m[10] * worldMatrix.m[10]); + // 提取旋转(假设是二维旋转) + var angle = Math.atan2(worldMatrix.m[1] / scaleX, worldMatrix.m[0] / scaleX) * (180 / Math.PI); + // 输出结果 + console.log("Position:", position); + console.log("Scale:", cc.v3(scaleX, scaleY, scaleZ)); + console.log("Angle:", angle); + }; + NewClass.prototype.getMatrixInfo = function (matrix) { + // 提取位置 + var position = cc.v3(matrix.m[12], matrix.m[13], matrix.m[14]); + // 提取缩放 + var scaleX = Math.sqrt(matrix.m[0] * matrix.m[0] + matrix.m[1] * matrix.m[1] + matrix.m[2] * matrix.m[2]); + var scaleY = Math.sqrt(matrix.m[4] * matrix.m[4] + matrix.m[5] * matrix.m[5] + matrix.m[6] * matrix.m[6]); + var scaleZ = Math.sqrt(matrix.m[8] * matrix.m[8] + matrix.m[9] * matrix.m[9] + matrix.m[10] * matrix.m[10]); + // 提取旋转(假设是二维旋转) + var angle = Math.atan2(matrix.m[1] / scaleX, matrix.m[0] / scaleX) * (180 / Math.PI); + // 输出结果 + console.log("Position:", position); + console.log("Scale:", cc.v3(scaleX, scaleY, scaleZ)); + console.log("Angle:", angle); + }; + NewClass.prototype.onDestroy = function () { + cc.director.off(cc.Director.EVENT_BEFORE_DRAW, this.onBeforeDraw, this); + }; + NewClass.prototype.onBeforeDraw = function () { + this.checkDirty(this.target); + this.checkDirty(this.targetParent); + }; + NewClass.prototype.checkDirty = function (node) { + //@ts-ignore + var _localMatDirty = node._localMatDirty; + if (_localMatDirty) { + console.log(node.name, _localMatDirty); + } + //@ts-ignore + var _worldMatDirty = node._worldMatDirty; + if (_worldMatDirty) { + console.log(node.name, _worldMatDirty); + } + //@ts-ignore + var _renderFlag = node._renderFlag; + if (_renderFlag) { + console.log(node.name, _renderFlag); + } + }; + __decorate([ + property(cc.Node) + ], NewClass.prototype, "target", void 0); + __decorate([ + property(cc.Node) + ], NewClass.prototype, "targetParent", void 0); + __decorate([ + property(cc.Node) + ], NewClass.prototype, "srcTarget", void 0); + __decorate([ + property(cc.Node) + ], NewClass.prototype, "srcTargetParent", void 0); + NewClass = __decorate([ + ccclass + ], NewClass); + return NewClass; +}(cc.Component)); +exports.default = NewClass; + +cc._RF.pop(); + } + if (nodeEnv) { + __define(__module.exports, __require, __module); + } + else { + __quick_compile_project__.registerModuleFunc(__filename, function () { + __define(__module.exports, __require, __module); + }); + } + })(); +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImFzc2V0c1xcU2NlbmVcXFRlc3RNYXRyaXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7OztBQUFBLG9CQUFvQjtBQUNwQix3RUFBd0U7QUFDeEUsbUJBQW1CO0FBQ25CLGtGQUFrRjtBQUNsRiw4QkFBOEI7QUFDOUIsa0ZBQWtGOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7QUFFNUUsSUFBQSxLQUF3QixFQUFFLENBQUMsVUFBVSxFQUFuQyxPQUFPLGFBQUEsRUFBRSxRQUFRLGNBQWtCLENBQUM7QUFHNUM7SUFBc0MsNEJBQVk7SUFBbEQ7UUFBQSxxRUF5SUM7UUF0SUcsWUFBTSxHQUFZLElBQUksQ0FBQztRQUd2QixrQkFBWSxHQUFZLElBQUksQ0FBQztRQUc3QixlQUFTLEdBQVksSUFBSSxDQUFDO1FBRzFCLHFCQUFlLEdBQVksSUFBSSxDQUFDOztRQTRIaEMsaUJBQWlCO0lBQ3JCLENBQUM7SUE1SEcsd0JBQXdCO0lBRXhCLHlCQUFNLEdBQU47UUFDSSwwRUFBMEU7SUFDOUUsQ0FBQztJQUVELHdCQUFLLEdBQUw7UUFDSSw0QkFBNEI7UUFDNUIsMkJBQTJCO1FBQzNCLDhCQUE4QjtRQUM5QixTQUFTO1FBRVQsNEJBQTRCO1FBQzVCLGdDQUFnQztRQUNoQyxnQ0FBZ0M7UUFDaEMsU0FBUztRQUNULElBQUksVUFBVSxHQUFHLElBQUksQ0FBQyxNQUFNLENBQUMsQ0FBQyxjQUFjO1FBQzVDLElBQUksVUFBVSxHQUFHLElBQUksQ0FBQyxZQUFZLENBQUMsQ0FBQyxVQUFVO1FBRTlDLElBQUksV0FBVyxHQUFHLEVBQUUsQ0FBQyxJQUFJLEVBQUUsQ0FBQztRQUM1QixVQUFVLENBQUMsY0FBYyxDQUFDLFdBQVcsQ0FBQyxDQUFDO1FBQ3ZDLElBQUksQ0FBQyxhQUFhLENBQUMsV0FBVyxDQUFDLENBQUM7UUFFaEMsY0FBYztRQUNkLElBQUksV0FBVyxHQUFHLEVBQUUsQ0FBQyxJQUFJLEVBQUUsQ0FBQztRQUM1QixVQUFVLENBQUMsY0FBYyxDQUFDLFdBQVcsQ0FBQyxDQUFBO1FBQ3RDLGFBQWE7UUFDYixJQUFJLGlCQUFpQixHQUFHLEVBQUUsQ0FBQyxJQUFJLEVBQUUsQ0FBQztRQUNsQyxVQUFVLENBQUMsY0FBYyxDQUFDLGlCQUFpQixDQUFDLENBQUM7UUFFN0MsWUFBWTtRQUNaLElBQUksbUJBQW1CLEdBQUcsaUJBQWlCLENBQUMsTUFBTSxFQUFFLENBQUM7UUFFckQsd0JBQXdCO1FBQ3hCLElBQUksWUFBWSxHQUFHLG1CQUFtQixDQUFDLFFBQVEsQ0FBQyxXQUFXLENBQUMsQ0FBQztRQUU3RCxJQUFJLENBQUMsYUFBYSxDQUFDLFlBQVksQ0FBQyxDQUFDO0lBRXJDLENBQUM7SUFFRCxrQ0FBZSxHQUFmO1FBQ0ksb0JBQW9CO1FBQ3BCLElBQUksVUFBVSxHQUFHLElBQUksQ0FBQyxNQUFNLENBQUMsQ0FBQyxjQUFjO1FBQzVDLElBQUksVUFBVSxHQUFHLElBQUksQ0FBQyxlQUFlLENBQUMsQ0FBQyxVQUFVO1FBRWpELGNBQWM7UUFDZCxJQUFJLFdBQVcsR0FBRyxFQUFFLENBQUMsSUFBSSxFQUFFLENBQUM7UUFDNUIsVUFBVSxDQUFDLGNBQWMsQ0FBQyxXQUFXLENBQUMsQ0FBQTtRQUV0QyxhQUFhO1FBQ2IsSUFBSSxpQkFBaUIsR0FBRyxFQUFFLENBQUMsSUFBSSxFQUFFLENBQUM7UUFDbEMsVUFBVSxDQUFDLGNBQWMsQ0FBQyxpQkFBaUIsQ0FBQyxDQUFBO1FBRTVDLFlBQVk7UUFDWixJQUFJLG1CQUFtQixHQUFHLGlCQUFpQixDQUFDLE1BQU0sRUFBRSxDQUFDO1FBRXJELHdCQUF3QjtRQUN4QixJQUFJLFdBQVcsR0FBRyxtQkFBbUIsQ0FBQyxRQUFRLENBQUMsV0FBVyxDQUFDLENBQUM7UUFHNUQsT0FBTztRQUNQLElBQUksUUFBUSxHQUFHLEVBQUUsQ0FBQyxFQUFFLENBQUMsV0FBVyxDQUFDLENBQUMsQ0FBQyxFQUFFLENBQUMsRUFBRSxXQUFXLENBQUMsQ0FBQyxDQUFDLEVBQUUsQ0FBQyxFQUFFLFdBQVcsQ0FBQyxDQUFDLENBQUMsRUFBRSxDQUFDLENBQUMsQ0FBQztRQUU5RSxPQUFPO1FBQ1AsSUFBSSxNQUFNLEdBQUcsSUFBSSxDQUFDLElBQUksQ0FBQyxXQUFXLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLFdBQVcsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsV0FBVyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxXQUFXLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLFdBQVcsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsV0FBVyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDO1FBQ3hJLElBQUksTUFBTSxHQUFHLElBQUksQ0FBQyxJQUFJLENBQUMsV0FBVyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxXQUFXLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLFdBQVcsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsV0FBVyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxXQUFXLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLFdBQVcsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQztRQUN4SSxJQUFJLE1BQU0sR0FBRyxJQUFJLENBQUMsSUFBSSxDQUFDLFdBQVcsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsV0FBVyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxXQUFXLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLFdBQVcsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsV0FBVyxDQUFDLENBQUMsQ0FBQyxFQUFFLENBQUMsR0FBRyxXQUFXLENBQUMsQ0FBQyxDQUFDLEVBQUUsQ0FBQyxDQUFDLENBQUM7UUFFMUksZ0JBQWdCO1FBQ2hCLElBQUksS0FBSyxHQUFHLElBQUksQ0FBQyxLQUFLLENBQUMsV0FBVyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxNQUFNLEVBQUUsV0FBVyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxNQUFNLENBQUMsR0FBRyxDQUFDLEdBQUcsR0FBRyxJQUFJLENBQUMsRUFBRSxDQUFDLENBQUM7UUFFL0YsT0FBTztRQUNQLE9BQU8sQ0FBQyxHQUFHLENBQUMsV0FBVyxFQUFFLFFBQVEsQ0FBQyxDQUFDO1FBQ25DLE9BQU8sQ0FBQyxHQUFHLENBQUMsUUFBUSxFQUFFLEVBQUUsQ0FBQyxFQUFFLENBQUMsTUFBTSxFQUFFLE1BQU0sRUFBRSxNQUFNLENBQUMsQ0FBQyxDQUFDO1FBQ3JELE9BQU8sQ0FBQyxHQUFHLENBQUMsUUFBUSxFQUFFLEtBQUssQ0FBQyxDQUFDO0lBQ2pDLENBQUM7SUFFRCxnQ0FBYSxHQUFiLFVBQWMsTUFBZTtRQUN6QixPQUFPO1FBQ1AsSUFBSSxRQUFRLEdBQUcsRUFBRSxDQUFDLEVBQUUsQ0FBQyxNQUFNLENBQUMsQ0FBQyxDQUFDLEVBQUUsQ0FBQyxFQUFFLE1BQU0sQ0FBQyxDQUFDLENBQUMsRUFBRSxDQUFDLEVBQUUsTUFBTSxDQUFDLENBQUMsQ0FBQyxFQUFFLENBQUMsQ0FBQyxDQUFDO1FBRS9ELE9BQU87UUFDUCxJQUFJLE1BQU0sR0FBRyxJQUFJLENBQUMsSUFBSSxDQUFDLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUM7UUFDMUcsSUFBSSxNQUFNLEdBQUcsSUFBSSxDQUFDLElBQUksQ0FBQyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDO1FBQzFHLElBQUksTUFBTSxHQUFHLElBQUksQ0FBQyxJQUFJLENBQUMsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxNQUFNLENBQUMsQ0FBQyxDQUFDLEVBQUUsQ0FBQyxHQUFHLE1BQU0sQ0FBQyxDQUFDLENBQUMsRUFBRSxDQUFDLENBQUMsQ0FBQztRQUU1RyxnQkFBZ0I7UUFDaEIsSUFBSSxLQUFLLEdBQUcsSUFBSSxDQUFDLEtBQUssQ0FBQyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLE1BQU0sRUFBRSxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLE1BQU0sQ0FBQyxHQUFHLENBQUMsR0FBRyxHQUFHLElBQUksQ0FBQyxFQUFFLENBQUMsQ0FBQztRQUVyRixPQUFPO1FBQ1AsT0FBTyxDQUFDLEdBQUcsQ0FBQyxXQUFXLEVBQUUsUUFBUSxDQUFDLENBQUM7UUFDbkMsT0FBTyxDQUFDLEdBQUcsQ0FBQyxRQUFRLEVBQUUsRUFBRSxDQUFDLEVBQUUsQ0FBQyxNQUFNLEVBQUUsTUFBTSxFQUFFLE1BQU0sQ0FBQyxDQUFDLENBQUM7UUFDckQsT0FBTyxDQUFDLEdBQUcsQ0FBQyxRQUFRLEVBQUUsS0FBSyxDQUFDLENBQUM7SUFDakMsQ0FBQztJQUVELDRCQUFTLEdBQVQ7UUFDSSxFQUFFLENBQUMsUUFBUSxDQUFDLEdBQUcsQ0FBQyxFQUFFLENBQUMsUUFBUSxDQUFDLGlCQUFpQixFQUFFLElBQUksQ0FBQyxZQUFZLEVBQUUsSUFBSSxDQUFDLENBQUM7SUFDNUUsQ0FBQztJQUdELCtCQUFZLEdBQVo7UUFDSSxJQUFJLENBQUMsVUFBVSxDQUFDLElBQUksQ0FBQyxNQUFNLENBQUMsQ0FBQztRQUM3QixJQUFJLENBQUMsVUFBVSxDQUFDLElBQUksQ0FBQyxZQUFZLENBQUMsQ0FBQztJQUN2QyxDQUFDO0lBRUQsNkJBQVUsR0FBVixVQUFXLElBQWE7UUFDcEIsWUFBWTtRQUNaLElBQUksY0FBYyxHQUFHLElBQUksQ0FBQyxjQUFjLENBQUM7UUFDekMsSUFBSSxjQUFjLEVBQUU7WUFDaEIsT0FBTyxDQUFDLEdBQUcsQ0FBQyxJQUFJLENBQUMsSUFBSSxFQUFFLGNBQWMsQ0FBQyxDQUFDO1NBQzFDO1FBQ0QsWUFBWTtRQUNaLElBQUksY0FBYyxHQUFHLElBQUksQ0FBQyxjQUFjLENBQUM7UUFDekMsSUFBSSxjQUFjLEVBQUU7WUFDaEIsT0FBTyxDQUFDLEdBQUcsQ0FBQyxJQUFJLENBQUMsSUFBSSxFQUFFLGNBQWMsQ0FBQyxDQUFDO1NBQzFDO1FBQ0QsWUFBWTtRQUNaLElBQUksV0FBVyxHQUFHLElBQUksQ0FBQyxXQUFXLENBQUM7UUFDbkMsSUFBSSxXQUFXLEVBQUU7WUFDYixPQUFPLENBQUMsR0FBRyxDQUFDLElBQUksQ0FBQyxJQUFJLEVBQUUsV0FBVyxDQUFDLENBQUM7U0FDdkM7SUFDTCxDQUFDO0lBbklEO1FBREMsUUFBUSxDQUFDLEVBQUUsQ0FBQyxJQUFJLENBQUM7NENBQ0s7SUFHdkI7UUFEQyxRQUFRLENBQUMsRUFBRSxDQUFDLElBQUksQ0FBQztrREFDVztJQUc3QjtRQURDLFFBQVEsQ0FBQyxFQUFFLENBQUMsSUFBSSxDQUFDOytDQUNRO0lBRzFCO1FBREMsUUFBUSxDQUFDLEVBQUUsQ0FBQyxJQUFJLENBQUM7cURBQ2M7SUFaZixRQUFRO1FBRDVCLE9BQU87T0FDYSxRQUFRLENBeUk1QjtJQUFELGVBQUM7Q0F6SUQsQUF5SUMsQ0F6SXFDLEVBQUUsQ0FBQyxTQUFTLEdBeUlqRDtrQkF6SW9CLFFBQVEiLCJmaWxlIjoiIiwic291cmNlUm9vdCI6Ii8iLCJzb3VyY2VzQ29udGVudCI6WyIvLyBMZWFybiBUeXBlU2NyaXB0OlxyXG4vLyAgLSBodHRwczovL2RvY3MuY29jb3MuY29tL2NyZWF0b3IvbWFudWFsL2VuL3NjcmlwdGluZy90eXBlc2NyaXB0Lmh0bWxcclxuLy8gTGVhcm4gQXR0cmlidXRlOlxyXG4vLyAgLSBodHRwczovL2RvY3MuY29jb3MuY29tL2NyZWF0b3IvbWFudWFsL2VuL3NjcmlwdGluZy9yZWZlcmVuY2UvYXR0cmlidXRlcy5odG1sXHJcbi8vIExlYXJuIGxpZmUtY3ljbGUgY2FsbGJhY2tzOlxyXG4vLyAgLSBodHRwczovL2RvY3MuY29jb3MuY29tL2NyZWF0b3IvbWFudWFsL2VuL3NjcmlwdGluZy9saWZlLWN5Y2xlLWNhbGxiYWNrcy5odG1sXHJcblxyXG5jb25zdCB7IGNjY2xhc3MsIHByb3BlcnR5IH0gPSBjYy5fZGVjb3JhdG9yO1xyXG5cclxuQGNjY2xhc3NcclxuZXhwb3J0IGRlZmF1bHQgY2xhc3MgTmV3Q2xhc3MgZXh0ZW5kcyBjYy5Db21wb25lbnQge1xyXG5cclxuICAgIEBwcm9wZXJ0eShjYy5Ob2RlKVxyXG4gICAgdGFyZ2V0OiBjYy5Ob2RlID0gbnVsbDtcclxuXHJcbiAgICBAcHJvcGVydHkoY2MuTm9kZSlcclxuICAgIHRhcmdldFBhcmVudDogY2MuTm9kZSA9IG51bGw7XHJcblxyXG4gICAgQHByb3BlcnR5KGNjLk5vZGUpXHJcbiAgICBzcmNUYXJnZXQ6IGNjLk5vZGUgPSBudWxsO1xyXG5cclxuICAgIEBwcm9wZXJ0eShjYy5Ob2RlKVxyXG4gICAgc3JjVGFyZ2V0UGFyZW50OiBjYy5Ob2RlID0gbnVsbDtcclxuICAgIC8vIExJRkUtQ1lDTEUgQ0FMTEJBQ0tTOlxyXG5cclxuICAgIG9uTG9hZCgpIHtcclxuICAgICAgICAvLyBjYy5kaXJlY3Rvci5vbihjYy5EaXJlY3Rvci5FVkVOVF9CRUZPUkVfRFJBVywgdGhpcy5vbkJlZm9yZURyYXcsIHRoaXMpO1xyXG4gICAgfVxyXG5cclxuICAgIHN0YXJ0KCkge1xyXG4gICAgICAgIC8vIHRoaXMuc2NoZWR1bGVPbmNlKCgpID0+IHtcclxuICAgICAgICAvLyAgICAgdGhpcy50YXJnZXQueCA9IDEwMDtcclxuICAgICAgICAvLyAgICAgdGhpcy50YXJnZXQuc2NhbGVYID0gMjtcclxuICAgICAgICAvLyB9LCAzKTtcclxuXHJcbiAgICAgICAgLy8gdGhpcy5zY2hlZHVsZU9uY2UoKCkgPT4ge1xyXG4gICAgICAgIC8vICAgICB0aGlzLnRhcmdldFBhcmVudC54ID0gMTA7XHJcbiAgICAgICAgLy8gICAgIHRoaXMudGFyZ2V0LnNjYWxlWCA9IDEuMTtcclxuICAgICAgICAvLyB9LCAxKTtcclxuICAgICAgICBsZXQgdGFyZ2V0Tm9kZSA9IHRoaXMudGFyZ2V0OyAvLyDpnIDopoHojrflj5bkuJbnlYznn6npmLXnmoToioLngrlcclxuICAgICAgICBsZXQgcGFyZW50Tm9kZSA9IHRoaXMudGFyZ2V0UGFyZW50OyAvLyDopoHovazmjaLliLDnmoToioLngrlcclxuXHJcbiAgICAgICAgbGV0IGxvY2FsTWF0cml4ID0gY2MubWF0NCgpO1xyXG4gICAgICAgIHRhcmdldE5vZGUuZ2V0TG9jYWxNYXRyaXgobG9jYWxNYXRyaXgpO1xyXG4gICAgICAgIHRoaXMuZ2V0TWF0cml4SW5mbyhsb2NhbE1hdHJpeCk7XHJcblxyXG4gICAgICAgIC8vIOiOt+WPluebruagh+iKgueCueeahOS4lueVjOefqemYtVxyXG4gICAgICAgIGxldCB3b3JsZE1hdHJpeCA9IGNjLm1hdDQoKTtcclxuICAgICAgICB0YXJnZXROb2RlLmdldFdvcmxkTWF0cml4KHdvcmxkTWF0cml4KVxyXG4gICAgICAgIC8vIOiOt+WPlueItuiKgueCueeahOS4lueVjOefqemYtVxyXG4gICAgICAgIGxldCBwYXJlbnRXb3JsZE1hdHJpeCA9IGNjLm1hdDQoKTtcclxuICAgICAgICBwYXJlbnROb2RlLmdldFdvcmxkTWF0cml4KHBhcmVudFdvcmxkTWF0cml4KTtcclxuXHJcbiAgICAgICAgLy8g6I635Y+W54i26IqC54K555qE6YCG55+p6Zi1XHJcbiAgICAgICAgbGV0IHBhcmVudEludmVyc2VNYXRyaXggPSBwYXJlbnRXb3JsZE1hdHJpeC5pbnZlcnQoKTtcclxuXHJcbiAgICAgICAgLy8g5bCG55uu5qCH6IqC54K555qE5LiW55WM55+p6Zi16L2s5o2i5Li654i26IqC54K555qE5pys5Zyw55+p6Zi1XHJcbiAgICAgICAgbGV0IGxvY2FsTWF0cml4MiA9IHBhcmVudEludmVyc2VNYXRyaXgubXVsdGlwbHkod29ybGRNYXRyaXgpO1xyXG5cclxuICAgICAgICB0aGlzLmdldE1hdHJpeEluZm8obG9jYWxNYXRyaXgyKTtcclxuXHJcbiAgICB9XHJcblxyXG4gICAgbWF0cml4VHJhbnNmb3JtKCkge1xyXG4gICAgICAgIC8vIOWBh+iuvuaIkeS7rOacieS4gOS4quebruagh+iKgueCueWSjOS4gOS4queItuiKgueCuVxyXG4gICAgICAgIGxldCB0YXJnZXROb2RlID0gdGhpcy50YXJnZXQ7IC8vIOmcgOimgeiOt+WPluS4lueVjOefqemYteeahOiKgueCuVxyXG4gICAgICAgIGxldCBwYXJlbnROb2RlID0gdGhpcy5zcmNUYXJnZXRQYXJlbnQ7IC8vIOimgei9rOaNouWIsOeahOiKgueCuVxyXG5cclxuICAgICAgICAvLyDojrflj5bnm67moIfoioLngrnnmoTkuJbnlYznn6npmLVcclxuICAgICAgICBsZXQgd29ybGRNYXRyaXggPSBjYy5tYXQ0KCk7XHJcbiAgICAgICAgdGFyZ2V0Tm9kZS5nZXRXb3JsZE1hdHJpeCh3b3JsZE1hdHJpeClcclxuXHJcbiAgICAgICAgLy8g6I635Y+W54i26IqC54K555qE5LiW55WM55+p6Zi1XHJcbiAgICAgICAgbGV0IHBhcmVudFdvcmxkTWF0cml4ID0gY2MubWF0NCgpO1xyXG4gICAgICAgIHBhcmVudE5vZGUuZ2V0V29ybGRNYXRyaXgocGFyZW50V29ybGRNYXRyaXgpXHJcblxyXG4gICAgICAgIC8vIOiOt+WPlueItuiKgueCueeahOmAhuefqemYtVxyXG4gICAgICAgIGxldCBwYXJlbnRJbnZlcnNlTWF0cml4ID0gcGFyZW50V29ybGRNYXRyaXguaW52ZXJ0KCk7XHJcblxyXG4gICAgICAgIC8vIOWwhuebruagh+iKgueCueeahOS4lueVjOefqemYtei9rOaNouS4uueItuiKgueCueeahOacrOWcsOefqemYtVxyXG4gICAgICAgIGxldCBsb2NhbE1hdHJpeCA9IHBhcmVudEludmVyc2VNYXRyaXgubXVsdGlwbHkod29ybGRNYXRyaXgpO1xyXG5cclxuXHJcbiAgICAgICAgLy8g5o+Q5Y+W5L2N572uXHJcbiAgICAgICAgbGV0IHBvc2l0aW9uID0gY2MudjMod29ybGRNYXRyaXgubVsxMl0sIHdvcmxkTWF0cml4Lm1bMTNdLCB3b3JsZE1hdHJpeC5tWzE0XSk7XHJcblxyXG4gICAgICAgIC8vIOaPkOWPlue8qeaUvlxyXG4gICAgICAgIGxldCBzY2FsZVggPSBNYXRoLnNxcnQod29ybGRNYXRyaXgubVswXSAqIHdvcmxkTWF0cml4Lm1bMF0gKyB3b3JsZE1hdHJpeC5tWzFdICogd29ybGRNYXRyaXgubVsxXSArIHdvcmxkTWF0cml4Lm1bMl0gKiB3b3JsZE1hdHJpeC5tWzJdKTtcclxuICAgICAgICBsZXQgc2NhbGVZID0gTWF0aC5zcXJ0KHdvcmxkTWF0cml4Lm1bNF0gKiB3b3JsZE1hdHJpeC5tWzRdICsgd29ybGRNYXRyaXgubVs1XSAqIHdvcmxkTWF0cml4Lm1bNV0gKyB3b3JsZE1hdHJpeC5tWzZdICogd29ybGRNYXRyaXgubVs2XSk7XHJcbiAgICAgICAgbGV0IHNjYWxlWiA9IE1hdGguc3FydCh3b3JsZE1hdHJpeC5tWzhdICogd29ybGRNYXRyaXgubVs4XSArIHdvcmxkTWF0cml4Lm1bOV0gKiB3b3JsZE1hdHJpeC5tWzldICsgd29ybGRNYXRyaXgubVsxMF0gKiB3b3JsZE1hdHJpeC5tWzEwXSk7XHJcblxyXG4gICAgICAgIC8vIOaPkOWPluaXi+i9rO+8iOWBh+iuvuaYr+S6jOe7tOaXi+i9rO+8iVxyXG4gICAgICAgIGxldCBhbmdsZSA9IE1hdGguYXRhbjIod29ybGRNYXRyaXgubVsxXSAvIHNjYWxlWCwgd29ybGRNYXRyaXgubVswXSAvIHNjYWxlWCkgKiAoMTgwIC8gTWF0aC5QSSk7XHJcblxyXG4gICAgICAgIC8vIOi+k+WHuue7k+aenFxyXG4gICAgICAgIGNvbnNvbGUubG9nKFwiUG9zaXRpb246XCIsIHBvc2l0aW9uKTtcclxuICAgICAgICBjb25zb2xlLmxvZyhcIlNjYWxlOlwiLCBjYy52MyhzY2FsZVgsIHNjYWxlWSwgc2NhbGVaKSk7XHJcbiAgICAgICAgY29uc29sZS5sb2coXCJBbmdsZTpcIiwgYW5nbGUpO1xyXG4gICAgfVxyXG5cclxuICAgIGdldE1hdHJpeEluZm8obWF0cml4OiBjYy5NYXQ0KSB7XHJcbiAgICAgICAgLy8g5o+Q5Y+W5L2N572uXHJcbiAgICAgICAgbGV0IHBvc2l0aW9uID0gY2MudjMobWF0cml4Lm1bMTJdLCBtYXRyaXgubVsxM10sIG1hdHJpeC5tWzE0XSk7XHJcblxyXG4gICAgICAgIC8vIOaPkOWPlue8qeaUvlxyXG4gICAgICAgIGxldCBzY2FsZVggPSBNYXRoLnNxcnQobWF0cml4Lm1bMF0gKiBtYXRyaXgubVswXSArIG1hdHJpeC5tWzFdICogbWF0cml4Lm1bMV0gKyBtYXRyaXgubVsyXSAqIG1hdHJpeC5tWzJdKTtcclxuICAgICAgICBsZXQgc2NhbGVZID0gTWF0aC5zcXJ0KG1hdHJpeC5tWzRdICogbWF0cml4Lm1bNF0gKyBtYXRyaXgubVs1XSAqIG1hdHJpeC5tWzVdICsgbWF0cml4Lm1bNl0gKiBtYXRyaXgubVs2XSk7XHJcbiAgICAgICAgbGV0IHNjYWxlWiA9IE1hdGguc3FydChtYXRyaXgubVs4XSAqIG1hdHJpeC5tWzhdICsgbWF0cml4Lm1bOV0gKiBtYXRyaXgubVs5XSArIG1hdHJpeC5tWzEwXSAqIG1hdHJpeC5tWzEwXSk7XHJcblxyXG4gICAgICAgIC8vIOaPkOWPluaXi+i9rO+8iOWBh+iuvuaYr+S6jOe7tOaXi+i9rO+8iVxyXG4gICAgICAgIGxldCBhbmdsZSA9IE1hdGguYXRhbjIobWF0cml4Lm1bMV0gLyBzY2FsZVgsIG1hdHJpeC5tWzBdIC8gc2NhbGVYKSAqICgxODAgLyBNYXRoLlBJKTtcclxuXHJcbiAgICAgICAgLy8g6L6T5Ye657uT5p6cXHJcbiAgICAgICAgY29uc29sZS5sb2coXCJQb3NpdGlvbjpcIiwgcG9zaXRpb24pO1xyXG4gICAgICAgIGNvbnNvbGUubG9nKFwiU2NhbGU6XCIsIGNjLnYzKHNjYWxlWCwgc2NhbGVZLCBzY2FsZVopKTtcclxuICAgICAgICBjb25zb2xlLmxvZyhcIkFuZ2xlOlwiLCBhbmdsZSk7XHJcbiAgICB9XHJcblxyXG4gICAgb25EZXN0cm95KCk6IHZvaWQge1xyXG4gICAgICAgIGNjLmRpcmVjdG9yLm9mZihjYy5EaXJlY3Rvci5FVkVOVF9CRUZPUkVfRFJBVywgdGhpcy5vbkJlZm9yZURyYXcsIHRoaXMpO1xyXG4gICAgfVxyXG5cclxuXHJcbiAgICBvbkJlZm9yZURyYXcoKSB7XHJcbiAgICAgICAgdGhpcy5jaGVja0RpcnR5KHRoaXMudGFyZ2V0KTtcclxuICAgICAgICB0aGlzLmNoZWNrRGlydHkodGhpcy50YXJnZXRQYXJlbnQpO1xyXG4gICAgfVxyXG5cclxuICAgIGNoZWNrRGlydHkobm9kZTogY2MuTm9kZSkge1xyXG4gICAgICAgIC8vQHRzLWlnbm9yZVxyXG4gICAgICAgIGxldCBfbG9jYWxNYXREaXJ0eSA9IG5vZGUuX2xvY2FsTWF0RGlydHk7XHJcbiAgICAgICAgaWYgKF9sb2NhbE1hdERpcnR5KSB7XHJcbiAgICAgICAgICAgIGNvbnNvbGUubG9nKG5vZGUubmFtZSwgX2xvY2FsTWF0RGlydHkpO1xyXG4gICAgICAgIH1cclxuICAgICAgICAvL0B0cy1pZ25vcmVcclxuICAgICAgICBsZXQgX3dvcmxkTWF0RGlydHkgPSBub2RlLl93b3JsZE1hdERpcnR5O1xyXG4gICAgICAgIGlmIChfd29ybGRNYXREaXJ0eSkge1xyXG4gICAgICAgICAgICBjb25zb2xlLmxvZyhub2RlLm5hbWUsIF93b3JsZE1hdERpcnR5KTtcclxuICAgICAgICB9XHJcbiAgICAgICAgLy9AdHMtaWdub3JlXHJcbiAgICAgICAgbGV0IF9yZW5kZXJGbGFnID0gbm9kZS5fcmVuZGVyRmxhZztcclxuICAgICAgICBpZiAoX3JlbmRlckZsYWcpIHtcclxuICAgICAgICAgICAgY29uc29sZS5sb2cobm9kZS5uYW1lLCBfcmVuZGVyRmxhZyk7XHJcbiAgICAgICAgfVxyXG4gICAgfVxyXG5cclxuICAgIC8vIHVwZGF0ZSAoZHQpIHt9XHJcbn1cclxuIl19 +//------QC-SOURCE-SPLIT------ + + (function() { + var nodeEnv = typeof require !== 'undefined' && typeof process !== 'undefined'; + var __module = nodeEnv ? module : {exports:{}}; + var __filename = 'preview-scripts/assets/Scene/Item.js'; + var __require = nodeEnv ? function (request) { + return cc.require(request); + } : function (request) { + return __quick_compile_project__.require(request, __filename); + }; + function __define (exports, require, module) { + if (!nodeEnv) {__quick_compile_project__.registerModule(__filename, module);}"use strict"; +cc._RF.push(module, '7e1f6lmx11Hho9BNV3MqKkZ', 'Item'); +// Scene/Item.ts + +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var RenderAlternativeItem_1 = require("../Script/RenderAlternativeItem"); +var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property; +var Item = /** @class */ (function (_super) { + __extends(Item, _super); + function Item() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /** */ + _this.nameLb = null; + /** */ + _this.contentLb = null; + /** */ + _this.Button = null; + /** */ + _this.ButtonLb = null; + _this.data = null; + return _this; + // update (dt) {} + } + Item.prototype.init = function (data) { + this.data = data.data; + var layer = data.layer; + this.initRenderLayer(layer); + this.initShow(); + }; + /** + * 初始化显示 + * @param data + */ + Item.prototype.initShow = function () { + this.nameLb.string = "我是第" + this.data.index + "个"; + this.contentLb.string = "我是内容" + this.data.name; + }; + __decorate([ + property(cc.Label) + ], Item.prototype, "nameLb", void 0); + __decorate([ + property(cc.Label) + ], Item.prototype, "contentLb", void 0); + __decorate([ + property(cc.Node) + ], Item.prototype, "Button", void 0); + __decorate([ + property(cc.Label) + ], Item.prototype, "ButtonLb", void 0); + Item = __decorate([ + ccclass + ], Item); + return Item; +}(RenderAlternativeItem_1.default)); +exports.default = Item; + +cc._RF.pop(); + } + if (nodeEnv) { + __define(__module.exports, __require, __module); + } + else { + __quick_compile_project__.registerModuleFunc(__filename, function () { + __define(__module.exports, __require, __module); + }); + } + })(); +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImFzc2V0c1xcU2NlbmVcXEl0ZW0udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0FBQUEseUVBQW9FO0FBRzlELElBQUEsS0FBd0IsRUFBRSxDQUFDLFVBQVUsRUFBbkMsT0FBTyxhQUFBLEVBQUUsUUFBUSxjQUFrQixDQUFDO0FBRzVDO0lBQWtDLHdCQUFxQjtJQUF2RDtRQUFBLHFFQWtDQztRQWhDRyxNQUFNO1FBRUMsWUFBTSxHQUFhLElBQUksQ0FBQztRQUMvQixNQUFNO1FBRUMsZUFBUyxHQUFhLElBQUksQ0FBQztRQUNsQyxNQUFNO1FBRUMsWUFBTSxHQUFZLElBQUksQ0FBQztRQUM5QixNQUFNO1FBRUMsY0FBUSxHQUFhLElBQUksQ0FBQztRQUVqQyxVQUFJLEdBQVEsSUFBSSxDQUFDOztRQWtCakIsaUJBQWlCO0lBQ3JCLENBQUM7SUFqQkcsbUJBQUksR0FBSixVQUFLLElBQVM7UUFDVixJQUFJLENBQUMsSUFBSSxHQUFHLElBQUksQ0FBQyxJQUFJLENBQUM7UUFDdEIsSUFBSSxLQUFLLEdBQUcsSUFBSSxDQUFDLEtBQUssQ0FBQztRQUN2QixJQUFJLENBQUMsZUFBZSxDQUFDLEtBQUssQ0FBQyxDQUFDO1FBQzVCLElBQUksQ0FBQyxRQUFRLEVBQUUsQ0FBQztJQUNwQixDQUFDO0lBRUQ7OztPQUdHO0lBQ0gsdUJBQVEsR0FBUjtRQUNJLElBQUksQ0FBQyxNQUFNLENBQUMsTUFBTSxHQUFHLEtBQUssR0FBRyxJQUFJLENBQUMsSUFBSSxDQUFDLEtBQUssR0FBRyxHQUFHLENBQUM7UUFDbkQsSUFBSSxDQUFDLFNBQVMsQ0FBQyxNQUFNLEdBQUcsTUFBTSxHQUFHLElBQUksQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDO0lBQ3BELENBQUM7SUEzQkQ7UUFEQyxRQUFRLENBQUMsRUFBRSxDQUFDLEtBQUssQ0FBQzt3Q0FDWTtJQUcvQjtRQURDLFFBQVEsQ0FBQyxFQUFFLENBQUMsS0FBSyxDQUFDOzJDQUNlO0lBR2xDO1FBREMsUUFBUSxDQUFDLEVBQUUsQ0FBQyxJQUFJLENBQUM7d0NBQ1k7SUFHOUI7UUFEQyxRQUFRLENBQUMsRUFBRSxDQUFDLEtBQUssQ0FBQzswQ0FDYztJQWJoQixJQUFJO1FBRHhCLE9BQU87T0FDYSxJQUFJLENBa0N4QjtJQUFELFdBQUM7Q0FsQ0QsQUFrQ0MsQ0FsQ2lDLCtCQUFxQixHQWtDdEQ7a0JBbENvQixJQUFJIiwiZmlsZSI6IiIsInNvdXJjZVJvb3QiOiIvIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IFJlbmRlckFsdGVybmF0aXZlSXRlbSBmcm9tIFwiLi4vU2NyaXB0L1JlbmRlckFsdGVybmF0aXZlSXRlbVwiO1xyXG5cclxuXHJcbmNvbnN0IHsgY2NjbGFzcywgcHJvcGVydHkgfSA9IGNjLl9kZWNvcmF0b3I7XHJcblxyXG5AY2NjbGFzc1xyXG5leHBvcnQgZGVmYXVsdCBjbGFzcyBJdGVtIGV4dGVuZHMgUmVuZGVyQWx0ZXJuYXRpdmVJdGVtIHtcclxuXHJcbiAgICAvKiogKi9cclxuICAgIEBwcm9wZXJ0eShjYy5MYWJlbClcclxuICAgIHB1YmxpYyBuYW1lTGI6IGNjLkxhYmVsID0gbnVsbDtcclxuICAgIC8qKiAqL1xyXG4gICAgQHByb3BlcnR5KGNjLkxhYmVsKVxyXG4gICAgcHVibGljIGNvbnRlbnRMYjogY2MuTGFiZWwgPSBudWxsO1xyXG4gICAgLyoqICovXHJcbiAgICBAcHJvcGVydHkoY2MuTm9kZSlcclxuICAgIHB1YmxpYyBCdXR0b246IGNjLk5vZGUgPSBudWxsO1xyXG4gICAgLyoqICovXHJcbiAgICBAcHJvcGVydHkoY2MuTGFiZWwpXHJcbiAgICBwdWJsaWMgQnV0dG9uTGI6IGNjLkxhYmVsID0gbnVsbDtcclxuXHJcbiAgICBkYXRhOiBhbnkgPSBudWxsO1xyXG5cclxuICAgIGluaXQoZGF0YTogYW55KSB7XHJcbiAgICAgICAgdGhpcy5kYXRhID0gZGF0YS5kYXRhO1xyXG4gICAgICAgIGxldCBsYXllciA9IGRhdGEubGF5ZXI7XHJcbiAgICAgICAgdGhpcy5pbml0UmVuZGVyTGF5ZXIobGF5ZXIpO1xyXG4gICAgICAgIHRoaXMuaW5pdFNob3coKTtcclxuICAgIH1cclxuXHJcbiAgICAvKipcclxuICAgICAqIOWIneWni+WMluaYvuekulxyXG4gICAgICogQHBhcmFtIGRhdGEgXHJcbiAgICAgKi9cclxuICAgIGluaXRTaG93KCkge1xyXG4gICAgICAgIHRoaXMubmFtZUxiLnN0cmluZyA9IFwi5oiR5piv56ysXCIgKyB0aGlzLmRhdGEuaW5kZXggKyBcIuS4qlwiO1xyXG4gICAgICAgIHRoaXMuY29udGVudExiLnN0cmluZyA9IFwi5oiR5piv5YaF5a65XCIgKyB0aGlzLmRhdGEubmFtZTtcclxuICAgIH1cclxuXHJcbiAgICAvLyB1cGRhdGUgKGR0KSB7fVxyXG59XHJcbiJdfQ== +//------QC-SOURCE-SPLIT------ + + (function() { + var nodeEnv = typeof require !== 'undefined' && typeof process !== 'undefined'; + var __module = nodeEnv ? module : {exports:{}}; + var __filename = 'preview-scripts/assets/Script/RenderAlternativeItem.js'; + var __require = nodeEnv ? function (request) { + return cc.require(request); + } : function (request) { + return __quick_compile_project__.require(request, __filename); + }; + function __define (exports, require, module) { + if (!nodeEnv) {__quick_compile_project__.registerModule(__filename, module);}"use strict"; +cc._RF.push(module, 'd33f6MUGOxJN5eMJ9UzS3KH', 'RenderAlternativeItem'); +// Script/RenderAlternativeItem.ts + +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var RenderAlternative_1 = require("./RenderAlternative"); +var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property; +var RenderAlternativeItem = /** @class */ (function (_super) { + __extends(RenderAlternativeItem, _super); + /** + * 渲染分层Item挂载组件 + * 处理渲染分层Item的渲染分层 + */ + function RenderAlternativeItem() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /**是否初始化过代理组建 */ + _this.hasInit = false; + return _this; + } + /**初始化 */ + RenderAlternativeItem.prototype.initRenderLayer = function (renderLayer) { + if (this.renderLayer != renderLayer) { + this.renderLayer = renderLayer; + renderLayer && this.initRenders(); + } + }; + /** + * 处理分层代理渲染 + */ + RenderAlternativeItem.prototype.initRenders = function () { + if (!this.hasInit && this.renderLayer) { + // + var propMap = new WeakMap(); + var keys = Object.keys(this); + for (var i = 0, len = keys.length; i < len; ++i) { + var value = this[keys[i]]; + var alternative = null; + if (value instanceof cc.Node) { + alternative = value.getComponent(RenderAlternative_1.default); + if (alternative) { + alternative.init(this.renderLayer); + } + } + else if (value instanceof cc.RenderComponent) { + alternative = value.getComponent(RenderAlternative_1.default); + if (alternative) { + this[keys[i]] = alternative.init(this.renderLayer); + } + } + alternative && propMap.set(alternative, true); + } + this.dealChilrenAlternative(this.node, propMap, 0, 0); + this.hasInit = true; + } + }; + /** + * 处理子节点代理 + * @param node + * @param propMap 记录脚本已经处理过的属性代理 + * @param parentSindex 父节点的所在的顺序 + * @param depth 深度 + */ + RenderAlternativeItem.prototype.dealChilrenAlternative = function (node, propMap, parentSindex, depth) { + var _a; + for (var i = 0, len = node.children.length; i < len; i++) { + var children = node.children[i]; + var alternative = (_a = children.getComponent(cc.RenderComponent)) === null || _a === void 0 ? void 0 : _a.getComponent(RenderAlternative_1.default); + var sIndex = parentSindex + (i * Math.pow(0.1, depth)); + if (alternative) { + if ((!propMap.has(alternative) || !propMap.get(alternative))) { + alternative.init(this.renderLayer); + } + alternative.sIndex = sIndex; + } + this.dealChilrenAlternative(children, propMap, sIndex, depth + 1); + } + }; + RenderAlternativeItem = __decorate([ + ccclass + /** + * 渲染分层Item挂载组件 + * 处理渲染分层Item的渲染分层 + */ + ], RenderAlternativeItem); + return RenderAlternativeItem; +}(cc.Component)); +exports.default = RenderAlternativeItem; + +cc._RF.pop(); + } + if (nodeEnv) { + __define(__module.exports, __require, __module); + } + else { + __quick_compile_project__.registerModuleFunc(__filename, function () { + __define(__module.exports, __require, __module); + }); + } + })(); +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImFzc2V0c1xcU2NyaXB0XFxSZW5kZXJBbHRlcm5hdGl2ZUl0ZW0udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0FBQUEseURBQW9EO0FBRzlDLElBQUEsS0FBd0IsRUFBRSxDQUFDLFVBQVUsRUFBbkMsT0FBTyxhQUFBLEVBQUUsUUFBUSxjQUFrQixDQUFDO0FBTzVDO0lBQW1ELHlDQUFZO0lBSi9EOzs7T0FHRztJQUNIO1FBQUEscUVBOERDO1FBNURHLGdCQUFnQjtRQUNSLGFBQU8sR0FBWSxLQUFLLENBQUM7O0lBMkRyQyxDQUFDO0lBeERHLFNBQVM7SUFDRiwrQ0FBZSxHQUF0QixVQUF1QixXQUFvQjtRQUN2QyxJQUFJLElBQUksQ0FBQyxXQUFXLElBQUksV0FBVyxFQUFFO1lBQ2pDLElBQUksQ0FBQyxXQUFXLEdBQUcsV0FBVyxDQUFDO1lBQy9CLFdBQVcsSUFBSSxJQUFJLENBQUMsV0FBVyxFQUFFLENBQUM7U0FDckM7SUFDTCxDQUFDO0lBQ0Q7O09BRUc7SUFDSywyQ0FBVyxHQUFuQjtRQUNJLElBQUksQ0FBQyxJQUFJLENBQUMsT0FBTyxJQUFJLElBQUksQ0FBQyxXQUFXLEVBQUU7WUFDbkMsRUFBRTtZQUNGLElBQUksT0FBTyxHQUF3QyxJQUFJLE9BQU8sRUFBRSxDQUFDO1lBQ2pFLElBQUksSUFBSSxHQUFHLE1BQU0sQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLENBQUM7WUFDN0IsS0FBSyxJQUFJLENBQUMsR0FBRyxDQUFDLEVBQUUsR0FBRyxHQUFHLElBQUksQ0FBQyxNQUFNLEVBQUUsQ0FBQyxHQUFHLEdBQUcsRUFBRSxFQUFFLENBQUMsRUFBRTtnQkFDN0MsSUFBSSxLQUFLLEdBQUcsSUFBSSxDQUFDLElBQUksQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDO2dCQUMxQixJQUFJLFdBQVcsR0FBc0IsSUFBSSxDQUFDO2dCQUMxQyxJQUFJLEtBQUssWUFBWSxFQUFFLENBQUMsSUFBSSxFQUFFO29CQUMxQixXQUFXLEdBQUcsS0FBSyxDQUFDLFlBQVksQ0FBQywyQkFBaUIsQ0FBQyxDQUFDO29CQUNwRCxJQUFJLFdBQVcsRUFBRTt3QkFDYixXQUFXLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxXQUFXLENBQUMsQ0FBQztxQkFDdEM7aUJBQ0o7cUJBQU0sSUFBSSxLQUFLLFlBQVksRUFBRSxDQUFDLGVBQWUsRUFBRTtvQkFDNUMsV0FBVyxHQUFHLEtBQUssQ0FBQyxZQUFZLENBQUMsMkJBQWlCLENBQUMsQ0FBQztvQkFDcEQsSUFBSSxXQUFXLEVBQUU7d0JBQ2IsSUFBSSxDQUFDLElBQUksQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLFdBQVcsQ0FBQyxJQUFJLENBQWUsSUFBSSxDQUFDLFdBQVcsQ0FBQyxDQUFDO3FCQUNwRTtpQkFDSjtnQkFDRCxXQUFXLElBQUksT0FBTyxDQUFDLEdBQUcsQ0FBQyxXQUFXLEVBQUUsSUFBSSxDQUFDLENBQUM7YUFDakQ7WUFDRCxJQUFJLENBQUMsc0JBQXNCLENBQUMsSUFBSSxDQUFDLElBQUksRUFBRSxPQUFPLEVBQUUsQ0FBQyxFQUFFLENBQUMsQ0FBQyxDQUFDO1lBQ3RELElBQUksQ0FBQyxPQUFPLEdBQUcsSUFBSSxDQUFDO1NBQ3ZCO0lBQ0wsQ0FBQztJQUNEOzs7Ozs7T0FNRztJQUNILHNEQUFzQixHQUF0QixVQUF1QixJQUFhLEVBQUUsT0FBNEMsRUFBRSxZQUFvQixFQUFFLEtBQWE7O1FBQ25ILEtBQUssSUFBSSxDQUFDLEdBQUcsQ0FBQyxFQUFFLEdBQUcsR0FBRyxJQUFJLENBQUMsUUFBUSxDQUFDLE1BQU0sRUFBRSxDQUFDLEdBQUcsR0FBRyxFQUFFLENBQUMsRUFBRSxFQUFFO1lBQ3RELElBQUksUUFBUSxHQUFHLElBQUksQ0FBQyxRQUFRLENBQUMsQ0FBQyxDQUFDLENBQUM7WUFDaEMsSUFBSSxXQUFXLFNBQUcsUUFBUSxDQUFDLFlBQVksQ0FBQyxFQUFFLENBQUMsZUFBZSxDQUFDLDBDQUFFLFlBQVksQ0FBQywyQkFBaUIsQ0FBQyxDQUFDO1lBQzdGLElBQUksTUFBTSxHQUFHLFlBQVksR0FBRyxDQUFDLENBQUMsR0FBRyxJQUFJLENBQUMsR0FBRyxDQUFDLEdBQUcsRUFBRSxLQUFLLENBQUMsQ0FBQyxDQUFDO1lBQ3ZELElBQUksV0FBVyxFQUFFO2dCQUNiLElBQUksQ0FBQyxDQUFDLE9BQU8sQ0FBQyxHQUFHLENBQUMsV0FBVyxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUMsR0FBRyxDQUFDLFdBQVcsQ0FBQyxDQUFDLEVBQUU7b0JBQzFELFdBQVcsQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLFdBQVcsQ0FBQyxDQUFDO2lCQUN0QztnQkFDRCxXQUFXLENBQUMsTUFBTSxHQUFHLE1BQU0sQ0FBQzthQUMvQjtZQUNELElBQUksQ0FBQyxzQkFBc0IsQ0FBQyxRQUFRLEVBQUUsT0FBTyxFQUFFLE1BQU0sRUFBRSxLQUFLLEdBQUcsQ0FBQyxDQUFDLENBQUM7U0FDckU7SUFDTCxDQUFDO0lBN0RnQixxQkFBcUI7UUFMekMsT0FBTztRQUNSOzs7V0FHRztPQUNrQixxQkFBcUIsQ0E4RHpDO0lBQUQsNEJBQUM7Q0E5REQsQUE4REMsQ0E5RGtELEVBQUUsQ0FBQyxTQUFTLEdBOEQ5RDtrQkE5RG9CLHFCQUFxQiIsImZpbGUiOiIiLCJzb3VyY2VSb290IjoiLyIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCBSZW5kZXJBbHRlcm5hdGl2ZSBmcm9tIFwiLi9SZW5kZXJBbHRlcm5hdGl2ZVwiO1xyXG5cclxuXHJcbmNvbnN0IHsgY2NjbGFzcywgcHJvcGVydHkgfSA9IGNjLl9kZWNvcmF0b3I7XHJcblxyXG5AY2NjbGFzc1xyXG4vKipcclxuICog5riy5p+T5YiG5bGCSXRlbeaMgui9vee7hOS7tlxyXG4gKiDlpITnkIbmuLLmn5PliIblsYJJdGVt55qE5riy5p+T5YiG5bGCXHJcbiAqL1xyXG5leHBvcnQgZGVmYXVsdCBjbGFzcyBSZW5kZXJBbHRlcm5hdGl2ZUl0ZW0gZXh0ZW5kcyBjYy5Db21wb25lbnQge1xyXG5cclxuICAgIC8qKuaYr+WQpuWIneWni+WMlui/h+S7o+eQhue7hOW7uiAqL1xyXG4gICAgcHJpdmF0ZSBoYXNJbml0OiBib29sZWFuID0gZmFsc2U7XHJcbiAgICAvKirmuLLmn5PliIblsYLlvIDlkK/nmoTmjILovb3oioLngrkgKi9cclxuICAgIHB1YmxpYyByZW5kZXJMYXllcjogY2MuTm9kZTtcclxuICAgIC8qKuWIneWni+WMliAqL1xyXG4gICAgcHVibGljIGluaXRSZW5kZXJMYXllcihyZW5kZXJMYXllcjogY2MuTm9kZSkge1xyXG4gICAgICAgIGlmICh0aGlzLnJlbmRlckxheWVyICE9IHJlbmRlckxheWVyKSB7XHJcbiAgICAgICAgICAgIHRoaXMucmVuZGVyTGF5ZXIgPSByZW5kZXJMYXllcjtcclxuICAgICAgICAgICAgcmVuZGVyTGF5ZXIgJiYgdGhpcy5pbml0UmVuZGVycygpO1xyXG4gICAgICAgIH1cclxuICAgIH1cclxuICAgIC8qKlxyXG4gICAgICog5aSE55CG5YiG5bGC5Luj55CG5riy5p+TXHJcbiAgICAgKi9cclxuICAgIHByaXZhdGUgaW5pdFJlbmRlcnMoKSB7XHJcbiAgICAgICAgaWYgKCF0aGlzLmhhc0luaXQgJiYgdGhpcy5yZW5kZXJMYXllcikge1xyXG4gICAgICAgICAgICAvL1xyXG4gICAgICAgICAgICBsZXQgcHJvcE1hcDogV2Vha01hcDxSZW5kZXJBbHRlcm5hdGl2ZSwgYm9vbGVhbj4gPSBuZXcgV2Vha01hcCgpO1xyXG4gICAgICAgICAgICBsZXQga2V5cyA9IE9iamVjdC5rZXlzKHRoaXMpO1xyXG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgbGVuID0ga2V5cy5sZW5ndGg7IGkgPCBsZW47ICsraSkge1xyXG4gICAgICAgICAgICAgICAgbGV0IHZhbHVlID0gdGhpc1trZXlzW2ldXTtcclxuICAgICAgICAgICAgICAgIGxldCBhbHRlcm5hdGl2ZTogUmVuZGVyQWx0ZXJuYXRpdmUgPSBudWxsO1xyXG4gICAgICAgICAgICAgICAgaWYgKHZhbHVlIGluc3RhbmNlb2YgY2MuTm9kZSkge1xyXG4gICAgICAgICAgICAgICAgICAgIGFsdGVybmF0aXZlID0gdmFsdWUuZ2V0Q29tcG9uZW50KFJlbmRlckFsdGVybmF0aXZlKTtcclxuICAgICAgICAgICAgICAgICAgICBpZiAoYWx0ZXJuYXRpdmUpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgYWx0ZXJuYXRpdmUuaW5pdCh0aGlzLnJlbmRlckxheWVyKTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHZhbHVlIGluc3RhbmNlb2YgY2MuUmVuZGVyQ29tcG9uZW50KSB7XHJcbiAgICAgICAgICAgICAgICAgICAgYWx0ZXJuYXRpdmUgPSB2YWx1ZS5nZXRDb21wb25lbnQoUmVuZGVyQWx0ZXJuYXRpdmUpO1xyXG4gICAgICAgICAgICAgICAgICAgIGlmIChhbHRlcm5hdGl2ZSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzW2tleXNbaV1dID0gYWx0ZXJuYXRpdmUuaW5pdDx0eXBlb2YgdmFsdWU+KHRoaXMucmVuZGVyTGF5ZXIpO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIGFsdGVybmF0aXZlICYmIHByb3BNYXAuc2V0KGFsdGVybmF0aXZlLCB0cnVlKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB0aGlzLmRlYWxDaGlscmVuQWx0ZXJuYXRpdmUodGhpcy5ub2RlLCBwcm9wTWFwLCAwLCAwKTtcclxuICAgICAgICAgICAgdGhpcy5oYXNJbml0ID0gdHJ1ZTtcclxuICAgICAgICB9XHJcbiAgICB9XHJcbiAgICAvKipcclxuICAgICAqIOWkhOeQhuWtkOiKgueCueS7o+eQhlxyXG4gICAgICogQHBhcmFtIG5vZGUgXHJcbiAgICAgKiBAcGFyYW0gcHJvcE1hcCDorrDlvZXohJrmnKzlt7Lnu4/lpITnkIbov4fnmoTlsZ7mgKfku6PnkIZcclxuICAgICAqIEBwYXJhbSBwYXJlbnRTaW5kZXgg54i26IqC54K555qE5omA5Zyo55qE6aG65bqPXHJcbiAgICAgKiBAcGFyYW0gZGVwdGgg5rex5bqmXHJcbiAgICAgKi9cclxuICAgIGRlYWxDaGlscmVuQWx0ZXJuYXRpdmUobm9kZTogY2MuTm9kZSwgcHJvcE1hcDogV2Vha01hcDxSZW5kZXJBbHRlcm5hdGl2ZSwgYm9vbGVhbj4sIHBhcmVudFNpbmRleDogbnVtYmVyLCBkZXB0aDogbnVtYmVyKSB7XHJcbiAgICAgICAgZm9yIChsZXQgaSA9IDAsIGxlbiA9IG5vZGUuY2hpbGRyZW4ubGVuZ3RoOyBpIDwgbGVuOyBpKyspIHtcclxuICAgICAgICAgICAgbGV0IGNoaWxkcmVuID0gbm9kZS5jaGlsZHJlbltpXTtcclxuICAgICAgICAgICAgbGV0IGFsdGVybmF0aXZlID0gY2hpbGRyZW4uZ2V0Q29tcG9uZW50KGNjLlJlbmRlckNvbXBvbmVudCk/LmdldENvbXBvbmVudChSZW5kZXJBbHRlcm5hdGl2ZSk7XHJcbiAgICAgICAgICAgIGxldCBzSW5kZXggPSBwYXJlbnRTaW5kZXggKyAoaSAqIE1hdGgucG93KDAuMSwgZGVwdGgpKTtcclxuICAgICAgICAgICAgaWYgKGFsdGVybmF0aXZlKSB7XHJcbiAgICAgICAgICAgICAgICBpZiAoKCFwcm9wTWFwLmhhcyhhbHRlcm5hdGl2ZSkgfHwgIXByb3BNYXAuZ2V0KGFsdGVybmF0aXZlKSkpIHtcclxuICAgICAgICAgICAgICAgICAgICBhbHRlcm5hdGl2ZS5pbml0KHRoaXMucmVuZGVyTGF5ZXIpO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgYWx0ZXJuYXRpdmUuc0luZGV4ID0gc0luZGV4O1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIHRoaXMuZGVhbENoaWxyZW5BbHRlcm5hdGl2ZShjaGlsZHJlbiwgcHJvcE1hcCwgc0luZGV4LCBkZXB0aCArIDEpO1xyXG4gICAgICAgIH1cclxuICAgIH1cclxufVxyXG4iXX0= +//------QC-SOURCE-SPLIT------ + + (function() { + var nodeEnv = typeof require !== 'undefined' && typeof process !== 'undefined'; + var __module = nodeEnv ? module : {exports:{}}; + var __filename = 'preview-scripts/assets/Scene/TestLoop.js'; + var __require = nodeEnv ? function (request) { + return cc.require(request); + } : function (request) { + return __quick_compile_project__.require(request, __filename); + }; + function __define (exports, require, module) { + if (!nodeEnv) {__quick_compile_project__.registerModule(__filename, module);}"use strict"; +cc._RF.push(module, '4850bCv26VE3LcjWQcJHche', 'TestLoop'); +// Scene/TestLoop.ts + +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.TestLoop = void 0; +var LoopList_1 = require("../Script/LoopList"); +var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property; +var TestLoop = /** @class */ (function (_super) { + __extends(TestLoop, _super); + function TestLoop() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /**分层渲染节点 */ + _this.rendeLayer = null; + /**显示节点预制件 */ + _this.scrollView = null; + /**显示节点预制件 */ + _this.showPrefab = null; + return _this; + } + TestLoop.prototype.start = function () { + //测试横向宽高数据 + /* let baseWidth = 80; + let changeWidth = 20; + let baseHeight = 600; + let changeHeight = 150; + let anchor = cc.v2(0.5, 0.5) */ + //测试纵向宽高数据 + var baseWidth = 600; + var changeWidth = 150; + var baseHeight = 80; + var changeHeight = 20; + var anchor = cc.v2(0.5, 0.5); + var data = []; + for (var i = 0, len = 30; i < len; ++i) { + data.push({ + index: i, text: "内容" + i + }); + } + LoopList_1.default.ins("Test").init(this.scrollView, this.rendeLayer, 18); + LoopList_1.default.ins("Test").initData(data, this.showPrefab, cc.size(baseWidth, baseHeight), anchor); + /* //测试插入数据 + this.scheduleOnce(() => { + LoopList.ins("Test").insertData({ index: 1, text: "我是插入1", size: cc.size(baseWidth, baseHeight) }, 1); + }, 3) + + //测试压入数据 + this.scheduleOnce(() => { + LoopList.ins("Test").pushDatas([ + { index: 1, text: "我是压入1", size: cc.size(baseWidth, baseHeight) }, + { index: 2, text: "我是压入2", size: cc.size(baseWidth, baseHeight) }, + { index: 3, text: "我是压入3", size: cc.size(baseWidth, baseHeight) }, + ]); + }, 4) + + //测试压入数据 + this.scheduleOnce(() => { + LoopList.ins("Test").removeData(1); + }, 5) */ + }; + __decorate([ + property(cc.Node) + ], TestLoop.prototype, "rendeLayer", void 0); + __decorate([ + property(cc.ScrollView) + ], TestLoop.prototype, "scrollView", void 0); + __decorate([ + property(cc.Prefab) + ], TestLoop.prototype, "showPrefab", void 0); + TestLoop = __decorate([ + ccclass + ], TestLoop); + return TestLoop; +}(cc.Component)); +exports.TestLoop = TestLoop; + +cc._RF.pop(); + } + if (nodeEnv) { + __define(__module.exports, __require, __module); + } + else { + __quick_compile_project__.registerModuleFunc(__filename, function () { + __define(__module.exports, __require, __module); + }); + } + })(); +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImFzc2V0c1xcU2NlbmVcXFRlc3RMb29wLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7QUFFQSwrQ0FBMEM7QUFFcEMsSUFBQSxLQUF3QixFQUFFLENBQUMsVUFBVSxFQUFuQyxPQUFPLGFBQUEsRUFBRSxRQUFRLGNBQWtCLENBQUM7QUFHNUM7SUFBOEIsNEJBQVk7SUFBMUM7UUFBQSxxRUFzREM7UUFyREcsWUFBWTtRQUVMLGdCQUFVLEdBQVksSUFBSSxDQUFDO1FBQ2xDLGFBQWE7UUFFTixnQkFBVSxHQUFrQixJQUFJLENBQUM7UUFDeEMsYUFBYTtRQUVOLGdCQUFVLEdBQWMsSUFBSSxDQUFDOztJQTZDeEMsQ0FBQztJQTNDRyx3QkFBSyxHQUFMO1FBQ0ksVUFBVTtRQUNWOzs7O3VDQUkrQjtRQUUvQixVQUFVO1FBQ1YsSUFBSSxTQUFTLEdBQUcsR0FBRyxDQUFDO1FBQ3BCLElBQUksV0FBVyxHQUFHLEdBQUcsQ0FBQztRQUN0QixJQUFJLFVBQVUsR0FBRyxFQUFFLENBQUM7UUFDcEIsSUFBSSxZQUFZLEdBQUcsRUFBRSxDQUFDO1FBQ3RCLElBQUksTUFBTSxHQUFHLEVBQUUsQ0FBQyxFQUFFLENBQUMsR0FBRyxFQUFFLEdBQUcsQ0FBQyxDQUFDO1FBRTdCLElBQUksSUFBSSxHQUFZLEVBQUUsQ0FBQztRQUN2QixLQUFLLElBQUksQ0FBQyxHQUFHLENBQUMsRUFBRSxHQUFHLEdBQUcsRUFBRSxFQUFFLENBQUMsR0FBRyxHQUFHLEVBQUUsRUFBRSxDQUFDLEVBQUU7WUFDcEMsSUFBSSxDQUFDLElBQUksQ0FBQztnQkFDTixLQUFLLEVBQUUsQ0FBQyxFQUFFLElBQUksRUFBRSxJQUFJLEdBQUcsQ0FBQzthQUMzQixDQUFDLENBQUM7U0FDTjtRQUNELGtCQUFRLENBQUMsR0FBRyxDQUFRLE1BQU0sQ0FBQyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsVUFBVSxFQUFFLElBQUksQ0FBQyxVQUFVLEVBQUUsRUFBRSxDQUFDLENBQUM7UUFDdkUsa0JBQVEsQ0FBQyxHQUFHLENBQVEsTUFBTSxDQUFDLENBQUMsUUFBUSxDQUFDLElBQUksRUFBRSxJQUFJLENBQUMsVUFBVSxFQUFFLEVBQUUsQ0FBQyxJQUFJLENBQUMsU0FBUyxFQUFFLFVBQVUsQ0FBQyxFQUFFLE1BQU0sQ0FBQyxDQUFDO1FBRXBHOzs7Ozs7Ozs7Ozs7Ozs7OztnQkFpQlE7SUFDWixDQUFDO0lBbEREO1FBREMsUUFBUSxDQUFDLEVBQUUsQ0FBQyxJQUFJLENBQUM7Z0RBQ2dCO0lBR2xDO1FBREMsUUFBUSxDQUFDLEVBQUUsQ0FBQyxVQUFVLENBQUM7Z0RBQ2dCO0lBR3hDO1FBREMsUUFBUSxDQUFDLEVBQUUsQ0FBQyxNQUFNLENBQUM7Z0RBQ2dCO0lBVDNCLFFBQVE7UUFEcEIsT0FBTztPQUNLLFFBQVEsQ0FzRHBCO0lBQUQsZUFBQztDQXRERCxBQXNEQyxDQXRENkIsRUFBRSxDQUFDLFNBQVMsR0FzRHpDO0FBdERZLDRCQUFRIiwiZmlsZSI6IiIsInNvdXJjZVJvb3QiOiIvIiwic291cmNlc0NvbnRlbnQiOlsiXHJcblxyXG5pbXBvcnQgTG9vcExpc3QgZnJvbSAnLi4vU2NyaXB0L0xvb3BMaXN0JztcclxuaW1wb3J0IHsgSURhdGEgfSBmcm9tICcuL1Rlc3RTaG93Tm9kZSc7XHJcbmNvbnN0IHsgY2NjbGFzcywgcHJvcGVydHkgfSA9IGNjLl9kZWNvcmF0b3I7XHJcblxyXG5AY2NjbGFzc1xyXG5leHBvcnQgY2xhc3MgVGVzdExvb3AgZXh0ZW5kcyBjYy5Db21wb25lbnQge1xyXG4gICAgLyoq5YiG5bGC5riy5p+T6IqC54K5ICovXHJcbiAgICBAcHJvcGVydHkoY2MuTm9kZSlcclxuICAgIHB1YmxpYyByZW5kZUxheWVyOiBjYy5Ob2RlID0gbnVsbDtcclxuICAgIC8qKuaYvuekuuiKgueCuemihOWItuS7tiAqL1xyXG4gICAgQHByb3BlcnR5KGNjLlNjcm9sbFZpZXcpXHJcbiAgICBwdWJsaWMgc2Nyb2xsVmlldzogY2MuU2Nyb2xsVmlldyA9IG51bGw7XHJcbiAgICAvKirmmL7npLroioLngrnpooTliLbku7YgKi9cclxuICAgIEBwcm9wZXJ0eShjYy5QcmVmYWIpXHJcbiAgICBwdWJsaWMgc2hvd1ByZWZhYjogY2MuUHJlZmFiID0gbnVsbDtcclxuXHJcbiAgICBzdGFydCgpIHtcclxuICAgICAgICAvL+a1i+ivleaoquWQkeWuvemrmOaVsOaNrlxyXG4gICAgICAgIC8qIGxldCBiYXNlV2lkdGggPSA4MDtcclxuICAgICAgICBsZXQgY2hhbmdlV2lkdGggPSAyMDtcclxuICAgICAgICBsZXQgYmFzZUhlaWdodCA9IDYwMDtcclxuICAgICAgICBsZXQgY2hhbmdlSGVpZ2h0ID0gMTUwO1xyXG4gICAgICAgIGxldCBhbmNob3IgPSBjYy52MigwLjUsIDAuNSkgKi9cclxuXHJcbiAgICAgICAgLy/mtYvor5XnurXlkJHlrr3pq5jmlbDmja5cclxuICAgICAgICBsZXQgYmFzZVdpZHRoID0gNjAwO1xyXG4gICAgICAgIGxldCBjaGFuZ2VXaWR0aCA9IDE1MDtcclxuICAgICAgICBsZXQgYmFzZUhlaWdodCA9IDgwO1xyXG4gICAgICAgIGxldCBjaGFuZ2VIZWlnaHQgPSAyMDtcclxuICAgICAgICBsZXQgYW5jaG9yID0gY2MudjIoMC41LCAwLjUpO1xyXG5cclxuICAgICAgICBsZXQgZGF0YTogSURhdGFbXSA9IFtdO1xyXG4gICAgICAgIGZvciAobGV0IGkgPSAwLCBsZW4gPSAzMDsgaSA8IGxlbjsgKytpKSB7XHJcbiAgICAgICAgICAgIGRhdGEucHVzaCh7XHJcbiAgICAgICAgICAgICAgICBpbmRleDogaSwgdGV4dDogXCLlhoXlrrlcIiArIGlcclxuICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgfVxyXG4gICAgICAgIExvb3BMaXN0LmluczxJRGF0YT4oXCJUZXN0XCIpLmluaXQodGhpcy5zY3JvbGxWaWV3LCB0aGlzLnJlbmRlTGF5ZXIsIDE4KTtcclxuICAgICAgICBMb29wTGlzdC5pbnM8SURhdGE+KFwiVGVzdFwiKS5pbml0RGF0YShkYXRhLCB0aGlzLnNob3dQcmVmYWIsIGNjLnNpemUoYmFzZVdpZHRoLCBiYXNlSGVpZ2h0KSwgYW5jaG9yKTtcclxuXHJcbiAgICAgICAgLyogLy/mtYvor5Xmj5LlhaXmlbDmja5cclxuICAgICAgICB0aGlzLnNjaGVkdWxlT25jZSgoKSA9PiB7XHJcbiAgICAgICAgICAgIExvb3BMaXN0LmluczxJRGF0YT4oXCJUZXN0XCIpLmluc2VydERhdGEoeyBpbmRleDogMSwgdGV4dDogXCLmiJHmmK/mj5LlhaUxXCIsIHNpemU6IGNjLnNpemUoYmFzZVdpZHRoLCBiYXNlSGVpZ2h0KSB9LCAxKTtcclxuICAgICAgICB9LCAzKVxyXG5cclxuICAgICAgICAvL+a1i+ivleWOi+WFpeaVsOaNrlxyXG4gICAgICAgIHRoaXMuc2NoZWR1bGVPbmNlKCgpID0+IHtcclxuICAgICAgICAgICAgTG9vcExpc3QuaW5zPElEYXRhPihcIlRlc3RcIikucHVzaERhdGFzKFtcclxuICAgICAgICAgICAgICAgIHsgaW5kZXg6IDEsIHRleHQ6IFwi5oiR5piv5Y6L5YWlMVwiLCBzaXplOiBjYy5zaXplKGJhc2VXaWR0aCwgYmFzZUhlaWdodCkgfSxcclxuICAgICAgICAgICAgICAgIHsgaW5kZXg6IDIsIHRleHQ6IFwi5oiR5piv5Y6L5YWlMlwiLCBzaXplOiBjYy5zaXplKGJhc2VXaWR0aCwgYmFzZUhlaWdodCkgfSxcclxuICAgICAgICAgICAgICAgIHsgaW5kZXg6IDMsIHRleHQ6IFwi5oiR5piv5Y6L5YWlM1wiLCBzaXplOiBjYy5zaXplKGJhc2VXaWR0aCwgYmFzZUhlaWdodCkgfSxcclxuICAgICAgICAgICAgXSk7XHJcbiAgICAgICAgfSwgNClcclxuXHJcbiAgICAgICAgLy/mtYvor5XljovlhaXmlbDmja5cclxuICAgICAgICB0aGlzLnNjaGVkdWxlT25jZSgoKSA9PiB7XHJcbiAgICAgICAgICAgIExvb3BMaXN0LmluczxJRGF0YT4oXCJUZXN0XCIpLnJlbW92ZURhdGEoMSk7XHJcbiAgICAgICAgfSwgNSkgKi9cclxuICAgIH1cclxufVxyXG5cclxuXHJcbiJdfQ== +//------QC-SOURCE-SPLIT------ + + (function() { + var nodeEnv = typeof require !== 'undefined' && typeof process !== 'undefined'; + var __module = nodeEnv ? module : {exports:{}}; + var __filename = 'preview-scripts/assets/Script/RenderReactiveHandler.js'; + var __require = nodeEnv ? function (request) { + return cc.require(request); + } : function (request) { + return __quick_compile_project__.require(request, __filename); + }; + function __define (exports, require, module) { + if (!nodeEnv) {__quick_compile_project__.registerModule(__filename, module);}"use strict"; +cc._RF.push(module, 'd38d0Ja+51M8L8TYTQwae9Q', 'RenderReactiveHandler'); +// Script/RenderReactiveHandler.ts + +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.RenderReactiveHandler = exports.hasChanged = exports.hasOwn = exports.isObject = void 0; +function isObject(value) { + return value !== null && typeof value === 'object'; +} +exports.isObject = isObject; +var hasOwnProperty = Object.prototype.hasOwnProperty; +/** 是否自身上存在属性 */ +function hasOwn(val, key) { + if (val instanceof cc.Component) { + return key in val; + } + return hasOwnProperty.call(val, key); +} +exports.hasOwn = hasOwn; +/** 比较值是否变化了,考虑NaN;如果是对象直接认为改变了 */ +function hasChanged(value, oldValue) { + var type = typeof value; + if (type === "object") + return true; + return !Object.is(value, oldValue); +} +exports.hasChanged = hasChanged; +var RenderReactiveHandler = /** @class */ (function () { + function RenderReactiveHandler(reactiveTarget) { + /**需要作出反应的对象 */ + this.reactiveTarget = null; + this.reactiveTarget = reactiveTarget; + } + /** + * + * @param target 被代理的对象 + * @param prop 被代理的对象的属性名 + * @param value 被代理的对象的属性值 + * @param receiver 代理对象 + * @returns + */ + RenderReactiveHandler.prototype.set = function (target, prop, value, receiver) { + var oldValue = Reflect.get(target, prop); + var hadKey = hasOwn(target, prop); + var result = Reflect.set(target, prop, value); + if (!hadKey || hasChanged(value, oldValue)) { + if (prop == "angle" || prop == 'scale' || prop == "position" || prop == "_renderFlag") + return; + if (prop == 'activeInHierarchy') { + console.warn(target); + } + // 属性变化 + this.reactiveTarget && (Reflect.set(this.reactiveTarget, prop, value)); + } + return result; + }; + RenderReactiveHandler.prototype.apply = function () { + console.warn(arguments); + }; + RenderReactiveHandler.prototype.get = function (target, prop, receiver) { + if (prop === '__raw__') { + return target; + } + else if (prop === '__isReactive__') { + return true; + } + var rawValue = Reflect.get(target, prop); + return rawValue; + }; + RenderReactiveHandler.prototype.deleteProperty = function (target, prop) { + var hadKey = hasOwn(target, prop); + var oldValue = target[prop]; + var result = Reflect.deleteProperty(target, prop); + if (result && hadKey) { + //trigger(target, prop, void 0, oldValue); + } + return result; + }; + return RenderReactiveHandler; +}()); +exports.RenderReactiveHandler = RenderReactiveHandler; + +cc._RF.pop(); + } + if (nodeEnv) { + __define(__module.exports, __require, __module); + } + else { + __quick_compile_project__.registerModuleFunc(__filename, function () { + __define(__module.exports, __require, __module); + }); + } + })(); +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImFzc2V0c1xcU2NyaXB0XFxSZW5kZXJSZWFjdGl2ZUhhbmRsZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7O0FBQ0EsU0FBZ0IsUUFBUSxDQUFDLEtBQWM7SUFDbkMsT0FBTyxLQUFLLEtBQUssSUFBSSxJQUFJLE9BQU8sS0FBSyxLQUFLLFFBQVEsQ0FBQztBQUN2RCxDQUFDO0FBRkQsNEJBRUM7QUFFRCxJQUFNLGNBQWMsR0FBRyxNQUFNLENBQUMsU0FBUyxDQUFDLGNBQWMsQ0FBQTtBQUN0RCxnQkFBZ0I7QUFDaEIsU0FBZ0IsTUFBTSxDQUFDLEdBQVcsRUFBRSxHQUE2QjtJQUM3RCxJQUFJLEdBQUcsWUFBWSxFQUFFLENBQUMsU0FBUyxFQUFFO1FBQzdCLE9BQU8sR0FBRyxJQUFJLEdBQUcsQ0FBQztLQUNyQjtJQUNELE9BQU8sY0FBYyxDQUFDLElBQUksQ0FBQyxHQUFHLEVBQUUsR0FBRyxDQUFDLENBQUM7QUFDekMsQ0FBQztBQUxELHdCQUtDO0FBRUQsa0NBQWtDO0FBQ2xDLFNBQWdCLFVBQVUsQ0FBQyxLQUFVLEVBQUUsUUFBYTtJQUNoRCxJQUFJLElBQUksR0FBRyxPQUFPLEtBQUssQ0FBQztJQUN4QixJQUFJLElBQUksS0FBSyxRQUFRO1FBQUUsT0FBTyxJQUFJLENBQUM7SUFDbkMsT0FBTyxDQUFDLE1BQU0sQ0FBQyxFQUFFLENBQUMsS0FBSyxFQUFFLFFBQVEsQ0FBQyxDQUFDO0FBQ3ZDLENBQUM7QUFKRCxnQ0FJQztBQUdEO0lBQ0ksK0JBQVksY0FBdUI7UUFHbkMsZUFBZTtRQUNQLG1CQUFjLEdBQVcsSUFBSSxDQUFDO1FBSGxDLElBQUksQ0FBQyxjQUFjLEdBQUcsY0FBYyxDQUFDO0lBQ3pDLENBQUM7SUFJRDs7Ozs7OztPQU9HO0lBQ0gsbUNBQUcsR0FBSCxVQUFJLE1BQWMsRUFBRSxJQUFxQixFQUFFLEtBQVUsRUFBRSxRQUFhO1FBRWhFLElBQUksUUFBUSxHQUFHLE9BQU8sQ0FBQyxHQUFHLENBQUMsTUFBTSxFQUFFLElBQUksQ0FBQyxDQUFDO1FBQ3pDLElBQUksTUFBTSxHQUFHLE1BQU0sQ0FBQyxNQUFNLEVBQUUsSUFBSSxDQUFDLENBQUM7UUFDbEMsSUFBSSxNQUFNLEdBQUcsT0FBTyxDQUFDLEdBQUcsQ0FBQyxNQUFNLEVBQUUsSUFBSSxFQUFFLEtBQUssQ0FBQyxDQUFDO1FBQzlDLElBQUksQ0FBQyxNQUFNLElBQUksVUFBVSxDQUFDLEtBQUssRUFBRSxRQUFRLENBQUMsRUFBRTtZQUN4QyxJQUFJLElBQUksSUFBSSxPQUFPLElBQUksSUFBSSxJQUFJLE9BQU8sSUFBSSxJQUFJLElBQUksVUFBVSxJQUFJLElBQUksSUFBSSxhQUFhO2dCQUFFLE9BQU87WUFDOUYsSUFBSSxJQUFJLElBQUksbUJBQW1CLEVBQUU7Z0JBQzdCLE9BQU8sQ0FBQyxJQUFJLENBQUMsTUFBTSxDQUFDLENBQUM7YUFDeEI7WUFDRCxPQUFPO1lBQ1AsSUFBSSxDQUFDLGNBQWMsSUFBSSxDQUFDLE9BQU8sQ0FBQyxHQUFHLENBQUMsSUFBSSxDQUFDLGNBQWMsRUFBRSxJQUFJLEVBQUUsS0FBSyxDQUFDLENBQUMsQ0FBQztTQUMxRTtRQUVELE9BQU8sTUFBTSxDQUFBO0lBQ2pCLENBQUM7SUFFRCxxQ0FBSyxHQUFMO1FBQ0ksT0FBTyxDQUFDLElBQUksQ0FBQyxTQUFTLENBQUMsQ0FBQTtJQUMzQixDQUFDO0lBRUQsbUNBQUcsR0FBSCxVQUFJLE1BQWMsRUFBRSxJQUFxQixFQUFFLFFBQWE7UUFFcEQsSUFBSSxJQUFJLEtBQUssU0FBUyxFQUFFO1lBQ3BCLE9BQU8sTUFBTSxDQUFDO1NBQ2pCO2FBQ0ksSUFBSSxJQUFJLEtBQUssZ0JBQWdCLEVBQUU7WUFDaEMsT0FBTyxJQUFJLENBQUM7U0FDZjtRQUNELElBQUksUUFBUSxHQUFHLE9BQU8sQ0FBQyxHQUFHLENBQUMsTUFBTSxFQUFFLElBQUksQ0FBQyxDQUFDO1FBQ3pDLE9BQU8sUUFBUSxDQUFDO0lBQ3BCLENBQUM7SUFFRCw4Q0FBYyxHQUFkLFVBQWUsTUFBYyxFQUFFLElBQXFCO1FBQ2hELElBQUksTUFBTSxHQUFHLE1BQU0sQ0FBQyxNQUFNLEVBQUUsSUFBSSxDQUFDLENBQUM7UUFDbEMsSUFBSSxRQUFRLEdBQUcsTUFBTSxDQUFDLElBQUksQ0FBQyxDQUFDO1FBQzVCLElBQUksTUFBTSxHQUFHLE9BQU8sQ0FBQyxjQUFjLENBQUMsTUFBTSxFQUFFLElBQUksQ0FBQyxDQUFDO1FBQ2xELElBQUksTUFBTSxJQUFJLE1BQU0sRUFBRTtZQUNsQiwwQ0FBMEM7U0FDN0M7UUFFRCxPQUFPLE1BQU0sQ0FBQztJQUNsQixDQUFDO0lBQ0wsNEJBQUM7QUFBRCxDQTFEQSxBQTBEQyxJQUFBO0FBMURZLHNEQUFxQiIsImZpbGUiOiIiLCJzb3VyY2VSb290IjoiLyIsInNvdXJjZXNDb250ZW50IjpbIlxyXG5leHBvcnQgZnVuY3Rpb24gaXNPYmplY3QodmFsdWU6IHVua25vd24pOiB2YWx1ZSBpcyBSZWNvcmQ8YW55LCBhbnk+IHtcclxuICAgIHJldHVybiB2YWx1ZSAhPT0gbnVsbCAmJiB0eXBlb2YgdmFsdWUgPT09ICdvYmplY3QnO1xyXG59XHJcblxyXG5jb25zdCBoYXNPd25Qcm9wZXJ0eSA9IE9iamVjdC5wcm90b3R5cGUuaGFzT3duUHJvcGVydHlcclxuLyoqIOaYr+WQpuiHqui6q+S4iuWtmOWcqOWxnuaApyAqL1xyXG5leHBvcnQgZnVuY3Rpb24gaGFzT3duKHZhbDogb2JqZWN0LCBrZXk6IHN0cmluZyB8IG51bWJlciB8IHN5bWJvbCk6IGtleSBpcyBrZXlvZiB0eXBlb2YgdmFsIHtcclxuICAgIGlmICh2YWwgaW5zdGFuY2VvZiBjYy5Db21wb25lbnQpIHtcclxuICAgICAgICByZXR1cm4ga2V5IGluIHZhbDtcclxuICAgIH1cclxuICAgIHJldHVybiBoYXNPd25Qcm9wZXJ0eS5jYWxsKHZhbCwga2V5KTtcclxufVxyXG5cclxuLyoqIOavlOi+g+WAvOaYr+WQpuWPmOWMluS6hu+8jOiAg+iZkU5hTu+8m+WmguaenOaYr+WvueixoeebtOaOpeiupOS4uuaUueWPmOS6hiAqL1xyXG5leHBvcnQgZnVuY3Rpb24gaGFzQ2hhbmdlZCh2YWx1ZTogYW55LCBvbGRWYWx1ZTogYW55KTogYm9vbGVhbiB7XHJcbiAgICBsZXQgdHlwZSA9IHR5cGVvZiB2YWx1ZTtcclxuICAgIGlmICh0eXBlID09PSBcIm9iamVjdFwiKSByZXR1cm4gdHJ1ZTtcclxuICAgIHJldHVybiAhT2JqZWN0LmlzKHZhbHVlLCBvbGRWYWx1ZSk7XHJcbn1cclxuXHJcblxyXG5leHBvcnQgY2xhc3MgUmVuZGVyUmVhY3RpdmVIYW5kbGVyIHtcclxuICAgIGNvbnN0cnVjdG9yKHJlYWN0aXZlVGFyZ2V0Pzogb2JqZWN0KSB7XHJcbiAgICAgICAgdGhpcy5yZWFjdGl2ZVRhcmdldCA9IHJlYWN0aXZlVGFyZ2V0O1xyXG4gICAgfVxyXG4gICAgLyoq6ZyA6KaB5L2c5Ye65Y+N5bqU55qE5a+56LGhICovXHJcbiAgICBwcml2YXRlIHJlYWN0aXZlVGFyZ2V0OiBvYmplY3QgPSBudWxsO1xyXG5cclxuICAgIC8qKlxyXG4gICAgICogXHJcbiAgICAgKiBAcGFyYW0gdGFyZ2V0IOiiq+S7o+eQhueahOWvueixoVxyXG4gICAgICogQHBhcmFtIHByb3Ag6KKr5Luj55CG55qE5a+56LGh55qE5bGe5oCn5ZCNXHJcbiAgICAgKiBAcGFyYW0gdmFsdWUg6KKr5Luj55CG55qE5a+56LGh55qE5bGe5oCn5YC8XHJcbiAgICAgKiBAcGFyYW0gcmVjZWl2ZXIg5Luj55CG5a+56LGhXHJcbiAgICAgKiBAcmV0dXJucyBcclxuICAgICAqL1xyXG4gICAgc2V0KHRhcmdldDogb2JqZWN0LCBwcm9wOiBzdHJpbmcgfCBzeW1ib2wsIHZhbHVlOiBhbnksIHJlY2VpdmVyOiBhbnkpOiBib29sZWFuIHtcclxuXHJcbiAgICAgICAgbGV0IG9sZFZhbHVlID0gUmVmbGVjdC5nZXQodGFyZ2V0LCBwcm9wKTtcclxuICAgICAgICBsZXQgaGFkS2V5ID0gaGFzT3duKHRhcmdldCwgcHJvcCk7XHJcbiAgICAgICAgbGV0IHJlc3VsdCA9IFJlZmxlY3Quc2V0KHRhcmdldCwgcHJvcCwgdmFsdWUpO1xyXG4gICAgICAgIGlmICghaGFkS2V5IHx8IGhhc0NoYW5nZWQodmFsdWUsIG9sZFZhbHVlKSkge1xyXG4gICAgICAgICAgICBpZiAocHJvcCA9PSBcImFuZ2xlXCIgfHwgcHJvcCA9PSAnc2NhbGUnIHx8IHByb3AgPT0gXCJwb3NpdGlvblwiIHx8IHByb3AgPT0gXCJfcmVuZGVyRmxhZ1wiKSByZXR1cm47XHJcbiAgICAgICAgICAgIGlmIChwcm9wID09ICdhY3RpdmVJbkhpZXJhcmNoeScpIHtcclxuICAgICAgICAgICAgICAgIGNvbnNvbGUud2Fybih0YXJnZXQpO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIC8vIOWxnuaAp+WPmOWMllxyXG4gICAgICAgICAgICB0aGlzLnJlYWN0aXZlVGFyZ2V0ICYmIChSZWZsZWN0LnNldCh0aGlzLnJlYWN0aXZlVGFyZ2V0LCBwcm9wLCB2YWx1ZSkpO1xyXG4gICAgICAgIH1cclxuXHJcbiAgICAgICAgcmV0dXJuIHJlc3VsdFxyXG4gICAgfVxyXG5cclxuICAgIGFwcGx5KCkge1xyXG4gICAgICAgIGNvbnNvbGUud2Fybihhcmd1bWVudHMpXHJcbiAgICB9XHJcblxyXG4gICAgZ2V0KHRhcmdldDogb2JqZWN0LCBwcm9wOiBzdHJpbmcgfCBzeW1ib2wsIHJlY2VpdmVyOiBhbnkpOiBhbnkge1xyXG5cclxuICAgICAgICBpZiAocHJvcCA9PT0gJ19fcmF3X18nKSB7XHJcbiAgICAgICAgICAgIHJldHVybiB0YXJnZXQ7XHJcbiAgICAgICAgfVxyXG4gICAgICAgIGVsc2UgaWYgKHByb3AgPT09ICdfX2lzUmVhY3RpdmVfXycpIHtcclxuICAgICAgICAgICAgcmV0dXJuIHRydWU7XHJcbiAgICAgICAgfVxyXG4gICAgICAgIGxldCByYXdWYWx1ZSA9IFJlZmxlY3QuZ2V0KHRhcmdldCwgcHJvcCk7XHJcbiAgICAgICAgcmV0dXJuIHJhd1ZhbHVlO1xyXG4gICAgfVxyXG5cclxuICAgIGRlbGV0ZVByb3BlcnR5KHRhcmdldDogb2JqZWN0LCBwcm9wOiBzdHJpbmcgfCBzeW1ib2wpOiBib29sZWFuIHtcclxuICAgICAgICBsZXQgaGFkS2V5ID0gaGFzT3duKHRhcmdldCwgcHJvcCk7XHJcbiAgICAgICAgbGV0IG9sZFZhbHVlID0gdGFyZ2V0W3Byb3BdO1xyXG4gICAgICAgIGxldCByZXN1bHQgPSBSZWZsZWN0LmRlbGV0ZVByb3BlcnR5KHRhcmdldCwgcHJvcCk7XHJcbiAgICAgICAgaWYgKHJlc3VsdCAmJiBoYWRLZXkpIHtcclxuICAgICAgICAgICAgLy90cmlnZ2VyKHRhcmdldCwgcHJvcCwgdm9pZCAwLCBvbGRWYWx1ZSk7XHJcbiAgICAgICAgfVxyXG5cclxuICAgICAgICByZXR1cm4gcmVzdWx0O1xyXG4gICAgfVxyXG59XHJcbiJdfQ== +//------QC-SOURCE-SPLIT------ + + (function() { + var nodeEnv = typeof require !== 'undefined' && typeof process !== 'undefined'; + var __module = nodeEnv ? module : {exports:{}}; + var __filename = 'preview-scripts/assets/Script/LoopList.js'; + var __require = nodeEnv ? function (request) { + return cc.require(request); + } : function (request) { + return __quick_compile_project__.require(request, __filename); + }; + function __define (exports, require, module) { + if (!nodeEnv) {__quick_compile_project__.registerModule(__filename, module);}"use strict"; +cc._RF.push(module, 'b4ec1SU3/dIdZG3ODfwZKk3', 'LoopList'); +// Script/LoopList.ts + +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ItemCell = exports.ShowNode = void 0; +var RenderAlternative_1 = require("./RenderAlternative"); +var ShowNode = /** @class */ (function (_super) { + __extends(ShowNode, _super); + function ShowNode() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /**是否初始化过代理组建 */ + _this.hasInit = false; + return _this; + } + /**初始化 */ + ShowNode.prototype.init = function (cell, data, renderLayer) { + this.cell = cell; + this.data = data; + if (this.renderLayer != renderLayer) { + this.renderLayer = renderLayer; + renderLayer && this.initRenders(); + } + this.initShow(); + }; + /**初始化操作 */ + ShowNode.prototype.initShow = function () { }; + /**被回收,应该做一些释放的操作 */ + ShowNode.prototype.onRecircle = function () { }; + /** + * 在特定时间内进行大小变化 + * @param targetSize + * @param time + */ + ShowNode.prototype.resize = function (targetSize, time) { + if (time === void 0) { time = 0.3; } + this.cell.resize(targetSize, time); + }; + /** + * 处理分层代理渲染 + */ + ShowNode.prototype.initRenders = function () { + if (!this.hasInit && this.renderLayer) { + var propMap = new WeakMap(); + var keys = Object.keys(this); + for (var i = 0, len = keys.length; i < len; ++i) { + var value = this[keys[i]]; + var alternative = null; + if (value instanceof cc.Node) { + alternative = value.getComponent(RenderAlternative_1.default); + if (alternative) { + alternative.init(this.renderLayer); + } + } + else if (value instanceof cc.RenderComponent) { + alternative = value.getComponent(RenderAlternative_1.default); + if (alternative) { + this[keys[i]] = alternative.init(this.renderLayer); + } + } + alternative && propMap.set(alternative, true); + } + this.dealChilrenAlternative(this.node, propMap, 0, 0); + this.hasInit = true; + } + }; + /** + * 处理子节点代理 + * @param node + * @param propMap 记录脚本已经处理过的属性代理 + * @param parentSindex 父节点的所在的顺序 + * @param depth 深度 + */ + ShowNode.prototype.dealChilrenAlternative = function (node, propMap, parentSindex, depth) { + var _a; + for (var i = 0, len = node.children.length; i < len; i++) { + var children = node.children[i]; + var alternative = (_a = children.getComponent(cc.RenderComponent)) === null || _a === void 0 ? void 0 : _a.getComponent(RenderAlternative_1.default); + var sIndex = parentSindex + (i * Math.pow(0.1, depth)); + if (alternative) { + if ((!propMap.has(alternative) || !propMap.get(alternative))) { + alternative.init(this.renderLayer); + } + alternative.sIndex = sIndex; + } + this.dealChilrenAlternative(children, propMap, sIndex, depth + 1); + } + }; + return ShowNode; +}(cc.Component)); +exports.ShowNode = ShowNode; +var ItemCell = /** @class */ (function () { + /** + * 构造函数 + * @param node + * @param looplist + */ + function ItemCell(node, looplist) { + /**持有cell的list */ + this.looplist = null; + /**位置节点 */ + this.node = null; + /**显示节点 */ + this.showNode = null; + /**尺寸 */ + this.size = null; + /**数据下标 */ + this.dataIndex = null; + /**cell下标 */ + this.cellIndex = null; + /**数据 */ + this.data = null; + this.node = node; + this.looplist = looplist; + } + /** + * 初始化 + * @param data + * @param size + * @param dataIndex + * @param cellIndex + * @param looplist + */ + ItemCell.prototype.init = function (data, size, dataIndex, cellIndex, looplist) { + cc.Tween.stopAllByTarget(this.node); + this.cellIndex = cellIndex; + this.dataIndex = dataIndex; + this.looplist = looplist; + this.node.width = size.width; + this.node.height = size.height; + this.data = data; + this.size = size; + }; + /** + * 重置大小 + * @param size + */ + ItemCell.prototype.resize = function (size, time) { + var _this = this; + var nodeSides = getNodeBorder(this, [true, true, true, true]); + var changeSize = cc.size(size.width - this.size.width, size.height - this.size.height); + this.size = size; + this.looplist.dealChangeSize(this, nodeSides, changeSize, time).then(function () { + _this.node.width = size.width; + _this.node.height = size.height; + _this.looplist.updateNodes(); + }); + }; + /** + * 更新节点显示 + * @param isShow 是否显示 + * @param prefab 需要显示的节点的预制件(也可以是节点,或者预制件url,生成方式自由改动) + * @param cacheNode 对象池中的显示节点 + * @param renderLayer 分层节点 + */ + ItemCell.prototype.updateShow = function (isShow, prefab, cacheNode, renderLayer) { + if (isShow) { + //当前没有显示节点 + if (!this.showNode) { + //如果是临时对象池还有节点则重用 + if (cacheNode) { + this.showNode = cacheNode; + } + else { //否则使用传入的预制件进行生成 + this.showNode = cc.instantiate(prefab).getComponent(ShowNode); + } + this.showNode.node.setParent(this.node); + this.showNode.node.position = cc.v3(); + this.updateShowNode(renderLayer); + } + } + }; + /** + * 更新showNode节点显示 + * @param renderLayer + */ + ItemCell.prototype.updateShowNode = function (renderLayer) { + //当前有显示节点 + if (this.showNode) { + this.showNode.init(this, this.data, renderLayer); + } + }; + Object.defineProperty(ItemCell.prototype, "hasNoNode", { + get: function () { + return !this.showNode; + }, + enumerable: false, + configurable: true + }); + ItemCell.prototype.recircle = function () { + if (this.showNode) { + var node = this.showNode; + this.showNode.getComponent(ShowNode).onRecircle(); + this.showNode.node.removeFromParent(false); + this.showNode = null; + return node; + } + }; + ItemCell.prototype.destroy = function () { + this.node.destroy(); + this.node = null; + this.looplist = null; + }; + /** + * 失去 + * @returns + */ + ItemCell.prototype.lostShowNode = function () { + if (this.showNode) { + var node = this.showNode; + this.showNode.node.removeFromParent(false); + this.showNode = null; + return node; + } + }; + /** + * 获取显示节点 + * @param showNode + */ + ItemCell.prototype.getShowNode = function (showNode) { + this.showNode = showNode; + showNode.node.setParent(this.node); + this.showNode.cell = this; + }; + return ItemCell; +}()); +exports.ItemCell = ItemCell; +/** + * 目前列表注意事项 + * 1.开启cellMaxNum后不能一行多列或者一列多行,只能单行或者单列 + */ +var LoopList = /** @class */ (function () { + function LoopList() { + /**分层节点(只有在showNode中挂载了RenderAlternative才能起作用) */ + this.renderLayer = null; + /**滚动组件 */ + this.scrollView = null; + /**cell节点最大数量 */ + this.cellMaxNum = null; + /**当前起点 */ + this.curStartIndex = null; + /**数据 */ + this.datas = []; + /**item节点们 */ + this.itemCells = []; + /**预制件 */ + this.prefab = null; + /**显示节点的池子 */ + this.showNodePool = []; + /**边缘数据 */ + this.viewSides = {}; + /**上一帧滚动容器的坐标 */ + this.lastPos = null; + /**刷新显示的间隔次数 */ + this.updateInv = 0; + /**循环切换的最后一次时间 */ + this.lastChange = 0; + /**通用尺寸 */ + this.size = null; + /**通用锚点 */ + this.anchor = null; + } + LoopList.ins = function (listName) { + if (!this.insMap.has(listName)) { + this.insMap.set(listName, new LoopList()); + } + return this.insMap.get(listName); + }; + LoopList.prototype.onLoad = function () { + this.updateBorder(); + }; + /** + * 更新边界 + */ + LoopList.prototype.updateBorder = function () { + var _this = this; + var view = this.scrollView.node.getChildByName("view"); + view.anchorX = this.scrollView.content.anchorX; + view.anchorY = this.scrollView.content.anchorY; + //修改锚点之后下一帧世界坐标才会更新,没办法只能等一帧了 + return new Promise(function (resolve, reject) { + requestAnimationFrame(function () { + var wpos = getNodeWPos(view); + //显示区域左边缘 + var leftSide = wpos.x - (view.width * view.anchorX); + //显示区域右边缘 + var rightSide = wpos.x + (view.width * (1 - view.anchorX)); + //显示区域下边缘 + var bottomSide = wpos.y - (view.height * view.anchorY); + //显示区域上边缘 + var topSide = wpos.y + (view.height * (1 - view.anchorY)); + _this.viewSides = { + leftSide: leftSide, rightSide: rightSide, bottomSide: bottomSide, topSide: topSide, + size: cc.size(view.width, view.height) + }; + _this.scrollView.content.setPosition(cc.v3(0, 0)); + resolve(); + }); + }); + }; + /** + * 初始化滚动列表 + * @param scrollView + * @param cellMaxNum cell节点的最大数量,设置成null则不启用,启用的话,要设置成(可视窗刚好能显示的最大数量*2)+2,假设最多能看到10个节点,那么设置成22 + * @param renderLayer 渲染分层的父节点,如果传入则可以配合showNode上的renderAlternative来进行渲染分层 + */ + LoopList.prototype.init = function (scrollView, renderLayer, cellMaxNum) { + return __awaiter(this, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + cellMaxNum && (this.cellMaxNum = cellMaxNum); + renderLayer && (this.renderLayer = renderLayer); + this.scrollView = scrollView; + return [4 /*yield*/, this.updateBorder()]; + case 1: + _a.sent(); + this.scrollView.node.on("scrolling", this.scrollingListener, this); + return [2 /*return*/]; + } + }); + }); + }; + /**滚动监听 */ + LoopList.prototype.scrollingListener = function () { + this.updateInv--; + if (this.updateInv <= 0) { + this.updateInv = 2; + var showCells = this.updateNodes(); + if (!this.cellMaxNum) { + return; + } + if (!this.lastPos) { + this.lastPos = this.scrollView.content.position.clone(); + } + else { + var offset = this.scrollView.content.position.clone().sub(this.lastPos); + this.lastPos = this.scrollView.content.position.clone(); + var now = cc.sys.now(); + if (!this.lastChange || (now - this.lastChange) > 100) { + this.lastChange = now; + this.dealLoopList(offset, showCells); + } + } + } + }; + /** + * 初始化 + * @param data 数据组 + * @param prefab 预制件 + * @param size 通用尺寸 + * @param anchor cell的锚点 + */ + LoopList.prototype.initData = function (data, prefab, size, anchor) { + if (anchor === void 0) { anchor = cc.v2(0.5, 0.5); } + this.datas = data; + this.size = size; + this.anchor = anchor; + this.prefab = prefab; + var len = this.cellMaxNum ? this.cellMaxNum : data.length; + this.curStartIndex = 0; + for (var i = 0; i < len; ++i) { + var itemCell = this.itemCells[i]; + if (!itemCell) { + var node = new cc.Node('LoopListCell'); + itemCell = this.itemCells[i] = new ItemCell(node, this); + node.setAnchorPoint(anchor); + node.setParent(this.scrollView.content); + } + var data_1 = this.datas[this.curStartIndex + i]; + var cellSize = data_1.size ? data_1.size : size; + itemCell.init(data_1, cellSize, this.curStartIndex + i, i, this); + } + for (var i = data.length, len_1 = this.itemCells.length; i < len_1; ++i) { + this.recircleShowNode(this.itemCells[i].recircle()); + this.itemCells[i].destroy(); + this.itemCells[i] = null; + } + this.updateNodes(); + }; + /** + * 压入新的数据 + * @param datas + */ + LoopList.prototype.pushDatas = function (datas) { + var length = this.datas.length; + for (var i = 0, len = datas.length; i < len; ++i) { + var data = datas[i]; + this.datas.push(data); + var index = length + i; + this.addNodeFromIndex(index); + } + }; + /** + * 插入新的数据 + * @param data + * @param insertIndex + */ + LoopList.prototype.insertData = function (data, insertIndex) { + if (this.datas.length >= insertIndex) { + this.datas.splice(insertIndex, 0, data); + this.addNodeFromIndex(insertIndex); + } + else { + this.pushDatas([data]); + } + }; + /** + * 移除对应数据 + * @param removeIndex + */ + LoopList.prototype.removeData = function (removeIndex) { + var _this = this; + if (this.datas.length >= removeIndex) { + this.datas.splice(removeIndex, 1); + if (this.cellMaxNum) { + var cellIndex_1 = removeIndex - this.curStartIndex; + //在使用范围内 + if (cellIndex_1 >= 0 && cellIndex_1 < this.cellMaxNum) { + var itemCell = this.itemCells[cellIndex_1]; + var nodeSides = getNodeBorder(itemCell, [true, true, true, true]); + var changeSize = cc.size(-itemCell.size.width, -itemCell.size.height); + itemCell.size = cc.size(0, 0); + this.dealChangeSize(itemCell, nodeSides, changeSize).then(function () { + //更新数据 + for (var i = cellIndex_1; i < _this.cellMaxNum; i++) { + var curDataIndex = _this.curStartIndex + i; + var curData = _this.datas[curDataIndex]; + var curCellSize = curData.size ? curData.size : _this.size; + _this.itemCells[i].init(curData, curCellSize, curDataIndex, i, _this); + _this.itemCells[i].updateShowNode(_this.renderLayer); + } + }); + } + } + else { + var itemCell_1 = this.itemCells.splice(removeIndex, 1)[0]; + var nodeSides = getNodeBorder(itemCell_1, [true, true, true, true]); + var changeSize = cc.size(-itemCell_1.size.width, -itemCell_1.size.height); + itemCell_1.size = cc.size(0, 0); + this.dealChangeSize(itemCell_1, nodeSides, changeSize).then(function () { + _this.recircleShowNode(itemCell_1.recircle()); + itemCell_1.node.destroy(); + }); + } + } + }; + /** + * 从某个数据开始更新 + * @param dataIndex + */ + LoopList.prototype.addNodeFromIndex = function (dataIndex) { + return __awaiter(this, void 0, void 0, function () { + var data, cellSize, cellIndex, i, curDataIndex, curData, curCellSize, nodeSides, itemCell_2, nodeSides_1, node, itemCell_3; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + data = this.datas[dataIndex]; + cellSize = data.size ? data.size : this.size; + if (!this.cellMaxNum) return [3 /*break*/, 1]; + cellIndex = dataIndex - this.curStartIndex; + //在使用范围内 + if (cellIndex >= 0 && cellIndex < this.cellMaxNum) { + //更新数据 + for (i = cellIndex; i < this.cellMaxNum; i++) { + curDataIndex = this.curStartIndex + i; + curData = this.datas[curDataIndex]; + curCellSize = curData.size ? curData.size : this.size; + this.itemCells[i].init(curData, curCellSize, curDataIndex, i, this); + this.itemCells[i].updateShowNode(this.renderLayer); + } + nodeSides = null; + itemCell_2 = this.itemCells[cellIndex]; + if (itemCell_2) { + nodeSides = getNodeBorder(itemCell_2, [true, true, true, true]); + itemCell_2.node.width = 0; + itemCell_2.node.height = 0; + this.dealChangeSize(itemCell_2, nodeSides, cellSize).then(function () { + itemCell_2.node.width = cellSize.width; + itemCell_2.node.height = cellSize.height; + }); + } + } + return [3 /*break*/, 4]; + case 1: + nodeSides_1 = null; + if (this.itemCells[dataIndex]) { + nodeSides_1 = getNodeBorder(this.itemCells[dataIndex], [true, true, true, true]); + } + node = new cc.Node('LoopListCell'); + node.setAnchorPoint(this.anchor); + node.setParent(this.scrollView.content); + node.setSiblingIndex(dataIndex); + itemCell_3 = new ItemCell(node, this); + this.itemCells.splice(dataIndex, 0, itemCell_3); + itemCell_3.init(data, cellSize, dataIndex, dataIndex, this); + if (!!nodeSides_1) return [3 /*break*/, 3]; + return [4 /*yield*/, new Promise(function (resolve, reject) { + requestAnimationFrame(function () { + nodeSides_1 = getNodeBorder(itemCell_3, [true, true, true, true]); + resolve(); + }); + })]; + case 2: + _a.sent(); + _a.label = 3; + case 3: + if (nodeSides_1) { + itemCell_3.node.width = 0; + itemCell_3.node.height = 0; + this.dealChangeSize(itemCell_3, nodeSides_1, cellSize).then(function () { + itemCell_3.node.width = cellSize.width; + itemCell_3.node.height = cellSize.height; + }); + } + this.dealItemShow(itemCell_3); + _a.label = 4; + case 4: return [2 /*return*/]; + } + }); + }); + }; + /** + * 处理列表的循环利用 + * @param offset + * @param dataIndexs + */ + LoopList.prototype.dealLoopList = function (offset, showCells) { + var startCell = showCells[0]; + var endCell = showCells[showCells.length - 1]; + if (this.scrollView.vertical) { + /**内容上移 */ + if (offset.y > 0) { + //已经到达最后倒数第二个节点并且还有数据 + if (this.scrollView.content.y >= (-this.itemCells[this.itemCells.length - 2].node.y - this.viewSides.size.height) && endCell.dataIndex < this.datas.length - 2) { + //显示开始数据下标(这里-1是想要顶部留一个itemcell做缓冲) + var showStart = startCell.dataIndex - 1; + //剩余可展示的数据量 + var leave = this.datas.length - showStart; + //计算应该从那个位置开始重新赋值,因为如果直接移动到最上方,数据量不够覆盖所有的cell + var cellStartIndex = Math.max(0, this.itemCells.length - leave); + //计算第一个cell的数据下标 + this.curStartIndex = showStart - cellStartIndex; + var cellTop = getNodeBorder(this.itemCells[startCell.cellIndex], [true]).topSide; + var contentHeight = 0; + var targetY = 0; + var jumpFirst = true; + var showIndex = 0; + for (var i = 0, len = this.itemCells.length; i < len; ++i) { + if (i >= cellStartIndex) { + //将当前已经显示的showNode节点直接重新设置到移动后的节点上 + if (showIndex < showCells.length && !jumpFirst) { + if (showIndex == 0) { + targetY = contentHeight; + } + var showNode = showCells[showIndex].lostShowNode(); + showIndex++; + this.itemCells[i].getShowNode(showNode); + } + jumpFirst = false; + } + var dataIndex = this.curStartIndex + i; + var data = this.datas[dataIndex]; + var cellSize = data.size ? data.size : this.size; + contentHeight += cellSize.height; + this.itemCells[i].init(data, cellSize, dataIndex, i, this); + } + //将content的位置移动到最上方并对齐移动前的状态 + var posY = targetY + (cellTop - this.viewSides.topSide); + this.scrollView.content.setPosition(cc.v3(this.scrollView.content.position.x, posY)); + this.scrollView.scrollToOffset(cc.v2(0, posY + endCell.size.height), 1); + this.lastPos = null; + } + } //内容下移 + else if (offset.y < 0) { + //已经到达第二个节点并且还有数据 + if (this.scrollView.content.y < (-this.itemCells[2].node.y) && startCell.dataIndex > 1) { + //展示的最后一个数据下表,+1是为了在底部预留一部分空间 + var showEndIndex = endCell.dataIndex + 1; + //计算应该从那个位置开始重新赋值,因为如果直接移动到最下方,数据量不够覆盖所有的cell + var cellEndIndex = Math.min(this.itemCells.length - 2, showEndIndex - 1); + //计算第一个cell的数据下标 + this.curStartIndex = Math.max(showEndIndex - (this.itemCells.length - 1), 0); + //将content的位置移动到最下方并对齐移动前的状态 + var cellTop = getNodeBorder(this.itemCells[startCell.cellIndex], [true]).topSide; + var contentHeight = 0; + var showIndex = showCells.length - 1; + for (var i = this.itemCells.length - 1; i >= 0; --i) { + if (i <= cellEndIndex) { + //将当前已经显示的showNode节点直接重新设置到移动后的节点上 + if (showIndex >= 0) { + var showNode = showCells[showIndex].lostShowNode(); + showIndex--; + this.itemCells[i].getShowNode(showNode); + } + else { + showIndex--; + } + } + var dataIndex = this.curStartIndex + i; + var data = this.datas[dataIndex]; + var cellSize = data.size ? data.size : this.size; + if (showIndex < -1) { + contentHeight += cellSize.height; + } + this.itemCells[i].init(data, cellSize, dataIndex, i, this); + } + //将content的位置移动到最下方并对齐移动前的状态 + var posY = contentHeight + (cellTop - this.viewSides.topSide); + this.scrollView.content.setPosition(cc.v3(this.scrollView.content.position.x, posY)); + this.scrollView.scrollToOffset(cc.v2(0, posY - startCell.size.height), 1); + this.lastPos = null; + } + } + } + else if (this.scrollView.horizontal) { + if (offset.x < 0) { + //已经到达最后倒数第二个节点并且还有数据 + if (this.scrollView.content.x <= (-(this.itemCells[this.itemCells.length - 2].node.x - this.viewSides.size.width)) && endCell.dataIndex < this.datas.length - 2) { + //显示开始数据下标(这里-1是想要左侧留一个itemcell做缓冲) + var showStart = startCell.dataIndex - 1; + //剩余可展示的数据量 + var leave = this.datas.length - showStart; + //计算应该从那个位置开始重新赋值,因为如果直接移动到最左侧,数据量不够覆盖所有的cell + var cellStartIndex = Math.max(0, this.itemCells.length - leave); + //计算第一个cell的数据下标 + this.curStartIndex = showStart - cellStartIndex; + var cellLeft = getNodeBorder(this.itemCells[startCell.cellIndex], [false, false, true]).leftSide; + var contentWidth = 0; + var targetX = 0; + var jumpFirst = true; + var showIndex = 0; + for (var i = 0, len = this.itemCells.length; i < len; ++i) { + if (i >= cellStartIndex) { + //将当前已经显示的showNode节点直接重新设置到移动后的节点上 + if (showIndex < showCells.length && !jumpFirst) { + if (showIndex == 0) { + targetX = contentWidth; + } + var showNode = showCells[showIndex].lostShowNode(); + showIndex++; + this.itemCells[i].getShowNode(showNode); + } + jumpFirst = false; + } + var dataIndex = this.curStartIndex + i; + var data = this.datas[dataIndex]; + var cellSize = data.size ? data.size : this.size; + contentWidth += cellSize.width; + this.itemCells[i].init(data, cellSize, dataIndex, i, this); + } + //将content的位置移动到最左侧并对齐移动前的状态 + var posX = (cellLeft - this.viewSides.leftSide) - targetX; + this.scrollView.content.setPosition(cc.v3(posX, this.scrollView.content.position.y)); + this.scrollView.scrollToOffset(cc.v2(-(posX - endCell.size.width), 0), 1); + this.lastPos = null; + } + } + else if (offset.x > 0) { + //已经到达第二个节点并且还有数据 + if (this.scrollView.content.x > (-this.itemCells[2].node.x) && startCell.dataIndex > 1) { + //展示的最后一个数据下表,+1是为了在右侧预留一部分空间 + var showEndIndex = endCell.dataIndex + 1; + //计算应该从那个位置开始重新赋值,因为如果直接移动到最右侧,数据量不够覆盖所有的cell + var cellEndIndex = Math.min(this.itemCells.length - 2, showEndIndex - 1); + //计算第一个cell的数据下标 + this.curStartIndex = Math.max(showEndIndex - (this.itemCells.length - 1), 0); + //将content的位置移动到最右侧并对齐移动前的状态 + var cellLeft = getNodeBorder(this.itemCells[startCell.cellIndex], [false, false, true]).leftSide; + var contentWidth = 0; + var showIndex = showCells.length - 1; + for (var i = this.itemCells.length - 1; i >= 0; --i) { + if (i <= cellEndIndex) { + //将当前已经显示的showNode节点直接重新设置到移动后的节点上 + if (showIndex >= 0) { + var showNode = showCells[showIndex].lostShowNode(); + showIndex--; + this.itemCells[i].getShowNode(showNode); + } + else { + showIndex--; + } + } + var dataIndex = this.curStartIndex + i; + var data = this.datas[dataIndex]; + var cellSize = data.size ? data.size : this.size; + if (showIndex < -1) { + contentWidth += cellSize.width; + } + this.itemCells[i].init(data, cellSize, dataIndex, i, this); + } + //将content的位置移动到最右侧并对齐移动前的状态 + var posX = (cellLeft - this.viewSides.leftSide) - contentWidth; + this.scrollView.content.setPosition(cc.v3(posX, this.scrollView.content.position.y)); + this.scrollView.scrollToOffset(cc.v2(-(posX + startCell.size.width), 0), 1); + this.lastPos = null; + } + } + } + }; + /**更新节点的显示 */ + LoopList.prototype.updateNodes = function () { + var showCells = []; + for (var i = 0, len = this.itemCells.length; i < len; ++i) { + var itemCell = this.itemCells[i]; + var isShow = this.dealItemShow(itemCell); + if (isShow) { + showCells.push(itemCell); + } + } + return showCells; + }; + /** + * 处理cell的显示隐藏 + * @param itemCell + */ + LoopList.prototype.dealItemShow = function (itemCell) { + if (itemCell) { + var isShow = this.checkInView(itemCell); + if (isShow) { + itemCell.hasNoNode && itemCell.updateShow(isShow, this.prefab, this.showNodePool.length > 0 ? this.showNodePool.pop() : null, this.renderLayer); + } + else { + !itemCell.hasNoNode && this.recircleShowNode(itemCell.recircle()); + } + return isShow; + } + }; + /** + * 检查是否在屏幕内 + * @param node + * @returns + */ + LoopList.prototype.checkInView = function (itemCell) { + var nodeSides = getNodeBorder(itemCell, [true, true, true, true]); + //节点右侧边缘在屏幕左侧外面或者节点左边缘在屏幕右侧外面 则不在显示区域 + var horizontalOutside = nodeSides.rightSide < this.viewSides.leftSide + || nodeSides.leftSide > this.viewSides.rightSide; + var verticalOutside = false; + if (!horizontalOutside) { + //节点上边缘在屏幕下方外面或者节点下边缘在屏幕上方外面 则不在显示区域 + verticalOutside = nodeSides.topSide < this.viewSides.bottomSide + || nodeSides.bottomSide > this.viewSides.topSide; + } + return !horizontalOutside && !verticalOutside; + }; + /** + * 处理变化的大小 + * @param cell + * @param nodeSides + * @param changeSize + */ + LoopList.prototype.dealChangeSize = function (cell, nodeSides, changeSize, time) { + if (time === void 0) { time = 0.3; } + return __awaiter(this, void 0, void 0, function () { + var topToBottomFulfill, bottomToTopFulfill, leftToRightFulfill, RightToLeftFulfill; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + topToBottomFulfill = (this.scrollView.content.anchorY == 1 && nodeSides.bottomSide >= this.viewSides.topSide); + bottomToTopFulfill = (this.scrollView.content.anchorY == 0 && nodeSides.topSide <= this.viewSides.bottomSide); + if (topToBottomFulfill || bottomToTopFulfill) { + if (topToBottomFulfill) { + this.scrollView.setContentPosition(cc.v2(this.scrollView.content.x, this.scrollView.content.y + changeSize.height)); + } + else { + this.scrollView.setContentPosition(cc.v2(this.scrollView.content.x, this.scrollView.content.y - changeSize.height)); + } + } + leftToRightFulfill = (this.scrollView.content.anchorX == 0 && nodeSides.rightSide <= this.viewSides.leftSide); + RightToLeftFulfill = (this.scrollView.content.anchorX == 1 && nodeSides.leftSide >= this.viewSides.rightSide); + if (leftToRightFulfill || RightToLeftFulfill) { + if (RightToLeftFulfill) { + this.scrollView.setContentPosition(cc.v2(this.scrollView.content.x + changeSize.width, this.scrollView.content.y)); + } + else { + this.scrollView.setContentPosition(cc.v2(this.scrollView.content.x - changeSize.width, this.scrollView.content.y)); + } + } + if (!!(topToBottomFulfill || bottomToTopFulfill || leftToRightFulfill || RightToLeftFulfill)) return [3 /*break*/, 2]; + cc.Tween.stopAllByTarget(cell.node); + return [4 /*yield*/, new Promise(function (resolve, reject) { + cc.tween(cell.node).to(time, { width: cell.size.width, height: cell.size.height }).call(function () { + resolve(); + }).start(); + })]; + case 1: + _a.sent(); + _a.label = 2; + case 2: + this.updateNodes(); + return [2 /*return*/, true]; + } + }); + }); + }; + /** + * 回收显示节点 + * @param node + */ + LoopList.prototype.recircleShowNode = function (node) { + node && this.showNodePool.push(node); + }; + /** + * 释放当前列表 + */ + LoopList.prototype.freeList = function () { + this.scrollView.node.off("scrolling", this.scrollingListener); + for (var i = 0, len = this.itemCells.length; i < len; ++i) { + this.recircleShowNode(this.itemCells[i].recircle()); + this.itemCells[i].destroy(); + } + this.itemCells = []; + for (var index = 0, len = this.showNodePool.length; index < len; ++index) { + this.showNodePool[index].destroy(); + } + this.showNodePool = []; + this.renderLayer = null; + this.scrollView = null; + this.prefab = null; + }; + LoopList.insMap = new Map(); + return LoopList; +}()); +exports.default = LoopList; +/** + * 获取节点的边缘 + * @param node + * @param needArr 顺序是上 下 左 右 + */ +function getNodeBorder(cell, needArr) { + var node = cell.node; + var boderData = {}; + var wpos = getNodeWPos(node); + //显示区域上边缘 + if (needArr[0]) { + boderData.topSide = wpos.y + (node.height * (1 - node.anchorY)); + } + //显示区域下边缘 + if (needArr[1]) { + boderData.bottomSide = wpos.y - (node.height * node.anchorY); + } + //显示区域左边缘 + if (needArr[2]) { + boderData.leftSide = wpos.x - (node.width * node.anchorX); + } + //显示区域右边缘 + if (needArr[3]) { + boderData.rightSide = wpos.x + (node.width * (1 - node.anchorX)); + } + boderData.size = cc.size(node.width, node.height); + return boderData; +} +/** + * 获取节点世界坐标 + * @param node + * @returns + */ +function getNodeWPos(node) { + return node.parent.convertToWorldSpaceAR(node.position); +} + +cc._RF.pop(); + } + if (nodeEnv) { + __define(__module.exports, __require, __module); + } + else { + __quick_compile_project__.registerModuleFunc(__filename, function () { + __define(__module.exports, __require, __module); + }); + } + })(); +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImFzc2V0c1xcU2NyaXB0XFxMb29wTGlzdC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0FBQUEseURBQW9EO0FBVXBEO0lBQStDLDRCQUFZO0lBQTNEO1FBQUEscUVBZ0ZDO1FBL0VHLGdCQUFnQjtRQUNSLGFBQU8sR0FBWSxLQUFLLENBQUM7O0lBOEVyQyxDQUFDO0lBdkVHLFNBQVM7SUFDRix1QkFBSSxHQUFYLFVBQVksSUFBaUIsRUFBRSxJQUFPLEVBQUUsV0FBb0I7UUFDeEQsSUFBSSxDQUFDLElBQUksR0FBRyxJQUFJLENBQUM7UUFDakIsSUFBSSxDQUFDLElBQUksR0FBRyxJQUFJLENBQUM7UUFDakIsSUFBSSxJQUFJLENBQUMsV0FBVyxJQUFJLFdBQVcsRUFBRTtZQUNqQyxJQUFJLENBQUMsV0FBVyxHQUFHLFdBQVcsQ0FBQztZQUMvQixXQUFXLElBQUksSUFBSSxDQUFDLFdBQVcsRUFBRSxDQUFDO1NBQ3JDO1FBQ0QsSUFBSSxDQUFDLFFBQVEsRUFBRSxDQUFDO0lBQ3BCLENBQUM7SUFDRCxXQUFXO0lBQ1gsMkJBQVEsR0FBUixjQUFhLENBQUM7SUFDZCxvQkFBb0I7SUFDcEIsNkJBQVUsR0FBVixjQUFlLENBQUM7SUFFaEI7Ozs7T0FJRztJQUNJLHlCQUFNLEdBQWIsVUFBYyxVQUFtQixFQUFFLElBQWtCO1FBQWxCLHFCQUFBLEVBQUEsVUFBa0I7UUFDakQsSUFBSSxDQUFDLElBQUksQ0FBQyxNQUFNLENBQUMsVUFBVSxFQUFFLElBQUksQ0FBQyxDQUFDO0lBQ3ZDLENBQUM7SUFDRDs7T0FFRztJQUNLLDhCQUFXLEdBQW5CO1FBQ0ksSUFBSSxDQUFDLElBQUksQ0FBQyxPQUFPLElBQUksSUFBSSxDQUFDLFdBQVcsRUFBRTtZQUNuQyxJQUFJLE9BQU8sR0FBd0MsSUFBSSxPQUFPLEVBQUUsQ0FBQztZQUNqRSxJQUFJLElBQUksR0FBRyxNQUFNLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxDQUFDO1lBQzdCLEtBQUssSUFBSSxDQUFDLEdBQUcsQ0FBQyxFQUFFLEdBQUcsR0FBRyxJQUFJLENBQUMsTUFBTSxFQUFFLENBQUMsR0FBRyxHQUFHLEVBQUUsRUFBRSxDQUFDLEVBQUU7Z0JBQzdDLElBQUksS0FBSyxHQUFHLElBQUksQ0FBQyxJQUFJLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQztnQkFDMUIsSUFBSSxXQUFXLEdBQXNCLElBQUksQ0FBQztnQkFDMUMsSUFBSSxLQUFLLFlBQVksRUFBRSxDQUFDLElBQUksRUFBRTtvQkFDMUIsV0FBVyxHQUFHLEtBQUssQ0FBQyxZQUFZLENBQUMsMkJBQWlCLENBQUMsQ0FBQztvQkFDcEQsSUFBSSxXQUFXLEVBQUU7d0JBQ2IsV0FBVyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsV0FBVyxDQUFDLENBQUM7cUJBQ3RDO2lCQUNKO3FCQUFNLElBQUksS0FBSyxZQUFZLEVBQUUsQ0FBQyxlQUFlLEVBQUU7b0JBQzVDLFdBQVcsR0FBRyxLQUFLLENBQUMsWUFBWSxDQUFDLDJCQUFpQixDQUFDLENBQUM7b0JBQ3BELElBQUksV0FBVyxFQUFFO3dCQUNiLElBQUksQ0FBQyxJQUFJLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxXQUFXLENBQUMsSUFBSSxDQUFlLElBQUksQ0FBQyxXQUFXLENBQUMsQ0FBQztxQkFDcEU7aUJBQ0o7Z0JBQ0QsV0FBVyxJQUFJLE9BQU8sQ0FBQyxHQUFHLENBQUMsV0FBVyxFQUFFLElBQUksQ0FBQyxDQUFDO2FBQ2pEO1lBQ0QsSUFBSSxDQUFDLHNCQUFzQixDQUFDLElBQUksQ0FBQyxJQUFJLEVBQUUsT0FBTyxFQUFFLENBQUMsRUFBRSxDQUFDLENBQUMsQ0FBQztZQUN0RCxJQUFJLENBQUMsT0FBTyxHQUFHLElBQUksQ0FBQztTQUN2QjtJQUNMLENBQUM7SUFDRDs7Ozs7O09BTUc7SUFDSCx5Q0FBc0IsR0FBdEIsVUFBdUIsSUFBYSxFQUFFLE9BQTRDLEVBQUUsWUFBb0IsRUFBRSxLQUFhOztRQUNuSCxLQUFLLElBQUksQ0FBQyxHQUFHLENBQUMsRUFBRSxHQUFHLEdBQUcsSUFBSSxDQUFDLFFBQVEsQ0FBQyxNQUFNLEVBQUUsQ0FBQyxHQUFHLEdBQUcsRUFBRSxDQUFDLEVBQUUsRUFBRTtZQUN0RCxJQUFJLFFBQVEsR0FBRyxJQUFJLENBQUMsUUFBUSxDQUFDLENBQUMsQ0FBQyxDQUFDO1lBQ2hDLElBQUksV0FBVyxTQUFHLFFBQVEsQ0FBQyxZQUFZLENBQUMsRUFBRSxDQUFDLGVBQWUsQ0FBQywwQ0FBRSxZQUFZLENBQUMsMkJBQWlCLENBQUMsQ0FBQztZQUM3RixJQUFJLE1BQU0sR0FBRyxZQUFZLEdBQUcsQ0FBQyxDQUFDLEdBQUcsSUFBSSxDQUFDLEdBQUcsQ0FBQyxHQUFHLEVBQUUsS0FBSyxDQUFDLENBQUMsQ0FBQztZQUN2RCxJQUFJLFdBQVcsRUFBRTtnQkFDYixJQUFJLENBQUMsQ0FBQyxPQUFPLENBQUMsR0FBRyxDQUFDLFdBQVcsQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDLEdBQUcsQ0FBQyxXQUFXLENBQUMsQ0FBQyxFQUFFO29CQUMxRCxXQUFXLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxXQUFXLENBQUMsQ0FBQztpQkFDdEM7Z0JBQ0QsV0FBVyxDQUFDLE1BQU0sR0FBRyxNQUFNLENBQUM7YUFDL0I7WUFDRCxJQUFJLENBQUMsc0JBQXNCLENBQUMsUUFBUSxFQUFFLE9BQU8sRUFBRSxNQUFNLEVBQUUsS0FBSyxHQUFHLENBQUMsQ0FBQyxDQUFDO1NBQ3JFO0lBQ0wsQ0FBQztJQUNMLGVBQUM7QUFBRCxDQWhGQSxBQWdGQyxDQWhGOEMsRUFBRSxDQUFDLFNBQVMsR0FnRjFEO0FBaEZZLDRCQUFRO0FBaUZyQjtJQWVJOzs7O09BSUc7SUFDSCxrQkFBWSxJQUFhLEVBQUUsUUFBcUI7UUFuQmhELGlCQUFpQjtRQUNWLGFBQVEsR0FBZ0IsSUFBSSxDQUFDO1FBQ3BDLFVBQVU7UUFDSCxTQUFJLEdBQVksSUFBSSxDQUFDO1FBQzVCLFVBQVU7UUFDSCxhQUFRLEdBQWdCLElBQUksQ0FBQztRQUNwQyxRQUFRO1FBQ0QsU0FBSSxHQUFZLElBQUksQ0FBQztRQUM1QixVQUFVO1FBQ0gsY0FBUyxHQUFXLElBQUksQ0FBQztRQUNoQyxZQUFZO1FBQ0wsY0FBUyxHQUFXLElBQUksQ0FBQztRQUNoQyxRQUFRO1FBQ0QsU0FBSSxHQUFNLElBQUksQ0FBQztRQU9sQixJQUFJLENBQUMsSUFBSSxHQUFHLElBQUksQ0FBQztRQUNqQixJQUFJLENBQUMsUUFBUSxHQUFHLFFBQVEsQ0FBQztJQUM3QixDQUFDO0lBRUQ7Ozs7Ozs7T0FPRztJQUNJLHVCQUFJLEdBQVgsVUFBWSxJQUFPLEVBQUUsSUFBYSxFQUFFLFNBQWlCLEVBQUUsU0FBaUIsRUFBRSxRQUFxQjtRQUMzRixFQUFFLENBQUMsS0FBSyxDQUFDLGVBQWUsQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLENBQUM7UUFDcEMsSUFBSSxDQUFDLFNBQVMsR0FBRyxTQUFTLENBQUM7UUFDM0IsSUFBSSxDQUFDLFNBQVMsR0FBRyxTQUFTLENBQUM7UUFDM0IsSUFBSSxDQUFDLFFBQVEsR0FBRyxRQUFRLENBQUM7UUFDekIsSUFBSSxDQUFDLElBQUksQ0FBQyxLQUFLLEdBQUcsSUFBSSxDQUFDLEtBQUssQ0FBQztRQUM3QixJQUFJLENBQUMsSUFBSSxDQUFDLE1BQU0sR0FBRyxJQUFJLENBQUMsTUFBTSxDQUFDO1FBQy9CLElBQUksQ0FBQyxJQUFJLEdBQUcsSUFBSSxDQUFDO1FBQ2pCLElBQUksQ0FBQyxJQUFJLEdBQUcsSUFBSSxDQUFDO0lBQ3JCLENBQUM7SUFDRDs7O09BR0c7SUFDSCx5QkFBTSxHQUFOLFVBQU8sSUFBYSxFQUFFLElBQVk7UUFBbEMsaUJBU0M7UUFSRyxJQUFJLFNBQVMsR0FBRyxhQUFhLENBQUMsSUFBSSxFQUFFLENBQUMsSUFBSSxFQUFFLElBQUksRUFBRSxJQUFJLEVBQUUsSUFBSSxDQUFDLENBQUMsQ0FBQztRQUM5RCxJQUFJLFVBQVUsR0FBRyxFQUFFLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxLQUFLLEdBQUcsSUFBSSxDQUFDLElBQUksQ0FBQyxLQUFLLEVBQUUsSUFBSSxDQUFDLE1BQU0sR0FBRyxJQUFJLENBQUMsSUFBSSxDQUFDLE1BQU0sQ0FBQyxDQUFDO1FBQ3ZGLElBQUksQ0FBQyxJQUFJLEdBQUcsSUFBSSxDQUFDO1FBQ2pCLElBQUksQ0FBQyxRQUFRLENBQUMsY0FBYyxDQUFDLElBQUksRUFBRSxTQUFTLEVBQUUsVUFBVSxFQUFFLElBQUksQ0FBQyxDQUFDLElBQUksQ0FBQztZQUNqRSxLQUFJLENBQUMsSUFBSSxDQUFDLEtBQUssR0FBRyxJQUFJLENBQUMsS0FBSyxDQUFDO1lBQzdCLEtBQUksQ0FBQyxJQUFJLENBQUMsTUFBTSxHQUFHLElBQUksQ0FBQyxNQUFNLENBQUM7WUFDL0IsS0FBSSxDQUFDLFFBQVEsQ0FBQyxXQUFXLEVBQUUsQ0FBQztRQUNoQyxDQUFDLENBQUMsQ0FBQztJQUNQLENBQUM7SUFFRDs7Ozs7O09BTUc7SUFDSCw2QkFBVSxHQUFWLFVBQVcsTUFBZSxFQUFFLE1BQWlCLEVBQUUsU0FBc0IsRUFBRSxXQUFvQjtRQUN2RixJQUFJLE1BQU0sRUFBRTtZQUNSLFVBQVU7WUFDVixJQUFJLENBQUMsSUFBSSxDQUFDLFFBQVEsRUFBRTtnQkFDaEIsaUJBQWlCO2dCQUNqQixJQUFJLFNBQVMsRUFBRTtvQkFDWCxJQUFJLENBQUMsUUFBUSxHQUFHLFNBQVMsQ0FBQztpQkFDN0I7cUJBQU0sRUFBQyxnQkFBZ0I7b0JBQ3BCLElBQUksQ0FBQyxRQUFRLEdBQUcsRUFBRSxDQUFDLFdBQVcsQ0FBQyxNQUFNLENBQUMsQ0FBQyxZQUFZLENBQUMsUUFBUSxDQUFDLENBQUM7aUJBQ2pFO2dCQUNELElBQUksQ0FBQyxRQUFRLENBQUMsSUFBSSxDQUFDLFNBQVMsQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLENBQUM7Z0JBQ3hDLElBQUksQ0FBQyxRQUFRLENBQUMsSUFBSSxDQUFDLFFBQVEsR0FBRyxFQUFFLENBQUMsRUFBRSxFQUFFLENBQUM7Z0JBQ3RDLElBQUksQ0FBQyxjQUFjLENBQUMsV0FBVyxDQUFDLENBQUM7YUFDcEM7U0FDSjtJQUNMLENBQUM7SUFDRDs7O09BR0c7SUFDSCxpQ0FBYyxHQUFkLFVBQWUsV0FBb0I7UUFDL0IsU0FBUztRQUNULElBQUksSUFBSSxDQUFDLFFBQVEsRUFBRTtZQUNmLElBQUksQ0FBQyxRQUFRLENBQUMsSUFBSSxDQUFDLElBQUksRUFBRSxJQUFJLENBQUMsSUFBSSxFQUFFLFdBQVcsQ0FBQyxDQUFDO1NBQ3BEO0lBQ0wsQ0FBQztJQUVELHNCQUFJLCtCQUFTO2FBQWI7WUFDSSxPQUFPLENBQUMsSUFBSSxDQUFDLFFBQVEsQ0FBQztRQUMxQixDQUFDOzs7T0FBQTtJQUVELDJCQUFRLEdBQVI7UUFDSSxJQUFJLElBQUksQ0FBQyxRQUFRLEVBQUU7WUFDZixJQUFJLElBQUksR0FBRyxJQUFJLENBQUMsUUFBUSxDQUFDO1lBQ3pCLElBQUksQ0FBQyxRQUFRLENBQUMsWUFBWSxDQUFDLFFBQVEsQ0FBQyxDQUFDLFVBQVUsRUFBRSxDQUFDO1lBQ2xELElBQUksQ0FBQyxRQUFRLENBQUMsSUFBSSxDQUFDLGdCQUFnQixDQUFDLEtBQUssQ0FBQyxDQUFDO1lBQzNDLElBQUksQ0FBQyxRQUFRLEdBQUcsSUFBSSxDQUFDO1lBQ3JCLE9BQU8sSUFBSSxDQUFDO1NBQ2Y7SUFDTCxDQUFDO0lBR0QsMEJBQU8sR0FBUDtRQUNJLElBQUksQ0FBQyxJQUFJLENBQUMsT0FBTyxFQUFFLENBQUM7UUFDcEIsSUFBSSxDQUFDLElBQUksR0FBRyxJQUFJLENBQUM7UUFDakIsSUFBSSxDQUFDLFFBQVEsR0FBRyxJQUFJLENBQUM7SUFDekIsQ0FBQztJQUVEOzs7T0FHRztJQUNILCtCQUFZLEdBQVo7UUFDSSxJQUFJLElBQUksQ0FBQyxRQUFRLEVBQUU7WUFDZixJQUFJLElBQUksR0FBRyxJQUFJLENBQUMsUUFBUSxDQUFDO1lBQ3pCLElBQUksQ0FBQyxRQUFRLENBQUMsSUFBSSxDQUFDLGdCQUFnQixDQUFDLEtBQUssQ0FBQyxDQUFDO1lBQzNDLElBQUksQ0FBQyxRQUFRLEdBQUcsSUFBSSxDQUFDO1lBQ3JCLE9BQU8sSUFBSSxDQUFDO1NBQ2Y7SUFDTCxDQUFDO0lBRUQ7OztPQUdHO0lBQ0gsOEJBQVcsR0FBWCxVQUFZLFFBQXFCO1FBQzdCLElBQUksQ0FBQyxRQUFRLEdBQUcsUUFBUSxDQUFDO1FBQ3pCLFFBQVEsQ0FBQyxJQUFJLENBQUMsU0FBUyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsQ0FBQztRQUNuQyxJQUFJLENBQUMsUUFBUSxDQUFDLElBQUksR0FBRyxJQUFJLENBQUM7SUFDOUIsQ0FBQztJQUNMLGVBQUM7QUFBRCxDQXZJQSxBQXVJQyxJQUFBO0FBdklZLDRCQUFRO0FBeUlyQjs7O0dBR0c7QUFDSDtJQUFBO1FBUUksaURBQWlEO1FBQ3pDLGdCQUFXLEdBQVksSUFBSSxDQUFDO1FBQ3BDLFVBQVU7UUFDRixlQUFVLEdBQWtCLElBQUksQ0FBQztRQUN6QyxnQkFBZ0I7UUFDUixlQUFVLEdBQVcsSUFBSSxDQUFDO1FBQ2xDLFVBQVU7UUFDRixrQkFBYSxHQUFXLElBQUksQ0FBQztRQUNyQyxRQUFRO1FBQ0EsVUFBSyxHQUFRLEVBQUUsQ0FBQztRQUN4QixhQUFhO1FBQ0wsY0FBUyxHQUFrQixFQUFFLENBQUM7UUFDdEMsU0FBUztRQUNELFdBQU0sR0FBYyxJQUFJLENBQUM7UUFDakMsYUFBYTtRQUNMLGlCQUFZLEdBQWtCLEVBQUUsQ0FBQztRQUN6QyxVQUFVO1FBQ0YsY0FBUyxHQUFZLEVBQUUsQ0FBQztRQUNoQyxnQkFBZ0I7UUFDVCxZQUFPLEdBQVksSUFBSSxDQUFDO1FBQy9CLGVBQWU7UUFDUixjQUFTLEdBQVcsQ0FBQyxDQUFDO1FBQzdCLGlCQUFpQjtRQUNWLGVBQVUsR0FBVyxDQUFDLENBQUM7UUFDOUIsVUFBVTtRQUNILFNBQUksR0FBWSxJQUFJLENBQUM7UUFDNUIsVUFBVTtRQUNILFdBQU0sR0FBWSxJQUFJLENBQUM7SUF5aEJsQyxDQUFDO0lBMWpCaUIsWUFBRyxHQUFqQixVQUFxQixRQUFnQjtRQUNqQyxJQUFJLENBQUMsSUFBSSxDQUFDLE1BQU0sQ0FBQyxHQUFHLENBQUMsUUFBUSxDQUFDLEVBQUU7WUFDNUIsSUFBSSxDQUFDLE1BQU0sQ0FBQyxHQUFHLENBQUMsUUFBUSxFQUFFLElBQUksUUFBUSxFQUFLLENBQUMsQ0FBQztTQUNoRDtRQUNELE9BQU8sSUFBSSxDQUFDLE1BQU0sQ0FBQyxHQUFHLENBQUMsUUFBUSxDQUFnQixDQUFDO0lBQ3BELENBQUM7SUE4QkQseUJBQU0sR0FBTjtRQUNJLElBQUksQ0FBQyxZQUFZLEVBQUUsQ0FBQTtJQUN2QixDQUFDO0lBRUQ7O09BRUc7SUFDSSwrQkFBWSxHQUFuQjtRQUFBLGlCQXdCQztRQXZCRyxJQUFJLElBQUksR0FBRyxJQUFJLENBQUMsVUFBVSxDQUFDLElBQUksQ0FBQyxjQUFjLENBQUMsTUFBTSxDQUFDLENBQUM7UUFDdkQsSUFBSSxDQUFDLE9BQU8sR0FBRyxJQUFJLENBQUMsVUFBVSxDQUFDLE9BQU8sQ0FBQyxPQUFPLENBQUM7UUFDL0MsSUFBSSxDQUFDLE9BQU8sR0FBRyxJQUFJLENBQUMsVUFBVSxDQUFDLE9BQU8sQ0FBQyxPQUFPLENBQUM7UUFDL0MsNkJBQTZCO1FBQzdCLE9BQU8sSUFBSSxPQUFPLENBQU8sVUFBQyxPQUFPLEVBQUUsTUFBTTtZQUNyQyxxQkFBcUIsQ0FBQztnQkFDbEIsSUFBSSxJQUFJLEdBQUcsV0FBVyxDQUFDLElBQUksQ0FBQyxDQUFDO2dCQUM3QixTQUFTO2dCQUNULElBQUksUUFBUSxHQUFHLElBQUksQ0FBQyxDQUFDLEdBQUcsQ0FBQyxJQUFJLENBQUMsS0FBSyxHQUFHLElBQUksQ0FBQyxPQUFPLENBQUMsQ0FBQztnQkFDcEQsU0FBUztnQkFDVCxJQUFJLFNBQVMsR0FBRyxJQUFJLENBQUMsQ0FBQyxHQUFHLENBQUMsSUFBSSxDQUFDLEtBQUssR0FBRyxDQUFDLENBQUMsR0FBRyxJQUFJLENBQUMsT0FBTyxDQUFDLENBQUMsQ0FBQztnQkFDM0QsU0FBUztnQkFDVCxJQUFJLFVBQVUsR0FBRyxJQUFJLENBQUMsQ0FBQyxHQUFHLENBQUMsSUFBSSxDQUFDLE1BQU0sR0FBRyxJQUFJLENBQUMsT0FBTyxDQUFDLENBQUM7Z0JBQ3ZELFNBQVM7Z0JBQ1QsSUFBSSxPQUFPLEdBQUcsSUFBSSxDQUFDLENBQUMsR0FBRyxDQUFDLElBQUksQ0FBQyxNQUFNLEdBQUcsQ0FBQyxDQUFDLEdBQUcsSUFBSSxDQUFDLE9BQU8sQ0FBQyxDQUFDLENBQUM7Z0JBQzFELEtBQUksQ0FBQyxTQUFTLEdBQUc7b0JBQ2IsUUFBUSxVQUFBLEVBQUUsU0FBUyxXQUFBLEVBQUUsVUFBVSxZQUFBLEVBQUUsT0FBTyxTQUFBO29CQUFFLElBQUksRUFBRSxFQUFFLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxLQUFLLEVBQUUsSUFBSSxDQUFDLE1BQU0sQ0FBQztpQkFDbkYsQ0FBQztnQkFDRixLQUFJLENBQUMsVUFBVSxDQUFDLE9BQU8sQ0FBQyxXQUFXLENBQUMsRUFBRSxDQUFDLEVBQUUsQ0FBQyxDQUFDLEVBQUUsQ0FBQyxDQUFDLENBQUMsQ0FBQztnQkFDakQsT0FBTyxFQUFFLENBQUM7WUFDZCxDQUFDLENBQUMsQ0FBQTtRQUNOLENBQUMsQ0FBQyxDQUFBO0lBRU4sQ0FBQztJQUVEOzs7OztPQUtHO0lBQ0csdUJBQUksR0FBVixVQUFXLFVBQXlCLEVBQUUsV0FBcUIsRUFBRSxVQUFtQjs7Ozs7d0JBQzVFLFVBQVUsSUFBSSxDQUFDLElBQUksQ0FBQyxVQUFVLEdBQUcsVUFBVSxDQUFDLENBQUM7d0JBQzdDLFdBQVcsSUFBSSxDQUFDLElBQUksQ0FBQyxXQUFXLEdBQUcsV0FBVyxDQUFDLENBQUM7d0JBQ2hELElBQUksQ0FBQyxVQUFVLEdBQUcsVUFBVSxDQUFDO3dCQUM3QixxQkFBTSxJQUFJLENBQUMsWUFBWSxFQUFFLEVBQUE7O3dCQUF6QixTQUF5QixDQUFDO3dCQUMxQixJQUFJLENBQUMsVUFBVSxDQUFDLElBQUksQ0FBQyxFQUFFLENBQUMsV0FBVyxFQUFFLElBQUksQ0FBQyxpQkFBaUIsRUFBRSxJQUFJLENBQUMsQ0FBQzs7Ozs7S0FDdEU7SUFFRCxVQUFVO0lBQ1Ysb0NBQWlCLEdBQWpCO1FBQ0ksSUFBSSxDQUFDLFNBQVMsRUFBRSxDQUFDO1FBQ2pCLElBQUksSUFBSSxDQUFDLFNBQVMsSUFBSSxDQUFDLEVBQUU7WUFDckIsSUFBSSxDQUFDLFNBQVMsR0FBRyxDQUFDLENBQUM7WUFDbkIsSUFBSSxTQUFTLEdBQUcsSUFBSSxDQUFDLFdBQVcsRUFBRSxDQUFDO1lBRW5DLElBQUksQ0FBQyxJQUFJLENBQUMsVUFBVSxFQUFFO2dCQUNsQixPQUFPO2FBQ1Y7WUFDRCxJQUFJLENBQUMsSUFBSSxDQUFDLE9BQU8sRUFBRTtnQkFDZixJQUFJLENBQUMsT0FBTyxHQUFHLElBQUksQ0FBQyxVQUFVLENBQUMsT0FBTyxDQUFDLFFBQVEsQ0FBQyxLQUFLLEVBQUUsQ0FBQzthQUMzRDtpQkFBTTtnQkFDSCxJQUFJLE1BQU0sR0FBRyxJQUFJLENBQUMsVUFBVSxDQUFDLE9BQU8sQ0FBQyxRQUFRLENBQUMsS0FBSyxFQUFFLENBQUMsR0FBRyxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUMsQ0FBQztnQkFDeEUsSUFBSSxDQUFDLE9BQU8sR0FBRyxJQUFJLENBQUMsVUFBVSxDQUFDLE9BQU8sQ0FBQyxRQUFRLENBQUMsS0FBSyxFQUFFLENBQUM7Z0JBQ3hELElBQUksR0FBRyxHQUFHLEVBQUUsQ0FBQyxHQUFHLENBQUMsR0FBRyxFQUFFLENBQUM7Z0JBQ3ZCLElBQUksQ0FBQyxJQUFJLENBQUMsVUFBVSxJQUFJLENBQUMsR0FBRyxHQUFHLElBQUksQ0FBQyxVQUFVLENBQUMsR0FBRyxHQUFHLEVBQUU7b0JBQ25ELElBQUksQ0FBQyxVQUFVLEdBQUcsR0FBRyxDQUFDO29CQUN0QixJQUFJLENBQUMsWUFBWSxDQUFDLE1BQU0sRUFBRSxTQUFTLENBQUMsQ0FBQztpQkFDeEM7YUFDSjtTQUNKO0lBQ0wsQ0FBQztJQUNEOzs7Ozs7T0FNRztJQUNJLDJCQUFRLEdBQWYsVUFBZ0IsSUFBUyxFQUFFLE1BQWlCLEVBQUUsSUFBYyxFQUFFLE1BQWlDO1FBQWpDLHVCQUFBLEVBQUEsU0FBa0IsRUFBRSxDQUFDLEVBQUUsQ0FBQyxHQUFHLEVBQUUsR0FBRyxDQUFDO1FBQzNGLElBQUksQ0FBQyxLQUFLLEdBQUcsSUFBSSxDQUFDO1FBQ2xCLElBQUksQ0FBQyxJQUFJLEdBQUcsSUFBSSxDQUFDO1FBQ2pCLElBQUksQ0FBQyxNQUFNLEdBQUcsTUFBTSxDQUFDO1FBQ3JCLElBQUksQ0FBQyxNQUFNLEdBQUcsTUFBTSxDQUFDO1FBQ3JCLElBQUksR0FBRyxHQUFHLElBQUksQ0FBQyxVQUFVLENBQUMsQ0FBQyxDQUFDLElBQUksQ0FBQyxVQUFVLENBQUMsQ0FBQyxDQUFDLElBQUksQ0FBQyxNQUFNLENBQUM7UUFDMUQsSUFBSSxDQUFDLGFBQWEsR0FBRyxDQUFDLENBQUM7UUFDdkIsS0FBSyxJQUFJLENBQUMsR0FBRyxDQUFDLEVBQUUsQ0FBQyxHQUFHLEdBQUcsRUFBRSxFQUFFLENBQUMsRUFBRTtZQUMxQixJQUFJLFFBQVEsR0FBRyxJQUFJLENBQUMsU0FBUyxDQUFDLENBQUMsQ0FBQyxDQUFDO1lBQ2pDLElBQUksQ0FBQyxRQUFRLEVBQUU7Z0JBQ1gsSUFBSSxJQUFJLEdBQUcsSUFBSSxFQUFFLENBQUMsSUFBSSxDQUFDLGNBQWMsQ0FBQyxDQUFBO2dCQUN0QyxRQUFRLEdBQUcsSUFBSSxDQUFDLFNBQVMsQ0FBQyxDQUFDLENBQUMsR0FBRyxJQUFJLFFBQVEsQ0FBSSxJQUFJLEVBQUUsSUFBSSxDQUFDLENBQUM7Z0JBQzNELElBQUksQ0FBQyxjQUFjLENBQUMsTUFBTSxDQUFDLENBQUM7Z0JBQzVCLElBQUksQ0FBQyxTQUFTLENBQUMsSUFBSSxDQUFDLFVBQVUsQ0FBQyxPQUFPLENBQUMsQ0FBQzthQUMzQztZQUNELElBQUksTUFBSSxHQUFHLElBQUksQ0FBQyxLQUFLLENBQUMsSUFBSSxDQUFDLGFBQWEsR0FBRyxDQUFDLENBQUMsQ0FBQztZQUM5QyxJQUFJLFFBQVEsR0FBRyxNQUFJLENBQUMsSUFBSSxDQUFDLENBQUMsQ0FBQyxNQUFJLENBQUMsSUFBSSxDQUFDLENBQUMsQ0FBQyxJQUFJLENBQUM7WUFDNUMsUUFBUSxDQUFDLElBQUksQ0FBQyxNQUFJLEVBQUUsUUFBUSxFQUFFLElBQUksQ0FBQyxhQUFhLEdBQUcsQ0FBQyxFQUFFLENBQUMsRUFBRSxJQUFJLENBQUMsQ0FBQztTQUNsRTtRQUNELEtBQUssSUFBSSxDQUFDLEdBQUcsSUFBSSxDQUFDLE1BQU0sRUFBRSxLQUFHLEdBQUcsSUFBSSxDQUFDLFNBQVMsQ0FBQyxNQUFNLEVBQUUsQ0FBQyxHQUFHLEtBQUcsRUFBRSxFQUFFLENBQUMsRUFBRTtZQUNqRSxJQUFJLENBQUMsZ0JBQWdCLENBQUMsSUFBSSxDQUFDLFNBQVMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxRQUFRLEVBQUUsQ0FBQyxDQUFDO1lBQ3BELElBQUksQ0FBQyxTQUFTLENBQUMsQ0FBQyxDQUFDLENBQUMsT0FBTyxFQUFFLENBQUE7WUFDM0IsSUFBSSxDQUFDLFNBQVMsQ0FBQyxDQUFDLENBQUMsR0FBRyxJQUFJLENBQUM7U0FDNUI7UUFDRCxJQUFJLENBQUMsV0FBVyxFQUFFLENBQUM7SUFDdkIsQ0FBQztJQUVEOzs7T0FHRztJQUNJLDRCQUFTLEdBQWhCLFVBQWlCLEtBQVU7UUFDdkIsSUFBSSxNQUFNLEdBQUcsSUFBSSxDQUFDLEtBQUssQ0FBQyxNQUFNLENBQUM7UUFDL0IsS0FBSyxJQUFJLENBQUMsR0FBRyxDQUFDLEVBQUUsR0FBRyxHQUFHLEtBQUssQ0FBQyxNQUFNLEVBQUUsQ0FBQyxHQUFHLEdBQUcsRUFBRSxFQUFFLENBQUMsRUFBRTtZQUM5QyxJQUFJLElBQUksR0FBRyxLQUFLLENBQUMsQ0FBQyxDQUFDLENBQUM7WUFDcEIsSUFBSSxDQUFDLEtBQUssQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLENBQUM7WUFDdEIsSUFBSSxLQUFLLEdBQUcsTUFBTSxHQUFHLENBQUMsQ0FBQztZQUN2QixJQUFJLENBQUMsZ0JBQWdCLENBQUMsS0FBSyxDQUFDLENBQUM7U0FDaEM7SUFDTCxDQUFDO0lBQ0Q7Ozs7T0FJRztJQUNJLDZCQUFVLEdBQWpCLFVBQWtCLElBQU8sRUFBRSxXQUFtQjtRQUMxQyxJQUFJLElBQUksQ0FBQyxLQUFLLENBQUMsTUFBTSxJQUFJLFdBQVcsRUFBRTtZQUNsQyxJQUFJLENBQUMsS0FBSyxDQUFDLE1BQU0sQ0FBQyxXQUFXLEVBQUUsQ0FBQyxFQUFFLElBQUksQ0FBQyxDQUFDO1lBQ3hDLElBQUksQ0FBQyxnQkFBZ0IsQ0FBQyxXQUFXLENBQUMsQ0FBQztTQUN0QzthQUFNO1lBQ0gsSUFBSSxDQUFDLFNBQVMsQ0FBQyxDQUFDLElBQUksQ0FBQyxDQUFDLENBQUM7U0FDMUI7SUFDTCxDQUFDO0lBQ0Q7OztPQUdHO0lBQ0ksNkJBQVUsR0FBakIsVUFBa0IsV0FBbUI7UUFBckMsaUJBaUNDO1FBaENHLElBQUksSUFBSSxDQUFDLEtBQUssQ0FBQyxNQUFNLElBQUksV0FBVyxFQUFFO1lBQ2xDLElBQUksQ0FBQyxLQUFLLENBQUMsTUFBTSxDQUFDLFdBQVcsRUFBRSxDQUFDLENBQUMsQ0FBQztZQUNsQyxJQUFJLElBQUksQ0FBQyxVQUFVLEVBQUU7Z0JBQ2pCLElBQUksV0FBUyxHQUFHLFdBQVcsR0FBRyxJQUFJLENBQUMsYUFBYSxDQUFDO2dCQUNqRCxRQUFRO2dCQUNSLElBQUksV0FBUyxJQUFJLENBQUMsSUFBSSxXQUFTLEdBQUcsSUFBSSxDQUFDLFVBQVUsRUFBRTtvQkFDL0MsSUFBSSxRQUFRLEdBQUcsSUFBSSxDQUFDLFNBQVMsQ0FBQyxXQUFTLENBQUMsQ0FBQztvQkFDekMsSUFBSSxTQUFTLEdBQUcsYUFBYSxDQUFDLFFBQVEsRUFBRSxDQUFDLElBQUksRUFBRSxJQUFJLEVBQUUsSUFBSSxFQUFFLElBQUksQ0FBQyxDQUFDLENBQUM7b0JBQ2xFLElBQUksVUFBVSxHQUFHLEVBQUUsQ0FBQyxJQUFJLENBQUMsQ0FBQyxRQUFRLENBQUMsSUFBSSxDQUFDLEtBQUssRUFBRSxDQUFDLFFBQVEsQ0FBQyxJQUFJLENBQUMsTUFBTSxDQUFDLENBQUM7b0JBQ3RFLFFBQVEsQ0FBQyxJQUFJLEdBQUcsRUFBRSxDQUFDLElBQUksQ0FBQyxDQUFDLEVBQUUsQ0FBQyxDQUFDLENBQUM7b0JBQzlCLElBQUksQ0FBQyxjQUFjLENBQUMsUUFBUSxFQUFFLFNBQVMsRUFBRSxVQUFVLENBQUMsQ0FBQyxJQUFJLENBQUM7d0JBQ3RELE1BQU07d0JBQ04sS0FBSyxJQUFJLENBQUMsR0FBRyxXQUFTLEVBQUUsQ0FBQyxHQUFHLEtBQUksQ0FBQyxVQUFVLEVBQUUsQ0FBQyxFQUFFLEVBQUU7NEJBQzlDLElBQUksWUFBWSxHQUFHLEtBQUksQ0FBQyxhQUFhLEdBQUcsQ0FBQyxDQUFDOzRCQUMxQyxJQUFJLE9BQU8sR0FBRyxLQUFJLENBQUMsS0FBSyxDQUFDLFlBQVksQ0FBQyxDQUFDOzRCQUN2QyxJQUFJLFdBQVcsR0FBWSxPQUFPLENBQUMsSUFBSSxDQUFDLENBQUMsQ0FBQyxPQUFPLENBQUMsSUFBSSxDQUFDLENBQUMsQ0FBQyxLQUFJLENBQUMsSUFBSSxDQUFDOzRCQUNuRSxLQUFJLENBQUMsU0FBUyxDQUFDLENBQUMsQ0FBQyxDQUFDLElBQUksQ0FBQyxPQUFPLEVBQUUsV0FBVyxFQUFFLFlBQVksRUFBRSxDQUFDLEVBQUUsS0FBSSxDQUFDLENBQUM7NEJBQ3BFLEtBQUksQ0FBQyxTQUFTLENBQUMsQ0FBQyxDQUFDLENBQUMsY0FBYyxDQUFDLEtBQUksQ0FBQyxXQUFXLENBQUMsQ0FBQzt5QkFDdEQ7b0JBQ0wsQ0FBQyxDQUFDLENBQUM7aUJBQ047YUFDSjtpQkFBTTtnQkFDSCxJQUFJLFVBQVEsR0FBRyxJQUFJLENBQUMsU0FBUyxDQUFDLE1BQU0sQ0FBQyxXQUFXLEVBQUUsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUM7Z0JBQ3hELElBQUksU0FBUyxHQUFHLGFBQWEsQ0FBQyxVQUFRLEVBQUUsQ0FBQyxJQUFJLEVBQUUsSUFBSSxFQUFFLElBQUksRUFBRSxJQUFJLENBQUMsQ0FBQyxDQUFDO2dCQUNsRSxJQUFJLFVBQVUsR0FBRyxFQUFFLENBQUMsSUFBSSxDQUFDLENBQUMsVUFBUSxDQUFDLElBQUksQ0FBQyxLQUFLLEVBQUUsQ0FBQyxVQUFRLENBQUMsSUFBSSxDQUFDLE1BQU0sQ0FBQyxDQUFDO2dCQUN0RSxVQUFRLENBQUMsSUFBSSxHQUFHLEVBQUUsQ0FBQyxJQUFJLENBQUMsQ0FBQyxFQUFFLENBQUMsQ0FBQyxDQUFDO2dCQUM5QixJQUFJLENBQUMsY0FBYyxDQUFDLFVBQVEsRUFBRSxTQUFTLEVBQUUsVUFBVSxDQUFDLENBQUMsSUFBSSxDQUFDO29CQUN0RCxLQUFJLENBQUMsZ0JBQWdCLENBQUMsVUFBUSxDQUFDLFFBQVEsRUFBRSxDQUFDLENBQUE7b0JBQzFDLFVBQVEsQ0FBQyxJQUFJLENBQUMsT0FBTyxFQUFFLENBQUM7Z0JBQzVCLENBQUMsQ0FBQyxDQUFDO2FBQ047U0FDSjtJQUNMLENBQUM7SUFDRDs7O09BR0c7SUFDVyxtQ0FBZ0IsR0FBOUIsVUFBK0IsU0FBaUI7Ozs7Ozt3QkFDeEMsSUFBSSxHQUFHLElBQUksQ0FBQyxLQUFLLENBQUMsU0FBUyxDQUFDLENBQUM7d0JBQzdCLFFBQVEsR0FBWSxJQUFJLENBQUMsSUFBSSxDQUFDLENBQUMsQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLENBQUMsQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDOzZCQUV0RCxJQUFJLENBQUMsVUFBVSxFQUFmLHdCQUFlO3dCQUNYLFNBQVMsR0FBRyxTQUFTLEdBQUcsSUFBSSxDQUFDLGFBQWEsQ0FBQzt3QkFDL0MsUUFBUTt3QkFDUixJQUFJLFNBQVMsSUFBSSxDQUFDLElBQUksU0FBUyxHQUFHLElBQUksQ0FBQyxVQUFVLEVBQUU7NEJBQy9DLE1BQU07NEJBQ04sS0FBUyxDQUFDLEdBQUcsU0FBUyxFQUFFLENBQUMsR0FBRyxJQUFJLENBQUMsVUFBVSxFQUFFLENBQUMsRUFBRSxFQUFFO2dDQUMxQyxZQUFZLEdBQUcsSUFBSSxDQUFDLGFBQWEsR0FBRyxDQUFDLENBQUM7Z0NBQ3RDLE9BQU8sR0FBRyxJQUFJLENBQUMsS0FBSyxDQUFDLFlBQVksQ0FBQyxDQUFDO2dDQUNuQyxXQUFXLEdBQVksT0FBTyxDQUFDLElBQUksQ0FBQyxDQUFDLENBQUMsT0FBTyxDQUFDLElBQUksQ0FBQyxDQUFDLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQztnQ0FDbkUsSUFBSSxDQUFDLFNBQVMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxJQUFJLENBQUMsT0FBTyxFQUFFLFdBQVcsRUFBRSxZQUFZLEVBQUUsQ0FBQyxFQUFFLElBQUksQ0FBQyxDQUFDO2dDQUNwRSxJQUFJLENBQUMsU0FBUyxDQUFDLENBQUMsQ0FBQyxDQUFDLGNBQWMsQ0FBQyxJQUFJLENBQUMsV0FBVyxDQUFDLENBQUM7NkJBQ3REOzRCQUVHLFNBQVMsR0FBWSxJQUFJLENBQUM7NEJBQzFCLGFBQXdCLElBQUksQ0FBQyxTQUFTLENBQUMsU0FBUyxDQUFDLENBQUM7NEJBQ3RELElBQUksVUFBUSxFQUFFO2dDQUNWLFNBQVMsR0FBRyxhQUFhLENBQUMsVUFBUSxFQUFFLENBQUMsSUFBSSxFQUFFLElBQUksRUFBRSxJQUFJLEVBQUUsSUFBSSxDQUFDLENBQUMsQ0FBQztnQ0FDOUQsVUFBUSxDQUFDLElBQUksQ0FBQyxLQUFLLEdBQUcsQ0FBQyxDQUFDO2dDQUN4QixVQUFRLENBQUMsSUFBSSxDQUFDLE1BQU0sR0FBRyxDQUFDLENBQUM7Z0NBQ3pCLElBQUksQ0FBQyxjQUFjLENBQUMsVUFBUSxFQUFFLFNBQVMsRUFBRSxRQUFRLENBQUMsQ0FBQyxJQUFJLENBQUM7b0NBQ3BELFVBQVEsQ0FBQyxJQUFJLENBQUMsS0FBSyxHQUFHLFFBQVEsQ0FBQyxLQUFLLENBQUM7b0NBQ3JDLFVBQVEsQ0FBQyxJQUFJLENBQUMsTUFBTSxHQUFHLFFBQVEsQ0FBQyxNQUFNLENBQUM7Z0NBQzNDLENBQUMsQ0FBQyxDQUFDOzZCQUNOO3lCQUNKOzs7d0JBR0csY0FBcUIsSUFBSSxDQUFDO3dCQUM5QixJQUFJLElBQUksQ0FBQyxTQUFTLENBQUMsU0FBUyxDQUFDLEVBQUU7NEJBQzNCLFdBQVMsR0FBRyxhQUFhLENBQUMsSUFBSSxDQUFDLFNBQVMsQ0FBQyxTQUFTLENBQUMsRUFBRSxDQUFDLElBQUksRUFBRSxJQUFJLEVBQUUsSUFBSSxFQUFFLElBQUksQ0FBQyxDQUFDLENBQUM7eUJBQ2xGO3dCQUNHLElBQUksR0FBRyxJQUFJLEVBQUUsQ0FBQyxJQUFJLENBQUMsY0FBYyxDQUFDLENBQUE7d0JBQ3RDLElBQUksQ0FBQyxjQUFjLENBQUMsSUFBSSxDQUFDLE1BQU0sQ0FBQyxDQUFDO3dCQUNqQyxJQUFJLENBQUMsU0FBUyxDQUFDLElBQUksQ0FBQyxVQUFVLENBQUMsT0FBTyxDQUFDLENBQUM7d0JBQ3hDLElBQUksQ0FBQyxlQUFlLENBQUMsU0FBUyxDQUFDLENBQUM7d0JBQzVCLGFBQXdCLElBQUksUUFBUSxDQUFJLElBQUksRUFBRSxJQUFJLENBQUMsQ0FBQzt3QkFDeEQsSUFBSSxDQUFDLFNBQVMsQ0FBQyxNQUFNLENBQUMsU0FBUyxFQUFFLENBQUMsRUFBRSxVQUFRLENBQUMsQ0FBQTt3QkFDN0MsVUFBUSxDQUFDLElBQUksQ0FBQyxJQUFJLEVBQUUsUUFBUSxFQUFFLFNBQVMsRUFBRSxTQUFTLEVBQUUsSUFBSSxDQUFDLENBQUM7NkJBQ3RELENBQUMsV0FBUyxFQUFWLHdCQUFVO3dCQUNWLHFCQUFNLElBQUksT0FBTyxDQUFPLFVBQUMsT0FBTyxFQUFFLE1BQU07Z0NBQ3BDLHFCQUFxQixDQUFDO29DQUNsQixXQUFTLEdBQUcsYUFBYSxDQUFDLFVBQVEsRUFBRSxDQUFDLElBQUksRUFBRSxJQUFJLEVBQUUsSUFBSSxFQUFFLElBQUksQ0FBQyxDQUFDLENBQUM7b0NBQzlELE9BQU8sRUFBRSxDQUFDO2dDQUNkLENBQUMsQ0FBQyxDQUFBOzRCQUNOLENBQUMsQ0FBQyxFQUFBOzt3QkFMRixTQUtFLENBQUM7Ozt3QkFFUCxJQUFJLFdBQVMsRUFBRTs0QkFDWCxVQUFRLENBQUMsSUFBSSxDQUFDLEtBQUssR0FBRyxDQUFDLENBQUM7NEJBQ3hCLFVBQVEsQ0FBQyxJQUFJLENBQUMsTUFBTSxHQUFHLENBQUMsQ0FBQzs0QkFDekIsSUFBSSxDQUFDLGNBQWMsQ0FBQyxVQUFRLEVBQUUsV0FBUyxFQUFFLFFBQVEsQ0FBQyxDQUFDLElBQUksQ0FBQztnQ0FDcEQsVUFBUSxDQUFDLElBQUksQ0FBQyxLQUFLLEdBQUcsUUFBUSxDQUFDLEtBQUssQ0FBQztnQ0FDckMsVUFBUSxDQUFDLElBQUksQ0FBQyxNQUFNLEdBQUcsUUFBUSxDQUFDLE1BQU0sQ0FBQzs0QkFDM0MsQ0FBQyxDQUFDLENBQUM7eUJBQ047d0JBQ0QsSUFBSSxDQUFDLFlBQVksQ0FBQyxVQUFRLENBQUMsQ0FBQzs7Ozs7O0tBRW5DO0lBRUQ7Ozs7T0FJRztJQUNLLCtCQUFZLEdBQXBCLFVBQXFCLE1BQWUsRUFBRSxTQUF3QjtRQUMxRCxJQUFJLFNBQVMsR0FBRyxTQUFTLENBQUMsQ0FBQyxDQUFDLENBQUM7UUFDN0IsSUFBSSxPQUFPLEdBQUcsU0FBUyxDQUFDLFNBQVMsQ0FBQyxNQUFNLEdBQUcsQ0FBQyxDQUFDLENBQUM7UUFDOUMsSUFBSSxJQUFJLENBQUMsVUFBVSxDQUFDLFFBQVEsRUFBRTtZQUMxQixVQUFVO1lBQ1YsSUFBSSxNQUFNLENBQUMsQ0FBQyxHQUFHLENBQUMsRUFBRTtnQkFDZCxxQkFBcUI7Z0JBQ3JCLElBQUksSUFBSSxDQUFDLFVBQVUsQ0FBQyxPQUFPLENBQUMsQ0FBQyxJQUFJLENBQUMsQ0FBRSxJQUFJLENBQUMsU0FBUyxDQUFDLElBQUksQ0FBQyxTQUFTLENBQUMsTUFBTSxHQUFHLENBQUMsQ0FBQyxDQUFDLElBQUksQ0FBQyxDQUFDLEdBQUcsSUFBSSxDQUFDLFNBQVMsQ0FBQyxJQUFJLENBQUMsTUFBTSxDQUFDLElBQUksT0FBTyxDQUFDLFNBQVMsR0FBRyxJQUFJLENBQUMsS0FBSyxDQUFDLE1BQU0sR0FBRyxDQUFDLEVBQUU7b0JBQzdKLG1DQUFtQztvQkFDbkMsSUFBSSxTQUFTLEdBQUcsU0FBUyxDQUFDLFNBQVMsR0FBRyxDQUFDLENBQUM7b0JBQ3hDLFlBQVk7b0JBQ1osSUFBSSxLQUFLLEdBQUcsSUFBSSxDQUFDLEtBQUssQ0FBQyxNQUFNLEdBQUcsU0FBUyxDQUFDO29CQUMxQyw2Q0FBNkM7b0JBQzdDLElBQUksY0FBYyxHQUFHLElBQUksQ0FBQyxHQUFHLENBQUMsQ0FBQyxFQUFFLElBQUksQ0FBQyxTQUFTLENBQUMsTUFBTSxHQUFHLEtBQUssQ0FBQyxDQUFDO29CQUNoRSxnQkFBZ0I7b0JBQ2hCLElBQUksQ0FBQyxhQUFhLEdBQUcsU0FBUyxHQUFHLGNBQWMsQ0FBQztvQkFFaEQsSUFBSSxPQUFPLEdBQUcsYUFBYSxDQUFDLElBQUksQ0FBQyxTQUFTLENBQUMsU0FBUyxDQUFDLFNBQVMsQ0FBQyxFQUFFLENBQUMsSUFBSSxDQUFDLENBQUMsQ0FBQyxPQUFPLENBQUM7b0JBRWpGLElBQUksYUFBYSxHQUFHLENBQUMsQ0FBQztvQkFDdEIsSUFBSSxPQUFPLEdBQUcsQ0FBQyxDQUFDO29CQUNoQixJQUFJLFNBQVMsR0FBRyxJQUFJLENBQUM7b0JBQ3JCLElBQUksU0FBUyxHQUFHLENBQUMsQ0FBQztvQkFDbEIsS0FBSyxJQUFJLENBQUMsR0FBRyxDQUFDLEVBQUUsR0FBRyxHQUFHLElBQUksQ0FBQyxTQUFTLENBQUMsTUFBTSxFQUFFLENBQUMsR0FBRyxHQUFHLEVBQUUsRUFBRSxDQUFDLEVBQUU7d0JBQ3ZELElBQUksQ0FBQyxJQUFJLGNBQWMsRUFBRTs0QkFDckIsa0NBQWtDOzRCQUNsQyxJQUFJLFNBQVMsR0FBRyxTQUFTLENBQUMsTUFBTSxJQUFJLENBQUMsU0FBUyxFQUFFO2dDQUM1QyxJQUFJLFNBQVMsSUFBSSxDQUFDLEVBQUU7b0NBQ2hCLE9BQU8sR0FBRyxhQUFhLENBQUM7aUNBQzNCO2dDQUNELElBQUksUUFBUSxHQUFHLFNBQVMsQ0FBQyxTQUFTLENBQUMsQ0FBQyxZQUFZLEVBQUUsQ0FBQztnQ0FDbkQsU0FBUyxFQUFFLENBQUM7Z0NBQ1osSUFBSSxDQUFDLFNBQVMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxXQUFXLENBQUMsUUFBUSxDQUFDLENBQUM7NkJBQzNDOzRCQUNELFNBQVMsR0FBRyxLQUFLLENBQUM7eUJBQ3JCO3dCQUNELElBQUksU0FBUyxHQUFHLElBQUksQ0FBQyxhQUFhLEdBQUcsQ0FBQyxDQUFDO3dCQUN2QyxJQUFJLElBQUksR0FBRyxJQUFJLENBQUMsS0FBSyxDQUFDLFNBQVMsQ0FBQyxDQUFDO3dCQUNqQyxJQUFJLFFBQVEsR0FBRyxJQUFJLENBQUMsSUFBSSxDQUFDLENBQUMsQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLENBQUMsQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDO3dCQUNqRCxhQUFhLElBQUksUUFBUSxDQUFDLE1BQU0sQ0FBQzt3QkFDakMsSUFBSSxDQUFDLFNBQVMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxJQUFJLENBQUMsSUFBSSxFQUFFLFFBQVEsRUFBRSxTQUFTLEVBQUUsQ0FBQyxFQUFFLElBQUksQ0FBQyxDQUFDO3FCQUM5RDtvQkFFRCw0QkFBNEI7b0JBQzVCLElBQUksSUFBSSxHQUFHLE9BQU8sR0FBRyxDQUFDLE9BQU8sR0FBRyxJQUFJLENBQUMsU0FBUyxDQUFDLE9BQU8sQ0FBQyxDQUFBO29CQUN2RCxJQUFJLENBQUMsVUFBVSxDQUFDLE9BQU8sQ0FBQyxXQUFXLENBQUMsRUFBRSxDQUFDLEVBQUUsQ0FBQyxJQUFJLENBQUMsVUFBVSxDQUFDLE9BQU8sQ0FBQyxRQUFRLENBQUMsQ0FBQyxFQUFFLElBQUksQ0FBQyxDQUFDLENBQUM7b0JBQ3JGLElBQUksQ0FBQyxVQUFVLENBQUMsY0FBYyxDQUFDLEVBQUUsQ0FBQyxFQUFFLENBQUMsQ0FBQyxFQUFFLElBQUksR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLE1BQU0sQ0FBQyxFQUFFLENBQUMsQ0FBQyxDQUFBO29CQUN2RSxJQUFJLENBQUMsT0FBTyxHQUFHLElBQUksQ0FBQztpQkFDdkI7YUFDSixDQUFDLE1BQU07aUJBQ0gsSUFBSSxNQUFNLENBQUMsQ0FBQyxHQUFHLENBQUMsRUFBRTtnQkFDbkIsaUJBQWlCO2dCQUNqQixJQUFJLElBQUksQ0FBQyxVQUFVLENBQUMsT0FBTyxDQUFDLENBQUMsR0FBRyxDQUFDLENBQUUsSUFBSSxDQUFDLFNBQVMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxJQUFJLENBQUMsQ0FBQyxDQUFDLElBQUksU0FBUyxDQUFDLFNBQVMsR0FBRyxDQUFDLEVBQUU7b0JBQ3JGLDZCQUE2QjtvQkFDN0IsSUFBSSxZQUFZLEdBQUcsT0FBTyxDQUFDLFNBQVMsR0FBRyxDQUFDLENBQUM7b0JBQ3pDLDZDQUE2QztvQkFDN0MsSUFBSSxZQUFZLEdBQUcsSUFBSSxDQUFDLEdBQUcsQ0FBQyxJQUFJLENBQUMsU0FBUyxDQUFDLE1BQU0sR0FBRyxDQUFDLEVBQUUsWUFBWSxHQUFHLENBQUMsQ0FBQyxDQUFDO29CQUN6RSxnQkFBZ0I7b0JBQ2hCLElBQUksQ0FBQyxhQUFhLEdBQUcsSUFBSSxDQUFDLEdBQUcsQ0FBQyxZQUFZLEdBQUcsQ0FBQyxJQUFJLENBQUMsU0FBUyxDQUFDLE1BQU0sR0FBRyxDQUFDLENBQUMsRUFBRSxDQUFDLENBQUMsQ0FBQztvQkFFN0UsNEJBQTRCO29CQUM1QixJQUFJLE9BQU8sR0FBRyxhQUFhLENBQUMsSUFBSSxDQUFDLFNBQVMsQ0FBQyxTQUFTLENBQUMsU0FBUyxDQUFDLEVBQUUsQ0FBQyxJQUFJLENBQUMsQ0FBQyxDQUFDLE9BQU8sQ0FBQztvQkFFakYsSUFBSSxhQUFhLEdBQUcsQ0FBQyxDQUFDO29CQUN0QixJQUFJLFNBQVMsR0FBRyxTQUFTLENBQUMsTUFBTSxHQUFHLENBQUMsQ0FBQztvQkFDckMsS0FBSyxJQUFJLENBQUMsR0FBRyxJQUFJLENBQUMsU0FBUyxDQUFDLE1BQU0sR0FBRyxDQUFDLEVBQUUsQ0FBQyxJQUFJLENBQUMsRUFBRSxFQUFFLENBQUMsRUFBRTt3QkFDakQsSUFBSSxDQUFDLElBQUksWUFBWSxFQUFFOzRCQUNuQixrQ0FBa0M7NEJBQ2xDLElBQUksU0FBUyxJQUFJLENBQUMsRUFBRTtnQ0FDaEIsSUFBSSxRQUFRLEdBQUcsU0FBUyxDQUFDLFNBQVMsQ0FBQyxDQUFDLFlBQVksRUFBRSxDQUFDO2dDQUNuRCxTQUFTLEVBQUUsQ0FBQztnQ0FDWixJQUFJLENBQUMsU0FBUyxDQUFDLENBQUMsQ0FBQyxDQUFDLFdBQVcsQ0FBQyxRQUFRLENBQUMsQ0FBQzs2QkFDM0M7aUNBQU07Z0NBQ0gsU0FBUyxFQUFFLENBQUM7NkJBQ2Y7eUJBQ0o7d0JBQ0QsSUFBSSxTQUFTLEdBQUcsSUFBSSxDQUFDLGFBQWEsR0FBRyxDQUFDLENBQUM7d0JBQ3ZDLElBQUksSUFBSSxHQUFHLElBQUksQ0FBQyxLQUFLLENBQUMsU0FBUyxDQUFDLENBQUM7d0JBQ2pDLElBQUksUUFBUSxHQUFHLElBQUksQ0FBQyxJQUFJLENBQUMsQ0FBQyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsQ0FBQyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUM7d0JBQ2pELElBQUksU0FBUyxHQUFHLENBQUMsQ0FBQyxFQUFFOzRCQUNoQixhQUFhLElBQUksUUFBUSxDQUFDLE1BQU0sQ0FBQzt5QkFDcEM7d0JBQ0QsSUFBSSxDQUFDLFNBQVMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxJQUFJLENBQUMsSUFBSSxFQUFFLFFBQVEsRUFBRSxTQUFTLEVBQUUsQ0FBQyxFQUFFLElBQUksQ0FBQyxDQUFDO3FCQUM5RDtvQkFFRCw0QkFBNEI7b0JBQzVCLElBQUksSUFBSSxHQUFHLGFBQWEsR0FBRyxDQUFDLE9BQU8sR0FBRyxJQUFJLENBQUMsU0FBUyxDQUFDLE9BQU8sQ0FBQyxDQUFBO29CQUM3RCxJQUFJLENBQUMsVUFBVSxDQUFDLE9BQU8sQ0FBQyxXQUFXLENBQUMsRUFBRSxDQUFDLEVBQUUsQ0FBQyxJQUFJLENBQUMsVUFBVSxDQUFDLE9BQU8sQ0FBQyxRQUFRLENBQUMsQ0FBQyxFQUFFLElBQUksQ0FBQyxDQUFDLENBQUM7b0JBQ3JGLElBQUksQ0FBQyxVQUFVLENBQUMsY0FBYyxDQUFDLEVBQUUsQ0FBQyxFQUFFLENBQUMsQ0FBQyxFQUFFLElBQUksR0FBRyxTQUFTLENBQUMsSUFBSSxDQUFDLE1BQU0sQ0FBQyxFQUFFLENBQUMsQ0FBQyxDQUFBO29CQUN6RSxJQUFJLENBQUMsT0FBTyxHQUFHLElBQUksQ0FBQztpQkFDdkI7YUFDSjtTQUNKO2FBQU0sSUFBSSxJQUFJLENBQUMsVUFBVSxDQUFDLFVBQVUsRUFBRTtZQUNuQyxJQUFJLE1BQU0sQ0FBQyxDQUFDLEdBQUcsQ0FBQyxFQUFFO2dCQUNkLHFCQUFxQjtnQkFDckIsSUFBSSxJQUFJLENBQUMsVUFBVSxDQUFDLE9BQU8sQ0FBQyxDQUFDLElBQUksQ0FBQyxDQUFFLENBQUMsSUFBSSxDQUFDLFNBQVMsQ0FBQyxJQUFJLENBQUMsU0FBUyxDQUFDLE1BQU0sR0FBRyxDQUFDLENBQUMsQ0FBQyxJQUFJLENBQUMsQ0FBQyxHQUFHLElBQUksQ0FBQyxTQUFTLENBQUMsSUFBSSxDQUFDLEtBQUssQ0FBQyxDQUFDLElBQUksT0FBTyxDQUFDLFNBQVMsR0FBRyxJQUFJLENBQUMsS0FBSyxDQUFDLE1BQU0sR0FBRyxDQUFDLEVBQUU7b0JBQzlKLG1DQUFtQztvQkFDbkMsSUFBSSxTQUFTLEdBQUcsU0FBUyxDQUFDLFNBQVMsR0FBRyxDQUFDLENBQUM7b0JBQ3hDLFlBQVk7b0JBQ1osSUFBSSxLQUFLLEdBQUcsSUFBSSxDQUFDLEtBQUssQ0FBQyxNQUFNLEdBQUcsU0FBUyxDQUFDO29CQUMxQyw2Q0FBNkM7b0JBQzdDLElBQUksY0FBYyxHQUFHLElBQUksQ0FBQyxHQUFHLENBQUMsQ0FBQyxFQUFFLElBQUksQ0FBQyxTQUFTLENBQUMsTUFBTSxHQUFHLEtBQUssQ0FBQyxDQUFDO29CQUNoRSxnQkFBZ0I7b0JBQ2hCLElBQUksQ0FBQyxhQUFhLEdBQUcsU0FBUyxHQUFHLGNBQWMsQ0FBQztvQkFFaEQsSUFBSSxRQUFRLEdBQUcsYUFBYSxDQUFDLElBQUksQ0FBQyxTQUFTLENBQUMsU0FBUyxDQUFDLFNBQVMsQ0FBQyxFQUFFLENBQUMsS0FBSyxFQUFFLEtBQUssRUFBRSxJQUFJLENBQUMsQ0FBQyxDQUFDLFFBQVEsQ0FBQztvQkFFakcsSUFBSSxZQUFZLEdBQUcsQ0FBQyxDQUFDO29CQUNyQixJQUFJLE9BQU8sR0FBRyxDQUFDLENBQUM7b0JBQ2hCLElBQUksU0FBUyxHQUFHLElBQUksQ0FBQztvQkFDckIsSUFBSSxTQUFTLEdBQUcsQ0FBQyxDQUFDO29CQUNsQixLQUFLLElBQUksQ0FBQyxHQUFHLENBQUMsRUFBRSxHQUFHLEdBQUcsSUFBSSxDQUFDLFNBQVMsQ0FBQyxNQUFNLEVBQUUsQ0FBQyxHQUFHLEdBQUcsRUFBRSxFQUFFLENBQUMsRUFBRTt3QkFDdkQsSUFBSSxDQUFDLElBQUksY0FBYyxFQUFFOzRCQUNyQixrQ0FBa0M7NEJBQ2xDLElBQUksU0FBUyxHQUFHLFNBQVMsQ0FBQyxNQUFNLElBQUksQ0FBQyxTQUFTLEVBQUU7Z0NBQzVDLElBQUksU0FBUyxJQUFJLENBQUMsRUFBRTtvQ0FDaEIsT0FBTyxHQUFHLFlBQVksQ0FBQztpQ0FDMUI7Z0NBQ0QsSUFBSSxRQUFRLEdBQUcsU0FBUyxDQUFDLFNBQVMsQ0FBQyxDQUFDLFlBQVksRUFBRSxDQUFDO2dDQUNuRCxTQUFTLEVBQUUsQ0FBQztnQ0FDWixJQUFJLENBQUMsU0FBUyxDQUFDLENBQUMsQ0FBQyxDQUFDLFdBQVcsQ0FBQyxRQUFRLENBQUMsQ0FBQzs2QkFDM0M7NEJBQ0QsU0FBUyxHQUFHLEtBQUssQ0FBQzt5QkFDckI7d0JBQ0QsSUFBSSxTQUFTLEdBQUcsSUFBSSxDQUFDLGFBQWEsR0FBRyxDQUFDLENBQUM7d0JBQ3ZDLElBQUksSUFBSSxHQUFHLElBQUksQ0FBQyxLQUFLLENBQUMsU0FBUyxDQUFDLENBQUM7d0JBQ2pDLElBQUksUUFBUSxHQUFHLElBQUksQ0FBQyxJQUFJLENBQUMsQ0FBQyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsQ0FBQyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUM7d0JBQ2pELFlBQVksSUFBSSxRQUFRLENBQUMsS0FBSyxDQUFDO3dCQUMvQixJQUFJLENBQUMsU0FBUyxDQUFDLENBQUMsQ0FBQyxDQUFDLElBQUksQ0FBQyxJQUFJLEVBQUUsUUFBUSxFQUFFLFNBQVMsRUFBRSxDQUFDLEVBQUUsSUFBSSxDQUFDLENBQUM7cUJBQzlEO29CQUVELDRCQUE0QjtvQkFDNUIsSUFBSSxJQUFJLEdBQUcsQ0FBQyxRQUFRLEdBQUcsSUFBSSxDQUFDLFNBQVMsQ0FBQyxRQUFRLENBQUMsR0FBRyxPQUFPLENBQUM7b0JBQzFELElBQUksQ0FBQyxVQUFVLENBQUMsT0FBTyxDQUFDLFdBQVcsQ0FBQyxFQUFFLENBQUMsRUFBRSxDQUFDLElBQUksRUFBRSxJQUFJLENBQUMsVUFBVSxDQUFDLE9BQU8sQ0FBQyxRQUFRLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQztvQkFDckYsSUFBSSxDQUFDLFVBQVUsQ0FBQyxjQUFjLENBQUMsRUFBRSxDQUFDLEVBQUUsQ0FBQyxDQUFDLENBQUMsSUFBSSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsS0FBSyxDQUFDLEVBQUUsQ0FBQyxDQUFDLEVBQUUsQ0FBQyxDQUFDLENBQUE7b0JBQ3pFLElBQUksQ0FBQyxPQUFPLEdBQUcsSUFBSSxDQUFDO2lCQUN2QjthQUNKO2lCQUFNLElBQUksTUFBTSxDQUFDLENBQUMsR0FBRyxDQUFDLEVBQUU7Z0JBQ3JCLGlCQUFpQjtnQkFDakIsSUFBSSxJQUFJLENBQUMsVUFBVSxDQUFDLE9BQU8sQ0FBQyxDQUFDLEdBQUcsQ0FBQyxDQUFDLElBQUksQ0FBQyxTQUFTLENBQUMsQ0FBQyxDQUFDLENBQUMsSUFBSSxDQUFDLENBQUMsQ0FBQyxJQUFJLFNBQVMsQ0FBQyxTQUFTLEdBQUcsQ0FBQyxFQUFFO29CQUNwRiw2QkFBNkI7b0JBQzdCLElBQUksWUFBWSxHQUFHLE9BQU8sQ0FBQyxTQUFTLEdBQUcsQ0FBQyxDQUFDO29CQUN6Qyw2Q0FBNkM7b0JBQzdDLElBQUksWUFBWSxHQUFHLElBQUksQ0FBQyxHQUFHLENBQUMsSUFBSSxDQUFDLFNBQVMsQ0FBQyxNQUFNLEdBQUcsQ0FBQyxFQUFFLFlBQVksR0FBRyxDQUFDLENBQUMsQ0FBQztvQkFDekUsZ0JBQWdCO29CQUNoQixJQUFJLENBQUMsYUFBYSxHQUFHLElBQUksQ0FBQyxHQUFHLENBQUMsWUFBWSxHQUFHLENBQUMsSUFBSSxDQUFDLFNBQVMsQ0FBQyxNQUFNLEdBQUcsQ0FBQyxDQUFDLEVBQUUsQ0FBQyxDQUFDLENBQUM7b0JBRTdFLDRCQUE0QjtvQkFDNUIsSUFBSSxRQUFRLEdBQUcsYUFBYSxDQUFDLElBQUksQ0FBQyxTQUFTLENBQUMsU0FBUyxDQUFDLFNBQVMsQ0FBQyxFQUFFLENBQUMsS0FBSyxFQUFFLEtBQUssRUFBRSxJQUFJLENBQUMsQ0FBQyxDQUFDLFFBQVEsQ0FBQztvQkFFakcsSUFBSSxZQUFZLEdBQUcsQ0FBQyxDQUFDO29CQUNyQixJQUFJLFNBQVMsR0FBRyxTQUFTLENBQUMsTUFBTSxHQUFHLENBQUMsQ0FBQztvQkFDckMsS0FBSyxJQUFJLENBQUMsR0FBRyxJQUFJLENBQUMsU0FBUyxDQUFDLE1BQU0sR0FBRyxDQUFDLEVBQUUsQ0FBQyxJQUFJLENBQUMsRUFBRSxFQUFFLENBQUMsRUFBRTt3QkFDakQsSUFBSSxDQUFDLElBQUksWUFBWSxFQUFFOzRCQUNuQixrQ0FBa0M7NEJBQ2xDLElBQUksU0FBUyxJQUFJLENBQUMsRUFBRTtnQ0FDaEIsSUFBSSxRQUFRLEdBQUcsU0FBUyxDQUFDLFNBQVMsQ0FBQyxDQUFDLFlBQVksRUFBRSxDQUFDO2dDQUNuRCxTQUFTLEVBQUUsQ0FBQztnQ0FDWixJQUFJLENBQUMsU0FBUyxDQUFDLENBQUMsQ0FBQyxDQUFDLFdBQVcsQ0FBQyxRQUFRLENBQUMsQ0FBQzs2QkFDM0M7aUNBQU07Z0NBQ0gsU0FBUyxFQUFFLENBQUM7NkJBQ2Y7eUJBQ0o7d0JBQ0QsSUFBSSxTQUFTLEdBQUcsSUFBSSxDQUFDLGFBQWEsR0FBRyxDQUFDLENBQUM7d0JBQ3ZDLElBQUksSUFBSSxHQUFHLElBQUksQ0FBQyxLQUFLLENBQUMsU0FBUyxDQUFDLENBQUM7d0JBQ2pDLElBQUksUUFBUSxHQUFHLElBQUksQ0FBQyxJQUFJLENBQUMsQ0FBQyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsQ0FBQyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUM7d0JBQ2pELElBQUksU0FBUyxHQUFHLENBQUMsQ0FBQyxFQUFFOzRCQUNoQixZQUFZLElBQUksUUFBUSxDQUFDLEtBQUssQ0FBQzt5QkFDbEM7d0JBQ0QsSUFBSSxDQUFDLFNBQVMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxJQUFJLENBQUMsSUFBSSxFQUFFLFFBQVEsRUFBRSxTQUFTLEVBQUUsQ0FBQyxFQUFFLElBQUksQ0FBQyxDQUFDO3FCQUM5RDtvQkFFRCw0QkFBNEI7b0JBQzVCLElBQUksSUFBSSxHQUFHLENBQUMsUUFBUSxHQUFHLElBQUksQ0FBQyxTQUFTLENBQUMsUUFBUSxDQUFDLEdBQUcsWUFBWSxDQUFDO29CQUMvRCxJQUFJLENBQUMsVUFBVSxDQUFDLE9BQU8sQ0FBQyxXQUFXLENBQUMsRUFBRSxDQUFDLEVBQUUsQ0FBQyxJQUFJLEVBQUUsSUFBSSxDQUFDLFVBQVUsQ0FBQyxPQUFPLENBQUMsUUFBUSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUM7b0JBQ3JGLElBQUksQ0FBQyxVQUFVLENBQUMsY0FBYyxDQUFDLEVBQUUsQ0FBQyxFQUFFLENBQUMsQ0FBRSxDQUFDLElBQUksR0FBRyxTQUFTLENBQUMsSUFBSSxDQUFDLEtBQUssQ0FBQyxFQUFFLENBQUMsQ0FBQyxFQUFFLENBQUMsQ0FBQyxDQUFBO29CQUM1RSxJQUFJLENBQUMsT0FBTyxHQUFHLElBQUksQ0FBQztpQkFDdkI7YUFDSjtTQUNKO0lBQ0wsQ0FBQztJQUdELGFBQWE7SUFDTiw4QkFBVyxHQUFsQjtRQUNJLElBQUksU0FBUyxHQUFrQixFQUFFLENBQUM7UUFDbEMsS0FBSyxJQUFJLENBQUMsR0FBRyxDQUFDLEVBQUUsR0FBRyxHQUFHLElBQUksQ0FBQyxTQUFTLENBQUMsTUFBTSxFQUFFLENBQUMsR0FBRyxHQUFHLEVBQUUsRUFBRSxDQUFDLEVBQUU7WUFDdkQsSUFBSSxRQUFRLEdBQUcsSUFBSSxDQUFDLFNBQVMsQ0FBQyxDQUFDLENBQUMsQ0FBQztZQUNqQyxJQUFJLE1BQU0sR0FBRyxJQUFJLENBQUMsWUFBWSxDQUFDLFFBQVEsQ0FBQyxDQUFBO1lBQ3hDLElBQUksTUFBTSxFQUFFO2dCQUNSLFNBQVMsQ0FBQyxJQUFJLENBQUMsUUFBUSxDQUFDLENBQUE7YUFDM0I7U0FDSjtRQUNELE9BQU8sU0FBUyxDQUFDO0lBQ3JCLENBQUM7SUFFRDs7O09BR0c7SUFDSywrQkFBWSxHQUFwQixVQUFxQixRQUFxQjtRQUN0QyxJQUFJLFFBQVEsRUFBRTtZQUNWLElBQUksTUFBTSxHQUFHLElBQUksQ0FBQyxXQUFXLENBQUMsUUFBUSxDQUFDLENBQUM7WUFDeEMsSUFBSSxNQUFNLEVBQUU7Z0JBQ1IsUUFBUSxDQUFDLFNBQVMsSUFBSSxRQUFRLENBQUMsVUFBVSxDQUFDLE1BQU0sRUFBRSxJQUFJLENBQUMsTUFBTSxFQUFFLElBQUksQ0FBQyxZQUFZLENBQUMsTUFBTSxHQUFHLENBQUMsQ0FBQyxDQUFDLENBQUMsSUFBSSxDQUFDLFlBQVksQ0FBQyxHQUFHLEVBQUUsQ0FBQyxDQUFDLENBQUMsSUFBSSxFQUFFLElBQUksQ0FBQyxXQUFXLENBQUMsQ0FBQzthQUNuSjtpQkFBTTtnQkFDSCxDQUFDLFFBQVEsQ0FBQyxTQUFTLElBQUksSUFBSSxDQUFDLGdCQUFnQixDQUFDLFFBQVEsQ0FBQyxRQUFRLEVBQUUsQ0FBQyxDQUFDO2FBQ3JFO1lBQ0QsT0FBTyxNQUFNLENBQUM7U0FDakI7SUFDTCxDQUFDO0lBR0Q7Ozs7T0FJRztJQUNLLDhCQUFXLEdBQW5CLFVBQW9CLFFBQXFCO1FBQ3JDLElBQUksU0FBUyxHQUFHLGFBQWEsQ0FBQyxRQUFRLEVBQUUsQ0FBQyxJQUFJLEVBQUUsSUFBSSxFQUFFLElBQUksRUFBRSxJQUFJLENBQUMsQ0FBQyxDQUFDO1FBQ2xFLHFDQUFxQztRQUNyQyxJQUFJLGlCQUFpQixHQUFHLFNBQVMsQ0FBQyxTQUFTLEdBQUcsSUFBSSxDQUFDLFNBQVMsQ0FBQyxRQUFRO2VBQzlELFNBQVMsQ0FBQyxRQUFRLEdBQUcsSUFBSSxDQUFDLFNBQVMsQ0FBQyxTQUFTLENBQUM7UUFFckQsSUFBSSxlQUFlLEdBQUcsS0FBSyxDQUFDO1FBQzVCLElBQUksQ0FBQyxpQkFBaUIsRUFBRTtZQUNwQixvQ0FBb0M7WUFDcEMsZUFBZSxHQUFHLFNBQVMsQ0FBQyxPQUFPLEdBQUcsSUFBSSxDQUFDLFNBQVMsQ0FBQyxVQUFVO21CQUN4RCxTQUFTLENBQUMsVUFBVSxHQUFHLElBQUksQ0FBQyxTQUFTLENBQUMsT0FBTyxDQUFDO1NBQ3hEO1FBQ0QsT0FBTyxDQUFDLGlCQUFpQixJQUFJLENBQUMsZUFBZSxDQUFDO0lBQ2xELENBQUM7SUFDRDs7Ozs7T0FLRztJQUNVLGlDQUFjLEdBQTNCLFVBQTRCLElBQWlCLEVBQUUsU0FBa0IsRUFBRSxVQUFtQixFQUFFLElBQWtCO1FBQWxCLHFCQUFBLEVBQUEsVUFBa0I7Ozs7Ozt3QkFDbEcsa0JBQWtCLEdBQUcsQ0FBQyxJQUFJLENBQUMsVUFBVSxDQUFDLE9BQU8sQ0FBQyxPQUFPLElBQUksQ0FBQyxJQUFJLFNBQVMsQ0FBQyxVQUFVLElBQUksSUFBSSxDQUFDLFNBQVMsQ0FBQyxPQUFPLENBQUMsQ0FBQzt3QkFDOUcsa0JBQWtCLEdBQUcsQ0FBQyxJQUFJLENBQUMsVUFBVSxDQUFDLE9BQU8sQ0FBQyxPQUFPLElBQUksQ0FBQyxJQUFJLFNBQVMsQ0FBQyxPQUFPLElBQUksSUFBSSxDQUFDLFNBQVMsQ0FBQyxVQUFVLENBQUMsQ0FBQzt3QkFDbEgsSUFBSSxrQkFBa0IsSUFBSSxrQkFBa0IsRUFBRTs0QkFDMUMsSUFBSSxrQkFBa0IsRUFBRTtnQ0FDcEIsSUFBSSxDQUFDLFVBQVUsQ0FBQyxrQkFBa0IsQ0FBQyxFQUFFLENBQUMsRUFBRSxDQUFDLElBQUksQ0FBQyxVQUFVLENBQUMsT0FBTyxDQUFDLENBQUMsRUFBRSxJQUFJLENBQUMsVUFBVSxDQUFDLE9BQU8sQ0FBQyxDQUFDLEdBQUcsVUFBVSxDQUFDLE1BQU0sQ0FBQyxDQUFDLENBQUE7NkJBQ3RIO2lDQUFNO2dDQUNILElBQUksQ0FBQyxVQUFVLENBQUMsa0JBQWtCLENBQUMsRUFBRSxDQUFDLEVBQUUsQ0FBQyxJQUFJLENBQUMsVUFBVSxDQUFDLE9BQU8sQ0FBQyxDQUFDLEVBQUUsSUFBSSxDQUFDLFVBQVUsQ0FBQyxPQUFPLENBQUMsQ0FBQyxHQUFHLFVBQVUsQ0FBQyxNQUFNLENBQUMsQ0FBQyxDQUFBOzZCQUN0SDt5QkFDSjt3QkFDRyxrQkFBa0IsR0FBRyxDQUFDLElBQUksQ0FBQyxVQUFVLENBQUMsT0FBTyxDQUFDLE9BQU8sSUFBSSxDQUFDLElBQUksU0FBUyxDQUFDLFNBQVMsSUFBSSxJQUFJLENBQUMsU0FBUyxDQUFDLFFBQVEsQ0FBQyxDQUFDO3dCQUM5RyxrQkFBa0IsR0FBRyxDQUFDLElBQUksQ0FBQyxVQUFVLENBQUMsT0FBTyxDQUFDLE9BQU8sSUFBSSxDQUFDLElBQUksU0FBUyxDQUFDLFFBQVEsSUFBSSxJQUFJLENBQUMsU0FBUyxDQUFDLFNBQVMsQ0FBQyxDQUFDO3dCQUNsSCxJQUFJLGtCQUFrQixJQUFJLGtCQUFrQixFQUFFOzRCQUMxQyxJQUFJLGtCQUFrQixFQUFFO2dDQUNwQixJQUFJLENBQUMsVUFBVSxDQUFDLGtCQUFrQixDQUFDLEVBQUUsQ0FBQyxFQUFFLENBQUMsSUFBSSxDQUFDLFVBQVUsQ0FBQyxPQUFPLENBQUMsQ0FBQyxHQUFHLFVBQVUsQ0FBQyxLQUFLLEVBQUUsSUFBSSxDQUFDLFVBQVUsQ0FBQyxPQUFPLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQTs2QkFDckg7aUNBQU07Z0NBQ0gsSUFBSSxDQUFDLFVBQVUsQ0FBQyxrQkFBa0IsQ0FBQyxFQUFFLENBQUMsRUFBRSxDQUFDLElBQUksQ0FBQyxVQUFVLENBQUMsT0FBTyxDQUFDLENBQUMsR0FBRyxVQUFVLENBQUMsS0FBSyxFQUFFLElBQUksQ0FBQyxVQUFVLENBQUMsT0FBTyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUE7NkJBQ3JIO3lCQUNKOzZCQUNHLENBQUMsQ0FBQyxrQkFBa0IsSUFBSSxrQkFBa0IsSUFBSSxrQkFBa0IsSUFBSSxrQkFBa0IsQ0FBQyxFQUF2Rix3QkFBdUY7d0JBQ3ZGLEVBQUUsQ0FBQyxLQUFLLENBQUMsZUFBZSxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsQ0FBQzt3QkFDcEMscUJBQU0sSUFBSSxPQUFPLENBQU8sVUFBQyxPQUFPLEVBQUUsTUFBTTtnQ0FDcEMsRUFBRSxDQUFDLEtBQUssQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLENBQUMsRUFBRSxDQUFDLElBQUksRUFBRSxFQUFFLEtBQUssRUFBRSxJQUFJLENBQUMsSUFBSSxDQUFDLEtBQUssRUFBRSxNQUFNLEVBQUUsSUFBSSxDQUFDLElBQUksQ0FBQyxNQUFNLEVBQUUsQ0FBQyxDQUFDLElBQUksQ0FBQztvQ0FDcEYsT0FBTyxFQUFFLENBQUM7Z0NBQ2QsQ0FBQyxDQUFDLENBQUMsS0FBSyxFQUFFLENBQUM7NEJBQ2YsQ0FBQyxDQUFDLEVBQUE7O3dCQUpGLFNBSUUsQ0FBQTs7O3dCQUVOLElBQUksQ0FBQyxXQUFXLEVBQUUsQ0FBQzt3QkFDbkIsc0JBQU8sSUFBSSxFQUFDOzs7O0tBQ2Y7SUFFRDs7O09BR0c7SUFDSyxtQ0FBZ0IsR0FBeEIsVUFBeUIsSUFBaUI7UUFDdEMsSUFBSSxJQUFJLElBQUksQ0FBQyxZQUFZLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxDQUFDO0lBQ3pDLENBQUM7SUFFRDs7T0FFRztJQUNJLDJCQUFRLEdBQWY7UUFDSSxJQUFJLENBQUMsVUFBVSxDQUFDLElBQUksQ0FBQyxHQUFHLENBQUMsV0FBVyxFQUFFLElBQUksQ0FBQyxpQkFBaUIsQ0FBQyxDQUFDO1FBQzlELEtBQUssSUFBSSxDQUFDLEdBQUcsQ0FBQyxFQUFFLEdBQUcsR0FBRyxJQUFJLENBQUMsU0FBUyxDQUFDLE1BQU0sRUFBRSxDQUFDLEdBQUcsR0FBRyxFQUFFLEVBQUUsQ0FBQyxFQUFFO1lBQ3ZELElBQUksQ0FBQyxnQkFBZ0IsQ0FBQyxJQUFJLENBQUMsU0FBUyxDQUFDLENBQUMsQ0FBQyxDQUFDLFFBQVEsRUFBRSxDQUFDLENBQUM7WUFDcEQsSUFBSSxDQUFDLFNBQVMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxPQUFPLEVBQUUsQ0FBQztTQUMvQjtRQUNELElBQUksQ0FBQyxTQUFTLEdBQUcsRUFBRSxDQUFDO1FBQ3BCLEtBQUssSUFBSSxLQUFLLEdBQUcsQ0FBQyxFQUFFLEdBQUcsR0FBRyxJQUFJLENBQUMsWUFBWSxDQUFDLE1BQU0sRUFBRSxLQUFLLEdBQUcsR0FBRyxFQUFFLEVBQUUsS0FBSyxFQUFFO1lBQ3RFLElBQUksQ0FBQyxZQUFZLENBQUMsS0FBSyxDQUFDLENBQUMsT0FBTyxFQUFFLENBQUM7U0FDdEM7UUFDRCxJQUFJLENBQUMsWUFBWSxHQUFHLEVBQUUsQ0FBQztRQUN2QixJQUFJLENBQUMsV0FBVyxHQUFHLElBQUksQ0FBQztRQUN4QixJQUFJLENBQUMsVUFBVSxHQUFHLElBQUksQ0FBQztRQUN2QixJQUFJLENBQUMsTUFBTSxHQUFHLElBQUksQ0FBQztJQUN2QixDQUFDO0lBempCYSxlQUFNLEdBQStCLElBQUksR0FBRyxFQUFFLENBQUM7SUEyakJqRSxlQUFDO0NBNWpCRCxBQTRqQkMsSUFBQTtrQkE1akJvQixRQUFRO0FBNmpCN0I7Ozs7R0FJRztBQUNILFNBQVMsYUFBYSxDQUFDLElBQW1CLEVBQUUsT0FBa0I7SUFDMUQsSUFBSSxJQUFJLEdBQUcsSUFBSSxDQUFDLElBQUksQ0FBQTtJQUNwQixJQUFJLFNBQVMsR0FBWSxFQUFFLENBQUM7SUFDNUIsSUFBSSxJQUFJLEdBQUcsV0FBVyxDQUFDLElBQUksQ0FBQyxDQUFDO0lBQzdCLFNBQVM7SUFDVCxJQUFJLE9BQU8sQ0FBQyxDQUFDLENBQUMsRUFBRTtRQUNaLFNBQVMsQ0FBQyxPQUFPLEdBQUcsSUFBSSxDQUFDLENBQUMsR0FBRyxDQUFDLElBQUksQ0FBQyxNQUFNLEdBQUcsQ0FBQyxDQUFDLEdBQUcsSUFBSSxDQUFDLE9BQU8sQ0FBQyxDQUFDLENBQUM7S0FDbkU7SUFDRCxTQUFTO0lBQ1QsSUFBSSxPQUFPLENBQUMsQ0FBQyxDQUFDLEVBQUU7UUFDWixTQUFTLENBQUMsVUFBVSxHQUFHLElBQUksQ0FBQyxDQUFDLEdBQUcsQ0FBQyxJQUFJLENBQUMsTUFBTSxHQUFHLElBQUksQ0FBQyxPQUFPLENBQUMsQ0FBQztLQUNoRTtJQUNELFNBQVM7SUFDVCxJQUFJLE9BQU8sQ0FBQyxDQUFDLENBQUMsRUFBRTtRQUNaLFNBQVMsQ0FBQyxRQUFRLEdBQUcsSUFBSSxDQUFDLENBQUMsR0FBRyxDQUFDLElBQUksQ0FBQyxLQUFLLEdBQUcsSUFBSSxDQUFDLE9BQU8sQ0FBQyxDQUFDO0tBQzdEO0lBQ0QsU0FBUztJQUNULElBQUksT0FBTyxDQUFDLENBQUMsQ0FBQyxFQUFFO1FBQ1osU0FBUyxDQUFDLFNBQVMsR0FBRyxJQUFJLENBQUMsQ0FBQyxHQUFHLENBQUMsSUFBSSxDQUFDLEtBQUssR0FBRyxDQUFDLENBQUMsR0FBRyxJQUFJLENBQUMsT0FBTyxDQUFDLENBQUMsQ0FBQztLQUNwRTtJQUNELFNBQVMsQ0FBQyxJQUFJLEdBQUcsRUFBRSxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsS0FBSyxFQUFFLElBQUksQ0FBQyxNQUFNLENBQUMsQ0FBQztJQUNsRCxPQUFPLFNBQVMsQ0FBQztBQUNyQixDQUFDO0FBRUQ7Ozs7R0FJRztBQUNILFNBQVMsV0FBVyxDQUFDLElBQWE7SUFDOUIsT0FBTyxJQUFJLENBQUMsTUFBTSxDQUFDLHFCQUFxQixDQUFDLElBQUksQ0FBQyxRQUFRLENBQUMsQ0FBQztBQUM1RCxDQUFDIiwiZmlsZSI6IiIsInNvdXJjZVJvb3QiOiIvIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IFJlbmRlckFsdGVybmF0aXZlIGZyb20gXCIuL1JlbmRlckFsdGVybmF0aXZlXCI7XHJcblxyXG5pbnRlcmZhY2UgSUJvcmRlciB7XHJcbiAgICBsZWZ0U2lkZT86IG51bWJlcjtcclxuICAgIHJpZ2h0U2lkZT86IG51bWJlcjtcclxuICAgIGJvdHRvbVNpZGU/OiBudW1iZXI7XHJcbiAgICB0b3BTaWRlPzogbnVtYmVyO1xyXG4gICAgc2l6ZT86IGNjLlNpemU7XHJcbn1cclxudHlwZSBURGF0ZSA9IHsgc2l6ZT86IGNjLlNpemUgfTtcclxuZXhwb3J0IGNsYXNzIFNob3dOb2RlPFQgZXh0ZW5kcyBURGF0ZT4gZXh0ZW5kcyBjYy5Db21wb25lbnQge1xyXG4gICAgLyoq5piv5ZCm5Yid5aeL5YyW6L+H5Luj55CG57uE5bu6ICovXHJcbiAgICBwcml2YXRlIGhhc0luaXQ6IGJvb2xlYW4gPSBmYWxzZTtcclxuICAgIC8qKua4suafk+WIhuWxguW8gOWQr+eahOaMgui9veiKgueCuSAqL1xyXG4gICAgcHVibGljIHJlbmRlckxheWVyOiBjYy5Ob2RlO1xyXG4gICAgLyoq5LiK57qn55qEY2VsbCAqL1xyXG4gICAgcHVibGljIGNlbGw6IEl0ZW1DZWxsPFQ+O1xyXG4gICAgLyoq5pWw5o2uICovXHJcbiAgICBwdWJsaWMgZGF0YTogVDtcclxuICAgIC8qKuWIneWni+WMliAqL1xyXG4gICAgcHVibGljIGluaXQoY2VsbDogSXRlbUNlbGw8VD4sIGRhdGE6IFQsIHJlbmRlckxheWVyOiBjYy5Ob2RlKSB7XHJcbiAgICAgICAgdGhpcy5jZWxsID0gY2VsbDtcclxuICAgICAgICB0aGlzLmRhdGEgPSBkYXRhO1xyXG4gICAgICAgIGlmICh0aGlzLnJlbmRlckxheWVyICE9IHJlbmRlckxheWVyKSB7XHJcbiAgICAgICAgICAgIHRoaXMucmVuZGVyTGF5ZXIgPSByZW5kZXJMYXllcjtcclxuICAgICAgICAgICAgcmVuZGVyTGF5ZXIgJiYgdGhpcy5pbml0UmVuZGVycygpO1xyXG4gICAgICAgIH1cclxuICAgICAgICB0aGlzLmluaXRTaG93KCk7XHJcbiAgICB9XHJcbiAgICAvKirliJ3lp4vljJbmk43kvZwgKi9cclxuICAgIGluaXRTaG93KCkgeyB9XHJcbiAgICAvKirooqvlm57mlLbvvIzlupTor6XlgZrkuIDkupvph4rmlL7nmoTmk43kvZwgKi9cclxuICAgIG9uUmVjaXJjbGUoKSB7IH1cclxuXHJcbiAgICAvKipcclxuICAgICAqIOWcqOeJueWumuaXtumXtOWGhei/m+ihjOWkp+Wwj+WPmOWMllxyXG4gICAgICogQHBhcmFtIHRhcmdldFNpemUgXHJcbiAgICAgKiBAcGFyYW0gdGltZSBcclxuICAgICAqL1xyXG4gICAgcHVibGljIHJlc2l6ZSh0YXJnZXRTaXplOiBjYy5TaXplLCB0aW1lOiBudW1iZXIgPSAwLjMpIHtcclxuICAgICAgICB0aGlzLmNlbGwucmVzaXplKHRhcmdldFNpemUsIHRpbWUpO1xyXG4gICAgfVxyXG4gICAgLyoqXHJcbiAgICAgKiDlpITnkIbliIblsYLku6PnkIbmuLLmn5NcclxuICAgICAqL1xyXG4gICAgcHJpdmF0ZSBpbml0UmVuZGVycygpIHtcclxuICAgICAgICBpZiAoIXRoaXMuaGFzSW5pdCAmJiB0aGlzLnJlbmRlckxheWVyKSB7XHJcbiAgICAgICAgICAgIGxldCBwcm9wTWFwOiBXZWFrTWFwPFJlbmRlckFsdGVybmF0aXZlLCBib29sZWFuPiA9IG5ldyBXZWFrTWFwKCk7XHJcbiAgICAgICAgICAgIGxldCBrZXlzID0gT2JqZWN0LmtleXModGhpcyk7XHJcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBsZW4gPSBrZXlzLmxlbmd0aDsgaSA8IGxlbjsgKytpKSB7XHJcbiAgICAgICAgICAgICAgICBsZXQgdmFsdWUgPSB0aGlzW2tleXNbaV1dO1xyXG4gICAgICAgICAgICAgICAgbGV0IGFsdGVybmF0aXZlOiBSZW5kZXJBbHRlcm5hdGl2ZSA9IG51bGw7XHJcbiAgICAgICAgICAgICAgICBpZiAodmFsdWUgaW5zdGFuY2VvZiBjYy5Ob2RlKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgYWx0ZXJuYXRpdmUgPSB2YWx1ZS5nZXRDb21wb25lbnQoUmVuZGVyQWx0ZXJuYXRpdmUpO1xyXG4gICAgICAgICAgICAgICAgICAgIGlmIChhbHRlcm5hdGl2ZSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBhbHRlcm5hdGl2ZS5pbml0KHRoaXMucmVuZGVyTGF5ZXIpO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAodmFsdWUgaW5zdGFuY2VvZiBjYy5SZW5kZXJDb21wb25lbnQpIHtcclxuICAgICAgICAgICAgICAgICAgICBhbHRlcm5hdGl2ZSA9IHZhbHVlLmdldENvbXBvbmVudChSZW5kZXJBbHRlcm5hdGl2ZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKGFsdGVybmF0aXZlKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXNba2V5c1tpXV0gPSBhbHRlcm5hdGl2ZS5pbml0PHR5cGVvZiB2YWx1ZT4odGhpcy5yZW5kZXJMYXllcik7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgYWx0ZXJuYXRpdmUgJiYgcHJvcE1hcC5zZXQoYWx0ZXJuYXRpdmUsIHRydWUpO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIHRoaXMuZGVhbENoaWxyZW5BbHRlcm5hdGl2ZSh0aGlzLm5vZGUsIHByb3BNYXAsIDAsIDApO1xyXG4gICAgICAgICAgICB0aGlzLmhhc0luaXQgPSB0cnVlO1xyXG4gICAgICAgIH1cclxuICAgIH1cclxuICAgIC8qKlxyXG4gICAgICog5aSE55CG5a2Q6IqC54K55Luj55CGXHJcbiAgICAgKiBAcGFyYW0gbm9kZSBcclxuICAgICAqIEBwYXJhbSBwcm9wTWFwIOiusOW9leiEmuacrOW3sue7j+WkhOeQhui/h+eahOWxnuaAp+S7o+eQhlxyXG4gICAgICogQHBhcmFtIHBhcmVudFNpbmRleCDniLboioLngrnnmoTmiYDlnKjnmoTpobrluo9cclxuICAgICAqIEBwYXJhbSBkZXB0aCDmt7HluqZcclxuICAgICAqL1xyXG4gICAgZGVhbENoaWxyZW5BbHRlcm5hdGl2ZShub2RlOiBjYy5Ob2RlLCBwcm9wTWFwOiBXZWFrTWFwPFJlbmRlckFsdGVybmF0aXZlLCBib29sZWFuPiwgcGFyZW50U2luZGV4OiBudW1iZXIsIGRlcHRoOiBudW1iZXIpIHtcclxuICAgICAgICBmb3IgKGxldCBpID0gMCwgbGVuID0gbm9kZS5jaGlsZHJlbi5sZW5ndGg7IGkgPCBsZW47IGkrKykge1xyXG4gICAgICAgICAgICBsZXQgY2hpbGRyZW4gPSBub2RlLmNoaWxkcmVuW2ldO1xyXG4gICAgICAgICAgICBsZXQgYWx0ZXJuYXRpdmUgPSBjaGlsZHJlbi5nZXRDb21wb25lbnQoY2MuUmVuZGVyQ29tcG9uZW50KT8uZ2V0Q29tcG9uZW50KFJlbmRlckFsdGVybmF0aXZlKTtcclxuICAgICAgICAgICAgbGV0IHNJbmRleCA9IHBhcmVudFNpbmRleCArIChpICogTWF0aC5wb3coMC4xLCBkZXB0aCkpO1xyXG4gICAgICAgICAgICBpZiAoYWx0ZXJuYXRpdmUpIHtcclxuICAgICAgICAgICAgICAgIGlmICgoIXByb3BNYXAuaGFzKGFsdGVybmF0aXZlKSB8fCAhcHJvcE1hcC5nZXQoYWx0ZXJuYXRpdmUpKSkge1xyXG4gICAgICAgICAgICAgICAgICAgIGFsdGVybmF0aXZlLmluaXQodGhpcy5yZW5kZXJMYXllcik7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICBhbHRlcm5hdGl2ZS5zSW5kZXggPSBzSW5kZXg7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgdGhpcy5kZWFsQ2hpbHJlbkFsdGVybmF0aXZlKGNoaWxkcmVuLCBwcm9wTWFwLCBzSW5kZXgsIGRlcHRoICsgMSk7XHJcbiAgICAgICAgfVxyXG4gICAgfVxyXG59XHJcbmV4cG9ydCBjbGFzcyBJdGVtQ2VsbDxUIGV4dGVuZHMgVERhdGU+IHtcclxuICAgIC8qKuaMgeaciWNlbGznmoRsaXN0ICovXHJcbiAgICBwdWJsaWMgbG9vcGxpc3Q6IExvb3BMaXN0PFQ+ID0gbnVsbDtcclxuICAgIC8qKuS9jee9ruiKgueCuSAqL1xyXG4gICAgcHVibGljIG5vZGU6IGNjLk5vZGUgPSBudWxsO1xyXG4gICAgLyoq5pi+56S66IqC54K5ICovXHJcbiAgICBwdWJsaWMgc2hvd05vZGU6IFNob3dOb2RlPFQ+ID0gbnVsbDtcclxuICAgIC8qKuWwuuWvuCAqL1xyXG4gICAgcHVibGljIHNpemU6IGNjLlNpemUgPSBudWxsO1xyXG4gICAgLyoq5pWw5o2u5LiL5qCHICovXHJcbiAgICBwdWJsaWMgZGF0YUluZGV4OiBudW1iZXIgPSBudWxsO1xyXG4gICAgLyoqY2VsbOS4i+aghyAqL1xyXG4gICAgcHVibGljIGNlbGxJbmRleDogbnVtYmVyID0gbnVsbDtcclxuICAgIC8qKuaVsOaNriAqL1xyXG4gICAgcHVibGljIGRhdGE6IFQgPSBudWxsO1xyXG4gICAgLyoqXHJcbiAgICAgKiDmnoTpgKDlh73mlbBcclxuICAgICAqIEBwYXJhbSBub2RlIFxyXG4gICAgICogQHBhcmFtIGxvb3BsaXN0IFxyXG4gICAgICovXHJcbiAgICBjb25zdHJ1Y3Rvcihub2RlOiBjYy5Ob2RlLCBsb29wbGlzdDogTG9vcExpc3Q8VD4pIHtcclxuICAgICAgICB0aGlzLm5vZGUgPSBub2RlO1xyXG4gICAgICAgIHRoaXMubG9vcGxpc3QgPSBsb29wbGlzdDtcclxuICAgIH1cclxuXHJcbiAgICAvKipcclxuICAgICAqIOWIneWni+WMllxyXG4gICAgICogQHBhcmFtIGRhdGEgXHJcbiAgICAgKiBAcGFyYW0gc2l6ZSBcclxuICAgICAqIEBwYXJhbSBkYXRhSW5kZXggXHJcbiAgICAgKiBAcGFyYW0gY2VsbEluZGV4IFxyXG4gICAgICogQHBhcmFtIGxvb3BsaXN0IFxyXG4gICAgICovXHJcbiAgICBwdWJsaWMgaW5pdChkYXRhOiBULCBzaXplOiBjYy5TaXplLCBkYXRhSW5kZXg6IG51bWJlciwgY2VsbEluZGV4OiBudW1iZXIsIGxvb3BsaXN0OiBMb29wTGlzdDxUPikge1xyXG4gICAgICAgIGNjLlR3ZWVuLnN0b3BBbGxCeVRhcmdldCh0aGlzLm5vZGUpO1xyXG4gICAgICAgIHRoaXMuY2VsbEluZGV4ID0gY2VsbEluZGV4O1xyXG4gICAgICAgIHRoaXMuZGF0YUluZGV4ID0gZGF0YUluZGV4O1xyXG4gICAgICAgIHRoaXMubG9vcGxpc3QgPSBsb29wbGlzdDtcclxuICAgICAgICB0aGlzLm5vZGUud2lkdGggPSBzaXplLndpZHRoO1xyXG4gICAgICAgIHRoaXMubm9kZS5oZWlnaHQgPSBzaXplLmhlaWdodDtcclxuICAgICAgICB0aGlzLmRhdGEgPSBkYXRhO1xyXG4gICAgICAgIHRoaXMuc2l6ZSA9IHNpemU7XHJcbiAgICB9XHJcbiAgICAvKipcclxuICAgICAqIOmHjee9ruWkp+Wwj1xyXG4gICAgICogQHBhcmFtIHNpemUgXHJcbiAgICAgKi9cclxuICAgIHJlc2l6ZShzaXplOiBjYy5TaXplLCB0aW1lOiBudW1iZXIpIHtcclxuICAgICAgICBsZXQgbm9kZVNpZGVzID0gZ2V0Tm9kZUJvcmRlcih0aGlzLCBbdHJ1ZSwgdHJ1ZSwgdHJ1ZSwgdHJ1ZV0pO1xyXG4gICAgICAgIGxldCBjaGFuZ2VTaXplID0gY2Muc2l6ZShzaXplLndpZHRoIC0gdGhpcy5zaXplLndpZHRoLCBzaXplLmhlaWdodCAtIHRoaXMuc2l6ZS5oZWlnaHQpO1xyXG4gICAgICAgIHRoaXMuc2l6ZSA9IHNpemU7XHJcbiAgICAgICAgdGhpcy5sb29wbGlzdC5kZWFsQ2hhbmdlU2l6ZSh0aGlzLCBub2RlU2lkZXMsIGNoYW5nZVNpemUsIHRpbWUpLnRoZW4oKCkgPT4ge1xyXG4gICAgICAgICAgICB0aGlzLm5vZGUud2lkdGggPSBzaXplLndpZHRoO1xyXG4gICAgICAgICAgICB0aGlzLm5vZGUuaGVpZ2h0ID0gc2l6ZS5oZWlnaHQ7XHJcbiAgICAgICAgICAgIHRoaXMubG9vcGxpc3QudXBkYXRlTm9kZXMoKTtcclxuICAgICAgICB9KTtcclxuICAgIH1cclxuXHJcbiAgICAvKipcclxuICAgICAqIOabtOaWsOiKgueCueaYvuekulxyXG4gICAgICogQHBhcmFtIGlzU2hvdyDmmK/lkKbmmL7npLpcclxuICAgICAqIEBwYXJhbSBwcmVmYWIg6ZyA6KaB5pi+56S655qE6IqC54K555qE6aKE5Yi25Lu277yI5Lmf5Y+v5Lul5piv6IqC54K577yM5oiW6ICF6aKE5Yi25Lu2dXJsLOeUn+aIkOaWueW8j+iHqueUseaUueWKqO+8iVxyXG4gICAgICogQHBhcmFtIGNhY2hlTm9kZSDlr7nosaHmsaDkuK3nmoTmmL7npLroioLngrlcclxuICAgICAqIEBwYXJhbSByZW5kZXJMYXllciDliIblsYLoioLngrlcclxuICAgICAqL1xyXG4gICAgdXBkYXRlU2hvdyhpc1Nob3c6IGJvb2xlYW4sIHByZWZhYjogY2MuUHJlZmFiLCBjYWNoZU5vZGU6IFNob3dOb2RlPFQ+LCByZW5kZXJMYXllcjogY2MuTm9kZSkge1xyXG4gICAgICAgIGlmIChpc1Nob3cpIHtcclxuICAgICAgICAgICAgLy/lvZPliY3msqHmnInmmL7npLroioLngrlcclxuICAgICAgICAgICAgaWYgKCF0aGlzLnNob3dOb2RlKSB7XHJcbiAgICAgICAgICAgICAgICAvL+WmguaenOaYr+S4tOaXtuWvueixoeaxoOi/mOacieiKgueCueWImemHjeeUqFxyXG4gICAgICAgICAgICAgICAgaWYgKGNhY2hlTm9kZSkge1xyXG4gICAgICAgICAgICAgICAgICAgIHRoaXMuc2hvd05vZGUgPSBjYWNoZU5vZGU7XHJcbiAgICAgICAgICAgICAgICB9IGVsc2Ugey8v5ZCm5YiZ5L2/55So5Lyg5YWl55qE6aKE5Yi25Lu26L+b6KGM55Sf5oiQXHJcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5zaG93Tm9kZSA9IGNjLmluc3RhbnRpYXRlKHByZWZhYikuZ2V0Q29tcG9uZW50KFNob3dOb2RlKTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIHRoaXMuc2hvd05vZGUubm9kZS5zZXRQYXJlbnQodGhpcy5ub2RlKTtcclxuICAgICAgICAgICAgICAgIHRoaXMuc2hvd05vZGUubm9kZS5wb3NpdGlvbiA9IGNjLnYzKCk7XHJcbiAgICAgICAgICAgICAgICB0aGlzLnVwZGF0ZVNob3dOb2RlKHJlbmRlckxheWVyKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH1cclxuICAgIH1cclxuICAgIC8qKlxyXG4gICAgICog5pu05pawc2hvd05vZGXoioLngrnmmL7npLpcclxuICAgICAqIEBwYXJhbSByZW5kZXJMYXllciBcclxuICAgICAqL1xyXG4gICAgdXBkYXRlU2hvd05vZGUocmVuZGVyTGF5ZXI6IGNjLk5vZGUpIHtcclxuICAgICAgICAvL+W9k+WJjeacieaYvuekuuiKgueCuVxyXG4gICAgICAgIGlmICh0aGlzLnNob3dOb2RlKSB7XHJcbiAgICAgICAgICAgIHRoaXMuc2hvd05vZGUuaW5pdCh0aGlzLCB0aGlzLmRhdGEsIHJlbmRlckxheWVyKTtcclxuICAgICAgICB9XHJcbiAgICB9XHJcblxyXG4gICAgZ2V0IGhhc05vTm9kZSgpIHtcclxuICAgICAgICByZXR1cm4gIXRoaXMuc2hvd05vZGU7XHJcbiAgICB9XHJcblxyXG4gICAgcmVjaXJjbGUoKSB7XHJcbiAgICAgICAgaWYgKHRoaXMuc2hvd05vZGUpIHtcclxuICAgICAgICAgICAgbGV0IG5vZGUgPSB0aGlzLnNob3dOb2RlO1xyXG4gICAgICAgICAgICB0aGlzLnNob3dOb2RlLmdldENvbXBvbmVudChTaG93Tm9kZSkub25SZWNpcmNsZSgpO1xyXG4gICAgICAgICAgICB0aGlzLnNob3dOb2RlLm5vZGUucmVtb3ZlRnJvbVBhcmVudChmYWxzZSk7XHJcbiAgICAgICAgICAgIHRoaXMuc2hvd05vZGUgPSBudWxsO1xyXG4gICAgICAgICAgICByZXR1cm4gbm9kZTtcclxuICAgICAgICB9XHJcbiAgICB9XHJcblxyXG5cclxuICAgIGRlc3Ryb3koKSB7XHJcbiAgICAgICAgdGhpcy5ub2RlLmRlc3Ryb3koKTtcclxuICAgICAgICB0aGlzLm5vZGUgPSBudWxsO1xyXG4gICAgICAgIHRoaXMubG9vcGxpc3QgPSBudWxsO1xyXG4gICAgfVxyXG5cclxuICAgIC8qKlxyXG4gICAgICog5aSx5Y67XHJcbiAgICAgKiBAcmV0dXJucyBcclxuICAgICAqL1xyXG4gICAgbG9zdFNob3dOb2RlKCkge1xyXG4gICAgICAgIGlmICh0aGlzLnNob3dOb2RlKSB7XHJcbiAgICAgICAgICAgIGxldCBub2RlID0gdGhpcy5zaG93Tm9kZTtcclxuICAgICAgICAgICAgdGhpcy5zaG93Tm9kZS5ub2RlLnJlbW92ZUZyb21QYXJlbnQoZmFsc2UpO1xyXG4gICAgICAgICAgICB0aGlzLnNob3dOb2RlID0gbnVsbDtcclxuICAgICAgICAgICAgcmV0dXJuIG5vZGU7XHJcbiAgICAgICAgfVxyXG4gICAgfVxyXG5cclxuICAgIC8qKlxyXG4gICAgICog6I635Y+W5pi+56S66IqC54K5XHJcbiAgICAgKiBAcGFyYW0gc2hvd05vZGUgXHJcbiAgICAgKi9cclxuICAgIGdldFNob3dOb2RlKHNob3dOb2RlOiBTaG93Tm9kZTxUPikge1xyXG4gICAgICAgIHRoaXMuc2hvd05vZGUgPSBzaG93Tm9kZTtcclxuICAgICAgICBzaG93Tm9kZS5ub2RlLnNldFBhcmVudCh0aGlzLm5vZGUpO1xyXG4gICAgICAgIHRoaXMuc2hvd05vZGUuY2VsbCA9IHRoaXM7XHJcbiAgICB9XHJcbn1cclxuXHJcbi8qKlxyXG4gKiDnm67liY3liJfooajms6jmhI/kuovpoblcclxuICogMS7lvIDlkK9jZWxsTWF4TnVt5ZCO5LiN6IO95LiA6KGM5aSa5YiX5oiW6ICF5LiA5YiX5aSa6KGM77yM5Y+q6IO95Y2V6KGM5oiW6ICF5Y2V5YiXXHJcbiAqL1xyXG5leHBvcnQgZGVmYXVsdCBjbGFzcyBMb29wTGlzdDxUIGV4dGVuZHMgVERhdGU+IHtcclxuICAgIHB1YmxpYyBzdGF0aWMgaW5zTWFwOiBNYXA8c3RyaW5nLCBMb29wTGlzdDxhbnk+PiA9IG5ldyBNYXAoKTtcclxuICAgIHB1YmxpYyBzdGF0aWMgaW5zPFQ+KGxpc3ROYW1lOiBzdHJpbmcpOiBMb29wTGlzdDxUPiB7XHJcbiAgICAgICAgaWYgKCF0aGlzLmluc01hcC5oYXMobGlzdE5hbWUpKSB7XHJcbiAgICAgICAgICAgIHRoaXMuaW5zTWFwLnNldChsaXN0TmFtZSwgbmV3IExvb3BMaXN0PFQ+KCkpO1xyXG4gICAgICAgIH1cclxuICAgICAgICByZXR1cm4gdGhpcy5pbnNNYXAuZ2V0KGxpc3ROYW1lKSBhcyBMb29wTGlzdDxUPjtcclxuICAgIH1cclxuICAgIC8qKuWIhuWxguiKgueCue+8iOWPquacieWcqHNob3dOb2Rl5Lit5oyC6L295LqGUmVuZGVyQWx0ZXJuYXRpdmXmiY3og73otbfkvZznlKjvvIkgKi9cclxuICAgIHByaXZhdGUgcmVuZGVyTGF5ZXI6IGNjLk5vZGUgPSBudWxsO1xyXG4gICAgLyoq5rua5Yqo57uE5Lu2ICovXHJcbiAgICBwcml2YXRlIHNjcm9sbFZpZXc6IGNjLlNjcm9sbFZpZXcgPSBudWxsO1xyXG4gICAgLyoqY2VsbOiKgueCueacgOWkp+aVsOmHjyAqL1xyXG4gICAgcHJpdmF0ZSBjZWxsTWF4TnVtOiBudW1iZXIgPSBudWxsO1xyXG4gICAgLyoq5b2T5YmN6LW354K5ICovXHJcbiAgICBwcml2YXRlIGN1clN0YXJ0SW5kZXg6IG51bWJlciA9IG51bGw7XHJcbiAgICAvKirmlbDmja4gKi9cclxuICAgIHByaXZhdGUgZGF0YXM6IFRbXSA9IFtdO1xyXG4gICAgLyoqaXRlbeiKgueCueS7rCAqL1xyXG4gICAgcHJpdmF0ZSBpdGVtQ2VsbHM6IEl0ZW1DZWxsPFQ+W10gPSBbXTtcclxuICAgIC8qKumihOWItuS7tiAqL1xyXG4gICAgcHJpdmF0ZSBwcmVmYWI6IGNjLlByZWZhYiA9IG51bGw7XHJcbiAgICAvKirmmL7npLroioLngrnnmoTmsaDlrZAgKi9cclxuICAgIHByaXZhdGUgc2hvd05vZGVQb29sOiBTaG93Tm9kZTxUPltdID0gW107XHJcbiAgICAvKirovrnnvJjmlbDmja4gKi9cclxuICAgIHByaXZhdGUgdmlld1NpZGVzOiBJQm9yZGVyID0ge307XHJcbiAgICAvKirkuIrkuIDluKfmu5rliqjlrrnlmajnmoTlnZDmoIcgKi9cclxuICAgIHB1YmxpYyBsYXN0UG9zOiBjYy5WZWMzID0gbnVsbDtcclxuICAgIC8qKuWIt+aWsOaYvuekuueahOmXtOmalOasoeaVsCAqL1xyXG4gICAgcHVibGljIHVwZGF0ZUludjogbnVtYmVyID0gMDtcclxuICAgIC8qKuW+queOr+WIh+aNoueahOacgOWQjuS4gOasoeaXtumXtCAqL1xyXG4gICAgcHVibGljIGxhc3RDaGFuZ2U6IG51bWJlciA9IDA7XHJcbiAgICAvKirpgJrnlKjlsLrlr7ggKi9cclxuICAgIHB1YmxpYyBzaXplOiBjYy5TaXplID0gbnVsbDtcclxuICAgIC8qKumAmueUqOmUmueCuSAqL1xyXG4gICAgcHVibGljIGFuY2hvcjogY2MuVmVjMiA9IG51bGw7XHJcblxyXG4gICAgb25Mb2FkKCkge1xyXG4gICAgICAgIHRoaXMudXBkYXRlQm9yZGVyKClcclxuICAgIH1cclxuXHJcbiAgICAvKipcclxuICAgICAqIOabtOaWsOi+ueeVjFxyXG4gICAgICovXHJcbiAgICBwdWJsaWMgdXBkYXRlQm9yZGVyKCkge1xyXG4gICAgICAgIGxldCB2aWV3ID0gdGhpcy5zY3JvbGxWaWV3Lm5vZGUuZ2V0Q2hpbGRCeU5hbWUoXCJ2aWV3XCIpO1xyXG4gICAgICAgIHZpZXcuYW5jaG9yWCA9IHRoaXMuc2Nyb2xsVmlldy5jb250ZW50LmFuY2hvclg7XHJcbiAgICAgICAgdmlldy5hbmNob3JZID0gdGhpcy5zY3JvbGxWaWV3LmNvbnRlbnQuYW5jaG9yWTtcclxuICAgICAgICAvL+S/ruaUuemUmueCueS5i+WQjuS4i+S4gOW4p+S4lueVjOWdkOagh+aJjeS8muabtOaWsO+8jOayoeWKnuazleWPquiDveetieS4gOW4p+S6hlxyXG4gICAgICAgIHJldHVybiBuZXcgUHJvbWlzZTx2b2lkPigocmVzb2x2ZSwgcmVqZWN0KSA9PiB7XHJcbiAgICAgICAgICAgIHJlcXVlc3RBbmltYXRpb25GcmFtZSgoKSA9PiB7XHJcbiAgICAgICAgICAgICAgICBsZXQgd3BvcyA9IGdldE5vZGVXUG9zKHZpZXcpO1xyXG4gICAgICAgICAgICAgICAgLy/mmL7npLrljLrln5/lt6bovrnnvJhcclxuICAgICAgICAgICAgICAgIGxldCBsZWZ0U2lkZSA9IHdwb3MueCAtICh2aWV3LndpZHRoICogdmlldy5hbmNob3JYKTtcclxuICAgICAgICAgICAgICAgIC8v5pi+56S65Yy65Z+f5Y+z6L6557yYXHJcbiAgICAgICAgICAgICAgICBsZXQgcmlnaHRTaWRlID0gd3Bvcy54ICsgKHZpZXcud2lkdGggKiAoMSAtIHZpZXcuYW5jaG9yWCkpO1xyXG4gICAgICAgICAgICAgICAgLy/mmL7npLrljLrln5/kuIvovrnnvJhcclxuICAgICAgICAgICAgICAgIGxldCBib3R0b21TaWRlID0gd3Bvcy55IC0gKHZpZXcuaGVpZ2h0ICogdmlldy5hbmNob3JZKTtcclxuICAgICAgICAgICAgICAgIC8v5pi+56S65Yy65Z+f5LiK6L6557yYXHJcbiAgICAgICAgICAgICAgICBsZXQgdG9wU2lkZSA9IHdwb3MueSArICh2aWV3LmhlaWdodCAqICgxIC0gdmlldy5hbmNob3JZKSk7XHJcbiAgICAgICAgICAgICAgICB0aGlzLnZpZXdTaWRlcyA9IHtcclxuICAgICAgICAgICAgICAgICAgICBsZWZ0U2lkZSwgcmlnaHRTaWRlLCBib3R0b21TaWRlLCB0b3BTaWRlLCBzaXplOiBjYy5zaXplKHZpZXcud2lkdGgsIHZpZXcuaGVpZ2h0KVxyXG4gICAgICAgICAgICAgICAgfTtcclxuICAgICAgICAgICAgICAgIHRoaXMuc2Nyb2xsVmlldy5jb250ZW50LnNldFBvc2l0aW9uKGNjLnYzKDAsIDApKTtcclxuICAgICAgICAgICAgICAgIHJlc29sdmUoKTtcclxuICAgICAgICAgICAgfSlcclxuICAgICAgICB9KVxyXG5cclxuICAgIH1cclxuXHJcbiAgICAvKipcclxuICAgICAqIOWIneWni+WMlua7muWKqOWIl+ihqFxyXG4gICAgICogQHBhcmFtIHNjcm9sbFZpZXcgXHJcbiAgICAgKiBAcGFyYW0gY2VsbE1heE51bSBjZWxs6IqC54K555qE5pyA5aSn5pWw6YePLOiuvue9ruaIkG51bGzliJnkuI3lkK/nlKjvvIzlkK/nlKjnmoTor53vvIzopoHorr7nva7miJDvvIjlj6/op4bnqpfliJrlpb3og73mmL7npLrnmoTmnIDlpKfmlbDph48qMu+8iSsy77yM5YGH6K6+5pyA5aSa6IO955yL5YiwMTDkuKroioLngrnvvIzpgqPkuYjorr7nva7miJAyMlxyXG4gICAgICogQHBhcmFtIHJlbmRlckxheWVyIOa4suafk+WIhuWxgueahOeItuiKgueCue+8jOWmguaenOS8oOWFpeWImeWPr+S7pemFjeWQiHNob3dOb2Rl5LiK55qEcmVuZGVyQWx0ZXJuYXRpdmXmnaXov5vooYzmuLLmn5PliIblsYJcclxuICAgICAqL1xyXG4gICAgYXN5bmMgaW5pdChzY3JvbGxWaWV3OiBjYy5TY3JvbGxWaWV3LCByZW5kZXJMYXllcj86IGNjLk5vZGUsIGNlbGxNYXhOdW0/OiBudW1iZXIpIHtcclxuICAgICAgICBjZWxsTWF4TnVtICYmICh0aGlzLmNlbGxNYXhOdW0gPSBjZWxsTWF4TnVtKTtcclxuICAgICAgICByZW5kZXJMYXllciAmJiAodGhpcy5yZW5kZXJMYXllciA9IHJlbmRlckxheWVyKTtcclxuICAgICAgICB0aGlzLnNjcm9sbFZpZXcgPSBzY3JvbGxWaWV3O1xyXG4gICAgICAgIGF3YWl0IHRoaXMudXBkYXRlQm9yZGVyKCk7XHJcbiAgICAgICAgdGhpcy5zY3JvbGxWaWV3Lm5vZGUub24oXCJzY3JvbGxpbmdcIiwgdGhpcy5zY3JvbGxpbmdMaXN0ZW5lciwgdGhpcyk7XHJcbiAgICB9XHJcblxyXG4gICAgLyoq5rua5Yqo55uR5ZCsICovXHJcbiAgICBzY3JvbGxpbmdMaXN0ZW5lcigpIHtcclxuICAgICAgICB0aGlzLnVwZGF0ZUludi0tO1xyXG4gICAgICAgIGlmICh0aGlzLnVwZGF0ZUludiA8PSAwKSB7XHJcbiAgICAgICAgICAgIHRoaXMudXBkYXRlSW52ID0gMjtcclxuICAgICAgICAgICAgbGV0IHNob3dDZWxscyA9IHRoaXMudXBkYXRlTm9kZXMoKTtcclxuXHJcbiAgICAgICAgICAgIGlmICghdGhpcy5jZWxsTWF4TnVtKSB7XHJcbiAgICAgICAgICAgICAgICByZXR1cm47XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgaWYgKCF0aGlzLmxhc3RQb3MpIHtcclxuICAgICAgICAgICAgICAgIHRoaXMubGFzdFBvcyA9IHRoaXMuc2Nyb2xsVmlldy5jb250ZW50LnBvc2l0aW9uLmNsb25lKCk7XHJcbiAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICBsZXQgb2Zmc2V0ID0gdGhpcy5zY3JvbGxWaWV3LmNvbnRlbnQucG9zaXRpb24uY2xvbmUoKS5zdWIodGhpcy5sYXN0UG9zKTtcclxuICAgICAgICAgICAgICAgIHRoaXMubGFzdFBvcyA9IHRoaXMuc2Nyb2xsVmlldy5jb250ZW50LnBvc2l0aW9uLmNsb25lKCk7XHJcbiAgICAgICAgICAgICAgICBsZXQgbm93ID0gY2Muc3lzLm5vdygpO1xyXG4gICAgICAgICAgICAgICAgaWYgKCF0aGlzLmxhc3RDaGFuZ2UgfHwgKG5vdyAtIHRoaXMubGFzdENoYW5nZSkgPiAxMDApIHtcclxuICAgICAgICAgICAgICAgICAgICB0aGlzLmxhc3RDaGFuZ2UgPSBub3c7XHJcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5kZWFsTG9vcExpc3Qob2Zmc2V0LCBzaG93Q2VsbHMpO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfVxyXG4gICAgfVxyXG4gICAgLyoqXHJcbiAgICAgKiDliJ3lp4vljJZcclxuICAgICAqIEBwYXJhbSBkYXRhIOaVsOaNrue7hFxyXG4gICAgICogQHBhcmFtIHByZWZhYiDpooTliLbku7ZcclxuICAgICAqIEBwYXJhbSBzaXplIOmAmueUqOWwuuWvuFxyXG4gICAgICogQHBhcmFtIGFuY2hvciBjZWxs55qE6ZSa54K5XHJcbiAgICAgKi9cclxuICAgIHB1YmxpYyBpbml0RGF0YShkYXRhOiBUW10sIHByZWZhYjogY2MuUHJlZmFiLCBzaXplPzogY2MuU2l6ZSwgYW5jaG9yOiBjYy5WZWMyID0gY2MudjIoMC41LCAwLjUpKSB7XHJcbiAgICAgICAgdGhpcy5kYXRhcyA9IGRhdGE7XHJcbiAgICAgICAgdGhpcy5zaXplID0gc2l6ZTtcclxuICAgICAgICB0aGlzLmFuY2hvciA9IGFuY2hvcjtcclxuICAgICAgICB0aGlzLnByZWZhYiA9IHByZWZhYjtcclxuICAgICAgICBsZXQgbGVuID0gdGhpcy5jZWxsTWF4TnVtID8gdGhpcy5jZWxsTWF4TnVtIDogZGF0YS5sZW5ndGg7XHJcbiAgICAgICAgdGhpcy5jdXJTdGFydEluZGV4ID0gMDtcclxuICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGxlbjsgKytpKSB7XHJcbiAgICAgICAgICAgIGxldCBpdGVtQ2VsbCA9IHRoaXMuaXRlbUNlbGxzW2ldO1xyXG4gICAgICAgICAgICBpZiAoIWl0ZW1DZWxsKSB7XHJcbiAgICAgICAgICAgICAgICBsZXQgbm9kZSA9IG5ldyBjYy5Ob2RlKCdMb29wTGlzdENlbGwnKVxyXG4gICAgICAgICAgICAgICAgaXRlbUNlbGwgPSB0aGlzLml0ZW1DZWxsc1tpXSA9IG5ldyBJdGVtQ2VsbDxUPihub2RlLCB0aGlzKTtcclxuICAgICAgICAgICAgICAgIG5vZGUuc2V0QW5jaG9yUG9pbnQoYW5jaG9yKTtcclxuICAgICAgICAgICAgICAgIG5vZGUuc2V0UGFyZW50KHRoaXMuc2Nyb2xsVmlldy5jb250ZW50KTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBsZXQgZGF0YSA9IHRoaXMuZGF0YXNbdGhpcy5jdXJTdGFydEluZGV4ICsgaV07XHJcbiAgICAgICAgICAgIGxldCBjZWxsU2l6ZSA9IGRhdGEuc2l6ZSA/IGRhdGEuc2l6ZSA6IHNpemU7XHJcbiAgICAgICAgICAgIGl0ZW1DZWxsLmluaXQoZGF0YSwgY2VsbFNpemUsIHRoaXMuY3VyU3RhcnRJbmRleCArIGksIGksIHRoaXMpO1xyXG4gICAgICAgIH1cclxuICAgICAgICBmb3IgKGxldCBpID0gZGF0YS5sZW5ndGgsIGxlbiA9IHRoaXMuaXRlbUNlbGxzLmxlbmd0aDsgaSA8IGxlbjsgKytpKSB7XHJcbiAgICAgICAgICAgIHRoaXMucmVjaXJjbGVTaG93Tm9kZSh0aGlzLml0ZW1DZWxsc1tpXS5yZWNpcmNsZSgpKTtcclxuICAgICAgICAgICAgdGhpcy5pdGVtQ2VsbHNbaV0uZGVzdHJveSgpXHJcbiAgICAgICAgICAgIHRoaXMuaXRlbUNlbGxzW2ldID0gbnVsbDtcclxuICAgICAgICB9XHJcbiAgICAgICAgdGhpcy51cGRhdGVOb2RlcygpO1xyXG4gICAgfVxyXG5cclxuICAgIC8qKlxyXG4gICAgICog5Y6L5YWl5paw55qE5pWw5o2uXHJcbiAgICAgKiBAcGFyYW0gZGF0YXMgXHJcbiAgICAgKi9cclxuICAgIHB1YmxpYyBwdXNoRGF0YXMoZGF0YXM6IFRbXSkge1xyXG4gICAgICAgIGxldCBsZW5ndGggPSB0aGlzLmRhdGFzLmxlbmd0aDtcclxuICAgICAgICBmb3IgKGxldCBpID0gMCwgbGVuID0gZGF0YXMubGVuZ3RoOyBpIDwgbGVuOyArK2kpIHtcclxuICAgICAgICAgICAgbGV0IGRhdGEgPSBkYXRhc1tpXTtcclxuICAgICAgICAgICAgdGhpcy5kYXRhcy5wdXNoKGRhdGEpO1xyXG4gICAgICAgICAgICBsZXQgaW5kZXggPSBsZW5ndGggKyBpO1xyXG4gICAgICAgICAgICB0aGlzLmFkZE5vZGVGcm9tSW5kZXgoaW5kZXgpO1xyXG4gICAgICAgIH1cclxuICAgIH1cclxuICAgIC8qKlxyXG4gICAgICog5o+S5YWl5paw55qE5pWw5o2uXHJcbiAgICAgKiBAcGFyYW0gZGF0YSBcclxuICAgICAqIEBwYXJhbSBpbnNlcnRJbmRleCBcclxuICAgICAqL1xyXG4gICAgcHVibGljIGluc2VydERhdGEoZGF0YTogVCwgaW5zZXJ0SW5kZXg6IG51bWJlcikge1xyXG4gICAgICAgIGlmICh0aGlzLmRhdGFzLmxlbmd0aCA+PSBpbnNlcnRJbmRleCkge1xyXG4gICAgICAgICAgICB0aGlzLmRhdGFzLnNwbGljZShpbnNlcnRJbmRleCwgMCwgZGF0YSk7XHJcbiAgICAgICAgICAgIHRoaXMuYWRkTm9kZUZyb21JbmRleChpbnNlcnRJbmRleCk7XHJcbiAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgdGhpcy5wdXNoRGF0YXMoW2RhdGFdKTtcclxuICAgICAgICB9XHJcbiAgICB9XHJcbiAgICAvKipcclxuICAgICAqIOenu+mZpOWvueW6lOaVsOaNrlxyXG4gICAgICogQHBhcmFtIHJlbW92ZUluZGV4IFxyXG4gICAgICovXHJcbiAgICBwdWJsaWMgcmVtb3ZlRGF0YShyZW1vdmVJbmRleDogbnVtYmVyKSB7XHJcbiAgICAgICAgaWYgKHRoaXMuZGF0YXMubGVuZ3RoID49IHJlbW92ZUluZGV4KSB7XHJcbiAgICAgICAgICAgIHRoaXMuZGF0YXMuc3BsaWNlKHJlbW92ZUluZGV4LCAxKTtcclxuICAgICAgICAgICAgaWYgKHRoaXMuY2VsbE1heE51bSkge1xyXG4gICAgICAgICAgICAgICAgbGV0IGNlbGxJbmRleCA9IHJlbW92ZUluZGV4IC0gdGhpcy5jdXJTdGFydEluZGV4O1xyXG4gICAgICAgICAgICAgICAgLy/lnKjkvb/nlKjojIPlm7TlhoVcclxuICAgICAgICAgICAgICAgIGlmIChjZWxsSW5kZXggPj0gMCAmJiBjZWxsSW5kZXggPCB0aGlzLmNlbGxNYXhOdW0pIHtcclxuICAgICAgICAgICAgICAgICAgICBsZXQgaXRlbUNlbGwgPSB0aGlzLml0ZW1DZWxsc1tjZWxsSW5kZXhdO1xyXG4gICAgICAgICAgICAgICAgICAgIGxldCBub2RlU2lkZXMgPSBnZXROb2RlQm9yZGVyKGl0ZW1DZWxsLCBbdHJ1ZSwgdHJ1ZSwgdHJ1ZSwgdHJ1ZV0pO1xyXG4gICAgICAgICAgICAgICAgICAgIGxldCBjaGFuZ2VTaXplID0gY2Muc2l6ZSgtaXRlbUNlbGwuc2l6ZS53aWR0aCwgLWl0ZW1DZWxsLnNpemUuaGVpZ2h0KTtcclxuICAgICAgICAgICAgICAgICAgICBpdGVtQ2VsbC5zaXplID0gY2Muc2l6ZSgwLCAwKTtcclxuICAgICAgICAgICAgICAgICAgICB0aGlzLmRlYWxDaGFuZ2VTaXplKGl0ZW1DZWxsLCBub2RlU2lkZXMsIGNoYW5nZVNpemUpLnRoZW4oKCkgPT4ge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAvL+abtOaWsOaVsOaNrlxyXG4gICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gY2VsbEluZGV4OyBpIDwgdGhpcy5jZWxsTWF4TnVtOyBpKyspIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBjdXJEYXRhSW5kZXggPSB0aGlzLmN1clN0YXJ0SW5kZXggKyBpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGN1ckRhdGEgPSB0aGlzLmRhdGFzW2N1ckRhdGFJbmRleF07XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgY3VyQ2VsbFNpemU6IGNjLlNpemUgPSBjdXJEYXRhLnNpemUgPyBjdXJEYXRhLnNpemUgOiB0aGlzLnNpemU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLml0ZW1DZWxsc1tpXS5pbml0KGN1ckRhdGEsIGN1ckNlbGxTaXplLCBjdXJEYXRhSW5kZXgsIGksIHRoaXMpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5pdGVtQ2VsbHNbaV0udXBkYXRlU2hvd05vZGUodGhpcy5yZW5kZXJMYXllcik7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICB9KTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgIGxldCBpdGVtQ2VsbCA9IHRoaXMuaXRlbUNlbGxzLnNwbGljZShyZW1vdmVJbmRleCwgMSlbMF07XHJcbiAgICAgICAgICAgICAgICBsZXQgbm9kZVNpZGVzID0gZ2V0Tm9kZUJvcmRlcihpdGVtQ2VsbCwgW3RydWUsIHRydWUsIHRydWUsIHRydWVdKTtcclxuICAgICAgICAgICAgICAgIGxldCBjaGFuZ2VTaXplID0gY2Muc2l6ZSgtaXRlbUNlbGwuc2l6ZS53aWR0aCwgLWl0ZW1DZWxsLnNpemUuaGVpZ2h0KTtcclxuICAgICAgICAgICAgICAgIGl0ZW1DZWxsLnNpemUgPSBjYy5zaXplKDAsIDApO1xyXG4gICAgICAgICAgICAgICAgdGhpcy5kZWFsQ2hhbmdlU2l6ZShpdGVtQ2VsbCwgbm9kZVNpZGVzLCBjaGFuZ2VTaXplKS50aGVuKCgpID0+IHtcclxuICAgICAgICAgICAgICAgICAgICB0aGlzLnJlY2lyY2xlU2hvd05vZGUoaXRlbUNlbGwucmVjaXJjbGUoKSlcclxuICAgICAgICAgICAgICAgICAgICBpdGVtQ2VsbC5ub2RlLmRlc3Ryb3koKTtcclxuICAgICAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfVxyXG4gICAgfVxyXG4gICAgLyoqXHJcbiAgICAgKiDku47mn5DkuKrmlbDmja7lvIDlp4vmm7TmlrBcclxuICAgICAqIEBwYXJhbSBkYXRhSW5kZXggXHJcbiAgICAgKi9cclxuICAgIHByaXZhdGUgYXN5bmMgYWRkTm9kZUZyb21JbmRleChkYXRhSW5kZXg6IG51bWJlcikge1xyXG4gICAgICAgIGxldCBkYXRhID0gdGhpcy5kYXRhc1tkYXRhSW5kZXhdO1xyXG4gICAgICAgIGxldCBjZWxsU2l6ZTogY2MuU2l6ZSA9IGRhdGEuc2l6ZSA/IGRhdGEuc2l6ZSA6IHRoaXMuc2l6ZTtcclxuICAgICAgICAvL+aYr+WQpuW8gOWQr2NlbGzlvqrnjq9cclxuICAgICAgICBpZiAodGhpcy5jZWxsTWF4TnVtKSB7XHJcbiAgICAgICAgICAgIGxldCBjZWxsSW5kZXggPSBkYXRhSW5kZXggLSB0aGlzLmN1clN0YXJ0SW5kZXg7XHJcbiAgICAgICAgICAgIC8v5Zyo5L2/55So6IyD5Zu05YaFXHJcbiAgICAgICAgICAgIGlmIChjZWxsSW5kZXggPj0gMCAmJiBjZWxsSW5kZXggPCB0aGlzLmNlbGxNYXhOdW0pIHtcclxuICAgICAgICAgICAgICAgIC8v5pu05paw5pWw5o2uXHJcbiAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gY2VsbEluZGV4OyBpIDwgdGhpcy5jZWxsTWF4TnVtOyBpKyspIHtcclxuICAgICAgICAgICAgICAgICAgICBsZXQgY3VyRGF0YUluZGV4ID0gdGhpcy5jdXJTdGFydEluZGV4ICsgaTtcclxuICAgICAgICAgICAgICAgICAgICBsZXQgY3VyRGF0YSA9IHRoaXMuZGF0YXNbY3VyRGF0YUluZGV4XTtcclxuICAgICAgICAgICAgICAgICAgICBsZXQgY3VyQ2VsbFNpemU6IGNjLlNpemUgPSBjdXJEYXRhLnNpemUgPyBjdXJEYXRhLnNpemUgOiB0aGlzLnNpemU7XHJcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5pdGVtQ2VsbHNbaV0uaW5pdChjdXJEYXRhLCBjdXJDZWxsU2l6ZSwgY3VyRGF0YUluZGV4LCBpLCB0aGlzKTtcclxuICAgICAgICAgICAgICAgICAgICB0aGlzLml0ZW1DZWxsc1tpXS51cGRhdGVTaG93Tm9kZSh0aGlzLnJlbmRlckxheWVyKTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIC8v6I635Y+W5b2T5YmN55qE5L2N572uXHJcbiAgICAgICAgICAgICAgICBsZXQgbm9kZVNpZGVzOiBJQm9yZGVyID0gbnVsbDtcclxuICAgICAgICAgICAgICAgIGxldCBpdGVtQ2VsbDogSXRlbUNlbGw8VD4gPSB0aGlzLml0ZW1DZWxsc1tjZWxsSW5kZXhdO1xyXG4gICAgICAgICAgICAgICAgaWYgKGl0ZW1DZWxsKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgbm9kZVNpZGVzID0gZ2V0Tm9kZUJvcmRlcihpdGVtQ2VsbCwgW3RydWUsIHRydWUsIHRydWUsIHRydWVdKTtcclxuICAgICAgICAgICAgICAgICAgICBpdGVtQ2VsbC5ub2RlLndpZHRoID0gMDtcclxuICAgICAgICAgICAgICAgICAgICBpdGVtQ2VsbC5ub2RlLmhlaWdodCA9IDA7XHJcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5kZWFsQ2hhbmdlU2l6ZShpdGVtQ2VsbCwgbm9kZVNpZGVzLCBjZWxsU2l6ZSkudGhlbigoKSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGl0ZW1DZWxsLm5vZGUud2lkdGggPSBjZWxsU2l6ZS53aWR0aDtcclxuICAgICAgICAgICAgICAgICAgICAgICAgaXRlbUNlbGwubm9kZS5oZWlnaHQgPSBjZWxsU2l6ZS5oZWlnaHQ7XHJcbiAgICAgICAgICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAvL+iOt+WPluW9k+WJjeeahOS9jee9rlxyXG4gICAgICAgICAgICBsZXQgbm9kZVNpZGVzOiBJQm9yZGVyID0gbnVsbDtcclxuICAgICAgICAgICAgaWYgKHRoaXMuaXRlbUNlbGxzW2RhdGFJbmRleF0pIHtcclxuICAgICAgICAgICAgICAgIG5vZGVTaWRlcyA9IGdldE5vZGVCb3JkZXIodGhpcy5pdGVtQ2VsbHNbZGF0YUluZGV4XSwgW3RydWUsIHRydWUsIHRydWUsIHRydWVdKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBsZXQgbm9kZSA9IG5ldyBjYy5Ob2RlKCdMb29wTGlzdENlbGwnKVxyXG4gICAgICAgICAgICBub2RlLnNldEFuY2hvclBvaW50KHRoaXMuYW5jaG9yKTtcclxuICAgICAgICAgICAgbm9kZS5zZXRQYXJlbnQodGhpcy5zY3JvbGxWaWV3LmNvbnRlbnQpO1xyXG4gICAgICAgICAgICBub2RlLnNldFNpYmxpbmdJbmRleChkYXRhSW5kZXgpO1xyXG4gICAgICAgICAgICBsZXQgaXRlbUNlbGw6IEl0ZW1DZWxsPFQ+ID0gbmV3IEl0ZW1DZWxsPFQ+KG5vZGUsIHRoaXMpO1xyXG4gICAgICAgICAgICB0aGlzLml0ZW1DZWxscy5zcGxpY2UoZGF0YUluZGV4LCAwLCBpdGVtQ2VsbClcclxuICAgICAgICAgICAgaXRlbUNlbGwuaW5pdChkYXRhLCBjZWxsU2l6ZSwgZGF0YUluZGV4LCBkYXRhSW5kZXgsIHRoaXMpO1xyXG4gICAgICAgICAgICBpZiAoIW5vZGVTaWRlcykge1xyXG4gICAgICAgICAgICAgICAgYXdhaXQgbmV3IFByb21pc2U8dm9pZD4oKHJlc29sdmUsIHJlamVjdCkgPT4ge1xyXG4gICAgICAgICAgICAgICAgICAgIHJlcXVlc3RBbmltYXRpb25GcmFtZSgoKSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIG5vZGVTaWRlcyA9IGdldE5vZGVCb3JkZXIoaXRlbUNlbGwsIFt0cnVlLCB0cnVlLCB0cnVlLCB0cnVlXSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHJlc29sdmUoKTtcclxuICAgICAgICAgICAgICAgICAgICB9KVxyXG4gICAgICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgaWYgKG5vZGVTaWRlcykge1xyXG4gICAgICAgICAgICAgICAgaXRlbUNlbGwubm9kZS53aWR0aCA9IDA7XHJcbiAgICAgICAgICAgICAgICBpdGVtQ2VsbC5ub2RlLmhlaWdodCA9IDA7XHJcbiAgICAgICAgICAgICAgICB0aGlzLmRlYWxDaGFuZ2VTaXplKGl0ZW1DZWxsLCBub2RlU2lkZXMsIGNlbGxTaXplKS50aGVuKCgpID0+IHtcclxuICAgICAgICAgICAgICAgICAgICBpdGVtQ2VsbC5ub2RlLndpZHRoID0gY2VsbFNpemUud2lkdGg7XHJcbiAgICAgICAgICAgICAgICAgICAgaXRlbUNlbGwubm9kZS5oZWlnaHQgPSBjZWxsU2l6ZS5oZWlnaHQ7XHJcbiAgICAgICAgICAgICAgICB9KTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB0aGlzLmRlYWxJdGVtU2hvdyhpdGVtQ2VsbCk7XHJcbiAgICAgICAgfVxyXG4gICAgfVxyXG5cclxuICAgIC8qKlxyXG4gICAgICog5aSE55CG5YiX6KGo55qE5b6q546v5Yip55SoXHJcbiAgICAgKiBAcGFyYW0gb2Zmc2V0IFxyXG4gICAgICogQHBhcmFtIGRhdGFJbmRleHMgXHJcbiAgICAgKi9cclxuICAgIHByaXZhdGUgZGVhbExvb3BMaXN0KG9mZnNldDogY2MuVmVjMywgc2hvd0NlbGxzOiBJdGVtQ2VsbDxUPltdKSB7XHJcbiAgICAgICAgbGV0IHN0YXJ0Q2VsbCA9IHNob3dDZWxsc1swXTtcclxuICAgICAgICBsZXQgZW5kQ2VsbCA9IHNob3dDZWxsc1tzaG93Q2VsbHMubGVuZ3RoIC0gMV07XHJcbiAgICAgICAgaWYgKHRoaXMuc2Nyb2xsVmlldy52ZXJ0aWNhbCkge1xyXG4gICAgICAgICAgICAvKirlhoXlrrnkuIrnp7sgKi9cclxuICAgICAgICAgICAgaWYgKG9mZnNldC55ID4gMCkge1xyXG4gICAgICAgICAgICAgICAgLy/lt7Lnu4/liLDovr7mnIDlkI7lgJLmlbDnrKzkuozkuKroioLngrnlubbkuJTov5jmnInmlbDmja5cclxuICAgICAgICAgICAgICAgIGlmICh0aGlzLnNjcm9sbFZpZXcuY29udGVudC55ID49ICgtIHRoaXMuaXRlbUNlbGxzW3RoaXMuaXRlbUNlbGxzLmxlbmd0aCAtIDJdLm5vZGUueSAtIHRoaXMudmlld1NpZGVzLnNpemUuaGVpZ2h0KSAmJiBlbmRDZWxsLmRhdGFJbmRleCA8IHRoaXMuZGF0YXMubGVuZ3RoIC0gMikge1xyXG4gICAgICAgICAgICAgICAgICAgIC8v5pi+56S65byA5aeL5pWw5o2u5LiL5qCHKOi/memHjC0x5piv5oOz6KaB6aG26YOo55WZ5LiA5LiqaXRlbWNlbGzlgZrnvJPlhrIpXHJcbiAgICAgICAgICAgICAgICAgICAgbGV0IHNob3dTdGFydCA9IHN0YXJ0Q2VsbC5kYXRhSW5kZXggLSAxO1xyXG4gICAgICAgICAgICAgICAgICAgIC8v5Ymp5L2Z5Y+v5bGV56S655qE5pWw5o2u6YePIFxyXG4gICAgICAgICAgICAgICAgICAgIGxldCBsZWF2ZSA9IHRoaXMuZGF0YXMubGVuZ3RoIC0gc2hvd1N0YXJ0O1xyXG4gICAgICAgICAgICAgICAgICAgIC8v6K6h566X5bqU6K+l5LuO6YKj5Liq5L2N572u5byA5aeL6YeN5paw6LWL5YC877yM5Zug5Li65aaC5p6c55u05o6l56e75Yqo5Yiw5pyA5LiK5pa577yM5pWw5o2u6YeP5LiN5aSf6KaG55uW5omA5pyJ55qEY2VsbFxyXG4gICAgICAgICAgICAgICAgICAgIGxldCBjZWxsU3RhcnRJbmRleCA9IE1hdGgubWF4KDAsIHRoaXMuaXRlbUNlbGxzLmxlbmd0aCAtIGxlYXZlKTtcclxuICAgICAgICAgICAgICAgICAgICAvL+iuoeeul+esrOS4gOS4qmNlbGznmoTmlbDmja7kuIvmoIdcclxuICAgICAgICAgICAgICAgICAgICB0aGlzLmN1clN0YXJ0SW5kZXggPSBzaG93U3RhcnQgLSBjZWxsU3RhcnRJbmRleDtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgbGV0IGNlbGxUb3AgPSBnZXROb2RlQm9yZGVyKHRoaXMuaXRlbUNlbGxzW3N0YXJ0Q2VsbC5jZWxsSW5kZXhdLCBbdHJ1ZV0pLnRvcFNpZGU7XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIGxldCBjb250ZW50SGVpZ2h0ID0gMDtcclxuICAgICAgICAgICAgICAgICAgICBsZXQgdGFyZ2V0WSA9IDA7XHJcbiAgICAgICAgICAgICAgICAgICAgbGV0IGp1bXBGaXJzdCA9IHRydWU7XHJcbiAgICAgICAgICAgICAgICAgICAgbGV0IHNob3dJbmRleCA9IDA7XHJcbiAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDAsIGxlbiA9IHRoaXMuaXRlbUNlbGxzLmxlbmd0aDsgaSA8IGxlbjsgKytpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpID49IGNlbGxTdGFydEluZGV4KSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvL+WwhuW9k+WJjeW3sue7j+aYvuekuueahHNob3dOb2Rl6IqC54K555u05o6l6YeN5paw6K6+572u5Yiw56e75Yqo5ZCO55qE6IqC54K55LiKXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc2hvd0luZGV4IDwgc2hvd0NlbGxzLmxlbmd0aCAmJiAhanVtcEZpcnN0KSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHNob3dJbmRleCA9PSAwKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldFkgPSBjb250ZW50SGVpZ2h0O1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgc2hvd05vZGUgPSBzaG93Q2VsbHNbc2hvd0luZGV4XS5sb3N0U2hvd05vZGUoKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaG93SW5kZXgrKztcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLml0ZW1DZWxsc1tpXS5nZXRTaG93Tm9kZShzaG93Tm9kZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBqdW1wRmlyc3QgPSBmYWxzZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgZGF0YUluZGV4ID0gdGhpcy5jdXJTdGFydEluZGV4ICsgaTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGRhdGEgPSB0aGlzLmRhdGFzW2RhdGFJbmRleF07XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBjZWxsU2l6ZSA9IGRhdGEuc2l6ZSA/IGRhdGEuc2l6ZSA6IHRoaXMuc2l6ZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgY29udGVudEhlaWdodCArPSBjZWxsU2l6ZS5oZWlnaHQ7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuaXRlbUNlbGxzW2ldLmluaXQoZGF0YSwgY2VsbFNpemUsIGRhdGFJbmRleCwgaSwgdGhpcyk7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICAvL+WwhmNvbnRlbnTnmoTkvY3nva7np7vliqjliLDmnIDkuIrmlrnlubblr7npvZDnp7vliqjliY3nmoTnirbmgIFcclxuICAgICAgICAgICAgICAgICAgICBsZXQgcG9zWSA9IHRhcmdldFkgKyAoY2VsbFRvcCAtIHRoaXMudmlld1NpZGVzLnRvcFNpZGUpXHJcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5zY3JvbGxWaWV3LmNvbnRlbnQuc2V0UG9zaXRpb24oY2MudjModGhpcy5zY3JvbGxWaWV3LmNvbnRlbnQucG9zaXRpb24ueCwgcG9zWSkpO1xyXG4gICAgICAgICAgICAgICAgICAgIHRoaXMuc2Nyb2xsVmlldy5zY3JvbGxUb09mZnNldChjYy52MigwLCBwb3NZICsgZW5kQ2VsbC5zaXplLmhlaWdodCksIDEpXHJcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5sYXN0UG9zID0gbnVsbDtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfSAvL+WGheWuueS4i+enu1xyXG4gICAgICAgICAgICBlbHNlIGlmIChvZmZzZXQueSA8IDApIHtcclxuICAgICAgICAgICAgICAgIC8v5bey57uP5Yiw6L6+56ys5LqM5Liq6IqC54K55bm25LiU6L+Y5pyJ5pWw5o2uXHJcbiAgICAgICAgICAgICAgICBpZiAodGhpcy5zY3JvbGxWaWV3LmNvbnRlbnQueSA8ICgtIHRoaXMuaXRlbUNlbGxzWzJdLm5vZGUueSkgJiYgc3RhcnRDZWxsLmRhdGFJbmRleCA+IDEpIHtcclxuICAgICAgICAgICAgICAgICAgICAvL+WxleekuueahOacgOWQjuS4gOS4quaVsOaNruS4i+ihqO+8jCsx5piv5Li65LqG5Zyo5bqV6YOo6aKE55WZ5LiA6YOo5YiG56m66Ze0XHJcbiAgICAgICAgICAgICAgICAgICAgbGV0IHNob3dFbmRJbmRleCA9IGVuZENlbGwuZGF0YUluZGV4ICsgMTtcclxuICAgICAgICAgICAgICAgICAgICAvL+iuoeeul+W6lOivpeS7jumCo+S4quS9jee9ruW8gOWni+mHjeaWsOi1i+WAvO+8jOWboOS4uuWmguaenOebtOaOpeenu+WKqOWIsOacgOS4i+aWue+8jOaVsOaNrumHj+S4jeWkn+imhuebluaJgOacieeahGNlbGxcclxuICAgICAgICAgICAgICAgICAgICBsZXQgY2VsbEVuZEluZGV4ID0gTWF0aC5taW4odGhpcy5pdGVtQ2VsbHMubGVuZ3RoIC0gMiwgc2hvd0VuZEluZGV4IC0gMSk7XHJcbiAgICAgICAgICAgICAgICAgICAgLy/orqHnrpfnrKzkuIDkuKpjZWxs55qE5pWw5o2u5LiL5qCHXHJcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJTdGFydEluZGV4ID0gTWF0aC5tYXgoc2hvd0VuZEluZGV4IC0gKHRoaXMuaXRlbUNlbGxzLmxlbmd0aCAtIDEpLCAwKTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgLy/lsIZjb250ZW5055qE5L2N572u56e75Yqo5Yiw5pyA5LiL5pa55bm25a+56b2Q56e75Yqo5YmN55qE54q25oCBXHJcbiAgICAgICAgICAgICAgICAgICAgbGV0IGNlbGxUb3AgPSBnZXROb2RlQm9yZGVyKHRoaXMuaXRlbUNlbGxzW3N0YXJ0Q2VsbC5jZWxsSW5kZXhdLCBbdHJ1ZV0pLnRvcFNpZGU7XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIGxldCBjb250ZW50SGVpZ2h0ID0gMDtcclxuICAgICAgICAgICAgICAgICAgICBsZXQgc2hvd0luZGV4ID0gc2hvd0NlbGxzLmxlbmd0aCAtIDE7XHJcbiAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IHRoaXMuaXRlbUNlbGxzLmxlbmd0aCAtIDE7IGkgPj0gMDsgLS1pKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpIDw9IGNlbGxFbmRJbmRleCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgLy/lsIblvZPliY3lt7Lnu4/mmL7npLrnmoRzaG93Tm9kZeiKgueCueebtOaOpemHjeaWsOiuvue9ruWIsOenu+WKqOWQjueahOiKgueCueS4ilxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHNob3dJbmRleCA+PSAwKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHNob3dOb2RlID0gc2hvd0NlbGxzW3Nob3dJbmRleF0ubG9zdFNob3dOb2RlKCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2hvd0luZGV4LS07XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5pdGVtQ2VsbHNbaV0uZ2V0U2hvd05vZGUoc2hvd05vZGUpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaG93SW5kZXgtLTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgZGF0YUluZGV4ID0gdGhpcy5jdXJTdGFydEluZGV4ICsgaTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGRhdGEgPSB0aGlzLmRhdGFzW2RhdGFJbmRleF07XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBjZWxsU2l6ZSA9IGRhdGEuc2l6ZSA/IGRhdGEuc2l6ZSA6IHRoaXMuc2l6ZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHNob3dJbmRleCA8IC0xKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250ZW50SGVpZ2h0ICs9IGNlbGxTaXplLmhlaWdodDtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLml0ZW1DZWxsc1tpXS5pbml0KGRhdGEsIGNlbGxTaXplLCBkYXRhSW5kZXgsIGksIHRoaXMpO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAgICAgLy/lsIZjb250ZW5055qE5L2N572u56e75Yqo5Yiw5pyA5LiL5pa55bm25a+56b2Q56e75Yqo5YmN55qE54q25oCBXHJcbiAgICAgICAgICAgICAgICAgICAgbGV0IHBvc1kgPSBjb250ZW50SGVpZ2h0ICsgKGNlbGxUb3AgLSB0aGlzLnZpZXdTaWRlcy50b3BTaWRlKVxyXG4gICAgICAgICAgICAgICAgICAgIHRoaXMuc2Nyb2xsVmlldy5jb250ZW50LnNldFBvc2l0aW9uKGNjLnYzKHRoaXMuc2Nyb2xsVmlldy5jb250ZW50LnBvc2l0aW9uLngsIHBvc1kpKTtcclxuICAgICAgICAgICAgICAgICAgICB0aGlzLnNjcm9sbFZpZXcuc2Nyb2xsVG9PZmZzZXQoY2MudjIoMCwgcG9zWSAtIHN0YXJ0Q2VsbC5zaXplLmhlaWdodCksIDEpXHJcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5sYXN0UG9zID0gbnVsbDtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH0gZWxzZSBpZiAodGhpcy5zY3JvbGxWaWV3Lmhvcml6b250YWwpIHtcclxuICAgICAgICAgICAgaWYgKG9mZnNldC54IDwgMCkge1xyXG4gICAgICAgICAgICAgICAgLy/lt7Lnu4/liLDovr7mnIDlkI7lgJLmlbDnrKzkuozkuKroioLngrnlubbkuJTov5jmnInmlbDmja5cclxuICAgICAgICAgICAgICAgIGlmICh0aGlzLnNjcm9sbFZpZXcuY29udGVudC54IDw9ICgtICh0aGlzLml0ZW1DZWxsc1t0aGlzLml0ZW1DZWxscy5sZW5ndGggLSAyXS5ub2RlLnggLSB0aGlzLnZpZXdTaWRlcy5zaXplLndpZHRoKSkgJiYgZW5kQ2VsbC5kYXRhSW5kZXggPCB0aGlzLmRhdGFzLmxlbmd0aCAtIDIpIHtcclxuICAgICAgICAgICAgICAgICAgICAvL+aYvuekuuW8gOWni+aVsOaNruS4i+aghyjov5nph4wtMeaYr+aDs+imgeW3puS+p+eVmeS4gOS4qml0ZW1jZWxs5YGa57yT5YayKVxyXG4gICAgICAgICAgICAgICAgICAgIGxldCBzaG93U3RhcnQgPSBzdGFydENlbGwuZGF0YUluZGV4IC0gMTtcclxuICAgICAgICAgICAgICAgICAgICAvL+WJqeS9meWPr+WxleekuueahOaVsOaNrumHjyBcclxuICAgICAgICAgICAgICAgICAgICBsZXQgbGVhdmUgPSB0aGlzLmRhdGFzLmxlbmd0aCAtIHNob3dTdGFydDtcclxuICAgICAgICAgICAgICAgICAgICAvL+iuoeeul+W6lOivpeS7jumCo+S4quS9jee9ruW8gOWni+mHjeaWsOi1i+WAvO+8jOWboOS4uuWmguaenOebtOaOpeenu+WKqOWIsOacgOW3puS+p++8jOaVsOaNrumHj+S4jeWkn+imhuebluaJgOacieeahGNlbGxcclxuICAgICAgICAgICAgICAgICAgICBsZXQgY2VsbFN0YXJ0SW5kZXggPSBNYXRoLm1heCgwLCB0aGlzLml0ZW1DZWxscy5sZW5ndGggLSBsZWF2ZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgLy/orqHnrpfnrKzkuIDkuKpjZWxs55qE5pWw5o2u5LiL5qCHXHJcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJTdGFydEluZGV4ID0gc2hvd1N0YXJ0IC0gY2VsbFN0YXJ0SW5kZXg7XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIGxldCBjZWxsTGVmdCA9IGdldE5vZGVCb3JkZXIodGhpcy5pdGVtQ2VsbHNbc3RhcnRDZWxsLmNlbGxJbmRleF0sIFtmYWxzZSwgZmFsc2UsIHRydWVdKS5sZWZ0U2lkZTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgbGV0IGNvbnRlbnRXaWR0aCA9IDA7XHJcbiAgICAgICAgICAgICAgICAgICAgbGV0IHRhcmdldFggPSAwO1xyXG4gICAgICAgICAgICAgICAgICAgIGxldCBqdW1wRmlyc3QgPSB0cnVlO1xyXG4gICAgICAgICAgICAgICAgICAgIGxldCBzaG93SW5kZXggPSAwO1xyXG4gICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBsZW4gPSB0aGlzLml0ZW1DZWxscy5sZW5ndGg7IGkgPCBsZW47ICsraSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoaSA+PSBjZWxsU3RhcnRJbmRleCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgLy/lsIblvZPliY3lt7Lnu4/mmL7npLrnmoRzaG93Tm9kZeiKgueCueebtOaOpemHjeaWsOiuvue9ruWIsOenu+WKqOWQjueahOiKgueCueS4ilxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHNob3dJbmRleCA8IHNob3dDZWxscy5sZW5ndGggJiYgIWp1bXBGaXJzdCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzaG93SW5kZXggPT0gMCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0YXJnZXRYID0gY29udGVudFdpZHRoO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgc2hvd05vZGUgPSBzaG93Q2VsbHNbc2hvd0luZGV4XS5sb3N0U2hvd05vZGUoKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaG93SW5kZXgrKztcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLml0ZW1DZWxsc1tpXS5nZXRTaG93Tm9kZShzaG93Tm9kZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBqdW1wRmlyc3QgPSBmYWxzZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgZGF0YUluZGV4ID0gdGhpcy5jdXJTdGFydEluZGV4ICsgaTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGRhdGEgPSB0aGlzLmRhdGFzW2RhdGFJbmRleF07XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBjZWxsU2l6ZSA9IGRhdGEuc2l6ZSA/IGRhdGEuc2l6ZSA6IHRoaXMuc2l6ZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgY29udGVudFdpZHRoICs9IGNlbGxTaXplLndpZHRoO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLml0ZW1DZWxsc1tpXS5pbml0KGRhdGEsIGNlbGxTaXplLCBkYXRhSW5kZXgsIGksIHRoaXMpO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAgICAgLy/lsIZjb250ZW5055qE5L2N572u56e75Yqo5Yiw5pyA5bem5L6n5bm25a+56b2Q56e75Yqo5YmN55qE54q25oCBXHJcbiAgICAgICAgICAgICAgICAgICAgbGV0IHBvc1ggPSAoY2VsbExlZnQgLSB0aGlzLnZpZXdTaWRlcy5sZWZ0U2lkZSkgLSB0YXJnZXRYO1xyXG4gICAgICAgICAgICAgICAgICAgIHRoaXMuc2Nyb2xsVmlldy5jb250ZW50LnNldFBvc2l0aW9uKGNjLnYzKHBvc1gsIHRoaXMuc2Nyb2xsVmlldy5jb250ZW50LnBvc2l0aW9uLnkpKTtcclxuICAgICAgICAgICAgICAgICAgICB0aGlzLnNjcm9sbFZpZXcuc2Nyb2xsVG9PZmZzZXQoY2MudjIoLShwb3NYIC0gZW5kQ2VsbC5zaXplLndpZHRoKSwgMCksIDEpXHJcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5sYXN0UG9zID0gbnVsbDtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfSBlbHNlIGlmIChvZmZzZXQueCA+IDApIHtcclxuICAgICAgICAgICAgICAgIC8v5bey57uP5Yiw6L6+56ys5LqM5Liq6IqC54K55bm25LiU6L+Y5pyJ5pWw5o2uXHJcbiAgICAgICAgICAgICAgICBpZiAodGhpcy5zY3JvbGxWaWV3LmNvbnRlbnQueCA+ICgtdGhpcy5pdGVtQ2VsbHNbMl0ubm9kZS54KSAmJiBzdGFydENlbGwuZGF0YUluZGV4ID4gMSkge1xyXG4gICAgICAgICAgICAgICAgICAgIC8v5bGV56S655qE5pyA5ZCO5LiA5Liq5pWw5o2u5LiL6KGo77yMKzHmmK/kuLrkuoblnKjlj7PkvqfpooTnlZnkuIDpg6jliIbnqbrpl7RcclxuICAgICAgICAgICAgICAgICAgICBsZXQgc2hvd0VuZEluZGV4ID0gZW5kQ2VsbC5kYXRhSW5kZXggKyAxO1xyXG4gICAgICAgICAgICAgICAgICAgIC8v6K6h566X5bqU6K+l5LuO6YKj5Liq5L2N572u5byA5aeL6YeN5paw6LWL5YC877yM5Zug5Li65aaC5p6c55u05o6l56e75Yqo5Yiw5pyA5Y+z5L6n77yM5pWw5o2u6YeP5LiN5aSf6KaG55uW5omA5pyJ55qEY2VsbFxyXG4gICAgICAgICAgICAgICAgICAgIGxldCBjZWxsRW5kSW5kZXggPSBNYXRoLm1pbih0aGlzLml0ZW1DZWxscy5sZW5ndGggLSAyLCBzaG93RW5kSW5kZXggLSAxKTtcclxuICAgICAgICAgICAgICAgICAgICAvL+iuoeeul+esrOS4gOS4qmNlbGznmoTmlbDmja7kuIvmoIdcclxuICAgICAgICAgICAgICAgICAgICB0aGlzLmN1clN0YXJ0SW5kZXggPSBNYXRoLm1heChzaG93RW5kSW5kZXggLSAodGhpcy5pdGVtQ2VsbHMubGVuZ3RoIC0gMSksIDApO1xyXG5cclxuICAgICAgICAgICAgICAgICAgICAvL+WwhmNvbnRlbnTnmoTkvY3nva7np7vliqjliLDmnIDlj7Pkvqflubblr7npvZDnp7vliqjliY3nmoTnirbmgIFcclxuICAgICAgICAgICAgICAgICAgICBsZXQgY2VsbExlZnQgPSBnZXROb2RlQm9yZGVyKHRoaXMuaXRlbUNlbGxzW3N0YXJ0Q2VsbC5jZWxsSW5kZXhdLCBbZmFsc2UsIGZhbHNlLCB0cnVlXSkubGVmdFNpZGU7XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIGxldCBjb250ZW50V2lkdGggPSAwO1xyXG4gICAgICAgICAgICAgICAgICAgIGxldCBzaG93SW5kZXggPSBzaG93Q2VsbHMubGVuZ3RoIC0gMTtcclxuICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gdGhpcy5pdGVtQ2VsbHMubGVuZ3RoIC0gMTsgaSA+PSAwOyAtLWkpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGkgPD0gY2VsbEVuZEluZGV4KSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvL+WwhuW9k+WJjeW3sue7j+aYvuekuueahHNob3dOb2Rl6IqC54K555u05o6l6YeN5paw6K6+572u5Yiw56e75Yqo5ZCO55qE6IqC54K55LiKXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc2hvd0luZGV4ID49IDApIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgc2hvd05vZGUgPSBzaG93Q2VsbHNbc2hvd0luZGV4XS5sb3N0U2hvd05vZGUoKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaG93SW5kZXgtLTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLml0ZW1DZWxsc1tpXS5nZXRTaG93Tm9kZShzaG93Tm9kZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNob3dJbmRleC0tO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBkYXRhSW5kZXggPSB0aGlzLmN1clN0YXJ0SW5kZXggKyBpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgZGF0YSA9IHRoaXMuZGF0YXNbZGF0YUluZGV4XTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGNlbGxTaXplID0gZGF0YS5zaXplID8gZGF0YS5zaXplIDogdGhpcy5zaXplO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoc2hvd0luZGV4IDwgLTEpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRlbnRXaWR0aCArPSBjZWxsU2l6ZS53aWR0aDtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLml0ZW1DZWxsc1tpXS5pbml0KGRhdGEsIGNlbGxTaXplLCBkYXRhSW5kZXgsIGksIHRoaXMpO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAgICAgLy/lsIZjb250ZW5055qE5L2N572u56e75Yqo5Yiw5pyA5Y+z5L6n5bm25a+56b2Q56e75Yqo5YmN55qE54q25oCBXHJcbiAgICAgICAgICAgICAgICAgICAgbGV0IHBvc1ggPSAoY2VsbExlZnQgLSB0aGlzLnZpZXdTaWRlcy5sZWZ0U2lkZSkgLSBjb250ZW50V2lkdGg7XHJcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5zY3JvbGxWaWV3LmNvbnRlbnQuc2V0UG9zaXRpb24oY2MudjMocG9zWCwgdGhpcy5zY3JvbGxWaWV3LmNvbnRlbnQucG9zaXRpb24ueSkpO1xyXG4gICAgICAgICAgICAgICAgICAgIHRoaXMuc2Nyb2xsVmlldy5zY3JvbGxUb09mZnNldChjYy52MigtIChwb3NYICsgc3RhcnRDZWxsLnNpemUud2lkdGgpLCAwKSwgMSlcclxuICAgICAgICAgICAgICAgICAgICB0aGlzLmxhc3RQb3MgPSBudWxsO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfVxyXG4gICAgfVxyXG5cclxuXHJcbiAgICAvKirmm7TmlrDoioLngrnnmoTmmL7npLogKi9cclxuICAgIHB1YmxpYyB1cGRhdGVOb2RlcygpIHtcclxuICAgICAgICBsZXQgc2hvd0NlbGxzOiBJdGVtQ2VsbDxUPltdID0gW107XHJcbiAgICAgICAgZm9yIChsZXQgaSA9IDAsIGxlbiA9IHRoaXMuaXRlbUNlbGxzLmxlbmd0aDsgaSA8IGxlbjsgKytpKSB7XHJcbiAgICAgICAgICAgIGxldCBpdGVtQ2VsbCA9IHRoaXMuaXRlbUNlbGxzW2ldO1xyXG4gICAgICAgICAgICBsZXQgaXNTaG93ID0gdGhpcy5kZWFsSXRlbVNob3coaXRlbUNlbGwpXHJcbiAgICAgICAgICAgIGlmIChpc1Nob3cpIHtcclxuICAgICAgICAgICAgICAgIHNob3dDZWxscy5wdXNoKGl0ZW1DZWxsKVxyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfVxyXG4gICAgICAgIHJldHVybiBzaG93Q2VsbHM7XHJcbiAgICB9XHJcblxyXG4gICAgLyoqXHJcbiAgICAgKiDlpITnkIZjZWxs55qE5pi+56S66ZqQ6JePXHJcbiAgICAgKiBAcGFyYW0gaXRlbUNlbGwgXHJcbiAgICAgKi9cclxuICAgIHByaXZhdGUgZGVhbEl0ZW1TaG93KGl0ZW1DZWxsOiBJdGVtQ2VsbDxUPikge1xyXG4gICAgICAgIGlmIChpdGVtQ2VsbCkge1xyXG4gICAgICAgICAgICBsZXQgaXNTaG93ID0gdGhpcy5jaGVja0luVmlldyhpdGVtQ2VsbCk7XHJcbiAgICAgICAgICAgIGlmIChpc1Nob3cpIHtcclxuICAgICAgICAgICAgICAgIGl0ZW1DZWxsLmhhc05vTm9kZSAmJiBpdGVtQ2VsbC51cGRhdGVTaG93KGlzU2hvdywgdGhpcy5wcmVmYWIsIHRoaXMuc2hvd05vZGVQb29sLmxlbmd0aCA+IDAgPyB0aGlzLnNob3dOb2RlUG9vbC5wb3AoKSA6IG51bGwsIHRoaXMucmVuZGVyTGF5ZXIpO1xyXG4gICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgIWl0ZW1DZWxsLmhhc05vTm9kZSAmJiB0aGlzLnJlY2lyY2xlU2hvd05vZGUoaXRlbUNlbGwucmVjaXJjbGUoKSk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgcmV0dXJuIGlzU2hvdztcclxuICAgICAgICB9XHJcbiAgICB9XHJcblxyXG5cclxuICAgIC8qKlxyXG4gICAgICog5qOA5p+l5piv5ZCm5Zyo5bGP5bmV5YaFXHJcbiAgICAgKiBAcGFyYW0gbm9kZSBcclxuICAgICAqIEByZXR1cm5zIFxyXG4gICAgICovXHJcbiAgICBwcml2YXRlIGNoZWNrSW5WaWV3KGl0ZW1DZWxsOiBJdGVtQ2VsbDxUPikge1xyXG4gICAgICAgIGxldCBub2RlU2lkZXMgPSBnZXROb2RlQm9yZGVyKGl0ZW1DZWxsLCBbdHJ1ZSwgdHJ1ZSwgdHJ1ZSwgdHJ1ZV0pO1xyXG4gICAgICAgIC8v6IqC54K55Y+z5L6n6L6557yY5Zyo5bGP5bmV5bem5L6n5aSW6Z2i5oiW6ICF6IqC54K55bem6L6557yY5Zyo5bGP5bmV5Y+z5L6n5aSW6Z2iIOWImeS4jeWcqOaYvuekuuWMuuWfn1xyXG4gICAgICAgIGxldCBob3Jpem9udGFsT3V0c2lkZSA9IG5vZGVTaWRlcy5yaWdodFNpZGUgPCB0aGlzLnZpZXdTaWRlcy5sZWZ0U2lkZVxyXG4gICAgICAgICAgICB8fCBub2RlU2lkZXMubGVmdFNpZGUgPiB0aGlzLnZpZXdTaWRlcy5yaWdodFNpZGU7XHJcblxyXG4gICAgICAgIGxldCB2ZXJ0aWNhbE91dHNpZGUgPSBmYWxzZTtcclxuICAgICAgICBpZiAoIWhvcml6b250YWxPdXRzaWRlKSB7XHJcbiAgICAgICAgICAgIC8v6IqC54K55LiK6L6557yY5Zyo5bGP5bmV5LiL5pa55aSW6Z2i5oiW6ICF6IqC54K55LiL6L6557yY5Zyo5bGP5bmV5LiK5pa55aSW6Z2iIOWImeS4jeWcqOaYvuekuuWMuuWfn1xyXG4gICAgICAgICAgICB2ZXJ0aWNhbE91dHNpZGUgPSBub2RlU2lkZXMudG9wU2lkZSA8IHRoaXMudmlld1NpZGVzLmJvdHRvbVNpZGVcclxuICAgICAgICAgICAgICAgIHx8IG5vZGVTaWRlcy5ib3R0b21TaWRlID4gdGhpcy52aWV3U2lkZXMudG9wU2lkZTtcclxuICAgICAgICB9XHJcbiAgICAgICAgcmV0dXJuICFob3Jpem9udGFsT3V0c2lkZSAmJiAhdmVydGljYWxPdXRzaWRlO1xyXG4gICAgfVxyXG4gICAgLyoqXHJcbiAgICAgKiDlpITnkIblj5jljJbnmoTlpKflsI9cclxuICAgICAqIEBwYXJhbSBjZWxsIFxyXG4gICAgICogQHBhcmFtIG5vZGVTaWRlcyBcclxuICAgICAqIEBwYXJhbSBjaGFuZ2VTaXplIFxyXG4gICAgICovXHJcbiAgICBwdWJsaWMgYXN5bmMgZGVhbENoYW5nZVNpemUoY2VsbDogSXRlbUNlbGw8VD4sIG5vZGVTaWRlczogSUJvcmRlciwgY2hhbmdlU2l6ZTogY2MuU2l6ZSwgdGltZTogbnVtYmVyID0gMC4zKSB7XHJcbiAgICAgICAgbGV0IHRvcFRvQm90dG9tRnVsZmlsbCA9ICh0aGlzLnNjcm9sbFZpZXcuY29udGVudC5hbmNob3JZID09IDEgJiYgbm9kZVNpZGVzLmJvdHRvbVNpZGUgPj0gdGhpcy52aWV3U2lkZXMudG9wU2lkZSk7XHJcbiAgICAgICAgbGV0IGJvdHRvbVRvVG9wRnVsZmlsbCA9ICh0aGlzLnNjcm9sbFZpZXcuY29udGVudC5hbmNob3JZID09IDAgJiYgbm9kZVNpZGVzLnRvcFNpZGUgPD0gdGhpcy52aWV3U2lkZXMuYm90dG9tU2lkZSk7XHJcbiAgICAgICAgaWYgKHRvcFRvQm90dG9tRnVsZmlsbCB8fCBib3R0b21Ub1RvcEZ1bGZpbGwpIHtcclxuICAgICAgICAgICAgaWYgKHRvcFRvQm90dG9tRnVsZmlsbCkge1xyXG4gICAgICAgICAgICAgICAgdGhpcy5zY3JvbGxWaWV3LnNldENvbnRlbnRQb3NpdGlvbihjYy52Mih0aGlzLnNjcm9sbFZpZXcuY29udGVudC54LCB0aGlzLnNjcm9sbFZpZXcuY29udGVudC55ICsgY2hhbmdlU2l6ZS5oZWlnaHQpKVxyXG4gICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgdGhpcy5zY3JvbGxWaWV3LnNldENvbnRlbnRQb3NpdGlvbihjYy52Mih0aGlzLnNjcm9sbFZpZXcuY29udGVudC54LCB0aGlzLnNjcm9sbFZpZXcuY29udGVudC55IC0gY2hhbmdlU2l6ZS5oZWlnaHQpKVxyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfVxyXG4gICAgICAgIGxldCBsZWZ0VG9SaWdodEZ1bGZpbGwgPSAodGhpcy5zY3JvbGxWaWV3LmNvbnRlbnQuYW5jaG9yWCA9PSAwICYmIG5vZGVTaWRlcy5yaWdodFNpZGUgPD0gdGhpcy52aWV3U2lkZXMubGVmdFNpZGUpO1xyXG4gICAgICAgIGxldCBSaWdodFRvTGVmdEZ1bGZpbGwgPSAodGhpcy5zY3JvbGxWaWV3LmNvbnRlbnQuYW5jaG9yWCA9PSAxICYmIG5vZGVTaWRlcy5sZWZ0U2lkZSA+PSB0aGlzLnZpZXdTaWRlcy5yaWdodFNpZGUpO1xyXG4gICAgICAgIGlmIChsZWZ0VG9SaWdodEZ1bGZpbGwgfHwgUmlnaHRUb0xlZnRGdWxmaWxsKSB7XHJcbiAgICAgICAgICAgIGlmIChSaWdodFRvTGVmdEZ1bGZpbGwpIHtcclxuICAgICAgICAgICAgICAgIHRoaXMuc2Nyb2xsVmlldy5zZXRDb250ZW50UG9zaXRpb24oY2MudjIodGhpcy5zY3JvbGxWaWV3LmNvbnRlbnQueCArIGNoYW5nZVNpemUud2lkdGgsIHRoaXMuc2Nyb2xsVmlldy5jb250ZW50LnkpKVxyXG4gICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgdGhpcy5zY3JvbGxWaWV3LnNldENvbnRlbnRQb3NpdGlvbihjYy52Mih0aGlzLnNjcm9sbFZpZXcuY29udGVudC54IC0gY2hhbmdlU2l6ZS53aWR0aCwgdGhpcy5zY3JvbGxWaWV3LmNvbnRlbnQueSkpXHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9XHJcbiAgICAgICAgaWYgKCEodG9wVG9Cb3R0b21GdWxmaWxsIHx8IGJvdHRvbVRvVG9wRnVsZmlsbCB8fCBsZWZ0VG9SaWdodEZ1bGZpbGwgfHwgUmlnaHRUb0xlZnRGdWxmaWxsKSkge1xyXG4gICAgICAgICAgICBjYy5Ud2Vlbi5zdG9wQWxsQnlUYXJnZXQoY2VsbC5ub2RlKTtcclxuICAgICAgICAgICAgYXdhaXQgbmV3IFByb21pc2U8dm9pZD4oKHJlc29sdmUsIHJlamVjdCkgPT4ge1xyXG4gICAgICAgICAgICAgICAgY2MudHdlZW4oY2VsbC5ub2RlKS50byh0aW1lLCB7IHdpZHRoOiBjZWxsLnNpemUud2lkdGgsIGhlaWdodDogY2VsbC5zaXplLmhlaWdodCB9KS5jYWxsKCgpID0+IHtcclxuICAgICAgICAgICAgICAgICAgICByZXNvbHZlKCk7XHJcbiAgICAgICAgICAgICAgICB9KS5zdGFydCgpO1xyXG4gICAgICAgICAgICB9KVxyXG4gICAgICAgIH1cclxuICAgICAgICB0aGlzLnVwZGF0ZU5vZGVzKCk7XHJcbiAgICAgICAgcmV0dXJuIHRydWU7XHJcbiAgICB9XHJcblxyXG4gICAgLyoqXHJcbiAgICAgKiDlm57mlLbmmL7npLroioLngrlcclxuICAgICAqIEBwYXJhbSBub2RlIFxyXG4gICAgICovXHJcbiAgICBwcml2YXRlIHJlY2lyY2xlU2hvd05vZGUobm9kZTogU2hvd05vZGU8VD4pIHtcclxuICAgICAgICBub2RlICYmIHRoaXMuc2hvd05vZGVQb29sLnB1c2gobm9kZSk7XHJcbiAgICB9XHJcblxyXG4gICAgLyoqXHJcbiAgICAgKiDph4rmlL7lvZPliY3liJfooahcclxuICAgICAqL1xyXG4gICAgcHVibGljIGZyZWVMaXN0KCkge1xyXG4gICAgICAgIHRoaXMuc2Nyb2xsVmlldy5ub2RlLm9mZihcInNjcm9sbGluZ1wiLCB0aGlzLnNjcm9sbGluZ0xpc3RlbmVyKTtcclxuICAgICAgICBmb3IgKGxldCBpID0gMCwgbGVuID0gdGhpcy5pdGVtQ2VsbHMubGVuZ3RoOyBpIDwgbGVuOyArK2kpIHtcclxuICAgICAgICAgICAgdGhpcy5yZWNpcmNsZVNob3dOb2RlKHRoaXMuaXRlbUNlbGxzW2ldLnJlY2lyY2xlKCkpO1xyXG4gICAgICAgICAgICB0aGlzLml0ZW1DZWxsc1tpXS5kZXN0cm95KCk7XHJcbiAgICAgICAgfVxyXG4gICAgICAgIHRoaXMuaXRlbUNlbGxzID0gW107XHJcbiAgICAgICAgZm9yIChsZXQgaW5kZXggPSAwLCBsZW4gPSB0aGlzLnNob3dOb2RlUG9vbC5sZW5ndGg7IGluZGV4IDwgbGVuOyArK2luZGV4KSB7XHJcbiAgICAgICAgICAgIHRoaXMuc2hvd05vZGVQb29sW2luZGV4XS5kZXN0cm95KCk7XHJcbiAgICAgICAgfVxyXG4gICAgICAgIHRoaXMuc2hvd05vZGVQb29sID0gW107XHJcbiAgICAgICAgdGhpcy5yZW5kZXJMYXllciA9IG51bGw7XHJcbiAgICAgICAgdGhpcy5zY3JvbGxWaWV3ID0gbnVsbDtcclxuICAgICAgICB0aGlzLnByZWZhYiA9IG51bGw7XHJcbiAgICB9XHJcblxyXG59XHJcbi8qKlxyXG4gKiDojrflj5boioLngrnnmoTovrnnvJhcclxuICogQHBhcmFtIG5vZGUgXHJcbiAqIEBwYXJhbSBuZWVkQXJyIOmhuuW6j+aYr+S4iiDkuIsg5bemIOWPs1xyXG4gKi9cclxuZnVuY3Rpb24gZ2V0Tm9kZUJvcmRlcihjZWxsOiBJdGVtQ2VsbDxhbnk+LCBuZWVkQXJyOiBib29sZWFuW10pIHtcclxuICAgIGxldCBub2RlID0gY2VsbC5ub2RlXHJcbiAgICBsZXQgYm9kZXJEYXRhOiBJQm9yZGVyID0ge307XHJcbiAgICBsZXQgd3BvcyA9IGdldE5vZGVXUG9zKG5vZGUpO1xyXG4gICAgLy/mmL7npLrljLrln5/kuIrovrnnvJhcclxuICAgIGlmIChuZWVkQXJyWzBdKSB7XHJcbiAgICAgICAgYm9kZXJEYXRhLnRvcFNpZGUgPSB3cG9zLnkgKyAobm9kZS5oZWlnaHQgKiAoMSAtIG5vZGUuYW5jaG9yWSkpO1xyXG4gICAgfVxyXG4gICAgLy/mmL7npLrljLrln5/kuIvovrnnvJhcclxuICAgIGlmIChuZWVkQXJyWzFdKSB7XHJcbiAgICAgICAgYm9kZXJEYXRhLmJvdHRvbVNpZGUgPSB3cG9zLnkgLSAobm9kZS5oZWlnaHQgKiBub2RlLmFuY2hvclkpO1xyXG4gICAgfVxyXG4gICAgLy/mmL7npLrljLrln5/lt6bovrnnvJhcclxuICAgIGlmIChuZWVkQXJyWzJdKSB7XHJcbiAgICAgICAgYm9kZXJEYXRhLmxlZnRTaWRlID0gd3Bvcy54IC0gKG5vZGUud2lkdGggKiBub2RlLmFuY2hvclgpO1xyXG4gICAgfVxyXG4gICAgLy/mmL7npLrljLrln5/lj7PovrnnvJhcclxuICAgIGlmIChuZWVkQXJyWzNdKSB7XHJcbiAgICAgICAgYm9kZXJEYXRhLnJpZ2h0U2lkZSA9IHdwb3MueCArIChub2RlLndpZHRoICogKDEgLSBub2RlLmFuY2hvclgpKTtcclxuICAgIH1cclxuICAgIGJvZGVyRGF0YS5zaXplID0gY2Muc2l6ZShub2RlLndpZHRoLCBub2RlLmhlaWdodCk7XHJcbiAgICByZXR1cm4gYm9kZXJEYXRhO1xyXG59XHJcblxyXG4vKipcclxuICog6I635Y+W6IqC54K55LiW55WM5Z2Q5qCHXHJcbiAqIEBwYXJhbSBub2RlIFxyXG4gKiBAcmV0dXJucyBcclxuICovXHJcbmZ1bmN0aW9uIGdldE5vZGVXUG9zKG5vZGU6IGNjLk5vZGUpIHtcclxuICAgIHJldHVybiBub2RlLnBhcmVudC5jb252ZXJ0VG9Xb3JsZFNwYWNlQVIobm9kZS5wb3NpdGlvbik7XHJcbn1cclxuXHJcblxyXG4iXX0= +//------QC-SOURCE-SPLIT------ + + (function() { + var nodeEnv = typeof require !== 'undefined' && typeof process !== 'undefined'; + var __module = nodeEnv ? module : {exports:{}}; + var __filename = 'preview-scripts/assets/Script/RenderAlternative_old.js'; + var __require = nodeEnv ? function (request) { + return cc.require(request); + } : function (request) { + return __quick_compile_project__.require(request, __filename); + }; + function __define (exports, require, module) { + if (!nodeEnv) {__quick_compile_project__.registerModule(__filename, module);}"use strict"; +cc._RF.push(module, '1b478Wr4HlMhLdWnJWcD6fi', 'RenderAlternative_old'); +// Script/RenderAlternative_old.ts + +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var RenderReactiveHandler_1 = require("./RenderReactiveHandler"); +/** + * 目前该渲染代理功能存在的问题 + * 1.被代理节点的父级不能出现scaleX和scaleY不一致的情况,被代理节点本身没有这个限制 + */ +var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property; +var RenderAlternative = /** @class */ (function (_super) { + __extends(RenderAlternative, _super); + function RenderAlternative() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /**渲染层节点 */ + _this.renderLayer = null; + /**渲染的zIndex 动态调整zIndex,用于方便临近合批 */ + _this.renderZIndex = 0; + /**同步的间隔(帧为单位) */ + _this.syncInv = 0.01; + /**渲染的sIndex */ + _this.sIndex = 0; + /**非渲染组件 */ + _this.proxyRender = null; + /**渲染组件 */ + _this.renderCompnent = null; + /**上次更新的数据 */ + _this.lastWMat4 = null; + /**上次更新的数据 */ + _this.lastLMat4 = null; + /**上次更新的数据 */ + _this.lastPos = null; + /**距离下次刷新累计了多少间隔 */ + _this.accuTime = 0; + /**最后一次刷新时间 */ + _this.lastFrameTime = null; + /**是否进行刷新 */ + _this.isAttachFrame = false; + return _this; + } + RenderAlternative_1 = RenderAlternative; + Object.defineProperty(RenderAlternative.prototype, "zIndex", { + /**获取总的ZIndex */ + get: function () { + var zIndex = this.renderZIndex + (this.sIndex * 0.01); + var parentNode = this.node.parent; + while (parentNode != this.renderLayer.parent && parentNode != cc.director.getScene()) { + var render = parentNode.getComponent(RenderAlternative_1); + if (render) { + zIndex += render.zIndex + 1; + break; + } + parentNode = parentNode.parent; + } + return zIndex; + }, + enumerable: false, + configurable: true + }); + /** + * 设置渲染节点层 + * @param layer + */ + RenderAlternative.prototype.init = function (layer) { + if (layer) { + this.renderLayer = layer; + } + if (!this.renderLayer) { + console.warn("\u8282\u70B9" + this.node.name + "\u6CA1\u6709\u8BBE\u7F6E\u6E32\u67D3\u5C42"); + return null; + } + return this.initRender(); + }; + /** + * 初始化渲染节点 + */ + RenderAlternative.prototype.initRender = function () { + var node = this.getRender(); + node.setParent(this.renderLayer ? this.renderLayer : cc.director.getScene().getChildByName("Canvas")); + this.isAttachFrame = true; + requestAnimationFrame(this.frameUpdate.bind(this)); + return this.doProxy(); + }; + /**生成代理 */ + RenderAlternative.prototype.doProxy = function () { + this.proxyRender = new Proxy(this.renderCompnent, new RenderReactiveHandler_1.RenderReactiveHandler()); + return this.proxyRender; + }; + RenderAlternative.prototype.frameUpdate = function () { + var now = cc.sys.now(); + !this.lastFrameTime && (this.lastFrameTime = now); + var dt = now - this.lastFrameTime; + if (this.proxyRender) { + this.accuTime += dt; + if (this.accuTime >= this.syncInv) { + this.accuTime -= this.syncInv; + this.updateProp(); + } + } + if (this.isAttachFrame) { + requestAnimationFrame(this.frameUpdate.bind(this)); + } + }; + /**更新最新状态 */ + RenderAlternative.prototype.updateProp = function () { + var node = this.renderCompnent.node; + if (!this.node.activeInHierarchy) { + node.opacity = 0; + return; + } + node.anchorX = this.node.anchorX; + node.anchorY = this.node.anchorY; + node.width = this.node.width; + node.height = this.node.height; + node.group = this.node.group; + node.color = this.node.color; + node.opacity = this.getOpacity(this.node); + var wMat4 = cc.mat4(); + this.node.getWorldMatrix(wMat4); + /* let lMat4 = cc.mat4(); + this.node.getLocalMatrix(wMat4); */ + //此处本可以过滤许多不必要的更新,但尚未排查出问题 + if (true /* || !this.lastWMat4?.equals(wMat4) || !this.lastLMat4?.equals(lMat4) */) { + this.onAngleChange(wMat4); + this.onScaleChange(wMat4); + this.onPosChange(); + /* this.lastLMat4 = lMat4; + this.lastWMat4 = wMat4; */ + } + node.zIndex = this.zIndex; + node.zIndex = this.zIndex; + }; + RenderAlternative.prototype.onDestroy = function () { + this.renderCompnent.node.destroy(); + this.renderCompnent = null; + this.proxyRender = null; + }; + /** + * 获取节点透明度 + * @param node + */ + RenderAlternative.prototype.getOpacity = function (node) { + var opacity = (node.opacity / 255); + var parentNode = node.parent; + while (parentNode != this.renderLayer.parent && parentNode != cc.director.getScene()) { + opacity *= (parentNode.opacity / 255); + parentNode = parentNode.parent; + } + return opacity * 255; + }; + /**位置变化处理 */ + RenderAlternative.prototype.onPosChange = function () { + var wpos = this.node.parent.convertToWorldSpaceAR(this.node.position); + this.renderCompnent.node.position = this.renderLayer.convertToNodeSpaceAR(wpos); + }; + /**旋转变化处理 */ + RenderAlternative.prototype.onAngleChange = function (mat4) { + this.renderCompnent.node.angle = this.extractRotationAngleFromMat4(mat4); + }; + /** + * 从 cc.Mat4 中获取旋转角度(不受缩放影响) + * @param matrix 输入的 cc.Mat4 矩阵 + * @returns 旋转角度(以度为单位) + */ + RenderAlternative.prototype.extractRotationAngleFromMat4 = function (matrix) { + // 提取旋转部分 + var scaleX = Math.sqrt(matrix.m[0] * matrix.m[0] + matrix.m[4] * matrix.m[4] + matrix.m[8] * matrix.m[8]); + var scaleY = Math.sqrt(matrix.m[1] * matrix.m[1] + matrix.m[5] * matrix.m[5] + matrix.m[9] * matrix.m[9]); + // 计算 Z 轴旋转角度(绕 Z 轴的旋转角度) + var angle = Math.atan2(matrix.m[1] / scaleY, matrix.m[0] / scaleX); + // 将弧度转换为角度 + var degrees = angle * (180 / Math.PI); + return degrees; + }; + /** + * 缩放变化处理 + * @param mat4 + */ + RenderAlternative.prototype.onScaleChange = function (mat4) { + var scale = this.extractScaleFromMat4(mat4); + this.renderCompnent.node.scaleX = scale.x; + this.renderCompnent.node.scaleY = scale.y; + this.renderCompnent.node.scaleZ = scale.z; + }; + /** + * 从mat4中获取缩放值 + * @param mat4 + * @returns + */ + RenderAlternative.prototype.extractScaleFromMat4 = function (mat4) { + var scaleX = cc.v3(mat4.m[0], mat4.m[1], mat4.m[2]).mag(); + var scaleY = cc.v3(mat4.m[4], mat4.m[5], mat4.m[6]).mag(); + var scaleZ = cc.v3(mat4.m[8], mat4.m[9], mat4.m[10]).mag(); + return cc.v3(scaleX, scaleY, scaleZ); + }; + /** + * 获取渲染组件 + * @param node + */ + RenderAlternative.prototype.getRender = function () { + var _a, _b; + var node = cc.instantiate(this.node); + node.removeAllChildren(); + this.renderCompnent = node.getComponent(cc.RenderComponent); + (_a = this.node.getComponent(cc.LabelOutline)) === null || _a === void 0 ? void 0 : _a.destroy(); + (_b = this.node.getComponent(cc.LabelShadow)) === null || _b === void 0 ? void 0 : _b.destroy(); + this.node.getComponent(cc.RenderComponent).destroy(); + var components = node.getComponents(cc.Component); + for (var i = 0, len = components.length; i < len; ++i) { + var comp = components[i]; + if (!((comp instanceof cc.RenderComponent) || (comp instanceof cc.LabelOutline) || (comp instanceof cc.LabelShadow))) { + comp.destroy(); + } + } + return node; + }; + var RenderAlternative_1; + __decorate([ + property + ], RenderAlternative.prototype, "renderZIndex", void 0); + __decorate([ + property({ + tooltip: '设置同步的间隔(秒为单位),0就是每帧都同步,0.1就是隔0.1秒同步一次' + }) + ], RenderAlternative.prototype, "syncInv", void 0); + RenderAlternative = RenderAlternative_1 = __decorate([ + ccclass + ], RenderAlternative); + return RenderAlternative; +}(cc.Component)); +exports.default = RenderAlternative; + +cc._RF.pop(); + } + if (nodeEnv) { + __define(__module.exports, __require, __module); + } + else { + __quick_compile_project__.registerModuleFunc(__filename, function () { + __define(__module.exports, __require, __module); + }); + } + })(); +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImFzc2V0c1xcU2NyaXB0XFxSZW5kZXJBbHRlcm5hdGl2ZV9vbGQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0FBQUEsaUVBQWdFO0FBRWhFOzs7R0FHRztBQUNHLElBQUEsS0FBd0IsRUFBRSxDQUFDLFVBQVUsRUFBbkMsT0FBTyxhQUFBLEVBQUUsUUFBUSxjQUFrQixDQUFDO0FBRTVDO0lBQStDLHFDQUFZO0lBQTNEO1FBQUEscUVBa05DO1FBak5HLFdBQVc7UUFDSixpQkFBVyxHQUFZLElBQUksQ0FBQztRQUNuQyxtQ0FBbUM7UUFFNUIsa0JBQVksR0FBVyxDQUFDLENBQUM7UUFDaEMsaUJBQWlCO1FBSVYsYUFBTyxHQUFXLElBQUksQ0FBQztRQUM5QixlQUFlO1FBQ1IsWUFBTSxHQUFXLENBQUMsQ0FBQztRQUMxQixXQUFXO1FBQ0osaUJBQVcsR0FBdUIsSUFBSSxDQUFDO1FBQzlDLFVBQVU7UUFDRixvQkFBYyxHQUF1QixJQUFJLENBQUM7UUFDbEQsYUFBYTtRQUNOLGVBQVMsR0FBWSxJQUFJLENBQUM7UUFDakMsYUFBYTtRQUNOLGVBQVMsR0FBWSxJQUFJLENBQUM7UUFDakMsYUFBYTtRQUNOLGFBQU8sR0FBWSxJQUFJLENBQUM7UUFDL0IsbUJBQW1CO1FBQ1osY0FBUSxHQUFXLENBQUMsQ0FBQztRQUM1QixjQUFjO1FBQ1AsbUJBQWEsR0FBVyxJQUFJLENBQUM7UUFDcEMsWUFBWTtRQUNMLG1CQUFhLEdBQVksS0FBSyxDQUFDOztJQXNMMUMsQ0FBQzswQkFsTm9CLGlCQUFpQjtJQStCbEMsc0JBQUkscUNBQU07UUFEVixnQkFBZ0I7YUFDaEI7WUFDSSxJQUFJLE1BQU0sR0FBRyxJQUFJLENBQUMsWUFBWSxHQUFHLENBQUMsSUFBSSxDQUFDLE1BQU0sR0FBRyxJQUFJLENBQUMsQ0FBQztZQUN0RCxJQUFJLFVBQVUsR0FBRyxJQUFJLENBQUMsSUFBSSxDQUFDLE1BQU0sQ0FBQztZQUNsQyxPQUFPLFVBQVUsSUFBSSxJQUFJLENBQUMsV0FBVyxDQUFDLE1BQU0sSUFBSSxVQUFVLElBQUksRUFBRSxDQUFDLFFBQVEsQ0FBQyxRQUFRLEVBQUUsRUFBRTtnQkFDbEYsSUFBSSxNQUFNLEdBQUcsVUFBVSxDQUFDLFlBQVksQ0FBQyxtQkFBaUIsQ0FBQyxDQUFDO2dCQUN4RCxJQUFJLE1BQU0sRUFBRTtvQkFDUixNQUFNLElBQUksTUFBTSxDQUFDLE1BQU0sR0FBRyxDQUFDLENBQUM7b0JBQzVCLE1BQU07aUJBQ1Q7Z0JBQ0QsVUFBVSxHQUFHLFVBQVUsQ0FBQyxNQUFNLENBQUM7YUFDbEM7WUFDRCxPQUFPLE1BQU0sQ0FBQztRQUNsQixDQUFDOzs7T0FBQTtJQUVEOzs7T0FHRztJQUNILGdDQUFJLEdBQUosVUFBbUMsS0FBZTtRQUM5QyxJQUFJLEtBQUssRUFBRTtZQUNQLElBQUksQ0FBQyxXQUFXLEdBQUcsS0FBSyxDQUFDO1NBQzVCO1FBQ0QsSUFBSSxDQUFDLElBQUksQ0FBQyxXQUFXLEVBQUU7WUFDbkIsT0FBTyxDQUFDLElBQUksQ0FBQyxpQkFBSyxJQUFJLENBQUMsSUFBSSxDQUFDLElBQUksK0NBQVMsQ0FBQyxDQUFBO1lBQzFDLE9BQU8sSUFBSSxDQUFDO1NBQ2Y7UUFDRCxPQUFPLElBQUksQ0FBQyxVQUFVLEVBQUssQ0FBQztJQUNoQyxDQUFDO0lBQ0Q7O09BRUc7SUFDSyxzQ0FBVSxHQUFsQjtRQUNJLElBQUksSUFBSSxHQUFHLElBQUksQ0FBQyxTQUFTLEVBQUUsQ0FBQztRQUM1QixJQUFJLENBQUMsU0FBUyxDQUFDLElBQUksQ0FBQyxXQUFXLENBQUMsQ0FBQyxDQUFDLElBQUksQ0FBQyxXQUFXLENBQUMsQ0FBQyxDQUFDLEVBQUUsQ0FBQyxRQUFRLENBQUMsUUFBUSxFQUFFLENBQUMsY0FBYyxDQUFDLFFBQVEsQ0FBQyxDQUFDLENBQUM7UUFDdEcsSUFBSSxDQUFDLGFBQWEsR0FBRyxJQUFJLENBQUM7UUFDMUIscUJBQXFCLENBQUMsSUFBSSxDQUFDLFdBQVcsQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLENBQUMsQ0FBQztRQUNuRCxPQUFPLElBQUksQ0FBQyxPQUFPLEVBQUssQ0FBQztJQUM3QixDQUFDO0lBQ0QsVUFBVTtJQUNGLG1DQUFPLEdBQWY7UUFDSSxJQUFJLENBQUMsV0FBVyxHQUFHLElBQUksS0FBSyxDQUFDLElBQUksQ0FBQyxjQUFjLEVBQUUsSUFBSSw2Q0FBcUIsRUFBRSxDQUFNLENBQUM7UUFDcEYsT0FBTyxJQUFJLENBQUMsV0FBZ0IsQ0FBQztJQUNqQyxDQUFDO0lBR1MsdUNBQVcsR0FBckI7UUFDSSxJQUFJLEdBQUcsR0FBRyxFQUFFLENBQUMsR0FBRyxDQUFDLEdBQUcsRUFBRSxDQUFDO1FBQ3ZCLENBQUMsSUFBSSxDQUFDLGFBQWEsSUFBSSxDQUFDLElBQUksQ0FBQyxhQUFhLEdBQUcsR0FBRyxDQUFDLENBQUM7UUFDbEQsSUFBSSxFQUFFLEdBQUcsR0FBRyxHQUFHLElBQUksQ0FBQyxhQUFhLENBQUM7UUFDbEMsSUFBSSxJQUFJLENBQUMsV0FBVyxFQUFFO1lBQ2xCLElBQUksQ0FBQyxRQUFRLElBQUksRUFBRSxDQUFDO1lBQ3BCLElBQUksSUFBSSxDQUFDLFFBQVEsSUFBSSxJQUFJLENBQUMsT0FBTyxFQUFFO2dCQUMvQixJQUFJLENBQUMsUUFBUSxJQUFJLElBQUksQ0FBQyxPQUFPLENBQUM7Z0JBQzlCLElBQUksQ0FBQyxVQUFVLEVBQUUsQ0FBQzthQUNyQjtTQUNKO1FBQ0QsSUFBSSxJQUFJLENBQUMsYUFBYSxFQUFFO1lBQ3BCLHFCQUFxQixDQUFDLElBQUksQ0FBQyxXQUFXLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxDQUFDLENBQUM7U0FDdEQ7SUFDTCxDQUFDO0lBRUQsWUFBWTtJQUNMLHNDQUFVLEdBQWpCO1FBQ0ksSUFBSSxJQUFJLEdBQUcsSUFBSSxDQUFDLGNBQWMsQ0FBQyxJQUFJLENBQUM7UUFDcEMsSUFBSSxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsaUJBQWlCLEVBQUU7WUFDOUIsSUFBSSxDQUFDLE9BQU8sR0FBRyxDQUFDLENBQUM7WUFDakIsT0FBTztTQUNWO1FBQ0QsSUFBSSxDQUFDLE9BQU8sR0FBRyxJQUFJLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQztRQUNqQyxJQUFJLENBQUMsT0FBTyxHQUFHLElBQUksQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDO1FBQ2pDLElBQUksQ0FBQyxLQUFLLEdBQUcsSUFBSSxDQUFDLElBQUksQ0FBQyxLQUFLLENBQUM7UUFDN0IsSUFBSSxDQUFDLE1BQU0sR0FBRyxJQUFJLENBQUMsSUFBSSxDQUFDLE1BQU0sQ0FBQztRQUMvQixJQUFJLENBQUMsS0FBSyxHQUFHLElBQUksQ0FBQyxJQUFJLENBQUMsS0FBSyxDQUFDO1FBQzdCLElBQUksQ0FBQyxLQUFLLEdBQUcsSUFBSSxDQUFDLElBQUksQ0FBQyxLQUFLLENBQUM7UUFDN0IsSUFBSSxDQUFDLE9BQU8sR0FBRyxJQUFJLENBQUMsVUFBVSxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsQ0FBQztRQUUxQyxJQUFJLEtBQUssR0FBRyxFQUFFLENBQUMsSUFBSSxFQUFFLENBQUM7UUFDdEIsSUFBSSxDQUFDLElBQUksQ0FBQyxjQUFjLENBQUMsS0FBSyxDQUFDLENBQUM7UUFDaEM7MkNBQ21DO1FBQ25DLDBCQUEwQjtRQUMxQixJQUFJLElBQUksQ0FBQyx5RUFBeUUsRUFBRTtZQUNoRixJQUFJLENBQUMsYUFBYSxDQUFDLEtBQUssQ0FBQyxDQUFDO1lBQzFCLElBQUksQ0FBQyxhQUFhLENBQUMsS0FBSyxDQUFDLENBQUM7WUFDMUIsSUFBSSxDQUFDLFdBQVcsRUFBRSxDQUFDO1lBQ25CO3VDQUMyQjtTQUM5QjtRQUNELElBQUksQ0FBQyxNQUFNLEdBQUcsSUFBSSxDQUFDLE1BQU0sQ0FBQztRQUMxQixJQUFJLENBQUMsTUFBTSxHQUFHLElBQUksQ0FBQyxNQUFNLENBQUM7SUFDOUIsQ0FBQztJQUVTLHFDQUFTLEdBQW5CO1FBQ0ksSUFBSSxDQUFDLGNBQWMsQ0FBQyxJQUFJLENBQUMsT0FBTyxFQUFFLENBQUM7UUFDbkMsSUFBSSxDQUFDLGNBQWMsR0FBRyxJQUFJLENBQUM7UUFDM0IsSUFBSSxDQUFDLFdBQVcsR0FBRyxJQUFJLENBQUM7SUFDNUIsQ0FBQztJQUVEOzs7T0FHRztJQUNLLHNDQUFVLEdBQWxCLFVBQW1CLElBQWE7UUFDNUIsSUFBSSxPQUFPLEdBQUcsQ0FBQyxJQUFJLENBQUMsT0FBTyxHQUFHLEdBQUcsQ0FBQyxDQUFDO1FBQ25DLElBQUksVUFBVSxHQUFHLElBQUksQ0FBQyxNQUFNLENBQUE7UUFDNUIsT0FBTyxVQUFVLElBQUksSUFBSSxDQUFDLFdBQVcsQ0FBQyxNQUFNLElBQUksVUFBVSxJQUFJLEVBQUUsQ0FBQyxRQUFRLENBQUMsUUFBUSxFQUFFLEVBQUU7WUFDbEYsT0FBTyxJQUFJLENBQUMsVUFBVSxDQUFDLE9BQU8sR0FBRyxHQUFHLENBQUMsQ0FBQztZQUN0QyxVQUFVLEdBQUcsVUFBVSxDQUFDLE1BQU0sQ0FBQztTQUNsQztRQUNELE9BQU8sT0FBTyxHQUFHLEdBQUcsQ0FBQztJQUN6QixDQUFDO0lBQ0QsWUFBWTtJQUNKLHVDQUFXLEdBQW5CO1FBQ0ksSUFBSSxJQUFJLEdBQUcsSUFBSSxDQUFDLElBQUksQ0FBQyxNQUFNLENBQUMscUJBQXFCLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxRQUFRLENBQUMsQ0FBQztRQUN0RSxJQUFJLENBQUMsY0FBYyxDQUFDLElBQUksQ0FBQyxRQUFRLEdBQUcsSUFBSSxDQUFDLFdBQVcsQ0FBQyxvQkFBb0IsQ0FBQyxJQUFJLENBQUMsQ0FBQztJQUNwRixDQUFDO0lBQ0QsWUFBWTtJQUNKLHlDQUFhLEdBQXJCLFVBQXNCLElBQWE7UUFDL0IsSUFBSSxDQUFDLGNBQWMsQ0FBQyxJQUFJLENBQUMsS0FBSyxHQUFHLElBQUksQ0FBQyw0QkFBNEIsQ0FBQyxJQUFJLENBQUMsQ0FBQztJQUM3RSxDQUFDO0lBQ0Q7Ozs7T0FJRztJQUNLLHdEQUE0QixHQUFwQyxVQUFxQyxNQUFlO1FBQ2hELFNBQVM7UUFDVCxJQUFJLE1BQU0sR0FBRyxJQUFJLENBQUMsSUFBSSxDQUFDLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUM7UUFDMUcsSUFBSSxNQUFNLEdBQUcsSUFBSSxDQUFDLElBQUksQ0FBQyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDO1FBRTFHLHlCQUF5QjtRQUN6QixJQUFJLEtBQUssR0FBRyxJQUFJLENBQUMsS0FBSyxDQUFDLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsTUFBTSxFQUFFLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsTUFBTSxDQUFDLENBQUM7UUFFbkUsV0FBVztRQUNYLElBQUksT0FBTyxHQUFHLEtBQUssR0FBRyxDQUFDLEdBQUcsR0FBRyxJQUFJLENBQUMsRUFBRSxDQUFDLENBQUM7UUFDdEMsT0FBTyxPQUFPLENBQUM7SUFDbkIsQ0FBQztJQUNEOzs7T0FHRztJQUNLLHlDQUFhLEdBQXJCLFVBQXNCLElBQWE7UUFDL0IsSUFBSSxLQUFLLEdBQUcsSUFBSSxDQUFDLG9CQUFvQixDQUFDLElBQUksQ0FBQyxDQUFBO1FBQzNDLElBQUksQ0FBQyxjQUFjLENBQUMsSUFBSSxDQUFDLE1BQU0sR0FBRyxLQUFLLENBQUMsQ0FBQyxDQUFDO1FBQzFDLElBQUksQ0FBQyxjQUFjLENBQUMsSUFBSSxDQUFDLE1BQU0sR0FBRyxLQUFLLENBQUMsQ0FBQyxDQUFDO1FBQzFDLElBQUksQ0FBQyxjQUFjLENBQUMsSUFBSSxDQUFDLE1BQU0sR0FBRyxLQUFLLENBQUMsQ0FBQyxDQUFDO0lBQzlDLENBQUM7SUFDRDs7OztPQUlHO0lBQ0ssZ0RBQW9CLEdBQTVCLFVBQTZCLElBQWE7UUFDdEMsSUFBSSxNQUFNLEdBQUcsRUFBRSxDQUFDLEVBQUUsQ0FBQyxJQUFJLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxFQUFFLElBQUksQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEVBQUUsSUFBSSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsRUFBRSxDQUFDO1FBQzFELElBQUksTUFBTSxHQUFHLEVBQUUsQ0FBQyxFQUFFLENBQUMsSUFBSSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsRUFBRSxJQUFJLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxFQUFFLElBQUksQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLEVBQUUsQ0FBQztRQUMxRCxJQUFJLE1BQU0sR0FBRyxFQUFFLENBQUMsRUFBRSxDQUFDLElBQUksQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEVBQUUsSUFBSSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsRUFBRSxJQUFJLENBQUMsQ0FBQyxDQUFDLEVBQUUsQ0FBQyxDQUFDLENBQUMsR0FBRyxFQUFFLENBQUM7UUFDM0QsT0FBTyxFQUFFLENBQUMsRUFBRSxDQUFDLE1BQU0sRUFBRSxNQUFNLEVBQUUsTUFBTSxDQUFDLENBQUM7SUFDekMsQ0FBQztJQUNEOzs7T0FHRztJQUNLLHFDQUFTLEdBQWpCOztRQUNJLElBQUksSUFBSSxHQUFHLEVBQUUsQ0FBQyxXQUFXLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxDQUFDO1FBQ3JDLElBQUksQ0FBQyxpQkFBaUIsRUFBRSxDQUFDO1FBQ3pCLElBQUksQ0FBQyxjQUFjLEdBQUcsSUFBSSxDQUFDLFlBQVksQ0FBQyxFQUFFLENBQUMsZUFBZSxDQUFDLENBQUM7UUFDNUQsTUFBQSxJQUFJLENBQUMsSUFBSSxDQUFDLFlBQVksQ0FBQyxFQUFFLENBQUMsWUFBWSxDQUFDLDBDQUFFLE9BQU8sR0FBRztRQUNuRCxNQUFBLElBQUksQ0FBQyxJQUFJLENBQUMsWUFBWSxDQUFDLEVBQUUsQ0FBQyxXQUFXLENBQUMsMENBQUUsT0FBTyxHQUFHO1FBQ2xELElBQUksQ0FBQyxJQUFJLENBQUMsWUFBWSxDQUFDLEVBQUUsQ0FBQyxlQUFlLENBQUMsQ0FBQyxPQUFPLEVBQUUsQ0FBQztRQUNyRCxJQUFJLFVBQVUsR0FBRyxJQUFJLENBQUMsYUFBYSxDQUFDLEVBQUUsQ0FBQyxTQUFTLENBQUMsQ0FBQztRQUNsRCxLQUFLLElBQUksQ0FBQyxHQUFHLENBQUMsRUFBRSxHQUFHLEdBQUcsVUFBVSxDQUFDLE1BQU0sRUFBRSxDQUFDLEdBQUcsR0FBRyxFQUFFLEVBQUUsQ0FBQyxFQUFFO1lBQ25ELElBQUksSUFBSSxHQUFHLFVBQVUsQ0FBQyxDQUFDLENBQUMsQ0FBQztZQUN6QixJQUFJLENBQUMsQ0FBQyxDQUFDLElBQUksWUFBWSxFQUFFLENBQUMsZUFBZSxDQUFDLElBQUksQ0FBQyxJQUFJLFlBQVksRUFBRSxDQUFDLFlBQVksQ0FBQyxJQUFJLENBQUMsSUFBSSxZQUFZLEVBQUUsQ0FBQyxXQUFXLENBQUMsQ0FBQyxFQUFFO2dCQUNsSCxJQUFJLENBQUMsT0FBTyxFQUFFLENBQUM7YUFDbEI7U0FDSjtRQUNELE9BQU8sSUFBSSxDQUFDO0lBQ2hCLENBQUM7O0lBM01EO1FBREMsUUFBUTsyREFDdUI7SUFLaEM7UUFIQyxRQUFRLENBQUM7WUFDTixPQUFPLEVBQUUsdUNBQXVDO1NBQ25ELENBQUM7c0RBQzRCO0lBVmIsaUJBQWlCO1FBRHJDLE9BQU87T0FDYSxpQkFBaUIsQ0FrTnJDO0lBQUQsd0JBQUM7Q0FsTkQsQUFrTkMsQ0FsTjhDLEVBQUUsQ0FBQyxTQUFTLEdBa04xRDtrQkFsTm9CLGlCQUFpQiIsImZpbGUiOiIiLCJzb3VyY2VSb290IjoiLyIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7IFJlbmRlclJlYWN0aXZlSGFuZGxlciB9IGZyb20gXCIuL1JlbmRlclJlYWN0aXZlSGFuZGxlclwiO1xyXG5cclxuLyoqXHJcbiAqIOebruWJjeivpea4suafk+S7o+eQhuWKn+iDveWtmOWcqOeahOmXrumimFxyXG4gKiAxLuiiq+S7o+eQhuiKgueCueeahOeItue6p+S4jeiDveWHuueOsHNjYWxlWOWSjHNjYWxlWeS4jeS4gOiHtOeahOaDheWGte+8jOiiq+S7o+eQhuiKgueCueacrOi6q+ayoeaciei/meS4qumZkOWItlxyXG4gKi9cclxuY29uc3QgeyBjY2NsYXNzLCBwcm9wZXJ0eSB9ID0gY2MuX2RlY29yYXRvcjtcclxuQGNjY2xhc3NcclxuZXhwb3J0IGRlZmF1bHQgY2xhc3MgUmVuZGVyQWx0ZXJuYXRpdmUgZXh0ZW5kcyBjYy5Db21wb25lbnQge1xyXG4gICAgLyoq5riy5p+T5bGC6IqC54K5ICovXHJcbiAgICBwdWJsaWMgcmVuZGVyTGF5ZXI6IGNjLk5vZGUgPSBudWxsO1xyXG4gICAgLyoq5riy5p+T55qEekluZGV4IOWKqOaAgeiwg+aVtHpJbmRleCznlKjkuo7mlrnkvr/kuLTov5HlkIjmibkgKi9cclxuICAgIEBwcm9wZXJ0eVxyXG4gICAgcHVibGljIHJlbmRlclpJbmRleDogbnVtYmVyID0gMDtcclxuICAgIC8qKuWQjOatpeeahOmXtOmalO+8iOW4p+S4uuWNleS9je+8iSAqL1xyXG4gICAgQHByb3BlcnR5KHtcclxuICAgICAgICB0b29sdGlwOiAn6K6+572u5ZCM5q2l55qE6Ze06ZqUKOenkuS4uuWNleS9jSnvvIww5bCx5piv5q+P5bin6YO95ZCM5q2l77yMMC4x5bCx5piv6ZqUMC4x56eS5ZCM5q2l5LiA5qyhJ1xyXG4gICAgfSlcclxuICAgIHB1YmxpYyBzeW5jSW52OiBudW1iZXIgPSAwLjAxO1xyXG4gICAgLyoq5riy5p+T55qEc0luZGV4ICovXHJcbiAgICBwdWJsaWMgc0luZGV4OiBudW1iZXIgPSAwO1xyXG4gICAgLyoq6Z2e5riy5p+T57uE5Lu2ICovXHJcbiAgICBwdWJsaWMgcHJveHlSZW5kZXI6IGNjLlJlbmRlckNvbXBvbmVudCA9IG51bGw7XHJcbiAgICAvKirmuLLmn5Pnu4Tku7YgKi9cclxuICAgIHByaXZhdGUgcmVuZGVyQ29tcG5lbnQ6IGNjLlJlbmRlckNvbXBvbmVudCA9IG51bGw7XHJcbiAgICAvKirkuIrmrKHmm7TmlrDnmoTmlbDmja4gKi9cclxuICAgIHB1YmxpYyBsYXN0V01hdDQ6IGNjLk1hdDQgPSBudWxsO1xyXG4gICAgLyoq5LiK5qyh5pu05paw55qE5pWw5o2uICovXHJcbiAgICBwdWJsaWMgbGFzdExNYXQ0OiBjYy5NYXQ0ID0gbnVsbDtcclxuICAgIC8qKuS4iuasoeabtOaWsOeahOaVsOaNriAqL1xyXG4gICAgcHVibGljIGxhc3RQb3M6IGNjLlZlYzMgPSBudWxsO1xyXG4gICAgLyoq6Led56a75LiL5qyh5Yi35paw57Sv6K6h5LqG5aSa5bCR6Ze06ZqUICovXHJcbiAgICBwdWJsaWMgYWNjdVRpbWU6IG51bWJlciA9IDA7XHJcbiAgICAvKirmnIDlkI7kuIDmrKHliLfmlrDml7bpl7QgKi9cclxuICAgIHB1YmxpYyBsYXN0RnJhbWVUaW1lOiBudW1iZXIgPSBudWxsO1xyXG4gICAgLyoq5piv5ZCm6L+b6KGM5Yi35pawICovXHJcbiAgICBwdWJsaWMgaXNBdHRhY2hGcmFtZTogYm9vbGVhbiA9IGZhbHNlO1xyXG5cclxuICAgIC8qKuiOt+WPluaAu+eahFpJbmRleCAqL1xyXG4gICAgZ2V0IHpJbmRleCgpIHtcclxuICAgICAgICBsZXQgekluZGV4ID0gdGhpcy5yZW5kZXJaSW5kZXggKyAodGhpcy5zSW5kZXggKiAwLjAxKTtcclxuICAgICAgICBsZXQgcGFyZW50Tm9kZSA9IHRoaXMubm9kZS5wYXJlbnQ7XHJcbiAgICAgICAgd2hpbGUgKHBhcmVudE5vZGUgIT0gdGhpcy5yZW5kZXJMYXllci5wYXJlbnQgJiYgcGFyZW50Tm9kZSAhPSBjYy5kaXJlY3Rvci5nZXRTY2VuZSgpKSB7XHJcbiAgICAgICAgICAgIGxldCByZW5kZXIgPSBwYXJlbnROb2RlLmdldENvbXBvbmVudChSZW5kZXJBbHRlcm5hdGl2ZSk7XHJcbiAgICAgICAgICAgIGlmIChyZW5kZXIpIHtcclxuICAgICAgICAgICAgICAgIHpJbmRleCArPSByZW5kZXIuekluZGV4ICsgMTtcclxuICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIHBhcmVudE5vZGUgPSBwYXJlbnROb2RlLnBhcmVudDtcclxuICAgICAgICB9XHJcbiAgICAgICAgcmV0dXJuIHpJbmRleDtcclxuICAgIH1cclxuXHJcbiAgICAvKipcclxuICAgICAqIOiuvue9rua4suafk+iKgueCueWxglxyXG4gICAgICogQHBhcmFtIGxheWVyIFxyXG4gICAgICovXHJcbiAgICBpbml0PFQgZXh0ZW5kcyBjYy5SZW5kZXJDb21wb25lbnQ+KGxheWVyPzogY2MuTm9kZSk6IFQge1xyXG4gICAgICAgIGlmIChsYXllcikge1xyXG4gICAgICAgICAgICB0aGlzLnJlbmRlckxheWVyID0gbGF5ZXI7XHJcbiAgICAgICAgfVxyXG4gICAgICAgIGlmICghdGhpcy5yZW5kZXJMYXllcikge1xyXG4gICAgICAgICAgICBjb25zb2xlLndhcm4oYOiKgueCuSR7dGhpcy5ub2RlLm5hbWV95rKh5pyJ6K6+572u5riy5p+T5bGCYClcclxuICAgICAgICAgICAgcmV0dXJuIG51bGw7XHJcbiAgICAgICAgfVxyXG4gICAgICAgIHJldHVybiB0aGlzLmluaXRSZW5kZXI8VD4oKTtcclxuICAgIH1cclxuICAgIC8qKlxyXG4gICAgICog5Yid5aeL5YyW5riy5p+T6IqC54K5XHJcbiAgICAgKi9cclxuICAgIHByaXZhdGUgaW5pdFJlbmRlcjxUIGV4dGVuZHMgY2MuUmVuZGVyQ29tcG9uZW50PigpOiBUIHtcclxuICAgICAgICBsZXQgbm9kZSA9IHRoaXMuZ2V0UmVuZGVyKCk7XHJcbiAgICAgICAgbm9kZS5zZXRQYXJlbnQodGhpcy5yZW5kZXJMYXllciA/IHRoaXMucmVuZGVyTGF5ZXIgOiBjYy5kaXJlY3Rvci5nZXRTY2VuZSgpLmdldENoaWxkQnlOYW1lKFwiQ2FudmFzXCIpKTtcclxuICAgICAgICB0aGlzLmlzQXR0YWNoRnJhbWUgPSB0cnVlO1xyXG4gICAgICAgIHJlcXVlc3RBbmltYXRpb25GcmFtZSh0aGlzLmZyYW1lVXBkYXRlLmJpbmQodGhpcykpO1xyXG4gICAgICAgIHJldHVybiB0aGlzLmRvUHJveHk8VD4oKTtcclxuICAgIH1cclxuICAgIC8qKueUn+aIkOS7o+eQhiAqL1xyXG4gICAgcHJpdmF0ZSBkb1Byb3h5PFQgZXh0ZW5kcyBjYy5SZW5kZXJDb21wb25lbnQ+KCk6IFQge1xyXG4gICAgICAgIHRoaXMucHJveHlSZW5kZXIgPSBuZXcgUHJveHkodGhpcy5yZW5kZXJDb21wbmVudCwgbmV3IFJlbmRlclJlYWN0aXZlSGFuZGxlcigpKSBhcyBUO1xyXG4gICAgICAgIHJldHVybiB0aGlzLnByb3h5UmVuZGVyIGFzIFQ7XHJcbiAgICB9XHJcblxyXG5cclxuICAgIHByb3RlY3RlZCBmcmFtZVVwZGF0ZSgpOiB2b2lkIHtcclxuICAgICAgICBsZXQgbm93ID0gY2Muc3lzLm5vdygpO1xyXG4gICAgICAgICF0aGlzLmxhc3RGcmFtZVRpbWUgJiYgKHRoaXMubGFzdEZyYW1lVGltZSA9IG5vdyk7XHJcbiAgICAgICAgbGV0IGR0ID0gbm93IC0gdGhpcy5sYXN0RnJhbWVUaW1lO1xyXG4gICAgICAgIGlmICh0aGlzLnByb3h5UmVuZGVyKSB7XHJcbiAgICAgICAgICAgIHRoaXMuYWNjdVRpbWUgKz0gZHQ7XHJcbiAgICAgICAgICAgIGlmICh0aGlzLmFjY3VUaW1lID49IHRoaXMuc3luY0ludikge1xyXG4gICAgICAgICAgICAgICAgdGhpcy5hY2N1VGltZSAtPSB0aGlzLnN5bmNJbnY7XHJcbiAgICAgICAgICAgICAgICB0aGlzLnVwZGF0ZVByb3AoKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH1cclxuICAgICAgICBpZiAodGhpcy5pc0F0dGFjaEZyYW1lKSB7XHJcbiAgICAgICAgICAgIHJlcXVlc3RBbmltYXRpb25GcmFtZSh0aGlzLmZyYW1lVXBkYXRlLmJpbmQodGhpcykpO1xyXG4gICAgICAgIH1cclxuICAgIH1cclxuXHJcbiAgICAvKirmm7TmlrDmnIDmlrDnirbmgIEgKi9cclxuICAgIHB1YmxpYyB1cGRhdGVQcm9wKCkge1xyXG4gICAgICAgIGxldCBub2RlID0gdGhpcy5yZW5kZXJDb21wbmVudC5ub2RlO1xyXG4gICAgICAgIGlmICghdGhpcy5ub2RlLmFjdGl2ZUluSGllcmFyY2h5KSB7XHJcbiAgICAgICAgICAgIG5vZGUub3BhY2l0eSA9IDA7XHJcbiAgICAgICAgICAgIHJldHVybjtcclxuICAgICAgICB9XHJcbiAgICAgICAgbm9kZS5hbmNob3JYID0gdGhpcy5ub2RlLmFuY2hvclg7XHJcbiAgICAgICAgbm9kZS5hbmNob3JZID0gdGhpcy5ub2RlLmFuY2hvclk7XHJcbiAgICAgICAgbm9kZS53aWR0aCA9IHRoaXMubm9kZS53aWR0aDtcclxuICAgICAgICBub2RlLmhlaWdodCA9IHRoaXMubm9kZS5oZWlnaHQ7XHJcbiAgICAgICAgbm9kZS5ncm91cCA9IHRoaXMubm9kZS5ncm91cDtcclxuICAgICAgICBub2RlLmNvbG9yID0gdGhpcy5ub2RlLmNvbG9yO1xyXG4gICAgICAgIG5vZGUub3BhY2l0eSA9IHRoaXMuZ2V0T3BhY2l0eSh0aGlzLm5vZGUpO1xyXG5cclxuICAgICAgICBsZXQgd01hdDQgPSBjYy5tYXQ0KCk7XHJcbiAgICAgICAgdGhpcy5ub2RlLmdldFdvcmxkTWF0cml4KHdNYXQ0KTtcclxuICAgICAgICAvKiBsZXQgbE1hdDQgPSBjYy5tYXQ0KCk7XHJcbiAgICAgICAgdGhpcy5ub2RlLmdldExvY2FsTWF0cml4KHdNYXQ0KTsgKi9cclxuICAgICAgICAvL+atpOWkhOacrOWPr+S7pei/h+a7pOiuuOWkmuS4jeW/heimgeeahOabtOaWsO+8jOS9huWwmuacquaOkuafpeWHuumXrumimFxyXG4gICAgICAgIGlmICh0cnVlIC8qIHx8ICF0aGlzLmxhc3RXTWF0ND8uZXF1YWxzKHdNYXQ0KSB8fCAhdGhpcy5sYXN0TE1hdDQ/LmVxdWFscyhsTWF0NCkgKi8pIHtcclxuICAgICAgICAgICAgdGhpcy5vbkFuZ2xlQ2hhbmdlKHdNYXQ0KTtcclxuICAgICAgICAgICAgdGhpcy5vblNjYWxlQ2hhbmdlKHdNYXQ0KTtcclxuICAgICAgICAgICAgdGhpcy5vblBvc0NoYW5nZSgpO1xyXG4gICAgICAgICAgICAvKiAgdGhpcy5sYXN0TE1hdDQgPSBsTWF0NDtcclxuICAgICAgICAgICAgIHRoaXMubGFzdFdNYXQ0ID0gd01hdDQ7ICovXHJcbiAgICAgICAgfVxyXG4gICAgICAgIG5vZGUuekluZGV4ID0gdGhpcy56SW5kZXg7XHJcbiAgICAgICAgbm9kZS56SW5kZXggPSB0aGlzLnpJbmRleDtcclxuICAgIH1cclxuXHJcbiAgICBwcm90ZWN0ZWQgb25EZXN0cm95KCk6IHZvaWQge1xyXG4gICAgICAgIHRoaXMucmVuZGVyQ29tcG5lbnQubm9kZS5kZXN0cm95KCk7XHJcbiAgICAgICAgdGhpcy5yZW5kZXJDb21wbmVudCA9IG51bGw7XHJcbiAgICAgICAgdGhpcy5wcm94eVJlbmRlciA9IG51bGw7XHJcbiAgICB9XHJcblxyXG4gICAgLyoqXHJcbiAgICAgKiDojrflj5boioLngrnpgI/mmI7luqZcclxuICAgICAqIEBwYXJhbSBub2RlIFxyXG4gICAgICovXHJcbiAgICBwcml2YXRlIGdldE9wYWNpdHkobm9kZTogY2MuTm9kZSkge1xyXG4gICAgICAgIGxldCBvcGFjaXR5ID0gKG5vZGUub3BhY2l0eSAvIDI1NSk7XHJcbiAgICAgICAgbGV0IHBhcmVudE5vZGUgPSBub2RlLnBhcmVudFxyXG4gICAgICAgIHdoaWxlIChwYXJlbnROb2RlICE9IHRoaXMucmVuZGVyTGF5ZXIucGFyZW50ICYmIHBhcmVudE5vZGUgIT0gY2MuZGlyZWN0b3IuZ2V0U2NlbmUoKSkge1xyXG4gICAgICAgICAgICBvcGFjaXR5ICo9IChwYXJlbnROb2RlLm9wYWNpdHkgLyAyNTUpO1xyXG4gICAgICAgICAgICBwYXJlbnROb2RlID0gcGFyZW50Tm9kZS5wYXJlbnQ7XHJcbiAgICAgICAgfVxyXG4gICAgICAgIHJldHVybiBvcGFjaXR5ICogMjU1O1xyXG4gICAgfVxyXG4gICAgLyoq5L2N572u5Y+Y5YyW5aSE55CGICovXHJcbiAgICBwcml2YXRlIG9uUG9zQ2hhbmdlKCkge1xyXG4gICAgICAgIGxldCB3cG9zID0gdGhpcy5ub2RlLnBhcmVudC5jb252ZXJ0VG9Xb3JsZFNwYWNlQVIodGhpcy5ub2RlLnBvc2l0aW9uKTtcclxuICAgICAgICB0aGlzLnJlbmRlckNvbXBuZW50Lm5vZGUucG9zaXRpb24gPSB0aGlzLnJlbmRlckxheWVyLmNvbnZlcnRUb05vZGVTcGFjZUFSKHdwb3MpO1xyXG4gICAgfVxyXG4gICAgLyoq5peL6L2s5Y+Y5YyW5aSE55CGICovXHJcbiAgICBwcml2YXRlIG9uQW5nbGVDaGFuZ2UobWF0NDogY2MuTWF0NCkge1xyXG4gICAgICAgIHRoaXMucmVuZGVyQ29tcG5lbnQubm9kZS5hbmdsZSA9IHRoaXMuZXh0cmFjdFJvdGF0aW9uQW5nbGVGcm9tTWF0NChtYXQ0KTtcclxuICAgIH1cclxuICAgIC8qKlxyXG4gICAgICog5LuOIGNjLk1hdDQg5Lit6I635Y+W5peL6L2s6KeS5bqm77yI5LiN5Y+X57yp5pS+5b2x5ZON77yJXHJcbiAgICAgKiBAcGFyYW0gbWF0cml4IOi+k+WFpeeahCBjYy5NYXQ0IOefqemYtVxyXG4gICAgICogQHJldHVybnMg5peL6L2s6KeS5bqm77yI5Lul5bqm5Li65Y2V5L2N77yJXHJcbiAgICAgKi9cclxuICAgIHByaXZhdGUgZXh0cmFjdFJvdGF0aW9uQW5nbGVGcm9tTWF0NChtYXRyaXg6IGNjLk1hdDQpOiBudW1iZXIge1xyXG4gICAgICAgIC8vIOaPkOWPluaXi+i9rOmDqOWIhlxyXG4gICAgICAgIGxldCBzY2FsZVggPSBNYXRoLnNxcnQobWF0cml4Lm1bMF0gKiBtYXRyaXgubVswXSArIG1hdHJpeC5tWzRdICogbWF0cml4Lm1bNF0gKyBtYXRyaXgubVs4XSAqIG1hdHJpeC5tWzhdKTtcclxuICAgICAgICBsZXQgc2NhbGVZID0gTWF0aC5zcXJ0KG1hdHJpeC5tWzFdICogbWF0cml4Lm1bMV0gKyBtYXRyaXgubVs1XSAqIG1hdHJpeC5tWzVdICsgbWF0cml4Lm1bOV0gKiBtYXRyaXgubVs5XSk7XHJcblxyXG4gICAgICAgIC8vIOiuoeeulyBaIOi9tOaXi+i9rOinkuW6pu+8iOe7lSBaIOi9tOeahOaXi+i9rOinkuW6pu+8iVxyXG4gICAgICAgIGxldCBhbmdsZSA9IE1hdGguYXRhbjIobWF0cml4Lm1bMV0gLyBzY2FsZVksIG1hdHJpeC5tWzBdIC8gc2NhbGVYKTtcclxuXHJcbiAgICAgICAgLy8g5bCG5byn5bqm6L2s5o2i5Li66KeS5bqmXHJcbiAgICAgICAgbGV0IGRlZ3JlZXMgPSBhbmdsZSAqICgxODAgLyBNYXRoLlBJKTtcclxuICAgICAgICByZXR1cm4gZGVncmVlcztcclxuICAgIH1cclxuICAgIC8qKlxyXG4gICAgICog57yp5pS+5Y+Y5YyW5aSE55CGXHJcbiAgICAgKiBAcGFyYW0gbWF0NCBcclxuICAgICAqL1xyXG4gICAgcHJpdmF0ZSBvblNjYWxlQ2hhbmdlKG1hdDQ6IGNjLk1hdDQpIHtcclxuICAgICAgICBsZXQgc2NhbGUgPSB0aGlzLmV4dHJhY3RTY2FsZUZyb21NYXQ0KG1hdDQpXHJcbiAgICAgICAgdGhpcy5yZW5kZXJDb21wbmVudC5ub2RlLnNjYWxlWCA9IHNjYWxlLng7XHJcbiAgICAgICAgdGhpcy5yZW5kZXJDb21wbmVudC5ub2RlLnNjYWxlWSA9IHNjYWxlLnk7XHJcbiAgICAgICAgdGhpcy5yZW5kZXJDb21wbmVudC5ub2RlLnNjYWxlWiA9IHNjYWxlLno7XHJcbiAgICB9XHJcbiAgICAvKipcclxuICAgICAqIOS7jm1hdDTkuK3ojrflj5bnvKnmlL7lgLxcclxuICAgICAqIEBwYXJhbSBtYXQ0IFxyXG4gICAgICogQHJldHVybnMgXHJcbiAgICAgKi9cclxuICAgIHByaXZhdGUgZXh0cmFjdFNjYWxlRnJvbU1hdDQobWF0NDogY2MuTWF0NCk6IGNjLlZlYzMge1xyXG4gICAgICAgIGxldCBzY2FsZVggPSBjYy52MyhtYXQ0Lm1bMF0sIG1hdDQubVsxXSwgbWF0NC5tWzJdKS5tYWcoKTtcclxuICAgICAgICBsZXQgc2NhbGVZID0gY2MudjMobWF0NC5tWzRdLCBtYXQ0Lm1bNV0sIG1hdDQubVs2XSkubWFnKCk7XHJcbiAgICAgICAgbGV0IHNjYWxlWiA9IGNjLnYzKG1hdDQubVs4XSwgbWF0NC5tWzldLCBtYXQ0Lm1bMTBdKS5tYWcoKTtcclxuICAgICAgICByZXR1cm4gY2MudjMoc2NhbGVYLCBzY2FsZVksIHNjYWxlWik7XHJcbiAgICB9XHJcbiAgICAvKipcclxuICAgICAqIOiOt+WPlua4suafk+e7hOS7tlxyXG4gICAgICogQHBhcmFtIG5vZGUgXHJcbiAgICAgKi9cclxuICAgIHByaXZhdGUgZ2V0UmVuZGVyKCkge1xyXG4gICAgICAgIGxldCBub2RlID0gY2MuaW5zdGFudGlhdGUodGhpcy5ub2RlKTtcclxuICAgICAgICBub2RlLnJlbW92ZUFsbENoaWxkcmVuKCk7XHJcbiAgICAgICAgdGhpcy5yZW5kZXJDb21wbmVudCA9IG5vZGUuZ2V0Q29tcG9uZW50KGNjLlJlbmRlckNvbXBvbmVudCk7XHJcbiAgICAgICAgdGhpcy5ub2RlLmdldENvbXBvbmVudChjYy5MYWJlbE91dGxpbmUpPy5kZXN0cm95KCk7XHJcbiAgICAgICAgdGhpcy5ub2RlLmdldENvbXBvbmVudChjYy5MYWJlbFNoYWRvdyk/LmRlc3Ryb3koKTtcclxuICAgICAgICB0aGlzLm5vZGUuZ2V0Q29tcG9uZW50KGNjLlJlbmRlckNvbXBvbmVudCkuZGVzdHJveSgpO1xyXG4gICAgICAgIGxldCBjb21wb25lbnRzID0gbm9kZS5nZXRDb21wb25lbnRzKGNjLkNvbXBvbmVudCk7XHJcbiAgICAgICAgZm9yIChsZXQgaSA9IDAsIGxlbiA9IGNvbXBvbmVudHMubGVuZ3RoOyBpIDwgbGVuOyArK2kpIHtcclxuICAgICAgICAgICAgbGV0IGNvbXAgPSBjb21wb25lbnRzW2ldO1xyXG4gICAgICAgICAgICBpZiAoISgoY29tcCBpbnN0YW5jZW9mIGNjLlJlbmRlckNvbXBvbmVudCkgfHwgKGNvbXAgaW5zdGFuY2VvZiBjYy5MYWJlbE91dGxpbmUpIHx8IChjb21wIGluc3RhbmNlb2YgY2MuTGFiZWxTaGFkb3cpKSkge1xyXG4gICAgICAgICAgICAgICAgY29tcC5kZXN0cm95KCk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9XHJcbiAgICAgICAgcmV0dXJuIG5vZGU7XHJcbiAgICB9XHJcblxyXG59XHJcbiJdfQ== +//------QC-SOURCE-SPLIT------ + + (function() { + var nodeEnv = typeof require !== 'undefined' && typeof process !== 'undefined'; + var __module = nodeEnv ? module : {exports:{}}; + var __filename = 'preview-scripts/assets/Script/RenderAlternative1.js'; + var __require = nodeEnv ? function (request) { + return cc.require(request); + } : function (request) { + return __quick_compile_project__.require(request, __filename); + }; + function __define (exports, require, module) { + if (!nodeEnv) {__quick_compile_project__.registerModule(__filename, module);}"use strict"; +cc._RF.push(module, '5be15eLnZlCKqPK4B3Y4J6x', 'RenderAlternative1'); +// Script/RenderAlternative1.ts + +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var RenderReactiveHandler_1 = require("./RenderReactiveHandler"); +/** + * 目前该渲染代理功能存在的问题 + * 1.被代理节点的父级不能出现scaleX和scaleY不一致的情况,被代理节点本身没有这个限制 + */ +var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property; +var RenderAlternative = /** @class */ (function (_super) { + __extends(RenderAlternative, _super); + function RenderAlternative() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /**渲染层节点 */ + _this.renderLayer = null; + /**渲染的zIndex 动态调整zIndex,用于方便临近合批 */ + _this.renderZIndex = 0; + /**同步的间隔(帧为单位) */ + _this.syncInv = 0.01; + /**渲染的sIndex */ + _this.sIndex = 0; + /**非渲染组件 */ + _this.proxyRender = null; + /**渲染组件 */ + _this.renderCompnent = null; + /**上次更新的数据 */ + _this.lastWMat4 = null; + /**上次更新的数据 */ + _this.lastLMat4 = null; + /**上次更新的数据 */ + _this.lastPos = null; + /**距离下次刷新累计了多少间隔 */ + _this.accuTime = 0; + /**最后一次刷新时间 */ + _this.lastFrameTime = null; + /**是否进行刷新 */ + _this.isAttachFrame = false; + return _this; + } + RenderAlternative_1 = RenderAlternative; + Object.defineProperty(RenderAlternative.prototype, "zIndex", { + /**获取总的ZIndex */ + get: function () { + var zIndex = this.renderZIndex + (this.sIndex * 0.01); + var parentNode = this.node.parent; + while (parentNode != this.renderLayer.parent && parentNode != cc.director.getScene()) { + var render = parentNode.getComponent(RenderAlternative_1); + if (render) { + zIndex += render.zIndex + 1; + break; + } + parentNode = parentNode.parent; + } + return zIndex; + }, + enumerable: false, + configurable: true + }); + /** + * 设置渲染节点层 + * @param layer + */ + RenderAlternative.prototype.init = function (layer) { + if (layer) { + this.renderLayer = layer; + } + if (!this.renderLayer) { + console.warn("\u8282\u70B9" + this.node.name + "\u6CA1\u6709\u8BBE\u7F6E\u6E32\u67D3\u5C42"); + return null; + } + return this.initRender(); + }; + /** + * 初始化渲染节点 + */ + RenderAlternative.prototype.initRender = function () { + var node = this.getRender(); + node.setParent(this.renderLayer ? this.renderLayer : cc.director.getScene().getChildByName("Canvas")); + this.isAttachFrame = true; + requestAnimationFrame(this.frameUpdate.bind(this)); + return this.doProxy(); + }; + /**生成代理 */ + RenderAlternative.prototype.doProxy = function () { + this.proxyRender = new Proxy(this.renderCompnent, new RenderReactiveHandler_1.RenderReactiveHandler()); + return this.proxyRender; + }; + RenderAlternative.prototype.frameUpdate = function () { + var now = cc.sys.now(); + !this.lastFrameTime && (this.lastFrameTime = now); + var dt = now - this.lastFrameTime; + if (this.proxyRender) { + this.accuTime += dt; + if (this.accuTime >= this.syncInv) { + this.accuTime -= this.syncInv; + this.updateProp(); + } + } + if (this.isAttachFrame) { + requestAnimationFrame(this.frameUpdate.bind(this)); + } + }; + /**更新最新状态 */ + RenderAlternative.prototype.updateProp = function () { + var node = this.renderCompnent.node; + if (!this.node.activeInHierarchy) { + node.opacity = 0; + return; + } + node.anchorX = this.node.anchorX; + node.anchorY = this.node.anchorY; + node.width = this.node.width; + node.height = this.node.height; + node.group = this.node.group; + node.color = this.node.color; + node.opacity = this.getOpacity(this.node); + var wMat4 = cc.mat4(); + this.node.getWorldMatrix(wMat4); + if (!this.lastWMat4 || !this.lastWMat4.equals(wMat4)) { + var localMatrix = this.getLocalMatrix(wMat4, node); + this.setLocalXYZScaleAngle(localMatrix, node, this.lastLMat4); + this.lastWMat4 = wMat4; + this.lastLMat4 = localMatrix; + } + node.zIndex = this.zIndex; + }; + RenderAlternative.prototype.getLocalMatrix = function (worldMatrix, node) { + var parentNode = null; + if (cc.isValid(node)) { + if (cc.isValid(node.parent)) { + parentNode = node.parent; + } + } + // 获取父节点的世界矩阵 + var parentWorldMatrix = cc.mat4(); + parentNode.getWorldMatrix(parentWorldMatrix); + // 获取父节点的逆矩阵 + var parentInverseMatrix = parentWorldMatrix.invert(); + // 将目标节点的世界矩阵转换为父节点的本地矩阵 + var localMatrix = parentInverseMatrix.multiply(worldMatrix); + return localMatrix; + }; + RenderAlternative.prototype.setLocalXYZScaleAngle = function (matrix, node, lastMatrix) { + if (lastMatrix && matrix.equals(lastMatrix)) { + return; + } + // 提取位置 + node.setPosition(matrix.m[12], matrix.m[13], matrix.m[14]); + var scaleX = null; + var scaleY = null; + var angle = null; + // 提取缩放X + if (!lastMatrix) { + scaleX = Math.sqrt(matrix.m[0] * matrix.m[0] + matrix.m[1] * matrix.m[1] + matrix.m[2] * matrix.m[2]); + } + else if (!this.equalsValue(matrix.m[0], lastMatrix.m[0]) + || !this.equalsValue(matrix.m[1], lastMatrix.m[1]) + || !this.equalsValue(matrix.m[2], lastMatrix.m[2])) { + scaleX = Math.sqrt(matrix.m[0] * matrix.m[0] + matrix.m[1] * matrix.m[1] + matrix.m[2] * matrix.m[2]); + } + // 提取缩放Y + if (!lastMatrix) { + scaleY = Math.sqrt(matrix.m[4] * matrix.m[4] + matrix.m[5] * matrix.m[5] + matrix.m[6] * matrix.m[6]); + } + else if (!this.equalsValue(matrix.m[4], lastMatrix.m[4]) + || !this.equalsValue(matrix.m[5], lastMatrix.m[5]) + || !this.equalsValue(matrix.m[6], lastMatrix.m[6])) { + scaleY = Math.sqrt(matrix.m[4] * matrix.m[4] + matrix.m[5] * matrix.m[5] + matrix.m[6] * matrix.m[6]); + } + //设置缩放X + if (scaleX !== null) { + node.scaleX = scaleX; + // 提取旋转 + angle = Math.atan2(matrix.m[1] / scaleX, matrix.m[0] / scaleX) * (180 / Math.PI); + } + if (scaleY !== null) { + node.scaleY = scaleY; + } + if (angle !== null) { + node.rotation = angle; + } + }; + RenderAlternative.prototype.equalsValue = function (a, b, epsilon) { + if (epsilon === void 0) { epsilon = 0.00001; } + return Math.abs(a - b) < epsilon; + }; + RenderAlternative.prototype.onDestroy = function () { + this.renderCompnent.node.destroy(); + this.renderCompnent = null; + this.proxyRender = null; + }; + /** + * 获取节点透明度 + * @param node + */ + RenderAlternative.prototype.getOpacity = function (node) { + var opacity = (node.opacity / 255); + var parentNode = node.parent; + while (parentNode != this.renderLayer.parent && parentNode != cc.director.getScene()) { + opacity *= (parentNode.opacity / 255); + parentNode = parentNode.parent; + } + return opacity * 255; + }; + /** + * 获取渲染组件 + * @param node + */ + RenderAlternative.prototype.getRender = function () { + var _a, _b; + var node = cc.instantiate(this.node); + node.removeAllChildren(); + this.renderCompnent = node.getComponent(cc.RenderComponent); + (_a = this.node.getComponent(cc.LabelOutline)) === null || _a === void 0 ? void 0 : _a.destroy(); + (_b = this.node.getComponent(cc.LabelShadow)) === null || _b === void 0 ? void 0 : _b.destroy(); + this.node.getComponent(cc.RenderComponent).destroy(); + var components = node.getComponents(cc.Component); + for (var i = 0, len = components.length; i < len; ++i) { + var comp = components[i]; + if (!((comp instanceof cc.RenderComponent) || (comp instanceof cc.LabelOutline) || (comp instanceof cc.LabelShadow))) { + comp.destroy(); + } + } + return node; + }; + var RenderAlternative_1; + __decorate([ + property + ], RenderAlternative.prototype, "renderZIndex", void 0); + __decorate([ + property({ + tooltip: '设置同步的间隔(秒为单位),0就是每帧都同步,0.1就是隔0.1秒同步一次' + }) + ], RenderAlternative.prototype, "syncInv", void 0); + RenderAlternative = RenderAlternative_1 = __decorate([ + ccclass + ], RenderAlternative); + return RenderAlternative; +}(cc.Component)); +exports.default = RenderAlternative; + +cc._RF.pop(); + } + if (nodeEnv) { + __define(__module.exports, __require, __module); + } + else { + __quick_compile_project__.registerModuleFunc(__filename, function () { + __define(__module.exports, __require, __module); + }); + } + })(); +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImFzc2V0c1xcU2NyaXB0XFxSZW5kZXJBbHRlcm5hdGl2ZTEudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0FBQUEsaUVBQWdFO0FBRWhFOzs7R0FHRztBQUNHLElBQUEsS0FBd0IsRUFBRSxDQUFDLFVBQVUsRUFBbkMsT0FBTyxhQUFBLEVBQUUsUUFBUSxjQUFrQixDQUFDO0FBRTVDO0lBQStDLHFDQUFZO0lBQTNEO1FBQUEscUVBNk5DO1FBNU5HLFdBQVc7UUFDSixpQkFBVyxHQUFZLElBQUksQ0FBQztRQUNuQyxtQ0FBbUM7UUFFNUIsa0JBQVksR0FBVyxDQUFDLENBQUM7UUFDaEMsaUJBQWlCO1FBSVYsYUFBTyxHQUFXLElBQUksQ0FBQztRQUM5QixlQUFlO1FBQ1IsWUFBTSxHQUFXLENBQUMsQ0FBQztRQUMxQixXQUFXO1FBQ0osaUJBQVcsR0FBdUIsSUFBSSxDQUFDO1FBQzlDLFVBQVU7UUFDRixvQkFBYyxHQUF1QixJQUFJLENBQUM7UUFDbEQsYUFBYTtRQUNOLGVBQVMsR0FBWSxJQUFJLENBQUM7UUFDakMsYUFBYTtRQUNOLGVBQVMsR0FBWSxJQUFJLENBQUM7UUFDakMsYUFBYTtRQUNOLGFBQU8sR0FBWSxJQUFJLENBQUM7UUFDL0IsbUJBQW1CO1FBQ1osY0FBUSxHQUFXLENBQUMsQ0FBQztRQUM1QixjQUFjO1FBQ1AsbUJBQWEsR0FBVyxJQUFJLENBQUM7UUFDcEMsWUFBWTtRQUNMLG1CQUFhLEdBQVksS0FBSyxDQUFDOztJQWlNMUMsQ0FBQzswQkE3Tm9CLGlCQUFpQjtJQStCbEMsc0JBQUkscUNBQU07UUFEVixnQkFBZ0I7YUFDaEI7WUFDSSxJQUFJLE1BQU0sR0FBRyxJQUFJLENBQUMsWUFBWSxHQUFHLENBQUMsSUFBSSxDQUFDLE1BQU0sR0FBRyxJQUFJLENBQUMsQ0FBQztZQUN0RCxJQUFJLFVBQVUsR0FBRyxJQUFJLENBQUMsSUFBSSxDQUFDLE1BQU0sQ0FBQztZQUNsQyxPQUFPLFVBQVUsSUFBSSxJQUFJLENBQUMsV0FBVyxDQUFDLE1BQU0sSUFBSSxVQUFVLElBQUksRUFBRSxDQUFDLFFBQVEsQ0FBQyxRQUFRLEVBQUUsRUFBRTtnQkFDbEYsSUFBSSxNQUFNLEdBQUcsVUFBVSxDQUFDLFlBQVksQ0FBQyxtQkFBaUIsQ0FBQyxDQUFDO2dCQUN4RCxJQUFJLE1BQU0sRUFBRTtvQkFDUixNQUFNLElBQUksTUFBTSxDQUFDLE1BQU0sR0FBRyxDQUFDLENBQUM7b0JBQzVCLE1BQU07aUJBQ1Q7Z0JBQ0QsVUFBVSxHQUFHLFVBQVUsQ0FBQyxNQUFNLENBQUM7YUFDbEM7WUFDRCxPQUFPLE1BQU0sQ0FBQztRQUNsQixDQUFDOzs7T0FBQTtJQUVEOzs7T0FHRztJQUNILGdDQUFJLEdBQUosVUFBbUMsS0FBZTtRQUM5QyxJQUFJLEtBQUssRUFBRTtZQUNQLElBQUksQ0FBQyxXQUFXLEdBQUcsS0FBSyxDQUFDO1NBQzVCO1FBQ0QsSUFBSSxDQUFDLElBQUksQ0FBQyxXQUFXLEVBQUU7WUFDbkIsT0FBTyxDQUFDLElBQUksQ0FBQyxpQkFBSyxJQUFJLENBQUMsSUFBSSxDQUFDLElBQUksK0NBQVMsQ0FBQyxDQUFBO1lBQzFDLE9BQU8sSUFBSSxDQUFDO1NBQ2Y7UUFDRCxPQUFPLElBQUksQ0FBQyxVQUFVLEVBQUssQ0FBQztJQUNoQyxDQUFDO0lBQ0Q7O09BRUc7SUFDSyxzQ0FBVSxHQUFsQjtRQUNJLElBQUksSUFBSSxHQUFHLElBQUksQ0FBQyxTQUFTLEVBQUUsQ0FBQztRQUM1QixJQUFJLENBQUMsU0FBUyxDQUFDLElBQUksQ0FBQyxXQUFXLENBQUMsQ0FBQyxDQUFDLElBQUksQ0FBQyxXQUFXLENBQUMsQ0FBQyxDQUFDLEVBQUUsQ0FBQyxRQUFRLENBQUMsUUFBUSxFQUFFLENBQUMsY0FBYyxDQUFDLFFBQVEsQ0FBQyxDQUFDLENBQUM7UUFDdEcsSUFBSSxDQUFDLGFBQWEsR0FBRyxJQUFJLENBQUM7UUFDMUIscUJBQXFCLENBQUMsSUFBSSxDQUFDLFdBQVcsQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLENBQUMsQ0FBQztRQUNuRCxPQUFPLElBQUksQ0FBQyxPQUFPLEVBQUssQ0FBQztJQUM3QixDQUFDO0lBQ0QsVUFBVTtJQUNGLG1DQUFPLEdBQWY7UUFDSSxJQUFJLENBQUMsV0FBVyxHQUFHLElBQUksS0FBSyxDQUFDLElBQUksQ0FBQyxjQUFjLEVBQUUsSUFBSSw2Q0FBcUIsRUFBRSxDQUFNLENBQUM7UUFDcEYsT0FBTyxJQUFJLENBQUMsV0FBZ0IsQ0FBQztJQUNqQyxDQUFDO0lBR1MsdUNBQVcsR0FBckI7UUFDSSxJQUFJLEdBQUcsR0FBRyxFQUFFLENBQUMsR0FBRyxDQUFDLEdBQUcsRUFBRSxDQUFDO1FBQ3ZCLENBQUMsSUFBSSxDQUFDLGFBQWEsSUFBSSxDQUFDLElBQUksQ0FBQyxhQUFhLEdBQUcsR0FBRyxDQUFDLENBQUM7UUFDbEQsSUFBSSxFQUFFLEdBQUcsR0FBRyxHQUFHLElBQUksQ0FBQyxhQUFhLENBQUM7UUFDbEMsSUFBSSxJQUFJLENBQUMsV0FBVyxFQUFFO1lBQ2xCLElBQUksQ0FBQyxRQUFRLElBQUksRUFBRSxDQUFDO1lBQ3BCLElBQUksSUFBSSxDQUFDLFFBQVEsSUFBSSxJQUFJLENBQUMsT0FBTyxFQUFFO2dCQUMvQixJQUFJLENBQUMsUUFBUSxJQUFJLElBQUksQ0FBQyxPQUFPLENBQUM7Z0JBQzlCLElBQUksQ0FBQyxVQUFVLEVBQUUsQ0FBQzthQUNyQjtTQUNKO1FBQ0QsSUFBSSxJQUFJLENBQUMsYUFBYSxFQUFFO1lBQ3BCLHFCQUFxQixDQUFDLElBQUksQ0FBQyxXQUFXLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxDQUFDLENBQUM7U0FDdEQ7SUFDTCxDQUFDO0lBRUQsWUFBWTtJQUNMLHNDQUFVLEdBQWpCO1FBQ0ksSUFBSSxJQUFJLEdBQUcsSUFBSSxDQUFDLGNBQWMsQ0FBQyxJQUFJLENBQUM7UUFDcEMsSUFBSSxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsaUJBQWlCLEVBQUU7WUFDOUIsSUFBSSxDQUFDLE9BQU8sR0FBRyxDQUFDLENBQUM7WUFDakIsT0FBTztTQUNWO1FBQ0QsSUFBSSxDQUFDLE9BQU8sR0FBRyxJQUFJLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQztRQUNqQyxJQUFJLENBQUMsT0FBTyxHQUFHLElBQUksQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDO1FBQ2pDLElBQUksQ0FBQyxLQUFLLEdBQUcsSUFBSSxDQUFDLElBQUksQ0FBQyxLQUFLLENBQUM7UUFDN0IsSUFBSSxDQUFDLE1BQU0sR0FBRyxJQUFJLENBQUMsSUFBSSxDQUFDLE1BQU0sQ0FBQztRQUMvQixJQUFJLENBQUMsS0FBSyxHQUFHLElBQUksQ0FBQyxJQUFJLENBQUMsS0FBSyxDQUFDO1FBQzdCLElBQUksQ0FBQyxLQUFLLEdBQUcsSUFBSSxDQUFDLElBQUksQ0FBQyxLQUFLLENBQUM7UUFDN0IsSUFBSSxDQUFDLE9BQU8sR0FBRyxJQUFJLENBQUMsVUFBVSxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsQ0FBQztRQUUxQyxJQUFJLEtBQUssR0FBRyxFQUFFLENBQUMsSUFBSSxFQUFFLENBQUM7UUFDdEIsSUFBSSxDQUFDLElBQUksQ0FBQyxjQUFjLENBQUMsS0FBSyxDQUFDLENBQUM7UUFDaEMsSUFBSSxDQUFDLElBQUksQ0FBQyxTQUFTLElBQUksQ0FBQyxJQUFJLENBQUMsU0FBUyxDQUFDLE1BQU0sQ0FBQyxLQUFLLENBQUMsRUFBRTtZQUNsRCxJQUFJLFdBQVcsR0FBRyxJQUFJLENBQUMsY0FBYyxDQUFDLEtBQUssRUFBRSxJQUFJLENBQUMsQ0FBQztZQUNuRCxJQUFJLENBQUMscUJBQXFCLENBQUMsV0FBVyxFQUFFLElBQUksRUFBRSxJQUFJLENBQUMsU0FBUyxDQUFDLENBQUM7WUFDOUQsSUFBSSxDQUFDLFNBQVMsR0FBRyxLQUFLLENBQUM7WUFDdkIsSUFBSSxDQUFDLFNBQVMsR0FBRyxXQUFXLENBQUM7U0FDaEM7UUFDRCxJQUFJLENBQUMsTUFBTSxHQUFHLElBQUksQ0FBQyxNQUFNLENBQUM7SUFDOUIsQ0FBQztJQUVPLDBDQUFjLEdBQXRCLFVBQXVCLFdBQW9CLEVBQUUsSUFBYTtRQUN0RCxJQUFJLFVBQVUsR0FBRyxJQUFJLENBQUM7UUFDdEIsSUFBSSxFQUFFLENBQUMsT0FBTyxDQUFDLElBQUksQ0FBQyxFQUFFO1lBQ2xCLElBQUksRUFBRSxDQUFDLE9BQU8sQ0FBQyxJQUFJLENBQUMsTUFBTSxDQUFDLEVBQUU7Z0JBQ3pCLFVBQVUsR0FBRyxJQUFJLENBQUMsTUFBTSxDQUFBO2FBQzNCO1NBQ0o7UUFDRCxhQUFhO1FBQ2IsSUFBSSxpQkFBaUIsR0FBRyxFQUFFLENBQUMsSUFBSSxFQUFFLENBQUM7UUFDbEMsVUFBVSxDQUFDLGNBQWMsQ0FBQyxpQkFBaUIsQ0FBQyxDQUFDO1FBQzdDLFlBQVk7UUFDWixJQUFJLG1CQUFtQixHQUFHLGlCQUFpQixDQUFDLE1BQU0sRUFBRSxDQUFDO1FBQ3JELHdCQUF3QjtRQUN4QixJQUFJLFdBQVcsR0FBRyxtQkFBbUIsQ0FBQyxRQUFRLENBQUMsV0FBVyxDQUFDLENBQUM7UUFDNUQsT0FBTyxXQUFXLENBQUM7SUFFdkIsQ0FBQztJQUVPLGlEQUFxQixHQUE3QixVQUE4QixNQUFlLEVBQUUsSUFBYSxFQUFFLFVBQW9CO1FBQzlFLElBQUksVUFBVSxJQUFJLE1BQU0sQ0FBQyxNQUFNLENBQUMsVUFBVSxDQUFDLEVBQUU7WUFDekMsT0FBTztTQUNWO1FBRUQsT0FBTztRQUNQLElBQUksQ0FBQyxXQUFXLENBQUMsTUFBTSxDQUFDLENBQUMsQ0FBQyxFQUFFLENBQUMsRUFBRSxNQUFNLENBQUMsQ0FBQyxDQUFDLEVBQUUsQ0FBQyxFQUFFLE1BQU0sQ0FBQyxDQUFDLENBQUMsRUFBRSxDQUFDLENBQUMsQ0FBQztRQUUzRCxJQUFJLE1BQU0sR0FBRyxJQUFJLENBQUM7UUFDbEIsSUFBSSxNQUFNLEdBQUcsSUFBSSxDQUFDO1FBQ2xCLElBQUksS0FBSyxHQUFHLElBQUksQ0FBQztRQUNqQixRQUFRO1FBQ1IsSUFBSSxDQUFDLFVBQVUsRUFBRTtZQUNiLE1BQU0sR0FBRyxJQUFJLENBQUMsSUFBSSxDQUFDLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUM7U0FDekc7YUFBTSxJQUFJLENBQUMsSUFBSSxDQUFDLFdBQVcsQ0FBQyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxFQUFFLFVBQVUsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUM7ZUFDbkQsQ0FBQyxJQUFJLENBQUMsV0FBVyxDQUFDLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEVBQUUsVUFBVSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQztlQUMvQyxDQUFDLElBQUksQ0FBQyxXQUFXLENBQUMsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsRUFBRSxVQUFVLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEVBQUU7WUFDcEQsTUFBTSxHQUFHLElBQUksQ0FBQyxJQUFJLENBQUMsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQztTQUN6RztRQUNELFFBQVE7UUFDUixJQUFJLENBQUMsVUFBVSxFQUFFO1lBQ2IsTUFBTSxHQUFHLElBQUksQ0FBQyxJQUFJLENBQUMsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQztTQUN6RzthQUFNLElBQUksQ0FBQyxJQUFJLENBQUMsV0FBVyxDQUFDLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEVBQUUsVUFBVSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQztlQUNuRCxDQUFDLElBQUksQ0FBQyxXQUFXLENBQUMsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsRUFBRSxVQUFVLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDO2VBQy9DLENBQUMsSUFBSSxDQUFDLFdBQVcsQ0FBQyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxFQUFFLFVBQVUsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsRUFBRTtZQUNwRCxNQUFNLEdBQUcsSUFBSSxDQUFDLElBQUksQ0FBQyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDO1NBQ3pHO1FBQ0QsT0FBTztRQUNQLElBQUksTUFBTSxLQUFLLElBQUksRUFBRTtZQUNqQixJQUFJLENBQUMsTUFBTSxHQUFHLE1BQU0sQ0FBQztZQUNyQixPQUFPO1lBQ1AsS0FBSyxHQUFHLElBQUksQ0FBQyxLQUFLLENBQUMsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxNQUFNLEVBQUUsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxNQUFNLENBQUMsR0FBRyxDQUFDLEdBQUcsR0FBRyxJQUFJLENBQUMsRUFBRSxDQUFDLENBQUM7U0FDcEY7UUFDRCxJQUFJLE1BQU0sS0FBSyxJQUFJLEVBQUU7WUFDakIsSUFBSSxDQUFDLE1BQU0sR0FBRyxNQUFNLENBQUM7U0FDeEI7UUFDRCxJQUFJLEtBQUssS0FBSyxJQUFJLEVBQUU7WUFDaEIsSUFBSSxDQUFDLFFBQVEsR0FBRyxLQUFLLENBQUM7U0FDekI7SUFDTCxDQUFDO0lBRU8sdUNBQVcsR0FBbkIsVUFBb0IsQ0FBUyxFQUFFLENBQVMsRUFBRSxPQUF5QjtRQUF6Qix3QkFBQSxFQUFBLGlCQUF5QjtRQUMvRCxPQUFPLElBQUksQ0FBQyxHQUFHLENBQUMsQ0FBQyxHQUFHLENBQUMsQ0FBQyxHQUFHLE9BQU8sQ0FBQztJQUNyQyxDQUFDO0lBRVMscUNBQVMsR0FBbkI7UUFDSSxJQUFJLENBQUMsY0FBYyxDQUFDLElBQUksQ0FBQyxPQUFPLEVBQUUsQ0FBQztRQUNuQyxJQUFJLENBQUMsY0FBYyxHQUFHLElBQUksQ0FBQztRQUMzQixJQUFJLENBQUMsV0FBVyxHQUFHLElBQUksQ0FBQztJQUM1QixDQUFDO0lBRUQ7OztPQUdHO0lBQ0ssc0NBQVUsR0FBbEIsVUFBbUIsSUFBYTtRQUM1QixJQUFJLE9BQU8sR0FBRyxDQUFDLElBQUksQ0FBQyxPQUFPLEdBQUcsR0FBRyxDQUFDLENBQUM7UUFDbkMsSUFBSSxVQUFVLEdBQUcsSUFBSSxDQUFDLE1BQU0sQ0FBQTtRQUM1QixPQUFPLFVBQVUsSUFBSSxJQUFJLENBQUMsV0FBVyxDQUFDLE1BQU0sSUFBSSxVQUFVLElBQUksRUFBRSxDQUFDLFFBQVEsQ0FBQyxRQUFRLEVBQUUsRUFBRTtZQUNsRixPQUFPLElBQUksQ0FBQyxVQUFVLENBQUMsT0FBTyxHQUFHLEdBQUcsQ0FBQyxDQUFDO1lBQ3RDLFVBQVUsR0FBRyxVQUFVLENBQUMsTUFBTSxDQUFDO1NBQ2xDO1FBQ0QsT0FBTyxPQUFPLEdBQUcsR0FBRyxDQUFDO0lBQ3pCLENBQUM7SUFDRDs7O09BR0c7SUFDSyxxQ0FBUyxHQUFqQjs7UUFDSSxJQUFJLElBQUksR0FBRyxFQUFFLENBQUMsV0FBVyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsQ0FBQztRQUNyQyxJQUFJLENBQUMsaUJBQWlCLEVBQUUsQ0FBQztRQUN6QixJQUFJLENBQUMsY0FBYyxHQUFHLElBQUksQ0FBQyxZQUFZLENBQUMsRUFBRSxDQUFDLGVBQWUsQ0FBQyxDQUFDO1FBQzVELE1BQUEsSUFBSSxDQUFDLElBQUksQ0FBQyxZQUFZLENBQUMsRUFBRSxDQUFDLFlBQVksQ0FBQywwQ0FBRSxPQUFPLEdBQUc7UUFDbkQsTUFBQSxJQUFJLENBQUMsSUFBSSxDQUFDLFlBQVksQ0FBQyxFQUFFLENBQUMsV0FBVyxDQUFDLDBDQUFFLE9BQU8sR0FBRztRQUNsRCxJQUFJLENBQUMsSUFBSSxDQUFDLFlBQVksQ0FBQyxFQUFFLENBQUMsZUFBZSxDQUFDLENBQUMsT0FBTyxFQUFFLENBQUM7UUFDckQsSUFBSSxVQUFVLEdBQUcsSUFBSSxDQUFDLGFBQWEsQ0FBQyxFQUFFLENBQUMsU0FBUyxDQUFDLENBQUM7UUFDbEQsS0FBSyxJQUFJLENBQUMsR0FBRyxDQUFDLEVBQUUsR0FBRyxHQUFHLFVBQVUsQ0FBQyxNQUFNLEVBQUUsQ0FBQyxHQUFHLEdBQUcsRUFBRSxFQUFFLENBQUMsRUFBRTtZQUNuRCxJQUFJLElBQUksR0FBRyxVQUFVLENBQUMsQ0FBQyxDQUFDLENBQUM7WUFDekIsSUFBSSxDQUFDLENBQUMsQ0FBQyxJQUFJLFlBQVksRUFBRSxDQUFDLGVBQWUsQ0FBQyxJQUFJLENBQUMsSUFBSSxZQUFZLEVBQUUsQ0FBQyxZQUFZLENBQUMsSUFBSSxDQUFDLElBQUksWUFBWSxFQUFFLENBQUMsV0FBVyxDQUFDLENBQUMsRUFBRTtnQkFDbEgsSUFBSSxDQUFDLE9BQU8sRUFBRSxDQUFDO2FBQ2xCO1NBQ0o7UUFDRCxPQUFPLElBQUksQ0FBQztJQUNoQixDQUFDOztJQXRORDtRQURDLFFBQVE7MkRBQ3VCO0lBS2hDO1FBSEMsUUFBUSxDQUFDO1lBQ04sT0FBTyxFQUFFLHVDQUF1QztTQUNuRCxDQUFDO3NEQUM0QjtJQVZiLGlCQUFpQjtRQURyQyxPQUFPO09BQ2EsaUJBQWlCLENBNk5yQztJQUFELHdCQUFDO0NBN05ELEFBNk5DLENBN044QyxFQUFFLENBQUMsU0FBUyxHQTZOMUQ7a0JBN05vQixpQkFBaUIiLCJmaWxlIjoiIiwic291cmNlUm9vdCI6Ii8iLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBSZW5kZXJSZWFjdGl2ZUhhbmRsZXIgfSBmcm9tIFwiLi9SZW5kZXJSZWFjdGl2ZUhhbmRsZXJcIjtcclxuXHJcbi8qKlxyXG4gKiDnm67liY3or6XmuLLmn5Pku6PnkIblip/og73lrZjlnKjnmoTpl67pophcclxuICogMS7ooqvku6PnkIboioLngrnnmoTniLbnuqfkuI3og73lh7rnjrBzY2FsZVjlkoxzY2FsZVnkuI3kuIDoh7TnmoTmg4XlhrXvvIzooqvku6PnkIboioLngrnmnKzouqvmsqHmnInov5nkuKrpmZDliLZcclxuICovXHJcbmNvbnN0IHsgY2NjbGFzcywgcHJvcGVydHkgfSA9IGNjLl9kZWNvcmF0b3I7XHJcbkBjY2NsYXNzXHJcbmV4cG9ydCBkZWZhdWx0IGNsYXNzIFJlbmRlckFsdGVybmF0aXZlIGV4dGVuZHMgY2MuQ29tcG9uZW50IHtcclxuICAgIC8qKua4suafk+WxguiKgueCuSAqL1xyXG4gICAgcHVibGljIHJlbmRlckxheWVyOiBjYy5Ob2RlID0gbnVsbDtcclxuICAgIC8qKua4suafk+eahHpJbmRleCDliqjmgIHosIPmlbR6SW5kZXgs55So5LqO5pa55L6/5Li06L+R5ZCI5om5ICovXHJcbiAgICBAcHJvcGVydHlcclxuICAgIHB1YmxpYyByZW5kZXJaSW5kZXg6IG51bWJlciA9IDA7XHJcbiAgICAvKirlkIzmraXnmoTpl7TpmpTvvIjluKfkuLrljZXkvY3vvIkgKi9cclxuICAgIEBwcm9wZXJ0eSh7XHJcbiAgICAgICAgdG9vbHRpcDogJ+iuvue9ruWQjOatpeeahOmXtOmalCjnp5LkuLrljZXkvY0p77yMMOWwseaYr+avj+W4p+mDveWQjOatpe+8jDAuMeWwseaYr+malDAuMeenkuWQjOatpeS4gOasoSdcclxuICAgIH0pXHJcbiAgICBwdWJsaWMgc3luY0ludjogbnVtYmVyID0gMC4wMTtcclxuICAgIC8qKua4suafk+eahHNJbmRleCAqL1xyXG4gICAgcHVibGljIHNJbmRleDogbnVtYmVyID0gMDtcclxuICAgIC8qKumdnua4suafk+e7hOS7tiAqL1xyXG4gICAgcHVibGljIHByb3h5UmVuZGVyOiBjYy5SZW5kZXJDb21wb25lbnQgPSBudWxsO1xyXG4gICAgLyoq5riy5p+T57uE5Lu2ICovXHJcbiAgICBwcml2YXRlIHJlbmRlckNvbXBuZW50OiBjYy5SZW5kZXJDb21wb25lbnQgPSBudWxsO1xyXG4gICAgLyoq5LiK5qyh5pu05paw55qE5pWw5o2uICovXHJcbiAgICBwdWJsaWMgbGFzdFdNYXQ0OiBjYy5NYXQ0ID0gbnVsbDtcclxuICAgIC8qKuS4iuasoeabtOaWsOeahOaVsOaNriAqL1xyXG4gICAgcHVibGljIGxhc3RMTWF0NDogY2MuTWF0NCA9IG51bGw7XHJcbiAgICAvKirkuIrmrKHmm7TmlrDnmoTmlbDmja4gKi9cclxuICAgIHB1YmxpYyBsYXN0UG9zOiBjYy5WZWMzID0gbnVsbDtcclxuICAgIC8qKui3neemu+S4i+asoeWIt+aWsOe0r+iuoeS6huWkmuWwkemXtOmalCAqL1xyXG4gICAgcHVibGljIGFjY3VUaW1lOiBudW1iZXIgPSAwO1xyXG4gICAgLyoq5pyA5ZCO5LiA5qyh5Yi35paw5pe26Ze0ICovXHJcbiAgICBwdWJsaWMgbGFzdEZyYW1lVGltZTogbnVtYmVyID0gbnVsbDtcclxuICAgIC8qKuaYr+WQpui/m+ihjOWIt+aWsCAqL1xyXG4gICAgcHVibGljIGlzQXR0YWNoRnJhbWU6IGJvb2xlYW4gPSBmYWxzZTtcclxuXHJcbiAgICAvKirojrflj5bmgLvnmoRaSW5kZXggKi9cclxuICAgIGdldCB6SW5kZXgoKSB7XHJcbiAgICAgICAgbGV0IHpJbmRleCA9IHRoaXMucmVuZGVyWkluZGV4ICsgKHRoaXMuc0luZGV4ICogMC4wMSk7XHJcbiAgICAgICAgbGV0IHBhcmVudE5vZGUgPSB0aGlzLm5vZGUucGFyZW50O1xyXG4gICAgICAgIHdoaWxlIChwYXJlbnROb2RlICE9IHRoaXMucmVuZGVyTGF5ZXIucGFyZW50ICYmIHBhcmVudE5vZGUgIT0gY2MuZGlyZWN0b3IuZ2V0U2NlbmUoKSkge1xyXG4gICAgICAgICAgICBsZXQgcmVuZGVyID0gcGFyZW50Tm9kZS5nZXRDb21wb25lbnQoUmVuZGVyQWx0ZXJuYXRpdmUpO1xyXG4gICAgICAgICAgICBpZiAocmVuZGVyKSB7XHJcbiAgICAgICAgICAgICAgICB6SW5kZXggKz0gcmVuZGVyLnpJbmRleCArIDE7XHJcbiAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBwYXJlbnROb2RlID0gcGFyZW50Tm9kZS5wYXJlbnQ7XHJcbiAgICAgICAgfVxyXG4gICAgICAgIHJldHVybiB6SW5kZXg7XHJcbiAgICB9XHJcblxyXG4gICAgLyoqXHJcbiAgICAgKiDorr7nva7muLLmn5PoioLngrnlsYJcclxuICAgICAqIEBwYXJhbSBsYXllciBcclxuICAgICAqL1xyXG4gICAgaW5pdDxUIGV4dGVuZHMgY2MuUmVuZGVyQ29tcG9uZW50PihsYXllcj86IGNjLk5vZGUpOiBUIHtcclxuICAgICAgICBpZiAobGF5ZXIpIHtcclxuICAgICAgICAgICAgdGhpcy5yZW5kZXJMYXllciA9IGxheWVyO1xyXG4gICAgICAgIH1cclxuICAgICAgICBpZiAoIXRoaXMucmVuZGVyTGF5ZXIpIHtcclxuICAgICAgICAgICAgY29uc29sZS53YXJuKGDoioLngrkke3RoaXMubm9kZS5uYW1lfeayoeacieiuvue9rua4suafk+WxgmApXHJcbiAgICAgICAgICAgIHJldHVybiBudWxsO1xyXG4gICAgICAgIH1cclxuICAgICAgICByZXR1cm4gdGhpcy5pbml0UmVuZGVyPFQ+KCk7XHJcbiAgICB9XHJcbiAgICAvKipcclxuICAgICAqIOWIneWni+WMlua4suafk+iKgueCuVxyXG4gICAgICovXHJcbiAgICBwcml2YXRlIGluaXRSZW5kZXI8VCBleHRlbmRzIGNjLlJlbmRlckNvbXBvbmVudD4oKTogVCB7XHJcbiAgICAgICAgbGV0IG5vZGUgPSB0aGlzLmdldFJlbmRlcigpO1xyXG4gICAgICAgIG5vZGUuc2V0UGFyZW50KHRoaXMucmVuZGVyTGF5ZXIgPyB0aGlzLnJlbmRlckxheWVyIDogY2MuZGlyZWN0b3IuZ2V0U2NlbmUoKS5nZXRDaGlsZEJ5TmFtZShcIkNhbnZhc1wiKSk7XHJcbiAgICAgICAgdGhpcy5pc0F0dGFjaEZyYW1lID0gdHJ1ZTtcclxuICAgICAgICByZXF1ZXN0QW5pbWF0aW9uRnJhbWUodGhpcy5mcmFtZVVwZGF0ZS5iaW5kKHRoaXMpKTtcclxuICAgICAgICByZXR1cm4gdGhpcy5kb1Byb3h5PFQ+KCk7XHJcbiAgICB9XHJcbiAgICAvKirnlJ/miJDku6PnkIYgKi9cclxuICAgIHByaXZhdGUgZG9Qcm94eTxUIGV4dGVuZHMgY2MuUmVuZGVyQ29tcG9uZW50PigpOiBUIHtcclxuICAgICAgICB0aGlzLnByb3h5UmVuZGVyID0gbmV3IFByb3h5KHRoaXMucmVuZGVyQ29tcG5lbnQsIG5ldyBSZW5kZXJSZWFjdGl2ZUhhbmRsZXIoKSkgYXMgVDtcclxuICAgICAgICByZXR1cm4gdGhpcy5wcm94eVJlbmRlciBhcyBUO1xyXG4gICAgfVxyXG5cclxuXHJcbiAgICBwcm90ZWN0ZWQgZnJhbWVVcGRhdGUoKTogdm9pZCB7XHJcbiAgICAgICAgbGV0IG5vdyA9IGNjLnN5cy5ub3coKTtcclxuICAgICAgICAhdGhpcy5sYXN0RnJhbWVUaW1lICYmICh0aGlzLmxhc3RGcmFtZVRpbWUgPSBub3cpO1xyXG4gICAgICAgIGxldCBkdCA9IG5vdyAtIHRoaXMubGFzdEZyYW1lVGltZTtcclxuICAgICAgICBpZiAodGhpcy5wcm94eVJlbmRlcikge1xyXG4gICAgICAgICAgICB0aGlzLmFjY3VUaW1lICs9IGR0O1xyXG4gICAgICAgICAgICBpZiAodGhpcy5hY2N1VGltZSA+PSB0aGlzLnN5bmNJbnYpIHtcclxuICAgICAgICAgICAgICAgIHRoaXMuYWNjdVRpbWUgLT0gdGhpcy5zeW5jSW52O1xyXG4gICAgICAgICAgICAgICAgdGhpcy51cGRhdGVQcm9wKCk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9XHJcbiAgICAgICAgaWYgKHRoaXMuaXNBdHRhY2hGcmFtZSkge1xyXG4gICAgICAgICAgICByZXF1ZXN0QW5pbWF0aW9uRnJhbWUodGhpcy5mcmFtZVVwZGF0ZS5iaW5kKHRoaXMpKTtcclxuICAgICAgICB9XHJcbiAgICB9XHJcblxyXG4gICAgLyoq5pu05paw5pyA5paw54q25oCBICovXHJcbiAgICBwdWJsaWMgdXBkYXRlUHJvcCgpIHtcclxuICAgICAgICBsZXQgbm9kZSA9IHRoaXMucmVuZGVyQ29tcG5lbnQubm9kZTtcclxuICAgICAgICBpZiAoIXRoaXMubm9kZS5hY3RpdmVJbkhpZXJhcmNoeSkge1xyXG4gICAgICAgICAgICBub2RlLm9wYWNpdHkgPSAwO1xyXG4gICAgICAgICAgICByZXR1cm47XHJcbiAgICAgICAgfVxyXG4gICAgICAgIG5vZGUuYW5jaG9yWCA9IHRoaXMubm9kZS5hbmNob3JYO1xyXG4gICAgICAgIG5vZGUuYW5jaG9yWSA9IHRoaXMubm9kZS5hbmNob3JZO1xyXG4gICAgICAgIG5vZGUud2lkdGggPSB0aGlzLm5vZGUud2lkdGg7XHJcbiAgICAgICAgbm9kZS5oZWlnaHQgPSB0aGlzLm5vZGUuaGVpZ2h0O1xyXG4gICAgICAgIG5vZGUuZ3JvdXAgPSB0aGlzLm5vZGUuZ3JvdXA7XHJcbiAgICAgICAgbm9kZS5jb2xvciA9IHRoaXMubm9kZS5jb2xvcjtcclxuICAgICAgICBub2RlLm9wYWNpdHkgPSB0aGlzLmdldE9wYWNpdHkodGhpcy5ub2RlKTtcclxuXHJcbiAgICAgICAgbGV0IHdNYXQ0ID0gY2MubWF0NCgpO1xyXG4gICAgICAgIHRoaXMubm9kZS5nZXRXb3JsZE1hdHJpeCh3TWF0NCk7XHJcbiAgICAgICAgaWYgKCF0aGlzLmxhc3RXTWF0NCB8fCAhdGhpcy5sYXN0V01hdDQuZXF1YWxzKHdNYXQ0KSkge1xyXG4gICAgICAgICAgICBsZXQgbG9jYWxNYXRyaXggPSB0aGlzLmdldExvY2FsTWF0cml4KHdNYXQ0LCBub2RlKTtcclxuICAgICAgICAgICAgdGhpcy5zZXRMb2NhbFhZWlNjYWxlQW5nbGUobG9jYWxNYXRyaXgsIG5vZGUsIHRoaXMubGFzdExNYXQ0KTtcclxuICAgICAgICAgICAgdGhpcy5sYXN0V01hdDQgPSB3TWF0NDtcclxuICAgICAgICAgICAgdGhpcy5sYXN0TE1hdDQgPSBsb2NhbE1hdHJpeDtcclxuICAgICAgICB9XHJcbiAgICAgICAgbm9kZS56SW5kZXggPSB0aGlzLnpJbmRleDtcclxuICAgIH1cclxuXHJcbiAgICBwcml2YXRlIGdldExvY2FsTWF0cml4KHdvcmxkTWF0cml4OiBjYy5NYXQ0LCBub2RlOiBjYy5Ob2RlKSB7XHJcbiAgICAgICAgbGV0IHBhcmVudE5vZGUgPSBudWxsO1xyXG4gICAgICAgIGlmIChjYy5pc1ZhbGlkKG5vZGUpKSB7XHJcbiAgICAgICAgICAgIGlmIChjYy5pc1ZhbGlkKG5vZGUucGFyZW50KSkge1xyXG4gICAgICAgICAgICAgICAgcGFyZW50Tm9kZSA9IG5vZGUucGFyZW50XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9XHJcbiAgICAgICAgLy8g6I635Y+W54i26IqC54K555qE5LiW55WM55+p6Zi1XHJcbiAgICAgICAgbGV0IHBhcmVudFdvcmxkTWF0cml4ID0gY2MubWF0NCgpO1xyXG4gICAgICAgIHBhcmVudE5vZGUuZ2V0V29ybGRNYXRyaXgocGFyZW50V29ybGRNYXRyaXgpO1xyXG4gICAgICAgIC8vIOiOt+WPlueItuiKgueCueeahOmAhuefqemYtVxyXG4gICAgICAgIGxldCBwYXJlbnRJbnZlcnNlTWF0cml4ID0gcGFyZW50V29ybGRNYXRyaXguaW52ZXJ0KCk7XHJcbiAgICAgICAgLy8g5bCG55uu5qCH6IqC54K555qE5LiW55WM55+p6Zi16L2s5o2i5Li654i26IqC54K555qE5pys5Zyw55+p6Zi1XHJcbiAgICAgICAgbGV0IGxvY2FsTWF0cml4ID0gcGFyZW50SW52ZXJzZU1hdHJpeC5tdWx0aXBseSh3b3JsZE1hdHJpeCk7XHJcbiAgICAgICAgcmV0dXJuIGxvY2FsTWF0cml4O1xyXG5cclxuICAgIH1cclxuXHJcbiAgICBwcml2YXRlIHNldExvY2FsWFlaU2NhbGVBbmdsZShtYXRyaXg6IGNjLk1hdDQsIG5vZGU6IGNjLk5vZGUsIGxhc3RNYXRyaXg/OiBjYy5NYXQ0KSB7XHJcbiAgICAgICAgaWYgKGxhc3RNYXRyaXggJiYgbWF0cml4LmVxdWFscyhsYXN0TWF0cml4KSkge1xyXG4gICAgICAgICAgICByZXR1cm47XHJcbiAgICAgICAgfVxyXG5cclxuICAgICAgICAvLyDmj5Dlj5bkvY3nva5cclxuICAgICAgICBub2RlLnNldFBvc2l0aW9uKG1hdHJpeC5tWzEyXSwgbWF0cml4Lm1bMTNdLCBtYXRyaXgubVsxNF0pO1xyXG5cclxuICAgICAgICBsZXQgc2NhbGVYID0gbnVsbDtcclxuICAgICAgICBsZXQgc2NhbGVZID0gbnVsbDtcclxuICAgICAgICBsZXQgYW5nbGUgPSBudWxsO1xyXG4gICAgICAgIC8vIOaPkOWPlue8qeaUvlhcclxuICAgICAgICBpZiAoIWxhc3RNYXRyaXgpIHtcclxuICAgICAgICAgICAgc2NhbGVYID0gTWF0aC5zcXJ0KG1hdHJpeC5tWzBdICogbWF0cml4Lm1bMF0gKyBtYXRyaXgubVsxXSAqIG1hdHJpeC5tWzFdICsgbWF0cml4Lm1bMl0gKiBtYXRyaXgubVsyXSk7XHJcbiAgICAgICAgfSBlbHNlIGlmICghdGhpcy5lcXVhbHNWYWx1ZShtYXRyaXgubVswXSwgbGFzdE1hdHJpeC5tWzBdKVxyXG4gICAgICAgICAgICB8fCAhdGhpcy5lcXVhbHNWYWx1ZShtYXRyaXgubVsxXSwgbGFzdE1hdHJpeC5tWzFdKVxyXG4gICAgICAgICAgICB8fCAhdGhpcy5lcXVhbHNWYWx1ZShtYXRyaXgubVsyXSwgbGFzdE1hdHJpeC5tWzJdKSkge1xyXG4gICAgICAgICAgICBzY2FsZVggPSBNYXRoLnNxcnQobWF0cml4Lm1bMF0gKiBtYXRyaXgubVswXSArIG1hdHJpeC5tWzFdICogbWF0cml4Lm1bMV0gKyBtYXRyaXgubVsyXSAqIG1hdHJpeC5tWzJdKTtcclxuICAgICAgICB9XHJcbiAgICAgICAgLy8g5o+Q5Y+W57yp5pS+WVxyXG4gICAgICAgIGlmICghbGFzdE1hdHJpeCkge1xyXG4gICAgICAgICAgICBzY2FsZVkgPSBNYXRoLnNxcnQobWF0cml4Lm1bNF0gKiBtYXRyaXgubVs0XSArIG1hdHJpeC5tWzVdICogbWF0cml4Lm1bNV0gKyBtYXRyaXgubVs2XSAqIG1hdHJpeC5tWzZdKTtcclxuICAgICAgICB9IGVsc2UgaWYgKCF0aGlzLmVxdWFsc1ZhbHVlKG1hdHJpeC5tWzRdLCBsYXN0TWF0cml4Lm1bNF0pXHJcbiAgICAgICAgICAgIHx8ICF0aGlzLmVxdWFsc1ZhbHVlKG1hdHJpeC5tWzVdLCBsYXN0TWF0cml4Lm1bNV0pXHJcbiAgICAgICAgICAgIHx8ICF0aGlzLmVxdWFsc1ZhbHVlKG1hdHJpeC5tWzZdLCBsYXN0TWF0cml4Lm1bNl0pKSB7XHJcbiAgICAgICAgICAgIHNjYWxlWSA9IE1hdGguc3FydChtYXRyaXgubVs0XSAqIG1hdHJpeC5tWzRdICsgbWF0cml4Lm1bNV0gKiBtYXRyaXgubVs1XSArIG1hdHJpeC5tWzZdICogbWF0cml4Lm1bNl0pO1xyXG4gICAgICAgIH1cclxuICAgICAgICAvL+iuvue9rue8qeaUvlhcclxuICAgICAgICBpZiAoc2NhbGVYICE9PSBudWxsKSB7XHJcbiAgICAgICAgICAgIG5vZGUuc2NhbGVYID0gc2NhbGVYO1xyXG4gICAgICAgICAgICAvLyDmj5Dlj5bml4vovaxcclxuICAgICAgICAgICAgYW5nbGUgPSBNYXRoLmF0YW4yKG1hdHJpeC5tWzFdIC8gc2NhbGVYLCBtYXRyaXgubVswXSAvIHNjYWxlWCkgKiAoMTgwIC8gTWF0aC5QSSk7XHJcbiAgICAgICAgfVxyXG4gICAgICAgIGlmIChzY2FsZVkgIT09IG51bGwpIHtcclxuICAgICAgICAgICAgbm9kZS5zY2FsZVkgPSBzY2FsZVk7XHJcbiAgICAgICAgfVxyXG4gICAgICAgIGlmIChhbmdsZSAhPT0gbnVsbCkge1xyXG4gICAgICAgICAgICBub2RlLnJvdGF0aW9uID0gYW5nbGU7XHJcbiAgICAgICAgfVxyXG4gICAgfVxyXG5cclxuICAgIHByaXZhdGUgZXF1YWxzVmFsdWUoYTogbnVtYmVyLCBiOiBudW1iZXIsIGVwc2lsb246IG51bWJlciA9IDAuMDAwMDEpIHtcclxuICAgICAgICByZXR1cm4gTWF0aC5hYnMoYSAtIGIpIDwgZXBzaWxvbjtcclxuICAgIH1cclxuXHJcbiAgICBwcm90ZWN0ZWQgb25EZXN0cm95KCk6IHZvaWQge1xyXG4gICAgICAgIHRoaXMucmVuZGVyQ29tcG5lbnQubm9kZS5kZXN0cm95KCk7XHJcbiAgICAgICAgdGhpcy5yZW5kZXJDb21wbmVudCA9IG51bGw7XHJcbiAgICAgICAgdGhpcy5wcm94eVJlbmRlciA9IG51bGw7XHJcbiAgICB9XHJcblxyXG4gICAgLyoqXHJcbiAgICAgKiDojrflj5boioLngrnpgI/mmI7luqZcclxuICAgICAqIEBwYXJhbSBub2RlIFxyXG4gICAgICovXHJcbiAgICBwcml2YXRlIGdldE9wYWNpdHkobm9kZTogY2MuTm9kZSkge1xyXG4gICAgICAgIGxldCBvcGFjaXR5ID0gKG5vZGUub3BhY2l0eSAvIDI1NSk7XHJcbiAgICAgICAgbGV0IHBhcmVudE5vZGUgPSBub2RlLnBhcmVudFxyXG4gICAgICAgIHdoaWxlIChwYXJlbnROb2RlICE9IHRoaXMucmVuZGVyTGF5ZXIucGFyZW50ICYmIHBhcmVudE5vZGUgIT0gY2MuZGlyZWN0b3IuZ2V0U2NlbmUoKSkge1xyXG4gICAgICAgICAgICBvcGFjaXR5ICo9IChwYXJlbnROb2RlLm9wYWNpdHkgLyAyNTUpO1xyXG4gICAgICAgICAgICBwYXJlbnROb2RlID0gcGFyZW50Tm9kZS5wYXJlbnQ7XHJcbiAgICAgICAgfVxyXG4gICAgICAgIHJldHVybiBvcGFjaXR5ICogMjU1O1xyXG4gICAgfVxyXG4gICAgLyoqXHJcbiAgICAgKiDojrflj5bmuLLmn5Pnu4Tku7ZcclxuICAgICAqIEBwYXJhbSBub2RlIFxyXG4gICAgICovXHJcbiAgICBwcml2YXRlIGdldFJlbmRlcigpIHtcclxuICAgICAgICBsZXQgbm9kZSA9IGNjLmluc3RhbnRpYXRlKHRoaXMubm9kZSk7XHJcbiAgICAgICAgbm9kZS5yZW1vdmVBbGxDaGlsZHJlbigpO1xyXG4gICAgICAgIHRoaXMucmVuZGVyQ29tcG5lbnQgPSBub2RlLmdldENvbXBvbmVudChjYy5SZW5kZXJDb21wb25lbnQpO1xyXG4gICAgICAgIHRoaXMubm9kZS5nZXRDb21wb25lbnQoY2MuTGFiZWxPdXRsaW5lKT8uZGVzdHJveSgpO1xyXG4gICAgICAgIHRoaXMubm9kZS5nZXRDb21wb25lbnQoY2MuTGFiZWxTaGFkb3cpPy5kZXN0cm95KCk7XHJcbiAgICAgICAgdGhpcy5ub2RlLmdldENvbXBvbmVudChjYy5SZW5kZXJDb21wb25lbnQpLmRlc3Ryb3koKTtcclxuICAgICAgICBsZXQgY29tcG9uZW50cyA9IG5vZGUuZ2V0Q29tcG9uZW50cyhjYy5Db21wb25lbnQpO1xyXG4gICAgICAgIGZvciAobGV0IGkgPSAwLCBsZW4gPSBjb21wb25lbnRzLmxlbmd0aDsgaSA8IGxlbjsgKytpKSB7XHJcbiAgICAgICAgICAgIGxldCBjb21wID0gY29tcG9uZW50c1tpXTtcclxuICAgICAgICAgICAgaWYgKCEoKGNvbXAgaW5zdGFuY2VvZiBjYy5SZW5kZXJDb21wb25lbnQpIHx8IChjb21wIGluc3RhbmNlb2YgY2MuTGFiZWxPdXRsaW5lKSB8fCAoY29tcCBpbnN0YW5jZW9mIGNjLkxhYmVsU2hhZG93KSkpIHtcclxuICAgICAgICAgICAgICAgIGNvbXAuZGVzdHJveSgpO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfVxyXG4gICAgICAgIHJldHVybiBub2RlO1xyXG4gICAgfVxyXG5cclxufVxyXG4iXX0= +//------QC-SOURCE-SPLIT------ diff --git a/Layered_virtual_list_2.x/temp/quick-scripts/dst/__qc_index__.js b/Layered_virtual_list_2.x/temp/quick-scripts/dst/__qc_index__.js new file mode 100644 index 0000000..db5af66 --- /dev/null +++ b/Layered_virtual_list_2.x/temp/quick-scripts/dst/__qc_index__.js @@ -0,0 +1,34 @@ + + (function() { + var nodeEnv = typeof require !== 'undefined' && typeof process !== 'undefined'; + var __module = nodeEnv ? module : {exports:{}}; + var __filename = 'preview-scripts/__qc_index__.js'; + var __require = nodeEnv ? function (request) { + return cc.require(request); + } : function (request) { + return __quick_compile_project__.require(request, __filename); + }; + function __define (exports, require, module) { + if (!nodeEnv) {__quick_compile_project__.registerModule(__filename, module);} +require('./assets/Scene/Item'); +require('./assets/Scene/TestLoop'); +require('./assets/Scene/TestMatrix'); +require('./assets/Scene/TestRenderAlternative'); +require('./assets/Scene/TestShowNode'); +require('./assets/Script/LoopList'); +require('./assets/Script/RenderAlternative'); +require('./assets/Script/RenderAlternative1'); +require('./assets/Script/RenderAlternativeItem'); +require('./assets/Script/RenderAlternative_old'); +require('./assets/Script/RenderReactiveHandler'); + + } + if (nodeEnv) { + __define(__module.exports, __require, __module); + } + else { + __quick_compile_project__.registerModuleFunc(__filename, function () { + __define(__module.exports, __require, __module); + }); + } + })(); \ No newline at end of file diff --git a/Layered_virtual_list_2.x/temp/quick-scripts/dst/__quick_compile__.js b/Layered_virtual_list_2.x/temp/quick-scripts/dst/__quick_compile__.js new file mode 100644 index 0000000..da20acf --- /dev/null +++ b/Layered_virtual_list_2.x/temp/quick-scripts/dst/__quick_compile__.js @@ -0,0 +1,267 @@ + +(function () { +var scripts = [{"deps":{"./assets/Scene/TestMatrix":4,"./assets/Scene/TestRenderAlternative":1,"./assets/Scene/TestShowNode":3,"./assets/Scene/Item":5,"./assets/Script/RenderAlternative":2,"./assets/Script/RenderAlternative1":11,"./assets/Script/RenderAlternativeItem":6,"./assets/Script/RenderAlternative_old":10,"./assets/Script/RenderReactiveHandler":8,"./assets/Script/LoopList":9,"./assets/Scene/TestLoop":7},"path":"preview-scripts/__qc_index__.js"},{"deps":{},"path":"preview-scripts/assets/Scene/TestRenderAlternative.js"},{"deps":{"./RenderReactiveHandler":8},"path":"preview-scripts/assets/Script/RenderAlternative.js"},{"deps":{"../Script/LoopList":9},"path":"preview-scripts/assets/Scene/TestShowNode.js"},{"deps":{},"path":"preview-scripts/assets/Scene/TestMatrix.js"},{"deps":{"../Script/RenderAlternativeItem":6},"path":"preview-scripts/assets/Scene/Item.js"},{"deps":{"./RenderAlternative":2},"path":"preview-scripts/assets/Script/RenderAlternativeItem.js"},{"deps":{"../Script/LoopList":9},"path":"preview-scripts/assets/Scene/TestLoop.js"},{"deps":{},"path":"preview-scripts/assets/Script/RenderReactiveHandler.js"},{"deps":{"./RenderAlternative":2},"path":"preview-scripts/assets/Script/LoopList.js"},{"deps":{"./RenderReactiveHandler":8},"path":"preview-scripts/assets/Script/RenderAlternative_old.js"},{"deps":{"./RenderReactiveHandler":8},"path":"preview-scripts/assets/Script/RenderAlternative1.js"}]; +var entries = ["preview-scripts/__qc_index__.js"]; +var bundleScript = 'preview-scripts/__qc_bundle__.js'; + +/** + * Notice: This file can not use ES6 (for IE 11) + */ +var modules = {}; +var name2path = {}; + +// Will generated by module.js plugin +// var scripts = ${scripts}; +// var entries = ${entries}; +// var bundleScript = ${bundleScript}; + +if (typeof global === 'undefined') { + window.global = window; +} + +var isJSB = typeof jsb !== 'undefined'; + +function getXMLHttpRequest () { + return window.XMLHttpRequest ? new window.XMLHttpRequest() : new ActiveXObject('MSXML2.XMLHTTP'); +} + +function downloadText(url, callback) { + if (isJSB) { + var result = jsb.fileUtils.getStringFromFile(url); + callback(null, result); + return; + } + + var xhr = getXMLHttpRequest(), + errInfo = 'Load text file failed: ' + url; + xhr.open('GET', url, true); + if (xhr.overrideMimeType) xhr.overrideMimeType('text\/plain; charset=utf-8'); + xhr.onload = function () { + if (xhr.readyState === 4) { + if (xhr.status === 200 || xhr.status === 0) { + callback(null, xhr.responseText); + } + else { + callback({status:xhr.status, errorMessage:errInfo + ', status: ' + xhr.status}); + } + } + else { + callback({status:xhr.status, errorMessage:errInfo + '(wrong readyState)'}); + } + }; + xhr.onerror = function(){ + callback({status:xhr.status, errorMessage:errInfo + '(error)'}); + }; + xhr.ontimeout = function(){ + callback({status:xhr.status, errorMessage:errInfo + '(time out)'}); + }; + xhr.send(null); +}; + +function loadScript (src, cb) { + if (typeof require !== 'undefined') { + require(src); + return cb(); + } + + // var timer = 'load ' + src; + // console.time(timer); + + var scriptElement = document.createElement('script'); + + function done() { + // console.timeEnd(timer); + // deallocation immediate whatever + scriptElement.remove(); + } + + scriptElement.onload = function () { + done(); + cb(); + }; + scriptElement.onerror = function () { + done(); + var error = 'Failed to load ' + src; + console.error(error); + cb(new Error(error)); + }; + scriptElement.setAttribute('type','text/javascript'); + scriptElement.setAttribute('charset', 'utf-8'); + scriptElement.setAttribute('src', src); + + document.head.appendChild(scriptElement); +} + +function loadScripts (srcs, cb) { + var n = srcs.length; + + srcs.forEach(function (src) { + loadScript(src, function () { + n--; + if (n === 0) { + cb(); + } + }); + }) +} + +function formatPath (path) { + let destPath = window.__quick_compile_project__.destPath; + if (destPath) { + let prefix = 'preview-scripts'; + if (destPath[destPath.length - 1] === '/') { + prefix += '/'; + } + path = path.replace(prefix, destPath); + } + return path; +} + +window.__quick_compile_project__ = { + destPath: '', + + registerModule: function (path, module) { + path = formatPath(path); + modules[path].module = module; + }, + + registerModuleFunc: function (path, func) { + path = formatPath(path); + modules[path].func = func; + + var sections = path.split('/'); + var name = sections[sections.length - 1]; + name = name.replace(/\.(?:js|ts|json)$/i, ''); + name2path[name] = path; + }, + + require: function (request, path) { + var m, requestScript; + + path = formatPath(path); + if (path) { + m = modules[path]; + if (!m) { + console.warn('Can not find module for path : ' + path); + return null; + } + } + + if (m) { + let depIndex = m.deps[request]; + // dependence script was excluded + if (depIndex === -1) { + return null; + } + else { + requestScript = scripts[ m.deps[request] ]; + } + } + + let requestPath = ''; + if (!requestScript) { + // search from name2path when request is a dynamic module name + if (/^[\w- .]*$/.test(request)) { + requestPath = name2path[request]; + } + + if (!requestPath) { + if (CC_JSB) { + return require(request); + } + else { + console.warn('Can not find deps [' + request + '] for path : ' + path); + return null; + } + } + } + else { + requestPath = formatPath(requestScript.path); + } + + let requestModule = modules[requestPath]; + if (!requestModule) { + console.warn('Can not find request module for path : ' + requestPath); + return null; + } + + if (!requestModule.module && requestModule.func) { + requestModule.func(); + } + + if (!requestModule.module) { + console.warn('Can not find requestModule.module for path : ' + path); + return null; + } + + return requestModule.module.exports; + }, + + run: function () { + entries.forEach(function (entry) { + entry = formatPath(entry); + var module = modules[entry]; + if (!module.module) { + module.func(); + } + }); + }, + + load: function (cb) { + var self = this; + + var srcs = scripts.map(function (script) { + var path = formatPath(script.path); + modules[path] = script; + + if (script.mtime) { + path += ("?mtime=" + script.mtime); + } + return path; + }); + + console.time && console.time('load __quick_compile_project__'); + // jsb can not analysis sourcemap, so keep separate files. + if (bundleScript && !isJSB) { + downloadText(formatPath(bundleScript), function (err, bundleSource) { + console.timeEnd && console.timeEnd('load __quick_compile_project__'); + if (err) { + console.error(err); + return; + } + + let evalTime = 'eval __quick_compile_project__ : ' + srcs.length + ' files'; + console.time && console.time(evalTime); + var sources = bundleSource.split('\n//------QC-SOURCE-SPLIT------\n'); + for (var i = 0; i < sources.length; i++) { + if (sources[i]) { + window.eval(sources[i]); + // not sure why new Function cannot set breakpoints precisely + // new Function(sources[i])() + } + } + self.run(); + console.timeEnd && console.timeEnd(evalTime); + cb(); + }) + } + else { + loadScripts(srcs, function () { + self.run(); + console.timeEnd && console.timeEnd('load __quick_compile_project__'); + cb(); + }); + } + } +}; + +// Polyfill for IE 11 +if (!('remove' in Element.prototype)) { + Element.prototype.remove = function () { + if (this.parentNode) { + this.parentNode.removeChild(this); + } + }; +} +})(); + \ No newline at end of file diff --git a/Layered_virtual_list_2.x/temp/quick-scripts/dst/assets/Scene/Item.js b/Layered_virtual_list_2.x/temp/quick-scripts/dst/assets/Scene/Item.js new file mode 100644 index 0000000..dc08d6a --- /dev/null +++ b/Layered_virtual_list_2.x/temp/quick-scripts/dst/assets/Scene/Item.js @@ -0,0 +1,99 @@ + + (function() { + var nodeEnv = typeof require !== 'undefined' && typeof process !== 'undefined'; + var __module = nodeEnv ? module : {exports:{}}; + var __filename = 'preview-scripts/assets/Scene/Item.js'; + var __require = nodeEnv ? function (request) { + return cc.require(request); + } : function (request) { + return __quick_compile_project__.require(request, __filename); + }; + function __define (exports, require, module) { + if (!nodeEnv) {__quick_compile_project__.registerModule(__filename, module);}"use strict"; +cc._RF.push(module, '7e1f6lmx11Hho9BNV3MqKkZ', 'Item'); +// Scene/Item.ts + +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var RenderAlternativeItem_1 = require("../Script/RenderAlternativeItem"); +var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property; +var Item = /** @class */ (function (_super) { + __extends(Item, _super); + function Item() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /** */ + _this.nameLb = null; + /** */ + _this.contentLb = null; + /** */ + _this.Button = null; + /** */ + _this.ButtonLb = null; + _this.data = null; + return _this; + // update (dt) {} + } + Item.prototype.init = function (data) { + this.data = data.data; + var layer = data.layer; + this.initRenderLayer(layer); + this.initShow(); + }; + /** + * 初始化显示 + * @param data + */ + Item.prototype.initShow = function () { + this.nameLb.string = "我是第" + this.data.index + "个"; + this.contentLb.string = "我是内容" + this.data.name; + }; + __decorate([ + property(cc.Label) + ], Item.prototype, "nameLb", void 0); + __decorate([ + property(cc.Label) + ], Item.prototype, "contentLb", void 0); + __decorate([ + property(cc.Node) + ], Item.prototype, "Button", void 0); + __decorate([ + property(cc.Label) + ], Item.prototype, "ButtonLb", void 0); + Item = __decorate([ + ccclass + ], Item); + return Item; +}(RenderAlternativeItem_1.default)); +exports.default = Item; + +cc._RF.pop(); + } + if (nodeEnv) { + __define(__module.exports, __require, __module); + } + else { + __quick_compile_project__.registerModuleFunc(__filename, function () { + __define(__module.exports, __require, __module); + }); + } + })(); +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImFzc2V0c1xcU2NlbmVcXEl0ZW0udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0FBQUEseUVBQW9FO0FBRzlELElBQUEsS0FBd0IsRUFBRSxDQUFDLFVBQVUsRUFBbkMsT0FBTyxhQUFBLEVBQUUsUUFBUSxjQUFrQixDQUFDO0FBRzVDO0lBQWtDLHdCQUFxQjtJQUF2RDtRQUFBLHFFQWtDQztRQWhDRyxNQUFNO1FBRUMsWUFBTSxHQUFhLElBQUksQ0FBQztRQUMvQixNQUFNO1FBRUMsZUFBUyxHQUFhLElBQUksQ0FBQztRQUNsQyxNQUFNO1FBRUMsWUFBTSxHQUFZLElBQUksQ0FBQztRQUM5QixNQUFNO1FBRUMsY0FBUSxHQUFhLElBQUksQ0FBQztRQUVqQyxVQUFJLEdBQVEsSUFBSSxDQUFDOztRQWtCakIsaUJBQWlCO0lBQ3JCLENBQUM7SUFqQkcsbUJBQUksR0FBSixVQUFLLElBQVM7UUFDVixJQUFJLENBQUMsSUFBSSxHQUFHLElBQUksQ0FBQyxJQUFJLENBQUM7UUFDdEIsSUFBSSxLQUFLLEdBQUcsSUFBSSxDQUFDLEtBQUssQ0FBQztRQUN2QixJQUFJLENBQUMsZUFBZSxDQUFDLEtBQUssQ0FBQyxDQUFDO1FBQzVCLElBQUksQ0FBQyxRQUFRLEVBQUUsQ0FBQztJQUNwQixDQUFDO0lBRUQ7OztPQUdHO0lBQ0gsdUJBQVEsR0FBUjtRQUNJLElBQUksQ0FBQyxNQUFNLENBQUMsTUFBTSxHQUFHLEtBQUssR0FBRyxJQUFJLENBQUMsSUFBSSxDQUFDLEtBQUssR0FBRyxHQUFHLENBQUM7UUFDbkQsSUFBSSxDQUFDLFNBQVMsQ0FBQyxNQUFNLEdBQUcsTUFBTSxHQUFHLElBQUksQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDO0lBQ3BELENBQUM7SUEzQkQ7UUFEQyxRQUFRLENBQUMsRUFBRSxDQUFDLEtBQUssQ0FBQzt3Q0FDWTtJQUcvQjtRQURDLFFBQVEsQ0FBQyxFQUFFLENBQUMsS0FBSyxDQUFDOzJDQUNlO0lBR2xDO1FBREMsUUFBUSxDQUFDLEVBQUUsQ0FBQyxJQUFJLENBQUM7d0NBQ1k7SUFHOUI7UUFEQyxRQUFRLENBQUMsRUFBRSxDQUFDLEtBQUssQ0FBQzswQ0FDYztJQWJoQixJQUFJO1FBRHhCLE9BQU87T0FDYSxJQUFJLENBa0N4QjtJQUFELFdBQUM7Q0FsQ0QsQUFrQ0MsQ0FsQ2lDLCtCQUFxQixHQWtDdEQ7a0JBbENvQixJQUFJIiwiZmlsZSI6IiIsInNvdXJjZVJvb3QiOiIvIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IFJlbmRlckFsdGVybmF0aXZlSXRlbSBmcm9tIFwiLi4vU2NyaXB0L1JlbmRlckFsdGVybmF0aXZlSXRlbVwiO1xyXG5cclxuXHJcbmNvbnN0IHsgY2NjbGFzcywgcHJvcGVydHkgfSA9IGNjLl9kZWNvcmF0b3I7XHJcblxyXG5AY2NjbGFzc1xyXG5leHBvcnQgZGVmYXVsdCBjbGFzcyBJdGVtIGV4dGVuZHMgUmVuZGVyQWx0ZXJuYXRpdmVJdGVtIHtcclxuXHJcbiAgICAvKiogKi9cclxuICAgIEBwcm9wZXJ0eShjYy5MYWJlbClcclxuICAgIHB1YmxpYyBuYW1lTGI6IGNjLkxhYmVsID0gbnVsbDtcclxuICAgIC8qKiAqL1xyXG4gICAgQHByb3BlcnR5KGNjLkxhYmVsKVxyXG4gICAgcHVibGljIGNvbnRlbnRMYjogY2MuTGFiZWwgPSBudWxsO1xyXG4gICAgLyoqICovXHJcbiAgICBAcHJvcGVydHkoY2MuTm9kZSlcclxuICAgIHB1YmxpYyBCdXR0b246IGNjLk5vZGUgPSBudWxsO1xyXG4gICAgLyoqICovXHJcbiAgICBAcHJvcGVydHkoY2MuTGFiZWwpXHJcbiAgICBwdWJsaWMgQnV0dG9uTGI6IGNjLkxhYmVsID0gbnVsbDtcclxuXHJcbiAgICBkYXRhOiBhbnkgPSBudWxsO1xyXG5cclxuICAgIGluaXQoZGF0YTogYW55KSB7XHJcbiAgICAgICAgdGhpcy5kYXRhID0gZGF0YS5kYXRhO1xyXG4gICAgICAgIGxldCBsYXllciA9IGRhdGEubGF5ZXI7XHJcbiAgICAgICAgdGhpcy5pbml0UmVuZGVyTGF5ZXIobGF5ZXIpO1xyXG4gICAgICAgIHRoaXMuaW5pdFNob3coKTtcclxuICAgIH1cclxuXHJcbiAgICAvKipcclxuICAgICAqIOWIneWni+WMluaYvuekulxyXG4gICAgICogQHBhcmFtIGRhdGEgXHJcbiAgICAgKi9cclxuICAgIGluaXRTaG93KCkge1xyXG4gICAgICAgIHRoaXMubmFtZUxiLnN0cmluZyA9IFwi5oiR5piv56ysXCIgKyB0aGlzLmRhdGEuaW5kZXggKyBcIuS4qlwiO1xyXG4gICAgICAgIHRoaXMuY29udGVudExiLnN0cmluZyA9IFwi5oiR5piv5YaF5a65XCIgKyB0aGlzLmRhdGEubmFtZTtcclxuICAgIH1cclxuXHJcbiAgICAvLyB1cGRhdGUgKGR0KSB7fVxyXG59XHJcbiJdfQ== \ No newline at end of file diff --git a/Layered_virtual_list_2.x/temp/quick-scripts/dst/assets/Scene/TestLoop.js b/Layered_virtual_list_2.x/temp/quick-scripts/dst/assets/Scene/TestLoop.js new file mode 100644 index 0000000..fc65e5f --- /dev/null +++ b/Layered_virtual_list_2.x/temp/quick-scripts/dst/assets/Scene/TestLoop.js @@ -0,0 +1,119 @@ + + (function() { + var nodeEnv = typeof require !== 'undefined' && typeof process !== 'undefined'; + var __module = nodeEnv ? module : {exports:{}}; + var __filename = 'preview-scripts/assets/Scene/TestLoop.js'; + var __require = nodeEnv ? function (request) { + return cc.require(request); + } : function (request) { + return __quick_compile_project__.require(request, __filename); + }; + function __define (exports, require, module) { + if (!nodeEnv) {__quick_compile_project__.registerModule(__filename, module);}"use strict"; +cc._RF.push(module, '4850bCv26VE3LcjWQcJHche', 'TestLoop'); +// Scene/TestLoop.ts + +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.TestLoop = void 0; +var LoopList_1 = require("../Script/LoopList"); +var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property; +var TestLoop = /** @class */ (function (_super) { + __extends(TestLoop, _super); + function TestLoop() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /**分层渲染节点 */ + _this.rendeLayer = null; + /**显示节点预制件 */ + _this.scrollView = null; + /**显示节点预制件 */ + _this.showPrefab = null; + return _this; + } + TestLoop.prototype.start = function () { + //测试横向宽高数据 + /* let baseWidth = 80; + let changeWidth = 20; + let baseHeight = 600; + let changeHeight = 150; + let anchor = cc.v2(0.5, 0.5) */ + //测试纵向宽高数据 + var baseWidth = 600; + var changeWidth = 150; + var baseHeight = 80; + var changeHeight = 20; + var anchor = cc.v2(0.5, 0.5); + var data = []; + for (var i = 0, len = 30; i < len; ++i) { + data.push({ + index: i, text: "内容" + i + }); + } + LoopList_1.default.ins("Test").init(this.scrollView, this.rendeLayer, 18); + LoopList_1.default.ins("Test").initData(data, this.showPrefab, cc.size(baseWidth, baseHeight), anchor); + /* //测试插入数据 + this.scheduleOnce(() => { + LoopList.ins("Test").insertData({ index: 1, text: "我是插入1", size: cc.size(baseWidth, baseHeight) }, 1); + }, 3) + + //测试压入数据 + this.scheduleOnce(() => { + LoopList.ins("Test").pushDatas([ + { index: 1, text: "我是压入1", size: cc.size(baseWidth, baseHeight) }, + { index: 2, text: "我是压入2", size: cc.size(baseWidth, baseHeight) }, + { index: 3, text: "我是压入3", size: cc.size(baseWidth, baseHeight) }, + ]); + }, 4) + + //测试压入数据 + this.scheduleOnce(() => { + LoopList.ins("Test").removeData(1); + }, 5) */ + }; + __decorate([ + property(cc.Node) + ], TestLoop.prototype, "rendeLayer", void 0); + __decorate([ + property(cc.ScrollView) + ], TestLoop.prototype, "scrollView", void 0); + __decorate([ + property(cc.Prefab) + ], TestLoop.prototype, "showPrefab", void 0); + TestLoop = __decorate([ + ccclass + ], TestLoop); + return TestLoop; +}(cc.Component)); +exports.TestLoop = TestLoop; + +cc._RF.pop(); + } + if (nodeEnv) { + __define(__module.exports, __require, __module); + } + else { + __quick_compile_project__.registerModuleFunc(__filename, function () { + __define(__module.exports, __require, __module); + }); + } + })(); +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImFzc2V0c1xcU2NlbmVcXFRlc3RMb29wLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7QUFFQSwrQ0FBMEM7QUFFcEMsSUFBQSxLQUF3QixFQUFFLENBQUMsVUFBVSxFQUFuQyxPQUFPLGFBQUEsRUFBRSxRQUFRLGNBQWtCLENBQUM7QUFHNUM7SUFBOEIsNEJBQVk7SUFBMUM7UUFBQSxxRUFzREM7UUFyREcsWUFBWTtRQUVMLGdCQUFVLEdBQVksSUFBSSxDQUFDO1FBQ2xDLGFBQWE7UUFFTixnQkFBVSxHQUFrQixJQUFJLENBQUM7UUFDeEMsYUFBYTtRQUVOLGdCQUFVLEdBQWMsSUFBSSxDQUFDOztJQTZDeEMsQ0FBQztJQTNDRyx3QkFBSyxHQUFMO1FBQ0ksVUFBVTtRQUNWOzs7O3VDQUkrQjtRQUUvQixVQUFVO1FBQ1YsSUFBSSxTQUFTLEdBQUcsR0FBRyxDQUFDO1FBQ3BCLElBQUksV0FBVyxHQUFHLEdBQUcsQ0FBQztRQUN0QixJQUFJLFVBQVUsR0FBRyxFQUFFLENBQUM7UUFDcEIsSUFBSSxZQUFZLEdBQUcsRUFBRSxDQUFDO1FBQ3RCLElBQUksTUFBTSxHQUFHLEVBQUUsQ0FBQyxFQUFFLENBQUMsR0FBRyxFQUFFLEdBQUcsQ0FBQyxDQUFDO1FBRTdCLElBQUksSUFBSSxHQUFZLEVBQUUsQ0FBQztRQUN2QixLQUFLLElBQUksQ0FBQyxHQUFHLENBQUMsRUFBRSxHQUFHLEdBQUcsRUFBRSxFQUFFLENBQUMsR0FBRyxHQUFHLEVBQUUsRUFBRSxDQUFDLEVBQUU7WUFDcEMsSUFBSSxDQUFDLElBQUksQ0FBQztnQkFDTixLQUFLLEVBQUUsQ0FBQyxFQUFFLElBQUksRUFBRSxJQUFJLEdBQUcsQ0FBQzthQUMzQixDQUFDLENBQUM7U0FDTjtRQUNELGtCQUFRLENBQUMsR0FBRyxDQUFRLE1BQU0sQ0FBQyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsVUFBVSxFQUFFLElBQUksQ0FBQyxVQUFVLEVBQUUsRUFBRSxDQUFDLENBQUM7UUFDdkUsa0JBQVEsQ0FBQyxHQUFHLENBQVEsTUFBTSxDQUFDLENBQUMsUUFBUSxDQUFDLElBQUksRUFBRSxJQUFJLENBQUMsVUFBVSxFQUFFLEVBQUUsQ0FBQyxJQUFJLENBQUMsU0FBUyxFQUFFLFVBQVUsQ0FBQyxFQUFFLE1BQU0sQ0FBQyxDQUFDO1FBRXBHOzs7Ozs7Ozs7Ozs7Ozs7OztnQkFpQlE7SUFDWixDQUFDO0lBbEREO1FBREMsUUFBUSxDQUFDLEVBQUUsQ0FBQyxJQUFJLENBQUM7Z0RBQ2dCO0lBR2xDO1FBREMsUUFBUSxDQUFDLEVBQUUsQ0FBQyxVQUFVLENBQUM7Z0RBQ2dCO0lBR3hDO1FBREMsUUFBUSxDQUFDLEVBQUUsQ0FBQyxNQUFNLENBQUM7Z0RBQ2dCO0lBVDNCLFFBQVE7UUFEcEIsT0FBTztPQUNLLFFBQVEsQ0FzRHBCO0lBQUQsZUFBQztDQXRERCxBQXNEQyxDQXRENkIsRUFBRSxDQUFDLFNBQVMsR0FzRHpDO0FBdERZLDRCQUFRIiwiZmlsZSI6IiIsInNvdXJjZVJvb3QiOiIvIiwic291cmNlc0NvbnRlbnQiOlsiXHJcblxyXG5pbXBvcnQgTG9vcExpc3QgZnJvbSAnLi4vU2NyaXB0L0xvb3BMaXN0JztcclxuaW1wb3J0IHsgSURhdGEgfSBmcm9tICcuL1Rlc3RTaG93Tm9kZSc7XHJcbmNvbnN0IHsgY2NjbGFzcywgcHJvcGVydHkgfSA9IGNjLl9kZWNvcmF0b3I7XHJcblxyXG5AY2NjbGFzc1xyXG5leHBvcnQgY2xhc3MgVGVzdExvb3AgZXh0ZW5kcyBjYy5Db21wb25lbnQge1xyXG4gICAgLyoq5YiG5bGC5riy5p+T6IqC54K5ICovXHJcbiAgICBAcHJvcGVydHkoY2MuTm9kZSlcclxuICAgIHB1YmxpYyByZW5kZUxheWVyOiBjYy5Ob2RlID0gbnVsbDtcclxuICAgIC8qKuaYvuekuuiKgueCuemihOWItuS7tiAqL1xyXG4gICAgQHByb3BlcnR5KGNjLlNjcm9sbFZpZXcpXHJcbiAgICBwdWJsaWMgc2Nyb2xsVmlldzogY2MuU2Nyb2xsVmlldyA9IG51bGw7XHJcbiAgICAvKirmmL7npLroioLngrnpooTliLbku7YgKi9cclxuICAgIEBwcm9wZXJ0eShjYy5QcmVmYWIpXHJcbiAgICBwdWJsaWMgc2hvd1ByZWZhYjogY2MuUHJlZmFiID0gbnVsbDtcclxuXHJcbiAgICBzdGFydCgpIHtcclxuICAgICAgICAvL+a1i+ivleaoquWQkeWuvemrmOaVsOaNrlxyXG4gICAgICAgIC8qIGxldCBiYXNlV2lkdGggPSA4MDtcclxuICAgICAgICBsZXQgY2hhbmdlV2lkdGggPSAyMDtcclxuICAgICAgICBsZXQgYmFzZUhlaWdodCA9IDYwMDtcclxuICAgICAgICBsZXQgY2hhbmdlSGVpZ2h0ID0gMTUwO1xyXG4gICAgICAgIGxldCBhbmNob3IgPSBjYy52MigwLjUsIDAuNSkgKi9cclxuXHJcbiAgICAgICAgLy/mtYvor5XnurXlkJHlrr3pq5jmlbDmja5cclxuICAgICAgICBsZXQgYmFzZVdpZHRoID0gNjAwO1xyXG4gICAgICAgIGxldCBjaGFuZ2VXaWR0aCA9IDE1MDtcclxuICAgICAgICBsZXQgYmFzZUhlaWdodCA9IDgwO1xyXG4gICAgICAgIGxldCBjaGFuZ2VIZWlnaHQgPSAyMDtcclxuICAgICAgICBsZXQgYW5jaG9yID0gY2MudjIoMC41LCAwLjUpO1xyXG5cclxuICAgICAgICBsZXQgZGF0YTogSURhdGFbXSA9IFtdO1xyXG4gICAgICAgIGZvciAobGV0IGkgPSAwLCBsZW4gPSAzMDsgaSA8IGxlbjsgKytpKSB7XHJcbiAgICAgICAgICAgIGRhdGEucHVzaCh7XHJcbiAgICAgICAgICAgICAgICBpbmRleDogaSwgdGV4dDogXCLlhoXlrrlcIiArIGlcclxuICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgfVxyXG4gICAgICAgIExvb3BMaXN0LmluczxJRGF0YT4oXCJUZXN0XCIpLmluaXQodGhpcy5zY3JvbGxWaWV3LCB0aGlzLnJlbmRlTGF5ZXIsIDE4KTtcclxuICAgICAgICBMb29wTGlzdC5pbnM8SURhdGE+KFwiVGVzdFwiKS5pbml0RGF0YShkYXRhLCB0aGlzLnNob3dQcmVmYWIsIGNjLnNpemUoYmFzZVdpZHRoLCBiYXNlSGVpZ2h0KSwgYW5jaG9yKTtcclxuXHJcbiAgICAgICAgLyogLy/mtYvor5Xmj5LlhaXmlbDmja5cclxuICAgICAgICB0aGlzLnNjaGVkdWxlT25jZSgoKSA9PiB7XHJcbiAgICAgICAgICAgIExvb3BMaXN0LmluczxJRGF0YT4oXCJUZXN0XCIpLmluc2VydERhdGEoeyBpbmRleDogMSwgdGV4dDogXCLmiJHmmK/mj5LlhaUxXCIsIHNpemU6IGNjLnNpemUoYmFzZVdpZHRoLCBiYXNlSGVpZ2h0KSB9LCAxKTtcclxuICAgICAgICB9LCAzKVxyXG5cclxuICAgICAgICAvL+a1i+ivleWOi+WFpeaVsOaNrlxyXG4gICAgICAgIHRoaXMuc2NoZWR1bGVPbmNlKCgpID0+IHtcclxuICAgICAgICAgICAgTG9vcExpc3QuaW5zPElEYXRhPihcIlRlc3RcIikucHVzaERhdGFzKFtcclxuICAgICAgICAgICAgICAgIHsgaW5kZXg6IDEsIHRleHQ6IFwi5oiR5piv5Y6L5YWlMVwiLCBzaXplOiBjYy5zaXplKGJhc2VXaWR0aCwgYmFzZUhlaWdodCkgfSxcclxuICAgICAgICAgICAgICAgIHsgaW5kZXg6IDIsIHRleHQ6IFwi5oiR5piv5Y6L5YWlMlwiLCBzaXplOiBjYy5zaXplKGJhc2VXaWR0aCwgYmFzZUhlaWdodCkgfSxcclxuICAgICAgICAgICAgICAgIHsgaW5kZXg6IDMsIHRleHQ6IFwi5oiR5piv5Y6L5YWlM1wiLCBzaXplOiBjYy5zaXplKGJhc2VXaWR0aCwgYmFzZUhlaWdodCkgfSxcclxuICAgICAgICAgICAgXSk7XHJcbiAgICAgICAgfSwgNClcclxuXHJcbiAgICAgICAgLy/mtYvor5XljovlhaXmlbDmja5cclxuICAgICAgICB0aGlzLnNjaGVkdWxlT25jZSgoKSA9PiB7XHJcbiAgICAgICAgICAgIExvb3BMaXN0LmluczxJRGF0YT4oXCJUZXN0XCIpLnJlbW92ZURhdGEoMSk7XHJcbiAgICAgICAgfSwgNSkgKi9cclxuICAgIH1cclxufVxyXG5cclxuXHJcbiJdfQ== \ No newline at end of file diff --git a/Layered_virtual_list_2.x/temp/quick-scripts/dst/assets/Scene/TestMatrix.js b/Layered_virtual_list_2.x/temp/quick-scripts/dst/assets/Scene/TestMatrix.js new file mode 100644 index 0000000..2df55d3 --- /dev/null +++ b/Layered_virtual_list_2.x/temp/quick-scripts/dst/assets/Scene/TestMatrix.js @@ -0,0 +1,180 @@ + + (function() { + var nodeEnv = typeof require !== 'undefined' && typeof process !== 'undefined'; + var __module = nodeEnv ? module : {exports:{}}; + var __filename = 'preview-scripts/assets/Scene/TestMatrix.js'; + var __require = nodeEnv ? function (request) { + return cc.require(request); + } : function (request) { + return __quick_compile_project__.require(request, __filename); + }; + function __define (exports, require, module) { + if (!nodeEnv) {__quick_compile_project__.registerModule(__filename, module);}"use strict"; +cc._RF.push(module, '41fb7HlhIJNzZMkSaq31ryP', 'TestMatrix'); +// Scene/TestMatrix.ts + +"use strict"; +// Learn TypeScript: +// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html +// Learn Attribute: +// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html +// Learn life-cycle callbacks: +// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property; +var NewClass = /** @class */ (function (_super) { + __extends(NewClass, _super); + function NewClass() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.target = null; + _this.targetParent = null; + _this.srcTarget = null; + _this.srcTargetParent = null; + return _this; + // update (dt) {} + } + // LIFE-CYCLE CALLBACKS: + NewClass.prototype.onLoad = function () { + // cc.director.on(cc.Director.EVENT_BEFORE_DRAW, this.onBeforeDraw, this); + }; + NewClass.prototype.start = function () { + // this.scheduleOnce(() => { + // this.target.x = 100; + // this.target.scaleX = 2; + // }, 3); + // this.scheduleOnce(() => { + // this.targetParent.x = 10; + // this.target.scaleX = 1.1; + // }, 1); + var targetNode = this.target; // 需要获取世界矩阵的节点 + var parentNode = this.targetParent; // 要转换到的节点 + var localMatrix = cc.mat4(); + targetNode.getLocalMatrix(localMatrix); + this.getMatrixInfo(localMatrix); + // 获取目标节点的世界矩阵 + var worldMatrix = cc.mat4(); + targetNode.getWorldMatrix(worldMatrix); + // 获取父节点的世界矩阵 + var parentWorldMatrix = cc.mat4(); + parentNode.getWorldMatrix(parentWorldMatrix); + // 获取父节点的逆矩阵 + var parentInverseMatrix = parentWorldMatrix.invert(); + // 将目标节点的世界矩阵转换为父节点的本地矩阵 + var localMatrix2 = parentInverseMatrix.multiply(worldMatrix); + this.getMatrixInfo(localMatrix2); + }; + NewClass.prototype.matrixTransform = function () { + // 假设我们有一个目标节点和一个父节点 + var targetNode = this.target; // 需要获取世界矩阵的节点 + var parentNode = this.srcTargetParent; // 要转换到的节点 + // 获取目标节点的世界矩阵 + var worldMatrix = cc.mat4(); + targetNode.getWorldMatrix(worldMatrix); + // 获取父节点的世界矩阵 + var parentWorldMatrix = cc.mat4(); + parentNode.getWorldMatrix(parentWorldMatrix); + // 获取父节点的逆矩阵 + var parentInverseMatrix = parentWorldMatrix.invert(); + // 将目标节点的世界矩阵转换为父节点的本地矩阵 + var localMatrix = parentInverseMatrix.multiply(worldMatrix); + // 提取位置 + var position = cc.v3(worldMatrix.m[12], worldMatrix.m[13], worldMatrix.m[14]); + // 提取缩放 + var scaleX = Math.sqrt(worldMatrix.m[0] * worldMatrix.m[0] + worldMatrix.m[1] * worldMatrix.m[1] + worldMatrix.m[2] * worldMatrix.m[2]); + var scaleY = Math.sqrt(worldMatrix.m[4] * worldMatrix.m[4] + worldMatrix.m[5] * worldMatrix.m[5] + worldMatrix.m[6] * worldMatrix.m[6]); + var scaleZ = Math.sqrt(worldMatrix.m[8] * worldMatrix.m[8] + worldMatrix.m[9] * worldMatrix.m[9] + worldMatrix.m[10] * worldMatrix.m[10]); + // 提取旋转(假设是二维旋转) + var angle = Math.atan2(worldMatrix.m[1] / scaleX, worldMatrix.m[0] / scaleX) * (180 / Math.PI); + // 输出结果 + console.log("Position:", position); + console.log("Scale:", cc.v3(scaleX, scaleY, scaleZ)); + console.log("Angle:", angle); + }; + NewClass.prototype.getMatrixInfo = function (matrix) { + // 提取位置 + var position = cc.v3(matrix.m[12], matrix.m[13], matrix.m[14]); + // 提取缩放 + var scaleX = Math.sqrt(matrix.m[0] * matrix.m[0] + matrix.m[1] * matrix.m[1] + matrix.m[2] * matrix.m[2]); + var scaleY = Math.sqrt(matrix.m[4] * matrix.m[4] + matrix.m[5] * matrix.m[5] + matrix.m[6] * matrix.m[6]); + var scaleZ = Math.sqrt(matrix.m[8] * matrix.m[8] + matrix.m[9] * matrix.m[9] + matrix.m[10] * matrix.m[10]); + // 提取旋转(假设是二维旋转) + var angle = Math.atan2(matrix.m[1] / scaleX, matrix.m[0] / scaleX) * (180 / Math.PI); + // 输出结果 + console.log("Position:", position); + console.log("Scale:", cc.v3(scaleX, scaleY, scaleZ)); + console.log("Angle:", angle); + }; + NewClass.prototype.onDestroy = function () { + cc.director.off(cc.Director.EVENT_BEFORE_DRAW, this.onBeforeDraw, this); + }; + NewClass.prototype.onBeforeDraw = function () { + this.checkDirty(this.target); + this.checkDirty(this.targetParent); + }; + NewClass.prototype.checkDirty = function (node) { + //@ts-ignore + var _localMatDirty = node._localMatDirty; + if (_localMatDirty) { + console.log(node.name, _localMatDirty); + } + //@ts-ignore + var _worldMatDirty = node._worldMatDirty; + if (_worldMatDirty) { + console.log(node.name, _worldMatDirty); + } + //@ts-ignore + var _renderFlag = node._renderFlag; + if (_renderFlag) { + console.log(node.name, _renderFlag); + } + }; + __decorate([ + property(cc.Node) + ], NewClass.prototype, "target", void 0); + __decorate([ + property(cc.Node) + ], NewClass.prototype, "targetParent", void 0); + __decorate([ + property(cc.Node) + ], NewClass.prototype, "srcTarget", void 0); + __decorate([ + property(cc.Node) + ], NewClass.prototype, "srcTargetParent", void 0); + NewClass = __decorate([ + ccclass + ], NewClass); + return NewClass; +}(cc.Component)); +exports.default = NewClass; + +cc._RF.pop(); + } + if (nodeEnv) { + __define(__module.exports, __require, __module); + } + else { + __quick_compile_project__.registerModuleFunc(__filename, function () { + __define(__module.exports, __require, __module); + }); + } + })(); +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImFzc2V0c1xcU2NlbmVcXFRlc3RNYXRyaXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7OztBQUFBLG9CQUFvQjtBQUNwQix3RUFBd0U7QUFDeEUsbUJBQW1CO0FBQ25CLGtGQUFrRjtBQUNsRiw4QkFBOEI7QUFDOUIsa0ZBQWtGOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7QUFFNUUsSUFBQSxLQUF3QixFQUFFLENBQUMsVUFBVSxFQUFuQyxPQUFPLGFBQUEsRUFBRSxRQUFRLGNBQWtCLENBQUM7QUFHNUM7SUFBc0MsNEJBQVk7SUFBbEQ7UUFBQSxxRUF5SUM7UUF0SUcsWUFBTSxHQUFZLElBQUksQ0FBQztRQUd2QixrQkFBWSxHQUFZLElBQUksQ0FBQztRQUc3QixlQUFTLEdBQVksSUFBSSxDQUFDO1FBRzFCLHFCQUFlLEdBQVksSUFBSSxDQUFDOztRQTRIaEMsaUJBQWlCO0lBQ3JCLENBQUM7SUE1SEcsd0JBQXdCO0lBRXhCLHlCQUFNLEdBQU47UUFDSSwwRUFBMEU7SUFDOUUsQ0FBQztJQUVELHdCQUFLLEdBQUw7UUFDSSw0QkFBNEI7UUFDNUIsMkJBQTJCO1FBQzNCLDhCQUE4QjtRQUM5QixTQUFTO1FBRVQsNEJBQTRCO1FBQzVCLGdDQUFnQztRQUNoQyxnQ0FBZ0M7UUFDaEMsU0FBUztRQUNULElBQUksVUFBVSxHQUFHLElBQUksQ0FBQyxNQUFNLENBQUMsQ0FBQyxjQUFjO1FBQzVDLElBQUksVUFBVSxHQUFHLElBQUksQ0FBQyxZQUFZLENBQUMsQ0FBQyxVQUFVO1FBRTlDLElBQUksV0FBVyxHQUFHLEVBQUUsQ0FBQyxJQUFJLEVBQUUsQ0FBQztRQUM1QixVQUFVLENBQUMsY0FBYyxDQUFDLFdBQVcsQ0FBQyxDQUFDO1FBQ3ZDLElBQUksQ0FBQyxhQUFhLENBQUMsV0FBVyxDQUFDLENBQUM7UUFFaEMsY0FBYztRQUNkLElBQUksV0FBVyxHQUFHLEVBQUUsQ0FBQyxJQUFJLEVBQUUsQ0FBQztRQUM1QixVQUFVLENBQUMsY0FBYyxDQUFDLFdBQVcsQ0FBQyxDQUFBO1FBQ3RDLGFBQWE7UUFDYixJQUFJLGlCQUFpQixHQUFHLEVBQUUsQ0FBQyxJQUFJLEVBQUUsQ0FBQztRQUNsQyxVQUFVLENBQUMsY0FBYyxDQUFDLGlCQUFpQixDQUFDLENBQUM7UUFFN0MsWUFBWTtRQUNaLElBQUksbUJBQW1CLEdBQUcsaUJBQWlCLENBQUMsTUFBTSxFQUFFLENBQUM7UUFFckQsd0JBQXdCO1FBQ3hCLElBQUksWUFBWSxHQUFHLG1CQUFtQixDQUFDLFFBQVEsQ0FBQyxXQUFXLENBQUMsQ0FBQztRQUU3RCxJQUFJLENBQUMsYUFBYSxDQUFDLFlBQVksQ0FBQyxDQUFDO0lBRXJDLENBQUM7SUFFRCxrQ0FBZSxHQUFmO1FBQ0ksb0JBQW9CO1FBQ3BCLElBQUksVUFBVSxHQUFHLElBQUksQ0FBQyxNQUFNLENBQUMsQ0FBQyxjQUFjO1FBQzVDLElBQUksVUFBVSxHQUFHLElBQUksQ0FBQyxlQUFlLENBQUMsQ0FBQyxVQUFVO1FBRWpELGNBQWM7UUFDZCxJQUFJLFdBQVcsR0FBRyxFQUFFLENBQUMsSUFBSSxFQUFFLENBQUM7UUFDNUIsVUFBVSxDQUFDLGNBQWMsQ0FBQyxXQUFXLENBQUMsQ0FBQTtRQUV0QyxhQUFhO1FBQ2IsSUFBSSxpQkFBaUIsR0FBRyxFQUFFLENBQUMsSUFBSSxFQUFFLENBQUM7UUFDbEMsVUFBVSxDQUFDLGNBQWMsQ0FBQyxpQkFBaUIsQ0FBQyxDQUFBO1FBRTVDLFlBQVk7UUFDWixJQUFJLG1CQUFtQixHQUFHLGlCQUFpQixDQUFDLE1BQU0sRUFBRSxDQUFDO1FBRXJELHdCQUF3QjtRQUN4QixJQUFJLFdBQVcsR0FBRyxtQkFBbUIsQ0FBQyxRQUFRLENBQUMsV0FBVyxDQUFDLENBQUM7UUFHNUQsT0FBTztRQUNQLElBQUksUUFBUSxHQUFHLEVBQUUsQ0FBQyxFQUFFLENBQUMsV0FBVyxDQUFDLENBQUMsQ0FBQyxFQUFFLENBQUMsRUFBRSxXQUFXLENBQUMsQ0FBQyxDQUFDLEVBQUUsQ0FBQyxFQUFFLFdBQVcsQ0FBQyxDQUFDLENBQUMsRUFBRSxDQUFDLENBQUMsQ0FBQztRQUU5RSxPQUFPO1FBQ1AsSUFBSSxNQUFNLEdBQUcsSUFBSSxDQUFDLElBQUksQ0FBQyxXQUFXLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLFdBQVcsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsV0FBVyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxXQUFXLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLFdBQVcsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsV0FBVyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDO1FBQ3hJLElBQUksTUFBTSxHQUFHLElBQUksQ0FBQyxJQUFJLENBQUMsV0FBVyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxXQUFXLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLFdBQVcsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsV0FBVyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxXQUFXLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLFdBQVcsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQztRQUN4SSxJQUFJLE1BQU0sR0FBRyxJQUFJLENBQUMsSUFBSSxDQUFDLFdBQVcsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsV0FBVyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxXQUFXLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLFdBQVcsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsV0FBVyxDQUFDLENBQUMsQ0FBQyxFQUFFLENBQUMsR0FBRyxXQUFXLENBQUMsQ0FBQyxDQUFDLEVBQUUsQ0FBQyxDQUFDLENBQUM7UUFFMUksZ0JBQWdCO1FBQ2hCLElBQUksS0FBSyxHQUFHLElBQUksQ0FBQyxLQUFLLENBQUMsV0FBVyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxNQUFNLEVBQUUsV0FBVyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxNQUFNLENBQUMsR0FBRyxDQUFDLEdBQUcsR0FBRyxJQUFJLENBQUMsRUFBRSxDQUFDLENBQUM7UUFFL0YsT0FBTztRQUNQLE9BQU8sQ0FBQyxHQUFHLENBQUMsV0FBVyxFQUFFLFFBQVEsQ0FBQyxDQUFDO1FBQ25DLE9BQU8sQ0FBQyxHQUFHLENBQUMsUUFBUSxFQUFFLEVBQUUsQ0FBQyxFQUFFLENBQUMsTUFBTSxFQUFFLE1BQU0sRUFBRSxNQUFNLENBQUMsQ0FBQyxDQUFDO1FBQ3JELE9BQU8sQ0FBQyxHQUFHLENBQUMsUUFBUSxFQUFFLEtBQUssQ0FBQyxDQUFDO0lBQ2pDLENBQUM7SUFFRCxnQ0FBYSxHQUFiLFVBQWMsTUFBZTtRQUN6QixPQUFPO1FBQ1AsSUFBSSxRQUFRLEdBQUcsRUFBRSxDQUFDLEVBQUUsQ0FBQyxNQUFNLENBQUMsQ0FBQyxDQUFDLEVBQUUsQ0FBQyxFQUFFLE1BQU0sQ0FBQyxDQUFDLENBQUMsRUFBRSxDQUFDLEVBQUUsTUFBTSxDQUFDLENBQUMsQ0FBQyxFQUFFLENBQUMsQ0FBQyxDQUFDO1FBRS9ELE9BQU87UUFDUCxJQUFJLE1BQU0sR0FBRyxJQUFJLENBQUMsSUFBSSxDQUFDLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUM7UUFDMUcsSUFBSSxNQUFNLEdBQUcsSUFBSSxDQUFDLElBQUksQ0FBQyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDO1FBQzFHLElBQUksTUFBTSxHQUFHLElBQUksQ0FBQyxJQUFJLENBQUMsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxNQUFNLENBQUMsQ0FBQyxDQUFDLEVBQUUsQ0FBQyxHQUFHLE1BQU0sQ0FBQyxDQUFDLENBQUMsRUFBRSxDQUFDLENBQUMsQ0FBQztRQUU1RyxnQkFBZ0I7UUFDaEIsSUFBSSxLQUFLLEdBQUcsSUFBSSxDQUFDLEtBQUssQ0FBQyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLE1BQU0sRUFBRSxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLE1BQU0sQ0FBQyxHQUFHLENBQUMsR0FBRyxHQUFHLElBQUksQ0FBQyxFQUFFLENBQUMsQ0FBQztRQUVyRixPQUFPO1FBQ1AsT0FBTyxDQUFDLEdBQUcsQ0FBQyxXQUFXLEVBQUUsUUFBUSxDQUFDLENBQUM7UUFDbkMsT0FBTyxDQUFDLEdBQUcsQ0FBQyxRQUFRLEVBQUUsRUFBRSxDQUFDLEVBQUUsQ0FBQyxNQUFNLEVBQUUsTUFBTSxFQUFFLE1BQU0sQ0FBQyxDQUFDLENBQUM7UUFDckQsT0FBTyxDQUFDLEdBQUcsQ0FBQyxRQUFRLEVBQUUsS0FBSyxDQUFDLENBQUM7SUFDakMsQ0FBQztJQUVELDRCQUFTLEdBQVQ7UUFDSSxFQUFFLENBQUMsUUFBUSxDQUFDLEdBQUcsQ0FBQyxFQUFFLENBQUMsUUFBUSxDQUFDLGlCQUFpQixFQUFFLElBQUksQ0FBQyxZQUFZLEVBQUUsSUFBSSxDQUFDLENBQUM7SUFDNUUsQ0FBQztJQUdELCtCQUFZLEdBQVo7UUFDSSxJQUFJLENBQUMsVUFBVSxDQUFDLElBQUksQ0FBQyxNQUFNLENBQUMsQ0FBQztRQUM3QixJQUFJLENBQUMsVUFBVSxDQUFDLElBQUksQ0FBQyxZQUFZLENBQUMsQ0FBQztJQUN2QyxDQUFDO0lBRUQsNkJBQVUsR0FBVixVQUFXLElBQWE7UUFDcEIsWUFBWTtRQUNaLElBQUksY0FBYyxHQUFHLElBQUksQ0FBQyxjQUFjLENBQUM7UUFDekMsSUFBSSxjQUFjLEVBQUU7WUFDaEIsT0FBTyxDQUFDLEdBQUcsQ0FBQyxJQUFJLENBQUMsSUFBSSxFQUFFLGNBQWMsQ0FBQyxDQUFDO1NBQzFDO1FBQ0QsWUFBWTtRQUNaLElBQUksY0FBYyxHQUFHLElBQUksQ0FBQyxjQUFjLENBQUM7UUFDekMsSUFBSSxjQUFjLEVBQUU7WUFDaEIsT0FBTyxDQUFDLEdBQUcsQ0FBQyxJQUFJLENBQUMsSUFBSSxFQUFFLGNBQWMsQ0FBQyxDQUFDO1NBQzFDO1FBQ0QsWUFBWTtRQUNaLElBQUksV0FBVyxHQUFHLElBQUksQ0FBQyxXQUFXLENBQUM7UUFDbkMsSUFBSSxXQUFXLEVBQUU7WUFDYixPQUFPLENBQUMsR0FBRyxDQUFDLElBQUksQ0FBQyxJQUFJLEVBQUUsV0FBVyxDQUFDLENBQUM7U0FDdkM7SUFDTCxDQUFDO0lBbklEO1FBREMsUUFBUSxDQUFDLEVBQUUsQ0FBQyxJQUFJLENBQUM7NENBQ0s7SUFHdkI7UUFEQyxRQUFRLENBQUMsRUFBRSxDQUFDLElBQUksQ0FBQztrREFDVztJQUc3QjtRQURDLFFBQVEsQ0FBQyxFQUFFLENBQUMsSUFBSSxDQUFDOytDQUNRO0lBRzFCO1FBREMsUUFBUSxDQUFDLEVBQUUsQ0FBQyxJQUFJLENBQUM7cURBQ2M7SUFaZixRQUFRO1FBRDVCLE9BQU87T0FDYSxRQUFRLENBeUk1QjtJQUFELGVBQUM7Q0F6SUQsQUF5SUMsQ0F6SXFDLEVBQUUsQ0FBQyxTQUFTLEdBeUlqRDtrQkF6SW9CLFFBQVEiLCJmaWxlIjoiIiwic291cmNlUm9vdCI6Ii8iLCJzb3VyY2VzQ29udGVudCI6WyIvLyBMZWFybiBUeXBlU2NyaXB0OlxyXG4vLyAgLSBodHRwczovL2RvY3MuY29jb3MuY29tL2NyZWF0b3IvbWFudWFsL2VuL3NjcmlwdGluZy90eXBlc2NyaXB0Lmh0bWxcclxuLy8gTGVhcm4gQXR0cmlidXRlOlxyXG4vLyAgLSBodHRwczovL2RvY3MuY29jb3MuY29tL2NyZWF0b3IvbWFudWFsL2VuL3NjcmlwdGluZy9yZWZlcmVuY2UvYXR0cmlidXRlcy5odG1sXHJcbi8vIExlYXJuIGxpZmUtY3ljbGUgY2FsbGJhY2tzOlxyXG4vLyAgLSBodHRwczovL2RvY3MuY29jb3MuY29tL2NyZWF0b3IvbWFudWFsL2VuL3NjcmlwdGluZy9saWZlLWN5Y2xlLWNhbGxiYWNrcy5odG1sXHJcblxyXG5jb25zdCB7IGNjY2xhc3MsIHByb3BlcnR5IH0gPSBjYy5fZGVjb3JhdG9yO1xyXG5cclxuQGNjY2xhc3NcclxuZXhwb3J0IGRlZmF1bHQgY2xhc3MgTmV3Q2xhc3MgZXh0ZW5kcyBjYy5Db21wb25lbnQge1xyXG5cclxuICAgIEBwcm9wZXJ0eShjYy5Ob2RlKVxyXG4gICAgdGFyZ2V0OiBjYy5Ob2RlID0gbnVsbDtcclxuXHJcbiAgICBAcHJvcGVydHkoY2MuTm9kZSlcclxuICAgIHRhcmdldFBhcmVudDogY2MuTm9kZSA9IG51bGw7XHJcblxyXG4gICAgQHByb3BlcnR5KGNjLk5vZGUpXHJcbiAgICBzcmNUYXJnZXQ6IGNjLk5vZGUgPSBudWxsO1xyXG5cclxuICAgIEBwcm9wZXJ0eShjYy5Ob2RlKVxyXG4gICAgc3JjVGFyZ2V0UGFyZW50OiBjYy5Ob2RlID0gbnVsbDtcclxuICAgIC8vIExJRkUtQ1lDTEUgQ0FMTEJBQ0tTOlxyXG5cclxuICAgIG9uTG9hZCgpIHtcclxuICAgICAgICAvLyBjYy5kaXJlY3Rvci5vbihjYy5EaXJlY3Rvci5FVkVOVF9CRUZPUkVfRFJBVywgdGhpcy5vbkJlZm9yZURyYXcsIHRoaXMpO1xyXG4gICAgfVxyXG5cclxuICAgIHN0YXJ0KCkge1xyXG4gICAgICAgIC8vIHRoaXMuc2NoZWR1bGVPbmNlKCgpID0+IHtcclxuICAgICAgICAvLyAgICAgdGhpcy50YXJnZXQueCA9IDEwMDtcclxuICAgICAgICAvLyAgICAgdGhpcy50YXJnZXQuc2NhbGVYID0gMjtcclxuICAgICAgICAvLyB9LCAzKTtcclxuXHJcbiAgICAgICAgLy8gdGhpcy5zY2hlZHVsZU9uY2UoKCkgPT4ge1xyXG4gICAgICAgIC8vICAgICB0aGlzLnRhcmdldFBhcmVudC54ID0gMTA7XHJcbiAgICAgICAgLy8gICAgIHRoaXMudGFyZ2V0LnNjYWxlWCA9IDEuMTtcclxuICAgICAgICAvLyB9LCAxKTtcclxuICAgICAgICBsZXQgdGFyZ2V0Tm9kZSA9IHRoaXMudGFyZ2V0OyAvLyDpnIDopoHojrflj5bkuJbnlYznn6npmLXnmoToioLngrlcclxuICAgICAgICBsZXQgcGFyZW50Tm9kZSA9IHRoaXMudGFyZ2V0UGFyZW50OyAvLyDopoHovazmjaLliLDnmoToioLngrlcclxuXHJcbiAgICAgICAgbGV0IGxvY2FsTWF0cml4ID0gY2MubWF0NCgpO1xyXG4gICAgICAgIHRhcmdldE5vZGUuZ2V0TG9jYWxNYXRyaXgobG9jYWxNYXRyaXgpO1xyXG4gICAgICAgIHRoaXMuZ2V0TWF0cml4SW5mbyhsb2NhbE1hdHJpeCk7XHJcblxyXG4gICAgICAgIC8vIOiOt+WPluebruagh+iKgueCueeahOS4lueVjOefqemYtVxyXG4gICAgICAgIGxldCB3b3JsZE1hdHJpeCA9IGNjLm1hdDQoKTtcclxuICAgICAgICB0YXJnZXROb2RlLmdldFdvcmxkTWF0cml4KHdvcmxkTWF0cml4KVxyXG4gICAgICAgIC8vIOiOt+WPlueItuiKgueCueeahOS4lueVjOefqemYtVxyXG4gICAgICAgIGxldCBwYXJlbnRXb3JsZE1hdHJpeCA9IGNjLm1hdDQoKTtcclxuICAgICAgICBwYXJlbnROb2RlLmdldFdvcmxkTWF0cml4KHBhcmVudFdvcmxkTWF0cml4KTtcclxuXHJcbiAgICAgICAgLy8g6I635Y+W54i26IqC54K555qE6YCG55+p6Zi1XHJcbiAgICAgICAgbGV0IHBhcmVudEludmVyc2VNYXRyaXggPSBwYXJlbnRXb3JsZE1hdHJpeC5pbnZlcnQoKTtcclxuXHJcbiAgICAgICAgLy8g5bCG55uu5qCH6IqC54K555qE5LiW55WM55+p6Zi16L2s5o2i5Li654i26IqC54K555qE5pys5Zyw55+p6Zi1XHJcbiAgICAgICAgbGV0IGxvY2FsTWF0cml4MiA9IHBhcmVudEludmVyc2VNYXRyaXgubXVsdGlwbHkod29ybGRNYXRyaXgpO1xyXG5cclxuICAgICAgICB0aGlzLmdldE1hdHJpeEluZm8obG9jYWxNYXRyaXgyKTtcclxuXHJcbiAgICB9XHJcblxyXG4gICAgbWF0cml4VHJhbnNmb3JtKCkge1xyXG4gICAgICAgIC8vIOWBh+iuvuaIkeS7rOacieS4gOS4quebruagh+iKgueCueWSjOS4gOS4queItuiKgueCuVxyXG4gICAgICAgIGxldCB0YXJnZXROb2RlID0gdGhpcy50YXJnZXQ7IC8vIOmcgOimgeiOt+WPluS4lueVjOefqemYteeahOiKgueCuVxyXG4gICAgICAgIGxldCBwYXJlbnROb2RlID0gdGhpcy5zcmNUYXJnZXRQYXJlbnQ7IC8vIOimgei9rOaNouWIsOeahOiKgueCuVxyXG5cclxuICAgICAgICAvLyDojrflj5bnm67moIfoioLngrnnmoTkuJbnlYznn6npmLVcclxuICAgICAgICBsZXQgd29ybGRNYXRyaXggPSBjYy5tYXQ0KCk7XHJcbiAgICAgICAgdGFyZ2V0Tm9kZS5nZXRXb3JsZE1hdHJpeCh3b3JsZE1hdHJpeClcclxuXHJcbiAgICAgICAgLy8g6I635Y+W54i26IqC54K555qE5LiW55WM55+p6Zi1XHJcbiAgICAgICAgbGV0IHBhcmVudFdvcmxkTWF0cml4ID0gY2MubWF0NCgpO1xyXG4gICAgICAgIHBhcmVudE5vZGUuZ2V0V29ybGRNYXRyaXgocGFyZW50V29ybGRNYXRyaXgpXHJcblxyXG4gICAgICAgIC8vIOiOt+WPlueItuiKgueCueeahOmAhuefqemYtVxyXG4gICAgICAgIGxldCBwYXJlbnRJbnZlcnNlTWF0cml4ID0gcGFyZW50V29ybGRNYXRyaXguaW52ZXJ0KCk7XHJcblxyXG4gICAgICAgIC8vIOWwhuebruagh+iKgueCueeahOS4lueVjOefqemYtei9rOaNouS4uueItuiKgueCueeahOacrOWcsOefqemYtVxyXG4gICAgICAgIGxldCBsb2NhbE1hdHJpeCA9IHBhcmVudEludmVyc2VNYXRyaXgubXVsdGlwbHkod29ybGRNYXRyaXgpO1xyXG5cclxuXHJcbiAgICAgICAgLy8g5o+Q5Y+W5L2N572uXHJcbiAgICAgICAgbGV0IHBvc2l0aW9uID0gY2MudjMod29ybGRNYXRyaXgubVsxMl0sIHdvcmxkTWF0cml4Lm1bMTNdLCB3b3JsZE1hdHJpeC5tWzE0XSk7XHJcblxyXG4gICAgICAgIC8vIOaPkOWPlue8qeaUvlxyXG4gICAgICAgIGxldCBzY2FsZVggPSBNYXRoLnNxcnQod29ybGRNYXRyaXgubVswXSAqIHdvcmxkTWF0cml4Lm1bMF0gKyB3b3JsZE1hdHJpeC5tWzFdICogd29ybGRNYXRyaXgubVsxXSArIHdvcmxkTWF0cml4Lm1bMl0gKiB3b3JsZE1hdHJpeC5tWzJdKTtcclxuICAgICAgICBsZXQgc2NhbGVZID0gTWF0aC5zcXJ0KHdvcmxkTWF0cml4Lm1bNF0gKiB3b3JsZE1hdHJpeC5tWzRdICsgd29ybGRNYXRyaXgubVs1XSAqIHdvcmxkTWF0cml4Lm1bNV0gKyB3b3JsZE1hdHJpeC5tWzZdICogd29ybGRNYXRyaXgubVs2XSk7XHJcbiAgICAgICAgbGV0IHNjYWxlWiA9IE1hdGguc3FydCh3b3JsZE1hdHJpeC5tWzhdICogd29ybGRNYXRyaXgubVs4XSArIHdvcmxkTWF0cml4Lm1bOV0gKiB3b3JsZE1hdHJpeC5tWzldICsgd29ybGRNYXRyaXgubVsxMF0gKiB3b3JsZE1hdHJpeC5tWzEwXSk7XHJcblxyXG4gICAgICAgIC8vIOaPkOWPluaXi+i9rO+8iOWBh+iuvuaYr+S6jOe7tOaXi+i9rO+8iVxyXG4gICAgICAgIGxldCBhbmdsZSA9IE1hdGguYXRhbjIod29ybGRNYXRyaXgubVsxXSAvIHNjYWxlWCwgd29ybGRNYXRyaXgubVswXSAvIHNjYWxlWCkgKiAoMTgwIC8gTWF0aC5QSSk7XHJcblxyXG4gICAgICAgIC8vIOi+k+WHuue7k+aenFxyXG4gICAgICAgIGNvbnNvbGUubG9nKFwiUG9zaXRpb246XCIsIHBvc2l0aW9uKTtcclxuICAgICAgICBjb25zb2xlLmxvZyhcIlNjYWxlOlwiLCBjYy52MyhzY2FsZVgsIHNjYWxlWSwgc2NhbGVaKSk7XHJcbiAgICAgICAgY29uc29sZS5sb2coXCJBbmdsZTpcIiwgYW5nbGUpO1xyXG4gICAgfVxyXG5cclxuICAgIGdldE1hdHJpeEluZm8obWF0cml4OiBjYy5NYXQ0KSB7XHJcbiAgICAgICAgLy8g5o+Q5Y+W5L2N572uXHJcbiAgICAgICAgbGV0IHBvc2l0aW9uID0gY2MudjMobWF0cml4Lm1bMTJdLCBtYXRyaXgubVsxM10sIG1hdHJpeC5tWzE0XSk7XHJcblxyXG4gICAgICAgIC8vIOaPkOWPlue8qeaUvlxyXG4gICAgICAgIGxldCBzY2FsZVggPSBNYXRoLnNxcnQobWF0cml4Lm1bMF0gKiBtYXRyaXgubVswXSArIG1hdHJpeC5tWzFdICogbWF0cml4Lm1bMV0gKyBtYXRyaXgubVsyXSAqIG1hdHJpeC5tWzJdKTtcclxuICAgICAgICBsZXQgc2NhbGVZID0gTWF0aC5zcXJ0KG1hdHJpeC5tWzRdICogbWF0cml4Lm1bNF0gKyBtYXRyaXgubVs1XSAqIG1hdHJpeC5tWzVdICsgbWF0cml4Lm1bNl0gKiBtYXRyaXgubVs2XSk7XHJcbiAgICAgICAgbGV0IHNjYWxlWiA9IE1hdGguc3FydChtYXRyaXgubVs4XSAqIG1hdHJpeC5tWzhdICsgbWF0cml4Lm1bOV0gKiBtYXRyaXgubVs5XSArIG1hdHJpeC5tWzEwXSAqIG1hdHJpeC5tWzEwXSk7XHJcblxyXG4gICAgICAgIC8vIOaPkOWPluaXi+i9rO+8iOWBh+iuvuaYr+S6jOe7tOaXi+i9rO+8iVxyXG4gICAgICAgIGxldCBhbmdsZSA9IE1hdGguYXRhbjIobWF0cml4Lm1bMV0gLyBzY2FsZVgsIG1hdHJpeC5tWzBdIC8gc2NhbGVYKSAqICgxODAgLyBNYXRoLlBJKTtcclxuXHJcbiAgICAgICAgLy8g6L6T5Ye657uT5p6cXHJcbiAgICAgICAgY29uc29sZS5sb2coXCJQb3NpdGlvbjpcIiwgcG9zaXRpb24pO1xyXG4gICAgICAgIGNvbnNvbGUubG9nKFwiU2NhbGU6XCIsIGNjLnYzKHNjYWxlWCwgc2NhbGVZLCBzY2FsZVopKTtcclxuICAgICAgICBjb25zb2xlLmxvZyhcIkFuZ2xlOlwiLCBhbmdsZSk7XHJcbiAgICB9XHJcblxyXG4gICAgb25EZXN0cm95KCk6IHZvaWQge1xyXG4gICAgICAgIGNjLmRpcmVjdG9yLm9mZihjYy5EaXJlY3Rvci5FVkVOVF9CRUZPUkVfRFJBVywgdGhpcy5vbkJlZm9yZURyYXcsIHRoaXMpO1xyXG4gICAgfVxyXG5cclxuXHJcbiAgICBvbkJlZm9yZURyYXcoKSB7XHJcbiAgICAgICAgdGhpcy5jaGVja0RpcnR5KHRoaXMudGFyZ2V0KTtcclxuICAgICAgICB0aGlzLmNoZWNrRGlydHkodGhpcy50YXJnZXRQYXJlbnQpO1xyXG4gICAgfVxyXG5cclxuICAgIGNoZWNrRGlydHkobm9kZTogY2MuTm9kZSkge1xyXG4gICAgICAgIC8vQHRzLWlnbm9yZVxyXG4gICAgICAgIGxldCBfbG9jYWxNYXREaXJ0eSA9IG5vZGUuX2xvY2FsTWF0RGlydHk7XHJcbiAgICAgICAgaWYgKF9sb2NhbE1hdERpcnR5KSB7XHJcbiAgICAgICAgICAgIGNvbnNvbGUubG9nKG5vZGUubmFtZSwgX2xvY2FsTWF0RGlydHkpO1xyXG4gICAgICAgIH1cclxuICAgICAgICAvL0B0cy1pZ25vcmVcclxuICAgICAgICBsZXQgX3dvcmxkTWF0RGlydHkgPSBub2RlLl93b3JsZE1hdERpcnR5O1xyXG4gICAgICAgIGlmIChfd29ybGRNYXREaXJ0eSkge1xyXG4gICAgICAgICAgICBjb25zb2xlLmxvZyhub2RlLm5hbWUsIF93b3JsZE1hdERpcnR5KTtcclxuICAgICAgICB9XHJcbiAgICAgICAgLy9AdHMtaWdub3JlXHJcbiAgICAgICAgbGV0IF9yZW5kZXJGbGFnID0gbm9kZS5fcmVuZGVyRmxhZztcclxuICAgICAgICBpZiAoX3JlbmRlckZsYWcpIHtcclxuICAgICAgICAgICAgY29uc29sZS5sb2cobm9kZS5uYW1lLCBfcmVuZGVyRmxhZyk7XHJcbiAgICAgICAgfVxyXG4gICAgfVxyXG5cclxuICAgIC8vIHVwZGF0ZSAoZHQpIHt9XHJcbn1cclxuIl19 \ No newline at end of file diff --git a/Layered_virtual_list_2.x/temp/quick-scripts/dst/assets/Scene/TestRenderAlternative.js b/Layered_virtual_list_2.x/temp/quick-scripts/dst/assets/Scene/TestRenderAlternative.js new file mode 100644 index 0000000..cf305bd --- /dev/null +++ b/Layered_virtual_list_2.x/temp/quick-scripts/dst/assets/Scene/TestRenderAlternative.js @@ -0,0 +1,95 @@ + + (function() { + var nodeEnv = typeof require !== 'undefined' && typeof process !== 'undefined'; + var __module = nodeEnv ? module : {exports:{}}; + var __filename = 'preview-scripts/assets/Scene/TestRenderAlternative.js'; + var __require = nodeEnv ? function (request) { + return cc.require(request); + } : function (request) { + return __quick_compile_project__.require(request, __filename); + }; + function __define (exports, require, module) { + if (!nodeEnv) {__quick_compile_project__.registerModule(__filename, module);}"use strict"; +cc._RF.push(module, 'b9be0tgoIVPk72LiE6N39f/', 'TestRenderAlternative'); +// Scene/TestRenderAlternative.ts + +"use strict"; +// Learn TypeScript: +// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html +// Learn Attribute: +// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html +// Learn life-cycle callbacks: +// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property; +var TestRenderAlternative = /** @class */ (function (_super) { + __extends(TestRenderAlternative, _super); + function TestRenderAlternative() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.scrollView = null; + _this.prefab = null; + _this.layer = null; + return _this; + // update (dt) {} + } + // onLoad () {} + TestRenderAlternative.prototype.start = function () { + var count = 1000; + var datas = []; + for (var i = 0; i < count; i++) { + var data = { name: 'name' + i, index: i }; + datas.push({ data: data, layer: this.layer }); + } + for (var i = 0; i < datas.length; i++) { + var item = cc.instantiate(this.prefab); + this.scrollView.content.addChild(item); + item.getComponent('Item').init(datas[i]); + } + }; + __decorate([ + property(cc.ScrollView) + ], TestRenderAlternative.prototype, "scrollView", void 0); + __decorate([ + property(cc.Prefab) + ], TestRenderAlternative.prototype, "prefab", void 0); + __decorate([ + property(cc.Node) + ], TestRenderAlternative.prototype, "layer", void 0); + TestRenderAlternative = __decorate([ + ccclass + ], TestRenderAlternative); + return TestRenderAlternative; +}(cc.Component)); +exports.default = TestRenderAlternative; + +cc._RF.pop(); + } + if (nodeEnv) { + __define(__module.exports, __require, __module); + } + else { + __quick_compile_project__.registerModuleFunc(__filename, function () { + __define(__module.exports, __require, __module); + }); + } + })(); +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImFzc2V0c1xcU2NlbmVcXFRlc3RSZW5kZXJBbHRlcm5hdGl2ZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7O0FBQUEsb0JBQW9CO0FBQ3BCLHdFQUF3RTtBQUN4RSxtQkFBbUI7QUFDbkIsa0ZBQWtGO0FBQ2xGLDhCQUE4QjtBQUM5QixrRkFBa0Y7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OztBQUU1RSxJQUFBLEtBQXdCLEVBQUUsQ0FBQyxVQUFVLEVBQW5DLE9BQU8sYUFBQSxFQUFFLFFBQVEsY0FBa0IsQ0FBQztBQUc1QztJQUFtRCx5Q0FBWTtJQUEvRDtRQUFBLHFFQTZCQztRQTFCRyxnQkFBVSxHQUFrQixJQUFJLENBQUM7UUFHakMsWUFBTSxHQUFjLElBQUksQ0FBQztRQUd6QixXQUFLLEdBQVksSUFBSSxDQUFDOztRQW1CdEIsaUJBQWlCO0lBQ3JCLENBQUM7SUFsQkcsZUFBZTtJQUVmLHFDQUFLLEdBQUw7UUFDSSxJQUFJLEtBQUssR0FBRyxJQUFJLENBQUM7UUFDakIsSUFBSSxLQUFLLEdBQUcsRUFBRSxDQUFDO1FBQ2YsS0FBSyxJQUFJLENBQUMsR0FBRyxDQUFDLEVBQUUsQ0FBQyxHQUFHLEtBQUssRUFBRSxDQUFDLEVBQUUsRUFBRTtZQUM1QixJQUFJLElBQUksR0FBRyxFQUFFLElBQUksRUFBRSxNQUFNLEdBQUcsQ0FBQyxFQUFFLEtBQUssRUFBRSxDQUFDLEVBQUUsQ0FBQztZQUMxQyxLQUFLLENBQUMsSUFBSSxDQUFDLEVBQUUsSUFBSSxFQUFFLElBQUksRUFBRSxLQUFLLEVBQUUsSUFBSSxDQUFDLEtBQUssRUFBRSxDQUFDLENBQUM7U0FDakQ7UUFFRCxLQUFLLElBQUksQ0FBQyxHQUFHLENBQUMsRUFBRSxDQUFDLEdBQUcsS0FBSyxDQUFDLE1BQU0sRUFBRSxDQUFDLEVBQUUsRUFBRTtZQUNuQyxJQUFJLElBQUksR0FBRyxFQUFFLENBQUMsV0FBVyxDQUFDLElBQUksQ0FBQyxNQUFNLENBQUMsQ0FBQztZQUN2QyxJQUFJLENBQUMsVUFBVSxDQUFDLE9BQU8sQ0FBQyxRQUFRLENBQUMsSUFBSSxDQUFDLENBQUM7WUFDdkMsSUFBSSxDQUFDLFlBQVksQ0FBQyxNQUFNLENBQUMsQ0FBQyxJQUFJLENBQUMsS0FBSyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUM7U0FDNUM7SUFDTCxDQUFDO0lBdkJEO1FBREMsUUFBUSxDQUFDLEVBQUUsQ0FBQyxVQUFVLENBQUM7NkRBQ1M7SUFHakM7UUFEQyxRQUFRLENBQUMsRUFBRSxDQUFDLE1BQU0sQ0FBQzt5REFDSztJQUd6QjtRQURDLFFBQVEsQ0FBQyxFQUFFLENBQUMsSUFBSSxDQUFDO3dEQUNJO0lBVEwscUJBQXFCO1FBRHpDLE9BQU87T0FDYSxxQkFBcUIsQ0E2QnpDO0lBQUQsNEJBQUM7Q0E3QkQsQUE2QkMsQ0E3QmtELEVBQUUsQ0FBQyxTQUFTLEdBNkI5RDtrQkE3Qm9CLHFCQUFxQiIsImZpbGUiOiIiLCJzb3VyY2VSb290IjoiLyIsInNvdXJjZXNDb250ZW50IjpbIi8vIExlYXJuIFR5cGVTY3JpcHQ6XHJcbi8vICAtIGh0dHBzOi8vZG9jcy5jb2Nvcy5jb20vY3JlYXRvci9tYW51YWwvZW4vc2NyaXB0aW5nL3R5cGVzY3JpcHQuaHRtbFxyXG4vLyBMZWFybiBBdHRyaWJ1dGU6XHJcbi8vICAtIGh0dHBzOi8vZG9jcy5jb2Nvcy5jb20vY3JlYXRvci9tYW51YWwvZW4vc2NyaXB0aW5nL3JlZmVyZW5jZS9hdHRyaWJ1dGVzLmh0bWxcclxuLy8gTGVhcm4gbGlmZS1jeWNsZSBjYWxsYmFja3M6XHJcbi8vICAtIGh0dHBzOi8vZG9jcy5jb2Nvcy5jb20vY3JlYXRvci9tYW51YWwvZW4vc2NyaXB0aW5nL2xpZmUtY3ljbGUtY2FsbGJhY2tzLmh0bWxcclxuXHJcbmNvbnN0IHsgY2NjbGFzcywgcHJvcGVydHkgfSA9IGNjLl9kZWNvcmF0b3I7XHJcblxyXG5AY2NjbGFzc1xyXG5leHBvcnQgZGVmYXVsdCBjbGFzcyBUZXN0UmVuZGVyQWx0ZXJuYXRpdmUgZXh0ZW5kcyBjYy5Db21wb25lbnQge1xyXG5cclxuICAgIEBwcm9wZXJ0eShjYy5TY3JvbGxWaWV3KVxyXG4gICAgc2Nyb2xsVmlldzogY2MuU2Nyb2xsVmlldyA9IG51bGw7XHJcblxyXG4gICAgQHByb3BlcnR5KGNjLlByZWZhYilcclxuICAgIHByZWZhYjogY2MuUHJlZmFiID0gbnVsbDtcclxuXHJcbiAgICBAcHJvcGVydHkoY2MuTm9kZSlcclxuICAgIGxheWVyOiBjYy5Ob2RlID0gbnVsbDtcclxuXHJcbiAgICAvLyBvbkxvYWQgKCkge31cclxuXHJcbiAgICBzdGFydCgpIHtcclxuICAgICAgICBsZXQgY291bnQgPSAxMDAwO1xyXG4gICAgICAgIGxldCBkYXRhcyA9IFtdO1xyXG4gICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgY291bnQ7IGkrKykge1xyXG4gICAgICAgICAgICBsZXQgZGF0YSA9IHsgbmFtZTogJ25hbWUnICsgaSwgaW5kZXg6IGkgfTtcclxuICAgICAgICAgICAgZGF0YXMucHVzaCh7IGRhdGE6IGRhdGEsIGxheWVyOiB0aGlzLmxheWVyIH0pO1xyXG4gICAgICAgIH1cclxuXHJcbiAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBkYXRhcy5sZW5ndGg7IGkrKykge1xyXG4gICAgICAgICAgICBsZXQgaXRlbSA9IGNjLmluc3RhbnRpYXRlKHRoaXMucHJlZmFiKTtcclxuICAgICAgICAgICAgdGhpcy5zY3JvbGxWaWV3LmNvbnRlbnQuYWRkQ2hpbGQoaXRlbSk7XHJcbiAgICAgICAgICAgIGl0ZW0uZ2V0Q29tcG9uZW50KCdJdGVtJykuaW5pdChkYXRhc1tpXSk7XHJcbiAgICAgICAgfVxyXG4gICAgfVxyXG5cclxuICAgIC8vIHVwZGF0ZSAoZHQpIHt9XHJcbn1cclxuIl19 \ No newline at end of file diff --git a/Layered_virtual_list_2.x/temp/quick-scripts/dst/assets/Scene/TestShowNode.js b/Layered_virtual_list_2.x/temp/quick-scripts/dst/assets/Scene/TestShowNode.js new file mode 100644 index 0000000..99e88d1 --- /dev/null +++ b/Layered_virtual_list_2.x/temp/quick-scripts/dst/assets/Scene/TestShowNode.js @@ -0,0 +1,112 @@ + + (function() { + var nodeEnv = typeof require !== 'undefined' && typeof process !== 'undefined'; + var __module = nodeEnv ? module : {exports:{}}; + var __filename = 'preview-scripts/assets/Scene/TestShowNode.js'; + var __require = nodeEnv ? function (request) { + return cc.require(request); + } : function (request) { + return __quick_compile_project__.require(request, __filename); + }; + function __define (exports, require, module) { + if (!nodeEnv) {__quick_compile_project__.registerModule(__filename, module);}"use strict"; +cc._RF.push(module, '9e178M6rUlI5qgi1+HcLO30', 'TestShowNode'); +// Scene/TestShowNode.ts + +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.TestShowNode = void 0; +var LoopList_1 = require("../Script/LoopList"); +var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property; +var TestShowNode = /** @class */ (function (_super) { + __extends(TestShowNode, _super); + function TestShowNode() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /** */ + _this.nameLb = null; + /** */ + _this.contentLb = null; + /** */ + _this.Button = null; + /** */ + _this.ButtonLb = null; + return _this; + } + /** + * 初始化显示 + * @param data + */ + TestShowNode.prototype.initShow = function () { + this.node.width = this.data.size.width; + this.node.height = this.data.size.height; + this.nameLb.string = "我是第" + this.data.index + "个"; + this.contentLb.string = "我是内容" + this.data.text; + //这个是改变控件大小的事例 + if (this.data.index == 5 || this.data.index == 11) { + //this.changeSize(cell); + } + }; + /** + * 改变大小 + * @param cell + */ + TestShowNode.prototype.changeSize = function (cell) { + var _this = this; + this.resize(cc.size(cell.size.width, 100 + (Math.random() * 400))); + this.scheduleOnce(function () { + _this.changeSize(cell); + }, 3 + Math.random() * 3); + }; + TestShowNode.prototype.onRecircle = function () { + //做释放操作 + }; + __decorate([ + property(cc.Label) + ], TestShowNode.prototype, "nameLb", void 0); + __decorate([ + property(cc.Label) + ], TestShowNode.prototype, "contentLb", void 0); + __decorate([ + property(cc.Node) + ], TestShowNode.prototype, "Button", void 0); + __decorate([ + property(cc.Label) + ], TestShowNode.prototype, "ButtonLb", void 0); + TestShowNode = __decorate([ + ccclass + ], TestShowNode); + return TestShowNode; +}(LoopList_1.ShowNode)); +exports.TestShowNode = TestShowNode; + +cc._RF.pop(); + } + if (nodeEnv) { + __define(__module.exports, __require, __module); + } + else { + __quick_compile_project__.registerModuleFunc(__filename, function () { + __define(__module.exports, __require, __module); + }); + } + })(); +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImFzc2V0c1xcU2NlbmVcXFRlc3RTaG93Tm9kZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0FBQUEsK0NBQXdEO0FBRWxELElBQUEsS0FBd0IsRUFBRSxDQUFDLFVBQVUsRUFBbkMsT0FBTyxhQUFBLEVBQUUsUUFBUSxjQUFrQixDQUFDO0FBUTVDO0lBQWtDLGdDQUFlO0lBQWpEO1FBQUEscUVBMkNDO1FBMUNHLE1BQU07UUFFQyxZQUFNLEdBQWEsSUFBSSxDQUFDO1FBQy9CLE1BQU07UUFFQyxlQUFTLEdBQWEsSUFBSSxDQUFDO1FBQ2xDLE1BQU07UUFFQyxZQUFNLEdBQVksSUFBSSxDQUFDO1FBQzlCLE1BQU07UUFFQyxjQUFRLEdBQWEsSUFBSSxDQUFDOztJQStCckMsQ0FBQztJQTdCRzs7O09BR0c7SUFDSCwrQkFBUSxHQUFSO1FBQ0ksSUFBSSxDQUFDLElBQUksQ0FBQyxLQUFLLEdBQUcsSUFBSSxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsS0FBSyxDQUFDO1FBQ3ZDLElBQUksQ0FBQyxJQUFJLENBQUMsTUFBTSxHQUFHLElBQUksQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLE1BQU0sQ0FBQztRQUN6QyxJQUFJLENBQUMsTUFBTSxDQUFDLE1BQU0sR0FBRyxLQUFLLEdBQUcsSUFBSSxDQUFDLElBQUksQ0FBQyxLQUFLLEdBQUcsR0FBRyxDQUFDO1FBQ25ELElBQUksQ0FBQyxTQUFTLENBQUMsTUFBTSxHQUFHLE1BQU0sR0FBRyxJQUFJLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQztRQUNoRCxjQUFjO1FBQ2QsSUFBSSxJQUFJLENBQUMsSUFBSSxDQUFDLEtBQUssSUFBSSxDQUFDLElBQUksSUFBSSxDQUFDLElBQUksQ0FBQyxLQUFLLElBQUksRUFBRSxFQUFFO1lBQy9DLHdCQUF3QjtTQUMzQjtJQUNMLENBQUM7SUFFRDs7O09BR0c7SUFDSCxpQ0FBVSxHQUFWLFVBQVcsSUFBcUI7UUFBaEMsaUJBS0M7UUFKRyxJQUFJLENBQUMsTUFBTSxDQUFDLEVBQUUsQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxLQUFLLEVBQUUsR0FBRyxHQUFHLENBQUMsSUFBSSxDQUFDLE1BQU0sRUFBRSxHQUFHLEdBQUcsQ0FBQyxDQUFDLENBQUMsQ0FBQztRQUNuRSxJQUFJLENBQUMsWUFBWSxDQUFDO1lBQ2QsS0FBSSxDQUFDLFVBQVUsQ0FBQyxJQUFJLENBQUMsQ0FBQTtRQUN6QixDQUFDLEVBQUUsQ0FBQyxHQUFHLElBQUksQ0FBQyxNQUFNLEVBQUUsR0FBRyxDQUFDLENBQUMsQ0FBQTtJQUM3QixDQUFDO0lBRUQsaUNBQVUsR0FBVjtRQUNJLE9BQU87SUFDWCxDQUFDO0lBdkNEO1FBREMsUUFBUSxDQUFDLEVBQUUsQ0FBQyxLQUFLLENBQUM7Z0RBQ1k7SUFHL0I7UUFEQyxRQUFRLENBQUMsRUFBRSxDQUFDLEtBQUssQ0FBQzttREFDZTtJQUdsQztRQURDLFFBQVEsQ0FBQyxFQUFFLENBQUMsSUFBSSxDQUFDO2dEQUNZO0lBRzlCO1FBREMsUUFBUSxDQUFDLEVBQUUsQ0FBQyxLQUFLLENBQUM7a0RBQ2M7SUFaeEIsWUFBWTtRQUR4QixPQUFPO09BQ0ssWUFBWSxDQTJDeEI7SUFBRCxtQkFBQztDQTNDRCxBQTJDQyxDQTNDaUMsbUJBQVEsR0EyQ3pDO0FBM0NZLG9DQUFZIiwiZmlsZSI6IiIsInNvdXJjZVJvb3QiOiIvIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IEl0ZW1DZWxsLCB7IFNob3dOb2RlIH0gZnJvbSBcIi4uL1NjcmlwdC9Mb29wTGlzdFwiO1xyXG5pbXBvcnQgUmVuZGVyQWx0ZXJuYXRpdmUgZnJvbSBcIi4uL1NjcmlwdC9SZW5kZXJBbHRlcm5hdGl2ZVwiO1xyXG5jb25zdCB7IGNjY2xhc3MsIHByb3BlcnR5IH0gPSBjYy5fZGVjb3JhdG9yO1xyXG5leHBvcnQgaW50ZXJmYWNlIElEYXRhIHtcclxuICAgIHNpemU/OiBjYy5TaXplLFxyXG4gICAgaW5kZXg6IG51bWJlcixcclxuICAgIHRleHQ6IHN0cmluZ1xyXG59XHJcblxyXG5AY2NjbGFzc1xyXG5leHBvcnQgY2xhc3MgVGVzdFNob3dOb2RlIGV4dGVuZHMgU2hvd05vZGU8SURhdGE+IHtcclxuICAgIC8qKiAqL1xyXG4gICAgQHByb3BlcnR5KGNjLkxhYmVsKVxyXG4gICAgcHVibGljIG5hbWVMYjogY2MuTGFiZWwgPSBudWxsO1xyXG4gICAgLyoqICovXHJcbiAgICBAcHJvcGVydHkoY2MuTGFiZWwpXHJcbiAgICBwdWJsaWMgY29udGVudExiOiBjYy5MYWJlbCA9IG51bGw7XHJcbiAgICAvKiogKi9cclxuICAgIEBwcm9wZXJ0eShjYy5Ob2RlKVxyXG4gICAgcHVibGljIEJ1dHRvbjogY2MuTm9kZSA9IG51bGw7XHJcbiAgICAvKiogKi9cclxuICAgIEBwcm9wZXJ0eShjYy5MYWJlbClcclxuICAgIHB1YmxpYyBCdXR0b25MYjogY2MuTGFiZWwgPSBudWxsO1xyXG5cclxuICAgIC8qKlxyXG4gICAgICog5Yid5aeL5YyW5pi+56S6XHJcbiAgICAgKiBAcGFyYW0gZGF0YSBcclxuICAgICAqL1xyXG4gICAgaW5pdFNob3coKSB7XHJcbiAgICAgICAgdGhpcy5ub2RlLndpZHRoID0gdGhpcy5kYXRhLnNpemUud2lkdGg7XHJcbiAgICAgICAgdGhpcy5ub2RlLmhlaWdodCA9IHRoaXMuZGF0YS5zaXplLmhlaWdodDtcclxuICAgICAgICB0aGlzLm5hbWVMYi5zdHJpbmcgPSBcIuaIkeaYr+esrFwiICsgdGhpcy5kYXRhLmluZGV4ICsgXCLkuKpcIjtcclxuICAgICAgICB0aGlzLmNvbnRlbnRMYi5zdHJpbmcgPSBcIuaIkeaYr+WGheWuuVwiICsgdGhpcy5kYXRhLnRleHQ7XHJcbiAgICAgICAgLy/ov5nkuKrmmK/mlLnlj5jmjqfku7blpKflsI/nmoTkuovkvotcclxuICAgICAgICBpZiAodGhpcy5kYXRhLmluZGV4ID09IDUgfHwgdGhpcy5kYXRhLmluZGV4ID09IDExKSB7XHJcbiAgICAgICAgICAgIC8vdGhpcy5jaGFuZ2VTaXplKGNlbGwpO1xyXG4gICAgICAgIH1cclxuICAgIH1cclxuXHJcbiAgICAvKipcclxuICAgICAqIOaUueWPmOWkp+Wwj1xyXG4gICAgICogQHBhcmFtIGNlbGwgXHJcbiAgICAgKi9cclxuICAgIGNoYW5nZVNpemUoY2VsbDogSXRlbUNlbGw8SURhdGE+KSB7XHJcbiAgICAgICAgdGhpcy5yZXNpemUoY2Muc2l6ZShjZWxsLnNpemUud2lkdGgsIDEwMCArIChNYXRoLnJhbmRvbSgpICogNDAwKSkpO1xyXG4gICAgICAgIHRoaXMuc2NoZWR1bGVPbmNlKCgpID0+IHtcclxuICAgICAgICAgICAgdGhpcy5jaGFuZ2VTaXplKGNlbGwpXHJcbiAgICAgICAgfSwgMyArIE1hdGgucmFuZG9tKCkgKiAzKVxyXG4gICAgfVxyXG5cclxuICAgIG9uUmVjaXJjbGUoKSB7XHJcbiAgICAgICAgLy/lgZrph4rmlL7mk43kvZxcclxuICAgIH1cclxufVxyXG5cclxuXHJcbiJdfQ== \ No newline at end of file diff --git a/Layered_virtual_list_2.x/temp/quick-scripts/dst/assets/Script/LoopList.js b/Layered_virtual_list_2.x/temp/quick-scripts/dst/assets/Script/LoopList.js new file mode 100644 index 0000000..9019480 --- /dev/null +++ b/Layered_virtual_list_2.x/temp/quick-scripts/dst/assets/Script/LoopList.js @@ -0,0 +1,935 @@ + + (function() { + var nodeEnv = typeof require !== 'undefined' && typeof process !== 'undefined'; + var __module = nodeEnv ? module : {exports:{}}; + var __filename = 'preview-scripts/assets/Script/LoopList.js'; + var __require = nodeEnv ? function (request) { + return cc.require(request); + } : function (request) { + return __quick_compile_project__.require(request, __filename); + }; + function __define (exports, require, module) { + if (!nodeEnv) {__quick_compile_project__.registerModule(__filename, module);}"use strict"; +cc._RF.push(module, 'b4ec1SU3/dIdZG3ODfwZKk3', 'LoopList'); +// Script/LoopList.ts + +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ItemCell = exports.ShowNode = void 0; +var RenderAlternative_1 = require("./RenderAlternative"); +var ShowNode = /** @class */ (function (_super) { + __extends(ShowNode, _super); + function ShowNode() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /**是否初始化过代理组建 */ + _this.hasInit = false; + return _this; + } + /**初始化 */ + ShowNode.prototype.init = function (cell, data, renderLayer) { + this.cell = cell; + this.data = data; + if (this.renderLayer != renderLayer) { + this.renderLayer = renderLayer; + renderLayer && this.initRenders(); + } + this.initShow(); + }; + /**初始化操作 */ + ShowNode.prototype.initShow = function () { }; + /**被回收,应该做一些释放的操作 */ + ShowNode.prototype.onRecircle = function () { }; + /** + * 在特定时间内进行大小变化 + * @param targetSize + * @param time + */ + ShowNode.prototype.resize = function (targetSize, time) { + if (time === void 0) { time = 0.3; } + this.cell.resize(targetSize, time); + }; + /** + * 处理分层代理渲染 + */ + ShowNode.prototype.initRenders = function () { + if (!this.hasInit && this.renderLayer) { + var propMap = new WeakMap(); + var keys = Object.keys(this); + for (var i = 0, len = keys.length; i < len; ++i) { + var value = this[keys[i]]; + var alternative = null; + if (value instanceof cc.Node) { + alternative = value.getComponent(RenderAlternative_1.default); + if (alternative) { + alternative.init(this.renderLayer); + } + } + else if (value instanceof cc.RenderComponent) { + alternative = value.getComponent(RenderAlternative_1.default); + if (alternative) { + this[keys[i]] = alternative.init(this.renderLayer); + } + } + alternative && propMap.set(alternative, true); + } + this.dealChilrenAlternative(this.node, propMap, 0, 0); + this.hasInit = true; + } + }; + /** + * 处理子节点代理 + * @param node + * @param propMap 记录脚本已经处理过的属性代理 + * @param parentSindex 父节点的所在的顺序 + * @param depth 深度 + */ + ShowNode.prototype.dealChilrenAlternative = function (node, propMap, parentSindex, depth) { + var _a; + for (var i = 0, len = node.children.length; i < len; i++) { + var children = node.children[i]; + var alternative = (_a = children.getComponent(cc.RenderComponent)) === null || _a === void 0 ? void 0 : _a.getComponent(RenderAlternative_1.default); + var sIndex = parentSindex + (i * Math.pow(0.1, depth)); + if (alternative) { + if ((!propMap.has(alternative) || !propMap.get(alternative))) { + alternative.init(this.renderLayer); + } + alternative.sIndex = sIndex; + } + this.dealChilrenAlternative(children, propMap, sIndex, depth + 1); + } + }; + return ShowNode; +}(cc.Component)); +exports.ShowNode = ShowNode; +var ItemCell = /** @class */ (function () { + /** + * 构造函数 + * @param node + * @param looplist + */ + function ItemCell(node, looplist) { + /**持有cell的list */ + this.looplist = null; + /**位置节点 */ + this.node = null; + /**显示节点 */ + this.showNode = null; + /**尺寸 */ + this.size = null; + /**数据下标 */ + this.dataIndex = null; + /**cell下标 */ + this.cellIndex = null; + /**数据 */ + this.data = null; + this.node = node; + this.looplist = looplist; + } + /** + * 初始化 + * @param data + * @param size + * @param dataIndex + * @param cellIndex + * @param looplist + */ + ItemCell.prototype.init = function (data, size, dataIndex, cellIndex, looplist) { + cc.Tween.stopAllByTarget(this.node); + this.cellIndex = cellIndex; + this.dataIndex = dataIndex; + this.looplist = looplist; + this.node.width = size.width; + this.node.height = size.height; + this.data = data; + this.size = size; + }; + /** + * 重置大小 + * @param size + */ + ItemCell.prototype.resize = function (size, time) { + var _this = this; + var nodeSides = getNodeBorder(this, [true, true, true, true]); + var changeSize = cc.size(size.width - this.size.width, size.height - this.size.height); + this.size = size; + this.looplist.dealChangeSize(this, nodeSides, changeSize, time).then(function () { + _this.node.width = size.width; + _this.node.height = size.height; + _this.looplist.updateNodes(); + }); + }; + /** + * 更新节点显示 + * @param isShow 是否显示 + * @param prefab 需要显示的节点的预制件(也可以是节点,或者预制件url,生成方式自由改动) + * @param cacheNode 对象池中的显示节点 + * @param renderLayer 分层节点 + */ + ItemCell.prototype.updateShow = function (isShow, prefab, cacheNode, renderLayer) { + if (isShow) { + //当前没有显示节点 + if (!this.showNode) { + //如果是临时对象池还有节点则重用 + if (cacheNode) { + this.showNode = cacheNode; + } + else { //否则使用传入的预制件进行生成 + this.showNode = cc.instantiate(prefab).getComponent(ShowNode); + } + this.showNode.node.setParent(this.node); + this.showNode.node.position = cc.v3(); + this.updateShowNode(renderLayer); + } + } + }; + /** + * 更新showNode节点显示 + * @param renderLayer + */ + ItemCell.prototype.updateShowNode = function (renderLayer) { + //当前有显示节点 + if (this.showNode) { + this.showNode.init(this, this.data, renderLayer); + } + }; + Object.defineProperty(ItemCell.prototype, "hasNoNode", { + get: function () { + return !this.showNode; + }, + enumerable: false, + configurable: true + }); + ItemCell.prototype.recircle = function () { + if (this.showNode) { + var node = this.showNode; + this.showNode.getComponent(ShowNode).onRecircle(); + this.showNode.node.removeFromParent(false); + this.showNode = null; + return node; + } + }; + ItemCell.prototype.destroy = function () { + this.node.destroy(); + this.node = null; + this.looplist = null; + }; + /** + * 失去 + * @returns + */ + ItemCell.prototype.lostShowNode = function () { + if (this.showNode) { + var node = this.showNode; + this.showNode.node.removeFromParent(false); + this.showNode = null; + return node; + } + }; + /** + * 获取显示节点 + * @param showNode + */ + ItemCell.prototype.getShowNode = function (showNode) { + this.showNode = showNode; + showNode.node.setParent(this.node); + this.showNode.cell = this; + }; + return ItemCell; +}()); +exports.ItemCell = ItemCell; +/** + * 目前列表注意事项 + * 1.开启cellMaxNum后不能一行多列或者一列多行,只能单行或者单列 + */ +var LoopList = /** @class */ (function () { + function LoopList() { + /**分层节点(只有在showNode中挂载了RenderAlternative才能起作用) */ + this.renderLayer = null; + /**滚动组件 */ + this.scrollView = null; + /**cell节点最大数量 */ + this.cellMaxNum = null; + /**当前起点 */ + this.curStartIndex = null; + /**数据 */ + this.datas = []; + /**item节点们 */ + this.itemCells = []; + /**预制件 */ + this.prefab = null; + /**显示节点的池子 */ + this.showNodePool = []; + /**边缘数据 */ + this.viewSides = {}; + /**上一帧滚动容器的坐标 */ + this.lastPos = null; + /**刷新显示的间隔次数 */ + this.updateInv = 0; + /**循环切换的最后一次时间 */ + this.lastChange = 0; + /**通用尺寸 */ + this.size = null; + /**通用锚点 */ + this.anchor = null; + } + LoopList.ins = function (listName) { + if (!this.insMap.has(listName)) { + this.insMap.set(listName, new LoopList()); + } + return this.insMap.get(listName); + }; + LoopList.prototype.onLoad = function () { + this.updateBorder(); + }; + /** + * 更新边界 + */ + LoopList.prototype.updateBorder = function () { + var _this = this; + var view = this.scrollView.node.getChildByName("view"); + view.anchorX = this.scrollView.content.anchorX; + view.anchorY = this.scrollView.content.anchorY; + //修改锚点之后下一帧世界坐标才会更新,没办法只能等一帧了 + return new Promise(function (resolve, reject) { + requestAnimationFrame(function () { + var wpos = getNodeWPos(view); + //显示区域左边缘 + var leftSide = wpos.x - (view.width * view.anchorX); + //显示区域右边缘 + var rightSide = wpos.x + (view.width * (1 - view.anchorX)); + //显示区域下边缘 + var bottomSide = wpos.y - (view.height * view.anchorY); + //显示区域上边缘 + var topSide = wpos.y + (view.height * (1 - view.anchorY)); + _this.viewSides = { + leftSide: leftSide, rightSide: rightSide, bottomSide: bottomSide, topSide: topSide, + size: cc.size(view.width, view.height) + }; + _this.scrollView.content.setPosition(cc.v3(0, 0)); + resolve(); + }); + }); + }; + /** + * 初始化滚动列表 + * @param scrollView + * @param cellMaxNum cell节点的最大数量,设置成null则不启用,启用的话,要设置成(可视窗刚好能显示的最大数量*2)+2,假设最多能看到10个节点,那么设置成22 + * @param renderLayer 渲染分层的父节点,如果传入则可以配合showNode上的renderAlternative来进行渲染分层 + */ + LoopList.prototype.init = function (scrollView, renderLayer, cellMaxNum) { + return __awaiter(this, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + cellMaxNum && (this.cellMaxNum = cellMaxNum); + renderLayer && (this.renderLayer = renderLayer); + this.scrollView = scrollView; + return [4 /*yield*/, this.updateBorder()]; + case 1: + _a.sent(); + this.scrollView.node.on("scrolling", this.scrollingListener, this); + return [2 /*return*/]; + } + }); + }); + }; + /**滚动监听 */ + LoopList.prototype.scrollingListener = function () { + this.updateInv--; + if (this.updateInv <= 0) { + this.updateInv = 2; + var showCells = this.updateNodes(); + if (!this.cellMaxNum) { + return; + } + if (!this.lastPos) { + this.lastPos = this.scrollView.content.position.clone(); + } + else { + var offset = this.scrollView.content.position.clone().sub(this.lastPos); + this.lastPos = this.scrollView.content.position.clone(); + var now = cc.sys.now(); + if (!this.lastChange || (now - this.lastChange) > 100) { + this.lastChange = now; + this.dealLoopList(offset, showCells); + } + } + } + }; + /** + * 初始化 + * @param data 数据组 + * @param prefab 预制件 + * @param size 通用尺寸 + * @param anchor cell的锚点 + */ + LoopList.prototype.initData = function (data, prefab, size, anchor) { + if (anchor === void 0) { anchor = cc.v2(0.5, 0.5); } + this.datas = data; + this.size = size; + this.anchor = anchor; + this.prefab = prefab; + var len = this.cellMaxNum ? this.cellMaxNum : data.length; + this.curStartIndex = 0; + for (var i = 0; i < len; ++i) { + var itemCell = this.itemCells[i]; + if (!itemCell) { + var node = new cc.Node('LoopListCell'); + itemCell = this.itemCells[i] = new ItemCell(node, this); + node.setAnchorPoint(anchor); + node.setParent(this.scrollView.content); + } + var data_1 = this.datas[this.curStartIndex + i]; + var cellSize = data_1.size ? data_1.size : size; + itemCell.init(data_1, cellSize, this.curStartIndex + i, i, this); + } + for (var i = data.length, len_1 = this.itemCells.length; i < len_1; ++i) { + this.recircleShowNode(this.itemCells[i].recircle()); + this.itemCells[i].destroy(); + this.itemCells[i] = null; + } + this.updateNodes(); + }; + /** + * 压入新的数据 + * @param datas + */ + LoopList.prototype.pushDatas = function (datas) { + var length = this.datas.length; + for (var i = 0, len = datas.length; i < len; ++i) { + var data = datas[i]; + this.datas.push(data); + var index = length + i; + this.addNodeFromIndex(index); + } + }; + /** + * 插入新的数据 + * @param data + * @param insertIndex + */ + LoopList.prototype.insertData = function (data, insertIndex) { + if (this.datas.length >= insertIndex) { + this.datas.splice(insertIndex, 0, data); + this.addNodeFromIndex(insertIndex); + } + else { + this.pushDatas([data]); + } + }; + /** + * 移除对应数据 + * @param removeIndex + */ + LoopList.prototype.removeData = function (removeIndex) { + var _this = this; + if (this.datas.length >= removeIndex) { + this.datas.splice(removeIndex, 1); + if (this.cellMaxNum) { + var cellIndex_1 = removeIndex - this.curStartIndex; + //在使用范围内 + if (cellIndex_1 >= 0 && cellIndex_1 < this.cellMaxNum) { + var itemCell = this.itemCells[cellIndex_1]; + var nodeSides = getNodeBorder(itemCell, [true, true, true, true]); + var changeSize = cc.size(-itemCell.size.width, -itemCell.size.height); + itemCell.size = cc.size(0, 0); + this.dealChangeSize(itemCell, nodeSides, changeSize).then(function () { + //更新数据 + for (var i = cellIndex_1; i < _this.cellMaxNum; i++) { + var curDataIndex = _this.curStartIndex + i; + var curData = _this.datas[curDataIndex]; + var curCellSize = curData.size ? curData.size : _this.size; + _this.itemCells[i].init(curData, curCellSize, curDataIndex, i, _this); + _this.itemCells[i].updateShowNode(_this.renderLayer); + } + }); + } + } + else { + var itemCell_1 = this.itemCells.splice(removeIndex, 1)[0]; + var nodeSides = getNodeBorder(itemCell_1, [true, true, true, true]); + var changeSize = cc.size(-itemCell_1.size.width, -itemCell_1.size.height); + itemCell_1.size = cc.size(0, 0); + this.dealChangeSize(itemCell_1, nodeSides, changeSize).then(function () { + _this.recircleShowNode(itemCell_1.recircle()); + itemCell_1.node.destroy(); + }); + } + } + }; + /** + * 从某个数据开始更新 + * @param dataIndex + */ + LoopList.prototype.addNodeFromIndex = function (dataIndex) { + return __awaiter(this, void 0, void 0, function () { + var data, cellSize, cellIndex, i, curDataIndex, curData, curCellSize, nodeSides, itemCell_2, nodeSides_1, node, itemCell_3; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + data = this.datas[dataIndex]; + cellSize = data.size ? data.size : this.size; + if (!this.cellMaxNum) return [3 /*break*/, 1]; + cellIndex = dataIndex - this.curStartIndex; + //在使用范围内 + if (cellIndex >= 0 && cellIndex < this.cellMaxNum) { + //更新数据 + for (i = cellIndex; i < this.cellMaxNum; i++) { + curDataIndex = this.curStartIndex + i; + curData = this.datas[curDataIndex]; + curCellSize = curData.size ? curData.size : this.size; + this.itemCells[i].init(curData, curCellSize, curDataIndex, i, this); + this.itemCells[i].updateShowNode(this.renderLayer); + } + nodeSides = null; + itemCell_2 = this.itemCells[cellIndex]; + if (itemCell_2) { + nodeSides = getNodeBorder(itemCell_2, [true, true, true, true]); + itemCell_2.node.width = 0; + itemCell_2.node.height = 0; + this.dealChangeSize(itemCell_2, nodeSides, cellSize).then(function () { + itemCell_2.node.width = cellSize.width; + itemCell_2.node.height = cellSize.height; + }); + } + } + return [3 /*break*/, 4]; + case 1: + nodeSides_1 = null; + if (this.itemCells[dataIndex]) { + nodeSides_1 = getNodeBorder(this.itemCells[dataIndex], [true, true, true, true]); + } + node = new cc.Node('LoopListCell'); + node.setAnchorPoint(this.anchor); + node.setParent(this.scrollView.content); + node.setSiblingIndex(dataIndex); + itemCell_3 = new ItemCell(node, this); + this.itemCells.splice(dataIndex, 0, itemCell_3); + itemCell_3.init(data, cellSize, dataIndex, dataIndex, this); + if (!!nodeSides_1) return [3 /*break*/, 3]; + return [4 /*yield*/, new Promise(function (resolve, reject) { + requestAnimationFrame(function () { + nodeSides_1 = getNodeBorder(itemCell_3, [true, true, true, true]); + resolve(); + }); + })]; + case 2: + _a.sent(); + _a.label = 3; + case 3: + if (nodeSides_1) { + itemCell_3.node.width = 0; + itemCell_3.node.height = 0; + this.dealChangeSize(itemCell_3, nodeSides_1, cellSize).then(function () { + itemCell_3.node.width = cellSize.width; + itemCell_3.node.height = cellSize.height; + }); + } + this.dealItemShow(itemCell_3); + _a.label = 4; + case 4: return [2 /*return*/]; + } + }); + }); + }; + /** + * 处理列表的循环利用 + * @param offset + * @param dataIndexs + */ + LoopList.prototype.dealLoopList = function (offset, showCells) { + var startCell = showCells[0]; + var endCell = showCells[showCells.length - 1]; + if (this.scrollView.vertical) { + /**内容上移 */ + if (offset.y > 0) { + //已经到达最后倒数第二个节点并且还有数据 + if (this.scrollView.content.y >= (-this.itemCells[this.itemCells.length - 2].node.y - this.viewSides.size.height) && endCell.dataIndex < this.datas.length - 2) { + //显示开始数据下标(这里-1是想要顶部留一个itemcell做缓冲) + var showStart = startCell.dataIndex - 1; + //剩余可展示的数据量 + var leave = this.datas.length - showStart; + //计算应该从那个位置开始重新赋值,因为如果直接移动到最上方,数据量不够覆盖所有的cell + var cellStartIndex = Math.max(0, this.itemCells.length - leave); + //计算第一个cell的数据下标 + this.curStartIndex = showStart - cellStartIndex; + var cellTop = getNodeBorder(this.itemCells[startCell.cellIndex], [true]).topSide; + var contentHeight = 0; + var targetY = 0; + var jumpFirst = true; + var showIndex = 0; + for (var i = 0, len = this.itemCells.length; i < len; ++i) { + if (i >= cellStartIndex) { + //将当前已经显示的showNode节点直接重新设置到移动后的节点上 + if (showIndex < showCells.length && !jumpFirst) { + if (showIndex == 0) { + targetY = contentHeight; + } + var showNode = showCells[showIndex].lostShowNode(); + showIndex++; + this.itemCells[i].getShowNode(showNode); + } + jumpFirst = false; + } + var dataIndex = this.curStartIndex + i; + var data = this.datas[dataIndex]; + var cellSize = data.size ? data.size : this.size; + contentHeight += cellSize.height; + this.itemCells[i].init(data, cellSize, dataIndex, i, this); + } + //将content的位置移动到最上方并对齐移动前的状态 + var posY = targetY + (cellTop - this.viewSides.topSide); + this.scrollView.content.setPosition(cc.v3(this.scrollView.content.position.x, posY)); + this.scrollView.scrollToOffset(cc.v2(0, posY + endCell.size.height), 1); + this.lastPos = null; + } + } //内容下移 + else if (offset.y < 0) { + //已经到达第二个节点并且还有数据 + if (this.scrollView.content.y < (-this.itemCells[2].node.y) && startCell.dataIndex > 1) { + //展示的最后一个数据下表,+1是为了在底部预留一部分空间 + var showEndIndex = endCell.dataIndex + 1; + //计算应该从那个位置开始重新赋值,因为如果直接移动到最下方,数据量不够覆盖所有的cell + var cellEndIndex = Math.min(this.itemCells.length - 2, showEndIndex - 1); + //计算第一个cell的数据下标 + this.curStartIndex = Math.max(showEndIndex - (this.itemCells.length - 1), 0); + //将content的位置移动到最下方并对齐移动前的状态 + var cellTop = getNodeBorder(this.itemCells[startCell.cellIndex], [true]).topSide; + var contentHeight = 0; + var showIndex = showCells.length - 1; + for (var i = this.itemCells.length - 1; i >= 0; --i) { + if (i <= cellEndIndex) { + //将当前已经显示的showNode节点直接重新设置到移动后的节点上 + if (showIndex >= 0) { + var showNode = showCells[showIndex].lostShowNode(); + showIndex--; + this.itemCells[i].getShowNode(showNode); + } + else { + showIndex--; + } + } + var dataIndex = this.curStartIndex + i; + var data = this.datas[dataIndex]; + var cellSize = data.size ? data.size : this.size; + if (showIndex < -1) { + contentHeight += cellSize.height; + } + this.itemCells[i].init(data, cellSize, dataIndex, i, this); + } + //将content的位置移动到最下方并对齐移动前的状态 + var posY = contentHeight + (cellTop - this.viewSides.topSide); + this.scrollView.content.setPosition(cc.v3(this.scrollView.content.position.x, posY)); + this.scrollView.scrollToOffset(cc.v2(0, posY - startCell.size.height), 1); + this.lastPos = null; + } + } + } + else if (this.scrollView.horizontal) { + if (offset.x < 0) { + //已经到达最后倒数第二个节点并且还有数据 + if (this.scrollView.content.x <= (-(this.itemCells[this.itemCells.length - 2].node.x - this.viewSides.size.width)) && endCell.dataIndex < this.datas.length - 2) { + //显示开始数据下标(这里-1是想要左侧留一个itemcell做缓冲) + var showStart = startCell.dataIndex - 1; + //剩余可展示的数据量 + var leave = this.datas.length - showStart; + //计算应该从那个位置开始重新赋值,因为如果直接移动到最左侧,数据量不够覆盖所有的cell + var cellStartIndex = Math.max(0, this.itemCells.length - leave); + //计算第一个cell的数据下标 + this.curStartIndex = showStart - cellStartIndex; + var cellLeft = getNodeBorder(this.itemCells[startCell.cellIndex], [false, false, true]).leftSide; + var contentWidth = 0; + var targetX = 0; + var jumpFirst = true; + var showIndex = 0; + for (var i = 0, len = this.itemCells.length; i < len; ++i) { + if (i >= cellStartIndex) { + //将当前已经显示的showNode节点直接重新设置到移动后的节点上 + if (showIndex < showCells.length && !jumpFirst) { + if (showIndex == 0) { + targetX = contentWidth; + } + var showNode = showCells[showIndex].lostShowNode(); + showIndex++; + this.itemCells[i].getShowNode(showNode); + } + jumpFirst = false; + } + var dataIndex = this.curStartIndex + i; + var data = this.datas[dataIndex]; + var cellSize = data.size ? data.size : this.size; + contentWidth += cellSize.width; + this.itemCells[i].init(data, cellSize, dataIndex, i, this); + } + //将content的位置移动到最左侧并对齐移动前的状态 + var posX = (cellLeft - this.viewSides.leftSide) - targetX; + this.scrollView.content.setPosition(cc.v3(posX, this.scrollView.content.position.y)); + this.scrollView.scrollToOffset(cc.v2(-(posX - endCell.size.width), 0), 1); + this.lastPos = null; + } + } + else if (offset.x > 0) { + //已经到达第二个节点并且还有数据 + if (this.scrollView.content.x > (-this.itemCells[2].node.x) && startCell.dataIndex > 1) { + //展示的最后一个数据下表,+1是为了在右侧预留一部分空间 + var showEndIndex = endCell.dataIndex + 1; + //计算应该从那个位置开始重新赋值,因为如果直接移动到最右侧,数据量不够覆盖所有的cell + var cellEndIndex = Math.min(this.itemCells.length - 2, showEndIndex - 1); + //计算第一个cell的数据下标 + this.curStartIndex = Math.max(showEndIndex - (this.itemCells.length - 1), 0); + //将content的位置移动到最右侧并对齐移动前的状态 + var cellLeft = getNodeBorder(this.itemCells[startCell.cellIndex], [false, false, true]).leftSide; + var contentWidth = 0; + var showIndex = showCells.length - 1; + for (var i = this.itemCells.length - 1; i >= 0; --i) { + if (i <= cellEndIndex) { + //将当前已经显示的showNode节点直接重新设置到移动后的节点上 + if (showIndex >= 0) { + var showNode = showCells[showIndex].lostShowNode(); + showIndex--; + this.itemCells[i].getShowNode(showNode); + } + else { + showIndex--; + } + } + var dataIndex = this.curStartIndex + i; + var data = this.datas[dataIndex]; + var cellSize = data.size ? data.size : this.size; + if (showIndex < -1) { + contentWidth += cellSize.width; + } + this.itemCells[i].init(data, cellSize, dataIndex, i, this); + } + //将content的位置移动到最右侧并对齐移动前的状态 + var posX = (cellLeft - this.viewSides.leftSide) - contentWidth; + this.scrollView.content.setPosition(cc.v3(posX, this.scrollView.content.position.y)); + this.scrollView.scrollToOffset(cc.v2(-(posX + startCell.size.width), 0), 1); + this.lastPos = null; + } + } + } + }; + /**更新节点的显示 */ + LoopList.prototype.updateNodes = function () { + var showCells = []; + for (var i = 0, len = this.itemCells.length; i < len; ++i) { + var itemCell = this.itemCells[i]; + var isShow = this.dealItemShow(itemCell); + if (isShow) { + showCells.push(itemCell); + } + } + return showCells; + }; + /** + * 处理cell的显示隐藏 + * @param itemCell + */ + LoopList.prototype.dealItemShow = function (itemCell) { + if (itemCell) { + var isShow = this.checkInView(itemCell); + if (isShow) { + itemCell.hasNoNode && itemCell.updateShow(isShow, this.prefab, this.showNodePool.length > 0 ? this.showNodePool.pop() : null, this.renderLayer); + } + else { + !itemCell.hasNoNode && this.recircleShowNode(itemCell.recircle()); + } + return isShow; + } + }; + /** + * 检查是否在屏幕内 + * @param node + * @returns + */ + LoopList.prototype.checkInView = function (itemCell) { + var nodeSides = getNodeBorder(itemCell, [true, true, true, true]); + //节点右侧边缘在屏幕左侧外面或者节点左边缘在屏幕右侧外面 则不在显示区域 + var horizontalOutside = nodeSides.rightSide < this.viewSides.leftSide + || nodeSides.leftSide > this.viewSides.rightSide; + var verticalOutside = false; + if (!horizontalOutside) { + //节点上边缘在屏幕下方外面或者节点下边缘在屏幕上方外面 则不在显示区域 + verticalOutside = nodeSides.topSide < this.viewSides.bottomSide + || nodeSides.bottomSide > this.viewSides.topSide; + } + return !horizontalOutside && !verticalOutside; + }; + /** + * 处理变化的大小 + * @param cell + * @param nodeSides + * @param changeSize + */ + LoopList.prototype.dealChangeSize = function (cell, nodeSides, changeSize, time) { + if (time === void 0) { time = 0.3; } + return __awaiter(this, void 0, void 0, function () { + var topToBottomFulfill, bottomToTopFulfill, leftToRightFulfill, RightToLeftFulfill; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + topToBottomFulfill = (this.scrollView.content.anchorY == 1 && nodeSides.bottomSide >= this.viewSides.topSide); + bottomToTopFulfill = (this.scrollView.content.anchorY == 0 && nodeSides.topSide <= this.viewSides.bottomSide); + if (topToBottomFulfill || bottomToTopFulfill) { + if (topToBottomFulfill) { + this.scrollView.setContentPosition(cc.v2(this.scrollView.content.x, this.scrollView.content.y + changeSize.height)); + } + else { + this.scrollView.setContentPosition(cc.v2(this.scrollView.content.x, this.scrollView.content.y - changeSize.height)); + } + } + leftToRightFulfill = (this.scrollView.content.anchorX == 0 && nodeSides.rightSide <= this.viewSides.leftSide); + RightToLeftFulfill = (this.scrollView.content.anchorX == 1 && nodeSides.leftSide >= this.viewSides.rightSide); + if (leftToRightFulfill || RightToLeftFulfill) { + if (RightToLeftFulfill) { + this.scrollView.setContentPosition(cc.v2(this.scrollView.content.x + changeSize.width, this.scrollView.content.y)); + } + else { + this.scrollView.setContentPosition(cc.v2(this.scrollView.content.x - changeSize.width, this.scrollView.content.y)); + } + } + if (!!(topToBottomFulfill || bottomToTopFulfill || leftToRightFulfill || RightToLeftFulfill)) return [3 /*break*/, 2]; + cc.Tween.stopAllByTarget(cell.node); + return [4 /*yield*/, new Promise(function (resolve, reject) { + cc.tween(cell.node).to(time, { width: cell.size.width, height: cell.size.height }).call(function () { + resolve(); + }).start(); + })]; + case 1: + _a.sent(); + _a.label = 2; + case 2: + this.updateNodes(); + return [2 /*return*/, true]; + } + }); + }); + }; + /** + * 回收显示节点 + * @param node + */ + LoopList.prototype.recircleShowNode = function (node) { + node && this.showNodePool.push(node); + }; + /** + * 释放当前列表 + */ + LoopList.prototype.freeList = function () { + this.scrollView.node.off("scrolling", this.scrollingListener); + for (var i = 0, len = this.itemCells.length; i < len; ++i) { + this.recircleShowNode(this.itemCells[i].recircle()); + this.itemCells[i].destroy(); + } + this.itemCells = []; + for (var index = 0, len = this.showNodePool.length; index < len; ++index) { + this.showNodePool[index].destroy(); + } + this.showNodePool = []; + this.renderLayer = null; + this.scrollView = null; + this.prefab = null; + }; + LoopList.insMap = new Map(); + return LoopList; +}()); +exports.default = LoopList; +/** + * 获取节点的边缘 + * @param node + * @param needArr 顺序是上 下 左 右 + */ +function getNodeBorder(cell, needArr) { + var node = cell.node; + var boderData = {}; + var wpos = getNodeWPos(node); + //显示区域上边缘 + if (needArr[0]) { + boderData.topSide = wpos.y + (node.height * (1 - node.anchorY)); + } + //显示区域下边缘 + if (needArr[1]) { + boderData.bottomSide = wpos.y - (node.height * node.anchorY); + } + //显示区域左边缘 + if (needArr[2]) { + boderData.leftSide = wpos.x - (node.width * node.anchorX); + } + //显示区域右边缘 + if (needArr[3]) { + boderData.rightSide = wpos.x + (node.width * (1 - node.anchorX)); + } + boderData.size = cc.size(node.width, node.height); + return boderData; +} +/** + * 获取节点世界坐标 + * @param node + * @returns + */ +function getNodeWPos(node) { + return node.parent.convertToWorldSpaceAR(node.position); +} + +cc._RF.pop(); + } + if (nodeEnv) { + __define(__module.exports, __require, __module); + } + else { + __quick_compile_project__.registerModuleFunc(__filename, function () { + __define(__module.exports, __require, __module); + }); + } + })(); +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImFzc2V0c1xcU2NyaXB0XFxMb29wTGlzdC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0FBQUEseURBQW9EO0FBVXBEO0lBQStDLDRCQUFZO0lBQTNEO1FBQUEscUVBZ0ZDO1FBL0VHLGdCQUFnQjtRQUNSLGFBQU8sR0FBWSxLQUFLLENBQUM7O0lBOEVyQyxDQUFDO0lBdkVHLFNBQVM7SUFDRix1QkFBSSxHQUFYLFVBQVksSUFBaUIsRUFBRSxJQUFPLEVBQUUsV0FBb0I7UUFDeEQsSUFBSSxDQUFDLElBQUksR0FBRyxJQUFJLENBQUM7UUFDakIsSUFBSSxDQUFDLElBQUksR0FBRyxJQUFJLENBQUM7UUFDakIsSUFBSSxJQUFJLENBQUMsV0FBVyxJQUFJLFdBQVcsRUFBRTtZQUNqQyxJQUFJLENBQUMsV0FBVyxHQUFHLFdBQVcsQ0FBQztZQUMvQixXQUFXLElBQUksSUFBSSxDQUFDLFdBQVcsRUFBRSxDQUFDO1NBQ3JDO1FBQ0QsSUFBSSxDQUFDLFFBQVEsRUFBRSxDQUFDO0lBQ3BCLENBQUM7SUFDRCxXQUFXO0lBQ1gsMkJBQVEsR0FBUixjQUFhLENBQUM7SUFDZCxvQkFBb0I7SUFDcEIsNkJBQVUsR0FBVixjQUFlLENBQUM7SUFFaEI7Ozs7T0FJRztJQUNJLHlCQUFNLEdBQWIsVUFBYyxVQUFtQixFQUFFLElBQWtCO1FBQWxCLHFCQUFBLEVBQUEsVUFBa0I7UUFDakQsSUFBSSxDQUFDLElBQUksQ0FBQyxNQUFNLENBQUMsVUFBVSxFQUFFLElBQUksQ0FBQyxDQUFDO0lBQ3ZDLENBQUM7SUFDRDs7T0FFRztJQUNLLDhCQUFXLEdBQW5CO1FBQ0ksSUFBSSxDQUFDLElBQUksQ0FBQyxPQUFPLElBQUksSUFBSSxDQUFDLFdBQVcsRUFBRTtZQUNuQyxJQUFJLE9BQU8sR0FBd0MsSUFBSSxPQUFPLEVBQUUsQ0FBQztZQUNqRSxJQUFJLElBQUksR0FBRyxNQUFNLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxDQUFDO1lBQzdCLEtBQUssSUFBSSxDQUFDLEdBQUcsQ0FBQyxFQUFFLEdBQUcsR0FBRyxJQUFJLENBQUMsTUFBTSxFQUFFLENBQUMsR0FBRyxHQUFHLEVBQUUsRUFBRSxDQUFDLEVBQUU7Z0JBQzdDLElBQUksS0FBSyxHQUFHLElBQUksQ0FBQyxJQUFJLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQztnQkFDMUIsSUFBSSxXQUFXLEdBQXNCLElBQUksQ0FBQztnQkFDMUMsSUFBSSxLQUFLLFlBQVksRUFBRSxDQUFDLElBQUksRUFBRTtvQkFDMUIsV0FBVyxHQUFHLEtBQUssQ0FBQyxZQUFZLENBQUMsMkJBQWlCLENBQUMsQ0FBQztvQkFDcEQsSUFBSSxXQUFXLEVBQUU7d0JBQ2IsV0FBVyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsV0FBVyxDQUFDLENBQUM7cUJBQ3RDO2lCQUNKO3FCQUFNLElBQUksS0FBSyxZQUFZLEVBQUUsQ0FBQyxlQUFlLEVBQUU7b0JBQzVDLFdBQVcsR0FBRyxLQUFLLENBQUMsWUFBWSxDQUFDLDJCQUFpQixDQUFDLENBQUM7b0JBQ3BELElBQUksV0FBVyxFQUFFO3dCQUNiLElBQUksQ0FBQyxJQUFJLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxXQUFXLENBQUMsSUFBSSxDQUFlLElBQUksQ0FBQyxXQUFXLENBQUMsQ0FBQztxQkFDcEU7aUJBQ0o7Z0JBQ0QsV0FBVyxJQUFJLE9BQU8sQ0FBQyxHQUFHLENBQUMsV0FBVyxFQUFFLElBQUksQ0FBQyxDQUFDO2FBQ2pEO1lBQ0QsSUFBSSxDQUFDLHNCQUFzQixDQUFDLElBQUksQ0FBQyxJQUFJLEVBQUUsT0FBTyxFQUFFLENBQUMsRUFBRSxDQUFDLENBQUMsQ0FBQztZQUN0RCxJQUFJLENBQUMsT0FBTyxHQUFHLElBQUksQ0FBQztTQUN2QjtJQUNMLENBQUM7SUFDRDs7Ozs7O09BTUc7SUFDSCx5Q0FBc0IsR0FBdEIsVUFBdUIsSUFBYSxFQUFFLE9BQTRDLEVBQUUsWUFBb0IsRUFBRSxLQUFhOztRQUNuSCxLQUFLLElBQUksQ0FBQyxHQUFHLENBQUMsRUFBRSxHQUFHLEdBQUcsSUFBSSxDQUFDLFFBQVEsQ0FBQyxNQUFNLEVBQUUsQ0FBQyxHQUFHLEdBQUcsRUFBRSxDQUFDLEVBQUUsRUFBRTtZQUN0RCxJQUFJLFFBQVEsR0FBRyxJQUFJLENBQUMsUUFBUSxDQUFDLENBQUMsQ0FBQyxDQUFDO1lBQ2hDLElBQUksV0FBVyxTQUFHLFFBQVEsQ0FBQyxZQUFZLENBQUMsRUFBRSxDQUFDLGVBQWUsQ0FBQywwQ0FBRSxZQUFZLENBQUMsMkJBQWlCLENBQUMsQ0FBQztZQUM3RixJQUFJLE1BQU0sR0FBRyxZQUFZLEdBQUcsQ0FBQyxDQUFDLEdBQUcsSUFBSSxDQUFDLEdBQUcsQ0FBQyxHQUFHLEVBQUUsS0FBSyxDQUFDLENBQUMsQ0FBQztZQUN2RCxJQUFJLFdBQVcsRUFBRTtnQkFDYixJQUFJLENBQUMsQ0FBQyxPQUFPLENBQUMsR0FBRyxDQUFDLFdBQVcsQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDLEdBQUcsQ0FBQyxXQUFXLENBQUMsQ0FBQyxFQUFFO29CQUMxRCxXQUFXLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxXQUFXLENBQUMsQ0FBQztpQkFDdEM7Z0JBQ0QsV0FBVyxDQUFDLE1BQU0sR0FBRyxNQUFNLENBQUM7YUFDL0I7WUFDRCxJQUFJLENBQUMsc0JBQXNCLENBQUMsUUFBUSxFQUFFLE9BQU8sRUFBRSxNQUFNLEVBQUUsS0FBSyxHQUFHLENBQUMsQ0FBQyxDQUFDO1NBQ3JFO0lBQ0wsQ0FBQztJQUNMLGVBQUM7QUFBRCxDQWhGQSxBQWdGQyxDQWhGOEMsRUFBRSxDQUFDLFNBQVMsR0FnRjFEO0FBaEZZLDRCQUFRO0FBaUZyQjtJQWVJOzs7O09BSUc7SUFDSCxrQkFBWSxJQUFhLEVBQUUsUUFBcUI7UUFuQmhELGlCQUFpQjtRQUNWLGFBQVEsR0FBZ0IsSUFBSSxDQUFDO1FBQ3BDLFVBQVU7UUFDSCxTQUFJLEdBQVksSUFBSSxDQUFDO1FBQzVCLFVBQVU7UUFDSCxhQUFRLEdBQWdCLElBQUksQ0FBQztRQUNwQyxRQUFRO1FBQ0QsU0FBSSxHQUFZLElBQUksQ0FBQztRQUM1QixVQUFVO1FBQ0gsY0FBUyxHQUFXLElBQUksQ0FBQztRQUNoQyxZQUFZO1FBQ0wsY0FBUyxHQUFXLElBQUksQ0FBQztRQUNoQyxRQUFRO1FBQ0QsU0FBSSxHQUFNLElBQUksQ0FBQztRQU9sQixJQUFJLENBQUMsSUFBSSxHQUFHLElBQUksQ0FBQztRQUNqQixJQUFJLENBQUMsUUFBUSxHQUFHLFFBQVEsQ0FBQztJQUM3QixDQUFDO0lBRUQ7Ozs7Ozs7T0FPRztJQUNJLHVCQUFJLEdBQVgsVUFBWSxJQUFPLEVBQUUsSUFBYSxFQUFFLFNBQWlCLEVBQUUsU0FBaUIsRUFBRSxRQUFxQjtRQUMzRixFQUFFLENBQUMsS0FBSyxDQUFDLGVBQWUsQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLENBQUM7UUFDcEMsSUFBSSxDQUFDLFNBQVMsR0FBRyxTQUFTLENBQUM7UUFDM0IsSUFBSSxDQUFDLFNBQVMsR0FBRyxTQUFTLENBQUM7UUFDM0IsSUFBSSxDQUFDLFFBQVEsR0FBRyxRQUFRLENBQUM7UUFDekIsSUFBSSxDQUFDLElBQUksQ0FBQyxLQUFLLEdBQUcsSUFBSSxDQUFDLEtBQUssQ0FBQztRQUM3QixJQUFJLENBQUMsSUFBSSxDQUFDLE1BQU0sR0FBRyxJQUFJLENBQUMsTUFBTSxDQUFDO1FBQy9CLElBQUksQ0FBQyxJQUFJLEdBQUcsSUFBSSxDQUFDO1FBQ2pCLElBQUksQ0FBQyxJQUFJLEdBQUcsSUFBSSxDQUFDO0lBQ3JCLENBQUM7SUFDRDs7O09BR0c7SUFDSCx5QkFBTSxHQUFOLFVBQU8sSUFBYSxFQUFFLElBQVk7UUFBbEMsaUJBU0M7UUFSRyxJQUFJLFNBQVMsR0FBRyxhQUFhLENBQUMsSUFBSSxFQUFFLENBQUMsSUFBSSxFQUFFLElBQUksRUFBRSxJQUFJLEVBQUUsSUFBSSxDQUFDLENBQUMsQ0FBQztRQUM5RCxJQUFJLFVBQVUsR0FBRyxFQUFFLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxLQUFLLEdBQUcsSUFBSSxDQUFDLElBQUksQ0FBQyxLQUFLLEVBQUUsSUFBSSxDQUFDLE1BQU0sR0FBRyxJQUFJLENBQUMsSUFBSSxDQUFDLE1BQU0sQ0FBQyxDQUFDO1FBQ3ZGLElBQUksQ0FBQyxJQUFJLEdBQUcsSUFBSSxDQUFDO1FBQ2pCLElBQUksQ0FBQyxRQUFRLENBQUMsY0FBYyxDQUFDLElBQUksRUFBRSxTQUFTLEVBQUUsVUFBVSxFQUFFLElBQUksQ0FBQyxDQUFDLElBQUksQ0FBQztZQUNqRSxLQUFJLENBQUMsSUFBSSxDQUFDLEtBQUssR0FBRyxJQUFJLENBQUMsS0FBSyxDQUFDO1lBQzdCLEtBQUksQ0FBQyxJQUFJLENBQUMsTUFBTSxHQUFHLElBQUksQ0FBQyxNQUFNLENBQUM7WUFDL0IsS0FBSSxDQUFDLFFBQVEsQ0FBQyxXQUFXLEVBQUUsQ0FBQztRQUNoQyxDQUFDLENBQUMsQ0FBQztJQUNQLENBQUM7SUFFRDs7Ozs7O09BTUc7SUFDSCw2QkFBVSxHQUFWLFVBQVcsTUFBZSxFQUFFLE1BQWlCLEVBQUUsU0FBc0IsRUFBRSxXQUFvQjtRQUN2RixJQUFJLE1BQU0sRUFBRTtZQUNSLFVBQVU7WUFDVixJQUFJLENBQUMsSUFBSSxDQUFDLFFBQVEsRUFBRTtnQkFDaEIsaUJBQWlCO2dCQUNqQixJQUFJLFNBQVMsRUFBRTtvQkFDWCxJQUFJLENBQUMsUUFBUSxHQUFHLFNBQVMsQ0FBQztpQkFDN0I7cUJBQU0sRUFBQyxnQkFBZ0I7b0JBQ3BCLElBQUksQ0FBQyxRQUFRLEdBQUcsRUFBRSxDQUFDLFdBQVcsQ0FBQyxNQUFNLENBQUMsQ0FBQyxZQUFZLENBQUMsUUFBUSxDQUFDLENBQUM7aUJBQ2pFO2dCQUNELElBQUksQ0FBQyxRQUFRLENBQUMsSUFBSSxDQUFDLFNBQVMsQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLENBQUM7Z0JBQ3hDLElBQUksQ0FBQyxRQUFRLENBQUMsSUFBSSxDQUFDLFFBQVEsR0FBRyxFQUFFLENBQUMsRUFBRSxFQUFFLENBQUM7Z0JBQ3RDLElBQUksQ0FBQyxjQUFjLENBQUMsV0FBVyxDQUFDLENBQUM7YUFDcEM7U0FDSjtJQUNMLENBQUM7SUFDRDs7O09BR0c7SUFDSCxpQ0FBYyxHQUFkLFVBQWUsV0FBb0I7UUFDL0IsU0FBUztRQUNULElBQUksSUFBSSxDQUFDLFFBQVEsRUFBRTtZQUNmLElBQUksQ0FBQyxRQUFRLENBQUMsSUFBSSxDQUFDLElBQUksRUFBRSxJQUFJLENBQUMsSUFBSSxFQUFFLFdBQVcsQ0FBQyxDQUFDO1NBQ3BEO0lBQ0wsQ0FBQztJQUVELHNCQUFJLCtCQUFTO2FBQWI7WUFDSSxPQUFPLENBQUMsSUFBSSxDQUFDLFFBQVEsQ0FBQztRQUMxQixDQUFDOzs7T0FBQTtJQUVELDJCQUFRLEdBQVI7UUFDSSxJQUFJLElBQUksQ0FBQyxRQUFRLEVBQUU7WUFDZixJQUFJLElBQUksR0FBRyxJQUFJLENBQUMsUUFBUSxDQUFDO1lBQ3pCLElBQUksQ0FBQyxRQUFRLENBQUMsWUFBWSxDQUFDLFFBQVEsQ0FBQyxDQUFDLFVBQVUsRUFBRSxDQUFDO1lBQ2xELElBQUksQ0FBQyxRQUFRLENBQUMsSUFBSSxDQUFDLGdCQUFnQixDQUFDLEtBQUssQ0FBQyxDQUFDO1lBQzNDLElBQUksQ0FBQyxRQUFRLEdBQUcsSUFBSSxDQUFDO1lBQ3JCLE9BQU8sSUFBSSxDQUFDO1NBQ2Y7SUFDTCxDQUFDO0lBR0QsMEJBQU8sR0FBUDtRQUNJLElBQUksQ0FBQyxJQUFJLENBQUMsT0FBTyxFQUFFLENBQUM7UUFDcEIsSUFBSSxDQUFDLElBQUksR0FBRyxJQUFJLENBQUM7UUFDakIsSUFBSSxDQUFDLFFBQVEsR0FBRyxJQUFJLENBQUM7SUFDekIsQ0FBQztJQUVEOzs7T0FHRztJQUNILCtCQUFZLEdBQVo7UUFDSSxJQUFJLElBQUksQ0FBQyxRQUFRLEVBQUU7WUFDZixJQUFJLElBQUksR0FBRyxJQUFJLENBQUMsUUFBUSxDQUFDO1lBQ3pCLElBQUksQ0FBQyxRQUFRLENBQUMsSUFBSSxDQUFDLGdCQUFnQixDQUFDLEtBQUssQ0FBQyxDQUFDO1lBQzNDLElBQUksQ0FBQyxRQUFRLEdBQUcsSUFBSSxDQUFDO1lBQ3JCLE9BQU8sSUFBSSxDQUFDO1NBQ2Y7SUFDTCxDQUFDO0lBRUQ7OztPQUdHO0lBQ0gsOEJBQVcsR0FBWCxVQUFZLFFBQXFCO1FBQzdCLElBQUksQ0FBQyxRQUFRLEdBQUcsUUFBUSxDQUFDO1FBQ3pCLFFBQVEsQ0FBQyxJQUFJLENBQUMsU0FBUyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsQ0FBQztRQUNuQyxJQUFJLENBQUMsUUFBUSxDQUFDLElBQUksR0FBRyxJQUFJLENBQUM7SUFDOUIsQ0FBQztJQUNMLGVBQUM7QUFBRCxDQXZJQSxBQXVJQyxJQUFBO0FBdklZLDRCQUFRO0FBeUlyQjs7O0dBR0c7QUFDSDtJQUFBO1FBUUksaURBQWlEO1FBQ3pDLGdCQUFXLEdBQVksSUFBSSxDQUFDO1FBQ3BDLFVBQVU7UUFDRixlQUFVLEdBQWtCLElBQUksQ0FBQztRQUN6QyxnQkFBZ0I7UUFDUixlQUFVLEdBQVcsSUFBSSxDQUFDO1FBQ2xDLFVBQVU7UUFDRixrQkFBYSxHQUFXLElBQUksQ0FBQztRQUNyQyxRQUFRO1FBQ0EsVUFBSyxHQUFRLEVBQUUsQ0FBQztRQUN4QixhQUFhO1FBQ0wsY0FBUyxHQUFrQixFQUFFLENBQUM7UUFDdEMsU0FBUztRQUNELFdBQU0sR0FBYyxJQUFJLENBQUM7UUFDakMsYUFBYTtRQUNMLGlCQUFZLEdBQWtCLEVBQUUsQ0FBQztRQUN6QyxVQUFVO1FBQ0YsY0FBUyxHQUFZLEVBQUUsQ0FBQztRQUNoQyxnQkFBZ0I7UUFDVCxZQUFPLEdBQVksSUFBSSxDQUFDO1FBQy9CLGVBQWU7UUFDUixjQUFTLEdBQVcsQ0FBQyxDQUFDO1FBQzdCLGlCQUFpQjtRQUNWLGVBQVUsR0FBVyxDQUFDLENBQUM7UUFDOUIsVUFBVTtRQUNILFNBQUksR0FBWSxJQUFJLENBQUM7UUFDNUIsVUFBVTtRQUNILFdBQU0sR0FBWSxJQUFJLENBQUM7SUF5aEJsQyxDQUFDO0lBMWpCaUIsWUFBRyxHQUFqQixVQUFxQixRQUFnQjtRQUNqQyxJQUFJLENBQUMsSUFBSSxDQUFDLE1BQU0sQ0FBQyxHQUFHLENBQUMsUUFBUSxDQUFDLEVBQUU7WUFDNUIsSUFBSSxDQUFDLE1BQU0sQ0FBQyxHQUFHLENBQUMsUUFBUSxFQUFFLElBQUksUUFBUSxFQUFLLENBQUMsQ0FBQztTQUNoRDtRQUNELE9BQU8sSUFBSSxDQUFDLE1BQU0sQ0FBQyxHQUFHLENBQUMsUUFBUSxDQUFnQixDQUFDO0lBQ3BELENBQUM7SUE4QkQseUJBQU0sR0FBTjtRQUNJLElBQUksQ0FBQyxZQUFZLEVBQUUsQ0FBQTtJQUN2QixDQUFDO0lBRUQ7O09BRUc7SUFDSSwrQkFBWSxHQUFuQjtRQUFBLGlCQXdCQztRQXZCRyxJQUFJLElBQUksR0FBRyxJQUFJLENBQUMsVUFBVSxDQUFDLElBQUksQ0FBQyxjQUFjLENBQUMsTUFBTSxDQUFDLENBQUM7UUFDdkQsSUFBSSxDQUFDLE9BQU8sR0FBRyxJQUFJLENBQUMsVUFBVSxDQUFDLE9BQU8sQ0FBQyxPQUFPLENBQUM7UUFDL0MsSUFBSSxDQUFDLE9BQU8sR0FBRyxJQUFJLENBQUMsVUFBVSxDQUFDLE9BQU8sQ0FBQyxPQUFPLENBQUM7UUFDL0MsNkJBQTZCO1FBQzdCLE9BQU8sSUFBSSxPQUFPLENBQU8sVUFBQyxPQUFPLEVBQUUsTUFBTTtZQUNyQyxxQkFBcUIsQ0FBQztnQkFDbEIsSUFBSSxJQUFJLEdBQUcsV0FBVyxDQUFDLElBQUksQ0FBQyxDQUFDO2dCQUM3QixTQUFTO2dCQUNULElBQUksUUFBUSxHQUFHLElBQUksQ0FBQyxDQUFDLEdBQUcsQ0FBQyxJQUFJLENBQUMsS0FBSyxHQUFHLElBQUksQ0FBQyxPQUFPLENBQUMsQ0FBQztnQkFDcEQsU0FBUztnQkFDVCxJQUFJLFNBQVMsR0FBRyxJQUFJLENBQUMsQ0FBQyxHQUFHLENBQUMsSUFBSSxDQUFDLEtBQUssR0FBRyxDQUFDLENBQUMsR0FBRyxJQUFJLENBQUMsT0FBTyxDQUFDLENBQUMsQ0FBQztnQkFDM0QsU0FBUztnQkFDVCxJQUFJLFVBQVUsR0FBRyxJQUFJLENBQUMsQ0FBQyxHQUFHLENBQUMsSUFBSSxDQUFDLE1BQU0sR0FBRyxJQUFJLENBQUMsT0FBTyxDQUFDLENBQUM7Z0JBQ3ZELFNBQVM7Z0JBQ1QsSUFBSSxPQUFPLEdBQUcsSUFBSSxDQUFDLENBQUMsR0FBRyxDQUFDLElBQUksQ0FBQyxNQUFNLEdBQUcsQ0FBQyxDQUFDLEdBQUcsSUFBSSxDQUFDLE9BQU8sQ0FBQyxDQUFDLENBQUM7Z0JBQzFELEtBQUksQ0FBQyxTQUFTLEdBQUc7b0JBQ2IsUUFBUSxVQUFBLEVBQUUsU0FBUyxXQUFBLEVBQUUsVUFBVSxZQUFBLEVBQUUsT0FBTyxTQUFBO29CQUFFLElBQUksRUFBRSxFQUFFLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxLQUFLLEVBQUUsSUFBSSxDQUFDLE1BQU0sQ0FBQztpQkFDbkYsQ0FBQztnQkFDRixLQUFJLENBQUMsVUFBVSxDQUFDLE9BQU8sQ0FBQyxXQUFXLENBQUMsRUFBRSxDQUFDLEVBQUUsQ0FBQyxDQUFDLEVBQUUsQ0FBQyxDQUFDLENBQUMsQ0FBQztnQkFDakQsT0FBTyxFQUFFLENBQUM7WUFDZCxDQUFDLENBQUMsQ0FBQTtRQUNOLENBQUMsQ0FBQyxDQUFBO0lBRU4sQ0FBQztJQUVEOzs7OztPQUtHO0lBQ0csdUJBQUksR0FBVixVQUFXLFVBQXlCLEVBQUUsV0FBcUIsRUFBRSxVQUFtQjs7Ozs7d0JBQzVFLFVBQVUsSUFBSSxDQUFDLElBQUksQ0FBQyxVQUFVLEdBQUcsVUFBVSxDQUFDLENBQUM7d0JBQzdDLFdBQVcsSUFBSSxDQUFDLElBQUksQ0FBQyxXQUFXLEdBQUcsV0FBVyxDQUFDLENBQUM7d0JBQ2hELElBQUksQ0FBQyxVQUFVLEdBQUcsVUFBVSxDQUFDO3dCQUM3QixxQkFBTSxJQUFJLENBQUMsWUFBWSxFQUFFLEVBQUE7O3dCQUF6QixTQUF5QixDQUFDO3dCQUMxQixJQUFJLENBQUMsVUFBVSxDQUFDLElBQUksQ0FBQyxFQUFFLENBQUMsV0FBVyxFQUFFLElBQUksQ0FBQyxpQkFBaUIsRUFBRSxJQUFJLENBQUMsQ0FBQzs7Ozs7S0FDdEU7SUFFRCxVQUFVO0lBQ1Ysb0NBQWlCLEdBQWpCO1FBQ0ksSUFBSSxDQUFDLFNBQVMsRUFBRSxDQUFDO1FBQ2pCLElBQUksSUFBSSxDQUFDLFNBQVMsSUFBSSxDQUFDLEVBQUU7WUFDckIsSUFBSSxDQUFDLFNBQVMsR0FBRyxDQUFDLENBQUM7WUFDbkIsSUFBSSxTQUFTLEdBQUcsSUFBSSxDQUFDLFdBQVcsRUFBRSxDQUFDO1lBRW5DLElBQUksQ0FBQyxJQUFJLENBQUMsVUFBVSxFQUFFO2dCQUNsQixPQUFPO2FBQ1Y7WUFDRCxJQUFJLENBQUMsSUFBSSxDQUFDLE9BQU8sRUFBRTtnQkFDZixJQUFJLENBQUMsT0FBTyxHQUFHLElBQUksQ0FBQyxVQUFVLENBQUMsT0FBTyxDQUFDLFFBQVEsQ0FBQyxLQUFLLEVBQUUsQ0FBQzthQUMzRDtpQkFBTTtnQkFDSCxJQUFJLE1BQU0sR0FBRyxJQUFJLENBQUMsVUFBVSxDQUFDLE9BQU8sQ0FBQyxRQUFRLENBQUMsS0FBSyxFQUFFLENBQUMsR0FBRyxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUMsQ0FBQztnQkFDeEUsSUFBSSxDQUFDLE9BQU8sR0FBRyxJQUFJLENBQUMsVUFBVSxDQUFDLE9BQU8sQ0FBQyxRQUFRLENBQUMsS0FBSyxFQUFFLENBQUM7Z0JBQ3hELElBQUksR0FBRyxHQUFHLEVBQUUsQ0FBQyxHQUFHLENBQUMsR0FBRyxFQUFFLENBQUM7Z0JBQ3ZCLElBQUksQ0FBQyxJQUFJLENBQUMsVUFBVSxJQUFJLENBQUMsR0FBRyxHQUFHLElBQUksQ0FBQyxVQUFVLENBQUMsR0FBRyxHQUFHLEVBQUU7b0JBQ25ELElBQUksQ0FBQyxVQUFVLEdBQUcsR0FBRyxDQUFDO29CQUN0QixJQUFJLENBQUMsWUFBWSxDQUFDLE1BQU0sRUFBRSxTQUFTLENBQUMsQ0FBQztpQkFDeEM7YUFDSjtTQUNKO0lBQ0wsQ0FBQztJQUNEOzs7Ozs7T0FNRztJQUNJLDJCQUFRLEdBQWYsVUFBZ0IsSUFBUyxFQUFFLE1BQWlCLEVBQUUsSUFBYyxFQUFFLE1BQWlDO1FBQWpDLHVCQUFBLEVBQUEsU0FBa0IsRUFBRSxDQUFDLEVBQUUsQ0FBQyxHQUFHLEVBQUUsR0FBRyxDQUFDO1FBQzNGLElBQUksQ0FBQyxLQUFLLEdBQUcsSUFBSSxDQUFDO1FBQ2xCLElBQUksQ0FBQyxJQUFJLEdBQUcsSUFBSSxDQUFDO1FBQ2pCLElBQUksQ0FBQyxNQUFNLEdBQUcsTUFBTSxDQUFDO1FBQ3JCLElBQUksQ0FBQyxNQUFNLEdBQUcsTUFBTSxDQUFDO1FBQ3JCLElBQUksR0FBRyxHQUFHLElBQUksQ0FBQyxVQUFVLENBQUMsQ0FBQyxDQUFDLElBQUksQ0FBQyxVQUFVLENBQUMsQ0FBQyxDQUFDLElBQUksQ0FBQyxNQUFNLENBQUM7UUFDMUQsSUFBSSxDQUFDLGFBQWEsR0FBRyxDQUFDLENBQUM7UUFDdkIsS0FBSyxJQUFJLENBQUMsR0FBRyxDQUFDLEVBQUUsQ0FBQyxHQUFHLEdBQUcsRUFBRSxFQUFFLENBQUMsRUFBRTtZQUMxQixJQUFJLFFBQVEsR0FBRyxJQUFJLENBQUMsU0FBUyxDQUFDLENBQUMsQ0FBQyxDQUFDO1lBQ2pDLElBQUksQ0FBQyxRQUFRLEVBQUU7Z0JBQ1gsSUFBSSxJQUFJLEdBQUcsSUFBSSxFQUFFLENBQUMsSUFBSSxDQUFDLGNBQWMsQ0FBQyxDQUFBO2dCQUN0QyxRQUFRLEdBQUcsSUFBSSxDQUFDLFNBQVMsQ0FBQyxDQUFDLENBQUMsR0FBRyxJQUFJLFFBQVEsQ0FBSSxJQUFJLEVBQUUsSUFBSSxDQUFDLENBQUM7Z0JBQzNELElBQUksQ0FBQyxjQUFjLENBQUMsTUFBTSxDQUFDLENBQUM7Z0JBQzVCLElBQUksQ0FBQyxTQUFTLENBQUMsSUFBSSxDQUFDLFVBQVUsQ0FBQyxPQUFPLENBQUMsQ0FBQzthQUMzQztZQUNELElBQUksTUFBSSxHQUFHLElBQUksQ0FBQyxLQUFLLENBQUMsSUFBSSxDQUFDLGFBQWEsR0FBRyxDQUFDLENBQUMsQ0FBQztZQUM5QyxJQUFJLFFBQVEsR0FBRyxNQUFJLENBQUMsSUFBSSxDQUFDLENBQUMsQ0FBQyxNQUFJLENBQUMsSUFBSSxDQUFDLENBQUMsQ0FBQyxJQUFJLENBQUM7WUFDNUMsUUFBUSxDQUFDLElBQUksQ0FBQyxNQUFJLEVBQUUsUUFBUSxFQUFFLElBQUksQ0FBQyxhQUFhLEdBQUcsQ0FBQyxFQUFFLENBQUMsRUFBRSxJQUFJLENBQUMsQ0FBQztTQUNsRTtRQUNELEtBQUssSUFBSSxDQUFDLEdBQUcsSUFBSSxDQUFDLE1BQU0sRUFBRSxLQUFHLEdBQUcsSUFBSSxDQUFDLFNBQVMsQ0FBQyxNQUFNLEVBQUUsQ0FBQyxHQUFHLEtBQUcsRUFBRSxFQUFFLENBQUMsRUFBRTtZQUNqRSxJQUFJLENBQUMsZ0JBQWdCLENBQUMsSUFBSSxDQUFDLFNBQVMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxRQUFRLEVBQUUsQ0FBQyxDQUFDO1lBQ3BELElBQUksQ0FBQyxTQUFTLENBQUMsQ0FBQyxDQUFDLENBQUMsT0FBTyxFQUFFLENBQUE7WUFDM0IsSUFBSSxDQUFDLFNBQVMsQ0FBQyxDQUFDLENBQUMsR0FBRyxJQUFJLENBQUM7U0FDNUI7UUFDRCxJQUFJLENBQUMsV0FBVyxFQUFFLENBQUM7SUFDdkIsQ0FBQztJQUVEOzs7T0FHRztJQUNJLDRCQUFTLEdBQWhCLFVBQWlCLEtBQVU7UUFDdkIsSUFBSSxNQUFNLEdBQUcsSUFBSSxDQUFDLEtBQUssQ0FBQyxNQUFNLENBQUM7UUFDL0IsS0FBSyxJQUFJLENBQUMsR0FBRyxDQUFDLEVBQUUsR0FBRyxHQUFHLEtBQUssQ0FBQyxNQUFNLEVBQUUsQ0FBQyxHQUFHLEdBQUcsRUFBRSxFQUFFLENBQUMsRUFBRTtZQUM5QyxJQUFJLElBQUksR0FBRyxLQUFLLENBQUMsQ0FBQyxDQUFDLENBQUM7WUFDcEIsSUFBSSxDQUFDLEtBQUssQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLENBQUM7WUFDdEIsSUFBSSxLQUFLLEdBQUcsTUFBTSxHQUFHLENBQUMsQ0FBQztZQUN2QixJQUFJLENBQUMsZ0JBQWdCLENBQUMsS0FBSyxDQUFDLENBQUM7U0FDaEM7SUFDTCxDQUFDO0lBQ0Q7Ozs7T0FJRztJQUNJLDZCQUFVLEdBQWpCLFVBQWtCLElBQU8sRUFBRSxXQUFtQjtRQUMxQyxJQUFJLElBQUksQ0FBQyxLQUFLLENBQUMsTUFBTSxJQUFJLFdBQVcsRUFBRTtZQUNsQyxJQUFJLENBQUMsS0FBSyxDQUFDLE1BQU0sQ0FBQyxXQUFXLEVBQUUsQ0FBQyxFQUFFLElBQUksQ0FBQyxDQUFDO1lBQ3hDLElBQUksQ0FBQyxnQkFBZ0IsQ0FBQyxXQUFXLENBQUMsQ0FBQztTQUN0QzthQUFNO1lBQ0gsSUFBSSxDQUFDLFNBQVMsQ0FBQyxDQUFDLElBQUksQ0FBQyxDQUFDLENBQUM7U0FDMUI7SUFDTCxDQUFDO0lBQ0Q7OztPQUdHO0lBQ0ksNkJBQVUsR0FBakIsVUFBa0IsV0FBbUI7UUFBckMsaUJBaUNDO1FBaENHLElBQUksSUFBSSxDQUFDLEtBQUssQ0FBQyxNQUFNLElBQUksV0FBVyxFQUFFO1lBQ2xDLElBQUksQ0FBQyxLQUFLLENBQUMsTUFBTSxDQUFDLFdBQVcsRUFBRSxDQUFDLENBQUMsQ0FBQztZQUNsQyxJQUFJLElBQUksQ0FBQyxVQUFVLEVBQUU7Z0JBQ2pCLElBQUksV0FBUyxHQUFHLFdBQVcsR0FBRyxJQUFJLENBQUMsYUFBYSxDQUFDO2dCQUNqRCxRQUFRO2dCQUNSLElBQUksV0FBUyxJQUFJLENBQUMsSUFBSSxXQUFTLEdBQUcsSUFBSSxDQUFDLFVBQVUsRUFBRTtvQkFDL0MsSUFBSSxRQUFRLEdBQUcsSUFBSSxDQUFDLFNBQVMsQ0FBQyxXQUFTLENBQUMsQ0FBQztvQkFDekMsSUFBSSxTQUFTLEdBQUcsYUFBYSxDQUFDLFFBQVEsRUFBRSxDQUFDLElBQUksRUFBRSxJQUFJLEVBQUUsSUFBSSxFQUFFLElBQUksQ0FBQyxDQUFDLENBQUM7b0JBQ2xFLElBQUksVUFBVSxHQUFHLEVBQUUsQ0FBQyxJQUFJLENBQUMsQ0FBQyxRQUFRLENBQUMsSUFBSSxDQUFDLEtBQUssRUFBRSxDQUFDLFFBQVEsQ0FBQyxJQUFJLENBQUMsTUFBTSxDQUFDLENBQUM7b0JBQ3RFLFFBQVEsQ0FBQyxJQUFJLEdBQUcsRUFBRSxDQUFDLElBQUksQ0FBQyxDQUFDLEVBQUUsQ0FBQyxDQUFDLENBQUM7b0JBQzlCLElBQUksQ0FBQyxjQUFjLENBQUMsUUFBUSxFQUFFLFNBQVMsRUFBRSxVQUFVLENBQUMsQ0FBQyxJQUFJLENBQUM7d0JBQ3RELE1BQU07d0JBQ04sS0FBSyxJQUFJLENBQUMsR0FBRyxXQUFTLEVBQUUsQ0FBQyxHQUFHLEtBQUksQ0FBQyxVQUFVLEVBQUUsQ0FBQyxFQUFFLEVBQUU7NEJBQzlDLElBQUksWUFBWSxHQUFHLEtBQUksQ0FBQyxhQUFhLEdBQUcsQ0FBQyxDQUFDOzRCQUMxQyxJQUFJLE9BQU8sR0FBRyxLQUFJLENBQUMsS0FBSyxDQUFDLFlBQVksQ0FBQyxDQUFDOzRCQUN2QyxJQUFJLFdBQVcsR0FBWSxPQUFPLENBQUMsSUFBSSxDQUFDLENBQUMsQ0FBQyxPQUFPLENBQUMsSUFBSSxDQUFDLENBQUMsQ0FBQyxLQUFJLENBQUMsSUFBSSxDQUFDOzRCQUNuRSxLQUFJLENBQUMsU0FBUyxDQUFDLENBQUMsQ0FBQyxDQUFDLElBQUksQ0FBQyxPQUFPLEVBQUUsV0FBVyxFQUFFLFlBQVksRUFBRSxDQUFDLEVBQUUsS0FBSSxDQUFDLENBQUM7NEJBQ3BFLEtBQUksQ0FBQyxTQUFTLENBQUMsQ0FBQyxDQUFDLENBQUMsY0FBYyxDQUFDLEtBQUksQ0FBQyxXQUFXLENBQUMsQ0FBQzt5QkFDdEQ7b0JBQ0wsQ0FBQyxDQUFDLENBQUM7aUJBQ047YUFDSjtpQkFBTTtnQkFDSCxJQUFJLFVBQVEsR0FBRyxJQUFJLENBQUMsU0FBUyxDQUFDLE1BQU0sQ0FBQyxXQUFXLEVBQUUsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUM7Z0JBQ3hELElBQUksU0FBUyxHQUFHLGFBQWEsQ0FBQyxVQUFRLEVBQUUsQ0FBQyxJQUFJLEVBQUUsSUFBSSxFQUFFLElBQUksRUFBRSxJQUFJLENBQUMsQ0FBQyxDQUFDO2dCQUNsRSxJQUFJLFVBQVUsR0FBRyxFQUFFLENBQUMsSUFBSSxDQUFDLENBQUMsVUFBUSxDQUFDLElBQUksQ0FBQyxLQUFLLEVBQUUsQ0FBQyxVQUFRLENBQUMsSUFBSSxDQUFDLE1BQU0sQ0FBQyxDQUFDO2dCQUN0RSxVQUFRLENBQUMsSUFBSSxHQUFHLEVBQUUsQ0FBQyxJQUFJLENBQUMsQ0FBQyxFQUFFLENBQUMsQ0FBQyxDQUFDO2dCQUM5QixJQUFJLENBQUMsY0FBYyxDQUFDLFVBQVEsRUFBRSxTQUFTLEVBQUUsVUFBVSxDQUFDLENBQUMsSUFBSSxDQUFDO29CQUN0RCxLQUFJLENBQUMsZ0JBQWdCLENBQUMsVUFBUSxDQUFDLFFBQVEsRUFBRSxDQUFDLENBQUE7b0JBQzFDLFVBQVEsQ0FBQyxJQUFJLENBQUMsT0FBTyxFQUFFLENBQUM7Z0JBQzVCLENBQUMsQ0FBQyxDQUFDO2FBQ047U0FDSjtJQUNMLENBQUM7SUFDRDs7O09BR0c7SUFDVyxtQ0FBZ0IsR0FBOUIsVUFBK0IsU0FBaUI7Ozs7Ozt3QkFDeEMsSUFBSSxHQUFHLElBQUksQ0FBQyxLQUFLLENBQUMsU0FBUyxDQUFDLENBQUM7d0JBQzdCLFFBQVEsR0FBWSxJQUFJLENBQUMsSUFBSSxDQUFDLENBQUMsQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLENBQUMsQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDOzZCQUV0RCxJQUFJLENBQUMsVUFBVSxFQUFmLHdCQUFlO3dCQUNYLFNBQVMsR0FBRyxTQUFTLEdBQUcsSUFBSSxDQUFDLGFBQWEsQ0FBQzt3QkFDL0MsUUFBUTt3QkFDUixJQUFJLFNBQVMsSUFBSSxDQUFDLElBQUksU0FBUyxHQUFHLElBQUksQ0FBQyxVQUFVLEVBQUU7NEJBQy9DLE1BQU07NEJBQ04sS0FBUyxDQUFDLEdBQUcsU0FBUyxFQUFFLENBQUMsR0FBRyxJQUFJLENBQUMsVUFBVSxFQUFFLENBQUMsRUFBRSxFQUFFO2dDQUMxQyxZQUFZLEdBQUcsSUFBSSxDQUFDLGFBQWEsR0FBRyxDQUFDLENBQUM7Z0NBQ3RDLE9BQU8sR0FBRyxJQUFJLENBQUMsS0FBSyxDQUFDLFlBQVksQ0FBQyxDQUFDO2dDQUNuQyxXQUFXLEdBQVksT0FBTyxDQUFDLElBQUksQ0FBQyxDQUFDLENBQUMsT0FBTyxDQUFDLElBQUksQ0FBQyxDQUFDLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQztnQ0FDbkUsSUFBSSxDQUFDLFNBQVMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxJQUFJLENBQUMsT0FBTyxFQUFFLFdBQVcsRUFBRSxZQUFZLEVBQUUsQ0FBQyxFQUFFLElBQUksQ0FBQyxDQUFDO2dDQUNwRSxJQUFJLENBQUMsU0FBUyxDQUFDLENBQUMsQ0FBQyxDQUFDLGNBQWMsQ0FBQyxJQUFJLENBQUMsV0FBVyxDQUFDLENBQUM7NkJBQ3REOzRCQUVHLFNBQVMsR0FBWSxJQUFJLENBQUM7NEJBQzFCLGFBQXdCLElBQUksQ0FBQyxTQUFTLENBQUMsU0FBUyxDQUFDLENBQUM7NEJBQ3RELElBQUksVUFBUSxFQUFFO2dDQUNWLFNBQVMsR0FBRyxhQUFhLENBQUMsVUFBUSxFQUFFLENBQUMsSUFBSSxFQUFFLElBQUksRUFBRSxJQUFJLEVBQUUsSUFBSSxDQUFDLENBQUMsQ0FBQztnQ0FDOUQsVUFBUSxDQUFDLElBQUksQ0FBQyxLQUFLLEdBQUcsQ0FBQyxDQUFDO2dDQUN4QixVQUFRLENBQUMsSUFBSSxDQUFDLE1BQU0sR0FBRyxDQUFDLENBQUM7Z0NBQ3pCLElBQUksQ0FBQyxjQUFjLENBQUMsVUFBUSxFQUFFLFNBQVMsRUFBRSxRQUFRLENBQUMsQ0FBQyxJQUFJLENBQUM7b0NBQ3BELFVBQVEsQ0FBQyxJQUFJLENBQUMsS0FBSyxHQUFHLFFBQVEsQ0FBQyxLQUFLLENBQUM7b0NBQ3JDLFVBQVEsQ0FBQyxJQUFJLENBQUMsTUFBTSxHQUFHLFFBQVEsQ0FBQyxNQUFNLENBQUM7Z0NBQzNDLENBQUMsQ0FBQyxDQUFDOzZCQUNOO3lCQUNKOzs7d0JBR0csY0FBcUIsSUFBSSxDQUFDO3dCQUM5QixJQUFJLElBQUksQ0FBQyxTQUFTLENBQUMsU0FBUyxDQUFDLEVBQUU7NEJBQzNCLFdBQVMsR0FBRyxhQUFhLENBQUMsSUFBSSxDQUFDLFNBQVMsQ0FBQyxTQUFTLENBQUMsRUFBRSxDQUFDLElBQUksRUFBRSxJQUFJLEVBQUUsSUFBSSxFQUFFLElBQUksQ0FBQyxDQUFDLENBQUM7eUJBQ2xGO3dCQUNHLElBQUksR0FBRyxJQUFJLEVBQUUsQ0FBQyxJQUFJLENBQUMsY0FBYyxDQUFDLENBQUE7d0JBQ3RDLElBQUksQ0FBQyxjQUFjLENBQUMsSUFBSSxDQUFDLE1BQU0sQ0FBQyxDQUFDO3dCQUNqQyxJQUFJLENBQUMsU0FBUyxDQUFDLElBQUksQ0FBQyxVQUFVLENBQUMsT0FBTyxDQUFDLENBQUM7d0JBQ3hDLElBQUksQ0FBQyxlQUFlLENBQUMsU0FBUyxDQUFDLENBQUM7d0JBQzVCLGFBQXdCLElBQUksUUFBUSxDQUFJLElBQUksRUFBRSxJQUFJLENBQUMsQ0FBQzt3QkFDeEQsSUFBSSxDQUFDLFNBQVMsQ0FBQyxNQUFNLENBQUMsU0FBUyxFQUFFLENBQUMsRUFBRSxVQUFRLENBQUMsQ0FBQTt3QkFDN0MsVUFBUSxDQUFDLElBQUksQ0FBQyxJQUFJLEVBQUUsUUFBUSxFQUFFLFNBQVMsRUFBRSxTQUFTLEVBQUUsSUFBSSxDQUFDLENBQUM7NkJBQ3RELENBQUMsV0FBUyxFQUFWLHdCQUFVO3dCQUNWLHFCQUFNLElBQUksT0FBTyxDQUFPLFVBQUMsT0FBTyxFQUFFLE1BQU07Z0NBQ3BDLHFCQUFxQixDQUFDO29DQUNsQixXQUFTLEdBQUcsYUFBYSxDQUFDLFVBQVEsRUFBRSxDQUFDLElBQUksRUFBRSxJQUFJLEVBQUUsSUFBSSxFQUFFLElBQUksQ0FBQyxDQUFDLENBQUM7b0NBQzlELE9BQU8sRUFBRSxDQUFDO2dDQUNkLENBQUMsQ0FBQyxDQUFBOzRCQUNOLENBQUMsQ0FBQyxFQUFBOzt3QkFMRixTQUtFLENBQUM7Ozt3QkFFUCxJQUFJLFdBQVMsRUFBRTs0QkFDWCxVQUFRLENBQUMsSUFBSSxDQUFDLEtBQUssR0FBRyxDQUFDLENBQUM7NEJBQ3hCLFVBQVEsQ0FBQyxJQUFJLENBQUMsTUFBTSxHQUFHLENBQUMsQ0FBQzs0QkFDekIsSUFBSSxDQUFDLGNBQWMsQ0FBQyxVQUFRLEVBQUUsV0FBUyxFQUFFLFFBQVEsQ0FBQyxDQUFDLElBQUksQ0FBQztnQ0FDcEQsVUFBUSxDQUFDLElBQUksQ0FBQyxLQUFLLEdBQUcsUUFBUSxDQUFDLEtBQUssQ0FBQztnQ0FDckMsVUFBUSxDQUFDLElBQUksQ0FBQyxNQUFNLEdBQUcsUUFBUSxDQUFDLE1BQU0sQ0FBQzs0QkFDM0MsQ0FBQyxDQUFDLENBQUM7eUJBQ047d0JBQ0QsSUFBSSxDQUFDLFlBQVksQ0FBQyxVQUFRLENBQUMsQ0FBQzs7Ozs7O0tBRW5DO0lBRUQ7Ozs7T0FJRztJQUNLLCtCQUFZLEdBQXBCLFVBQXFCLE1BQWUsRUFBRSxTQUF3QjtRQUMxRCxJQUFJLFNBQVMsR0FBRyxTQUFTLENBQUMsQ0FBQyxDQUFDLENBQUM7UUFDN0IsSUFBSSxPQUFPLEdBQUcsU0FBUyxDQUFDLFNBQVMsQ0FBQyxNQUFNLEdBQUcsQ0FBQyxDQUFDLENBQUM7UUFDOUMsSUFBSSxJQUFJLENBQUMsVUFBVSxDQUFDLFFBQVEsRUFBRTtZQUMxQixVQUFVO1lBQ1YsSUFBSSxNQUFNLENBQUMsQ0FBQyxHQUFHLENBQUMsRUFBRTtnQkFDZCxxQkFBcUI7Z0JBQ3JCLElBQUksSUFBSSxDQUFDLFVBQVUsQ0FBQyxPQUFPLENBQUMsQ0FBQyxJQUFJLENBQUMsQ0FBRSxJQUFJLENBQUMsU0FBUyxDQUFDLElBQUksQ0FBQyxTQUFTLENBQUMsTUFBTSxHQUFHLENBQUMsQ0FBQyxDQUFDLElBQUksQ0FBQyxDQUFDLEdBQUcsSUFBSSxDQUFDLFNBQVMsQ0FBQyxJQUFJLENBQUMsTUFBTSxDQUFDLElBQUksT0FBTyxDQUFDLFNBQVMsR0FBRyxJQUFJLENBQUMsS0FBSyxDQUFDLE1BQU0sR0FBRyxDQUFDLEVBQUU7b0JBQzdKLG1DQUFtQztvQkFDbkMsSUFBSSxTQUFTLEdBQUcsU0FBUyxDQUFDLFNBQVMsR0FBRyxDQUFDLENBQUM7b0JBQ3hDLFlBQVk7b0JBQ1osSUFBSSxLQUFLLEdBQUcsSUFBSSxDQUFDLEtBQUssQ0FBQyxNQUFNLEdBQUcsU0FBUyxDQUFDO29CQUMxQyw2Q0FBNkM7b0JBQzdDLElBQUksY0FBYyxHQUFHLElBQUksQ0FBQyxHQUFHLENBQUMsQ0FBQyxFQUFFLElBQUksQ0FBQyxTQUFTLENBQUMsTUFBTSxHQUFHLEtBQUssQ0FBQyxDQUFDO29CQUNoRSxnQkFBZ0I7b0JBQ2hCLElBQUksQ0FBQyxhQUFhLEdBQUcsU0FBUyxHQUFHLGNBQWMsQ0FBQztvQkFFaEQsSUFBSSxPQUFPLEdBQUcsYUFBYSxDQUFDLElBQUksQ0FBQyxTQUFTLENBQUMsU0FBUyxDQUFDLFNBQVMsQ0FBQyxFQUFFLENBQUMsSUFBSSxDQUFDLENBQUMsQ0FBQyxPQUFPLENBQUM7b0JBRWpGLElBQUksYUFBYSxHQUFHLENBQUMsQ0FBQztvQkFDdEIsSUFBSSxPQUFPLEdBQUcsQ0FBQyxDQUFDO29CQUNoQixJQUFJLFNBQVMsR0FBRyxJQUFJLENBQUM7b0JBQ3JCLElBQUksU0FBUyxHQUFHLENBQUMsQ0FBQztvQkFDbEIsS0FBSyxJQUFJLENBQUMsR0FBRyxDQUFDLEVBQUUsR0FBRyxHQUFHLElBQUksQ0FBQyxTQUFTLENBQUMsTUFBTSxFQUFFLENBQUMsR0FBRyxHQUFHLEVBQUUsRUFBRSxDQUFDLEVBQUU7d0JBQ3ZELElBQUksQ0FBQyxJQUFJLGNBQWMsRUFBRTs0QkFDckIsa0NBQWtDOzRCQUNsQyxJQUFJLFNBQVMsR0FBRyxTQUFTLENBQUMsTUFBTSxJQUFJLENBQUMsU0FBUyxFQUFFO2dDQUM1QyxJQUFJLFNBQVMsSUFBSSxDQUFDLEVBQUU7b0NBQ2hCLE9BQU8sR0FBRyxhQUFhLENBQUM7aUNBQzNCO2dDQUNELElBQUksUUFBUSxHQUFHLFNBQVMsQ0FBQyxTQUFTLENBQUMsQ0FBQyxZQUFZLEVBQUUsQ0FBQztnQ0FDbkQsU0FBUyxFQUFFLENBQUM7Z0NBQ1osSUFBSSxDQUFDLFNBQVMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxXQUFXLENBQUMsUUFBUSxDQUFDLENBQUM7NkJBQzNDOzRCQUNELFNBQVMsR0FBRyxLQUFLLENBQUM7eUJBQ3JCO3dCQUNELElBQUksU0FBUyxHQUFHLElBQUksQ0FBQyxhQUFhLEdBQUcsQ0FBQyxDQUFDO3dCQUN2QyxJQUFJLElBQUksR0FBRyxJQUFJLENBQUMsS0FBSyxDQUFDLFNBQVMsQ0FBQyxDQUFDO3dCQUNqQyxJQUFJLFFBQVEsR0FBRyxJQUFJLENBQUMsSUFBSSxDQUFDLENBQUMsQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLENBQUMsQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDO3dCQUNqRCxhQUFhLElBQUksUUFBUSxDQUFDLE1BQU0sQ0FBQzt3QkFDakMsSUFBSSxDQUFDLFNBQVMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxJQUFJLENBQUMsSUFBSSxFQUFFLFFBQVEsRUFBRSxTQUFTLEVBQUUsQ0FBQyxFQUFFLElBQUksQ0FBQyxDQUFDO3FCQUM5RDtvQkFFRCw0QkFBNEI7b0JBQzVCLElBQUksSUFBSSxHQUFHLE9BQU8sR0FBRyxDQUFDLE9BQU8sR0FBRyxJQUFJLENBQUMsU0FBUyxDQUFDLE9BQU8sQ0FBQyxDQUFBO29CQUN2RCxJQUFJLENBQUMsVUFBVSxDQUFDLE9BQU8sQ0FBQyxXQUFXLENBQUMsRUFBRSxDQUFDLEVBQUUsQ0FBQyxJQUFJLENBQUMsVUFBVSxDQUFDLE9BQU8sQ0FBQyxRQUFRLENBQUMsQ0FBQyxFQUFFLElBQUksQ0FBQyxDQUFDLENBQUM7b0JBQ3JGLElBQUksQ0FBQyxVQUFVLENBQUMsY0FBYyxDQUFDLEVBQUUsQ0FBQyxFQUFFLENBQUMsQ0FBQyxFQUFFLElBQUksR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLE1BQU0sQ0FBQyxFQUFFLENBQUMsQ0FBQyxDQUFBO29CQUN2RSxJQUFJLENBQUMsT0FBTyxHQUFHLElBQUksQ0FBQztpQkFDdkI7YUFDSixDQUFDLE1BQU07aUJBQ0gsSUFBSSxNQUFNLENBQUMsQ0FBQyxHQUFHLENBQUMsRUFBRTtnQkFDbkIsaUJBQWlCO2dCQUNqQixJQUFJLElBQUksQ0FBQyxVQUFVLENBQUMsT0FBTyxDQUFDLENBQUMsR0FBRyxDQUFDLENBQUUsSUFBSSxDQUFDLFNBQVMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxJQUFJLENBQUMsQ0FBQyxDQUFDLElBQUksU0FBUyxDQUFDLFNBQVMsR0FBRyxDQUFDLEVBQUU7b0JBQ3JGLDZCQUE2QjtvQkFDN0IsSUFBSSxZQUFZLEdBQUcsT0FBTyxDQUFDLFNBQVMsR0FBRyxDQUFDLENBQUM7b0JBQ3pDLDZDQUE2QztvQkFDN0MsSUFBSSxZQUFZLEdBQUcsSUFBSSxDQUFDLEdBQUcsQ0FBQyxJQUFJLENBQUMsU0FBUyxDQUFDLE1BQU0sR0FBRyxDQUFDLEVBQUUsWUFBWSxHQUFHLENBQUMsQ0FBQyxDQUFDO29CQUN6RSxnQkFBZ0I7b0JBQ2hCLElBQUksQ0FBQyxhQUFhLEdBQUcsSUFBSSxDQUFDLEdBQUcsQ0FBQyxZQUFZLEdBQUcsQ0FBQyxJQUFJLENBQUMsU0FBUyxDQUFDLE1BQU0sR0FBRyxDQUFDLENBQUMsRUFBRSxDQUFDLENBQUMsQ0FBQztvQkFFN0UsNEJBQTRCO29CQUM1QixJQUFJLE9BQU8sR0FBRyxhQUFhLENBQUMsSUFBSSxDQUFDLFNBQVMsQ0FBQyxTQUFTLENBQUMsU0FBUyxDQUFDLEVBQUUsQ0FBQyxJQUFJLENBQUMsQ0FBQyxDQUFDLE9BQU8sQ0FBQztvQkFFakYsSUFBSSxhQUFhLEdBQUcsQ0FBQyxDQUFDO29CQUN0QixJQUFJLFNBQVMsR0FBRyxTQUFTLENBQUMsTUFBTSxHQUFHLENBQUMsQ0FBQztvQkFDckMsS0FBSyxJQUFJLENBQUMsR0FBRyxJQUFJLENBQUMsU0FBUyxDQUFDLE1BQU0sR0FBRyxDQUFDLEVBQUUsQ0FBQyxJQUFJLENBQUMsRUFBRSxFQUFFLENBQUMsRUFBRTt3QkFDakQsSUFBSSxDQUFDLElBQUksWUFBWSxFQUFFOzRCQUNuQixrQ0FBa0M7NEJBQ2xDLElBQUksU0FBUyxJQUFJLENBQUMsRUFBRTtnQ0FDaEIsSUFBSSxRQUFRLEdBQUcsU0FBUyxDQUFDLFNBQVMsQ0FBQyxDQUFDLFlBQVksRUFBRSxDQUFDO2dDQUNuRCxTQUFTLEVBQUUsQ0FBQztnQ0FDWixJQUFJLENBQUMsU0FBUyxDQUFDLENBQUMsQ0FBQyxDQUFDLFdBQVcsQ0FBQyxRQUFRLENBQUMsQ0FBQzs2QkFDM0M7aUNBQU07Z0NBQ0gsU0FBUyxFQUFFLENBQUM7NkJBQ2Y7eUJBQ0o7d0JBQ0QsSUFBSSxTQUFTLEdBQUcsSUFBSSxDQUFDLGFBQWEsR0FBRyxDQUFDLENBQUM7d0JBQ3ZDLElBQUksSUFBSSxHQUFHLElBQUksQ0FBQyxLQUFLLENBQUMsU0FBUyxDQUFDLENBQUM7d0JBQ2pDLElBQUksUUFBUSxHQUFHLElBQUksQ0FBQyxJQUFJLENBQUMsQ0FBQyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsQ0FBQyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUM7d0JBQ2pELElBQUksU0FBUyxHQUFHLENBQUMsQ0FBQyxFQUFFOzRCQUNoQixhQUFhLElBQUksUUFBUSxDQUFDLE1BQU0sQ0FBQzt5QkFDcEM7d0JBQ0QsSUFBSSxDQUFDLFNBQVMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxJQUFJLENBQUMsSUFBSSxFQUFFLFFBQVEsRUFBRSxTQUFTLEVBQUUsQ0FBQyxFQUFFLElBQUksQ0FBQyxDQUFDO3FCQUM5RDtvQkFFRCw0QkFBNEI7b0JBQzVCLElBQUksSUFBSSxHQUFHLGFBQWEsR0FBRyxDQUFDLE9BQU8sR0FBRyxJQUFJLENBQUMsU0FBUyxDQUFDLE9BQU8sQ0FBQyxDQUFBO29CQUM3RCxJQUFJLENBQUMsVUFBVSxDQUFDLE9BQU8sQ0FBQyxXQUFXLENBQUMsRUFBRSxDQUFDLEVBQUUsQ0FBQyxJQUFJLENBQUMsVUFBVSxDQUFDLE9BQU8sQ0FBQyxRQUFRLENBQUMsQ0FBQyxFQUFFLElBQUksQ0FBQyxDQUFDLENBQUM7b0JBQ3JGLElBQUksQ0FBQyxVQUFVLENBQUMsY0FBYyxDQUFDLEVBQUUsQ0FBQyxFQUFFLENBQUMsQ0FBQyxFQUFFLElBQUksR0FBRyxTQUFTLENBQUMsSUFBSSxDQUFDLE1BQU0sQ0FBQyxFQUFFLENBQUMsQ0FBQyxDQUFBO29CQUN6RSxJQUFJLENBQUMsT0FBTyxHQUFHLElBQUksQ0FBQztpQkFDdkI7YUFDSjtTQUNKO2FBQU0sSUFBSSxJQUFJLENBQUMsVUFBVSxDQUFDLFVBQVUsRUFBRTtZQUNuQyxJQUFJLE1BQU0sQ0FBQyxDQUFDLEdBQUcsQ0FBQyxFQUFFO2dCQUNkLHFCQUFxQjtnQkFDckIsSUFBSSxJQUFJLENBQUMsVUFBVSxDQUFDLE9BQU8sQ0FBQyxDQUFDLElBQUksQ0FBQyxDQUFFLENBQUMsSUFBSSxDQUFDLFNBQVMsQ0FBQyxJQUFJLENBQUMsU0FBUyxDQUFDLE1BQU0sR0FBRyxDQUFDLENBQUMsQ0FBQyxJQUFJLENBQUMsQ0FBQyxHQUFHLElBQUksQ0FBQyxTQUFTLENBQUMsSUFBSSxDQUFDLEtBQUssQ0FBQyxDQUFDLElBQUksT0FBTyxDQUFDLFNBQVMsR0FBRyxJQUFJLENBQUMsS0FBSyxDQUFDLE1BQU0sR0FBRyxDQUFDLEVBQUU7b0JBQzlKLG1DQUFtQztvQkFDbkMsSUFBSSxTQUFTLEdBQUcsU0FBUyxDQUFDLFNBQVMsR0FBRyxDQUFDLENBQUM7b0JBQ3hDLFlBQVk7b0JBQ1osSUFBSSxLQUFLLEdBQUcsSUFBSSxDQUFDLEtBQUssQ0FBQyxNQUFNLEdBQUcsU0FBUyxDQUFDO29CQUMxQyw2Q0FBNkM7b0JBQzdDLElBQUksY0FBYyxHQUFHLElBQUksQ0FBQyxHQUFHLENBQUMsQ0FBQyxFQUFFLElBQUksQ0FBQyxTQUFTLENBQUMsTUFBTSxHQUFHLEtBQUssQ0FBQyxDQUFDO29CQUNoRSxnQkFBZ0I7b0JBQ2hCLElBQUksQ0FBQyxhQUFhLEdBQUcsU0FBUyxHQUFHLGNBQWMsQ0FBQztvQkFFaEQsSUFBSSxRQUFRLEdBQUcsYUFBYSxDQUFDLElBQUksQ0FBQyxTQUFTLENBQUMsU0FBUyxDQUFDLFNBQVMsQ0FBQyxFQUFFLENBQUMsS0FBSyxFQUFFLEtBQUssRUFBRSxJQUFJLENBQUMsQ0FBQyxDQUFDLFFBQVEsQ0FBQztvQkFFakcsSUFBSSxZQUFZLEdBQUcsQ0FBQyxDQUFDO29CQUNyQixJQUFJLE9BQU8sR0FBRyxDQUFDLENBQUM7b0JBQ2hCLElBQUksU0FBUyxHQUFHLElBQUksQ0FBQztvQkFDckIsSUFBSSxTQUFTLEdBQUcsQ0FBQyxDQUFDO29CQUNsQixLQUFLLElBQUksQ0FBQyxHQUFHLENBQUMsRUFBRSxHQUFHLEdBQUcsSUFBSSxDQUFDLFNBQVMsQ0FBQyxNQUFNLEVBQUUsQ0FBQyxHQUFHLEdBQUcsRUFBRSxFQUFFLENBQUMsRUFBRTt3QkFDdkQsSUFBSSxDQUFDLElBQUksY0FBYyxFQUFFOzRCQUNyQixrQ0FBa0M7NEJBQ2xDLElBQUksU0FBUyxHQUFHLFNBQVMsQ0FBQyxNQUFNLElBQUksQ0FBQyxTQUFTLEVBQUU7Z0NBQzVDLElBQUksU0FBUyxJQUFJLENBQUMsRUFBRTtvQ0FDaEIsT0FBTyxHQUFHLFlBQVksQ0FBQztpQ0FDMUI7Z0NBQ0QsSUFBSSxRQUFRLEdBQUcsU0FBUyxDQUFDLFNBQVMsQ0FBQyxDQUFDLFlBQVksRUFBRSxDQUFDO2dDQUNuRCxTQUFTLEVBQUUsQ0FBQztnQ0FDWixJQUFJLENBQUMsU0FBUyxDQUFDLENBQUMsQ0FBQyxDQUFDLFdBQVcsQ0FBQyxRQUFRLENBQUMsQ0FBQzs2QkFDM0M7NEJBQ0QsU0FBUyxHQUFHLEtBQUssQ0FBQzt5QkFDckI7d0JBQ0QsSUFBSSxTQUFTLEdBQUcsSUFBSSxDQUFDLGFBQWEsR0FBRyxDQUFDLENBQUM7d0JBQ3ZDLElBQUksSUFBSSxHQUFHLElBQUksQ0FBQyxLQUFLLENBQUMsU0FBUyxDQUFDLENBQUM7d0JBQ2pDLElBQUksUUFBUSxHQUFHLElBQUksQ0FBQyxJQUFJLENBQUMsQ0FBQyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsQ0FBQyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUM7d0JBQ2pELFlBQVksSUFBSSxRQUFRLENBQUMsS0FBSyxDQUFDO3dCQUMvQixJQUFJLENBQUMsU0FBUyxDQUFDLENBQUMsQ0FBQyxDQUFDLElBQUksQ0FBQyxJQUFJLEVBQUUsUUFBUSxFQUFFLFNBQVMsRUFBRSxDQUFDLEVBQUUsSUFBSSxDQUFDLENBQUM7cUJBQzlEO29CQUVELDRCQUE0QjtvQkFDNUIsSUFBSSxJQUFJLEdBQUcsQ0FBQyxRQUFRLEdBQUcsSUFBSSxDQUFDLFNBQVMsQ0FBQyxRQUFRLENBQUMsR0FBRyxPQUFPLENBQUM7b0JBQzFELElBQUksQ0FBQyxVQUFVLENBQUMsT0FBTyxDQUFDLFdBQVcsQ0FBQyxFQUFFLENBQUMsRUFBRSxDQUFDLElBQUksRUFBRSxJQUFJLENBQUMsVUFBVSxDQUFDLE9BQU8sQ0FBQyxRQUFRLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQztvQkFDckYsSUFBSSxDQUFDLFVBQVUsQ0FBQyxjQUFjLENBQUMsRUFBRSxDQUFDLEVBQUUsQ0FBQyxDQUFDLENBQUMsSUFBSSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsS0FBSyxDQUFDLEVBQUUsQ0FBQyxDQUFDLEVBQUUsQ0FBQyxDQUFDLENBQUE7b0JBQ3pFLElBQUksQ0FBQyxPQUFPLEdBQUcsSUFBSSxDQUFDO2lCQUN2QjthQUNKO2lCQUFNLElBQUksTUFBTSxDQUFDLENBQUMsR0FBRyxDQUFDLEVBQUU7Z0JBQ3JCLGlCQUFpQjtnQkFDakIsSUFBSSxJQUFJLENBQUMsVUFBVSxDQUFDLE9BQU8sQ0FBQyxDQUFDLEdBQUcsQ0FBQyxDQUFDLElBQUksQ0FBQyxTQUFTLENBQUMsQ0FBQyxDQUFDLENBQUMsSUFBSSxDQUFDLENBQUMsQ0FBQyxJQUFJLFNBQVMsQ0FBQyxTQUFTLEdBQUcsQ0FBQyxFQUFFO29CQUNwRiw2QkFBNkI7b0JBQzdCLElBQUksWUFBWSxHQUFHLE9BQU8sQ0FBQyxTQUFTLEdBQUcsQ0FBQyxDQUFDO29CQUN6Qyw2Q0FBNkM7b0JBQzdDLElBQUksWUFBWSxHQUFHLElBQUksQ0FBQyxHQUFHLENBQUMsSUFBSSxDQUFDLFNBQVMsQ0FBQyxNQUFNLEdBQUcsQ0FBQyxFQUFFLFlBQVksR0FBRyxDQUFDLENBQUMsQ0FBQztvQkFDekUsZ0JBQWdCO29CQUNoQixJQUFJLENBQUMsYUFBYSxHQUFHLElBQUksQ0FBQyxHQUFHLENBQUMsWUFBWSxHQUFHLENBQUMsSUFBSSxDQUFDLFNBQVMsQ0FBQyxNQUFNLEdBQUcsQ0FBQyxDQUFDLEVBQUUsQ0FBQyxDQUFDLENBQUM7b0JBRTdFLDRCQUE0QjtvQkFDNUIsSUFBSSxRQUFRLEdBQUcsYUFBYSxDQUFDLElBQUksQ0FBQyxTQUFTLENBQUMsU0FBUyxDQUFDLFNBQVMsQ0FBQyxFQUFFLENBQUMsS0FBSyxFQUFFLEtBQUssRUFBRSxJQUFJLENBQUMsQ0FBQyxDQUFDLFFBQVEsQ0FBQztvQkFFakcsSUFBSSxZQUFZLEdBQUcsQ0FBQyxDQUFDO29CQUNyQixJQUFJLFNBQVMsR0FBRyxTQUFTLENBQUMsTUFBTSxHQUFHLENBQUMsQ0FBQztvQkFDckMsS0FBSyxJQUFJLENBQUMsR0FBRyxJQUFJLENBQUMsU0FBUyxDQUFDLE1BQU0sR0FBRyxDQUFDLEVBQUUsQ0FBQyxJQUFJLENBQUMsRUFBRSxFQUFFLENBQUMsRUFBRTt3QkFDakQsSUFBSSxDQUFDLElBQUksWUFBWSxFQUFFOzRCQUNuQixrQ0FBa0M7NEJBQ2xDLElBQUksU0FBUyxJQUFJLENBQUMsRUFBRTtnQ0FDaEIsSUFBSSxRQUFRLEdBQUcsU0FBUyxDQUFDLFNBQVMsQ0FBQyxDQUFDLFlBQVksRUFBRSxDQUFDO2dDQUNuRCxTQUFTLEVBQUUsQ0FBQztnQ0FDWixJQUFJLENBQUMsU0FBUyxDQUFDLENBQUMsQ0FBQyxDQUFDLFdBQVcsQ0FBQyxRQUFRLENBQUMsQ0FBQzs2QkFDM0M7aUNBQU07Z0NBQ0gsU0FBUyxFQUFFLENBQUM7NkJBQ2Y7eUJBQ0o7d0JBQ0QsSUFBSSxTQUFTLEdBQUcsSUFBSSxDQUFDLGFBQWEsR0FBRyxDQUFDLENBQUM7d0JBQ3ZDLElBQUksSUFBSSxHQUFHLElBQUksQ0FBQyxLQUFLLENBQUMsU0FBUyxDQUFDLENBQUM7d0JBQ2pDLElBQUksUUFBUSxHQUFHLElBQUksQ0FBQyxJQUFJLENBQUMsQ0FBQyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsQ0FBQyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUM7d0JBQ2pELElBQUksU0FBUyxHQUFHLENBQUMsQ0FBQyxFQUFFOzRCQUNoQixZQUFZLElBQUksUUFBUSxDQUFDLEtBQUssQ0FBQzt5QkFDbEM7d0JBQ0QsSUFBSSxDQUFDLFNBQVMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxJQUFJLENBQUMsSUFBSSxFQUFFLFFBQVEsRUFBRSxTQUFTLEVBQUUsQ0FBQyxFQUFFLElBQUksQ0FBQyxDQUFDO3FCQUM5RDtvQkFFRCw0QkFBNEI7b0JBQzVCLElBQUksSUFBSSxHQUFHLENBQUMsUUFBUSxHQUFHLElBQUksQ0FBQyxTQUFTLENBQUMsUUFBUSxDQUFDLEdBQUcsWUFBWSxDQUFDO29CQUMvRCxJQUFJLENBQUMsVUFBVSxDQUFDLE9BQU8sQ0FBQyxXQUFXLENBQUMsRUFBRSxDQUFDLEVBQUUsQ0FBQyxJQUFJLEVBQUUsSUFBSSxDQUFDLFVBQVUsQ0FBQyxPQUFPLENBQUMsUUFBUSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUM7b0JBQ3JGLElBQUksQ0FBQyxVQUFVLENBQUMsY0FBYyxDQUFDLEVBQUUsQ0FBQyxFQUFFLENBQUMsQ0FBRSxDQUFDLElBQUksR0FBRyxTQUFTLENBQUMsSUFBSSxDQUFDLEtBQUssQ0FBQyxFQUFFLENBQUMsQ0FBQyxFQUFFLENBQUMsQ0FBQyxDQUFBO29CQUM1RSxJQUFJLENBQUMsT0FBTyxHQUFHLElBQUksQ0FBQztpQkFDdkI7YUFDSjtTQUNKO0lBQ0wsQ0FBQztJQUdELGFBQWE7SUFDTiw4QkFBVyxHQUFsQjtRQUNJLElBQUksU0FBUyxHQUFrQixFQUFFLENBQUM7UUFDbEMsS0FBSyxJQUFJLENBQUMsR0FBRyxDQUFDLEVBQUUsR0FBRyxHQUFHLElBQUksQ0FBQyxTQUFTLENBQUMsTUFBTSxFQUFFLENBQUMsR0FBRyxHQUFHLEVBQUUsRUFBRSxDQUFDLEVBQUU7WUFDdkQsSUFBSSxRQUFRLEdBQUcsSUFBSSxDQUFDLFNBQVMsQ0FBQyxDQUFDLENBQUMsQ0FBQztZQUNqQyxJQUFJLE1BQU0sR0FBRyxJQUFJLENBQUMsWUFBWSxDQUFDLFFBQVEsQ0FBQyxDQUFBO1lBQ3hDLElBQUksTUFBTSxFQUFFO2dCQUNSLFNBQVMsQ0FBQyxJQUFJLENBQUMsUUFBUSxDQUFDLENBQUE7YUFDM0I7U0FDSjtRQUNELE9BQU8sU0FBUyxDQUFDO0lBQ3JCLENBQUM7SUFFRDs7O09BR0c7SUFDSywrQkFBWSxHQUFwQixVQUFxQixRQUFxQjtRQUN0QyxJQUFJLFFBQVEsRUFBRTtZQUNWLElBQUksTUFBTSxHQUFHLElBQUksQ0FBQyxXQUFXLENBQUMsUUFBUSxDQUFDLENBQUM7WUFDeEMsSUFBSSxNQUFNLEVBQUU7Z0JBQ1IsUUFBUSxDQUFDLFNBQVMsSUFBSSxRQUFRLENBQUMsVUFBVSxDQUFDLE1BQU0sRUFBRSxJQUFJLENBQUMsTUFBTSxFQUFFLElBQUksQ0FBQyxZQUFZLENBQUMsTUFBTSxHQUFHLENBQUMsQ0FBQyxDQUFDLENBQUMsSUFBSSxDQUFDLFlBQVksQ0FBQyxHQUFHLEVBQUUsQ0FBQyxDQUFDLENBQUMsSUFBSSxFQUFFLElBQUksQ0FBQyxXQUFXLENBQUMsQ0FBQzthQUNuSjtpQkFBTTtnQkFDSCxDQUFDLFFBQVEsQ0FBQyxTQUFTLElBQUksSUFBSSxDQUFDLGdCQUFnQixDQUFDLFFBQVEsQ0FBQyxRQUFRLEVBQUUsQ0FBQyxDQUFDO2FBQ3JFO1lBQ0QsT0FBTyxNQUFNLENBQUM7U0FDakI7SUFDTCxDQUFDO0lBR0Q7Ozs7T0FJRztJQUNLLDhCQUFXLEdBQW5CLFVBQW9CLFFBQXFCO1FBQ3JDLElBQUksU0FBUyxHQUFHLGFBQWEsQ0FBQyxRQUFRLEVBQUUsQ0FBQyxJQUFJLEVBQUUsSUFBSSxFQUFFLElBQUksRUFBRSxJQUFJLENBQUMsQ0FBQyxDQUFDO1FBQ2xFLHFDQUFxQztRQUNyQyxJQUFJLGlCQUFpQixHQUFHLFNBQVMsQ0FBQyxTQUFTLEdBQUcsSUFBSSxDQUFDLFNBQVMsQ0FBQyxRQUFRO2VBQzlELFNBQVMsQ0FBQyxRQUFRLEdBQUcsSUFBSSxDQUFDLFNBQVMsQ0FBQyxTQUFTLENBQUM7UUFFckQsSUFBSSxlQUFlLEdBQUcsS0FBSyxDQUFDO1FBQzVCLElBQUksQ0FBQyxpQkFBaUIsRUFBRTtZQUNwQixvQ0FBb0M7WUFDcEMsZUFBZSxHQUFHLFNBQVMsQ0FBQyxPQUFPLEdBQUcsSUFBSSxDQUFDLFNBQVMsQ0FBQyxVQUFVO21CQUN4RCxTQUFTLENBQUMsVUFBVSxHQUFHLElBQUksQ0FBQyxTQUFTLENBQUMsT0FBTyxDQUFDO1NBQ3hEO1FBQ0QsT0FBTyxDQUFDLGlCQUFpQixJQUFJLENBQUMsZUFBZSxDQUFDO0lBQ2xELENBQUM7SUFDRDs7Ozs7T0FLRztJQUNVLGlDQUFjLEdBQTNCLFVBQTRCLElBQWlCLEVBQUUsU0FBa0IsRUFBRSxVQUFtQixFQUFFLElBQWtCO1FBQWxCLHFCQUFBLEVBQUEsVUFBa0I7Ozs7Ozt3QkFDbEcsa0JBQWtCLEdBQUcsQ0FBQyxJQUFJLENBQUMsVUFBVSxDQUFDLE9BQU8sQ0FBQyxPQUFPLElBQUksQ0FBQyxJQUFJLFNBQVMsQ0FBQyxVQUFVLElBQUksSUFBSSxDQUFDLFNBQVMsQ0FBQyxPQUFPLENBQUMsQ0FBQzt3QkFDOUcsa0JBQWtCLEdBQUcsQ0FBQyxJQUFJLENBQUMsVUFBVSxDQUFDLE9BQU8sQ0FBQyxPQUFPLElBQUksQ0FBQyxJQUFJLFNBQVMsQ0FBQyxPQUFPLElBQUksSUFBSSxDQUFDLFNBQVMsQ0FBQyxVQUFVLENBQUMsQ0FBQzt3QkFDbEgsSUFBSSxrQkFBa0IsSUFBSSxrQkFBa0IsRUFBRTs0QkFDMUMsSUFBSSxrQkFBa0IsRUFBRTtnQ0FDcEIsSUFBSSxDQUFDLFVBQVUsQ0FBQyxrQkFBa0IsQ0FBQyxFQUFFLENBQUMsRUFBRSxDQUFDLElBQUksQ0FBQyxVQUFVLENBQUMsT0FBTyxDQUFDLENBQUMsRUFBRSxJQUFJLENBQUMsVUFBVSxDQUFDLE9BQU8sQ0FBQyxDQUFDLEdBQUcsVUFBVSxDQUFDLE1BQU0sQ0FBQyxDQUFDLENBQUE7NkJBQ3RIO2lDQUFNO2dDQUNILElBQUksQ0FBQyxVQUFVLENBQUMsa0JBQWtCLENBQUMsRUFBRSxDQUFDLEVBQUUsQ0FBQyxJQUFJLENBQUMsVUFBVSxDQUFDLE9BQU8sQ0FBQyxDQUFDLEVBQUUsSUFBSSxDQUFDLFVBQVUsQ0FBQyxPQUFPLENBQUMsQ0FBQyxHQUFHLFVBQVUsQ0FBQyxNQUFNLENBQUMsQ0FBQyxDQUFBOzZCQUN0SDt5QkFDSjt3QkFDRyxrQkFBa0IsR0FBRyxDQUFDLElBQUksQ0FBQyxVQUFVLENBQUMsT0FBTyxDQUFDLE9BQU8sSUFBSSxDQUFDLElBQUksU0FBUyxDQUFDLFNBQVMsSUFBSSxJQUFJLENBQUMsU0FBUyxDQUFDLFFBQVEsQ0FBQyxDQUFDO3dCQUM5RyxrQkFBa0IsR0FBRyxDQUFDLElBQUksQ0FBQyxVQUFVLENBQUMsT0FBTyxDQUFDLE9BQU8sSUFBSSxDQUFDLElBQUksU0FBUyxDQUFDLFFBQVEsSUFBSSxJQUFJLENBQUMsU0FBUyxDQUFDLFNBQVMsQ0FBQyxDQUFDO3dCQUNsSCxJQUFJLGtCQUFrQixJQUFJLGtCQUFrQixFQUFFOzRCQUMxQyxJQUFJLGtCQUFrQixFQUFFO2dDQUNwQixJQUFJLENBQUMsVUFBVSxDQUFDLGtCQUFrQixDQUFDLEVBQUUsQ0FBQyxFQUFFLENBQUMsSUFBSSxDQUFDLFVBQVUsQ0FBQyxPQUFPLENBQUMsQ0FBQyxHQUFHLFVBQVUsQ0FBQyxLQUFLLEVBQUUsSUFBSSxDQUFDLFVBQVUsQ0FBQyxPQUFPLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQTs2QkFDckg7aUNBQU07Z0NBQ0gsSUFBSSxDQUFDLFVBQVUsQ0FBQyxrQkFBa0IsQ0FBQyxFQUFFLENBQUMsRUFBRSxDQUFDLElBQUksQ0FBQyxVQUFVLENBQUMsT0FBTyxDQUFDLENBQUMsR0FBRyxVQUFVLENBQUMsS0FBSyxFQUFFLElBQUksQ0FBQyxVQUFVLENBQUMsT0FBTyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUE7NkJBQ3JIO3lCQUNKOzZCQUNHLENBQUMsQ0FBQyxrQkFBa0IsSUFBSSxrQkFBa0IsSUFBSSxrQkFBa0IsSUFBSSxrQkFBa0IsQ0FBQyxFQUF2Rix3QkFBdUY7d0JBQ3ZGLEVBQUUsQ0FBQyxLQUFLLENBQUMsZUFBZSxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsQ0FBQzt3QkFDcEMscUJBQU0sSUFBSSxPQUFPLENBQU8sVUFBQyxPQUFPLEVBQUUsTUFBTTtnQ0FDcEMsRUFBRSxDQUFDLEtBQUssQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLENBQUMsRUFBRSxDQUFDLElBQUksRUFBRSxFQUFFLEtBQUssRUFBRSxJQUFJLENBQUMsSUFBSSxDQUFDLEtBQUssRUFBRSxNQUFNLEVBQUUsSUFBSSxDQUFDLElBQUksQ0FBQyxNQUFNLEVBQUUsQ0FBQyxDQUFDLElBQUksQ0FBQztvQ0FDcEYsT0FBTyxFQUFFLENBQUM7Z0NBQ2QsQ0FBQyxDQUFDLENBQUMsS0FBSyxFQUFFLENBQUM7NEJBQ2YsQ0FBQyxDQUFDLEVBQUE7O3dCQUpGLFNBSUUsQ0FBQTs7O3dCQUVOLElBQUksQ0FBQyxXQUFXLEVBQUUsQ0FBQzt3QkFDbkIsc0JBQU8sSUFBSSxFQUFDOzs7O0tBQ2Y7SUFFRDs7O09BR0c7SUFDSyxtQ0FBZ0IsR0FBeEIsVUFBeUIsSUFBaUI7UUFDdEMsSUFBSSxJQUFJLElBQUksQ0FBQyxZQUFZLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxDQUFDO0lBQ3pDLENBQUM7SUFFRDs7T0FFRztJQUNJLDJCQUFRLEdBQWY7UUFDSSxJQUFJLENBQUMsVUFBVSxDQUFDLElBQUksQ0FBQyxHQUFHLENBQUMsV0FBVyxFQUFFLElBQUksQ0FBQyxpQkFBaUIsQ0FBQyxDQUFDO1FBQzlELEtBQUssSUFBSSxDQUFDLEdBQUcsQ0FBQyxFQUFFLEdBQUcsR0FBRyxJQUFJLENBQUMsU0FBUyxDQUFDLE1BQU0sRUFBRSxDQUFDLEdBQUcsR0FBRyxFQUFFLEVBQUUsQ0FBQyxFQUFFO1lBQ3ZELElBQUksQ0FBQyxnQkFBZ0IsQ0FBQyxJQUFJLENBQUMsU0FBUyxDQUFDLENBQUMsQ0FBQyxDQUFDLFFBQVEsRUFBRSxDQUFDLENBQUM7WUFDcEQsSUFBSSxDQUFDLFNBQVMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxPQUFPLEVBQUUsQ0FBQztTQUMvQjtRQUNELElBQUksQ0FBQyxTQUFTLEdBQUcsRUFBRSxDQUFDO1FBQ3BCLEtBQUssSUFBSSxLQUFLLEdBQUcsQ0FBQyxFQUFFLEdBQUcsR0FBRyxJQUFJLENBQUMsWUFBWSxDQUFDLE1BQU0sRUFBRSxLQUFLLEdBQUcsR0FBRyxFQUFFLEVBQUUsS0FBSyxFQUFFO1lBQ3RFLElBQUksQ0FBQyxZQUFZLENBQUMsS0FBSyxDQUFDLENBQUMsT0FBTyxFQUFFLENBQUM7U0FDdEM7UUFDRCxJQUFJLENBQUMsWUFBWSxHQUFHLEVBQUUsQ0FBQztRQUN2QixJQUFJLENBQUMsV0FBVyxHQUFHLElBQUksQ0FBQztRQUN4QixJQUFJLENBQUMsVUFBVSxHQUFHLElBQUksQ0FBQztRQUN2QixJQUFJLENBQUMsTUFBTSxHQUFHLElBQUksQ0FBQztJQUN2QixDQUFDO0lBempCYSxlQUFNLEdBQStCLElBQUksR0FBRyxFQUFFLENBQUM7SUEyakJqRSxlQUFDO0NBNWpCRCxBQTRqQkMsSUFBQTtrQkE1akJvQixRQUFRO0FBNmpCN0I7Ozs7R0FJRztBQUNILFNBQVMsYUFBYSxDQUFDLElBQW1CLEVBQUUsT0FBa0I7SUFDMUQsSUFBSSxJQUFJLEdBQUcsSUFBSSxDQUFDLElBQUksQ0FBQTtJQUNwQixJQUFJLFNBQVMsR0FBWSxFQUFFLENBQUM7SUFDNUIsSUFBSSxJQUFJLEdBQUcsV0FBVyxDQUFDLElBQUksQ0FBQyxDQUFDO0lBQzdCLFNBQVM7SUFDVCxJQUFJLE9BQU8sQ0FBQyxDQUFDLENBQUMsRUFBRTtRQUNaLFNBQVMsQ0FBQyxPQUFPLEdBQUcsSUFBSSxDQUFDLENBQUMsR0FBRyxDQUFDLElBQUksQ0FBQyxNQUFNLEdBQUcsQ0FBQyxDQUFDLEdBQUcsSUFBSSxDQUFDLE9BQU8sQ0FBQyxDQUFDLENBQUM7S0FDbkU7SUFDRCxTQUFTO0lBQ1QsSUFBSSxPQUFPLENBQUMsQ0FBQyxDQUFDLEVBQUU7UUFDWixTQUFTLENBQUMsVUFBVSxHQUFHLElBQUksQ0FBQyxDQUFDLEdBQUcsQ0FBQyxJQUFJLENBQUMsTUFBTSxHQUFHLElBQUksQ0FBQyxPQUFPLENBQUMsQ0FBQztLQUNoRTtJQUNELFNBQVM7SUFDVCxJQUFJLE9BQU8sQ0FBQyxDQUFDLENBQUMsRUFBRTtRQUNaLFNBQVMsQ0FBQyxRQUFRLEdBQUcsSUFBSSxDQUFDLENBQUMsR0FBRyxDQUFDLElBQUksQ0FBQyxLQUFLLEdBQUcsSUFBSSxDQUFDLE9BQU8sQ0FBQyxDQUFDO0tBQzdEO0lBQ0QsU0FBUztJQUNULElBQUksT0FBTyxDQUFDLENBQUMsQ0FBQyxFQUFFO1FBQ1osU0FBUyxDQUFDLFNBQVMsR0FBRyxJQUFJLENBQUMsQ0FBQyxHQUFHLENBQUMsSUFBSSxDQUFDLEtBQUssR0FBRyxDQUFDLENBQUMsR0FBRyxJQUFJLENBQUMsT0FBTyxDQUFDLENBQUMsQ0FBQztLQUNwRTtJQUNELFNBQVMsQ0FBQyxJQUFJLEdBQUcsRUFBRSxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsS0FBSyxFQUFFLElBQUksQ0FBQyxNQUFNLENBQUMsQ0FBQztJQUNsRCxPQUFPLFNBQVMsQ0FBQztBQUNyQixDQUFDO0FBRUQ7Ozs7R0FJRztBQUNILFNBQVMsV0FBVyxDQUFDLElBQWE7SUFDOUIsT0FBTyxJQUFJLENBQUMsTUFBTSxDQUFDLHFCQUFxQixDQUFDLElBQUksQ0FBQyxRQUFRLENBQUMsQ0FBQztBQUM1RCxDQUFDIiwiZmlsZSI6IiIsInNvdXJjZVJvb3QiOiIvIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IFJlbmRlckFsdGVybmF0aXZlIGZyb20gXCIuL1JlbmRlckFsdGVybmF0aXZlXCI7XHJcblxyXG5pbnRlcmZhY2UgSUJvcmRlciB7XHJcbiAgICBsZWZ0U2lkZT86IG51bWJlcjtcclxuICAgIHJpZ2h0U2lkZT86IG51bWJlcjtcclxuICAgIGJvdHRvbVNpZGU/OiBudW1iZXI7XHJcbiAgICB0b3BTaWRlPzogbnVtYmVyO1xyXG4gICAgc2l6ZT86IGNjLlNpemU7XHJcbn1cclxudHlwZSBURGF0ZSA9IHsgc2l6ZT86IGNjLlNpemUgfTtcclxuZXhwb3J0IGNsYXNzIFNob3dOb2RlPFQgZXh0ZW5kcyBURGF0ZT4gZXh0ZW5kcyBjYy5Db21wb25lbnQge1xyXG4gICAgLyoq5piv5ZCm5Yid5aeL5YyW6L+H5Luj55CG57uE5bu6ICovXHJcbiAgICBwcml2YXRlIGhhc0luaXQ6IGJvb2xlYW4gPSBmYWxzZTtcclxuICAgIC8qKua4suafk+WIhuWxguW8gOWQr+eahOaMgui9veiKgueCuSAqL1xyXG4gICAgcHVibGljIHJlbmRlckxheWVyOiBjYy5Ob2RlO1xyXG4gICAgLyoq5LiK57qn55qEY2VsbCAqL1xyXG4gICAgcHVibGljIGNlbGw6IEl0ZW1DZWxsPFQ+O1xyXG4gICAgLyoq5pWw5o2uICovXHJcbiAgICBwdWJsaWMgZGF0YTogVDtcclxuICAgIC8qKuWIneWni+WMliAqL1xyXG4gICAgcHVibGljIGluaXQoY2VsbDogSXRlbUNlbGw8VD4sIGRhdGE6IFQsIHJlbmRlckxheWVyOiBjYy5Ob2RlKSB7XHJcbiAgICAgICAgdGhpcy5jZWxsID0gY2VsbDtcclxuICAgICAgICB0aGlzLmRhdGEgPSBkYXRhO1xyXG4gICAgICAgIGlmICh0aGlzLnJlbmRlckxheWVyICE9IHJlbmRlckxheWVyKSB7XHJcbiAgICAgICAgICAgIHRoaXMucmVuZGVyTGF5ZXIgPSByZW5kZXJMYXllcjtcclxuICAgICAgICAgICAgcmVuZGVyTGF5ZXIgJiYgdGhpcy5pbml0UmVuZGVycygpO1xyXG4gICAgICAgIH1cclxuICAgICAgICB0aGlzLmluaXRTaG93KCk7XHJcbiAgICB9XHJcbiAgICAvKirliJ3lp4vljJbmk43kvZwgKi9cclxuICAgIGluaXRTaG93KCkgeyB9XHJcbiAgICAvKirooqvlm57mlLbvvIzlupTor6XlgZrkuIDkupvph4rmlL7nmoTmk43kvZwgKi9cclxuICAgIG9uUmVjaXJjbGUoKSB7IH1cclxuXHJcbiAgICAvKipcclxuICAgICAqIOWcqOeJueWumuaXtumXtOWGhei/m+ihjOWkp+Wwj+WPmOWMllxyXG4gICAgICogQHBhcmFtIHRhcmdldFNpemUgXHJcbiAgICAgKiBAcGFyYW0gdGltZSBcclxuICAgICAqL1xyXG4gICAgcHVibGljIHJlc2l6ZSh0YXJnZXRTaXplOiBjYy5TaXplLCB0aW1lOiBudW1iZXIgPSAwLjMpIHtcclxuICAgICAgICB0aGlzLmNlbGwucmVzaXplKHRhcmdldFNpemUsIHRpbWUpO1xyXG4gICAgfVxyXG4gICAgLyoqXHJcbiAgICAgKiDlpITnkIbliIblsYLku6PnkIbmuLLmn5NcclxuICAgICAqL1xyXG4gICAgcHJpdmF0ZSBpbml0UmVuZGVycygpIHtcclxuICAgICAgICBpZiAoIXRoaXMuaGFzSW5pdCAmJiB0aGlzLnJlbmRlckxheWVyKSB7XHJcbiAgICAgICAgICAgIGxldCBwcm9wTWFwOiBXZWFrTWFwPFJlbmRlckFsdGVybmF0aXZlLCBib29sZWFuPiA9IG5ldyBXZWFrTWFwKCk7XHJcbiAgICAgICAgICAgIGxldCBrZXlzID0gT2JqZWN0LmtleXModGhpcyk7XHJcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBsZW4gPSBrZXlzLmxlbmd0aDsgaSA8IGxlbjsgKytpKSB7XHJcbiAgICAgICAgICAgICAgICBsZXQgdmFsdWUgPSB0aGlzW2tleXNbaV1dO1xyXG4gICAgICAgICAgICAgICAgbGV0IGFsdGVybmF0aXZlOiBSZW5kZXJBbHRlcm5hdGl2ZSA9IG51bGw7XHJcbiAgICAgICAgICAgICAgICBpZiAodmFsdWUgaW5zdGFuY2VvZiBjYy5Ob2RlKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgYWx0ZXJuYXRpdmUgPSB2YWx1ZS5nZXRDb21wb25lbnQoUmVuZGVyQWx0ZXJuYXRpdmUpO1xyXG4gICAgICAgICAgICAgICAgICAgIGlmIChhbHRlcm5hdGl2ZSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBhbHRlcm5hdGl2ZS5pbml0KHRoaXMucmVuZGVyTGF5ZXIpO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAodmFsdWUgaW5zdGFuY2VvZiBjYy5SZW5kZXJDb21wb25lbnQpIHtcclxuICAgICAgICAgICAgICAgICAgICBhbHRlcm5hdGl2ZSA9IHZhbHVlLmdldENvbXBvbmVudChSZW5kZXJBbHRlcm5hdGl2ZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKGFsdGVybmF0aXZlKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXNba2V5c1tpXV0gPSBhbHRlcm5hdGl2ZS5pbml0PHR5cGVvZiB2YWx1ZT4odGhpcy5yZW5kZXJMYXllcik7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgYWx0ZXJuYXRpdmUgJiYgcHJvcE1hcC5zZXQoYWx0ZXJuYXRpdmUsIHRydWUpO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIHRoaXMuZGVhbENoaWxyZW5BbHRlcm5hdGl2ZSh0aGlzLm5vZGUsIHByb3BNYXAsIDAsIDApO1xyXG4gICAgICAgICAgICB0aGlzLmhhc0luaXQgPSB0cnVlO1xyXG4gICAgICAgIH1cclxuICAgIH1cclxuICAgIC8qKlxyXG4gICAgICog5aSE55CG5a2Q6IqC54K55Luj55CGXHJcbiAgICAgKiBAcGFyYW0gbm9kZSBcclxuICAgICAqIEBwYXJhbSBwcm9wTWFwIOiusOW9leiEmuacrOW3sue7j+WkhOeQhui/h+eahOWxnuaAp+S7o+eQhlxyXG4gICAgICogQHBhcmFtIHBhcmVudFNpbmRleCDniLboioLngrnnmoTmiYDlnKjnmoTpobrluo9cclxuICAgICAqIEBwYXJhbSBkZXB0aCDmt7HluqZcclxuICAgICAqL1xyXG4gICAgZGVhbENoaWxyZW5BbHRlcm5hdGl2ZShub2RlOiBjYy5Ob2RlLCBwcm9wTWFwOiBXZWFrTWFwPFJlbmRlckFsdGVybmF0aXZlLCBib29sZWFuPiwgcGFyZW50U2luZGV4OiBudW1iZXIsIGRlcHRoOiBudW1iZXIpIHtcclxuICAgICAgICBmb3IgKGxldCBpID0gMCwgbGVuID0gbm9kZS5jaGlsZHJlbi5sZW5ndGg7IGkgPCBsZW47IGkrKykge1xyXG4gICAgICAgICAgICBsZXQgY2hpbGRyZW4gPSBub2RlLmNoaWxkcmVuW2ldO1xyXG4gICAgICAgICAgICBsZXQgYWx0ZXJuYXRpdmUgPSBjaGlsZHJlbi5nZXRDb21wb25lbnQoY2MuUmVuZGVyQ29tcG9uZW50KT8uZ2V0Q29tcG9uZW50KFJlbmRlckFsdGVybmF0aXZlKTtcclxuICAgICAgICAgICAgbGV0IHNJbmRleCA9IHBhcmVudFNpbmRleCArIChpICogTWF0aC5wb3coMC4xLCBkZXB0aCkpO1xyXG4gICAgICAgICAgICBpZiAoYWx0ZXJuYXRpdmUpIHtcclxuICAgICAgICAgICAgICAgIGlmICgoIXByb3BNYXAuaGFzKGFsdGVybmF0aXZlKSB8fCAhcHJvcE1hcC5nZXQoYWx0ZXJuYXRpdmUpKSkge1xyXG4gICAgICAgICAgICAgICAgICAgIGFsdGVybmF0aXZlLmluaXQodGhpcy5yZW5kZXJMYXllcik7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICBhbHRlcm5hdGl2ZS5zSW5kZXggPSBzSW5kZXg7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgdGhpcy5kZWFsQ2hpbHJlbkFsdGVybmF0aXZlKGNoaWxkcmVuLCBwcm9wTWFwLCBzSW5kZXgsIGRlcHRoICsgMSk7XHJcbiAgICAgICAgfVxyXG4gICAgfVxyXG59XHJcbmV4cG9ydCBjbGFzcyBJdGVtQ2VsbDxUIGV4dGVuZHMgVERhdGU+IHtcclxuICAgIC8qKuaMgeaciWNlbGznmoRsaXN0ICovXHJcbiAgICBwdWJsaWMgbG9vcGxpc3Q6IExvb3BMaXN0PFQ+ID0gbnVsbDtcclxuICAgIC8qKuS9jee9ruiKgueCuSAqL1xyXG4gICAgcHVibGljIG5vZGU6IGNjLk5vZGUgPSBudWxsO1xyXG4gICAgLyoq5pi+56S66IqC54K5ICovXHJcbiAgICBwdWJsaWMgc2hvd05vZGU6IFNob3dOb2RlPFQ+ID0gbnVsbDtcclxuICAgIC8qKuWwuuWvuCAqL1xyXG4gICAgcHVibGljIHNpemU6IGNjLlNpemUgPSBudWxsO1xyXG4gICAgLyoq5pWw5o2u5LiL5qCHICovXHJcbiAgICBwdWJsaWMgZGF0YUluZGV4OiBudW1iZXIgPSBudWxsO1xyXG4gICAgLyoqY2VsbOS4i+aghyAqL1xyXG4gICAgcHVibGljIGNlbGxJbmRleDogbnVtYmVyID0gbnVsbDtcclxuICAgIC8qKuaVsOaNriAqL1xyXG4gICAgcHVibGljIGRhdGE6IFQgPSBudWxsO1xyXG4gICAgLyoqXHJcbiAgICAgKiDmnoTpgKDlh73mlbBcclxuICAgICAqIEBwYXJhbSBub2RlIFxyXG4gICAgICogQHBhcmFtIGxvb3BsaXN0IFxyXG4gICAgICovXHJcbiAgICBjb25zdHJ1Y3Rvcihub2RlOiBjYy5Ob2RlLCBsb29wbGlzdDogTG9vcExpc3Q8VD4pIHtcclxuICAgICAgICB0aGlzLm5vZGUgPSBub2RlO1xyXG4gICAgICAgIHRoaXMubG9vcGxpc3QgPSBsb29wbGlzdDtcclxuICAgIH1cclxuXHJcbiAgICAvKipcclxuICAgICAqIOWIneWni+WMllxyXG4gICAgICogQHBhcmFtIGRhdGEgXHJcbiAgICAgKiBAcGFyYW0gc2l6ZSBcclxuICAgICAqIEBwYXJhbSBkYXRhSW5kZXggXHJcbiAgICAgKiBAcGFyYW0gY2VsbEluZGV4IFxyXG4gICAgICogQHBhcmFtIGxvb3BsaXN0IFxyXG4gICAgICovXHJcbiAgICBwdWJsaWMgaW5pdChkYXRhOiBULCBzaXplOiBjYy5TaXplLCBkYXRhSW5kZXg6IG51bWJlciwgY2VsbEluZGV4OiBudW1iZXIsIGxvb3BsaXN0OiBMb29wTGlzdDxUPikge1xyXG4gICAgICAgIGNjLlR3ZWVuLnN0b3BBbGxCeVRhcmdldCh0aGlzLm5vZGUpO1xyXG4gICAgICAgIHRoaXMuY2VsbEluZGV4ID0gY2VsbEluZGV4O1xyXG4gICAgICAgIHRoaXMuZGF0YUluZGV4ID0gZGF0YUluZGV4O1xyXG4gICAgICAgIHRoaXMubG9vcGxpc3QgPSBsb29wbGlzdDtcclxuICAgICAgICB0aGlzLm5vZGUud2lkdGggPSBzaXplLndpZHRoO1xyXG4gICAgICAgIHRoaXMubm9kZS5oZWlnaHQgPSBzaXplLmhlaWdodDtcclxuICAgICAgICB0aGlzLmRhdGEgPSBkYXRhO1xyXG4gICAgICAgIHRoaXMuc2l6ZSA9IHNpemU7XHJcbiAgICB9XHJcbiAgICAvKipcclxuICAgICAqIOmHjee9ruWkp+Wwj1xyXG4gICAgICogQHBhcmFtIHNpemUgXHJcbiAgICAgKi9cclxuICAgIHJlc2l6ZShzaXplOiBjYy5TaXplLCB0aW1lOiBudW1iZXIpIHtcclxuICAgICAgICBsZXQgbm9kZVNpZGVzID0gZ2V0Tm9kZUJvcmRlcih0aGlzLCBbdHJ1ZSwgdHJ1ZSwgdHJ1ZSwgdHJ1ZV0pO1xyXG4gICAgICAgIGxldCBjaGFuZ2VTaXplID0gY2Muc2l6ZShzaXplLndpZHRoIC0gdGhpcy5zaXplLndpZHRoLCBzaXplLmhlaWdodCAtIHRoaXMuc2l6ZS5oZWlnaHQpO1xyXG4gICAgICAgIHRoaXMuc2l6ZSA9IHNpemU7XHJcbiAgICAgICAgdGhpcy5sb29wbGlzdC5kZWFsQ2hhbmdlU2l6ZSh0aGlzLCBub2RlU2lkZXMsIGNoYW5nZVNpemUsIHRpbWUpLnRoZW4oKCkgPT4ge1xyXG4gICAgICAgICAgICB0aGlzLm5vZGUud2lkdGggPSBzaXplLndpZHRoO1xyXG4gICAgICAgICAgICB0aGlzLm5vZGUuaGVpZ2h0ID0gc2l6ZS5oZWlnaHQ7XHJcbiAgICAgICAgICAgIHRoaXMubG9vcGxpc3QudXBkYXRlTm9kZXMoKTtcclxuICAgICAgICB9KTtcclxuICAgIH1cclxuXHJcbiAgICAvKipcclxuICAgICAqIOabtOaWsOiKgueCueaYvuekulxyXG4gICAgICogQHBhcmFtIGlzU2hvdyDmmK/lkKbmmL7npLpcclxuICAgICAqIEBwYXJhbSBwcmVmYWIg6ZyA6KaB5pi+56S655qE6IqC54K555qE6aKE5Yi25Lu277yI5Lmf5Y+v5Lul5piv6IqC54K577yM5oiW6ICF6aKE5Yi25Lu2dXJsLOeUn+aIkOaWueW8j+iHqueUseaUueWKqO+8iVxyXG4gICAgICogQHBhcmFtIGNhY2hlTm9kZSDlr7nosaHmsaDkuK3nmoTmmL7npLroioLngrlcclxuICAgICAqIEBwYXJhbSByZW5kZXJMYXllciDliIblsYLoioLngrlcclxuICAgICAqL1xyXG4gICAgdXBkYXRlU2hvdyhpc1Nob3c6IGJvb2xlYW4sIHByZWZhYjogY2MuUHJlZmFiLCBjYWNoZU5vZGU6IFNob3dOb2RlPFQ+LCByZW5kZXJMYXllcjogY2MuTm9kZSkge1xyXG4gICAgICAgIGlmIChpc1Nob3cpIHtcclxuICAgICAgICAgICAgLy/lvZPliY3msqHmnInmmL7npLroioLngrlcclxuICAgICAgICAgICAgaWYgKCF0aGlzLnNob3dOb2RlKSB7XHJcbiAgICAgICAgICAgICAgICAvL+WmguaenOaYr+S4tOaXtuWvueixoeaxoOi/mOacieiKgueCueWImemHjeeUqFxyXG4gICAgICAgICAgICAgICAgaWYgKGNhY2hlTm9kZSkge1xyXG4gICAgICAgICAgICAgICAgICAgIHRoaXMuc2hvd05vZGUgPSBjYWNoZU5vZGU7XHJcbiAgICAgICAgICAgICAgICB9IGVsc2Ugey8v5ZCm5YiZ5L2/55So5Lyg5YWl55qE6aKE5Yi25Lu26L+b6KGM55Sf5oiQXHJcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5zaG93Tm9kZSA9IGNjLmluc3RhbnRpYXRlKHByZWZhYikuZ2V0Q29tcG9uZW50KFNob3dOb2RlKTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIHRoaXMuc2hvd05vZGUubm9kZS5zZXRQYXJlbnQodGhpcy5ub2RlKTtcclxuICAgICAgICAgICAgICAgIHRoaXMuc2hvd05vZGUubm9kZS5wb3NpdGlvbiA9IGNjLnYzKCk7XHJcbiAgICAgICAgICAgICAgICB0aGlzLnVwZGF0ZVNob3dOb2RlKHJlbmRlckxheWVyKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH1cclxuICAgIH1cclxuICAgIC8qKlxyXG4gICAgICog5pu05pawc2hvd05vZGXoioLngrnmmL7npLpcclxuICAgICAqIEBwYXJhbSByZW5kZXJMYXllciBcclxuICAgICAqL1xyXG4gICAgdXBkYXRlU2hvd05vZGUocmVuZGVyTGF5ZXI6IGNjLk5vZGUpIHtcclxuICAgICAgICAvL+W9k+WJjeacieaYvuekuuiKgueCuVxyXG4gICAgICAgIGlmICh0aGlzLnNob3dOb2RlKSB7XHJcbiAgICAgICAgICAgIHRoaXMuc2hvd05vZGUuaW5pdCh0aGlzLCB0aGlzLmRhdGEsIHJlbmRlckxheWVyKTtcclxuICAgICAgICB9XHJcbiAgICB9XHJcblxyXG4gICAgZ2V0IGhhc05vTm9kZSgpIHtcclxuICAgICAgICByZXR1cm4gIXRoaXMuc2hvd05vZGU7XHJcbiAgICB9XHJcblxyXG4gICAgcmVjaXJjbGUoKSB7XHJcbiAgICAgICAgaWYgKHRoaXMuc2hvd05vZGUpIHtcclxuICAgICAgICAgICAgbGV0IG5vZGUgPSB0aGlzLnNob3dOb2RlO1xyXG4gICAgICAgICAgICB0aGlzLnNob3dOb2RlLmdldENvbXBvbmVudChTaG93Tm9kZSkub25SZWNpcmNsZSgpO1xyXG4gICAgICAgICAgICB0aGlzLnNob3dOb2RlLm5vZGUucmVtb3ZlRnJvbVBhcmVudChmYWxzZSk7XHJcbiAgICAgICAgICAgIHRoaXMuc2hvd05vZGUgPSBudWxsO1xyXG4gICAgICAgICAgICByZXR1cm4gbm9kZTtcclxuICAgICAgICB9XHJcbiAgICB9XHJcblxyXG5cclxuICAgIGRlc3Ryb3koKSB7XHJcbiAgICAgICAgdGhpcy5ub2RlLmRlc3Ryb3koKTtcclxuICAgICAgICB0aGlzLm5vZGUgPSBudWxsO1xyXG4gICAgICAgIHRoaXMubG9vcGxpc3QgPSBudWxsO1xyXG4gICAgfVxyXG5cclxuICAgIC8qKlxyXG4gICAgICog5aSx5Y67XHJcbiAgICAgKiBAcmV0dXJucyBcclxuICAgICAqL1xyXG4gICAgbG9zdFNob3dOb2RlKCkge1xyXG4gICAgICAgIGlmICh0aGlzLnNob3dOb2RlKSB7XHJcbiAgICAgICAgICAgIGxldCBub2RlID0gdGhpcy5zaG93Tm9kZTtcclxuICAgICAgICAgICAgdGhpcy5zaG93Tm9kZS5ub2RlLnJlbW92ZUZyb21QYXJlbnQoZmFsc2UpO1xyXG4gICAgICAgICAgICB0aGlzLnNob3dOb2RlID0gbnVsbDtcclxuICAgICAgICAgICAgcmV0dXJuIG5vZGU7XHJcbiAgICAgICAgfVxyXG4gICAgfVxyXG5cclxuICAgIC8qKlxyXG4gICAgICog6I635Y+W5pi+56S66IqC54K5XHJcbiAgICAgKiBAcGFyYW0gc2hvd05vZGUgXHJcbiAgICAgKi9cclxuICAgIGdldFNob3dOb2RlKHNob3dOb2RlOiBTaG93Tm9kZTxUPikge1xyXG4gICAgICAgIHRoaXMuc2hvd05vZGUgPSBzaG93Tm9kZTtcclxuICAgICAgICBzaG93Tm9kZS5ub2RlLnNldFBhcmVudCh0aGlzLm5vZGUpO1xyXG4gICAgICAgIHRoaXMuc2hvd05vZGUuY2VsbCA9IHRoaXM7XHJcbiAgICB9XHJcbn1cclxuXHJcbi8qKlxyXG4gKiDnm67liY3liJfooajms6jmhI/kuovpoblcclxuICogMS7lvIDlkK9jZWxsTWF4TnVt5ZCO5LiN6IO95LiA6KGM5aSa5YiX5oiW6ICF5LiA5YiX5aSa6KGM77yM5Y+q6IO95Y2V6KGM5oiW6ICF5Y2V5YiXXHJcbiAqL1xyXG5leHBvcnQgZGVmYXVsdCBjbGFzcyBMb29wTGlzdDxUIGV4dGVuZHMgVERhdGU+IHtcclxuICAgIHB1YmxpYyBzdGF0aWMgaW5zTWFwOiBNYXA8c3RyaW5nLCBMb29wTGlzdDxhbnk+PiA9IG5ldyBNYXAoKTtcclxuICAgIHB1YmxpYyBzdGF0aWMgaW5zPFQ+KGxpc3ROYW1lOiBzdHJpbmcpOiBMb29wTGlzdDxUPiB7XHJcbiAgICAgICAgaWYgKCF0aGlzLmluc01hcC5oYXMobGlzdE5hbWUpKSB7XHJcbiAgICAgICAgICAgIHRoaXMuaW5zTWFwLnNldChsaXN0TmFtZSwgbmV3IExvb3BMaXN0PFQ+KCkpO1xyXG4gICAgICAgIH1cclxuICAgICAgICByZXR1cm4gdGhpcy5pbnNNYXAuZ2V0KGxpc3ROYW1lKSBhcyBMb29wTGlzdDxUPjtcclxuICAgIH1cclxuICAgIC8qKuWIhuWxguiKgueCue+8iOWPquacieWcqHNob3dOb2Rl5Lit5oyC6L295LqGUmVuZGVyQWx0ZXJuYXRpdmXmiY3og73otbfkvZznlKjvvIkgKi9cclxuICAgIHByaXZhdGUgcmVuZGVyTGF5ZXI6IGNjLk5vZGUgPSBudWxsO1xyXG4gICAgLyoq5rua5Yqo57uE5Lu2ICovXHJcbiAgICBwcml2YXRlIHNjcm9sbFZpZXc6IGNjLlNjcm9sbFZpZXcgPSBudWxsO1xyXG4gICAgLyoqY2VsbOiKgueCueacgOWkp+aVsOmHjyAqL1xyXG4gICAgcHJpdmF0ZSBjZWxsTWF4TnVtOiBudW1iZXIgPSBudWxsO1xyXG4gICAgLyoq5b2T5YmN6LW354K5ICovXHJcbiAgICBwcml2YXRlIGN1clN0YXJ0SW5kZXg6IG51bWJlciA9IG51bGw7XHJcbiAgICAvKirmlbDmja4gKi9cclxuICAgIHByaXZhdGUgZGF0YXM6IFRbXSA9IFtdO1xyXG4gICAgLyoqaXRlbeiKgueCueS7rCAqL1xyXG4gICAgcHJpdmF0ZSBpdGVtQ2VsbHM6IEl0ZW1DZWxsPFQ+W10gPSBbXTtcclxuICAgIC8qKumihOWItuS7tiAqL1xyXG4gICAgcHJpdmF0ZSBwcmVmYWI6IGNjLlByZWZhYiA9IG51bGw7XHJcbiAgICAvKirmmL7npLroioLngrnnmoTmsaDlrZAgKi9cclxuICAgIHByaXZhdGUgc2hvd05vZGVQb29sOiBTaG93Tm9kZTxUPltdID0gW107XHJcbiAgICAvKirovrnnvJjmlbDmja4gKi9cclxuICAgIHByaXZhdGUgdmlld1NpZGVzOiBJQm9yZGVyID0ge307XHJcbiAgICAvKirkuIrkuIDluKfmu5rliqjlrrnlmajnmoTlnZDmoIcgKi9cclxuICAgIHB1YmxpYyBsYXN0UG9zOiBjYy5WZWMzID0gbnVsbDtcclxuICAgIC8qKuWIt+aWsOaYvuekuueahOmXtOmalOasoeaVsCAqL1xyXG4gICAgcHVibGljIHVwZGF0ZUludjogbnVtYmVyID0gMDtcclxuICAgIC8qKuW+queOr+WIh+aNoueahOacgOWQjuS4gOasoeaXtumXtCAqL1xyXG4gICAgcHVibGljIGxhc3RDaGFuZ2U6IG51bWJlciA9IDA7XHJcbiAgICAvKirpgJrnlKjlsLrlr7ggKi9cclxuICAgIHB1YmxpYyBzaXplOiBjYy5TaXplID0gbnVsbDtcclxuICAgIC8qKumAmueUqOmUmueCuSAqL1xyXG4gICAgcHVibGljIGFuY2hvcjogY2MuVmVjMiA9IG51bGw7XHJcblxyXG4gICAgb25Mb2FkKCkge1xyXG4gICAgICAgIHRoaXMudXBkYXRlQm9yZGVyKClcclxuICAgIH1cclxuXHJcbiAgICAvKipcclxuICAgICAqIOabtOaWsOi+ueeVjFxyXG4gICAgICovXHJcbiAgICBwdWJsaWMgdXBkYXRlQm9yZGVyKCkge1xyXG4gICAgICAgIGxldCB2aWV3ID0gdGhpcy5zY3JvbGxWaWV3Lm5vZGUuZ2V0Q2hpbGRCeU5hbWUoXCJ2aWV3XCIpO1xyXG4gICAgICAgIHZpZXcuYW5jaG9yWCA9IHRoaXMuc2Nyb2xsVmlldy5jb250ZW50LmFuY2hvclg7XHJcbiAgICAgICAgdmlldy5hbmNob3JZID0gdGhpcy5zY3JvbGxWaWV3LmNvbnRlbnQuYW5jaG9yWTtcclxuICAgICAgICAvL+S/ruaUuemUmueCueS5i+WQjuS4i+S4gOW4p+S4lueVjOWdkOagh+aJjeS8muabtOaWsO+8jOayoeWKnuazleWPquiDveetieS4gOW4p+S6hlxyXG4gICAgICAgIHJldHVybiBuZXcgUHJvbWlzZTx2b2lkPigocmVzb2x2ZSwgcmVqZWN0KSA9PiB7XHJcbiAgICAgICAgICAgIHJlcXVlc3RBbmltYXRpb25GcmFtZSgoKSA9PiB7XHJcbiAgICAgICAgICAgICAgICBsZXQgd3BvcyA9IGdldE5vZGVXUG9zKHZpZXcpO1xyXG4gICAgICAgICAgICAgICAgLy/mmL7npLrljLrln5/lt6bovrnnvJhcclxuICAgICAgICAgICAgICAgIGxldCBsZWZ0U2lkZSA9IHdwb3MueCAtICh2aWV3LndpZHRoICogdmlldy5hbmNob3JYKTtcclxuICAgICAgICAgICAgICAgIC8v5pi+56S65Yy65Z+f5Y+z6L6557yYXHJcbiAgICAgICAgICAgICAgICBsZXQgcmlnaHRTaWRlID0gd3Bvcy54ICsgKHZpZXcud2lkdGggKiAoMSAtIHZpZXcuYW5jaG9yWCkpO1xyXG4gICAgICAgICAgICAgICAgLy/mmL7npLrljLrln5/kuIvovrnnvJhcclxuICAgICAgICAgICAgICAgIGxldCBib3R0b21TaWRlID0gd3Bvcy55IC0gKHZpZXcuaGVpZ2h0ICogdmlldy5hbmNob3JZKTtcclxuICAgICAgICAgICAgICAgIC8v5pi+56S65Yy65Z+f5LiK6L6557yYXHJcbiAgICAgICAgICAgICAgICBsZXQgdG9wU2lkZSA9IHdwb3MueSArICh2aWV3LmhlaWdodCAqICgxIC0gdmlldy5hbmNob3JZKSk7XHJcbiAgICAgICAgICAgICAgICB0aGlzLnZpZXdTaWRlcyA9IHtcclxuICAgICAgICAgICAgICAgICAgICBsZWZ0U2lkZSwgcmlnaHRTaWRlLCBib3R0b21TaWRlLCB0b3BTaWRlLCBzaXplOiBjYy5zaXplKHZpZXcud2lkdGgsIHZpZXcuaGVpZ2h0KVxyXG4gICAgICAgICAgICAgICAgfTtcclxuICAgICAgICAgICAgICAgIHRoaXMuc2Nyb2xsVmlldy5jb250ZW50LnNldFBvc2l0aW9uKGNjLnYzKDAsIDApKTtcclxuICAgICAgICAgICAgICAgIHJlc29sdmUoKTtcclxuICAgICAgICAgICAgfSlcclxuICAgICAgICB9KVxyXG5cclxuICAgIH1cclxuXHJcbiAgICAvKipcclxuICAgICAqIOWIneWni+WMlua7muWKqOWIl+ihqFxyXG4gICAgICogQHBhcmFtIHNjcm9sbFZpZXcgXHJcbiAgICAgKiBAcGFyYW0gY2VsbE1heE51bSBjZWxs6IqC54K555qE5pyA5aSn5pWw6YePLOiuvue9ruaIkG51bGzliJnkuI3lkK/nlKjvvIzlkK/nlKjnmoTor53vvIzopoHorr7nva7miJDvvIjlj6/op4bnqpfliJrlpb3og73mmL7npLrnmoTmnIDlpKfmlbDph48qMu+8iSsy77yM5YGH6K6+5pyA5aSa6IO955yL5YiwMTDkuKroioLngrnvvIzpgqPkuYjorr7nva7miJAyMlxyXG4gICAgICogQHBhcmFtIHJlbmRlckxheWVyIOa4suafk+WIhuWxgueahOeItuiKgueCue+8jOWmguaenOS8oOWFpeWImeWPr+S7pemFjeWQiHNob3dOb2Rl5LiK55qEcmVuZGVyQWx0ZXJuYXRpdmXmnaXov5vooYzmuLLmn5PliIblsYJcclxuICAgICAqL1xyXG4gICAgYXN5bmMgaW5pdChzY3JvbGxWaWV3OiBjYy5TY3JvbGxWaWV3LCByZW5kZXJMYXllcj86IGNjLk5vZGUsIGNlbGxNYXhOdW0/OiBudW1iZXIpIHtcclxuICAgICAgICBjZWxsTWF4TnVtICYmICh0aGlzLmNlbGxNYXhOdW0gPSBjZWxsTWF4TnVtKTtcclxuICAgICAgICByZW5kZXJMYXllciAmJiAodGhpcy5yZW5kZXJMYXllciA9IHJlbmRlckxheWVyKTtcclxuICAgICAgICB0aGlzLnNjcm9sbFZpZXcgPSBzY3JvbGxWaWV3O1xyXG4gICAgICAgIGF3YWl0IHRoaXMudXBkYXRlQm9yZGVyKCk7XHJcbiAgICAgICAgdGhpcy5zY3JvbGxWaWV3Lm5vZGUub24oXCJzY3JvbGxpbmdcIiwgdGhpcy5zY3JvbGxpbmdMaXN0ZW5lciwgdGhpcyk7XHJcbiAgICB9XHJcblxyXG4gICAgLyoq5rua5Yqo55uR5ZCsICovXHJcbiAgICBzY3JvbGxpbmdMaXN0ZW5lcigpIHtcclxuICAgICAgICB0aGlzLnVwZGF0ZUludi0tO1xyXG4gICAgICAgIGlmICh0aGlzLnVwZGF0ZUludiA8PSAwKSB7XHJcbiAgICAgICAgICAgIHRoaXMudXBkYXRlSW52ID0gMjtcclxuICAgICAgICAgICAgbGV0IHNob3dDZWxscyA9IHRoaXMudXBkYXRlTm9kZXMoKTtcclxuXHJcbiAgICAgICAgICAgIGlmICghdGhpcy5jZWxsTWF4TnVtKSB7XHJcbiAgICAgICAgICAgICAgICByZXR1cm47XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgaWYgKCF0aGlzLmxhc3RQb3MpIHtcclxuICAgICAgICAgICAgICAgIHRoaXMubGFzdFBvcyA9IHRoaXMuc2Nyb2xsVmlldy5jb250ZW50LnBvc2l0aW9uLmNsb25lKCk7XHJcbiAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICBsZXQgb2Zmc2V0ID0gdGhpcy5zY3JvbGxWaWV3LmNvbnRlbnQucG9zaXRpb24uY2xvbmUoKS5zdWIodGhpcy5sYXN0UG9zKTtcclxuICAgICAgICAgICAgICAgIHRoaXMubGFzdFBvcyA9IHRoaXMuc2Nyb2xsVmlldy5jb250ZW50LnBvc2l0aW9uLmNsb25lKCk7XHJcbiAgICAgICAgICAgICAgICBsZXQgbm93ID0gY2Muc3lzLm5vdygpO1xyXG4gICAgICAgICAgICAgICAgaWYgKCF0aGlzLmxhc3RDaGFuZ2UgfHwgKG5vdyAtIHRoaXMubGFzdENoYW5nZSkgPiAxMDApIHtcclxuICAgICAgICAgICAgICAgICAgICB0aGlzLmxhc3RDaGFuZ2UgPSBub3c7XHJcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5kZWFsTG9vcExpc3Qob2Zmc2V0LCBzaG93Q2VsbHMpO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfVxyXG4gICAgfVxyXG4gICAgLyoqXHJcbiAgICAgKiDliJ3lp4vljJZcclxuICAgICAqIEBwYXJhbSBkYXRhIOaVsOaNrue7hFxyXG4gICAgICogQHBhcmFtIHByZWZhYiDpooTliLbku7ZcclxuICAgICAqIEBwYXJhbSBzaXplIOmAmueUqOWwuuWvuFxyXG4gICAgICogQHBhcmFtIGFuY2hvciBjZWxs55qE6ZSa54K5XHJcbiAgICAgKi9cclxuICAgIHB1YmxpYyBpbml0RGF0YShkYXRhOiBUW10sIHByZWZhYjogY2MuUHJlZmFiLCBzaXplPzogY2MuU2l6ZSwgYW5jaG9yOiBjYy5WZWMyID0gY2MudjIoMC41LCAwLjUpKSB7XHJcbiAgICAgICAgdGhpcy5kYXRhcyA9IGRhdGE7XHJcbiAgICAgICAgdGhpcy5zaXplID0gc2l6ZTtcclxuICAgICAgICB0aGlzLmFuY2hvciA9IGFuY2hvcjtcclxuICAgICAgICB0aGlzLnByZWZhYiA9IHByZWZhYjtcclxuICAgICAgICBsZXQgbGVuID0gdGhpcy5jZWxsTWF4TnVtID8gdGhpcy5jZWxsTWF4TnVtIDogZGF0YS5sZW5ndGg7XHJcbiAgICAgICAgdGhpcy5jdXJTdGFydEluZGV4ID0gMDtcclxuICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGxlbjsgKytpKSB7XHJcbiAgICAgICAgICAgIGxldCBpdGVtQ2VsbCA9IHRoaXMuaXRlbUNlbGxzW2ldO1xyXG4gICAgICAgICAgICBpZiAoIWl0ZW1DZWxsKSB7XHJcbiAgICAgICAgICAgICAgICBsZXQgbm9kZSA9IG5ldyBjYy5Ob2RlKCdMb29wTGlzdENlbGwnKVxyXG4gICAgICAgICAgICAgICAgaXRlbUNlbGwgPSB0aGlzLml0ZW1DZWxsc1tpXSA9IG5ldyBJdGVtQ2VsbDxUPihub2RlLCB0aGlzKTtcclxuICAgICAgICAgICAgICAgIG5vZGUuc2V0QW5jaG9yUG9pbnQoYW5jaG9yKTtcclxuICAgICAgICAgICAgICAgIG5vZGUuc2V0UGFyZW50KHRoaXMuc2Nyb2xsVmlldy5jb250ZW50KTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBsZXQgZGF0YSA9IHRoaXMuZGF0YXNbdGhpcy5jdXJTdGFydEluZGV4ICsgaV07XHJcbiAgICAgICAgICAgIGxldCBjZWxsU2l6ZSA9IGRhdGEuc2l6ZSA/IGRhdGEuc2l6ZSA6IHNpemU7XHJcbiAgICAgICAgICAgIGl0ZW1DZWxsLmluaXQoZGF0YSwgY2VsbFNpemUsIHRoaXMuY3VyU3RhcnRJbmRleCArIGksIGksIHRoaXMpO1xyXG4gICAgICAgIH1cclxuICAgICAgICBmb3IgKGxldCBpID0gZGF0YS5sZW5ndGgsIGxlbiA9IHRoaXMuaXRlbUNlbGxzLmxlbmd0aDsgaSA8IGxlbjsgKytpKSB7XHJcbiAgICAgICAgICAgIHRoaXMucmVjaXJjbGVTaG93Tm9kZSh0aGlzLml0ZW1DZWxsc1tpXS5yZWNpcmNsZSgpKTtcclxuICAgICAgICAgICAgdGhpcy5pdGVtQ2VsbHNbaV0uZGVzdHJveSgpXHJcbiAgICAgICAgICAgIHRoaXMuaXRlbUNlbGxzW2ldID0gbnVsbDtcclxuICAgICAgICB9XHJcbiAgICAgICAgdGhpcy51cGRhdGVOb2RlcygpO1xyXG4gICAgfVxyXG5cclxuICAgIC8qKlxyXG4gICAgICog5Y6L5YWl5paw55qE5pWw5o2uXHJcbiAgICAgKiBAcGFyYW0gZGF0YXMgXHJcbiAgICAgKi9cclxuICAgIHB1YmxpYyBwdXNoRGF0YXMoZGF0YXM6IFRbXSkge1xyXG4gICAgICAgIGxldCBsZW5ndGggPSB0aGlzLmRhdGFzLmxlbmd0aDtcclxuICAgICAgICBmb3IgKGxldCBpID0gMCwgbGVuID0gZGF0YXMubGVuZ3RoOyBpIDwgbGVuOyArK2kpIHtcclxuICAgICAgICAgICAgbGV0IGRhdGEgPSBkYXRhc1tpXTtcclxuICAgICAgICAgICAgdGhpcy5kYXRhcy5wdXNoKGRhdGEpO1xyXG4gICAgICAgICAgICBsZXQgaW5kZXggPSBsZW5ndGggKyBpO1xyXG4gICAgICAgICAgICB0aGlzLmFkZE5vZGVGcm9tSW5kZXgoaW5kZXgpO1xyXG4gICAgICAgIH1cclxuICAgIH1cclxuICAgIC8qKlxyXG4gICAgICog5o+S5YWl5paw55qE5pWw5o2uXHJcbiAgICAgKiBAcGFyYW0gZGF0YSBcclxuICAgICAqIEBwYXJhbSBpbnNlcnRJbmRleCBcclxuICAgICAqL1xyXG4gICAgcHVibGljIGluc2VydERhdGEoZGF0YTogVCwgaW5zZXJ0SW5kZXg6IG51bWJlcikge1xyXG4gICAgICAgIGlmICh0aGlzLmRhdGFzLmxlbmd0aCA+PSBpbnNlcnRJbmRleCkge1xyXG4gICAgICAgICAgICB0aGlzLmRhdGFzLnNwbGljZShpbnNlcnRJbmRleCwgMCwgZGF0YSk7XHJcbiAgICAgICAgICAgIHRoaXMuYWRkTm9kZUZyb21JbmRleChpbnNlcnRJbmRleCk7XHJcbiAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgdGhpcy5wdXNoRGF0YXMoW2RhdGFdKTtcclxuICAgICAgICB9XHJcbiAgICB9XHJcbiAgICAvKipcclxuICAgICAqIOenu+mZpOWvueW6lOaVsOaNrlxyXG4gICAgICogQHBhcmFtIHJlbW92ZUluZGV4IFxyXG4gICAgICovXHJcbiAgICBwdWJsaWMgcmVtb3ZlRGF0YShyZW1vdmVJbmRleDogbnVtYmVyKSB7XHJcbiAgICAgICAgaWYgKHRoaXMuZGF0YXMubGVuZ3RoID49IHJlbW92ZUluZGV4KSB7XHJcbiAgICAgICAgICAgIHRoaXMuZGF0YXMuc3BsaWNlKHJlbW92ZUluZGV4LCAxKTtcclxuICAgICAgICAgICAgaWYgKHRoaXMuY2VsbE1heE51bSkge1xyXG4gICAgICAgICAgICAgICAgbGV0IGNlbGxJbmRleCA9IHJlbW92ZUluZGV4IC0gdGhpcy5jdXJTdGFydEluZGV4O1xyXG4gICAgICAgICAgICAgICAgLy/lnKjkvb/nlKjojIPlm7TlhoVcclxuICAgICAgICAgICAgICAgIGlmIChjZWxsSW5kZXggPj0gMCAmJiBjZWxsSW5kZXggPCB0aGlzLmNlbGxNYXhOdW0pIHtcclxuICAgICAgICAgICAgICAgICAgICBsZXQgaXRlbUNlbGwgPSB0aGlzLml0ZW1DZWxsc1tjZWxsSW5kZXhdO1xyXG4gICAgICAgICAgICAgICAgICAgIGxldCBub2RlU2lkZXMgPSBnZXROb2RlQm9yZGVyKGl0ZW1DZWxsLCBbdHJ1ZSwgdHJ1ZSwgdHJ1ZSwgdHJ1ZV0pO1xyXG4gICAgICAgICAgICAgICAgICAgIGxldCBjaGFuZ2VTaXplID0gY2Muc2l6ZSgtaXRlbUNlbGwuc2l6ZS53aWR0aCwgLWl0ZW1DZWxsLnNpemUuaGVpZ2h0KTtcclxuICAgICAgICAgICAgICAgICAgICBpdGVtQ2VsbC5zaXplID0gY2Muc2l6ZSgwLCAwKTtcclxuICAgICAgICAgICAgICAgICAgICB0aGlzLmRlYWxDaGFuZ2VTaXplKGl0ZW1DZWxsLCBub2RlU2lkZXMsIGNoYW5nZVNpemUpLnRoZW4oKCkgPT4ge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAvL+abtOaWsOaVsOaNrlxyXG4gICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gY2VsbEluZGV4OyBpIDwgdGhpcy5jZWxsTWF4TnVtOyBpKyspIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBjdXJEYXRhSW5kZXggPSB0aGlzLmN1clN0YXJ0SW5kZXggKyBpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGN1ckRhdGEgPSB0aGlzLmRhdGFzW2N1ckRhdGFJbmRleF07XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgY3VyQ2VsbFNpemU6IGNjLlNpemUgPSBjdXJEYXRhLnNpemUgPyBjdXJEYXRhLnNpemUgOiB0aGlzLnNpemU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLml0ZW1DZWxsc1tpXS5pbml0KGN1ckRhdGEsIGN1ckNlbGxTaXplLCBjdXJEYXRhSW5kZXgsIGksIHRoaXMpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5pdGVtQ2VsbHNbaV0udXBkYXRlU2hvd05vZGUodGhpcy5yZW5kZXJMYXllcik7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICB9KTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgIGxldCBpdGVtQ2VsbCA9IHRoaXMuaXRlbUNlbGxzLnNwbGljZShyZW1vdmVJbmRleCwgMSlbMF07XHJcbiAgICAgICAgICAgICAgICBsZXQgbm9kZVNpZGVzID0gZ2V0Tm9kZUJvcmRlcihpdGVtQ2VsbCwgW3RydWUsIHRydWUsIHRydWUsIHRydWVdKTtcclxuICAgICAgICAgICAgICAgIGxldCBjaGFuZ2VTaXplID0gY2Muc2l6ZSgtaXRlbUNlbGwuc2l6ZS53aWR0aCwgLWl0ZW1DZWxsLnNpemUuaGVpZ2h0KTtcclxuICAgICAgICAgICAgICAgIGl0ZW1DZWxsLnNpemUgPSBjYy5zaXplKDAsIDApO1xyXG4gICAgICAgICAgICAgICAgdGhpcy5kZWFsQ2hhbmdlU2l6ZShpdGVtQ2VsbCwgbm9kZVNpZGVzLCBjaGFuZ2VTaXplKS50aGVuKCgpID0+IHtcclxuICAgICAgICAgICAgICAgICAgICB0aGlzLnJlY2lyY2xlU2hvd05vZGUoaXRlbUNlbGwucmVjaXJjbGUoKSlcclxuICAgICAgICAgICAgICAgICAgICBpdGVtQ2VsbC5ub2RlLmRlc3Ryb3koKTtcclxuICAgICAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfVxyXG4gICAgfVxyXG4gICAgLyoqXHJcbiAgICAgKiDku47mn5DkuKrmlbDmja7lvIDlp4vmm7TmlrBcclxuICAgICAqIEBwYXJhbSBkYXRhSW5kZXggXHJcbiAgICAgKi9cclxuICAgIHByaXZhdGUgYXN5bmMgYWRkTm9kZUZyb21JbmRleChkYXRhSW5kZXg6IG51bWJlcikge1xyXG4gICAgICAgIGxldCBkYXRhID0gdGhpcy5kYXRhc1tkYXRhSW5kZXhdO1xyXG4gICAgICAgIGxldCBjZWxsU2l6ZTogY2MuU2l6ZSA9IGRhdGEuc2l6ZSA/IGRhdGEuc2l6ZSA6IHRoaXMuc2l6ZTtcclxuICAgICAgICAvL+aYr+WQpuW8gOWQr2NlbGzlvqrnjq9cclxuICAgICAgICBpZiAodGhpcy5jZWxsTWF4TnVtKSB7XHJcbiAgICAgICAgICAgIGxldCBjZWxsSW5kZXggPSBkYXRhSW5kZXggLSB0aGlzLmN1clN0YXJ0SW5kZXg7XHJcbiAgICAgICAgICAgIC8v5Zyo5L2/55So6IyD5Zu05YaFXHJcbiAgICAgICAgICAgIGlmIChjZWxsSW5kZXggPj0gMCAmJiBjZWxsSW5kZXggPCB0aGlzLmNlbGxNYXhOdW0pIHtcclxuICAgICAgICAgICAgICAgIC8v5pu05paw5pWw5o2uXHJcbiAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gY2VsbEluZGV4OyBpIDwgdGhpcy5jZWxsTWF4TnVtOyBpKyspIHtcclxuICAgICAgICAgICAgICAgICAgICBsZXQgY3VyRGF0YUluZGV4ID0gdGhpcy5jdXJTdGFydEluZGV4ICsgaTtcclxuICAgICAgICAgICAgICAgICAgICBsZXQgY3VyRGF0YSA9IHRoaXMuZGF0YXNbY3VyRGF0YUluZGV4XTtcclxuICAgICAgICAgICAgICAgICAgICBsZXQgY3VyQ2VsbFNpemU6IGNjLlNpemUgPSBjdXJEYXRhLnNpemUgPyBjdXJEYXRhLnNpemUgOiB0aGlzLnNpemU7XHJcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5pdGVtQ2VsbHNbaV0uaW5pdChjdXJEYXRhLCBjdXJDZWxsU2l6ZSwgY3VyRGF0YUluZGV4LCBpLCB0aGlzKTtcclxuICAgICAgICAgICAgICAgICAgICB0aGlzLml0ZW1DZWxsc1tpXS51cGRhdGVTaG93Tm9kZSh0aGlzLnJlbmRlckxheWVyKTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIC8v6I635Y+W5b2T5YmN55qE5L2N572uXHJcbiAgICAgICAgICAgICAgICBsZXQgbm9kZVNpZGVzOiBJQm9yZGVyID0gbnVsbDtcclxuICAgICAgICAgICAgICAgIGxldCBpdGVtQ2VsbDogSXRlbUNlbGw8VD4gPSB0aGlzLml0ZW1DZWxsc1tjZWxsSW5kZXhdO1xyXG4gICAgICAgICAgICAgICAgaWYgKGl0ZW1DZWxsKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgbm9kZVNpZGVzID0gZ2V0Tm9kZUJvcmRlcihpdGVtQ2VsbCwgW3RydWUsIHRydWUsIHRydWUsIHRydWVdKTtcclxuICAgICAgICAgICAgICAgICAgICBpdGVtQ2VsbC5ub2RlLndpZHRoID0gMDtcclxuICAgICAgICAgICAgICAgICAgICBpdGVtQ2VsbC5ub2RlLmhlaWdodCA9IDA7XHJcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5kZWFsQ2hhbmdlU2l6ZShpdGVtQ2VsbCwgbm9kZVNpZGVzLCBjZWxsU2l6ZSkudGhlbigoKSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGl0ZW1DZWxsLm5vZGUud2lkdGggPSBjZWxsU2l6ZS53aWR0aDtcclxuICAgICAgICAgICAgICAgICAgICAgICAgaXRlbUNlbGwubm9kZS5oZWlnaHQgPSBjZWxsU2l6ZS5oZWlnaHQ7XHJcbiAgICAgICAgICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAvL+iOt+WPluW9k+WJjeeahOS9jee9rlxyXG4gICAgICAgICAgICBsZXQgbm9kZVNpZGVzOiBJQm9yZGVyID0gbnVsbDtcclxuICAgICAgICAgICAgaWYgKHRoaXMuaXRlbUNlbGxzW2RhdGFJbmRleF0pIHtcclxuICAgICAgICAgICAgICAgIG5vZGVTaWRlcyA9IGdldE5vZGVCb3JkZXIodGhpcy5pdGVtQ2VsbHNbZGF0YUluZGV4XSwgW3RydWUsIHRydWUsIHRydWUsIHRydWVdKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBsZXQgbm9kZSA9IG5ldyBjYy5Ob2RlKCdMb29wTGlzdENlbGwnKVxyXG4gICAgICAgICAgICBub2RlLnNldEFuY2hvclBvaW50KHRoaXMuYW5jaG9yKTtcclxuICAgICAgICAgICAgbm9kZS5zZXRQYXJlbnQodGhpcy5zY3JvbGxWaWV3LmNvbnRlbnQpO1xyXG4gICAgICAgICAgICBub2RlLnNldFNpYmxpbmdJbmRleChkYXRhSW5kZXgpO1xyXG4gICAgICAgICAgICBsZXQgaXRlbUNlbGw6IEl0ZW1DZWxsPFQ+ID0gbmV3IEl0ZW1DZWxsPFQ+KG5vZGUsIHRoaXMpO1xyXG4gICAgICAgICAgICB0aGlzLml0ZW1DZWxscy5zcGxpY2UoZGF0YUluZGV4LCAwLCBpdGVtQ2VsbClcclxuICAgICAgICAgICAgaXRlbUNlbGwuaW5pdChkYXRhLCBjZWxsU2l6ZSwgZGF0YUluZGV4LCBkYXRhSW5kZXgsIHRoaXMpO1xyXG4gICAgICAgICAgICBpZiAoIW5vZGVTaWRlcykge1xyXG4gICAgICAgICAgICAgICAgYXdhaXQgbmV3IFByb21pc2U8dm9pZD4oKHJlc29sdmUsIHJlamVjdCkgPT4ge1xyXG4gICAgICAgICAgICAgICAgICAgIHJlcXVlc3RBbmltYXRpb25GcmFtZSgoKSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIG5vZGVTaWRlcyA9IGdldE5vZGVCb3JkZXIoaXRlbUNlbGwsIFt0cnVlLCB0cnVlLCB0cnVlLCB0cnVlXSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHJlc29sdmUoKTtcclxuICAgICAgICAgICAgICAgICAgICB9KVxyXG4gICAgICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgaWYgKG5vZGVTaWRlcykge1xyXG4gICAgICAgICAgICAgICAgaXRlbUNlbGwubm9kZS53aWR0aCA9IDA7XHJcbiAgICAgICAgICAgICAgICBpdGVtQ2VsbC5ub2RlLmhlaWdodCA9IDA7XHJcbiAgICAgICAgICAgICAgICB0aGlzLmRlYWxDaGFuZ2VTaXplKGl0ZW1DZWxsLCBub2RlU2lkZXMsIGNlbGxTaXplKS50aGVuKCgpID0+IHtcclxuICAgICAgICAgICAgICAgICAgICBpdGVtQ2VsbC5ub2RlLndpZHRoID0gY2VsbFNpemUud2lkdGg7XHJcbiAgICAgICAgICAgICAgICAgICAgaXRlbUNlbGwubm9kZS5oZWlnaHQgPSBjZWxsU2l6ZS5oZWlnaHQ7XHJcbiAgICAgICAgICAgICAgICB9KTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB0aGlzLmRlYWxJdGVtU2hvdyhpdGVtQ2VsbCk7XHJcbiAgICAgICAgfVxyXG4gICAgfVxyXG5cclxuICAgIC8qKlxyXG4gICAgICog5aSE55CG5YiX6KGo55qE5b6q546v5Yip55SoXHJcbiAgICAgKiBAcGFyYW0gb2Zmc2V0IFxyXG4gICAgICogQHBhcmFtIGRhdGFJbmRleHMgXHJcbiAgICAgKi9cclxuICAgIHByaXZhdGUgZGVhbExvb3BMaXN0KG9mZnNldDogY2MuVmVjMywgc2hvd0NlbGxzOiBJdGVtQ2VsbDxUPltdKSB7XHJcbiAgICAgICAgbGV0IHN0YXJ0Q2VsbCA9IHNob3dDZWxsc1swXTtcclxuICAgICAgICBsZXQgZW5kQ2VsbCA9IHNob3dDZWxsc1tzaG93Q2VsbHMubGVuZ3RoIC0gMV07XHJcbiAgICAgICAgaWYgKHRoaXMuc2Nyb2xsVmlldy52ZXJ0aWNhbCkge1xyXG4gICAgICAgICAgICAvKirlhoXlrrnkuIrnp7sgKi9cclxuICAgICAgICAgICAgaWYgKG9mZnNldC55ID4gMCkge1xyXG4gICAgICAgICAgICAgICAgLy/lt7Lnu4/liLDovr7mnIDlkI7lgJLmlbDnrKzkuozkuKroioLngrnlubbkuJTov5jmnInmlbDmja5cclxuICAgICAgICAgICAgICAgIGlmICh0aGlzLnNjcm9sbFZpZXcuY29udGVudC55ID49ICgtIHRoaXMuaXRlbUNlbGxzW3RoaXMuaXRlbUNlbGxzLmxlbmd0aCAtIDJdLm5vZGUueSAtIHRoaXMudmlld1NpZGVzLnNpemUuaGVpZ2h0KSAmJiBlbmRDZWxsLmRhdGFJbmRleCA8IHRoaXMuZGF0YXMubGVuZ3RoIC0gMikge1xyXG4gICAgICAgICAgICAgICAgICAgIC8v5pi+56S65byA5aeL5pWw5o2u5LiL5qCHKOi/memHjC0x5piv5oOz6KaB6aG26YOo55WZ5LiA5LiqaXRlbWNlbGzlgZrnvJPlhrIpXHJcbiAgICAgICAgICAgICAgICAgICAgbGV0IHNob3dTdGFydCA9IHN0YXJ0Q2VsbC5kYXRhSW5kZXggLSAxO1xyXG4gICAgICAgICAgICAgICAgICAgIC8v5Ymp5L2Z5Y+v5bGV56S655qE5pWw5o2u6YePIFxyXG4gICAgICAgICAgICAgICAgICAgIGxldCBsZWF2ZSA9IHRoaXMuZGF0YXMubGVuZ3RoIC0gc2hvd1N0YXJ0O1xyXG4gICAgICAgICAgICAgICAgICAgIC8v6K6h566X5bqU6K+l5LuO6YKj5Liq5L2N572u5byA5aeL6YeN5paw6LWL5YC877yM5Zug5Li65aaC5p6c55u05o6l56e75Yqo5Yiw5pyA5LiK5pa577yM5pWw5o2u6YeP5LiN5aSf6KaG55uW5omA5pyJ55qEY2VsbFxyXG4gICAgICAgICAgICAgICAgICAgIGxldCBjZWxsU3RhcnRJbmRleCA9IE1hdGgubWF4KDAsIHRoaXMuaXRlbUNlbGxzLmxlbmd0aCAtIGxlYXZlKTtcclxuICAgICAgICAgICAgICAgICAgICAvL+iuoeeul+esrOS4gOS4qmNlbGznmoTmlbDmja7kuIvmoIdcclxuICAgICAgICAgICAgICAgICAgICB0aGlzLmN1clN0YXJ0SW5kZXggPSBzaG93U3RhcnQgLSBjZWxsU3RhcnRJbmRleDtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgbGV0IGNlbGxUb3AgPSBnZXROb2RlQm9yZGVyKHRoaXMuaXRlbUNlbGxzW3N0YXJ0Q2VsbC5jZWxsSW5kZXhdLCBbdHJ1ZV0pLnRvcFNpZGU7XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIGxldCBjb250ZW50SGVpZ2h0ID0gMDtcclxuICAgICAgICAgICAgICAgICAgICBsZXQgdGFyZ2V0WSA9IDA7XHJcbiAgICAgICAgICAgICAgICAgICAgbGV0IGp1bXBGaXJzdCA9IHRydWU7XHJcbiAgICAgICAgICAgICAgICAgICAgbGV0IHNob3dJbmRleCA9IDA7XHJcbiAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDAsIGxlbiA9IHRoaXMuaXRlbUNlbGxzLmxlbmd0aDsgaSA8IGxlbjsgKytpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpID49IGNlbGxTdGFydEluZGV4KSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvL+WwhuW9k+WJjeW3sue7j+aYvuekuueahHNob3dOb2Rl6IqC54K555u05o6l6YeN5paw6K6+572u5Yiw56e75Yqo5ZCO55qE6IqC54K55LiKXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc2hvd0luZGV4IDwgc2hvd0NlbGxzLmxlbmd0aCAmJiAhanVtcEZpcnN0KSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHNob3dJbmRleCA9PSAwKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldFkgPSBjb250ZW50SGVpZ2h0O1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgc2hvd05vZGUgPSBzaG93Q2VsbHNbc2hvd0luZGV4XS5sb3N0U2hvd05vZGUoKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaG93SW5kZXgrKztcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLml0ZW1DZWxsc1tpXS5nZXRTaG93Tm9kZShzaG93Tm9kZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBqdW1wRmlyc3QgPSBmYWxzZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgZGF0YUluZGV4ID0gdGhpcy5jdXJTdGFydEluZGV4ICsgaTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGRhdGEgPSB0aGlzLmRhdGFzW2RhdGFJbmRleF07XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBjZWxsU2l6ZSA9IGRhdGEuc2l6ZSA/IGRhdGEuc2l6ZSA6IHRoaXMuc2l6ZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgY29udGVudEhlaWdodCArPSBjZWxsU2l6ZS5oZWlnaHQ7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuaXRlbUNlbGxzW2ldLmluaXQoZGF0YSwgY2VsbFNpemUsIGRhdGFJbmRleCwgaSwgdGhpcyk7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICAvL+WwhmNvbnRlbnTnmoTkvY3nva7np7vliqjliLDmnIDkuIrmlrnlubblr7npvZDnp7vliqjliY3nmoTnirbmgIFcclxuICAgICAgICAgICAgICAgICAgICBsZXQgcG9zWSA9IHRhcmdldFkgKyAoY2VsbFRvcCAtIHRoaXMudmlld1NpZGVzLnRvcFNpZGUpXHJcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5zY3JvbGxWaWV3LmNvbnRlbnQuc2V0UG9zaXRpb24oY2MudjModGhpcy5zY3JvbGxWaWV3LmNvbnRlbnQucG9zaXRpb24ueCwgcG9zWSkpO1xyXG4gICAgICAgICAgICAgICAgICAgIHRoaXMuc2Nyb2xsVmlldy5zY3JvbGxUb09mZnNldChjYy52MigwLCBwb3NZICsgZW5kQ2VsbC5zaXplLmhlaWdodCksIDEpXHJcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5sYXN0UG9zID0gbnVsbDtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfSAvL+WGheWuueS4i+enu1xyXG4gICAgICAgICAgICBlbHNlIGlmIChvZmZzZXQueSA8IDApIHtcclxuICAgICAgICAgICAgICAgIC8v5bey57uP5Yiw6L6+56ys5LqM5Liq6IqC54K55bm25LiU6L+Y5pyJ5pWw5o2uXHJcbiAgICAgICAgICAgICAgICBpZiAodGhpcy5zY3JvbGxWaWV3LmNvbnRlbnQueSA8ICgtIHRoaXMuaXRlbUNlbGxzWzJdLm5vZGUueSkgJiYgc3RhcnRDZWxsLmRhdGFJbmRleCA+IDEpIHtcclxuICAgICAgICAgICAgICAgICAgICAvL+WxleekuueahOacgOWQjuS4gOS4quaVsOaNruS4i+ihqO+8jCsx5piv5Li65LqG5Zyo5bqV6YOo6aKE55WZ5LiA6YOo5YiG56m66Ze0XHJcbiAgICAgICAgICAgICAgICAgICAgbGV0IHNob3dFbmRJbmRleCA9IGVuZENlbGwuZGF0YUluZGV4ICsgMTtcclxuICAgICAgICAgICAgICAgICAgICAvL+iuoeeul+W6lOivpeS7jumCo+S4quS9jee9ruW8gOWni+mHjeaWsOi1i+WAvO+8jOWboOS4uuWmguaenOebtOaOpeenu+WKqOWIsOacgOS4i+aWue+8jOaVsOaNrumHj+S4jeWkn+imhuebluaJgOacieeahGNlbGxcclxuICAgICAgICAgICAgICAgICAgICBsZXQgY2VsbEVuZEluZGV4ID0gTWF0aC5taW4odGhpcy5pdGVtQ2VsbHMubGVuZ3RoIC0gMiwgc2hvd0VuZEluZGV4IC0gMSk7XHJcbiAgICAgICAgICAgICAgICAgICAgLy/orqHnrpfnrKzkuIDkuKpjZWxs55qE5pWw5o2u5LiL5qCHXHJcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJTdGFydEluZGV4ID0gTWF0aC5tYXgoc2hvd0VuZEluZGV4IC0gKHRoaXMuaXRlbUNlbGxzLmxlbmd0aCAtIDEpLCAwKTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgLy/lsIZjb250ZW5055qE5L2N572u56e75Yqo5Yiw5pyA5LiL5pa55bm25a+56b2Q56e75Yqo5YmN55qE54q25oCBXHJcbiAgICAgICAgICAgICAgICAgICAgbGV0IGNlbGxUb3AgPSBnZXROb2RlQm9yZGVyKHRoaXMuaXRlbUNlbGxzW3N0YXJ0Q2VsbC5jZWxsSW5kZXhdLCBbdHJ1ZV0pLnRvcFNpZGU7XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIGxldCBjb250ZW50SGVpZ2h0ID0gMDtcclxuICAgICAgICAgICAgICAgICAgICBsZXQgc2hvd0luZGV4ID0gc2hvd0NlbGxzLmxlbmd0aCAtIDE7XHJcbiAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IHRoaXMuaXRlbUNlbGxzLmxlbmd0aCAtIDE7IGkgPj0gMDsgLS1pKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpIDw9IGNlbGxFbmRJbmRleCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgLy/lsIblvZPliY3lt7Lnu4/mmL7npLrnmoRzaG93Tm9kZeiKgueCueebtOaOpemHjeaWsOiuvue9ruWIsOenu+WKqOWQjueahOiKgueCueS4ilxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHNob3dJbmRleCA+PSAwKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHNob3dOb2RlID0gc2hvd0NlbGxzW3Nob3dJbmRleF0ubG9zdFNob3dOb2RlKCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2hvd0luZGV4LS07XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5pdGVtQ2VsbHNbaV0uZ2V0U2hvd05vZGUoc2hvd05vZGUpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaG93SW5kZXgtLTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgZGF0YUluZGV4ID0gdGhpcy5jdXJTdGFydEluZGV4ICsgaTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGRhdGEgPSB0aGlzLmRhdGFzW2RhdGFJbmRleF07XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBjZWxsU2l6ZSA9IGRhdGEuc2l6ZSA/IGRhdGEuc2l6ZSA6IHRoaXMuc2l6ZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHNob3dJbmRleCA8IC0xKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250ZW50SGVpZ2h0ICs9IGNlbGxTaXplLmhlaWdodDtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLml0ZW1DZWxsc1tpXS5pbml0KGRhdGEsIGNlbGxTaXplLCBkYXRhSW5kZXgsIGksIHRoaXMpO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAgICAgLy/lsIZjb250ZW5055qE5L2N572u56e75Yqo5Yiw5pyA5LiL5pa55bm25a+56b2Q56e75Yqo5YmN55qE54q25oCBXHJcbiAgICAgICAgICAgICAgICAgICAgbGV0IHBvc1kgPSBjb250ZW50SGVpZ2h0ICsgKGNlbGxUb3AgLSB0aGlzLnZpZXdTaWRlcy50b3BTaWRlKVxyXG4gICAgICAgICAgICAgICAgICAgIHRoaXMuc2Nyb2xsVmlldy5jb250ZW50LnNldFBvc2l0aW9uKGNjLnYzKHRoaXMuc2Nyb2xsVmlldy5jb250ZW50LnBvc2l0aW9uLngsIHBvc1kpKTtcclxuICAgICAgICAgICAgICAgICAgICB0aGlzLnNjcm9sbFZpZXcuc2Nyb2xsVG9PZmZzZXQoY2MudjIoMCwgcG9zWSAtIHN0YXJ0Q2VsbC5zaXplLmhlaWdodCksIDEpXHJcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5sYXN0UG9zID0gbnVsbDtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH0gZWxzZSBpZiAodGhpcy5zY3JvbGxWaWV3Lmhvcml6b250YWwpIHtcclxuICAgICAgICAgICAgaWYgKG9mZnNldC54IDwgMCkge1xyXG4gICAgICAgICAgICAgICAgLy/lt7Lnu4/liLDovr7mnIDlkI7lgJLmlbDnrKzkuozkuKroioLngrnlubbkuJTov5jmnInmlbDmja5cclxuICAgICAgICAgICAgICAgIGlmICh0aGlzLnNjcm9sbFZpZXcuY29udGVudC54IDw9ICgtICh0aGlzLml0ZW1DZWxsc1t0aGlzLml0ZW1DZWxscy5sZW5ndGggLSAyXS5ub2RlLnggLSB0aGlzLnZpZXdTaWRlcy5zaXplLndpZHRoKSkgJiYgZW5kQ2VsbC5kYXRhSW5kZXggPCB0aGlzLmRhdGFzLmxlbmd0aCAtIDIpIHtcclxuICAgICAgICAgICAgICAgICAgICAvL+aYvuekuuW8gOWni+aVsOaNruS4i+aghyjov5nph4wtMeaYr+aDs+imgeW3puS+p+eVmeS4gOS4qml0ZW1jZWxs5YGa57yT5YayKVxyXG4gICAgICAgICAgICAgICAgICAgIGxldCBzaG93U3RhcnQgPSBzdGFydENlbGwuZGF0YUluZGV4IC0gMTtcclxuICAgICAgICAgICAgICAgICAgICAvL+WJqeS9meWPr+WxleekuueahOaVsOaNrumHjyBcclxuICAgICAgICAgICAgICAgICAgICBsZXQgbGVhdmUgPSB0aGlzLmRhdGFzLmxlbmd0aCAtIHNob3dTdGFydDtcclxuICAgICAgICAgICAgICAgICAgICAvL+iuoeeul+W6lOivpeS7jumCo+S4quS9jee9ruW8gOWni+mHjeaWsOi1i+WAvO+8jOWboOS4uuWmguaenOebtOaOpeenu+WKqOWIsOacgOW3puS+p++8jOaVsOaNrumHj+S4jeWkn+imhuebluaJgOacieeahGNlbGxcclxuICAgICAgICAgICAgICAgICAgICBsZXQgY2VsbFN0YXJ0SW5kZXggPSBNYXRoLm1heCgwLCB0aGlzLml0ZW1DZWxscy5sZW5ndGggLSBsZWF2ZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgLy/orqHnrpfnrKzkuIDkuKpjZWxs55qE5pWw5o2u5LiL5qCHXHJcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJTdGFydEluZGV4ID0gc2hvd1N0YXJ0IC0gY2VsbFN0YXJ0SW5kZXg7XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIGxldCBjZWxsTGVmdCA9IGdldE5vZGVCb3JkZXIodGhpcy5pdGVtQ2VsbHNbc3RhcnRDZWxsLmNlbGxJbmRleF0sIFtmYWxzZSwgZmFsc2UsIHRydWVdKS5sZWZ0U2lkZTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgbGV0IGNvbnRlbnRXaWR0aCA9IDA7XHJcbiAgICAgICAgICAgICAgICAgICAgbGV0IHRhcmdldFggPSAwO1xyXG4gICAgICAgICAgICAgICAgICAgIGxldCBqdW1wRmlyc3QgPSB0cnVlO1xyXG4gICAgICAgICAgICAgICAgICAgIGxldCBzaG93SW5kZXggPSAwO1xyXG4gICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBsZW4gPSB0aGlzLml0ZW1DZWxscy5sZW5ndGg7IGkgPCBsZW47ICsraSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoaSA+PSBjZWxsU3RhcnRJbmRleCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgLy/lsIblvZPliY3lt7Lnu4/mmL7npLrnmoRzaG93Tm9kZeiKgueCueebtOaOpemHjeaWsOiuvue9ruWIsOenu+WKqOWQjueahOiKgueCueS4ilxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHNob3dJbmRleCA8IHNob3dDZWxscy5sZW5ndGggJiYgIWp1bXBGaXJzdCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzaG93SW5kZXggPT0gMCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0YXJnZXRYID0gY29udGVudFdpZHRoO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgc2hvd05vZGUgPSBzaG93Q2VsbHNbc2hvd0luZGV4XS5sb3N0U2hvd05vZGUoKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaG93SW5kZXgrKztcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLml0ZW1DZWxsc1tpXS5nZXRTaG93Tm9kZShzaG93Tm9kZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBqdW1wRmlyc3QgPSBmYWxzZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgZGF0YUluZGV4ID0gdGhpcy5jdXJTdGFydEluZGV4ICsgaTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGRhdGEgPSB0aGlzLmRhdGFzW2RhdGFJbmRleF07XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBjZWxsU2l6ZSA9IGRhdGEuc2l6ZSA/IGRhdGEuc2l6ZSA6IHRoaXMuc2l6ZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgY29udGVudFdpZHRoICs9IGNlbGxTaXplLndpZHRoO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLml0ZW1DZWxsc1tpXS5pbml0KGRhdGEsIGNlbGxTaXplLCBkYXRhSW5kZXgsIGksIHRoaXMpO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAgICAgLy/lsIZjb250ZW5055qE5L2N572u56e75Yqo5Yiw5pyA5bem5L6n5bm25a+56b2Q56e75Yqo5YmN55qE54q25oCBXHJcbiAgICAgICAgICAgICAgICAgICAgbGV0IHBvc1ggPSAoY2VsbExlZnQgLSB0aGlzLnZpZXdTaWRlcy5sZWZ0U2lkZSkgLSB0YXJnZXRYO1xyXG4gICAgICAgICAgICAgICAgICAgIHRoaXMuc2Nyb2xsVmlldy5jb250ZW50LnNldFBvc2l0aW9uKGNjLnYzKHBvc1gsIHRoaXMuc2Nyb2xsVmlldy5jb250ZW50LnBvc2l0aW9uLnkpKTtcclxuICAgICAgICAgICAgICAgICAgICB0aGlzLnNjcm9sbFZpZXcuc2Nyb2xsVG9PZmZzZXQoY2MudjIoLShwb3NYIC0gZW5kQ2VsbC5zaXplLndpZHRoKSwgMCksIDEpXHJcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5sYXN0UG9zID0gbnVsbDtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfSBlbHNlIGlmIChvZmZzZXQueCA+IDApIHtcclxuICAgICAgICAgICAgICAgIC8v5bey57uP5Yiw6L6+56ys5LqM5Liq6IqC54K55bm25LiU6L+Y5pyJ5pWw5o2uXHJcbiAgICAgICAgICAgICAgICBpZiAodGhpcy5zY3JvbGxWaWV3LmNvbnRlbnQueCA+ICgtdGhpcy5pdGVtQ2VsbHNbMl0ubm9kZS54KSAmJiBzdGFydENlbGwuZGF0YUluZGV4ID4gMSkge1xyXG4gICAgICAgICAgICAgICAgICAgIC8v5bGV56S655qE5pyA5ZCO5LiA5Liq5pWw5o2u5LiL6KGo77yMKzHmmK/kuLrkuoblnKjlj7PkvqfpooTnlZnkuIDpg6jliIbnqbrpl7RcclxuICAgICAgICAgICAgICAgICAgICBsZXQgc2hvd0VuZEluZGV4ID0gZW5kQ2VsbC5kYXRhSW5kZXggKyAxO1xyXG4gICAgICAgICAgICAgICAgICAgIC8v6K6h566X5bqU6K+l5LuO6YKj5Liq5L2N572u5byA5aeL6YeN5paw6LWL5YC877yM5Zug5Li65aaC5p6c55u05o6l56e75Yqo5Yiw5pyA5Y+z5L6n77yM5pWw5o2u6YeP5LiN5aSf6KaG55uW5omA5pyJ55qEY2VsbFxyXG4gICAgICAgICAgICAgICAgICAgIGxldCBjZWxsRW5kSW5kZXggPSBNYXRoLm1pbih0aGlzLml0ZW1DZWxscy5sZW5ndGggLSAyLCBzaG93RW5kSW5kZXggLSAxKTtcclxuICAgICAgICAgICAgICAgICAgICAvL+iuoeeul+esrOS4gOS4qmNlbGznmoTmlbDmja7kuIvmoIdcclxuICAgICAgICAgICAgICAgICAgICB0aGlzLmN1clN0YXJ0SW5kZXggPSBNYXRoLm1heChzaG93RW5kSW5kZXggLSAodGhpcy5pdGVtQ2VsbHMubGVuZ3RoIC0gMSksIDApO1xyXG5cclxuICAgICAgICAgICAgICAgICAgICAvL+WwhmNvbnRlbnTnmoTkvY3nva7np7vliqjliLDmnIDlj7Pkvqflubblr7npvZDnp7vliqjliY3nmoTnirbmgIFcclxuICAgICAgICAgICAgICAgICAgICBsZXQgY2VsbExlZnQgPSBnZXROb2RlQm9yZGVyKHRoaXMuaXRlbUNlbGxzW3N0YXJ0Q2VsbC5jZWxsSW5kZXhdLCBbZmFsc2UsIGZhbHNlLCB0cnVlXSkubGVmdFNpZGU7XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIGxldCBjb250ZW50V2lkdGggPSAwO1xyXG4gICAgICAgICAgICAgICAgICAgIGxldCBzaG93SW5kZXggPSBzaG93Q2VsbHMubGVuZ3RoIC0gMTtcclxuICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gdGhpcy5pdGVtQ2VsbHMubGVuZ3RoIC0gMTsgaSA+PSAwOyAtLWkpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGkgPD0gY2VsbEVuZEluZGV4KSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvL+WwhuW9k+WJjeW3sue7j+aYvuekuueahHNob3dOb2Rl6IqC54K555u05o6l6YeN5paw6K6+572u5Yiw56e75Yqo5ZCO55qE6IqC54K55LiKXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc2hvd0luZGV4ID49IDApIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgc2hvd05vZGUgPSBzaG93Q2VsbHNbc2hvd0luZGV4XS5sb3N0U2hvd05vZGUoKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaG93SW5kZXgtLTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLml0ZW1DZWxsc1tpXS5nZXRTaG93Tm9kZShzaG93Tm9kZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNob3dJbmRleC0tO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBkYXRhSW5kZXggPSB0aGlzLmN1clN0YXJ0SW5kZXggKyBpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgZGF0YSA9IHRoaXMuZGF0YXNbZGF0YUluZGV4XTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGNlbGxTaXplID0gZGF0YS5zaXplID8gZGF0YS5zaXplIDogdGhpcy5zaXplO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoc2hvd0luZGV4IDwgLTEpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRlbnRXaWR0aCArPSBjZWxsU2l6ZS53aWR0aDtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLml0ZW1DZWxsc1tpXS5pbml0KGRhdGEsIGNlbGxTaXplLCBkYXRhSW5kZXgsIGksIHRoaXMpO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAgICAgLy/lsIZjb250ZW5055qE5L2N572u56e75Yqo5Yiw5pyA5Y+z5L6n5bm25a+56b2Q56e75Yqo5YmN55qE54q25oCBXHJcbiAgICAgICAgICAgICAgICAgICAgbGV0IHBvc1ggPSAoY2VsbExlZnQgLSB0aGlzLnZpZXdTaWRlcy5sZWZ0U2lkZSkgLSBjb250ZW50V2lkdGg7XHJcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5zY3JvbGxWaWV3LmNvbnRlbnQuc2V0UG9zaXRpb24oY2MudjMocG9zWCwgdGhpcy5zY3JvbGxWaWV3LmNvbnRlbnQucG9zaXRpb24ueSkpO1xyXG4gICAgICAgICAgICAgICAgICAgIHRoaXMuc2Nyb2xsVmlldy5zY3JvbGxUb09mZnNldChjYy52MigtIChwb3NYICsgc3RhcnRDZWxsLnNpemUud2lkdGgpLCAwKSwgMSlcclxuICAgICAgICAgICAgICAgICAgICB0aGlzLmxhc3RQb3MgPSBudWxsO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfVxyXG4gICAgfVxyXG5cclxuXHJcbiAgICAvKirmm7TmlrDoioLngrnnmoTmmL7npLogKi9cclxuICAgIHB1YmxpYyB1cGRhdGVOb2RlcygpIHtcclxuICAgICAgICBsZXQgc2hvd0NlbGxzOiBJdGVtQ2VsbDxUPltdID0gW107XHJcbiAgICAgICAgZm9yIChsZXQgaSA9IDAsIGxlbiA9IHRoaXMuaXRlbUNlbGxzLmxlbmd0aDsgaSA8IGxlbjsgKytpKSB7XHJcbiAgICAgICAgICAgIGxldCBpdGVtQ2VsbCA9IHRoaXMuaXRlbUNlbGxzW2ldO1xyXG4gICAgICAgICAgICBsZXQgaXNTaG93ID0gdGhpcy5kZWFsSXRlbVNob3coaXRlbUNlbGwpXHJcbiAgICAgICAgICAgIGlmIChpc1Nob3cpIHtcclxuICAgICAgICAgICAgICAgIHNob3dDZWxscy5wdXNoKGl0ZW1DZWxsKVxyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfVxyXG4gICAgICAgIHJldHVybiBzaG93Q2VsbHM7XHJcbiAgICB9XHJcblxyXG4gICAgLyoqXHJcbiAgICAgKiDlpITnkIZjZWxs55qE5pi+56S66ZqQ6JePXHJcbiAgICAgKiBAcGFyYW0gaXRlbUNlbGwgXHJcbiAgICAgKi9cclxuICAgIHByaXZhdGUgZGVhbEl0ZW1TaG93KGl0ZW1DZWxsOiBJdGVtQ2VsbDxUPikge1xyXG4gICAgICAgIGlmIChpdGVtQ2VsbCkge1xyXG4gICAgICAgICAgICBsZXQgaXNTaG93ID0gdGhpcy5jaGVja0luVmlldyhpdGVtQ2VsbCk7XHJcbiAgICAgICAgICAgIGlmIChpc1Nob3cpIHtcclxuICAgICAgICAgICAgICAgIGl0ZW1DZWxsLmhhc05vTm9kZSAmJiBpdGVtQ2VsbC51cGRhdGVTaG93KGlzU2hvdywgdGhpcy5wcmVmYWIsIHRoaXMuc2hvd05vZGVQb29sLmxlbmd0aCA+IDAgPyB0aGlzLnNob3dOb2RlUG9vbC5wb3AoKSA6IG51bGwsIHRoaXMucmVuZGVyTGF5ZXIpO1xyXG4gICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgIWl0ZW1DZWxsLmhhc05vTm9kZSAmJiB0aGlzLnJlY2lyY2xlU2hvd05vZGUoaXRlbUNlbGwucmVjaXJjbGUoKSk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgcmV0dXJuIGlzU2hvdztcclxuICAgICAgICB9XHJcbiAgICB9XHJcblxyXG5cclxuICAgIC8qKlxyXG4gICAgICog5qOA5p+l5piv5ZCm5Zyo5bGP5bmV5YaFXHJcbiAgICAgKiBAcGFyYW0gbm9kZSBcclxuICAgICAqIEByZXR1cm5zIFxyXG4gICAgICovXHJcbiAgICBwcml2YXRlIGNoZWNrSW5WaWV3KGl0ZW1DZWxsOiBJdGVtQ2VsbDxUPikge1xyXG4gICAgICAgIGxldCBub2RlU2lkZXMgPSBnZXROb2RlQm9yZGVyKGl0ZW1DZWxsLCBbdHJ1ZSwgdHJ1ZSwgdHJ1ZSwgdHJ1ZV0pO1xyXG4gICAgICAgIC8v6IqC54K55Y+z5L6n6L6557yY5Zyo5bGP5bmV5bem5L6n5aSW6Z2i5oiW6ICF6IqC54K55bem6L6557yY5Zyo5bGP5bmV5Y+z5L6n5aSW6Z2iIOWImeS4jeWcqOaYvuekuuWMuuWfn1xyXG4gICAgICAgIGxldCBob3Jpem9udGFsT3V0c2lkZSA9IG5vZGVTaWRlcy5yaWdodFNpZGUgPCB0aGlzLnZpZXdTaWRlcy5sZWZ0U2lkZVxyXG4gICAgICAgICAgICB8fCBub2RlU2lkZXMubGVmdFNpZGUgPiB0aGlzLnZpZXdTaWRlcy5yaWdodFNpZGU7XHJcblxyXG4gICAgICAgIGxldCB2ZXJ0aWNhbE91dHNpZGUgPSBmYWxzZTtcclxuICAgICAgICBpZiAoIWhvcml6b250YWxPdXRzaWRlKSB7XHJcbiAgICAgICAgICAgIC8v6IqC54K55LiK6L6557yY5Zyo5bGP5bmV5LiL5pa55aSW6Z2i5oiW6ICF6IqC54K55LiL6L6557yY5Zyo5bGP5bmV5LiK5pa55aSW6Z2iIOWImeS4jeWcqOaYvuekuuWMuuWfn1xyXG4gICAgICAgICAgICB2ZXJ0aWNhbE91dHNpZGUgPSBub2RlU2lkZXMudG9wU2lkZSA8IHRoaXMudmlld1NpZGVzLmJvdHRvbVNpZGVcclxuICAgICAgICAgICAgICAgIHx8IG5vZGVTaWRlcy5ib3R0b21TaWRlID4gdGhpcy52aWV3U2lkZXMudG9wU2lkZTtcclxuICAgICAgICB9XHJcbiAgICAgICAgcmV0dXJuICFob3Jpem9udGFsT3V0c2lkZSAmJiAhdmVydGljYWxPdXRzaWRlO1xyXG4gICAgfVxyXG4gICAgLyoqXHJcbiAgICAgKiDlpITnkIblj5jljJbnmoTlpKflsI9cclxuICAgICAqIEBwYXJhbSBjZWxsIFxyXG4gICAgICogQHBhcmFtIG5vZGVTaWRlcyBcclxuICAgICAqIEBwYXJhbSBjaGFuZ2VTaXplIFxyXG4gICAgICovXHJcbiAgICBwdWJsaWMgYXN5bmMgZGVhbENoYW5nZVNpemUoY2VsbDogSXRlbUNlbGw8VD4sIG5vZGVTaWRlczogSUJvcmRlciwgY2hhbmdlU2l6ZTogY2MuU2l6ZSwgdGltZTogbnVtYmVyID0gMC4zKSB7XHJcbiAgICAgICAgbGV0IHRvcFRvQm90dG9tRnVsZmlsbCA9ICh0aGlzLnNjcm9sbFZpZXcuY29udGVudC5hbmNob3JZID09IDEgJiYgbm9kZVNpZGVzLmJvdHRvbVNpZGUgPj0gdGhpcy52aWV3U2lkZXMudG9wU2lkZSk7XHJcbiAgICAgICAgbGV0IGJvdHRvbVRvVG9wRnVsZmlsbCA9ICh0aGlzLnNjcm9sbFZpZXcuY29udGVudC5hbmNob3JZID09IDAgJiYgbm9kZVNpZGVzLnRvcFNpZGUgPD0gdGhpcy52aWV3U2lkZXMuYm90dG9tU2lkZSk7XHJcbiAgICAgICAgaWYgKHRvcFRvQm90dG9tRnVsZmlsbCB8fCBib3R0b21Ub1RvcEZ1bGZpbGwpIHtcclxuICAgICAgICAgICAgaWYgKHRvcFRvQm90dG9tRnVsZmlsbCkge1xyXG4gICAgICAgICAgICAgICAgdGhpcy5zY3JvbGxWaWV3LnNldENvbnRlbnRQb3NpdGlvbihjYy52Mih0aGlzLnNjcm9sbFZpZXcuY29udGVudC54LCB0aGlzLnNjcm9sbFZpZXcuY29udGVudC55ICsgY2hhbmdlU2l6ZS5oZWlnaHQpKVxyXG4gICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgdGhpcy5zY3JvbGxWaWV3LnNldENvbnRlbnRQb3NpdGlvbihjYy52Mih0aGlzLnNjcm9sbFZpZXcuY29udGVudC54LCB0aGlzLnNjcm9sbFZpZXcuY29udGVudC55IC0gY2hhbmdlU2l6ZS5oZWlnaHQpKVxyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfVxyXG4gICAgICAgIGxldCBsZWZ0VG9SaWdodEZ1bGZpbGwgPSAodGhpcy5zY3JvbGxWaWV3LmNvbnRlbnQuYW5jaG9yWCA9PSAwICYmIG5vZGVTaWRlcy5yaWdodFNpZGUgPD0gdGhpcy52aWV3U2lkZXMubGVmdFNpZGUpO1xyXG4gICAgICAgIGxldCBSaWdodFRvTGVmdEZ1bGZpbGwgPSAodGhpcy5zY3JvbGxWaWV3LmNvbnRlbnQuYW5jaG9yWCA9PSAxICYmIG5vZGVTaWRlcy5sZWZ0U2lkZSA+PSB0aGlzLnZpZXdTaWRlcy5yaWdodFNpZGUpO1xyXG4gICAgICAgIGlmIChsZWZ0VG9SaWdodEZ1bGZpbGwgfHwgUmlnaHRUb0xlZnRGdWxmaWxsKSB7XHJcbiAgICAgICAgICAgIGlmIChSaWdodFRvTGVmdEZ1bGZpbGwpIHtcclxuICAgICAgICAgICAgICAgIHRoaXMuc2Nyb2xsVmlldy5zZXRDb250ZW50UG9zaXRpb24oY2MudjIodGhpcy5zY3JvbGxWaWV3LmNvbnRlbnQueCArIGNoYW5nZVNpemUud2lkdGgsIHRoaXMuc2Nyb2xsVmlldy5jb250ZW50LnkpKVxyXG4gICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgdGhpcy5zY3JvbGxWaWV3LnNldENvbnRlbnRQb3NpdGlvbihjYy52Mih0aGlzLnNjcm9sbFZpZXcuY29udGVudC54IC0gY2hhbmdlU2l6ZS53aWR0aCwgdGhpcy5zY3JvbGxWaWV3LmNvbnRlbnQueSkpXHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9XHJcbiAgICAgICAgaWYgKCEodG9wVG9Cb3R0b21GdWxmaWxsIHx8IGJvdHRvbVRvVG9wRnVsZmlsbCB8fCBsZWZ0VG9SaWdodEZ1bGZpbGwgfHwgUmlnaHRUb0xlZnRGdWxmaWxsKSkge1xyXG4gICAgICAgICAgICBjYy5Ud2Vlbi5zdG9wQWxsQnlUYXJnZXQoY2VsbC5ub2RlKTtcclxuICAgICAgICAgICAgYXdhaXQgbmV3IFByb21pc2U8dm9pZD4oKHJlc29sdmUsIHJlamVjdCkgPT4ge1xyXG4gICAgICAgICAgICAgICAgY2MudHdlZW4oY2VsbC5ub2RlKS50byh0aW1lLCB7IHdpZHRoOiBjZWxsLnNpemUud2lkdGgsIGhlaWdodDogY2VsbC5zaXplLmhlaWdodCB9KS5jYWxsKCgpID0+IHtcclxuICAgICAgICAgICAgICAgICAgICByZXNvbHZlKCk7XHJcbiAgICAgICAgICAgICAgICB9KS5zdGFydCgpO1xyXG4gICAgICAgICAgICB9KVxyXG4gICAgICAgIH1cclxuICAgICAgICB0aGlzLnVwZGF0ZU5vZGVzKCk7XHJcbiAgICAgICAgcmV0dXJuIHRydWU7XHJcbiAgICB9XHJcblxyXG4gICAgLyoqXHJcbiAgICAgKiDlm57mlLbmmL7npLroioLngrlcclxuICAgICAqIEBwYXJhbSBub2RlIFxyXG4gICAgICovXHJcbiAgICBwcml2YXRlIHJlY2lyY2xlU2hvd05vZGUobm9kZTogU2hvd05vZGU8VD4pIHtcclxuICAgICAgICBub2RlICYmIHRoaXMuc2hvd05vZGVQb29sLnB1c2gobm9kZSk7XHJcbiAgICB9XHJcblxyXG4gICAgLyoqXHJcbiAgICAgKiDph4rmlL7lvZPliY3liJfooahcclxuICAgICAqL1xyXG4gICAgcHVibGljIGZyZWVMaXN0KCkge1xyXG4gICAgICAgIHRoaXMuc2Nyb2xsVmlldy5ub2RlLm9mZihcInNjcm9sbGluZ1wiLCB0aGlzLnNjcm9sbGluZ0xpc3RlbmVyKTtcclxuICAgICAgICBmb3IgKGxldCBpID0gMCwgbGVuID0gdGhpcy5pdGVtQ2VsbHMubGVuZ3RoOyBpIDwgbGVuOyArK2kpIHtcclxuICAgICAgICAgICAgdGhpcy5yZWNpcmNsZVNob3dOb2RlKHRoaXMuaXRlbUNlbGxzW2ldLnJlY2lyY2xlKCkpO1xyXG4gICAgICAgICAgICB0aGlzLml0ZW1DZWxsc1tpXS5kZXN0cm95KCk7XHJcbiAgICAgICAgfVxyXG4gICAgICAgIHRoaXMuaXRlbUNlbGxzID0gW107XHJcbiAgICAgICAgZm9yIChsZXQgaW5kZXggPSAwLCBsZW4gPSB0aGlzLnNob3dOb2RlUG9vbC5sZW5ndGg7IGluZGV4IDwgbGVuOyArK2luZGV4KSB7XHJcbiAgICAgICAgICAgIHRoaXMuc2hvd05vZGVQb29sW2luZGV4XS5kZXN0cm95KCk7XHJcbiAgICAgICAgfVxyXG4gICAgICAgIHRoaXMuc2hvd05vZGVQb29sID0gW107XHJcbiAgICAgICAgdGhpcy5yZW5kZXJMYXllciA9IG51bGw7XHJcbiAgICAgICAgdGhpcy5zY3JvbGxWaWV3ID0gbnVsbDtcclxuICAgICAgICB0aGlzLnByZWZhYiA9IG51bGw7XHJcbiAgICB9XHJcblxyXG59XHJcbi8qKlxyXG4gKiDojrflj5boioLngrnnmoTovrnnvJhcclxuICogQHBhcmFtIG5vZGUgXHJcbiAqIEBwYXJhbSBuZWVkQXJyIOmhuuW6j+aYr+S4iiDkuIsg5bemIOWPs1xyXG4gKi9cclxuZnVuY3Rpb24gZ2V0Tm9kZUJvcmRlcihjZWxsOiBJdGVtQ2VsbDxhbnk+LCBuZWVkQXJyOiBib29sZWFuW10pIHtcclxuICAgIGxldCBub2RlID0gY2VsbC5ub2RlXHJcbiAgICBsZXQgYm9kZXJEYXRhOiBJQm9yZGVyID0ge307XHJcbiAgICBsZXQgd3BvcyA9IGdldE5vZGVXUG9zKG5vZGUpO1xyXG4gICAgLy/mmL7npLrljLrln5/kuIrovrnnvJhcclxuICAgIGlmIChuZWVkQXJyWzBdKSB7XHJcbiAgICAgICAgYm9kZXJEYXRhLnRvcFNpZGUgPSB3cG9zLnkgKyAobm9kZS5oZWlnaHQgKiAoMSAtIG5vZGUuYW5jaG9yWSkpO1xyXG4gICAgfVxyXG4gICAgLy/mmL7npLrljLrln5/kuIvovrnnvJhcclxuICAgIGlmIChuZWVkQXJyWzFdKSB7XHJcbiAgICAgICAgYm9kZXJEYXRhLmJvdHRvbVNpZGUgPSB3cG9zLnkgLSAobm9kZS5oZWlnaHQgKiBub2RlLmFuY2hvclkpO1xyXG4gICAgfVxyXG4gICAgLy/mmL7npLrljLrln5/lt6bovrnnvJhcclxuICAgIGlmIChuZWVkQXJyWzJdKSB7XHJcbiAgICAgICAgYm9kZXJEYXRhLmxlZnRTaWRlID0gd3Bvcy54IC0gKG5vZGUud2lkdGggKiBub2RlLmFuY2hvclgpO1xyXG4gICAgfVxyXG4gICAgLy/mmL7npLrljLrln5/lj7PovrnnvJhcclxuICAgIGlmIChuZWVkQXJyWzNdKSB7XHJcbiAgICAgICAgYm9kZXJEYXRhLnJpZ2h0U2lkZSA9IHdwb3MueCArIChub2RlLndpZHRoICogKDEgLSBub2RlLmFuY2hvclgpKTtcclxuICAgIH1cclxuICAgIGJvZGVyRGF0YS5zaXplID0gY2Muc2l6ZShub2RlLndpZHRoLCBub2RlLmhlaWdodCk7XHJcbiAgICByZXR1cm4gYm9kZXJEYXRhO1xyXG59XHJcblxyXG4vKipcclxuICog6I635Y+W6IqC54K55LiW55WM5Z2Q5qCHXHJcbiAqIEBwYXJhbSBub2RlIFxyXG4gKiBAcmV0dXJucyBcclxuICovXHJcbmZ1bmN0aW9uIGdldE5vZGVXUG9zKG5vZGU6IGNjLk5vZGUpIHtcclxuICAgIHJldHVybiBub2RlLnBhcmVudC5jb252ZXJ0VG9Xb3JsZFNwYWNlQVIobm9kZS5wb3NpdGlvbik7XHJcbn1cclxuXHJcblxyXG4iXX0= \ No newline at end of file diff --git a/Layered_virtual_list_2.x/temp/quick-scripts/dst/assets/Script/RenderAlternative.js b/Layered_virtual_list_2.x/temp/quick-scripts/dst/assets/Script/RenderAlternative.js new file mode 100644 index 0000000..9ca8ef8 --- /dev/null +++ b/Layered_virtual_list_2.x/temp/quick-scripts/dst/assets/Script/RenderAlternative.js @@ -0,0 +1,286 @@ + + (function() { + var nodeEnv = typeof require !== 'undefined' && typeof process !== 'undefined'; + var __module = nodeEnv ? module : {exports:{}}; + var __filename = 'preview-scripts/assets/Script/RenderAlternative.js'; + var __require = nodeEnv ? function (request) { + return cc.require(request); + } : function (request) { + return __quick_compile_project__.require(request, __filename); + }; + function __define (exports, require, module) { + if (!nodeEnv) {__quick_compile_project__.registerModule(__filename, module);}"use strict"; +cc._RF.push(module, 'f9782xj4QNK842OAHoabRFb', 'RenderAlternative'); +// Script/RenderAlternative.ts + +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var RenderReactiveHandler_1 = require("./RenderReactiveHandler"); +/** + * 目前该渲染代理功能存在的问题 + * 1.被代理节点的父级不能出现scaleX和scaleY不一致的情况,被代理节点本身没有这个限制 + */ +var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property; +var RenderAlternative = /** @class */ (function (_super) { + __extends(RenderAlternative, _super); + function RenderAlternative() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /**渲染层节点 */ + _this.renderLayer = null; + /**渲染的zIndex 动态调整zIndex,用于方便临近合批 */ + _this.renderZIndex = 0; + /**同步的间隔(帧为单位) */ + _this.syncInv = 0.01; + /**渲染的sIndex */ + _this.sIndex = 0; + /**非渲染组件 */ + _this.proxyRender = null; + /**渲染组件 */ + _this.renderCompnent = null; + /**上次更新的数据 */ + _this.lastWMat4 = null; + /**上次更新的数据 */ + _this.lastLMat4 = null; + /**上次更新的数据 */ + _this.lastPos = null; + /**距离下次刷新累计了多少间隔 */ + _this.accuTime = 0; + /**最后一次刷新时间 */ + _this.lastFrameTime = null; + /**是否进行刷新 */ + _this.isAttachFrame = false; + return _this; + } + RenderAlternative_1 = RenderAlternative; + Object.defineProperty(RenderAlternative.prototype, "zIndex", { + /**获取总的ZIndex */ + get: function () { + var zIndex = this.renderZIndex + (this.sIndex * 0.01); + var parentNode = this.node.parent; + while (parentNode != this.renderLayer.parent && parentNode != cc.director.getScene()) { + var render = parentNode.getComponent(RenderAlternative_1); + if (render) { + zIndex += render.zIndex + 1; + break; + } + parentNode = parentNode.parent; + } + return zIndex; + }, + enumerable: false, + configurable: true + }); + /** + * 设置渲染节点层 + * @param layer + */ + RenderAlternative.prototype.init = function (layer) { + if (layer) { + this.renderLayer = layer; + } + if (!this.renderLayer) { + console.warn("\u8282\u70B9" + this.node.name + "\u6CA1\u6709\u8BBE\u7F6E\u6E32\u67D3\u5C42"); + return null; + } + return this.initRender(); + }; + /** + * 初始化渲染节点 + */ + RenderAlternative.prototype.initRender = function () { + var node = this.getRender(); + node.setParent(this.renderLayer ? this.renderLayer : cc.director.getScene().getChildByName("Canvas")); + this.isAttachFrame = true; + requestAnimationFrame(this.frameUpdate.bind(this)); + return this.doProxy(); + }; + /**生成代理 */ + RenderAlternative.prototype.doProxy = function () { + this.proxyRender = new Proxy(this.renderCompnent, new RenderReactiveHandler_1.RenderReactiveHandler()); + return this.proxyRender; + }; + RenderAlternative.prototype.frameUpdate = function () { + var now = cc.sys.now(); + !this.lastFrameTime && (this.lastFrameTime = now); + var dt = now - this.lastFrameTime; + if (this.proxyRender) { + this.accuTime += dt; + if (this.accuTime >= this.syncInv) { + this.accuTime -= this.syncInv; + this.updateProp(); + } + } + if (this.isAttachFrame) { + requestAnimationFrame(this.frameUpdate.bind(this)); + } + }; + /**更新最新状态 */ + RenderAlternative.prototype.updateProp = function () { + var node = this.renderCompnent.node; + if (!this.node.activeInHierarchy) { + node.opacity = 0; + return; + } + node.anchorX = this.node.anchorX; + node.anchorY = this.node.anchorY; + node.width = this.node.width; + node.height = this.node.height; + node.group = this.node.group; + node.color = this.node.color; + node.opacity = this.getOpacity(this.node); + var wMat4 = cc.mat4(); + this.node.getWorldMatrix(wMat4); + if (!this.lastWMat4 || !this.lastWMat4.equals(wMat4)) { + var localMatrix = this.getLocalMatrix(wMat4, node); + this.setLocalXYZScaleAngle(localMatrix, node, this.lastLMat4); + this.lastWMat4 = wMat4; + this.lastLMat4 = localMatrix; + } + node.zIndex = this.zIndex; + }; + RenderAlternative.prototype.getLocalMatrix = function (worldMatrix, node) { + var parentNode = null; + if (cc.isValid(node)) { + if (cc.isValid(node.parent)) { + parentNode = node.parent; + } + } + // 获取父节点的世界矩阵 + var parentWorldMatrix = cc.mat4(); + parentNode.getWorldMatrix(parentWorldMatrix); + // 获取父节点的逆矩阵 + var parentInverseMatrix = parentWorldMatrix.invert(); + // 将目标节点的世界矩阵转换为父节点的本地矩阵 + var localMatrix = parentInverseMatrix.multiply(worldMatrix); + return localMatrix; + }; + RenderAlternative.prototype.setLocalXYZScaleAngle = function (matrix, node, lastMatrix) { + if (lastMatrix && matrix.equals(lastMatrix)) { + return; + } + // 提取位置 + node.setPosition(matrix.m[12], matrix.m[13], matrix.m[14]); + var scaleX = null; + var scaleY = null; + var angle = null; + // 提取缩放X + if (!lastMatrix) { + scaleX = Math.sqrt(matrix.m[0] * matrix.m[0] + matrix.m[1] * matrix.m[1] + matrix.m[2] * matrix.m[2]); + } + else if (!this.equalsValue(matrix.m[0], lastMatrix.m[0]) + || !this.equalsValue(matrix.m[1], lastMatrix.m[1]) + || !this.equalsValue(matrix.m[2], lastMatrix.m[2])) { + scaleX = Math.sqrt(matrix.m[0] * matrix.m[0] + matrix.m[1] * matrix.m[1] + matrix.m[2] * matrix.m[2]); + } + // 提取缩放Y + if (!lastMatrix) { + scaleY = Math.sqrt(matrix.m[4] * matrix.m[4] + matrix.m[5] * matrix.m[5] + matrix.m[6] * matrix.m[6]); + } + else if (!this.equalsValue(matrix.m[4], lastMatrix.m[4]) + || !this.equalsValue(matrix.m[5], lastMatrix.m[5]) + || !this.equalsValue(matrix.m[6], lastMatrix.m[6])) { + scaleY = Math.sqrt(matrix.m[4] * matrix.m[4] + matrix.m[5] * matrix.m[5] + matrix.m[6] * matrix.m[6]); + } + //设置缩放X + if (scaleX !== null) { + node.scaleX = scaleX; + // 提取旋转 + angle = Math.atan2(matrix.m[1] / scaleX, matrix.m[0] / scaleX) * (180 / Math.PI); + } + if (scaleY !== null) { + node.scaleY = scaleY; + } + if (angle !== null) { + node.rotation = angle; + } + }; + RenderAlternative.prototype.equalsValue = function (a, b, epsilon) { + if (epsilon === void 0) { epsilon = 0.00001; } + return Math.abs(a - b) < epsilon; + }; + RenderAlternative.prototype.onDestroy = function () { + this.renderCompnent.node.destroy(); + this.renderCompnent = null; + this.proxyRender = null; + }; + /** + * 获取节点透明度 + * @param node + */ + RenderAlternative.prototype.getOpacity = function (node) { + var opacity = (node.opacity / 255); + var parentNode = node.parent; + while (parentNode != this.renderLayer.parent && parentNode != cc.director.getScene()) { + opacity *= (parentNode.opacity / 255); + parentNode = parentNode.parent; + } + return opacity * 255; + }; + /** + * 获取渲染组件 + * @param node + */ + RenderAlternative.prototype.getRender = function () { + var _a, _b; + var node = cc.instantiate(this.node); + node.removeAllChildren(); + this.renderCompnent = node.getComponent(cc.RenderComponent); + (_a = this.node.getComponent(cc.LabelOutline)) === null || _a === void 0 ? void 0 : _a.destroy(); + (_b = this.node.getComponent(cc.LabelShadow)) === null || _b === void 0 ? void 0 : _b.destroy(); + this.node.getComponent(cc.RenderComponent).destroy(); + var components = node.getComponents(cc.Component); + for (var i = 0, len = components.length; i < len; ++i) { + var comp = components[i]; + if (!((comp instanceof cc.RenderComponent) || (comp instanceof cc.LabelOutline) || (comp instanceof cc.LabelShadow))) { + comp.destroy(); + } + } + return node; + }; + var RenderAlternative_1; + __decorate([ + property + ], RenderAlternative.prototype, "renderZIndex", void 0); + __decorate([ + property({ + tooltip: '设置同步的间隔(秒为单位),0就是每帧都同步,0.1就是隔0.1秒同步一次' + }) + ], RenderAlternative.prototype, "syncInv", void 0); + RenderAlternative = RenderAlternative_1 = __decorate([ + ccclass + ], RenderAlternative); + return RenderAlternative; +}(cc.Component)); +exports.default = RenderAlternative; + +cc._RF.pop(); + } + if (nodeEnv) { + __define(__module.exports, __require, __module); + } + else { + __quick_compile_project__.registerModuleFunc(__filename, function () { + __define(__module.exports, __require, __module); + }); + } + })(); +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImFzc2V0c1xcU2NyaXB0XFxSZW5kZXJBbHRlcm5hdGl2ZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7QUFBQSxpRUFBZ0U7QUFFaEU7OztHQUdHO0FBQ0csSUFBQSxLQUF3QixFQUFFLENBQUMsVUFBVSxFQUFuQyxPQUFPLGFBQUEsRUFBRSxRQUFRLGNBQWtCLENBQUM7QUFFNUM7SUFBK0MscUNBQVk7SUFBM0Q7UUFBQSxxRUE2TkM7UUE1TkcsV0FBVztRQUNKLGlCQUFXLEdBQVksSUFBSSxDQUFDO1FBQ25DLG1DQUFtQztRQUU1QixrQkFBWSxHQUFXLENBQUMsQ0FBQztRQUNoQyxpQkFBaUI7UUFJVixhQUFPLEdBQVcsSUFBSSxDQUFDO1FBQzlCLGVBQWU7UUFDUixZQUFNLEdBQVcsQ0FBQyxDQUFDO1FBQzFCLFdBQVc7UUFDSixpQkFBVyxHQUF1QixJQUFJLENBQUM7UUFDOUMsVUFBVTtRQUNGLG9CQUFjLEdBQXVCLElBQUksQ0FBQztRQUNsRCxhQUFhO1FBQ04sZUFBUyxHQUFZLElBQUksQ0FBQztRQUNqQyxhQUFhO1FBQ04sZUFBUyxHQUFZLElBQUksQ0FBQztRQUNqQyxhQUFhO1FBQ04sYUFBTyxHQUFZLElBQUksQ0FBQztRQUMvQixtQkFBbUI7UUFDWixjQUFRLEdBQVcsQ0FBQyxDQUFDO1FBQzVCLGNBQWM7UUFDUCxtQkFBYSxHQUFXLElBQUksQ0FBQztRQUNwQyxZQUFZO1FBQ0wsbUJBQWEsR0FBWSxLQUFLLENBQUM7O0lBaU0xQyxDQUFDOzBCQTdOb0IsaUJBQWlCO0lBK0JsQyxzQkFBSSxxQ0FBTTtRQURWLGdCQUFnQjthQUNoQjtZQUNJLElBQUksTUFBTSxHQUFHLElBQUksQ0FBQyxZQUFZLEdBQUcsQ0FBQyxJQUFJLENBQUMsTUFBTSxHQUFHLElBQUksQ0FBQyxDQUFDO1lBQ3RELElBQUksVUFBVSxHQUFHLElBQUksQ0FBQyxJQUFJLENBQUMsTUFBTSxDQUFDO1lBQ2xDLE9BQU8sVUFBVSxJQUFJLElBQUksQ0FBQyxXQUFXLENBQUMsTUFBTSxJQUFJLFVBQVUsSUFBSSxFQUFFLENBQUMsUUFBUSxDQUFDLFFBQVEsRUFBRSxFQUFFO2dCQUNsRixJQUFJLE1BQU0sR0FBRyxVQUFVLENBQUMsWUFBWSxDQUFDLG1CQUFpQixDQUFDLENBQUM7Z0JBQ3hELElBQUksTUFBTSxFQUFFO29CQUNSLE1BQU0sSUFBSSxNQUFNLENBQUMsTUFBTSxHQUFHLENBQUMsQ0FBQztvQkFDNUIsTUFBTTtpQkFDVDtnQkFDRCxVQUFVLEdBQUcsVUFBVSxDQUFDLE1BQU0sQ0FBQzthQUNsQztZQUNELE9BQU8sTUFBTSxDQUFDO1FBQ2xCLENBQUM7OztPQUFBO0lBRUQ7OztPQUdHO0lBQ0gsZ0NBQUksR0FBSixVQUFtQyxLQUFlO1FBQzlDLElBQUksS0FBSyxFQUFFO1lBQ1AsSUFBSSxDQUFDLFdBQVcsR0FBRyxLQUFLLENBQUM7U0FDNUI7UUFDRCxJQUFJLENBQUMsSUFBSSxDQUFDLFdBQVcsRUFBRTtZQUNuQixPQUFPLENBQUMsSUFBSSxDQUFDLGlCQUFLLElBQUksQ0FBQyxJQUFJLENBQUMsSUFBSSwrQ0FBUyxDQUFDLENBQUE7WUFDMUMsT0FBTyxJQUFJLENBQUM7U0FDZjtRQUNELE9BQU8sSUFBSSxDQUFDLFVBQVUsRUFBSyxDQUFDO0lBQ2hDLENBQUM7SUFDRDs7T0FFRztJQUNLLHNDQUFVLEdBQWxCO1FBQ0ksSUFBSSxJQUFJLEdBQUcsSUFBSSxDQUFDLFNBQVMsRUFBRSxDQUFDO1FBQzVCLElBQUksQ0FBQyxTQUFTLENBQUMsSUFBSSxDQUFDLFdBQVcsQ0FBQyxDQUFDLENBQUMsSUFBSSxDQUFDLFdBQVcsQ0FBQyxDQUFDLENBQUMsRUFBRSxDQUFDLFFBQVEsQ0FBQyxRQUFRLEVBQUUsQ0FBQyxjQUFjLENBQUMsUUFBUSxDQUFDLENBQUMsQ0FBQztRQUN0RyxJQUFJLENBQUMsYUFBYSxHQUFHLElBQUksQ0FBQztRQUMxQixxQkFBcUIsQ0FBQyxJQUFJLENBQUMsV0FBVyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsQ0FBQyxDQUFDO1FBQ25ELE9BQU8sSUFBSSxDQUFDLE9BQU8sRUFBSyxDQUFDO0lBQzdCLENBQUM7SUFDRCxVQUFVO0lBQ0YsbUNBQU8sR0FBZjtRQUNJLElBQUksQ0FBQyxXQUFXLEdBQUcsSUFBSSxLQUFLLENBQUMsSUFBSSxDQUFDLGNBQWMsRUFBRSxJQUFJLDZDQUFxQixFQUFFLENBQU0sQ0FBQztRQUNwRixPQUFPLElBQUksQ0FBQyxXQUFnQixDQUFDO0lBQ2pDLENBQUM7SUFHUyx1Q0FBVyxHQUFyQjtRQUNJLElBQUksR0FBRyxHQUFHLEVBQUUsQ0FBQyxHQUFHLENBQUMsR0FBRyxFQUFFLENBQUM7UUFDdkIsQ0FBQyxJQUFJLENBQUMsYUFBYSxJQUFJLENBQUMsSUFBSSxDQUFDLGFBQWEsR0FBRyxHQUFHLENBQUMsQ0FBQztRQUNsRCxJQUFJLEVBQUUsR0FBRyxHQUFHLEdBQUcsSUFBSSxDQUFDLGFBQWEsQ0FBQztRQUNsQyxJQUFJLElBQUksQ0FBQyxXQUFXLEVBQUU7WUFDbEIsSUFBSSxDQUFDLFFBQVEsSUFBSSxFQUFFLENBQUM7WUFDcEIsSUFBSSxJQUFJLENBQUMsUUFBUSxJQUFJLElBQUksQ0FBQyxPQUFPLEVBQUU7Z0JBQy9CLElBQUksQ0FBQyxRQUFRLElBQUksSUFBSSxDQUFDLE9BQU8sQ0FBQztnQkFDOUIsSUFBSSxDQUFDLFVBQVUsRUFBRSxDQUFDO2FBQ3JCO1NBQ0o7UUFDRCxJQUFJLElBQUksQ0FBQyxhQUFhLEVBQUU7WUFDcEIscUJBQXFCLENBQUMsSUFBSSxDQUFDLFdBQVcsQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLENBQUMsQ0FBQztTQUN0RDtJQUNMLENBQUM7SUFFRCxZQUFZO0lBQ0wsc0NBQVUsR0FBakI7UUFDSSxJQUFJLElBQUksR0FBRyxJQUFJLENBQUMsY0FBYyxDQUFDLElBQUksQ0FBQztRQUNwQyxJQUFJLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxpQkFBaUIsRUFBRTtZQUM5QixJQUFJLENBQUMsT0FBTyxHQUFHLENBQUMsQ0FBQztZQUNqQixPQUFPO1NBQ1Y7UUFDRCxJQUFJLENBQUMsT0FBTyxHQUFHLElBQUksQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDO1FBQ2pDLElBQUksQ0FBQyxPQUFPLEdBQUcsSUFBSSxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUM7UUFDakMsSUFBSSxDQUFDLEtBQUssR0FBRyxJQUFJLENBQUMsSUFBSSxDQUFDLEtBQUssQ0FBQztRQUM3QixJQUFJLENBQUMsTUFBTSxHQUFHLElBQUksQ0FBQyxJQUFJLENBQUMsTUFBTSxDQUFDO1FBQy9CLElBQUksQ0FBQyxLQUFLLEdBQUcsSUFBSSxDQUFDLElBQUksQ0FBQyxLQUFLLENBQUM7UUFDN0IsSUFBSSxDQUFDLEtBQUssR0FBRyxJQUFJLENBQUMsSUFBSSxDQUFDLEtBQUssQ0FBQztRQUM3QixJQUFJLENBQUMsT0FBTyxHQUFHLElBQUksQ0FBQyxVQUFVLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxDQUFDO1FBRTFDLElBQUksS0FBSyxHQUFHLEVBQUUsQ0FBQyxJQUFJLEVBQUUsQ0FBQztRQUN0QixJQUFJLENBQUMsSUFBSSxDQUFDLGNBQWMsQ0FBQyxLQUFLLENBQUMsQ0FBQztRQUNoQyxJQUFJLENBQUMsSUFBSSxDQUFDLFNBQVMsSUFBSSxDQUFDLElBQUksQ0FBQyxTQUFTLENBQUMsTUFBTSxDQUFDLEtBQUssQ0FBQyxFQUFFO1lBQ2xELElBQUksV0FBVyxHQUFHLElBQUksQ0FBQyxjQUFjLENBQUMsS0FBSyxFQUFFLElBQUksQ0FBQyxDQUFDO1lBQ25ELElBQUksQ0FBQyxxQkFBcUIsQ0FBQyxXQUFXLEVBQUUsSUFBSSxFQUFFLElBQUksQ0FBQyxTQUFTLENBQUMsQ0FBQztZQUM5RCxJQUFJLENBQUMsU0FBUyxHQUFHLEtBQUssQ0FBQztZQUN2QixJQUFJLENBQUMsU0FBUyxHQUFHLFdBQVcsQ0FBQztTQUNoQztRQUNELElBQUksQ0FBQyxNQUFNLEdBQUcsSUFBSSxDQUFDLE1BQU0sQ0FBQztJQUM5QixDQUFDO0lBRU8sMENBQWMsR0FBdEIsVUFBdUIsV0FBb0IsRUFBRSxJQUFhO1FBQ3RELElBQUksVUFBVSxHQUFHLElBQUksQ0FBQztRQUN0QixJQUFJLEVBQUUsQ0FBQyxPQUFPLENBQUMsSUFBSSxDQUFDLEVBQUU7WUFDbEIsSUFBSSxFQUFFLENBQUMsT0FBTyxDQUFDLElBQUksQ0FBQyxNQUFNLENBQUMsRUFBRTtnQkFDekIsVUFBVSxHQUFHLElBQUksQ0FBQyxNQUFNLENBQUE7YUFDM0I7U0FDSjtRQUNELGFBQWE7UUFDYixJQUFJLGlCQUFpQixHQUFHLEVBQUUsQ0FBQyxJQUFJLEVBQUUsQ0FBQztRQUNsQyxVQUFVLENBQUMsY0FBYyxDQUFDLGlCQUFpQixDQUFDLENBQUM7UUFDN0MsWUFBWTtRQUNaLElBQUksbUJBQW1CLEdBQUcsaUJBQWlCLENBQUMsTUFBTSxFQUFFLENBQUM7UUFDckQsd0JBQXdCO1FBQ3hCLElBQUksV0FBVyxHQUFHLG1CQUFtQixDQUFDLFFBQVEsQ0FBQyxXQUFXLENBQUMsQ0FBQztRQUM1RCxPQUFPLFdBQVcsQ0FBQztJQUV2QixDQUFDO0lBRU8saURBQXFCLEdBQTdCLFVBQThCLE1BQWUsRUFBRSxJQUFhLEVBQUUsVUFBb0I7UUFDOUUsSUFBSSxVQUFVLElBQUksTUFBTSxDQUFDLE1BQU0sQ0FBQyxVQUFVLENBQUMsRUFBRTtZQUN6QyxPQUFPO1NBQ1Y7UUFFRCxPQUFPO1FBQ1AsSUFBSSxDQUFDLFdBQVcsQ0FBQyxNQUFNLENBQUMsQ0FBQyxDQUFDLEVBQUUsQ0FBQyxFQUFFLE1BQU0sQ0FBQyxDQUFDLENBQUMsRUFBRSxDQUFDLEVBQUUsTUFBTSxDQUFDLENBQUMsQ0FBQyxFQUFFLENBQUMsQ0FBQyxDQUFDO1FBRTNELElBQUksTUFBTSxHQUFHLElBQUksQ0FBQztRQUNsQixJQUFJLE1BQU0sR0FBRyxJQUFJLENBQUM7UUFDbEIsSUFBSSxLQUFLLEdBQUcsSUFBSSxDQUFDO1FBQ2pCLFFBQVE7UUFDUixJQUFJLENBQUMsVUFBVSxFQUFFO1lBQ2IsTUFBTSxHQUFHLElBQUksQ0FBQyxJQUFJLENBQUMsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQztTQUN6RzthQUFNLElBQUksQ0FBQyxJQUFJLENBQUMsV0FBVyxDQUFDLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEVBQUUsVUFBVSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQztlQUNuRCxDQUFDLElBQUksQ0FBQyxXQUFXLENBQUMsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsRUFBRSxVQUFVLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDO2VBQy9DLENBQUMsSUFBSSxDQUFDLFdBQVcsQ0FBQyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxFQUFFLFVBQVUsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsRUFBRTtZQUNwRCxNQUFNLEdBQUcsSUFBSSxDQUFDLElBQUksQ0FBQyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDO1NBQ3pHO1FBQ0QsUUFBUTtRQUNSLElBQUksQ0FBQyxVQUFVLEVBQUU7WUFDYixNQUFNLEdBQUcsSUFBSSxDQUFDLElBQUksQ0FBQyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDO1NBQ3pHO2FBQU0sSUFBSSxDQUFDLElBQUksQ0FBQyxXQUFXLENBQUMsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsRUFBRSxVQUFVLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDO2VBQ25ELENBQUMsSUFBSSxDQUFDLFdBQVcsQ0FBQyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxFQUFFLFVBQVUsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUM7ZUFDL0MsQ0FBQyxJQUFJLENBQUMsV0FBVyxDQUFDLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEVBQUUsVUFBVSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxFQUFFO1lBQ3BELE1BQU0sR0FBRyxJQUFJLENBQUMsSUFBSSxDQUFDLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUM7U0FDekc7UUFDRCxPQUFPO1FBQ1AsSUFBSSxNQUFNLEtBQUssSUFBSSxFQUFFO1lBQ2pCLElBQUksQ0FBQyxNQUFNLEdBQUcsTUFBTSxDQUFDO1lBQ3JCLE9BQU87WUFDUCxLQUFLLEdBQUcsSUFBSSxDQUFDLEtBQUssQ0FBQyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLE1BQU0sRUFBRSxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLE1BQU0sQ0FBQyxHQUFHLENBQUMsR0FBRyxHQUFHLElBQUksQ0FBQyxFQUFFLENBQUMsQ0FBQztTQUNwRjtRQUNELElBQUksTUFBTSxLQUFLLElBQUksRUFBRTtZQUNqQixJQUFJLENBQUMsTUFBTSxHQUFHLE1BQU0sQ0FBQztTQUN4QjtRQUNELElBQUksS0FBSyxLQUFLLElBQUksRUFBRTtZQUNoQixJQUFJLENBQUMsUUFBUSxHQUFHLEtBQUssQ0FBQztTQUN6QjtJQUNMLENBQUM7SUFFTyx1Q0FBVyxHQUFuQixVQUFvQixDQUFTLEVBQUUsQ0FBUyxFQUFFLE9BQXlCO1FBQXpCLHdCQUFBLEVBQUEsaUJBQXlCO1FBQy9ELE9BQU8sSUFBSSxDQUFDLEdBQUcsQ0FBQyxDQUFDLEdBQUcsQ0FBQyxDQUFDLEdBQUcsT0FBTyxDQUFDO0lBQ3JDLENBQUM7SUFFUyxxQ0FBUyxHQUFuQjtRQUNJLElBQUksQ0FBQyxjQUFjLENBQUMsSUFBSSxDQUFDLE9BQU8sRUFBRSxDQUFDO1FBQ25DLElBQUksQ0FBQyxjQUFjLEdBQUcsSUFBSSxDQUFDO1FBQzNCLElBQUksQ0FBQyxXQUFXLEdBQUcsSUFBSSxDQUFDO0lBQzVCLENBQUM7SUFFRDs7O09BR0c7SUFDSyxzQ0FBVSxHQUFsQixVQUFtQixJQUFhO1FBQzVCLElBQUksT0FBTyxHQUFHLENBQUMsSUFBSSxDQUFDLE9BQU8sR0FBRyxHQUFHLENBQUMsQ0FBQztRQUNuQyxJQUFJLFVBQVUsR0FBRyxJQUFJLENBQUMsTUFBTSxDQUFBO1FBQzVCLE9BQU8sVUFBVSxJQUFJLElBQUksQ0FBQyxXQUFXLENBQUMsTUFBTSxJQUFJLFVBQVUsSUFBSSxFQUFFLENBQUMsUUFBUSxDQUFDLFFBQVEsRUFBRSxFQUFFO1lBQ2xGLE9BQU8sSUFBSSxDQUFDLFVBQVUsQ0FBQyxPQUFPLEdBQUcsR0FBRyxDQUFDLENBQUM7WUFDdEMsVUFBVSxHQUFHLFVBQVUsQ0FBQyxNQUFNLENBQUM7U0FDbEM7UUFDRCxPQUFPLE9BQU8sR0FBRyxHQUFHLENBQUM7SUFDekIsQ0FBQztJQUNEOzs7T0FHRztJQUNLLHFDQUFTLEdBQWpCOztRQUNJLElBQUksSUFBSSxHQUFHLEVBQUUsQ0FBQyxXQUFXLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxDQUFDO1FBQ3JDLElBQUksQ0FBQyxpQkFBaUIsRUFBRSxDQUFDO1FBQ3pCLElBQUksQ0FBQyxjQUFjLEdBQUcsSUFBSSxDQUFDLFlBQVksQ0FBQyxFQUFFLENBQUMsZUFBZSxDQUFDLENBQUM7UUFDNUQsTUFBQSxJQUFJLENBQUMsSUFBSSxDQUFDLFlBQVksQ0FBQyxFQUFFLENBQUMsWUFBWSxDQUFDLDBDQUFFLE9BQU8sR0FBRztRQUNuRCxNQUFBLElBQUksQ0FBQyxJQUFJLENBQUMsWUFBWSxDQUFDLEVBQUUsQ0FBQyxXQUFXLENBQUMsMENBQUUsT0FBTyxHQUFHO1FBQ2xELElBQUksQ0FBQyxJQUFJLENBQUMsWUFBWSxDQUFDLEVBQUUsQ0FBQyxlQUFlLENBQUMsQ0FBQyxPQUFPLEVBQUUsQ0FBQztRQUNyRCxJQUFJLFVBQVUsR0FBRyxJQUFJLENBQUMsYUFBYSxDQUFDLEVBQUUsQ0FBQyxTQUFTLENBQUMsQ0FBQztRQUNsRCxLQUFLLElBQUksQ0FBQyxHQUFHLENBQUMsRUFBRSxHQUFHLEdBQUcsVUFBVSxDQUFDLE1BQU0sRUFBRSxDQUFDLEdBQUcsR0FBRyxFQUFFLEVBQUUsQ0FBQyxFQUFFO1lBQ25ELElBQUksSUFBSSxHQUFHLFVBQVUsQ0FBQyxDQUFDLENBQUMsQ0FBQztZQUN6QixJQUFJLENBQUMsQ0FBQyxDQUFDLElBQUksWUFBWSxFQUFFLENBQUMsZUFBZSxDQUFDLElBQUksQ0FBQyxJQUFJLFlBQVksRUFBRSxDQUFDLFlBQVksQ0FBQyxJQUFJLENBQUMsSUFBSSxZQUFZLEVBQUUsQ0FBQyxXQUFXLENBQUMsQ0FBQyxFQUFFO2dCQUNsSCxJQUFJLENBQUMsT0FBTyxFQUFFLENBQUM7YUFDbEI7U0FDSjtRQUNELE9BQU8sSUFBSSxDQUFDO0lBQ2hCLENBQUM7O0lBdE5EO1FBREMsUUFBUTsyREFDdUI7SUFLaEM7UUFIQyxRQUFRLENBQUM7WUFDTixPQUFPLEVBQUUsdUNBQXVDO1NBQ25ELENBQUM7c0RBQzRCO0lBVmIsaUJBQWlCO1FBRHJDLE9BQU87T0FDYSxpQkFBaUIsQ0E2TnJDO0lBQUQsd0JBQUM7Q0E3TkQsQUE2TkMsQ0E3TjhDLEVBQUUsQ0FBQyxTQUFTLEdBNk4xRDtrQkE3Tm9CLGlCQUFpQiIsImZpbGUiOiIiLCJzb3VyY2VSb290IjoiLyIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7IFJlbmRlclJlYWN0aXZlSGFuZGxlciB9IGZyb20gXCIuL1JlbmRlclJlYWN0aXZlSGFuZGxlclwiO1xyXG5cclxuLyoqXHJcbiAqIOebruWJjeivpea4suafk+S7o+eQhuWKn+iDveWtmOWcqOeahOmXrumimFxyXG4gKiAxLuiiq+S7o+eQhuiKgueCueeahOeItue6p+S4jeiDveWHuueOsHNjYWxlWOWSjHNjYWxlWeS4jeS4gOiHtOeahOaDheWGte+8jOiiq+S7o+eQhuiKgueCueacrOi6q+ayoeaciei/meS4qumZkOWItlxyXG4gKi9cclxuY29uc3QgeyBjY2NsYXNzLCBwcm9wZXJ0eSB9ID0gY2MuX2RlY29yYXRvcjtcclxuQGNjY2xhc3NcclxuZXhwb3J0IGRlZmF1bHQgY2xhc3MgUmVuZGVyQWx0ZXJuYXRpdmUgZXh0ZW5kcyBjYy5Db21wb25lbnQge1xyXG4gICAgLyoq5riy5p+T5bGC6IqC54K5ICovXHJcbiAgICBwdWJsaWMgcmVuZGVyTGF5ZXI6IGNjLk5vZGUgPSBudWxsO1xyXG4gICAgLyoq5riy5p+T55qEekluZGV4IOWKqOaAgeiwg+aVtHpJbmRleCznlKjkuo7mlrnkvr/kuLTov5HlkIjmibkgKi9cclxuICAgIEBwcm9wZXJ0eVxyXG4gICAgcHVibGljIHJlbmRlclpJbmRleDogbnVtYmVyID0gMDtcclxuICAgIC8qKuWQjOatpeeahOmXtOmalO+8iOW4p+S4uuWNleS9je+8iSAqL1xyXG4gICAgQHByb3BlcnR5KHtcclxuICAgICAgICB0b29sdGlwOiAn6K6+572u5ZCM5q2l55qE6Ze06ZqUKOenkuS4uuWNleS9jSnvvIww5bCx5piv5q+P5bin6YO95ZCM5q2l77yMMC4x5bCx5piv6ZqUMC4x56eS5ZCM5q2l5LiA5qyhJ1xyXG4gICAgfSlcclxuICAgIHB1YmxpYyBzeW5jSW52OiBudW1iZXIgPSAwLjAxO1xyXG4gICAgLyoq5riy5p+T55qEc0luZGV4ICovXHJcbiAgICBwdWJsaWMgc0luZGV4OiBudW1iZXIgPSAwO1xyXG4gICAgLyoq6Z2e5riy5p+T57uE5Lu2ICovXHJcbiAgICBwdWJsaWMgcHJveHlSZW5kZXI6IGNjLlJlbmRlckNvbXBvbmVudCA9IG51bGw7XHJcbiAgICAvKirmuLLmn5Pnu4Tku7YgKi9cclxuICAgIHByaXZhdGUgcmVuZGVyQ29tcG5lbnQ6IGNjLlJlbmRlckNvbXBvbmVudCA9IG51bGw7XHJcbiAgICAvKirkuIrmrKHmm7TmlrDnmoTmlbDmja4gKi9cclxuICAgIHB1YmxpYyBsYXN0V01hdDQ6IGNjLk1hdDQgPSBudWxsO1xyXG4gICAgLyoq5LiK5qyh5pu05paw55qE5pWw5o2uICovXHJcbiAgICBwdWJsaWMgbGFzdExNYXQ0OiBjYy5NYXQ0ID0gbnVsbDtcclxuICAgIC8qKuS4iuasoeabtOaWsOeahOaVsOaNriAqL1xyXG4gICAgcHVibGljIGxhc3RQb3M6IGNjLlZlYzMgPSBudWxsO1xyXG4gICAgLyoq6Led56a75LiL5qyh5Yi35paw57Sv6K6h5LqG5aSa5bCR6Ze06ZqUICovXHJcbiAgICBwdWJsaWMgYWNjdVRpbWU6IG51bWJlciA9IDA7XHJcbiAgICAvKirmnIDlkI7kuIDmrKHliLfmlrDml7bpl7QgKi9cclxuICAgIHB1YmxpYyBsYXN0RnJhbWVUaW1lOiBudW1iZXIgPSBudWxsO1xyXG4gICAgLyoq5piv5ZCm6L+b6KGM5Yi35pawICovXHJcbiAgICBwdWJsaWMgaXNBdHRhY2hGcmFtZTogYm9vbGVhbiA9IGZhbHNlO1xyXG5cclxuICAgIC8qKuiOt+WPluaAu+eahFpJbmRleCAqL1xyXG4gICAgZ2V0IHpJbmRleCgpIHtcclxuICAgICAgICBsZXQgekluZGV4ID0gdGhpcy5yZW5kZXJaSW5kZXggKyAodGhpcy5zSW5kZXggKiAwLjAxKTtcclxuICAgICAgICBsZXQgcGFyZW50Tm9kZSA9IHRoaXMubm9kZS5wYXJlbnQ7XHJcbiAgICAgICAgd2hpbGUgKHBhcmVudE5vZGUgIT0gdGhpcy5yZW5kZXJMYXllci5wYXJlbnQgJiYgcGFyZW50Tm9kZSAhPSBjYy5kaXJlY3Rvci5nZXRTY2VuZSgpKSB7XHJcbiAgICAgICAgICAgIGxldCByZW5kZXIgPSBwYXJlbnROb2RlLmdldENvbXBvbmVudChSZW5kZXJBbHRlcm5hdGl2ZSk7XHJcbiAgICAgICAgICAgIGlmIChyZW5kZXIpIHtcclxuICAgICAgICAgICAgICAgIHpJbmRleCArPSByZW5kZXIuekluZGV4ICsgMTtcclxuICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIHBhcmVudE5vZGUgPSBwYXJlbnROb2RlLnBhcmVudDtcclxuICAgICAgICB9XHJcbiAgICAgICAgcmV0dXJuIHpJbmRleDtcclxuICAgIH1cclxuXHJcbiAgICAvKipcclxuICAgICAqIOiuvue9rua4suafk+iKgueCueWxglxyXG4gICAgICogQHBhcmFtIGxheWVyIFxyXG4gICAgICovXHJcbiAgICBpbml0PFQgZXh0ZW5kcyBjYy5SZW5kZXJDb21wb25lbnQ+KGxheWVyPzogY2MuTm9kZSk6IFQge1xyXG4gICAgICAgIGlmIChsYXllcikge1xyXG4gICAgICAgICAgICB0aGlzLnJlbmRlckxheWVyID0gbGF5ZXI7XHJcbiAgICAgICAgfVxyXG4gICAgICAgIGlmICghdGhpcy5yZW5kZXJMYXllcikge1xyXG4gICAgICAgICAgICBjb25zb2xlLndhcm4oYOiKgueCuSR7dGhpcy5ub2RlLm5hbWV95rKh5pyJ6K6+572u5riy5p+T5bGCYClcclxuICAgICAgICAgICAgcmV0dXJuIG51bGw7XHJcbiAgICAgICAgfVxyXG4gICAgICAgIHJldHVybiB0aGlzLmluaXRSZW5kZXI8VD4oKTtcclxuICAgIH1cclxuICAgIC8qKlxyXG4gICAgICog5Yid5aeL5YyW5riy5p+T6IqC54K5XHJcbiAgICAgKi9cclxuICAgIHByaXZhdGUgaW5pdFJlbmRlcjxUIGV4dGVuZHMgY2MuUmVuZGVyQ29tcG9uZW50PigpOiBUIHtcclxuICAgICAgICBsZXQgbm9kZSA9IHRoaXMuZ2V0UmVuZGVyKCk7XHJcbiAgICAgICAgbm9kZS5zZXRQYXJlbnQodGhpcy5yZW5kZXJMYXllciA/IHRoaXMucmVuZGVyTGF5ZXIgOiBjYy5kaXJlY3Rvci5nZXRTY2VuZSgpLmdldENoaWxkQnlOYW1lKFwiQ2FudmFzXCIpKTtcclxuICAgICAgICB0aGlzLmlzQXR0YWNoRnJhbWUgPSB0cnVlO1xyXG4gICAgICAgIHJlcXVlc3RBbmltYXRpb25GcmFtZSh0aGlzLmZyYW1lVXBkYXRlLmJpbmQodGhpcykpO1xyXG4gICAgICAgIHJldHVybiB0aGlzLmRvUHJveHk8VD4oKTtcclxuICAgIH1cclxuICAgIC8qKueUn+aIkOS7o+eQhiAqL1xyXG4gICAgcHJpdmF0ZSBkb1Byb3h5PFQgZXh0ZW5kcyBjYy5SZW5kZXJDb21wb25lbnQ+KCk6IFQge1xyXG4gICAgICAgIHRoaXMucHJveHlSZW5kZXIgPSBuZXcgUHJveHkodGhpcy5yZW5kZXJDb21wbmVudCwgbmV3IFJlbmRlclJlYWN0aXZlSGFuZGxlcigpKSBhcyBUO1xyXG4gICAgICAgIHJldHVybiB0aGlzLnByb3h5UmVuZGVyIGFzIFQ7XHJcbiAgICB9XHJcblxyXG5cclxuICAgIHByb3RlY3RlZCBmcmFtZVVwZGF0ZSgpOiB2b2lkIHtcclxuICAgICAgICBsZXQgbm93ID0gY2Muc3lzLm5vdygpO1xyXG4gICAgICAgICF0aGlzLmxhc3RGcmFtZVRpbWUgJiYgKHRoaXMubGFzdEZyYW1lVGltZSA9IG5vdyk7XHJcbiAgICAgICAgbGV0IGR0ID0gbm93IC0gdGhpcy5sYXN0RnJhbWVUaW1lO1xyXG4gICAgICAgIGlmICh0aGlzLnByb3h5UmVuZGVyKSB7XHJcbiAgICAgICAgICAgIHRoaXMuYWNjdVRpbWUgKz0gZHQ7XHJcbiAgICAgICAgICAgIGlmICh0aGlzLmFjY3VUaW1lID49IHRoaXMuc3luY0ludikge1xyXG4gICAgICAgICAgICAgICAgdGhpcy5hY2N1VGltZSAtPSB0aGlzLnN5bmNJbnY7XHJcbiAgICAgICAgICAgICAgICB0aGlzLnVwZGF0ZVByb3AoKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH1cclxuICAgICAgICBpZiAodGhpcy5pc0F0dGFjaEZyYW1lKSB7XHJcbiAgICAgICAgICAgIHJlcXVlc3RBbmltYXRpb25GcmFtZSh0aGlzLmZyYW1lVXBkYXRlLmJpbmQodGhpcykpO1xyXG4gICAgICAgIH1cclxuICAgIH1cclxuXHJcbiAgICAvKirmm7TmlrDmnIDmlrDnirbmgIEgKi9cclxuICAgIHB1YmxpYyB1cGRhdGVQcm9wKCkge1xyXG4gICAgICAgIGxldCBub2RlID0gdGhpcy5yZW5kZXJDb21wbmVudC5ub2RlO1xyXG4gICAgICAgIGlmICghdGhpcy5ub2RlLmFjdGl2ZUluSGllcmFyY2h5KSB7XHJcbiAgICAgICAgICAgIG5vZGUub3BhY2l0eSA9IDA7XHJcbiAgICAgICAgICAgIHJldHVybjtcclxuICAgICAgICB9XHJcbiAgICAgICAgbm9kZS5hbmNob3JYID0gdGhpcy5ub2RlLmFuY2hvclg7XHJcbiAgICAgICAgbm9kZS5hbmNob3JZID0gdGhpcy5ub2RlLmFuY2hvclk7XHJcbiAgICAgICAgbm9kZS53aWR0aCA9IHRoaXMubm9kZS53aWR0aDtcclxuICAgICAgICBub2RlLmhlaWdodCA9IHRoaXMubm9kZS5oZWlnaHQ7XHJcbiAgICAgICAgbm9kZS5ncm91cCA9IHRoaXMubm9kZS5ncm91cDtcclxuICAgICAgICBub2RlLmNvbG9yID0gdGhpcy5ub2RlLmNvbG9yO1xyXG4gICAgICAgIG5vZGUub3BhY2l0eSA9IHRoaXMuZ2V0T3BhY2l0eSh0aGlzLm5vZGUpO1xyXG5cclxuICAgICAgICBsZXQgd01hdDQgPSBjYy5tYXQ0KCk7XHJcbiAgICAgICAgdGhpcy5ub2RlLmdldFdvcmxkTWF0cml4KHdNYXQ0KTtcclxuICAgICAgICBpZiAoIXRoaXMubGFzdFdNYXQ0IHx8ICF0aGlzLmxhc3RXTWF0NC5lcXVhbHMod01hdDQpKSB7XHJcbiAgICAgICAgICAgIGxldCBsb2NhbE1hdHJpeCA9IHRoaXMuZ2V0TG9jYWxNYXRyaXgod01hdDQsIG5vZGUpO1xyXG4gICAgICAgICAgICB0aGlzLnNldExvY2FsWFlaU2NhbGVBbmdsZShsb2NhbE1hdHJpeCwgbm9kZSwgdGhpcy5sYXN0TE1hdDQpO1xyXG4gICAgICAgICAgICB0aGlzLmxhc3RXTWF0NCA9IHdNYXQ0O1xyXG4gICAgICAgICAgICB0aGlzLmxhc3RMTWF0NCA9IGxvY2FsTWF0cml4O1xyXG4gICAgICAgIH1cclxuICAgICAgICBub2RlLnpJbmRleCA9IHRoaXMuekluZGV4O1xyXG4gICAgfVxyXG5cclxuICAgIHByaXZhdGUgZ2V0TG9jYWxNYXRyaXgod29ybGRNYXRyaXg6IGNjLk1hdDQsIG5vZGU6IGNjLk5vZGUpIHtcclxuICAgICAgICBsZXQgcGFyZW50Tm9kZSA9IG51bGw7XHJcbiAgICAgICAgaWYgKGNjLmlzVmFsaWQobm9kZSkpIHtcclxuICAgICAgICAgICAgaWYgKGNjLmlzVmFsaWQobm9kZS5wYXJlbnQpKSB7XHJcbiAgICAgICAgICAgICAgICBwYXJlbnROb2RlID0gbm9kZS5wYXJlbnRcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH1cclxuICAgICAgICAvLyDojrflj5bniLboioLngrnnmoTkuJbnlYznn6npmLVcclxuICAgICAgICBsZXQgcGFyZW50V29ybGRNYXRyaXggPSBjYy5tYXQ0KCk7XHJcbiAgICAgICAgcGFyZW50Tm9kZS5nZXRXb3JsZE1hdHJpeChwYXJlbnRXb3JsZE1hdHJpeCk7XHJcbiAgICAgICAgLy8g6I635Y+W54i26IqC54K555qE6YCG55+p6Zi1XHJcbiAgICAgICAgbGV0IHBhcmVudEludmVyc2VNYXRyaXggPSBwYXJlbnRXb3JsZE1hdHJpeC5pbnZlcnQoKTtcclxuICAgICAgICAvLyDlsIbnm67moIfoioLngrnnmoTkuJbnlYznn6npmLXovazmjaLkuLrniLboioLngrnnmoTmnKzlnLDnn6npmLVcclxuICAgICAgICBsZXQgbG9jYWxNYXRyaXggPSBwYXJlbnRJbnZlcnNlTWF0cml4Lm11bHRpcGx5KHdvcmxkTWF0cml4KTtcclxuICAgICAgICByZXR1cm4gbG9jYWxNYXRyaXg7XHJcblxyXG4gICAgfVxyXG5cclxuICAgIHByaXZhdGUgc2V0TG9jYWxYWVpTY2FsZUFuZ2xlKG1hdHJpeDogY2MuTWF0NCwgbm9kZTogY2MuTm9kZSwgbGFzdE1hdHJpeD86IGNjLk1hdDQpIHtcclxuICAgICAgICBpZiAobGFzdE1hdHJpeCAmJiBtYXRyaXguZXF1YWxzKGxhc3RNYXRyaXgpKSB7XHJcbiAgICAgICAgICAgIHJldHVybjtcclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIC8vIOaPkOWPluS9jee9rlxyXG4gICAgICAgIG5vZGUuc2V0UG9zaXRpb24obWF0cml4Lm1bMTJdLCBtYXRyaXgubVsxM10sIG1hdHJpeC5tWzE0XSk7XHJcblxyXG4gICAgICAgIGxldCBzY2FsZVggPSBudWxsO1xyXG4gICAgICAgIGxldCBzY2FsZVkgPSBudWxsO1xyXG4gICAgICAgIGxldCBhbmdsZSA9IG51bGw7XHJcbiAgICAgICAgLy8g5o+Q5Y+W57yp5pS+WFxyXG4gICAgICAgIGlmICghbGFzdE1hdHJpeCkge1xyXG4gICAgICAgICAgICBzY2FsZVggPSBNYXRoLnNxcnQobWF0cml4Lm1bMF0gKiBtYXRyaXgubVswXSArIG1hdHJpeC5tWzFdICogbWF0cml4Lm1bMV0gKyBtYXRyaXgubVsyXSAqIG1hdHJpeC5tWzJdKTtcclxuICAgICAgICB9IGVsc2UgaWYgKCF0aGlzLmVxdWFsc1ZhbHVlKG1hdHJpeC5tWzBdLCBsYXN0TWF0cml4Lm1bMF0pXHJcbiAgICAgICAgICAgIHx8ICF0aGlzLmVxdWFsc1ZhbHVlKG1hdHJpeC5tWzFdLCBsYXN0TWF0cml4Lm1bMV0pXHJcbiAgICAgICAgICAgIHx8ICF0aGlzLmVxdWFsc1ZhbHVlKG1hdHJpeC5tWzJdLCBsYXN0TWF0cml4Lm1bMl0pKSB7XHJcbiAgICAgICAgICAgIHNjYWxlWCA9IE1hdGguc3FydChtYXRyaXgubVswXSAqIG1hdHJpeC5tWzBdICsgbWF0cml4Lm1bMV0gKiBtYXRyaXgubVsxXSArIG1hdHJpeC5tWzJdICogbWF0cml4Lm1bMl0pO1xyXG4gICAgICAgIH1cclxuICAgICAgICAvLyDmj5Dlj5bnvKnmlL5ZXHJcbiAgICAgICAgaWYgKCFsYXN0TWF0cml4KSB7XHJcbiAgICAgICAgICAgIHNjYWxlWSA9IE1hdGguc3FydChtYXRyaXgubVs0XSAqIG1hdHJpeC5tWzRdICsgbWF0cml4Lm1bNV0gKiBtYXRyaXgubVs1XSArIG1hdHJpeC5tWzZdICogbWF0cml4Lm1bNl0pO1xyXG4gICAgICAgIH0gZWxzZSBpZiAoIXRoaXMuZXF1YWxzVmFsdWUobWF0cml4Lm1bNF0sIGxhc3RNYXRyaXgubVs0XSlcclxuICAgICAgICAgICAgfHwgIXRoaXMuZXF1YWxzVmFsdWUobWF0cml4Lm1bNV0sIGxhc3RNYXRyaXgubVs1XSlcclxuICAgICAgICAgICAgfHwgIXRoaXMuZXF1YWxzVmFsdWUobWF0cml4Lm1bNl0sIGxhc3RNYXRyaXgubVs2XSkpIHtcclxuICAgICAgICAgICAgc2NhbGVZID0gTWF0aC5zcXJ0KG1hdHJpeC5tWzRdICogbWF0cml4Lm1bNF0gKyBtYXRyaXgubVs1XSAqIG1hdHJpeC5tWzVdICsgbWF0cml4Lm1bNl0gKiBtYXRyaXgubVs2XSk7XHJcbiAgICAgICAgfVxyXG4gICAgICAgIC8v6K6+572u57yp5pS+WFxyXG4gICAgICAgIGlmIChzY2FsZVggIT09IG51bGwpIHtcclxuICAgICAgICAgICAgbm9kZS5zY2FsZVggPSBzY2FsZVg7XHJcbiAgICAgICAgICAgIC8vIOaPkOWPluaXi+i9rFxyXG4gICAgICAgICAgICBhbmdsZSA9IE1hdGguYXRhbjIobWF0cml4Lm1bMV0gLyBzY2FsZVgsIG1hdHJpeC5tWzBdIC8gc2NhbGVYKSAqICgxODAgLyBNYXRoLlBJKTtcclxuICAgICAgICB9XHJcbiAgICAgICAgaWYgKHNjYWxlWSAhPT0gbnVsbCkge1xyXG4gICAgICAgICAgICBub2RlLnNjYWxlWSA9IHNjYWxlWTtcclxuICAgICAgICB9XHJcbiAgICAgICAgaWYgKGFuZ2xlICE9PSBudWxsKSB7XHJcbiAgICAgICAgICAgIG5vZGUucm90YXRpb24gPSBhbmdsZTtcclxuICAgICAgICB9XHJcbiAgICB9XHJcblxyXG4gICAgcHJpdmF0ZSBlcXVhbHNWYWx1ZShhOiBudW1iZXIsIGI6IG51bWJlciwgZXBzaWxvbjogbnVtYmVyID0gMC4wMDAwMSkge1xyXG4gICAgICAgIHJldHVybiBNYXRoLmFicyhhIC0gYikgPCBlcHNpbG9uO1xyXG4gICAgfVxyXG5cclxuICAgIHByb3RlY3RlZCBvbkRlc3Ryb3koKTogdm9pZCB7XHJcbiAgICAgICAgdGhpcy5yZW5kZXJDb21wbmVudC5ub2RlLmRlc3Ryb3koKTtcclxuICAgICAgICB0aGlzLnJlbmRlckNvbXBuZW50ID0gbnVsbDtcclxuICAgICAgICB0aGlzLnByb3h5UmVuZGVyID0gbnVsbDtcclxuICAgIH1cclxuXHJcbiAgICAvKipcclxuICAgICAqIOiOt+WPluiKgueCuemAj+aYjuW6plxyXG4gICAgICogQHBhcmFtIG5vZGUgXHJcbiAgICAgKi9cclxuICAgIHByaXZhdGUgZ2V0T3BhY2l0eShub2RlOiBjYy5Ob2RlKSB7XHJcbiAgICAgICAgbGV0IG9wYWNpdHkgPSAobm9kZS5vcGFjaXR5IC8gMjU1KTtcclxuICAgICAgICBsZXQgcGFyZW50Tm9kZSA9IG5vZGUucGFyZW50XHJcbiAgICAgICAgd2hpbGUgKHBhcmVudE5vZGUgIT0gdGhpcy5yZW5kZXJMYXllci5wYXJlbnQgJiYgcGFyZW50Tm9kZSAhPSBjYy5kaXJlY3Rvci5nZXRTY2VuZSgpKSB7XHJcbiAgICAgICAgICAgIG9wYWNpdHkgKj0gKHBhcmVudE5vZGUub3BhY2l0eSAvIDI1NSk7XHJcbiAgICAgICAgICAgIHBhcmVudE5vZGUgPSBwYXJlbnROb2RlLnBhcmVudDtcclxuICAgICAgICB9XHJcbiAgICAgICAgcmV0dXJuIG9wYWNpdHkgKiAyNTU7XHJcbiAgICB9XHJcbiAgICAvKipcclxuICAgICAqIOiOt+WPlua4suafk+e7hOS7tlxyXG4gICAgICogQHBhcmFtIG5vZGUgXHJcbiAgICAgKi9cclxuICAgIHByaXZhdGUgZ2V0UmVuZGVyKCkge1xyXG4gICAgICAgIGxldCBub2RlID0gY2MuaW5zdGFudGlhdGUodGhpcy5ub2RlKTtcclxuICAgICAgICBub2RlLnJlbW92ZUFsbENoaWxkcmVuKCk7XHJcbiAgICAgICAgdGhpcy5yZW5kZXJDb21wbmVudCA9IG5vZGUuZ2V0Q29tcG9uZW50KGNjLlJlbmRlckNvbXBvbmVudCk7XHJcbiAgICAgICAgdGhpcy5ub2RlLmdldENvbXBvbmVudChjYy5MYWJlbE91dGxpbmUpPy5kZXN0cm95KCk7XHJcbiAgICAgICAgdGhpcy5ub2RlLmdldENvbXBvbmVudChjYy5MYWJlbFNoYWRvdyk/LmRlc3Ryb3koKTtcclxuICAgICAgICB0aGlzLm5vZGUuZ2V0Q29tcG9uZW50KGNjLlJlbmRlckNvbXBvbmVudCkuZGVzdHJveSgpO1xyXG4gICAgICAgIGxldCBjb21wb25lbnRzID0gbm9kZS5nZXRDb21wb25lbnRzKGNjLkNvbXBvbmVudCk7XHJcbiAgICAgICAgZm9yIChsZXQgaSA9IDAsIGxlbiA9IGNvbXBvbmVudHMubGVuZ3RoOyBpIDwgbGVuOyArK2kpIHtcclxuICAgICAgICAgICAgbGV0IGNvbXAgPSBjb21wb25lbnRzW2ldO1xyXG4gICAgICAgICAgICBpZiAoISgoY29tcCBpbnN0YW5jZW9mIGNjLlJlbmRlckNvbXBvbmVudCkgfHwgKGNvbXAgaW5zdGFuY2VvZiBjYy5MYWJlbE91dGxpbmUpIHx8IChjb21wIGluc3RhbmNlb2YgY2MuTGFiZWxTaGFkb3cpKSkge1xyXG4gICAgICAgICAgICAgICAgY29tcC5kZXN0cm95KCk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9XHJcbiAgICAgICAgcmV0dXJuIG5vZGU7XHJcbiAgICB9XHJcblxyXG59XHJcbiJdfQ== \ No newline at end of file diff --git a/Layered_virtual_list_2.x/temp/quick-scripts/dst/assets/Script/RenderAlternative1.js b/Layered_virtual_list_2.x/temp/quick-scripts/dst/assets/Script/RenderAlternative1.js new file mode 100644 index 0000000..0abc4e8 --- /dev/null +++ b/Layered_virtual_list_2.x/temp/quick-scripts/dst/assets/Script/RenderAlternative1.js @@ -0,0 +1,286 @@ + + (function() { + var nodeEnv = typeof require !== 'undefined' && typeof process !== 'undefined'; + var __module = nodeEnv ? module : {exports:{}}; + var __filename = 'preview-scripts/assets/Script/RenderAlternative1.js'; + var __require = nodeEnv ? function (request) { + return cc.require(request); + } : function (request) { + return __quick_compile_project__.require(request, __filename); + }; + function __define (exports, require, module) { + if (!nodeEnv) {__quick_compile_project__.registerModule(__filename, module);}"use strict"; +cc._RF.push(module, '5be15eLnZlCKqPK4B3Y4J6x', 'RenderAlternative1'); +// Script/RenderAlternative1.ts + +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var RenderReactiveHandler_1 = require("./RenderReactiveHandler"); +/** + * 目前该渲染代理功能存在的问题 + * 1.被代理节点的父级不能出现scaleX和scaleY不一致的情况,被代理节点本身没有这个限制 + */ +var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property; +var RenderAlternative = /** @class */ (function (_super) { + __extends(RenderAlternative, _super); + function RenderAlternative() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /**渲染层节点 */ + _this.renderLayer = null; + /**渲染的zIndex 动态调整zIndex,用于方便临近合批 */ + _this.renderZIndex = 0; + /**同步的间隔(帧为单位) */ + _this.syncInv = 0.01; + /**渲染的sIndex */ + _this.sIndex = 0; + /**非渲染组件 */ + _this.proxyRender = null; + /**渲染组件 */ + _this.renderCompnent = null; + /**上次更新的数据 */ + _this.lastWMat4 = null; + /**上次更新的数据 */ + _this.lastLMat4 = null; + /**上次更新的数据 */ + _this.lastPos = null; + /**距离下次刷新累计了多少间隔 */ + _this.accuTime = 0; + /**最后一次刷新时间 */ + _this.lastFrameTime = null; + /**是否进行刷新 */ + _this.isAttachFrame = false; + return _this; + } + RenderAlternative_1 = RenderAlternative; + Object.defineProperty(RenderAlternative.prototype, "zIndex", { + /**获取总的ZIndex */ + get: function () { + var zIndex = this.renderZIndex + (this.sIndex * 0.01); + var parentNode = this.node.parent; + while (parentNode != this.renderLayer.parent && parentNode != cc.director.getScene()) { + var render = parentNode.getComponent(RenderAlternative_1); + if (render) { + zIndex += render.zIndex + 1; + break; + } + parentNode = parentNode.parent; + } + return zIndex; + }, + enumerable: false, + configurable: true + }); + /** + * 设置渲染节点层 + * @param layer + */ + RenderAlternative.prototype.init = function (layer) { + if (layer) { + this.renderLayer = layer; + } + if (!this.renderLayer) { + console.warn("\u8282\u70B9" + this.node.name + "\u6CA1\u6709\u8BBE\u7F6E\u6E32\u67D3\u5C42"); + return null; + } + return this.initRender(); + }; + /** + * 初始化渲染节点 + */ + RenderAlternative.prototype.initRender = function () { + var node = this.getRender(); + node.setParent(this.renderLayer ? this.renderLayer : cc.director.getScene().getChildByName("Canvas")); + this.isAttachFrame = true; + requestAnimationFrame(this.frameUpdate.bind(this)); + return this.doProxy(); + }; + /**生成代理 */ + RenderAlternative.prototype.doProxy = function () { + this.proxyRender = new Proxy(this.renderCompnent, new RenderReactiveHandler_1.RenderReactiveHandler()); + return this.proxyRender; + }; + RenderAlternative.prototype.frameUpdate = function () { + var now = cc.sys.now(); + !this.lastFrameTime && (this.lastFrameTime = now); + var dt = now - this.lastFrameTime; + if (this.proxyRender) { + this.accuTime += dt; + if (this.accuTime >= this.syncInv) { + this.accuTime -= this.syncInv; + this.updateProp(); + } + } + if (this.isAttachFrame) { + requestAnimationFrame(this.frameUpdate.bind(this)); + } + }; + /**更新最新状态 */ + RenderAlternative.prototype.updateProp = function () { + var node = this.renderCompnent.node; + if (!this.node.activeInHierarchy) { + node.opacity = 0; + return; + } + node.anchorX = this.node.anchorX; + node.anchorY = this.node.anchorY; + node.width = this.node.width; + node.height = this.node.height; + node.group = this.node.group; + node.color = this.node.color; + node.opacity = this.getOpacity(this.node); + var wMat4 = cc.mat4(); + this.node.getWorldMatrix(wMat4); + if (!this.lastWMat4 || !this.lastWMat4.equals(wMat4)) { + var localMatrix = this.getLocalMatrix(wMat4, node); + this.setLocalXYZScaleAngle(localMatrix, node, this.lastLMat4); + this.lastWMat4 = wMat4; + this.lastLMat4 = localMatrix; + } + node.zIndex = this.zIndex; + }; + RenderAlternative.prototype.getLocalMatrix = function (worldMatrix, node) { + var parentNode = null; + if (cc.isValid(node)) { + if (cc.isValid(node.parent)) { + parentNode = node.parent; + } + } + // 获取父节点的世界矩阵 + var parentWorldMatrix = cc.mat4(); + parentNode.getWorldMatrix(parentWorldMatrix); + // 获取父节点的逆矩阵 + var parentInverseMatrix = parentWorldMatrix.invert(); + // 将目标节点的世界矩阵转换为父节点的本地矩阵 + var localMatrix = parentInverseMatrix.multiply(worldMatrix); + return localMatrix; + }; + RenderAlternative.prototype.setLocalXYZScaleAngle = function (matrix, node, lastMatrix) { + if (lastMatrix && matrix.equals(lastMatrix)) { + return; + } + // 提取位置 + node.setPosition(matrix.m[12], matrix.m[13], matrix.m[14]); + var scaleX = null; + var scaleY = null; + var angle = null; + // 提取缩放X + if (!lastMatrix) { + scaleX = Math.sqrt(matrix.m[0] * matrix.m[0] + matrix.m[1] * matrix.m[1] + matrix.m[2] * matrix.m[2]); + } + else if (!this.equalsValue(matrix.m[0], lastMatrix.m[0]) + || !this.equalsValue(matrix.m[1], lastMatrix.m[1]) + || !this.equalsValue(matrix.m[2], lastMatrix.m[2])) { + scaleX = Math.sqrt(matrix.m[0] * matrix.m[0] + matrix.m[1] * matrix.m[1] + matrix.m[2] * matrix.m[2]); + } + // 提取缩放Y + if (!lastMatrix) { + scaleY = Math.sqrt(matrix.m[4] * matrix.m[4] + matrix.m[5] * matrix.m[5] + matrix.m[6] * matrix.m[6]); + } + else if (!this.equalsValue(matrix.m[4], lastMatrix.m[4]) + || !this.equalsValue(matrix.m[5], lastMatrix.m[5]) + || !this.equalsValue(matrix.m[6], lastMatrix.m[6])) { + scaleY = Math.sqrt(matrix.m[4] * matrix.m[4] + matrix.m[5] * matrix.m[5] + matrix.m[6] * matrix.m[6]); + } + //设置缩放X + if (scaleX !== null) { + node.scaleX = scaleX; + // 提取旋转 + angle = Math.atan2(matrix.m[1] / scaleX, matrix.m[0] / scaleX) * (180 / Math.PI); + } + if (scaleY !== null) { + node.scaleY = scaleY; + } + if (angle !== null) { + node.rotation = angle; + } + }; + RenderAlternative.prototype.equalsValue = function (a, b, epsilon) { + if (epsilon === void 0) { epsilon = 0.00001; } + return Math.abs(a - b) < epsilon; + }; + RenderAlternative.prototype.onDestroy = function () { + this.renderCompnent.node.destroy(); + this.renderCompnent = null; + this.proxyRender = null; + }; + /** + * 获取节点透明度 + * @param node + */ + RenderAlternative.prototype.getOpacity = function (node) { + var opacity = (node.opacity / 255); + var parentNode = node.parent; + while (parentNode != this.renderLayer.parent && parentNode != cc.director.getScene()) { + opacity *= (parentNode.opacity / 255); + parentNode = parentNode.parent; + } + return opacity * 255; + }; + /** + * 获取渲染组件 + * @param node + */ + RenderAlternative.prototype.getRender = function () { + var _a, _b; + var node = cc.instantiate(this.node); + node.removeAllChildren(); + this.renderCompnent = node.getComponent(cc.RenderComponent); + (_a = this.node.getComponent(cc.LabelOutline)) === null || _a === void 0 ? void 0 : _a.destroy(); + (_b = this.node.getComponent(cc.LabelShadow)) === null || _b === void 0 ? void 0 : _b.destroy(); + this.node.getComponent(cc.RenderComponent).destroy(); + var components = node.getComponents(cc.Component); + for (var i = 0, len = components.length; i < len; ++i) { + var comp = components[i]; + if (!((comp instanceof cc.RenderComponent) || (comp instanceof cc.LabelOutline) || (comp instanceof cc.LabelShadow))) { + comp.destroy(); + } + } + return node; + }; + var RenderAlternative_1; + __decorate([ + property + ], RenderAlternative.prototype, "renderZIndex", void 0); + __decorate([ + property({ + tooltip: '设置同步的间隔(秒为单位),0就是每帧都同步,0.1就是隔0.1秒同步一次' + }) + ], RenderAlternative.prototype, "syncInv", void 0); + RenderAlternative = RenderAlternative_1 = __decorate([ + ccclass + ], RenderAlternative); + return RenderAlternative; +}(cc.Component)); +exports.default = RenderAlternative; + +cc._RF.pop(); + } + if (nodeEnv) { + __define(__module.exports, __require, __module); + } + else { + __quick_compile_project__.registerModuleFunc(__filename, function () { + __define(__module.exports, __require, __module); + }); + } + })(); +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImFzc2V0c1xcU2NyaXB0XFxSZW5kZXJBbHRlcm5hdGl2ZTEudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0FBQUEsaUVBQWdFO0FBRWhFOzs7R0FHRztBQUNHLElBQUEsS0FBd0IsRUFBRSxDQUFDLFVBQVUsRUFBbkMsT0FBTyxhQUFBLEVBQUUsUUFBUSxjQUFrQixDQUFDO0FBRTVDO0lBQStDLHFDQUFZO0lBQTNEO1FBQUEscUVBNk5DO1FBNU5HLFdBQVc7UUFDSixpQkFBVyxHQUFZLElBQUksQ0FBQztRQUNuQyxtQ0FBbUM7UUFFNUIsa0JBQVksR0FBVyxDQUFDLENBQUM7UUFDaEMsaUJBQWlCO1FBSVYsYUFBTyxHQUFXLElBQUksQ0FBQztRQUM5QixlQUFlO1FBQ1IsWUFBTSxHQUFXLENBQUMsQ0FBQztRQUMxQixXQUFXO1FBQ0osaUJBQVcsR0FBdUIsSUFBSSxDQUFDO1FBQzlDLFVBQVU7UUFDRixvQkFBYyxHQUF1QixJQUFJLENBQUM7UUFDbEQsYUFBYTtRQUNOLGVBQVMsR0FBWSxJQUFJLENBQUM7UUFDakMsYUFBYTtRQUNOLGVBQVMsR0FBWSxJQUFJLENBQUM7UUFDakMsYUFBYTtRQUNOLGFBQU8sR0FBWSxJQUFJLENBQUM7UUFDL0IsbUJBQW1CO1FBQ1osY0FBUSxHQUFXLENBQUMsQ0FBQztRQUM1QixjQUFjO1FBQ1AsbUJBQWEsR0FBVyxJQUFJLENBQUM7UUFDcEMsWUFBWTtRQUNMLG1CQUFhLEdBQVksS0FBSyxDQUFDOztJQWlNMUMsQ0FBQzswQkE3Tm9CLGlCQUFpQjtJQStCbEMsc0JBQUkscUNBQU07UUFEVixnQkFBZ0I7YUFDaEI7WUFDSSxJQUFJLE1BQU0sR0FBRyxJQUFJLENBQUMsWUFBWSxHQUFHLENBQUMsSUFBSSxDQUFDLE1BQU0sR0FBRyxJQUFJLENBQUMsQ0FBQztZQUN0RCxJQUFJLFVBQVUsR0FBRyxJQUFJLENBQUMsSUFBSSxDQUFDLE1BQU0sQ0FBQztZQUNsQyxPQUFPLFVBQVUsSUFBSSxJQUFJLENBQUMsV0FBVyxDQUFDLE1BQU0sSUFBSSxVQUFVLElBQUksRUFBRSxDQUFDLFFBQVEsQ0FBQyxRQUFRLEVBQUUsRUFBRTtnQkFDbEYsSUFBSSxNQUFNLEdBQUcsVUFBVSxDQUFDLFlBQVksQ0FBQyxtQkFBaUIsQ0FBQyxDQUFDO2dCQUN4RCxJQUFJLE1BQU0sRUFBRTtvQkFDUixNQUFNLElBQUksTUFBTSxDQUFDLE1BQU0sR0FBRyxDQUFDLENBQUM7b0JBQzVCLE1BQU07aUJBQ1Q7Z0JBQ0QsVUFBVSxHQUFHLFVBQVUsQ0FBQyxNQUFNLENBQUM7YUFDbEM7WUFDRCxPQUFPLE1BQU0sQ0FBQztRQUNsQixDQUFDOzs7T0FBQTtJQUVEOzs7T0FHRztJQUNILGdDQUFJLEdBQUosVUFBbUMsS0FBZTtRQUM5QyxJQUFJLEtBQUssRUFBRTtZQUNQLElBQUksQ0FBQyxXQUFXLEdBQUcsS0FBSyxDQUFDO1NBQzVCO1FBQ0QsSUFBSSxDQUFDLElBQUksQ0FBQyxXQUFXLEVBQUU7WUFDbkIsT0FBTyxDQUFDLElBQUksQ0FBQyxpQkFBSyxJQUFJLENBQUMsSUFBSSxDQUFDLElBQUksK0NBQVMsQ0FBQyxDQUFBO1lBQzFDLE9BQU8sSUFBSSxDQUFDO1NBQ2Y7UUFDRCxPQUFPLElBQUksQ0FBQyxVQUFVLEVBQUssQ0FBQztJQUNoQyxDQUFDO0lBQ0Q7O09BRUc7SUFDSyxzQ0FBVSxHQUFsQjtRQUNJLElBQUksSUFBSSxHQUFHLElBQUksQ0FBQyxTQUFTLEVBQUUsQ0FBQztRQUM1QixJQUFJLENBQUMsU0FBUyxDQUFDLElBQUksQ0FBQyxXQUFXLENBQUMsQ0FBQyxDQUFDLElBQUksQ0FBQyxXQUFXLENBQUMsQ0FBQyxDQUFDLEVBQUUsQ0FBQyxRQUFRLENBQUMsUUFBUSxFQUFFLENBQUMsY0FBYyxDQUFDLFFBQVEsQ0FBQyxDQUFDLENBQUM7UUFDdEcsSUFBSSxDQUFDLGFBQWEsR0FBRyxJQUFJLENBQUM7UUFDMUIscUJBQXFCLENBQUMsSUFBSSxDQUFDLFdBQVcsQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLENBQUMsQ0FBQztRQUNuRCxPQUFPLElBQUksQ0FBQyxPQUFPLEVBQUssQ0FBQztJQUM3QixDQUFDO0lBQ0QsVUFBVTtJQUNGLG1DQUFPLEdBQWY7UUFDSSxJQUFJLENBQUMsV0FBVyxHQUFHLElBQUksS0FBSyxDQUFDLElBQUksQ0FBQyxjQUFjLEVBQUUsSUFBSSw2Q0FBcUIsRUFBRSxDQUFNLENBQUM7UUFDcEYsT0FBTyxJQUFJLENBQUMsV0FBZ0IsQ0FBQztJQUNqQyxDQUFDO0lBR1MsdUNBQVcsR0FBckI7UUFDSSxJQUFJLEdBQUcsR0FBRyxFQUFFLENBQUMsR0FBRyxDQUFDLEdBQUcsRUFBRSxDQUFDO1FBQ3ZCLENBQUMsSUFBSSxDQUFDLGFBQWEsSUFBSSxDQUFDLElBQUksQ0FBQyxhQUFhLEdBQUcsR0FBRyxDQUFDLENBQUM7UUFDbEQsSUFBSSxFQUFFLEdBQUcsR0FBRyxHQUFHLElBQUksQ0FBQyxhQUFhLENBQUM7UUFDbEMsSUFBSSxJQUFJLENBQUMsV0FBVyxFQUFFO1lBQ2xCLElBQUksQ0FBQyxRQUFRLElBQUksRUFBRSxDQUFDO1lBQ3BCLElBQUksSUFBSSxDQUFDLFFBQVEsSUFBSSxJQUFJLENBQUMsT0FBTyxFQUFFO2dCQUMvQixJQUFJLENBQUMsUUFBUSxJQUFJLElBQUksQ0FBQyxPQUFPLENBQUM7Z0JBQzlCLElBQUksQ0FBQyxVQUFVLEVBQUUsQ0FBQzthQUNyQjtTQUNKO1FBQ0QsSUFBSSxJQUFJLENBQUMsYUFBYSxFQUFFO1lBQ3BCLHFCQUFxQixDQUFDLElBQUksQ0FBQyxXQUFXLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxDQUFDLENBQUM7U0FDdEQ7SUFDTCxDQUFDO0lBRUQsWUFBWTtJQUNMLHNDQUFVLEdBQWpCO1FBQ0ksSUFBSSxJQUFJLEdBQUcsSUFBSSxDQUFDLGNBQWMsQ0FBQyxJQUFJLENBQUM7UUFDcEMsSUFBSSxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsaUJBQWlCLEVBQUU7WUFDOUIsSUFBSSxDQUFDLE9BQU8sR0FBRyxDQUFDLENBQUM7WUFDakIsT0FBTztTQUNWO1FBQ0QsSUFBSSxDQUFDLE9BQU8sR0FBRyxJQUFJLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQztRQUNqQyxJQUFJLENBQUMsT0FBTyxHQUFHLElBQUksQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDO1FBQ2pDLElBQUksQ0FBQyxLQUFLLEdBQUcsSUFBSSxDQUFDLElBQUksQ0FBQyxLQUFLLENBQUM7UUFDN0IsSUFBSSxDQUFDLE1BQU0sR0FBRyxJQUFJLENBQUMsSUFBSSxDQUFDLE1BQU0sQ0FBQztRQUMvQixJQUFJLENBQUMsS0FBSyxHQUFHLElBQUksQ0FBQyxJQUFJLENBQUMsS0FBSyxDQUFDO1FBQzdCLElBQUksQ0FBQyxLQUFLLEdBQUcsSUFBSSxDQUFDLElBQUksQ0FBQyxLQUFLLENBQUM7UUFDN0IsSUFBSSxDQUFDLE9BQU8sR0FBRyxJQUFJLENBQUMsVUFBVSxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsQ0FBQztRQUUxQyxJQUFJLEtBQUssR0FBRyxFQUFFLENBQUMsSUFBSSxFQUFFLENBQUM7UUFDdEIsSUFBSSxDQUFDLElBQUksQ0FBQyxjQUFjLENBQUMsS0FBSyxDQUFDLENBQUM7UUFDaEMsSUFBSSxDQUFDLElBQUksQ0FBQyxTQUFTLElBQUksQ0FBQyxJQUFJLENBQUMsU0FBUyxDQUFDLE1BQU0sQ0FBQyxLQUFLLENBQUMsRUFBRTtZQUNsRCxJQUFJLFdBQVcsR0FBRyxJQUFJLENBQUMsY0FBYyxDQUFDLEtBQUssRUFBRSxJQUFJLENBQUMsQ0FBQztZQUNuRCxJQUFJLENBQUMscUJBQXFCLENBQUMsV0FBVyxFQUFFLElBQUksRUFBRSxJQUFJLENBQUMsU0FBUyxDQUFDLENBQUM7WUFDOUQsSUFBSSxDQUFDLFNBQVMsR0FBRyxLQUFLLENBQUM7WUFDdkIsSUFBSSxDQUFDLFNBQVMsR0FBRyxXQUFXLENBQUM7U0FDaEM7UUFDRCxJQUFJLENBQUMsTUFBTSxHQUFHLElBQUksQ0FBQyxNQUFNLENBQUM7SUFDOUIsQ0FBQztJQUVPLDBDQUFjLEdBQXRCLFVBQXVCLFdBQW9CLEVBQUUsSUFBYTtRQUN0RCxJQUFJLFVBQVUsR0FBRyxJQUFJLENBQUM7UUFDdEIsSUFBSSxFQUFFLENBQUMsT0FBTyxDQUFDLElBQUksQ0FBQyxFQUFFO1lBQ2xCLElBQUksRUFBRSxDQUFDLE9BQU8sQ0FBQyxJQUFJLENBQUMsTUFBTSxDQUFDLEVBQUU7Z0JBQ3pCLFVBQVUsR0FBRyxJQUFJLENBQUMsTUFBTSxDQUFBO2FBQzNCO1NBQ0o7UUFDRCxhQUFhO1FBQ2IsSUFBSSxpQkFBaUIsR0FBRyxFQUFFLENBQUMsSUFBSSxFQUFFLENBQUM7UUFDbEMsVUFBVSxDQUFDLGNBQWMsQ0FBQyxpQkFBaUIsQ0FBQyxDQUFDO1FBQzdDLFlBQVk7UUFDWixJQUFJLG1CQUFtQixHQUFHLGlCQUFpQixDQUFDLE1BQU0sRUFBRSxDQUFDO1FBQ3JELHdCQUF3QjtRQUN4QixJQUFJLFdBQVcsR0FBRyxtQkFBbUIsQ0FBQyxRQUFRLENBQUMsV0FBVyxDQUFDLENBQUM7UUFDNUQsT0FBTyxXQUFXLENBQUM7SUFFdkIsQ0FBQztJQUVPLGlEQUFxQixHQUE3QixVQUE4QixNQUFlLEVBQUUsSUFBYSxFQUFFLFVBQW9CO1FBQzlFLElBQUksVUFBVSxJQUFJLE1BQU0sQ0FBQyxNQUFNLENBQUMsVUFBVSxDQUFDLEVBQUU7WUFDekMsT0FBTztTQUNWO1FBRUQsT0FBTztRQUNQLElBQUksQ0FBQyxXQUFXLENBQUMsTUFBTSxDQUFDLENBQUMsQ0FBQyxFQUFFLENBQUMsRUFBRSxNQUFNLENBQUMsQ0FBQyxDQUFDLEVBQUUsQ0FBQyxFQUFFLE1BQU0sQ0FBQyxDQUFDLENBQUMsRUFBRSxDQUFDLENBQUMsQ0FBQztRQUUzRCxJQUFJLE1BQU0sR0FBRyxJQUFJLENBQUM7UUFDbEIsSUFBSSxNQUFNLEdBQUcsSUFBSSxDQUFDO1FBQ2xCLElBQUksS0FBSyxHQUFHLElBQUksQ0FBQztRQUNqQixRQUFRO1FBQ1IsSUFBSSxDQUFDLFVBQVUsRUFBRTtZQUNiLE1BQU0sR0FBRyxJQUFJLENBQUMsSUFBSSxDQUFDLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUM7U0FDekc7YUFBTSxJQUFJLENBQUMsSUFBSSxDQUFDLFdBQVcsQ0FBQyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxFQUFFLFVBQVUsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUM7ZUFDbkQsQ0FBQyxJQUFJLENBQUMsV0FBVyxDQUFDLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEVBQUUsVUFBVSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQztlQUMvQyxDQUFDLElBQUksQ0FBQyxXQUFXLENBQUMsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsRUFBRSxVQUFVLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEVBQUU7WUFDcEQsTUFBTSxHQUFHLElBQUksQ0FBQyxJQUFJLENBQUMsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQztTQUN6RztRQUNELFFBQVE7UUFDUixJQUFJLENBQUMsVUFBVSxFQUFFO1lBQ2IsTUFBTSxHQUFHLElBQUksQ0FBQyxJQUFJLENBQUMsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQztTQUN6RzthQUFNLElBQUksQ0FBQyxJQUFJLENBQUMsV0FBVyxDQUFDLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEVBQUUsVUFBVSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQztlQUNuRCxDQUFDLElBQUksQ0FBQyxXQUFXLENBQUMsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsRUFBRSxVQUFVLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDO2VBQy9DLENBQUMsSUFBSSxDQUFDLFdBQVcsQ0FBQyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxFQUFFLFVBQVUsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsRUFBRTtZQUNwRCxNQUFNLEdBQUcsSUFBSSxDQUFDLElBQUksQ0FBQyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDO1NBQ3pHO1FBQ0QsT0FBTztRQUNQLElBQUksTUFBTSxLQUFLLElBQUksRUFBRTtZQUNqQixJQUFJLENBQUMsTUFBTSxHQUFHLE1BQU0sQ0FBQztZQUNyQixPQUFPO1lBQ1AsS0FBSyxHQUFHLElBQUksQ0FBQyxLQUFLLENBQUMsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxNQUFNLEVBQUUsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxNQUFNLENBQUMsR0FBRyxDQUFDLEdBQUcsR0FBRyxJQUFJLENBQUMsRUFBRSxDQUFDLENBQUM7U0FDcEY7UUFDRCxJQUFJLE1BQU0sS0FBSyxJQUFJLEVBQUU7WUFDakIsSUFBSSxDQUFDLE1BQU0sR0FBRyxNQUFNLENBQUM7U0FDeEI7UUFDRCxJQUFJLEtBQUssS0FBSyxJQUFJLEVBQUU7WUFDaEIsSUFBSSxDQUFDLFFBQVEsR0FBRyxLQUFLLENBQUM7U0FDekI7SUFDTCxDQUFDO0lBRU8sdUNBQVcsR0FBbkIsVUFBb0IsQ0FBUyxFQUFFLENBQVMsRUFBRSxPQUF5QjtRQUF6Qix3QkFBQSxFQUFBLGlCQUF5QjtRQUMvRCxPQUFPLElBQUksQ0FBQyxHQUFHLENBQUMsQ0FBQyxHQUFHLENBQUMsQ0FBQyxHQUFHLE9BQU8sQ0FBQztJQUNyQyxDQUFDO0lBRVMscUNBQVMsR0FBbkI7UUFDSSxJQUFJLENBQUMsY0FBYyxDQUFDLElBQUksQ0FBQyxPQUFPLEVBQUUsQ0FBQztRQUNuQyxJQUFJLENBQUMsY0FBYyxHQUFHLElBQUksQ0FBQztRQUMzQixJQUFJLENBQUMsV0FBVyxHQUFHLElBQUksQ0FBQztJQUM1QixDQUFDO0lBRUQ7OztPQUdHO0lBQ0ssc0NBQVUsR0FBbEIsVUFBbUIsSUFBYTtRQUM1QixJQUFJLE9BQU8sR0FBRyxDQUFDLElBQUksQ0FBQyxPQUFPLEdBQUcsR0FBRyxDQUFDLENBQUM7UUFDbkMsSUFBSSxVQUFVLEdBQUcsSUFBSSxDQUFDLE1BQU0sQ0FBQTtRQUM1QixPQUFPLFVBQVUsSUFBSSxJQUFJLENBQUMsV0FBVyxDQUFDLE1BQU0sSUFBSSxVQUFVLElBQUksRUFBRSxDQUFDLFFBQVEsQ0FBQyxRQUFRLEVBQUUsRUFBRTtZQUNsRixPQUFPLElBQUksQ0FBQyxVQUFVLENBQUMsT0FBTyxHQUFHLEdBQUcsQ0FBQyxDQUFDO1lBQ3RDLFVBQVUsR0FBRyxVQUFVLENBQUMsTUFBTSxDQUFDO1NBQ2xDO1FBQ0QsT0FBTyxPQUFPLEdBQUcsR0FBRyxDQUFDO0lBQ3pCLENBQUM7SUFDRDs7O09BR0c7SUFDSyxxQ0FBUyxHQUFqQjs7UUFDSSxJQUFJLElBQUksR0FBRyxFQUFFLENBQUMsV0FBVyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsQ0FBQztRQUNyQyxJQUFJLENBQUMsaUJBQWlCLEVBQUUsQ0FBQztRQUN6QixJQUFJLENBQUMsY0FBYyxHQUFHLElBQUksQ0FBQyxZQUFZLENBQUMsRUFBRSxDQUFDLGVBQWUsQ0FBQyxDQUFDO1FBQzVELE1BQUEsSUFBSSxDQUFDLElBQUksQ0FBQyxZQUFZLENBQUMsRUFBRSxDQUFDLFlBQVksQ0FBQywwQ0FBRSxPQUFPLEdBQUc7UUFDbkQsTUFBQSxJQUFJLENBQUMsSUFBSSxDQUFDLFlBQVksQ0FBQyxFQUFFLENBQUMsV0FBVyxDQUFDLDBDQUFFLE9BQU8sR0FBRztRQUNsRCxJQUFJLENBQUMsSUFBSSxDQUFDLFlBQVksQ0FBQyxFQUFFLENBQUMsZUFBZSxDQUFDLENBQUMsT0FBTyxFQUFFLENBQUM7UUFDckQsSUFBSSxVQUFVLEdBQUcsSUFBSSxDQUFDLGFBQWEsQ0FBQyxFQUFFLENBQUMsU0FBUyxDQUFDLENBQUM7UUFDbEQsS0FBSyxJQUFJLENBQUMsR0FBRyxDQUFDLEVBQUUsR0FBRyxHQUFHLFVBQVUsQ0FBQyxNQUFNLEVBQUUsQ0FBQyxHQUFHLEdBQUcsRUFBRSxFQUFFLENBQUMsRUFBRTtZQUNuRCxJQUFJLElBQUksR0FBRyxVQUFVLENBQUMsQ0FBQyxDQUFDLENBQUM7WUFDekIsSUFBSSxDQUFDLENBQUMsQ0FBQyxJQUFJLFlBQVksRUFBRSxDQUFDLGVBQWUsQ0FBQyxJQUFJLENBQUMsSUFBSSxZQUFZLEVBQUUsQ0FBQyxZQUFZLENBQUMsSUFBSSxDQUFDLElBQUksWUFBWSxFQUFFLENBQUMsV0FBVyxDQUFDLENBQUMsRUFBRTtnQkFDbEgsSUFBSSxDQUFDLE9BQU8sRUFBRSxDQUFDO2FBQ2xCO1NBQ0o7UUFDRCxPQUFPLElBQUksQ0FBQztJQUNoQixDQUFDOztJQXRORDtRQURDLFFBQVE7MkRBQ3VCO0lBS2hDO1FBSEMsUUFBUSxDQUFDO1lBQ04sT0FBTyxFQUFFLHVDQUF1QztTQUNuRCxDQUFDO3NEQUM0QjtJQVZiLGlCQUFpQjtRQURyQyxPQUFPO09BQ2EsaUJBQWlCLENBNk5yQztJQUFELHdCQUFDO0NBN05ELEFBNk5DLENBN044QyxFQUFFLENBQUMsU0FBUyxHQTZOMUQ7a0JBN05vQixpQkFBaUIiLCJmaWxlIjoiIiwic291cmNlUm9vdCI6Ii8iLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBSZW5kZXJSZWFjdGl2ZUhhbmRsZXIgfSBmcm9tIFwiLi9SZW5kZXJSZWFjdGl2ZUhhbmRsZXJcIjtcclxuXHJcbi8qKlxyXG4gKiDnm67liY3or6XmuLLmn5Pku6PnkIblip/og73lrZjlnKjnmoTpl67pophcclxuICogMS7ooqvku6PnkIboioLngrnnmoTniLbnuqfkuI3og73lh7rnjrBzY2FsZVjlkoxzY2FsZVnkuI3kuIDoh7TnmoTmg4XlhrXvvIzooqvku6PnkIboioLngrnmnKzouqvmsqHmnInov5nkuKrpmZDliLZcclxuICovXHJcbmNvbnN0IHsgY2NjbGFzcywgcHJvcGVydHkgfSA9IGNjLl9kZWNvcmF0b3I7XHJcbkBjY2NsYXNzXHJcbmV4cG9ydCBkZWZhdWx0IGNsYXNzIFJlbmRlckFsdGVybmF0aXZlIGV4dGVuZHMgY2MuQ29tcG9uZW50IHtcclxuICAgIC8qKua4suafk+WxguiKgueCuSAqL1xyXG4gICAgcHVibGljIHJlbmRlckxheWVyOiBjYy5Ob2RlID0gbnVsbDtcclxuICAgIC8qKua4suafk+eahHpJbmRleCDliqjmgIHosIPmlbR6SW5kZXgs55So5LqO5pa55L6/5Li06L+R5ZCI5om5ICovXHJcbiAgICBAcHJvcGVydHlcclxuICAgIHB1YmxpYyByZW5kZXJaSW5kZXg6IG51bWJlciA9IDA7XHJcbiAgICAvKirlkIzmraXnmoTpl7TpmpTvvIjluKfkuLrljZXkvY3vvIkgKi9cclxuICAgIEBwcm9wZXJ0eSh7XHJcbiAgICAgICAgdG9vbHRpcDogJ+iuvue9ruWQjOatpeeahOmXtOmalCjnp5LkuLrljZXkvY0p77yMMOWwseaYr+avj+W4p+mDveWQjOatpe+8jDAuMeWwseaYr+malDAuMeenkuWQjOatpeS4gOasoSdcclxuICAgIH0pXHJcbiAgICBwdWJsaWMgc3luY0ludjogbnVtYmVyID0gMC4wMTtcclxuICAgIC8qKua4suafk+eahHNJbmRleCAqL1xyXG4gICAgcHVibGljIHNJbmRleDogbnVtYmVyID0gMDtcclxuICAgIC8qKumdnua4suafk+e7hOS7tiAqL1xyXG4gICAgcHVibGljIHByb3h5UmVuZGVyOiBjYy5SZW5kZXJDb21wb25lbnQgPSBudWxsO1xyXG4gICAgLyoq5riy5p+T57uE5Lu2ICovXHJcbiAgICBwcml2YXRlIHJlbmRlckNvbXBuZW50OiBjYy5SZW5kZXJDb21wb25lbnQgPSBudWxsO1xyXG4gICAgLyoq5LiK5qyh5pu05paw55qE5pWw5o2uICovXHJcbiAgICBwdWJsaWMgbGFzdFdNYXQ0OiBjYy5NYXQ0ID0gbnVsbDtcclxuICAgIC8qKuS4iuasoeabtOaWsOeahOaVsOaNriAqL1xyXG4gICAgcHVibGljIGxhc3RMTWF0NDogY2MuTWF0NCA9IG51bGw7XHJcbiAgICAvKirkuIrmrKHmm7TmlrDnmoTmlbDmja4gKi9cclxuICAgIHB1YmxpYyBsYXN0UG9zOiBjYy5WZWMzID0gbnVsbDtcclxuICAgIC8qKui3neemu+S4i+asoeWIt+aWsOe0r+iuoeS6huWkmuWwkemXtOmalCAqL1xyXG4gICAgcHVibGljIGFjY3VUaW1lOiBudW1iZXIgPSAwO1xyXG4gICAgLyoq5pyA5ZCO5LiA5qyh5Yi35paw5pe26Ze0ICovXHJcbiAgICBwdWJsaWMgbGFzdEZyYW1lVGltZTogbnVtYmVyID0gbnVsbDtcclxuICAgIC8qKuaYr+WQpui/m+ihjOWIt+aWsCAqL1xyXG4gICAgcHVibGljIGlzQXR0YWNoRnJhbWU6IGJvb2xlYW4gPSBmYWxzZTtcclxuXHJcbiAgICAvKirojrflj5bmgLvnmoRaSW5kZXggKi9cclxuICAgIGdldCB6SW5kZXgoKSB7XHJcbiAgICAgICAgbGV0IHpJbmRleCA9IHRoaXMucmVuZGVyWkluZGV4ICsgKHRoaXMuc0luZGV4ICogMC4wMSk7XHJcbiAgICAgICAgbGV0IHBhcmVudE5vZGUgPSB0aGlzLm5vZGUucGFyZW50O1xyXG4gICAgICAgIHdoaWxlIChwYXJlbnROb2RlICE9IHRoaXMucmVuZGVyTGF5ZXIucGFyZW50ICYmIHBhcmVudE5vZGUgIT0gY2MuZGlyZWN0b3IuZ2V0U2NlbmUoKSkge1xyXG4gICAgICAgICAgICBsZXQgcmVuZGVyID0gcGFyZW50Tm9kZS5nZXRDb21wb25lbnQoUmVuZGVyQWx0ZXJuYXRpdmUpO1xyXG4gICAgICAgICAgICBpZiAocmVuZGVyKSB7XHJcbiAgICAgICAgICAgICAgICB6SW5kZXggKz0gcmVuZGVyLnpJbmRleCArIDE7XHJcbiAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBwYXJlbnROb2RlID0gcGFyZW50Tm9kZS5wYXJlbnQ7XHJcbiAgICAgICAgfVxyXG4gICAgICAgIHJldHVybiB6SW5kZXg7XHJcbiAgICB9XHJcblxyXG4gICAgLyoqXHJcbiAgICAgKiDorr7nva7muLLmn5PoioLngrnlsYJcclxuICAgICAqIEBwYXJhbSBsYXllciBcclxuICAgICAqL1xyXG4gICAgaW5pdDxUIGV4dGVuZHMgY2MuUmVuZGVyQ29tcG9uZW50PihsYXllcj86IGNjLk5vZGUpOiBUIHtcclxuICAgICAgICBpZiAobGF5ZXIpIHtcclxuICAgICAgICAgICAgdGhpcy5yZW5kZXJMYXllciA9IGxheWVyO1xyXG4gICAgICAgIH1cclxuICAgICAgICBpZiAoIXRoaXMucmVuZGVyTGF5ZXIpIHtcclxuICAgICAgICAgICAgY29uc29sZS53YXJuKGDoioLngrkke3RoaXMubm9kZS5uYW1lfeayoeacieiuvue9rua4suafk+WxgmApXHJcbiAgICAgICAgICAgIHJldHVybiBudWxsO1xyXG4gICAgICAgIH1cclxuICAgICAgICByZXR1cm4gdGhpcy5pbml0UmVuZGVyPFQ+KCk7XHJcbiAgICB9XHJcbiAgICAvKipcclxuICAgICAqIOWIneWni+WMlua4suafk+iKgueCuVxyXG4gICAgICovXHJcbiAgICBwcml2YXRlIGluaXRSZW5kZXI8VCBleHRlbmRzIGNjLlJlbmRlckNvbXBvbmVudD4oKTogVCB7XHJcbiAgICAgICAgbGV0IG5vZGUgPSB0aGlzLmdldFJlbmRlcigpO1xyXG4gICAgICAgIG5vZGUuc2V0UGFyZW50KHRoaXMucmVuZGVyTGF5ZXIgPyB0aGlzLnJlbmRlckxheWVyIDogY2MuZGlyZWN0b3IuZ2V0U2NlbmUoKS5nZXRDaGlsZEJ5TmFtZShcIkNhbnZhc1wiKSk7XHJcbiAgICAgICAgdGhpcy5pc0F0dGFjaEZyYW1lID0gdHJ1ZTtcclxuICAgICAgICByZXF1ZXN0QW5pbWF0aW9uRnJhbWUodGhpcy5mcmFtZVVwZGF0ZS5iaW5kKHRoaXMpKTtcclxuICAgICAgICByZXR1cm4gdGhpcy5kb1Byb3h5PFQ+KCk7XHJcbiAgICB9XHJcbiAgICAvKirnlJ/miJDku6PnkIYgKi9cclxuICAgIHByaXZhdGUgZG9Qcm94eTxUIGV4dGVuZHMgY2MuUmVuZGVyQ29tcG9uZW50PigpOiBUIHtcclxuICAgICAgICB0aGlzLnByb3h5UmVuZGVyID0gbmV3IFByb3h5KHRoaXMucmVuZGVyQ29tcG5lbnQsIG5ldyBSZW5kZXJSZWFjdGl2ZUhhbmRsZXIoKSkgYXMgVDtcclxuICAgICAgICByZXR1cm4gdGhpcy5wcm94eVJlbmRlciBhcyBUO1xyXG4gICAgfVxyXG5cclxuXHJcbiAgICBwcm90ZWN0ZWQgZnJhbWVVcGRhdGUoKTogdm9pZCB7XHJcbiAgICAgICAgbGV0IG5vdyA9IGNjLnN5cy5ub3coKTtcclxuICAgICAgICAhdGhpcy5sYXN0RnJhbWVUaW1lICYmICh0aGlzLmxhc3RGcmFtZVRpbWUgPSBub3cpO1xyXG4gICAgICAgIGxldCBkdCA9IG5vdyAtIHRoaXMubGFzdEZyYW1lVGltZTtcclxuICAgICAgICBpZiAodGhpcy5wcm94eVJlbmRlcikge1xyXG4gICAgICAgICAgICB0aGlzLmFjY3VUaW1lICs9IGR0O1xyXG4gICAgICAgICAgICBpZiAodGhpcy5hY2N1VGltZSA+PSB0aGlzLnN5bmNJbnYpIHtcclxuICAgICAgICAgICAgICAgIHRoaXMuYWNjdVRpbWUgLT0gdGhpcy5zeW5jSW52O1xyXG4gICAgICAgICAgICAgICAgdGhpcy51cGRhdGVQcm9wKCk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9XHJcbiAgICAgICAgaWYgKHRoaXMuaXNBdHRhY2hGcmFtZSkge1xyXG4gICAgICAgICAgICByZXF1ZXN0QW5pbWF0aW9uRnJhbWUodGhpcy5mcmFtZVVwZGF0ZS5iaW5kKHRoaXMpKTtcclxuICAgICAgICB9XHJcbiAgICB9XHJcblxyXG4gICAgLyoq5pu05paw5pyA5paw54q25oCBICovXHJcbiAgICBwdWJsaWMgdXBkYXRlUHJvcCgpIHtcclxuICAgICAgICBsZXQgbm9kZSA9IHRoaXMucmVuZGVyQ29tcG5lbnQubm9kZTtcclxuICAgICAgICBpZiAoIXRoaXMubm9kZS5hY3RpdmVJbkhpZXJhcmNoeSkge1xyXG4gICAgICAgICAgICBub2RlLm9wYWNpdHkgPSAwO1xyXG4gICAgICAgICAgICByZXR1cm47XHJcbiAgICAgICAgfVxyXG4gICAgICAgIG5vZGUuYW5jaG9yWCA9IHRoaXMubm9kZS5hbmNob3JYO1xyXG4gICAgICAgIG5vZGUuYW5jaG9yWSA9IHRoaXMubm9kZS5hbmNob3JZO1xyXG4gICAgICAgIG5vZGUud2lkdGggPSB0aGlzLm5vZGUud2lkdGg7XHJcbiAgICAgICAgbm9kZS5oZWlnaHQgPSB0aGlzLm5vZGUuaGVpZ2h0O1xyXG4gICAgICAgIG5vZGUuZ3JvdXAgPSB0aGlzLm5vZGUuZ3JvdXA7XHJcbiAgICAgICAgbm9kZS5jb2xvciA9IHRoaXMubm9kZS5jb2xvcjtcclxuICAgICAgICBub2RlLm9wYWNpdHkgPSB0aGlzLmdldE9wYWNpdHkodGhpcy5ub2RlKTtcclxuXHJcbiAgICAgICAgbGV0IHdNYXQ0ID0gY2MubWF0NCgpO1xyXG4gICAgICAgIHRoaXMubm9kZS5nZXRXb3JsZE1hdHJpeCh3TWF0NCk7XHJcbiAgICAgICAgaWYgKCF0aGlzLmxhc3RXTWF0NCB8fCAhdGhpcy5sYXN0V01hdDQuZXF1YWxzKHdNYXQ0KSkge1xyXG4gICAgICAgICAgICBsZXQgbG9jYWxNYXRyaXggPSB0aGlzLmdldExvY2FsTWF0cml4KHdNYXQ0LCBub2RlKTtcclxuICAgICAgICAgICAgdGhpcy5zZXRMb2NhbFhZWlNjYWxlQW5nbGUobG9jYWxNYXRyaXgsIG5vZGUsIHRoaXMubGFzdExNYXQ0KTtcclxuICAgICAgICAgICAgdGhpcy5sYXN0V01hdDQgPSB3TWF0NDtcclxuICAgICAgICAgICAgdGhpcy5sYXN0TE1hdDQgPSBsb2NhbE1hdHJpeDtcclxuICAgICAgICB9XHJcbiAgICAgICAgbm9kZS56SW5kZXggPSB0aGlzLnpJbmRleDtcclxuICAgIH1cclxuXHJcbiAgICBwcml2YXRlIGdldExvY2FsTWF0cml4KHdvcmxkTWF0cml4OiBjYy5NYXQ0LCBub2RlOiBjYy5Ob2RlKSB7XHJcbiAgICAgICAgbGV0IHBhcmVudE5vZGUgPSBudWxsO1xyXG4gICAgICAgIGlmIChjYy5pc1ZhbGlkKG5vZGUpKSB7XHJcbiAgICAgICAgICAgIGlmIChjYy5pc1ZhbGlkKG5vZGUucGFyZW50KSkge1xyXG4gICAgICAgICAgICAgICAgcGFyZW50Tm9kZSA9IG5vZGUucGFyZW50XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9XHJcbiAgICAgICAgLy8g6I635Y+W54i26IqC54K555qE5LiW55WM55+p6Zi1XHJcbiAgICAgICAgbGV0IHBhcmVudFdvcmxkTWF0cml4ID0gY2MubWF0NCgpO1xyXG4gICAgICAgIHBhcmVudE5vZGUuZ2V0V29ybGRNYXRyaXgocGFyZW50V29ybGRNYXRyaXgpO1xyXG4gICAgICAgIC8vIOiOt+WPlueItuiKgueCueeahOmAhuefqemYtVxyXG4gICAgICAgIGxldCBwYXJlbnRJbnZlcnNlTWF0cml4ID0gcGFyZW50V29ybGRNYXRyaXguaW52ZXJ0KCk7XHJcbiAgICAgICAgLy8g5bCG55uu5qCH6IqC54K555qE5LiW55WM55+p6Zi16L2s5o2i5Li654i26IqC54K555qE5pys5Zyw55+p6Zi1XHJcbiAgICAgICAgbGV0IGxvY2FsTWF0cml4ID0gcGFyZW50SW52ZXJzZU1hdHJpeC5tdWx0aXBseSh3b3JsZE1hdHJpeCk7XHJcbiAgICAgICAgcmV0dXJuIGxvY2FsTWF0cml4O1xyXG5cclxuICAgIH1cclxuXHJcbiAgICBwcml2YXRlIHNldExvY2FsWFlaU2NhbGVBbmdsZShtYXRyaXg6IGNjLk1hdDQsIG5vZGU6IGNjLk5vZGUsIGxhc3RNYXRyaXg/OiBjYy5NYXQ0KSB7XHJcbiAgICAgICAgaWYgKGxhc3RNYXRyaXggJiYgbWF0cml4LmVxdWFscyhsYXN0TWF0cml4KSkge1xyXG4gICAgICAgICAgICByZXR1cm47XHJcbiAgICAgICAgfVxyXG5cclxuICAgICAgICAvLyDmj5Dlj5bkvY3nva5cclxuICAgICAgICBub2RlLnNldFBvc2l0aW9uKG1hdHJpeC5tWzEyXSwgbWF0cml4Lm1bMTNdLCBtYXRyaXgubVsxNF0pO1xyXG5cclxuICAgICAgICBsZXQgc2NhbGVYID0gbnVsbDtcclxuICAgICAgICBsZXQgc2NhbGVZID0gbnVsbDtcclxuICAgICAgICBsZXQgYW5nbGUgPSBudWxsO1xyXG4gICAgICAgIC8vIOaPkOWPlue8qeaUvlhcclxuICAgICAgICBpZiAoIWxhc3RNYXRyaXgpIHtcclxuICAgICAgICAgICAgc2NhbGVYID0gTWF0aC5zcXJ0KG1hdHJpeC5tWzBdICogbWF0cml4Lm1bMF0gKyBtYXRyaXgubVsxXSAqIG1hdHJpeC5tWzFdICsgbWF0cml4Lm1bMl0gKiBtYXRyaXgubVsyXSk7XHJcbiAgICAgICAgfSBlbHNlIGlmICghdGhpcy5lcXVhbHNWYWx1ZShtYXRyaXgubVswXSwgbGFzdE1hdHJpeC5tWzBdKVxyXG4gICAgICAgICAgICB8fCAhdGhpcy5lcXVhbHNWYWx1ZShtYXRyaXgubVsxXSwgbGFzdE1hdHJpeC5tWzFdKVxyXG4gICAgICAgICAgICB8fCAhdGhpcy5lcXVhbHNWYWx1ZShtYXRyaXgubVsyXSwgbGFzdE1hdHJpeC5tWzJdKSkge1xyXG4gICAgICAgICAgICBzY2FsZVggPSBNYXRoLnNxcnQobWF0cml4Lm1bMF0gKiBtYXRyaXgubVswXSArIG1hdHJpeC5tWzFdICogbWF0cml4Lm1bMV0gKyBtYXRyaXgubVsyXSAqIG1hdHJpeC5tWzJdKTtcclxuICAgICAgICB9XHJcbiAgICAgICAgLy8g5o+Q5Y+W57yp5pS+WVxyXG4gICAgICAgIGlmICghbGFzdE1hdHJpeCkge1xyXG4gICAgICAgICAgICBzY2FsZVkgPSBNYXRoLnNxcnQobWF0cml4Lm1bNF0gKiBtYXRyaXgubVs0XSArIG1hdHJpeC5tWzVdICogbWF0cml4Lm1bNV0gKyBtYXRyaXgubVs2XSAqIG1hdHJpeC5tWzZdKTtcclxuICAgICAgICB9IGVsc2UgaWYgKCF0aGlzLmVxdWFsc1ZhbHVlKG1hdHJpeC5tWzRdLCBsYXN0TWF0cml4Lm1bNF0pXHJcbiAgICAgICAgICAgIHx8ICF0aGlzLmVxdWFsc1ZhbHVlKG1hdHJpeC5tWzVdLCBsYXN0TWF0cml4Lm1bNV0pXHJcbiAgICAgICAgICAgIHx8ICF0aGlzLmVxdWFsc1ZhbHVlKG1hdHJpeC5tWzZdLCBsYXN0TWF0cml4Lm1bNl0pKSB7XHJcbiAgICAgICAgICAgIHNjYWxlWSA9IE1hdGguc3FydChtYXRyaXgubVs0XSAqIG1hdHJpeC5tWzRdICsgbWF0cml4Lm1bNV0gKiBtYXRyaXgubVs1XSArIG1hdHJpeC5tWzZdICogbWF0cml4Lm1bNl0pO1xyXG4gICAgICAgIH1cclxuICAgICAgICAvL+iuvue9rue8qeaUvlhcclxuICAgICAgICBpZiAoc2NhbGVYICE9PSBudWxsKSB7XHJcbiAgICAgICAgICAgIG5vZGUuc2NhbGVYID0gc2NhbGVYO1xyXG4gICAgICAgICAgICAvLyDmj5Dlj5bml4vovaxcclxuICAgICAgICAgICAgYW5nbGUgPSBNYXRoLmF0YW4yKG1hdHJpeC5tWzFdIC8gc2NhbGVYLCBtYXRyaXgubVswXSAvIHNjYWxlWCkgKiAoMTgwIC8gTWF0aC5QSSk7XHJcbiAgICAgICAgfVxyXG4gICAgICAgIGlmIChzY2FsZVkgIT09IG51bGwpIHtcclxuICAgICAgICAgICAgbm9kZS5zY2FsZVkgPSBzY2FsZVk7XHJcbiAgICAgICAgfVxyXG4gICAgICAgIGlmIChhbmdsZSAhPT0gbnVsbCkge1xyXG4gICAgICAgICAgICBub2RlLnJvdGF0aW9uID0gYW5nbGU7XHJcbiAgICAgICAgfVxyXG4gICAgfVxyXG5cclxuICAgIHByaXZhdGUgZXF1YWxzVmFsdWUoYTogbnVtYmVyLCBiOiBudW1iZXIsIGVwc2lsb246IG51bWJlciA9IDAuMDAwMDEpIHtcclxuICAgICAgICByZXR1cm4gTWF0aC5hYnMoYSAtIGIpIDwgZXBzaWxvbjtcclxuICAgIH1cclxuXHJcbiAgICBwcm90ZWN0ZWQgb25EZXN0cm95KCk6IHZvaWQge1xyXG4gICAgICAgIHRoaXMucmVuZGVyQ29tcG5lbnQubm9kZS5kZXN0cm95KCk7XHJcbiAgICAgICAgdGhpcy5yZW5kZXJDb21wbmVudCA9IG51bGw7XHJcbiAgICAgICAgdGhpcy5wcm94eVJlbmRlciA9IG51bGw7XHJcbiAgICB9XHJcblxyXG4gICAgLyoqXHJcbiAgICAgKiDojrflj5boioLngrnpgI/mmI7luqZcclxuICAgICAqIEBwYXJhbSBub2RlIFxyXG4gICAgICovXHJcbiAgICBwcml2YXRlIGdldE9wYWNpdHkobm9kZTogY2MuTm9kZSkge1xyXG4gICAgICAgIGxldCBvcGFjaXR5ID0gKG5vZGUub3BhY2l0eSAvIDI1NSk7XHJcbiAgICAgICAgbGV0IHBhcmVudE5vZGUgPSBub2RlLnBhcmVudFxyXG4gICAgICAgIHdoaWxlIChwYXJlbnROb2RlICE9IHRoaXMucmVuZGVyTGF5ZXIucGFyZW50ICYmIHBhcmVudE5vZGUgIT0gY2MuZGlyZWN0b3IuZ2V0U2NlbmUoKSkge1xyXG4gICAgICAgICAgICBvcGFjaXR5ICo9IChwYXJlbnROb2RlLm9wYWNpdHkgLyAyNTUpO1xyXG4gICAgICAgICAgICBwYXJlbnROb2RlID0gcGFyZW50Tm9kZS5wYXJlbnQ7XHJcbiAgICAgICAgfVxyXG4gICAgICAgIHJldHVybiBvcGFjaXR5ICogMjU1O1xyXG4gICAgfVxyXG4gICAgLyoqXHJcbiAgICAgKiDojrflj5bmuLLmn5Pnu4Tku7ZcclxuICAgICAqIEBwYXJhbSBub2RlIFxyXG4gICAgICovXHJcbiAgICBwcml2YXRlIGdldFJlbmRlcigpIHtcclxuICAgICAgICBsZXQgbm9kZSA9IGNjLmluc3RhbnRpYXRlKHRoaXMubm9kZSk7XHJcbiAgICAgICAgbm9kZS5yZW1vdmVBbGxDaGlsZHJlbigpO1xyXG4gICAgICAgIHRoaXMucmVuZGVyQ29tcG5lbnQgPSBub2RlLmdldENvbXBvbmVudChjYy5SZW5kZXJDb21wb25lbnQpO1xyXG4gICAgICAgIHRoaXMubm9kZS5nZXRDb21wb25lbnQoY2MuTGFiZWxPdXRsaW5lKT8uZGVzdHJveSgpO1xyXG4gICAgICAgIHRoaXMubm9kZS5nZXRDb21wb25lbnQoY2MuTGFiZWxTaGFkb3cpPy5kZXN0cm95KCk7XHJcbiAgICAgICAgdGhpcy5ub2RlLmdldENvbXBvbmVudChjYy5SZW5kZXJDb21wb25lbnQpLmRlc3Ryb3koKTtcclxuICAgICAgICBsZXQgY29tcG9uZW50cyA9IG5vZGUuZ2V0Q29tcG9uZW50cyhjYy5Db21wb25lbnQpO1xyXG4gICAgICAgIGZvciAobGV0IGkgPSAwLCBsZW4gPSBjb21wb25lbnRzLmxlbmd0aDsgaSA8IGxlbjsgKytpKSB7XHJcbiAgICAgICAgICAgIGxldCBjb21wID0gY29tcG9uZW50c1tpXTtcclxuICAgICAgICAgICAgaWYgKCEoKGNvbXAgaW5zdGFuY2VvZiBjYy5SZW5kZXJDb21wb25lbnQpIHx8IChjb21wIGluc3RhbmNlb2YgY2MuTGFiZWxPdXRsaW5lKSB8fCAoY29tcCBpbnN0YW5jZW9mIGNjLkxhYmVsU2hhZG93KSkpIHtcclxuICAgICAgICAgICAgICAgIGNvbXAuZGVzdHJveSgpO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfVxyXG4gICAgICAgIHJldHVybiBub2RlO1xyXG4gICAgfVxyXG5cclxufVxyXG4iXX0= \ No newline at end of file diff --git a/Layered_virtual_list_2.x/temp/quick-scripts/dst/assets/Script/RenderAlternativeItem.js b/Layered_virtual_list_2.x/temp/quick-scripts/dst/assets/Script/RenderAlternativeItem.js new file mode 100644 index 0000000..241e300 --- /dev/null +++ b/Layered_virtual_list_2.x/temp/quick-scripts/dst/assets/Script/RenderAlternativeItem.js @@ -0,0 +1,131 @@ + + (function() { + var nodeEnv = typeof require !== 'undefined' && typeof process !== 'undefined'; + var __module = nodeEnv ? module : {exports:{}}; + var __filename = 'preview-scripts/assets/Script/RenderAlternativeItem.js'; + var __require = nodeEnv ? function (request) { + return cc.require(request); + } : function (request) { + return __quick_compile_project__.require(request, __filename); + }; + function __define (exports, require, module) { + if (!nodeEnv) {__quick_compile_project__.registerModule(__filename, module);}"use strict"; +cc._RF.push(module, 'd33f6MUGOxJN5eMJ9UzS3KH', 'RenderAlternativeItem'); +// Script/RenderAlternativeItem.ts + +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var RenderAlternative_1 = require("./RenderAlternative"); +var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property; +var RenderAlternativeItem = /** @class */ (function (_super) { + __extends(RenderAlternativeItem, _super); + /** + * 渲染分层Item挂载组件 + * 处理渲染分层Item的渲染分层 + */ + function RenderAlternativeItem() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /**是否初始化过代理组建 */ + _this.hasInit = false; + return _this; + } + /**初始化 */ + RenderAlternativeItem.prototype.initRenderLayer = function (renderLayer) { + if (this.renderLayer != renderLayer) { + this.renderLayer = renderLayer; + renderLayer && this.initRenders(); + } + }; + /** + * 处理分层代理渲染 + */ + RenderAlternativeItem.prototype.initRenders = function () { + if (!this.hasInit && this.renderLayer) { + // + var propMap = new WeakMap(); + var keys = Object.keys(this); + for (var i = 0, len = keys.length; i < len; ++i) { + var value = this[keys[i]]; + var alternative = null; + if (value instanceof cc.Node) { + alternative = value.getComponent(RenderAlternative_1.default); + if (alternative) { + alternative.init(this.renderLayer); + } + } + else if (value instanceof cc.RenderComponent) { + alternative = value.getComponent(RenderAlternative_1.default); + if (alternative) { + this[keys[i]] = alternative.init(this.renderLayer); + } + } + alternative && propMap.set(alternative, true); + } + this.dealChilrenAlternative(this.node, propMap, 0, 0); + this.hasInit = true; + } + }; + /** + * 处理子节点代理 + * @param node + * @param propMap 记录脚本已经处理过的属性代理 + * @param parentSindex 父节点的所在的顺序 + * @param depth 深度 + */ + RenderAlternativeItem.prototype.dealChilrenAlternative = function (node, propMap, parentSindex, depth) { + var _a; + for (var i = 0, len = node.children.length; i < len; i++) { + var children = node.children[i]; + var alternative = (_a = children.getComponent(cc.RenderComponent)) === null || _a === void 0 ? void 0 : _a.getComponent(RenderAlternative_1.default); + var sIndex = parentSindex + (i * Math.pow(0.1, depth)); + if (alternative) { + if ((!propMap.has(alternative) || !propMap.get(alternative))) { + alternative.init(this.renderLayer); + } + alternative.sIndex = sIndex; + } + this.dealChilrenAlternative(children, propMap, sIndex, depth + 1); + } + }; + RenderAlternativeItem = __decorate([ + ccclass + /** + * 渲染分层Item挂载组件 + * 处理渲染分层Item的渲染分层 + */ + ], RenderAlternativeItem); + return RenderAlternativeItem; +}(cc.Component)); +exports.default = RenderAlternativeItem; + +cc._RF.pop(); + } + if (nodeEnv) { + __define(__module.exports, __require, __module); + } + else { + __quick_compile_project__.registerModuleFunc(__filename, function () { + __define(__module.exports, __require, __module); + }); + } + })(); +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImFzc2V0c1xcU2NyaXB0XFxSZW5kZXJBbHRlcm5hdGl2ZUl0ZW0udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0FBQUEseURBQW9EO0FBRzlDLElBQUEsS0FBd0IsRUFBRSxDQUFDLFVBQVUsRUFBbkMsT0FBTyxhQUFBLEVBQUUsUUFBUSxjQUFrQixDQUFDO0FBTzVDO0lBQW1ELHlDQUFZO0lBSi9EOzs7T0FHRztJQUNIO1FBQUEscUVBOERDO1FBNURHLGdCQUFnQjtRQUNSLGFBQU8sR0FBWSxLQUFLLENBQUM7O0lBMkRyQyxDQUFDO0lBeERHLFNBQVM7SUFDRiwrQ0FBZSxHQUF0QixVQUF1QixXQUFvQjtRQUN2QyxJQUFJLElBQUksQ0FBQyxXQUFXLElBQUksV0FBVyxFQUFFO1lBQ2pDLElBQUksQ0FBQyxXQUFXLEdBQUcsV0FBVyxDQUFDO1lBQy9CLFdBQVcsSUFBSSxJQUFJLENBQUMsV0FBVyxFQUFFLENBQUM7U0FDckM7SUFDTCxDQUFDO0lBQ0Q7O09BRUc7SUFDSywyQ0FBVyxHQUFuQjtRQUNJLElBQUksQ0FBQyxJQUFJLENBQUMsT0FBTyxJQUFJLElBQUksQ0FBQyxXQUFXLEVBQUU7WUFDbkMsRUFBRTtZQUNGLElBQUksT0FBTyxHQUF3QyxJQUFJLE9BQU8sRUFBRSxDQUFDO1lBQ2pFLElBQUksSUFBSSxHQUFHLE1BQU0sQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLENBQUM7WUFDN0IsS0FBSyxJQUFJLENBQUMsR0FBRyxDQUFDLEVBQUUsR0FBRyxHQUFHLElBQUksQ0FBQyxNQUFNLEVBQUUsQ0FBQyxHQUFHLEdBQUcsRUFBRSxFQUFFLENBQUMsRUFBRTtnQkFDN0MsSUFBSSxLQUFLLEdBQUcsSUFBSSxDQUFDLElBQUksQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDO2dCQUMxQixJQUFJLFdBQVcsR0FBc0IsSUFBSSxDQUFDO2dCQUMxQyxJQUFJLEtBQUssWUFBWSxFQUFFLENBQUMsSUFBSSxFQUFFO29CQUMxQixXQUFXLEdBQUcsS0FBSyxDQUFDLFlBQVksQ0FBQywyQkFBaUIsQ0FBQyxDQUFDO29CQUNwRCxJQUFJLFdBQVcsRUFBRTt3QkFDYixXQUFXLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxXQUFXLENBQUMsQ0FBQztxQkFDdEM7aUJBQ0o7cUJBQU0sSUFBSSxLQUFLLFlBQVksRUFBRSxDQUFDLGVBQWUsRUFBRTtvQkFDNUMsV0FBVyxHQUFHLEtBQUssQ0FBQyxZQUFZLENBQUMsMkJBQWlCLENBQUMsQ0FBQztvQkFDcEQsSUFBSSxXQUFXLEVBQUU7d0JBQ2IsSUFBSSxDQUFDLElBQUksQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLFdBQVcsQ0FBQyxJQUFJLENBQWUsSUFBSSxDQUFDLFdBQVcsQ0FBQyxDQUFDO3FCQUNwRTtpQkFDSjtnQkFDRCxXQUFXLElBQUksT0FBTyxDQUFDLEdBQUcsQ0FBQyxXQUFXLEVBQUUsSUFBSSxDQUFDLENBQUM7YUFDakQ7WUFDRCxJQUFJLENBQUMsc0JBQXNCLENBQUMsSUFBSSxDQUFDLElBQUksRUFBRSxPQUFPLEVBQUUsQ0FBQyxFQUFFLENBQUMsQ0FBQyxDQUFDO1lBQ3RELElBQUksQ0FBQyxPQUFPLEdBQUcsSUFBSSxDQUFDO1NBQ3ZCO0lBQ0wsQ0FBQztJQUNEOzs7Ozs7T0FNRztJQUNILHNEQUFzQixHQUF0QixVQUF1QixJQUFhLEVBQUUsT0FBNEMsRUFBRSxZQUFvQixFQUFFLEtBQWE7O1FBQ25ILEtBQUssSUFBSSxDQUFDLEdBQUcsQ0FBQyxFQUFFLEdBQUcsR0FBRyxJQUFJLENBQUMsUUFBUSxDQUFDLE1BQU0sRUFBRSxDQUFDLEdBQUcsR0FBRyxFQUFFLENBQUMsRUFBRSxFQUFFO1lBQ3RELElBQUksUUFBUSxHQUFHLElBQUksQ0FBQyxRQUFRLENBQUMsQ0FBQyxDQUFDLENBQUM7WUFDaEMsSUFBSSxXQUFXLFNBQUcsUUFBUSxDQUFDLFlBQVksQ0FBQyxFQUFFLENBQUMsZUFBZSxDQUFDLDBDQUFFLFlBQVksQ0FBQywyQkFBaUIsQ0FBQyxDQUFDO1lBQzdGLElBQUksTUFBTSxHQUFHLFlBQVksR0FBRyxDQUFDLENBQUMsR0FBRyxJQUFJLENBQUMsR0FBRyxDQUFDLEdBQUcsRUFBRSxLQUFLLENBQUMsQ0FBQyxDQUFDO1lBQ3ZELElBQUksV0FBVyxFQUFFO2dCQUNiLElBQUksQ0FBQyxDQUFDLE9BQU8sQ0FBQyxHQUFHLENBQUMsV0FBVyxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUMsR0FBRyxDQUFDLFdBQVcsQ0FBQyxDQUFDLEVBQUU7b0JBQzFELFdBQVcsQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLFdBQVcsQ0FBQyxDQUFDO2lCQUN0QztnQkFDRCxXQUFXLENBQUMsTUFBTSxHQUFHLE1BQU0sQ0FBQzthQUMvQjtZQUNELElBQUksQ0FBQyxzQkFBc0IsQ0FBQyxRQUFRLEVBQUUsT0FBTyxFQUFFLE1BQU0sRUFBRSxLQUFLLEdBQUcsQ0FBQyxDQUFDLENBQUM7U0FDckU7SUFDTCxDQUFDO0lBN0RnQixxQkFBcUI7UUFMekMsT0FBTztRQUNSOzs7V0FHRztPQUNrQixxQkFBcUIsQ0E4RHpDO0lBQUQsNEJBQUM7Q0E5REQsQUE4REMsQ0E5RGtELEVBQUUsQ0FBQyxTQUFTLEdBOEQ5RDtrQkE5RG9CLHFCQUFxQiIsImZpbGUiOiIiLCJzb3VyY2VSb290IjoiLyIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCBSZW5kZXJBbHRlcm5hdGl2ZSBmcm9tIFwiLi9SZW5kZXJBbHRlcm5hdGl2ZVwiO1xyXG5cclxuXHJcbmNvbnN0IHsgY2NjbGFzcywgcHJvcGVydHkgfSA9IGNjLl9kZWNvcmF0b3I7XHJcblxyXG5AY2NjbGFzc1xyXG4vKipcclxuICog5riy5p+T5YiG5bGCSXRlbeaMgui9vee7hOS7tlxyXG4gKiDlpITnkIbmuLLmn5PliIblsYJJdGVt55qE5riy5p+T5YiG5bGCXHJcbiAqL1xyXG5leHBvcnQgZGVmYXVsdCBjbGFzcyBSZW5kZXJBbHRlcm5hdGl2ZUl0ZW0gZXh0ZW5kcyBjYy5Db21wb25lbnQge1xyXG5cclxuICAgIC8qKuaYr+WQpuWIneWni+WMlui/h+S7o+eQhue7hOW7uiAqL1xyXG4gICAgcHJpdmF0ZSBoYXNJbml0OiBib29sZWFuID0gZmFsc2U7XHJcbiAgICAvKirmuLLmn5PliIblsYLlvIDlkK/nmoTmjILovb3oioLngrkgKi9cclxuICAgIHB1YmxpYyByZW5kZXJMYXllcjogY2MuTm9kZTtcclxuICAgIC8qKuWIneWni+WMliAqL1xyXG4gICAgcHVibGljIGluaXRSZW5kZXJMYXllcihyZW5kZXJMYXllcjogY2MuTm9kZSkge1xyXG4gICAgICAgIGlmICh0aGlzLnJlbmRlckxheWVyICE9IHJlbmRlckxheWVyKSB7XHJcbiAgICAgICAgICAgIHRoaXMucmVuZGVyTGF5ZXIgPSByZW5kZXJMYXllcjtcclxuICAgICAgICAgICAgcmVuZGVyTGF5ZXIgJiYgdGhpcy5pbml0UmVuZGVycygpO1xyXG4gICAgICAgIH1cclxuICAgIH1cclxuICAgIC8qKlxyXG4gICAgICog5aSE55CG5YiG5bGC5Luj55CG5riy5p+TXHJcbiAgICAgKi9cclxuICAgIHByaXZhdGUgaW5pdFJlbmRlcnMoKSB7XHJcbiAgICAgICAgaWYgKCF0aGlzLmhhc0luaXQgJiYgdGhpcy5yZW5kZXJMYXllcikge1xyXG4gICAgICAgICAgICAvL1xyXG4gICAgICAgICAgICBsZXQgcHJvcE1hcDogV2Vha01hcDxSZW5kZXJBbHRlcm5hdGl2ZSwgYm9vbGVhbj4gPSBuZXcgV2Vha01hcCgpO1xyXG4gICAgICAgICAgICBsZXQga2V5cyA9IE9iamVjdC5rZXlzKHRoaXMpO1xyXG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgbGVuID0ga2V5cy5sZW5ndGg7IGkgPCBsZW47ICsraSkge1xyXG4gICAgICAgICAgICAgICAgbGV0IHZhbHVlID0gdGhpc1trZXlzW2ldXTtcclxuICAgICAgICAgICAgICAgIGxldCBhbHRlcm5hdGl2ZTogUmVuZGVyQWx0ZXJuYXRpdmUgPSBudWxsO1xyXG4gICAgICAgICAgICAgICAgaWYgKHZhbHVlIGluc3RhbmNlb2YgY2MuTm9kZSkge1xyXG4gICAgICAgICAgICAgICAgICAgIGFsdGVybmF0aXZlID0gdmFsdWUuZ2V0Q29tcG9uZW50KFJlbmRlckFsdGVybmF0aXZlKTtcclxuICAgICAgICAgICAgICAgICAgICBpZiAoYWx0ZXJuYXRpdmUpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgYWx0ZXJuYXRpdmUuaW5pdCh0aGlzLnJlbmRlckxheWVyKTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHZhbHVlIGluc3RhbmNlb2YgY2MuUmVuZGVyQ29tcG9uZW50KSB7XHJcbiAgICAgICAgICAgICAgICAgICAgYWx0ZXJuYXRpdmUgPSB2YWx1ZS5nZXRDb21wb25lbnQoUmVuZGVyQWx0ZXJuYXRpdmUpO1xyXG4gICAgICAgICAgICAgICAgICAgIGlmIChhbHRlcm5hdGl2ZSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzW2tleXNbaV1dID0gYWx0ZXJuYXRpdmUuaW5pdDx0eXBlb2YgdmFsdWU+KHRoaXMucmVuZGVyTGF5ZXIpO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIGFsdGVybmF0aXZlICYmIHByb3BNYXAuc2V0KGFsdGVybmF0aXZlLCB0cnVlKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB0aGlzLmRlYWxDaGlscmVuQWx0ZXJuYXRpdmUodGhpcy5ub2RlLCBwcm9wTWFwLCAwLCAwKTtcclxuICAgICAgICAgICAgdGhpcy5oYXNJbml0ID0gdHJ1ZTtcclxuICAgICAgICB9XHJcbiAgICB9XHJcbiAgICAvKipcclxuICAgICAqIOWkhOeQhuWtkOiKgueCueS7o+eQhlxyXG4gICAgICogQHBhcmFtIG5vZGUgXHJcbiAgICAgKiBAcGFyYW0gcHJvcE1hcCDorrDlvZXohJrmnKzlt7Lnu4/lpITnkIbov4fnmoTlsZ7mgKfku6PnkIZcclxuICAgICAqIEBwYXJhbSBwYXJlbnRTaW5kZXgg54i26IqC54K555qE5omA5Zyo55qE6aG65bqPXHJcbiAgICAgKiBAcGFyYW0gZGVwdGgg5rex5bqmXHJcbiAgICAgKi9cclxuICAgIGRlYWxDaGlscmVuQWx0ZXJuYXRpdmUobm9kZTogY2MuTm9kZSwgcHJvcE1hcDogV2Vha01hcDxSZW5kZXJBbHRlcm5hdGl2ZSwgYm9vbGVhbj4sIHBhcmVudFNpbmRleDogbnVtYmVyLCBkZXB0aDogbnVtYmVyKSB7XHJcbiAgICAgICAgZm9yIChsZXQgaSA9IDAsIGxlbiA9IG5vZGUuY2hpbGRyZW4ubGVuZ3RoOyBpIDwgbGVuOyBpKyspIHtcclxuICAgICAgICAgICAgbGV0IGNoaWxkcmVuID0gbm9kZS5jaGlsZHJlbltpXTtcclxuICAgICAgICAgICAgbGV0IGFsdGVybmF0aXZlID0gY2hpbGRyZW4uZ2V0Q29tcG9uZW50KGNjLlJlbmRlckNvbXBvbmVudCk/LmdldENvbXBvbmVudChSZW5kZXJBbHRlcm5hdGl2ZSk7XHJcbiAgICAgICAgICAgIGxldCBzSW5kZXggPSBwYXJlbnRTaW5kZXggKyAoaSAqIE1hdGgucG93KDAuMSwgZGVwdGgpKTtcclxuICAgICAgICAgICAgaWYgKGFsdGVybmF0aXZlKSB7XHJcbiAgICAgICAgICAgICAgICBpZiAoKCFwcm9wTWFwLmhhcyhhbHRlcm5hdGl2ZSkgfHwgIXByb3BNYXAuZ2V0KGFsdGVybmF0aXZlKSkpIHtcclxuICAgICAgICAgICAgICAgICAgICBhbHRlcm5hdGl2ZS5pbml0KHRoaXMucmVuZGVyTGF5ZXIpO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgYWx0ZXJuYXRpdmUuc0luZGV4ID0gc0luZGV4O1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIHRoaXMuZGVhbENoaWxyZW5BbHRlcm5hdGl2ZShjaGlsZHJlbiwgcHJvcE1hcCwgc0luZGV4LCBkZXB0aCArIDEpO1xyXG4gICAgICAgIH1cclxuICAgIH1cclxufVxyXG4iXX0= \ No newline at end of file diff --git a/Layered_virtual_list_2.x/temp/quick-scripts/dst/assets/Script/RenderAlternative_old.js b/Layered_virtual_list_2.x/temp/quick-scripts/dst/assets/Script/RenderAlternative_old.js new file mode 100644 index 0000000..fad4d6d --- /dev/null +++ b/Layered_virtual_list_2.x/temp/quick-scripts/dst/assets/Script/RenderAlternative_old.js @@ -0,0 +1,276 @@ + + (function() { + var nodeEnv = typeof require !== 'undefined' && typeof process !== 'undefined'; + var __module = nodeEnv ? module : {exports:{}}; + var __filename = 'preview-scripts/assets/Script/RenderAlternative_old.js'; + var __require = nodeEnv ? function (request) { + return cc.require(request); + } : function (request) { + return __quick_compile_project__.require(request, __filename); + }; + function __define (exports, require, module) { + if (!nodeEnv) {__quick_compile_project__.registerModule(__filename, module);}"use strict"; +cc._RF.push(module, '1b478Wr4HlMhLdWnJWcD6fi', 'RenderAlternative_old'); +// Script/RenderAlternative_old.ts + +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var RenderReactiveHandler_1 = require("./RenderReactiveHandler"); +/** + * 目前该渲染代理功能存在的问题 + * 1.被代理节点的父级不能出现scaleX和scaleY不一致的情况,被代理节点本身没有这个限制 + */ +var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property; +var RenderAlternative = /** @class */ (function (_super) { + __extends(RenderAlternative, _super); + function RenderAlternative() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /**渲染层节点 */ + _this.renderLayer = null; + /**渲染的zIndex 动态调整zIndex,用于方便临近合批 */ + _this.renderZIndex = 0; + /**同步的间隔(帧为单位) */ + _this.syncInv = 0.01; + /**渲染的sIndex */ + _this.sIndex = 0; + /**非渲染组件 */ + _this.proxyRender = null; + /**渲染组件 */ + _this.renderCompnent = null; + /**上次更新的数据 */ + _this.lastWMat4 = null; + /**上次更新的数据 */ + _this.lastLMat4 = null; + /**上次更新的数据 */ + _this.lastPos = null; + /**距离下次刷新累计了多少间隔 */ + _this.accuTime = 0; + /**最后一次刷新时间 */ + _this.lastFrameTime = null; + /**是否进行刷新 */ + _this.isAttachFrame = false; + return _this; + } + RenderAlternative_1 = RenderAlternative; + Object.defineProperty(RenderAlternative.prototype, "zIndex", { + /**获取总的ZIndex */ + get: function () { + var zIndex = this.renderZIndex + (this.sIndex * 0.01); + var parentNode = this.node.parent; + while (parentNode != this.renderLayer.parent && parentNode != cc.director.getScene()) { + var render = parentNode.getComponent(RenderAlternative_1); + if (render) { + zIndex += render.zIndex + 1; + break; + } + parentNode = parentNode.parent; + } + return zIndex; + }, + enumerable: false, + configurable: true + }); + /** + * 设置渲染节点层 + * @param layer + */ + RenderAlternative.prototype.init = function (layer) { + if (layer) { + this.renderLayer = layer; + } + if (!this.renderLayer) { + console.warn("\u8282\u70B9" + this.node.name + "\u6CA1\u6709\u8BBE\u7F6E\u6E32\u67D3\u5C42"); + return null; + } + return this.initRender(); + }; + /** + * 初始化渲染节点 + */ + RenderAlternative.prototype.initRender = function () { + var node = this.getRender(); + node.setParent(this.renderLayer ? this.renderLayer : cc.director.getScene().getChildByName("Canvas")); + this.isAttachFrame = true; + requestAnimationFrame(this.frameUpdate.bind(this)); + return this.doProxy(); + }; + /**生成代理 */ + RenderAlternative.prototype.doProxy = function () { + this.proxyRender = new Proxy(this.renderCompnent, new RenderReactiveHandler_1.RenderReactiveHandler()); + return this.proxyRender; + }; + RenderAlternative.prototype.frameUpdate = function () { + var now = cc.sys.now(); + !this.lastFrameTime && (this.lastFrameTime = now); + var dt = now - this.lastFrameTime; + if (this.proxyRender) { + this.accuTime += dt; + if (this.accuTime >= this.syncInv) { + this.accuTime -= this.syncInv; + this.updateProp(); + } + } + if (this.isAttachFrame) { + requestAnimationFrame(this.frameUpdate.bind(this)); + } + }; + /**更新最新状态 */ + RenderAlternative.prototype.updateProp = function () { + var node = this.renderCompnent.node; + if (!this.node.activeInHierarchy) { + node.opacity = 0; + return; + } + node.anchorX = this.node.anchorX; + node.anchorY = this.node.anchorY; + node.width = this.node.width; + node.height = this.node.height; + node.group = this.node.group; + node.color = this.node.color; + node.opacity = this.getOpacity(this.node); + var wMat4 = cc.mat4(); + this.node.getWorldMatrix(wMat4); + /* let lMat4 = cc.mat4(); + this.node.getLocalMatrix(wMat4); */ + //此处本可以过滤许多不必要的更新,但尚未排查出问题 + if (true /* || !this.lastWMat4?.equals(wMat4) || !this.lastLMat4?.equals(lMat4) */) { + this.onAngleChange(wMat4); + this.onScaleChange(wMat4); + this.onPosChange(); + /* this.lastLMat4 = lMat4; + this.lastWMat4 = wMat4; */ + } + node.zIndex = this.zIndex; + node.zIndex = this.zIndex; + }; + RenderAlternative.prototype.onDestroy = function () { + this.renderCompnent.node.destroy(); + this.renderCompnent = null; + this.proxyRender = null; + }; + /** + * 获取节点透明度 + * @param node + */ + RenderAlternative.prototype.getOpacity = function (node) { + var opacity = (node.opacity / 255); + var parentNode = node.parent; + while (parentNode != this.renderLayer.parent && parentNode != cc.director.getScene()) { + opacity *= (parentNode.opacity / 255); + parentNode = parentNode.parent; + } + return opacity * 255; + }; + /**位置变化处理 */ + RenderAlternative.prototype.onPosChange = function () { + var wpos = this.node.parent.convertToWorldSpaceAR(this.node.position); + this.renderCompnent.node.position = this.renderLayer.convertToNodeSpaceAR(wpos); + }; + /**旋转变化处理 */ + RenderAlternative.prototype.onAngleChange = function (mat4) { + this.renderCompnent.node.angle = this.extractRotationAngleFromMat4(mat4); + }; + /** + * 从 cc.Mat4 中获取旋转角度(不受缩放影响) + * @param matrix 输入的 cc.Mat4 矩阵 + * @returns 旋转角度(以度为单位) + */ + RenderAlternative.prototype.extractRotationAngleFromMat4 = function (matrix) { + // 提取旋转部分 + var scaleX = Math.sqrt(matrix.m[0] * matrix.m[0] + matrix.m[4] * matrix.m[4] + matrix.m[8] * matrix.m[8]); + var scaleY = Math.sqrt(matrix.m[1] * matrix.m[1] + matrix.m[5] * matrix.m[5] + matrix.m[9] * matrix.m[9]); + // 计算 Z 轴旋转角度(绕 Z 轴的旋转角度) + var angle = Math.atan2(matrix.m[1] / scaleY, matrix.m[0] / scaleX); + // 将弧度转换为角度 + var degrees = angle * (180 / Math.PI); + return degrees; + }; + /** + * 缩放变化处理 + * @param mat4 + */ + RenderAlternative.prototype.onScaleChange = function (mat4) { + var scale = this.extractScaleFromMat4(mat4); + this.renderCompnent.node.scaleX = scale.x; + this.renderCompnent.node.scaleY = scale.y; + this.renderCompnent.node.scaleZ = scale.z; + }; + /** + * 从mat4中获取缩放值 + * @param mat4 + * @returns + */ + RenderAlternative.prototype.extractScaleFromMat4 = function (mat4) { + var scaleX = cc.v3(mat4.m[0], mat4.m[1], mat4.m[2]).mag(); + var scaleY = cc.v3(mat4.m[4], mat4.m[5], mat4.m[6]).mag(); + var scaleZ = cc.v3(mat4.m[8], mat4.m[9], mat4.m[10]).mag(); + return cc.v3(scaleX, scaleY, scaleZ); + }; + /** + * 获取渲染组件 + * @param node + */ + RenderAlternative.prototype.getRender = function () { + var _a, _b; + var node = cc.instantiate(this.node); + node.removeAllChildren(); + this.renderCompnent = node.getComponent(cc.RenderComponent); + (_a = this.node.getComponent(cc.LabelOutline)) === null || _a === void 0 ? void 0 : _a.destroy(); + (_b = this.node.getComponent(cc.LabelShadow)) === null || _b === void 0 ? void 0 : _b.destroy(); + this.node.getComponent(cc.RenderComponent).destroy(); + var components = node.getComponents(cc.Component); + for (var i = 0, len = components.length; i < len; ++i) { + var comp = components[i]; + if (!((comp instanceof cc.RenderComponent) || (comp instanceof cc.LabelOutline) || (comp instanceof cc.LabelShadow))) { + comp.destroy(); + } + } + return node; + }; + var RenderAlternative_1; + __decorate([ + property + ], RenderAlternative.prototype, "renderZIndex", void 0); + __decorate([ + property({ + tooltip: '设置同步的间隔(秒为单位),0就是每帧都同步,0.1就是隔0.1秒同步一次' + }) + ], RenderAlternative.prototype, "syncInv", void 0); + RenderAlternative = RenderAlternative_1 = __decorate([ + ccclass + ], RenderAlternative); + return RenderAlternative; +}(cc.Component)); +exports.default = RenderAlternative; + +cc._RF.pop(); + } + if (nodeEnv) { + __define(__module.exports, __require, __module); + } + else { + __quick_compile_project__.registerModuleFunc(__filename, function () { + __define(__module.exports, __require, __module); + }); + } + })(); +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImFzc2V0c1xcU2NyaXB0XFxSZW5kZXJBbHRlcm5hdGl2ZV9vbGQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0FBQUEsaUVBQWdFO0FBRWhFOzs7R0FHRztBQUNHLElBQUEsS0FBd0IsRUFBRSxDQUFDLFVBQVUsRUFBbkMsT0FBTyxhQUFBLEVBQUUsUUFBUSxjQUFrQixDQUFDO0FBRTVDO0lBQStDLHFDQUFZO0lBQTNEO1FBQUEscUVBa05DO1FBak5HLFdBQVc7UUFDSixpQkFBVyxHQUFZLElBQUksQ0FBQztRQUNuQyxtQ0FBbUM7UUFFNUIsa0JBQVksR0FBVyxDQUFDLENBQUM7UUFDaEMsaUJBQWlCO1FBSVYsYUFBTyxHQUFXLElBQUksQ0FBQztRQUM5QixlQUFlO1FBQ1IsWUFBTSxHQUFXLENBQUMsQ0FBQztRQUMxQixXQUFXO1FBQ0osaUJBQVcsR0FBdUIsSUFBSSxDQUFDO1FBQzlDLFVBQVU7UUFDRixvQkFBYyxHQUF1QixJQUFJLENBQUM7UUFDbEQsYUFBYTtRQUNOLGVBQVMsR0FBWSxJQUFJLENBQUM7UUFDakMsYUFBYTtRQUNOLGVBQVMsR0FBWSxJQUFJLENBQUM7UUFDakMsYUFBYTtRQUNOLGFBQU8sR0FBWSxJQUFJLENBQUM7UUFDL0IsbUJBQW1CO1FBQ1osY0FBUSxHQUFXLENBQUMsQ0FBQztRQUM1QixjQUFjO1FBQ1AsbUJBQWEsR0FBVyxJQUFJLENBQUM7UUFDcEMsWUFBWTtRQUNMLG1CQUFhLEdBQVksS0FBSyxDQUFDOztJQXNMMUMsQ0FBQzswQkFsTm9CLGlCQUFpQjtJQStCbEMsc0JBQUkscUNBQU07UUFEVixnQkFBZ0I7YUFDaEI7WUFDSSxJQUFJLE1BQU0sR0FBRyxJQUFJLENBQUMsWUFBWSxHQUFHLENBQUMsSUFBSSxDQUFDLE1BQU0sR0FBRyxJQUFJLENBQUMsQ0FBQztZQUN0RCxJQUFJLFVBQVUsR0FBRyxJQUFJLENBQUMsSUFBSSxDQUFDLE1BQU0sQ0FBQztZQUNsQyxPQUFPLFVBQVUsSUFBSSxJQUFJLENBQUMsV0FBVyxDQUFDLE1BQU0sSUFBSSxVQUFVLElBQUksRUFBRSxDQUFDLFFBQVEsQ0FBQyxRQUFRLEVBQUUsRUFBRTtnQkFDbEYsSUFBSSxNQUFNLEdBQUcsVUFBVSxDQUFDLFlBQVksQ0FBQyxtQkFBaUIsQ0FBQyxDQUFDO2dCQUN4RCxJQUFJLE1BQU0sRUFBRTtvQkFDUixNQUFNLElBQUksTUFBTSxDQUFDLE1BQU0sR0FBRyxDQUFDLENBQUM7b0JBQzVCLE1BQU07aUJBQ1Q7Z0JBQ0QsVUFBVSxHQUFHLFVBQVUsQ0FBQyxNQUFNLENBQUM7YUFDbEM7WUFDRCxPQUFPLE1BQU0sQ0FBQztRQUNsQixDQUFDOzs7T0FBQTtJQUVEOzs7T0FHRztJQUNILGdDQUFJLEdBQUosVUFBbUMsS0FBZTtRQUM5QyxJQUFJLEtBQUssRUFBRTtZQUNQLElBQUksQ0FBQyxXQUFXLEdBQUcsS0FBSyxDQUFDO1NBQzVCO1FBQ0QsSUFBSSxDQUFDLElBQUksQ0FBQyxXQUFXLEVBQUU7WUFDbkIsT0FBTyxDQUFDLElBQUksQ0FBQyxpQkFBSyxJQUFJLENBQUMsSUFBSSxDQUFDLElBQUksK0NBQVMsQ0FBQyxDQUFBO1lBQzFDLE9BQU8sSUFBSSxDQUFDO1NBQ2Y7UUFDRCxPQUFPLElBQUksQ0FBQyxVQUFVLEVBQUssQ0FBQztJQUNoQyxDQUFDO0lBQ0Q7O09BRUc7SUFDSyxzQ0FBVSxHQUFsQjtRQUNJLElBQUksSUFBSSxHQUFHLElBQUksQ0FBQyxTQUFTLEVBQUUsQ0FBQztRQUM1QixJQUFJLENBQUMsU0FBUyxDQUFDLElBQUksQ0FBQyxXQUFXLENBQUMsQ0FBQyxDQUFDLElBQUksQ0FBQyxXQUFXLENBQUMsQ0FBQyxDQUFDLEVBQUUsQ0FBQyxRQUFRLENBQUMsUUFBUSxFQUFFLENBQUMsY0FBYyxDQUFDLFFBQVEsQ0FBQyxDQUFDLENBQUM7UUFDdEcsSUFBSSxDQUFDLGFBQWEsR0FBRyxJQUFJLENBQUM7UUFDMUIscUJBQXFCLENBQUMsSUFBSSxDQUFDLFdBQVcsQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLENBQUMsQ0FBQztRQUNuRCxPQUFPLElBQUksQ0FBQyxPQUFPLEVBQUssQ0FBQztJQUM3QixDQUFDO0lBQ0QsVUFBVTtJQUNGLG1DQUFPLEdBQWY7UUFDSSxJQUFJLENBQUMsV0FBVyxHQUFHLElBQUksS0FBSyxDQUFDLElBQUksQ0FBQyxjQUFjLEVBQUUsSUFBSSw2Q0FBcUIsRUFBRSxDQUFNLENBQUM7UUFDcEYsT0FBTyxJQUFJLENBQUMsV0FBZ0IsQ0FBQztJQUNqQyxDQUFDO0lBR1MsdUNBQVcsR0FBckI7UUFDSSxJQUFJLEdBQUcsR0FBRyxFQUFFLENBQUMsR0FBRyxDQUFDLEdBQUcsRUFBRSxDQUFDO1FBQ3ZCLENBQUMsSUFBSSxDQUFDLGFBQWEsSUFBSSxDQUFDLElBQUksQ0FBQyxhQUFhLEdBQUcsR0FBRyxDQUFDLENBQUM7UUFDbEQsSUFBSSxFQUFFLEdBQUcsR0FBRyxHQUFHLElBQUksQ0FBQyxhQUFhLENBQUM7UUFDbEMsSUFBSSxJQUFJLENBQUMsV0FBVyxFQUFFO1lBQ2xCLElBQUksQ0FBQyxRQUFRLElBQUksRUFBRSxDQUFDO1lBQ3BCLElBQUksSUFBSSxDQUFDLFFBQVEsSUFBSSxJQUFJLENBQUMsT0FBTyxFQUFFO2dCQUMvQixJQUFJLENBQUMsUUFBUSxJQUFJLElBQUksQ0FBQyxPQUFPLENBQUM7Z0JBQzlCLElBQUksQ0FBQyxVQUFVLEVBQUUsQ0FBQzthQUNyQjtTQUNKO1FBQ0QsSUFBSSxJQUFJLENBQUMsYUFBYSxFQUFFO1lBQ3BCLHFCQUFxQixDQUFDLElBQUksQ0FBQyxXQUFXLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxDQUFDLENBQUM7U0FDdEQ7SUFDTCxDQUFDO0lBRUQsWUFBWTtJQUNMLHNDQUFVLEdBQWpCO1FBQ0ksSUFBSSxJQUFJLEdBQUcsSUFBSSxDQUFDLGNBQWMsQ0FBQyxJQUFJLENBQUM7UUFDcEMsSUFBSSxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsaUJBQWlCLEVBQUU7WUFDOUIsSUFBSSxDQUFDLE9BQU8sR0FBRyxDQUFDLENBQUM7WUFDakIsT0FBTztTQUNWO1FBQ0QsSUFBSSxDQUFDLE9BQU8sR0FBRyxJQUFJLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQztRQUNqQyxJQUFJLENBQUMsT0FBTyxHQUFHLElBQUksQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDO1FBQ2pDLElBQUksQ0FBQyxLQUFLLEdBQUcsSUFBSSxDQUFDLElBQUksQ0FBQyxLQUFLLENBQUM7UUFDN0IsSUFBSSxDQUFDLE1BQU0sR0FBRyxJQUFJLENBQUMsSUFBSSxDQUFDLE1BQU0sQ0FBQztRQUMvQixJQUFJLENBQUMsS0FBSyxHQUFHLElBQUksQ0FBQyxJQUFJLENBQUMsS0FBSyxDQUFDO1FBQzdCLElBQUksQ0FBQyxLQUFLLEdBQUcsSUFBSSxDQUFDLElBQUksQ0FBQyxLQUFLLENBQUM7UUFDN0IsSUFBSSxDQUFDLE9BQU8sR0FBRyxJQUFJLENBQUMsVUFBVSxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsQ0FBQztRQUUxQyxJQUFJLEtBQUssR0FBRyxFQUFFLENBQUMsSUFBSSxFQUFFLENBQUM7UUFDdEIsSUFBSSxDQUFDLElBQUksQ0FBQyxjQUFjLENBQUMsS0FBSyxDQUFDLENBQUM7UUFDaEM7MkNBQ21DO1FBQ25DLDBCQUEwQjtRQUMxQixJQUFJLElBQUksQ0FBQyx5RUFBeUUsRUFBRTtZQUNoRixJQUFJLENBQUMsYUFBYSxDQUFDLEtBQUssQ0FBQyxDQUFDO1lBQzFCLElBQUksQ0FBQyxhQUFhLENBQUMsS0FBSyxDQUFDLENBQUM7WUFDMUIsSUFBSSxDQUFDLFdBQVcsRUFBRSxDQUFDO1lBQ25CO3VDQUMyQjtTQUM5QjtRQUNELElBQUksQ0FBQyxNQUFNLEdBQUcsSUFBSSxDQUFDLE1BQU0sQ0FBQztRQUMxQixJQUFJLENBQUMsTUFBTSxHQUFHLElBQUksQ0FBQyxNQUFNLENBQUM7SUFDOUIsQ0FBQztJQUVTLHFDQUFTLEdBQW5CO1FBQ0ksSUFBSSxDQUFDLGNBQWMsQ0FBQyxJQUFJLENBQUMsT0FBTyxFQUFFLENBQUM7UUFDbkMsSUFBSSxDQUFDLGNBQWMsR0FBRyxJQUFJLENBQUM7UUFDM0IsSUFBSSxDQUFDLFdBQVcsR0FBRyxJQUFJLENBQUM7SUFDNUIsQ0FBQztJQUVEOzs7T0FHRztJQUNLLHNDQUFVLEdBQWxCLFVBQW1CLElBQWE7UUFDNUIsSUFBSSxPQUFPLEdBQUcsQ0FBQyxJQUFJLENBQUMsT0FBTyxHQUFHLEdBQUcsQ0FBQyxDQUFDO1FBQ25DLElBQUksVUFBVSxHQUFHLElBQUksQ0FBQyxNQUFNLENBQUE7UUFDNUIsT0FBTyxVQUFVLElBQUksSUFBSSxDQUFDLFdBQVcsQ0FBQyxNQUFNLElBQUksVUFBVSxJQUFJLEVBQUUsQ0FBQyxRQUFRLENBQUMsUUFBUSxFQUFFLEVBQUU7WUFDbEYsT0FBTyxJQUFJLENBQUMsVUFBVSxDQUFDLE9BQU8sR0FBRyxHQUFHLENBQUMsQ0FBQztZQUN0QyxVQUFVLEdBQUcsVUFBVSxDQUFDLE1BQU0sQ0FBQztTQUNsQztRQUNELE9BQU8sT0FBTyxHQUFHLEdBQUcsQ0FBQztJQUN6QixDQUFDO0lBQ0QsWUFBWTtJQUNKLHVDQUFXLEdBQW5CO1FBQ0ksSUFBSSxJQUFJLEdBQUcsSUFBSSxDQUFDLElBQUksQ0FBQyxNQUFNLENBQUMscUJBQXFCLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxRQUFRLENBQUMsQ0FBQztRQUN0RSxJQUFJLENBQUMsY0FBYyxDQUFDLElBQUksQ0FBQyxRQUFRLEdBQUcsSUFBSSxDQUFDLFdBQVcsQ0FBQyxvQkFBb0IsQ0FBQyxJQUFJLENBQUMsQ0FBQztJQUNwRixDQUFDO0lBQ0QsWUFBWTtJQUNKLHlDQUFhLEdBQXJCLFVBQXNCLElBQWE7UUFDL0IsSUFBSSxDQUFDLGNBQWMsQ0FBQyxJQUFJLENBQUMsS0FBSyxHQUFHLElBQUksQ0FBQyw0QkFBNEIsQ0FBQyxJQUFJLENBQUMsQ0FBQztJQUM3RSxDQUFDO0lBQ0Q7Ozs7T0FJRztJQUNLLHdEQUE0QixHQUFwQyxVQUFxQyxNQUFlO1FBQ2hELFNBQVM7UUFDVCxJQUFJLE1BQU0sR0FBRyxJQUFJLENBQUMsSUFBSSxDQUFDLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUM7UUFDMUcsSUFBSSxNQUFNLEdBQUcsSUFBSSxDQUFDLElBQUksQ0FBQyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDO1FBRTFHLHlCQUF5QjtRQUN6QixJQUFJLEtBQUssR0FBRyxJQUFJLENBQUMsS0FBSyxDQUFDLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsTUFBTSxFQUFFLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsTUFBTSxDQUFDLENBQUM7UUFFbkUsV0FBVztRQUNYLElBQUksT0FBTyxHQUFHLEtBQUssR0FBRyxDQUFDLEdBQUcsR0FBRyxJQUFJLENBQUMsRUFBRSxDQUFDLENBQUM7UUFDdEMsT0FBTyxPQUFPLENBQUM7SUFDbkIsQ0FBQztJQUNEOzs7T0FHRztJQUNLLHlDQUFhLEdBQXJCLFVBQXNCLElBQWE7UUFDL0IsSUFBSSxLQUFLLEdBQUcsSUFBSSxDQUFDLG9CQUFvQixDQUFDLElBQUksQ0FBQyxDQUFBO1FBQzNDLElBQUksQ0FBQyxjQUFjLENBQUMsSUFBSSxDQUFDLE1BQU0sR0FBRyxLQUFLLENBQUMsQ0FBQyxDQUFDO1FBQzFDLElBQUksQ0FBQyxjQUFjLENBQUMsSUFBSSxDQUFDLE1BQU0sR0FBRyxLQUFLLENBQUMsQ0FBQyxDQUFDO1FBQzFDLElBQUksQ0FBQyxjQUFjLENBQUMsSUFBSSxDQUFDLE1BQU0sR0FBRyxLQUFLLENBQUMsQ0FBQyxDQUFDO0lBQzlDLENBQUM7SUFDRDs7OztPQUlHO0lBQ0ssZ0RBQW9CLEdBQTVCLFVBQTZCLElBQWE7UUFDdEMsSUFBSSxNQUFNLEdBQUcsRUFBRSxDQUFDLEVBQUUsQ0FBQyxJQUFJLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxFQUFFLElBQUksQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEVBQUUsSUFBSSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsRUFBRSxDQUFDO1FBQzFELElBQUksTUFBTSxHQUFHLEVBQUUsQ0FBQyxFQUFFLENBQUMsSUFBSSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsRUFBRSxJQUFJLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxFQUFFLElBQUksQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLEVBQUUsQ0FBQztRQUMxRCxJQUFJLE1BQU0sR0FBRyxFQUFFLENBQUMsRUFBRSxDQUFDLElBQUksQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEVBQUUsSUFBSSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsRUFBRSxJQUFJLENBQUMsQ0FBQyxDQUFDLEVBQUUsQ0FBQyxDQUFDLENBQUMsR0FBRyxFQUFFLENBQUM7UUFDM0QsT0FBTyxFQUFFLENBQUMsRUFBRSxDQUFDLE1BQU0sRUFBRSxNQUFNLEVBQUUsTUFBTSxDQUFDLENBQUM7SUFDekMsQ0FBQztJQUNEOzs7T0FHRztJQUNLLHFDQUFTLEdBQWpCOztRQUNJLElBQUksSUFBSSxHQUFHLEVBQUUsQ0FBQyxXQUFXLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxDQUFDO1FBQ3JDLElBQUksQ0FBQyxpQkFBaUIsRUFBRSxDQUFDO1FBQ3pCLElBQUksQ0FBQyxjQUFjLEdBQUcsSUFBSSxDQUFDLFlBQVksQ0FBQyxFQUFFLENBQUMsZUFBZSxDQUFDLENBQUM7UUFDNUQsTUFBQSxJQUFJLENBQUMsSUFBSSxDQUFDLFlBQVksQ0FBQyxFQUFFLENBQUMsWUFBWSxDQUFDLDBDQUFFLE9BQU8sR0FBRztRQUNuRCxNQUFBLElBQUksQ0FBQyxJQUFJLENBQUMsWUFBWSxDQUFDLEVBQUUsQ0FBQyxXQUFXLENBQUMsMENBQUUsT0FBTyxHQUFHO1FBQ2xELElBQUksQ0FBQyxJQUFJLENBQUMsWUFBWSxDQUFDLEVBQUUsQ0FBQyxlQUFlLENBQUMsQ0FBQyxPQUFPLEVBQUUsQ0FBQztRQUNyRCxJQUFJLFVBQVUsR0FBRyxJQUFJLENBQUMsYUFBYSxDQUFDLEVBQUUsQ0FBQyxTQUFTLENBQUMsQ0FBQztRQUNsRCxLQUFLLElBQUksQ0FBQyxHQUFHLENBQUMsRUFBRSxHQUFHLEdBQUcsVUFBVSxDQUFDLE1BQU0sRUFBRSxDQUFDLEdBQUcsR0FBRyxFQUFFLEVBQUUsQ0FBQyxFQUFFO1lBQ25ELElBQUksSUFBSSxHQUFHLFVBQVUsQ0FBQyxDQUFDLENBQUMsQ0FBQztZQUN6QixJQUFJLENBQUMsQ0FBQyxDQUFDLElBQUksWUFBWSxFQUFFLENBQUMsZUFBZSxDQUFDLElBQUksQ0FBQyxJQUFJLFlBQVksRUFBRSxDQUFDLFlBQVksQ0FBQyxJQUFJLENBQUMsSUFBSSxZQUFZLEVBQUUsQ0FBQyxXQUFXLENBQUMsQ0FBQyxFQUFFO2dCQUNsSCxJQUFJLENBQUMsT0FBTyxFQUFFLENBQUM7YUFDbEI7U0FDSjtRQUNELE9BQU8sSUFBSSxDQUFDO0lBQ2hCLENBQUM7O0lBM01EO1FBREMsUUFBUTsyREFDdUI7SUFLaEM7UUFIQyxRQUFRLENBQUM7WUFDTixPQUFPLEVBQUUsdUNBQXVDO1NBQ25ELENBQUM7c0RBQzRCO0lBVmIsaUJBQWlCO1FBRHJDLE9BQU87T0FDYSxpQkFBaUIsQ0FrTnJDO0lBQUQsd0JBQUM7Q0FsTkQsQUFrTkMsQ0FsTjhDLEVBQUUsQ0FBQyxTQUFTLEdBa04xRDtrQkFsTm9CLGlCQUFpQiIsImZpbGUiOiIiLCJzb3VyY2VSb290IjoiLyIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7IFJlbmRlclJlYWN0aXZlSGFuZGxlciB9IGZyb20gXCIuL1JlbmRlclJlYWN0aXZlSGFuZGxlclwiO1xyXG5cclxuLyoqXHJcbiAqIOebruWJjeivpea4suafk+S7o+eQhuWKn+iDveWtmOWcqOeahOmXrumimFxyXG4gKiAxLuiiq+S7o+eQhuiKgueCueeahOeItue6p+S4jeiDveWHuueOsHNjYWxlWOWSjHNjYWxlWeS4jeS4gOiHtOeahOaDheWGte+8jOiiq+S7o+eQhuiKgueCueacrOi6q+ayoeaciei/meS4qumZkOWItlxyXG4gKi9cclxuY29uc3QgeyBjY2NsYXNzLCBwcm9wZXJ0eSB9ID0gY2MuX2RlY29yYXRvcjtcclxuQGNjY2xhc3NcclxuZXhwb3J0IGRlZmF1bHQgY2xhc3MgUmVuZGVyQWx0ZXJuYXRpdmUgZXh0ZW5kcyBjYy5Db21wb25lbnQge1xyXG4gICAgLyoq5riy5p+T5bGC6IqC54K5ICovXHJcbiAgICBwdWJsaWMgcmVuZGVyTGF5ZXI6IGNjLk5vZGUgPSBudWxsO1xyXG4gICAgLyoq5riy5p+T55qEekluZGV4IOWKqOaAgeiwg+aVtHpJbmRleCznlKjkuo7mlrnkvr/kuLTov5HlkIjmibkgKi9cclxuICAgIEBwcm9wZXJ0eVxyXG4gICAgcHVibGljIHJlbmRlclpJbmRleDogbnVtYmVyID0gMDtcclxuICAgIC8qKuWQjOatpeeahOmXtOmalO+8iOW4p+S4uuWNleS9je+8iSAqL1xyXG4gICAgQHByb3BlcnR5KHtcclxuICAgICAgICB0b29sdGlwOiAn6K6+572u5ZCM5q2l55qE6Ze06ZqUKOenkuS4uuWNleS9jSnvvIww5bCx5piv5q+P5bin6YO95ZCM5q2l77yMMC4x5bCx5piv6ZqUMC4x56eS5ZCM5q2l5LiA5qyhJ1xyXG4gICAgfSlcclxuICAgIHB1YmxpYyBzeW5jSW52OiBudW1iZXIgPSAwLjAxO1xyXG4gICAgLyoq5riy5p+T55qEc0luZGV4ICovXHJcbiAgICBwdWJsaWMgc0luZGV4OiBudW1iZXIgPSAwO1xyXG4gICAgLyoq6Z2e5riy5p+T57uE5Lu2ICovXHJcbiAgICBwdWJsaWMgcHJveHlSZW5kZXI6IGNjLlJlbmRlckNvbXBvbmVudCA9IG51bGw7XHJcbiAgICAvKirmuLLmn5Pnu4Tku7YgKi9cclxuICAgIHByaXZhdGUgcmVuZGVyQ29tcG5lbnQ6IGNjLlJlbmRlckNvbXBvbmVudCA9IG51bGw7XHJcbiAgICAvKirkuIrmrKHmm7TmlrDnmoTmlbDmja4gKi9cclxuICAgIHB1YmxpYyBsYXN0V01hdDQ6IGNjLk1hdDQgPSBudWxsO1xyXG4gICAgLyoq5LiK5qyh5pu05paw55qE5pWw5o2uICovXHJcbiAgICBwdWJsaWMgbGFzdExNYXQ0OiBjYy5NYXQ0ID0gbnVsbDtcclxuICAgIC8qKuS4iuasoeabtOaWsOeahOaVsOaNriAqL1xyXG4gICAgcHVibGljIGxhc3RQb3M6IGNjLlZlYzMgPSBudWxsO1xyXG4gICAgLyoq6Led56a75LiL5qyh5Yi35paw57Sv6K6h5LqG5aSa5bCR6Ze06ZqUICovXHJcbiAgICBwdWJsaWMgYWNjdVRpbWU6IG51bWJlciA9IDA7XHJcbiAgICAvKirmnIDlkI7kuIDmrKHliLfmlrDml7bpl7QgKi9cclxuICAgIHB1YmxpYyBsYXN0RnJhbWVUaW1lOiBudW1iZXIgPSBudWxsO1xyXG4gICAgLyoq5piv5ZCm6L+b6KGM5Yi35pawICovXHJcbiAgICBwdWJsaWMgaXNBdHRhY2hGcmFtZTogYm9vbGVhbiA9IGZhbHNlO1xyXG5cclxuICAgIC8qKuiOt+WPluaAu+eahFpJbmRleCAqL1xyXG4gICAgZ2V0IHpJbmRleCgpIHtcclxuICAgICAgICBsZXQgekluZGV4ID0gdGhpcy5yZW5kZXJaSW5kZXggKyAodGhpcy5zSW5kZXggKiAwLjAxKTtcclxuICAgICAgICBsZXQgcGFyZW50Tm9kZSA9IHRoaXMubm9kZS5wYXJlbnQ7XHJcbiAgICAgICAgd2hpbGUgKHBhcmVudE5vZGUgIT0gdGhpcy5yZW5kZXJMYXllci5wYXJlbnQgJiYgcGFyZW50Tm9kZSAhPSBjYy5kaXJlY3Rvci5nZXRTY2VuZSgpKSB7XHJcbiAgICAgICAgICAgIGxldCByZW5kZXIgPSBwYXJlbnROb2RlLmdldENvbXBvbmVudChSZW5kZXJBbHRlcm5hdGl2ZSk7XHJcbiAgICAgICAgICAgIGlmIChyZW5kZXIpIHtcclxuICAgICAgICAgICAgICAgIHpJbmRleCArPSByZW5kZXIuekluZGV4ICsgMTtcclxuICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIHBhcmVudE5vZGUgPSBwYXJlbnROb2RlLnBhcmVudDtcclxuICAgICAgICB9XHJcbiAgICAgICAgcmV0dXJuIHpJbmRleDtcclxuICAgIH1cclxuXHJcbiAgICAvKipcclxuICAgICAqIOiuvue9rua4suafk+iKgueCueWxglxyXG4gICAgICogQHBhcmFtIGxheWVyIFxyXG4gICAgICovXHJcbiAgICBpbml0PFQgZXh0ZW5kcyBjYy5SZW5kZXJDb21wb25lbnQ+KGxheWVyPzogY2MuTm9kZSk6IFQge1xyXG4gICAgICAgIGlmIChsYXllcikge1xyXG4gICAgICAgICAgICB0aGlzLnJlbmRlckxheWVyID0gbGF5ZXI7XHJcbiAgICAgICAgfVxyXG4gICAgICAgIGlmICghdGhpcy5yZW5kZXJMYXllcikge1xyXG4gICAgICAgICAgICBjb25zb2xlLndhcm4oYOiKgueCuSR7dGhpcy5ub2RlLm5hbWV95rKh5pyJ6K6+572u5riy5p+T5bGCYClcclxuICAgICAgICAgICAgcmV0dXJuIG51bGw7XHJcbiAgICAgICAgfVxyXG4gICAgICAgIHJldHVybiB0aGlzLmluaXRSZW5kZXI8VD4oKTtcclxuICAgIH1cclxuICAgIC8qKlxyXG4gICAgICog5Yid5aeL5YyW5riy5p+T6IqC54K5XHJcbiAgICAgKi9cclxuICAgIHByaXZhdGUgaW5pdFJlbmRlcjxUIGV4dGVuZHMgY2MuUmVuZGVyQ29tcG9uZW50PigpOiBUIHtcclxuICAgICAgICBsZXQgbm9kZSA9IHRoaXMuZ2V0UmVuZGVyKCk7XHJcbiAgICAgICAgbm9kZS5zZXRQYXJlbnQodGhpcy5yZW5kZXJMYXllciA/IHRoaXMucmVuZGVyTGF5ZXIgOiBjYy5kaXJlY3Rvci5nZXRTY2VuZSgpLmdldENoaWxkQnlOYW1lKFwiQ2FudmFzXCIpKTtcclxuICAgICAgICB0aGlzLmlzQXR0YWNoRnJhbWUgPSB0cnVlO1xyXG4gICAgICAgIHJlcXVlc3RBbmltYXRpb25GcmFtZSh0aGlzLmZyYW1lVXBkYXRlLmJpbmQodGhpcykpO1xyXG4gICAgICAgIHJldHVybiB0aGlzLmRvUHJveHk8VD4oKTtcclxuICAgIH1cclxuICAgIC8qKueUn+aIkOS7o+eQhiAqL1xyXG4gICAgcHJpdmF0ZSBkb1Byb3h5PFQgZXh0ZW5kcyBjYy5SZW5kZXJDb21wb25lbnQ+KCk6IFQge1xyXG4gICAgICAgIHRoaXMucHJveHlSZW5kZXIgPSBuZXcgUHJveHkodGhpcy5yZW5kZXJDb21wbmVudCwgbmV3IFJlbmRlclJlYWN0aXZlSGFuZGxlcigpKSBhcyBUO1xyXG4gICAgICAgIHJldHVybiB0aGlzLnByb3h5UmVuZGVyIGFzIFQ7XHJcbiAgICB9XHJcblxyXG5cclxuICAgIHByb3RlY3RlZCBmcmFtZVVwZGF0ZSgpOiB2b2lkIHtcclxuICAgICAgICBsZXQgbm93ID0gY2Muc3lzLm5vdygpO1xyXG4gICAgICAgICF0aGlzLmxhc3RGcmFtZVRpbWUgJiYgKHRoaXMubGFzdEZyYW1lVGltZSA9IG5vdyk7XHJcbiAgICAgICAgbGV0IGR0ID0gbm93IC0gdGhpcy5sYXN0RnJhbWVUaW1lO1xyXG4gICAgICAgIGlmICh0aGlzLnByb3h5UmVuZGVyKSB7XHJcbiAgICAgICAgICAgIHRoaXMuYWNjdVRpbWUgKz0gZHQ7XHJcbiAgICAgICAgICAgIGlmICh0aGlzLmFjY3VUaW1lID49IHRoaXMuc3luY0ludikge1xyXG4gICAgICAgICAgICAgICAgdGhpcy5hY2N1VGltZSAtPSB0aGlzLnN5bmNJbnY7XHJcbiAgICAgICAgICAgICAgICB0aGlzLnVwZGF0ZVByb3AoKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH1cclxuICAgICAgICBpZiAodGhpcy5pc0F0dGFjaEZyYW1lKSB7XHJcbiAgICAgICAgICAgIHJlcXVlc3RBbmltYXRpb25GcmFtZSh0aGlzLmZyYW1lVXBkYXRlLmJpbmQodGhpcykpO1xyXG4gICAgICAgIH1cclxuICAgIH1cclxuXHJcbiAgICAvKirmm7TmlrDmnIDmlrDnirbmgIEgKi9cclxuICAgIHB1YmxpYyB1cGRhdGVQcm9wKCkge1xyXG4gICAgICAgIGxldCBub2RlID0gdGhpcy5yZW5kZXJDb21wbmVudC5ub2RlO1xyXG4gICAgICAgIGlmICghdGhpcy5ub2RlLmFjdGl2ZUluSGllcmFyY2h5KSB7XHJcbiAgICAgICAgICAgIG5vZGUub3BhY2l0eSA9IDA7XHJcbiAgICAgICAgICAgIHJldHVybjtcclxuICAgICAgICB9XHJcbiAgICAgICAgbm9kZS5hbmNob3JYID0gdGhpcy5ub2RlLmFuY2hvclg7XHJcbiAgICAgICAgbm9kZS5hbmNob3JZID0gdGhpcy5ub2RlLmFuY2hvclk7XHJcbiAgICAgICAgbm9kZS53aWR0aCA9IHRoaXMubm9kZS53aWR0aDtcclxuICAgICAgICBub2RlLmhlaWdodCA9IHRoaXMubm9kZS5oZWlnaHQ7XHJcbiAgICAgICAgbm9kZS5ncm91cCA9IHRoaXMubm9kZS5ncm91cDtcclxuICAgICAgICBub2RlLmNvbG9yID0gdGhpcy5ub2RlLmNvbG9yO1xyXG4gICAgICAgIG5vZGUub3BhY2l0eSA9IHRoaXMuZ2V0T3BhY2l0eSh0aGlzLm5vZGUpO1xyXG5cclxuICAgICAgICBsZXQgd01hdDQgPSBjYy5tYXQ0KCk7XHJcbiAgICAgICAgdGhpcy5ub2RlLmdldFdvcmxkTWF0cml4KHdNYXQ0KTtcclxuICAgICAgICAvKiBsZXQgbE1hdDQgPSBjYy5tYXQ0KCk7XHJcbiAgICAgICAgdGhpcy5ub2RlLmdldExvY2FsTWF0cml4KHdNYXQ0KTsgKi9cclxuICAgICAgICAvL+atpOWkhOacrOWPr+S7pei/h+a7pOiuuOWkmuS4jeW/heimgeeahOabtOaWsO+8jOS9huWwmuacquaOkuafpeWHuumXrumimFxyXG4gICAgICAgIGlmICh0cnVlIC8qIHx8ICF0aGlzLmxhc3RXTWF0ND8uZXF1YWxzKHdNYXQ0KSB8fCAhdGhpcy5sYXN0TE1hdDQ/LmVxdWFscyhsTWF0NCkgKi8pIHtcclxuICAgICAgICAgICAgdGhpcy5vbkFuZ2xlQ2hhbmdlKHdNYXQ0KTtcclxuICAgICAgICAgICAgdGhpcy5vblNjYWxlQ2hhbmdlKHdNYXQ0KTtcclxuICAgICAgICAgICAgdGhpcy5vblBvc0NoYW5nZSgpO1xyXG4gICAgICAgICAgICAvKiAgdGhpcy5sYXN0TE1hdDQgPSBsTWF0NDtcclxuICAgICAgICAgICAgIHRoaXMubGFzdFdNYXQ0ID0gd01hdDQ7ICovXHJcbiAgICAgICAgfVxyXG4gICAgICAgIG5vZGUuekluZGV4ID0gdGhpcy56SW5kZXg7XHJcbiAgICAgICAgbm9kZS56SW5kZXggPSB0aGlzLnpJbmRleDtcclxuICAgIH1cclxuXHJcbiAgICBwcm90ZWN0ZWQgb25EZXN0cm95KCk6IHZvaWQge1xyXG4gICAgICAgIHRoaXMucmVuZGVyQ29tcG5lbnQubm9kZS5kZXN0cm95KCk7XHJcbiAgICAgICAgdGhpcy5yZW5kZXJDb21wbmVudCA9IG51bGw7XHJcbiAgICAgICAgdGhpcy5wcm94eVJlbmRlciA9IG51bGw7XHJcbiAgICB9XHJcblxyXG4gICAgLyoqXHJcbiAgICAgKiDojrflj5boioLngrnpgI/mmI7luqZcclxuICAgICAqIEBwYXJhbSBub2RlIFxyXG4gICAgICovXHJcbiAgICBwcml2YXRlIGdldE9wYWNpdHkobm9kZTogY2MuTm9kZSkge1xyXG4gICAgICAgIGxldCBvcGFjaXR5ID0gKG5vZGUub3BhY2l0eSAvIDI1NSk7XHJcbiAgICAgICAgbGV0IHBhcmVudE5vZGUgPSBub2RlLnBhcmVudFxyXG4gICAgICAgIHdoaWxlIChwYXJlbnROb2RlICE9IHRoaXMucmVuZGVyTGF5ZXIucGFyZW50ICYmIHBhcmVudE5vZGUgIT0gY2MuZGlyZWN0b3IuZ2V0U2NlbmUoKSkge1xyXG4gICAgICAgICAgICBvcGFjaXR5ICo9IChwYXJlbnROb2RlLm9wYWNpdHkgLyAyNTUpO1xyXG4gICAgICAgICAgICBwYXJlbnROb2RlID0gcGFyZW50Tm9kZS5wYXJlbnQ7XHJcbiAgICAgICAgfVxyXG4gICAgICAgIHJldHVybiBvcGFjaXR5ICogMjU1O1xyXG4gICAgfVxyXG4gICAgLyoq5L2N572u5Y+Y5YyW5aSE55CGICovXHJcbiAgICBwcml2YXRlIG9uUG9zQ2hhbmdlKCkge1xyXG4gICAgICAgIGxldCB3cG9zID0gdGhpcy5ub2RlLnBhcmVudC5jb252ZXJ0VG9Xb3JsZFNwYWNlQVIodGhpcy5ub2RlLnBvc2l0aW9uKTtcclxuICAgICAgICB0aGlzLnJlbmRlckNvbXBuZW50Lm5vZGUucG9zaXRpb24gPSB0aGlzLnJlbmRlckxheWVyLmNvbnZlcnRUb05vZGVTcGFjZUFSKHdwb3MpO1xyXG4gICAgfVxyXG4gICAgLyoq5peL6L2s5Y+Y5YyW5aSE55CGICovXHJcbiAgICBwcml2YXRlIG9uQW5nbGVDaGFuZ2UobWF0NDogY2MuTWF0NCkge1xyXG4gICAgICAgIHRoaXMucmVuZGVyQ29tcG5lbnQubm9kZS5hbmdsZSA9IHRoaXMuZXh0cmFjdFJvdGF0aW9uQW5nbGVGcm9tTWF0NChtYXQ0KTtcclxuICAgIH1cclxuICAgIC8qKlxyXG4gICAgICog5LuOIGNjLk1hdDQg5Lit6I635Y+W5peL6L2s6KeS5bqm77yI5LiN5Y+X57yp5pS+5b2x5ZON77yJXHJcbiAgICAgKiBAcGFyYW0gbWF0cml4IOi+k+WFpeeahCBjYy5NYXQ0IOefqemYtVxyXG4gICAgICogQHJldHVybnMg5peL6L2s6KeS5bqm77yI5Lul5bqm5Li65Y2V5L2N77yJXHJcbiAgICAgKi9cclxuICAgIHByaXZhdGUgZXh0cmFjdFJvdGF0aW9uQW5nbGVGcm9tTWF0NChtYXRyaXg6IGNjLk1hdDQpOiBudW1iZXIge1xyXG4gICAgICAgIC8vIOaPkOWPluaXi+i9rOmDqOWIhlxyXG4gICAgICAgIGxldCBzY2FsZVggPSBNYXRoLnNxcnQobWF0cml4Lm1bMF0gKiBtYXRyaXgubVswXSArIG1hdHJpeC5tWzRdICogbWF0cml4Lm1bNF0gKyBtYXRyaXgubVs4XSAqIG1hdHJpeC5tWzhdKTtcclxuICAgICAgICBsZXQgc2NhbGVZID0gTWF0aC5zcXJ0KG1hdHJpeC5tWzFdICogbWF0cml4Lm1bMV0gKyBtYXRyaXgubVs1XSAqIG1hdHJpeC5tWzVdICsgbWF0cml4Lm1bOV0gKiBtYXRyaXgubVs5XSk7XHJcblxyXG4gICAgICAgIC8vIOiuoeeulyBaIOi9tOaXi+i9rOinkuW6pu+8iOe7lSBaIOi9tOeahOaXi+i9rOinkuW6pu+8iVxyXG4gICAgICAgIGxldCBhbmdsZSA9IE1hdGguYXRhbjIobWF0cml4Lm1bMV0gLyBzY2FsZVksIG1hdHJpeC5tWzBdIC8gc2NhbGVYKTtcclxuXHJcbiAgICAgICAgLy8g5bCG5byn5bqm6L2s5o2i5Li66KeS5bqmXHJcbiAgICAgICAgbGV0IGRlZ3JlZXMgPSBhbmdsZSAqICgxODAgLyBNYXRoLlBJKTtcclxuICAgICAgICByZXR1cm4gZGVncmVlcztcclxuICAgIH1cclxuICAgIC8qKlxyXG4gICAgICog57yp5pS+5Y+Y5YyW5aSE55CGXHJcbiAgICAgKiBAcGFyYW0gbWF0NCBcclxuICAgICAqL1xyXG4gICAgcHJpdmF0ZSBvblNjYWxlQ2hhbmdlKG1hdDQ6IGNjLk1hdDQpIHtcclxuICAgICAgICBsZXQgc2NhbGUgPSB0aGlzLmV4dHJhY3RTY2FsZUZyb21NYXQ0KG1hdDQpXHJcbiAgICAgICAgdGhpcy5yZW5kZXJDb21wbmVudC5ub2RlLnNjYWxlWCA9IHNjYWxlLng7XHJcbiAgICAgICAgdGhpcy5yZW5kZXJDb21wbmVudC5ub2RlLnNjYWxlWSA9IHNjYWxlLnk7XHJcbiAgICAgICAgdGhpcy5yZW5kZXJDb21wbmVudC5ub2RlLnNjYWxlWiA9IHNjYWxlLno7XHJcbiAgICB9XHJcbiAgICAvKipcclxuICAgICAqIOS7jm1hdDTkuK3ojrflj5bnvKnmlL7lgLxcclxuICAgICAqIEBwYXJhbSBtYXQ0IFxyXG4gICAgICogQHJldHVybnMgXHJcbiAgICAgKi9cclxuICAgIHByaXZhdGUgZXh0cmFjdFNjYWxlRnJvbU1hdDQobWF0NDogY2MuTWF0NCk6IGNjLlZlYzMge1xyXG4gICAgICAgIGxldCBzY2FsZVggPSBjYy52MyhtYXQ0Lm1bMF0sIG1hdDQubVsxXSwgbWF0NC5tWzJdKS5tYWcoKTtcclxuICAgICAgICBsZXQgc2NhbGVZID0gY2MudjMobWF0NC5tWzRdLCBtYXQ0Lm1bNV0sIG1hdDQubVs2XSkubWFnKCk7XHJcbiAgICAgICAgbGV0IHNjYWxlWiA9IGNjLnYzKG1hdDQubVs4XSwgbWF0NC5tWzldLCBtYXQ0Lm1bMTBdKS5tYWcoKTtcclxuICAgICAgICByZXR1cm4gY2MudjMoc2NhbGVYLCBzY2FsZVksIHNjYWxlWik7XHJcbiAgICB9XHJcbiAgICAvKipcclxuICAgICAqIOiOt+WPlua4suafk+e7hOS7tlxyXG4gICAgICogQHBhcmFtIG5vZGUgXHJcbiAgICAgKi9cclxuICAgIHByaXZhdGUgZ2V0UmVuZGVyKCkge1xyXG4gICAgICAgIGxldCBub2RlID0gY2MuaW5zdGFudGlhdGUodGhpcy5ub2RlKTtcclxuICAgICAgICBub2RlLnJlbW92ZUFsbENoaWxkcmVuKCk7XHJcbiAgICAgICAgdGhpcy5yZW5kZXJDb21wbmVudCA9IG5vZGUuZ2V0Q29tcG9uZW50KGNjLlJlbmRlckNvbXBvbmVudCk7XHJcbiAgICAgICAgdGhpcy5ub2RlLmdldENvbXBvbmVudChjYy5MYWJlbE91dGxpbmUpPy5kZXN0cm95KCk7XHJcbiAgICAgICAgdGhpcy5ub2RlLmdldENvbXBvbmVudChjYy5MYWJlbFNoYWRvdyk/LmRlc3Ryb3koKTtcclxuICAgICAgICB0aGlzLm5vZGUuZ2V0Q29tcG9uZW50KGNjLlJlbmRlckNvbXBvbmVudCkuZGVzdHJveSgpO1xyXG4gICAgICAgIGxldCBjb21wb25lbnRzID0gbm9kZS5nZXRDb21wb25lbnRzKGNjLkNvbXBvbmVudCk7XHJcbiAgICAgICAgZm9yIChsZXQgaSA9IDAsIGxlbiA9IGNvbXBvbmVudHMubGVuZ3RoOyBpIDwgbGVuOyArK2kpIHtcclxuICAgICAgICAgICAgbGV0IGNvbXAgPSBjb21wb25lbnRzW2ldO1xyXG4gICAgICAgICAgICBpZiAoISgoY29tcCBpbnN0YW5jZW9mIGNjLlJlbmRlckNvbXBvbmVudCkgfHwgKGNvbXAgaW5zdGFuY2VvZiBjYy5MYWJlbE91dGxpbmUpIHx8IChjb21wIGluc3RhbmNlb2YgY2MuTGFiZWxTaGFkb3cpKSkge1xyXG4gICAgICAgICAgICAgICAgY29tcC5kZXN0cm95KCk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9XHJcbiAgICAgICAgcmV0dXJuIG5vZGU7XHJcbiAgICB9XHJcblxyXG59XHJcbiJdfQ== \ No newline at end of file diff --git a/Layered_virtual_list_2.x/temp/quick-scripts/dst/assets/Script/RenderReactiveHandler.js b/Layered_virtual_list_2.x/temp/quick-scripts/dst/assets/Script/RenderReactiveHandler.js new file mode 100644 index 0000000..be80bcd --- /dev/null +++ b/Layered_virtual_list_2.x/temp/quick-scripts/dst/assets/Script/RenderReactiveHandler.js @@ -0,0 +1,106 @@ + + (function() { + var nodeEnv = typeof require !== 'undefined' && typeof process !== 'undefined'; + var __module = nodeEnv ? module : {exports:{}}; + var __filename = 'preview-scripts/assets/Script/RenderReactiveHandler.js'; + var __require = nodeEnv ? function (request) { + return cc.require(request); + } : function (request) { + return __quick_compile_project__.require(request, __filename); + }; + function __define (exports, require, module) { + if (!nodeEnv) {__quick_compile_project__.registerModule(__filename, module);}"use strict"; +cc._RF.push(module, 'd38d0Ja+51M8L8TYTQwae9Q', 'RenderReactiveHandler'); +// Script/RenderReactiveHandler.ts + +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.RenderReactiveHandler = exports.hasChanged = exports.hasOwn = exports.isObject = void 0; +function isObject(value) { + return value !== null && typeof value === 'object'; +} +exports.isObject = isObject; +var hasOwnProperty = Object.prototype.hasOwnProperty; +/** 是否自身上存在属性 */ +function hasOwn(val, key) { + if (val instanceof cc.Component) { + return key in val; + } + return hasOwnProperty.call(val, key); +} +exports.hasOwn = hasOwn; +/** 比较值是否变化了,考虑NaN;如果是对象直接认为改变了 */ +function hasChanged(value, oldValue) { + var type = typeof value; + if (type === "object") + return true; + return !Object.is(value, oldValue); +} +exports.hasChanged = hasChanged; +var RenderReactiveHandler = /** @class */ (function () { + function RenderReactiveHandler(reactiveTarget) { + /**需要作出反应的对象 */ + this.reactiveTarget = null; + this.reactiveTarget = reactiveTarget; + } + /** + * + * @param target 被代理的对象 + * @param prop 被代理的对象的属性名 + * @param value 被代理的对象的属性值 + * @param receiver 代理对象 + * @returns + */ + RenderReactiveHandler.prototype.set = function (target, prop, value, receiver) { + var oldValue = Reflect.get(target, prop); + var hadKey = hasOwn(target, prop); + var result = Reflect.set(target, prop, value); + if (!hadKey || hasChanged(value, oldValue)) { + if (prop == "angle" || prop == 'scale' || prop == "position" || prop == "_renderFlag") + return; + if (prop == 'activeInHierarchy') { + console.warn(target); + } + // 属性变化 + this.reactiveTarget && (Reflect.set(this.reactiveTarget, prop, value)); + } + return result; + }; + RenderReactiveHandler.prototype.apply = function () { + console.warn(arguments); + }; + RenderReactiveHandler.prototype.get = function (target, prop, receiver) { + if (prop === '__raw__') { + return target; + } + else if (prop === '__isReactive__') { + return true; + } + var rawValue = Reflect.get(target, prop); + return rawValue; + }; + RenderReactiveHandler.prototype.deleteProperty = function (target, prop) { + var hadKey = hasOwn(target, prop); + var oldValue = target[prop]; + var result = Reflect.deleteProperty(target, prop); + if (result && hadKey) { + //trigger(target, prop, void 0, oldValue); + } + return result; + }; + return RenderReactiveHandler; +}()); +exports.RenderReactiveHandler = RenderReactiveHandler; + +cc._RF.pop(); + } + if (nodeEnv) { + __define(__module.exports, __require, __module); + } + else { + __quick_compile_project__.registerModuleFunc(__filename, function () { + __define(__module.exports, __require, __module); + }); + } + })(); +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImFzc2V0c1xcU2NyaXB0XFxSZW5kZXJSZWFjdGl2ZUhhbmRsZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7O0FBQ0EsU0FBZ0IsUUFBUSxDQUFDLEtBQWM7SUFDbkMsT0FBTyxLQUFLLEtBQUssSUFBSSxJQUFJLE9BQU8sS0FBSyxLQUFLLFFBQVEsQ0FBQztBQUN2RCxDQUFDO0FBRkQsNEJBRUM7QUFFRCxJQUFNLGNBQWMsR0FBRyxNQUFNLENBQUMsU0FBUyxDQUFDLGNBQWMsQ0FBQTtBQUN0RCxnQkFBZ0I7QUFDaEIsU0FBZ0IsTUFBTSxDQUFDLEdBQVcsRUFBRSxHQUE2QjtJQUM3RCxJQUFJLEdBQUcsWUFBWSxFQUFFLENBQUMsU0FBUyxFQUFFO1FBQzdCLE9BQU8sR0FBRyxJQUFJLEdBQUcsQ0FBQztLQUNyQjtJQUNELE9BQU8sY0FBYyxDQUFDLElBQUksQ0FBQyxHQUFHLEVBQUUsR0FBRyxDQUFDLENBQUM7QUFDekMsQ0FBQztBQUxELHdCQUtDO0FBRUQsa0NBQWtDO0FBQ2xDLFNBQWdCLFVBQVUsQ0FBQyxLQUFVLEVBQUUsUUFBYTtJQUNoRCxJQUFJLElBQUksR0FBRyxPQUFPLEtBQUssQ0FBQztJQUN4QixJQUFJLElBQUksS0FBSyxRQUFRO1FBQUUsT0FBTyxJQUFJLENBQUM7SUFDbkMsT0FBTyxDQUFDLE1BQU0sQ0FBQyxFQUFFLENBQUMsS0FBSyxFQUFFLFFBQVEsQ0FBQyxDQUFDO0FBQ3ZDLENBQUM7QUFKRCxnQ0FJQztBQUdEO0lBQ0ksK0JBQVksY0FBdUI7UUFHbkMsZUFBZTtRQUNQLG1CQUFjLEdBQVcsSUFBSSxDQUFDO1FBSGxDLElBQUksQ0FBQyxjQUFjLEdBQUcsY0FBYyxDQUFDO0lBQ3pDLENBQUM7SUFJRDs7Ozs7OztPQU9HO0lBQ0gsbUNBQUcsR0FBSCxVQUFJLE1BQWMsRUFBRSxJQUFxQixFQUFFLEtBQVUsRUFBRSxRQUFhO1FBRWhFLElBQUksUUFBUSxHQUFHLE9BQU8sQ0FBQyxHQUFHLENBQUMsTUFBTSxFQUFFLElBQUksQ0FBQyxDQUFDO1FBQ3pDLElBQUksTUFBTSxHQUFHLE1BQU0sQ0FBQyxNQUFNLEVBQUUsSUFBSSxDQUFDLENBQUM7UUFDbEMsSUFBSSxNQUFNLEdBQUcsT0FBTyxDQUFDLEdBQUcsQ0FBQyxNQUFNLEVBQUUsSUFBSSxFQUFFLEtBQUssQ0FBQyxDQUFDO1FBQzlDLElBQUksQ0FBQyxNQUFNLElBQUksVUFBVSxDQUFDLEtBQUssRUFBRSxRQUFRLENBQUMsRUFBRTtZQUN4QyxJQUFJLElBQUksSUFBSSxPQUFPLElBQUksSUFBSSxJQUFJLE9BQU8sSUFBSSxJQUFJLElBQUksVUFBVSxJQUFJLElBQUksSUFBSSxhQUFhO2dCQUFFLE9BQU87WUFDOUYsSUFBSSxJQUFJLElBQUksbUJBQW1CLEVBQUU7Z0JBQzdCLE9BQU8sQ0FBQyxJQUFJLENBQUMsTUFBTSxDQUFDLENBQUM7YUFDeEI7WUFDRCxPQUFPO1lBQ1AsSUFBSSxDQUFDLGNBQWMsSUFBSSxDQUFDLE9BQU8sQ0FBQyxHQUFHLENBQUMsSUFBSSxDQUFDLGNBQWMsRUFBRSxJQUFJLEVBQUUsS0FBSyxDQUFDLENBQUMsQ0FBQztTQUMxRTtRQUVELE9BQU8sTUFBTSxDQUFBO0lBQ2pCLENBQUM7SUFFRCxxQ0FBSyxHQUFMO1FBQ0ksT0FBTyxDQUFDLElBQUksQ0FBQyxTQUFTLENBQUMsQ0FBQTtJQUMzQixDQUFDO0lBRUQsbUNBQUcsR0FBSCxVQUFJLE1BQWMsRUFBRSxJQUFxQixFQUFFLFFBQWE7UUFFcEQsSUFBSSxJQUFJLEtBQUssU0FBUyxFQUFFO1lBQ3BCLE9BQU8sTUFBTSxDQUFDO1NBQ2pCO2FBQ0ksSUFBSSxJQUFJLEtBQUssZ0JBQWdCLEVBQUU7WUFDaEMsT0FBTyxJQUFJLENBQUM7U0FDZjtRQUNELElBQUksUUFBUSxHQUFHLE9BQU8sQ0FBQyxHQUFHLENBQUMsTUFBTSxFQUFFLElBQUksQ0FBQyxDQUFDO1FBQ3pDLE9BQU8sUUFBUSxDQUFDO0lBQ3BCLENBQUM7SUFFRCw4Q0FBYyxHQUFkLFVBQWUsTUFBYyxFQUFFLElBQXFCO1FBQ2hELElBQUksTUFBTSxHQUFHLE1BQU0sQ0FBQyxNQUFNLEVBQUUsSUFBSSxDQUFDLENBQUM7UUFDbEMsSUFBSSxRQUFRLEdBQUcsTUFBTSxDQUFDLElBQUksQ0FBQyxDQUFDO1FBQzVCLElBQUksTUFBTSxHQUFHLE9BQU8sQ0FBQyxjQUFjLENBQUMsTUFBTSxFQUFFLElBQUksQ0FBQyxDQUFDO1FBQ2xELElBQUksTUFBTSxJQUFJLE1BQU0sRUFBRTtZQUNsQiwwQ0FBMEM7U0FDN0M7UUFFRCxPQUFPLE1BQU0sQ0FBQztJQUNsQixDQUFDO0lBQ0wsNEJBQUM7QUFBRCxDQTFEQSxBQTBEQyxJQUFBO0FBMURZLHNEQUFxQiIsImZpbGUiOiIiLCJzb3VyY2VSb290IjoiLyIsInNvdXJjZXNDb250ZW50IjpbIlxyXG5leHBvcnQgZnVuY3Rpb24gaXNPYmplY3QodmFsdWU6IHVua25vd24pOiB2YWx1ZSBpcyBSZWNvcmQ8YW55LCBhbnk+IHtcclxuICAgIHJldHVybiB2YWx1ZSAhPT0gbnVsbCAmJiB0eXBlb2YgdmFsdWUgPT09ICdvYmplY3QnO1xyXG59XHJcblxyXG5jb25zdCBoYXNPd25Qcm9wZXJ0eSA9IE9iamVjdC5wcm90b3R5cGUuaGFzT3duUHJvcGVydHlcclxuLyoqIOaYr+WQpuiHqui6q+S4iuWtmOWcqOWxnuaApyAqL1xyXG5leHBvcnQgZnVuY3Rpb24gaGFzT3duKHZhbDogb2JqZWN0LCBrZXk6IHN0cmluZyB8IG51bWJlciB8IHN5bWJvbCk6IGtleSBpcyBrZXlvZiB0eXBlb2YgdmFsIHtcclxuICAgIGlmICh2YWwgaW5zdGFuY2VvZiBjYy5Db21wb25lbnQpIHtcclxuICAgICAgICByZXR1cm4ga2V5IGluIHZhbDtcclxuICAgIH1cclxuICAgIHJldHVybiBoYXNPd25Qcm9wZXJ0eS5jYWxsKHZhbCwga2V5KTtcclxufVxyXG5cclxuLyoqIOavlOi+g+WAvOaYr+WQpuWPmOWMluS6hu+8jOiAg+iZkU5hTu+8m+WmguaenOaYr+WvueixoeebtOaOpeiupOS4uuaUueWPmOS6hiAqL1xyXG5leHBvcnQgZnVuY3Rpb24gaGFzQ2hhbmdlZCh2YWx1ZTogYW55LCBvbGRWYWx1ZTogYW55KTogYm9vbGVhbiB7XHJcbiAgICBsZXQgdHlwZSA9IHR5cGVvZiB2YWx1ZTtcclxuICAgIGlmICh0eXBlID09PSBcIm9iamVjdFwiKSByZXR1cm4gdHJ1ZTtcclxuICAgIHJldHVybiAhT2JqZWN0LmlzKHZhbHVlLCBvbGRWYWx1ZSk7XHJcbn1cclxuXHJcblxyXG5leHBvcnQgY2xhc3MgUmVuZGVyUmVhY3RpdmVIYW5kbGVyIHtcclxuICAgIGNvbnN0cnVjdG9yKHJlYWN0aXZlVGFyZ2V0Pzogb2JqZWN0KSB7XHJcbiAgICAgICAgdGhpcy5yZWFjdGl2ZVRhcmdldCA9IHJlYWN0aXZlVGFyZ2V0O1xyXG4gICAgfVxyXG4gICAgLyoq6ZyA6KaB5L2c5Ye65Y+N5bqU55qE5a+56LGhICovXHJcbiAgICBwcml2YXRlIHJlYWN0aXZlVGFyZ2V0OiBvYmplY3QgPSBudWxsO1xyXG5cclxuICAgIC8qKlxyXG4gICAgICogXHJcbiAgICAgKiBAcGFyYW0gdGFyZ2V0IOiiq+S7o+eQhueahOWvueixoVxyXG4gICAgICogQHBhcmFtIHByb3Ag6KKr5Luj55CG55qE5a+56LGh55qE5bGe5oCn5ZCNXHJcbiAgICAgKiBAcGFyYW0gdmFsdWUg6KKr5Luj55CG55qE5a+56LGh55qE5bGe5oCn5YC8XHJcbiAgICAgKiBAcGFyYW0gcmVjZWl2ZXIg5Luj55CG5a+56LGhXHJcbiAgICAgKiBAcmV0dXJucyBcclxuICAgICAqL1xyXG4gICAgc2V0KHRhcmdldDogb2JqZWN0LCBwcm9wOiBzdHJpbmcgfCBzeW1ib2wsIHZhbHVlOiBhbnksIHJlY2VpdmVyOiBhbnkpOiBib29sZWFuIHtcclxuXHJcbiAgICAgICAgbGV0IG9sZFZhbHVlID0gUmVmbGVjdC5nZXQodGFyZ2V0LCBwcm9wKTtcclxuICAgICAgICBsZXQgaGFkS2V5ID0gaGFzT3duKHRhcmdldCwgcHJvcCk7XHJcbiAgICAgICAgbGV0IHJlc3VsdCA9IFJlZmxlY3Quc2V0KHRhcmdldCwgcHJvcCwgdmFsdWUpO1xyXG4gICAgICAgIGlmICghaGFkS2V5IHx8IGhhc0NoYW5nZWQodmFsdWUsIG9sZFZhbHVlKSkge1xyXG4gICAgICAgICAgICBpZiAocHJvcCA9PSBcImFuZ2xlXCIgfHwgcHJvcCA9PSAnc2NhbGUnIHx8IHByb3AgPT0gXCJwb3NpdGlvblwiIHx8IHByb3AgPT0gXCJfcmVuZGVyRmxhZ1wiKSByZXR1cm47XHJcbiAgICAgICAgICAgIGlmIChwcm9wID09ICdhY3RpdmVJbkhpZXJhcmNoeScpIHtcclxuICAgICAgICAgICAgICAgIGNvbnNvbGUud2Fybih0YXJnZXQpO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIC8vIOWxnuaAp+WPmOWMllxyXG4gICAgICAgICAgICB0aGlzLnJlYWN0aXZlVGFyZ2V0ICYmIChSZWZsZWN0LnNldCh0aGlzLnJlYWN0aXZlVGFyZ2V0LCBwcm9wLCB2YWx1ZSkpO1xyXG4gICAgICAgIH1cclxuXHJcbiAgICAgICAgcmV0dXJuIHJlc3VsdFxyXG4gICAgfVxyXG5cclxuICAgIGFwcGx5KCkge1xyXG4gICAgICAgIGNvbnNvbGUud2Fybihhcmd1bWVudHMpXHJcbiAgICB9XHJcblxyXG4gICAgZ2V0KHRhcmdldDogb2JqZWN0LCBwcm9wOiBzdHJpbmcgfCBzeW1ib2wsIHJlY2VpdmVyOiBhbnkpOiBhbnkge1xyXG5cclxuICAgICAgICBpZiAocHJvcCA9PT0gJ19fcmF3X18nKSB7XHJcbiAgICAgICAgICAgIHJldHVybiB0YXJnZXQ7XHJcbiAgICAgICAgfVxyXG4gICAgICAgIGVsc2UgaWYgKHByb3AgPT09ICdfX2lzUmVhY3RpdmVfXycpIHtcclxuICAgICAgICAgICAgcmV0dXJuIHRydWU7XHJcbiAgICAgICAgfVxyXG4gICAgICAgIGxldCByYXdWYWx1ZSA9IFJlZmxlY3QuZ2V0KHRhcmdldCwgcHJvcCk7XHJcbiAgICAgICAgcmV0dXJuIHJhd1ZhbHVlO1xyXG4gICAgfVxyXG5cclxuICAgIGRlbGV0ZVByb3BlcnR5KHRhcmdldDogb2JqZWN0LCBwcm9wOiBzdHJpbmcgfCBzeW1ib2wpOiBib29sZWFuIHtcclxuICAgICAgICBsZXQgaGFkS2V5ID0gaGFzT3duKHRhcmdldCwgcHJvcCk7XHJcbiAgICAgICAgbGV0IG9sZFZhbHVlID0gdGFyZ2V0W3Byb3BdO1xyXG4gICAgICAgIGxldCByZXN1bHQgPSBSZWZsZWN0LmRlbGV0ZVByb3BlcnR5KHRhcmdldCwgcHJvcCk7XHJcbiAgICAgICAgaWYgKHJlc3VsdCAmJiBoYWRLZXkpIHtcclxuICAgICAgICAgICAgLy90cmlnZ2VyKHRhcmdldCwgcHJvcCwgdm9pZCAwLCBvbGRWYWx1ZSk7XHJcbiAgICAgICAgfVxyXG5cclxuICAgICAgICByZXR1cm4gcmVzdWx0O1xyXG4gICAgfVxyXG59XHJcbiJdfQ== \ No newline at end of file diff --git a/Layered_virtual_list_2.x/temp/quick-scripts/src/__qc_index__.js b/Layered_virtual_list_2.x/temp/quick-scripts/src/__qc_index__.js new file mode 100644 index 0000000..3185c82 --- /dev/null +++ b/Layered_virtual_list_2.x/temp/quick-scripts/src/__qc_index__.js @@ -0,0 +1,12 @@ + +require('./assets/Scene/Item'); +require('./assets/Scene/TestLoop'); +require('./assets/Scene/TestMatrix'); +require('./assets/Scene/TestRenderAlternative'); +require('./assets/Scene/TestShowNode'); +require('./assets/Script/LoopList'); +require('./assets/Script/RenderAlternative'); +require('./assets/Script/RenderAlternative1'); +require('./assets/Script/RenderAlternativeItem'); +require('./assets/Script/RenderAlternative_old'); +require('./assets/Script/RenderReactiveHandler'); diff --git a/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Scene/Item.js b/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Scene/Item.js new file mode 100644 index 0000000..9ee1bcf --- /dev/null +++ b/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Scene/Item.js @@ -0,0 +1,77 @@ +"use strict"; +cc._RF.push(module, '7e1f6lmx11Hho9BNV3MqKkZ', 'Item'); +// Scene/Item.ts + +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var RenderAlternativeItem_1 = require("../Script/RenderAlternativeItem"); +var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property; +var Item = /** @class */ (function (_super) { + __extends(Item, _super); + function Item() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /** */ + _this.nameLb = null; + /** */ + _this.contentLb = null; + /** */ + _this.Button = null; + /** */ + _this.ButtonLb = null; + _this.data = null; + return _this; + // update (dt) {} + } + Item.prototype.init = function (data) { + this.data = data.data; + var layer = data.layer; + this.initRenderLayer(layer); + this.initShow(); + }; + /** + * 初始化显示 + * @param data + */ + Item.prototype.initShow = function () { + this.nameLb.string = "我是第" + this.data.index + "个"; + this.contentLb.string = "我是内容" + this.data.name; + }; + __decorate([ + property(cc.Label) + ], Item.prototype, "nameLb", void 0); + __decorate([ + property(cc.Label) + ], Item.prototype, "contentLb", void 0); + __decorate([ + property(cc.Node) + ], Item.prototype, "Button", void 0); + __decorate([ + property(cc.Label) + ], Item.prototype, "ButtonLb", void 0); + Item = __decorate([ + ccclass + ], Item); + return Item; +}(RenderAlternativeItem_1.default)); +exports.default = Item; + +cc._RF.pop(); \ No newline at end of file diff --git a/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Scene/Item.js.map b/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Scene/Item.js.map new file mode 100644 index 0000000..55c1fe7 --- /dev/null +++ b/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Scene/Item.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["assets\\Scene\\Item.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yEAAoE;AAG9D,IAAA,KAAwB,EAAE,CAAC,UAAU,EAAnC,OAAO,aAAA,EAAE,QAAQ,cAAkB,CAAC;AAG5C;IAAkC,wBAAqB;IAAvD;QAAA,qEAkCC;QAhCG,MAAM;QAEC,YAAM,GAAa,IAAI,CAAC;QAC/B,MAAM;QAEC,eAAS,GAAa,IAAI,CAAC;QAClC,MAAM;QAEC,YAAM,GAAY,IAAI,CAAC;QAC9B,MAAM;QAEC,cAAQ,GAAa,IAAI,CAAC;QAEjC,UAAI,GAAQ,IAAI,CAAC;;QAkBjB,iBAAiB;IACrB,CAAC;IAjBG,mBAAI,GAAJ,UAAK,IAAS;QACV,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACtB,IAAI,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACvB,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;QAC5B,IAAI,CAAC,QAAQ,EAAE,CAAC;IACpB,CAAC;IAED;;;OAGG;IACH,uBAAQ,GAAR;QACI,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC;QACnD,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;IACpD,CAAC;IA3BD;QADC,QAAQ,CAAC,EAAE,CAAC,KAAK,CAAC;wCACY;IAG/B;QADC,QAAQ,CAAC,EAAE,CAAC,KAAK,CAAC;2CACe;IAGlC;QADC,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC;wCACY;IAG9B;QADC,QAAQ,CAAC,EAAE,CAAC,KAAK,CAAC;0CACc;IAbhB,IAAI;QADxB,OAAO;OACa,IAAI,CAkCxB;IAAD,WAAC;CAlCD,AAkCC,CAlCiC,+BAAqB,GAkCtD;kBAlCoB,IAAI","file":"","sourceRoot":"/","sourcesContent":["import RenderAlternativeItem from \"../Script/RenderAlternativeItem\";\r\n\r\n\r\nconst { ccclass, property } = cc._decorator;\r\n\r\n@ccclass\r\nexport default class Item extends RenderAlternativeItem {\r\n\r\n /** */\r\n @property(cc.Label)\r\n public nameLb: cc.Label = null;\r\n /** */\r\n @property(cc.Label)\r\n public contentLb: cc.Label = null;\r\n /** */\r\n @property(cc.Node)\r\n public Button: cc.Node = null;\r\n /** */\r\n @property(cc.Label)\r\n public ButtonLb: cc.Label = null;\r\n\r\n data: any = null;\r\n\r\n init(data: any) {\r\n this.data = data.data;\r\n let layer = data.layer;\r\n this.initRenderLayer(layer);\r\n this.initShow();\r\n }\r\n\r\n /**\r\n * 初始化显示\r\n * @param data \r\n */\r\n initShow() {\r\n this.nameLb.string = \"我是第\" + this.data.index + \"个\";\r\n this.contentLb.string = \"我是内容\" + this.data.name;\r\n }\r\n\r\n // update (dt) {}\r\n}\r\n"]} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Scene/TestLoop.js b/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Scene/TestLoop.js new file mode 100644 index 0000000..a5410f0 --- /dev/null +++ b/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Scene/TestLoop.js @@ -0,0 +1,97 @@ +"use strict"; +cc._RF.push(module, '4850bCv26VE3LcjWQcJHche', 'TestLoop'); +// Scene/TestLoop.ts + +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.TestLoop = void 0; +var LoopList_1 = require("../Script/LoopList"); +var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property; +var TestLoop = /** @class */ (function (_super) { + __extends(TestLoop, _super); + function TestLoop() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /**分层渲染节点 */ + _this.rendeLayer = null; + /**显示节点预制件 */ + _this.scrollView = null; + /**显示节点预制件 */ + _this.showPrefab = null; + return _this; + } + TestLoop.prototype.start = function () { + //测试横向宽高数据 + /* let baseWidth = 80; + let changeWidth = 20; + let baseHeight = 600; + let changeHeight = 150; + let anchor = cc.v2(0.5, 0.5) */ + //测试纵向宽高数据 + var baseWidth = 600; + var changeWidth = 150; + var baseHeight = 80; + var changeHeight = 20; + var anchor = cc.v2(0.5, 0.5); + var data = []; + for (var i = 0, len = 30; i < len; ++i) { + data.push({ + index: i, text: "内容" + i + }); + } + LoopList_1.default.ins("Test").init(this.scrollView, this.rendeLayer, 18); + LoopList_1.default.ins("Test").initData(data, this.showPrefab, cc.size(baseWidth, baseHeight), anchor); + /* //测试插入数据 + this.scheduleOnce(() => { + LoopList.ins("Test").insertData({ index: 1, text: "我是插入1", size: cc.size(baseWidth, baseHeight) }, 1); + }, 3) + + //测试压入数据 + this.scheduleOnce(() => { + LoopList.ins("Test").pushDatas([ + { index: 1, text: "我是压入1", size: cc.size(baseWidth, baseHeight) }, + { index: 2, text: "我是压入2", size: cc.size(baseWidth, baseHeight) }, + { index: 3, text: "我是压入3", size: cc.size(baseWidth, baseHeight) }, + ]); + }, 4) + + //测试压入数据 + this.scheduleOnce(() => { + LoopList.ins("Test").removeData(1); + }, 5) */ + }; + __decorate([ + property(cc.Node) + ], TestLoop.prototype, "rendeLayer", void 0); + __decorate([ + property(cc.ScrollView) + ], TestLoop.prototype, "scrollView", void 0); + __decorate([ + property(cc.Prefab) + ], TestLoop.prototype, "showPrefab", void 0); + TestLoop = __decorate([ + ccclass + ], TestLoop); + return TestLoop; +}(cc.Component)); +exports.TestLoop = TestLoop; + +cc._RF.pop(); \ No newline at end of file diff --git a/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Scene/TestLoop.js.map b/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Scene/TestLoop.js.map new file mode 100644 index 0000000..d1118fb --- /dev/null +++ b/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Scene/TestLoop.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["assets\\Scene\\TestLoop.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,+CAA0C;AAEpC,IAAA,KAAwB,EAAE,CAAC,UAAU,EAAnC,OAAO,aAAA,EAAE,QAAQ,cAAkB,CAAC;AAG5C;IAA8B,4BAAY;IAA1C;QAAA,qEAsDC;QArDG,YAAY;QAEL,gBAAU,GAAY,IAAI,CAAC;QAClC,aAAa;QAEN,gBAAU,GAAkB,IAAI,CAAC;QACxC,aAAa;QAEN,gBAAU,GAAc,IAAI,CAAC;;IA6CxC,CAAC;IA3CG,wBAAK,GAAL;QACI,UAAU;QACV;;;;uCAI+B;QAE/B,UAAU;QACV,IAAI,SAAS,GAAG,GAAG,CAAC;QACpB,IAAI,WAAW,GAAG,GAAG,CAAC;QACtB,IAAI,UAAU,GAAG,EAAE,CAAC;QACpB,IAAI,YAAY,GAAG,EAAE,CAAC;QACtB,IAAI,MAAM,GAAG,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QAE7B,IAAI,IAAI,GAAY,EAAE,CAAC;QACvB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,EAAE,EAAE,CAAC,GAAG,GAAG,EAAE,EAAE,CAAC,EAAE;YACpC,IAAI,CAAC,IAAI,CAAC;gBACN,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,GAAG,CAAC;aAC3B,CAAC,CAAC;SACN;QACD,kBAAQ,CAAC,GAAG,CAAQ,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;QACvE,kBAAQ,CAAC,GAAG,CAAQ,MAAM,CAAC,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,UAAU,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,CAAC;QAEpG;;;;;;;;;;;;;;;;;gBAiBQ;IACZ,CAAC;IAlDD;QADC,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC;gDACgB;IAGlC;QADC,QAAQ,CAAC,EAAE,CAAC,UAAU,CAAC;gDACgB;IAGxC;QADC,QAAQ,CAAC,EAAE,CAAC,MAAM,CAAC;gDACgB;IAT3B,QAAQ;QADpB,OAAO;OACK,QAAQ,CAsDpB;IAAD,eAAC;CAtDD,AAsDC,CAtD6B,EAAE,CAAC,SAAS,GAsDzC;AAtDY,4BAAQ","file":"","sourceRoot":"/","sourcesContent":["\r\n\r\nimport LoopList from '../Script/LoopList';\r\nimport { IData } from './TestShowNode';\r\nconst { ccclass, property } = cc._decorator;\r\n\r\n@ccclass\r\nexport class TestLoop extends cc.Component {\r\n /**分层渲染节点 */\r\n @property(cc.Node)\r\n public rendeLayer: cc.Node = null;\r\n /**显示节点预制件 */\r\n @property(cc.ScrollView)\r\n public scrollView: cc.ScrollView = null;\r\n /**显示节点预制件 */\r\n @property(cc.Prefab)\r\n public showPrefab: cc.Prefab = null;\r\n\r\n start() {\r\n //测试横向宽高数据\r\n /* let baseWidth = 80;\r\n let changeWidth = 20;\r\n let baseHeight = 600;\r\n let changeHeight = 150;\r\n let anchor = cc.v2(0.5, 0.5) */\r\n\r\n //测试纵向宽高数据\r\n let baseWidth = 600;\r\n let changeWidth = 150;\r\n let baseHeight = 80;\r\n let changeHeight = 20;\r\n let anchor = cc.v2(0.5, 0.5);\r\n\r\n let data: IData[] = [];\r\n for (let i = 0, len = 30; i < len; ++i) {\r\n data.push({\r\n index: i, text: \"内容\" + i\r\n });\r\n }\r\n LoopList.ins(\"Test\").init(this.scrollView, this.rendeLayer, 18);\r\n LoopList.ins(\"Test\").initData(data, this.showPrefab, cc.size(baseWidth, baseHeight), anchor);\r\n\r\n /* //测试插入数据\r\n this.scheduleOnce(() => {\r\n LoopList.ins(\"Test\").insertData({ index: 1, text: \"我是插入1\", size: cc.size(baseWidth, baseHeight) }, 1);\r\n }, 3)\r\n\r\n //测试压入数据\r\n this.scheduleOnce(() => {\r\n LoopList.ins(\"Test\").pushDatas([\r\n { index: 1, text: \"我是压入1\", size: cc.size(baseWidth, baseHeight) },\r\n { index: 2, text: \"我是压入2\", size: cc.size(baseWidth, baseHeight) },\r\n { index: 3, text: \"我是压入3\", size: cc.size(baseWidth, baseHeight) },\r\n ]);\r\n }, 4)\r\n\r\n //测试压入数据\r\n this.scheduleOnce(() => {\r\n LoopList.ins(\"Test\").removeData(1);\r\n }, 5) */\r\n }\r\n}\r\n\r\n\r\n"]} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Scene/TestMatrix.js b/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Scene/TestMatrix.js new file mode 100644 index 0000000..23e7ac8 --- /dev/null +++ b/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Scene/TestMatrix.js @@ -0,0 +1,158 @@ +"use strict"; +cc._RF.push(module, '41fb7HlhIJNzZMkSaq31ryP', 'TestMatrix'); +// Scene/TestMatrix.ts + +"use strict"; +// Learn TypeScript: +// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html +// Learn Attribute: +// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html +// Learn life-cycle callbacks: +// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property; +var NewClass = /** @class */ (function (_super) { + __extends(NewClass, _super); + function NewClass() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.target = null; + _this.targetParent = null; + _this.srcTarget = null; + _this.srcTargetParent = null; + return _this; + // update (dt) {} + } + // LIFE-CYCLE CALLBACKS: + NewClass.prototype.onLoad = function () { + // cc.director.on(cc.Director.EVENT_BEFORE_DRAW, this.onBeforeDraw, this); + }; + NewClass.prototype.start = function () { + // this.scheduleOnce(() => { + // this.target.x = 100; + // this.target.scaleX = 2; + // }, 3); + // this.scheduleOnce(() => { + // this.targetParent.x = 10; + // this.target.scaleX = 1.1; + // }, 1); + var targetNode = this.target; // 需要获取世界矩阵的节点 + var parentNode = this.targetParent; // 要转换到的节点 + var localMatrix = cc.mat4(); + targetNode.getLocalMatrix(localMatrix); + this.getMatrixInfo(localMatrix); + // 获取目标节点的世界矩阵 + var worldMatrix = cc.mat4(); + targetNode.getWorldMatrix(worldMatrix); + // 获取父节点的世界矩阵 + var parentWorldMatrix = cc.mat4(); + parentNode.getWorldMatrix(parentWorldMatrix); + // 获取父节点的逆矩阵 + var parentInverseMatrix = parentWorldMatrix.invert(); + // 将目标节点的世界矩阵转换为父节点的本地矩阵 + var localMatrix2 = parentInverseMatrix.multiply(worldMatrix); + this.getMatrixInfo(localMatrix2); + }; + NewClass.prototype.matrixTransform = function () { + // 假设我们有一个目标节点和一个父节点 + var targetNode = this.target; // 需要获取世界矩阵的节点 + var parentNode = this.srcTargetParent; // 要转换到的节点 + // 获取目标节点的世界矩阵 + var worldMatrix = cc.mat4(); + targetNode.getWorldMatrix(worldMatrix); + // 获取父节点的世界矩阵 + var parentWorldMatrix = cc.mat4(); + parentNode.getWorldMatrix(parentWorldMatrix); + // 获取父节点的逆矩阵 + var parentInverseMatrix = parentWorldMatrix.invert(); + // 将目标节点的世界矩阵转换为父节点的本地矩阵 + var localMatrix = parentInverseMatrix.multiply(worldMatrix); + // 提取位置 + var position = cc.v3(worldMatrix.m[12], worldMatrix.m[13], worldMatrix.m[14]); + // 提取缩放 + var scaleX = Math.sqrt(worldMatrix.m[0] * worldMatrix.m[0] + worldMatrix.m[1] * worldMatrix.m[1] + worldMatrix.m[2] * worldMatrix.m[2]); + var scaleY = Math.sqrt(worldMatrix.m[4] * worldMatrix.m[4] + worldMatrix.m[5] * worldMatrix.m[5] + worldMatrix.m[6] * worldMatrix.m[6]); + var scaleZ = Math.sqrt(worldMatrix.m[8] * worldMatrix.m[8] + worldMatrix.m[9] * worldMatrix.m[9] + worldMatrix.m[10] * worldMatrix.m[10]); + // 提取旋转(假设是二维旋转) + var angle = Math.atan2(worldMatrix.m[1] / scaleX, worldMatrix.m[0] / scaleX) * (180 / Math.PI); + // 输出结果 + console.log("Position:", position); + console.log("Scale:", cc.v3(scaleX, scaleY, scaleZ)); + console.log("Angle:", angle); + }; + NewClass.prototype.getMatrixInfo = function (matrix) { + // 提取位置 + var position = cc.v3(matrix.m[12], matrix.m[13], matrix.m[14]); + // 提取缩放 + var scaleX = Math.sqrt(matrix.m[0] * matrix.m[0] + matrix.m[1] * matrix.m[1] + matrix.m[2] * matrix.m[2]); + var scaleY = Math.sqrt(matrix.m[4] * matrix.m[4] + matrix.m[5] * matrix.m[5] + matrix.m[6] * matrix.m[6]); + var scaleZ = Math.sqrt(matrix.m[8] * matrix.m[8] + matrix.m[9] * matrix.m[9] + matrix.m[10] * matrix.m[10]); + // 提取旋转(假设是二维旋转) + var angle = Math.atan2(matrix.m[1] / scaleX, matrix.m[0] / scaleX) * (180 / Math.PI); + // 输出结果 + console.log("Position:", position); + console.log("Scale:", cc.v3(scaleX, scaleY, scaleZ)); + console.log("Angle:", angle); + }; + NewClass.prototype.onDestroy = function () { + cc.director.off(cc.Director.EVENT_BEFORE_DRAW, this.onBeforeDraw, this); + }; + NewClass.prototype.onBeforeDraw = function () { + this.checkDirty(this.target); + this.checkDirty(this.targetParent); + }; + NewClass.prototype.checkDirty = function (node) { + //@ts-ignore + var _localMatDirty = node._localMatDirty; + if (_localMatDirty) { + console.log(node.name, _localMatDirty); + } + //@ts-ignore + var _worldMatDirty = node._worldMatDirty; + if (_worldMatDirty) { + console.log(node.name, _worldMatDirty); + } + //@ts-ignore + var _renderFlag = node._renderFlag; + if (_renderFlag) { + console.log(node.name, _renderFlag); + } + }; + __decorate([ + property(cc.Node) + ], NewClass.prototype, "target", void 0); + __decorate([ + property(cc.Node) + ], NewClass.prototype, "targetParent", void 0); + __decorate([ + property(cc.Node) + ], NewClass.prototype, "srcTarget", void 0); + __decorate([ + property(cc.Node) + ], NewClass.prototype, "srcTargetParent", void 0); + NewClass = __decorate([ + ccclass + ], NewClass); + return NewClass; +}(cc.Component)); +exports.default = NewClass; + +cc._RF.pop(); \ No newline at end of file diff --git a/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Scene/TestMatrix.js.map b/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Scene/TestMatrix.js.map new file mode 100644 index 0000000..1ac69d4 --- /dev/null +++ b/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Scene/TestMatrix.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["assets\\Scene\\TestMatrix.ts"],"names":[],"mappings":";;;;;AAAA,oBAAoB;AACpB,wEAAwE;AACxE,mBAAmB;AACnB,kFAAkF;AAClF,8BAA8B;AAC9B,kFAAkF;;;;;;;;;;;;;;;;;;;;;AAE5E,IAAA,KAAwB,EAAE,CAAC,UAAU,EAAnC,OAAO,aAAA,EAAE,QAAQ,cAAkB,CAAC;AAG5C;IAAsC,4BAAY;IAAlD;QAAA,qEAuDC;QApDG,YAAM,GAAY,IAAI,CAAC;QAIvB,kBAAY,GAAY,IAAI,CAAC;;QA+C7B,iBAAiB;IACrB,CAAC;IA/CG,wBAAwB;IAExB,yBAAM,GAAN;QACI,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC,QAAQ,CAAC,iBAAiB,EAAE,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;IAC3E,CAAC;IAED,wBAAK,GAAL;QAAA,iBAUC;QATG,IAAI,CAAC,YAAY,CAAC;YACd,KAAI,CAAC,MAAM,CAAC,CAAC,GAAG,GAAG,CAAC;YACpB,KAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;QAC3B,CAAC,EAAE,CAAC,CAAC,CAAC;QAEN,IAAI,CAAC,YAAY,CAAC;YACd,KAAI,CAAC,YAAY,CAAC,CAAC,GAAG,EAAE,CAAC;YACzB,KAAI,CAAC,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC;QAC7B,CAAC,EAAE,CAAC,CAAC,CAAC;IACV,CAAC;IAED,4BAAS,GAAT;QACI,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,QAAQ,CAAC,iBAAiB,EAAE,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;IAC5E,CAAC;IAGD,+BAAY,GAAZ;QACI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC7B,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACvC,CAAC;IAED,6BAAU,GAAV,UAAW,IAAa;QACpB,YAAY;QACZ,IAAI,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC;QACzC,IAAI,cAAc,EAAE;YAChB,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;SAC1C;QACD,YAAY;QACZ,IAAI,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC;QACzC,IAAI,cAAc,EAAE;YAChB,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;SAC1C;QACD,YAAY;QACZ,IAAI,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;QACnC,IAAI,WAAW,EAAE;YACb,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;SACvC;IACL,CAAC;IAjDD;QADC,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC;4CACK;IAIvB;QADC,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC;kDACW;IAPZ,QAAQ;QAD5B,OAAO;OACa,QAAQ,CAuD5B;IAAD,eAAC;CAvDD,AAuDC,CAvDqC,EAAE,CAAC,SAAS,GAuDjD;kBAvDoB,QAAQ","file":"","sourceRoot":"/","sourcesContent":["// Learn TypeScript:\r\n// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html\r\n// Learn Attribute:\r\n// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html\r\n// Learn life-cycle callbacks:\r\n// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html\r\n\r\nconst { ccclass, property } = cc._decorator;\r\n\r\n@ccclass\r\nexport default class NewClass extends cc.Component {\r\n\r\n @property(cc.Node)\r\n target: cc.Node = null;\r\n\r\n\r\n @property(cc.Node)\r\n targetParent: cc.Node = null;\r\n // LIFE-CYCLE CALLBACKS:\r\n\r\n onLoad() {\r\n cc.director.on(cc.Director.EVENT_BEFORE_DRAW, this.onBeforeDraw, this);\r\n }\r\n\r\n start() {\r\n this.scheduleOnce(() => {\r\n this.target.x = 100;\r\n this.target.scaleX = 2;\r\n }, 3);\r\n\r\n this.scheduleOnce(() => {\r\n this.targetParent.x = 10;\r\n this.target.scaleX = 1.1;\r\n }, 1);\r\n }\r\n\r\n onDestroy(): void {\r\n cc.director.off(cc.Director.EVENT_BEFORE_DRAW, this.onBeforeDraw, this);\r\n }\r\n\r\n\r\n onBeforeDraw() {\r\n this.checkDirty(this.target);\r\n this.checkDirty(this.targetParent);\r\n }\r\n\r\n checkDirty(node: cc.Node) {\r\n //@ts-ignore\r\n let _localMatDirty = node._localMatDirty;\r\n if (_localMatDirty) {\r\n console.log(node.name, _localMatDirty);\r\n }\r\n //@ts-ignore\r\n let _worldMatDirty = node._worldMatDirty;\r\n if (_worldMatDirty) {\r\n console.log(node.name, _worldMatDirty);\r\n }\r\n //@ts-ignore\r\n let _renderFlag = node._renderFlag;\r\n if (_renderFlag) {\r\n console.log(node.name, _renderFlag);\r\n }\r\n }\r\n\r\n // update (dt) {}\r\n}\r\n"]} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Scene/TestRenderAlternative.js b/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Scene/TestRenderAlternative.js new file mode 100644 index 0000000..a1be642 --- /dev/null +++ b/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Scene/TestRenderAlternative.js @@ -0,0 +1,73 @@ +"use strict"; +cc._RF.push(module, 'b9be0tgoIVPk72LiE6N39f/', 'TestRenderAlternative'); +// Scene/TestRenderAlternative.ts + +"use strict"; +// Learn TypeScript: +// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html +// Learn Attribute: +// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html +// Learn life-cycle callbacks: +// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property; +var TestRenderAlternative = /** @class */ (function (_super) { + __extends(TestRenderAlternative, _super); + function TestRenderAlternative() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.scrollView = null; + _this.prefab = null; + _this.layer = null; + return _this; + // update (dt) {} + } + // onLoad () {} + TestRenderAlternative.prototype.start = function () { + var count = 1000; + var datas = []; + for (var i = 0; i < count; i++) { + var data = { name: 'name' + i, index: i }; + datas.push({ data: data, layer: this.layer }); + } + for (var i = 0; i < datas.length; i++) { + var item = cc.instantiate(this.prefab); + this.scrollView.content.addChild(item); + item.getComponent('Item').init(datas[i]); + } + }; + __decorate([ + property(cc.ScrollView) + ], TestRenderAlternative.prototype, "scrollView", void 0); + __decorate([ + property(cc.Prefab) + ], TestRenderAlternative.prototype, "prefab", void 0); + __decorate([ + property(cc.Node) + ], TestRenderAlternative.prototype, "layer", void 0); + TestRenderAlternative = __decorate([ + ccclass + ], TestRenderAlternative); + return TestRenderAlternative; +}(cc.Component)); +exports.default = TestRenderAlternative; + +cc._RF.pop(); \ No newline at end of file diff --git a/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Scene/TestRenderAlternative.js.map b/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Scene/TestRenderAlternative.js.map new file mode 100644 index 0000000..fdf3ece --- /dev/null +++ b/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Scene/TestRenderAlternative.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["assets\\Scene\\TestRenderAlternative.ts"],"names":[],"mappings":";;;;;AAAA,oBAAoB;AACpB,wEAAwE;AACxE,mBAAmB;AACnB,kFAAkF;AAClF,8BAA8B;AAC9B,kFAAkF;;;;;;;;;;;;;;;;;;;;;AAE5E,IAAA,KAAwB,EAAE,CAAC,UAAU,EAAnC,OAAO,aAAA,EAAE,QAAQ,cAAkB,CAAC;AAG5C;IAAmD,yCAAY;IAA/D;QAAA,qEA6BC;QA1BG,gBAAU,GAAkB,IAAI,CAAC;QAGjC,YAAM,GAAc,IAAI,CAAC;QAGzB,WAAK,GAAY,IAAI,CAAC;;QAmBtB,iBAAiB;IACrB,CAAC;IAlBG,eAAe;IAEf,qCAAK,GAAL;QACI,IAAI,KAAK,GAAG,EAAE,CAAC;QACf,IAAI,KAAK,GAAG,EAAE,CAAC;QACf,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE,EAAE;YAC5B,IAAI,IAAI,GAAG,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;YAC1C,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;SACjD;QAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACnC,IAAI,IAAI,GAAG,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACvC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;YACvC,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;SAC5C;IACL,CAAC;IAvBD;QADC,QAAQ,CAAC,EAAE,CAAC,UAAU,CAAC;6DACS;IAGjC;QADC,QAAQ,CAAC,EAAE,CAAC,MAAM,CAAC;yDACK;IAGzB;QADC,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC;wDACI;IATL,qBAAqB;QADzC,OAAO;OACa,qBAAqB,CA6BzC;IAAD,4BAAC;CA7BD,AA6BC,CA7BkD,EAAE,CAAC,SAAS,GA6B9D;kBA7BoB,qBAAqB","file":"","sourceRoot":"/","sourcesContent":["// Learn TypeScript:\r\n// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html\r\n// Learn Attribute:\r\n// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html\r\n// Learn life-cycle callbacks:\r\n// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html\r\n\r\nconst { ccclass, property } = cc._decorator;\r\n\r\n@ccclass\r\nexport default class TestRenderAlternative extends cc.Component {\r\n\r\n @property(cc.ScrollView)\r\n scrollView: cc.ScrollView = null;\r\n\r\n @property(cc.Prefab)\r\n prefab: cc.Prefab = null;\r\n\r\n @property(cc.Node)\r\n layer: cc.Node = null;\r\n\r\n // onLoad () {}\r\n\r\n start() {\r\n let count = 10;\r\n let datas = [];\r\n for (let i = 0; i < count; i++) {\r\n let data = { name: 'name' + i, index: i };\r\n datas.push({ data: data, layer: this.layer });\r\n }\r\n\r\n for (let i = 0; i < datas.length; i++) {\r\n let item = cc.instantiate(this.prefab);\r\n this.scrollView.content.addChild(item);\r\n item.getComponent('Item').init(datas[i]);\r\n }\r\n }\r\n\r\n // update (dt) {}\r\n}\r\n"]} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Scene/TestShowNode.js b/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Scene/TestShowNode.js new file mode 100644 index 0000000..a3243b7 --- /dev/null +++ b/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Scene/TestShowNode.js @@ -0,0 +1,90 @@ +"use strict"; +cc._RF.push(module, '9e178M6rUlI5qgi1+HcLO30', 'TestShowNode'); +// Scene/TestShowNode.ts + +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.TestShowNode = void 0; +var LoopList_1 = require("../Script/LoopList"); +var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property; +var TestShowNode = /** @class */ (function (_super) { + __extends(TestShowNode, _super); + function TestShowNode() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /** */ + _this.nameLb = null; + /** */ + _this.contentLb = null; + /** */ + _this.Button = null; + /** */ + _this.ButtonLb = null; + return _this; + } + /** + * 初始化显示 + * @param data + */ + TestShowNode.prototype.initShow = function () { + this.node.width = this.data.size.width; + this.node.height = this.data.size.height; + this.nameLb.string = "我是第" + this.data.index + "个"; + this.contentLb.string = "我是内容" + this.data.text; + //这个是改变控件大小的事例 + if (this.data.index == 5 || this.data.index == 11) { + //this.changeSize(cell); + } + }; + /** + * 改变大小 + * @param cell + */ + TestShowNode.prototype.changeSize = function (cell) { + var _this = this; + this.resize(cc.size(cell.size.width, 100 + (Math.random() * 400))); + this.scheduleOnce(function () { + _this.changeSize(cell); + }, 3 + Math.random() * 3); + }; + TestShowNode.prototype.onRecircle = function () { + //做释放操作 + }; + __decorate([ + property(cc.Label) + ], TestShowNode.prototype, "nameLb", void 0); + __decorate([ + property(cc.Label) + ], TestShowNode.prototype, "contentLb", void 0); + __decorate([ + property(cc.Node) + ], TestShowNode.prototype, "Button", void 0); + __decorate([ + property(cc.Label) + ], TestShowNode.prototype, "ButtonLb", void 0); + TestShowNode = __decorate([ + ccclass + ], TestShowNode); + return TestShowNode; +}(LoopList_1.ShowNode)); +exports.TestShowNode = TestShowNode; + +cc._RF.pop(); \ No newline at end of file diff --git a/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Scene/TestShowNode.js.map b/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Scene/TestShowNode.js.map new file mode 100644 index 0000000..e384b67 --- /dev/null +++ b/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Scene/TestShowNode.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["assets\\Scene\\TestShowNode.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAwD;AAElD,IAAA,KAAwB,EAAE,CAAC,UAAU,EAAnC,OAAO,aAAA,EAAE,QAAQ,cAAkB,CAAC;AAQ5C;IAAkC,gCAAe;IAAjD;QAAA,qEA2CC;QA1CG,MAAM;QAEC,YAAM,GAAa,IAAI,CAAC;QAC/B,MAAM;QAEC,eAAS,GAAa,IAAI,CAAC;QAClC,MAAM;QAEC,YAAM,GAAY,IAAI,CAAC;QAC9B,MAAM;QAEC,cAAQ,GAAa,IAAI,CAAC;;IA+BrC,CAAC;IA7BG;;;OAGG;IACH,+BAAQ,GAAR;QACI,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;QACvC,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;QACzC,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC;QACnD,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;QAChD,cAAc;QACd,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,EAAE;YAC/C,wBAAwB;SAC3B;IACL,CAAC;IAED;;;OAGG;IACH,iCAAU,GAAV,UAAW,IAAqB;QAAhC,iBAKC;QAJG,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;QACnE,IAAI,CAAC,YAAY,CAAC;YACd,KAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;QACzB,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAA;IAC7B,CAAC;IAED,iCAAU,GAAV;QACI,OAAO;IACX,CAAC;IAvCD;QADC,QAAQ,CAAC,EAAE,CAAC,KAAK,CAAC;gDACY;IAG/B;QADC,QAAQ,CAAC,EAAE,CAAC,KAAK,CAAC;mDACe;IAGlC;QADC,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC;gDACY;IAG9B;QADC,QAAQ,CAAC,EAAE,CAAC,KAAK,CAAC;kDACc;IAZxB,YAAY;QADxB,OAAO;OACK,YAAY,CA2CxB;IAAD,mBAAC;CA3CD,AA2CC,CA3CiC,mBAAQ,GA2CzC;AA3CY,oCAAY","file":"","sourceRoot":"/","sourcesContent":["import ItemCell, { ShowNode } from \"../Script/LoopList\";\r\nimport RenderAlternative from \"../Script/RenderAlternative\";\r\nconst { ccclass, property } = cc._decorator;\r\nexport interface IData {\r\n size?: cc.Size,\r\n index: number,\r\n text: string\r\n}\r\n\r\n@ccclass\r\nexport class TestShowNode extends ShowNode {\r\n /** */\r\n @property(cc.Label)\r\n public nameLb: cc.Label = null;\r\n /** */\r\n @property(cc.Label)\r\n public contentLb: cc.Label = null;\r\n /** */\r\n @property(cc.Node)\r\n public Button: cc.Node = null;\r\n /** */\r\n @property(cc.Label)\r\n public ButtonLb: cc.Label = null;\r\n\r\n /**\r\n * 初始化显示\r\n * @param data \r\n */\r\n initShow() {\r\n this.node.width = this.data.size.width;\r\n this.node.height = this.data.size.height;\r\n this.nameLb.string = \"我是第\" + this.data.index + \"个\";\r\n this.contentLb.string = \"我是内容\" + this.data.text;\r\n //这个是改变控件大小的事例\r\n if (this.data.index == 5 || this.data.index == 11) {\r\n //this.changeSize(cell);\r\n }\r\n }\r\n\r\n /**\r\n * 改变大小\r\n * @param cell \r\n */\r\n changeSize(cell: ItemCell) {\r\n this.resize(cc.size(cell.size.width, 100 + (Math.random() * 400)));\r\n this.scheduleOnce(() => {\r\n this.changeSize(cell)\r\n }, 3 + Math.random() * 3)\r\n }\r\n\r\n onRecircle() {\r\n //做释放操作\r\n }\r\n}\r\n\r\n\r\n"]} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Script/LoopList.js b/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Script/LoopList.js new file mode 100644 index 0000000..0a3696b --- /dev/null +++ b/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Script/LoopList.js @@ -0,0 +1,913 @@ +"use strict"; +cc._RF.push(module, 'b4ec1SU3/dIdZG3ODfwZKk3', 'LoopList'); +// Script/LoopList.ts + +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ItemCell = exports.ShowNode = void 0; +var RenderAlternative_1 = require("./RenderAlternative"); +var ShowNode = /** @class */ (function (_super) { + __extends(ShowNode, _super); + function ShowNode() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /**是否初始化过代理组建 */ + _this.hasInit = false; + return _this; + } + /**初始化 */ + ShowNode.prototype.init = function (cell, data, renderLayer) { + this.cell = cell; + this.data = data; + if (this.renderLayer != renderLayer) { + this.renderLayer = renderLayer; + renderLayer && this.initRenders(); + } + this.initShow(); + }; + /**初始化操作 */ + ShowNode.prototype.initShow = function () { }; + /**被回收,应该做一些释放的操作 */ + ShowNode.prototype.onRecircle = function () { }; + /** + * 在特定时间内进行大小变化 + * @param targetSize + * @param time + */ + ShowNode.prototype.resize = function (targetSize, time) { + if (time === void 0) { time = 0.3; } + this.cell.resize(targetSize, time); + }; + /** + * 处理分层代理渲染 + */ + ShowNode.prototype.initRenders = function () { + if (!this.hasInit && this.renderLayer) { + var propMap = new WeakMap(); + var keys = Object.keys(this); + for (var i = 0, len = keys.length; i < len; ++i) { + var value = this[keys[i]]; + var alternative = null; + if (value instanceof cc.Node) { + alternative = value.getComponent(RenderAlternative_1.default); + if (alternative) { + alternative.init(this.renderLayer); + } + } + else if (value instanceof cc.RenderComponent) { + alternative = value.getComponent(RenderAlternative_1.default); + if (alternative) { + this[keys[i]] = alternative.init(this.renderLayer); + } + } + alternative && propMap.set(alternative, true); + } + this.dealChilrenAlternative(this.node, propMap, 0, 0); + this.hasInit = true; + } + }; + /** + * 处理子节点代理 + * @param node + * @param propMap 记录脚本已经处理过的属性代理 + * @param parentSindex 父节点的所在的顺序 + * @param depth 深度 + */ + ShowNode.prototype.dealChilrenAlternative = function (node, propMap, parentSindex, depth) { + var _a; + for (var i = 0, len = node.children.length; i < len; i++) { + var children = node.children[i]; + var alternative = (_a = children.getComponent(cc.RenderComponent)) === null || _a === void 0 ? void 0 : _a.getComponent(RenderAlternative_1.default); + var sIndex = parentSindex + (i * Math.pow(0.1, depth)); + if (alternative) { + if ((!propMap.has(alternative) || !propMap.get(alternative))) { + alternative.init(this.renderLayer); + } + alternative.sIndex = sIndex; + } + this.dealChilrenAlternative(children, propMap, sIndex, depth + 1); + } + }; + return ShowNode; +}(cc.Component)); +exports.ShowNode = ShowNode; +var ItemCell = /** @class */ (function () { + /** + * 构造函数 + * @param node + * @param looplist + */ + function ItemCell(node, looplist) { + /**持有cell的list */ + this.looplist = null; + /**位置节点 */ + this.node = null; + /**显示节点 */ + this.showNode = null; + /**尺寸 */ + this.size = null; + /**数据下标 */ + this.dataIndex = null; + /**cell下标 */ + this.cellIndex = null; + /**数据 */ + this.data = null; + this.node = node; + this.looplist = looplist; + } + /** + * 初始化 + * @param data + * @param size + * @param dataIndex + * @param cellIndex + * @param looplist + */ + ItemCell.prototype.init = function (data, size, dataIndex, cellIndex, looplist) { + cc.Tween.stopAllByTarget(this.node); + this.cellIndex = cellIndex; + this.dataIndex = dataIndex; + this.looplist = looplist; + this.node.width = size.width; + this.node.height = size.height; + this.data = data; + this.size = size; + }; + /** + * 重置大小 + * @param size + */ + ItemCell.prototype.resize = function (size, time) { + var _this = this; + var nodeSides = getNodeBorder(this, [true, true, true, true]); + var changeSize = cc.size(size.width - this.size.width, size.height - this.size.height); + this.size = size; + this.looplist.dealChangeSize(this, nodeSides, changeSize, time).then(function () { + _this.node.width = size.width; + _this.node.height = size.height; + _this.looplist.updateNodes(); + }); + }; + /** + * 更新节点显示 + * @param isShow 是否显示 + * @param prefab 需要显示的节点的预制件(也可以是节点,或者预制件url,生成方式自由改动) + * @param cacheNode 对象池中的显示节点 + * @param renderLayer 分层节点 + */ + ItemCell.prototype.updateShow = function (isShow, prefab, cacheNode, renderLayer) { + if (isShow) { + //当前没有显示节点 + if (!this.showNode) { + //如果是临时对象池还有节点则重用 + if (cacheNode) { + this.showNode = cacheNode; + } + else { //否则使用传入的预制件进行生成 + this.showNode = cc.instantiate(prefab).getComponent(ShowNode); + } + this.showNode.node.setParent(this.node); + this.showNode.node.position = cc.v3(); + this.updateShowNode(renderLayer); + } + } + }; + /** + * 更新showNode节点显示 + * @param renderLayer + */ + ItemCell.prototype.updateShowNode = function (renderLayer) { + //当前有显示节点 + if (this.showNode) { + this.showNode.init(this, this.data, renderLayer); + } + }; + Object.defineProperty(ItemCell.prototype, "hasNoNode", { + get: function () { + return !this.showNode; + }, + enumerable: false, + configurable: true + }); + ItemCell.prototype.recircle = function () { + if (this.showNode) { + var node = this.showNode; + this.showNode.getComponent(ShowNode).onRecircle(); + this.showNode.node.removeFromParent(false); + this.showNode = null; + return node; + } + }; + ItemCell.prototype.destroy = function () { + this.node.destroy(); + this.node = null; + this.looplist = null; + }; + /** + * 失去 + * @returns + */ + ItemCell.prototype.lostShowNode = function () { + if (this.showNode) { + var node = this.showNode; + this.showNode.node.removeFromParent(false); + this.showNode = null; + return node; + } + }; + /** + * 获取显示节点 + * @param showNode + */ + ItemCell.prototype.getShowNode = function (showNode) { + this.showNode = showNode; + showNode.node.setParent(this.node); + this.showNode.cell = this; + }; + return ItemCell; +}()); +exports.ItemCell = ItemCell; +/** + * 目前列表注意事项 + * 1.开启cellMaxNum后不能一行多列或者一列多行,只能单行或者单列 + */ +var LoopList = /** @class */ (function () { + function LoopList() { + /**分层节点(只有在showNode中挂载了RenderAlternative才能起作用) */ + this.renderLayer = null; + /**滚动组件 */ + this.scrollView = null; + /**cell节点最大数量 */ + this.cellMaxNum = null; + /**当前起点 */ + this.curStartIndex = null; + /**数据 */ + this.datas = []; + /**item节点们 */ + this.itemCells = []; + /**预制件 */ + this.prefab = null; + /**显示节点的池子 */ + this.showNodePool = []; + /**边缘数据 */ + this.viewSides = {}; + /**上一帧滚动容器的坐标 */ + this.lastPos = null; + /**刷新显示的间隔次数 */ + this.updateInv = 0; + /**循环切换的最后一次时间 */ + this.lastChange = 0; + /**通用尺寸 */ + this.size = null; + /**通用锚点 */ + this.anchor = null; + } + LoopList.ins = function (listName) { + if (!this.insMap.has(listName)) { + this.insMap.set(listName, new LoopList()); + } + return this.insMap.get(listName); + }; + LoopList.prototype.onLoad = function () { + this.updateBorder(); + }; + /** + * 更新边界 + */ + LoopList.prototype.updateBorder = function () { + var _this = this; + var view = this.scrollView.node.getChildByName("view"); + view.anchorX = this.scrollView.content.anchorX; + view.anchorY = this.scrollView.content.anchorY; + //修改锚点之后下一帧世界坐标才会更新,没办法只能等一帧了 + return new Promise(function (resolve, reject) { + requestAnimationFrame(function () { + var wpos = getNodeWPos(view); + //显示区域左边缘 + var leftSide = wpos.x - (view.width * view.anchorX); + //显示区域右边缘 + var rightSide = wpos.x + (view.width * (1 - view.anchorX)); + //显示区域下边缘 + var bottomSide = wpos.y - (view.height * view.anchorY); + //显示区域上边缘 + var topSide = wpos.y + (view.height * (1 - view.anchorY)); + _this.viewSides = { + leftSide: leftSide, rightSide: rightSide, bottomSide: bottomSide, topSide: topSide, + size: cc.size(view.width, view.height) + }; + _this.scrollView.content.setPosition(cc.v3(0, 0)); + resolve(); + }); + }); + }; + /** + * 初始化滚动列表 + * @param scrollView + * @param cellMaxNum cell节点的最大数量,设置成null则不启用,启用的话,要设置成(可视窗刚好能显示的最大数量*2)+2,假设最多能看到10个节点,那么设置成22 + * @param renderLayer 渲染分层的父节点,如果传入则可以配合showNode上的renderAlternative来进行渲染分层 + */ + LoopList.prototype.init = function (scrollView, renderLayer, cellMaxNum) { + return __awaiter(this, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + cellMaxNum && (this.cellMaxNum = cellMaxNum); + renderLayer && (this.renderLayer = renderLayer); + this.scrollView = scrollView; + return [4 /*yield*/, this.updateBorder()]; + case 1: + _a.sent(); + this.scrollView.node.on("scrolling", this.scrollingListener, this); + return [2 /*return*/]; + } + }); + }); + }; + /**滚动监听 */ + LoopList.prototype.scrollingListener = function () { + this.updateInv--; + if (this.updateInv <= 0) { + this.updateInv = 2; + var showCells = this.updateNodes(); + if (!this.cellMaxNum) { + return; + } + if (!this.lastPos) { + this.lastPos = this.scrollView.content.position.clone(); + } + else { + var offset = this.scrollView.content.position.clone().sub(this.lastPos); + this.lastPos = this.scrollView.content.position.clone(); + var now = cc.sys.now(); + if (!this.lastChange || (now - this.lastChange) > 100) { + this.lastChange = now; + this.dealLoopList(offset, showCells); + } + } + } + }; + /** + * 初始化 + * @param data 数据组 + * @param prefab 预制件 + * @param size 通用尺寸 + * @param anchor cell的锚点 + */ + LoopList.prototype.initData = function (data, prefab, size, anchor) { + if (anchor === void 0) { anchor = cc.v2(0.5, 0.5); } + this.datas = data; + this.size = size; + this.anchor = anchor; + this.prefab = prefab; + var len = this.cellMaxNum ? this.cellMaxNum : data.length; + this.curStartIndex = 0; + for (var i = 0; i < len; ++i) { + var itemCell = this.itemCells[i]; + if (!itemCell) { + var node = new cc.Node('LoopListCell'); + itemCell = this.itemCells[i] = new ItemCell(node, this); + node.setAnchorPoint(anchor); + node.setParent(this.scrollView.content); + } + var data_1 = this.datas[this.curStartIndex + i]; + var cellSize = data_1.size ? data_1.size : size; + itemCell.init(data_1, cellSize, this.curStartIndex + i, i, this); + } + for (var i = data.length, len_1 = this.itemCells.length; i < len_1; ++i) { + this.recircleShowNode(this.itemCells[i].recircle()); + this.itemCells[i].destroy(); + this.itemCells[i] = null; + } + this.updateNodes(); + }; + /** + * 压入新的数据 + * @param datas + */ + LoopList.prototype.pushDatas = function (datas) { + var length = this.datas.length; + for (var i = 0, len = datas.length; i < len; ++i) { + var data = datas[i]; + this.datas.push(data); + var index = length + i; + this.addNodeFromIndex(index); + } + }; + /** + * 插入新的数据 + * @param data + * @param insertIndex + */ + LoopList.prototype.insertData = function (data, insertIndex) { + if (this.datas.length >= insertIndex) { + this.datas.splice(insertIndex, 0, data); + this.addNodeFromIndex(insertIndex); + } + else { + this.pushDatas([data]); + } + }; + /** + * 移除对应数据 + * @param removeIndex + */ + LoopList.prototype.removeData = function (removeIndex) { + var _this = this; + if (this.datas.length >= removeIndex) { + this.datas.splice(removeIndex, 1); + if (this.cellMaxNum) { + var cellIndex_1 = removeIndex - this.curStartIndex; + //在使用范围内 + if (cellIndex_1 >= 0 && cellIndex_1 < this.cellMaxNum) { + var itemCell = this.itemCells[cellIndex_1]; + var nodeSides = getNodeBorder(itemCell, [true, true, true, true]); + var changeSize = cc.size(-itemCell.size.width, -itemCell.size.height); + itemCell.size = cc.size(0, 0); + this.dealChangeSize(itemCell, nodeSides, changeSize).then(function () { + //更新数据 + for (var i = cellIndex_1; i < _this.cellMaxNum; i++) { + var curDataIndex = _this.curStartIndex + i; + var curData = _this.datas[curDataIndex]; + var curCellSize = curData.size ? curData.size : _this.size; + _this.itemCells[i].init(curData, curCellSize, curDataIndex, i, _this); + _this.itemCells[i].updateShowNode(_this.renderLayer); + } + }); + } + } + else { + var itemCell_1 = this.itemCells.splice(removeIndex, 1)[0]; + var nodeSides = getNodeBorder(itemCell_1, [true, true, true, true]); + var changeSize = cc.size(-itemCell_1.size.width, -itemCell_1.size.height); + itemCell_1.size = cc.size(0, 0); + this.dealChangeSize(itemCell_1, nodeSides, changeSize).then(function () { + _this.recircleShowNode(itemCell_1.recircle()); + itemCell_1.node.destroy(); + }); + } + } + }; + /** + * 从某个数据开始更新 + * @param dataIndex + */ + LoopList.prototype.addNodeFromIndex = function (dataIndex) { + return __awaiter(this, void 0, void 0, function () { + var data, cellSize, cellIndex, i, curDataIndex, curData, curCellSize, nodeSides, itemCell_2, nodeSides_1, node, itemCell_3; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + data = this.datas[dataIndex]; + cellSize = data.size ? data.size : this.size; + if (!this.cellMaxNum) return [3 /*break*/, 1]; + cellIndex = dataIndex - this.curStartIndex; + //在使用范围内 + if (cellIndex >= 0 && cellIndex < this.cellMaxNum) { + //更新数据 + for (i = cellIndex; i < this.cellMaxNum; i++) { + curDataIndex = this.curStartIndex + i; + curData = this.datas[curDataIndex]; + curCellSize = curData.size ? curData.size : this.size; + this.itemCells[i].init(curData, curCellSize, curDataIndex, i, this); + this.itemCells[i].updateShowNode(this.renderLayer); + } + nodeSides = null; + itemCell_2 = this.itemCells[cellIndex]; + if (itemCell_2) { + nodeSides = getNodeBorder(itemCell_2, [true, true, true, true]); + itemCell_2.node.width = 0; + itemCell_2.node.height = 0; + this.dealChangeSize(itemCell_2, nodeSides, cellSize).then(function () { + itemCell_2.node.width = cellSize.width; + itemCell_2.node.height = cellSize.height; + }); + } + } + return [3 /*break*/, 4]; + case 1: + nodeSides_1 = null; + if (this.itemCells[dataIndex]) { + nodeSides_1 = getNodeBorder(this.itemCells[dataIndex], [true, true, true, true]); + } + node = new cc.Node('LoopListCell'); + node.setAnchorPoint(this.anchor); + node.setParent(this.scrollView.content); + node.setSiblingIndex(dataIndex); + itemCell_3 = new ItemCell(node, this); + this.itemCells.splice(dataIndex, 0, itemCell_3); + itemCell_3.init(data, cellSize, dataIndex, dataIndex, this); + if (!!nodeSides_1) return [3 /*break*/, 3]; + return [4 /*yield*/, new Promise(function (resolve, reject) { + requestAnimationFrame(function () { + nodeSides_1 = getNodeBorder(itemCell_3, [true, true, true, true]); + resolve(); + }); + })]; + case 2: + _a.sent(); + _a.label = 3; + case 3: + if (nodeSides_1) { + itemCell_3.node.width = 0; + itemCell_3.node.height = 0; + this.dealChangeSize(itemCell_3, nodeSides_1, cellSize).then(function () { + itemCell_3.node.width = cellSize.width; + itemCell_3.node.height = cellSize.height; + }); + } + this.dealItemShow(itemCell_3); + _a.label = 4; + case 4: return [2 /*return*/]; + } + }); + }); + }; + /** + * 处理列表的循环利用 + * @param offset + * @param dataIndexs + */ + LoopList.prototype.dealLoopList = function (offset, showCells) { + var startCell = showCells[0]; + var endCell = showCells[showCells.length - 1]; + if (this.scrollView.vertical) { + /**内容上移 */ + if (offset.y > 0) { + //已经到达最后倒数第二个节点并且还有数据 + if (this.scrollView.content.y >= (-this.itemCells[this.itemCells.length - 2].node.y - this.viewSides.size.height) && endCell.dataIndex < this.datas.length - 2) { + //显示开始数据下标(这里-1是想要顶部留一个itemcell做缓冲) + var showStart = startCell.dataIndex - 1; + //剩余可展示的数据量 + var leave = this.datas.length - showStart; + //计算应该从那个位置开始重新赋值,因为如果直接移动到最上方,数据量不够覆盖所有的cell + var cellStartIndex = Math.max(0, this.itemCells.length - leave); + //计算第一个cell的数据下标 + this.curStartIndex = showStart - cellStartIndex; + var cellTop = getNodeBorder(this.itemCells[startCell.cellIndex], [true]).topSide; + var contentHeight = 0; + var targetY = 0; + var jumpFirst = true; + var showIndex = 0; + for (var i = 0, len = this.itemCells.length; i < len; ++i) { + if (i >= cellStartIndex) { + //将当前已经显示的showNode节点直接重新设置到移动后的节点上 + if (showIndex < showCells.length && !jumpFirst) { + if (showIndex == 0) { + targetY = contentHeight; + } + var showNode = showCells[showIndex].lostShowNode(); + showIndex++; + this.itemCells[i].getShowNode(showNode); + } + jumpFirst = false; + } + var dataIndex = this.curStartIndex + i; + var data = this.datas[dataIndex]; + var cellSize = data.size ? data.size : this.size; + contentHeight += cellSize.height; + this.itemCells[i].init(data, cellSize, dataIndex, i, this); + } + //将content的位置移动到最上方并对齐移动前的状态 + var posY = targetY + (cellTop - this.viewSides.topSide); + this.scrollView.content.setPosition(cc.v3(this.scrollView.content.position.x, posY)); + this.scrollView.scrollToOffset(cc.v2(0, posY + endCell.size.height), 1); + this.lastPos = null; + } + } //内容下移 + else if (offset.y < 0) { + //已经到达第二个节点并且还有数据 + if (this.scrollView.content.y < (-this.itemCells[2].node.y) && startCell.dataIndex > 1) { + //展示的最后一个数据下表,+1是为了在底部预留一部分空间 + var showEndIndex = endCell.dataIndex + 1; + //计算应该从那个位置开始重新赋值,因为如果直接移动到最下方,数据量不够覆盖所有的cell + var cellEndIndex = Math.min(this.itemCells.length - 2, showEndIndex - 1); + //计算第一个cell的数据下标 + this.curStartIndex = Math.max(showEndIndex - (this.itemCells.length - 1), 0); + //将content的位置移动到最下方并对齐移动前的状态 + var cellTop = getNodeBorder(this.itemCells[startCell.cellIndex], [true]).topSide; + var contentHeight = 0; + var showIndex = showCells.length - 1; + for (var i = this.itemCells.length - 1; i >= 0; --i) { + if (i <= cellEndIndex) { + //将当前已经显示的showNode节点直接重新设置到移动后的节点上 + if (showIndex >= 0) { + var showNode = showCells[showIndex].lostShowNode(); + showIndex--; + this.itemCells[i].getShowNode(showNode); + } + else { + showIndex--; + } + } + var dataIndex = this.curStartIndex + i; + var data = this.datas[dataIndex]; + var cellSize = data.size ? data.size : this.size; + if (showIndex < -1) { + contentHeight += cellSize.height; + } + this.itemCells[i].init(data, cellSize, dataIndex, i, this); + } + //将content的位置移动到最下方并对齐移动前的状态 + var posY = contentHeight + (cellTop - this.viewSides.topSide); + this.scrollView.content.setPosition(cc.v3(this.scrollView.content.position.x, posY)); + this.scrollView.scrollToOffset(cc.v2(0, posY - startCell.size.height), 1); + this.lastPos = null; + } + } + } + else if (this.scrollView.horizontal) { + if (offset.x < 0) { + //已经到达最后倒数第二个节点并且还有数据 + if (this.scrollView.content.x <= (-(this.itemCells[this.itemCells.length - 2].node.x - this.viewSides.size.width)) && endCell.dataIndex < this.datas.length - 2) { + //显示开始数据下标(这里-1是想要左侧留一个itemcell做缓冲) + var showStart = startCell.dataIndex - 1; + //剩余可展示的数据量 + var leave = this.datas.length - showStart; + //计算应该从那个位置开始重新赋值,因为如果直接移动到最左侧,数据量不够覆盖所有的cell + var cellStartIndex = Math.max(0, this.itemCells.length - leave); + //计算第一个cell的数据下标 + this.curStartIndex = showStart - cellStartIndex; + var cellLeft = getNodeBorder(this.itemCells[startCell.cellIndex], [false, false, true]).leftSide; + var contentWidth = 0; + var targetX = 0; + var jumpFirst = true; + var showIndex = 0; + for (var i = 0, len = this.itemCells.length; i < len; ++i) { + if (i >= cellStartIndex) { + //将当前已经显示的showNode节点直接重新设置到移动后的节点上 + if (showIndex < showCells.length && !jumpFirst) { + if (showIndex == 0) { + targetX = contentWidth; + } + var showNode = showCells[showIndex].lostShowNode(); + showIndex++; + this.itemCells[i].getShowNode(showNode); + } + jumpFirst = false; + } + var dataIndex = this.curStartIndex + i; + var data = this.datas[dataIndex]; + var cellSize = data.size ? data.size : this.size; + contentWidth += cellSize.width; + this.itemCells[i].init(data, cellSize, dataIndex, i, this); + } + //将content的位置移动到最左侧并对齐移动前的状态 + var posX = (cellLeft - this.viewSides.leftSide) - targetX; + this.scrollView.content.setPosition(cc.v3(posX, this.scrollView.content.position.y)); + this.scrollView.scrollToOffset(cc.v2(-(posX - endCell.size.width), 0), 1); + this.lastPos = null; + } + } + else if (offset.x > 0) { + //已经到达第二个节点并且还有数据 + if (this.scrollView.content.x > (-this.itemCells[2].node.x) && startCell.dataIndex > 1) { + //展示的最后一个数据下表,+1是为了在右侧预留一部分空间 + var showEndIndex = endCell.dataIndex + 1; + //计算应该从那个位置开始重新赋值,因为如果直接移动到最右侧,数据量不够覆盖所有的cell + var cellEndIndex = Math.min(this.itemCells.length - 2, showEndIndex - 1); + //计算第一个cell的数据下标 + this.curStartIndex = Math.max(showEndIndex - (this.itemCells.length - 1), 0); + //将content的位置移动到最右侧并对齐移动前的状态 + var cellLeft = getNodeBorder(this.itemCells[startCell.cellIndex], [false, false, true]).leftSide; + var contentWidth = 0; + var showIndex = showCells.length - 1; + for (var i = this.itemCells.length - 1; i >= 0; --i) { + if (i <= cellEndIndex) { + //将当前已经显示的showNode节点直接重新设置到移动后的节点上 + if (showIndex >= 0) { + var showNode = showCells[showIndex].lostShowNode(); + showIndex--; + this.itemCells[i].getShowNode(showNode); + } + else { + showIndex--; + } + } + var dataIndex = this.curStartIndex + i; + var data = this.datas[dataIndex]; + var cellSize = data.size ? data.size : this.size; + if (showIndex < -1) { + contentWidth += cellSize.width; + } + this.itemCells[i].init(data, cellSize, dataIndex, i, this); + } + //将content的位置移动到最右侧并对齐移动前的状态 + var posX = (cellLeft - this.viewSides.leftSide) - contentWidth; + this.scrollView.content.setPosition(cc.v3(posX, this.scrollView.content.position.y)); + this.scrollView.scrollToOffset(cc.v2(-(posX + startCell.size.width), 0), 1); + this.lastPos = null; + } + } + } + }; + /**更新节点的显示 */ + LoopList.prototype.updateNodes = function () { + var showCells = []; + for (var i = 0, len = this.itemCells.length; i < len; ++i) { + var itemCell = this.itemCells[i]; + var isShow = this.dealItemShow(itemCell); + if (isShow) { + showCells.push(itemCell); + } + } + return showCells; + }; + /** + * 处理cell的显示隐藏 + * @param itemCell + */ + LoopList.prototype.dealItemShow = function (itemCell) { + if (itemCell) { + var isShow = this.checkInView(itemCell); + if (isShow) { + itemCell.hasNoNode && itemCell.updateShow(isShow, this.prefab, this.showNodePool.length > 0 ? this.showNodePool.pop() : null, this.renderLayer); + } + else { + !itemCell.hasNoNode && this.recircleShowNode(itemCell.recircle()); + } + return isShow; + } + }; + /** + * 检查是否在屏幕内 + * @param node + * @returns + */ + LoopList.prototype.checkInView = function (itemCell) { + var nodeSides = getNodeBorder(itemCell, [true, true, true, true]); + //节点右侧边缘在屏幕左侧外面或者节点左边缘在屏幕右侧外面 则不在显示区域 + var horizontalOutside = nodeSides.rightSide < this.viewSides.leftSide + || nodeSides.leftSide > this.viewSides.rightSide; + var verticalOutside = false; + if (!horizontalOutside) { + //节点上边缘在屏幕下方外面或者节点下边缘在屏幕上方外面 则不在显示区域 + verticalOutside = nodeSides.topSide < this.viewSides.bottomSide + || nodeSides.bottomSide > this.viewSides.topSide; + } + return !horizontalOutside && !verticalOutside; + }; + /** + * 处理变化的大小 + * @param cell + * @param nodeSides + * @param changeSize + */ + LoopList.prototype.dealChangeSize = function (cell, nodeSides, changeSize, time) { + if (time === void 0) { time = 0.3; } + return __awaiter(this, void 0, void 0, function () { + var topToBottomFulfill, bottomToTopFulfill, leftToRightFulfill, RightToLeftFulfill; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + topToBottomFulfill = (this.scrollView.content.anchorY == 1 && nodeSides.bottomSide >= this.viewSides.topSide); + bottomToTopFulfill = (this.scrollView.content.anchorY == 0 && nodeSides.topSide <= this.viewSides.bottomSide); + if (topToBottomFulfill || bottomToTopFulfill) { + if (topToBottomFulfill) { + this.scrollView.setContentPosition(cc.v2(this.scrollView.content.x, this.scrollView.content.y + changeSize.height)); + } + else { + this.scrollView.setContentPosition(cc.v2(this.scrollView.content.x, this.scrollView.content.y - changeSize.height)); + } + } + leftToRightFulfill = (this.scrollView.content.anchorX == 0 && nodeSides.rightSide <= this.viewSides.leftSide); + RightToLeftFulfill = (this.scrollView.content.anchorX == 1 && nodeSides.leftSide >= this.viewSides.rightSide); + if (leftToRightFulfill || RightToLeftFulfill) { + if (RightToLeftFulfill) { + this.scrollView.setContentPosition(cc.v2(this.scrollView.content.x + changeSize.width, this.scrollView.content.y)); + } + else { + this.scrollView.setContentPosition(cc.v2(this.scrollView.content.x - changeSize.width, this.scrollView.content.y)); + } + } + if (!!(topToBottomFulfill || bottomToTopFulfill || leftToRightFulfill || RightToLeftFulfill)) return [3 /*break*/, 2]; + cc.Tween.stopAllByTarget(cell.node); + return [4 /*yield*/, new Promise(function (resolve, reject) { + cc.tween(cell.node).to(time, { width: cell.size.width, height: cell.size.height }).call(function () { + resolve(); + }).start(); + })]; + case 1: + _a.sent(); + _a.label = 2; + case 2: + this.updateNodes(); + return [2 /*return*/, true]; + } + }); + }); + }; + /** + * 回收显示节点 + * @param node + */ + LoopList.prototype.recircleShowNode = function (node) { + node && this.showNodePool.push(node); + }; + /** + * 释放当前列表 + */ + LoopList.prototype.freeList = function () { + this.scrollView.node.off("scrolling", this.scrollingListener); + for (var i = 0, len = this.itemCells.length; i < len; ++i) { + this.recircleShowNode(this.itemCells[i].recircle()); + this.itemCells[i].destroy(); + } + this.itemCells = []; + for (var index = 0, len = this.showNodePool.length; index < len; ++index) { + this.showNodePool[index].destroy(); + } + this.showNodePool = []; + this.renderLayer = null; + this.scrollView = null; + this.prefab = null; + }; + LoopList.insMap = new Map(); + return LoopList; +}()); +exports.default = LoopList; +/** + * 获取节点的边缘 + * @param node + * @param needArr 顺序是上 下 左 右 + */ +function getNodeBorder(cell, needArr) { + var node = cell.node; + var boderData = {}; + var wpos = getNodeWPos(node); + //显示区域上边缘 + if (needArr[0]) { + boderData.topSide = wpos.y + (node.height * (1 - node.anchorY)); + } + //显示区域下边缘 + if (needArr[1]) { + boderData.bottomSide = wpos.y - (node.height * node.anchorY); + } + //显示区域左边缘 + if (needArr[2]) { + boderData.leftSide = wpos.x - (node.width * node.anchorX); + } + //显示区域右边缘 + if (needArr[3]) { + boderData.rightSide = wpos.x + (node.width * (1 - node.anchorX)); + } + boderData.size = cc.size(node.width, node.height); + return boderData; +} +/** + * 获取节点世界坐标 + * @param node + * @returns + */ +function getNodeWPos(node) { + return node.parent.convertToWorldSpaceAR(node.position); +} + +cc._RF.pop(); \ No newline at end of file diff --git a/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Script/LoopList.js.map b/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Script/LoopList.js.map new file mode 100644 index 0000000..f2c10e0 --- /dev/null +++ b/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Script/LoopList.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["assets\\Script\\LoopList.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yDAAoD;AAUpD;IAA+C,4BAAY;IAA3D;QAAA,qEAgFC;QA/EG,gBAAgB;QACR,aAAO,GAAY,KAAK,CAAC;;IA8ErC,CAAC;IAvEG,SAAS;IACF,uBAAI,GAAX,UAAY,IAAiB,EAAE,IAAO,EAAE,WAAoB;QACxD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,IAAI,CAAC,WAAW,IAAI,WAAW,EAAE;YACjC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;YAC/B,WAAW,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;SACrC;QACD,IAAI,CAAC,QAAQ,EAAE,CAAC;IACpB,CAAC;IACD,WAAW;IACX,2BAAQ,GAAR,cAAa,CAAC;IACd,oBAAoB;IACpB,6BAAU,GAAV,cAAe,CAAC;IAEhB;;;;OAIG;IACI,yBAAM,GAAb,UAAc,UAAmB,EAAE,IAAkB;QAAlB,qBAAA,EAAA,UAAkB;QACjD,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;IACvC,CAAC;IACD;;OAEG;IACK,8BAAW,GAAnB;QACI,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,WAAW,EAAE;YACnC,IAAI,OAAO,GAAwC,IAAI,OAAO,EAAE,CAAC;YACjE,IAAI,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC7B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,GAAG,GAAG,EAAE,EAAE,CAAC,EAAE;gBAC7C,IAAI,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;gBAC1B,IAAI,WAAW,GAAsB,IAAI,CAAC;gBAC1C,IAAI,KAAK,YAAY,EAAE,CAAC,IAAI,EAAE;oBAC1B,WAAW,GAAG,KAAK,CAAC,YAAY,CAAC,2BAAiB,CAAC,CAAC;oBACpD,IAAI,WAAW,EAAE;wBACb,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;qBACtC;iBACJ;qBAAM,IAAI,KAAK,YAAY,EAAE,CAAC,eAAe,EAAE;oBAC5C,WAAW,GAAG,KAAK,CAAC,YAAY,CAAC,2BAAiB,CAAC,CAAC;oBACpD,IAAI,WAAW,EAAE;wBACb,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,IAAI,CAAe,IAAI,CAAC,WAAW,CAAC,CAAC;qBACpE;iBACJ;gBACD,WAAW,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;aACjD;YACD,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;YACtD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;SACvB;IACL,CAAC;IACD;;;;;;OAMG;IACH,yCAAsB,GAAtB,UAAuB,IAAa,EAAE,OAA4C,EAAE,YAAoB,EAAE,KAAa;;QACnH,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE;YACtD,IAAI,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;YAChC,IAAI,WAAW,SAAG,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC,eAAe,CAAC,0CAAE,YAAY,CAAC,2BAAiB,CAAC,CAAC;YAC7F,IAAI,MAAM,GAAG,YAAY,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;YACvD,IAAI,WAAW,EAAE;gBACb,IAAI,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,EAAE;oBAC1D,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;iBACtC;gBACD,WAAW,CAAC,MAAM,GAAG,MAAM,CAAC;aAC/B;YACD,IAAI,CAAC,sBAAsB,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;SACrE;IACL,CAAC;IACL,eAAC;AAAD,CAhFA,AAgFC,CAhF8C,EAAE,CAAC,SAAS,GAgF1D;AAhFY,4BAAQ;AAiFrB;IAeI;;;;OAIG;IACH,kBAAY,IAAa,EAAE,QAAqB;QAnBhD,iBAAiB;QACV,aAAQ,GAAgB,IAAI,CAAC;QACpC,UAAU;QACH,SAAI,GAAY,IAAI,CAAC;QAC5B,UAAU;QACH,aAAQ,GAAgB,IAAI,CAAC;QACpC,QAAQ;QACD,SAAI,GAAY,IAAI,CAAC;QAC5B,UAAU;QACH,cAAS,GAAW,IAAI,CAAC;QAChC,YAAY;QACL,cAAS,GAAW,IAAI,CAAC;QAChC,QAAQ;QACD,SAAI,GAAM,IAAI,CAAC;QAOlB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC7B,CAAC;IAED;;;;;;;OAOG;IACI,uBAAI,GAAX,UAAY,IAAO,EAAE,IAAa,EAAE,SAAiB,EAAE,SAAiB,EAAE,QAAqB;QAC3F,EAAE,CAAC,KAAK,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACpC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QAC7B,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC/B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACrB,CAAC;IACD;;;OAGG;IACH,yBAAM,GAAN,UAAO,IAAa,EAAE,IAAY;QAAlC,iBASC;QARG,IAAI,SAAS,GAAG,aAAa,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;QAC9D,IAAI,UAAU,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACvF,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC;YACjE,KAAI,CAAC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;YAC7B,KAAI,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;YAC/B,KAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC;QAChC,CAAC,CAAC,CAAC;IACP,CAAC;IAED;;;;;;OAMG;IACH,6BAAU,GAAV,UAAW,MAAe,EAAE,MAAiB,EAAE,SAAsB,EAAE,WAAoB;QACvF,IAAI,MAAM,EAAE;YACR,UAAU;YACV,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;gBAChB,iBAAiB;gBACjB,IAAI,SAAS,EAAE;oBACX,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAC;iBAC7B;qBAAM,EAAC,gBAAgB;oBACpB,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;iBACjE;gBACD,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACxC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC;gBACtC,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;aACpC;SACJ;IACL,CAAC;IACD;;;OAGG;IACH,iCAAc,GAAd,UAAe,WAAoB;QAC/B,SAAS;QACT,IAAI,IAAI,CAAC,QAAQ,EAAE;YACf,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;SACpD;IACL,CAAC;IAED,sBAAI,+BAAS;aAAb;YACI,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC;QAC1B,CAAC;;;OAAA;IAED,2BAAQ,GAAR;QACI,IAAI,IAAI,CAAC,QAAQ,EAAE;YACf,IAAI,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC;YACzB,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,UAAU,EAAE,CAAC;YAClD,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;YAC3C,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;YACrB,OAAO,IAAI,CAAC;SACf;IACL,CAAC;IAGD,0BAAO,GAAP;QACI,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;QACpB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;IACzB,CAAC;IAED;;;OAGG;IACH,+BAAY,GAAZ;QACI,IAAI,IAAI,CAAC,QAAQ,EAAE;YACf,IAAI,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC;YACzB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;YAC3C,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;YACrB,OAAO,IAAI,CAAC;SACf;IACL,CAAC;IAED;;;OAGG;IACH,8BAAW,GAAX,UAAY,QAAqB;QAC7B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACnC,IAAI,CAAC,QAAQ,CAAC,IAAI,GAAG,IAAI,CAAC;IAC9B,CAAC;IACL,eAAC;AAAD,CAvIA,AAuIC,IAAA;AAvIY,4BAAQ;AAyIrB;;;GAGG;AACH;IAAA;QAQI,iDAAiD;QACzC,gBAAW,GAAY,IAAI,CAAC;QACpC,UAAU;QACF,eAAU,GAAkB,IAAI,CAAC;QACzC,gBAAgB;QACR,eAAU,GAAW,IAAI,CAAC;QAClC,UAAU;QACF,kBAAa,GAAW,IAAI,CAAC;QACrC,QAAQ;QACA,UAAK,GAAQ,EAAE,CAAC;QACxB,aAAa;QACL,cAAS,GAAkB,EAAE,CAAC;QACtC,SAAS;QACD,WAAM,GAAc,IAAI,CAAC;QACjC,aAAa;QACL,iBAAY,GAAkB,EAAE,CAAC;QACzC,UAAU;QACF,cAAS,GAAY,EAAE,CAAC;QAChC,gBAAgB;QACT,YAAO,GAAY,IAAI,CAAC;QAC/B,eAAe;QACR,cAAS,GAAW,CAAC,CAAC;QAC7B,iBAAiB;QACV,eAAU,GAAW,CAAC,CAAC;QAC9B,UAAU;QACH,SAAI,GAAY,IAAI,CAAC;QAC5B,UAAU;QACH,WAAM,GAAY,IAAI,CAAC;IAyhBlC,CAAC;IA1jBiB,YAAG,GAAjB,UAAqB,QAAgB;QACjC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;YAC5B,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,QAAQ,EAAK,CAAC,CAAC;SAChD;QACD,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAgB,CAAC;IACpD,CAAC;IA8BD,yBAAM,GAAN;QACI,IAAI,CAAC,YAAY,EAAE,CAAA;IACvB,CAAC;IAED;;OAEG;IACI,+BAAY,GAAnB;QAAA,iBAwBC;QAvBG,IAAI,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;QACvD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC;QAC/C,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC;QAC/C,6BAA6B;QAC7B,OAAO,IAAI,OAAO,CAAO,UAAC,OAAO,EAAE,MAAM;YACrC,qBAAqB,CAAC;gBAClB,IAAI,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;gBAC7B,SAAS;gBACT,IAAI,QAAQ,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC;gBACpD,SAAS;gBACT,IAAI,SAAS,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;gBAC3D,SAAS;gBACT,IAAI,UAAU,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC;gBACvD,SAAS;gBACT,IAAI,OAAO,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;gBAC1D,KAAI,CAAC,SAAS,GAAG;oBACb,QAAQ,UAAA,EAAE,SAAS,WAAA,EAAE,UAAU,YAAA,EAAE,OAAO,SAAA;oBAAE,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC;iBACnF,CAAC;gBACF,KAAI,CAAC,UAAU,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;gBACjD,OAAO,EAAE,CAAC;YACd,CAAC,CAAC,CAAA;QACN,CAAC,CAAC,CAAA;IAEN,CAAC;IAED;;;;;OAKG;IACG,uBAAI,GAAV,UAAW,UAAyB,EAAE,WAAqB,EAAE,UAAmB;;;;;wBAC5E,UAAU,IAAI,CAAC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC,CAAC;wBAC7C,WAAW,IAAI,CAAC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC,CAAC;wBAChD,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;wBAC7B,qBAAM,IAAI,CAAC,YAAY,EAAE,EAAA;;wBAAzB,SAAyB,CAAC;wBAC1B,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,WAAW,EAAE,IAAI,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC;;;;;KACtE;IAED,UAAU;IACV,oCAAiB,GAAjB;QACI,IAAI,CAAC,SAAS,EAAE,CAAC;QACjB,IAAI,IAAI,CAAC,SAAS,IAAI,CAAC,EAAE;YACrB,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC;YACnB,IAAI,SAAS,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;YAEnC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE;gBAClB,OAAO;aACV;YACD,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;gBACf,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;aAC3D;iBAAM;gBACH,IAAI,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;gBACxE,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;gBACxD,IAAI,GAAG,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;gBACvB,IAAI,CAAC,IAAI,CAAC,UAAU,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,GAAG,EAAE;oBACnD,IAAI,CAAC,UAAU,GAAG,GAAG,CAAC;oBACtB,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;iBACxC;aACJ;SACJ;IACL,CAAC;IACD;;;;;;OAMG;IACI,2BAAQ,GAAf,UAAgB,IAAS,EAAE,MAAiB,EAAE,IAAc,EAAE,MAAiC;QAAjC,uBAAA,EAAA,SAAkB,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC;QAC3F,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC;QAC1D,IAAI,CAAC,aAAa,GAAG,CAAC,CAAC;QACvB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,EAAE,EAAE,CAAC,EAAE;YAC1B,IAAI,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;YACjC,IAAI,CAAC,QAAQ,EAAE;gBACX,IAAI,IAAI,GAAG,IAAI,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,CAAA;gBACtC,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,IAAI,QAAQ,CAAI,IAAI,EAAE,IAAI,CAAC,CAAC;gBAC3D,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;gBAC5B,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;aAC3C;YACD,IAAI,MAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,GAAG,CAAC,CAAC,CAAC;YAC9C,IAAI,QAAQ,GAAG,MAAI,CAAC,IAAI,CAAC,CAAC,CAAC,MAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;YAC5C,QAAQ,CAAC,IAAI,CAAC,MAAI,EAAE,QAAQ,EAAE,IAAI,CAAC,aAAa,GAAG,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;SAClE;QACD,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,KAAG,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,GAAG,KAAG,EAAE,EAAE,CAAC,EAAE;YACjE,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;YACpD,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAA;YAC3B,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;SAC5B;QACD,IAAI,CAAC,WAAW,EAAE,CAAC;IACvB,CAAC;IAED;;;OAGG;IACI,4BAAS,GAAhB,UAAiB,KAAU;QACvB,IAAI,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;QAC/B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,GAAG,GAAG,EAAE,EAAE,CAAC,EAAE;YAC9C,IAAI,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;YACpB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACtB,IAAI,KAAK,GAAG,MAAM,GAAG,CAAC,CAAC;YACvB,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;SAChC;IACL,CAAC;IACD;;;;OAIG;IACI,6BAAU,GAAjB,UAAkB,IAAO,EAAE,WAAmB;QAC1C,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,WAAW,EAAE;YAClC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;YACxC,IAAI,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC;SACtC;aAAM;YACH,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;SAC1B;IACL,CAAC;IACD;;;OAGG;IACI,6BAAU,GAAjB,UAAkB,WAAmB;QAArC,iBAiCC;QAhCG,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,WAAW,EAAE;YAClC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;YAClC,IAAI,IAAI,CAAC,UAAU,EAAE;gBACjB,IAAI,WAAS,GAAG,WAAW,GAAG,IAAI,CAAC,aAAa,CAAC;gBACjD,QAAQ;gBACR,IAAI,WAAS,IAAI,CAAC,IAAI,WAAS,GAAG,IAAI,CAAC,UAAU,EAAE;oBAC/C,IAAI,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,WAAS,CAAC,CAAC;oBACzC,IAAI,SAAS,GAAG,aAAa,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;oBAClE,IAAI,UAAU,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;oBACtE,QAAQ,CAAC,IAAI,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;oBAC9B,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC,IAAI,CAAC;wBACtD,MAAM;wBACN,KAAK,IAAI,CAAC,GAAG,WAAS,EAAE,CAAC,GAAG,KAAI,CAAC,UAAU,EAAE,CAAC,EAAE,EAAE;4BAC9C,IAAI,YAAY,GAAG,KAAI,CAAC,aAAa,GAAG,CAAC,CAAC;4BAC1C,IAAI,OAAO,GAAG,KAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;4BACvC,IAAI,WAAW,GAAY,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,KAAI,CAAC,IAAI,CAAC;4BACnE,KAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC,EAAE,KAAI,CAAC,CAAC;4BACpE,KAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,KAAI,CAAC,WAAW,CAAC,CAAC;yBACtD;oBACL,CAAC,CAAC,CAAC;iBACN;aACJ;iBAAM;gBACH,IAAI,UAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBACxD,IAAI,SAAS,GAAG,aAAa,CAAC,UAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;gBAClE,IAAI,UAAU,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,UAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,UAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;gBACtE,UAAQ,CAAC,IAAI,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;gBAC9B,IAAI,CAAC,cAAc,CAAC,UAAQ,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC,IAAI,CAAC;oBACtD,KAAI,CAAC,gBAAgB,CAAC,UAAQ,CAAC,QAAQ,EAAE,CAAC,CAAA;oBAC1C,UAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;gBAC5B,CAAC,CAAC,CAAC;aACN;SACJ;IACL,CAAC;IACD;;;OAGG;IACW,mCAAgB,GAA9B,UAA+B,SAAiB;;;;;;wBACxC,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;wBAC7B,QAAQ,GAAY,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;6BAEtD,IAAI,CAAC,UAAU,EAAf,wBAAe;wBACX,SAAS,GAAG,SAAS,GAAG,IAAI,CAAC,aAAa,CAAC;wBAC/C,QAAQ;wBACR,IAAI,SAAS,IAAI,CAAC,IAAI,SAAS,GAAG,IAAI,CAAC,UAAU,EAAE;4BAC/C,MAAM;4BACN,KAAS,CAAC,GAAG,SAAS,EAAE,CAAC,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC,EAAE,EAAE;gCAC1C,YAAY,GAAG,IAAI,CAAC,aAAa,GAAG,CAAC,CAAC;gCACtC,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;gCACnC,WAAW,GAAY,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;gCACnE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;gCACpE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;6BACtD;4BAEG,SAAS,GAAY,IAAI,CAAC;4BAC1B,aAAwB,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;4BACtD,IAAI,UAAQ,EAAE;gCACV,SAAS,GAAG,aAAa,CAAC,UAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;gCAC9D,UAAQ,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;gCACxB,UAAQ,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;gCACzB,IAAI,CAAC,cAAc,CAAC,UAAQ,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC,IAAI,CAAC;oCACpD,UAAQ,CAAC,IAAI,CAAC,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC;oCACrC,UAAQ,CAAC,IAAI,CAAC,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC;gCAC3C,CAAC,CAAC,CAAC;6BACN;yBACJ;;;wBAGG,cAAqB,IAAI,CAAC;wBAC9B,IAAI,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE;4BAC3B,WAAS,GAAG,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;yBAClF;wBACG,IAAI,GAAG,IAAI,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,CAAA;wBACtC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;wBACjC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;wBACxC,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;wBAC5B,aAAwB,IAAI,QAAQ,CAAI,IAAI,EAAE,IAAI,CAAC,CAAC;wBACxD,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,EAAE,UAAQ,CAAC,CAAA;wBAC7C,UAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;6BACtD,CAAC,WAAS,EAAV,wBAAU;wBACV,qBAAM,IAAI,OAAO,CAAO,UAAC,OAAO,EAAE,MAAM;gCACpC,qBAAqB,CAAC;oCAClB,WAAS,GAAG,aAAa,CAAC,UAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;oCAC9D,OAAO,EAAE,CAAC;gCACd,CAAC,CAAC,CAAA;4BACN,CAAC,CAAC,EAAA;;wBALF,SAKE,CAAC;;;wBAEP,IAAI,WAAS,EAAE;4BACX,UAAQ,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;4BACxB,UAAQ,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;4BACzB,IAAI,CAAC,cAAc,CAAC,UAAQ,EAAE,WAAS,EAAE,QAAQ,CAAC,CAAC,IAAI,CAAC;gCACpD,UAAQ,CAAC,IAAI,CAAC,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC;gCACrC,UAAQ,CAAC,IAAI,CAAC,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC;4BAC3C,CAAC,CAAC,CAAC;yBACN;wBACD,IAAI,CAAC,YAAY,CAAC,UAAQ,CAAC,CAAC;;;;;;KAEnC;IAED;;;;OAIG;IACK,+BAAY,GAApB,UAAqB,MAAe,EAAE,SAAwB;QAC1D,IAAI,SAAS,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;QAC7B,IAAI,OAAO,GAAG,SAAS,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAC9C,IAAI,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE;YAC1B,UAAU;YACV,IAAI,MAAM,CAAC,CAAC,GAAG,CAAC,EAAE;gBACd,qBAAqB;gBACrB,IAAI,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;oBAC7J,mCAAmC;oBACnC,IAAI,SAAS,GAAG,SAAS,CAAC,SAAS,GAAG,CAAC,CAAC;oBACxC,YAAY;oBACZ,IAAI,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC;oBAC1C,6CAA6C;oBAC7C,IAAI,cAAc,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC;oBAChE,gBAAgB;oBAChB,IAAI,CAAC,aAAa,GAAG,SAAS,GAAG,cAAc,CAAC;oBAEhD,IAAI,OAAO,GAAG,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC;oBAEjF,IAAI,aAAa,GAAG,CAAC,CAAC;oBACtB,IAAI,OAAO,GAAG,CAAC,CAAC;oBAChB,IAAI,SAAS,GAAG,IAAI,CAAC;oBACrB,IAAI,SAAS,GAAG,CAAC,CAAC;oBAClB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,GAAG,GAAG,EAAE,EAAE,CAAC,EAAE;wBACvD,IAAI,CAAC,IAAI,cAAc,EAAE;4BACrB,kCAAkC;4BAClC,IAAI,SAAS,GAAG,SAAS,CAAC,MAAM,IAAI,CAAC,SAAS,EAAE;gCAC5C,IAAI,SAAS,IAAI,CAAC,EAAE;oCAChB,OAAO,GAAG,aAAa,CAAC;iCAC3B;gCACD,IAAI,QAAQ,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC,YAAY,EAAE,CAAC;gCACnD,SAAS,EAAE,CAAC;gCACZ,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;6BAC3C;4BACD,SAAS,GAAG,KAAK,CAAC;yBACrB;wBACD,IAAI,SAAS,GAAG,IAAI,CAAC,aAAa,GAAG,CAAC,CAAC;wBACvC,IAAI,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;wBACjC,IAAI,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;wBACjD,aAAa,IAAI,QAAQ,CAAC,MAAM,CAAC;wBACjC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;qBAC9D;oBAED,4BAA4B;oBAC5B,IAAI,IAAI,GAAG,OAAO,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAA;oBACvD,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;oBACrF,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAA;oBACvE,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;iBACvB;aACJ,CAAC,MAAM;iBACH,IAAI,MAAM,CAAC,CAAC,GAAG,CAAC,EAAE;gBACnB,iBAAiB;gBACjB,IAAI,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,SAAS,CAAC,SAAS,GAAG,CAAC,EAAE;oBACrF,6BAA6B;oBAC7B,IAAI,YAAY,GAAG,OAAO,CAAC,SAAS,GAAG,CAAC,CAAC;oBACzC,6CAA6C;oBAC7C,IAAI,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,YAAY,GAAG,CAAC,CAAC,CAAC;oBACzE,gBAAgB;oBAChB,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,GAAG,CAAC,YAAY,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;oBAE7E,4BAA4B;oBAC5B,IAAI,OAAO,GAAG,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC;oBAEjF,IAAI,aAAa,GAAG,CAAC,CAAC;oBACtB,IAAI,SAAS,GAAG,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;oBACrC,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,EAAE;wBACjD,IAAI,CAAC,IAAI,YAAY,EAAE;4BACnB,kCAAkC;4BAClC,IAAI,SAAS,IAAI,CAAC,EAAE;gCAChB,IAAI,QAAQ,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC,YAAY,EAAE,CAAC;gCACnD,SAAS,EAAE,CAAC;gCACZ,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;6BAC3C;iCAAM;gCACH,SAAS,EAAE,CAAC;6BACf;yBACJ;wBACD,IAAI,SAAS,GAAG,IAAI,CAAC,aAAa,GAAG,CAAC,CAAC;wBACvC,IAAI,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;wBACjC,IAAI,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;wBACjD,IAAI,SAAS,GAAG,CAAC,CAAC,EAAE;4BAChB,aAAa,IAAI,QAAQ,CAAC,MAAM,CAAC;yBACpC;wBACD,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;qBAC9D;oBAED,4BAA4B;oBAC5B,IAAI,IAAI,GAAG,aAAa,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAA;oBAC7D,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;oBACrF,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAA;oBACzE,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;iBACvB;aACJ;SACJ;aAAM,IAAI,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE;YACnC,IAAI,MAAM,CAAC,CAAC,GAAG,CAAC,EAAE;gBACd,qBAAqB;gBACrB,IAAI,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAE,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;oBAC9J,mCAAmC;oBACnC,IAAI,SAAS,GAAG,SAAS,CAAC,SAAS,GAAG,CAAC,CAAC;oBACxC,YAAY;oBACZ,IAAI,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC;oBAC1C,6CAA6C;oBAC7C,IAAI,cAAc,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC;oBAChE,gBAAgB;oBAChB,IAAI,CAAC,aAAa,GAAG,SAAS,GAAG,cAAc,CAAC;oBAEhD,IAAI,QAAQ,GAAG,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC;oBAEjG,IAAI,YAAY,GAAG,CAAC,CAAC;oBACrB,IAAI,OAAO,GAAG,CAAC,CAAC;oBAChB,IAAI,SAAS,GAAG,IAAI,CAAC;oBACrB,IAAI,SAAS,GAAG,CAAC,CAAC;oBAClB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,GAAG,GAAG,EAAE,EAAE,CAAC,EAAE;wBACvD,IAAI,CAAC,IAAI,cAAc,EAAE;4BACrB,kCAAkC;4BAClC,IAAI,SAAS,GAAG,SAAS,CAAC,MAAM,IAAI,CAAC,SAAS,EAAE;gCAC5C,IAAI,SAAS,IAAI,CAAC,EAAE;oCAChB,OAAO,GAAG,YAAY,CAAC;iCAC1B;gCACD,IAAI,QAAQ,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC,YAAY,EAAE,CAAC;gCACnD,SAAS,EAAE,CAAC;gCACZ,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;6BAC3C;4BACD,SAAS,GAAG,KAAK,CAAC;yBACrB;wBACD,IAAI,SAAS,GAAG,IAAI,CAAC,aAAa,GAAG,CAAC,CAAC;wBACvC,IAAI,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;wBACjC,IAAI,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;wBACjD,YAAY,IAAI,QAAQ,CAAC,KAAK,CAAC;wBAC/B,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;qBAC9D;oBAED,4BAA4B;oBAC5B,IAAI,IAAI,GAAG,CAAC,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC;oBAC1D,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;oBACrF,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;oBACzE,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;iBACvB;aACJ;iBAAM,IAAI,MAAM,CAAC,CAAC,GAAG,CAAC,EAAE;gBACrB,iBAAiB;gBACjB,IAAI,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,SAAS,CAAC,SAAS,GAAG,CAAC,EAAE;oBACpF,6BAA6B;oBAC7B,IAAI,YAAY,GAAG,OAAO,CAAC,SAAS,GAAG,CAAC,CAAC;oBACzC,6CAA6C;oBAC7C,IAAI,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,YAAY,GAAG,CAAC,CAAC,CAAC;oBACzE,gBAAgB;oBAChB,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,GAAG,CAAC,YAAY,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;oBAE7E,4BAA4B;oBAC5B,IAAI,QAAQ,GAAG,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC;oBAEjG,IAAI,YAAY,GAAG,CAAC,CAAC;oBACrB,IAAI,SAAS,GAAG,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;oBACrC,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,EAAE;wBACjD,IAAI,CAAC,IAAI,YAAY,EAAE;4BACnB,kCAAkC;4BAClC,IAAI,SAAS,IAAI,CAAC,EAAE;gCAChB,IAAI,QAAQ,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC,YAAY,EAAE,CAAC;gCACnD,SAAS,EAAE,CAAC;gCACZ,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;6BAC3C;iCAAM;gCACH,SAAS,EAAE,CAAC;6BACf;yBACJ;wBACD,IAAI,SAAS,GAAG,IAAI,CAAC,aAAa,GAAG,CAAC,CAAC;wBACvC,IAAI,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;wBACjC,IAAI,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;wBACjD,IAAI,SAAS,GAAG,CAAC,CAAC,EAAE;4BAChB,YAAY,IAAI,QAAQ,CAAC,KAAK,CAAC;yBAClC;wBACD,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;qBAC9D;oBAED,4BAA4B;oBAC5B,IAAI,IAAI,GAAG,CAAC,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,YAAY,CAAC;oBAC/D,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;oBACrF,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,EAAE,CAAC,EAAE,CAAC,CAAE,CAAC,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;oBAC5E,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;iBACvB;aACJ;SACJ;IACL,CAAC;IAGD,aAAa;IACN,8BAAW,GAAlB;QACI,IAAI,SAAS,GAAkB,EAAE,CAAC;QAClC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,GAAG,GAAG,EAAE,EAAE,CAAC,EAAE;YACvD,IAAI,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;YACjC,IAAI,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAA;YACxC,IAAI,MAAM,EAAE;gBACR,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;aAC3B;SACJ;QACD,OAAO,SAAS,CAAC;IACrB,CAAC;IAED;;;OAGG;IACK,+BAAY,GAApB,UAAqB,QAAqB;QACtC,IAAI,QAAQ,EAAE;YACV,IAAI,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;YACxC,IAAI,MAAM,EAAE;gBACR,QAAQ,CAAC,SAAS,IAAI,QAAQ,CAAC,UAAU,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;aACnJ;iBAAM;gBACH,CAAC,QAAQ,CAAC,SAAS,IAAI,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC;aACrE;YACD,OAAO,MAAM,CAAC;SACjB;IACL,CAAC;IAGD;;;;OAIG;IACK,8BAAW,GAAnB,UAAoB,QAAqB;QACrC,IAAI,SAAS,GAAG,aAAa,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;QAClE,qCAAqC;QACrC,IAAI,iBAAiB,GAAG,SAAS,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ;eAC9D,SAAS,CAAC,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC;QAErD,IAAI,eAAe,GAAG,KAAK,CAAC;QAC5B,IAAI,CAAC,iBAAiB,EAAE;YACpB,oCAAoC;YACpC,eAAe,GAAG,SAAS,CAAC,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU;mBACxD,SAAS,CAAC,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;SACxD;QACD,OAAO,CAAC,iBAAiB,IAAI,CAAC,eAAe,CAAC;IAClD,CAAC;IACD;;;;;OAKG;IACU,iCAAc,GAA3B,UAA4B,IAAiB,EAAE,SAAkB,EAAE,UAAmB,EAAE,IAAkB;QAAlB,qBAAA,EAAA,UAAkB;;;;;;wBAClG,kBAAkB,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,OAAO,IAAI,CAAC,IAAI,SAAS,CAAC,UAAU,IAAI,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;wBAC9G,kBAAkB,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,OAAO,IAAI,CAAC,IAAI,SAAS,CAAC,OAAO,IAAI,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;wBAClH,IAAI,kBAAkB,IAAI,kBAAkB,EAAE;4BAC1C,IAAI,kBAAkB,EAAE;gCACpB,IAAI,CAAC,UAAU,CAAC,kBAAkB,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,CAAA;6BACtH;iCAAM;gCACH,IAAI,CAAC,UAAU,CAAC,kBAAkB,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,CAAA;6BACtH;yBACJ;wBACG,kBAAkB,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,OAAO,IAAI,CAAC,IAAI,SAAS,CAAC,SAAS,IAAI,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;wBAC9G,kBAAkB,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,OAAO,IAAI,CAAC,IAAI,SAAS,CAAC,QAAQ,IAAI,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;wBAClH,IAAI,kBAAkB,IAAI,kBAAkB,EAAE;4BAC1C,IAAI,kBAAkB,EAAE;gCACpB,IAAI,CAAC,UAAU,CAAC,kBAAkB,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,GAAG,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAA;6BACrH;iCAAM;gCACH,IAAI,CAAC,UAAU,CAAC,kBAAkB,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,GAAG,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAA;6BACrH;yBACJ;6BACG,CAAC,CAAC,kBAAkB,IAAI,kBAAkB,IAAI,kBAAkB,IAAI,kBAAkB,CAAC,EAAvF,wBAAuF;wBACvF,EAAE,CAAC,KAAK,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;wBACpC,qBAAM,IAAI,OAAO,CAAO,UAAC,OAAO,EAAE,MAAM;gCACpC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC;oCACpF,OAAO,EAAE,CAAC;gCACd,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC;4BACf,CAAC,CAAC,EAAA;;wBAJF,SAIE,CAAA;;;wBAEN,IAAI,CAAC,WAAW,EAAE,CAAC;wBACnB,sBAAO,IAAI,EAAC;;;;KACf;IAED;;;OAGG;IACK,mCAAgB,GAAxB,UAAyB,IAAiB;QACtC,IAAI,IAAI,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACzC,CAAC;IAED;;OAEG;IACI,2BAAQ,GAAf;QACI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAC9D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,GAAG,GAAG,EAAE,EAAE,CAAC,EAAE;YACvD,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;YACpD,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;SAC/B;QACD,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;QACpB,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,KAAK,GAAG,GAAG,EAAE,EAAE,KAAK,EAAE;YACtE,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC;SACtC;QACD,IAAI,CAAC,YAAY,GAAG,EAAE,CAAC;QACvB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;IACvB,CAAC;IAzjBa,eAAM,GAA+B,IAAI,GAAG,EAAE,CAAC;IA2jBjE,eAAC;CA5jBD,AA4jBC,IAAA;kBA5jBoB,QAAQ;AA6jB7B;;;;GAIG;AACH,SAAS,aAAa,CAAC,IAAmB,EAAE,OAAkB;IAC1D,IAAI,IAAI,GAAG,IAAI,CAAC,IAAI,CAAA;IACpB,IAAI,SAAS,GAAY,EAAE,CAAC;IAC5B,IAAI,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;IAC7B,SAAS;IACT,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE;QACZ,SAAS,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;KACnE;IACD,SAAS;IACT,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE;QACZ,SAAS,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC;KAChE;IACD,SAAS;IACT,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE;QACZ,SAAS,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC;KAC7D;IACD,SAAS;IACT,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE;QACZ,SAAS,CAAC,SAAS,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;KACpE;IACD,SAAS,CAAC,IAAI,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IAClD,OAAO,SAAS,CAAC;AACrB,CAAC;AAED;;;;GAIG;AACH,SAAS,WAAW,CAAC,IAAa;IAC9B,OAAO,IAAI,CAAC,MAAM,CAAC,qBAAqB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AAC5D,CAAC","file":"","sourceRoot":"/","sourcesContent":["import RenderAlternative from \"./RenderAlternative\";\r\n\r\ninterface IBorder {\r\n leftSide?: number;\r\n rightSide?: number;\r\n bottomSide?: number;\r\n topSide?: number;\r\n size?: cc.Size;\r\n}\r\ntype TDate = { size?: cc.Size };\r\nexport class ShowNode extends cc.Component {\r\n /**是否初始化过代理组建 */\r\n private hasInit: boolean = false;\r\n /**渲染分层开启的挂载节点 */\r\n public renderLayer: cc.Node;\r\n /**上级的cell */\r\n public cell: ItemCell;\r\n /**数据 */\r\n public data: T;\r\n /**初始化 */\r\n public init(cell: ItemCell, data: T, renderLayer: cc.Node) {\r\n this.cell = cell;\r\n this.data = data;\r\n if (this.renderLayer != renderLayer) {\r\n this.renderLayer = renderLayer;\r\n renderLayer && this.initRenders();\r\n }\r\n this.initShow();\r\n }\r\n /**初始化操作 */\r\n initShow() { }\r\n /**被回收,应该做一些释放的操作 */\r\n onRecircle() { }\r\n\r\n /**\r\n * 在特定时间内进行大小变化\r\n * @param targetSize \r\n * @param time \r\n */\r\n public resize(targetSize: cc.Size, time: number = 0.3) {\r\n this.cell.resize(targetSize, time);\r\n }\r\n /**\r\n * 处理分层代理渲染\r\n */\r\n private initRenders() {\r\n if (!this.hasInit && this.renderLayer) {\r\n let propMap: WeakMap = new WeakMap();\r\n let keys = Object.keys(this);\r\n for (let i = 0, len = keys.length; i < len; ++i) {\r\n let value = this[keys[i]];\r\n let alternative: RenderAlternative = null;\r\n if (value instanceof cc.Node) {\r\n alternative = value.getComponent(RenderAlternative);\r\n if (alternative) {\r\n alternative.init(this.renderLayer);\r\n }\r\n } else if (value instanceof cc.RenderComponent) {\r\n alternative = value.getComponent(RenderAlternative);\r\n if (alternative) {\r\n this[keys[i]] = alternative.init(this.renderLayer);\r\n }\r\n }\r\n alternative && propMap.set(alternative, true);\r\n }\r\n this.dealChilrenAlternative(this.node, propMap, 0, 0);\r\n this.hasInit = true;\r\n }\r\n }\r\n /**\r\n * 处理子节点代理\r\n * @param node \r\n * @param propMap 记录脚本已经处理过的属性代理\r\n * @param parentSindex 父节点的所在的顺序\r\n * @param depth 深度\r\n */\r\n dealChilrenAlternative(node: cc.Node, propMap: WeakMap, parentSindex: number, depth: number) {\r\n for (let i = 0, len = node.children.length; i < len; i++) {\r\n let children = node.children[i];\r\n let alternative = children.getComponent(cc.RenderComponent)?.getComponent(RenderAlternative);\r\n let sIndex = parentSindex + (i * Math.pow(0.1, depth));\r\n if (alternative) {\r\n if ((!propMap.has(alternative) || !propMap.get(alternative))) {\r\n alternative.init(this.renderLayer);\r\n }\r\n alternative.sIndex = sIndex;\r\n }\r\n this.dealChilrenAlternative(children, propMap, sIndex, depth + 1);\r\n }\r\n }\r\n}\r\nexport class ItemCell {\r\n /**持有cell的list */\r\n public looplist: LoopList = null;\r\n /**位置节点 */\r\n public node: cc.Node = null;\r\n /**显示节点 */\r\n public showNode: ShowNode = null;\r\n /**尺寸 */\r\n public size: cc.Size = null;\r\n /**数据下标 */\r\n public dataIndex: number = null;\r\n /**cell下标 */\r\n public cellIndex: number = null;\r\n /**数据 */\r\n public data: T = null;\r\n /**\r\n * 构造函数\r\n * @param node \r\n * @param looplist \r\n */\r\n constructor(node: cc.Node, looplist: LoopList) {\r\n this.node = node;\r\n this.looplist = looplist;\r\n }\r\n\r\n /**\r\n * 初始化\r\n * @param data \r\n * @param size \r\n * @param dataIndex \r\n * @param cellIndex \r\n * @param looplist \r\n */\r\n public init(data: T, size: cc.Size, dataIndex: number, cellIndex: number, looplist: LoopList) {\r\n cc.Tween.stopAllByTarget(this.node);\r\n this.cellIndex = cellIndex;\r\n this.dataIndex = dataIndex;\r\n this.looplist = looplist;\r\n this.node.width = size.width;\r\n this.node.height = size.height;\r\n this.data = data;\r\n this.size = size;\r\n }\r\n /**\r\n * 重置大小\r\n * @param size \r\n */\r\n resize(size: cc.Size, time: number) {\r\n let nodeSides = getNodeBorder(this, [true, true, true, true]);\r\n let changeSize = cc.size(size.width - this.size.width, size.height - this.size.height);\r\n this.size = size;\r\n this.looplist.dealChangeSize(this, nodeSides, changeSize, time).then(() => {\r\n this.node.width = size.width;\r\n this.node.height = size.height;\r\n this.looplist.updateNodes();\r\n });\r\n }\r\n\r\n /**\r\n * 更新节点显示\r\n * @param isShow 是否显示\r\n * @param prefab 需要显示的节点的预制件(也可以是节点,或者预制件url,生成方式自由改动)\r\n * @param cacheNode 对象池中的显示节点\r\n * @param renderLayer 分层节点\r\n */\r\n updateShow(isShow: boolean, prefab: cc.Prefab, cacheNode: ShowNode, renderLayer: cc.Node) {\r\n if (isShow) {\r\n //当前没有显示节点\r\n if (!this.showNode) {\r\n //如果是临时对象池还有节点则重用\r\n if (cacheNode) {\r\n this.showNode = cacheNode;\r\n } else {//否则使用传入的预制件进行生成\r\n this.showNode = cc.instantiate(prefab).getComponent(ShowNode);\r\n }\r\n this.showNode.node.setParent(this.node);\r\n this.showNode.node.position = cc.v3();\r\n this.updateShowNode(renderLayer);\r\n }\r\n }\r\n }\r\n /**\r\n * 更新showNode节点显示\r\n * @param renderLayer \r\n */\r\n updateShowNode(renderLayer: cc.Node) {\r\n //当前有显示节点\r\n if (this.showNode) {\r\n this.showNode.init(this, this.data, renderLayer);\r\n }\r\n }\r\n\r\n get hasNoNode() {\r\n return !this.showNode;\r\n }\r\n\r\n recircle() {\r\n if (this.showNode) {\r\n let node = this.showNode;\r\n this.showNode.getComponent(ShowNode).onRecircle();\r\n this.showNode.node.removeFromParent(false);\r\n this.showNode = null;\r\n return node;\r\n }\r\n }\r\n\r\n\r\n destroy() {\r\n this.node.destroy();\r\n this.node = null;\r\n this.looplist = null;\r\n }\r\n\r\n /**\r\n * 失去\r\n * @returns \r\n */\r\n lostShowNode() {\r\n if (this.showNode) {\r\n let node = this.showNode;\r\n this.showNode.node.removeFromParent(false);\r\n this.showNode = null;\r\n return node;\r\n }\r\n }\r\n\r\n /**\r\n * 获取显示节点\r\n * @param showNode \r\n */\r\n getShowNode(showNode: ShowNode) {\r\n this.showNode = showNode;\r\n showNode.node.setParent(this.node);\r\n this.showNode.cell = this;\r\n }\r\n}\r\n\r\n/**\r\n * 目前列表注意事项\r\n * 1.开启cellMaxNum后不能一行多列或者一列多行,只能单行或者单列\r\n */\r\nexport default class LoopList {\r\n public static insMap: Map> = new Map();\r\n public static ins(listName: string): LoopList {\r\n if (!this.insMap.has(listName)) {\r\n this.insMap.set(listName, new LoopList());\r\n }\r\n return this.insMap.get(listName) as LoopList;\r\n }\r\n /**分层节点(只有在showNode中挂载了RenderAlternative才能起作用) */\r\n private renderLayer: cc.Node = null;\r\n /**滚动组件 */\r\n private scrollView: cc.ScrollView = null;\r\n /**cell节点最大数量 */\r\n private cellMaxNum: number = null;\r\n /**当前起点 */\r\n private curStartIndex: number = null;\r\n /**数据 */\r\n private datas: T[] = [];\r\n /**item节点们 */\r\n private itemCells: ItemCell[] = [];\r\n /**预制件 */\r\n private prefab: cc.Prefab = null;\r\n /**显示节点的池子 */\r\n private showNodePool: ShowNode[] = [];\r\n /**边缘数据 */\r\n private viewSides: IBorder = {};\r\n /**上一帧滚动容器的坐标 */\r\n public lastPos: cc.Vec3 = null;\r\n /**刷新显示的间隔次数 */\r\n public updateInv: number = 0;\r\n /**循环切换的最后一次时间 */\r\n public lastChange: number = 0;\r\n /**通用尺寸 */\r\n public size: cc.Size = null;\r\n /**通用锚点 */\r\n public anchor: cc.Vec2 = null;\r\n\r\n onLoad() {\r\n this.updateBorder()\r\n }\r\n\r\n /**\r\n * 更新边界\r\n */\r\n public updateBorder() {\r\n let view = this.scrollView.node.getChildByName(\"view\");\r\n view.anchorX = this.scrollView.content.anchorX;\r\n view.anchorY = this.scrollView.content.anchorY;\r\n //修改锚点之后下一帧世界坐标才会更新,没办法只能等一帧了\r\n return new Promise((resolve, reject) => {\r\n requestAnimationFrame(() => {\r\n let wpos = getNodeWPos(view);\r\n //显示区域左边缘\r\n let leftSide = wpos.x - (view.width * view.anchorX);\r\n //显示区域右边缘\r\n let rightSide = wpos.x + (view.width * (1 - view.anchorX));\r\n //显示区域下边缘\r\n let bottomSide = wpos.y - (view.height * view.anchorY);\r\n //显示区域上边缘\r\n let topSide = wpos.y + (view.height * (1 - view.anchorY));\r\n this.viewSides = {\r\n leftSide, rightSide, bottomSide, topSide, size: cc.size(view.width, view.height)\r\n };\r\n this.scrollView.content.setPosition(cc.v3(0, 0));\r\n resolve();\r\n })\r\n })\r\n\r\n }\r\n\r\n /**\r\n * 初始化滚动列表\r\n * @param scrollView \r\n * @param cellMaxNum cell节点的最大数量,设置成null则不启用,启用的话,要设置成(可视窗刚好能显示的最大数量*2)+2,假设最多能看到10个节点,那么设置成22\r\n * @param renderLayer 渲染分层的父节点,如果传入则可以配合showNode上的renderAlternative来进行渲染分层\r\n */\r\n async init(scrollView: cc.ScrollView, renderLayer?: cc.Node, cellMaxNum?: number) {\r\n cellMaxNum && (this.cellMaxNum = cellMaxNum);\r\n renderLayer && (this.renderLayer = renderLayer);\r\n this.scrollView = scrollView;\r\n await this.updateBorder();\r\n this.scrollView.node.on(\"scrolling\", this.scrollingListener, this);\r\n }\r\n\r\n /**滚动监听 */\r\n scrollingListener() {\r\n this.updateInv--;\r\n if (this.updateInv <= 0) {\r\n this.updateInv = 2;\r\n let showCells = this.updateNodes();\r\n\r\n if (!this.cellMaxNum) {\r\n return;\r\n }\r\n if (!this.lastPos) {\r\n this.lastPos = this.scrollView.content.position.clone();\r\n } else {\r\n let offset = this.scrollView.content.position.clone().sub(this.lastPos);\r\n this.lastPos = this.scrollView.content.position.clone();\r\n let now = cc.sys.now();\r\n if (!this.lastChange || (now - this.lastChange) > 100) {\r\n this.lastChange = now;\r\n this.dealLoopList(offset, showCells);\r\n }\r\n }\r\n }\r\n }\r\n /**\r\n * 初始化\r\n * @param data 数据组\r\n * @param prefab 预制件\r\n * @param size 通用尺寸\r\n * @param anchor cell的锚点\r\n */\r\n public initData(data: T[], prefab: cc.Prefab, size?: cc.Size, anchor: cc.Vec2 = cc.v2(0.5, 0.5)) {\r\n this.datas = data;\r\n this.size = size;\r\n this.anchor = anchor;\r\n this.prefab = prefab;\r\n let len = this.cellMaxNum ? this.cellMaxNum : data.length;\r\n this.curStartIndex = 0;\r\n for (let i = 0; i < len; ++i) {\r\n let itemCell = this.itemCells[i];\r\n if (!itemCell) {\r\n let node = new cc.Node('LoopListCell')\r\n itemCell = this.itemCells[i] = new ItemCell(node, this);\r\n node.setAnchorPoint(anchor);\r\n node.setParent(this.scrollView.content);\r\n }\r\n let data = this.datas[this.curStartIndex + i];\r\n let cellSize = data.size ? data.size : size;\r\n itemCell.init(data, cellSize, this.curStartIndex + i, i, this);\r\n }\r\n for (let i = data.length, len = this.itemCells.length; i < len; ++i) {\r\n this.recircleShowNode(this.itemCells[i].recircle());\r\n this.itemCells[i].destroy()\r\n this.itemCells[i] = null;\r\n }\r\n this.updateNodes();\r\n }\r\n\r\n /**\r\n * 压入新的数据\r\n * @param datas \r\n */\r\n public pushDatas(datas: T[]) {\r\n let length = this.datas.length;\r\n for (let i = 0, len = datas.length; i < len; ++i) {\r\n let data = datas[i];\r\n this.datas.push(data);\r\n let index = length + i;\r\n this.addNodeFromIndex(index);\r\n }\r\n }\r\n /**\r\n * 插入新的数据\r\n * @param data \r\n * @param insertIndex \r\n */\r\n public insertData(data: T, insertIndex: number) {\r\n if (this.datas.length >= insertIndex) {\r\n this.datas.splice(insertIndex, 0, data);\r\n this.addNodeFromIndex(insertIndex);\r\n } else {\r\n this.pushDatas([data]);\r\n }\r\n }\r\n /**\r\n * 移除对应数据\r\n * @param removeIndex \r\n */\r\n public removeData(removeIndex: number) {\r\n if (this.datas.length >= removeIndex) {\r\n this.datas.splice(removeIndex, 1);\r\n if (this.cellMaxNum) {\r\n let cellIndex = removeIndex - this.curStartIndex;\r\n //在使用范围内\r\n if (cellIndex >= 0 && cellIndex < this.cellMaxNum) {\r\n let itemCell = this.itemCells[cellIndex];\r\n let nodeSides = getNodeBorder(itemCell, [true, true, true, true]);\r\n let changeSize = cc.size(-itemCell.size.width, -itemCell.size.height);\r\n itemCell.size = cc.size(0, 0);\r\n this.dealChangeSize(itemCell, nodeSides, changeSize).then(() => {\r\n //更新数据\r\n for (let i = cellIndex; i < this.cellMaxNum; i++) {\r\n let curDataIndex = this.curStartIndex + i;\r\n let curData = this.datas[curDataIndex];\r\n let curCellSize: cc.Size = curData.size ? curData.size : this.size;\r\n this.itemCells[i].init(curData, curCellSize, curDataIndex, i, this);\r\n this.itemCells[i].updateShowNode(this.renderLayer);\r\n }\r\n });\r\n }\r\n } else {\r\n let itemCell = this.itemCells.splice(removeIndex, 1)[0];\r\n let nodeSides = getNodeBorder(itemCell, [true, true, true, true]);\r\n let changeSize = cc.size(-itemCell.size.width, -itemCell.size.height);\r\n itemCell.size = cc.size(0, 0);\r\n this.dealChangeSize(itemCell, nodeSides, changeSize).then(() => {\r\n this.recircleShowNode(itemCell.recircle())\r\n itemCell.node.destroy();\r\n });\r\n }\r\n }\r\n }\r\n /**\r\n * 从某个数据开始更新\r\n * @param dataIndex \r\n */\r\n private async addNodeFromIndex(dataIndex: number) {\r\n let data = this.datas[dataIndex];\r\n let cellSize: cc.Size = data.size ? data.size : this.size;\r\n //是否开启cell循环\r\n if (this.cellMaxNum) {\r\n let cellIndex = dataIndex - this.curStartIndex;\r\n //在使用范围内\r\n if (cellIndex >= 0 && cellIndex < this.cellMaxNum) {\r\n //更新数据\r\n for (let i = cellIndex; i < this.cellMaxNum; i++) {\r\n let curDataIndex = this.curStartIndex + i;\r\n let curData = this.datas[curDataIndex];\r\n let curCellSize: cc.Size = curData.size ? curData.size : this.size;\r\n this.itemCells[i].init(curData, curCellSize, curDataIndex, i, this);\r\n this.itemCells[i].updateShowNode(this.renderLayer);\r\n }\r\n //获取当前的位置\r\n let nodeSides: IBorder = null;\r\n let itemCell: ItemCell = this.itemCells[cellIndex];\r\n if (itemCell) {\r\n nodeSides = getNodeBorder(itemCell, [true, true, true, true]);\r\n itemCell.node.width = 0;\r\n itemCell.node.height = 0;\r\n this.dealChangeSize(itemCell, nodeSides, cellSize).then(() => {\r\n itemCell.node.width = cellSize.width;\r\n itemCell.node.height = cellSize.height;\r\n });\r\n }\r\n }\r\n } else {\r\n //获取当前的位置\r\n let nodeSides: IBorder = null;\r\n if (this.itemCells[dataIndex]) {\r\n nodeSides = getNodeBorder(this.itemCells[dataIndex], [true, true, true, true]);\r\n }\r\n let node = new cc.Node('LoopListCell')\r\n node.setAnchorPoint(this.anchor);\r\n node.setParent(this.scrollView.content);\r\n node.setSiblingIndex(dataIndex);\r\n let itemCell: ItemCell = new ItemCell(node, this);\r\n this.itemCells.splice(dataIndex, 0, itemCell)\r\n itemCell.init(data, cellSize, dataIndex, dataIndex, this);\r\n if (!nodeSides) {\r\n await new Promise((resolve, reject) => {\r\n requestAnimationFrame(() => {\r\n nodeSides = getNodeBorder(itemCell, [true, true, true, true]);\r\n resolve();\r\n })\r\n });\r\n }\r\n if (nodeSides) {\r\n itemCell.node.width = 0;\r\n itemCell.node.height = 0;\r\n this.dealChangeSize(itemCell, nodeSides, cellSize).then(() => {\r\n itemCell.node.width = cellSize.width;\r\n itemCell.node.height = cellSize.height;\r\n });\r\n }\r\n this.dealItemShow(itemCell);\r\n }\r\n }\r\n\r\n /**\r\n * 处理列表的循环利用\r\n * @param offset \r\n * @param dataIndexs \r\n */\r\n private dealLoopList(offset: cc.Vec3, showCells: ItemCell[]) {\r\n let startCell = showCells[0];\r\n let endCell = showCells[showCells.length - 1];\r\n if (this.scrollView.vertical) {\r\n /**内容上移 */\r\n if (offset.y > 0) {\r\n //已经到达最后倒数第二个节点并且还有数据\r\n if (this.scrollView.content.y >= (- this.itemCells[this.itemCells.length - 2].node.y - this.viewSides.size.height) && endCell.dataIndex < this.datas.length - 2) {\r\n //显示开始数据下标(这里-1是想要顶部留一个itemcell做缓冲)\r\n let showStart = startCell.dataIndex - 1;\r\n //剩余可展示的数据量 \r\n let leave = this.datas.length - showStart;\r\n //计算应该从那个位置开始重新赋值,因为如果直接移动到最上方,数据量不够覆盖所有的cell\r\n let cellStartIndex = Math.max(0, this.itemCells.length - leave);\r\n //计算第一个cell的数据下标\r\n this.curStartIndex = showStart - cellStartIndex;\r\n\r\n let cellTop = getNodeBorder(this.itemCells[startCell.cellIndex], [true]).topSide;\r\n\r\n let contentHeight = 0;\r\n let targetY = 0;\r\n let jumpFirst = true;\r\n let showIndex = 0;\r\n for (let i = 0, len = this.itemCells.length; i < len; ++i) {\r\n if (i >= cellStartIndex) {\r\n //将当前已经显示的showNode节点直接重新设置到移动后的节点上\r\n if (showIndex < showCells.length && !jumpFirst) {\r\n if (showIndex == 0) {\r\n targetY = contentHeight;\r\n }\r\n let showNode = showCells[showIndex].lostShowNode();\r\n showIndex++;\r\n this.itemCells[i].getShowNode(showNode);\r\n }\r\n jumpFirst = false;\r\n }\r\n let dataIndex = this.curStartIndex + i;\r\n let data = this.datas[dataIndex];\r\n let cellSize = data.size ? data.size : this.size;\r\n contentHeight += cellSize.height;\r\n this.itemCells[i].init(data, cellSize, dataIndex, i, this);\r\n }\r\n\r\n //将content的位置移动到最上方并对齐移动前的状态\r\n let posY = targetY + (cellTop - this.viewSides.topSide)\r\n this.scrollView.content.setPosition(cc.v3(this.scrollView.content.position.x, posY));\r\n this.scrollView.scrollToOffset(cc.v2(0, posY + endCell.size.height), 1)\r\n this.lastPos = null;\r\n }\r\n } //内容下移\r\n else if (offset.y < 0) {\r\n //已经到达第二个节点并且还有数据\r\n if (this.scrollView.content.y < (- this.itemCells[2].node.y) && startCell.dataIndex > 1) {\r\n //展示的最后一个数据下表,+1是为了在底部预留一部分空间\r\n let showEndIndex = endCell.dataIndex + 1;\r\n //计算应该从那个位置开始重新赋值,因为如果直接移动到最下方,数据量不够覆盖所有的cell\r\n let cellEndIndex = Math.min(this.itemCells.length - 2, showEndIndex - 1);\r\n //计算第一个cell的数据下标\r\n this.curStartIndex = Math.max(showEndIndex - (this.itemCells.length - 1), 0);\r\n\r\n //将content的位置移动到最下方并对齐移动前的状态\r\n let cellTop = getNodeBorder(this.itemCells[startCell.cellIndex], [true]).topSide;\r\n\r\n let contentHeight = 0;\r\n let showIndex = showCells.length - 1;\r\n for (let i = this.itemCells.length - 1; i >= 0; --i) {\r\n if (i <= cellEndIndex) {\r\n //将当前已经显示的showNode节点直接重新设置到移动后的节点上\r\n if (showIndex >= 0) {\r\n let showNode = showCells[showIndex].lostShowNode();\r\n showIndex--;\r\n this.itemCells[i].getShowNode(showNode);\r\n } else {\r\n showIndex--;\r\n }\r\n }\r\n let dataIndex = this.curStartIndex + i;\r\n let data = this.datas[dataIndex];\r\n let cellSize = data.size ? data.size : this.size;\r\n if (showIndex < -1) {\r\n contentHeight += cellSize.height;\r\n }\r\n this.itemCells[i].init(data, cellSize, dataIndex, i, this);\r\n }\r\n\r\n //将content的位置移动到最下方并对齐移动前的状态\r\n let posY = contentHeight + (cellTop - this.viewSides.topSide)\r\n this.scrollView.content.setPosition(cc.v3(this.scrollView.content.position.x, posY));\r\n this.scrollView.scrollToOffset(cc.v2(0, posY - startCell.size.height), 1)\r\n this.lastPos = null;\r\n }\r\n }\r\n } else if (this.scrollView.horizontal) {\r\n if (offset.x < 0) {\r\n //已经到达最后倒数第二个节点并且还有数据\r\n if (this.scrollView.content.x <= (- (this.itemCells[this.itemCells.length - 2].node.x - this.viewSides.size.width)) && endCell.dataIndex < this.datas.length - 2) {\r\n //显示开始数据下标(这里-1是想要左侧留一个itemcell做缓冲)\r\n let showStart = startCell.dataIndex - 1;\r\n //剩余可展示的数据量 \r\n let leave = this.datas.length - showStart;\r\n //计算应该从那个位置开始重新赋值,因为如果直接移动到最左侧,数据量不够覆盖所有的cell\r\n let cellStartIndex = Math.max(0, this.itemCells.length - leave);\r\n //计算第一个cell的数据下标\r\n this.curStartIndex = showStart - cellStartIndex;\r\n\r\n let cellLeft = getNodeBorder(this.itemCells[startCell.cellIndex], [false, false, true]).leftSide;\r\n\r\n let contentWidth = 0;\r\n let targetX = 0;\r\n let jumpFirst = true;\r\n let showIndex = 0;\r\n for (let i = 0, len = this.itemCells.length; i < len; ++i) {\r\n if (i >= cellStartIndex) {\r\n //将当前已经显示的showNode节点直接重新设置到移动后的节点上\r\n if (showIndex < showCells.length && !jumpFirst) {\r\n if (showIndex == 0) {\r\n targetX = contentWidth;\r\n }\r\n let showNode = showCells[showIndex].lostShowNode();\r\n showIndex++;\r\n this.itemCells[i].getShowNode(showNode);\r\n }\r\n jumpFirst = false;\r\n }\r\n let dataIndex = this.curStartIndex + i;\r\n let data = this.datas[dataIndex];\r\n let cellSize = data.size ? data.size : this.size;\r\n contentWidth += cellSize.width;\r\n this.itemCells[i].init(data, cellSize, dataIndex, i, this);\r\n }\r\n\r\n //将content的位置移动到最左侧并对齐移动前的状态\r\n let posX = (cellLeft - this.viewSides.leftSide) - targetX;\r\n this.scrollView.content.setPosition(cc.v3(posX, this.scrollView.content.position.y));\r\n this.scrollView.scrollToOffset(cc.v2(-(posX - endCell.size.width), 0), 1)\r\n this.lastPos = null;\r\n }\r\n } else if (offset.x > 0) {\r\n //已经到达第二个节点并且还有数据\r\n if (this.scrollView.content.x > (-this.itemCells[2].node.x) && startCell.dataIndex > 1) {\r\n //展示的最后一个数据下表,+1是为了在右侧预留一部分空间\r\n let showEndIndex = endCell.dataIndex + 1;\r\n //计算应该从那个位置开始重新赋值,因为如果直接移动到最右侧,数据量不够覆盖所有的cell\r\n let cellEndIndex = Math.min(this.itemCells.length - 2, showEndIndex - 1);\r\n //计算第一个cell的数据下标\r\n this.curStartIndex = Math.max(showEndIndex - (this.itemCells.length - 1), 0);\r\n\r\n //将content的位置移动到最右侧并对齐移动前的状态\r\n let cellLeft = getNodeBorder(this.itemCells[startCell.cellIndex], [false, false, true]).leftSide;\r\n\r\n let contentWidth = 0;\r\n let showIndex = showCells.length - 1;\r\n for (let i = this.itemCells.length - 1; i >= 0; --i) {\r\n if (i <= cellEndIndex) {\r\n //将当前已经显示的showNode节点直接重新设置到移动后的节点上\r\n if (showIndex >= 0) {\r\n let showNode = showCells[showIndex].lostShowNode();\r\n showIndex--;\r\n this.itemCells[i].getShowNode(showNode);\r\n } else {\r\n showIndex--;\r\n }\r\n }\r\n let dataIndex = this.curStartIndex + i;\r\n let data = this.datas[dataIndex];\r\n let cellSize = data.size ? data.size : this.size;\r\n if (showIndex < -1) {\r\n contentWidth += cellSize.width;\r\n }\r\n this.itemCells[i].init(data, cellSize, dataIndex, i, this);\r\n }\r\n\r\n //将content的位置移动到最右侧并对齐移动前的状态\r\n let posX = (cellLeft - this.viewSides.leftSide) - contentWidth;\r\n this.scrollView.content.setPosition(cc.v3(posX, this.scrollView.content.position.y));\r\n this.scrollView.scrollToOffset(cc.v2(- (posX + startCell.size.width), 0), 1)\r\n this.lastPos = null;\r\n }\r\n }\r\n }\r\n }\r\n\r\n\r\n /**更新节点的显示 */\r\n public updateNodes() {\r\n let showCells: ItemCell[] = [];\r\n for (let i = 0, len = this.itemCells.length; i < len; ++i) {\r\n let itemCell = this.itemCells[i];\r\n let isShow = this.dealItemShow(itemCell)\r\n if (isShow) {\r\n showCells.push(itemCell)\r\n }\r\n }\r\n return showCells;\r\n }\r\n\r\n /**\r\n * 处理cell的显示隐藏\r\n * @param itemCell \r\n */\r\n private dealItemShow(itemCell: ItemCell) {\r\n if (itemCell) {\r\n let isShow = this.checkInView(itemCell);\r\n if (isShow) {\r\n itemCell.hasNoNode && itemCell.updateShow(isShow, this.prefab, this.showNodePool.length > 0 ? this.showNodePool.pop() : null, this.renderLayer);\r\n } else {\r\n !itemCell.hasNoNode && this.recircleShowNode(itemCell.recircle());\r\n }\r\n return isShow;\r\n }\r\n }\r\n\r\n\r\n /**\r\n * 检查是否在屏幕内\r\n * @param node \r\n * @returns \r\n */\r\n private checkInView(itemCell: ItemCell) {\r\n let nodeSides = getNodeBorder(itemCell, [true, true, true, true]);\r\n //节点右侧边缘在屏幕左侧外面或者节点左边缘在屏幕右侧外面 则不在显示区域\r\n let horizontalOutside = nodeSides.rightSide < this.viewSides.leftSide\r\n || nodeSides.leftSide > this.viewSides.rightSide;\r\n\r\n let verticalOutside = false;\r\n if (!horizontalOutside) {\r\n //节点上边缘在屏幕下方外面或者节点下边缘在屏幕上方外面 则不在显示区域\r\n verticalOutside = nodeSides.topSide < this.viewSides.bottomSide\r\n || nodeSides.bottomSide > this.viewSides.topSide;\r\n }\r\n return !horizontalOutside && !verticalOutside;\r\n }\r\n /**\r\n * 处理变化的大小\r\n * @param cell \r\n * @param nodeSides \r\n * @param changeSize \r\n */\r\n public async dealChangeSize(cell: ItemCell, nodeSides: IBorder, changeSize: cc.Size, time: number = 0.3) {\r\n let topToBottomFulfill = (this.scrollView.content.anchorY == 1 && nodeSides.bottomSide >= this.viewSides.topSide);\r\n let bottomToTopFulfill = (this.scrollView.content.anchorY == 0 && nodeSides.topSide <= this.viewSides.bottomSide);\r\n if (topToBottomFulfill || bottomToTopFulfill) {\r\n if (topToBottomFulfill) {\r\n this.scrollView.setContentPosition(cc.v2(this.scrollView.content.x, this.scrollView.content.y + changeSize.height))\r\n } else {\r\n this.scrollView.setContentPosition(cc.v2(this.scrollView.content.x, this.scrollView.content.y - changeSize.height))\r\n }\r\n }\r\n let leftToRightFulfill = (this.scrollView.content.anchorX == 0 && nodeSides.rightSide <= this.viewSides.leftSide);\r\n let RightToLeftFulfill = (this.scrollView.content.anchorX == 1 && nodeSides.leftSide >= this.viewSides.rightSide);\r\n if (leftToRightFulfill || RightToLeftFulfill) {\r\n if (RightToLeftFulfill) {\r\n this.scrollView.setContentPosition(cc.v2(this.scrollView.content.x + changeSize.width, this.scrollView.content.y))\r\n } else {\r\n this.scrollView.setContentPosition(cc.v2(this.scrollView.content.x - changeSize.width, this.scrollView.content.y))\r\n }\r\n }\r\n if (!(topToBottomFulfill || bottomToTopFulfill || leftToRightFulfill || RightToLeftFulfill)) {\r\n cc.Tween.stopAllByTarget(cell.node);\r\n await new Promise((resolve, reject) => {\r\n cc.tween(cell.node).to(time, { width: cell.size.width, height: cell.size.height }).call(() => {\r\n resolve();\r\n }).start();\r\n })\r\n }\r\n this.updateNodes();\r\n return true;\r\n }\r\n\r\n /**\r\n * 回收显示节点\r\n * @param node \r\n */\r\n private recircleShowNode(node: ShowNode) {\r\n node && this.showNodePool.push(node);\r\n }\r\n\r\n /**\r\n * 释放当前列表\r\n */\r\n public freeList() {\r\n this.scrollView.node.off(\"scrolling\", this.scrollingListener);\r\n for (let i = 0, len = this.itemCells.length; i < len; ++i) {\r\n this.recircleShowNode(this.itemCells[i].recircle());\r\n this.itemCells[i].destroy();\r\n }\r\n this.itemCells = [];\r\n for (let index = 0, len = this.showNodePool.length; index < len; ++index) {\r\n this.showNodePool[index].destroy();\r\n }\r\n this.showNodePool = [];\r\n this.renderLayer = null;\r\n this.scrollView = null;\r\n this.prefab = null;\r\n }\r\n\r\n}\r\n/**\r\n * 获取节点的边缘\r\n * @param node \r\n * @param needArr 顺序是上 下 左 右\r\n */\r\nfunction getNodeBorder(cell: ItemCell, needArr: boolean[]) {\r\n let node = cell.node\r\n let boderData: IBorder = {};\r\n let wpos = getNodeWPos(node);\r\n //显示区域上边缘\r\n if (needArr[0]) {\r\n boderData.topSide = wpos.y + (node.height * (1 - node.anchorY));\r\n }\r\n //显示区域下边缘\r\n if (needArr[1]) {\r\n boderData.bottomSide = wpos.y - (node.height * node.anchorY);\r\n }\r\n //显示区域左边缘\r\n if (needArr[2]) {\r\n boderData.leftSide = wpos.x - (node.width * node.anchorX);\r\n }\r\n //显示区域右边缘\r\n if (needArr[3]) {\r\n boderData.rightSide = wpos.x + (node.width * (1 - node.anchorX));\r\n }\r\n boderData.size = cc.size(node.width, node.height);\r\n return boderData;\r\n}\r\n\r\n/**\r\n * 获取节点世界坐标\r\n * @param node \r\n * @returns \r\n */\r\nfunction getNodeWPos(node: cc.Node) {\r\n return node.parent.convertToWorldSpaceAR(node.position);\r\n}\r\n\r\n\r\n"]} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Script/RenderAlternative.js b/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Script/RenderAlternative.js new file mode 100644 index 0000000..e003033 --- /dev/null +++ b/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Script/RenderAlternative.js @@ -0,0 +1,264 @@ +"use strict"; +cc._RF.push(module, 'f9782xj4QNK842OAHoabRFb', 'RenderAlternative'); +// Script/RenderAlternative.ts + +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var RenderReactiveHandler_1 = require("./RenderReactiveHandler"); +/** + * 目前该渲染代理功能存在的问题 + * 1.被代理节点的父级不能出现scaleX和scaleY不一致的情况,被代理节点本身没有这个限制 + */ +var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property; +var RenderAlternative = /** @class */ (function (_super) { + __extends(RenderAlternative, _super); + function RenderAlternative() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /**渲染层节点 */ + _this.renderLayer = null; + /**渲染的zIndex 动态调整zIndex,用于方便临近合批 */ + _this.renderZIndex = 0; + /**同步的间隔(帧为单位) */ + _this.syncInv = 0.01; + /**渲染的sIndex */ + _this.sIndex = 0; + /**非渲染组件 */ + _this.proxyRender = null; + /**渲染组件 */ + _this.renderCompnent = null; + /**上次更新的数据 */ + _this.lastWMat4 = null; + /**上次更新的数据 */ + _this.lastLMat4 = null; + /**上次更新的数据 */ + _this.lastPos = null; + /**距离下次刷新累计了多少间隔 */ + _this.accuTime = 0; + /**最后一次刷新时间 */ + _this.lastFrameTime = null; + /**是否进行刷新 */ + _this.isAttachFrame = false; + return _this; + } + RenderAlternative_1 = RenderAlternative; + Object.defineProperty(RenderAlternative.prototype, "zIndex", { + /**获取总的ZIndex */ + get: function () { + var zIndex = this.renderZIndex + (this.sIndex * 0.01); + var parentNode = this.node.parent; + while (parentNode != this.renderLayer.parent && parentNode != cc.director.getScene()) { + var render = parentNode.getComponent(RenderAlternative_1); + if (render) { + zIndex += render.zIndex + 1; + break; + } + parentNode = parentNode.parent; + } + return zIndex; + }, + enumerable: false, + configurable: true + }); + /** + * 设置渲染节点层 + * @param layer + */ + RenderAlternative.prototype.init = function (layer) { + if (layer) { + this.renderLayer = layer; + } + if (!this.renderLayer) { + console.warn("\u8282\u70B9" + this.node.name + "\u6CA1\u6709\u8BBE\u7F6E\u6E32\u67D3\u5C42"); + return null; + } + return this.initRender(); + }; + /** + * 初始化渲染节点 + */ + RenderAlternative.prototype.initRender = function () { + var node = this.getRender(); + node.setParent(this.renderLayer ? this.renderLayer : cc.director.getScene().getChildByName("Canvas")); + this.isAttachFrame = true; + requestAnimationFrame(this.frameUpdate.bind(this)); + return this.doProxy(); + }; + /**生成代理 */ + RenderAlternative.prototype.doProxy = function () { + this.proxyRender = new Proxy(this.renderCompnent, new RenderReactiveHandler_1.RenderReactiveHandler()); + return this.proxyRender; + }; + RenderAlternative.prototype.frameUpdate = function () { + var now = cc.sys.now(); + !this.lastFrameTime && (this.lastFrameTime = now); + var dt = now - this.lastFrameTime; + if (this.proxyRender) { + this.accuTime += dt; + if (this.accuTime >= this.syncInv) { + this.accuTime -= this.syncInv; + this.updateProp(); + } + } + if (this.isAttachFrame) { + requestAnimationFrame(this.frameUpdate.bind(this)); + } + }; + /**更新最新状态 */ + RenderAlternative.prototype.updateProp = function () { + var node = this.renderCompnent.node; + if (!this.node.activeInHierarchy) { + node.opacity = 0; + return; + } + node.anchorX = this.node.anchorX; + node.anchorY = this.node.anchorY; + node.width = this.node.width; + node.height = this.node.height; + node.group = this.node.group; + node.color = this.node.color; + node.opacity = this.getOpacity(this.node); + var wMat4 = cc.mat4(); + this.node.getWorldMatrix(wMat4); + if (!this.lastWMat4 || !this.lastWMat4.equals(wMat4)) { + var localMatrix = this.getLocalMatrix(wMat4, node); + this.setLocalXYZScaleAngle(localMatrix, node, this.lastLMat4); + this.lastWMat4 = wMat4; + this.lastLMat4 = localMatrix; + } + node.zIndex = this.zIndex; + }; + RenderAlternative.prototype.getLocalMatrix = function (worldMatrix, node) { + var parentNode = null; + if (cc.isValid(node)) { + if (cc.isValid(node.parent)) { + parentNode = node.parent; + } + } + // 获取父节点的世界矩阵 + var parentWorldMatrix = cc.mat4(); + parentNode.getWorldMatrix(parentWorldMatrix); + // 获取父节点的逆矩阵 + var parentInverseMatrix = parentWorldMatrix.invert(); + // 将目标节点的世界矩阵转换为父节点的本地矩阵 + var localMatrix = parentInverseMatrix.multiply(worldMatrix); + return localMatrix; + }; + RenderAlternative.prototype.setLocalXYZScaleAngle = function (matrix, node, lastMatrix) { + if (lastMatrix && matrix.equals(lastMatrix)) { + return; + } + // 提取位置 + node.setPosition(matrix.m[12], matrix.m[13], matrix.m[14]); + var scaleX = null; + var scaleY = null; + var angle = null; + // 提取缩放X + if (!lastMatrix) { + scaleX = Math.sqrt(matrix.m[0] * matrix.m[0] + matrix.m[1] * matrix.m[1] + matrix.m[2] * matrix.m[2]); + } + else if (!this.equalsValue(matrix.m[0], lastMatrix.m[0]) + || !this.equalsValue(matrix.m[1], lastMatrix.m[1]) + || !this.equalsValue(matrix.m[2], lastMatrix.m[2])) { + scaleX = Math.sqrt(matrix.m[0] * matrix.m[0] + matrix.m[1] * matrix.m[1] + matrix.m[2] * matrix.m[2]); + } + // 提取缩放Y + if (!lastMatrix) { + scaleY = Math.sqrt(matrix.m[4] * matrix.m[4] + matrix.m[5] * matrix.m[5] + matrix.m[6] * matrix.m[6]); + } + else if (!this.equalsValue(matrix.m[4], lastMatrix.m[4]) + || !this.equalsValue(matrix.m[5], lastMatrix.m[5]) + || !this.equalsValue(matrix.m[6], lastMatrix.m[6])) { + scaleY = Math.sqrt(matrix.m[4] * matrix.m[4] + matrix.m[5] * matrix.m[5] + matrix.m[6] * matrix.m[6]); + } + //设置缩放X + if (scaleX !== null) { + node.scaleX = scaleX; + // 提取旋转 + angle = Math.atan2(matrix.m[1] / scaleX, matrix.m[0] / scaleX) * (180 / Math.PI); + } + if (scaleY !== null) { + node.scaleY = scaleY; + } + if (angle !== null) { + node.rotation = angle; + } + }; + RenderAlternative.prototype.equalsValue = function (a, b, epsilon) { + if (epsilon === void 0) { epsilon = 0.00001; } + return Math.abs(a - b) < epsilon; + }; + RenderAlternative.prototype.onDestroy = function () { + this.renderCompnent.node.destroy(); + this.renderCompnent = null; + this.proxyRender = null; + }; + /** + * 获取节点透明度 + * @param node + */ + RenderAlternative.prototype.getOpacity = function (node) { + var opacity = (node.opacity / 255); + var parentNode = node.parent; + while (parentNode != this.renderLayer.parent && parentNode != cc.director.getScene()) { + opacity *= (parentNode.opacity / 255); + parentNode = parentNode.parent; + } + return opacity * 255; + }; + /** + * 获取渲染组件 + * @param node + */ + RenderAlternative.prototype.getRender = function () { + var _a, _b; + var node = cc.instantiate(this.node); + node.removeAllChildren(); + this.renderCompnent = node.getComponent(cc.RenderComponent); + (_a = this.node.getComponent(cc.LabelOutline)) === null || _a === void 0 ? void 0 : _a.destroy(); + (_b = this.node.getComponent(cc.LabelShadow)) === null || _b === void 0 ? void 0 : _b.destroy(); + this.node.getComponent(cc.RenderComponent).destroy(); + var components = node.getComponents(cc.Component); + for (var i = 0, len = components.length; i < len; ++i) { + var comp = components[i]; + if (!((comp instanceof cc.RenderComponent) || (comp instanceof cc.LabelOutline) || (comp instanceof cc.LabelShadow))) { + comp.destroy(); + } + } + return node; + }; + var RenderAlternative_1; + __decorate([ + property + ], RenderAlternative.prototype, "renderZIndex", void 0); + __decorate([ + property({ + tooltip: '设置同步的间隔(秒为单位),0就是每帧都同步,0.1就是隔0.1秒同步一次' + }) + ], RenderAlternative.prototype, "syncInv", void 0); + RenderAlternative = RenderAlternative_1 = __decorate([ + ccclass + ], RenderAlternative); + return RenderAlternative; +}(cc.Component)); +exports.default = RenderAlternative; + +cc._RF.pop(); \ No newline at end of file diff --git a/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Script/RenderAlternative.js.map b/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Script/RenderAlternative.js.map new file mode 100644 index 0000000..7ef79cc --- /dev/null +++ b/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Script/RenderAlternative.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["assets\\Script\\RenderAlternative.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iEAAgE;AAEhE;;;GAGG;AACG,IAAA,KAAwB,EAAE,CAAC,UAAU,EAAnC,OAAO,aAAA,EAAE,QAAQ,cAAkB,CAAC;AAE5C;IAA+C,qCAAY;IAA3D;QAAA,qEAkNC;QAjNG,WAAW;QACJ,iBAAW,GAAY,IAAI,CAAC;QACnC,mCAAmC;QAE5B,kBAAY,GAAW,CAAC,CAAC;QAChC,iBAAiB;QAIV,aAAO,GAAW,IAAI,CAAC;QAC9B,eAAe;QACR,YAAM,GAAW,CAAC,CAAC;QAC1B,WAAW;QACJ,iBAAW,GAAuB,IAAI,CAAC;QAC9C,UAAU;QACF,oBAAc,GAAuB,IAAI,CAAC;QAClD,aAAa;QACN,eAAS,GAAY,IAAI,CAAC;QACjC,aAAa;QACN,eAAS,GAAY,IAAI,CAAC;QACjC,aAAa;QACN,aAAO,GAAY,IAAI,CAAC;QAC/B,mBAAmB;QACZ,cAAQ,GAAW,CAAC,CAAC;QAC5B,cAAc;QACP,mBAAa,GAAW,IAAI,CAAC;QACpC,YAAY;QACL,mBAAa,GAAY,KAAK,CAAC;;IAsL1C,CAAC;0BAlNoB,iBAAiB;IA+BlC,sBAAI,qCAAM;QADV,gBAAgB;aAChB;YACI,IAAI,MAAM,GAAG,IAAI,CAAC,YAAY,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;YACtD,IAAI,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;YAClC,OAAO,UAAU,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,IAAI,UAAU,IAAI,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,EAAE;gBAClF,IAAI,MAAM,GAAG,UAAU,CAAC,YAAY,CAAC,mBAAiB,CAAC,CAAC;gBACxD,IAAI,MAAM,EAAE;oBACR,MAAM,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;oBAC5B,MAAM;iBACT;gBACD,UAAU,GAAG,UAAU,CAAC,MAAM,CAAC;aAClC;YACD,OAAO,MAAM,CAAC;QAClB,CAAC;;;OAAA;IAED;;;OAGG;IACH,gCAAI,GAAJ,UAAmC,KAAe;QAC9C,IAAI,KAAK,EAAE;YACP,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;SAC5B;QACD,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;YACnB,OAAO,CAAC,IAAI,CAAC,iBAAK,IAAI,CAAC,IAAI,CAAC,IAAI,+CAAS,CAAC,CAAA;YAC1C,OAAO,IAAI,CAAC;SACf;QACD,OAAO,IAAI,CAAC,UAAU,EAAK,CAAC;IAChC,CAAC;IACD;;OAEG;IACK,sCAAU,GAAlB;QACI,IAAI,IAAI,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;QAC5B,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC;QACtG,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;QAC1B,qBAAqB,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QACnD,OAAO,IAAI,CAAC,OAAO,EAAK,CAAC;IAC7B,CAAC;IACD,UAAU;IACF,mCAAO,GAAf;QACI,IAAI,CAAC,WAAW,GAAG,IAAI,KAAK,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,6CAAqB,EAAE,CAAM,CAAC;QACpF,OAAO,IAAI,CAAC,WAAgB,CAAC;IACjC,CAAC;IAGS,uCAAW,GAArB;QACI,IAAI,GAAG,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;QACvB,CAAC,IAAI,CAAC,aAAa,IAAI,CAAC,IAAI,CAAC,aAAa,GAAG,GAAG,CAAC,CAAC;QAClD,IAAI,EAAE,GAAG,GAAG,GAAG,IAAI,CAAC,aAAa,CAAC;QAClC,IAAI,IAAI,CAAC,WAAW,EAAE;YAClB,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAC;YACpB,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,OAAO,EAAE;gBAC/B,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,OAAO,CAAC;gBAC9B,IAAI,CAAC,UAAU,EAAE,CAAC;aACrB;SACJ;QACD,IAAI,IAAI,CAAC,aAAa,EAAE;YACpB,qBAAqB,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;SACtD;IACL,CAAC;IAED,YAAY;IACL,sCAAU,GAAjB;QACI,IAAI,IAAI,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC;QACpC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE;YAC9B,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;YACjB,OAAO;SACV;QACD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC;QACjC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC;QACjC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;QAC7B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;QAC/B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;QAC7B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAE1C,IAAI,KAAK,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC;QACtB,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;QAChC;2CACmC;QACnC,0BAA0B;QAC1B,IAAI,IAAI,CAAC,yEAAyE,EAAE;YAChF,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;YAC1B,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;YAC1B,IAAI,CAAC,WAAW,EAAE,CAAC;YACnB;uCAC2B;SAC9B;QACD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IAC9B,CAAC;IAES,qCAAS,GAAnB;QACI,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;QACnC,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;QAC3B,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;IAC5B,CAAC;IAED;;;OAGG;IACK,sCAAU,GAAlB,UAAmB,IAAa;QAC5B,IAAI,OAAO,GAAG,CAAC,IAAI,CAAC,OAAO,GAAG,GAAG,CAAC,CAAC;QACnC,IAAI,UAAU,GAAG,IAAI,CAAC,MAAM,CAAA;QAC5B,OAAO,UAAU,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,IAAI,UAAU,IAAI,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,EAAE;YAClF,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,GAAG,GAAG,CAAC,CAAC;YACtC,UAAU,GAAG,UAAU,CAAC,MAAM,CAAC;SAClC;QACD,OAAO,OAAO,GAAG,GAAG,CAAC;IACzB,CAAC;IACD,YAAY;IACJ,uCAAW,GAAnB;QACI,IAAI,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACtE,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC;IACpF,CAAC;IACD,YAAY;IACJ,yCAAa,GAArB,UAAsB,IAAa;QAC/B,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,4BAA4B,CAAC,IAAI,CAAC,CAAC;IAC7E,CAAC;IACD;;;;OAIG;IACK,wDAA4B,GAApC,UAAqC,MAAe;QAChD,SAAS;QACT,IAAI,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1G,IAAI,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAE1G,yBAAyB;QACzB,IAAI,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC;QAEnE,WAAW;QACX,IAAI,OAAO,GAAG,KAAK,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC;QACtC,OAAO,OAAO,CAAC;IACnB,CAAC;IACD;;;OAGG;IACK,yCAAa,GAArB,UAAsB,IAAa;QAC/B,IAAI,KAAK,GAAG,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAA;QAC3C,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC;QAC1C,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC;QAC1C,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC;IAC9C,CAAC;IACD;;;;OAIG;IACK,gDAAoB,GAA5B,UAA6B,IAAa;QACtC,IAAI,MAAM,GAAG,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;QAC1D,IAAI,MAAM,GAAG,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;QAC1D,IAAI,MAAM,GAAG,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;QAC3D,OAAO,EAAE,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC,CAAC;IACD;;;OAGG;IACK,qCAAS,GAAjB;;QACI,IAAI,IAAI,GAAG,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACzB,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC;QAC5D,MAAA,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,YAAY,CAAC,0CAAE,OAAO,GAAG;QACnD,MAAA,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,WAAW,CAAC,0CAAE,OAAO,GAAG;QAClD,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC,OAAO,EAAE,CAAC;QACrD,IAAI,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC;QAClD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,GAAG,GAAG,EAAE,EAAE,CAAC,EAAE;YACnD,IAAI,IAAI,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;YACzB,IAAI,CAAC,CAAC,CAAC,IAAI,YAAY,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,YAAY,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,YAAY,EAAE,CAAC,WAAW,CAAC,CAAC,EAAE;gBAClH,IAAI,CAAC,OAAO,EAAE,CAAC;aAClB;SACJ;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;;IA3MD;QADC,QAAQ;2DACuB;IAKhC;QAHC,QAAQ,CAAC;YACN,OAAO,EAAE,uCAAuC;SACnD,CAAC;sDAC4B;IAVb,iBAAiB;QADrC,OAAO;OACa,iBAAiB,CAkNrC;IAAD,wBAAC;CAlND,AAkNC,CAlN8C,EAAE,CAAC,SAAS,GAkN1D;kBAlNoB,iBAAiB","file":"","sourceRoot":"/","sourcesContent":["import { RenderReactiveHandler } from \"./RenderReactiveHandler\";\r\n\r\n/**\r\n * 目前该渲染代理功能存在的问题\r\n * 1.被代理节点的父级不能出现scaleX和scaleY不一致的情况,被代理节点本身没有这个限制\r\n */\r\nconst { ccclass, property } = cc._decorator;\r\n@ccclass\r\nexport default class RenderAlternative extends cc.Component {\r\n /**渲染层节点 */\r\n public renderLayer: cc.Node = null;\r\n /**渲染的zIndex 动态调整zIndex,用于方便临近合批 */\r\n @property\r\n public renderZIndex: number = 0;\r\n /**同步的间隔(帧为单位) */\r\n @property({\r\n tooltip: '设置同步的间隔(秒为单位),0就是每帧都同步,0.1就是隔0.1秒同步一次'\r\n })\r\n public syncInv: number = 0.01;\r\n /**渲染的sIndex */\r\n public sIndex: number = 0;\r\n /**非渲染组件 */\r\n public proxyRender: cc.RenderComponent = null;\r\n /**渲染组件 */\r\n private renderCompnent: cc.RenderComponent = null;\r\n /**上次更新的数据 */\r\n public lastWMat4: cc.Mat4 = null;\r\n /**上次更新的数据 */\r\n public lastLMat4: cc.Mat4 = null;\r\n /**上次更新的数据 */\r\n public lastPos: cc.Vec3 = null;\r\n /**距离下次刷新累计了多少间隔 */\r\n public accuTime: number = 0;\r\n /**最后一次刷新时间 */\r\n public lastFrameTime: number = null;\r\n /**是否进行刷新 */\r\n public isAttachFrame: boolean = false;\r\n\r\n /**获取总的ZIndex */\r\n get zIndex() {\r\n let zIndex = this.renderZIndex + (this.sIndex * 0.01);\r\n let parentNode = this.node.parent;\r\n while (parentNode != this.renderLayer.parent && parentNode != cc.director.getScene()) {\r\n let render = parentNode.getComponent(RenderAlternative);\r\n if (render) {\r\n zIndex += render.zIndex + 1;\r\n break;\r\n }\r\n parentNode = parentNode.parent;\r\n }\r\n return zIndex;\r\n }\r\n\r\n /**\r\n * 设置渲染节点层\r\n * @param layer \r\n */\r\n init(layer?: cc.Node): T {\r\n if (layer) {\r\n this.renderLayer = layer;\r\n }\r\n if (!this.renderLayer) {\r\n console.warn(`节点${this.node.name}没有设置渲染层`)\r\n return null;\r\n }\r\n return this.initRender();\r\n }\r\n /**\r\n * 初始化渲染节点\r\n */\r\n private initRender(): T {\r\n let node = this.getRender();\r\n node.setParent(this.renderLayer ? this.renderLayer : cc.director.getScene().getChildByName(\"Canvas\"));\r\n this.isAttachFrame = true;\r\n requestAnimationFrame(this.frameUpdate.bind(this));\r\n return this.doProxy();\r\n }\r\n /**生成代理 */\r\n private doProxy(): T {\r\n this.proxyRender = new Proxy(this.renderCompnent, new RenderReactiveHandler()) as T;\r\n return this.proxyRender as T;\r\n }\r\n\r\n\r\n protected frameUpdate(): void {\r\n let now = cc.sys.now();\r\n !this.lastFrameTime && (this.lastFrameTime = now);\r\n let dt = now - this.lastFrameTime;\r\n if (this.proxyRender) {\r\n this.accuTime += dt;\r\n if (this.accuTime >= this.syncInv) {\r\n this.accuTime -= this.syncInv;\r\n this.updateProp();\r\n }\r\n }\r\n if (this.isAttachFrame) {\r\n requestAnimationFrame(this.frameUpdate.bind(this));\r\n }\r\n }\r\n\r\n /**更新最新状态 */\r\n public updateProp() {\r\n let node = this.renderCompnent.node;\r\n if (!this.node.activeInHierarchy) {\r\n node.opacity = 0;\r\n return;\r\n }\r\n node.anchorX = this.node.anchorX;\r\n node.anchorY = this.node.anchorY;\r\n node.width = this.node.width;\r\n node.height = this.node.height;\r\n node.group = this.node.group;\r\n node.color = this.node.color;\r\n node.opacity = this.getOpacity(this.node);\r\n\r\n let wMat4 = cc.mat4();\r\n this.node.getWorldMatrix(wMat4);\r\n /* let lMat4 = cc.mat4();\r\n this.node.getLocalMatrix(wMat4); */\r\n //此处本可以过滤许多不必要的更新,但尚未排查出问题\r\n if (true /* || !this.lastWMat4?.equals(wMat4) || !this.lastLMat4?.equals(lMat4) */) {\r\n this.onAngleChange(wMat4);\r\n this.onScaleChange(wMat4);\r\n this.onPosChange();\r\n /* this.lastLMat4 = lMat4;\r\n this.lastWMat4 = wMat4; */\r\n }\r\n node.zIndex = this.zIndex;\r\n node.zIndex = this.zIndex;\r\n }\r\n\r\n protected onDestroy(): void {\r\n this.renderCompnent.node.destroy();\r\n this.renderCompnent = null;\r\n this.proxyRender = null;\r\n }\r\n\r\n /**\r\n * 获取节点透明度\r\n * @param node \r\n */\r\n private getOpacity(node: cc.Node) {\r\n let opacity = (node.opacity / 255);\r\n let parentNode = node.parent\r\n while (parentNode != this.renderLayer.parent && parentNode != cc.director.getScene()) {\r\n opacity *= (parentNode.opacity / 255);\r\n parentNode = parentNode.parent;\r\n }\r\n return opacity * 255;\r\n }\r\n /**位置变化处理 */\r\n private onPosChange() {\r\n let wpos = this.node.parent.convertToWorldSpaceAR(this.node.position);\r\n this.renderCompnent.node.position = this.renderLayer.convertToNodeSpaceAR(wpos);\r\n }\r\n /**旋转变化处理 */\r\n private onAngleChange(mat4: cc.Mat4) {\r\n this.renderCompnent.node.angle = this.extractRotationAngleFromMat4(mat4);\r\n }\r\n /**\r\n * 从 cc.Mat4 中获取旋转角度(不受缩放影响)\r\n * @param matrix 输入的 cc.Mat4 矩阵\r\n * @returns 旋转角度(以度为单位)\r\n */\r\n private extractRotationAngleFromMat4(matrix: cc.Mat4): number {\r\n // 提取旋转部分\r\n let scaleX = Math.sqrt(matrix.m[0] * matrix.m[0] + matrix.m[4] * matrix.m[4] + matrix.m[8] * matrix.m[8]);\r\n let scaleY = Math.sqrt(matrix.m[1] * matrix.m[1] + matrix.m[5] * matrix.m[5] + matrix.m[9] * matrix.m[9]);\r\n\r\n // 计算 Z 轴旋转角度(绕 Z 轴的旋转角度)\r\n let angle = Math.atan2(matrix.m[1] / scaleY, matrix.m[0] / scaleX);\r\n\r\n // 将弧度转换为角度\r\n let degrees = angle * (180 / Math.PI);\r\n return degrees;\r\n }\r\n /**\r\n * 缩放变化处理\r\n * @param mat4 \r\n */\r\n private onScaleChange(mat4: cc.Mat4) {\r\n let scale = this.extractScaleFromMat4(mat4)\r\n this.renderCompnent.node.scaleX = scale.x;\r\n this.renderCompnent.node.scaleY = scale.y;\r\n this.renderCompnent.node.scaleZ = scale.z;\r\n }\r\n /**\r\n * 从mat4中获取缩放值\r\n * @param mat4 \r\n * @returns \r\n */\r\n private extractScaleFromMat4(mat4: cc.Mat4): cc.Vec3 {\r\n let scaleX = cc.v3(mat4.m[0], mat4.m[1], mat4.m[2]).mag();\r\n let scaleY = cc.v3(mat4.m[4], mat4.m[5], mat4.m[6]).mag();\r\n let scaleZ = cc.v3(mat4.m[8], mat4.m[9], mat4.m[10]).mag();\r\n return cc.v3(scaleX, scaleY, scaleZ);\r\n }\r\n /**\r\n * 获取渲染组件\r\n * @param node \r\n */\r\n private getRender() {\r\n let node = cc.instantiate(this.node);\r\n node.removeAllChildren();\r\n this.renderCompnent = node.getComponent(cc.RenderComponent);\r\n this.node.getComponent(cc.LabelOutline)?.destroy();\r\n this.node.getComponent(cc.LabelShadow)?.destroy();\r\n this.node.getComponent(cc.RenderComponent).destroy();\r\n let components = node.getComponents(cc.Component);\r\n for (let i = 0, len = components.length; i < len; ++i) {\r\n let comp = components[i];\r\n if (!((comp instanceof cc.RenderComponent) || (comp instanceof cc.LabelOutline) || (comp instanceof cc.LabelShadow))) {\r\n comp.destroy();\r\n }\r\n }\r\n return node;\r\n }\r\n\r\n}\r\n"]} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Script/RenderAlternative1.js b/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Script/RenderAlternative1.js new file mode 100644 index 0000000..2d818d1 --- /dev/null +++ b/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Script/RenderAlternative1.js @@ -0,0 +1,264 @@ +"use strict"; +cc._RF.push(module, '5be15eLnZlCKqPK4B3Y4J6x', 'RenderAlternative1'); +// Script/RenderAlternative1.ts + +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var RenderReactiveHandler_1 = require("./RenderReactiveHandler"); +/** + * 目前该渲染代理功能存在的问题 + * 1.被代理节点的父级不能出现scaleX和scaleY不一致的情况,被代理节点本身没有这个限制 + */ +var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property; +var RenderAlternative = /** @class */ (function (_super) { + __extends(RenderAlternative, _super); + function RenderAlternative() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /**渲染层节点 */ + _this.renderLayer = null; + /**渲染的zIndex 动态调整zIndex,用于方便临近合批 */ + _this.renderZIndex = 0; + /**同步的间隔(帧为单位) */ + _this.syncInv = 0.01; + /**渲染的sIndex */ + _this.sIndex = 0; + /**非渲染组件 */ + _this.proxyRender = null; + /**渲染组件 */ + _this.renderCompnent = null; + /**上次更新的数据 */ + _this.lastWMat4 = null; + /**上次更新的数据 */ + _this.lastLMat4 = null; + /**上次更新的数据 */ + _this.lastPos = null; + /**距离下次刷新累计了多少间隔 */ + _this.accuTime = 0; + /**最后一次刷新时间 */ + _this.lastFrameTime = null; + /**是否进行刷新 */ + _this.isAttachFrame = false; + return _this; + } + RenderAlternative_1 = RenderAlternative; + Object.defineProperty(RenderAlternative.prototype, "zIndex", { + /**获取总的ZIndex */ + get: function () { + var zIndex = this.renderZIndex + (this.sIndex * 0.01); + var parentNode = this.node.parent; + while (parentNode != this.renderLayer.parent && parentNode != cc.director.getScene()) { + var render = parentNode.getComponent(RenderAlternative_1); + if (render) { + zIndex += render.zIndex + 1; + break; + } + parentNode = parentNode.parent; + } + return zIndex; + }, + enumerable: false, + configurable: true + }); + /** + * 设置渲染节点层 + * @param layer + */ + RenderAlternative.prototype.init = function (layer) { + if (layer) { + this.renderLayer = layer; + } + if (!this.renderLayer) { + console.warn("\u8282\u70B9" + this.node.name + "\u6CA1\u6709\u8BBE\u7F6E\u6E32\u67D3\u5C42"); + return null; + } + return this.initRender(); + }; + /** + * 初始化渲染节点 + */ + RenderAlternative.prototype.initRender = function () { + var node = this.getRender(); + node.setParent(this.renderLayer ? this.renderLayer : cc.director.getScene().getChildByName("Canvas")); + this.isAttachFrame = true; + requestAnimationFrame(this.frameUpdate.bind(this)); + return this.doProxy(); + }; + /**生成代理 */ + RenderAlternative.prototype.doProxy = function () { + this.proxyRender = new Proxy(this.renderCompnent, new RenderReactiveHandler_1.RenderReactiveHandler()); + return this.proxyRender; + }; + RenderAlternative.prototype.frameUpdate = function () { + var now = cc.sys.now(); + !this.lastFrameTime && (this.lastFrameTime = now); + var dt = now - this.lastFrameTime; + if (this.proxyRender) { + this.accuTime += dt; + if (this.accuTime >= this.syncInv) { + this.accuTime -= this.syncInv; + this.updateProp(); + } + } + if (this.isAttachFrame) { + requestAnimationFrame(this.frameUpdate.bind(this)); + } + }; + /**更新最新状态 */ + RenderAlternative.prototype.updateProp = function () { + var node = this.renderCompnent.node; + if (!this.node.activeInHierarchy) { + node.opacity = 0; + return; + } + node.anchorX = this.node.anchorX; + node.anchorY = this.node.anchorY; + node.width = this.node.width; + node.height = this.node.height; + node.group = this.node.group; + node.color = this.node.color; + node.opacity = this.getOpacity(this.node); + var wMat4 = cc.mat4(); + this.node.getWorldMatrix(wMat4); + if (!this.lastWMat4 || !this.lastWMat4.equals(wMat4)) { + var localMatrix = this.getLocalMatrix(wMat4, node); + this.setLocalXYZScaleAngle(localMatrix, node, this.lastLMat4); + this.lastWMat4 = wMat4; + this.lastLMat4 = localMatrix; + } + node.zIndex = this.zIndex; + }; + RenderAlternative.prototype.getLocalMatrix = function (worldMatrix, node) { + var parentNode = null; + if (cc.isValid(node)) { + if (cc.isValid(node.parent)) { + parentNode = node.parent; + } + } + // 获取父节点的世界矩阵 + var parentWorldMatrix = cc.mat4(); + parentNode.getWorldMatrix(parentWorldMatrix); + // 获取父节点的逆矩阵 + var parentInverseMatrix = parentWorldMatrix.invert(); + // 将目标节点的世界矩阵转换为父节点的本地矩阵 + var localMatrix = parentInverseMatrix.multiply(worldMatrix); + return localMatrix; + }; + RenderAlternative.prototype.setLocalXYZScaleAngle = function (matrix, node, lastMatrix) { + if (lastMatrix && matrix.equals(lastMatrix)) { + return; + } + // 提取位置 + node.setPosition(matrix.m[12], matrix.m[13], matrix.m[14]); + var scaleX = null; + var scaleY = null; + var angle = null; + // 提取缩放X + if (!lastMatrix) { + scaleX = Math.sqrt(matrix.m[0] * matrix.m[0] + matrix.m[1] * matrix.m[1] + matrix.m[2] * matrix.m[2]); + } + else if (!this.equalsValue(matrix.m[0], lastMatrix.m[0]) + || !this.equalsValue(matrix.m[1], lastMatrix.m[1]) + || !this.equalsValue(matrix.m[2], lastMatrix.m[2])) { + scaleX = Math.sqrt(matrix.m[0] * matrix.m[0] + matrix.m[1] * matrix.m[1] + matrix.m[2] * matrix.m[2]); + } + // 提取缩放Y + if (!lastMatrix) { + scaleY = Math.sqrt(matrix.m[4] * matrix.m[4] + matrix.m[5] * matrix.m[5] + matrix.m[6] * matrix.m[6]); + } + else if (!this.equalsValue(matrix.m[4], lastMatrix.m[4]) + || !this.equalsValue(matrix.m[5], lastMatrix.m[5]) + || !this.equalsValue(matrix.m[6], lastMatrix.m[6])) { + scaleY = Math.sqrt(matrix.m[4] * matrix.m[4] + matrix.m[5] * matrix.m[5] + matrix.m[6] * matrix.m[6]); + } + //设置缩放X + if (scaleX !== null) { + node.scaleX = scaleX; + // 提取旋转 + angle = Math.atan2(matrix.m[1] / scaleX, matrix.m[0] / scaleX) * (180 / Math.PI); + } + if (scaleY !== null) { + node.scaleY = scaleY; + } + if (angle !== null) { + node.rotation = angle; + } + }; + RenderAlternative.prototype.equalsValue = function (a, b, epsilon) { + if (epsilon === void 0) { epsilon = 0.00001; } + return Math.abs(a - b) < epsilon; + }; + RenderAlternative.prototype.onDestroy = function () { + this.renderCompnent.node.destroy(); + this.renderCompnent = null; + this.proxyRender = null; + }; + /** + * 获取节点透明度 + * @param node + */ + RenderAlternative.prototype.getOpacity = function (node) { + var opacity = (node.opacity / 255); + var parentNode = node.parent; + while (parentNode != this.renderLayer.parent && parentNode != cc.director.getScene()) { + opacity *= (parentNode.opacity / 255); + parentNode = parentNode.parent; + } + return opacity * 255; + }; + /** + * 获取渲染组件 + * @param node + */ + RenderAlternative.prototype.getRender = function () { + var _a, _b; + var node = cc.instantiate(this.node); + node.removeAllChildren(); + this.renderCompnent = node.getComponent(cc.RenderComponent); + (_a = this.node.getComponent(cc.LabelOutline)) === null || _a === void 0 ? void 0 : _a.destroy(); + (_b = this.node.getComponent(cc.LabelShadow)) === null || _b === void 0 ? void 0 : _b.destroy(); + this.node.getComponent(cc.RenderComponent).destroy(); + var components = node.getComponents(cc.Component); + for (var i = 0, len = components.length; i < len; ++i) { + var comp = components[i]; + if (!((comp instanceof cc.RenderComponent) || (comp instanceof cc.LabelOutline) || (comp instanceof cc.LabelShadow))) { + comp.destroy(); + } + } + return node; + }; + var RenderAlternative_1; + __decorate([ + property + ], RenderAlternative.prototype, "renderZIndex", void 0); + __decorate([ + property({ + tooltip: '设置同步的间隔(秒为单位),0就是每帧都同步,0.1就是隔0.1秒同步一次' + }) + ], RenderAlternative.prototype, "syncInv", void 0); + RenderAlternative = RenderAlternative_1 = __decorate([ + ccclass + ], RenderAlternative); + return RenderAlternative; +}(cc.Component)); +exports.default = RenderAlternative; + +cc._RF.pop(); \ No newline at end of file diff --git a/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Script/RenderAlternativeItem.js b/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Script/RenderAlternativeItem.js new file mode 100644 index 0000000..9717478 --- /dev/null +++ b/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Script/RenderAlternativeItem.js @@ -0,0 +1,109 @@ +"use strict"; +cc._RF.push(module, 'd33f6MUGOxJN5eMJ9UzS3KH', 'RenderAlternativeItem'); +// Script/RenderAlternativeItem.ts + +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var RenderAlternative_1 = require("./RenderAlternative"); +var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property; +var RenderAlternativeItem = /** @class */ (function (_super) { + __extends(RenderAlternativeItem, _super); + /** + * 渲染分层Item挂载组件 + * 处理渲染分层Item的渲染分层 + */ + function RenderAlternativeItem() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /**是否初始化过代理组建 */ + _this.hasInit = false; + return _this; + } + /**初始化 */ + RenderAlternativeItem.prototype.initRenderLayer = function (renderLayer) { + if (this.renderLayer != renderLayer) { + this.renderLayer = renderLayer; + renderLayer && this.initRenders(); + } + }; + /** + * 处理分层代理渲染 + */ + RenderAlternativeItem.prototype.initRenders = function () { + if (!this.hasInit && this.renderLayer) { + // + var propMap = new WeakMap(); + var keys = Object.keys(this); + for (var i = 0, len = keys.length; i < len; ++i) { + var value = this[keys[i]]; + var alternative = null; + if (value instanceof cc.Node) { + alternative = value.getComponent(RenderAlternative_1.default); + if (alternative) { + alternative.init(this.renderLayer); + } + } + else if (value instanceof cc.RenderComponent) { + alternative = value.getComponent(RenderAlternative_1.default); + if (alternative) { + this[keys[i]] = alternative.init(this.renderLayer); + } + } + alternative && propMap.set(alternative, true); + } + this.dealChilrenAlternative(this.node, propMap, 0, 0); + this.hasInit = true; + } + }; + /** + * 处理子节点代理 + * @param node + * @param propMap 记录脚本已经处理过的属性代理 + * @param parentSindex 父节点的所在的顺序 + * @param depth 深度 + */ + RenderAlternativeItem.prototype.dealChilrenAlternative = function (node, propMap, parentSindex, depth) { + var _a; + for (var i = 0, len = node.children.length; i < len; i++) { + var children = node.children[i]; + var alternative = (_a = children.getComponent(cc.RenderComponent)) === null || _a === void 0 ? void 0 : _a.getComponent(RenderAlternative_1.default); + var sIndex = parentSindex + (i * Math.pow(0.1, depth)); + if (alternative) { + if ((!propMap.has(alternative) || !propMap.get(alternative))) { + alternative.init(this.renderLayer); + } + alternative.sIndex = sIndex; + } + this.dealChilrenAlternative(children, propMap, sIndex, depth + 1); + } + }; + RenderAlternativeItem = __decorate([ + ccclass + /** + * 渲染分层Item挂载组件 + * 处理渲染分层Item的渲染分层 + */ + ], RenderAlternativeItem); + return RenderAlternativeItem; +}(cc.Component)); +exports.default = RenderAlternativeItem; + +cc._RF.pop(); \ No newline at end of file diff --git a/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Script/RenderAlternativeItem.js.map b/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Script/RenderAlternativeItem.js.map new file mode 100644 index 0000000..3fa21b1 --- /dev/null +++ b/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Script/RenderAlternativeItem.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["assets\\Script\\RenderAlternativeItem.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yDAAoD;AAG9C,IAAA,KAAwB,EAAE,CAAC,UAAU,EAAnC,OAAO,aAAA,EAAE,QAAQ,cAAkB,CAAC;AAO5C;IAAmD,yCAAY;IAJ/D;;;OAGG;IACH;QAAA,qEA8DC;QA5DG,gBAAgB;QACR,aAAO,GAAY,KAAK,CAAC;;IA2DrC,CAAC;IAxDG,SAAS;IACF,+CAAe,GAAtB,UAAuB,WAAoB;QACvC,IAAI,IAAI,CAAC,WAAW,IAAI,WAAW,EAAE;YACjC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;YAC/B,WAAW,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;SACrC;IACL,CAAC;IACD;;OAEG;IACK,2CAAW,GAAnB;QACI,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,WAAW,EAAE;YACnC,EAAE;YACF,IAAI,OAAO,GAAwC,IAAI,OAAO,EAAE,CAAC;YACjE,IAAI,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC7B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,GAAG,GAAG,EAAE,EAAE,CAAC,EAAE;gBAC7C,IAAI,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;gBAC1B,IAAI,WAAW,GAAsB,IAAI,CAAC;gBAC1C,IAAI,KAAK,YAAY,EAAE,CAAC,IAAI,EAAE;oBAC1B,WAAW,GAAG,KAAK,CAAC,YAAY,CAAC,2BAAiB,CAAC,CAAC;oBACpD,IAAI,WAAW,EAAE;wBACb,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;qBACtC;iBACJ;qBAAM,IAAI,KAAK,YAAY,EAAE,CAAC,eAAe,EAAE;oBAC5C,WAAW,GAAG,KAAK,CAAC,YAAY,CAAC,2BAAiB,CAAC,CAAC;oBACpD,IAAI,WAAW,EAAE;wBACb,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,IAAI,CAAe,IAAI,CAAC,WAAW,CAAC,CAAC;qBACpE;iBACJ;gBACD,WAAW,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;aACjD;YACD,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;YACtD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;SACvB;IACL,CAAC;IACD;;;;;;OAMG;IACH,sDAAsB,GAAtB,UAAuB,IAAa,EAAE,OAA4C,EAAE,YAAoB,EAAE,KAAa;;QACnH,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE;YACtD,IAAI,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;YAChC,IAAI,WAAW,SAAG,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC,eAAe,CAAC,0CAAE,YAAY,CAAC,2BAAiB,CAAC,CAAC;YAC7F,IAAI,MAAM,GAAG,YAAY,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;YACvD,IAAI,WAAW,EAAE;gBACb,IAAI,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,EAAE;oBAC1D,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;iBACtC;gBACD,WAAW,CAAC,MAAM,GAAG,MAAM,CAAC;aAC/B;YACD,IAAI,CAAC,sBAAsB,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;SACrE;IACL,CAAC;IA7DgB,qBAAqB;QALzC,OAAO;QACR;;;WAGG;OACkB,qBAAqB,CA8DzC;IAAD,4BAAC;CA9DD,AA8DC,CA9DkD,EAAE,CAAC,SAAS,GA8D9D;kBA9DoB,qBAAqB","file":"","sourceRoot":"/","sourcesContent":["import RenderAlternative from \"./RenderAlternative\";\r\n\r\n\r\nconst { ccclass, property } = cc._decorator;\r\n\r\n@ccclass\r\n/**\r\n * 渲染分层Item挂载组件\r\n * 处理渲染分层Item的渲染分层\r\n */\r\nexport default class RenderAlternativeItem extends cc.Component {\r\n\r\n /**是否初始化过代理组建 */\r\n private hasInit: boolean = false;\r\n /**渲染分层开启的挂载节点 */\r\n public renderLayer: cc.Node;\r\n /**初始化 */\r\n public initRenderLayer(renderLayer: cc.Node) {\r\n if (this.renderLayer != renderLayer) {\r\n this.renderLayer = renderLayer;\r\n renderLayer && this.initRenders();\r\n }\r\n }\r\n /**\r\n * 处理分层代理渲染\r\n */\r\n private initRenders() {\r\n if (!this.hasInit && this.renderLayer) {\r\n //\r\n let propMap: WeakMap = new WeakMap();\r\n let keys = Object.keys(this);\r\n for (let i = 0, len = keys.length; i < len; ++i) {\r\n let value = this[keys[i]];\r\n let alternative: RenderAlternative = null;\r\n if (value instanceof cc.Node) {\r\n alternative = value.getComponent(RenderAlternative);\r\n if (alternative) {\r\n alternative.init(this.renderLayer);\r\n }\r\n } else if (value instanceof cc.RenderComponent) {\r\n alternative = value.getComponent(RenderAlternative);\r\n if (alternative) {\r\n this[keys[i]] = alternative.init(this.renderLayer);\r\n }\r\n }\r\n alternative && propMap.set(alternative, true);\r\n }\r\n this.dealChilrenAlternative(this.node, propMap, 0, 0);\r\n this.hasInit = true;\r\n }\r\n }\r\n /**\r\n * 处理子节点代理\r\n * @param node \r\n * @param propMap 记录脚本已经处理过的属性代理\r\n * @param parentSindex 父节点的所在的顺序\r\n * @param depth 深度\r\n */\r\n dealChilrenAlternative(node: cc.Node, propMap: WeakMap, parentSindex: number, depth: number) {\r\n for (let i = 0, len = node.children.length; i < len; i++) {\r\n let children = node.children[i];\r\n let alternative = children.getComponent(cc.RenderComponent)?.getComponent(RenderAlternative);\r\n let sIndex = parentSindex + (i * Math.pow(0.1, depth));\r\n if (alternative) {\r\n if ((!propMap.has(alternative) || !propMap.get(alternative))) {\r\n alternative.init(this.renderLayer);\r\n }\r\n alternative.sIndex = sIndex;\r\n }\r\n this.dealChilrenAlternative(children, propMap, sIndex, depth + 1);\r\n }\r\n }\r\n}\r\n"]} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Script/RenderAlternative_old.js b/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Script/RenderAlternative_old.js new file mode 100644 index 0000000..5abc2a4 --- /dev/null +++ b/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Script/RenderAlternative_old.js @@ -0,0 +1,254 @@ +"use strict"; +cc._RF.push(module, '1b478Wr4HlMhLdWnJWcD6fi', 'RenderAlternative_old'); +// Script/RenderAlternative_old.ts + +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var RenderReactiveHandler_1 = require("./RenderReactiveHandler"); +/** + * 目前该渲染代理功能存在的问题 + * 1.被代理节点的父级不能出现scaleX和scaleY不一致的情况,被代理节点本身没有这个限制 + */ +var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property; +var RenderAlternative = /** @class */ (function (_super) { + __extends(RenderAlternative, _super); + function RenderAlternative() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /**渲染层节点 */ + _this.renderLayer = null; + /**渲染的zIndex 动态调整zIndex,用于方便临近合批 */ + _this.renderZIndex = 0; + /**同步的间隔(帧为单位) */ + _this.syncInv = 0.01; + /**渲染的sIndex */ + _this.sIndex = 0; + /**非渲染组件 */ + _this.proxyRender = null; + /**渲染组件 */ + _this.renderCompnent = null; + /**上次更新的数据 */ + _this.lastWMat4 = null; + /**上次更新的数据 */ + _this.lastLMat4 = null; + /**上次更新的数据 */ + _this.lastPos = null; + /**距离下次刷新累计了多少间隔 */ + _this.accuTime = 0; + /**最后一次刷新时间 */ + _this.lastFrameTime = null; + /**是否进行刷新 */ + _this.isAttachFrame = false; + return _this; + } + RenderAlternative_1 = RenderAlternative; + Object.defineProperty(RenderAlternative.prototype, "zIndex", { + /**获取总的ZIndex */ + get: function () { + var zIndex = this.renderZIndex + (this.sIndex * 0.01); + var parentNode = this.node.parent; + while (parentNode != this.renderLayer.parent && parentNode != cc.director.getScene()) { + var render = parentNode.getComponent(RenderAlternative_1); + if (render) { + zIndex += render.zIndex + 1; + break; + } + parentNode = parentNode.parent; + } + return zIndex; + }, + enumerable: false, + configurable: true + }); + /** + * 设置渲染节点层 + * @param layer + */ + RenderAlternative.prototype.init = function (layer) { + if (layer) { + this.renderLayer = layer; + } + if (!this.renderLayer) { + console.warn("\u8282\u70B9" + this.node.name + "\u6CA1\u6709\u8BBE\u7F6E\u6E32\u67D3\u5C42"); + return null; + } + return this.initRender(); + }; + /** + * 初始化渲染节点 + */ + RenderAlternative.prototype.initRender = function () { + var node = this.getRender(); + node.setParent(this.renderLayer ? this.renderLayer : cc.director.getScene().getChildByName("Canvas")); + this.isAttachFrame = true; + requestAnimationFrame(this.frameUpdate.bind(this)); + return this.doProxy(); + }; + /**生成代理 */ + RenderAlternative.prototype.doProxy = function () { + this.proxyRender = new Proxy(this.renderCompnent, new RenderReactiveHandler_1.RenderReactiveHandler()); + return this.proxyRender; + }; + RenderAlternative.prototype.frameUpdate = function () { + var now = cc.sys.now(); + !this.lastFrameTime && (this.lastFrameTime = now); + var dt = now - this.lastFrameTime; + if (this.proxyRender) { + this.accuTime += dt; + if (this.accuTime >= this.syncInv) { + this.accuTime -= this.syncInv; + this.updateProp(); + } + } + if (this.isAttachFrame) { + requestAnimationFrame(this.frameUpdate.bind(this)); + } + }; + /**更新最新状态 */ + RenderAlternative.prototype.updateProp = function () { + var node = this.renderCompnent.node; + if (!this.node.activeInHierarchy) { + node.opacity = 0; + return; + } + node.anchorX = this.node.anchorX; + node.anchorY = this.node.anchorY; + node.width = this.node.width; + node.height = this.node.height; + node.group = this.node.group; + node.color = this.node.color; + node.opacity = this.getOpacity(this.node); + var wMat4 = cc.mat4(); + this.node.getWorldMatrix(wMat4); + /* let lMat4 = cc.mat4(); + this.node.getLocalMatrix(wMat4); */ + //此处本可以过滤许多不必要的更新,但尚未排查出问题 + if (true /* || !this.lastWMat4?.equals(wMat4) || !this.lastLMat4?.equals(lMat4) */) { + this.onAngleChange(wMat4); + this.onScaleChange(wMat4); + this.onPosChange(); + /* this.lastLMat4 = lMat4; + this.lastWMat4 = wMat4; */ + } + node.zIndex = this.zIndex; + node.zIndex = this.zIndex; + }; + RenderAlternative.prototype.onDestroy = function () { + this.renderCompnent.node.destroy(); + this.renderCompnent = null; + this.proxyRender = null; + }; + /** + * 获取节点透明度 + * @param node + */ + RenderAlternative.prototype.getOpacity = function (node) { + var opacity = (node.opacity / 255); + var parentNode = node.parent; + while (parentNode != this.renderLayer.parent && parentNode != cc.director.getScene()) { + opacity *= (parentNode.opacity / 255); + parentNode = parentNode.parent; + } + return opacity * 255; + }; + /**位置变化处理 */ + RenderAlternative.prototype.onPosChange = function () { + var wpos = this.node.parent.convertToWorldSpaceAR(this.node.position); + this.renderCompnent.node.position = this.renderLayer.convertToNodeSpaceAR(wpos); + }; + /**旋转变化处理 */ + RenderAlternative.prototype.onAngleChange = function (mat4) { + this.renderCompnent.node.angle = this.extractRotationAngleFromMat4(mat4); + }; + /** + * 从 cc.Mat4 中获取旋转角度(不受缩放影响) + * @param matrix 输入的 cc.Mat4 矩阵 + * @returns 旋转角度(以度为单位) + */ + RenderAlternative.prototype.extractRotationAngleFromMat4 = function (matrix) { + // 提取旋转部分 + var scaleX = Math.sqrt(matrix.m[0] * matrix.m[0] + matrix.m[4] * matrix.m[4] + matrix.m[8] * matrix.m[8]); + var scaleY = Math.sqrt(matrix.m[1] * matrix.m[1] + matrix.m[5] * matrix.m[5] + matrix.m[9] * matrix.m[9]); + // 计算 Z 轴旋转角度(绕 Z 轴的旋转角度) + var angle = Math.atan2(matrix.m[1] / scaleY, matrix.m[0] / scaleX); + // 将弧度转换为角度 + var degrees = angle * (180 / Math.PI); + return degrees; + }; + /** + * 缩放变化处理 + * @param mat4 + */ + RenderAlternative.prototype.onScaleChange = function (mat4) { + var scale = this.extractScaleFromMat4(mat4); + this.renderCompnent.node.scaleX = scale.x; + this.renderCompnent.node.scaleY = scale.y; + this.renderCompnent.node.scaleZ = scale.z; + }; + /** + * 从mat4中获取缩放值 + * @param mat4 + * @returns + */ + RenderAlternative.prototype.extractScaleFromMat4 = function (mat4) { + var scaleX = cc.v3(mat4.m[0], mat4.m[1], mat4.m[2]).mag(); + var scaleY = cc.v3(mat4.m[4], mat4.m[5], mat4.m[6]).mag(); + var scaleZ = cc.v3(mat4.m[8], mat4.m[9], mat4.m[10]).mag(); + return cc.v3(scaleX, scaleY, scaleZ); + }; + /** + * 获取渲染组件 + * @param node + */ + RenderAlternative.prototype.getRender = function () { + var _a, _b; + var node = cc.instantiate(this.node); + node.removeAllChildren(); + this.renderCompnent = node.getComponent(cc.RenderComponent); + (_a = this.node.getComponent(cc.LabelOutline)) === null || _a === void 0 ? void 0 : _a.destroy(); + (_b = this.node.getComponent(cc.LabelShadow)) === null || _b === void 0 ? void 0 : _b.destroy(); + this.node.getComponent(cc.RenderComponent).destroy(); + var components = node.getComponents(cc.Component); + for (var i = 0, len = components.length; i < len; ++i) { + var comp = components[i]; + if (!((comp instanceof cc.RenderComponent) || (comp instanceof cc.LabelOutline) || (comp instanceof cc.LabelShadow))) { + comp.destroy(); + } + } + return node; + }; + var RenderAlternative_1; + __decorate([ + property + ], RenderAlternative.prototype, "renderZIndex", void 0); + __decorate([ + property({ + tooltip: '设置同步的间隔(秒为单位),0就是每帧都同步,0.1就是隔0.1秒同步一次' + }) + ], RenderAlternative.prototype, "syncInv", void 0); + RenderAlternative = RenderAlternative_1 = __decorate([ + ccclass + ], RenderAlternative); + return RenderAlternative; +}(cc.Component)); +exports.default = RenderAlternative; + +cc._RF.pop(); \ No newline at end of file diff --git a/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Script/RenderAlternative_old.js.map b/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Script/RenderAlternative_old.js.map new file mode 100644 index 0000000..75ce3a3 --- /dev/null +++ b/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Script/RenderAlternative_old.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["assets\\Script\\RenderAlternative_old.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iEAAgE;AAEhE;;;GAGG;AACG,IAAA,KAAwB,EAAE,CAAC,UAAU,EAAnC,OAAO,aAAA,EAAE,QAAQ,cAAkB,CAAC;AAE5C;IAA+C,qCAAY;IAA3D;QAAA,qEAkNC;QAjNG,WAAW;QACJ,iBAAW,GAAY,IAAI,CAAC;QACnC,mCAAmC;QAE5B,kBAAY,GAAW,CAAC,CAAC;QAChC,iBAAiB;QAIV,aAAO,GAAW,IAAI,CAAC;QAC9B,eAAe;QACR,YAAM,GAAW,CAAC,CAAC;QAC1B,WAAW;QACJ,iBAAW,GAAuB,IAAI,CAAC;QAC9C,UAAU;QACF,oBAAc,GAAuB,IAAI,CAAC;QAClD,aAAa;QACN,eAAS,GAAY,IAAI,CAAC;QACjC,aAAa;QACN,eAAS,GAAY,IAAI,CAAC;QACjC,aAAa;QACN,aAAO,GAAY,IAAI,CAAC;QAC/B,mBAAmB;QACZ,cAAQ,GAAW,CAAC,CAAC;QAC5B,cAAc;QACP,mBAAa,GAAW,IAAI,CAAC;QACpC,YAAY;QACL,mBAAa,GAAY,KAAK,CAAC;;IAsL1C,CAAC;0BAlNoB,iBAAiB;IA+BlC,sBAAI,qCAAM;QADV,gBAAgB;aAChB;YACI,IAAI,MAAM,GAAG,IAAI,CAAC,YAAY,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;YACtD,IAAI,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;YAClC,OAAO,UAAU,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,IAAI,UAAU,IAAI,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,EAAE;gBAClF,IAAI,MAAM,GAAG,UAAU,CAAC,YAAY,CAAC,mBAAiB,CAAC,CAAC;gBACxD,IAAI,MAAM,EAAE;oBACR,MAAM,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;oBAC5B,MAAM;iBACT;gBACD,UAAU,GAAG,UAAU,CAAC,MAAM,CAAC;aAClC;YACD,OAAO,MAAM,CAAC;QAClB,CAAC;;;OAAA;IAED;;;OAGG;IACH,gCAAI,GAAJ,UAAmC,KAAe;QAC9C,IAAI,KAAK,EAAE;YACP,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;SAC5B;QACD,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;YACnB,OAAO,CAAC,IAAI,CAAC,iBAAK,IAAI,CAAC,IAAI,CAAC,IAAI,+CAAS,CAAC,CAAA;YAC1C,OAAO,IAAI,CAAC;SACf;QACD,OAAO,IAAI,CAAC,UAAU,EAAK,CAAC;IAChC,CAAC;IACD;;OAEG;IACK,sCAAU,GAAlB;QACI,IAAI,IAAI,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;QAC5B,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC;QACtG,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;QAC1B,qBAAqB,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QACnD,OAAO,IAAI,CAAC,OAAO,EAAK,CAAC;IAC7B,CAAC;IACD,UAAU;IACF,mCAAO,GAAf;QACI,IAAI,CAAC,WAAW,GAAG,IAAI,KAAK,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,6CAAqB,EAAE,CAAM,CAAC;QACpF,OAAO,IAAI,CAAC,WAAgB,CAAC;IACjC,CAAC;IAGS,uCAAW,GAArB;QACI,IAAI,GAAG,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;QACvB,CAAC,IAAI,CAAC,aAAa,IAAI,CAAC,IAAI,CAAC,aAAa,GAAG,GAAG,CAAC,CAAC;QAClD,IAAI,EAAE,GAAG,GAAG,GAAG,IAAI,CAAC,aAAa,CAAC;QAClC,IAAI,IAAI,CAAC,WAAW,EAAE;YAClB,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAC;YACpB,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,OAAO,EAAE;gBAC/B,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,OAAO,CAAC;gBAC9B,IAAI,CAAC,UAAU,EAAE,CAAC;aACrB;SACJ;QACD,IAAI,IAAI,CAAC,aAAa,EAAE;YACpB,qBAAqB,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;SACtD;IACL,CAAC;IAED,YAAY;IACL,sCAAU,GAAjB;QACI,IAAI,IAAI,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC;QACpC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE;YAC9B,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;YACjB,OAAO;SACV;QACD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC;QACjC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC;QACjC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;QAC7B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;QAC/B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;QAC7B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAE1C,IAAI,KAAK,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC;QACtB,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;QAChC;2CACmC;QACnC,0BAA0B;QAC1B,IAAI,IAAI,CAAC,yEAAyE,EAAE;YAChF,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;YAC1B,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;YAC1B,IAAI,CAAC,WAAW,EAAE,CAAC;YACnB;uCAC2B;SAC9B;QACD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IAC9B,CAAC;IAES,qCAAS,GAAnB;QACI,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;QACnC,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;QAC3B,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;IAC5B,CAAC;IAED;;;OAGG;IACK,sCAAU,GAAlB,UAAmB,IAAa;QAC5B,IAAI,OAAO,GAAG,CAAC,IAAI,CAAC,OAAO,GAAG,GAAG,CAAC,CAAC;QACnC,IAAI,UAAU,GAAG,IAAI,CAAC,MAAM,CAAA;QAC5B,OAAO,UAAU,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,IAAI,UAAU,IAAI,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,EAAE;YAClF,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,GAAG,GAAG,CAAC,CAAC;YACtC,UAAU,GAAG,UAAU,CAAC,MAAM,CAAC;SAClC;QACD,OAAO,OAAO,GAAG,GAAG,CAAC;IACzB,CAAC;IACD,YAAY;IACJ,uCAAW,GAAnB;QACI,IAAI,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACtE,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC;IACpF,CAAC;IACD,YAAY;IACJ,yCAAa,GAArB,UAAsB,IAAa;QAC/B,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,4BAA4B,CAAC,IAAI,CAAC,CAAC;IAC7E,CAAC;IACD;;;;OAIG;IACK,wDAA4B,GAApC,UAAqC,MAAe;QAChD,SAAS;QACT,IAAI,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1G,IAAI,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAE1G,yBAAyB;QACzB,IAAI,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC;QAEnE,WAAW;QACX,IAAI,OAAO,GAAG,KAAK,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC;QACtC,OAAO,OAAO,CAAC;IACnB,CAAC;IACD;;;OAGG;IACK,yCAAa,GAArB,UAAsB,IAAa;QAC/B,IAAI,KAAK,GAAG,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAA;QAC3C,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC;QAC1C,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC;QAC1C,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC;IAC9C,CAAC;IACD;;;;OAIG;IACK,gDAAoB,GAA5B,UAA6B,IAAa;QACtC,IAAI,MAAM,GAAG,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;QAC1D,IAAI,MAAM,GAAG,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;QAC1D,IAAI,MAAM,GAAG,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;QAC3D,OAAO,EAAE,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC,CAAC;IACD;;;OAGG;IACK,qCAAS,GAAjB;;QACI,IAAI,IAAI,GAAG,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACzB,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC;QAC5D,MAAA,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,YAAY,CAAC,0CAAE,OAAO,GAAG;QACnD,MAAA,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,WAAW,CAAC,0CAAE,OAAO,GAAG;QAClD,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC,OAAO,EAAE,CAAC;QACrD,IAAI,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC;QAClD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,GAAG,GAAG,EAAE,EAAE,CAAC,EAAE;YACnD,IAAI,IAAI,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;YACzB,IAAI,CAAC,CAAC,CAAC,IAAI,YAAY,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,YAAY,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,YAAY,EAAE,CAAC,WAAW,CAAC,CAAC,EAAE;gBAClH,IAAI,CAAC,OAAO,EAAE,CAAC;aAClB;SACJ;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;;IA3MD;QADC,QAAQ;2DACuB;IAKhC;QAHC,QAAQ,CAAC;YACN,OAAO,EAAE,uCAAuC;SACnD,CAAC;sDAC4B;IAVb,iBAAiB;QADrC,OAAO;OACa,iBAAiB,CAkNrC;IAAD,wBAAC;CAlND,AAkNC,CAlN8C,EAAE,CAAC,SAAS,GAkN1D;kBAlNoB,iBAAiB","file":"","sourceRoot":"/","sourcesContent":["import { RenderReactiveHandler } from \"./RenderReactiveHandler\";\r\n\r\n/**\r\n * 目前该渲染代理功能存在的问题\r\n * 1.被代理节点的父级不能出现scaleX和scaleY不一致的情况,被代理节点本身没有这个限制\r\n */\r\nconst { ccclass, property } = cc._decorator;\r\n@ccclass\r\nexport default class RenderAlternative extends cc.Component {\r\n /**渲染层节点 */\r\n public renderLayer: cc.Node = null;\r\n /**渲染的zIndex 动态调整zIndex,用于方便临近合批 */\r\n @property\r\n public renderZIndex: number = 0;\r\n /**同步的间隔(帧为单位) */\r\n @property({\r\n tooltip: '设置同步的间隔(秒为单位),0就是每帧都同步,0.1就是隔0.1秒同步一次'\r\n })\r\n public syncInv: number = 0.01;\r\n /**渲染的sIndex */\r\n public sIndex: number = 0;\r\n /**非渲染组件 */\r\n public proxyRender: cc.RenderComponent = null;\r\n /**渲染组件 */\r\n private renderCompnent: cc.RenderComponent = null;\r\n /**上次更新的数据 */\r\n public lastWMat4: cc.Mat4 = null;\r\n /**上次更新的数据 */\r\n public lastLMat4: cc.Mat4 = null;\r\n /**上次更新的数据 */\r\n public lastPos: cc.Vec3 = null;\r\n /**距离下次刷新累计了多少间隔 */\r\n public accuTime: number = 0;\r\n /**最后一次刷新时间 */\r\n public lastFrameTime: number = null;\r\n /**是否进行刷新 */\r\n public isAttachFrame: boolean = false;\r\n\r\n /**获取总的ZIndex */\r\n get zIndex() {\r\n let zIndex = this.renderZIndex + (this.sIndex * 0.01);\r\n let parentNode = this.node.parent;\r\n while (parentNode != this.renderLayer.parent && parentNode != cc.director.getScene()) {\r\n let render = parentNode.getComponent(RenderAlternative);\r\n if (render) {\r\n zIndex += render.zIndex + 1;\r\n break;\r\n }\r\n parentNode = parentNode.parent;\r\n }\r\n return zIndex;\r\n }\r\n\r\n /**\r\n * 设置渲染节点层\r\n * @param layer \r\n */\r\n init(layer?: cc.Node): T {\r\n if (layer) {\r\n this.renderLayer = layer;\r\n }\r\n if (!this.renderLayer) {\r\n console.warn(`节点${this.node.name}没有设置渲染层`)\r\n return null;\r\n }\r\n return this.initRender();\r\n }\r\n /**\r\n * 初始化渲染节点\r\n */\r\n private initRender(): T {\r\n let node = this.getRender();\r\n node.setParent(this.renderLayer ? this.renderLayer : cc.director.getScene().getChildByName(\"Canvas\"));\r\n this.isAttachFrame = true;\r\n requestAnimationFrame(this.frameUpdate.bind(this));\r\n return this.doProxy();\r\n }\r\n /**生成代理 */\r\n private doProxy(): T {\r\n this.proxyRender = new Proxy(this.renderCompnent, new RenderReactiveHandler()) as T;\r\n return this.proxyRender as T;\r\n }\r\n\r\n\r\n protected frameUpdate(): void {\r\n let now = cc.sys.now();\r\n !this.lastFrameTime && (this.lastFrameTime = now);\r\n let dt = now - this.lastFrameTime;\r\n if (this.proxyRender) {\r\n this.accuTime += dt;\r\n if (this.accuTime >= this.syncInv) {\r\n this.accuTime -= this.syncInv;\r\n this.updateProp();\r\n }\r\n }\r\n if (this.isAttachFrame) {\r\n requestAnimationFrame(this.frameUpdate.bind(this));\r\n }\r\n }\r\n\r\n /**更新最新状态 */\r\n public updateProp() {\r\n let node = this.renderCompnent.node;\r\n if (!this.node.activeInHierarchy) {\r\n node.opacity = 0;\r\n return;\r\n }\r\n node.anchorX = this.node.anchorX;\r\n node.anchorY = this.node.anchorY;\r\n node.width = this.node.width;\r\n node.height = this.node.height;\r\n node.group = this.node.group;\r\n node.color = this.node.color;\r\n node.opacity = this.getOpacity(this.node);\r\n\r\n let wMat4 = cc.mat4();\r\n this.node.getWorldMatrix(wMat4);\r\n /* let lMat4 = cc.mat4();\r\n this.node.getLocalMatrix(wMat4); */\r\n //此处本可以过滤许多不必要的更新,但尚未排查出问题\r\n if (true /* || !this.lastWMat4?.equals(wMat4) || !this.lastLMat4?.equals(lMat4) */) {\r\n this.onAngleChange(wMat4);\r\n this.onScaleChange(wMat4);\r\n this.onPosChange();\r\n /* this.lastLMat4 = lMat4;\r\n this.lastWMat4 = wMat4; */\r\n }\r\n node.zIndex = this.zIndex;\r\n node.zIndex = this.zIndex;\r\n }\r\n\r\n protected onDestroy(): void {\r\n this.renderCompnent.node.destroy();\r\n this.renderCompnent = null;\r\n this.proxyRender = null;\r\n }\r\n\r\n /**\r\n * 获取节点透明度\r\n * @param node \r\n */\r\n private getOpacity(node: cc.Node) {\r\n let opacity = (node.opacity / 255);\r\n let parentNode = node.parent\r\n while (parentNode != this.renderLayer.parent && parentNode != cc.director.getScene()) {\r\n opacity *= (parentNode.opacity / 255);\r\n parentNode = parentNode.parent;\r\n }\r\n return opacity * 255;\r\n }\r\n /**位置变化处理 */\r\n private onPosChange() {\r\n let wpos = this.node.parent.convertToWorldSpaceAR(this.node.position);\r\n this.renderCompnent.node.position = this.renderLayer.convertToNodeSpaceAR(wpos);\r\n }\r\n /**旋转变化处理 */\r\n private onAngleChange(mat4: cc.Mat4) {\r\n this.renderCompnent.node.angle = this.extractRotationAngleFromMat4(mat4);\r\n }\r\n /**\r\n * 从 cc.Mat4 中获取旋转角度(不受缩放影响)\r\n * @param matrix 输入的 cc.Mat4 矩阵\r\n * @returns 旋转角度(以度为单位)\r\n */\r\n private extractRotationAngleFromMat4(matrix: cc.Mat4): number {\r\n // 提取旋转部分\r\n let scaleX = Math.sqrt(matrix.m[0] * matrix.m[0] + matrix.m[4] * matrix.m[4] + matrix.m[8] * matrix.m[8]);\r\n let scaleY = Math.sqrt(matrix.m[1] * matrix.m[1] + matrix.m[5] * matrix.m[5] + matrix.m[9] * matrix.m[9]);\r\n\r\n // 计算 Z 轴旋转角度(绕 Z 轴的旋转角度)\r\n let angle = Math.atan2(matrix.m[1] / scaleY, matrix.m[0] / scaleX);\r\n\r\n // 将弧度转换为角度\r\n let degrees = angle * (180 / Math.PI);\r\n return degrees;\r\n }\r\n /**\r\n * 缩放变化处理\r\n * @param mat4 \r\n */\r\n private onScaleChange(mat4: cc.Mat4) {\r\n let scale = this.extractScaleFromMat4(mat4)\r\n this.renderCompnent.node.scaleX = scale.x;\r\n this.renderCompnent.node.scaleY = scale.y;\r\n this.renderCompnent.node.scaleZ = scale.z;\r\n }\r\n /**\r\n * 从mat4中获取缩放值\r\n * @param mat4 \r\n * @returns \r\n */\r\n private extractScaleFromMat4(mat4: cc.Mat4): cc.Vec3 {\r\n let scaleX = cc.v3(mat4.m[0], mat4.m[1], mat4.m[2]).mag();\r\n let scaleY = cc.v3(mat4.m[4], mat4.m[5], mat4.m[6]).mag();\r\n let scaleZ = cc.v3(mat4.m[8], mat4.m[9], mat4.m[10]).mag();\r\n return cc.v3(scaleX, scaleY, scaleZ);\r\n }\r\n /**\r\n * 获取渲染组件\r\n * @param node \r\n */\r\n private getRender() {\r\n let node = cc.instantiate(this.node);\r\n node.removeAllChildren();\r\n this.renderCompnent = node.getComponent(cc.RenderComponent);\r\n this.node.getComponent(cc.LabelOutline)?.destroy();\r\n this.node.getComponent(cc.LabelShadow)?.destroy();\r\n this.node.getComponent(cc.RenderComponent).destroy();\r\n let components = node.getComponents(cc.Component);\r\n for (let i = 0, len = components.length; i < len; ++i) {\r\n let comp = components[i];\r\n if (!((comp instanceof cc.RenderComponent) || (comp instanceof cc.LabelOutline) || (comp instanceof cc.LabelShadow))) {\r\n comp.destroy();\r\n }\r\n }\r\n return node;\r\n }\r\n\r\n}\r\n"]} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Script/RenderReactiveHandler.js b/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Script/RenderReactiveHandler.js new file mode 100644 index 0000000..8bc1637 --- /dev/null +++ b/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Script/RenderReactiveHandler.js @@ -0,0 +1,84 @@ +"use strict"; +cc._RF.push(module, 'd38d0Ja+51M8L8TYTQwae9Q', 'RenderReactiveHandler'); +// Script/RenderReactiveHandler.ts + +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.RenderReactiveHandler = exports.hasChanged = exports.hasOwn = exports.isObject = void 0; +function isObject(value) { + return value !== null && typeof value === 'object'; +} +exports.isObject = isObject; +var hasOwnProperty = Object.prototype.hasOwnProperty; +/** 是否自身上存在属性 */ +function hasOwn(val, key) { + if (val instanceof cc.Component) { + return key in val; + } + return hasOwnProperty.call(val, key); +} +exports.hasOwn = hasOwn; +/** 比较值是否变化了,考虑NaN;如果是对象直接认为改变了 */ +function hasChanged(value, oldValue) { + var type = typeof value; + if (type === "object") + return true; + return !Object.is(value, oldValue); +} +exports.hasChanged = hasChanged; +var RenderReactiveHandler = /** @class */ (function () { + function RenderReactiveHandler(reactiveTarget) { + /**需要作出反应的对象 */ + this.reactiveTarget = null; + this.reactiveTarget = reactiveTarget; + } + /** + * + * @param target 被代理的对象 + * @param prop 被代理的对象的属性名 + * @param value 被代理的对象的属性值 + * @param receiver 代理对象 + * @returns + */ + RenderReactiveHandler.prototype.set = function (target, prop, value, receiver) { + var oldValue = Reflect.get(target, prop); + var hadKey = hasOwn(target, prop); + var result = Reflect.set(target, prop, value); + if (!hadKey || hasChanged(value, oldValue)) { + if (prop == "angle" || prop == 'scale' || prop == "position" || prop == "_renderFlag") + return; + if (prop == 'activeInHierarchy') { + console.warn(target); + } + // 属性变化 + this.reactiveTarget && (Reflect.set(this.reactiveTarget, prop, value)); + } + return result; + }; + RenderReactiveHandler.prototype.apply = function () { + console.warn(arguments); + }; + RenderReactiveHandler.prototype.get = function (target, prop, receiver) { + if (prop === '__raw__') { + return target; + } + else if (prop === '__isReactive__') { + return true; + } + var rawValue = Reflect.get(target, prop); + return rawValue; + }; + RenderReactiveHandler.prototype.deleteProperty = function (target, prop) { + var hadKey = hasOwn(target, prop); + var oldValue = target[prop]; + var result = Reflect.deleteProperty(target, prop); + if (result && hadKey) { + //trigger(target, prop, void 0, oldValue); + } + return result; + }; + return RenderReactiveHandler; +}()); +exports.RenderReactiveHandler = RenderReactiveHandler; + +cc._RF.pop(); \ No newline at end of file diff --git a/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Script/RenderReactiveHandler.js.map b/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Script/RenderReactiveHandler.js.map new file mode 100644 index 0000000..db07343 --- /dev/null +++ b/Layered_virtual_list_2.x/temp/quick-scripts/src/assets/Script/RenderReactiveHandler.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["assets\\Script\\RenderReactiveHandler.ts"],"names":[],"mappings":";;;;;;;AACA,SAAgB,QAAQ,CAAC,KAAc;IACnC,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC;AACvD,CAAC;AAFD,4BAEC;AAED,IAAM,cAAc,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc,CAAA;AACtD,gBAAgB;AAChB,SAAgB,MAAM,CAAC,GAAW,EAAE,GAA6B;IAC7D,IAAI,GAAG,YAAY,EAAE,CAAC,SAAS,EAAE;QAC7B,OAAO,GAAG,IAAI,GAAG,CAAC;KACrB;IACD,OAAO,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AACzC,CAAC;AALD,wBAKC;AAED,kCAAkC;AAClC,SAAgB,UAAU,CAAC,KAAU,EAAE,QAAa;IAChD,IAAI,IAAI,GAAG,OAAO,KAAK,CAAC;IACxB,IAAI,IAAI,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IACnC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;AACvC,CAAC;AAJD,gCAIC;AAGD;IACI,+BAAY,cAAuB;QAGnC,eAAe;QACP,mBAAc,GAAW,IAAI,CAAC;QAHlC,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IACzC,CAAC;IAID;;;;;;;OAOG;IACH,mCAAG,GAAH,UAAI,MAAc,EAAE,IAAqB,EAAE,KAAU,EAAE,QAAa;QAEhE,IAAI,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QACzC,IAAI,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAClC,IAAI,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;QAC9C,IAAI,CAAC,MAAM,IAAI,UAAU,CAAC,KAAK,EAAE,QAAQ,CAAC,EAAE;YACxC,IAAI,IAAI,IAAI,OAAO,IAAI,IAAI,IAAI,OAAO,IAAI,IAAI,IAAI,UAAU,IAAI,IAAI,IAAI,aAAa;gBAAE,OAAO;YAC9F,IAAI,IAAI,IAAI,mBAAmB,EAAE;gBAC7B,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;aACxB;YACD,OAAO;YACP,IAAI,CAAC,cAAc,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;SAC1E;QAED,OAAO,MAAM,CAAA;IACjB,CAAC;IAED,qCAAK,GAAL;QACI,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;IAC3B,CAAC;IAED,mCAAG,GAAH,UAAI,MAAc,EAAE,IAAqB,EAAE,QAAa;QAEpD,IAAI,IAAI,KAAK,SAAS,EAAE;YACpB,OAAO,MAAM,CAAC;SACjB;aACI,IAAI,IAAI,KAAK,gBAAgB,EAAE;YAChC,OAAO,IAAI,CAAC;SACf;QACD,IAAI,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QACzC,OAAO,QAAQ,CAAC;IACpB,CAAC;IAED,8CAAc,GAAd,UAAe,MAAc,EAAE,IAAqB;QAChD,IAAI,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAClC,IAAI,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;QAC5B,IAAI,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAClD,IAAI,MAAM,IAAI,MAAM,EAAE;YAClB,0CAA0C;SAC7C;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;IACL,4BAAC;AAAD,CA1DA,AA0DC,IAAA;AA1DY,sDAAqB","file":"","sourceRoot":"/","sourcesContent":["\r\nexport function isObject(value: unknown): value is Record {\r\n return value !== null && typeof value === 'object';\r\n}\r\n\r\nconst hasOwnProperty = Object.prototype.hasOwnProperty\r\n/** 是否自身上存在属性 */\r\nexport function hasOwn(val: object, key: string | number | symbol): key is keyof typeof val {\r\n if (val instanceof cc.Component) {\r\n return key in val;\r\n }\r\n return hasOwnProperty.call(val, key);\r\n}\r\n\r\n/** 比较值是否变化了,考虑NaN;如果是对象直接认为改变了 */\r\nexport function hasChanged(value: any, oldValue: any): boolean {\r\n let type = typeof value;\r\n if (type === \"object\") return true;\r\n return !Object.is(value, oldValue);\r\n}\r\n\r\n\r\nexport class RenderReactiveHandler {\r\n constructor(reactiveTarget?: object) {\r\n this.reactiveTarget = reactiveTarget;\r\n }\r\n /**需要作出反应的对象 */\r\n private reactiveTarget: object = null;\r\n\r\n /**\r\n * \r\n * @param target 被代理的对象\r\n * @param prop 被代理的对象的属性名\r\n * @param value 被代理的对象的属性值\r\n * @param receiver 代理对象\r\n * @returns \r\n */\r\n set(target: object, prop: string | symbol, value: any, receiver: any): boolean {\r\n\r\n let oldValue = Reflect.get(target, prop);\r\n let hadKey = hasOwn(target, prop);\r\n let result = Reflect.set(target, prop, value);\r\n if (!hadKey || hasChanged(value, oldValue)) {\r\n if (prop == \"angle\" || prop == 'scale' || prop == \"position\" || prop == \"_renderFlag\") return;\r\n if (prop == 'activeInHierarchy') {\r\n console.warn(target);\r\n }\r\n // 属性变化\r\n this.reactiveTarget && (Reflect.set(this.reactiveTarget, prop, value));\r\n }\r\n\r\n return result\r\n }\r\n\r\n apply() {\r\n console.warn(arguments)\r\n }\r\n\r\n get(target: object, prop: string | symbol, receiver: any): any {\r\n\r\n if (prop === '__raw__') {\r\n return target;\r\n }\r\n else if (prop === '__isReactive__') {\r\n return true;\r\n }\r\n let rawValue = Reflect.get(target, prop);\r\n return rawValue;\r\n }\r\n\r\n deleteProperty(target: object, prop: string | symbol): boolean {\r\n let hadKey = hasOwn(target, prop);\r\n let oldValue = target[prop];\r\n let result = Reflect.deleteProperty(target, prop);\r\n if (result && hadKey) {\r\n //trigger(target, prop, void 0, oldValue);\r\n }\r\n\r\n return result;\r\n }\r\n}\r\n"]} \ No newline at end of file diff --git a/Layered_virtual_list_2.x/temp/startup.json b/Layered_virtual_list_2.x/temp/startup.json new file mode 100644 index 0000000..70a73e6 --- /dev/null +++ b/Layered_virtual_list_2.x/temp/startup.json @@ -0,0 +1 @@ +{"pid":34480} diff --git a/Layered_virtual_list_2.x/tsconfig.json b/Layered_virtual_list_2.x/tsconfig.json new file mode 100644 index 0000000..93c0b22 --- /dev/null +++ b/Layered_virtual_list_2.x/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ "es2015", "es2017", "dom" ], + "target": "es5", + "experimentalDecorators": true, + "skipLibCheck": true, + "outDir": "temp/vscode-dist", + "forceConsistentCasingInFileNames": true + }, + "exclude": [ + "node_modules", + "library", + "local", + "temp", + "build", + "settings" + ] +} \ No newline at end of file diff --git a/ListViewV2Demo/README.md b/ListViewV2Demo/README.md index a4bacb1..54f5ec9 100644 --- a/ListViewV2Demo/README.md +++ b/ListViewV2Demo/README.md @@ -1,5 +1,25 @@ # ListView ### ListView, 循环滚动列表,固定尺寸item, 屏幕可见范围外item会回收等待下次复用。支持横向,竖向,多行多列。支持追加删除数据。支持上右下左padding, 支持设置item锚点。 -### 有js/ts版本 +### 使用 +* 新建ScrollView组件 +* 设置view中anchor属性x=0.5,y=1.并设置好position +* 设置content中anchor属性x=0,y=1.并设置好position +* 新建ListItem的prefab节点,并设置node的中size、设置anchor属性x=0.5,y=1 最后添加脚本继承ListViewItem +* 在srollview节点中添加ListViewFactory来管理listView + +### js/ts版本 +关于js与ts之间的互相调用 +ts调用js中的b()方法 aa是脚本名称 panels是节点 + +import aa from './aa' + +let send2:aa = this.panels.getComponent('aa'); +send2.b(); + +js调用ts中的b()方法 +var aa= require("aa"); +aa.b(); ### 参数 * https://github.com/caochao/cocos_creator_proj_base + + diff --git a/ListViewV2Demo/assets/Scene/helloworldTs.fire b/ListViewV2Demo/assets/Scene/helloworldTs.fire index 1bd4a52..8a0a1ab 100644 --- a/ListViewV2Demo/assets/Scene/helloworldTs.fire +++ b/ListViewV2Demo/assets/Scene/helloworldTs.fire @@ -60,16 +60,19 @@ }, { "__id__": 6 + }, + { + "__id__": 15 } ], "_tag": -1, "_active": true, "_components": [ { - "__id__": 15 + "__id__": 21 }, { - "__id__": 16 + "__id__": 22 } ], "_prefab": null, @@ -533,6 +536,242 @@ "gap_x": 0, "gap_y": 0 }, + { + "__type__": "cc.Node", + "_name": "New Button", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [ + { + "__id__": 16 + } + ], + "_tag": -1, + "_active": true, + "_components": [ + { + "__id__": 18 + }, + { + "__id__": 19 + } + ], + "_prefab": null, + "_id": "1cCEojzRZBE5TlenfIjah+", + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_cascadeOpacityEnabled": true, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 40 + }, + "_rotationX": 0, + "_rotationY": 0, + "_scaleX": 1, + "_scaleY": 1, + "_position": { + "__type__": "cc.Vec2", + "x": 0, + "y": -248 + }, + "_skewX": 0, + "_skewY": 0, + "_localZOrder": 0, + "_globalZOrder": 0, + "_opacityModifyRGB": false, + "groupIndex": 0 + }, + { + "__type__": "cc.Node", + "_name": "Label", + "_objFlags": 0, + "_parent": { + "__id__": 15 + }, + "_children": [], + "_tag": -1, + "_active": true, + "_components": [ + { + "__id__": 17 + } + ], + "_prefab": null, + "_id": "1aD68m3NBDgJvHRJX1dw+U", + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_cascadeOpacityEnabled": true, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 40 + }, + "_rotationX": 0, + "_rotationY": 0, + "_scaleX": 1, + "_scaleY": 1, + "_position": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_localZOrder": 0, + "_globalZOrder": 0, + "_opacityModifyRGB": false, + "groupIndex": 0 + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 16 + }, + "_enabled": true, + "_useOriginalSize": false, + "_actualFontSize": 20, + "_fontSize": 20, + "_lineHeight": 40, + "_enableWrapText": false, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_N$string": "append", + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 1 + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 15 + }, + "_enabled": true, + "_spriteFrame": { + "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952" + }, + "_type": 1, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_atlas": null + }, + { + "__type__": "cc.Button", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 15 + }, + "_enabled": true, + "transition": 2, + "pressedColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "duration": 0.1, + "zoomScale": 1.2, + "clickEvents": [ + { + "__id__": 20 + } + ], + "_N$interactable": true, + "_N$enableAutoGrayEffect": false, + "_N$normalColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$disabledColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$normalSprite": { + "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952" + }, + "_N$pressedSprite": { + "__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a" + }, + "pressedSprite": { + "__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a" + }, + "_N$hoverSprite": { + "__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a" + }, + "hoverSprite": { + "__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a" + }, + "_N$disabledSprite": { + "__uuid__": "29158224-f8dd-4661-a796-1ffab537140e" + }, + "_N$target": { + "__id__": 15 + } + }, + { + "__type__": "cc.ClickEvent", + "target": { + "__id__": 2 + }, + "component": "HelloWorld", + "handler": "onEventClicked", + "customEventData": "" + }, { "__type__": "cc.Canvas", "_name": "", diff --git a/ListViewV2Demo/assets/Script/HelloWorld.js b/ListViewV2Demo/assets/Script/HelloWorld.js index e2787ef..b58743a 100644 --- a/ListViewV2Demo/assets/Script/HelloWorld.js +++ b/ListViewV2Demo/assets/Script/HelloWorld.js @@ -8,7 +8,13 @@ cc.Class({ start() { let script = this.listViewNode.getComponent('ListViewFactory'); - script.init([1, 2, 3, 4, 5, 6, 7, 8, 9]); + this.dataSize = 9; + script.init([1, 2, 3, 4, 5, 6, 7, 8, 9], 2); + }, + + onEventClicked() { + let script = this.listViewNode.getComponent('ListViewFactory'); + script.append(this.dataSize++); }, // called every frame diff --git a/ListViewV2Demo/assets/Script/ListViewFactory.ts b/ListViewV2Demo/assets/Script/ListViewFactory.ts index 1135500..4d09f60 100644 --- a/ListViewV2Demo/assets/Script/ListViewFactory.ts +++ b/ListViewV2Demo/assets/Script/ListViewFactory.ts @@ -36,16 +36,26 @@ export default class ListViewFactory extends cc.Component { listView: ListViewTs; - init(data: Array) { + init(data: Array, offsetIndex: number = 0, time: number = 0.5) { //下一帧执行,当使用widget适配高宽,可以取得真实长度。 this.scheduleOnce(() => { - this._init(data); + this._init(data, offsetIndex, time); }, 0); } - _init(data: Array) { + append(data: any) { + if (!this.listView) { + this.init([data]); + return; + } + this.listView.append_data(data); + } + + _init(data: Array, offsetIndex: number = 0, time: number = 0.5) { //初始化 let item = cc.instantiate(this.prefab); + let size = this.getItemSize(item, this.gap_x, this.gap_y); + this.listView = new ListViewTs({ scrollview: this.scrollview, mask: this.mask, @@ -60,8 +70,26 @@ export default class ListViewFactory extends cc.Component { }); //显示 this.listView.set_data(data); - this.scrollview.scrollToTop(); - this.scrollview.stopAutoScroll(); + let realIdx = Math.floor(offsetIndex / this.column); + if (realIdx > 0) { + let offSet = this.setOffsetByIndex(realIdx, this.direction, size); + this.scrollview.scrollToOffset(offSet, time); + } else { + this.scrollview.scrollToTop(); + this.scrollview.stopAutoScroll(); + } + } + + setOffsetByIndex(index: number, direction: number, size: cc.Size) { + if (direction == 1) { + return cc.v2(0, index * size.height); + } else { + return cc.v2(index * size.width, 0); + } + } + + getItemSize(node: cc.Node, x: number, y: number) { + return cc.size(node.width + x, node.height + y); } update(dt) { diff --git a/MeshDemo/.gitignore b/MeshDemo/.gitignore new file mode 100644 index 0000000..0c09bf3 --- /dev/null +++ b/MeshDemo/.gitignore @@ -0,0 +1,51 @@ +#///////////////////////////////////////////////////////////////////////////// +# Fireball Projects +#///////////////////////////////////////////////////////////////////////////// + +/library/ +/temp/ +/local/ +/build/ + +#///////////////////////////////////////////////////////////////////////////// +# npm files +#///////////////////////////////////////////////////////////////////////////// + +npm-debug.log +node_modules/ + +#///////////////////////////////////////////////////////////////////////////// +# Logs and databases +#///////////////////////////////////////////////////////////////////////////// + +*.log +*.sql +*.sqlite + +#///////////////////////////////////////////////////////////////////////////// +# files for debugger +#///////////////////////////////////////////////////////////////////////////// + +*.sln +*.pidb +*.suo + +#///////////////////////////////////////////////////////////////////////////// +# OS generated files +#///////////////////////////////////////////////////////////////////////////// + +.DS_Store +ehthumbs.db +Thumbs.db + +#///////////////////////////////////////////////////////////////////////////// +# WebStorm files +#///////////////////////////////////////////////////////////////////////////// + +.idea/ + +#////////////////////////// +# VS Code files +#////////////////////////// + +.vscode/ diff --git a/MeshDemo/README.md b/MeshDemo/README.md new file mode 100644 index 0000000..f5d92cc --- /dev/null +++ b/MeshDemo/README.md @@ -0,0 +1,59 @@ +# 网格Mesh 入门 +> Mesh 资源是渲染网格的必要资源 demo版本为如果Creator2.4.3 + +### 组成 +* 顶点数据 +* uv 顶点数据 +* 索引数据 + +### 初始化 +~~~ +let gfx = cc.renderer.renderEngine.gfx; + +// 定义顶点数据格式,只需要指明所需的属性,避免造成存储空间的浪费 +var vfmtPosColor = new gfx.VertexFormat([ + // 用户需要创建一个三维的盒子,所以需要三个值来保存位置信息 + {name: gfx.ATTR_POSITION, type: gfx.ATTR_TYPE_FLOAT32, num: 3}, + {name: gfx.ATTR_UV0, type: gfx.ATTR_TYPE_FLOAT32, num: 2}, + {name: gfx.ATTR_COLOR, type: gfx.ATTR_TYPE_UINT8, num: 4, normalize: true}, +]); + +let mesh = new cc.Mesh(); +// 初始化网格信息 +mesh.init(vfmtPosColor, 8, true); +// 修改 position 顶点数据 +mesh.setVertices(gfx.ATTR_POSITION, [ + cc.v3(-100, 100, 100), cc.v3(-100, -100, 100), cc.v3(100, 100, 100), cc.v3(100, -100, 100), + cc.v3(-100, 100, -100), cc.v3(-100, -100, -100), cc.v3(100, 100, -100), cc.v3(100, -100, -100) +]); + +// 修改 color 顶点数据 +let color1 = cc.Color.RED; +let color2 = cc.Color.BLUE; +mesh.setVertices(gfx.ATTR_COLOR, [ + color1, color1, color1, color1, + color2, color2, color2, color2, +]); + +// 修改 uv 顶点数据 +mesh.setVertices(gfx.ATTR_UV0, [ + cc.v2(0,0), cc.v2(0, 1), cc.v2(1, 0), cc.v2(1, 1), + cc.v2(1,1), cc.v2(1, 0), cc.v2(0, 1), cc.v2(0, 0), +]); + +// 修改索引数据 +mesh.setIndices([ + 0, 1, 2, 1, 3, 2, // front + 0, 6, 4, 0, 2, 6, // top + 2, 7, 6, 2, 3, 7, // right + 0, 5, 4, 0, 1, 5, // left + 1, 7, 5, 1, 3, 7, // bottom, + 4, 5, 6, 5, 7, 6, // back +]); +~~~ + +### 使用 +需要使用到cc.MeshRenderer组件,并设置mesh属性 + +### 参考 +* https://docs.cocos.com/creator/manual/zh/3d/mesh.html diff --git a/MeshDemo/assets/Scene.meta b/MeshDemo/assets/Scene.meta new file mode 100644 index 0000000..1f1c69c --- /dev/null +++ b/MeshDemo/assets/Scene.meta @@ -0,0 +1,12 @@ +{ + "ver": "1.1.2", + "uuid": "29f52784-2fca-467b-92e7-8fd9ef8c57b7", + "isBundle": false, + "bundleName": "", + "priority": 1, + "compressionType": {}, + "optimizeHotUpdate": {}, + "inlineSpriteFrames": {}, + "isRemoteBundle": {}, + "subMetas": {} +} \ No newline at end of file diff --git a/MeshDemo/assets/Scene/helloworld.fire b/MeshDemo/assets/Scene/helloworld.fire new file mode 100644 index 0000000..1f6d431 --- /dev/null +++ b/MeshDemo/assets/Scene/helloworld.fire @@ -0,0 +1,1258 @@ +[ + { + "__type__": "cc.SceneAsset", + "_name": "", + "_objFlags": 0, + "_native": "", + "scene": { + "__id__": 1 + } + }, + { + "__type__": "cc.Scene", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + } + ], + "_active": true, + "_components": [], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_is3DNode": true, + "_groupIndex": 0, + "groupIndex": 0, + "autoReleaseAssets": false, + "_id": "2d2f792f-a40c-49bb-a189-ed176a246e49" + }, + { + "__type__": "cc.Node", + "_name": "Canvas", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 3 + }, + { + "__id__": 5 + }, + { + "__id__": 8 + }, + { + "__id__": 10 + }, + { + "__id__": 12 + }, + { + "__id__": 15 + }, + { + "__id__": 18 + } + ], + "_active": true, + "_components": [ + { + "__id__": 28 + }, + { + "__id__": 29 + }, + { + "__id__": 30 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 252, + "g": 252, + "b": 252, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 960, + "height": 640 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 480, + 320, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "a286bbGknJLZpRpxROV6M94" + }, + { + "__type__": "cc.Node", + "_name": "Main Camera", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 4 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 554.2562584220408, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "c2pWI1+8dFe6L4u3+15PTp" + }, + { + "__type__": "cc.Camera", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 3 + }, + "_enabled": true, + "_cullingMask": 4294967295, + "_clearFlags": 7, + "_backgroundColor": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_depth": -1, + "_zoomRatio": 1, + "_targetTexture": null, + "_fov": 60, + "_orthoSize": 10, + "_nearClip": 1, + "_farClip": 4096, + "_ortho": true, + "_rect": { + "__type__": "cc.Rect", + "x": 0, + "y": 0, + "width": 1, + "height": 1 + }, + "_renderStages": 1, + "_alignWithScreen": true, + "_id": "0f9Y9E1ypF/b+c9oIr7DYF" + }, + { + "__type__": "cc.Node", + "_name": "background", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 6 + }, + { + "__id__": 7 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 27, + "g": 38, + "b": 46, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 960, + "height": 640 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 1, + "groupIndex": 1, + "_id": "e2e0crkOLxGrpMxpbC4iQg1" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 5 + }, + "_enabled": true, + "alignMode": 0, + "_target": null, + "_alignFlags": 45, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 200, + "_originalHeight": 150, + "_id": "533VWC56tH8Yh2sH1Ily43" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 5 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "410fb916-8721-4663-bab8-34397391ace7" + }, + "_type": 1, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "cbBBuvEVJB9pYw2l4Al/oi" + }, + { + "__type__": "cc.Node", + "_name": "cocos", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 9 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 195, + "height": 270 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 50, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 1, + "groupIndex": 1, + "_id": "c4f30YOS65G64U2TwufdJ+2" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 8 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "31bc895a-c003-4566-a9f3-2e54ae1c17dc" + }, + "_type": 0, + "_sizeMode": 1, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "2f3QtdfJVIuL6gRqLUsEda" + }, + { + "__type__": "cc.Node", + "_name": "label", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 11 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 342.33, + "height": 75.6 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + -180, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 1, + "groupIndex": 1, + "_id": "31f1bH7V69Ajr1iXhluMpTB" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 10 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_string": "Hello, World!", + "_N$string": "Hello, World!", + "_fontSize": 60, + "_lineHeight": 60, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_styleFlags": 0, + "_underlineHeight": 0, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 0, + "_id": "e6mwgoXAFJM6NjGTeeEV+1" + }, + { + "__type__": "cc.Node", + "_name": "New Node", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 13 + }, + { + "__id__": 14 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 1, + "groupIndex": 1, + "_id": "a4S44DyaBIeLUV+ngzUy6t" + }, + { + "__type__": "cc.MeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 12 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "bbdca2e8-da73-4ed3-bf81-eadc72d7ae2f" + } + ], + "_mesh": null, + "_receiveShadows": false, + "_shadowCastingMode": 0, + "_enableAutoBatch": false, + "textures": [], + "_id": "3duCcJk8hAdL94t3zd4Yyf" + }, + { + "__type__": "e924dAHRipEZ6QoZ2X3muPE", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 12 + }, + "_enabled": true, + "_id": "c6wd6PLrJBc74Yv8mBwYSB" + }, + { + "__type__": "cc.Node", + "_name": "New Node", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 16 + }, + { + "__id__": 17 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 1, + "groupIndex": 1, + "_id": "b7CaS6FPdANYjHET0JUK2Y" + }, + { + "__type__": "cc.MeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 15 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "2a296057-247c-4a1c-bbeb-0548b6c98650" + } + ], + "_mesh": null, + "_receiveShadows": false, + "_shadowCastingMode": 0, + "_enableAutoBatch": false, + "textures": [], + "_id": "c76Yj8rsxB2KY+fy9vRn+h" + }, + { + "__type__": "e924dAHRipEZ6QoZ2X3muPE", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 15 + }, + "_enabled": true, + "_id": "9do5PaN1lKkrDgo3fhcDVs" + }, + { + "__type__": "cc.Node", + "_name": "New 3D Stage", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [ + { + "__id__": 19 + }, + { + "__id__": 21 + }, + { + "__id__": 23 + }, + { + "__id__": 25 + } + ], + "_active": true, + "_components": [], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "b2HXShC8RKEacbb4IMzsiY" + }, + { + "__type__": "cc.Node", + "_name": "3D Camera", + "_objFlags": 0, + "_parent": { + "__id__": 18 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 20 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 496.223, + 370.093, + -0.25881904510252074, + 0, + 0, + 0.9659258262890683, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": -30, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "84+f9XckNNDYMkvZ/pdV4G" + }, + { + "__type__": "cc.Camera", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 19 + }, + "_enabled": true, + "_cullingMask": 1, + "_clearFlags": 6, + "_backgroundColor": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_depth": 0, + "_zoomRatio": 1, + "_targetTexture": null, + "_fov": 1000, + "_orthoSize": 10, + "_nearClip": 1, + "_farClip": 1024, + "_ortho": false, + "_rect": { + "__type__": "cc.Rect", + "x": 0, + "y": 0, + "width": 1, + "height": 1 + }, + "_renderStages": 1, + "_alignWithScreen": false, + "_id": "4eLjpwsL5CJrwtZ/G/+0sL" + }, + { + "__type__": "cc.Node", + "_name": "New Directional Light", + "_objFlags": 512, + "_parent": { + "__id__": 18 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 22 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + -0.25881904510252074, + 0, + 0, + 0.9659258262890683, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": -30, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "26O7j+YmNNP5cxBsF3TEpX" + }, + { + "__type__": "cc.Light", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 21 + }, + "_enabled": true, + "_type": 0, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_intensity": 1, + "_range": 1000, + "_spotAngle": 60, + "_spotExp": 1, + "_shadowType": 0, + "_shadowResolution": 1024, + "_shadowDarkness": 0.5, + "_shadowMinDepth": 1, + "_shadowMaxDepth": 1000, + "_shadowFrustumSize": 50, + "_shadowBias": 0.0005, + "_id": "9cLGIzl99Mfovx757ToOeP" + }, + { + "__type__": "cc.Node", + "_name": "New Ambient Light", + "_objFlags": 512, + "_parent": { + "__id__": 18 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 24 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "9aV0pM/PFDEKEYfRFVZIli" + }, + { + "__type__": "cc.Light", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 23 + }, + "_enabled": true, + "_type": 3, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_intensity": 0.25, + "_range": 1, + "_spotAngle": 60, + "_spotExp": 1, + "_shadowType": 0, + "_shadowResolution": 1024, + "_shadowDarkness": 0.5, + "_shadowMinDepth": 1, + "_shadowMaxDepth": 1000, + "_shadowFrustumSize": 50, + "_shadowBias": 0.0005, + "_id": "2b7fasJrlKB6loBQt1BcIK" + }, + { + "__type__": "cc.Node", + "_name": "New Box", + "_objFlags": 0, + "_parent": { + "__id__": 18 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 26 + }, + { + "__id__": 27 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -156.804, + 154.628, + -375.689, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": true, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "04TcPcSAVCbIAewWXwc/96" + }, + { + "__type__": "cc.MeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 25 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "2a296057-247c-4a1c-bbeb-0548b6c98650" + } + ], + "_mesh": null, + "_receiveShadows": false, + "_shadowCastingMode": 0, + "_enableAutoBatch": false, + "textures": [], + "_id": "8dcEah9MNC1pQUT00aihpG" + }, + { + "__type__": "080e321hdVNb7hS90JS6JmP", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 25 + }, + "_enabled": true, + "_id": "73xKwxUo9CmKGe6OxKp86/" + }, + { + "__type__": "cc.Canvas", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "_designResolution": { + "__type__": "cc.Size", + "width": 960, + "height": 640 + }, + "_fitWidth": false, + "_fitHeight": true, + "_id": "5e/0eJGS5LIJBqJ1e1Doei" + }, + { + "__type__": "e1b90/rohdEk4SdmmEZANaD", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "label": { + "__id__": 11 + }, + "text": "hello", + "_id": "d888QJgE1KNLbAsAFd2xhU" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "alignMode": 1, + "_target": null, + "_alignFlags": 45, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 0, + "_originalHeight": 0, + "_id": "bewOsMmrBPZrYt3neBOYYy" + } +] \ No newline at end of file diff --git a/MeshDemo/assets/Scene/helloworld.fire.meta b/MeshDemo/assets/Scene/helloworld.fire.meta new file mode 100644 index 0000000..b7d59e6 --- /dev/null +++ b/MeshDemo/assets/Scene/helloworld.fire.meta @@ -0,0 +1,7 @@ +{ + "ver": "1.2.9", + "uuid": "2d2f792f-a40c-49bb-a189-ed176a246e49", + "asyncLoadAssets": false, + "autoReleaseAssets": false, + "subMetas": {} +} \ No newline at end of file diff --git a/MeshDemo/assets/Script.meta b/MeshDemo/assets/Script.meta new file mode 100644 index 0000000..776c9cc --- /dev/null +++ b/MeshDemo/assets/Script.meta @@ -0,0 +1,12 @@ +{ + "ver": "1.1.2", + "uuid": "4734c20c-0db8-4eb2-92ea-e692f4d70934", + "isBundle": false, + "bundleName": "", + "priority": 1, + "compressionType": {}, + "optimizeHotUpdate": {}, + "inlineSpriteFrames": {}, + "isRemoteBundle": {}, + "subMetas": {} +} \ No newline at end of file diff --git a/MeshDemo/assets/Script/Helloworld.ts b/MeshDemo/assets/Script/Helloworld.ts new file mode 100644 index 0000000..a9249d0 --- /dev/null +++ b/MeshDemo/assets/Script/Helloworld.ts @@ -0,0 +1,16 @@ +const {ccclass, property} = cc._decorator; + +@ccclass +export default class Helloworld extends cc.Component { + + @property(cc.Label) + label: cc.Label = null; + + @property + text: string = 'hello'; + + start () { + // init logic + this.label.string = this.text; + } +} diff --git a/MeshDemo/assets/Script/Helloworld.ts.meta b/MeshDemo/assets/Script/Helloworld.ts.meta new file mode 100644 index 0000000..b99dded --- /dev/null +++ b/MeshDemo/assets/Script/Helloworld.ts.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.8", + "uuid": "e1b90feb-a217-4493-849d-9a611900d683", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/MeshDemo/assets/TestMesh.meta b/MeshDemo/assets/TestMesh.meta new file mode 100644 index 0000000..826d485 --- /dev/null +++ b/MeshDemo/assets/TestMesh.meta @@ -0,0 +1,12 @@ +{ + "ver": "1.1.2", + "uuid": "e0ea8b3b-e847-4828-8008-d767a2a884a8", + "isBundle": false, + "bundleName": "", + "priority": 1, + "compressionType": {}, + "optimizeHotUpdate": {}, + "inlineSpriteFrames": {}, + "isRemoteBundle": {}, + "subMetas": {} +} \ No newline at end of file diff --git a/MeshDemo/assets/TestMesh/HelloWorld.png b/MeshDemo/assets/TestMesh/HelloWorld.png new file mode 100644 index 0000000..21d4326 Binary files /dev/null and b/MeshDemo/assets/TestMesh/HelloWorld.png differ diff --git a/MeshDemo/assets/TestMesh/HelloWorld.png.meta b/MeshDemo/assets/TestMesh/HelloWorld.png.meta new file mode 100644 index 0000000..eb65993 --- /dev/null +++ b/MeshDemo/assets/TestMesh/HelloWorld.png.meta @@ -0,0 +1,36 @@ +{ + "ver": "2.3.5", + "uuid": "6aa0aa6a-ebee-4155-a088-a687a6aadec4", + "type": "sprite", + "wrapMode": "clamp", + "filterMode": "bilinear", + "premultiplyAlpha": false, + "genMipmaps": false, + "packable": true, + "width": 195, + "height": 270, + "platformSettings": {}, + "subMetas": { + "HelloWorld": { + "ver": "1.0.4", + "uuid": "31bc895a-c003-4566-a9f3-2e54ae1c17dc", + "rawTextureUuid": "6aa0aa6a-ebee-4155-a088-a687a6aadec4", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 0, + "trimY": 0, + "width": 195, + "height": 270, + "rawWidth": 195, + "rawHeight": 270, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "subMetas": {} + } + } +} \ No newline at end of file diff --git a/MeshDemo/assets/TestMesh/MeshTest.ts b/MeshDemo/assets/TestMesh/MeshTest.ts new file mode 100644 index 0000000..2ebc8b3 --- /dev/null +++ b/MeshDemo/assets/TestMesh/MeshTest.ts @@ -0,0 +1,64 @@ +// Learn TypeScript: +// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html +// Learn Attribute: +// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html +// Learn life-cycle callbacks: +// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html + +const { ccclass, property,executeInEditMode } = cc._decorator; + +// const renderEngine = cc.renderer.renderEngine; +const gfx = cc.gfx; + +@ccclass +@executeInEditMode +export default class MeshTest extends cc.Component { + + mr_model: cc.MeshRenderer = null; + + onLoad() { + console.log('abc=', gfx); + this.mr_model = this.node.getComponent(cc.MeshRenderer); + } + + start() { + let vfmtPosColor = new gfx.VertexFormat([ + { name: gfx.ATTR_POSITION, type: gfx.ATTR_TYPE_FLOAT32, num: 3 }, + { name: gfx.ATTR_UV0, type: gfx.ATTR_TYPE_FLOAT32, num: 2 }, + { name: gfx.ATTR_COLOR, type: gfx.ATTR_TYPE_UINT8, num: 4, normalize: true }, + + ]) + + let mesh = new cc.Mesh(); + + this.mr_model.mesh = mesh; + mesh.init(vfmtPosColor, 4, true); + + // 修改 position 顶点数据 + mesh.setVertices(gfx.ATTR_POSITION, [ + cc.v3(100, 200, 100), cc.v3(100, 100, 100), cc.v3(200, 200, 100), cc.v3(200, 100, 100) + // cc.v3(-100, 100, -100), cc.v3(-100, -100, -100), cc.v3(100, 100, -100), cc.v3(100, -100, -100) + ]); + + // 修改 color 顶点数据 + let color1 = cc.Color.RED; + let color2 = cc.Color.BLUE; + mesh.setVertices(gfx.ATTR_COLOR, [ + color1, color1, color1, color1, + // color2, color2, color2, color2, + ]); + + // 修改 uv 顶点数据 + mesh.setVertices(gfx.ATTR_UV0, [ + cc.v2(0, 0), cc.v2(0, 1), cc.v2(1, 0), cc.v2(1, 1), + ]); + + // 修改索引数据 + mesh.setIndices([ + 0, 1, 2, 1, 3, 2 // front + + ]); + } + + // update (dt) {} +} diff --git a/MeshDemo/assets/TestMesh/MeshTest.ts.meta b/MeshDemo/assets/TestMesh/MeshTest.ts.meta new file mode 100644 index 0000000..212ac13 --- /dev/null +++ b/MeshDemo/assets/TestMesh/MeshTest.ts.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.8", + "uuid": "e924d007-462a-4467-a428-6765f79ae3c4", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/MeshDemo/assets/TestMesh/TestAB.mtl b/MeshDemo/assets/TestMesh/TestAB.mtl new file mode 100644 index 0000000..d421faa --- /dev/null +++ b/MeshDemo/assets/TestMesh/TestAB.mtl @@ -0,0 +1,22 @@ +{ + "__type__": "cc.Material", + "_name": "New Material", + "_objFlags": 0, + "_native": "", + "_effectAsset": { + "__uuid__": "2874f8dd-416c-4440-81b7-555975426e93" + }, + "_techniqueIndex": 0, + "_techniqueData": { + "0": { + "defines": { + "USE_TEXTURE": true + }, + "props": { + "texture": { + "__uuid__": "6aa0aa6a-ebee-4155-a088-a687a6aadec4" + } + } + } + } +} \ No newline at end of file diff --git a/MeshDemo/assets/TestMesh/TestAB.mtl.meta b/MeshDemo/assets/TestMesh/TestAB.mtl.meta new file mode 100644 index 0000000..f161b25 --- /dev/null +++ b/MeshDemo/assets/TestMesh/TestAB.mtl.meta @@ -0,0 +1,6 @@ +{ + "ver": "1.0.3", + "uuid": "bbdca2e8-da73-4ed3-bf81-eadc72d7ae2f", + "dataAsSubAsset": null, + "subMetas": {} +} \ No newline at end of file diff --git a/MeshDemo/assets/TestMesh/chroma.js b/MeshDemo/assets/TestMesh/chroma.js new file mode 100644 index 0000000..74759bc --- /dev/null +++ b/MeshDemo/assets/TestMesh/chroma.js @@ -0,0 +1,26 @@ +/* +chroma.js - JavaScript library for color conversions +Copyright (c) 2011-2017, Gregor Aisch +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. +3. The name Gregor Aisch may not be used to endorse or promote products + derived from this software without specific prior written permission. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL GREGOR AISCH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +(function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,$,_,aa,ba,ca,da,ea,fa,ga,ha,ia,ja,ka,la,ma,na,oa,pa,qa,ra,sa,ta,ua,va,wa,xa,ya,za,Aa,Ba,Ca=[].slice;xa=function(){var a,b,c,d,e;for(a={},e="Boolean Number String Function Array Date RegExp Undefined Null".split(" "),d=0,b=e.length;dc&&(a=c),a},ya=function(a){return a.length>=3?Array.prototype.slice.call(a):a[0]},u=function(a){var b,c;for(a._clipped=!1,a._unclipped=a.slice(0),b=c=0;c<3;b=++c)b<3?((a[b]<0||a[b]>255)&&(a._clipped=!0),a[b]<0&&(a[b]=0),a[b]>255&&(a[b]=255)):3===b&&(a[b]<0&&(a[b]=0),a[b]>1&&(a[b]=1));return a._clipped||delete a._unclipped,a},d=Math.PI,sa=Math.round,w=Math.cos,B=Math.floor,ba=Math.pow,V=Math.log,ua=Math.sin,va=Math.sqrt,n=Math.atan2,Y=Math.max,m=Math.abs,g=2*d,e=d/3,b=d/180,f=180/d,t=function(){return arguments[0]instanceof a?arguments[0]:function(a,b,c){c.prototype=a.prototype;var d=new c,e=a.apply(d,b);return Object(e)===e?e:d}(a,arguments,function(){})},t.default=t,l=[],"undefined"!=typeof module&&null!==module&&null!=module.exports&&(module.exports=t),"function"==typeof define&&define.amd?define([],function(){return t}):(ra="undefined"!=typeof exports&&null!==exports?exports:(this||window),ra.chroma=t),t.version="1.3.7",k={},i=[],j=!1,a=function(){function a(){var a,b,c,d,e,f,g,h,l;for(f=this,b=[],h=0,d=arguments.length;h1&&(g=b[b.length-1]),null!=k[g])f._rgb=u(k[g](ya(b.slice(0,-1))));else{for(j||(i=i.sort(function(a,b){return b.p-a.p}),j=!0),l=0,e=i.length;l3?b[3]:1]},Ba=function(a){return 255*(a<=.00304?12.92*a:1.055*ba(a,1/2.4)-.055)},Q=function(a){return a>c.t1?a*a*a:c.t2*(a-c.t0)},c={Kn:18,Xn:.95047,Yn:1,Zn:1.08883,t0:.137931034,t1:.206896552,t2:.12841855,t3:.008856452},ja=function(){var a,b,c,d,e,f,g,h;return d=ya(arguments),c=d[0],b=d[1],a=d[2],e=oa(c,b,a),f=e[0],g=e[1],h=e[2],[116*g-16,500*(f-g),200*(g-h)]},pa=function(a){return(a/=255)<=.04045?a/12.92:ba((a+.055)/1.055,2.4)},Aa=function(a){return a>c.t3?ba(a,1/3):a/c.t2+c.t0},oa=function(){var a,b,d,e,f,g,h;return e=ya(arguments),d=e[0],b=e[1],a=e[2],d=pa(d),b=pa(b),a=pa(a),f=Aa((.4124564*d+.3575761*b+.1804375*a)/c.Xn),g=Aa((.2126729*d+.7151522*b+.072175*a)/c.Yn),h=Aa((.0193339*d+.119192*b+.9503041*a)/c.Zn),[f,g,h]},t.lab=function(){return function(a,b,c){c.prototype=a.prototype;var d=new c,e=a.apply(d,b);return Object(e)===e?e:d}(a,Ca.call(arguments).concat(["lab"]),function(){})},k.lab=P,a.prototype.lab=function(){return ja(this._rgb)},o=function(a){var b,c,d,e,f,g,h,i,j,k,l;return a=function(){var b,c,d;for(d=[],c=0,b=a.length;c=0&&b[3]<=1?"rgb":void 0}}),k.lrgb=k.rgb,L=function(b,c,d,e){var f,g;return f=b._rgb,g=c._rgb,new a(va(ba(f[0],2)*(1-d)+ba(g[0],2)*d),va(ba(f[1],2)*(1-d)+ba(g[1],2)*d),va(ba(f[2],2)*(1-d)+ba(g[2],2)*d),e)},h=function(b){var c,d,e,f,g,h;for(d=1/b.length,h=[0,0,0,0],f=0,e=b.length;f=360;)c-=360;q[l]=c}else q[l]=q[l]/g[l];return t(q,b).alpha(e/m)},D=function(a){var b,c,d,e,f,g;if(a.match(/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/))return 4!==a.length&&7!==a.length||(a=a.substr(1)),3===a.length&&(a=a.split(""),a=a[0]+a[0]+a[1]+a[1]+a[2]+a[2]),g=parseInt(a,16),e=g>>16,d=g>>8&255,c=255&g,[e,d,c,1];if(a.match(/^#?([A-Fa-f0-9]{8})$/))return 9===a.length&&(a=a.substr(1)),g=parseInt(a,16),e=g>>24&255,d=g>>16&255,c=g>>8&255,b=sa((255&g)/255*100)/100,[e,d,c,b];if(null!=k.css&&(f=k.css(a)))return f;throw"unknown color: "+a},fa=function(a,b){var c,d,e,f,g,h,i;return null==b&&(b="rgb"),g=a[0],e=a[1],d=a[2],c=a[3],g=Math.round(g),e=Math.round(e),d=Math.round(d),i=g<<16|e<<8|d,h="000000"+i.toString(16),h=h.substr(h.length-6),f="0"+sa(255*c).toString(16),f=f.substr(f.length-2),"#"+function(){switch(b.toLowerCase()){case"rgba":return h+f;case"argb":return f+h;default:return h}}()},k.hex=function(a){return D(a)},t.hex=function(){return function(a,b,c){c.prototype=a.prototype;var d=new c,e=a.apply(d,b);return Object(e)===e?e:d}(a,Ca.call(arguments).concat(["hex"]),function(){})},a.prototype.hex=function(a){return null==a&&(a="rgb"),fa(this._rgb,a)},i.push({p:4,test:function(a){if(1===arguments.length&&"string"===xa(a))return"hex"}}),G=function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n;if(a=ya(arguments),e=a[0],k=a[1],g=a[2],0===k)i=d=b=255*g;else{for(n=[0,0,0],c=[0,0,0],m=g<.5?g*(1+k):g+k-g*k,l=2*g-m,e/=360,n[0]=e+1/3,n[1]=e,n[2]=e-1/3,f=h=0;h<=2;f=++h)n[f]<0&&(n[f]+=1),n[f]>1&&(n[f]-=1),6*n[f]<1?c[f]=l+6*(m-l)*n[f]:2*n[f]<1?c[f]=m:3*n[f]<2?c[f]=l+(m-l)*(2/3-n[f])*6:c[f]=l;j=[sa(255*c[0]),sa(255*c[1]),sa(255*c[2])],i=j[0],d=j[1],b=j[2]}return a.length>3?[i,d,b,a[3]]:[i,d,b]},ha=function(a,b,c){var d,e,f,g,h;return void 0!==a&&a.length>=3&&(g=a,a=g[0],b=g[1],c=g[2]),a/=255,b/=255,c/=255,f=Math.min(a,b,c),Y=Math.max(a,b,c),e=(Y+f)/2,Y===f?(h=0,d=Number.NaN):h=e<.5?(Y-f)/(Y+f):(Y-f)/(2-Y-f),a===Y?d=(b-c)/(Y-f):b===Y?d=2+(c-a)/(Y-f):c===Y&&(d=4+(a-b)/(Y-f)),d*=60,d<0&&(d+=360),[d,h,e]},t.hsl=function(){return function(a,b,c){c.prototype=a.prototype;var d=new c,e=a.apply(d,b);return Object(e)===e?e:d}(a,Ca.call(arguments).concat(["hsl"]),function(){})},k.hsl=G,a.prototype.hsl=function(){return ha(this._rgb)},H=function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r;if(a=ya(arguments),e=a[0],p=a[1],r=a[2],r*=255,0===p)i=d=b=r;else switch(360===e&&(e=0),e>360&&(e-=360),e<0&&(e+=360),e/=60,f=B(e),c=e-f,g=r*(1-p),h=r*(1-p*c),q=r*(1-p*(1-c)),f){case 0:j=[r,q,g],i=j[0],d=j[1],b=j[2];break;case 1:k=[h,r,g],i=k[0],d=k[1],b=k[2];break;case 2:l=[g,r,q],i=l[0],d=l[1],b=l[2];break;case 3:m=[g,h,r],i=m[0],d=m[1],b=m[2];break;case 4:n=[q,g,r],i=n[0],d=n[1],b=n[2];break;case 5:o=[r,g,h],i=o[0],d=o[1],b=o[2]}return[i,d,b,a.length>3?a[3]:1]},ia=function(){var a,b,c,d,e,f,g,h,i;return g=ya(arguments),f=g[0],c=g[1],a=g[2],e=Math.min(f,c,a),Y=Math.max(f,c,a),b=Y-e,i=Y/255,0===Y?(d=Number.NaN,h=0):(h=b/Y,f===Y&&(d=(c-a)/b),c===Y&&(d=2+(a-f)/b),a===Y&&(d=4+(f-c)/b),(d*=60)<0&&(d+=360)),[d,h,i]},t.hsv=function(){return function(a,b,c){c.prototype=a.prototype;var d=new c,e=a.apply(d,b);return Object(e)===e?e:d}(a,Ca.call(arguments).concat(["hsv"]),function(){})},k.hsv=H,a.prototype.hsv=function(){return ia(this._rgb)},_=function(a){var b,c,d;return"number"===xa(a)&&a>=0&&a<=16777215?(d=a>>16,c=a>>8&255,b=255&a,[d,c,b,1]):(console.warn("unknown num color: "+a),[0,0,0,1])},ma=function(){var a,b,c,d;return d=ya(arguments),c=d[0],b=d[1],a=d[2],(c<<16)+(b<<8)+a},t.num=function(b){return new a(b,"num")},a.prototype.num=function(a){return null==a&&(a="rgb"),ma(this._rgb,a)},k.num=_,i.push({p:1,test:function(a){if(1===arguments.length&&"number"===xa(a)&&a>=0&&a<=16777215)return"num"}}),C=function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t;if(c=ya(arguments),h=c[0],e=c[1],b=c[2],e/=100,g=g/100*255,a=255*e,0===e)l=g=d=b;else switch(360===h&&(h=0),h>360&&(h-=360),h<0&&(h+=360),h/=60,i=B(h),f=h-i,j=b*(1-e),k=j+a*(1-f),s=j+a*f,t=j+a,i){case 0:m=[t,s,j],l=m[0],g=m[1],d=m[2];break;case 1:n=[k,t,j],l=n[0],g=n[1],d=n[2];break;case 2:o=[j,t,s],l=o[0],g=o[1],d=o[2];break;case 3:p=[j,k,t],l=p[0],g=p[1],d=p[2];break;case 4:q=[s,j,t],l=q[0],g=q[1],d=q[2];break;case 5:r=[t,j,k],l=r[0],g=r[1],d=r[2]}return[l,g,d,c.length>3?c[3]:1]},ea=function(){var a,b,c,d,e,f,g,h,i;return i=ya(arguments),h=i[0],e=i[1],b=i[2],g=Math.min(h,e,b),Y=Math.max(h,e,b),d=Y-g,c=100*d/255,a=g/(255-d)*100,0===d?f=Number.NaN:(h===Y&&(f=(e-b)/d),e===Y&&(f=2+(b-h)/d),b===Y&&(f=4+(h-e)/d),(f*=60)<0&&(f+=360)),[f,c,a]},t.hcg=function(){return function(a,b,c){c.prototype=a.prototype;var d=new c,e=a.apply(d,b);return Object(e)===e?e:d}(a,Ca.call(arguments).concat(["hcg"]),function(){})},k.hcg=C,a.prototype.hcg=function(){return ea(this._rgb)},x=function(a){var b,c,d,e,f,g,h,i;if(a=a.toLowerCase(),null!=t.colors&&t.colors[a])return D(t.colors[a]);if(f=a.match(/rgb\(\s*(\-?\d+),\s*(\-?\d+)\s*,\s*(\-?\d+)\s*\)/)){for(h=f.slice(1,4),e=g=0;g<=2;e=++g)h[e]=+h[e];h[3]=1}else if(f=a.match(/rgba\(\s*(\-?\d+),\s*(\-?\d+)\s*,\s*(\-?\d+)\s*,\s*([01]|[01]?\.\d+)\)/))for(h=f.slice(1,5),e=i=0;i<=3;e=++i)h[e]=+h[e];else if(f=a.match(/rgb\(\s*(\-?\d+(?:\.\d+)?)%,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*\)/)){for(h=f.slice(1,4),e=b=0;b<=2;e=++b)h[e]=sa(2.55*h[e]);h[3]=1}else if(f=a.match(/rgba\(\s*(\-?\d+(?:\.\d+)?)%,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)/)){for(h=f.slice(1,5),e=c=0;c<=2;e=++c)h[e]=sa(2.55*h[e]);h[3]=+h[3]}else(f=a.match(/hsl\(\s*(\-?\d+(?:\.\d+)?),\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*\)/))?(d=f.slice(1,4),d[1]*=.01,d[2]*=.01,h=G(d),h[3]=1):(f=a.match(/hsla\(\s*(\-?\d+(?:\.\d+)?),\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)/))&&(d=f.slice(1,4),d[1]*=.01,d[2]*=.01,h=G(d),h[3]=+f[4]);return h},da=function(a){var b;return b=a[3]<1?"rgba":"rgb","rgb"===b?b+"("+a.slice(0,3).map(sa).join(",")+")":"rgba"===b?b+"("+a.slice(0,3).map(sa).join(",")+","+a[3]+")":void 0},qa=function(a){return sa(100*a)/100},F=function(a,b){var c;return c=b<1?"hsla":"hsl",a[0]=qa(a[0]||0),a[1]=qa(100*a[1])+"%",a[2]=qa(100*a[2])+"%","hsla"===c&&(a[3]=b),c+"("+a.join(",")+")"},k.css=function(a){return x(a)},t.css=function(){return function(a,b,c){c.prototype=a.prototype;var d=new c,e=a.apply(d,b);return Object(e)===e?e:d}(a,Ca.call(arguments).concat(["css"]),function(){})},a.prototype.css=function(a){return null==a&&(a="rgb"),"rgb"===a.slice(0,3)?da(this._rgb):"hsl"===a.slice(0,3)?F(this.hsl(),this.alpha()):void 0},k.named=function(a){return D(za[a])},i.push({p:5,test:function(a){if(1===arguments.length&&null!=za[a])return"named"}}),a.prototype.name=function(a){var b,c;arguments.length&&(za[a]&&(this._rgb=D(za[a])),this._rgb[3]=1),b=this.hex();for(c in za)if(b===za[c])return c;return b},R=function(){var a,c,d,e;return e=ya(arguments),d=e[0],a=e[1],c=e[2],c*=b,[d,w(c)*a,ua(c)*a]},S=function(){var a,b,c,d,e,f,g,h,i,j,k;return c=ya(arguments),h=c[0],e=c[1],g=c[2],j=R(h,e,g),a=j[0],b=j[1],d=j[2],k=P(a,b,d),i=k[0],f=k[1],d=k[2],[i,f,d,c.length>3?c[3]:1]},O=function(){var a,b,c,d,e,g;return g=ya(arguments),e=g[0],a=g[1],b=g[2],c=va(a*a+b*b),d=(n(b,a)*f+360)%360,0===sa(1e4*c)&&(d=Number.NaN),[e,c,d]},ka=function(){var a,b,c,d,e,f,g;return f=ya(arguments),e=f[0],c=f[1],b=f[2],g=ja(e,c,b),d=g[0],a=g[1],b=g[2],O(d,a,b)},t.lch=function(){var b;return b=ya(arguments),new a(b,"lch")},t.hcl=function(){var b;return b=ya(arguments),new a(b,"hcl")},k.lch=S,k.hcl=function(){var a,b,c,d;return d=ya(arguments),b=d[0],a=d[1],c=d[2],S([c,a,b])},a.prototype.lch=function(){return ka(this._rgb)},a.prototype.hcl=function(){return ka(this._rgb).reverse()},ca=function(a){var b,c,d,e,f,g,h,i,j;return null==a&&(a="rgb"),i=ya(arguments),h=i[0],e=i[1],b=i[2],h/=255,e/=255,b/=255,f=1-Math.max(h,Math.max(e,b)),d=f<1?1/(1-f):0,c=(1-h-f)*d,g=(1-e-f)*d,j=(1-b-f)*d,[c,g,j,f]},v=function(){var a,b,c,d,e,f,g,h,i;return b=ya(arguments),d=b[0],g=b[1],i=b[2],f=b[3],a=b.length>4?b[4]:1,1===f?[0,0,0,a]:(h=d>=1?0:255*(1-d)*(1-f),e=g>=1?0:255*(1-g)*(1-f),c=i>=1?0:255*(1-i)*(1-f),[h,e,c,a])},k.cmyk=function(){return v(ya(arguments))},t.cmyk=function(){return function(a,b,c){c.prototype=a.prototype;var d=new c,e=a.apply(d,b);return Object(e)===e?e:d}(a,Ca.call(arguments).concat(["cmyk"]),function(){})},a.prototype.cmyk=function(){return ca(this._rgb)},k.gl=function(){var a,b,c,d,e;for(d=function(){var a,c;a=ya(arguments),c=[];for(b in a)e=a[b],c.push(e);return c}.apply(this,arguments),a=c=0;c<=2;a=++c)d[a]*=255;return d},t.gl=function(){return function(a,b,c){c.prototype=a.prototype;var d=new c,e=a.apply(d,b);return Object(e)===e?e:d}(a,Ca.call(arguments).concat(["gl"]),function(){})},a.prototype.gl=function(){var a;return a=this._rgb,[a[0]/255,a[1]/255,a[2]/255,a[3]]},la=function(a,b,c){var d;return d=ya(arguments),a=d[0],b=d[1],c=d[2],a=W(a),b=W(b),c=W(c),.2126*a+.7152*b+.0722*c},W=function(a){return a/=255,a<=.03928?a/12.92:ba((a+.055)/1.055,2.4)},N=function(b,c,d,e){var f,g;return f=b._rgb,g=c._rgb,new a(f[0]+d*(g[0]-f[0]),f[1]+d*(g[1]-f[1]),f[2]+d*(g[2]-f[2]),e)},l.push(["rgb",N]),a.prototype.luminance=function(a,b){var c,d,e,f,g;return null==b&&(b="rgb"),arguments.length?(f=this._rgb,0===a?f=[0,0,0,this._rgb[3]]:1===a?f=[255,255,255,this[3]]:(c=la(this._rgb),d=1e-7,e=20,g=function(c,f){var h,i;return i=c.interpolate(f,.5,b),h=i.luminance(),Math.abs(a-h)a?g(c,i):g(i,f)},f=c>a?g(t("black"),this).rgba():g(this,t("white")).rgba()),t(f).alpha(this.alpha())):la(this._rgb)},wa=function(a){var b,c,d,e;return e=a/100,e<66?(d=255,c=-155.25485562709179-.44596950469579133*(c=e-2)+104.49216199393888*V(c),b=e<20?0:.8274096064007395*(b=e-10)-254.76935184120902+115.67994401066147*V(b)):(d=351.97690566805693+.114206453784165*(d=e-55)-40.25366309332127*V(d),c=325.4494125711974+.07943456536662342*(c=e-50)-28.0852963507957*V(c),b=255),[d,c,b]},na=function(){var a,b,c,d,e,f,g,h;for(f=ya(arguments),e=f[0],f[1],a=f[2],d=1e3,c=4e4,b=.4;c-d>b;)h=.5*(c+d),g=wa(h),g[2]/g[0]>=a/e?c=h:d=h;return sa(h)},t.temperature=t.kelvin=function(){return function(a,b,c){c.prototype=a.prototype;var d=new c,e=a.apply(d,b);return Object(e)===e?e:d}(a,Ca.call(arguments).concat(["temperature"]),function(){})},k.temperature=k.kelvin=k.K=wa,a.prototype.temperature=function(){return na(this._rgb)},a.prototype.kelvin=a.prototype.temperature,t.contrast=function(b,c){var d,e,f,g;return"string"!==(f=xa(b))&&"number"!==f||(b=new a(b)),"string"!==(g=xa(c))&&"number"!==g||(c=new a(c)),d=b.luminance(),e=c.luminance(),d>e?(d+.05)/(e+.05):(e+.05)/(d+.05)},t.distance=function(b,c,d){var e,f,g,h,i,j,k;null==d&&(d="lab"),"string"!==(i=xa(b))&&"number"!==i||(b=new a(b)),"string"!==(j=xa(c))&&"number"!==j||(c=new a(c)),g=b.get(d),h=c.get(d),k=0;for(f in g)e=(g[f]||0)-(h[f]||0),k+=e*e;return Math.sqrt(k)},t.deltaE=function(b,c,e,f){var g,h,i,j,k,l,o,p,q,r,s,t,u,v,x,y,z,A,B,C,D,E,F,G,H,I,J;for(null==e&&(e=1),null==f&&(f=1),"string"!==(z=xa(b))&&"number"!==z||(b=new a(b)),"string"!==(A=xa(c))&&"number"!==A||(c=new a(c)),B=b.lab(),g=B[0],i=B[1],k=B[2],C=c.lab(),h=C[0],j=C[1],l=C[2],o=va(i*i+k*k),p=va(j*j+l*l),F=g<16?.511:.040975*g/(1+.01765*g),D=.0638*o/(1+.0131*o)+.638,y=o<1e-6?0:180*n(k,i)/d;y<0;)y+=360;for(;y>=360;)y-=360;return G=y>=164&&y<=345?.56+m(.2*w(d*(y+168)/180)):.36+m(.4*w(d*(y+35)/180)),q=o*o*o*o,x=va(q/(q+1900)),E=D*(x*G+1-x),v=g-h,u=o-p,s=i-j,t=k-l,r=s*s+t*t-u*u,H=v/(e*F),I=u/(f*D),J=E,va(H*H+I*I+r/(J*J))},a.prototype.get=function(a){var b,c,d,e,f,g;return d=this,f=a.split("."),e=f[0],b=f[1],g=d[e](),b?(c=e.indexOf(b),c>-1?g[c]:console.warn("unknown channel "+b+" in mode "+e)):g},a.prototype.set=function(a,b){var c,d,e,f,g,h;if(e=this,g=a.split("."),f=g[0],c=g[1],c)if(h=e[f](),(d=f.indexOf(c))>-1)if("string"===xa(b))switch(b.charAt(0)){case"+":case"-":h[d]+=+b;break;case"*":h[d]*=+b.substr(1);break;case"/":h[d]/=+b.substr(1);break;default:h[d]=+b}else h[d]=b;else console.warn("unknown channel "+c+" in mode "+f);else h=b;return t(h,f).alpha(e.alpha())},a.prototype.clipped=function(){return this._rgb._clipped||!1},a.prototype.alpha=function(a){return arguments.length?t.rgb([this._rgb[0],this._rgb[1],this._rgb[2],a]):this._rgb[3]},a.prototype.darken=function(a){var b,d;return null==a&&(a=1),d=this,b=d.lab(),b[0]-=c.Kn*a,t.lab(b).alpha(d.alpha())},a.prototype.brighten=function(a){return null==a&&(a=1),this.darken(-a)},a.prototype.darker=a.prototype.darken,a.prototype.brighter=a.prototype.brighten,a.prototype.saturate=function(a){var b,d;return null==a&&(a=1),d=this,b=d.lch(),b[1]+=a*c.Kn,b[1]<0&&(b[1]=0),t.lch(b).alpha(d.alpha())},a.prototype.desaturate=function(a){return null==a&&(a=1),this.saturate(-a)},a.prototype.premultiply=function(){var a,b;return b=this.rgb(),a=this.alpha(),t(b[0]*a,b[1]*a,b[2]*a,a)},p=function(a,b,c){if(!p[c])throw"unknown blend mode "+c;return p[c](a,b)},q=function(a){return function(b,c){var d,e;return d=t(c).rgb(),e=t(b).rgb(),t(a(d,e),"rgb")}},A=function(a){return function(b,c){var d,e,f;for(f=[],d=e=0;e<=3;d=++e)f[d]=a(b[d],c[d]);return f}},$=function(a,b){return a},Z=function(a,b){return a*b/255},y=function(a,b){return a>b?b:a},T=function(a,b){return a>b?a:b},ta=function(a,b){return 255*(1-(1-a/255)*(1-b/255))},aa=function(a,b){return b<128?2*a*b/255:255*(1-2*(1-a/255)*(1-b/255))},s=function(a,b){return 255*(1-(1-b/255)/(a/255))},z=function(a,b){return 255===a?255:(a=b/255*255/(1-a/255),a>255?255:a)},p.normal=q(A($)),p.multiply=q(A(Z)),p.screen=q(A(ta)),p.overlay=q(A(aa)),p.darken=q(A(y)),p.lighten=q(A(T)),p.dodge=q(A(z)),p.burn=q(A(s)),t.blend=p,t.analyze=function(a){var b,c,d,e;for(d={min:Number.MAX_VALUE,max:-1*Number.MAX_VALUE,sum:0,values:[],count:0},c=0,b=a.length;cd.max&&(d.max=e),d.count+=1);return d.domain=[d.min,d.max],d.limits=function(a,b){return t.limits(d,a,b)},d},t.scale=function(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,u,v,w,x;return k="rgb",l=t("#ccc"),p=0,!1,g=[0,1],o=[],n=[0,0],c=!1,e=[],m=!1,j=0,i=1,f=!1,d={},q=!0,h=1,w=function(a){var b,c,d,f,g,h;if(null==a&&(a=["#fff","#000"]),null!=a&&"string"===xa(a)&&null!=t.brewer&&(a=t.brewer[a]||t.brewer[a.toLowerCase()]||a),"array"===xa(a)){for(a=a.slice(0),b=d=0,f=a.length-1;0<=f?d<=f:d>=f;b=0<=f?++d:--d)c=a[b],"string"===xa(c)&&(a[b]=t(c));for(o.length=0,b=h=0,g=a.length-1;0<=g?h<=g:h>=g;b=0<=g?++h:--h)o.push(b/(a.length-1))}return v(),e=a},s=function(a){var b,d;if(null!=c){for(d=c.length-1,b=0;b=c[b];)b++;return b-1}return 0},x=function(a){return a},function(a){var b,d,e,f,g;return g=a,c.length>2&&(f=c.length-1,b=s(a),e=c[0]+(c[1]-c[0])*(0+.5*p),d=c[f-1]+(c[f]-c[f-1])*(1-.5*p),g=j+(c[b]+.5*(c[b+1]-c[b])-e)/(d-e)*(i-j)),g},u=function(a,b){var f,g,m,p,r,u,v,w;if(null==b&&(b=!1),isNaN(a))return l;if(b?w=a:c&&c.length>2?(f=s(a),w=f/(c.length-2)):w=i!==j?(a-j)/(i-j):1,b||(w=x(w)),1!==h&&(w=ba(w,h)),w=n[0]+w*(1-n[0]-n[1]),w=Math.min(1,Math.max(0,w)),p=Math.floor(1e4*w),q&&d[p])g=d[p];else{if("array"===xa(e))for(m=r=0,v=o.length-1;0<=v?r<=v:r>=v;m=0<=v?++r:--r){if(u=o[m],w<=u){g=e[m];break}if(w>=u&&m===o.length-1){g=e[m];break}if(w>u&&w=k;b=0<=k?++l:--l)o.push(b/(d-1));return g=[j,i],r},r.mode=function(a){return arguments.length?(k=a,v(),r):k},r.range=function(a,b){return w(a,b),r},r.out=function(a){return m=a,r},r.spread=function(a){return arguments.length?(p=a,r):p},r.correctLightness=function(a){return null==a&&(a=!0),f=a,v(),x=f?function(a){var b,c,d,e,f,g,h,i,j;for(b=u(0,!0).lab()[0],c=u(1,!0).lab()[0],h=b>c,d=u(a,!0).lab()[0],f=b+(c-b)*a,e=d-f,i=0,j=1,g=20;Math.abs(e)>.01&&g-- >0;)!function(){h&&(e*=-1),e<0?(i=a,a+=.5*(j-a)):(j=a,a+=.5*(i-a)),d=u(a,!0).lab()[0],e=d-f}();return a}:function(a){return a},r},r.padding=function(a){return null!=a?("number"===xa(a)&&(a=[a,a]),n=a,r):n},r.colors=function(b,d){var f,h,i,j,k,l,m,n;if(arguments.length<2&&(d="hex"),k=[],0===arguments.length)k=e.slice(0);else if(1===b)k=[r(.5)];else if(b>1)h=g[0],f=g[1]-h,k=function(){l=[];for(var a=0;0<=b?ab;0<=b?a++:a--)l.push(a);return l}.apply(this).map(function(a){return r(h+a/(b-1)*f)});else{if(a=[],m=[],c&&c.length>2)for(i=n=1,j=c.length;1<=j?nj;i=1<=j?++n:--n)m.push(.5*(c[i-1]+c[i]));else m=g;k=m.map(function(a){return r(a)})}return t[d]&&(k=k.map(function(a){return a[d]()})),k},r.cache=function(a){return null!=a?(q=a,r):q},r.gamma=function(a){return null!=a?(h=a,r):h},r},null==t.scales&&(t.scales={}),t.scales.cool=function(){return t.scale([t.hsl(180,1,.9),t.hsl(250,.7,.4)])},t.scales.hot=function(){return t.scale(["#000","#f00","#ff0","#fff"],[0,.25,.75,1]).mode("rgb")},t.analyze=function(a,b,c){var d,e,f,g,h,i,j;if(h={min:Number.MAX_VALUE,max:-1*Number.MAX_VALUE,sum:0,values:[],count:0},null==c&&(c=function(){return!0}),d=function(a){null==a||isNaN(a)||(h.values.push(a),h.sum+=a,ah.max&&(h.max=a),h.count+=1)},j=function(a,e){if(c(a,e))return d(null!=b&&"function"===xa(b)?b(a):null!=b&&"string"===xa(b)||"number"===xa(b)?a[b]:a)},"array"===xa(a))for(g=0,f=a.length;g=O;y=1<=O?++K:--K)C.push(E+y/c*(Y-E));C.push(Y)}else if("l"===b.substr(0,1)){if(E<=0)throw"Logarithmic scales are only possible for values > 0";for(F=Math.LOG10E*V(E),D=Math.LOG10E*V(Y),C.push(E),y=ja=1,P=c-1;1<=P?ja<=P:ja>=P;y=1<=P?++ja:--ja)C.push(ba(10,F+y/c*(D-F)));C.push(Y)}else if("q"===b.substr(0,1)){for(C.push(E),y=d=1,W=c-1;1<=W?d<=W:d>=W;y=1<=W?++d:--d)L=(ia.length-1)*y/c,M=B(L),M===L?C.push(ia[M]):(N=L-M,C.push(ia[M]*(1-N)+ia[M+1]*N));C.push(Y)}else if("k"===b.substr(0,1)){for(H=ia.length,r=new Array(H),w=new Array(c),ea=!0,I=0,u=null,u=[],u.push(E),y=e=1,X=c-1;1<=X?e<=X:e>=X;y=1<=X?++e:--e)u.push(E+y/c*(Y-E));for(u.push(Y);ea;){for(z=f=0,Z=c-1;0<=Z?f<=Z:f>=Z;z=0<=Z?++f:--f)w[z]=0;for(y=g=0,$=H-1;0<=$?g<=$:g>=$;y=0<=$?++g:--g){for(ha=ia[y],G=Number.MAX_VALUE,z=h=0,_=c-1;0<=_?h<=_:h>=_;z=0<=_?++h:--h)(x=m(u[z]-ha))=aa;z=0<=aa?++i:--i)J[z]=null;for(y=j=0,ca=H-1;0<=ca?j<=ca:j>=ca;y=0<=ca?++j:--j)v=r[y],null===J[v]?J[v]=ia[y]:J[v]+=ia[y];for(z=k=0,da=c-1;0<=da?k<=da:k>=da;z=0<=da?++k:--k)J[z]*=1/w[z];for(ea=!1,z=l=0,Q=c-1;0<=Q?l<=Q:l>=Q;z=0<=Q?++l:--l)if(J[z]!==u[y]){ea=!0;break}u=J,I++,I>200&&(ea=!1)}for(A={},z=n=0,R=c-1;0<=R?n<=R:n>=R;z=0<=R?++n:--n)A[z]=[];for(y=o=0,S=H-1;0<=S?o<=S:o>=S;y=0<=S?++o:--o)v=r[y],A[v].push(ia[y]);for(fa=[],z=p=0,T=c-1;0<=T?p<=T:p>=T;z=0<=T?++p:--p)fa.push(A[z][0]),fa.push(A[z][A[z].length-1]);for(fa=fa.sort(function(a,b){return a-b}),C.push(fa[0]),y=q=1,U=fa.length-1;q<=U;y=q+=2)ga=fa[y],isNaN(ga)||-1!==C.indexOf(ga)||C.push(ga)}return C},E=function(a,b,c){var d,f,h,i;return d=ya(arguments),a=d[0],b=d[1],c=d[2],isNaN(a)&&(a=0),a/=360,a<1/3?(f=(1-b)/3,i=(1+b*w(g*a)/w(e-g*a))/3,h=1-(f+i)):a<2/3?(a-=1/3,i=(1-b)/3,h=(1+b*w(g*a)/w(e-g*a))/3,f=1-(i+h)):(a-=2/3,h=(1-b)/3,f=(1+b*w(g*a)/w(e-g*a))/3,i=1-(h+f)),i=U(c*i*3),h=U(c*h*3),f=U(c*f*3),[255*i,255*h,255*f,d.length>3?d[3]:1]},ga=function(){var a,b,c,d,e,f,h,i;return h=ya(arguments),f=h[0],b=h[1],a=h[2],g=2*Math.PI,f/=255,b/=255,a/=255,e=Math.min(f,b,a),d=(f+b+a)/3,i=1-e/d,0===i?c=0:(c=(f-b+(f-a))/2,c/=Math.sqrt((f-b)*(f-b)+(f-a)*(b-a)),c=Math.acos(c),a>b&&(c=g-c),c/=g),[360*c,i,d]},t.hsi=function(){return function(a,b,c){c.prototype=a.prototype;var d=new c,e=a.apply(d,b);return Object(e)===e?e:d}(a,Ca.call(arguments).concat(["hsi"]),function(){})},k.hsi=E,a.prototype.hsi=function(){return ga(this._rgb)},J=function(a,b,c,d){var e,f,g,h,i,j,k,l,m,n,o,p;return"hsl"===d?(o=a.hsl(),p=b.hsl()):"hsv"===d?(o=a.hsv(),p=b.hsv()):"hcg"===d?(o=a.hcg(),p=b.hcg()):"hsi"===d?(o=a.hsi(),p=b.hsi()):"lch"!==d&&"hcl"!==d||(d="hcl",o=a.hcl(),p=b.hcl()),"h"===d.substr(0,1)&&(g=o[0],m=o[1],j=o[2],h=p[0],n=p[1],k=p[2]),isNaN(g)||isNaN(h)?isNaN(g)?isNaN(h)?f=Number.NaN:(f=h,1!==j&&0!==j||"hsv"===d||(l=n)):(f=g,1!==k&&0!==k||"hsv"===d||(l=m)):(e=h>g&&h-g>180?h-(g+360):h180?h+360-g:h-g,f=g+c*e),null==l&&(l=m+c*(n-m)),i=j+c*(k-j),t[d](f,l,i)},l=l.concat(function(){var a,b,c,d;for(c=["hsv","hsl","hsi","hcl","lch","hcg"],d=[],b=0,a=c.length;b 1 && this.lightenDirection > 0) || + (this.lighten < 0 && this.lightenDirection < 0)) { + this.lightenDirection *= -1; + } + + this.c1.fromHEX(c1.toString()); + this.c2.fromHEX(c2.toString()); + this.updateColor(this.c1, this.c2); + }, +}); diff --git a/MeshDemo/assets/TestMesh/mesh - 001.js.meta b/MeshDemo/assets/TestMesh/mesh - 001.js.meta new file mode 100644 index 0000000..87d0f08 --- /dev/null +++ b/MeshDemo/assets/TestMesh/mesh - 001.js.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.8", + "uuid": "080e3db5-85d5-4d6f-b852-f74252e8998f", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/MeshDemo/assets/TestMesh/mesh - 002.js b/MeshDemo/assets/TestMesh/mesh - 002.js new file mode 100644 index 0000000..6460362 --- /dev/null +++ b/MeshDemo/assets/TestMesh/mesh - 002.js @@ -0,0 +1,95 @@ +const chroma = require('chroma'); + +let gfx = cc.gfx; + +cc.Class({ + extends: cc.Component, + + editor: { + executeInEditMode: true + }, + + properties: { + camera: cc.Camera + }, + + // LIFE-CYCLE CALLBACKS: + + // onLoad () {}, + + start() { + this.lighten = 0; + this.lightenDirection = 1; + this.c1 = cc.color(); + this.c2 = cc.color(); + + var vfmtPosColor = new gfx.VertexFormat([ + { name: gfx.ATTR_POSITION, type: gfx.ATTR_TYPE_FLOAT32, num: 3 }, + { name: gfx.ATTR_UV0, type: gfx.ATTR_TYPE_FLOAT32, num: 2 } + // { name: gfx.ATTR_COLOR, type: gfx.ATTR_TYPE_UINT8, num: 4, normalize: true } + ]); + + let mesh = new cc.Mesh(); + mesh.init(vfmtPosColor, 4, true); + this.mesh = mesh; + + let posList = [ + cc.v3(-100, 100, 100), cc.v3(-100, -100, 100), cc.v3(100, 100, 100), cc.v3(100, -100, 100), + // cc.v3(-100, 100, -100), cc.v3(-100, -100, -100), cc.v3(100, 100, -100), cc.v3(100, -100, -100) + ]; + posList = posList.map((pos) => { + return this.camera.getWorldToScreenPoint(pos); + }); + console.log('pos=',posList); + + mesh.setVertices(gfx.ATTR_POSITION,posList); + + mesh.setVertices(gfx.ATTR_UV0, [ + cc.v2(0, 0), cc.v2(0, 1), cc.v2(1, 0), cc.v2(1, 1) + ]) + + // mesh._minPos = cc.v3(-100, -100, -100); + // mesh._maxPos = cc.v3(100, 100, 100); + + // this.updateColor(cc.Color.RED, cc.Color.BLUE); + + mesh.setIndices([ + 0, 1, 2, 1, 3, 2, // front + // 0, 6, 4, 0, 2, 6, // top + // 2, 7, 6, 2, 3, 7, // right + // 0, 5, 4, 0, 1, 5, // left + // 1, 7, 5, 1, 3, 7, // bottm, + // 4, 5, 6, 5, 7, 6, // back + ]); + + let renderer = this.node.getComponent(cc.MeshRenderer); + if (!renderer) { + renderer = this.node.addComponent(cc.MeshRenderer); + } + renderer.mesh = mesh; + }, + + updateColor(c1, c2) { + this.mesh.setVertices(gfx.ATTR_COLOR, [ + c1, c1, c1, c1, + // c2, c2, c2, c2, + ]); + }, + + update(dt) { + if (CC_EDITOR) return; + + let c1 = chroma.hsl(330, 1, this.lighten); + let c2 = chroma.hsl(100, 1, (1 - this.lighten)); + + this.lighten += dt * 0.1 * this.lightenDirection; + if ((this.lighten > 1 && this.lightenDirection > 0) || + (this.lighten < 0 && this.lightenDirection < 0)) { + this.lightenDirection *= -1; + } + + this.c1.fromHEX(c1.toString()); + this.c2.fromHEX(c2.toString()); + // this.updateColor(this.c1, this.c2); + }, +}); diff --git a/MeshDemo/assets/TestMesh/mesh - 002.js.meta b/MeshDemo/assets/TestMesh/mesh - 002.js.meta new file mode 100644 index 0000000..866113b --- /dev/null +++ b/MeshDemo/assets/TestMesh/mesh - 002.js.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.8", + "uuid": "1ae8754d-caa0-4d62-a415-a4f7d279ac2b", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/MeshDemo/assets/Texture.meta b/MeshDemo/assets/Texture.meta new file mode 100644 index 0000000..ca86565 --- /dev/null +++ b/MeshDemo/assets/Texture.meta @@ -0,0 +1,12 @@ +{ + "ver": "1.1.2", + "uuid": "7b81d4e8-ec84-4716-968d-500ac1d78a54", + "isBundle": false, + "bundleName": "", + "priority": 1, + "compressionType": {}, + "optimizeHotUpdate": {}, + "inlineSpriteFrames": {}, + "isRemoteBundle": {}, + "subMetas": {} +} \ No newline at end of file diff --git a/MeshDemo/assets/Texture/singleColor.png b/MeshDemo/assets/Texture/singleColor.png new file mode 100644 index 0000000..fa6376e Binary files /dev/null and b/MeshDemo/assets/Texture/singleColor.png differ diff --git a/MeshDemo/assets/Texture/singleColor.png.meta b/MeshDemo/assets/Texture/singleColor.png.meta new file mode 100644 index 0000000..a0a712e --- /dev/null +++ b/MeshDemo/assets/Texture/singleColor.png.meta @@ -0,0 +1,36 @@ +{ + "ver": "2.3.5", + "uuid": "a8027877-d8d6-4645-97a0-52d4a0123dba", + "type": "sprite", + "wrapMode": "clamp", + "filterMode": "bilinear", + "premultiplyAlpha": false, + "genMipmaps": false, + "packable": true, + "width": 2, + "height": 2, + "platformSettings": {}, + "subMetas": { + "singleColor": { + "ver": "1.0.4", + "uuid": "410fb916-8721-4663-bab8-34397391ace7", + "rawTextureUuid": "a8027877-d8d6-4645-97a0-52d4a0123dba", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 0, + "trimY": 0, + "width": 2, + "height": 2, + "rawWidth": 2, + "rawHeight": 2, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "subMetas": {} + } + } +} \ No newline at end of file diff --git a/MeshDemo/assets/TrailEffect.meta b/MeshDemo/assets/TrailEffect.meta new file mode 100644 index 0000000..8414c80 --- /dev/null +++ b/MeshDemo/assets/TrailEffect.meta @@ -0,0 +1,12 @@ +{ + "ver": "1.1.2", + "uuid": "3ab61d17-c8af-4a85-9eaa-87df7657af58", + "isBundle": false, + "bundleName": "", + "priority": 1, + "compressionType": {}, + "optimizeHotUpdate": {}, + "inlineSpriteFrames": {}, + "isRemoteBundle": {}, + "subMetas": {} +} \ No newline at end of file diff --git a/MeshDemo/assets/TrailEffect/TrailEffect.effect b/MeshDemo/assets/TrailEffect/TrailEffect.effect new file mode 100644 index 0000000..c72a1bc --- /dev/null +++ b/MeshDemo/assets/TrailEffect/TrailEffect.effect @@ -0,0 +1,78 @@ +// Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. + +CCEffect %{ + techniques: + - passes: + - vert: vs + frag: fs + depthStencilState: + depthTest: true + depthWrite: false + blendState: + targets: + - blend: true + blendSrc: src_alpha + blendDst: one_minus_src_alpha + blendDstAlpha: one_minus_src_alpha + rasterizerState: + cullMode: none + properties: + texture: { value: white } + startColor: { value: [1, 1, 1, 1], editor : { type: color } } + endColor: { value: [1, 1, 1, 1], editor : { type: color } } +}% + + +CCProgram vs %{ + precision highp float; + + #include + #include + + in vec3 a_position; + + in vec2 a_uv0; + out vec2 v_uv0; + #if USE_TEXTURE + #endif + + void main () { + vec4 pos = vec4(a_position, 1); + + pos = cc_matViewProj * cc_matWorld * pos; + + v_uv0 = a_uv0; + + gl_Position = pos; + } +}% + + +CCProgram fs %{ + precision highp float; + + in vec2 v_uv0; + #if USE_TEXTURE + uniform sampler2D texture; + #endif + + uniform color { + vec4 startColor; + vec4 endColor; + }; + + void main () { + vec4 o = vec4(1, 1, 1, 1); + + #if USE_TEXTURE + o *= texture(texture, v_uv0); + #endif + + vec4 fade = endColor - startColor; + fade *= v_uv0.x; + fade += startColor; + o *= fade; + + gl_FragColor = o; + } +}% diff --git a/MeshDemo/assets/TrailEffect/TrailEffect.effect.meta b/MeshDemo/assets/TrailEffect/TrailEffect.effect.meta new file mode 100644 index 0000000..e1ef1f7 --- /dev/null +++ b/MeshDemo/assets/TrailEffect/TrailEffect.effect.meta @@ -0,0 +1,17 @@ +{ + "ver": "1.0.25", + "uuid": "a1d78203-a464-4efb-8226-67c91adfbb50", + "compiledShaders": [ + { + "glsl1": { + "vert": "\nprecision highp float;\nuniform mat4 cc_matViewProj;\nuniform mat4 cc_matWorld;\nattribute vec3 a_position;\nattribute vec2 a_uv0;\nvarying vec2 v_uv0;\n#if USE_TEXTURE\n#endif\nvoid main () {\n vec4 pos = vec4(a_position, 1);\n pos = cc_matViewProj * cc_matWorld * pos;\n v_uv0 = a_uv0;\n gl_Position = pos;\n}", + "frag": "\nprecision highp float;\nvarying vec2 v_uv0;\n#if USE_TEXTURE\nuniform sampler2D texture;\n#endif\nuniform vec4 startColor;\nuniform vec4 endColor;\nvoid main () {\n vec4 o = vec4(1, 1, 1, 1);\n #if USE_TEXTURE\n o *= texture2D(texture, v_uv0);\n #endif\n vec4 fade = endColor - startColor;\n fade *= v_uv0.x;\n fade += startColor;\n o *= fade;\n gl_FragColor = o;\n}" + }, + "glsl3": { + "vert": "\nprecision highp float;\nuniform CCGlobal {\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\nuniform CCLocal {\n mat4 cc_matWorld;\n mat4 cc_matWorldIT;\n};\nin vec3 a_position;\nin vec2 a_uv0;\nout vec2 v_uv0;\n#if USE_TEXTURE\n#endif\nvoid main () {\n vec4 pos = vec4(a_position, 1);\n pos = cc_matViewProj * cc_matWorld * pos;\n v_uv0 = a_uv0;\n gl_Position = pos;\n}", + "frag": "\nprecision highp float;\nin vec2 v_uv0;\n#if USE_TEXTURE\nuniform sampler2D texture;\n#endif\nuniform color {\n vec4 startColor;\n vec4 endColor;\n};\nvoid main () {\n vec4 o = vec4(1, 1, 1, 1);\n #if USE_TEXTURE\n o *= texture(texture, v_uv0);\n #endif\n vec4 fade = endColor - startColor;\n fade *= v_uv0.x;\n fade += startColor;\n o *= fade;\n gl_FragColor = o;\n}" + } + } + ], + "subMetas": {} +} \ No newline at end of file diff --git a/MeshDemo/assets/TrailEffect/TrailEffect.mtl b/MeshDemo/assets/TrailEffect/TrailEffect.mtl new file mode 100644 index 0000000..acd11d1 --- /dev/null +++ b/MeshDemo/assets/TrailEffect/TrailEffect.mtl @@ -0,0 +1,36 @@ +{ + "__type__": "cc.Material", + "_name": "TrailEffect", + "_objFlags": 0, + "_native": "", + "_effectAsset": { + "__uuid__": "a1d78203-a464-4efb-8226-67c91adfbb50" + }, + "_techniqueIndex": 0, + "_techniqueData": { + "0": { + "props": { + "endColor": { + "__type__": "cc.Color", + "r": 204, + "g": 0, + "b": 255, + "a": 57 + }, + "startColor": { + "__type__": "cc.Color", + "r": 201, + "g": 45, + "b": 45, + "a": 172 + }, + "texture": { + "__uuid__": "a8027877-d8d6-4645-97a0-52d4a0123dba" + } + }, + "defines": { + "USE_TEXTURE": true + } + } + } +} \ No newline at end of file diff --git a/MeshDemo/assets/TrailEffect/TrailEffect.mtl.meta b/MeshDemo/assets/TrailEffect/TrailEffect.mtl.meta new file mode 100644 index 0000000..55df4a4 --- /dev/null +++ b/MeshDemo/assets/TrailEffect/TrailEffect.mtl.meta @@ -0,0 +1,6 @@ +{ + "ver": "1.0.3", + "uuid": "c8ad05c7-6568-4d98-bab4-0b24c9db8e6d", + "dataAsSubAsset": null, + "subMetas": {} +} \ No newline at end of file diff --git a/MeshDemo/assets/TrailEffect/TrailEffect.ts b/MeshDemo/assets/TrailEffect/TrailEffect.ts new file mode 100644 index 0000000..ecaae58 --- /dev/null +++ b/MeshDemo/assets/TrailEffect/TrailEffect.ts @@ -0,0 +1,433 @@ + +const { ccclass, property } = cc._decorator; +//材质球可设置的属性: +const diffuseTexture = "diffuseTexture"; +const startColor = "startColor"; +const endColor = "endColor"; +/** + * 拖尾特效。 + * + * 使用方法: + * 先 init 初始化(可以添加方法 onload ,直接调用 init,这里的 init reset 是为了适配我的框架写的),再 setShape 设置横截面形状; + * + * 其他属性如柔软度、起始颜色、纹理等,可在属性面板中设置,也可以通过代码设置; + * + * 请尽量在设置横截面之前将曲面细分等级设置好,并避免在运行过程中修改细分等级,因为设置细分等级后,需要重新设置网格的顶点数据。 + * + * 怎样让它动起来呢: + * + * (一) + * 由update方法自动更新时,将挂载本脚本的节点与要跟随的目标节点放在同一父节点下,拖尾节点坐标(0,0,0),角度(0,0,0); + * 设置跟随的目标节点,跟随目标节点的位置偏移; + * + * 注:默认的 update 方法已注释掉!要使用它请自行取消注释(在最底部)。 + * + * (二) + * 自行使用代码更新时,将挂载本脚本的节点放置在3D场景根节点下,坐标(0,0,0),角度(0,0,0), + * 通过方法 moveTo 设置拖尾头部的世界坐标即可。 + * + * 注: + * 需要设置拖尾横截面形状才能看到曲面; + * + */ +@ccclass +export default class TrailEffect extends cc.Component { + + @property(cc.MeshRenderer) + protected meshRenderer: cc.MeshRenderer = null; + protected mesh: cc.Mesh = null; + protected mat: cc.Material = null; + protected initMat() { + this.mat = this.meshRenderer.getMaterial(0); + let c = [this.startColor.r / 255, this.startColor.g / 255, this.startColor.b / 255, this.startColor.a / 255]; + this.mat.setProperty(startColor, c); + c = [this.endColor.r / 255, this.endColor.g / 255, this.endColor.b / 255, this.endColor.a / 255]; + this.mat.setProperty(endColor, c); + if (!!this.diffuseTexture) { + this.mat.setProperty(diffuseTexture, this.diffuseTexture); + } + } + + @property({ + type: cc.Texture2D + }) + protected diffuseTexture: cc.Texture2D = null; + /**设置拖尾纹理 */ + public setTexture(t: cc.Texture2D) { + this.diffuseTexture = t; + this.mat.setProperty(diffuseTexture, this.diffuseTexture); + } + + @property(cc.Color) + protected startColor: cc.Color = cc.Color.WHITE; + /**设置拖尾头部的颜色及透明度 */ + public setStartColor(color: cc.Color) { + if (this.startColor.equals(color)) return; + this.startColor.set(color); + if (!!this.mat) { + let c = [this.startColor.r / 255, this.startColor.g / 255, this.startColor.b / 255, this.startColor.a / 255]; + this.mat.setProperty(startColor, c); + } + } + + @property(cc.Color) + protected endColor: cc.Color = cc.color(255, 255, 255, 0); + /**设置拖尾尾部的颜色及透明度 */ + public setEndColor(color: cc.Color) { + if (this.endColor.equals(color)) return; + this.endColor.set(color); + if (!!this.mat) { + let c = [this.endColor.r / 255, this.endColor.g / 255, this.endColor.b / 255, this.endColor.a / 255]; + this.mat.setProperty(endColor, c); + } + } + + /**Z轴方向的曲面细分等级 */ + @property(cc.Integer) + protected level: number = 5; + /**设置Z轴方向的曲面细分等级 */ + public setLevel(level: number) { + if (this.level === level || level <= 0) return; + this.level = level; + if (this.polygon.length > 0) { + cc.warn("提示:修改细分等级后,将重新设置拖尾的顶点数据,请尽量在设置横截面之前设置好细分等级,并避免频繁修改。"); + this.createVerts(); + this.createMesh(); + } + } + @property(cc.Integer) + /**拖尾的柔软度,值越大尾巴越柔软 */ + protected soft: number = 5; + /**设置拖尾的柔软度,值越大尾巴越柔软,拉伸的越长,默认值为5 */ + public setSoft(soft: number) { + if (this.soft === soft || soft <= 0) return; + this.soft = soft; + } + /**是否跟随目标节点的角度 */ + @property(cc.Boolean) + protected followAngle: boolean = false; + + /**拖尾头部的坐标 */ + protected startPosition: cc.Vec3 = cc.v3(); + protected initPosition() { + this.startPosition = cc.v3(); + } + + /**网格顶点数据 */ + protected verts: cc.Vec3[] = []; + /**拖尾横截面的顶点坐标x、y,按逆时针排列 */ + @property({ + type: [cc.Vec2], + tooltip: "拖尾的横截面多边形的顶点坐标,该横截面为从 cc.v3(0, 0, 1) 位置看向XY平面时的形状,顶点坐标按逆时针排列,建议通过setShape在代码中设置。" + }) + protected polygon: cc.Vec2[] = []; + /**横截面是否为闭合的多边形 */ + @property({ + tooltip: "横截面是否为闭合的多边形" + }) + protected polygonClosed: boolean = false; + protected initPolygon() { + this.polygon = []; + } + protected resetPolygon() { + this.polygon = []; + this.polygonClosed = false; + } + /** + * 设置拖尾的横截面多边形的顶点坐标,该横截面为从 cc.v3(0, 0, 1) 位置看向XY平面时的形状,顶点坐标按逆时针排列 + * @param polygon 顶点坐标数组 + * @param close 是否闭合的多边形 + */ + public setShape(polygon: cc.Vec2[], close: boolean = false) { + this.polygon = [].concat(polygon); + this.polygonClosed = !!close; + this.createVerts(); + this.createMesh(); + } + /**根据截面形状和拖尾位置创建网格顶点 */ + protected createVerts() { + //顶点的Z轴偏移为0 + this.verts = []; + let nPolygon = this.polygon.length; + if (nPolygon > 2 && this.polygonClosed) { + for (let i = 0; i <= this.level; ++i) { + for (let j = 0; j < nPolygon; ++j) { + this.verts.push(cc.v3(this.polygon[j].x, this.polygon[j].y, 0).addSelf(this.startPosition)); + } + this.verts.push(cc.v3(this.polygon[0].x, this.polygon[0].y, 0).addSelf(this.startPosition)); + } + } else { + for (let i = 0; i <= this.level; ++i) { + for (let j = 0; j < nPolygon; ++j) { + this.verts.push(cc.v3(this.polygon[j].x, this.polygon[j].y, 0).addSelf(this.startPosition)); + } + } + } + } + + /**创建网格数据 */ + protected createMesh() { + // let gfx = cc.renderer.renderEngine.gfx; + let gfx = cc.gfx; + // 定义顶点数据格式,只需要指明所需的属性,避免造成存储空间的浪费 + var vfmtPosColor = new gfx.VertexFormat([ + // 用户需要创建一个三维的盒子,所以需要三个值来保存位置信息 + { name: gfx.ATTR_POSITION, type: gfx.ATTR_TYPE_FLOAT32, num: 3 }, + { name: gfx.ATTR_UV0, type: gfx.ATTR_TYPE_FLOAT32, num: 2 }, + { name: gfx.ATTR_COLOR, type: gfx.ATTR_TYPE_UINT8, num: 4, normalize: true }, + ]); + this.mesh = new cc.Mesh(); + this.meshRenderer.mesh = this.mesh; + + let mesh = this.mesh; + // 初始化网格信息 + mesh.init(vfmtPosColor, this.verts.length, true); + // 修改 position 顶点数据 + mesh.setVertices(gfx.ATTR_POSITION, this.verts); + // 修改 color 顶点数据 + let colors = []; + for (let i = 0, c = this.verts.length; i < c; ++i) { + colors.push(cc.Color.WHITE); + } + mesh.setVertices(gfx.ATTR_COLOR, colors); + // 修改 uv 顶点数据 + let uv: cc.Vec2[] = []; + let nPolygon = this.polygon.length; + if (nPolygon > 2 && this.polygonClosed) { + for (let i = 0; i <= this.level; ++i) { + let uv_x = 1 - i / this.level; + for (let j = 0; j <= nPolygon; ++j) { + uv.push(cc.v2(uv_x, j / nPolygon)); + } + } + } else { + for (let i = 0; i <= this.level; ++i) { + let uv_x = 1 - i / this.level; + for (let j = 0; j < nPolygon; ++j) { + uv.push(cc.v2(uv_x, j / nPolygon)); + } + } + } + mesh.setVertices(gfx.ATTR_UV0, uv); + + // 修改索引数据 + let frag: number[] = []; + if (nPolygon > 2 && this.polygonClosed) { + let p2 = nPolygon + 1; + let p3 = nPolygon + 2; + for (let i = 0; i < this.level; ++i) { + for (let j = 0; j < nPolygon; ++j) { + let index = i * nPolygon + i + j; + frag.push(index, index + 1, index + p3); + frag.push(index, index + p3, index + p2); + } + } + } else { + let p2 = nPolygon; + let p3 = nPolygon + 1; + let maxJ = nPolygon - 2; + for (let i = 0; i < this.level; ++i) { + for (let j = 0; j <= maxJ; ++j) { + let index = i * nPolygon + j; + frag.push(index, index + 1, index + p3); + frag.push(index, index + p3, index + p2); + } + } + } + mesh.setIndices(frag); + } + protected resetMesh() { + let nPolygon = this.polygon.length; + if (nPolygon > 2 && this.polygonClosed) { + for (let i = 0; i <= this.level; ++i) { + for (let j = 0; j < nPolygon; ++j) { + this.verts[i * nPolygon + i + j].set(cc.v3(this.polygon[j].x, this.polygon[j].y, 0).addSelf(this.startPosition)); + } + this.verts[i * nPolygon + i + nPolygon].set(cc.v3(this.polygon[0].x, this.polygon[0].y, 0).addSelf(this.startPosition)); + } + } else { + for (let i = 0; i <= this.level; ++i) { + for (let j = 0; j < nPolygon; ++j) { + this.verts[i * nPolygon + j].set(cc.v3(this.polygon[j].x, this.polygon[j].y, 0).addSelf(this.startPosition)); + } + } + } + let gfx = cc.gfx; + this.mesh.setVertices(gfx.ATTR_POSITION, this.verts); + } + /**更新网格形状 */ + protected updateMesh() { + let rate = this.soft == 0 ? 0.2 : (1 / this.soft); + let nPolygon = this.polygon.length; + if (nPolygon > 2 && this.polygonClosed) { + let offset = nPolygon + 1; + for (let i = 1; i <= this.level; ++i) { + let index = i * offset; + for (let j = 0; j <= nPolygon; ++j) { + let previousVert = this.verts[index - offset + j]; + let nextVert = this.verts[index + j]; + this.interpolationPos(nextVert, previousVert, rate); + } + } + } else { + let offset = nPolygon; + for (let i = 1; i <= this.level; ++i) { + let index = i * offset; + for (let j = 0; j < nPolygon; ++j) { + let previousVert = this.verts[index - offset + j]; + let nextVert = this.verts[index + j]; + this.interpolationPos(nextVert, previousVert, rate); + } + } + } + + let gfx = cc.gfx; + this.mesh.setVertices(gfx.ATTR_POSITION, this.verts); + } + protected getInterpplation(a: number, b: number, r: number) { + return (b - a) * r; + } + protected interpolationPos(p1: cc.Vec3, p2: cc.Vec3, rate: number) { + p1.x += this.getInterpplation(p1.x, p2.x, rate); + p1.y += this.getInterpplation(p1.y, p2.y, rate); + p1.z += this.getInterpplation(p1.z, p2.z, rate); + } + + public init() { + this.initPosition(); + this.initPolygon(); + this.initMat(); + } + + public reset() { + this.resetMesh(); + this._playing = false; + } + public clear() { + + } + + protected _playing: boolean = false; + /**是否正在运行 */ + public get playing() { return this._playing; } + /** + * 开始运行 + * @param startPosition 拖尾头部坐标,将从该位置开始出现拖尾 + * @param angle 拖尾初始角度(该功能暂未完成) + */ + public play(startPosition: cc.Vec3, angle?: cc.Vec3) { + if (this.polygon.length == 0) { + cc.warn("拖尾特效未设置横截面形状!"); + return; + } + if (!this.target) { + cc.warn("拖尾未设置跟随的目标节点!"); + return; + } + this._playing = true; + this.startPosition.set(startPosition); + this.resetMesh(); + } + /**停止运行,拖尾将逐渐缩短消失 */ + public stop() { + this._playing = false; + } + + /** + * 设置拖尾头部的位置,可通过定时调用该方法驱动拖尾运行 + * @param pos 头尾头部坐标 + * @param angle 拖尾头部的方向,默认为垂直朝向XY平面 + */ + public moveTo(pos: cc.Vec3, angle?: cc.Vec3) { + this.startPosition = pos; + let maxIndex = this.polygon.length - 1; + if (undefined === angle) { + for (let i = maxIndex; i >= 0; --i) { + this.verts[i].x = this.startPosition.x + this.polygon[i].x; + this.verts[i].y = this.startPosition.y + this.polygon[i].y; + this.verts[i].z = this.startPosition.z; + } + if (maxIndex >= 2 && this.polygonClosed) { + maxIndex++; + this.verts[maxIndex].x = this.startPosition.x + this.polygon[0].x; + this.verts[maxIndex].y = this.startPosition.y + this.polygon[0].y; + this.verts[maxIndex].z = this.startPosition.z; + } + } else { + for (let i = maxIndex; i >= 0; --i) { + let offset = cc.v3(this.polygon[i].x, this.polygon[i].y, 0); + offset = this.rotatePos(offset, angle); + this.verts[i].x = this.startPosition.x + offset.x; + this.verts[i].y = this.startPosition.y + offset.y; + this.verts[i].z = this.startPosition.z + offset.z; + } + if (maxIndex >= 2 && this.polygonClosed) { + maxIndex++; + let offset = cc.v3(this.polygon[0].x, this.polygon[0].y, 0); + offset = this.rotatePos(offset, angle); + this.verts[maxIndex].x = this.startPosition.x + offset.x; + this.verts[maxIndex].y = this.startPosition.y + offset.y; + this.verts[maxIndex].z = this.startPosition.z + offset.z; + } + } + this.updateMesh(); + } + protected rotatePos(p: cc.Vec3, angle: cc.Vec3): cc.Vec3 { + //旋转顺序:Y-X-Z + let p1 = cc.v2(p.x, p.z); + this.rotateV2(p1, angle.y); + let p2 = cc.v2(p.y, p1.y); + this.rotateV2(p2, angle.x); + let p3 = cc.v2(p1.x, p2.x); + this.rotateV2(p3, angle.z); + p.x = p3.x; + p.y = p3.y; + p.z = p2.y; + return p; + } + protected rotateV2(p: cc.Vec2, angle: number) { + let radian = angle * 0.017453; + let sin = Math.sin(radian); + let cos = Math.cos(radian); + let x = p.x; + let y = p.y; + p.x = x * cos - y * sin; + p.y = x * sin + y * cos; + } + + /**跟随的目标节点 */ + protected target: cc.Node; + protected offset: cc.Vec3; + /** + * 设置拖尾跟随的目标节点 + * @param target 目标节点,需要与本节点在同一父节点下,或者其所有父节点的坐标、角度为(0,0,0),缩放为(1,1,1) + * @param offset 拖尾的中心点相对目标节点的坐标的偏移量 + */ + public setTarget(target: cc.Node, offset: cc.Vec3) { + this.target = target; + this.offset = offset.clone(); + } + + + //自定义方法,针对实际需求优化: + public customUpdate(dt: number) { + if (!this._playing) { + this.moveTo(this.startPosition); + } else { + this.moveTo(cc.v3(0, this.target.y + 0.5, this.target.z)); + } + } + + //通用方法: + // public update(dt: number) { + // if (!this.playing || !this.target) return; + // let pos = cc.v3(); + // this.target.getPosition(pos); + // pos.addSelf(this.offset); + // if (!this.followAngle) { + // this.moveTo(pos); + // } else { + // this.moveTo(pos, this.target.eulerAngles); + // } + // } +} diff --git a/MeshDemo/assets/TrailEffect/TrailEffect.ts.meta b/MeshDemo/assets/TrailEffect/TrailEffect.ts.meta new file mode 100644 index 0000000..e977dfc --- /dev/null +++ b/MeshDemo/assets/TrailEffect/TrailEffect.ts.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.8", + "uuid": "bfef6526-3884-4025-8adb-56fe6b83ebb5", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/MeshDemo/creator.d.ts b/MeshDemo/creator.d.ts new file mode 100644 index 0000000..d027e3e --- /dev/null +++ b/MeshDemo/creator.d.ts @@ -0,0 +1,32069 @@ + +/** !#en +The main namespace of Cocos2d-JS, all engine core classes, functions, properties and constants are defined in this namespace. +!#zh +Cocos 引擎的主要命名空间,引擎代码中所有的类,函数,属性和常量都在这个命名空间中定义。 */ +declare namespace cc { + /** The current version of Cocos2d being used.
+ Please DO NOT remove this String, it is an important flag for bug tracking.
+ If you post a bug to forum, please attach this flag. */ + export var ENGINE_VERSION: string; + /** + !#en + Creates the speed action which changes the speed of an action, making it take longer (speed > 1) + or less (speed < 1) time.
+ Useful to simulate 'slow motion' or 'fast forward' effect. + !#zh 修改目标动作的速率。 + @param action action + @param speed speed + + @example + ```js + // change the target action speed; + var action = cc.scaleTo(0.2, 1, 0.6); + var newAction = cc.speed(action, 0.5); + ``` + */ + export function speed(action: ActionInterval, speed: number): Action; + /** + !#en Create a follow action which makes its target follows another node. + !#zh 追踪目标节点的位置。 + @param followedNode followedNode + @param rect rect + + @example + ```js + // example + // creates the action with a set boundary + var followAction = cc.follow(targetNode, cc.rect(0, 0, screenWidth * 2 - 100, screenHeight)); + node.runAction(followAction); + + // creates the action with no boundary set + var followAction = cc.follow(targetNode); + node.runAction(followAction); + ``` + */ + export function follow(followedNode: Node, rect: Rect): Action; + /** + Points setter + @param points points + */ + export function setPoints(points: any[]): void; + /** + !#en Creates an action with a Cardinal Spline array of points and tension. + !#zh 按基数样条曲线轨迹移动到目标位置。 + @param duration duration + @param points array of control points + @param tension tension + + @example + ```js + //create a cc.CardinalSplineTo + var action1 = cc.cardinalSplineTo(3, array, 0); + ``` + */ + export function cardinalSplineTo(duration: number, points: any[], tension: number): ActionInterval; + /** + update position of target + @param newPos newPos + */ + export function updatePosition(newPos: Vec2): void; + /** + !#en Creates an action with a Cardinal Spline array of points and tension. + !#zh 按基数样条曲线轨迹移动指定的距离。 + @param duration duration + @param points points + @param tension tension + */ + export function cardinalSplineBy(duration: number, points: any[], tension: number): ActionInterval; + /** + !#en Creates an action with a Cardinal Spline array of points and tension. + !#zh 按 Catmull Rom 样条曲线轨迹移动到目标位置。 + @param dt dt + @param points points + + @example + ```js + var action1 = cc.catmullRomTo(3, array); + ``` + */ + export function catmullRomTo(dt: number, points: any[]): ActionInterval; + /** + !#en Creates an action with a Cardinal Spline array of points and tension. + !#zh 按 Catmull Rom 样条曲线轨迹移动指定的距离。 + @param dt dt + @param points points + + @example + ```js + var action1 = cc.catmullRomBy(3, array); + ``` + */ + export function catmullRomBy(dt: number, points: any[]): ActionInterval; + /** + !#en + Creates the action easing object with the rate parameter.
+ From slow to fast. + !#zh 创建 easeIn 缓动对象,由慢到快。 + @param rate rate + + @example + ```js + action.easing(cc.easeIn(3.0)); + ``` + */ + export function easeIn(rate: number): any; + /** + !#en + Creates the action easing object with the rate parameter.
+ From fast to slow. + !#zh 创建 easeOut 缓动对象,由快到慢。 + @param rate rate + + @example + ```js + action.easing(cc.easeOut(3.0)); + ``` + */ + export function easeOut(rate: number): any; + /** + !#en + Creates the action easing object with the rate parameter.
+ Slow to fast then to slow. + !#zh 创建 easeInOut 缓动对象,慢到快,然后慢。 + @param rate rate + + @example + ```js + action.easing(cc.easeInOut(3.0)); + ``` + */ + export function easeInOut(rate: number): any; + /** + !#en + Creates the action easing object with the rate parameter.
+ Reference easeInExpo:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeExponentialIn 缓动对象。
+ EaseExponentialIn 是按指数函数缓动进入的动作。
+ 参考 easeInExpo:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + action.easing(cc.easeExponentialIn()); + ``` + */ + export function easeExponentialIn(): any; + /** + !#en + Creates the action easing object.
+ Reference easeOutExpo:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeExponentialOut 缓动对象。
+ EaseExponentialOut 是按指数函数缓动退出的动作。
+ 参考 easeOutExpo:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + action.easing(cc.easeExponentialOut()); + ``` + */ + export function easeExponentialOut(): any; + /** + !#en + Creates an EaseExponentialInOut action easing object.
+ Reference easeInOutExpo:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeExponentialInOut 缓动对象。
+ EaseExponentialInOut 是按指数函数缓动进入并退出的动作。
+ 参考 easeInOutExpo:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + action.easing(cc.easeExponentialInOut()); + ``` + */ + export function easeExponentialInOut(): any; + /** + !#en + Creates an EaseSineIn action.
+ Reference easeInSine:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 EaseSineIn 缓动对象。
+ EaseSineIn 是按正弦函数缓动进入的动作。
+ 参考 easeInSine:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + action.easing(cc.easeSineIn()); + ``` + */ + export function easeSineIn(): any; + /** + !#en + Creates an EaseSineOut action easing object.
+ Reference easeOutSine:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 EaseSineOut 缓动对象。
+ EaseSineIn 是按正弦函数缓动退出的动作。
+ 参考 easeOutSine:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + action.easing(cc.easeSineOut()); + ``` + */ + export function easeSineOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInOutSine:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeSineInOut 缓动对象。
+ EaseSineIn 是按正弦函数缓动进入并退出的动作。
+ 参考 easeInOutSine:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + action.easing(cc.easeSineInOut()); + ``` + */ + export function easeSineInOut(): any; + /** + !#en + Creates the action easing object with the period in radians (default is 0.3).
+ Reference easeInElastic:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeElasticIn 缓动对象。
+ EaseElasticIn 是按弹性曲线缓动进入的动作。
+ 参数 easeInElastic:http://www.zhihu.com/question/21981571/answer/19925418 + @param period period + + @example + ```js + // example + action.easing(cc.easeElasticIn(3.0)); + ``` + */ + export function easeElasticIn(period: number): any; + /** + !#en + Creates the action easing object with the period in radians (default is 0.3).
+ Reference easeOutElastic:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeElasticOut 缓动对象。
+ EaseElasticOut 是按弹性曲线缓动退出的动作。
+ 参考 easeOutElastic:http://www.zhihu.com/question/21981571/answer/19925418 + @param period period + + @example + ```js + // example + action.easing(cc.easeElasticOut(3.0)); + ``` + */ + export function easeElasticOut(period: number): any; + /** + !#en + Creates the action easing object with the period in radians (default is 0.3).
+ Reference easeInOutElastic:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeElasticInOut 缓动对象。
+ EaseElasticInOut 是按弹性曲线缓动进入并退出的动作。
+ 参考 easeInOutElastic:http://www.zhihu.com/question/21981571/answer/19925418 + @param period period + + @example + ```js + // example + action.easing(cc.easeElasticInOut(3.0)); + ``` + */ + export function easeElasticInOut(period: number): any; + /** + !#en + Creates the action easing object.
+ Eased bounce effect at the beginning. + !#zh + 创建 easeBounceIn 缓动对象。
+ EaseBounceIn 是按弹跳动作缓动进入的动作。 + + @example + ```js + // example + action.easing(cc.easeBounceIn()); + ``` + */ + export function easeBounceIn(): any; + /** + !#en + Creates the action easing object.
+ Eased bounce effect at the ending. + !#zh + 创建 easeBounceOut 缓动对象。
+ EaseBounceOut 是按弹跳动作缓动退出的动作。 + + @example + ```js + // example + action.easing(cc.easeBounceOut()); + ``` + */ + export function easeBounceOut(): any; + /** + !#en + Creates the action easing object.
+ Eased bounce effect at the begining and ending. + !#zh + 创建 easeBounceInOut 缓动对象。
+ EaseBounceInOut 是按弹跳动作缓动进入并退出的动作。 + + @example + ```js + // example + action.easing(cc.easeBounceInOut()); + ``` + */ + export function easeBounceInOut(): any; + /** + !#en + Creates the action easing object.
+ In the opposite direction to move slowly, and then accelerated to the right direction. + !#zh + 创建 easeBackIn 缓动对象。
+ easeBackIn 是在相反的方向缓慢移动,然后加速到正确的方向。
+ + @example + ```js + // example + action.easing(cc.easeBackIn()); + ``` + */ + export function easeBackIn(): any; + /** + !#en + Creates the action easing object.
+ Fast moving more than the finish, and then slowly back to the finish. + !#zh + 创建 easeBackOut 缓动对象。
+ easeBackOut 快速移动超出目标,然后慢慢回到目标点。 + + @example + ```js + // example + action.easing(cc.easeBackOut()); + ``` + */ + export function easeBackOut(): any; + /** + !#en + Creates the action easing object.
+ Begining of cc.EaseBackIn. Ending of cc.EaseBackOut. + !#zh + 创建 easeBackInOut 缓动对象。
+ + @example + ```js + // example + action.easing(cc.easeBackInOut()); + ``` + */ + export function easeBackInOut(): any; + /** + !#en + Creates the action easing object.
+ Into the 4 reference point.
+ To calculate the motion curve. + !#zh + 创建 easeBezierAction 缓动对象。
+ EaseBezierAction 是按贝塞尔曲线缓动的动作。 + @param p0 The first bezier parameter + @param p1 The second bezier parameter + @param p2 The third bezier parameter + @param p3 The fourth bezier parameter + + @example + ```js + // example + action.easing(cc.easeBezierAction(0.5, 0.5, 1.0, 1.0)); + ``` + */ + export function easeBezierAction(p0: number, p1: number, p2: number, p3: number): any; + /** + !#en + Creates the action easing object.
+ Reference easeInQuad:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuadraticActionIn 缓动对象。
+ EaseQuadraticIn是按二次函数缓动进入的动作。
+ 参考 easeInQuad:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeQuadraticActionIn()); + ``` + */ + export function easeQuadraticActionIn(): any; + /** + !#en + Creates the action easing object.
+ Reference easeOutQuad:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuadraticActionOut 缓动对象。
+ EaseQuadraticOut 是按二次函数缓动退出的动作。
+ 参考 easeOutQuad:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeQuadraticActionOut()); + ``` + */ + export function easeQuadraticActionOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInOutQuad:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuadraticActionInOut 缓动对象。
+ EaseQuadraticInOut 是按二次函数缓动进入并退出的动作。
+ 参考 easeInOutQuad:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeQuadraticActionInOut()); + ``` + */ + export function easeQuadraticActionInOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeIntQuart:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuarticActionIn 缓动对象。
+ EaseQuarticIn 是按四次函数缓动进入的动作。
+ 参考 easeIntQuart:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeQuarticActionIn()); + ``` + */ + export function easeQuarticActionIn(): any; + /** + !#en + Creates the action easing object.
+ Reference easeOutQuart:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuarticActionOut 缓动对象。
+ EaseQuarticOut 是按四次函数缓动退出的动作。
+ 参考 easeOutQuart:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.QuarticActionOut()); + ``` + */ + export function easeQuarticActionOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInOutQuart:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuarticActionInOut 缓动对象。
+ EaseQuarticInOut 是按四次函数缓动进入并退出的动作。
+ 参考 easeInOutQuart:http://www.zhihu.com/question/21981571/answer/19925418 + */ + export function easeQuarticActionInOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInQuint:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuinticActionIn 缓动对象。
+ EaseQuinticIn 是按五次函数缓动进的动作。
+ 参考 easeInQuint:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeQuinticActionIn()); + ``` + */ + export function easeQuinticActionIn(): any; + /** + !#en + Creates the action easing object.
+ Reference easeOutQuint:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuinticActionOut 缓动对象。
+ EaseQuinticOut 是按五次函数缓动退出的动作 + 参考 easeOutQuint:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeQuadraticActionOut()); + ``` + */ + export function easeQuinticActionOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInOutQuint:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeQuinticActionInOut 缓动对象。
+ EaseQuinticInOut是按五次函数缓动进入并退出的动作。
+ 参考 easeInOutQuint:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeQuinticActionInOut()); + ``` + */ + export function easeQuinticActionInOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInCirc:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeCircleActionIn 缓动对象。
+ EaseCircleIn是按圆形曲线缓动进入的动作。
+ 参考 easeInCirc:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeCircleActionIn()); + ``` + */ + export function easeCircleActionIn(): any; + /** + !#en + Creates the action easing object.
+ Reference easeOutCirc:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeCircleActionOut 缓动对象。
+ EaseCircleOut是按圆形曲线缓动退出的动作。
+ 参考 easeOutCirc:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + actioneasing(cc.easeCircleActionOut()); + ``` + */ + export function easeCircleActionOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInOutCirc:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeCircleActionInOut 缓动对象。
+ EaseCircleInOut 是按圆形曲线缓动进入并退出的动作。
+ 参考 easeInOutCirc:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeCircleActionInOut()); + ``` + */ + export function easeCircleActionInOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInCubic:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeCubicActionIn 缓动对象。
+ EaseCubicIn 是按三次函数缓动进入的动作。
+ 参考 easeInCubic:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeCubicActionIn()); + ``` + */ + export function easeCubicActionIn(): any; + /** + !#en + Creates the action easing object.
+ Reference easeOutCubic:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeCubicActionOut 缓动对象。
+ EaseCubicOut 是按三次函数缓动退出的动作。
+ 参考 easeOutCubic:http://www.zhihu.com/question/21981571/answer/19925418 + + @example + ```js + //example + action.easing(cc.easeCubicActionOut()); + ``` + */ + export function easeCubicActionOut(): any; + /** + !#en + Creates the action easing object.
+ Reference easeInOutCubic:
+ http://www.zhihu.com/question/21981571/answer/19925418 + !#zh + 创建 easeCubicActionInOut 缓动对象。
+ EaseCubicInOut是按三次函数缓动进入并退出的动作。
+ 参考 easeInOutCubic:http://www.zhihu.com/question/21981571/answer/19925418 + */ + export function easeCubicActionInOut(): any; + /** + !#en Show the Node. + !#zh 立即显示。 + + @example + ```js + // example + var showAction = cc.show(); + ``` + */ + export function show(): ActionInstant; + /** + !#en Hide the node. + !#zh 立即隐藏。 + + @example + ```js + // example + var hideAction = cc.hide(); + ``` + */ + export function hide(): ActionInstant; + /** + !#en Toggles the visibility of a node. + !#zh 显隐状态切换。 + + @example + ```js + // example + var toggleVisibilityAction = cc.toggleVisibility(); + ``` + */ + export function toggleVisibility(): ActionInstant; + /** + !#en Create a RemoveSelf object with a flag indicate whether the target should be cleaned up while removing. + !#zh 从父节点移除自身。 + @param isNeedCleanUp isNeedCleanUp + + @example + ```js + // example + var removeSelfAction = cc.removeSelf(); + ``` + */ + export function removeSelf(isNeedCleanUp ?: boolean): ActionInstant; + /** + !#en Destroy self + !#zh 创建一个销毁自身的动作。 + + @example + ```js + var destroySelfAction = cc.destroySelf(); + ``` + */ + export function destroySelf(): ActionInstant; + /** + !#en Create a FlipX action to flip or unflip the target. + !#zh X轴翻转。 + @param flip Indicate whether the target should be flipped or not + + @example + ```js + var flipXAction = cc.flipX(true); + ``` + */ + export function flipX(flip: boolean): ActionInstant; + /** + !#en Create a FlipY action to flip or unflip the target. + !#zh Y轴翻转。 + @param flip flip + + @example + ```js + var flipYAction = cc.flipY(true); + ``` + */ + export function flipY(flip: boolean): ActionInstant; + /** + !#en Creates a Place action with a position. + !#zh 放置在目标位置。 + @param pos pos + @param y y + + @example + ```js + // example + var placeAction = cc.place(cc.v2(200, 200)); + var placeAction = cc.place(200, 200); + ``` + */ + export function place(pos: Vec2|number, y?: number): ActionInstant; + /** + !#en Creates the action with the callback. + !#zh 执行回调函数。 + @param selector selector + @param selectorTarget selectorTarget + @param data data for function, it accepts all data types. + + @example + ```js + // example + // CallFunc without data + var finish = cc.callFunc(this.removeSprite, this); + + // CallFunc with data + var finish = cc.callFunc(this.removeFromParentAndCleanup, this._grossini, true); + ``` + */ + export function callFunc(selector: Function, selectorTarget?: any, data?: any): ActionInstant; + /** + !#en + Helper constructor to create an array of sequenceable actions + The created action will run actions sequentially, one after another. + !#zh 顺序执行动作,创建的动作将按顺序依次运行。 + @param actionOrActionArray actionOrActionArray + @param tempArray tempArray + + @example + ```js + // example + // create sequence with actions + var seq = cc.sequence(act1, act2); + + // create sequence with array + var seq = cc.sequence(actArray); + ``` + */ + export function sequence(actionOrActionArray: FiniteTimeAction|FiniteTimeAction[], ...tempArray: FiniteTimeAction[]): ActionInterval; + /** + !#en Creates a Repeat action. Times is an unsigned integer between 1 and pow(2,30) + !#zh 重复动作,可以按一定次数重复一个动,如果想永远重复一个动作请使用 repeatForever 动作来完成。 + @param action action + @param times times + + @example + ```js + // example + var rep = cc.repeat(cc.sequence(jump2, jump1), 5); + ``` + */ + export function repeat(action: FiniteTimeAction, times: number): ActionInterval; + /** + !#en Create a acton which repeat forever, as it runs forever, it can't be added into cc.sequence and cc.spawn. + !#zh 永远地重复一个动作,有限次数内重复一个动作请使用 repeat 动作,由于这个动作不会停止,所以不能被添加到 cc.sequence 或 cc.spawn 中。 + @param action action + + @example + ```js + // example + var repeat = cc.repeatForever(cc.rotateBy(1.0, 360)); + ``` + */ + export function repeatForever(action: FiniteTimeAction): ActionInterval; + /** + !#en Create a spawn action which runs several actions in parallel. + !#zh 同步执行动作,同步执行一组动作。 + @param actionOrActionArray actionOrActionArray + @param tempArray tempArray + + @example + ```js + // example + var action = cc.spawn(cc.jumpBy(2, cc.v2(300, 0), 50, 4), cc.rotateBy(2, 720)); + todo: It should be the direct use new + ``` + */ + export function spawn(actionOrActionArray: FiniteTimeAction|FiniteTimeAction[], ...tempArray: FiniteTimeAction[]): FiniteTimeAction; + /** + !#en + Rotates a Node object to a certain angle by modifying its angle property.
+ The direction will be decided by the shortest angle. + !#zh 旋转到目标角度,通过逐帧修改它的 angle 属性,旋转方向将由最短的角度决定。 + @param duration duration in seconds + @param dstAngle dstAngle in degrees. + + @example + ```js + // example + var rotateTo = cc.rotateTo(2, 61.0); + ``` + */ + export function rotateTo(duration: number, dstAngle: number): ActionInterval; + /** + !#en + Rotates a Node object clockwise a number of degrees by modifying its angle property. + Relative to its properties to modify. + !#zh 旋转指定的角度。 + @param duration duration in seconds + @param deltaAngle deltaAngle in degrees + + @example + ```js + // example + var actionBy = cc.rotateBy(2, 360); + ``` + */ + export function rotateBy(duration: number, deltaAngle: number): ActionInterval; + /** + !#en + Moves a Node object x,y pixels by modifying its position property.
+ x and y are relative to the position of the object.
+ Several MoveBy actions can be concurrently called, and the resulting
+ movement will be the sum of individual movements. + !#zh 移动指定的距离。 + @param duration duration in seconds + @param deltaPos deltaPos + @param deltaY deltaY + + @example + ```js + // example + var actionTo = cc.moveBy(2, cc.v2(windowSize.width - 40, windowSize.height - 40)); + ``` + */ + export function moveBy(duration: number, deltaPos: Vec2|number, deltaY?: number): ActionInterval; + /** + !#en + Moves a Node object to the position x,y. x and y are absolute coordinates by modifying its position property.
+ Several MoveTo actions can be concurrently called, and the resulting
+ movement will be the sum of individual movements. + !#zh 移动到目标位置。 + @param duration duration in seconds + @param position position + @param y y + + @example + ```js + // example + var actionBy = cc.moveTo(2, cc.v2(80, 80)); + ``` + */ + export function moveTo(duration: number, position: Vec2|number, y?: number): ActionInterval; + /** + !#en + Create a action which skews a Node object to given angles by modifying its skewX and skewY properties. + Changes to the specified value. + !#zh 偏斜到目标角度。 + @param t time in seconds + @param sx sx + @param sy sy + + @example + ```js + // example + var actionTo = cc.skewTo(2, 37.2, -37.2); + ``` + */ + export function skewTo(t: number, sx: number, sy: number): ActionInterval; + /** + !#en + Skews a Node object by skewX and skewY degrees.
+ Relative to its property modification. + !#zh 偏斜指定的角度。 + @param t time in seconds + @param sx sx skew in degrees for X axis + @param sy sy skew in degrees for Y axis + + @example + ```js + // example + var actionBy = cc.skewBy(2, 0, -90); + ``` + */ + export function skewBy(t: number, sx: number, sy: number): ActionInterval; + /** + !#en + Moves a Node object simulating a parabolic jump movement by modifying it's position property. + Relative to its movement. + !#zh 用跳跃的方式移动指定的距离。 + @param duration duration + @param position position + @param y y + @param height height + @param jumps jumps + + @example + ```js + // example + var actionBy = cc.jumpBy(2, cc.v2(300, 0), 50, 4); + var actionBy = cc.jumpBy(2, 300, 0, 50, 4); + ``` + */ + export function jumpBy(duration: number, position: Vec2|number, y?: number, height?: number, jumps?: number): ActionInterval; + /** + !#en + Moves a Node object to a parabolic position simulating a jump movement by modifying its position property.
+ Jump to the specified location. + !#zh 用跳跃的方式移动到目标位置。 + @param duration duration + @param position position + @param y y + @param height height + @param jumps jumps + + @example + ```js + // example + var actionTo = cc.jumpTo(2, cc.v2(300, 300), 50, 4); + var actionTo = cc.jumpTo(2, 300, 300, 50, 4); + ``` + */ + export function jumpTo(duration: number, position: Vec2|number, y?: number, height?: number, jumps?: number): ActionInterval; + /** + !#en + An action that moves the target with a cubic Bezier curve by a certain distance. + Relative to its movement. + !#zh 按贝赛尔曲线轨迹移动指定的距离。 + @param t time in seconds + @param c Array of points + + @example + ```js + // example + var bezier = [cc.v2(0, windowSize.height / 2), cc.v2(300, -windowSize.height / 2), cc.v2(300, 100)]; + var bezierForward = cc.bezierBy(3, bezier); + ``` + */ + export function bezierBy(t: number, c: Vec2[]): ActionInterval; + /** + !#en An action that moves the target with a cubic Bezier curve to a destination point. + !#zh 按贝赛尔曲线轨迹移动到目标位置。 + @param t t + @param c Array of points + + @example + ```js + // example + var bezier = [cc.v2(0, windowSize.height / 2), cc.v2(300, -windowSize.height / 2), cc.v2(300, 100)]; + var bezierTo = cc.bezierTo(2, bezier); + ``` + */ + export function bezierTo(t: number, c: Vec2[]): ActionInterval; + /** + !#en Scales a Node object to a zoom factor by modifying it's scale property. + !#zh 将节点大小缩放到指定的倍数。 + @param duration duration + @param sx scale parameter in X + @param sy scale parameter in Y, if Null equal to sx + + @example + ```js + // example + // It scales to 0.5 in both X and Y. + var actionTo = cc.scaleTo(2, 0.5); + + // It scales to 0.5 in x and 2 in Y + var actionTo = cc.scaleTo(2, 0.5, 2); + ``` + */ + export function scaleTo(duration: number, sx: number, sy?: number): ActionInterval; + /** + !#en + Scales a Node object a zoom factor by modifying it's scale property. + Relative to its changes. + !#zh 按指定的倍数缩放节点大小。 + @param duration duration in seconds + @param sx sx scale parameter in X + @param sy sy scale parameter in Y, if Null equal to sx + + @example + ```js + // example without sy, it scales by 2 both in X and Y + var actionBy = cc.scaleBy(2, 2); + + //example with sy, it scales by 0.25 in X and 4.5 in Y + var actionBy2 = cc.scaleBy(2, 0.25, 4.5); + ``` + */ + export function scaleBy(duration: number, sx: number, sy?: number|void): ActionInterval; + /** + !#en Blinks a Node object by modifying it's visible property. + !#zh 闪烁(基于透明度)。 + @param duration duration in seconds + @param blinks blinks in times + + @example + ```js + // example + var action = cc.blink(2, 10); + ``` + */ + export function blink(duration: number, blinks: number): ActionInterval; + /** + !#en + Fades an object that implements the cc.RGBAProtocol protocol. + It modifies the opacity from the current value to a custom one. + !#zh 修改透明度到指定值。 + @param duration duration + @param opacity 0-255, 0 is transparent + + @example + ```js + // example + var action = cc.fadeTo(1.0, 0); + ``` + */ + export function fadeTo(duration: number, opacity: number): ActionInterval; + /** + !#en Fades In an object that implements the cc.RGBAProtocol protocol. It modifies the opacity from 0 to 255. + !#zh 渐显效果。 + @param duration duration in seconds + + @example + ```js + //example + var action = cc.fadeIn(1.0); + ``` + */ + export function fadeIn(duration: number): ActionInterval; + /** + !#en Fades Out an object that implements the cc.RGBAProtocol protocol. It modifies the opacity from 255 to 0. + !#zh 渐隐效果。 + @param d duration in seconds + + @example + ```js + // example + var action = cc.fadeOut(1.0); + ``` + */ + export function fadeOut(d: number): ActionInterval; + /** + !#en Tints a Node that implements the cc.NodeRGB protocol from current tint to a custom one. + !#zh 修改颜色到指定值。 + @param duration duration + @param red 0-255 + @param green 0-255 + @param blue 0-255 + + @example + ```js + // example + var action = cc.tintTo(2, 255, 0, 255); + ``` + */ + export function tintTo(duration: number, red: number, green: number, blue: number): ActionInterval; + /** + !#en + Tints a Node that implements the cc.NodeRGB protocol from current tint to a custom one. + Relative to their own color change. + !#zh 按照指定的增量修改颜色。 + @param duration duration in seconds + @param deltaRed deltaRed + @param deltaGreen deltaGreen + @param deltaBlue deltaBlue + + @example + ```js + // example + var action = cc.tintBy(2, -127, -255, -127); + ``` + */ + export function tintBy(duration: number, deltaRed: number, deltaGreen: number, deltaBlue: number): ActionInterval; + /** + !#en Delays the action a certain amount of seconds. + !#zh 延迟指定的时间量。 + @param d duration in seconds + + @example + ```js + // example + var delay = cc.delayTime(1); + ``` + */ + export function delayTime(d: number): ActionInterval; + /** + !#en Executes an action in reverse order, from time=duration to time=0. + !#zh 反转目标动作的时间轴。 + @param action action + + @example + ```js + // example + var reverse = cc.reverseTime(this); + ``` + */ + export function reverseTime(action: FiniteTimeAction): ActionInterval; + /** + !#en Create an action with the specified action and forced target. + !#zh 用已有动作和一个新的目标节点创建动作。 + @param target target + @param action action + */ + export function targetedAction(target: Node, action: FiniteTimeAction): ActionInterval; + /** + + @param target the target to animate + */ + export function tween (target?: T) : Tween; + /** !#en This is a Easing instance. + !#zh 这是一个 Easing 类实例。 */ + export var easing: Easing; + /** + !#en + Outputs an error message to the Cocos Creator Console (editor) or Web Console (runtime).
+ - In Cocos Creator, error is red.
+ - In Chrome, error have a red icon along with red message text.
+ !#zh + 输出错误消息到 Cocos Creator 编辑器的 Console 或运行时页面端的 Console 中。
+ - 在 Cocos Creator 中,错误信息显示是红色的。
+ - 在 Chrome 中,错误信息有红色的图标以及红色的消息文本。
+ @param msg A JavaScript string containing zero or more substitution strings. + @param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output. + */ + export function error(msg: any, ...subst: any[]): void; + /** + !#en + Outputs a warning message to the Cocos Creator Console (editor) or Web Console (runtime). + - In Cocos Creator, warning is yellow. + - In Chrome, warning have a yellow warning icon with the message text. + !#zh + 输出警告消息到 Cocos Creator 编辑器的 Console 或运行时 Web 端的 Console 中。
+ - 在 Cocos Creator 中,警告信息显示是黄色的。
+ - 在 Chrome 中,警告信息有着黄色的图标以及黄色的消息文本。
+ @param msg A JavaScript string containing zero or more substitution strings. + @param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output. + */ + export function warn(msg: any, ...subst: any[]): void; + /** + !#en Outputs a message to the Cocos Creator Console (editor) or Web Console (runtime). + !#zh 输出一条消息到 Cocos Creator 编辑器的 Console 或运行时 Web 端的 Console 中。 + @param msg A JavaScript string containing zero or more substitution strings. + @param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output. + */ + export function log(msg: string|any, ...subst: any[]): void; + /** !#en Director + !#zh 导演类。 */ + export var director: Director; + /** !#en This is a Game instance. + !#zh 这是一个 Game 类的实例,包含游戏主体信息并负责驱动游戏的游戏对象。。 */ + export var game: Game; + export var assetManager: AssetManager; + /** !#en + cc.resources is a bundle and controls all asset under assets/resources + + !#zh + cc.resources 是一个 bundle,用于管理所有在 assets/resources 下的资源 */ + export var resources: AssetManager.Bundle; + /** + !#en + Rotates a Node object to a certain angle by modifying its quternion property.
+ The direction will be decided by the shortest angle. + !#zh 旋转到目标角度,通过逐帧修改它的 quternion 属性,旋转方向将由最短的角度决定。 + @param duration duration in seconds + @param dstAngleX dstAngleX in degrees. + @param dstAngleY dstAngleY in degrees. + @param dstAngleZ dstAngleZ in degrees. + + @example + ```js + // example + var rotate3DTo = cc.rotate3DTo(2, cc.v3(0, 180, 0)); + ``` + */ + export function rotate3DTo(duration: number, dstAngleX: number|Vec3|Quat, dstAngleY?: number, dstAngleZ?: number): ActionInterval; + /** + !#en + Rotates a Node object counter clockwise a number of degrees by modifying its quaternion property. + Relative to its properties to modify. + !#zh 旋转指定的 3D 角度。 + @param duration duration in seconds + @param deltaAngleX deltaAngleX in degrees + @param deltaAngleY deltaAngleY in degrees + @param deltaAngleZ deltaAngleZ in degrees + + @example + ```js + // example + var actionBy = cc.rotate3DBy(2, cc.v3(0, 360, 0)); + ``` + */ + export function rotate3DBy(duration: number, deltaAngleX: number|Vec3, deltaAngleY?: number, deltaAngleZ?: number): ActionInterval; + /** !#en The System event singleton for global usage + !#zh 系统事件单例,方便全局使用 */ + export var systemEvent: SystemEvent; + /** + !#en Defines a CCClass using the given specification, please see [Class](/docs/editors_and_tools/creator-chapters/scripting/class.html) for details. + !#zh 定义一个 CCClass,传入参数必须是一个包含类型参数的字面量对象,具体用法请查阅[类型定义](/docs/creator/scripting/class.html)。 + @param options options + + @example + ```js + // define base class + var Node = cc.Class(); + + // define sub class + var Sprite = cc.Class({ + name: 'Sprite', + extends: Node, + + ctor: function () { + this.url = ""; + this.id = 0; + }, + + statics: { + // define static members + count: 0, + getBounds: function (spriteList) { + // compute bounds... + } + }, + + properties { + width: { + default: 128, + type: cc.Integer, + tooltip: 'The width of sprite' + }, + height: 128, + size: { + get: function () { + return cc.v2(this.width, this.height); + } + } + }, + + load: function () { + // load this.url... + }; + }); + + // instantiate + + var obj = new Sprite(); + obj.url = 'sprite.png'; + obj.load(); + ``` + */ + export function Class(options?: {name?: string; extends?: Function; ctor?: Function; __ctor__?: Function; properties?: any; statics?: any; mixins?: Function[]; editor?: {executeInEditMode?: boolean; requireComponent?: Function; menu?: string; executionOrder?: number; disallowMultiple?: boolean; playOnFocus?: boolean; inspector?: string; icon?: string; help?: string; }; update?: Function; lateUpdate?: Function; onLoad?: Function; start?: Function; onEnable?: Function; onDisable?: Function; onDestroy?: Function; onFocusInEditor?: Function; onLostFocusInEditor?: Function; resetInEditor?: Function; onRestore?: Function; _getLocalBounds?: Function; }): Function; + /** + !#en + Define an enum type.
+ If a enum item has a value of -1, it will be given an Integer number according to it's order in the list.
+ Otherwise it will use the value specified by user who writes the enum definition. + + !#zh + 定义一个枚举类型。
+ 用户可以把枚举值设为任意的整数,如果设为 -1,系统将会分配为上一个枚举值 + 1。 + @param obj a JavaScript literal object containing enum names and values, or a TypeScript enum type + + @example + ```js + // JavaScript: + + var WrapMode = cc.Enum({ + Repeat: -1, + Clamp: -1 + }); + + // Texture.WrapMode.Repeat == 0 + // Texture.WrapMode.Clamp == 1 + // Texture.WrapMode[0] == "Repeat" + // Texture.WrapMode[1] == "Clamp" + + var FlagType = cc.Enum({ + Flag1: 1, + Flag2: 2, + Flag3: 4, + Flag4: 8, + }); + + var AtlasSizeList = cc.Enum({ + 128: 128, + 256: 256, + 512: 512, + 1024: 1024, + }); + + // TypeScript: + + // If used in TypeScript, just define a TypeScript enum: + enum Direction { + Up, + Down, + Left, + Right + } + + // If you need to inspect the enum in Properties panel, you can call cc.Enum: + const {ccclass, property} = cc._decorator; + + @ccclass + class NewScript extends cc.Component { + @property({ + type: cc.Enum(Direction) // call cc.Enum + }) + direction: Direction = Direction.Up; + } + + ``` + */ + export function Enum(obj: T): T; + /** + + @param touches touches + */ + export function handleTouchesBegin(touches: any[]): void; + /** + + @param touches touches + */ + export function handleTouchesMove(touches: any[]): void; + /** + + @param touches touches + */ + export function handleTouchesEnd(touches: any[]): void; + /** + + @param touches touches + */ + export function handleTouchesCancel(touches: any[]): void; + /** + + @param touches touches + */ + export function getSetOfTouchesEndOrCancel(touches: any[]): any[]; + /** + + @param touch touch + */ + export function getPreTouch(touch: Touch): Touch; + /** + + @param touch touch + */ + export function setPreTouch(touch: Touch): void; + /** + + @param tx tx + @param ty ty + @param pos pos + */ + export function getTouchByXY(tx: number, ty: number, pos: Vec2): Touch; + /** + + @param location location + @param pos pos + @param eventType eventType + */ + export function getMouseEvent(location: Vec2, pos: Vec2, eventType: number): Event.EventMouse; + /** + + @param event event + @param pos pos + */ + export function getPointByEvent(event: Touch, pos: Vec2): Vec2; + /** + + @param event event + @param pos pos + */ + export function getTouchesByEvent(event: Touch, pos: Vec2): any[]; + /** + + @param element element + */ + export function registerSystemEvent(element: HTMLElement): void; + /** + + @param dt dt + */ + export function update(dt: number): void; + /** + !#en + Checks whether the object is non-nil and not yet destroyed.
+ When an object's `destroy` is called, it is actually destroyed after the end of this frame. + So `isValid` will return false from the next frame, while `isValid` in the current frame will still be true. + If you want to determine whether the current frame has called `destroy`, use `cc.isValid(obj, true)`, + but this is often caused by a particular logical requirements, which is not normally required. + + !#zh + 检查该对象是否不为 null 并且尚未销毁。
+ 当一个对象的 `destroy` 调用以后,会在这一帧结束后才真正销毁。因此从下一帧开始 `isValid` 就会返回 false,而当前帧内 `isValid` 仍然会是 true。如果希望判断当前帧是否调用过 `destroy`,请使用 `cc.isValid(obj, true)`,不过这往往是特殊的业务需求引起的,通常情况下不需要这样。 + @param value value + @param strictMode If true, Object called destroy() in this frame will also treated as invalid. + + @example + ```js + var node = new cc.Node(); + cc.log(cc.isValid(node)); // true + node.destroy(); + cc.log(cc.isValid(node)); // true, still valid in this frame + // after a frame... + cc.log(cc.isValid(node)); // false, destroyed in the end of last frame + ``` + */ + export function isValid(value: any, strictMode?: boolean): boolean; + /** !#en cc.view is the shared view object. + !#zh cc.view 是全局的视图对象。 */ + export var view: View; + /** !#en cc.winSize is the alias object for the size of the current game window. + !#zh cc.winSize 为当前的游戏窗口的大小。 */ + export var winSize: Size; + /** Specify that the input value must be integer in Inspector. + Also used to indicates that the elements in array should be type integer. */ + export var Integer: string; + /** Indicates that the elements in array should be type double. */ + export var Float: string; + /** Indicates that the elements in array should be type boolean. */ + export var Boolean: string; + /** Indicates that the elements in array should be type string. */ + export var String: string; + /** + !#en Deserialize json to cc.Asset + !#zh 将 JSON 反序列化为对象实例。 + @param data the serialized cc.Asset json string or json object. + @param details additional loading result + @param options options + */ + export function deserialize(data: string|any, details?: Details, options?: any): any; + /** + !#en Clones the object `original` and returns the clone, or instantiate a node from the Prefab. + !#zh 克隆指定的任意类型的对象,或者从 Prefab 实例化出新节点。 + + (Instantiate 时,function 和 dom 等非可序列化对象会直接保留原有引用,Asset 会直接进行浅拷贝,可序列化类型会进行深拷贝。) + @param original An existing object that you want to make a copy of. + + @example + ```js + // instantiate node from prefab + var scene = cc.director.getScene(); + var node = cc.instantiate(prefabAsset); + node.parent = scene; + // clone node + var scene = cc.director.getScene(); + var node = cc.instantiate(targetNode); + node.parent = scene; + ``` + */ + export function instantiate(original: Prefab): Node; + export function instantiate(original: T): T; + /** + Finds a node by hierarchy path, the path is case-sensitive. + It will traverse the hierarchy by splitting the path using '/' character. + This function will still returns the node even if it is inactive. + It is recommended to not use this function every frame instead cache the result at startup. + @param path path + @param referenceNode referenceNode + */ + export function find(path: string, referenceNode?: Node): Node; + /** + !#en + The convenience method to create a new {{#crossLink "Color/Color:method"}}cc.Color{{/crossLink}} + Alpha channel is optional. Default value is 255. + + !#zh + 通过该方法来创建一个新的 {{#crossLink "Color/Color:method"}}cc.Color{{/crossLink}} 对象。 + Alpha 通道是可选的。默认值是 255。 + @param r r + @param g g + @param b b + @param a a + + @example + ```js + ----------------------- + // 1. All channels seperately as parameters + var color1 = new cc.Color(255, 255, 255, 255); + // 2. Convert a hex string to a color + var color2 = new cc.Color("#000000"); + // 3. An color object as parameter + var color3 = new cc.Color({r: 255, g: 255, b: 255, a: 255}); + + ``` + */ + export function color(r?: number, g?: number, b?: number, a?: number): Color; + /** + !#en The convenience method to create a new {{#crossLink "Mat4"}}cc.Mat4{{/crossLink}}. + !#zh 通过该简便的函数进行创建 {{#crossLink "Mat4"}}cc.Mat4{{/crossLink}} 对象。 + @param m00 Component in column 0, row 0 position (index 0) + @param m01 Component in column 0, row 1 position (index 1) + @param m02 Component in column 0, row 2 position (index 2) + @param m03 Component in column 0, row 3 position (index 3) + @param m10 Component in column 1, row 0 position (index 4) + @param m11 Component in column 1, row 1 position (index 5) + @param m12 Component in column 1, row 2 position (index 6) + @param m13 Component in column 1, row 3 position (index 7) + @param m20 Component in column 2, row 0 position (index 8) + @param m21 Component in column 2, row 1 position (index 9) + @param m22 Component in column 2, row 2 position (index 10) + @param m23 Component in column 2, row 3 position (index 11) + @param m30 Component in column 3, row 0 position (index 12) + @param m31 Component in column 3, row 1 position (index 13) + @param m32 Component in column 3, row 2 position (index 14) + @param m33 Component in column 3, row 3 position (index 15) + */ + export function mat4(m00?: number, m01?: number, m02?: number, m03?: number, m10?: number, m11?: number, m12?: number, m13?: number, m20?: number, m21?: number, m22?: number, m23?: number, m30?: number, m31?: number, m32?: number, m33?: number): Mat4; + /** + !#en The convenience method to create a new {{#crossLink "Quat"}}cc.Quat{{/crossLink}}. + !#zh 通过该简便的函数进行创建 {{#crossLink "Quat"}}cc.Quat{{/crossLink}} 对象。 + @param x x + @param y y + @param z z + @param w w + */ + export function quat(x?: number|any, y?: number, z?: number, w?: number): Quat; + /** + !#en + The convenience method to create a new Rect. + see {{#crossLink "Rect/Rect:method"}}cc.Rect{{/crossLink}} + !#zh + 该方法用来快速创建一个新的矩形。{{#crossLink "Rect/Rect:method"}}cc.Rect{{/crossLink}} + @param x x + @param y y + @param w w + @param h h + + @example + ```js + var a = new cc.Rect(0 , 0, 10, 0); + ``` + */ + export function rect(x?: number, y?: number, w?: number, h?: number): Rect; + /** + !#en + Helper function that creates a cc.Size.
+ Please use cc.p or cc.v2 instead, it will soon replace cc.Size. + !#zh + 创建一个 cc.Size 对象的帮助函数。
+ 注意:可以使用 cc.p 或者是 cc.v2 代替,它们将很快取代 cc.Size。 + @param w width or a size object + @param h height + + @example + ```js + var size1 = cc.size(); + var size2 = cc.size(100,100); + var size3 = cc.size(size2); + var size4 = cc.size({width: 100, height: 100}); + + ``` + */ + export function size(w: number|Size, h?: number): Size; + export var EPSILON: number; + /** + Clamps a value between a minimum float and maximum float value. + @param val val + @param min min + @param max max + */ + export function clamp(val: number, min: number, max: number): number; + /** + Clamps a value between 0 and 1. + @param val val + */ + export function clamp01(val: number): number; + /** + + @param from from + @param to to + @param ratio the interpolation coefficient + */ + export function lerp(from: number, to: number, ratio: number): number; + export function random(): void; + /** + Returns a floating-point random number between min (inclusive) and max (exclusive). + @param min min + @param max max + */ + export function randomRange(min: number, max: number): number; + /** + Returns a random integer between min (inclusive) and max (exclusive). + @param min min + @param max max + */ + export function randomRangeInt(min: number, max: number): number; + /** + Linear congruential generator using Hull-Dobell Theorem. + @param seed the random seed + */ + export function pseudoRandom(seed: number): number; + /** + Returns a floating-point pseudo-random number between min (inclusive) and max (exclusive). + @param seed seed + @param min min + @param max max + */ + export function pseudoRandomRange(seed: number, min: number, max: number): number; + /** + Returns a pseudo-random integer between min (inclusive) and max (exclusive). + @param seed seed + @param min min + @param max max + */ + export function pseudoRandomRangeInt(seed: number, min: number, max: number): number; + /** + Returns the next power of two for the value + @param val val + */ + export function nextPow2(val: number): number; + /** + Returns float remainder for t / length + @param t time start at 0 + @param length time of one cycle + */ + export function repeat(t: number, length: number): number; + /** + Returns time wrapped in ping-pong mode + @param t time start at 0 + @param length time of one cycle + */ + export function repeat(t: number, length: number): number; + /** + Returns ratio of a value within a given range + @param from start value + @param to end value + @param value given value + */ + export function repeat(from: number, to: number, value: number): number; + /** + Returns -1, 0, +1 depending on sign of x. + @param v v + */ + export function sign(v: number): void; + /** + !#en The convenience method to create a new {{#crossLink "Vec2"}}cc.Vec2{{/crossLink}}. + !#zh 通过该简便的函数进行创建 {{#crossLink "Vec2"}}cc.Vec2{{/crossLink}} 对象。 + @param x x + @param y y + + @example + ```js + var v1 = cc.v2(); + var v2 = cc.v2(0, 0); + var v3 = cc.v2(v2); + var v4 = cc.v2({x: 100, y: 100}); + ``` + */ + export function v2(x?: number|any, y?: number): Vec2; + /** + !#en The convenience method to create a new {{#crossLink "Vec3"}}cc.Vec3{{/crossLink}}. + !#zh 通过该简便的函数进行创建 {{#crossLink "Vec3"}}cc.Vec3{{/crossLink}} 对象。 + @param x x + @param y y + @param z z + + @example + ```js + var v1 = cc.v3(); + var v2 = cc.v3(0, 0, 0); + var v3 = cc.v3(v2); + var v4 = cc.v3({x: 100, y: 100, z: 0}); + ``` + */ + export function v3(x?: number|any, y?: number, z?: number): Vec3; + export var dynamicAtlasManager: DynamicAtlasManager; + /** !#en The matrix storage */ + export var matrix: any[]; + /** + !#en Get an element + @param i i + @param j j + */ + export function get(i: number, j: number): number; + /** + !#en Set an element + @param i i + @param j j + @param value value + */ + export function set(i: number, j: number, value: boolean): void; + /** + !#en Sets all elements to zero + */ + export function reset(): void; + /** !#en Base class cc.Action for action classes. + !#zh Action 类是所有动作类型的基类。 */ + export class Action { + /** + !#en + to copy object with deep copy. + returns a clone of action. + !#zh 返回一个克隆的动作。 + */ + clone(): Action; + /** + !#en + return true if the action has finished. + !#zh 如果动作已完成就返回 true。 + */ + isDone(): boolean; + /** + !#en get the target. + !#zh 获取当前目标节点。 + */ + getTarget(): Node; + /** + !#en The action will modify the target properties. + !#zh 设置目标节点。 + @param target target + */ + setTarget(target: Node): void; + /** + !#en get the original target. + !#zh 获取原始目标节点。 + */ + getOriginalTarget(): Node; + /** + !#en get tag number. + !#zh 获取用于识别动作的标签。 + */ + getTag(): number; + /** + !#en set tag number. + !#zh 设置标签,用于识别动作。 + @param tag tag + */ + setTag(tag: number): void; + /** !#en Default Action tag. + !#zh 默认动作标签。 */ + static TAG_INVALID: number; + } + /** !#en + Base class actions that do have a finite time duration.
+ Possible actions:
+ - An action with a duration of 0 seconds.
+ - An action with a duration of 35.5 seconds. + + Infinite time actions are valid + !#zh 有限时间动作,这种动作拥有时长 duration 属性。 */ + export class FiniteTimeAction extends Action { + /** + !#en get duration of the action. (seconds). + !#zh 获取动作以秒为单位的持续时间。 + */ + getDuration(): number; + /** + !#en set duration of the action. (seconds). + !#zh 设置动作以秒为单位的持续时间。 + @param duration duration + */ + setDuration(duration: number): void; + /** + !#en + Returns a reversed action.
+ For example:
+ - The action will be x coordinates of 0 move to 100.
+ - The reversed action will be x of 100 move to 0. + - Will be rewritten + !#zh 返回一个新的动作,执行与原动作完全相反的动作。 + */ + reverse(): void; + /** + !#en + to copy object with deep copy. + returns a clone of action. + !#zh 返回一个克隆的动作。 + */ + clone(): FiniteTimeAction; + } + /** !#en Instant actions are immediate actions. They don't have a duration like the ActionInterval actions. + !#zh 即时动作,这种动作立即就会执行,继承自 FiniteTimeAction。 */ + export class ActionInstant extends FiniteTimeAction { + } + /** !#en +

An interval action is an action that takes place within a certain period of time.
+ It has an start time, and a finish time. The finish time is the parameter
+ duration plus the start time.

+ +

These CCActionInterval actions have some interesting properties, like:
+ - They can run normally (default)
+ - They can run reversed with the reverse method
+ - They can run with the time altered with the Accelerate, AccelDeccel and Speed actions.

+ +

For example, you can simulate a Ping Pong effect running the action normally and
+ then running it again in Reverse mode.

+ !#zh 时间间隔动作,这种动作在已定时间内完成,继承 FiniteTimeAction。 */ + export class ActionInterval extends FiniteTimeAction { + /** + !#en Implementation of ease motion. + !#zh 缓动运动。 + @param easeObj easeObj + + @example + ```js + action.easing(cc.easeIn(3.0)); + ``` + */ + easing(easeObj: any): ActionInterval; + /** + !#en + Repeats an action a number of times. + To repeat an action forever use the CCRepeatForever action. + !#zh 重复动作可以按一定次数重复一个动作,使用 RepeatForever 动作来永远重复一个动作。 + @param times times + */ + repeat(times: number): ActionInterval; + /** + !#en + Repeats an action for ever.
+ To repeat the an action for a limited number of times use the Repeat action.
+ !#zh 永远地重复一个动作,有限次数内重复一个动作请使用 Repeat 动作。 + */ + repeatForever(): ActionInterval; + } + /** !#en + cc.ActionManager is a class that can manage actions.
+ Normally you won't need to use this class directly. 99% of the cases you will use the CCNode interface, + which uses this class's singleton object. + But there are some cases where you might need to use this class.
+ Examples:
+ - When you want to run an action where the target is different from a CCNode.
+ - When you want to pause / resume the actions
+ !#zh + cc.ActionManager 是可以管理动作的单例类。
+ 通常你并不需要直接使用这个类,99%的情况您将使用 CCNode 的接口。
+ 但也有一些情况下,您可能需要使用这个类。
+ 例如: + - 当你想要运行一个动作,但目标不是 CCNode 类型时。
+ - 当你想要暂停/恢复动作时。
*/ + export class ActionManager { + /** + !#en + Adds an action with a target.
+ If the target is already present, then the action will be added to the existing target. + If the target is not present, a new instance of this target will be created either paused or not, and the action will be added to the newly created target. + When the target is paused, the queued actions won't be 'ticked'. + !#zh + 增加一个动作,同时还需要提供动作的目标对象,目标对象是否暂停作为参数。
+ 如果目标已存在,动作将会被直接添加到现有的节点中。
+ 如果目标不存在,将为这一目标创建一个新的实例,并将动作添加进去。
+ 当目标状态的 paused 为 true,动作将不会被执行 + @param action action + @param target target + @param paused paused + */ + addAction(action: Action, target: Node, paused: boolean): void; + /** + !#en Removes all actions from all the targets. + !#zh 移除所有对象的所有动作。 + */ + removeAllActions(): void; + /** + !#en + Removes all actions from a certain target.
+ All the actions that belongs to the target will be removed. + !#zh + 移除指定对象上的所有动作。
+ 属于该目标的所有的动作将被删除。 + @param target target + @param forceDelete forceDelete + */ + removeAllActionsFromTarget(target: Node, forceDelete: boolean): void; + /** + !#en Removes an action given an action reference. + !#zh 移除指定的动作。 + @param action action + */ + removeAction(action: Action): void; + /** + !#en Removes an action given its tag and the target. + !#zh 删除指定对象下特定标签的一个动作,将删除首个匹配到的动作。 + @param tag tag + @param target target + */ + removeActionByTag(tag: number, target?: Node): void; + /** + !#en Gets an action given its tag an a target. + !#zh 通过目标对象和标签获取一个动作。 + @param tag tag + @param target target + */ + getActionByTag(tag: number, target: Node): Action; + /** + !#en + Returns the numbers of actions that are running in a certain target.
+ Composable actions are counted as 1 action.
+ Example:
+ - If you are running 1 Sequence of 7 actions, it will return 1.
+ - If you are running 7 Sequences of 2 actions, it will return 7. + !#zh + 返回指定对象下所有正在运行的动作数量。
+ 组合动作被算作一个动作。
+ 例如:
+ - 如果您正在运行 7 个动作组成的序列动作(Sequence),这个函数将返回 1。
+ - 如果你正在运行 2 个序列动作(Sequence)和 5 个普通动作,这个函数将返回 7。
+ @param target target + */ + getNumberOfRunningActionsInTarget(target: Node): number; + /** + !#en Pauses the target: all running actions and newly added actions will be paused. + !#zh 暂停指定对象:所有正在运行的动作和新添加的动作都将会暂停。 + @param target target + */ + pauseTarget(target: Node): void; + /** + !#en Resumes the target. All queued actions will be resumed. + !#zh 让指定目标恢复运行。在执行序列中所有被暂停的动作将重新恢复运行。 + @param target target + */ + resumeTarget(target: Node): void; + /** + !#en Pauses all running actions, returning a list of targets whose actions were paused. + !#zh 暂停所有正在运行的动作,返回一个包含了那些动作被暂停了的目标对象的列表。 + */ + pauseAllRunningActions(): any[]; + /** + !#en Resume a set of targets (convenience function to reverse a pauseAllRunningActions or pauseTargets call). + !#zh 让一组指定对象恢复运行(用来逆转 pauseAllRunningActions 效果的便捷函数)。 + @param targetsToResume targetsToResume + */ + resumeTargets(targetsToResume: any[]): void; + /** + !#en Pause a set of targets. + !#zh 暂停一组指定对象。 + @param targetsToPause targetsToPause + */ + pauseTargets(targetsToPause: any[]): void; + /** + !#en + purges the shared action manager. It releases the retained instance.
+ because it uses this, so it can not be static. + !#zh + 清除共用的动作管理器。它释放了持有的实例。
+ 因为它使用 this,因此它不能是静态的。 + */ + purgeSharedManager(): void; + /** + !#en The ActionManager update。 + !#zh ActionManager 主循环。 + @param dt delta time in seconds + */ + update(dt: number): void; + } + /** !#en + Tween provide a simple and flexible way to create action. Tween's api is more flexible than `cc.Action`: + - Support creating an action sequence in chained api. + - Support animate any objects' any properties, not limited to node's properties. By contrast, `cc.Action` needs to create a new action class to support new node property. + - Support working with `cc.Action`. + - Support easing and progress function. + !#zh + Tween 提供了一个简单灵活的方法来创建 action。相对于 Cocos 传统的 `cc.Action`,`cc.Tween` 在创建动画上要灵活非常多: + - 支持以链式结构的方式创建一个动画序列。 + - 支持对任意对象的任意属性进行缓动,不再局限于节点上的属性,而 `cc.Action` 添加一个属性的支持时还需要添加一个新的 action 类型。 + - 支持与 `cc.Action` 混用。 + - 支持设置 {{#crossLink "Easing"}}{{/crossLink}} 或者 progress 函数。 */ + export class Tween { + /** + + @param target target + */ + constructor(target?: any); + /** + !#en Stop all tweens + !#zh 停止所有缓动 + */ + static stopAll(): void; + /** + !#en Stop all tweens by tag + !#zh 停止所有指定标签的缓动 + @param tag tag + */ + static stopAllByTag(tag: number): void; + /** + !#en Stop all tweens by target + !#zh 停止所有指定对象的缓动 + @param target target + */ + static stopAllByTarget(target: any): void; + /** + !#en + Insert an action or tween to this sequence + !#zh + 插入一个 action 或者 tween 到队列中 + @param other other + */ + then(other: Action|Tween): Tween; + /** + !#en + Set tween target + !#zh + 设置 tween 的 target + @param target target + */ + target(target: any): Tween; + /** + !#en + Start this tween + !#zh + 运行当前 tween + */ + start(): Tween; + /** + !#en + Stop this tween + !#zh + 停止当前 tween + */ + stop(): Tween; + /** + !#en Sets tween tag + !#zh 设置缓动的标签 + @param tag tag + */ + tag(tag: number): Tween; + /** + !#en + Clone a tween + !#zh + 克隆当前 tween + @param target target + */ + clone(target?: any): Tween; + /** + !#en + Integrate all previous actions to an action. + !#zh + 将之前所有的 action 整合为一个 action。 + */ + union(): Tween; + /** + !#en Sets target's position property according to the bezier curve. + !#zh 按照贝塞尔路径设置目标的 position 属性。 + @param duration duration + @param c1 c1 + @param c2 c2 + @param to to + */ + bezierTo(duration: number, c1: Vec2, c2: Vec2, to: Vec2): Tween; + /** + !#en Sets target's position property according to the bezier curve. + !#zh 按照贝塞尔路径设置目标的 position 属性。 + @param duration duration + @param c1 c1 + @param c2 c2 + @param to to + */ + bezierBy(duration: number, c1: Vec2, c2: Vec2, to: Vec2): Tween; + /** + !#en Flips target's scaleX + !#zh 翻转目标的 scaleX 属性 + */ + flipX(): Tween; + /** + !#en Flips target's scaleY + !#zh 翻转目标的 scaleY 属性 + */ + flipY(): Tween; + /** + !#en Blinks target by set target's opacity property + !#zh 通过设置目标的 opacity 属性达到闪烁效果 + @param duration duration + @param times times + @param opts opts + */ + blink(duration: number, times: number, opts?: {progress?: Function; easing?: Function|string; }): Tween; + /** + !#en + Add an action which calculate with absolute value + !#zh + 添加一个对属性进行绝对值计算的 action + @param duration duration + @param props {scale: 2, position: cc.v3(100, 100, 100)} + @param opts opts + */ + to > (duration: number, props: ConstructorType, opts?: OPTS) : Tween; + /** + !#en + Add an action which calculate with relative value + !#zh + 添加一个对属性进行相对值计算的 action + @param duration duration + @param props {scale: 2, position: cc.v3(100, 100, 100)} + @param opts opts + */ + by > (duration: number, props: ConstructorType, opts?: OPTS) : Tween; + /** + !#en + Directly set target properties + !#zh + 直接设置 target 的属性 + @param props props + */ + set (props: ConstructorType) : Tween; + /** + !#en + Add an delay action + !#zh + 添加一个延时 action + @param duration duration + */ + delay(duration: number): Tween; + /** + !#en + Add an callback action + !#zh + 添加一个回调 action + @param callback callback + */ + call(callback: Function): Tween; + /** + !#en + Add an hide action + !#zh + 添加一个隐藏 action + */ + hide(): Tween; + /** + !#en + Add an show action + !#zh + 添加一个显示 action + */ + show(): Tween; + /** + !#en + Add an removeSelf action + !#zh + 添加一个移除自己 action + */ + removeSelf(): Tween; + /** + !#en + Add an sequence action + !#zh + 添加一个队列 action + @param action action + @param actions actions + */ + sequence(action: Action|Tween, ...actions: (Action|Tween)[]): Tween; + /** + !#en + Add an parallel action + !#zh + 添加一个并行 action + @param action action + @param actions actions + */ + parallel(action: Action|Tween, ...actions: (Action|Tween)[]): Tween; + /** + !#en + Add an repeat action. This action will integrate before actions to a sequence action as their parameters. + !#zh + 添加一个重复 action,这个 action 会将前一个动作作为他的参数。 + @param repeatTimes repeatTimes + @param action action + */ + repeat(repeatTimes: number, action?: Action|Tween): Tween; + /** + !#en + Add an repeat forever action. This action will integrate before actions to a sequence action as their parameters. + !#zh + 添加一个永久重复 action,这个 action 会将前一个动作作为他的参数。 + @param action action + */ + repeatForever(action?: Action|Tween): Tween; + /** + !#en + Add an reverse time action. This action will integrate before actions to a sequence action as their parameters. + !#zh + 添加一个倒置时间 action,这个 action 会将前一个动作作为他的参数。 + @param action action + */ + reverseTime(action?: Action|Tween): Tween; + } + /** !#en Class for animation data handling. + !#zh 动画剪辑,用于存储动画数据。 */ + export class AnimationClip extends Asset { + /** !#en Duration of this animation. + !#zh 动画的持续时间。 */ + duration: number; + /** !#en FrameRate of this animation. + !#zh 动画的帧速率。 */ + sample: number; + /** !#en Speed of this animation. + !#zh 动画的播放速度。 */ + speed: number; + /** !#en WrapMode of this animation. + !#zh 动画的循环模式。 */ + wrapMode: WrapMode; + /** !#en Curve data. + !#zh 曲线数据。 */ + curveData: any; + /** !#en Event data. + !#zh 事件数据。 */ + events: {frame: number, func: string, params: string[]}[]; + /** + !#en Crate clip with a set of sprite frames + !#zh 使用一组序列帧图片来创建动画剪辑 + @param spriteFrames spriteFrames + @param sample sample + + @example + ```js + var clip = cc.AnimationClip.createWithSpriteFrames(spriteFrames, 10); + ``` + */ + static createWithSpriteFrames(spriteFrames: SpriteFrame[], sample: number): AnimationClip; + } + /** !#en + The AnimationState gives full control over animation playback process. + In most cases the Animation Component is sufficient and easier to use. Use the AnimationState if you need full control. + !#zh + AnimationState 完全控制动画播放过程。
+ 大多数情况下 动画组件 是足够和易于使用的。如果您需要更多的动画控制接口,请使用 AnimationState。 */ + export class AnimationState extends Playable { + /** + + @param clip clip + @param name name + */ + constructor(clip: AnimationClip, name?: string); + /** !#en The curves list. + !#zh 曲线列表。 */ + curves: any[]; + /** !#en The start delay which represents the number of seconds from an animation's start time to the start of + the active interval. + !#zh 延迟多少秒播放。 */ + delay: number; + /** !#en The animation's iteration count property. + + A real number greater than or equal to zero (including positive infinity) representing the number of times + to repeat the animation node. + + Values less than zero and NaN values are treated as the value 1.0 for the purpose of timing model + calculations. + + !#zh 迭代次数,指动画播放多少次后结束, normalize time。 如 2.5(2次半) */ + repeatCount: number; + /** !#en The iteration duration of this animation in seconds. (length) + !#zh 单次动画的持续时间,秒。 */ + duration: number; + /** !#en The animation's playback speed. 1 is normal playback speed. + !#zh 播放速率。 */ + speed: number; + /** !#en + Wrapping mode of the playing animation. + Notice : dynamic change wrapMode will reset time and repeatCount property + !#zh + 动画循环方式。 + 需要注意的是,动态修改 wrapMode 时,会重置 time 以及 repeatCount */ + wrapMode: WrapMode; + /** !#en The current time of this animation in seconds. + !#zh 动画当前的时间,秒。 */ + time: number; + /** !#en The clip that is being played by this animation state. + !#zh 此动画状态正在播放的剪辑。 */ + clip: AnimationClip; + /** !#en The name of the playing animation. + !#zh 动画的名字 */ + name: string; + } + /** !#en + This class provide easing methods for {{#crossLink "tween"}}{{/crossLink}} class.
+ Demonstratio: https://easings.net/ + !#zh + 缓动函数类,为 {{#crossLink "Tween"}}{{/crossLink}} 提供缓动效果函数。
+ 函数效果演示: https://easings.net/ */ + export class Easing { + /** + !#en Easing in with quadratic formula. From slow to fast. + !#zh 平方曲线缓入函数。运动由慢到快。 + @param t The current time as a percentage of the total time. + */ + quadIn(t: number): number; + /** + !#en Easing out with quadratic formula. From fast to slow. + !#zh 平方曲线缓出函数。运动由快到慢。 + @param t The current time as a percentage of the total time. + */ + quadOut(t: number): number; + /** + !#en Easing in and out with quadratic formula. From slow to fast, then back to slow. + !#zh 平方曲线缓入缓出函数。运动由慢到快再到慢。 + @param t The current time as a percentage of the total time. + */ + quadInOut(t: number): number; + /** + !#en Easing in with cubic formula. From slow to fast. + !#zh 立方曲线缓入函数。运动由慢到快。 + @param t The current time as a percentage of the total time. + */ + cubicIn(t: number): number; + /** + !#en Easing out with cubic formula. From slow to fast. + !#zh 立方曲线缓出函数。运动由快到慢。 + @param t The current time as a percentage of the total time. + */ + cubicOut(t: number): number; + /** + !#en Easing in and out with cubic formula. From slow to fast, then back to slow. + !#zh 立方曲线缓入缓出函数。运动由慢到快再到慢。 + @param t The current time as a percentage of the total time. + */ + cubicInOut(t: number): number; + /** + !#en Easing in with quartic formula. From slow to fast. + !#zh 四次方曲线缓入函数。运动由慢到快。 + @param t The current time as a percentage of the total time. + */ + quartIn(t: number): number; + /** + !#en Easing out with quartic formula. From fast to slow. + !#zh 四次方曲线缓出函数。运动由快到慢。 + @param t The current time as a percentage of the total time. + */ + quartOut(t: number): number; + /** + !#en Easing in and out with quartic formula. From slow to fast, then back to slow. + !#zh 四次方曲线缓入缓出函数。运动由慢到快再到慢。 + @param t The current time as a percentage of the total time. + */ + quartInOut(t: number): number; + /** + !#en Easing in with quintic formula. From slow to fast. + !#zh 五次方曲线缓入函数。运动由慢到快。 + @param t The current time as a percentage of the total time. + */ + quintIn(t: number): number; + /** + !#en Easing out with quintic formula. From fast to slow. + !#zh 五次方曲线缓出函数。运动由快到慢。 + @param t The current time as a percentage of the total time. + */ + quintOut(t: number): number; + /** + !#en Easing in and out with quintic formula. From slow to fast, then back to slow. + !#zh 五次方曲线缓入缓出函数。运动由慢到快再到慢。 + @param t The current time as a percentage of the total time. + */ + quintInOut(t: number): number; + /** + !#en Easing in and out with sine formula. From slow to fast. + !#zh 正弦曲线缓入函数。运动由慢到快。 + @param t The current time as a percentage of the total time. + */ + sineIn(t: number): number; + /** + !#en Easing in and out with sine formula. From fast to slow. + !#zh 正弦曲线缓出函数。运动由快到慢。 + @param t The current time as a percentage of the total time. + */ + sineOut(t: number): number; + /** + !#en Easing in and out with sine formula. From slow to fast, then back to slow. + !#zh 正弦曲线缓入缓出函数。运动由慢到快再到慢。 + @param t The current time as a percentage of the total time. + */ + sineInOut(t: number): number; + /** + !#en Easing in and out with exponential formula. From slow to fast. + !#zh 指数曲线缓入函数。运动由慢到快。 + @param t The current time as a percentage of the total time. + */ + expoIn(t: number): number; + /** + !#en Easing in and out with exponential formula. From fast to slow. + !#zh 指数曲线缓出函数。运动由快到慢。 + @param t The current time as a percentage of the total time. + */ + expoOut(t: number): number; + /** + !#en Easing in and out with exponential formula. From slow to fast. + !#zh 指数曲线缓入和缓出函数。运动由慢到很快再到慢。 + @param t The current time as a percentage of the total time, then back to slow. + */ + expoInOut(t: number): number; + /** + !#en Easing in and out with circular formula. From slow to fast. + !#zh 循环公式缓入函数。运动由慢到快。 + @param t The current time as a percentage of the total time. + */ + circIn(t: number): number; + /** + !#en Easing in and out with circular formula. From fast to slow. + !#zh 循环公式缓出函数。运动由快到慢。 + @param t The current time as a percentage of the total time. + */ + circOut(t: number): number; + /** + !#en Easing in and out with circular formula. From slow to fast. + !#zh 指数曲线缓入缓出函数。运动由慢到很快再到慢。 + @param t The current time as a percentage of the total time, then back to slow. + */ + circInOut(t: number): number; + /** + !#en Easing in action with a spring oscillating effect. + !#zh 弹簧回震效果的缓入函数。 + @param t The current time as a percentage of the total time. + */ + elasticIn(t: number): number; + /** + !#en Easing out action with a spring oscillating effect. + !#zh 弹簧回震效果的缓出函数。 + @param t The current time as a percentage of the total time. + */ + elasticOut(t: number): number; + /** + !#en Easing in and out action with a spring oscillating effect. + !#zh 弹簧回震效果的缓入缓出函数。 + @param t The current time as a percentage of the total time. + */ + elasticInOut(t: number): number; + /** + !#en Easing in action with "back up" behavior. + !#zh 回退效果的缓入函数。 + @param t The current time as a percentage of the total time. + */ + backIn(t: number): number; + /** + !#en Easing out action with "back up" behavior. + !#zh 回退效果的缓出函数。 + @param t The current time as a percentage of the total time. + */ + backOut(t: number): number; + /** + !#en Easing in and out action with "back up" behavior. + !#zh 回退效果的缓入缓出函数。 + @param t The current time as a percentage of the total time. + */ + backInOut(t: number): number; + /** + !#en Easing in action with bouncing effect. + !#zh 弹跳效果的缓入函数。 + @param t The current time as a percentage of the total time. + */ + bounceIn(t: number): number; + /** + !#en Easing out action with bouncing effect. + !#zh 弹跳效果的缓出函数。 + @param t The current time as a percentage of the total time. + */ + bounceOut(t: number): number; + /** + !#en Easing in and out action with bouncing effect. + !#zh 弹跳效果的缓入缓出函数。 + @param t The current time as a percentage of the total time. + */ + bounceInOut(t: number): number; + /** + !#en Target will run action with smooth effect. + !#zh 平滑效果函数。 + @param t The current time as a percentage of the total time. + */ + smooth(t: number): number; + /** + !#en Target will run action with fade effect. + !#zh 渐褪效果函数。 + @param t The current time as a percentage of the total time. + */ + fade(t: number): number; + } + /** undefined */ + export class Playable { + /** !#en Is playing or paused in play mode? + !#zh 当前是否正在播放。 */ + isPlaying: boolean; + /** !#en Is currently paused? This can be true even if in edit mode(isPlaying == false). + !#zh 当前是否正在暂停 */ + isPaused: boolean; + /** + !#en Play this animation. + !#zh 播放动画。 + */ + play(): void; + /** + !#en Stop this animation. + !#zh 停止动画播放。 + */ + stop(): void; + /** + !#en Pause this animation. + !#zh 暂停动画。 + */ + pause(): void; + /** + !#en Resume this animation. + !#zh 重新播放动画。 + */ + resume(): void; + /** + !#en Perform a single frame step. + !#zh 执行一帧动画。 + */ + step(): void; + } + /** !#en Specifies how time is treated when it is outside of the keyframe range of an Animation. + !#zh 动画使用的循环模式。 */ + export enum WrapMode { + Default = 0, + Normal = 0, + Reverse = 0, + Loop = 0, + LoopReverse = 0, + PingPong = 0, + PingPongReverse = 0, + } + /** !#en `cc.audioEngine` is the singleton object, it provide simple audio APIs. + !#zh + cc.audioengine是单例对象。
+ 主要用来播放音频,播放的时候会返回一个 audioID,之后都可以通过这个 audioID 来操作这个音频对象。
+ 不使用的时候,请使用 `cc.audioEngine.uncache(filePath);` 进行资源释放
+ 注意:
+ 在 Android 系统浏览器上,不同浏览器,不同版本的效果不尽相同。
+ 比如说:大多数浏览器都需要用户物理交互才可以开始播放音效,有一些不支持 WebAudio,有一些不支持多音轨播放。总之如果对音乐依赖比较强,请做尽可能多的测试。 */ + export class audioEngine { + /** + !#en Play audio. + !#zh 播放音频 + @param clip The audio clip to play. + @param loop Whether the music loop or not. + @param volume Volume size. + + @example + ```js + cc.resources.load(path, cc.AudioClip, null, function (err, clip) { + var audioID = cc.audioEngine.play(clip, false, 0.5); + }); + ``` + */ + static play(clip: AudioClip, loop: boolean, volume: number): number; + /** + !#en Set audio loop. + !#zh 设置音频是否循环。 + @param audioID audio id. + @param loop Whether cycle. + + @example + ```js + cc.audioEngine.setLoop(id, true); + ``` + */ + static setLoop(audioID: number, loop: boolean): void; + /** + !#en Get audio cycle state. + !#zh 获取音频的循环状态。 + @param audioID audio id. + + @example + ```js + cc.audioEngine.isLoop(id); + ``` + */ + static isLoop(audioID: number): boolean; + /** + !#en Set the volume of audio. + !#zh 设置音量(0.0 ~ 1.0)。 + @param audioID audio id. + @param volume Volume must be in 0.0~1.0 . + + @example + ```js + cc.audioEngine.setVolume(id, 0.5); + ``` + */ + static setVolume(audioID: number, volume: number): void; + /** + !#en The volume of the music max value is 1.0,the min value is 0.0 . + !#zh 获取音量(0.0 ~ 1.0)。 + @param audioID audio id. + + @example + ```js + var volume = cc.audioEngine.getVolume(id); + ``` + */ + static getVolume(audioID: number): number; + /** + !#en Set current time + !#zh 设置当前的音频时间。 + @param audioID audio id. + @param sec current time. + + @example + ```js + cc.audioEngine.setCurrentTime(id, 2); + ``` + */ + static setCurrentTime(audioID: number, sec: number): boolean; + /** + !#en Get current time + !#zh 获取当前的音频播放时间。 + @param audioID audio id. + + @example + ```js + var time = cc.audioEngine.getCurrentTime(id); + ``` + */ + static getCurrentTime(audioID: number): number; + /** + !#en Get audio duration + !#zh 获取音频总时长。 + @param audioID audio id. + + @example + ```js + var time = cc.audioEngine.getDuration(id); + ``` + */ + static getDuration(audioID: number): number; + /** + !#en Get audio state + !#zh 获取音频状态。 + @param audioID audio id. + + @example + ```js + var state = cc.audioEngine.getState(id); + ``` + */ + static getState(audioID: number): audioEngine.AudioState; + /** + !#en Set Audio finish callback + !#zh 设置一个音频结束后的回调 + @param audioID audio id. + @param callback loaded callback. + + @example + ```js + cc.audioEngine.setFinishCallback(id, function () {}); + ``` + */ + static setFinishCallback(audioID: number, callback: Function): void; + /** + !#en Pause playing audio. + !#zh 暂停正在播放音频。 + @param audioID The return value of function play. + + @example + ```js + cc.audioEngine.pause(audioID); + ``` + */ + static pause(audioID: number): void; + /** + !#en Pause all playing audio + !#zh 暂停现在正在播放的所有音频。 + + @example + ```js + cc.audioEngine.pauseAll(); + ``` + */ + static pauseAll(): void; + /** + !#en Resume playing audio. + !#zh 恢复播放指定的音频。 + @param audioID The return value of function play. + + @example + ```js + cc.audioEngine.resume(audioID); + ``` + */ + static resume(audioID: number): void; + /** + !#en Resume all playing audio. + !#zh 恢复播放所有之前暂停的所有音频。 + + @example + ```js + cc.audioEngine.resumeAll(); + ``` + */ + static resumeAll(): void; + /** + !#en Stop playing audio. + !#zh 停止播放指定音频。 + @param audioID The return value of function play. + + @example + ```js + cc.audioEngine.stop(audioID); + ``` + */ + static stop(audioID: number): void; + /** + !#en Stop all playing audio. + !#zh 停止正在播放的所有音频。 + + @example + ```js + cc.audioEngine.stopAll(); + ``` + */ + static stopAll(): void; + /** + !#en Set up an audio can generate a few examples. + !#zh 设置一个音频可以设置几个实例 + @param num a number of instances to be created from within an audio + + @example + ```js + cc.audioEngine.setMaxAudioInstance(20); + ``` + */ + static setMaxAudioInstance(num: number): void; + /** + !#en Getting audio can produce several examples. + !#zh 获取一个音频可以设置几个实例 + + @example + ```js + cc.audioEngine.getMaxAudioInstance(); + ``` + */ + static getMaxAudioInstance(): number; + /** + !#en Unload the preloaded audio from internal buffer. + !#zh 卸载预加载的音频。 + @param clip clip + + @example + ```js + cc.audioEngine.uncache(filePath); + ``` + */ + static uncache(clip: AudioClip): void; + /** + !#en Unload all audio from internal buffer. + !#zh 卸载所有音频。 + + @example + ```js + cc.audioEngine.uncacheAll(); + ``` + */ + static uncacheAll(): void; + /** + !#en Play background music + !#zh 播放背景音乐 + @param clip The audio clip to play. + @param loop Whether the music loop or not. + + @example + ```js + cc.resources.load(path, cc.AudioClip, null, function (err, clip) { + var audioID = cc.audioEngine.playMusic(clip, false); + }); + ``` + */ + static playMusic(clip: AudioClip, loop: boolean): number; + /** + !#en Stop background music. + !#zh 停止播放背景音乐。 + + @example + ```js + cc.audioEngine.stopMusic(); + ``` + */ + static stopMusic(): void; + /** + !#en Pause the background music. + !#zh 暂停播放背景音乐。 + + @example + ```js + cc.audioEngine.pauseMusic(); + ``` + */ + static pauseMusic(): void; + /** + !#en Resume playing background music. + !#zh 恢复播放背景音乐。 + + @example + ```js + cc.audioEngine.resumeMusic(); + ``` + */ + static resumeMusic(): void; + /** + !#en Get the volume(0.0 ~ 1.0). + !#zh 获取音量(0.0 ~ 1.0)。 + + @example + ```js + var volume = cc.audioEngine.getMusicVolume(); + ``` + */ + static getMusicVolume(): number; + /** + !#en Set the background music volume. + !#zh 设置背景音乐音量(0.0 ~ 1.0)。 + @param volume Volume must be in 0.0~1.0. + + @example + ```js + cc.audioEngine.setMusicVolume(0.5); + ``` + */ + static setMusicVolume(volume: number): void; + /** + !#en Background music playing state + !#zh 背景音乐是否正在播放 + + @example + ```js + cc.audioEngine.isMusicPlaying(); + ``` + */ + static isMusicPlaying(): boolean; + /** + !#en Play effect audio. + !#zh 播放音效 + @param clip The audio clip to play. + @param loop Whether the music loop or not. + + @example + ```js + cc.resources.load(path, cc.AudioClip, null, function (err, clip) { + var audioID = cc.audioEngine.playEffect(clip, false); + }); + ``` + */ + static playEffect(clip: AudioClip, loop: boolean): number; + /** + !#en Set the volume of effect audio. + !#zh 设置音效音量(0.0 ~ 1.0)。 + @param volume Volume must be in 0.0~1.0. + + @example + ```js + cc.audioEngine.setEffectsVolume(0.5); + ``` + */ + static setEffectsVolume(volume: number): void; + /** + !#en The volume of the effect audio max value is 1.0,the min value is 0.0 . + !#zh 获取音效音量(0.0 ~ 1.0)。 + + @example + ```js + var volume = cc.audioEngine.getEffectsVolume(); + ``` + */ + static getEffectsVolume(): number; + /** + !#en Pause effect audio. + !#zh 暂停播放音效。 + @param audioID audio id. + + @example + ```js + cc.audioEngine.pauseEffect(audioID); + ``` + */ + static pauseEffect(audioID: number): void; + /** + !#en Stop playing all the sound effects. + !#zh 暂停播放所有音效。 + + @example + ```js + cc.audioEngine.pauseAllEffects(); + ``` + */ + static pauseAllEffects(): void; + /** + !#en Resume effect audio. + !#zh 恢复播放音效音频。 + @param audioID The return value of function play. + + @example + ```js + cc.audioEngine.resumeEffect(audioID); + ``` + */ + static resumeEffect(audioID: number): void; + /** + !#en Resume all effect audio. + !#zh 恢复播放所有之前暂停的音效。 + + @example + ```js + cc.audioEngine.resumeAllEffects(); + ``` + */ + static resumeAllEffects(): void; + /** + !#en Stop playing the effect audio. + !#zh 停止播放音效。 + @param audioID audio id. + + @example + ```js + cc.audioEngine.stopEffect(id); + ``` + */ + static stopEffect(audioID: number): void; + /** + !#en Stop playing all the effects. + !#zh 停止播放所有音效。 + + @example + ```js + cc.audioEngine.stopAllEffects(); + ``` + */ + static stopAllEffects(): void; + } + /** !#en An object to boot the game. + !#zh 包含游戏主体信息并负责驱动游戏的游戏对象。 */ + export class debug { + /** + !#en Gets error message with the error id and possible parameters. + !#zh 通过 error id 和必要的参数来获取错误信息。 + @param errorId errorId + @param param param + */ + static getError(errorId: string, param?: any): string; + /** + !#en Returns whether or not to display the FPS informations. + !#zh 是否显示 FPS 信息。 + */ + static isDisplayStats(): boolean; + /** + !#en Sets whether display the FPS on the bottom-left corner. + !#zh 设置是否在左下角显示 FPS。 + @param displayStats displayStats + */ + static setDisplayStats(displayStats: boolean): void; + } + /** !#en +

+ ATTENTION: USE cc.director INSTEAD OF cc.Director.
+ cc.director is a singleton object which manage your game's logic flow.
+ Since the cc.director is a singleton, you don't need to call any constructor or create functions,
+ the standard way to use it is by calling:
+ - cc.director.methodName();
+ + It creates and handle the main Window and manages how and when to execute the Scenes.
+
+ The cc.director is also responsible for:
+ - initializing the OpenGL context
+ - setting the OpenGL pixel format (default on is RGB565)
+ - setting the OpenGL buffer depth (default on is 0-bit)
+ - setting the color for clear screen (default one is BLACK)
+ - setting the projection (default one is 3D)
+ - setting the orientation (default one is Portrait)
+
+
+ The cc.director also sets the default OpenGL context:
+ - GL_TEXTURE_2D is enabled
+ - GL_VERTEX_ARRAY is enabled
+ - GL_COLOR_ARRAY is enabled
+ - GL_TEXTURE_COORD_ARRAY is enabled
+

+

+ cc.director also synchronizes timers with the refresh rate of the display.
+ Features and Limitations:
+ - Scheduled timers & drawing are synchronizes with the refresh rate of the display
+ - Only supports animation intervals of 1/60 1/30 & 1/15
+

+ + !#zh +

+ 注意:用 cc.director 代替 cc.Director。
+ cc.director 一个管理你的游戏的逻辑流程的单例对象。
+ 由于 cc.director 是一个单例,你不需要调用任何构造函数或创建函数,
+ 使用它的标准方法是通过调用:
+ - cc.director.methodName(); +
+ 它创建和处理主窗口并且管理什么时候执行场景。
+
+ cc.director 还负责:
+ - 初始化 OpenGL 环境。
+ - 设置OpenGL像素格式。(默认是 RGB565)
+ - 设置OpenGL缓冲区深度 (默认是 0-bit)
+ - 设置空白场景的颜色 (默认是 黑色)
+ - 设置投影 (默认是 3D)
+ - 设置方向 (默认是 Portrait)
+
+ cc.director 设置了 OpenGL 默认环境
+ - GL_TEXTURE_2D 启用。
+ - GL_VERTEX_ARRAY 启用。
+ - GL_COLOR_ARRAY 启用。
+ - GL_TEXTURE_COORD_ARRAY 启用。
+

+

+ cc.director 也同步定时器与显示器的刷新速率。 +
+ 特点和局限性:
+ - 将计时器 & 渲染与显示器的刷新频率同步。
+ - 只支持动画的间隔 1/60 1/30 & 1/15。
+

*/ + export class Director extends EventTarget { + /** + !#en + Converts a view coordinate to an WebGL coordinate
+ Useful to convert (multi) touches coordinates to the current layout (portrait or landscape)
+ Implementation can be found in CCDirectorWebGL. + !#zh 将触摸点的屏幕坐标转换为 WebGL View 下的坐标。 + @param uiPoint uiPoint + */ + convertToGL(uiPoint: Vec2): Vec2; + /** + !#en + Converts an OpenGL coordinate to a view coordinate
+ Useful to convert node points to window points for calls such as glScissor
+ Implementation can be found in CCDirectorWebGL. + !#zh 将触摸点的 WebGL View 坐标转换为屏幕坐标。 + @param glPoint glPoint + */ + convertToUI(glPoint: Vec2): Vec2; + /** + End the life of director in the next frame + */ + end(): void; + /** + !#en + Returns the size of the WebGL view in points.
+ It takes into account any possible rotation (device orientation) of the window. + !#zh 获取视图的大小,以点为单位。 + */ + getWinSize(): Size; + /** + !#en + Returns the size of the OpenGL view in pixels.
+ It takes into account any possible rotation (device orientation) of the window.
+ On Mac winSize and winSizeInPixels return the same value. + (The pixel here refers to the resource resolution. If you want to get the physics resolution of device, you need to use cc.view.getFrameSize()) + !#zh + 获取视图大小,以像素为单位(这里的像素指的是资源分辨率。 + 如果要获取屏幕物理分辨率,需要用 cc.view.getFrameSize()) + */ + getWinSizeInPixels(): Size; + /** + !#en Pause the director's ticker, only involve the game logic execution. + It won't pause the rendering process nor the event manager. + If you want to pause the entier game including rendering, audio and event, + please use {{#crossLink "Game.pause"}}cc.game.pause{{/crossLink}} + !#zh 暂停正在运行的场景,该暂停只会停止游戏逻辑执行,但是不会停止渲染和 UI 响应。 + 如果想要更彻底得暂停游戏,包含渲染,音频和事件,请使用 {{#crossLink "Game.pause"}}cc.game.pause{{/crossLink}}。 + */ + pause(): void; + /** + !#en + Run a scene. Replaces the running scene with a new one or enter the first scene.
+ The new scene will be launched immediately. + !#zh 立刻切换指定场景。 + @param scene The need run scene. + @param onBeforeLoadScene The function invoked at the scene before loading. + @param onLaunched The function invoked at the scene after launch. + */ + runSceneImmediate(scene: Scene|SceneAsset, onBeforeLoadScene?: Function, onLaunched?: Function): void; + /** + !#en + Run a scene. Replaces the running scene with a new one or enter the first scene. + The new scene will be launched at the end of the current frame. + !#zh 运行指定场景。 + @param scene The need run scene. + @param onBeforeLoadScene The function invoked at the scene before loading. + @param onLaunched The function invoked at the scene after launch. + */ + runScene(scene: Scene|SceneAsset, onBeforeLoadScene?: Function, onLaunched?: Function): void; + /** + !#en Loads the scene by its name. + !#zh 通过场景名称进行加载场景。 + @param sceneName The name of the scene to load. + @param onLaunched callback, will be called after scene launched. + */ + loadScene(sceneName: string, onLaunched?: Function): boolean; + /** + !#en + Preloads the scene to reduces loading time. You can call this method at any time you want. + After calling this method, you still need to launch the scene by `cc.director.loadScene`. + It will be totally fine to call `cc.director.loadScene` at any time even if the preloading is not + yet finished, the scene will be launched after loaded automatically. + !#zh 预加载场景,你可以在任何时候调用这个方法。 + 调用完后,你仍然需要通过 `cc.director.loadScene` 来启动场景,因为这个方法不会执行场景加载操作。 + 就算预加载还没完成,你也可以直接调用 `cc.director.loadScene`,加载完成后场景就会启动。 + @param sceneName The name of the scene to preload. + @param onProgress callback, will be called when the load progression change. + @param onLoaded callback, will be called after scene loaded. + */ + preloadScene(sceneName: string, onProgress?: (completedCount: number, totalCount: number, item: any) => void, onLoaded?: (error: Error) => void): void; + /** + !#en Resume game logic execution after pause, if the current scene is not paused, nothing will happen. + !#zh 恢复暂停场景的游戏逻辑,如果当前场景没有暂停将没任何事情发生。 + */ + resume(): void; + /** + !#en + Enables or disables WebGL depth test.
+ Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js + !#zh 启用/禁用深度测试(在 Canvas 渲染模式下不会生效)。 + @param on on + */ + setDepthTest(on: boolean): void; + /** + !#en + Set color for clear screen.
+ (Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js) + !#zh + 设置场景的默认擦除颜色。
+ 支持全透明,但不支持透明度为中间值。要支持全透明需手工开启 cc.macro.ENABLE_TRANSPARENT_CANVAS。 + @param clearColor clearColor + */ + setClearColor(clearColor: Color): void; + /** + !#en Returns current logic Scene. + !#zh 获取当前逻辑场景。 + + @example + ```js + // This will help you to get the Canvas node in scene + cc.director.getScene().getChildByName('Canvas'); + ``` + */ + getScene(): Scene; + /** + !#en Returns the FPS value. Please use {{#crossLink "Game.setFrameRate"}}cc.game.setFrameRate{{/crossLink}} to control animation interval. + !#zh 获取单位帧执行时间。请使用 {{#crossLink "Game.setFrameRate"}}cc.game.setFrameRate{{/crossLink}} 来控制游戏帧率。 + */ + getAnimationInterval(): number; + /** + Sets animation interval, this doesn't control the main loop. + To control the game's frame rate overall, please use {{#crossLink "Game.setFrameRate"}}cc.game.setFrameRate{{/crossLink}} + @param value The animation interval desired. + */ + setAnimationInterval(value: number): void; + /** + !#en Returns the delta time since last frame. + !#zh 获取上一帧的增量时间。 + */ + getDeltaTime(): number; + /** + !#en Returns the total passed time since game start, unit: ms + !#zh 获取从游戏开始到现在总共经过的时间,单位为 ms + */ + getTotalTime(): number; + /** + !#en Returns how many frames were called since the director started. + !#zh 获取 director 启动以来游戏运行的总帧数。 + */ + getTotalFrames(): number; + /** + !#en Returns whether or not the Director is paused. + !#zh 是否处于暂停状态。 + */ + isPaused(): boolean; + /** + !#en Returns the cc.Scheduler associated with this director. + !#zh 获取和 director 相关联的 cc.Scheduler。 + */ + getScheduler(): Scheduler; + /** + !#en Sets the cc.Scheduler associated with this director. + !#zh 设置和 director 相关联的 cc.Scheduler。 + @param scheduler scheduler + */ + setScheduler(scheduler: Scheduler): void; + /** + !#en Returns the cc.ActionManager associated with this director. + !#zh 获取和 director 相关联的 cc.ActionManager(动作管理器)。 + */ + getActionManager(): ActionManager; + /** + !#en Sets the cc.ActionManager associated with this director. + !#zh 设置和 director 相关联的 cc.ActionManager(动作管理器)。 + @param actionManager actionManager + */ + setActionManager(actionManager: ActionManager): void; + /** + !#en Returns the cc.CollisionManager associated with this director. + !#zh 获取和 director 相关联的 cc.CollisionManager (碰撞管理器)。 + */ + getCollisionManager(): CollisionManager; + /** + !#en Returns the cc.PhysicsManager associated with this director. + !#zh 返回与 director 相关联的 cc.PhysicsManager (物理管理器)。 + */ + getPhysicsManager(): PhysicsManager; + /** + !#en Returns the cc.Physics3DManager associated with this director. + !#zh 返回与 director 相关联的 cc.Physics3DManager (物理管理器)。 + */ + getPhysics3DManager(): Physics3DManager; + /** !#en The event projection changed of cc.Director. This event will not get triggered since v2.0 + !#zh cc.Director 投影变化的事件。从 v2.0 开始这个事件不会再被触发 */ + static EVENT_PROJECTION_CHANGED: string; + /** !#en The event which will be triggered before loading a new scene. + !#zh 加载新场景之前所触发的事件。 */ + static EVENT_BEFORE_SCENE_LOADING: string; + /** !#en The event which will be triggered before launching a new scene. + !#zh 运行新场景之前所触发的事件。 */ + static EVENT_BEFORE_SCENE_LAUNCH: string; + /** !#en The event which will be triggered after launching a new scene. + !#zh 运行新场景之后所触发的事件。 */ + static EVENT_AFTER_SCENE_LAUNCH: string; + /** !#en The event which will be triggered at the beginning of every frame. + !#zh 每个帧的开始时所触发的事件。 */ + static EVENT_BEFORE_UPDATE: string; + /** !#en The event which will be triggered after engine and components update logic. + !#zh 将在引擎和组件 “update” 逻辑之后所触发的事件。 */ + static EVENT_AFTER_UPDATE: string; + /** !#en The event is deprecated since v2.0, please use cc.Director.EVENT_BEFORE_DRAW instead + !#zh 这个事件从 v2.0 开始被废弃,请直接使用 cc.Director.EVENT_BEFORE_DRAW */ + static EVENT_BEFORE_VISIT: string; + /** !#en The event is deprecated since v2.0, please use cc.Director.EVENT_BEFORE_DRAW instead + !#zh 这个事件从 v2.0 开始被废弃,请直接使用 cc.Director.EVENT_BEFORE_DRAW */ + static EVENT_AFTER_VISIT: string; + /** !#en The event which will be triggered before the rendering process. + !#zh 渲染过程之前所触发的事件。 */ + static EVENT_BEFORE_DRAW: string; + /** !#en The event which will be triggered after the rendering process. + !#zh 渲染过程之后所触发的事件。 */ + static EVENT_AFTER_DRAW: string; + /** Constant for 2D projection (orthogonal projection) */ + static PROJECTION_2D: number; + /** Constant for 3D projection with a fovy=60, znear=0.5f and zfar=1500. */ + static PROJECTION_3D: number; + /** Constant for custom projection, if cc.Director's projection set to it, it calls "updateProjection" on the projection delegate. */ + static PROJECTION_CUSTOM: number; + /** Constant for default projection of cc.Director, default projection is 2D projection */ + static PROJECTION_DEFAULT: number; + } + /** !#en An object to boot the game. + !#zh 包含游戏主体信息并负责驱动游戏的游戏对象。 */ + export class Game extends EventTarget { + /** !#en Event triggered when game hide to background. + Please note that this event is not 100% guaranteed to be fired on Web platform, + on native platforms, it corresponds to enter background event, os status bar or notification center may not trigger this event. + !#zh 游戏进入后台时触发的事件。 + 请注意,在 WEB 平台,这个事件不一定会 100% 触发,这完全取决于浏览器的回调行为。 + 在原生平台,它对应的是应用被切换到后台事件,下拉菜单和上拉状态栏等不一定会触发这个事件,这取决于系统行为。 */ + EVENT_HIDE: string; + /** !#en Event triggered when game back to foreground + Please note that this event is not 100% guaranteed to be fired on Web platform, + on native platforms, it corresponds to enter foreground event. + !#zh 游戏进入前台运行时触发的事件。 + 请注意,在 WEB 平台,这个事件不一定会 100% 触发,这完全取决于浏览器的回调行为。 + 在原生平台,它对应的是应用被切换到前台事件。 */ + EVENT_SHOW: string; + /** !#en Event triggered when game restart + !#zh 调用restart后,触发事件。 */ + EVENT_RESTART: string; + /** Event triggered after game inited, at this point all engine objects and game scripts are loaded */ + EVENT_GAME_INITED: string; + /** Event triggered after engine inited, at this point you will be able to use all engine classes. + It was defined as EVENT_RENDERER_INITED in cocos creator v1.x and renamed in v2.0 */ + EVENT_ENGINE_INITED: string; + /** Web Canvas 2d API as renderer backend */ + RENDER_TYPE_CANVAS: number; + /** WebGL API as renderer backend */ + RENDER_TYPE_WEBGL: number; + /** OpenGL API as renderer backend */ + RENDER_TYPE_OPENGL: number; + /** !#en The outer frame of the game canvas, parent of game container. + !#zh 游戏画布的外框,container 的父容器。 */ + frame: any; + /** !#en The container of game canvas. + !#zh 游戏画布的容器。 */ + container: HTMLDivElement; + /** !#en The canvas of the game. + !#zh 游戏的画布。 */ + canvas: HTMLCanvasElement; + /** !#en The renderer backend of the game. + !#zh 游戏的渲染器类型。 */ + renderType: number; + /** !#en + The current game configuration, including:
+ 1. debugMode
+ "debugMode" possible values :
+ 0 - No message will be printed.
+ 1 - cc.error, cc.assert, cc.warn, cc.log will print in console.
+ 2 - cc.error, cc.assert, cc.warn will print in console.
+ 3 - cc.error, cc.assert will print in console.
+ 4 - cc.error, cc.assert, cc.warn, cc.log will print on canvas, available only on web.
+ 5 - cc.error, cc.assert, cc.warn will print on canvas, available only on web.
+ 6 - cc.error, cc.assert will print on canvas, available only on web.
+ 2. showFPS
+ Left bottom corner fps information will show when "showFPS" equals true, otherwise it will be hide.
+ 3. exposeClassName
+ Expose class name to chrome debug tools, the class intantiate performance is a little bit slower when exposed.
+ 4. frameRate
+ "frameRate" set the wanted frame rate for your game, but the real fps depends on your game implementation and the running environment.
+ 5. id
+ "gameCanvas" sets the id of your canvas element on the web page, it's useful only on web.
+ 6. renderMode
+ "renderMode" sets the renderer type, only useful on web :
+ 0 - Automatically chosen by engine
+ 1 - Forced to use canvas renderer
+ 2 - Forced to use WebGL renderer, but this will be ignored on mobile browsers
+
+ Please DO NOT modify this object directly, it won't have any effect.
+ !#zh + 当前的游戏配置,包括:
+ 1. debugMode(debug 模式,但是在浏览器中这个选项会被忽略)
+ "debugMode" 各种设置选项的意义。
+ 0 - 没有消息被打印出来。
+ 1 - cc.error,cc.assert,cc.warn,cc.log 将打印在 console 中。
+ 2 - cc.error,cc.assert,cc.warn 将打印在 console 中。
+ 3 - cc.error,cc.assert 将打印在 console 中。
+ 4 - cc.error,cc.assert,cc.warn,cc.log 将打印在 canvas 中(仅适用于 web 端)。
+ 5 - cc.error,cc.assert,cc.warn 将打印在 canvas 中(仅适用于 web 端)。
+ 6 - cc.error,cc.assert 将打印在 canvas 中(仅适用于 web 端)。
+ 2. showFPS(显示 FPS)
+ 当 showFPS 为 true 的时候界面的左下角将显示 fps 的信息,否则被隐藏。
+ 3. exposeClassName
+ 暴露类名让 Chrome DevTools 可以识别,如果开启会稍稍降低类的创建过程的性能,但对对象构造没有影响。
+ 4. frameRate (帧率)
+ “frameRate” 设置想要的帧率你的游戏,但真正的FPS取决于你的游戏实现和运行环境。
+ 5. id
+ "gameCanvas" Web 页面上的 Canvas Element ID,仅适用于 web 端。
+ 6. renderMode(渲染模式)
+ “renderMode” 设置渲染器类型,仅适用于 web 端:
+ 0 - 通过引擎自动选择。
+ 1 - 强制使用 canvas 渲染。 + 2 - 强制使用 WebGL 渲染,但是在部分 Android 浏览器中这个选项会被忽略。
+
+ 注意:请不要直接修改这个对象,它不会有任何效果。 */ + config: any; + /** + !#en Callback when the scripts of engine have been load. + !#zh 当引擎完成启动后的回调函数。 + */ + onStart(): void; + /** + !#en Set frame rate of game. + !#zh 设置游戏帧率。 + @param frameRate frameRate + */ + setFrameRate(frameRate: number): void; + /** + !#en Get frame rate set for the game, it doesn't represent the real frame rate. + !#zh 获取设置的游戏帧率(不等同于实际帧率)。 + */ + getFrameRate(): number; + /** + !#en Run the game frame by frame. + !#zh 执行一帧游戏循环。 + */ + step(): void; + /** + !#en Pause the game main loop. This will pause: + game logic execution, rendering process, event manager, background music and all audio effects. + This is different with cc.director.pause which only pause the game logic execution. + !#zh 暂停游戏主循环。包含:游戏逻辑,渲染,事件处理,背景音乐和所有音效。这点和只暂停游戏逻辑的 cc.director.pause 不同。 + */ + pause(): void; + /** + !#en Resume the game from pause. This will resume: + game logic execution, rendering process, event manager, background music and all audio effects. + !#zh 恢复游戏主循环。包含:游戏逻辑,渲染,事件处理,背景音乐和所有音效。 + */ + resume(): void; + /** + !#en Check whether the game is paused. + !#zh 判断游戏是否暂停。 + */ + isPaused(): boolean; + /** + !#en Restart game. + !#zh 重新开始游戏 + */ + restart(): void; + /** + !#en End game, it will close the game window + !#zh 退出游戏 + */ + end(): void; + /** + !#en + Register an callback of a specific event type on the game object. + This type of event should be triggered via `emit`. + !#zh + 注册 game 的特定事件类型回调。这种类型的事件应该被 `emit` 触发。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + */ + on(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Register an callback of a specific event type on the game object, + the callback will remove itself after the first time it is triggered. + !#zh + 注册 game 的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + */ + once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; + /** + !#en Prepare game. + !#zh 准备引擎,请不要直接调用这个函数。 + @param cb cb + */ + prepare(cb: Function): void; + /** + !#en Run game with configuration object and onStart function. + !#zh 运行游戏,并且指定引擎配置和 onStart 的回调。 + @param config Pass configuration object or onStart function + @param onStart function to be executed after game initialized + */ + run(config: any, onStart: Function): void; + /** + !#en + Add a persistent root node to the game, the persistent node won't be destroyed during scene transition.
+ The target node must be placed in the root level of hierarchy, otherwise this API won't have any effect. + !#zh + 声明常驻根节点,该节点不会被在场景切换中被销毁。
+ 目标节点必须位于为层级的根节点,否则无效。 + @param node The node to be made persistent + */ + addPersistRootNode(node: Node): void; + /** + !#en Remove a persistent root node. + !#zh 取消常驻根节点。 + @param node The node to be removed from persistent node list + */ + removePersistRootNode(node: Node): void; + /** + !#en Check whether the node is a persistent root node. + !#zh 检查节点是否是常驻根节点。 + @param node The node to be checked + */ + isPersistRootNode(node: Node): boolean; + } + /** !#en + Class of all entities in Cocos Creator scenes.
+ For events supported by Node, please refer to {{#crossLink "Node.EventType"}}{{/crossLink}} + !#zh + Cocos Creator 场景中的所有节点类。
+ 支持的节点事件,请参阅 {{#crossLink "Node.EventType"}}{{/crossLink}}。 */ + export class Node extends _BaseNode { + /** !#en + Group index of node.
+ Which Group this node belongs to will resolve that this node's collision components can collide with which other collision componentns.
+ !#zh + 节点的分组索引。
+ 节点的分组将关系到节点的碰撞组件可以与哪些碰撞组件相碰撞。
*/ + groupIndex: number; + /** !#en + Group of node.
+ Which Group this node belongs to will resolve that this node's collision components can collide with which other collision componentns.
+ !#zh + 节点的分组。
+ 节点的分组将关系到节点的碰撞组件可以与哪些碰撞组件相碰撞。
*/ + group: string; + /** !#en The position (x, y) of the node in its parent's coordinates. + !#zh 节点在父节点坐标系中的位置(x, y)。 */ + position: Vec3; + /** !#en x axis position of node. + !#zh 节点 X 轴坐标。 */ + x: number; + /** !#en y axis position of node. + !#zh 节点 Y 轴坐标。 */ + y: number; + /** !#en z axis position of node. + !#zh 节点 Z 轴坐标。 */ + z: number; + /** !#en Rotation of node. + !#zh 该节点旋转角度。 */ + rotation: number; + /** !#en + Angle of node, the positive value is anti-clockwise direction. + !#zh + 该节点的旋转角度,正值为逆时针方向。 */ + angle: number; + /** !#en The rotation as Euler angles in degrees, used in 3D node. + !#zh 该节点的欧拉角度,用于 3D 节点。 */ + eulerAngles: Vec3; + /** !#en Rotation on x axis. + !#zh 该节点 X 轴旋转角度。 */ + rotationX: number; + /** !#en Rotation on y axis. + !#zh 该节点 Y 轴旋转角度。 */ + rotationY: number; + /** !#en The local scale relative to the parent. + !#zh 节点相对父节点的缩放。 */ + scale: number; + /** !#en Scale on x axis. + !#zh 节点 X 轴缩放。 */ + scaleX: number; + /** !#en Scale on y axis. + !#zh 节点 Y 轴缩放。 */ + scaleY: number; + /** !#en Scale on z axis. + !#zh 节点 Z 轴缩放。 */ + scaleZ: number; + /** !#en Skew x + !#zh 该节点 X 轴倾斜角度。 */ + skewX: number; + /** !#en Skew y + !#zh 该节点 Y 轴倾斜角度。 */ + skewY: number; + /** !#en Opacity of node, default value is 255. + !#zh 节点透明度,默认值为 255。 */ + opacity: number; + /** !#en Color of node, default value is white: (255, 255, 255). + !#zh 节点颜色。默认为白色,数值为:(255,255,255)。 */ + color: Color; + /** !#en Anchor point's position on x axis. + !#zh 节点 X 轴锚点位置。 */ + anchorX: number; + /** !#en Anchor point's position on y axis. + !#zh 节点 Y 轴锚点位置。 */ + anchorY: number; + /** !#en Width of node. + !#zh 节点宽度。 */ + width: number; + /** !#en Height of node. + !#zh 节点高度。 */ + height: number; + /** !#en zIndex is the 'key' used to sort the node relative to its siblings.
+ The value of zIndex should be in the range between cc.macro.MIN_ZINDEX and cc.macro.MAX_ZINDEX.
+ The Node's parent will sort all its children based on the zIndex value and the arrival order.
+ Nodes with greater zIndex will be sorted after nodes with smaller zIndex.
+ If two nodes have the same zIndex, then the node that was added first to the children's array will be in front of the other node in the array.
+ Node's order in children list will affect its rendering order. Parent is always rendering before all children. + !#zh zIndex 是用来对节点进行排序的关键属性,它决定一个节点在兄弟节点之间的位置。
+ zIndex 的取值应该介于 cc.macro.MIN_ZINDEX 和 cc.macro.MAX_ZINDEX 之间 + 父节点主要根据节点的 zIndex 和添加次序来排序,拥有更高 zIndex 的节点将被排在后面,如果两个节点的 zIndex 一致,先添加的节点会稳定排在另一个节点之前。
+ 节点在 children 中的顺序决定了其渲染顺序。父节点永远在所有子节点之前被渲染 */ + zIndex: number; + /** !#en + Switch 2D/3D node. The 2D nodes will run faster. + !#zh + 切换 2D/3D 节点,2D 节点会有更高的运行效率 */ + is3DNode: boolean; + /** !#en Returns a normalized vector representing the up direction (Y axis) of the node in world space. + !#zh 获取节点正上方(y 轴)面对的方向,返回值为世界坐标系下的归一化向量 */ + up: Vec3; + /** !#en Returns a normalized vector representing the right direction (X axis) of the node in world space. + !#zh 获取节点正右方(x 轴)面对的方向,返回值为世界坐标系下的归一化向量 */ + right: Vec3; + /** !#en Returns a normalized vector representing the forward direction (Z axis) of the node in world space. + !#zh 获取节点正前方(z 轴)面对的方向,返回值为世界坐标系下的归一化向量 */ + forward: Vec3; + /** + + @param name name + */ + constructor(name?: string); + /** + !#en + Register a callback of a specific event type on Node.
+ Use this method to register touch or mouse event permit propagation based on scene graph,
+ These kinds of event are triggered with dispatchEvent, the dispatch process has three steps:
+ 1. Capturing phase: dispatch in capture targets (`_getCapturingTargets`), e.g. parents in node tree, from root to the real target
+ 2. At target phase: dispatch to the listeners of the real target
+ 3. Bubbling phase: dispatch in bubble targets (`_getBubblingTargets`), e.g. parents in node tree, from the real target to root
+ In any moment of the dispatching process, it can be stopped via `event.stopPropagation()` or `event.stopPropagationImmidiate()`.
+ It's the recommended way to register touch/mouse event for Node,
+ please do not use cc.eventManager directly for Node.
+ You can also register custom event and use `emit` to trigger custom event on Node.
+ For such events, there won't be capturing and bubbling phase, your event will be dispatched directly to its listeners registered on the same node.
+ You can also pass event callback parameters with `emit` by passing parameters after `type`. + !#zh + 在节点上注册指定类型的回调函数,也可以设置 target 用于绑定响应函数的 this 对象。
+ 鼠标或触摸事件会被系统调用 dispatchEvent 方法触发,触发的过程包含三个阶段:
+ 1. 捕获阶段:派发事件给捕获目标(通过 `_getCapturingTargets` 获取),比如,节点树中注册了捕获阶段的父节点,从根节点开始派发直到目标节点。
+ 2. 目标阶段:派发给目标节点的监听器。
+ 3. 冒泡阶段:派发事件给冒泡目标(通过 `_getBubblingTargets` 获取),比如,节点树中注册了冒泡阶段的父节点,从目标节点开始派发直到根节点。
+ 同时您可以将事件派发到父节点或者通过调用 stopPropagation 拦截它。
+ 推荐使用这种方式来监听节点上的触摸或鼠标事件,请不要在节点上直接使用 cc.eventManager。
+ 你也可以注册自定义事件到节点上,并通过 emit 方法触发此类事件,对于这类事件,不会发生捕获冒泡阶段,只会直接派发给注册在该节点上的监听器
+ 你可以通过在 emit 方法调用时在 type 之后传递额外的参数作为事件回调的参数列表 + @param type A string representing the event type to listen for.
See {{#crossLink "Node/EventTyupe/POSITION_CHANGED"}}Node Events{{/crossLink}} for all builtin events. + @param callback The callback that will be invoked when the event is dispatched. The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + @param useCapture When set to true, the listener will be triggered at capturing phase which is ahead of the final target emit, otherwise it will be triggered during bubbling phase. + + @example + ```js + this.node.on(cc.Node.EventType.TOUCH_START, this.memberFunction, this); // if "this" is component and the "memberFunction" declared in CCClass. + node.on(cc.Node.EventType.TOUCH_START, callback, this); + node.on(cc.Node.EventType.TOUCH_MOVE, callback, this); + node.on(cc.Node.EventType.TOUCH_END, callback, this); + node.on(cc.Node.EventType.TOUCH_CANCEL, callback, this); + node.on(cc.Node.EventType.ANCHOR_CHANGED, callback); + node.on(cc.Node.EventType.COLOR_CHANGED, callback); + ``` + */ + on(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Register an callback of a specific event type on the Node, + the callback will remove itself after the first time it is triggered. + !#zh + 注册节点的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + node.once(cc.Node.EventType.ANCHOR_CHANGED, callback); + ``` + */ + once(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Removes the callback previously registered with the same type, callback, target and or useCapture. + This method is merely an alias to removeEventListener. + !#zh 删除之前与同类型,回调,目标或 useCapture 注册的回调。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + @param useCapture When set to true, the listener will be triggered at capturing phase which is ahead of the final target emit, otherwise it will be triggered during bubbling phase. + + @example + ```js + this.node.off(cc.Node.EventType.TOUCH_START, this.memberFunction, this); + node.off(cc.Node.EventType.TOUCH_START, callback, this.node); + node.off(cc.Node.EventType.ANCHOR_CHANGED, callback, this); + ``` + */ + off(type: string, callback?: Function, target?: any, useCapture?: boolean): void; + /** + !#en Removes all callbacks previously registered with the same target. + !#zh 移除目标上的所有注册事件。 + @param target The target to be searched for all related callbacks + + @example + ```js + node.targetOff(target); + ``` + */ + targetOff(target: any): void; + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en + Trigger an event directly with the event name and necessary arguments. + !#zh + 通过事件名发送自定义事件 + @param type event type + @param arg1 First argument in callback + @param arg2 Second argument in callback + @param arg3 Third argument in callback + @param arg4 Fourth argument in callback + @param arg5 Fifth argument in callback + + @example + ```js + eventTarget.emit('fire', event); + eventTarget.emit('fire', message, emitter); + ``` + */ + emit(type: string, arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any): void; + /** + !#en + Dispatches an event into the event flow. + The event target is the EventTarget object upon which the dispatchEvent() method is called. + !#zh 分发事件到事件流中。 + @param event The Event object that is dispatched into the event flow + */ + dispatchEvent(event: Event): void; + /** + !#en Pause node related system events registered with the current Node. Node system events includes touch and mouse events. + If recursive is set to true, then this API will pause the node system events for the node and all nodes in its sub node tree. + Reference: http://docs.cocos2d-x.org/editors_and_tools/creator-chapters/scripting/internal-events/ + !#zh 暂停当前节点上注册的所有节点系统事件,节点系统事件包含触摸和鼠标事件。 + 如果传递 recursive 为 true,那么这个 API 将暂停本节点和它的子树上所有节点的节点系统事件。 + 参考:https://www.cocos.com/docs/creator/scripting/internal-events.html + @param recursive Whether to pause node system events on the sub node tree. + + @example + ```js + node.pauseSystemEvents(true); + ``` + */ + pauseSystemEvents(recursive: boolean): void; + /** + !#en Resume node related system events registered with the current Node. Node system events includes touch and mouse events. + If recursive is set to true, then this API will resume the node system events for the node and all nodes in its sub node tree. + Reference: http://docs.cocos2d-x.org/editors_and_tools/creator-chapters/scripting/internal-events/ + !#zh 恢复当前节点上注册的所有节点系统事件,节点系统事件包含触摸和鼠标事件。 + 如果传递 recursive 为 true,那么这个 API 将恢复本节点和它的子树上所有节点的节点系统事件。 + 参考:https://www.cocos.com/docs/creator/scripting/internal-events.html + @param recursive Whether to resume node system events on the sub node tree. + + @example + ```js + node.resumeSystemEvents(true); + ``` + */ + resumeSystemEvents(recursive: boolean): void; + /** + !#en + Executes an action, and returns the action that is executed.
+ The node becomes the action's target. Refer to cc.Action's getTarget()
+ Calling runAction while the node is not active won't have any effect.
+ Note:You shouldn't modify the action after runAction, that won't take any effect.
+ if you want to modify, when you define action plus. + !#zh + 执行并返回该执行的动作。该节点将会变成动作的目标。
+ 调用 runAction 时,节点自身处于不激活状态将不会有任何效果。
+ 注意:你不应该修改 runAction 后的动作,将无法发挥作用,如果想进行修改,请在定义 action 时加入。 + @param action action + + @example + ```js + var action = cc.scaleTo(0.2, 1, 0.6); + node.runAction(action); + node.runAction(action).repeatForever(); // fail + node.runAction(action.repeatForever()); // right + ``` + */ + runAction(action: Action): Action; + /** + !#en Pause all actions running on the current node. Equals to `cc.director.getActionManager().pauseTarget(node)`. + !#zh 暂停本节点上所有正在运行的动作。和 `cc.director.getActionManager().pauseTarget(node);` 等价。 + + @example + ```js + node.pauseAllActions(); + ``` + */ + pauseAllActions(): void; + /** + !#en Resume all paused actions on the current node. Equals to `cc.director.getActionManager().resumeTarget(node)`. + !#zh 恢复运行本节点上所有暂停的动作。和 `cc.director.getActionManager().resumeTarget(node);` 等价。 + + @example + ```js + node.resumeAllActions(); + ``` + */ + resumeAllActions(): void; + /** + !#en Stops and removes all actions from the running action list . + !#zh 停止并且移除所有正在运行的动作列表。 + + @example + ```js + node.stopAllActions(); + ``` + */ + stopAllActions(): void; + /** + !#en Stops and removes an action from the running action list. + !#zh 停止并移除指定的动作。 + @param action An action object to be removed. + + @example + ```js + var action = cc.scaleTo(0.2, 1, 0.6); + node.stopAction(action); + ``` + */ + stopAction(action: Action): void; + /** + !#en Removes an action from the running action list by its tag. + !#zh 停止并且移除指定标签的动作。 + @param tag A tag that indicates the action to be removed. + + @example + ```js + node.stopActionByTag(1); + ``` + */ + stopActionByTag(tag: number): void; + /** + !#en Returns an action from the running action list by its tag. + !#zh 通过标签获取指定动作。 + @param tag tag + + @example + ```js + var action = node.getActionByTag(1); + ``` + */ + getActionByTag(tag: number): Action; + /** + !#en + Returns the numbers of actions that are running plus the ones that are schedule to run (actions in actionsToAdd and actions arrays).
+ Composable actions are counted as 1 action. Example:
+ If you are running 1 Sequence of 7 actions, it will return 1.
+ If you are running 7 Sequences of 2 actions, it will return 7.

+ !#zh + 获取运行着的动作加上正在调度运行的动作的总数。
+ 例如:
+ - 如果你正在运行 7 个动作中的 1 个 Sequence,它将返回 1。
+ - 如果你正在运行 2 个动作中的 7 个 Sequence,它将返回 7。
+ + @example + ```js + var count = node.getNumberOfRunningActions(); + cc.log("Running Action Count: " + count); + ``` + */ + getNumberOfRunningActions(): number; + /** + !#en + Returns a copy of the position (x, y, z) of the node in its parent's coordinates. + You can pass a cc.Vec2 or cc.Vec3 as the argument to receive the return values. + !#zh + 获取节点在父节点坐标系中的位置(x, y, z)。 + 你可以传一个 cc.Vec2 或者 cc.Vec3 作为参数来接收返回值。 + @param out The return value to receive position + + @example + ```js + cc.log("Node Position: " + node.getPosition()); + ``` + */ + getPosition(out?: Vec2|Vec3): Vec2; + /** + !#en + Sets the position (x, y, z) of the node in its parent's coordinates.
+ Usually we use cc.v2(x, y) to compose cc.Vec2 object, in this case, position.z will become 0.
+ and passing two numbers (x, y) is more efficient than passing cc.Vec2 object, in this case, position.z will remain unchanged. + For 3D node we can use cc.v3(x, y, z) to compose cc.Vec3 object,
+ and passing three numbers (x, y, z) is more efficient than passing cc.Vec3 object. + !#zh + 设置节点在父节点坐标系中的位置。
+ 可以通过下面的方式设置坐标点:
+ 1. 传入 2 个数值 x, y (此时不会改变 position.z 的值)。
+ 2. 传入 cc.v2(x, y) 类型为 cc.Vec2 的对象 (此时 position.z 的值将被设置为0)。 + 3. 对于 3D 节点可以传入 3 个数值 x, y, z。
+ 4. 对于 3D 节点可以传入 cc.v3(x, y, z) 类型为 cc.Vec3 的对象。 + @param x X coordinate for position or the position object + @param y Y coordinate for position + @param z Z coordinate for position + */ + setPosition(x: Vec2|Vec3|number, y?: number, z?: number): void; + /** + !#en + Returns the scale factor of the node. + Need pass a cc.Vec2 or cc.Vec3 as the argument to receive the return values. + !#zh 获取节点的缩放,需要传一个 cc.Vec2 或者 cc.Vec3 作为参数来接收返回值。 + @param out out + + @example + ```js + cc.log("Node Scale: " + node.getScale(cc.v3())); + ``` + */ + getScale(out: Vec2|Vec3): Vec2; + /** + !#en + Sets the scale of axis in local coordinates of the node. + You can operate 2 axis in 2D node, and 3 axis in 3D node. + When only (x, y) is passed, the value of scale.z will not be changed. + When a Vec2 is passed in, the value of scale.z will be set to 0. + !#zh + 设置节点在本地坐标系中坐标轴上的缩放比例。 + 2D 节点可以操作两个坐标轴,而 3D 节点可以操作三个坐标轴。 + 当只传入 (x, y) 时,scale.z 的值不会被改变。 + 当只传入 Vec2 对象时,scale.z 的值将被设置为0。 + @param x scaleX or scale object + @param y y + @param z z + + @example + ```js + node.setScale(cc.v2(2, 2)); // Notice: scaleZ will be 0 + node.setScale(cc.v3(2, 2, 2)); // for 3D node + node.setScale(2); + ``` + */ + setScale(x: number|Vec2|Vec3, y?: number, z?: number): void; + /** + !#en + Get rotation of node (in quaternion). + Need pass a cc.Quat as the argument to receive the return values. + !#zh + 获取该节点的 quaternion 旋转角度,需要传一个 cc.Quat 作为参数来接收返回值。 + @param out out + */ + getRotation(out: Quat): Quat; + /** + !#en Set rotation of node (in quaternion). + !#zh 设置该节点的 quaternion 旋转角度。 + @param quat Quaternion object represents the rotation or the x value of quaternion + @param y y value of quternion + @param z z value of quternion + @param w w value of quternion + */ + setRotation(quat: Quat|number, y?: number, z?: number, w?: number): void; + /** + !#en + Returns a copy the untransformed size of the node.
+ The contentSize remains the same no matter the node is scaled or rotated.
+ All nodes has a size. Layer and Scene has the same size of the screen by default.
+ !#zh 获取节点自身大小,不受该节点是否被缩放或者旋转的影响。 + + @example + ```js + cc.log("Content Size: " + node.getContentSize()); + ``` + */ + getContentSize(): Size; + /** + !#en + Sets the untransformed size of the node.
+ The contentSize remains the same no matter the node is scaled or rotated.
+ All nodes has a size. Layer and Scene has the same size of the screen. + !#zh 设置节点原始大小,不受该节点是否被缩放或者旋转的影响。 + @param size The untransformed size of the node or The untransformed size's width of the node. + @param height The untransformed size's height of the node. + + @example + ```js + node.setContentSize(cc.size(100, 100)); + node.setContentSize(100, 100); + ``` + */ + setContentSize(size: Size|number, height?: number): void; + /** + !#en + Returns a copy of the anchor point.
+ Anchor point is the point around which all transformations and positioning manipulations take place.
+ It's like a pin in the node where it is "attached" to its parent.
+ The anchorPoint is normalized, like a percentage. (0,0) means the bottom-left corner and (1,1) means the top-right corner.
+ But you can use values higher than (1,1) and lower than (0,0) too.
+ The default anchor point is (0.5,0.5), so it starts at the center of the node. + !#zh + 获取节点锚点,用百分比表示。
+ 锚点应用于所有变换和坐标点的操作,它就像在节点上连接其父节点的大头针。
+ 锚点是标准化的,就像百分比一样。(0,0) 表示左下角,(1,1) 表示右上角。
+ 但是你可以使用比(1,1)更高的值或者比(0,0)更低的值。
+ 默认的锚点是(0.5,0.5),因此它开始于节点的中心位置。
+ 注意:Creator 中的锚点仅用于定位所在的节点,子节点的定位不受影响。 + + @example + ```js + cc.log("Node AnchorPoint: " + node.getAnchorPoint()); + ``` + */ + getAnchorPoint(): Vec2; + /** + !#en + Sets the anchor point in percent.
+ anchor point is the point around which all transformations and positioning manipulations take place.
+ It's like a pin in the node where it is "attached" to its parent.
+ The anchorPoint is normalized, like a percentage. (0,0) means the bottom-left corner and (1,1) means the top-right corner.
+ But you can use values higher than (1,1) and lower than (0,0) too.
+ The default anchor point is (0.5,0.5), so it starts at the center of the node. + !#zh + 设置锚点的百分比。
+ 锚点应用于所有变换和坐标点的操作,它就像在节点上连接其父节点的大头针。
+ 锚点是标准化的,就像百分比一样。(0,0) 表示左下角,(1,1) 表示右上角。
+ 但是你可以使用比(1,1)更高的值或者比(0,0)更低的值。
+ 默认的锚点是(0.5,0.5),因此它开始于节点的中心位置。
+ 注意:Creator 中的锚点仅用于定位所在的节点,子节点的定位不受影响。 + @param point The anchor point of node or The x axis anchor of node. + @param y The y axis anchor of node. + + @example + ```js + node.setAnchorPoint(cc.v2(1, 1)); + node.setAnchorPoint(1, 1); + ``` + */ + setAnchorPoint(point: Vec2|number, y?: number): void; + /** + !#en Set rotation by lookAt target point, normally used by Camera Node + !#zh 通过观察目标来设置 rotation,一般用于 Camera Node 上 + @param pos pos + @param up default is (0,1,0) + */ + lookAt(pos: Vec3, up?: Vec3): void; + /** + !#en + Get the local transform matrix (4x4), based on parent node coordinates + !#zh 返回局部空间坐标系的矩阵,基于父节点坐标系。 + @param out The matrix object to be filled with data + + @example + ```js + let mat4 = cc.mat4(); + node.getLocalMatrix(mat4); + ``` + */ + getLocalMatrix(out: Mat4): Mat4; + /** + !#en + Get the world transform matrix (4x4) + !#zh 返回世界空间坐标系的矩阵。 + @param out The matrix object to be filled with data + + @example + ```js + let mat4 = cc.mat4(); + node.getWorldMatrix(mat4); + ``` + */ + getWorldMatrix(out: Mat4): Mat4; + /** + !#en + Converts a Point to node (local) space coordinates. + !#zh + 将一个点转换到节点 (局部) 空间坐标系。 + @param worldPoint worldPoint + @param out out + + @example + ```js + var newVec2 = node.convertToNodeSpaceAR(cc.v2(100, 100)); + var newVec3 = node.convertToNodeSpaceAR(cc.v3(100, 100, 100)); + ``` + */ + convertToNodeSpaceAR(worldPoint: T, out?: T): T; + /** + !#en + Converts a Point in node coordinates to world space coordinates. + !#zh + 将节点坐标系下的一个点转换到世界空间坐标系。 + @param nodePoint nodePoint + @param out out + + @example + ```js + var newVec2 = node.convertToWorldSpaceAR(cc.v2(100, 100)); + var newVec3 = node.convertToWorldSpaceAR(cc.v3(100, 100, 100)); + ``` + */ + convertToWorldSpaceAR(nodePoint: T, out?: T): T; + /** + !#en Converts a Point to node (local) space coordinates then add the anchor point position. + So the return position will be related to the left bottom corner of the node's bounding box. + This equals to the API behavior of cocos2d-x, you probably want to use convertToNodeSpaceAR instead + !#zh 将一个点转换到节点 (局部) 坐标系,并加上锚点的坐标。
+ 也就是说返回的坐标是相对于节点包围盒左下角的坐标。
+ 这个 API 的设计是为了和 cocos2d-x 中行为一致,更多情况下你可能需要使用 convertToNodeSpaceAR。 + @param worldPoint worldPoint + + @example + ```js + var newVec2 = node.convertToNodeSpace(cc.v2(100, 100)); + ``` + */ + convertToNodeSpace(worldPoint: Vec2): Vec2; + /** + !#en Converts a Point related to the left bottom corner of the node's bounding box to world space coordinates. + This equals to the API behavior of cocos2d-x, you probably want to use convertToWorldSpaceAR instead + !#zh 将一个相对于节点左下角的坐标位置转换到世界空间坐标系。 + 这个 API 的设计是为了和 cocos2d-x 中行为一致,更多情况下你可能需要使用 convertToWorldSpaceAR + @param nodePoint nodePoint + + @example + ```js + var newVec2 = node.convertToWorldSpace(cc.v2(100, 100)); + ``` + */ + convertToWorldSpace(nodePoint: Vec2): Vec2; + /** + !#en + Returns the matrix that transform the node's (local) space coordinates into the parent's space coordinates.
+ The matrix is in Pixels. + !#zh 返回这个将节点(局部)的空间坐标系转换成父节点的空间坐标系的矩阵。这个矩阵以像素为单位。 + @param out The affine transform object to be filled with data + + @example + ```js + let affineTransform = cc.AffineTransform.create(); + node.getNodeToParentTransform(affineTransform); + ``` + */ + getNodeToParentTransform(out?: AffineTransform): AffineTransform; + /** + !#en + Returns the matrix that transform the node's (local) space coordinates into the parent's space coordinates.
+ The matrix is in Pixels.
+ This method is AR (Anchor Relative). + !#zh + 返回这个将节点(局部)的空间坐标系转换成父节点的空间坐标系的矩阵。
+ 这个矩阵以像素为单位。
+ 该方法基于节点坐标。 + @param out The affine transform object to be filled with data + + @example + ```js + let affineTransform = cc.AffineTransform.create(); + node.getNodeToParentTransformAR(affineTransform); + ``` + */ + getNodeToParentTransformAR(out?: AffineTransform): AffineTransform; + /** + !#en Returns the world affine transform matrix. The matrix is in Pixels. + !#zh 返回节点到世界坐标系的仿射变换矩阵。矩阵单位是像素。 + @param out The affine transform object to be filled with data + + @example + ```js + let affineTransform = cc.AffineTransform.create(); + node.getNodeToWorldTransform(affineTransform); + ``` + */ + getNodeToWorldTransform(out?: AffineTransform): AffineTransform; + /** + !#en + Returns the world affine transform matrix. The matrix is in Pixels.
+ This method is AR (Anchor Relative). + !#zh + 返回节点到世界坐标仿射变换矩阵。矩阵单位是像素。
+ 该方法基于节点坐标。 + @param out The affine transform object to be filled with data + + @example + ```js + let affineTransform = cc.AffineTransform.create(); + node.getNodeToWorldTransformAR(affineTransform); + ``` + */ + getNodeToWorldTransformAR(out?: AffineTransform): AffineTransform; + /** + !#en + Returns the matrix that transform parent's space coordinates to the node's (local) space coordinates.
+ The matrix is in Pixels. The returned transform is readonly and cannot be changed. + !#zh + 返回将父节点的坐标系转换成节点(局部)的空间坐标系的矩阵。
+ 该矩阵以像素为单位。返回的矩阵是只读的,不能更改。 + @param out The affine transform object to be filled with data + + @example + ```js + let affineTransform = cc.AffineTransform.create(); + node.getParentToNodeTransform(affineTransform); + ``` + */ + getParentToNodeTransform(out?: AffineTransform): AffineTransform; + /** + !#en Returns the inverse world affine transform matrix. The matrix is in Pixels. + !#en 返回世界坐标系到节点坐标系的逆矩阵。 + @param out The affine transform object to be filled with data + + @example + ```js + let affineTransform = cc.AffineTransform.create(); + node.getWorldToNodeTransform(affineTransform); + ``` + */ + getWorldToNodeTransform(out?: AffineTransform): AffineTransform; + /** + !#en convenience methods which take a cc.Touch instead of cc.Vec2. + !#zh 将触摸点转换成本地坐标系中位置。 + @param touch The touch object + + @example + ```js + var newVec2 = node.convertTouchToNodeSpace(touch); + ``` + */ + convertTouchToNodeSpace(touch: Touch): Vec2; + /** + !#en converts a cc.Touch (world coordinates) into a local coordinate. This method is AR (Anchor Relative). + !#zh 转换一个 cc.Touch(世界坐标)到一个局部坐标,该方法基于节点坐标。 + @param touch The touch object + + @example + ```js + var newVec2 = node.convertTouchToNodeSpaceAR(touch); + ``` + */ + convertTouchToNodeSpaceAR(touch: Touch): Vec2; + /** + !#en + Returns a "local" axis aligned bounding box of the node.
+ The returned box is relative only to its parent. + !#zh 返回父节坐标系下的轴向对齐的包围盒。 + + @example + ```js + var boundingBox = node.getBoundingBox(); + ``` + */ + getBoundingBox(): Rect; + /** + !#en + Returns a "world" axis aligned bounding box of the node.
+ The bounding box contains self and active children's world bounding box. + !#zh + 返回节点在世界坐标系下的对齐轴向的包围盒(AABB)。
+ 该边框包含自身和已激活的子节点的世界边框。 + + @example + ```js + var newRect = node.getBoundingBoxToWorld(); + ``` + */ + getBoundingBoxToWorld(): Rect; + /** + !#en + Adds a child to the node with z order and name. + !#zh + 添加子节点,并且可以修改该节点的 局部 Z 顺序和名字。 + @param child A child node + @param zIndex Z order for drawing priority. Please refer to zIndex property + @param name A name to identify the node easily. Please refer to name property + + @example + ```js + node.addChild(newNode, 1, "node"); + ``` + */ + addChild(child: Node, zIndex?: number, name?: string): void; + /** + !#en Stops all running actions and schedulers. + !#zh 停止所有正在播放的动作和计时器。 + + @example + ```js + node.cleanup(); + ``` + */ + cleanup(): void; + /** + !#en Sorts the children array depends on children's zIndex and arrivalOrder, + normally you won't need to invoke this function. + !#zh 根据子节点的 zIndex 和 arrivalOrder 进行排序,正常情况下开发者不需要手动调用这个函数。 + */ + sortAllChildren(): void; + /** + !#en + Returns the displayed opacity of Node, + the difference between displayed opacity and opacity is that displayed opacity is calculated based on opacity and parent node's opacity when cascade opacity enabled. + !#zh + 获取节点显示透明度, + 显示透明度和透明度之间的不同之处在于当启用级连透明度时, + 显示透明度是基于自身透明度和父节点透明度计算的。 + */ + getDisplayedOpacity(): number; + /** + !#en + Returns the displayed color of Node, + the difference between displayed color and color is that displayed color is calculated based on color and parent node's color when cascade color enabled. + !#zh + 获取节点的显示颜色, + 显示颜色和颜色之间的不同之处在于当启用级连颜色时, + 显示颜色是基于自身颜色和父节点颜色计算的。 + */ + getDisplayedColor(): Color; + /** !#en Cascade opacity is removed from v2.0 + Indicate whether node's opacity value affect its child nodes, default value is true. + !#zh 透明度级联功能从 v2.0 开始已移除 + 节点的不透明度值是否影响其子节点,默认值为 true。 */ + cascadeOpacity: boolean; + /** + !#en Cascade opacity is removed from v2.0 + Returns whether node's opacity value affect its child nodes. + !#zh 透明度级联功能从 v2.0 开始已移除 + 返回节点的不透明度值是否影响其子节点。 + */ + isCascadeOpacityEnabled(): boolean; + /** + !#en Cascade opacity is removed from v2.0 + Enable or disable cascade opacity, if cascade enabled, child nodes' opacity will be the multiplication of parent opacity and its own opacity. + !#zh 透明度级联功能从 v2.0 开始已移除 + 启用或禁用级连不透明度,如果级连启用,子节点的不透明度将是父不透明度乘上它自己的不透明度。 + @param cascadeOpacityEnabled cascadeOpacityEnabled + */ + setCascadeOpacityEnabled(cascadeOpacityEnabled: boolean): void; + /** + !#en Opacity modify RGB have been removed since v2.0 + Set whether color should be changed with the opacity value, + useless in ccsg.Node, but this function is override in some class to have such behavior. + !#zh 透明度影响颜色配置已经被废弃 + 设置更改透明度时是否修改RGB值, + @param opacityValue opacityValue + */ + setOpacityModifyRGB(opacityValue: boolean): void; + /** + !#en Opacity modify RGB have been removed since v2.0 + Get whether color should be changed with the opacity value. + !#zh 透明度影响颜色配置已经被废弃 + 获取更改透明度时是否修改RGB值。 + */ + isOpacityModifyRGB(): boolean; + } + /** !#en + Class of private entities in Cocos Creator scenes.
+ The PrivateNode is hidden in editor, and completely transparent to users.
+ It's normally used as Node's private content created by components in parent node.
+ So in theory private nodes are not children, they are part of the parent node.
+ Private node have two important characteristics:
+ 1. It has the minimum z index and cannot be modified, because they can't be displayed over real children.
+ 2. The positioning of private nodes is also special, they will consider the left bottom corner of the parent node's bounding box as the origin of local coordinates.
+ In this way, they can be easily kept inside the bounding box.
+ Currently, it's used by RichText component and TileMap component. + !#zh + Cocos Creator 场景中的私有节点类。
+ 私有节点在编辑器中不可见,对用户透明。
+ 通常私有节点是被一些特殊的组件创建出来作为父节点的一部分而存在的,理论上来说,它们不是子节点,而是父节点的组成部分。
+ 私有节点有两个非常重要的特性:
+ 1. 它有着最小的渲染排序的 Z 轴深度,并且无法被更改,因为它们不能被显示在其他正常子节点之上。
+ 2. 它的定位也是特殊的,对于私有节点来说,父节点包围盒的左下角是它的局部坐标系原点,这个原点相当于父节点的位置减去它锚点的偏移。这样私有节点可以比较容易被控制在包围盒之中。
+ 目前在引擎中,RichText 和 TileMap 都有可能生成私有节点。 */ + export class PrivateNode extends Node { + /** + + @param name name + */ + constructor(name?: string); + } + /** !#en + cc.Scene is a subclass of cc.Node that is used only as an abstract concept.
+ cc.Scene and cc.Node are almost identical with the difference that users can not modify cc.Scene manually. + !#zh + cc.Scene 是 cc.Node 的子类,仅作为一个抽象的概念。
+ cc.Scene 和 cc.Node 有点不同,用户不应直接修改 cc.Scene。 */ + export class Scene extends Node { + /** !#en Indicates whether all (directly or indirectly) static referenced assets of this scene are releasable by default after scene unloading. + !#zh 指示该场景中直接或间接静态引用到的所有资源是否默认在场景切换后自动释放。 */ + autoReleaseAssets: boolean; + } + /** !#en + Scheduler is responsible of triggering the scheduled callbacks.
+ You should not use NSTimer. Instead use this class.
+
+ There are 2 different types of callbacks (selectors):
+ - update callback: the 'update' callback will be called every frame. You can customize the priority.
+ - custom callback: A custom callback will be called every frame, or with a custom interval of time
+
+ The 'custom selectors' should be avoided when possible. It is faster, + and consumes less memory to use the 'update callback'. * + !#zh + Scheduler 是负责触发回调函数的类。
+ 通常情况下,建议使用 cc.director.getScheduler() 来获取系统定时器。
+ 有两种不同类型的定时器:
+ - update 定时器:每一帧都会触发。您可以自定义优先级。
+ - 自定义定时器:自定义定时器可以每一帧或者自定义的时间间隔触发。
+ 如果希望每帧都触发,应该使用 update 定时器,使用 update 定时器更快,而且消耗更少的内存。 */ + export class Scheduler { + /** + !#en This method should be called for any target which needs to schedule tasks, and this method should be called before any scheduler API usage. + This method will add a `_id` property if it doesn't exist. + !#zh 任何需要用 Scheduler 管理任务的对象主体都应该调用这个方法,并且应该在调用任何 Scheduler API 之前调用这个方法。 + 这个方法会给对象添加一个 `_id` 属性,如果这个属性不存在的话。 + @param target target + */ + enableForTarget(target: any): void; + /** + !#en + Modifies the time of all scheduled callbacks.
+ You can use this property to create a 'slow motion' or 'fast forward' effect.
+ Default is 1.0. To create a 'slow motion' effect, use values below 1.0.
+ To create a 'fast forward' effect, use values higher than 1.0.
+ Note:It will affect EVERY scheduled selector / action. + !#zh + 设置时间间隔的缩放比例。
+ 您可以使用这个方法来创建一个 “slow motion(慢动作)” 或 “fast forward(快进)” 的效果。
+ 默认是 1.0。要创建一个 “slow motion(慢动作)” 效果,使用值低于 1.0。
+ 要使用 “fast forward(快进)” 效果,使用值大于 1.0。
+ 注意:它影响该 Scheduler 下管理的所有定时器。 + @param timeScale timeScale + */ + setTimeScale(timeScale: number): void; + /** + !#en Returns time scale of scheduler. + !#zh 获取时间间隔的缩放比例。 + */ + getTimeScale(): number; + /** + !#en 'update' the scheduler. (You should NEVER call this method, unless you know what you are doing.) + !#zh update 调度函数。(不应该直接调用这个方法,除非完全了解这么做的结果) + @param dt delta time + */ + update(dt: number): void; + /** + !#en +

+ The scheduled method will be called every 'interval' seconds.
+ If paused is YES, then it won't be called until it is resumed.
+ If 'interval' is 0, it will be called every frame, but if so, it recommended to use 'scheduleUpdateForTarget:' instead.
+ If the callback function is already scheduled, then only the interval parameter will be updated without re-scheduling it again.
+ repeat let the action be repeated repeat + 1 times, use cc.macro.REPEAT_FOREVER to let the action run continuously
+ delay is the amount of time the action will wait before it'll start
+

+ !#zh + 指定回调函数,调用对象等信息来添加一个新的定时器。
+ 如果 paused 值为 true,那么直到 resume 被调用才开始计时。
+ 当时间间隔达到指定值时,设置的回调函数将会被调用。
+ 如果 interval 值为 0,那么回调函数每一帧都会被调用,但如果是这样, + 建议使用 scheduleUpdateForTarget 代替。
+ 如果回调函数已经被定时器使用,那么只会更新之前定时器的时间间隔参数,不会设置新的定时器。
+ repeat 值可以让定时器触发 repeat + 1 次,使用 cc.macro.REPEAT_FOREVER + 可以让定时器一直循环触发。
+ delay 值指定延迟时间,定时器会在延迟指定的时间之后开始计时。 + @param callback callback + @param target target + @param interval interval + @param repeat repeat + @param delay delay + @param paused paused + + @example + ```js + //register a schedule to scheduler + cc.director.getScheduler().schedule(callback, this, interval, !this._isRunning); + + ``` + */ + schedule(callback: Function, target: any, interval: number, repeat: number, delay: number, paused?: boolean): void; + schedule(callback: Function, target: any, interval: number, paused?: boolean): void; + /** + !#en + Schedules the update callback for a given target, + During every frame after schedule started, the "update" function of target will be invoked. + !#zh + 使用指定的优先级为指定的对象设置 update 定时器。 + update 定时器每一帧都会被触发,触发时自动调用指定对象的 "update" 函数。 + 优先级的值越低,定时器被触发的越早。 + @param target target + @param priority priority + @param paused paused + */ + scheduleUpdate(target: any, priority: number, paused: boolean): void; + /** + !#en + Unschedules a callback for a callback and a given target. + If you want to unschedule the "update", use `unscheduleUpdate()` + !#zh + 取消指定对象定时器。 + 如果需要取消 update 定时器,请使用 unscheduleUpdate()。 + @param callback The callback to be unscheduled + @param target The target bound to the callback. + */ + unschedule(callback: Function, target: any): void; + /** + !#en Unschedules the update callback for a given target. + !#zh 取消指定对象的 update 定时器。 + @param target The target to be unscheduled. + */ + unscheduleUpdate(target: any): void; + /** + !#en + Unschedules all scheduled callbacks for a given target. + This also includes the "update" callback. + !#zh 取消指定对象的所有定时器,包括 update 定时器。 + @param target The target to be unscheduled. + */ + unscheduleAllForTarget(target: any): void; + /** + !#en + Unschedules all scheduled callbacks from all targets including the system callbacks.
+ You should NEVER call this method, unless you know what you are doing. + !#zh + 取消所有对象的所有定时器,包括系统定时器。
+ 不要调用此函数,除非你确定你在做什么。 + */ + unscheduleAll(): void; + /** + !#en + Unschedules all callbacks from all targets with a minimum priority.
+ You should only call this with `PRIORITY_NON_SYSTEM_MIN` or higher. + !#zh + 取消所有优先级的值大于指定优先级的定时器。
+ 你应该只取消优先级的值大于 PRIORITY_NON_SYSTEM_MIN 的定时器。 + @param minPriority The minimum priority of selector to be unscheduled. Which means, all selectors which + priority is higher than minPriority will be unscheduled. + */ + unscheduleAllWithMinPriority(minPriority: number): void; + /** + !#en Checks whether a callback for a given target is scheduled. + !#zh 检查指定的回调函数和回调对象组合是否存在定时器。 + @param callback The callback to check. + @param target The target of the callback. + */ + isScheduled(callback: Function, target: any): boolean; + /** + !#en + Pause all selectors from all targets.
+ You should NEVER call this method, unless you know what you are doing. + !#zh + 暂停所有对象的所有定时器。
+ 不要调用这个方法,除非你知道你正在做什么。 + */ + pauseAllTargets(): void; + /** + !#en + Pause all selectors from all targets with a minimum priority.
+ You should only call this with kCCPriorityNonSystemMin or higher. + !#zh + 暂停所有优先级的值大于指定优先级的定时器。
+ 你应该只暂停优先级的值大于 PRIORITY_NON_SYSTEM_MIN 的定时器。 + @param minPriority minPriority + */ + pauseAllTargetsWithMinPriority(minPriority: number): void; + /** + !#en + Resume selectors on a set of targets.
+ This can be useful for undoing a call to pauseAllCallbacks. + !#zh + 恢复指定数组中所有对象的定时器。
+ 这个函数是 pauseAllCallbacks 的逆操作。 + @param targetsToResume targetsToResume + */ + resumeTargets(targetsToResume: any[]): void; + /** + !#en + Pauses the target.
+ All scheduled selectors/update for a given target won't be 'ticked' until the target is resumed.
+ If the target is not present, nothing happens. + !#zh + 暂停指定对象的定时器。
+ 指定对象的所有定时器都会被暂停。
+ 如果指定的对象没有定时器,什么也不会发生。 + @param target target + */ + pauseTarget(target: any): void; + /** + !#en + Resumes the target.
+ The 'target' will be unpaused, so all schedule selectors/update will be 'ticked' again.
+ If the target is not present, nothing happens. + !#zh + 恢复指定对象的所有定时器。
+ 指定对象的所有定时器将继续工作。
+ 如果指定的对象没有定时器,什么也不会发生。 + @param target target + */ + resumeTarget(target: any): void; + /** + !#en Returns whether or not the target is paused. + !#zh 返回指定对象的定时器是否暂停了。 + @param target target + */ + isTargetPaused(target: any): boolean; + /** !#en Priority level reserved for system services. + !#zh 系统服务的优先级。 */ + static PRIORITY_SYSTEM: number; + /** !#en Minimum priority level for user scheduling. + !#zh 用户调度最低优先级。 */ + static PRIORITY_NON_SYSTEM: number; + } + /** Class for particle asset handling. */ + export class ParticleAsset extends Asset { + } + /** Particle System base class.
+ Attributes of a Particle System:
+ - emmision rate of the particles
+ - Gravity Mode (Mode A):
+ - gravity
+ - direction
+ - speed +- variance
+ - tangential acceleration +- variance
+ - radial acceleration +- variance
+ - Radius Mode (Mode B):
+ - startRadius +- variance
+ - endRadius +- variance
+ - rotate +- variance
+ - Properties common to all modes:
+ - life +- life variance
+ - start spin +- variance
+ - end spin +- variance
+ - start size +- variance
+ - end size +- variance
+ - start color +- variance
+ - end color +- variance
+ - life +- variance
+ - blending function
+ - texture
+
+ cocos2d also supports particles generated by Particle Designer (http://particledesigner.71squared.com/).
+ 'Radius Mode' in Particle Designer uses a fixed emit rate of 30 hz. Since that can't be guarateed in cocos2d,
+ cocos2d uses a another approach, but the results are almost identical.
+ cocos2d supports all the variables used by Particle Designer plus a bit more:
+ - spinning particles (supported when using ParticleSystem)
+ - tangential acceleration (Gravity mode)
+ - radial acceleration (Gravity mode)
+ - radius direction (Radius mode) (Particle Designer supports outwards to inwards direction only)
+ It is possible to customize any of the above mentioned properties in runtime. Example:
*/ + export class ParticleSystem extends RenderComponent implements BlendFunc { + /** !#en Play particle in edit mode. + !#zh 在编辑器模式下预览粒子,启用后选中粒子时,粒子将自动播放。 */ + preview: boolean; + /** !#en + If set custom to true, then use custom properties insteadof read particle file. + !#zh 是否自定义粒子属性。 */ + custom: boolean; + /** !#en The plist file. + !#zh plist 格式的粒子配置文件。 */ + file: ParticleAsset; + /** !#en SpriteFrame used for particles display + !#zh 用于粒子呈现的 SpriteFrame */ + spriteFrame: SpriteFrame; + /** !#en Texture of Particle System, readonly, please use spriteFrame to setup new texture。 + !#zh 粒子贴图,只读属性,请使用 spriteFrame 属性来替换贴图。 */ + texture: string; + /** !#en Current quantity of particles that are being simulated. + !#zh 当前播放的粒子数量。 */ + particleCount: number; + /** !#en Indicate whether the system simulation have stopped. + !#zh 指示粒子播放是否完毕。 */ + stopped: boolean; + /** !#en If set to true, the particle system will automatically start playing on onLoad. + !#zh 如果设置为 true 运行时会自动发射粒子。 */ + playOnLoad: boolean; + /** !#en Indicate whether the owner node will be auto-removed when it has no particles left. + !#zh 粒子播放完毕后自动销毁所在的节点。 */ + autoRemoveOnFinish: boolean; + /** !#en Indicate whether the particle system is activated. + !#zh 是否激活粒子。 */ + active: boolean; + /** !#en Maximum particles of the system. + !#zh 粒子最大数量。 */ + totalParticles: number; + /** !#en How many seconds the emitter wil run. -1 means 'forever'. + !#zh 发射器生存时间,单位秒,-1表示持续发射。 */ + duration: number; + /** !#en Emission rate of the particles. + !#zh 每秒发射的粒子数目。 */ + emissionRate: number; + /** !#en Life of each particle setter. + !#zh 粒子的运行时间。 */ + life: number; + /** !#en Variation of life. + !#zh 粒子的运行时间变化范围。 */ + lifeVar: number; + /** !#en Start color of each particle. + !#zh 粒子初始颜色。 */ + startColor: Color; + /** !#en Variation of the start color. + !#zh 粒子初始颜色变化范围。 */ + startColorVar: Color; + /** !#en Ending color of each particle. + !#zh 粒子结束颜色。 */ + endColor: Color; + /** !#en Variation of the end color. + !#zh 粒子结束颜色变化范围。 */ + endColorVar: Color; + /** !#en Angle of each particle setter. + !#zh 粒子角度。 */ + angle: number; + /** !#en Variation of angle of each particle setter. + !#zh 粒子角度变化范围。 */ + angleVar: number; + /** !#en Start size in pixels of each particle. + !#zh 粒子的初始大小。 */ + startSize: number; + /** !#en Variation of start size in pixels. + !#zh 粒子初始大小的变化范围。 */ + startSizeVar: number; + /** !#en End size in pixels of each particle. + !#zh 粒子结束时的大小。 */ + endSize: number; + /** !#en Variation of end size in pixels. + !#zh 粒子结束大小的变化范围。 */ + endSizeVar: number; + /** !#en Start angle of each particle. + !#zh 粒子开始自旋角度。 */ + startSpin: number; + /** !#en Variation of start angle. + !#zh 粒子开始自旋角度变化范围。 */ + startSpinVar: number; + /** !#en End angle of each particle. + !#zh 粒子结束自旋角度。 */ + endSpin: number; + /** !#en Variation of end angle. + !#zh 粒子结束自旋角度变化范围。 */ + endSpinVar: number; + /** !#en Source position of the emitter. + !#zh 发射器位置。 */ + sourcePos: Vec2; + /** !#en Variation of source position. + !#zh 发射器位置的变化范围。(横向和纵向) */ + posVar: Vec2; + /** !#en Particles movement type. + !#zh 粒子位置类型。 */ + positionType: ParticleSystem.PositionType; + /** !#en Particles emitter modes. + !#zh 发射器类型。 */ + emitterMode: ParticleSystem.EmitterMode; + /** !#en Gravity of the emitter. + !#zh 重力。 */ + gravity: Vec2; + /** !#en Speed of the emitter. + !#zh 速度。 */ + speed: number; + /** !#en Variation of the speed. + !#zh 速度变化范围。 */ + speedVar: number; + /** !#en Tangential acceleration of each particle. Only available in 'Gravity' mode. + !#zh 每个粒子的切向加速度,即垂直于重力方向的加速度,只有在重力模式下可用。 */ + tangentialAccel: number; + /** !#en Variation of the tangential acceleration. + !#zh 每个粒子的切向加速度变化范围。 */ + tangentialAccelVar: number; + /** !#en Acceleration of each particle. Only available in 'Gravity' mode. + !#zh 粒子径向加速度,即平行于重力方向的加速度,只有在重力模式下可用。 */ + radialAccel: number; + /** !#en Variation of the radial acceleration. + !#zh 粒子径向加速度变化范围。 */ + radialAccelVar: number; + /** !#en Indicate whether the rotation of each particle equals to its direction. Only available in 'Gravity' mode. + !#zh 每个粒子的旋转是否等于其方向,只有在重力模式下可用。 */ + rotationIsDir: boolean; + /** !#en Starting radius of the particles. Only available in 'Radius' mode. + !#zh 初始半径,表示粒子出生时相对发射器的距离,只有在半径模式下可用。 */ + startRadius: number; + /** !#en Variation of the starting radius. + !#zh 初始半径变化范围。 */ + startRadiusVar: number; + /** !#en Ending radius of the particles. Only available in 'Radius' mode. + !#zh 结束半径,只有在半径模式下可用。 */ + endRadius: number; + /** !#en Variation of the ending radius. + !#zh 结束半径变化范围。 */ + endRadiusVar: number; + /** !#en Number of degress to rotate a particle around the source pos per second. Only available in 'Radius' mode. + !#zh 粒子每秒围绕起始点的旋转角度,只有在半径模式下可用。 */ + rotatePerS: number; + /** !#en Variation of the degress to rotate a particle around the source pos per second. + !#zh 粒子每秒围绕起始点的旋转角度变化范围。 */ + rotatePerSVar: number; + /** !#en The Particle emitter lives forever. + !#zh 表示发射器永久存在 */ + static DURATION_INFINITY: number; + /** !#en The starting size of the particle is equal to the ending size. + !#zh 表示粒子的起始大小等于结束大小。 */ + static START_SIZE_EQUAL_TO_END_SIZE: number; + /** !#en The starting radius of the particle is equal to the ending radius. + !#zh 表示粒子的起始半径等于结束半径。 */ + static START_RADIUS_EQUAL_TO_END_RADIUS: number; + /** + !#en Stop emitting particles. Running particles will continue to run until they die. + !#zh 停止发射器发射粒子,发射出去的粒子将继续运行,直至粒子生命结束。 + + @example + ```js + // stop particle system. + myParticleSystem.stopSystem(); + ``` + */ + stopSystem(): void; + /** + !#en Kill all living particles. + !#zh 杀死所有存在的粒子,然后重新启动粒子发射器。 + + @example + ```js + // play particle system. + myParticleSystem.resetSystem(); + ``` + */ + resetSystem(): void; + /** + !#en Whether or not the system is full. + !#zh 发射器中粒子是否大于等于设置的总粒子数量。 + */ + isFull(): boolean; + /** + !#en Sets a new texture with a rect. The rect is in texture position and size. + Please use spriteFrame property instead, this function is deprecated since v1.9 + !#zh 设置一张新贴图和关联的矩形。 + 请直接设置 spriteFrame 属性,这个函数从 v1.9 版本开始已经被废弃 + @param texture texture + @param rect rect + */ + setTextureWithRect(texture: Texture2D, rect: Rect): void; + /** !#en specify the source Blend Factor, this will generate a custom material object, please pay attention to the memory cost. + !#zh 指定原图的混合模式,这会克隆一个新的材质对象,注意这带来的开销 */ + srcBlendFactor: macro.BlendFactor; + /** !#en specify the destination Blend Factor. + !#zh 指定目标的混合模式 */ + dstBlendFactor: macro.BlendFactor; + } + /** !#en cc.VideoPlayer is a component for playing videos, you can use it for showing videos in your game. Because different platforms have different authorization, API and control methods for VideoPlayer component. And have not yet formed a unified standard, only Web, iOS, and Android platforms are currently supported. + !#zh Video 组件,用于在游戏中播放视频。由于不同平台对于 VideoPlayer 组件的授权、API、控制方式都不同,还没有形成统一的标准,所以目前只支持 Web、iOS 和 Android 平台。 */ + export class VideoPlayer extends Component { + /** !#en The resource type of videoplayer, REMOTE for remote url and LOCAL for local file path. + !#zh 视频来源:REMOTE 表示远程视频 URL,LOCAL 表示本地视频地址。 */ + resourceType: VideoPlayer.ResourceType; + /** !#en The remote URL of video. + !#zh 远程视频的 URL */ + remoteURL: string; + /** !#en The local video full path. + !#zh 本地视频的 URL */ + clip: string; + /** !#en The current playback time of the now playing item in seconds, you could also change the start playback time. + !#zh 指定视频从什么时间点开始播放,单位是秒,也可以用来获取当前视频播放的时间进度。 */ + currentTime: number; + /** !#en The volume of the video. + !#zh 视频的音量(0.0 ~ 1.0) */ + volume: number; + /** !#en Mutes the VideoPlayer. Mute sets the volume=0, Un-Mute restore the original volume. + !#zh 是否静音视频。静音时设置音量为 0,取消静音是恢复原来的音量。 */ + mute: boolean; + /** !#en Whether keep the aspect ration of the original video. + !#zh 是否保持视频原来的宽高比 */ + keepAspectRatio: boolean; + /** !#en Whether play video in fullscreen mode. + !#zh 是否全屏播放视频 */ + isFullscreen: boolean; + /** !#en Always below the game view (only useful on Web. Note: The specific effects are not guaranteed to be consistent, depending on whether each browser supports or restricts). + !#zh 永远在游戏视图最底层(这个属性只有在 Web 平台上有效果。注意:具体效果无法保证一致,跟各个浏览器是否支持与限制有关) */ + stayOnBottom: boolean; + /** !#en the video player's callback, it will be triggered when certain event occurs, like: playing, paused, stopped and completed. + !#zh 视频播放回调函数,该回调函数会在特定情况被触发,比如播放中,暂时,停止和完成播放。 */ + videoPlayerEvent: Component.EventHandler[]; + /** + !#en If a video is paused, call this method could resume playing. If a video is stopped, call this method to play from scratch. + !#zh 如果视频被暂停播放了,调用这个接口可以继续播放。如果视频被停止播放了,调用这个接口可以从头开始播放。 + */ + play(): void; + /** + !#en If a video is paused, call this method to resume playing. + !#zh 如果一个视频播放被暂停播放了,调用这个接口可以继续播放。 + */ + resume(): void; + /** + !#en If a video is playing, call this method to pause playing. + !#zh 如果一个视频正在播放,调用这个接口可以暂停播放。 + */ + pause(): void; + /** + !#en If a video is playing, call this method to stop playing immediately. + !#zh 如果一个视频正在播放,调用这个接口可以立马停止播放。 + */ + stop(): void; + /** + !#en Gets the duration of the video + !#zh 获取视频文件的播放总时长 + */ + getDuration(): number; + /** + !#en Determine whether video is playing or not. + !#zh 判断当前视频是否处于播放状态 + */ + isPlaying(): boolean; + /** + !#en if you don't need the VideoPlayer and it isn't in any running Scene, you should + call the destroy method on this component or the associated node explicitly. + Otherwise, the created DOM element won't be removed from web page. + !#zh + 如果你不再使用 VideoPlayer,并且组件未添加到场景中,那么你必须手动对组件或所在节点调用 destroy。 + 这样才能移除网页上的 DOM 节点,避免 Web 平台内存泄露。 + + @example + ```js + videoplayer.node.parent = null; // or videoplayer.node.removeFromParent(false); + // when you don't need videoplayer anymore + videoplayer.node.destroy(); + ``` + */ + destroy(): boolean; + } + /** cc.TMXLayerInfo contains the information about the layers like: + - Layer name + - Layer size + - Layer opacity at creation time (it can be modified at runtime) + - Whether the layer is visible (if it's not visible, then the CocosNode won't be created) + This information is obtained from the TMX file. */ + export class TMXLayerInfo { + /** Properties of the layer info. */ + properties: any; + } + /** cc.TMXImageLayerInfo contains the information about the image layers. + This information is obtained from the TMX file. */ + export class TMXImageLayerInfo { + } + /**

cc.TMXObjectGroupInfo contains the information about the object group like: + - group name + - group size + - group opacity at creation time (it can be modified at runtime) + - Whether the group is visible + + This information is obtained from the TMX file.

*/ + export class TMXObjectGroupInfo { + /** Properties of the ObjectGroup info. */ + properties: any[]; + } + /**

cc.TMXTilesetInfo contains the information about the tilesets like:
+ - Tileset name
+ - Tileset spacing
+ - Tileset margin
+ - size of the tiles
+ - Image used for the tiles
+ - Image size
+ + This information is obtained from the TMX file.

*/ + export class TMXTilesetInfo { + /** Tileset name */ + name: string; + /** First grid */ + firstGid: number; + /** Spacing */ + spacing: number; + /** Margin */ + margin: number; + /** Texture containing the tiles (should be sprite sheet / texture atlas) */ + sourceImage: any; + /** Size in pixels of the image */ + imageSize: Size; + } + /**

cc.TMXMapInfo contains the information about the map like:
+ - Map orientation (hexagonal, isometric or orthogonal)
+ - Tile size
+ - Map size

+ +

And it also contains:
+ - Layers (an array of TMXLayerInfo objects)
+ - Tilesets (an array of TMXTilesetInfo objects)
+ - ObjectGroups (an array of TMXObjectGroupInfo objects)

+ +

This information is obtained from the TMX file.

*/ + export class TMXMapInfo { + /** Properties of the map info. */ + properties: any[]; + /** Map orientation. */ + orientation: number; + /** Parent element. */ + parentElement: any; + /** Parent GID. */ + parentGID: number; + /** Layer attributes. */ + layerAttrs: any; + /** Is reading storing characters stream. */ + storingCharacters: boolean; + /** Current string stored from characters stream. */ + currentString: string; + /** Width of the map */ + mapWidth: number; + /** Height of the map */ + mapHeight: number; + /** Width of a tile */ + tileWidth: number; + /** Height of a tile */ + tileHeight: number; + static ATTRIB_NONE: number; + static ATTRIB_BASE64: number; + static ATTRIB_GZIP: number; + static ATTRIB_ZLIB: number; + } + /** !#en Render the TMX layer. + !#zh 渲染 TMX layer。 */ + export class TiledLayer extends Component { + /** + !#en enable or disable culling + !#zh 开启或关闭裁剪。 + @param value value + */ + enableCulling(value: any): void; + /** + !#en Adds user's node into layer. + !#zh 添加用户节点。 + @param node node + */ + addUserNode(node: Node): boolean; + /** + !#en Removes user's node. + !#zh 移除用户节点。 + @param node node + */ + removeUserNode(node: Node): boolean; + /** + !#en Destroy user's node. + !#zh 销毁用户节点。 + @param node node + */ + destroyUserNode(node: Node): void; + /** + !#en Gets the layer name. + !#zh 获取层的名称。 + + @example + ```js + let layerName = tiledLayer.getLayerName(); + cc.log(layerName); + ``` + */ + getLayerName(): string; + /** + !#en Set the layer name. + !#zh 设置层的名称 + @param layerName layerName + + @example + ```js + tiledLayer.setLayerName("New Layer"); + ``` + */ + SetLayerName(layerName: string): void; + /** + !#en Return the value for the specific property name. + !#zh 获取指定属性名的值。 + @param propertyName propertyName + + @example + ```js + let property = tiledLayer.getProperty("info"); + cc.log(property); + ``` + */ + getProperty(propertyName: string): any; + /** + !#en Returns the position in pixels of a given tile coordinate. + !#zh 获取指定 tile 的像素坐标。 + @param pos position or x + @param y y + + @example + ```js + let pos = tiledLayer.getPositionAt(cc.v2(0, 0)); + cc.log("Pos: " + pos); + let pos = tiledLayer.getPositionAt(0, 0); + cc.log("Pos: " + pos); + ``` + */ + getPositionAt(pos: Vec2|number, y?: number): Vec2; + /** + !#en + Sets the tiles gid (gid = tile global id) at a given tiles rect. + !#zh + 设置给定区域的 tile 的 gid (gid = tile 全局 id), + @param gids an array contains gid + @param beginCol begin col number + @param beginRow begin row number + @param totalCols count of column + + @example + ```js + tiledLayer.setTilesGIDAt([1, 1, 1, 1], 10, 10, 2) + ``` + */ + setTilesGIDAt(gids: any[], beginCol: number, beginRow: number, totalCols: number): void; + /** + !#en + Sets the tile gid (gid = tile global id) at a given tile coordinate.
+ The Tile GID can be obtained by using the method "tileGIDAt" or by using the TMX editor . Tileset Mgr +1.
+ If a tile is already placed at that position, then it will be removed. + !#zh + 设置给定坐标的 tile 的 gid (gid = tile 全局 id), + tile 的 GID 可以使用方法 “tileGIDAt” 来获得。
+ 如果一个 tile 已经放在那个位置,那么它将被删除。 + @param gid gid + @param posOrX position or x + @param flagsOrY flags or y + @param flags flags + + @example + ```js + tiledLayer.setTileGIDAt(1001, 10, 10, 1) + ``` + */ + setTileGIDAt(gid: number, posOrX: Vec2|number, flagsOrY: number, flags?: number): void; + /** + !#en + Returns the tiles data.An array fill with GIDs.
+ !#zh + 返回 tiles 数据. 由GID构成的一个数组.
+ */ + getTiles(): number[]; + /** + !#en + Returns the tile gid at a given tile coordinate.
+ if it returns 0, it means that the tile is empty.
+ !#zh + 通过给定的 tile 坐标、flags(可选)返回 tile 的 GID.
+ 如果它返回 0,则表示该 tile 为空。
+ @param pos or x + @param y y + + @example + ```js + let tileGid = tiledLayer.getTileGIDAt(0, 0); + ``` + */ + getTileGIDAt(pos: Vec2|number, y?: number): number; + /** + !#en Layer orientation, which is the same as the map orientation. + !#zh 获取 Layer 方向(同地图方向)。 + + @example + ```js + let orientation = tiledLayer.getLayerOrientation(); + cc.log("Layer Orientation: " + orientation); + ``` + */ + getLayerOrientation(): number; + /** + !#en properties from the layer. They can be added using Tiled. + !#zh 获取 layer 的属性,可以使用 Tiled 编辑器添加属性。 + + @example + ```js + let properties = tiledLayer.getProperties(); + cc.log("Properties: " + properties); + ``` + */ + getProperties(): any; + /** + !#en + Get the TiledTile with the tile coordinate.
+ If there is no tile in the specified coordinate and forceCreate parameter is true,
+ then will create a new TiledTile at the coordinate. + The renderer will render the tile with the rotation, scale, position and color property of the TiledTile. + !#zh + 通过指定的 tile 坐标获取对应的 TiledTile。
+ 如果指定的坐标没有 tile,并且设置了 forceCreate 那么将会在指定的坐标创建一个新的 TiledTile 。
+ 在渲染这个 tile 的时候,将会使用 TiledTile 的节点的旋转、缩放、位移、颜色属性。
+ @param x x + @param y y + @param forceCreate forceCreate + + @example + ```js + let tile = tiledLayer.getTiledTileAt(100, 100, true); + cc.log(tile); + ``` + */ + getTiledTileAt(x: number, y: number, forceCreate: boolean): TiledTile; + /** + !#en + Change tile to TiledTile at the specified coordinate. + !#zh + 将指定的 tile 坐标替换为指定的 TiledTile。 + @param x x + @param y y + @param tiledTile tiledTile + */ + setTiledTileAt(x: number, y: number, tiledTile: TiledTile): TiledTile; + /** + !#en Return texture. + !#zh 获取纹理。 + @param index The index of textures + */ + getTexture(index: any): Texture2D; + /** + !#en Return texture. + !#zh 获取纹理。 + */ + getTextures(): Texture2D; + /** + !#en Set the texture. + !#zh 设置纹理。 + @param texture texture + */ + setTexture(texture: Texture2D): void; + /** + !#en Set the texture. + !#zh 设置纹理。 + @param textures textures + */ + setTexture(textures: Texture2D): void; + /** + !#en Gets layer size. + !#zh 获得层大小。 + + @example + ```js + let size = tiledLayer.getLayerSize(); + cc.log("layer size: " + size); + ``` + */ + getLayerSize(): Size; + /** + !#en Size of the map's tile (could be different from the tile's size). + !#zh 获取 tile 的大小( tile 的大小可能会有所不同)。 + + @example + ```js + let mapTileSize = tiledLayer.getMapTileSize(); + cc.log("MapTile size: " + mapTileSize); + ``` + */ + getMapTileSize(): Size; + /** + !#en Gets Tile set first information for the layer. + !#zh 获取 layer 索引位置为0的 Tileset 信息。 + @param index The index of tilesets + */ + getTileSet(index: any): TMXTilesetInfo; + /** + !#en Gets tile set all information for the layer. + !#zh 获取 layer 所有的 Tileset 信息。 + */ + getTileSet(): TMXTilesetInfo; + /** + !#en Sets tile set information for the layer. + !#zh 设置 layer 的 tileset 信息。 + @param tileset tileset + */ + setTileSet(tileset: TMXTilesetInfo): void; + /** + !#en Sets Tile set information for the layer. + !#zh 设置 layer 的 Tileset 信息。 + @param tilesets tilesets + */ + setTileSets(tilesets: TMXTilesetInfo): void; + } + /** !#en Renders a TMX Tile Map in the scene. + !#zh 在场景中渲染一个 tmx 格式的 Tile Map。 */ + export class TiledMap extends Component { + /** !#en The TiledMap Asset. + !#zh TiledMap 资源。 */ + tmxAsset: TiledMapAsset; + /** + !#en Gets the map size. + !#zh 获取地图大小。 + + @example + ```js + let mapSize = tiledMap.getMapSize(); + cc.log("Map Size: " + mapSize); + ``` + */ + getMapSize(): Size; + /** + !#en Gets the tile size. + !#zh 获取地图背景中 tile 元素的大小。 + + @example + ```js + let tileSize = tiledMap.getTileSize(); + cc.log("Tile Size: " + tileSize); + ``` + */ + getTileSize(): Size; + /** + !#en map orientation. + !#zh 获取地图方向。 + + @example + ```js + let mapOrientation = tiledMap.getMapOrientation(); + cc.log("Map Orientation: " + mapOrientation); + ``` + */ + getMapOrientation(): number; + /** + !#en object groups. + !#zh 获取所有的对象层。 + + @example + ```js + let objGroups = titledMap.getObjectGroups(); + for (let i = 0; i < objGroups.length; ++i) { + cc.log("obj: " + objGroups[i]); + } + ``` + */ + getObjectGroups(): TiledObjectGroup[]; + /** + !#en Return the TMXObjectGroup for the specific group. + !#zh 获取指定的 TMXObjectGroup。 + @param groupName groupName + + @example + ```js + let group = titledMap.getObjectGroup("Players"); + cc.log("ObjectGroup: " + group); + ``` + */ + getObjectGroup(groupName: string): TiledObjectGroup; + /** + !#en enable or disable culling + !#zh 开启或关闭裁剪。 + @param value value + */ + enableCulling(value: any): void; + /** + !#en Gets the map properties. + !#zh 获取地图的属性。 + + @example + ```js + let properties = titledMap.getProperties(); + for (let i = 0; i < properties.length; ++i) { + cc.log("Properties: " + properties[i]); + } + ``` + */ + getProperties(): any[]; + /** + !#en Return All layers array. + !#zh 返回包含所有 layer 的数组。 + + @example + ```js + let layers = titledMap.getLayers(); + for (let i = 0; i < layers.length; ++i) { + cc.log("Layers: " + layers[i]); + } + ``` + */ + getLayers(): TiledLayer[]; + /** + !#en return the cc.TiledLayer for the specific layer. + !#zh 获取指定名称的 layer。 + @param layerName layerName + + @example + ```js + let layer = titledMap.getLayer("Player"); + cc.log(layer); + ``` + */ + getLayer(layerName: string): TiledLayer; + /** + !#en Return the value for the specific property name. + !#zh 通过属性名称,获取指定的属性。 + @param propertyName propertyName + + @example + ```js + let property = titledMap.getProperty("info"); + cc.log("Property: " + property); + ``` + */ + getProperty(propertyName: string): string; + /** + !#en Return properties dictionary for tile GID. + !#zh 通过 GID ,获取指定的属性。 + @param GID GID + + @example + ```js + let properties = titledMap.getPropertiesForGID(GID); + cc.log("Properties: " + properties); + ``` + */ + getPropertiesForGID(GID: number): any; + } + /** Class for tiled map asset handling. */ + export class TiledMapAsset extends Asset { + textures: Texture2D[]; + textureNames: string[]; + textureSizes: Size[]; + imageLayerTextures: Texture2D[]; + imageLayerTextureNames: string[]; + } + /** !#en Renders the TMX object group. + !#zh 渲染 tmx object group。 */ + export class TiledObjectGroup extends Component { + /** + !#en Offset position of child objects. + !#zh 获取子对象的偏移位置。 + + @example + ```js + let offset = tMXObjectGroup.getPositionOffset(); + ``` + */ + getPositionOffset(): Vec2; + /** + !#en List of properties stored in a dictionary. + !#zh 以映射的形式获取属性列表。 + + @example + ```js + let offset = tMXObjectGroup.getProperties(); + ``` + */ + getProperties(): any; + /** + !#en Gets the Group name. + !#zh 获取组名称。 + + @example + ```js + let groupName = tMXObjectGroup.getGroupName; + ``` + */ + getGroupName(): string; + /** + !#en + Return the object for the specific object name.
+ It will return the 1st object found on the array for the given name. + !#zh 获取指定的对象。 + @param objectName objectName + + @example + ```js + let object = tMXObjectGroup.getObject("Group"); + ``` + */ + getObject(objectName: string): any; + /** + !#en Gets the objects. + !#zh 获取对象数组。 + + @example + ```js + let objects = tMXObjectGroup.getObjects(); + ``` + */ + getObjects(): any[]; + } + /** !#en TiledTile can control the specified map tile. + It will apply the node rotation, scale, translate to the map tile. + You can change the TiledTile's gid to change the map tile's style. + !#zh TiledTile 可以单独对某一个地图块进行操作。 + 他会将节点的旋转,缩放,平移操作应用在这个地图块上,并可以通过更换当前地图块的 gid 来更换地图块的显示样式。 */ + export class TiledTile extends Component { + /** !#en Specify the TiledTile horizontal coordinate,use map tile as the unit. + !#zh 指定 TiledTile 的横向坐标,以地图块为单位 */ + x: number; + /** !#en Specify the TiledTile vertical coordinate,use map tile as the unit. + !#zh 指定 TiledTile 的纵向坐标,以地图块为单位 */ + y: number; + /** !#en Specify the TiledTile gid. + !#zh 指定 TiledTile 的 gid 值 */ + gid: number; + } + /** !#en cc.WebView is a component for display web pages in the game. Because different platforms have different authorization, API and control methods for WebView component. And have not yet formed a unified standard, only Web, iOS, and Android platforms are currently supported. + !#zh WebView 组件,用于在游戏中显示网页。由于不同平台对于 WebView 组件的授权、API、控制方式都不同,还没有形成统一的标准,所以目前只支持 Web、iOS 和 Android 平台。 */ + export class WebView extends Component { + /** !#en A given URL to be loaded by the WebView, it should have a http or https prefix. + !#zh 指定 WebView 加载的网址,它应该是一个 http 或者 https 开头的字符串 */ + url: string; + /** !#en The webview's event callback , it will be triggered when certain webview event occurs. + !#zh WebView 的回调事件,当网页加载过程中,加载完成后或者加载出错时都会回调此函数 */ + webviewLoadedEvents: Component.EventHandler[]; + /** + !#en + Set javascript interface scheme (see also setOnJSCallback).
+ Note: Supports only on the Android and iOS. For HTML5, please refer to the official documentation.
+ Please refer to the official documentation for more details. + !#zh + 设置 JavaScript 接口方案(与 'setOnJSCallback' 配套使用)。
+ 注意:只支持 Android 和 iOS ,Web 端用法请前往官方文档查看。
+ 详情请参阅官方文档 + @param scheme scheme + */ + setJavascriptInterfaceScheme(scheme: string): void; + /** + !#en + This callback called when load URL that start with javascript + interface scheme (see also setJavascriptInterfaceScheme).
+ Note: Supports only on the Android and iOS. For HTML5, please refer to the official documentation.
+ Please refer to the official documentation for more details. + !#zh + 当加载 URL 以 JavaScript 接口方案开始时调用这个回调函数。
+ 注意:只支持 Android 和 iOS,Web 端用法请前往官方文档查看。 + 详情请参阅官方文档 + @param callback callback + */ + setOnJSCallback(callback: Function): void; + /** + !#en + Evaluates JavaScript in the context of the currently displayed page.
+ Please refer to the official document for more details
+ Note: Cross domain issues need to be resolved by yourself
+ !#zh + 执行 WebView 内部页面脚本(详情请参阅官方文档)
+ 注意:需要自行解决跨域问题 + @param str str + */ + evaluateJS(str: string): void; + /** + !#en if you don't need the WebView and it isn't in any running Scene, you should + call the destroy method on this component or the associated node explicitly. + Otherwise, the created DOM element won't be removed from web page. + !#zh + 如果你不再使用 WebView,并且组件未添加到场景中,那么你必须手动对组件或所在节点调用 destroy。 + 这样才能移除网页上的 DOM 节点,避免 Web 平台内存泄露。 + + @example + ```js + webview.node.parent = null; // or webview.node.removeFromParent(false); + // when you don't need webview anymore + webview.node.destroy(); + ``` + */ + destroy(): boolean; + } + /** !#en + cc.NodePool is the cache pool designed for node type.
+ It can helps you to improve your game performance for objects which need frequent release and recreate operations
+ + It's recommended to create cc.NodePool instances by node type, the type corresponds to node type in game design, not the class, + for example, a prefab is a specific node type.
+ When you create a node pool, you can pass a Component which contains `unuse`, `reuse` functions to control the content of node.
+ + Some common use case is :
+ 1. Bullets in game (die very soon, massive creation and recreation, no side effect on other objects)
+ 2. Blocks in candy crash (massive creation and recreation)
+ etc... + !#zh + cc.NodePool 是用于管理节点对象的对象缓存池。
+ 它可以帮助您提高游戏性能,适用于优化对象的反复创建和销毁
+ 以前 cocos2d-x 中的 cc.pool 和新的节点事件注册系统不兼容,因此请使用 cc.NodePool 来代替。 + + 新的 NodePool 需要实例化之后才能使用,每种不同的节点对象池需要一个不同的对象池实例,这里的种类对应于游戏中的节点设计,一个 prefab 相当于一个种类的节点。
+ 在创建缓冲池时,可以传入一个包含 unuse, reuse 函数的组件类型用于节点的回收和复用逻辑。
+ + 一些常见的用例是:
+ 1.在游戏中的子弹(死亡很快,频繁创建,对其他对象无副作用)
+ 2.糖果粉碎传奇中的木块(频繁创建)。 + 等等.... */ + export class NodePool { + /** + !#en + Constructor for creating a pool for a specific node template (usually a prefab). You can pass a component (type or name) argument for handling event for reusing and recycling node. + !#zh + 使用构造函数来创建一个节点专用的对象池,您可以传递一个组件类型或名称,用于处理节点回收和复用时的事件逻辑。 + @param poolHandlerComp !#en The constructor or the class name of the component to control the unuse/reuse logic. !#zh 处理节点回收和复用事件逻辑的组件类型或名称。 + + @example + ```js + properties: { + template: cc.Prefab + }, + onLoad () { + // MyTemplateHandler is a component with 'unuse' and 'reuse' to handle events when node is reused or recycled. + this.myPool = new cc.NodePool('MyTemplateHandler'); + } + ``` + */ + constructor(poolHandlerComp?: {prototype: Component}|string); + /** !#en The pool handler component, it could be the class name or the constructor. + !#zh 缓冲池处理组件,用于节点的回收和复用逻辑,这个属性可以是组件类名或组件的构造函数。 */ + poolHandlerComp: Function|string; + /** + !#en The current available size in the pool + !#zh 获取当前缓冲池的可用对象数量 + */ + size(): number; + /** + !#en Destroy all cached nodes in the pool + !#zh 销毁对象池中缓存的所有节点 + */ + clear(): void; + /** + !#en Put a new Node into the pool. + It will automatically remove the node from its parent without cleanup. + It will also invoke unuse method of the poolHandlerComp if exist. + !#zh 向缓冲池中存入一个不再需要的节点对象。 + 这个函数会自动将目标节点从父节点上移除,但是不会进行 cleanup 操作。 + 这个函数会调用 poolHandlerComp 的 unuse 函数,如果组件和函数都存在的话。 + @param obj obj + + @example + ```js + let myNode = cc.instantiate(this.template); + this.myPool.put(myNode); + ``` + */ + put(obj: Node): void; + /** + !#en Get a obj from pool, if no available object in pool, null will be returned. + This function will invoke the reuse function of poolHandlerComp if exist. + !#zh 获取对象池中的对象,如果对象池没有可用对象,则返回空。 + 这个函数会调用 poolHandlerComp 的 reuse 函数,如果组件和函数都存在的话。 + @param params !#en Params to pass to 'reuse' method in poolHandlerComp !#zh 向 poolHandlerComp 中的 'reuse' 函数传递的参数 + + @example + ```js + let newNode = this.myPool.get(); + ``` + */ + get(...params: any[]): Node; + } + /** !#en + Camera is usefull when making reel game or other games which need scroll screen. + Using camera will be more efficient than moving node to scroll screen. + Camera + !#zh + 摄像机在制作卷轴或是其他需要移动屏幕的游戏时比较有用,使用摄像机将会比移动节点来移动屏幕更加高效。 */ + export class Camera extends Component { + /** !#en + The camera zoom ratio, only support 2D camera. + !#zh + 摄像机缩放比率, 只支持 2D camera。 */ + zoomRatio: number; + /** !#en + Field of view. The width of the Camera’s view angle, measured in degrees along the local Y axis. + !#zh + 决定摄像机视角的宽度,当摄像机处于透视投影模式下这个属性才会生效。 */ + fov: number; + /** !#en + The viewport size of the Camera when set to orthographic projection. + !#zh + 摄像机在正交投影模式下的视窗大小。 */ + orthoSize: number; + /** !#en + The near clipping plane. + !#zh + 摄像机的近剪裁面。 */ + nearClip: number; + /** !#en + The far clipping plane. + !#zh + 摄像机的远剪裁面。 */ + farClip: number; + /** !#en + Is the camera orthographic (true) or perspective (false)? + !#zh + 设置摄像机的投影模式是正交还是透视模式。 */ + ortho: boolean; + /** !#en + Four values (0 ~ 1) that indicate where on the screen this camera view will be drawn. + !#zh + 决定摄像机绘制在屏幕上哪个位置,值为(0 ~ 1)。 */ + rect: Rect; + /** !#en + This is used to render parts of the scene selectively. + !#zh + 决定摄像机会渲染场景的哪一部分。 */ + cullingMask: number; + /** !#en + Determining what to clear when camera rendering. + !#zh + 决定摄像机渲染时会清除哪些状态。 */ + clearFlags: Camera.ClearFlags; + /** !#en + The color with which the screen will be cleared. + !#zh + 摄像机用于清除屏幕的背景色。 */ + backgroundColor: Color; + /** !#en + Camera's depth in the camera rendering order. Cameras with higher depth are rendered after cameras with lower depth. + !#zh + 摄像机深度。用于决定摄像机的渲染顺序,值越大渲染在越上层。 */ + depth: number; + /** !#en + Destination render texture. + Usually cameras render directly to screen, but for some effects it is useful to make a camera render into a texture. + !#zh + 摄像机渲染的目标 RenderTexture。 + 一般摄像机会直接渲染到屏幕上,但是有一些效果可以使用摄像机渲染到 RenderTexture 上再对 RenderTexture 进行处理来实现。 */ + targetTexture: RenderTexture; + /** !#en + Sets the camera's render stages. + !#zh + 设置摄像机渲染的阶段 */ + renderStages: number; + /** !#en Whether auto align camera viewport to screen + !#zh 是否自动将摄像机的视口对准屏幕 */ + alignWithScreen: boolean; + /** !#en + The primary camera in the scene. Returns the rear most rendered camera, which is the camera with the lowest depth. + !#zh + 当前场景中激活的主摄像机。将会返回渲染在屏幕最底层,也就是 depth 最小的摄像机。 */ + static main: Camera; + /** !#en + All enabled cameras. + !#zh + 当前激活的所有摄像机。 */ + static cameras: Camera[]; + /** + !#en + Get the first camera which the node belong to. + !#zh + 获取节点所在的第一个摄像机。 + @param node node + */ + static findCamera(node: Node): Camera; + /** + !#en + Get the screen to world matrix, only support 2D camera which alignWithScreen is true. + !#zh + 获取屏幕坐标系到世界坐标系的矩阵,只适用于 alignWithScreen 为 true 的 2D 摄像机。 + @param out the matrix to receive the result + */ + getScreenToWorldMatrix2D(out: Mat4): Mat4; + /** + !#en + Get the world to camera matrix, only support 2D camera which alignWithScreen is true. + !#zh + 获取世界坐标系到摄像机坐标系的矩阵,只适用于 alignWithScreen 为 true 的 2D 摄像机。 + @param out the matrix to receive the result + */ + getWorldToScreenMatrix2D(out: Mat4): Mat4; + /** + !#en + Convert point from screen to world. + !#zh + 将坐标从屏幕坐标系转换到世界坐标系。 + @param screenPosition screenPosition + @param out out + */ + getScreenToWorldPoint(screenPosition: Vec3|Vec2, out?: Vec3|Vec2): Vec3; + /** + !#en + Convert point from world to screen. + !#zh + 将坐标从世界坐标系转化到屏幕坐标系。 + @param worldPosition worldPosition + @param out out + */ + getWorldToScreenPoint(worldPosition: Vec3|Vec2, out?: Vec3|Vec2): Vec3; + /** + !#en + Get a ray from screen position + !#zh + 从屏幕坐标获取一条射线 + @param screenPos screenPos + */ + getRay(screenPos: Vec2): geomUtils.Ray; + /** + !#en + Check whether the node is in the camera. + !#zh + 检测节点是否被此摄像机影响 + @param node the node which need to check + */ + containsNode(node: Node): boolean; + /** + !#en + Render the camera manually. + !#zh + 手动渲染摄像机。 + @param rootNode rootNode + */ + render(rootNode?: Node): void; + /** + !#en + Returns the matrix that transform the node's (local) space coordinates into the camera's space coordinates. + !#zh + 返回一个将节点坐标系转换到摄像机坐标系下的矩阵 + @param node the node which should transform + */ + getNodeToCameraTransform(node: Node): AffineTransform; + /** + !#en + Conver a camera coordinates point to world coordinates. + !#zh + 将一个摄像机坐标系下的点转换到世界坐标系下。 + @param point the point which should transform + @param out the point to receive the result + */ + getCameraToWorldPoint(point: Vec2, out?: Vec2): Vec2; + /** + !#en + Conver a world coordinates point to camera coordinates. + !#zh + 将一个世界坐标系下的点转换到摄像机坐标系下。 + @param point point + @param out the point to receive the result + */ + getWorldToCameraPoint(point: Vec2, out?: Vec2): Vec2; + /** + !#en + Get the camera to world matrix + !#zh + 获取摄像机坐标系到世界坐标系的矩阵 + @param out the matrix to receive the result + */ + getCameraToWorldMatrix(out: Mat4): Mat4; + /** + !#en + Get the world to camera matrix + !#zh + 获取世界坐标系到摄像机坐标系的矩阵 + @param out the matrix to receive the result + */ + getWorldToCameraMatrix(out: Mat4): Mat4; + } + /** !#en + This module controls asset's behaviors and information, include loading, releasing etc. it is a singleton + All member can be accessed with `cc.assetManager`. + + !#zh + 此模块管理资源的行为和信息,包括加载,释放等,这是一个单例,所有成员能够通过 `cc.assetManager` 调用 */ + export class AssetManager { + /** !#en + Normal loading pipeline + + !#zh + 正常加载管线 */ + pipeline: cc.AssetManager.Pipeline; + /** !#en + Fetching pipeline + + !#zh + 下载管线 */ + fetchPipeline: cc.AssetManager.Pipeline; + /** !#en + Url transformer + + !#zh + Url 转换器 */ + transformPipeline: cc.AssetManager.Pipeline; + /** !#en + The collection of bundle which is already loaded, you can remove cache with {{#crossLink "AssetManager/removeBundle:method"}}{{/crossLink}} + + !#zh + 已加载 bundle 的集合, 你能通过 {{#crossLink "AssetManager/removeBundle:method"}}{{/crossLink}} 来移除缓存 */ + bundles: AssetManager.Cache; + /** !#en + The collection of asset which is already loaded, you can remove cache with {{#crossLink "AssetManager/releaseAsset:method"}}{{/crossLink}} + + !#zh + 已加载资源的集合, 你能通过 {{#crossLink "AssetManager/releaseAsset:method"}}{{/crossLink}} 来移除缓存 */ + assets: AssetManager.Cache; + /** !#en + Manage relationship between asset and its dependencies + + !#zh + 管理资源依赖关系 */ + dependUtil: cc.AssetManager.DependUtil; + /** !#en + Whether or not cache the loaded asset + + !#zh + 是否缓存已加载的资源 */ + cacheAsset: boolean; + /** !#en + Whether or not load asset forcely, if it is true, asset will be loaded regardless of error + + !#zh + 是否强制加载资源, 如果为 true ,加载资源将会忽略报错 */ + force: boolean; + /** !#en + Some useful function + + !#zh + 一些有用的方法 */ + utils: cc.AssetManager.Helper; + /** !#en + Manage all downloading task + + !#zh + 管理所有下载任务 */ + downloader: cc.AssetManager.Downloader; + /** !#en + Manage all parsing task + + !#zh + 管理所有解析任务 */ + parser: cc.AssetManager.Parser; + /** !#en + Manage internal asset + + !#zh + 管理内置资源 */ + builtins: cc.AssetManager.Builtins; + /** !#en + Manage all packed asset + + !#zh + 管理所有合并后的资源 */ + packManager: cc.AssetManager.PackManager; + /** !#en + Cache manager is a module which controls all caches downloaded from server in non-web platform. + + !#zh + 缓存管理器是一个模块,在非 WEB 平台上,用于管理所有从服务器上下载下来的缓存 */ + cacheManager: cc.AssetManager.CacheManager|null; + /** !#en + The preset of options + + !#zh + 可选参数的预设集 */ + presets: Record>; + /** !#en + The builtin 'main' bundle + + !#zh + 内置 main 包 */ + main: cc.AssetManager.Bundle; + /** !#en + The builtin 'resources' bundle + + !#zh + 内置 resources 包 */ + resources: cc.AssetManager.Bundle; + /** !#en + The builtin 'internal' bundle + + !#zh + 内置 internal 包 */ + internal: cc.AssetManager.Bundle; + /** + !#en + Initialize assetManager with options + + !#zh + 初始化资源管理器 + @param options options + */ + init(options: Record): void; + /** + !#en + Get the bundle which has been loaded + + !#zh + 获取已加载的分包 + @param name The name of bundle + + @example + ```js + // ${project}/assets/test1 + cc.assetManager.getBundle('test1'); + + cc.assetManager.getBundle('resources'); + ``` + */ + getBundle (name: string): cc.AssetManager.Bundle; + /** + !#en + Remove this bundle. NOTE: The asset whthin this bundle will not be released automatically, you can call {{#crossLink "Bundle/releaseAll:method"}}{{/crossLink}} manually before remove it if you need + + !#zh + 移除此包, 注意:这个包内的资源不会自动释放, 如果需要的话你可以在摧毁之前手动调用 {{#crossLink "Bundle/releaseAll:method"}}{{/crossLink}} 进行释放 + @param bundle The bundle to be removed + */ + removeBundle(bundle: cc.AssetManager.Bundle): void; + /** + !#en + General interface used to load assets with a progression callback and a complete callback. You can achieve almost all effect you want with combination of `requests` and `options`. + It is highly recommended that you use more simple API, such as `load`, `loadDir` etc. Every custom parameter in `options` will be distribute to each of `requests`. + if request already has same one, the parameter in request will be given priority. Besides, if request has dependencies, `options` will distribute to dependencies too. + Every custom parameter in `requests` will be tranfered to handler of `downloader` and `parser` as `options`. + You can register you own handler downloader or parser to collect these custom parameters for some effect. + + Reserved Keyword: `uuid`, `url`, `path`, `dir`, `scene`, `type`, `priority`, `preset`, `audioLoadMode`, `ext`, `bundle`, `onFileProgress`, `maxConcurrency`, `maxRequestsPerFrame` + `maxRetryCount`, `version`, `responseType`, `withCredentials`, `mimeType`, `timeout`, `header`, `reload`, `cacheAsset`, `cacheEnabled`, + Please DO NOT use these words as custom options! + + !#zh + 通用加载资源接口,可传入进度回调以及完成回调,通过组合 `request` 和 `options` 参数,几乎可以实现和扩展所有想要的加载效果。非常建议你使用更简单的API,例如 `load`、`loadDir` 等。 + `options` 中的自定义参数将会分发到 `requests` 的每一项中,如果request中已存在同名的参数则以 `requests` 中为准,同时如果有其他 + 依赖资源,则 `options` 中的参数会继续向依赖项中分发。request中的自定义参数都会以 `options` 形式传入加载流程中的 `downloader`, `parser` 的方法中, 你可以 + 扩展 `downloader`, `parser` 收集参数完成想实现的效果。 + + 保留关键字: `uuid`, `url`, `path`, `dir`, `scene`, `type`, `priority`, `preset`, `audioLoadMode`, `ext`, `bundle`, `onFileProgress`, `maxConcurrency`, `maxRequestsPerFrame` + `maxRetryCount`, `version`, `responseType`, `withCredentials`, `mimeType`, `timeout`, `header`, `reload`, `cacheAsset`, `cacheEnabled`, + 请不要使用这些字段为自定义参数! + @param requests The request you want to load + @param options Optional parameters + @param onProgress Callback invoked when progression change + @param onComplete Callback invoked when finish loading + + @example + ```js + cc.assetManager.loadAny({url: 'http://example.com/a.png'}, (err, img) => cc.log(img)); + cc.assetManager.loadAny(['60sVXiTH1D/6Aft4MRt9VC'], (err, assets) => cc.log(assets)); + cc.assetManager.loadAny([{ uuid: '0cbZa5Y71CTZAccaIFluuZ'}, {url: 'http://example.com/a.png'}], (err, assets) => cc.log(assets)); + cc.assetManager.downloader.register('.asset', (url, options, onComplete) => { + url += '?userName=' + options.userName + "&password=" + options.password; + cc.assetManager.downloader.downloadFile(url, null, onComplete); + }); + cc.assetManager.parser.register('.asset', (file, options, onComplete) => { + var json = JSON.parse(file); + var skin = json[options.skin]; + var model = json[options.model]; + onComplete(null, {skin, model}); + }); + cc.assetManager.loadAny({ url: 'http://example.com/my.asset', skin: 'xxx', model: 'xxx', userName: 'xxx', password: 'xxx' }); + ``` + */ + loadAny(requests: string | string[] | Record | Record[], options: Record, onProgress: (finished: number, total: number, item: cc.AssetManager.RequestItem) => void, onComplete: (err: Error, data: any) => void): void; + loadAny(requests: string | string[] | Record | Record[], onProgress: (finished: number, total: number, item: cc.AssetManager.RequestItem) => void, onComplete: (err: Error, data: any) => void): void; + loadAny(requests: string | string[] | Record | Record[], options: Record, onComplete: (err: Error, data: any) => void): void; + loadAny(requests: string | string[] | Record | Record[], onComplete: (err: Error, data: any) => void): void; + loadAny(requests: string | string[] | Record | Record[], options: Record): void; + loadAny(requests: string | string[] | Record | Record[]): void; + /** + !#en + General interface used to preload assets with a progression callback and a complete callback.It is highly recommended that you use more simple API, such as `preloadRes`, `preloadResDir` etc. + Everything about preload is just likes `cc.assetManager.loadAny`, the difference is `cc.assetManager.preloadAny` will only download asset but not parse asset. You need to invoke `cc.assetManager.loadAny(preloadTask)` + to finish loading asset + + !#zh + 通用预加载资源接口,可传入进度回调以及完成回调,非常建议你使用更简单的 API ,例如 `preloadRes`, `preloadResDir` 等。`preloadAny` 和 `loadAny` 几乎一样,区别在于 `preloadAny` 只会下载资源,不会去解析资源,你需要调用 `cc.assetManager.loadAny(preloadTask)` + 来完成资源加载。 + @param requests The request you want to preload + @param options Optional parameters + @param onProgress Callback invoked when progression change + @param onComplete Callback invoked when finish preloading + + @example + ```js + cc.assetManager.preloadAny('0cbZa5Y71CTZAccaIFluuZ', (err) => cc.assetManager.loadAny('0cbZa5Y71CTZAccaIFluuZ')); + ``` + */ + preloadAny(requests: string | string[] | Record | Record[], options: Record, onProgress: (finished: number, total: number, item: cc.AssetManager.RequestItem) => void, onComplete: (err: Error, items: cc.AssetManager.RequestItem[]) => void): void; + preloadAny(requests: string | string[] | Record | Record[], onProgress: (finished: number, total: number, item: cc.AssetManager.RequestItem) => void, onComplete: (err: Error, items: cc.AssetManager.RequestItem[]) => void): void; + preloadAny(requests: string | string[] | Record | Record[], options: Record, onComplete: (err: Error, items: cc.AssetManager.RequestItem[]) => void): void; + preloadAny(requests: string | string[] | Record | Record[], onComplete: (err: Error, items: cc.AssetManager.RequestItem[]) => void): void; + preloadAny(requests: string | string[] | Record | Record[], options: Record): void; + preloadAny(requests: string | string[] | Record | Record[]): void; + /** + !#en + Load native file of asset, if you check the option 'Async Load Assets', you may need to load native file with this before you use the asset + + !#zh + 加载资源的原生文件,如果你勾选了'延迟加载资源'选项,你可能需要在使用资源之前调用此方法来加载原生文件 + @param asset The asset + @param options Some optional parameters + @param onComplete Callback invoked when finish loading + + @example + ```js + cc.assetManager.postLoadNative(texture, (err) => console.log(err)); + ``` + */ + postLoadNative(asset: cc.Asset, options: Record, onComplete: (err: Error) => void): void; + postLoadNative(asset: cc.Asset, onComplete: (err: Error) => void): void; + postLoadNative(asset: cc.Asset, options: Record): void; + postLoadNative(asset: cc.Asset): void; + /** + !#en + Load remote asset with url, such as audio, image, text and so on. + + !#zh + 使用 url 加载远程资源,例如音频,图片,文本等等。 + @param url The url of asset + @param options Some optional parameters + @param onComplete Callback invoked when finish loading + + @example + ```js + cc.assetManager.loadRemote('http://www.cloud.com/test1.jpg', (err, texture) => console.log(err)); + cc.assetManager.loadRemote('http://www.cloud.com/test2.mp3', (err, audioClip) => console.log(err)); + cc.assetManager.loadRemote('http://www.cloud.com/test3', { ext: '.png' }, (err, texture) => console.log(err)); + ``` + */ + loadRemote(url: string, options: Record, onComplete: (err: Error, asset: T) => void): void; + loadRemote(url: string, onComplete: (err: Error, asset: T) => void): void; + loadRemote(url: string, options: Record): void; + loadRemote(url: string): void; + /** + !#en + Load script + + !#zh + 加载脚本 + @param url Url of the script + @param options Some optional paramters + @param onComplete Callback when script loaded or failed + + @example + ```js + loadScript('http://localhost:8080/index.js', null, (err) => console.log(err)); + ``` + */ + loadScript(url: string|string[], options: Record, onComplete: (err: Error) => void): void;; + loadScript(url: string|string[], onComplete: (err: Error) => void): void;; + loadScript(url: string|string[], options: Record): void;; + loadScript(url: string|string[]): void;; + /** + !#en + load bundle + + !#zh + 加载资源包 + @param nameOrUrl The name or root path of bundle + @param options Some optional paramter, same like downloader.downloadFile + @param onComplete Callback when bundle loaded or failed + + @example + ```js + loadBundle('http://localhost:8080/test', null, (err, bundle) => console.log(err)); + ``` + */ + loadBundle(nameOrUrl: string, options: Record, onComplete: (err: Error, bundle: cc.AssetManager.Bundle) => void): void; + loadBundle(nameOrUrl: string, onComplete: (err: Error, bundle: cc.AssetManager.Bundle) => void): void; + loadBundle(nameOrUrl: string, options: Record): void; + loadBundle(nameOrUrl: string): void; + /** + !#en + Release asset and it's dependencies. + This method will not only remove the cache of the asset in assetManager, but also clean up its content. + For example, if you release a texture, the texture asset and its gl texture data will be freed up. + Notice, this method may cause the texture to be unusable, if there are still other nodes use the same texture, they may turn to black and report gl errors. + + !#zh + 释放资源以及其依赖资源, 这个方法不仅会从 assetManager 中删除资源的缓存引用,还会清理它的资源内容。 + 比如说,当你释放一个 texture 资源,这个 texture 和它的 gl 贴图数据都会被释放。 + 注意,这个函数可能会导致资源贴图或资源所依赖的贴图不可用,如果场景中存在节点仍然依赖同样的贴图,它们可能会变黑并报 GL 错误。 + @param asset The asset to be released + + @example + ```js + // release a texture which is no longer need + cc.assetManager.releaseAsset(texture); + ``` + */ + releaseAsset(asset: cc.Asset): void; + /** + !#en + Release all assets. Refer to {{#crossLink "AssetManager/releaseAsset:method"}}{{/crossLink}} for detailed informations. + + !#zh + 释放所有资源。详细信息请参考 {{#crossLink "AssetManager/releaseAsset:method"}}{{/crossLink}} + */ + releaseAll(): void; + } + /** `cc.loader` is deprecated, please backup your project and upgrade to {{#crossLink "AssetManager"}}{{/crossLink}} */ + export class loader { + /** `cc.loader.onProgress` is deprecated, please transfer onProgress to API as a parameter */ + static onProgress: any; + /** + `cc.loader.load` is deprecated, please use {{#crossLink "AssetManager/loadAny:method"}}{{/crossLink}} instead + @param resources Url list in an array + @param progressCallback Callback invoked when progression change + @param completeCallback Callback invoked when all resources loaded + */ + static load(resources: string|string[]|{uuid?: string, url?: string, type?: string}, completeCallback?: Function): void; + static load(resources: string|string[]|{uuid?: string, url?: string, type?: string}, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: Function|null): void; + /** + `cc.loader.getXMLHttpRequest` is deprecated, please use `XMLHttpRequest` directly + */ + static getXMLHttpRequest(): XMLHttpRequest; + /** + `cc.loader.getItem` is deprecated, please use `cc.assetManager.asset.get` instead + @param id The id of the item + */ + static getItem(id: any): any; + /** + `cc.loader.loadRes` is deprecated, please use {{#crossLink "Bundle/load:method"}}{{/crossLink}} instead + @param url Url of the target resource. + The url is relative to the "resources" folder, extensions must be omitted. + @param type Only asset of type will be loaded if this argument is supplied. + @param progressCallback Callback invoked when progression change. + @param completeCallback Callback invoked when the resource loaded. + */ + static loadRes(url: string, type: typeof cc.Asset, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any) => void)|null): void; + static loadRes(url: string, type: typeof cc.Asset, completeCallback: (error: Error, resource: any) => void): void; + static loadRes(url: string, type: typeof cc.Asset): void; + static loadRes(url: string, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any) => void)|null): void; + static loadRes(url: string, completeCallback: (error: Error, resource: any) => void): void; + static loadRes(url: string): void; + /** + `cc.loader.loadResArray` is deprecated, please use {{#crossLink "Bundle/load:method"}}{{/crossLink}} instead + @param urls Array of URLs of the target resource. + The url is relative to the "resources" folder, extensions must be omitted. + @param type Only asset of type will be loaded if this argument is supplied. + @param progressCallback Callback invoked when progression change. + @param completeCallback A callback which is called when all assets have been loaded, or an error occurs. + */ + static loadResArray(url: string[], type: typeof cc.Asset, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any[]) => void)|null): void; + static loadResArray(url: string[], type: typeof cc.Asset, completeCallback: (error: Error, resource: any[]) => void): void; + static loadResArray(url: string[], type: typeof cc.Asset): void; + static loadResArray(url: string[], progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any[]) => void)|null): void; + static loadResArray(url: string[], completeCallback: (error: Error, resource: any[]) => void): void; + static loadResArray(url: string[]): void; + static loadResArray(url: string[], type: typeof cc.Asset[]): void; + /** + `cc.loader.loadResDir` is deprecated, please use {{#crossLink "Bundle/loadDir:method"}}{{/crossLink}} instead + @param url Url of the target folder. + The url is relative to the "resources" folder, extensions must be omitted. + @param type Only asset of type will be loaded if this argument is supplied. + @param progressCallback Callback invoked when progression change. + @param completeCallback A callback which is called when all assets have been loaded, or an error occurs. + */ + static loadResDir(url: string, type: typeof cc.Asset, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any[], urls: string[]) => void)|null): void; + static loadResDir(url: string, type: typeof cc.Asset, completeCallback: (error: Error, resource: any[], urls: string[]) => void): void; + static loadResDir(url: string, type: typeof cc.Asset): void; + static loadResDir(url: string, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any[], urls: string[]) => void)|null): void; + static loadResDir(url: string, completeCallback: (error: Error, resource: any[], urls: string[]) => void): void; + static loadResDir(url: string): void; + /** + `cc.loader.getRes` is deprecated, please use {{#crossLink "Bundle/get:method"}}{{/crossLink}} instead + @param url url + @param type Only asset of type will be returned if this argument is supplied. + */ + static getRes(url: string, type?: Function): any; + /** + `cc.loader.getDependsRecursively` is deprecated, please use use {{#crossLink "DependUtil/getDepsRecursively:method"}}{{/crossLink}} instead + @param owner The owner asset or the resource url or the asset's uuid + */ + static getDependsRecursively(owner: Asset|string): any[]; + /** `cc.loader.assetLoader` was removed, assetLoader and md5Pipe were merged into {{#crossLink "AssetManager/transformPipeline:property"}}{{/crossLink}} */ + static assetLoader: any; + /** `cc.loader.md5Pipe` is deprecated, assetLoader and md5Pipe were merged into {{#crossLink "AssetManager/transformPipeline:property"}}{{/crossLink}} */ + static md5Pipe: any; + /** `cc.loader.downloader` is deprecated, please use {{#crossLink "AssetManager/downloader:property"}}{{/crossLink}} instead */ + static downloader: any; + /** `cc.loader.loader` is deprecated, please use {{#crossLink "AssetManager/parser:property"}}{{/crossLink}} instead */ + static loader: any; + /** + `cc.loader.addDownloadHandlers` is deprecated, please use `cc.assetManager.downloader.register` instead + @param extMap Custom supported types with corresponded handler + */ + static addDownloadHandlers(extMap: any): void; + /** + `cc.loader.addLoadHandlers` is deprecated, please use `cc.assetManager.parser.register` instead + @param extMap Custom supported types with corresponded handler + */ + static addLoadHandlers(extMap: any): void; + /** + `cc.loader.release` is deprecated, please use {{#crossLink "AssetManager/releaseAsset:method"}}{{/crossLink}} instead + @param asset asset + */ + static release(asset: Asset|string|any[]): void; + /** + `cc.loader.releaseAsset` is deprecated, please use {{#crossLink "AssetManager/releaseAsset:method"}}{{/crossLink}} instead + @param asset asset + */ + static releaseAsset(asset: Asset): void; + /** + `cc.loader.releaseRes` is deprecated, please use {{#crossLink "AssetManager/releaseRes:method"}}{{/crossLink}} instead + @param url url + @param type Only asset of type will be released if this argument is supplied. + */ + static releaseRes(url: string, type?: Function): void; + /** + `cc.loader.releaseResDir` was removed, please use {{#crossLink "AssetManager/releaseRes:method"}}{{/crossLink}} instead + */ + static releaseResDir(): void; + /** + `cc.loader.releaseAll` is deprecated, please use {{#crossLink "AssetManager/releaseAll:method"}}{{/crossLink}} instead + */ + static releaseAll(): void; + /** + `cc.loader.removeItem` is deprecated, please use `cc.assetManager.assets.remove` instead + @param id The id of the item + */ + static removeItem(id: any): boolean; + /** + `cc.loader.setAutoRelease` is deprecated, if you want to prevent some asset from auto releasing, please use {{#crossLink "Asset/addRef:method"}}{{/crossLink}} instead + @param assetOrUrlOrUuid asset object or the raw asset's url or uuid + @param autoRelease indicates whether should release automatically + */ + static setAutoRelease(assetOrUrlOrUuid: Asset|string, autoRelease: boolean): void; + /** + `cc.loader.setAutoReleaseRecursively` is deprecated, if you want to prevent some asset from auto releasing, please use {{#crossLink "Asset/addRef:method"}}{{/crossLink}} instead + @param assetOrUrlOrUuid asset object or the raw asset's url or uuid + @param autoRelease indicates whether should release automatically + */ + static setAutoReleaseRecursively(assetOrUrlOrUuid: Asset|string, autoRelease: boolean): void; + /** + `cc.loader.isAutoRelease` is deprecated + @param assetOrUrl asset object or the raw asset's url + */ + static isAutoRelease(assetOrUrl: Asset|string): boolean; + } + /** `cc.url` is deprecated */ + export class url { + /** + `cc.url.raw` is deprecated, please use `cc.resources.load` directly, or use `Asset.nativeUrl` instead. + @param url url + */ + static raw(url: string): string; + } + /** `cc.LoadingItems` was removed, please use {{#crossLink "Task"}}{{/crossLink}} instead */ + export class LoadingItems { + } + /** !#en + Base class for handling assets used in Creator.
+ + You may want to override:
+ - createNode
+ - getset functions of _nativeAsset
+ - cc.Object._serialize
+ - cc.Object._deserialize
+ !#zh + Creator 中的资源基类。
+ + 您可能需要重写:
+ - createNode
+ - _nativeAsset 的 getset 方法
+ - cc.Object._serialize
+ - cc.Object._deserialize
*/ + export class Asset extends Object { + /** `cc.Asset.url` is deprecated, please use {{#crossLink "Asset/nativeUrl:property"}}{{/crossLink}} instead */ + url: string; + /** !#en + Whether the asset is loaded or not. + !#zh + 该资源是否已经成功加载。 */ + loaded: boolean; + /** !#en + Returns the url of this asset's native object, if none it will returns an empty string. + !#zh + 返回该资源对应的目标平台资源的 URL,如果没有将返回一个空字符串。 */ + nativeUrl: string; + /** !#en + The number of reference + + !#zh + 引用的数量 */ + refCount: number; + /** !#en Indicates whether its dependent raw assets can support deferred load if the owner scene (or prefab) is marked as `asyncLoadAssets`. + !#zh 当场景或 Prefab 被标记为 `asyncLoadAssets`,禁止延迟加载该资源所依赖的其它原始资源。 */ + static preventDeferredLoadDependents: boolean; + /** !#en Indicates whether its native object should be preloaded from native url. + !#zh 禁止预加载原生对象。 */ + static preventPreloadNativeObject: boolean; + /** + !#en + Returns the asset's url. + + The `Asset` object overrides the `toString()` method of the `Object` object. + For `Asset` objects, the `toString()` method returns a string representation of the object. + JavaScript calls the `toString()` method automatically when an asset is to be represented as a text value or when a texture is referred to in a string concatenation. + !#zh + 返回资源的 URL。 + + Asset 对象将会重写 Object 对象的 `toString()` 方法。 + 对于 Asset 对象,`toString()` 方法返回该对象的字符串表示形式。 + 当资源要表示为文本值时或在字符串连接时引用时,JavaScript 会自动调用 `toString()` 方法。 + */ + toString(): string; + /** + !#en + Create a new node using this asset in the scene.
+ If this type of asset dont have its corresponding node type, this method should be null. + !#zh + 使用该资源在场景中创建一个新节点。
+ 如果这类资源没有相应的节点类型,该方法应该是空的。 + @param callback callback + */ + createNode(callback: (error: string, node: any) => void): void; + /** + !#en + Add references of asset + + !#zh + 增加资源的引用 + */ + addRef(): cc.Asset; + /** + !#en + Reduce references of asset and it will be auto released when refCount equals 0. + + !#zh + 减少资源的引用并尝试进行自动释放。 + */ + decRef(): cc.Asset; + } + /** Predefined constants */ + export class macro { + /** `cc.macro.DOWNLOAD_MAX_CONCURRENT` is deprecated now, please use {{#crossLink "Downloader/maxConcurrency:property"}}{{/crossLink}} instead */ + static DOWNLOAD_MAX_CONCURRENT: number; + /** PI / 180 */ + static RAD: number; + /** One degree */ + static DEG: number; + static REPEAT_FOREVER: number; + static FLT_EPSILON: number; + /** Minimum z index value for node */ + static MIN_ZINDEX: number; + /** Maximum z index value for node */ + static MAX_ZINDEX: number; + static ONE: number; + static ZERO: number; + static SRC_ALPHA: number; + static SRC_ALPHA_SATURATE: number; + static SRC_COLOR: number; + static DST_ALPHA: number; + static DST_COLOR: number; + static ONE_MINUS_SRC_ALPHA: number; + static ONE_MINUS_SRC_COLOR: number; + static ONE_MINUS_DST_ALPHA: number; + static ONE_MINUS_DST_COLOR: number; + static ONE_MINUS_CONSTANT_ALPHA: number; + static ONE_MINUS_CONSTANT_COLOR: number; + /** Oriented vertically */ + static ORIENTATION_PORTRAIT: number; + /** Oriented horizontally */ + static ORIENTATION_LANDSCAPE: number; + /** Oriented automatically */ + static ORIENTATION_AUTO: number; + /**

+ If enabled, the texture coordinates will be calculated by using this formula:
+ - texCoord.left = (rect.x*2+1) / (texture.wide*2);
+ - texCoord.right = texCoord.left + (rect.width*2-2)/(texture.wide*2);
+
+ The same for bottom and top.
+
+ This formula prevents artifacts by using 99% of the texture.
+ The "correct" way to prevent artifacts is by expand the texture's border with the same color by 1 pixel
+
+ Affected component:
+ - cc.TMXLayer
+
+ Enabled by default. To disabled set it to 0.
+ To modify it, in Web engine please refer to CCMacro.js, in JSB please refer to CCConfig.h +

*/ + static FIX_ARTIFACTS_BY_STRECHING_TEXEL_TMX: number; + /** Position of the FPS (Default: 0,0 (bottom-left corner))
+ To modify it, in Web engine please refer to CCMacro.js, in JSB please refer to CCConfig.h */ + static DIRECTOR_STATS_POSITION: Vec2; + /**

+ If enabled, actions that alter the position property (eg: CCMoveBy, CCJumpBy, CCBezierBy, etc..) will be stacked.
+ If you run 2 or more 'position' actions at the same time on a node, then end position will be the sum of all the positions.
+ If disabled, only the last run action will take effect. +

*/ + static ENABLE_STACKABLE_ACTIONS: number; + /** !#en + The timeout to determine whether a touch is no longer active and should be removed. + The reason to add this timeout is due to an issue in X5 browser core, + when X5 is presented in wechat on Android, if a touch is glissed from the bottom up, and leave the page area, + no touch cancel event is triggered, and the touch will be considered active forever. + After multiple times of this action, our maximum touches number will be reached and all new touches will be ignored. + So this new mechanism can remove the touch that should be inactive if it's not updated during the last 5000 milliseconds. + Though it might remove a real touch if it's just not moving for the last 5 seconds which is not easy with the sensibility of mobile touch screen. + You can modify this value to have a better behavior if you find it's not enough. + !#zh + 用于甄别一个触点对象是否已经失效并且可以被移除的延时时长 + 添加这个时长的原因是 X5 内核在微信浏览器中出现的一个 bug。 + 在这个环境下,如果用户将一个触点从底向上移出页面区域,将不会触发任何 touch cancel 或 touch end 事件,而这个触点会被永远当作停留在页面上的有效触点。 + 重复这样操作几次之后,屏幕上的触点数量将达到我们的事件系统所支持的最高触点数量,之后所有的触摸事件都将被忽略。 + 所以这个新的机制可以在触点在一定时间内没有任何更新的情况下视为失效触点并从事件系统中移除。 + 当然,这也可能移除一个真实的触点,如果用户的触点真的在一定时间段内完全没有移动(这在当前手机屏幕的灵敏度下会很难)。 + 你可以修改这个值来获得你需要的效果,默认值是 5000 毫秒。 */ + static TOUCH_TIMEOUT: number; + /** !#en + The maximum vertex count for a single batched draw call. + !#zh + 最大可以被单次批处理渲染的顶点数量。 */ + static BATCH_VERTEX_COUNT: number; + /** !#en + Whether or not enabled tiled map auto culling. If you set the TiledMap skew or rotation, then need to manually disable this, otherwise, the rendering will be wrong. + !#zh + 是否开启瓦片地图的自动裁减功能。瓦片地图如果设置了 skew, rotation 或者采用了摄像机的话,需要手动关闭,否则渲染会出错。 */ + static ENABLE_TILEDMAP_CULLING: boolean; + /** !#en + Boolean that indicates if the canvas contains an alpha channel, default sets to false for better performance. + Though if you want to make your canvas background transparent and show other dom elements at the background, + you can set it to true before `cc.game.run`. + Web only. + !#zh + 用于设置 Canvas 背景是否支持 alpha 通道,默认为 false,这样可以有更高的性能表现。 + 如果你希望 Canvas 背景是透明的,并显示背后的其他 DOM 元素,你可以在 `cc.game.run` 之前将这个值设为 true。 + 仅支持 Web */ + static ENABLE_TRANSPARENT_CANVAS: boolean; + /** !#en + Boolean that indicates if the WebGL context is created with `antialias` option turned on, default value is false. + Set it to true could make your game graphics slightly smoother, like texture hard edges when rotated. + Whether to use this really depend on your game design and targeted platform, + device with retina display usually have good detail on graphics with or without this option, + you probably don't want antialias if your game style is pixel art based. + Also, it could have great performance impact with some browser / device using software MSAA. + You can set it to true before `cc.game.run`. + Web only. + !#zh + 用于设置在创建 WebGL Context 时是否开启抗锯齿选项,默认值是 false。 + 将这个选项设置为 true 会让你的游戏画面稍稍平滑一些,比如旋转硬边贴图时的锯齿。是否开启这个选项很大程度上取决于你的游戏和面向的平台。 + 在大多数拥有 retina 级别屏幕的设备上用户往往无法区分这个选项带来的变化;如果你的游戏选择像素艺术风格,你也多半不会想开启这个选项。 + 同时,在少部分使用软件级别抗锯齿算法的设备或浏览器上,这个选项会对性能产生比较大的影响。 + 你可以在 `cc.game.run` 之前设置这个值,否则它不会生效。 + 仅支持 Web */ + static ENABLE_WEBGL_ANTIALIAS: boolean; + /** !#en + Whether or not enable auto culling. + This feature have been removed in v2.0 new renderer due to overall performance consumption. + We have no plan currently to re-enable auto culling. + If your game have more dynamic objects, we suggest to disable auto culling. + If your game have more static objects, we suggest to enable auto culling. + !#zh + 是否开启自动裁减功能,开启裁减功能将会把在屏幕外的物体从渲染队列中去除掉。 + 这个功能在 v2.0 的新渲染器中被移除了,因为它在大多数游戏中所带来的损耗要高于性能的提升,目前我们没有计划重新支持自动裁剪。 + 如果游戏中的动态物体比较多的话,建议将此选项关闭。 + 如果游戏中的静态物体比较多的话,建议将此选项打开。 */ + static ENABLE_CULLING: boolean; + /** !#en + Whether to clear the original image cache after uploaded a texture to GPU. If cleared, [Dynamic Atlas](https://docs.cocos.com/creator/manual/en/advanced-topics/dynamic-atlas.html) will not be supported. + Normally you don't need to enable this option on the web platform, because Image object doesn't consume too much memory. + But on WeChat Game platform, the current version cache decoded data in Image object, which has high memory usage. + So we enabled this option by default on WeChat, so that we can release Image cache immediately after uploaded to GPU. + !#zh + 是否在将贴图上传至 GPU 之后删除原始图片缓存,删除之后图片将无法进行 [动态合图](https://docs.cocos.com/creator/manual/zh/advanced-topics/dynamic-atlas.html)。 + 在 Web 平台,你通常不需要开启这个选项,因为在 Web 平台 Image 对象所占用的内存很小。 + 但是在微信小游戏平台的当前版本,Image 对象会缓存解码后的图片数据,它所占用的内存空间很大。 + 所以我们在微信平台默认开启了这个选项,这样我们就可以在上传 GL 贴图之后立即释放 Image 对象的内存,避免过高的内存占用。 */ + static CLEANUP_IMAGE_CACHE: boolean; + /** !#en + Whether or not show mesh wire frame. + !#zh + 是否显示网格的线框。 */ + static SHOW_MESH_WIREFRAME: boolean; + /** !#en + Whether or not show mesh normal. + !#zh + 是否显示网格的法线。 */ + static SHOW_MESH_NORMAL: boolean; + /** !#en + Whether to enable multi-touch. + !#zh + 是否开启多点触摸 */ + static ENABLE_MULTI_TOUCH: boolean; + /** References: + https://developer.mozilla.org/en-US/docs/Web/API/ImageBitmap + https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/createImageBitmap + + !#en + Whether to use image bitmap first. If enabled, memory usage will increase. + + !#zh + 是否优先使用 image bitmap,启用之后,内存占用会变高 */ + static ALLOW_IMAGE_BITMAP: boolean; + /** !#en + Whether to use native TTF renderer which is faster but layout slightly different. + + !#zh + 是否使用原生的文本渲染机制, 布局和编辑器有差异. */ + static ENABLE_NATIVE_TTF_RENDERER: boolean; + /** !#en + The image format supported by the engine defaults, and the supported formats may differ in different build platforms and device types. + Currently all platform and device support ['.webp', '.jpg', '.jpeg', '.bmp', '.png'], The iOS mobile platform also supports the PVR format。 + !#zh + 引擎默认支持的图片格式,支持的格式可能在不同的构建平台和设备类型上有所差别。 + 目前所有平台和设备支持的格式有 ['.webp', '.jpg', '.jpeg', '.bmp', '.png']. 另外 Ios 手机平台还额外支持了 PVR 格式。 */ + static SUPPORT_TEXTURE_FORMATS: string[]; + } + /** !#en The Light Component + + !#zh 光源组件 */ + export class Light extends Component { + } + /** !#en Class for audio data handling. + !#zh 音频资源类。 */ + export class AudioClip extends Asset implements EventTarget { + /** !#en Get the audio clip duration + !#zh 获取音频剪辑的长度 */ + duration: number; + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en + Register an callback of a specific event type on the EventTarget. + This type of event should be triggered via `emit`. + !#zh + 注册事件目标的特定事件类型回调。这种类型的事件应该被 `emit` 触发。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, node); + ``` + */ + on(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. + !#zh + 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + + @example + ```js + // register fire eventListener + var callback = eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, target); + // remove fire event listener + eventTarget.off('fire', callback, target); + // remove all fire event listeners + eventTarget.off('fire'); + ``` + */ + off(type: string, callback?: Function, target?: any): void; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.once('fire', function () { + cc.log("this is the callback and will be invoked only once"); + }, node); + ``` + */ + once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; + /** + !#en + Send an event with the event object. + !#zh + 通过事件对象派发事件 + @param event event + */ + dispatchEvent(event: Event): void; + /** + !#en + Destroy all callbackInfos. + !#zh + 销毁记录的事件 + */ + clear(): void; + } + /** !#en Class for BitmapFont handling. + !#zh 位图字体资源类。 */ + export class BitmapFont extends Font { + } + /** undefined */ + export class BufferAsset extends Asset { + } + /** !#en Class for Font handling. + !#zh 字体资源类。 */ + export class Font extends Asset { + } + /** !#en + Class for JSON file. When the JSON file is loaded, this object is returned. + The parsed JSON object can be accessed through the `json` attribute in it.
+ If you want to get the original JSON text, you should modify the extname to `.txt` + so that it is loaded as a `TextAsset` instead of a `JsonAsset`. + + !#zh + JSON 资源类。JSON 文件加载后,将会返回该对象。可以通过其中的 `json` 属性访问解析后的 JSON 对象。
+ 如果你想要获得 JSON 的原始文本,那么应该修改源文件的后缀为 `.txt`,这样就会加载为一个 `TextAsset` 而不是 `JsonAsset`。 */ + export class JsonAsset extends Asset { + /** The loaded JSON object. */ + json: any; + } + /** !#en Class for LabelAtlas handling. + !#zh 艺术数字字体资源类。 */ + export class LabelAtlas extends BitmapFont { + } + /** !#en Class for prefab handling. + !#zh 预制资源类。 */ + export class Prefab extends Asset { + /** the main cc.Node in the prefab */ + data: Node; + /** !#zh + 设置实例化这个 prefab 时所用的优化策略。根据使用情况设置为合适的值,能优化该 prefab 实例化所用的时间。 + !#en + Indicates the optimization policy for instantiating this prefab. + Set to a suitable value based on usage, can optimize the time it takes to instantiate this prefab. */ + optimizationPolicy: Prefab.OptimizationPolicy; + /** !#en Indicates the raw assets of this prefab can be load after prefab loaded. + !#zh 指示该 Prefab 依赖的资源可否在 Prefab 加载后再延迟加载。 */ + asyncLoadAssets: boolean; + readonly: boolean; + /** + Dynamically translation prefab data into minimized code.
+ This method will be called automatically before the first time the prefab being instantiated, + but you can re-call to refresh the create function once you modified the original prefab data in script. + */ + compileCreateFunction(): void; + } + /** Render textures are textures that can be rendered to. */ + export class RenderTexture extends Texture2D { + /** + !#en + Init the render texture with size. + !#zh + 初始化 render texture + @param width width + @param height height + @param depthStencilFormat depthStencilFormat + */ + initWithSize(width?: number, height?: number, depthStencilFormat?: number): void; + /** + !#en + Get pixels from render texture, the pixels data stores in a RGBA Uint8Array. + It will return a new (width * height * 4) length Uint8Array by default。 + You can specify a data to store the pixels to reuse the data, + you and can specify other params to specify the texture region to read. + !#zh + 从 render texture 读取像素数据,数据类型为 RGBA 格式的 Uint8Array 数组。 + 默认每次调用此函数会生成一个大小为 (长 x 高 x 4) 的 Uint8Array。 + 你可以通过传入 data 来接收像素数据,也可以通过传参来指定需要读取的区域的像素。 + @param data data + @param x x + @param y y + @param w w + @param h h + */ + readPixels(data?: Uint8Array, x?: number, y?: number, w?: number, h?: number): Uint8Array; + } + /** !#en Class for scene handling. + !#zh 场景资源类。 */ + export class SceneAsset extends Asset { + scene: Scene; + /** !#en Indicates the raw assets of this scene can be load after scene launched. + !#zh 指示该场景依赖的资源可否在场景切换后再延迟加载。 */ + asyncLoadAssets: boolean; + } + /** !#en Class for script handling. + !#zh Script 资源类。 */ + export class _Script extends Asset { + } + /** !#en Class for JavaScript handling. + !#zh JavaScript 资源类。 */ + export class _JavaScript extends Asset { + } + /** !#en Class for TypeScript handling. + !#zh TypeScript 资源类。 */ + export class TypeScript extends Asset { + } + /** !#en Class for sprite atlas handling. + !#zh 精灵图集资源类。 */ + export class SpriteAtlas extends Asset { + /** + Returns the texture of the sprite atlas + */ + getTexture(): Texture2D; + /** + Returns the sprite frame correspond to the given key in sprite atlas. + @param key key + */ + getSpriteFrame(key: string): SpriteFrame; + /** + Returns the sprite frames in sprite atlas. + */ + getSpriteFrames(): SpriteFrame[]; + } + /** !#en + A cc.SpriteFrame has:
+ - texture: A cc.Texture2D that will be used by render components
+ - rectangle: A rectangle of the texture + + !#zh + 一个 SpriteFrame 包含:
+ - 纹理:会被渲染组件使用的 Texture2D 对象。
+ - 矩形:在纹理中的矩形区域。 */ + export class SpriteFrame extends Asset implements EventTarget { + /** !#en Top border of the sprite + !#zh sprite 的顶部边框 */ + insetTop: number; + /** !#en Bottom border of the sprite + !#zh sprite 的底部边框 */ + insetBottom: number; + /** !#en Left border of the sprite + !#zh sprite 的左边边框 */ + insetLeft: number; + /** !#en Right border of the sprite + !#zh sprite 的左边边框 */ + insetRight: number; + /** + !#en + Constructor of SpriteFrame class. + !#zh + SpriteFrame 类的构造函数。 + @param filename filename + @param rect rect + @param rotated Whether the frame is rotated in the texture + @param offset The offset of the frame in the texture + @param originalSize The size of the frame in the texture + */ + constructor(filename?: string|Texture2D, rect?: Rect, rotated?: boolean, offset?: Vec2, originalSize?: Size); + /** + !#en Returns whether the texture have been loaded + !#zh 返回是否已加载纹理 + */ + textureLoaded(): boolean; + /** + !#en Returns whether the sprite frame is rotated in the texture. + !#zh 获取 SpriteFrame 是否旋转 + */ + isRotated(): boolean; + /** + !#en Set whether the sprite frame is rotated in the texture. + !#zh 设置 SpriteFrame 是否旋转 + @param bRotated bRotated + */ + setRotated(bRotated: boolean): void; + /** + !#en Returns whether the sprite frame is flip x axis in the texture. + !#zh 获取 SpriteFrame 是否反转 x 轴 + */ + isFlipX(): boolean; + /** + !#en Returns whether the sprite frame is flip y axis in the texture. + !#zh 获取 SpriteFrame 是否反转 y 轴 + */ + isFlipY(): boolean; + /** + !#en Set whether the sprite frame is flip x axis in the texture. + !#zh 设置 SpriteFrame 是否翻转 x 轴 + @param flipX flipX + */ + setFlipX(flipX: boolean): void; + /** + !#en Set whether the sprite frame is flip y axis in the texture. + !#zh 设置 SpriteFrame 是否翻转 y 轴 + @param flipY flipY + */ + setFlipY(flipY: boolean): void; + /** + !#en Returns the rect of the sprite frame in the texture. + !#zh 获取 SpriteFrame 的纹理矩形区域 + */ + getRect(): Rect; + /** + !#en Sets the rect of the sprite frame in the texture. + !#zh 设置 SpriteFrame 的纹理矩形区域 + @param rect rect + */ + setRect(rect: Rect): void; + /** + !#en Returns the original size of the trimmed image. + !#zh 获取修剪前的原始大小 + */ + getOriginalSize(): Size; + /** + !#en Sets the original size of the trimmed image. + !#zh 设置修剪前的原始大小 + @param size size + */ + setOriginalSize(size: Size): void; + /** + !#en Returns the texture of the frame. + !#zh 获取使用的纹理实例 + */ + getTexture(): Texture2D; + /** + !#en Returns the offset of the frame in the texture. + !#zh 获取偏移量 + */ + getOffset(): Vec2; + /** + !#en Sets the offset of the frame in the texture. + !#zh 设置偏移量 + @param offsets offsets + */ + setOffset(offsets: Vec2): void; + /** + !#en Clone the sprite frame. + !#zh 克隆 SpriteFrame + */ + clone(): SpriteFrame; + /** + !#en Set SpriteFrame with Texture, rect, rotated, offset and originalSize.
+ !#zh 通过 Texture,rect,rotated,offset 和 originalSize 设置 SpriteFrame。 + @param texture texture + @param rect rect + @param rotated rotated + @param offset offset + @param originalSize originalSize + */ + setTexture(texture: Texture2D, rect?: Rect, rotated?: boolean, offset?: Vec2, originalSize?: Size): boolean; + /** + !#en If a loading scene (or prefab) is marked as `asyncLoadAssets`, all the textures of the SpriteFrame which + associated by user's custom Components in the scene, will not preload automatically. + These textures will be load when Sprite component is going to render the SpriteFrames. + You can call this method if you want to load the texture early. + !#zh 当加载中的场景或 Prefab 被标记为 `asyncLoadAssets` 时,用户在场景中由自定义组件关联到的所有 SpriteFrame 的贴图都不会被提前加载。 + 只有当 Sprite 组件要渲染这些 SpriteFrame 时,才会检查贴图是否加载。如果你希望加载过程提前,你可以手工调用这个方法。 + + @example + ```js + if (spriteFrame.textureLoaded()) { + this._onSpriteFrameLoaded(); + } + else { + spriteFrame.once('load', this._onSpriteFrameLoaded, this); + spriteFrame.ensureLoadTexture(); + } + ``` + */ + ensureLoadTexture(): void; + /** + !#en + If you do not need to use the SpriteFrame temporarily, you can call this method so that its texture could be garbage collected. Then when you need to render the SpriteFrame, you should call `ensureLoadTexture` manually to reload texture. + !#zh + 当你暂时不再使用这个 SpriteFrame 时,可以调用这个方法来保证引用的贴图对象能被 GC。然后当你要渲染 SpriteFrame 时,你需要手动调用 `ensureLoadTexture` 来重新加载贴图。 + */ + clearTexture(): void; + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en + Register an callback of a specific event type on the EventTarget. + This type of event should be triggered via `emit`. + !#zh + 注册事件目标的特定事件类型回调。这种类型的事件应该被 `emit` 触发。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, node); + ``` + */ + on(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. + !#zh + 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + + @example + ```js + // register fire eventListener + var callback = eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, target); + // remove fire event listener + eventTarget.off('fire', callback, target); + // remove all fire event listeners + eventTarget.off('fire'); + ``` + */ + off(type: string, callback?: Function, target?: any): void; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.once('fire', function () { + cc.log("this is the callback and will be invoked only once"); + }, node); + ``` + */ + once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; + /** + !#en + Send an event with the event object. + !#zh + 通过事件对象派发事件 + @param event event + */ + dispatchEvent(event: Event): void; + /** + !#en + Destroy all callbackInfos. + !#zh + 销毁记录的事件 + */ + clear(): void; + } + /** !#en Class for TTFFont handling. + !#zh TTF 字体资源类。 */ + export class TTFFont extends Font { + } + /** !#en Class for text file. + !#zh 文本资源类。 */ + export class TextAsset extends Asset { + /** The text contents of the resource. */ + text: string; + } + /** This class allows to easily create OpenGL or Canvas 2D textures from images or raw data. */ + export class Texture2D extends Asset implements EventTarget { + /** !#en Sets whether generate mipmaps for the texture + !#zh 是否为纹理设置生成 mipmaps。 */ + genMipmaps: boolean; + /** !#en + Sets whether texture can be packed into texture atlas. + If need use texture uv in custom Effect, please sets packable to false. + !#zh + 设置纹理是否允许参与合图。 + 如果需要在自定义 Effect 中使用纹理 UV,需要禁止该选项。 */ + packable: boolean; + /** !#en + Whether the texture is loaded or not + !#zh + 贴图是否已经成功加载 */ + loaded: boolean; + /** !#en + Texture width in pixel + !#zh + 贴图像素宽度 */ + width: number; + /** !#en + Texture height in pixel + !#zh + 贴图像素高度 */ + height: number; + /** + !#en + Get renderer texture implementation object + extended from render.Texture2D + !#zh 返回渲染器内部贴图对象 + */ + getImpl(): void; + /** + Update texture options, not available in Canvas render mode. + image, format, premultiplyAlpha can not be updated in native. + @param options options + */ + update(options: {image: DOMImageElement; genMipmaps: boolean; format: Texture2D.PixelFormat; minFilter: Texture2D.Filter; magFilter: Texture2D.Filter; wrapS: WrapMode; wrapT: WrapMode; premultiplyAlpha: boolean; }): void; + /** + !#en + Init with HTML element. + !#zh 用 HTML Image 或 Canvas 对象初始化贴图。 + @param element element + + @example + ```js + var img = new Image(); + img.src = dataURL; + texture.initWithElement(img); + ``` + */ + initWithElement(element: HTMLImageElement|HTMLCanvasElement): void; + /** + !#en + Intializes with texture data in ArrayBufferView. + !#zh 使用一个存储在 ArrayBufferView 中的图像数据(raw data)初始化数据。 + @param data data + @param pixelFormat pixelFormat + @param pixelsWidth pixelsWidth + @param pixelsHeight pixelsHeight + */ + initWithData(data: ArrayBufferView, pixelFormat: number, pixelsWidth: number, pixelsHeight: number): boolean; + /** + !#en + HTMLElement Object getter, available only on web.
+ Note: texture is packed into texture atlas by default
+ you should set texture.packable as false before getting Html element object. + !#zh 获取当前贴图对应的 HTML Image 或 Canvas 对象,只在 Web 平台下有效。
+ 注意:
+ texture 默认参与动态合图,如果需要获取到正确的 Html 元素对象,需要先设置 texture.packable 为 false + */ + getHtmlElementObj(): HTMLImageElement; + /** + !#en + Destory this texture and immediately release its video memory. (Inherit from cc.Object.destroy)
+ After destroy, this object is not usable anymore. + You can use cc.isValid(obj) to check whether the object is destroyed before accessing it. + !#zh + 销毁该贴图,并立即释放它对应的显存。(继承自 cc.Object.destroy)
+ 销毁后,该对象不再可用。您可以在访问对象之前使用 cc.isValid(obj) 来检查对象是否已被销毁。 + */ + destroy(): boolean; + /** + !#en + Pixel format of the texture. + !#zh 获取纹理的像素格式。 + */ + getPixelFormat(): number; + /** + !#en + Whether or not the texture has their Alpha premultiplied. + !#zh 检查纹理在上传 GPU 时预乘选项是否开启。 + */ + hasPremultipliedAlpha(): boolean; + /** + !#en + Handler of texture loaded event. + Since v2.0, you don't need to invoke this function, it will be invoked automatically after texture loaded. + !#zh 贴图加载事件处理器。v2.0 之后你将不在需要手动执行这个函数,它会在贴图加载成功之后自动执行。 + @param premultiplied premultiplied + */ + handleLoadedTexture(premultiplied?: boolean): void; + /** + !#en + Description of cc.Texture2D. + !#zh cc.Texture2D 描述。 + */ + description(): string; + /** + !#en + Release texture, please use destroy instead. + !#zh 释放纹理,请使用 destroy 替代。 + */ + releaseTexture(): void; + /** + !#en Sets the wrap s and wrap t options.
+ If the texture size is NPOT (non power of 2), then in can only use gl.CLAMP_TO_EDGE in gl.TEXTURE_WRAP_{S,T}. + !#zh 设置纹理包装模式。 + 若纹理贴图尺寸是 NPOT(non power of 2),则只能使用 Texture2D.WrapMode.CLAMP_TO_EDGE。 + @param wrapS wrapS + @param wrapT wrapT + */ + setWrapMode(wrapS: Texture2D.WrapMode, wrapT: Texture2D.WrapMode): void; + /** + !#en Sets the minFilter and magFilter options + !#zh 设置纹理贴图缩小和放大过滤器算法选项。 + @param minFilter minFilter + @param magFilter magFilter + */ + setFilters(minFilter: Texture2D.Filter, magFilter: Texture2D.Filter): void; + /** + !#en + Sets the flipY options + !#zh 设置贴图的纵向翻转选项。 + @param flipY flipY + */ + setFlipY(flipY: boolean): void; + /** + !#en + Sets the premultiply alpha options + !#zh 设置贴图的预乘选项。 + @param premultiply premultiply + */ + setPremultiplyAlpha(premultiply: boolean): void; + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en + Register an callback of a specific event type on the EventTarget. + This type of event should be triggered via `emit`. + !#zh + 注册事件目标的特定事件类型回调。这种类型的事件应该被 `emit` 触发。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, node); + ``` + */ + on(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. + !#zh + 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + + @example + ```js + // register fire eventListener + var callback = eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, target); + // remove fire event listener + eventTarget.off('fire', callback, target); + // remove all fire event listeners + eventTarget.off('fire'); + ``` + */ + off(type: string, callback?: Function, target?: any): void; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.once('fire', function () { + cc.log("this is the callback and will be invoked only once"); + }, node); + ``` + */ + once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; + /** + !#en + Send an event with the event object. + !#zh + 通过事件对象派发事件 + @param event event + */ + dispatchEvent(event: Event): void; + /** + !#en + Destroy all callbackInfos. + !#zh + 销毁记录的事件 + */ + clear(): void; + } + /** !#en + EventTarget is an object to which an event is dispatched when something has occurred. + Entity are the most common event targets, but other objects can be event targets too. + + Event targets are an important part of the Fireball event model. + The event target serves as the focal point for how events flow through the scene graph. + When an event such as a mouse click or a keypress occurs, Fireball dispatches an event object + into the event flow from the root of the hierarchy. The event object then makes its way through + the scene graph until it reaches the event target, at which point it begins its return trip through + the scene graph. This round-trip journey to the event target is conceptually divided into three phases: + - The capture phase comprises the journey from the root to the last node before the event target's node + - The target phase comprises only the event target node + - The bubbling phase comprises any subsequent nodes encountered on the return trip to the root of the tree + See also: http://www.w3.org/TR/DOM-Level-3-Events/#event-flow + + Event targets can implement the following methods: + - _getCapturingTargets + - _getBubblingTargets + + !#zh + 事件目标是事件触发时,分派的事件对象,Node 是最常见的事件目标, + 但是其他对象也可以是事件目标。
*/ + export class EventTarget extends CallbacksInvoker { + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en + Register an callback of a specific event type on the EventTarget. + This type of event should be triggered via `emit`. + !#zh + 注册事件目标的特定事件类型回调。这种类型的事件应该被 `emit` 触发。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, node); + ``` + */ + on(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. + !#zh + 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + + @example + ```js + // register fire eventListener + var callback = eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, target); + // remove fire event listener + eventTarget.off('fire', callback, target); + // remove all fire event listeners + eventTarget.off('fire'); + ``` + */ + off(type: string, callback?: Function, target?: any): void; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.once('fire', function () { + cc.log("this is the callback and will be invoked only once"); + }, node); + ``` + */ + once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; + /** + !#en + Send an event with the event object. + !#zh + 通过事件对象派发事件 + @param event event + */ + dispatchEvent(event: Event): void; + /** + !#en + Destroy all callbackInfos. + !#zh + 销毁记录的事件 + */ + clear(): void; + } + /** !#en Base class of all kinds of events. + !#zh 包含事件相关信息的对象。 */ + export class Event { + /** + + @param type The name of the event (case-sensitive), e.g. "click", "fire", or "submit" + @param bubbles A boolean indicating whether the event bubbles up through the tree or not + */ + constructor(type: string, bubbles: boolean); + /** !#en The name of the event (case-sensitive), e.g. "click", "fire", or "submit". + !#zh 事件类型。 */ + type: string; + /** !#en Indicate whether the event bubbles up through the tree or not. + !#zh 表示该事件是否进行冒泡。 */ + bubbles: boolean; + /** !#en A reference to the target to which the event was originally dispatched. + !#zh 最初事件触发的目标 */ + target: any; + /** !#en A reference to the currently registered target for the event. + !#zh 当前目标 */ + currentTarget: any; + /** !#en + Indicates which phase of the event flow is currently being evaluated. + Returns an integer value represented by 4 constants: + - Event.NONE = 0 + - Event.CAPTURING_PHASE = 1 + - Event.AT_TARGET = 2 + - Event.BUBBLING_PHASE = 3 + The phases are explained in the [section 3.1, Event dispatch and DOM event flow] + (http://www.w3.org/TR/DOM-Level-3-Events/#event-flow), of the DOM Level 3 Events specification. + !#zh 事件阶段 */ + eventPhase: number; + /** + !#en Reset the event for being stored in the object pool. + !#zh 重置对象池中存储的事件。 + */ + unuse(): string; + /** + !#en Reuse the event for being used again by the object pool. + !#zh 用于对象池再次使用的事件。 + */ + reuse(): string; + /** + !#en Stops propagation for current event. + !#zh 停止传递当前事件。 + */ + stopPropagation(): void; + /** + !#en Stops propagation for current event immediately, + the event won't even be dispatched to the listeners attached in the current target. + !#zh 立即停止当前事件的传递,事件甚至不会被分派到所连接的当前目标。 + */ + stopPropagationImmediate(): void; + /** + !#en Checks whether the event has been stopped. + !#zh 检查该事件是否已经停止传递. + */ + isStopped(): boolean; + /** + !#en +

+ Gets current target of the event
+ note: It only be available when the event listener is associated with node.
+ It returns 0 when the listener is associated with fixed priority. +

+ !#zh 获取当前目标节点 + */ + getCurrentTarget(): Node; + /** + !#en Gets the event type. + !#zh 获取事件类型 + */ + getType(): string; + /** !#en Code for event without type. + !#zh 没有类型的事件 */ + static NO_TYPE: string; + /** !#en The type code of Touch event. + !#zh 触摸事件类型 */ + static TOUCH: string; + /** !#en The type code of Mouse event. + !#zh 鼠标事件类型 */ + static MOUSE: string; + /** !#en The type code of Keyboard event. + !#zh 键盘事件类型 */ + static KEYBOARD: string; + /** !#en The type code of Acceleration event. + !#zh 加速器事件类型 */ + static ACCELERATION: string; + /** !#en Events not currently dispatched are in this phase + !#zh 尚未派发事件阶段 */ + static NONE: number; + /** !#en + The capturing phase comprises the journey from the root to the last node before the event target's node + see http://www.w3.org/TR/DOM-Level-3-Events/#event-flow + !#zh 捕获阶段,包括事件目标节点之前从根节点到最后一个节点的过程。 */ + static CAPTURING_PHASE: number; + /** !#en + The target phase comprises only the event target node + see http://www.w3.org/TR/DOM-Level-3-Events/#event-flow + !#zh 目标阶段仅包括事件目标节点。 */ + static AT_TARGET: number; + /** !#en + The bubbling phase comprises any subsequent nodes encountered on the return trip to the root of the hierarchy + see http://www.w3.org/TR/DOM-Level-3-Events/#event-flow + !#zh 冒泡阶段, 包括回程遇到到层次根节点的任何后续节点。 */ + static BUBBLING_PHASE: number; + } + /** !#en + The System event, it currently supports keyboard events and accelerometer events.
+ You can get the SystemEvent instance with cc.systemEvent.
+ !#zh + 系统事件,它目前支持按键事件和重力感应事件。
+ 你可以通过 cc.systemEvent 获取到 SystemEvent 的实例。
*/ + export class SystemEvent extends EventTarget { + /** + !#en whether enable accelerometer event + !#zh 是否启用加速度计事件 + @param isEnable isEnable + */ + setAccelerometerEnabled(isEnable: boolean): void; + /** + !#en set accelerometer interval value + !#zh 设置加速度计间隔值 + @param interval interval + */ + setAccelerometerInterval(interval: number): void; + } + /** !#en Box Collider. + !#zh 包围盒碰撞组件 */ + export class BoxCollider extends Collider implements Collider.Box { + /** !#en + Collider info in world coordinate. + !#zh + 碰撞体的世界坐标系下的信息。 */ + world: ColliderInfo; + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Box size + !#zh 包围盒大小 */ + size: Size; + } + /** !#en Circle Collider. + !#zh 圆形碰撞组件 */ + export class CircleCollider extends Collider implements Collider.Circle { + /** !#en + Collider info in world coordinate. + !#zh + 碰撞体的世界坐标系下的信息。 */ + world: ColliderInfo; + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Circle radius + !#zh 圆形半径 */ + radius: number; + } + /** !#en Collider component base class. + !#zh 碰撞组件基类 */ + export class Collider extends Component { + /** !#en Tag. If a node has several collider components, you can judge which type of collider is collided according to the tag. + !#zh 标签。当一个节点上有多个碰撞组件时,在发生碰撞后,可以使用此标签来判断是节点上的哪个碰撞组件被碰撞了。 */ + tag: number; + } + /** !#en + Collider Info. + !#zh + 碰撞体信息。 */ + export class ColliderInfo { + /** !#en + Collider aabb information of last frame + !#zh + 碰撞体上一帧的 aabb 信息 */ + preAabb: Rect; + /** !#en + Collider aabb information of current frame + !#zh + 碰撞体当前帧的 aabb 信息 */ + aabb: Rect; + /** !#en + Collider matrix + !#zh + 碰撞体的矩阵信息 */ + matrix: Mat4; + /** !#en + Collider radius (for CircleCollider) + !#zh + 碰撞体的半径(只对 CircleCollider 有效) */ + radius: number; + /** !#en + Collider position (for CircleCollider) + !#zh + 碰撞体的位置(只对 CircleCollider 有效) */ + position: Vec2; + /** !#en + Collider points (for BoxCollider and PolygonCollider) + !#zh + 碰撞体的顶点信息(只对 BoxCollider 和 PolygonCollider 有效) */ + points: Vec2[]; + } + /** !#en + A simple collision manager class. + It will calculate whether the collider collides other colliders, if collides then call the callbacks. + !#zh + 一个简单的碰撞组件管理类,用于处理节点之间的碰撞组件是否产生了碰撞,并调用相应回调函数。 */ + export class CollisionManager implements EventTarget { + /** !#en + !#zh + 是否开启碰撞管理,默认为不开启 */ + enabled: boolean; + /** !#en + !#zh + 是否绘制碰撞组件的包围盒,默认为不绘制 */ + enabledDrawBoundingBox: boolean; + /** !#en + !#zh + 是否绘制碰撞组件的形状,默认为不绘制 */ + enabledDebugDraw: boolean; + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en + Register an callback of a specific event type on the EventTarget. + This type of event should be triggered via `emit`. + !#zh + 注册事件目标的特定事件类型回调。这种类型的事件应该被 `emit` 触发。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, node); + ``` + */ + on(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. + !#zh + 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + + @example + ```js + // register fire eventListener + var callback = eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, target); + // remove fire event listener + eventTarget.off('fire', callback, target); + // remove all fire event listeners + eventTarget.off('fire'); + ``` + */ + off(type: string, callback?: Function, target?: any): void; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.once('fire', function () { + cc.log("this is the callback and will be invoked only once"); + }, node); + ``` + */ + once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; + /** + !#en + Send an event with the event object. + !#zh + 通过事件对象派发事件 + @param event event + */ + dispatchEvent(event: Event): void; + /** + !#en + Destroy all callbackInfos. + !#zh + 销毁记录的事件 + */ + clear(): void; + } + /** !#en Intersection helper class + !#zh 辅助类,用于测试形状与形状是否相交 */ + export class Intersection { + /** + !#en Test line and line + !#zh 测试线段与线段是否相交 + @param a1 The start point of the first line + @param a2 The end point of the first line + @param b1 The start point of the second line + @param b2 The end point of the second line + */ + static lineLine(a1: Vec2, a2: Vec2, b1: Vec2, b2: Vec2): boolean; + /** + !#en Test line and rect + !#zh 测试线段与矩形是否相交 + @param a1 The start point of the line + @param a2 The end point of the line + @param b The rect + */ + static lineRect(a1: Vec2, a2: Vec2, b: Rect): boolean; + /** + !#en Test line and polygon + !#zh 测试线段与多边形是否相交 + @param a1 The start point of the line + @param a2 The end point of the line + @param b The polygon, a set of points + */ + static linePolygon(a1: Vec2, a2: Vec2, b: Vec2[]): boolean; + /** + !#en Test rect and rect + !#zh 测试矩形与矩形是否相交 + @param a The first rect + @param b The second rect + */ + static rectRect(a: Rect, b: Rect): boolean; + /** + !#en Test rect and polygon + !#zh 测试矩形与多边形是否相交 + @param a The rect + @param b The polygon, a set of points + */ + static rectPolygon(a: Rect, b: Vec2[]): boolean; + /** + !#en Test polygon and polygon + !#zh 测试多边形与多边形是否相交 + @param a The first polygon, a set of points + @param b The second polygon, a set of points + */ + static polygonPolygon(a: Vec2[], b: Vec2[]): boolean; + /** + !#en Test circle and circle + !#zh 测试圆形与圆形是否相交 + @param a Object contains position and radius + @param b Object contains position and radius + */ + static circleCircle(a: {position: Vec2, radius: number}, b: {position: Vec2, radius: number}): boolean; + /** + !#en Test polygon and circle + !#zh 测试矩形与圆形是否相交 + @param polygon The Polygon, a set of points + @param circle Object contains position and radius + */ + static polygonCircle(polygon: Vec2[], circle: {position: Vec2, radius: number}): boolean; + /** + !#en Test whether the point is in the polygon + !#zh 测试一个点是否在一个多边形中 + @param point The point + @param polygon The polygon, a set of points + */ + static pointInPolygon(point: Vec2, polygon: Vec2[]): boolean; + /** + !#en Calculate the distance of point to line. + !#zh 计算点到直线的距离。如果这是一条线段并且垂足不在线段内,则会计算点到线段端点的距离。 + @param point The point + @param start The start point of line + @param end The end point of line + @param isSegment whether this line is a segment + */ + static pointLineDistance(point: Vec2, start: Vec2, end: Vec2, isSegment: boolean): number; + } + /** !#en Polygon Collider. + !#zh 多边形碰撞组件 */ + export class PolygonCollider extends Collider implements Collider.Polygon { + /** !#en + Collider info in world coordinate. + !#zh + 碰撞体的世界坐标系下的信息。 */ + world: ColliderInfo; + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Polygon points + !#zh 多边形顶点数组 */ + points: Vec2[]; + } + /** !#en The touch event class + !#zh 封装了触摸相关的信息。 */ + export class Touch { + /** + !#en Returns the current touch location in OpenGL coordinates.、 + !#zh 获取当前触点位置。 + */ + getLocation(): Vec2; + /** + !#en Returns X axis location value. + !#zh 获取当前触点 X 轴位置。 + */ + getLocationX(): number; + /** + !#en Returns Y axis location value. + !#zh 获取当前触点 Y 轴位置。 + */ + getLocationY(): number; + /** + !#en Returns the previous touch location in OpenGL coordinates. + !#zh 获取触点在上一次事件时的位置对象,对象包含 x 和 y 属性。 + */ + getPreviousLocation(): Vec2; + /** + !#en Returns the start touch location in OpenGL coordinates. + !#zh 获取触点落下时的位置对象,对象包含 x 和 y 属性。 + */ + getStartLocation(): Vec2; + /** + !#en Returns the delta distance from the previous touche to the current one in screen coordinates. + !#zh 获取触点距离上一次事件移动的距离对象,对象包含 x 和 y 属性。 + */ + getDelta(): Vec2; + /** + !#en Returns the current touch location in screen coordinates. + !#zh 获取当前事件在游戏窗口内的坐标位置对象,对象包含 x 和 y 属性。 + */ + getLocationInView(): Vec2; + /** + !#en Returns the previous touch location in screen coordinates. + !#zh 获取触点在上一次事件时在游戏窗口中的位置对象,对象包含 x 和 y 属性。 + */ + getPreviousLocationInView(): Vec2; + /** + !#en Returns the start touch location in screen coordinates. + !#zh 获取触点落下时在游戏窗口中的位置对象,对象包含 x 和 y 属性。 + */ + getStartLocationInView(): Vec2; + /** + !#en Returns the id of cc.Touch. + !#zh 触点的标识 ID,可以用来在多点触摸中跟踪触点。 + */ + getID(): number; + /** + !#en Sets information to touch. + !#zh 设置触摸相关的信息。用于监控触摸事件。 + @param id id + @param x x + @param y y + */ + setTouchInfo(id: number, x: number, y: number): void; + } + /** !#en The animation component is used to play back animations. + + Animation provide several events to register: + - play : Emit when begin playing animation + - stop : Emit when stop playing animation + - pause : Emit when pause animation + - resume : Emit when resume animation + - lastframe : If animation repeat count is larger than 1, emit when animation play to the last frame + - finished : Emit when finish playing animation + + !#zh Animation 组件用于播放动画。 + + Animation 提供了一系列可注册的事件: + - play : 开始播放时 + - stop : 停止播放时 + - pause : 暂停播放时 + - resume : 恢复播放时 + - lastframe : 假如动画循环次数大于 1,当动画播放到最后一帧时 + - finished : 动画播放完成时 */ + export class Animation extends Component implements EventTarget { + /** !#en Animation will play the default clip when start game. + !#zh 在勾选自动播放或调用 play() 时默认播放的动画剪辑。 */ + defaultClip: AnimationClip; + /** !#en Current played clip. + !#zh 当前播放的动画剪辑。 */ + currentClip: AnimationClip; + /** !#en Whether the animation should auto play the default clip when start game. + !#zh 是否在运行游戏后自动播放默认动画剪辑。 */ + playOnLoad: boolean; + /** + !#en Get all the clips used in this animation. + !#zh 获取动画组件上的所有动画剪辑。 + */ + getClips(): AnimationClip[]; + /** + !#en Plays an animation and stop other animations. + !#zh 播放指定的动画,并且停止当前正在播放动画。如果没有指定动画,则播放默认动画。 + @param name The name of animation to play. If no name is supplied then the default animation will be played. + @param startTime play an animation from startTime + + @example + ```js + var animCtrl = this.node.getComponent(cc.Animation); + animCtrl.play("linear"); + ``` + */ + play(name?: string, startTime?: number): AnimationState; + /** + !#en + Plays an additive animation, it will not stop other animations. + If there are other animations playing, then will play several animations at the same time. + !#zh 播放指定的动画(将不会停止当前播放的动画)。如果没有指定动画,则播放默认动画。 + @param name The name of animation to play. If no name is supplied then the default animation will be played. + @param startTime play an animation from startTime + + @example + ```js + // linear_1 and linear_2 at the same time playing. + var animCtrl = this.node.getComponent(cc.Animation); + animCtrl.playAdditive("linear_1"); + animCtrl.playAdditive("linear_2"); + ``` + */ + playAdditive(name?: string, startTime?: number): AnimationState; + /** + !#en Stops an animation named name. If no name is supplied then stops all playing animations that were started with this Animation.
+ Stopping an animation also Rewinds it to the Start. + !#zh 停止指定的动画。如果没有指定名字,则停止当前正在播放的动画。 + @param name The animation to stop, if not supplied then stops all playing animations. + */ + stop(name?: string): void; + /** + !#en Pauses an animation named name. If no name is supplied then pauses all playing animations that were started with this Animation. + !#zh 暂停当前或者指定的动画。如果没有指定名字,则暂停当前正在播放的动画。 + @param name The animation to pauses, if not supplied then pauses all playing animations. + */ + pause(name?: string): void; + /** + !#en Resumes an animation named name. If no name is supplied then resumes all paused animations that were started with this Animation. + !#zh 重新播放指定的动画,如果没有指定名字,则重新播放当前正在播放的动画。 + @param name The animation to resumes, if not supplied then resumes all paused animations. + */ + resume(name?: string): void; + /** + !#en Make an animation named name go to the specified time. If no name is supplied then make all animations go to the specified time. + !#zh 设置指定动画的播放时间。如果没有指定名字,则设置当前播放动画的播放时间。 + @param time The time to go to + @param name Specified animation name, if not supplied then make all animations go to the time. + */ + setCurrentTime(time?: number, name?: string): void; + /** + !#en Returns the animation state named name. If no animation with the specified name, the function will return null. + !#zh 获取当前或者指定的动画状态,如果未找到指定动画剪辑则返回 null。 + @param name name + */ + getAnimationState(name: string): AnimationState; + /** + !#en Adds a clip to the animation with name newName. If a clip with that name already exists it will be replaced with the new clip. + !#zh 添加动画剪辑,并且可以重新设置该动画剪辑的名称。 + @param clip the clip to add + @param newName newName + */ + addClip(clip: AnimationClip, newName?: string): AnimationState; + /** + !#en + Remove clip from the animation list. This will remove the clip and any animation states based on it. + If there are animation states depand on the clip are playing or clip is defaultClip, it will not delete the clip. + But if force is true, then will always remove the clip and any animation states based on it. If clip is defaultClip, defaultClip will be reset to null + !#zh + 从动画列表中移除指定的动画剪辑,
+ 如果依赖于 clip 的 AnimationState 正在播放或者 clip 是 defaultClip 的话,默认是不会删除 clip 的。 + 但是如果 force 参数为 true,则会强制停止该动画,然后移除该动画剪辑和相关的动画。这时候如果 clip 是 defaultClip,defaultClip 将会被重置为 null。 + @param clip clip + @param force If force is true, then will always remove the clip and any animation states based on it. + */ + removeClip(clip: AnimationClip, force?: boolean): void; + /** + !#en + Samples animations at the current state.
+ This is useful when you explicitly want to set up some animation state, and sample it once. + !#zh 对指定或当前动画进行采样。你可以手动将动画设置到某一个状态,然后采样一次。 + @param name name + */ + sample(name: string): void; + /** + !#en + Register animation event callback. + The event arguments will provide the AnimationState which emit the event. + When play an animation, will auto register the event callback to the AnimationState, and unregister the event callback from the AnimationState when animation stopped. + !#zh + 注册动画事件回调。 + 回调的事件里将会附上发送事件的 AnimationState。 + 当播放一个动画时,会自动将事件注册到对应的 AnimationState 上,停止播放时会将事件从这个 AnimationState 上取消注册。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param state state + @param target The target (this object) to invoke the callback, can be null + @param useCapture When set to true, the capture argument prevents callback + from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. + When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE. + Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET. + + @example + ```js + onPlay: function (type, state) { + // callback + } + + // register event to all animation + animation.on('play', this.onPlay, this); + ``` + */ + on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void; + on(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void; + on(type: string, callback: (type: string, state: cc.AnimationState) => void, target?: any, useCapture?: boolean): (type: string, state: cc.AnimationState) => void; + /** + !#en + Unregister animation event callback. + !#zh + 取消注册动画事件回调。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not. + If not specified, useCapture defaults to false. If a callback was registered twice, + one with capture and one without, each must be removed separately. Removal of a capturing callback + does not affect a non-capturing version of the same listener, and vice versa. + + @example + ```js + // unregister event to all animation + animation.off('play', this.onPlay, this); + ``` + */ + off(type: string, callback?: Function, target?: any, useCapture?: boolean): void; + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.once('fire', function () { + cc.log("this is the callback and will be invoked only once"); + }, node); + ``` + */ + once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; + /** + !#en + Send an event with the event object. + !#zh + 通过事件对象派发事件 + @param event event + */ + dispatchEvent(event: Event): void; + /** + !#en + Destroy all callbackInfos. + !#zh + 销毁记录的事件 + */ + clear(): void; + } + /** !#en Audio Source. + !#zh 音频源组件,能对音频剪辑。 */ + export class AudioSource extends Component { + /** !#en + Is the audio source playing (Read Only).
+ Note: isPlaying is not supported for Native platforms. + !#zh + 该音频剪辑是否正播放(只读)。
+ 注意:Native 平台暂时不支持 isPlaying。 */ + isPlaying: boolean; + /** !#en The clip of the audio source to play. + !#zh 要播放的音频剪辑。 */ + clip: AudioClip; + /** !#en The volume of the audio source. + !#zh 音频源的音量(0.0 ~ 1.0)。 */ + volume: number; + /** !#en Is the audio source mute? + !#zh 是否静音音频源。Mute 是设置音量为 0,取消静音是恢复原来的音量。 */ + mute: boolean; + /** !#en Is the audio source looping? + !#zh 音频源是否循环播放? */ + loop: boolean; + /** !#en If set to true, the audio source will automatically start playing on onEnable. + !#zh 如果设置为 true,音频源将在 onEnable 时自动播放。 */ + playOnLoad: boolean; + /** !#en If set to true and AudioClip is a deferred load resource, the component will preload AudioClip in the onLoad phase. + !#zh 如果设置为 true 且 AudioClip 为延迟加载资源,组件将在 onLoad 阶段预加载 AudioClip。 */ + preload: boolean; + /** + !#en Plays the clip. + !#zh 播放音频剪辑。 + */ + play(): void; + /** + !#en Stops the clip. + !#zh 停止当前音频剪辑。 + */ + stop(): void; + /** + !#en Pause the clip. + !#zh 暂停当前音频剪辑。 + */ + pause(): void; + /** + !#en Resume the clip. + !#zh 恢复播放。 + */ + resume(): void; + /** + !#en Rewind playing music. + !#zh 从头开始播放。 + */ + rewind(): void; + /** + !#en Get current time + !#zh 获取当前的播放时间 + */ + getCurrentTime(): number; + /** + !#en Set current time + !#zh 设置当前的播放时间 + @param time time + */ + setCurrentTime(time: number): number; + /** + !#en Get audio duration + !#zh 获取当前音频的长度 + */ + getDuration(): number; + } + /** !#en + This component will block all input events (mouse and touch) within the bounding box of the node, preventing the input from penetrating into the underlying node, typically for the background of the top UI.
+ This component does not have any API interface and can be added directly to the scene to take effect. + !#zh + 该组件将拦截所属节点 bounding box 内的所有输入事件(鼠标和触摸),防止输入穿透到下层节点,一般用于上层 UI 的背景。
+ 该组件没有任何 API 接口,直接添加到场景即可生效。 */ + export class BlockInputEvents extends Component { + } + /** !#en + Button component. Can be pressed or clicked. Button has 4 Transition types: + + - Button.Transition.NONE // Button will do nothing + - Button.Transition.COLOR // Button will change target's color + - Button.Transition.SPRITE // Button will change target Sprite's sprite + - Button.Transition.SCALE // Button will change target node's scale + + The button can bind events (but you must be on the button's node to bind events).
+ The following events can be triggered on all platforms. + + - cc.Node.EventType.TOUCH_START // Press + - cc.Node.EventType.TOUCH_MOVE // After pressing and moving + - cc.Node.EventType.TOUCH_END // After pressing and releasing + - cc.Node.EventType.TOUCH_CANCEL // Press to cancel + + The following events are only triggered on the PC platform: + + - cc.Node.EventType.MOUSE_DOWN + - cc.Node.EventType.MOUSE_MOVE + - cc.Node.EventType.MOUSE_ENTER + - cc.Node.EventType.MOUSE_LEAVE + - cc.Node.EventType.MOUSE_UP + - cc.Node.EventType.MOUSE_WHEEL + + User can get the current clicked node with 'event.target' from event object which is passed as parameter in the callback function of click event. + + !#zh + 按钮组件。可以被按下,或者点击。 + + 按钮可以通过修改 Transition 来设置按钮状态过渡的方式: + + - Button.Transition.NONE // 不做任何过渡 + - Button.Transition.COLOR // 进行颜色之间过渡 + - Button.Transition.SPRITE // 进行精灵之间过渡 + - Button.Transition.SCALE // 进行缩放过渡 + + 按钮可以绑定事件(但是必须要在按钮的 Node 上才能绑定事件):
+ 以下事件可以在全平台上都触发: + + - cc.Node.EventType.TOUCH_START // 按下时事件 + - cc.Node.EventType.TOUCH_MOVE // 按住移动后事件 + - cc.Node.EventType.TOUCH_END // 按下后松开后事件 + - cc.Node.EventType.TOUCH_CANCEL // 按下取消事件 + + 以下事件只在 PC 平台上触发: + + - cc.Node.EventType.MOUSE_DOWN // 鼠标按下时事件 + - cc.Node.EventType.MOUSE_MOVE // 鼠标按住移动后事件 + - cc.Node.EventType.MOUSE_ENTER // 鼠标进入目标事件 + - cc.Node.EventType.MOUSE_LEAVE // 鼠标离开目标事件 + - cc.Node.EventType.MOUSE_UP // 鼠标松开事件 + - cc.Node.EventType.MOUSE_WHEEL // 鼠标滚轮事件 + + 用户可以通过获取 __点击事件__ 回调函数的参数 event 的 target 属性获取当前点击对象。 */ + export class Button extends Component implements GraySpriteState { + /** !#en + Whether the Button is disabled. + If true, the Button will trigger event and do transition. + !#zh + 按钮事件是否被响应,如果为 false,则按钮将被禁用。 */ + interactable: boolean; + /** !#en When this flag is true, Button target sprite will turn gray when interactable is false. + !#zh 如果这个标记为 true,当 button 的 interactable 属性为 false 的时候,会使用内置 shader 让 button 的 target 节点的 sprite 组件变灰 */ + enableAutoGrayEffect: boolean; + /** !#en Transition type + !#zh 按钮状态改变时过渡方式。 */ + transition: Button.Transition; + /** !#en Normal state color. + !#zh 普通状态下按钮所显示的颜色。 */ + normalColor: Color; + /** !#en Pressed state color + !#zh 按下状态时按钮所显示的颜色。 */ + pressedColor: Color; + /** !#en Hover state color + !#zh 悬停状态下按钮所显示的颜色。 */ + hoverColor: Color; + /** !#en Disabled state color + !#zh 禁用状态下按钮所显示的颜色。 */ + disabledColor: Color; + /** !#en Color and Scale transition duration + !#zh 颜色过渡和缩放过渡时所需时间 */ + duration: number; + /** !#en When user press the button, the button will zoom to a scale. + The final scale of the button equals (button original scale * zoomScale) + !#zh 当用户点击按钮后,按钮会缩放到一个值,这个值等于 Button 原始 scale * zoomScale */ + zoomScale: number; + /** !#en Normal state sprite + !#zh 普通状态下按钮所显示的 Sprite 。 */ + normalSprite: SpriteFrame; + /** !#en Pressed state sprite + !#zh 按下状态时按钮所显示的 Sprite 。 */ + pressedSprite: SpriteFrame; + /** !#en Hover state sprite + !#zh 悬停状态下按钮所显示的 Sprite 。 */ + hoverSprite: SpriteFrame; + /** !#en Disabled state sprite + !#zh 禁用状态下按钮所显示的 Sprite 。 */ + disabledSprite: SpriteFrame; + /** !#en + Transition target. + When Button state changed: + If Transition type is Button.Transition.NONE, Button will do nothing + If Transition type is Button.Transition.COLOR, Button will change target's color + If Transition type is Button.Transition.SPRITE, Button will change target Sprite's sprite + !#zh + 需要过渡的目标。 + 当前按钮状态改变规则: + -如果 Transition type 选择 Button.Transition.NONE,按钮不做任何过渡。 + -如果 Transition type 选择 Button.Transition.COLOR,按钮会对目标颜色进行颜色之间的过渡。 + -如果 Transition type 选择 Button.Transition.Sprite,按钮会对目标 Sprite 进行 Sprite 之间的过渡。 */ + target: Node; + /** !#en If Button is clicked, it will trigger event's handler + !#zh 按钮的点击事件列表。 */ + clickEvents: Component.EventHandler[]; + /** !#en The normal material. + !#zh 正常状态的材质。 */ + normalMaterial: Material; + /** !#en The gray material. + !#zh 置灰状态的材质。 */ + grayMaterial: Material; + } + /** !#zh 作为 UI 根节点,为所有子节点提供视窗四边的位置信息以供对齐,另外提供屏幕适配策略接口,方便从编辑器设置。
+ 注:由于本节点的尺寸会跟随屏幕拉伸,所以 anchorPoint 只支持 (0.5, 0.5),否则适配不同屏幕时坐标会有偏差。 */ + export class Canvas extends Component { + /** !#en Current active canvas, the scene should only have one active canvas at the same time. + !#zh 当前激活的画布组件,场景同一时间只能有一个激活的画布。 */ + static instance: Canvas; + /** !#en The desigin resolution for current scene. + !#zh 当前场景设计分辨率。 */ + designResolution: Size; + /** !#en TODO + !#zh: 是否优先将设计分辨率高度撑满视图高度。 */ + fitHeight: boolean; + /** !#en TODO + !#zh: 是否优先将设计分辨率宽度撑满视图宽度。 */ + fitWidth: boolean; + } + /** !#en + Base class for everything attached to Node(Entity).
+
+ NOTE: Not allowed to use construction parameters for Component's subclasses, + because Component is created by the engine. + !#zh + 所有附加到节点的基类。
+
+ 注意:不允许使用组件的子类构造参数,因为组件是由引擎创建的。 */ + export class Component extends Object { + /** !#en The node this component is attached to. A component is always attached to a node. + !#zh 该组件被附加到的节点。组件总会附加到一个节点。 */ + node: Node; + /** !#en The uuid for editor. + !#zh 组件的 uuid,用于编辑器。 */ + uuid: string; + /** !#en indicates whether this component is enabled or not. + !#zh 表示该组件自身是否启用。 */ + enabled: boolean; + /** !#en indicates whether this component is enabled and its node is also active in the hierarchy. + !#zh 表示该组件是否被启用并且所在的节点也处于激活状态。 */ + enabledInHierarchy: boolean; + /** !#en Returns a value which used to indicate the onLoad get called or not. + !#zh 返回一个值用来判断 onLoad 是否被调用过,不等于 0 时调用过,等于 0 时未调用。 */ + _isOnLoadCalled: number; + /** + !#en Update is called every frame, if the Component is enabled.
+ This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere. + !#zh 如果该组件启用,则每帧调用 update。
+ 该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。 + @param dt the delta time in seconds it took to complete the last frame + */ + protected update(dt: number): void; + /** + !#en LateUpdate is called every frame, if the Component is enabled.
+ This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere. + !#zh 如果该组件启用,则每帧调用 LateUpdate。
+ 该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。 + @param dt the delta time in seconds it took to complete the last frame + */ + protected lateUpdate(dt: number): void; + /** + !#en + When attaching to an active node or its node first activated. + onLoad is always called before any start functions, this allows you to order initialization of scripts.
+ This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere. + !#zh + 当附加到一个激活的节点上或者其节点第一次激活时候调用。onLoad 总是会在任何 start 方法调用前执行,这能用于安排脚本的初始化顺序。
+ 该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。 + */ + protected onLoad(): void; + /** + !#en + Called before all scripts' update if the Component is enabled the first time. + Usually used to initialize some logic which need to be called after all components' `onload` methods called.
+ This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere. + !#zh + 如果该组件第一次启用,则在所有组件的 update 之前调用。通常用于需要在所有组件的 onLoad 初始化完毕后执行的逻辑。
+ 该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。 + */ + protected start(): void; + /** + !#en Called when this component becomes enabled and its node is active.
+ This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere. + !#zh 当该组件被启用,并且它的节点也激活时。
+ 该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。 + */ + protected onEnable(): void; + /** + !#en Called when this component becomes disabled or its node becomes inactive.
+ This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere. + !#zh 当该组件被禁用或节点变为无效时调用。
+ 该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。 + */ + protected onDisable(): void; + /** + !#en Called when this component will be destroyed.
+ This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere. + !#zh 当该组件被销毁时调用
+ 该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。 + */ + protected onDestroy(): void; + protected onFocusInEditor(): void; + protected onLostFocusInEditor(): void; + /** + !#en Called to initialize the component or node’s properties when adding the component the first time or when the Reset command is used. This function is only called in editor. + !#zh 用来初始化组件或节点的一些属性,当该组件被第一次添加到节点上或用户点击了它的 Reset 菜单时调用。这个回调只会在编辑器下调用。 + */ + protected resetInEditor(): void; + /** + !#en Adds a component class to the node. You can also add component to node by passing in the name of the script. + !#zh 向节点添加一个组件类,你还可以通过传入脚本的名称来添加组件。 + @param typeOrClassName the constructor or the class name of the component to add + + @example + ```js + var sprite = node.addComponent(cc.Sprite); + var test = node.addComponent("Test"); + ``` + */ + addComponent(type: {new(): T}): T; + addComponent(className: string): any; + /** + !#en + Returns the component of supplied type if the node has one attached, null if it doesn't.
+ You can also get component in the node by passing in the name of the script. + !#zh + 获取节点上指定类型的组件,如果节点有附加指定类型的组件,则返回,如果没有则为空。
+ 传入参数也可以是脚本的名称。 + @param typeOrClassName typeOrClassName + + @example + ```js + // get sprite component. + var sprite = node.getComponent(cc.Sprite); + // get custom test calss. + var test = node.getComponent("Test"); + ``` + */ + getComponent(type: {prototype: T}): T; + getComponent(className: string): any; + /** + !#en Returns all components of supplied Type in the node. + !#zh 返回节点上指定类型的所有组件。 + @param typeOrClassName typeOrClassName + + @example + ```js + var sprites = node.getComponents(cc.Sprite); + var tests = node.getComponents("Test"); + ``` + */ + getComponents(type: {prototype: T}): T[]; + getComponents(className: string): any[]; + /** + !#en Returns the component of supplied type in any of its children using depth first search. + !#zh 递归查找所有子节点中第一个匹配指定类型的组件。 + @param typeOrClassName typeOrClassName + + @example + ```js + var sprite = node.getComponentInChildren(cc.Sprite); + var Test = node.getComponentInChildren("Test"); + ``` + */ + getComponentInChildren(type: {prototype: T}): T; + getComponentInChildren(className: string): any; + /** + !#en Returns the components of supplied type in self or any of its children using depth first search. + !#zh 递归查找自身或所有子节点中指定类型的组件 + @param typeOrClassName typeOrClassName + + @example + ```js + var sprites = node.getComponentsInChildren(cc.Sprite); + var tests = node.getComponentsInChildren("Test"); + ``` + */ + getComponentsInChildren(type: {prototype: T}): T[]; + getComponentsInChildren(className: string): any[]; + /** + !#en + If the component's bounding box is different from the node's, you can implement this method to supply + a custom axis aligned bounding box (AABB), so the editor's scene view can perform hit test properly. + !#zh + 如果组件的包围盒与节点不同,您可以实现该方法以提供自定义的轴向对齐的包围盒(AABB), + 以便编辑器的场景视图可以正确地执行点选测试。 + @param out_rect the Rect to receive the bounding box + */ + _getLocalBounds(out_rect: Rect): void; + /** + !#en + onRestore is called after the user clicks the Reset item in the Inspector's context menu or performs + an undo operation on this component.
+
+ If the component contains the "internal state", short for "temporary member variables which not included
+ in its CCClass properties", then you may need to implement this function.
+
+ The editor will call the getset accessors of your component to record/restore the component's state
+ for undo/redo operation. However, in extreme cases, it may not works well. Then you should implement
+ this function to manually synchronize your component's "internal states" with its public properties.
+ Once you implement this function, all the getset accessors of your component will not be called when
+ the user performs an undo/redo operation. Which means that only the properties with default value
+ will be recorded or restored by editor.
+
+ Similarly, the editor may failed to reset your component correctly in extreme cases. Then if you need
+ to support the reset menu, you should manually synchronize your component's "internal states" with its
+ properties in this function. Once you implement this function, all the getset accessors of your component
+ will not be called during reset operation. Which means that only the properties with default value
+ will be reset by editor. + + This function is only called in editor mode. + !#zh + onRestore 是用户在检查器菜单点击 Reset 时,对此组件执行撤消操作后调用的。
+
+ 如果组件包含了“内部状态”(不在 CCClass 属性中定义的临时成员变量),那么你可能需要实现该方法。
+
+ 编辑器执行撤销/重做操作时,将调用组件的 get set 来录制和还原组件的状态。然而,在极端的情况下,它可能无法良好运作。
+ 那么你就应该实现这个方法,手动根据组件的属性同步“内部状态”。一旦你实现这个方法,当用户撤销或重做时,组件的所有 get set 都不会再被调用。这意味着仅仅指定了默认值的属性将被编辑器记录和还原。
+
+ 同样的,编辑可能无法在极端情况下正确地重置您的组件。如果你需要支持组件重置菜单,则需要在该方法中手工同步组件属性到“内部状态”。一旦你实现这个方法,组件的所有 get set 都不会在重置操作时被调用。这意味着仅仅指定了默认值的属性将被编辑器重置。 +
+ 此方法仅在编辑器下会被调用。 + */ + onRestore(): void; + /** + !#en + Schedules a custom selector.
+ If the selector is already scheduled, then the interval parameter will be updated without scheduling it again. + !#zh + 调度一个自定义的回调函数。
+ 如果回调函数已调度,那么将不会重复调度它,只会更新时间间隔参数。 + @param callback The callback function + @param interval Tick interval in seconds. 0 means tick every frame. + @param repeat The selector will be executed (repeat + 1) times, you can use cc.macro.REPEAT_FOREVER for tick infinitely. + @param delay The amount of time that the first tick will wait before execution. Unit: s + + @example + ```js + var timeCallback = function (dt) { + cc.log("time: " + dt); + } + this.schedule(timeCallback, 1); + ``` + */ + schedule(callback: Function, interval?: number, repeat?: number, delay?: number): void; + /** + !#en Schedules a callback function that runs only once, with a delay of 0 or larger. + !#zh 调度一个只运行一次的回调函数,可以指定 0 让回调函数在下一帧立即执行或者在一定的延时之后执行。 + @param callback A function wrapped as a selector + @param delay The amount of time that the first tick will wait before execution. Unit: s + + @example + ```js + var timeCallback = function (dt) { + cc.log("time: " + dt); + } + this.scheduleOnce(timeCallback, 2); + ``` + */ + scheduleOnce(callback: Function, delay?: number): void; + /** + !#en Unschedules a custom callback function. + !#zh 取消调度一个自定义的回调函数。 + @param callback_fn A function wrapped as a selector + + @example + ```js + this.unschedule(_callback); + ``` + */ + unschedule(callback_fn: Function): void; + /** + !#en + unschedule all scheduled callback functions: custom callback functions, and the 'update' callback function.
+ Actions are not affected by this method. + !#zh 取消调度所有已调度的回调函数:定制的回调函数以及 `update` 回调函数。动作不受此方法影响。 + + @example + ```js + this.unscheduleAllCallbacks(); + ``` + */ + unscheduleAllCallbacks(): void; + } + /** !#en The Label Component. + !#zh 文字标签组件 */ + export class Label extends RenderComponent { + /** !#en Content string of label. + !#zh 标签显示的文本内容。 */ + string: string; + /** !#en Horizontal Alignment of label. + !#zh 文本内容的水平对齐方式。 */ + horizontalAlign: Label.HorizontalAlign; + /** !#en Vertical Alignment of label. + !#zh 文本内容的垂直对齐方式。 */ + verticalAlign: Label.VerticalAlign; + /** !#en The actual rendering font size in shrink mode + !#zh SHRINK 模式下面文本实际渲染的字体大小 */ + actualFontSize: number; + /** !#en Font size of label. + !#zh 文本字体大小。 */ + fontSize: number; + /** !#en Font family of label, only take effect when useSystemFont property is true. + !#zh 文本字体名称, 只在 useSystemFont 属性为 true 的时候生效。 */ + fontFamily: string; + /** !#en Line Height of label. + !#zh 文本行高。 */ + lineHeight: number; + /** !#en Overflow of label. + !#zh 文字显示超出范围时的处理方式。 */ + overflow: Label.Overflow; + /** !#en Whether auto wrap label when string width is large than label width. + !#zh 是否自动换行。 */ + enableWrapText: boolean; + /** !#en The font of label. + !#zh 文本字体。 */ + font: Font; + /** !#en Whether use system font name or not. + !#zh 是否使用系统字体。 */ + useSystemFont: boolean; + /** !#en The spacing of the x axis between characters, only take Effect when using bitmap fonts. + !#zh 文字之间 x 轴的间距,仅在使用位图字体时生效。 */ + spacingX: number; + /** !#en The cache mode of label. This mode only supports system fonts. + !#zh 文本缓存模式, 该模式只支持系统字体。 */ + cacheMode: Label.CacheMode; + /** !#en Whether enable bold. + !#zh 是否启用黑体。 */ + enableBold: boolean; + /** !#en Whether enable italic. + !#zh 是否启用斜体。 */ + enableItalic: boolean; + /** !#en Whether enable underline. + !#zh 是否启用下划线。 */ + enableUnderline: boolean; + /** !#en The height of underline. + !#zh 下划线高度。 */ + underlineHeight: number; + /** + !#zh 需要保证当前场景中没有使用CHAR缓存的Label才可以清除,否则已渲染的文字没有重新绘制会不显示 + !#en It can be cleared that need to ensure there is not use the CHAR cache in the current scene. Otherwise, the rendered text will not be displayed without repainting. + */ + static clearCharCache(): void; + } + /** !#en Outline effect used to change the display, only for system fonts or TTF fonts + !#zh 描边效果组件,用于字体描边,只能用于系统字体 */ + export class LabelOutline extends Component { + /** !#en outline color + !#zh 改变描边的颜色 */ + color: Color; + /** !#en Change the outline width + !#zh 改变描边的宽度 */ + width: number; + } + /** !#en Shadow effect for Label component, only for system fonts or TTF fonts + !#zh 用于给 Label 组件添加阴影效果,只能用于系统字体或 ttf 字体 */ + export class LabelShadow extends Component { + /** !#en The shadow color + !#zh 阴影的颜色 */ + color: Color; + /** !#en Offset between font and shadow + !#zh 字体与阴影的偏移 */ + offset: Vec2; + /** !#en A non-negative float specifying the level of shadow blur + !#zh 阴影的模糊程度 */ + blur: number; + } + /** !#en + The Layout is a container component, use it to arrange child elements easily.
+ Note:
+ 1.Scaling and rotation of child nodes are not considered.
+ 2.After setting the Layout, the results need to be updated until the next frame, + unless you manually call {{#crossLink "Layout/updateLayout:method"}}{{/crossLink}}。 + !#zh + Layout 组件相当于一个容器,能自动对它的所有子节点进行统一排版。
+ 注意:
+ 1.不会考虑子节点的缩放和旋转。
+ 2.对 Layout 设置后结果需要到下一帧才会更新,除非你设置完以后手动调用 {{#crossLink "Layout/updateLayout:method"}}{{/crossLink}}。 */ + export class Layout extends Component { + /** !#en The layout type. + !#zh 布局类型 */ + type: Layout.Type; + /** !#en + The are three resize modes for Layout. + None, resize Container and resize children. + !#zh 缩放模式 */ + resizeMode: Layout.ResizeMode; + /** !#en The cell size for grid layout. + !#zh 每个格子的大小,只有布局类型为 GRID 的时候才有效。 */ + cellSize: Size; + /** !#en + The start axis for grid layout. If you choose horizontal, then children will layout horizontally at first, + and then break line on demand. Choose vertical if you want to layout vertically at first . + !#zh 起始轴方向类型,可进行水平和垂直布局排列,只有布局类型为 GRID 的时候才有效。 */ + startAxis: Layout.AxisDirection; + /** !#en The left padding of layout, it only effect the layout in one direction. + !#zh 容器内左边距,只会在一个布局方向上生效。 */ + paddingLeft: number; + /** !#en The right padding of layout, it only effect the layout in one direction. + !#zh 容器内右边距,只会在一个布局方向上生效。 */ + paddingRight: number; + /** !#en The top padding of layout, it only effect the layout in one direction. + !#zh 容器内上边距,只会在一个布局方向上生效。 */ + paddingTop: number; + /** !#en The bottom padding of layout, it only effect the layout in one direction. + !#zh 容器内下边距,只会在一个布局方向上生效。 */ + paddingBottom: number; + /** !#en The distance in x-axis between each element in layout. + !#zh 子节点之间的水平间距。 */ + spacingX: number; + /** !#en The distance in y-axis between each element in layout. + !#zh 子节点之间的垂直间距。 */ + spacingY: number; + /** !#en + Only take effect in Vertical layout mode. + This option changes the start element's positioning. + !#zh 垂直排列子节点的方向。 */ + verticalDirection: Layout.VerticalDirection; + /** !#en + Only take effect in Horizontal layout mode. + This option changes the start element's positioning. + !#zh 水平排列子节点的方向。 */ + horizontalDirection: Layout.HorizontalDirection; + /** !#en Adjust the layout if the children scaled. + !#zh 子节点缩放比例是否影响布局。 */ + affectedByScale: boolean; + /** + !#en Perform the layout update + !#zh 立即执行更新布局 + + @example + ```js + layout.type = cc.Layout.HORIZONTAL; + layout.node.addChild(childNode); + cc.log(childNode.x); // not yet changed + layout.updateLayout(); + cc.log(childNode.x); // changed + ``` + */ + updateLayout(): void; + } + /** !#en The Mask Component + !#zh 遮罩组件 */ + export class Mask extends RenderComponent { + /** !#en The mask type. + !#zh 遮罩类型 */ + type: Mask.Type; + /** !#en The mask image + !#zh 遮罩所需要的贴图 */ + spriteFrame: SpriteFrame; + /** !#en + The alpha threshold.(Not supported Canvas Mode)
+ The content is drawn only where the stencil have pixel with alpha greater than the alphaThreshold.
+ Should be a float between 0 and 1.
+ This default to 0.1. + When it's set to 1, the stencil will discard all pixels, nothing will be shown. + !#zh + Alpha 阈值(不支持 Canvas 模式)
+ 只有当模板的像素的 alpha 大于等于 alphaThreshold 时,才会绘制内容。
+ 该数值 0 ~ 1 之间的浮点数,默认值为 0.1 + 当被设置为 1 时,会丢弃所有蒙版像素,所以不会显示任何内容 */ + alphaThreshold: number; + /** !#en Reverse mask (Not supported Canvas Mode) + !#zh 反向遮罩(不支持 Canvas 模式) */ + inverted: boolean; + /** TODO: remove segments, not supported by graphics + !#en The segements for ellipse mask. + !#zh 椭圆遮罩的曲线细分数 */ + segements: number; + } + /** !#en + cc.MotionStreak manages a Ribbon based on it's motion in absolute space.
+ You construct it with a fadeTime, minimum segment size, texture path, texture
+ length and color. The fadeTime controls how long it takes each vertex in
+ the streak to fade out, the minimum segment size it how many pixels the
+ streak will move before adding a new ribbon segment, and the texture
+ length is the how many pixels the texture is stretched across. The texture
+ is vertically aligned along the streak segment. + !#zh 运动轨迹,用于游戏对象的运动轨迹上实现拖尾渐隐效果。 */ + export class MotionStreak extends Component implements BlendFunc { + /** !#en + !#zh 在编辑器模式下预览拖尾效果。 */ + preview: boolean; + /** !#en The fade time to fade. + !#zh 拖尾的渐隐时间,以秒为单位。 */ + fadeTime: number; + /** !#en The minimum segment size. + !#zh 拖尾之间最小距离。 */ + minSeg: number; + /** !#en The stroke's width. + !#zh 拖尾的宽度。 */ + stroke: number; + /** !#en The texture of the MotionStreak. + !#zh 拖尾的贴图。 */ + texture: Texture2D; + /** !#en The color of the MotionStreak. + !#zh 拖尾的颜色 */ + color: Color; + /** !#en The fast Mode. + !#zh 是否启用了快速模式。当启用快速模式,新的点会被更快地添加,但精度较低。 */ + fastMode: boolean; + /** + !#en Remove all living segments of the ribbon. + !#zh 删除当前所有的拖尾片段。 + + @example + ```js + // Remove all living segments of the ribbon. + myMotionStreak.reset(); + ``` + */ + reset(): void; + /** !#en specify the source Blend Factor, this will generate a custom material object, please pay attention to the memory cost. + !#zh 指定原图的混合模式,这会克隆一个新的材质对象,注意这带来的开销 */ + srcBlendFactor: macro.BlendFactor; + /** !#en specify the destination Blend Factor. + !#zh 指定目标的混合模式 */ + dstBlendFactor: macro.BlendFactor; + } + /** !#en The PageView control + !#zh 页面视图组件 */ + export class PageView extends ScrollView { + /** !#en Specify the size type of each page in PageView. + !#zh 页面视图中每个页面大小类型 */ + sizeMode: PageView.SizeMode; + /** !#en The page view direction + !#zh 页面视图滚动类型 */ + direction: PageView.Direction; + /** !#en + The scroll threshold value, when drag exceeds this value, + release the next page will automatically scroll, less than the restore + !#zh 滚动临界值,默认单位百分比,当拖拽超出该数值时,松开会自动滚动下一页,小于时则还原。 */ + scrollThreshold: number; + /** !#en + Auto page turning velocity threshold. When users swipe the PageView quickly, + it will calculate a velocity based on the scroll distance and time, + if the calculated velocity is larger than the threshold, then it will trigger page turning. + !#zh + 快速滑动翻页临界值。 + 当用户快速滑动时,会根据滑动开始和结束的距离与时间计算出一个速度值, + 该值与此临界值相比较,如果大于临界值,则进行自动翻页。 */ + autoPageTurningThreshold: number; + /** !#en Change the PageTurning event timing of PageView. + !#zh 设置 PageView PageTurning 事件的发送时机。 */ + pageTurningEventTiming: number; + /** !#en The Page View Indicator + !#zh 页面视图指示器组件 */ + indicator: PageViewIndicator; + /** !#en The time required to turn over a page. unit: second + !#zh 每个页面翻页时所需时间。单位:秒 */ + pageTurningSpeed: number; + /** !#en PageView events callback + !#zh 滚动视图的事件回调函数 */ + pageEvents: Component.EventHandler[]; + /** + !#en Returns current page index + !#zh 返回当前页面索引 + */ + getCurrentPageIndex(): number; + /** + !#en Set current page index + !#zh 设置当前页面索引 + @param index index + */ + setCurrentPageIndex(index: number): void; + /** + !#en Returns all pages of pageview + !#zh 返回视图中的所有页面 + */ + getPages(): Node[]; + /** + !#en At the end of the current page view to insert a new view + !#zh 在当前页面视图的尾部插入一个新视图 + @param page page + */ + addPage(page: Node): void; + /** + !#en Inserts a page in the specified location + !#zh 将页面插入指定位置中 + @param page page + @param index index + */ + insertPage(page: Node, index: number): void; + /** + !#en Removes a page from PageView. + !#zh 移除指定页面 + @param page page + */ + removePage(page: Node): void; + /** + !#en Removes a page at index of PageView. + !#zh 移除指定下标的页面 + @param index index + */ + removePageAtIndex(index: number): void; + /** + !#en Removes all pages from PageView + !#zh 移除所有页面 + */ + removeAllPages(): void; + /** + !#en Scroll PageView to index. + !#zh 滚动到指定页面 + @param idx index of page. + @param timeInSecond scrolling time + */ + scrollToPage(idx: number, timeInSecond: number): void; + } + /** !#en + Visual indicator of progress in some operation. + Displays a bar to the user representing how far the operation has progressed. + !#zh + 进度条组件,可用于显示加载资源时的进度。 */ + export class ProgressBar extends Component { + /** !#en The targeted Sprite which will be changed progressively. + !#zh 用来显示进度条比例的 Sprite 对象。 */ + barSprite: Sprite; + /** !#en The progress mode, there are two modes supported now: horizontal and vertical. + !#zh 进度条的模式 */ + mode: ProgressBar.Mode; + /** !#en The total width or height of the bar sprite. + !#zh 进度条实际的总长度 */ + totalLength: number; + /** !#en The current progress of the bar sprite. The valid value is between 0-1. + !#zh 当前进度值,该数值的区间是 0-1 之间。 */ + progress: number; + /** !#en Whether reverse the progress direction of the bar sprite. + !#zh 进度条是否进行反方向变化。 */ + reverse: boolean; + } + /** !#en The Page View Indicator Component + !#zh 页面视图每页标记组件 */ + export class PageViewIndicator extends Component { + /** !#en The spriteFrame for each element. + !#zh 每个页面标记显示的图片 */ + spriteFrame: SpriteFrame; + /** !#en The location direction of PageViewIndicator. + !#zh 页面标记摆放方向 */ + direction: PageViewIndicator.Direction; + /** !#en The cellSize for each element. + !#zh 每个页面标记的大小 */ + cellSize: Size; + /** !#en The distance between each element. + !#zh 每个页面标记之间的边距 */ + spacing: number; + /** + !#en Set Page View + !#zh 设置页面视图 + @param target target + */ + setPageView(target: PageView): void; + } + /** !#en + Base class for components which supports rendering features. + !#zh + 所有支持渲染的组件的基类 */ + export class RenderComponent extends Component { + /** !#en The materials used by this render component. + !#zh 渲染组件使用的材质。 */ + sharedMaterials: Material[]; + /** + !#en Get the material by index. + !#zh 根据指定索引获取材质 + @param index index + */ + getMaterial(index: number): MaterialVariant; + /** + !#en Gets all the materials. + !#zh 获取所有材质。 + */ + getMaterials(): MaterialVariant[]; + /** + !#en Set the material by index. + !#zh 根据指定索引设置材质 + @param index index + @param material material + */ + setMaterial(index: number, material: Material): Material; + } + /** !#en The RichText Component. + !#zh 富文本组件 */ + export class RichText extends Component { + /** !#en Content string of RichText. + !#zh 富文本显示的文本内容。 */ + string: string; + /** !#en Horizontal Alignment of each line in RichText. + !#zh 文本内容的水平对齐方式。 */ + horizontalAlign: macro.TextAlignment; + /** !#en Font size of RichText. + !#zh 富文本字体大小。 */ + fontSize: number; + /** !#en Custom System font of RichText + !#zh 富文本定制系统字体 */ + fontFamily: string; + /** !#en Custom TTF font of RichText + !#zh 富文本定制字体 */ + font: TTFFont; + /** !#en Whether use system font name or not. + !#zh 是否使用系统字体。 */ + useSystemFont: boolean; + /** !#en The cache mode of label. This mode only supports system fonts. + !#zh 文本缓存模式, 该模式只支持系统字体。 */ + cacheMode: Label.CacheMode; + /** !#en The maximize width of the RichText + !#zh 富文本的最大宽度 */ + maxWidth: number; + /** !#en Line Height of RichText. + !#zh 富文本行高。 */ + lineHeight: number; + /** !#en The image atlas for the img tag. For each src value in the img tag, there should be a valid spriteFrame in the image atlas. + !#zh 对于 img 标签里面的 src 属性名称,都需要在 imageAtlas 里面找到一个有效的 spriteFrame,否则 img tag 会判定为无效。 */ + imageAtlas: SpriteAtlas; + /** !#en + Once checked, the RichText will block all input events (mouse and touch) within + the bounding box of the node, preventing the input from penetrating into the underlying node. + !#zh + 选中此选项后,RichText 将阻止节点边界框中的所有输入事件(鼠标和触摸),从而防止输入事件穿透到底层节点。 */ + handleTouchEvent: boolean; + } + /** !#en + This component is used to adjust the layout of current node to respect the safe area of a notched mobile device such as the iPhone X. + It is typically used for the top node of the UI interaction area. For specific usage, refer to the official [example-cases/02_ui/16_safeArea/SafeArea.fire](https://github.com/cocos-creator/example-cases). + + The concept of safe area is to give you a fixed inner rectangle in which you can safely display content that will be drawn on screen. + You are strongly discouraged from providing controls outside of this area. But your screen background could embellish edges. + + This component internally uses the API `cc.sys.getSafeAreaRect();` to obtain the safe area of the current iOS or Android device, + and implements the adaptation by using the Widget component and set anchor. + + !#zh + 该组件会将所在节点的布局适配到 iPhone X 等异形屏手机的安全区域内,通常用于 UI 交互区域的顶层节点,具体用法可参考官方范例 [example-cases/02_ui/16_safeArea/SafeArea.fire](https://github.com/cocos-creator/example-cases)。 + + 该组件内部通过 API `cc.sys.getSafeAreaRect();` 获取到当前 iOS 或 Android 设备的安全区域,并通过 Widget 组件实现适配。 */ + export class SafeArea extends Component { + /** + !#en Adapt to safe area + !#zh 立即适配安全区域 + + @example + ```js + let safeArea = this.node.addComponent(cc.SafeArea); + safeArea.updateArea(); + ``` + */ + updateArea(): void; + } + /** !#en + The Scrollbar control allows the user to scroll an image or other view that is too large to see completely + !#zh 滚动条组件 */ + export class Scrollbar extends Component { + /** !#en The "handle" part of the scrollbar. + !#zh 作为当前滚动区域位置显示的滑块 Sprite。 */ + handle: Sprite; + /** !#en The direction of scrollbar. + !#zh ScrollBar 的滚动方向。 */ + direction: Scrollbar.Direction; + /** !#en Whether enable auto hide or not. + !#zh 是否在没有滚动动作时自动隐藏 ScrollBar。 */ + enableAutoHide: boolean; + /** !#en + The time to hide scrollbar when scroll finished. + Note: This value is only useful when enableAutoHide is true. + !#zh + 没有滚动动作后经过多久会自动隐藏。 + 注意:只要当 “enableAutoHide” 为 true 时,才有效。 */ + autoHideTime: number; + } + /** !#en + Layout container for a view hierarchy that can be scrolled by the user, + allowing it to be larger than the physical display. + + !#zh + 滚动视图组件 */ + export class ScrollView extends Component { + /** !#en This is a reference to the UI element to be scrolled. + !#zh 可滚动展示内容的节点。 */ + content: Node; + /** !#en Enable horizontal scroll. + !#zh 是否开启水平滚动。 */ + horizontal: boolean; + /** !#en Enable vertical scroll. + !#zh 是否开启垂直滚动。 */ + vertical: boolean; + /** !#en When inertia is set, the content will continue to move when touch ended. + !#zh 是否开启滚动惯性。 */ + inertia: boolean; + /** !#en + It determines how quickly the content stop moving. A value of 1 will stop the movement immediately. + A value of 0 will never stop the movement until it reaches to the boundary of scrollview. + !#zh + 开启惯性后,在用户停止触摸后滚动多快停止,0表示永不停止,1表示立刻停止。 */ + brake: number; + /** !#en When elastic is set, the content will be bounce back when move out of boundary. + !#zh 是否允许滚动内容超过边界,并在停止触摸后回弹。 */ + elastic: boolean; + /** !#en The elapse time of bouncing back. A value of 0 will bounce back immediately. + !#zh 回弹持续的时间,0 表示将立即反弹。 */ + bounceDuration: number; + /** !#en The horizontal scrollbar reference. + !#zh 水平滚动的 ScrollBar。 */ + horizontalScrollBar: Scrollbar; + /** !#en The vertical scrollbar reference. + !#zh 垂直滚动的 ScrollBar。 */ + verticalScrollBar: Scrollbar; + /** !#en Scrollview events callback + !#zh 滚动视图的事件回调函数 */ + scrollEvents: Component.EventHandler[]; + /** !#en If cancelInnerEvents is set to true, the scroll behavior will cancel touch events on inner content nodes + It's set to true by default. + !#zh 如果这个属性被设置为 true,那么滚动行为会取消子节点上注册的触摸事件,默认被设置为 true。 + 注意,子节点上的 touchstart 事件仍然会触发,触点移动距离非常短的情况下 touchmove 和 touchend 也不会受影响。 */ + cancelInnerEvents: boolean; + /** + !#en Scroll the content to the bottom boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图底部。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the bottom boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the bottom of the view. + scrollView.scrollToBottom(0.1); + ``` + */ + scrollToBottom(timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the top boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图顶部。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the top boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the top of the view. + scrollView.scrollToTop(0.1); + ``` + */ + scrollToTop(timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the left boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图左边。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the left boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the left of the view. + scrollView.scrollToLeft(0.1); + ``` + */ + scrollToLeft(timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the right boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图右边。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the right boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the right of the view. + scrollView.scrollToRight(0.1); + ``` + */ + scrollToRight(timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the top left boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图左上角。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the top left boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the upper left corner of the view. + scrollView.scrollToTopLeft(0.1); + ``` + */ + scrollToTopLeft(timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the top right boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图右上角。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the top right boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the top right corner of the view. + scrollView.scrollToTopRight(0.1); + ``` + */ + scrollToTopRight(timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the bottom left boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图左下角。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the bottom left boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the lower left corner of the view. + scrollView.scrollToBottomLeft(0.1); + ``` + */ + scrollToBottomLeft(timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the bottom right boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图右下角。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the bottom right boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the lower right corner of the view. + scrollView.scrollToBottomRight(0.1); + ``` + */ + scrollToBottomRight(timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll with an offset related to the ScrollView's top left origin, if timeInSecond is omitted, then it will jump to the + specific offset immediately. + !#zh 视图内容在规定时间内将滚动到 ScrollView 相对左上角原点的偏移位置, 如果 timeInSecond参数不传,则立即滚动到指定偏移位置。 + @param offset A Vec2, the value of which each axis between 0 and maxScrollOffset + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the specific offset of ScrollView immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to middle position in 0.1 second in x-axis + let maxScrollOffset = this.getMaxScrollOffset(); + scrollView.scrollToOffset(cc.v2(maxScrollOffset.x / 2, 0), 0.1); + ``` + */ + scrollToOffset(offset: Vec2, timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Get the positive offset value corresponds to the content's top left boundary. + !#zh 获取滚动视图相对于左上角原点的当前滚动偏移 + */ + getScrollOffset(): Vec2; + /** + !#en Get the maximize available scroll offset + !#zh 获取滚动视图最大可以滚动的偏移量 + */ + getMaxScrollOffset(): Vec2; + /** + !#en Scroll the content to the horizontal percent position of ScrollView. + !#zh 视图内容在规定时间内将滚动到 ScrollView 水平方向的百分比位置上。 + @param percent A value between 0 and 1. + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the horizontal percent position of ScrollView immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to middle position. + scrollView.scrollToBottomRight(0.5, 0.1); + ``` + */ + scrollToPercentHorizontal(percent: number, timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the percent position of ScrollView in any direction. + !#zh 视图内容在规定时间内进行垂直方向和水平方向的滚动,并且滚动到指定百分比位置上。 + @param anchor A point which will be clamp between cc.v2(0,0) and cc.v2(1,1). + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the percent position of ScrollView immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Vertical scroll to the bottom of the view. + scrollView.scrollTo(cc.v2(0, 1), 0.1); + + // Horizontal scroll to view right. + scrollView.scrollTo(cc.v2(1, 0), 0.1); + ``` + */ + scrollTo(anchor: Vec2, timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the vertical percent position of ScrollView. + !#zh 视图内容在规定时间内滚动到 ScrollView 垂直方向的百分比位置上。 + @param percent A value between 0 and 1. + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the vertical percent position of ScrollView immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + // Scroll to middle position. + scrollView.scrollToPercentVertical(0.5, 0.1); + */ + scrollToPercentVertical(percent: number, timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Stop auto scroll immediately + !#zh 停止自动滚动, 调用此 API 可以让 Scrollview 立即停止滚动 + */ + stopAutoScroll(): void; + /** + !#en Modify the content position. + !#zh 设置当前视图内容的坐标点。 + @param position The position in content's parent space. + */ + setContentPosition(position: Vec2): void; + /** + !#en Query the content's position in its parent space. + !#zh 获取当前视图内容的坐标点。 + */ + getContentPosition(): Vec2; + /** + !#en Query whether the user is currently dragging the ScrollView to scroll it + !#zh 用户是否在拖拽当前滚动视图 + */ + isScrolling(): boolean; + /** + !#en Query whether the ScrollView is currently scrolling because of a bounceback or inertia slowdown. + !#zh 当前滚动视图是否在惯性滚动 + */ + isAutoScrolling(): boolean; + } + /** !#en The Slider Control + !#zh 滑动器组件 */ + export class Slider extends Component { + /** !#en The "handle" part of the slider + !#zh 滑动器滑块按钮部件 */ + handle: Button; + /** !#en The slider direction + !#zh 滑动器方向 */ + direction: Slider.Direction; + /** !#en The current progress of the slider. The valid value is between 0-1 + !#zh 当前进度值,该数值的区间是 0-1 之间 */ + progress: number; + /** !#en The slider slide events' callback array + !#zh 滑动器组件滑动事件回调函数数组 */ + slideEvents: Component.EventHandler[]; + } + /** !#en Renders a sprite in the scene. + !#zh 该组件用于在场景中渲染精灵。 */ + export class Sprite extends RenderComponent implements BlendFunc { + /** !#en The sprite frame of the sprite. + !#zh 精灵的精灵帧 */ + spriteFrame: SpriteFrame; + /** !#en The sprite render type. + !#zh 精灵渲染类型 */ + type: Sprite.Type; + /** !#en + The fill type, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”. + !#zh + 精灵填充类型,仅渲染类型设置为 cc.Sprite.Type.FILLED 时有效。 */ + fillType: Sprite.FillType; + /** !#en + The fill Center, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”. + !#zh + 填充中心点,仅渲染类型设置为 cc.Sprite.Type.FILLED 时有效。 */ + fillCenter: Vec2; + /** !#en + The fill Start, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”. + !#zh + 填充起始点,仅渲染类型设置为 cc.Sprite.Type.FILLED 时有效。 */ + fillStart: number; + /** !#en + The fill Range, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”. + !#zh + 填充范围,仅渲染类型设置为 cc.Sprite.Type.FILLED 时有效。 */ + fillRange: number; + /** !#en specify the frame is trimmed or not. + !#zh 是否使用裁剪模式 */ + trim: boolean; + /** !#en specify the size tracing mode. + !#zh 精灵尺寸调整模式 */ + sizeMode: Sprite.SizeMode; + /** + Change the state of sprite. + @param state NORMAL or GRAY State. + */ + setState(state: Sprite.State): void; + /** + Gets the current state. + */ + getState(): Sprite.State; + /** !#en specify the source Blend Factor, this will generate a custom material object, please pay attention to the memory cost. + !#zh 指定原图的混合模式,这会克隆一个新的材质对象,注意这带来的开销 */ + srcBlendFactor: macro.BlendFactor; + /** !#en specify the destination Blend Factor. + !#zh 指定目标的混合模式 */ + dstBlendFactor: macro.BlendFactor; + } + /** !#en The toggle component is a CheckBox, when it used together with a ToggleGroup, it + could be treated as a RadioButton. + !#zh Toggle 是一个 CheckBox,当它和 ToggleGroup 一起使用的时候,可以变成 RadioButton。 */ + export class Toggle extends Button implements GraySpriteState { + /** !#en When this value is true, the check mark component will be enabled, otherwise + the check mark component will be disabled. + !#zh 如果这个设置为 true,则 check mark 组件会处于 enabled 状态,否则处于 disabled 状态。 */ + isChecked: boolean; + /** !#en The toggle group which the toggle belongs to, when it is null, the toggle is a CheckBox. + Otherwise, the toggle is a RadioButton. + !#zh Toggle 所属的 ToggleGroup,这个属性是可选的。如果这个属性为 null,则 Toggle 是一个 CheckBox, + 否则,Toggle 是一个 RadioButton。 */ + toggleGroup: ToggleGroup; + /** !#en The image used for the checkmark. + !#zh Toggle 处于选中状态时显示的图片 */ + checkMark: Sprite; + /** !#en If Toggle is clicked, it will trigger event's handler + !#zh Toggle 按钮的点击事件列表。 */ + checkEvents: Component.EventHandler[]; + /** + !#en Make the toggle button checked. + !#zh 使 toggle 按钮处于选中状态 + */ + check(): void; + /** + !#en Make the toggle button unchecked. + !#zh 使 toggle 按钮处于未选中状态 + */ + uncheck(): void; + /** !#en The normal material. + !#zh 正常状态的材质。 */ + normalMaterial: Material; + /** !#en The gray material. + !#zh 置灰状态的材质。 */ + grayMaterial: Material; + } + /** !#en ToggleContainer is not a visiable UI component but a way to modify the behavior of a set of Toggles.
+ Toggles that belong to the same group could only have one of them to be switched on at a time.
+ Note: All the first layer child node containing the toggle component will auto be added to the container + !#zh ToggleContainer 不是一个可见的 UI 组件,它可以用来修改一组 Toggle 组件的行为。
+ 当一组 Toggle 属于同一个 ToggleContainer 的时候,任何时候只能有一个 Toggle 处于选中状态。
+ 注意:所有包含 Toggle 组件的一级子节点都会自动被添加到该容器中 */ + export class ToggleContainer extends Component { + /** !#en If this setting is true, a toggle could be switched off and on when pressed. + If it is false, it will make sure there is always only one toggle could be switched on + and the already switched on toggle can't be switched off. + !#zh 如果这个设置为 true, 那么 toggle 按钮在被点击的时候可以反复地被选中和未选中。 */ + allowSwitchOff: boolean; + /** !#en If Toggle is clicked, it will trigger event's handler + !#zh Toggle 按钮的点击事件列表。 */ + checkEvents: Component.EventHandler[]; + /** !#en Read only property, return the toggle items array reference managed by ToggleContainer. + !#zh 只读属性,返回 ToggleContainer 管理的 toggle 数组引用 */ + toggleItems: Toggle[]; + } + /** !#en ToggleGroup is not a visiable UI component but a way to modify the behavior of a set of Toggles. + Toggles that belong to the same group could only have one of them to be switched on at a time. + !#zh ToggleGroup 不是一个可见的 UI 组件,它可以用来修改一组 Toggle 组件的行为。当一组 Toggle 属于同一个 ToggleGroup 的时候, + 任何时候只能有一个 Toggle 处于选中状态。 */ + export class ToggleGroup extends Component { + /** !#en If this setting is true, a toggle could be switched off and on when pressed. + If it is false, it will make sure there is always only one toggle could be switched on + and the already switched on toggle can't be switched off. + !#zh 如果这个设置为 true, 那么 toggle 按钮在被点击的时候可以反复地被选中和未选中。 */ + allowSwitchOff: boolean; + /** !#en Read only property, return the toggle items array reference managed by toggleGroup. + !#zh 只读属性,返回 toggleGroup 管理的 toggle 数组引用 */ + toggleItems: any[]; + } + /** !#en + Handling touch events in a ViewGroup takes special care, + because it's common for a ViewGroup to have children that are targets for different touch events than the ViewGroup itself. + To make sure that each view correctly receives the touch events intended for it, + ViewGroup should register capture phase event and handle the event propagation properly. + Please refer to Scrollview for more information. + + !#zh + ViewGroup的事件处理比较特殊,因为 ViewGroup 里面的子节点关心的事件跟 ViewGroup 本身可能不一样。 + 为了让子节点能够正确地处理事件,ViewGroup 需要注册 capture 阶段的事件,并且合理地处理 ViewGroup 之间的事件传递。 + 请参考 ScrollView 的实现来获取更多信息。 */ + export class ViewGroup extends Component { + } + /** !#en + Stores and manipulate the anchoring based on its parent. + Widget are used for GUI but can also be used for other things. + Widget will adjust current node's position and size automatically, but the results after adjustment can not be obtained until the next frame unless you call {{#crossLink "Widget/updateAlignment:method"}}{{/crossLink}} manually. + !#zh + Widget 组件,用于设置和适配其相对于父节点的边距,Widget 通常被用于 UI 界面,也可以用于其他地方。 + Widget 会自动调整当前节点的坐标和宽高,不过目前调整后的结果要到下一帧才能在脚本里获取到,除非你先手动调用 {{#crossLink "Widget/updateAlignment:method"}}{{/crossLink}}。 */ + export class Widget extends Component { + /** !#en Specifies an alignment target that can only be one of the parent nodes of the current node. + The default value is null, and when null, indicates the current parent. + !#zh 指定一个对齐目标,只能是当前节点的其中一个父节点,默认为空,为空时表示当前父节点。 */ + target: Node; + /** !#en Whether to align the top. + !#zh 是否对齐上边。 */ + isAlignTop: boolean; + /** !#en + Vertically aligns the midpoint, This will open the other vertical alignment options cancel. + !#zh + 是否垂直方向对齐中点,开启此项会将垂直方向其他对齐选项取消。 */ + isAlignVerticalCenter: boolean; + /** !#en Whether to align the bottom. + !#zh 是否对齐下边。 */ + isAlignBottom: boolean; + /** !#en Whether to align the left. + !#zh 是否对齐左边 */ + isAlignLeft: boolean; + /** !#en + Horizontal aligns the midpoint. This will open the other horizontal alignment options canceled. + !#zh + 是否水平方向对齐中点,开启此选项会将水平方向其他对齐选项取消。 */ + isAlignHorizontalCenter: boolean; + /** !#en Whether to align the right. + !#zh 是否对齐右边。 */ + isAlignRight: boolean; + /** !#en + Whether the stretched horizontally, when enable the left and right alignment will be stretched horizontally, + the width setting is invalid (read only). + !#zh + 当前是否水平拉伸。当同时启用左右对齐时,节点将会被水平拉伸,此时节点的宽度只读。 */ + isStretchWidth: boolean; + /** !#en + Whether the stretched vertically, when enable the left and right alignment will be stretched vertically, + then height setting is invalid (read only) + !#zh + 当前是否垂直拉伸。当同时启用上下对齐时,节点将会被垂直拉伸,此时节点的高度只读。 */ + isStretchHeight: boolean; + /** !#en + The margins between the top of this node and the top of parent node, + the value can be negative, Only available in 'isAlignTop' open. + !#zh + 本节点顶边和父节点顶边的距离,可填写负值,只有在 isAlignTop 开启时才有作用。 */ + top: number; + /** !#en + The margins between the bottom of this node and the bottom of parent node, + the value can be negative, Only available in 'isAlignBottom' open. + !#zh + 本节点底边和父节点底边的距离,可填写负值,只有在 isAlignBottom 开启时才有作用。 */ + bottom: number; + /** !#en + The margins between the left of this node and the left of parent node, + the value can be negative, Only available in 'isAlignLeft' open. + !#zh + 本节点左边和父节点左边的距离,可填写负值,只有在 isAlignLeft 开启时才有作用。 */ + left: number; + /** !#en + The margins between the right of this node and the right of parent node, + the value can be negative, Only available in 'isAlignRight' open. + !#zh + 本节点右边和父节点右边的距离,可填写负值,只有在 isAlignRight 开启时才有作用。 */ + right: number; + /** !#en + Horizontal aligns the midpoint offset value, + the value can be negative, Only available in 'isAlignHorizontalCenter' open. + !#zh 水平居中的偏移值,可填写负值,只有在 isAlignHorizontalCenter 开启时才有作用。 */ + horizontalCenter: number; + /** !#en + Vertical aligns the midpoint offset value, + the value can be negative, Only available in 'isAlignVerticalCenter' open. + !#zh 垂直居中的偏移值,可填写负值,只有在 isAlignVerticalCenter 开启时才有作用。 */ + verticalCenter: number; + /** !#en If true, horizontalCenter is pixel margin, otherwise is percentage (0 - 1) margin. + !#zh 如果为 true,"horizontalCenter" 将会以像素作为偏移值,反之为百分比(0 到 1)。 */ + isAbsoluteHorizontalCenter: boolean; + /** !#en If true, verticalCenter is pixel margin, otherwise is percentage (0 - 1) margin. + !#zh 如果为 true,"verticalCenter" 将会以像素作为偏移值,反之为百分比(0 到 1)。 */ + isAbsoluteVerticalCenter: boolean; + /** !#en + If true, top is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's height. + !#zh + 如果为 true,"top" 将会以像素作为边距,否则将会以相对父物体高度的百分比(0 到 1)作为边距。 */ + isAbsoluteTop: boolean; + /** !#en + If true, bottom is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's height. + !#zh + 如果为 true,"bottom" 将会以像素作为边距,否则将会以相对父物体高度的百分比(0 到 1)作为边距。 */ + isAbsoluteBottom: boolean; + /** !#en + If true, left is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's width. + !#zh + 如果为 true,"left" 将会以像素作为边距,否则将会以相对父物体宽度的百分比(0 到 1)作为边距。 */ + isAbsoluteLeft: boolean; + /** !#en + If true, right is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's width. + !#zh + 如果为 true,"right" 将会以像素作为边距,否则将会以相对父物体宽度的百分比(0 到 1)作为边距。 */ + isAbsoluteRight: boolean; + /** !#en Specifies the alignment mode of the Widget, which determines when the widget should refresh. + !#zh 指定 Widget 的对齐模式,用于决定 Widget 应该何时刷新。 */ + alignMode: Widget.AlignMode; + /** + !#en + Immediately perform the widget alignment. You need to manually call this method only if + you need to get the latest results after the alignment before the end of current frame. + !#zh + 立刻执行 widget 对齐操作。这个接口一般不需要手工调用。 + 只有当你需要在当前帧结束前获得 widget 对齐后的最新结果时才需要手动调用这个方法。 + + @example + ```js + widget.top = 10; // change top margin + cc.log(widget.node.y); // not yet changed + widget.updateAlignment(); + cc.log(widget.node.y); // changed + ``` + */ + updateAlignment(): void; + /** !#en + When turned on, it will only be aligned once at the end of the onEnable frame, + then immediately disables the current component. + This will allow the script or animation to continue controlling the current node. + Note: It will still be aligned at the frame when onEnable is called. + !#zh + 开启后仅会在 onEnable 的当帧结束时对齐一次,然后立刻禁用当前组件。 + 这样便于脚本或动画继续控制当前节点。 + 注意:onEnable 时所在的那一帧仍然会进行对齐。 */ + isAlignOnce: boolean; + } + /** !#en SubContextView is a view component which controls open data context viewport in minigame platform.
+ The component's node size decide the viewport of the sub context content in main context, + the entire sub context texture will be scaled to the node's bounding box area.
+ This component provides multiple important features:
+ 1. Sub context could use its own resolution size and policy.
+ 2. Sub context could be minized to smallest size it needed.
+ 3. Resolution of sub context content could be increased.
+ 4. User touch input is transformed to the correct viewport.
+ 5. Texture update is handled by this component. User don't need to worry.
+ One important thing to be noted, whenever the node's bounding box change, + !#zh SubContextView 可以用来控制小游戏平台开放数据域在主域中的视窗的位置。
+ 这个组件的节点尺寸决定了开放数据域内容在主域中的尺寸,整个开放数据域会被缩放到节点的包围盒范围内。
+ 在这个组件的控制下,用户可以更自由得控制开放数据域:
+ 1. 子域中可以使用独立的设计分辨率和适配模式
+ 2. 子域区域尺寸可以缩小到只容纳内容即可
+ 3. 子域的分辨率也可以被放大,以便获得更清晰的显示效果
+ 4. 用户输入坐标会被自动转换到正确的子域视窗中
+ 5. 子域内容贴图的更新由组件负责,用户不需要处理
*/ + export class SubContextView extends Component { + /** + !#en Reset open data context size and viewport + !#zh 重置开放数据域的尺寸和视窗 + */ + reset(): void; + /** + !#en Update the sub context viewport manually, it should be called whenever the node's bounding box changes. + !#zh 更新开放数据域相对于主域的 viewport,这个函数应该在节点包围盒改变时手动调用。 + */ + updateSubContextViewport(): void; + } + /** !#en WXSubContextView is deprecated since v2.4.1, please use SubContextView instead. + !#zh 自 v2.4.1 起,WXSubContextView 已经废弃,请使用 SubContextView */ + export class WXSubContextView extends Component { + } + /** !#en SwanSubContextView is deprecated since v2.4.1, please use SubContextView instead. + !#zh 自 v2.4.1 起,SwanSubContextView 已经废弃,请使用 SubContextView */ + export class SwanSubContextView extends Component { + } + /** undefined */ + export class Graphics extends RenderComponent { + /** !#en + Current line width. + !#zh + 当前线条宽度 */ + lineWidth: number; + /** !#en + lineJoin determines how two connecting segments (of lines, arcs or curves) with non-zero lengths in a shape are joined together. + !#zh + lineJoin 用来设置2个长度不为0的相连部分(线段,圆弧,曲线)如何连接在一起的属性。 */ + lineJoin: Graphics.LineJoin; + /** !#en + lineCap determines how the end points of every line are drawn. + !#zh + lineCap 指定如何绘制每一条线段末端。 */ + lineCap: Graphics.LineCap; + /** !#en + stroke color + !#zh + 线段颜色 */ + strokeColor: Color; + /** !#en + fill color + !#zh + 填充颜色 */ + fillColor: Color; + /** !#en + Sets the miter limit ratio + !#zh + 设置斜接面限制比例 */ + miterLimit: number; + /** + !#en Move path start point to (x,y). + !#zh 移动路径起点到坐标(x, y) + @param x The x axis of the coordinate for the end point. + @param y The y axis of the coordinate for the end point. + */ + moveTo(x?: number, y?: number): void; + /** + !#en Adds a straight line to the path + !#zh 绘制直线路径 + @param x The x axis of the coordinate for the end point. + @param y The y axis of the coordinate for the end point. + */ + lineTo(x?: number, y?: number): void; + /** + !#en Adds a cubic Bézier curve to the path + !#zh 绘制三次贝赛尔曲线路径 + @param c1x The x axis of the coordinate for the first control point. + @param c1y The y axis of the coordinate for first control point. + @param c2x The x axis of the coordinate for the second control point. + @param c2y The y axis of the coordinate for the second control point. + @param x The x axis of the coordinate for the end point. + @param y The y axis of the coordinate for the end point. + */ + bezierCurveTo(c1x?: number, c1y?: number, c2x?: number, c2y?: number, x?: number, y?: number): void; + /** + !#en Adds a quadratic Bézier curve to the path + !#zh 绘制二次贝赛尔曲线路径 + @param cx The x axis of the coordinate for the control point. + @param cy The y axis of the coordinate for the control point. + @param x The x axis of the coordinate for the end point. + @param y The y axis of the coordinate for the end point. + */ + quadraticCurveTo(cx?: number, cy?: number, x?: number, y?: number): void; + /** + !#en Adds an arc to the path which is centered at (cx, cy) position with radius r starting at startAngle and ending at endAngle going in the given direction by counterclockwise (defaulting to false). + !#zh 绘制圆弧路径。圆弧路径的圆心在 (cx, cy) 位置,半径为 r ,根据 counterclockwise (默认为false)指定的方向从 startAngle 开始绘制,到 endAngle 结束。 + @param cx The x axis of the coordinate for the center point. + @param cy The y axis of the coordinate for the center point. + @param r The arc's radius. + @param startAngle The angle at which the arc starts, measured clockwise from the positive x axis and expressed in radians. + @param endAngle The angle at which the arc ends, measured clockwise from the positive x axis and expressed in radians. + @param counterclockwise An optional Boolean which, if true, causes the arc to be drawn counter-clockwise between the two angles. By default it is drawn clockwise. + */ + arc(cx?: number, cy?: number, r?: number, startAngle?: number, endAngle?: number, counterclockwise?: boolean): void; + /** + !#en Adds an ellipse to the path. + !#zh 绘制椭圆路径。 + @param cx The x axis of the coordinate for the center point. + @param cy The y axis of the coordinate for the center point. + @param rx The ellipse's x-axis radius. + @param ry The ellipse's y-axis radius. + */ + ellipse(cx?: number, cy?: number, rx?: number, ry?: number): void; + /** + !#en Adds an circle to the path. + !#zh 绘制圆形路径。 + @param cx The x axis of the coordinate for the center point. + @param cy The y axis of the coordinate for the center point. + @param r The circle's radius. + */ + circle(cx?: number, cy?: number, r?: number): void; + /** + !#en Adds an rectangle to the path. + !#zh 绘制矩形路径。 + @param x The x axis of the coordinate for the rectangle starting point. + @param y The y axis of the coordinate for the rectangle starting point. + @param w The rectangle's width. + @param h The rectangle's height. + */ + rect(x?: number, y?: number, w?: number, h?: number): void; + /** + !#en Adds an round corner rectangle to the path. + !#zh 绘制圆角矩形路径。 + @param x The x axis of the coordinate for the rectangle starting point. + @param y The y axis of the coordinate for the rectangle starting point. + @param w The rectangles width. + @param h The rectangle's height. + @param r The radius of the rectangle. + */ + roundRect(x?: number, y?: number, w?: number, h?: number, r?: number): void; + /** + !#en Draws a filled rectangle. + !#zh 绘制填充矩形。 + @param x The x axis of the coordinate for the rectangle starting point. + @param y The y axis of the coordinate for the rectangle starting point. + @param w The rectangle's width. + @param h The rectangle's height. + */ + fillRect(x?: number, y?: number, w?: number, h?: number): void; + /** + !#en Erasing any previously drawn content. + !#zh 擦除之前绘制的所有内容的方法。 + @param clean Whether to clean the graphics inner cache. + */ + clear(clean?: boolean): void; + /** + !#en Causes the point of the pen to move back to the start of the current path. It tries to add a straight line from the current point to the start. + !#zh 将笔点返回到当前路径起始点的。它尝试从当前点到起始点绘制一条直线。 + */ + close(): void; + /** + !#en Strokes the current or given path with the current stroke style. + !#zh 根据当前的画线样式,绘制当前或已经存在的路径。 + */ + stroke(): void; + /** + !#en Fills the current or given path with the current fill style. + !#zh 根据当前的画线样式,填充当前或已经存在的路径。 + */ + fill(): void; + } + /** undefined */ + export class WorldManifold { + /** !#en + world contact point (point of intersection) + !#zh + 碰撞点集合 */ + points: Vec2[]; + /** !#en + world vector pointing from A to B + !#zh + 世界坐标系下由 A 指向 B 的向量 */ + normal: Vec2; + } + /** !#en + A manifold point is a contact point belonging to a contact manifold. + It holds details related to the geometry and dynamics of the contact points. + Note: the impulses are used for internal caching and may not + provide reliable contact forces, especially for high speed collisions. + !#zh + ManifoldPoint 是接触信息中的接触点信息。它拥有关于几何和接触点的详细信息。 + 注意:信息中的冲量用于系统内部缓存,提供的接触力可能不是很准确,特别是高速移动中的碰撞信息。 */ + export class ManifoldPoint { + /** !#en + The local point usage depends on the manifold type: + -e_circles: the local center of circleB + -e_faceA: the local center of circleB or the clip point of polygonB + -e_faceB: the clip point of polygonA + !#zh + 本地坐标点的用途取决于 manifold 的类型 + - e_circles: circleB 的本地中心点 + - e_faceA: circleB 的本地中心点 或者是 polygonB 的截取点 + - e_faceB: polygonB 的截取点 */ + localPoint: Vec2; + /** !#en + Normal impulse. + !#zh + 法线冲量。 */ + normalImpulse: number; + /** !#en + Tangent impulse. + !#zh + 切线冲量。 */ + tangentImpulse: number; + } + /** undefined */ + export class Manifold { + /** !#en + Manifold type : 0: e_circles, 1: e_faceA, 2: e_faceB + !#zh + Manifold 类型 : 0: e_circles, 1: e_faceA, 2: e_faceB */ + type: number; + /** !#en + The local point usage depends on the manifold type: + -e_circles: the local center of circleA + -e_faceA: the center of faceA + -e_faceB: the center of faceB + !#zh + 用途取决于 manifold 类型 + -e_circles: circleA 的本地中心点 + -e_faceA: faceA 的本地中心点 + -e_faceB: faceB 的本地中心点 */ + localPoint: Vec2; + /** !#en + -e_circles: not used + -e_faceA: the normal on polygonA + -e_faceB: the normal on polygonB + !#zh + -e_circles: 没被使用到 + -e_faceA: polygonA 的法向量 + -e_faceB: polygonB 的法向量 */ + localNormal: Vec2; + /** !#en + the points of contact. + !#zh + 接触点信息。 */ + points: ManifoldPoint[]; + } + /** !#en + Contact impulses for reporting. + !#zh + 用于返回给回调的接触冲量。 */ + export class PhysicsImpulse { + /** !#en + Normal impulses. + !#zh + 法线方向的冲量 */ + normalImpulses: any; + /** !#en + Tangent impulses + !#zh + 切线方向的冲量 */ + tangentImpulses: any; + } + /** !#en + PhysicsContact will be generated during begin and end collision as a parameter of the collision callback. + Note that contacts will be reused for speed up cpu time, so do not cache anything in the contact. + !#zh + 物理接触会在开始和结束碰撞之间生成,并作为参数传入到碰撞回调函数中。 + 注意:传入的物理接触会被系统进行重用,所以不要在使用中缓存里面的任何信息。 */ + export class PhysicsContact { + /** + !#en + Get the world manifold. + !#zh + 获取世界坐标系下的碰撞信息。 + */ + getWorldManifold(): WorldManifold; + /** + !#en + Get the manifold. + !#zh + 获取本地(局部)坐标系下的碰撞信息。 + */ + getManifold(): Manifold; + /** + !#en + Get the impulses. + Note: PhysicsImpulse can only used in onPostSolve callback. + !#zh + 获取冲量信息 + 注意:这个信息只有在 onPostSolve 回调中才能获取到 + */ + getImpulse(): PhysicsImpulse; + /** !#en + One of the collider that collided + !#zh + 发生碰撞的碰撞体之一 */ + colliderA: Collider; + /** !#en + One of the collider that collided + !#zh + 发生碰撞的碰撞体之一 */ + colliderB: Collider; + /** !#en + If set disabled to true, the contact will be ignored until contact end. + If you just want to disabled contact for current time step or sub-step, please use disabledOnce. + !#zh + 如果 disabled 被设置为 true,那么直到接触结束此接触都将被忽略。 + 如果只是希望在当前时间步或子步中忽略此接触,请使用 disabledOnce 。 */ + disabled: boolean; + /** !#en + Disabled contact for current time step or sub-step. + !#zh + 在当前时间步或子步中忽略此接触。 */ + disabledOnce: boolean; + /** + !#en + Is this contact touching? + !#zh + 返回碰撞体是否已经接触到。 + */ + isTouching(): boolean; + /** + !#en + Set the desired tangent speed for a conveyor belt behavior. + !#zh + 为传送带设置期望的切线速度 + @param tangentSpeed tangentSpeed + */ + setTangentSpeed(tangentSpeed: number): void; + /** + !#en + Get the desired tangent speed. + !#zh + 获取切线速度 + */ + getTangentSpeed(): number; + /** + !#en + Override the default friction mixture. You can call this in onPreSolve callback. + !#zh + 覆盖默认的摩擦力系数。你可以在 onPreSolve 回调中调用此函数。 + @param friction friction + */ + setFriction(friction: number): void; + /** + !#en + Get the friction. + !#zh + 获取当前摩擦力系数 + */ + getFriction(): number; + /** + !#en + Reset the friction mixture to the default value. + !#zh + 重置摩擦力系数到默认值 + */ + resetFriction(): void; + /** + !#en + Override the default restitution mixture. You can call this in onPreSolve callback. + !#zh + 覆盖默认的恢复系数。你可以在 onPreSolve 回调中调用此函数。 + @param restitution restitution + */ + setRestitution(restitution: number): void; + /** + !#en + Get the restitution. + !#zh + 获取当前恢复系数 + */ + getRestitution(): number; + /** + !#en + Reset the restitution mixture to the default value. + !#zh + 重置恢复系数到默认值 + */ + resetRestitution(): void; + } + /** !#en Enum for RigidBodyType. + !#zh 刚体类型 */ + export enum RigidBodyType { + Static = 0, + Kinematic = 0, + Dynamic = 0, + Animated = 0, + } + /** !#en Enum for RayCastType. + !#zh 射线检测类型 */ + export enum RayCastType { + Closest = 0, + Any = 0, + AllClosest = 0, + All = 0, + } + /** !#en + Physics manager uses box2d as the inner physics system, and hide most box2d implement details(creating rigidbody, synchronize rigidbody info to node). + You can visit some common box2d function through physics manager(hit testing, raycast, debug info). + Physics manager distributes the collision information to each collision callback when collision is produced. + Note: You need first enable the collision listener in the rigidbody. + !#zh + 物理系统将 box2d 作为内部物理系统,并且隐藏了大部分 box2d 实现细节(比如创建刚体,同步刚体信息到节点中等)。 + 你可以通过物理系统访问一些 box2d 常用的功能,比如点击测试,射线测试,设置测试信息等。 + 物理系统还管理碰撞信息的分发,她会在产生碰撞时,将碰撞信息分发到各个碰撞回调中。 + 注意:你需要先在刚体中开启碰撞接听才会产生相应的碰撞回调。
+ 支持的物理系统指定绘制信息事件,请参阅 {{#crossLink "PhysicsManager.DrawBits"}}{{/crossLink}} */ + export class PhysicsManager implements EventTarget { + /** !#en + The ratio transform between physics unit and pixel unit, generally is 32. + !#zh + 物理单位与像素单位互相转换的比率,一般是 32。 */ + static PTM_RATIO: number; + /** !#en + The velocity iterations for the velocity constraint solver. + !#zh + 速度更新迭代数 */ + static VELOCITY_ITERATIONS: number; + /** !#en + The position Iterations for the position constraint solver. + !#zh + 位置迭代更新数 */ + static POSITION_ITERATIONS: number; + /** !#en + Specify the fixed time step. + Need enabledAccumulator to make it work. + !#zh + 指定固定的物理更新间隔时间,需要开启 enabledAccumulator 才有效。 */ + static FIXED_TIME_STEP: number; + /** !#en + Specify the max accumulator time. + Need enabledAccumulator to make it work. + !#zh + 每次可用于更新物理系统的最大时间,需要开启 enabledAccumulator 才有效。 */ + static MAX_ACCUMULATOR: number; + /** !#en + If enabled accumulator, then will call step function with the fixed time step FIXED_TIME_STEP. + And if the update dt is bigger than the time step, then will call step function several times. + If disabled accumulator, then will call step function with a time step calculated with the frame rate. + !#zh + 如果开启此选项,那么将会以固定的间隔时间 FIXED_TIME_STEP 来更新物理引擎,如果一个 update 的间隔时间大于 FIXED_TIME_STEP,则会对物理引擎进行多次更新。 + 如果关闭此选项,那么将会根据设定的 frame rate 计算出一个间隔时间来更新物理引擎。 */ + enabledAccumulator: boolean; + /** + !#en + Test which collider contains the given world point + !#zh + 获取包含给定世界坐标系点的碰撞体 + @param point the world point + */ + testPoint(point: Vec2): PhysicsCollider; + /** + !#en + Test which colliders intersect the given world rect + !#zh + 获取与给定世界坐标系矩形相交的碰撞体 + @param rect the world rect + */ + testAABB(rect: Rect): PhysicsCollider[]; + /** + !#en + Raycast the world for all colliders in the path of the ray. + The raycast ignores colliders that contain the starting point. + !#zh + 检测哪些碰撞体在给定射线的路径上,射线检测将忽略包含起始点的碰撞体。 + @param p1 start point of the raycast + @param p2 end point of the raycast + @param type optional, default is RayCastType.Closest + */ + rayCast(p1: Vec2, p2: Vec2, type: RayCastType): PhysicsRayCastResult[]; + /** !#en + Enabled the physics manager? + !#zh + 指定是否启用物理系统? */ + enabled: boolean; + /** !#en + Debug draw flags. + !#zh + 设置调试绘制标志 */ + debugDrawFlags: number; + /** !#en + The physics world gravity. + !#zh + 物理世界重力值 */ + gravity: Vec2; + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en + Register an callback of a specific event type on the EventTarget. + This type of event should be triggered via `emit`. + !#zh + 注册事件目标的特定事件类型回调。这种类型的事件应该被 `emit` 触发。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, node); + ``` + */ + on(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. + !#zh + 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + + @example + ```js + // register fire eventListener + var callback = eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, target); + // remove fire event listener + eventTarget.off('fire', callback, target); + // remove all fire event listeners + eventTarget.off('fire'); + ``` + */ + off(type: string, callback?: Function, target?: any): void; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.once('fire', function () { + cc.log("this is the callback and will be invoked only once"); + }, node); + ``` + */ + once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; + /** + !#en + Send an event with the event object. + !#zh + 通过事件对象派发事件 + @param event event + */ + dispatchEvent(event: Event): void; + /** + !#en + Destroy all callbackInfos. + !#zh + 销毁记录的事件 + */ + clear(): void; + } + /** undefined */ + export class PhysicsRayCastResult { + /** !#en + The PhysicsCollider which intersects with the raycast + !#zh + 与射线相交的碰撞体 */ + collider: PhysicsCollider; + /** !#en + The intersection point + !#zh + 射线与碰撞体相交的点 */ + point: Vec2; + /** !#en + The normal vector at the point of intersection + !#zh + 射线与碰撞体相交的点的法向量 */ + normal: Vec2; + /** !#en + The fraction of the raycast path at the point of intersection + !#zh + 射线与碰撞体相交的点占射线长度的分数 */ + fraction: number; + } + /** undefined */ + export class RigidBody extends Component { + /** !#en + Should enabled contact listener? + When a collision is trigger, the collision callback will only be called when enabled contact listener. + !#zh + 是否启用接触接听器。 + 当 collider 产生碰撞时,只有开启了接触接听器才会调用相应的回调函数 */ + enabledContactListener: boolean; + /** + !#en + Collision callback. + Called when two collider begin to touch. + !#zh + 碰撞回调。 + 如果你的脚本中实现了这个函数,那么它将会在两个碰撞体开始接触时被调用。 + @param contact contact information + @param selfCollider the collider belong to this rigidbody + @param otherCollider the collider belong to another rigidbody + */ + onBeginContact(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void; + /** + !#en + Collision callback. + Called when two collider cease to touch. + !#zh + 碰撞回调。 + 如果你的脚本中实现了这个函数,那么它将会在两个碰撞体停止接触时被调用。 + @param contact contact information + @param selfCollider the collider belong to this rigidbody + @param otherCollider the collider belong to another rigidbody + */ + onEndContact(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void; + /** + !#en + Collision callback. + This is called when a contact is updated. + This allows you to inspect a contact before it goes to the solver(e.g. disable contact). + Note: this is called only for awake bodies. + Note: this is called even when the number of contact points is zero. + Note: this is not called for sensors. + !#zh + 碰撞回调。 + 如果你的脚本中实现了这个函数,那么它将会在接触更新时被调用。 + 你可以在接触被处理前根据他包含的信息作出相应的处理,比如将这个接触禁用掉。 + 注意:回调只会为醒着的刚体调用。 + 注意:接触点为零的时候也有可能被调用。 + 注意:感知体(sensor)的回调不会被调用。 + @param contact contact information + @param selfCollider the collider belong to this rigidbody + @param otherCollider the collider belong to another rigidbody + */ + onPreSolve(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void; + /** + !#en + Collision callback. + This is called after a contact is updated. + You can get the impulses from the contact in this callback. + !#zh + 碰撞回调。 + 如果你的脚本中实现了这个函数,那么它将会在接触更新完后被调用。 + 你可以在这个回调中从接触信息中获取到冲量信息。 + @param contact contact information + @param selfCollider the collider belong to this rigidbody + @param otherCollider the collider belong to another rigidbody + */ + onPostSolve(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void; + /** !#en + Is this a fast moving body that should be prevented from tunneling through + other moving bodies? + Note : + - All bodies are prevented from tunneling through kinematic and static bodies. This setting is only considered on dynamic bodies. + - You should use this flag sparingly since it increases processing time. + !#zh + 这个刚体是否是一个快速移动的刚体,并且需要禁止穿过其他快速移动的刚体? + 需要注意的是 : + - 所有刚体都被禁止从 运动刚体 和 静态刚体 中穿过。此选项只关注于 动态刚体。 + - 应该尽量少的使用此选项,因为它会增加程序处理时间。 */ + bullet: boolean; + /** !#en + Rigidbody type : Static, Kinematic, Dynamic or Animated. + !#zh + 刚体类型: Static, Kinematic, Dynamic or Animated. */ + type: RigidBodyType; + /** !#en + Set this flag to false if this body should never fall asleep. + Note that this increases CPU usage. + !#zh + 如果此刚体永远都不应该进入睡眠,那么设置这个属性为 false。 + 需要注意这将使 CPU 占用率提高。 */ + allowSleep: boolean; + /** !#en + Scale the gravity applied to this body. + !#zh + 缩放应用在此刚体上的重力值 */ + gravityScale: number; + /** !#en + Linear damping is use to reduce the linear velocity. + The damping parameter can be larger than 1, but the damping effect becomes sensitive to the + time step when the damping parameter is large. + !#zh + Linear damping 用于衰减刚体的线性速度。衰减系数可以大于 1,但是当衰减系数比较大的时候,衰减的效果会变得比较敏感。 */ + linearDamping: number; + /** !#en + Angular damping is use to reduce the angular velocity. The damping parameter + can be larger than 1 but the damping effect becomes sensitive to the + time step when the damping parameter is large. + !#zh + Angular damping 用于衰减刚体的角速度。衰减系数可以大于 1,但是当衰减系数比较大的时候,衰减的效果会变得比较敏感。 */ + angularDamping: number; + /** !#en + The linear velocity of the body's origin in world co-ordinates. + !#zh + 刚体在世界坐标下的线性速度 */ + linearVelocity: Vec2; + /** !#en + The angular velocity of the body. + !#zh + 刚体的角速度 */ + angularVelocity: number; + /** !#en + Should this body be prevented from rotating? + !#zh + 是否禁止此刚体进行旋转 */ + fixedRotation: boolean; + /** !#en + Set the sleep state of the body. A sleeping body has very low CPU cost.(When the rigid body is hit, if the rigid body is in sleep state, it will be immediately awakened.) + !#zh + 设置刚体的睡眠状态。 睡眠的刚体具有非常低的 CPU 成本。(当刚体被碰撞到时,如果刚体处于睡眠状态,它会立即被唤醒) */ + awake: boolean; + /** !#en + Whether to wake up this rigid body during initialization + !#zh + 是否在初始化时唤醒此刚体 */ + awakeOnLoad: boolean; + /** !#en + Set the active state of the body. An inactive body is not + simulated and cannot be collided with or woken up. + If body is active, all fixtures will be added to the + broad-phase. + If body is inactive, all fixtures will be removed from + the broad-phase and all contacts will be destroyed. + Fixtures on an inactive body are implicitly inactive and will + not participate in collisions, ray-casts, or queries. + Joints connected to an inactive body are implicitly inactive. + !#zh + 设置刚体的激活状态。一个非激活状态下的刚体是不会被模拟和碰撞的,不管它是否处于睡眠状态下。 + 如果刚体处于激活状态下,所有夹具会被添加到 粗测阶段(broad-phase)。 + 如果刚体处于非激活状态下,所有夹具会被从 粗测阶段(broad-phase)中移除。 + 在非激活状态下的夹具不会参与到碰撞,射线,或者查找中 + 链接到非激活状态下刚体的关节也是非激活的。 */ + active: boolean; + /** + !#en + Converts a given point in the world coordinate system to this rigid body's local coordinate system + !#zh + 将一个给定的世界坐标系下的点转换为刚体本地坐标系下的点 + @param worldPoint a point in world coordinates. + @param out optional, the receiving point + */ + getLocalPoint(worldPoint: Vec2, out: Vec2): Vec2; + /** + !#en + Converts a given point in this rigid body's local coordinate system to the world coordinate system + !#zh + 将一个给定的刚体本地坐标系下的点转换为世界坐标系下的点 + @param localPoint a point in local coordinates. + @param out optional, the receiving point + */ + getWorldPoint(localPoint: Vec2, out: Vec2): Vec2; + /** + !#en + Converts a given vector in this rigid body's local coordinate system to the world coordinate system + !#zh + 将一个给定的刚体本地坐标系下的向量转换为世界坐标系下的向量 + @param localVector a vector in world coordinates. + @param out optional, the receiving vector + */ + getWorldVector(localVector: Vec2, out: Vec2): Vec2; + /** + !#en + Converts a given vector in the world coordinate system to this rigid body's local coordinate system + !#zh + 将一个给定的世界坐标系下的向量转换为刚体本地坐标系下的向量 + @param worldVector a vector in world coordinates. + @param out optional, the receiving vector + */ + getLocalVector(worldVector: Vec2, out: Vec2): Vec2; + /** + !#en + Get the world body origin position. + !#zh + 获取刚体世界坐标系下的原点值 + @param out optional, the receiving point + */ + getWorldPosition(out: Vec2): Vec2; + /** + !#en + Get the world body rotation angle. + !#zh + 获取刚体世界坐标系下的旋转值。 + */ + getWorldRotation(): number; + /** + !#en + Get the local position of the center of mass. + !#zh + 获取刚体本地坐标系下的质心 + */ + getLocalCenter(): Vec2; + /** + !#en + Get the world position of the center of mass. + !#zh + 获取刚体世界坐标系下的质心 + */ + getWorldCenter(): Vec2; + /** + !#en + Get the world linear velocity of a world point attached to this body. + !#zh + 获取刚体上指定点的线性速度 + @param worldPoint a point in world coordinates. + @param out optional, the receiving point + */ + getLinearVelocityFromWorldPoint(worldPoint: Vec2, out: Vec2): Vec2; + /** + !#en + Get total mass of the body. + !#zh + 获取刚体的质量。 + */ + getMass(): number; + /** + !#en + Get the rotational inertia of the body about the local origin. + !#zh + 获取刚体本地坐标系下原点的旋转惯性 + */ + getInertia(): number; + /** + !#en + Get all the joints connect to the rigidbody. + !#zh + 获取链接到此刚体的所有关节 + */ + getJointList(): Joint[]; + /** + !#en + Apply a force at a world point. If the force is not + applied at the center of mass, it will generate a torque and + affect the angular velocity. + !#zh + 施加一个力到刚体上的一个点。如果力没有施加到刚体的质心上,还会产生一个扭矩并且影响到角速度。 + @param force the world force vector. + @param point the world position. + @param wake also wake up the body. + */ + applyForce(force: Vec2, point: Vec2, wake: boolean): void; + /** + !#en + Apply a force to the center of mass. + !#zh + 施加一个力到刚体上的质心上。 + @param force the world force vector. + @param wake also wake up the body. + */ + applyForceToCenter(force: Vec2, wake: boolean): void; + /** + !#en + Apply a torque. This affects the angular velocity. + !#zh + 施加一个扭矩力,将影响刚体的角速度 + @param torque about the z-axis (out of the screen), usually in N-m. + @param wake also wake up the body + */ + applyTorque(torque: number, wake: boolean): void; + /** + !#en + Apply a impulse at a world point, This immediately modifies the velocity. + If the impulse is not applied at the center of mass, it will generate a torque and + affect the angular velocity. + !#zh + 施加冲量到刚体上的一个点,将立即改变刚体的线性速度。 + 如果冲量施加到的点不是刚体的质心,那么将产生一个扭矩并影响刚体的角速度。 + @param impulse the world impulse vector, usually in N-seconds or kg-m/s. + @param point the world position + @param wake alse wake up the body + */ + applyLinearImpulse(impulse: Vec2, point: Vec2, wake: boolean): void; + /** + !#en + Apply an angular impulse. + !#zh + 施加一个角速度冲量。 + @param impulse the angular impulse in units of kg*m*m/s + @param wake also wake up the body + */ + applyAngularImpulse(impulse: number, wake: boolean): void; + /** + !#en + Synchronize node's world position to box2d rigidbody's position. + If enableAnimated is true and rigidbody's type is Animated type, + will set linear velocity instead of directly set rigidbody's position. + !#zh + 同步节点的世界坐标到 box2d 刚体的坐标上。 + 如果 enableAnimated 是 true,并且刚体的类型是 Animated ,那么将设置刚体的线性速度来代替直接设置刚体的位置。 + @param enableAnimated enableAnimated + */ + syncPosition(enableAnimated: boolean): void; + /** + !#en + Synchronize node's world angle to box2d rigidbody's angle. + If enableAnimated is true and rigidbody's type is Animated type, + will set angular velocity instead of directly set rigidbody's angle. + !#zh + 同步节点的世界旋转角度值到 box2d 刚体的旋转值上。 + 如果 enableAnimated 是 true,并且刚体的类型是 Animated ,那么将设置刚体的角速度来代替直接设置刚体的角度。 + @param enableAnimated enableAnimated + */ + syncRotation(enableAnimated: boolean): void; + } + /** !#en Mesh Asset. + !#zh 网格资源。 */ + export class Mesh extends Asset implements EventTarget { + /** !#en Get ir set the sub meshes. + !#zh 设置或者获取子网格。 */ + subMeshes: InputAssembler[]; + /** + !#en + Init vertex buffer according to the vertex format. + !#zh + 根据顶点格式初始化顶点内存。 + @param vertexFormat vertex format + @param vertexCount how much vertex should be create in this buffer. + @param dynamic whether or not to use dynamic buffer. + @param index index + */ + init(vertexFormat: gfx.VertexFormat, vertexCount: number, dynamic?: boolean, index?: boolean): void; + /** + !#en + Set the vertex values. + !#zh + 设置顶点数据 + @param name the attribute name, e.g. gfx.ATTR_POSITION + @param values the vertex values + */ + setVertices(name: string, values: Vec2[]|Vec3[]|Color[]|number[]|Uint8Array|Float32Array): void; + /** + !#en + Set the sub mesh indices. + !#zh + 设置子网格索引。 + @param indices the sub mesh indices. + @param index sub mesh index. + @param dynamic whether or not to use dynamic buffer. + */ + setIndices(indices: number[]|Uint16Array|Uint8Array, index?: number, dynamic?: boolean): void; + /** + !#en + Set the sub mesh primitive type. + !#zh + 设置子网格绘制线条的方式。 + @param type type + @param index index + */ + setPrimitiveType(type: number, index: number): void; + /** + !#en + Clear the buffer data. + !#zh + 清除网格创建的内存数据。 + */ + clear(): void; + /** + !#en Set mesh bounding box + !#zh 设置网格的包围盒 + @param min min + @param max max + */ + setBoundingBox(min: Vec3, max: Vec3): void; + /** + !#en Read the specified attributes of the subgrid into the target buffer. + !#zh 读取子网格的指定属性到目标缓冲区中。 + @param primitiveIndex The subgrid index. + @param attributeName attribute name. + @param buffer The target buffer. + @param stride The byte interval between adjacent attributes in the target buffer. + @param offset The offset of the first attribute in the target buffer. + */ + copyAttribute(primitiveIndex: number, attributeName: string, buffer: ArrayBuffer, stride: number, offset: number): boolean; + /** + !#en Read the index data of the subgrid into the target array. + !#zh 读取子网格的索引数据到目标数组中。 + @param primitiveIndex The subgrid index. + @param outputArray The target array. + */ + copyIndices(primitiveIndex: number, outputArray: DataView): boolean; + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en + Register an callback of a specific event type on the EventTarget. + This type of event should be triggered via `emit`. + !#zh + 注册事件目标的特定事件类型回调。这种类型的事件应该被 `emit` 触发。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, node); + ``` + */ + on(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. + !#zh + 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + + @example + ```js + // register fire eventListener + var callback = eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, target); + // remove fire event listener + eventTarget.off('fire', callback, target); + // remove all fire event listeners + eventTarget.off('fire'); + ``` + */ + off(type: string, callback?: Function, target?: any): void; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.once('fire', function () { + cc.log("this is the callback and will be invoked only once"); + }, node); + ``` + */ + once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; + /** + !#en + Send an event with the event object. + !#zh + 通过事件对象派发事件 + @param event event + */ + dispatchEvent(event: Event): void; + } + /** !#en + Mesh Renderer Component + !#zh + 网格渲染组件 */ + export class MeshRenderer extends RenderComponent { + /** !#en + The mesh which the renderer uses. + !#zh + 设置使用的网格 */ + mesh: Mesh; + /** !#en + Whether the mesh should receive shadows. + !#zh + 网格是否接受光源投射的阴影 */ + receiveShadows: boolean; + /** !#en + Shadow Casting Mode + !#zh + 网格投射阴影的模式 */ + shadowCastingMode: MeshRenderer.ShadowCastingMode; + /** !#en + Enable auto merge mesh, only support when mesh's VertexFormat, PrimitiveType, materials are all the same + !#zh + 开启自动合并 mesh 功能,只有在网格的 顶点格式,PrimitiveType, 使用的材质 都一致的情况下才会有效 */ + enableAutoBatch: boolean; + } + /** The class BufferRange denotes a range of the buffer. */ + export class BufferRange { + /** The offset of the range. */ + offset: number; + /** The length of the range. */ + length: number; + } + /** undefined */ + export class VertexFormat { + /** The data range of this bundle. + This range of data is essentially mapped to a GPU vertex buffer. */ + data: BufferRange; + /** The attribute formats. */ + formats: VertexFormat; + /** The vertex bundle that the primitive use. */ + vertexBundleIndices: number[]; + /** The data range of the primitive. + This range of data is essentially mapped to a GPU indices buffer. */ + data: BufferRange; + /** The type of this primitive's indices. */ + indexUnit: number; + /** The primitive's topology. */ + topology: number; + } + /** !#en The renderer object which provide access to render system APIs, + detailed APIs will be available progressively. + !#zh 提供基础渲染接口的渲染器对象,渲染层的基础接口将逐步开放给用户 */ + export class renderer { + /** !#en The render engine is available only after cc.game.EVENT_ENGINE_INITED event.
+ Normally it will be inited as the webgl render engine, but in wechat open context domain, + it will be inited as the canvas render engine. Canvas render engine is no longer available for other use case since v2.0. + !#zh 基础渲染引擎对象只在 cc.game.EVENT_ENGINE_INITED 事件触发后才可获取。
+ 大多数情况下,它都会是 WebGL 渲染引擎实例,但是在微信开放数据域当中,它会是 Canvas 渲染引擎实例。请注意,从 2.0 开始,我们在其他平台和环境下都废弃了 Canvas 渲染器。 */ + static renderEngine: any; + /** !#en The total draw call count in last rendered frame. + !#zh 上一次渲染帧所提交的渲染批次总数。 */ + static drawCalls: number; + } + /** !#en the device accelerometer reports values for each axis in units of g-force. + !#zh 设备重力传感器传递的各个轴的数据。 */ + export class constructor { + /** + whether enable accelerometer event + @param isEnable isEnable + */ + setAccelerometerEnabled(isEnable: boolean): void; + /** + set accelerometer interval value + @param interval interval + */ + setAccelerometerInterval(interval: number): void; + } + /** undefined */ + export enum VerticalTextAlignment { + TOP = 0, + CENTER = 0, + BOTTOM = 0, + } + /** The base class of most of all the objects in Fireball. */ + export class Object { + /** !#en The name of the object. + !#zh 该对象的名称。 */ + name: string; + /** !#en + Indicates whether the object is not yet destroyed. (It will not be available after being destroyed)
+ When an object's `destroy` is called, it is actually destroyed after the end of this frame. + So `isValid` will return false from the next frame, while `isValid` in the current frame will still be true. + If you want to determine whether the current frame has called `destroy`, use `cc.isValid(obj, true)`, + but this is often caused by a particular logical requirements, which is not normally required. + + !#zh + 表示该对象是否可用(被 destroy 后将不可用)。
+ 当一个对象的 `destroy` 调用以后,会在这一帧结束后才真正销毁。因此从下一帧开始 `isValid` 就会返回 false,而当前帧内 `isValid` 仍然会是 true。如果希望判断当前帧是否调用过 `destroy`,请使用 `cc.isValid(obj, true)`,不过这往往是特殊的业务需求引起的,通常情况下不需要这样。 */ + isValid: boolean; + /** + !#en + Destroy this Object, and release all its own references to other objects.
+ Actual object destruction will delayed until before rendering. + From the next frame, this object is not usable anymore. + You can use `cc.isValid(obj)` to check whether the object is destroyed before accessing it. + !#zh + 销毁该对象,并释放所有它对其它对象的引用。
+ 实际销毁操作会延迟到当前帧渲染前执行。从下一帧开始,该对象将不再可用。 + 您可以在访问对象之前使用 `cc.isValid(obj)` 来检查对象是否已被销毁。 + + @example + ```js + obj.destroy(); + ``` + */ + destroy(): boolean; + } + /** Bit mask that controls object states. */ + export enum Flags { + DontSave = 0, + EditorOnly = 0, + HideInHierarchy = 0, + } + /** The fullscreen API provides an easy way for web content to be presented using the user's entire screen. + It's invalid on safari, QQbrowser and android browser */ + export class screen { + /** + initialize + */ + init(): void; + /** + return true if it's full now. + */ + fullScreen(): boolean; + /** + change the screen to full mode. + @param element element + @param onFullScreenChange onFullScreenChange + @param onFullScreenError onFullScreenError + */ + requestFullScreen(element: Element, onFullScreenChange: Function, onFullScreenError: Function): void; + /** + exit the full mode. + */ + exitFullScreen(): boolean; + /** + Automatically request full screen with a touch/click event + @param element element + @param onFullScreenChange onFullScreenChange + */ + autoFullScreen(element: Element, onFullScreenChange: Function): void; + } + /** System variables */ + export class sys { + /** English language code */ + static LANGUAGE_ENGLISH: string; + /** Chinese language code */ + static LANGUAGE_CHINESE: string; + /** French language code */ + static LANGUAGE_FRENCH: string; + /** Italian language code */ + static LANGUAGE_ITALIAN: string; + /** German language code */ + static LANGUAGE_GERMAN: string; + /** Spanish language code */ + static LANGUAGE_SPANISH: string; + /** Spanish language code */ + static LANGUAGE_DUTCH: string; + /** Russian language code */ + static LANGUAGE_RUSSIAN: string; + /** Korean language code */ + static LANGUAGE_KOREAN: string; + /** Japanese language code */ + static LANGUAGE_JAPANESE: string; + /** Hungarian language code */ + static LANGUAGE_HUNGARIAN: string; + /** Portuguese language code */ + static LANGUAGE_PORTUGUESE: string; + /** Arabic language code */ + static LANGUAGE_ARABIC: string; + /** Norwegian language code */ + static LANGUAGE_NORWEGIAN: string; + /** Polish language code */ + static LANGUAGE_POLISH: string; + /** Turkish language code */ + static LANGUAGE_TURKISH: string; + /** Ukrainian language code */ + static LANGUAGE_UKRAINIAN: string; + /** Romanian language code */ + static LANGUAGE_ROMANIAN: string; + /** Bulgarian language code */ + static LANGUAGE_BULGARIAN: string; + /** Unknown language code */ + static LANGUAGE_UNKNOWN: string; + static OS_IOS: string; + static OS_ANDROID: string; + static OS_WINDOWS: string; + static OS_MARMALADE: string; + static OS_LINUX: string; + static OS_BADA: string; + static OS_BLACKBERRY: string; + static OS_OSX: string; + static OS_WP8: string; + static OS_WINRT: string; + static OS_UNKNOWN: string; + static UNKNOWN: number; + static WIN32: number; + static LINUX: number; + static MACOS: number; + static ANDROID: number; + static IPHONE: number; + static IPAD: number; + static BLACKBERRY: number; + static NACL: number; + static EMSCRIPTEN: number; + static TIZEN: number; + static WINRT: number; + static WP8: number; + static MOBILE_BROWSER: number; + static DESKTOP_BROWSER: number; + /** Indicates whether executes in editor's window process (Electron's renderer context) */ + static EDITOR_PAGE: number; + /** Indicates whether executes in editor's main process (Electron's browser context) */ + static EDITOR_CORE: number; + static WECHAT_GAME: number; + static QQ_PLAY: number; + static FB_PLAYABLE_ADS: number; + static BAIDU_GAME: number; + static VIVO_GAME: number; + static OPPO_GAME: number; + static HUAWEI_GAME: number; + static XIAOMI_GAME: number; + static JKW_GAME: number; + static ALIPAY_GAME: number; + static WECHAT_GAME_SUB: number; + static BAIDU_GAME_SUB: number; + static QTT_GAME: number; + static BYTEDANCE_GAME: number; + static BYTEDANCE_GAME_SUB: number; + static LINKSURE: number; + /** BROWSER_TYPE_WECHAT */ + static BROWSER_TYPE_WECHAT: string; + static BROWSER_TYPE_ANDROID: string; + static BROWSER_TYPE_IE: string; + static BROWSER_TYPE_EDGE: string; + static BROWSER_TYPE_QQ: string; + static BROWSER_TYPE_MOBILE_QQ: string; + static BROWSER_TYPE_UC: string; + /** uc third party integration. */ + static BROWSER_TYPE_UCBS: string; + static BROWSER_TYPE_360: string; + static BROWSER_TYPE_BAIDU_APP: string; + static BROWSER_TYPE_BAIDU: string; + static BROWSER_TYPE_MAXTHON: string; + static BROWSER_TYPE_OPERA: string; + static BROWSER_TYPE_OUPENG: string; + static BROWSER_TYPE_MIUI: string; + static BROWSER_TYPE_FIREFOX: string; + static BROWSER_TYPE_SAFARI: string; + static BROWSER_TYPE_CHROME: string; + static BROWSER_TYPE_LIEBAO: string; + static BROWSER_TYPE_QZONE: string; + static BROWSER_TYPE_SOUGOU: string; + static BROWSER_TYPE_HUAWEI: string; + static BROWSER_TYPE_UNKNOWN: string; + /** Is native ? This is set to be true in jsb auto. */ + static isNative: boolean; + /** Is web browser ? */ + static isBrowser: boolean; + /** + Is webgl extension support? + @param name name + */ + static glExtension(name: any): void; + /** + Get max joint matrix size for skinned mesh renderer. + */ + static getMaxJointMatrixSize(): void; + /** + !#en + Returns the safe area of the screen. If the screen is not notched, the design resolution will be returned by default. + Only supported on Android, iOS and WeChat Mini Game platform. + !#zh + 返回手机屏幕安全区域,如果不是异形屏将默认返回设计分辨率尺寸。目前只支持安卓、iOS 原生平台和微信小游戏平台。 + */ + static getSafeAreaRect(): Rect; + /** Indicate whether system is mobile system */ + static isMobile: boolean; + /** Indicate the running platform */ + static platform: number; + /** Get current language iso 639-1 code. + Examples of valid language codes include "zh-tw", "en", "en-us", "fr", "fr-fr", "es-es", etc. + The actual value totally depends on results provided by destination platform. */ + static languageCode: string; + /** Indicate the current language of the running system */ + static language: string; + /** Indicate the running os name */ + static os: string; + /** Indicate the running os version */ + static osVersion: string; + /** Indicate the running os main version */ + static osMainVersion: number; + /** Indicate the running browser type */ + static browserType: string|void; + /** Indicate the running browser version */ + static browserVersion: string|void; + /** Indicate the real pixel resolution of the whole game window */ + static windowPixelResolution: Size; + /** cc.sys.localStorage is a local storage component. */ + static localStorage: any; + /** The capabilities of the current platform */ + static capabilities: any; + /** + !#en + Get the network type of current device, return cc.sys.NetworkType.LAN if failure. + !#zh + 获取当前设备的网络类型, 如果网络类型无法获取,默认将返回 cc.sys.NetworkType.LAN + */ + static getNetworkType(): sys.NetworkType; + /** + !#en + Get the battery level of current device, return 1.0 if failure. + !#zh + 获取当前设备的电池电量,如果电量无法获取,默认将返回 1 + */ + static getBatteryLevel(): number; + /** + Forces the garbage collection, only available in JSB + */ + static garbageCollect(): void; + /** + Restart the JS VM, only available in JSB + */ + static restartVM(): void; + /** + Check whether an object is valid, + In web engine, it will return true if the object exist + In native engine, it will return true if the JS object and the correspond native object are both valid + @param obj obj + */ + static isObjectValid(obj: any): boolean; + /** + Dump system informations + */ + static dump(): void; + /** + Open a url in browser + @param url url + */ + static openURL(url: string): void; + /** + Get the number of milliseconds elapsed since 1 January 1970 00:00:00 UTC. + */ + static now(): number; + } + /** cc.view is the singleton object which represents the game window.
+ It's main task include:
+ - Apply the design resolution policy
+ - Provide interaction with the window, like resize event on web, retina display support, etc...
+ - Manage the game view port which can be different with the window
+ - Manage the content scale and translation
+
+ Since the cc.view is a singleton, you don't need to call any constructor or create functions,
+ the standard way to use it is by calling:
+ - cc.view.methodName();
*/ + export class View extends EventTarget { + /** + !#en + Sets view's target-densitydpi for android mobile browser. it can be set to:
+ 1. cc.macro.DENSITYDPI_DEVICE, value is "device-dpi"
+ 2. cc.macro.DENSITYDPI_HIGH, value is "high-dpi" (default value)
+ 3. cc.macro.DENSITYDPI_MEDIUM, value is "medium-dpi" (browser's default value)
+ 4. cc.macro.DENSITYDPI_LOW, value is "low-dpi"
+ 5. Custom value, e.g: "480"
+ !#zh 设置目标内容的每英寸像素点密度。 + @param densityDPI densityDPI + */ + setTargetDensityDPI(densityDPI: string): void; + /** + !#en + Returns the current target-densitydpi value of cc.view. + !#zh 获取目标内容的每英寸像素点密度。 + */ + getTargetDensityDPI(): string; + /** + !#en + Sets whether resize canvas automatically when browser's size changed.
+ Useful only on web. + !#zh 设置当发现浏览器的尺寸改变时,是否自动调整 canvas 尺寸大小。 + 仅在 Web 模式下有效。 + @param enabled Whether enable automatic resize with browser's resize event + */ + resizeWithBrowserSize(enabled: boolean): void; + /** + !#en + Sets the callback function for cc.view's resize action,
+ this callback will be invoked before applying resolution policy,
+ so you can do any additional modifications within the callback.
+ Useful only on web. + !#zh 设置 cc.view 调整视窗尺寸行为的回调函数, + 这个回调函数会在应用适配模式之前被调用, + 因此你可以在这个回调函数内添加任意附加改变, + 仅在 Web 平台下有效。 + @param callback The callback function + */ + setResizeCallback(callback: Function|void): void; + /** + !#en + Sets the orientation of the game, it can be landscape, portrait or auto. + When set it to landscape or portrait, and screen w/h ratio doesn't fit, + cc.view will automatically rotate the game canvas using CSS. + Note that this function doesn't have any effect in native, + in native, you need to set the application orientation in native project settings + !#zh 设置游戏屏幕朝向,它能够是横版,竖版或自动。 + 当设置为横版或竖版,并且屏幕的宽高比例不匹配时, + cc.view 会自动用 CSS 旋转游戏场景的 canvas, + 这个方法不会对 native 部分产生任何影响,对于 native 而言,你需要在应用设置中的设置排版。 + @param orientation Possible values: cc.macro.ORIENTATION_LANDSCAPE | cc.macro.ORIENTATION_PORTRAIT | cc.macro.ORIENTATION_AUTO + */ + setOrientation(orientation: number): void; + /** + !#en + Sets whether the engine modify the "viewport" meta in your web page.
+ It's enabled by default, we strongly suggest you not to disable it.
+ And even when it's enabled, you can still set your own "viewport" meta, it won't be overridden
+ Only useful on web + !#zh 设置引擎是否调整 viewport meta 来配合屏幕适配。 + 默认设置为启动,我们强烈建议你不要将它设置为关闭。 + 即使当它启动时,你仍然能够设置你的 viewport meta,它不会被覆盖。 + 仅在 Web 模式下有效 + @param enabled Enable automatic modification to "viewport" meta + */ + adjustViewportMeta(enabled: boolean): void; + /** + !#en + Retina support is enabled by default for Apple device but disabled for other devices,
+ it takes effect only when you called setDesignResolutionPolicy
+ Only useful on web + !#zh 对于 Apple 这种支持 Retina 显示的设备上默认进行优化而其他类型设备默认不进行优化, + 它仅会在你调用 setDesignResolutionPolicy 方法时有影响。 + 仅在 Web 模式下有效。 + @param enabled Enable or disable retina display + */ + enableRetina(enabled: boolean): void; + /** + !#en + Check whether retina display is enabled.
+ Only useful on web + !#zh 检查是否对 Retina 显示设备进行优化。 + 仅在 Web 模式下有效。 + */ + isRetinaEnabled(): boolean; + /** + !#en Whether to Enable on anti-alias + !#zh 控制抗锯齿是否开启 + @param enabled Enable or not anti-alias + */ + enableAntiAlias(enabled: boolean): void; + /** + !#en Returns whether the current enable on anti-alias + !#zh 返回当前是否抗锯齿 + */ + isAntiAliasEnabled(): boolean; + /** + !#en + If enabled, the application will try automatically to enter full screen mode on mobile devices
+ You can pass true as parameter to enable it and disable it by passing false.
+ Only useful on web + !#zh 启动时,移动端游戏会在移动端自动尝试进入全屏模式。 + 你能够传入 true 为参数去启动它,用 false 参数来关闭它。 + @param enabled Enable or disable auto full screen on mobile devices + */ + enableAutoFullScreen(enabled: boolean): void; + /** + !#en + Check whether auto full screen is enabled.
+ Only useful on web + !#zh 检查自动进入全屏模式是否启动。 + 仅在 Web 模式下有效。 + */ + isAutoFullScreenEnabled(): boolean; + /** + !#en + Returns the canvas size of the view.
+ On native platforms, it returns the screen size since the view is a fullscreen view.
+ On web, it returns the size of the canvas element. + !#zh 返回视图中 canvas 的尺寸。 + 在 native 平台下,它返回全屏视图下屏幕的尺寸。 + 在 Web 平台下,它返回 canvas 元素尺寸。 + */ + getCanvasSize(): Size; + /** + !#en + Returns the frame size of the view.
+ On native platforms, it returns the screen size since the view is a fullscreen view.
+ On web, it returns the size of the canvas's outer DOM element. + !#zh 返回视图中边框尺寸。 + 在 native 平台下,它返回全屏视图下屏幕的尺寸。 + 在 web 平台下,它返回 canvas 元素的外层 DOM 元素尺寸。 + */ + getFrameSize(): Size; + /** + !#en + On native, it sets the frame size of view.
+ On web, it sets the size of the canvas's outer DOM element. + !#zh 在 native 平台下,设置视图框架尺寸。 + 在 web 平台下,设置 canvas 外层 DOM 元素尺寸。 + @param width width + @param height height + */ + setFrameSize(width: number, height: number): void; + /** + !#en + Returns the visible area size of the view port. + !#zh 返回视图窗口可见区域尺寸。 + */ + getVisibleSize(): Size; + /** + !#en + Returns the visible area size of the view port. + !#zh 返回视图窗口可见区域像素尺寸。 + */ + getVisibleSizeInPixel(): Size; + /** + !#en + Returns the visible origin of the view port. + !#zh 返回视图窗口可见区域原点。 + */ + getVisibleOrigin(): Vec2; + /** + !#en + Returns the visible origin of the view port. + !#zh 返回视图窗口可见区域像素原点。 + */ + getVisibleOriginInPixel(): Vec2; + /** + !#en + Returns the current resolution policy + !#zh 返回当前分辨率方案 + */ + getResolutionPolicy(): ResolutionPolicy; + /** + !#en + Sets the current resolution policy + !#zh 设置当前分辨率模式 + @param resolutionPolicy resolutionPolicy + */ + setResolutionPolicy(resolutionPolicy: ResolutionPolicy|number): void; + /** + !#en + Sets the resolution policy with designed view size in points.
+ The resolution policy include:
+ [1] ResolutionExactFit Fill screen by stretch-to-fit: if the design resolution ratio of width to height is different from the screen resolution ratio, your game view will be stretched.
+ [2] ResolutionNoBorder Full screen without black border: if the design resolution ratio of width to height is different from the screen resolution ratio, two areas of your game view will be cut.
+ [3] ResolutionShowAll Full screen with black border: if the design resolution ratio of width to height is different from the screen resolution ratio, two black borders will be shown.
+ [4] ResolutionFixedHeight Scale the content's height to screen's height and proportionally scale its width
+ [5] ResolutionFixedWidth Scale the content's width to screen's width and proportionally scale its height
+ [cc.ResolutionPolicy] [Web only feature] Custom resolution policy, constructed by cc.ResolutionPolicy
+ !#zh 通过设置设计分辨率和匹配模式来进行游戏画面的屏幕适配。 + @param width Design resolution width. + @param height Design resolution height. + @param resolutionPolicy The resolution policy desired + */ + setDesignResolutionSize(width: number, height: number, resolutionPolicy: ResolutionPolicy|number): void; + /** + !#en + Returns the designed size for the view. + Default resolution size is the same as 'getFrameSize'. + !#zh 返回视图的设计分辨率。 + 默认下分辨率尺寸同 `getFrameSize` 方法相同 + */ + getDesignResolutionSize(): Size; + /** + !#en + Sets the container to desired pixel resolution and fit the game content to it. + This function is very useful for adaptation in mobile browsers. + In some HD android devices, the resolution is very high, but its browser performance may not be very good. + In this case, enabling retina display is very costy and not suggested, and if retina is disabled, the image may be blurry. + But this API can be helpful to set a desired pixel resolution which is in between. + This API will do the following: + 1. Set viewport's width to the desired width in pixel + 2. Set body width to the exact pixel resolution + 3. The resolution policy will be reset with designed view size in points. + !#zh 设置容器(container)需要的像素分辨率并且适配相应分辨率的游戏内容。 + @param width Design resolution width. + @param height Design resolution height. + @param resolutionPolicy The resolution policy desired + */ + setRealPixelResolution(width: number, height: number, resolutionPolicy: ResolutionPolicy|number): void; + /** + !#en + Sets view port rectangle with points. + !#zh 用设计分辨率下的点尺寸来设置视窗。 + @param x x + @param y y + @param w width + @param h height + */ + setViewportInPoints(x: number, y: number, w: number, h: number): void; + /** + !#en + Sets Scissor rectangle with points. + !#zh 用设计分辨率下的点的尺寸来设置 scissor 剪裁区域。 + @param x x + @param y y + @param w w + @param h h + */ + setScissorInPoints(x: number, y: number, w: number, h: number): void; + /** + !#en + Returns whether GL_SCISSOR_TEST is enable + !#zh 检查 scissor 是否生效。 + */ + isScissorEnabled(): boolean; + /** + !#en + Returns the current scissor rectangle + !#zh 返回当前的 scissor 剪裁区域。 + */ + getScissorRect(): Rect; + /** + !#en + Returns the view port rectangle. + !#zh 返回视窗剪裁区域。 + */ + getViewportRect(): Rect; + /** + !#en + Returns scale factor of the horizontal direction (X axis). + !#zh 返回横轴的缩放比,这个缩放比是将画布像素分辨率放到设计分辨率的比例。 + */ + getScaleX(): number; + /** + !#en + Returns scale factor of the vertical direction (Y axis). + !#zh 返回纵轴的缩放比,这个缩放比是将画布像素分辨率缩放到设计分辨率的比例。 + */ + getScaleY(): number; + /** + !#en + Returns device pixel ratio for retina display. + !#zh 返回设备或浏览器像素比例。 + */ + getDevicePixelRatio(): number; + /** + !#en + Returns the real location in view for a translation based on a related position + !#zh 将屏幕坐标转换为游戏视图下的坐标。 + @param tx The X axis translation + @param ty The Y axis translation + @param relatedPos The related position object including "left", "top", "width", "height" informations + */ + convertToLocationInView(tx: number, ty: number, relatedPos: any): Vec2; + } + /**

cc.game.containerStrategy class is the root strategy class of container's scale strategy, + it controls the behavior of how to scale the cc.game.container and cc.game.canvas object

*/ + export class ContainerStrategy { + /** + !#en + Manipulation before appling the strategy + !#zh 在应用策略之前的操作 + @param view The target view + */ + preApply(view: View): void; + /** + !#en + Function to apply this strategy + !#zh 策略应用方法 + @param view view + @param designedResolution designedResolution + */ + apply(view: View, designedResolution: Size): void; + /** + !#en + Manipulation after applying the strategy + !#zh 策略调用之后的操作 + @param view The target view + */ + postApply(view: View): void; + } + /**

cc.ContentStrategy class is the root strategy class of content's scale strategy, + it controls the behavior of how to scale the scene and setup the viewport for the game

*/ + export class ContentStrategy { + /** + !#en + Manipulation before applying the strategy + !#zh 策略应用前的操作 + @param view The target view + */ + preApply(view: View): void; + /** + !#en Function to apply this strategy + The return value is {scale: [scaleX, scaleY], viewport: {cc.Rect}}, + The target view can then apply these value to itself, it's preferred not to modify directly its private variables + !#zh 调用策略方法 + @param view view + @param designedResolution designedResolution + */ + apply(view: View, designedResolution: Size): any; + /** + !#en + Manipulation after applying the strategy + !#zh 策略调用之后的操作 + @param view The target view + */ + postApply(view: View): void; + } + /** undefined */ + export class EqualToFrame extends ContainerStrategy { + } + /** undefined */ + export class ProportionalToFrame extends ContainerStrategy { + } + /** undefined */ + export class EqualToWindow extends EqualToFrame { + } + /** undefined */ + export class ProportionalToWindow extends ProportionalToFrame { + } + /** undefined */ + export class OriginalContainer extends ContainerStrategy { + } + /**

cc.ResolutionPolicy class is the root strategy class of scale strategy, + its main task is to maintain the compatibility with Cocos2d-x

*/ + export class ResolutionPolicy { + /** + + @param containerStg The container strategy + @param contentStg The content strategy + */ + constructor(containerStg: ContainerStrategy, contentStg: ContentStrategy); + /** + !#en Manipulation before applying the resolution policy + !#zh 策略应用前的操作 + @param view The target view + */ + preApply(view: View): void; + /** + !#en Function to apply this resolution policy + The return value is {scale: [scaleX, scaleY], viewport: {cc.Rect}}, + The target view can then apply these value to itself, it's preferred not to modify directly its private variables + !#zh 调用策略方法 + @param view The target view + @param designedResolution The user defined design resolution + */ + apply(view: View, designedResolution: Size): any; + /** + !#en Manipulation after appyling the strategy + !#zh 策略应用之后的操作 + @param view The target view + */ + postApply(view: View): void; + /** + !#en + Setup the container's scale strategy + !#zh 设置容器的适配策略 + @param containerStg containerStg + */ + setContainerStrategy(containerStg: ContainerStrategy): void; + /** + !#en + Setup the content's scale strategy + !#zh 设置内容的适配策略 + @param contentStg contentStg + */ + setContentStrategy(contentStg: ContentStrategy): void; + /** The entire application is visible in the specified area without trying to preserve the original aspect ratio.
+ Distortion can occur, and the application may appear stretched or compressed. */ + static EXACT_FIT: number; + /** The entire application fills the specified area, without distortion but possibly with some cropping,
+ while maintaining the original aspect ratio of the application. */ + static NO_BORDER: number; + /** The entire application is visible in the specified area without distortion while maintaining the original
+ aspect ratio of the application. Borders can appear on two sides of the application. */ + static SHOW_ALL: number; + /** The application takes the height of the design resolution size and modifies the width of the internal
+ canvas so that it fits the aspect ratio of the device
+ no distortion will occur however you must make sure your application works on different
+ aspect ratios */ + static FIXED_HEIGHT: number; + /** The application takes the width of the design resolution size and modifies the height of the internal
+ canvas so that it fits the aspect ratio of the device
+ no distortion will occur however you must make sure your application works on different
+ aspect ratios */ + static FIXED_WIDTH: number; + /** Unknow policy */ + static UNKNOWN: number; + } + /** cc.visibleRect is a singleton object which defines the actual visible rect of the current view, + it should represent the same rect as cc.view.getViewportRect() */ + export class visibleRect { + /** + initialize + @param visibleRect visibleRect + */ + static init(visibleRect: Rect): void; + /** Top left coordinate of the screen related to the game scene. */ + static topLeft: Vec2; + /** Top right coordinate of the screen related to the game scene. */ + static topRight: Vec2; + /** Top center coordinate of the screen related to the game scene. */ + static top: Vec2; + /** Bottom left coordinate of the screen related to the game scene. */ + static bottomLeft: Vec2; + /** Bottom right coordinate of the screen related to the game scene. */ + static bottomRight: Vec2; + /** Bottom center coordinate of the screen related to the game scene. */ + static bottom: Vec2; + /** Center coordinate of the screen related to the game scene. */ + static center: Vec2; + /** Left center coordinate of the screen related to the game scene. */ + static left: Vec2; + /** Right center coordinate of the screen related to the game scene. */ + static right: Vec2; + /** Width of the screen. */ + static width: number; + /** Height of the screen. */ + static height: number; + } + /** !#en The callbacks invoker to handle and invoke callbacks by key. + !#zh CallbacksInvoker 用来根据 Key 管理并调用回调方法。 */ + export class CallbacksInvoker { + /** + !#zh + 检查指定事件是否已注册回调。 + !#en + Check if the specified key has any registered callback. If a callback is also specified, + it will only return true if the callback is registered. + @param key key + @param callback callback + @param target target + */ + hasEventListener(key: string, callback?: Function, target?: any): boolean; + /** + !#zh + 移除在特定事件类型中注册的所有回调或在某个目标中注册的所有回调。 + + !#en + Removes all callbacks registered in a certain event type or all callbacks registered with a certain target + @param keyOrTarget The event key to be removed or the target to be removed + */ + removeAll(keyOrTarget: string|any): void; + /** + !#zh + 删除之前与同类型,回调,目标注册的回调。 + @param key key + @param callback callback + @param target target + */ + off(key: string, callback: Function, target?: any): void; + /** + !#en + Trigger an event directly with the event name and necessary arguments. + !#zh + 通过事件名发送自定义事件 + @param key event type + @param arg1 First argument + @param arg2 Second argument + @param arg3 Third argument + @param arg4 Fourth argument + @param arg5 Fifth argument + + @example + ```js + eventTarget.emit('fire', event); + eventTarget.emit('fire', message, emitter); + ``` + */ + emit(key: string, arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any): void; + } + /** !#en Contains information collected during deserialization + !#zh 包含反序列化时的一些信息 */ + export class Details { + /** the obj list whose field needs to load asset by uuid */ + uuidObjList: any[]; + /** the corresponding field name which referenced to the asset */ + uuidPropList: (String|Number)[]; + /** list of the depends assets' uuid */ + uuidList: string[]; + /** + + @param data data + */ + init(data: any): void; + reset(): void; + /** + + @param obj obj + @param propName propName + @param uuid uuid + */ + push(obj: any, propName: string, uuid: string): void; + /** list of the depends assets' uuid */ + uuidList: string[]; + /** the obj list whose field needs to load asset by uuid */ + uuidObjList: any[]; + /** the corresponding field name which referenced to the asset */ + uuidPropList: string[]; + reset(): void; + /** + + @param obj obj + @param propName propName + @param uuid uuid + */ + push(obj: any, propName: string, uuid: string): void; + } + /** !#en The module provides utilities for working with file and directory paths + !#zh 用于处理文件与目录的路径的模块 */ + export class path { + /** + !#en Join strings to be a path. + !#zh 拼接字符串为 Path + + @example + ```js + ------------------------------ + cc.path.join("a", "b.png"); //-->"a/b.png" + cc.path.join("a", "b", "c.png"); //-->"a/b/c.png" + cc.path.join("a", "b"); //-->"a/b" + cc.path.join("a", "b", "/"); //-->"a/b/" + cc.path.join("a", "b/", "/"); //-->"a/b/" + + ``` + */ + static join(): string; + /** + !#en Get the ext name of a path including '.', like '.png'. + !#zh 返回 Path 的扩展名,包括 '.',例如 '.png'。 + @param pathStr pathStr + + @example + ```js + --------------------------- + cc.path.extname("a/b.png"); //-->".png" + cc.path.extname("a/b.png?a=1&b=2"); //-->".png" + cc.path.extname("a/b"); //-->null + cc.path.extname("a/b?a=1&b=2"); //-->null + + ``` + */ + static extname(pathStr: string): any; + /** + !#en Get the main name of a file name + !#zh 获取文件名的主名称 + @param fileName fileName + */ + static mainFileName(fileName: string): string; + /** + !#en Get the file name of a file path. + !#zh 获取文件路径的文件名。 + @param pathStr pathStr + @param extname extname + + @example + ```js + --------------------------------- + cc.path.basename("a/b.png"); //-->"b.png" + cc.path.basename("a/b.png?a=1&b=2"); //-->"b.png" + cc.path.basename("a/b.png", ".png"); //-->"b" + cc.path.basename("a/b.png?a=1&b=2", ".png"); //-->"b" + cc.path.basename("a/b.png", ".txt"); //-->"b.png" + + ``` + */ + static basename(pathStr: string, extname?: string): any; + /** + !#en Get dirname of a file path. + !#zh 获取文件路径的目录名。 + @param pathStr pathStr + + @example + ```js + --------------------------------- + * unix + cc.path.driname("a/b/c.png"); //-->"a/b" + cc.path.driname("a/b/c.png?a=1&b=2"); //-->"a/b" + cc.path.dirname("a/b/"); //-->"a/b" + cc.path.dirname("c.png"); //-->"" + * windows + cc.path.driname("a\\b\\c.png"); //-->"a\b" + cc.path.driname("a\\b\\c.png?a=1&b=2"); //-->"a\b" + + ``` + */ + static dirname(pathStr: string): any; + /** + !#en Change extname of a file path. + !#zh 更改文件路径的扩展名。 + @param pathStr pathStr + @param extname extname + + @example + ```js + --------------------------------- + cc.path.changeExtname("a/b.png", ".plist"); //-->"a/b.plist" + cc.path.changeExtname("a/b.png?a=1&b=2", ".plist"); //-->"a/b.plist?a=1&b=2" + + ``` + */ + static changeExtname(pathStr: string, extname?: string): string; + } + /** !#en + AffineTransform class represent an affine transform matrix. It's composed basically by translation, rotation, scale transformations.
+ !#zh + AffineTransform 类代表一个仿射变换矩阵。它基本上是由平移旋转,缩放转变所组成。
*/ + export class AffineTransform { + /** + !#en Create a AffineTransform object with all contents in the matrix. + !#zh 用在矩阵中的所有内容创建一个 AffineTransform 对象。 + @param a a + @param b b + @param c c + @param d d + @param tx tx + @param ty ty + */ + static create(a: number, b: number, c: number, d: number, tx: number, ty: number): AffineTransform; + /** + !#en + Create a identity transformation matrix:
+ [ 1, 0, 0,
+ 0, 1, 0 ] + !#zh + 单位矩阵:
+ [ 1, 0, 0,
+ 0, 1, 0 ] + */ + static identity(): AffineTransform; + /** + !#en Clone a AffineTransform object from the specified transform. + !#zh 克隆指定的 AffineTransform 对象。 + @param t t + */ + static clone(t: AffineTransform): AffineTransform; + /** + !#en + Concatenate a transform matrix to another + The results are reflected in the out affine transform + out = t1 * t2 + This function is memory free, you should create the output affine transform by yourself and manage its memory. + !#zh + 拼接两个矩阵,将结果保存到 out 矩阵。这个函数不创建任何内存,你需要先创建 AffineTransform 对象用来存储结果,并作为第一个参数传入函数。 + out = t1 * t2 + @param out Out object to store the concat result + @param t1 The first transform object. + @param t2 The transform object to concatenate. + */ + static concat(out: AffineTransform, t1: AffineTransform, t2: AffineTransform): AffineTransform; + /** + !#en Get the invert transform of an AffineTransform object. + This function is memory free, you should create the output affine transform by yourself and manage its memory. + !#zh 求逆矩阵。这个函数不创建任何内存,你需要先创建 AffineTransform 对象用来存储结果,并作为第一个参数传入函数。 + @param out out + @param t t + */ + static invert(out: AffineTransform, t: AffineTransform): AffineTransform; + /** + !#en Get an AffineTransform object from a given matrix 4x4. + This function is memory free, you should create the output affine transform by yourself and manage its memory. + !#zh 从一个 4x4 Matrix 获取 AffineTransform 对象。这个函数不创建任何内存,你需要先创建 AffineTransform 对象用来存储结果,并作为第一个参数传入函数。 + @param out out + @param mat mat + */ + static invert(out: AffineTransform, mat: Mat4): AffineTransform; + /** + !#en Apply the affine transformation on a point. + This function is memory free, you should create the output Vec2 by yourself and manage its memory. + !#zh 对一个点应用矩阵变换。这个函数不创建任何内存,你需要先创建一个 Vec2 对象用来存储结果,并作为第一个参数传入函数。 + @param out The output point to store the result + @param point Point to apply transform or x. + @param transOrY transform matrix or y. + @param t transform matrix. + */ + static transformVec2(out: Vec2, point: Vec2|number, transOrY: AffineTransform|number, t?: AffineTransform): Vec2; + /** + !#en Apply the affine transformation on a size. + This function is memory free, you should create the output Size by yourself and manage its memory. + !#zh 应用仿射变换矩阵到 Size 上。这个函数不创建任何内存,你需要先创建一个 Size 对象用来存储结果,并作为第一个参数传入函数。 + @param out The output point to store the result + @param size size + @param t t + */ + static transformSize(out: Size, size: Size, t: AffineTransform): Size; + /** + !#en Apply the affine transformation on a rect. + This function is memory free, you should create the output Rect by yourself and manage its memory. + !#zh 应用仿射变换矩阵到 Rect 上。这个函数不创建任何内存,你需要先创建一个 Rect 对象用来存储结果,并作为第一个参数传入函数。 + @param out out + @param rect rect + @param anAffineTransform anAffineTransform + */ + static transformRect(out: Rect, rect: Rect, anAffineTransform: AffineTransform): Rect; + /** + !#en Apply the affine transformation on a rect, and truns to an Oriented Bounding Box. + This function is memory free, you should create the output vectors by yourself and manage their memory. + !#zh 应用仿射变换矩阵到 Rect 上, 并转换为有向包围盒。这个函数不创建任何内存,你需要先创建包围盒的四个 Vector 对象用来存储结果,并作为前四个参数传入函数。 + @param out_bl out_bl + @param out_tl out_tl + @param out_tr out_tr + @param out_br out_br + @param rect rect + @param anAffineTransform anAffineTransform + */ + static transformObb(out_bl: Vec2, out_tl: Vec2, out_tr: Vec2, out_br: Vec2, rect: Rect, anAffineTransform: AffineTransform): void; + } + /** A base node for CCNode, it will: + - maintain scene hierarchy and active logic + - notifications if some properties changed + - define some interfaces shares between CCNode + - define machanisms for Enity Component Systems + - define prefab and serialize functions */ + export class _BaseNode extends Object implements EventTarget { + /** !#en Name of node. + !#zh 该节点名称。 */ + name: string; + /** !#en The uuid for editor, will be stripped before building project. + !#zh 主要用于编辑器的 uuid,在编辑器下可用于持久化存储,在项目构建之后将变成自增的 id。 */ + uuid: string; + /** !#en All children nodes. + !#zh 节点的所有子节点。 */ + children: Node[]; + /** !#en All children nodes. + !#zh 节点的子节点数量。 */ + childrenCount: number; + /** !#en + The local active state of this node.
+ Note that a Node may be inactive because a parent is not active, even if this returns true.
+ Use {{#crossLink "Node/activeInHierarchy:property"}}{{/crossLink}} if you want to check if the Node is actually treated as active in the scene. + !#zh + 当前节点的自身激活状态。
+ 值得注意的是,一个节点的父节点如果不被激活,那么即使它自身设为激活,它仍然无法激活。
+ 如果你想检查节点在场景中实际的激活状态可以使用 {{#crossLink "Node/activeInHierarchy:property"}}{{/crossLink}}。 */ + active: boolean; + /** !#en Indicates whether this node is active in the scene. + !#zh 表示此节点是否在场景中激活。 */ + activeInHierarchy: boolean; + /** + + @param name name + */ + constructor(name?: string); + /** !#en The parent of the node. + !#zh 该节点的父节点。 */ + parent: Node; + /** + !#en Get parent of the node. + !#zh 获取该节点的父节点。 + + @example + ```js + var parent = this.node.getParent(); + ``` + */ + getParent(): Node; + /** + !#en Set parent of the node. + !#zh 设置该节点的父节点。 + @param value value + + @example + ```js + node.setParent(newNode); + ``` + */ + setParent(value: Node): void; + /** + !#en + Properties configuration function
+ All properties in attrs will be set to the node,
+ when the setter of the node is available,
+ the property will be set via setter function.
+ !#zh 属性配置函数。在 attrs 的所有属性将被设置为节点属性。 + @param attrs Properties to be set to node + + @example + ```js + var attrs = { key: 0, num: 100 }; + node.attr(attrs); + ``` + */ + attr(attrs: any): void; + /** + !#en Returns a child from the container given its uuid. + !#zh 通过 uuid 获取节点的子节点。 + @param uuid The uuid to find the child node. + + @example + ```js + var child = node.getChildByUuid(uuid); + ``` + */ + getChildByUuid(uuid: string): Node; + /** + !#en Returns a child from the container given its name. + !#zh 通过名称获取节点的子节点。 + @param name A name to find the child node. + + @example + ```js + var child = node.getChildByName("Test Node"); + ``` + */ + getChildByName(name: string): Node; + /** + !#en + Inserts a child to the node at a specified index. + !#zh + 插入子节点到指定位置 + @param child the child node to be inserted + @param siblingIndex the sibling index to place the child in + + @example + ```js + node.insertChild(child, 2); + ``` + */ + insertChild(child: Node, siblingIndex: number): void; + /** + !#en Get the sibling index. + !#zh 获取同级索引。 + + @example + ```js + var index = node.getSiblingIndex(); + ``` + */ + getSiblingIndex(): number; + /** + !#en Set the sibling index of this node. + !#zh 设置节点同级索引。 + @param index index + + @example + ```js + node.setSiblingIndex(1); + ``` + */ + setSiblingIndex(index: number): void; + /** + !#en Walk though the sub children tree of the current node. + Each node, including the current node, in the sub tree will be visited two times, before all children and after all children. + This function call is not recursive, it's based on stack. + Please don't walk any other node inside the walk process. + !#zh 遍历该节点的子树里的所有节点并按规则执行回调函数。 + 对子树中的所有节点,包含当前节点,会执行两次回调,prefunc 会在访问它的子节点之前调用,postfunc 会在访问所有子节点之后调用。 + 这个函数的实现不是基于递归的,而是基于栈展开递归的方式。 + 请不要在 walk 过程中对任何其他的节点嵌套执行 walk。 + @param prefunc The callback to process node when reach the node for the first time + @param postfunc The callback to process node when re-visit the node after walked all children in its sub tree + + @example + ```js + node.walk(function (target) { + console.log('Walked through node ' + target.name + ' for the first time'); + }, function (target) { + console.log('Walked through node ' + target.name + ' after walked all children in its sub tree'); + }); + ``` + */ + walk(prefunc: (target: _BaseNode) => void, postfunc: (target: _BaseNode) => void): void; + /** + !#en + Remove itself from its parent node. If cleanup is `true`, then also remove all events and actions.
+ If the cleanup parameter is not passed, it will force a cleanup, so it is recommended that you always pass in the `false` parameter when calling this API.
+ If the node orphan, then nothing happens. + !#zh + 从父节点中删除该节点。如果不传入 cleanup 参数或者传入 `true`,那么这个节点上所有绑定的事件、action 都会被删除。
+ 因此建议调用这个 API 时总是传入 `false` 参数。
+ 如果这个节点是一个孤节点,那么什么都不会发生。 + @param cleanup true if all actions and callbacks on this node should be removed, false otherwise. + + @example + ```js + node.removeFromParent(); + node.removeFromParent(false); + ``` + */ + removeFromParent(cleanup?: boolean): void; + /** + !#en + Removes a child from the container. It will also cleanup all running actions depending on the cleanup parameter.

+ If the cleanup parameter is not passed, it will force a cleanup.
+ "remove" logic MUST only be on this method
+ If a class wants to extend the 'removeChild' behavior it only needs
+ to override this method. + !#zh + 移除节点中指定的子节点,是否需要清理所有正在运行的行为取决于 cleanup 参数。
+ 如果 cleanup 参数不传入,默认为 true 表示清理。
+ @param child The child node which will be removed. + @param cleanup true if all running actions and callbacks on the child node will be cleanup, false otherwise. + + @example + ```js + node.removeChild(newNode); + node.removeChild(newNode, false); + ``` + */ + removeChild(child: Node, cleanup?: boolean): void; + /** + !#en + Removes all children from the container and do a cleanup all running actions depending on the cleanup parameter.
+ If the cleanup parameter is not passed, it will force a cleanup. + !#zh + 移除节点所有的子节点,是否需要清理所有正在运行的行为取决于 cleanup 参数。
+ 如果 cleanup 参数不传入,默认为 true 表示清理。 + @param cleanup true if all running actions on all children nodes should be cleanup, false otherwise. + + @example + ```js + node.removeAllChildren(); + node.removeAllChildren(false); + ``` + */ + removeAllChildren(cleanup?: boolean): void; + /** + !#en Is this node a child of the given node? + !#zh 是否是指定节点的子节点? + @param parent parent + + @example + ```js + node.isChildOf(newNode); + ``` + */ + isChildOf(parent: Node): boolean; + /** + !#en + Returns the component of supplied type if the node has one attached, null if it doesn't.
+ You can also get component in the node by passing in the name of the script. + !#zh + 获取节点上指定类型的组件,如果节点有附加指定类型的组件,则返回,如果没有则为空。
+ 传入参数也可以是脚本的名称。 + @param typeOrClassName typeOrClassName + + @example + ```js + // get sprite component + var sprite = node.getComponent(cc.Sprite); + // get custom test class + var test = node.getComponent("Test"); + ``` + */ + getComponent(type: {prototype: T}): T; + getComponent(className: string): any; + /** + !#en Returns all components of supplied type in the node. + !#zh 返回节点上指定类型的所有组件。 + @param typeOrClassName typeOrClassName + + @example + ```js + var sprites = node.getComponents(cc.Sprite); + var tests = node.getComponents("Test"); + ``` + */ + getComponents(type: {prototype: T}): T[]; + getComponents(className: string): any[]; + /** + !#en Returns the component of supplied type in any of its children using depth first search. + !#zh 递归查找所有子节点中第一个匹配指定类型的组件。 + @param typeOrClassName typeOrClassName + + @example + ```js + var sprite = node.getComponentInChildren(cc.Sprite); + var Test = node.getComponentInChildren("Test"); + ``` + */ + getComponentInChildren(type: {prototype: T}): T; + getComponentInChildren(className: string): any; + /** + !#en Returns all components of supplied type in self or any of its children. + !#zh 递归查找自身或所有子节点中指定类型的组件 + @param typeOrClassName typeOrClassName + + @example + ```js + var sprites = node.getComponentsInChildren(cc.Sprite); + var tests = node.getComponentsInChildren("Test"); + ``` + */ + getComponentsInChildren(type: {prototype: T}): T[]; + getComponentsInChildren(className: string): any[]; + /** + !#en Adds a component class to the node. You can also add component to node by passing in the name of the script. + !#zh 向节点添加一个指定类型的组件类,你还可以通过传入脚本的名称来添加组件。 + @param typeOrClassName The constructor or the class name of the component to add + + @example + ```js + var sprite = node.addComponent(cc.Sprite); + var test = node.addComponent("Test"); + ``` + */ + addComponent(type: {new(): T}): T; + addComponent(className: string): any; + /** + !#en + Removes a component identified by the given name or removes the component object given. + You can also use component.destroy() if you already have the reference. + !#zh + 删除节点上的指定组件,传入参数可以是一个组件构造函数或组件名,也可以是已经获得的组件引用。 + 如果你已经获得组件引用,你也可以直接调用 component.destroy() + @param component The need remove component. + + @example + ```js + node.removeComponent(cc.Sprite); + var Test = require("Test"); + node.removeComponent(Test); + ``` + */ + removeComponent(component: string|Function|Component): void; + /** + !#en + Destroy all children from the node, and release all their own references to other objects.
+ Actual destruct operation will delayed until before rendering. + !#zh + 销毁所有子节点,并释放所有它们对其它对象的引用。
+ 实际销毁操作会延迟到当前帧渲染前执行。 + + @example + ```js + node.destroyAllChildren(); + ``` + */ + destroyAllChildren(): void; + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en + Register an callback of a specific event type on the EventTarget. + This type of event should be triggered via `emit`. + !#zh + 注册事件目标的特定事件类型回调。这种类型的事件应该被 `emit` 触发。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, node); + ``` + */ + on(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. + !#zh + 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + + @example + ```js + // register fire eventListener + var callback = eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, target); + // remove fire event listener + eventTarget.off('fire', callback, target); + // remove all fire event listeners + eventTarget.off('fire'); + ``` + */ + off(type: string, callback?: Function, target?: any): void; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.once('fire', function () { + cc.log("this is the callback and will be invoked only once"); + }, node); + ``` + */ + once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; + /** + !#en + Send an event with the event object. + !#zh + 通过事件对象派发事件 + @param event event + */ + dispatchEvent(event: Event): void; + /** + !#en + Destroy all callbackInfos. + !#zh + 销毁记录的事件 + */ + clear(): void; + } + /** !#en + Helper class for setting material blend function. + !#zh + 设置材质混合模式的辅助类。 */ + export class BlendFunc { + /** !#en specify the source Blend Factor, this will generate a custom material object, please pay attention to the memory cost. + !#zh 指定原图的混合模式,这会克隆一个新的材质对象,注意这带来的开销 */ + srcBlendFactor: macro.BlendFactor; + /** !#en specify the destination Blend Factor. + !#zh 指定目标的混合模式 */ + dstBlendFactor: macro.BlendFactor; + } + /** An internal helper class for switching render component's material between normal sprite material and gray sprite material. */ + export class GraySpriteState { + /** !#en The normal material. + !#zh 正常状态的材质。 */ + normalMaterial: Material; + /** !#en The gray material. + !#zh 置灰状态的材质。 */ + grayMaterial: Material; + } + /** misc utilities */ + export class misc { + /** + !#en Clamp a value between from and to. + !#zh + 限定浮点数的最大最小值。
+ 数值大于 max_inclusive 则返回 max_inclusive。
+ 数值小于 min_inclusive 则返回 min_inclusive。
+ 否则返回自身。 + @param value value + @param min_inclusive min_inclusive + @param max_inclusive max_inclusive + + @example + ```js + var v1 = cc.misc.clampf(20, 0, 20); // 20; + var v2 = cc.misc.clampf(-1, 0, 20); // 0; + var v3 = cc.misc.clampf(10, 0, 20); // 10; + ``` + */ + static clampf(value: number, min_inclusive: number, max_inclusive: number): number; + /** + !#en Clamp a value between 0 and 1. + !#zh 限定浮点数的取值范围为 0 ~ 1 之间。 + @param value value + + @example + ```js + var v1 = cc.misc.clamp01(20); // 1; + var v2 = cc.misc.clamp01(-1); // 0; + var v3 = cc.misc.clamp01(0.5); // 0.5; + ``` + */ + static clamp01(value: number): number; + /** + Linear interpolation between 2 numbers, the ratio sets how much it is biased to each end + @param a number A + @param b number B + @param r ratio between 0 and 1 + + @example + ```js + ---- + lerp + cc.misc.lerp(2,10,0.5)//returns 6 + cc.misc.lerp(2,10,0.2)//returns 3.6 + + ``` + */ + static lerp(a: number, b: number, r: number): number; + /** + converts degrees to radians + @param angle angle + */ + static degreesToRadians(angle: number): number; + /** + converts radians to degrees + @param angle angle + */ + static radiansToDegrees(angle: number): number; + } + /** !#en + Representation of RGBA colors. + + Each color component is a floating point value with a range from 0 to 255. + + You can also use the convenience method {{#crossLink "cc/color:method"}}cc.color{{/crossLink}} to create a new Color. + + !#zh + cc.Color 用于表示颜色。 + + 它包含 RGBA 四个以浮点数保存的颜色分量,每个的值都在 0 到 255 之间。 + + 您也可以通过使用 {{#crossLink "cc/color:method"}}cc.color{{/crossLink}} 的便捷方法来创建一个新的 Color。 */ + export class Color extends ValueType { + /** !#en Solid white, RGBA is [255, 255, 255, 255]. + !#zh 纯白色,RGBA 是 [255, 255, 255, 255]。 */ + static WHITE: Color; + /** !#en Solid black, RGBA is [0, 0, 0, 255]. + !#zh 纯黑色,RGBA 是 [0, 0, 0, 255]。 */ + static BLACK: Color; + /** !#en Transparent, RGBA is [0, 0, 0, 0]. + !#zh 透明,RGBA 是 [0, 0, 0, 0]。 */ + static TRANSPARENT: Color; + /** !#en Grey, RGBA is [127.5, 127.5, 127.5]. + !#zh 灰色,RGBA 是 [127.5, 127.5, 127.5]。 */ + static GRAY: Color; + /** !#en Solid red, RGBA is [255, 0, 0]. + !#zh 纯红色,RGBA 是 [255, 0, 0]。 */ + static RED: Color; + /** !#en Solid green, RGBA is [0, 255, 0]. + !#zh 纯绿色,RGBA 是 [0, 255, 0]。 */ + static GREEN: Color; + /** !#en Solid blue, RGBA is [0, 0, 255]. + !#zh 纯蓝色,RGBA 是 [0, 0, 255]。 */ + static BLUE: Color; + /** !#en Yellow, RGBA is [255, 235, 4]. + !#zh 黄色,RGBA 是 [255, 235, 4]。 */ + static YELLOW: Color; + /** !#en Orange, RGBA is [255, 127, 0]. + !#zh 橙色,RGBA 是 [255, 127, 0]。 */ + static ORANGE: Color; + /** !#en Cyan, RGBA is [0, 255, 255]. + !#zh 青色,RGBA 是 [0, 255, 255]。 */ + static CYAN: Color; + /** !#en Magenta, RGBA is [255, 0, 255]. + !#zh 洋红色(品红色),RGBA 是 [255, 0, 255]。 */ + static MAGENTA: Color; + /** + Copy content of a color into another. + */ + static copy (out: Color, a: Color): Color; + /** + Clone a new color. + */ + static clone (a: Color): Color; + /** + Set the components of a color to the given values. + */ + static set (out: Color, r?: number, g?: number, b?: number, a?: number): Color; + /** + Converts the hexadecimal formal color into rgb formal. + */ + static fromHex (out: Color, hex: number): Color; + /** + Converts the hexadecimal formal color into rgb formal. + */ + static fromHEX (out: Color, hex: string): Color; + /** + Add components of two colors, respectively. + */ + static add (out: Color, a: Color, b: Color): Color; + /** + Subtract components of color b from components of color a, respectively. + */ + static subtract (out: Color, a: Color, b: Color): Color; + /** + Multiply components of two colors, respectively. + */ + static multiply (out: Color, a: Color, b: Color): Color; + /** + Divide components of color a by components of color b, respectively. + */ + static divide (out: Color, a: Color, b: Color): Color; + /** + Scales a color by a number. + */ + static scale (out: Color, a: Color, b: number): Color; + /** + Performs a linear interpolation between two colors. + */ + static lerp (out: Color, a: Color, b: Color, t: number): Color; + /** + !#zh 颜色转数组 + !#en Turn an array of colors + @param ofs 数组起始偏移量 + */ + static toArray > (out: Out, a: IColorLike, ofs?: number): Out; + /** + !#zh 数组转颜色 + !#en An array of colors turn + @param ofs 数组起始偏移量 + */ + static fromArray (arr: IWritableArrayLike, out: Out, ofs?: number): Out; + /** + !#zh 颜色 RGB 预乘 Alpha 通道 + !#en RGB premultiply alpha channel + @param out 返回颜色 + @param color 预乘处理的目标颜色 + */ + static premultiplyAlpha (out: Out, a: IColorLike); + /** + + @param r red component of the color, default value is 0. + @param g green component of the color, defualt value is 0. + @param b blue component of the color, default value is 0. + @param a alpha component of the color, default value is 255. + */ + constructor(r?: number, g?: number, b?: number, a?: number); + /** + !#en Clone a new color from the current color. + !#zh 克隆当前颜色。 + + @example + ```js + var color = new cc.Color(); + var newColor = color.clone();// Color {r: 0, g: 0, b: 0, a: 255} + ``` + */ + clone(): Color; + /** + !#en TODO + !#zh 判断两个颜色是否相等。 + @param other other + + @example + ```js + var color1 = cc.Color.WHITE; + var color2 = new cc.Color(255, 255, 255); + cc.log(color1.equals(color2)); // true; + color2 = cc.Color.RED; + cc.log(color2.equals(color1)); // false; + ``` + */ + equals(other: Color): boolean; + /** + !#en TODO + !#zh 线性插值 + @param to to + @param ratio the interpolation coefficient. + @param out optional, the receiving vector. + + @example + ```js + // Converts a white color to a black one trough time. + update: function (dt) { + var color = this.node.color; + if (color.equals(cc.Color.BLACK)) { + return; + } + this.ratio += dt * 0.1; + this.node.color = cc.Color.WHITE.lerp(cc.Color.BLACK, ratio); + } + + ``` + */ + lerp(to: Color, ratio: number, out?: Color): Color; + /** + !#en TODO + !#zh 转换为方便阅读的字符串。 + + @example + ```js + var color = cc.Color.WHITE; + color.toString(); // "rgba(255, 255, 255, 255)" + ``` + */ + toString(): string; + /** !#en Get or set red channel value + !#zh 获取或者设置红色通道 */ + r: number; + /** !#en Get or set green channel value + !#zh 获取或者设置绿色通道 */ + g: number; + /** !#en Get or set blue channel value + !#zh 获取或者设置蓝色通道 */ + b: number; + /** !#en Get or set alpha channel value + !#zh 获取或者设置透明通道 */ + a: number; + /** + !#en Gets red channel value + !#zh 获取当前颜色的红色值。 + */ + getR(): number; + /** + !#en Sets red value and return the current color object + !#zh 设置当前的红色值,并返回当前对象。 + @param red the new Red component. + + @example + ```js + var color = new cc.Color(); + color.setR(255); // Color {r: 255, g: 0, b: 0, a: 255} + ``` + */ + setR(red: number): Color; + /** + !#en Gets green channel value + !#zh 获取当前颜色的绿色值。 + */ + getG(): number; + /** + !#en Sets green value and return the current color object + !#zh 设置当前的绿色值,并返回当前对象。 + @param green the new Green component. + + @example + ```js + var color = new cc.Color(); + color.setG(255); // Color {r: 0, g: 255, b: 0, a: 255} + ``` + */ + setG(green: number): Color; + /** + !#en Gets blue channel value + !#zh 获取当前颜色的蓝色值。 + */ + getB(): number; + /** + !#en Sets blue value and return the current color object + !#zh 设置当前的蓝色值,并返回当前对象。 + @param blue the new Blue component. + + @example + ```js + var color = new cc.Color(); + color.setB(255); // Color {r: 0, g: 0, b: 255, a: 255} + ``` + */ + setB(blue: number): Color; + /** + !#en Gets alpha channel value + !#zh 获取当前颜色的透明度值。 + */ + getA(): number; + /** + !#en Sets alpha value and return the current color object + !#zh 设置当前的透明度,并返回当前对象。 + @param alpha the new Alpha component. + + @example + ```js + var color = new cc.Color(); + color.setA(0); // Color {r: 0, g: 0, b: 0, a: 0} + ``` + */ + setA(alpha: number): Color; + /** + !#en Convert color to css format. + !#zh 转换为 CSS 格式。 + @param opt "rgba", "rgb", "#rgb" or "#rrggbb". + + @example + ```js + var color = cc.Color.BLACK; + color.toCSS(); // "rgba(0,0,0,1.00)"; + color.toCSS("rgba"); // "rgba(0,0,0,1.00)"; + color.toCSS("rgb"); // "rgba(0,0,0)"; + color.toCSS("#rgb"); // "#000"; + color.toCSS("#rrggbb"); // "#000000"; + ``` + */ + toCSS(opt?: string): string; + /** + !#en Read hex string and store color data into the current color object, the hex string must be formated as rgba or rgb. + !#zh 读取 16 进制颜色。 + @param hexString hexString + + @example + ```js + var color = cc.Color.BLACK; + color.fromHEX("#FFFF33"); // Color {r: 255, g: 255, b: 51, a: 255}; + ``` + */ + fromHEX(hexString: string): Color; + /** + !#en convert Color to HEX color string. + !#zh 转换为 16 进制。 + @param fmt "#rgb", "#rrggbb" or "#rrggbbaa". + + @example + ```js + var color = cc.Color.BLACK; + color.toHEX("#rgb"); // "000"; + color.toHEX("#rrggbb"); // "000000"; + ``` + */ + toHEX(fmt?: string): string; + /** + !#en Convert to 24bit rgb value. + !#zh 转换为 24bit 的 RGB 值。 + + @example + ```js + var color = cc.Color.YELLOW; + color.toRGBValue(); // 16771844; + ``` + */ + toRGBValue(): number; + /** + !#en Read HSV model color and convert to RGB color + !#zh 读取 HSV(色彩模型)格式。 + @param h h + @param s s + @param v v + + @example + ```js + var color = cc.Color.YELLOW; + color.fromHSV(0, 0, 1); // Color {r: 255, g: 255, b: 255, a: 255}; + ``` + */ + fromHSV(h: number, s: number, v: number): Color; + /** + !#en Transform to HSV model color + !#zh 转换为 HSV(色彩模型)格式。 + + @example + ```js + var color = cc.Color.YELLOW; + color.toHSV(); // Object {h: 0.1533864541832669, s: 0.9843137254901961, v: 1}; + ``` + */ + toHSV(): any; + /** + !#en Set the color + !#zh 设置颜色 + @param color color + */ + set (color: Color): Color; + /** + !#en Multiplies the current color by the specified color + !#zh 将当前颜色乘以与指定颜色 + @param other other + */ + multiply(other: Color): Color; + } + /** Mathematical 3x3 matrix. + + NOTE: we use column-major matrix for all matrix calculation. + + This may lead to some confusion when referencing OpenGL documentation, + however, which represents out all matricies in column-major format. + This means that while in code a matrix may be typed out as: + + [1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 1, 0, + x, y, z, 0] + + The same matrix in the [OpenGL documentation](https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glTranslate.xml) + is written as: + + 1 0 0 x + 0 1 0 y + 0 0 1 z + 0 0 0 0 + + Please rest assured, however, that they are the same thing! + This is not unique to glMatrix, either, as OpenGL developers have long been confused by the + apparent lack of consistency between the memory layout and the documentation. */ + export class Mat3 extends ValueType { + /** Identity of Mat3 */ + static IDENTITY: Mat3; + /** + !#zh 矩阵转数组 + !#en Matrix transpose array + @param ofs 数组内的起始偏移量 + */ + static toArray > (out: Out, mat: IMat3Like, ofs?: number): Out; + /** + !#zh 数组转矩阵 + !#en Transfer matrix array + @param ofs 数组起始偏移量 + */ + static fromArray (out: Out, arr: IWritableArrayLike, ofs?: number): Out; + /** !#en Matrix Data + !#zh 矩阵数据 */ + m: Float64Array|Float32Array; + constructor (m00?: number | Float32Array, m01?: number, m02?: number, m03?: number, m04?: number, m05?: number, m06?: number, m07?: number, m08?: number); + } + /** !#en Representation of 4*4 matrix. + !#zh 表示 4*4 矩阵 */ + export class Mat4 extends ValueType { + /** + !#en Multiply the current matrix with another one + !#zh 将当前矩阵与指定矩阵相乘 + @param other the second operand + @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created + */ + mul(other: Mat4, out?: Mat4): Mat4; + /** + !#en Multiply each element of the matrix by a scalar. + !#zh 将矩阵的每一个元素都乘以指定的缩放值。 + @param number amount to scale the matrix's elements by + @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created + */ + mulScalar(number: number, out?: Mat4): Mat4; + /** + !#en Subtracts the current matrix with another one + !#zh 将当前矩阵与指定的矩阵相减 + @param other the second operand + @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created + */ + sub(other: Mat4, out?: Mat4): Mat4; + /** Identity of Mat4 */ + static IDENTITY: Mat4; + /** + !#zh 获得指定矩阵的拷贝 + !#en Copy of the specified matrix to obtain + */ + static clone (a: Out): Mat4; + /** + !#zh 复制目标矩阵 + !#en Copy the target matrix + */ + static copy (out: Out, a: Out): Out; + /** + !#zh 将目标赋值为单位矩阵 + !#en The target of an assignment is the identity matrix + */ + static identity (out: Out): Out; + /** + !#zh 转置矩阵 + !#en Transposed matrix + */ + static transpose (out: Out, a: Out): Out; + /** + !#zh 矩阵求逆 + !#en Matrix inversion + */ + static invert (out: Out, a: Out): Out; + /** + !#zh 矩阵行列式 + !#en Matrix determinant + */ + static determinant (a: Out): number; + /** + !#zh 矩阵乘法 + !#en Matrix Multiplication + */ + static multiply (out: Out, a: Out, b: Out): Out; + /** + !#zh 在给定矩阵变换基础上加入变换 + !#en Was added in a given transformation matrix transformation on the basis of + */ + static transform (out: Out, a: Out, v: VecLike): Out; + /** + !#zh 在给定矩阵变换基础上加入新位移变换 + !#en Add new displacement transducer in a matrix transformation on the basis of a given + */ + static translate (out: Out, a: Out, v: VecLike): Out; + /** + !#zh 在给定矩阵变换基础上加入新缩放变换 + !#en Add new scaling transformation in a given matrix transformation on the basis of + */ + static scale (out: Out, a: Out, v: VecLike): Out; + /** + !#zh 在给定矩阵变换基础上加入新旋转变换 + !#en Add a new rotational transform matrix transformation on the basis of a given + @param rad 旋转角度 + @param axis 旋转轴 + */ + static rotate (out: Out, a: Out, rad: number, axis: VecLike): Out; + /** + !#zh 在给定矩阵变换基础上加入绕 X 轴的旋转变换 + !#en Add rotational transformation around the X axis at a given matrix transformation on the basis of + @param rad 旋转角度 + */ + static rotateX (out: Out, a: Out, rad: number): Out; + /** + !#zh 在给定矩阵变换基础上加入绕 Y 轴的旋转变换 + !#en Add about the Y axis rotation transformation in a given matrix transformation on the basis of + @param rad 旋转角度 + */ + static rotateY (out: Out, a: Out, rad: number): Out; + /** + !#zh 在给定矩阵变换基础上加入绕 Z 轴的旋转变换 + !#en Added about the Z axis at a given rotational transformation matrix transformation on the basis of + @param rad 旋转角度 + */ + static rotateZ (out: Out, a: Out, rad: number): Out; + /** + !#zh 计算位移矩阵 + !#en Displacement matrix calculation + */ + static fromTranslation (out: Out, v: VecLike): Out; + /** + !#zh 计算缩放矩阵 + !#en Scaling matrix calculation + */ + static fromScaling (out: Out, v: VecLike): Out; + /** + !#zh 计算旋转矩阵 + !#en Calculates the rotation matrix + */ + static fromRotation (out: Out, rad: number, axis: VecLike): Out; + /** + !#zh 计算绕 X 轴的旋转矩阵 + !#en Calculating rotation matrix about the X axis + */ + static fromXRotation (out: Out, rad: number): Out; + /** + !#zh 计算绕 Y 轴的旋转矩阵 + !#en Calculating rotation matrix about the Y axis + */ + static fromYRotation (out: Out, rad: number): Out; + /** + !#zh 计算绕 Z 轴的旋转矩阵 + !#en Calculating rotation matrix about the Z axis + */ + static fromZRotation (out: Out, rad: number): Out; + /** + !#zh 根据旋转和位移信息计算矩阵 + !#en The rotation and displacement information calculating matrix + */ + static fromRT (out: Out, q: Quat, v: VecLike): Out; + /** + !#zh 提取矩阵的位移信息, 默认矩阵中的变换以 S->R->T 的顺序应用 + !#en Extracting displacement information of the matrix, the matrix transform to the default sequential application S-> R-> T is + */ + static getTranslation (out: VecLike, mat: Out): VecLike; + /** + !#zh 提取矩阵的缩放信息, 默认矩阵中的变换以 S->R->T 的顺序应用 + !#en Scaling information extraction matrix, the matrix transform to the default sequential application S-> R-> T is + */ + static getScaling (out: VecLike, mat: Out): VecLike; + /** + !#zh 提取矩阵的旋转信息, 默认输入矩阵不含有缩放信息,如考虑缩放应使用 `toRTS` 函数。 + !#en Rotation information extraction matrix, the matrix containing no default input scaling information, such as the use of `toRTS` should consider the scaling function. + */ + static getRotation (out: Quat, mat: Out): Quat; + /** + !#zh 提取旋转、位移、缩放信息, 默认矩阵中的变换以 S->R->T 的顺序应用 + !#en Extracting rotational displacement, zoom information, the default matrix transformation in order S-> R-> T applications + */ + static toRTS (mat: Out, q: Quat, v: VecLike, s: VecLike): void; + /** + !#zh 根据旋转、位移、缩放信息计算矩阵,以 S->R->T 的顺序应用 + !#en The rotary displacement, the scaling matrix calculation information, the order S-> R-> T applications + */ + static fromRTS (out: Out, q: Quat, v: VecLike, s: VecLike): Out; + /** + !#zh 根据指定的旋转、位移、缩放及变换中心信息计算矩阵,以 S->R->T 的顺序应用 + !#en According to the specified rotation, displacement, and scale conversion matrix calculation information center, order S-> R-> T applications + @param q 旋转值 + @param v 位移值 + @param s 缩放值 + @param o 指定变换中心 + */ + static fromRTSOrigin (out: Out, q: Quat, v: VecLike, s: VecLike, o: VecLike): Out; + /** + !#zh 根据指定的旋转信息计算矩阵 + !#en The rotation matrix calculation information specified + */ + static fromQuat (out: Out, q: Quat): Out; + /** + !#zh 根据指定的视锥体信息计算矩阵 + !#en The matrix calculation information specified frustum + @param left 左平面距离 + @param right 右平面距离 + @param bottom 下平面距离 + @param top 上平面距离 + @param near 近平面距离 + @param far 远平面距离 + */ + static frustum (out: Out, left: number, right: number, bottom: number, top: number, near: number, far: number): Out; + /** + !#zh 计算透视投影矩阵 + !#en Perspective projection matrix calculation + @param fovy 纵向视角高度 + @param aspect 长宽比 + @param near 近平面距离 + @param far 远平面距离 + */ + static perspective (out: Out, fovy: number, aspect: number, near: number, far: number): Out; + /** + !#zh 计算正交投影矩阵 + !#en Computing orthogonal projection matrix + @param left 左平面距离 + @param right 右平面距离 + @param bottom 下平面距离 + @param top 上平面距离 + @param near 近平面距离 + @param far 远平面距离 + */ + static ortho (out: Out, left: number, right: number, bottom: number, top: number, near: number, far: number): Out; + /** + !#zh 根据视点计算矩阵,注意 `eye - center` 不能为零向量或与 `up` 向量平行 + !#en `Up` parallel vector or vector center` not be zero - the matrix calculation according to the viewpoint, note` eye + @param eye 当前位置 + @param center 目标视点 + @param up 视口上方向 + */ + static lookAt (out: Out, eye: VecLike, center: VecLike, up: VecLike): Out; + /** + !#zh 计算逆转置矩阵 + !#en Reversal matrix calculation + */ + static inverseTranspose (out: Out, a: Out): Out; + /** + !#zh 逐元素矩阵加法 + !#en Element by element matrix addition + */ + static add (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素矩阵减法 + !#en Matrix element by element subtraction + */ + static subtract (out: Out, a: Out, b: Out): Out; + /** + !#zh 矩阵标量乘法 + !#en Matrix scalar multiplication + */ + static multiplyScalar (out: Out, a: Out, b: number): Out; + /** + !#zh 逐元素矩阵标量乘加: A + B * scale + !#en Elements of the matrix by the scalar multiplication and addition: A + B * scale + */ + static multiplyScalarAndAdd (out: Out, a: Out, b: Out, scale: number): Out; + /** + !#zh 矩阵等价判断 + !#en Analyzing the equivalent matrix + */ + static strictEquals (a: Out, b: Out): boolean; + /** + !#zh 排除浮点数误差的矩阵近似等价判断 + !#en Negative floating point error is approximately equivalent to determining a matrix + */ + static equals (a: Out, b: Out, epsilon?: number): boolean; + /** + !#zh 矩阵转数组 + !#en Matrix transpose array + @param ofs 数组内的起始偏移量 + */ + static toArray > (out: Out, mat: IMat4Like, ofs?: number): Out; + /** + !#zh 数组转矩阵 + !#en Transfer matrix array + @param ofs 数组起始偏移量 + */ + static fromArray (out: Out, arr: IWritableArrayLike, ofs?: number): Out; + /** !#en Matrix Data + !#zh 矩阵数据 */ + m: Float64Array|Float32Array; + /** + !#en + Constructor + see {{#crossLink "cc/mat4:method"}}cc.mat4{{/crossLink}} + !#zh + 构造函数,可查看 {{#crossLink "cc/mat4:method"}}cc.mat4{{/crossLink}} + */ + constructor ( m00?: number, m01?: number, m02?: number, m03?: number, m10?: number, m11?: number, m12?: number, m13?: number, m20?: number, m21?: number, m22?: number, m23?: number, m30?: number, m31?: number, m32?: number, m33?: number); + /** + !#en clone a Mat4 object + !#zh 克隆一个 Mat4 对象 + */ + clone(): Mat4; + /** + !#en Sets the matrix with another one's value + !#zh 用另一个矩阵设置这个矩阵的值。 + @param srcObj srcObj + */ + set(srcObj: Mat4): Mat4; + /** + !#en Check whether two matrix equal + !#zh 当前的矩阵是否与指定的矩阵相等。 + @param other other + */ + equals(other: Mat4): boolean; + /** + !#en Check whether two matrix equal with default degree of variance. + !#zh + 近似判断两个矩阵是否相等。
+ 判断 2 个矩阵是否在默认误差范围之内,如果在则返回 true,反之则返回 false。 + @param other other + */ + fuzzyEquals(other: Mat4): boolean; + /** + !#en Transform to string with matrix informations + !#zh 转换为方便阅读的字符串。 + */ + toString(): string; + /** + Set the matrix to the identity matrix + */ + identity(): Mat4; + /** + Transpose the values of a mat4 + @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created. + */ + transpose(out?: Mat4): Mat4; + /** + Inverts a mat4 + @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created. + */ + invert(out?: Mat4): Mat4; + /** + Calculates the adjugate of a mat4 + @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created. + */ + adjoint(out?: Mat4): Mat4; + /** + Calculates the determinant of a mat4 + */ + determinant(): number; + /** + Adds two Mat4 + @param other the second operand + @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created. + */ + add(other: Mat4, out?: Mat4): Mat4; + /** + Subtracts the current matrix with another one + @param other the second operand + */ + subtract(other: Mat4): Mat4; + /** + Subtracts the current matrix with another one + @param other the second operand + */ + multiply(other: Mat4): Mat4; + /** + Multiply each element of the matrix by a scalar. + @param number amount to scale the matrix's elements by + */ + multiplyScalar(number: number): Mat4; + /** + Translate a mat4 by the given vector + @param v vector to translate by + @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created + */ + translate(v: Vec3, out?: Mat4): Mat4; + /** + Scales the mat4 by the dimensions in the given vec3 + @param v vector to scale by + @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created + */ + scale(v: Vec3, out?: Mat4): Mat4; + /** + Rotates a mat4 by the given angle around the given axis + @param rad the angle to rotate the matrix by + @param axis the axis to rotate around + @param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created + */ + rotate(rad: number, axis: Vec3, out?: Mat4): Mat4; + /** + Returns the translation vector component of a transformation matrix. + @param out Vector to receive translation component, if not provided, a new vec3 will be created + */ + getTranslation(out: Vec3): Vec3; + /** + Returns the scale factor component of a transformation matrix + @param out Vector to receive scale component, if not provided, a new vec3 will be created + */ + getScale(out: Vec3): Vec3; + /** + Returns the rotation factor component of a transformation matrix + @param out Vector to receive rotation component, if not provided, a new quaternion object will be created + */ + getRotation(out: Quat): Quat; + /** + Restore the matrix values from a quaternion rotation, vector translation and vector scale + @param q Rotation quaternion + @param v Translation vector + @param s Scaling vector + */ + fromRTS(q: Quat, v: Vec3, s: Vec3): Mat4; + /** + Restore the matrix values from a quaternion rotation + @param q Rotation quaternion + */ + fromQuat(q: Quat): Mat4; + } + /** !#en Representation of 2D vectors and points. + !#zh 表示 2D 向量和坐标 */ + export class Quat extends ValueType { + /** + !#en + Constructor + see {{#crossLink "cc/quat:method"}}cc.quat{{/crossLink}} + !#zh + 构造函数,可查看 {{#crossLink "cc/quat:method"}}cc.quat{{/crossLink}} + @param x x + @param y y + @param z z + @param w w + */ + constructor(x?: number, y?: number, z?: number, w?: number); + /** + !#en Calculate the multiply result between this quaternion and another one + !#zh 计算四元数乘积的结果 + @param other other + @param out out + */ + mul(other: Quat, out?: Quat): Quat; + /** + !#zh 获得指定四元数的拷贝 + !#en Obtaining copy specified quaternion + */ + static clone (a: Out): Quat; + /** + !#zh 复制目标四元数 + !#en Copy quaternion target + */ + static copy (out: Out, a: QuatLike): Out; + /** + !#zh 设置四元数值 + !#en Provided Quaternion Value + */ + static set (out: Out, x: number, y: number, z: number, w: number): Out; + /** + !#zh 将目标赋值为单位四元数 + !#en The target of an assignment as a unit quaternion + */ + static identity (out: Out): Out; + /** + !#zh 设置四元数为两向量间的最短路径旋转,默认两向量都已归一化 + !#en Set quaternion rotation is the shortest path between two vectors, the default two vectors are normalized + */ + static rotationTo (out: Out, a: VecLike, b: VecLike): Out; + /** + !#zh 获取四元数的旋转轴和旋转弧度 + !#en Get the rotary shaft and the arc of rotation quaternion + @param outAxis 旋转轴输出 + @param q 源四元数 + */ + static getAxisAngle (outAxis: VecLike, q: Out): number; + /** + !#zh 四元数乘法 + !#en Quaternion multiplication + */ + static multiply (out: Out, a: QuatLike_1, b: QuatLike_2): Out; + /** + !#zh 四元数标量乘法 + !#en Quaternion scalar multiplication + */ + static multiplyScalar (out: Out, a: Out, b: number): Out; + /** + !#zh 四元数乘加:A + B * scale + !#en Quaternion multiplication and addition: A + B * scale + */ + static scaleAndAdd (out: Out, a: Out, b: Out, scale: number): Out; + /** + !#zh 绕 X 轴旋转指定四元数 + !#en About the X axis specified quaternion + @param rad 旋转弧度 + */ + static rotateX (out: Out, a: Out, rad: number): Out; + /** + !#zh 绕 Y 轴旋转指定四元数 + !#en Rotation about the Y axis designated quaternion + @param rad 旋转弧度 + */ + static rotateY (out: Out, a: Out, rad: number): Out; + /** + !#zh 绕 Z 轴旋转指定四元数 + !#en Around the Z axis specified quaternion + @param rad 旋转弧度 + */ + static rotateZ (out: Out, a: Out, rad: number): Out; + /** + !#zh 绕世界空间下指定轴旋转四元数 + !#en Space around the world at a given axis of rotation quaternion + @param axis 旋转轴,默认已归一化 + @param rad 旋转弧度 + */ + static rotateAround (out: Out, rot: Out, axis: VecLike, rad: number): Out; + /** + !#zh 绕本地空间下指定轴旋转四元数 + !#en Local space around the specified axis rotation quaternion + @param axis 旋转轴 + @param rad 旋转弧度 + */ + static rotateAroundLocal (out: Out, rot: Out, axis: VecLike, rad: number): Out; + /** + !#zh 根据 xyz 分量计算 w 分量,默认已归一化 + !#en The component w xyz components calculated, normalized by default + */ + static calculateW (out: Out, a: Out): Out; + /** + !#zh 四元数点积(数量积) + !#en Quaternion dot product (scalar product) + */ + static dot (a: Out, b: Out): number; + /** + !#zh 逐元素线性插值: A + t * (B - A) + !#en Element by element linear interpolation: A + t * (B - A) + */ + static lerp (out: Out, a: Out, b: Out, t: number): Out; + /** + !#zh 四元数球面插值 + !#en Spherical quaternion interpolation + */ + static slerp(out: Out, a: QuatLike_1, b: QuatLike_2, t: number): Out; + /** + !#zh 带两个控制点的四元数球面插值 + !#en Quaternion with two spherical interpolation control points + */ + static sqlerp (out: Out, a: Out, b: Out, c: Out, d: Out, t: number): Out; + /** + !#zh 四元数求逆 + !#en Quaternion inverse + */ + static invert (out: Out, a: QuatLike): Out; + /** + !#zh 求共轭四元数,对单位四元数与求逆等价,但更高效 + !#en Conjugating a quaternion, and the unit quaternion equivalent to inversion, but more efficient + */ + static conjugate (out: Out, a: Out): Out; + /** + !#zh 求四元数长度 + !#en Seek length quaternion + */ + static len (a: Out): number; + /** + !#zh 求四元数长度平方 + !#en Seeking quaternion square of the length + */ + static lengthSqr (a: Out): number; + /** + !#zh 归一化四元数 + !#en Normalized quaternions + */ + static normalize (out: Out, a: Out): Out; + /** + !#zh 根据本地坐标轴朝向计算四元数,默认三向量都已归一化且相互垂直 + !#en Calculated according to the local orientation quaternion coordinate axis, the default three vectors are normalized and mutually perpendicular + */ + static fromAxes (out: Out, xAxis: VecLike, yAxis: VecLike, zAxis: VecLike): Out; + /** + !#zh 根据视口的前方向和上方向计算四元数 + !#en The forward direction and the direction of the viewport computing quaternion + @param view 视口面向的前方向,必须归一化 + @param up 视口的上方向,必须归一化,默认为 (0, 1, 0) + */ + static fromViewUp (out: Out, view: Vec3, up?: Vec3): Out; + /** + !#zh 根据旋转轴和旋转弧度计算四元数 + !#en The quaternion calculated and the arc of rotation of the rotary shaft + */ + static fromAxisAngle (out: Out, axis: VecLike, rad: number): Out; + /** + !#zh 根据三维矩阵信息计算四元数,默认输入矩阵不含有缩放信息 + !#en Calculating the three-dimensional quaternion matrix information, default zoom information input matrix does not contain + */ + static fromMat3 (out: Out, mat: Mat3): Out; + /** + !#zh 根据欧拉角信息计算四元数,旋转顺序为 YZX + !#en The quaternion calculated Euler angle information, rotation order YZX + */ + static fromEuler (out: Out, x: number, y: number, z: number): Out; + /** + !#zh 返回定义此四元数的坐标系 X 轴向量 + !#en This returns the result of the quaternion coordinate system X-axis vector + */ + static toAxisX (out: VecLike, q: Out): VecLike; + /** + !#zh 返回定义此四元数的坐标系 Y 轴向量 + !#en This returns the result of the quaternion coordinate system Y axis vector + */ + static toAxisY (out: VecLike, q: Out): VecLike; + /** + !#zh 返回定义此四元数的坐标系 Z 轴向量 + !#en This returns the result of the quaternion coordinate system the Z-axis vector + */ + static toAxisZ (out: VecLike, q: Out): VecLike; + /** + !#zh 根据四元数计算欧拉角,返回角度 x, y 在 [-180, 180] 区间内, z 默认在 [-90, 90] 区间内,旋转顺序为 YZX + !#en The quaternion calculated Euler angles, return angle x, y in the [-180, 180] interval, z default the range [-90, 90] interval, the rotation order YZX + @param outerZ z 取值范围区间改为 [-180, -90] U [90, 180] + */ + static toEuler (out: Out, q: IQuatLike, outerZ?: boolean): Out; + /** + !#zh 四元数等价判断 + !#en Analyzing quaternion equivalent + */ + static strictEquals (a: Out, b: Out): boolean; + /** + !#zh 排除浮点数误差的四元数近似等价判断 + !#en Negative floating point error quaternion approximately equivalent Analyzing + */ + static equals (a: Out, b: Out, epsilon?: number): boolean; + /** + !#zh 四元数转数组 + !#en Quaternion rotation array + @param ofs 数组内的起始偏移量 + */ + static toArray > (out: Out, q: IQuatLike, ofs?: number): Out; + /** + !#zh 数组转四元数 + !#en Array to a quaternion + @param ofs 数组起始偏移量 + */ + static fromArray (out: Out, arr: IWritableArrayLike, ofs?: number): Out; + x: number; + y: number; + z: number; + w: number; + /** + !#en clone a Quat object and return the new object + !#zh 克隆一个四元数并返回 + */ + clone(): Quat; + /** + !#en Set values with another quaternion + !#zh 用另一个四元数的值设置到当前对象上。 + @param newValue !#en new value to set. !#zh 要设置的新值 + */ + set(newValue: Quat): Quat; + /** + !#en Check whether current quaternion equals another + !#zh 当前的四元数是否与指定的四元数相等。 + @param other other + */ + equals(other: Quat): boolean; + /** + !#en Convert quaternion to euler + !#zh 转换四元数到欧拉角 + @param out out + */ + toEuler(out: Vec3): Vec3; + /** + !#en Convert euler to quaternion + !#zh 转换欧拉角到四元数 + @param euler euler + */ + fromEuler(euler: Vec3): Quat; + /** + !#en Calculate the interpolation result between this quaternion and another one with given ratio + !#zh 计算四元数的插值结果 + @param to to + @param ratio ratio + @param out out + */ + lerp(to: Quat, ratio: number, out?: Quat): Quat; + /** + !#en Calculate the multiply result between this quaternion and another one + !#zh 计算四元数乘积的结果 + @param other other + */ + multiply(other: Quat): Quat; + /** + !#en Rotates a quaternion by the given angle (in radians) about a world space axis. + !#zh 围绕世界空间轴按给定弧度旋转四元数 + @param rot Quaternion to rotate + @param axis The axis around which to rotate in world space + @param rad Angle (in radians) to rotate + @param out Quaternion to store result + */ + rotateAround(rot: Quat, axis: Vec3, rad: number, out?: Quat): Quat; + } + /** !#en A 2D rectangle defined by x, y position and width, height. + !#zh 通过位置和宽高定义的 2D 矩形。 */ + export class Rect extends ValueType { + /** + !#en + Constructor of Rect class. + see {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} for convenience method. + !#zh + Rect类的构造函数。可以通过 {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} 简便方法进行创建。 + @param x x + @param y y + @param w w + @param h h + */ + constructor(x?: number, y?: number, w?: number, h?: number); + /** + !#en Creates a rectangle from two coordinate values. + !#zh 根据指定 2 个坐标创建出一个矩形区域。 + @param v1 v1 + @param v2 v2 + + @example + ```js + cc.Rect.fromMinMax(cc.v2(10, 10), cc.v2(20, 20)); // Rect {x: 10, y: 10, width: 10, height: 10}; + ``` + */ + static fromMinMax(v1: Vec2, v2: Vec2): Rect; + x: number; + y: number; + width: number; + height: number; + /** + !#en TODO + !#zh 克隆一个新的 Rect。 + + @example + ```js + var a = new cc.Rect(0, 0, 10, 10); + a.clone();// Rect {x: 0, y: 0, width: 10, height: 10} + ``` + */ + clone(): Rect; + /** + !#en TODO + !#zh 是否等于指定的矩形。 + @param other other + + @example + ```js + var a = new cc.Rect(0, 0, 10, 10); + var b = new cc.Rect(0, 0, 10, 10); + a.equals(b);// true; + ``` + */ + equals(other: Rect): boolean; + /** + !#en TODO + !#zh 线性插值 + @param to to + @param ratio the interpolation coefficient. + @param out optional, the receiving vector. + + @example + ```js + var a = new cc.Rect(0, 0, 10, 10); + var b = new cc.Rect(50, 50, 100, 100); + update (dt) { + // method 1; + var c = a.lerp(b, dt * 0.1); + // method 2; + a.lerp(b, dt * 0.1, c); + } + ``` + */ + lerp(to: Rect, ratio: number, out?: Rect): Rect; + /** + !#en Check whether the current rectangle intersects with the given one + !#zh 当前矩形与指定矩形是否相交。 + @param rect rect + + @example + ```js + var a = new cc.Rect(0, 0, 10, 10); + var b = new cc.Rect(0, 0, 20, 20); + a.intersects(b);// true + ``` + */ + intersects(rect: Rect): boolean; + /** + !#en Returns the overlapping portion of 2 rectangles. + !#zh 返回 2 个矩形重叠的部分。 + @param out Stores the result + @param rectB rectB + + @example + ```js + var a = new cc.Rect(0, 10, 20, 20); + var b = new cc.Rect(0, 10, 10, 10); + var intersection = new cc.Rect(); + a.intersection(intersection, b); // intersection {x: 0, y: 10, width: 10, height: 10}; + ``` + */ + intersection(out: Rect, rectB: Rect): Rect; + /** + !#en Check whether the current rect contains the given point + !#zh 当前矩形是否包含指定坐标点。 + Returns true if the point inside this rectangle. + @param point point + + @example + ```js + var a = new cc.Rect(0, 0, 10, 10); + var b = new cc.Vec2(0, 5); + a.contains(b);// true + ``` + */ + contains(point: Vec2): boolean; + /** + !#en Returns true if the other rect totally inside this rectangle. + !#zh 当前矩形是否包含指定矩形。 + @param rect rect + + @example + ```js + var a = new cc.Rect(0, 0, 20, 20); + var b = new cc.Rect(0, 0, 10, 10); + a.containsRect(b);// true + ``` + */ + containsRect(rect: Rect): boolean; + /** + !#en Returns the smallest rectangle that contains the current rect and the given rect. + !#zh 返回一个包含当前矩形和指定矩形的最小矩形。 + @param out Stores the result + @param rectB rectB + + @example + ```js + var a = new cc.Rect(0, 10, 20, 20); + var b = new cc.Rect(0, 10, 10, 10); + var union = new cc.Rect(); + a.union(union, b); // union {x: 0, y: 10, width: 20, height: 20}; + ``` + */ + union(out: Rect, rectB: Rect): Rect; + /** + !#en Apply matrix4 to the rect. + !#zh 使用 mat4 对矩形进行矩阵转换。 + @param out The output rect + @param mat The matrix4 + */ + transformMat4(out: Rect, mat: Mat4): void; + /** + !#en Output rect informations to string + !#zh 转换为方便阅读的字符串 + + @example + ```js + var a = new cc.Rect(0, 0, 10, 10); + a.toString();// "(0.00, 0.00, 10.00, 10.00)"; + ``` + */ + toString(): string; + /** !#en The minimum x value, equals to rect.x + !#zh 矩形 x 轴上的最小值,等价于 rect.x。 */ + xMin: number; + /** !#en The minimum y value, equals to rect.y + !#zh 矩形 y 轴上的最小值。 */ + yMin: number; + /** !#en The maximum x value. + !#zh 矩形 x 轴上的最大值。 */ + xMax: number; + /** !#en The maximum y value. + !#zh 矩形 y 轴上的最大值。 */ + yMax: number; + /** !#en The position of the center of the rectangle. + !#zh 矩形的中心点。 */ + center: Vec2; + /** !#en The X and Y position of the rectangle. + !#zh 矩形的 x 和 y 坐标。 */ + origin: Vec2; + /** !#en Width and height of the rectangle. + !#zh 矩形的大小。 */ + size: Size; + } + /** !#en + cc.Size is the class for size object,
+ please do not use its constructor to create sizes,
+ use {{#crossLink "cc/size:method"}}{{/crossLink}} alias function instead.
+ It will be deprecated soon, please use cc.Vec2 instead. + + !#zh + cc.Size 是 size 对象的类。
+ 请不要使用它的构造函数创建的 size,
+ 使用 {{#crossLink "cc/size:method"}}{{/crossLink}} 别名函数。
+ 它不久将被取消,请使用cc.Vec2代替。 */ + export class Size { + /** + + @param width width + @param height height + */ + constructor(width: number|Size, height?: number); + /** !#en return a Size object with width = 0 and height = 0. + !#zh 返回一个宽度为 0 和高度为 0 的 Size 对象。 */ + static ZERO: Size; + width: number; + height: number; + /** + !#en TODO + !#zh 克隆 size 对象。 + + @example + ```js + var a = new cc.size(10, 10); + a.clone();// return Size {width: 0, height: 0}; + ``` + */ + clone(): Size; + /** + !#en TODO + !#zh 当前 Size 对象是否等于指定 Size 对象。 + @param other other + + @example + ```js + var a = new cc.size(10, 10); + a.equals(new cc.size(10, 10));// return true; + ``` + */ + equals(other: Size): boolean; + /** + !#en TODO + !#zh 线性插值。 + @param to to + @param ratio the interpolation coefficient. + @param out optional, the receiving vector. + + @example + ```js + var a = new cc.size(10, 10); + var b = new cc.rect(50, 50, 100, 100); + update (dt) { + // method 1; + var c = a.lerp(b, dt * 0.1); + // method 2; + a.lerp(b, dt * 0.1, c); + } + ``` + */ + lerp(to: Rect, ratio: number, out?: Size): Size; + /** + !#en TODO + !#zh 转换为方便阅读的字符串。 + + @example + ```js + var a = new cc.size(10, 10); + a.toString();// return "(10.00, 10.00)"; + ``` + */ + toString(): string; + } + /** !#en The base class of all value types. + !#zh 所有值类型的基类。 */ + export class ValueType { + /** + !#en This method returns an exact copy of current value. + !#zh 克隆当前值,该方法返回一个新对象,新对象的值和原对象相等。 + */ + clone(): ValueType; + /** + !#en Compares this object with the other one. + !#zh 当前对象是否等于指定对象。 + @param other other + */ + equals(other: ValueType): boolean; + /** + !#en + Linearly interpolates between this value to to value by ratio which is in the range [0, 1]. + When ratio = 0 returns this. When ratio = 1 return to. When ratio = 0.5 returns the average of this and to. + !#zh + 线性插值。
+ 当 ratio = 0 时返回自身,ratio = 1 时返回目标,ratio = 0.5 返回自身和目标的平均值。。 + @param to the to value + @param ratio the interpolation coefficient + */ + lerp(to: ValueType, ratio: number): ValueType; + /** + !#en + Copys all the properties from another given object to this value. + !#zh + 从其它对象把所有属性复制到当前对象。 + @param source the source to copy + */ + set(source: ValueType): void; + /** + !#en Convert to a readable string. + !#zh 转换为方便阅读的字符串。 + */ + toString(): string; + } + /** !#en Representation of 2D vectors and points. + !#zh 表示 2D 向量和坐标 */ + export class Vec2 extends ValueType { + /** + !#en Returns the length of this vector. + !#zh 返回该向量的长度。 + + @example + ```js + var v = cc.v2(10, 10); + v.mag(); // return 14.142135623730951; + ``` + */ + mag(): number; + /** + !#en Returns the squared length of this vector. + !#zh 返回该向量的长度平方。 + + @example + ```js + var v = cc.v2(10, 10); + v.magSqr(); // return 200; + ``` + */ + magSqr(): number; + /** + !#en Subtracts one vector from this. If you want to save result to another vector, use sub() instead. + !#zh 向量减法。如果你想保存结果到另一个向量,可使用 sub() 代替。 + @param vector vector + + @example + ```js + var v = cc.v2(10, 10); + v.subSelf(cc.v2(5, 5));// return Vec2 {x: 5, y: 5}; + ``` + */ + subSelf(vector: Vec2): Vec2; + /** + !#en Subtracts one vector from this, and returns the new result. + !#zh 向量减法,并返回新结果。 + @param vector vector + @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created + + @example + ```js + var v = cc.v2(10, 10); + v.sub(cc.v2(5, 5)); // return Vec2 {x: 5, y: 5}; + var v1 = new Vec2; + v.sub(cc.v2(5, 5), v1); // return Vec2 {x: 5, y: 5}; + ``` + */ + sub(vector: Vec2, out?: Vec2): Vec2; + /** + !#en Multiplies this by a number. If you want to save result to another vector, use mul() instead. + !#zh 缩放当前向量。如果你想结果保存到另一个向量,可使用 mul() 代替。 + @param num num + + @example + ```js + var v = cc.v2(10, 10); + v.mulSelf(5);// return Vec2 {x: 50, y: 50}; + ``` + */ + mulSelf(num: number): Vec2; + /** + !#en Multiplies by a number, and returns the new result. + !#zh 缩放向量,并返回新结果。 + @param num num + @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created + + @example + ```js + var v = cc.v2(10, 10); + v.mul(5); // return Vec2 {x: 50, y: 50}; + var v1 = new Vec2; + v.mul(5, v1); // return Vec2 {x: 50, y: 50}; + ``` + */ + mul(num: number, out?: Vec2): Vec2; + /** + !#en Divides by a number. If you want to save result to another vector, use div() instead. + !#zh 向量除法。如果你想结果保存到另一个向量,可使用 div() 代替。 + @param num num + + @example + ```js + var v = cc.v2(10, 10); + v.divSelf(5); // return Vec2 {x: 2, y: 2}; + ``` + */ + divSelf(num: number): Vec2; + /** + !#en Divides by a number, and returns the new result. + !#zh 向量除法,并返回新的结果。 + @param num num + @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created + + @example + ```js + var v = cc.v2(10, 10); + v.div(5); // return Vec2 {x: 2, y: 2}; + var v1 = new Vec2; + v.div(5, v1); // return Vec2 {x: 2, y: 2}; + ``` + */ + div(num: number, out?: Vec2): Vec2; + /** + !#en Multiplies two vectors. + !#zh 分量相乘。 + @param vector vector + + @example + ```js + var v = cc.v2(10, 10); + v.scaleSelf(cc.v2(5, 5));// return Vec2 {x: 50, y: 50}; + ``` + */ + scaleSelf(vector: Vec2): Vec2; + /** + !#en Multiplies two vectors, and returns the new result. + !#zh 分量相乘,并返回新的结果。 + @param vector vector + @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created + + @example + ```js + var v = cc.v2(10, 10); + v.scale(cc.v2(5, 5)); // return Vec2 {x: 50, y: 50}; + var v1 = new Vec2; + v.scale(cc.v2(5, 5), v1); // return Vec2 {x: 50, y: 50}; + ``` + */ + scale(vector: Vec2, out?: Vec2): Vec2; + /** + !#en Negates the components. If you want to save result to another vector, use neg() instead. + !#zh 向量取反。如果你想结果保存到另一个向量,可使用 neg() 代替。 + + @example + ```js + var v = cc.v2(10, 10); + v.negSelf(); // return Vec2 {x: -10, y: -10}; + ``` + */ + negSelf(): Vec2; + /** + !#en Negates the components, and returns the new result. + !#zh 返回取反后的新向量。 + @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created + + @example + ```js + var v = cc.v2(10, 10); + var v1 = new Vec2; + v.neg(v1); // return Vec2 {x: -10, y: -10}; + ``` + */ + neg(out?: Vec2): Vec2; + /** !#en return a Vec2 object with x = 1 and y = 1. + !#zh 新 Vec2 对象。 */ + static ONE: Vec2; + /** !#en return a Vec2 object with x = 0 and y = 0. + !#zh 返回 x = 0 和 y = 0 的 Vec2 对象。 */ + static ZERO: Vec2; + /** !#en return a readonly Vec2 object with x = 0 and y = 0. + !#zh 返回一个 x = 0 和 y = 0 的 Vec2 只读对象。 */ + static ZERO_R: Vec2; + /** !#en return a Vec2 object with x = 0 and y = 1. + !#zh 返回 x = 0 和 y = 1 的 Vec2 对象。 */ + static UP: Vec2; + /** !#en return a readonly Vec2 object with x = 0 and y = 1. + !#zh 返回 x = 0 和 y = 1 的 Vec2 只读对象。 */ + static UP_R: Vec2; + /** !#en return a readonly Vec2 object with x = 1 and y = 0. + !#zh 返回 x = 1 和 y = 0 的 Vec2 只读对象。 */ + static RIGHT: Vec2; + /** !#en return a Vec2 object with x = 1 and y = 0. + !#zh 返回 x = 1 和 y = 0 的 Vec2 对象。 */ + static RIGHT_R: Vec2; + /** + !#zh 获得指定向量的拷贝 + */ + static clone (a: Out): Vec2; + /** + !#zh 复制指定向量的值 + */ + static copy (out: Out, a: Out): Out; + /** + !#zh 设置向量值 + */ + static set (out: Out, x: number, y: number): Out; + /** + !#zh 逐元素向量加法 + */ + static add (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量减法 + */ + static subtract (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量乘法 + */ + static multiply (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量除法 + */ + static divide (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量向上取整 + */ + static ceil (out: Out, a: Out): Out; + /** + !#zh 逐元素向量向下取整 + */ + static floor (out: Out, a: Out): Out; + /** + !#zh 逐元素向量最小值 + */ + static min (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量最大值 + */ + static max (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量四舍五入取整 + */ + static round (out: Out, a: Out): Out; + /** + !#zh 向量标量乘法 + */ + static multiplyScalar (out: Out, a: Out, b: number): Out; + /** + !#zh 逐元素向量乘加: A + B * scale + */ + static scaleAndAdd (out: Out, a: Out, b: Out, scale: number): Out; + /** + !#zh 求两向量的欧氏距离 + */ + static distance (a: Out, b: Out): number; + /** + !#zh 求两向量的欧氏距离平方 + */ + static squaredDistance (a: Out, b: Out): number; + /** + !#zh 求向量长度 + */ + static len (a: Out): number; + /** + !#zh 求向量长度平方 + */ + static lengthSqr (a: Out): number; + /** + !#zh 逐元素向量取负 + */ + static negate (out: Out, a: Out): Out; + /** + !#zh 逐元素向量取倒数,接近 0 时返回 Infinity + */ + static inverse (out: Out, a: Out): Out; + /** + !#zh 逐元素向量取倒数,接近 0 时返回 0 + */ + static inverseSafe (out: Out, a: Out): Out; + /** + !#zh 归一化向量 + */ + static normalize (out: Out, a: Vec2Like): Out; + /** + !#zh 向量点积(数量积) + */ + static dot (a: Out, b: Out): number; + /** + !#zh 向量叉积(向量积),注意二维向量的叉积为与 Z 轴平行的三维向量 + */ + static cross (out: Vec2, a: Out, b: Out): Vec2; + /** + !#zh 逐元素向量线性插值: A + t * (B - A) + */ + static lerp (out: Out, a: Out, b: Out, t: number): Out; + /** + !#zh 生成一个在单位圆上均匀分布的随机向量 + */ + static random (out: Out, scale?: number): Out; + /** + !#zh 向量与三维矩阵乘法,默认向量第三位为 1。 + */ + static transformMat3 (out: Out, a: Out, mat: IMat3Like): Out; + /** + !#zh 向量与四维矩阵乘法,默认向量第三位为 0,第四位为 1。 + */ + static transformMat4 (out: Out, a: Out, mat: MatLike): Out; + /** + !#zh 向量等价判断 + */ + static strictEquals (a: Out, b: Out): boolean; + /** + !#zh 排除浮点数误差的向量近似等价判断 + */ + static equals (a: Out, b: Out, epsilon?: number): boolean; + /** + !#zh 排除浮点数误差的向量近似等价判断 + */ + static angle (a: Out, b: Out): number; + /** + !#zh 向量转数组 + */ + static toArray > (out: Out, v: IVec2Like, ofs?: number): Out; + /** + !#zh 数组转向量 + */ + static fromArray (out: Out, arr: IWritableArrayLike, ofs?: number): Out; + x: number; + y: number; + /** + !#en + Constructor + see {{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} or {{#crossLink "cc/p:method"}}cc.p{{/crossLink}} + !#zh + 构造函数,可查看 {{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} 或者 {{#crossLink "cc/p:method"}}cc.p{{/crossLink}} + @param x x + @param y y + */ + constructor(x?: number, y?: number); + /** + !#en clone a Vec2 object + !#zh 克隆一个 Vec2 对象 + */ + clone(): Vec2; + /** + !#en Sets vector with another's value + !#zh 设置向量值。 + @param newValue !#en new value to set. !#zh 要设置的新值 + */ + set(newValue: Vec2): Vec2; + /** + !#en Check whether two vector equal + !#zh 当前的向量是否与指定的向量相等。 + @param other other + */ + equals(other: Vec2): boolean; + /** + !#en Check whether two vector equal with some degree of variance. + !#zh + 近似判断两个点是否相等。
+ 判断 2 个向量是否在指定数值的范围之内,如果在则返回 true,反之则返回 false。 + @param other other + @param variance variance + */ + fuzzyEquals(other: Vec2, variance: number): boolean; + /** + !#en Transform to string with vector informations + !#zh 转换为方便阅读的字符串。 + */ + toString(): string; + /** + !#en Calculate linear interpolation result between this vector and another one with given ratio + !#zh 线性插值。 + @param to to + @param ratio the interpolation coefficient + @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created + */ + lerp(to: Vec2, ratio: number, out?: Vec2): Vec2; + /** + !#en Clamp the vector between from float and to float. + !#zh + 返回指定限制区域后的向量。
+ 向量大于 max_inclusive 则返回 max_inclusive。
+ 向量小于 min_inclusive 则返回 min_inclusive。
+ 否则返回自身。 + @param min_inclusive min_inclusive + @param max_inclusive max_inclusive + + @example + ```js + var min_inclusive = cc.v2(0, 0); + var max_inclusive = cc.v2(20, 20); + var v1 = cc.v2(20, 20).clampf(min_inclusive, max_inclusive); // Vec2 {x: 20, y: 20}; + var v2 = cc.v2(0, 0).clampf(min_inclusive, max_inclusive); // Vec2 {x: 0, y: 0}; + var v3 = cc.v2(10, 10).clampf(min_inclusive, max_inclusive); // Vec2 {x: 10, y: 10}; + ``` + */ + clampf(min_inclusive: Vec2, max_inclusive: Vec2): Vec2; + /** + !#en Adds this vector. + !#zh 向量加法。 + @param vector vector + @param out out + + @example + ```js + var v = cc.v2(10, 10); + v.add(cc.v2(5, 5));// return Vec2 {x: 15, y: 15}; + ``` + */ + add(vector: Vec2, out?: Vec2): Vec2; + /** + !#en Adds this vector. If you want to save result to another vector, use add() instead. + !#zh 向量加法。如果你想保存结果到另一个向量,使用 add() 代替。 + @param vector vector + */ + addSelf(vector: Vec2): Vec2; + /** + !#en Subtracts one vector from this. + !#zh 向量减法。 + @param vector vector + + @example + ```js + var v = cc.v2(10, 10); + v.subSelf(cc.v2(5, 5));// return Vec2 {x: 5, y: 5}; + ``` + */ + subtract(vector: Vec2): Vec2; + /** + !#en Multiplies this by a number. + !#zh 缩放当前向量。 + @param num num + + @example + ```js + var v = cc.v2(10, 10); + v.multiply(5);// return Vec2 {x: 50, y: 50}; + ``` + */ + multiplyScalar(num: number): Vec2; + /** + !#en Multiplies two vectors. + !#zh 分量相乘。 + @param vector vector + + @example + ```js + var v = cc.v2(10, 10); + v.multiply(cc.v2(5, 5));// return Vec2 {x: 50, y: 50}; + ``` + */ + multiply(vector: Vec2): Vec2; + /** + !#en Divides by a number. + !#zh 向量除法。 + @param num num + + @example + ```js + var v = cc.v2(10, 10); + v.divide(5); // return Vec2 {x: 2, y: 2}; + ``` + */ + divide(num: number): Vec2; + /** + !#en Negates the components. + !#zh 向量取反。 + + @example + ```js + var v = cc.v2(10, 10); + v.negate(); // return Vec2 {x: -10, y: -10}; + ``` + */ + negate(): Vec2; + /** + !#en Dot product + !#zh 当前向量与指定向量进行点乘。 + @param vector vector + + @example + ```js + var v = cc.v2(10, 10); + v.dot(cc.v2(5, 5)); // return 100; + ``` + */ + dot(vector?: Vec2): number; + /** + !#en Cross product + !#zh 当前向量与指定向量进行叉乘。 + @param vector vector + + @example + ```js + var v = cc.v2(10, 10); + v.cross(cc.v2(5, 5)); // return 0; + ``` + */ + cross(vector?: Vec2): number; + /** + !#en Returns the length of this vector. + !#zh 返回该向量的长度。 + + @example + ```js + var v = cc.v2(10, 10); + v.len(); // return 14.142135623730951; + ``` + */ + len(): number; + /** + !#en Returns the squared length of this vector. + !#zh 返回该向量的长度平方。 + + @example + ```js + var v = cc.v2(10, 10); + v.lengthSqr(); // return 200; + ``` + */ + lengthSqr(): number; + /** + !#en Make the length of this vector to 1. + !#zh 向量归一化,让这个向量的长度为 1。 + + @example + ```js + var v = cc.v2(10, 10); + v.normalizeSelf(); // return Vec2 {x: 0.7071067811865475, y: 0.7071067811865475}; + ``` + */ + normalizeSelf(): Vec2; + /** + !#en + Returns this vector with a magnitude of 1.
+
+ Note that the current vector is unchanged and a new normalized vector is returned. If you want to normalize the current vector, use normalizeSelf function. + !#zh + 返回归一化后的向量。
+
+ 注意,当前向量不变,并返回一个新的归一化向量。如果你想来归一化当前向量,可使用 normalizeSelf 函数。 + @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created + */ + normalize(out?: Vec2): Vec2; + /** + !#en Get angle in radian between this and vector. + !#zh 夹角的弧度。 + @param vector vector + */ + angle(vector: Vec2): number; + /** + !#en Get angle in radian between this and vector with direction. + !#zh 带方向的夹角的弧度。 + @param vector vector + */ + signAngle(vector: Vec2): number; + /** + !#en rotate + !#zh 返回旋转给定弧度后的新向量。 + @param radians radians + @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created + */ + rotate(radians: number, out?: Vec2): Vec2; + /** + !#en rotate self + !#zh 按指定弧度旋转向量。 + @param radians radians + */ + rotateSelf(radians: number): Vec2; + /** + !#en Calculates the projection of the current vector over the given vector. + !#zh 返回当前向量在指定 vector 向量上的投影向量。 + @param vector vector + + @example + ```js + var v1 = cc.v2(20, 20); + var v2 = cc.v2(5, 5); + v1.project(v2); // Vec2 {x: 20, y: 20}; + ``` + */ + project(vector: Vec2): Vec2; + /** + Transforms the vec2 with a mat4. 3rd vector component is implicitly '0', 4th vector component is implicitly '1' + @param m matrix to transform with + @param out the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created + */ + transformMat4(m: Mat4, out?: Vec2): Vec2; + /** + Returns the maximum value in x, y. + */ + maxAxis(): number; + } + /** !#en Representation of 3D vectors and points. + !#zh 表示 3D 向量和坐标 */ + export class Vec3 extends ValueType { + /** + !#en Returns the length of this vector. + !#zh 返回该向量的长度。 + + @example + ```js + var v = cc.v3(10, 10, 10); + v.mag(); // return 17.320508075688775; + ``` + */ + mag(): number; + /** + !#en Returns the squared length of this vector. + !#zh 返回该向量的长度平方。 + */ + magSqr(): number; + /** + !#en Subtracts one vector from this. If you want to save result to another vector, use sub() instead. + !#zh 向量减法。如果你想保存结果到另一个向量,可使用 sub() 代替。 + @param vector vector + */ + subSelf(vector: Vec3): Vec3; + /** + !#en Subtracts one vector from this, and returns the new result. + !#zh 向量减法,并返回新结果。 + @param vector vector + @param out optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created + */ + sub(vector: Vec3, out?: Vec3): Vec3; + /** + !#en Multiplies this by a number. If you want to save result to another vector, use mul() instead. + !#zh 缩放当前向量。如果你想结果保存到另一个向量,可使用 mul() 代替。 + @param num num + */ + mulSelf(num: number): Vec3; + /** + !#en Multiplies by a number, and returns the new result. + !#zh 缩放向量,并返回新结果。 + @param num num + @param out optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created + */ + mul(num: number, out?: Vec3): Vec3; + /** + !#en Divides by a number. If you want to save result to another vector, use div() instead. + !#zh 向量除法。如果你想结果保存到另一个向量,可使用 div() 代替。 + @param num num + */ + divSelf(num: number): Vec3; + /** + !#en Divides by a number, and returns the new result. + !#zh 向量除法,并返回新的结果。 + @param num num + @param out optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created + */ + div(num: number, out?: Vec3): Vec3; + /** + !#en Multiplies two vectors. + !#zh 分量相乘。 + @param vector vector + */ + scaleSelf(vector: Vec3): Vec3; + /** + !#en Multiplies two vectors, and returns the new result. + !#zh 分量相乘,并返回新的结果。 + @param vector vector + @param out optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created + */ + scale(vector: Vec3, out?: Vec3): Vec3; + /** + !#en Negates the components. If you want to save result to another vector, use neg() instead. + !#zh 向量取反。如果你想结果保存到另一个向量,可使用 neg() 代替。 + */ + negSelf(): Vec3; + /** + !#en Negates the components, and returns the new result. + !#zh 返回取反后的新向量。 + @param out optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created + */ + neg(out?: Vec3): Vec3; + /** !#en return a Vec3 object with x = 1, y = 1, z = 1. + !#zh 新 Vec3 对象。 */ + static ONE: Vec3; + /** !#en return a Vec3 object with x = 0, y = 0, z = 0. + !#zh 返回 x = 0,y = 0,z = 0 的 Vec3 对象。 */ + static ZERO: Vec3; + /** !#en return a Vec3 object with x = 0, y = 1, z = 0. + !#zh 返回 x = 0, y = 1, z = 0 的 Vec3 对象。 */ + static UP: Vec3; + /** !#en return a Vec3 object with x = 1, y = 0, z = 0. + !#zh 返回 x = 1,y = 0,z = 0 的 Vec3 对象。 */ + static RIGHT: Vec3; + /** !#en return a Vec3 object with x = 0, y = 0, z = 1. + !#zh 返回 x = 0,y = 0,z = 1 的 Vec3 对象。 */ + static FORWARD: Vec3; + /** + !#zh 将目标赋值为零向量 + !#en The target of an assignment zero vector + */ + static zero (out: Out): Out; + /** + !#zh 获得指定向量的拷贝 + !#en Obtaining copy vectors designated + */ + static clone (a: Out): Vec3; + /** + !#zh 复制目标向量 + !#en Copy the target vector + */ + static copy (out: Out, a: Vec3Like): Out; + /** + !#zh 设置向量值 + !#en Set to value + */ + static set (out: Out, x: number, y: number, z: number): Out; + /** + !#zh 逐元素向量加法 + !#en Element-wise vector addition + */ + static add (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量减法 + !#en Element-wise vector subtraction + */ + static subtract (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量乘法 (分量积) + !#en Element-wise vector multiplication (product component) + */ + static multiply (out: Out, a: Vec3Like_1, b: Vec3Like_2): Out; + /** + !#zh 逐元素向量除法 + !#en Element-wise vector division + */ + static divide (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量向上取整 + !#en Rounding up by elements of the vector + */ + static ceil (out: Out, a: Out): Out; + /** + !#zh 逐元素向量向下取整 + !#en Element vector by rounding down + */ + static floor (out: Out, a: Out): Out; + /** + !#zh 逐元素向量最小值 + !#en The minimum by-element vector + */ + static min (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量最大值 + !#en The maximum value of the element-wise vector + */ + static max (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量四舍五入取整 + !#en Element-wise vector of rounding to whole + */ + static round (out: Out, a: Out): Out; + /** + !#zh 向量标量乘法 + !#en Vector scalar multiplication + */ + static multiplyScalar (out: Out, a: Vec3Like, b: number): Out; + /** + !#zh 逐元素向量乘加: A + B * scale + !#en Element-wise vector multiply add: A + B * scale + */ + static scaleAndAdd (out: Out, a: Out, b: Out, scale: number): Out; + /** + !#zh 求两向量的欧氏距离 + !#en Seeking two vectors Euclidean distance + */ + static distance (a: Out, b: Out): number; + /** + !#zh 求两向量的欧氏距离平方 + !#en Euclidean distance squared seeking two vectors + */ + static squaredDistance (a: Out, b: Out): number; + /** + !#zh 求向量长度 + !#en Seeking vector length + */ + static len (a: Out): number; + /** + !#zh 求向量长度平方 + !#en Seeking squared vector length + */ + static lengthSqr (a: Out): number; + /** + !#zh 逐元素向量取负 + !#en By taking the negative elements of the vector + */ + static negate (out: Out, a: Out): Out; + /** + !#zh 逐元素向量取倒数,接近 0 时返回 Infinity + !#en Element vector by taking the inverse, return near 0 Infinity + */ + static inverse (out: Out, a: Out): Out; + /** + !#zh 逐元素向量取倒数,接近 0 时返回 0 + !#en Element vector by taking the inverse, return near 0 0 + */ + static inverseSafe (out: Out, a: Out): Out; + /** + !#zh 归一化向量 + !#en Normalized vector + */ + static normalize (out: Out, a: Vec3Like): Out; + /** + !#zh 向量点积(数量积) + !#en Vector dot product (scalar product) + */ + static dot (a: Out, b: Out): number; + /** + !#zh 向量叉积(向量积) + !#en Vector cross product (vector product) + */ + static cross (out: Out, a: Vec3Like_1, b: Vec3Like_2): Out; + /** + !#zh 逐元素向量线性插值: A + t * (B - A) + !#en Vector element by element linear interpolation: A + t * (B - A) + */ + static lerp (out: Out, a: Out, b: Out, t: number): Out; + /** + !#zh 生成一个在单位球体上均匀分布的随机向量 + !#en Generates a uniformly distributed random vectors on the unit sphere + @param scale 生成的向量长度 + */ + static random (out: Out, scale?: number): Out; + /** + !#zh 向量与四维矩阵乘法,默认向量第四位为 1。 + !#en Four-dimensional vector and matrix multiplication, the default vectors fourth one. + */ + static transformMat4 (out: Out, a: Vec3Like, mat: MatLike): Out; + /** + !#zh 向量与四维矩阵乘法,默认向量第四位为 0。 + !#en Four-dimensional vector and matrix multiplication, vector fourth default is 0. + */ + static transformMat4Normal (out: Out, a: Out, mat: MatLike): Out; + /** + !#zh 向量与三维矩阵乘法 + !#en Dimensional vector matrix multiplication + */ + static transformMat3 (out: Out, a: Out, mat: MatLike): Out; + /** + !#zh 向量仿射变换 + !#en Affine transformation vector + */ + static transformAffine(out: Out, v: VecLike, mat: MatLike): Out; + /** + !#zh 向量四元数乘法 + !#en Vector quaternion multiplication + */ + static transformQuat (out: Out, a: VecLike, q: QuatLike): Out; + /** + !#zh 以缩放 -> 旋转 -> 平移顺序变换向量 + !#en To scale -> rotation -> transformation vector sequence translation + */ + static transformRTS(out: Out, a: VecLike, r: QuatLike, t: VecLike, s: VecLike): Out; + /** + !#zh 以平移 -> 旋转 -> 缩放顺序逆变换向量 + !#en Translational -> rotation -> Zoom inverse transformation vector sequence + */ + static transformInverseRTS(out: Out, a: VecLike, r: QuatLike, t: VecLike, s: VecLike): Out; + /** + !#zh 绕 X 轴旋转向量指定弧度 + !#en Rotation vector specified angle about the X axis + @param v 待旋转向量 + @param o 旋转中心 + @param a 旋转弧度 + */ + static rotateX (out: Out, v: Out, o: Out, a: number): Out; + /** + !#zh 绕 Y 轴旋转向量指定弧度 + !#en Rotation vector specified angle around the Y axis + @param v 待旋转向量 + @param o 旋转中心 + @param a 旋转弧度 + */ + static rotateY (out: Out, v: Out, o: Out, a: number): Out; + /** + !#zh 绕 Z 轴旋转向量指定弧度 + !#en Around the Z axis specified angle vector + @param v 待旋转向量 + @param o 旋转中心 + @param a 旋转弧度 + */ + static rotateZ (out: Out, v: Out, o: Out, a: number): Out; + /** + !#zh 向量等价判断 + !#en Equivalent vectors Analyzing + */ + static strictEquals (a: Out, b: Out): boolean; + /** + !#zh 排除浮点数误差的向量近似等价判断 + !#en Negative error vector floating point approximately equivalent Analyzing + */ + static equals (a: Out, b: Out, epsilon?: number): boolean; + /** + !#zh 求两向量夹角弧度 + !#en Radian angle between two vectors seek + */ + static angle (a: Out, b: Out): number; + /** + !#zh 计算向量在指定平面上的投影 + !#en Calculating a projection vector in the specified plane + @param a 待投影向量 + @param n 指定平面的法线 + */ + static projectOnPlane (out: Out, a: Out, n: Out): Out; + /** + !#zh 计算向量在指定向量上的投影 + !#en Projection vector calculated in the vector designated + @param a 待投影向量 + @param n 目标向量 + */ + static project (out: Out, a: Out, b: Out): Out; + /** + !#zh 向量转数组 + !#en Vector transfer array + @param ofs 数组起始偏移量 + */ + static toArray > (out: Out, v: IVec3Like, ofs?: number): Out; + /** + !#zh 数组转向量 + !#en Array steering amount + @param ofs 数组起始偏移量 + */ + static fromArray (out: Out, arr: IWritableArrayLike, ofs?: number): Out; + x: number; + y: number; + z: number; + /** + !#en + Constructor + see {{#crossLink "cc/vec3:method"}}cc.v3{{/crossLink}} + !#zh + 构造函数,可查看 {{#crossLink "cc/vec3:method"}}cc.v3{{/crossLink}} + @param x x + @param y y + @param z z + */ + constructor(x?: Vec3|number, y?: number, z?: number); + /** + !#en clone a Vec3 value + !#zh 克隆一个 Vec3 值 + */ + clone(): Vec3; + /** + !#en Set the current vector value with the given vector. + !#zh 用另一个向量设置当前的向量对象值。 + @param newValue !#en new value to set. !#zh 要设置的新值 + */ + set(newValue: Vec3): Vec3; + /** + !#en Check whether the vector equals another one + !#zh 当前的向量是否与指定的向量相等。 + @param other other + */ + equals(other: Vec3): boolean; + /** + !#en Check whether two vector equal with some degree of variance. + !#zh + 近似判断两个点是否相等。
+ 判断 2 个向量是否在指定数值的范围之内,如果在则返回 true,反之则返回 false。 + @param other other + @param variance variance + */ + fuzzyEquals(other: Vec3, variance: number): boolean; + /** + !#en Transform to string with vector informations + !#zh 转换为方便阅读的字符串。 + */ + toString(): string; + /** + !#en Calculate linear interpolation result between this vector and another one with given ratio + !#zh 线性插值。 + @param to to + @param ratio the interpolation coefficient + @param out optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created + */ + lerp(to: Vec3, ratio: number, out?: Vec3): Vec3; + /** + !#en Clamp the vector between from float and to float. + !#zh + 返回指定限制区域后的向量。
+ 向量大于 max_inclusive 则返回 max_inclusive。
+ 向量小于 min_inclusive 则返回 min_inclusive。
+ 否则返回自身。 + @param min_inclusive min_inclusive + @param max_inclusive max_inclusive + */ + clampf(min_inclusive: Vec3, max_inclusive: Vec3): Vec3; + /** + !#en Adds this vector. If you want to save result to another vector, use add() instead. + !#zh 向量加法。如果你想保存结果到另一个向量,使用 add() 代替。 + @param vector vector + */ + addSelf(vector: Vec3): Vec3; + /** + !#en Adds two vectors, and returns the new result. + !#zh 向量加法,并返回新结果。 + @param vector vector + @param out optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created + */ + add(vector: Vec3, out?: Vec3): Vec3; + /** + !#en Subtracts one vector from this. + !#zh 向量减法。 + @param vector vector + */ + subtract(vector: Vec3): Vec3; + /** + !#en Multiplies this by a number. + !#zh 缩放当前向量。 + @param num num + */ + multiplyScalar(num: number): Vec3; + /** + !#en Multiplies two vectors. + !#zh 分量相乘。 + @param vector vector + */ + multiply(vector: Vec3): Vec3; + /** + !#en Divides by a number. + !#zh 向量除法。 + @param num num + */ + divide(num: number): Vec3; + /** + !#en Negates the components. + !#zh 向量取反。 + */ + negate(): Vec3; + /** + !#en Dot product + !#zh 当前向量与指定向量进行点乘。 + @param vector vector + */ + dot(vector?: Vec3): number; + /** + !#en Cross product + !#zh 当前向量与指定向量进行叉乘。 + @param vector vector + @param out out + */ + cross(vector: Vec3, out?: Vec3): Vec3; + /** + !#en Returns the length of this vector. + !#zh 返回该向量的长度。 + + @example + ```js + var v = cc.v3(10, 10, 10); + v.len(); // return 17.320508075688775; + ``` + */ + len(): number; + /** + !#en Returns the squared length of this vector. + !#zh 返回该向量的长度平方。 + */ + lengthSqr(): number; + /** + !#en Make the length of this vector to 1. + !#zh 向量归一化,让这个向量的长度为 1。 + */ + normalizeSelf(): Vec3; + /** + !#en + Returns this vector with a magnitude of 1.
+
+ Note that the current vector is unchanged and a new normalized vector is returned. If you want to normalize the current vector, use normalizeSelf function. + !#zh + 返回归一化后的向量。
+
+ 注意,当前向量不变,并返回一个新的归一化向量。如果你想来归一化当前向量,可使用 normalizeSelf 函数。 + @param out optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created + */ + normalize(out?: Vec3): Vec3; + /** + Transforms the vec3 with a mat4. 4th vector component is implicitly '1' + @param m matrix to transform with + @param out the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created + */ + transformMat4(m: Mat4, out?: Vec3): Vec3; + /** + Returns the maximum value in x, y, and z + */ + maxAxis(): number; + /** + !#en Get angle in radian between this and vector. + !#zh 夹角的弧度。 + @param vector vector + */ + angle(vector: Vec3): number; + /** + !#en Calculates the projection of the current vector over the given vector. + !#zh 返回当前向量在指定 vector 向量上的投影向量。 + @param vector vector + + @example + ```js + var v1 = cc.v3(20, 20, 20); + var v2 = cc.v3(5, 5, 5); + v1.project(v2); // Vec3 {x: 20, y: 20, z: 20}; + ``` + */ + project(vector: Vec3): Vec3; + /** + !#en Get angle in radian between this and vector with direction.
+ In order to compatible with the vec2 API. + !#zh 带方向的夹角的弧度。该方法仅用做兼容 2D 计算。 + @param vector vector + */ + signAngle(vector: Vec3|Vec2): number; + /** + !#en rotate. In order to compatible with the vec2 API. + !#zh 返回旋转给定弧度后的新向量。该方法仅用做兼容 2D 计算。 + @param radians radians + @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created + */ + rotate(radians: number, out?: Vec3): Vec2; + /** + !#en rotate self. In order to compatible with the vec2 API. + !#zh 按指定弧度旋转向量。该方法仅用做兼容 2D 计算。 + @param radians radians + */ + rotateSelf(radians: number): Vec3; + } + /** !#en Representation of 3D vectors and points. + !#zh 表示 3D 向量和坐标 */ + export class Vec4 extends ValueType { + /** + !#en Subtracts one vector from this. If you want to save result to another vector, use sub() instead. + !#zh 向量减法。如果你想保存结果到另一个向量,可使用 sub() 代替。 + @param vector vector + */ + subSelf(vector: Vec4): Vec4; + /** + !#en Subtracts one vector from this, and returns the new result. + !#zh 向量减法,并返回新结果。 + @param vector vector + @param out optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created + */ + sub(vector: Vec4, out?: Vec4): Vec4; + /** + !#en Multiplies this by a number. If you want to save result to another vector, use mul() instead. + !#zh 缩放当前向量。如果你想结果保存到另一个向量,可使用 mul() 代替。 + @param num num + */ + mulSelf(num: number): Vec4; + /** + !#en Multiplies by a number, and returns the new result. + !#zh 缩放向量,并返回新结果。 + @param num num + @param out optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created + */ + mul(num: number, out?: Vec4): Vec4; + /** + !#en Divides by a number. If you want to save result to another vector, use div() instead. + !#zh 向量除法。如果你想结果保存到另一个向量,可使用 div() 代替。 + @param num num + */ + divSelf(num: number): Vec4; + /** + !#en Divides by a number, and returns the new result. + !#zh 向量除法,并返回新的结果。 + @param num num + @param out optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created + */ + div(num: number, out?: Vec4): Vec4; + /** + !#en Multiplies two vectors. + !#zh 分量相乘。 + @param vector vector + */ + scaleSelf(vector: Vec4): Vec4; + /** + !#en Multiplies two vectors, and returns the new result. + !#zh 分量相乘,并返回新的结果。 + @param vector vector + @param out optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created + */ + scale(vector: Vec4, out?: Vec4): Vec4; + /** + !#en Negates the components. If you want to save result to another vector, use neg() instead. + !#zh 向量取反。如果你想结果保存到另一个向量,可使用 neg() 代替。 + */ + negSelf(): Vec4; + /** + !#en Negates the components, and returns the new result. + !#zh 返回取反后的新向量。 + @param out optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created + */ + neg(out?: Vec4): Vec4; + /** + !#zh 获得指定向量的拷贝 + !#en Obtaining copy vectors designated + */ + static clone (a: Out): Vec4; + /** + !#zh 复制目标向量 + !#en Copy the target vector + */ + static copy (out: Out, a: Out): Out; + /** + !#zh 设置向量值 + !#en Set to value + */ + static set (out: Out, x: number, y: number, z: number, w: number): Out; + /** + !#zh 逐元素向量加法 + !#en Element-wise vector addition + */ + static add (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量减法 + !#en Element-wise vector subtraction + */ + static subtract (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量乘法 + !#en Element-wise vector multiplication + */ + static multiply (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量除法 + !#en Element-wise vector division + */ + static divide (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量向上取整 + !#en Rounding up by elements of the vector + */ + static ceil (out: Out, a: Out): Out; + /** + !#zh 逐元素向量向下取整 + !#en Element vector by rounding down + */ + static floor (out: Out, a: Out): Out; + /** + !#zh 逐元素向量最小值 + !#en The minimum by-element vector + */ + static min (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量最大值 + !#en The maximum value of the element-wise vector + */ + static max (out: Out, a: Out, b: Out): Out; + /** + !#zh 逐元素向量四舍五入取整 + !#en Element-wise vector of rounding to whole + */ + static round (out: Out, a: Out): Out; + /** + !#zh 向量标量乘法 + !#en Vector scalar multiplication + */ + static multiplyScalar (out: Out, a: Out, b: number): Out; + /** + !#zh 逐元素向量乘加: A + B * scale + !#en Element-wise vector multiply add: A + B * scale + */ + static scaleAndAdd (out: Out, a: Out, b: Out, scale: number): Out; + /** + !#zh 求两向量的欧氏距离 + !#en Seeking two vectors Euclidean distance + */ + static distance (a: Out, b: Out): number; + /** + !#zh 求两向量的欧氏距离平方 + !#en Euclidean distance squared seeking two vectors + */ + static squaredDistance (a: Out, b: Out): number; + /** + !#zh 求向量长度 + !#en Seeking vector length + */ + static len (a: Out): number; + /** + !#zh 求向量长度平方 + !#en Seeking squared vector length + */ + static lengthSqr (a: Out): number; + /** + !#zh 逐元素向量取负 + !#en By taking the negative elements of the vector + */ + static negate (out: Out, a: Out): Out; + /** + !#zh 逐元素向量取倒数,接近 0 时返回 Infinity + !#en Element vector by taking the inverse, return near 0 Infinity + */ + static inverse (out: Out, a: Out): Out; + /** + !#zh 逐元素向量取倒数,接近 0 时返回 0 + !#en Element vector by taking the inverse, return near 0 0 + */ + static inverseSafe (out: Out, a: Out): Out; + /** + !#zh 归一化向量 + !#en Normalized vector + */ + static normalize (out: Out, a: Out): Out; + /** + !#zh 向量点积(数量积) + !#en Vector dot product (scalar product) + */ + static dot (a: Out, b: Out): number; + /** + !#zh 逐元素向量线性插值: A + t * (B - A) + !#en Vector element by element linear interpolation: A + t * (B - A) + */ + static lerp (out: Out, a: Out, b: Out, t: number): Out; + /** + !#zh 生成一个在单位球体上均匀分布的随机向量 + !#en Generates a uniformly distributed random vectors on the unit sphere + @param scale 生成的向量长度 + */ + static random (out: Out, scale?: number): Out; + /** + !#zh 向量矩阵乘法 + !#en Vector matrix multiplication + */ + static transformMat4 (out: Out, a: Out, mat: MatLike): Out; + /** + !#zh 向量仿射变换 + !#en Affine transformation vector + */ + static transformAffine(out: Out, v: VecLike, mat: MatLike): Out; + /** + !#zh 向量四元数乘法 + !#en Vector quaternion multiplication + */ + static transformQuat (out: Out, a: Out, q: QuatLike): Out; + /** + !#zh 向量等价判断 + !#en Equivalent vectors Analyzing + */ + static strictEquals (a: Out, b: Out): boolean; + /** + !#zh 排除浮点数误差的向量近似等价判断 + !#en Negative error vector floating point approximately equivalent Analyzing + */ + static equals (a: Out, b: Out, epsilon?: number): boolean; + /** + !#zh 向量转数组 + !#en Vector transfer array + @param ofs 数组起始偏移量 + */ + static toArray > (out: Out, v: IVec4Like, ofs?: number): Out; + /** + !#zh 数组转向量 + !#en Array steering amount + @param ofs 数组起始偏移量 + */ + static fromArray (out: Out, arr: IWritableArrayLike, ofs?: number): Out; + x: number; + y: number; + z: number; + w: number; + /** + !#en + Constructor + see {{#crossLink "cc/vec4:method"}}cc.v4{{/crossLink}} + !#zh + 构造函数,可查看 {{#crossLink "cc/vec4:method"}}cc.v4{{/crossLink}} + @param x x + @param y y + @param z z + @param w w + */ + constructor(x?: number, y?: number, z?: number, w?: number); + /** + !#en clone a Vec4 value + !#zh 克隆一个 Vec4 值 + */ + clone(): Vec4; + /** + !#en Set the current vector value with the given vector. + !#zh 用另一个向量设置当前的向量对象值。 + @param newValue !#en new value to set. !#zh 要设置的新值 + */ + set(newValue: Vec4): Vec4; + /** + !#en Check whether the vector equals another one + !#zh 当前的向量是否与指定的向量相等。 + @param other other + @param epsilon epsilon + */ + equals(other: Vec4, epsilon?: number): boolean; + /** + !#en Check whether the vector equals another one + !#zh 判断当前向量是否在误差范围内与指定分量的向量相等。 + @param x 相比较的向量的 x 分量。 + @param y 相比较的向量的 y 分量。 + @param z 相比较的向量的 z 分量。 + @param w 相比较的向量的 w 分量。 + @param epsilon 允许的误差,应为非负数。 + */ + equals4f(x: number, y: number, z: number, w: number, epsilon?: number): boolean; + /** + !#en Check whether strict equals other Vec4 + !#zh 判断当前向量是否与指定向量相等。两向量的各分量都分别相等时返回 `true`;否则返回 `false`。 + @param other 相比较的向量。 + */ + strictEquals(other: Vec4): boolean; + /** + !#en Check whether strict equals other Vec4 + !#zh 判断当前向量是否与指定分量的向量相等。两向量的各分量都分别相等时返回 `true`;否则返回 `false`。 + @param x 指定向量的 x 分量。 + @param y 指定向量的 y 分量。 + @param z 指定向量的 z 分量。 + @param w 指定向量的 w 分量。 + */ + strictEquals4f(x: number, y: number, z: number, w: number): boolean; + /** + !#en Calculate linear interpolation result between this vector and another one with given ratio + !#zh 根据指定的插值比率,从当前向量到目标向量之间做插值。 + @param to 目标向量。 + @param ratio 插值比率,范围为 [0,1]。 + */ + lerp(to: Vec4, ratio: number): Vec4; + /** + !#en Transform to string with vector informations + !#zh 返回当前向量的字符串表示。 + */ + toString(): string; + /** + !#en Clamp the vector between minInclusive and maxInclusive. + !#zh 设置当前向量的值,使其各个分量都处于指定的范围内。 + @param minInclusive 每个分量都代表了对应分量允许的最小值。 + @param maxInclusive 每个分量都代表了对应分量允许的最大值。 + */ + clampf(minInclusive: Vec4, maxInclusive: Vec4): Vec4; + /** + !#en Adds this vector. If you want to save result to another vector, use add() instead. + !#zh 向量加法。如果你想保存结果到另一个向量,使用 add() 代替。 + @param vector vector + */ + addSelf(vector: Vec4): Vec4; + /** + !#en Adds two vectors, and returns the new result. + !#zh 向量加法,并返回新结果。 + @param vector vector + @param out optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created + */ + add(vector: Vec4, out?: Vec4): Vec4; + /** + !#en Subtracts one vector from this, and returns the new result. + !#zh 向量减法,并返回新结果。 + @param vector vector + @param out optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created + */ + subtract(vector: Vec4, out?: Vec4): Vec4; + /** + !#en Multiplies this by a number. + !#zh 缩放当前向量。 + @param num num + */ + multiplyScalar(num: number): Vec4; + /** + !#en Multiplies two vectors. + !#zh 分量相乘。 + @param vector vector + */ + multiply(vector: Vec4): Vec4; + /** + !#en Divides by a number. + !#zh 向量除法。 + @param num num + */ + divide(num: number): Vec4; + /** + !#en Negates the components. + !#zh 向量取反 + */ + negate(): Vec4; + /** + !#en Dot product + !#zh 当前向量与指定向量进行点乘。 + @param vector vector + */ + dot(vector?: Vec4): number; + /** + !#en Cross product + !#zh 当前向量与指定向量进行叉乘。 + @param vector vector + @param out out + */ + cross(vector: Vec4, out?: Vec4): Vec4; + /** + !#en Returns the length of this vector. + !#zh 返回该向量的长度。 + + @example + ```js + var v = cc.v4(10, 10); + v.len(); // return 14.142135623730951; + ``` + */ + len(): number; + /** + !#en Returns the squared length of this vector. + !#zh 返回该向量的长度平方。 + */ + lengthSqr(): number; + /** + !#en Make the length of this vector to 1. + !#zh 向量归一化,让这个向量的长度为 1。 + */ + normalizeSelf(): Vec4; + /** + !#en + Returns this vector with a magnitude of 1.
+
+ Note that the current vector is unchanged and a new normalized vector is returned. If you want to normalize the current vector, use normalizeSelf function. + !#zh + 返回归一化后的向量。
+
+ 注意,当前向量不变,并返回一个新的归一化向量。如果你想来归一化当前向量,可使用 normalizeSelf 函数。 + @param out optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created + */ + normalize(out?: Vec4): Vec4; + /** + Transforms the vec4 with a mat4. 4th vector component is implicitly '1' + @param m matrix to transform with + @param out the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created + */ + transformMat4(m: Mat4, out?: Vec4): Vec4; + /** + Returns the maximum value in x, y, z, w. + */ + maxAxis(): number; + } + /** !#en The burst of 3d particle. + !#zh 3D 粒子发射时的爆发个数 */ + export class Burst { + /** !#en Time between the start of the particle system and the trigger of this Brust + !#zh 粒子系统开始运行到触发此次 Brust 的时间 */ + time: number; + /** !#en Minimum number of emitted particles + !#zh 发射粒子的最小数量 */ + minCount: number; + /** !#en Maximum number of emitted particles + !#zh 发射粒子的最大数量 */ + maxCount: number; + /** !#en The number of times Burst was triggered. + !#zh Burst 的触发次数 */ + repeatCount: number; + /** !#en Interval of each trigger + !#zh 每次触发的间隔时间 */ + repeatInterval: number; + /** !#en Number of particles emitted + !#zh 发射的粒子的数量 */ + count: CurveRange; + } + /** !#en The animation curve of 3d particle. + !#zh 3D 粒子动画曲线 */ + export class AnimationCurve { + /** !#en Array of key value. + !#zh 关键值列表。 */ + keyFrames: Keyframe[]; + /** !#en Pre-wrap mode. + !#zh 前置循环模式。 */ + preWrapMode: WrapMode; + /** !#en Post-wrap mode. + !#zh 后置循环模式。 */ + postWrapMode: WrapMode; + } + /** !#en The ParticleSystem3D Component. + !#zh 3D 粒子组件 */ + export class ParticleSystem3D extends RenderComponent { + /** !#en The run time of particle. + !#zh 粒子系统运行时间 */ + duration: number; + /** !#en The maximum number of particles that a particle system can generate. + !#zh 粒子系统能生成的最大粒子数量 */ + capacity: number; + /** !#en Whether the particle system loops. + !#zh 粒子系统是否循环播放 */ + loop: boolean; + /** !#en Whether the particles start playing automatically after loaded. + !#zh 粒子系统加载后是否自动开始播放 */ + playOnAwake: boolean; + /** !#en When selected, the particle system will start playing after one round has been played (only effective when loop is enabled). + !#zh 选中之后,粒子系统会以已播放完一轮之后的状态开始播放(仅当循环播放启用时有效) */ + prewarm: boolean; + /** !#en The coordinate system in which the particle system is located.
+ World coordinates (does not change when the position of other objects changes)
+ Local coordinates (moving as the position of the parent node changes)
+ Custom coordinates (moving with the position of a custom node) + !#zh 选择粒子系统所在的坐标系
+ 世界坐标(不随其他物体位置改变而变换)
+ 局部坐标(跟随父节点位置改变而移动)
+ 自定坐标(跟随自定义节点的位置改变而移动) */ + simulationSpace: ParticleSystem3DAssembler.Space; + /** !#en Controlling the update speed of the entire particle system. + !#zh 控制整个粒子系统的更新速度。 */ + simulationSpeed: number; + /** !#en Delay particle emission time after particle system starts running. + !#zh 粒子系统开始运行后,延迟粒子发射的时间。 */ + startDelay: CurveRange; + /** !#en Particle life cycle。 + !#zh 粒子生命周期。 */ + startLifetime: CurveRange; + /** !#en Particle initial color + !#zh 粒子初始颜色 */ + startColor: GradientRange; + /** !#en Particle scale space + !#zh 缩放空间 */ + scaleSpace: ParticleSystem3DAssembler.Space; + /** !#en Initial particle size + !#zh 粒子初始大小 */ + startSize: CurveRange; + /** !#en Initial particle speed + !#zh 粒子初始速度 */ + startSpeed: CurveRange; + /** !#en Particle initial rotation angle + !#zh 粒子初始旋转角度 */ + startRotation: CurveRange; + /** !#en Gravity coefficient of particles affected by gravity + !#zh 粒子受重力影响的重力系数 */ + gravityModifier: CurveRange; + /** !#en Particles emitted per second + !#zh 每秒发射的粒子数 */ + rateOverTime: CurveRange; + /** !#en Number of particles emitted per unit distance moved + !#zh 每移动单位距离发射的粒子数 */ + rateOverDistance: CurveRange; + /** !#en The number of Brusts that emit a specified number of particles at a specified time + !#zh 设定在指定时间发射指定数量的粒子的 Brust 的数量 */ + bursts: Burst[]; + /** !#en Particle emitter module + !#zh 粒子发射器模块 */ + shapeModule: ShapeModule; + /** !#en Color control module + !#zh 颜色控制模块 */ + colorOverLifetimeModule: ColorOverLifetimeModule; + /** !#en Particle size module + !#zh 粒子大小模块 */ + sizeOvertimeModule: SizeOvertimeModule; + /** !#en Particle speed module + !#zh 粒子速度模块 */ + velocityOvertimeModule: VelocityOvertimeModule; + /** !#en Particle acceleration module + !#zh 粒子加速度模块 */ + forceOvertimeModule: ForceOvertimeModule; + /** !#en Particle limit speed module (only CPU particles are supported) + !#zh 粒子限制速度模块(只支持 CPU 粒子) */ + limitVelocityOvertimeModule: LimitVelocityOvertimeModule; + /** !#en Particle rotation module + !#zh 粒子旋转模块 */ + rotationOvertimeModule: RotationOvertimeModule; + /** !#en Texture Animation Module + !#zh 贴图动画模块 */ + textureAnimationModule: TextureAnimationModule; + /** !#en Particle Trajectory Module + !#zh 粒子轨迹模块 */ + trailModule: TrailModule; + /** !#en Particle generation mode + !#zh 设定粒子生成模式 */ + renderMode: ParticleSystem3DAssembler.RenderMode; + /** !#en When the particle generation mode is StrecthedBillboard, in the direction of movement of the particles is stretched by velocity magnitude + !#zh 在粒子生成方式为 StrecthedBillboard 时,对粒子在运动方向上按速度大小进行拉伸 */ + velocityScale: number; + /** !#en When the particle generation method is StrecthedBillboard, the particles are stretched according to the particle size in the direction of motion + !#zh 在粒子生成方式为 StrecthedBillboard 时,对粒子在运动方向上按粒子大小进行拉伸 */ + lengthScale: number; + /** !#en Particle model + !#zh 粒子模型 */ + mesh: Mesh; + /** !#en Particle material + !#zh 粒子材质 */ + particleMaterial: Material; + /** !#en Particle trail material + !#zh 粒子轨迹材质 */ + trailMaterial: Material; + /** + !#en Playing particle effects + !#zh 播放粒子效果 + */ + play(): void; + /** + !#en Pause particle effect + !#zh 暂停播放粒子效果 + */ + pause(): void; + /** + !#en Stop particle effect + !#zh 停止播放粒子效果 + */ + stop(): void; + /** + !#en Remove all particle effect + !#zh 将所有粒子从粒子系统中清除 + */ + clear(): void; + } + /** !#en + Helper class for ES5 Map. + !#zh + ES5 Map 辅助类。 */ + export class MapUtils { + } + /** !#en Effect Asset. + !#zh Effect 资源类型。 */ + export class EffectAsset extends Asset { + } + /** !#en Material Asset. + !#zh 材质资源类。 */ + export class Material extends Asset { + /** + !#en Get built-in materials + !#zh 获取内置材质 + @param name name + */ + static getBuiltinMaterial(name: string): Material; + /** + !#en Creates a Material with builtin Effect. + !#zh 使用内建 Effect 创建一个材质。 + @param effectName effectName + @param techniqueIndex techniqueIndex + */ + static createWithBuiltin(effectName: string, techniqueIndex?: number): Material; + /** + !#en Creates a Material. + !#zh 创建一个材质。 + @param effectAsset effectAsset + @param techniqueIndex techniqueIndex + */ + static create(effectAsset: EffectAsset, techniqueIndex?: number): Material; + /** + !#en Sets the Material property + !#zh 设置材质的属性 + @param name name + @param val val + @param passIdx passIdx + @param directly directly + */ + setProperty(name: string, val: any, passIdx?: number, directly?: boolean): void; + /** + !#en Gets the Material property. + !#zh 获取材质的属性。 + @param name name + @param passIdx passIdx + */ + getProperty(name: string, passIdx: number): any; + /** + !#en Sets the Material define. + !#zh 设置材质的宏定义。 + @param name name + @param val val + @param passIdx passIdx + @param force force + */ + define(name: string, val: boolean|number, passIdx?: number, force?: boolean): void; + /** + !#en Gets the Material define. + !#zh 获取材质的宏定义。 + @param name name + @param passIdx passIdx + */ + getDefine(name: string, passIdx?: number): boolean; + /** + !#en Sets the Material cull mode. + !#zh 设置材质的裁减模式。 + @param cullMode cullMode + @param passIdx passIdx + */ + setCullMode(cullMode: number, passIdx: number): void; + /** + !#en Sets the Material depth states. + !#zh 设置材质的深度渲染状态。 + @param depthTest depthTest + @param depthWrite depthWrite + @param depthFunc depthFunc + @param passIdx passIdx + */ + setDepth(depthTest: boolean, depthWrite: boolean, depthFunc: number, passIdx: number): void; + /** + !#en Sets the Material blend states. + !#zh 设置材质的混合渲染状态。 + @param enabled enabled + @param blendEq blendEq + @param blendSrc blendSrc + @param blendDst blendDst + @param blendAlphaEq blendAlphaEq + @param blendSrcAlpha blendSrcAlpha + @param blendDstAlpha blendDstAlpha + @param blendColor blendColor + @param passIdx passIdx + */ + setBlend(enabled: boolean, blendEq: number, blendSrc: number, blendDst: number, blendAlphaEq: number, blendSrcAlpha: number, blendDstAlpha: number, blendColor: number, passIdx: number): void; + /** + !#en Sets whether enable the stencil test. + !#zh 设置是否开启模板测试。 + @param stencilTest stencilTest + @param passIdx passIdx + */ + setStencilEnabled(stencilTest: number, passIdx: number): void; + /** + !#en Sets the Material stencil render states. + !#zh 设置材质的模板测试渲染参数。 + @param stencilTest stencilTest + @param stencilFunc stencilFunc + @param stencilRef stencilRef + @param stencilMask stencilMask + @param stencilFailOp stencilFailOp + @param stencilZFailOp stencilZFailOp + @param stencilZPassOp stencilZPassOp + @param stencilWriteMask stencilWriteMask + @param passIdx passIdx + */ + setStencil(stencilTest: number, stencilFunc: number, stencilRef: number, stencilMask: number, stencilFailOp: number, stencilZFailOp: number, stencilZPassOp: number, stencilWriteMask: number, passIdx: number): void; + } + /** !#en + Material Variant is an extension of the Material Asset. + Changes to Material Variant do not affect other Material Variant or Material Asset, + and changes to Material Asset are synchronized to the Material Variant. + However, when a Material Variant had already modifies a state, the Material Asset state is not synchronized to the Material Variant. + !#zh + 材质变体是材质资源的一个延伸。 + 材质变体的修改不会影响到其他的材质变体或者材质资源,而材质资源的修改会同步体现到材质变体上, + 但是当材质变体对一个状态修改后,材质资源再对这个状态修改是不会同步到材质变体上的。 */ + export class MaterialVariant extends Material { + /** + + @param materialName materialName + @param owner owner + */ + static createWithBuiltin (materialName: string, owner: cc.RenderComponent): MaterialVariant | null; + /** + + @param material material + @param owner owner + */ + static create (material: Material, owner: cc.RenderComponent): MaterialVariant | null; + } + /** !#en cc.EditBox is a component for inputing text, you can use it to gather small amounts of text from users. + !#zh EditBox 组件,用于获取用户的输入文本。 */ + export class EditBox extends Component { + /** !#en Input string of EditBox. + !#zh 输入框的初始输入内容,如果为空则会显示占位符的文本。 */ + string: string; + /** !#en The Label component attached to the node for EditBox's input text label + !#zh 输入框输入文本节点上挂载的 Label 组件对象 */ + textLabel: Label; + /** !#en The Label component attached to the node for EditBox's placeholder text label + !#zh 输入框占位符节点上挂载的 Label 组件对象 */ + placeholderLabel: Label; + /** !#en The Sprite component attached to the node for EditBox's background + !#zh 输入框背景节点上挂载的 Sprite 组件对象 */ + background: Sprite; + /** !#en The background image of EditBox. This property will be removed in the future, use editBox.background instead please. + !#zh 输入框的背景图片。 该属性会在将来的版本中移除,请用 editBox.background */ + backgroundImage: SpriteFrame; + /** !#en + The return key type of EditBox. + Note: it is meaningless for web platforms and desktop platforms. + !#zh + 指定移动设备上面回车按钮的样式。 + 注意:这个选项对 web 平台与 desktop 平台无效。 */ + returnType: EditBox.KeyboardReturnType; + /** !#en Set the input flags that are to be applied to the EditBox. + !#zh 指定输入标志位,可以指定输入方式为密码或者单词首字母大写。 */ + inputFlag: EditBox.InputFlag; + /** !#en + Set the input mode of the edit box. + If you pass ANY, it will create a multiline EditBox. + !#zh + 指定输入模式: ANY表示多行输入,其它都是单行输入,移动平台上还可以指定键盘样式。 */ + inputMode: EditBox.InputMode; + /** !#en Font size of the input text. This property will be removed in the future, use editBox.textLabel.fontSize instead please. + !#zh 输入框文本的字体大小。 该属性会在将来的版本中移除,请使用 editBox.textLabel.fontSize。 */ + fontSize: number; + /** !#en Change the lineHeight of displayed text. This property will be removed in the future, use editBox.textLabel.lineHeight instead. + !#zh 输入框文本的行高。该属性会在将来的版本中移除,请使用 editBox.textLabel.lineHeight */ + lineHeight: number; + /** !#en Font color of the input text. This property will be removed in the future, use editBox.textLabel.node.color instead. + !#zh 输入框文本的颜色。该属性会在将来的版本中移除,请使用 editBox.textLabel.node.color */ + fontColor: Color; + /** !#en The display text of placeholder. + !#zh 输入框占位符的文本内容。 */ + placeholder: string; + /** !#en The font size of placeholder. This property will be removed in the future, use editBox.placeholderLabel.fontSize instead. + !#zh 输入框占位符的字体大小。该属性会在将来的版本中移除,请使用 editBox.placeholderLabel.fontSize */ + placeholderFontSize: number; + /** !#en The font color of placeholder. This property will be removed in the future, use editBox.placeholderLabel.node.color instead. + !#zh 输入框占位符的字体颜色。该属性会在将来的版本中移除,请使用 editBox.placeholderLabel.node.color */ + placeholderFontColor: Color; + /** !#en The maximize input length of EditBox. + - If pass a value less than 0, it won't limit the input number of characters. + - If pass 0, it doesn't allow input any characters. + !#zh 输入框最大允许输入的字符个数。 + - 如果值为小于 0 的值,则不会限制输入字符个数。 + - 如果值为 0,则不允许用户进行任何输入。 */ + maxLength: number; + /** !#en The input is always visible and be on top of the game view (only useful on Web), this property will be removed on v2.1 + !zh 输入框总是可见,并且永远在游戏视图的上面(这个属性只有在 Web 上面修改有意义),该属性会在 v2.1 中移除 + Note: only available on Web at the moment. */ + stayOnTop: boolean; + /** !#en Set the tabIndex of the DOM input element (only useful on Web). + !#zh 修改 DOM 输入元素的 tabIndex(这个属性只有在 Web 上面修改有意义)。 */ + tabIndex: number; + /** !#en The event handler to be called when EditBox began to edit text. + !#zh 开始编辑文本输入框触发的事件回调。 */ + editingDidBegan: Component.EventHandler[]; + /** !#en The event handler to be called when EditBox text changes. + !#zh 编辑文本输入框时触发的事件回调。 */ + textChanged: Component.EventHandler[]; + /** !#en The event handler to be called when EditBox edit ends. + !#zh 结束编辑文本输入框时触发的事件回调。 */ + editingDidEnded: Component.EventHandler[]; + /** !#en The event handler to be called when return key is pressed. Windows is not supported. + !#zh 当用户按下回车按键时的事件回调,目前不支持 windows 平台 */ + editingReturn: Component.EventHandler[]; + /** + !#en Let the EditBox get focus, this method will be removed on v2.1 + !#zh 让当前 EditBox 获得焦点, 这个方法会在 v2.1 中移除 + */ + setFocus(): void; + /** + !#en Let the EditBox get focus + !#zh 让当前 EditBox 获得焦点 + */ + focus(): void; + /** + !#en Let the EditBox lose focus + !#zh 让当前 EditBox 失去焦点 + */ + blur(): void; + /** + !#en Determine whether EditBox is getting focus or not. + !#zh 判断 EditBox 是否获得了焦点 + */ + isFocused(): void; + /** + !#en if you don't need the EditBox and it isn't in any running Scene, you should + call the destroy method on this component or the associated node explicitly. + Otherwise, the created DOM element won't be removed from web page. + !#zh + 如果你不再使用 EditBox,并且组件未添加到场景中,那么你必须手动对组件或所在节点调用 destroy。 + 这样才能移除网页上的 DOM 节点,避免 Web 平台内存泄露。 + + @example + ```js + editbox.node.parent = null; // or editbox.node.removeFromParent(false); + // when you don't need editbox anymore + editbox.node.destroy(); + ``` + */ + destroy(): boolean; + } + /** !#en . + !#zh 。 */ + export class SkeletonAnimation extends Animation { + } + /** !#en SkeletonAnimationClip Asset. + !#zh 骨骼动画剪辑。 */ + export class SkeletonAnimationClip extends AnimationClip { + } + /** !#en + Skinned Mesh Renderer + !#zh + 蒙皮渲染组件 */ + export class SkinnedMeshRenderer extends MeshRenderer { + /** !#en + Skeleton Asset + !#zh + 骨骼资源 */ + skeleton: sp.Skeleton; + /** !#en + Root Bone + !#zh + 骨骼根节点 */ + rootBone: Node; + } + /** !#en + A distance joint constrains two points on two bodies + to remain at a fixed distance from each other. You can view + this as a massless, rigid rod. + !#zh + 距离关节通过一个固定的长度来约束关节链接的两个刚体。你可以将它想象成一个无质量,坚固的木棍。 */ + export class DistanceJoint extends Joint { + /** !#en + The distance separating the two ends of the joint. + !#zh + 关节两端的距离 */ + distance: number; + /** !#en + The spring frequency. + !#zh + 弹性系数。 */ + frequency: number; + /** !#en + The damping ratio. + !#zh + 阻尼,表示关节变形后,恢复到初始状态受到的阻力。 */ + dampingRatio: number; + } + /** !#en + Base class for joints to connect rigidbody. + !#zh + 关节类的基类 */ + export class Joint extends Component { + /** !#en + The anchor of the rigidbody. + !#zh + 刚体的锚点。 */ + anchor: Vec2; + /** !#en + The anchor of the connected rigidbody. + !#zh + 关节另一端刚体的锚点。 */ + connectedAnchor: Vec2; + /** !#en + The rigidbody to which the other end of the joint is attached. + !#zh + 关节另一端链接的刚体 */ + connectedBody: RigidBody; + /** !#en + Should the two rigid bodies connected with this joint collide with each other? + !#zh + 链接到关节上的两个刚体是否应该相互碰撞? */ + collideConnected: boolean; + /** + !#en + Apply current changes to joint, this will regenerate inner box2d joint. + !#zh + 应用当前关节中的修改,调用此函数会重新生成内部 box2d 的关节。 + */ + apply(): void; + /** + !#en + Get the anchor point on rigidbody in world coordinates. + !#zh + 获取刚体世界坐标系下的锚点。 + */ + getWorldAnchor(): Vec2; + /** + !#en + Get the anchor point on connected rigidbody in world coordinates. + !#zh + 获取链接刚体世界坐标系下的锚点。 + */ + getWorldConnectedAnchor(): Vec2; + /** + !#en + Gets the reaction force of the joint. + !#zh + 获取关节的反作用力。 + @param timeStep The time to calculate the reaction force for. + */ + getReactionForce(timeStep: number): Vec2; + /** + !#en + Gets the reaction torque of the joint. + !#zh + 获取关节的反扭矩。 + @param timeStep The time to calculate the reaction torque for. + */ + getReactionTorque(timeStep: number): number; + } + /** !#en + A motor joint is used to control the relative motion + between two bodies. A typical usage is to control the movement + of a dynamic body with respect to the ground. + !#zh + 马达关节被用来控制两个刚体间的相对运动。 + 一个典型的例子是用来控制一个动态刚体相对于地面的运动。 */ + export class MotorJoint extends Joint { + /** !#en + The anchor of the rigidbody. + !#zh + 刚体的锚点。 */ + anchor: Vec2; + /** !#en + The anchor of the connected rigidbody. + !#zh + 关节另一端刚体的锚点。 */ + connectedAnchor: Vec2; + /** !#en + The linear offset from connected rigidbody to rigidbody. + !#zh + 关节另一端的刚体相对于起始端刚体的位置偏移量 */ + linearOffset: Vec2; + /** !#en + The angular offset from connected rigidbody to rigidbody. + !#zh + 关节另一端的刚体相对于起始端刚体的角度偏移量 */ + angularOffset: number; + /** !#en + The maximum force can be applied to rigidbody. + !#zh + 可以应用于刚体的最大的力值 */ + maxForce: number; + /** !#en + The maximum torque can be applied to rigidbody. + !#zh + 可以应用于刚体的最大扭矩值 */ + maxTorque: number; + /** !#en + The position correction factor in the range [0,1]. + !#zh + 位置矫正系数,范围为 [0, 1] */ + correctionFactor: number; + } + /** !#en + A mouse joint is used to make a point on a body track a + specified world point. This a soft constraint with a maximum + force. This allows the constraint to stretch and without + applying huge forces. + Mouse Joint will auto register the touch event with the mouse region node, + and move the choosed rigidbody in touch move event. + Note : generally mouse joint only used in test bed. + !#zh + 鼠标关节用于使刚体上的一个点追踪一个指定的世界坐标系下的位置。 + 鼠标关节可以指定一个最大的里来施加一个柔和的约束。 + 鼠标关节会自动使用 mouse region 节点来注册鼠标事件,并且在触摸移动事件中移动选中的刚体。 + 注意:一般鼠标关节只在测试环境中使用。 */ + export class MouseJoint extends Joint { + /** !#en + The anchor of the rigidbody. + !#zh + 刚体的锚点。 */ + anchor: Vec2; + /** !#en + The anchor of the connected rigidbody. + !#zh + 关节另一端刚体的锚点。 */ + connectedAnchor: Vec2; + /** !#en + The node used to register touch evnet. + If this is null, it will be the joint's node. + !#zh + 用于注册触摸事件的节点。 + 如果没有设置这个值,那么将会使用关节的节点来注册事件。 */ + mouseRegion: Node; + /** !#en + The target point. + The mouse joint will move choosed rigidbody to target point. + !#zh + 目标点,鼠标关节将会移动选中的刚体到指定的目标点 */ + target: Vec2; + /** !#en + The spring frequency. + !#zh + 弹簧系数。 */ + frequency: number; + /** !#en + The damping ratio. + !#zh + 阻尼,表示关节变形后,恢复到初始状态受到的阻力。 */ + 0: number; + /** !#en + The maximum force + !#zh + 最大阻力值 */ + maxForce: number; + } + /** !#en + A prismatic joint. This joint provides one degree of freedom: translation + along an axis fixed in rigidbody. Relative rotation is prevented. You can + use a joint limit to restrict the range of motion and a joint motor to + drive the motion or to model joint friction. + !#zh + 移动关节指定了只能在一个方向上移动刚体。 + 你可以开启关节限制来设置刚体运行移动的间距,也可以开启马达来使用关节马达驱动刚体的运行。 */ + export class PrismaticJoint extends Joint { + /** !#en + The local joint axis relative to rigidbody. + !#zh + 指定刚体可以移动的方向。 */ + localAxisA: Vec2; + /** !#en + The reference angle. + !#zh + 相对角度 */ + referenceAngle: number; + /** !#en + Enable joint distance limit? + !#zh + 是否开启关节的距离限制? */ + enableLimit: boolean; + /** !#en + Enable joint motor? + !#zh + 是否开启关节马达? */ + enableMotor: boolean; + /** !#en + The lower joint limit. + !#zh + 刚体能够移动的最小值 */ + lowerLimit: number; + /** !#en + The upper joint limit. + !#zh + 刚体能够移动的最大值 */ + upperLimit: number; + /** !#en + The maxium force can be applied to rigidbody to rearch the target motor speed. + !#zh + 可以施加到刚体的最大力。 */ + maxMotorForce: number; + /** !#en + The expected motor speed. + !#zh + 期望的马达速度。 */ + motorSpeed: number; + } + /** !#en + A revolute joint constrains two bodies to share a common point while they + are free to rotate about the point. The relative rotation about the shared + point is the joint angle. You can limit the relative rotation with + a joint limit that specifies a lower and upper angle. You can use a motor + to drive the relative rotation about the shared point. A maximum motor torque + is provided so that infinite forces are not generated. + !#zh + 旋转关节可以约束两个刚体围绕一个点来进行旋转。 + 你可以通过开启关节限制来限制旋转的最大角度和最小角度。 + 你可以通过开启马达来施加一个扭矩力来驱动这两个刚体在这一点上的相对速度。 */ + export class RevoluteJoint extends Joint { + /** !#en + The reference angle. + An angle between bodies considered to be zero for the joint angle. + !#zh + 相对角度。 + 两个物体之间角度为零时可以看作相等于关节角度 */ + referenceAngle: number; + /** !#en + The lower angle. + !#zh + 角度的最低限制。 */ + lowerAngle: number; + /** !#en + The upper angle. + !#zh + 角度的最高限制。 */ + upperAngle: number; + /** !#en + The maxium torque can be applied to rigidbody to rearch the target motor speed. + !#zh + 可以施加到刚体的最大扭矩。 */ + maxMotorTorque: number; + /** !#en + The expected motor speed. + !#zh + 期望的马达速度。 */ + motorSpeed: number; + /** !#en + Enable joint limit? + !#zh + 是否开启关节的限制? */ + enableLimit: boolean; + /** !#en + Enable joint motor? + !#zh + 是否开启关节马达? */ + enableMotor: boolean; + /** + !#en + Get the joint angle. + !#zh + 获取关节角度。 + */ + getJointAngle(): number; + } + /** !#en + A rope joint enforces a maximum distance between two points + on two bodies. It has no other effect. + Warning: if you attempt to change the maximum length during + the simulation you will get some non-physical behavior. + !#zh + 绳子关节只指定两个刚体间的最大距离,没有其他的效果。 + 注意:如果你试图动态修改关节的长度,这有可能会得到一些意外的效果。 */ + export class RopeJoint extends Joint { + /** !#en + The max length. + !#zh + 最大长度。 */ + maxLength: number; + } + /** !#en + A weld joint essentially glues two bodies together. A weld joint may + distort somewhat because the island constraint solver is approximate. + !#zh + 熔接关节相当于将两个刚体粘在了一起。 + 熔接关节可能会使某些东西失真,因为约束求解器算出的都是近似值。 */ + export class WeldJoint extends Joint { + /** !#en + The reference angle. + !#zh + 相对角度。 */ + referenceAngle: number; + /** !#en + The frequency. + !#zh + 弹性系数。 */ + frequency: number; + /** !#en + The damping ratio. + !#zh + 阻尼,表示关节变形后,恢复到初始状态受到的阻力。 */ + 0: number; + } + /** !#en + A wheel joint. This joint provides two degrees of freedom: translation + along an axis fixed in bodyA and rotation in the plane. You can use a joint motor to drive + the rotation or to model rotational friction. + This joint is designed for vehicle suspensions. + !#zh + 轮子关节提供两个维度的自由度:旋转和沿着指定方向上位置的移动。 + 你可以通过开启关节马达来使用马达驱动刚体的旋转。 + 轮组关节是专门为机动车类型设计的。 */ + export class WheelJoint extends Joint { + /** !#en + The local joint axis relative to rigidbody. + !#zh + 指定刚体可以移动的方向。 */ + localAxisA: Vec2; + /** !#en + The maxium torque can be applied to rigidbody to rearch the target motor speed. + !#zh + 可以施加到刚体的最大扭矩。 */ + maxMotorTorque: number; + /** !#en + The expected motor speed. + !#zh + 期望的马达速度。 */ + motorSpeed: number; + /** !#en + Enable joint motor? + !#zh + 是否开启关节马达? */ + enableMotor: boolean; + /** !#en + The spring frequency. + !#zh + 弹性系数。 */ + frequency: number; + /** !#en + The damping ratio. + !#zh + 阻尼,表示关节变形后,恢复到初始状态受到的阻力。 */ + dampingRatio: number; + } + /** undefined */ + export class PhysicsBoxCollider extends PhysicsCollider implements Collider.Box { + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Box size + !#zh 包围盒大小 */ + size: Size; + } + /** undefined */ + export class PhysicsChainCollider extends PolygonCollider { + /** !#en Whether the chain is loop + !#zh 链条是否首尾相连 */ + loop: boolean; + /** !#en Chain points + !#zh 链条顶点数组 */ + points: Vec2[]; + } + /** undefined */ + export class PhysicsCircleCollider extends PhysicsCollider implements Collider.Circle { + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Circle radius + !#zh 圆形半径 */ + radius: number; + } + /** undefined */ + export class PhysicsCollider extends Collider { + /** !#en + The density. + !#zh + 密度 */ + density: number; + /** !#en + A sensor collider collects contact information but never generates a collision response + !#zh + 一个传感器类型的碰撞体会产生碰撞回调,但是不会发生物理碰撞效果。 */ + sensor: boolean; + /** !#en + The friction coefficient, usually in the range [0,1]. + !#zh + 摩擦系数,取值一般在 [0, 1] 之间 */ + friction: number; + /** !#en + The restitution (elasticity) usually in the range [0,1]. + !#zh + 弹性系数,取值一般在 [0, 1]之间 */ + restitution: number; + /** !#en + Physics collider will find the rigidbody component on the node and set to this property. + !#zh + 碰撞体会在初始化时查找节点上是否存在刚体,如果查找成功则赋值到这个属性上。 */ + body: RigidBody; + /** + !#en + Apply current changes to collider, this will regenerate inner box2d fixtures. + !#zh + 应用当前 collider 中的修改,调用此函数会重新生成内部 box2d 的夹具。 + */ + apply(): void; + /** + !#en + Get the world aabb of the collider + !#zh + 获取碰撞体的世界坐标系下的包围盒 + */ + getAABB(): void; + } + /** undefined */ + export class PhysicsPolygonCollider extends PhysicsCollider implements Collider.Polygon { + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Polygon points + !#zh 多边形顶点数组 */ + points: Vec2[]; + } + /** !#en The shape module of 3d particle. + !#zh 3D 粒子的发射形状模块 */ + export class ShapeModule { + /** !#en The enable of shapeModule. + !#zh 是否启用 */ + enable: boolean; + /** !#en Particle emitter type. + !#zh 粒子发射器类型。 */ + shapeType: shapeModule.ShapeType; + /** !#en The emission site of the particle. + !#zh 粒子从发射器哪个部位发射。 */ + emitFrom: shapeModule.EmitLocation; + /** !#en Particle emitter radius. + !#zh 粒子发射器半径。 */ + radius: number; + /** !#en Particle emitter emission position (not valid for Box type emitters): + - 0 means emitted from the surface; + - 1 means launch from the center; + - 0 ~ 1 indicates emission from the center to the surface. + !#zh 粒子发射器发射位置(对 Box 类型的发射器无效): + - 0 表示从表面发射; + - 1 表示从中心发射; + - 0 ~ 1 之间表示在中心到表面之间发射。 */ + radiusThickness: number; + /** !#en The angle between the axis of the cone and the generatrix + Determines the opening and closing of the cone launcher + !#zh 圆锥的轴与母线的夹角。 + 决定圆锥发射器的开合程度。 */ + angle: number; + /** !#en Particle emitters emit in a fan-shaped range. + !#zh 粒子发射器在一个扇形范围内发射。 */ + arc: number; + /** !#en How particles are emitted in the sector range. + !#zh 粒子在扇形范围内的发射方式。 */ + arcMode: shapeModule.ArcMode; + /** !#en Controls the discrete intervals around the arcs where particles might be generated. + !#zh 控制可能产生粒子的弧周围的离散间隔。 */ + arcSpread: number; + /** !#en The speed at which particles are emitted around the circumference. + !#zh 粒子沿圆周发射的速度。 */ + arcSpeed: CurveRange; + /** !#en Axis length from top of cone to bottom of cone . + Determines the height of the cone emitter. + !#zh 圆锥顶部截面距离底部的轴长。 + 决定圆锥发射器的高度。 */ + length: number; + /** !#en Particle emitter emission location (for box-type particle emitters). + !#zh 粒子发射器发射位置(针对 Box 类型的粒子发射器。 */ + boxThickness: Vec3; + /** !#en Particle Emitter Position + !#zh 粒子发射器位置。 */ + position: Vec3; + /** !#en Particle emitter rotation angle. + !#zh 粒子发射器旋转角度。 */ + rotation: Vec3; + /** !#en Particle emitter scaling + !#zh 粒子发射器缩放比例。 */ + scale: Vec3; + /** !#en The direction of particle movement is determined based on the initial direction of the particles. + !#zh 根据粒子的初始方向决定粒子的移动方向。 */ + alignToDirection: boolean; + /** !#en Set particle generation direction randomly. + !#zh 粒子生成方向随机设定。 */ + randomDirectionAmount: number; + /** !#en Interpolation between the current emission direction and the direction from the current position to the center of the node. + !#zh 表示当前发射方向与当前位置到结点中心连线方向的插值。 */ + sphericalDirectionAmount: number; + } + /** !#en The color over time module of 3d particle. + !#zh 3D 粒子颜色变化模块 */ + export class ColorOvertimeModule { + /** !#en The enable of ColorOvertimeModule. + !#zh 是否启用 */ + enable: boolean; + } + /** !#en The curve range of target value. + !#zh 目标值的曲线范围 */ + export class CurveRange { + /** !#en Curve type. + !#zh 曲线类型。 */ + mode: debug.DebugMode; + /** !#en The curve to use when mode is Curve. + !#zh 当 mode 为 Curve 时,使用的曲线。 */ + curve: AnimationCurve; + /** !#en The lower limit of the curve to use when mode is TwoCurves + !#zh 当 mode 为 TwoCurves 时,使用的曲线下限。 */ + curveMin: AnimationCurve; + /** !#en The upper limit of the curve to use when mode is TwoCurves + !#zh 当 mode 为 TwoCurves 时,使用的曲线上限。 */ + curveMax: AnimationCurve; + /** !#en When mode is Constant, the value of the curve. + !#zh 当 mode 为 Constant 时,曲线的值。 */ + constant: number; + /** !#en The lower limit of the curve to use when mode is TwoConstants + !#zh 当 mode 为 TwoConstants 时,曲线的下限。 */ + constantMin: number; + /** !#en The upper limit of the curve to use when mode is TwoConstants + !#zh 当 mode 为 TwoConstants 时,曲线的上限。 */ + constantMax: number; + /** !#en Coefficients applied to curve interpolation. + !#zh 应用于曲线插值的系数。 */ + multiplier: number; + } + /** !#en The force over time module of 3d particle. + !#zh 3D 粒子的加速度模块 */ + export class ForceOvertimeModule { + /** !#en The enable of ColorOvertimeModule. + !#zh 是否启用 */ + enable: boolean; + /** !#en Coordinate system used in acceleration calculation. + !#zh 加速度计算时采用的坐标系。 */ + space: ParticleSystem3DAssembler.Space; + /** !#en X-axis acceleration component. + !#zh X 轴方向上的加速度分量。 */ + x: CurveRange; + /** !#en Y-axis acceleration component. + !#zh Y 轴方向上的加速度分量。 */ + y: CurveRange; + /** !#en Z-axis acceleration component. + !#zh Z 轴方向上的加速度分量。 */ + z: CurveRange; + } + /** !#en The gradient range of color. + !#zh 颜色值的渐变范围 */ + export class GradientRange { + /** !#en Gradient type. + !#zh 渐变色类型。 */ + mode: debug.DebugMode; + /** !#en The color when mode is Color. + !#zh 当 mode 为 Color 时的颜色。 */ + color: Color; + /** !#en Lower color limit when mode is TwoColors. + !#zh 当 mode 为 TwoColors 时的颜色下限。 */ + colorMin: Color; + /** !#en Upper color limit when mode is TwoColors. + !#zh 当 mode 为 TwoColors 时的颜色上限。 */ + colorMax: Color; + /** !#en Color gradient when mode is Gradient + !#zh 当 mode 为 Gradient 时的颜色渐变。 */ + gradient: Gradient; + /** !#en Lower color gradient limit when mode is TwoGradients. + !#zh 当 mode 为 TwoGradients 时的颜色渐变下限。 */ + gradientMin: Gradient; + /** !#en Upper color gradient limit when mode is TwoGradients. + !#zh 当 mode 为 TwoGradients 时的颜色渐变上限。 */ + gradientMax: Gradient; + } + /** !#en The color key of gradient. + !#zh color 关键帧 */ + export class ColorKey { + /** !#en Color value. + !#zh 颜色值。 */ + color: Color; + /** !#en Time value. + !#zh 时间值。 */ + time: number; + } + /** !#en The alpha key of gradient. + !#zh alpha 关键帧 */ + export class AlphaKey { + /** !#en Alpha value. + !#zh 透明度。 */ + alpha: number; + /** !#en Time. + !#zh 时间帧。 */ + time: number; + } + /** !#en The gradient data of color. + !#zh 颜色渐变数据 */ + export class Gradient { + /** !#en Array of color key. + !#zh 颜色关键帧列表。 */ + colorKeys: ColorKey[]; + /** !#en Array of alpha key. + !#zh 透明度关键帧列表。 */ + alphaKeys: AlphaKey[]; + /** !#en Blend mode. + !#zh 混合模式。 */ + mode: debug.DebugMode; + } + /** !#en The limit velocity module of 3d particle. + !#zh 3D 粒子的限速模块 */ + export class LimitVelocityOvertimeModule { + /** !#en The enable of LimitVelocityOvertimeModule. + !#zh 是否启用 */ + enable: boolean; + /** !#en The coordinate system used when calculating the lower speed limit. + !#zh 计算速度下限时采用的坐标系。 */ + space: ParticleSystem3DAssembler.Space; + /** !#en Whether to limit the three axes separately. + !#zh 是否三个轴分开限制。 */ + separateAxes: boolean; + /** !#en Lower speed limit + !#zh 速度下限。 */ + limit: CurveRange; + /** !#en Lower speed limit in X direction. + !#zh X 轴方向上的速度下限。 */ + limitX: CurveRange; + /** !#en Lower speed limit in Y direction. + !#zh Y 轴方向上的速度下限。 */ + limitY: CurveRange; + /** !#en Lower speed limit in Z direction. + !#zh Z 轴方向上的速度下限。 */ + limitZ: CurveRange; + /** !#en Interpolation of current speed and lower speed limit. + !#zh 当前速度与速度下限的插值。 */ + dampen: number; + } + /** !#en The optimized curve. + !#zh 优化曲线 */ + export class OptimizedCurve { + } + /** !#en The rotation module of 3d particle. + !#zh 3D 粒子的旋转模块 */ + export class RotationOvertimeModule { + /** !#en The enable of RotationOvertimeModule. + !#zh 是否启用 */ + enable: boolean; + /** !#en Whether to set the rotation of three axes separately (not currently supported) + !#zh 是否三个轴分开设定旋转(暂不支持)。 */ + separateAxes: boolean; + /** !#en Set rotation around X axis. + !#zh 绕 X 轴设定旋转。 */ + x: CurveRange; + /** !#en Set rotation around Y axis. + !#zh 绕 Y 轴设定旋转。 */ + y: CurveRange; + /** !#en Set rotation around Z axis. + !#zh 绕 Z 轴设定旋转。 */ + z: CurveRange; + } + /** !#en The size module of 3d particle. + !#zh 3D 粒子的大小模块 */ + export class SizeOvertimeModule { + /** !#en The enable of SizeOvertimeModule. + !#zh 是否启用 */ + enable: boolean; + /** !#en Decide whether to control particle size independently on each axis. + !#zh 决定是否在每个轴上独立控制粒子大小。 */ + separateAxes: boolean; + /** !#en Define a curve to determine the size change of particles during their life cycle. + !#zh 定义一条曲线来决定粒子在其生命周期中的大小变化。 */ + size: CurveRange; + /** !#en Defines a curve to determine the size change of particles in the X-axis direction during their life cycle. + !#zh 定义一条曲线来决定粒子在其生命周期中 X 轴方向上的大小变化。 */ + x: CurveRange; + /** !#en Defines a curve to determine the size change of particles in the Y-axis direction during their life cycle. + !#zh 定义一条曲线来决定粒子在其生命周期中 Y 轴方向上的大小变化。 */ + y: CurveRange; + /** !#en Defines a curve to determine the size change of particles in the Z-axis direction during their life cycle. + !#zh 定义一条曲线来决定粒子在其生命周期中 Z 轴方向上的大小变化。 */ + z: CurveRange; + } + /** !#en The texture animation module of 3d particle. + !#zh 3D 粒子的贴图动画模块 */ + export class TextureAnimationModule { + /** !#en The enable of TextureAnimationModule. + !#zh 是否启用 */ + enable: boolean; + /** !#en Set the type of particle map animation (only supports Grid mode for the time being) + !#zh 设定粒子贴图动画的类型(暂只支持 Grid 模式。 */ + mode: debug.DebugMode; + /** !#en Animation frames in X direction. + !#zh X 方向动画帧数。 */ + numTilesX: number; + /** !#en Animation frames in Y direction. + !#zh Y 方向动画帧数。 */ + numTilesY: number; + /** !#en The way of the animation plays. + !#zh 动画播放方式。 */ + animation: Animation; + /** !#en Randomly select a line from the animated map to generate the animation.
+ This option only takes effect when the animation playback mode is SingleRow. + !#zh 随机从动画贴图中选择一行以生成动画。
+ 此选项仅在动画播放方式为 SingleRow 时生效。 */ + randomRow: boolean; + /** !#en Select specific lines from the animation map to generate the animation.
+ This option is only available when the animation playback mode is SingleRow and randomRow is disabled. + !#zh 从动画贴图中选择特定行以生成动画。
+ 此选项仅在动画播放方式为 SingleRow 时且禁用 randomRow 时可用。 */ + rowIndex: number; + /** !#en Frame and time curve of animation playback in one cycle. + !#zh 一个周期内动画播放的帧与时间变化曲线。 */ + frameOverTime: CurveRange; + /** !#en Play from which frames, the time is the life cycle of the entire particle system. + !#zh 从第几帧开始播放,时间为整个粒子系统的生命周期。 */ + startFrame: CurveRange; + /** !#en Number of playback loops in a life cycle. + !#zh 一个生命周期内播放循环的次数。 */ + cycleCount: number; + } + /** !#en The velocity module of 3d particle. + !#zh 3D 粒子的速度模块 */ + export class VelocityOvertimeModule { + /** !#en The enable of VelocityOvertimeModule. + !#zh 是否启用 */ + enable: boolean; + /** !#en Coordinate system used in speed calculation. + !#zh 速度计算时采用的坐标系。 */ + space: ParticleSystem3DAssembler.Space; + /** !#en Velocity component in X axis direction + !#zh X 轴方向上的速度分量。 */ + x: CurveRange; + /** !#en Velocity component in Y axis direction + !#zh Y 轴方向上的速度分量。 */ + y: CurveRange; + /** !#en Velocity component in Z axis direction + !#zh Z 轴方向上的速度分量。 */ + z: CurveRange; + /** !#en Speed correction factor (only supports CPU particles). + !#zh 速度修正系数(只支持 CPU 粒子)。 */ + speedModifier: CurveRange; + } + /** !#en The trail module of 3d particle. + !#zh 3D 粒子拖尾模块 */ + export class TrailModule { + /** !#en The enable of trailModule. + !#zh 是否启用 */ + enable: boolean; + /** !#en Sets how particles generate trajectories. + !#zh 设定粒子生成轨迹的方式。 */ + mode: trailModule.TrailMode; + /** !#en Life cycle of trajectory. + !#zh 轨迹存在的生命周期。 */ + lifeTime: CurveRange; + /** !#en Minimum spacing between each track particle + !#zh 每个轨迹粒子之间的最小间距。 */ + minParticleDistance: number; + /** !#en The coordinate system of trajectories. + !#zh 轨迹设定时的坐标系。 */ + space: ParticleSystem3DAssembler.Space; + /** !#en Whether the particle itself exists. + !#zh 粒子本身是否存在。 */ + existWithParticles: boolean; + /** !#en Set the texture fill method + !#zh 设定纹理填充方式。 */ + textureMode: trailModule.TextureMode; + /** !#en Whether to use particle width + !#zh 是否使用粒子的宽度。 */ + widthFromParticle: boolean; + /** !#en Curves that control track length + !#zh 控制轨迹长度的曲线。 */ + widthRatio: CurveRange; + /** !#en Whether to use particle color + !#zh 是否使用粒子的颜色。 */ + colorFromParticle: boolean; + /** !#en The color of trajectories. + !#zh 轨迹的颜色。 */ + colorOverTrail: GradientRange; + /** !#en Trajectories color over time. + !#zh 轨迹随时间变化的颜色。 */ + colorOvertime: GradientRange; + } + /** Rigid body interface */ + export class IRigidBody { + rigidBody: RigidBody3D; + mass: number; + linearDamping: number; + angularDamping: number; + isKinematic: boolean; + useGravity: boolean; + fixedRotation: boolean; + linearFactor: IVec3Like; + angularFactor: IVec3Like; + allowSleep: boolean; + isAwake: boolean; + isSleepy: boolean; + isSleeping: boolean; + wakeUp(): void; + sleep(): void; + /** + + @param out out + */ + getLinearVelocity(out: IVec3Like): void; + /** + + @param out out + */ + setLinearVelocity(out: IVec3Like): void; + /** + + @param out out + */ + getAngularVelocity(out: IVec3Like): void; + /** + + @param out out + */ + setAngularVelocity(out: IVec3Like): void; + /** + + @param force force + @param relativePoint relativePoint + */ + applyForce(force: IVec3Like, relativePoint: IVec3Like): void; + /** + + @param force force + @param relativePoint relativePoint + */ + applyLocalForce(force: IVec3Like, relativePoint: IVec3Like): void; + /** + + @param force force + @param relativePoint relativePoint + */ + applyImpulse(force: IVec3Like, relativePoint: IVec3Like): void; + /** + + @param force force + @param relativePoint relativePoint + */ + applyLocalImpulse(force: IVec3Like, relativePoint: IVec3Like): void; + /** + + @param torque torque + */ + applyTorque(torque: IVec3Like): void; + /** + + @param torque torque + */ + applyLocalTorque(torque: IVec3Like): void; + } + /** Class has x y z properties */ + export class IVec3Like { + x: number; + y: number; + z: number; + } + /** Class has x y z w properties */ + export class IQuatLike { + x: number; + y: number; + z: number; + w: number; + } + /** !#en Base shape interface. */ + export class IBaseShape { + collider: Collider3D; + attachedRigidBody: RigidBody3D|void; + material: any; + isTrigger: boolean; + center: IVec3Like; + } + /** !#en box shape interface */ + export class IBoxShape { + size: IVec3Like; + } + /** !#en Sphere shape interface */ + export class ISphereShape { + radius: number; + } + /** Ray cast options */ + export class IRaycastOptions { + groupIndex: number; + queryTrigger: boolean; + maxDistance: number; + } + /** Collision detect */ + export class ICollisionDetect { + /** + Ray cast, and return information of the closest hit. + @param worldRay worldRay + @param options options + @param out out + */ + raycastClosest(worldRay: geomUtils.Ray, options: IRaycastOptions, out: PhysicsRayResult): boolean; + /** + Ray cast against all bodies. The provided callback will be executed for each hit with a RaycastResult as single argument. + @param worldRay worldRay + @param options options + @param pool pool + @param resultes resultes + */ + raycast(worldRay: geomUtils.Ray, options: IRaycastOptions, pool: RecyclePool, resultes: PhysicsRayResult[]): boolean; + } + /** Physics world interface */ + export class IPhysicsWorld { + } + /** !#en The rigid body type + !#zh 刚体类型 */ + export enum ERigidBodyType { + DYNAMIC = 0, + STATIC = 0, + KINEMATIC = 0, + } + /** !#en + Trigger event + !#zh + 触发事件。 */ + export class ITriggerEvent { + /** !#en + The type of event fired + !#zh + 触发的事件类型 */ + type: string; + /** !#en + Triggers its own collider in the event + !#zh + 触发事件中的自己的碰撞器 */ + selfCollider: Collider3D; + /** !#en + Triggers another collider in the event + !#zh + 触发事件中的另一个碰撞器 */ + otherCollider: Collider3D; + } + /** !#en + Collision information for collision events. + !#zh + 碰撞事件的碰撞信息。 */ + export class IContactEquation { + /** !#en + The collision point A in the collision information. + !#zh + 碰撞信息中的碰撞点 A。 */ + contactA: Vec3; + /** !#en + Collision point B in collision information. + !#zh + 碰撞信息中的碰撞点 B。 */ + contactB: Vec3; + /** !#en + Normals in collision information. + !#zh + 碰撞信息中的法线。 */ + normal: Vec3; + } + /** !#en + Collision events. + !#zh + 碰撞事件。 */ + export class ICollisionEvent { + /** !#en + Event type of collision. + !#zh + 碰撞的事件类型。 */ + type: string; + /** !#en + Collider of its own in collision. + !#zh + 碰撞中的自己的碰撞器。 */ + selfCollider: Collider3D; + /** !#en + Another collider in the collision. + !#zh + 碰撞中的另一个碰撞器。 */ + otherCollider: Collider3D; + /** !#en + Information about all the points of impact in the collision. + !#zh + 碰撞中的所有碰撞点的信息。 */ + contacts: IContactEquation[]; + } + /** !#en + Physical systems manager. + !#zh + 物理系统管理器。 */ + export class Physics3DManager { + /** !#en + Whether to enable the physics system, default is false. + !#zh + 是否启用物理系统,默认不启用。 */ + enabled: boolean; + /** !#en + Whether to allow the physics system to automatically hibernate, default is true. + !#zh + 物理系统是否允许自动休眠,默认为 true。 */ + allowSleep: boolean; + /** !#en + The maximum number of sub-steps a full step is permitted to be broken into, default is 2. + !#zh + 物理每帧模拟的最大子步数,默认为 2。 */ + maxSubStep: number; + /** !#en + Time spent in each simulation of physics, default is 1/60s. + !#zh + 物理每步模拟消耗的固定时间,默认为 1/60 秒。 */ + deltaTime: number; + /** !#en + Whether to use a fixed time step. + !#zh + 是否使用固定的时间步长。 */ + useFixedTime: boolean; + /** !#en + Gravity value of the physics simulation, default is (0, -10, 0). + !#zh + 物理世界的重力数值,默认为 (0, -10, 0)。 */ + gravity: Vec3; + /** !#en + Gets the global default physical material. Note that builtin is null. + !#zh + 获取全局的默认物理材质,注意:builtin 时为 null。 */ + defaultMaterial: PhysicsMaterial|void; + /** + !#en + A physical system simulation is performed once and will now be performed automatically once per frame. + !#zh + 执行一次物理系统的模拟,目前将在每帧自动执行一次。 + @param deltaTime The time difference from the last execution is currently elapsed per frame + */ + update(deltaTime: number): void; + /** + !#en Detect all collision boxes and return all detected results, or null if none is detected. Note that the return value is taken from the object pool, so do not save the result reference or modify the result. + !#zh 检测所有的碰撞盒,并返回所有被检测到的结果,若没有检测到,则返回空值。注意返回值是从对象池中取的,所以请不要保存结果引用或者修改结果。 + @param worldRay A ray in world space + @param groupIndexOrName Collision group index or group name + @param maxDistance Maximum detection distance + @param queryTrigger Detect trigger or not + */ + raycast(worldRay: geomUtils.Ray, groupIndexOrName: number|string, maxDistance: number, queryTrigger: boolean): PhysicsRayResult[]; + /** + !#en Detect all collision boxes and return the detection result with the shortest ray distance. If not, return null value. Note that the return value is taken from the object pool, so do not save the result reference or modify the result. + !#zh 检测所有的碰撞盒,并返回射线距离最短的检测结果,若没有,则返回空值。注意返回值是从对象池中取的,所以请不要保存结果引用或者修改结果。 + @param worldRay A ray in world space + @param groupIndexOrName Collision group index or group name + @param maxDistance Maximum detection distance + @param queryTrigger Detect trigger or not + */ + raycastClosest(worldRay: geomUtils.Ray, groupIndexOrName: number|string, maxDistance: number, queryTrigger: boolean): PhysicsRayResult; + } + /** !#en + Used to store physical ray detection results + !#zh + 用于保存物理射线检测结果 */ + export class PhysicsRayResult { + /** !#en + Hit the point + !#zh + 击中点 */ + hitPoint: Vec3; + /** !#en + Distance + !#zh + 距离 */ + distance: number; + /** !#en + Hit the collision box + !#zh + 击中的碰撞盒 */ + collider: Collider3D; + /** + !#en + Set up ray. This method is used internally by the engine. Do not call it from an external script + !#zh + 设置射线,此方法由引擎内部使用,请勿在外部脚本调用 + @param hitPoint hitPoint + @param distance distance + @param collider collider + */ + _assign(hitPoint: Vec3, distance: number, collider: Collider3D): void; + /** + !#en + Clone + !#zh + 克隆 + */ + clone(): void; + } + /** !#en Manage Dynamic Atlas Manager. Dynamic Atlas Manager is used for merging textures at runtime, see [Dynamic Atlas](https://docs.cocos.com/creator/manual/en/advanced-topics/dynamic-atlas.html) for details. + !#zh 管理动态图集。动态图集用于在运行时对贴图进行合并,详见 [动态合图](https://docs.cocos.com/creator/manual/zh/advanced-topics/dynamic-atlas.html)。 */ + export class DynamicAtlasManager { + /** !#en Enable or disable the dynamic atlas, see [Dynamic Atlas](https://docs.cocos.com/creator/manual/en/advanced-topics/dynamic-atlas.html) for details. + !#zh 开启或者关闭动态图集,详见 [动态合图](https://docs.cocos.com/creator/manual/zh/advanced-topics/dynamic-atlas.html)。 */ + enabled: boolean; + /** !#en The maximum number of atlas that can be created. + !#zh 可以创建的最大图集数量。 */ + maxAtlasCount: number; + /** !#en Is enable textureBleeding. + !#zh 是否开启 textureBleeding */ + textureBleeding: boolean; + /** !#en The size of the atlas that was created + !#zh 创建的图集的宽高 */ + textureSize: number; + /** !#en The maximum size of the picture that can be added to the atlas. + !#zh 可以添加进图集的图片的最大尺寸。 */ + maxFrameSize: number; + /** !#en The minimum size of the picture that can be added to the atlas. + !#zh 可以添加进图集的图片的最小尺寸。 */ + minFrameSize: number; + /** + !#en Append a sprite frame into the dynamic atlas. + !#zh 添加碎图进入动态图集。 + @param spriteFrame spriteFrame + */ + insertSpriteFrame(spriteFrame: SpriteFrame): void; + /** + !#en Resets all dynamic atlas, and the existing ones will be destroyed. + !#zh 重置所有动态图集,已有的动态图集会被销毁。 + */ + reset(): void; + /** + !#en Displays all the dynamic atlas in the current scene, which you can use to view the current atlas state. + !#zh 在当前场景中显示所有动态图集,可以用来查看当前的合图状态。 + @param show show + */ + showDebug(show: boolean): Node; + } + /** !#en + RigidBody is the basic object that make up the physical world, and it can make a node physically affected and react. + !#zh + 刚体是组成物理世界的基本对象,可以让一个节点受到物理影响并产生反应。该组件在使用 Builtin 物理引擎时无效。 */ + export class RigidBody3D extends Component { + /** !#en + Whether sleep is allowed. + !#zh + 是否允许休眠。 */ + allowSleep: boolean; + /** !#en + The mass of the rigidbody. + !#zh + 刚体的质量。 */ + mass: number; + /** !#en + Used to reduce the linear rate of rigidbody. The larger the value, the slower the rigidbody moves. + !#zh + 线性阻尼,用于减小刚体的线性速率,值越大物体移动越慢。 */ + linearDamping: number; + /** !#en + Used to reduce the rotation rate of rigidbody. The larger the value, the slower the rigidbody rotates. + !#zh + 角阻尼,用于减小刚体的旋转速率,值越大刚体旋转越慢。 */ + angularDamping: number; + /** !#en + If enabled, the developer controls the displacement and rotation of the rigidbody, not the physics engine. + !#zh + 是否由开发者来控制刚体的位移和旋转,而不是受物理引擎的影响。 */ + isKinematic: boolean; + /** !#en + If enabled, the rigidbody is affected by gravity. + !#zh + 如果开启,刚体会受到重力影响。 */ + useGravity: boolean; + /** !#en + If enabled, the rigidbody will be fixed without rotation during a collision. + !#zh + 如果开启,发生碰撞时会固定刚体不产生旋转。 */ + fixedRotation: boolean; + /** !#en + It can affect the linear velocity change of the rigidbody in each axis. The larger the value, the faster the rigidbody moves. + !#zh + 线性因子,可影响刚体在每个轴向的线性速度变化,值越大刚体移动越快。 */ + linearFactor: Vec3; + /** !#en + It can affect the rotation speed change of the rigidbody in each axis. The larger the value, the faster the rigidbody rotates. + !#zh + 旋转因子,可影响刚体在每个轴向的旋转速度变化,值越大刚体旋转越快。 */ + angularFactor: Vec3; + /** !#en + The rigidbody is awake. + !#zh + 刚体是否为唤醒的状态。 */ + isAwake: boolean; + /** !#en + The rigidbody can enter hibernation. + !#zh + 刚体是否为可进入休眠的状态。 */ + isSleepy: boolean; + /** !#en + The rigidbody is sleeping. + !#zh + 刚体是否为正在休眠的状态。 */ + isSleeping: boolean; + /** !#en + Get the rigidbody object inside the physics engine. + !#zh + 获得物理引擎内部刚体对象。 */ + rigidBody: IRigidBody; + /** + !#en + A force is applied to a rigid body at a point in world space. + !#zh + 在世界空间中的某点上对刚体施加一个作用力。 + @param force force + @param relativePoint The point of action, relative to the center of the rigid body. + */ + applyForce(force: Vec3, relativePoint: Vec3): void; + /** + !#en + Apply a force on the rigid body at a point in local space. + !#zh + 在本地空间中的某点上对刚体施加一个作用力。 + @param force force + @param localPoint Point of application + */ + applyLocalForce(force: Vec3, localPoint: Vec3): void; + /** + !#en + Apply an impulse to a rigid body at a point in world space. + !#zh + 在世界空间的某点上对刚体施加一个冲量。 + @param impulse impulse + @param relativePoint The point of action, relative to the center of the rigid body. + */ + applyImpulse(impulse: Vec3, relativePoint: Vec3): void; + /** + !#en + Apply an impulse to the rigid body at a point in local space. + !#zh + 在本地空间的某点上对刚体施加一个冲量。 + @param impulse impulse + @param localPoint Point of application + */ + applyLocalImpulse(impulse: Vec3, localPoint: Vec3): void; + /** + !#en + Apply a torque to the rigid body. + !#zh + 对刚体施加扭转力。 + @param torque torque + */ + applyTorque(torque: Vec3): void; + /** + !#en + Apply a local torque to the rigid body. + !#zh + 对刚体施加本地扭转力。 + @param torque torque + */ + applyLocalTorque(torque: Vec3): void; + /** + !#en + Awaken the rigid body. + !#zh + 唤醒刚体。 + */ + wakeUp(): void; + /** + !#en + Dormant rigid body. + !#zh + 休眠刚体。 + */ + sleep(): void; + /** + !#en + Get linear velocity. + !#zh + 获取线性速度。 + @param out out + */ + getLinearVelocity(out: Vec3): void; + /** + !#en + Set linear speed. + !#zh + 设置线性速度。 + @param value value + */ + setLinearVelocity(value: Vec3): void; + /** + !#en + Gets the rotation speed. + !#zh + 获取旋转速度。 + @param out out + */ + getAngularVelocity(out: Vec3): void; + /** + !#en + Set rotation speed. + !#zh + 设置旋转速度。 + @param value value + */ + setAngularVelocity(value: Vec3): void; + } + /** !#en + Each frame applies a constant force to a rigid body, depending on the RigidBody3D + !#zh + 在每帧对一个刚体施加持续的力,依赖 RigidBody3D 组件 */ + export class ConstantForce extends Component { + /** !#en + Set the force used in the world coordinate system, use `this.force = otherVec3`. + !#zh + 设置世界坐标系中使用的力,设置时请用 `this.force = otherVec3` 的方式。 */ + force: Vec3; + /** !#en + Set the force used in the local coordinate system, using `this.localforce = otherVec3`. + !#zh + 获取和设置本地坐标系中使用的力,设置时请用 `this.localForce = otherVec3` 的方式。 */ + localForce: Vec3; + /** !#en + Torque applied to the world orientation + !#zh + 对世界朝向施加的扭矩 */ + torque: Vec3; + /** !#en + Torque applied to local orientation, using `this.localtorque = otherVec3`. + !#zh + 对本地朝向施加的扭矩,设置时请用 `this.localTorque = otherVec3` 的方式。 */ + localTorque: Vec3; + } + /** !#en + Physics material. + !#zh + 物理材质。 */ + export class PhysicsMaterial extends Asset { + /** !#en + Friction for this material. + !#zh + 物理材质的摩擦力。 */ + friction: number; + /** !#en + Restitution for this material. + !#zh + 物理材质的弹力。 */ + restitution: number; + } + /** !#en + Physics box collider + !#zh + 物理盒子碰撞器 */ + export class BoxCollider3D extends Collider3D { + /** !#en + Get or set the size of the box, in local space. + !#zh + 获取或设置盒的大小。 */ + size: Vec3; + boxShape: IBoxShape; + } + /** !#en + The base class of the collider. + !#zh + 碰撞器的基类。 */ + export class Collider3D extends Component implements EventTarget { + sharedMaterial: PhysicsMaterial; + /** !#en + get or set the collider is trigger, this will be always trigger if using builtin. + !#zh + 获取或设置碰撞器是否为触发器。 */ + isTrigger: boolean; + /** !#en + get or set the center of the collider, in local space. + !#zh + 获取或设置碰撞器的中心点。 */ + center: Vec3; + /** !#en + get the collider attached rigidbody, this may be null. + !#zh + 获取碰撞器所绑定的刚体组件,可能为 null。 */ + attachedRigidbody: RigidBody3D|void; + /** !#en + get collider shape. + !#zh + 获取碰撞器形状。 */ + shape: IBaseShape; + /** + !#en + Register an callback of a specific event type on the EventTarget. + This type of event should be triggered via `emit`. + !#zh + 注册事件目标的特定事件类型回调。这种类型的事件应该被 `emit` 触发。 + @param type The type of collider event can be `trigger-enter`, `trigger-stay`, `trigger-exit` or `collision-enter`, `collision-stay`, `collision-exit`. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null. + + @example + ```js + eventTarget.on('fire', function (event) { + // event is ITriggerEvent or ICollisionEvent + }, node); + ``` + */ + on(type: string, callback: T, target?: any, useCapture?: boolean): T; + /** + !#en + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. + !#zh + 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。 + @param type The type of collider event can be `trigger-enter`, `trigger-stay`, `trigger-exit` or `collision-enter`, `collision-stay`, `collision-exit`. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed. + + @example + ```js + // register fire eventListener + var callback = eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, target); + // remove fire event listener + eventTarget.off('fire', callback, target); + // remove all fire event listeners + eventTarget.off('fire'); + ``` + */ + off(type: string, callback?: Function, target?: any): void; + /** + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。 + @param type The type of collider event can be `trigger-enter`, `trigger-stay`, `trigger-exit` or `collision-enter`, `collision-stay`, `collision-exit`. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null. + + @example + ```js + eventTarget.once('fire', function (event) { + // event is ITriggerEvent or ICollisionEvent + }, node); + ``` + */ + once(type: string, callback: (event: ITriggerEvent|ICollisionEvent) => void, target?: any): void; + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh 检查事件目标对象是否有为特定类型的事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 + 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 + 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。 + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Send an event with the event object. + !#zh + 通过事件对象派发事件 + @param event event + */ + dispatchEvent(event: Event): void; + /** + !#en + Destroy all callbackInfos. + !#zh + 销毁记录的事件 + */ + clear(): void; + } + /** !#en + Physics sphere collider + !#zh + 物理球碰撞器 */ + export class SphereCollider3D extends Collider3D { + /** !#en + Get or set the radius of the sphere. + !#zh + 获取或设置球的半径。 */ + radius: number; + sphereShape: ISphereShape; + } + /**************************************************** + * audioEngine + *****************************************************/ + + export namespace audioEngine { + /** !#en Audio state. + !#zh 声音播放状态 */ + export enum AudioState { + ERROR = 0, + INITIALZING = 0, + PLAYING = 0, + PAUSED = 0, + STOPPED = 0, + } + } + + /**************************************************** + * debug + *****************************************************/ + + export namespace debug { + /** !#en Enum for debug modes. + !#zh 调试模式 */ + export enum DebugMode { + NONE = 0, + INFO = 0, + WARN = 0, + ERROR = 0, + INFO_FOR_WEB_PAGE = 0, + WARN_FOR_WEB_PAGE = 0, + ERROR_FOR_WEB_PAGE = 0, + } + } + + /**************************************************** + * Node + *****************************************************/ + + export namespace Node { + /** !#en Node's local dirty properties flag + !#zh Node 的本地属性 dirty 状态位 */ + export enum _LocalDirtyFlag { + POSITION = 0, + SCALE = 0, + ROTATION = 0, + SKEW = 0, + TRS = 0, + RS = 0, + TRS = 0, + PHYSICS_POSITION = 0, + PHYSICS_SCALE = 0, + PHYSICS_ROTATION = 0, + PHYSICS_TRS = 0, + PHYSICS_RS = 0, + ALL_POSITION = 0, + ALL_SCALE = 0, + ALL_ROTATION = 0, + ALL_TRS = 0, + ALL = 0, + } + } + + /**************************************************** + * Node + *****************************************************/ + + export namespace Node { + /** !#en The event type supported by Node + !#zh Node 支持的事件类型 */ + export class EventType { + /** !#en The event type for touch start event, you can use its value directly: 'touchstart' + !#zh 当手指触摸到屏幕时。 */ + static TOUCH_START: string; + /** !#en The event type for touch move event, you can use its value directly: 'touchmove' + !#zh 当手指在屏幕上移动时。 */ + static TOUCH_MOVE: string; + /** !#en The event type for touch end event, you can use its value directly: 'touchend' + !#zh 当手指在目标节点区域内离开屏幕时。 */ + static TOUCH_END: string; + /** !#en The event type for touch end event, you can use its value directly: 'touchcancel' + !#zh 当手指在目标节点区域外离开屏幕时。 */ + static TOUCH_CANCEL: string; + /** !#en The event type for mouse down events, you can use its value directly: 'mousedown' + !#zh 当鼠标按下时触发一次。 */ + static MOUSE_DOWN: string; + /** !#en The event type for mouse move events, you can use its value directly: 'mousemove' + !#zh 当鼠标在目标节点在目标节点区域中移动时,不论是否按下。 */ + static MOUSE_MOVE: string; + /** !#en The event type for mouse enter target events, you can use its value directly: 'mouseenter' + !#zh 当鼠标移入目标节点区域时,不论是否按下。 */ + static MOUSE_ENTER: string; + /** !#en The event type for mouse leave target events, you can use its value directly: 'mouseleave' + !#zh 当鼠标移出目标节点区域时,不论是否按下。 */ + static MOUSE_LEAVE: string; + /** !#en The event type for mouse up events, you can use its value directly: 'mouseup' + !#zh 当鼠标从按下状态松开时触发一次。 */ + static MOUSE_UP: string; + /** !#en The event type for mouse wheel events, you can use its value directly: 'mousewheel' + !#zh 当鼠标滚轮滚动时。 */ + static MOUSE_WHEEL: string; + /** !#en The event type for position change events. + Performance note, this event will be triggered every time corresponding properties being changed, + if the event callback have heavy logic it may have great performance impact, try to avoid such scenario. + !#zh 当节点位置改变时触发的事件。 + 性能警告:这个事件会在每次对应的属性被修改时触发,如果事件回调损耗较高,有可能对性能有很大的负面影响,请尽量避免这种情况。 */ + static POSITION_CHANGED: string; + /** !#en The event type for rotation change events. + Performance note, this event will be triggered every time corresponding properties being changed, + if the event callback have heavy logic it may have great performance impact, try to avoid such scenario. + !#zh 当节点旋转改变时触发的事件。 + 性能警告:这个事件会在每次对应的属性被修改时触发,如果事件回调损耗较高,有可能对性能有很大的负面影响,请尽量避免这种情况。 */ + static ROTATION_CHANGED: string; + /** !#en The event type for scale change events. + Performance note, this event will be triggered every time corresponding properties being changed, + if the event callback have heavy logic it may have great performance impact, try to avoid such scenario. + !#zh 当节点缩放改变时触发的事件。 + 性能警告:这个事件会在每次对应的属性被修改时触发,如果事件回调损耗较高,有可能对性能有很大的负面影响,请尽量避免这种情况。 */ + static SCALE_CHANGED: string; + /** !#en The event type for size change events. + Performance note, this event will be triggered every time corresponding properties being changed, + if the event callback have heavy logic it may have great performance impact, try to avoid such scenario. + !#zh 当节点尺寸改变时触发的事件。 + 性能警告:这个事件会在每次对应的属性被修改时触发,如果事件回调损耗较高,有可能对性能有很大的负面影响,请尽量避免这种情况。 */ + static SIZE_CHANGED: string; + /** !#en The event type for anchor point change events. + Performance note, this event will be triggered every time corresponding properties being changed, + if the event callback have heavy logic it may have great performance impact, try to avoid such scenario. + !#zh 当节点锚点改变时触发的事件。 + 性能警告:这个事件会在每次对应的属性被修改时触发,如果事件回调损耗较高,有可能对性能有很大的负面影响,请尽量避免这种情况。 */ + static ANCHOR_CHANGED: string; + /** !#en The event type for color change events. + Performance note, this event will be triggered every time corresponding properties being changed, + if the event callback have heavy logic it may have great performance impact, try to avoid such scenario. + !#zh 当节点颜色改变时触发的事件。 + 性能警告:这个事件会在每次对应的属性被修改时触发,如果事件回调损耗较高,有可能对性能有很大的负面影响,请尽量避免这种情况。 */ + static COLOR_CHANGED: string; + /** !#en The event type for new child added events. + !#zh 当新的子节点被添加时触发的事件。 */ + static CHILD_ADDED: string; + /** !#en The event type for child removed events. + !#zh 当子节点被移除时触发的事件。 */ + static CHILD_REMOVED: string; + /** !#en The event type for children reorder events. + !#zh 当子节点顺序改变时触发的事件。 */ + static CHILD_REORDER: string; + /** !#en The event type for node group changed events. + !#zh 当节点归属群组发生变化时触发的事件。 */ + static GROUP_CHANGED: string; + /** !#en The event type for node's sibling order changed. + !#zh 当节点在兄弟节点中的顺序发生变化时触发的事件。 */ + static SIBLING_ORDER_CHANGED: string; + } + } + + /**************************************************** + * ParticleSystem + *****************************************************/ + + export namespace ParticleSystem { + /** !#en Enum for emitter modes + !#zh 发射模式 */ + export enum EmitterMode { + GRAVITY = 0, + RADIUS = 0, + } + } + + /**************************************************** + * ParticleSystem + *****************************************************/ + + export namespace ParticleSystem { + /** !#en Enum for particles movement type. + !#zh 粒子位置类型 */ + export enum PositionType { + FREE = 0, + RELATIVE = 0, + GROUPED = 0, + } + } + + /**************************************************** + * VideoPlayer + *****************************************************/ + + export namespace VideoPlayer { + /** !#en Video event type + !#zh 视频事件类型 */ + export enum EventType { + PLAYING = 0, + PAUSED = 0, + STOPPED = 0, + COMPLETED = 0, + META_LOADED = 0, + CLICKED = 0, + READY_TO_PLAY = 0, + } + } + + /**************************************************** + * VideoPlayer + *****************************************************/ + + export namespace VideoPlayer { + /** !#en Enum for video resouce type type. + !#zh 视频来源 */ + export enum ResourceType { + REMOTE = 0, + LOCAL = 0, + } + } + + /**************************************************** + * TiledMap + *****************************************************/ + + export namespace TiledMap { + /** !#en The orientation of tiled map. + !#zh Tiled Map 地图方向。 */ + export enum Orientation { + ORTHO = 0, + HEX = 0, + ISO = 0, + } + } + + /**************************************************** + * TiledMap + *****************************************************/ + + export namespace TiledMap { + /** The property type of tiled map. */ + export enum Property { + NONE = 0, + MAP = 0, + LAYER = 0, + OBJECTGROUP = 0, + OBJECT = 0, + TILE = 0, + } + } + + /**************************************************** + * TiledMap + *****************************************************/ + + export namespace TiledMap { + /** The tile flags of tiled map. */ + export enum TileFlag { + HORIZONTAL = 0, + VERTICAL = 0, + DIAGONAL = 0, + FLIPPED_ALL = 0, + FLIPPED_MASK = 0, + } + } + + /**************************************************** + * TiledMap + *****************************************************/ + + export namespace TiledMap { + /** !#en The stagger axis of Hex tiled map. + !#zh 六边形地图的 stagger axis 值 */ + export enum StaggerAxis { + STAGGERAXIS_X = 0, + STAGGERAXIS_Y = 0, + } + } + + /**************************************************** + * TiledMap + *****************************************************/ + + export namespace TiledMap { + /** !#en The render order of tiled map. + !#zh 地图的渲染顺序 */ + export enum RenderOrder { + STAGGERINDEX_ODD = 0, + STAGGERINDEX_EVEN = 0, + RightDown = 0, + RightUp = 0, + LeftDown = 0, + LeftUp = 0, + } + } + + /**************************************************** + * TiledMap + *****************************************************/ + + export namespace TiledMap { + /** !#en TiledMap Object Type + !#zh 地图物体类型 */ + export enum TMXObjectType { + RECT = 0, + ELLIPSE = 0, + POLYGON = 0, + POLYLINE = 0, + IMAGE = 0, + TEXT = 0, + } + } + + /**************************************************** + * WebView + *****************************************************/ + + export namespace WebView { + /** !#en WebView event type + !#zh 网页视图事件类型 */ + export enum EventType { + LOADED = 0, + LOADING = 0, + ERROR = 0, + } + } + + /**************************************************** + * Camera + *****************************************************/ + + export namespace Camera { + /** !#en Values for Camera.clearFlags, determining what to clear when rendering a Camera. + !#zh 摄像机清除标记位,决定摄像机渲染时会清除哪些状态 */ + export enum ClearFlags { + COLOR = 0, + DEPTH = 0, + STENCIL = 0, + } + } + + /**************************************************** + * Light + *****************************************************/ + + export namespace Light { + /** !#en The light source type + + !#zh 光源类型 */ + export enum Type { + DIRECTIONAL = 0, + POINT = 0, + SPOT = 0, + AMBIENT = 0, + } + } + + /**************************************************** + * Light + *****************************************************/ + + export namespace Light { + /** !#en The shadow type + + !#zh 阴影类型 */ + export enum ShadowType { + NONE = 0, + HARD = 0, + SOFT_PCF3X3 = 0, + SOFT_PCF5X5 = 0, + } + } + + /**************************************************** + * Prefab + *****************************************************/ + + export namespace Prefab { + /** !#zh + Prefab 创建实例所用的优化策略,配合 {{#crossLink "Prefab.optimizationPolicy"}}cc.Prefab#optimizationPolicy{{/crossLink}} 使用。 + !#en + An enumeration used with the {{#crossLink "Prefab.optimizationPolicy"}}cc.Prefab#optimizationPolicy{{/crossLink}} + to specify how to optimize the instantiate operation. */ + export enum OptimizationPolicy { + AUTO = 0, + SINGLE_INSTANCE = 0, + MULTI_INSTANCE = 0, + } + } + + /**************************************************** + * RenderTexture + *****************************************************/ + + export namespace RenderTexture { + /** !#en The depth buffer and stencil buffer format for RenderTexture. + !#zh RenderTexture 的深度缓冲以及模板缓冲格式。 */ + export enum DepthStencilFormat { + RB_FMT_D24S8 = 0, + RB_FMT_S8 = 0, + RB_FMT_D16 = 0, + } + } + + /**************************************************** + * Texture2D + *****************************************************/ + + export namespace Texture2D { + /** The texture pixel format, default value is RGBA8888, + you should note that textures loaded by normal image files (png, jpg) can only support RGBA8888 format, + other formats are supported by compressed file types or raw data. */ + export enum PixelFormat { + RGB565 = 0, + RGB5A1 = 0, + RGBA4444 = 0, + RGB888 = 0, + RGBA8888 = 0, + RGBA32F = 0, + A8 = 0, + I8 = 0, + AI88 = 0, + RGB_PVRTC_2BPPV1 = 0, + RGBA_PVRTC_2BPPV1 = 0, + RGB_A_PVRTC_2BPPV1 = 0, + RGB_PVRTC_4BPPV1 = 0, + RGBA_PVRTC_4BPPV1 = 0, + RGB_A_PVRTC_4BPPV1 = 0, + RGB_ETC1 = 0, + RGBA_ETC1 = 0, + RGB_ETC2 = 0, + RGBA_ETC2 = 0, + } + } + + /**************************************************** + * Texture2D + *****************************************************/ + + export namespace Texture2D { + /** The texture wrap mode */ + export enum WrapMode { + REPEAT = 0, + CLAMP_TO_EDGE = 0, + MIRRORED_REPEAT = 0, + } + } + + /**************************************************** + * Texture2D + *****************************************************/ + + export namespace Texture2D { + /** The texture filter mode */ + export enum Filter { + LINEAR = 0, + NEAREST = 0, + } + } + + /**************************************************** + * Event + *****************************************************/ + + export namespace Event { + /** !#en The Custom event + !#zh 自定义事件 */ + export class EventCustom extends Event { + /** + + @param type The name of the event (case-sensitive), e.g. "click", "fire", or "submit" + @param bubbles A boolean indicating whether the event bubbles up through the tree or not + */ + constructor(type: string, bubbles: boolean); + /** !#en A reference to the detailed data of the event + !#zh 事件的详细数据 */ + detail: any; + /** + !#en Sets user data + !#zh 设置用户数据 + @param data data + */ + setUserData(data: any): void; + /** + !#en Gets user data + !#zh 获取用户数据 + */ + getUserData(): any; + /** + !#en Gets event name + !#zh 获取事件名称 + */ + getEventName(): string; + } + } + + /**************************************************** + * SystemEvent + *****************************************************/ + + export namespace SystemEvent { + /** !#en The event type supported by SystemEvent + !#zh SystemEvent 支持的事件类型 */ + export class EventType { + /** !#en The event type for press the key down event, you can use its value directly: 'keydown' + !#zh 当按下按键时触发的事件 */ + static KEY_DOWN: string; + /** !#en The event type for press the key up event, you can use its value directly: 'keyup' + !#zh 当松开按键时触发的事件 */ + static KEY_UP: string; + /** !#en The event type for press the devicemotion event, you can use its value directly: 'devicemotion' + !#zh 重力感应 */ + static DEVICEMOTION: string; + } + } + + /**************************************************** + * Collider + *****************************************************/ + + export namespace Collider { + /** !#en Defines a Box Collider . + !#zh 用来定义包围盒碰撞体 */ + export class Box { + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Box size + !#zh 包围盒大小 */ + size: Size; + } + } + + /**************************************************** + * Collider + *****************************************************/ + + export namespace Collider { + /** !#en Defines a Circle Collider . + !#zh 用来定义圆形碰撞体 */ + export class Circle { + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Circle radius + !#zh 圆形半径 */ + radius: number; + } + } + + /**************************************************** + * Collider + *****************************************************/ + + export namespace Collider { + /** !#en Defines a Polygon Collider . + !#zh 用来定义多边形碰撞体 */ + export class Polygon { + /** !#en Position offset + !#zh 位置偏移量 */ + offset: Vec2; + /** !#en Polygon points + !#zh 多边形顶点数组 */ + points: Vec2[]; + } + } + + /**************************************************** + * Event + *****************************************************/ + + export namespace Event { + /** !#en The mouse event + !#zh 鼠标事件类型 */ + export class EventMouse extends Event { + /** + !#en Sets scroll data. + !#zh 设置鼠标的滚动数据。 + @param scrollX scrollX + @param scrollY scrollY + */ + setScrollData(scrollX: number, scrollY: number): void; + /** + !#en Returns the x axis scroll value. + !#zh 获取鼠标滚动的X轴距离,只有滚动时才有效。 + */ + getScrollX(): number; + /** + !#en Returns the y axis scroll value. + !#zh 获取滚轮滚动的 Y 轴距离,只有滚动时才有效。 + */ + getScrollY(): number; + /** + !#en Sets cursor location. + !#zh 设置当前鼠标位置。 + @param x x + @param y y + */ + setLocation(x: number, y: number): void; + /** + !#en Returns cursor location. + !#zh 获取鼠标位置对象,对象包含 x 和 y 属性。 + */ + getLocation(): Vec2; + /** + !#en Returns the current cursor location in screen coordinates. + !#zh 获取当前事件在游戏窗口内的坐标位置对象,对象包含 x 和 y 属性。 + */ + getLocationInView(): Vec2; + /** + !#en Returns the previous touch location. + !#zh 获取鼠标点击在上一次事件时的位置对象,对象包含 x 和 y 属性。 + */ + getPreviousLocation(): Vec2; + /** + !#en Returns the delta distance from the previous location to current location. + !#zh 获取鼠标距离上一次事件移动的距离对象,对象包含 x 和 y 属性。 + */ + getDelta(): Vec2; + /** + !#en Returns the X axis delta distance from the previous location to current location. + !#zh 获取鼠标距离上一次事件移动的 X 轴距离。 + */ + getDeltaX(): number; + /** + !#en Returns the Y axis delta distance from the previous location to current location. + !#zh 获取鼠标距离上一次事件移动的 Y 轴距离。 + */ + getDeltaY(): number; + /** + !#en Sets mouse button. + !#zh 设置鼠标按键。 + @param button button + */ + setButton(button: number): void; + /** + !#en Returns mouse button. + !#zh 获取鼠标按键。 + */ + getButton(): number; + /** + !#en Returns location X axis data. + !#zh 获取鼠标当前位置 X 轴。 + */ + getLocationX(): number; + /** + !#en Returns location Y axis data. + !#zh 获取鼠标当前位置 Y 轴。 + */ + getLocationY(): number; + /** !#en The none event code of mouse event. + !#zh 无。 */ + static NONE: number; + /** !#en The event type code of mouse down event. + !#zh 鼠标按下事件。 */ + static DOWN: number; + /** !#en The event type code of mouse up event. + !#zh 鼠标按下后释放事件。 */ + static UP: number; + /** !#en The event type code of mouse move event. + !#zh 鼠标移动事件。 */ + static MOVE: number; + /** !#en The event type code of mouse scroll event. + !#zh 鼠标滚轮事件。 */ + static SCROLL: number; + /** !#en The tag of Mouse left button. + !#zh 鼠标左键的标签。 */ + static BUTTON_LEFT: number; + /** !#en The tag of Mouse right button (The right button number is 2 on browser). + !#zh 鼠标右键的标签。 */ + static BUTTON_RIGHT: number; + /** !#en The tag of Mouse middle button (The right button number is 1 on browser). + !#zh 鼠标中键的标签。 */ + static BUTTON_MIDDLE: number; + /** !#en The tag of Mouse button 4. + !#zh 鼠标按键 4 的标签。 */ + static BUTTON_4: number; + /** !#en The tag of Mouse button 5. + !#zh 鼠标按键 5 的标签。 */ + static BUTTON_5: number; + /** !#en The tag of Mouse button 6. + !#zh 鼠标按键 6 的标签。 */ + static BUTTON_6: number; + /** !#en The tag of Mouse button 7. + !#zh 鼠标按键 7 的标签。 */ + static BUTTON_7: number; + /** !#en The tag of Mouse button 8. + !#zh 鼠标按键 8 的标签。 */ + static BUTTON_8: number; + } + } + + /**************************************************** + * Event + *****************************************************/ + + export namespace Event { + /** !#en The touch event + !#zh 触摸事件 */ + export class EventTouch extends Event { + /** + + @param touchArr The array of the touches + @param bubbles A boolean indicating whether the event bubbles up through the tree or not + */ + constructor(touchArr: any[], bubbles: boolean); + /** !#en The current touch object + !#zh 当前触点对象 */ + touch: Touch; + /** + !#en Returns event code. + !#zh 获取事件类型。 + */ + getEventCode(): number; + /** + !#en Returns touches of event. + !#zh 获取触摸点的列表。 + */ + getTouches(): any[]; + /** + !#en Sets touch location. + !#zh 设置当前触点位置 + @param x x + @param y y + */ + setLocation(x: number, y: number): void; + /** + !#en Returns touch location. + !#zh 获取触点位置。 + */ + getLocation(): Vec2; + /** + !#en Returns the current touch location in screen coordinates. + !#zh 获取当前触点在游戏窗口中的位置。 + */ + getLocationInView(): Vec2; + /** + !#en Returns the previous touch location. + !#zh 获取触点在上一次事件时的位置对象,对象包含 x 和 y 属性。 + */ + getPreviousLocation(): Vec2; + /** + !#en Returns the start touch location. + !#zh 获取触点落下时的位置对象,对象包含 x 和 y 属性。 + */ + getStartLocation(): Vec2; + /** + !#en Returns the id of cc.Touch. + !#zh 触点的标识 ID,可以用来在多点触摸中跟踪触点。 + */ + getID(): number; + /** + !#en Returns the delta distance from the previous location to current location. + !#zh 获取触点距离上一次事件移动的距离对象,对象包含 x 和 y 属性。 + */ + getDelta(): Vec2; + /** + !#en Returns the X axis delta distance from the previous location to current location. + !#zh 获取触点距离上一次事件移动的 x 轴距离。 + */ + getDeltaX(): number; + /** + !#en Returns the Y axis delta distance from the previous location to current location. + !#zh 获取触点距离上一次事件移动的 y 轴距离。 + */ + getDeltaY(): number; + /** + !#en Returns location X axis data. + !#zh 获取当前触点 X 轴位置。 + */ + getLocationX(): number; + /** + !#en Returns location Y axis data. + !#zh 获取当前触点 Y 轴位置。 + */ + getLocationY(): number; + } + } + + /**************************************************** + * Event + *****************************************************/ + + export namespace Event { + /** !#en The acceleration event + !#zh 加速度事件 */ + export class EventAcceleration extends Event { + } + } + + /**************************************************** + * Event + *****************************************************/ + + export namespace Event { + /** !#en The keyboard event + !#zh 键盘事件 */ + export class EventKeyboard extends Event { + /** !#en + The keyCode read-only property represents a system and implementation dependent numerical code identifying the unmodified value of the pressed key. + This is usually the decimal ASCII (RFC 20) or Windows 1252 code corresponding to the key. + If the key can't be identified, this value is 0. + + !#zh + keyCode 是只读属性它表示一个系统和依赖于实现的数字代码,可以识别按键的未修改值。 + 这通常是十进制 ASCII (RFC20) 或者 Windows 1252 代码,所对应的密钥。 + 如果无法识别该键,则该值为 0。 */ + keyCode: number; + } + } + + /**************************************************** + * Animation + *****************************************************/ + + export namespace Animation { + /** !#en The event type supported by Animation + !#zh Animation 支持的事件类型 */ + export class EventType { + /** !#en Emit when begin playing animation + !#zh 开始播放时触发 */ + static PLAY: string; + /** !#en Emit when stop playing animation + !#zh 停止播放时触发 */ + static STOP: string; + /** !#en Emit when pause animation + !#zh 暂停播放时触发 */ + static PAUSE: string; + /** !#en Emit when resume animation + !#zh 恢复播放时触发 */ + static RESUME: string; + /** !#en If animation repeat count is larger than 1, emit when animation play to the last frame + !#zh 假如动画循环次数大于 1,当动画播放到最后一帧时触发 */ + static LASTFRAME: string; + /** !#en Emit when finish playing animation + !#zh 动画播放完成时触发 */ + static FINISHED: string; + } + } + + /**************************************************** + * Button + *****************************************************/ + + export namespace Button { + /** !#en Enum for transition type. + !#zh 过渡类型 */ + export enum Transition { + NONE = 0, + COLOR = 0, + SPRITE = 0, + SCALE = 0, + } + } + + /**************************************************** + * Component + *****************************************************/ + + export namespace Component { + /** !#en + Component will register a event to target component's handler. + And it will trigger the handler when a certain event occurs. + + !@zh + “EventHandler” 类用来设置场景中的事件回调, + 该类允许用户设置回调目标节点,目标组件名,组件方法名, + 并可通过 emit 方法调用目标函数。 */ + export class EventHandler { + /** !#en the node that contains target callback, such as the node example script belongs to + !#zh 事件响应函数所在节点 ,比如例子中脚本归属的节点本身 */ + target: Node; + /** !#en name of the component(script) that contains target callback, such as the name 'MainMenu' of script in example + !#zh 事件响应函数所在组件名(脚本名), 比如例子中的脚本名 'MainMenu' */ + component: string; + /** !#en Event handler, such as function's name 'onClick' in example + !#zh 响应事件函数名,比如例子中的 'onClick' */ + handler: string; + /** !#en Custom Event Data, such as 'eventType' in example + !#zh 自定义事件数据,比如例子中的 eventType */ + customEventData: string; + /** + + @param events events + @param params params + */ + static emitEvents(events: EventHandler[], ...params: any[]): void; + /** + !#en Emit event with params + !#zh 触发目标组件上的指定 handler 函数,该参数是回调函数的参数值(可不填)。 + @param params params + + @example + ```js + // Call Function + var eventHandler = new cc.Component.EventHandler(); + eventHandler.target = newTarget; + eventHandler.component = "MainMenu"; + eventHandler.handler = "OnClick" + eventHandler.emit(["param1", "param2", ....]); + ``` + */ + emit(params: any[]): void; + } + } + + /**************************************************** + * Label + *****************************************************/ + + export namespace Label { + /** !#en Enum for text alignment. + !#zh 文本横向对齐类型 */ + export enum HorizontalAlign { + LEFT = 0, + CENTER = 0, + RIGHT = 0, + } + } + + /**************************************************** + * Label + *****************************************************/ + + export namespace Label { + /** !#en Enum for vertical text alignment. + !#zh 文本垂直对齐类型 */ + export enum VerticalAlign { + TOP = 0, + CENTER = 0, + BOTTOM = 0, + } + } + + /**************************************************** + * Label + *****************************************************/ + + export namespace Label { + /** !#en Enum for Overflow. + !#zh Overflow 类型 */ + export enum Overflow { + NONE = 0, + CLAMP = 0, + SHRINK = 0, + RESIZE_HEIGHT = 0, + } + } + + /**************************************************** + * Label + *****************************************************/ + + export namespace Label { + /** !#en Enum for font type. + !#zh Type 类型 */ + export enum Type { + TTF = 0, + BMFont = 0, + SystemFont = 0, + } + } + + /**************************************************** + * Label + *****************************************************/ + + export namespace Label { + /** !#en Enum for cache mode. + !#zh CacheMode 类型 */ + export enum CacheMode { + NONE = 0, + BITMAP = 0, + CHAR = 0, + } + } + + /**************************************************** + * Layout + *****************************************************/ + + export namespace Layout { + /** !#en Enum for Layout type + !#zh 布局类型 */ + export enum Type { + NONE = 0, + HORIZONTAL = 0, + VERTICAL = 0, + GRID = 0, + } + } + + /**************************************************** + * Layout + *****************************************************/ + + export namespace Layout { + /** !#en Enum for Layout Resize Mode + !#zh 缩放模式 */ + export enum ResizeMode { + NONE = 0, + CONTAINER = 0, + CHILDREN = 0, + } + } + + /**************************************************** + * Layout + *****************************************************/ + + export namespace Layout { + /** !#en Enum for Grid Layout start axis direction. + The items in grid layout will be arranged in each axis at first.; + !#zh 布局轴向,只用于 GRID 布局。 */ + export enum AxisDirection { + HORIZONTAL = 0, + VERTICAL = 0, + } + } + + /**************************************************** + * Layout + *****************************************************/ + + export namespace Layout { + /** !#en Enum for vertical layout direction. + Used in Grid Layout together with AxisDirection is VERTICAL + !#zh 垂直方向布局方式 */ + export enum VerticalDirection { + BOTTOM_TO_TOP = 0, + TOP_TO_BOTTOM = 0, + } + } + + /**************************************************** + * Layout + *****************************************************/ + + export namespace Layout { + /** !#en Enum for horizontal layout direction. + Used in Grid Layout together with AxisDirection is HORIZONTAL + !#zh 水平方向布局方式 */ + export enum HorizontalDirection { + LEFT_TO_RIGHT = 0, + RIGHT_TO_LEFT = 0, + } + } + + /**************************************************** + * Mask + *****************************************************/ + + export namespace Mask { + /** !#en the type for mask. + !#zh 遮罩组件类型 */ + export enum Type { + RECT = 0, + ELLIPSE = 0, + IMAGE_STENCIL = 0, + } + } + + /**************************************************** + * PageView + *****************************************************/ + + export namespace PageView { + /** !#en The Page View Size Mode + !#zh 页面视图每个页面统一的大小类型 */ + export enum SizeMode { + Unified = 0, + Free = 0, + } + } + + /**************************************************** + * PageView + *****************************************************/ + + export namespace PageView { + /** !#en The Page View Direction + !#zh 页面视图滚动类型 */ + export enum Direction { + Horizontal = 0, + Vertical = 0, + } + } + + /**************************************************** + * PageView + *****************************************************/ + + export namespace PageView { + /** !#en Enum for ScrollView event type. + !#zh 滚动视图事件类型 */ + export enum EventType { + PAGE_TURNING = 0, + } + } + + /**************************************************** + * ProgressBar + *****************************************************/ + + export namespace ProgressBar { + /** !#en Enum for ProgressBar mode + !#zh 进度条模式 */ + export enum Mode { + HORIZONTAL = 0, + VERTICAL = 0, + FILLED = 0, + } + } + + /**************************************************** + * PageViewIndicator + *****************************************************/ + + export namespace PageViewIndicator { + /** !#en Enum for PageView Indicator direction + !#zh 页面视图指示器的摆放方向 */ + export enum Direction { + HORIZONTAL = 0, + VERTICAL = 0, + } + } + + /**************************************************** + * Scrollbar + *****************************************************/ + + export namespace Scrollbar { + /** Enum for Scrollbar direction */ + export enum Direction { + HORIZONTAL = 0, + VERTICAL = 0, + } + } + + /**************************************************** + * ScrollView + *****************************************************/ + + export namespace ScrollView { + /** !#en Enum for ScrollView event type. + !#zh 滚动视图事件类型 */ + export enum EventType { + SCROLL_TO_TOP = 0, + SCROLL_TO_BOTTOM = 0, + SCROLL_TO_LEFT = 0, + SCROLL_TO_RIGHT = 0, + SCROLLING = 0, + BOUNCE_TOP = 0, + BOUNCE_BOTTOM = 0, + BOUNCE_LEFT = 0, + BOUNCE_RIGHT = 0, + SCROLL_ENDED = 0, + TOUCH_UP = 0, + AUTOSCROLL_ENDED_WITH_THRESHOLD = 0, + SCROLL_BEGAN = 0, + } + } + + /**************************************************** + * Slider + *****************************************************/ + + export namespace Slider { + /** !#en The Slider Direction + !#zh 滑动器方向 */ + export enum Direction { + Horizontal = 0, + Vertical = 0, + } + } + + /**************************************************** + * Sprite + *****************************************************/ + + export namespace Sprite { + /** !#en Enum for sprite type. + !#zh Sprite 类型 */ + export enum Type { + SIMPLE = 0, + SLICED = 0, + TILED = 0, + FILLED = 0, + MESH = 0, + } + } + + /**************************************************** + * Sprite + *****************************************************/ + + export namespace Sprite { + /** !#en Enum for fill type. + !#zh 填充类型 */ + export enum FillType { + HORIZONTAL = 0, + VERTICAL = 0, + RADIAL = 0, + } + } + + /**************************************************** + * Sprite + *****************************************************/ + + export namespace Sprite { + /** !#en Sprite Size can track trimmed size, raw size or none. + !#zh 精灵尺寸调整模式 */ + export enum SizeMode { + CUSTOM = 0, + TRIMMED = 0, + RAW = 0, + } + } + + /**************************************************** + * Sprite + *****************************************************/ + + export namespace Sprite { + /** !#en Sprite state can choice the normal or grayscale. + !#zh 精灵颜色通道模式。 */ + export enum State { + NORMAL = 0, + GRAY = 0, + } + } + + /**************************************************** + * Widget + *****************************************************/ + + export namespace Widget { + /** !#en Enum for Widget's alignment mode, indicating when the widget should refresh. + !#zh Widget 的对齐模式,表示 Widget 应该何时刷新。 */ + export enum AlignMode { + ONCE = 0, + ON_WINDOW_RESIZE = 0, + ALWAYS = 0, + } + } + + /**************************************************** + * geomUtils + *****************************************************/ + + export namespace geomUtils { + /** Aabb */ + export class Aabb { + /** + create a new aabb + @param px X coordinates for aabb's original point + @param py Y coordinates for aabb's original point + @param pz Z coordinates for aabb's original point + @param w the half of aabb width + @param h the half of aabb height + @param l the half of aabb length + */ + create(px: number, py: number, pz: number, w: number, h: number, l: number): Aabb; + /** + clone a new aabb + @param a the source aabb + */ + clone(a: Aabb): Aabb; + /** + copy the values from one aabb to another + @param out the receiving aabb + @param a the source aabb + */ + copy(out: Aabb, a: Aabb): Aabb; + /** + create a new aabb from two corner points + @param out the receiving aabb + @param minPos lower corner position of the aabb + @param maxPos upper corner position of the aabb + */ + fromPoints(out: Aabb, minPos: Vec3, maxPos: Vec3): Aabb; + /** + Set the components of a aabb to the given values + @param out the receiving aabb + @param px X coordinates for aabb's original point + @param py Y coordinates for aabb's original point + @param pz Z coordinates for aabb's original point + @param w the half of aabb width + @param h the half of aabb height + @param l the half of aabb length + */ + set(out: Aabb, px: number, py: number, pz: number, w: number, h: number, l: number): Aabb; + center: Vec3; + halfExtents: Vec3; + _type: number; + /** + Get the bounding points of this shape + @param minPos minPos + @param maxPos maxPos + */ + getBoundary(minPos: Vec3, maxPos: Vec3): void; + /** + Transform this shape + @param m the transform matrix + @param pos the position part of the transform + @param rot the rotation part of the transform + @param scale the scale part of the transform + @param out the target shape + */ + transform(m: Mat4, pos: Vec3, rot: Quat, scale: Vec3, out?: Aabb): void; + } + } + + /**************************************************** + * geomUtils + *****************************************************/ + + export namespace geomUtils { + /** !#en Shape type. */ + export enum enums { + SHAPE_RAY = 0, + SHAPE_LINE = 0, + SHAPE_SPHERE = 0, + SHAPE_AABB = 0, + SHAPE_OBB = 0, + SHAPE_PLANE = 0, + SHAPE_TRIANGLE = 0, + SHAPE_FRUSTUM = 0, + SHAPE_FRUSTUM_ACCURATE = 0, + } + } + + /**************************************************** + * geomUtils + *****************************************************/ + + export namespace geomUtils { + /** !#en frustum + !#zh 平截头体 */ + export class Frustum { + /** Set whether to use accurate intersection testing function on this frustum */ + accurate: boolean; + /** + create a new frustum + */ + static create(): Frustum; + /** + Clone a frustum + @param f f + */ + static clone(f: Frustum): Frustum; + /** + Copy the values from one frustum to another + @param out out + @param f f + */ + copy(out: Frustum, f: Frustum): Frustum; + planes: geomUtils.Plane[]; + planes: Vec3[]; + /** + !#en Update the frustum information according to the given transform matrix. + Note that the resulting planes are not normalized under normal mode. + @param m the view-projection matrix + @param inv the inverse view-projection matrix + */ + update(m: Mat4, inv: Mat4): void; + /** + !#en transform by matrix + @param mat mat + */ + transform(mat: Mat4): void; + } + } + + /**************************************************** + * geomUtils + *****************************************************/ + + export namespace geomUtils { + /** undefined */ + export class intersect { + /** + !#en + Check whether ray intersect with nodes + !#zh + 检测射线是否与物体有交集 + @param root If root is null, then traversal nodes from scene node + @param worldRay worldRay + @param handler handler + @param filter filter + */ + static ray_cast(root: Node, worldRay: geomUtils.Ray, handler: Function, filter: Function): any[]; + /** + !#en ray-plane intersect
+ !#zh 射线与平面的相交性检测。 + @param ray ray + @param plane plane + */ + static ray_plane(ray: geomUtils.Ray, plane: geomUtils.Plane): number; + /** + !#en line-plane intersect
+ !#zh 线段与平面的相交性检测。 + @param line line + @param plane plane + */ + static line_plane(line: geomUtils.Line, plane: geomUtils.Plane): number; + /** + !#en ray-triangle intersect
+ !#zh 射线与三角形的相交性检测。 + @param ray ray + @param triangle triangle + @param doubleSided doubleSided + */ + static ray_triangle(ray: geomUtils.Ray, triangle: geomUtils.Triangle, doubleSided: boolean): number; + /** + !#en line-triangle intersect
+ !#zh 线段与三角形的相交性检测。 + @param line line + @param triangle triangle + @param outPt optional, The intersection point + */ + static line_triangle(line: geomUtils.Line, triangle: geomUtils.Triangle, outPt: Vec3): number; + /** + !#en line-quad intersect
+ !#zh 线段与四边形的相交性检测。 + @param p A point on a line segment + @param q Another point on the line segment + @param a Quadrilateral point a + @param b Quadrilateral point b + @param c Quadrilateral point c + @param d Quadrilateral point d + @param outPt optional, The intersection point + */ + static line_quad(p: Vec3, q: Vec3, a: Vec3, b: Vec3, c: Vec3, d: Vec3, outPt: Vec3): number; + /** + !#en ray-sphere intersect
+ !#zh 射线和球的相交性检测。 + @param ray ray + @param sphere sphere + */ + static ray_sphere(ray: geomUtils.Ray, sphere: geomUtils.Sphere): number; + /** + !#en ray-aabb intersect
+ !#zh 射线和轴对齐包围盒的相交性检测。 + @param ray ray + @param aabb Align the axis around the box + */ + static ray_aabb(ray: geomUtils.Ray, aabb: Aabb): number; + /** + !#en ray-obb intersect
+ !#zh 射线和方向包围盒的相交性检测。 + @param ray ray + @param obb Direction box + */ + static ray_obb(ray: geomUtils.Ray, obb: geomUtils.Obb): number; + /** + !#en aabb-aabb intersect
+ !#zh 轴对齐包围盒和轴对齐包围盒的相交性检测。 + @param aabb1 Axis alignment surrounds box 1 + @param aabb2 Axis alignment surrounds box 2 + */ + static aabb_aabb(aabb1: Aabb, aabb2: Aabb): number; + /** + !#en aabb-obb intersect
+ !#zh 轴对齐包围盒和方向包围盒的相交性检测。 + @param aabb Align the axis around the box + @param obb Direction box + */ + static aabb_obb(aabb: Aabb, obb: geomUtils.Obb): number; + /** + !#en aabb-plane intersect
+ !#zh 轴对齐包围盒和平面的相交性检测。 + @param aabb Align the axis around the box + @param plane plane + */ + static aabb_plane(aabb: Aabb, plane: geomUtils.Plane): number; + /** + !#en aabb-frustum intersect, faster but has false positive corner cases
+ !#zh 轴对齐包围盒和锥台相交性检测,速度快,但有错误情况。 + @param aabb Align the axis around the box + @param frustum frustum + */ + static aabb_frustum(aabb: Aabb, frustum: Frustum): number; + /** + !#en aabb-frustum intersect, handles most of the false positives correctly
+ !#zh 轴对齐包围盒和锥台相交性检测,正确处理大多数错误情况。 + @param aabb Align the axis around the box + @param frustum frustum + */ + static aabb_frustum_accurate(aabb: Aabb, frustum: Frustum): number; + /** + !#en obb-point intersect
+ !#zh 方向包围盒和点的相交性检测。 + @param obb Direction box + @param point point + */ + static obb_point(obb: geomUtils.Obb, point: geomUtils.Vec3): boolean; + /** + !#en obb-plane intersect
+ !#zh 方向包围盒和平面的相交性检测。 + @param obb Direction box + @param plane plane + */ + static obb_plane(obb: geomUtils.Obb, plane: geomUtils.Plane): number; + /** + !#en obb-frustum intersect, faster but has false positive corner cases
+ !#zh 方向包围盒和锥台相交性检测,速度快,但有错误情况。 + @param obb Direction box + @param frustum frustum + */ + static obb_frustum(obb: geomUtils.Obb, frustum: Frustum): number; + /** + !#en obb-frustum intersect, handles most of the false positives correctly
+ !#zh 方向包围盒和锥台相交性检测,正确处理大多数错误情况。 + @param obb Direction box + @param frustum frustum + */ + static obb_frustum_accurate(obb: geomUtils.Obb, frustum: Frustum): number; + /** + !#en obb-obb intersect
+ !#zh 方向包围盒和方向包围盒的相交性检测。 + @param obb1 Direction box1 + @param obb2 Direction box2 + */ + static obb_obb(obb1: geomUtils.Obb, obb2: geomUtils.Obb): number; + /** + !#en phere-plane intersect, not necessarily faster than obb-plane
+ due to the length calculation of the plane normal to factor out
+ the unnomalized plane distance
+ !#zh 球与平面的相交性检测。 + @param sphere sphere + @param plane plane + */ + static sphere_plane(sphere: geomUtils.Sphere, plane: geomUtils.Plane): number; + /** + !#en sphere-frustum intersect, faster but has false positive corner cases
+ !#zh 球和锥台的相交性检测,速度快,但有错误情况。 + @param sphere sphere + @param frustum frustum + */ + static sphere_frustum(sphere: geomUtils.Sphere, frustum: Frustum): number; + /** + !#en sphere-frustum intersect, handles the false positives correctly
+ !#zh 球和锥台的相交性检测,正确处理大多数错误情况。 + @param sphere sphere + @param frustum frustum + */ + static sphere_frustum_accurate(sphere: geomUtils.Sphere, frustum: Frustum): number; + /** + !#en sphere-sphere intersect
+ !#zh 球和球的相交性检测。 + @param sphere0 sphere0 + @param sphere1 sphere1 + */ + static sphere_sphere(sphere0: geomUtils.Sphere, sphere1: geomUtils.Sphere): boolean; + /** + !#en sphere-aabb intersect
+ !#zh 球和轴对齐包围盒的相交性检测。 + @param sphere sphere + @param aabb aabb + */ + static sphere_aabb(sphere: geomUtils.Sphere, aabb: Aabb): boolean; + /** + !#en sphere-obb intersect
+ !#zh 球和方向包围盒的相交性检测。 + @param sphere sphere + @param obb obb + */ + static sphere_obb(sphere: geomUtils.Sphere, obb: geomUtils.Obb): boolean; + /** + !#en + The intersection detection of g1 and g2 can fill in the shape in the basic geometry. + !#zh + g1 和 g2 的相交性检测,可填入基础几何中的形状。 + @param g1 Geometry 1 + @param g2 Geometry 2 + @param outPt optional, Intersection point. (note: only partial shape detection with this return value) + */ + static resolve(g1: any, g2: any, outPt: any): void; + } + } + + /**************************************************** + * geomUtils + *****************************************************/ + + export namespace geomUtils { + /** !#en + line + !#zh + 直线 */ + export class Line { + /** + !#en + create a new line + !#zh + 创建一个新的 line。 + @param sx The x part of the starting point. + @param sy The y part of the starting point. + @param sz The z part of the starting point. + @param ex The x part of the end point. + @param ey The y part of the end point. + @param ez The z part of the end point. + */ + create(sx: number, sy: number, sz: number, ex: number, ey: number, ez: number): Line; + /** + !#en + Creates a new line initialized with values from an existing line + !#zh + 克隆一个新的 line。 + @param a The source of cloning. + */ + clone(a: Line): Line; + /** + !#en + Copy the values from one line to another + !#zh + 复制一个线的值到另一个。 + @param out The object that accepts the action. + @param a The source of the copy. + */ + copy(out: Line, a: Line): Line; + /** + !#en + create a line from two points + !#zh + 用两个点创建一个线。 + @param out The object that accepts the action. + @param start The starting point. + @param end At the end. + */ + fromPoints(out: Line, start: Vec3, end: Vec3): Line; + /** + !#en + Set the components of a Vec3 to the given values + !#zh + 将给定线的属性设置为给定值。 + @param out The object that accepts the action. + @param sx The x part of the starting point. + @param sy The y part of the starting point. + @param sz The z part of the starting point. + @param ex The x part of the end point. + @param ey The y part of the end point. + @param ez The z part of the end point. + */ + set(out: Line, sx: number, sy: number, sz: number, ex: number, ey: number, ez: number): Line; + /** + !#en + Calculate the length of the line. + !#zh + 计算线的长度。 + @param a The line to calculate. + */ + len(a: Line): number; + /** !#en + Start points. + !#zh + 起点。 */ + s: Vec3; + /** !#en + End points. + !#zh + 终点。 */ + e: Vec3; + /** + !#en + Calculate the length of the line. + !#zh + 计算线的长度。 + */ + length(): number; + } + } + + /**************************************************** + * geomUtils + *****************************************************/ + + export namespace geomUtils { + /** !#en obb + !#zh + 基础几何 方向包围盒。 */ + export class Obb { + /** !#zh + 获取形状的类型。 */ + type: number; + /** + !#en + create a new obb + !#zh + 创建一个新的 obb 实例。 + @param cx X coordinates of the shape relative to the origin. + @param cy Y coordinates of the shape relative to the origin. + @param cz Z coordinates of the shape relative to the origin. + @param hw Obb is half the width. + @param hh Obb is half the height. + @param hl Obb is half the Length. + @param ox_1 Direction matrix parameter. + @param ox_2 Direction matrix parameter. + @param ox_3 Direction matrix parameter. + @param oy_1 Direction matrix parameter. + @param oy_2 Direction matrix parameter. + @param oy_3 Direction matrix parameter. + @param oz_1 Direction matrix parameter. + @param oz_2 Direction matrix parameter. + @param oz_3 Direction matrix parameter. + */ + create(cx: number, cy: number, cz: number, hw: number, hh: number, hl: number, ox_1: number, ox_2: number, ox_3: number, oy_1: number, oy_2: number, oy_3: number, oz_1: number, oz_2: number, oz_3: number): Obb; + /** + !#en + clone a new obb + !#zh + 克隆一个 obb。 + @param a The target of cloning. + */ + clone(a: Obb): Obb; + /** + !#en + copy the values from one obb to another + !#zh + 将从一个 obb 的值复制到另一个 obb。 + @param out Obb that accepts the operation. + @param a Obb being copied. + */ + copy(out: Obb, a: Obb): Obb; + /** + !#en + create a new obb from two corner points + !#zh + 用两个点创建一个新的 obb。 + @param out Obb that accepts the operation. + @param minPos The smallest point of obb. + @param maxPos Obb's maximum point. + */ + fromPoints(out: Obb, minPos: Vec3, maxPos: Vec3): Obb; + /** + !#en + Set the components of a obb to the given values + !#zh + 将给定 obb 的属性设置为给定的值。 + @param cx X coordinates of the shape relative to the origin. + @param cy Y coordinates of the shape relative to the origin. + @param cz Z coordinates of the shape relative to the origin. + @param hw Obb is half the width. + @param hh Obb is half the height. + @param hl Obb is half the Length. + @param ox_1 Direction matrix parameter. + @param ox_2 Direction matrix parameter. + @param ox_3 Direction matrix parameter. + @param oy_1 Direction matrix parameter. + @param oy_2 Direction matrix parameter. + @param oy_3 Direction matrix parameter. + @param oz_1 Direction matrix parameter. + @param oz_2 Direction matrix parameter. + @param oz_3 Direction matrix parameter. + */ + set(cx: number, cy: number, cz: number, hw: number, hh: number, hl: number, ox_1: number, ox_2: number, ox_3: number, oy_1: number, oy_2: number, oy_3: number, oz_1: number, oz_2: number, oz_3: number): Obb; + /** !#en + The center of the local coordinate. + !#zh + 本地坐标的中心点。 */ + center: Vec3; + /** !#en + Half the length, width, and height. + !#zh + 长宽高的一半。 */ + halfExtents: Vec3; + /** !#en + Direction matrix. + !#zh + 方向矩阵。 */ + orientation: Mat3; + /** + !#en + Get the bounding points of this shape + !#zh + 获取 obb 的最小点和最大点。 + @param minPos minPos + @param maxPos maxPos + */ + getBoundary(minPos: Vec3, maxPos: Vec3): void; + /** + !#en Transform this shape + !#zh + 将 out 根据这个 obb 的数据进行变换。 + @param m The transformation matrix. + @param pos The position part of the transformation. + @param rot The rotating part of the transformation. + @param scale The scaling part of the transformation. + @param out Target of transformation. + */ + transform(m: Mat4, pos: Vec3, rot: Quat, scale: Vec3, out: Obb): void; + /** + !#en + Transform out based on this obb data. + !#zh + 将 out 根据这个 obb 的数据进行变换。 + @param m The transformation matrix. + @param rot The rotating part of the transformation. + @param out Target of transformation. + */ + translateAndRotate(m: Mat4, rot: Quat, out: Obb): void; + /** + !#en + Scale out based on this obb data. + !#zh + 将 out 根据这个 obb 的数据进行缩放。 + @param scale Scale value. + @param out Scaled target. + */ + setScale(scale: Vec3, out: Obb): void; + } + } + + /**************************************************** + * geomUtils + *****************************************************/ + + export namespace geomUtils { + /** !#en + plane。 + !#zh + 平面。 */ + export class Plane { + /** + !#en + create a new plane + !#zh + 创建一个新的 plane。 + @param nx The x part of the normal component. + @param ny The y part of the normal component. + @param nz The z part of the normal component. + @param d Distance from the origin. + */ + create(nx: number, ny: number, nz: number, d: number): Plane; + /** + !#en + clone a new plane + !#zh + 克隆一个新的 plane。 + @param p The source of cloning. + */ + clone(p: Plane): Plane; + /** + !#en + copy the values from one plane to another + !#zh + 复制一个平面的值到另一个。 + @param out The object that accepts the action. + @param p The source of the copy. + */ + copy(out: Plane, p: Plane): Plane; + /** + !#en + create a plane from three points + !#zh + 用三个点创建一个平面。 + @param out The object that accepts the action. + @param a Point a。 + @param b Point b。 + @param c Point c。 + */ + fromPoints(out: Plane, a: Vec3, b: Vec3, c: Vec3): Plane; + /** + !#en + Set the components of a plane to the given values + !#zh + 将给定平面的属性设置为给定值。 + @param out The object that accepts the action. + @param nx The x part of the normal component. + @param ny The y part of the normal component. + @param nz The z part of the normal component. + @param d Distance from the origin. + */ + set(out: Plane, nx: number, ny: number, nz: number, d: number): Plane; + /** + !#en + create plane from normal and point + !#zh + 用一条法线和一个点创建平面。 + @param out The object that accepts the action. + @param normal The normal of a plane. + @param point A point on the plane. + */ + fromNormalAndPoint(out: Plane, normal: Vec3, point: Vec3): Plane; + /** + !#en + normalize a plane + !#zh + 归一化一个平面。 + @param out The object that accepts the action. + @param a Source data for operations. + */ + normalize(out: Plane, a: Plane): Plane; + /** !#en + A normal vector. + !#zh + 法线向量。 */ + n: Vec3; + /** !#en + The distance from the origin to the plane. + !#zh + 原点到平面的距离。 */ + d: number; + /** + !#en + Transform a plane. + !#zh + 变换一个平面。 + @param mat mat + */ + transform(mat: Mat4): void; + } + } + + /**************************************************** + * geomUtils + *****************************************************/ + + export namespace geomUtils { + /** !#en + ray + !#zh + 射线。 */ + export class Ray { + /** + !#en + create a new ray + !#zh + 创建一条射线。 + @param ox The x part of the starting point. + @param oy The y part of the starting point. + @param oz The z part of the starting point. + @param dx X in the direction. + @param dy Y in the direction. + @param dz Z in the direction. + */ + create(ox: number, oy: number, oz: number, dx: number, dy: number, dz: number): Ray; + /** + !#en + Creates a new ray initialized with values from an existing ray + !#zh + 从一条射线克隆出一条新的射线。 + @param a Clone target + */ + clone(a: Ray): Ray; + /** + !#en + Copy the values from one ray to another + !#zh + 将从一个 ray 的值复制到另一个 ray。 + @param out Accept the ray of the operation. + @param a Copied ray. + */ + copy(out: Ray, a: Ray): Ray; + /** + !#en + create a ray from two points + !#zh + 用两个点创建一条射线。 + @param out Receive the operating ray. + @param origin Origin of ray + @param target A point on a ray. + */ + fromPoints(out: Ray, origin: Vec3, target: Vec3): Ray; + /** + !#en + Set the components of a ray to the given values + !#zh + 将给定射线的属性设置为给定的值。 + @param out Receive the operating ray. + @param ox The x part of the starting point. + @param oy The y part of the starting point. + @param oz The z part of the starting point. + @param dx X in the direction. + @param dy Y in the direction. + @param dz Z in the direction. + */ + set(out: Ray, ox: number, oy: number, oz: number, dx: number, dy: number, dz: number): Ray; + /** !#en + Start point. + !#zh + 起点。 */ + o: Vec3; + /** !#e + Direction + !#zh + 方向。 */ + d: Vec3; + /** + !#en Compute hit. + @param out out + @param distance distance + */ + computeHit(out: IVec3Like, distance: number): void; + } + } + + /**************************************************** + * geomUtils + *****************************************************/ + + export namespace geomUtils { + /** !#en + Sphere. + !#zh + 轴对齐球。 */ + export class Sphere { + /** + !#en + create a new sphere + !#zh + 创建一个新的 sphere 实例。 + @param cx X coordinates of the shape relative to the origin. + @param cy Y coordinates of the shape relative to the origin. + @param cz Z coordinates of the shape relative to the origin. + @param r Radius of sphere + */ + create(cx: any, cy: any, cz: any, r: any): Sphere; + /** + !#en + clone a new sphere + !#zh + 克隆一个新的 sphere 实例。 + @param p The target of cloning. + */ + clone(p: Sphere): Sphere; + /** + !#en + copy the values from one sphere to another + !#zh + 将从一个 sphere 的值复制到另一个 sphere。 + @param out Accept the sphere of operations. + @param a Sphere being copied. + */ + copy(out: Sphere, a: Sphere): Sphere; + /** + !#en + create a new bounding sphere from two corner points + !#zh + 从两个点创建一个新的 sphere。 + @param out Accept the sphere of operations. + @param minPos The smallest point of sphere. + @param maxPos The maximum point of sphere. + */ + fromPoints(out: any, minPos: any, maxPos: any): Sphere; + /** + !#en Set the components of a sphere to the given values + !#zh 将球体的属性设置为给定的值。 + @param out Accept the sphere of operations. + @param cx X coordinates of the shape relative to the origin. + @param cy Y coordinates of the shape relative to the origin. + @param cz Z coordinates of the shape relative to the origin. + @param r Radius. + */ + set(out: Sphere, cx: any, cy: any, cz: any, r: number): Sphere; + /** !#en + The center of the local coordinate. + !#zh + 本地坐标的中心点。 */ + center: Vec3; + /** !#zh + 半径。 */ + radius: number; + /** + !#en + Clone. + !#zh + 获得克隆。 + */ + clone(): void; + /** + !#en + Copy sphere + !#zh + 拷贝对象。 + @param a Copy target. + */ + copy(a: any): void; + /** + !#en + Get the bounding points of this shape + !#zh + 获取此形状的边界点。 + @param minPos minPos + @param maxPos maxPos + */ + getBoundary(minPos: Vec3, maxPos: Vec3): void; + /** + !#en + Transform this shape + !#zh + 将 out 根据这个 sphere 的数据进行变换。 + @param m The transformation matrix. + @param pos The position part of the transformation. + @param rot The rotating part of the transformation. + @param scale The scaling part of the transformation. + @param out The target of the transformation. + */ + transform(m: any, pos: any, rot: any, scale: any, out: any): void; + /** + !#en + Scale out based on the sphere data. + !#zh + 将 out 根据这个 sphere 的数据进行缩放。 + @param scale Scale value + @param out Scale target + */ + setScale(scale: any, out: any): void; + } + } + + /**************************************************** + * geomUtils + *****************************************************/ + + export namespace geomUtils { + /** Triangle */ + export class Triangle { + /** + create a new triangle + @param ax ax + @param ay ay + @param az az + @param bx bx + @param by by + @param bz bz + @param cx cx + @param cy cy + @param cz cz + */ + create(ax: number, ay: number, az: number, bx: number, by: number, bz: number, cx: number, cy: number, cz: number): Triangle; + /** + clone a new triangle + @param t the source plane + */ + clone(t: Triangle): Triangle; + /** + copy the values from one triangle to another + @param out the receiving triangle + @param t the source triangle + */ + copy(out: Triangle, t: Triangle): Triangle; + /** + Create a triangle from three points + @param out the receiving triangle + @param a a + @param b b + @param c c + */ + fromPoints(out: Triangle, a: Vec3, b: Vec3, c: Vec3): Triangle; + /** + Set the components of a triangle to the given values + @param out the receiving plane + @param ax X component of a + @param ay Y component of a + @param az Z component of a + @param bx X component of b + @param by Y component of b + @param bz Z component of b + @param cx X component of c + @param cy Y component of c + @param cz Z component of c + */ + set(out: Triangle, ax: number, ay: number, az: number, bx: number, by: number, bz: number, cx: number, cy: number, cz: number): Plane; + a: Vec3; + b: Vec3; + c: Vec3; + } + } + + /**************************************************** + * Graphics + *****************************************************/ + + export namespace Graphics { + /** !#en Enum for LineCap. + !#zh 线段末端属性 */ + export enum LineCap { + BUTT = 0, + ROUND = 0, + SQUARE = 0, + } + } + + /**************************************************** + * Graphics + *****************************************************/ + + export namespace Graphics { + /** !#en Enum for LineJoin. + !#zh 线段拐角属性 */ + export enum LineJoin { + BEVEL = 0, + ROUND = 0, + MITER = 0, + } + } + + /**************************************************** + * PhysicsManager + *****************************************************/ + + export namespace PhysicsManager { + /** !#en + The draw bits for drawing physics debug information.
+ example:
+ ```js + cc.director.getPhysicsManager().debugDrawFlags = + // cc.PhysicsManager.DrawBits.e_aabbBit | + // cc.PhysicsManager.DrawBits.e_pairBit | + // cc.PhysicsManager.DrawBits.e_centerOfMassBit | + cc.PhysicsManager.DrawBits.e_jointBit | + cc.PhysicsManager.DrawBits.e_shapeBit; + ``` + !#zh + 指定物理系统需要绘制哪些调试信息。
+ example:
+ ```js + cc.director.getPhysicsManager().debugDrawFlags = + // cc.PhysicsManager.DrawBits.e_aabbBit | + // cc.PhysicsManager.DrawBits.e_pairBit | + // cc.PhysicsManager.DrawBits.e_centerOfMassBit | + cc.PhysicsManager.DrawBits.e_jointBit | + cc.PhysicsManager.DrawBits.e_shapeBit; + ``` */ + export enum DrawBits { + e_aabbBit = 0, + e_jointBit = 0, + e_shapeBit = 0, + } + } + + /**************************************************** + * MeshRenderer + *****************************************************/ + + export namespace MeshRenderer { + /** !#en Shadow projection mode + + !#ch 阴影投射方式 */ + export enum ShadowCastingMode { + OFF = 0, + ON = 0, + } + } + + /**************************************************** + * macro + *****************************************************/ + + export namespace macro { + /** !#en Key map for keyboard event + !#zh 键盘事件的按键值 */ + export enum KEY { + none = 0, + back = 0, + menu = 0, + backspace = 0, + tab = 0, + enter = 0, + shift = 0, + ctrl = 0, + alt = 0, + pause = 0, + capslock = 0, + escape = 0, + space = 0, + pageup = 0, + pagedown = 0, + end = 0, + home = 0, + left = 0, + up = 0, + right = 0, + down = 0, + select = 0, + insert = 0, + Delete = 0, + a = 0, + b = 0, + c = 0, + d = 0, + e = 0, + f = 0, + g = 0, + h = 0, + i = 0, + j = 0, + k = 0, + l = 0, + m = 0, + n = 0, + o = 0, + p = 0, + q = 0, + r = 0, + s = 0, + t = 0, + u = 0, + v = 0, + w = 0, + x = 0, + y = 0, + z = 0, + num0 = 0, + num1 = 0, + num2 = 0, + num3 = 0, + num4 = 0, + num5 = 0, + num6 = 0, + num7 = 0, + num8 = 0, + num9 = 0, + '*' = 0, + '+' = 0, + '-' = 0, + numdel = 0, + '/' = 0, + f1 = 0, + f2 = 0, + f3 = 0, + f4 = 0, + f5 = 0, + f6 = 0, + f7 = 0, + f8 = 0, + f9 = 0, + f10 = 0, + f11 = 0, + f12 = 0, + numlock = 0, + scrolllock = 0, + ';' = 0, + semicolon = 0, + equal = 0, + '=' = 0, + ',' = 0, + comma = 0, + dash = 0, + '.' = 0, + period = 0, + forwardslash = 0, + grave = 0, + '[' = 0, + openbracket = 0, + backslash = 0, + ']' = 0, + closebracket = 0, + quote = 0, + dpadLeft = 0, + dpadRight = 0, + dpadUp = 0, + dpadDown = 0, + dpadCenter = 0, + } + } + + /**************************************************** + * macro + *****************************************************/ + + export namespace macro { + /** Image formats */ + export enum ImageFormat { + JPG = 0, + PNG = 0, + TIFF = 0, + WEBP = 0, + PVR = 0, + ETC = 0, + S3TC = 0, + ATITC = 0, + TGA = 0, + RAWDATA = 0, + UNKNOWN = 0, + } + } + + /**************************************************** + * macro + *****************************************************/ + + export namespace macro { + /** !#en + Enum for blend factor + Refer to: http://www.andersriggelsen.dk/glblendfunc.php + !#zh + 混合因子 + 可参考: http://www.andersriggelsen.dk/glblendfunc.php */ + export enum BlendFactor { + ONE = 0, + ZERO = 0, + SRC_ALPHA = 0, + SRC_COLOR = 0, + DST_ALPHA = 0, + DST_COLOR = 0, + ONE_MINUS_SRC_ALPHA = 0, + ONE_MINUS_SRC_COLOR = 0, + ONE_MINUS_DST_ALPHA = 0, + ONE_MINUS_DST_COLOR = 0, + } + } + + /**************************************************** + * macro + *****************************************************/ + + export namespace macro { + /** undefined */ + export enum TextAlignment { + LEFT = 0, + CENTER = 0, + RIGHT = 0, + } + } + + /**************************************************** + * sys + *****************************************************/ + + export namespace sys { + /** !#en + Network type enumeration + !#zh + 网络类型枚举 */ + export enum NetworkType { + NONE = 0, + LAN = 0, + WWAN = 0, + } + } + + /**************************************************** + * AnimationCurve + *****************************************************/ + + export namespace AnimationCurve { + /** !#en The wrap mode + !#zh 循环模式 */ + export enum WrapMode { + Default = 0, + Once = 0, + Loop = 0, + PingPong = 0, + ClampForever = 0, + time = 0, + value = 0, + inTangent = 0, + outTangent = 0, + } + } + + /**************************************************** + * ParticleSystem3DAssembler + *****************************************************/ + + export namespace ParticleSystem3DAssembler { + /** undefined */ + export enum Space { + } + } + + /**************************************************** + * ParticleSystem3DAssembler + *****************************************************/ + + export namespace ParticleSystem3DAssembler { + /** 粒子的生成模式 */ + export enum RenderMode { + } + } + + /**************************************************** + * shapeModule + *****************************************************/ + + export namespace shapeModule { + /** 粒子发射器类型 */ + export enum ShapeType { + Box = 0, + Circle = 0, + Cone = 0, + Sphere = 0, + Hemisphere = 0, + } + } + + /**************************************************** + * shapeModule + *****************************************************/ + + export namespace shapeModule { + /** 粒子从发射器的哪个部位发射 */ + export enum EmitLocation { + Base = 0, + Edge = 0, + Shell = 0, + Volume = 0, + } + } + + /**************************************************** + * shapeModule + *****************************************************/ + + export namespace shapeModule { + /** 粒子在扇形区域的发射方式 */ + export enum ArcMode { + Random = 0, + Loop = 0, + PingPong = 0, + } + } + + /**************************************************** + * trailModule + *****************************************************/ + + export namespace trailModule { + /** 选择如何为粒子系统生成轨迹 */ + export enum TrailMode { + } + } + + /**************************************************** + * trailModule + *****************************************************/ + + export namespace trailModule { + /** 纹理填充模式 */ + export enum TextureMode { + } + } + + /**************************************************** + * primitive + *****************************************************/ + + export namespace primitive { + /** undefined */ + export enum PolyhedronType { + Tetrahedron = 0, + Octahedron = 0, + Dodecahedron = 0, + Icosahedron = 0, + Rhombicuboctahedron = 0, + TriangularPrism = 0, + PentagonalPrism = 0, + HexagonalPrism = 0, + SquarePyramid = 0, + PentagonalPyramid = 0, + TriangularDipyramid = 0, + PentagonalDipyramid = 0, + ElongatedSquareDipyramid = 0, + ElongatedPentagonalDipyramid = 0, + ElongatedPentagonalCupola = 0, + } + } + + /**************************************************** + * primitive + *****************************************************/ + + export namespace primitive { + /** undefined */ + export class VertexData { + positions: number[]; + normals: number[]; + uvs: number[]; + indices: number[]; + minPos: Vec3; + maxPos: Vec3; + boundingRadius: number; + } + } + + /**************************************************** + * Material + *****************************************************/ + + export namespace Material { + /** !#en Material builtin name + !#zh 内置材质名字 */ + export enum BUILTIN_NAME { + SPRITE = 0, + GRAY_SPRITE = 0, + UNLIT = 0, + } + } + + /**************************************************** + * EditBox + *****************************************************/ + + export namespace EditBox { + /** !#en Enum for keyboard return types + !#zh 键盘的返回键类型 */ + export enum KeyboardReturnType { + DEFAULT = 0, + DONE = 0, + SEND = 0, + SEARCH = 0, + GO = 0, + NEXT = 0, + } + } + + /**************************************************** + * EditBox + *****************************************************/ + + export namespace EditBox { + /** !#en The EditBox's InputMode defines the type of text that the user is allowed to enter. + !#zh 输入模式 */ + export enum InputMode { + ANY = 0, + EMAIL_ADDR = 0, + NUMERIC = 0, + PHONE_NUMBER = 0, + URL = 0, + DECIMAL = 0, + SINGLE_LINE = 0, + } + } + + /**************************************************** + * EditBox + *****************************************************/ + + export namespace EditBox { + /** !#en Enum for the EditBox's input flags + !#zh 定义了一些用于设置文本显示和文本格式化的标志位。 */ + export enum InputFlag { + PASSWORD = 0, + SENSITIVE = 0, + INITIAL_CAPS_WORD = 0, + INITIAL_CAPS_SENTENCE = 0, + INITIAL_CAPS_ALL_CHARACTERS = 0, + DEFAULT = 0, + } + } + + /**************************************************** + * textureAnimationModule + *****************************************************/ + + export namespace textureAnimationModule { + /** 粒子贴图动画类型 */ + export enum Mode { + } + } + + /**************************************************** + * textureAnimationModule + *****************************************************/ + + export namespace textureAnimationModule { + /** 贴图动画的播放方式 */ + export enum Animation { + } + } + +} + +/** !#en +The global main namespace of Spine, all classes, functions, +properties and constants of Spine are defined in this namespace +!#zh +Spine 的全局的命名空间, +与 Spine 相关的所有的类,函数,属性,常量都在这个命名空间中定义。 */ +declare namespace sp { + /** !#en + The skeleton of Spine
+
+ (Skeleton has a reference to a SkeletonData and stores the state for skeleton instance, + which consists of the current pose's bone SRT, slot colors, and which slot attachments are visible.
+ Multiple skeletons can use the same SkeletonData which includes all animations, skins, and attachments.)
+ !#zh + Spine 骨骼动画
+
+ (Skeleton 具有对骨骼数据的引用并且存储了骨骼实例的状态, + 它由当前的骨骼动作,slot 颜色,和可见的 slot attachments 组成。
+ 多个 Skeleton 可以使用相同的骨骼数据,其中包括所有的动画,皮肤和 attachments。 */ + export class Skeleton extends cc.RenderComponent { + /** !#en The skeletal animation is paused? + !#zh 该骨骼动画是否暂停。 */ + paused: boolean; + /** !#en + The skeleton data contains the skeleton information (bind pose bones, slots, draw order, + attachments, skins, etc) and animations but does not hold any state.
+ Multiple skeletons can share the same skeleton data. + !#zh + 骨骼数据包含了骨骼信息(绑定骨骼动作,slots,渲染顺序, + attachments,皮肤等等)和动画但不持有任何状态。
+ 多个 Skeleton 可以共用相同的骨骼数据。 */ + skeletonData: SkeletonData; + /** !#en The name of default skin. + !#zh 默认的皮肤名称。 */ + defaultSkin: string; + /** !#en The name of default animation. + !#zh 默认的动画名称。 */ + defaultAnimation: string; + /** !#en The name of current playing animation. + !#zh 当前播放的动画名称。 */ + animation: string; + _defaultSkinIndex: number; + /** !#en TODO + !#zh 是否循环播放当前骨骼动画。 */ + loop: boolean; + /** !#en Indicates whether to enable premultiplied alpha. + You should disable this option when image's transparent area appears to have opaque pixels, + or enable this option when image's half transparent area appears to be darken. + !#zh 是否启用贴图预乘。 + 当图片的透明区域出现色块时需要关闭该选项,当图片的半透明区域颜色变黑时需要启用该选项。 */ + premultipliedAlpha: boolean; + /** !#en The time scale of this skeleton. + !#zh 当前骨骼中所有动画的时间缩放率。 */ + timeScale: number; + /** !#en Indicates whether open debug slots. + !#zh 是否显示 slot 的 debug 信息。 */ + debugSlots: boolean; + /** !#en Indicates whether open debug bones. + !#zh 是否显示 bone 的 debug 信息。 */ + debugBones: boolean; + /** !#en Indicates whether open debug mesh. + !#zh 是否显示 mesh 的 debug 信息。 */ + debugMesh: boolean; + /** !#en Enabled two color tint. + !#zh 是否启用染色效果。 */ + useTint: boolean; + /** !#en Enabled batch model, if skeleton is complex, do not enable batch, or will lower performance. + !#zh 开启合批,如果渲染大量相同纹理,且结构简单的骨骼动画,开启合批可以降低drawcall,否则请不要开启,cpu消耗会上升。 */ + enableBatch: boolean; + /** + !#en + Sets runtime skeleton data to sp.Skeleton.
+ This method is different from the `skeletonData` property. This method is passed in the raw data provided by the Spine runtime, and the skeletonData type is the asset type provided by Creator. + !#zh + 设置底层运行时用到的 SkeletonData。
+ 这个接口有别于 `skeletonData` 属性,这个接口传入的是 Spine runtime 提供的原始数据,而 skeletonData 的类型是 Creator 提供的资源类型。 + @param skeletonData skeletonData + */ + setSkeletonData(skeletonData: sp.spine.SkeletonData): void; + /** + !#en Sets slots visible range. + !#zh 设置骨骼插槽可视范围。 + @param startSlotIndex startSlotIndex + @param endSlotIndex endSlotIndex + */ + setSlotsRange(startSlotIndex: number, endSlotIndex: number): void; + /** + !#en Sets animation state data.
+ The parameter type is {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.AnimationStateData. + !#zh 设置动画状态数据。
+ 参数是 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.AnimationStateData。 + @param stateData stateData + */ + setAnimationStateData(stateData: sp.spine.AnimationStateData): void; + /** + !#en + It's best to set cache mode before set property 'dragonAsset', or will waste some cpu time. + If set the mode in editor, then no need to worry about order problem. + !#zh + 若想切换渲染模式,最好在设置'dragonAsset'之前,先设置好渲染模式,否则有运行时开销。 + 若在编辑中设置渲染模式,则无需担心设置次序的问题。 + @param cacheMode cacheMode + + @example + ```js + skeleton.setAnimationCacheMode(sp.Skeleton.AnimationCacheMode.SHARED_CACHE); + ``` + */ + setAnimationCacheMode(cacheMode: Skeleton.AnimationCacheMode): void; + /** + !#en Whether in cached mode. + !#zh 当前是否处于缓存模式。 + */ + isAnimationCached(): boolean; + /** + !#en Sets vertex effect delegate. + !#zh 设置顶点动画代理 + @param effectDelegate effectDelegate + */ + setVertexEffectDelegate(effectDelegate: VertexEffectDelegate): void; + /** + !#en Computes the world SRT from the local SRT for each bone. + !#zh 重新更新所有骨骼的世界 Transform, + 当获取 bone 的数值未更新时,即可使用该函数进行更新数值。 + + @example + ```js + var bone = spine.findBone('head'); + cc.log(bone.worldX); // return 0; + spine.updateWorldTransform(); + bone = spine.findBone('head'); + cc.log(bone.worldX); // return -23.12; + ``` + */ + updateWorldTransform(): void; + /** + !#en Sets the bones and slots to the setup pose. + !#zh 还原到起始动作 + */ + setToSetupPose(): void; + /** + !#en + Sets the bones to the setup pose, + using the values from the `BoneData` list in the `SkeletonData`. + !#zh + 设置 bone 到起始动作 + 使用 SkeletonData 中的 BoneData 列表中的值。 + */ + setBonesToSetupPose(): void; + /** + !#en + Sets the slots to the setup pose, + using the values from the `SlotData` list in the `SkeletonData`. + !#zh + 设置 slot 到起始动作。 + 使用 SkeletonData 中的 SlotData 列表中的值。 + */ + setSlotsToSetupPose(): void; + /** + !#en + Updating an animation cache to calculate all frame data in the animation is a cost in + performance due to calculating all data in a single frame. + To update the cache, use the invalidAnimationCache method with high performance. + !#zh + 更新某个动画缓存, 预计算动画中所有帧数据,由于在单帧计算所有数据,所以较消耗性能。 + 若想更新缓存,可使用 invalidAnimationCache 方法,具有较高性能。 + @param animName animName + */ + updateAnimationCache(animName: string): void; + /** + !#en + Invalidates the animation cache, which is then recomputed on each frame.. + !#zh + 使动画缓存失效,之后会在每帧重新计算。 + */ + invalidAnimationCache(): void; + /** + !#en + Finds a bone by name. + This does a string comparison for every bone.
+ Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Bone object. + !#zh + 通过名称查找 bone。 + 这里对每个 bone 的名称进行了对比。
+ 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Bone 对象。 + @param boneName boneName + */ + findBone(boneName: string): sp.spine.Bone; + /** + !#en + Finds a slot by name. This does a string comparison for every slot.
+ Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Slot object. + !#zh + 通过名称查找 slot。这里对每个 slot 的名称进行了比较。
+ 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Slot 对象。 + @param slotName slotName + */ + findSlot(slotName: string): sp.spine.Slot; + /** + !#en + Finds a skin by name and makes it the active skin. + This does a string comparison for every skin.
+ Note that setting the skin does not change which attachments are visible.
+ Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Skin object. + !#zh + 按名称查找皮肤,激活该皮肤。这里对每个皮肤的名称进行了比较。
+ 注意:设置皮肤不会改变 attachment 的可见性。
+ 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Skin 对象。 + @param skinName skinName + */ + setSkin(skinName: string): void; + /** + !#en + Returns the attachment for the slot and attachment name. + The skeleton looks first in its skin, then in the skeleton data’s default skin.
+ Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Attachment object. + !#zh + 通过 slot 和 attachment 的名称获取 attachment。Skeleton 优先查找它的皮肤,然后才是 Skeleton Data 中默认的皮肤。
+ 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Attachment 对象。 + @param slotName slotName + @param attachmentName attachmentName + */ + getAttachment(slotName: string, attachmentName: string): sp.spine.Attachment; + /** + !#en + Sets the attachment for the slot and attachment name. + The skeleton looks first in its skin, then in the skeleton data’s default skin. + !#zh + 通过 slot 和 attachment 的名字来设置 attachment。 + Skeleton 优先查找它的皮肤,然后才是 Skeleton Data 中默认的皮肤。 + @param slotName slotName + @param attachmentName attachmentName + */ + setAttachment(slotName: string, attachmentName: string): void; + /** + Return the renderer of attachment. + @param regionAttachment regionAttachment + */ + getTextureAtlas(regionAttachment: sp.spine.RegionAttachment|spine.BoundingBoxAttachment): sp.spine.TextureAtlasRegion; + /** + !#en + Mix applies all keyframe values, + interpolated for the specified time and mixed with the current values. + !#zh 为所有关键帧设定混合及混合时间(从当前值开始差值)。 + @param fromAnimation fromAnimation + @param toAnimation toAnimation + @param duration duration + */ + setMix(fromAnimation: string, toAnimation: string, duration: number): void; + /** + !#en Set the current animation. Any queued animations are cleared.
+ Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry object. + !#zh 设置当前动画。队列中的任何的动画将被清除。
+ 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry 对象。 + @param trackIndex trackIndex + @param name name + @param loop loop + */ + setAnimation(trackIndex: number, name: string, loop: boolean): sp.spine.TrackEntry; + /** + !#en Adds an animation to be played delay seconds after the current or last queued animation.
+ Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry object. + !#zh 添加一个动画到动画队列尾部,还可以延迟指定的秒数。
+ 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry 对象。 + @param trackIndex trackIndex + @param name name + @param loop loop + @param delay delay + */ + addAnimation(trackIndex: number, name: string, loop: boolean, delay?: number): sp.spine.TrackEntry; + /** + !#en Find animation with specified name. + !#zh 查找指定名称的动画 + @param name name + */ + findAnimation(name: string): sp.spine.Animation; + /** + !#en Returns track entry by trackIndex.
+ Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry object. + !#zh 通过 track 索引获取 TrackEntry。
+ 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry 对象。 + @param trackIndex trackIndex + */ + getCurrent(trackIndex: any): sp.spine.TrackEntry; + /** + !#en Clears all tracks of animation state. + !#zh 清除所有 track 的动画状态。 + */ + clearTracks(): void; + /** + !#en Clears track of animation state by trackIndex. + !#zh 清除出指定 track 的动画状态。 + @param trackIndex trackIndex + */ + clearTrack(trackIndex: number): void; + /** + !#en Set the start event listener. + !#zh 用来设置开始播放动画的事件监听。 + @param listener listener + */ + setStartListener(listener: Function): void; + /** + !#en Set the interrupt event listener. + !#zh 用来设置动画被打断的事件监听。 + @param listener listener + */ + setInterruptListener(listener: Function): void; + /** + !#en Set the end event listener. + !#zh 用来设置动画播放完后的事件监听。 + @param listener listener + */ + setEndListener(listener: Function): void; + /** + !#en Set the dispose event listener. + !#zh 用来设置动画将被销毁的事件监听。 + @param listener listener + */ + setDisposeListener(listener: Function): void; + /** + !#en Set the complete event listener. + !#zh 用来设置动画播放一次循环结束后的事件监听。 + @param listener listener + */ + setCompleteListener(listener: Function): void; + /** + !#en Set the animation event listener. + !#zh 用来设置动画播放过程中帧事件的监听。 + @param listener listener + */ + setEventListener(listener: Function): void; + /** + !#en Set the start event listener for specified TrackEntry. + !#zh 用来为指定的 TrackEntry 设置动画开始播放的事件监听。 + @param entry entry + @param listener listener + */ + setTrackStartListener(entry: sp.spine.TrackEntry, listener: Function): void; + /** + !#en Set the interrupt event listener for specified TrackEntry. + !#zh 用来为指定的 TrackEntry 设置动画被打断的事件监听。 + @param entry entry + @param listener listener + */ + setTrackInterruptListener(entry: sp.spine.TrackEntry, listener: Function): void; + /** + !#en Set the end event listener for specified TrackEntry. + !#zh 用来为指定的 TrackEntry 设置动画播放结束的事件监听。 + @param entry entry + @param listener listener + */ + setTrackEndListener(entry: sp.spine.TrackEntry, listener: Function): void; + /** + !#en Set the dispose event listener for specified TrackEntry. + !#zh 用来为指定的 TrackEntry 设置动画即将被销毁的事件监听。 + @param entry entry + @param listener listener + */ + setTrackDisposeListener(entry: sp.spine.TrackEntry, listener: Function): void; + /** + !#en Set the complete event listener for specified TrackEntry. + !#zh 用来为指定的 TrackEntry 设置动画一次循环播放结束的事件监听。 + @param entry entry + @param listener listener + */ + setTrackCompleteListener(entry: sp.spine.TrackEntry, listener: (entry: sp.spine.TrackEntry, loopCount: number) => void): void; + /** + !#en Set the event listener for specified TrackEntry. + !#zh 用来为指定的 TrackEntry 设置动画帧事件的监听。 + @param entry entry + @param listener listener + */ + setTrackEventListener(entry: sp.spine.TrackEntry, listener: Function): void; + /** + !#en Get the animation state object + !#zh 获取动画状态 + */ + getState(): sp.spine.AnimationState; + } + /** !#en The event type of spine skeleton animation. + !#zh 骨骼动画事件类型。 */ + export enum AnimationEventType { + START = 0, + END = 0, + COMPLETE = 0, + EVENT = 0, + } + /** !#en The skeleton data of spine. + !#zh Spine 的 骨骼数据。 */ + export class SkeletonData extends cc.Asset { + /** !#en See http://en.esotericsoftware.com/spine-json-format + !#zh 可查看 Spine 官方文档 http://zh.esotericsoftware.com/spine-json-format */ + skeletonJson: any; + atlasText: string; + textures: cc.Texture2D[]; + /** !#en + A scale can be specified on the JSON or binary loader which will scale the bone positions, + image sizes, and animation translations. + This can be useful when using different sized images than were used when designing the skeleton + in Spine. For example, if using images that are half the size than were used in Spine, + a scale of 0.5 can be used. This is commonly used for games that can run with either low or high + resolution texture atlases. + see http://en.esotericsoftware.com/spine-using-runtimes#Scaling + !#zh 可查看 Spine 官方文档: http://zh.esotericsoftware.com/spine-using-runtimes#Scaling */ + scale: number; + /** + !#en Get the included SkeletonData used in spine runtime.
+ Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.SkeletonData object. + !#zh 获取 Spine Runtime 使用的 SkeletonData。
+ 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.SkeletonData 对象。 + @param quiet quiet + */ + getRuntimeData(quiet?: boolean): sp.spine.SkeletonData; + } + /** !#en + The delegate of spine vertex effect + !#zh + Spine 顶点动画代理 */ + export class VertexEffectDelegate { + /** + !#en Clears vertex effect. + !#zh 清空顶点效果 + */ + clear(): void; + /** + !#en Inits delegate with jitter effect + !#zh 设置顶点抖动效果 + @param jitterX jitterX + @param jitterY jitterY + */ + initJitter(jitterX: number, jitterY: number): void; + /** + !#en Inits delegate with swirl effect + !#zh 设置顶点漩涡效果 + @param radius radius + @param power power + */ + initSwirlWithPow(radius: number, power: number): sp.spine.JitterEffect; + /** + !#en Inits delegate with swirl effect + !#zh 设置顶点漩涡效果 + @param radius radius + @param power power + */ + initSwirlWithPowOut(radius: number, power: number): sp.spine.SwirlEffect; + /** + !#en Gets jitter vertex effect + !#zh 获取顶点抖动效果 + */ + getJitterVertexEffect(): sp.spine.JitterEffect; + /** + !#en Gets swirl vertex effect + !#zh 获取顶点漩涡效果 + */ + getSwirlVertexEffect(): sp.spine.SwirlEffect; + /** + !#en Gets vertex effect + !#zh 获取顶点效果 + */ + getVertexEffect(): sp.spine.JitterEffect; + /** + !#en Gets effect type + !#zh 获取效果类型 + */ + getEffectType(): string; + } + /**************************************************** + * sp + *****************************************************/ + + export namespace sp { + /** !#en Attach node tool + !#zh 挂点工具类 */ + export class AttachUtil { + /** + !#en Gets attached root node. + !#zh 获取挂接节点树的根节点 + */ + getAttachedRootNode(): cc.Node; + /** + !#en Gets attached node which you want. + !#zh 获得对应的挂点 + @param boneName boneName + */ + getAttachedNodes(boneName: string): cc.Node[]; + /** + !#en Destroy attached node which you want. + !#zh 销毁对应的挂点 + @param boneName boneName + */ + destroyAttachedNodes(boneName: string): void; + /** + !#en Traverse all bones to generate the minimum node tree containing the given bone names, NOTE that make sure the skeleton has initialized before calling this interface. + !#zh 遍历所有插槽,生成包含所有给定插槽名称的最小节点树,注意,调用该接口前请确保骨骼动画已经初始化好。 + @param boneName boneName + */ + generateAttachedNodes(boneName: string): cc.Node[]; + /** + !#en Destroy all attached node. + !#zh 销毁所有挂点 + */ + destroyAllAttachedNodes(): void; + /** + !#en Traverse all bones to generate a tree containing all bones nodes, NOTE that make sure the skeleton has initialized before calling this interface. + !#zh 遍历所有插槽,生成包含所有插槽的节点树,注意,调用该接口前请确保骨骼动画已经初始化好。 + */ + generateAllAttachedNodes(): cc.Node; + } + } + + /**************************************************** + * Skeleton + *****************************************************/ + + export namespace Skeleton { + /** !#en Enum for animation cache mode type. + !#zh Spine动画缓存类型 */ + export enum AnimationCacheMode { + REALTIME = 0, + SHARED_CACHE = 0, + PRIVATE_CACHE = 0, + } + } + +} + +/** !#en +`sp.spine` is the namespace for official Spine Runtime, which officially implemented and maintained by Spine.
+Please refer to the official documentation for its detailed usage: [http://en.esotericsoftware.com/spine-using-runtimes](http://en.esotericsoftware.com/spine-using-runtimes) +!#zh +sp.spine 模块是 Spine 官方运行库的 API 入口,由 Spine 官方统一实现和维护,具体用法请参考:[http://zh.esotericsoftware.com/spine-using-runtimes](http://zh.esotericsoftware.com/spine-using-runtimes) */ +declare namespace sp.spine { +} + +/** !#en +The global main namespace of DragonBones, all classes, functions, +properties and constants of DragonBones are defined in this namespace +!#zh +DragonBones 的全局的命名空间, +与 DragonBones 相关的所有的类,函数,属性,常量都在这个命名空间中定义。 */ +declare namespace dragonBones { + /** !#en + The Armature Display of DragonBones
+
+ Armature Display has a reference to a DragonBonesAsset and stores the state for ArmatureDisplay instance, + which consists of the current pose's bone SRT, slot colors, and which slot attachments are visible.
+ Multiple Armature Display can use the same DragonBonesAsset which includes all animations, skins, and attachments.
+ !#zh + DragonBones 骨骼动画
+
+ Armature Display 具有对骨骼数据的引用并且存储了骨骼实例的状态, + 它由当前的骨骼动作,slot 颜色,和可见的 slot attachments 组成。
+ 多个 Armature Display 可以使用相同的骨骼数据,其中包括所有的动画,皮肤和 attachments。
*/ + export class ArmatureDisplay extends cc.RenderComponent { + /** !#en + The DragonBones data contains the armatures information (bind pose bones, slots, draw order, + attachments, skins, etc) and animations but does not hold any state.
+ Multiple ArmatureDisplay can share the same DragonBones data. + !#zh + 骨骼数据包含了骨骼信息(绑定骨骼动作,slots,渲染顺序, + attachments,皮肤等等)和动画但不持有任何状态。
+ 多个 ArmatureDisplay 可以共用相同的骨骼数据。 */ + dragonAsset: DragonBonesAsset; + /** !#en + The atlas asset for the DragonBones. + !#zh + 骨骼数据所需的 Atlas Texture 数据。 */ + dragonAtlasAsset: DragonBonesAtlasAsset; + /** !#en The name of current armature. + !#zh 当前的 Armature 名称。 */ + armatureName: string; + /** !#en The name of current playing animation. + !#zh 当前播放的动画名称。 */ + animationName: string; + _defaultArmatureIndex: number; + /** !#en The time scale of this armature. + !#zh 当前骨骼中所有动画的时间缩放率。 */ + timeScale: number; + /** !#en The play times of the default animation. + -1 means using the value of config file; + 0 means repeat for ever + >0 means repeat times + !#zh 播放默认动画的循环次数 + -1 表示使用配置文件中的默认值; + 0 表示无限循环 + >0 表示循环次数 */ + playTimes: number; + /** !#en Indicates whether to enable premultiplied alpha. + You should disable this option when image's transparent area appears to have opaque pixels, + or enable this option when image's half transparent area appears to be darken. + !#zh 是否启用贴图预乘。 + 当图片的透明区域出现色块时需要关闭该选项,当图片的半透明区域颜色变黑时需要启用该选项。 */ + premultipliedAlpha: boolean; + /** !#en Indicates whether open debug bones. + !#zh 是否显示 bone 的 debug 信息。 */ + debugBones: boolean; + /** !#en Enabled batch model, if skeleton is complex, do not enable batch, or will lower performance. + !#zh 开启合批,如果渲染大量相同纹理,且结构简单的骨骼动画,开启合批可以降低drawcall,否则请不要开启,cpu消耗会上升。 */ + enableBatch: boolean; + /** + !#en + The key of dragonbones cache data, which is regard as 'dragonbonesName', when you want to change dragonbones cloth. + !#zh + 缓存龙骨数据的key值,换装的时会使用到该值,作为dragonbonesName使用 + + @example + ```js + let factory = dragonBones.CCFactory.getInstance(); + let needChangeSlot = needChangeArmature.armature().getSlot("changeSlotName"); + factory.replaceSlotDisplay(toChangeArmature.getArmatureKey(), "armatureName", "slotName", "displayName", needChangeSlot); + ``` + */ + getArmatureKey(): string; + /** + !#en + It's best to set cache mode before set property 'dragonAsset', or will waste some cpu time. + If set the mode in editor, then no need to worry about order problem. + !#zh + 若想切换渲染模式,最好在设置'dragonAsset'之前,先设置好渲染模式,否则有运行时开销。 + 若在编辑中设置渲染模式,则无需担心设置次序的问题。 + @param cacheMode cacheMode + + @example + ```js + armatureDisplay.setAnimationCacheMode(dragonBones.ArmatureDisplay.AnimationCacheMode.SHARED_CACHE); + ``` + */ + setAnimationCacheMode(cacheMode: ArmatureDisplay.AnimationCacheMode): void; + /** + !#en Whether in cached mode. + !#zh 当前是否处于缓存模式。 + */ + isAnimationCached(): boolean; + /** + !#en + Play the specified animation. + Parameter animName specify the animation name. + Parameter playTimes specify the repeat times of the animation. + -1 means use the value of the config file. + 0 means play the animation for ever. + >0 means repeat times. + !#zh + 播放指定的动画. + animName 指定播放动画的名称。 + playTimes 指定播放动画的次数。 + -1 为使用配置文件中的次数。 + 0 为无限循环播放。 + >0 为动画的重复次数。 + @param animName animName + @param playTimes playTimes + */ + playAnimation(animName: string, playTimes: number): dragonBones.AnimationState; + /** + !#en + Updating an animation cache to calculate all frame data in the animation is a cost in + performance due to calculating all data in a single frame. + To update the cache, use the invalidAnimationCache method with high performance. + !#zh + 更新某个动画缓存, 预计算动画中所有帧数据,由于在单帧计算所有数据,所以较消耗性能。 + 若想更新缓存,可使用 invalidAnimationCache 方法,具有较高性能。 + @param animName animName + */ + updateAnimationCache(animName: string): void; + /** + !#en + Invalidates the animation cache, which is then recomputed on each frame.. + !#zh + 使动画缓存失效,之后会在每帧重新计算。 + */ + invalidAnimationCache(): void; + /** + !#en + Get the all armature names in the DragonBones Data. + !#zh + 获取 DragonBones 数据中所有的 armature 名称 + */ + getArmatureNames(): any[]; + /** + !#en + Get the all animation names of specified armature. + !#zh + 获取指定的 armature 的所有动画名称。 + @param armatureName armatureName + */ + getAnimationNames(armatureName: string): any[]; + /** + !#en + Add event listener for the DragonBones Event, the same to addEventListener. + !#zh + 添加 DragonBones 事件监听器,与 addEventListener 作用相同。 + @param type A string representing the event type to listen for. + @param listener The callback that will be invoked when the event is dispatched. + @param target The target (this object) to invoke the callback, can be null + */ + on(type: string, listener: (event: cc.Event) => void, target?: any): void; + /** + !#en + Remove the event listener for the DragonBones Event, the same to removeEventListener. + !#zh + 移除 DragonBones 事件监听器,与 removeEventListener 作用相同。 + @param type A string representing the event type to listen for. + @param listener listener + @param target target + */ + off(type: string, listener?: Function, target?: any): void; + /** + !#en + Add DragonBones one-time event listener, the callback will remove itself after the first time it is triggered. + !#zh + 添加 DragonBones 一次性事件监听器,回调会在第一时间被触发后删除自身。 + @param type A string representing the event type to listen for. + @param listener The callback that will be invoked when the event is dispatched. + @param target The target (this object) to invoke the callback, can be null + */ + once(type: string, listener: (event: cc.Event) => void, target?: any): void; + /** + !#en + Add event listener for the DragonBones Event. + !#zh + 添加 DragonBones 事件监听器。 + @param type A string representing the event type to listen for. + @param listener The callback that will be invoked when the event is dispatched. + @param target The target (this object) to invoke the callback, can be null + */ + addEventListener(type: string, listener: (event: cc.Event) => void, target?: any): void; + /** + !#en + Remove the event listener for the DragonBones Event. + !#zh + 移除 DragonBones 事件监听器。 + @param type A string representing the event type to listen for. + @param listener listener + @param target target + */ + removeEventListener(type: string, listener?: Function, target?: any): void; + /** + !#en + Build the armature for specified name. + !#zh + 构建指定名称的 armature 对象 + @param armatureName armatureName + @param node node + */ + buildArmature(armatureName: string, node: cc.Node): ArmatureDisplay; + /** + !#en + Get the current armature object of the ArmatureDisplay. + !#zh + 获取 ArmatureDisplay 当前使用的 Armature 对象 + */ + armature(): any; + } + /** DragonBones factory */ + export class CCFactory extends BaseFactory { + /** + + + @example + ```js + let factory = dragonBones.CCFactory.getInstance(); + ``` + */ + static getInstance(): CCFactory; + } + /** !#en The skeleton data of dragonBones. + !#zh dragonBones 的 骨骼数据。 */ + export class DragonBonesAsset extends cc.Asset { + /** !#en See http://developer.egret.com/cn/github/egret-docs/DB/dbLibs/dataFormat/index.html + !#zh 可查看 DragonBones 官方文档 http://developer.egret.com/cn/github/egret-docs/DB/dbLibs/dataFormat/index.html */ + dragonBonesJson: string; + } + /** !#en The skeleton atlas data of dragonBones. + !#zh dragonBones 的骨骼纹理数据。 */ + export class DragonBonesAtlasAsset extends cc.Asset { + atlasJson: string; + texture: cc.Texture2D; + } + /**************************************************** + * ArmatureDisplay + *****************************************************/ + + export namespace ArmatureDisplay { + /** !#en Enum for cache mode type. + !#zh Dragonbones渲染类型 */ + export enum AnimationCacheMode { + REALTIME = 0, + SHARED_CACHE = 0, + PRIVATE_CACHE = 0, + } + } + + /**************************************************** + * dragonBones + *****************************************************/ + + export namespace dragonBones { + /** !#en Attach node tool + !#zh 挂点工具类 */ + export class AttachUtil { + /** + !#en Gets attached root node. + !#zh 获取挂接节点树的根节点 + */ + getAttachedRootNode(): cc.Node; + /** + !#en Gets attached node which you want. + !#zh 获得对应的挂点 + @param boneName boneName + */ + getAttachedNodes(boneName: string): cc.Node[]; + /** + !#en Destroy attached node which you want. + !#zh 销毁对应的挂点 + @param boneName boneName + */ + destroyAttachedNodes(boneName: string): void; + /** + !#en Traverse all bones to generate the minimum node tree containing the given bone names, NOTE that make sure the skeleton has initialized before calling this interface. + !#zh 遍历所有插槽,生成包含所有给定插槽名称的最小节点树,注意,调用该接口前请确保骨骼动画已经初始化好。 + @param boneName boneName + */ + generateAttachedNodes(boneName: string): cc.Node[]; + /** + !#en Destroy all attached node. + !#zh 销毁所有挂点 + */ + destroyAllAttachedNodes(): void; + /** + !#en Traverse all bones to generate a tree containing all bones nodes, NOTE that make sure the skeleton has initialized before calling this interface. + !#zh 遍历所有插槽,生成包含所有插槽的节点树,注意,调用该接口前请确保骨骼动画已经初始化好。 + */ + generateAllAttachedNodes(): cc.Node; + } + } + +} + +/** !#en +This module controls asset's behaviors and information, include loading, releasing etc. +All member can be accessed with `cc.assetManager`. All class or enum can be accessed with `cc.AssetManager` + +!#zh +此模块管理资源的行为和信息,包括加载,释放等,所有成员能够通过 `cc.assetManager` 调用. 所有类型或枚举能通过 `cc.AssetManager` 访问 */ +declare namespace cc.AssetManager { + /** !#en + This module contains the builtin asset, it's a singleton, all member can be accessed with `cc.assetManager.builtins` + + !#zh + 此模块包含内建资源,这是一个单例,所有成员能通过 `cc.assetManager.builtins` 访问 */ + export class Builtins { + /** + !#en + Initialize + + !#zh + 初始化 + @param cb Callback when finish loading built-in assets + */ + init (cb: () => void): void; + /** + !#en + Get the built-in asset using specific type and name. + + !#zh + 通过特定的类型和名称获取内建资源 + @param type The type of asset, such as `effect` + @param name The name of asset, such as `phong` + + @example + ```js + cc.assetManaer.builtins.getBuiltin('effect', 'phone'); + ``` + */ + getBuiltin(type?: string, name?: string): cc.Asset | Cache; + /** + !#en + Clear all builtin assets + + !#zh + 清空所有内置资源 + */ + clear(): void; + } + /** !#en + A bundle contains an amount of assets(includes scene), you can load, preload, release asset which is in this bundle + + !#zh + 一个包含一定数量资源(包括场景)的包,你可以加载,预加载,释放此包内的资源 */ + export class Bundle { + /** + !#en + Create a bundle + + !#zh + 创建一个 bundle + */ + constructor(); + /** !#en + The name of this bundle + + !#zh + 此 bundle 的名称 */ + name: string; + /** !#en + The dependency of this bundle + + !#zh + 此 bundle 的依赖 */ + deps: string[]; + /** !#en + The root path of this bundle, such like 'http://example.com/bundle1' + + !#zh + 此 bundle 的根路径, 例如 'http://example.com/bundle1' */ + base: string; + /** + !#en + Get asset's info using path, only valid when asset is in bundle folder. + + !#zh + 使用 path 获取资源的配置信息 + @param path The relative path of asset, such as 'images/a' + @param type The constructor of asset, such as `cc.Texture2D` + + @example + ```js + var info = bundle.getInfoWithPath('image/a', cc.Texture2D); + ``` + */ + getInfoWithPath (path: string, type?: typeof cc.Asset): Record; + /** + !#en + Get all asset's info within specific folder + + !#zh + 获取在某个指定文件夹下的所有资源信息 + @param path The relative path of folder, such as 'images' + @param type The constructor should be used to filter paths + @param out The output array + + @example + ```js + var infos = []; + bundle.getDirWithPath('images', cc.Texture2D, infos); + ``` + */ + getDirWithPath (path: string, type: typeof cc.Asset, out: Array>): Array>; + getDirWithPath (path: string, type: typeof cc.Asset): Array>; + getDirWithPath (path: string): Array>; + /** + !#en + Get asset's info with uuid + + !#zh + 通过 uuid 获取资源信息 + @param uuid The asset's uuid + + @example + ```js + var info = bundle.getAssetInfo('fcmR3XADNLgJ1ByKhqcC5Z'); + ``` + */ + getAssetInfo (uuid: string): Record; + /** + !#en + Get scene'info with name + + !#zh + 通过场景名获取场景信息 + @param name The name of scene + + @example + ```js + var info = bundle.getSceneInfo('first.fire'); + ``` + */ + getSceneInfo(name: string): Record; + /** + !#en + Initialize this bundle with options + + !#zh + 初始化此 bundle + @param options options + */ + init(options: Record): void; + /** + !#en + Load the asset within this bundle by the path which is relative to bundle's path + + !#zh + 通过相对路径加载分包中的资源。路径是相对分包文件夹路径的相对路径 + @param paths Paths of the target assets.The path is relative to the bundle's folder, extensions must be omitted. + @param type Only asset of type will be loaded if this argument is supplied. + @param onProgress Callback invoked when progression change. + @param onComplete Callback invoked when all assets loaded. + + @example + ```js + // load the texture (${project}/assets/resources/textures/background.jpg) from resources + cc.resources.load('textures/background', cc.Texture2D, (err, texture) => console.log(err)); + + // load the audio (${project}/assets/resources/music/hit.mp3) from resources + cc.resources.load('music/hit', cc.AudioClip, (err, audio) => console.log(err)); + + // load the prefab (${project}/assets/bundle1/misc/character/cocos) from bundle1 folder + bundle1.load('misc/character/cocos', cc.Prefab, (err, prefab) => console.log(err)); + + // load the sprite frame (${project}/assets/some/xxx/bundle2/imgs/cocos.png) from bundle2 folder + bundle2.load('imgs/cocos', cc.SpriteFrame, null, (err, spriteFrame) => console.log(err)); + ``` + */ + load(paths: string, type: typeof cc.Asset, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, assets: T) => void): void; + load(paths: string[], type: typeof cc.Asset, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, assets: Array) => void): void; + load(paths: string, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, assets: T) => void): void; + load(paths: string[], onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, assets: Array) => void): void; + load(paths: string, type: typeof cc.Asset, onComplete?: (error: Error, assets: T) => void): void; + load(paths: string[], type: typeof cc.Asset, onComplete?: (error: Error, assets: Array) => void): void; + load(paths: string, onComplete?: (error: Error, assets: T) => void): void; + load(paths: string[], onComplete?: (error: Error, assets: Array) => void): void; + /** + !#en + Preload the asset within this bundle by the path which is relative to bundle's path. + After calling this method, you still need to finish loading by calling `Bundle.load`. + It will be totally fine to call `Bundle.load` at any time even if the preloading is not + yet finished + + !#zh + 通过相对路径预加载分包中的资源。路径是相对分包文件夹路径的相对路径。调用完后,你仍然需要通过 `Bundle.load` 来完成加载。 + 就算预加载还没完成,你也可以直接调用 `Bundle.load`。 + @param paths Paths of the target asset.The path is relative to bundle folder, extensions must be omitted. + @param type Only asset of type will be loaded if this argument is supplied. + @param onProgress Callback invoked when progression change. + @param onComplete Callback invoked when the resource loaded. + + @example + ```js + // preload the texture (${project}/assets/resources/textures/background.jpg) from resources + cc.resources.preload('textures/background', cc.Texture2D); + + // preload the audio (${project}/assets/resources/music/hit.mp3) from resources + cc.resources.preload('music/hit', cc.AudioClip); + // wait for while + cc.resources.load('music/hit', cc.AudioClip, (err, audioClip) => {}); + + * // preload the prefab (${project}/assets/bundle1/misc/character/cocos) from bundle1 folder + bundle1.preload('misc/character/cocos', cc.Prefab); + + // load the sprite frame of (${project}/assets/bundle2/imgs/cocos.png) from bundle2 folder + bundle2.preload('imgs/cocos', cc.SpriteFrame); + // wait for while + bundle2.load('imgs/cocos', cc.SpriteFrame, (err, spriteFrame) => {}); + ``` + */ + preload(paths: string|string[], type: typeof cc.Asset, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, items: RequestItem[]) => void): void; + preload(paths: string|string[], onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, items: RequestItem[]) => void): void; + preload(paths: string|string[], type: typeof cc.Asset, onComplete: (error: Error, items: RequestItem[]) => void): void; + preload(paths: string|string[], type: typeof cc.Asset): void; + preload(paths: string|string[], onComplete: (error: Error, items: RequestItem[]) => void): void; + preload(paths: string|string[]): void; + /** + !#en + Load all assets under a folder inside the bundle folder.
+
+ Note: All asset paths in Creator use forward slashes, paths using backslashes will not work. + + !#zh + 加载目标文件夹中的所有资源, 注意:路径中只能使用斜杠,反斜杠将停止工作 + @param dir path of the target folder.The path is relative to the bundle folder, extensions must be omitted. + @param type Only asset of type will be loaded if this argument is supplied. + @param onProgress Callback invoked when progression change. + @param onComplete A callback which is called when all assets have been loaded, or an error occurs. + + @example + ```js + // load all audios (resources/audios/) + cc.resources.loadDir('audios', cc.AudioClip, (err, audios) => {}); + + // load all textures in "resources/imgs/" + cc.resources.loadDir('imgs', cc.Texture2D, null, function (err, textures) { + var texture1 = textures[0]; + var texture2 = textures[1]; + }); + + // load all prefabs (${project}/assets/bundle1/misc/characters/) from bundle1 folder + bundle1.loadDir('misc/characters', cc.Prefab, (err, prefabs) => console.log(err)); + + // load all sprite frame (${project}/assets/some/xxx/bundle2/skills/) from bundle2 folder + bundle2.loadDir('skills', cc.SpriteFrame, null, (err, spriteFrames) => console.log(err)); + ``` + */ + loadDir(dir: string, type: typeof cc.Asset, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, assets: Array) => void): void; + loadDir(dir: string, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, assets: Array) => void): void; + loadDir(dir: string, type: typeof cc.Asset, onComplete: (error: Error, assets: Array) => void): void; + loadDir(dir: string, type: typeof cc.Asset): void; + loadDir(dir: string, onComplete: (error: Error, assets: Array) => void): void; + loadDir(dir: string): void; + /** + !#en + Preload all assets under a folder inside the bundle folder.
After calling this method, you still need to finish loading by calling `Bundle.loadDir`. + It will be totally fine to call `Bundle.loadDir` at any time even if the preloading is not yet finished + + !#zh + 预加载目标文件夹中的所有资源。调用完后,你仍然需要通过 `Bundle.loadDir` 来完成加载。 + 就算预加载还没完成,你也可以直接调用 `Bundle.loadDir`。 + @param dir path of the target folder.The path is relative to the bundle folder, extensions must be omitted. + @param type Only asset of type will be preloaded if this argument is supplied. + @param onProgress Callback invoked when progression change. + @param onComplete A callback which is called when all assets have been loaded, or an error occurs. + + @example + ```js + // preload all audios (resources/audios/) + cc.resources.preloadDir('audios', cc.AudioClip); + + // preload all textures in "resources/imgs/" + cc.resources.preloadDir('imgs', cc.Texture2D); + // wait for while + cc.resources.loadDir('imgs', cc.Texture2D, (err, textures) => {}); + + // preload all prefabs (${project}/assets/bundle1/misc/characters/) from bundle1 folder + bundle1.preloadDir('misc/characters', cc.Prefab); + + // preload all sprite frame (${project}/assets/some/xxx/bundle2/skills/) from bundle2 folder + bundle2.preloadDir('skills', cc.SpriteFrame); + // wait for while + bundle2.loadDir('skills', cc.SpriteFrame, (err, spriteFrames) => {}); + ``` + */ + preloadDir(dir: string, type: typeof cc.Asset, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, items: RequestItem[]) => void): void; + preloadDir(dir: string, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, items: RequestItem[]) => void): void; + preloadDir(dir: string, type: typeof cc.Asset, onComplete: (error: Error, items: RequestItem[]) => void): void; + preloadDir(dir: string, type: typeof cc.Asset): void; + preloadDir(dir: string, onComplete: (error: Error, items: RequestItem[]) => void): void; + preloadDir(dir: string): void; + /** + !#en + Loads the scene within this bundle by its name. + + !#zh + 通过场景名称加载分包中的场景。 + @param sceneName The name of the scene to load. + @param options Some optional parameters + @param onProgress Callback invoked when progression change. + @param onComplete callback, will be called after scene launched. + + @example + ```js + bundle1.loadScene('first', (err, sceneAsset) => cc.director.runScene(sceneAsset)); + ``` + */ + loadScene(sceneName: string, options: Record, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, sceneAsset: cc.SceneAsset) => void): void; + loadScene(sceneName: string, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, sceneAsset: cc.SceneAsset) => void): void; + loadScene(sceneName: string, options: Record, onComplete: (error: Error, sceneAsset: cc.SceneAsset) => void): void; + loadScene(sceneName: string, onComplete: (error: Error, sceneAsset: cc.SceneAsset) => void): void; + loadScene(sceneName: string, options: Record): void; + loadScene(sceneName: string): void; + /** + !#en + Preloads the scene within this bundle by its name. After calling this method, you still need to finish loading by calling `Bundle.loadScene` or `cc.director.loadScene`. + It will be totally fine to call `Bundle.loadDir` at any time even if the preloading is not yet finished + + !#zh + 通过场景名称预加载分包中的场景.调用完后,你仍然需要通过 `Bundle.loadScene` 或 `cc.director.loadScene` 来完成加载。 + 就算预加载还没完成,你也可以直接调用 `Bundle.loadScene` 或 `cc.director.loadScene`。 + @param sceneName The name of the scene to preload. + @param options Some optional parameters + @param onProgress callback, will be called when the load progression change. + @param onComplete callback, will be called after scene loaded. + + @example + ```js + bundle1.preloadScene('first'); + // wait for a while + bundle1.loadScene('first', (err, scene) => cc.director.runScene(scene)); + ``` + */ + preloadScene(sceneName: string, options: Record, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error) => void): void; + preloadScene(sceneName: string, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error) => void): void; + preloadScene(sceneName: string, options: Record, onComplete: (error: Error) => void): void; + preloadScene(sceneName: string, onComplete: (error: Error) => void): void; + preloadScene(sceneName: string, options: Record): void; + preloadScene(sceneName: string): void; + /** + !#en + Get asset within this bundle by path and type.
+ After you load asset with {{#crossLink "Bundle/load:method"}}{{/crossLink}} or {{#crossLink "Bundle/loadDir:method"}}{{/crossLink}}, + you can acquire them by passing the path to this API. + + !#zh + 通过路径与类型获取资源。在你使用 {{#crossLink "Bundle/load:method"}}{{/crossLink}} 或者 {{#crossLink "Bundle/loadDir:method"}}{{/crossLink}} 之后, + 你能通过传路径通过这个 API 获取到这些资源。 + @param path The path of asset + @param type Only asset of type will be returned if this argument is supplied. + + @example + ```js + bundle1.get('music/hit', cc.AudioClip); + ``` + */ + get (path: string, type?: typeof cc.Asset): T; + /** + !#en + Release the asset loaded by {{#crossLink "Bundle/load:method"}}{{/crossLink}} or {{#crossLink "Bundle/loadDir:method"}}{{/crossLink}} and it's dependencies. + Refer to {{#crossLink "AssetManager/releaseAsset:method"}}{{/crossLink}} for detailed informations. + + !#zh + 释放通过 {{#crossLink "Bundle/load:method"}}{{/crossLink}} 或者 {{#crossLink "Bundle/loadDir:method"}}{{/crossLink}} 加载的资源。详细信息请参考 {{#crossLink "AssetManager/releaseAsset:method"}}{{/crossLink}} + @param path The path of asset + @param type Only asset of type will be released if this argument is supplied. + + @example + ```js + // release a texture which is no longer need + bundle1.release('misc/character/cocos'); + ``` + */ + release(path: string, type: typeof cc.Asset): void; + release(path: string): void; + /** + !#en + Release all assets within this bundle. Refer to {{#crossLink "AssetManager/releaseAll:method"}}{{/crossLink}} for detailed informations. + + !#zh + 释放此包中的所有资源。详细信息请参考 {{#crossLink "AssetManager/releaseAll:method"}}{{/crossLink}} + + @example + ```js + // release all asset within bundle1 + bundle1.releaseAll(); + ``` + */ + releaseAll(): void; + } + /** !#en + Cache manager is a module which controls all caches downloaded from server in non-web platform, it is a singleton + All member can be accessed with `cc.assetManager.cacheManager`. + + !#zh + 缓存管理器是一个模块,在非 WEB 平台上,用于管理所有从服务器上下载下来的缓存,这是一个单例,所有成员能通过 `cc.assetManager.cacheManager` 访问。 */ + export class CacheManager { + /** !#en + The name of cacheDir + + !#zh + 缓存目录的名称 */ + cacheDir: string; + /** !#en + Whether or not cache asset into user's storage space, this property only works on mini-game platforms + + !#zh + 是否缓存资源到用户存储空间,此属性只在小游戏平台有效 */ + cacheEnabled: boolean; + /** !#en + Whether or not auto clear cache when storage ran out, this property only works on mini-game platforms + + !#zh + 是否在存储空间满了后自动清理缓存,此属性只在小游戏平台有效 */ + autoClear: boolean; + /** !#en + The interval between caching resources, this property only works on mini-game platforms, unit: ms + + !#zh + 缓存资源的间隔时间,此属性只在小游戏平台有效,单位:ms */ + cacheInterval: number; + /** !#en + The interval between deleting resources, when you use `cleanLRU`, the resources will be deleted as this interval, unit: ms + + !#zh + 清理资源的间隔时间,当你使用 `cleanLRU` 时,资源将以此间隔被删除,单位:ms */ + deleteInterval: number; + /** !#en + List of all cached files + + !#zh + 所有缓存文件列表 */ + cachedFiles: Cache<{ bundle: string, url: string, lastTime: url }>; + /** + !#en + Get cached path with origin url + + !#zh + 通过原始 url 获取缓存后的路径 + @param originUrl originUrl + */ + getCache(originUrl: string): string; + /** + !#en + Get temporary path with origin url, this method only works on mini-game platforms + + !#zh + 通过原始 url 获取临时文件的路径,此方法只在小游戏平台有效 + @param originUrl originUrl + */ + getTemp(originUrl: string): string; + /** + !#en + Clear all caches, please use with caution, If necessary, we recommend using it before the game is launched + + !#zh + 清空所有缓存,请谨慎使用,如果必要的话,我们建议在游戏启动之前使用 + */ + clearCache(): void; + /** + !#en + Clear part of caches with LRU strategy + + !#zh + 使用 LRU 策略清空部分缓存 + */ + clearLRU(): void; + /** + !#en + Remove cache with origin url + + !#zh + 通过原始 url 移除缓存 + */ + removeCache(): void; + } + /** !#en + use to cache something + + !#zh + 用于缓存某些内容 */ + export class Cache { + /** + !#en + Create a cache + + !#zh + 创建一个 cache + @param map An object used to initialize + */ + constructor(map?: Record); + /** + !#en + Add Key-Value to cache + + !#zh + 增加键值对到缓存中 + @param key The key + @param val The value + + @example + ```js + var cache = new Cache(); + cache.add('test', null); + ``` + */ + add(key: string, val: T): T; + /** + !#en + Get the cached content by key + + !#zh + 通过 key 获取对应的 value + @param key The key + + @example + ```js + var cache = new Cache(); + var test = cache.get('test'); + ``` + */ + get(key: string): T; + /** + !#en + Check whether or not content exists by key + + !#zh + 通过 Key 判断是否存在对应的内容 + @param key The key + + @example + ```js + var cache = new Cache(); + var exist = cache.has('test'); + ``` + */ + has(key: string): boolean; + /** + !#en + Remove the cached content by key + + !#zh + 通过 Key 移除对应的内容 + @param key The key + + @example + ```js + var cache = new Cache(); + var content = cache.remove('test'); + ``` + */ + remove(key: string): T; + /** + !#en + Clear all content + + !#zh + 清除所有内容 + + @example + ```js + var cache = new Cache(); + cache.clear(); + ``` + */ + clear():void; + /** + !#en + Enumerate all content and invoke function + + !#zh + 枚举所有内容并执行方法 + @param func Function to be invoked + + @example + ```js + var cache = new Cache(); + cache.forEach((val, key) => console.log(key)); + ``` + */ + forEach(func: (val: T, key: string) => void): void; + /** + !#en + Enumerate all content to find one element which can fulfill condition + + !#zh + 枚举所有内容,找到一个可以满足条件的元素 + @param predicate The condition + + @example + ```js + var cache = new Cache(); + var val = cache.find((val, key) => key === 'test'); + ``` + */ + find(predicate: (val: T, key: string) => boolean): T; + /** !#en + The count of cached content + + !#zh + 缓存数量 */ + count: number; + /** + !#en + Destroy this cache + + !#zh + 销毁这个 cache + */ + destroy(): void; + } + /** !#en + Control asset's dependency list, it is a singleton. All member can be accessed with `cc.assetManager.dependUtil` + + !#zh + 控制资源的依赖列表,这是一个单例, 所有成员能通过 `cc.assetManager.dependUtil` 访问 */ + export class DependUtil { + /** + !#en + Get asset's native dependency. For example, Texture's native dependency is image. + + !#zh + 获取资源的原生依赖,例如 Texture 的原生依赖是图片 + @param uuid asset's uuid + + @example + ```js + var dep = dependUtil.getNativeDep('fcmR3XADNLgJ1ByKhqcC5Z'); + ``` + */ + getNativeDep(uuid: string): Record; + /** + !#en + Get asset's direct referencing non-native dependency list. For example, Material's non-native dependencies are Texture. + + !#zh + 获取资源直接引用的非原生依赖列表,例如,材质的非原生依赖是 Texture + @param uuid asset's uuid + + @example + ```js + var deps = dependUtil.getDeps('fcmR3XADNLgJ1ByKhqcC5Z'); + ``` + */ + getDeps(uuid: string): string[]; + /** + !#en + Get non-native dependency list of the loaded asset, include indirect reference. + The returned array stores the dependencies with their uuid, after retrieve dependencies, + + !#zh + 获取某个已经加载好的资源的所有非原生依赖资源列表,包括间接引用的资源,并保存在数组中返回。 + 返回的数组将仅保存依赖资源的 uuid。 + @param uuid The asset's uuid + + @example + ```js + var deps = dependUtil.getDepsRecursively('fcmR3XADNLgJ1ByKhqcC5Z'); + ``` + */ + getDepsRecursively(uuid: string): string[]; + } + /** !#en + Control all download process, it is a singleton. All member can be accessed with `cc.assetManager.downloader` , it can download several types of files: + 1. Text + 2. Image + 3. Audio + 4. Assets + 5. Scripts + + !#zh + 管理所有下载过程,downloader 是个单例,所有成员能通过 `cc.assetManager.downloader` 访问,它能下载以下几种类型的文件: + 1. 文本 + 2. 图片 + 3. 音频 + 4. 资源 + 5. 脚本 */ + export class Downloader { + /** !#en + The address of remote server + + !#zh + 远程服务器地址 */ + remoteServerAddress: string; + /** !#en + The maximum number of concurrent when downloading + + !#zh + 下载时的最大并发数 */ + maxConcurrency: number; + /** !#en + The maximum number of request can be launched per frame when downloading + + !#zh + 下载时每帧可以启动的最大请求数 */ + maxRequestsPerFrame: number; + /** !#en + The max number of retries when fail + + !#zh + 失败重试次数 */ + maxRetryCount: number; + /** !#en + Wait for while before another retry, unit: ms + + !#zh + 重试的间隔时间 */ + retryInterval: number; + /** + !#en + Register custom handler if you want to change default behavior or extend downloader to download other format file + + !#zh + 当你想修改默认行为或者拓展 downloader 来下载其他格式文件时可以注册自定义的 handler + @param type Extension likes '.jpg' or map likes {'.jpg': jpgHandler, '.png': pngHandler} + @param handler handler + + @example + ```js + downloader.register('.tga', (url, options, onComplete) => onComplete(null, null)); + downloader.register({'.tga': (url, options, onComplete) => onComplete(null, null), '.ext': (url, options, onComplete) => onComplete(null, null)}); + ``` + */ + register(type: string, handler: (url: string, options: Record, onComplete: (err: Error, content: any) => void) => void): void; + register(map: Record, onComplete: (err: Error, content: any) => void) => void>): void; + /** + !#en + Use corresponding handler to download file under limitation + + !#zh + 在限制下使用对应的 handler 来下载文件 + @param url The url should be downloaded + @param type The type indicates that which handler should be used to download, such as '.jpg' + @param options some optional paramters will be transferred to the corresponding handler. + @param onComplete callback when finishing downloading + + @example + ```js + download('http://example.com/test.tga', '.tga', {onFileProgress: (loaded, total) => console.lgo(loaded/total)}, onComplete: (err) => console.log(err)); + ``` + */ + download(id: string, url: string, type: string, options: Record, onComplete: (err: Error, content: any) => void): void; + } + /** !#en + Provide some helpful function, it is a singleton. All member can be accessed with `cc.assetManager.utils` + + !#zh + 提供一些辅助方法,helper 是一个单例, 所有成员能通过 `cc.assetManager.utils` 访问 */ + export class Helper { + /** + !#en + Decode uuid, returns the original uuid + + !#zh + 解码 uuid,返回原始 uuid + @param base64 the encoded uuid + + @example + ```js + var uuid = 'fcmR3XADNLgJ1ByKhqcC5Z'; + var originalUuid = decodeUuid(uuid); // fc991dd7-0033-4b80-9d41-c8a86a702e59 + ``` + */ + decodeUuid(base64: string): string; + /** + !#en + Extract uuid from url + + !#zh + 从 url 中提取 uuid + @param url url + + @example + ```js + var url = 'assets/main/import/fc/fc991dd7-0033-4b80-9d41-c8a86a702e59.json'; + var uuid = getUuidFromURL(url); // fc991dd7-0033-4b80-9d41-c8a86a702e59 + ``` + */ + getUuidFromURL(url: string): string; + /** + !#en + Transform uuid to url + + !#zh + 转换 uuid 为 url + @param uuid The uuid of asset + @param options Some optional parameters + + @example + ```js + // json path, 'assets/main/import/fc/fc991dd7-0033-4b80-9d41-c8a86a702e59.json'; + var url = getUrlWithUuid('fcmR3XADNLgJ1ByKhqcC5Z', {isNative: false}); + + // png path, 'assets/main/native/fc/fc991dd7-0033-4b80-9d41-c8a86a702e59.png'; + var url = getUrlWithUuid('fcmR3XADNLgJ1ByKhqcC5Z', {isNative: true, nativeExt: '.png'}); + ``` + */ + getUrlWithUuid(uuid: string, options?: Record): string; + /** + !#en + Check if the type of asset is scene + + !#zh + 检查资源类型是否是场景 + @param asset asset + */ + isScene(asset: any): boolean; + /** + !#en + Normalize url, strip './' and '/' + + !#zh + 标准化 url ,去除 './' 和 '/' + @param url url + */ + normalize(url: string): string; + } + /** !#en + Handle the packed asset, include unpacking, loading, cache and so on. It is a singleton. All member can be accessed with `cc.assetManager.packManager` + + !#zh + 处理打包资源,包括拆包,加载,缓存等等,这是一个单例, 所有成员能通过 `cc.assetManager.packManager` 访问 */ + export class PackManager { + /** + !#en + Unpack the json, revert to what it was before packing + + !#zh + 拆解 json 包,恢复为打包之前的内容 + @param pack The pack + @param json The content of pack + @param options Some optional parameters + @param onComplete Callback when finish unpacking + + @example + ```js + downloader.downloadFile('pack.json', {responseType: 'json'}, null, (err, file) => { + packManager.unpackJson(['a', 'b'], file, null, (err, data) => console.log(err)); + }); + ``` + */ + unpackJson(pack: string[], json: any, options: Record, onComplete?: (err: Error, content: any) => void): void; + /** + !#en + Register custom handler if you want to change default behavior or extend packManager to unpack other format pack + + !#zh + 当你想修改默认行为或者拓展 packManager 来拆分其他格式的包时可以注册自定义的 handler + @param type Extension likes '.bin' or map likes {'.bin': binHandler, '.ab': abHandler} + @param handler handler + + @example + ```js + packManager.register('.bin', (packUuid, file, options, onComplete) => onComplete(null, null)); + packManager.register({'.bin': (packUuid, file, options, onComplete) => onComplete(null, null), '.ab': (packUuid, file, options, onComplete) => onComplete(null, null)}); + ``` + */ + register(type: string, handler: (packUuid: string, data: any, options: Record, onComplete: (err: Error, content: any) => void) => void): void; + register(map: Record, onComplete: (err: Error, content: any) => void) => void>): void; + /** + !#en + Use corresponding handler to unpack package + + !#zh + 用对应的 handler 来进行解包 + @param pack The uuid of packed assets + @param data The packed data + @param type The type indicates that which handler should be used to download, such as '.jpg' + @param options Some optional parameter + @param onComplete callback when finishing unpacking + + @example + ```js + downloader.downloadFile('pack.json', {responseType: 'json'}, null, (err, file) => { + packManager.unpack(['2fawq123d', '1zsweq23f'], file, '.json', null, (err, data) => console.log(err)); + }); + ``` + */ + unpack(pack: string[], data: any, type: string, options: Record, onComplete?: (err: Error, data: any) => void): void; + /** + !#en + Download request item, If item is not in any package, download as usual. Otherwise, download the corresponding package and unpack it. + And then retrieve the corresponding content form it. + + !#zh + 下载请求对象,如果请求对象不在任何包内,则正常下载,否则下载对应的 package 并进行拆解,并取回包内对应的内容 + @param item Some item you want to download + @param options Some optional parameters + @param onComplete Callback when finished + + @example + ```js + var requestItem = cc.AssetManager.RequestItem.create(); + requestItem.uuid = 'fcmR3XADNLgJ1ByKhqcC5Z'; + requestItem.info = config.getAssetInfo('fcmR3XADNLgJ1ByKhqcC5Z'); + packManager.load(requestItem, null, (err, data) => console.log(err)); + ``` + */ + load(item: RequestItem, options: Record, onComplete: (err: Error, data: any) => void): void; + } + /** !#en + Parse the downloaded file, it's a singleton, all member can be accessed with `cc.assetManager.parser` + + !#zh + 解析已下载的文件,parser 是一个单例, 所有成员能通过 `cc.assetManaager.parser` 访问 */ + export class Parser { + /** + !#en + Register custom handler if you want to change default behavior or extend parser to parse other format file + + !#zh + 当你想修改默认行为或者拓展 parser 来解析其他格式文件时可以注册自定义的handler + @param type Extension likes '.jpg' or map likes {'.jpg': jpgHandler, '.png': pngHandler} + @param handler The corresponding handler + + @example + ```js + parser.register('.tga', (file, options, onComplete) => onComplete(null, null)); + parser.register({'.tga': (file, options, onComplete) => onComplete(null, null), '.ext': (file, options, onComplete) => onComplete(null, null)}); + ``` + */ + register(type: string, handler: (file: any, options: Record, onComplete: (err: Error, data: any) => void) => void): void; + register(map: Record, onComplete: (err: Error, data: any) => void) => void>): void; + /** + !#en + Use corresponding handler to parse file + + !#zh + 使用对应的handler来解析文件 + @param id The id of file + @param file File + @param type The corresponding type of file, likes '.jpg'. + @param options Some optional paramters will be transferred to the corresponding handler. + @param onComplete callback when finishing downloading + + @example + ```js + downloader.downloadFile('test.jpg', {responseType: 'blob'}, null, (err, file) => { + parser.parse('test.jpg', file, '.jpg', null, (err, img) => console.log(err)); + }); + ``` + */ + parse(id: string, file: any, type: string, options: Record, onComplete: (err: Error, content: any) => void): void; + } + /** !#en + Pipeline can execute the task for some effect. + + !#zh + 管线能执行任务达到某个效果 */ + export class Pipeline { + /** !#en + The id of pipeline + + !#zh + 管线的 id */ + id: number; + /** !#en + The name of pipeline + + !#zh + 管线的名字 */ + name: string; + /** !#en + All pipes of pipeline + + !#zh + 所有的管道 */ + pipes: Function[]; + /** + !#en + Create a new pipeline + + !#zh + 创建一个管线 + @param name The name of pipeline + @param funcs The array of pipe, every pipe must be function which take two parameters, the first is a `Task` flowed in pipeline, the second is complete callback + + @example + ```js + var pipeline = new Pipeline('download', [ + (task, done) => { + var url = task.input; + cc.assetManager.downloader.downloadFile(url, null, null, (err, result) => { + task.output = result; + done(err); + }); + }, + (task, done) => { + var text = task.input; + var json = JSON.stringify(text); + task.output = json; + done(); + } + ]); + ``` + */ + constructor(name: string, funcs: Array<(task: Task, done?: (err: Error) => void) => void>); + /** + !#en + At specific point insert a new pipe to pipeline + + !#zh + 在某个特定的点为管线插入一个新的 pipe + @param func The new pipe + @param index The specific point you want to insert at. + + @example + ```js + var pipeline = new Pipeline('test', []); + pipeline.insert((task, done) => { + // do something + done(); + }, 0); + ``` + */ + insert(func: (task: Task, callback?: (err: Error) => void) => void, index: number): Pipeline; + /** + !#en + Append a new pipe to the pipeline + + !#zh + 添加一个管道到管线中 + @param func The new pipe + + @example + ```js + var pipeline = new Pipeline('test', []); + pipeline.append((task, done) => { + // do something + done(); + }); + ``` + */ + append(func: (task: Task, callback?: (err: Error) => void) => void): Pipeline; + /** + !#en + Remove pipe which at specific point + + !#zh + 移除特定位置的管道 + @param index The specific point + + @example + ```js + var pipeline = new Pipeline('test', (task, done) => { + // do something + done(); + }); + pipeline.remove(0); + ``` + */ + remove(index: number): Pipeline; + /** + !#en + Execute task synchronously + + !#zh + 同步执行任务 + @param task The task will be executed + + @example + ```js + var pipeline = new Pipeline('sync', [(task) => { + let input = task.input; + task.output = doSomething(task.input); + }]); + + var task = new Task({input: 'test'}); + console.log(pipeline.sync(task)); + ``` + */ + sync(task: Task): any; + /** + !#en + Execute task asynchronously + + !#zh + 异步执行任务 + @param task The task will be executed + + @example + ```js + var pipeline = new Pipeline('sync', [(task, done) => { + let input = task.input; + task.output = doSomething(task.input); + done(); + }]); + var task = new Task({input: 'test', onComplete: (err, result) => console.log(result)}); + pipeline.async(task); + ``` + */ + async(task: Task): void; + } + /** !#en + A collection of information about a request + + !#zh + 请求的相关信息集合 */ + export class RequestItem { + /** !#en + The uuid of request + + !#zh + 请求资源的uuid */ + uuid: string; + /** !#en + The final url of request + + !#zh + 请求的最终url */ + url: string; + /** !#en + The extension name of asset + + !#zh + 资源的扩展名 */ + ext: string; + /** !#en + The content of asset + + !#zh + 资源的内容 */ + content: any; + /** !#en + The file of asset + + !#zh + 资源的文件 */ + file: any; + /** !#en + The information of asset + + !#zh + 资源的相关信息 */ + info: any; + /** !#en + Whether or not it is native asset + + !#zh + 资源是否是原生资源 */ + isNative: boolean; + /** !#en + Custom options + + !#zh + 自定义参数 */ + options: any; + /** + !#en + Create a request item + + !#zh + 创建一个 request item + */ + constructor(); + /** !#en + The id of request, combined from uuid and isNative + + !#zh + 请求的 id, 由 uuid 和 isNative 组合而成 */ + id: string; + /** + !#en + Recycle this for reuse + + !#zh + 回收 requestItem 用于复用 + */ + recycle(): void; + /** + !#en + Create a new request item from pool + + !#zh + 从对象池中创建 requestItem + */ + static create(): RequestItem; + } + /** !#en + The builtin bundles + + !#zh + 内置 bundle */ + export enum BuiltinBundleName { + RESOURCES = 0, + INTERNAL = 0, + MAIN = 0, + START_SCENE = 0, + } + /** !#en + Task is used to run in the pipeline for some effect + + !#zh + 任务用于在管线中运行以达成某种效果 */ + export class Task { + /** !#en + The id of task + + !#zh + 任务id */ + id: number; + /** !#en + The callback when task is completed + + !#zh + 完成回调 */ + onComplete: Function; + /** !#en + The callback of progression + + !#zh + 进度回调 */ + onProgress: Function; + /** !#en + The callback when something goes wrong + + !#zh + 错误回调 */ + onError: Function; + /** !#en + The source of task + + !#zh + 任务的源 */ + source: any; + /** !#en + The output of task + + !#zh + 任务的输出 */ + output: any; + /** !#en + The input of task + + !#zh + 任务的输入 */ + input: any; + /** !#en + The progression of task + + !#zh + 任务的进度 */ + progress: any; + /** !#en + Custom options + + !#zh + 自定义参数 */ + options: any; + /** + !#en + Create a new Task + + !#zh + 创建一个任务 + @param options Some optional paramters + */ + constructor(options?: {onComplete?: (err: Error, result: any) => void, onError?: () => void, onProgress?: Function, input: any, progress?: any, options?: Record}); + /** + !#en + Set paramters of this task + + !#zh + 设置任务的参数 + @param options Some optional paramters + + @example + ```js + var task = new Task(); + task.set({input: ['test'], onComplete: (err, result) => console.log(err), onProgress: (finish, total) => console.log(finish / total)}); + ``` + */ + set(options?: {onComplete?: (err: Error, result: any) => void, onError?: () => void, onProgress?: Function, input: any, progress?: any, options?: Record}): void; + /** + !#en + Dispatch event + + !#zh + 发布事件 + @param event The event name + @param param1 Parameter 1 + @param param2 Parameter 2 + @param param3 Parameter 3 + @param param4 Parameter 4 + + @example + ```js + var task = Task.create(); + Task.onComplete = (msg) => console.log(msg); + Task.dispatch('complete', 'hello world'); + ``` + */ + dispatch(event: string, param1?: any, param2?: any, param3?: any, param4?: any): void; + /** + !#en + Recycle this for reuse + + !#zh + 回收 task 用于复用 + */ + recycle(): void; + /** !#en + Whether or not this task is completed + + !#zh + 此任务是否已经完成 */ + isFinish: boolean; + /** + !#en + Create a new task from pool + + !#zh + 从对象池中创建 task + @param options Some optional paramters + */ + static create(options?: {onComplete?: (err: Error, result: any) => void, onError?: () => void, onProgress?: Function, input: any, progress?: any, options?: Record}): Task; + } +} + +/** Some helpful utilities */ +declare namespace cc.geomUtils { + /** + !#en + the distance between a point and a plane + !#zh + 计算点和平面之间的距离。 + @param point point + @param plane plane + */ + export function point_plane(point: cc.Vec3, plane: cc.Plane): number; + /** + !#en + the closest point on plane to a given point + !#zh + 计算平面上最接近给定点的点。 + @param out Closest point + @param point Given point + @param plane plane + */ + export function pt_point_plane(out: cc.Vec3, point: cc.Vec3, plane: cc.Plane): cc.Vec3; + /** + !#en + the closest point on aabb to a given point + !#zh + 计算 aabb 上最接近给定点的点。 + @param out Closest point. + @param point Given point. + @param aabb Align the axis around the box. + */ + export function pt_point_aabb(out: cc.Vec3, point: cc.Vec3, aabb: cc.Aabb): cc.Vec3; + /** + !#en + the closest point on obb to a given point + !#zh + 计算 obb 上最接近给定点的点。 + @param out Closest point + @param point Given point + @param obb Direction box + */ + export function pt_point_obb(out: cc.Vec3, point: cc.Vec3, obb: cc.Obb): cc.Vec3; +} + +/** !#en Some JavaScript decorators which can be accessed with "cc._decorator". +!#zh 一些 JavaScript 装饰器,目前可以通过 "cc._decorator" 来访问。 +(这些 API 仍不完全稳定,有可能随着 JavaScript 装饰器的标准实现而调整) */ +declare namespace cc._decorator { + /** + !#en + Declare the standard [ES6 Class](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes) + as CCClass, please see [Class](../../../manual/en/scripting/class.html) for details. + !#zh + 将标准写法的 [ES6 Class](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes) 声明为 CCClass,具体用法请参阅[类型定义](../../../manual/zh/scripting/class.html)。 + @param name The class name used for serialization. + + @example + ```js + const {ccclass} = cc._decorator; + + // define a CCClass, omit the name + @ccclass + class NewScript extends cc.Component { + // ... + } + + // define a CCClass with a name + @ccclass('LoginData') + class LoginData { + // ... + } + ``` + */ + export function ccclass(name?: string): Function; + export function ccclass(_class?: Function): void; + /** + !#en + Declare property for [CCClass](../../../manual/en/scripting/reference/attributes.html). + !#zh + 定义 [CCClass](../../../manual/zh/scripting/reference/attributes.html) 所用的属性。 + @param options an object with some property attributes + + @example + ```js + const {ccclass, property} = cc._decorator; + + @ccclass + class NewScript extends cc.Component { + @property({ + type: cc.Node + }) + targetNode1 = null; + + @property(cc.Node) + targetNode2 = null; + + @property(cc.Button) + targetButton = null; + + @property + _width = 100; + + @property + get width () { + return this._width; + } + + @property + set width (value) { + this._width = value; + } + + @property + offset = new cc.Vec2(100, 100); + + @property(cc.Vec2) + offsets = []; + + @property(cc.SpriteFrame) + frame = null; + } + + // above is equivalent to (上面的代码相当于): + + var NewScript = cc.Class({ + properties: { + targetNode1: { + default: null, + type: cc.Node + }, + + targetNode2: { + default: null, + type: cc.Node + }, + + targetButton: { + default: null, + type: cc.Button + }, + + _width: 100, + + width: { + get () { + return this._width; + }, + set (value) { + this._width = value; + } + }, + + offset: new cc.Vec2(100, 100) + + offsets: { + default: [], + type: cc.Vec2 + } + + frame: { + default: null, + type: cc.SpriteFrame + }, + } + }); + ``` + */ + export function property(options?: {type?: any; visible?: boolean|(() => boolean); displayName?: string; tooltip?: string; multiline?: boolean; readonly?: boolean; min?: number; max?: number; step?: number; range?: number[]; slide?: boolean; serializable?: boolean; formerlySerializedAs?: string; editorOnly?: boolean; override?: boolean; animatable?: boolean} | any[]|Function|cc.ValueType|number|string|boolean): Function; + export function property(_target: Object, _key: any, _desc?: any): void; + /** + !#en + Makes a CCClass that inherit from component execute in edit mode.
+ By default, all components are only executed in play mode, + which means they will not have their callback functions executed while the Editor is in edit mode. + !#zh + 允许继承自 Component 的 CCClass 在编辑器里执行。
+ 默认情况下,所有 Component 都只会在运行时才会执行,也就是说它们的生命周期回调不会在编辑器里触发。 + + @example + ```js + const {ccclass, executeInEditMode} = cc._decorator; + + @ccclass + @executeInEditMode + class NewScript extends cc.Component { + // ... + } + ``` + */ + export function executeInEditMode(): Function; + export function executeInEditMode(_class: Function): void; + /** + !#en + Automatically add required component as a dependency for the CCClass that inherit from component. + !#zh + 为声明为 CCClass 的组件添加依赖的其它组件。当组件添加到节点上时,如果依赖的组件不存在,引擎将会自动将依赖组件添加到同一个节点,防止脚本出错。该设置在运行时同样有效。 + @param requiredComponent requiredComponent + + @example + ```js + const {ccclass, requireComponent} = cc._decorator; + + @ccclass + @requireComponent(cc.Sprite) + class SpriteCtrl extends cc.Component { + // ... + } + ``` + */ + export function requireComponent(requiredComponent: typeof cc.Component): Function; + /** + !#en + The menu path to register a component to the editors "Component" menu. Eg. "Rendering/CameraCtrl". + !#zh + 将当前组件添加到组件菜单中,方便用户查找。例如 "Rendering/CameraCtrl"。 + @param path The path is the menu represented like a pathname. + For example the menu could be "Rendering/CameraCtrl". + + @example + ```js + const {ccclass, menu} = cc._decorator; + + @ccclass + @menu("Rendering/CameraCtrl") + class NewScript extends cc.Component { + // ... + } + ``` + */ + export function menu(path: string): Function; + /** + !#en + The execution order of lifecycle methods for Component. + Those less than 0 will execute before while those greater than 0 will execute after. + The order will only affect onLoad, onEnable, start, update and lateUpdate while onDisable and onDestroy will not be affected. + !#zh + 设置脚本生命周期方法调用的优先级。优先级小于 0 的组件将会优先执行,优先级大于 0 的组件将会延后执行。优先级仅会影响 onLoad, onEnable, start, update 和 lateUpdate,而 onDisable 和 onDestroy 不受影响。 + @param order The execution order of lifecycle methods for Component. Those less than 0 will execute before while those greater than 0 will execute after. + + @example + ```js + const {ccclass, executionOrder} = cc._decorator; + + @ccclass + @executionOrder(1) + class CameraCtrl extends cc.Component { + // ... + } + ``` + */ + export function executionOrder(order: number): Function; + /** + !#en + Prevents Component of the same type (or subtype) to be added more than once to a Node. + !#zh + 防止多个相同类型(或子类型)的组件被添加到同一个节点。 + + @example + ```js + const {ccclass, disallowMultiple} = cc._decorator; + + @ccclass + @disallowMultiple + class CameraCtrl extends cc.Component { + // ... + } + ``` + */ + export function disallowMultiple(): Function; + export function disallowMultiple(_class: Function): void; + /** + !#en + If specified, the editor's scene view will keep updating this node in 60 fps when it is selected, otherwise, it will update only if necessary.
+ This property is only available if executeInEditMode is true. + !#zh + 当指定了 "executeInEditMode" 以后,playOnFocus 可以在选中当前组件所在的节点时,提高编辑器的场景刷新频率到 60 FPS,否则场景就只会在必要的时候进行重绘。 + + @example + ```js + const {ccclass, playOnFocus, executeInEditMode} = cc._decorator; + + @ccclass + @executeInEditMode + @playOnFocus + class CameraCtrl extends cc.Component { + // ... + } + ``` + */ + export function playOnFocus(): Function; + export function playOnFocus(_class: Function): void; + /** + !#en + Specifying the url of the custom html to draw the component in **Properties**. + !#zh + 自定义当前组件在 **属性检查器** 中渲染时所用的网页 url。 + @param url url + + @example + ```js + const {ccclass, inspector} = cc._decorator; + + @ccclass + @inspector("packages://inspector/inspectors/comps/camera-ctrl.js") + class NewScript extends cc.Component { + // ... + } + ``` + */ + export function inspector(path: string): Function; + /** + !#en + The custom documentation URL. + !#zh + 指定当前组件的帮助文档的 url,设置过后,在 **属性检查器** 中就会出现一个帮助图标,用户点击将打开指定的网页。 + @param url url + + @example + ```js + const {ccclass, help} = cc._decorator; + + @ccclass + @help("app://docs/html/components/spine.html") + class NewScript extends cc.Component { + // ... + } + ``` + */ + export function help(path: string): Function; + /** + NOTE:
+ The old mixins implemented in cc.Class(ES5) behaves exact the same as multiple inheritance. + But since ES6, class constructor can't be function-called and class methods become non-enumerable, + so we can not mix in ES6 Classes.
+ See:
+ [https://esdiscuss.org/topic/traits-are-now-impossible-in-es6-until-es7-since-rev32](https://esdiscuss.org/topic/traits-are-now-impossible-in-es6-until-es7-since-rev32)
+ One possible solution (but IDE unfriendly):
+ [http://justinfagnani.com/2015/12/21/real-mixins-with-javascript-classes](http://justinfagnani.com/2015/12/21/real-mixins-with-javascript-classes/)
+
+ NOTE:
+ You must manually call mixins constructor, this is different from cc.Class(ES5). + @param ctor constructors to mix, only support ES5 constructors or classes defined by using `cc.Class`, + not support ES6 Classes. + + @example + ```js + const {ccclass, mixins} = cc._decorator; + + class Animal { ... } + + const Fly = cc.Class({ + constructor () { ... } + }); + + @ccclass + @mixins(cc.EventTarget, Fly) + class Bird extends Animal { + constructor () { + super(); + + // You must manually call mixins constructor, this is different from cc.Class(ES5) + cc.EventTarget.call(this); + Fly.call(this); + } + // ... + } + ``` + */ + export function mixins(ctor: Function, ...rest: Function[]): Function; +} + +/** !#en This module provides some JavaScript utilities. All members can be accessed with `cc.js`. +!#zh 这个模块封装了 JavaScript 相关的一些实用函数,你可以通过 `cc.js` 来访问这个模块。 */ +declare namespace cc.js { + /** + Check the obj whether is number or not + If a number is created by using 'new Number(10086)', the typeof it will be "object"... + Then you can use this function if you care about this case. + @param obj obj + */ + export function isNumber(obj: any): boolean; + /** + Check the obj whether is string or not. + If a string is created by using 'new String("blabla")', the typeof it will be "object"... + Then you can use this function if you care about this case. + @param obj obj + */ + export function isString(obj: any): boolean; + /** + Copy all properties not defined in obj from arguments[1...n] + @param obj object to extend its properties + @param sourceObj source object to copy properties from + */ + export function addon(obj: any, ...sourceObj: any[]): any; + /** + copy all properties from arguments[1...n] to obj + @param obj obj + @param sourceObj sourceObj + */ + export function mixin(obj: any, ...sourceObj: any[]): any; + /** + Derive the class from the supplied base class. + Both classes are just native javascript constructors, not created by cc.Class, so + usually you will want to inherit using {{#crossLink "cc/Class:method"}}cc.Class {{/crossLink}} instead. + @param cls cls + @param base the baseclass to inherit + */ + export function extend(cls: Function, base: Function): Function; + /** + Get super class + @param ctor the constructor of subclass + */ + export function getSuper(ctor: Function): Function; + /** + Checks whether subclass is child of superclass or equals to superclass + @param subclass subclass + @param superclass superclass + */ + export function isChildClassOf(subclass: Function, superclass: Function): boolean; + /** + Removes all enumerable properties from object + @param obj obj + */ + export function clear(obj: any): void; + /** + Checks whether obj is an empty object + @param obj obj + */ + export function isEmptyObject(obj: any): boolean; + /** + Get property descriptor in object and all its ancestors + @param obj obj + @param name name + */ + export function getPropertyDescriptor(obj: any, name: string): any; + /** + Define value, just help to call Object.defineProperty.
+ The configurable will be true. + @param obj obj + @param prop prop + @param value value + @param writable writable + @param enumerable enumerable + */ + export function value(obj: any, prop: string, value: any, writable?: boolean, enumerable?: boolean): void; + /** + Define get set accessor, just help to call Object.defineProperty(...) + @param obj obj + @param prop prop + @param getter getter + @param setter setter + @param enumerable enumerable + @param configurable configurable + */ + export function getset(obj: any, prop: string, getter: Function, setter?: Function, enumerable?: boolean, configurable?: boolean): void; + /** + Define get accessor, just help to call Object.defineProperty(...) + @param obj obj + @param prop prop + @param getter getter + @param enumerable enumerable + @param configurable configurable + */ + export function get(obj: any, prop: string, getter: Function, enumerable?: boolean, configurable?: boolean): void; + /** + Define set accessor, just help to call Object.defineProperty(...) + @param obj obj + @param prop prop + @param setter setter + @param enumerable enumerable + @param configurable configurable + */ + export function set(obj: any, prop: string, setter: Function, enumerable?: boolean, configurable?: boolean): void; + /** + Get class name of the object, if object is just a {} (and which class named 'Object'), it will return "". + (modified from the code from this stackoverflow post) + @param objOrCtor instance or constructor + */ + export function getClassName(objOrCtor: any|Function): string; + /** !#en All classes registered in the engine, indexed by ID. + !#zh 引擎中已注册的所有类型,通过 ID 进行索引。 */ + export var _registeredClassIds: any; + /** !#en All classes registered in the engine, indexed by name. + !#zh 引擎中已注册的所有类型,通过名称进行索引。 */ + export var _registeredClassNames: any; + /** + Register the class by specified name manually + @param className className + @param constructor constructor + */ + export function setClassName(className: string, constructor: Function): void; + /** + Unregister a class from fireball. + + If you dont need a registered class anymore, you should unregister the class so that Fireball will not keep its reference anymore. + Please note that its still your responsibility to free other references to the class. + @param constructor the class you will want to unregister, any number of classes can be added + */ + export function unregisterClass(...constructor: Function[]): void; + /** + Get the registered class by name + @param classname classname + */ + export function getClassByName(classname: string): Function; + /** + Defines a polyfill field for deprecated codes. + @param obj YourObject or YourClass.prototype + @param obsoleted "OldParam" or "YourClass.OldParam" + @param newExpr "NewParam" or "YourClass.NewParam" + @param writable writable + */ + export function obsolete(obj: any, obsoleted: string, newExpr: string, writable?: boolean): void; + /** + Defines all polyfill fields for obsoleted codes corresponding to the enumerable properties of props. + @param obj YourObject or YourClass.prototype + @param objName "YourObject" or "YourClass" + @param props props + @param writable writable + */ + export function obsoletes(obj: any, objName: any, props: any, writable?: boolean): void; + /** + A string tool to construct a string with format string. + @param msg A JavaScript string containing zero or more substitution strings (%s). + @param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output. + + @example + ```js + cc.js.formatStr("a: %s, b: %s", a, b); + cc.js.formatStr(a, b, c); + ``` + */ + export function formatStr(msg: string|any, ...subst: any[]): string; + /** + !#en + A simple wrapper of `Object.create(null)` which ensures the return object have no prototype (and thus no inherited members). So we can skip `hasOwnProperty` calls on property lookups. It is a worthwhile optimization than the `{}` literal when `hasOwnProperty` calls are necessary. + !#zh + 该方法是对 `Object.create(null)` 的简单封装。`Object.create(null)` 用于创建无 prototype (也就无继承)的空对象。这样我们在该对象上查找属性时,就不用进行 `hasOwnProperty` 判断。在需要频繁判断 `hasOwnProperty` 时,使用这个方法性能会比 `{}` 更高。 + @param forceDictMode Apply the delete operator to newly created map object. This causes V8 to put the object in "dictionary mode" and disables creation of hidden classes which are very expensive for objects that are constantly changing shape. + */ + export function createMap(forceDictMode?: boolean): any; + /** undefined */ + export class array { + /** + Removes the array item at the specified index. + @param array array + @param index index + */ + static removeAt(array: any[], index: number): void; + /** + Removes the array item at the specified index. + It's faster but the order of the array will be changed. + @param array array + @param index index + */ + static fastRemoveAt(array: any[], index: number): void; + /** + Removes the first occurrence of a specific object from the array. + @param array array + @param value value + */ + static remove(array: any[], value: any): boolean; + /** + Removes the first occurrence of a specific object from the array. + It's faster but the order of the array will be changed. + @param array array + @param value value + */ + static fastRemove(array: any[], value: number): void; + /** + Verify array's Type + @param array array + @param type type + */ + static verifyType(array: any[], type: Function): boolean; + /** + Removes from array all values in minusArr. For each Value in minusArr, the first matching instance in array will be removed. + @param array Source Array + @param minusArr minus Array + */ + static removeArray(array: any[], minusArr: any[]): void; + /** + Inserts some objects at index + @param array array + @param addObjs addObjs + @param index index + */ + static appendObjectsAt(array: any[], addObjs: any[], index: number): any[]; + /** + Determines whether the array contains a specific value. + @param array array + @param value value + */ + static contains(array: any[], value: any): boolean; + /** + Copy an array's item to a new array (its performance is better than Array.slice) + @param array array + */ + static copy(array: any[]): any[]; + } + /** !#en + A fixed-length object pool designed for general type.
+ The implementation of this object pool is very simple, + it can helps you to improve your game performance for objects which need frequent release and recreate operations
+ !#zh + 长度固定的对象缓存池,可以用来缓存各种对象类型。
+ 这个对象池的实现非常精简,它可以帮助您提高游戏性能,适用于优化对象的反复创建和销毁。 */ + export class Pool { + /** + !#en + Constructor for creating an object pool for the specific object type. + You can pass a callback argument for process the cleanup logic when the object is recycled. + !#zh + 使用构造函数来创建一个指定对象类型的对象池,您可以传递一个回调函数,用于处理对象回收时的清理逻辑。 + @param cleanupFunc the callback method used to process the cleanup logic when the object is recycled. + @param size initializes the length of the array + */ + constructor(cleanupFunc: (obj: any) => void, size: number); + constructor(size: number); + /** + !#en + Get and initialize an object from pool. This method defaults to null and requires the user to implement it. + !#zh + 获取并初始化对象池中的对象。这个方法默认为空,需要用户自己实现。 + @param params parameters to used to initialize the object + */ + get(...params: any[]): any; + /** !#en + The current number of available objects, the default is 0, it will gradually increase with the recycle of the object, + the maximum will not exceed the size specified when the constructor is called. + !#zh + 当前可用对象数量,一开始默认是 0,随着对象的回收会逐渐增大,最大不会超过调用构造函数时指定的 size。 */ + count: number; + /** + !#en + Get an object from pool, if no available object in the pool, null will be returned. + !#zh + 获取对象池中的对象,如果对象池没有可用对象,则返回空。 + */ + _get(): any; + /** + !#en Put an object into the pool. + !#zh 向对象池返还一个不再需要的对象。 + */ + put(): void; + /** + !#en Resize the pool. + !#zh 设置对象池容量。 + */ + resize(): void; + } +} + +/** !#en A basic module for creating vertex data for 3D objects. You can access this module by `cc.primitive`. +!#zh 一个创建 3D 物体顶点数据的基础模块,你可以通过 `cc.primitive` 来访问这个模块。 */ +declare namespace cc.primitive { + /** + !#en Create box vertex data + !#zh 创建长方体顶点数据 + @param width width + @param height height + @param length length + @param opts opts + */ + export function box(width: number, height: number, length: number, opts: {widthSegments: number; heightSegments: number; lengthSegments: number; }): cc.VertexData; + /** + !#en Create cone vertex data + !#zh 创建圆锥体顶点数据 + @param radius radius + @param height height + @param opts opts + */ + export function cone(radius: number, height: number, opts: {radialSegments: number; heightSegments: number; capped: boolean; arc: number; }): cc.VertexData; + /** + !#en Create cylinder vertex data + !#zh 创建圆柱体顶点数据 + @param radiusTop radiusTop + @param radiusBottom radiusBottom + @param height height + @param opts opts + */ + export function cylinder(radiusTop: number, radiusBottom: number, height: number, opts: {radialSegments: number; heightSegments: number; capped: boolean; arc: number; }): cc.VertexData; + /** + !#en Create plane vertex data + !#zh 创建平台顶点数据 + @param width width + @param length length + @param opts opts + */ + export function plane(width: number, length: number, opts: {widthSegments: number; lengthSegments: number; }): cc.VertexData; + /** + !#en Create quad vertex data + !#zh 创建面片顶点数据 + */ + export function quad(): cc.VertexData; + /** + !#en Create sphere vertex data + !#zh 创建球体顶点数据 + @param radius radius + @param opts opts + */ + export function sphere(radius: number, opts: {segments: number; }): cc.VertexData; + /** + !#en Create torus vertex data + !#zh 创建圆环顶点数据 + @param radius radius + @param tube tube + @param opts opts + */ + export function torus(radius: number, tube: number, opts: {radialSegments: number; tubularSegments: number; arc: number; }): cc.VertexData; + /** + !#en Create capsule vertex data + !#zh 创建胶囊体顶点数据 + @param radiusTop radiusTop + @param radiusBottom radiusBottom + @param height height + @param opts opts + */ + export function capsule(radiusTop: number, radiusBottom: number, height: number, opts: {sides: number; heightSegments: number; capped: boolean; arc: number; }): cc.VertexData; + /** + !#en Create polyhedron vertex data + !#zh 创建多面体顶点数据 + @param type type + @param Size Size + @param opts opts + */ + export function polyhedron(type: cc.primitive.PolyhedronType, Size: number, opts: {sizeX: number; sizeY: number; sizeZ: number; }): cc.VertexData; +} + +declare let CC_JSB: boolean +declare let CC_NATIVERENDERER: boolean +declare let CC_EDITOR: boolean +declare let CC_PREVIEW: boolean +declare let CC_TEST: boolean +declare let CC_DEBUG: boolean + +declare let cc: { + // polyfills: { + // destroyObject? (object: any): void; + // }; + [x: string]: any; +} + +declare let Editor: any; + +// https://medium.com/dailyjs/typescript-create-a-condition-based-subset-types-9d902cea5b8c +type FlagExcludedType = { [Key in keyof Base]: Base[Key] extends Type ? never : Key }; +type AllowedNames = FlagExcludedType[keyof Base]; +type KeyPartial = { [P in K]?: T[P] }; +type OmitType = KeyPartial>; +type ConstructorType = OmitType; + +declare interface IWritableArrayLike { + readonly length: number; + [index: number]: T; +} + +declare let module: { + exports: object +} + + +declare interface Math { + sign(v: number); +} + +declare interface Object { + assign(target: {}, source: {}); +} + + +type FloatArray = Float64Array | Float32Array; + +interface IColorLike { + r: number; + g: number; + b: number; + a: number; + _val: number; + +} + +interface IMat3Like { + m: FloatArray +} + +interface IMat4Like { + m: FloatArray +} + +interface IQuatLike { + x: number; + y: number; + z: number; + w: number; +} + +interface IRectLike { + x: number; + y: number; + width: number; + height: number; +} + +interface ISizeLike { + width: number; + height: number; +} + +interface IVec2Like { + x: number; + y: number; +} + +interface IVec3Like { + x: number; + y: number; + z: number; +} + +interface IVec4Like { + x: number; + y: number; + z: number; + w: number; +} +declare namespace dragonBones { + /** + * @internal + * @private + */ + const webAssemblyModule: { + HEAP16: Int16Array; + _malloc(byteSize: number): number; + _free(pointer: number): void; + setDataBinary(data: DragonBonesData, binaryPointer: number, intBytesLength: number, floatBytesLength: number, frameIntBytesLength: number, frameFloatBytesLength: number, frameBytesLength: number, timelineBytesLength: number): void; + }; +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + const enum BinaryOffset { + WeigthBoneCount = 0, + WeigthFloatOffset = 1, + WeigthBoneIndices = 2, + MeshVertexCount = 0, + MeshTriangleCount = 1, + MeshFloatOffset = 2, + MeshWeightOffset = 3, + MeshVertexIndices = 4, + TimelineScale = 0, + TimelineOffset = 1, + TimelineKeyFrameCount = 2, + TimelineFrameValueCount = 3, + TimelineFrameValueOffset = 4, + TimelineFrameOffset = 5, + FramePosition = 0, + FrameTweenType = 1, + FrameTweenEasingOrCurveSampleCount = 2, + FrameCurveSamples = 3, + DeformMeshOffset = 0, + DeformCount = 1, + DeformValueCount = 2, + DeformValueOffset = 3, + DeformFloatOffset = 4, + } + /** + * @internal + * @private + */ + const enum ArmatureType { + Armature = 0, + MovieClip = 1, + Stage = 2, + } + /** + * @internal + * @private + */ + const enum BoneType { + Bone = 0, + Surface = 1, + } + /** + * @private + */ + const enum DisplayType { + Image = 0, + Armature = 1, + Mesh = 2, + BoundingBox = 3, + } + /** + * - Bounding box type. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 边界框类型。 + * @version DragonBones 5.0 + * @language zh_CN + */ + const enum BoundingBoxType { + Rectangle = 0, + Ellipse = 1, + Polygon = 2, + } + /** + * @internal + * @private + */ + const enum ActionType { + Play = 0, + Frame = 10, + Sound = 11, + } + /** + * @internal + * @private + */ + const enum BlendMode { + Normal = 0, + Add = 1, + Alpha = 2, + Darken = 3, + Difference = 4, + Erase = 5, + HardLight = 6, + Invert = 7, + Layer = 8, + Lighten = 9, + Multiply = 10, + Overlay = 11, + Screen = 12, + Subtract = 13, + } + /** + * @internal + * @private + */ + const enum TweenType { + None = 0, + Line = 1, + Curve = 2, + QuadIn = 3, + QuadOut = 4, + QuadInOut = 5, + } + /** + * @internal + * @private + */ + const enum TimelineType { + Action = 0, + ZOrder = 1, + BoneAll = 10, + BoneTranslate = 11, + BoneRotate = 12, + BoneScale = 13, + Surface = 50, + SlotDisplay = 20, + SlotColor = 21, + SlotFFD = 22, + IKConstraint = 30, + AnimationTime = 40, + AnimationWeight = 41, + } + /** + * - Offset mode. + * @version DragonBones 5.5 + * @language en_US + */ + /** + * - 偏移模式。 + * @version DragonBones 5.5 + * @language zh_CN + */ + const enum OffsetMode { + None = 0, + Additive = 1, + Override = 2, + } + /** + * - Animation fade out mode. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画淡出模式。 + * @version DragonBones 4.5 + * @language zh_CN + */ + const enum AnimationFadeOutMode { + /** + * - Do not fade out of any animation states. + * @language en_US + */ + /** + * - 不淡出任何的动画状态。 + * @language zh_CN + */ + None = 0, + /** + * - Fade out the animation states of the same layer. + * @language en_US + */ + /** + * - 淡出同层的动画状态。 + * @language zh_CN + */ + SameLayer = 1, + /** + * - Fade out the animation states of the same group. + * @language en_US + */ + /** + * - 淡出同组的动画状态。 + * @language zh_CN + */ + SameGroup = 2, + /** + * - Fade out the animation states of the same layer and group. + * @language en_US + */ + /** + * - 淡出同层并且同组的动画状态。 + * @language zh_CN + */ + SameLayerAndGroup = 3, + /** + * - Fade out of all animation states. + * @language en_US + */ + /** + * - 淡出所有的动画状态。 + * @language zh_CN + */ + All = 4, + /** + * - Does not replace the animation state with the same name. + * @language en_US + */ + /** + * - 不替换同名的动画状态。 + * @language zh_CN + */ + Single = 5, + } + /** + * @private + */ + interface Map { + [key: string]: T; + } + /** + * @private + */ + class DragonBones { + static readonly VERSION: string; + static yDown: boolean; + static debug: boolean; + static debugDraw: boolean; + static webAssembly: boolean; + private readonly _clock; + private readonly _events; + private readonly _objects; + private _eventManager; + constructor(eventManager: IEventDispatcher); + advanceTime(passedTime: number): void; + bufferEvent(value: EventObject): void; + bufferObject(object: BaseObject): void; + readonly clock: WorldClock; + readonly eventManager: IEventDispatcher; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The BaseObject is the base class for all objects in the DragonBones framework. + * All BaseObject instances are cached to the object pool to reduce the performance consumption of frequent requests for memory or memory recovery. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 基础对象,通常 DragonBones 的对象都继承自该类。 + * 所有基础对象的实例都会缓存到对象池,以减少频繁申请内存或内存回收的性能消耗。 + * @version DragonBones 4.5 + * @language zh_CN + */ + abstract class BaseObject { + private static _hashCode; + private static _defaultMaxCount; + private static readonly _maxCountMap; + private static readonly _poolsMap; + private static _returnObject(object); + static toString(): string; + /** + * - Set the maximum cache count of the specify object pool. + * @param objectConstructor - The specify class. (Set all object pools max cache count if not set) + * @param maxCount - Max count. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 设置特定对象池的最大缓存数量。 + * @param objectConstructor - 特定的类。 (不设置则设置所有对象池的最大缓存数量) + * @param maxCount - 最大缓存数量。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static setMaxCount(objectConstructor: (typeof BaseObject) | null, maxCount: number): void; + /** + * - Clear the cached instances of a specify object pool. + * @param objectConstructor - Specify class. (Clear all cached instances if not set) + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 清除特定对象池的缓存实例。 + * @param objectConstructor - 特定的类。 (不设置则清除所有缓存的实例) + * @version DragonBones 4.5 + * @language zh_CN + */ + static clearPool(objectConstructor?: (typeof BaseObject) | null): void; + /** + * - Get an instance of the specify class from object pool. + * @param objectConstructor - The specify class. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 从对象池中获取特定类的实例。 + * @param objectConstructor - 特定的类。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static borrowObject(objectConstructor: { + new (): T; + }): T; + /** + * - A unique identification number assigned to the object. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 分配给此实例的唯一标识号。 + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly hashCode: number; + private _isInPool; + /** + * @private + */ + protected abstract _onClear(): void; + /** + * - Clear the object and return it back to object pool。 + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 清除该实例的所有数据并将其返还对象池。 + * @version DragonBones 4.5 + * @language zh_CN + */ + returnToPool(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - 2D Transform matrix. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 2D 转换矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class Matrix { + /** + * - The value that affects the positioning of pixels along the x axis when scaling or rotating an image. + * @default 1.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 缩放或旋转图像时影响像素沿 x 轴定位的值。 + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + a: number; + /** + * - The value that affects the positioning of pixels along the y axis when rotating or skewing an image. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 旋转或倾斜图像时影响像素沿 y 轴定位的值。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + b: number; + /** + * - The value that affects the positioning of pixels along the x axis when rotating or skewing an image. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 旋转或倾斜图像时影响像素沿 x 轴定位的值。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + c: number; + /** + * - The value that affects the positioning of pixels along the y axis when scaling or rotating an image. + * @default 1.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 缩放或旋转图像时影响像素沿 y 轴定位的值。 + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + d: number; + /** + * - The distance by which to translate each point along the x axis. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 沿 x 轴平移每个点的距离。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + tx: number; + /** + * - The distance by which to translate each point along the y axis. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 沿 y 轴平移每个点的距离。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + ty: number; + /** + * @private + */ + constructor(a?: number, b?: number, c?: number, d?: number, tx?: number, ty?: number); + toString(): string; + /** + * @private + */ + copyFrom(value: Matrix): Matrix; + /** + * @private + */ + copyFromArray(value: Array, offset?: number): Matrix; + /** + * - Convert to unit matrix. + * The resulting matrix has the following properties: a=1, b=0, c=0, d=1, tx=0, ty=0. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 转换为单位矩阵。 + * 该矩阵具有以下属性:a=1、b=0、c=0、d=1、tx=0、ty=0。 + * @version DragonBones 3.0 + * @language zh_CN + */ + identity(): Matrix; + /** + * - Multiplies the current matrix with another matrix. + * @param value - The matrix that needs to be multiplied. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 将当前矩阵与另一个矩阵相乘。 + * @param value - 需要相乘的矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + concat(value: Matrix): Matrix; + /** + * - Convert to inverse matrix. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 转换为逆矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + invert(): Matrix; + /** + * - Apply a matrix transformation to a specific point. + * @param x - X coordinate. + * @param y - Y coordinate. + * @param result - The point after the transformation is applied. + * @param delta - Whether to ignore tx, ty's conversion to point. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 将矩阵转换应用于特定点。 + * @param x - 横坐标。 + * @param y - 纵坐标。 + * @param result - 应用转换之后的点。 + * @param delta - 是否忽略 tx,ty 对点的转换。 + * @version DragonBones 3.0 + * @language zh_CN + */ + transformPoint(x: number, y: number, result: { + x: number; + y: number; + }, delta?: boolean): void; + /** + * @private + */ + transformRectangle(rectangle: { + x: number; + y: number; + width: number; + height: number; + }, delta?: boolean): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - 2D Transform. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 2D 变换。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class Transform { + /** + * @private + */ + static readonly PI: number; + /** + * @private + */ + static readonly PI_D: number; + /** + * @private + */ + static readonly PI_H: number; + /** + * @private + */ + static readonly PI_Q: number; + /** + * @private + */ + static readonly RAD_DEG: number; + /** + * @private + */ + static readonly DEG_RAD: number; + /** + * @private + */ + static normalizeRadian(value: number): number; + /** + * - Horizontal translate. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 水平位移。 + * @version DragonBones 3.0 + * @language zh_CN + */ + x: number; + /** + * - Vertical translate. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 垂直位移。 + * @version DragonBones 3.0 + * @language zh_CN + */ + y: number; + /** + * - Skew. (In radians) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 倾斜。 (以弧度为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + skew: number; + /** + * - rotation. (In radians) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 旋转。 (以弧度为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + rotation: number; + /** + * - Horizontal Scaling. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 水平缩放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + scaleX: number; + /** + * - Vertical scaling. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 垂直缩放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + scaleY: number; + /** + * @private + */ + constructor(x?: number, y?: number, skew?: number, rotation?: number, scaleX?: number, scaleY?: number); + toString(): string; + /** + * @private + */ + copyFrom(value: Transform): Transform; + /** + * @private + */ + identity(): Transform; + /** + * @private + */ + add(value: Transform): Transform; + /** + * @private + */ + minus(value: Transform): Transform; + /** + * @private + */ + fromMatrix(matrix: Matrix): Transform; + /** + * @private + */ + toMatrix(matrix: Matrix): Transform; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + class ColorTransform { + alphaMultiplier: number; + redMultiplier: number; + greenMultiplier: number; + blueMultiplier: number; + alphaOffset: number; + redOffset: number; + greenOffset: number; + blueOffset: number; + constructor(alphaMultiplier?: number, redMultiplier?: number, greenMultiplier?: number, blueMultiplier?: number, alphaOffset?: number, redOffset?: number, greenOffset?: number, blueOffset?: number); + copyFrom(value: ColorTransform): void; + identity(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The Point object represents a location in a two-dimensional coordinate system. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - Point 对象表示二维坐标系统中的某个位置。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class Point { + /** + * - The horizontal coordinate. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 该点的水平坐标。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + x: number; + /** + * - The vertical coordinate. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 该点的垂直坐标。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + y: number; + /** + * - Creates a new point. If you pass no parameters to this method, a point is created at (0,0). + * @param x - The horizontal coordinate. + * @param y - The vertical coordinate. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 创建一个 egret.Point 对象.若不传入任何参数,将会创建一个位于(0,0)位置的点。 + * @param x - 该对象的x属性值,默认为 0.0。 + * @param y - 该对象的y属性值,默认为 0.0。 + * @version DragonBones 3.0 + * @language zh_CN + */ + constructor(x?: number, y?: number); + /** + * @private + */ + copyFrom(value: Point): void; + /** + * @private + */ + clear(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - A Rectangle object is an area defined by its position, as indicated by its top-left corner point (x, y) and by its + * width and its height.
+ * The x, y, width, and height properties of the Rectangle class are independent of each other; changing the value of + * one property has no effect on the others. However, the right and bottom properties are integrally related to those + * four properties. For example, if you change the value of the right property, the value of the width property changes; + * if you change the bottom property, the value of the height property changes. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - Rectangle 对象是按其位置(由它左上角的点 (x, y) 确定)以及宽度和高度定义的区域。
+ * Rectangle 类的 x、y、width 和 height 属性相互独立;更改一个属性的值不会影响其他属性。 + * 但是,right 和 bottom 属性与这四个属性是整体相关的。例如,如果更改 right 属性的值,则 width + * 属性的值将发生变化;如果更改 bottom 属性,则 height 属性的值将发生变化。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class Rectangle { + /** + * - The x coordinate of the top-left corner of the rectangle. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 矩形左上角的 x 坐标。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + x: number; + /** + * - The y coordinate of the top-left corner of the rectangle. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 矩形左上角的 y 坐标。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + y: number; + /** + * - The width of the rectangle, in pixels. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 矩形的宽度(以像素为单位)。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + width: number; + /** + * - 矩形的高度(以像素为单位)。 + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - The height of the rectangle, in pixels. + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + height: number; + /** + * @private + */ + constructor(x?: number, y?: number, width?: number, height?: number); + /** + * @private + */ + copyFrom(value: Rectangle): void; + /** + * @private + */ + clear(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The user custom data. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 用户自定义数据。 + * @version DragonBones 5.0 + * @language zh_CN + */ + class UserData extends BaseObject { + static toString(): string; + /** + * - The custom int numbers. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 自定义整数。 + * @version DragonBones 5.0 + * @language zh_CN + */ + readonly ints: Array; + /** + * - The custom float numbers. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 自定义浮点数。 + * @version DragonBones 5.0 + * @language zh_CN + */ + readonly floats: Array; + /** + * - The custom strings. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 自定义字符串。 + * @version DragonBones 5.0 + * @language zh_CN + */ + readonly strings: Array; + /** + * @inheritDoc + */ + protected _onClear(): void; + /** + * @internal + * @private + */ + addInt(value: number): void; + /** + * @internal + * @private + */ + addFloat(value: number): void; + /** + * @internal + * @private + */ + addString(value: string): void; + /** + * - Get the custom int number. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 获取自定义整数。 + * @version DragonBones 5.0 + * @language zh_CN + */ + getInt(index?: number): number; + /** + * - Get the custom float number. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 获取自定义浮点数。 + * @version DragonBones 5.0 + * @language zh_CN + */ + getFloat(index?: number): number; + /** + * - Get the custom string. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 获取自定义字符串。 + * @version DragonBones 5.0 + * @language zh_CN + */ + getString(index?: number): string; + } + /** + * @internal + * @private + */ + class ActionData extends BaseObject { + static toString(): string; + type: ActionType; + name: string; + bone: BoneData | null; + slot: SlotData | null; + data: UserData | null; + protected _onClear(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The DragonBones data. + * A DragonBones data contains multiple armature data. + * @see dragonBones.ArmatureData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 龙骨数据。 + * 一个龙骨数据包含多个骨架数据。 + * @see dragonBones.ArmatureData + * @version DragonBones 3.0 + * @language zh_CN + */ + class DragonBonesData extends BaseObject { + static toString(): string; + /** + * @private + */ + autoSearch: boolean; + /** + * - The animation frame rate. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画帧频。 + * @version DragonBones 3.0 + * @language zh_CN + */ + frameRate: number; + /** + * - The data version. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 数据版本。 + * @version DragonBones 3.0 + * @language zh_CN + */ + version: string; + /** + * - The DragonBones data name. + * The name is consistent with the DragonBones project name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 龙骨数据名称。 + * 该名称与龙骨项目名保持一致。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + stage: ArmatureData | null; + /** + * @internal + * @private + */ + readonly frameIndices: Array; + /** + * @internal + * @private + */ + readonly cachedFrames: Array; + /** + * - All armature data names. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 所有的骨架数据名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly armatureNames: Array; + /** + * @private + */ + readonly armatures: Map; + /** + * @internal + * @private + */ + binary: ArrayBuffer; + /** + * @internal + * @private + */ + intArray: Int16Array; + /** + * @internal + * @private + */ + floatArray: Float32Array; + /** + * @internal + * @private + */ + frameIntArray: Int16Array; + /** + * @internal + * @private + */ + frameFloatArray: Float32Array; + /** + * @internal + * @private + */ + frameArray: Int16Array; + /** + * @internal + * @private + */ + timelineArray: Uint16Array; + /** + * @private + */ + userData: UserData | null; + /** + * @inheritDoc + */ + protected _onClear(): void; + /** + * @internal + * @private + */ + addArmature(value: ArmatureData): void; + /** + * - Get a specific armature data. + * @param name - The armature data name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的骨架数据。 + * @param name - 骨架数据名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + getArmature(name: string): ArmatureData | null; + /** + * - Deprecated, please refer to {@link #dragonBones.BaseFactory#removeDragonBonesData()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #dragonBones.BaseFactory#removeDragonBonesData()}。 + * @deprecated + * @language zh_CN + */ + dispose(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The armature data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨架数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class ArmatureData extends BaseObject { + static toString(): string; + /** + * @private + */ + type: ArmatureType; + /** + * - The animation frame rate. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画帧率。 + * @version DragonBones 3.0 + * @language zh_CN + */ + frameRate: number; + /** + * @private + */ + cacheFrameRate: number; + /** + * @private + */ + scale: number; + /** + * - The armature name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨架名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + readonly aabb: Rectangle; + /** + * - The names of all the animation data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 所有的动画数据名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly animationNames: Array; + /** + * @private + */ + readonly sortedBones: Array; + /** + * @private + */ + readonly sortedSlots: Array; + /** + * @private + */ + readonly defaultActions: Array; + /** + * @private + */ + readonly actions: Array; + /** + * @private + */ + readonly bones: Map; + /** + * @private + */ + readonly slots: Map; + /** + * @private + */ + readonly constraints: Map; + /** + * @private + */ + readonly skins: Map; + /** + * @private + */ + readonly animations: Map; + /** + * - The default skin data. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 默认插槽数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + defaultSkin: SkinData | null; + /** + * - The default animation data. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 默认动画数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + defaultAnimation: AnimationData | null; + /** + * @private + */ + canvas: CanvasData | null; + /** + * @private + */ + userData: UserData | null; + /** + * @private + */ + parent: DragonBonesData; + /** + * @inheritDoc + */ + protected _onClear(): void; + /** + * @internal + * @private + */ + sortBones(): void; + /** + * @internal + * @private + */ + cacheFrames(frameRate: number): void; + /** + * @internal + * @private + */ + setCacheFrame(globalTransformMatrix: Matrix, transform: Transform): number; + /** + * @internal + * @private + */ + getCacheFrame(globalTransformMatrix: Matrix, transform: Transform, arrayOffset: number): void; + /** + * @internal + * @private + */ + addBone(value: BoneData): void; + /** + * @internal + * @private + */ + addSlot(value: SlotData): void; + /** + * @internal + * @private + */ + addConstraint(value: ConstraintData): void; + /** + * @internal + * @private + */ + addSkin(value: SkinData): void; + /** + * @internal + * @private + */ + addAnimation(value: AnimationData): void; + /** + * @internal + * @private + */ + addAction(value: ActionData, isDefault: boolean): void; + /** + * - Get a specific done data. + * @param name - The bone name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的骨骼数据。 + * @param name - 骨骼名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + getBone(name: string): BoneData | null; + /** + * - Get a specific slot data. + * @param name - The slot name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的插槽数据。 + * @param name - 插槽名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + getSlot(name: string): SlotData | null; + /** + * @private + */ + getConstraint(name: string): ConstraintData | null; + /** + * - Get a specific skin data. + * @param name - The skin name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定皮肤数据。 + * @param name - 皮肤名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + getSkin(name: string): SkinData | null; + /** + * @internal + * @private + */ + getMesh(skinName: string, slotName: string, meshName: string): MeshDisplayData | null; + /** + * - Get a specific animation data. + * @param name - The animation name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的动画数据。 + * @param name - 动画名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + getAnimation(name: string): AnimationData | null; + } + /** + * - The bone data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨骼数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class BoneData extends BaseObject { + static toString(): string; + /** + * @private + */ + inheritTranslation: boolean; + /** + * @private + */ + inheritRotation: boolean; + /** + * @private + */ + inheritScale: boolean; + /** + * @private + */ + inheritReflection: boolean; + /** + * @private + */ + type: BoneType; + /** + * - The bone length. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨骼长度。 + * @version DragonBones 3.0 + * @language zh_CN + */ + length: number; + /** + * - The bone name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨骼名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + readonly transform: Transform; + /** + * @private + */ + userData: UserData | null; + /** + * - The parent bone data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 父骨骼数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + parent: BoneData | null; + /** + * @inheritDoc + */ + protected _onClear(): void; + } + /** + * @internal + * @private + */ + class SurfaceData extends BoneData { + static toString(): string; + segmentX: number; + segmentY: number; + readonly vertices: Array; + /** + * @inheritDoc + */ + protected _onClear(): void; + } + /** + * - The slot data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 插槽数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class SlotData extends BaseObject { + /** + * @internal + * @private + */ + static readonly DEFAULT_COLOR: ColorTransform; + /** + * @internal + * @private + */ + static createColor(): ColorTransform; + static toString(): string; + /** + * @private + */ + blendMode: BlendMode; + /** + * @private + */ + displayIndex: number; + /** + * @private + */ + zOrder: number; + /** + * - The slot name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 插槽名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + color: ColorTransform; + /** + * @private + */ + userData: UserData | null; + /** + * - The parent bone data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 父骨骼数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + parent: BoneData; + /** + * @inheritDoc + */ + protected _onClear(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + abstract class ConstraintData extends BaseObject { + order: number; + name: string; + target: BoneData; + root: BoneData; + bone: BoneData | null; + protected _onClear(): void; + } + /** + * @internal + * @private + */ + class IKConstraintData extends ConstraintData { + static toString(): string; + scaleEnabled: boolean; + bendPositive: boolean; + weight: number; + protected _onClear(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + class CanvasData extends BaseObject { + static toString(): string; + hasBackground: boolean; + color: number; + x: number; + y: number; + width: number; + height: number; + protected _onClear(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The skin data, typically a armature data instance contains at least one skinData. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 皮肤数据,通常一个骨架数据至少包含一个皮肤数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class SkinData extends BaseObject { + static toString(): string; + /** + * - The skin name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 皮肤名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + readonly displays: Map>; + /** + * @private + */ + parent: ArmatureData; + /** + * @inheritDoc + */ + protected _onClear(): void; + /** + * @internal + * @private + */ + addDisplay(slotName: string, value: DisplayData | null): void; + /** + * @private + */ + getDisplay(slotName: string, displayName: string): DisplayData | null; + /** + * @private + */ + getDisplays(slotName: string): Array | null; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + abstract class DisplayData extends BaseObject { + type: DisplayType; + name: string; + path: string; + parent: SkinData; + readonly transform: Transform; + protected _onClear(): void; + } + /** + * @internal + * @private + */ + class ImageDisplayData extends DisplayData { + static toString(): string; + readonly pivot: Point; + texture: TextureData | null; + protected _onClear(): void; + } + /** + * @internal + * @private + */ + class ArmatureDisplayData extends DisplayData { + static toString(): string; + inheritAnimation: boolean; + readonly actions: Array; + armature: ArmatureData | null; + protected _onClear(): void; + /** + * @private + */ + addAction(value: ActionData): void; + } + /** + * @internal + * @private + */ + class MeshDisplayData extends DisplayData { + static toString(): string; + inheritDeform: boolean; + offset: number; + weight: WeightData | null; + glue: GlueData | null; + texture: TextureData | null; + protected _onClear(): void; + } + /** + * @internal + * @private + */ + class BoundingBoxDisplayData extends DisplayData { + static toString(): string; + boundingBox: BoundingBoxData | null; + protected _onClear(): void; + } + /** + * @internal + * @private + */ + class WeightData extends BaseObject { + static toString(): string; + count: number; + offset: number; + readonly bones: Array; + protected _onClear(): void; + addBone(value: BoneData): void; + } + /** + * @internal + * @private + */ + class GlueData extends BaseObject { + static toString(): string; + readonly weights: Array; + readonly meshes: Array; + protected _onClear(): void; + addMesh(value: MeshDisplayData | null): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The base class of bounding box data. + * @see dragonBones.RectangleData + * @see dragonBones.EllipseData + * @see dragonBones.PolygonData + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 边界框数据基类。 + * @see dragonBones.RectangleData + * @see dragonBones.EllipseData + * @see dragonBones.PolygonData + * @version DragonBones 5.0 + * @language zh_CN + */ + abstract class BoundingBoxData extends BaseObject { + /** + * - The bounding box type. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 边界框类型。 + * @version DragonBones 5.0 + * @language zh_CN + */ + type: BoundingBoxType; + /** + * @private + */ + color: number; + /** + * @private + */ + width: number; + /** + * @private + */ + height: number; + /** + * @private + */ + protected _onClear(): void; + /** + * - Check whether the bounding box contains a specific point. (Local coordinate system) + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 检查边界框是否包含特定点。(本地坐标系) + * @version DragonBones 5.0 + * @language zh_CN + */ + abstract containsPoint(pX: number, pY: number): boolean; + /** + * - Check whether the bounding box intersects a specific segment. (Local coordinate system) + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 检查边界框是否与特定线段相交。(本地坐标系) + * @version DragonBones 5.0 + * @language zh_CN + */ + abstract intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA: { + x: number; + y: number; + } | null, intersectionPointB: { + x: number; + y: number; + } | null, normalRadians: { + x: number; + y: number; + } | null): number; + } + /** + * - The rectangle bounding box data. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 矩形边界框数据。 + * @version DragonBones 5.1 + * @language zh_CN + */ + class RectangleBoundingBoxData extends BoundingBoxData { + static toString(): string; + /** + * - Compute the bit code for a point (x, y) using the clip rectangle + */ + private static _computeOutCode(x, y, xMin, yMin, xMax, yMax); + /** + * @private + */ + static rectangleIntersectsSegment(xA: number, yA: number, xB: number, yB: number, xMin: number, yMin: number, xMax: number, yMax: number, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): number; + /** + * @inheritDoc + * @private + */ + protected _onClear(): void; + /** + * @inheritDoc + */ + containsPoint(pX: number, pY: number): boolean; + /** + * @inheritDoc + */ + intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): number; + } + /** + * - The ellipse bounding box data. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 椭圆边界框数据。 + * @version DragonBones 5.1 + * @language zh_CN + */ + class EllipseBoundingBoxData extends BoundingBoxData { + static toString(): string; + /** + * @private + */ + static ellipseIntersectsSegment(xA: number, yA: number, xB: number, yB: number, xC: number, yC: number, widthH: number, heightH: number, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): number; + /** + * @inheritDoc + * @private + */ + protected _onClear(): void; + /** + * @inheritDoc + */ + containsPoint(pX: number, pY: number): boolean; + /** + * @inheritDoc + */ + intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): number; + } + /** + * - The polygon bounding box data. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 多边形边界框数据。 + * @version DragonBones 5.1 + * @language zh_CN + */ + class PolygonBoundingBoxData extends BoundingBoxData { + static toString(): string; + /** + * @private + */ + static polygonIntersectsSegment(xA: number, yA: number, xB: number, yB: number, vertices: Array, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): number; + /** + * @private + */ + x: number; + /** + * @private + */ + y: number; + /** + * - The polygon vertices. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 多边形顶点。 + * @version DragonBones 5.1 + * @language zh_CN + */ + readonly vertices: Array; + /** + * @private + */ + weight: WeightData | null; + /** + * @inheritDoc + * @private + */ + protected _onClear(): void; + /** + * @inheritDoc + */ + containsPoint(pX: number, pY: number): boolean; + /** + * @inheritDoc + */ + intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): number; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The animation data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class AnimationData extends BaseObject { + static toString(): string; + /** + * - FrameIntArray. + * @internal + * @private + */ + frameIntOffset: number; + /** + * - FrameFloatArray. + * @internal + * @private + */ + frameFloatOffset: number; + /** + * - FrameArray. + * @internal + * @private + */ + frameOffset: number; + /** + * - The frame count of the animation. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画的帧数。 + * @version DragonBones 3.0 + * @language zh_CN + */ + frameCount: number; + /** + * - The play times of the animation. [0: Loop play, [1~N]: Play N times] + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画的播放次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次] + * @version DragonBones 3.0 + * @language zh_CN + */ + playTimes: number; + /** + * - The duration of the animation. (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画的持续时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + duration: number; + /** + * @private + */ + scale: number; + /** + * - The fade in time of the animation. (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画的淡入时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + fadeInTime: number; + /** + * @private + */ + cacheFrameRate: number; + /** + * - The animation name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + readonly cachedFrames: Array; + /** + * @private + */ + readonly boneTimelines: Map>; + /** + * @private + */ + readonly surfaceTimelines: Map>; + /** + * @private + */ + readonly slotTimelines: Map>; + /** + * @private + */ + readonly constraintTimelines: Map>; + /** + * @private + */ + readonly animationTimelines: Map>; + /** + * @private + */ + readonly boneCachedFrameIndices: Map>; + /** + * @private + */ + readonly slotCachedFrameIndices: Map>; + /** + * @private + */ + actionTimeline: TimelineData | null; + /** + * @private + */ + zOrderTimeline: TimelineData | null; + /** + * @private + */ + parent: ArmatureData; + /** + * @inheritDoc + */ + protected _onClear(): void; + /** + * @internal + * @private + */ + cacheFrames(frameRate: number): void; + /** + * @private + */ + addBoneTimeline(bone: BoneData, timeline: TimelineData): void; + /** + * @private + */ + addSurfaceTimeline(surface: SurfaceData, timeline: TimelineData): void; + /** + * @private + */ + addSlotTimeline(slot: SlotData, timeline: TimelineData): void; + /** + * @private + */ + addConstraintTimeline(constraint: ConstraintData, timeline: TimelineData): void; + /** + * @private + */ + addAnimationTimeline(name: string, timeline: TimelineData): void; + /** + * @private + */ + getBoneTimelines(name: string): Array | null; + /** + * @private + */ + getSurfaceTimelines(name: string): Array | null; + /** + * @private + */ + getSlotTimelines(name: string): Array | null; + /** + * @private + */ + getConstraintTimelines(name: string): Array | null; + /** + * @private + */ + getAnimationTimelines(name: string): Array | null; + /** + * @private + */ + getBoneCachedFrameIndices(name: string): Array | null; + /** + * @private + */ + getSlotCachedFrameIndices(name: string): Array | null; + } + /** + * @internal + * @private + */ + class TimelineData extends BaseObject { + static toString(): string; + type: TimelineType; + offset: number; + frameIndicesOffset: number; + protected _onClear(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The animation config is used to describe all the information needed to play an animation state. + * The API is still in the experimental phase and may encounter bugs or stability or compatibility issues when used. + * @see dragonBones.AnimationState + * @beta + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画配置用来描述播放一个动画状态所需要的全部信息。 + * 该 API 仍在实验阶段,使用时可能遭遇 bug 或稳定性或兼容性问题。 + * @see dragonBones.AnimationState + * @beta + * @version DragonBones 5.0 + * @language zh_CN + */ + class AnimationConfig extends BaseObject { + static toString(): string; + /** + * @private + */ + pauseFadeOut: boolean; + /** + * - Fade out the pattern of other animation states when the animation state is fade in. + * This property is typically used to specify the substitution of multiple animation states blend. + * @default dragonBones.AnimationFadeOutMode.All + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 淡入动画状态时淡出其他动画状态的模式。 + * 该属性通常用来指定多个动画状态混合时的相互替换关系。 + * @default dragonBones.AnimationFadeOutMode.All + * @version DragonBones 5.0 + * @language zh_CN + */ + fadeOutMode: AnimationFadeOutMode; + /** + * @private + */ + fadeOutTweenType: TweenType; + /** + * @private + */ + fadeOutTime: number; + /** + * @private + */ + pauseFadeIn: boolean; + /** + * @private + */ + actionEnabled: boolean; + /** + * @private + */ + additiveBlending: boolean; + /** + * - Whether the animation state has control over the display property of the slots. + * Sometimes blend a animation state does not want it to control the display properties of the slots, + * especially if other animation state are controlling the display properties of the slots. + * @default true + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画状态是否对插槽的显示对象属性有控制权。 + * 有时混合一个动画状态并不希望其控制插槽的显示对象属性, + * 尤其是其他动画状态正在控制这些插槽的显示对象属性时。 + * @default true + * @version DragonBones 5.0 + * @language zh_CN + */ + displayControl: boolean; + /** + * - Whether to reset the objects without animation to the armature pose when the animation state is start to play. + * This property should usually be set to false when blend multiple animation states. + * @default true + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 开始播放动画状态时是否将没有动画的对象重置为骨架初始值。 + * 通常在混合多个动画状态时应该将该属性设置为 false。 + * @default true + * @version DragonBones 5.1 + * @language zh_CN + */ + resetToPose: boolean; + /** + * @private + */ + fadeInTweenType: TweenType; + /** + * - The play times. [0: Loop play, [1~N]: Play N times] + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 播放次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次] + * @version DragonBones 3.0 + * @language zh_CN + */ + playTimes: number; + /** + * - The blend layer. + * High layer animation state will get the blend weight first. + * When the blend weight is assigned more than 1, the remaining animation states will no longer get the weight assigned. + * @readonly + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 混合图层。 + * 图层高的动画状态会优先获取混合权重。 + * 当混合权重分配超过 1 时,剩余的动画状态将不再获得权重分配。 + * @readonly + * @version DragonBones 5.0 + * @language zh_CN + */ + layer: number; + /** + * - The start time of play. (In seconds) + * @default 0.0 + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 播放的开始时间。 (以秒为单位) + * @default 0.0 + * @version DragonBones 5.0 + * @language zh_CN + */ + position: number; + /** + * - The duration of play. + * [-1: Use the default value of the animation data, 0: Stop play, (0~N]: The duration] (In seconds) + * @default -1.0 + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 播放的持续时间。 + * [-1: 使用动画数据默认值, 0: 动画停止, (0~N]: 持续时间] (以秒为单位) + * @default -1.0 + * @version DragonBones 5.0 + * @language zh_CN + */ + duration: number; + /** + * - The play speed. + * The value is an overlay relationship with {@link dragonBones.Animation#timeScale}. + * [(-N~0): Reverse play, 0: Stop play, (0~1): Slow play, 1: Normal play, (1~N): Fast play] + * @default 1.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 播放速度。 + * 该值与 {@link dragonBones.Animation#timeScale} 是叠加关系。 + * [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + timeScale: number; + /** + * - The blend weight. + * @default 1.0 + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 混合权重。 + * @default 1.0 + * @version DragonBones 5.0 + * @language zh_CN + */ + weight: number; + /** + * - The fade in time. + * [-1: Use the default value of the animation data, [0~N]: The fade in time] (In seconds) + * @default -1.0 + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 淡入时间。 + * [-1: 使用动画数据默认值, [0~N]: 淡入时间] (以秒为单位) + * @default -1.0 + * @version DragonBones 5.0 + * @language zh_CN + */ + fadeInTime: number; + /** + * - The auto fade out time when the animation state play completed. + * [-1: Do not fade out automatically, [0~N]: The fade out time] (In seconds) + * @default -1.0 + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画状态播放完成后的自动淡出时间。 + * [-1: 不自动淡出, [0~N]: 淡出时间] (以秒为单位) + * @default -1.0 + * @version DragonBones 5.0 + * @language zh_CN + */ + autoFadeOutTime: number; + /** + * - The name of the animation state. (Can be different from the name of the animation data) + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画状态名称。 (可以不同于动画数据) + * @version DragonBones 5.0 + * @language zh_CN + */ + name: string; + /** + * - The animation data name. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画数据名称。 + * @version DragonBones 5.0 + * @language zh_CN + */ + animation: string; + /** + * - The blend group name of the animation state. + * This property is typically used to specify the substitution of multiple animation states blend. + * @readonly + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 混合组名称。 + * 该属性通常用来指定多个动画状态混合时的相互替换关系。 + * @readonly + * @version DragonBones 5.0 + * @language zh_CN + */ + group: string; + /** + * @private + */ + readonly boneMask: Array; + /** + * @private + */ + protected _onClear(): void; + /** + * @private + */ + clear(): void; + /** + * @private + */ + copyFrom(value: AnimationConfig): void; + /** + * @private + */ + containsBoneMask(name: string): boolean; + /** + * @private + */ + addBoneMask(armature: Armature, name: string, recursive?: boolean): void; + /** + * @private + */ + removeBoneMask(armature: Armature, name: string, recursive?: boolean): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The texture atlas data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 贴图集数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + abstract class TextureAtlasData extends BaseObject { + /** + * @private + */ + autoSearch: boolean; + /** + * @private + */ + width: number; + /** + * @private + */ + height: number; + /** + * @private + */ + scale: number; + /** + * - The texture atlas name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 贴图集名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * - The image path of the texture atlas. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 贴图集图片路径。 + * @version DragonBones 3.0 + * @language zh_CN + */ + imagePath: string; + /** + * @private + */ + readonly textures: Map; + /** + * @inheritDoc + */ + protected _onClear(): void; + /** + * @private + */ + copyFrom(value: TextureAtlasData): void; + /** + * @internal + * @private + */ + abstract createTexture(): TextureData; + /** + * @internal + * @private + */ + addTexture(value: TextureData): void; + /** + * @private + */ + getTexture(name: string): TextureData | null; + } + /** + * @internal + * @private + */ + abstract class TextureData extends BaseObject { + static createRectangle(): Rectangle; + rotated: boolean; + name: string; + readonly region: Rectangle; + parent: TextureAtlasData; + frame: Rectangle | null; + protected _onClear(): void; + copyFrom(value: TextureData): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The armature proxy interface, the docking engine needs to implement it concretely. + * @see dragonBones.Armature + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 骨架代理接口,对接的引擎需要对其进行具体实现。 + * @see dragonBones.Armature + * @version DragonBones 5.0 + * @language zh_CN + */ + interface IArmatureProxy extends IEventDispatcher { + /** + * @internal + * @private + */ + dbInit(armature: Armature): void; + /** + * @internal + * @private + */ + dbClear(): void; + /** + * @internal + * @private + */ + dbUpdate(): void; + /** + * - Dispose the instance and the Armature instance. (The Armature instance will return to the object pool) + * @example + *
+         *     removeChild(armatureDisplay);
+         *     armatureDisplay.dispose();
+         * 
+ * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 释放该实例和骨架。 (骨架会回收到对象池) + * @example + *
+         *     removeChild(armatureDisplay);
+         *     armatureDisplay.dispose();
+         * 
+ * @version DragonBones 4.5 + * @language zh_CN + */ + dispose(disposeProxy: boolean): void; + /** + * - The armature. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 骨架。 + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly armature: Armature; + /** + * - The animation player. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画播放器。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly animation: Animation; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - Armature is the core of the skeleton animation system. + * @see dragonBones.ArmatureData + * @see dragonBones.Bone + * @see dragonBones.Slot + * @see dragonBones.Animation + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨架是骨骼动画系统的核心。 + * @see dragonBones.ArmatureData + * @see dragonBones.Bone + * @see dragonBones.Slot + * @see dragonBones.Animation + * @version DragonBones 3.0 + * @language zh_CN + */ + class Armature extends BaseObject implements IAnimatable { + static toString(): string; + private static _onSortSlots(a, b); + /** + * - Whether to inherit the animation control of the parent armature. + * True to try to have the child armature play an animation with the same name when the parent armature play the animation. + * @default true + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 是否继承父骨架的动画控制。 + * 如果该值为 true,当父骨架播放动画时,会尝试让子骨架播放同名动画。 + * @default true + * @version DragonBones 4.5 + * @language zh_CN + */ + inheritAnimation: boolean; + /** + * @private + */ + userData: any; + private _lockUpdate; + private _bonesDirty; + private _slotsDirty; + private _zOrderDirty; + private _flipX; + private _flipY; + /** + * @internal + * @private + */ + _cacheFrameIndex: number; + private readonly _bones; + private readonly _slots; + /** + * @internal + * @private + */ + readonly _glueSlots: Array; + /** + * @internal + * @private + */ + readonly _constraints: Array; + private readonly _actions; + /** + * @internal + * @private + */ + _armatureData: ArmatureData; + private _animation; + private _proxy; + private _display; + /** + * @internal + * @private + */ + _replaceTextureAtlasData: TextureAtlasData | null; + private _replacedTexture; + /** + * @internal + * @private + */ + _dragonBones: DragonBones; + private _clock; + /** + * @internal + * @private + */ + _parent: Slot | null; + /** + * @private + */ + protected _onClear(): void; + private _sortBones(); + private _sortSlots(); + /** + * @internal + * @private + */ + _sortZOrder(slotIndices: Array | Int16Array | null, offset: number): void; + /** + * @internal + * @private + */ + _addBoneToBoneList(value: Bone): void; + /** + * @internal + * @private + */ + _removeBoneFromBoneList(value: Bone): void; + /** + * @internal + * @private + */ + _addSlotToSlotList(value: Slot): void; + /** + * @internal + * @private + */ + _removeSlotFromSlotList(value: Slot): void; + /** + * @internal + * @private + */ + _bufferAction(action: ActionData, append: boolean): void; + /** + * - Dispose the armature. (Return to the object pool) + * @example + *
+         *     removeChild(armature.display);
+         *     armature.dispose();
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 释放骨架。 (回收到对象池) + * @example + *
+         *     removeChild(armature.display);
+         *     armature.dispose();
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + dispose(): void; + /** + * @internal + * @private + */ + init(armatureData: ArmatureData, proxy: IArmatureProxy, display: any, dragonBones: DragonBones): void; + /** + * @inheritDoc + */ + advanceTime(passedTime: number): void; + /** + * - Forces a specific bone or its owning slot to update the transform or display property in the next frame. + * @param boneName - The bone name. (If not set, all bones will be update) + * @param updateSlot - Whether to update the bone's slots. (Default: false) + * @see dragonBones.Bone#invalidUpdate() + * @see dragonBones.Slot#invalidUpdate() + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 强制特定骨骼或其拥有的插槽在下一帧更新变换或显示属性。 + * @param boneName - 骨骼名称。 (如果未设置,将更新所有骨骼) + * @param updateSlot - 是否更新骨骼的插槽。 (默认: false) + * @see dragonBones.Bone#invalidUpdate() + * @see dragonBones.Slot#invalidUpdate() + * @version DragonBones 3.0 + * @language zh_CN + */ + invalidUpdate(boneName?: string | null, updateSlot?: boolean): void; + /** + * - Check whether a specific point is inside a custom bounding box in a slot. + * The coordinate system of the point is the inner coordinate system of the armature. + * Custom bounding boxes need to be customized in Dragonbones Pro. + * @param x - The horizontal coordinate of the point. + * @param y - The vertical coordinate of the point. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 检查特定点是否在某个插槽的自定义边界框内。 + * 点的坐标系为骨架内坐标系。 + * 自定义边界框需要在 DragonBones Pro 中自定义。 + * @param x - 点的水平坐标。 + * @param y - 点的垂直坐标。 + * @version DragonBones 5.0 + * @language zh_CN + */ + containsPoint(x: number, y: number): Slot | null; + /** + * - Check whether a specific segment intersects a custom bounding box for a slot in the armature. + * The coordinate system of the segment and intersection is the inner coordinate system of the armature. + * Custom bounding boxes need to be customized in Dragonbones Pro. + * @param xA - The horizontal coordinate of the beginning of the segment. + * @param yA - The vertical coordinate of the beginning of the segment. + * @param xB - The horizontal coordinate of the end point of the segment. + * @param yB - The vertical coordinate of the end point of the segment. + * @param intersectionPointA - The first intersection at which a line segment intersects the bounding box from the beginning to the end. (If not set, the intersection point will not calculated) + * @param intersectionPointB - The first intersection at which a line segment intersects the bounding box from the end to the beginning. (If not set, the intersection point will not calculated) + * @param normalRadians - The normal radians of the tangent of the intersection boundary box. [x: Normal radian of the first intersection tangent, y: Normal radian of the second intersection tangent] (If not set, the normal will not calculated) + * @returns The slot of the first custom bounding box where the segment intersects from the start point to the end point. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 检查特定线段是否与骨架的某个插槽的自定义边界框相交。 + * 线段和交点的坐标系均为骨架内坐标系。 + * 自定义边界框需要在 DragonBones Pro 中自定义。 + * @param xA - 线段起点的水平坐标。 + * @param yA - 线段起点的垂直坐标。 + * @param xB - 线段终点的水平坐标。 + * @param yB - 线段终点的垂直坐标。 + * @param intersectionPointA - 线段从起点到终点与边界框相交的第一个交点。 (如果未设置,则不计算交点) + * @param intersectionPointB - 线段从终点到起点与边界框相交的第一个交点。 (如果未设置,则不计算交点) + * @param normalRadians - 交点边界框切线的法线弧度。 [x: 第一个交点切线的法线弧度, y: 第二个交点切线的法线弧度] (如果未设置,则不计算法线) + * @returns 线段从起点到终点相交的第一个自定义边界框的插槽。 + * @version DragonBones 5.0 + * @language zh_CN + */ + intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): Slot | null; + /** + * - Get a specific bone. + * @param name - The bone name. + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的骨骼。 + * @param name - 骨骼名称。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + getBone(name: string): Bone | null; + /** + * - Get a specific bone by the display. + * @param display - The display object. + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 通过显示对象获取特定的骨骼。 + * @param display - 显示对象。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + getBoneByDisplay(display: any): Bone | null; + /** + * - Get a specific slot. + * @param name - The slot name. + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的插槽。 + * @param name - 插槽名称。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + getSlot(name: string): Slot | null; + /** + * - Get a specific slot by the display. + * @param display - The display object. + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 通过显示对象获取特定的插槽。 + * @param display - 显示对象。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + getSlotByDisplay(display: any): Slot | null; + /** + * @deprecated + */ + addBone(value: Bone, parentName: string): void; + /** + * @deprecated + */ + addSlot(value: Slot, parentName: string): void; + /** + * @private + */ + addConstraint(value: Constraint): void; + /** + * @deprecated + */ + removeBone(value: Bone): void; + /** + * @deprecated + */ + removeSlot(value: Slot): void; + /** + * - Get all bones. + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取所有的骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + getBones(): Array; + /** + * - Get all slots. + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取所有的插槽。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + getSlots(): Array; + /** + * - Whether to flip the armature horizontally. + * @version DragonBones 5.5 + * @language en_US + */ + /** + * - 是否将骨架水平翻转。 + * @version DragonBones 5.5 + * @language zh_CN + */ + flipX: boolean; + /** + * - Whether to flip the armature vertically. + * @version DragonBones 5.5 + * @language en_US + */ + /** + * - 是否将骨架垂直翻转。 + * @version DragonBones 5.5 + * @language zh_CN + */ + flipY: boolean; + /** + * - The animation cache frame rate, which turns on the animation cache when the set value is greater than 0. + * There is a certain amount of memory overhead to improve performance by caching animation data in memory. + * The frame rate should not be set too high, usually with the frame rate of the animation is similar and lower than the program running frame rate. + * When the animation cache is turned on, some features will fail, such as the offset property of bone. + * @example + *
+         *     armature.cacheFrameRate = 24;
+         * 
+ * @see dragonBones.DragonBonesData#frameRate + * @see dragonBones.ArmatureData#frameRate + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画缓存帧率,当设置的值大于 0 的时,将会开启动画缓存。 + * 通过将动画数据缓存在内存中来提高运行性能,会有一定的内存开销。 + * 帧率不宜设置的过高,通常跟动画的帧率相当且低于程序运行的帧率。 + * 开启动画缓存后,某些功能将会失效,比如骨骼的 offset 属性等。 + * @example + *
+         *     armature.cacheFrameRate = 24;
+         * 
+ * @see dragonBones.DragonBonesData#frameRate + * @see dragonBones.ArmatureData#frameRate + * @version DragonBones 4.5 + * @language zh_CN + */ + cacheFrameRate: number; + /** + * - The armature name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨架名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly name: string; + /** + * - The armature data. + * @see dragonBones.ArmatureData + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 骨架数据。 + * @see dragonBones.ArmatureData + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly armatureData: ArmatureData; + /** + * - The animation player. + * @see dragonBones.Animation + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画播放器。 + * @see dragonBones.Animation + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly animation: Animation; + /** + * @pivate + */ + readonly proxy: IArmatureProxy; + /** + * - The EventDispatcher instance of the armature. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 该骨架的 EventDispatcher 实例。 + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly eventDispatcher: IEventDispatcher; + /** + * - The display container. + * The display of the slot is displayed as the parent. + * Depending on the rendering engine, the type will be different, usually the DisplayObjectContainer type. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 显示容器实例。 + * 插槽的显示对象都会以此显示容器为父级。 + * 根据渲染引擎的不同,类型会不同,通常是 DisplayObjectContainer 类型。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly display: any; + /** + * @private + */ + replacedTexture: any; + /** + * @inheritDoc + */ + clock: WorldClock | null; + /** + * - Get the parent slot which the armature belongs to. + * @see dragonBones.Slot + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 该骨架所属的父插槽。 + * @see dragonBones.Slot + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly parent: Slot | null; + /** + * @deprecated + * @private + */ + replaceTexture(texture: any): void; + /** + * - Deprecated, please refer to {@link #eventDispatcher}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #eventDispatcher}。 + * @deprecated + * @language zh_CN + */ + hasEventListener(type: EventStringType): boolean; + /** + * - Deprecated, please refer to {@link #eventDispatcher}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #eventDispatcher}。 + * @deprecated + * @language zh_CN + */ + addEventListener(type: EventStringType, listener: Function, target: any): void; + /** + * - Deprecated, please refer to {@link #eventDispatcher}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #eventDispatcher}。 + * @deprecated + * @language zh_CN + */ + removeEventListener(type: EventStringType, listener: Function, target: any): void; + /** + * - Deprecated, please refer to {@link #cacheFrameRate}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #cacheFrameRate}。 + * @deprecated + * @language zh_CN + */ + enableAnimationCache(frameRate: number): void; + /** + * - Deprecated, please refer to {@link #display}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #display}。 + * @deprecated + * @language zh_CN + */ + getDisplay(): any; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The base class of the transform object. + * @see dragonBones.Transform + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 变换对象的基类。 + * @see dragonBones.Transform + * @version DragonBones 4.5 + * @language zh_CN + */ + abstract class TransformObject extends BaseObject { + /** + * @private + */ + protected static readonly _helpMatrix: Matrix; + /** + * @private + */ + protected static readonly _helpTransform: Transform; + /** + * @private + */ + protected static readonly _helpPoint: Point; + /** + * - A matrix relative to the armature coordinate system. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 相对于骨架坐标系的矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly globalTransformMatrix: Matrix; + /** + * - A transform relative to the armature coordinate system. + * @see #updateGlobalTransform() + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 相对于骨架坐标系的变换。 + * @see #updateGlobalTransform() + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly global: Transform; + /** + * - The offset transform relative to the armature or the parent bone coordinate system. + * @see #dragonBones.Bone#invalidUpdate() + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 相对于骨架或父骨骼坐标系的偏移变换。 + * @see #dragonBones.Bone#invalidUpdate() + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly offset: Transform; + /** + * @private + */ + origin: Transform | null; + /** + * @private + */ + userData: any; + /** + * @private + */ + protected _globalDirty: boolean; + /** + * @internal + * @private + */ + _armature: Armature; + /** + * @internal + * @private + */ + _parent: Bone; + /** + * @private + */ + protected _onClear(): void; + /** + * @internal + * @private + */ + _setArmature(value: Armature | null): void; + /** + * @internal + * @private + */ + _setParent(value: Bone | null): void; + /** + * - For performance considerations, rotation or scale in the {@link #global} attribute of the bone or slot is not always properly accessible, + * some engines do not rely on these attributes to update rendering, such as Egret. + * The use of this method ensures that the access to the {@link #global} property is correctly rotation or scale. + * @example + *
+         *     bone.updateGlobalTransform();
+         *     let rotation = bone.global.rotation;
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 出于性能的考虑,骨骼或插槽的 {@link #global} 属性中的旋转或缩放并不总是正确可访问的,有些引擎并不依赖这些属性更新渲染,比如 Egret。 + * 使用此方法可以保证访问到 {@link #global} 属性中正确的旋转或缩放。 + * @example + *
+         *     bone.updateGlobalTransform();
+         *     let rotation = bone.global.rotation;
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + updateGlobalTransform(): void; + /** + * - The armature to which it belongs. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 所属的骨架。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly armature: Armature; + /** + * - The parent bone to which it belongs. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 所属的父骨骼。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly parent: Bone; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - Bone is one of the most important logical units in the armature animation system, + * and is responsible for the realization of translate, rotation, scaling in the animations. + * A armature can contain multiple bones. + * @see dragonBones.BoneData + * @see dragonBones.Armature + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨骼在骨骼动画体系中是最重要的逻辑单元之一,负责动画中的平移、旋转、缩放的实现。 + * 一个骨架中可以包含多个骨骼。 + * @see dragonBones.BoneData + * @see dragonBones.Armature + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + class Bone extends TransformObject { + static toString(): string; + /** + * - The offset mode. + * @see #offset + * @version DragonBones 5.5 + * @language en_US + */ + /** + * - 偏移模式。 + * @see #offset + * @version DragonBones 5.5 + * @language zh_CN + */ + offsetMode: OffsetMode; + /** + * @internal + * @private + */ + readonly animationPose: Transform; + /** + * @internal + * @private + */ + _transformDirty: boolean; + /** + * @internal + * @private + */ + _childrenTransformDirty: boolean; + protected _localDirty: boolean; + /** + * @internal + * @private + */ + _hasConstraint: boolean; + private _visible; + protected _cachedFrameIndex: number; + /** + * @internal + * @private + */ + readonly _blendState: BlendState; + /** + * @internal + * @private + */ + _boneData: BoneData; + /** + * @internal + * @private + */ + _cachedFrameIndices: Array | null; + /** + * @inheritDoc + */ + protected _onClear(): void; + /** + * @private + */ + protected _updateGlobalTransformMatrix(isCache: boolean): void; + /** + * @inheritDoc + */ + _setArmature(value: Armature | null): void; + /** + * @internal + * @private + */ + init(boneData: BoneData): void; + /** + * @internal + * @private + */ + update(cacheFrameIndex: number): void; + /** + * @internal + * @private + */ + updateByConstraint(): void; + /** + * - Forces the bone to update the transform in the next frame. + * When the bone is not animated or its animation state is finished, the bone will not continue to update, + * and when the skeleton must be updated for some reason, the method needs to be called explicitly. + * @example + *
+         *     let bone = armature.getBone("arm");
+         *     bone.offset.scaleX = 2.0;
+         *     bone.invalidUpdate();
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 强制骨骼在下一帧更新变换。 + * 当该骨骼没有动画状态或其动画状态播放完成时,骨骼将不在继续更新,而此时由于某些原因必须更新骨骼时,则需要显式调用该方法。 + * @example + *
+         *     let bone = armature.getBone("arm");
+         *     bone.offset.scaleX = 2.0;
+         *     bone.invalidUpdate();
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + invalidUpdate(): void; + /** + * - Check whether the bone contains a specific bone or slot. + * @see dragonBones.Bone + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 检查该骨骼是否包含特定的骨骼或插槽。 + * @see dragonBones.Bone + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + contains(value: TransformObject): boolean; + /** + * - The bone data. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 骨骼数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly boneData: BoneData; + /** + * - The visible of all slots in the bone. + * @default true + * @see dragonBones.Slot#visible + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 此骨骼所有插槽的可见。 + * @default true + * @see dragonBones.Slot#visible + * @version DragonBones 3.0 + * @language zh_CN + */ + visible: boolean; + /** + * - The bone name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨骼名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly name: string; + /** + * - Deprecated, please refer to {@link dragonBones.Armature#getBones()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link dragonBones.Armature#getBones()}。 + * @deprecated + * @language zh_CN + */ + getBones(): Array; + /** + * - Deprecated, please refer to {@link dragonBones.Armature#getSlots()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link dragonBones.Armature#getSlots()}。 + * @deprecated + * @language zh_CN + */ + getSlots(): Array; + /** + * - Deprecated, please refer to {@link dragonBones.Armature#getSlot()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link dragonBones.Armature#getSlot()}。 + * @deprecated + * @language zh_CN + */ + readonly slot: Slot | null; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + class Surface extends Bone { + static toString(): string; + private _dX; + private _dY; + private _k; + private _kX; + private _kY; + /** + * For debug draw. + * @internal + * @private + */ + readonly _vertices: Array; + /** + * For timeline state. + * @internal + * @private + */ + readonly _deformVertices: Array; + /** + * x1, y1, x2, y2, x3, y3, x4, y4, d1X, d1Y, d2X, d2Y + */ + private readonly _hullCache; + /** + * Inside [flag, a, b, c, d, tx, ty], Outside [flag, a, b, c, d, tx, ty] + */ + private readonly _matrixCahce; + /** + * @inheritDoc + */ + protected _onClear(): void; + private _getAffineTransform(x, y, lX, lY, aX, aY, bX, bY, cX, cY, transform, matrix, isDown); + private _updateVertices(); + /** + * @private + */ + protected _updateGlobalTransformMatrix(isCache: boolean): void; + _getGlobalTransformMatrix(x: number, y: number): Matrix; + init(surfaceData: SurfaceData): void; + /** + * @internal + * @private + */ + update(cacheFrameIndex: number): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The slot attached to the armature, controls the display status and properties of the display object. + * A bone can contain multiple slots. + * A slot can contain multiple display objects, displaying only one of the display objects at a time, + * but you can toggle the display object into frame animation while the animation is playing. + * The display object can be a normal texture, or it can be a display of a child armature, a grid display object, + * and a custom other display object. + * @see dragonBones.Armature + * @see dragonBones.Bone + * @see dragonBones.SlotData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 插槽附着在骨骼上,控制显示对象的显示状态和属性。 + * 一个骨骼上可以包含多个插槽。 + * 一个插槽中可以包含多个显示对象,同一时间只能显示其中的一个显示对象,但可以在动画播放的过程中切换显示对象实现帧动画。 + * 显示对象可以是普通的图片纹理,也可以是子骨架的显示容器,网格显示对象,还可以是自定义的其他显示对象。 + * @see dragonBones.Armature + * @see dragonBones.Bone + * @see dragonBones.SlotData + * @version DragonBones 3.0 + * @language zh_CN + */ + abstract class Slot extends TransformObject { + /** + * - Displays the animated state or mixed group name controlled by the object, set to null to be controlled by all animation states. + * @default null + * @see dragonBones.AnimationState#displayControl + * @see dragonBones.AnimationState#name + * @see dragonBones.AnimationState#group + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 显示对象受到控制的动画状态或混合组名称,设置为 null 则表示受所有的动画状态控制。 + * @default null + * @see dragonBones.AnimationState#displayControl + * @see dragonBones.AnimationState#name + * @see dragonBones.AnimationState#group + * @version DragonBones 4.5 + * @language zh_CN + */ + displayController: string | null; + /** + * @private + */ + protected _displayDirty: boolean; + /** + * @private + */ + protected _zOrderDirty: boolean; + /** + * @private + */ + protected _visibleDirty: boolean; + /** + * @private + */ + protected _blendModeDirty: boolean; + /** + * @internal + * @private + */ + _colorDirty: boolean; + /** + * @internal + * @private + */ + _meshDirty: boolean; + /** + * @private + */ + protected _transformDirty: boolean; + /** + * @private + */ + protected _visible: boolean; + /** + * @private + */ + protected _blendMode: BlendMode; + /** + * @private + */ + protected _displayIndex: number; + /** + * @private + */ + protected _animationDisplayIndex: number; + /** + * @internal + * @private + */ + _zOrder: number; + /** + * @private + */ + protected _cachedFrameIndex: number; + /** + * @internal + * @private + */ + _pivotX: number; + /** + * @internal + * @private + */ + _pivotY: number; + /** + * @private + */ + protected readonly _localMatrix: Matrix; + /** + * @internal + * @private + */ + readonly _colorTransform: ColorTransform; + /** + * @internal + * @private + */ + readonly _deformVertices: Array; + /** + * @private + */ + readonly _displayDatas: Array; + /** + * @private + */ + protected readonly _displayList: Array; + /** + * @private + */ + protected readonly _meshBones: Array; + /** + * @private + */ + protected readonly _meshSlots: Array; + /** + * @internal + * @private + */ + _slotData: SlotData; + /** + * @private + */ + protected _rawDisplayDatas: Array | null; + /** + * @private + */ + protected _displayData: DisplayData | null; + /** + * @private + */ + protected _textureData: TextureData | null; + /** + * @internal + * @private + */ + _meshData: MeshDisplayData | null; + /** + * @private + */ + protected _boundingBoxData: BoundingBoxData | null; + /** + * @private + */ + protected _rawDisplay: any; + /** + * @private + */ + protected _meshDisplay: any; + /** + * @private + */ + protected _display: any; + /** + * @private + */ + protected _childArmature: Armature | null; + /** + * @internal + * @private + */ + _cachedFrameIndices: Array | null; + /** + * @inheritDoc + */ + protected _onClear(): void; + /** + * @private + */ + protected abstract _initDisplay(value: any, isRetain: boolean): void; + /** + * @private + */ + protected abstract _disposeDisplay(value: any, isRelease: boolean): void; + /** + * @private + */ + protected abstract _onUpdateDisplay(): void; + /** + * @private + */ + protected abstract _addDisplay(): void; + /** + * @private + */ + protected abstract _replaceDisplay(value: any): void; + /** + * @private + */ + protected abstract _removeDisplay(): void; + /** + * @private + */ + protected abstract _updateZOrder(): void; + /** + * @private + */ + abstract _updateVisible(): void; + /** + * @private + */ + protected abstract _updateBlendMode(): void; + /** + * @private + */ + protected abstract _updateColor(): void; + /** + * @private + */ + protected abstract _updateFrame(): void; + /** + * @private + */ + protected abstract _updateMesh(): void; + /** + * @internal + * @private + */ + abstract _updateGlueMesh(): void; + /** + * @private + */ + protected abstract _updateTransform(): void; + /** + * @private + */ + protected abstract _identityTransform(): void; + /** + * @private + */ + protected _getDefaultRawDisplayData(): DisplayData | null; + /** + * @private + */ + protected _updateDisplayData(): void; + /** + * @private + */ + protected _updateDisplay(): void; + /** + * @private + */ + protected _updateGlobalTransformMatrix(isCache: boolean): void; + /** + * @private + */ + protected _isMeshBonesUpdate(): boolean; + /** + * @inheritDoc + */ + _setArmature(value: Armature | null): void; + /** + * @internal + * @private + */ + _setDisplayIndex(value: number, isAnimation?: boolean): boolean; + /** + * @internal + * @private + */ + _setZorder(value: number): boolean; + /** + * @internal + * @private + */ + _setColor(value: ColorTransform): boolean; + /** + * @internal + * @private + */ + _setDisplayList(value: Array | null): boolean; + /** + * @internal + * @private + */ + init(slotData: SlotData, displayDatas: Array | null, rawDisplay: any, meshDisplay: any): void; + /** + * @internal + * @private + */ + update(cacheFrameIndex: number): void; + /** + * @private + */ + updateTransformAndMatrix(): void; + /** + * @private + */ + replaceDisplayData(value: DisplayData | null, displayIndex?: number): void; + /** + * - Check whether a specific point is inside a custom bounding box in the slot. + * The coordinate system of the point is the inner coordinate system of the armature. + * Custom bounding boxes need to be customized in Dragonbones Pro. + * @param x - The horizontal coordinate of the point. + * @param y - The vertical coordinate of the point. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 检查特定点是否在插槽的自定义边界框内。 + * 点的坐标系为骨架内坐标系。 + * 自定义边界框需要在 DragonBones Pro 中自定义。 + * @param x - 点的水平坐标。 + * @param y - 点的垂直坐标。 + * @version DragonBones 5.0 + * @language zh_CN + */ + containsPoint(x: number, y: number): boolean; + /** + * - Check whether a specific segment intersects a custom bounding box for the slot. + * The coordinate system of the segment and intersection is the inner coordinate system of the armature. + * Custom bounding boxes need to be customized in Dragonbones Pro. + * @param xA - The horizontal coordinate of the beginning of the segment. + * @param yA - The vertical coordinate of the beginning of the segment. + * @param xB - The horizontal coordinate of the end point of the segment. + * @param yB - The vertical coordinate of the end point of the segment. + * @param intersectionPointA - The first intersection at which a line segment intersects the bounding box from the beginning to the end. (If not set, the intersection point will not calculated) + * @param intersectionPointB - The first intersection at which a line segment intersects the bounding box from the end to the beginning. (If not set, the intersection point will not calculated) + * @param normalRadians - The normal radians of the tangent of the intersection boundary box. [x: Normal radian of the first intersection tangent, y: Normal radian of the second intersection tangent] (If not set, the normal will not calculated) + * @returns Intersection situation. [1: Disjoint and segments within the bounding box, 0: Disjoint, 1: Intersecting and having a nodal point and ending in the bounding box, 2: Intersecting and having a nodal point and starting at the bounding box, 3: Intersecting and having two intersections, N: Intersecting and having N intersections] + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 检查特定线段是否与插槽的自定义边界框相交。 + * 线段和交点的坐标系均为骨架内坐标系。 + * 自定义边界框需要在 DragonBones Pro 中自定义。 + * @param xA - 线段起点的水平坐标。 + * @param yA - 线段起点的垂直坐标。 + * @param xB - 线段终点的水平坐标。 + * @param yB - 线段终点的垂直坐标。 + * @param intersectionPointA - 线段从起点到终点与边界框相交的第一个交点。 (如果未设置,则不计算交点) + * @param intersectionPointB - 线段从终点到起点与边界框相交的第一个交点。 (如果未设置,则不计算交点) + * @param normalRadians - 交点边界框切线的法线弧度。 [x: 第一个交点切线的法线弧度, y: 第二个交点切线的法线弧度] (如果未设置,则不计算法线) + * @returns 相交的情况。 [-1: 不相交且线段在包围盒内, 0: 不相交, 1: 相交且有一个交点且终点在包围盒内, 2: 相交且有一个交点且起点在包围盒内, 3: 相交且有两个交点, N: 相交且有 N 个交点] + * @version DragonBones 5.0 + * @language zh_CN + */ + intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): number; + /** + * - Forces the slot to update the state of the display object in the next frame. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 强制插槽在下一帧更新显示对象的状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + invalidUpdate(): void; + /** + * - The visible of slot's display object. + * @default true + * @version DragonBones 5.6 + * @language en_US + */ + /** + * - 插槽的显示对象的可见。 + * @default true + * @version DragonBones 5.6 + * @language zh_CN + */ + visible: boolean; + /** + * - The index of the display object displayed in the display list. + * @example + *
+         *     let slot = armature.getSlot("weapon");
+         *     slot.displayIndex = 3;
+         *     slot.displayController = "none";
+         * 
+ * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 此时显示的显示对象在显示列表中的索引。 + * @example + *
+         *     let slot = armature.getSlot("weapon");
+         *     slot.displayIndex = 3;
+         *     slot.displayController = "none";
+         * 
+ * @version DragonBones 4.5 + * @language zh_CN + */ + displayIndex: number; + /** + * - The slot name. + * @see dragonBones.SlotData#name + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 插槽名称。 + * @see dragonBones.SlotData#name + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly name: string; + /** + * - Contains a display list of display objects or child armatures. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 包含显示对象或子骨架的显示列表。 + * @version DragonBones 3.0 + * @language zh_CN + */ + displayList: Array; + /** + * - The slot data. + * @see dragonBones.SlotData + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 插槽数据。 + * @see dragonBones.SlotData + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly slotData: SlotData; + /** + * @private + */ + rawDisplayDatas: Array | null; + /** + * - The custom bounding box data for the slot at current time. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 插槽此时的自定义包围盒数据。 + * @version DragonBones 5.0 + * @language zh_CN + */ + readonly boundingBoxData: BoundingBoxData | null; + /** + * @private + */ + readonly rawDisplay: any; + /** + * @private + */ + readonly meshDisplay: any; + /** + * - The display object that the slot displays at this time. + * @example + *
+         *     let slot = armature.getSlot("text");
+         *     slot.display = new yourEngine.TextField();
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 插槽此时显示的显示对象。 + * @example + *
+         *     let slot = armature.getSlot("text");
+         *     slot.display = new yourEngine.TextField();
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + display: any; + /** + * - The child armature that the slot displayed at current time. + * @example + *
+         *     let slot = armature.getSlot("weapon");
+         *     slot.childArmature = factory.buildArmature("weapon_blabla", "weapon_blabla_project");
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 插槽此时显示的子骨架。 + * @example + *
+         *     let slot = armature.getSlot("weapon");
+         *     slot.childArmature = factory.buildArmature("weapon_blabla", "weapon_blabla_project");
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + childArmature: Armature | null; + /** + * - Deprecated, please refer to {@link #display}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #display}。 + * @deprecated + * @language zh_CN + */ + getDisplay(): any; + /** + * - Deprecated, please refer to {@link #display}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #display}。 + * @deprecated + * @language zh_CN + */ + setDisplay(value: any): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + abstract class Constraint extends BaseObject { + protected static readonly _helpMatrix: Matrix; + protected static readonly _helpTransform: Transform; + protected static readonly _helpPoint: Point; + /** + * - For timeline state. + * @internal + */ + _constraintData: ConstraintData; + protected _armature: Armature; + /** + * - For sort bones. + * @internal + */ + _target: Bone; + /** + * - For sort bones. + * @internal + */ + _root: Bone; + protected _bone: Bone | null; + protected _onClear(): void; + abstract init(constraintData: ConstraintData, armature: Armature): void; + abstract update(): void; + abstract invalidUpdate(): void; + readonly name: string; + } + /** + * @internal + * @private + */ + class IKConstraint extends Constraint { + static toString(): string; + private _scaleEnabled; + /** + * - For timeline state. + * @internal + */ + _bendPositive: boolean; + /** + * - For timeline state. + * @internal + */ + _weight: number; + protected _onClear(): void; + private _computeA(); + private _computeB(); + init(constraintData: ConstraintData, armature: Armature): void; + update(): void; + invalidUpdate(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - Play animation interface. (Both Armature and Wordclock implement the interface) + * Any instance that implements the interface can be added to the Worldclock instance and advance time by Worldclock instance uniformly. + * @see dragonBones.WorldClock + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 播放动画接口。 (Armature 和 WordClock 都实现了该接口) + * 任何实现了此接口的实例都可以添加到 WorldClock 实例中,由 WorldClock 实例统一更新时间。 + * @see dragonBones.WorldClock + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + interface IAnimatable { + /** + * - Advance time. + * @param passedTime - Passed time. (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 更新时间。 + * @param passedTime - 前进的时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + advanceTime(passedTime: number): void; + /** + * - The Wordclock instance to which the current belongs. + * @example + *
+         *     armature.clock = factory.clock; // Add armature to clock.
+         *     armature.clock = null; // Remove armature from clock.
+         * 
+ * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 当前所属的 WordClock 实例。 + * @example + *
+         *     armature.clock = factory.clock; // 将骨架添加到时钟。
+         *     armature.clock = null; // 将骨架从时钟移除。
+         * 
+ * @version DragonBones 5.0 + * @language zh_CN + */ + clock: WorldClock | null; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - Worldclock provides clock support for animations, advance time for each IAnimatable object added to the instance. + * @see dragonBones.IAnimateble + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - WorldClock 对动画提供时钟支持,为每个加入到该实例的 IAnimatable 对象更新时间。 + * @see dragonBones.IAnimateble + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + class WorldClock implements IAnimatable { + /** + * - Current time. (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 当前的时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + time: number; + /** + * - The play speed, used to control animation speed-shift play. + * [0: Stop play, (0~1): Slow play, 1: Normal play, (1~N): Fast play] + * @default 1.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 播放速度,用于控制动画变速播放。 + * [0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + timeScale: number; + private readonly _animatebles; + private _clock; + /** + * - Creating a Worldclock instance. Typically, you do not need to create Worldclock instance. + * When multiple Worldclock instances are running at different speeds, can achieving some specific animation effects, such as bullet time. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 创建一个 WorldClock 实例。通常并不需要创建 WorldClock 实例。 + * 当多个 WorldClock 实例使用不同的速度运行时,可以实现一些特殊的动画效果,比如子弹时间等。 + * @version DragonBones 3.0 + * @language zh_CN + */ + constructor(time?: number); + /** + * - Advance time for all IAnimatable instances. + * @param passedTime - Passed time. [-1: Automatically calculates the time difference between the current frame and the previous frame, [0~N): Passed time] (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 为所有的 IAnimatable 实例更新时间。 + * @param passedTime - 前进的时间。 [-1: 自动计算当前帧与上一帧的时间差, [0~N): 前进的时间] (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + advanceTime(passedTime: number): void; + /** + * - Check whether contains a specific instance of IAnimatable. + * @param value - The IAnimatable instance. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 检查是否包含特定的 IAnimatable 实例。 + * @param value - IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + contains(value: IAnimatable): boolean; + /** + * - Add IAnimatable instance. + * @param value - The IAnimatable instance. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 添加 IAnimatable 实例。 + * @param value - IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + add(value: IAnimatable): void; + /** + * - Removes a specified IAnimatable instance. + * @param value - The IAnimatable instance. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 移除特定的 IAnimatable 实例。 + * @param value - IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + remove(value: IAnimatable): void; + /** + * - Clear all IAnimatable instances. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 清除所有的 IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + clear(): void; + /** + * @inheritDoc + */ + clock: WorldClock | null; + /** + * - Deprecated, please refer to {@link dragonBones.BaseFactory#clock}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link dragonBones.BaseFactory#clock}。 + * @deprecated + * @language zh_CN + */ + static readonly clock: WorldClock; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The animation player is used to play the animation data and manage the animation states. + * @see dragonBones.AnimationData + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画播放器用来播放动画数据和管理动画状态。 + * @see dragonBones.AnimationData + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + class Animation extends BaseObject { + static toString(): string; + /** + * - The play speed of all animations. [0: Stop, (0~1): Slow, 1: Normal, (1~N): Fast] + * @default 1.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 所有动画的播放速度。 [0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + timeScale: number; + private _lockUpdate; + private _animationDirty; + private _inheritTimeScale; + private readonly _animationNames; + private readonly _animationStates; + private readonly _animations; + private _armature; + private _animationConfig; + private _lastAnimationState; + /** + * @private + */ + protected _onClear(): void; + private _fadeOut(animationConfig); + /** + * @internal + * @private + */ + init(armature: Armature): void; + /** + * @internal + * @private + */ + advanceTime(passedTime: number): void; + /** + * - Clear all animations states. + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 清除所有的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + reset(): void; + /** + * - Pause a specific animation state. + * @param animationName - The name of animation state. (If not set, it will pause all animations) + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 暂停指定动画状态的播放。 + * @param animationName - 动画状态名称。 (如果未设置,则暂停所有动画) + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + stop(animationName?: string | null): void; + /** + * - Play animation with a specific animation config. + * The API is still in the experimental phase and may encounter bugs or stability or compatibility issues when used. + * @param animationConfig - The animation config. + * @returns The playing animation state. + * @see dragonBones.AnimationConfig + * @beta + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 通过指定的动画配置来播放动画。 + * 该 API 仍在实验阶段,使用时可能遭遇 bug 或稳定性或兼容性问题。 + * @param animationConfig - 动画配置。 + * @returns 播放的动画状态。 + * @see dragonBones.AnimationConfig + * @beta + * @version DragonBones 5.0 + * @language zh_CN + */ + playConfig(animationConfig: AnimationConfig): AnimationState | null; + /** + * - Play a specific animation. + * @param animationName - The name of animation data. (If not set, The default animation will be played, or resume the animation playing from pause status, or replay the last playing animation) + * @param playTimes - Playing repeat times. [-1: Use default value of the animation data, 0: No end loop playing, [1~N]: Repeat N times] (default: -1) + * @returns The playing animation state. + * @example + *
+         *     armature.animation.play("walk");
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 播放指定动画。 + * @param animationName - 动画数据名称。 (如果未设置,则播放默认动画,或将暂停状态切换为播放状态,或重新播放之前播放的动画) + * @param playTimes - 循环播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) + * @returns 播放的动画状态。 + * @example + *
+         *     armature.animation.play("walk");
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + play(animationName?: string | null, playTimes?: number): AnimationState | null; + /** + * - Fade in a specific animation. + * @param animationName - The name of animation data. + * @param fadeInTime - The fade in time. [-1: Use the default value of animation data, [0~N]: The fade in time (In seconds)] (Default: -1) + * @param playTimes - playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) + * @param layer - The blending layer, the animation states in high level layer will get the blending weights with high priority, when the total blending weights are more than 1.0, there will be no more weights can be allocated to the other animation states. (Default: 0) + * @param group - The blending group name, it is typically used to specify the substitution of multiple animation states blending. (Default: null) + * @param fadeOutMode - The fade out mode, which is typically used to specify alternate mode of multiple animation states blending. (Default: AnimationFadeOutMode.SameLayerAndGroup) + * @returns The playing animation state. + * @example + *
+         *     armature.animation.fadeIn("walk", 0.3, 0, 0, "normalGroup").resetToPose = false;
+         *     armature.animation.fadeIn("attack", 0.3, 1, 0, "attackGroup").resetToPose = false;
+         * 
+ * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 淡入播放指定的动画。 + * @param animationName - 动画数据名称。 + * @param fadeInTime - 淡入时间。 [-1: 使用动画数据默认值, [0~N]: 淡入时间 (以秒为单位)] (默认: -1) + * @param playTimes - 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) + * @param layer - 混合图层,图层高的动画状态会优先获取混合权重,当混合权重分配总和超过 1.0 时,剩余的动画状态将不能再获得权重分配。 (默认: 0) + * @param group - 混合组名称,该属性通常用来指定多个动画状态混合时的相互替换关系。 (默认: null) + * @param fadeOutMode - 淡出模式,该属性通常用来指定多个动画状态混合时的相互替换模式。 (默认: AnimationFadeOutMode.SameLayerAndGroup) + * @returns 播放的动画状态。 + * @example + *
+         *     armature.animation.fadeIn("walk", 0.3, 0, 0, "normalGroup").resetToPose = false;
+         *     armature.animation.fadeIn("attack", 0.3, 1, 0, "attackGroup").resetToPose = false;
+         * 
+ * @version DragonBones 4.5 + * @language zh_CN + */ + fadeIn(animationName: string, fadeInTime?: number, playTimes?: number, layer?: number, group?: string | null, fadeOutMode?: AnimationFadeOutMode): AnimationState | null; + /** + * - Play a specific animation from the specific time. + * @param animationName - The name of animation data. + * @param time - The start time point of playing. (In seconds) + * @param playTimes - Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) + * @returns The played animation state. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 从指定时间开始播放指定的动画。 + * @param animationName - 动画数据名称。 + * @param time - 播放开始的时间。 (以秒为单位) + * @param playTimes - 循环播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) + * @returns 播放的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndPlayByTime(animationName: string, time?: number, playTimes?: number): AnimationState | null; + /** + * - Play a specific animation from the specific frame. + * @param animationName - The name of animation data. + * @param frame - The start frame of playing. + * @param playTimes - Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) + * @returns The played animation state. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 从指定帧开始播放指定的动画。 + * @param animationName - 动画数据名称。 + * @param frame - 播放开始的帧数。 + * @param playTimes - 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) + * @returns 播放的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndPlayByFrame(animationName: string, frame?: number, playTimes?: number): AnimationState | null; + /** + * - Play a specific animation from the specific progress. + * @param animationName - The name of animation data. + * @param progress - The start progress value of playing. + * @param playTimes - Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) + * @returns The played animation state. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 从指定进度开始播放指定的动画。 + * @param animationName - 动画数据名称。 + * @param progress - 开始播放的进度。 + * @param playTimes - 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) + * @returns 播放的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndPlayByProgress(animationName: string, progress?: number, playTimes?: number): AnimationState | null; + /** + * - Stop a specific animation at the specific time. + * @param animationName - The name of animation data. + * @param time - The stop time. (In seconds) + * @returns The played animation state. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 在指定时间停止指定动画播放 + * @param animationName - 动画数据名称。 + * @param time - 停止的时间。 (以秒为单位) + * @returns 播放的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndStopByTime(animationName: string, time?: number): AnimationState | null; + /** + * - Stop a specific animation at the specific frame. + * @param animationName - The name of animation data. + * @param frame - The stop frame. + * @returns The played animation state. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 在指定帧停止指定动画的播放 + * @param animationName - 动画数据名称。 + * @param frame - 停止的帧数。 + * @returns 播放的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndStopByFrame(animationName: string, frame?: number): AnimationState | null; + /** + * - Stop a specific animation at the specific progress. + * @param animationName - The name of animation data. + * @param progress - The stop progress value. + * @returns The played animation state. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 在指定的进度停止指定的动画播放。 + * @param animationName - 动画数据名称。 + * @param progress - 停止进度。 + * @returns 播放的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndStopByProgress(animationName: string, progress?: number): AnimationState | null; + /** + * - Get a specific animation state. + * @param animationName - The name of animation state. + * @example + *
+         *     armature.animation.play("walk");
+         *     let walkState = armature.animation.getState("walk");
+         *     walkState.timeScale = 0.5;
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取指定的动画状态 + * @param animationName - 动画状态名称。 + * @example + *
+         *     armature.animation.play("walk");
+         *     let walkState = armature.animation.getState("walk");
+         *     walkState.timeScale = 0.5;
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + getState(animationName: string): AnimationState | null; + /** + * - Check whether a specific animation data is included. + * @param animationName - The name of animation data. + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 检查是否包含指定的动画数据 + * @param animationName - 动画数据名称。 + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language zh_CN + */ + hasAnimation(animationName: string): boolean; + /** + * - Get all the animation states. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 获取所有的动画状态 + * @version DragonBones 5.1 + * @language zh_CN + */ + getStates(): Array; + /** + * - Check whether there is an animation state is playing + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 检查是否有动画状态正在播放 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly isPlaying: boolean; + /** + * - Check whether all the animation states' playing were finished. + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 检查是否所有的动画状态均已播放完毕。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly isCompleted: boolean; + /** + * - The name of the last playing animation state. + * @see #lastAnimationState + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 上一个播放的动画状态名称 + * @see #lastAnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly lastAnimationName: string; + /** + * - The name of all animation data + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 所有动画数据的名称 + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly animationNames: Array; + /** + * - All animation data. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 所有的动画数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + animations: Map; + /** + * - An AnimationConfig instance that can be used quickly. + * @see dragonBones.AnimationConfig + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 一个可以快速使用的动画配置实例。 + * @see dragonBones.AnimationConfig + * @version DragonBones 5.0 + * @language zh_CN + */ + readonly animationConfig: AnimationConfig; + /** + * - The last playing animation state + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 上一个播放的动画状态 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly lastAnimationState: AnimationState | null; + /** + * - Deprecated, please refer to {@link #play()} {@link #fadeIn()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #play()} {@link #fadeIn()}。 + * @deprecated + * @language zh_CN + */ + gotoAndPlay(animationName: string, fadeInTime?: number, duration?: number, playTimes?: number, layer?: number, group?: string | null, fadeOutMode?: AnimationFadeOutMode, pauseFadeOut?: boolean, pauseFadeIn?: boolean): AnimationState | null; + /** + * - Deprecated, please refer to {@link #gotoAndStopByTime()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #gotoAndStopByTime()}。 + * @deprecated + * @language zh_CN + */ + gotoAndStop(animationName: string, time?: number): AnimationState | null; + /** + * - Deprecated, please refer to {@link #animationNames}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #animationNames}。 + * @deprecated + * @language zh_CN + */ + readonly animationList: Array; + /** + * - Deprecated, please refer to {@link #animationNames}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #animationNames}。 + * @deprecated + * @language zh_CN + */ + readonly animationDataList: Array; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The animation state is generated when the animation data is played. + * @see dragonBones.Animation + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画状态由播放动画数据时产生。 + * @see dragonBones.Animation + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language zh_CN + */ + class AnimationState extends BaseObject { + static toString(): string; + /** + * @private + */ + actionEnabled: boolean; + /** + * @private + */ + additiveBlending: boolean; + /** + * - Whether the animation state has control over the display object properties of the slots. + * Sometimes blend a animation state does not want it to control the display object properties of the slots, + * especially if other animation state are controlling the display object properties of the slots. + * @default true + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画状态是否对插槽的显示对象属性有控制权。 + * 有时混合一个动画状态并不希望其控制插槽的显示对象属性, + * 尤其是其他动画状态正在控制这些插槽的显示对象属性时。 + * @default true + * @version DragonBones 5.0 + * @language zh_CN + */ + displayControl: boolean; + /** + * - Whether to reset the objects without animation to the armature pose when the animation state is start to play. + * This property should usually be set to false when blend multiple animation states. + * @default true + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 开始播放动画状态时是否将没有动画的对象重置为骨架初始值。 + * 通常在混合多个动画状态时应该将该属性设置为 false。 + * @default true + * @version DragonBones 5.1 + * @language zh_CN + */ + resetToPose: boolean; + /** + * - The play times. [0: Loop play, [1~N]: Play N times] + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 播放次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次] + * @version DragonBones 3.0 + * @language zh_CN + */ + playTimes: number; + /** + * - The blend layer. + * High layer animation state will get the blend weight first. + * When the blend weight is assigned more than 1, the remaining animation states will no longer get the weight assigned. + * @readonly + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 混合图层。 + * 图层高的动画状态会优先获取混合权重。 + * 当混合权重分配超过 1 时,剩余的动画状态将不再获得权重分配。 + * @readonly + * @version DragonBones 5.0 + * @language zh_CN + */ + layer: number; + /** + * - The play speed. + * The value is an overlay relationship with {@link dragonBones.Animation#timeScale}. + * [(-N~0): Reverse play, 0: Stop play, (0~1): Slow play, 1: Normal play, (1~N): Fast play] + * @default 1.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 播放速度。 + * 该值与 {@link dragonBones.Animation#timeScale} 是叠加关系。 + * [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + timeScale: number; + /** + * - The blend weight. + * @default 1.0 + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 混合权重。 + * @default 1.0 + * @version DragonBones 5.0 + * @language zh_CN + */ + weight: number; + /** + * - The auto fade out time when the animation state play completed. + * [-1: Do not fade out automatically, [0~N]: The fade out time] (In seconds) + * @default -1.0 + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画状态播放完成后的自动淡出时间。 + * [-1: 不自动淡出, [0~N]: 淡出时间] (以秒为单位) + * @default -1.0 + * @version DragonBones 5.0 + * @language zh_CN + */ + autoFadeOutTime: number; + /** + * @private + */ + fadeTotalTime: number; + /** + * - The name of the animation state. (Can be different from the name of the animation data) + * @readonly + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画状态名称。 (可以不同于动画数据) + * @readonly + * @version DragonBones 5.0 + * @language zh_CN + */ + name: string; + /** + * - The blend group name of the animation state. + * This property is typically used to specify the substitution of multiple animation states blend. + * @readonly + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 混合组名称。 + * 该属性通常用来指定多个动画状态混合时的相互替换关系。 + * @readonly + * @version DragonBones 5.0 + * @language zh_CN + */ + group: string; + private _timelineDirty; + /** + * - xx: Play Enabled, Fade Play Enabled + * @internal + * @private + */ + _playheadState: number; + /** + * -1: Fade in, 0: Fade complete, 1: Fade out; + * @internal + * @private + */ + _fadeState: number; + /** + * -1: Fade start, 0: Fading, 1: Fade complete; + * @internal + * @private + */ + _subFadeState: number; + /** + * @internal + * @private + */ + _position: number; + /** + * @internal + * @private + */ + _duration: number; + private _fadeTime; + private _time; + /** + * @internal + * @private + */ + _fadeProgress: number; + /** + * @internal + * @private + */ + _weightResult: number; + /** + * @internal + * @private + */ + readonly _blendState: BlendState; + private readonly _boneMask; + private readonly _boneTimelines; + private readonly _surfaceTimelines; + private readonly _slotTimelines; + private readonly _constraintTimelines; + private readonly _animationTimelines; + private readonly _poseTimelines; + private readonly _bonePoses; + /** + * @internal + * @private + */ + _animationData: AnimationData; + private _armature; + /** + * @internal + * @private + */ + _actionTimeline: ActionTimelineState; + private _zOrderTimeline; + /** + * @internal + * @private + */ + _parent: AnimationState; + /** + * @private + */ + protected _onClear(): void; + private _updateTimelines(); + private _updateBoneAndSlotTimelines(); + private _advanceFadeTime(passedTime); + /** + * @internal + * @private + */ + init(armature: Armature, animationData: AnimationData, animationConfig: AnimationConfig): void; + /** + * @internal + * @private + */ + advanceTime(passedTime: number, cacheFrameRate: number): void; + /** + * - Continue play. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 继续播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + play(): void; + /** + * - Stop play. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 暂停播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + stop(): void; + /** + * - Fade out the animation state. + * @param fadeOutTime - The fade out time. (In seconds) + * @param pausePlayhead - Whether to pause the animation playing when fade out. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 淡出动画状态。 + * @param fadeOutTime - 淡出时间。 (以秒为单位) + * @param pausePlayhead - 淡出时是否暂停播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + fadeOut(fadeOutTime: number, pausePlayhead?: boolean): void; + /** + * - Check if a specific bone mask is included. + * @param name - The bone name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 检查是否包含特定骨骼遮罩。 + * @param name - 骨骼名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + containsBoneMask(name: string): boolean; + /** + * - Add a specific bone mask. + * @param name - The bone name. + * @param recursive - Whether or not to add a mask to the bone's sub-bone. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 添加特定的骨骼遮罩。 + * @param name - 骨骼名称。 + * @param recursive - 是否为该骨骼的子骨骼添加遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + addBoneMask(name: string, recursive?: boolean): void; + /** + * - Remove the mask of a specific bone. + * @param name - The bone name. + * @param recursive - Whether to remove the bone's sub-bone mask. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 删除特定骨骼的遮罩。 + * @param name - 骨骼名称。 + * @param recursive - 是否删除该骨骼的子骨骼遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + removeBoneMask(name: string, recursive?: boolean): void; + /** + * - Remove all bone masks. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 删除所有骨骼遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + removeAllBoneMask(): void; + /** + * - Whether the animation state is fading in. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 是否正在淡入。 + * @version DragonBones 5.1 + * @language zh_CN + */ + readonly isFadeIn: boolean; + /** + * - Whether the animation state is fading out. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 是否正在淡出。 + * @version DragonBones 5.1 + * @language zh_CN + */ + readonly isFadeOut: boolean; + /** + * - Whether the animation state is fade completed. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 是否淡入或淡出完毕。 + * @version DragonBones 5.1 + * @language zh_CN + */ + readonly isFadeComplete: boolean; + /** + * - Whether the animation state is playing. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 是否正在播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly isPlaying: boolean; + /** + * - Whether the animation state is play completed. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 是否播放完毕。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly isCompleted: boolean; + /** + * - The times has been played. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 已经循环播放的次数。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly currentPlayTimes: number; + /** + * - The total time. (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 总播放时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly totalTime: number; + /** + * - The time is currently playing. (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 当前播放的时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + currentTime: number; + /** + * - The animation data. + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画数据。 + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly animationData: AnimationData; + } + /** + * @internal + * @private + */ + class BonePose extends BaseObject { + static toString(): string; + readonly current: Transform; + readonly delta: Transform; + readonly result: Transform; + protected _onClear(): void; + } + /** + * @internal + * @private + */ + class BlendState { + dirty: boolean; + layer: number; + leftWeight: number; + layerWeight: number; + blendWeight: number; + update(weight: number, layer: number): number; + clear(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + const enum TweenState { + None = 0, + Once = 1, + Always = 2, + } + /** + * @internal + * @private + */ + abstract class TimelineState extends BaseObject { + playState: number; + currentPlayTimes: number; + currentTime: number; + protected _tweenState: TweenState; + protected _frameRate: number; + protected _frameValueOffset: number; + protected _frameCount: number; + protected _frameOffset: number; + protected _frameIndex: number; + protected _frameRateR: number; + protected _position: number; + protected _duration: number; + protected _timeScale: number; + protected _timeOffset: number; + protected _dragonBonesData: DragonBonesData; + protected _animationData: AnimationData; + protected _timelineData: TimelineData | null; + protected _armature: Armature; + protected _animationState: AnimationState; + protected _actionTimeline: TimelineState; + protected _frameArray: Array | Int16Array; + protected _frameIntArray: Array | Int16Array; + protected _frameFloatArray: Array | Int16Array; + protected _timelineArray: Array | Uint16Array; + protected _frameIndices: Array; + protected _onClear(): void; + protected abstract _onArriveAtFrame(): void; + protected abstract _onUpdateFrame(): void; + protected _setCurrentTime(passedTime: number): boolean; + init(armature: Armature, animationState: AnimationState, timelineData: TimelineData | null): void; + fadeOut(): void; + update(passedTime: number): void; + } + /** + * @internal + * @private + */ + abstract class TweenTimelineState extends TimelineState { + private static _getEasingValue(tweenType, progress, easing); + private static _getEasingCurveValue(progress, samples, count, offset); + protected _tweenType: TweenType; + protected _curveCount: number; + protected _framePosition: number; + protected _frameDurationR: number; + protected _tweenProgress: number; + protected _tweenEasing: number; + protected _onClear(): void; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + } + /** + * @internal + * @private + */ + abstract class BoneTimelineState extends TweenTimelineState { + bone: Bone; + bonePose: BonePose; + protected _onClear(): void; + blend(state: number): void; + } + /** + * @internal + * @private + */ + abstract class SlotTimelineState extends TweenTimelineState { + slot: Slot; + protected _onClear(): void; + } + /** + * @internal + * @private + */ + abstract class ConstraintTimelineState extends TweenTimelineState { + constraint: Constraint; + protected _onClear(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + class ActionTimelineState extends TimelineState { + static toString(): string; + private _onCrossFrame(frameIndex); + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + update(passedTime: number): void; + setCurrentTime(value: number): void; + } + /** + * @internal + * @private + */ + class ZOrderTimelineState extends TimelineState { + static toString(): string; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + } + /** + * @internal + * @private + */ + class BoneAllTimelineState extends BoneTimelineState { + static toString(): string; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + fadeOut(): void; + } + /** + * @internal + * @private + */ + class BoneTranslateTimelineState extends BoneTimelineState { + static toString(): string; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + } + /** + * @internal + * @private + */ + class BoneRotateTimelineState extends BoneTimelineState { + static toString(): string; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + fadeOut(): void; + } + /** + * @internal + * @private + */ + class BoneScaleTimelineState extends BoneTimelineState { + static toString(): string; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + } + /** + * @internal + * @private + */ + class SurfaceTimelineState extends TweenTimelineState { + static toString(): string; + surface: Surface; + private _frameFloatOffset; + private _valueCount; + private _deformCount; + private _valueOffset; + private readonly _current; + private readonly _delta; + private readonly _result; + protected _onClear(): void; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + init(armature: Armature, animationState: AnimationState, timelineData: TimelineData | null): void; + blend(state: number): void; + } + /** + * @internal + * @private + */ + class SlotDislayTimelineState extends SlotTimelineState { + static toString(): string; + protected _onArriveAtFrame(): void; + } + /** + * @internal + * @private + */ + class SlotColorTimelineState extends SlotTimelineState { + static toString(): string; + private _dirty; + private readonly _current; + private readonly _delta; + private readonly _result; + protected _onClear(): void; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + fadeOut(): void; + update(passedTime: number): void; + } + /** + * @internal + * @private + */ + class SlotFFDTimelineState extends SlotTimelineState { + static toString(): string; + meshOffset: number; + private _dirty; + private _frameFloatOffset; + private _valueCount; + private _deformCount; + private _valueOffset; + private readonly _current; + private readonly _delta; + private readonly _result; + protected _onClear(): void; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + init(armature: Armature, animationState: AnimationState, timelineData: TimelineData | null): void; + fadeOut(): void; + update(passedTime: number): void; + } + /** + * @internal + * @private + */ + class IKConstraintTimelineState extends ConstraintTimelineState { + static toString(): string; + private _current; + private _delta; + protected _onClear(): void; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + } + /** + * @internal + * @private + */ + class AnimationTimelineState extends TweenTimelineState { + static toString(): string; + animationState: AnimationState; + private readonly _floats; + protected _onClear(): void; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + blend(state: number): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - The properties of the object carry basic information about an event, + * which are passed as parameter or parameter's parameter to event listeners when an event occurs. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 事件对象,包含有关事件的基本信息,当发生事件时,该实例将作为参数或参数的参数传递给事件侦听器。 + * @version DragonBones 4.5 + * @language zh_CN + */ + class EventObject extends BaseObject { + /** + * - Animation start play. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画开始播放。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly START: string; + /** + * - Animation loop play complete once. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画循环播放完成一次。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly LOOP_COMPLETE: string; + /** + * - Animation play complete. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画播放完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly COMPLETE: string; + /** + * - Animation fade in start. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画淡入开始。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly FADE_IN: string; + /** + * - Animation fade in complete. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画淡入完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly FADE_IN_COMPLETE: string; + /** + * - Animation fade out start. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画淡出开始。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly FADE_OUT: string; + /** + * - Animation fade out complete. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画淡出完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly FADE_OUT_COMPLETE: string; + /** + * - Animation frame event. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画帧事件。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly FRAME_EVENT: string; + /** + * - Animation frame sound event. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画帧声音事件。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly SOUND_EVENT: string; + static toString(): string; + /** + * - If is a frame event, the value is used to describe the time that the event was in the animation timeline. (In seconds) + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 如果是帧事件,此值用来描述该事件在动画时间轴中所处的时间。(以秒为单位) + * @version DragonBones 4.5 + * @language zh_CN + */ + time: number; + /** + * - The event type。 + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 事件类型。 + * @version DragonBones 4.5 + * @language zh_CN + */ + type: EventStringType; + /** + * - The event name. (The frame event name or the frame sound name) + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 事件名称。 (帧事件的名称或帧声音的名称) + * @version DragonBones 4.5 + * @language zh_CN + */ + name: string; + /** + * - The armature that dispatch the event. + * @see dragonBones.Armature + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 发出该事件的骨架。 + * @see dragonBones.Armature + * @version DragonBones 4.5 + * @language zh_CN + */ + armature: Armature; + /** + * - The bone that dispatch the event. + * @see dragonBones.Bone + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 发出该事件的骨骼。 + * @see dragonBones.Bone + * @version DragonBones 4.5 + * @language zh_CN + */ + bone: Bone | null; + /** + * - The slot that dispatch the event. + * @see dragonBones.Slot + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 发出该事件的插槽。 + * @see dragonBones.Slot + * @version DragonBones 4.5 + * @language zh_CN + */ + slot: Slot | null; + /** + * - The animation state that dispatch the event. + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 发出该事件的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + animationState: AnimationState; + /** + * - The custom data. + * @see dragonBones.CustomData + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 自定义数据。 + * @see dragonBones.CustomData + * @version DragonBones 5.0 + * @language zh_CN + */ + data: UserData | null; + /** + * @private + */ + protected _onClear(): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @private + */ + type EventStringType = string | "start" | "loopComplete" | "complete" | "fadeIn" | "fadeInComplete" | "fadeOut" | "fadeOutComplete" | "frameEvent" | "soundEvent"; + /** + * - The event dispatcher interface. + * Dragonbones event dispatch usually relies on docking engine to implement, which defines the event method to be implemented when docking the engine. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 事件派发接口。 + * DragonBones 的事件派发通常依赖于对接的引擎来实现,该接口定义了对接引擎时需要实现的事件方法。 + * @version DragonBones 4.5 + * @language zh_CN + */ + interface IEventDispatcher { + /** + * - Checks whether the object has any listeners registered for a specific type of event。 + * @param type - Event type. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 检查是否为特定的事件类型注册了任何侦听器。 + * @param type - 事件类型。 + * @version DragonBones 4.5 + * @language zh_CN + */ + hasDBEventListener(type: EventStringType): boolean; + /** + * - Dispatches an event into the event flow. + * @param type - Event type. + * @param eventObject - Event object. + * @see dragonBones.EventObject + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 分派特定的事件到事件流中。 + * @param type - 事件类型。 + * @param eventObject - 事件数据。 + * @see dragonBones.EventObject + * @version DragonBones 4.5 + * @language zh_CN + */ + dispatchDBEvent(type: EventStringType, eventObject: EventObject): void; + /** + * - Add an event listener object so that the listener receives notification of an event. + * @param type - Event type. + * @param listener - Event listener. + * @param thisObject - The listener function's "this". + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 添加特定事件类型的事件侦听器,以使侦听器能够接收事件通知。 + * @param type - 事件类型。 + * @param listener - 事件侦听器。 + * @param thisObject - 侦听函数绑定的 this 对象。 + * @version DragonBones 4.5 + * @language zh_CN + */ + addDBEventListener(type: EventStringType, listener: Function, thisObject: any): void; + /** + * - Removes a listener from the object. + * @param type - Event type. + * @param listener - Event listener. + * @param thisObject - The listener function's "this". + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 删除特定事件类型的侦听器。 + * @param type - 事件类型。 + * @param listener - 事件侦听器。 + * @param thisObject - 侦听函数绑定的 this 对象。 + * @version DragonBones 4.5 + * @language zh_CN + */ + removeDBEventListener(type: EventStringType, listener: Function, thisObject: any): void; + /** + * - Deprecated, please refer to {@link #hasDBEventListener()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #hasDBEventListener()}。 + * @deprecated + * @language zh_CN + */ + hasEvent(type: EventStringType): boolean; + /** + * - Deprecated, please refer to {@link #addDBEventListener()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #addDBEventListener()}。 + * @deprecated + * @language zh_CN + */ + addEvent(type: EventStringType, listener: Function, thisObject: any): void; + /** + * - Deprecated, please refer to {@link #removeDBEventListener()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #removeDBEventListener()}。 + * @deprecated + * @language zh_CN + */ + removeEvent(type: EventStringType, listener: Function, thisObject: any): void; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + abstract class DataParser { + protected static readonly DATA_VERSION_2_3: string; + protected static readonly DATA_VERSION_3_0: string; + protected static readonly DATA_VERSION_4_0: string; + protected static readonly DATA_VERSION_4_5: string; + protected static readonly DATA_VERSION_5_0: string; + protected static readonly DATA_VERSION_5_5: string; + protected static readonly DATA_VERSION: string; + protected static readonly DATA_VERSIONS: Array; + protected static readonly TEXTURE_ATLAS: string; + protected static readonly SUB_TEXTURE: string; + protected static readonly FORMAT: string; + protected static readonly IMAGE_PATH: string; + protected static readonly WIDTH: string; + protected static readonly HEIGHT: string; + protected static readonly ROTATED: string; + protected static readonly FRAME_X: string; + protected static readonly FRAME_Y: string; + protected static readonly FRAME_WIDTH: string; + protected static readonly FRAME_HEIGHT: string; + protected static readonly DRADON_BONES: string; + protected static readonly USER_DATA: string; + protected static readonly ARMATURE: string; + protected static readonly BONE: string; + protected static readonly SURFACE: string; + protected static readonly SLOT: string; + protected static readonly CONSTRAINT: string; + protected static readonly IK: string; + protected static readonly SKIN: string; + protected static readonly DISPLAY: string; + protected static readonly ANIMATION: string; + protected static readonly Z_ORDER: string; + protected static readonly FFD: string; + protected static readonly FRAME: string; + protected static readonly TRANSLATE_FRAME: string; + protected static readonly ROTATE_FRAME: string; + protected static readonly SCALE_FRAME: string; + protected static readonly DISPLAY_FRAME: string; + protected static readonly COLOR_FRAME: string; + protected static readonly DEFAULT_ACTIONS: string; + protected static readonly ACTIONS: string; + protected static readonly EVENTS: string; + protected static readonly INTS: string; + protected static readonly FLOATS: string; + protected static readonly STRINGS: string; + protected static readonly CANVAS: string; + protected static readonly TRANSFORM: string; + protected static readonly PIVOT: string; + protected static readonly AABB: string; + protected static readonly COLOR: string; + protected static readonly VERSION: string; + protected static readonly COMPATIBLE_VERSION: string; + protected static readonly FRAME_RATE: string; + protected static readonly TYPE: string; + protected static readonly SUB_TYPE: string; + protected static readonly NAME: string; + protected static readonly PARENT: string; + protected static readonly TARGET: string; + protected static readonly STAGE: string; + protected static readonly SHARE: string; + protected static readonly PATH: string; + protected static readonly LENGTH: string; + protected static readonly DISPLAY_INDEX: string; + protected static readonly BLEND_MODE: string; + protected static readonly INHERIT_TRANSLATION: string; + protected static readonly INHERIT_ROTATION: string; + protected static readonly INHERIT_SCALE: string; + protected static readonly INHERIT_REFLECTION: string; + protected static readonly INHERIT_ANIMATION: string; + protected static readonly INHERIT_DEFORM: string; + protected static readonly SEGMENT_X: string; + protected static readonly SEGMENT_Y: string; + protected static readonly BEND_POSITIVE: string; + protected static readonly CHAIN: string; + protected static readonly WEIGHT: string; + protected static readonly FADE_IN_TIME: string; + protected static readonly PLAY_TIMES: string; + protected static readonly SCALE: string; + protected static readonly OFFSET: string; + protected static readonly POSITION: string; + protected static readonly DURATION: string; + protected static readonly TWEEN_EASING: string; + protected static readonly TWEEN_ROTATE: string; + protected static readonly TWEEN_SCALE: string; + protected static readonly CLOCK_WISE: string; + protected static readonly CURVE: string; + protected static readonly SOUND: string; + protected static readonly EVENT: string; + protected static readonly ACTION: string; + protected static readonly X: string; + protected static readonly Y: string; + protected static readonly SKEW_X: string; + protected static readonly SKEW_Y: string; + protected static readonly SCALE_X: string; + protected static readonly SCALE_Y: string; + protected static readonly VALUE: string; + protected static readonly ROTATE: string; + protected static readonly SKEW: string; + protected static readonly ALPHA_OFFSET: string; + protected static readonly RED_OFFSET: string; + protected static readonly GREEN_OFFSET: string; + protected static readonly BLUE_OFFSET: string; + protected static readonly ALPHA_MULTIPLIER: string; + protected static readonly RED_MULTIPLIER: string; + protected static readonly GREEN_MULTIPLIER: string; + protected static readonly BLUE_MULTIPLIER: string; + protected static readonly UVS: string; + protected static readonly VERTICES: string; + protected static readonly TRIANGLES: string; + protected static readonly WEIGHTS: string; + protected static readonly SLOT_POSE: string; + protected static readonly BONE_POSE: string; + protected static readonly GLUE_WEIGHTS: string; + protected static readonly GLUE_MESHES: string; + protected static readonly GOTO_AND_PLAY: string; + protected static readonly DEFAULT_NAME: string; + protected static _getArmatureType(value: string): ArmatureType; + protected static _getBoneType(value: string): BoneType; + protected static _getDisplayType(value: string): DisplayType; + protected static _getBoundingBoxType(value: string): BoundingBoxType; + protected static _getActionType(value: string): ActionType; + protected static _getBlendMode(value: string): BlendMode; + abstract parseDragonBonesData(rawData: any, scale: number): DragonBonesData | null; + abstract parseTextureAtlasData(rawData: any, textureAtlasData: TextureAtlasData, scale: number): boolean; + /** + * - Deprecated, please refer to {@link dragonBones.BaseFactory#parsetTextureAtlasData()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link dragonBones.BaseFactory#parsetTextureAtlasData()}。 + * @deprecated + * @language zh_CN + */ + static parseDragonBonesData(rawData: any): DragonBonesData | null; + /** + * - Deprecated, please refer to {@link dragonBones.BaseFactory#parsetTextureAtlasData()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link dragonBones.BaseFactory#parsetTextureAtlasData()}。 + * @deprecated + * @language zh_CN + */ + static parseTextureAtlasData(rawData: any, scale?: number): any; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + class ObjectDataParser extends DataParser { + protected static _getBoolean(rawData: any, key: string, defaultValue: boolean): boolean; + protected static _getNumber(rawData: any, key: string, defaultValue: number): number; + protected static _getString(rawData: any, key: string, defaultValue: string): string; + protected _rawTextureAtlasIndex: number; + protected readonly _rawBones: Array; + protected _data: DragonBonesData; + protected _armature: ArmatureData; + protected _bone: BoneData; + protected _surface: SurfaceData; + protected _slot: SlotData; + protected _skin: SkinData; + protected _mesh: MeshDisplayData; + protected _animation: AnimationData; + protected _timeline: TimelineData; + protected _rawTextureAtlases: Array | null; + private _defaultColorOffset; + private _prevClockwise; + private _prevRotation; + private readonly _helpMatrixA; + private readonly _helpMatrixB; + private readonly _helpTransform; + private readonly _helpColorTransform; + private readonly _helpPoint; + private readonly _helpArray; + private readonly _intArray; + private readonly _floatArray; + private readonly _frameIntArray; + private readonly _frameFloatArray; + private readonly _frameArray; + private readonly _timelineArray; + private readonly _cacheRawMeshes; + private readonly _cacheMeshes; + private readonly _actionFrames; + private readonly _weightSlotPose; + private readonly _weightBonePoses; + private readonly _cacheBones; + private readonly _slotChildActions; + private _getCurvePoint(x1, y1, x2, y2, x3, y3, x4, y4, t, result); + private _samplingEasingCurve(curve, samples); + private _parseActionDataInFrame(rawData, frameStart, bone, slot); + private _mergeActionFrame(rawData, frameStart, type, bone, slot); + protected _parseArmature(rawData: any, scale: number): ArmatureData; + protected _parseBone(rawData: any): BoneData; + protected _parseIKConstraint(rawData: any): ConstraintData | null; + protected _parseSlot(rawData: any, zOrder: number): SlotData; + protected _parseSkin(rawData: any): SkinData; + protected _parseDisplay(rawData: any): DisplayData | null; + protected _parsePivot(rawData: any, display: ImageDisplayData): void; + protected _parseMesh(rawData: any, mesh: MeshDisplayData): void; + protected _parseMeshGlue(rawData: any, mesh: MeshDisplayData): void; + protected _parseBoundingBox(rawData: any): BoundingBoxData | null; + protected _parsePolygonBoundingBox(rawData: any): PolygonBoundingBoxData; + protected _parseAnimation(rawData: any): AnimationData; + protected _parseTimeline(rawData: any, rawFrames: Array | null, framesKey: string, type: TimelineType, addIntOffset: boolean, addFloatOffset: boolean, frameValueCount: number, frameParser: (rawData: any, frameStart: number, frameCount: number) => number): TimelineData | null; + protected _parseBoneTimeline(rawData: any): void; + protected _parseSlotTimeline(rawData: any): void; + protected _parseFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseTweenFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseActionFrame(frame: ActionFrame, frameStart: number, frameCount: number): number; + protected _parseZOrderFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseBoneAllFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseBoneTranslateFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseBoneRotateFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseBoneScaleFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseSurfaceFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseSlotDisplayFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseSlotColorFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseSlotFFDFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseIKConstraintFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseAnimationFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseActionData(rawData: any, type: ActionType, bone: BoneData | null, slot: SlotData | null): Array; + protected _parseTransform(rawData: any, transform: Transform, scale: number): void; + protected _parseColorTransform(rawData: any, color: ColorTransform): void; + protected _parseArray(rawData: any): void; + protected _modifyArray(): void; + parseDragonBonesData(rawData: any, scale?: number): DragonBonesData | null; + parseTextureAtlasData(rawData: any, textureAtlasData: TextureAtlasData, scale?: number): boolean; + private static _objectDataParserInstance; + /** + * - Deprecated, please refer to {@link dragonBones.BaseFactory#parseDragonBonesData()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link dragonBones.BaseFactory#parseDragonBonesData()}。 + * @deprecated + * @language zh_CN + */ + static getInstance(): ObjectDataParser; + } + /** + * @internal + * @private + */ + class ActionFrame { + frameStart: number; + readonly actions: Array; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * @internal + * @private + */ + class BinaryDataParser extends ObjectDataParser { + private _binaryOffset; + private _binary; + private _intArrayBuffer; + private _floatArrayBuffer; + private _frameIntArrayBuffer; + private _frameFloatArrayBuffer; + private _frameArrayBuffer; + private _timelineArrayBuffer; + private _inRange(a, min, max); + private _decodeUTF8(data); + private _getUTF16Key(value); + private _parseBinaryTimeline(type, offset, timelineData?); + protected _parseMesh(rawData: any, mesh: MeshDisplayData): void; + protected _parseAnimation(rawData: any): AnimationData; + protected _parseArray(rawData: any): void; + parseDragonBonesData(rawData: any, scale?: number): DragonBonesData | null; + private static _binaryDataParserInstance; + /** + * - Deprecated, please refer to {@link dragonBones.BaseFactory#parseDragonBonesData()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link dragonBones.BaseFactory#parseDragonBonesData()}。 + * @deprecated + * @language zh_CN + */ + static getInstance(): BinaryDataParser; + } +} +/** + * The MIT License (MIT) + * + * Copyright (c) 2012-2017 DragonBones team and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +declare namespace dragonBones { + /** + * - Base class for the factory that create the armatures. (Typically only one global factory instance is required) + * The factory instance create armatures by parsed and added DragonBonesData instances and TextureAtlasData instances. + * Once the data has been parsed, it has been cached in the factory instance and does not need to be parsed again until it is cleared by the factory instance. + * @see dragonBones.DragonBonesData + * @see dragonBones.TextureAtlasData + * @see dragonBones.ArmatureData + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 创建骨架的工厂基类。 (通常只需要一个全局工厂实例) + * 工厂通过解析并添加的 DragonBonesData 实例和 TextureAtlasData 实例来创建骨架。 + * 当数据被解析过之后,已经添加到工厂中,在没有被工厂清理之前,不需要再次解析。 + * @see dragonBones.DragonBonesData + * @see dragonBones.TextureAtlasData + * @see dragonBones.ArmatureData + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + abstract class BaseFactory { + /** + * @private + */ + protected static _objectParser: ObjectDataParser; + /** + * @private + */ + protected static _binaryParser: BinaryDataParser; + /** + * @private + */ + autoSearch: boolean; + /** + * @private + */ + protected readonly _dragonBonesDataMap: Map; + /** + * @private + */ + protected readonly _textureAtlasDataMap: Map>; + /** + * @private + */ + protected _dragonBones: DragonBones; + /** + * @private + */ + protected _dataParser: DataParser; + /** + * - Create a factory instance. (typically only one global factory instance is required) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 创建一个工厂实例。 (通常只需要一个全局工厂实例) + * @version DragonBones 3.0 + * @language zh_CN + */ + constructor(dataParser?: DataParser | null); + /** + * @private + */ + protected _isSupportMesh(): boolean; + /** + * @private + */ + protected _getTextureData(textureAtlasName: string, textureName: string): TextureData | null; + /** + * @private + */ + protected _fillBuildArmaturePackage(dataPackage: BuildArmaturePackage, dragonBonesName: string, armatureName: string, skinName: string, textureAtlasName: string): boolean; + /** + * @private + */ + protected _buildBones(dataPackage: BuildArmaturePackage, armature: Armature): void; + /** + * @private + */ + protected _buildSlots(dataPackage: BuildArmaturePackage, armature: Armature): void; + /** + * @private + */ + protected _buildChildArmature(dataPackage: BuildArmaturePackage | null, slot: Slot, displayData: DisplayData): Armature | null; + /** + * @private + */ + protected _getSlotDisplay(dataPackage: BuildArmaturePackage | null, displayData: DisplayData, rawDisplayData: DisplayData | null, slot: Slot): any; + /** + * @private + */ + protected abstract _buildTextureAtlasData(textureAtlasData: TextureAtlasData | null, textureAtlas: any): TextureAtlasData; + /** + * @private + */ + protected abstract _buildArmature(dataPackage: BuildArmaturePackage): Armature; + /** + * @private + */ + protected abstract _buildSlot(dataPackage: BuildArmaturePackage, slotData: SlotData, displays: Array | null, armature: Armature): Slot; + /** + * - Parse the raw data to a DragonBonesData instance and cache it to the factory. + * @param rawData - The raw data. + * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (If not set, use the instance name instead) + * @param scale - Specify a scaling value for all armatures. (Default: 1.0) + * @returns DragonBonesData instance + * @see #getDragonBonesData() + * @see #addDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 将原始数据解析为 DragonBonesData 实例,并缓存到工厂中。 + * @param rawData - 原始数据。 + * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) + * @param scale - 为所有的骨架指定一个缩放值。 (默认: 1.0) + * @returns DragonBonesData 实例 + * @see #getDragonBonesData() + * @see #addDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 4.5 + * @language zh_CN + */ + parseDragonBonesData(rawData: any, name?: string | null, scale?: number): DragonBonesData | null; + /** + * - Parse the raw texture atlas data and the texture atlas object to a TextureAtlasData instance and cache it to the factory. + * @param rawData - The raw texture atlas data. + * @param textureAtlas - The texture atlas object. + * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (If not set, use the instance name instead) + * @param scale - Specify a scaling value for the map set. (Default: 1.0) + * @returns TextureAtlasData instance + * @see #getTextureAtlasData() + * @see #addTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 将原始贴图集数据和贴图集对象解析为 TextureAtlasData 实例,并缓存到工厂中。 + * @param rawData - 原始贴图集数据。 + * @param textureAtlas - 贴图集对象。 + * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) + * @param scale - 为贴图集指定一个缩放值。 (默认: 1.0) + * @returns TextureAtlasData 实例 + * @see #getTextureAtlasData() + * @see #addTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 4.5 + * @language zh_CN + */ + parseTextureAtlasData(rawData: any, textureAtlas: any, name?: string | null, scale?: number): TextureAtlasData; + /** + * @private + */ + updateTextureAtlasData(name: string, textureAtlases: Array): void; + /** + * - Get a specific DragonBonesData instance. + * @param name - The DragonBonesData instance cache name. + * @returns DragonBonesData instance + * @see #parseDragonBonesData() + * @see #addDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的 DragonBonesData 实例。 + * @param name - DragonBonesData 实例的缓存名称。 + * @returns DragonBonesData 实例 + * @see #parseDragonBonesData() + * @see #addDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language zh_CN + */ + getDragonBonesData(name: string): DragonBonesData | null; + /** + * - Cache a DragonBonesData instance to the factory. + * @param data - The DragonBonesData instance. + * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (if not set, use the instance name instead) + * @see #parseDragonBonesData() + * @see #getDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 将 DragonBonesData 实例缓存到工厂中。 + * @param data - DragonBonesData 实例。 + * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) + * @see #parseDragonBonesData() + * @see #getDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language zh_CN + */ + addDragonBonesData(data: DragonBonesData, name?: string | null): void; + /** + * - Remove a DragonBonesData instance. + * @param name - The DragonBonesData instance cache name. + * @param disposeData - Whether to dispose data. (Default: true) + * @see #parseDragonBonesData() + * @see #getDragonBonesData() + * @see #addDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 移除 DragonBonesData 实例。 + * @param name - DragonBonesData 实例缓存名称。 + * @param disposeData - 是否释放数据。 (默认: true) + * @see #parseDragonBonesData() + * @see #getDragonBonesData() + * @see #addDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language zh_CN + */ + removeDragonBonesData(name: string, disposeData?: boolean): void; + /** + * - Get a list of specific TextureAtlasData instances. + * @param name - The TextureAtlasData cahce name. + * @see #parseTextureAtlasData() + * @see #addTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的 TextureAtlasData 实例列表。 + * @param name - TextureAtlasData 实例缓存名称。 + * @see #parseTextureAtlasData() + * @see #addTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language zh_CN + */ + getTextureAtlasData(name: string): Array | null; + /** + * - Cache a TextureAtlasData instance to the factory. + * @param data - The TextureAtlasData instance. + * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (if not set, use the instance name instead) + * @see #parseTextureAtlasData() + * @see #getTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 将 TextureAtlasData 实例缓存到工厂中。 + * @param data - TextureAtlasData 实例。 + * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) + * @see #parseTextureAtlasData() + * @see #getTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language zh_CN + */ + addTextureAtlasData(data: TextureAtlasData, name?: string | null): void; + /** + * - Remove a TextureAtlasData instance. + * @param name - The TextureAtlasData instance cache name. + * @param disposeData - Whether to dispose data. + * @see #parseTextureAtlasData() + * @see #getTextureAtlasData() + * @see #addTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 移除 TextureAtlasData 实例。 + * @param name - TextureAtlasData 实例的缓存名称。 + * @param disposeData - 是否释放数据。 + * @see #parseTextureAtlasData() + * @see #getTextureAtlasData() + * @see #addTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language zh_CN + */ + removeTextureAtlasData(name: string, disposeData?: boolean): void; + /** + * - Get a specific armature data. + * @param name - The armature data name. + * @param dragonBonesName - The cached name for DragonbonesData instance. + * @see dragonBones.ArmatureData + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 获取特定的骨架数据。 + * @param name - 骨架数据名称。 + * @param dragonBonesName - DragonBonesData 实例的缓存名称。 + * @see dragonBones.ArmatureData + * @version DragonBones 5.1 + * @language zh_CN + */ + getArmatureData(name: string, dragonBonesName?: string): ArmatureData | null; + /** + * - Clear all cached DragonBonesData instances and TextureAtlasData instances. + * @param disposeData - Whether to dispose data. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 清除缓存的所有 DragonBonesData 实例和 TextureAtlasData 实例。 + * @param disposeData - 是否释放数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + clear(disposeData?: boolean): void; + /** + * - Create a armature from cached DragonBonesData instances and TextureAtlasData instances. + * @param armatureName - The armature data name. + * @param dragonBonesName - The cached name of the DragonBonesData instance. (If not set, all DragonBonesData instances are retrieved, and when multiple DragonBonesData instances contain a the same name armature data, it may not be possible to accurately create a specific armature) + * @param skinName - The skin name, you can set a different ArmatureData name to share it's skin data. (If not set, use the default skin data) + * @returns The armature. + * @example + *
+         *     let armature = factory.buildArmature("armatureName", "dragonBonesName");
+         *     armature.clock = factory.clock;
+         * 
+ * @see dragonBones.DragonBonesData + * @see dragonBones.ArmatureData + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 通过缓存的 DragonBonesData 实例和 TextureAtlasData 实例创建一个骨架。 + * @param armatureName - 骨架数据名称。 + * @param dragonBonesName - DragonBonesData 实例的缓存名称。 (如果未设置,将检索所有的 DragonBonesData 实例,当多个 DragonBonesData 实例中包含同名的骨架数据时,可能无法准确的创建出特定的骨架) + * @param skinName - 皮肤名称,可以设置一个其他骨架数据名称来共享其皮肤数据(如果未设置,则使用默认的皮肤数据)。 + * @returns 骨架。 + * @example + *
+         *     let armature = factory.buildArmature("armatureName", "dragonBonesName");
+         *     armature.clock = factory.clock;
+         * 
+ * @see dragonBones.DragonBonesData + * @see dragonBones.ArmatureData + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + buildArmature(armatureName: string, dragonBonesName?: string, skinName?: string, textureAtlasName?: string): Armature | null; + /** + * @private + */ + replaceDisplay(slot: Slot, displayData: DisplayData, displayIndex?: number): void; + /** + * - Replaces the current display data for a particular slot with a specific display data. + * Specify display data with "dragonBonesName/armatureName/slotName/displayName". + * @param dragonBonesName - The DragonBonesData instance cache name. + * @param armatureName - The armature data name. + * @param slotName - The slot data name. + * @param displayName - The display data name. + * @param slot - The slot. + * @param displayIndex - The index of the display data that is replaced. (If it is not set, replaces the current display data) + * @example + *
+         *     let slot = armature.getSlot("weapon");
+         *     factory.replaceSlotDisplay("dragonBonesName", "armatureName", "slotName", "displayName", slot);
+         * 
+ * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 用特定的显示对象数据替换特定插槽当前的显示对象数据。 + * 用 "dragonBonesName/armatureName/slotName/displayName" 指定显示对象数据。 + * @param dragonBonesName - DragonBonesData 实例的缓存名称。 + * @param armatureName - 骨架数据名称。 + * @param slotName - 插槽数据名称。 + * @param displayName - 显示对象数据名称。 + * @param slot - 插槽。 + * @param displayIndex - 被替换的显示对象数据的索引。 (如果未设置,则替换当前的显示对象数据) + * @example + *
+         *     let slot = armature.getSlot("weapon");
+         *     factory.replaceSlotDisplay("dragonBonesName", "armatureName", "slotName", "displayName", slot);
+         * 
+ * @version DragonBones 4.5 + * @language zh_CN + */ + replaceSlotDisplay(dragonBonesName: string, armatureName: string, slotName: string, displayName: string, slot: Slot, displayIndex?: number): boolean; + /** + * @private + */ + replaceSlotDisplayList(dragonBonesName: string | null, armatureName: string, slotName: string, slot: Slot): boolean; + /** + * - Share specific skin data with specific armature. + * @param armature - The armature. + * @param skin - The skin data. + * @param isOverride - Whether it completely override the original skin. (Default: false) + * @param exclude - A list of slot names that do not need to be replace. + * @example + *
+         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
+         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
+         *     if (armatureDataB && armatureDataB.defaultSkin) {
+         *     factory.replaceSkin(armatureA, armatureDataB.defaultSkin, false, ["arm_l", "weapon_l"]);
+         *     }
+         * 
+ * @see dragonBones.Armature + * @see dragonBones.SkinData + * @version DragonBones 5.6 + * @language en_US + */ + /** + * - 将特定的皮肤数据共享给特定的骨架使用。 + * @param armature - 骨架。 + * @param skin - 皮肤数据。 + * @param isOverride - 是否完全覆盖原来的皮肤。 (默认: false) + * @param exclude - 不需要被替换的插槽名称列表。 + * @example + *
+         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
+         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
+         *     if (armatureDataB && armatureDataB.defaultSkin) {
+         *     factory.replaceSkin(armatureA, armatureDataB.defaultSkin, false, ["arm_l", "weapon_l"]);
+         *     }
+         * 
+ * @see dragonBones.Armature + * @see dragonBones.SkinData + * @version DragonBones 5.6 + * @language zh_CN + */ + replaceSkin(armature: Armature, skin: SkinData, isOverride?: boolean, exclude?: Array | null): boolean; + /** + * - Replaces the existing animation data for a specific armature with the animation data for the specific armature data. + * This enables you to make a armature template so that other armature without animations can share it's animations. + * @param armature - The armtaure. + * @param armatureData - The armature data. + * @param isOverride - Whether to completely overwrite the original animation. (Default: false) + * @example + *
+         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
+         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
+         *     if (armatureDataB) {
+         *     factory.replaceAnimation(armatureA, armatureDataB);
+         *     }
+         * 
+ * @see dragonBones.Armature + * @see dragonBones.ArmatureData + * @version DragonBones 5.6 + * @language en_US + */ + /** + * - 用特定骨架数据的动画数据替换特定骨架现有的动画数据。 + * 这样就能实现制作一个骨架动画模板,让其他没有制作动画的骨架共享该动画。 + * @param armature - 骨架。 + * @param armatureData - 骨架数据。 + * @param isOverride - 是否完全覆盖原来的动画。(默认: false)。 + * @example + *
+         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
+         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
+         *     if (armatureDataB) {
+         *     factory.replaceAnimation(armatureA, armatureDataB);
+         *     }
+         * 
+ * @see dragonBones.Armature + * @see dragonBones.ArmatureData + * @version DragonBones 5.6 + * @language zh_CN + */ + replaceAnimation(armature: Armature, armatureData: ArmatureData, isOverride?: boolean): boolean; + /** + * @private + */ + getAllDragonBonesData(): Map; + /** + * @private + */ + getAllTextureAtlasData(): Map>; + /** + * - An Worldclock instance updated by engine. + * @version DragonBones 5.7 + * @language en_US + */ + /** + * - 由引擎驱动的 WorldClock 实例。 + * @version DragonBones 5.7 + * @language zh_CN + */ + readonly clock: WorldClock; + /** + * @private + */ + readonly dragonBones: DragonBones; + /** + * - Deprecated, please refer to {@link #replaceSkin}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #replaceSkin}。 + * @deprecated + * @language zh_CN + */ + changeSkin(armature: Armature, skin: SkinData, exclude?: Array | null): boolean; + /** + * - Deprecated, please refer to {@link #replaceAnimation}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #replaceAnimation}。 + * @deprecated + * @language zh_CN + */ + copyAnimationsToArmature(toArmature: Armature, fromArmatreName: string, fromSkinName?: string, fromDragonBonesDataName?: string, replaceOriginalAnimation?: boolean): boolean; + } + /** + * @internal + * @private + */ + class BuildArmaturePackage { + dataName: string; + textureAtlasName: string; + data: DragonBonesData; + armature: ArmatureData; + skin: SkinData | null; + } +} + +declare namespace sp.spine { + class Animation { + name: string; + timelines: Array; + timelineIds: Array; + duration: number; + constructor(name: string, timelines: Array, duration: number); + hasTimeline(id: number): boolean; + apply(skeleton: Skeleton, lastTime: number, time: number, loop: boolean, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + static binarySearch(values: ArrayLike, target: number, step?: number): number; + static linearSearch(values: ArrayLike, target: number, step: number): number; + } + interface Timeline { + apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + getPropertyId(): number; + } + enum MixBlend { + setup = 0, + first = 1, + replace = 2, + add = 3 + } + enum MixDirection { + mixIn = 0, + mixOut = 1 + } + enum TimelineType { + rotate = 0, + translate = 1, + scale = 2, + shear = 3, + attachment = 4, + color = 5, + deform = 6, + event = 7, + drawOrder = 8, + ikConstraint = 9, + transformConstraint = 10, + pathConstraintPosition = 11, + pathConstraintSpacing = 12, + pathConstraintMix = 13, + twoColor = 14 + } + abstract class CurveTimeline implements Timeline { + static LINEAR: number; + static STEPPED: number; + static BEZIER: number; + static BEZIER_SIZE: number; + private curves; + abstract getPropertyId(): number; + constructor(frameCount: number); + getFrameCount(): number; + setLinear(frameIndex: number): void; + setStepped(frameIndex: number): void; + getCurveType(frameIndex: number): number; + setCurve(frameIndex: number, cx1: number, cy1: number, cx2: number, cy2: number): void; + getCurvePercent(frameIndex: number, percent: number): number; + abstract apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class RotateTimeline extends CurveTimeline { + static ENTRIES: number; + static PREV_TIME: number; + static PREV_ROTATION: number; + static ROTATION: number; + boneIndex: number; + frames: ArrayLike; + constructor(frameCount: number); + getPropertyId(): number; + setFrame(frameIndex: number, time: number, degrees: number): void; + apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class TranslateTimeline extends CurveTimeline { + static ENTRIES: number; + static PREV_TIME: number; + static PREV_X: number; + static PREV_Y: number; + static X: number; + static Y: number; + boneIndex: number; + frames: ArrayLike; + constructor(frameCount: number); + getPropertyId(): number; + setFrame(frameIndex: number, time: number, x: number, y: number): void; + apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class ScaleTimeline extends TranslateTimeline { + constructor(frameCount: number); + getPropertyId(): number; + apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class ShearTimeline extends TranslateTimeline { + constructor(frameCount: number); + getPropertyId(): number; + apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class ColorTimeline extends CurveTimeline { + static ENTRIES: number; + static PREV_TIME: number; + static PREV_R: number; + static PREV_G: number; + static PREV_B: number; + static PREV_A: number; + static R: number; + static G: number; + static B: number; + static A: number; + slotIndex: number; + frames: ArrayLike; + constructor(frameCount: number); + getPropertyId(): number; + setFrame(frameIndex: number, time: number, r: number, g: number, b: number, a: number): void; + apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class TwoColorTimeline extends CurveTimeline { + static ENTRIES: number; + static PREV_TIME: number; + static PREV_R: number; + static PREV_G: number; + static PREV_B: number; + static PREV_A: number; + static PREV_R2: number; + static PREV_G2: number; + static PREV_B2: number; + static R: number; + static G: number; + static B: number; + static A: number; + static R2: number; + static G2: number; + static B2: number; + slotIndex: number; + frames: ArrayLike; + constructor(frameCount: number); + getPropertyId(): number; + setFrame(frameIndex: number, time: number, r: number, g: number, b: number, a: number, r2: number, g2: number, b2: number): void; + apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class AttachmentTimeline implements Timeline { + slotIndex: number; + frames: ArrayLike; + attachmentNames: Array; + constructor(frameCount: number); + getPropertyId(): number; + getFrameCount(): number; + setFrame(frameIndex: number, time: number, attachmentName: string): void; + apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class DeformTimeline extends CurveTimeline { + slotIndex: number; + attachment: VertexAttachment; + frames: ArrayLike; + frameVertices: Array>; + constructor(frameCount: number); + getPropertyId(): number; + setFrame(frameIndex: number, time: number, vertices: ArrayLike): void; + apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class EventTimeline implements Timeline { + frames: ArrayLike; + events: Array; + constructor(frameCount: number); + getPropertyId(): number; + getFrameCount(): number; + setFrame(frameIndex: number, event: Event): void; + apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class DrawOrderTimeline implements Timeline { + frames: ArrayLike; + drawOrders: Array>; + constructor(frameCount: number); + getPropertyId(): number; + getFrameCount(): number; + setFrame(frameIndex: number, time: number, drawOrder: Array): void; + apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class IkConstraintTimeline extends CurveTimeline { + static ENTRIES: number; + static PREV_TIME: number; + static PREV_MIX: number; + static PREV_SOFTNESS: number; + static PREV_BEND_DIRECTION: number; + static PREV_COMPRESS: number; + static PREV_STRETCH: number; + static MIX: number; + static SOFTNESS: number; + static BEND_DIRECTION: number; + static COMPRESS: number; + static STRETCH: number; + ikConstraintIndex: number; + frames: ArrayLike; + constructor(frameCount: number); + getPropertyId(): number; + setFrame(frameIndex: number, time: number, mix: number, softness: number, bendDirection: number, compress: boolean, stretch: boolean): void; + apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class TransformConstraintTimeline extends CurveTimeline { + static ENTRIES: number; + static PREV_TIME: number; + static PREV_ROTATE: number; + static PREV_TRANSLATE: number; + static PREV_SCALE: number; + static PREV_SHEAR: number; + static ROTATE: number; + static TRANSLATE: number; + static SCALE: number; + static SHEAR: number; + transformConstraintIndex: number; + frames: ArrayLike; + constructor(frameCount: number); + getPropertyId(): number; + setFrame(frameIndex: number, time: number, rotateMix: number, translateMix: number, scaleMix: number, shearMix: number): void; + apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class PathConstraintPositionTimeline extends CurveTimeline { + static ENTRIES: number; + static PREV_TIME: number; + static PREV_VALUE: number; + static VALUE: number; + pathConstraintIndex: number; + frames: ArrayLike; + constructor(frameCount: number); + getPropertyId(): number; + setFrame(frameIndex: number, time: number, value: number): void; + apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class PathConstraintSpacingTimeline extends PathConstraintPositionTimeline { + constructor(frameCount: number); + getPropertyId(): number; + apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } + class PathConstraintMixTimeline extends CurveTimeline { + static ENTRIES: number; + static PREV_TIME: number; + static PREV_ROTATE: number; + static PREV_TRANSLATE: number; + static ROTATE: number; + static TRANSLATE: number; + pathConstraintIndex: number; + frames: ArrayLike; + constructor(frameCount: number); + getPropertyId(): number; + setFrame(frameIndex: number, time: number, rotateMix: number, translateMix: number): void; + apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + } +} +declare namespace sp.spine { + class AnimationState { + static emptyAnimation: Animation; + static SUBSEQUENT: number; + static FIRST: number; + static HOLD: number; + static HOLD_MIX: number; + static NOT_LAST: number; + data: AnimationStateData; + tracks: TrackEntry[]; + timeScale: number; + events: Event[]; + listeners: AnimationStateListener[]; + queue: EventQueue; + propertyIDs: IntSet; + animationsChanged: boolean; + trackEntryPool: Pool; + constructor(data: AnimationStateData); + update(delta: number): void; + updateMixingFrom(to: TrackEntry, delta: number): boolean; + apply(skeleton: Skeleton): boolean; + applyMixingFrom(to: TrackEntry, skeleton: Skeleton, blend: MixBlend): number; + applyRotateTimeline(timeline: Timeline, skeleton: Skeleton, time: number, alpha: number, blend: MixBlend, timelinesRotation: Array, i: number, firstFrame: boolean): void; + queueEvents(entry: TrackEntry, animationTime: number): void; + clearTracks(): void; + clearTrack(trackIndex: number): void; + setCurrent(index: number, current: TrackEntry, interrupt: boolean): void; + setAnimation(trackIndex: number, animationName: string, loop: boolean): TrackEntry; + setAnimationWith(trackIndex: number, animation: Animation, loop: boolean): TrackEntry; + addAnimation(trackIndex: number, animationName: string, loop: boolean, delay: number): TrackEntry; + addAnimationWith(trackIndex: number, animation: Animation, loop: boolean, delay: number): TrackEntry; + setEmptyAnimation(trackIndex: number, mixDuration: number): TrackEntry; + addEmptyAnimation(trackIndex: number, mixDuration: number, delay: number): TrackEntry; + setEmptyAnimations(mixDuration: number): void; + expandToIndex(index: number): TrackEntry; + trackEntry(trackIndex: number, animation: Animation, loop: boolean, last: TrackEntry): TrackEntry; + disposeNext(entry: TrackEntry): void; + _animationsChanged(): void; + computeHold(entry: TrackEntry): void; + computeNotLast(entry: TrackEntry): void; + getCurrent(trackIndex: number): TrackEntry; + addListener(listener: AnimationStateListener): void; + removeListener(listener: AnimationStateListener): void; + clearListeners(): void; + clearListenerNotifications(): void; + } + class TrackEntry { + animation: Animation; + next: TrackEntry; + mixingFrom: TrackEntry; + mixingTo: TrackEntry; + listener: AnimationStateListener; + trackIndex: number; + loop: boolean; + holdPrevious: boolean; + eventThreshold: number; + attachmentThreshold: number; + drawOrderThreshold: number; + animationStart: number; + animationEnd: number; + animationLast: number; + nextAnimationLast: number; + delay: number; + trackTime: number; + trackLast: number; + nextTrackLast: number; + trackEnd: number; + timeScale: number; + alpha: number; + mixTime: number; + mixDuration: number; + interruptAlpha: number; + totalAlpha: number; + mixBlend: MixBlend; + timelineMode: number[]; + timelineHoldMix: TrackEntry[]; + timelinesRotation: number[]; + reset(): void; + getAnimationTime(): number; + setAnimationLast(animationLast: number): void; + isComplete(): boolean; + resetRotationDirections(): void; + } + class EventQueue { + objects: Array; + drainDisabled: boolean; + animState: AnimationState; + constructor(animState: AnimationState); + start(entry: TrackEntry): void; + interrupt(entry: TrackEntry): void; + end(entry: TrackEntry): void; + dispose(entry: TrackEntry): void; + complete(entry: TrackEntry): void; + event(entry: TrackEntry, event: Event): void; + drain(): void; + clear(): void; + } + enum EventType { + start = 0, + interrupt = 1, + end = 2, + dispose = 3, + complete = 4, + event = 5 + } + interface AnimationStateListener { + start(entry: TrackEntry): void; + interrupt(entry: TrackEntry): void; + end(entry: TrackEntry): void; + dispose(entry: TrackEntry): void; + complete(entry: TrackEntry): void; + event(entry: TrackEntry, event: Event): void; + } + abstract class AnimationStateAdapter implements AnimationStateListener { + start(entry: TrackEntry): void; + interrupt(entry: TrackEntry): void; + end(entry: TrackEntry): void; + dispose(entry: TrackEntry): void; + complete(entry: TrackEntry): void; + event(entry: TrackEntry, event: Event): void; + } +} +declare namespace sp.spine { + class AnimationStateData { + skeletonData: SkeletonData; + animationToMixTime: Map; + defaultMix: number; + constructor(skeletonData: SkeletonData); + setMix(fromName: string, toName: string, duration: number): void; + setMixWith(from: Animation, to: Animation, duration: number): void; + getMix(from: Animation, to: Animation): number; + } +} +declare namespace sp.spine { + class AssetManager implements Disposable { + private pathPrefix; + private textureLoader; + private assets; + private errors; + private toLoad; + private loaded; + constructor(textureLoader: (image: HTMLImageElement) => any, pathPrefix?: string); + private static downloadText; + private static downloadBinary; + loadBinary(path: string, success?: (path: string, binary: Uint8Array) => void, error?: (path: string, error: string) => void): void; + loadText(path: string, success?: (path: string, text: string) => void, error?: (path: string, error: string) => void): void; + loadTexture(path: string, success?: (path: string, image: HTMLImageElement) => void, error?: (path: string, error: string) => void): void; + loadTextureData(path: string, data: string, success?: (path: string, image: HTMLImageElement) => void, error?: (path: string, error: string) => void): void; + loadTextureAtlas(path: string, success?: (path: string, atlas: TextureAtlas) => void, error?: (path: string, error: string) => void): void; + get(path: string): any; + remove(path: string): void; + removeAll(): void; + isLoadingComplete(): boolean; + getToLoad(): number; + getLoaded(): number; + dispose(): void; + hasErrors(): boolean; + getErrors(): Map; + } +} +declare namespace sp.spine { + class AtlasAttachmentLoader implements AttachmentLoader { + atlas: TextureAtlas; + constructor(atlas: TextureAtlas); + newRegionAttachment(skin: Skin, name: string, path: string): RegionAttachment; + newMeshAttachment(skin: Skin, name: string, path: string): MeshAttachment; + newBoundingBoxAttachment(skin: Skin, name: string): BoundingBoxAttachment; + newPathAttachment(skin: Skin, name: string): PathAttachment; + newPointAttachment(skin: Skin, name: string): PointAttachment; + newClippingAttachment(skin: Skin, name: string): ClippingAttachment; + } +} +declare namespace sp.spine { + enum BlendMode { + Normal = 0, + Additive = 1, + Multiply = 2, + Screen = 3 + } +} +declare namespace sp.spine { + class Bone implements Updatable { + data: BoneData; + skeleton: Skeleton; + parent: Bone; + children: Bone[]; + x: number; + y: number; + rotation: number; + scaleX: number; + scaleY: number; + shearX: number; + shearY: number; + ax: number; + ay: number; + arotation: number; + ascaleX: number; + ascaleY: number; + ashearX: number; + ashearY: number; + appliedValid: boolean; + a: number; + b: number; + c: number; + d: number; + worldY: number; + worldX: number; + sorted: boolean; + active: boolean; + constructor(data: BoneData, skeleton: Skeleton, parent: Bone); + isActive(): boolean; + update(): void; + updateWorldTransform(): void; + updateWorldTransformWith(x: number, y: number, rotation: number, scaleX: number, scaleY: number, shearX: number, shearY: number): void; + setToSetupPose(): void; + getWorldRotationX(): number; + getWorldRotationY(): number; + getWorldScaleX(): number; + getWorldScaleY(): number; + updateAppliedTransform(): void; + worldToLocal(world: Vector2): Vector2; + localToWorld(local: Vector2): Vector2; + worldToLocalRotation(worldRotation: number): number; + localToWorldRotation(localRotation: number): number; + rotateWorld(degrees: number): void; + } +} +declare namespace sp.spine { + class BoneData { + index: number; + name: string; + parent: BoneData; + length: number; + x: number; + y: number; + rotation: number; + scaleX: number; + scaleY: number; + shearX: number; + shearY: number; + transformMode: TransformMode; + skinRequired: boolean; + color: Color; + constructor(index: number, name: string, parent: BoneData); + } + enum TransformMode { + Normal = 0, + OnlyTranslation = 1, + NoRotationOrReflection = 2, + NoScale = 3, + NoScaleOrReflection = 4 + } +} +declare namespace sp.spine { + abstract class ConstraintData { + name: string; + order: number; + skinRequired: boolean; + constructor(name: string, order: number, skinRequired: boolean); + } +} +declare namespace sp.spine { + class Event { + data: EventData; + intValue: number; + floatValue: number; + stringValue: string; + time: number; + volume: number; + balance: number; + constructor(time: number, data: EventData); + } +} +declare namespace sp.spine { + class EventData { + name: string; + intValue: number; + floatValue: number; + stringValue: string; + audioPath: string; + volume: number; + balance: number; + constructor(name: string); + } +} +declare namespace sp.spine { + class IkConstraint implements Updatable { + data: IkConstraintData; + bones: Array; + target: Bone; + bendDirection: number; + compress: boolean; + stretch: boolean; + mix: number; + softness: number; + active: boolean; + constructor(data: IkConstraintData, skeleton: Skeleton); + isActive(): boolean; + apply(): void; + update(): void; + apply1(bone: Bone, targetX: number, targetY: number, compress: boolean, stretch: boolean, uniform: boolean, alpha: number): void; + apply2(parent: Bone, child: Bone, targetX: number, targetY: number, bendDir: number, stretch: boolean, softness: number, alpha: number): void; + } +} +declare namespace sp.spine { + class IkConstraintData extends ConstraintData { + bones: BoneData[]; + target: BoneData; + bendDirection: number; + compress: boolean; + stretch: boolean; + uniform: boolean; + mix: number; + softness: number; + constructor(name: string); + } +} +declare namespace sp.spine { + class PathConstraint implements Updatable { + static NONE: number; + static BEFORE: number; + static AFTER: number; + static epsilon: number; + data: PathConstraintData; + bones: Array; + target: Slot; + position: number; + spacing: number; + rotateMix: number; + translateMix: number; + spaces: number[]; + positions: number[]; + world: number[]; + curves: number[]; + lengths: number[]; + segments: number[]; + active: boolean; + constructor(data: PathConstraintData, skeleton: Skeleton); + isActive(): boolean; + apply(): void; + update(): void; + computeWorldPositions(path: PathAttachment, spacesCount: number, tangents: boolean, percentPosition: boolean, percentSpacing: boolean): number[]; + addBeforePosition(p: number, temp: Array, i: number, out: Array, o: number): void; + addAfterPosition(p: number, temp: Array, i: number, out: Array, o: number): void; + addCurvePosition(p: number, x1: number, y1: number, cx1: number, cy1: number, cx2: number, cy2: number, x2: number, y2: number, out: Array, o: number, tangents: boolean): void; + } +} +declare namespace sp.spine { + class PathConstraintData extends ConstraintData { + bones: BoneData[]; + target: SlotData; + positionMode: PositionMode; + spacingMode: SpacingMode; + rotateMode: RotateMode; + offsetRotation: number; + position: number; + spacing: number; + rotateMix: number; + translateMix: number; + constructor(name: string); + } + enum PositionMode { + Fixed = 0, + Percent = 1 + } + enum SpacingMode { + Length = 0, + Fixed = 1, + Percent = 2 + } + enum RotateMode { + Tangent = 0, + Chain = 1, + ChainScale = 2 + } +} +declare namespace sp.spine { + class SharedAssetManager implements Disposable { + private pathPrefix; + private clientAssets; + private queuedAssets; + private rawAssets; + private errors; + constructor(pathPrefix?: string); + private queueAsset; + loadText(clientId: string, path: string): void; + loadJson(clientId: string, path: string): void; + loadTexture(clientId: string, textureLoader: (image: HTMLImageElement) => any, path: string): void; + get(clientId: string, path: string): any; + private updateClientAssets; + isLoadingComplete(clientId: string): boolean; + dispose(): void; + hasErrors(): boolean; + getErrors(): Map; + } +} +declare namespace sp.spine { + class Skeleton { + data: SkeletonData; + bones: Array; + slots: Array; + drawOrder: Array; + ikConstraints: Array; + transformConstraints: Array; + pathConstraints: Array; + _updateCache: Updatable[]; + updateCacheReset: Updatable[]; + skin: Skin; + color: Color; + time: number; + scaleX: number; + scaleY: number; + x: number; + y: number; + constructor(data: SkeletonData); + updateCache(): void; + sortIkConstraint(constraint: IkConstraint): void; + sortPathConstraint(constraint: PathConstraint): void; + sortTransformConstraint(constraint: TransformConstraint): void; + sortPathConstraintAttachment(skin: Skin, slotIndex: number, slotBone: Bone): void; + sortPathConstraintAttachmentWith(attachment: Attachment, slotBone: Bone): void; + sortBone(bone: Bone): void; + sortReset(bones: Array): void; + updateWorldTransform(): void; + setToSetupPose(): void; + setBonesToSetupPose(): void; + setSlotsToSetupPose(): void; + getRootBone(): Bone; + findBone(boneName: string): Bone; + findBoneIndex(boneName: string): number; + findSlot(slotName: string): Slot; + findSlotIndex(slotName: string): number; + setSkinByName(skinName: string): void; + setSkin(newSkin: Skin): void; + getAttachmentByName(slotName: string, attachmentName: string): Attachment; + getAttachment(slotIndex: number, attachmentName: string): Attachment; + setAttachment(slotName: string, attachmentName: string): void; + findIkConstraint(constraintName: string): IkConstraint; + findTransformConstraint(constraintName: string): TransformConstraint; + findPathConstraint(constraintName: string): PathConstraint; + getBounds(offset: Vector2, size: Vector2, temp?: Array): void; + update(delta: number): void; + } +} +declare namespace sp.spine { + class SkeletonBinary { + static AttachmentTypeValues: number[]; + static TransformModeValues: TransformMode[]; + static PositionModeValues: PositionMode[]; + static SpacingModeValues: SpacingMode[]; + static RotateModeValues: RotateMode[]; + static BlendModeValues: BlendMode[]; + static BONE_ROTATE: number; + static BONE_TRANSLATE: number; + static BONE_SCALE: number; + static BONE_SHEAR: number; + static SLOT_ATTACHMENT: number; + static SLOT_COLOR: number; + static SLOT_TWO_COLOR: number; + static PATH_POSITION: number; + static PATH_SPACING: number; + static PATH_MIX: number; + static CURVE_LINEAR: number; + static CURVE_STEPPED: number; + static CURVE_BEZIER: number; + scale: number; + attachmentLoader: AttachmentLoader; + private linkedMeshes; + constructor(attachmentLoader: AttachmentLoader); + readSkeletonData(binary: Uint8Array): SkeletonData; + private readSkin; + private readAttachment; + private readVertices; + private readFloatArray; + private readShortArray; + private readAnimation; + private readCurve; + setCurve(timeline: CurveTimeline, frameIndex: number, cx1: number, cy1: number, cx2: number, cy2: number): void; + } +} +declare namespace sp.spine { + class SkeletonBounds { + minX: number; + minY: number; + maxX: number; + maxY: number; + boundingBoxes: BoundingBoxAttachment[]; + polygons: ArrayLike[]; + private polygonPool; + update(skeleton: Skeleton, updateAabb: boolean): void; + aabbCompute(): void; + aabbContainsPoint(x: number, y: number): boolean; + aabbIntersectsSegment(x1: number, y1: number, x2: number, y2: number): boolean; + aabbIntersectsSkeleton(bounds: SkeletonBounds): boolean; + containsPoint(x: number, y: number): BoundingBoxAttachment; + containsPointPolygon(polygon: ArrayLike, x: number, y: number): boolean; + intersectsSegment(x1: number, y1: number, x2: number, y2: number): BoundingBoxAttachment; + intersectsSegmentPolygon(polygon: ArrayLike, x1: number, y1: number, x2: number, y2: number): boolean; + getPolygon(boundingBox: BoundingBoxAttachment): ArrayLike; + getWidth(): number; + getHeight(): number; + } +} +declare namespace sp.spine { + class SkeletonClipping { + private triangulator; + private clippingPolygon; + private clipOutput; + clippedVertices: number[]; + clippedTriangles: number[]; + private scratch; + private clipAttachment; + private clippingPolygons; + clipStart(slot: Slot, clip: ClippingAttachment): number; + clipEndWithSlot(slot: Slot): void; + clipEnd(): void; + isClipping(): boolean; + clipTriangles(vertices: ArrayLike, verticesLength: number, triangles: ArrayLike, trianglesLength: number, uvs: ArrayLike, light: Color, dark: Color, twoColor: boolean): void; + clip(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, clippingArea: Array, output: Array): boolean; + static makeClockwise(polygon: ArrayLike): void; + } +} +declare namespace sp.spine { + class SkeletonData { + name: string; + bones: BoneData[]; + slots: SlotData[]; + skins: Skin[]; + defaultSkin: Skin; + events: EventData[]; + animations: Animation[]; + ikConstraints: IkConstraintData[]; + transformConstraints: TransformConstraintData[]; + pathConstraints: PathConstraintData[]; + x: number; + y: number; + width: number; + height: number; + version: string; + hash: string; + fps: number; + imagesPath: string; + audioPath: string; + findBone(boneName: string): BoneData; + findBoneIndex(boneName: string): number; + findSlot(slotName: string): SlotData; + findSlotIndex(slotName: string): number; + findSkin(skinName: string): Skin; + findEvent(eventDataName: string): EventData; + findAnimation(animationName: string): Animation; + findIkConstraint(constraintName: string): IkConstraintData; + findTransformConstraint(constraintName: string): TransformConstraintData; + findPathConstraint(constraintName: string): PathConstraintData; + findPathConstraintIndex(pathConstraintName: string): number; + } +} +declare namespace sp.spine { + class SkeletonJson { + attachmentLoader: AttachmentLoader; + scale: number; + private linkedMeshes; + constructor(attachmentLoader: AttachmentLoader); + readSkeletonData(json: string | any): SkeletonData; + readAttachment(map: any, skin: Skin, slotIndex: number, name: string, skeletonData: SkeletonData): Attachment; + readVertices(map: any, attachment: VertexAttachment, verticesLength: number): void; + readAnimation(map: any, name: string, skeletonData: SkeletonData): void; + readCurve(map: any, timeline: CurveTimeline, frameIndex: number): void; + getValue(map: any, prop: string, defaultValue: any): any; + static blendModeFromString(str: string): BlendMode; + static positionModeFromString(str: string): PositionMode; + static spacingModeFromString(str: string): SpacingMode; + static rotateModeFromString(str: string): RotateMode; + static transformModeFromString(str: string): TransformMode; + } +} +declare namespace sp.spine { + class SkinEntry { + slotIndex: number; + name: string; + attachment: Attachment; + constructor(slotIndex: number, name: string, attachment: Attachment); + } + class Skin { + name: string; + attachments: Map[]; + bones: BoneData[]; + constraints: ConstraintData[]; + constructor(name: string); + setAttachment(slotIndex: number, name: string, attachment: Attachment): void; + addSkin(skin: Skin): void; + copySkin(skin: Skin): void; + getAttachment(slotIndex: number, name: string): Attachment; + removeAttachment(slotIndex: number, name: string): void; + getAttachments(): Array; + getAttachmentsForSlot(slotIndex: number, attachments: Array): void; + clear(): void; + attachAll(skeleton: Skeleton, oldSkin: Skin): void; + } +} +declare namespace sp.spine { + class Slot { + data: SlotData; + bone: Bone; + color: Color; + darkColor: Color; + private attachment; + private attachmentTime; + deform: number[]; + constructor(data: SlotData, bone: Bone); + getSkeleton(): Skeleton; + getAttachment(): Attachment; + setAttachment(attachment: Attachment): void; + setAttachmentTime(time: number): void; + getAttachmentTime(): number; + setToSetupPose(): void; + } +} +declare namespace sp.spine { + class SlotData { + index: number; + name: string; + boneData: BoneData; + color: Color; + darkColor: Color; + attachmentName: string; + blendMode: BlendMode; + constructor(index: number, name: string, boneData: BoneData); + } +} +declare namespace sp.spine { + abstract class Texture { + protected _image: HTMLImageElement; + constructor(image: HTMLImageElement); + getImage(): HTMLImageElement; + abstract setFilters(minFilter: TextureFilter, magFilter: TextureFilter): void; + abstract setWraps(uWrap: TextureWrap, vWrap: TextureWrap): void; + abstract dispose(): void; + static filterFromString(text: string): TextureFilter; + static wrapFromString(text: string): TextureWrap; + } + enum TextureFilter { + Nearest = 9728, + Linear = 9729, + MipMap = 9987, + MipMapNearestNearest = 9984, + MipMapLinearNearest = 9985, + MipMapNearestLinear = 9986, + MipMapLinearLinear = 9987 + } + enum TextureWrap { + MirroredRepeat = 33648, + ClampToEdge = 33071, + Repeat = 10497 + } + class TextureRegion { + renderObject: any; + u: number; + v: number; + u2: number; + v2: number; + width: number; + height: number; + rotate: boolean; + offsetX: number; + offsetY: number; + originalWidth: number; + originalHeight: number; + } + class FakeTexture extends Texture { + setFilters(minFilter: TextureFilter, magFilter: TextureFilter): void; + setWraps(uWrap: TextureWrap, vWrap: TextureWrap): void; + dispose(): void; + } +} +declare namespace sp.spine { + class TextureAtlas implements Disposable { + pages: TextureAtlasPage[]; + regions: TextureAtlasRegion[]; + constructor(atlasText: string, textureLoader: (path: string) => any); + private load; + findRegion(name: string): TextureAtlasRegion; + dispose(): void; + } + class TextureAtlasPage { + name: string; + minFilter: TextureFilter; + magFilter: TextureFilter; + uWrap: TextureWrap; + vWrap: TextureWrap; + texture: Texture; + width: number; + height: number; + } + class TextureAtlasRegion extends TextureRegion { + page: TextureAtlasPage; + name: string; + x: number; + y: number; + index: number; + rotate: boolean; + degrees: number; + texture: Texture; + } +} +declare namespace sp.spine { + class TransformConstraint implements Updatable { + data: TransformConstraintData; + bones: Array; + target: Bone; + rotateMix: number; + translateMix: number; + scaleMix: number; + shearMix: number; + temp: Vector2; + active: boolean; + constructor(data: TransformConstraintData, skeleton: Skeleton); + isActive(): boolean; + apply(): void; + update(): void; + applyAbsoluteWorld(): void; + applyRelativeWorld(): void; + applyAbsoluteLocal(): void; + applyRelativeLocal(): void; + } +} +declare namespace sp.spine { + class TransformConstraintData extends ConstraintData { + bones: BoneData[]; + target: BoneData; + rotateMix: number; + translateMix: number; + scaleMix: number; + shearMix: number; + offsetRotation: number; + offsetX: number; + offsetY: number; + offsetScaleX: number; + offsetScaleY: number; + offsetShearY: number; + relative: boolean; + local: boolean; + constructor(name: string); + } +} +declare namespace sp.spine { + class Triangulator { + private convexPolygons; + private convexPolygonsIndices; + private indicesArray; + private isConcaveArray; + private triangles; + private polygonPool; + private polygonIndicesPool; + triangulate(verticesArray: ArrayLike): Array; + decompose(verticesArray: Array, triangles: Array): Array>; + private static isConcave; + private static positiveArea; + private static winding; + } +} +declare namespace sp.spine { + interface Updatable { + update(): void; + isActive(): boolean; + } +} +declare namespace sp.spine { + interface Map { + [key: string]: T; + } + class IntSet { + array: number[]; + add(value: number): boolean; + contains(value: number): boolean; + remove(value: number): void; + clear(): void; + } + interface Disposable { + dispose(): void; + } + interface Restorable { + restore(): void; + } + class Color { + r: number; + g: number; + b: number; + a: number; + static WHITE: Color; + static RED: Color; + static GREEN: Color; + static BLUE: Color; + static MAGENTA: Color; + constructor(r?: number, g?: number, b?: number, a?: number); + set(r: number, g: number, b: number, a: number): this; + setFromColor(c: Color): this; + setFromString(hex: string): this; + add(r: number, g: number, b: number, a: number): this; + clamp(): this; + static rgba8888ToColor(color: Color, value: number): void; + static rgb888ToColor(color: Color, value: number): void; + } + class MathUtils { + static PI: number; + static PI2: number; + static radiansToDegrees: number; + static radDeg: number; + static degreesToRadians: number; + static degRad: number; + static clamp(value: number, min: number, max: number): number; + static cosDeg(degrees: number): number; + static sinDeg(degrees: number): number; + static signum(value: number): number; + static toInt(x: number): number; + static cbrt(x: number): number; + static randomTriangular(min: number, max: number): number; + static randomTriangularWith(min: number, max: number, mode: number): number; + } + abstract class Interpolation { + protected abstract applyInternal(a: number): number; + apply(start: number, end: number, a: number): number; + } + class Pow extends Interpolation { + protected power: number; + constructor(power: number); + applyInternal(a: number): number; + } + class PowOut extends Pow { + constructor(power: number); + applyInternal(a: number): number; + } + class Utils { + static SUPPORTS_TYPED_ARRAYS: boolean; + static arrayCopy(source: ArrayLike, sourceStart: number, dest: ArrayLike, destStart: number, numElements: number): void; + static setArraySize(array: Array, size: number, value?: any): Array; + static ensureArrayCapacity(array: Array, size: number, value?: any): Array; + static newArray(size: number, defaultValue: T): Array; + static newFloatArray(size: number): ArrayLike; + static newShortArray(size: number): ArrayLike; + static toFloatArray(array: Array): number[] | Float32Array; + static toSinglePrecision(value: number): number; + static webkit602BugfixHelper(alpha: number, blend: MixBlend): void; + static contains(array: Array, element: T, identity?: boolean): boolean; + } + class DebugUtils { + static logBones(skeleton: Skeleton): void; + } + class Pool { + private items; + private instantiator; + constructor(instantiator: () => T); + obtain(): T; + free(item: T): void; + freeAll(items: ArrayLike): void; + clear(): void; + } + class Vector2 { + x: number; + y: number; + constructor(x?: number, y?: number); + set(x: number, y: number): Vector2; + length(): number; + normalize(): this; + } + class TimeKeeper { + maxDelta: number; + framesPerSecond: number; + delta: number; + totalTime: number; + private lastTime; + private frameCount; + private frameTime; + update(): void; + } + interface ArrayLike { + length: number; + [n: number]: T; + } + class WindowedMean { + values: Array; + addedValues: number; + lastValue: number; + mean: number; + dirty: boolean; + constructor(windowSize?: number); + hasEnoughData(): boolean; + addValue(value: number): void; + getMean(): number; + } +} +declare namespace sp.spine { + interface VertexEffect { + begin(skeleton: Skeleton): void; + transform(position: Vector2, uv: Vector2, light: Color, dark: Color): void; + end(): void; + } +} +interface Math { + fround(n: number): number; +} +declare namespace sp.spine { + abstract class Attachment { + name: string; + constructor(name: string); + abstract copy(): Attachment; + } + abstract class VertexAttachment extends Attachment { + private static nextID; + id: number; + bones: Array; + vertices: ArrayLike; + worldVerticesLength: number; + deformAttachment: VertexAttachment; + constructor(name: string); + computeWorldVertices(slot: Slot, start: number, count: number, worldVertices: ArrayLike, offset: number, stride: number): void; + copyTo(attachment: VertexAttachment): void; + } +} +declare namespace sp.spine { + interface AttachmentLoader { + newRegionAttachment(skin: Skin, name: string, path: string): RegionAttachment; + newMeshAttachment(skin: Skin, name: string, path: string): MeshAttachment; + newBoundingBoxAttachment(skin: Skin, name: string): BoundingBoxAttachment; + newPathAttachment(skin: Skin, name: string): PathAttachment; + newPointAttachment(skin: Skin, name: string): PointAttachment; + newClippingAttachment(skin: Skin, name: string): ClippingAttachment; + } +} +declare namespace sp.spine { + enum AttachmentType { + Region = 0, + BoundingBox = 1, + Mesh = 2, + LinkedMesh = 3, + Path = 4, + Point = 5, + Clipping = 6 + } +} +declare namespace sp.spine { + class BoundingBoxAttachment extends VertexAttachment { + color: Color; + constructor(name: string); + copy(): Attachment; + } +} +declare namespace sp.spine { + class ClippingAttachment extends VertexAttachment { + endSlot: SlotData; + color: Color; + constructor(name: string); + copy(): Attachment; + } +} +declare namespace sp.spine { + class MeshAttachment extends VertexAttachment { + region: TextureRegion; + path: string; + regionUVs: ArrayLike; + uvs: ArrayLike; + triangles: Array; + color: Color; + width: number; + height: number; + hullLength: number; + edges: Array; + private parentMesh; + tempColor: Color; + constructor(name: string); + updateUVs(): void; + getParentMesh(): MeshAttachment; + setParentMesh(parentMesh: MeshAttachment): void; + copy(): Attachment; + newLinkedMesh(): MeshAttachment; + } +} +declare namespace sp.spine { + class PathAttachment extends VertexAttachment { + lengths: Array; + closed: boolean; + constantSpeed: boolean; + color: Color; + constructor(name: string); + copy(): Attachment; + } +} +declare namespace sp.spine { + class PointAttachment extends VertexAttachment { + x: number; + y: number; + rotation: number; + color: Color; + constructor(name: string); + computeWorldPosition(bone: Bone, point: Vector2): Vector2; + computeWorldRotation(bone: Bone): number; + copy(): Attachment; + } +} +declare namespace sp.spine { + class RegionAttachment extends Attachment { + static OX1: number; + static OY1: number; + static OX2: number; + static OY2: number; + static OX3: number; + static OY3: number; + static OX4: number; + static OY4: number; + static X1: number; + static Y1: number; + static C1R: number; + static C1G: number; + static C1B: number; + static C1A: number; + static U1: number; + static V1: number; + static X2: number; + static Y2: number; + static C2R: number; + static C2G: number; + static C2B: number; + static C2A: number; + static U2: number; + static V2: number; + static X3: number; + static Y3: number; + static C3R: number; + static C3G: number; + static C3B: number; + static C3A: number; + static U3: number; + static V3: number; + static X4: number; + static Y4: number; + static C4R: number; + static C4G: number; + static C4B: number; + static C4A: number; + static U4: number; + static V4: number; + x: number; + y: number; + scaleX: number; + scaleY: number; + rotation: number; + width: number; + height: number; + color: Color; + path: string; + rendererObject: any; + region: TextureRegion; + offset: ArrayLike; + uvs: ArrayLike; + tempColor: Color; + constructor(name: string); + updateOffset(): void; + setRegion(region: TextureRegion): void; + computeWorldVertices(bone: Bone, worldVertices: ArrayLike, offset: number, stride: number): void; + copy(): Attachment; + } +} +declare namespace sp.spine { + class JitterEffect implements VertexEffect { + jitterX: number; + jitterY: number; + constructor(jitterX: number, jitterY: number); + begin(skeleton: Skeleton): void; + transform(position: Vector2, uv: Vector2, light: Color, dark: Color): void; + end(): void; + } +} +declare namespace sp.spine { + class SwirlEffect implements VertexEffect { + static interpolation: PowOut; + centerX: number; + centerY: number; + radius: number; + angle: number; + private worldX; + private worldY; + constructor(radius: number); + begin(skeleton: Skeleton): void; + transform(position: Vector2, uv: Vector2, light: Color, dark: Color): void; + end(): void; + } +} + +/** + * API for jsb module + * Author: haroel + * Homepage: https://github.com/haroel/creatorexDTS + */ +declare namespace jsb{ + export module reflection{ + /** + * https://docs.cocos.com/creator/manual/zh/advanced-topics/java-reflection.html + * call OBJC/Java static methods + * + * @param className + * @param methodName + * @param methodSignature + * @param parameters + */ + export function callStaticMethod (className: string, methodName: string, methodSignature: string, ...parameters:any): any; + } + /** + * 下载任务对象 + */ + export type DownloaderTask = { requestURL: string, storagePath: string, identifier: string }; + + /** + * Http file downloader for jsb! + */ + export class Downloader{ + /** + * create a download task + * @param requestURL + * @param storagePath + * @param identifier + */ + createDownloadFileTask (requestURL:string, storagePath:string, identifier?:string): DownloaderTask; + + setOnFileTaskSuccess (onSucceed: (task: DownloaderTask) => void): void; + + setOnTaskProgress (onProgress: (task: DownloaderTask, bytesReceived: number, totalBytesReceived: number, totalBytesExpected: number) => void): void; + + setOnTaskError (onError: (task: DownloaderTask, errorCode: number, errorCodeInternal: number, errorStr: string) => void): void; + + } + + export interface ManifestAsset { + md5: string; + path: string; + compressed: boolean; + size: number; + downloadState: number; + } + + export class Manifest { + constructor (manifestUrl: string); + constructor (content: string, manifestRoot: string); + parseFile (manifestUrl: string): void; + parseJSONString (content: string, manifestRoot: string): void; + + getManifestRoot (): string; + getManifestFileUrl (): string; + getVersionFileUrl (): string; + getSearchPaths (): [string]; + getVersion (): string; + getPackageUrl (): boolean; + + setUpdating (isUpdating: boolean): void; + isUpdating (): boolean; + isVersionLoaded (): boolean; + isLoaded (): boolean; + } + + export class EventAssetsManager { + // EventCode + static ERROR_NO_LOCAL_MANIFEST: number; + static ERROR_DOWNLOAD_MANIFEST: number; + static ERROR_PARSE_MANIFEST: number; + static NEW_VERSION_FOUND: number; + static ALREADY_UP_TO_DATE: number; + static UPDATE_PROGRESSION: number; + static ASSET_UPDATED: number; + static ERROR_UPDATING: number; + static UPDATE_FINISHED: number; + static UPDATE_FAILED: number; + static ERROR_DECOMPRESS: number; + + constructor (eventName: string, manager: AssetsManager, eventCode: number, + assetId?: string, message?: string, curleCode?: number, curlmCode?: number); + getAssetsManagerEx (): AssetsManager; + isResuming (): boolean; + + getDownloadedFiles (): number; + getDownloadedBytes (): number; + getTotalFiles (): number; + getTotalBytes (): number; + getPercent (): number; + getPercentByFile (): number; + + getEventCode (): number; + getMessage (): string; + getAssetId (): string; + getCURLECode (): number; + getCURLMCode (): number; + } + + export module AssetsManager { + export enum State { + UNINITED, + UNCHECKED, + PREDOWNLOAD_VERSION, + DOWNLOADING_VERSION, + VERSION_LOADED, + PREDOWNLOAD_MANIFEST, + DOWNLOADING_MANIFEST, + MANIFEST_LOADED, + NEED_UPDATE, + READY_TO_UPDATE, + UPDATING, + UNZIPPING, + UP_TO_DATE, + FAIL_TO_UPDATE, + } + } + + export class AssetsManager { + constructor (manifestUrl: string, storagePath: string, versionCompareHandle?: (versionA: string, versionB: string) => number); + static create (manifestUrl: string, storagePath: string): AssetsManager; + + getState (): AssetsManager.State; + getStoragePath (): string + getMaxConcurrentTask (): number; + // setMaxConcurrentTask (max: number): void; // actually not supported + + checkUpdate (): void; + prepareUpdate (): void; + update (): void; + isResuming (): boolean; + + getDownloadedFiles (): number; + getDownloadedBytes (): number; + getTotalFiles (): number; + getTotalBytes (): number; + downloadFailedAssets (): void; + + getLocalManifest (): Manifest; + loadLocalManifest (manifestUrl: string): boolean; + loadLocalManifest (localManifest: Manifest, storagePath: string): boolean; + getRemoteManifest (): Manifest; + loadRemoteManifest (remoteManifest: Manifest): boolean; + + /** + * Setup your own version compare handler, versionA and B is versions in string. + * if the return value greater than 0, versionA is greater than B, + * if the return value equals 0, versionA equals to B, + * if the return value smaller than 0, versionA is smaller than B. + */ + setVersionCompareHandle (versionCompareHandle?: (versionA: string, versionB: string) => number): void; + /** + * Setup the verification callback, Return true if the verification passed, otherwise return false + */ + setVerifyCallback (verifyCallback: (path: string, asset: ManifestAsset) => boolean): void; + setEventCallback (eventCallback: (event: EventAssetsManager) => void): void; + } + + /** + * FileUtils Helper class to handle file operations. + */ + export module fileUtils{ + /** + * Checks whether the path is an absolute path. + * + * @note On Android, if the parameter passed in is relative to "@assets/", this method will treat it as an absolute path. + * Also on Blackberry, path starts with "app/native/Resources/" is treated as an absolute path. + * + * @param path The path that needs to be checked. + * @return True if it's an absolute path, false if not. + */ + export function isAbsolutePath (path:string):boolean; + /** Returns the fullpath for a given filename. + + First it will try to get a new filename from the "filenameLookup" dictionary. + If a new filename can't be found on the dictionary, it will use the original filename. + Then it will try to obtain the full path of the filename using the FileUtils search rules: resolutions, and search paths. + The file search is based on the array element order of search paths and resolution directories. + + For instance: + + We set two elements("/mnt/sdcard/", "internal_dir/") to search paths vector by setSearchPaths, + and set three elements("resources-ipadhd/", "resources-ipad/", "resources-iphonehd") + to resolutions vector by setSearchResolutionsOrder. The "internal_dir" is relative to "Resources/". + + If we have a file named 'sprite.png', the mapping in fileLookup dictionary contains `key: sprite.png -> value: sprite.pvr.gz`. + Firstly, it will replace 'sprite.png' with 'sprite.pvr.gz', then searching the file sprite.pvr.gz as follows: + + /mnt/sdcard/resources-ipadhd/sprite.pvr.gz (if not found, search next) + /mnt/sdcard/resources-ipad/sprite.pvr.gz (if not found, search next) + /mnt/sdcard/resources-iphonehd/sprite.pvr.gz (if not found, search next) + /mnt/sdcard/sprite.pvr.gz (if not found, search next) + internal_dir/resources-ipadhd/sprite.pvr.gz (if not found, search next) + internal_dir/resources-ipad/sprite.pvr.gz (if not found, search next) + internal_dir/resources-iphonehd/sprite.pvr.gz (if not found, search next) + internal_dir/sprite.pvr.gz (if not found, return "sprite.png") + + If the filename contains relative path like "gamescene/uilayer/sprite.png", + and the mapping in fileLookup dictionary contains `key: gamescene/uilayer/sprite.png -> value: gamescene/uilayer/sprite.pvr.gz`. + The file search order will be: + + /mnt/sdcard/gamescene/uilayer/resources-ipadhd/sprite.pvr.gz (if not found, search next) + /mnt/sdcard/gamescene/uilayer/resources-ipad/sprite.pvr.gz (if not found, search next) + /mnt/sdcard/gamescene/uilayer/resources-iphonehd/sprite.pvr.gz (if not found, search next) + /mnt/sdcard/gamescene/uilayer/sprite.pvr.gz (if not found, search next) + internal_dir/gamescene/uilayer/resources-ipadhd/sprite.pvr.gz (if not found, search next) + internal_dir/gamescene/uilayer/resources-ipad/sprite.pvr.gz (if not found, search next) + internal_dir/gamescene/uilayer/resources-iphonehd/sprite.pvr.gz (if not found, search next) + internal_dir/gamescene/uilayer/sprite.pvr.gz (if not found, return "gamescene/uilayer/sprite.png") + + If the new file can't be found on the file system, it will return the parameter filename directly. + + This method was added to simplify multiplatform support. Whether you are using cocos2d-js or any cross-compilation toolchain like StellaSDK or Apportable, + you might need to load different resources for a given file in the different platforms. + + @since v2.1 + */ + export function fullPathForFilename (filename:string):string; + /** + * Gets string from a file. + */ + export function getStringFromFile (filename:string):string; + /** + * Removes a file. + * + * @param filepath The full path of the file, it must be an absolute path. + * @return True if the file have been removed successfully, false if not. + */ + export function removeFile (filepath:string):boolean; + /** + * Checks whether the path is a directory. + * + * @param dirPath The path of the directory, it could be a relative or an absolute path. + * @return True if the directory exists, false if not. + */ + export function isDirectoryExist (dirPath:string):boolean; + /** + * Normalize: remove . and .. + * @param filepath + */ + export function normalizePath (filepath:string):string; + /** + * Get default resource root path. + */ + export function getDefaultResourceRootPath ():string; + /** + * Loads the filenameLookup dictionary from the contents of a filename. + * + * @note The plist file name should follow the format below: + * + * @code + * + * + * + * + * filenames + * + * sounds/click.wav + * sounds/click.caf + * sounds/endgame.wav + * sounds/endgame.caf + * sounds/gem-0.wav + * sounds/gem-0.caf + * + * metadata + * + * version + * 1 + * + * + * + * @endcode + * @param filename The plist file name. + * + @since v2.1 + * @js loadFilenameLookup + * @lua loadFilenameLookup + */ + export function loadFilenameLookup (filepath:string):void; + /** Checks whether to pop up a message box when failed to load an image. + * @return True if pop up a message box when failed to load an image, false if not. + */ + export function isPopupNotify ():boolean; + /** + * Sets whether to pop-up a message box when failed to load an image. + */ + export function setPopupNotify (notify:boolean):void; + + // Converts the contents of a file to a ValueVector. + // This method is used internally. + export function getValueVectorFromFile (filepath:string):Array; + /** + * Gets the array of search paths. + * + * @return The array of search paths which may contain the prefix of default resource root path. + * @note In best practise, getter function should return the value of setter function passes in. + * But since we should not break the compatibility, we keep using the old logic. + * Therefore, If you want to get the original search paths, please call 'getOriginalSearchPaths()' instead. + * @see fullPathForFilename(const char*). + * @lua NA + */ + export function getSearchPaths ():Array; + /** + * + * @param filepath + */ + export function getFileDir (filepath:string):string; + /** + * write a ValueMap into a plist file + * + *@param dict the ValueMap want to save (key,value) + *@param fullPath The full path to the file you want to save a string + *@return bool + */ + export function writeToFile ( valueMap:any ):boolean; + /** + * Gets the original search path array set by 'setSearchPaths' or 'addSearchPath'. + * @return The array of the original search paths + */ + export function getOriginalSearchPaths ():Array; + /** + * List all files in a directory. + * + * @param dirPath The path of the directory, it could be a relative or an absolute path. + * @return File paths in a string vector + */ + export function listFiles (filepath:string):Array; + /** + * Converts the contents of a file to a ValueMap. + * @param filename The filename of the file to gets content. + * @return ValueMap of the file contents. + * @note This method is used internally. + */ + export function getValueMapFromFile (filepath:string):any; + /** + * Retrieve the file size. + * + * @note If a relative path was passed in, it will be inserted a default root path at the beginning. + * @param filepath The path of the file, it could be a relative or absolute path. + * @return The file size. + */ + export function getFileSize (filepath:string):number; + + /** Converts the contents of a file to a ValueMap. + * This method is used internally. + */ + export function getValueMapFromData (filedata:string,filesize:number):any; + /** + * Removes a directory. + * + * @param dirPath The full path of the directory, it must be an absolute path. + * @return True if the directory have been removed successfully, false if not. + */ + export function removeDirectory (dirPath:string):boolean; + /** + * Sets the array of search paths. + * + * You can use this array to modify the search path of the resources. + * If you want to use "themes" or search resources in the "cache", you can do it easily by adding new entries in this array. + * + * @note This method could access relative path and absolute path. + * If the relative path was passed to the vector, FileUtils will add the default resource directory before the relative path. + * For instance: + * On Android, the default resource root path is "@assets/". + * If "/mnt/sdcard/" and "resources-large" were set to the search paths vector, + * "resources-large" will be converted to "@assets/resources-large" since it was a relative path. + * + * @param searchPaths The array contains search paths. + * @see fullPathForFilename(const char*) + * @since v2.1 + * In js:var setSearchPaths(var jsval); + * @lua NA + */ + export function setSearchPaths ( searchPath:Array):void; + /** + * write a string into a file + * + * @param dataStr the string want to save + * @param fullPath The full path to the file you want to save a string + * @return bool True if write success + */ + export function writeStringToFile (dataStr:string,fullPath:string):boolean; + /** + * Sets the array that contains the search order of the resources. + * + * @param searchResolutionsOrder The source array that contains the search order of the resources. + * @see getSearchResolutionsOrder(), fullPathForFilename(const char*). + * @since v2.1 + * In js:var setSearchResolutionsOrder(var jsval) + * @lua NA + */ + export function setSearchResolutionsOrder (searchResolutionsOrder:Array):void; + /** + * Append search order of the resources. + * + * @see setSearchResolutionsOrder(), fullPathForFilename(). + * @since v2.1 + */ + export function addSearchResolutionsOrder (order:string,front:boolean):void; + /** + * Add search path. + * + * @since v2.1 + */ + export function addSearchPath (path:string,front:boolean):void; + /** + * write ValueVector into a plist file + * + *@param vecData the ValueVector want to save + *@param fullPath The full path to the file you want to save a string + *@return bool + */ + export function writeValueVectorToFile (vecData:Array,fullPath:string):boolean; + /** + * Checks whether a file exists. + * + * @note If a relative path was passed in, it will be inserted a default root path at the beginning. + * @param filename The path of the file, it could be a relative or absolute path. + * @return True if the file exists, false if not. + */ + export function isFileExist (filename:string):boolean; + /**©∫ + * Purges full path caches. + */ + export function purgeCachedEntries ():void; + /** + * Gets full path from a file name and the path of the relative file. + * @param filename The file name. + * @param relativeFile The path of the relative file. + * @return The full path. + * e.g. filename: hello.png, pszRelativeFile: /User/path1/path2/hello.plist + * Return: /User/path1/path2/hello.pvr (If there a a key(hello.png)-value(hello.pvr) in FilenameLookup dictionary. ) + * + */ + export function fullPathFromRelativeFile (filename:string,relativeFile:string):string; + /** + * Windows fopen can't support UTF-8 filename + * Need convert all parameters fopen and other 3rd-party libs + * + * @param filenameUtf8 std::string name file for conversion from utf-8 + * @return std::string ansi filename in current locale + */ + export function getSuitableFOpen (filenameUtf8:string):string; + /** + * write ValueMap into a plist file + * + *@param dict the ValueMap want to save + *@param fullPath The full path to the file you want to save a string + *@return bool + */ + export function writeValueMapToFile (dict:any,fullPath:string):string; + /** + * Gets filename extension is a suffix (separated from the base filename by a dot) in lower case. + * Examples of filename extensions are .png, .jpeg, .exe, .dmg and .txt. + * @param filePath The path of the file, it could be a relative or absolute path. + * @return suffix for filename in lower case or empty if a dot not found. + */ + export function getFileExtension (filePath:string):string; + /** + * Sets writable path. + */ + export function setWritablePath (writablePath:string):void; + /** + * Set default resource root path. + */ + export function setDefaultResourceRootPath (filepath:string):void; + + /** + * Gets the array that contains the search order of the resources. + * + * @see setSearchResolutionsOrder(const std::vector&), fullPathForFilename(const char*). + * @since v2.1 + * @lua NA + */ + export function getSearchResolutionsOrder ():Array; + /** + * Creates a directory. + * + * @param dirPath The path of the directory, it must be an absolute path. + * @return True if the directory have been created successfully, false if not. + */ + export function createDirectory (dirPath:string):string; + /** + * List all files recursively in a directory. + * + * @param dirPath The path of the directory, it could be a relative or an absolute path. + * @return File paths in a string vector + */ + export function listFilesRecursively (dirPath:string, files:Array):void; + /** + * Gets the writable path. + * @return The path that can be write/read a file in + */ + export function getWritablePath ():string; + } +} + +/** Running in the editor. */ +declare const CC_EDITOR: boolean; +/** Preview in browser or simulator. */ +declare const CC_PREVIEW: boolean; +/** Running in the editor or preview. */ +declare const CC_DEV: boolean; +/** Running in the editor or preview, or build in debug mode. */ +declare const CC_DEBUG: boolean; +/** Running in published project. */ +declare const CC_BUILD: boolean; +/** Running in native platforms (mobile app, desktop app, or simulator). */ +declare const CC_JSB: boolean; +/** Running in runtime environments. */ +declare const CC_RUNTIME: boolean; +/** Running in the engine's unit test. */ +declare const CC_TEST: boolean; +/** Running in the WeChat Mini Game. */ +declare const CC_WECHATGAME: boolean; diff --git a/MeshDemo/jsconfig.json b/MeshDemo/jsconfig.json new file mode 100644 index 0000000..05394dd --- /dev/null +++ b/MeshDemo/jsconfig.json @@ -0,0 +1,13 @@ +{ + "compilerOptions": { + "target": "es6", + "module": "commonjs" + }, + "exclude": [ + "node_modules", + "library", + "local", + "settings", + "temp" + ] +} \ No newline at end of file diff --git a/MeshDemo/project.json b/MeshDemo/project.json new file mode 100644 index 0000000..d9513d4 --- /dev/null +++ b/MeshDemo/project.json @@ -0,0 +1,8 @@ +{ + "engine": "cocos2d-html5", + "packages": "packages", + "version": "2.4.3", + "name": "NewProject", + "id": "e8f8c035-bd9f-4f7e-a9de-440bfc9cfe65", + "isNew": false +} \ No newline at end of file diff --git a/MeshDemo/settings/builder.json b/MeshDemo/settings/builder.json new file mode 100644 index 0000000..09f915c --- /dev/null +++ b/MeshDemo/settings/builder.json @@ -0,0 +1,13 @@ +{ + "excludeScenes": [], + "orientation": { + "landscapeLeft": true, + "landscapeRight": true, + "portrait": false, + "upsideDown": false + }, + "packageName": "org.cocos2d.helloworld", + "startScene": "2d2f792f-a40c-49bb-a189-ed176a246e49", + "title": "hello_world", + "webOrientation": "auto" +} \ No newline at end of file diff --git a/MeshDemo/settings/builder.panel.json b/MeshDemo/settings/builder.panel.json new file mode 100644 index 0000000..6a7c356 --- /dev/null +++ b/MeshDemo/settings/builder.panel.json @@ -0,0 +1,7 @@ +{ + "excludeScenes": [], + "packageName": "org.cocos2d.helloworld", + "platform": "web-mobile", + "startScene": "2d2f792f-a40c-49bb-a189-ed176a246e49", + "title": "HelloWorld" +} \ No newline at end of file diff --git a/MeshDemo/settings/project.json b/MeshDemo/settings/project.json new file mode 100644 index 0000000..92ed669 --- /dev/null +++ b/MeshDemo/settings/project.json @@ -0,0 +1,42 @@ +{ + "collision-matrix": [ + [ + true + ], + [ + false, + false + ] + ], + "excluded-modules": [], + "group-list": [ + "default", + "UI" + ], + "start-scene": "2d2f792f-a40c-49bb-a189-ed176a246e49", + "design-resolution-width": 960, + "design-resolution-height": 640, + "fit-width": false, + "fit-height": true, + "use-project-simulator-setting": false, + "simulator-orientation": false, + "use-customize-simulator": true, + "simulator-resolution": { + "height": 640, + "width": 960 + }, + "last-module-event-record-time": 0, + "assets-sort-type": "name", + "facebook": { + "appID": "", + "audience": { + "enable": false + }, + "enable": false, + "live": { + "enable": false + } + }, + "preview-port": 7456, + "clear-simulator-cache": true +} diff --git a/MeshDemo/settings/services.json b/MeshDemo/settings/services.json new file mode 100644 index 0000000..599b09e --- /dev/null +++ b/MeshDemo/settings/services.json @@ -0,0 +1,6 @@ +{ + "game": { + "name": "未知游戏", + "appid": "UNKNOW" + } +} \ No newline at end of file diff --git a/MeshDemo/template-banner.png b/MeshDemo/template-banner.png new file mode 100644 index 0000000..2aa766f Binary files /dev/null and b/MeshDemo/template-banner.png differ diff --git a/MeshDemo/template.json b/MeshDemo/template.json new file mode 100644 index 0000000..78d02bc --- /dev/null +++ b/MeshDemo/template.json @@ -0,0 +1,5 @@ +{ + "name": "TEMPLATES.helloworld-ts.name", + "desc": "TEMPLATES.helloworld-ts.desc", + "banner": "template-banner.png" +} \ No newline at end of file diff --git a/MeshDemo/tsconfig.json b/MeshDemo/tsconfig.json new file mode 100644 index 0000000..93c0b22 --- /dev/null +++ b/MeshDemo/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ "es2015", "es2017", "dom" ], + "target": "es5", + "experimentalDecorators": true, + "skipLibCheck": true, + "outDir": "temp/vscode-dist", + "forceConsistentCasingInFileNames": true + }, + "exclude": [ + "node_modules", + "library", + "local", + "temp", + "build", + "settings" + ] +} \ No newline at end of file diff --git a/MovementDemo/.gitignore b/MovementDemo/.gitignore new file mode 100644 index 0000000..a231b3f --- /dev/null +++ b/MovementDemo/.gitignore @@ -0,0 +1,24 @@ + +#/////////////////////////// +# Cocos Creator 3D Project +#/////////////////////////// +library/ +temp/ +local/ +build/ +profiles/ +native +#////////////////////////// +# NPM +#////////////////////////// +node_modules/ + +#////////////////////////// +# VSCode +#////////////////////////// +.vscode/ + +#////////////////////////// +# WebStorm +#////////////////////////// +.idea/ \ No newline at end of file diff --git a/MovementDemo/@types/editor.d.ts b/MovementDemo/@types/editor.d.ts new file mode 100644 index 0000000..6813c1c --- /dev/null +++ b/MovementDemo/@types/editor.d.ts @@ -0,0 +1,1191 @@ +/// + +/// +/// + +import * as NodeJSPath from 'path'; +import { EventEmitter } from 'events'; +import { FileFilter, BrowserWindow, OpenDialogReturnValue, SaveDialogReturnValue, MessageBoxReturnValue } from 'electron'; + +declare global { + export module Editor { + export module App { + export const userAgent: string; + /** + * 是否是开发模式 + * Development mode + */ + export const dev: boolean; + /** + * 编辑器版本号 + * Editor version + */ + export const version: string; + /** + * 主目录 + * Home directory + */ + export const home: string; + /** + * 编辑器程序文件夹 + * Program folder + */ + export const path: string; + /** + * 获取当前编辑器的临时缓存目录 + * Temporary cache directory + */ + export const temp: string; + /** + * 获取当前编辑器 icon 地址 + * Gets the icon address of the current editor + */ + export const icon: string; + /** + * 获取当前编辑器使用的 url 地址 + * Gets the URL used by the current editor + */ + export const urls: { + manual: string; + api: string; + forum: string; + }; + /** + * 退出程序 + * Exit the program + */ + export function quit(): void; + } + export module Clipboard { + export type ICopyType = 'image' | 'text' | 'files' | string; + /** + * 获取剪贴板内容 + * @param type + */ + export function read(type: ICopyType): any; + /** + * 写入剪贴板内容 + * @param type + * @param value + */ + export function write(type: 'image', value: string): boolean; + export function write(type: 'text', value: string): boolean; + export function write(type: 'files', value: FileList): boolean; + export function write(type: string, value: any): boolean; + + /** + * 判断当前剪贴板内是否是指定类型 + * @param type + */ + export function has(type: ICopyType): boolean; + /** + * 清空剪贴板 + */ + export function clear(): void; + } + export module Dialog { + export interface SelectDialogOptions { + title?: string; + path?: string; + type?: 'directory' | 'file'; + button?: string; + multi?: boolean; + filters?: FileFilter[]; + extensions?: string; + } + export interface MessageDialogOptions { + title?: string; + detail?: string; + default?: number; + cancel?: number; + checkboxLabel?: string; + checkboxChecked?: boolean; + buttons?: string[]; + } + + /** + * 选择文件弹窗 + * Select the file popover + * + * @param options 选择弹窗参数 Select popover parameters + * @param window 依附于哪个窗口(插件主进程才可使用) Which window it is attached to (only available to the plugin's main process) + */ + export function select(options?: SelectDialogOptions, window?: BrowserWindow): Promise; + /** + * 保存文件弹窗 + * Save the file popup + * + * @param options 保存文件窗口参数 Save the file window parameters + * @param window 依附于哪个窗口(插件主进程才可使用) Which window it is attached to (only available to the plugin's main process) + */ + export function save(options?: SelectDialogOptions, window?: BrowserWindow): Promise; + /** + * 信息弹窗 + * Information popup window + * + * @param message 显示的消息 Displayed message + * @param options 信息弹窗可选参数 Information popup optional parameter + * @param window 依附于哪个窗口(插件主进程才可使用) Which window it is attached to (only available to the plugin's main process) + */ + export function info(message: string, options?: MessageDialogOptions, window?: BrowserWindow): Promise; + /** + * 警告弹窗 + * Warning popup + * + * @param message 警告信息 Warning message + * @param options 警告弹窗可选参数 Warning popover optional parameter + * @param window 依附于哪个窗口(插件主进程才可使用) Which window it is attached to (only available to the plugin's main process) + */ + export function warn(message: string, options?: MessageDialogOptions, window?: BrowserWindow): Promise; + /** + * 错误弹窗 + * Error popup window + * + * @param message 错误信息 The error message + * @param options 错误弹窗可选参数 Error popover optional parameter + * @param window 依附于哪个窗口(插件主进程才可使用) Which window it is attached to (only available to the plugin's main process) + */ + export function error(message: string, options?: MessageDialogOptions, window?: BrowserWindow): Promise; + } + export module EditMode { + /** + * 标记编辑器进入了一种编辑模式 + * The tag editor goes into an edit mode + * + * @param mode 编辑模式的名字 The name of the edit mode + */ + export function enter(mode: string): any; + /** + * 当前所处的编辑模式 + * The current editing mode + * + */ + export function getMode(): string; + } + export module I18n { + export type I18nMap = { + [key: string]: I18nMap | string; + }; + /** + * 获取当前的语言 + * Get the current language + */ + export function getLanguage(): any; + /** + * 传入 key,翻译成当前语言 + * Passing in the key translates into the current language + * 允许翻译变量 {a},传入的第二个参数 obj 内定义 a + * The translation variable {a} is allowed, and a is defined in the second argument passed in obj + * + * @param key 用于翻译的 key 值 The key value for translation + * @param obj 翻译字段内如果有 {key} 等可以在这里传入替换字段 If you have {key} in the translation field, you can pass in the replacement field here + */ + export function t(key: string, obj?: { + [key: string]: string; + }): any; + /** + * 选择一种翻译语言 + * Choose a translation language + * + * @param language 选择当前使用的语言 Select the language currently in use + */ + export function select(language: string): any; + } + export module Layout { + /** + * 应用布局信息 + * Application layout information + * + * @param json 布局文件内容 Layout file content + */ + export function apply(json: any): any; + /** + * 初始化布局系统 + * Initialize the layout system + */ + export function init(): any; + } + export module Logger { + /** + * 清空所有的日志 + * Clear all logs + */ + export function clear(): any; + /** + * 查询所有日志 + * Query all logs + */ + export function query(): any; + } + export module Menu { + export interface BaseMenuItem { + template?: string; + type?: string; + label?: string; + subLabel?: string; + checked?: boolean; + enabled?: boolean; + icon?: string; + accelerator?: string; + order?: number; + group?: string; + message?: string; + target?: string; + params?: any[]; + click?: Function | null; + role?: string; + submenu?: MenuTemplateItem[]; + } + export interface MainMenuItem extends BaseMenuItem { + path: string; + } + export interface ContextMenuItem extends BaseMenuItem { + accelerator?: string; + } + export interface MenuTemplateItem extends BaseMenuItem { + } + export interface PopupOptions { + x?: number; + y?: number; + menu: ContextMenuItem[]; + } + /** + * 右键弹窗 + * Right-click pop-up + * 只有面板进程可以使用 + * Only panel processes can be used + * + * @param json + */ + export function popup(json: PopupOptions): any; + } + export module Message { + export interface MessageInfo { + methods: string[]; + public?: boolean; + description?: string; + doc?: string; + sync?: boolean; + } + + export interface TableBase { + [x: string]: any; + params: any[]; + } + /** + * 发送一个消息,并等待返回 + * Send a message and wait for it to return + * + * @param name 目标插件的名字 The name of the target plug-in + * @param message 触发消息的名字 The name of the trigger message + * @param args 消息需要的参数 The parameters required for the message + */ + export function request(name: J, message: K, ...args: EditorMessageMaps[J][K]['params']): Promise; + /** + * 发送一个消息,没有返回 + * Send a message, no return + * + * @param name 目标插件的名字 The name of the target plug-in + * @param message 触发消息的名字 The name of the trigger message + * @param args 消息需要的参数 The parameters required for the message + */ + export function send(name: M, message: N, ...args: EditorMessageMaps[M][N]['params']): void; + /** + * 广播一个消息 + * Broadcast a message + * + * @param message 消息的名字 Name of message + * @param args 消息附加的参数 Parameter attached to the message + */ + export function broadcast(message: string, ...args: any[]): void; + /** + * 新增一个广播消息监听器 + * Add a new broadcast message listener + * 不监听的时候,需要主动取消监听 + * When not listening, you need to take the initiative to cancel listening + * + * @param message 消息名 Message name + * @param func 处理函数 The processing function + */ + export function addBroadcastListener(message: string, func: Function): any; + /** + * 新增一个广播消息监听器 + * Removes a broadcast message listener + * + * @param message 消息名 Message name + * @param func 处理函数 The processing function + */ + export function removeBroadcastListener(message: string, func: Function): any; + } + export module Network { + /** + * 查询当前电脑的 ip 列表 + * Query the IP list of the current computer + */ + export function queryIPList(): string[]; + /** + * 测试是否可以联通 passport.cocos.com 服务器 + * Test whether you can connect to the passport.cocos.com server + */ + export function testConnectServer(): Promise; + /** + * 检查一个端口是否被占用 + * Checks if a port is used + * + * @param port + */ + export function portIsOccupied(port: number): Promise; + /** + * 测试是否可以联通某一台主机 + * Test whether a host can be connected + * + * @param ip + */ + export function testHost(ip: string): Promise; + /** + * Get 方式请求某个服务器数据 + * GET requests data from a server + * + * @param url + * @param data + */ + export function get(url: string, data?: { + [index: string]: string | string[]; + }): Promise; + /** + * Post 方式请求某个服务器数据 + * POST requests data from a server + * + * @param url + * @param data + */ + export function post(url: string, data?: { + [index: string]: string | number | string[]; + }): Promise; + } + export module Package { + // export module VERSION: string; + export interface GetPackageOptions { + name?: string; + debug?: boolean; + path?: string; + enable?: boolean; + invalid?: boolean; + } + export interface PackageJson { + author?: string; + debug?: boolean; + description?: string; + main?: string; + menu?: any; + name: string; + version: string; + windows: string; + editor?: string; + panel?: any; + } + export type PathType = 'home' | 'data' | 'temp'; + /** + * 查询插件列表 + * Query Plug-in List + * + * @param options + */ + export function getPackages(options?: GetPackageOptions): Editor.Interface.PackageInfo[]; + /** + * 注册一个插件 + * Register a plug-in + * 谨慎使用,之后会被移除 + * Use with caution and it will be removed later + * + * @param path + */ + export function register(path: string): any; + /** + * 反注册一个插件 + * Unregister a plug-in + * 谨慎使用,之后会被移除 + * Use with caution and it will be removed later + * + * @param path + */ + export function unregister(path: string): any; + /** + * 启动一个插件 + * Enable a plug-in + * + * @param path + */ + export function enable(path: string): any; + /** + * 关闭一个插件 + * Disable a plug-in + * + * @param path + */ + export function disable(path: string, options: any): any; + /** + * 获取一个插件的几个预制目录地址 + * Gets several prefab directory addresses for a plug-in + * + * @param extensionName 扩展的名字 Name of the extension + * @param type 地址类型(temp 临时目录,data 需要同步的数据目录,不传则返回现在打开的插件路径) Address type (temp temporary directory, data need to synchronize data directory, do not pass to return the current open plug-in path) + */ + export function getPath(extensionName: string, type?: PathType): any; + } + export module Panel { + export const _kitControl: any; + /** + * 打开一个面板 + * Open up a panel + * + * @param name + * @param args + */ + export function open(name: string, ...args: any[]): any; + /** + * 关闭一个面板 + * Close a panel + * + * @param name + */ + export function close(name: string): any; + /** + * 将焦点传递给一个面板 + * Pass focus to a panel + * + * @param name + */ + export function focus(name: string): any; + /** + * 检查面板是否已经打开 + * Check that the panel is open + * + * @param name + */ + export function has(name: string): Promise; + /** + * 查询当前窗口里某个面板里的元素列表 + * @param name + * @param selector + */ + export function querySelector(name: string, selector: string): Promise; + + export type Selector<$> = { $: Record } + + export type Options void> = { + /** + * @en Listening to panel events + * @zh 监听面板事件 + */ + listeners?: { + /** + * @en Hooks triggered when the panel is displayed + * @zh 面板显示的时候触发的钩子 + */ + show?: () => any; + /** + * @en Hooks triggered when the panel is hidden + * @zh 面板隐藏的时候触发的钩子 + */ + hide?: () => any; + }; + + /** + * @en Template of the panel + * @zh 面板的内容 + */ + template: string; + /** + * @en Style of the panel + * @zh 面板上的样式 + * */ + style?: string; + /** + * @en Selector of the panel + * @zh 快捷选择器 + */ + $?: S; + /** + * @en Panel built-in function methods that can be called in Messages, Listeners, lifecycle functions + * @zh panel 内置的函数方法,可以在 messages、listeners、生命周期函数内调用 + */ + methods?: M; + /** + * @en Hooks triggered when the panel is update + * @zh 面板数据更新后触发的钩子函数 + */ + update?: (...args: Parameters) => void; + /** + * @en Hooks triggered when the panel is ready + * @zh 面板启动后触发的钩子函数 + */ + ready?: () => void; + /** + * @en The function that will be triggered when the panel is ready to close, and will terminate the closing of the panel if it + * returns false + * @zh 面板准备关闭的时候会触发的函数,return false 的话,会终止关闭面板 + * 生命周期函数,在 panel 准备关闭的时候触发 + * 如果 return false,则会中断关闭流程,请谨慎使用,错误的判断会导致编辑器无法关闭。 + */ + beforeClose?: () => Promise | boolean | void; + /** + * @en Hook functions after panel closure + * @zh 面板关闭后的钩子函数 + */ + close?: () => void; + + } & ThisType & M> // merge them together + + export function define void, Selector = Record, M = Record>(options: Options): any; + } + export module Profile { + export type preferencesProtocol = 'default' | 'global' | 'local'; + export type projectProtocol = 'default' | 'project'; + export type tempProtocol = 'temp'; + export interface ProfileGetOptions { + type: 'deep' | 'current' | 'inherit'; + } + export interface ProfileObj { + get: (key?: string, options?: ProfileGetOptions) => any; + set: (key?: string, value?: any) => any; + remove: (key: string) => void; + save: () => void; + clear: () => void; + reset: () => void; + } + /** + * 读取插件配置 + * Read the plug-in configuration + * + * @param name 插件名 The plugin name + * @param key 配置路径 Configure path + * @param type 配置的类型,选填 Type of configuration, optional(global,local,default) + */ + export function getConfig(name: string, key?: string, type?: preferencesProtocol): Promise; + /** + * 设置插件配置 + * Set the plug-in configuration + * + * @param name 插件名 The plugin name + * @param key 配置路径 Configure path + * @param value 配置的值 The value of the configuration + * @param type 配置的类型,选填 Type of configuration, optional(global,local,default) + */ + export function setConfig(name: string, key: string, value: any, type?: preferencesProtocol): Promise; + /** + * 删除某个插件配置 + * Delete a plug-in configuration + * + * @param name 插件名 The plugin name + * @param key 配置路径 Configure path + * @param type 配置的类型,选填 Type of configuration, optional(global,local,default) + */ + export function removeConfig(name: string, key: string, type?: preferencesProtocol): Promise; + /** + * 读取插件内的项目配置 + * Read the project configuration within the plug-in + * + * @param name 插件名 The plugin name + * @param key 配置路径 Configure path + * @param type 配置的类型,选填 Type of configuration, optional(project,default) + */ + export function getProject(name: string, key?: string, type?: projectProtocol): Promise; + /** + * 设置插件内的项目配置 + * Set the project configuration within the plug-in + * + * @param name 插件名 The plugin name + * @param key 配置路径 Configure path + * @param value 配置的值 The value of the configuration + * @param type 配置的类型,选填 Type of configuration, optional(project,default) + */ + export function setProject(name: string, key: string, value: any, type?: projectProtocol): Promise; + /** + * 删除插件内的项目配置 + * Delete the project configuration within the plug-in + * + * @param name 插件名 The plugin name + * @param key 配置路径 Configure path + * @param type 配置的类型,选填 Type of configuration, optional(project,default) + */ + export function removeProject(name: string, key: string, type?: projectProtocol): Promise; + /** + * 读取插件配置 + * Read the plug-in configuration + * + * @param name 插件名 The plugin name + * @param key 配置路径 Configure path + */ + export function getTemp(name: string, key?: string): Promise; + /** + * 设置插件配置 + * Set the plug-in configuration + * + * @param name 插件名 The plugin name + * @param key 配置路径 Configure path + * @param value 配置的值 The value of the configuration + */ + export function setTemp(name: string, key: string, value: any): Promise; + /** + * 删除某个插件配置 + * Delete a plug-in configuration + * + * @param name 插件名 The plugin name + * @param key 配置路径 Configure path + */ + export function removeTemp(name: string, key: string): Promise; + /** + * 迁移插件某个版本的本地配置数据到编辑器最新版本 + * Migrate the local configuration data of a certain version of the plugin to the latest version of the editor + * + * @param pkgName + * @param profileVersion + * @param profileData + */ + export function migrateLocal(pkgName: string, profileVersion: string, profileData: any): any; + /** + * 迁移插件某个版本的全局配置数据到编辑器最新版本 + * Migrate the global configuration data of a certain version of the plugin to the latest version of the editor + * + * @param pkgName + * @param profileVersion + * @param profileData + */ + export function migrateGlobal(pkgName: string, profileVersion: string, profileData: any): any; + /** + * 迁移插件某个版本的项目配置数据到编辑器最新版本 + * Migrate the project configuration data of a certain version of the plugin to the latest version of the editor + * + * @param pkgName + * @param profileVersion + * @param profileData + */ + export function migrateProject(pkgName: string, profileVersion: string, profileData: any): any; + } + export module Project { + /** + * 创建一个项目 + * Creating a project + * 谨慎使用,之后会被移除 + * Use with caution and it will be removed later + */ + export function create(): any; + /** + * 打开一个项目 + * Open a project + * 谨慎使用,之后会被移除 + * Use with caution and it will be removed later + * + * @param path + */ + export function open(path?: string): Promise; + /** + * 添加一个项目 + * Add a project + * 谨慎使用,之后会被移除 + * Use with caution and it will be removed later + * + * @param path + */ + export function add(path: string): any; + /** + * 当前项目路径 + * Current project path + */ + export const path: string; + /** + * 当前项目 uuid + * The current project UUID + */ + export const uuid: string; + /** + * 当前项目名称(取自 package.json) + * The current project name + */ + export const name: string; + /** + * 当前项目临时文件夹 + * Temporary folder for current project + */ + export const tmpDir: string; + /** + * 当前项目类型 + * 谨慎使用,之后会被移除 + * Use with caution and it will be removed later + */ + export const type: '2d' | '3d'; + } + export module Selection { + /** + * 选中一个或者一组元素 + * Select one or a group of elements + * + * @param type + * @param uuid + */ + export function select(type: string, uuid: string | string[]): any; + /** + * 取消一个或者一组元素的选中状态 + * To deselect one or a group of elements + * + * @param type + * @param uuid + */ + export function unselect(type: string, uuid: string | string[]): any; + /** + * 清空一个类型的所有选中元素 + * Clears all selected elements of a type + * + * @param type + */ + export function clear(type: string): any; + /** + * 更新当前选中的类型数据 + * Updates the currently selected type data + * + * @param type + * @param uuids + */ + export function update(type: string, uuids: string[]): any; + /** + * 悬停触碰了某个元素 + * Hover touches an element + * 会发出 selection:hover 的广播消息 + * A broadcast message for selection:hover is issued + * + * @param type + * @param uuid + */ + export function hover(type: string, uuid?: string): any; + /** + * 获取最后选中的元素的类型 + * Gets the type of the last selected element + */ + export function getLastSelectedType(): string; + /** + * 获取某个类型内,最后选中的元素 + * Gets the last selected element of a type + * + * @param type + */ + export function getLastSelected(type: string): string; + /** + * 获取一个类型选中的所有元素数组 + * Gets an array of all elements selected for a type + * + * @param type + */ + export function getSelected(type: string): string[]; + } + export module Task { + export interface NoticeOptions { + title: string; + message?: string; + type?: 'error' | 'warn' | 'log' | 'success'; + source?: string; + timeout?: number; + } + /** + * 添加一个同步任务 + * Add a synchronous task + * 会在主窗口显示一个遮罩层 + * A mask layer is displayed in the main window + * + * @param title 任务名字 The task name + * @param describe 任务描述 Task description + * @param message 任务内容 Content of the task + */ + export function addSyncTask(title: string, describe?: string, message?: string): any; + /** + * 更新某一个同步任务显示的数据 + * Update the data displayed by a synchronous task + * + * @param title 任务名字 The task name + * @param describe 任务描述 Task description + * @param message 任务内容 Content of the task + */ + export function updateSyncTask(title: string, describe?: string, message?: string): any; + /** + * 删除一个同步任务 + * Delete a synchronous task + * + * @param title 任务的名字 The name of the task + */ + export function removeSyncTask(title: string): any; + /** + * 添加一个通知 + * Add a notification + * + * @param options 消息配置 Message configuration + */ + export function addNotice(options: NoticeOptions): any; + /** + * 删除一个通知 + * Delete a notification + * + * @param id 通知 id Notification ID + */ + export function removeNotice(id: number): any; + /** + * 修改 notice 自动移除的时间 + * Modify notice automatic removal time + * + * @param id 通知 id Notification ID + * @param time 超时时间 timeout + */ + export function changeNoticeTimeout(id: number, time: number): any; + /** + * 查询所有通知 + * Query all notifications + */ + export function queryNotices(): any; + /** + * 页面进程立即同步一次主进程数据 + * The page process synchronizes the master process data immediately + * 谨慎使用,之后会被移除 + * Use with caution and it will be removed later + */ + export function sync(): any; + } + export module Theme { + /** + * 获取所有主题的名字 + * Gets the names of all topics + */ + export function getList(): any; + /** + * 使用某个皮肤 + * Use a certain skin + * + * @param name + */ + export function use(name?: string): any; + } + export module UI { + /** + * 在当前页面上注册一个自定义节点 + * Registers a custom node on the current page + * 谨慎使用,之后会被移除 + * Use with caution and it will be removed later + * + * @param tagName 元素名字 + * @param element 元素的定义函数 + */ + export function register(tagName: string, element: any): void; + export const Base: any; + export const Button: any; + export const Input: any; + export const NumInput: any; + export const Loading: any; + export const Checkbox: any; + export const Section: any; + export const Select: any; + export const Bit: any; + export const Slider: any; + export const ColorPicker: any; + export const Color: any; + export const DragItem: any; + export const DragArea: any; + export const DragObject: any; + export const Prop: any; + export const Tooltip: any; + export const TextArea: any; + export const Progress: any; + export const Label: any; + export const Code: any; + export const Tab: any; + export const Gradient: any; + export const GradientPicker: any; + export const Icon: any; + export const File: any; + export const Link: any; + export const Image: any; + export const QRCode: any; + export const Markdown: any; + export const Curve: any; + export const CurveEditor: any; + export const NodeGraph: any; + } + export module User { + export interface UserData { + session_id: string; + session_key: string; + cocos_uid: string; + email: string; + nickname: string; + } + /** + * 跳过 User + * Skip the User + * 谨慎使用,之后会被移除 + * Use with caution and it will be removed later + */ + export function skip(): any; + /** + * 获取 user 数据 + * Get user data + */ + export function getData(): Promise; + /** + * 检查用户是否登陆 + * Check if the user is logged in + */ + export function isLoggedIn(): Promise; + /** + * 用户登陆 + * The user login + * 失败会抛出异常 + * Failure throws an exception + * + * @param username + * @param password + */ + export function login(username: string, password: string): Promise; + /** + * 退出登陆 + * Logged out + * 失败会抛出异常 + * Failure throws an exception + */ + export function logout(): void; + /** + * 获取用户 token + * Get user token + * 失败会抛出异常 + * Failure throws an exception + */ + export function getUserToken(): Promise; + /** + * 根据插件 id 返回 session code + * Returns the session code based on the plug-in ID + * + * @param extensionId + */ + export function getSessionCode(extensionId: number): Promise; + /** + * 显示用户登陆遮罩层 + * Shows user login mask layer + * 谨慎使用,之后会被移除 + * Use with caution and it will be removed later + */ + export function showMask(): void; + /** + * 隐藏用户登陆遮罩层 + * Hide user login mask layer + * 谨慎使用,之后会被移除 + * Use with caution and it will be removed later + */ + export function hideMask(): void; + /** + * 监听事件 + * Listen for an event + * 谨慎使用,之后会被移除 + * Use with caution and it will be removed later + * @param action + * @param handle + */ + export function on(action: string, handle: Function): any; + /** + * 监听一次事件 + * Listening for one event + * 谨慎使用,之后会被移除 + * Use with caution and it will be removed later + * @param action + * @param handle + */ + export function once(action: string, handle: Function): any; + /** + * 取消已经监听的事件 + * Cancels the event you are listening for + * 谨慎使用,之后会被移除 + * Use with caution and it will be removed later + * @param action + * @param handle + */ + export function removeListener(action: string, handle: Function): any; + } + export module Utils { + export module File { + /** + * 初始化一个可用的文件名 + * Initializes a available filename + * 返回可用名称的文件路径 + * Returns the file path with the available name + * + * @param file 初始文件路径 Initial file path + */ + export function getName(file: string): string; + interface UnzipOptions { + peel?: boolean; + } + /** + * 解压文件夹 + * Unzip folder + * + * @param zip + * @param target + * @param options + */ + export function unzip(zip: string, target: string, options?: UnzipOptions): Promise; + /** + * 复制一个文件到另一个位置 + * Copy a file to another location + * + * @param source + * @param target + */ + export function copy(source: string, target: string): void; + } + export module Path { + + /** + * 返回一个不含扩展名的文件名 + * @param path + */ + export function basenameNoExt(path: string): string; + /** + * 将 \ 统一换成 / + * @param path + */ + export function slash(path: string): string; + /** + * 去除路径最后的斜杆,返回一个不带斜杆的路径 + * @param path + */ + export function stripSep(path: string): string; + /** + * 删除一个路径的扩展名 + * @param path + */ + export function stripExt(path: string): string; + /** + * 判断路径 pathA 是否包含 pathB + * pathA = foo/bar, pathB = foo/bar/foobar, return true + * pathA = foo/bar, pathB = foo/bar, return true + * pathA = foo/bar/foobar, pathB = foo/bar, return false + * pathA = foo/bar/foobar, pathB = foobar/bar/foo, return false + * @param pathA + * @param pathB + */ + export function contains(pathA: string, pathB: string): boolean; + /** + * 格式化路径 + * 如果是 Windows 平台,需要将盘符转成小写进行判断 + * @param path + */ + export function normalize(path: string): string; + export const join: typeof NodeJSPath.join; + export const resolve: typeof NodeJSPath.resolve; + export const isAbsolute: typeof NodeJSPath.isAbsolute; + export const relative: typeof NodeJSPath.relative; + export const dirname: typeof NodeJSPath.dirname; + export const basename: typeof NodeJSPath.basename; + export const extname: typeof NodeJSPath.extname; + export const sep: '\\' | '/'; + export const delimiter: ';' | ':'; + export const parse: typeof NodeJSPath.parse; + export const format: typeof NodeJSPath.format; + + + } + export module Math { + /** + * 取给定边界范围的值 + * Take the value of the given boundary range + * @param {number} val + * @param {number} min + * @param {number} max + */ + export function clamp(val: number, min: number, max: number): any; + /** + * @function clamp01 + * @param {number} val + * @returns {number} + * + * Clamps a value between 0 and 1. + */ + export function clamp01(val: number): number; + /** + * 加法函数 + * 入参:函数内部转化时会先转字符串再转数值,因而传入字符串或 number 均可 + * 返回值:arg1 加上 arg2 的精确结果 + * @param {number|string} arg1 + * @param {number|string} arg2 + */ + export function add(arg1: number | string, arg2: number | string): number; + /** + * 减法函数 + * 入参:函数内部转化时会先转字符串再转数值,因而传入字符串或number均可 + * 返回值:arg1 减 arg2的精确结果 + * @param {number|string} arg1 + * @param {number|string} arg2 + */ + export function sub(arg1: number | string, arg2: number | string): number; + /** + * 保留小数点 + * @param val + * @param num + */ + export function toFixed(val: number, num: number): number; + } + export module Parse { + interface WhenParam { + PanelName?: string; + EditMode?: string; + } + /** + * 解析 when 参数 + * when 的格式: + * PanelName === '' && EditMode === '' + * 整理后的数据格式: + * { + * PanelName: '', + * EditMode: '', + * } + */ + export function when(when: string): WhenParam; + /** + * 判断一个 when 数据是否符合当前条件 + * @param when + */ + export function checkWhen(when: string): boolean; + } + export module Url { + /** + * 快捷获取文档路径 + * @param relativeUrl + * @param type + */ + export function getDocUrl(relativeUrl: string, type?: 'manual' | 'api'): string; + } + + export module UUID { + /** + * 压缩 UUID + * compress UUID + * @param uuid + * @param min + */ + export function compressUUID(uuid: string, min: boolean): string; + /** + * 解压 UUID + * decompress the UUID + * @param str + */ + export function decompressUUID(str: string): string; + /** + * 检查输入字符串是否是 UUID + * Check whether the input string is a UUID + * @param str + */ + export function isUUID(str: string): string; + /** + * 生成一个新的 uuid + */ + export function generate(): string; + } + } + } +} + diff --git a/MovementDemo/@types/electron.d.ts b/MovementDemo/@types/electron.d.ts new file mode 100644 index 0000000..e84cbb9 --- /dev/null +++ b/MovementDemo/@types/electron.d.ts @@ -0,0 +1,16092 @@ +// Type definitions for Electron 13.1.4 +// Project: http://electronjs.org/ +// Definitions by: The Electron Team +// Definitions: https://github.com/electron/electron-typescript-definitions + +/// + +type GlobalEvent = Event & { returnValue: any }; + +declare namespace Electron { + const NodeEventEmitter: typeof import('events').EventEmitter; + + class Accelerator extends String { + + } + interface App extends NodeJS.EventEmitter { + + // Docs: https://electronjs.org/docs/api/app + + /** + * Emitted when Chrome's accessibility support changes. This event fires when + * assistive technologies, such as screen readers, are enabled or disabled. See + * https://www.chromium.org/developers/design-documents/accessibility for more + * details. + * + * @platform darwin,win32 + */ + on(event: 'accessibility-support-changed', listener: (event: Event, + /** + * `true` when Chrome's accessibility support is enabled, `false` otherwise. + */ + accessibilitySupportEnabled: boolean) => void): this; + once(event: 'accessibility-support-changed', listener: (event: Event, + /** + * `true` when Chrome's accessibility support is enabled, `false` otherwise. + */ + accessibilitySupportEnabled: boolean) => void): this; + addListener(event: 'accessibility-support-changed', listener: (event: Event, + /** + * `true` when Chrome's accessibility support is enabled, `false` otherwise. + */ + accessibilitySupportEnabled: boolean) => void): this; + removeListener(event: 'accessibility-support-changed', listener: (event: Event, + /** + * `true` when Chrome's accessibility support is enabled, `false` otherwise. + */ + accessibilitySupportEnabled: boolean) => void): this; + /** + * Emitted when the application is activated. Various actions can trigger this + * event, such as launching the application for the first time, attempting to + * re-launch the application when it's already running, or clicking on the + * application's dock or taskbar icon. + * + * @platform darwin + */ + on(event: 'activate', listener: (event: Event, + hasVisibleWindows: boolean) => void): this; + once(event: 'activate', listener: (event: Event, + hasVisibleWindows: boolean) => void): this; + addListener(event: 'activate', listener: (event: Event, + hasVisibleWindows: boolean) => void): this; + removeListener(event: 'activate', listener: (event: Event, + hasVisibleWindows: boolean) => void): this; + /** + * Emitted during Handoff after an activity from this device was successfully + * resumed on another one. + * + * @platform darwin + */ + on(event: 'activity-was-continued', listener: (event: Event, + /** + * A string identifying the activity. Maps to `NSUserActivity.activityType`. + */ + type: string, + /** + * Contains app-specific state stored by the activity. + */ + userInfo: unknown) => void): this; + once(event: 'activity-was-continued', listener: (event: Event, + /** + * A string identifying the activity. Maps to `NSUserActivity.activityType`. + */ + type: string, + /** + * Contains app-specific state stored by the activity. + */ + userInfo: unknown) => void): this; + addListener(event: 'activity-was-continued', listener: (event: Event, + /** + * A string identifying the activity. Maps to `NSUserActivity.activityType`. + */ + type: string, + /** + * Contains app-specific state stored by the activity. + */ + userInfo: unknown) => void): this; + removeListener(event: 'activity-was-continued', listener: (event: Event, + /** + * A string identifying the activity. Maps to `NSUserActivity.activityType`. + */ + type: string, + /** + * Contains app-specific state stored by the activity. + */ + userInfo: unknown) => void): this; + /** + * Emitted before the application starts closing its windows. Calling + * `event.preventDefault()` will prevent the default behavior, which is terminating + * the application. + * + * **Note:** If application quit was initiated by `autoUpdater.quitAndInstall()`, + * then `before-quit` is emitted *after* emitting `close` event on all windows and + * closing them. + * + * **Note:** On Windows, this event will not be emitted if the app is closed due to + * a shutdown/restart of the system or a user logout. + */ + on(event: 'before-quit', listener: (event: Event) => void): this; + once(event: 'before-quit', listener: (event: Event) => void): this; + addListener(event: 'before-quit', listener: (event: Event) => void): this; + removeListener(event: 'before-quit', listener: (event: Event) => void): this; + /** + * Emitted when a browserWindow gets blurred. + */ + on(event: 'browser-window-blur', listener: (event: Event, + window: BrowserWindow) => void): this; + once(event: 'browser-window-blur', listener: (event: Event, + window: BrowserWindow) => void): this; + addListener(event: 'browser-window-blur', listener: (event: Event, + window: BrowserWindow) => void): this; + removeListener(event: 'browser-window-blur', listener: (event: Event, + window: BrowserWindow) => void): this; + /** + * Emitted when a new browserWindow is created. + */ + on(event: 'browser-window-created', listener: (event: Event, + window: BrowserWindow) => void): this; + once(event: 'browser-window-created', listener: (event: Event, + window: BrowserWindow) => void): this; + addListener(event: 'browser-window-created', listener: (event: Event, + window: BrowserWindow) => void): this; + removeListener(event: 'browser-window-created', listener: (event: Event, + window: BrowserWindow) => void): this; + /** + * Emitted when a browserWindow gets focused. + */ + on(event: 'browser-window-focus', listener: (event: Event, + window: BrowserWindow) => void): this; + once(event: 'browser-window-focus', listener: (event: Event, + window: BrowserWindow) => void): this; + addListener(event: 'browser-window-focus', listener: (event: Event, + window: BrowserWindow) => void): this; + removeListener(event: 'browser-window-focus', listener: (event: Event, + window: BrowserWindow) => void): this; + /** + * Emitted when failed to verify the `certificate` for `url`, to trust the + * certificate you should prevent the default behavior with + * `event.preventDefault()` and call `callback(true)`. + */ + on(event: 'certificate-error', listener: (event: Event, + webContents: WebContents, + url: string, + /** + * The error code + */ + error: string, + certificate: Certificate, + callback: (isTrusted: boolean) => void) => void): this; + once(event: 'certificate-error', listener: (event: Event, + webContents: WebContents, + url: string, + /** + * The error code + */ + error: string, + certificate: Certificate, + callback: (isTrusted: boolean) => void) => void): this; + addListener(event: 'certificate-error', listener: (event: Event, + webContents: WebContents, + url: string, + /** + * The error code + */ + error: string, + certificate: Certificate, + callback: (isTrusted: boolean) => void) => void): this; + removeListener(event: 'certificate-error', listener: (event: Event, + webContents: WebContents, + url: string, + /** + * The error code + */ + error: string, + certificate: Certificate, + callback: (isTrusted: boolean) => void) => void): this; + /** + * Emitted when the child process unexpectedly disappears. This is normally because + * it was crashed or killed. It does not include renderer processes. + */ + on(event: 'child-process-gone', listener: (event: Event, + details: Details) => void): this; + once(event: 'child-process-gone', listener: (event: Event, + details: Details) => void): this; + addListener(event: 'child-process-gone', listener: (event: Event, + details: Details) => void): this; + removeListener(event: 'child-process-gone', listener: (event: Event, + details: Details) => void): this; + /** + * Emitted during Handoff when an activity from a different device wants to be + * resumed. You should call `event.preventDefault()` if you want to handle this + * event. + * + * A user activity can be continued only in an app that has the same developer Team + * ID as the activity's source app and that supports the activity's type. Supported + * activity types are specified in the app's `Info.plist` under the + * `NSUserActivityTypes` key. + * + * @platform darwin + */ + on(event: 'continue-activity', listener: (event: Event, + /** + * A string identifying the activity. Maps to `NSUserActivity.activityType`. + */ + type: string, + /** + * Contains app-specific state stored by the activity on another device. + */ + userInfo: unknown) => void): this; + once(event: 'continue-activity', listener: (event: Event, + /** + * A string identifying the activity. Maps to `NSUserActivity.activityType`. + */ + type: string, + /** + * Contains app-specific state stored by the activity on another device. + */ + userInfo: unknown) => void): this; + addListener(event: 'continue-activity', listener: (event: Event, + /** + * A string identifying the activity. Maps to `NSUserActivity.activityType`. + */ + type: string, + /** + * Contains app-specific state stored by the activity on another device. + */ + userInfo: unknown) => void): this; + removeListener(event: 'continue-activity', listener: (event: Event, + /** + * A string identifying the activity. Maps to `NSUserActivity.activityType`. + */ + type: string, + /** + * Contains app-specific state stored by the activity on another device. + */ + userInfo: unknown) => void): this; + /** + * Emitted during Handoff when an activity from a different device fails to be + * resumed. + * + * @platform darwin + */ + on(event: 'continue-activity-error', listener: (event: Event, + /** + * A string identifying the activity. Maps to `NSUserActivity.activityType`. + */ + type: string, + /** + * A string with the error's localized description. + */ + error: string) => void): this; + once(event: 'continue-activity-error', listener: (event: Event, + /** + * A string identifying the activity. Maps to `NSUserActivity.activityType`. + */ + type: string, + /** + * A string with the error's localized description. + */ + error: string) => void): this; + addListener(event: 'continue-activity-error', listener: (event: Event, + /** + * A string identifying the activity. Maps to `NSUserActivity.activityType`. + */ + type: string, + /** + * A string with the error's localized description. + */ + error: string) => void): this; + removeListener(event: 'continue-activity-error', listener: (event: Event, + /** + * A string identifying the activity. Maps to `NSUserActivity.activityType`. + */ + type: string, + /** + * A string with the error's localized description. + */ + error: string) => void): this; + /** + * Emitted when `desktopCapturer.getSources()` is called in the renderer process of + * `webContents`. Calling `event.preventDefault()` will make it return empty + * sources. + */ + on(event: 'desktop-capturer-get-sources', listener: (event: Event, + webContents: WebContents) => void): this; + once(event: 'desktop-capturer-get-sources', listener: (event: Event, + webContents: WebContents) => void): this; + addListener(event: 'desktop-capturer-get-sources', listener: (event: Event, + webContents: WebContents) => void): this; + removeListener(event: 'desktop-capturer-get-sources', listener: (event: Event, + webContents: WebContents) => void): this; + /** + * Emitted when mac application become active. Difference from `activate` event is + * that `did-become-active` is emitted every time the app becomes active, not only + * when Dock icon is clicked or application is re-launched. + * + * @platform darwin + */ + on(event: 'did-become-active', listener: (event: Event) => void): this; + once(event: 'did-become-active', listener: (event: Event) => void): this; + addListener(event: 'did-become-active', listener: (event: Event) => void): this; + removeListener(event: 'did-become-active', listener: (event: Event) => void): this; + /** + * Emitted whenever there is a GPU info update. + */ + on(event: 'gpu-info-update', listener: Function): this; + once(event: 'gpu-info-update', listener: Function): this; + addListener(event: 'gpu-info-update', listener: Function): this; + removeListener(event: 'gpu-info-update', listener: Function): this; + /** + * Emitted when the GPU process crashes or is killed. + * + * **Deprecated:** This event is superceded by the `child-process-gone` event which + * contains more information about why the child process disappeared. It isn't + * always because it crashed. The `killed` boolean can be replaced by checking + * `reason === 'killed'` when you switch to that event. + * + * @deprecated + */ + on(event: 'gpu-process-crashed', listener: (event: Event, + killed: boolean) => void): this; + once(event: 'gpu-process-crashed', listener: (event: Event, + killed: boolean) => void): this; + addListener(event: 'gpu-process-crashed', listener: (event: Event, + killed: boolean) => void): this; + removeListener(event: 'gpu-process-crashed', listener: (event: Event, + killed: boolean) => void): this; + /** + * Emitted when `webContents` wants to do basic auth. + * + * The default behavior is to cancel all authentications. To override this you + * should prevent the default behavior with `event.preventDefault()` and call + * `callback(username, password)` with the credentials. + * + * If `callback` is called without a username or password, the authentication + * request will be cancelled and the authentication error will be returned to the + * page. + */ + on(event: 'login', listener: (event: Event, + webContents: WebContents, + authenticationResponseDetails: AuthenticationResponseDetails, + authInfo: AuthInfo, + callback: (username?: string, password?: string) => void) => void): this; + once(event: 'login', listener: (event: Event, + webContents: WebContents, + authenticationResponseDetails: AuthenticationResponseDetails, + authInfo: AuthInfo, + callback: (username?: string, password?: string) => void) => void): this; + addListener(event: 'login', listener: (event: Event, + webContents: WebContents, + authenticationResponseDetails: AuthenticationResponseDetails, + authInfo: AuthInfo, + callback: (username?: string, password?: string) => void) => void): this; + removeListener(event: 'login', listener: (event: Event, + webContents: WebContents, + authenticationResponseDetails: AuthenticationResponseDetails, + authInfo: AuthInfo, + callback: (username?: string, password?: string) => void) => void): this; + /** + * Emitted when the user clicks the native macOS new tab button. The new tab button + * is only visible if the current `BrowserWindow` has a `tabbingIdentifier` + * + * @platform darwin + */ + on(event: 'new-window-for-tab', listener: (event: Event) => void): this; + once(event: 'new-window-for-tab', listener: (event: Event) => void): this; + addListener(event: 'new-window-for-tab', listener: (event: Event) => void): this; + removeListener(event: 'new-window-for-tab', listener: (event: Event) => void): this; + /** + * Emitted when the user wants to open a file with the application. The `open-file` + * event is usually emitted when the application is already open and the OS wants + * to reuse the application to open the file. `open-file` is also emitted when a + * file is dropped onto the dock and the application is not yet running. Make sure + * to listen for the `open-file` event very early in your application startup to + * handle this case (even before the `ready` event is emitted). + * + * You should call `event.preventDefault()` if you want to handle this event. + * + * On Windows, you have to parse `process.argv` (in the main process) to get the + * filepath. + * + * @platform darwin + */ + on(event: 'open-file', listener: (event: Event, + path: string) => void): this; + once(event: 'open-file', listener: (event: Event, + path: string) => void): this; + addListener(event: 'open-file', listener: (event: Event, + path: string) => void): this; + removeListener(event: 'open-file', listener: (event: Event, + path: string) => void): this; + /** + * Emitted when the user wants to open a URL with the application. Your + * application's `Info.plist` file must define the URL scheme within the + * `CFBundleURLTypes` key, and set `NSPrincipalClass` to `AtomApplication`. + * +You should call `event.preventDefault()` if you want to handle this event. + * + * @platform darwin + */ + on(event: 'open-url', listener: (event: Event, + url: string) => void): this; + once(event: 'open-url', listener: (event: Event, + url: string) => void): this; + addListener(event: 'open-url', listener: (event: Event, + url: string) => void): this; + removeListener(event: 'open-url', listener: (event: Event, + url: string) => void): this; + /** + * Emitted when the application is quitting. + * + * **Note:** On Windows, this event will not be emitted if the app is closed due to + * a shutdown/restart of the system or a user logout. + */ + on(event: 'quit', listener: (event: Event, + exitCode: number) => void): this; + once(event: 'quit', listener: (event: Event, + exitCode: number) => void): this; + addListener(event: 'quit', listener: (event: Event, + exitCode: number) => void): this; + removeListener(event: 'quit', listener: (event: Event, + exitCode: number) => void): this; + /** + * Emitted once, when Electron has finished initializing. On macOS, `launchInfo` + * holds the `userInfo` of the `NSUserNotification` or information from + * `UNNotificationResponse` that was used to open the application, if it was + * launched from Notification Center. You can also call `app.isReady()` to check if + * this event has already fired and `app.whenReady()` to get a Promise that is + * fulfilled when Electron is initialized. + */ + on(event: 'ready', listener: (event: Event, + launchInfo: (Record) | (NotificationResponse)) => void): this; + once(event: 'ready', listener: (event: Event, + launchInfo: (Record) | (NotificationResponse)) => void): this; + addListener(event: 'ready', listener: (event: Event, + launchInfo: (Record) | (NotificationResponse)) => void): this; + removeListener(event: 'ready', listener: (event: Event, + launchInfo: (Record) | (NotificationResponse)) => void): this; + /** + * Emitted when `remote.getBuiltin()` is called in the renderer process of + * `webContents`. Calling `event.preventDefault()` will prevent the module from + * being returned. Custom value can be returned by setting `event.returnValue`. + * + * @deprecated + */ + on(event: 'remote-get-builtin', listener: (event: Event, + webContents: WebContents, + moduleName: string) => void): this; + once(event: 'remote-get-builtin', listener: (event: Event, + webContents: WebContents, + moduleName: string) => void): this; + addListener(event: 'remote-get-builtin', listener: (event: Event, + webContents: WebContents, + moduleName: string) => void): this; + removeListener(event: 'remote-get-builtin', listener: (event: Event, + webContents: WebContents, + moduleName: string) => void): this; + /** + * Emitted when `remote.getCurrentWebContents()` is called in the renderer process + * of `webContents`. Calling `event.preventDefault()` will prevent the object from + * being returned. Custom value can be returned by setting `event.returnValue`. + * + * @deprecated + */ + on(event: 'remote-get-current-web-contents', listener: (event: Event, + webContents: WebContents) => void): this; + once(event: 'remote-get-current-web-contents', listener: (event: Event, + webContents: WebContents) => void): this; + addListener(event: 'remote-get-current-web-contents', listener: (event: Event, + webContents: WebContents) => void): this; + removeListener(event: 'remote-get-current-web-contents', listener: (event: Event, + webContents: WebContents) => void): this; + /** + * Emitted when `remote.getCurrentWindow()` is called in the renderer process of + * `webContents`. Calling `event.preventDefault()` will prevent the object from + * being returned. Custom value can be returned by setting `event.returnValue`. + * + * @deprecated + */ + on(event: 'remote-get-current-window', listener: (event: Event, + webContents: WebContents) => void): this; + once(event: 'remote-get-current-window', listener: (event: Event, + webContents: WebContents) => void): this; + addListener(event: 'remote-get-current-window', listener: (event: Event, + webContents: WebContents) => void): this; + removeListener(event: 'remote-get-current-window', listener: (event: Event, + webContents: WebContents) => void): this; + /** + * Emitted when `remote.getGlobal()` is called in the renderer process of + * `webContents`. Calling `event.preventDefault()` will prevent the global from + * being returned. Custom value can be returned by setting `event.returnValue`. + * + * @deprecated + */ + on(event: 'remote-get-global', listener: (event: Event, + webContents: WebContents, + globalName: string) => void): this; + once(event: 'remote-get-global', listener: (event: Event, + webContents: WebContents, + globalName: string) => void): this; + addListener(event: 'remote-get-global', listener: (event: Event, + webContents: WebContents, + globalName: string) => void): this; + removeListener(event: 'remote-get-global', listener: (event: Event, + webContents: WebContents, + globalName: string) => void): this; + /** + * Emitted when `remote.require()` is called in the renderer process of + * `webContents`. Calling `event.preventDefault()` will prevent the module from + * being returned. Custom value can be returned by setting `event.returnValue`. + * + * @deprecated + */ + on(event: 'remote-require', listener: (event: Event, + webContents: WebContents, + moduleName: string) => void): this; + once(event: 'remote-require', listener: (event: Event, + webContents: WebContents, + moduleName: string) => void): this; + addListener(event: 'remote-require', listener: (event: Event, + webContents: WebContents, + moduleName: string) => void): this; + removeListener(event: 'remote-require', listener: (event: Event, + webContents: WebContents, + moduleName: string) => void): this; + /** + * Emitted when the renderer process unexpectedly disappears. This is normally + * because it was crashed or killed. + */ + on(event: 'render-process-gone', listener: (event: Event, + webContents: WebContents, + details: RenderProcessGoneDetails) => void): this; + once(event: 'render-process-gone', listener: (event: Event, + webContents: WebContents, + details: RenderProcessGoneDetails) => void): this; + addListener(event: 'render-process-gone', listener: (event: Event, + webContents: WebContents, + details: RenderProcessGoneDetails) => void): this; + removeListener(event: 'render-process-gone', listener: (event: Event, + webContents: WebContents, + details: RenderProcessGoneDetails) => void): this; + /** + * Emitted when the renderer process of `webContents` crashes or is killed. + * + * **Deprecated:** This event is superceded by the `render-process-gone` event + * which contains more information about why the render process disappeared. It + * isn't always because it crashed. The `killed` boolean can be replaced by + * checking `reason === 'killed'` when you switch to that event. + * + * @deprecated + */ + on(event: 'renderer-process-crashed', listener: (event: Event, + webContents: WebContents, + killed: boolean) => void): this; + once(event: 'renderer-process-crashed', listener: (event: Event, + webContents: WebContents, + killed: boolean) => void): this; + addListener(event: 'renderer-process-crashed', listener: (event: Event, + webContents: WebContents, + killed: boolean) => void): this; + removeListener(event: 'renderer-process-crashed', listener: (event: Event, + webContents: WebContents, + killed: boolean) => void): this; + /** + * This event will be emitted inside the primary instance of your application when + * a second instance has been executed and calls `app.requestSingleInstanceLock()`. + * + * `argv` is an Array of the second instance's command line arguments, and + * `workingDirectory` is its current working directory. Usually applications + * respond to this by making their primary window focused and non-minimized. + * + * **Note:** If the second instance is started by a different user than the first, + * the `argv` array will not include the arguments. + * + * This event is guaranteed to be emitted after the `ready` event of `app` gets + * emitted. + * + * **Note:** Extra command line arguments might be added by Chromium, such as + * `--original-process-start-time`. + */ + on(event: 'second-instance', listener: (event: Event, + /** + * An array of the second instance's command line arguments + */ + argv: string[], + /** + * The second instance's working directory + */ + workingDirectory: string) => void): this; + once(event: 'second-instance', listener: (event: Event, + /** + * An array of the second instance's command line arguments + */ + argv: string[], + /** + * The second instance's working directory + */ + workingDirectory: string) => void): this; + addListener(event: 'second-instance', listener: (event: Event, + /** + * An array of the second instance's command line arguments + */ + argv: string[], + /** + * The second instance's working directory + */ + workingDirectory: string) => void): this; + removeListener(event: 'second-instance', listener: (event: Event, + /** + * An array of the second instance's command line arguments + */ + argv: string[], + /** + * The second instance's working directory + */ + workingDirectory: string) => void): this; + /** + * Emitted when a client certificate is requested. + * + * The `url` corresponds to the navigation entry requesting the client certificate + * and `callback` can be called with an entry filtered from the list. Using + * `event.preventDefault()` prevents the application from using the first + * certificate from the store. + */ + on(event: 'select-client-certificate', listener: (event: Event, + webContents: WebContents, + url: string, + certificateList: Certificate[], + callback: (certificate?: Certificate) => void) => void): this; + once(event: 'select-client-certificate', listener: (event: Event, + webContents: WebContents, + url: string, + certificateList: Certificate[], + callback: (certificate?: Certificate) => void) => void): this; + addListener(event: 'select-client-certificate', listener: (event: Event, + webContents: WebContents, + url: string, + certificateList: Certificate[], + callback: (certificate?: Certificate) => void) => void): this; + removeListener(event: 'select-client-certificate', listener: (event: Event, + webContents: WebContents, + url: string, + certificateList: Certificate[], + callback: (certificate?: Certificate) => void) => void): this; + /** + * Emitted when Electron has created a new `session`. + */ + on(event: 'session-created', listener: (session: Session) => void): this; + once(event: 'session-created', listener: (session: Session) => void): this; + addListener(event: 'session-created', listener: (session: Session) => void): this; + removeListener(event: 'session-created', listener: (session: Session) => void): this; + /** + * Emitted when Handoff is about to be resumed on another device. If you need to + * update the state to be transferred, you should call `event.preventDefault()` + * immediately, construct a new `userInfo` dictionary and call + * `app.updateCurrentActivity()` in a timely manner. Otherwise, the operation will + * fail and `continue-activity-error` will be called. + * + * @platform darwin + */ + on(event: 'update-activity-state', listener: (event: Event, + /** + * A string identifying the activity. Maps to `NSUserActivity.activityType`. + */ + type: string, + /** + * Contains app-specific state stored by the activity. + */ + userInfo: unknown) => void): this; + once(event: 'update-activity-state', listener: (event: Event, + /** + * A string identifying the activity. Maps to `NSUserActivity.activityType`. + */ + type: string, + /** + * Contains app-specific state stored by the activity. + */ + userInfo: unknown) => void): this; + addListener(event: 'update-activity-state', listener: (event: Event, + /** + * A string identifying the activity. Maps to `NSUserActivity.activityType`. + */ + type: string, + /** + * Contains app-specific state stored by the activity. + */ + userInfo: unknown) => void): this; + removeListener(event: 'update-activity-state', listener: (event: Event, + /** + * A string identifying the activity. Maps to `NSUserActivity.activityType`. + */ + type: string, + /** + * Contains app-specific state stored by the activity. + */ + userInfo: unknown) => void): this; + /** + * Emitted when a new webContents is created. + */ + on(event: 'web-contents-created', listener: (event: Event, + webContents: WebContents) => void): this; + once(event: 'web-contents-created', listener: (event: Event, + webContents: WebContents) => void): this; + addListener(event: 'web-contents-created', listener: (event: Event, + webContents: WebContents) => void): this; + removeListener(event: 'web-contents-created', listener: (event: Event, + webContents: WebContents) => void): this; + /** + * Emitted during Handoff before an activity from a different device wants to be + * resumed. You should call `event.preventDefault()` if you want to handle this + * event. + * + * @platform darwin + */ + on(event: 'will-continue-activity', listener: (event: Event, + /** + * A string identifying the activity. Maps to `NSUserActivity.activityType`. + */ + type: string) => void): this; + once(event: 'will-continue-activity', listener: (event: Event, + /** + * A string identifying the activity. Maps to `NSUserActivity.activityType`. + */ + type: string) => void): this; + addListener(event: 'will-continue-activity', listener: (event: Event, + /** + * A string identifying the activity. Maps to `NSUserActivity.activityType`. + */ + type: string) => void): this; + removeListener(event: 'will-continue-activity', listener: (event: Event, + /** + * A string identifying the activity. Maps to `NSUserActivity.activityType`. + */ + type: string) => void): this; + /** + * Emitted when the application has finished basic startup. On Windows and Linux, + * the `will-finish-launching` event is the same as the `ready` event; on macOS, + * this event represents the `applicationWillFinishLaunching` notification of + * `NSApplication`. You would usually set up listeners for the `open-file` and + * `open-url` events here, and start the crash reporter and auto updater. + * +In most cases, you should do everything in the `ready` event handler. + */ + on(event: 'will-finish-launching', listener: Function): this; + once(event: 'will-finish-launching', listener: Function): this; + addListener(event: 'will-finish-launching', listener: Function): this; + removeListener(event: 'will-finish-launching', listener: Function): this; + /** + * Emitted when all windows have been closed and the application will quit. Calling + * `event.preventDefault()` will prevent the default behavior, which is terminating + * the application. + * + * See the description of the `window-all-closed` event for the differences between + * the `will-quit` and `window-all-closed` events. + * + * **Note:** On Windows, this event will not be emitted if the app is closed due to + * a shutdown/restart of the system or a user logout. + */ + on(event: 'will-quit', listener: (event: Event) => void): this; + once(event: 'will-quit', listener: (event: Event) => void): this; + addListener(event: 'will-quit', listener: (event: Event) => void): this; + removeListener(event: 'will-quit', listener: (event: Event) => void): this; + /** + * Emitted when all windows have been closed. + * + * If you do not subscribe to this event and all windows are closed, the default + * behavior is to quit the app; however, if you subscribe, you control whether the + * app quits or not. If the user pressed `Cmd + Q`, or the developer called + * `app.quit()`, Electron will first try to close all the windows and then emit the + * `will-quit` event, and in this case the `window-all-closed` event would not be + * emitted. + */ + on(event: 'window-all-closed', listener: Function): this; + once(event: 'window-all-closed', listener: Function): this; + addListener(event: 'window-all-closed', listener: Function): this; + removeListener(event: 'window-all-closed', listener: Function): this; + /** + * Adds `path` to the recent documents list. + * + * This list is managed by the OS. On Windows, you can visit the list from the task + * bar, and on macOS, you can visit it from dock menu. + * + * @platform darwin,win32 + */ + addRecentDocument(path: string): void; + /** + * Clears the recent documents list. + * + * @platform darwin,win32 + */ + clearRecentDocuments(): void; + /** + * By default, Chromium disables 3D APIs (e.g. WebGL) until restart on a per domain + * basis if the GPU processes crashes too frequently. This function disables that + * behavior. + +This method can only be called before app is ready. + */ + disableDomainBlockingFor3DAPIs(): void; + /** + * Disables hardware acceleration for current app. + * +This method can only be called before app is ready. + */ + disableHardwareAcceleration(): void; + /** + * Enables full sandbox mode on the app. This means that all renderers will be + * launched sandboxed, regardless of the value of the `sandbox` flag in + * WebPreferences. + +This method can only be called before app is ready. + */ + enableSandbox(): void; + /** + * Exits immediately with `exitCode`. `exitCode` defaults to 0. + * + * All windows will be closed immediately without asking the user, and the + * `before-quit` and `will-quit` events will not be emitted. + */ + exit(exitCode?: number): void; + /** + * On Linux, focuses on the first visible window. On macOS, makes the application + * the active app. On Windows, focuses on the application's first window. + * +You should seek to use the `steal` option as sparingly as possible. + */ + focus(options?: FocusOptions): void; + /** + * Resolve with an object containing the following: + * + * * `icon` NativeImage - the display icon of the app handling the protocol. + * * `path` String - installation path of the app handling the protocol. + * * `name` String - display name of the app handling the protocol. + * + * This method returns a promise that contains the application name, icon and path + * of the default handler for the protocol (aka URI scheme) of a URL. + * + * @platform darwin,win32 + */ + getApplicationInfoForProtocol(url: string): Promise; + /** + * Name of the application handling the protocol, or an empty string if there is no + * handler. For instance, if Electron is the default handler of the URL, this could + * be `Electron` on Windows and Mac. However, don't rely on the precise format + * which is not guaranteed to remain unchanged. Expect a different format on Linux, + * possibly with a `.desktop` suffix. + * + * This method returns the application name of the default handler for the protocol + * (aka URI scheme) of a URL. + */ + getApplicationNameForProtocol(url: string): string; + /** + * Array of `ProcessMetric` objects that correspond to memory and CPU usage + * statistics of all the processes associated with the app. + */ + getAppMetrics(): ProcessMetric[]; + /** + * The current application directory. + */ + getAppPath(): string; + /** + * The current value displayed in the counter badge. + * + * @platform linux,darwin + */ + getBadgeCount(): number; + /** + * The type of the currently running activity. + * + * @platform darwin + */ + getCurrentActivityType(): string; + /** + * fulfilled with the app's icon, which is a NativeImage. + * + * Fetches a path's associated icon. + * + * On _Windows_, there a 2 kinds of icons: + * + * * Icons associated with certain file extensions, like `.mp3`, `.png`, etc. + * * Icons inside the file itself, like `.exe`, `.dll`, `.ico`. + * + * On _Linux_ and _macOS_, icons depend on the application associated with file + * mime type. + */ + getFileIcon(path: string, options?: FileIconOptions): Promise; + /** + * The Graphics Feature Status from `chrome://gpu/`. + * + * **Note:** This information is only usable after the `gpu-info-update` event is + * emitted. + */ + getGPUFeatureStatus(): GPUFeatureStatus; + /** + * For `infoType` equal to `complete`: Promise is fulfilled with `Object` + * containing all the GPU Information as in chromium's GPUInfo object. This + * includes the version and driver information that's shown on `chrome://gpu` page. + * + * For `infoType` equal to `basic`: Promise is fulfilled with `Object` containing + * fewer attributes than when requested with `complete`. Here's an example of basic + * response: + * + * Using `basic` should be preferred if only basic information like `vendorId` or + * `driverId` is needed. + */ + getGPUInfo(infoType: 'basic' | 'complete'): Promise; + /** + * * `minItems` Integer - The minimum number of items that will be shown in the + * Jump List (for a more detailed description of this value see the MSDN docs). + * * `removedItems` JumpListItem[] - Array of `JumpListItem` objects that + * correspond to items that the user has explicitly removed from custom categories + * in the Jump List. These items must not be re-added to the Jump List in the + * **next** call to `app.setJumpList()`, Windows will not display any custom + * category that contains any of the removed items. + * + * @platform win32 + */ + getJumpListSettings(): JumpListSettings; + /** + * The current application locale, fetched using Chromium's `l10n_util` library. + * Possible return values are documented here. + * + * To set the locale, you'll want to use a command line switch at app startup, + * which may be found here. + * + * **Note:** When distributing your packaged app, you have to also ship the + * `locales` folder. + * + * **Note:** On Windows, you have to call it after the `ready` events gets emitted. + */ + getLocale(): string; + /** + * User operating system's locale two-letter ISO 3166 country code. The value is + * taken from native OS APIs. + * +**Note:** When unable to detect locale country code, it returns empty string. + */ + getLocaleCountryCode(): string; + /** + * If you provided `path` and `args` options to `app.setLoginItemSettings`, then + * you need to pass the same arguments here for `openAtLogin` to be set correctly. + * + * + * * `openAtLogin` Boolean - `true` if the app is set to open at login. + * * `openAsHidden` Boolean _macOS_ - `true` if the app is set to open as hidden at + * login. This setting is not available on MAS builds. + * * `wasOpenedAtLogin` Boolean _macOS_ - `true` if the app was opened at login + * automatically. This setting is not available on MAS builds. + * * `wasOpenedAsHidden` Boolean _macOS_ - `true` if the app was opened as a hidden + * login item. This indicates that the app should not open any windows at startup. + * This setting is not available on MAS builds. + * * `restoreState` Boolean _macOS_ - `true` if the app was opened as a login item + * that should restore the state from the previous session. This indicates that the + * app should restore the windows that were open the last time the app was closed. + * This setting is not available on MAS builds. + * * `executableWillLaunchAtLogin` Boolean _Windows_ - `true` if app is set to open + * at login and its run key is not deactivated. This differs from `openAtLogin` as + * it ignores the `args` option, this property will be true if the given executable + * would be launched at login with **any** arguments. + * * `launchItems` Object[] _Windows_ + * * `name` String _Windows_ - name value of a registry entry. + * * `path` String _Windows_ - The executable to an app that corresponds to a + * registry entry. + * * `args` String[] _Windows_ - the command-line arguments to pass to the + * executable. + * * `scope` String _Windows_ - one of `user` or `machine`. Indicates whether the + * registry entry is under `HKEY_CURRENT USER` or `HKEY_LOCAL_MACHINE`. + * * `enabled` Boolean _Windows_ - `true` if the app registry key is startup + * approved and therefore shows as `enabled` in Task Manager and Windows settings. + * + * @platform darwin,win32 + */ + getLoginItemSettings(options?: LoginItemSettingsOptions): LoginItemSettings; + /** + * The current application's name, which is the name in the application's + * `package.json` file. + * + * Usually the `name` field of `package.json` is a short lowercase name, according + * to the npm modules spec. You should usually also specify a `productName` field, + * which is your application's full capitalized name, and which will be preferred + * over `name` by Electron. + */ + getName(): string; + /** + * A path to a special directory or file associated with `name`. On failure, an + * `Error` is thrown. + * + * If `app.getPath('logs')` is called without called `app.setAppLogsPath()` being + * called first, a default log directory will be created equivalent to calling + * `app.setAppLogsPath()` without a `path` parameter. + */ + getPath(name: 'home' | 'appData' | 'userData' | 'cache' | 'temp' | 'exe' | 'module' | 'desktop' | 'documents' | 'downloads' | 'music' | 'pictures' | 'videos' | 'recent' | 'logs' | 'crashDumps'): string; + /** + * The version of the loaded application. If no version is found in the + * application's `package.json` file, the version of the current bundle or + * executable is returned. + */ + getVersion(): string; + /** + * This method returns whether or not this instance of your app is currently + * holding the single instance lock. You can request the lock with + * `app.requestSingleInstanceLock()` and release with + * `app.releaseSingleInstanceLock()` + */ + hasSingleInstanceLock(): boolean; + /** + * Hides all application windows without minimizing them. + * + * @platform darwin + */ + hide(): void; + /** + * Imports the certificate in pkcs12 format into the platform certificate store. + * `callback` is called with the `result` of import operation, a value of `0` + * indicates success while any other value indicates failure according to Chromium + * net_error_list. + * + * @platform linux + */ + importCertificate(options: ImportCertificateOptions, callback: (result: number) => void): void; + /** + * Invalidates the current Handoff user activity. + * + * @platform darwin + */ + invalidateCurrentActivity(): void; + /** + * `true` if Chrome's accessibility support is enabled, `false` otherwise. This API + * will return `true` if the use of assistive technologies, such as screen readers, + * has been detected. See + * https://www.chromium.org/developers/design-documents/accessibility for more + * details. + * + * @platform darwin,win32 + */ + isAccessibilitySupportEnabled(): boolean; + /** + * Whether the current executable is the default handler for a protocol (aka URI + * scheme). + * + * **Note:** On macOS, you can use this method to check if the app has been + * registered as the default protocol handler for a protocol. You can also verify + * this by checking `~/Library/Preferences/com.apple.LaunchServices.plist` on the + * macOS machine. Please refer to Apple's documentation for details. + * + * The API uses the Windows Registry and `LSCopyDefaultHandlerForURLScheme` + * internally. + */ + isDefaultProtocolClient(protocol: string, path?: string, args?: string[]): boolean; + /** + * whether or not the current OS version allows for native emoji pickers. + */ + isEmojiPanelSupported(): boolean; + /** + * Whether the application is currently running from the systems Application + * folder. Use in combination with `app.moveToApplicationsFolder()` + * + * @platform darwin + */ + isInApplicationsFolder(): boolean; + /** + * `true` if Electron has finished initializing, `false` otherwise. See also + * `app.whenReady()`. + */ + isReady(): boolean; + /** + * whether `Secure Keyboard Entry` is enabled. + * +By default this API will return `false`. + * + * @platform darwin + */ + isSecureKeyboardEntryEnabled(): boolean; + /** + * Whether the current desktop environment is Unity launcher. + * + * @platform linux + */ + isUnityRunning(): boolean; + /** + * Whether the move was successful. Please note that if the move is successful, + * your application will quit and relaunch. + * + * No confirmation dialog will be presented by default. If you wish to allow the + * user to confirm the operation, you may do so using the `dialog` API. + * + * **NOTE:** This method throws errors if anything other than the user causes the + * move to fail. For instance if the user cancels the authorization dialog, this + * method returns false. If we fail to perform the copy, then this method will + * throw an error. The message in the error should be informative and tell you + * exactly what went wrong. + * + * By default, if an app of the same name as the one being moved exists in the + * Applications directory and is _not_ running, the existing app will be trashed + * and the active app moved into its place. If it _is_ running, the pre-existing + * running app will assume focus and the previously active app will quit itself. + * This behavior can be changed by providing the optional conflict handler, where + * the boolean returned by the handler determines whether or not the move conflict + * is resolved with default behavior. i.e. returning `false` will ensure no + * further action is taken, returning `true` will result in the default behavior + * and the method continuing. + * + * For example: + * + * Would mean that if an app already exists in the user directory, if the user + * chooses to 'Continue Move' then the function would continue with its default + * behavior and the existing app will be trashed and the active app moved into its + * place. + * + * @platform darwin + */ + moveToApplicationsFolder(options?: MoveToApplicationsFolderOptions): boolean; + /** + * Try to close all windows. The `before-quit` event will be emitted first. If all + * windows are successfully closed, the `will-quit` event will be emitted and by + * default the application will terminate. + * + * This method guarantees that all `beforeunload` and `unload` event handlers are + * correctly executed. It is possible that a window cancels the quitting by + * returning `false` in the `beforeunload` event handler. + */ + quit(): void; + /** + * Relaunches the app when current instance exits. + * + * By default, the new instance will use the same working directory and command + * line arguments with current instance. When `args` is specified, the `args` will + * be passed as command line arguments instead. When `execPath` is specified, the + * `execPath` will be executed for relaunch instead of current app. + * + * Note that this method does not quit the app when executed, you have to call + * `app.quit` or `app.exit` after calling `app.relaunch` to make the app restart. + * + * When `app.relaunch` is called for multiple times, multiple instances will be + * started after current instance exited. + * + * An example of restarting current instance immediately and adding a new command + * line argument to the new instance: + */ + relaunch(options?: RelaunchOptions): void; + /** + * Releases all locks that were created by `requestSingleInstanceLock`. This will + * allow multiple instances of the application to once again run side by side. + */ + releaseSingleInstanceLock(): void; + /** + * Whether the call succeeded. + * + * This method checks if the current executable as the default handler for a + * protocol (aka URI scheme). If so, it will remove the app as the default handler. + * + * @platform darwin,win32 + */ + removeAsDefaultProtocolClient(protocol: string, path?: string, args?: string[]): boolean; + /** + * The return value of this method indicates whether or not this instance of your + * application successfully obtained the lock. If it failed to obtain the lock, + * you can assume that another instance of your application is already running with + * the lock and exit immediately. + * + * I.e. This method returns `true` if your process is the primary instance of your + * application and your app should continue loading. It returns `false` if your + * process should immediately quit as it has sent its parameters to another + * instance that has already acquired the lock. + * + * On macOS, the system enforces single instance automatically when users try to + * open a second instance of your app in Finder, and the `open-file` and `open-url` + * events will be emitted for that. However when users start your app in command + * line, the system's single instance mechanism will be bypassed, and you have to + * use this method to ensure single instance. + * + * An example of activating the window of primary instance when a second instance + * starts: + */ + requestSingleInstanceLock(): boolean; + /** + * Marks the current Handoff user activity as inactive without invalidating it. + * + * @platform darwin + */ + resignCurrentActivity(): void; + /** + * Set the about panel options. This will override the values defined in the app's + * `.plist` file on macOS. See the Apple docs for more details. On Linux, values + * must be set in order to be shown; there are no defaults. + * + * If you do not set `credits` but still wish to surface them in your app, AppKit + * will look for a file named "Credits.html", "Credits.rtf", and "Credits.rtfd", in + * that order, in the bundle returned by the NSBundle class method main. The first + * file found is used, and if none is found, the info area is left blank. See Apple + * documentation for more information. + */ + setAboutPanelOptions(options: AboutPanelOptionsOptions): void; + /** + * Manually enables Chrome's accessibility support, allowing to expose + * accessibility switch to users in application settings. See Chromium's + * accessibility docs for more details. Disabled by default. + * + * This API must be called after the `ready` event is emitted. + * + * **Note:** Rendering accessibility tree can significantly affect the performance + * of your app. It should not be enabled by default. + * + * @platform darwin,win32 + */ + setAccessibilitySupportEnabled(enabled: boolean): void; + /** + * Sets the activation policy for a given app. + * + * Activation policy types: + * + * * 'regular' - The application is an ordinary app that appears in the Dock and + * may have a user interface. + * * 'accessory' - The application doesn’t appear in the Dock and doesn’t have a + * menu bar, but it may be activated programmatically or by clicking on one of its + * windows. + * * 'prohibited' - The application doesn’t appear in the Dock and may not create + * windows or be activated. + * + * @platform darwin + */ + setActivationPolicy(policy: 'regular' | 'accessory' | 'prohibited'): void; + /** + * Sets or creates a directory your app's logs which can then be manipulated with + * `app.getPath()` or `app.setPath(pathName, newPath)`. + * + * Calling `app.setAppLogsPath()` without a `path` parameter will result in this + * directory being set to `~/Library/Logs/YourAppName` on _macOS_, and inside the + * `userData` directory on _Linux_ and _Windows_. + */ + setAppLogsPath(path?: string): void; + /** + * Changes the Application User Model ID to `id`. + * + * @platform win32 + */ + setAppUserModelId(id: string): void; + /** + * Whether the call succeeded. + * + * Sets the current executable as the default handler for a protocol (aka URI + * scheme). It allows you to integrate your app deeper into the operating system. + * Once registered, all links with `your-protocol://` will be opened with the + * current executable. The whole link, including protocol, will be passed to your + * application as a parameter. + * + * **Note:** On macOS, you can only register protocols that have been added to your + * app's `info.plist`, which cannot be modified at runtime. However, you can change + * the file during build time via Electron Forge, Electron Packager, or by editing + * `info.plist` with a text editor. Please refer to Apple's documentation for + * details. + * + * **Note:** In a Windows Store environment (when packaged as an `appx`) this API + * will return `true` for all calls but the registry key it sets won't be + * accessible by other applications. In order to register your Windows Store + * application as a default protocol handler you must declare the protocol in your + * manifest. + * + * The API uses the Windows Registry and `LSSetDefaultHandlerForURLScheme` + * internally. + */ + setAsDefaultProtocolClient(protocol: string, path?: string, args?: string[]): boolean; + /** + * Whether the call succeeded. + * + * Sets the counter badge for current app. Setting the count to `0` will hide the + * badge. + * + * On macOS, it shows on the dock icon. On Linux, it only works for Unity launcher. + * + * **Note:** Unity launcher requires the existence of a `.desktop` file to work, + * for more information please read Desktop Environment Integration. + * + * @platform linux,darwin + */ + setBadgeCount(count?: number): boolean; + /** + * Sets or removes a custom Jump List for the application, and returns one of the + * following strings: + * + * * `ok` - Nothing went wrong. + * * `error` - One or more errors occurred, enable runtime logging to figure out + * the likely cause. + * * `invalidSeparatorError` - An attempt was made to add a separator to a custom + * category in the Jump List. Separators are only allowed in the standard `Tasks` + * category. + * * `fileTypeRegistrationError` - An attempt was made to add a file link to the + * Jump List for a file type the app isn't registered to handle. + * * `customCategoryAccessDeniedError` - Custom categories can't be added to the + * Jump List due to user privacy or group policy settings. + * + * If `categories` is `null` the previously set custom Jump List (if any) will be + * replaced by the standard Jump List for the app (managed by Windows). + * + * **Note:** If a `JumpListCategory` object has neither the `type` nor the `name` + * property set then its `type` is assumed to be `tasks`. If the `name` property is + * set but the `type` property is omitted then the `type` is assumed to be + * `custom`. + * + * **Note:** Users can remove items from custom categories, and Windows will not + * allow a removed item to be added back into a custom category until **after** the + * next successful call to `app.setJumpList(categories)`. Any attempt to re-add a + * removed item to a custom category earlier than that will result in the entire + * custom category being omitted from the Jump List. The list of removed items can + * be obtained using `app.getJumpListSettings()`. + * + * **Note:** The maximum length of a Jump List item's `description` property is 260 + * characters. Beyond this limit, the item will not be added to the Jump List, nor + * will it be displayed. + * +Here's a very simple example of creating a custom Jump List: + * + * @platform win32 + */ + setJumpList(categories: (JumpListCategory[]) | (null)): void; + /** + * To work with Electron's `autoUpdater` on Windows, which uses Squirrel, you'll + * want to set the launch path to Update.exe, and pass arguments that specify your + * application name. For example: + * + * @platform darwin,win32 + */ + setLoginItemSettings(settings: Settings): void; + /** + * Overrides the current application's name. + * + * **Note:** This function overrides the name used internally by Electron; it does + * not affect the name that the OS uses. + */ + setName(name: string): void; + /** + * Overrides the `path` to a special directory or file associated with `name`. If + * the path specifies a directory that does not exist, an `Error` is thrown. In + * that case, the directory should be created with `fs.mkdirSync` or similar. + * + * You can only override paths of a `name` defined in `app.getPath`. + * + * By default, web pages' cookies and caches will be stored under the `userData` + * directory. If you want to change this location, you have to override the + * `userData` path before the `ready` event of the `app` module is emitted. + */ + setPath(name: string, path: string): void; + /** + * Set the `Secure Keyboard Entry` is enabled in your application. + * + * By using this API, important information such as password and other sensitive + * information can be prevented from being intercepted by other processes. + * + * See Apple's documentation for more details. + * + * **Note:** Enable `Secure Keyboard Entry` only when it is needed and disable it + * when it is no longer needed. + * + * @platform darwin + */ + setSecureKeyboardEntryEnabled(enabled: boolean): void; + /** + * Creates an `NSUserActivity` and sets it as the current activity. The activity is + * eligible for Handoff to another device afterward. + * + * @platform darwin + */ + setUserActivity(type: string, userInfo: any, webpageURL?: string): void; + /** + * Adds `tasks` to the Tasks category of the Jump List on Windows. + * + * `tasks` is an array of `Task` objects. + * + * Whether the call succeeded. + * + * **Note:** If you'd like to customize the Jump List even more use + * `app.setJumpList(categories)` instead. + * + * @platform win32 + */ + setUserTasks(tasks: Task[]): boolean; + /** + * Shows application windows after they were hidden. Does not automatically focus + * them. + * + * @platform darwin + */ + show(): void; + /** + * Show the app's about panel options. These options can be overridden with + * `app.setAboutPanelOptions(options)`. + */ + showAboutPanel(): void; + /** + * Show the platform's native emoji picker. + * + * @platform darwin,win32 + */ + showEmojiPanel(): void; + /** + * This function **must** be called once you have finished accessing the security + * scoped file. If you do not remember to stop accessing the bookmark, kernel + * resources will be leaked and your app will lose its ability to reach outside the + * sandbox completely, until your app is restarted. + * + * Start accessing a security scoped resource. With this method Electron + * applications that are packaged for the Mac App Store may reach outside their + * sandbox to access files chosen by the user. See Apple's documentation for a + * description of how this system works. + * + * @platform mas + */ + startAccessingSecurityScopedResource(bookmarkData: string): Function; + /** + * Updates the current activity if its type matches `type`, merging the entries + * from `userInfo` into its current `userInfo` dictionary. + * + * @platform darwin + */ + updateCurrentActivity(type: string, userInfo: any): void; + /** + * fulfilled when Electron is initialized. May be used as a convenient alternative + * to checking `app.isReady()` and subscribing to the `ready` event if the app is + * not ready yet. + */ + whenReady(): Promise; + /** + * A `Boolean` property that's `true` if Chrome's accessibility support is enabled, + * `false` otherwise. This property will be `true` if the use of assistive + * technologies, such as screen readers, has been detected. Setting this property + * to `true` manually enables Chrome's accessibility support, allowing developers + * to expose accessibility switch to users in application settings. + * + * See Chromium's accessibility docs for more details. Disabled by default. + * + * This API must be called after the `ready` event is emitted. + * + * **Note:** Rendering accessibility tree can significantly affect the performance + * of your app. It should not be enabled by default. + * + * @platform darwin,win32 + */ + accessibilitySupportEnabled: boolean; + /** + * A `Boolean` which when `true` disables the overrides that Electron has in place + * to ensure renderer processes are restarted on every navigation. The current + * default value for this property is `true`. + * + * The intention is for these overrides to become disabled by default and then at + * some point in the future this property will be removed. This property impacts + * which native modules you can use in the renderer process. For more information + * on the direction Electron is going with renderer process restarts and usage of + * native modules in the renderer process please check out this Tracking Issue. + */ + allowRendererProcessReuse: boolean; + /** + * A `Menu | null` property that returns `Menu` if one has been set and `null` + * otherwise. Users can pass a Menu to set this property. + */ + applicationMenu: (Menu) | (null); + /** + * An `Integer` property that returns the badge count for current app. Setting the + * count to `0` will hide the badge. + * + * On macOS, setting this with any nonzero integer shows on the dock icon. On + * Linux, this property only works for Unity launcher. + * + * **Note:** Unity launcher requires the existence of a `.desktop` file to work, + * for more information please read Desktop Environment Integration. + * + * **Note:** On macOS, you need to ensure that your application has the permission + * to display notifications for this property to take effect. + * + * @platform linux,darwin + */ + badgeCount: number; + /** + * A `CommandLine` object that allows you to read and manipulate the command line + * arguments that Chromium uses. + * + */ + readonly commandLine: CommandLine; + /** + * A `Dock` `| undefined` object that allows you to perform actions on your app + * icon in the user's dock on macOS. + * + * @platform darwin + */ + readonly dock: Dock; + /** + * A `Boolean` property that returns `true` if the app is packaged, `false` + * otherwise. For many apps, this property can be used to distinguish development + * and production environments. + * + */ + readonly isPackaged: boolean; + /** + * A `String` property that indicates the current application's name, which is the + * name in the application's `package.json` file. + * + * Usually the `name` field of `package.json` is a short lowercase name, according + * to the npm modules spec. You should usually also specify a `productName` field, + * which is your application's full capitalized name, and which will be preferred + * over `name` by Electron. + */ + name: string; + /** + * A `Boolean` which when `true` indicates that the app is currently running under + * the Rosetta Translator Environment. + * + * You can use this property to prompt users to download the arm64 version of your + * application when they are running the x64 version under Rosetta incorrectly. + * + * @platform darwin + */ + readonly runningUnderRosettaTranslation: boolean; + /** + * A `String` which is the user agent string Electron will use as a global + * fallback. + * + * This is the user agent that will be used when no user agent is set at the + * `webContents` or `session` level. It is useful for ensuring that your entire + * app has the same user agent. Set to a custom value as early as possible in your + * app's initialization to ensure that your overridden value is used. + */ + userAgentFallback: string; + } + + interface AutoUpdater extends NodeJS.EventEmitter { + + // Docs: https://electronjs.org/docs/api/auto-updater + + /** + * This event is emitted after a user calls `quitAndInstall()`. + * + * When this API is called, the `before-quit` event is not emitted before all + * windows are closed. As a result you should listen to this event if you wish to + * perform actions before the windows are closed while a process is quitting, as + * well as listening to `before-quit`. + */ + on(event: 'before-quit-for-update', listener: Function): this; + once(event: 'before-quit-for-update', listener: Function): this; + addListener(event: 'before-quit-for-update', listener: Function): this; + removeListener(event: 'before-quit-for-update', listener: Function): this; + /** + * Emitted when checking if an update has started. + */ + on(event: 'checking-for-update', listener: Function): this; + once(event: 'checking-for-update', listener: Function): this; + addListener(event: 'checking-for-update', listener: Function): this; + removeListener(event: 'checking-for-update', listener: Function): this; + /** + * Emitted when there is an error while updating. + */ + on(event: 'error', listener: (error: Error) => void): this; + once(event: 'error', listener: (error: Error) => void): this; + addListener(event: 'error', listener: (error: Error) => void): this; + removeListener(event: 'error', listener: (error: Error) => void): this; + /** + * Emitted when there is an available update. The update is downloaded + * automatically. + */ + on(event: 'update-available', listener: Function): this; + once(event: 'update-available', listener: Function): this; + addListener(event: 'update-available', listener: Function): this; + removeListener(event: 'update-available', listener: Function): this; + /** + * Emitted when an update has been downloaded. + * + * On Windows only `releaseName` is available. + * + * **Note:** It is not strictly necessary to handle this event. A successfully + * downloaded update will still be applied the next time the application starts. + */ + on(event: 'update-downloaded', listener: (event: Event, + releaseNotes: string, + releaseName: string, + releaseDate: Date, + updateURL: string) => void): this; + once(event: 'update-downloaded', listener: (event: Event, + releaseNotes: string, + releaseName: string, + releaseDate: Date, + updateURL: string) => void): this; + addListener(event: 'update-downloaded', listener: (event: Event, + releaseNotes: string, + releaseName: string, + releaseDate: Date, + updateURL: string) => void): this; + removeListener(event: 'update-downloaded', listener: (event: Event, + releaseNotes: string, + releaseName: string, + releaseDate: Date, + updateURL: string) => void): this; + /** + * Emitted when there is no available update. + */ + on(event: 'update-not-available', listener: Function): this; + once(event: 'update-not-available', listener: Function): this; + addListener(event: 'update-not-available', listener: Function): this; + removeListener(event: 'update-not-available', listener: Function): this; + /** + * Asks the server whether there is an update. You must call `setFeedURL` before + * using this API. + */ + checkForUpdates(): void; + /** + * The current update feed URL. + */ + getFeedURL(): string; + /** + * Restarts the app and installs the update after it has been downloaded. It should + * only be called after `update-downloaded` has been emitted. + * + * Under the hood calling `autoUpdater.quitAndInstall()` will close all application + * windows first, and automatically call `app.quit()` after all windows have been + * closed. + * + * **Note:** It is not strictly necessary to call this function to apply an update, + * as a successfully downloaded update will always be applied the next time the + * application starts. + */ + quitAndInstall(): void; + /** + * Sets the `url` and initialize the auto updater. + */ + setFeedURL(options: FeedURLOptions): void; + } + + interface BluetoothDevice { + + // Docs: https://electronjs.org/docs/api/structures/bluetooth-device + + deviceId: string; + deviceName: string; + } + + class BrowserView { + + // Docs: https://electronjs.org/docs/api/browser-view + + /** + * BrowserView + */ + constructor(options?: BrowserViewConstructorOptions); + /** + * The `bounds` of this BrowserView instance as `Object`. + * + * @experimental + */ + getBounds(): Rectangle; + setAutoResize(options: AutoResizeOptions): void; + setBackgroundColor(color: string): void; + /** + * Resizes and moves the view to the supplied bounds relative to the window. + * + * @experimental + */ + setBounds(bounds: Rectangle): void; + webContents: WebContents; + } + + class BrowserWindow extends NodeEventEmitter { + + // Docs: https://electronjs.org/docs/api/browser-window + + /** + * Emitted when the window is set or unset to show always on top of other windows. + */ + on(event: 'always-on-top-changed', listener: (event: Event, + isAlwaysOnTop: boolean) => void): this; + once(event: 'always-on-top-changed', listener: (event: Event, + isAlwaysOnTop: boolean) => void): this; + addListener(event: 'always-on-top-changed', listener: (event: Event, + isAlwaysOnTop: boolean) => void): this; + removeListener(event: 'always-on-top-changed', listener: (event: Event, + isAlwaysOnTop: boolean) => void): this; + /** + * Emitted when an App Command is invoked. These are typically related to keyboard + * media keys or browser commands, as well as the "Back" button built into some + * mice on Windows. + * + * Commands are lowercased, underscores are replaced with hyphens, and the + * `APPCOMMAND_` prefix is stripped off. e.g. `APPCOMMAND_BROWSER_BACKWARD` is + * emitted as `browser-backward`. + * + * The following app commands are explicitly supported on Linux: + * +* `browser-backward` +* `browser-forward` + * + * @platform win32,linux + */ + on(event: 'app-command', listener: (event: Event, + command: string) => void): this; + once(event: 'app-command', listener: (event: Event, + command: string) => void): this; + addListener(event: 'app-command', listener: (event: Event, + command: string) => void): this; + removeListener(event: 'app-command', listener: (event: Event, + command: string) => void): this; + /** + * Emitted when the window loses focus. + */ + on(event: 'blur', listener: Function): this; + once(event: 'blur', listener: Function): this; + addListener(event: 'blur', listener: Function): this; + removeListener(event: 'blur', listener: Function): this; + /** + * Emitted when the window is going to be closed. It's emitted before the + * `beforeunload` and `unload` event of the DOM. Calling `event.preventDefault()` + * will cancel the close. + * + * Usually you would want to use the `beforeunload` handler to decide whether the + * window should be closed, which will also be called when the window is reloaded. + * In Electron, returning any value other than `undefined` would cancel the close. + * For example: + * + * _**Note**: There is a subtle difference between the behaviors of + * `window.onbeforeunload = handler` and `window.addEventListener('beforeunload', + * handler)`. It is recommended to always set the `event.returnValue` explicitly, + * instead of only returning a value, as the former works more consistently within + * Electron._ + */ + on(event: 'close', listener: (event: Event) => void): this; + once(event: 'close', listener: (event: Event) => void): this; + addListener(event: 'close', listener: (event: Event) => void): this; + removeListener(event: 'close', listener: (event: Event) => void): this; + /** + * Emitted when the window is closed. After you have received this event you should + * remove the reference to the window and avoid using it any more. + */ + on(event: 'closed', listener: Function): this; + once(event: 'closed', listener: Function): this; + addListener(event: 'closed', listener: Function): this; + removeListener(event: 'closed', listener: Function): this; + /** + * Emitted when the window enters a full-screen state. + */ + on(event: 'enter-full-screen', listener: Function): this; + once(event: 'enter-full-screen', listener: Function): this; + addListener(event: 'enter-full-screen', listener: Function): this; + removeListener(event: 'enter-full-screen', listener: Function): this; + /** + * Emitted when the window enters a full-screen state triggered by HTML API. + */ + on(event: 'enter-html-full-screen', listener: Function): this; + once(event: 'enter-html-full-screen', listener: Function): this; + addListener(event: 'enter-html-full-screen', listener: Function): this; + removeListener(event: 'enter-html-full-screen', listener: Function): this; + /** + * Emitted when the window gains focus. + */ + on(event: 'focus', listener: Function): this; + once(event: 'focus', listener: Function): this; + addListener(event: 'focus', listener: Function): this; + removeListener(event: 'focus', listener: Function): this; + /** + * Emitted when the window is hidden. + */ + on(event: 'hide', listener: Function): this; + once(event: 'hide', listener: Function): this; + addListener(event: 'hide', listener: Function): this; + removeListener(event: 'hide', listener: Function): this; + /** + * Emitted when the window leaves a full-screen state. + */ + on(event: 'leave-full-screen', listener: Function): this; + once(event: 'leave-full-screen', listener: Function): this; + addListener(event: 'leave-full-screen', listener: Function): this; + removeListener(event: 'leave-full-screen', listener: Function): this; + /** + * Emitted when the window leaves a full-screen state triggered by HTML API. + */ + on(event: 'leave-html-full-screen', listener: Function): this; + once(event: 'leave-html-full-screen', listener: Function): this; + addListener(event: 'leave-html-full-screen', listener: Function): this; + removeListener(event: 'leave-html-full-screen', listener: Function): this; + /** + * Emitted when window is maximized. + */ + on(event: 'maximize', listener: Function): this; + once(event: 'maximize', listener: Function): this; + addListener(event: 'maximize', listener: Function): this; + removeListener(event: 'maximize', listener: Function): this; + /** + * Emitted when the window is minimized. + */ + on(event: 'minimize', listener: Function): this; + once(event: 'minimize', listener: Function): this; + addListener(event: 'minimize', listener: Function): this; + removeListener(event: 'minimize', listener: Function): this; + /** + * Emitted when the window is being moved to a new position. + */ + on(event: 'move', listener: Function): this; + once(event: 'move', listener: Function): this; + addListener(event: 'move', listener: Function): this; + removeListener(event: 'move', listener: Function): this; + /** + * Emitted once when the window is moved to a new position. + * +__Note__: On macOS this event is an alias of `move`. + * + * @platform darwin,win32 + */ + on(event: 'moved', listener: Function): this; + once(event: 'moved', listener: Function): this; + addListener(event: 'moved', listener: Function): this; + removeListener(event: 'moved', listener: Function): this; + /** + * Emitted when the native new tab button is clicked. + * + * @platform darwin + */ + on(event: 'new-window-for-tab', listener: Function): this; + once(event: 'new-window-for-tab', listener: Function): this; + addListener(event: 'new-window-for-tab', listener: Function): this; + removeListener(event: 'new-window-for-tab', listener: Function): this; + /** + * Emitted when the document changed its title, calling `event.preventDefault()` + * will prevent the native window's title from changing. `explicitSet` is false + * when title is synthesized from file URL. + */ + on(event: 'page-title-updated', listener: (event: Event, + title: string, + explicitSet: boolean) => void): this; + once(event: 'page-title-updated', listener: (event: Event, + title: string, + explicitSet: boolean) => void): this; + addListener(event: 'page-title-updated', listener: (event: Event, + title: string, + explicitSet: boolean) => void): this; + removeListener(event: 'page-title-updated', listener: (event: Event, + title: string, + explicitSet: boolean) => void): this; + /** + * Emitted when the web page has been rendered (while not being shown) and window + * can be displayed without a visual flash. + * + * Please note that using this event implies that the renderer will be considered + * "visible" and paint even though `show` is false. This event will never fire if + * you use `paintWhenInitiallyHidden: false` + */ + on(event: 'ready-to-show', listener: Function): this; + once(event: 'ready-to-show', listener: Function): this; + addListener(event: 'ready-to-show', listener: Function): this; + removeListener(event: 'ready-to-show', listener: Function): this; + /** + * Emitted after the window has been resized. + */ + on(event: 'resize', listener: Function): this; + once(event: 'resize', listener: Function): this; + addListener(event: 'resize', listener: Function): this; + removeListener(event: 'resize', listener: Function): this; + /** + * Emitted once when the window has finished being resized. + * + * This is usually emitted when the window has been resized manually. On macOS, + * resizing the window with `setBounds`/`setSize` and setting the `animate` + * parameter to `true` will also emit this event once resizing has finished. + * + * @platform darwin,win32 + */ + on(event: 'resized', listener: Function): this; + once(event: 'resized', listener: Function): this; + addListener(event: 'resized', listener: Function): this; + removeListener(event: 'resized', listener: Function): this; + /** + * Emitted when the unresponsive web page becomes responsive again. + */ + on(event: 'responsive', listener: Function): this; + once(event: 'responsive', listener: Function): this; + addListener(event: 'responsive', listener: Function): this; + removeListener(event: 'responsive', listener: Function): this; + /** + * Emitted when the window is restored from a minimized state. + */ + on(event: 'restore', listener: Function): this; + once(event: 'restore', listener: Function): this; + addListener(event: 'restore', listener: Function): this; + removeListener(event: 'restore', listener: Function): this; + /** + * Emitted on trackpad rotation gesture. Continually emitted until rotation gesture + * is ended. The `rotation` value on each emission is the angle in degrees rotated + * since the last emission. The last emitted event upon a rotation gesture will + * always be of value `0`. Counter-clockwise rotation values are positive, while + * clockwise ones are negative. + * + * @platform darwin + */ + on(event: 'rotate-gesture', listener: (event: Event, + rotation: number) => void): this; + once(event: 'rotate-gesture', listener: (event: Event, + rotation: number) => void): this; + addListener(event: 'rotate-gesture', listener: (event: Event, + rotation: number) => void): this; + removeListener(event: 'rotate-gesture', listener: (event: Event, + rotation: number) => void): this; + /** + * Emitted when scroll wheel event phase has begun. + * + * @platform darwin + */ + on(event: 'scroll-touch-begin', listener: Function): this; + once(event: 'scroll-touch-begin', listener: Function): this; + addListener(event: 'scroll-touch-begin', listener: Function): this; + removeListener(event: 'scroll-touch-begin', listener: Function): this; + /** + * Emitted when scroll wheel event phase filed upon reaching the edge of element. + * + * @platform darwin + */ + on(event: 'scroll-touch-edge', listener: Function): this; + once(event: 'scroll-touch-edge', listener: Function): this; + addListener(event: 'scroll-touch-edge', listener: Function): this; + removeListener(event: 'scroll-touch-edge', listener: Function): this; + /** + * Emitted when scroll wheel event phase has ended. + * + * @platform darwin + */ + on(event: 'scroll-touch-end', listener: Function): this; + once(event: 'scroll-touch-end', listener: Function): this; + addListener(event: 'scroll-touch-end', listener: Function): this; + removeListener(event: 'scroll-touch-end', listener: Function): this; + /** + * Emitted when window session is going to end due to force shutdown or machine + * restart or session log off. + * + * @platform win32 + */ + on(event: 'session-end', listener: Function): this; + once(event: 'session-end', listener: Function): this; + addListener(event: 'session-end', listener: Function): this; + removeListener(event: 'session-end', listener: Function): this; + /** + * Emitted when the window opens a sheet. + * + * @platform darwin + */ + on(event: 'sheet-begin', listener: Function): this; + once(event: 'sheet-begin', listener: Function): this; + addListener(event: 'sheet-begin', listener: Function): this; + removeListener(event: 'sheet-begin', listener: Function): this; + /** + * Emitted when the window has closed a sheet. + * + * @platform darwin + */ + on(event: 'sheet-end', listener: Function): this; + once(event: 'sheet-end', listener: Function): this; + addListener(event: 'sheet-end', listener: Function): this; + removeListener(event: 'sheet-end', listener: Function): this; + /** + * Emitted when the window is shown. + */ + on(event: 'show', listener: Function): this; + once(event: 'show', listener: Function): this; + addListener(event: 'show', listener: Function): this; + removeListener(event: 'show', listener: Function): this; + /** + * Emitted on 3-finger swipe. Possible directions are `up`, `right`, `down`, + * `left`. + * + * The method underlying this event is built to handle older macOS-style trackpad + * swiping, where the content on the screen doesn't move with the swipe. Most macOS + * trackpads are not configured to allow this kind of swiping anymore, so in order + * for it to emit properly the 'Swipe between pages' preference in `System + * Preferences > Trackpad > More Gestures` must be set to 'Swipe with two or three + * fingers'. + * + * @platform darwin + */ + on(event: 'swipe', listener: (event: Event, + direction: string) => void): this; + once(event: 'swipe', listener: (event: Event, + direction: string) => void): this; + addListener(event: 'swipe', listener: (event: Event, + direction: string) => void): this; + removeListener(event: 'swipe', listener: (event: Event, + direction: string) => void): this; + /** + * Emitted when the system context menu is triggered on the window, this is + * normally only triggered when the user right clicks on the non-client area of + * your window. This is the window titlebar or any area you have declared as + * `-webkit-app-region: drag` in a frameless window. + * +Calling `event.preventDefault()` will prevent the menu from being displayed. + * + * @platform win32 + */ + on(event: 'system-context-menu', listener: (event: Event, + /** + * The screen coordinates the context menu was triggered at + */ + point: Point) => void): this; + once(event: 'system-context-menu', listener: (event: Event, + /** + * The screen coordinates the context menu was triggered at + */ + point: Point) => void): this; + addListener(event: 'system-context-menu', listener: (event: Event, + /** + * The screen coordinates the context menu was triggered at + */ + point: Point) => void): this; + removeListener(event: 'system-context-menu', listener: (event: Event, + /** + * The screen coordinates the context menu was triggered at + */ + point: Point) => void): this; + /** + * Emitted when the window exits from a maximized state. + */ + on(event: 'unmaximize', listener: Function): this; + once(event: 'unmaximize', listener: Function): this; + addListener(event: 'unmaximize', listener: Function): this; + removeListener(event: 'unmaximize', listener: Function): this; + /** + * Emitted when the web page becomes unresponsive. + */ + on(event: 'unresponsive', listener: Function): this; + once(event: 'unresponsive', listener: Function): this; + addListener(event: 'unresponsive', listener: Function): this; + removeListener(event: 'unresponsive', listener: Function): this; + /** + * Emitted before the window is moved. On Windows, calling `event.preventDefault()` + * will prevent the window from being moved. + * + * Note that this is only emitted when the window is being resized manually. + * Resizing the window with `setBounds`/`setSize` will not emit this event. + * + * @platform darwin,win32 + */ + on(event: 'will-move', listener: (event: Event, + /** + * Location the window is being moved to. + */ + newBounds: Rectangle) => void): this; + once(event: 'will-move', listener: (event: Event, + /** + * Location the window is being moved to. + */ + newBounds: Rectangle) => void): this; + addListener(event: 'will-move', listener: (event: Event, + /** + * Location the window is being moved to. + */ + newBounds: Rectangle) => void): this; + removeListener(event: 'will-move', listener: (event: Event, + /** + * Location the window is being moved to. + */ + newBounds: Rectangle) => void): this; + /** + * Emitted before the window is resized. Calling `event.preventDefault()` will + * prevent the window from being resized. + * + * Note that this is only emitted when the window is being resized manually. + * Resizing the window with `setBounds`/`setSize` will not emit this event. + * + * @platform darwin,win32 + */ + on(event: 'will-resize', listener: (event: Event, + /** + * Size the window is being resized to. + */ + newBounds: Rectangle) => void): this; + once(event: 'will-resize', listener: (event: Event, + /** + * Size the window is being resized to. + */ + newBounds: Rectangle) => void): this; + addListener(event: 'will-resize', listener: (event: Event, + /** + * Size the window is being resized to. + */ + newBounds: Rectangle) => void): this; + removeListener(event: 'will-resize', listener: (event: Event, + /** + * Size the window is being resized to. + */ + newBounds: Rectangle) => void): this; + /** + * BrowserWindow + */ + constructor(options?: BrowserWindowConstructorOptions); + /** + * The window that owns the given `browserView`. If the given view is not attached + * to any window, returns `null`. + */ + static fromBrowserView(browserView: BrowserView): (BrowserWindow) | (null); + /** + * The window with the given `id`. + */ + static fromId(id: number): (BrowserWindow) | (null); + /** + * The window that owns the given `webContents` or `null` if the contents are not + * owned by a window. + */ + static fromWebContents(webContents: WebContents): (BrowserWindow) | (null); + /** + * An array of all opened browser windows. + */ + static getAllWindows(): BrowserWindow[]; + /** + * The window that is focused in this application, otherwise returns `null`. + */ + static getFocusedWindow(): (BrowserWindow) | (null); + /** + * Replacement API for setBrowserView supporting work with multi browser views. + * + * @experimental + */ + addBrowserView(browserView: BrowserView): void; + /** + * Adds a window as a tab on this window, after the tab for the window instance. + * + * @platform darwin + */ + addTabbedWindow(browserWindow: BrowserWindow): void; + /** + * Removes focus from the window. + */ + blur(): void; + blurWebView(): void; + /** + * Resolves with a NativeImage + * + * Captures a snapshot of the page within `rect`. Omitting `rect` will capture the + * whole visible page. If the page is not visible, `rect` may be empty. + */ + capturePage(rect?: Rectangle): Promise; + /** + * Moves window to the center of the screen. + */ + center(): void; + /** + * Try to close the window. This has the same effect as a user manually clicking + * the close button of the window. The web page may cancel the close though. See + * the close event. + */ + close(): void; + /** + * Closes the currently open Quick Look panel. + * + * @platform darwin + */ + closeFilePreview(): void; + /** + * Force closing the window, the `unload` and `beforeunload` event won't be emitted + * for the web page, and `close` event will also not be emitted for this window, + * but it guarantees the `closed` event will be emitted. + */ + destroy(): void; + /** + * Starts or stops flashing the window to attract user's attention. + */ + flashFrame(flag: boolean): void; + /** + * Focuses on the window. + */ + focus(): void; + focusOnWebView(): void; + /** + * Gets the background color of the window. See Setting `backgroundColor`. + */ + getBackgroundColor(): string; + /** + * The `bounds` of the window as `Object`. + */ + getBounds(): Rectangle; + /** + * The `BrowserView` attached to `win`. Returns `null` if one is not attached. + * Throws an error if multiple `BrowserView`s are attached. + * + * @experimental + */ + getBrowserView(): (BrowserView) | (null); + /** + * an array of all BrowserViews that have been attached with `addBrowserView` or + * `setBrowserView`. + * + * **Note:** The BrowserView API is currently experimental and may change or be + * removed in future Electron releases. + * + * @experimental + */ + getBrowserViews(): BrowserView[]; + /** + * All child windows. + */ + getChildWindows(): BrowserWindow[]; + /** + * The `bounds` of the window's client area as `Object`. + */ + getContentBounds(): Rectangle; + /** + * Contains the window's client area's width and height. + */ + getContentSize(): number[]; + /** + * Contains the window's maximum width and height. + */ + getMaximumSize(): number[]; + /** + * Window id in the format of DesktopCapturerSource's id. For example + * "window:1324:0". + * + * More precisely the format is `window:id:other_id` where `id` is `HWND` on + * Windows, `CGWindowID` (`uint64_t`) on macOS and `Window` (`unsigned long`) on + * Linux. `other_id` is used to identify web contents (tabs) so within the same top + * level window. + */ + getMediaSourceId(): string; + /** + * Contains the window's minimum width and height. + */ + getMinimumSize(): number[]; + /** + * The platform-specific handle of the window. + * + * The native type of the handle is `HWND` on Windows, `NSView*` on macOS, and + * `Window` (`unsigned long`) on Linux. + */ + getNativeWindowHandle(): Buffer; + /** + * Contains the window bounds of the normal state + * + * **Note:** whatever the current state of the window : maximized, minimized or in + * fullscreen, this function always returns the position and size of the window in + * normal state. In normal state, getBounds and getNormalBounds returns the same + * `Rectangle`. + */ + getNormalBounds(): Rectangle; + /** + * between 0.0 (fully transparent) and 1.0 (fully opaque). On Linux, always returns + * 1. + */ + getOpacity(): number; + /** + * The parent window. + */ + getParentWindow(): BrowserWindow; + /** + * Contains the window's current position. + */ + getPosition(): number[]; + /** + * The pathname of the file the window represents. + * + * @platform darwin + */ + getRepresentedFilename(): string; + /** + * Contains the window's width and height. + */ + getSize(): number[]; + /** + * The title of the native window. + * + * **Note:** The title of the web page can be different from the title of the + * native window. + */ + getTitle(): string; + /** + * The custom position for the traffic light buttons in frameless window. + * + * @platform darwin + */ + getTrafficLightPosition(): Point; + /** + * Whether the window has a shadow. + */ + hasShadow(): boolean; + /** + * Hides the window. + */ + hide(): void; + /** + * Hooks a windows message. The `callback` is called when the message is received + * in the WndProc. + * + * @platform win32 + */ + hookWindowMessage(message: number, callback: (wParam: any, lParam: any) => void): void; + /** + * Whether the window is always on top of other windows. + */ + isAlwaysOnTop(): boolean; + /** + * Whether the window can be manually closed by user. + * +On Linux always returns `true`. + * + * @platform darwin,win32 + */ + isClosable(): boolean; + /** + * Whether the window is destroyed. + */ + isDestroyed(): boolean; + /** + * Whether the window's document has been edited. + * + * @platform darwin + */ + isDocumentEdited(): boolean; + /** + * whether the window is enabled. + */ + isEnabled(): boolean; + /** + * Whether the window is focused. + */ + isFocused(): boolean; + /** + * Whether the window is in fullscreen mode. + */ + isFullScreen(): boolean; + /** + * Whether the maximize/zoom window button toggles fullscreen mode or maximizes the + * window. + */ + isFullScreenable(): boolean; + /** + * Whether the window is in kiosk mode. + */ + isKiosk(): boolean; + /** + * Whether the window can be manually maximized by user. + * +On Linux always returns `true`. + * + * @platform darwin,win32 + */ + isMaximizable(): boolean; + /** + * Whether the window is maximized. + */ + isMaximized(): boolean; + /** + * Whether menu bar automatically hides itself. + */ + isMenuBarAutoHide(): boolean; + /** + * Whether the menu bar is visible. + */ + isMenuBarVisible(): boolean; + /** + * Whether the window can be manually minimized by the user. + * +On Linux always returns `true`. + * + * @platform darwin,win32 + */ + isMinimizable(): boolean; + /** + * Whether the window is minimized. + */ + isMinimized(): boolean; + /** + * Whether current window is a modal window. + */ + isModal(): boolean; + /** + * Whether the window can be moved by user. + +On Linux always returns `true`. + * + * @platform darwin,win32 + */ + isMovable(): boolean; + /** + * Whether the window is in normal state (not maximized, not minimized, not in + * fullscreen mode). + */ + isNormal(): boolean; + /** + * Whether the window can be manually resized by the user. + */ + isResizable(): boolean; + /** + * Whether the window is in simple (pre-Lion) fullscreen mode. + * + * @platform darwin + */ + isSimpleFullScreen(): boolean; + /** + * Whether the window is in Windows 10 tablet mode. + * + * Since Windows 10 users can use their PC as tablet, under this mode apps can + * choose to optimize their UI for tablets, such as enlarging the titlebar and + * hiding titlebar buttons. + * + * This API returns whether the window is in tablet mode, and the `resize` event + * can be be used to listen to changes to tablet mode. + * + * @platform win32 + */ + isTabletMode(): boolean; + /** + * Whether the window is visible to the user. + */ + isVisible(): boolean; + /** + * Whether the window is visible on all workspaces. + * +**Note:** This API always returns false on Windows. + */ + isVisibleOnAllWorkspaces(): boolean; + /** + * `true` or `false` depending on whether the message is hooked. + * + * @platform win32 + */ + isWindowMessageHooked(message: number): boolean; + /** + * the promise will resolve when the page has finished loading (see + * `did-finish-load`), and rejects if the page fails to load (see `did-fail-load`). + * + * Same as `webContents.loadFile`, `filePath` should be a path to an HTML file + * relative to the root of your application. See the `webContents` docs for more + * information. + */ + loadFile(filePath: string, options?: LoadFileOptions): Promise; + /** + * the promise will resolve when the page has finished loading (see + * `did-finish-load`), and rejects if the page fails to load (see `did-fail-load`). + * + * Same as `webContents.loadURL(url[, options])`. + * + * The `url` can be a remote address (e.g. `http://`) or a path to a local HTML + * file using the `file://` protocol. + * + * To ensure that file URLs are properly formatted, it is recommended to use Node's + * `url.format` method: + * + * You can load a URL using a `POST` request with URL-encoded data by doing the + * following: + */ + loadURL(url: string, options?: LoadURLOptions): Promise; + /** + * Maximizes the window. This will also show (but not focus) the window if it isn't + * being displayed already. + */ + maximize(): void; + /** + * Merges all windows into one window with multiple tabs when native tabs are + * enabled and there is more than one open window. + * + * @platform darwin + */ + mergeAllWindows(): void; + /** + * Minimizes the window. On some platforms the minimized window will be shown in + * the Dock. + */ + minimize(): void; + /** + * Moves window above the source window in the sense of z-order. If the + * `mediaSourceId` is not of type window or if the window does not exist then this + * method throws an error. + */ + moveAbove(mediaSourceId: string): void; + /** + * Moves the current tab into a new window if native tabs are enabled and there is + * more than one tab in the current window. + * + * @platform darwin + */ + moveTabToNewWindow(): void; + /** + * Moves window to top(z-order) regardless of focus + */ + moveTop(): void; + /** + * Uses Quick Look to preview a file at a given path. + * + * @platform darwin + */ + previewFile(path: string, displayName?: string): void; + /** + * Same as `webContents.reload`. + */ + reload(): void; + removeBrowserView(browserView: BrowserView): void; + /** + * Remove the window's menu bar. + * + * @platform linux,win32 + */ + removeMenu(): void; + /** + * Restores the window from minimized state to its previous state. + */ + restore(): void; + /** + * Selects the next tab when native tabs are enabled and there are other tabs in + * the window. + * + * @platform darwin + */ + selectNextTab(): void; + /** + * Selects the previous tab when native tabs are enabled and there are other tabs + * in the window. + * + * @platform darwin + */ + selectPreviousTab(): void; + /** + * Sets whether the window should show always on top of other windows. After + * setting this, the window is still a normal window, not a toolbox window which + * can not be focused on. + */ + setAlwaysOnTop(flag: boolean, level?: 'normal' | 'floating' | 'torn-off-menu' | 'modal-panel' | 'main-menu' | 'status' | 'pop-up-menu' | 'screen-saver', relativeLevel?: number): void; + /** + * Sets the properties for the window's taskbar button. + * + * **Note:** `relaunchCommand` and `relaunchDisplayName` must always be set + * together. If one of those properties is not set, then neither will be used. + * + * @platform win32 + */ + setAppDetails(options: AppDetailsOptions): void; + /** + * This will make a window maintain an aspect ratio. The extra size allows a + * developer to have space, specified in pixels, not included within the aspect + * ratio calculations. This API already takes into account the difference between a + * window's size and its content size. + * + * Consider a normal window with an HD video player and associated controls. + * Perhaps there are 15 pixels of controls on the left edge, 25 pixels of controls + * on the right edge and 50 pixels of controls below the player. In order to + * maintain a 16:9 aspect ratio (standard aspect ratio for HD @1920x1080) within + * the player itself we would call this function with arguments of 16/9 and { + * width: 40, height: 50 }. The second argument doesn't care where the extra width + * and height are within the content view--only that they exist. Sum any extra + * width and height areas you have within the overall content view. + * + * The aspect ratio is not respected when window is resized programmingly with APIs + * like `win.setSize`. + */ + setAspectRatio(aspectRatio: number, extraSize?: Size): void; + /** + * Controls whether to hide cursor when typing. + * + * @platform darwin + */ + setAutoHideCursor(autoHide: boolean): void; + /** + * Sets whether the window menu bar should hide itself automatically. Once set the + * menu bar will only show when users press the single `Alt` key. + * + * If the menu bar is already visible, calling `setAutoHideMenuBar(true)` won't + * hide it immediately. + */ + setAutoHideMenuBar(hide: boolean): void; + /** + * Sets the background color of the window. See Setting `backgroundColor`. + */ + setBackgroundColor(backgroundColor: string): void; + /** + * Resizes and moves the window to the supplied bounds. Any properties that are not + * supplied will default to their current values. + */ + setBounds(bounds: Partial, animate?: boolean): void; + setBrowserView(browserView: (BrowserView) | (null)): void; + /** + * Sets whether the window can be manually closed by user. On Linux does nothing. + * + * @platform darwin,win32 + */ + setClosable(closable: boolean): void; + /** + * Resizes and moves the window's client area (e.g. the web page) to the supplied + * bounds. + */ + setContentBounds(bounds: Rectangle, animate?: boolean): void; + /** + * Prevents the window contents from being captured by other apps. + * + * On macOS it sets the NSWindow's sharingType to NSWindowSharingNone. On Windows + * it calls SetWindowDisplayAffinity with `WDA_EXCLUDEFROMCAPTURE`. For Windows 10 + * version 2004 and up the window will be removed from capture entirely, older + * Windows versions behave as if `WDA_MONITOR` is applied capturing a black window. + * + * @platform darwin,win32 + */ + setContentProtection(enable: boolean): void; + /** + * Resizes the window's client area (e.g. the web page) to `width` and `height`. + */ + setContentSize(width: number, height: number, animate?: boolean): void; + /** + * Specifies whether the window’s document has been edited, and the icon in title + * bar will become gray when set to `true`. + * + * @platform darwin + */ + setDocumentEdited(edited: boolean): void; + /** + * Disable or enable the window. + */ + setEnabled(enable: boolean): void; + /** + * Changes whether the window can be focused. + * +On macOS it does not remove the focus from the window. + * + * @platform darwin,win32 + */ + setFocusable(focusable: boolean): void; + /** + * Sets whether the window should be in fullscreen mode. + */ + setFullScreen(flag: boolean): void; + /** + * Sets whether the maximize/zoom window button toggles fullscreen mode or + * maximizes the window. + */ + setFullScreenable(fullscreenable: boolean): void; + /** + * Sets whether the window should have a shadow. + */ + setHasShadow(hasShadow: boolean): void; + /** + * Changes window icon. + * + * @platform win32,linux + */ + setIcon(icon: (NativeImage) | (string)): void; + /** + * Makes the window ignore all mouse events. + * + * All mouse events happened in this window will be passed to the window below this + * window, but if this window has focus, it will still receive keyboard events. + */ + setIgnoreMouseEvents(ignore: boolean, options?: IgnoreMouseEventsOptions): void; + /** + * Enters or leaves kiosk mode. + */ + setKiosk(flag: boolean): void; + /** + * Sets whether the window can be manually maximized by user. On Linux does + * nothing. + * + * @platform darwin,win32 + */ + setMaximizable(maximizable: boolean): void; + /** + * Sets the maximum size of window to `width` and `height`. + */ + setMaximumSize(width: number, height: number): void; + /** + * Sets the `menu` as the window's menu bar. + * + * @platform linux,win32 + */ + setMenu(menu: (Menu) | (null)): void; + /** + * Sets whether the menu bar should be visible. If the menu bar is auto-hide, users + * can still bring up the menu bar by pressing the single `Alt` key. + * + * @platform win32,linux + */ + setMenuBarVisibility(visible: boolean): void; + /** + * Sets whether the window can be manually minimized by user. On Linux does + * nothing. + * + * @platform darwin,win32 + */ + setMinimizable(minimizable: boolean): void; + /** + * Sets the minimum size of window to `width` and `height`. + */ + setMinimumSize(width: number, height: number): void; + /** + * Sets whether the window can be moved by user. On Linux does nothing. + * + * @platform darwin,win32 + */ + setMovable(movable: boolean): void; + /** + * Sets the opacity of the window. On Linux, does nothing. Out of bound number + * values are clamped to the [0, 1] range. + * + * @platform win32,darwin + */ + setOpacity(opacity: number): void; + /** + * Sets a 16 x 16 pixel overlay onto the current taskbar icon, usually used to + * convey some sort of application status or to passively notify the user. + * + * @platform win32 + */ + setOverlayIcon(overlay: (NativeImage) | (null), description: string): void; + /** + * Sets `parent` as current window's parent window, passing `null` will turn + * current window into a top-level window. + */ + setParentWindow(parent: (BrowserWindow) | (null)): void; + /** + * Moves window to `x` and `y`. + */ + setPosition(x: number, y: number, animate?: boolean): void; + /** + * Sets progress value in progress bar. Valid range is [0, 1.0]. + * + * Remove progress bar when progress < 0; Change to indeterminate mode when + * progress > 1. + * + * On Linux platform, only supports Unity desktop environment, you need to specify + * the `*.desktop` file name to `desktopName` field in `package.json`. By default, + * it will assume `{app.name}.desktop`. + * + * On Windows, a mode can be passed. Accepted values are `none`, `normal`, + * `indeterminate`, `error`, and `paused`. If you call `setProgressBar` without a + * mode set (but with a value within the valid range), `normal` will be assumed. + */ + setProgressBar(progress: number, options?: ProgressBarOptions): void; + /** + * Sets the pathname of the file the window represents, and the icon of the file + * will show in window's title bar. + * + * @platform darwin + */ + setRepresentedFilename(filename: string): void; + /** + * Sets whether the window can be manually resized by the user. + */ + setResizable(resizable: boolean): void; + /** + * Setting a window shape determines the area within the window where the system + * permits drawing and user interaction. Outside of the given region, no pixels + * will be drawn and no mouse events will be registered. Mouse events outside of + * the region will not be received by that window, but will fall through to + * whatever is behind the window. + * + * @experimental + * @platform win32,linux + */ + setShape(rects: Rectangle[]): void; + /** + * Changes the attachment point for sheets on macOS. By default, sheets are + * attached just below the window frame, but you may want to display them beneath a + * HTML-rendered toolbar. For example: + * + * @platform darwin + */ + setSheetOffset(offsetY: number, offsetX?: number): void; + /** + * Enters or leaves simple fullscreen mode. + * + * Simple fullscreen mode emulates the native fullscreen behavior found in versions + * of macOS prior to Lion (10.7). + * + * @platform darwin + */ + setSimpleFullScreen(flag: boolean): void; + /** + * Resizes the window to `width` and `height`. If `width` or `height` are below any + * set minimum size constraints the window will snap to its minimum size. + */ + setSize(width: number, height: number, animate?: boolean): void; + /** + * Makes the window not show in the taskbar. + */ + setSkipTaskbar(skip: boolean): void; + /** + * Whether the buttons were added successfully + * + * Add a thumbnail toolbar with a specified set of buttons to the thumbnail image + * of a window in a taskbar button layout. Returns a `Boolean` object indicates + * whether the thumbnail has been added successfully. + * + * The number of buttons in thumbnail toolbar should be no greater than 7 due to + * the limited room. Once you setup the thumbnail toolbar, the toolbar cannot be + * removed due to the platform's limitation. But you can call the API with an empty + * array to clean the buttons. + * + * The `buttons` is an array of `Button` objects: + * + * * `Button` Object + * * `icon` NativeImage - The icon showing in thumbnail toolbar. + * * `click` Function + * * `tooltip` String (optional) - The text of the button's tooltip. + * * `flags` String[] (optional) - Control specific states and behaviors of the + * button. By default, it is `['enabled']`. + * + * The `flags` is an array that can include following `String`s: + * + * * `enabled` - The button is active and available to the user. + * * `disabled` - The button is disabled. It is present, but has a visual state + * indicating it will not respond to user action. + * * `dismissonclick` - When the button is clicked, the thumbnail window closes + * immediately. + * * `nobackground` - Do not draw a button border, use only the image. + * * `hidden` - The button is not shown to the user. + * * `noninteractive` - The button is enabled but not interactive; no pressed + * button state is drawn. This value is intended for instances where the button is + * used in a notification. + * + * @platform win32 + */ + setThumbarButtons(buttons: ThumbarButton[]): boolean; + /** + * Sets the region of the window to show as the thumbnail image displayed when + * hovering over the window in the taskbar. You can reset the thumbnail to be the + * entire window by specifying an empty region: `{ x: 0, y: 0, width: 0, height: 0 + * }`. + * + * @platform win32 + */ + setThumbnailClip(region: Rectangle): void; + /** + * Sets the toolTip that is displayed when hovering over the window thumbnail in + * the taskbar. + * + * @platform win32 + */ + setThumbnailToolTip(toolTip: string): void; + /** + * Changes the title of native window to `title`. + */ + setTitle(title: string): void; + /** + * Raises `browserView` above other `BrowserView`s attached to `win`. Throws an + * error if `browserView` is not attached to `win`. + * + * @experimental + */ + setTopBrowserView(browserView: BrowserView): void; + /** + * Sets the touchBar layout for the current window. Specifying `null` or + * `undefined` clears the touch bar. This method only has an effect if the machine + * has a touch bar and is running on macOS 10.12.1+. + * + * **Note:** The TouchBar API is currently experimental and may change or be + * removed in future Electron releases. + * + * @platform darwin + */ + setTouchBar(touchBar: (TouchBar) | (null)): void; + /** + * Set a custom position for the traffic light buttons in frameless window. + * + * @platform darwin + */ + setTrafficLightPosition(position: Point): void; + /** + * Adds a vibrancy effect to the browser window. Passing `null` or an empty string + * will remove the vibrancy effect on the window. + * + * Note that `appearance-based`, `light`, `dark`, `medium-light`, and `ultra-dark` + * have been deprecated and will be removed in an upcoming version of macOS. + * + * @platform darwin + */ + setVibrancy(type: (('appearance-based' | 'light' | 'dark' | 'titlebar' | 'selection' | 'menu' | 'popover' | 'sidebar' | 'medium-light' | 'ultra-dark' | 'header' | 'sheet' | 'window' | 'hud' | 'fullscreen-ui' | 'tooltip' | 'content' | 'under-window' | 'under-page')) | (null)): void; + /** + * Sets whether the window should be visible on all workspaces. + * +**Note:** This API does nothing on Windows. + */ + setVisibleOnAllWorkspaces(visible: boolean, options?: VisibleOnAllWorkspacesOptions): void; + /** + * Sets whether the window traffic light buttons should be visible. + * + * @platform darwin + */ + setWindowButtonVisibility(visible: boolean): void; + /** + * Shows and gives focus to the window. + */ + show(): void; + /** + * Same as `webContents.showDefinitionForSelection()`. + * + * @platform darwin + */ + showDefinitionForSelection(): void; + /** + * Shows the window but doesn't focus on it. + */ + showInactive(): void; + /** + * Toggles the visibility of the tab bar if native tabs are enabled and there is + * only one tab in the current window. + * + * @platform darwin + */ + toggleTabBar(): void; + /** + * Unhooks all of the window messages. + * + * @platform win32 + */ + unhookAllWindowMessages(): void; + /** + * Unhook the window message. + * + * @platform win32 + */ + unhookWindowMessage(message: number): void; + /** + * Unmaximizes the window. + */ + unmaximize(): void; + accessibleTitle: string; + autoHideMenuBar: boolean; + closable: boolean; + documentEdited: boolean; + excludedFromShownWindowsMenu: boolean; + fullScreen: boolean; + fullScreenable: boolean; + readonly id: number; + kiosk: boolean; + maximizable: boolean; + menuBarVisible: boolean; + minimizable: boolean; + movable: boolean; + representedFilename: string; + resizable: boolean; + shadow: boolean; + simpleFullScreen: boolean; + title: string; + visibleOnAllWorkspaces: boolean; + readonly webContents: WebContents; + } + + class BrowserWindowProxy { + + // Docs: https://electronjs.org/docs/api/browser-window-proxy + + /** + * Removes focus from the child window. + */ + blur(): void; + /** + * Forcefully closes the child window without calling its unload event. + */ + close(): void; + /** + * Evaluates the code in the child window. + */ + eval(code: string): void; + /** + * Focuses the child window (brings the window to front). + */ + focus(): void; + /** + * Sends a message to the child window with the specified origin or `*` for no + * origin preference. + * + * In addition to these methods, the child window implements `window.opener` object + * with no properties and a single method. + */ + postMessage(message: any, targetOrigin: string): void; + /** + * Invokes the print dialog on the child window. + */ + print(): void; + closed: boolean; + } + + interface Certificate { + + // Docs: https://electronjs.org/docs/api/structures/certificate + + /** + * PEM encoded data + */ + data: string; + /** + * Fingerprint of the certificate + */ + fingerprint: string; + /** + * Issuer principal + */ + issuer: CertificatePrincipal; + /** + * Issuer certificate (if not self-signed) + */ + issuerCert: Certificate; + /** + * Issuer's Common Name + */ + issuerName: string; + /** + * Hex value represented string + */ + serialNumber: string; + /** + * Subject principal + */ + subject: CertificatePrincipal; + /** + * Subject's Common Name + */ + subjectName: string; + /** + * End date of the certificate being valid in seconds + */ + validExpiry: number; + /** + * Start date of the certificate being valid in seconds + */ + validStart: number; + } + + interface CertificatePrincipal { + + // Docs: https://electronjs.org/docs/api/structures/certificate-principal + + /** + * Common Name. + */ + commonName: string; + /** + * Country or region. + */ + country: string; + /** + * Locality. + */ + locality: string; + /** + * Organization names. + */ + organizations: string[]; + /** + * Organization Unit names. + */ + organizationUnits: string[]; + /** + * State or province. + */ + state: string; + } + + class ClientRequest extends NodeEventEmitter { + + // Docs: https://electronjs.org/docs/api/client-request + + /** + * Emitted when the `request` is aborted. The `abort` event will not be fired if + * the `request` is already closed. + */ + on(event: 'abort', listener: Function): this; + once(event: 'abort', listener: Function): this; + addListener(event: 'abort', listener: Function): this; + removeListener(event: 'abort', listener: Function): this; + /** + * Emitted as the last event in the HTTP request-response transaction. The `close` + * event indicates that no more events will be emitted on either the `request` or + * `response` objects. + */ + on(event: 'close', listener: Function): this; + once(event: 'close', listener: Function): this; + addListener(event: 'close', listener: Function): this; + removeListener(event: 'close', listener: Function): this; + /** + * Emitted when the `net` module fails to issue a network request. Typically when + * the `request` object emits an `error` event, a `close` event will subsequently + * follow and no response object will be provided. + */ + on(event: 'error', listener: ( + /** + * an error object providing some information about the failure. + */ + error: Error) => void): this; + once(event: 'error', listener: ( + /** + * an error object providing some information about the failure. + */ + error: Error) => void): this; + addListener(event: 'error', listener: ( + /** + * an error object providing some information about the failure. + */ + error: Error) => void): this; + removeListener(event: 'error', listener: ( + /** + * an error object providing some information about the failure. + */ + error: Error) => void): this; + /** + * Emitted just after the last chunk of the `request`'s data has been written into + * the `request` object. + */ + on(event: 'finish', listener: Function): this; + once(event: 'finish', listener: Function): this; + addListener(event: 'finish', listener: Function): this; + removeListener(event: 'finish', listener: Function): this; + /** + * Emitted when an authenticating proxy is asking for user credentials. + * + * The `callback` function is expected to be called back with user credentials: + * + * * `username` String + * * `password` String + * + * Providing empty credentials will cancel the request and report an authentication + * error on the response object: + */ + on(event: 'login', listener: (authInfo: AuthInfo, + callback: (username?: string, password?: string) => void) => void): this; + once(event: 'login', listener: (authInfo: AuthInfo, + callback: (username?: string, password?: string) => void) => void): this; + addListener(event: 'login', listener: (authInfo: AuthInfo, + callback: (username?: string, password?: string) => void) => void): this; + removeListener(event: 'login', listener: (authInfo: AuthInfo, + callback: (username?: string, password?: string) => void) => void): this; + /** + * Emitted when the server returns a redirect response (e.g. 301 Moved + * Permanently). Calling `request.followRedirect` will continue with the + * redirection. If this event is handled, `request.followRedirect` must be called + * **synchronously**, otherwise the request will be cancelled. + */ + on(event: 'redirect', listener: (statusCode: number, + method: string, + redirectUrl: string, + responseHeaders: Record) => void): this; + once(event: 'redirect', listener: (statusCode: number, + method: string, + redirectUrl: string, + responseHeaders: Record) => void): this; + addListener(event: 'redirect', listener: (statusCode: number, + method: string, + redirectUrl: string, + responseHeaders: Record) => void): this; + removeListener(event: 'redirect', listener: (statusCode: number, + method: string, + redirectUrl: string, + responseHeaders: Record) => void): this; + on(event: 'response', listener: ( + /** + * An object representing the HTTP response message. + */ + response: IncomingMessage) => void): this; + once(event: 'response', listener: ( + /** + * An object representing the HTTP response message. + */ + response: IncomingMessage) => void): this; + addListener(event: 'response', listener: ( + /** + * An object representing the HTTP response message. + */ + response: IncomingMessage) => void): this; + removeListener(event: 'response', listener: ( + /** + * An object representing the HTTP response message. + */ + response: IncomingMessage) => void): this; + /** + * ClientRequest + */ + constructor(options: (ClientRequestConstructorOptions) | (string)); + /** + * Cancels an ongoing HTTP transaction. If the request has already emitted the + * `close` event, the abort operation will have no effect. Otherwise an ongoing + * event will emit `abort` and `close` events. Additionally, if there is an ongoing + * response object,it will emit the `aborted` event. + */ + abort(): void; + /** + * Sends the last chunk of the request data. Subsequent write or end operations + * will not be allowed. The `finish` event is emitted just after the end operation. + */ + end(chunk?: (string) | (Buffer), encoding?: string, callback?: () => void): void; + /** + * Continues any pending redirection. Can only be called during a `'redirect'` + * event. + */ + followRedirect(): void; + /** + * The value of a previously set extra header name. + */ + getHeader(name: string): string; + /** + * * `active` Boolean - Whether the request is currently active. If this is false + * no other properties will be set + * * `started` Boolean - Whether the upload has started. If this is false both + * `current` and `total` will be set to 0. + * * `current` Integer - The number of bytes that have been uploaded so far + * * `total` Integer - The number of bytes that will be uploaded this request + * + * You can use this method in conjunction with `POST` requests to get the progress + * of a file upload or other data transfer. + */ + getUploadProgress(): UploadProgress; + /** + * Removes a previously set extra header name. This method can be called only + * before first write. Trying to call it after the first write will throw an error. + */ + removeHeader(name: string): void; + /** + * Adds an extra HTTP header. The header name will be issued as-is without + * lowercasing. It can be called only before first write. Calling this method after + * the first write will throw an error. If the passed value is not a `String`, its + * `toString()` method will be called to obtain the final value. + * + * Certain headers are restricted from being set by apps. These headers are listed + * below. More information on restricted headers can be found in Chromium's header + * utils. + * + * * `Content-Length` + * * `Host` + * * `Trailer` or `Te` + * * `Upgrade` + * * `Cookie2` + * * `Keep-Alive` + * * `Transfer-Encoding` + * + * Additionally, setting the `Connection` header to the value `upgrade` is also + * disallowed. + */ + setHeader(name: string, value: string): void; + /** + * `callback` is essentially a dummy function introduced in the purpose of keeping + * similarity with the Node.js API. It is called asynchronously in the next tick + * after `chunk` content have been delivered to the Chromium networking layer. + * Contrary to the Node.js implementation, it is not guaranteed that `chunk` + * content have been flushed on the wire before `callback` is called. + * + * Adds a chunk of data to the request body. The first write operation may cause + * the request headers to be issued on the wire. After the first write operation, + * it is not allowed to add or remove a custom header. + */ + write(chunk: (string) | (Buffer), encoding?: string, callback?: () => void): void; + chunkedEncoding: boolean; + } + + interface Clipboard { + + // Docs: https://electronjs.org/docs/api/clipboard + + /** + * An array of supported formats for the clipboard `type`. + */ + availableFormats(type?: 'selection' | 'clipboard'): string[]; + /** + * Clears the clipboard content. + */ + clear(type?: 'selection' | 'clipboard'): void; + /** + * Whether the clipboard supports the specified `format`. + * + * @experimental + */ + has(format: string, type?: 'selection' | 'clipboard'): boolean; + /** + * Reads `format` type from the clipboard. + * + * @experimental + */ + read(format: string): string; + /** + * * `title` String + * * `url` String + * + * Returns an Object containing `title` and `url` keys representing the bookmark in + * the clipboard. The `title` and `url` values will be empty strings when the + * bookmark is unavailable. + * + * @platform darwin,win32 + */ + readBookmark(): ReadBookmark; + /** + * Reads `format` type from the clipboard. + * + * @experimental + */ + readBuffer(format: string): Buffer; + /** + * The text on the find pasteboard, which is the pasteboard that holds information + * about the current state of the active application’s find panel. + * + * This method uses synchronous IPC when called from the renderer process. The + * cached value is reread from the find pasteboard whenever the application is + * activated. + * + * @platform darwin + */ + readFindText(): string; + /** + * The content in the clipboard as markup. + */ + readHTML(type?: 'selection' | 'clipboard'): string; + /** + * The image content in the clipboard. + */ + readImage(type?: 'selection' | 'clipboard'): NativeImage; + /** + * The content in the clipboard as RTF. + */ + readRTF(type?: 'selection' | 'clipboard'): string; + /** + * The content in the clipboard as plain text. + */ + readText(type?: 'selection' | 'clipboard'): string; + /** + * Writes `data` to the clipboard. + */ + write(data: Data, type?: 'selection' | 'clipboard'): void; + /** + * Writes the `title` and `url` into the clipboard as a bookmark. + * + * **Note:** Most apps on Windows don't support pasting bookmarks into them so you + * can use `clipboard.write` to write both a bookmark and fallback text to the + * clipboard. + * + * @platform darwin,win32 + */ + writeBookmark(title: string, url: string, type?: 'selection' | 'clipboard'): void; + /** + * Writes the `buffer` into the clipboard as `format`. + * + * @experimental + */ + writeBuffer(format: string, buffer: Buffer, type?: 'selection' | 'clipboard'): void; + /** + * Writes the `text` into the find pasteboard (the pasteboard that holds + * information about the current state of the active application’s find panel) as + * plain text. This method uses synchronous IPC when called from the renderer + * process. + * + * @platform darwin + */ + writeFindText(text: string): void; + /** + * Writes `markup` to the clipboard. + */ + writeHTML(markup: string, type?: 'selection' | 'clipboard'): void; + /** + * Writes `image` to the clipboard. + */ + writeImage(image: NativeImage, type?: 'selection' | 'clipboard'): void; + /** + * Writes the `text` into the clipboard in RTF. + */ + writeRTF(text: string, type?: 'selection' | 'clipboard'): void; + /** + * Writes the `text` into the clipboard as plain text. + */ + writeText(text: string, type?: 'selection' | 'clipboard'): void; + } + + class CommandLine { + + // Docs: https://electronjs.org/docs/api/command-line + + /** + * Append an argument to Chromium's command line. The argument will be quoted + * correctly. Switches will precede arguments regardless of appending order. + * + * If you're appending an argument like `--switch=value`, consider using + * `appendSwitch('switch', 'value')` instead. + * + * **Note:** This will not affect `process.argv`. The intended usage of this + * function is to control Chromium's behavior. + */ + appendArgument(value: string): void; + /** + * Append a switch (with optional `value`) to Chromium's command line. + * + * **Note:** This will not affect `process.argv`. The intended usage of this + * function is to control Chromium's behavior. + */ + appendSwitch(the_switch: string, value?: string): void; + /** + * The command-line switch value. + * + * **Note:** When the switch is not present or has no value, it returns empty + * string. + */ + getSwitchValue(the_switch: string): string; + /** + * Whether the command-line switch is present. + */ + hasSwitch(the_switch: string): boolean; + } + + interface ContentTracing { + + // Docs: https://electronjs.org/docs/api/content-tracing + + /** + * resolves with an array of category groups once all child processes have + * acknowledged the `getCategories` request + * + * Get a set of category groups. The category groups can change as new code paths + * are reached. See also the list of built-in tracing categories. + * + * > **NOTE:** Electron adds a non-default tracing category called `"electron"`. + * This category can be used to capture Electron-specific tracing events. + */ + getCategories(): Promise; + /** + * Resolves with an object containing the `value` and `percentage` of trace buffer + * maximum usage + * + * * `value` Number + * * `percentage` Number + * + * Get the maximum usage across processes of trace buffer as a percentage of the + * full state. + */ + getTraceBufferUsage(): Promise; + /** + * resolved once all child processes have acknowledged the `startRecording` + * request. + * + * Start recording on all processes. + * + * Recording begins immediately locally and asynchronously on child processes as + * soon as they receive the EnableRecording request. + * + * If a recording is already running, the promise will be immediately resolved, as + * only one trace operation can be in progress at a time. + */ + startRecording(options: (TraceConfig) | (TraceCategoriesAndOptions)): Promise; + /** + * resolves with a path to a file that contains the traced data once all child + * processes have acknowledged the `stopRecording` request + * + * Stop recording on all processes. + * + * Child processes typically cache trace data and only rarely flush and send trace + * data back to the main process. This helps to minimize the runtime overhead of + * tracing since sending trace data over IPC can be an expensive operation. So, to + * end tracing, Chromium asynchronously asks all child processes to flush any + * pending trace data. + * + * Trace data will be written into `resultFilePath`. If `resultFilePath` is empty + * or not provided, trace data will be written to a temporary file, and the path + * will be returned in the promise. + */ + stopRecording(resultFilePath?: string): Promise; + } + + interface ContextBridge { + + // Docs: https://electronjs.org/docs/api/context-bridge + + exposeInMainWorld(apiKey: string, api: any): void; + } + + interface Cookie { + + // Docs: https://electronjs.org/docs/api/structures/cookie + + /** + * The domain of the cookie; this will be normalized with a preceding dot so that + * it's also valid for subdomains. + */ + domain?: string; + /** + * The expiration date of the cookie as the number of seconds since the UNIX epoch. + * Not provided for session cookies. + */ + expirationDate?: number; + /** + * Whether the cookie is a host-only cookie; this will only be `true` if no domain + * was passed. + */ + hostOnly?: boolean; + /** + * Whether the cookie is marked as HTTP only. + */ + httpOnly?: boolean; + /** + * The name of the cookie. + */ + name: string; + /** + * The path of the cookie. + */ + path?: string; + /** + * The Same Site policy applied to this cookie. Can be `unspecified`, + * `no_restriction`, `lax` or `strict`. + */ + sameSite: ('unspecified' | 'no_restriction' | 'lax' | 'strict'); + /** + * Whether the cookie is marked as secure. + */ + secure?: boolean; + /** + * Whether the cookie is a session cookie or a persistent cookie with an expiration + * date. + */ + session?: boolean; + /** + * The value of the cookie. + */ + value: string; + } + + class Cookies extends NodeEventEmitter { + + // Docs: https://electronjs.org/docs/api/cookies + + /** + * Emitted when a cookie is changed because it was added, edited, removed, or + * expired. + */ + on(event: 'changed', listener: (event: Event, + /** + * The cookie that was changed. + */ + cookie: Cookie, + /** + * The cause of the change with one of the following values: + */ + cause: ('explicit' | 'overwrite' | 'expired' | 'evicted' | 'expired-overwrite'), + /** + * `true` if the cookie was removed, `false` otherwise. + */ + removed: boolean) => void): this; + once(event: 'changed', listener: (event: Event, + /** + * The cookie that was changed. + */ + cookie: Cookie, + /** + * The cause of the change with one of the following values: + */ + cause: ('explicit' | 'overwrite' | 'expired' | 'evicted' | 'expired-overwrite'), + /** + * `true` if the cookie was removed, `false` otherwise. + */ + removed: boolean) => void): this; + addListener(event: 'changed', listener: (event: Event, + /** + * The cookie that was changed. + */ + cookie: Cookie, + /** + * The cause of the change with one of the following values: + */ + cause: ('explicit' | 'overwrite' | 'expired' | 'evicted' | 'expired-overwrite'), + /** + * `true` if the cookie was removed, `false` otherwise. + */ + removed: boolean) => void): this; + removeListener(event: 'changed', listener: (event: Event, + /** + * The cookie that was changed. + */ + cookie: Cookie, + /** + * The cause of the change with one of the following values: + */ + cause: ('explicit' | 'overwrite' | 'expired' | 'evicted' | 'expired-overwrite'), + /** + * `true` if the cookie was removed, `false` otherwise. + */ + removed: boolean) => void): this; + /** + * A promise which resolves when the cookie store has been flushed + * +Writes any unwritten cookies data to disk. + */ + flushStore(): Promise; + /** + * A promise which resolves an array of cookie objects. + * + * Sends a request to get all cookies matching `filter`, and resolves a promise + * with the response. + */ + get(filter: CookiesGetFilter): Promise; + /** + * A promise which resolves when the cookie has been removed + * +Removes the cookies matching `url` and `name` + */ + remove(url: string, name: string): Promise; + /** + * A promise which resolves when the cookie has been set + * +Sets a cookie with `details`. + */ + set(details: CookiesSetDetails): Promise; + } + + interface CPUUsage { + + // Docs: https://electronjs.org/docs/api/structures/cpu-usage + + /** + * The number of average idle CPU wakeups per second since the last call to + * getCPUUsage. First call returns 0. Will always return 0 on Windows. + */ + idleWakeupsPerSecond: number; + /** + * Percentage of CPU used since the last call to getCPUUsage. First call returns 0. + */ + percentCPUUsage: number; + } + + interface CrashReport { + + // Docs: https://electronjs.org/docs/api/structures/crash-report + + date: Date; + id: string; + } + + interface CrashReporter { + + // Docs: https://electronjs.org/docs/api/crash-reporter + + /** + * Set an extra parameter to be sent with the crash report. The values specified + * here will be sent in addition to any values set via the `extra` option when + * `start` was called. + * + * Parameters added in this fashion (or via the `extra` parameter to + * `crashReporter.start`) are specific to the calling process. Adding extra + * parameters in the main process will not cause those parameters to be sent along + * with crashes from renderer or other child processes. Similarly, adding extra + * parameters in a renderer process will not result in those parameters being sent + * with crashes that occur in other renderer processes or in the main process. + * + * **Note:** Parameters have limits on the length of the keys and values. Key names + * must be no longer than 39 bytes, and values must be no longer than 20320 bytes. + * Keys with names longer than the maximum will be silently ignored. Key values + * longer than the maximum length will be truncated. + * + * **Note:** On linux values that are longer than 127 bytes will be chunked into + * multiple keys, each 127 bytes in length. E.g. `addExtraParameter('foo', + * 'a'.repeat(130))` will result in two chunked keys `foo__1` and `foo__2`, the + * first will contain the first 127 bytes and the second will contain the remaining + * 3 bytes. On your crash reporting backend you should stitch together keys in + * this format. + */ + addExtraParameter(key: string, value: string): void; + /** + * The date and ID of the last crash report. Only crash reports that have been + * uploaded will be returned; even if a crash report is present on disk it will not + * be returned until it is uploaded. In the case that there are no uploaded + * reports, `null` is returned. + * +**Note:** This method is only available in the main process. + */ + getLastCrashReport(): CrashReport; + /** + * The current 'extra' parameters of the crash reporter. + */ + getParameters(): Record; + /** + * Returns all uploaded crash reports. Each report contains the date and uploaded + * ID. + +**Note:** This method is only available in the main process. + */ + getUploadedReports(): CrashReport[]; + /** + * Whether reports should be submitted to the server. Set through the `start` + * method or `setUploadToServer`. + * +**Note:** This method is only available in the main process. + */ + getUploadToServer(): boolean; + /** + * Remove an extra parameter from the current set of parameters. Future crashes + * will not include this parameter. + */ + removeExtraParameter(key: string): void; + /** + * This would normally be controlled by user preferences. This has no effect if + * called before `start` is called. + * +**Note:** This method is only available in the main process. + */ + setUploadToServer(uploadToServer: boolean): void; + /** + * This method must be called before using any other `crashReporter` APIs. Once + * initialized this way, the crashpad handler collects crashes from all + * subsequently created processes. The crash reporter cannot be disabled once + * started. + * + * This method should be called as early as possible in app startup, preferably + * before `app.on('ready')`. If the crash reporter is not initialized at the time a + * renderer process is created, then that renderer process will not be monitored by + * the crash reporter. + * + * **Note:** You can test out the crash reporter by generating a crash using + * `process.crash()`. + * + * **Note:** If you need to send additional/updated `extra` parameters after your + * first call `start` you can call `addExtraParameter`. + * + * **Note:** Parameters passed in `extra`, `globalExtra` or set with + * `addExtraParameter` have limits on the length of the keys and values. Key names + * must be at most 39 bytes long, and values must be no longer than 127 bytes. Keys + * with names longer than the maximum will be silently ignored. Key values longer + * than the maximum length will be truncated. + * +**Note:** This method is only available in the main process. + */ + start(options: CrashReporterStartOptions): void; + } + + interface CustomScheme { + + // Docs: https://electronjs.org/docs/api/structures/custom-scheme + + privileges?: Privileges; + /** + * Custom schemes to be registered with options. + */ + scheme: string; + } + + class Debugger extends NodeEventEmitter { + + // Docs: https://electronjs.org/docs/api/debugger + + /** + * Emitted when the debugging session is terminated. This happens either when + * `webContents` is closed or devtools is invoked for the attached `webContents`. + */ + on(event: 'detach', listener: (event: Event, + /** + * Reason for detaching debugger. + */ + reason: string) => void): this; + once(event: 'detach', listener: (event: Event, + /** + * Reason for detaching debugger. + */ + reason: string) => void): this; + addListener(event: 'detach', listener: (event: Event, + /** + * Reason for detaching debugger. + */ + reason: string) => void): this; + removeListener(event: 'detach', listener: (event: Event, + /** + * Reason for detaching debugger. + */ + reason: string) => void): this; + /** + * Emitted whenever the debugging target issues an instrumentation event. + */ + on(event: 'message', listener: (event: Event, + /** + * Method name. + */ + method: string, + /** + * Event parameters defined by the 'parameters' attribute in the remote debugging + * protocol. + */ + params: any, + /** + * Unique identifier of attached debugging session, will match the value sent from + * `debugger.sendCommand`. + */ + sessionId: string) => void): this; + once(event: 'message', listener: (event: Event, + /** + * Method name. + */ + method: string, + /** + * Event parameters defined by the 'parameters' attribute in the remote debugging + * protocol. + */ + params: any, + /** + * Unique identifier of attached debugging session, will match the value sent from + * `debugger.sendCommand`. + */ + sessionId: string) => void): this; + addListener(event: 'message', listener: (event: Event, + /** + * Method name. + */ + method: string, + /** + * Event parameters defined by the 'parameters' attribute in the remote debugging + * protocol. + */ + params: any, + /** + * Unique identifier of attached debugging session, will match the value sent from + * `debugger.sendCommand`. + */ + sessionId: string) => void): this; + removeListener(event: 'message', listener: (event: Event, + /** + * Method name. + */ + method: string, + /** + * Event parameters defined by the 'parameters' attribute in the remote debugging + * protocol. + */ + params: any, + /** + * Unique identifier of attached debugging session, will match the value sent from + * `debugger.sendCommand`. + */ + sessionId: string) => void): this; + /** + * Attaches the debugger to the `webContents`. + */ + attach(protocolVersion?: string): void; + /** + * Detaches the debugger from the `webContents`. + */ + detach(): void; + /** + * Whether a debugger is attached to the `webContents`. + */ + isAttached(): boolean; + /** + * A promise that resolves with the response defined by the 'returns' attribute of + * the command description in the remote debugging protocol or is rejected + * indicating the failure of the command. + * +Send given command to the debugging target. + */ + sendCommand(method: string, commandParams?: any, sessionId?: string): Promise; + } + + interface DesktopCapturer { + + // Docs: https://electronjs.org/docs/api/desktop-capturer + + /** + * Resolves with an array of `DesktopCapturerSource` objects, each + * `DesktopCapturerSource` represents a screen or an individual window that can be + * captured. + * + * **Note** Capturing the screen contents requires user consent on macOS 10.15 + * Catalina or higher, which can detected by + * `systemPreferences.getMediaAccessStatus`. + */ + getSources(options: SourcesOptions): Promise; + } + + interface DesktopCapturerSource { + + // Docs: https://electronjs.org/docs/api/structures/desktop-capturer-source + + /** + * An icon image of the application that owns the window or null if the source has + * a type screen. The size of the icon is not known in advance and depends on what + * the application provides. + */ + appIcon: NativeImage; + /** + * A unique identifier that will correspond to the `id` of the matching Display + * returned by the Screen API. On some platforms, this is equivalent to the `XX` + * portion of the `id` field above and on others it will differ. It will be an + * empty string if not available. + */ + display_id: string; + /** + * The identifier of a window or screen that can be used as a `chromeMediaSourceId` + * constraint when calling [`navigator.webkitGetUserMedia`]. The format of the + * identifier will be `window:XX:YY` or `screen:ZZ:0`. XX is the windowID/handle. + * YY is 1 for the current process, and 0 for all others. ZZ is a sequential number + * that represents the screen, and it does not equal to the index in the source's + * name. + */ + id: string; + /** + * A screen source will be named either `Entire Screen` or `Screen `, while + * the name of a window source will match the window title. + */ + name: string; + /** + * A thumbnail image. **Note:** There is no guarantee that the size of the + * thumbnail is the same as the `thumbnailSize` specified in the `options` passed + * to `desktopCapturer.getSources`. The actual size depends on the scale of the + * screen or window. + */ + thumbnail: NativeImage; + } + + interface Dialog { + + // Docs: https://electronjs.org/docs/api/dialog + + /** + * resolves when the certificate trust dialog is shown. + * + * On macOS, this displays a modal dialog that shows a message and certificate + * information, and gives the user the option of trusting/importing the + * certificate. If you provide a `browserWindow` argument the dialog will be + * attached to the parent window, making it modal. + * + * On Windows the options are more limited, due to the Win32 APIs used: + * + * * The `message` argument is not used, as the OS provides its own confirmation + * dialog. + * * The `browserWindow` argument is ignored since it is not possible to make this + * confirmation dialog modal. + * + * @platform darwin,win32 + */ + showCertificateTrustDialog(browserWindow: BrowserWindow, options: CertificateTrustDialogOptions): Promise; + /** + * resolves when the certificate trust dialog is shown. + * + * On macOS, this displays a modal dialog that shows a message and certificate + * information, and gives the user the option of trusting/importing the + * certificate. If you provide a `browserWindow` argument the dialog will be + * attached to the parent window, making it modal. + * + * On Windows the options are more limited, due to the Win32 APIs used: + * + * * The `message` argument is not used, as the OS provides its own confirmation + * dialog. + * * The `browserWindow` argument is ignored since it is not possible to make this + * confirmation dialog modal. + * + * @platform darwin,win32 + */ + showCertificateTrustDialog(options: CertificateTrustDialogOptions): Promise; + /** + * Displays a modal dialog that shows an error message. + * + * This API can be called safely before the `ready` event the `app` module emits, + * it is usually used to report errors in early stage of startup. If called before + * the app `ready`event on Linux, the message will be emitted to stderr, and no GUI + * dialog will appear. + */ + showErrorBox(title: string, content: string): void; + /** + * resolves with a promise containing the following properties: + * + * * `response` Number - The index of the clicked button. + * * `checkboxChecked` Boolean - The checked state of the checkbox if + * `checkboxLabel` was set. Otherwise `false`. + * + * Shows a message box. + * + * The `browserWindow` argument allows the dialog to attach itself to a parent + * window, making it modal. + */ + showMessageBox(browserWindow: BrowserWindow, options: MessageBoxOptions): Promise; + /** + * resolves with a promise containing the following properties: + * + * * `response` Number - The index of the clicked button. + * * `checkboxChecked` Boolean - The checked state of the checkbox if + * `checkboxLabel` was set. Otherwise `false`. + * + * Shows a message box. + * + * The `browserWindow` argument allows the dialog to attach itself to a parent + * window, making it modal. + */ + showMessageBox(options: MessageBoxOptions): Promise; + /** + * the index of the clicked button. + * + * Shows a message box, it will block the process until the message box is closed. + * It returns the index of the clicked button. + * + * The `browserWindow` argument allows the dialog to attach itself to a parent + * window, making it modal. If `browserWindow` is not shown dialog will not be + * attached to it. In such case it will be displayed as an independent window. + */ + showMessageBoxSync(browserWindow: BrowserWindow, options: MessageBoxSyncOptions): number; + /** + * the index of the clicked button. + * + * Shows a message box, it will block the process until the message box is closed. + * It returns the index of the clicked button. + * + * The `browserWindow` argument allows the dialog to attach itself to a parent + * window, making it modal. If `browserWindow` is not shown dialog will not be + * attached to it. In such case it will be displayed as an independent window. + */ + showMessageBoxSync(options: MessageBoxSyncOptions): number; + /** + * Resolve with an object containing the following: + * + * * `canceled` Boolean - whether or not the dialog was canceled. + * * `filePaths` String[] - An array of file paths chosen by the user. If the + * dialog is cancelled this will be an empty array. + * * `bookmarks` String[] (optional) _macOS_ _mas_ - An array matching the + * `filePaths` array of base64 encoded strings which contains security scoped + * bookmark data. `securityScopedBookmarks` must be enabled for this to be + * populated. (For return values, see table here.) + * + * The `browserWindow` argument allows the dialog to attach itself to a parent + * window, making it modal. + * + * The `filters` specifies an array of file types that can be displayed or selected + * when you want to limit the user to a specific type. For example: + * + * The `extensions` array should contain extensions without wildcards or dots (e.g. + * `'png'` is good but `'.png'` and `'*.png'` are bad). To show all files, use the + * `'*'` wildcard (no other wildcard is supported). + * + * **Note:** On Windows and Linux an open dialog can not be both a file selector + * and a directory selector, so if you set `properties` to `['openFile', + * 'openDirectory']` on these platforms, a directory selector will be shown. + */ + showOpenDialog(browserWindow: BrowserWindow, options: OpenDialogOptions): Promise; + /** + * Resolve with an object containing the following: + * + * * `canceled` Boolean - whether or not the dialog was canceled. + * * `filePaths` String[] - An array of file paths chosen by the user. If the + * dialog is cancelled this will be an empty array. + * * `bookmarks` String[] (optional) _macOS_ _mas_ - An array matching the + * `filePaths` array of base64 encoded strings which contains security scoped + * bookmark data. `securityScopedBookmarks` must be enabled for this to be + * populated. (For return values, see table here.) + * + * The `browserWindow` argument allows the dialog to attach itself to a parent + * window, making it modal. + * + * The `filters` specifies an array of file types that can be displayed or selected + * when you want to limit the user to a specific type. For example: + * + * The `extensions` array should contain extensions without wildcards or dots (e.g. + * `'png'` is good but `'.png'` and `'*.png'` are bad). To show all files, use the + * `'*'` wildcard (no other wildcard is supported). + * + * **Note:** On Windows and Linux an open dialog can not be both a file selector + * and a directory selector, so if you set `properties` to `['openFile', + * 'openDirectory']` on these platforms, a directory selector will be shown. + */ + showOpenDialog(options: OpenDialogOptions): Promise; + /** + * the file paths chosen by the user; if the dialog is cancelled it returns + * `undefined`. + * + * The `browserWindow` argument allows the dialog to attach itself to a parent + * window, making it modal. + * + * The `filters` specifies an array of file types that can be displayed or selected + * when you want to limit the user to a specific type. For example: + * + * The `extensions` array should contain extensions without wildcards or dots (e.g. + * `'png'` is good but `'.png'` and `'*.png'` are bad). To show all files, use the + * `'*'` wildcard (no other wildcard is supported). + * + * **Note:** On Windows and Linux an open dialog can not be both a file selector + * and a directory selector, so if you set `properties` to `['openFile', + * 'openDirectory']` on these platforms, a directory selector will be shown. + */ + showOpenDialogSync(browserWindow: BrowserWindow, options: OpenDialogSyncOptions): (string[]) | (undefined); + /** + * the file paths chosen by the user; if the dialog is cancelled it returns + * `undefined`. + * + * The `browserWindow` argument allows the dialog to attach itself to a parent + * window, making it modal. + * + * The `filters` specifies an array of file types that can be displayed or selected + * when you want to limit the user to a specific type. For example: + * + * The `extensions` array should contain extensions without wildcards or dots (e.g. + * `'png'` is good but `'.png'` and `'*.png'` are bad). To show all files, use the + * `'*'` wildcard (no other wildcard is supported). + * + * **Note:** On Windows and Linux an open dialog can not be both a file selector + * and a directory selector, so if you set `properties` to `['openFile', + * 'openDirectory']` on these platforms, a directory selector will be shown. + */ + showOpenDialogSync(options: OpenDialogSyncOptions): (string[]) | (undefined); + /** + * Resolve with an object containing the following: + * + * * `canceled` Boolean - whether or not the dialog was canceled. + * * `filePath` String (optional) - If the dialog is canceled, this will be + * `undefined`. + * * `bookmark` String (optional) _macOS_ _mas_ - Base64 encoded string which + * contains the security scoped bookmark data for the saved file. + * `securityScopedBookmarks` must be enabled for this to be present. (For return + * values, see table here.) + * + * The `browserWindow` argument allows the dialog to attach itself to a parent + * window, making it modal. + * + * The `filters` specifies an array of file types that can be displayed, see + * `dialog.showOpenDialog` for an example. + * + * **Note:** On macOS, using the asynchronous version is recommended to avoid + * issues when expanding and collapsing the dialog. + */ + showSaveDialog(browserWindow: BrowserWindow, options: SaveDialogOptions): Promise; + /** + * Resolve with an object containing the following: + * + * * `canceled` Boolean - whether or not the dialog was canceled. + * * `filePath` String (optional) - If the dialog is canceled, this will be + * `undefined`. + * * `bookmark` String (optional) _macOS_ _mas_ - Base64 encoded string which + * contains the security scoped bookmark data for the saved file. + * `securityScopedBookmarks` must be enabled for this to be present. (For return + * values, see table here.) + * + * The `browserWindow` argument allows the dialog to attach itself to a parent + * window, making it modal. + * + * The `filters` specifies an array of file types that can be displayed, see + * `dialog.showOpenDialog` for an example. + * + * **Note:** On macOS, using the asynchronous version is recommended to avoid + * issues when expanding and collapsing the dialog. + */ + showSaveDialog(options: SaveDialogOptions): Promise; + /** + * the path of the file chosen by the user; if the dialog is cancelled it returns + * `undefined`. + * + * The `browserWindow` argument allows the dialog to attach itself to a parent + * window, making it modal. + * + * The `filters` specifies an array of file types that can be displayed, see + * `dialog.showOpenDialog` for an example. + */ + showSaveDialogSync(browserWindow: BrowserWindow, options: SaveDialogSyncOptions): (string) | (undefined); + /** + * the path of the file chosen by the user; if the dialog is cancelled it returns + * `undefined`. + * + * The `browserWindow` argument allows the dialog to attach itself to a parent + * window, making it modal. + * + * The `filters` specifies an array of file types that can be displayed, see + * `dialog.showOpenDialog` for an example. + */ + showSaveDialogSync(options: SaveDialogSyncOptions): (string) | (undefined); + } + + interface Display { + + // Docs: https://electronjs.org/docs/api/structures/display + + /** + * Can be `available`, `unavailable`, `unknown`. + */ + accelerometerSupport: ('available' | 'unavailable' | 'unknown'); + /** + * the bounds of the display in DIP points. + */ + bounds: Rectangle; + /** + * The number of bits per pixel. + */ + colorDepth: number; + /** + * represent a color space (three-dimensional object which contains all realizable + * color combinations) for the purpose of color conversions + */ + colorSpace: string; + /** + * The number of bits per color component. + */ + depthPerComponent: number; + /** + * The display refresh rate. + */ + displayFrequency: number; + /** + * Unique identifier associated with the display. + */ + id: number; + /** + * `true` for an internal display and `false` for an external display + */ + internal: boolean; + /** + * Whether or not the display is a monochrome display. + */ + monochrome: boolean; + /** + * Can be 0, 90, 180, 270, represents screen rotation in clock-wise degrees. + */ + rotation: number; + /** + * Output device's pixel scale factor. + */ + scaleFactor: number; + size: Size; + /** + * Can be `available`, `unavailable`, `unknown`. + */ + touchSupport: ('available' | 'unavailable' | 'unknown'); + /** + * the work area of the display in DIP points. + */ + workArea: Rectangle; + workAreaSize: Size; + } + + class Dock { + + // Docs: https://electronjs.org/docs/api/dock + + /** + * an ID representing the request. + * + * When `critical` is passed, the dock icon will bounce until either the + * application becomes active or the request is canceled. + * + * When `informational` is passed, the dock icon will bounce for one second. + * However, the request remains active until either the application becomes active + * or the request is canceled. + * + * **Nota Bene:** This method can only be used while the app is not focused; when + * the app is focused it will return -1. + * + * @platform darwin + */ + bounce(type?: 'critical' | 'informational'): number; + /** + * Cancel the bounce of `id`. + * + * @platform darwin + */ + cancelBounce(id: number): void; + /** + * Bounces the Downloads stack if the filePath is inside the Downloads folder. + * + * @platform darwin + */ + downloadFinished(filePath: string): void; + /** + * The badge string of the dock. + * + * @platform darwin + */ + getBadge(): string; + /** + * The application's [dock menu][dock-menu]. + * + * @platform darwin + */ + getMenu(): (Menu) | (null); + /** + * Hides the dock icon. + * + * @platform darwin + */ + hide(): void; + /** + * Whether the dock icon is visible. + * + * @platform darwin + */ + isVisible(): boolean; + /** + * Sets the string to be displayed in the dock’s badging area. + * + * @platform darwin + */ + setBadge(text: string): void; + /** + * Sets the `image` associated with this dock icon. + * + * @platform darwin + */ + setIcon(image: (NativeImage) | (string)): void; + /** + * Sets the application's [dock menu][dock-menu]. + * + * @platform darwin + */ + setMenu(menu: Menu): void; + /** + * Resolves when the dock icon is shown. + * + * @platform darwin + */ + show(): Promise; + } + + class DownloadItem extends NodeEventEmitter { + + // Docs: https://electronjs.org/docs/api/download-item + + /** + * Emitted when the download is in a terminal state. This includes a completed + * download, a cancelled download (via `downloadItem.cancel()`), and interrupted + * download that can't be resumed. + * + * The `state` can be one of following: + * + * * `completed` - The download completed successfully. + * * `cancelled` - The download has been cancelled. + * * `interrupted` - The download has interrupted and can not resume. + */ + on(event: 'done', listener: (event: Event, + /** + * Can be `completed`, `cancelled` or `interrupted`. + */ + state: ('completed' | 'cancelled' | 'interrupted')) => void): this; + once(event: 'done', listener: (event: Event, + /** + * Can be `completed`, `cancelled` or `interrupted`. + */ + state: ('completed' | 'cancelled' | 'interrupted')) => void): this; + addListener(event: 'done', listener: (event: Event, + /** + * Can be `completed`, `cancelled` or `interrupted`. + */ + state: ('completed' | 'cancelled' | 'interrupted')) => void): this; + removeListener(event: 'done', listener: (event: Event, + /** + * Can be `completed`, `cancelled` or `interrupted`. + */ + state: ('completed' | 'cancelled' | 'interrupted')) => void): this; + /** + * Emitted when the download has been updated and is not done. + * + * The `state` can be one of following: + * + * * `progressing` - The download is in-progress. + * * `interrupted` - The download has interrupted and can be resumed. + */ + on(event: 'updated', listener: (event: Event, + /** + * Can be `progressing` or `interrupted`. + */ + state: ('progressing' | 'interrupted')) => void): this; + once(event: 'updated', listener: (event: Event, + /** + * Can be `progressing` or `interrupted`. + */ + state: ('progressing' | 'interrupted')) => void): this; + addListener(event: 'updated', listener: (event: Event, + /** + * Can be `progressing` or `interrupted`. + */ + state: ('progressing' | 'interrupted')) => void): this; + removeListener(event: 'updated', listener: (event: Event, + /** + * Can be `progressing` or `interrupted`. + */ + state: ('progressing' | 'interrupted')) => void): this; + /** + * Cancels the download operation. + */ + cancel(): void; + /** + * Whether the download can resume. + */ + canResume(): boolean; + /** + * The Content-Disposition field from the response header. + */ + getContentDisposition(): string; + /** + * ETag header value. + */ + getETag(): string; + /** + * The file name of the download item. + * + * **Note:** The file name is not always the same as the actual one saved in local + * disk. If user changes the file name in a prompted download saving dialog, the + * actual name of saved file will be different. + */ + getFilename(): string; + /** + * Last-Modified header value. + */ + getLastModifiedTime(): string; + /** + * The files mime type. + */ + getMimeType(): string; + /** + * The received bytes of the download item. + */ + getReceivedBytes(): number; + /** + * Returns the object previously set by + * `downloadItem.setSaveDialogOptions(options)`. + */ + getSaveDialogOptions(): SaveDialogOptions; + /** + * The save path of the download item. This will be either the path set via + * `downloadItem.setSavePath(path)` or the path selected from the shown save + * dialog. + */ + getSavePath(): string; + /** + * Number of seconds since the UNIX epoch when the download was started. + */ + getStartTime(): number; + /** + * The current state. Can be `progressing`, `completed`, `cancelled` or + * `interrupted`. + * + * **Note:** The following methods are useful specifically to resume a `cancelled` + * item when session is restarted. + */ + getState(): ('progressing' | 'completed' | 'cancelled' | 'interrupted'); + /** + * The total size in bytes of the download item. + * +If the size is unknown, it returns 0. + */ + getTotalBytes(): number; + /** + * The origin URL where the item is downloaded from. + */ + getURL(): string; + /** + * The complete URL chain of the item including any redirects. + */ + getURLChain(): string[]; + /** + * Whether the download has user gesture. + */ + hasUserGesture(): boolean; + /** + * Whether the download is paused. + */ + isPaused(): boolean; + /** + * Pauses the download. + */ + pause(): void; + /** + * Resumes the download that has been paused. + * + * **Note:** To enable resumable downloads the server you are downloading from must + * support range requests and provide both `Last-Modified` and `ETag` header + * values. Otherwise `resume()` will dismiss previously received bytes and restart + * the download from the beginning. + */ + resume(): void; + /** + * This API allows the user to set custom options for the save dialog that opens + * for the download item by default. The API is only available in session's + * `will-download` callback function. + */ + setSaveDialogOptions(options: SaveDialogOptions): void; + /** + * The API is only available in session's `will-download` callback function. If + * `path` doesn't exist, Electron will try to make the directory recursively. If + * user doesn't set the save path via the API, Electron will use the original + * routine to determine the save path; this usually prompts a save dialog. + */ + setSavePath(path: string): void; + savePath: string; + } + + interface Event extends GlobalEvent { + + // Docs: https://electronjs.org/docs/api/structures/event + + preventDefault: (() => void); + } + + interface Extension { + + // Docs: https://electronjs.org/docs/api/structures/extension + + id: string; + /** + * Copy of the extension's manifest data. + */ + manifest: any; + name: string; + /** + * The extension's file path. + */ + path: string; + /** + * The extension's `chrome-extension://` URL. + */ + url: string; + version: string; + } + + interface ExtensionInfo { + + // Docs: https://electronjs.org/docs/api/structures/extension-info + + name: string; + version: string; + } + + interface FileFilter { + + // Docs: https://electronjs.org/docs/api/structures/file-filter + + extensions: string[]; + name: string; + } + + interface FilePathWithHeaders { + + // Docs: https://electronjs.org/docs/api/structures/file-path-with-headers + + /** + * Additional headers to be sent. + */ + headers?: Record; + /** + * The path to the file to send. + */ + path: string; + } + + interface GlobalShortcut { + + // Docs: https://electronjs.org/docs/api/global-shortcut + + /** + * Whether this application has registered `accelerator`. + * + * When the accelerator is already taken by other applications, this call will + * still return `false`. This behavior is intended by operating systems, since they + * don't want applications to fight for global shortcuts. + */ + isRegistered(accelerator: Accelerator): boolean; + /** + * Whether or not the shortcut was registered successfully. + * + * Registers a global shortcut of `accelerator`. The `callback` is called when the + * registered shortcut is pressed by the user. + * + * When the accelerator is already taken by other applications, this call will + * silently fail. This behavior is intended by operating systems, since they don't + * want applications to fight for global shortcuts. + * + * The following accelerators will not be registered successfully on macOS 10.14 + * Mojave unless the app has been authorized as a trusted accessibility client: + * + * * "Media Play/Pause" + * * "Media Next Track" +* "Media Previous Track" +* "Media Stop" + */ + register(accelerator: Accelerator, callback: () => void): boolean; + /** + * Registers a global shortcut of all `accelerator` items in `accelerators`. The + * `callback` is called when any of the registered shortcuts are pressed by the + * user. + * + * When a given accelerator is already taken by other applications, this call will + * silently fail. This behavior is intended by operating systems, since they don't + * want applications to fight for global shortcuts. + * + * The following accelerators will not be registered successfully on macOS 10.14 + * Mojave unless the app has been authorized as a trusted accessibility client: + * + * * "Media Play/Pause" + * * "Media Next Track" +* "Media Previous Track" +* "Media Stop" + */ + registerAll(accelerators: string[], callback: () => void): void; + /** + * Unregisters the global shortcut of `accelerator`. + */ + unregister(accelerator: Accelerator): void; + /** + * Unregisters all of the global shortcuts. + */ + unregisterAll(): void; + } + + interface GPUFeatureStatus { + + // Docs: https://electronjs.org/docs/api/structures/gpu-feature-status + + /** + * Canvas. + */ + '2d_canvas': string; + /** + * Flash. + */ + flash_3d: string; + /** + * Flash Stage3D. + */ + flash_stage3d: string; + /** + * Flash Stage3D Baseline profile. + */ + flash_stage3d_baseline: string; + /** + * Compositing. + */ + gpu_compositing: string; + /** + * Multiple Raster Threads. + */ + multiple_raster_threads: string; + /** + * Native GpuMemoryBuffers. + */ + native_gpu_memory_buffers: string; + /** + * Rasterization. + */ + rasterization: string; + /** + * Video Decode. + */ + video_decode: string; + /** + * Video Encode. + */ + video_encode: string; + /** + * VPx Video Decode. + */ + vpx_decode: string; + /** + * WebGL. + */ + webgl: string; + /** + * WebGL2. + */ + webgl2: string; + } + + interface InAppPurchase extends NodeJS.EventEmitter { + + // Docs: https://electronjs.org/docs/api/in-app-purchase + + on(event: 'transactions-updated', listener: Function): this; + once(event: 'transactions-updated', listener: Function): this; + addListener(event: 'transactions-updated', listener: Function): this; + removeListener(event: 'transactions-updated', listener: Function): this; + /** + * whether a user can make a payment. + */ + canMakePayments(): boolean; + /** + * Completes all pending transactions. + */ + finishAllTransactions(): void; + /** + * Completes the pending transactions corresponding to the date. + */ + finishTransactionByDate(date: string): void; + /** + * Resolves with an array of `Product` objects. + * +Retrieves the product descriptions. + */ + getProducts(productIDs: string[]): Promise; + /** + * the path to the receipt. + */ + getReceiptURL(): string; + /** + * Returns `true` if the product is valid and added to the payment queue. + * + * You should listen for the `transactions-updated` event as soon as possible and + * certainly before you call `purchaseProduct`. + */ + purchaseProduct(productID: string, quantity?: number): Promise; + /** + * Restores finished transactions. This method can be called either to install + * purchases on additional devices, or to restore purchases for an application that + * the user deleted and reinstalled. + * + * The payment queue delivers a new transaction for each previously completed + * transaction that can be restored. Each transaction includes a copy of the + * original transaction. + */ + restoreCompletedTransactions(): void; + } + + class IncomingMessage extends NodeEventEmitter { + + // Docs: https://electronjs.org/docs/api/incoming-message + + /** + * Emitted when a request has been canceled during an ongoing HTTP transaction. + */ + on(event: 'aborted', listener: Function): this; + once(event: 'aborted', listener: Function): this; + addListener(event: 'aborted', listener: Function): this; + removeListener(event: 'aborted', listener: Function): this; + /** + * The `data` event is the usual method of transferring response data into + * applicative code. + */ + on(event: 'data', listener: ( + /** + * A chunk of response body's data. + */ + chunk: Buffer) => void): this; + once(event: 'data', listener: ( + /** + * A chunk of response body's data. + */ + chunk: Buffer) => void): this; + addListener(event: 'data', listener: ( + /** + * A chunk of response body's data. + */ + chunk: Buffer) => void): this; + removeListener(event: 'data', listener: ( + /** + * A chunk of response body's data. + */ + chunk: Buffer) => void): this; + /** + * Indicates that response body has ended. Must be placed before 'data' event. + */ + on(event: 'end', listener: Function): this; + once(event: 'end', listener: Function): this; + addListener(event: 'end', listener: Function): this; + removeListener(event: 'end', listener: Function): this; + /** + * Returns: + * + * `error` Error - Typically holds an error string identifying failure root cause. + * + * Emitted when an error was encountered while streaming response data events. For + * instance, if the server closes the underlying while the response is still + * streaming, an `error` event will be emitted on the response object and a `close` + * event will subsequently follow on the request object. + */ + on(event: 'error', listener: Function): this; + once(event: 'error', listener: Function): this; + addListener(event: 'error', listener: Function): this; + removeListener(event: 'error', listener: Function): this; + headers: Record; + httpVersion: string; + httpVersionMajor: number; + httpVersionMinor: number; + statusCode: number; + statusMessage: string; + } + + interface InputEvent { + + // Docs: https://electronjs.org/docs/api/structures/input-event + + /** + * An array of modifiers of the event, can be `shift`, `control`, `ctrl`, `alt`, + * `meta`, `command`, `cmd`, `isKeypad`, `isAutoRepeat`, `leftButtonDown`, + * `middleButtonDown`, `rightButtonDown`, `capsLock`, `numLock`, `left`, `right`. + */ + modifiers?: Array<'shift' | 'control' | 'ctrl' | 'alt' | 'meta' | 'command' | 'cmd' | 'isKeypad' | 'isAutoRepeat' | 'leftButtonDown' | 'middleButtonDown' | 'rightButtonDown' | 'capsLock' | 'numLock' | 'left' | 'right'>; + } + + interface IOCounters { + + // Docs: https://electronjs.org/docs/api/structures/io-counters + + /** + * Then number of I/O other operations. + */ + otherOperationCount: number; + /** + * Then number of I/O other transfers. + */ + otherTransferCount: number; + /** + * The number of I/O read operations. + */ + readOperationCount: number; + /** + * The number of I/O read transfers. + */ + readTransferCount: number; + /** + * The number of I/O write operations. + */ + writeOperationCount: number; + /** + * The number of I/O write transfers. + */ + writeTransferCount: number; + } + + interface IpcMain extends NodeJS.EventEmitter { + + // Docs: https://electronjs.org/docs/api/ipc-main + + /** + * Adds a handler for an `invoke`able IPC. This handler will be called whenever a + * renderer calls `ipcRenderer.invoke(channel, ...args)`. + * + * If `listener` returns a Promise, the eventual result of the promise will be + * returned as a reply to the remote caller. Otherwise, the return value of the + * listener will be used as the value of the reply. + * + * The `event` that is passed as the first argument to the handler is the same as + * that passed to a regular event listener. It includes information about which + * WebContents is the source of the invoke request. + * + * Errors thrown through `handle` in the main process are not transparent as they + * are serialized and only the `message` property from the original error is + * provided to the renderer process. Please refer to #24427 for details. + */ + handle(channel: string, listener: (event: IpcMainInvokeEvent, ...args: any[]) => (Promise) | (any)): void; + /** + * Handles a single `invoke`able IPC message, then removes the listener. See + * `ipcMain.handle(channel, listener)`. + */ + handleOnce(channel: string, listener: (event: IpcMainInvokeEvent, ...args: any[]) => (Promise) | (any)): void; + /** + * Listens to `channel`, when a new message arrives `listener` would be called with + * `listener(event, args...)`. + */ + on(channel: string, listener: (event: IpcMainEvent, ...args: any[]) => void): this; + /** + * Adds a one time `listener` function for the event. This `listener` is invoked + * only the next time a message is sent to `channel`, after which it is removed. + */ + once(channel: string, listener: (event: IpcMainEvent, ...args: any[]) => void): this; + /** + * Removes listeners of the specified `channel`. + */ + removeAllListeners(channel?: string): this; + /** + * Removes any handler for `channel`, if present. + */ + removeHandler(channel: string): void; + /** + * Removes the specified `listener` from the listener array for the specified + * `channel`. + */ + removeListener(channel: string, listener: (...args: any[]) => void): this; + } + + interface IpcMainEvent extends Event { + + // Docs: https://electronjs.org/docs/api/structures/ipc-main-event + + /** + * The ID of the renderer frame that sent this message + */ + frameId: number; + /** + * A list of MessagePorts that were transferred with this message + */ + ports: MessagePortMain[]; + /** + * The internal ID of the renderer process that sent this message + */ + processId: number; + /** + * A function that will send an IPC message to the renderer frame that sent the + * original message that you are currently handling. You should use this method to + * "reply" to the sent message in order to guarantee the reply will go to the + * correct process and frame. + */ + reply: Function; + /** + * Set this to the value to be returned in a synchronous message + */ + returnValue: any; + /** + * Returns the `webContents` that sent the message + */ + sender: WebContents; + /** + * The frame that sent this message + * + */ + readonly senderFrame: WebFrameMain; + } + + interface IpcMainInvokeEvent extends Event { + + // Docs: https://electronjs.org/docs/api/structures/ipc-main-invoke-event + + /** + * The ID of the renderer frame that sent this message + */ + frameId: number; + /** + * The internal ID of the renderer process that sent this message + */ + processId: number; + /** + * Returns the `webContents` that sent the message + */ + sender: WebContents; + /** + * The frame that sent this message + * + */ + readonly senderFrame: WebFrameMain; + } + + interface IpcRenderer extends NodeJS.EventEmitter { + + // Docs: https://electronjs.org/docs/api/ipc-renderer + + /** + * Resolves with the response from the main process. + * + * Send a message to the main process via `channel` and expect a result + * asynchronously. Arguments will be serialized with the Structured Clone + * Algorithm, just like `window.postMessage`, so prototype chains will not be + * included. Sending Functions, Promises, Symbols, WeakMaps, or WeakSets will throw + * an exception. + * + * > **NOTE:** Sending non-standard JavaScript types such as DOM objects or special + * Electron objects will throw an exception. + * + * Since the main process does not have support for DOM objects such as + * `ImageBitmap`, `File`, `DOMMatrix` and so on, such objects cannot be sent over + * Electron's IPC to the main process, as the main process would have no way to + * decode them. Attempting to send such objects over IPC will result in an error. + * + * The main process should listen for `channel` with `ipcMain.handle()`. + * + * For example: + * + * If you need to transfer a `MessagePort` to the main process, use + * `ipcRenderer.postMessage`. + * + * If you do not need a response to the message, consider using `ipcRenderer.send`. + */ + invoke(channel: string, ...args: any[]): Promise; + /** + * Listens to `channel`, when a new message arrives `listener` would be called with + * `listener(event, args...)`. + */ + on(channel: string, listener: (event: IpcRendererEvent, ...args: any[]) => void): this; + /** + * Adds a one time `listener` function for the event. This `listener` is invoked + * only the next time a message is sent to `channel`, after which it is removed. + */ + once(channel: string, listener: (event: IpcRendererEvent, ...args: any[]) => void): this; + /** + * Send a message to the main process, optionally transferring ownership of zero or + * more `MessagePort` objects. + * + * The transferred `MessagePort` objects will be available in the main process as + * `MessagePortMain` objects by accessing the `ports` property of the emitted + * event. + * + * For example: + * + * For more information on using `MessagePort` and `MessageChannel`, see the MDN + * documentation. + */ + postMessage(channel: string, message: any, transfer?: MessagePort[]): void; + /** + * Removes all listeners, or those of the specified `channel`. + */ + removeAllListeners(channel: string): this; + /** + * Removes the specified `listener` from the listener array for the specified + * `channel`. + */ + removeListener(channel: string, listener: (...args: any[]) => void): this; + /** + * Send an asynchronous message to the main process via `channel`, along with + * arguments. Arguments will be serialized with the Structured Clone Algorithm, + * just like `window.postMessage`, so prototype chains will not be included. + * Sending Functions, Promises, Symbols, WeakMaps, or WeakSets will throw an + * exception. + * + * > **NOTE:** Sending non-standard JavaScript types such as DOM objects or special + * Electron objects will throw an exception. + * + * Since the main process does not have support for DOM objects such as + * `ImageBitmap`, `File`, `DOMMatrix` and so on, such objects cannot be sent over + * Electron's IPC to the main process, as the main process would have no way to + * decode them. Attempting to send such objects over IPC will result in an error. + * + * The main process handles it by listening for `channel` with the `ipcMain` + * module. + * + * If you need to transfer a `MessagePort` to the main process, use + * `ipcRenderer.postMessage`. + * + * If you want to receive a single response from the main process, like the result + * of a method call, consider using `ipcRenderer.invoke`. + */ + send(channel: string, ...args: any[]): void; + /** + * The value sent back by the `ipcMain` handler. + * + * Send a message to the main process via `channel` and expect a result + * synchronously. Arguments will be serialized with the Structured Clone Algorithm, + * just like `window.postMessage`, so prototype chains will not be included. + * Sending Functions, Promises, Symbols, WeakMaps, or WeakSets will throw an + * exception. + * + * > **NOTE:** Sending non-standard JavaScript types such as DOM objects or special + * Electron objects will throw an exception. + * + * Since the main process does not have support for DOM objects such as + * `ImageBitmap`, `File`, `DOMMatrix` and so on, such objects cannot be sent over + * Electron's IPC to the main process, as the main process would have no way to + * decode them. Attempting to send such objects over IPC will result in an error. + * + * The main process handles it by listening for `channel` with `ipcMain` module, + * and replies by setting `event.returnValue`. + * + * > :warning: **WARNING**: Sending a synchronous message will block the whole + * renderer process until the reply is received, so use this method only as a last + * resort. It's much better to use the asynchronous version, `invoke()`. + */ + sendSync(channel: string, ...args: any[]): any; + /** + * Sends a message to a window with `webContentsId` via `channel`. + */ + sendTo(webContentsId: number, channel: string, ...args: any[]): void; + /** + * Like `ipcRenderer.send` but the event will be sent to the `` element in + * the host page instead of the main process. + */ + sendToHost(channel: string, ...args: any[]): void; + } + + interface IpcRendererEvent extends Event { + + // Docs: https://electronjs.org/docs/api/structures/ipc-renderer-event + + /** + * A list of MessagePorts that were transferred with this message + */ + ports: MessagePort[]; + /** + * The `IpcRenderer` instance that emitted the event originally + */ + sender: IpcRenderer; + /** + * The `webContents.id` that sent the message, you can call + * `event.sender.sendTo(event.senderId, ...)` to reply to the message, see + * ipcRenderer.sendTo for more information. This only applies to messages sent from + * a different renderer. Messages sent directly from the main process set + * `event.senderId` to `0`. + */ + senderId: number; + } + + interface JumpListCategory { + + // Docs: https://electronjs.org/docs/api/structures/jump-list-category + + /** + * Array of `JumpListItem` objects if `type` is `tasks` or `custom`, otherwise it + * should be omitted. + */ + items?: JumpListItem[]; + /** + * Must be set if `type` is `custom`, otherwise it should be omitted. + */ + name?: string; + /** + * One of the following: + */ + type?: ('tasks' | 'frequent' | 'recent' | 'custom'); + } + + interface JumpListItem { + + // Docs: https://electronjs.org/docs/api/structures/jump-list-item + + /** + * The command line arguments when `program` is executed. Should only be set if + * `type` is `task`. + */ + args?: string; + /** + * Description of the task (displayed in a tooltip). Should only be set if `type` + * is `task`. Maximum length 260 characters. + */ + description?: string; + /** + * The index of the icon in the resource file. If a resource file contains multiple + * icons this value can be used to specify the zero-based index of the icon that + * should be displayed for this task. If a resource file contains only one icon, + * this property should be set to zero. + */ + iconIndex?: number; + /** + * The absolute path to an icon to be displayed in a Jump List, which can be an + * arbitrary resource file that contains an icon (e.g. `.ico`, `.exe`, `.dll`). You + * can usually specify `process.execPath` to show the program icon. + */ + iconPath?: string; + /** + * Path of the file to open, should only be set if `type` is `file`. + */ + path?: string; + /** + * Path of the program to execute, usually you should specify `process.execPath` + * which opens the current program. Should only be set if `type` is `task`. + */ + program?: string; + /** + * The text to be displayed for the item in the Jump List. Should only be set if + * `type` is `task`. + */ + title?: string; + /** + * One of the following: + */ + type?: ('task' | 'separator' | 'file'); + /** + * The working directory. Default is empty. + */ + workingDirectory?: string; + } + + interface KeyboardEvent { + + // Docs: https://electronjs.org/docs/api/structures/keyboard-event + + /** + * whether an Alt key was used in an accelerator to trigger the Event + */ + altKey?: boolean; + /** + * whether the Control key was used in an accelerator to trigger the Event + */ + ctrlKey?: boolean; + /** + * whether a meta key was used in an accelerator to trigger the Event + */ + metaKey?: boolean; + /** + * whether a Shift key was used in an accelerator to trigger the Event + */ + shiftKey?: boolean; + /** + * whether an accelerator was used to trigger the event as opposed to another user + * gesture like mouse click + */ + triggeredByAccelerator?: boolean; + } + + interface KeyboardInputEvent extends InputEvent { + + // Docs: https://electronjs.org/docs/api/structures/keyboard-input-event + + /** + * The character that will be sent as the keyboard event. Should only use the valid + * key codes in Accelerator. + */ + keyCode: string; + /** + * The type of the event, can be `keyDown`, `keyUp` or `char`. + */ + type: ('keyDown' | 'keyUp' | 'char'); + } + + interface MemoryInfo { + + // Docs: https://electronjs.org/docs/api/structures/memory-info + + /** + * The maximum amount of memory that has ever been pinned to actual physical RAM. + */ + peakWorkingSetSize: number; + /** + * The amount of memory not shared by other processes, such as JS heap or HTML + * content. + * + * @platform win32 + */ + privateBytes?: number; + /** + * The amount of memory currently pinned to actual physical RAM. + */ + workingSetSize: number; + } + + interface MemoryUsageDetails { + + // Docs: https://electronjs.org/docs/api/structures/memory-usage-details + + count: number; + liveSize: number; + size: number; + } + + class Menu { + + // Docs: https://electronjs.org/docs/api/menu + + /** + * Emitted when a popup is closed either manually or with `menu.closePopup()`. + */ + on(event: 'menu-will-close', listener: (event: Event) => void): this; + once(event: 'menu-will-close', listener: (event: Event) => void): this; + addListener(event: 'menu-will-close', listener: (event: Event) => void): this; + removeListener(event: 'menu-will-close', listener: (event: Event) => void): this; + /** + * Emitted when `menu.popup()` is called. + */ + on(event: 'menu-will-show', listener: (event: Event) => void): this; + once(event: 'menu-will-show', listener: (event: Event) => void): this; + addListener(event: 'menu-will-show', listener: (event: Event) => void): this; + removeListener(event: 'menu-will-show', listener: (event: Event) => void): this; + /** + * Menu + */ + constructor(); + /** + * Generally, the `template` is an array of `options` for constructing a MenuItem. + * The usage can be referenced above. + * + * You can also attach other fields to the element of the `template` and they will + * become properties of the constructed menu items. + */ + static buildFromTemplate(template: Array<(MenuItemConstructorOptions) | (MenuItem)>): Menu; + /** + * The application menu, if set, or `null`, if not set. + * + * **Note:** The returned `Menu` instance doesn't support dynamic addition or + * removal of menu items. Instance properties can still be dynamically modified. + */ + static getApplicationMenu(): (Menu) | (null); + /** + * Sends the `action` to the first responder of application. This is used for + * emulating default macOS menu behaviors. Usually you would use the `role` + * property of a `MenuItem`. + * + * See the macOS Cocoa Event Handling Guide for more information on macOS' native + * actions. + * + * @platform darwin + */ + static sendActionToFirstResponder(action: string): void; + /** + * Sets `menu` as the application menu on macOS. On Windows and Linux, the `menu` + * will be set as each window's top menu. + * + * Also on Windows and Linux, you can use a `&` in the top-level item name to + * indicate which letter should get a generated accelerator. For example, using + * `&File` for the file menu would result in a generated `Alt-F` accelerator that + * opens the associated menu. The indicated character in the button label then gets + * an underline, and the `&` character is not displayed on the button label. + * + * In order to escape the `&` character in an item name, add a proceeding `&`. For + * example, `&&File` would result in `&File` displayed on the button label. + * + * Passing `null` will suppress the default menu. On Windows and Linux, this has + * the additional effect of removing the menu bar from the window. + * + * **Note:** The default menu will be created automatically if the app does not set + * one. It contains standard items such as `File`, `Edit`, `View`, `Window` and + * `Help`. + */ + static setApplicationMenu(menu: (Menu) | (null)): void; + /** + * Appends the `menuItem` to the menu. + */ + append(menuItem: MenuItem): void; + /** + * Closes the context menu in the `browserWindow`. + */ + closePopup(browserWindow?: BrowserWindow): void; + /** + * the item with the specified `id` + */ + getMenuItemById(id: string): (MenuItem) | (null); + /** + * Inserts the `menuItem` to the `pos` position of the menu. + */ + insert(pos: number, menuItem: MenuItem): void; + /** + * Pops up this menu as a context menu in the `BrowserWindow`. + */ + popup(options?: PopupOptions): void; + items: MenuItem[]; + } + + class MenuItem { + + // Docs: https://electronjs.org/docs/api/menu-item + + /** + * MenuItem + */ + constructor(options: MenuItemConstructorOptions); + accelerator?: Accelerator; + checked: boolean; + click: Function; + commandId: number; + enabled: boolean; + icon?: (NativeImage) | (string); + id: string; + label: string; + menu: Menu; + registerAccelerator: boolean; + role?: ('undo' | 'redo' | 'cut' | 'copy' | 'paste' | 'pasteAndMatchStyle' | 'delete' | 'selectAll' | 'reload' | 'forceReload' | 'toggleDevTools' | 'resetZoom' | 'zoomIn' | 'zoomOut' | 'togglefullscreen' | 'window' | 'minimize' | 'close' | 'help' | 'about' | 'services' | 'hide' | 'hideOthers' | 'unhide' | 'quit' | 'startSpeaking' | 'stopSpeaking' | 'zoom' | 'front' | 'appMenu' | 'fileMenu' | 'editMenu' | 'viewMenu' | 'recentDocuments' | 'toggleTabBar' | 'selectNextTab' | 'selectPreviousTab' | 'mergeAllWindows' | 'clearRecentDocuments' | 'moveTabToNewWindow' | 'windowMenu'); + sharingItem: SharingItem; + sublabel: string; + submenu?: Menu; + toolTip: string; + type: ('normal' | 'separator' | 'submenu' | 'checkbox' | 'radio'); + visible: boolean; + } + + class MessageChannelMain extends NodeEventEmitter { + + // Docs: https://electronjs.org/docs/api/message-channel-main + + port1: MessagePortMain; + port2: MessagePortMain; + } + + class MessagePortMain extends NodeEventEmitter { + + // Docs: https://electronjs.org/docs/api/message-port-main + + /** + * Emitted when the remote end of a MessagePortMain object becomes disconnected. + */ + on(event: 'close', listener: Function): this; + once(event: 'close', listener: Function): this; + addListener(event: 'close', listener: Function): this; + removeListener(event: 'close', listener: Function): this; + /** + * Emitted when a MessagePortMain object receives a message. + */ + on(event: 'message', listener: (messageEvent: MessageEvent) => void): this; + once(event: 'message', listener: (messageEvent: MessageEvent) => void): this; + addListener(event: 'message', listener: (messageEvent: MessageEvent) => void): this; + removeListener(event: 'message', listener: (messageEvent: MessageEvent) => void): this; + /** + * Disconnects the port, so it is no longer active. + */ + close(): void; + /** + * Sends a message from the port, and optionally, transfers ownership of objects to + * other browsing contexts. + */ + postMessage(message: any, transfer?: MessagePortMain[]): void; + /** + * Starts the sending of messages queued on the port. Messages will be queued until + * this method is called. + */ + start(): void; + } + + interface MimeTypedBuffer { + + // Docs: https://electronjs.org/docs/api/structures/mime-typed-buffer + + /** + * Charset of the buffer. + */ + charset?: string; + /** + * The actual Buffer content. + */ + data: Buffer; + /** + * MIME type of the buffer. + */ + mimeType?: string; + } + + interface MouseInputEvent extends InputEvent { + + // Docs: https://electronjs.org/docs/api/structures/mouse-input-event + + /** + * The button pressed, can be `left`, `middle`, `right`. + */ + button?: ('left' | 'middle' | 'right'); + clickCount?: number; + globalX?: number; + globalY?: number; + movementX?: number; + movementY?: number; + /** + * The type of the event, can be `mouseDown`, `mouseUp`, `mouseEnter`, + * `mouseLeave`, `contextMenu`, `mouseWheel` or `mouseMove`. + */ + type: ('mouseDown' | 'mouseUp' | 'mouseEnter' | 'mouseLeave' | 'contextMenu' | 'mouseWheel' | 'mouseMove'); + x: number; + y: number; + } + + interface MouseWheelInputEvent extends MouseInputEvent { + + // Docs: https://electronjs.org/docs/api/structures/mouse-wheel-input-event + + accelerationRatioX?: number; + accelerationRatioY?: number; + canScroll?: boolean; + deltaX?: number; + deltaY?: number; + hasPreciseScrollingDeltas?: boolean; + /** + * The type of the event, can be `mouseWheel`. + */ + type: ('mouseWheel'); + wheelTicksX?: number; + wheelTicksY?: number; + } + + class NativeImage { + + // Docs: https://electronjs.org/docs/api/native-image + + /** + * Creates an empty `NativeImage` instance. + */ + static createEmpty(): NativeImage; + /** + * Creates a new `NativeImage` instance from `buffer` that contains the raw bitmap + * pixel data returned by `toBitmap()`. The specific format is platform-dependent. + */ + static createFromBitmap(buffer: Buffer, options: CreateFromBitmapOptions): NativeImage; + /** + * Creates a new `NativeImage` instance from `buffer`. Tries to decode as PNG or + * JPEG first. + */ + static createFromBuffer(buffer: Buffer, options?: CreateFromBufferOptions): NativeImage; + /** + * Creates a new `NativeImage` instance from `dataURL`. + */ + static createFromDataURL(dataURL: string): NativeImage; + /** + * Creates a new `NativeImage` instance from the NSImage that maps to the given + * image name. See `System Icons` for a list of possible values. + * + * The `hslShift` is applied to the image with the following rules: + * + * * `hsl_shift[0]` (hue): The absolute hue value for the image - 0 and 1 map to 0 + * and 360 on the hue color wheel (red). + * * `hsl_shift[1]` (saturation): A saturation shift for the image, with the + * following key values: 0 = remove all color. 0.5 = leave unchanged. 1 = fully + * saturate the image. + * * `hsl_shift[2]` (lightness): A lightness shift for the image, with the + * following key values: 0 = remove all lightness (make all pixels black). 0.5 = + * leave unchanged. 1 = full lightness (make all pixels white). + * + * This means that `[-1, 0, 1]` will make the image completely white and `[-1, 1, + * 0]` will make the image completely black. + * + * In some cases, the `NSImageName` doesn't match its string representation; one + * example of this is `NSFolderImageName`, whose string representation would + * actually be `NSFolder`. Therefore, you'll need to determine the correct string + * representation for your image before passing it in. This can be done with the + * following: + * + * `echo -e '#import \nint main() { NSLog(@"%@", SYSTEM_IMAGE_NAME); + * }' | clang -otest -x objective-c -framework Cocoa - && ./test` + * +where `SYSTEM_IMAGE_NAME` should be replaced with any value from this list. + * + * @platform darwin + */ + static createFromNamedImage(imageName: string, hslShift?: number[]): NativeImage; + /** + * Creates a new `NativeImage` instance from a file located at `path`. This method + * returns an empty image if the `path` does not exist, cannot be read, or is not a + * valid image. + */ + static createFromPath(path: string): NativeImage; + /** + * fulfilled with the file's thumbnail preview image, which is a NativeImage. + * + * @platform darwin,win32 + */ + static createThumbnailFromPath(path: string, maxSize: Size): Promise; + /** + * Add an image representation for a specific scale factor. This can be used to + * explicitly add different scale factor representations to an image. This can be + * called on empty images. + */ + addRepresentation(options: AddRepresentationOptions): void; + /** + * The cropped image. + */ + crop(rect: Rectangle): NativeImage; + /** + * The image's aspect ratio. + * + * If `scaleFactor` is passed, this will return the aspect ratio corresponding to + * the image representation most closely matching the passed value. + */ + getAspectRatio(scaleFactor?: number): number; + /** + * A Buffer that contains the image's raw bitmap pixel data. + * + * The difference between `getBitmap()` and `toBitmap()` is that `getBitmap()` does + * not copy the bitmap data, so you have to use the returned Buffer immediately in + * current event loop tick; otherwise the data might be changed or destroyed. + */ + getBitmap(options?: BitmapOptions): Buffer; + /** + * A Buffer that stores C pointer to underlying native handle of the image. On + * macOS, a pointer to `NSImage` instance would be returned. + * + * Notice that the returned pointer is a weak pointer to the underlying native + * image instead of a copy, so you _must_ ensure that the associated `nativeImage` + * instance is kept around. + * + * @platform darwin + */ + getNativeHandle(): Buffer; + /** + * An array of all scale factors corresponding to representations for a given + * nativeImage. + */ + getScaleFactors(): number[]; + /** + * If `scaleFactor` is passed, this will return the size corresponding to the image + * representation most closely matching the passed value. + */ + getSize(scaleFactor?: number): Size; + /** + * Whether the image is empty. + */ + isEmpty(): boolean; + /** + * Whether the image is a template image. + */ + isTemplateImage(): boolean; + /** + * The resized image. + * + * If only the `height` or the `width` are specified then the current aspect ratio + * will be preserved in the resized image. + */ + resize(options: ResizeOptions): NativeImage; + /** + * Marks the image as a template image. + */ + setTemplateImage(option: boolean): void; + /** + * A Buffer that contains a copy of the image's raw bitmap pixel data. + */ + toBitmap(options?: ToBitmapOptions): Buffer; + /** + * The data URL of the image. + */ + toDataURL(options?: ToDataURLOptions): string; + /** + * A Buffer that contains the image's `JPEG` encoded data. + */ + toJPEG(quality: number): Buffer; + /** + * A Buffer that contains the image's `PNG` encoded data. + */ + toPNG(options?: ToPNGOptions): Buffer; + isMacTemplateImage: boolean; + } + + interface NativeTheme extends NodeJS.EventEmitter { + + // Docs: https://electronjs.org/docs/api/native-theme + + /** + * Emitted when something in the underlying NativeTheme has changed. This normally + * means that either the value of `shouldUseDarkColors`, + * `shouldUseHighContrastColors` or `shouldUseInvertedColorScheme` has changed. You + * will have to check them to determine which one has changed. + */ + on(event: 'updated', listener: Function): this; + once(event: 'updated', listener: Function): this; + addListener(event: 'updated', listener: Function): this; + removeListener(event: 'updated', listener: Function): this; + /** + * A `Boolean` for if the OS / Chromium currently has a dark mode enabled or is + * being instructed to show a dark-style UI. If you want to modify this value you + * should use `themeSource` below. + * + */ + readonly shouldUseDarkColors: boolean; + /** + * A `Boolean` for if the OS / Chromium currently has high-contrast mode enabled or + * is being instructed to show a high-contrast UI. + * + * @platform darwin,win32 + */ + readonly shouldUseHighContrastColors: boolean; + /** + * A `Boolean` for if the OS / Chromium currently has an inverted color scheme or + * is being instructed to use an inverted color scheme. + * + * @platform darwin,win32 + */ + readonly shouldUseInvertedColorScheme: boolean; + /** + * A `String` property that can be `system`, `light` or `dark`. It is used to + * override and supersede the value that Chromium has chosen to use internally. + * + * Setting this property to `system` will remove the override and everything will + * be reset to the OS default. By default `themeSource` is `system`. + * + * Settings this property to `dark` will have the following effects: + * + * * `nativeTheme.shouldUseDarkColors` will be `true` when accessed + * * Any UI Electron renders on Linux and Windows including context menus, + * devtools, etc. will use the dark UI. + * * Any UI the OS renders on macOS including menus, window frames, etc. will use + * the dark UI. + * * The `prefers-color-scheme` CSS query will match `dark` mode. + * * The `updated` event will be emitted + * + * Settings this property to `light` will have the following effects: + * + * * `nativeTheme.shouldUseDarkColors` will be `false` when accessed + * * Any UI Electron renders on Linux and Windows including context menus, + * devtools, etc. will use the light UI. + * * Any UI the OS renders on macOS including menus, window frames, etc. will use + * the light UI. + * * The `prefers-color-scheme` CSS query will match `light` mode. + * * The `updated` event will be emitted + * + * The usage of this property should align with a classic "dark mode" state machine + * in your application where the user has three options. + * + * * `Follow OS` --> `themeSource = 'system'` + * * `Dark Mode` --> `themeSource = 'dark'` + * * `Light Mode` --> `themeSource = 'light'` + * + * Your application should then always use `shouldUseDarkColors` to determine what + * CSS to apply. + */ + themeSource: ('system' | 'light' | 'dark'); + } + + interface Net { + + // Docs: https://electronjs.org/docs/api/net + + /** + * Whether there is currently internet connection. + * + * A return value of `false` is a pretty strong indicator that the user won't be + * able to connect to remote sites. However, a return value of `true` is + * inconclusive; even if some link is up, it is uncertain whether a particular + * connection attempt to a particular remote site will be successful. + */ + isOnline(): boolean; + /** + * Creates a `ClientRequest` instance using the provided `options` which are + * directly forwarded to the `ClientRequest` constructor. The `net.request` method + * would be used to issue both secure and insecure HTTP requests according to the + * specified protocol scheme in the `options` object. + */ + request(options: (ClientRequestConstructorOptions) | (string)): ClientRequest; + /** + * A `Boolean` property. Whether there is currently internet connection. + * + * A return value of `false` is a pretty strong indicator that the user won't be + * able to connect to remote sites. However, a return value of `true` is + * inconclusive; even if some link is up, it is uncertain whether a particular + * connection attempt to a particular remote site will be successful. + * + */ + readonly online: boolean; + } + + interface NetLog { + + // Docs: https://electronjs.org/docs/api/net-log + + /** + * resolves when the net log has begun recording. + * +Starts recording network events to `path`. + */ + startLogging(path: string, options?: StartLoggingOptions): Promise; + /** + * resolves when the net log has been flushed to disk. + * + * Stops recording network events. If not called, net logging will automatically + * end when app quits. + */ + stopLogging(): Promise; + /** + * A `Boolean` property that indicates whether network logs are currently being + * recorded. + * + */ + readonly currentlyLogging: boolean; + } + + interface NewWindowWebContentsEvent extends Event { + + // Docs: https://electronjs.org/docs/api/structures/new-window-web-contents-event + + newGuest?: BrowserWindow; + } + + class Notification extends NodeEventEmitter { + + // Docs: https://electronjs.org/docs/api/notification + + on(event: 'action', listener: (event: Event, + /** + * The index of the action that was activated. + */ + index: number) => void): this; + once(event: 'action', listener: (event: Event, + /** + * The index of the action that was activated. + */ + index: number) => void): this; + addListener(event: 'action', listener: (event: Event, + /** + * The index of the action that was activated. + */ + index: number) => void): this; + removeListener(event: 'action', listener: (event: Event, + /** + * The index of the action that was activated. + */ + index: number) => void): this; + /** + * Emitted when the notification is clicked by the user. + */ + on(event: 'click', listener: (event: Event) => void): this; + once(event: 'click', listener: (event: Event) => void): this; + addListener(event: 'click', listener: (event: Event) => void): this; + removeListener(event: 'click', listener: (event: Event) => void): this; + /** + * Emitted when the notification is closed by manual intervention from the user. + * + * This event is not guaranteed to be emitted in all cases where the notification + * is closed. + */ + on(event: 'close', listener: (event: Event) => void): this; + once(event: 'close', listener: (event: Event) => void): this; + addListener(event: 'close', listener: (event: Event) => void): this; + removeListener(event: 'close', listener: (event: Event) => void): this; + /** + * Emitted when an error is encountered while creating and showing the native + * notification. + * + * @platform win32 + */ + on(event: 'failed', listener: (event: Event, + /** + * The error encountered during execution of the `show()` method. + */ + error: string) => void): this; + once(event: 'failed', listener: (event: Event, + /** + * The error encountered during execution of the `show()` method. + */ + error: string) => void): this; + addListener(event: 'failed', listener: (event: Event, + /** + * The error encountered during execution of the `show()` method. + */ + error: string) => void): this; + removeListener(event: 'failed', listener: (event: Event, + /** + * The error encountered during execution of the `show()` method. + */ + error: string) => void): this; + /** + * Emitted when the user clicks the "Reply" button on a notification with + * `hasReply: true`. + * + * @platform darwin + */ + on(event: 'reply', listener: (event: Event, + /** + * The string the user entered into the inline reply field. + */ + reply: string) => void): this; + once(event: 'reply', listener: (event: Event, + /** + * The string the user entered into the inline reply field. + */ + reply: string) => void): this; + addListener(event: 'reply', listener: (event: Event, + /** + * The string the user entered into the inline reply field. + */ + reply: string) => void): this; + removeListener(event: 'reply', listener: (event: Event, + /** + * The string the user entered into the inline reply field. + */ + reply: string) => void): this; + /** + * Emitted when the notification is shown to the user, note this could be fired + * multiple times as a notification can be shown multiple times through the + * `show()` method. + */ + on(event: 'show', listener: (event: Event) => void): this; + once(event: 'show', listener: (event: Event) => void): this; + addListener(event: 'show', listener: (event: Event) => void): this; + removeListener(event: 'show', listener: (event: Event) => void): this; + /** + * Notification + */ + constructor(options?: NotificationConstructorOptions); + /** + * Whether or not desktop notifications are supported on the current system + */ + static isSupported(): boolean; + /** + * Dismisses the notification. + */ + close(): void; + /** + * Immediately shows the notification to the user, please note this means unlike + * the HTML5 Notification implementation, instantiating a `new Notification` does + * not immediately show it to the user, you need to call this method before the OS + * will display it. + * + * If the notification has been shown before, this method will dismiss the + * previously shown notification and create a new one with identical properties. + */ + show(): void; + actions: NotificationAction[]; + body: string; + closeButtonText: string; + hasReply: boolean; + replyPlaceholder: string; + silent: boolean; + sound: string; + subtitle: string; + timeoutType: ('default' | 'never'); + title: string; + toastXml: string; + urgency: ('normal' | 'critical' | 'low'); + } + + interface NotificationAction { + + // Docs: https://electronjs.org/docs/api/structures/notification-action + + /** + * The label for the given action. + */ + text?: string; + /** + * The type of action, can be `button`. + */ + type: ('button'); + } + + interface NotificationResponse { + + // Docs: https://electronjs.org/docs/api/structures/notification-response + + /** + * The identifier string of the action that the user selected. + */ + actionIdentifier: string; + /** + * The delivery date of the notification. + */ + date: number; + /** + * The unique identifier for this notification request. + */ + identifier: string; + /** + * A dictionary of custom information associated with the notification. + */ + userInfo: Record; + /** + * The text entered or chosen by the user. + */ + userText?: string; + } + + interface Point { + + // Docs: https://electronjs.org/docs/api/structures/point + + x: number; + y: number; + } + + interface PostBody { + + // Docs: https://electronjs.org/docs/api/structures/post-body + + /** + * The boundary used to separate multiple parts of the message. Only valid when + * `contentType` is `multipart/form-data`. + */ + boundary?: string; + /** + * The `content-type` header used for the data. One of + * `application/x-www-form-urlencoded` or `multipart/form-data`. Corresponds to the + * `enctype` attribute of the submitted HTML form. + */ + contentType: string; + /** + * The post data to be sent to the new window. + */ + data: Array<(UploadRawData) | (UploadFile)>; + } + + interface PowerMonitor extends NodeJS.EventEmitter { + + // Docs: https://electronjs.org/docs/api/power-monitor + + /** + * Emitted when the system is about to lock the screen. + * + * @platform darwin,win32 + */ + on(event: 'lock-screen', listener: Function): this; + once(event: 'lock-screen', listener: Function): this; + addListener(event: 'lock-screen', listener: Function): this; + removeListener(event: 'lock-screen', listener: Function): this; + /** + * Emitted when the system changes to AC power. + * + * @platform darwin,win32 + */ + on(event: 'on-ac', listener: Function): this; + once(event: 'on-ac', listener: Function): this; + addListener(event: 'on-ac', listener: Function): this; + removeListener(event: 'on-ac', listener: Function): this; + /** + * Emitted when system changes to battery power. + * + * @platform darwin + */ + on(event: 'on-battery', listener: Function): this; + once(event: 'on-battery', listener: Function): this; + addListener(event: 'on-battery', listener: Function): this; + removeListener(event: 'on-battery', listener: Function): this; + /** + * Emitted when system is resuming. + * + * @platform darwin,win32 + */ + on(event: 'resume', listener: Function): this; + once(event: 'resume', listener: Function): this; + addListener(event: 'resume', listener: Function): this; + removeListener(event: 'resume', listener: Function): this; + /** + * Emitted when the system is about to reboot or shut down. If the event handler + * invokes `e.preventDefault()`, Electron will attempt to delay system shutdown in + * order for the app to exit cleanly. If `e.preventDefault()` is called, the app + * should exit as soon as possible by calling something like `app.quit()`. + * + * @platform linux,darwin + */ + on(event: 'shutdown', listener: Function): this; + once(event: 'shutdown', listener: Function): this; + addListener(event: 'shutdown', listener: Function): this; + removeListener(event: 'shutdown', listener: Function): this; + /** + * Emitted when the system is suspending. + * + * @platform darwin,win32 + */ + on(event: 'suspend', listener: Function): this; + once(event: 'suspend', listener: Function): this; + addListener(event: 'suspend', listener: Function): this; + removeListener(event: 'suspend', listener: Function): this; + /** + * Emitted as soon as the systems screen is unlocked. + * + * @platform darwin,win32 + */ + on(event: 'unlock-screen', listener: Function): this; + once(event: 'unlock-screen', listener: Function): this; + addListener(event: 'unlock-screen', listener: Function): this; + removeListener(event: 'unlock-screen', listener: Function): this; + /** + * Emitted when a login session is activated. See documentation for more + * information. + * + * @platform darwin + */ + on(event: 'user-did-become-active', listener: Function): this; + once(event: 'user-did-become-active', listener: Function): this; + addListener(event: 'user-did-become-active', listener: Function): this; + removeListener(event: 'user-did-become-active', listener: Function): this; + /** + * Emitted when a login session is deactivated. See documentation for more + * information. + * + * @platform darwin + */ + on(event: 'user-did-resign-active', listener: Function): this; + once(event: 'user-did-resign-active', listener: Function): this; + addListener(event: 'user-did-resign-active', listener: Function): this; + removeListener(event: 'user-did-resign-active', listener: Function): this; + /** + * The system's current state. Can be `active`, `idle`, `locked` or `unknown`. + * + * Calculate the system idle state. `idleThreshold` is the amount of time (in + * seconds) before considered idle. `locked` is available on supported systems + * only. + */ + getSystemIdleState(idleThreshold: number): ('active' | 'idle' | 'locked' | 'unknown'); + /** + * Idle time in seconds + +Calculate system idle time in seconds. + */ + getSystemIdleTime(): number; + /** + * Whether the system is on battery power. + * + * To monitor for changes in this property, use the `on-battery` and `on-ac` + * events. + */ + isOnBatteryPower(): boolean; + /** + * A `Boolean` property. True if the system is on battery power. + * +See `powerMonitor.isOnBatteryPower()`. + */ + onBatteryPower: boolean; + } + + interface PowerSaveBlocker { + + // Docs: https://electronjs.org/docs/api/power-save-blocker + + /** + * Whether the corresponding `powerSaveBlocker` has started. + */ + isStarted(id: number): boolean; + /** + * The blocker ID that is assigned to this power blocker. + * + * Starts preventing the system from entering lower-power mode. Returns an integer + * identifying the power save blocker. + * + * **Note:** `prevent-display-sleep` has higher precedence over + * `prevent-app-suspension`. Only the highest precedence type takes effect. In + * other words, `prevent-display-sleep` always takes precedence over + * `prevent-app-suspension`. + * + * For example, an API calling A requests for `prevent-app-suspension`, and another + * calling B requests for `prevent-display-sleep`. `prevent-display-sleep` will be + * used until B stops its request. After that, `prevent-app-suspension` is used. + */ + start(type: 'prevent-app-suspension' | 'prevent-display-sleep'): number; + /** + * Stops the specified power save blocker. + */ + stop(id: number): void; + } + + interface PrinterInfo { + + // Docs: https://electronjs.org/docs/api/structures/printer-info + + /** + * a longer description of the printer's type. + */ + description: string; + /** + * the name of the printer as shown in Print Preview. + */ + displayName: string; + /** + * whether or not a given printer is set as the default printer on the OS. + */ + isDefault: boolean; + /** + * the name of the printer as understood by the OS. + */ + name: string; + /** + * an object containing a variable number of platform-specific printer information. + */ + options: Options; + /** + * the current status of the printer. + */ + status: number; + } + + interface ProcessMemoryInfo { + + // Docs: https://electronjs.org/docs/api/structures/process-memory-info + + /** + * The amount of memory not shared by other processes, such as JS heap or HTML + * content in Kilobytes. + */ + private: number; + /** + * The amount of memory currently pinned to actual physical RAM in Kilobytes. + * + * @platform linux,win32 + */ + residentSet: number; + /** + * The amount of memory shared between processes, typically memory consumed by the + * Electron code itself in Kilobytes. + */ + shared: number; + } + + interface ProcessMetric { + + // Docs: https://electronjs.org/docs/api/structures/process-metric + + /** + * CPU usage of the process. + */ + cpu: CPUUsage; + /** + * Creation time for this process. The time is represented as number of + * milliseconds since epoch. Since the `pid` can be reused after a process dies, it + * is useful to use both the `pid` and the `creationTime` to uniquely identify a + * process. + */ + creationTime: number; + /** + * One of the following values: + * + * @platform win32 + */ + integrityLevel?: ('untrusted' | 'low' | 'medium' | 'high' | 'unknown'); + /** + * Memory information for the process. + */ + memory: MemoryInfo; + /** + * The name of the process. Examples for utility: `Audio Service`, `Content + * Decryption Module Service`, `Network Service`, `Video Capture`, etc. + */ + name?: string; + /** + * Process id of the process. + */ + pid: number; + /** + * Whether the process is sandboxed on OS level. + * + * @platform darwin,win32 + */ + sandboxed?: boolean; + /** + * The non-localized name of the process. + */ + serviceName?: string; + /** + * Process type. One of the following values: + */ + type: ('Browser' | 'Tab' | 'Utility' | 'Zygote' | 'Sandbox helper' | 'GPU' | 'Pepper Plugin' | 'Pepper Plugin Broker' | 'Unknown'); + } + + interface Product { + + // Docs: https://electronjs.org/docs/api/structures/product + + /** + * The total size of the content, in bytes. + */ + contentLengths: number[]; + /** + * A string that identifies the version of the content. + */ + contentVersion: string; + /** + * 3 character code presenting a product's currency based on the ISO 4217 standard. + */ + currencyCode: string; + /** + * The locale formatted price of the product. + */ + formattedPrice: string; + /** + * A Boolean value that indicates whether the App Store has downloadable content + * for this product. `true` if at least one file has been associated with the + * product. + */ + isDownloadable: boolean; + /** + * A description of the product. + */ + localizedDescription: string; + /** + * The name of the product. + */ + localizedTitle: string; + /** + * The cost of the product in the local currency. + */ + price: number; + /** + * The string that identifies the product to the Apple App Store. + */ + productIdentifier: string; + } + + interface Protocol { + + // Docs: https://electronjs.org/docs/api/protocol + + /** + * Whether the protocol was successfully intercepted + * + * Intercepts `scheme` protocol and uses `handler` as the protocol's new handler + * which sends a `Buffer` as a response. + */ + interceptBufferProtocol(scheme: string, handler: (request: ProtocolRequest, callback: (response: (Buffer) | (ProtocolResponse)) => void) => void): boolean; + /** + * Whether the protocol was successfully intercepted + * + * Intercepts `scheme` protocol and uses `handler` as the protocol's new handler + * which sends a file as a response. + */ + interceptFileProtocol(scheme: string, handler: (request: ProtocolRequest, callback: (response: (string) | (ProtocolResponse)) => void) => void): boolean; + /** + * Whether the protocol was successfully intercepted + * + * Intercepts `scheme` protocol and uses `handler` as the protocol's new handler + * which sends a new HTTP request as a response. + */ + interceptHttpProtocol(scheme: string, handler: (request: ProtocolRequest, callback: (response: ProtocolResponse) => void) => void): boolean; + /** + * Whether the protocol was successfully intercepted + * + * Same as `protocol.registerStreamProtocol`, except that it replaces an existing + * protocol handler. + */ + interceptStreamProtocol(scheme: string, handler: (request: ProtocolRequest, callback: (response: (NodeJS.ReadableStream) | (ProtocolResponse)) => void) => void): boolean; + /** + * Whether the protocol was successfully intercepted + * + * Intercepts `scheme` protocol and uses `handler` as the protocol's new handler + * which sends a `String` as a response. + */ + interceptStringProtocol(scheme: string, handler: (request: ProtocolRequest, callback: (response: (string) | (ProtocolResponse)) => void) => void): boolean; + /** + * Whether `scheme` is already intercepted. + */ + isProtocolIntercepted(scheme: string): boolean; + /** + * Whether `scheme` is already registered. + */ + isProtocolRegistered(scheme: string): boolean; + /** + * Whether the protocol was successfully registered + * + * Registers a protocol of `scheme` that will send a `Buffer` as a response. + * + * The usage is the same with `registerFileProtocol`, except that the `callback` + * should be called with either a `Buffer` object or an object that has the `data` + * property. + +Example: + */ + registerBufferProtocol(scheme: string, handler: (request: ProtocolRequest, callback: (response: (Buffer) | (ProtocolResponse)) => void) => void): boolean; + /** + * Whether the protocol was successfully registered + * + * Registers a protocol of `scheme` that will send a file as the response. The + * `handler` will be called with `request` and `callback` where `request` is an + * incoming request for the `scheme`. + * + * To handle the `request`, the `callback` should be called with either the file's + * path or an object that has a `path` property, e.g. `callback(filePath)` or + * `callback({ path: filePath })`. The `filePath` must be an absolute path. + * + * By default the `scheme` is treated like `http:`, which is parsed differently + * from protocols that follow the "generic URI syntax" like `file:`. + */ + registerFileProtocol(scheme: string, handler: (request: ProtocolRequest, callback: (response: (string) | (ProtocolResponse)) => void) => void): boolean; + /** + * Whether the protocol was successfully registered + * + * Registers a protocol of `scheme` that will send an HTTP request as a response. + * + * The usage is the same with `registerFileProtocol`, except that the `callback` + * should be called with an object that has the `url` property. + */ + registerHttpProtocol(scheme: string, handler: (request: ProtocolRequest, callback: (response: ProtocolResponse) => void) => void): boolean; + /** + * **Note:** This method can only be used before the `ready` event of the `app` + * module gets emitted and can be called only once. + * + * Registers the `scheme` as standard, secure, bypasses content security policy for + * resources, allows registering ServiceWorker, supports fetch API, and streaming + * video/audio. Specify a privilege with the value of `true` to enable the + * capability. + * + * An example of registering a privileged scheme, that bypasses Content Security + * Policy: + * + * A standard scheme adheres to what RFC 3986 calls generic URI syntax. For example + * `http` and `https` are standard schemes, while `file` is not. + * + * Registering a scheme as standard allows relative and absolute resources to be + * resolved correctly when served. Otherwise the scheme will behave like the `file` + * protocol, but without the ability to resolve relative URLs. + * + * For example when you load following page with custom protocol without + * registering it as standard scheme, the image will not be loaded because + * non-standard schemes can not recognize relative URLs: + * + * Registering a scheme as standard will allow access to files through the + * FileSystem API. Otherwise the renderer will throw a security error for the + * scheme. + * + * By default web storage apis (localStorage, sessionStorage, webSQL, indexedDB, + * cookies) are disabled for non standard schemes. So in general if you want to + * register a custom protocol to replace the `http` protocol, you have to register + * it as a standard scheme. + * + * Protocols that use streams (http and stream protocols) should set `stream: + * true`. The `